Repository: abritinthebay/datejs Branch: master Commit: 3675d46ed96d Files: 733 Total size: 24.6 MB Directory structure: gitextract__b16c9in/ ├── .gitignore ├── .jshintrc ├── .npmignore ├── .travis.yml ├── GruntFile.js ├── LICENSE ├── README.md ├── bower.json ├── build/ │ ├── date-af-ZA.js │ ├── date-ar-AE.js │ ├── date-ar-BH.js │ ├── date-ar-DZ.js │ ├── date-ar-EG.js │ ├── date-ar-IQ.js │ ├── date-ar-JO.js │ ├── date-ar-KW.js │ ├── date-ar-LB.js │ ├── date-ar-LY.js │ ├── date-ar-MA.js │ ├── date-ar-OM.js │ ├── date-ar-QA.js │ ├── date-ar-SA.js │ ├── date-ar-SY.js │ ├── date-ar-TN.js │ ├── date-ar-YE.js │ ├── date-az-Cyrl-AZ.js │ ├── date-az-Latn-AZ.js │ ├── date-be-BY.js │ ├── date-bg-BG.js │ ├── date-bs-Latn-BA.js │ ├── date-ca-ES.js │ ├── date-cs-CZ.js │ ├── date-cy-GB.js │ ├── date-da-DK.js │ ├── date-de-AT.js │ ├── date-de-CH.js │ ├── date-de-DE.js │ ├── date-de-LI.js │ ├── date-de-LU.js │ ├── date-dv-MV.js │ ├── date-el-GR.js │ ├── date-en-029.js │ ├── date-en-AU.js │ ├── date-en-BZ.js │ ├── date-en-CA.js │ ├── date-en-GB.js │ ├── date-en-IE.js │ ├── date-en-JM.js │ ├── date-en-NZ.js │ ├── date-en-PH.js │ ├── date-en-TT.js │ ├── date-en-US.js │ ├── date-en-ZA.js │ ├── date-en-ZW.js │ ├── date-es-AR.js │ ├── date-es-BO.js │ ├── date-es-CL.js │ ├── date-es-CO.js │ ├── date-es-CR.js │ ├── date-es-DO.js │ ├── date-es-EC.js │ ├── date-es-ES.js │ ├── date-es-GT.js │ ├── date-es-HN.js │ ├── date-es-MX.js │ ├── date-es-NI.js │ ├── date-es-PA.js │ ├── date-es-PE.js │ ├── date-es-PR.js │ ├── date-es-PY.js │ ├── date-es-SV.js │ ├── date-es-UY.js │ ├── date-es-VE.js │ ├── date-et-EE.js │ ├── date-eu-ES.js │ ├── date-fa-IR.js │ ├── date-fi-FI.js │ ├── date-fo-FO.js │ ├── date-fr-BE.js │ ├── date-fr-CA.js │ ├── date-fr-CH.js │ ├── date-fr-FR.js │ ├── date-fr-LU.js │ ├── date-fr-MC.js │ ├── date-gl-ES.js │ ├── date-gu-IN.js │ ├── date-he-IL.js │ ├── date-hi-IN.js │ ├── date-hr-BA.js │ ├── date-hr-HR.js │ ├── date-hu-HU.js │ ├── date-hy-AM.js │ ├── date-id-ID.js │ ├── date-is-IS.js │ ├── date-it-CH.js │ ├── date-it-IT.js │ ├── date-ja-JP.js │ ├── date-ka-GE.js │ ├── date-kk-KZ.js │ ├── date-kn-IN.js │ ├── date-ko-KR.js │ ├── date-kok-IN.js │ ├── date-ky-KG.js │ ├── date-lt-LT.js │ ├── date-lv-LV.js │ ├── date-mi-NZ.js │ ├── date-mk-MK.js │ ├── date-mn-MN.js │ ├── date-mr-IN.js │ ├── date-ms-BN.js │ ├── date-ms-MY.js │ ├── date-mt-MT.js │ ├── date-nb-NO.js │ ├── date-nl-BE.js │ ├── date-nl-NL.js │ ├── date-nn-NO.js │ ├── date-ns-ZA.js │ ├── date-pa-IN.js │ ├── date-pl-PL.js │ ├── date-pt-BR.js │ ├── date-pt-PT.js │ ├── date-quz-BO.js │ ├── date-quz-EC.js │ ├── date-quz-PE.js │ ├── date-ro-RO.js │ ├── date-ru-RU.js │ ├── date-sa-IN.js │ ├── date-se-FI.js │ ├── date-se-NO.js │ ├── date-se-SE.js │ ├── date-sk-SK.js │ ├── date-sl-SI.js │ ├── date-sma-NO.js │ ├── date-sma-SE.js │ ├── date-smj-NO.js │ ├── date-smj-SE.js │ ├── date-smn-FI.js │ ├── date-sms-FI.js │ ├── date-sq-AL.js │ ├── date-sr-Cyrl-BA.js │ ├── date-sr-Cyrl-CS.js │ ├── date-sr-Latn-BA.js │ ├── date-sr-Latn-CS.js │ ├── date-sv-FI.js │ ├── date-sv-SE.js │ ├── date-sw-KE.js │ ├── date-syr-SY.js │ ├── date-ta-IN.js │ ├── date-te-IN.js │ ├── date-th-TH.js │ ├── date-tn-ZA.js │ ├── date-tr-TR.js │ ├── date-tt-RU.js │ ├── date-uk-UA.js │ ├── date-ur-PK.js │ ├── date-uz-Cyrl-UZ.js │ ├── date-uz-Latn-UZ.js │ ├── date-vi-VN.js │ ├── date-xh-ZA.js │ ├── date-zh-CN.js │ ├── date-zh-HK.js │ ├── date-zh-MO.js │ ├── date-zh-SG.js │ ├── date-zh-TW.js │ ├── date-zu-ZA.js │ ├── date.js │ ├── i18n/ │ │ ├── af-ZA.js │ │ ├── ar-AE.js │ │ ├── ar-BH.js │ │ ├── ar-DZ.js │ │ ├── ar-EG.js │ │ ├── ar-IQ.js │ │ ├── ar-JO.js │ │ ├── ar-KW.js │ │ ├── ar-LB.js │ │ ├── ar-LY.js │ │ ├── ar-MA.js │ │ ├── ar-OM.js │ │ ├── ar-QA.js │ │ ├── ar-SA.js │ │ ├── ar-SY.js │ │ ├── ar-TN.js │ │ ├── ar-YE.js │ │ ├── az-Cyrl-AZ.js │ │ ├── az-Latn-AZ.js │ │ ├── be-BY.js │ │ ├── bg-BG.js │ │ ├── bs-Latn-BA.js │ │ ├── ca-ES.js │ │ ├── cs-CZ.js │ │ ├── cy-GB.js │ │ ├── da-DK.js │ │ ├── de-AT.js │ │ ├── de-CH.js │ │ ├── de-DE.js │ │ ├── de-LI.js │ │ ├── de-LU.js │ │ ├── dv-MV.js │ │ ├── el-GR.js │ │ ├── en-029.js │ │ ├── en-AU.js │ │ ├── en-BZ.js │ │ ├── en-CA.js │ │ ├── en-GB.js │ │ ├── en-IE.js │ │ ├── en-JM.js │ │ ├── en-NZ.js │ │ ├── en-PH.js │ │ ├── en-TT.js │ │ ├── en-ZA.js │ │ ├── en-ZW.js │ │ ├── es-AR.js │ │ ├── es-BO.js │ │ ├── es-CL.js │ │ ├── es-CO.js │ │ ├── es-CR.js │ │ ├── es-DO.js │ │ ├── es-EC.js │ │ ├── es-ES.js │ │ ├── es-GT.js │ │ ├── es-HN.js │ │ ├── es-MX.js │ │ ├── es-NI.js │ │ ├── es-PA.js │ │ ├── es-PE.js │ │ ├── es-PR.js │ │ ├── es-PY.js │ │ ├── es-SV.js │ │ ├── es-UY.js │ │ ├── es-VE.js │ │ ├── et-EE.js │ │ ├── eu-ES.js │ │ ├── fa-IR.js │ │ ├── fi-FI.js │ │ ├── fo-FO.js │ │ ├── fr-BE.js │ │ ├── fr-CA.js │ │ ├── fr-CH.js │ │ ├── fr-FR.js │ │ ├── fr-LU.js │ │ ├── fr-MC.js │ │ ├── gl-ES.js │ │ ├── gu-IN.js │ │ ├── he-IL.js │ │ ├── hi-IN.js │ │ ├── hr-BA.js │ │ ├── hr-HR.js │ │ ├── hu-HU.js │ │ ├── hy-AM.js │ │ ├── id-ID.js │ │ ├── is-IS.js │ │ ├── it-CH.js │ │ ├── it-IT.js │ │ ├── ja-JP.js │ │ ├── ka-GE.js │ │ ├── kk-KZ.js │ │ ├── kn-IN.js │ │ ├── ko-KR.js │ │ ├── kok-IN.js │ │ ├── ky-KG.js │ │ ├── lt-LT.js │ │ ├── lv-LV.js │ │ ├── mi-NZ.js │ │ ├── mk-MK.js │ │ ├── mn-MN.js │ │ ├── mr-IN.js │ │ ├── ms-BN.js │ │ ├── ms-MY.js │ │ ├── mt-MT.js │ │ ├── nb-NO.js │ │ ├── nl-BE.js │ │ ├── nl-NL.js │ │ ├── nn-NO.js │ │ ├── ns-ZA.js │ │ ├── pa-IN.js │ │ ├── pl-PL.js │ │ ├── pt-BR.js │ │ ├── pt-PT.js │ │ ├── quz-BO.js │ │ ├── quz-EC.js │ │ ├── quz-PE.js │ │ ├── ro-RO.js │ │ ├── ru-RU.js │ │ ├── sa-IN.js │ │ ├── se-FI.js │ │ ├── se-NO.js │ │ ├── se-SE.js │ │ ├── sk-SK.js │ │ ├── sl-SI.js │ │ ├── sma-NO.js │ │ ├── sma-SE.js │ │ ├── smj-NO.js │ │ ├── smj-SE.js │ │ ├── smn-FI.js │ │ ├── sms-FI.js │ │ ├── sq-AL.js │ │ ├── sr-Cyrl-BA.js │ │ ├── sr-Cyrl-CS.js │ │ ├── sr-Latn-BA.js │ │ ├── sr-Latn-CS.js │ │ ├── sv-FI.js │ │ ├── sv-SE.js │ │ ├── sw-KE.js │ │ ├── syr-SY.js │ │ ├── ta-IN.js │ │ ├── te-IN.js │ │ ├── th-TH.js │ │ ├── tn-ZA.js │ │ ├── tr-TR.js │ │ ├── tt-RU.js │ │ ├── uk-UA.js │ │ ├── ur-PK.js │ │ ├── uz-Cyrl-UZ.js │ │ ├── uz-Latn-UZ.js │ │ ├── vi-VN.js │ │ ├── xh-ZA.js │ │ ├── zh-CN.js │ │ ├── zh-HK.js │ │ ├── zh-MO.js │ │ ├── zh-SG.js │ │ ├── zh-TW.js │ │ └── zu-ZA.js │ └── production/ │ └── i18n/ │ ├── af-ZA.js │ ├── ar-AE.js │ ├── ar-BH.js │ ├── ar-DZ.js │ ├── ar-EG.js │ ├── ar-IQ.js │ ├── ar-JO.js │ ├── ar-KW.js │ ├── ar-LB.js │ ├── ar-LY.js │ ├── ar-MA.js │ ├── ar-OM.js │ ├── ar-QA.js │ ├── ar-SA.js │ ├── ar-SY.js │ ├── ar-TN.js │ ├── ar-YE.js │ ├── az-Cyrl-AZ.js │ ├── az-Latn-AZ.js │ ├── be-BY.js │ ├── bg-BG.js │ ├── bs-Latn-BA.js │ ├── ca-ES.js │ ├── cs-CZ.js │ ├── cy-GB.js │ ├── da-DK.js │ ├── de-AT.js │ ├── de-CH.js │ ├── de-DE.js │ ├── de-LI.js │ ├── de-LU.js │ ├── dv-MV.js │ ├── el-GR.js │ ├── en-029.js │ ├── en-AU.js │ ├── en-BZ.js │ ├── en-CA.js │ ├── en-GB.js │ ├── en-IE.js │ ├── en-JM.js │ ├── en-NZ.js │ ├── en-PH.js │ ├── en-TT.js │ ├── en-ZA.js │ ├── en-ZW.js │ ├── es-AR.js │ ├── es-BO.js │ ├── es-CL.js │ ├── es-CO.js │ ├── es-CR.js │ ├── es-DO.js │ ├── es-EC.js │ ├── es-ES.js │ ├── es-GT.js │ ├── es-HN.js │ ├── es-MX.js │ ├── es-NI.js │ ├── es-PA.js │ ├── es-PE.js │ ├── es-PR.js │ ├── es-PY.js │ ├── es-SV.js │ ├── es-UY.js │ ├── es-VE.js │ ├── et-EE.js │ ├── eu-ES.js │ ├── fa-IR.js │ ├── fi-FI.js │ ├── fo-FO.js │ ├── fr-BE.js │ ├── fr-CA.js │ ├── fr-CH.js │ ├── fr-FR.js │ ├── fr-LU.js │ ├── fr-MC.js │ ├── gl-ES.js │ ├── gu-IN.js │ ├── he-IL.js │ ├── hi-IN.js │ ├── hr-BA.js │ ├── hr-HR.js │ ├── hu-HU.js │ ├── hy-AM.js │ ├── id-ID.js │ ├── is-IS.js │ ├── it-CH.js │ ├── it-IT.js │ ├── ja-JP.js │ ├── ka-GE.js │ ├── kk-KZ.js │ ├── kn-IN.js │ ├── ko-KR.js │ ├── kok-IN.js │ ├── ky-KG.js │ ├── lt-LT.js │ ├── lv-LV.js │ ├── mi-NZ.js │ ├── mk-MK.js │ ├── mn-MN.js │ ├── mr-IN.js │ ├── ms-BN.js │ ├── ms-MY.js │ ├── mt-MT.js │ ├── nb-NO.js │ ├── nl-BE.js │ ├── nl-NL.js │ ├── nn-NO.js │ ├── ns-ZA.js │ ├── pa-IN.js │ ├── pl-PL.js │ ├── pt-BR.js │ ├── pt-PT.js │ ├── quz-BO.js │ ├── quz-EC.js │ ├── quz-PE.js │ ├── ro-RO.js │ ├── ru-RU.js │ ├── sa-IN.js │ ├── se-FI.js │ ├── se-NO.js │ ├── se-SE.js │ ├── sk-SK.js │ ├── sl-SI.js │ ├── sma-NO.js │ ├── sma-SE.js │ ├── smj-NO.js │ ├── smj-SE.js │ ├── smn-FI.js │ ├── sms-FI.js │ ├── sq-AL.js │ ├── sr-Cyrl-BA.js │ ├── sr-Cyrl-CS.js │ ├── sr-Latn-BA.js │ ├── sr-Latn-CS.js │ ├── sv-FI.js │ ├── sv-SE.js │ ├── sw-KE.js │ ├── syr-SY.js │ ├── ta-IN.js │ ├── te-IN.js │ ├── th-TH.js │ ├── tn-ZA.js │ ├── tr-TR.js │ ├── tt-RU.js │ ├── uk-UA.js │ ├── ur-PK.js │ ├── uz-Cyrl-UZ.js │ ├── uz-Latn-UZ.js │ ├── vi-VN.js │ ├── xh-ZA.js │ ├── zh-CN.js │ ├── zh-HK.js │ ├── zh-MO.js │ ├── zh-SG.js │ ├── zh-TW.js │ └── zu-ZA.js ├── index.js ├── package.json ├── reports/ │ ├── coverage.json │ ├── lcov-report/ │ │ ├── core/ │ │ │ ├── core-prototypes.js.html │ │ │ ├── core.js.html │ │ │ ├── extras.js.html │ │ │ ├── format_parser.js.html │ │ │ ├── i18n.js.html │ │ │ ├── index.html │ │ │ ├── parser.js.html │ │ │ ├── parsing_grammar.js.html │ │ │ ├── parsing_operators.js.html │ │ │ ├── parsing_translator.js.html │ │ │ ├── sugarpak.js.html │ │ │ ├── time_period.js.html │ │ │ └── time_span.js.html │ │ ├── index.html │ │ ├── prettify.css │ │ └── prettify.js │ └── lcov.info ├── specs/ │ ├── Core-spec.js │ ├── DateMath-spec.js │ ├── Extras-spec.js │ ├── I18n-spec.js │ ├── ISOparsing-spec.js │ ├── Parsing-spec.js │ ├── SpecRunner.html │ ├── Sugarpak-spec.js │ └── jasmine-2.0.3/ │ ├── boot.js │ ├── console.js │ ├── jasmine-html.js │ ├── jasmine.css │ ├── jasmine.js │ └── specrunner.tmpl ├── src/ │ ├── core/ │ │ ├── core-prototypes.js │ │ ├── core.js │ │ ├── extras.js │ │ ├── format_parser.js │ │ ├── i18n.js │ │ ├── parser.js │ │ ├── parsing_grammar.js │ │ ├── parsing_operators.js │ │ ├── parsing_translator.js │ │ ├── sugarpak.js │ │ ├── time_period.js │ │ └── time_span.js │ ├── i18n/ │ │ ├── af-ZA.js │ │ ├── ar-AE.js │ │ ├── ar-BH.js │ │ ├── ar-DZ.js │ │ ├── ar-EG.js │ │ ├── ar-IQ.js │ │ ├── ar-JO.js │ │ ├── ar-KW.js │ │ ├── ar-LB.js │ │ ├── ar-LY.js │ │ ├── ar-MA.js │ │ ├── ar-OM.js │ │ ├── ar-QA.js │ │ ├── ar-SA.js │ │ ├── ar-SY.js │ │ ├── ar-TN.js │ │ ├── ar-YE.js │ │ ├── az-Cyrl-AZ.js │ │ ├── az-Latn-AZ.js │ │ ├── be-BY.js │ │ ├── bg-BG.js │ │ ├── bs-Latn-BA.js │ │ ├── ca-ES.js │ │ ├── cs-CZ.js │ │ ├── cy-GB.js │ │ ├── da-DK.js │ │ ├── de-AT.js │ │ ├── de-CH.js │ │ ├── de-DE.js │ │ ├── de-LI.js │ │ ├── de-LU.js │ │ ├── dv-MV.js │ │ ├── el-GR.js │ │ ├── en-029.js │ │ ├── en-AU.js │ │ ├── en-BZ.js │ │ ├── en-CA.js │ │ ├── en-GB.js │ │ ├── en-IE.js │ │ ├── en-JM.js │ │ ├── en-NZ.js │ │ ├── en-PH.js │ │ ├── en-TT.js │ │ ├── en-ZA.js │ │ ├── en-ZW.js │ │ ├── es-AR.js │ │ ├── es-BO.js │ │ ├── es-CL.js │ │ ├── es-CO.js │ │ ├── es-CR.js │ │ ├── es-DO.js │ │ ├── es-EC.js │ │ ├── es-ES.js │ │ ├── es-GT.js │ │ ├── es-HN.js │ │ ├── es-MX.js │ │ ├── es-NI.js │ │ ├── es-PA.js │ │ ├── es-PE.js │ │ ├── es-PR.js │ │ ├── es-PY.js │ │ ├── es-SV.js │ │ ├── es-UY.js │ │ ├── es-VE.js │ │ ├── et-EE.js │ │ ├── eu-ES.js │ │ ├── fa-IR.js │ │ ├── fi-FI.js │ │ ├── fo-FO.js │ │ ├── fr-BE.js │ │ ├── fr-CA.js │ │ ├── fr-CH.js │ │ ├── fr-FR.js │ │ ├── fr-LU.js │ │ ├── fr-MC.js │ │ ├── gl-ES.js │ │ ├── gu-IN.js │ │ ├── he-IL.js │ │ ├── hi-IN.js │ │ ├── hr-BA.js │ │ ├── hr-HR.js │ │ ├── hu-HU.js │ │ ├── hy-AM.js │ │ ├── id-ID.js │ │ ├── is-IS.js │ │ ├── it-CH.js │ │ ├── it-IT.js │ │ ├── ja-JP.js │ │ ├── ka-GE.js │ │ ├── kk-KZ.js │ │ ├── kn-IN.js │ │ ├── ko-KR.js │ │ ├── kok-IN.js │ │ ├── ky-KG.js │ │ ├── lt-LT.js │ │ ├── lv-LV.js │ │ ├── mi-NZ.js │ │ ├── mk-MK.js │ │ ├── mn-MN.js │ │ ├── mr-IN.js │ │ ├── ms-BN.js │ │ ├── ms-MY.js │ │ ├── mt-MT.js │ │ ├── nb-NO.js │ │ ├── nl-BE.js │ │ ├── nl-NL.js │ │ ├── nn-NO.js │ │ ├── ns-ZA.js │ │ ├── pa-IN.js │ │ ├── pl-PL.js │ │ ├── pt-BR.js │ │ ├── pt-PT.js │ │ ├── quz-BO.js │ │ ├── quz-EC.js │ │ ├── quz-PE.js │ │ ├── ro-RO.js │ │ ├── ru-RU.js │ │ ├── sa-IN.js │ │ ├── se-FI.js │ │ ├── se-NO.js │ │ ├── se-SE.js │ │ ├── sk-SK.js │ │ ├── sl-SI.js │ │ ├── sma-NO.js │ │ ├── sma-SE.js │ │ ├── smj-NO.js │ │ ├── smj-SE.js │ │ ├── smn-FI.js │ │ ├── sms-FI.js │ │ ├── sq-AL.js │ │ ├── sr-Cyrl-BA.js │ │ ├── sr-Cyrl-CS.js │ │ ├── sr-Latn-BA.js │ │ ├── sr-Latn-CS.js │ │ ├── sv-FI.js │ │ ├── sv-SE.js │ │ ├── sw-KE.js │ │ ├── syr-SY.js │ │ ├── ta-IN.js │ │ ├── te-IN.js │ │ ├── th-TH.js │ │ ├── tn-ZA.js │ │ ├── tr-TR.js │ │ ├── tt-RU.js │ │ ├── uk-UA.js │ │ ├── ur-PK.js │ │ ├── uz-Cyrl-UZ.js │ │ ├── uz-Latn-UZ.js │ │ ├── vi-VN.js │ │ ├── xh-ZA.js │ │ ├── zh-CN.js │ │ ├── zh-HK.js │ │ ├── zh-MO.js │ │ ├── zh-SG.js │ │ ├── zh-TW.js │ │ └── zu-ZA.js │ └── i18n-template.js └── tests/ ├── core/ │ ├── index.html │ └── index.js ├── culture_info/ │ ├── index.html │ └── index.js ├── date/ │ ├── index.html │ └── index.js ├── date2/ │ ├── date2.js │ └── index.html ├── date_and_time/ │ ├── index.html │ └── index.js ├── dst/ │ ├── index.html │ └── index.js ├── index.html ├── jQuery/ │ ├── datepicker.css │ ├── datepicker.html │ ├── datepicker.js │ └── datepicker_datejs.js ├── parseExact/ │ ├── index.html │ └── index.js ├── partial/ │ ├── index.html │ └── index.js ├── performance/ │ ├── bulk.css │ ├── index.html │ └── index.js ├── relative/ │ ├── index.html │ └── index.js ├── relative_date_and_time/ │ ├── index.html │ └── index.js ├── rememberthemilk/ │ ├── index.html │ └── index.js ├── ruby_chronic/ │ ├── index.html │ └── index.js ├── scripts/ │ ├── Date_Ext.js │ ├── cruiser.js │ ├── date-functions.js │ ├── debugging.js │ ├── enumerable.js │ ├── firebug/ │ │ ├── firebug.css │ │ ├── firebug.html │ │ ├── firebug.js │ │ └── firebugx.js │ ├── jquery-1.2.1.pack.js │ ├── specifications.js │ └── specifications_original.js ├── styles/ │ ├── chart.css │ └── specifications.css ├── sugarpak/ │ ├── index.html │ └── index.js ├── time/ │ ├── index.html │ └── index.js └── tostring/ ├── index.html └── index.js ================================================ FILE CONTENTS ================================================ ================================================ FILE: .gitignore ================================================ node_modules/* .grunt/* ================================================ FILE: .jshintrc ================================================ { "bitwise": true, "curly": true, "eqeqeq": true, "forin": true, "immed": true, "latedef": true, "newcap": true, "noarg": true, "nonew": true, "quotmark": true, "undef": false, "unused": true, "trailing": true, "asi": false, "boss": false, "eqnull": true, "evil": false, "funcscope": false, "globalstrict": false, "laxcomma": false, "laxbreak": false, "loopfunc": false, "sub": false, "smarttabs": true, "supernew": false, "browser": true, "jquery": true, "node": true, "nonstandard": true } ================================================ FILE: .npmignore ================================================ build/* build/development/* build/production/* tests/* specs/* .travis.yml bower.json Gruntfile.js ================================================ FILE: .travis.yml ================================================ env: global: - secure: DG9gn0YVLiDRt93E9q/XpBiya/KhUncXhqL46xw32S52qh4kq//5wxIAZefwcpdq+VaP4kLfayBu/9Rt5enJvXUP/K7nyPHT+veNv03zwffClPiDXvNi61FDl4wQ5Z0MbNlsiDLSg8OG9fpzwGqAwGP0UWuepJqKcmuH2tAoYqk= - secure: kzB/ikqg9kyes4VlGvDTjECiE5TOeCwCjNLtg6b/m6vxUeTKYN1xinRKg9yPtfPLTsl0MghjuIA50fy/kKhfzsEn5Ce6GzAahiuqxvfOd6uafZ8GOADMiZJ9vQkUdz6U+UfHmVFMMVM/OP8SuqhWNyOPKABJejObxS/oKYUQHME= - secure: d5YSjmCB1Mdkf3OOnDs+euroW5ZY4O8P/r1q0YvR8ltjnYrJM9Y/YDTqcFMH+SgZriC/YuIBFaes0YOtNNvJL6vc8jcO/p3MZD5GDH1pc/vGcnpP3iQqKOi54d9jfTj9+vWDsqhRDBo+8ObXtvMnzOuVul1OJc+MQp+D9nm5PLY= language: node_js notifications: email: false install: - npm install - npm i -g jasmine-node@2.0.0-beta4 - npm install -g codeclimate-test-reporter node_js: - "0.10" - "0.11" ================================================ FILE: GruntFile.js ================================================ // GruntFile for building the final compiled files from the core. // Run using NodeJS and the Grunt module var fs = require("fs"); var dirs = { core: "src/core", i18n: "src/i18n", build: "build" }; var getI18NFiles = function () { return fs.readdirSync(dirs.i18n); }; var buildMinifyFileList = function (dev) { var output_path = dev ? "" : "production/"; var output_ext = dev ? "." : ".min."; var files = getI18NFiles(); var output = {}; files.map(function(item){ var file_core_name = "date-" + item.replace(".js", ""); var dest = dirs.build + "/"+output_path + file_core_name + output_ext + "js"; output[dest] = [dirs.build + "/" + file_core_name + ".js"]; return dest; }); output[dirs.build + "/"+output_path + "date"+output_ext+"js"] = [dirs.build + "/" + "date.js"]; return output; }; var banner = "/** \n" + " * @overview <%= pkg.name %>\n" + " * @version <%= pkg.version %>\n" + " * @author <%= pkg.author.name %> <<%= pkg.author.email %>>\n" + " * @copyright <%= grunt.template.today('yyyy') %> <%= pkg.author.name %>\n" + " * @license <%= pkg.license %>\n" + " * @homepage <%= pkg.homepage %>\n" + " */"; module.exports = function(grunt) { // Project configuration. grunt.initConfig({ pkg: grunt.file.readJSON("package.json"), dirs: dirs, build_dev: { description: "Builds files designed for easy debugging on dev enviroments (non-minified)" }, build_prod: { description: "Builds production ready files (minified)" }, closurecompiler: { minify: { files: buildMinifyFileList(), options: { "compilation_level": "SIMPLE_OPTIMIZATIONS", "max_processes": 5, "banner": banner } } }, concat: { options: { separator: "\n", banner: banner, nonull: true }, core: { src: [ "<%= dirs.core %>/i18n.js", "<%= dirs.core %>/core.js", "<%= dirs.core %>/core-prototypes.js", "<%= dirs.core %>/sugarpak.js", "<%= dirs.core %>/format_parser.js", "<%= dirs.core %>/parsing_operators.js", "<%= dirs.core %>/parsing_translator.js", "<%= dirs.core %>/parsing_grammar.js", "<%= dirs.core %>/parser.js", "<%= dirs.core %>/extras.js", "<%= dirs.core %>/time_span.js", "<%= dirs.core %>/time_period.js" ], dest: "<%= dirs.build %>/date-core.js" }, basic: { src: [ "<%= dirs.core %>/i18n.js", "<%= dirs.core %>/core.js", "<%= dirs.core %>/core-prototypes.js", "<%= dirs.core %>/sugarpak.js", "<%= dirs.core %>/format_parser.js", "<%= dirs.core %>/parsing_operators.js", "<%= dirs.core %>/parsing_translator.js", "<%= dirs.core %>/parsing_grammar.js", "<%= dirs.core %>/parser.js", "<%= dirs.core %>/extras.js", "<%= dirs.core %>/time_span.js", "<%= dirs.core %>/time_period.js" ], dest: "<%= dirs.build %>/date.js" } }, i18n: { core: { core: "<%= dirs.build %>/date-core.js", src: ["<%= dirs.i18n %>/*.js"], dest: "<%= dirs.build %>/" // destination *directory*, probably better than specifying same file names twice } }, shell: { updateCodeClimate: { command: "codeclimate < reports/lcov.info", options: { stdout: true, stderr: true, failOnError: true } } }, jasmine : { src : [ "src/core/i18n.js", "src/core/core.js", "src/core/core-prototypes.js", "src/core/sugarpak.js", "src/core/format_parser.js", "src/core/parsing_operators.js", "src/core/parsing_translator.js", "src/core/parsing_grammar.js", "src/core/parser.js", "src/core/extras.js", "src/core/time_period.js", "src/core/time_span.js" ], options : { specs : "specs/*-spec.js", template : require("grunt-template-jasmine-istanbul"), templateOptions: { template: "specs/jasmine-2.0.3/specrunner.tmpl", coverage: "reports/coverage.json", report: { type: "lcov", options: { replace: true, dir: "reports/" } } } } }, }); grunt.registerMultiTask("i18n", "Wraps DateJS core with Internationalization info.", function() { var data = this.data, path = require("path"), dest = grunt.template.process(data.dest), files = grunt.file.expand(data.src), core = grunt.file.read(grunt.template.process(data.core)), sep = grunt.util.linefeed, banner_compiled = grunt.template.process(banner); files.forEach(function(f) { var p = dest + "/" + "date-" + path.basename(f), contents = grunt.file.read(f); grunt.file.write(p, banner_compiled + sep + contents + sep + core ); grunt.log.writeln("File \"" + p + "\" created."); }); grunt.file.delete(dirs.build+"/date-core.js"); }); grunt.registerMultiTask("build_dev", "Builds compiled, non-minfied, files for development enviroments", function() { grunt.task.run(["concat:core", "concat:basic", "i18n:core"]); }); grunt.registerMultiTask("build_prod", "Rebuilds dev and minifies files for production enviroments", function() { grunt.task.run(["concat:core", "concat:basic", "i18n:core", "closurecompiler:minify"]); }); grunt.loadNpmTasks("grunt-contrib-jasmine"); // now set the default grunt.registerTask("default", ["build_dev"]); // Load the plugin that provides the "minify" task. grunt.loadNpmTasks("grunt-shell"); grunt.loadNpmTasks("grunt-closurecompiler"); grunt.loadNpmTasks("grunt-contrib-concat"); grunt.registerTask("test", ["jasmine", "shell:updateCodeClimate"]); }; ================================================ FILE: LICENSE ================================================ The MIT License (MIT) Copyright (c) 2013 Gregory Wild-Smith Original Project Copyright (c) 2006-2008 Geoffrey McGill at Cooline Inc. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ================================================ FILE: README.md ================================================ # DateJS: Evolved The JavaScript Date Library [![Build Status](https://travis-ci.org/abritinthebay/datejs.svg?branch=master)](https://travis-ci.org/abritinthebay/datejs) [![NPM version](https://badge.fury.io/js/datejs.svg)](http://badge.fury.io/js/datejs) [![Code Climate](https://codeclimate.com/github/abritinthebay/datejs.svg)](https://codeclimate.com/github/abritinthebay/datejs) [![Test Coverage](https://codeclimate.com/github/abritinthebay/datejs/badges/coverage.svg)](https://codeclimate.com/github/abritinthebay/datejs) ## What is it? DateJS extends the built-in JavaScript Date object to add much better parsing, internationalization support, and all the functions and syntactic sugar you could wish for. ### Background Date JS was started by Geoffrey McGill in 2007, he abandoned it on May 13th 2008; leaving the Google Code repository stagnant and with many bugs unresolved. This fork was started improve and maintain DateJS. To keep what is still the most full featured JavaScript Date library alive, maintained, and improved. Currently we're on track towards a 1.0 release - having fixed almost all the existing bugs and added several new features, improved parsing, and many other changes. ### How to Install/Use DateJS supports running either your regular web browser as a client library or Node.js. #### In Node.js Installation is as easy as running: npm install datejs To run just `require('datejs')` and DateJS will extend the built in Date object like it does in the browser. #### For a Browser If you use [Bower](http://bower.io/) to manage your frontend packages then it's also really simple: bower install datejs Otherwise... * For production environments include [the production ready minified file from the Build directory](https://github.com/abritinthebay/datejs/blob/master/build/production/date.min.js) on your page. * For debugging (eg, in development) include [the unminified and fully commented version](https://github.com/abritinthebay/datejs/blob/master/build/date.js) #### International Language Versions DateJS supports 157 different languages and dialects and ships with US English as the default. It is however easily changed and you can support languages on the fly or just a specific subset. ##### In Node.js Just call the following: `Date.i18n.setLanguage([country code])` Where "country code" is the appropriate IETF code for the language (e.g. "de-DE", or "es-MX") and DateJS will import the correct strings for that language. ##### In a Browser For browsers DateJS has langauge support in one of two ways: 1. Set `Date.Config.i18n` to the location of [the internationalization files](https://github.com/abritinthebay/datejs/blob/master/build/i18n/) on your server and DateJS will dynamically load the files by dynamic script element insertion. You can support all languages this way. 2. Or download the appropriate file from [the Build directory of your choice](https://github.com/abritinthebay/datejs/blob/master/build/). Files are named after the IETF code the load (i.e. `date-es-MX.js` loads Mexican Spanish). This static method will _only_ allow you support of the selected language & US English. DateJS +will always support loading US English_ via `Date.i18n.setLanguage("en-US")` no matter what other language is specifically loaded. So you can always support both your localization and the English speaking world. ## File Structure * `build/` Output from the Grunt powered build process * Non-minified files with full comments. Suitable for development environments. * `production/` Fully minified (by Google's Closure Compiler) files suitable for production. * `src` All the source files used to build the final files. * `core/` The main DateJS source files. * `i18n/` Internationalization files. Language specifics (days of the week, regex formats,etc). Organized by IETF language tag (eg - en-US, etc). * `specs/` Unit Tests written using [Jasmine](https://jasmine.github.io/). Code coverage is calculated by [BlanketJS](http://blanketjs.org/). * `reports/` Code coverage reports in `lcov` and `html` that are generated by [Istanbul](http://gotwarlost.github.io/istanbul/) * `tests/` Orginal unit tests for 2008 project. *Deprecated* ================================================ FILE: bower.json ================================================ { "name": "DateJS", "version": "1.0.0-rc1", "homepage": "https://github.com/abritinthebay/datejs", "authors": [ "Gregory Wild-Smith" ], "description": "Datejs is an open-source JavaScript Date Library.", "main": "build/production/date.min.js", "keywords": [ "date", "javascript", "js", "mit" ], "license": "MIT", "ignore": [ "**/.*", "node_modules", "bower_components", "test", "tests", "specs" ] } ================================================ FILE: build/date-af-ZA.js ================================================ /** * @overview datejs * @version 1.0.0-rc3 * @author Gregory Wild-Smith * @copyright 2015 Gregory Wild-Smith * @license MIT * @homepage https://github.com/abritinthebay/datejs */ /* * DateJS Culture String File * Country Code: af-ZA * Name: Afrikaans (South Africa) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["af-ZA"] = { "name": "af-ZA", "englishName": "Afrikaans (South Africa)", "nativeName": "Afrikaans (Suid Afrika)", "Sunday": "Sondag", "Monday": "Maandag", "Tuesday": "Dinsdag", "Wednesday": "Woensdag", "Thursday": "Donderdag", "Friday": "Vrydag", "Saturday": "Saterdag", "Sun": "Son", "Mon": "Maan", "Tue": "Dins", "Wed": "Woen", "Thu": "Dond", "Fri": "Vry", "Sat": "Sat", "Su": "So", "Mo": "Ma", "Tu": "Di", "We": "Wo", "Th": "Do", "Fr": "Vr", "Sa": "Sa", "S_Sun_Initial": "S", "M_Mon_Initial": "M", "T_Tue_Initial": "D", "W_Wed_Initial": "W", "T_Thu_Initial": "D", "F_Fri_Initial": "V", "S_Sat_Initial": "S", "January": "Januarie", "February": "Februarie", "March": "Maart", "April": "April", "May": "Mei", "June": "Junie", "July": "Julie", "August": "Augustus", "September": "September", "October": "Oktober", "November": "November", "December": "Desember", "Jan_Abbr": "Jan", "Feb_Abbr": "Feb", "Mar_Abbr": "Mar", "Apr_Abbr": "Apr", "May_Abbr": "Mei", "Jun_Abbr": "Jun", "Jul_Abbr": "Jul", "Aug_Abbr": "Aug", "Sep_Abbr": "Sep", "Oct_Abbr": "Okt", "Nov_Abbr": "Nov", "Dec_Abbr": "Des", "AM": "", "PM": "nm", "firstDayOfWeek": 0, "twoDigitYearMax": 2029, "mdy": "ymd", "M/d/yyyy": "yyyy/MM/dd", "dddd, MMMM dd, yyyy": "dd MMMM yyyy", "h:mm tt": "hh:mm tt", "h:mm:ss tt": "hh:mm:ss tt", "dddd, MMMM dd, yyyy h:mm:ss tt": "dd MMMM yyyy hh:mm:ss tt", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "dd MMMM", "MMMM, yyyy": "MMMM yyyy", "/jan(uary)?/": "jan(uarie)?", "/feb(ruary)?/": "feb(ruarie)?", "/mar(ch)?/": "maart", "/apr(il)?/": "apr(il)?", "/may/": "mei", "/jun(e)?/": "jun(ie)?", "/jul(y)?/": "jul(ie)?", "/aug(ust)?/": "aug(ustus)?", "/sep(t(ember)?)?/": "sep(t(ember)?)?", "/oct(ober)?/": "okt(ober)?", "/nov(ember)?/": "nov(ember)?", "/dec(ember)?/": "des(ember)?", "/^su(n(day)?)?/": "^so(n(dag)?)?", "/^mo(n(day)?)?/": "^ma(an(dag)?)?", "/^tu(e(s(day)?)?)?/": "^di(ns(dag)?)?", "/^we(d(nesday)?)?/": "^wo(en(sdag)?)?", "/^th(u(r(s(day)?)?)?)?/": "^do(nd(erdag)?)?", "/^fr(i(day)?)?/": "^vr(y(dag)?)?", "/^sa(t(urday)?)?/": "^sa(t(erdag)?)?", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "af-ZA"; /** * @overview datejs * @version 1.0.0-rc3 * @author Gregory Wild-Smith * @copyright 2015 Gregory Wild-Smith * @license MIT * @homepage https://github.com/abritinthebay/datejs */(function () { var $D = Date; var lang = Date.CultureStrings ? Date.CultureStrings.lang : null; var loggedKeys = {}; // for debug purposes. var getText = { getFromKey: function (key, countryCode) { var output; if (Date.CultureStrings && Date.CultureStrings[countryCode] && Date.CultureStrings[countryCode][key]) { output = Date.CultureStrings[countryCode][key]; } else { output = getText.buildFromDefault(key); } if (key.charAt(0) === "/") { // Assume it's a regex output = getText.buildFromRegex(key, countryCode); } return output; }, getFromObjectValues: function (obj, countryCode) { var key, output = {}; for(key in obj) { if (obj.hasOwnProperty(key)) { output[key] = getText.getFromKey(obj[key], countryCode); } } return output; }, getFromObjectKeys: function (obj, countryCode) { var key, output = {}; for(key in obj) { if (obj.hasOwnProperty(key)) { output[getText.getFromKey(key, countryCode)] = obj[key]; } } return output; }, getFromArray: function (arr, countryCode) { var output = []; for (var i=0; i < arr.length; i++){ if (i in arr) { output[i] = getText.getFromKey(arr[i], countryCode); } } return output; }, buildFromDefault: function (key) { var output, length, split, last; switch(key) { case "name": output = "en-US"; break; case "englishName": output = "English (United States)"; break; case "nativeName": output = "English (United States)"; break; case "twoDigitYearMax": output = 2049; break; case "firstDayOfWeek": output = 0; break; default: output = key; split = key.split("_"); length = split.length; if (length > 1 && key.charAt(0) !== "/") { // if the key isn't a regex and it has a split. last = split[(length - 1)].toLowerCase(); if (last === "initial" || last === "abbr") { output = split[0]; } } break; } return output; }, buildFromRegex: function (key, countryCode) { var output; if (Date.CultureStrings && Date.CultureStrings[countryCode] && Date.CultureStrings[countryCode][key]) { output = new RegExp(Date.CultureStrings[countryCode][key], "i"); } else { output = new RegExp(key.replace(new RegExp("/", "g"),""), "i"); } return output; } }; var shallowMerge = function (obj1, obj2) { for (var attrname in obj2) { if (obj2.hasOwnProperty(attrname)) { obj1[attrname] = obj2[attrname]; } } }; var __ = function (key, language) { var countryCode = (language) ? language : lang; loggedKeys[key] = key; if (typeof key === "object") { if (key instanceof Array) { return getText.getFromArray(key, countryCode); } else { return getText.getFromObjectKeys(key, countryCode); } } else { return getText.getFromKey(key, countryCode); } }; var loadI18nScript = function (code) { // paatterned after jQuery's getScript. var url = Date.Config.i18n + code + ".js"; var head = document.getElementsByTagName("head")[0] || document.documentElement; var script = document.createElement("script"); script.src = url; var completed = false; var events = { done: function (){} // placeholder function }; // Attach handlers for all browsers script.onload = script.onreadystatechange = function() { if ( !completed && (!this.readyState || this.readyState === "loaded" || this.readyState === "complete") ) { events.done(); head.removeChild(script); } }; setTimeout(function() { head.insertBefore(script, head.firstChild); }, 0); // allows return to execute first return { done: function (cb) { events.done = function() { if (cb) { setTimeout(cb,0); } }; } }; }; var buildInfo = { buildFromMethodHash: function (obj) { var key; for(key in obj) { if (obj.hasOwnProperty(key)) { obj[key] = buildInfo[obj[key]](); } } return obj; }, timeZoneDST: function () { var DST = { "CHADT": "+1345", "NZDT": "+1300", "AEDT": "+1100", "ACDT": "+1030", "AZST": "+0500", "IRDT": "+0430", "EEST": "+0300", "CEST": "+0200", "BST": "+0100", "PMDT": "-0200", "ADT": "-0300", "NDT": "-0230", "EDT": "-0400", "CDT": "-0500", "MDT": "-0600", "PDT": "-0700", "AKDT": "-0800", "HADT": "-0900" }; return __(DST); }, timeZoneStandard: function () { var standard = { "LINT": "+1400", "TOT": "+1300", "CHAST": "+1245", "NZST": "+1200", "NFT": "+1130", "SBT": "+1100", "AEST": "+1000", "ACST": "+0930", "JST": "+0900", "CWST": "+0845", "CT": "+0800", "ICT": "+0700", "MMT": "+0630", "BST": "+0600", "NPT": "+0545", "IST": "+0530", "PKT": "+0500", "AFT": "+0430", "MSK": "+0400", "IRST": "+0330", "FET": "+0300", "EET": "+0200", "CET": "+0100", "GMT": "+0000", "UTC": "+0000", "CVT": "-0100", "GST": "-0200", "BRT": "-0300", "NST": "-0330", "AST": "-0400", "EST": "-0500", "CST": "-0600", "MST": "-0700", "PST": "-0800", "AKST": "-0900", "MIT": "-0930", "HST": "-1000", "SST": "-1100", "BIT": "-1200" }; return __(standard); }, timeZones: function (data) { var zone; data.timezones = []; for (zone in data.abbreviatedTimeZoneStandard) { if (data.abbreviatedTimeZoneStandard.hasOwnProperty(zone)) { data.timezones.push({ name: zone, offset: data.abbreviatedTimeZoneStandard[zone]}); } } for (zone in data.abbreviatedTimeZoneDST) { if (data.abbreviatedTimeZoneDST.hasOwnProperty(zone)) { data.timezones.push({ name: zone, offset: data.abbreviatedTimeZoneDST[zone], dst: true}); } } return data.timezones; }, days: function () { return __(["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"]); }, dayAbbr: function () { return __(["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"]); }, dayShortNames: function () { return __(["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"]); }, dayFirstLetters: function () { return __(["S_Sun_Initial", "M_Mon_Initial", "T_Tues_Initial", "W_Wed_Initial", "T_Thu_Initial", "F_Fri_Initial", "S_Sat_Initial"]); }, months: function () { return __(["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"]); }, monthAbbr: function () { return __(["Jan_Abbr", "Feb_Abbr", "Mar_Abbr", "Apr_Abbr", "May_Abbr", "Jun_Abbr", "Jul_Abbr", "Aug_Abbr", "Sep_Abbr", "Oct_Abbr", "Nov_Abbr", "Dec_Abbr"]); }, formatPatterns: function () { return getText.getFromObjectValues({ shortDate: "M/d/yyyy", longDate: "dddd, MMMM dd, yyyy", shortTime: "h:mm tt", longTime: "h:mm:ss tt", fullDateTime: "dddd, MMMM dd, yyyy h:mm:ss tt", sortableDateTime: "yyyy-MM-ddTHH:mm:ss", universalSortableDateTime: "yyyy-MM-dd HH:mm:ssZ", rfc1123: "ddd, dd MMM yyyy HH:mm:ss", monthDay: "MMMM dd", yearMonth: "MMMM, yyyy" }, Date.i18n.currentLanguage()); }, regex: function () { return getText.getFromObjectValues({ inTheMorning: "/( in the )(morn(ing)?)\\b/", thisMorning: "/(this )(morn(ing)?)\\b/", amThisMorning: "/(\b\\d(am)? )(this )(morn(ing)?)/", inTheEvening: "/( in the )(even(ing)?)\\b/", thisEvening: "/(this )(even(ing)?)\\b/", pmThisEvening: "/(\b\\d(pm)? )(this )(even(ing)?)/", jan: "/jan(uary)?/", feb: "/feb(ruary)?/", mar: "/mar(ch)?/", apr: "/apr(il)?/", may: "/may/", jun: "/jun(e)?/", jul: "/jul(y)?/", aug: "/aug(ust)?/", sep: "/sep(t(ember)?)?/", oct: "/oct(ober)?/", nov: "/nov(ember)?/", dec: "/dec(ember)?/", sun: "/^su(n(day)?)?/", mon: "/^mo(n(day)?)?/", tue: "/^tu(e(s(day)?)?)?/", wed: "/^we(d(nesday)?)?/", thu: "/^th(u(r(s(day)?)?)?)?/", fri: "/fr(i(day)?)?/", sat: "/^sa(t(urday)?)?/", future: "/^next/", past: "/^last|past|prev(ious)?/", add: "/^(\\+|aft(er)?|from|hence)/", subtract: "/^(\\-|bef(ore)?|ago)/", yesterday: "/^yes(terday)?/", today: "/^t(od(ay)?)?/", tomorrow: "/^tom(orrow)?/", now: "/^n(ow)?/", millisecond: "/^ms|milli(second)?s?/", second: "/^sec(ond)?s?/", minute: "/^mn|min(ute)?s?/", hour: "/^h(our)?s?/", week: "/^w(eek)?s?/", month: "/^m(onth)?s?/", day: "/^d(ay)?s?/", year: "/^y(ear)?s?/", shortMeridian: "/^(a|p)/", longMeridian: "/^(a\\.?m?\\.?|p\\.?m?\\.?)/", timezone: "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/", ordinalSuffix: "/^\\s*(st|nd|rd|th)/", timeContext: "/^\\s*(\\:|a(?!u|p)|p)/" }, Date.i18n.currentLanguage()); } }; var CultureInfo = function () { var info = getText.getFromObjectValues({ name: "name", englishName: "englishName", nativeName: "nativeName", amDesignator: "AM", pmDesignator: "PM", firstDayOfWeek: "firstDayOfWeek", twoDigitYearMax: "twoDigitYearMax", dateElementOrder: "mdy" }, Date.i18n.currentLanguage()); var constructedInfo = buildInfo.buildFromMethodHash({ dayNames: "days", abbreviatedDayNames: "dayAbbr", shortestDayNames: "dayShortNames", firstLetterDayNames: "dayFirstLetters", monthNames: "months", abbreviatedMonthNames: "monthAbbr", formatPatterns: "formatPatterns", regexPatterns: "regex", abbreviatedTimeZoneDST: "timeZoneDST", abbreviatedTimeZoneStandard: "timeZoneStandard" }); shallowMerge(info, constructedInfo); buildInfo.timeZones(info); return info; }; $D.i18n = { __: function (key, lang) { return __(key, lang); }, currentLanguage: function () { return lang || "en-US"; }, setLanguage: function (code, force, cb) { var async = false; if (force || code === "en-US" || (!!Date.CultureStrings && !!Date.CultureStrings[code])) { lang = code; Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings.lang = code; Date.CultureInfo = new CultureInfo(); } else { if (!(!!Date.CultureStrings && !!Date.CultureStrings[code])) { if (typeof exports !== "undefined" && this.exports !== exports) { // we're in a Node enviroment, load it using require try { require("../i18n/" + code + ".js"); lang = code; Date.CultureStrings.lang = code; Date.CultureInfo = new CultureInfo(); } catch (e) { // var str = "The language for '" + code + "' could not be loaded by Node. It likely does not exist."; throw new Error("The DateJS IETF language tag '" + code + "' could not be loaded by Node. It likely does not exist."); } } else if (Date.Config && Date.Config.i18n) { // we know the location of the files, so lets load them async = true; loadI18nScript(code).done(function(){ lang = code; Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings.lang = code; Date.CultureInfo = new CultureInfo(); $D.Parsing.Normalizer.buildReplaceData(); // because this is async if ($D.Grammar) { $D.Grammar.buildGrammarFormats(); // so we can parse those strings... } if (cb) { setTimeout(cb,0); } }); } else { Date.console.error("The DateJS IETF language tag '" + code + "' is not available and has not been loaded."); return false; } } } $D.Parsing.Normalizer.buildReplaceData(); // rebuild normalizer strings if ($D.Grammar) { $D.Grammar.buildGrammarFormats(); // so we can parse those strings... } if (!async && cb) { setTimeout(cb,0); } }, getLoggedKeys: function () { return loggedKeys; }, updateCultureInfo: function () { Date.CultureInfo = new CultureInfo(); } }; $D.i18n.updateCultureInfo(); // run automatically }()); (function () { var $D = Date, $P = $D.prototype, p = function (s, l) { if (!l) { l = 2; } return ("000" + s).slice(l * -1); }; if (typeof window !== "undefined" && typeof window.console !== "undefined" && typeof window.console.log !== "undefined") { $D.console = console; // used only to raise non-critical errors if available } else { // set mock so we don't give errors. $D.console = { log: function(){}, error: function(){} }; } $D.Config = $D.Config || {}; $D.initOverloads = function() { /** * Overload of Date.now. Allows an alternate call for Date.now where it returns the * current Date as an object rather than just milliseconds since the Unix Epoch. * * Also provides an implementation of now() for browsers (IE<9) that don't have it. * * Backwards compatible so with work with either: * Date.now() [returns ms] * or * Date.now(true) [returns Date] */ if (!$D.now) { $D._now = function now() { return new Date().getTime(); }; } else if (!$D._now) { $D._now = $D.now; } $D.now = function (returnObj) { if (returnObj) { return $D.present(); } else { return $D._now(); } }; if ( !$P.toISOString ) { $P.toISOString = function() { return this.getUTCFullYear() + "-" + p(this.getUTCMonth() + 1) + "-" + p(this.getUTCDate()) + "T" + p(this.getUTCHours()) + ":" + p(this.getUTCMinutes()) + ":" + p(this.getUTCSeconds()) + "." + String( (this.getUTCMilliseconds()/1000).toFixed(3)).slice(2, 5) + "Z"; }; } // private if ( $P._toString === undefined ){ $P._toString = $P.toString; } }; $D.initOverloads(); /** * Gets a date that is set to the current date. The time is set to the start of the day (00:00 or 12:00 AM). * @return {Date} The current date. */ $D.today = function () { return new Date().clearTime(); }; /** * Gets a date that is set to the current date and time (same as new Date, but chainable) * @return {Date} The current date. */ $D.present = function () { return new Date(); }; /** * Compares the first date to the second date and returns an number indication of their relative values. * @param {Date} First Date object to compare [Required]. * @param {Date} Second Date object to compare to [Required]. * @return {Number} -1 = date1 is lessthan date2. 0 = values are equal. 1 = date1 is greaterthan date2. */ $D.compare = function (date1, date2) { if (isNaN(date1) || isNaN(date2)) { throw new Error(date1 + " - " + date2); } else if (date1 instanceof Date && date2 instanceof Date) { return (date1 < date2) ? -1 : (date1 > date2) ? 1 : 0; } else { throw new TypeError(date1 + " - " + date2); } }; /** * Compares the first Date object to the second Date object and returns true if they are equal. * @param {Date} First Date object to compare [Required] * @param {Date} Second Date object to compare to [Required] * @return {Boolean} true if dates are equal. false if they are not equal. */ $D.equals = function (date1, date2) { return (date1.compareTo(date2) === 0); }; /** * Gets the language appropriate day name when given the day number(0-6) * eg - 0 == Sunday * @return {String} The day name */ $D.getDayName = function (n) { return Date.CultureInfo.dayNames[n]; }; /** * Gets the day number (0-6) if given a CultureInfo specific string which is a valid dayName, abbreviatedDayName or shortestDayName (two char). * @param {String} The name of the day (eg. "Monday, "Mon", "tuesday", "tue", "We", "we"). * @return {Number} The day number */ $D.getDayNumberFromName = function (name) { var n = Date.CultureInfo.dayNames, m = Date.CultureInfo.abbreviatedDayNames, o = Date.CultureInfo.shortestDayNames, s = name.toLowerCase(); for (var i = 0; i < n.length; i++) { if (n[i].toLowerCase() === s || m[i].toLowerCase() === s || o[i].toLowerCase() === s) { return i; } } return -1; }; /** * Gets the month number (0-11) if given a Culture Info specific string which is a valid monthName or abbreviatedMonthName. * @param {String} The name of the month (eg. "February, "Feb", "october", "oct"). * @return {Number} The day number */ $D.getMonthNumberFromName = function (name) { var n = Date.CultureInfo.monthNames, m = Date.CultureInfo.abbreviatedMonthNames, s = name.toLowerCase(); for (var i = 0; i < n.length; i++) { if (n[i].toLowerCase() === s || m[i].toLowerCase() === s) { return i; } } return -1; }; /** * Gets the language appropriate month name when given the month number(0-11) * eg - 0 == January * @return {String} The month name */ $D.getMonthName = function (n) { return Date.CultureInfo.monthNames[n]; }; /** * Determines if the current date instance is within a LeapYear. * @param {Number} The year. * @return {Boolean} true if date is within a LeapYear, otherwise false. */ $D.isLeapYear = function (year) { return ((year % 4 === 0 && year % 100 !== 0) || year % 400 === 0); }; /** * Gets the number of days in the month, given a year and month value. Automatically corrects for LeapYear. * @param {Number} The year. * @param {Number} The month (0-11). * @return {Number} The number of days in the month. */ $D.getDaysInMonth = function (year, month) { if (!month && $D.validateMonth(year)) { month = year; year = Date.today().getFullYear(); } return [31, ($D.isLeapYear(year) ? 29 : 28), 31, 30, 31, 30, 31, 31, 30, 31, 30, 31][month]; }; $P.getDaysInMonth = function () { return $D.getDaysInMonth(this.getFullYear(), this.getMonth()); }; $D.getTimezoneAbbreviation = function (offset, dst) { var p, n = (dst || false) ? Date.CultureInfo.abbreviatedTimeZoneDST : Date.CultureInfo.abbreviatedTimeZoneStandard; for (p in n) { if (n.hasOwnProperty(p)) { if (n[p] === offset) { return p; } } } return null; }; $D.getTimezoneOffset = function (name, dst) { var i, a =[], z = Date.CultureInfo.timezones; if (!name) { name = (new Date()).getTimezone();} for (i = 0; i < z.length; i++) { if (z[i].name === name.toUpperCase()) { a.push(i); } } if (!z[a[0]]) { return null; } if (a.length === 1 || !dst) { return z[a[0]].offset; } else { for (i=0; i < a.length; i++) { if (z[a[i]].dst) { return z[a[i]].offset; } } } }; $D.getQuarter = function (d) { d = d || new Date(); // If no date supplied, use today var q = [1,2,3,4]; return q[Math.floor(d.getMonth() / 3)]; // ~~~ is a bitwise op. Faster than Math.floor }; $D.getDaysLeftInQuarter = function (d) { d = d || new Date(); var qEnd = new Date(d); qEnd.setMonth(qEnd.getMonth() + 3 - qEnd.getMonth() % 3, 0); return Math.floor((qEnd - d) / 8.64e7); }; // private var validate = function (n, min, max, name) { name = name ? name : "Object"; if (typeof n === "undefined") { return false; } else if (typeof n !== "number") { throw new TypeError(n + " is not a Number."); } else if (n < min || n > max) { // As failing validation is *not* an exceptional circumstance // lets not throw a RangeError Exception here. // It's semantically correct but it's not sensible. return false; } return true; }; /** * Validates the number is within an acceptable range for milliseconds [0-999]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateMillisecond = function (value) { return validate(value, 0, 999, "millisecond"); }; /** * Validates the number is within an acceptable range for seconds [0-59]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateSecond = function (value) { return validate(value, 0, 59, "second"); }; /** * Validates the number is within an acceptable range for minutes [0-59]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateMinute = function (value) { return validate(value, 0, 59, "minute"); }; /** * Validates the number is within an acceptable range for hours [0-23]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateHour = function (value) { return validate(value, 0, 23, "hour"); }; /** * Validates the number is within an acceptable range for the days in a month [0-MaxDaysInMonth]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateDay = function (value, year, month) { if (year === undefined || year === null || month === undefined || month === null) { return false;} return validate(value, 1, $D.getDaysInMonth(year, month), "day"); }; /** * Validates the number is within an acceptable range for months [0-11]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateWeek = function (value) { return validate(value, 0, 53, "week"); }; /** * Validates the number is within an acceptable range for months [0-11]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateMonth = function (value) { return validate(value, 0, 11, "month"); }; /** * Validates the number is within an acceptable range for years. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateYear = function (value) { /** * Per ECMAScript spec the range of times supported by Date objects is * exactly -100,000,000 days to +100,000,000 days measured relative to * midnight at the beginning of 01 January, 1970 UTC. * This gives a range of 8,640,000,000,000,000 milliseconds to either * side of 01 January, 1970 UTC. * * Earliest possible date: Tue, 20 Apr 271,822 B.C. 00:00:00 UTC * Latest possible date: Sat, 13 Sep 275,760 00:00:00 UTC */ return validate(value, -271822, 275760, "year"); }; $D.validateTimezone = function(value) { var timezones = {"ACDT":1,"ACST":1,"ACT":1,"ADT":1,"AEDT":1,"AEST":1,"AFT":1,"AKDT":1,"AKST":1,"AMST":1,"AMT":1,"ART":1,"AST":1,"AWDT":1,"AWST":1,"AZOST":1,"AZT":1,"BDT":1,"BIOT":1,"BIT":1,"BOT":1,"BRT":1,"BST":1,"BTT":1,"CAT":1,"CCT":1,"CDT":1,"CEDT":1,"CEST":1,"CET":1,"CHADT":1,"CHAST":1,"CHOT":1,"ChST":1,"CHUT":1,"CIST":1,"CIT":1,"CKT":1,"CLST":1,"CLT":1,"COST":1,"COT":1,"CST":1,"CT":1,"CVT":1,"CWST":1,"CXT":1,"DAVT":1,"DDUT":1,"DFT":1,"EASST":1,"EAST":1,"EAT":1,"ECT":1,"EDT":1,"EEDT":1,"EEST":1,"EET":1,"EGST":1,"EGT":1,"EIT":1,"EST":1,"FET":1,"FJT":1,"FKST":1,"FKT":1,"FNT":1,"GALT":1,"GAMT":1,"GET":1,"GFT":1,"GILT":1,"GIT":1,"GMT":1,"GST":1,"GYT":1,"HADT":1,"HAEC":1,"HAST":1,"HKT":1,"HMT":1,"HOVT":1,"HST":1,"ICT":1,"IDT":1,"IOT":1,"IRDT":1,"IRKT":1,"IRST":1,"IST":1,"JST":1,"KGT":1,"KOST":1,"KRAT":1,"KST":1,"LHST":1,"LINT":1,"MAGT":1,"MART":1,"MAWT":1,"MDT":1,"MET":1,"MEST":1,"MHT":1,"MIST":1,"MIT":1,"MMT":1,"MSK":1,"MST":1,"MUT":1,"MVT":1,"MYT":1,"NCT":1,"NDT":1,"NFT":1,"NPT":1,"NST":1,"NT":1,"NUT":1,"NZDT":1,"NZST":1,"OMST":1,"ORAT":1,"PDT":1,"PET":1,"PETT":1,"PGT":1,"PHOT":1,"PHT":1,"PKT":1,"PMDT":1,"PMST":1,"PONT":1,"PST":1,"PYST":1,"PYT":1,"RET":1,"ROTT":1,"SAKT":1,"SAMT":1,"SAST":1,"SBT":1,"SCT":1,"SGT":1,"SLST":1,"SRT":1,"SST":1,"SYOT":1,"TAHT":1,"THA":1,"TFT":1,"TJT":1,"TKT":1,"TLT":1,"TMT":1,"TOT":1,"TVT":1,"UCT":1,"ULAT":1,"UTC":1,"UYST":1,"UYT":1,"UZT":1,"VET":1,"VLAT":1,"VOLT":1,"VOST":1,"VUT":1,"WAKT":1,"WAST":1,"WAT":1,"WEDT":1,"WEST":1,"WET":1,"WST":1,"YAKT":1,"YEKT":1,"Z":1}; return (timezones[value] === 1); }; $D.validateTimezoneOffset= function(value) { // timezones go from +14hrs to -12hrs, the +X hours are negative offsets. return (value > -841 && value < 721); }; }()); (function () { var $D = Date, $P = $D.prototype, p = function (s, l) { if (!l) { l = 2; } return ("000" + s).slice(l * -1); }; var validateConfigObject = function (obj) { var result = {}, self = this, prop, testFunc; testFunc = function (prop, func, value) { if (prop === "day") { var month = (obj.month !== undefined) ? obj.month : self.getMonth(); var year = (obj.year !== undefined) ? obj.year : self.getFullYear(); return $D[func](value, year, month); } else { return $D[func](value); } }; for (prop in obj) { if (Object.prototype.hasOwnProperty.call(obj, prop)) { var func = "validate" + prop.charAt(0).toUpperCase() + prop.slice(1); if ($D[func] && obj[prop] !== null && testFunc(prop, func, obj[prop])) { result[prop] = obj[prop]; } } } return result; }; /** * Resets the time of this Date object to 12:00 AM (00:00), which is the start of the day. * @param {Boolean} .clone() this date instance before clearing Time * @return {Date} this */ $P.clearTime = function () { this.setHours(0); this.setMinutes(0); this.setSeconds(0); this.setMilliseconds(0); return this; }; /** * Resets the time of this Date object to the current time ('now'). * @return {Date} this */ $P.setTimeToNow = function () { var n = new Date(); this.setHours(n.getHours()); this.setMinutes(n.getMinutes()); this.setSeconds(n.getSeconds()); this.setMilliseconds(n.getMilliseconds()); return this; }; /** * Returns a new Date object that is an exact date and time copy of the original instance. * @return {Date} A new Date instance */ $P.clone = function () { return new Date(this.getTime()); }; /** * Compares this instance to a Date object and returns an number indication of their relative values. * @param {Date} Date object to compare [Required] * @return {Number} -1 = this is lessthan date. 0 = values are equal. 1 = this is greaterthan date. */ $P.compareTo = function (date) { return Date.compare(this, date); }; /** * Compares this instance to another Date object and returns true if they are equal. * @param {Date} Date object to compare. If no date to compare, new Date() [now] is used. * @return {Boolean} true if dates are equal. false if they are not equal. */ $P.equals = function (date) { return Date.equals(this, (date !== undefined ? date : new Date())); }; /** * Determines if this instance is between a range of two dates or equal to either the start or end dates. * @param {Date} Start of range [Required] * @param {Date} End of range [Required] * @return {Boolean} true is this is between or equal to the start and end dates, else false */ $P.between = function (start, end) { return this.getTime() >= start.getTime() && this.getTime() <= end.getTime(); }; /** * Determines if this date occurs after the date to compare to. * @param {Date} Date object to compare. If no date to compare, new Date() ("now") is used. * @return {Boolean} true if this date instance is greater than the date to compare to (or "now"), otherwise false. */ $P.isAfter = function (date) { return this.compareTo(date || new Date()) === 1; }; /** * Determines if this date occurs before the date to compare to. * @param {Date} Date object to compare. If no date to compare, new Date() ("now") is used. * @return {Boolean} true if this date instance is less than the date to compare to (or "now"). */ $P.isBefore = function (date) { return (this.compareTo(date || new Date()) === -1); }; /** * Determines if the current Date instance occurs today. * @return {Boolean} true if this date instance is 'today', otherwise false. */ /** * Determines if the current Date instance occurs on the same Date as the supplied 'date'. * If no 'date' to compare to is provided, the current Date instance is compared to 'today'. * @param {date} Date object to compare. If no date to compare, the current Date ("now") is used. * @return {Boolean} true if this Date instance occurs on the same Day as the supplied 'date'. */ $P.isToday = $P.isSameDay = function (date) { return this.clone().clearTime().equals((date || new Date()).clone().clearTime()); }; /** * Adds the specified number of milliseconds to this instance. * @param {Number} The number of milliseconds to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addMilliseconds = function (value) { if (!value) { return this; } this.setTime(this.getTime() + value * 1); return this; }; /** * Adds the specified number of seconds to this instance. * @param {Number} The number of seconds to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addSeconds = function (value) { if (!value) { return this; } return this.addMilliseconds(value * 1000); }; /** * Adds the specified number of seconds to this instance. * @param {Number} The number of seconds to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addMinutes = function (value) { if (!value) { return this; } return this.addMilliseconds(value * 60000); // 60*1000 }; /** * Adds the specified number of hours to this instance. * @param {Number} The number of hours to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addHours = function (value) { if (!value) { return this; } return this.addMilliseconds(value * 3600000); // 60*60*1000 }; /** * Adds the specified number of days to this instance. * @param {Number} The number of days to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addDays = function (value) { if (!value) { return this; } this.setDate(this.getDate() + value * 1); return this; }; /** * Adds the specified number of weekdays (ie - not sat or sun) to this instance. * @param {Number} The number of days to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addWeekdays = function (value) { if (!value) { return this; } var day = this.getDay(); var weeks = (Math.ceil(Math.abs(value)/7)); if (day === 0 || day === 6) { if (value > 0) { this.next().monday(); this.addDays(-1); day = this.getDay(); } } if (value < 0) { while (value < 0) { this.addDays(-1); day = this.getDay(); if (day !== 0 && day !== 6) { value++; } } return this; } else if (value > 5 || (6-day) <= value) { value = value + (weeks * 2); } return this.addDays(value); }; /** * Adds the specified number of weeks to this instance. * @param {Number} The number of weeks to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addWeeks = function (value) { if (!value) { return this; } return this.addDays(value * 7); }; /** * Adds the specified number of months to this instance. * @param {Number} The number of months to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addMonths = function (value) { if (!value) { return this; } var n = this.getDate(); this.setDate(1); this.setMonth(this.getMonth() + value * 1); this.setDate(Math.min(n, $D.getDaysInMonth(this.getFullYear(), this.getMonth()))); return this; }; $P.addQuarters = function (value) { if (!value) { return this; } // note this will take you to the same point in the quarter as you are now. // i.e. - if you are 15 days into the quarter you'll be 15 days into the resulting one. // bonus: this allows adding fractional quarters return this.addMonths(value * 3); }; /** * Adds the specified number of years to this instance. * @param {Number} The number of years to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addYears = function (value) { if (!value) { return this; } return this.addMonths(value * 12); }; /** * Adds (or subtracts) to the value of the years, months, weeks, days, hours, minutes, seconds, milliseconds of the date instance using given configuration object. Positive and Negative values allowed. * Example

	Date.today().add( { days: 1, months: 1 } )

	new Date().add( { years: -1 } )
	
* @param {Object} Configuration object containing attributes (months, days, etc.) * @return {Date} this */ $P.add = function (config) { if (typeof config === "number") { this._orient = config; return this; } var x = config; if (x.day) { // If we should be a different date than today (eg: for 'tomorrow -1d', etc). // Should only effect parsing, not direct usage (eg, Finish and FinishExact) if ((x.day - this.getDate()) !== 0) { this.setDate(x.day); } } if (x.milliseconds) { this.addMilliseconds(x.milliseconds); } if (x.seconds) { this.addSeconds(x.seconds); } if (x.minutes) { this.addMinutes(x.minutes); } if (x.hours) { this.addHours(x.hours); } if (x.weeks) { this.addWeeks(x.weeks); } if (x.months) { this.addMonths(x.months); } if (x.years) { this.addYears(x.years); } if (x.days) { this.addDays(x.days); } return this; }; /** * Get the week number. Week one (1) is the week which contains the first Thursday of the year. Monday is considered the first day of the week. * The .getWeek() function does NOT convert the date to UTC. The local datetime is used. * Please use .getISOWeek() to get the week of the UTC converted date. * @return {Number} 1 to 53 */ $P.getWeek = function (utc) { // Create a copy of this date object var self, target = new Date(this.valueOf()); if (utc) { target.addMinutes(target.getTimezoneOffset()); self = target.clone(); } else { self = this; } // ISO week date weeks start on monday // so correct the day number var dayNr = (self.getDay() + 6) % 7; // ISO 8601 states that week 1 is the week // with the first thursday of that year. // Set the target date to the thursday in the target week target.setDate(target.getDate() - dayNr + 3); // Store the millisecond value of the target date var firstThursday = target.valueOf(); // Set the target to the first thursday of the year // First set the target to january first target.setMonth(0, 1); // Not a thursday? Correct the date to the next thursday if (target.getDay() !== 4) { target.setMonth(0, 1 + ((4 - target.getDay()) + 7) % 7); } // The weeknumber is the number of weeks between the // first thursday of the year and the thursday in the target week return 1 + Math.ceil((firstThursday - target) / 604800000); // 604800000 = 7 * 24 * 3600 * 1000 }; /** * Get the ISO 8601 week number. Week one ("01") is the week which contains the first Thursday of the year. Monday is considered the first day of the week. * The .getISOWeek() function does convert the date to it's UTC value. Please use .getWeek() to get the week of the local date. * @return {String} "01" to "53" */ $P.getISOWeek = function () { return p(this.getWeek(true)); }; /** * Moves the date to Monday of the week set. Week one (1) is the week which contains the first Thursday of the year. * @param {Number} A Number (1 to 53) that represents the week of the year. * @return {Date} this */ $P.setWeek = function (n) { if ((n - this.getWeek()) === 0) { if (this.getDay() !== 1) { return this.moveToDayOfWeek(1, (this.getDay() > 1 ? -1 : 1)); } else { return this; } } else { return this.moveToDayOfWeek(1, (this.getDay() > 1 ? -1 : 1)).addWeeks(n - this.getWeek()); } }; $P.setQuarter = function (qtr) { var month = Math.abs(((qtr-1) * 3) + 1); return this.setMonth(month, 1); }; $P.getQuarter = function () { return Date.getQuarter(this); }; $P.getDaysLeftInQuarter = function () { return Date.getDaysLeftInQuarter(this); }; /** * Moves the date to the next n'th occurrence of the dayOfWeek starting from the beginning of the month. The number (-1) is a magic number and will return the last occurrence of the dayOfWeek in the month. * @param {Number} The dayOfWeek to move to * @param {Number} The n'th occurrence to move to. Use (-1) to return the last occurrence in the month * @return {Date} this */ $P.moveToNthOccurrence = function (dayOfWeek, occurrence) { if (dayOfWeek === "Weekday") { if (occurrence > 0) { this.moveToFirstDayOfMonth(); if (this.is().weekday()) { occurrence -= 1; } } else if (occurrence < 0) { this.moveToLastDayOfMonth(); if (this.is().weekday()) { occurrence += 1; } } else { return this; } return this.addWeekdays(occurrence); } var shift = 0; if (occurrence > 0) { shift = occurrence - 1; } else if (occurrence === -1) { this.moveToLastDayOfMonth(); if (this.getDay() !== dayOfWeek) { this.moveToDayOfWeek(dayOfWeek, -1); } return this; } return this.moveToFirstDayOfMonth().addDays(-1).moveToDayOfWeek(dayOfWeek, +1).addWeeks(shift); }; var moveToN = function (getFunc, addFunc, nVal) { return function (value, orient) { var diff = (value - this[getFunc]() + nVal * (orient || +1)) % nVal; return this[addFunc]((diff === 0) ? diff += nVal * (orient || +1) : diff); }; }; /** * Move to the next or last dayOfWeek based on the orient value. * @param {Number} The dayOfWeek to move to * @param {Number} Forward (+1) or Back (-1). Defaults to +1. [Optional] * @return {Date} this */ $P.moveToDayOfWeek = moveToN("getDay", "addDays", 7); /** * Move to the next or last month based on the orient value. * @param {Number} The month to move to. 0 = January, 11 = December * @param {Number} Forward (+1) or Back (-1). Defaults to +1. [Optional] * @return {Date} this */ $P.moveToMonth = moveToN("getMonth", "addMonths", 12); /** * Get the Ordinate of the current day ("th", "st", "rd"). * @return {String} */ $P.getOrdinate = function () { var num = this.getDate(); return ord(num); }; /** * Get the Ordinal day (numeric day number) of the year, adjusted for leap year. * @return {Number} 1 through 365 (366 in leap years) */ $P.getOrdinalNumber = function () { return Math.ceil((this.clone().clearTime() - new Date(this.getFullYear(), 0, 1)) / 86400000) + 1; }; /** * Get the time zone abbreviation of the current date. * @return {String} The abbreviated time zone name (e.g. "EST") */ $P.getTimezone = function () { return $D.getTimezoneAbbreviation(this.getUTCOffset(), this.isDaylightSavingTime()); }; $P.setTimezoneOffset = function (offset) { var here = this.getTimezoneOffset(), there = Number(offset) * -6 / 10; return (there || there === 0) ? this.addMinutes(there - here) : this; }; $P.setTimezone = function (offset) { return this.setTimezoneOffset($D.getTimezoneOffset(offset)); }; /** * Indicates whether Daylight Saving Time is observed in the current time zone. * @return {Boolean} true|false */ $P.hasDaylightSavingTime = function () { return (Date.today().set({month: 0, day: 1}).getTimezoneOffset() !== Date.today().set({month: 6, day: 1}).getTimezoneOffset()); }; /** * Indicates whether this Date instance is within the Daylight Saving Time range for the current time zone. * @return {Boolean} true|false */ $P.isDaylightSavingTime = function () { return Date.today().set({month: 0, day: 1}).getTimezoneOffset() !== this.getTimezoneOffset(); }; /** * Get the offset from UTC of the current date. * @return {String} The 4-character offset string prefixed with + or - (e.g. "-0500") */ $P.getUTCOffset = function (offset) { var n = (offset || this.getTimezoneOffset()) * -10 / 6, r; if (n < 0) { r = (n - 10000).toString(); return r.charAt(0) + r.substr(2); } else { r = (n + 10000).toString(); return "+" + r.substr(1); } }; /** * Returns the number of milliseconds between this date and date. * @param {Date} Defaults to now * @return {Number} The diff in milliseconds */ $P.getElapsed = function (date) { return (date || new Date()) - this; }; /** * Set the value of year, month, day, hour, minute, second, millisecond of date instance using given configuration object. * Example

	Date.today().set( { day: 20, month: 1 } )

	new Date().set( { millisecond: 0 } )
	
* * @param {Object} Configuration object containing attributes (month, day, etc.) * @return {Date} this */ $P.set = function (config) { config = validateConfigObject.call(this, config); var key; for (key in config) { if (Object.prototype.hasOwnProperty.call(config, key)) { var name = key.charAt(0).toUpperCase() + key.slice(1); var addFunc, getFunc; if (key !== "week" && key !== "month" && key !== "timezone" && key !== "timezoneOffset") { name += "s"; } addFunc = "add" + name; getFunc = "get" + name; if (key === "month") { addFunc = addFunc + "s"; } else if (key === "year"){ getFunc = "getFullYear"; } if (key !== "day" && key !== "timezone" && key !== "timezoneOffset" && key !== "week" && key !== "hour") { this[addFunc](config[key] - this[getFunc]()); } else if ( key === "timezone"|| key === "timezoneOffset" || key === "week" || key === "hour") { this["set"+name](config[key]); } } } // day has to go last because you can't validate the day without first knowing the month if (config.day) { this.addDays(config.day - this.getDate()); } return this; }; /** * Moves the date to the first day of the month. * @return {Date} this */ $P.moveToFirstDayOfMonth = function () { return this.set({ day: 1 }); }; /** * Moves the date to the last day of the month. * @return {Date} this */ $P.moveToLastDayOfMonth = function () { return this.set({ day: $D.getDaysInMonth(this.getFullYear(), this.getMonth())}); }; /** * Converts the value of the current Date object to its equivalent string representation. * Format Specifiers * CUSTOM DATE AND TIME FORMAT STRINGS * Format Description Example * ------ --------------------------------------------------------------------------- ----------------------- * s The seconds of the minute between 0-59. "0" to "59" * ss The seconds of the minute with leading zero if required. "00" to "59" * * m The minute of the hour between 0-59. "0" or "59" * mm The minute of the hour with leading zero if required. "00" or "59" * * h The hour of the day between 1-12. "1" to "12" * hh The hour of the day with leading zero if required. "01" to "12" * * H The hour of the day between 0-23. "0" to "23" * HH The hour of the day with leading zero if required. "00" to "23" * * d The day of the month between 1 and 31. "1" to "31" * dd The day of the month with leading zero if required. "01" to "31" * ddd Abbreviated day name. Date.CultureInfo.abbreviatedDayNames. "Mon" to "Sun" * dddd The full day name. Date.CultureInfo.dayNames. "Monday" to "Sunday" * * M The month of the year between 1-12. "1" to "12" * MM The month of the year with leading zero if required. "01" to "12" * MMM Abbreviated month name. Date.CultureInfo.abbreviatedMonthNames. "Jan" to "Dec" * MMMM The full month name. Date.CultureInfo.monthNames. "January" to "December" * * yy The year as a two-digit number. "99" or "08" * yyyy The full four digit year. "1999" or "2008" * * t Displays the first character of the A.M./P.M. designator. "A" or "P" * Date.CultureInfo.amDesignator or Date.CultureInfo.pmDesignator * tt Displays the A.M./P.M. designator. "AM" or "PM" * Date.CultureInfo.amDesignator or Date.CultureInfo.pmDesignator * * S The ordinal suffix ("st, "nd", "rd" or "th") of the current day. "st, "nd", "rd" or "th" * * STANDARD DATE AND TIME FORMAT STRINGS * Format Description Example *------ --------------------------------------------------------------------------- ----------------------- * d The CultureInfo shortDate Format Pattern "M/d/yyyy" * D The CultureInfo longDate Format Pattern "dddd, MMMM dd, yyyy" * F The CultureInfo fullDateTime Format Pattern "dddd, MMMM dd, yyyy h:mm:ss tt" * m The CultureInfo monthDay Format Pattern "MMMM dd" * r The CultureInfo rfc1123 Format Pattern "ddd, dd MMM yyyy HH:mm:ss GMT" * s The CultureInfo sortableDateTime Format Pattern "yyyy-MM-ddTHH:mm:ss" * t The CultureInfo shortTime Format Pattern "h:mm tt" * T The CultureInfo longTime Format Pattern "h:mm:ss tt" * u The CultureInfo universalSortableDateTime Format Pattern "yyyy-MM-dd HH:mm:ssZ" * y The CultureInfo yearMonth Format Pattern "MMMM, yyyy" * * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @return {String} A string representation of the current Date object. */ var ord = function (n) { switch (n * 1) { case 1: case 21: case 31: return "st"; case 2: case 22: return "nd"; case 3: case 23: return "rd"; default: return "th"; } }; var parseStandardFormats = function (format) { var y, c = Date.CultureInfo.formatPatterns; switch (format) { case "d": return this.toString(c.shortDate); case "D": return this.toString(c.longDate); case "F": return this.toString(c.fullDateTime); case "m": return this.toString(c.monthDay); case "r": case "R": y = this.clone().addMinutes(this.getTimezoneOffset()); return y.toString(c.rfc1123) + " GMT"; case "s": return this.toString(c.sortableDateTime); case "t": return this.toString(c.shortTime); case "T": return this.toString(c.longTime); case "u": y = this.clone().addMinutes(this.getTimezoneOffset()); return y.toString(c.universalSortableDateTime); case "y": return this.toString(c.yearMonth); default: return false; } }; var parseFormatStringsClosure = function (context) { return function (m) { if (m.charAt(0) === "\\") { return m.replace("\\", ""); } switch (m) { case "hh": return p(context.getHours() < 13 ? (context.getHours() === 0 ? 12 : context.getHours()) : (context.getHours() - 12)); case "h": return context.getHours() < 13 ? (context.getHours() === 0 ? 12 : context.getHours()) : (context.getHours() - 12); case "HH": return p(context.getHours()); case "H": return context.getHours(); case "mm": return p(context.getMinutes()); case "m": return context.getMinutes(); case "ss": return p(context.getSeconds()); case "s": return context.getSeconds(); case "yyyy": return p(context.getFullYear(), 4); case "yy": return p(context.getFullYear()); case "y": return context.getFullYear(); case "E": case "dddd": return Date.CultureInfo.dayNames[context.getDay()]; case "ddd": return Date.CultureInfo.abbreviatedDayNames[context.getDay()]; case "dd": return p(context.getDate()); case "d": return context.getDate(); case "MMMM": return Date.CultureInfo.monthNames[context.getMonth()]; case "MMM": return Date.CultureInfo.abbreviatedMonthNames[context.getMonth()]; case "MM": return p((context.getMonth() + 1)); case "M": return context.getMonth() + 1; case "t": return context.getHours() < 12 ? Date.CultureInfo.amDesignator.substring(0, 1) : Date.CultureInfo.pmDesignator.substring(0, 1); case "tt": return context.getHours() < 12 ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator; case "S": return ord(context.getDate()); case "W": return context.getWeek(); case "WW": return context.getISOWeek(); case "Q": return "Q" + context.getQuarter(); case "q": return String(context.getQuarter()); case "z": return context.getTimezone(); case "Z": case "X": return Date.getTimezoneOffset(context.getTimezone()); case "ZZ": // Timezone offset in seconds return context.getTimezoneOffset() * -60; case "u": return context.getDay(); case "L": return ($D.isLeapYear(context.getFullYear())) ? 1 : 0; case "B": // Swatch Internet Time (.beats) return "@"+((context.getUTCSeconds() + (context.getUTCMinutes()*60) + ((context.getUTCHours()+1)*3600))/86.4); default: return m; } }; }; $P.toString = function (format, ignoreStandards) { // Standard Date and Time Format Strings. Formats pulled from CultureInfo file and // may vary by culture. if (!ignoreStandards && format && format.length === 1) { output = parseStandardFormats.call(this, format); if (output) { return output; } } var parseFormatStrings = parseFormatStringsClosure(this); return format ? format.replace(/((\\)?(dd?d?d?|MM?M?M?|yy?y?y?|hh?|HH?|mm?|ss?|tt?|S|q|Q|WW?W?W?)(?![^\[]*\]))/g, parseFormatStrings).replace(/\[|\]/g, "") : this._toString(); }; }()); /************************************************************* * SugarPak - Domain Specific Language - Syntactical Sugar * *************************************************************/ (function () { var $D = Date, $P = $D.prototype, $N = Number.prototype; // private $P._orient = +1; // private $P._nth = null; // private $P._is = false; // private $P._same = false; // private $P._isSecond = false; // private $N._dateElement = "days"; /** * Moves the date to the next instance of a date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.today().next().friday();
	Date.today().next().fri();
	Date.today().next().march();
	Date.today().next().mar();
	Date.today().next().week();
	
* * @return {Date} date */ $P.next = function () { this._move = true; this._orient = +1; return this; }; /** * Creates a new Date (Date.today()) and moves the date to the next instance of the date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.next().friday();
	Date.next().fri();
	Date.next().march();
	Date.next().mar();
	Date.next().week();
	
* * @return {Date} date */ $D.next = function () { return $D.today().next(); }; /** * Moves the date to the previous instance of a date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.today().last().friday();
	Date.today().last().fri();
	Date.today().last().march();
	Date.today().last().mar();
	Date.today().last().week();
	
* * @return {Date} date */ $P.last = $P.prev = $P.previous = function () { this._move = true; this._orient = -1; return this; }; /** * Creates a new Date (Date.today()) and moves the date to the previous instance of the date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.last().friday();
	Date.last().fri();
	Date.previous().march();
	Date.prev().mar();
	Date.last().week();
	
* * @return {Date} date */ $D.last = $D.prev = $D.previous = function () { return $D.today().last(); }; /** * Performs a equality check when followed by either a month name, day name or .weekday() function. * Example

	Date.today().is().friday(); // true|false
	Date.today().is().fri();
	Date.today().is().march();
	Date.today().is().mar();
	
* * @return {Boolean} true|false */ $P.is = function () { this._is = true; return this; }; /** * Determines if two date objects occur on/in exactly the same instance of the subsequent date part function. * The function .same() must be followed by a date part function (example: .day(), .month(), .year(), etc). * * An optional Date can be passed in the date part function. If now date is passed as a parameter, 'Now' is used. * * The following example demonstrates how to determine if two dates fall on the exact same day. * * Example

	var d1 = Date.today(); // today at 00:00
	var d2 = new Date();   // exactly now.

	// Do they occur on the same day?
	d1.same().day(d2); // true
	
	// Do they occur on the same hour?
	d1.same().hour(d2); // false, unless d2 hour is '00' (midnight).
	
	// What if it's the same day, but one year apart?
	var nextYear = Date.today().add(1).year();

	d1.same().day(nextYear); // false, because the dates must occur on the exact same day. 
	
* * Scenario: Determine if a given date occurs during some week period 2 months from now. * * Example

	var future = Date.today().add(2).months();
	return someDate.same().week(future); // true|false;
	
* * @return {Boolean} true|false */ $P.same = function () { this._same = true; this._isSecond = false; return this; }; /** * Determines if the current date/time occurs during Today. Must be preceded by the .is() function. * Example

	someDate.is().today();    // true|false
	new Date().is().today();  // true
	Date.today().is().today();// true
	Date.today().add(-1).day().is().today(); // false
	
* * @return {Boolean} true|false */ $P.today = function () { return this.same().day(); }; /** * Determines if the current date is a weekday. This function must be preceded by the .is() function. * Example

	Date.today().is().weekday(); // true|false
	
* * @return {Boolean} true|false */ $P.weekday = function () { if (this._nth) { return df("Weekday").call(this); } if (this._move) { return this.addWeekdays(this._orient); } if (this._is) { this._is = false; return (!this.is().sat() && !this.is().sun()); } return false; }; /** * Determines if the current date is on the weekend. This function must be preceded by the .is() function. * Example

	Date.today().is().weekend(); // true|false
	
* * @return {Boolean} true|false */ $P.weekend = function () { if (this._is) { this._is = false; return (this.is().sat() || this.is().sun()); } return false; }; /** * Sets the Time of the current Date instance. A string "6:15 pm" or config object {hour:18, minute:15} are accepted. * Example

	// Set time to 6:15pm with a String
	Date.today().at("6:15pm");

	// Set time to 6:15pm with a config object
	Date.today().at({hour:18, minute:15});
	
* * @return {Date} date */ $P.at = function (time) { return (typeof time === "string") ? $D.parse(this.toString("d") + " " + time) : this.set(time); }; /** * Creates a new Date() and adds this (Number) to the date based on the preceding date element function (eg. second|minute|hour|day|month|year). * Example

	// Undeclared Numbers must be wrapped with parentheses. Requirment of JavaScript.
	(3).days().fromNow();
	(6).months().fromNow();

	// Declared Number variables do not require parentheses. 
	var n = 6;
	n.months().fromNow();
	
* * @return {Date} A new Date instance */ $N.fromNow = $N.after = function (date) { var c = {}; c[this._dateElement] = this; return ((!date) ? new Date() : date.clone()).add(c); }; /** * Creates a new Date() and subtract this (Number) from the date based on the preceding date element function (eg. second|minute|hour|day|month|year). * Example

	// Undeclared Numbers must be wrapped with parentheses. Requirment of JavaScript.
	(3).days().ago();
	(6).months().ago();

	// Declared Number variables do not require parentheses. 
	var n = 6;
	n.months().ago();
	
* * @return {Date} A new Date instance */ $N.ago = $N.before = function (date) { var c = {}, s = (this._dateElement[this._dateElement.length-1] !== "s") ? this._dateElement + "s" : this._dateElement; c[s] = this * -1; return ((!date) ? new Date() : date.clone()).add(c); }; // Do NOT modify the following string tokens. These tokens are used to build dynamic functions. // All culture-specific strings can be found in the CultureInfo files. var dx = ("sunday monday tuesday wednesday thursday friday saturday").split(/\s/), mx = ("january february march april may june july august september october november december").split(/\s/), px = ("Millisecond Second Minute Hour Day Week Month Year Quarter Weekday").split(/\s/), pxf = ("Milliseconds Seconds Minutes Hours Date Week Month FullYear Quarter").split(/\s/), nth = ("final first second third fourth fifth").split(/\s/), de; /** * Returns an object literal of all the date parts. * Example

	var o = new Date().toObject();
	
	// { year: 2008, month: 4, week: 20, day: 13, hour: 18, minute: 9, second: 32, millisecond: 812 }
	
	// The object properties can be referenced directly from the object.
	
	alert(o.day);  // alerts "13"
	alert(o.year); // alerts "2008"
	
* * @return {Date} An object literal representing the original date object. */ $P.toObject = function () { var o = {}; for (var i = 0; i < px.length; i++) { if (this["get" + pxf[i]]) { o[px[i].toLowerCase()] = this["get" + pxf[i]](); } } return o; }; /** * Returns a date created from an object literal. Ignores the .week property if set in the config. * Example

	var o = new Date().toObject();
	
	return Date.fromObject(o); // will return the same date. 

	var o2 = {month: 1, day: 20, hour: 18}; // birthday party!
	Date.fromObject(o2);
	
* * @return {Date} An object literal representing the original date object. */ $D.fromObject = function(config) { config.week = null; return Date.today().set(config); }; // Create day name functions and abbreviated day name functions (eg. monday(), friday(), fri()). var df = function (n) { return function () { if (this._is) { this._is = false; return this.getDay() === n; } if (this._move) { this._move = null; } if (this._nth !== null) { // If the .second() function was called earlier, remove the _orient // from the date, and then continue. // This is required because 'second' can be used in two different context. // // Example // // Date.today().add(1).second(); // Date.march().second().monday(); // // Things get crazy with the following... // Date.march().add(1).second().second().monday(); // but it works!! // if (this._isSecond) { this.addSeconds(this._orient * -1); } // make sure we reset _isSecond this._isSecond = false; var ntemp = this._nth; this._nth = null; var temp = this.clone().moveToLastDayOfMonth(); this.moveToNthOccurrence(n, ntemp); if (this > temp) { throw new RangeError($D.getDayName(n) + " does not occur " + ntemp + " times in the month of " + $D.getMonthName(temp.getMonth()) + " " + temp.getFullYear() + "."); } return this; } return this.moveToDayOfWeek(n, this._orient); }; }; var sdf = function (n) { return function () { var t = $D.today(), shift = n - t.getDay(); if (n === 0 && Date.CultureInfo.firstDayOfWeek === 1 && t.getDay() !== 0) { shift = shift + 7; } return t.addDays(shift); }; }; // Create month name functions and abbreviated month name functions (eg. january(), march(), mar()). var month_instance_functions = function (n) { return function () { if (this._is) { this._is = false; return this.getMonth() === n; } return this.moveToMonth(n, this._orient); }; }; var month_static_functions = function (n) { return function () { return $D.today().set({ month: n, day: 1 }); }; }; var processTerms = function (names, staticFunc, instanceFunc) { for (var i = 0; i < names.length; i++) { // Create constant static Name variables. $D[names[i].toUpperCase()] = $D[names[i].toUpperCase().substring(0, 3)] = i; // Create Name functions. $D[names[i]] = $D[names[i].substring(0, 3)] = staticFunc(i); // Create Name instance functions. $P[names[i]] = $P[names[i].substring(0, 3)] = instanceFunc(i); } }; processTerms(dx, sdf, df); processTerms(mx, month_static_functions, month_instance_functions); // Create date element functions and plural date element functions used with Date (eg. day(), days(), months()). var ef = function (j) { return function () { // if the .second() function was called earlier, the _orient // has alread been added. Just return this and reset _isSecond. if (this._isSecond) { this._isSecond = false; return this; } if (this._same) { this._same = this._is = false; var o1 = this.toObject(), o2 = (arguments[0] || new Date()).toObject(), v = "", k = j.toLowerCase(); // the substr trick with -1 doesn't work in IE8 or less k = (k[k.length-1] === "s") ? k.substring(0,k.length-1) : k; for (var m = (px.length - 1); m > -1; m--) { v = px[m].toLowerCase(); if (o1[v] !== o2[v]) { return false; } if (k === v) { break; } } return true; } if (j.substring(j.length - 1) !== "s") { j += "s"; } if (this._move) { this._move = null; } return this["add" + j](this._orient); }; }; var nf = function (n) { return function () { this._dateElement = n; return this; }; }; for (var k = 0; k < px.length; k++) { de = px[k].toLowerCase(); if(de !== "weekday") { // Create date element functions and plural date element functions used with Date (eg. day(), days(), months()). $P[de] = $P[de + "s"] = ef(px[k]); // Create date element functions and plural date element functions used with Number (eg. day(), days(), months()). $N[de] = $N[de + "s"] = nf(de + "s"); } } $P._ss = ef("Second"); var nthfn = function (n) { return function (dayOfWeek) { if (this._same) { return this._ss(arguments[0]); } if (dayOfWeek || dayOfWeek === 0) { return this.moveToNthOccurrence(dayOfWeek, n); } this._nth = n; // if the operator is 'second' add the _orient, then deal with it later... if (n === 2 && (dayOfWeek === undefined || dayOfWeek === null)) { this._isSecond = true; return this.addSeconds(this._orient); } return this; }; }; for (var l = 0; l < nth.length; l++) { $P[nth[l]] = (l === 0) ? nthfn(-1) : nthfn(l); } }()); (function () { "use strict"; Date.Parsing = { Exception: function (s) { this.message = "Parse error at '" + s.substring(0, 10) + " ...'"; } }; var $P = Date.Parsing; var dayOffsets = { standard: [0,31,59,90,120,151,181,212,243,273,304,334], leap: [0,31,60,91,121,152,182,213,244,274,305,335] }; $P.isLeapYear = function(year) { return ((year % 4 === 0) && (year % 100 !== 0)) || (year % 400 === 0); }; var utils = { multiReplace : function (str, hash ) { var key; for (key in hash) { if (Object.prototype.hasOwnProperty.call(hash, key)) { var regex; if (typeof hash[key] === "function") { } else { regex = (hash[key] instanceof RegExp) ? hash[key] : new RegExp(hash[key], "g"); } str = str.replace(regex, key); } } return str; }, getDayOfYearFromWeek : function (obj) { var d, jan4, offset; obj.weekDay = (!obj.weekDay && obj.weekDay !== 0) ? 1 : obj.weekDay; d = new Date(obj.year, 0, 4); jan4 = d.getDay() === 0 ? 7 : d.getDay(); // JS is 0 indexed on Sunday. offset = jan4+3; obj.dayOfYear = ((obj.week * 7) + (obj.weekDay === 0 ? 7 : obj.weekDay))-offset; return obj; }, getDayOfYear : function (obj, dayOffset) { if (!obj.dayOfYear) { obj = utils.getDayOfYearFromWeek(obj); } for (var i=0;i <= dayOffset.length;i++) { if (obj.dayOfYear < dayOffset[i] || i === dayOffset.length) { obj.day = obj.day ? obj.day : (obj.dayOfYear - dayOffset[i-1]); break; } else { obj.month = i; } } return obj; }, adjustForTimeZone : function (obj, date) { var offset; if (obj.zone.toUpperCase() === "Z" || (obj.zone_hours === 0 && obj.zone_minutes === 0)) { // it's UTC/GML so work out the current timeszone offset offset = -date.getTimezoneOffset(); } else { offset = (obj.zone_hours*60) + (obj.zone_minutes || 0); if (obj.zone_sign === "+") { offset *= -1; } offset -= date.getTimezoneOffset(); } date.setMinutes(date.getMinutes()+offset); return date; }, setDefaults : function (obj) { obj.year = obj.year || Date.today().getFullYear(); obj.hours = obj.hours || 0; obj.minutes = obj.minutes || 0; obj.seconds = obj.seconds || 0; obj.milliseconds = obj.milliseconds || 0; if (!(!obj.month && (obj.week || obj.dayOfYear))) { // if we have a month, or if we don't but don't have the day calculation data obj.month = obj.month || 0; obj.day = obj.day || 1; } return obj; }, dataNum: function (data, mod, explict, postProcess) { var dataNum = data*1; if (mod) { if (postProcess) { return data ? mod(data)*1 : data; } else { return data ? mod(dataNum) : data; } } else if (!explict){ return data ? dataNum : data; } else { return (data && typeof data !== "undefined") ? dataNum : data; } }, timeDataProcess: function (obj) { var timeObj = {}; for (var x in obj.data) { if (obj.data.hasOwnProperty(x)) { timeObj[x] = obj.ignore[x] ? obj.data[x] : utils.dataNum(obj.data[x], obj.mods[x], obj.explict[x], obj.postProcess[x]); } } if (obj.data.secmins) { obj.data.secmins = obj.data.secmins.replace(",", ".") * 60; if (!timeObj.minutes) { timeObj.minutes = obj.data.secmins; } else if (!timeObj.seconds) { timeObj.seconds = obj.data.secmins; } delete obj.secmins; } return timeObj; }, buildTimeObjectFromData: function (data) { var time = utils.timeDataProcess({ data: { year : data[1], month : data[5], day : data[7], week : data[8], dayOfYear : data[10], hours : data[15], zone_hours : data[23], zone_minutes : data[24], zone : data[21], zone_sign : data[22], weekDay : data[9], minutes: data[16], seconds: data[19], milliseconds: data[20], secmins: data[18] }, mods: { month: function(data) { return data-1; }, weekDay: function (data) { data = Math.abs(data); return (data === 7 ? 0 : data); }, minutes: function (data) { return data.replace(":",""); }, seconds: function (data) { return Math.floor( (data.replace(":","").replace(",","."))*1 ); }, milliseconds: function (data) { return (data.replace(",",".")*1000); } }, postProcess: { minutes: true, seconds: true, milliseconds: true }, explict: { zone_hours: true, zone_minutes: true }, ignore: { zone: true, zone_sign: true, secmins: true } }); return time; }, addToHash: function (hash, keys, data) { keys = keys; data = data; var len = keys.length; for (var i = 0; i < len; i++) { hash[keys[i]] = data[i]; } return hash; }, combineRegex: function (r1, r2) { return new RegExp("(("+r1.source+")\\s("+r2.source+"))"); }, getDateNthString: function(add, last, inc){ if (add) { return Date.today().addDays(inc).toString("d"); } else if (last) { return Date.today().last()[inc]().toString("d"); } }, buildRegexData: function (array) { var arr = []; var len = array.length; for (var i=0; i < len; i++) { if (Object.prototype.toString.call(array[i]) === '[object Array]') { // oldIE compat version of Array.isArray arr.push(this.combineRegex(array[i][0], array[i][1])); } else { arr.push(array[i]); } } return arr; } }; $P.processTimeObject = function (obj) { var date, dayOffset; utils.setDefaults(obj); dayOffset = ($P.isLeapYear(obj.year)) ? dayOffsets.leap : dayOffsets.standard; if (!obj.month && (obj.week || obj.dayOfYear)) { utils.getDayOfYear(obj, dayOffset); } else { obj.dayOfYear = dayOffset[obj.month] + obj.day; } date = new Date(obj.year, obj.month, obj.day, obj.hours, obj.minutes, obj.seconds, obj.milliseconds); if (obj.zone) { utils.adjustForTimeZone(obj, date); // adjust (and calculate) for timezone } return date; }; $P.ISO = { regex : /^([\+-]?\d{4}(?!\d{2}\b))((-?)((0[1-9]|1[0-2])(\3([12]\d|0[1-9]|3[01]))?|W([0-4]\d|5[0-3])(-?[1-7])?|(00[1-9]|0[1-9]\d|[12]\d{2}|3([0-5]\d|6[1-6])))([T\s]((([01]\d|2[0-4])((:?)[0-5]\d)?|24\:?00)([\.,]\d+(?!:))?)?(\17[0-5]\d([\.,]\d+)?)?\s?([zZ]|([\+-])([01]\d|2[0-3]):?([0-5]\d)?)?)?)?$/, parse : function (s) { var time, data = s.match(this.regex); if (!data || !data.length) { return null; } time = utils.buildTimeObjectFromData(data); if (!time.year || (!time.year && (!time.month && !time.day) && (!time.week && !time.dayOfYear)) ) { return null; } return $P.processTimeObject(time); } }; $P.Numeric = { isNumeric: function (e){return!isNaN(parseFloat(e))&&isFinite(e);}, regex: /\b([0-1]?[0-9])([0-3]?[0-9])([0-2]?[0-9]?[0-9][0-9])\b/i, parse: function (s) { var data, i, time = {}, order = Date.CultureInfo.dateElementOrder.split(""); if (!(this.isNumeric(s)) || // if it's non-numeric OR (s[0] === "+" && s[0] === "-")) { // It's an arithmatic string (eg +/-1000) return null; } if (s.length < 5 && s.indexOf(".") < 0 && s.indexOf("/") < 0) { // assume it's just a year. time.year = s; return $P.processTimeObject(time); } data = s.match(this.regex); if (!data || !data.length) { return null; } for (i=0; i < order.length; i++) { switch(order[i]) { case "d": time.day = data[i+1]; break; case "m": time.month = (data[i+1]-1); break; case "y": time.year = data[i+1]; break; } } return $P.processTimeObject(time); } }; $P.Normalizer = { regexData: function () { var $R = Date.CultureInfo.regexPatterns; return utils.buildRegexData([ $R.tomorrow, $R.yesterday, [$R.past, $R.mon], [$R.past, $R.tue], [$R.past, $R.wed], [$R.past, $R.thu], [$R.past, $R.fri], [$R.past, $R.sat], [$R.past, $R.sun] ]); }, basicReplaceHash : function() { var $R = Date.CultureInfo.regexPatterns; return { "January": $R.jan.source, "February": $R.feb, "March": $R.mar, "April": $R.apr, "May": $R.may, "June": $R.jun, "July": $R.jul, "August": $R.aug, "September": $R.sep, "October": $R.oct, "November": $R.nov, "December": $R.dec, "": /\bat\b/gi, " ": /\s{2,}/, "am": $R.inTheMorning, "9am": $R.thisMorning, "pm": $R.inTheEvening, "7pm":$R.thisEvening }; }, keys : function(){ return [ utils.getDateNthString(true, false, 1), // tomorrow utils.getDateNthString(true, false, -1), // yesterday utils.getDateNthString(false, true, "monday"), //last mon utils.getDateNthString(false, true, "tuesday"), //last tues utils.getDateNthString(false, true, "wednesday"), //last wed utils.getDateNthString(false, true, "thursday"), //last thurs utils.getDateNthString(false, true, "friday"), //last fri utils.getDateNthString(false, true, "saturday"), //last sat utils.getDateNthString(false, true, "sunday") //last sun ]; }, buildRegexFunctions: function () { var $R = Date.CultureInfo.regexPatterns; var __ = Date.i18n.__; var tomorrowRE = new RegExp("(\\b\\d\\d?("+__("AM")+"|"+__("PM")+")? )("+$R.tomorrow.source.slice(1)+")", "i"); // adapted tomorrow regex for AM PM relative dates var todayRE = new RegExp($R.today.source + "(?!\\s*([+-]))\\b"); // today, but excludes the math operators (eg "today + 2h") this.replaceFuncs = [ [todayRE, function (full) { return (full.length > 1) ? Date.today().toString("d") : full; }], [tomorrowRE, function(full, m1) { var t = Date.today().addDays(1).toString("d"); return (t + " " + m1); }], [$R.amThisMorning, function(str, am){return am;}], [$R.pmThisEvening, function(str, pm){return pm;}] ]; }, buildReplaceData: function () { this.buildRegexFunctions(); this.replaceHash = utils.addToHash(this.basicReplaceHash(), this.keys(), this.regexData()); }, stringReplaceFuncs: function (s) { for (var i=0; i < this.replaceFuncs.length; i++) { s = s.replace(this.replaceFuncs[i][0], this.replaceFuncs[i][1]); } return s; }, parse: function (s) { s = this.stringReplaceFuncs(s); s = utils.multiReplace(s, this.replaceHash); try { var n = s.split(/([\s\-\.\,\/\x27]+)/); if (n.length === 3 && $P.Numeric.isNumeric(n[0]) && $P.Numeric.isNumeric(n[2]) && (n[2].length >= 4)) { // ok, so we're dealing with x/year. But that's not a full date. // This fixes wonky dateElementOrder parsing when set to dmy order. if (Date.CultureInfo.dateElementOrder[0] === "d") { s = "1/" + n[0] + "/" + n[2]; // set to 1st of month and normalize the seperator } } } catch (e) {} return s; } }; $P.Normalizer.buildReplaceData(); }()); (function () { var $P = Date.Parsing; var _ = $P.Operators = { // // Tokenizers // rtoken: function (r) { // regex token return function (s) { var mx = s.match(r); if (mx) { return ([ mx[0], s.substring(mx[0].length) ]); } else { throw new $P.Exception(s); } }; }, token: function () { // whitespace-eating token return function (s) { return _.rtoken(new RegExp("^\\s*" + s + "\\s*"))(s); }; }, stoken: function (s) { // string token return _.rtoken(new RegExp("^" + s)); }, // Atomic Operators until: function (p) { return function (s) { var qx = [], rx = null; while (s.length) { try { rx = p.call(this, s); } catch (e) { qx.push(rx[0]); s = rx[1]; continue; } break; } return [ qx, s ]; }; }, many: function (p) { return function (s) { var rx = [], r = null; while (s.length) { try { r = p.call(this, s); } catch (e) { return [ rx, s ]; } rx.push(r[0]); s = r[1]; } return [ rx, s ]; }; }, // generator operators -- see below optional: function (p) { return function (s) { var r = null; try { r = p.call(this, s); } catch (e) { return [ null, s ]; } return [ r[0], r[1] ]; }; }, not: function (p) { return function (s) { try { p.call(this, s); } catch (e) { return [null, s]; } throw new $P.Exception(s); }; }, ignore: function (p) { return p ? function (s) { var r = null; r = p.call(this, s); return [null, r[1]]; } : null; }, product: function () { var px = arguments[0], qx = Array.prototype.slice.call(arguments, 1), rx = []; for (var i = 0 ; i < px.length ; i++) { rx.push(_.each(px[i], qx)); } return rx; }, cache: function (rule) { var cache = {}, cache_length = 0, cache_keys = [], CACHE_MAX = Date.Config.CACHE_MAX || 100000, r = null; var cacheCheck = function () { if (cache_length === CACHE_MAX) { // kill several keys, don't want to have to do this all the time... for (var i=0; i < 10; i++) { var key = cache_keys.shift(); if (key) { delete cache[key]; cache_length--; } } } }; return function (s) { cacheCheck(); try { r = cache[s] = (cache[s] || rule.call(this, s)); } catch (e) { r = cache[s] = e; } cache_length++; cache_keys.push(s); if (r instanceof $P.Exception) { throw r; } else { return r; } }; }, // vector operators -- see below any: function () { var px = arguments; return function (s) { var r = null; for (var i = 0; i < px.length; i++) { if (px[i] == null) { continue; } try { r = (px[i].call(this, s)); } catch (e) { r = null; } if (r) { return r; } } throw new $P.Exception(s); }; }, each: function () { var px = arguments; return function (s) { var rx = [], r = null; for (var i = 0; i < px.length ; i++) { if (px[i] == null) { continue; } try { r = (px[i].call(this, s)); } catch (e) { throw new $P.Exception(s); } rx.push(r[0]); s = r[1]; } return [ rx, s]; }; }, all: function () { var px = arguments, _ = _; return _.each(_.optional(px)); }, // delimited operators sequence: function (px, d, c) { d = d || _.rtoken(/^\s*/); c = c || null; if (px.length === 1) { return px[0]; } return function (s) { var r = null, q = null; var rx = []; for (var i = 0; i < px.length ; i++) { try { r = px[i].call(this, s); } catch (e) { break; } rx.push(r[0]); try { q = d.call(this, r[1]); } catch (ex) { q = null; break; } s = q[1]; } if (!r) { throw new $P.Exception(s); } if (q) { throw new $P.Exception(q[1]); } if (c) { try { r = c.call(this, r[1]); } catch (ey) { throw new $P.Exception(r[1]); } } return [ rx, (r?r[1]:s) ]; }; }, // // Composite Operators // between: function (d1, p, d2) { d2 = d2 || d1; var _fn = _.each(_.ignore(d1), p, _.ignore(d2)); return function (s) { var rx = _fn.call(this, s); return [[rx[0][0], r[0][2]], rx[1]]; }; }, list: function (p, d, c) { d = d || _.rtoken(/^\s*/); c = c || null; return (p instanceof Array ? _.each(_.product(p.slice(0, -1), _.ignore(d)), p.slice(-1), _.ignore(c)) : _.each(_.many(_.each(p, _.ignore(d))), px, _.ignore(c))); }, set: function (px, d, c) { d = d || _.rtoken(/^\s*/); c = c || null; return function (s) { // r is the current match, best the current 'best' match // which means it parsed the most amount of input var r = null, p = null, q = null, rx = null, best = [[], s], last = false; // go through the rules in the given set for (var i = 0; i < px.length ; i++) { // last is a flag indicating whether this must be the last element // if there is only 1 element, then it MUST be the last one q = null; p = null; r = null; last = (px.length === 1); // first, we try simply to match the current pattern // if not, try the next pattern try { r = px[i].call(this, s); } catch (e) { continue; } // since we are matching against a set of elements, the first // thing to do is to add r[0] to matched elements rx = [[r[0]], r[1]]; // if we matched and there is still input to parse and // we don't already know this is the last element, // we're going to next check for the delimiter ... // if there's none, or if there's no input left to parse // than this must be the last element after all ... if (r[1].length > 0 && ! last) { try { q = d.call(this, r[1]); } catch (ex) { last = true; } } else { last = true; } // if we parsed the delimiter and now there's no more input, // that means we shouldn't have parsed the delimiter at all // so don't update r and mark this as the last element ... if (!last && q[1].length === 0) { last = true; } // so, if this isn't the last element, we're going to see if // we can get any more matches from the remaining (unmatched) // elements ... if (!last) { // build a list of the remaining rules we can match against, // i.e., all but the one we just matched against var qx = []; for (var j = 0; j < px.length ; j++) { if (i !== j) { qx.push(px[j]); } } // now invoke recursively set with the remaining input // note that we don't include the closing delimiter ... // we'll check for that ourselves at the end p = _.set(qx, d).call(this, q[1]); // if we got a non-empty set as a result ... // (otw rx already contains everything we want to match) if (p[0].length > 0) { // update current result, which is stored in rx ... // basically, pick up the remaining text from p[1] // and concat the result from p[0] so that we don't // get endless nesting ... rx[0] = rx[0].concat(p[0]); rx[1] = p[1]; } } // at this point, rx either contains the last matched element // or the entire matched set that starts with this element. // now we just check to see if this variation is better than // our best so far, in terms of how much of the input is parsed if (rx[1].length < best[1].length) { best = rx; } // if we've parsed all the input, then we're finished if (best[1].length === 0) { break; } } // so now we've either gone through all the patterns trying them // as the initial match; or we found one that parsed the entire // input string ... // if best has no matches, just return empty set ... if (best[0].length === 0) { return best; } // if a closing delimiter is provided, then we have to check it also if (c) { // we try this even if there is no remaining input because the pattern // may well be optional or match empty input ... try { q = c.call(this, best[1]); } catch (ey) { throw new $P.Exception(best[1]); } // it parsed ... be sure to update the best match remaining input best[1] = q[1]; } // if we're here, either there was no closing delimiter or we parsed it // so now we have the best match; just return it! return best; }; }, forward: function (gr, fname) { return function (s) { return gr[fname].call(this, s); }; }, // // Translation Operators // replace: function (rule, repl) { return function (s) { var r = rule.call(this, s); return [repl, r[1]]; }; }, process: function (rule, fn) { return function (s) { var r = rule.call(this, s); return [fn.call(this, r[0]), r[1]]; }; }, min: function (min, rule) { return function (s) { var rx = rule.call(this, s); if (rx[0].length < min) { throw new $P.Exception(s); } return rx; }; } }; // Generator Operators And Vector Operators // Generators are operators that have a signature of F(R) => R, // taking a given rule and returning another rule, such as // ignore, which parses a given rule and throws away the result. // Vector operators are those that have a signature of F(R1,R2,...) => R, // take a list of rules and returning a new rule, such as each. // Generator operators are converted (via the following _generator // function) into functions that can also take a list or array of rules // and return an array of new rules as though the function had been // called on each rule in turn (which is what actually happens). // This allows generators to be used with vector operators more easily. // Example: // each(ignore(foo, bar)) instead of each(ignore(foo), ignore(bar)) // This also turns generators into vector operators, which allows // constructs like: // not(cache(foo, bar)) var _generator = function (op) { function gen() { var args = null, rx = [], px, i; if (arguments.length > 1) { args = Array.prototype.slice.call(arguments); } else if (arguments[0] instanceof Array) { args = arguments[0]; } if (args) { px = args.shift(); if (px.length > 0) { args.unshift(px[i]); rx.push(op.apply(null, args)); args.shift(); return rx; } } else { return op.apply(null, arguments); } } return gen; }; var gx = "optional not ignore cache".split(/\s/); for (var i = 0 ; i < gx.length ; i++) { _[gx[i]] = _generator(_[gx[i]]); } var _vector = function (op) { return function () { if (arguments[0] instanceof Array) { return op.apply(null, arguments[0]); } else { return op.apply(null, arguments); } }; }; var vx = "each any all".split(/\s/); for (var j = 0 ; j < vx.length ; j++) { _[vx[j]] = _vector(_[vx[j]]); } }()); (function () { var $D = Date; var flattenAndCompact = function (ax) { var rx = []; for (var i = 0; i < ax.length; i++) { if (ax[i] instanceof Array) { rx = rx.concat(flattenAndCompact(ax[i])); } else { if (ax[i]) { rx.push(ax[i]); } } } return rx; }; var parseMeridian = function () { if (this.meridian && (this.hour || this.hour === 0)) { if (this.meridian === "a" && this.hour > 11 && Date.Config.strict24hr){ throw "Invalid hour and meridian combination"; } else if (this.meridian === "p" && this.hour < 12 && Date.Config.strict24hr){ throw "Invalid hour and meridian combination"; } else if (this.meridian === "p" && this.hour < 12) { this.hour = this.hour + 12; } else if (this.meridian === "a" && this.hour === 12) { this.hour = 0; } } }; var setDefaults = function () { var now = new Date(); if ((this.hour || this.minute) && (!this.month && !this.year && !this.day)) { this.day = now.getDate(); } if (!this.year) { this.year = now.getFullYear(); } if (!this.month && this.month !== 0) { this.month = now.getMonth(); } if (!this.day) { this.day = 1; } if (!this.hour) { this.hour = 0; } if (!this.minute) { this.minute = 0; } if (!this.second) { this.second = 0; } if (!this.millisecond) { this.millisecond = 0; } }; var finishUtils = { getToday: function () { if (this.now || "hour minute second".indexOf(this.unit) !== -1) { return new Date(); } else { return $D.today(); } }, setDaysFromWeekday: function (today, orient){ var gap; orient = orient || 1; this.unit = "day"; gap = ($D.getDayNumberFromName(this.weekday) - today.getDay()); this.days = gap ? ((gap + (orient * 7)) % 7) : (orient * 7); return this; }, setMonthsFromMonth: function (today, orient) { var gap; orient = orient || 1; this.unit = "month"; gap = (this.month - today.getMonth()); this.months = gap ? ((gap + (orient * 12)) % 12) : (orient * 12); this.month = null; return this; }, setDMYFromWeekday: function () { var d = Date[this.weekday](); this.day = d.getDate(); if (!this.month) { this.month = d.getMonth(); } this.year = d.getFullYear(); return this; }, setUnitValue: function (orient) { if (!this.value && this.operator && this.operator !== null && this[this.unit + "s"] && this[this.unit + "s"] !== null) { this[this.unit + "s"] = this[this.unit + "s"] + ((this.operator === "add") ? 1 : -1) + (this.value||0) * orient; } else if (this[this.unit + "s"] == null || this.operator != null) { if (!this.value) { this.value = 1; } this[this.unit + "s"] = this.value * orient; } }, generateDateFromWeeks: function () { var weekday = (this.weekday !== undefined) ? this.weekday : "today"; var d = Date[weekday]().addWeeks(this.weeks); if (this.now) { d.setTimeToNow(); } return d; } }; $D.Translator = { hour: function (s) { return function () { this.hour = Number(s); }; }, minute: function (s) { return function () { this.minute = Number(s); }; }, second: function (s) { return function () { this.second = Number(s); }; }, /* for ss.s format */ secondAndMillisecond: function (s) { return function () { var mx = s.match(/^([0-5][0-9])\.([0-9]{1,3})/); this.second = Number(mx[1]); this.millisecond = Number(mx[2]); }; }, meridian: function (s) { return function () { this.meridian = s.slice(0, 1).toLowerCase(); }; }, timezone: function (s) { return function () { var n = s.replace(/[^\d\+\-]/g, ""); if (n.length) { this.timezoneOffset = Number(n); } else { this.timezone = s.toLowerCase(); } }; }, day: function (x) { var s = x[0]; return function () { this.day = Number(s.match(/\d+/)[0]); if (this.day < 1) { throw "invalid day"; } }; }, month: function (s) { return function () { this.month = (s.length === 3) ? "jan feb mar apr may jun jul aug sep oct nov dec".indexOf(s)/4 : Number(s) - 1; if (this.month < 0) { throw "invalid month"; } }; }, year: function (s) { return function () { var n = Number(s); this.year = ((s.length > 2) ? n : (n + (((n + 2000) < Date.CultureInfo.twoDigitYearMax) ? 2000 : 1900))); }; }, rday: function (s) { return function () { switch (s) { case "yesterday": this.days = -1; break; case "tomorrow": this.days = 1; break; case "today": this.days = 0; break; case "now": this.days = 0; this.now = true; break; } }; }, finishExact: function (x) { var d; x = (x instanceof Array) ? x : [x]; for (var i = 0 ; i < x.length ; i++) { if (x[i]) { x[i].call(this); } } setDefaults.call(this); parseMeridian.call(this); if (this.day > $D.getDaysInMonth(this.year, this.month)) { throw new RangeError(this.day + " is not a valid value for days."); } d = new Date(this.year, this.month, this.day, this.hour, this.minute, this.second, this.millisecond); if (this.year < 100) { d.setFullYear(this.year); // means years less that 100 are process correctly. JS will parse it otherwise as 1900-1999. } if (this.timezone) { d.set({ timezone: this.timezone }); } else if (this.timezoneOffset) { d.set({ timezoneOffset: this.timezoneOffset }); } return d; }, finish: function (x) { var today, expression, orient, temp; x = (x instanceof Array) ? flattenAndCompact(x) : [ x ]; if (x.length === 0) { return null; } for (var i = 0 ; i < x.length ; i++) { if (typeof x[i] === "function") { x[i].call(this); } } if (this.now && !this.unit && !this.operator) { return new Date(); } else { today = finishUtils.getToday.call(this); } expression = !!(this.days && this.days !== null || this.orient || this.operator); orient = ((this.orient === "past" || this.operator === "subtract") ? -1 : 1); if (this.month && this.unit === "week") { this.value = this.month + 1; delete this.month; delete this.day; } if ((this.month || this.month === 0) && "year day hour minute second".indexOf(this.unit) !== -1) { if (!this.value) { this.value = this.month + 1; } this.month = null; expression = true; } if (!expression && this.weekday && !this.day && !this.days) { finishUtils.setDMYFromWeekday.call(this); } if (expression && this.weekday && this.unit !== "month" && this.unit !== "week") { finishUtils.setDaysFromWeekday.call(this, today, orient); } if (this.weekday && this.unit !== "week" && !this.day && !this.days) { temp = Date[this.weekday](); this.day = temp.getDate(); if (temp.getMonth() !== today.getMonth()) { this.month = temp.getMonth(); } } if (this.month && this.unit === "day" && this.operator) { if (!this.value) { this.value = (this.month + 1); } this.month = null; } if (this.value != null && this.month != null && this.year != null) { this.day = this.value * 1; } if (this.month && !this.day && this.value) { today.set({ day: this.value * 1 }); if (!expression) { this.day = this.value * 1; } } if (!this.month && this.value && this.unit === "month" && !this.now) { this.month = this.value; expression = true; } if (expression && (this.month || this.month === 0) && this.unit !== "year") { finishUtils.setMonthsFromMonth.call(this, today, orient); } if (!this.unit) { this.unit = "day"; } finishUtils.setUnitValue.call(this, orient); parseMeridian.call(this); if ((this.month || this.month === 0) && !this.day) { this.day = 1; } if (!this.orient && !this.operator && this.unit === "week" && this.value && !this.day && !this.month) { return Date.today().setWeek(this.value); } if (this.unit === "week" && this.weeks && !this.day && !this.month) { return finishUtils.generateDateFromWeeks.call(this); } if (expression && this.timezone && this.day && this.days) { this.day = this.days; } if (expression){ today.add(this); } else { today.set(this); } if (this.timezone) { this.timezone = this.timezone.toUpperCase(); var offset = $D.getTimezoneOffset(this.timezone); var timezone; if (today.hasDaylightSavingTime()) { // lets check that we're being sane with timezone setting timezone = $D.getTimezoneAbbreviation(offset, today.isDaylightSavingTime()); if (timezone !== this.timezone) { // bugger, we're in a place where things like EST vs EDT matters. if (today.isDaylightSavingTime()) { today.addHours(-1); } else { today.addHours(1); } } } today.setTimezoneOffset(offset); } return today; } }; }()); (function () { var $D = Date; $D.Grammar = {}; var _ = $D.Parsing.Operators, g = $D.Grammar, t = $D.Translator, _fn; // Allow rolling up into general purpose rules _fn = function () { return _.each(_.any.apply(null, arguments), _.not(g.ctoken2("timeContext"))); }; g.datePartDelimiter = _.rtoken(/^([\s\-\.\,\/\x27]+)/); g.timePartDelimiter = _.stoken(":"); g.whiteSpace = _.rtoken(/^\s*/); g.generalDelimiter = _.rtoken(/^(([\s\,]|at|@|on)+)/); var _C = {}; g.ctoken = function (keys) { var fn = _C[keys]; if (! fn) { var c = Date.CultureInfo.regexPatterns; var kx = keys.split(/\s+/), px = []; for (var i = 0; i < kx.length ; i++) { px.push(_.replace(_.rtoken(c[kx[i]]), kx[i])); } fn = _C[keys] = _.any.apply(null, px); } return fn; }; g.ctoken2 = function (key) { return _.rtoken(Date.CultureInfo.regexPatterns[key]); }; var cacheProcessRtoken = function (key, token, type, eachToken) { if (eachToken) { g[key] = _.cache(_.process(_.each(_.rtoken(token),_.optional(g.ctoken2(eachToken))), type)); } else { g[key] = _.cache(_.process(_.rtoken(token), type)); } }; var cacheProcessCtoken = function (token, type) { return _.cache(_.process(g.ctoken2(token), type)); }; var _F = {}; //function cache var _get = function (f) { _F[f] = (_F[f] || g.format(f)[0]); return _F[f]; }; g.allformats = function (fx) { var rx = []; if (fx instanceof Array) { for (var i = 0; i < fx.length; i++) { rx.push(_get(fx[i])); } } else { rx.push(_get(fx)); } return rx; }; g.formats = function (fx) { if (fx instanceof Array) { var rx = []; for (var i = 0 ; i < fx.length ; i++) { rx.push(_get(fx[i])); } return _.any.apply(null, rx); } else { return _get(fx); } }; var grammarFormats = { timeFormats: function(){ var i, RTokenKeys = [ "h", "hh", "H", "HH", "m", "mm", "s", "ss", "ss.s", "z", "zz" ], RToken = [ /^(0[0-9]|1[0-2]|[1-9])/, /^(0[0-9]|1[0-2])/, /^([0-1][0-9]|2[0-3]|[0-9])/, /^([0-1][0-9]|2[0-3])/, /^([0-5][0-9]|[0-9])/, /^[0-5][0-9]/, /^([0-5][0-9]|[0-9])/, /^[0-5][0-9]/, /^[0-5][0-9]\.[0-9]{1,3}/, /^((\+|\-)\s*\d\d\d\d)|((\+|\-)\d\d\:?\d\d)/, /^((\+|\-)\s*\d\d\d\d)|((\+|\-)\d\d\:?\d\d)/ ], tokens = [ t.hour, t.hour, t.hour, t.hour, t.minute, t.minute, t.second, t.second, t.secondAndMillisecond, t.timezone, t.timezone ]; for (i=0; i < RTokenKeys.length; i++) { cacheProcessRtoken(RTokenKeys[i], RToken[i], tokens[i]); } g.hms = _.cache(_.sequence([g.H, g.m, g.s], g.timePartDelimiter)); g.t = cacheProcessCtoken("shortMeridian", t.meridian); g.tt = cacheProcessCtoken("longMeridian", t.meridian); g.zzz = cacheProcessCtoken("timezone", t.timezone); g.timeSuffix = _.each(_.ignore(g.whiteSpace), _.set([ g.tt, g.zzz ])); g.time = _.each(_.optional(_.ignore(_.stoken("T"))), g.hms, g.timeSuffix); }, dateFormats: function () { // pre-loaded rules for different date part order preferences var _setfn = function () { return _.set(arguments, g.datePartDelimiter); }; var i, RTokenKeys = [ "d", "dd", "M", "MM", "y", "yy", "yyy", "yyyy" ], RToken = [ /^([0-2]\d|3[0-1]|\d)/, /^([0-2]\d|3[0-1])/, /^(1[0-2]|0\d|\d)/, /^(1[0-2]|0\d)/, /^(\d+)/, /^(\d\d)/, /^(\d\d?\d?\d?)/, /^(\d\d\d\d)/ ], tokens = [ t.day, t.day, t.month, t.month, t.year, t.year, t.year, t.year ], eachToken = [ "ordinalSuffix", "ordinalSuffix" ]; for (i=0; i < RTokenKeys.length; i++) { cacheProcessRtoken(RTokenKeys[i], RToken[i], tokens[i], eachToken[i]); } g.MMM = g.MMMM = _.cache(_.process(g.ctoken("jan feb mar apr may jun jul aug sep oct nov dec"), t.month)); g.ddd = g.dddd = _.cache(_.process(g.ctoken("sun mon tue wed thu fri sat"), function (s) { return function () { this.weekday = s; }; } )); g.day = _fn(g.d, g.dd); g.month = _fn(g.M, g.MMM); g.year = _fn(g.yyyy, g.yy); g.mdy = _setfn(g.ddd, g.month, g.day, g.year); g.ymd = _setfn(g.ddd, g.year, g.month, g.day); g.dmy = _setfn(g.ddd, g.day, g.month, g.year); g.date = function (s) { return ((g[Date.CultureInfo.dateElementOrder] || g.mdy).call(this, s)); }; }, relative: function () { // relative date / time expressions g.orientation = _.process(g.ctoken("past future"), function (s) { return function () { this.orient = s; }; } ); g.operator = _.process(g.ctoken("add subtract"), function (s) { return function () { this.operator = s; }; } ); g.rday = _.process(g.ctoken("yesterday tomorrow today now"), t.rday); g.unit = _.process(g.ctoken("second minute hour day week month year"), function (s) { return function () { this.unit = s; }; } ); } }; g.buildGrammarFormats = function () { // these need to be rebuilt every time the language changes. _C = {}; grammarFormats.timeFormats(); grammarFormats.dateFormats(); grammarFormats.relative(); g.value = _.process(_.rtoken(/^([-+]?\d+)?(st|nd|rd|th)?/), function (s) { return function () { this.value = s.replace(/\D/g, ""); }; } ); g.expression = _.set([g.rday, g.operator, g.value, g.unit, g.orientation, g.ddd, g.MMM ]); g.format = _.process(_.many( _.any( // translate format specifiers into grammar rules _.process( _.rtoken(/^(dd?d?d?(?!e)|MM?M?M?|yy?y?y?|hh?|HH?|mm?|ss?|tt?|zz?z?)/), function (fmt) { if (g[fmt]) { return g[fmt]; } else { throw $D.Parsing.Exception(fmt); } } ), // translate separator tokens into token rules _.process(_.rtoken(/^[^dMyhHmstz]+/), // all legal separators function (s) { return _.ignore(_.stoken(s)); } ) ) ), // construct the parser ... function (rules) { return _.process(_.each.apply(null, rules), t.finishExact); } ); // starting rule for general purpose grammar g._start = _.process(_.set([ g.date, g.time, g.expression ], g.generalDelimiter, g.whiteSpace), t.finish); }; g.buildGrammarFormats(); // parsing date format specifiers - ex: "h:m:s tt" // this little guy will generate a custom parser based // on the format string, ex: g.format("h:m:s tt") // check for these formats first g._formats = g.formats([ "\"yyyy-MM-ddTHH:mm:ssZ\"", "yyyy-MM-ddTHH:mm:ss.sz", "yyyy-MM-ddTHH:mm:ssZ", "yyyy-MM-ddTHH:mm:ssz", "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-ddTHH:mmZ", "yyyy-MM-ddTHH:mmz", "yyyy-MM-ddTHH:mm", "ddd, MMM dd, yyyy H:mm:ss tt", "ddd MMM d yyyy HH:mm:ss zzz", "MMddyyyy", "ddMMyyyy", "Mddyyyy", "ddMyyyy", "Mdyyyy", "dMyyyy", "yyyy", "Mdyy", "dMyy", "d" ]); // real starting rule: tries selected formats first, // then general purpose rule g.start = function (s) { try { var r = g._formats.call({}, s); if (r[1].length === 0) { return r; } } catch (e) {} return g._start.call({}, s); }; }()); (function () { var $D = Date; /** * @desc Converts the specified string value into its JavaScript Date equivalent using CultureInfo specific format information. * * Example

	///////////
	// Dates //
	///////////

	// 15-Oct-2004
	var d1 = Date.parse("10/15/2004");

	// 15-Oct-2004
	var d1 = Date.parse("15-Oct-2004");

	// 15-Oct-2004
	var d1 = Date.parse("2004.10.15");

	//Fri Oct 15, 2004
	var d1 = Date.parse("Fri Oct 15, 2004");

	///////////
	// Times //
	///////////

	// Today at 10 PM.
	var d1 = Date.parse("10 PM");

	// Today at 10:30 PM.
	var d1 = Date.parse("10:30 P.M.");

	// Today at 6 AM.
	var d1 = Date.parse("06am");

	/////////////////////
	// Dates and Times //
	/////////////////////

	// 8-July-2004 @ 10:30 PM
	var d1 = Date.parse("July 8th, 2004, 10:30 PM");

	// 1-July-2004 @ 10:30 PM
	var d1 = Date.parse("2004-07-01T22:30:00");

	////////////////////
	// Relative Dates //
	////////////////////

	// Returns today's date. The string "today" is culture specific.
	var d1 = Date.parse("today");

	// Returns yesterday's date. The string "yesterday" is culture specific.
	var d1 = Date.parse("yesterday");

	// Returns the date of the next thursday.
	var d1 = Date.parse("Next thursday");

	// Returns the date of the most previous monday.
	var d1 = Date.parse("last monday");

	// Returns today's day + one year.
	var d1 = Date.parse("next year");

	///////////////
	// Date Math //
	///////////////

	// Today + 2 days
	var d1 = Date.parse("t+2");

	// Today + 2 days
	var d1 = Date.parse("today + 2 days");

	// Today + 3 months
	var d1 = Date.parse("t+3m");

	// Today - 1 year
	var d1 = Date.parse("today - 1 year");

	// Today - 1 year
	var d1 = Date.parse("t-1y"); 


	/////////////////////////////
	// Partial Dates and Times //
	/////////////////////////////

	// July 15th of this year.
	var d1 = Date.parse("July 15");

	// 15th day of current day and year.
	var d1 = Date.parse("15");

	// July 1st of current year at 10pm.
	var d1 = Date.parse("7/1 10pm");
	
* * @param {String} The string value to convert into a Date object [Required] * @return {Date} A Date object or null if the string cannot be converted into a Date. */ var parseUtils = { removeOrds: function (s) { ords = s.match(/\b(\d+)(?:st|nd|rd|th)\b/); // find ordinal matches s = ((ords && ords.length === 2) ? s.replace(ords[0], ords[1]) : s); return s; }, grammarParser: function (s) { var r = null; try { r = $D.Grammar.start.call({}, s.replace(/^\s*(\S*(\s+\S+)*)\s*$/, "$1")); } catch (e) { return null; } return ((r[1].length === 0) ? r[0] : null); }, nativeFallback: function(s) { var t; try { // ok we haven't parsed it, last ditch attempt with the built-in parser. t = Date._parse(s); return (t || t === 0) ? new Date(t) : null; } catch (e) { return null; } } }; function parse (s) { var d; if (!s) { return null; } if (s instanceof Date) { return s.clone(); } if (s.length >= 4 && s.charAt(0) !== "0" && s.charAt(0) !== "+"&& s.charAt(0) !== "-") { // ie: 2004 will pass, 0800 won't. // Start with specific formats d = $D.Parsing.ISO.parse(s) || $D.Parsing.Numeric.parse(s); } if (d instanceof Date && !isNaN(d.getTime())) { return d; } else { // find ordinal dates (1st, 3rd, 8th, etc and remove them as they cause parsing issues) s = $D.Parsing.Normalizer.parse(parseUtils.removeOrds(s)); d = parseUtils.grammarParser(s); if (d !== null) { return d; } else { return parseUtils.nativeFallback(s); } } } if (!$D._parse) { $D._parse = $D.parse; } $D.parse = parse; Date.getParseFunction = function (fx) { var fns = Date.Grammar.allformats(fx); return function (s) { var r = null; for (var i = 0; i < fns.length; i++) { try { r = fns[i].call({}, s); } catch (e) { continue; } if (r[1].length === 0) { return r[0]; } } return null; }; }; /** * Converts the specified string value into its JavaScript Date equivalent using the specified format {String} or formats {Array} and the CultureInfo specific format information. * The format of the string value must match one of the supplied formats exactly. * * Example

	// 15-Oct-2004
	var d1 = Date.parseExact("10/15/2004", "M/d/yyyy");

	// 15-Oct-2004
	var d1 = Date.parse("15-Oct-2004", "M-ddd-yyyy");

	// 15-Oct-2004
	var d1 = Date.parse("2004.10.15", "yyyy.MM.dd");

	// Multiple formats
	var d1 = Date.parseExact("10/15/2004", ["M/d/yyyy", "MMMM d, yyyy"]);
	
* * @param {String} The string value to convert into a Date object [Required]. * @param {Object} The expected format {String} or an array of expected formats {Array} of the date string [Required]. * @return {Date} A Date object or null if the string cannot be converted into a Date. */ $D.parseExact = function (s, fx) { return $D.getParseFunction(fx)(s); }; }()); (function () { var $D = Date, $P = $D.prototype, // $C = $D.CultureInfo, // not used atm p = function (s, l) { if (!l) { l = 2; } return ("000" + s).slice(l * -1); }; /** * Converts a PHP format string to Java/.NET format string. * A PHP format string can be used with ._format or .format. * A Java/.NET format string can be used with .toString(). * The .parseExact function will only accept a Java/.NET format string * * Example * var f1 = "%m/%d/%y" * var f2 = Date.normalizeFormat(f1); // "MM/dd/yy" * * new Date().format(f1); // "04/13/08" * new Date()._format(f1); // "04/13/08" * new Date().toString(f2); // "04/13/08" * * var date = Date.parseExact("04/13/08", f2); // Sun Apr 13 2008 * * @param {String} A PHP format string consisting of one or more format spcifiers. * @return {String} The PHP format converted to a Java/.NET format string. */ var normalizerSubstitutions = { "d" : "dd", "%d": "dd", "D" : "ddd", "%a": "ddd", "j" : "dddd", "l" : "dddd", "%A": "dddd", "S" : "S", "F" : "MMMM", "%B": "MMMM", "m" : "MM", "%m": "MM", "M" : "MMM", "%b": "MMM", "%h": "MMM", "n" : "M", "Y" : "yyyy", "%Y": "yyyy", "y" : "yy", "%y": "yy", "g" : "h", "%I": "h", "G" : "H", "h" : "hh", "H" : "HH", "%H": "HH", "i" : "mm", "%M": "mm", "s" : "ss", "%S": "ss", "%r": "hh:mm tt", "%R": "H:mm", "%T": "H:mm:ss", "%X": "t", "%x": "d", "%e": "d", "%D": "MM/dd/yy", "%n": "\\n", "%t": "\\t", "e" : "z", "T" : "z", "%z": "z", "%Z": "z", "Z" : "ZZ", "N" : "u", "w" : "u", "%w": "u", "W" : "W", "%V": "W" }; var normalizer = { substitutes: function (m) { return normalizerSubstitutions[m]; }, interpreted: function (m, x) { var y; switch (m) { case "%u": return x.getDay() + 1; case "z": return x.getOrdinalNumber(); case "%j": return p(x.getOrdinalNumber(), 3); case "%U": var d1 = x.clone().set({month: 0, day: 1}).addDays(-1).moveToDayOfWeek(0), d2 = x.clone().addDays(1).moveToDayOfWeek(0, -1); return (d2 < d1) ? "00" : p((d2.getOrdinalNumber() - d1.getOrdinalNumber()) / 7 + 1); case "%W": return p(x.getWeek()); case "t": return $D.getDaysInMonth(x.getFullYear(), x.getMonth()); case "o": case "%G": return x.setWeek(x.getISOWeek()).toString("yyyy"); case "%g": return x._format("%G").slice(-2); case "a": case "%p": return t("tt").toLowerCase(); case "A": return t("tt").toUpperCase(); case "u": return p(x.getMilliseconds(), 3); case "I": return (x.isDaylightSavingTime()) ? 1 : 0; case "O": return x.getUTCOffset(); case "P": y = x.getUTCOffset(); return y.substring(0, y.length - 2) + ":" + y.substring(y.length - 2); case "B": var now = new Date(); return Math.floor(((now.getHours() * 3600) + (now.getMinutes() * 60) + now.getSeconds() + (now.getTimezoneOffset() + 60) * 60) / 86.4); case "c": return x.toISOString().replace(/\"/g, ""); case "U": return $D.strtotime("now"); case "%c": return t("d") + " " + t("t"); case "%C": return Math.floor(x.getFullYear() / 100 + 1); } }, shouldOverrideDefaults: function (m) { switch (m) { case "%e": return true; default: return false; } }, parse: function (m, context) { var formatString, c = context || new Date(); formatString = normalizer.substitutes(m); if (formatString) { return formatString; } formatString = normalizer.interpreted(m, c); if (formatString) { return formatString; } else { return m; } } }; $D.normalizeFormat = function (format, context) { return format.replace(/(%|\\)?.|%%/g, function(t){ return normalizer.parse(t, context); }); }; /** * Format a local Unix timestamp according to locale settings * * Example: * Date.strftime("%m/%d/%y", new Date()); // "04/13/08" * Date.strftime("c", "2008-04-13T17:52:03Z"); // "04/13/08" * * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @param {Number|String} The number representing the number of seconds that have elapsed since January 1, 1970 (local time). * @return {String} A string representation of the current Date object. */ $D.strftime = function (format, time) { var d = Date.parse(time); return d._format(format); }; /** * Parse any textual datetime description into a Unix timestamp. * A Unix timestamp is the number of seconds that have elapsed since January 1, 1970 (midnight UTC/GMT). * * Example: * Date.strtotime("04/13/08"); // 1208044800 * Date.strtotime("1970-01-01T00:00:00Z"); // 0 * * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @param {Object} A string or date object. * @return {String} A string representation of the current Date object. */ $D.strtotime = function (time) { var d = $D.parse(time); return Math.round($D.UTC(d.getUTCFullYear(), d.getUTCMonth(), d.getUTCDate(), d.getUTCHours(), d.getUTCMinutes(), d.getUTCSeconds(), d.getUTCMilliseconds()) / 1000); }; /** * Converts the value of the current Date object to its equivalent string representation using a PHP/Unix style of date format specifiers. * Format Specifiers * Format Description Example * ------ --------------------------------------------------------------------------- ----------------------- * %a abbreviated weekday name according to the current localed "Mon" through "Sun" * %A full weekday name according to the current localed "Sunday" through "Saturday" * %b abbreviated month name according to the current localed "Jan" through "Dec" * %B full month name according to the current locale "January" through "December" * %c preferred date and time representation for the current locale "4/13/2008 12:33 PM" * %C century number (the year divided by 100 and truncated to an integer) "00" to "99" * %d day of the month as a decimal number "01" to "31" * %D same as %m/%d/%y "04/13/08" * %e day of the month as a decimal number, a single digit is preceded by a space "1" to "31" * %g like %G, but without the century "08" * %G The 4-digit year corresponding to the ISO week number (see %V). "2008" * This has the same format and value as %Y, except that if the ISO week number * belongs to the previous or next year, that year is used instead. * %h same as %b "Jan" through "Dec" * %H hour as a decimal number using a 24-hour clock. "00" to "23" * %I hour as a decimal number using a 12-hour clock. "01" to "12" * %j day of the year as a decimal number. "001" to "366" * %m month as a decimal number. "01" to "12" * %M minute as a decimal number. "00" to "59" * %n newline character "\n" * %p either "am" or "pm" according to the given time value, or the "am" or "pm" * corresponding strings for the current locale. * %r time in a.m. and p.m. notation "8:44 PM" * %R time in 24 hour notation "20:44" * %S second as a decimal number "00" to "59" * %t tab character "\t" * %T current time, equal to %H:%M:%S "12:49:11" * %u weekday as a decimal number ["1", "7"], with "1" representing Monday "1" to "7" * %U week number of the current year as a decimal number, starting with the "0" to ("52" or "53") * first Sunday as the first day of the first week * %V The ISO 8601:1988 week number of the current year as a decimal number, "00" to ("52" or "53") * range 01 to 53, where week 1 is the first week that has at least 4 days * in the current year, and with Monday as the first day of the week. * (Use %G or %g for the year component that corresponds to the week number * for the specified timestamp.) * %W week number of the current year as a decimal number, starting with the "00" to ("52" or "53") * first Monday as the first day of the first week * %w day of the week as a decimal, Sunday being "0" "0" to "6" * %x preferred date representation for the current locale without the time "4/13/2008" * %X preferred time representation for the current locale without the date "12:53:05" * %y year as a decimal number without a century "00" "99" * %Y year as a decimal number including the century "2008" * %Z time zone or name or abbreviation "UTC", "EST", "PST" * %z same as %Z * %% a literal "%" characters "%" * d Day of the month, 2 digits with leading zeros "01" to "31" * D A textual representation of a day, three letters "Mon" through "Sun" * j Day of the month without leading zeros "1" to "31" * l A full textual representation of the day of the week (lowercase "L") "Sunday" through "Saturday" * N ISO-8601 numeric representation of the day of the week (added in PHP 5.1.0) "1" (for Monday) through "7" (for Sunday) * S English ordinal suffix for the day of the month, 2 characters "st", "nd", "rd" or "th". Works well with j * w Numeric representation of the day of the week "0" (for Sunday) through "6" (for Saturday) * z The day of the year (starting from "0") "0" through "365" * W ISO-8601 week number of year, weeks starting on Monday "00" to ("52" or "53") * F A full textual representation of a month, such as January or March "January" through "December" * m Numeric representation of a month, with leading zeros "01" through "12" * M A short textual representation of a month, three letters "Jan" through "Dec" * n Numeric representation of a month, without leading zeros "1" through "12" * t Number of days in the given month "28" through "31" * L Whether it's a leap year "1" if it is a leap year, "0" otherwise * o ISO-8601 year number. This has the same value as Y, except that if the "2008" * ISO week number (W) belongs to the previous or next year, that year * is used instead. * Y A full numeric representation of a year, 4 digits "2008" * y A two digit representation of a year "08" * a Lowercase Ante meridiem and Post meridiem "am" or "pm" * A Uppercase Ante meridiem and Post meridiem "AM" or "PM" * B Swatch Internet time "000" through "999" * g 12-hour format of an hour without leading zeros "1" through "12" * G 24-hour format of an hour without leading zeros "0" through "23" * h 12-hour format of an hour with leading zeros "01" through "12" * H 24-hour format of an hour with leading zeros "00" through "23" * i Minutes with leading zeros "00" to "59" * s Seconds, with leading zeros "00" through "59" * u Milliseconds "54321" * e Timezone identifier "UTC", "EST", "PST" * I Whether or not the date is in daylight saving time (uppercase i) "1" if Daylight Saving Time, "0" otherwise * O Difference to Greenwich time (GMT) in hours "+0200", "-0600" * P Difference to Greenwich time (GMT) with colon between hours and minutes "+02:00", "-06:00" * T Timezone abbreviation "UTC", "EST", "PST" * Z Timezone offset in seconds. The offset for timezones west of UTC is "-43200" through "50400" * always negative, and for those east of UTC is always positive. * c ISO 8601 date "2004-02-12T15:19:21+00:00" * r RFC 2822 formatted date "Thu, 21 Dec 2000 16:01:07 +0200" * U Seconds since the Unix Epoch (January 1 1970 00:00:00 GMT) "0" * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @return {String} A string representation of the current Date object. */ var formatReplace = function (context) { return function (m) { var formatString, override = false; if (m.charAt(0) === "\\" || m.substring(0, 2) === "%%") { return m.replace("\\", "").replace("%%", "%"); } override = normalizer.shouldOverrideDefaults(m); formatString = $D.normalizeFormat(m, context); if (formatString) { return context.toString(formatString, override); } }; }; $P._format = function (format) { var formatter = formatReplace(this); if (!format) { return this._toString(); } else { return format.replace(/(%|\\)?.|%%/g, formatter); } }; if (!$P.format) { $P.format = $P._format; } }()); (function () { "use strict"; var gFn = function (attr) { return function () { return this[attr]; }; }; var sFn = function (attr) { return function (val) { this[attr] = val; return this; }; }; var attrs = ["years", "months", "days", "hours", "minutes", "seconds", "milliseconds"]; var addSetFuncs = function (context, attrs) { for (var i = 0; i < attrs.length ; i++) { var $a = attrs[i], $b = $a.slice(0, 1).toUpperCase() + $a.slice(1); context.prototype[$a] = 0; context.prototype["get" + $b] = gFn($a); context.prototype["set" + $b] = sFn($a); } }; /** * new TimeSpan(milliseconds); * new TimeSpan(days, hours, minutes, seconds); * new TimeSpan(days, hours, minutes, seconds, milliseconds); */ var TimeSpan = function (days, hours, minutes, seconds, milliseconds) { if (arguments.length === 1 && typeof days === "number") { var orient = (days < 0) ? -1 : +1; var millsLeft = Math.abs(days); this.setDays(Math.floor(millsLeft / 86400000) * orient); millsLeft = millsLeft % 86400000; this.setHours(Math.floor(millsLeft / 3600000) * orient); millsLeft = millsLeft % 3600000; this.setMinutes(Math.floor(millsLeft / 60000) * orient); millsLeft = millsLeft % 60000; this.setSeconds(Math.floor(millsLeft / 1000) * orient); millsLeft = millsLeft % 1000; this.setMilliseconds(millsLeft * orient); } else { this.set(days, hours, minutes, seconds, milliseconds); } this.getTotalMilliseconds = function () { return (this.getDays() * 86400000) + (this.getHours() * 3600000) + (this.getMinutes() * 60000) + (this.getSeconds() * 1000); }; this.compareTo = function (time) { var t1 = new Date(1970, 1, 1, this.getHours(), this.getMinutes(), this.getSeconds()), t2; if (time === null) { t2 = new Date(1970, 1, 1, 0, 0, 0); } else { t2 = new Date(1970, 1, 1, time.getHours(), time.getMinutes(), time.getSeconds()); } return (t1 < t2) ? -1 : (t1 > t2) ? 1 : 0; }; this.equals = function (time) { return (this.compareTo(time) === 0); }; this.add = function (time) { return (time === null) ? this : this.addSeconds(time.getTotalMilliseconds() / 1000); }; this.subtract = function (time) { return (time === null) ? this : this.addSeconds(-time.getTotalMilliseconds() / 1000); }; this.addDays = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 86400000)); }; this.addHours = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 3600000)); }; this.addMinutes = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 60000)); }; this.addSeconds = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 1000)); }; this.addMilliseconds = function (n) { return new TimeSpan(this.getTotalMilliseconds() + n); }; this.get12HourHour = function () { return (this.getHours() > 12) ? this.getHours() - 12 : (this.getHours() === 0) ? 12 : this.getHours(); }; this.getDesignator = function () { return (this.getHours() < 12) ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator; }; this.toString = function (format) { this._toString = function () { if (this.getDays() !== null && this.getDays() > 0) { return this.getDays() + "." + this.getHours() + ":" + this.p(this.getMinutes()) + ":" + this.p(this.getSeconds()); } else { return this.getHours() + ":" + this.p(this.getMinutes()) + ":" + this.p(this.getSeconds()); } }; this.p = function (s) { return (s.toString().length < 2) ? "0" + s : s; }; var me = this; return format ? format.replace(/dd?|HH?|hh?|mm?|ss?|tt?/g, function (format) { switch (format) { case "d": return me.getDays(); case "dd": return me.p(me.getDays()); case "H": return me.getHours(); case "HH": return me.p(me.getHours()); case "h": return me.get12HourHour(); case "hh": return me.p(me.get12HourHour()); case "m": return me.getMinutes(); case "mm": return me.p(me.getMinutes()); case "s": return me.getSeconds(); case "ss": return me.p(me.getSeconds()); case "t": return ((me.getHours() < 12) ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator).substring(0, 1); case "tt": return (me.getHours() < 12) ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator; } } ) : this._toString(); }; return this; }; addSetFuncs(TimeSpan, attrs.slice(2)); TimeSpan.prototype.set = function (days, hours, minutes, seconds, milliseconds){ this.setDays(days || this.getDays()); this.setHours(hours || this.getHours()); this.setMinutes(minutes || this.getMinutes()); this.setSeconds(seconds || this.getSeconds()); this.setMilliseconds(milliseconds || this.getMilliseconds()); }; /** * Gets the time of day for this date instances. * @return {TimeSpan} TimeSpan */ Date.prototype.getTimeOfDay = function () { return new TimeSpan(0, this.getHours(), this.getMinutes(), this.getSeconds(), this.getMilliseconds()); }; Date.TimeSpan = TimeSpan; if (typeof window !== "undefined" ) { // keeping API compatible for v1.x window.TimeSpan = TimeSpan; } }()); (function () { "use strict"; var attrs = ["years", "months", "days", "hours", "minutes", "seconds", "milliseconds"]; var gFn = function (attr) { return function () { return this[attr]; }; }; var sFn = function (attr) { return function (val) { this[attr] = val; return this; }; }; var addSetFuncs = function (context, attrs) { for (var i = 0; i < attrs.length ; i++) { var $a = attrs[i], $b = $a.slice(0, 1).toUpperCase() + $a.slice(1); context.prototype[$a] = 0; context.prototype["get" + $b] = gFn($a); context.prototype["set" + $b] = sFn($a); } }; var setMonthsAndYears = function (orient, d1, d2, context) { function inc() { d1.addMonths(-orient); context.months++; if (context.months === 12) { context.years++; context.months = 0; } } if (orient === +1) { while (d1 > d2) { inc(); } } else { while (d1 < d2) { inc(); } } context.months--; context.months *= orient; context.years *= orient; }; var adjustForDST = function(orient, startDate, endDate) { var hasDSTMismatch = (false === (startDate.isDaylightSavingTime() === endDate.isDaylightSavingTime())); if (hasDSTMismatch && orient === 1) { startDate.addHours(-1); } else if (hasDSTMismatch) { startDate.addHours(1); } }; /** * TimePeriod(startDate, endDate); * TimePeriod(years, months, days, hours, minutes, seconds, milliseconds); */ var TimePeriod = function (years, months, days, hours, minutes, seconds, milliseconds) { if (arguments.length === 7) { this.set(years, months, days, hours, minutes, seconds, milliseconds); } else if (arguments.length === 2 && arguments[0] instanceof Date && arguments[1] instanceof Date) { var startDate = arguments[0].clone(); var endDate = arguments[1].clone(); var orient = (startDate > endDate) ? +1 : -1; this.dates = { start: arguments[0].clone(), end: arguments[1].clone() }; setMonthsAndYears(orient, startDate, endDate, this); adjustForDST(orient, startDate, endDate); // // TODO - adjust for DST var diff = endDate - startDate; if (diff !== 0) { var ts = new TimeSpan(diff); this.set(this.years, this.months, ts.getDays(), ts.getHours(), ts.getMinutes(), ts.getSeconds(), ts.getMilliseconds()); } } return this; }; // create all the set functions. addSetFuncs(TimePeriod, attrs); TimePeriod.prototype.set = function (years, months, days, hours, minutes, seconds, milliseconds){ this.setYears(years || this.getYears()); this.setMonths(months || this.getMonths()); this.setDays(days || this.getDays()); this.setHours(hours || this.getHours()); this.setMinutes(minutes || this.getMinutes()); this.setSeconds(seconds || this.getSeconds()); this.setMilliseconds(milliseconds || this.getMilliseconds()); }; Date.TimePeriod = TimePeriod; if (typeof window !== "undefined") { // keeping API compatible for v1.x window.TimePeriod = TimePeriod; } }()); ================================================ FILE: build/date-ar-AE.js ================================================ /** * @overview datejs * @version 1.0.0-rc3 * @author Gregory Wild-Smith * @copyright 2015 Gregory Wild-Smith * @license MIT * @homepage https://github.com/abritinthebay/datejs */ /* * DateJS Culture String File * Country Code: ar-AE * Name: Arabic (U.A.E.) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["ar-AE"] = { "name": "ar-AE", "englishName": "Arabic (U.A.E.)", "nativeName": "العربية (الإمارات العربية المتحدة)", "Sunday": "الاحد", "Monday": "الاثنين", "Tuesday": "الثلاثاء", "Wednesday": "الاربعاء", "Thursday": "الخميس", "Friday": "الجمعة", "Saturday": "السبت", "Sun": "الاحد", "Mon": "الاثنين", "Tue": "الثلاثاء", "Wed": "الاربعاء", "Thu": "الخميس", "Fri": "الجمعة", "Sat": "السبت", "Su": "أ", "Mo": "ا", "Tu": "ث", "We": "أ", "Th": "خ", "Fr": "ج", "Sa": "س", "S_Sun_Initial": "أ", "M_Mon_Initial": "ا", "T_Tue_Initial": "ث", "W_Wed_Initial": "أ", "T_Thu_Initial": "خ", "F_Fri_Initial": "ج", "S_Sat_Initial": "س", "January": "يناير", "February": "فبراير", "March": "مارس", "April": "ابريل", "May": "مايو", "June": "يونيو", "July": "يوليو", "August": "اغسطس", "September": "سبتمبر", "October": "اكتوبر", "November": "نوفمبر", "December": "ديسمبر", "Jan_Abbr": "يناير", "Feb_Abbr": "فبراير", "Mar_Abbr": "مارس", "Apr_Abbr": "ابريل", "May_Abbr": "مايو", "Jun_Abbr": "يونيو", "Jul_Abbr": "يوليو", "Aug_Abbr": "اغسطس", "Sep_Abbr": "سبتمبر", "Oct_Abbr": "اكتوبر", "Nov_Abbr": "نوفمبر", "Dec_Abbr": "ديسمبر", "AM": "ص", "PM": "م", "firstDayOfWeek": 6, "twoDigitYearMax": 2029, "mdy": "dmy", "M/d/yyyy": "dd/MM/yyyy", "dddd, MMMM dd, yyyy": "dd MMMM, yyyy", "h:mm tt": "hh:mm tt", "h:mm:ss tt": "hh:mm:ss tt", "dddd, MMMM dd, yyyy h:mm:ss tt": "dd MMMM, yyyy hh:mm:ss tt", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "dd MMMM", "MMMM, yyyy": "MMMM, yyyy", "/jan(uary)?/": "يناير", "/feb(ruary)?/": "فبراير", "/mar(ch)?/": "مارس", "/apr(il)?/": "ابريل", "/may/": "مايو", "/jun(e)?/": "يونيو", "/jul(y)?/": "يوليو", "/aug(ust)?/": "اغسطس", "/sep(t(ember)?)?/": "سبتمبر", "/oct(ober)?/": "اكتوبر", "/nov(ember)?/": "نوفمبر", "/dec(ember)?/": "ديسمبر", "/^su(n(day)?)?/": "^الاحد", "/^mo(n(day)?)?/": "^ا(1)?", "/^tu(e(s(day)?)?)?/": "^الثلاثاء", "/^we(d(nesday)?)?/": "^الاربعاء", "/^th(u(r(s(day)?)?)?)?/": "^الخميس", "/^fr(i(day)?)?/": "^الجمعة", "/^sa(t(urday)?)?/": "^السبت", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "ar-AE"; /** * @overview datejs * @version 1.0.0-rc3 * @author Gregory Wild-Smith * @copyright 2015 Gregory Wild-Smith * @license MIT * @homepage https://github.com/abritinthebay/datejs */(function () { var $D = Date; var lang = Date.CultureStrings ? Date.CultureStrings.lang : null; var loggedKeys = {}; // for debug purposes. var getText = { getFromKey: function (key, countryCode) { var output; if (Date.CultureStrings && Date.CultureStrings[countryCode] && Date.CultureStrings[countryCode][key]) { output = Date.CultureStrings[countryCode][key]; } else { output = getText.buildFromDefault(key); } if (key.charAt(0) === "/") { // Assume it's a regex output = getText.buildFromRegex(key, countryCode); } return output; }, getFromObjectValues: function (obj, countryCode) { var key, output = {}; for(key in obj) { if (obj.hasOwnProperty(key)) { output[key] = getText.getFromKey(obj[key], countryCode); } } return output; }, getFromObjectKeys: function (obj, countryCode) { var key, output = {}; for(key in obj) { if (obj.hasOwnProperty(key)) { output[getText.getFromKey(key, countryCode)] = obj[key]; } } return output; }, getFromArray: function (arr, countryCode) { var output = []; for (var i=0; i < arr.length; i++){ if (i in arr) { output[i] = getText.getFromKey(arr[i], countryCode); } } return output; }, buildFromDefault: function (key) { var output, length, split, last; switch(key) { case "name": output = "en-US"; break; case "englishName": output = "English (United States)"; break; case "nativeName": output = "English (United States)"; break; case "twoDigitYearMax": output = 2049; break; case "firstDayOfWeek": output = 0; break; default: output = key; split = key.split("_"); length = split.length; if (length > 1 && key.charAt(0) !== "/") { // if the key isn't a regex and it has a split. last = split[(length - 1)].toLowerCase(); if (last === "initial" || last === "abbr") { output = split[0]; } } break; } return output; }, buildFromRegex: function (key, countryCode) { var output; if (Date.CultureStrings && Date.CultureStrings[countryCode] && Date.CultureStrings[countryCode][key]) { output = new RegExp(Date.CultureStrings[countryCode][key], "i"); } else { output = new RegExp(key.replace(new RegExp("/", "g"),""), "i"); } return output; } }; var shallowMerge = function (obj1, obj2) { for (var attrname in obj2) { if (obj2.hasOwnProperty(attrname)) { obj1[attrname] = obj2[attrname]; } } }; var __ = function (key, language) { var countryCode = (language) ? language : lang; loggedKeys[key] = key; if (typeof key === "object") { if (key instanceof Array) { return getText.getFromArray(key, countryCode); } else { return getText.getFromObjectKeys(key, countryCode); } } else { return getText.getFromKey(key, countryCode); } }; var loadI18nScript = function (code) { // paatterned after jQuery's getScript. var url = Date.Config.i18n + code + ".js"; var head = document.getElementsByTagName("head")[0] || document.documentElement; var script = document.createElement("script"); script.src = url; var completed = false; var events = { done: function (){} // placeholder function }; // Attach handlers for all browsers script.onload = script.onreadystatechange = function() { if ( !completed && (!this.readyState || this.readyState === "loaded" || this.readyState === "complete") ) { events.done(); head.removeChild(script); } }; setTimeout(function() { head.insertBefore(script, head.firstChild); }, 0); // allows return to execute first return { done: function (cb) { events.done = function() { if (cb) { setTimeout(cb,0); } }; } }; }; var buildInfo = { buildFromMethodHash: function (obj) { var key; for(key in obj) { if (obj.hasOwnProperty(key)) { obj[key] = buildInfo[obj[key]](); } } return obj; }, timeZoneDST: function () { var DST = { "CHADT": "+1345", "NZDT": "+1300", "AEDT": "+1100", "ACDT": "+1030", "AZST": "+0500", "IRDT": "+0430", "EEST": "+0300", "CEST": "+0200", "BST": "+0100", "PMDT": "-0200", "ADT": "-0300", "NDT": "-0230", "EDT": "-0400", "CDT": "-0500", "MDT": "-0600", "PDT": "-0700", "AKDT": "-0800", "HADT": "-0900" }; return __(DST); }, timeZoneStandard: function () { var standard = { "LINT": "+1400", "TOT": "+1300", "CHAST": "+1245", "NZST": "+1200", "NFT": "+1130", "SBT": "+1100", "AEST": "+1000", "ACST": "+0930", "JST": "+0900", "CWST": "+0845", "CT": "+0800", "ICT": "+0700", "MMT": "+0630", "BST": "+0600", "NPT": "+0545", "IST": "+0530", "PKT": "+0500", "AFT": "+0430", "MSK": "+0400", "IRST": "+0330", "FET": "+0300", "EET": "+0200", "CET": "+0100", "GMT": "+0000", "UTC": "+0000", "CVT": "-0100", "GST": "-0200", "BRT": "-0300", "NST": "-0330", "AST": "-0400", "EST": "-0500", "CST": "-0600", "MST": "-0700", "PST": "-0800", "AKST": "-0900", "MIT": "-0930", "HST": "-1000", "SST": "-1100", "BIT": "-1200" }; return __(standard); }, timeZones: function (data) { var zone; data.timezones = []; for (zone in data.abbreviatedTimeZoneStandard) { if (data.abbreviatedTimeZoneStandard.hasOwnProperty(zone)) { data.timezones.push({ name: zone, offset: data.abbreviatedTimeZoneStandard[zone]}); } } for (zone in data.abbreviatedTimeZoneDST) { if (data.abbreviatedTimeZoneDST.hasOwnProperty(zone)) { data.timezones.push({ name: zone, offset: data.abbreviatedTimeZoneDST[zone], dst: true}); } } return data.timezones; }, days: function () { return __(["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"]); }, dayAbbr: function () { return __(["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"]); }, dayShortNames: function () { return __(["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"]); }, dayFirstLetters: function () { return __(["S_Sun_Initial", "M_Mon_Initial", "T_Tues_Initial", "W_Wed_Initial", "T_Thu_Initial", "F_Fri_Initial", "S_Sat_Initial"]); }, months: function () { return __(["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"]); }, monthAbbr: function () { return __(["Jan_Abbr", "Feb_Abbr", "Mar_Abbr", "Apr_Abbr", "May_Abbr", "Jun_Abbr", "Jul_Abbr", "Aug_Abbr", "Sep_Abbr", "Oct_Abbr", "Nov_Abbr", "Dec_Abbr"]); }, formatPatterns: function () { return getText.getFromObjectValues({ shortDate: "M/d/yyyy", longDate: "dddd, MMMM dd, yyyy", shortTime: "h:mm tt", longTime: "h:mm:ss tt", fullDateTime: "dddd, MMMM dd, yyyy h:mm:ss tt", sortableDateTime: "yyyy-MM-ddTHH:mm:ss", universalSortableDateTime: "yyyy-MM-dd HH:mm:ssZ", rfc1123: "ddd, dd MMM yyyy HH:mm:ss", monthDay: "MMMM dd", yearMonth: "MMMM, yyyy" }, Date.i18n.currentLanguage()); }, regex: function () { return getText.getFromObjectValues({ inTheMorning: "/( in the )(morn(ing)?)\\b/", thisMorning: "/(this )(morn(ing)?)\\b/", amThisMorning: "/(\b\\d(am)? )(this )(morn(ing)?)/", inTheEvening: "/( in the )(even(ing)?)\\b/", thisEvening: "/(this )(even(ing)?)\\b/", pmThisEvening: "/(\b\\d(pm)? )(this )(even(ing)?)/", jan: "/jan(uary)?/", feb: "/feb(ruary)?/", mar: "/mar(ch)?/", apr: "/apr(il)?/", may: "/may/", jun: "/jun(e)?/", jul: "/jul(y)?/", aug: "/aug(ust)?/", sep: "/sep(t(ember)?)?/", oct: "/oct(ober)?/", nov: "/nov(ember)?/", dec: "/dec(ember)?/", sun: "/^su(n(day)?)?/", mon: "/^mo(n(day)?)?/", tue: "/^tu(e(s(day)?)?)?/", wed: "/^we(d(nesday)?)?/", thu: "/^th(u(r(s(day)?)?)?)?/", fri: "/fr(i(day)?)?/", sat: "/^sa(t(urday)?)?/", future: "/^next/", past: "/^last|past|prev(ious)?/", add: "/^(\\+|aft(er)?|from|hence)/", subtract: "/^(\\-|bef(ore)?|ago)/", yesterday: "/^yes(terday)?/", today: "/^t(od(ay)?)?/", tomorrow: "/^tom(orrow)?/", now: "/^n(ow)?/", millisecond: "/^ms|milli(second)?s?/", second: "/^sec(ond)?s?/", minute: "/^mn|min(ute)?s?/", hour: "/^h(our)?s?/", week: "/^w(eek)?s?/", month: "/^m(onth)?s?/", day: "/^d(ay)?s?/", year: "/^y(ear)?s?/", shortMeridian: "/^(a|p)/", longMeridian: "/^(a\\.?m?\\.?|p\\.?m?\\.?)/", timezone: "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/", ordinalSuffix: "/^\\s*(st|nd|rd|th)/", timeContext: "/^\\s*(\\:|a(?!u|p)|p)/" }, Date.i18n.currentLanguage()); } }; var CultureInfo = function () { var info = getText.getFromObjectValues({ name: "name", englishName: "englishName", nativeName: "nativeName", amDesignator: "AM", pmDesignator: "PM", firstDayOfWeek: "firstDayOfWeek", twoDigitYearMax: "twoDigitYearMax", dateElementOrder: "mdy" }, Date.i18n.currentLanguage()); var constructedInfo = buildInfo.buildFromMethodHash({ dayNames: "days", abbreviatedDayNames: "dayAbbr", shortestDayNames: "dayShortNames", firstLetterDayNames: "dayFirstLetters", monthNames: "months", abbreviatedMonthNames: "monthAbbr", formatPatterns: "formatPatterns", regexPatterns: "regex", abbreviatedTimeZoneDST: "timeZoneDST", abbreviatedTimeZoneStandard: "timeZoneStandard" }); shallowMerge(info, constructedInfo); buildInfo.timeZones(info); return info; }; $D.i18n = { __: function (key, lang) { return __(key, lang); }, currentLanguage: function () { return lang || "en-US"; }, setLanguage: function (code, force, cb) { var async = false; if (force || code === "en-US" || (!!Date.CultureStrings && !!Date.CultureStrings[code])) { lang = code; Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings.lang = code; Date.CultureInfo = new CultureInfo(); } else { if (!(!!Date.CultureStrings && !!Date.CultureStrings[code])) { if (typeof exports !== "undefined" && this.exports !== exports) { // we're in a Node enviroment, load it using require try { require("../i18n/" + code + ".js"); lang = code; Date.CultureStrings.lang = code; Date.CultureInfo = new CultureInfo(); } catch (e) { // var str = "The language for '" + code + "' could not be loaded by Node. It likely does not exist."; throw new Error("The DateJS IETF language tag '" + code + "' could not be loaded by Node. It likely does not exist."); } } else if (Date.Config && Date.Config.i18n) { // we know the location of the files, so lets load them async = true; loadI18nScript(code).done(function(){ lang = code; Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings.lang = code; Date.CultureInfo = new CultureInfo(); $D.Parsing.Normalizer.buildReplaceData(); // because this is async if ($D.Grammar) { $D.Grammar.buildGrammarFormats(); // so we can parse those strings... } if (cb) { setTimeout(cb,0); } }); } else { Date.console.error("The DateJS IETF language tag '" + code + "' is not available and has not been loaded."); return false; } } } $D.Parsing.Normalizer.buildReplaceData(); // rebuild normalizer strings if ($D.Grammar) { $D.Grammar.buildGrammarFormats(); // so we can parse those strings... } if (!async && cb) { setTimeout(cb,0); } }, getLoggedKeys: function () { return loggedKeys; }, updateCultureInfo: function () { Date.CultureInfo = new CultureInfo(); } }; $D.i18n.updateCultureInfo(); // run automatically }()); (function () { var $D = Date, $P = $D.prototype, p = function (s, l) { if (!l) { l = 2; } return ("000" + s).slice(l * -1); }; if (typeof window !== "undefined" && typeof window.console !== "undefined" && typeof window.console.log !== "undefined") { $D.console = console; // used only to raise non-critical errors if available } else { // set mock so we don't give errors. $D.console = { log: function(){}, error: function(){} }; } $D.Config = $D.Config || {}; $D.initOverloads = function() { /** * Overload of Date.now. Allows an alternate call for Date.now where it returns the * current Date as an object rather than just milliseconds since the Unix Epoch. * * Also provides an implementation of now() for browsers (IE<9) that don't have it. * * Backwards compatible so with work with either: * Date.now() [returns ms] * or * Date.now(true) [returns Date] */ if (!$D.now) { $D._now = function now() { return new Date().getTime(); }; } else if (!$D._now) { $D._now = $D.now; } $D.now = function (returnObj) { if (returnObj) { return $D.present(); } else { return $D._now(); } }; if ( !$P.toISOString ) { $P.toISOString = function() { return this.getUTCFullYear() + "-" + p(this.getUTCMonth() + 1) + "-" + p(this.getUTCDate()) + "T" + p(this.getUTCHours()) + ":" + p(this.getUTCMinutes()) + ":" + p(this.getUTCSeconds()) + "." + String( (this.getUTCMilliseconds()/1000).toFixed(3)).slice(2, 5) + "Z"; }; } // private if ( $P._toString === undefined ){ $P._toString = $P.toString; } }; $D.initOverloads(); /** * Gets a date that is set to the current date. The time is set to the start of the day (00:00 or 12:00 AM). * @return {Date} The current date. */ $D.today = function () { return new Date().clearTime(); }; /** * Gets a date that is set to the current date and time (same as new Date, but chainable) * @return {Date} The current date. */ $D.present = function () { return new Date(); }; /** * Compares the first date to the second date and returns an number indication of their relative values. * @param {Date} First Date object to compare [Required]. * @param {Date} Second Date object to compare to [Required]. * @return {Number} -1 = date1 is lessthan date2. 0 = values are equal. 1 = date1 is greaterthan date2. */ $D.compare = function (date1, date2) { if (isNaN(date1) || isNaN(date2)) { throw new Error(date1 + " - " + date2); } else if (date1 instanceof Date && date2 instanceof Date) { return (date1 < date2) ? -1 : (date1 > date2) ? 1 : 0; } else { throw new TypeError(date1 + " - " + date2); } }; /** * Compares the first Date object to the second Date object and returns true if they are equal. * @param {Date} First Date object to compare [Required] * @param {Date} Second Date object to compare to [Required] * @return {Boolean} true if dates are equal. false if they are not equal. */ $D.equals = function (date1, date2) { return (date1.compareTo(date2) === 0); }; /** * Gets the language appropriate day name when given the day number(0-6) * eg - 0 == Sunday * @return {String} The day name */ $D.getDayName = function (n) { return Date.CultureInfo.dayNames[n]; }; /** * Gets the day number (0-6) if given a CultureInfo specific string which is a valid dayName, abbreviatedDayName or shortestDayName (two char). * @param {String} The name of the day (eg. "Monday, "Mon", "tuesday", "tue", "We", "we"). * @return {Number} The day number */ $D.getDayNumberFromName = function (name) { var n = Date.CultureInfo.dayNames, m = Date.CultureInfo.abbreviatedDayNames, o = Date.CultureInfo.shortestDayNames, s = name.toLowerCase(); for (var i = 0; i < n.length; i++) { if (n[i].toLowerCase() === s || m[i].toLowerCase() === s || o[i].toLowerCase() === s) { return i; } } return -1; }; /** * Gets the month number (0-11) if given a Culture Info specific string which is a valid monthName or abbreviatedMonthName. * @param {String} The name of the month (eg. "February, "Feb", "october", "oct"). * @return {Number} The day number */ $D.getMonthNumberFromName = function (name) { var n = Date.CultureInfo.monthNames, m = Date.CultureInfo.abbreviatedMonthNames, s = name.toLowerCase(); for (var i = 0; i < n.length; i++) { if (n[i].toLowerCase() === s || m[i].toLowerCase() === s) { return i; } } return -1; }; /** * Gets the language appropriate month name when given the month number(0-11) * eg - 0 == January * @return {String} The month name */ $D.getMonthName = function (n) { return Date.CultureInfo.monthNames[n]; }; /** * Determines if the current date instance is within a LeapYear. * @param {Number} The year. * @return {Boolean} true if date is within a LeapYear, otherwise false. */ $D.isLeapYear = function (year) { return ((year % 4 === 0 && year % 100 !== 0) || year % 400 === 0); }; /** * Gets the number of days in the month, given a year and month value. Automatically corrects for LeapYear. * @param {Number} The year. * @param {Number} The month (0-11). * @return {Number} The number of days in the month. */ $D.getDaysInMonth = function (year, month) { if (!month && $D.validateMonth(year)) { month = year; year = Date.today().getFullYear(); } return [31, ($D.isLeapYear(year) ? 29 : 28), 31, 30, 31, 30, 31, 31, 30, 31, 30, 31][month]; }; $P.getDaysInMonth = function () { return $D.getDaysInMonth(this.getFullYear(), this.getMonth()); }; $D.getTimezoneAbbreviation = function (offset, dst) { var p, n = (dst || false) ? Date.CultureInfo.abbreviatedTimeZoneDST : Date.CultureInfo.abbreviatedTimeZoneStandard; for (p in n) { if (n.hasOwnProperty(p)) { if (n[p] === offset) { return p; } } } return null; }; $D.getTimezoneOffset = function (name, dst) { var i, a =[], z = Date.CultureInfo.timezones; if (!name) { name = (new Date()).getTimezone();} for (i = 0; i < z.length; i++) { if (z[i].name === name.toUpperCase()) { a.push(i); } } if (!z[a[0]]) { return null; } if (a.length === 1 || !dst) { return z[a[0]].offset; } else { for (i=0; i < a.length; i++) { if (z[a[i]].dst) { return z[a[i]].offset; } } } }; $D.getQuarter = function (d) { d = d || new Date(); // If no date supplied, use today var q = [1,2,3,4]; return q[Math.floor(d.getMonth() / 3)]; // ~~~ is a bitwise op. Faster than Math.floor }; $D.getDaysLeftInQuarter = function (d) { d = d || new Date(); var qEnd = new Date(d); qEnd.setMonth(qEnd.getMonth() + 3 - qEnd.getMonth() % 3, 0); return Math.floor((qEnd - d) / 8.64e7); }; // private var validate = function (n, min, max, name) { name = name ? name : "Object"; if (typeof n === "undefined") { return false; } else if (typeof n !== "number") { throw new TypeError(n + " is not a Number."); } else if (n < min || n > max) { // As failing validation is *not* an exceptional circumstance // lets not throw a RangeError Exception here. // It's semantically correct but it's not sensible. return false; } return true; }; /** * Validates the number is within an acceptable range for milliseconds [0-999]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateMillisecond = function (value) { return validate(value, 0, 999, "millisecond"); }; /** * Validates the number is within an acceptable range for seconds [0-59]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateSecond = function (value) { return validate(value, 0, 59, "second"); }; /** * Validates the number is within an acceptable range for minutes [0-59]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateMinute = function (value) { return validate(value, 0, 59, "minute"); }; /** * Validates the number is within an acceptable range for hours [0-23]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateHour = function (value) { return validate(value, 0, 23, "hour"); }; /** * Validates the number is within an acceptable range for the days in a month [0-MaxDaysInMonth]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateDay = function (value, year, month) { if (year === undefined || year === null || month === undefined || month === null) { return false;} return validate(value, 1, $D.getDaysInMonth(year, month), "day"); }; /** * Validates the number is within an acceptable range for months [0-11]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateWeek = function (value) { return validate(value, 0, 53, "week"); }; /** * Validates the number is within an acceptable range for months [0-11]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateMonth = function (value) { return validate(value, 0, 11, "month"); }; /** * Validates the number is within an acceptable range for years. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateYear = function (value) { /** * Per ECMAScript spec the range of times supported by Date objects is * exactly -100,000,000 days to +100,000,000 days measured relative to * midnight at the beginning of 01 January, 1970 UTC. * This gives a range of 8,640,000,000,000,000 milliseconds to either * side of 01 January, 1970 UTC. * * Earliest possible date: Tue, 20 Apr 271,822 B.C. 00:00:00 UTC * Latest possible date: Sat, 13 Sep 275,760 00:00:00 UTC */ return validate(value, -271822, 275760, "year"); }; $D.validateTimezone = function(value) { var timezones = {"ACDT":1,"ACST":1,"ACT":1,"ADT":1,"AEDT":1,"AEST":1,"AFT":1,"AKDT":1,"AKST":1,"AMST":1,"AMT":1,"ART":1,"AST":1,"AWDT":1,"AWST":1,"AZOST":1,"AZT":1,"BDT":1,"BIOT":1,"BIT":1,"BOT":1,"BRT":1,"BST":1,"BTT":1,"CAT":1,"CCT":1,"CDT":1,"CEDT":1,"CEST":1,"CET":1,"CHADT":1,"CHAST":1,"CHOT":1,"ChST":1,"CHUT":1,"CIST":1,"CIT":1,"CKT":1,"CLST":1,"CLT":1,"COST":1,"COT":1,"CST":1,"CT":1,"CVT":1,"CWST":1,"CXT":1,"DAVT":1,"DDUT":1,"DFT":1,"EASST":1,"EAST":1,"EAT":1,"ECT":1,"EDT":1,"EEDT":1,"EEST":1,"EET":1,"EGST":1,"EGT":1,"EIT":1,"EST":1,"FET":1,"FJT":1,"FKST":1,"FKT":1,"FNT":1,"GALT":1,"GAMT":1,"GET":1,"GFT":1,"GILT":1,"GIT":1,"GMT":1,"GST":1,"GYT":1,"HADT":1,"HAEC":1,"HAST":1,"HKT":1,"HMT":1,"HOVT":1,"HST":1,"ICT":1,"IDT":1,"IOT":1,"IRDT":1,"IRKT":1,"IRST":1,"IST":1,"JST":1,"KGT":1,"KOST":1,"KRAT":1,"KST":1,"LHST":1,"LINT":1,"MAGT":1,"MART":1,"MAWT":1,"MDT":1,"MET":1,"MEST":1,"MHT":1,"MIST":1,"MIT":1,"MMT":1,"MSK":1,"MST":1,"MUT":1,"MVT":1,"MYT":1,"NCT":1,"NDT":1,"NFT":1,"NPT":1,"NST":1,"NT":1,"NUT":1,"NZDT":1,"NZST":1,"OMST":1,"ORAT":1,"PDT":1,"PET":1,"PETT":1,"PGT":1,"PHOT":1,"PHT":1,"PKT":1,"PMDT":1,"PMST":1,"PONT":1,"PST":1,"PYST":1,"PYT":1,"RET":1,"ROTT":1,"SAKT":1,"SAMT":1,"SAST":1,"SBT":1,"SCT":1,"SGT":1,"SLST":1,"SRT":1,"SST":1,"SYOT":1,"TAHT":1,"THA":1,"TFT":1,"TJT":1,"TKT":1,"TLT":1,"TMT":1,"TOT":1,"TVT":1,"UCT":1,"ULAT":1,"UTC":1,"UYST":1,"UYT":1,"UZT":1,"VET":1,"VLAT":1,"VOLT":1,"VOST":1,"VUT":1,"WAKT":1,"WAST":1,"WAT":1,"WEDT":1,"WEST":1,"WET":1,"WST":1,"YAKT":1,"YEKT":1,"Z":1}; return (timezones[value] === 1); }; $D.validateTimezoneOffset= function(value) { // timezones go from +14hrs to -12hrs, the +X hours are negative offsets. return (value > -841 && value < 721); }; }()); (function () { var $D = Date, $P = $D.prototype, p = function (s, l) { if (!l) { l = 2; } return ("000" + s).slice(l * -1); }; var validateConfigObject = function (obj) { var result = {}, self = this, prop, testFunc; testFunc = function (prop, func, value) { if (prop === "day") { var month = (obj.month !== undefined) ? obj.month : self.getMonth(); var year = (obj.year !== undefined) ? obj.year : self.getFullYear(); return $D[func](value, year, month); } else { return $D[func](value); } }; for (prop in obj) { if (Object.prototype.hasOwnProperty.call(obj, prop)) { var func = "validate" + prop.charAt(0).toUpperCase() + prop.slice(1); if ($D[func] && obj[prop] !== null && testFunc(prop, func, obj[prop])) { result[prop] = obj[prop]; } } } return result; }; /** * Resets the time of this Date object to 12:00 AM (00:00), which is the start of the day. * @param {Boolean} .clone() this date instance before clearing Time * @return {Date} this */ $P.clearTime = function () { this.setHours(0); this.setMinutes(0); this.setSeconds(0); this.setMilliseconds(0); return this; }; /** * Resets the time of this Date object to the current time ('now'). * @return {Date} this */ $P.setTimeToNow = function () { var n = new Date(); this.setHours(n.getHours()); this.setMinutes(n.getMinutes()); this.setSeconds(n.getSeconds()); this.setMilliseconds(n.getMilliseconds()); return this; }; /** * Returns a new Date object that is an exact date and time copy of the original instance. * @return {Date} A new Date instance */ $P.clone = function () { return new Date(this.getTime()); }; /** * Compares this instance to a Date object and returns an number indication of their relative values. * @param {Date} Date object to compare [Required] * @return {Number} -1 = this is lessthan date. 0 = values are equal. 1 = this is greaterthan date. */ $P.compareTo = function (date) { return Date.compare(this, date); }; /** * Compares this instance to another Date object and returns true if they are equal. * @param {Date} Date object to compare. If no date to compare, new Date() [now] is used. * @return {Boolean} true if dates are equal. false if they are not equal. */ $P.equals = function (date) { return Date.equals(this, (date !== undefined ? date : new Date())); }; /** * Determines if this instance is between a range of two dates or equal to either the start or end dates. * @param {Date} Start of range [Required] * @param {Date} End of range [Required] * @return {Boolean} true is this is between or equal to the start and end dates, else false */ $P.between = function (start, end) { return this.getTime() >= start.getTime() && this.getTime() <= end.getTime(); }; /** * Determines if this date occurs after the date to compare to. * @param {Date} Date object to compare. If no date to compare, new Date() ("now") is used. * @return {Boolean} true if this date instance is greater than the date to compare to (or "now"), otherwise false. */ $P.isAfter = function (date) { return this.compareTo(date || new Date()) === 1; }; /** * Determines if this date occurs before the date to compare to. * @param {Date} Date object to compare. If no date to compare, new Date() ("now") is used. * @return {Boolean} true if this date instance is less than the date to compare to (or "now"). */ $P.isBefore = function (date) { return (this.compareTo(date || new Date()) === -1); }; /** * Determines if the current Date instance occurs today. * @return {Boolean} true if this date instance is 'today', otherwise false. */ /** * Determines if the current Date instance occurs on the same Date as the supplied 'date'. * If no 'date' to compare to is provided, the current Date instance is compared to 'today'. * @param {date} Date object to compare. If no date to compare, the current Date ("now") is used. * @return {Boolean} true if this Date instance occurs on the same Day as the supplied 'date'. */ $P.isToday = $P.isSameDay = function (date) { return this.clone().clearTime().equals((date || new Date()).clone().clearTime()); }; /** * Adds the specified number of milliseconds to this instance. * @param {Number} The number of milliseconds to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addMilliseconds = function (value) { if (!value) { return this; } this.setTime(this.getTime() + value * 1); return this; }; /** * Adds the specified number of seconds to this instance. * @param {Number} The number of seconds to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addSeconds = function (value) { if (!value) { return this; } return this.addMilliseconds(value * 1000); }; /** * Adds the specified number of seconds to this instance. * @param {Number} The number of seconds to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addMinutes = function (value) { if (!value) { return this; } return this.addMilliseconds(value * 60000); // 60*1000 }; /** * Adds the specified number of hours to this instance. * @param {Number} The number of hours to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addHours = function (value) { if (!value) { return this; } return this.addMilliseconds(value * 3600000); // 60*60*1000 }; /** * Adds the specified number of days to this instance. * @param {Number} The number of days to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addDays = function (value) { if (!value) { return this; } this.setDate(this.getDate() + value * 1); return this; }; /** * Adds the specified number of weekdays (ie - not sat or sun) to this instance. * @param {Number} The number of days to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addWeekdays = function (value) { if (!value) { return this; } var day = this.getDay(); var weeks = (Math.ceil(Math.abs(value)/7)); if (day === 0 || day === 6) { if (value > 0) { this.next().monday(); this.addDays(-1); day = this.getDay(); } } if (value < 0) { while (value < 0) { this.addDays(-1); day = this.getDay(); if (day !== 0 && day !== 6) { value++; } } return this; } else if (value > 5 || (6-day) <= value) { value = value + (weeks * 2); } return this.addDays(value); }; /** * Adds the specified number of weeks to this instance. * @param {Number} The number of weeks to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addWeeks = function (value) { if (!value) { return this; } return this.addDays(value * 7); }; /** * Adds the specified number of months to this instance. * @param {Number} The number of months to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addMonths = function (value) { if (!value) { return this; } var n = this.getDate(); this.setDate(1); this.setMonth(this.getMonth() + value * 1); this.setDate(Math.min(n, $D.getDaysInMonth(this.getFullYear(), this.getMonth()))); return this; }; $P.addQuarters = function (value) { if (!value) { return this; } // note this will take you to the same point in the quarter as you are now. // i.e. - if you are 15 days into the quarter you'll be 15 days into the resulting one. // bonus: this allows adding fractional quarters return this.addMonths(value * 3); }; /** * Adds the specified number of years to this instance. * @param {Number} The number of years to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addYears = function (value) { if (!value) { return this; } return this.addMonths(value * 12); }; /** * Adds (or subtracts) to the value of the years, months, weeks, days, hours, minutes, seconds, milliseconds of the date instance using given configuration object. Positive and Negative values allowed. * Example

	Date.today().add( { days: 1, months: 1 } )

	new Date().add( { years: -1 } )
	
* @param {Object} Configuration object containing attributes (months, days, etc.) * @return {Date} this */ $P.add = function (config) { if (typeof config === "number") { this._orient = config; return this; } var x = config; if (x.day) { // If we should be a different date than today (eg: for 'tomorrow -1d', etc). // Should only effect parsing, not direct usage (eg, Finish and FinishExact) if ((x.day - this.getDate()) !== 0) { this.setDate(x.day); } } if (x.milliseconds) { this.addMilliseconds(x.milliseconds); } if (x.seconds) { this.addSeconds(x.seconds); } if (x.minutes) { this.addMinutes(x.minutes); } if (x.hours) { this.addHours(x.hours); } if (x.weeks) { this.addWeeks(x.weeks); } if (x.months) { this.addMonths(x.months); } if (x.years) { this.addYears(x.years); } if (x.days) { this.addDays(x.days); } return this; }; /** * Get the week number. Week one (1) is the week which contains the first Thursday of the year. Monday is considered the first day of the week. * The .getWeek() function does NOT convert the date to UTC. The local datetime is used. * Please use .getISOWeek() to get the week of the UTC converted date. * @return {Number} 1 to 53 */ $P.getWeek = function (utc) { // Create a copy of this date object var self, target = new Date(this.valueOf()); if (utc) { target.addMinutes(target.getTimezoneOffset()); self = target.clone(); } else { self = this; } // ISO week date weeks start on monday // so correct the day number var dayNr = (self.getDay() + 6) % 7; // ISO 8601 states that week 1 is the week // with the first thursday of that year. // Set the target date to the thursday in the target week target.setDate(target.getDate() - dayNr + 3); // Store the millisecond value of the target date var firstThursday = target.valueOf(); // Set the target to the first thursday of the year // First set the target to january first target.setMonth(0, 1); // Not a thursday? Correct the date to the next thursday if (target.getDay() !== 4) { target.setMonth(0, 1 + ((4 - target.getDay()) + 7) % 7); } // The weeknumber is the number of weeks between the // first thursday of the year and the thursday in the target week return 1 + Math.ceil((firstThursday - target) / 604800000); // 604800000 = 7 * 24 * 3600 * 1000 }; /** * Get the ISO 8601 week number. Week one ("01") is the week which contains the first Thursday of the year. Monday is considered the first day of the week. * The .getISOWeek() function does convert the date to it's UTC value. Please use .getWeek() to get the week of the local date. * @return {String} "01" to "53" */ $P.getISOWeek = function () { return p(this.getWeek(true)); }; /** * Moves the date to Monday of the week set. Week one (1) is the week which contains the first Thursday of the year. * @param {Number} A Number (1 to 53) that represents the week of the year. * @return {Date} this */ $P.setWeek = function (n) { if ((n - this.getWeek()) === 0) { if (this.getDay() !== 1) { return this.moveToDayOfWeek(1, (this.getDay() > 1 ? -1 : 1)); } else { return this; } } else { return this.moveToDayOfWeek(1, (this.getDay() > 1 ? -1 : 1)).addWeeks(n - this.getWeek()); } }; $P.setQuarter = function (qtr) { var month = Math.abs(((qtr-1) * 3) + 1); return this.setMonth(month, 1); }; $P.getQuarter = function () { return Date.getQuarter(this); }; $P.getDaysLeftInQuarter = function () { return Date.getDaysLeftInQuarter(this); }; /** * Moves the date to the next n'th occurrence of the dayOfWeek starting from the beginning of the month. The number (-1) is a magic number and will return the last occurrence of the dayOfWeek in the month. * @param {Number} The dayOfWeek to move to * @param {Number} The n'th occurrence to move to. Use (-1) to return the last occurrence in the month * @return {Date} this */ $P.moveToNthOccurrence = function (dayOfWeek, occurrence) { if (dayOfWeek === "Weekday") { if (occurrence > 0) { this.moveToFirstDayOfMonth(); if (this.is().weekday()) { occurrence -= 1; } } else if (occurrence < 0) { this.moveToLastDayOfMonth(); if (this.is().weekday()) { occurrence += 1; } } else { return this; } return this.addWeekdays(occurrence); } var shift = 0; if (occurrence > 0) { shift = occurrence - 1; } else if (occurrence === -1) { this.moveToLastDayOfMonth(); if (this.getDay() !== dayOfWeek) { this.moveToDayOfWeek(dayOfWeek, -1); } return this; } return this.moveToFirstDayOfMonth().addDays(-1).moveToDayOfWeek(dayOfWeek, +1).addWeeks(shift); }; var moveToN = function (getFunc, addFunc, nVal) { return function (value, orient) { var diff = (value - this[getFunc]() + nVal * (orient || +1)) % nVal; return this[addFunc]((diff === 0) ? diff += nVal * (orient || +1) : diff); }; }; /** * Move to the next or last dayOfWeek based on the orient value. * @param {Number} The dayOfWeek to move to * @param {Number} Forward (+1) or Back (-1). Defaults to +1. [Optional] * @return {Date} this */ $P.moveToDayOfWeek = moveToN("getDay", "addDays", 7); /** * Move to the next or last month based on the orient value. * @param {Number} The month to move to. 0 = January, 11 = December * @param {Number} Forward (+1) or Back (-1). Defaults to +1. [Optional] * @return {Date} this */ $P.moveToMonth = moveToN("getMonth", "addMonths", 12); /** * Get the Ordinate of the current day ("th", "st", "rd"). * @return {String} */ $P.getOrdinate = function () { var num = this.getDate(); return ord(num); }; /** * Get the Ordinal day (numeric day number) of the year, adjusted for leap year. * @return {Number} 1 through 365 (366 in leap years) */ $P.getOrdinalNumber = function () { return Math.ceil((this.clone().clearTime() - new Date(this.getFullYear(), 0, 1)) / 86400000) + 1; }; /** * Get the time zone abbreviation of the current date. * @return {String} The abbreviated time zone name (e.g. "EST") */ $P.getTimezone = function () { return $D.getTimezoneAbbreviation(this.getUTCOffset(), this.isDaylightSavingTime()); }; $P.setTimezoneOffset = function (offset) { var here = this.getTimezoneOffset(), there = Number(offset) * -6 / 10; return (there || there === 0) ? this.addMinutes(there - here) : this; }; $P.setTimezone = function (offset) { return this.setTimezoneOffset($D.getTimezoneOffset(offset)); }; /** * Indicates whether Daylight Saving Time is observed in the current time zone. * @return {Boolean} true|false */ $P.hasDaylightSavingTime = function () { return (Date.today().set({month: 0, day: 1}).getTimezoneOffset() !== Date.today().set({month: 6, day: 1}).getTimezoneOffset()); }; /** * Indicates whether this Date instance is within the Daylight Saving Time range for the current time zone. * @return {Boolean} true|false */ $P.isDaylightSavingTime = function () { return Date.today().set({month: 0, day: 1}).getTimezoneOffset() !== this.getTimezoneOffset(); }; /** * Get the offset from UTC of the current date. * @return {String} The 4-character offset string prefixed with + or - (e.g. "-0500") */ $P.getUTCOffset = function (offset) { var n = (offset || this.getTimezoneOffset()) * -10 / 6, r; if (n < 0) { r = (n - 10000).toString(); return r.charAt(0) + r.substr(2); } else { r = (n + 10000).toString(); return "+" + r.substr(1); } }; /** * Returns the number of milliseconds between this date and date. * @param {Date} Defaults to now * @return {Number} The diff in milliseconds */ $P.getElapsed = function (date) { return (date || new Date()) - this; }; /** * Set the value of year, month, day, hour, minute, second, millisecond of date instance using given configuration object. * Example

	Date.today().set( { day: 20, month: 1 } )

	new Date().set( { millisecond: 0 } )
	
* * @param {Object} Configuration object containing attributes (month, day, etc.) * @return {Date} this */ $P.set = function (config) { config = validateConfigObject.call(this, config); var key; for (key in config) { if (Object.prototype.hasOwnProperty.call(config, key)) { var name = key.charAt(0).toUpperCase() + key.slice(1); var addFunc, getFunc; if (key !== "week" && key !== "month" && key !== "timezone" && key !== "timezoneOffset") { name += "s"; } addFunc = "add" + name; getFunc = "get" + name; if (key === "month") { addFunc = addFunc + "s"; } else if (key === "year"){ getFunc = "getFullYear"; } if (key !== "day" && key !== "timezone" && key !== "timezoneOffset" && key !== "week" && key !== "hour") { this[addFunc](config[key] - this[getFunc]()); } else if ( key === "timezone"|| key === "timezoneOffset" || key === "week" || key === "hour") { this["set"+name](config[key]); } } } // day has to go last because you can't validate the day without first knowing the month if (config.day) { this.addDays(config.day - this.getDate()); } return this; }; /** * Moves the date to the first day of the month. * @return {Date} this */ $P.moveToFirstDayOfMonth = function () { return this.set({ day: 1 }); }; /** * Moves the date to the last day of the month. * @return {Date} this */ $P.moveToLastDayOfMonth = function () { return this.set({ day: $D.getDaysInMonth(this.getFullYear(), this.getMonth())}); }; /** * Converts the value of the current Date object to its equivalent string representation. * Format Specifiers * CUSTOM DATE AND TIME FORMAT STRINGS * Format Description Example * ------ --------------------------------------------------------------------------- ----------------------- * s The seconds of the minute between 0-59. "0" to "59" * ss The seconds of the minute with leading zero if required. "00" to "59" * * m The minute of the hour between 0-59. "0" or "59" * mm The minute of the hour with leading zero if required. "00" or "59" * * h The hour of the day between 1-12. "1" to "12" * hh The hour of the day with leading zero if required. "01" to "12" * * H The hour of the day between 0-23. "0" to "23" * HH The hour of the day with leading zero if required. "00" to "23" * * d The day of the month between 1 and 31. "1" to "31" * dd The day of the month with leading zero if required. "01" to "31" * ddd Abbreviated day name. Date.CultureInfo.abbreviatedDayNames. "Mon" to "Sun" * dddd The full day name. Date.CultureInfo.dayNames. "Monday" to "Sunday" * * M The month of the year between 1-12. "1" to "12" * MM The month of the year with leading zero if required. "01" to "12" * MMM Abbreviated month name. Date.CultureInfo.abbreviatedMonthNames. "Jan" to "Dec" * MMMM The full month name. Date.CultureInfo.monthNames. "January" to "December" * * yy The year as a two-digit number. "99" or "08" * yyyy The full four digit year. "1999" or "2008" * * t Displays the first character of the A.M./P.M. designator. "A" or "P" * Date.CultureInfo.amDesignator or Date.CultureInfo.pmDesignator * tt Displays the A.M./P.M. designator. "AM" or "PM" * Date.CultureInfo.amDesignator or Date.CultureInfo.pmDesignator * * S The ordinal suffix ("st, "nd", "rd" or "th") of the current day. "st, "nd", "rd" or "th" * * STANDARD DATE AND TIME FORMAT STRINGS * Format Description Example *------ --------------------------------------------------------------------------- ----------------------- * d The CultureInfo shortDate Format Pattern "M/d/yyyy" * D The CultureInfo longDate Format Pattern "dddd, MMMM dd, yyyy" * F The CultureInfo fullDateTime Format Pattern "dddd, MMMM dd, yyyy h:mm:ss tt" * m The CultureInfo monthDay Format Pattern "MMMM dd" * r The CultureInfo rfc1123 Format Pattern "ddd, dd MMM yyyy HH:mm:ss GMT" * s The CultureInfo sortableDateTime Format Pattern "yyyy-MM-ddTHH:mm:ss" * t The CultureInfo shortTime Format Pattern "h:mm tt" * T The CultureInfo longTime Format Pattern "h:mm:ss tt" * u The CultureInfo universalSortableDateTime Format Pattern "yyyy-MM-dd HH:mm:ssZ" * y The CultureInfo yearMonth Format Pattern "MMMM, yyyy" * * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @return {String} A string representation of the current Date object. */ var ord = function (n) { switch (n * 1) { case 1: case 21: case 31: return "st"; case 2: case 22: return "nd"; case 3: case 23: return "rd"; default: return "th"; } }; var parseStandardFormats = function (format) { var y, c = Date.CultureInfo.formatPatterns; switch (format) { case "d": return this.toString(c.shortDate); case "D": return this.toString(c.longDate); case "F": return this.toString(c.fullDateTime); case "m": return this.toString(c.monthDay); case "r": case "R": y = this.clone().addMinutes(this.getTimezoneOffset()); return y.toString(c.rfc1123) + " GMT"; case "s": return this.toString(c.sortableDateTime); case "t": return this.toString(c.shortTime); case "T": return this.toString(c.longTime); case "u": y = this.clone().addMinutes(this.getTimezoneOffset()); return y.toString(c.universalSortableDateTime); case "y": return this.toString(c.yearMonth); default: return false; } }; var parseFormatStringsClosure = function (context) { return function (m) { if (m.charAt(0) === "\\") { return m.replace("\\", ""); } switch (m) { case "hh": return p(context.getHours() < 13 ? (context.getHours() === 0 ? 12 : context.getHours()) : (context.getHours() - 12)); case "h": return context.getHours() < 13 ? (context.getHours() === 0 ? 12 : context.getHours()) : (context.getHours() - 12); case "HH": return p(context.getHours()); case "H": return context.getHours(); case "mm": return p(context.getMinutes()); case "m": return context.getMinutes(); case "ss": return p(context.getSeconds()); case "s": return context.getSeconds(); case "yyyy": return p(context.getFullYear(), 4); case "yy": return p(context.getFullYear()); case "y": return context.getFullYear(); case "E": case "dddd": return Date.CultureInfo.dayNames[context.getDay()]; case "ddd": return Date.CultureInfo.abbreviatedDayNames[context.getDay()]; case "dd": return p(context.getDate()); case "d": return context.getDate(); case "MMMM": return Date.CultureInfo.monthNames[context.getMonth()]; case "MMM": return Date.CultureInfo.abbreviatedMonthNames[context.getMonth()]; case "MM": return p((context.getMonth() + 1)); case "M": return context.getMonth() + 1; case "t": return context.getHours() < 12 ? Date.CultureInfo.amDesignator.substring(0, 1) : Date.CultureInfo.pmDesignator.substring(0, 1); case "tt": return context.getHours() < 12 ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator; case "S": return ord(context.getDate()); case "W": return context.getWeek(); case "WW": return context.getISOWeek(); case "Q": return "Q" + context.getQuarter(); case "q": return String(context.getQuarter()); case "z": return context.getTimezone(); case "Z": case "X": return Date.getTimezoneOffset(context.getTimezone()); case "ZZ": // Timezone offset in seconds return context.getTimezoneOffset() * -60; case "u": return context.getDay(); case "L": return ($D.isLeapYear(context.getFullYear())) ? 1 : 0; case "B": // Swatch Internet Time (.beats) return "@"+((context.getUTCSeconds() + (context.getUTCMinutes()*60) + ((context.getUTCHours()+1)*3600))/86.4); default: return m; } }; }; $P.toString = function (format, ignoreStandards) { // Standard Date and Time Format Strings. Formats pulled from CultureInfo file and // may vary by culture. if (!ignoreStandards && format && format.length === 1) { output = parseStandardFormats.call(this, format); if (output) { return output; } } var parseFormatStrings = parseFormatStringsClosure(this); return format ? format.replace(/((\\)?(dd?d?d?|MM?M?M?|yy?y?y?|hh?|HH?|mm?|ss?|tt?|S|q|Q|WW?W?W?)(?![^\[]*\]))/g, parseFormatStrings).replace(/\[|\]/g, "") : this._toString(); }; }()); /************************************************************* * SugarPak - Domain Specific Language - Syntactical Sugar * *************************************************************/ (function () { var $D = Date, $P = $D.prototype, $N = Number.prototype; // private $P._orient = +1; // private $P._nth = null; // private $P._is = false; // private $P._same = false; // private $P._isSecond = false; // private $N._dateElement = "days"; /** * Moves the date to the next instance of a date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.today().next().friday();
	Date.today().next().fri();
	Date.today().next().march();
	Date.today().next().mar();
	Date.today().next().week();
	
* * @return {Date} date */ $P.next = function () { this._move = true; this._orient = +1; return this; }; /** * Creates a new Date (Date.today()) and moves the date to the next instance of the date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.next().friday();
	Date.next().fri();
	Date.next().march();
	Date.next().mar();
	Date.next().week();
	
* * @return {Date} date */ $D.next = function () { return $D.today().next(); }; /** * Moves the date to the previous instance of a date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.today().last().friday();
	Date.today().last().fri();
	Date.today().last().march();
	Date.today().last().mar();
	Date.today().last().week();
	
* * @return {Date} date */ $P.last = $P.prev = $P.previous = function () { this._move = true; this._orient = -1; return this; }; /** * Creates a new Date (Date.today()) and moves the date to the previous instance of the date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.last().friday();
	Date.last().fri();
	Date.previous().march();
	Date.prev().mar();
	Date.last().week();
	
* * @return {Date} date */ $D.last = $D.prev = $D.previous = function () { return $D.today().last(); }; /** * Performs a equality check when followed by either a month name, day name or .weekday() function. * Example

	Date.today().is().friday(); // true|false
	Date.today().is().fri();
	Date.today().is().march();
	Date.today().is().mar();
	
* * @return {Boolean} true|false */ $P.is = function () { this._is = true; return this; }; /** * Determines if two date objects occur on/in exactly the same instance of the subsequent date part function. * The function .same() must be followed by a date part function (example: .day(), .month(), .year(), etc). * * An optional Date can be passed in the date part function. If now date is passed as a parameter, 'Now' is used. * * The following example demonstrates how to determine if two dates fall on the exact same day. * * Example

	var d1 = Date.today(); // today at 00:00
	var d2 = new Date();   // exactly now.

	// Do they occur on the same day?
	d1.same().day(d2); // true
	
	// Do they occur on the same hour?
	d1.same().hour(d2); // false, unless d2 hour is '00' (midnight).
	
	// What if it's the same day, but one year apart?
	var nextYear = Date.today().add(1).year();

	d1.same().day(nextYear); // false, because the dates must occur on the exact same day. 
	
* * Scenario: Determine if a given date occurs during some week period 2 months from now. * * Example

	var future = Date.today().add(2).months();
	return someDate.same().week(future); // true|false;
	
* * @return {Boolean} true|false */ $P.same = function () { this._same = true; this._isSecond = false; return this; }; /** * Determines if the current date/time occurs during Today. Must be preceded by the .is() function. * Example

	someDate.is().today();    // true|false
	new Date().is().today();  // true
	Date.today().is().today();// true
	Date.today().add(-1).day().is().today(); // false
	
* * @return {Boolean} true|false */ $P.today = function () { return this.same().day(); }; /** * Determines if the current date is a weekday. This function must be preceded by the .is() function. * Example

	Date.today().is().weekday(); // true|false
	
* * @return {Boolean} true|false */ $P.weekday = function () { if (this._nth) { return df("Weekday").call(this); } if (this._move) { return this.addWeekdays(this._orient); } if (this._is) { this._is = false; return (!this.is().sat() && !this.is().sun()); } return false; }; /** * Determines if the current date is on the weekend. This function must be preceded by the .is() function. * Example

	Date.today().is().weekend(); // true|false
	
* * @return {Boolean} true|false */ $P.weekend = function () { if (this._is) { this._is = false; return (this.is().sat() || this.is().sun()); } return false; }; /** * Sets the Time of the current Date instance. A string "6:15 pm" or config object {hour:18, minute:15} are accepted. * Example

	// Set time to 6:15pm with a String
	Date.today().at("6:15pm");

	// Set time to 6:15pm with a config object
	Date.today().at({hour:18, minute:15});
	
* * @return {Date} date */ $P.at = function (time) { return (typeof time === "string") ? $D.parse(this.toString("d") + " " + time) : this.set(time); }; /** * Creates a new Date() and adds this (Number) to the date based on the preceding date element function (eg. second|minute|hour|day|month|year). * Example

	// Undeclared Numbers must be wrapped with parentheses. Requirment of JavaScript.
	(3).days().fromNow();
	(6).months().fromNow();

	// Declared Number variables do not require parentheses. 
	var n = 6;
	n.months().fromNow();
	
* * @return {Date} A new Date instance */ $N.fromNow = $N.after = function (date) { var c = {}; c[this._dateElement] = this; return ((!date) ? new Date() : date.clone()).add(c); }; /** * Creates a new Date() and subtract this (Number) from the date based on the preceding date element function (eg. second|minute|hour|day|month|year). * Example

	// Undeclared Numbers must be wrapped with parentheses. Requirment of JavaScript.
	(3).days().ago();
	(6).months().ago();

	// Declared Number variables do not require parentheses. 
	var n = 6;
	n.months().ago();
	
* * @return {Date} A new Date instance */ $N.ago = $N.before = function (date) { var c = {}, s = (this._dateElement[this._dateElement.length-1] !== "s") ? this._dateElement + "s" : this._dateElement; c[s] = this * -1; return ((!date) ? new Date() : date.clone()).add(c); }; // Do NOT modify the following string tokens. These tokens are used to build dynamic functions. // All culture-specific strings can be found in the CultureInfo files. var dx = ("sunday monday tuesday wednesday thursday friday saturday").split(/\s/), mx = ("january february march april may june july august september october november december").split(/\s/), px = ("Millisecond Second Minute Hour Day Week Month Year Quarter Weekday").split(/\s/), pxf = ("Milliseconds Seconds Minutes Hours Date Week Month FullYear Quarter").split(/\s/), nth = ("final first second third fourth fifth").split(/\s/), de; /** * Returns an object literal of all the date parts. * Example

	var o = new Date().toObject();
	
	// { year: 2008, month: 4, week: 20, day: 13, hour: 18, minute: 9, second: 32, millisecond: 812 }
	
	// The object properties can be referenced directly from the object.
	
	alert(o.day);  // alerts "13"
	alert(o.year); // alerts "2008"
	
* * @return {Date} An object literal representing the original date object. */ $P.toObject = function () { var o = {}; for (var i = 0; i < px.length; i++) { if (this["get" + pxf[i]]) { o[px[i].toLowerCase()] = this["get" + pxf[i]](); } } return o; }; /** * Returns a date created from an object literal. Ignores the .week property if set in the config. * Example

	var o = new Date().toObject();
	
	return Date.fromObject(o); // will return the same date. 

	var o2 = {month: 1, day: 20, hour: 18}; // birthday party!
	Date.fromObject(o2);
	
* * @return {Date} An object literal representing the original date object. */ $D.fromObject = function(config) { config.week = null; return Date.today().set(config); }; // Create day name functions and abbreviated day name functions (eg. monday(), friday(), fri()). var df = function (n) { return function () { if (this._is) { this._is = false; return this.getDay() === n; } if (this._move) { this._move = null; } if (this._nth !== null) { // If the .second() function was called earlier, remove the _orient // from the date, and then continue. // This is required because 'second' can be used in two different context. // // Example // // Date.today().add(1).second(); // Date.march().second().monday(); // // Things get crazy with the following... // Date.march().add(1).second().second().monday(); // but it works!! // if (this._isSecond) { this.addSeconds(this._orient * -1); } // make sure we reset _isSecond this._isSecond = false; var ntemp = this._nth; this._nth = null; var temp = this.clone().moveToLastDayOfMonth(); this.moveToNthOccurrence(n, ntemp); if (this > temp) { throw new RangeError($D.getDayName(n) + " does not occur " + ntemp + " times in the month of " + $D.getMonthName(temp.getMonth()) + " " + temp.getFullYear() + "."); } return this; } return this.moveToDayOfWeek(n, this._orient); }; }; var sdf = function (n) { return function () { var t = $D.today(), shift = n - t.getDay(); if (n === 0 && Date.CultureInfo.firstDayOfWeek === 1 && t.getDay() !== 0) { shift = shift + 7; } return t.addDays(shift); }; }; // Create month name functions and abbreviated month name functions (eg. january(), march(), mar()). var month_instance_functions = function (n) { return function () { if (this._is) { this._is = false; return this.getMonth() === n; } return this.moveToMonth(n, this._orient); }; }; var month_static_functions = function (n) { return function () { return $D.today().set({ month: n, day: 1 }); }; }; var processTerms = function (names, staticFunc, instanceFunc) { for (var i = 0; i < names.length; i++) { // Create constant static Name variables. $D[names[i].toUpperCase()] = $D[names[i].toUpperCase().substring(0, 3)] = i; // Create Name functions. $D[names[i]] = $D[names[i].substring(0, 3)] = staticFunc(i); // Create Name instance functions. $P[names[i]] = $P[names[i].substring(0, 3)] = instanceFunc(i); } }; processTerms(dx, sdf, df); processTerms(mx, month_static_functions, month_instance_functions); // Create date element functions and plural date element functions used with Date (eg. day(), days(), months()). var ef = function (j) { return function () { // if the .second() function was called earlier, the _orient // has alread been added. Just return this and reset _isSecond. if (this._isSecond) { this._isSecond = false; return this; } if (this._same) { this._same = this._is = false; var o1 = this.toObject(), o2 = (arguments[0] || new Date()).toObject(), v = "", k = j.toLowerCase(); // the substr trick with -1 doesn't work in IE8 or less k = (k[k.length-1] === "s") ? k.substring(0,k.length-1) : k; for (var m = (px.length - 1); m > -1; m--) { v = px[m].toLowerCase(); if (o1[v] !== o2[v]) { return false; } if (k === v) { break; } } return true; } if (j.substring(j.length - 1) !== "s") { j += "s"; } if (this._move) { this._move = null; } return this["add" + j](this._orient); }; }; var nf = function (n) { return function () { this._dateElement = n; return this; }; }; for (var k = 0; k < px.length; k++) { de = px[k].toLowerCase(); if(de !== "weekday") { // Create date element functions and plural date element functions used with Date (eg. day(), days(), months()). $P[de] = $P[de + "s"] = ef(px[k]); // Create date element functions and plural date element functions used with Number (eg. day(), days(), months()). $N[de] = $N[de + "s"] = nf(de + "s"); } } $P._ss = ef("Second"); var nthfn = function (n) { return function (dayOfWeek) { if (this._same) { return this._ss(arguments[0]); } if (dayOfWeek || dayOfWeek === 0) { return this.moveToNthOccurrence(dayOfWeek, n); } this._nth = n; // if the operator is 'second' add the _orient, then deal with it later... if (n === 2 && (dayOfWeek === undefined || dayOfWeek === null)) { this._isSecond = true; return this.addSeconds(this._orient); } return this; }; }; for (var l = 0; l < nth.length; l++) { $P[nth[l]] = (l === 0) ? nthfn(-1) : nthfn(l); } }()); (function () { "use strict"; Date.Parsing = { Exception: function (s) { this.message = "Parse error at '" + s.substring(0, 10) + " ...'"; } }; var $P = Date.Parsing; var dayOffsets = { standard: [0,31,59,90,120,151,181,212,243,273,304,334], leap: [0,31,60,91,121,152,182,213,244,274,305,335] }; $P.isLeapYear = function(year) { return ((year % 4 === 0) && (year % 100 !== 0)) || (year % 400 === 0); }; var utils = { multiReplace : function (str, hash ) { var key; for (key in hash) { if (Object.prototype.hasOwnProperty.call(hash, key)) { var regex; if (typeof hash[key] === "function") { } else { regex = (hash[key] instanceof RegExp) ? hash[key] : new RegExp(hash[key], "g"); } str = str.replace(regex, key); } } return str; }, getDayOfYearFromWeek : function (obj) { var d, jan4, offset; obj.weekDay = (!obj.weekDay && obj.weekDay !== 0) ? 1 : obj.weekDay; d = new Date(obj.year, 0, 4); jan4 = d.getDay() === 0 ? 7 : d.getDay(); // JS is 0 indexed on Sunday. offset = jan4+3; obj.dayOfYear = ((obj.week * 7) + (obj.weekDay === 0 ? 7 : obj.weekDay))-offset; return obj; }, getDayOfYear : function (obj, dayOffset) { if (!obj.dayOfYear) { obj = utils.getDayOfYearFromWeek(obj); } for (var i=0;i <= dayOffset.length;i++) { if (obj.dayOfYear < dayOffset[i] || i === dayOffset.length) { obj.day = obj.day ? obj.day : (obj.dayOfYear - dayOffset[i-1]); break; } else { obj.month = i; } } return obj; }, adjustForTimeZone : function (obj, date) { var offset; if (obj.zone.toUpperCase() === "Z" || (obj.zone_hours === 0 && obj.zone_minutes === 0)) { // it's UTC/GML so work out the current timeszone offset offset = -date.getTimezoneOffset(); } else { offset = (obj.zone_hours*60) + (obj.zone_minutes || 0); if (obj.zone_sign === "+") { offset *= -1; } offset -= date.getTimezoneOffset(); } date.setMinutes(date.getMinutes()+offset); return date; }, setDefaults : function (obj) { obj.year = obj.year || Date.today().getFullYear(); obj.hours = obj.hours || 0; obj.minutes = obj.minutes || 0; obj.seconds = obj.seconds || 0; obj.milliseconds = obj.milliseconds || 0; if (!(!obj.month && (obj.week || obj.dayOfYear))) { // if we have a month, or if we don't but don't have the day calculation data obj.month = obj.month || 0; obj.day = obj.day || 1; } return obj; }, dataNum: function (data, mod, explict, postProcess) { var dataNum = data*1; if (mod) { if (postProcess) { return data ? mod(data)*1 : data; } else { return data ? mod(dataNum) : data; } } else if (!explict){ return data ? dataNum : data; } else { return (data && typeof data !== "undefined") ? dataNum : data; } }, timeDataProcess: function (obj) { var timeObj = {}; for (var x in obj.data) { if (obj.data.hasOwnProperty(x)) { timeObj[x] = obj.ignore[x] ? obj.data[x] : utils.dataNum(obj.data[x], obj.mods[x], obj.explict[x], obj.postProcess[x]); } } if (obj.data.secmins) { obj.data.secmins = obj.data.secmins.replace(",", ".") * 60; if (!timeObj.minutes) { timeObj.minutes = obj.data.secmins; } else if (!timeObj.seconds) { timeObj.seconds = obj.data.secmins; } delete obj.secmins; } return timeObj; }, buildTimeObjectFromData: function (data) { var time = utils.timeDataProcess({ data: { year : data[1], month : data[5], day : data[7], week : data[8], dayOfYear : data[10], hours : data[15], zone_hours : data[23], zone_minutes : data[24], zone : data[21], zone_sign : data[22], weekDay : data[9], minutes: data[16], seconds: data[19], milliseconds: data[20], secmins: data[18] }, mods: { month: function(data) { return data-1; }, weekDay: function (data) { data = Math.abs(data); return (data === 7 ? 0 : data); }, minutes: function (data) { return data.replace(":",""); }, seconds: function (data) { return Math.floor( (data.replace(":","").replace(",","."))*1 ); }, milliseconds: function (data) { return (data.replace(",",".")*1000); } }, postProcess: { minutes: true, seconds: true, milliseconds: true }, explict: { zone_hours: true, zone_minutes: true }, ignore: { zone: true, zone_sign: true, secmins: true } }); return time; }, addToHash: function (hash, keys, data) { keys = keys; data = data; var len = keys.length; for (var i = 0; i < len; i++) { hash[keys[i]] = data[i]; } return hash; }, combineRegex: function (r1, r2) { return new RegExp("(("+r1.source+")\\s("+r2.source+"))"); }, getDateNthString: function(add, last, inc){ if (add) { return Date.today().addDays(inc).toString("d"); } else if (last) { return Date.today().last()[inc]().toString("d"); } }, buildRegexData: function (array) { var arr = []; var len = array.length; for (var i=0; i < len; i++) { if (Object.prototype.toString.call(array[i]) === '[object Array]') { // oldIE compat version of Array.isArray arr.push(this.combineRegex(array[i][0], array[i][1])); } else { arr.push(array[i]); } } return arr; } }; $P.processTimeObject = function (obj) { var date, dayOffset; utils.setDefaults(obj); dayOffset = ($P.isLeapYear(obj.year)) ? dayOffsets.leap : dayOffsets.standard; if (!obj.month && (obj.week || obj.dayOfYear)) { utils.getDayOfYear(obj, dayOffset); } else { obj.dayOfYear = dayOffset[obj.month] + obj.day; } date = new Date(obj.year, obj.month, obj.day, obj.hours, obj.minutes, obj.seconds, obj.milliseconds); if (obj.zone) { utils.adjustForTimeZone(obj, date); // adjust (and calculate) for timezone } return date; }; $P.ISO = { regex : /^([\+-]?\d{4}(?!\d{2}\b))((-?)((0[1-9]|1[0-2])(\3([12]\d|0[1-9]|3[01]))?|W([0-4]\d|5[0-3])(-?[1-7])?|(00[1-9]|0[1-9]\d|[12]\d{2}|3([0-5]\d|6[1-6])))([T\s]((([01]\d|2[0-4])((:?)[0-5]\d)?|24\:?00)([\.,]\d+(?!:))?)?(\17[0-5]\d([\.,]\d+)?)?\s?([zZ]|([\+-])([01]\d|2[0-3]):?([0-5]\d)?)?)?)?$/, parse : function (s) { var time, data = s.match(this.regex); if (!data || !data.length) { return null; } time = utils.buildTimeObjectFromData(data); if (!time.year || (!time.year && (!time.month && !time.day) && (!time.week && !time.dayOfYear)) ) { return null; } return $P.processTimeObject(time); } }; $P.Numeric = { isNumeric: function (e){return!isNaN(parseFloat(e))&&isFinite(e);}, regex: /\b([0-1]?[0-9])([0-3]?[0-9])([0-2]?[0-9]?[0-9][0-9])\b/i, parse: function (s) { var data, i, time = {}, order = Date.CultureInfo.dateElementOrder.split(""); if (!(this.isNumeric(s)) || // if it's non-numeric OR (s[0] === "+" && s[0] === "-")) { // It's an arithmatic string (eg +/-1000) return null; } if (s.length < 5 && s.indexOf(".") < 0 && s.indexOf("/") < 0) { // assume it's just a year. time.year = s; return $P.processTimeObject(time); } data = s.match(this.regex); if (!data || !data.length) { return null; } for (i=0; i < order.length; i++) { switch(order[i]) { case "d": time.day = data[i+1]; break; case "m": time.month = (data[i+1]-1); break; case "y": time.year = data[i+1]; break; } } return $P.processTimeObject(time); } }; $P.Normalizer = { regexData: function () { var $R = Date.CultureInfo.regexPatterns; return utils.buildRegexData([ $R.tomorrow, $R.yesterday, [$R.past, $R.mon], [$R.past, $R.tue], [$R.past, $R.wed], [$R.past, $R.thu], [$R.past, $R.fri], [$R.past, $R.sat], [$R.past, $R.sun] ]); }, basicReplaceHash : function() { var $R = Date.CultureInfo.regexPatterns; return { "January": $R.jan.source, "February": $R.feb, "March": $R.mar, "April": $R.apr, "May": $R.may, "June": $R.jun, "July": $R.jul, "August": $R.aug, "September": $R.sep, "October": $R.oct, "November": $R.nov, "December": $R.dec, "": /\bat\b/gi, " ": /\s{2,}/, "am": $R.inTheMorning, "9am": $R.thisMorning, "pm": $R.inTheEvening, "7pm":$R.thisEvening }; }, keys : function(){ return [ utils.getDateNthString(true, false, 1), // tomorrow utils.getDateNthString(true, false, -1), // yesterday utils.getDateNthString(false, true, "monday"), //last mon utils.getDateNthString(false, true, "tuesday"), //last tues utils.getDateNthString(false, true, "wednesday"), //last wed utils.getDateNthString(false, true, "thursday"), //last thurs utils.getDateNthString(false, true, "friday"), //last fri utils.getDateNthString(false, true, "saturday"), //last sat utils.getDateNthString(false, true, "sunday") //last sun ]; }, buildRegexFunctions: function () { var $R = Date.CultureInfo.regexPatterns; var __ = Date.i18n.__; var tomorrowRE = new RegExp("(\\b\\d\\d?("+__("AM")+"|"+__("PM")+")? )("+$R.tomorrow.source.slice(1)+")", "i"); // adapted tomorrow regex for AM PM relative dates var todayRE = new RegExp($R.today.source + "(?!\\s*([+-]))\\b"); // today, but excludes the math operators (eg "today + 2h") this.replaceFuncs = [ [todayRE, function (full) { return (full.length > 1) ? Date.today().toString("d") : full; }], [tomorrowRE, function(full, m1) { var t = Date.today().addDays(1).toString("d"); return (t + " " + m1); }], [$R.amThisMorning, function(str, am){return am;}], [$R.pmThisEvening, function(str, pm){return pm;}] ]; }, buildReplaceData: function () { this.buildRegexFunctions(); this.replaceHash = utils.addToHash(this.basicReplaceHash(), this.keys(), this.regexData()); }, stringReplaceFuncs: function (s) { for (var i=0; i < this.replaceFuncs.length; i++) { s = s.replace(this.replaceFuncs[i][0], this.replaceFuncs[i][1]); } return s; }, parse: function (s) { s = this.stringReplaceFuncs(s); s = utils.multiReplace(s, this.replaceHash); try { var n = s.split(/([\s\-\.\,\/\x27]+)/); if (n.length === 3 && $P.Numeric.isNumeric(n[0]) && $P.Numeric.isNumeric(n[2]) && (n[2].length >= 4)) { // ok, so we're dealing with x/year. But that's not a full date. // This fixes wonky dateElementOrder parsing when set to dmy order. if (Date.CultureInfo.dateElementOrder[0] === "d") { s = "1/" + n[0] + "/" + n[2]; // set to 1st of month and normalize the seperator } } } catch (e) {} return s; } }; $P.Normalizer.buildReplaceData(); }()); (function () { var $P = Date.Parsing; var _ = $P.Operators = { // // Tokenizers // rtoken: function (r) { // regex token return function (s) { var mx = s.match(r); if (mx) { return ([ mx[0], s.substring(mx[0].length) ]); } else { throw new $P.Exception(s); } }; }, token: function () { // whitespace-eating token return function (s) { return _.rtoken(new RegExp("^\\s*" + s + "\\s*"))(s); }; }, stoken: function (s) { // string token return _.rtoken(new RegExp("^" + s)); }, // Atomic Operators until: function (p) { return function (s) { var qx = [], rx = null; while (s.length) { try { rx = p.call(this, s); } catch (e) { qx.push(rx[0]); s = rx[1]; continue; } break; } return [ qx, s ]; }; }, many: function (p) { return function (s) { var rx = [], r = null; while (s.length) { try { r = p.call(this, s); } catch (e) { return [ rx, s ]; } rx.push(r[0]); s = r[1]; } return [ rx, s ]; }; }, // generator operators -- see below optional: function (p) { return function (s) { var r = null; try { r = p.call(this, s); } catch (e) { return [ null, s ]; } return [ r[0], r[1] ]; }; }, not: function (p) { return function (s) { try { p.call(this, s); } catch (e) { return [null, s]; } throw new $P.Exception(s); }; }, ignore: function (p) { return p ? function (s) { var r = null; r = p.call(this, s); return [null, r[1]]; } : null; }, product: function () { var px = arguments[0], qx = Array.prototype.slice.call(arguments, 1), rx = []; for (var i = 0 ; i < px.length ; i++) { rx.push(_.each(px[i], qx)); } return rx; }, cache: function (rule) { var cache = {}, cache_length = 0, cache_keys = [], CACHE_MAX = Date.Config.CACHE_MAX || 100000, r = null; var cacheCheck = function () { if (cache_length === CACHE_MAX) { // kill several keys, don't want to have to do this all the time... for (var i=0; i < 10; i++) { var key = cache_keys.shift(); if (key) { delete cache[key]; cache_length--; } } } }; return function (s) { cacheCheck(); try { r = cache[s] = (cache[s] || rule.call(this, s)); } catch (e) { r = cache[s] = e; } cache_length++; cache_keys.push(s); if (r instanceof $P.Exception) { throw r; } else { return r; } }; }, // vector operators -- see below any: function () { var px = arguments; return function (s) { var r = null; for (var i = 0; i < px.length; i++) { if (px[i] == null) { continue; } try { r = (px[i].call(this, s)); } catch (e) { r = null; } if (r) { return r; } } throw new $P.Exception(s); }; }, each: function () { var px = arguments; return function (s) { var rx = [], r = null; for (var i = 0; i < px.length ; i++) { if (px[i] == null) { continue; } try { r = (px[i].call(this, s)); } catch (e) { throw new $P.Exception(s); } rx.push(r[0]); s = r[1]; } return [ rx, s]; }; }, all: function () { var px = arguments, _ = _; return _.each(_.optional(px)); }, // delimited operators sequence: function (px, d, c) { d = d || _.rtoken(/^\s*/); c = c || null; if (px.length === 1) { return px[0]; } return function (s) { var r = null, q = null; var rx = []; for (var i = 0; i < px.length ; i++) { try { r = px[i].call(this, s); } catch (e) { break; } rx.push(r[0]); try { q = d.call(this, r[1]); } catch (ex) { q = null; break; } s = q[1]; } if (!r) { throw new $P.Exception(s); } if (q) { throw new $P.Exception(q[1]); } if (c) { try { r = c.call(this, r[1]); } catch (ey) { throw new $P.Exception(r[1]); } } return [ rx, (r?r[1]:s) ]; }; }, // // Composite Operators // between: function (d1, p, d2) { d2 = d2 || d1; var _fn = _.each(_.ignore(d1), p, _.ignore(d2)); return function (s) { var rx = _fn.call(this, s); return [[rx[0][0], r[0][2]], rx[1]]; }; }, list: function (p, d, c) { d = d || _.rtoken(/^\s*/); c = c || null; return (p instanceof Array ? _.each(_.product(p.slice(0, -1), _.ignore(d)), p.slice(-1), _.ignore(c)) : _.each(_.many(_.each(p, _.ignore(d))), px, _.ignore(c))); }, set: function (px, d, c) { d = d || _.rtoken(/^\s*/); c = c || null; return function (s) { // r is the current match, best the current 'best' match // which means it parsed the most amount of input var r = null, p = null, q = null, rx = null, best = [[], s], last = false; // go through the rules in the given set for (var i = 0; i < px.length ; i++) { // last is a flag indicating whether this must be the last element // if there is only 1 element, then it MUST be the last one q = null; p = null; r = null; last = (px.length === 1); // first, we try simply to match the current pattern // if not, try the next pattern try { r = px[i].call(this, s); } catch (e) { continue; } // since we are matching against a set of elements, the first // thing to do is to add r[0] to matched elements rx = [[r[0]], r[1]]; // if we matched and there is still input to parse and // we don't already know this is the last element, // we're going to next check for the delimiter ... // if there's none, or if there's no input left to parse // than this must be the last element after all ... if (r[1].length > 0 && ! last) { try { q = d.call(this, r[1]); } catch (ex) { last = true; } } else { last = true; } // if we parsed the delimiter and now there's no more input, // that means we shouldn't have parsed the delimiter at all // so don't update r and mark this as the last element ... if (!last && q[1].length === 0) { last = true; } // so, if this isn't the last element, we're going to see if // we can get any more matches from the remaining (unmatched) // elements ... if (!last) { // build a list of the remaining rules we can match against, // i.e., all but the one we just matched against var qx = []; for (var j = 0; j < px.length ; j++) { if (i !== j) { qx.push(px[j]); } } // now invoke recursively set with the remaining input // note that we don't include the closing delimiter ... // we'll check for that ourselves at the end p = _.set(qx, d).call(this, q[1]); // if we got a non-empty set as a result ... // (otw rx already contains everything we want to match) if (p[0].length > 0) { // update current result, which is stored in rx ... // basically, pick up the remaining text from p[1] // and concat the result from p[0] so that we don't // get endless nesting ... rx[0] = rx[0].concat(p[0]); rx[1] = p[1]; } } // at this point, rx either contains the last matched element // or the entire matched set that starts with this element. // now we just check to see if this variation is better than // our best so far, in terms of how much of the input is parsed if (rx[1].length < best[1].length) { best = rx; } // if we've parsed all the input, then we're finished if (best[1].length === 0) { break; } } // so now we've either gone through all the patterns trying them // as the initial match; or we found one that parsed the entire // input string ... // if best has no matches, just return empty set ... if (best[0].length === 0) { return best; } // if a closing delimiter is provided, then we have to check it also if (c) { // we try this even if there is no remaining input because the pattern // may well be optional or match empty input ... try { q = c.call(this, best[1]); } catch (ey) { throw new $P.Exception(best[1]); } // it parsed ... be sure to update the best match remaining input best[1] = q[1]; } // if we're here, either there was no closing delimiter or we parsed it // so now we have the best match; just return it! return best; }; }, forward: function (gr, fname) { return function (s) { return gr[fname].call(this, s); }; }, // // Translation Operators // replace: function (rule, repl) { return function (s) { var r = rule.call(this, s); return [repl, r[1]]; }; }, process: function (rule, fn) { return function (s) { var r = rule.call(this, s); return [fn.call(this, r[0]), r[1]]; }; }, min: function (min, rule) { return function (s) { var rx = rule.call(this, s); if (rx[0].length < min) { throw new $P.Exception(s); } return rx; }; } }; // Generator Operators And Vector Operators // Generators are operators that have a signature of F(R) => R, // taking a given rule and returning another rule, such as // ignore, which parses a given rule and throws away the result. // Vector operators are those that have a signature of F(R1,R2,...) => R, // take a list of rules and returning a new rule, such as each. // Generator operators are converted (via the following _generator // function) into functions that can also take a list or array of rules // and return an array of new rules as though the function had been // called on each rule in turn (which is what actually happens). // This allows generators to be used with vector operators more easily. // Example: // each(ignore(foo, bar)) instead of each(ignore(foo), ignore(bar)) // This also turns generators into vector operators, which allows // constructs like: // not(cache(foo, bar)) var _generator = function (op) { function gen() { var args = null, rx = [], px, i; if (arguments.length > 1) { args = Array.prototype.slice.call(arguments); } else if (arguments[0] instanceof Array) { args = arguments[0]; } if (args) { px = args.shift(); if (px.length > 0) { args.unshift(px[i]); rx.push(op.apply(null, args)); args.shift(); return rx; } } else { return op.apply(null, arguments); } } return gen; }; var gx = "optional not ignore cache".split(/\s/); for (var i = 0 ; i < gx.length ; i++) { _[gx[i]] = _generator(_[gx[i]]); } var _vector = function (op) { return function () { if (arguments[0] instanceof Array) { return op.apply(null, arguments[0]); } else { return op.apply(null, arguments); } }; }; var vx = "each any all".split(/\s/); for (var j = 0 ; j < vx.length ; j++) { _[vx[j]] = _vector(_[vx[j]]); } }()); (function () { var $D = Date; var flattenAndCompact = function (ax) { var rx = []; for (var i = 0; i < ax.length; i++) { if (ax[i] instanceof Array) { rx = rx.concat(flattenAndCompact(ax[i])); } else { if (ax[i]) { rx.push(ax[i]); } } } return rx; }; var parseMeridian = function () { if (this.meridian && (this.hour || this.hour === 0)) { if (this.meridian === "a" && this.hour > 11 && Date.Config.strict24hr){ throw "Invalid hour and meridian combination"; } else if (this.meridian === "p" && this.hour < 12 && Date.Config.strict24hr){ throw "Invalid hour and meridian combination"; } else if (this.meridian === "p" && this.hour < 12) { this.hour = this.hour + 12; } else if (this.meridian === "a" && this.hour === 12) { this.hour = 0; } } }; var setDefaults = function () { var now = new Date(); if ((this.hour || this.minute) && (!this.month && !this.year && !this.day)) { this.day = now.getDate(); } if (!this.year) { this.year = now.getFullYear(); } if (!this.month && this.month !== 0) { this.month = now.getMonth(); } if (!this.day) { this.day = 1; } if (!this.hour) { this.hour = 0; } if (!this.minute) { this.minute = 0; } if (!this.second) { this.second = 0; } if (!this.millisecond) { this.millisecond = 0; } }; var finishUtils = { getToday: function () { if (this.now || "hour minute second".indexOf(this.unit) !== -1) { return new Date(); } else { return $D.today(); } }, setDaysFromWeekday: function (today, orient){ var gap; orient = orient || 1; this.unit = "day"; gap = ($D.getDayNumberFromName(this.weekday) - today.getDay()); this.days = gap ? ((gap + (orient * 7)) % 7) : (orient * 7); return this; }, setMonthsFromMonth: function (today, orient) { var gap; orient = orient || 1; this.unit = "month"; gap = (this.month - today.getMonth()); this.months = gap ? ((gap + (orient * 12)) % 12) : (orient * 12); this.month = null; return this; }, setDMYFromWeekday: function () { var d = Date[this.weekday](); this.day = d.getDate(); if (!this.month) { this.month = d.getMonth(); } this.year = d.getFullYear(); return this; }, setUnitValue: function (orient) { if (!this.value && this.operator && this.operator !== null && this[this.unit + "s"] && this[this.unit + "s"] !== null) { this[this.unit + "s"] = this[this.unit + "s"] + ((this.operator === "add") ? 1 : -1) + (this.value||0) * orient; } else if (this[this.unit + "s"] == null || this.operator != null) { if (!this.value) { this.value = 1; } this[this.unit + "s"] = this.value * orient; } }, generateDateFromWeeks: function () { var weekday = (this.weekday !== undefined) ? this.weekday : "today"; var d = Date[weekday]().addWeeks(this.weeks); if (this.now) { d.setTimeToNow(); } return d; } }; $D.Translator = { hour: function (s) { return function () { this.hour = Number(s); }; }, minute: function (s) { return function () { this.minute = Number(s); }; }, second: function (s) { return function () { this.second = Number(s); }; }, /* for ss.s format */ secondAndMillisecond: function (s) { return function () { var mx = s.match(/^([0-5][0-9])\.([0-9]{1,3})/); this.second = Number(mx[1]); this.millisecond = Number(mx[2]); }; }, meridian: function (s) { return function () { this.meridian = s.slice(0, 1).toLowerCase(); }; }, timezone: function (s) { return function () { var n = s.replace(/[^\d\+\-]/g, ""); if (n.length) { this.timezoneOffset = Number(n); } else { this.timezone = s.toLowerCase(); } }; }, day: function (x) { var s = x[0]; return function () { this.day = Number(s.match(/\d+/)[0]); if (this.day < 1) { throw "invalid day"; } }; }, month: function (s) { return function () { this.month = (s.length === 3) ? "jan feb mar apr may jun jul aug sep oct nov dec".indexOf(s)/4 : Number(s) - 1; if (this.month < 0) { throw "invalid month"; } }; }, year: function (s) { return function () { var n = Number(s); this.year = ((s.length > 2) ? n : (n + (((n + 2000) < Date.CultureInfo.twoDigitYearMax) ? 2000 : 1900))); }; }, rday: function (s) { return function () { switch (s) { case "yesterday": this.days = -1; break; case "tomorrow": this.days = 1; break; case "today": this.days = 0; break; case "now": this.days = 0; this.now = true; break; } }; }, finishExact: function (x) { var d; x = (x instanceof Array) ? x : [x]; for (var i = 0 ; i < x.length ; i++) { if (x[i]) { x[i].call(this); } } setDefaults.call(this); parseMeridian.call(this); if (this.day > $D.getDaysInMonth(this.year, this.month)) { throw new RangeError(this.day + " is not a valid value for days."); } d = new Date(this.year, this.month, this.day, this.hour, this.minute, this.second, this.millisecond); if (this.year < 100) { d.setFullYear(this.year); // means years less that 100 are process correctly. JS will parse it otherwise as 1900-1999. } if (this.timezone) { d.set({ timezone: this.timezone }); } else if (this.timezoneOffset) { d.set({ timezoneOffset: this.timezoneOffset }); } return d; }, finish: function (x) { var today, expression, orient, temp; x = (x instanceof Array) ? flattenAndCompact(x) : [ x ]; if (x.length === 0) { return null; } for (var i = 0 ; i < x.length ; i++) { if (typeof x[i] === "function") { x[i].call(this); } } if (this.now && !this.unit && !this.operator) { return new Date(); } else { today = finishUtils.getToday.call(this); } expression = !!(this.days && this.days !== null || this.orient || this.operator); orient = ((this.orient === "past" || this.operator === "subtract") ? -1 : 1); if (this.month && this.unit === "week") { this.value = this.month + 1; delete this.month; delete this.day; } if ((this.month || this.month === 0) && "year day hour minute second".indexOf(this.unit) !== -1) { if (!this.value) { this.value = this.month + 1; } this.month = null; expression = true; } if (!expression && this.weekday && !this.day && !this.days) { finishUtils.setDMYFromWeekday.call(this); } if (expression && this.weekday && this.unit !== "month" && this.unit !== "week") { finishUtils.setDaysFromWeekday.call(this, today, orient); } if (this.weekday && this.unit !== "week" && !this.day && !this.days) { temp = Date[this.weekday](); this.day = temp.getDate(); if (temp.getMonth() !== today.getMonth()) { this.month = temp.getMonth(); } } if (this.month && this.unit === "day" && this.operator) { if (!this.value) { this.value = (this.month + 1); } this.month = null; } if (this.value != null && this.month != null && this.year != null) { this.day = this.value * 1; } if (this.month && !this.day && this.value) { today.set({ day: this.value * 1 }); if (!expression) { this.day = this.value * 1; } } if (!this.month && this.value && this.unit === "month" && !this.now) { this.month = this.value; expression = true; } if (expression && (this.month || this.month === 0) && this.unit !== "year") { finishUtils.setMonthsFromMonth.call(this, today, orient); } if (!this.unit) { this.unit = "day"; } finishUtils.setUnitValue.call(this, orient); parseMeridian.call(this); if ((this.month || this.month === 0) && !this.day) { this.day = 1; } if (!this.orient && !this.operator && this.unit === "week" && this.value && !this.day && !this.month) { return Date.today().setWeek(this.value); } if (this.unit === "week" && this.weeks && !this.day && !this.month) { return finishUtils.generateDateFromWeeks.call(this); } if (expression && this.timezone && this.day && this.days) { this.day = this.days; } if (expression){ today.add(this); } else { today.set(this); } if (this.timezone) { this.timezone = this.timezone.toUpperCase(); var offset = $D.getTimezoneOffset(this.timezone); var timezone; if (today.hasDaylightSavingTime()) { // lets check that we're being sane with timezone setting timezone = $D.getTimezoneAbbreviation(offset, today.isDaylightSavingTime()); if (timezone !== this.timezone) { // bugger, we're in a place where things like EST vs EDT matters. if (today.isDaylightSavingTime()) { today.addHours(-1); } else { today.addHours(1); } } } today.setTimezoneOffset(offset); } return today; } }; }()); (function () { var $D = Date; $D.Grammar = {}; var _ = $D.Parsing.Operators, g = $D.Grammar, t = $D.Translator, _fn; // Allow rolling up into general purpose rules _fn = function () { return _.each(_.any.apply(null, arguments), _.not(g.ctoken2("timeContext"))); }; g.datePartDelimiter = _.rtoken(/^([\s\-\.\,\/\x27]+)/); g.timePartDelimiter = _.stoken(":"); g.whiteSpace = _.rtoken(/^\s*/); g.generalDelimiter = _.rtoken(/^(([\s\,]|at|@|on)+)/); var _C = {}; g.ctoken = function (keys) { var fn = _C[keys]; if (! fn) { var c = Date.CultureInfo.regexPatterns; var kx = keys.split(/\s+/), px = []; for (var i = 0; i < kx.length ; i++) { px.push(_.replace(_.rtoken(c[kx[i]]), kx[i])); } fn = _C[keys] = _.any.apply(null, px); } return fn; }; g.ctoken2 = function (key) { return _.rtoken(Date.CultureInfo.regexPatterns[key]); }; var cacheProcessRtoken = function (key, token, type, eachToken) { if (eachToken) { g[key] = _.cache(_.process(_.each(_.rtoken(token),_.optional(g.ctoken2(eachToken))), type)); } else { g[key] = _.cache(_.process(_.rtoken(token), type)); } }; var cacheProcessCtoken = function (token, type) { return _.cache(_.process(g.ctoken2(token), type)); }; var _F = {}; //function cache var _get = function (f) { _F[f] = (_F[f] || g.format(f)[0]); return _F[f]; }; g.allformats = function (fx) { var rx = []; if (fx instanceof Array) { for (var i = 0; i < fx.length; i++) { rx.push(_get(fx[i])); } } else { rx.push(_get(fx)); } return rx; }; g.formats = function (fx) { if (fx instanceof Array) { var rx = []; for (var i = 0 ; i < fx.length ; i++) { rx.push(_get(fx[i])); } return _.any.apply(null, rx); } else { return _get(fx); } }; var grammarFormats = { timeFormats: function(){ var i, RTokenKeys = [ "h", "hh", "H", "HH", "m", "mm", "s", "ss", "ss.s", "z", "zz" ], RToken = [ /^(0[0-9]|1[0-2]|[1-9])/, /^(0[0-9]|1[0-2])/, /^([0-1][0-9]|2[0-3]|[0-9])/, /^([0-1][0-9]|2[0-3])/, /^([0-5][0-9]|[0-9])/, /^[0-5][0-9]/, /^([0-5][0-9]|[0-9])/, /^[0-5][0-9]/, /^[0-5][0-9]\.[0-9]{1,3}/, /^((\+|\-)\s*\d\d\d\d)|((\+|\-)\d\d\:?\d\d)/, /^((\+|\-)\s*\d\d\d\d)|((\+|\-)\d\d\:?\d\d)/ ], tokens = [ t.hour, t.hour, t.hour, t.hour, t.minute, t.minute, t.second, t.second, t.secondAndMillisecond, t.timezone, t.timezone ]; for (i=0; i < RTokenKeys.length; i++) { cacheProcessRtoken(RTokenKeys[i], RToken[i], tokens[i]); } g.hms = _.cache(_.sequence([g.H, g.m, g.s], g.timePartDelimiter)); g.t = cacheProcessCtoken("shortMeridian", t.meridian); g.tt = cacheProcessCtoken("longMeridian", t.meridian); g.zzz = cacheProcessCtoken("timezone", t.timezone); g.timeSuffix = _.each(_.ignore(g.whiteSpace), _.set([ g.tt, g.zzz ])); g.time = _.each(_.optional(_.ignore(_.stoken("T"))), g.hms, g.timeSuffix); }, dateFormats: function () { // pre-loaded rules for different date part order preferences var _setfn = function () { return _.set(arguments, g.datePartDelimiter); }; var i, RTokenKeys = [ "d", "dd", "M", "MM", "y", "yy", "yyy", "yyyy" ], RToken = [ /^([0-2]\d|3[0-1]|\d)/, /^([0-2]\d|3[0-1])/, /^(1[0-2]|0\d|\d)/, /^(1[0-2]|0\d)/, /^(\d+)/, /^(\d\d)/, /^(\d\d?\d?\d?)/, /^(\d\d\d\d)/ ], tokens = [ t.day, t.day, t.month, t.month, t.year, t.year, t.year, t.year ], eachToken = [ "ordinalSuffix", "ordinalSuffix" ]; for (i=0; i < RTokenKeys.length; i++) { cacheProcessRtoken(RTokenKeys[i], RToken[i], tokens[i], eachToken[i]); } g.MMM = g.MMMM = _.cache(_.process(g.ctoken("jan feb mar apr may jun jul aug sep oct nov dec"), t.month)); g.ddd = g.dddd = _.cache(_.process(g.ctoken("sun mon tue wed thu fri sat"), function (s) { return function () { this.weekday = s; }; } )); g.day = _fn(g.d, g.dd); g.month = _fn(g.M, g.MMM); g.year = _fn(g.yyyy, g.yy); g.mdy = _setfn(g.ddd, g.month, g.day, g.year); g.ymd = _setfn(g.ddd, g.year, g.month, g.day); g.dmy = _setfn(g.ddd, g.day, g.month, g.year); g.date = function (s) { return ((g[Date.CultureInfo.dateElementOrder] || g.mdy).call(this, s)); }; }, relative: function () { // relative date / time expressions g.orientation = _.process(g.ctoken("past future"), function (s) { return function () { this.orient = s; }; } ); g.operator = _.process(g.ctoken("add subtract"), function (s) { return function () { this.operator = s; }; } ); g.rday = _.process(g.ctoken("yesterday tomorrow today now"), t.rday); g.unit = _.process(g.ctoken("second minute hour day week month year"), function (s) { return function () { this.unit = s; }; } ); } }; g.buildGrammarFormats = function () { // these need to be rebuilt every time the language changes. _C = {}; grammarFormats.timeFormats(); grammarFormats.dateFormats(); grammarFormats.relative(); g.value = _.process(_.rtoken(/^([-+]?\d+)?(st|nd|rd|th)?/), function (s) { return function () { this.value = s.replace(/\D/g, ""); }; } ); g.expression = _.set([g.rday, g.operator, g.value, g.unit, g.orientation, g.ddd, g.MMM ]); g.format = _.process(_.many( _.any( // translate format specifiers into grammar rules _.process( _.rtoken(/^(dd?d?d?(?!e)|MM?M?M?|yy?y?y?|hh?|HH?|mm?|ss?|tt?|zz?z?)/), function (fmt) { if (g[fmt]) { return g[fmt]; } else { throw $D.Parsing.Exception(fmt); } } ), // translate separator tokens into token rules _.process(_.rtoken(/^[^dMyhHmstz]+/), // all legal separators function (s) { return _.ignore(_.stoken(s)); } ) ) ), // construct the parser ... function (rules) { return _.process(_.each.apply(null, rules), t.finishExact); } ); // starting rule for general purpose grammar g._start = _.process(_.set([ g.date, g.time, g.expression ], g.generalDelimiter, g.whiteSpace), t.finish); }; g.buildGrammarFormats(); // parsing date format specifiers - ex: "h:m:s tt" // this little guy will generate a custom parser based // on the format string, ex: g.format("h:m:s tt") // check for these formats first g._formats = g.formats([ "\"yyyy-MM-ddTHH:mm:ssZ\"", "yyyy-MM-ddTHH:mm:ss.sz", "yyyy-MM-ddTHH:mm:ssZ", "yyyy-MM-ddTHH:mm:ssz", "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-ddTHH:mmZ", "yyyy-MM-ddTHH:mmz", "yyyy-MM-ddTHH:mm", "ddd, MMM dd, yyyy H:mm:ss tt", "ddd MMM d yyyy HH:mm:ss zzz", "MMddyyyy", "ddMMyyyy", "Mddyyyy", "ddMyyyy", "Mdyyyy", "dMyyyy", "yyyy", "Mdyy", "dMyy", "d" ]); // real starting rule: tries selected formats first, // then general purpose rule g.start = function (s) { try { var r = g._formats.call({}, s); if (r[1].length === 0) { return r; } } catch (e) {} return g._start.call({}, s); }; }()); (function () { var $D = Date; /** * @desc Converts the specified string value into its JavaScript Date equivalent using CultureInfo specific format information. * * Example

	///////////
	// Dates //
	///////////

	// 15-Oct-2004
	var d1 = Date.parse("10/15/2004");

	// 15-Oct-2004
	var d1 = Date.parse("15-Oct-2004");

	// 15-Oct-2004
	var d1 = Date.parse("2004.10.15");

	//Fri Oct 15, 2004
	var d1 = Date.parse("Fri Oct 15, 2004");

	///////////
	// Times //
	///////////

	// Today at 10 PM.
	var d1 = Date.parse("10 PM");

	// Today at 10:30 PM.
	var d1 = Date.parse("10:30 P.M.");

	// Today at 6 AM.
	var d1 = Date.parse("06am");

	/////////////////////
	// Dates and Times //
	/////////////////////

	// 8-July-2004 @ 10:30 PM
	var d1 = Date.parse("July 8th, 2004, 10:30 PM");

	// 1-July-2004 @ 10:30 PM
	var d1 = Date.parse("2004-07-01T22:30:00");

	////////////////////
	// Relative Dates //
	////////////////////

	// Returns today's date. The string "today" is culture specific.
	var d1 = Date.parse("today");

	// Returns yesterday's date. The string "yesterday" is culture specific.
	var d1 = Date.parse("yesterday");

	// Returns the date of the next thursday.
	var d1 = Date.parse("Next thursday");

	// Returns the date of the most previous monday.
	var d1 = Date.parse("last monday");

	// Returns today's day + one year.
	var d1 = Date.parse("next year");

	///////////////
	// Date Math //
	///////////////

	// Today + 2 days
	var d1 = Date.parse("t+2");

	// Today + 2 days
	var d1 = Date.parse("today + 2 days");

	// Today + 3 months
	var d1 = Date.parse("t+3m");

	// Today - 1 year
	var d1 = Date.parse("today - 1 year");

	// Today - 1 year
	var d1 = Date.parse("t-1y"); 


	/////////////////////////////
	// Partial Dates and Times //
	/////////////////////////////

	// July 15th of this year.
	var d1 = Date.parse("July 15");

	// 15th day of current day and year.
	var d1 = Date.parse("15");

	// July 1st of current year at 10pm.
	var d1 = Date.parse("7/1 10pm");
	
* * @param {String} The string value to convert into a Date object [Required] * @return {Date} A Date object or null if the string cannot be converted into a Date. */ var parseUtils = { removeOrds: function (s) { ords = s.match(/\b(\d+)(?:st|nd|rd|th)\b/); // find ordinal matches s = ((ords && ords.length === 2) ? s.replace(ords[0], ords[1]) : s); return s; }, grammarParser: function (s) { var r = null; try { r = $D.Grammar.start.call({}, s.replace(/^\s*(\S*(\s+\S+)*)\s*$/, "$1")); } catch (e) { return null; } return ((r[1].length === 0) ? r[0] : null); }, nativeFallback: function(s) { var t; try { // ok we haven't parsed it, last ditch attempt with the built-in parser. t = Date._parse(s); return (t || t === 0) ? new Date(t) : null; } catch (e) { return null; } } }; function parse (s) { var d; if (!s) { return null; } if (s instanceof Date) { return s.clone(); } if (s.length >= 4 && s.charAt(0) !== "0" && s.charAt(0) !== "+"&& s.charAt(0) !== "-") { // ie: 2004 will pass, 0800 won't. // Start with specific formats d = $D.Parsing.ISO.parse(s) || $D.Parsing.Numeric.parse(s); } if (d instanceof Date && !isNaN(d.getTime())) { return d; } else { // find ordinal dates (1st, 3rd, 8th, etc and remove them as they cause parsing issues) s = $D.Parsing.Normalizer.parse(parseUtils.removeOrds(s)); d = parseUtils.grammarParser(s); if (d !== null) { return d; } else { return parseUtils.nativeFallback(s); } } } if (!$D._parse) { $D._parse = $D.parse; } $D.parse = parse; Date.getParseFunction = function (fx) { var fns = Date.Grammar.allformats(fx); return function (s) { var r = null; for (var i = 0; i < fns.length; i++) { try { r = fns[i].call({}, s); } catch (e) { continue; } if (r[1].length === 0) { return r[0]; } } return null; }; }; /** * Converts the specified string value into its JavaScript Date equivalent using the specified format {String} or formats {Array} and the CultureInfo specific format information. * The format of the string value must match one of the supplied formats exactly. * * Example

	// 15-Oct-2004
	var d1 = Date.parseExact("10/15/2004", "M/d/yyyy");

	// 15-Oct-2004
	var d1 = Date.parse("15-Oct-2004", "M-ddd-yyyy");

	// 15-Oct-2004
	var d1 = Date.parse("2004.10.15", "yyyy.MM.dd");

	// Multiple formats
	var d1 = Date.parseExact("10/15/2004", ["M/d/yyyy", "MMMM d, yyyy"]);
	
* * @param {String} The string value to convert into a Date object [Required]. * @param {Object} The expected format {String} or an array of expected formats {Array} of the date string [Required]. * @return {Date} A Date object or null if the string cannot be converted into a Date. */ $D.parseExact = function (s, fx) { return $D.getParseFunction(fx)(s); }; }()); (function () { var $D = Date, $P = $D.prototype, // $C = $D.CultureInfo, // not used atm p = function (s, l) { if (!l) { l = 2; } return ("000" + s).slice(l * -1); }; /** * Converts a PHP format string to Java/.NET format string. * A PHP format string can be used with ._format or .format. * A Java/.NET format string can be used with .toString(). * The .parseExact function will only accept a Java/.NET format string * * Example * var f1 = "%m/%d/%y" * var f2 = Date.normalizeFormat(f1); // "MM/dd/yy" * * new Date().format(f1); // "04/13/08" * new Date()._format(f1); // "04/13/08" * new Date().toString(f2); // "04/13/08" * * var date = Date.parseExact("04/13/08", f2); // Sun Apr 13 2008 * * @param {String} A PHP format string consisting of one or more format spcifiers. * @return {String} The PHP format converted to a Java/.NET format string. */ var normalizerSubstitutions = { "d" : "dd", "%d": "dd", "D" : "ddd", "%a": "ddd", "j" : "dddd", "l" : "dddd", "%A": "dddd", "S" : "S", "F" : "MMMM", "%B": "MMMM", "m" : "MM", "%m": "MM", "M" : "MMM", "%b": "MMM", "%h": "MMM", "n" : "M", "Y" : "yyyy", "%Y": "yyyy", "y" : "yy", "%y": "yy", "g" : "h", "%I": "h", "G" : "H", "h" : "hh", "H" : "HH", "%H": "HH", "i" : "mm", "%M": "mm", "s" : "ss", "%S": "ss", "%r": "hh:mm tt", "%R": "H:mm", "%T": "H:mm:ss", "%X": "t", "%x": "d", "%e": "d", "%D": "MM/dd/yy", "%n": "\\n", "%t": "\\t", "e" : "z", "T" : "z", "%z": "z", "%Z": "z", "Z" : "ZZ", "N" : "u", "w" : "u", "%w": "u", "W" : "W", "%V": "W" }; var normalizer = { substitutes: function (m) { return normalizerSubstitutions[m]; }, interpreted: function (m, x) { var y; switch (m) { case "%u": return x.getDay() + 1; case "z": return x.getOrdinalNumber(); case "%j": return p(x.getOrdinalNumber(), 3); case "%U": var d1 = x.clone().set({month: 0, day: 1}).addDays(-1).moveToDayOfWeek(0), d2 = x.clone().addDays(1).moveToDayOfWeek(0, -1); return (d2 < d1) ? "00" : p((d2.getOrdinalNumber() - d1.getOrdinalNumber()) / 7 + 1); case "%W": return p(x.getWeek()); case "t": return $D.getDaysInMonth(x.getFullYear(), x.getMonth()); case "o": case "%G": return x.setWeek(x.getISOWeek()).toString("yyyy"); case "%g": return x._format("%G").slice(-2); case "a": case "%p": return t("tt").toLowerCase(); case "A": return t("tt").toUpperCase(); case "u": return p(x.getMilliseconds(), 3); case "I": return (x.isDaylightSavingTime()) ? 1 : 0; case "O": return x.getUTCOffset(); case "P": y = x.getUTCOffset(); return y.substring(0, y.length - 2) + ":" + y.substring(y.length - 2); case "B": var now = new Date(); return Math.floor(((now.getHours() * 3600) + (now.getMinutes() * 60) + now.getSeconds() + (now.getTimezoneOffset() + 60) * 60) / 86.4); case "c": return x.toISOString().replace(/\"/g, ""); case "U": return $D.strtotime("now"); case "%c": return t("d") + " " + t("t"); case "%C": return Math.floor(x.getFullYear() / 100 + 1); } }, shouldOverrideDefaults: function (m) { switch (m) { case "%e": return true; default: return false; } }, parse: function (m, context) { var formatString, c = context || new Date(); formatString = normalizer.substitutes(m); if (formatString) { return formatString; } formatString = normalizer.interpreted(m, c); if (formatString) { return formatString; } else { return m; } } }; $D.normalizeFormat = function (format, context) { return format.replace(/(%|\\)?.|%%/g, function(t){ return normalizer.parse(t, context); }); }; /** * Format a local Unix timestamp according to locale settings * * Example: * Date.strftime("%m/%d/%y", new Date()); // "04/13/08" * Date.strftime("c", "2008-04-13T17:52:03Z"); // "04/13/08" * * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @param {Number|String} The number representing the number of seconds that have elapsed since January 1, 1970 (local time). * @return {String} A string representation of the current Date object. */ $D.strftime = function (format, time) { var d = Date.parse(time); return d._format(format); }; /** * Parse any textual datetime description into a Unix timestamp. * A Unix timestamp is the number of seconds that have elapsed since January 1, 1970 (midnight UTC/GMT). * * Example: * Date.strtotime("04/13/08"); // 1208044800 * Date.strtotime("1970-01-01T00:00:00Z"); // 0 * * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @param {Object} A string or date object. * @return {String} A string representation of the current Date object. */ $D.strtotime = function (time) { var d = $D.parse(time); return Math.round($D.UTC(d.getUTCFullYear(), d.getUTCMonth(), d.getUTCDate(), d.getUTCHours(), d.getUTCMinutes(), d.getUTCSeconds(), d.getUTCMilliseconds()) / 1000); }; /** * Converts the value of the current Date object to its equivalent string representation using a PHP/Unix style of date format specifiers. * Format Specifiers * Format Description Example * ------ --------------------------------------------------------------------------- ----------------------- * %a abbreviated weekday name according to the current localed "Mon" through "Sun" * %A full weekday name according to the current localed "Sunday" through "Saturday" * %b abbreviated month name according to the current localed "Jan" through "Dec" * %B full month name according to the current locale "January" through "December" * %c preferred date and time representation for the current locale "4/13/2008 12:33 PM" * %C century number (the year divided by 100 and truncated to an integer) "00" to "99" * %d day of the month as a decimal number "01" to "31" * %D same as %m/%d/%y "04/13/08" * %e day of the month as a decimal number, a single digit is preceded by a space "1" to "31" * %g like %G, but without the century "08" * %G The 4-digit year corresponding to the ISO week number (see %V). "2008" * This has the same format and value as %Y, except that if the ISO week number * belongs to the previous or next year, that year is used instead. * %h same as %b "Jan" through "Dec" * %H hour as a decimal number using a 24-hour clock. "00" to "23" * %I hour as a decimal number using a 12-hour clock. "01" to "12" * %j day of the year as a decimal number. "001" to "366" * %m month as a decimal number. "01" to "12" * %M minute as a decimal number. "00" to "59" * %n newline character "\n" * %p either "am" or "pm" according to the given time value, or the "am" or "pm" * corresponding strings for the current locale. * %r time in a.m. and p.m. notation "8:44 PM" * %R time in 24 hour notation "20:44" * %S second as a decimal number "00" to "59" * %t tab character "\t" * %T current time, equal to %H:%M:%S "12:49:11" * %u weekday as a decimal number ["1", "7"], with "1" representing Monday "1" to "7" * %U week number of the current year as a decimal number, starting with the "0" to ("52" or "53") * first Sunday as the first day of the first week * %V The ISO 8601:1988 week number of the current year as a decimal number, "00" to ("52" or "53") * range 01 to 53, where week 1 is the first week that has at least 4 days * in the current year, and with Monday as the first day of the week. * (Use %G or %g for the year component that corresponds to the week number * for the specified timestamp.) * %W week number of the current year as a decimal number, starting with the "00" to ("52" or "53") * first Monday as the first day of the first week * %w day of the week as a decimal, Sunday being "0" "0" to "6" * %x preferred date representation for the current locale without the time "4/13/2008" * %X preferred time representation for the current locale without the date "12:53:05" * %y year as a decimal number without a century "00" "99" * %Y year as a decimal number including the century "2008" * %Z time zone or name or abbreviation "UTC", "EST", "PST" * %z same as %Z * %% a literal "%" characters "%" * d Day of the month, 2 digits with leading zeros "01" to "31" * D A textual representation of a day, three letters "Mon" through "Sun" * j Day of the month without leading zeros "1" to "31" * l A full textual representation of the day of the week (lowercase "L") "Sunday" through "Saturday" * N ISO-8601 numeric representation of the day of the week (added in PHP 5.1.0) "1" (for Monday) through "7" (for Sunday) * S English ordinal suffix for the day of the month, 2 characters "st", "nd", "rd" or "th". Works well with j * w Numeric representation of the day of the week "0" (for Sunday) through "6" (for Saturday) * z The day of the year (starting from "0") "0" through "365" * W ISO-8601 week number of year, weeks starting on Monday "00" to ("52" or "53") * F A full textual representation of a month, such as January or March "January" through "December" * m Numeric representation of a month, with leading zeros "01" through "12" * M A short textual representation of a month, three letters "Jan" through "Dec" * n Numeric representation of a month, without leading zeros "1" through "12" * t Number of days in the given month "28" through "31" * L Whether it's a leap year "1" if it is a leap year, "0" otherwise * o ISO-8601 year number. This has the same value as Y, except that if the "2008" * ISO week number (W) belongs to the previous or next year, that year * is used instead. * Y A full numeric representation of a year, 4 digits "2008" * y A two digit representation of a year "08" * a Lowercase Ante meridiem and Post meridiem "am" or "pm" * A Uppercase Ante meridiem and Post meridiem "AM" or "PM" * B Swatch Internet time "000" through "999" * g 12-hour format of an hour without leading zeros "1" through "12" * G 24-hour format of an hour without leading zeros "0" through "23" * h 12-hour format of an hour with leading zeros "01" through "12" * H 24-hour format of an hour with leading zeros "00" through "23" * i Minutes with leading zeros "00" to "59" * s Seconds, with leading zeros "00" through "59" * u Milliseconds "54321" * e Timezone identifier "UTC", "EST", "PST" * I Whether or not the date is in daylight saving time (uppercase i) "1" if Daylight Saving Time, "0" otherwise * O Difference to Greenwich time (GMT) in hours "+0200", "-0600" * P Difference to Greenwich time (GMT) with colon between hours and minutes "+02:00", "-06:00" * T Timezone abbreviation "UTC", "EST", "PST" * Z Timezone offset in seconds. The offset for timezones west of UTC is "-43200" through "50400" * always negative, and for those east of UTC is always positive. * c ISO 8601 date "2004-02-12T15:19:21+00:00" * r RFC 2822 formatted date "Thu, 21 Dec 2000 16:01:07 +0200" * U Seconds since the Unix Epoch (January 1 1970 00:00:00 GMT) "0" * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @return {String} A string representation of the current Date object. */ var formatReplace = function (context) { return function (m) { var formatString, override = false; if (m.charAt(0) === "\\" || m.substring(0, 2) === "%%") { return m.replace("\\", "").replace("%%", "%"); } override = normalizer.shouldOverrideDefaults(m); formatString = $D.normalizeFormat(m, context); if (formatString) { return context.toString(formatString, override); } }; }; $P._format = function (format) { var formatter = formatReplace(this); if (!format) { return this._toString(); } else { return format.replace(/(%|\\)?.|%%/g, formatter); } }; if (!$P.format) { $P.format = $P._format; } }()); (function () { "use strict"; var gFn = function (attr) { return function () { return this[attr]; }; }; var sFn = function (attr) { return function (val) { this[attr] = val; return this; }; }; var attrs = ["years", "months", "days", "hours", "minutes", "seconds", "milliseconds"]; var addSetFuncs = function (context, attrs) { for (var i = 0; i < attrs.length ; i++) { var $a = attrs[i], $b = $a.slice(0, 1).toUpperCase() + $a.slice(1); context.prototype[$a] = 0; context.prototype["get" + $b] = gFn($a); context.prototype["set" + $b] = sFn($a); } }; /** * new TimeSpan(milliseconds); * new TimeSpan(days, hours, minutes, seconds); * new TimeSpan(days, hours, minutes, seconds, milliseconds); */ var TimeSpan = function (days, hours, minutes, seconds, milliseconds) { if (arguments.length === 1 && typeof days === "number") { var orient = (days < 0) ? -1 : +1; var millsLeft = Math.abs(days); this.setDays(Math.floor(millsLeft / 86400000) * orient); millsLeft = millsLeft % 86400000; this.setHours(Math.floor(millsLeft / 3600000) * orient); millsLeft = millsLeft % 3600000; this.setMinutes(Math.floor(millsLeft / 60000) * orient); millsLeft = millsLeft % 60000; this.setSeconds(Math.floor(millsLeft / 1000) * orient); millsLeft = millsLeft % 1000; this.setMilliseconds(millsLeft * orient); } else { this.set(days, hours, minutes, seconds, milliseconds); } this.getTotalMilliseconds = function () { return (this.getDays() * 86400000) + (this.getHours() * 3600000) + (this.getMinutes() * 60000) + (this.getSeconds() * 1000); }; this.compareTo = function (time) { var t1 = new Date(1970, 1, 1, this.getHours(), this.getMinutes(), this.getSeconds()), t2; if (time === null) { t2 = new Date(1970, 1, 1, 0, 0, 0); } else { t2 = new Date(1970, 1, 1, time.getHours(), time.getMinutes(), time.getSeconds()); } return (t1 < t2) ? -1 : (t1 > t2) ? 1 : 0; }; this.equals = function (time) { return (this.compareTo(time) === 0); }; this.add = function (time) { return (time === null) ? this : this.addSeconds(time.getTotalMilliseconds() / 1000); }; this.subtract = function (time) { return (time === null) ? this : this.addSeconds(-time.getTotalMilliseconds() / 1000); }; this.addDays = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 86400000)); }; this.addHours = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 3600000)); }; this.addMinutes = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 60000)); }; this.addSeconds = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 1000)); }; this.addMilliseconds = function (n) { return new TimeSpan(this.getTotalMilliseconds() + n); }; this.get12HourHour = function () { return (this.getHours() > 12) ? this.getHours() - 12 : (this.getHours() === 0) ? 12 : this.getHours(); }; this.getDesignator = function () { return (this.getHours() < 12) ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator; }; this.toString = function (format) { this._toString = function () { if (this.getDays() !== null && this.getDays() > 0) { return this.getDays() + "." + this.getHours() + ":" + this.p(this.getMinutes()) + ":" + this.p(this.getSeconds()); } else { return this.getHours() + ":" + this.p(this.getMinutes()) + ":" + this.p(this.getSeconds()); } }; this.p = function (s) { return (s.toString().length < 2) ? "0" + s : s; }; var me = this; return format ? format.replace(/dd?|HH?|hh?|mm?|ss?|tt?/g, function (format) { switch (format) { case "d": return me.getDays(); case "dd": return me.p(me.getDays()); case "H": return me.getHours(); case "HH": return me.p(me.getHours()); case "h": return me.get12HourHour(); case "hh": return me.p(me.get12HourHour()); case "m": return me.getMinutes(); case "mm": return me.p(me.getMinutes()); case "s": return me.getSeconds(); case "ss": return me.p(me.getSeconds()); case "t": return ((me.getHours() < 12) ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator).substring(0, 1); case "tt": return (me.getHours() < 12) ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator; } } ) : this._toString(); }; return this; }; addSetFuncs(TimeSpan, attrs.slice(2)); TimeSpan.prototype.set = function (days, hours, minutes, seconds, milliseconds){ this.setDays(days || this.getDays()); this.setHours(hours || this.getHours()); this.setMinutes(minutes || this.getMinutes()); this.setSeconds(seconds || this.getSeconds()); this.setMilliseconds(milliseconds || this.getMilliseconds()); }; /** * Gets the time of day for this date instances. * @return {TimeSpan} TimeSpan */ Date.prototype.getTimeOfDay = function () { return new TimeSpan(0, this.getHours(), this.getMinutes(), this.getSeconds(), this.getMilliseconds()); }; Date.TimeSpan = TimeSpan; if (typeof window !== "undefined" ) { // keeping API compatible for v1.x window.TimeSpan = TimeSpan; } }()); (function () { "use strict"; var attrs = ["years", "months", "days", "hours", "minutes", "seconds", "milliseconds"]; var gFn = function (attr) { return function () { return this[attr]; }; }; var sFn = function (attr) { return function (val) { this[attr] = val; return this; }; }; var addSetFuncs = function (context, attrs) { for (var i = 0; i < attrs.length ; i++) { var $a = attrs[i], $b = $a.slice(0, 1).toUpperCase() + $a.slice(1); context.prototype[$a] = 0; context.prototype["get" + $b] = gFn($a); context.prototype["set" + $b] = sFn($a); } }; var setMonthsAndYears = function (orient, d1, d2, context) { function inc() { d1.addMonths(-orient); context.months++; if (context.months === 12) { context.years++; context.months = 0; } } if (orient === +1) { while (d1 > d2) { inc(); } } else { while (d1 < d2) { inc(); } } context.months--; context.months *= orient; context.years *= orient; }; var adjustForDST = function(orient, startDate, endDate) { var hasDSTMismatch = (false === (startDate.isDaylightSavingTime() === endDate.isDaylightSavingTime())); if (hasDSTMismatch && orient === 1) { startDate.addHours(-1); } else if (hasDSTMismatch) { startDate.addHours(1); } }; /** * TimePeriod(startDate, endDate); * TimePeriod(years, months, days, hours, minutes, seconds, milliseconds); */ var TimePeriod = function (years, months, days, hours, minutes, seconds, milliseconds) { if (arguments.length === 7) { this.set(years, months, days, hours, minutes, seconds, milliseconds); } else if (arguments.length === 2 && arguments[0] instanceof Date && arguments[1] instanceof Date) { var startDate = arguments[0].clone(); var endDate = arguments[1].clone(); var orient = (startDate > endDate) ? +1 : -1; this.dates = { start: arguments[0].clone(), end: arguments[1].clone() }; setMonthsAndYears(orient, startDate, endDate, this); adjustForDST(orient, startDate, endDate); // // TODO - adjust for DST var diff = endDate - startDate; if (diff !== 0) { var ts = new TimeSpan(diff); this.set(this.years, this.months, ts.getDays(), ts.getHours(), ts.getMinutes(), ts.getSeconds(), ts.getMilliseconds()); } } return this; }; // create all the set functions. addSetFuncs(TimePeriod, attrs); TimePeriod.prototype.set = function (years, months, days, hours, minutes, seconds, milliseconds){ this.setYears(years || this.getYears()); this.setMonths(months || this.getMonths()); this.setDays(days || this.getDays()); this.setHours(hours || this.getHours()); this.setMinutes(minutes || this.getMinutes()); this.setSeconds(seconds || this.getSeconds()); this.setMilliseconds(milliseconds || this.getMilliseconds()); }; Date.TimePeriod = TimePeriod; if (typeof window !== "undefined") { // keeping API compatible for v1.x window.TimePeriod = TimePeriod; } }()); ================================================ FILE: build/date-ar-BH.js ================================================ /** * @overview datejs * @version 1.0.0-rc3 * @author Gregory Wild-Smith * @copyright 2015 Gregory Wild-Smith * @license MIT * @homepage https://github.com/abritinthebay/datejs */ /* * DateJS Culture String File * Country Code: ar-BH * Name: Arabic (Bahrain) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["ar-BH"] = { "name": "ar-BH", "englishName": "Arabic (Bahrain)", "nativeName": "العربية (البحرين)", "Sunday": "الاحد", "Monday": "الاثنين", "Tuesday": "الثلاثاء", "Wednesday": "الاربعاء", "Thursday": "الخميس", "Friday": "الجمعة", "Saturday": "السبت", "Sun": "الاحد", "Mon": "الاثنين", "Tue": "الثلاثاء", "Wed": "الاربعاء", "Thu": "الخميس", "Fri": "الجمعة", "Sat": "السبت", "Su": "أ", "Mo": "ا", "Tu": "ث", "We": "أ", "Th": "خ", "Fr": "ج", "Sa": "س", "S_Sun_Initial": "أ", "M_Mon_Initial": "ا", "T_Tue_Initial": "ث", "W_Wed_Initial": "أ", "T_Thu_Initial": "خ", "F_Fri_Initial": "ج", "S_Sat_Initial": "س", "January": "يناير", "February": "فبراير", "March": "مارس", "April": "ابريل", "May": "مايو", "June": "يونيو", "July": "يوليو", "August": "اغسطس", "September": "سبتمبر", "October": "اكتوبر", "November": "نوفمبر", "December": "ديسمبر", "Jan_Abbr": "يناير", "Feb_Abbr": "فبراير", "Mar_Abbr": "مارس", "Apr_Abbr": "ابريل", "May_Abbr": "مايو", "Jun_Abbr": "يونيو", "Jul_Abbr": "يوليو", "Aug_Abbr": "اغسطس", "Sep_Abbr": "سبتمبر", "Oct_Abbr": "اكتوبر", "Nov_Abbr": "نوفمبر", "Dec_Abbr": "ديسمبر", "AM": "ص", "PM": "م", "firstDayOfWeek": 6, "twoDigitYearMax": 2029, "mdy": "dmy", "M/d/yyyy": "dd/MM/yyyy", "dddd, MMMM dd, yyyy": "dd MMMM, yyyy", "h:mm tt": "hh:mm tt", "h:mm:ss tt": "hh:mm:ss tt", "dddd, MMMM dd, yyyy h:mm:ss tt": "dd MMMM, yyyy hh:mm:ss tt", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "dd MMMM", "MMMM, yyyy": "MMMM, yyyy", "/jan(uary)?/": "يناير", "/feb(ruary)?/": "فبراير", "/mar(ch)?/": "مارس", "/apr(il)?/": "ابريل", "/may/": "مايو", "/jun(e)?/": "يونيو", "/jul(y)?/": "يوليو", "/aug(ust)?/": "اغسطس", "/sep(t(ember)?)?/": "سبتمبر", "/oct(ober)?/": "اكتوبر", "/nov(ember)?/": "نوفمبر", "/dec(ember)?/": "ديسمبر", "/^su(n(day)?)?/": "^الاحد", "/^mo(n(day)?)?/": "^ا(1)?", "/^tu(e(s(day)?)?)?/": "^الثلاثاء", "/^we(d(nesday)?)?/": "^الاربعاء", "/^th(u(r(s(day)?)?)?)?/": "^الخميس", "/^fr(i(day)?)?/": "^الجمعة", "/^sa(t(urday)?)?/": "^السبت", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "ar-BH"; /** * @overview datejs * @version 1.0.0-rc3 * @author Gregory Wild-Smith * @copyright 2015 Gregory Wild-Smith * @license MIT * @homepage https://github.com/abritinthebay/datejs */(function () { var $D = Date; var lang = Date.CultureStrings ? Date.CultureStrings.lang : null; var loggedKeys = {}; // for debug purposes. var getText = { getFromKey: function (key, countryCode) { var output; if (Date.CultureStrings && Date.CultureStrings[countryCode] && Date.CultureStrings[countryCode][key]) { output = Date.CultureStrings[countryCode][key]; } else { output = getText.buildFromDefault(key); } if (key.charAt(0) === "/") { // Assume it's a regex output = getText.buildFromRegex(key, countryCode); } return output; }, getFromObjectValues: function (obj, countryCode) { var key, output = {}; for(key in obj) { if (obj.hasOwnProperty(key)) { output[key] = getText.getFromKey(obj[key], countryCode); } } return output; }, getFromObjectKeys: function (obj, countryCode) { var key, output = {}; for(key in obj) { if (obj.hasOwnProperty(key)) { output[getText.getFromKey(key, countryCode)] = obj[key]; } } return output; }, getFromArray: function (arr, countryCode) { var output = []; for (var i=0; i < arr.length; i++){ if (i in arr) { output[i] = getText.getFromKey(arr[i], countryCode); } } return output; }, buildFromDefault: function (key) { var output, length, split, last; switch(key) { case "name": output = "en-US"; break; case "englishName": output = "English (United States)"; break; case "nativeName": output = "English (United States)"; break; case "twoDigitYearMax": output = 2049; break; case "firstDayOfWeek": output = 0; break; default: output = key; split = key.split("_"); length = split.length; if (length > 1 && key.charAt(0) !== "/") { // if the key isn't a regex and it has a split. last = split[(length - 1)].toLowerCase(); if (last === "initial" || last === "abbr") { output = split[0]; } } break; } return output; }, buildFromRegex: function (key, countryCode) { var output; if (Date.CultureStrings && Date.CultureStrings[countryCode] && Date.CultureStrings[countryCode][key]) { output = new RegExp(Date.CultureStrings[countryCode][key], "i"); } else { output = new RegExp(key.replace(new RegExp("/", "g"),""), "i"); } return output; } }; var shallowMerge = function (obj1, obj2) { for (var attrname in obj2) { if (obj2.hasOwnProperty(attrname)) { obj1[attrname] = obj2[attrname]; } } }; var __ = function (key, language) { var countryCode = (language) ? language : lang; loggedKeys[key] = key; if (typeof key === "object") { if (key instanceof Array) { return getText.getFromArray(key, countryCode); } else { return getText.getFromObjectKeys(key, countryCode); } } else { return getText.getFromKey(key, countryCode); } }; var loadI18nScript = function (code) { // paatterned after jQuery's getScript. var url = Date.Config.i18n + code + ".js"; var head = document.getElementsByTagName("head")[0] || document.documentElement; var script = document.createElement("script"); script.src = url; var completed = false; var events = { done: function (){} // placeholder function }; // Attach handlers for all browsers script.onload = script.onreadystatechange = function() { if ( !completed && (!this.readyState || this.readyState === "loaded" || this.readyState === "complete") ) { events.done(); head.removeChild(script); } }; setTimeout(function() { head.insertBefore(script, head.firstChild); }, 0); // allows return to execute first return { done: function (cb) { events.done = function() { if (cb) { setTimeout(cb,0); } }; } }; }; var buildInfo = { buildFromMethodHash: function (obj) { var key; for(key in obj) { if (obj.hasOwnProperty(key)) { obj[key] = buildInfo[obj[key]](); } } return obj; }, timeZoneDST: function () { var DST = { "CHADT": "+1345", "NZDT": "+1300", "AEDT": "+1100", "ACDT": "+1030", "AZST": "+0500", "IRDT": "+0430", "EEST": "+0300", "CEST": "+0200", "BST": "+0100", "PMDT": "-0200", "ADT": "-0300", "NDT": "-0230", "EDT": "-0400", "CDT": "-0500", "MDT": "-0600", "PDT": "-0700", "AKDT": "-0800", "HADT": "-0900" }; return __(DST); }, timeZoneStandard: function () { var standard = { "LINT": "+1400", "TOT": "+1300", "CHAST": "+1245", "NZST": "+1200", "NFT": "+1130", "SBT": "+1100", "AEST": "+1000", "ACST": "+0930", "JST": "+0900", "CWST": "+0845", "CT": "+0800", "ICT": "+0700", "MMT": "+0630", "BST": "+0600", "NPT": "+0545", "IST": "+0530", "PKT": "+0500", "AFT": "+0430", "MSK": "+0400", "IRST": "+0330", "FET": "+0300", "EET": "+0200", "CET": "+0100", "GMT": "+0000", "UTC": "+0000", "CVT": "-0100", "GST": "-0200", "BRT": "-0300", "NST": "-0330", "AST": "-0400", "EST": "-0500", "CST": "-0600", "MST": "-0700", "PST": "-0800", "AKST": "-0900", "MIT": "-0930", "HST": "-1000", "SST": "-1100", "BIT": "-1200" }; return __(standard); }, timeZones: function (data) { var zone; data.timezones = []; for (zone in data.abbreviatedTimeZoneStandard) { if (data.abbreviatedTimeZoneStandard.hasOwnProperty(zone)) { data.timezones.push({ name: zone, offset: data.abbreviatedTimeZoneStandard[zone]}); } } for (zone in data.abbreviatedTimeZoneDST) { if (data.abbreviatedTimeZoneDST.hasOwnProperty(zone)) { data.timezones.push({ name: zone, offset: data.abbreviatedTimeZoneDST[zone], dst: true}); } } return data.timezones; }, days: function () { return __(["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"]); }, dayAbbr: function () { return __(["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"]); }, dayShortNames: function () { return __(["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"]); }, dayFirstLetters: function () { return __(["S_Sun_Initial", "M_Mon_Initial", "T_Tues_Initial", "W_Wed_Initial", "T_Thu_Initial", "F_Fri_Initial", "S_Sat_Initial"]); }, months: function () { return __(["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"]); }, monthAbbr: function () { return __(["Jan_Abbr", "Feb_Abbr", "Mar_Abbr", "Apr_Abbr", "May_Abbr", "Jun_Abbr", "Jul_Abbr", "Aug_Abbr", "Sep_Abbr", "Oct_Abbr", "Nov_Abbr", "Dec_Abbr"]); }, formatPatterns: function () { return getText.getFromObjectValues({ shortDate: "M/d/yyyy", longDate: "dddd, MMMM dd, yyyy", shortTime: "h:mm tt", longTime: "h:mm:ss tt", fullDateTime: "dddd, MMMM dd, yyyy h:mm:ss tt", sortableDateTime: "yyyy-MM-ddTHH:mm:ss", universalSortableDateTime: "yyyy-MM-dd HH:mm:ssZ", rfc1123: "ddd, dd MMM yyyy HH:mm:ss", monthDay: "MMMM dd", yearMonth: "MMMM, yyyy" }, Date.i18n.currentLanguage()); }, regex: function () { return getText.getFromObjectValues({ inTheMorning: "/( in the )(morn(ing)?)\\b/", thisMorning: "/(this )(morn(ing)?)\\b/", amThisMorning: "/(\b\\d(am)? )(this )(morn(ing)?)/", inTheEvening: "/( in the )(even(ing)?)\\b/", thisEvening: "/(this )(even(ing)?)\\b/", pmThisEvening: "/(\b\\d(pm)? )(this )(even(ing)?)/", jan: "/jan(uary)?/", feb: "/feb(ruary)?/", mar: "/mar(ch)?/", apr: "/apr(il)?/", may: "/may/", jun: "/jun(e)?/", jul: "/jul(y)?/", aug: "/aug(ust)?/", sep: "/sep(t(ember)?)?/", oct: "/oct(ober)?/", nov: "/nov(ember)?/", dec: "/dec(ember)?/", sun: "/^su(n(day)?)?/", mon: "/^mo(n(day)?)?/", tue: "/^tu(e(s(day)?)?)?/", wed: "/^we(d(nesday)?)?/", thu: "/^th(u(r(s(day)?)?)?)?/", fri: "/fr(i(day)?)?/", sat: "/^sa(t(urday)?)?/", future: "/^next/", past: "/^last|past|prev(ious)?/", add: "/^(\\+|aft(er)?|from|hence)/", subtract: "/^(\\-|bef(ore)?|ago)/", yesterday: "/^yes(terday)?/", today: "/^t(od(ay)?)?/", tomorrow: "/^tom(orrow)?/", now: "/^n(ow)?/", millisecond: "/^ms|milli(second)?s?/", second: "/^sec(ond)?s?/", minute: "/^mn|min(ute)?s?/", hour: "/^h(our)?s?/", week: "/^w(eek)?s?/", month: "/^m(onth)?s?/", day: "/^d(ay)?s?/", year: "/^y(ear)?s?/", shortMeridian: "/^(a|p)/", longMeridian: "/^(a\\.?m?\\.?|p\\.?m?\\.?)/", timezone: "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/", ordinalSuffix: "/^\\s*(st|nd|rd|th)/", timeContext: "/^\\s*(\\:|a(?!u|p)|p)/" }, Date.i18n.currentLanguage()); } }; var CultureInfo = function () { var info = getText.getFromObjectValues({ name: "name", englishName: "englishName", nativeName: "nativeName", amDesignator: "AM", pmDesignator: "PM", firstDayOfWeek: "firstDayOfWeek", twoDigitYearMax: "twoDigitYearMax", dateElementOrder: "mdy" }, Date.i18n.currentLanguage()); var constructedInfo = buildInfo.buildFromMethodHash({ dayNames: "days", abbreviatedDayNames: "dayAbbr", shortestDayNames: "dayShortNames", firstLetterDayNames: "dayFirstLetters", monthNames: "months", abbreviatedMonthNames: "monthAbbr", formatPatterns: "formatPatterns", regexPatterns: "regex", abbreviatedTimeZoneDST: "timeZoneDST", abbreviatedTimeZoneStandard: "timeZoneStandard" }); shallowMerge(info, constructedInfo); buildInfo.timeZones(info); return info; }; $D.i18n = { __: function (key, lang) { return __(key, lang); }, currentLanguage: function () { return lang || "en-US"; }, setLanguage: function (code, force, cb) { var async = false; if (force || code === "en-US" || (!!Date.CultureStrings && !!Date.CultureStrings[code])) { lang = code; Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings.lang = code; Date.CultureInfo = new CultureInfo(); } else { if (!(!!Date.CultureStrings && !!Date.CultureStrings[code])) { if (typeof exports !== "undefined" && this.exports !== exports) { // we're in a Node enviroment, load it using require try { require("../i18n/" + code + ".js"); lang = code; Date.CultureStrings.lang = code; Date.CultureInfo = new CultureInfo(); } catch (e) { // var str = "The language for '" + code + "' could not be loaded by Node. It likely does not exist."; throw new Error("The DateJS IETF language tag '" + code + "' could not be loaded by Node. It likely does not exist."); } } else if (Date.Config && Date.Config.i18n) { // we know the location of the files, so lets load them async = true; loadI18nScript(code).done(function(){ lang = code; Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings.lang = code; Date.CultureInfo = new CultureInfo(); $D.Parsing.Normalizer.buildReplaceData(); // because this is async if ($D.Grammar) { $D.Grammar.buildGrammarFormats(); // so we can parse those strings... } if (cb) { setTimeout(cb,0); } }); } else { Date.console.error("The DateJS IETF language tag '" + code + "' is not available and has not been loaded."); return false; } } } $D.Parsing.Normalizer.buildReplaceData(); // rebuild normalizer strings if ($D.Grammar) { $D.Grammar.buildGrammarFormats(); // so we can parse those strings... } if (!async && cb) { setTimeout(cb,0); } }, getLoggedKeys: function () { return loggedKeys; }, updateCultureInfo: function () { Date.CultureInfo = new CultureInfo(); } }; $D.i18n.updateCultureInfo(); // run automatically }()); (function () { var $D = Date, $P = $D.prototype, p = function (s, l) { if (!l) { l = 2; } return ("000" + s).slice(l * -1); }; if (typeof window !== "undefined" && typeof window.console !== "undefined" && typeof window.console.log !== "undefined") { $D.console = console; // used only to raise non-critical errors if available } else { // set mock so we don't give errors. $D.console = { log: function(){}, error: function(){} }; } $D.Config = $D.Config || {}; $D.initOverloads = function() { /** * Overload of Date.now. Allows an alternate call for Date.now where it returns the * current Date as an object rather than just milliseconds since the Unix Epoch. * * Also provides an implementation of now() for browsers (IE<9) that don't have it. * * Backwards compatible so with work with either: * Date.now() [returns ms] * or * Date.now(true) [returns Date] */ if (!$D.now) { $D._now = function now() { return new Date().getTime(); }; } else if (!$D._now) { $D._now = $D.now; } $D.now = function (returnObj) { if (returnObj) { return $D.present(); } else { return $D._now(); } }; if ( !$P.toISOString ) { $P.toISOString = function() { return this.getUTCFullYear() + "-" + p(this.getUTCMonth() + 1) + "-" + p(this.getUTCDate()) + "T" + p(this.getUTCHours()) + ":" + p(this.getUTCMinutes()) + ":" + p(this.getUTCSeconds()) + "." + String( (this.getUTCMilliseconds()/1000).toFixed(3)).slice(2, 5) + "Z"; }; } // private if ( $P._toString === undefined ){ $P._toString = $P.toString; } }; $D.initOverloads(); /** * Gets a date that is set to the current date. The time is set to the start of the day (00:00 or 12:00 AM). * @return {Date} The current date. */ $D.today = function () { return new Date().clearTime(); }; /** * Gets a date that is set to the current date and time (same as new Date, but chainable) * @return {Date} The current date. */ $D.present = function () { return new Date(); }; /** * Compares the first date to the second date and returns an number indication of their relative values. * @param {Date} First Date object to compare [Required]. * @param {Date} Second Date object to compare to [Required]. * @return {Number} -1 = date1 is lessthan date2. 0 = values are equal. 1 = date1 is greaterthan date2. */ $D.compare = function (date1, date2) { if (isNaN(date1) || isNaN(date2)) { throw new Error(date1 + " - " + date2); } else if (date1 instanceof Date && date2 instanceof Date) { return (date1 < date2) ? -1 : (date1 > date2) ? 1 : 0; } else { throw new TypeError(date1 + " - " + date2); } }; /** * Compares the first Date object to the second Date object and returns true if they are equal. * @param {Date} First Date object to compare [Required] * @param {Date} Second Date object to compare to [Required] * @return {Boolean} true if dates are equal. false if they are not equal. */ $D.equals = function (date1, date2) { return (date1.compareTo(date2) === 0); }; /** * Gets the language appropriate day name when given the day number(0-6) * eg - 0 == Sunday * @return {String} The day name */ $D.getDayName = function (n) { return Date.CultureInfo.dayNames[n]; }; /** * Gets the day number (0-6) if given a CultureInfo specific string which is a valid dayName, abbreviatedDayName or shortestDayName (two char). * @param {String} The name of the day (eg. "Monday, "Mon", "tuesday", "tue", "We", "we"). * @return {Number} The day number */ $D.getDayNumberFromName = function (name) { var n = Date.CultureInfo.dayNames, m = Date.CultureInfo.abbreviatedDayNames, o = Date.CultureInfo.shortestDayNames, s = name.toLowerCase(); for (var i = 0; i < n.length; i++) { if (n[i].toLowerCase() === s || m[i].toLowerCase() === s || o[i].toLowerCase() === s) { return i; } } return -1; }; /** * Gets the month number (0-11) if given a Culture Info specific string which is a valid monthName or abbreviatedMonthName. * @param {String} The name of the month (eg. "February, "Feb", "october", "oct"). * @return {Number} The day number */ $D.getMonthNumberFromName = function (name) { var n = Date.CultureInfo.monthNames, m = Date.CultureInfo.abbreviatedMonthNames, s = name.toLowerCase(); for (var i = 0; i < n.length; i++) { if (n[i].toLowerCase() === s || m[i].toLowerCase() === s) { return i; } } return -1; }; /** * Gets the language appropriate month name when given the month number(0-11) * eg - 0 == January * @return {String} The month name */ $D.getMonthName = function (n) { return Date.CultureInfo.monthNames[n]; }; /** * Determines if the current date instance is within a LeapYear. * @param {Number} The year. * @return {Boolean} true if date is within a LeapYear, otherwise false. */ $D.isLeapYear = function (year) { return ((year % 4 === 0 && year % 100 !== 0) || year % 400 === 0); }; /** * Gets the number of days in the month, given a year and month value. Automatically corrects for LeapYear. * @param {Number} The year. * @param {Number} The month (0-11). * @return {Number} The number of days in the month. */ $D.getDaysInMonth = function (year, month) { if (!month && $D.validateMonth(year)) { month = year; year = Date.today().getFullYear(); } return [31, ($D.isLeapYear(year) ? 29 : 28), 31, 30, 31, 30, 31, 31, 30, 31, 30, 31][month]; }; $P.getDaysInMonth = function () { return $D.getDaysInMonth(this.getFullYear(), this.getMonth()); }; $D.getTimezoneAbbreviation = function (offset, dst) { var p, n = (dst || false) ? Date.CultureInfo.abbreviatedTimeZoneDST : Date.CultureInfo.abbreviatedTimeZoneStandard; for (p in n) { if (n.hasOwnProperty(p)) { if (n[p] === offset) { return p; } } } return null; }; $D.getTimezoneOffset = function (name, dst) { var i, a =[], z = Date.CultureInfo.timezones; if (!name) { name = (new Date()).getTimezone();} for (i = 0; i < z.length; i++) { if (z[i].name === name.toUpperCase()) { a.push(i); } } if (!z[a[0]]) { return null; } if (a.length === 1 || !dst) { return z[a[0]].offset; } else { for (i=0; i < a.length; i++) { if (z[a[i]].dst) { return z[a[i]].offset; } } } }; $D.getQuarter = function (d) { d = d || new Date(); // If no date supplied, use today var q = [1,2,3,4]; return q[Math.floor(d.getMonth() / 3)]; // ~~~ is a bitwise op. Faster than Math.floor }; $D.getDaysLeftInQuarter = function (d) { d = d || new Date(); var qEnd = new Date(d); qEnd.setMonth(qEnd.getMonth() + 3 - qEnd.getMonth() % 3, 0); return Math.floor((qEnd - d) / 8.64e7); }; // private var validate = function (n, min, max, name) { name = name ? name : "Object"; if (typeof n === "undefined") { return false; } else if (typeof n !== "number") { throw new TypeError(n + " is not a Number."); } else if (n < min || n > max) { // As failing validation is *not* an exceptional circumstance // lets not throw a RangeError Exception here. // It's semantically correct but it's not sensible. return false; } return true; }; /** * Validates the number is within an acceptable range for milliseconds [0-999]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateMillisecond = function (value) { return validate(value, 0, 999, "millisecond"); }; /** * Validates the number is within an acceptable range for seconds [0-59]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateSecond = function (value) { return validate(value, 0, 59, "second"); }; /** * Validates the number is within an acceptable range for minutes [0-59]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateMinute = function (value) { return validate(value, 0, 59, "minute"); }; /** * Validates the number is within an acceptable range for hours [0-23]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateHour = function (value) { return validate(value, 0, 23, "hour"); }; /** * Validates the number is within an acceptable range for the days in a month [0-MaxDaysInMonth]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateDay = function (value, year, month) { if (year === undefined || year === null || month === undefined || month === null) { return false;} return validate(value, 1, $D.getDaysInMonth(year, month), "day"); }; /** * Validates the number is within an acceptable range for months [0-11]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateWeek = function (value) { return validate(value, 0, 53, "week"); }; /** * Validates the number is within an acceptable range for months [0-11]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateMonth = function (value) { return validate(value, 0, 11, "month"); }; /** * Validates the number is within an acceptable range for years. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateYear = function (value) { /** * Per ECMAScript spec the range of times supported by Date objects is * exactly -100,000,000 days to +100,000,000 days measured relative to * midnight at the beginning of 01 January, 1970 UTC. * This gives a range of 8,640,000,000,000,000 milliseconds to either * side of 01 January, 1970 UTC. * * Earliest possible date: Tue, 20 Apr 271,822 B.C. 00:00:00 UTC * Latest possible date: Sat, 13 Sep 275,760 00:00:00 UTC */ return validate(value, -271822, 275760, "year"); }; $D.validateTimezone = function(value) { var timezones = {"ACDT":1,"ACST":1,"ACT":1,"ADT":1,"AEDT":1,"AEST":1,"AFT":1,"AKDT":1,"AKST":1,"AMST":1,"AMT":1,"ART":1,"AST":1,"AWDT":1,"AWST":1,"AZOST":1,"AZT":1,"BDT":1,"BIOT":1,"BIT":1,"BOT":1,"BRT":1,"BST":1,"BTT":1,"CAT":1,"CCT":1,"CDT":1,"CEDT":1,"CEST":1,"CET":1,"CHADT":1,"CHAST":1,"CHOT":1,"ChST":1,"CHUT":1,"CIST":1,"CIT":1,"CKT":1,"CLST":1,"CLT":1,"COST":1,"COT":1,"CST":1,"CT":1,"CVT":1,"CWST":1,"CXT":1,"DAVT":1,"DDUT":1,"DFT":1,"EASST":1,"EAST":1,"EAT":1,"ECT":1,"EDT":1,"EEDT":1,"EEST":1,"EET":1,"EGST":1,"EGT":1,"EIT":1,"EST":1,"FET":1,"FJT":1,"FKST":1,"FKT":1,"FNT":1,"GALT":1,"GAMT":1,"GET":1,"GFT":1,"GILT":1,"GIT":1,"GMT":1,"GST":1,"GYT":1,"HADT":1,"HAEC":1,"HAST":1,"HKT":1,"HMT":1,"HOVT":1,"HST":1,"ICT":1,"IDT":1,"IOT":1,"IRDT":1,"IRKT":1,"IRST":1,"IST":1,"JST":1,"KGT":1,"KOST":1,"KRAT":1,"KST":1,"LHST":1,"LINT":1,"MAGT":1,"MART":1,"MAWT":1,"MDT":1,"MET":1,"MEST":1,"MHT":1,"MIST":1,"MIT":1,"MMT":1,"MSK":1,"MST":1,"MUT":1,"MVT":1,"MYT":1,"NCT":1,"NDT":1,"NFT":1,"NPT":1,"NST":1,"NT":1,"NUT":1,"NZDT":1,"NZST":1,"OMST":1,"ORAT":1,"PDT":1,"PET":1,"PETT":1,"PGT":1,"PHOT":1,"PHT":1,"PKT":1,"PMDT":1,"PMST":1,"PONT":1,"PST":1,"PYST":1,"PYT":1,"RET":1,"ROTT":1,"SAKT":1,"SAMT":1,"SAST":1,"SBT":1,"SCT":1,"SGT":1,"SLST":1,"SRT":1,"SST":1,"SYOT":1,"TAHT":1,"THA":1,"TFT":1,"TJT":1,"TKT":1,"TLT":1,"TMT":1,"TOT":1,"TVT":1,"UCT":1,"ULAT":1,"UTC":1,"UYST":1,"UYT":1,"UZT":1,"VET":1,"VLAT":1,"VOLT":1,"VOST":1,"VUT":1,"WAKT":1,"WAST":1,"WAT":1,"WEDT":1,"WEST":1,"WET":1,"WST":1,"YAKT":1,"YEKT":1,"Z":1}; return (timezones[value] === 1); }; $D.validateTimezoneOffset= function(value) { // timezones go from +14hrs to -12hrs, the +X hours are negative offsets. return (value > -841 && value < 721); }; }()); (function () { var $D = Date, $P = $D.prototype, p = function (s, l) { if (!l) { l = 2; } return ("000" + s).slice(l * -1); }; var validateConfigObject = function (obj) { var result = {}, self = this, prop, testFunc; testFunc = function (prop, func, value) { if (prop === "day") { var month = (obj.month !== undefined) ? obj.month : self.getMonth(); var year = (obj.year !== undefined) ? obj.year : self.getFullYear(); return $D[func](value, year, month); } else { return $D[func](value); } }; for (prop in obj) { if (Object.prototype.hasOwnProperty.call(obj, prop)) { var func = "validate" + prop.charAt(0).toUpperCase() + prop.slice(1); if ($D[func] && obj[prop] !== null && testFunc(prop, func, obj[prop])) { result[prop] = obj[prop]; } } } return result; }; /** * Resets the time of this Date object to 12:00 AM (00:00), which is the start of the day. * @param {Boolean} .clone() this date instance before clearing Time * @return {Date} this */ $P.clearTime = function () { this.setHours(0); this.setMinutes(0); this.setSeconds(0); this.setMilliseconds(0); return this; }; /** * Resets the time of this Date object to the current time ('now'). * @return {Date} this */ $P.setTimeToNow = function () { var n = new Date(); this.setHours(n.getHours()); this.setMinutes(n.getMinutes()); this.setSeconds(n.getSeconds()); this.setMilliseconds(n.getMilliseconds()); return this; }; /** * Returns a new Date object that is an exact date and time copy of the original instance. * @return {Date} A new Date instance */ $P.clone = function () { return new Date(this.getTime()); }; /** * Compares this instance to a Date object and returns an number indication of their relative values. * @param {Date} Date object to compare [Required] * @return {Number} -1 = this is lessthan date. 0 = values are equal. 1 = this is greaterthan date. */ $P.compareTo = function (date) { return Date.compare(this, date); }; /** * Compares this instance to another Date object and returns true if they are equal. * @param {Date} Date object to compare. If no date to compare, new Date() [now] is used. * @return {Boolean} true if dates are equal. false if they are not equal. */ $P.equals = function (date) { return Date.equals(this, (date !== undefined ? date : new Date())); }; /** * Determines if this instance is between a range of two dates or equal to either the start or end dates. * @param {Date} Start of range [Required] * @param {Date} End of range [Required] * @return {Boolean} true is this is between or equal to the start and end dates, else false */ $P.between = function (start, end) { return this.getTime() >= start.getTime() && this.getTime() <= end.getTime(); }; /** * Determines if this date occurs after the date to compare to. * @param {Date} Date object to compare. If no date to compare, new Date() ("now") is used. * @return {Boolean} true if this date instance is greater than the date to compare to (or "now"), otherwise false. */ $P.isAfter = function (date) { return this.compareTo(date || new Date()) === 1; }; /** * Determines if this date occurs before the date to compare to. * @param {Date} Date object to compare. If no date to compare, new Date() ("now") is used. * @return {Boolean} true if this date instance is less than the date to compare to (or "now"). */ $P.isBefore = function (date) { return (this.compareTo(date || new Date()) === -1); }; /** * Determines if the current Date instance occurs today. * @return {Boolean} true if this date instance is 'today', otherwise false. */ /** * Determines if the current Date instance occurs on the same Date as the supplied 'date'. * If no 'date' to compare to is provided, the current Date instance is compared to 'today'. * @param {date} Date object to compare. If no date to compare, the current Date ("now") is used. * @return {Boolean} true if this Date instance occurs on the same Day as the supplied 'date'. */ $P.isToday = $P.isSameDay = function (date) { return this.clone().clearTime().equals((date || new Date()).clone().clearTime()); }; /** * Adds the specified number of milliseconds to this instance. * @param {Number} The number of milliseconds to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addMilliseconds = function (value) { if (!value) { return this; } this.setTime(this.getTime() + value * 1); return this; }; /** * Adds the specified number of seconds to this instance. * @param {Number} The number of seconds to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addSeconds = function (value) { if (!value) { return this; } return this.addMilliseconds(value * 1000); }; /** * Adds the specified number of seconds to this instance. * @param {Number} The number of seconds to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addMinutes = function (value) { if (!value) { return this; } return this.addMilliseconds(value * 60000); // 60*1000 }; /** * Adds the specified number of hours to this instance. * @param {Number} The number of hours to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addHours = function (value) { if (!value) { return this; } return this.addMilliseconds(value * 3600000); // 60*60*1000 }; /** * Adds the specified number of days to this instance. * @param {Number} The number of days to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addDays = function (value) { if (!value) { return this; } this.setDate(this.getDate() + value * 1); return this; }; /** * Adds the specified number of weekdays (ie - not sat or sun) to this instance. * @param {Number} The number of days to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addWeekdays = function (value) { if (!value) { return this; } var day = this.getDay(); var weeks = (Math.ceil(Math.abs(value)/7)); if (day === 0 || day === 6) { if (value > 0) { this.next().monday(); this.addDays(-1); day = this.getDay(); } } if (value < 0) { while (value < 0) { this.addDays(-1); day = this.getDay(); if (day !== 0 && day !== 6) { value++; } } return this; } else if (value > 5 || (6-day) <= value) { value = value + (weeks * 2); } return this.addDays(value); }; /** * Adds the specified number of weeks to this instance. * @param {Number} The number of weeks to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addWeeks = function (value) { if (!value) { return this; } return this.addDays(value * 7); }; /** * Adds the specified number of months to this instance. * @param {Number} The number of months to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addMonths = function (value) { if (!value) { return this; } var n = this.getDate(); this.setDate(1); this.setMonth(this.getMonth() + value * 1); this.setDate(Math.min(n, $D.getDaysInMonth(this.getFullYear(), this.getMonth()))); return this; }; $P.addQuarters = function (value) { if (!value) { return this; } // note this will take you to the same point in the quarter as you are now. // i.e. - if you are 15 days into the quarter you'll be 15 days into the resulting one. // bonus: this allows adding fractional quarters return this.addMonths(value * 3); }; /** * Adds the specified number of years to this instance. * @param {Number} The number of years to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addYears = function (value) { if (!value) { return this; } return this.addMonths(value * 12); }; /** * Adds (or subtracts) to the value of the years, months, weeks, days, hours, minutes, seconds, milliseconds of the date instance using given configuration object. Positive and Negative values allowed. * Example

	Date.today().add( { days: 1, months: 1 } )

	new Date().add( { years: -1 } )
	
* @param {Object} Configuration object containing attributes (months, days, etc.) * @return {Date} this */ $P.add = function (config) { if (typeof config === "number") { this._orient = config; return this; } var x = config; if (x.day) { // If we should be a different date than today (eg: for 'tomorrow -1d', etc). // Should only effect parsing, not direct usage (eg, Finish and FinishExact) if ((x.day - this.getDate()) !== 0) { this.setDate(x.day); } } if (x.milliseconds) { this.addMilliseconds(x.milliseconds); } if (x.seconds) { this.addSeconds(x.seconds); } if (x.minutes) { this.addMinutes(x.minutes); } if (x.hours) { this.addHours(x.hours); } if (x.weeks) { this.addWeeks(x.weeks); } if (x.months) { this.addMonths(x.months); } if (x.years) { this.addYears(x.years); } if (x.days) { this.addDays(x.days); } return this; }; /** * Get the week number. Week one (1) is the week which contains the first Thursday of the year. Monday is considered the first day of the week. * The .getWeek() function does NOT convert the date to UTC. The local datetime is used. * Please use .getISOWeek() to get the week of the UTC converted date. * @return {Number} 1 to 53 */ $P.getWeek = function (utc) { // Create a copy of this date object var self, target = new Date(this.valueOf()); if (utc) { target.addMinutes(target.getTimezoneOffset()); self = target.clone(); } else { self = this; } // ISO week date weeks start on monday // so correct the day number var dayNr = (self.getDay() + 6) % 7; // ISO 8601 states that week 1 is the week // with the first thursday of that year. // Set the target date to the thursday in the target week target.setDate(target.getDate() - dayNr + 3); // Store the millisecond value of the target date var firstThursday = target.valueOf(); // Set the target to the first thursday of the year // First set the target to january first target.setMonth(0, 1); // Not a thursday? Correct the date to the next thursday if (target.getDay() !== 4) { target.setMonth(0, 1 + ((4 - target.getDay()) + 7) % 7); } // The weeknumber is the number of weeks between the // first thursday of the year and the thursday in the target week return 1 + Math.ceil((firstThursday - target) / 604800000); // 604800000 = 7 * 24 * 3600 * 1000 }; /** * Get the ISO 8601 week number. Week one ("01") is the week which contains the first Thursday of the year. Monday is considered the first day of the week. * The .getISOWeek() function does convert the date to it's UTC value. Please use .getWeek() to get the week of the local date. * @return {String} "01" to "53" */ $P.getISOWeek = function () { return p(this.getWeek(true)); }; /** * Moves the date to Monday of the week set. Week one (1) is the week which contains the first Thursday of the year. * @param {Number} A Number (1 to 53) that represents the week of the year. * @return {Date} this */ $P.setWeek = function (n) { if ((n - this.getWeek()) === 0) { if (this.getDay() !== 1) { return this.moveToDayOfWeek(1, (this.getDay() > 1 ? -1 : 1)); } else { return this; } } else { return this.moveToDayOfWeek(1, (this.getDay() > 1 ? -1 : 1)).addWeeks(n - this.getWeek()); } }; $P.setQuarter = function (qtr) { var month = Math.abs(((qtr-1) * 3) + 1); return this.setMonth(month, 1); }; $P.getQuarter = function () { return Date.getQuarter(this); }; $P.getDaysLeftInQuarter = function () { return Date.getDaysLeftInQuarter(this); }; /** * Moves the date to the next n'th occurrence of the dayOfWeek starting from the beginning of the month. The number (-1) is a magic number and will return the last occurrence of the dayOfWeek in the month. * @param {Number} The dayOfWeek to move to * @param {Number} The n'th occurrence to move to. Use (-1) to return the last occurrence in the month * @return {Date} this */ $P.moveToNthOccurrence = function (dayOfWeek, occurrence) { if (dayOfWeek === "Weekday") { if (occurrence > 0) { this.moveToFirstDayOfMonth(); if (this.is().weekday()) { occurrence -= 1; } } else if (occurrence < 0) { this.moveToLastDayOfMonth(); if (this.is().weekday()) { occurrence += 1; } } else { return this; } return this.addWeekdays(occurrence); } var shift = 0; if (occurrence > 0) { shift = occurrence - 1; } else if (occurrence === -1) { this.moveToLastDayOfMonth(); if (this.getDay() !== dayOfWeek) { this.moveToDayOfWeek(dayOfWeek, -1); } return this; } return this.moveToFirstDayOfMonth().addDays(-1).moveToDayOfWeek(dayOfWeek, +1).addWeeks(shift); }; var moveToN = function (getFunc, addFunc, nVal) { return function (value, orient) { var diff = (value - this[getFunc]() + nVal * (orient || +1)) % nVal; return this[addFunc]((diff === 0) ? diff += nVal * (orient || +1) : diff); }; }; /** * Move to the next or last dayOfWeek based on the orient value. * @param {Number} The dayOfWeek to move to * @param {Number} Forward (+1) or Back (-1). Defaults to +1. [Optional] * @return {Date} this */ $P.moveToDayOfWeek = moveToN("getDay", "addDays", 7); /** * Move to the next or last month based on the orient value. * @param {Number} The month to move to. 0 = January, 11 = December * @param {Number} Forward (+1) or Back (-1). Defaults to +1. [Optional] * @return {Date} this */ $P.moveToMonth = moveToN("getMonth", "addMonths", 12); /** * Get the Ordinate of the current day ("th", "st", "rd"). * @return {String} */ $P.getOrdinate = function () { var num = this.getDate(); return ord(num); }; /** * Get the Ordinal day (numeric day number) of the year, adjusted for leap year. * @return {Number} 1 through 365 (366 in leap years) */ $P.getOrdinalNumber = function () { return Math.ceil((this.clone().clearTime() - new Date(this.getFullYear(), 0, 1)) / 86400000) + 1; }; /** * Get the time zone abbreviation of the current date. * @return {String} The abbreviated time zone name (e.g. "EST") */ $P.getTimezone = function () { return $D.getTimezoneAbbreviation(this.getUTCOffset(), this.isDaylightSavingTime()); }; $P.setTimezoneOffset = function (offset) { var here = this.getTimezoneOffset(), there = Number(offset) * -6 / 10; return (there || there === 0) ? this.addMinutes(there - here) : this; }; $P.setTimezone = function (offset) { return this.setTimezoneOffset($D.getTimezoneOffset(offset)); }; /** * Indicates whether Daylight Saving Time is observed in the current time zone. * @return {Boolean} true|false */ $P.hasDaylightSavingTime = function () { return (Date.today().set({month: 0, day: 1}).getTimezoneOffset() !== Date.today().set({month: 6, day: 1}).getTimezoneOffset()); }; /** * Indicates whether this Date instance is within the Daylight Saving Time range for the current time zone. * @return {Boolean} true|false */ $P.isDaylightSavingTime = function () { return Date.today().set({month: 0, day: 1}).getTimezoneOffset() !== this.getTimezoneOffset(); }; /** * Get the offset from UTC of the current date. * @return {String} The 4-character offset string prefixed with + or - (e.g. "-0500") */ $P.getUTCOffset = function (offset) { var n = (offset || this.getTimezoneOffset()) * -10 / 6, r; if (n < 0) { r = (n - 10000).toString(); return r.charAt(0) + r.substr(2); } else { r = (n + 10000).toString(); return "+" + r.substr(1); } }; /** * Returns the number of milliseconds between this date and date. * @param {Date} Defaults to now * @return {Number} The diff in milliseconds */ $P.getElapsed = function (date) { return (date || new Date()) - this; }; /** * Set the value of year, month, day, hour, minute, second, millisecond of date instance using given configuration object. * Example

	Date.today().set( { day: 20, month: 1 } )

	new Date().set( { millisecond: 0 } )
	
* * @param {Object} Configuration object containing attributes (month, day, etc.) * @return {Date} this */ $P.set = function (config) { config = validateConfigObject.call(this, config); var key; for (key in config) { if (Object.prototype.hasOwnProperty.call(config, key)) { var name = key.charAt(0).toUpperCase() + key.slice(1); var addFunc, getFunc; if (key !== "week" && key !== "month" && key !== "timezone" && key !== "timezoneOffset") { name += "s"; } addFunc = "add" + name; getFunc = "get" + name; if (key === "month") { addFunc = addFunc + "s"; } else if (key === "year"){ getFunc = "getFullYear"; } if (key !== "day" && key !== "timezone" && key !== "timezoneOffset" && key !== "week" && key !== "hour") { this[addFunc](config[key] - this[getFunc]()); } else if ( key === "timezone"|| key === "timezoneOffset" || key === "week" || key === "hour") { this["set"+name](config[key]); } } } // day has to go last because you can't validate the day without first knowing the month if (config.day) { this.addDays(config.day - this.getDate()); } return this; }; /** * Moves the date to the first day of the month. * @return {Date} this */ $P.moveToFirstDayOfMonth = function () { return this.set({ day: 1 }); }; /** * Moves the date to the last day of the month. * @return {Date} this */ $P.moveToLastDayOfMonth = function () { return this.set({ day: $D.getDaysInMonth(this.getFullYear(), this.getMonth())}); }; /** * Converts the value of the current Date object to its equivalent string representation. * Format Specifiers * CUSTOM DATE AND TIME FORMAT STRINGS * Format Description Example * ------ --------------------------------------------------------------------------- ----------------------- * s The seconds of the minute between 0-59. "0" to "59" * ss The seconds of the minute with leading zero if required. "00" to "59" * * m The minute of the hour between 0-59. "0" or "59" * mm The minute of the hour with leading zero if required. "00" or "59" * * h The hour of the day between 1-12. "1" to "12" * hh The hour of the day with leading zero if required. "01" to "12" * * H The hour of the day between 0-23. "0" to "23" * HH The hour of the day with leading zero if required. "00" to "23" * * d The day of the month between 1 and 31. "1" to "31" * dd The day of the month with leading zero if required. "01" to "31" * ddd Abbreviated day name. Date.CultureInfo.abbreviatedDayNames. "Mon" to "Sun" * dddd The full day name. Date.CultureInfo.dayNames. "Monday" to "Sunday" * * M The month of the year between 1-12. "1" to "12" * MM The month of the year with leading zero if required. "01" to "12" * MMM Abbreviated month name. Date.CultureInfo.abbreviatedMonthNames. "Jan" to "Dec" * MMMM The full month name. Date.CultureInfo.monthNames. "January" to "December" * * yy The year as a two-digit number. "99" or "08" * yyyy The full four digit year. "1999" or "2008" * * t Displays the first character of the A.M./P.M. designator. "A" or "P" * Date.CultureInfo.amDesignator or Date.CultureInfo.pmDesignator * tt Displays the A.M./P.M. designator. "AM" or "PM" * Date.CultureInfo.amDesignator or Date.CultureInfo.pmDesignator * * S The ordinal suffix ("st, "nd", "rd" or "th") of the current day. "st, "nd", "rd" or "th" * * STANDARD DATE AND TIME FORMAT STRINGS * Format Description Example *------ --------------------------------------------------------------------------- ----------------------- * d The CultureInfo shortDate Format Pattern "M/d/yyyy" * D The CultureInfo longDate Format Pattern "dddd, MMMM dd, yyyy" * F The CultureInfo fullDateTime Format Pattern "dddd, MMMM dd, yyyy h:mm:ss tt" * m The CultureInfo monthDay Format Pattern "MMMM dd" * r The CultureInfo rfc1123 Format Pattern "ddd, dd MMM yyyy HH:mm:ss GMT" * s The CultureInfo sortableDateTime Format Pattern "yyyy-MM-ddTHH:mm:ss" * t The CultureInfo shortTime Format Pattern "h:mm tt" * T The CultureInfo longTime Format Pattern "h:mm:ss tt" * u The CultureInfo universalSortableDateTime Format Pattern "yyyy-MM-dd HH:mm:ssZ" * y The CultureInfo yearMonth Format Pattern "MMMM, yyyy" * * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @return {String} A string representation of the current Date object. */ var ord = function (n) { switch (n * 1) { case 1: case 21: case 31: return "st"; case 2: case 22: return "nd"; case 3: case 23: return "rd"; default: return "th"; } }; var parseStandardFormats = function (format) { var y, c = Date.CultureInfo.formatPatterns; switch (format) { case "d": return this.toString(c.shortDate); case "D": return this.toString(c.longDate); case "F": return this.toString(c.fullDateTime); case "m": return this.toString(c.monthDay); case "r": case "R": y = this.clone().addMinutes(this.getTimezoneOffset()); return y.toString(c.rfc1123) + " GMT"; case "s": return this.toString(c.sortableDateTime); case "t": return this.toString(c.shortTime); case "T": return this.toString(c.longTime); case "u": y = this.clone().addMinutes(this.getTimezoneOffset()); return y.toString(c.universalSortableDateTime); case "y": return this.toString(c.yearMonth); default: return false; } }; var parseFormatStringsClosure = function (context) { return function (m) { if (m.charAt(0) === "\\") { return m.replace("\\", ""); } switch (m) { case "hh": return p(context.getHours() < 13 ? (context.getHours() === 0 ? 12 : context.getHours()) : (context.getHours() - 12)); case "h": return context.getHours() < 13 ? (context.getHours() === 0 ? 12 : context.getHours()) : (context.getHours() - 12); case "HH": return p(context.getHours()); case "H": return context.getHours(); case "mm": return p(context.getMinutes()); case "m": return context.getMinutes(); case "ss": return p(context.getSeconds()); case "s": return context.getSeconds(); case "yyyy": return p(context.getFullYear(), 4); case "yy": return p(context.getFullYear()); case "y": return context.getFullYear(); case "E": case "dddd": return Date.CultureInfo.dayNames[context.getDay()]; case "ddd": return Date.CultureInfo.abbreviatedDayNames[context.getDay()]; case "dd": return p(context.getDate()); case "d": return context.getDate(); case "MMMM": return Date.CultureInfo.monthNames[context.getMonth()]; case "MMM": return Date.CultureInfo.abbreviatedMonthNames[context.getMonth()]; case "MM": return p((context.getMonth() + 1)); case "M": return context.getMonth() + 1; case "t": return context.getHours() < 12 ? Date.CultureInfo.amDesignator.substring(0, 1) : Date.CultureInfo.pmDesignator.substring(0, 1); case "tt": return context.getHours() < 12 ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator; case "S": return ord(context.getDate()); case "W": return context.getWeek(); case "WW": return context.getISOWeek(); case "Q": return "Q" + context.getQuarter(); case "q": return String(context.getQuarter()); case "z": return context.getTimezone(); case "Z": case "X": return Date.getTimezoneOffset(context.getTimezone()); case "ZZ": // Timezone offset in seconds return context.getTimezoneOffset() * -60; case "u": return context.getDay(); case "L": return ($D.isLeapYear(context.getFullYear())) ? 1 : 0; case "B": // Swatch Internet Time (.beats) return "@"+((context.getUTCSeconds() + (context.getUTCMinutes()*60) + ((context.getUTCHours()+1)*3600))/86.4); default: return m; } }; }; $P.toString = function (format, ignoreStandards) { // Standard Date and Time Format Strings. Formats pulled from CultureInfo file and // may vary by culture. if (!ignoreStandards && format && format.length === 1) { output = parseStandardFormats.call(this, format); if (output) { return output; } } var parseFormatStrings = parseFormatStringsClosure(this); return format ? format.replace(/((\\)?(dd?d?d?|MM?M?M?|yy?y?y?|hh?|HH?|mm?|ss?|tt?|S|q|Q|WW?W?W?)(?![^\[]*\]))/g, parseFormatStrings).replace(/\[|\]/g, "") : this._toString(); }; }()); /************************************************************* * SugarPak - Domain Specific Language - Syntactical Sugar * *************************************************************/ (function () { var $D = Date, $P = $D.prototype, $N = Number.prototype; // private $P._orient = +1; // private $P._nth = null; // private $P._is = false; // private $P._same = false; // private $P._isSecond = false; // private $N._dateElement = "days"; /** * Moves the date to the next instance of a date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.today().next().friday();
	Date.today().next().fri();
	Date.today().next().march();
	Date.today().next().mar();
	Date.today().next().week();
	
* * @return {Date} date */ $P.next = function () { this._move = true; this._orient = +1; return this; }; /** * Creates a new Date (Date.today()) and moves the date to the next instance of the date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.next().friday();
	Date.next().fri();
	Date.next().march();
	Date.next().mar();
	Date.next().week();
	
* * @return {Date} date */ $D.next = function () { return $D.today().next(); }; /** * Moves the date to the previous instance of a date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.today().last().friday();
	Date.today().last().fri();
	Date.today().last().march();
	Date.today().last().mar();
	Date.today().last().week();
	
* * @return {Date} date */ $P.last = $P.prev = $P.previous = function () { this._move = true; this._orient = -1; return this; }; /** * Creates a new Date (Date.today()) and moves the date to the previous instance of the date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.last().friday();
	Date.last().fri();
	Date.previous().march();
	Date.prev().mar();
	Date.last().week();
	
* * @return {Date} date */ $D.last = $D.prev = $D.previous = function () { return $D.today().last(); }; /** * Performs a equality check when followed by either a month name, day name or .weekday() function. * Example

	Date.today().is().friday(); // true|false
	Date.today().is().fri();
	Date.today().is().march();
	Date.today().is().mar();
	
* * @return {Boolean} true|false */ $P.is = function () { this._is = true; return this; }; /** * Determines if two date objects occur on/in exactly the same instance of the subsequent date part function. * The function .same() must be followed by a date part function (example: .day(), .month(), .year(), etc). * * An optional Date can be passed in the date part function. If now date is passed as a parameter, 'Now' is used. * * The following example demonstrates how to determine if two dates fall on the exact same day. * * Example

	var d1 = Date.today(); // today at 00:00
	var d2 = new Date();   // exactly now.

	// Do they occur on the same day?
	d1.same().day(d2); // true
	
	// Do they occur on the same hour?
	d1.same().hour(d2); // false, unless d2 hour is '00' (midnight).
	
	// What if it's the same day, but one year apart?
	var nextYear = Date.today().add(1).year();

	d1.same().day(nextYear); // false, because the dates must occur on the exact same day. 
	
* * Scenario: Determine if a given date occurs during some week period 2 months from now. * * Example

	var future = Date.today().add(2).months();
	return someDate.same().week(future); // true|false;
	
* * @return {Boolean} true|false */ $P.same = function () { this._same = true; this._isSecond = false; return this; }; /** * Determines if the current date/time occurs during Today. Must be preceded by the .is() function. * Example

	someDate.is().today();    // true|false
	new Date().is().today();  // true
	Date.today().is().today();// true
	Date.today().add(-1).day().is().today(); // false
	
* * @return {Boolean} true|false */ $P.today = function () { return this.same().day(); }; /** * Determines if the current date is a weekday. This function must be preceded by the .is() function. * Example

	Date.today().is().weekday(); // true|false
	
* * @return {Boolean} true|false */ $P.weekday = function () { if (this._nth) { return df("Weekday").call(this); } if (this._move) { return this.addWeekdays(this._orient); } if (this._is) { this._is = false; return (!this.is().sat() && !this.is().sun()); } return false; }; /** * Determines if the current date is on the weekend. This function must be preceded by the .is() function. * Example

	Date.today().is().weekend(); // true|false
	
* * @return {Boolean} true|false */ $P.weekend = function () { if (this._is) { this._is = false; return (this.is().sat() || this.is().sun()); } return false; }; /** * Sets the Time of the current Date instance. A string "6:15 pm" or config object {hour:18, minute:15} are accepted. * Example

	// Set time to 6:15pm with a String
	Date.today().at("6:15pm");

	// Set time to 6:15pm with a config object
	Date.today().at({hour:18, minute:15});
	
* * @return {Date} date */ $P.at = function (time) { return (typeof time === "string") ? $D.parse(this.toString("d") + " " + time) : this.set(time); }; /** * Creates a new Date() and adds this (Number) to the date based on the preceding date element function (eg. second|minute|hour|day|month|year). * Example

	// Undeclared Numbers must be wrapped with parentheses. Requirment of JavaScript.
	(3).days().fromNow();
	(6).months().fromNow();

	// Declared Number variables do not require parentheses. 
	var n = 6;
	n.months().fromNow();
	
* * @return {Date} A new Date instance */ $N.fromNow = $N.after = function (date) { var c = {}; c[this._dateElement] = this; return ((!date) ? new Date() : date.clone()).add(c); }; /** * Creates a new Date() and subtract this (Number) from the date based on the preceding date element function (eg. second|minute|hour|day|month|year). * Example

	// Undeclared Numbers must be wrapped with parentheses. Requirment of JavaScript.
	(3).days().ago();
	(6).months().ago();

	// Declared Number variables do not require parentheses. 
	var n = 6;
	n.months().ago();
	
* * @return {Date} A new Date instance */ $N.ago = $N.before = function (date) { var c = {}, s = (this._dateElement[this._dateElement.length-1] !== "s") ? this._dateElement + "s" : this._dateElement; c[s] = this * -1; return ((!date) ? new Date() : date.clone()).add(c); }; // Do NOT modify the following string tokens. These tokens are used to build dynamic functions. // All culture-specific strings can be found in the CultureInfo files. var dx = ("sunday monday tuesday wednesday thursday friday saturday").split(/\s/), mx = ("january february march april may june july august september october november december").split(/\s/), px = ("Millisecond Second Minute Hour Day Week Month Year Quarter Weekday").split(/\s/), pxf = ("Milliseconds Seconds Minutes Hours Date Week Month FullYear Quarter").split(/\s/), nth = ("final first second third fourth fifth").split(/\s/), de; /** * Returns an object literal of all the date parts. * Example

	var o = new Date().toObject();
	
	// { year: 2008, month: 4, week: 20, day: 13, hour: 18, minute: 9, second: 32, millisecond: 812 }
	
	// The object properties can be referenced directly from the object.
	
	alert(o.day);  // alerts "13"
	alert(o.year); // alerts "2008"
	
* * @return {Date} An object literal representing the original date object. */ $P.toObject = function () { var o = {}; for (var i = 0; i < px.length; i++) { if (this["get" + pxf[i]]) { o[px[i].toLowerCase()] = this["get" + pxf[i]](); } } return o; }; /** * Returns a date created from an object literal. Ignores the .week property if set in the config. * Example

	var o = new Date().toObject();
	
	return Date.fromObject(o); // will return the same date. 

	var o2 = {month: 1, day: 20, hour: 18}; // birthday party!
	Date.fromObject(o2);
	
* * @return {Date} An object literal representing the original date object. */ $D.fromObject = function(config) { config.week = null; return Date.today().set(config); }; // Create day name functions and abbreviated day name functions (eg. monday(), friday(), fri()). var df = function (n) { return function () { if (this._is) { this._is = false; return this.getDay() === n; } if (this._move) { this._move = null; } if (this._nth !== null) { // If the .second() function was called earlier, remove the _orient // from the date, and then continue. // This is required because 'second' can be used in two different context. // // Example // // Date.today().add(1).second(); // Date.march().second().monday(); // // Things get crazy with the following... // Date.march().add(1).second().second().monday(); // but it works!! // if (this._isSecond) { this.addSeconds(this._orient * -1); } // make sure we reset _isSecond this._isSecond = false; var ntemp = this._nth; this._nth = null; var temp = this.clone().moveToLastDayOfMonth(); this.moveToNthOccurrence(n, ntemp); if (this > temp) { throw new RangeError($D.getDayName(n) + " does not occur " + ntemp + " times in the month of " + $D.getMonthName(temp.getMonth()) + " " + temp.getFullYear() + "."); } return this; } return this.moveToDayOfWeek(n, this._orient); }; }; var sdf = function (n) { return function () { var t = $D.today(), shift = n - t.getDay(); if (n === 0 && Date.CultureInfo.firstDayOfWeek === 1 && t.getDay() !== 0) { shift = shift + 7; } return t.addDays(shift); }; }; // Create month name functions and abbreviated month name functions (eg. january(), march(), mar()). var month_instance_functions = function (n) { return function () { if (this._is) { this._is = false; return this.getMonth() === n; } return this.moveToMonth(n, this._orient); }; }; var month_static_functions = function (n) { return function () { return $D.today().set({ month: n, day: 1 }); }; }; var processTerms = function (names, staticFunc, instanceFunc) { for (var i = 0; i < names.length; i++) { // Create constant static Name variables. $D[names[i].toUpperCase()] = $D[names[i].toUpperCase().substring(0, 3)] = i; // Create Name functions. $D[names[i]] = $D[names[i].substring(0, 3)] = staticFunc(i); // Create Name instance functions. $P[names[i]] = $P[names[i].substring(0, 3)] = instanceFunc(i); } }; processTerms(dx, sdf, df); processTerms(mx, month_static_functions, month_instance_functions); // Create date element functions and plural date element functions used with Date (eg. day(), days(), months()). var ef = function (j) { return function () { // if the .second() function was called earlier, the _orient // has alread been added. Just return this and reset _isSecond. if (this._isSecond) { this._isSecond = false; return this; } if (this._same) { this._same = this._is = false; var o1 = this.toObject(), o2 = (arguments[0] || new Date()).toObject(), v = "", k = j.toLowerCase(); // the substr trick with -1 doesn't work in IE8 or less k = (k[k.length-1] === "s") ? k.substring(0,k.length-1) : k; for (var m = (px.length - 1); m > -1; m--) { v = px[m].toLowerCase(); if (o1[v] !== o2[v]) { return false; } if (k === v) { break; } } return true; } if (j.substring(j.length - 1) !== "s") { j += "s"; } if (this._move) { this._move = null; } return this["add" + j](this._orient); }; }; var nf = function (n) { return function () { this._dateElement = n; return this; }; }; for (var k = 0; k < px.length; k++) { de = px[k].toLowerCase(); if(de !== "weekday") { // Create date element functions and plural date element functions used with Date (eg. day(), days(), months()). $P[de] = $P[de + "s"] = ef(px[k]); // Create date element functions and plural date element functions used with Number (eg. day(), days(), months()). $N[de] = $N[de + "s"] = nf(de + "s"); } } $P._ss = ef("Second"); var nthfn = function (n) { return function (dayOfWeek) { if (this._same) { return this._ss(arguments[0]); } if (dayOfWeek || dayOfWeek === 0) { return this.moveToNthOccurrence(dayOfWeek, n); } this._nth = n; // if the operator is 'second' add the _orient, then deal with it later... if (n === 2 && (dayOfWeek === undefined || dayOfWeek === null)) { this._isSecond = true; return this.addSeconds(this._orient); } return this; }; }; for (var l = 0; l < nth.length; l++) { $P[nth[l]] = (l === 0) ? nthfn(-1) : nthfn(l); } }()); (function () { "use strict"; Date.Parsing = { Exception: function (s) { this.message = "Parse error at '" + s.substring(0, 10) + " ...'"; } }; var $P = Date.Parsing; var dayOffsets = { standard: [0,31,59,90,120,151,181,212,243,273,304,334], leap: [0,31,60,91,121,152,182,213,244,274,305,335] }; $P.isLeapYear = function(year) { return ((year % 4 === 0) && (year % 100 !== 0)) || (year % 400 === 0); }; var utils = { multiReplace : function (str, hash ) { var key; for (key in hash) { if (Object.prototype.hasOwnProperty.call(hash, key)) { var regex; if (typeof hash[key] === "function") { } else { regex = (hash[key] instanceof RegExp) ? hash[key] : new RegExp(hash[key], "g"); } str = str.replace(regex, key); } } return str; }, getDayOfYearFromWeek : function (obj) { var d, jan4, offset; obj.weekDay = (!obj.weekDay && obj.weekDay !== 0) ? 1 : obj.weekDay; d = new Date(obj.year, 0, 4); jan4 = d.getDay() === 0 ? 7 : d.getDay(); // JS is 0 indexed on Sunday. offset = jan4+3; obj.dayOfYear = ((obj.week * 7) + (obj.weekDay === 0 ? 7 : obj.weekDay))-offset; return obj; }, getDayOfYear : function (obj, dayOffset) { if (!obj.dayOfYear) { obj = utils.getDayOfYearFromWeek(obj); } for (var i=0;i <= dayOffset.length;i++) { if (obj.dayOfYear < dayOffset[i] || i === dayOffset.length) { obj.day = obj.day ? obj.day : (obj.dayOfYear - dayOffset[i-1]); break; } else { obj.month = i; } } return obj; }, adjustForTimeZone : function (obj, date) { var offset; if (obj.zone.toUpperCase() === "Z" || (obj.zone_hours === 0 && obj.zone_minutes === 0)) { // it's UTC/GML so work out the current timeszone offset offset = -date.getTimezoneOffset(); } else { offset = (obj.zone_hours*60) + (obj.zone_minutes || 0); if (obj.zone_sign === "+") { offset *= -1; } offset -= date.getTimezoneOffset(); } date.setMinutes(date.getMinutes()+offset); return date; }, setDefaults : function (obj) { obj.year = obj.year || Date.today().getFullYear(); obj.hours = obj.hours || 0; obj.minutes = obj.minutes || 0; obj.seconds = obj.seconds || 0; obj.milliseconds = obj.milliseconds || 0; if (!(!obj.month && (obj.week || obj.dayOfYear))) { // if we have a month, or if we don't but don't have the day calculation data obj.month = obj.month || 0; obj.day = obj.day || 1; } return obj; }, dataNum: function (data, mod, explict, postProcess) { var dataNum = data*1; if (mod) { if (postProcess) { return data ? mod(data)*1 : data; } else { return data ? mod(dataNum) : data; } } else if (!explict){ return data ? dataNum : data; } else { return (data && typeof data !== "undefined") ? dataNum : data; } }, timeDataProcess: function (obj) { var timeObj = {}; for (var x in obj.data) { if (obj.data.hasOwnProperty(x)) { timeObj[x] = obj.ignore[x] ? obj.data[x] : utils.dataNum(obj.data[x], obj.mods[x], obj.explict[x], obj.postProcess[x]); } } if (obj.data.secmins) { obj.data.secmins = obj.data.secmins.replace(",", ".") * 60; if (!timeObj.minutes) { timeObj.minutes = obj.data.secmins; } else if (!timeObj.seconds) { timeObj.seconds = obj.data.secmins; } delete obj.secmins; } return timeObj; }, buildTimeObjectFromData: function (data) { var time = utils.timeDataProcess({ data: { year : data[1], month : data[5], day : data[7], week : data[8], dayOfYear : data[10], hours : data[15], zone_hours : data[23], zone_minutes : data[24], zone : data[21], zone_sign : data[22], weekDay : data[9], minutes: data[16], seconds: data[19], milliseconds: data[20], secmins: data[18] }, mods: { month: function(data) { return data-1; }, weekDay: function (data) { data = Math.abs(data); return (data === 7 ? 0 : data); }, minutes: function (data) { return data.replace(":",""); }, seconds: function (data) { return Math.floor( (data.replace(":","").replace(",","."))*1 ); }, milliseconds: function (data) { return (data.replace(",",".")*1000); } }, postProcess: { minutes: true, seconds: true, milliseconds: true }, explict: { zone_hours: true, zone_minutes: true }, ignore: { zone: true, zone_sign: true, secmins: true } }); return time; }, addToHash: function (hash, keys, data) { keys = keys; data = data; var len = keys.length; for (var i = 0; i < len; i++) { hash[keys[i]] = data[i]; } return hash; }, combineRegex: function (r1, r2) { return new RegExp("(("+r1.source+")\\s("+r2.source+"))"); }, getDateNthString: function(add, last, inc){ if (add) { return Date.today().addDays(inc).toString("d"); } else if (last) { return Date.today().last()[inc]().toString("d"); } }, buildRegexData: function (array) { var arr = []; var len = array.length; for (var i=0; i < len; i++) { if (Object.prototype.toString.call(array[i]) === '[object Array]') { // oldIE compat version of Array.isArray arr.push(this.combineRegex(array[i][0], array[i][1])); } else { arr.push(array[i]); } } return arr; } }; $P.processTimeObject = function (obj) { var date, dayOffset; utils.setDefaults(obj); dayOffset = ($P.isLeapYear(obj.year)) ? dayOffsets.leap : dayOffsets.standard; if (!obj.month && (obj.week || obj.dayOfYear)) { utils.getDayOfYear(obj, dayOffset); } else { obj.dayOfYear = dayOffset[obj.month] + obj.day; } date = new Date(obj.year, obj.month, obj.day, obj.hours, obj.minutes, obj.seconds, obj.milliseconds); if (obj.zone) { utils.adjustForTimeZone(obj, date); // adjust (and calculate) for timezone } return date; }; $P.ISO = { regex : /^([\+-]?\d{4}(?!\d{2}\b))((-?)((0[1-9]|1[0-2])(\3([12]\d|0[1-9]|3[01]))?|W([0-4]\d|5[0-3])(-?[1-7])?|(00[1-9]|0[1-9]\d|[12]\d{2}|3([0-5]\d|6[1-6])))([T\s]((([01]\d|2[0-4])((:?)[0-5]\d)?|24\:?00)([\.,]\d+(?!:))?)?(\17[0-5]\d([\.,]\d+)?)?\s?([zZ]|([\+-])([01]\d|2[0-3]):?([0-5]\d)?)?)?)?$/, parse : function (s) { var time, data = s.match(this.regex); if (!data || !data.length) { return null; } time = utils.buildTimeObjectFromData(data); if (!time.year || (!time.year && (!time.month && !time.day) && (!time.week && !time.dayOfYear)) ) { return null; } return $P.processTimeObject(time); } }; $P.Numeric = { isNumeric: function (e){return!isNaN(parseFloat(e))&&isFinite(e);}, regex: /\b([0-1]?[0-9])([0-3]?[0-9])([0-2]?[0-9]?[0-9][0-9])\b/i, parse: function (s) { var data, i, time = {}, order = Date.CultureInfo.dateElementOrder.split(""); if (!(this.isNumeric(s)) || // if it's non-numeric OR (s[0] === "+" && s[0] === "-")) { // It's an arithmatic string (eg +/-1000) return null; } if (s.length < 5 && s.indexOf(".") < 0 && s.indexOf("/") < 0) { // assume it's just a year. time.year = s; return $P.processTimeObject(time); } data = s.match(this.regex); if (!data || !data.length) { return null; } for (i=0; i < order.length; i++) { switch(order[i]) { case "d": time.day = data[i+1]; break; case "m": time.month = (data[i+1]-1); break; case "y": time.year = data[i+1]; break; } } return $P.processTimeObject(time); } }; $P.Normalizer = { regexData: function () { var $R = Date.CultureInfo.regexPatterns; return utils.buildRegexData([ $R.tomorrow, $R.yesterday, [$R.past, $R.mon], [$R.past, $R.tue], [$R.past, $R.wed], [$R.past, $R.thu], [$R.past, $R.fri], [$R.past, $R.sat], [$R.past, $R.sun] ]); }, basicReplaceHash : function() { var $R = Date.CultureInfo.regexPatterns; return { "January": $R.jan.source, "February": $R.feb, "March": $R.mar, "April": $R.apr, "May": $R.may, "June": $R.jun, "July": $R.jul, "August": $R.aug, "September": $R.sep, "October": $R.oct, "November": $R.nov, "December": $R.dec, "": /\bat\b/gi, " ": /\s{2,}/, "am": $R.inTheMorning, "9am": $R.thisMorning, "pm": $R.inTheEvening, "7pm":$R.thisEvening }; }, keys : function(){ return [ utils.getDateNthString(true, false, 1), // tomorrow utils.getDateNthString(true, false, -1), // yesterday utils.getDateNthString(false, true, "monday"), //last mon utils.getDateNthString(false, true, "tuesday"), //last tues utils.getDateNthString(false, true, "wednesday"), //last wed utils.getDateNthString(false, true, "thursday"), //last thurs utils.getDateNthString(false, true, "friday"), //last fri utils.getDateNthString(false, true, "saturday"), //last sat utils.getDateNthString(false, true, "sunday") //last sun ]; }, buildRegexFunctions: function () { var $R = Date.CultureInfo.regexPatterns; var __ = Date.i18n.__; var tomorrowRE = new RegExp("(\\b\\d\\d?("+__("AM")+"|"+__("PM")+")? )("+$R.tomorrow.source.slice(1)+")", "i"); // adapted tomorrow regex for AM PM relative dates var todayRE = new RegExp($R.today.source + "(?!\\s*([+-]))\\b"); // today, but excludes the math operators (eg "today + 2h") this.replaceFuncs = [ [todayRE, function (full) { return (full.length > 1) ? Date.today().toString("d") : full; }], [tomorrowRE, function(full, m1) { var t = Date.today().addDays(1).toString("d"); return (t + " " + m1); }], [$R.amThisMorning, function(str, am){return am;}], [$R.pmThisEvening, function(str, pm){return pm;}] ]; }, buildReplaceData: function () { this.buildRegexFunctions(); this.replaceHash = utils.addToHash(this.basicReplaceHash(), this.keys(), this.regexData()); }, stringReplaceFuncs: function (s) { for (var i=0; i < this.replaceFuncs.length; i++) { s = s.replace(this.replaceFuncs[i][0], this.replaceFuncs[i][1]); } return s; }, parse: function (s) { s = this.stringReplaceFuncs(s); s = utils.multiReplace(s, this.replaceHash); try { var n = s.split(/([\s\-\.\,\/\x27]+)/); if (n.length === 3 && $P.Numeric.isNumeric(n[0]) && $P.Numeric.isNumeric(n[2]) && (n[2].length >= 4)) { // ok, so we're dealing with x/year. But that's not a full date. // This fixes wonky dateElementOrder parsing when set to dmy order. if (Date.CultureInfo.dateElementOrder[0] === "d") { s = "1/" + n[0] + "/" + n[2]; // set to 1st of month and normalize the seperator } } } catch (e) {} return s; } }; $P.Normalizer.buildReplaceData(); }()); (function () { var $P = Date.Parsing; var _ = $P.Operators = { // // Tokenizers // rtoken: function (r) { // regex token return function (s) { var mx = s.match(r); if (mx) { return ([ mx[0], s.substring(mx[0].length) ]); } else { throw new $P.Exception(s); } }; }, token: function () { // whitespace-eating token return function (s) { return _.rtoken(new RegExp("^\\s*" + s + "\\s*"))(s); }; }, stoken: function (s) { // string token return _.rtoken(new RegExp("^" + s)); }, // Atomic Operators until: function (p) { return function (s) { var qx = [], rx = null; while (s.length) { try { rx = p.call(this, s); } catch (e) { qx.push(rx[0]); s = rx[1]; continue; } break; } return [ qx, s ]; }; }, many: function (p) { return function (s) { var rx = [], r = null; while (s.length) { try { r = p.call(this, s); } catch (e) { return [ rx, s ]; } rx.push(r[0]); s = r[1]; } return [ rx, s ]; }; }, // generator operators -- see below optional: function (p) { return function (s) { var r = null; try { r = p.call(this, s); } catch (e) { return [ null, s ]; } return [ r[0], r[1] ]; }; }, not: function (p) { return function (s) { try { p.call(this, s); } catch (e) { return [null, s]; } throw new $P.Exception(s); }; }, ignore: function (p) { return p ? function (s) { var r = null; r = p.call(this, s); return [null, r[1]]; } : null; }, product: function () { var px = arguments[0], qx = Array.prototype.slice.call(arguments, 1), rx = []; for (var i = 0 ; i < px.length ; i++) { rx.push(_.each(px[i], qx)); } return rx; }, cache: function (rule) { var cache = {}, cache_length = 0, cache_keys = [], CACHE_MAX = Date.Config.CACHE_MAX || 100000, r = null; var cacheCheck = function () { if (cache_length === CACHE_MAX) { // kill several keys, don't want to have to do this all the time... for (var i=0; i < 10; i++) { var key = cache_keys.shift(); if (key) { delete cache[key]; cache_length--; } } } }; return function (s) { cacheCheck(); try { r = cache[s] = (cache[s] || rule.call(this, s)); } catch (e) { r = cache[s] = e; } cache_length++; cache_keys.push(s); if (r instanceof $P.Exception) { throw r; } else { return r; } }; }, // vector operators -- see below any: function () { var px = arguments; return function (s) { var r = null; for (var i = 0; i < px.length; i++) { if (px[i] == null) { continue; } try { r = (px[i].call(this, s)); } catch (e) { r = null; } if (r) { return r; } } throw new $P.Exception(s); }; }, each: function () { var px = arguments; return function (s) { var rx = [], r = null; for (var i = 0; i < px.length ; i++) { if (px[i] == null) { continue; } try { r = (px[i].call(this, s)); } catch (e) { throw new $P.Exception(s); } rx.push(r[0]); s = r[1]; } return [ rx, s]; }; }, all: function () { var px = arguments, _ = _; return _.each(_.optional(px)); }, // delimited operators sequence: function (px, d, c) { d = d || _.rtoken(/^\s*/); c = c || null; if (px.length === 1) { return px[0]; } return function (s) { var r = null, q = null; var rx = []; for (var i = 0; i < px.length ; i++) { try { r = px[i].call(this, s); } catch (e) { break; } rx.push(r[0]); try { q = d.call(this, r[1]); } catch (ex) { q = null; break; } s = q[1]; } if (!r) { throw new $P.Exception(s); } if (q) { throw new $P.Exception(q[1]); } if (c) { try { r = c.call(this, r[1]); } catch (ey) { throw new $P.Exception(r[1]); } } return [ rx, (r?r[1]:s) ]; }; }, // // Composite Operators // between: function (d1, p, d2) { d2 = d2 || d1; var _fn = _.each(_.ignore(d1), p, _.ignore(d2)); return function (s) { var rx = _fn.call(this, s); return [[rx[0][0], r[0][2]], rx[1]]; }; }, list: function (p, d, c) { d = d || _.rtoken(/^\s*/); c = c || null; return (p instanceof Array ? _.each(_.product(p.slice(0, -1), _.ignore(d)), p.slice(-1), _.ignore(c)) : _.each(_.many(_.each(p, _.ignore(d))), px, _.ignore(c))); }, set: function (px, d, c) { d = d || _.rtoken(/^\s*/); c = c || null; return function (s) { // r is the current match, best the current 'best' match // which means it parsed the most amount of input var r = null, p = null, q = null, rx = null, best = [[], s], last = false; // go through the rules in the given set for (var i = 0; i < px.length ; i++) { // last is a flag indicating whether this must be the last element // if there is only 1 element, then it MUST be the last one q = null; p = null; r = null; last = (px.length === 1); // first, we try simply to match the current pattern // if not, try the next pattern try { r = px[i].call(this, s); } catch (e) { continue; } // since we are matching against a set of elements, the first // thing to do is to add r[0] to matched elements rx = [[r[0]], r[1]]; // if we matched and there is still input to parse and // we don't already know this is the last element, // we're going to next check for the delimiter ... // if there's none, or if there's no input left to parse // than this must be the last element after all ... if (r[1].length > 0 && ! last) { try { q = d.call(this, r[1]); } catch (ex) { last = true; } } else { last = true; } // if we parsed the delimiter and now there's no more input, // that means we shouldn't have parsed the delimiter at all // so don't update r and mark this as the last element ... if (!last && q[1].length === 0) { last = true; } // so, if this isn't the last element, we're going to see if // we can get any more matches from the remaining (unmatched) // elements ... if (!last) { // build a list of the remaining rules we can match against, // i.e., all but the one we just matched against var qx = []; for (var j = 0; j < px.length ; j++) { if (i !== j) { qx.push(px[j]); } } // now invoke recursively set with the remaining input // note that we don't include the closing delimiter ... // we'll check for that ourselves at the end p = _.set(qx, d).call(this, q[1]); // if we got a non-empty set as a result ... // (otw rx already contains everything we want to match) if (p[0].length > 0) { // update current result, which is stored in rx ... // basically, pick up the remaining text from p[1] // and concat the result from p[0] so that we don't // get endless nesting ... rx[0] = rx[0].concat(p[0]); rx[1] = p[1]; } } // at this point, rx either contains the last matched element // or the entire matched set that starts with this element. // now we just check to see if this variation is better than // our best so far, in terms of how much of the input is parsed if (rx[1].length < best[1].length) { best = rx; } // if we've parsed all the input, then we're finished if (best[1].length === 0) { break; } } // so now we've either gone through all the patterns trying them // as the initial match; or we found one that parsed the entire // input string ... // if best has no matches, just return empty set ... if (best[0].length === 0) { return best; } // if a closing delimiter is provided, then we have to check it also if (c) { // we try this even if there is no remaining input because the pattern // may well be optional or match empty input ... try { q = c.call(this, best[1]); } catch (ey) { throw new $P.Exception(best[1]); } // it parsed ... be sure to update the best match remaining input best[1] = q[1]; } // if we're here, either there was no closing delimiter or we parsed it // so now we have the best match; just return it! return best; }; }, forward: function (gr, fname) { return function (s) { return gr[fname].call(this, s); }; }, // // Translation Operators // replace: function (rule, repl) { return function (s) { var r = rule.call(this, s); return [repl, r[1]]; }; }, process: function (rule, fn) { return function (s) { var r = rule.call(this, s); return [fn.call(this, r[0]), r[1]]; }; }, min: function (min, rule) { return function (s) { var rx = rule.call(this, s); if (rx[0].length < min) { throw new $P.Exception(s); } return rx; }; } }; // Generator Operators And Vector Operators // Generators are operators that have a signature of F(R) => R, // taking a given rule and returning another rule, such as // ignore, which parses a given rule and throws away the result. // Vector operators are those that have a signature of F(R1,R2,...) => R, // take a list of rules and returning a new rule, such as each. // Generator operators are converted (via the following _generator // function) into functions that can also take a list or array of rules // and return an array of new rules as though the function had been // called on each rule in turn (which is what actually happens). // This allows generators to be used with vector operators more easily. // Example: // each(ignore(foo, bar)) instead of each(ignore(foo), ignore(bar)) // This also turns generators into vector operators, which allows // constructs like: // not(cache(foo, bar)) var _generator = function (op) { function gen() { var args = null, rx = [], px, i; if (arguments.length > 1) { args = Array.prototype.slice.call(arguments); } else if (arguments[0] instanceof Array) { args = arguments[0]; } if (args) { px = args.shift(); if (px.length > 0) { args.unshift(px[i]); rx.push(op.apply(null, args)); args.shift(); return rx; } } else { return op.apply(null, arguments); } } return gen; }; var gx = "optional not ignore cache".split(/\s/); for (var i = 0 ; i < gx.length ; i++) { _[gx[i]] = _generator(_[gx[i]]); } var _vector = function (op) { return function () { if (arguments[0] instanceof Array) { return op.apply(null, arguments[0]); } else { return op.apply(null, arguments); } }; }; var vx = "each any all".split(/\s/); for (var j = 0 ; j < vx.length ; j++) { _[vx[j]] = _vector(_[vx[j]]); } }()); (function () { var $D = Date; var flattenAndCompact = function (ax) { var rx = []; for (var i = 0; i < ax.length; i++) { if (ax[i] instanceof Array) { rx = rx.concat(flattenAndCompact(ax[i])); } else { if (ax[i]) { rx.push(ax[i]); } } } return rx; }; var parseMeridian = function () { if (this.meridian && (this.hour || this.hour === 0)) { if (this.meridian === "a" && this.hour > 11 && Date.Config.strict24hr){ throw "Invalid hour and meridian combination"; } else if (this.meridian === "p" && this.hour < 12 && Date.Config.strict24hr){ throw "Invalid hour and meridian combination"; } else if (this.meridian === "p" && this.hour < 12) { this.hour = this.hour + 12; } else if (this.meridian === "a" && this.hour === 12) { this.hour = 0; } } }; var setDefaults = function () { var now = new Date(); if ((this.hour || this.minute) && (!this.month && !this.year && !this.day)) { this.day = now.getDate(); } if (!this.year) { this.year = now.getFullYear(); } if (!this.month && this.month !== 0) { this.month = now.getMonth(); } if (!this.day) { this.day = 1; } if (!this.hour) { this.hour = 0; } if (!this.minute) { this.minute = 0; } if (!this.second) { this.second = 0; } if (!this.millisecond) { this.millisecond = 0; } }; var finishUtils = { getToday: function () { if (this.now || "hour minute second".indexOf(this.unit) !== -1) { return new Date(); } else { return $D.today(); } }, setDaysFromWeekday: function (today, orient){ var gap; orient = orient || 1; this.unit = "day"; gap = ($D.getDayNumberFromName(this.weekday) - today.getDay()); this.days = gap ? ((gap + (orient * 7)) % 7) : (orient * 7); return this; }, setMonthsFromMonth: function (today, orient) { var gap; orient = orient || 1; this.unit = "month"; gap = (this.month - today.getMonth()); this.months = gap ? ((gap + (orient * 12)) % 12) : (orient * 12); this.month = null; return this; }, setDMYFromWeekday: function () { var d = Date[this.weekday](); this.day = d.getDate(); if (!this.month) { this.month = d.getMonth(); } this.year = d.getFullYear(); return this; }, setUnitValue: function (orient) { if (!this.value && this.operator && this.operator !== null && this[this.unit + "s"] && this[this.unit + "s"] !== null) { this[this.unit + "s"] = this[this.unit + "s"] + ((this.operator === "add") ? 1 : -1) + (this.value||0) * orient; } else if (this[this.unit + "s"] == null || this.operator != null) { if (!this.value) { this.value = 1; } this[this.unit + "s"] = this.value * orient; } }, generateDateFromWeeks: function () { var weekday = (this.weekday !== undefined) ? this.weekday : "today"; var d = Date[weekday]().addWeeks(this.weeks); if (this.now) { d.setTimeToNow(); } return d; } }; $D.Translator = { hour: function (s) { return function () { this.hour = Number(s); }; }, minute: function (s) { return function () { this.minute = Number(s); }; }, second: function (s) { return function () { this.second = Number(s); }; }, /* for ss.s format */ secondAndMillisecond: function (s) { return function () { var mx = s.match(/^([0-5][0-9])\.([0-9]{1,3})/); this.second = Number(mx[1]); this.millisecond = Number(mx[2]); }; }, meridian: function (s) { return function () { this.meridian = s.slice(0, 1).toLowerCase(); }; }, timezone: function (s) { return function () { var n = s.replace(/[^\d\+\-]/g, ""); if (n.length) { this.timezoneOffset = Number(n); } else { this.timezone = s.toLowerCase(); } }; }, day: function (x) { var s = x[0]; return function () { this.day = Number(s.match(/\d+/)[0]); if (this.day < 1) { throw "invalid day"; } }; }, month: function (s) { return function () { this.month = (s.length === 3) ? "jan feb mar apr may jun jul aug sep oct nov dec".indexOf(s)/4 : Number(s) - 1; if (this.month < 0) { throw "invalid month"; } }; }, year: function (s) { return function () { var n = Number(s); this.year = ((s.length > 2) ? n : (n + (((n + 2000) < Date.CultureInfo.twoDigitYearMax) ? 2000 : 1900))); }; }, rday: function (s) { return function () { switch (s) { case "yesterday": this.days = -1; break; case "tomorrow": this.days = 1; break; case "today": this.days = 0; break; case "now": this.days = 0; this.now = true; break; } }; }, finishExact: function (x) { var d; x = (x instanceof Array) ? x : [x]; for (var i = 0 ; i < x.length ; i++) { if (x[i]) { x[i].call(this); } } setDefaults.call(this); parseMeridian.call(this); if (this.day > $D.getDaysInMonth(this.year, this.month)) { throw new RangeError(this.day + " is not a valid value for days."); } d = new Date(this.year, this.month, this.day, this.hour, this.minute, this.second, this.millisecond); if (this.year < 100) { d.setFullYear(this.year); // means years less that 100 are process correctly. JS will parse it otherwise as 1900-1999. } if (this.timezone) { d.set({ timezone: this.timezone }); } else if (this.timezoneOffset) { d.set({ timezoneOffset: this.timezoneOffset }); } return d; }, finish: function (x) { var today, expression, orient, temp; x = (x instanceof Array) ? flattenAndCompact(x) : [ x ]; if (x.length === 0) { return null; } for (var i = 0 ; i < x.length ; i++) { if (typeof x[i] === "function") { x[i].call(this); } } if (this.now && !this.unit && !this.operator) { return new Date(); } else { today = finishUtils.getToday.call(this); } expression = !!(this.days && this.days !== null || this.orient || this.operator); orient = ((this.orient === "past" || this.operator === "subtract") ? -1 : 1); if (this.month && this.unit === "week") { this.value = this.month + 1; delete this.month; delete this.day; } if ((this.month || this.month === 0) && "year day hour minute second".indexOf(this.unit) !== -1) { if (!this.value) { this.value = this.month + 1; } this.month = null; expression = true; } if (!expression && this.weekday && !this.day && !this.days) { finishUtils.setDMYFromWeekday.call(this); } if (expression && this.weekday && this.unit !== "month" && this.unit !== "week") { finishUtils.setDaysFromWeekday.call(this, today, orient); } if (this.weekday && this.unit !== "week" && !this.day && !this.days) { temp = Date[this.weekday](); this.day = temp.getDate(); if (temp.getMonth() !== today.getMonth()) { this.month = temp.getMonth(); } } if (this.month && this.unit === "day" && this.operator) { if (!this.value) { this.value = (this.month + 1); } this.month = null; } if (this.value != null && this.month != null && this.year != null) { this.day = this.value * 1; } if (this.month && !this.day && this.value) { today.set({ day: this.value * 1 }); if (!expression) { this.day = this.value * 1; } } if (!this.month && this.value && this.unit === "month" && !this.now) { this.month = this.value; expression = true; } if (expression && (this.month || this.month === 0) && this.unit !== "year") { finishUtils.setMonthsFromMonth.call(this, today, orient); } if (!this.unit) { this.unit = "day"; } finishUtils.setUnitValue.call(this, orient); parseMeridian.call(this); if ((this.month || this.month === 0) && !this.day) { this.day = 1; } if (!this.orient && !this.operator && this.unit === "week" && this.value && !this.day && !this.month) { return Date.today().setWeek(this.value); } if (this.unit === "week" && this.weeks && !this.day && !this.month) { return finishUtils.generateDateFromWeeks.call(this); } if (expression && this.timezone && this.day && this.days) { this.day = this.days; } if (expression){ today.add(this); } else { today.set(this); } if (this.timezone) { this.timezone = this.timezone.toUpperCase(); var offset = $D.getTimezoneOffset(this.timezone); var timezone; if (today.hasDaylightSavingTime()) { // lets check that we're being sane with timezone setting timezone = $D.getTimezoneAbbreviation(offset, today.isDaylightSavingTime()); if (timezone !== this.timezone) { // bugger, we're in a place where things like EST vs EDT matters. if (today.isDaylightSavingTime()) { today.addHours(-1); } else { today.addHours(1); } } } today.setTimezoneOffset(offset); } return today; } }; }()); (function () { var $D = Date; $D.Grammar = {}; var _ = $D.Parsing.Operators, g = $D.Grammar, t = $D.Translator, _fn; // Allow rolling up into general purpose rules _fn = function () { return _.each(_.any.apply(null, arguments), _.not(g.ctoken2("timeContext"))); }; g.datePartDelimiter = _.rtoken(/^([\s\-\.\,\/\x27]+)/); g.timePartDelimiter = _.stoken(":"); g.whiteSpace = _.rtoken(/^\s*/); g.generalDelimiter = _.rtoken(/^(([\s\,]|at|@|on)+)/); var _C = {}; g.ctoken = function (keys) { var fn = _C[keys]; if (! fn) { var c = Date.CultureInfo.regexPatterns; var kx = keys.split(/\s+/), px = []; for (var i = 0; i < kx.length ; i++) { px.push(_.replace(_.rtoken(c[kx[i]]), kx[i])); } fn = _C[keys] = _.any.apply(null, px); } return fn; }; g.ctoken2 = function (key) { return _.rtoken(Date.CultureInfo.regexPatterns[key]); }; var cacheProcessRtoken = function (key, token, type, eachToken) { if (eachToken) { g[key] = _.cache(_.process(_.each(_.rtoken(token),_.optional(g.ctoken2(eachToken))), type)); } else { g[key] = _.cache(_.process(_.rtoken(token), type)); } }; var cacheProcessCtoken = function (token, type) { return _.cache(_.process(g.ctoken2(token), type)); }; var _F = {}; //function cache var _get = function (f) { _F[f] = (_F[f] || g.format(f)[0]); return _F[f]; }; g.allformats = function (fx) { var rx = []; if (fx instanceof Array) { for (var i = 0; i < fx.length; i++) { rx.push(_get(fx[i])); } } else { rx.push(_get(fx)); } return rx; }; g.formats = function (fx) { if (fx instanceof Array) { var rx = []; for (var i = 0 ; i < fx.length ; i++) { rx.push(_get(fx[i])); } return _.any.apply(null, rx); } else { return _get(fx); } }; var grammarFormats = { timeFormats: function(){ var i, RTokenKeys = [ "h", "hh", "H", "HH", "m", "mm", "s", "ss", "ss.s", "z", "zz" ], RToken = [ /^(0[0-9]|1[0-2]|[1-9])/, /^(0[0-9]|1[0-2])/, /^([0-1][0-9]|2[0-3]|[0-9])/, /^([0-1][0-9]|2[0-3])/, /^([0-5][0-9]|[0-9])/, /^[0-5][0-9]/, /^([0-5][0-9]|[0-9])/, /^[0-5][0-9]/, /^[0-5][0-9]\.[0-9]{1,3}/, /^((\+|\-)\s*\d\d\d\d)|((\+|\-)\d\d\:?\d\d)/, /^((\+|\-)\s*\d\d\d\d)|((\+|\-)\d\d\:?\d\d)/ ], tokens = [ t.hour, t.hour, t.hour, t.hour, t.minute, t.minute, t.second, t.second, t.secondAndMillisecond, t.timezone, t.timezone ]; for (i=0; i < RTokenKeys.length; i++) { cacheProcessRtoken(RTokenKeys[i], RToken[i], tokens[i]); } g.hms = _.cache(_.sequence([g.H, g.m, g.s], g.timePartDelimiter)); g.t = cacheProcessCtoken("shortMeridian", t.meridian); g.tt = cacheProcessCtoken("longMeridian", t.meridian); g.zzz = cacheProcessCtoken("timezone", t.timezone); g.timeSuffix = _.each(_.ignore(g.whiteSpace), _.set([ g.tt, g.zzz ])); g.time = _.each(_.optional(_.ignore(_.stoken("T"))), g.hms, g.timeSuffix); }, dateFormats: function () { // pre-loaded rules for different date part order preferences var _setfn = function () { return _.set(arguments, g.datePartDelimiter); }; var i, RTokenKeys = [ "d", "dd", "M", "MM", "y", "yy", "yyy", "yyyy" ], RToken = [ /^([0-2]\d|3[0-1]|\d)/, /^([0-2]\d|3[0-1])/, /^(1[0-2]|0\d|\d)/, /^(1[0-2]|0\d)/, /^(\d+)/, /^(\d\d)/, /^(\d\d?\d?\d?)/, /^(\d\d\d\d)/ ], tokens = [ t.day, t.day, t.month, t.month, t.year, t.year, t.year, t.year ], eachToken = [ "ordinalSuffix", "ordinalSuffix" ]; for (i=0; i < RTokenKeys.length; i++) { cacheProcessRtoken(RTokenKeys[i], RToken[i], tokens[i], eachToken[i]); } g.MMM = g.MMMM = _.cache(_.process(g.ctoken("jan feb mar apr may jun jul aug sep oct nov dec"), t.month)); g.ddd = g.dddd = _.cache(_.process(g.ctoken("sun mon tue wed thu fri sat"), function (s) { return function () { this.weekday = s; }; } )); g.day = _fn(g.d, g.dd); g.month = _fn(g.M, g.MMM); g.year = _fn(g.yyyy, g.yy); g.mdy = _setfn(g.ddd, g.month, g.day, g.year); g.ymd = _setfn(g.ddd, g.year, g.month, g.day); g.dmy = _setfn(g.ddd, g.day, g.month, g.year); g.date = function (s) { return ((g[Date.CultureInfo.dateElementOrder] || g.mdy).call(this, s)); }; }, relative: function () { // relative date / time expressions g.orientation = _.process(g.ctoken("past future"), function (s) { return function () { this.orient = s; }; } ); g.operator = _.process(g.ctoken("add subtract"), function (s) { return function () { this.operator = s; }; } ); g.rday = _.process(g.ctoken("yesterday tomorrow today now"), t.rday); g.unit = _.process(g.ctoken("second minute hour day week month year"), function (s) { return function () { this.unit = s; }; } ); } }; g.buildGrammarFormats = function () { // these need to be rebuilt every time the language changes. _C = {}; grammarFormats.timeFormats(); grammarFormats.dateFormats(); grammarFormats.relative(); g.value = _.process(_.rtoken(/^([-+]?\d+)?(st|nd|rd|th)?/), function (s) { return function () { this.value = s.replace(/\D/g, ""); }; } ); g.expression = _.set([g.rday, g.operator, g.value, g.unit, g.orientation, g.ddd, g.MMM ]); g.format = _.process(_.many( _.any( // translate format specifiers into grammar rules _.process( _.rtoken(/^(dd?d?d?(?!e)|MM?M?M?|yy?y?y?|hh?|HH?|mm?|ss?|tt?|zz?z?)/), function (fmt) { if (g[fmt]) { return g[fmt]; } else { throw $D.Parsing.Exception(fmt); } } ), // translate separator tokens into token rules _.process(_.rtoken(/^[^dMyhHmstz]+/), // all legal separators function (s) { return _.ignore(_.stoken(s)); } ) ) ), // construct the parser ... function (rules) { return _.process(_.each.apply(null, rules), t.finishExact); } ); // starting rule for general purpose grammar g._start = _.process(_.set([ g.date, g.time, g.expression ], g.generalDelimiter, g.whiteSpace), t.finish); }; g.buildGrammarFormats(); // parsing date format specifiers - ex: "h:m:s tt" // this little guy will generate a custom parser based // on the format string, ex: g.format("h:m:s tt") // check for these formats first g._formats = g.formats([ "\"yyyy-MM-ddTHH:mm:ssZ\"", "yyyy-MM-ddTHH:mm:ss.sz", "yyyy-MM-ddTHH:mm:ssZ", "yyyy-MM-ddTHH:mm:ssz", "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-ddTHH:mmZ", "yyyy-MM-ddTHH:mmz", "yyyy-MM-ddTHH:mm", "ddd, MMM dd, yyyy H:mm:ss tt", "ddd MMM d yyyy HH:mm:ss zzz", "MMddyyyy", "ddMMyyyy", "Mddyyyy", "ddMyyyy", "Mdyyyy", "dMyyyy", "yyyy", "Mdyy", "dMyy", "d" ]); // real starting rule: tries selected formats first, // then general purpose rule g.start = function (s) { try { var r = g._formats.call({}, s); if (r[1].length === 0) { return r; } } catch (e) {} return g._start.call({}, s); }; }()); (function () { var $D = Date; /** * @desc Converts the specified string value into its JavaScript Date equivalent using CultureInfo specific format information. * * Example

	///////////
	// Dates //
	///////////

	// 15-Oct-2004
	var d1 = Date.parse("10/15/2004");

	// 15-Oct-2004
	var d1 = Date.parse("15-Oct-2004");

	// 15-Oct-2004
	var d1 = Date.parse("2004.10.15");

	//Fri Oct 15, 2004
	var d1 = Date.parse("Fri Oct 15, 2004");

	///////////
	// Times //
	///////////

	// Today at 10 PM.
	var d1 = Date.parse("10 PM");

	// Today at 10:30 PM.
	var d1 = Date.parse("10:30 P.M.");

	// Today at 6 AM.
	var d1 = Date.parse("06am");

	/////////////////////
	// Dates and Times //
	/////////////////////

	// 8-July-2004 @ 10:30 PM
	var d1 = Date.parse("July 8th, 2004, 10:30 PM");

	// 1-July-2004 @ 10:30 PM
	var d1 = Date.parse("2004-07-01T22:30:00");

	////////////////////
	// Relative Dates //
	////////////////////

	// Returns today's date. The string "today" is culture specific.
	var d1 = Date.parse("today");

	// Returns yesterday's date. The string "yesterday" is culture specific.
	var d1 = Date.parse("yesterday");

	// Returns the date of the next thursday.
	var d1 = Date.parse("Next thursday");

	// Returns the date of the most previous monday.
	var d1 = Date.parse("last monday");

	// Returns today's day + one year.
	var d1 = Date.parse("next year");

	///////////////
	// Date Math //
	///////////////

	// Today + 2 days
	var d1 = Date.parse("t+2");

	// Today + 2 days
	var d1 = Date.parse("today + 2 days");

	// Today + 3 months
	var d1 = Date.parse("t+3m");

	// Today - 1 year
	var d1 = Date.parse("today - 1 year");

	// Today - 1 year
	var d1 = Date.parse("t-1y"); 


	/////////////////////////////
	// Partial Dates and Times //
	/////////////////////////////

	// July 15th of this year.
	var d1 = Date.parse("July 15");

	// 15th day of current day and year.
	var d1 = Date.parse("15");

	// July 1st of current year at 10pm.
	var d1 = Date.parse("7/1 10pm");
	
* * @param {String} The string value to convert into a Date object [Required] * @return {Date} A Date object or null if the string cannot be converted into a Date. */ var parseUtils = { removeOrds: function (s) { ords = s.match(/\b(\d+)(?:st|nd|rd|th)\b/); // find ordinal matches s = ((ords && ords.length === 2) ? s.replace(ords[0], ords[1]) : s); return s; }, grammarParser: function (s) { var r = null; try { r = $D.Grammar.start.call({}, s.replace(/^\s*(\S*(\s+\S+)*)\s*$/, "$1")); } catch (e) { return null; } return ((r[1].length === 0) ? r[0] : null); }, nativeFallback: function(s) { var t; try { // ok we haven't parsed it, last ditch attempt with the built-in parser. t = Date._parse(s); return (t || t === 0) ? new Date(t) : null; } catch (e) { return null; } } }; function parse (s) { var d; if (!s) { return null; } if (s instanceof Date) { return s.clone(); } if (s.length >= 4 && s.charAt(0) !== "0" && s.charAt(0) !== "+"&& s.charAt(0) !== "-") { // ie: 2004 will pass, 0800 won't. // Start with specific formats d = $D.Parsing.ISO.parse(s) || $D.Parsing.Numeric.parse(s); } if (d instanceof Date && !isNaN(d.getTime())) { return d; } else { // find ordinal dates (1st, 3rd, 8th, etc and remove them as they cause parsing issues) s = $D.Parsing.Normalizer.parse(parseUtils.removeOrds(s)); d = parseUtils.grammarParser(s); if (d !== null) { return d; } else { return parseUtils.nativeFallback(s); } } } if (!$D._parse) { $D._parse = $D.parse; } $D.parse = parse; Date.getParseFunction = function (fx) { var fns = Date.Grammar.allformats(fx); return function (s) { var r = null; for (var i = 0; i < fns.length; i++) { try { r = fns[i].call({}, s); } catch (e) { continue; } if (r[1].length === 0) { return r[0]; } } return null; }; }; /** * Converts the specified string value into its JavaScript Date equivalent using the specified format {String} or formats {Array} and the CultureInfo specific format information. * The format of the string value must match one of the supplied formats exactly. * * Example

	// 15-Oct-2004
	var d1 = Date.parseExact("10/15/2004", "M/d/yyyy");

	// 15-Oct-2004
	var d1 = Date.parse("15-Oct-2004", "M-ddd-yyyy");

	// 15-Oct-2004
	var d1 = Date.parse("2004.10.15", "yyyy.MM.dd");

	// Multiple formats
	var d1 = Date.parseExact("10/15/2004", ["M/d/yyyy", "MMMM d, yyyy"]);
	
* * @param {String} The string value to convert into a Date object [Required]. * @param {Object} The expected format {String} or an array of expected formats {Array} of the date string [Required]. * @return {Date} A Date object or null if the string cannot be converted into a Date. */ $D.parseExact = function (s, fx) { return $D.getParseFunction(fx)(s); }; }()); (function () { var $D = Date, $P = $D.prototype, // $C = $D.CultureInfo, // not used atm p = function (s, l) { if (!l) { l = 2; } return ("000" + s).slice(l * -1); }; /** * Converts a PHP format string to Java/.NET format string. * A PHP format string can be used with ._format or .format. * A Java/.NET format string can be used with .toString(). * The .parseExact function will only accept a Java/.NET format string * * Example * var f1 = "%m/%d/%y" * var f2 = Date.normalizeFormat(f1); // "MM/dd/yy" * * new Date().format(f1); // "04/13/08" * new Date()._format(f1); // "04/13/08" * new Date().toString(f2); // "04/13/08" * * var date = Date.parseExact("04/13/08", f2); // Sun Apr 13 2008 * * @param {String} A PHP format string consisting of one or more format spcifiers. * @return {String} The PHP format converted to a Java/.NET format string. */ var normalizerSubstitutions = { "d" : "dd", "%d": "dd", "D" : "ddd", "%a": "ddd", "j" : "dddd", "l" : "dddd", "%A": "dddd", "S" : "S", "F" : "MMMM", "%B": "MMMM", "m" : "MM", "%m": "MM", "M" : "MMM", "%b": "MMM", "%h": "MMM", "n" : "M", "Y" : "yyyy", "%Y": "yyyy", "y" : "yy", "%y": "yy", "g" : "h", "%I": "h", "G" : "H", "h" : "hh", "H" : "HH", "%H": "HH", "i" : "mm", "%M": "mm", "s" : "ss", "%S": "ss", "%r": "hh:mm tt", "%R": "H:mm", "%T": "H:mm:ss", "%X": "t", "%x": "d", "%e": "d", "%D": "MM/dd/yy", "%n": "\\n", "%t": "\\t", "e" : "z", "T" : "z", "%z": "z", "%Z": "z", "Z" : "ZZ", "N" : "u", "w" : "u", "%w": "u", "W" : "W", "%V": "W" }; var normalizer = { substitutes: function (m) { return normalizerSubstitutions[m]; }, interpreted: function (m, x) { var y; switch (m) { case "%u": return x.getDay() + 1; case "z": return x.getOrdinalNumber(); case "%j": return p(x.getOrdinalNumber(), 3); case "%U": var d1 = x.clone().set({month: 0, day: 1}).addDays(-1).moveToDayOfWeek(0), d2 = x.clone().addDays(1).moveToDayOfWeek(0, -1); return (d2 < d1) ? "00" : p((d2.getOrdinalNumber() - d1.getOrdinalNumber()) / 7 + 1); case "%W": return p(x.getWeek()); case "t": return $D.getDaysInMonth(x.getFullYear(), x.getMonth()); case "o": case "%G": return x.setWeek(x.getISOWeek()).toString("yyyy"); case "%g": return x._format("%G").slice(-2); case "a": case "%p": return t("tt").toLowerCase(); case "A": return t("tt").toUpperCase(); case "u": return p(x.getMilliseconds(), 3); case "I": return (x.isDaylightSavingTime()) ? 1 : 0; case "O": return x.getUTCOffset(); case "P": y = x.getUTCOffset(); return y.substring(0, y.length - 2) + ":" + y.substring(y.length - 2); case "B": var now = new Date(); return Math.floor(((now.getHours() * 3600) + (now.getMinutes() * 60) + now.getSeconds() + (now.getTimezoneOffset() + 60) * 60) / 86.4); case "c": return x.toISOString().replace(/\"/g, ""); case "U": return $D.strtotime("now"); case "%c": return t("d") + " " + t("t"); case "%C": return Math.floor(x.getFullYear() / 100 + 1); } }, shouldOverrideDefaults: function (m) { switch (m) { case "%e": return true; default: return false; } }, parse: function (m, context) { var formatString, c = context || new Date(); formatString = normalizer.substitutes(m); if (formatString) { return formatString; } formatString = normalizer.interpreted(m, c); if (formatString) { return formatString; } else { return m; } } }; $D.normalizeFormat = function (format, context) { return format.replace(/(%|\\)?.|%%/g, function(t){ return normalizer.parse(t, context); }); }; /** * Format a local Unix timestamp according to locale settings * * Example: * Date.strftime("%m/%d/%y", new Date()); // "04/13/08" * Date.strftime("c", "2008-04-13T17:52:03Z"); // "04/13/08" * * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @param {Number|String} The number representing the number of seconds that have elapsed since January 1, 1970 (local time). * @return {String} A string representation of the current Date object. */ $D.strftime = function (format, time) { var d = Date.parse(time); return d._format(format); }; /** * Parse any textual datetime description into a Unix timestamp. * A Unix timestamp is the number of seconds that have elapsed since January 1, 1970 (midnight UTC/GMT). * * Example: * Date.strtotime("04/13/08"); // 1208044800 * Date.strtotime("1970-01-01T00:00:00Z"); // 0 * * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @param {Object} A string or date object. * @return {String} A string representation of the current Date object. */ $D.strtotime = function (time) { var d = $D.parse(time); return Math.round($D.UTC(d.getUTCFullYear(), d.getUTCMonth(), d.getUTCDate(), d.getUTCHours(), d.getUTCMinutes(), d.getUTCSeconds(), d.getUTCMilliseconds()) / 1000); }; /** * Converts the value of the current Date object to its equivalent string representation using a PHP/Unix style of date format specifiers. * Format Specifiers * Format Description Example * ------ --------------------------------------------------------------------------- ----------------------- * %a abbreviated weekday name according to the current localed "Mon" through "Sun" * %A full weekday name according to the current localed "Sunday" through "Saturday" * %b abbreviated month name according to the current localed "Jan" through "Dec" * %B full month name according to the current locale "January" through "December" * %c preferred date and time representation for the current locale "4/13/2008 12:33 PM" * %C century number (the year divided by 100 and truncated to an integer) "00" to "99" * %d day of the month as a decimal number "01" to "31" * %D same as %m/%d/%y "04/13/08" * %e day of the month as a decimal number, a single digit is preceded by a space "1" to "31" * %g like %G, but without the century "08" * %G The 4-digit year corresponding to the ISO week number (see %V). "2008" * This has the same format and value as %Y, except that if the ISO week number * belongs to the previous or next year, that year is used instead. * %h same as %b "Jan" through "Dec" * %H hour as a decimal number using a 24-hour clock. "00" to "23" * %I hour as a decimal number using a 12-hour clock. "01" to "12" * %j day of the year as a decimal number. "001" to "366" * %m month as a decimal number. "01" to "12" * %M minute as a decimal number. "00" to "59" * %n newline character "\n" * %p either "am" or "pm" according to the given time value, or the "am" or "pm" * corresponding strings for the current locale. * %r time in a.m. and p.m. notation "8:44 PM" * %R time in 24 hour notation "20:44" * %S second as a decimal number "00" to "59" * %t tab character "\t" * %T current time, equal to %H:%M:%S "12:49:11" * %u weekday as a decimal number ["1", "7"], with "1" representing Monday "1" to "7" * %U week number of the current year as a decimal number, starting with the "0" to ("52" or "53") * first Sunday as the first day of the first week * %V The ISO 8601:1988 week number of the current year as a decimal number, "00" to ("52" or "53") * range 01 to 53, where week 1 is the first week that has at least 4 days * in the current year, and with Monday as the first day of the week. * (Use %G or %g for the year component that corresponds to the week number * for the specified timestamp.) * %W week number of the current year as a decimal number, starting with the "00" to ("52" or "53") * first Monday as the first day of the first week * %w day of the week as a decimal, Sunday being "0" "0" to "6" * %x preferred date representation for the current locale without the time "4/13/2008" * %X preferred time representation for the current locale without the date "12:53:05" * %y year as a decimal number without a century "00" "99" * %Y year as a decimal number including the century "2008" * %Z time zone or name or abbreviation "UTC", "EST", "PST" * %z same as %Z * %% a literal "%" characters "%" * d Day of the month, 2 digits with leading zeros "01" to "31" * D A textual representation of a day, three letters "Mon" through "Sun" * j Day of the month without leading zeros "1" to "31" * l A full textual representation of the day of the week (lowercase "L") "Sunday" through "Saturday" * N ISO-8601 numeric representation of the day of the week (added in PHP 5.1.0) "1" (for Monday) through "7" (for Sunday) * S English ordinal suffix for the day of the month, 2 characters "st", "nd", "rd" or "th". Works well with j * w Numeric representation of the day of the week "0" (for Sunday) through "6" (for Saturday) * z The day of the year (starting from "0") "0" through "365" * W ISO-8601 week number of year, weeks starting on Monday "00" to ("52" or "53") * F A full textual representation of a month, such as January or March "January" through "December" * m Numeric representation of a month, with leading zeros "01" through "12" * M A short textual representation of a month, three letters "Jan" through "Dec" * n Numeric representation of a month, without leading zeros "1" through "12" * t Number of days in the given month "28" through "31" * L Whether it's a leap year "1" if it is a leap year, "0" otherwise * o ISO-8601 year number. This has the same value as Y, except that if the "2008" * ISO week number (W) belongs to the previous or next year, that year * is used instead. * Y A full numeric representation of a year, 4 digits "2008" * y A two digit representation of a year "08" * a Lowercase Ante meridiem and Post meridiem "am" or "pm" * A Uppercase Ante meridiem and Post meridiem "AM" or "PM" * B Swatch Internet time "000" through "999" * g 12-hour format of an hour without leading zeros "1" through "12" * G 24-hour format of an hour without leading zeros "0" through "23" * h 12-hour format of an hour with leading zeros "01" through "12" * H 24-hour format of an hour with leading zeros "00" through "23" * i Minutes with leading zeros "00" to "59" * s Seconds, with leading zeros "00" through "59" * u Milliseconds "54321" * e Timezone identifier "UTC", "EST", "PST" * I Whether or not the date is in daylight saving time (uppercase i) "1" if Daylight Saving Time, "0" otherwise * O Difference to Greenwich time (GMT) in hours "+0200", "-0600" * P Difference to Greenwich time (GMT) with colon between hours and minutes "+02:00", "-06:00" * T Timezone abbreviation "UTC", "EST", "PST" * Z Timezone offset in seconds. The offset for timezones west of UTC is "-43200" through "50400" * always negative, and for those east of UTC is always positive. * c ISO 8601 date "2004-02-12T15:19:21+00:00" * r RFC 2822 formatted date "Thu, 21 Dec 2000 16:01:07 +0200" * U Seconds since the Unix Epoch (January 1 1970 00:00:00 GMT) "0" * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @return {String} A string representation of the current Date object. */ var formatReplace = function (context) { return function (m) { var formatString, override = false; if (m.charAt(0) === "\\" || m.substring(0, 2) === "%%") { return m.replace("\\", "").replace("%%", "%"); } override = normalizer.shouldOverrideDefaults(m); formatString = $D.normalizeFormat(m, context); if (formatString) { return context.toString(formatString, override); } }; }; $P._format = function (format) { var formatter = formatReplace(this); if (!format) { return this._toString(); } else { return format.replace(/(%|\\)?.|%%/g, formatter); } }; if (!$P.format) { $P.format = $P._format; } }()); (function () { "use strict"; var gFn = function (attr) { return function () { return this[attr]; }; }; var sFn = function (attr) { return function (val) { this[attr] = val; return this; }; }; var attrs = ["years", "months", "days", "hours", "minutes", "seconds", "milliseconds"]; var addSetFuncs = function (context, attrs) { for (var i = 0; i < attrs.length ; i++) { var $a = attrs[i], $b = $a.slice(0, 1).toUpperCase() + $a.slice(1); context.prototype[$a] = 0; context.prototype["get" + $b] = gFn($a); context.prototype["set" + $b] = sFn($a); } }; /** * new TimeSpan(milliseconds); * new TimeSpan(days, hours, minutes, seconds); * new TimeSpan(days, hours, minutes, seconds, milliseconds); */ var TimeSpan = function (days, hours, minutes, seconds, milliseconds) { if (arguments.length === 1 && typeof days === "number") { var orient = (days < 0) ? -1 : +1; var millsLeft = Math.abs(days); this.setDays(Math.floor(millsLeft / 86400000) * orient); millsLeft = millsLeft % 86400000; this.setHours(Math.floor(millsLeft / 3600000) * orient); millsLeft = millsLeft % 3600000; this.setMinutes(Math.floor(millsLeft / 60000) * orient); millsLeft = millsLeft % 60000; this.setSeconds(Math.floor(millsLeft / 1000) * orient); millsLeft = millsLeft % 1000; this.setMilliseconds(millsLeft * orient); } else { this.set(days, hours, minutes, seconds, milliseconds); } this.getTotalMilliseconds = function () { return (this.getDays() * 86400000) + (this.getHours() * 3600000) + (this.getMinutes() * 60000) + (this.getSeconds() * 1000); }; this.compareTo = function (time) { var t1 = new Date(1970, 1, 1, this.getHours(), this.getMinutes(), this.getSeconds()), t2; if (time === null) { t2 = new Date(1970, 1, 1, 0, 0, 0); } else { t2 = new Date(1970, 1, 1, time.getHours(), time.getMinutes(), time.getSeconds()); } return (t1 < t2) ? -1 : (t1 > t2) ? 1 : 0; }; this.equals = function (time) { return (this.compareTo(time) === 0); }; this.add = function (time) { return (time === null) ? this : this.addSeconds(time.getTotalMilliseconds() / 1000); }; this.subtract = function (time) { return (time === null) ? this : this.addSeconds(-time.getTotalMilliseconds() / 1000); }; this.addDays = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 86400000)); }; this.addHours = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 3600000)); }; this.addMinutes = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 60000)); }; this.addSeconds = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 1000)); }; this.addMilliseconds = function (n) { return new TimeSpan(this.getTotalMilliseconds() + n); }; this.get12HourHour = function () { return (this.getHours() > 12) ? this.getHours() - 12 : (this.getHours() === 0) ? 12 : this.getHours(); }; this.getDesignator = function () { return (this.getHours() < 12) ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator; }; this.toString = function (format) { this._toString = function () { if (this.getDays() !== null && this.getDays() > 0) { return this.getDays() + "." + this.getHours() + ":" + this.p(this.getMinutes()) + ":" + this.p(this.getSeconds()); } else { return this.getHours() + ":" + this.p(this.getMinutes()) + ":" + this.p(this.getSeconds()); } }; this.p = function (s) { return (s.toString().length < 2) ? "0" + s : s; }; var me = this; return format ? format.replace(/dd?|HH?|hh?|mm?|ss?|tt?/g, function (format) { switch (format) { case "d": return me.getDays(); case "dd": return me.p(me.getDays()); case "H": return me.getHours(); case "HH": return me.p(me.getHours()); case "h": return me.get12HourHour(); case "hh": return me.p(me.get12HourHour()); case "m": return me.getMinutes(); case "mm": return me.p(me.getMinutes()); case "s": return me.getSeconds(); case "ss": return me.p(me.getSeconds()); case "t": return ((me.getHours() < 12) ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator).substring(0, 1); case "tt": return (me.getHours() < 12) ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator; } } ) : this._toString(); }; return this; }; addSetFuncs(TimeSpan, attrs.slice(2)); TimeSpan.prototype.set = function (days, hours, minutes, seconds, milliseconds){ this.setDays(days || this.getDays()); this.setHours(hours || this.getHours()); this.setMinutes(minutes || this.getMinutes()); this.setSeconds(seconds || this.getSeconds()); this.setMilliseconds(milliseconds || this.getMilliseconds()); }; /** * Gets the time of day for this date instances. * @return {TimeSpan} TimeSpan */ Date.prototype.getTimeOfDay = function () { return new TimeSpan(0, this.getHours(), this.getMinutes(), this.getSeconds(), this.getMilliseconds()); }; Date.TimeSpan = TimeSpan; if (typeof window !== "undefined" ) { // keeping API compatible for v1.x window.TimeSpan = TimeSpan; } }()); (function () { "use strict"; var attrs = ["years", "months", "days", "hours", "minutes", "seconds", "milliseconds"]; var gFn = function (attr) { return function () { return this[attr]; }; }; var sFn = function (attr) { return function (val) { this[attr] = val; return this; }; }; var addSetFuncs = function (context, attrs) { for (var i = 0; i < attrs.length ; i++) { var $a = attrs[i], $b = $a.slice(0, 1).toUpperCase() + $a.slice(1); context.prototype[$a] = 0; context.prototype["get" + $b] = gFn($a); context.prototype["set" + $b] = sFn($a); } }; var setMonthsAndYears = function (orient, d1, d2, context) { function inc() { d1.addMonths(-orient); context.months++; if (context.months === 12) { context.years++; context.months = 0; } } if (orient === +1) { while (d1 > d2) { inc(); } } else { while (d1 < d2) { inc(); } } context.months--; context.months *= orient; context.years *= orient; }; var adjustForDST = function(orient, startDate, endDate) { var hasDSTMismatch = (false === (startDate.isDaylightSavingTime() === endDate.isDaylightSavingTime())); if (hasDSTMismatch && orient === 1) { startDate.addHours(-1); } else if (hasDSTMismatch) { startDate.addHours(1); } }; /** * TimePeriod(startDate, endDate); * TimePeriod(years, months, days, hours, minutes, seconds, milliseconds); */ var TimePeriod = function (years, months, days, hours, minutes, seconds, milliseconds) { if (arguments.length === 7) { this.set(years, months, days, hours, minutes, seconds, milliseconds); } else if (arguments.length === 2 && arguments[0] instanceof Date && arguments[1] instanceof Date) { var startDate = arguments[0].clone(); var endDate = arguments[1].clone(); var orient = (startDate > endDate) ? +1 : -1; this.dates = { start: arguments[0].clone(), end: arguments[1].clone() }; setMonthsAndYears(orient, startDate, endDate, this); adjustForDST(orient, startDate, endDate); // // TODO - adjust for DST var diff = endDate - startDate; if (diff !== 0) { var ts = new TimeSpan(diff); this.set(this.years, this.months, ts.getDays(), ts.getHours(), ts.getMinutes(), ts.getSeconds(), ts.getMilliseconds()); } } return this; }; // create all the set functions. addSetFuncs(TimePeriod, attrs); TimePeriod.prototype.set = function (years, months, days, hours, minutes, seconds, milliseconds){ this.setYears(years || this.getYears()); this.setMonths(months || this.getMonths()); this.setDays(days || this.getDays()); this.setHours(hours || this.getHours()); this.setMinutes(minutes || this.getMinutes()); this.setSeconds(seconds || this.getSeconds()); this.setMilliseconds(milliseconds || this.getMilliseconds()); }; Date.TimePeriod = TimePeriod; if (typeof window !== "undefined") { // keeping API compatible for v1.x window.TimePeriod = TimePeriod; } }()); ================================================ FILE: build/date-ar-DZ.js ================================================ /** * @overview datejs * @version 1.0.0-rc3 * @author Gregory Wild-Smith * @copyright 2015 Gregory Wild-Smith * @license MIT * @homepage https://github.com/abritinthebay/datejs */ /* * DateJS Culture String File * Country Code: ar-DZ * Name: Arabic (Algeria) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["ar-DZ"] = { "name": "ar-DZ", "englishName": "Arabic (Algeria)", "nativeName": "العربية (الجزائر)", "Sunday": "الاحد", "Monday": "الاثنين", "Tuesday": "الثلاثاء", "Wednesday": "الاربعاء", "Thursday": "الخميس", "Friday": "الجمعة", "Saturday": "السبت", "Sun": "الاحد", "Mon": "الاثنين", "Tue": "الثلاثاء", "Wed": "الاربعاء", "Thu": "الخميس", "Fri": "الجمعة", "Sat": "السبت", "Su": "أ", "Mo": "ا", "Tu": "ث", "We": "أ", "Th": "خ", "Fr": "ج", "Sa": "س", "S_Sun_Initial": "أ", "M_Mon_Initial": "ا", "T_Tue_Initial": "ث", "W_Wed_Initial": "أ", "T_Thu_Initial": "خ", "F_Fri_Initial": "ج", "S_Sat_Initial": "س", "January": "جانفييه", "February": "فيفرييه", "March": "مارس", "April": "أفريل", "May": "مي", "June": "جوان", "July": "جوييه", "August": "أوت", "September": "سبتمبر", "October": "اكتوبر", "November": "نوفمبر", "December": "ديسمبر", "Jan_Abbr": "جانفييه", "Feb_Abbr": "فيفرييه", "Mar_Abbr": "مارس", "Apr_Abbr": "أفريل", "May_Abbr": "مي", "Jun_Abbr": "جوان", "Jul_Abbr": "جوييه", "Aug_Abbr": "أوت", "Sep_Abbr": "سبتمبر", "Oct_Abbr": "اكتوبر", "Nov_Abbr": "نوفمبر", "Dec_Abbr": "ديسمبر", "AM": "ص", "PM": "م", "firstDayOfWeek": 6, "twoDigitYearMax": 2029, "mdy": "dmy", "M/d/yyyy": "dd-MM-yyyy", "dddd, MMMM dd, yyyy": "dd MMMM, yyyy", "h:mm tt": "H:mm", "h:mm:ss tt": "H:mm:ss", "dddd, MMMM dd, yyyy h:mm:ss tt": "dd MMMM, yyyy H:mm:ss", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "dd MMMM", "MMMM, yyyy": "MMMM, yyyy", "/jan(uary)?/": "جانفييه", "/feb(ruary)?/": "فيفرييه", "/mar(ch)?/": "مارس", "/apr(il)?/": "أفريل", "/may/": "مي", "/jun(e)?/": "جوان", "/jul(y)?/": "جوييه", "/aug(ust)?/": "أوت", "/sep(t(ember)?)?/": "سبتمبر", "/oct(ober)?/": "اكتوبر", "/nov(ember)?/": "نوفمبر", "/dec(ember)?/": "ديسمبر", "/^su(n(day)?)?/": "^الاحد", "/^mo(n(day)?)?/": "^ا(1)?", "/^tu(e(s(day)?)?)?/": "^الثلاثاء", "/^we(d(nesday)?)?/": "^الاربعاء", "/^th(u(r(s(day)?)?)?)?/": "^الخميس", "/^fr(i(day)?)?/": "^الجمعة", "/^sa(t(urday)?)?/": "^السبت", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "ar-DZ"; /** * @overview datejs * @version 1.0.0-rc3 * @author Gregory Wild-Smith * @copyright 2015 Gregory Wild-Smith * @license MIT * @homepage https://github.com/abritinthebay/datejs */(function () { var $D = Date; var lang = Date.CultureStrings ? Date.CultureStrings.lang : null; var loggedKeys = {}; // for debug purposes. var getText = { getFromKey: function (key, countryCode) { var output; if (Date.CultureStrings && Date.CultureStrings[countryCode] && Date.CultureStrings[countryCode][key]) { output = Date.CultureStrings[countryCode][key]; } else { output = getText.buildFromDefault(key); } if (key.charAt(0) === "/") { // Assume it's a regex output = getText.buildFromRegex(key, countryCode); } return output; }, getFromObjectValues: function (obj, countryCode) { var key, output = {}; for(key in obj) { if (obj.hasOwnProperty(key)) { output[key] = getText.getFromKey(obj[key], countryCode); } } return output; }, getFromObjectKeys: function (obj, countryCode) { var key, output = {}; for(key in obj) { if (obj.hasOwnProperty(key)) { output[getText.getFromKey(key, countryCode)] = obj[key]; } } return output; }, getFromArray: function (arr, countryCode) { var output = []; for (var i=0; i < arr.length; i++){ if (i in arr) { output[i] = getText.getFromKey(arr[i], countryCode); } } return output; }, buildFromDefault: function (key) { var output, length, split, last; switch(key) { case "name": output = "en-US"; break; case "englishName": output = "English (United States)"; break; case "nativeName": output = "English (United States)"; break; case "twoDigitYearMax": output = 2049; break; case "firstDayOfWeek": output = 0; break; default: output = key; split = key.split("_"); length = split.length; if (length > 1 && key.charAt(0) !== "/") { // if the key isn't a regex and it has a split. last = split[(length - 1)].toLowerCase(); if (last === "initial" || last === "abbr") { output = split[0]; } } break; } return output; }, buildFromRegex: function (key, countryCode) { var output; if (Date.CultureStrings && Date.CultureStrings[countryCode] && Date.CultureStrings[countryCode][key]) { output = new RegExp(Date.CultureStrings[countryCode][key], "i"); } else { output = new RegExp(key.replace(new RegExp("/", "g"),""), "i"); } return output; } }; var shallowMerge = function (obj1, obj2) { for (var attrname in obj2) { if (obj2.hasOwnProperty(attrname)) { obj1[attrname] = obj2[attrname]; } } }; var __ = function (key, language) { var countryCode = (language) ? language : lang; loggedKeys[key] = key; if (typeof key === "object") { if (key instanceof Array) { return getText.getFromArray(key, countryCode); } else { return getText.getFromObjectKeys(key, countryCode); } } else { return getText.getFromKey(key, countryCode); } }; var loadI18nScript = function (code) { // paatterned after jQuery's getScript. var url = Date.Config.i18n + code + ".js"; var head = document.getElementsByTagName("head")[0] || document.documentElement; var script = document.createElement("script"); script.src = url; var completed = false; var events = { done: function (){} // placeholder function }; // Attach handlers for all browsers script.onload = script.onreadystatechange = function() { if ( !completed && (!this.readyState || this.readyState === "loaded" || this.readyState === "complete") ) { events.done(); head.removeChild(script); } }; setTimeout(function() { head.insertBefore(script, head.firstChild); }, 0); // allows return to execute first return { done: function (cb) { events.done = function() { if (cb) { setTimeout(cb,0); } }; } }; }; var buildInfo = { buildFromMethodHash: function (obj) { var key; for(key in obj) { if (obj.hasOwnProperty(key)) { obj[key] = buildInfo[obj[key]](); } } return obj; }, timeZoneDST: function () { var DST = { "CHADT": "+1345", "NZDT": "+1300", "AEDT": "+1100", "ACDT": "+1030", "AZST": "+0500", "IRDT": "+0430", "EEST": "+0300", "CEST": "+0200", "BST": "+0100", "PMDT": "-0200", "ADT": "-0300", "NDT": "-0230", "EDT": "-0400", "CDT": "-0500", "MDT": "-0600", "PDT": "-0700", "AKDT": "-0800", "HADT": "-0900" }; return __(DST); }, timeZoneStandard: function () { var standard = { "LINT": "+1400", "TOT": "+1300", "CHAST": "+1245", "NZST": "+1200", "NFT": "+1130", "SBT": "+1100", "AEST": "+1000", "ACST": "+0930", "JST": "+0900", "CWST": "+0845", "CT": "+0800", "ICT": "+0700", "MMT": "+0630", "BST": "+0600", "NPT": "+0545", "IST": "+0530", "PKT": "+0500", "AFT": "+0430", "MSK": "+0400", "IRST": "+0330", "FET": "+0300", "EET": "+0200", "CET": "+0100", "GMT": "+0000", "UTC": "+0000", "CVT": "-0100", "GST": "-0200", "BRT": "-0300", "NST": "-0330", "AST": "-0400", "EST": "-0500", "CST": "-0600", "MST": "-0700", "PST": "-0800", "AKST": "-0900", "MIT": "-0930", "HST": "-1000", "SST": "-1100", "BIT": "-1200" }; return __(standard); }, timeZones: function (data) { var zone; data.timezones = []; for (zone in data.abbreviatedTimeZoneStandard) { if (data.abbreviatedTimeZoneStandard.hasOwnProperty(zone)) { data.timezones.push({ name: zone, offset: data.abbreviatedTimeZoneStandard[zone]}); } } for (zone in data.abbreviatedTimeZoneDST) { if (data.abbreviatedTimeZoneDST.hasOwnProperty(zone)) { data.timezones.push({ name: zone, offset: data.abbreviatedTimeZoneDST[zone], dst: true}); } } return data.timezones; }, days: function () { return __(["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"]); }, dayAbbr: function () { return __(["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"]); }, dayShortNames: function () { return __(["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"]); }, dayFirstLetters: function () { return __(["S_Sun_Initial", "M_Mon_Initial", "T_Tues_Initial", "W_Wed_Initial", "T_Thu_Initial", "F_Fri_Initial", "S_Sat_Initial"]); }, months: function () { return __(["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"]); }, monthAbbr: function () { return __(["Jan_Abbr", "Feb_Abbr", "Mar_Abbr", "Apr_Abbr", "May_Abbr", "Jun_Abbr", "Jul_Abbr", "Aug_Abbr", "Sep_Abbr", "Oct_Abbr", "Nov_Abbr", "Dec_Abbr"]); }, formatPatterns: function () { return getText.getFromObjectValues({ shortDate: "M/d/yyyy", longDate: "dddd, MMMM dd, yyyy", shortTime: "h:mm tt", longTime: "h:mm:ss tt", fullDateTime: "dddd, MMMM dd, yyyy h:mm:ss tt", sortableDateTime: "yyyy-MM-ddTHH:mm:ss", universalSortableDateTime: "yyyy-MM-dd HH:mm:ssZ", rfc1123: "ddd, dd MMM yyyy HH:mm:ss", monthDay: "MMMM dd", yearMonth: "MMMM, yyyy" }, Date.i18n.currentLanguage()); }, regex: function () { return getText.getFromObjectValues({ inTheMorning: "/( in the )(morn(ing)?)\\b/", thisMorning: "/(this )(morn(ing)?)\\b/", amThisMorning: "/(\b\\d(am)? )(this )(morn(ing)?)/", inTheEvening: "/( in the )(even(ing)?)\\b/", thisEvening: "/(this )(even(ing)?)\\b/", pmThisEvening: "/(\b\\d(pm)? )(this )(even(ing)?)/", jan: "/jan(uary)?/", feb: "/feb(ruary)?/", mar: "/mar(ch)?/", apr: "/apr(il)?/", may: "/may/", jun: "/jun(e)?/", jul: "/jul(y)?/", aug: "/aug(ust)?/", sep: "/sep(t(ember)?)?/", oct: "/oct(ober)?/", nov: "/nov(ember)?/", dec: "/dec(ember)?/", sun: "/^su(n(day)?)?/", mon: "/^mo(n(day)?)?/", tue: "/^tu(e(s(day)?)?)?/", wed: "/^we(d(nesday)?)?/", thu: "/^th(u(r(s(day)?)?)?)?/", fri: "/fr(i(day)?)?/", sat: "/^sa(t(urday)?)?/", future: "/^next/", past: "/^last|past|prev(ious)?/", add: "/^(\\+|aft(er)?|from|hence)/", subtract: "/^(\\-|bef(ore)?|ago)/", yesterday: "/^yes(terday)?/", today: "/^t(od(ay)?)?/", tomorrow: "/^tom(orrow)?/", now: "/^n(ow)?/", millisecond: "/^ms|milli(second)?s?/", second: "/^sec(ond)?s?/", minute: "/^mn|min(ute)?s?/", hour: "/^h(our)?s?/", week: "/^w(eek)?s?/", month: "/^m(onth)?s?/", day: "/^d(ay)?s?/", year: "/^y(ear)?s?/", shortMeridian: "/^(a|p)/", longMeridian: "/^(a\\.?m?\\.?|p\\.?m?\\.?)/", timezone: "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/", ordinalSuffix: "/^\\s*(st|nd|rd|th)/", timeContext: "/^\\s*(\\:|a(?!u|p)|p)/" }, Date.i18n.currentLanguage()); } }; var CultureInfo = function () { var info = getText.getFromObjectValues({ name: "name", englishName: "englishName", nativeName: "nativeName", amDesignator: "AM", pmDesignator: "PM", firstDayOfWeek: "firstDayOfWeek", twoDigitYearMax: "twoDigitYearMax", dateElementOrder: "mdy" }, Date.i18n.currentLanguage()); var constructedInfo = buildInfo.buildFromMethodHash({ dayNames: "days", abbreviatedDayNames: "dayAbbr", shortestDayNames: "dayShortNames", firstLetterDayNames: "dayFirstLetters", monthNames: "months", abbreviatedMonthNames: "monthAbbr", formatPatterns: "formatPatterns", regexPatterns: "regex", abbreviatedTimeZoneDST: "timeZoneDST", abbreviatedTimeZoneStandard: "timeZoneStandard" }); shallowMerge(info, constructedInfo); buildInfo.timeZones(info); return info; }; $D.i18n = { __: function (key, lang) { return __(key, lang); }, currentLanguage: function () { return lang || "en-US"; }, setLanguage: function (code, force, cb) { var async = false; if (force || code === "en-US" || (!!Date.CultureStrings && !!Date.CultureStrings[code])) { lang = code; Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings.lang = code; Date.CultureInfo = new CultureInfo(); } else { if (!(!!Date.CultureStrings && !!Date.CultureStrings[code])) { if (typeof exports !== "undefined" && this.exports !== exports) { // we're in a Node enviroment, load it using require try { require("../i18n/" + code + ".js"); lang = code; Date.CultureStrings.lang = code; Date.CultureInfo = new CultureInfo(); } catch (e) { // var str = "The language for '" + code + "' could not be loaded by Node. It likely does not exist."; throw new Error("The DateJS IETF language tag '" + code + "' could not be loaded by Node. It likely does not exist."); } } else if (Date.Config && Date.Config.i18n) { // we know the location of the files, so lets load them async = true; loadI18nScript(code).done(function(){ lang = code; Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings.lang = code; Date.CultureInfo = new CultureInfo(); $D.Parsing.Normalizer.buildReplaceData(); // because this is async if ($D.Grammar) { $D.Grammar.buildGrammarFormats(); // so we can parse those strings... } if (cb) { setTimeout(cb,0); } }); } else { Date.console.error("The DateJS IETF language tag '" + code + "' is not available and has not been loaded."); return false; } } } $D.Parsing.Normalizer.buildReplaceData(); // rebuild normalizer strings if ($D.Grammar) { $D.Grammar.buildGrammarFormats(); // so we can parse those strings... } if (!async && cb) { setTimeout(cb,0); } }, getLoggedKeys: function () { return loggedKeys; }, updateCultureInfo: function () { Date.CultureInfo = new CultureInfo(); } }; $D.i18n.updateCultureInfo(); // run automatically }()); (function () { var $D = Date, $P = $D.prototype, p = function (s, l) { if (!l) { l = 2; } return ("000" + s).slice(l * -1); }; if (typeof window !== "undefined" && typeof window.console !== "undefined" && typeof window.console.log !== "undefined") { $D.console = console; // used only to raise non-critical errors if available } else { // set mock so we don't give errors. $D.console = { log: function(){}, error: function(){} }; } $D.Config = $D.Config || {}; $D.initOverloads = function() { /** * Overload of Date.now. Allows an alternate call for Date.now where it returns the * current Date as an object rather than just milliseconds since the Unix Epoch. * * Also provides an implementation of now() for browsers (IE<9) that don't have it. * * Backwards compatible so with work with either: * Date.now() [returns ms] * or * Date.now(true) [returns Date] */ if (!$D.now) { $D._now = function now() { return new Date().getTime(); }; } else if (!$D._now) { $D._now = $D.now; } $D.now = function (returnObj) { if (returnObj) { return $D.present(); } else { return $D._now(); } }; if ( !$P.toISOString ) { $P.toISOString = function() { return this.getUTCFullYear() + "-" + p(this.getUTCMonth() + 1) + "-" + p(this.getUTCDate()) + "T" + p(this.getUTCHours()) + ":" + p(this.getUTCMinutes()) + ":" + p(this.getUTCSeconds()) + "." + String( (this.getUTCMilliseconds()/1000).toFixed(3)).slice(2, 5) + "Z"; }; } // private if ( $P._toString === undefined ){ $P._toString = $P.toString; } }; $D.initOverloads(); /** * Gets a date that is set to the current date. The time is set to the start of the day (00:00 or 12:00 AM). * @return {Date} The current date. */ $D.today = function () { return new Date().clearTime(); }; /** * Gets a date that is set to the current date and time (same as new Date, but chainable) * @return {Date} The current date. */ $D.present = function () { return new Date(); }; /** * Compares the first date to the second date and returns an number indication of their relative values. * @param {Date} First Date object to compare [Required]. * @param {Date} Second Date object to compare to [Required]. * @return {Number} -1 = date1 is lessthan date2. 0 = values are equal. 1 = date1 is greaterthan date2. */ $D.compare = function (date1, date2) { if (isNaN(date1) || isNaN(date2)) { throw new Error(date1 + " - " + date2); } else if (date1 instanceof Date && date2 instanceof Date) { return (date1 < date2) ? -1 : (date1 > date2) ? 1 : 0; } else { throw new TypeError(date1 + " - " + date2); } }; /** * Compares the first Date object to the second Date object and returns true if they are equal. * @param {Date} First Date object to compare [Required] * @param {Date} Second Date object to compare to [Required] * @return {Boolean} true if dates are equal. false if they are not equal. */ $D.equals = function (date1, date2) { return (date1.compareTo(date2) === 0); }; /** * Gets the language appropriate day name when given the day number(0-6) * eg - 0 == Sunday * @return {String} The day name */ $D.getDayName = function (n) { return Date.CultureInfo.dayNames[n]; }; /** * Gets the day number (0-6) if given a CultureInfo specific string which is a valid dayName, abbreviatedDayName or shortestDayName (two char). * @param {String} The name of the day (eg. "Monday, "Mon", "tuesday", "tue", "We", "we"). * @return {Number} The day number */ $D.getDayNumberFromName = function (name) { var n = Date.CultureInfo.dayNames, m = Date.CultureInfo.abbreviatedDayNames, o = Date.CultureInfo.shortestDayNames, s = name.toLowerCase(); for (var i = 0; i < n.length; i++) { if (n[i].toLowerCase() === s || m[i].toLowerCase() === s || o[i].toLowerCase() === s) { return i; } } return -1; }; /** * Gets the month number (0-11) if given a Culture Info specific string which is a valid monthName or abbreviatedMonthName. * @param {String} The name of the month (eg. "February, "Feb", "october", "oct"). * @return {Number} The day number */ $D.getMonthNumberFromName = function (name) { var n = Date.CultureInfo.monthNames, m = Date.CultureInfo.abbreviatedMonthNames, s = name.toLowerCase(); for (var i = 0; i < n.length; i++) { if (n[i].toLowerCase() === s || m[i].toLowerCase() === s) { return i; } } return -1; }; /** * Gets the language appropriate month name when given the month number(0-11) * eg - 0 == January * @return {String} The month name */ $D.getMonthName = function (n) { return Date.CultureInfo.monthNames[n]; }; /** * Determines if the current date instance is within a LeapYear. * @param {Number} The year. * @return {Boolean} true if date is within a LeapYear, otherwise false. */ $D.isLeapYear = function (year) { return ((year % 4 === 0 && year % 100 !== 0) || year % 400 === 0); }; /** * Gets the number of days in the month, given a year and month value. Automatically corrects for LeapYear. * @param {Number} The year. * @param {Number} The month (0-11). * @return {Number} The number of days in the month. */ $D.getDaysInMonth = function (year, month) { if (!month && $D.validateMonth(year)) { month = year; year = Date.today().getFullYear(); } return [31, ($D.isLeapYear(year) ? 29 : 28), 31, 30, 31, 30, 31, 31, 30, 31, 30, 31][month]; }; $P.getDaysInMonth = function () { return $D.getDaysInMonth(this.getFullYear(), this.getMonth()); }; $D.getTimezoneAbbreviation = function (offset, dst) { var p, n = (dst || false) ? Date.CultureInfo.abbreviatedTimeZoneDST : Date.CultureInfo.abbreviatedTimeZoneStandard; for (p in n) { if (n.hasOwnProperty(p)) { if (n[p] === offset) { return p; } } } return null; }; $D.getTimezoneOffset = function (name, dst) { var i, a =[], z = Date.CultureInfo.timezones; if (!name) { name = (new Date()).getTimezone();} for (i = 0; i < z.length; i++) { if (z[i].name === name.toUpperCase()) { a.push(i); } } if (!z[a[0]]) { return null; } if (a.length === 1 || !dst) { return z[a[0]].offset; } else { for (i=0; i < a.length; i++) { if (z[a[i]].dst) { return z[a[i]].offset; } } } }; $D.getQuarter = function (d) { d = d || new Date(); // If no date supplied, use today var q = [1,2,3,4]; return q[Math.floor(d.getMonth() / 3)]; // ~~~ is a bitwise op. Faster than Math.floor }; $D.getDaysLeftInQuarter = function (d) { d = d || new Date(); var qEnd = new Date(d); qEnd.setMonth(qEnd.getMonth() + 3 - qEnd.getMonth() % 3, 0); return Math.floor((qEnd - d) / 8.64e7); }; // private var validate = function (n, min, max, name) { name = name ? name : "Object"; if (typeof n === "undefined") { return false; } else if (typeof n !== "number") { throw new TypeError(n + " is not a Number."); } else if (n < min || n > max) { // As failing validation is *not* an exceptional circumstance // lets not throw a RangeError Exception here. // It's semantically correct but it's not sensible. return false; } return true; }; /** * Validates the number is within an acceptable range for milliseconds [0-999]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateMillisecond = function (value) { return validate(value, 0, 999, "millisecond"); }; /** * Validates the number is within an acceptable range for seconds [0-59]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateSecond = function (value) { return validate(value, 0, 59, "second"); }; /** * Validates the number is within an acceptable range for minutes [0-59]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateMinute = function (value) { return validate(value, 0, 59, "minute"); }; /** * Validates the number is within an acceptable range for hours [0-23]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateHour = function (value) { return validate(value, 0, 23, "hour"); }; /** * Validates the number is within an acceptable range for the days in a month [0-MaxDaysInMonth]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateDay = function (value, year, month) { if (year === undefined || year === null || month === undefined || month === null) { return false;} return validate(value, 1, $D.getDaysInMonth(year, month), "day"); }; /** * Validates the number is within an acceptable range for months [0-11]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateWeek = function (value) { return validate(value, 0, 53, "week"); }; /** * Validates the number is within an acceptable range for months [0-11]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateMonth = function (value) { return validate(value, 0, 11, "month"); }; /** * Validates the number is within an acceptable range for years. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateYear = function (value) { /** * Per ECMAScript spec the range of times supported by Date objects is * exactly -100,000,000 days to +100,000,000 days measured relative to * midnight at the beginning of 01 January, 1970 UTC. * This gives a range of 8,640,000,000,000,000 milliseconds to either * side of 01 January, 1970 UTC. * * Earliest possible date: Tue, 20 Apr 271,822 B.C. 00:00:00 UTC * Latest possible date: Sat, 13 Sep 275,760 00:00:00 UTC */ return validate(value, -271822, 275760, "year"); }; $D.validateTimezone = function(value) { var timezones = {"ACDT":1,"ACST":1,"ACT":1,"ADT":1,"AEDT":1,"AEST":1,"AFT":1,"AKDT":1,"AKST":1,"AMST":1,"AMT":1,"ART":1,"AST":1,"AWDT":1,"AWST":1,"AZOST":1,"AZT":1,"BDT":1,"BIOT":1,"BIT":1,"BOT":1,"BRT":1,"BST":1,"BTT":1,"CAT":1,"CCT":1,"CDT":1,"CEDT":1,"CEST":1,"CET":1,"CHADT":1,"CHAST":1,"CHOT":1,"ChST":1,"CHUT":1,"CIST":1,"CIT":1,"CKT":1,"CLST":1,"CLT":1,"COST":1,"COT":1,"CST":1,"CT":1,"CVT":1,"CWST":1,"CXT":1,"DAVT":1,"DDUT":1,"DFT":1,"EASST":1,"EAST":1,"EAT":1,"ECT":1,"EDT":1,"EEDT":1,"EEST":1,"EET":1,"EGST":1,"EGT":1,"EIT":1,"EST":1,"FET":1,"FJT":1,"FKST":1,"FKT":1,"FNT":1,"GALT":1,"GAMT":1,"GET":1,"GFT":1,"GILT":1,"GIT":1,"GMT":1,"GST":1,"GYT":1,"HADT":1,"HAEC":1,"HAST":1,"HKT":1,"HMT":1,"HOVT":1,"HST":1,"ICT":1,"IDT":1,"IOT":1,"IRDT":1,"IRKT":1,"IRST":1,"IST":1,"JST":1,"KGT":1,"KOST":1,"KRAT":1,"KST":1,"LHST":1,"LINT":1,"MAGT":1,"MART":1,"MAWT":1,"MDT":1,"MET":1,"MEST":1,"MHT":1,"MIST":1,"MIT":1,"MMT":1,"MSK":1,"MST":1,"MUT":1,"MVT":1,"MYT":1,"NCT":1,"NDT":1,"NFT":1,"NPT":1,"NST":1,"NT":1,"NUT":1,"NZDT":1,"NZST":1,"OMST":1,"ORAT":1,"PDT":1,"PET":1,"PETT":1,"PGT":1,"PHOT":1,"PHT":1,"PKT":1,"PMDT":1,"PMST":1,"PONT":1,"PST":1,"PYST":1,"PYT":1,"RET":1,"ROTT":1,"SAKT":1,"SAMT":1,"SAST":1,"SBT":1,"SCT":1,"SGT":1,"SLST":1,"SRT":1,"SST":1,"SYOT":1,"TAHT":1,"THA":1,"TFT":1,"TJT":1,"TKT":1,"TLT":1,"TMT":1,"TOT":1,"TVT":1,"UCT":1,"ULAT":1,"UTC":1,"UYST":1,"UYT":1,"UZT":1,"VET":1,"VLAT":1,"VOLT":1,"VOST":1,"VUT":1,"WAKT":1,"WAST":1,"WAT":1,"WEDT":1,"WEST":1,"WET":1,"WST":1,"YAKT":1,"YEKT":1,"Z":1}; return (timezones[value] === 1); }; $D.validateTimezoneOffset= function(value) { // timezones go from +14hrs to -12hrs, the +X hours are negative offsets. return (value > -841 && value < 721); }; }()); (function () { var $D = Date, $P = $D.prototype, p = function (s, l) { if (!l) { l = 2; } return ("000" + s).slice(l * -1); }; var validateConfigObject = function (obj) { var result = {}, self = this, prop, testFunc; testFunc = function (prop, func, value) { if (prop === "day") { var month = (obj.month !== undefined) ? obj.month : self.getMonth(); var year = (obj.year !== undefined) ? obj.year : self.getFullYear(); return $D[func](value, year, month); } else { return $D[func](value); } }; for (prop in obj) { if (Object.prototype.hasOwnProperty.call(obj, prop)) { var func = "validate" + prop.charAt(0).toUpperCase() + prop.slice(1); if ($D[func] && obj[prop] !== null && testFunc(prop, func, obj[prop])) { result[prop] = obj[prop]; } } } return result; }; /** * Resets the time of this Date object to 12:00 AM (00:00), which is the start of the day. * @param {Boolean} .clone() this date instance before clearing Time * @return {Date} this */ $P.clearTime = function () { this.setHours(0); this.setMinutes(0); this.setSeconds(0); this.setMilliseconds(0); return this; }; /** * Resets the time of this Date object to the current time ('now'). * @return {Date} this */ $P.setTimeToNow = function () { var n = new Date(); this.setHours(n.getHours()); this.setMinutes(n.getMinutes()); this.setSeconds(n.getSeconds()); this.setMilliseconds(n.getMilliseconds()); return this; }; /** * Returns a new Date object that is an exact date and time copy of the original instance. * @return {Date} A new Date instance */ $P.clone = function () { return new Date(this.getTime()); }; /** * Compares this instance to a Date object and returns an number indication of their relative values. * @param {Date} Date object to compare [Required] * @return {Number} -1 = this is lessthan date. 0 = values are equal. 1 = this is greaterthan date. */ $P.compareTo = function (date) { return Date.compare(this, date); }; /** * Compares this instance to another Date object and returns true if they are equal. * @param {Date} Date object to compare. If no date to compare, new Date() [now] is used. * @return {Boolean} true if dates are equal. false if they are not equal. */ $P.equals = function (date) { return Date.equals(this, (date !== undefined ? date : new Date())); }; /** * Determines if this instance is between a range of two dates or equal to either the start or end dates. * @param {Date} Start of range [Required] * @param {Date} End of range [Required] * @return {Boolean} true is this is between or equal to the start and end dates, else false */ $P.between = function (start, end) { return this.getTime() >= start.getTime() && this.getTime() <= end.getTime(); }; /** * Determines if this date occurs after the date to compare to. * @param {Date} Date object to compare. If no date to compare, new Date() ("now") is used. * @return {Boolean} true if this date instance is greater than the date to compare to (or "now"), otherwise false. */ $P.isAfter = function (date) { return this.compareTo(date || new Date()) === 1; }; /** * Determines if this date occurs before the date to compare to. * @param {Date} Date object to compare. If no date to compare, new Date() ("now") is used. * @return {Boolean} true if this date instance is less than the date to compare to (or "now"). */ $P.isBefore = function (date) { return (this.compareTo(date || new Date()) === -1); }; /** * Determines if the current Date instance occurs today. * @return {Boolean} true if this date instance is 'today', otherwise false. */ /** * Determines if the current Date instance occurs on the same Date as the supplied 'date'. * If no 'date' to compare to is provided, the current Date instance is compared to 'today'. * @param {date} Date object to compare. If no date to compare, the current Date ("now") is used. * @return {Boolean} true if this Date instance occurs on the same Day as the supplied 'date'. */ $P.isToday = $P.isSameDay = function (date) { return this.clone().clearTime().equals((date || new Date()).clone().clearTime()); }; /** * Adds the specified number of milliseconds to this instance. * @param {Number} The number of milliseconds to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addMilliseconds = function (value) { if (!value) { return this; } this.setTime(this.getTime() + value * 1); return this; }; /** * Adds the specified number of seconds to this instance. * @param {Number} The number of seconds to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addSeconds = function (value) { if (!value) { return this; } return this.addMilliseconds(value * 1000); }; /** * Adds the specified number of seconds to this instance. * @param {Number} The number of seconds to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addMinutes = function (value) { if (!value) { return this; } return this.addMilliseconds(value * 60000); // 60*1000 }; /** * Adds the specified number of hours to this instance. * @param {Number} The number of hours to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addHours = function (value) { if (!value) { return this; } return this.addMilliseconds(value * 3600000); // 60*60*1000 }; /** * Adds the specified number of days to this instance. * @param {Number} The number of days to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addDays = function (value) { if (!value) { return this; } this.setDate(this.getDate() + value * 1); return this; }; /** * Adds the specified number of weekdays (ie - not sat or sun) to this instance. * @param {Number} The number of days to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addWeekdays = function (value) { if (!value) { return this; } var day = this.getDay(); var weeks = (Math.ceil(Math.abs(value)/7)); if (day === 0 || day === 6) { if (value > 0) { this.next().monday(); this.addDays(-1); day = this.getDay(); } } if (value < 0) { while (value < 0) { this.addDays(-1); day = this.getDay(); if (day !== 0 && day !== 6) { value++; } } return this; } else if (value > 5 || (6-day) <= value) { value = value + (weeks * 2); } return this.addDays(value); }; /** * Adds the specified number of weeks to this instance. * @param {Number} The number of weeks to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addWeeks = function (value) { if (!value) { return this; } return this.addDays(value * 7); }; /** * Adds the specified number of months to this instance. * @param {Number} The number of months to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addMonths = function (value) { if (!value) { return this; } var n = this.getDate(); this.setDate(1); this.setMonth(this.getMonth() + value * 1); this.setDate(Math.min(n, $D.getDaysInMonth(this.getFullYear(), this.getMonth()))); return this; }; $P.addQuarters = function (value) { if (!value) { return this; } // note this will take you to the same point in the quarter as you are now. // i.e. - if you are 15 days into the quarter you'll be 15 days into the resulting one. // bonus: this allows adding fractional quarters return this.addMonths(value * 3); }; /** * Adds the specified number of years to this instance. * @param {Number} The number of years to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addYears = function (value) { if (!value) { return this; } return this.addMonths(value * 12); }; /** * Adds (or subtracts) to the value of the years, months, weeks, days, hours, minutes, seconds, milliseconds of the date instance using given configuration object. Positive and Negative values allowed. * Example

	Date.today().add( { days: 1, months: 1 } )

	new Date().add( { years: -1 } )
	
* @param {Object} Configuration object containing attributes (months, days, etc.) * @return {Date} this */ $P.add = function (config) { if (typeof config === "number") { this._orient = config; return this; } var x = config; if (x.day) { // If we should be a different date than today (eg: for 'tomorrow -1d', etc). // Should only effect parsing, not direct usage (eg, Finish and FinishExact) if ((x.day - this.getDate()) !== 0) { this.setDate(x.day); } } if (x.milliseconds) { this.addMilliseconds(x.milliseconds); } if (x.seconds) { this.addSeconds(x.seconds); } if (x.minutes) { this.addMinutes(x.minutes); } if (x.hours) { this.addHours(x.hours); } if (x.weeks) { this.addWeeks(x.weeks); } if (x.months) { this.addMonths(x.months); } if (x.years) { this.addYears(x.years); } if (x.days) { this.addDays(x.days); } return this; }; /** * Get the week number. Week one (1) is the week which contains the first Thursday of the year. Monday is considered the first day of the week. * The .getWeek() function does NOT convert the date to UTC. The local datetime is used. * Please use .getISOWeek() to get the week of the UTC converted date. * @return {Number} 1 to 53 */ $P.getWeek = function (utc) { // Create a copy of this date object var self, target = new Date(this.valueOf()); if (utc) { target.addMinutes(target.getTimezoneOffset()); self = target.clone(); } else { self = this; } // ISO week date weeks start on monday // so correct the day number var dayNr = (self.getDay() + 6) % 7; // ISO 8601 states that week 1 is the week // with the first thursday of that year. // Set the target date to the thursday in the target week target.setDate(target.getDate() - dayNr + 3); // Store the millisecond value of the target date var firstThursday = target.valueOf(); // Set the target to the first thursday of the year // First set the target to january first target.setMonth(0, 1); // Not a thursday? Correct the date to the next thursday if (target.getDay() !== 4) { target.setMonth(0, 1 + ((4 - target.getDay()) + 7) % 7); } // The weeknumber is the number of weeks between the // first thursday of the year and the thursday in the target week return 1 + Math.ceil((firstThursday - target) / 604800000); // 604800000 = 7 * 24 * 3600 * 1000 }; /** * Get the ISO 8601 week number. Week one ("01") is the week which contains the first Thursday of the year. Monday is considered the first day of the week. * The .getISOWeek() function does convert the date to it's UTC value. Please use .getWeek() to get the week of the local date. * @return {String} "01" to "53" */ $P.getISOWeek = function () { return p(this.getWeek(true)); }; /** * Moves the date to Monday of the week set. Week one (1) is the week which contains the first Thursday of the year. * @param {Number} A Number (1 to 53) that represents the week of the year. * @return {Date} this */ $P.setWeek = function (n) { if ((n - this.getWeek()) === 0) { if (this.getDay() !== 1) { return this.moveToDayOfWeek(1, (this.getDay() > 1 ? -1 : 1)); } else { return this; } } else { return this.moveToDayOfWeek(1, (this.getDay() > 1 ? -1 : 1)).addWeeks(n - this.getWeek()); } }; $P.setQuarter = function (qtr) { var month = Math.abs(((qtr-1) * 3) + 1); return this.setMonth(month, 1); }; $P.getQuarter = function () { return Date.getQuarter(this); }; $P.getDaysLeftInQuarter = function () { return Date.getDaysLeftInQuarter(this); }; /** * Moves the date to the next n'th occurrence of the dayOfWeek starting from the beginning of the month. The number (-1) is a magic number and will return the last occurrence of the dayOfWeek in the month. * @param {Number} The dayOfWeek to move to * @param {Number} The n'th occurrence to move to. Use (-1) to return the last occurrence in the month * @return {Date} this */ $P.moveToNthOccurrence = function (dayOfWeek, occurrence) { if (dayOfWeek === "Weekday") { if (occurrence > 0) { this.moveToFirstDayOfMonth(); if (this.is().weekday()) { occurrence -= 1; } } else if (occurrence < 0) { this.moveToLastDayOfMonth(); if (this.is().weekday()) { occurrence += 1; } } else { return this; } return this.addWeekdays(occurrence); } var shift = 0; if (occurrence > 0) { shift = occurrence - 1; } else if (occurrence === -1) { this.moveToLastDayOfMonth(); if (this.getDay() !== dayOfWeek) { this.moveToDayOfWeek(dayOfWeek, -1); } return this; } return this.moveToFirstDayOfMonth().addDays(-1).moveToDayOfWeek(dayOfWeek, +1).addWeeks(shift); }; var moveToN = function (getFunc, addFunc, nVal) { return function (value, orient) { var diff = (value - this[getFunc]() + nVal * (orient || +1)) % nVal; return this[addFunc]((diff === 0) ? diff += nVal * (orient || +1) : diff); }; }; /** * Move to the next or last dayOfWeek based on the orient value. * @param {Number} The dayOfWeek to move to * @param {Number} Forward (+1) or Back (-1). Defaults to +1. [Optional] * @return {Date} this */ $P.moveToDayOfWeek = moveToN("getDay", "addDays", 7); /** * Move to the next or last month based on the orient value. * @param {Number} The month to move to. 0 = January, 11 = December * @param {Number} Forward (+1) or Back (-1). Defaults to +1. [Optional] * @return {Date} this */ $P.moveToMonth = moveToN("getMonth", "addMonths", 12); /** * Get the Ordinate of the current day ("th", "st", "rd"). * @return {String} */ $P.getOrdinate = function () { var num = this.getDate(); return ord(num); }; /** * Get the Ordinal day (numeric day number) of the year, adjusted for leap year. * @return {Number} 1 through 365 (366 in leap years) */ $P.getOrdinalNumber = function () { return Math.ceil((this.clone().clearTime() - new Date(this.getFullYear(), 0, 1)) / 86400000) + 1; }; /** * Get the time zone abbreviation of the current date. * @return {String} The abbreviated time zone name (e.g. "EST") */ $P.getTimezone = function () { return $D.getTimezoneAbbreviation(this.getUTCOffset(), this.isDaylightSavingTime()); }; $P.setTimezoneOffset = function (offset) { var here = this.getTimezoneOffset(), there = Number(offset) * -6 / 10; return (there || there === 0) ? this.addMinutes(there - here) : this; }; $P.setTimezone = function (offset) { return this.setTimezoneOffset($D.getTimezoneOffset(offset)); }; /** * Indicates whether Daylight Saving Time is observed in the current time zone. * @return {Boolean} true|false */ $P.hasDaylightSavingTime = function () { return (Date.today().set({month: 0, day: 1}).getTimezoneOffset() !== Date.today().set({month: 6, day: 1}).getTimezoneOffset()); }; /** * Indicates whether this Date instance is within the Daylight Saving Time range for the current time zone. * @return {Boolean} true|false */ $P.isDaylightSavingTime = function () { return Date.today().set({month: 0, day: 1}).getTimezoneOffset() !== this.getTimezoneOffset(); }; /** * Get the offset from UTC of the current date. * @return {String} The 4-character offset string prefixed with + or - (e.g. "-0500") */ $P.getUTCOffset = function (offset) { var n = (offset || this.getTimezoneOffset()) * -10 / 6, r; if (n < 0) { r = (n - 10000).toString(); return r.charAt(0) + r.substr(2); } else { r = (n + 10000).toString(); return "+" + r.substr(1); } }; /** * Returns the number of milliseconds between this date and date. * @param {Date} Defaults to now * @return {Number} The diff in milliseconds */ $P.getElapsed = function (date) { return (date || new Date()) - this; }; /** * Set the value of year, month, day, hour, minute, second, millisecond of date instance using given configuration object. * Example

	Date.today().set( { day: 20, month: 1 } )

	new Date().set( { millisecond: 0 } )
	
* * @param {Object} Configuration object containing attributes (month, day, etc.) * @return {Date} this */ $P.set = function (config) { config = validateConfigObject.call(this, config); var key; for (key in config) { if (Object.prototype.hasOwnProperty.call(config, key)) { var name = key.charAt(0).toUpperCase() + key.slice(1); var addFunc, getFunc; if (key !== "week" && key !== "month" && key !== "timezone" && key !== "timezoneOffset") { name += "s"; } addFunc = "add" + name; getFunc = "get" + name; if (key === "month") { addFunc = addFunc + "s"; } else if (key === "year"){ getFunc = "getFullYear"; } if (key !== "day" && key !== "timezone" && key !== "timezoneOffset" && key !== "week" && key !== "hour") { this[addFunc](config[key] - this[getFunc]()); } else if ( key === "timezone"|| key === "timezoneOffset" || key === "week" || key === "hour") { this["set"+name](config[key]); } } } // day has to go last because you can't validate the day without first knowing the month if (config.day) { this.addDays(config.day - this.getDate()); } return this; }; /** * Moves the date to the first day of the month. * @return {Date} this */ $P.moveToFirstDayOfMonth = function () { return this.set({ day: 1 }); }; /** * Moves the date to the last day of the month. * @return {Date} this */ $P.moveToLastDayOfMonth = function () { return this.set({ day: $D.getDaysInMonth(this.getFullYear(), this.getMonth())}); }; /** * Converts the value of the current Date object to its equivalent string representation. * Format Specifiers * CUSTOM DATE AND TIME FORMAT STRINGS * Format Description Example * ------ --------------------------------------------------------------------------- ----------------------- * s The seconds of the minute between 0-59. "0" to "59" * ss The seconds of the minute with leading zero if required. "00" to "59" * * m The minute of the hour between 0-59. "0" or "59" * mm The minute of the hour with leading zero if required. "00" or "59" * * h The hour of the day between 1-12. "1" to "12" * hh The hour of the day with leading zero if required. "01" to "12" * * H The hour of the day between 0-23. "0" to "23" * HH The hour of the day with leading zero if required. "00" to "23" * * d The day of the month between 1 and 31. "1" to "31" * dd The day of the month with leading zero if required. "01" to "31" * ddd Abbreviated day name. Date.CultureInfo.abbreviatedDayNames. "Mon" to "Sun" * dddd The full day name. Date.CultureInfo.dayNames. "Monday" to "Sunday" * * M The month of the year between 1-12. "1" to "12" * MM The month of the year with leading zero if required. "01" to "12" * MMM Abbreviated month name. Date.CultureInfo.abbreviatedMonthNames. "Jan" to "Dec" * MMMM The full month name. Date.CultureInfo.monthNames. "January" to "December" * * yy The year as a two-digit number. "99" or "08" * yyyy The full four digit year. "1999" or "2008" * * t Displays the first character of the A.M./P.M. designator. "A" or "P" * Date.CultureInfo.amDesignator or Date.CultureInfo.pmDesignator * tt Displays the A.M./P.M. designator. "AM" or "PM" * Date.CultureInfo.amDesignator or Date.CultureInfo.pmDesignator * * S The ordinal suffix ("st, "nd", "rd" or "th") of the current day. "st, "nd", "rd" or "th" * * STANDARD DATE AND TIME FORMAT STRINGS * Format Description Example *------ --------------------------------------------------------------------------- ----------------------- * d The CultureInfo shortDate Format Pattern "M/d/yyyy" * D The CultureInfo longDate Format Pattern "dddd, MMMM dd, yyyy" * F The CultureInfo fullDateTime Format Pattern "dddd, MMMM dd, yyyy h:mm:ss tt" * m The CultureInfo monthDay Format Pattern "MMMM dd" * r The CultureInfo rfc1123 Format Pattern "ddd, dd MMM yyyy HH:mm:ss GMT" * s The CultureInfo sortableDateTime Format Pattern "yyyy-MM-ddTHH:mm:ss" * t The CultureInfo shortTime Format Pattern "h:mm tt" * T The CultureInfo longTime Format Pattern "h:mm:ss tt" * u The CultureInfo universalSortableDateTime Format Pattern "yyyy-MM-dd HH:mm:ssZ" * y The CultureInfo yearMonth Format Pattern "MMMM, yyyy" * * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @return {String} A string representation of the current Date object. */ var ord = function (n) { switch (n * 1) { case 1: case 21: case 31: return "st"; case 2: case 22: return "nd"; case 3: case 23: return "rd"; default: return "th"; } }; var parseStandardFormats = function (format) { var y, c = Date.CultureInfo.formatPatterns; switch (format) { case "d": return this.toString(c.shortDate); case "D": return this.toString(c.longDate); case "F": return this.toString(c.fullDateTime); case "m": return this.toString(c.monthDay); case "r": case "R": y = this.clone().addMinutes(this.getTimezoneOffset()); return y.toString(c.rfc1123) + " GMT"; case "s": return this.toString(c.sortableDateTime); case "t": return this.toString(c.shortTime); case "T": return this.toString(c.longTime); case "u": y = this.clone().addMinutes(this.getTimezoneOffset()); return y.toString(c.universalSortableDateTime); case "y": return this.toString(c.yearMonth); default: return false; } }; var parseFormatStringsClosure = function (context) { return function (m) { if (m.charAt(0) === "\\") { return m.replace("\\", ""); } switch (m) { case "hh": return p(context.getHours() < 13 ? (context.getHours() === 0 ? 12 : context.getHours()) : (context.getHours() - 12)); case "h": return context.getHours() < 13 ? (context.getHours() === 0 ? 12 : context.getHours()) : (context.getHours() - 12); case "HH": return p(context.getHours()); case "H": return context.getHours(); case "mm": return p(context.getMinutes()); case "m": return context.getMinutes(); case "ss": return p(context.getSeconds()); case "s": return context.getSeconds(); case "yyyy": return p(context.getFullYear(), 4); case "yy": return p(context.getFullYear()); case "y": return context.getFullYear(); case "E": case "dddd": return Date.CultureInfo.dayNames[context.getDay()]; case "ddd": return Date.CultureInfo.abbreviatedDayNames[context.getDay()]; case "dd": return p(context.getDate()); case "d": return context.getDate(); case "MMMM": return Date.CultureInfo.monthNames[context.getMonth()]; case "MMM": return Date.CultureInfo.abbreviatedMonthNames[context.getMonth()]; case "MM": return p((context.getMonth() + 1)); case "M": return context.getMonth() + 1; case "t": return context.getHours() < 12 ? Date.CultureInfo.amDesignator.substring(0, 1) : Date.CultureInfo.pmDesignator.substring(0, 1); case "tt": return context.getHours() < 12 ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator; case "S": return ord(context.getDate()); case "W": return context.getWeek(); case "WW": return context.getISOWeek(); case "Q": return "Q" + context.getQuarter(); case "q": return String(context.getQuarter()); case "z": return context.getTimezone(); case "Z": case "X": return Date.getTimezoneOffset(context.getTimezone()); case "ZZ": // Timezone offset in seconds return context.getTimezoneOffset() * -60; case "u": return context.getDay(); case "L": return ($D.isLeapYear(context.getFullYear())) ? 1 : 0; case "B": // Swatch Internet Time (.beats) return "@"+((context.getUTCSeconds() + (context.getUTCMinutes()*60) + ((context.getUTCHours()+1)*3600))/86.4); default: return m; } }; }; $P.toString = function (format, ignoreStandards) { // Standard Date and Time Format Strings. Formats pulled from CultureInfo file and // may vary by culture. if (!ignoreStandards && format && format.length === 1) { output = parseStandardFormats.call(this, format); if (output) { return output; } } var parseFormatStrings = parseFormatStringsClosure(this); return format ? format.replace(/((\\)?(dd?d?d?|MM?M?M?|yy?y?y?|hh?|HH?|mm?|ss?|tt?|S|q|Q|WW?W?W?)(?![^\[]*\]))/g, parseFormatStrings).replace(/\[|\]/g, "") : this._toString(); }; }()); /************************************************************* * SugarPak - Domain Specific Language - Syntactical Sugar * *************************************************************/ (function () { var $D = Date, $P = $D.prototype, $N = Number.prototype; // private $P._orient = +1; // private $P._nth = null; // private $P._is = false; // private $P._same = false; // private $P._isSecond = false; // private $N._dateElement = "days"; /** * Moves the date to the next instance of a date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.today().next().friday();
	Date.today().next().fri();
	Date.today().next().march();
	Date.today().next().mar();
	Date.today().next().week();
	
* * @return {Date} date */ $P.next = function () { this._move = true; this._orient = +1; return this; }; /** * Creates a new Date (Date.today()) and moves the date to the next instance of the date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.next().friday();
	Date.next().fri();
	Date.next().march();
	Date.next().mar();
	Date.next().week();
	
* * @return {Date} date */ $D.next = function () { return $D.today().next(); }; /** * Moves the date to the previous instance of a date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.today().last().friday();
	Date.today().last().fri();
	Date.today().last().march();
	Date.today().last().mar();
	Date.today().last().week();
	
* * @return {Date} date */ $P.last = $P.prev = $P.previous = function () { this._move = true; this._orient = -1; return this; }; /** * Creates a new Date (Date.today()) and moves the date to the previous instance of the date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.last().friday();
	Date.last().fri();
	Date.previous().march();
	Date.prev().mar();
	Date.last().week();
	
* * @return {Date} date */ $D.last = $D.prev = $D.previous = function () { return $D.today().last(); }; /** * Performs a equality check when followed by either a month name, day name or .weekday() function. * Example

	Date.today().is().friday(); // true|false
	Date.today().is().fri();
	Date.today().is().march();
	Date.today().is().mar();
	
* * @return {Boolean} true|false */ $P.is = function () { this._is = true; return this; }; /** * Determines if two date objects occur on/in exactly the same instance of the subsequent date part function. * The function .same() must be followed by a date part function (example: .day(), .month(), .year(), etc). * * An optional Date can be passed in the date part function. If now date is passed as a parameter, 'Now' is used. * * The following example demonstrates how to determine if two dates fall on the exact same day. * * Example

	var d1 = Date.today(); // today at 00:00
	var d2 = new Date();   // exactly now.

	// Do they occur on the same day?
	d1.same().day(d2); // true
	
	// Do they occur on the same hour?
	d1.same().hour(d2); // false, unless d2 hour is '00' (midnight).
	
	// What if it's the same day, but one year apart?
	var nextYear = Date.today().add(1).year();

	d1.same().day(nextYear); // false, because the dates must occur on the exact same day. 
	
* * Scenario: Determine if a given date occurs during some week period 2 months from now. * * Example

	var future = Date.today().add(2).months();
	return someDate.same().week(future); // true|false;
	
* * @return {Boolean} true|false */ $P.same = function () { this._same = true; this._isSecond = false; return this; }; /** * Determines if the current date/time occurs during Today. Must be preceded by the .is() function. * Example

	someDate.is().today();    // true|false
	new Date().is().today();  // true
	Date.today().is().today();// true
	Date.today().add(-1).day().is().today(); // false
	
* * @return {Boolean} true|false */ $P.today = function () { return this.same().day(); }; /** * Determines if the current date is a weekday. This function must be preceded by the .is() function. * Example

	Date.today().is().weekday(); // true|false
	
* * @return {Boolean} true|false */ $P.weekday = function () { if (this._nth) { return df("Weekday").call(this); } if (this._move) { return this.addWeekdays(this._orient); } if (this._is) { this._is = false; return (!this.is().sat() && !this.is().sun()); } return false; }; /** * Determines if the current date is on the weekend. This function must be preceded by the .is() function. * Example

	Date.today().is().weekend(); // true|false
	
* * @return {Boolean} true|false */ $P.weekend = function () { if (this._is) { this._is = false; return (this.is().sat() || this.is().sun()); } return false; }; /** * Sets the Time of the current Date instance. A string "6:15 pm" or config object {hour:18, minute:15} are accepted. * Example

	// Set time to 6:15pm with a String
	Date.today().at("6:15pm");

	// Set time to 6:15pm with a config object
	Date.today().at({hour:18, minute:15});
	
* * @return {Date} date */ $P.at = function (time) { return (typeof time === "string") ? $D.parse(this.toString("d") + " " + time) : this.set(time); }; /** * Creates a new Date() and adds this (Number) to the date based on the preceding date element function (eg. second|minute|hour|day|month|year). * Example

	// Undeclared Numbers must be wrapped with parentheses. Requirment of JavaScript.
	(3).days().fromNow();
	(6).months().fromNow();

	// Declared Number variables do not require parentheses. 
	var n = 6;
	n.months().fromNow();
	
* * @return {Date} A new Date instance */ $N.fromNow = $N.after = function (date) { var c = {}; c[this._dateElement] = this; return ((!date) ? new Date() : date.clone()).add(c); }; /** * Creates a new Date() and subtract this (Number) from the date based on the preceding date element function (eg. second|minute|hour|day|month|year). * Example

	// Undeclared Numbers must be wrapped with parentheses. Requirment of JavaScript.
	(3).days().ago();
	(6).months().ago();

	// Declared Number variables do not require parentheses. 
	var n = 6;
	n.months().ago();
	
* * @return {Date} A new Date instance */ $N.ago = $N.before = function (date) { var c = {}, s = (this._dateElement[this._dateElement.length-1] !== "s") ? this._dateElement + "s" : this._dateElement; c[s] = this * -1; return ((!date) ? new Date() : date.clone()).add(c); }; // Do NOT modify the following string tokens. These tokens are used to build dynamic functions. // All culture-specific strings can be found in the CultureInfo files. var dx = ("sunday monday tuesday wednesday thursday friday saturday").split(/\s/), mx = ("january february march april may june july august september october november december").split(/\s/), px = ("Millisecond Second Minute Hour Day Week Month Year Quarter Weekday").split(/\s/), pxf = ("Milliseconds Seconds Minutes Hours Date Week Month FullYear Quarter").split(/\s/), nth = ("final first second third fourth fifth").split(/\s/), de; /** * Returns an object literal of all the date parts. * Example

	var o = new Date().toObject();
	
	// { year: 2008, month: 4, week: 20, day: 13, hour: 18, minute: 9, second: 32, millisecond: 812 }
	
	// The object properties can be referenced directly from the object.
	
	alert(o.day);  // alerts "13"
	alert(o.year); // alerts "2008"
	
* * @return {Date} An object literal representing the original date object. */ $P.toObject = function () { var o = {}; for (var i = 0; i < px.length; i++) { if (this["get" + pxf[i]]) { o[px[i].toLowerCase()] = this["get" + pxf[i]](); } } return o; }; /** * Returns a date created from an object literal. Ignores the .week property if set in the config. * Example

	var o = new Date().toObject();
	
	return Date.fromObject(o); // will return the same date. 

	var o2 = {month: 1, day: 20, hour: 18}; // birthday party!
	Date.fromObject(o2);
	
* * @return {Date} An object literal representing the original date object. */ $D.fromObject = function(config) { config.week = null; return Date.today().set(config); }; // Create day name functions and abbreviated day name functions (eg. monday(), friday(), fri()). var df = function (n) { return function () { if (this._is) { this._is = false; return this.getDay() === n; } if (this._move) { this._move = null; } if (this._nth !== null) { // If the .second() function was called earlier, remove the _orient // from the date, and then continue. // This is required because 'second' can be used in two different context. // // Example // // Date.today().add(1).second(); // Date.march().second().monday(); // // Things get crazy with the following... // Date.march().add(1).second().second().monday(); // but it works!! // if (this._isSecond) { this.addSeconds(this._orient * -1); } // make sure we reset _isSecond this._isSecond = false; var ntemp = this._nth; this._nth = null; var temp = this.clone().moveToLastDayOfMonth(); this.moveToNthOccurrence(n, ntemp); if (this > temp) { throw new RangeError($D.getDayName(n) + " does not occur " + ntemp + " times in the month of " + $D.getMonthName(temp.getMonth()) + " " + temp.getFullYear() + "."); } return this; } return this.moveToDayOfWeek(n, this._orient); }; }; var sdf = function (n) { return function () { var t = $D.today(), shift = n - t.getDay(); if (n === 0 && Date.CultureInfo.firstDayOfWeek === 1 && t.getDay() !== 0) { shift = shift + 7; } return t.addDays(shift); }; }; // Create month name functions and abbreviated month name functions (eg. january(), march(), mar()). var month_instance_functions = function (n) { return function () { if (this._is) { this._is = false; return this.getMonth() === n; } return this.moveToMonth(n, this._orient); }; }; var month_static_functions = function (n) { return function () { return $D.today().set({ month: n, day: 1 }); }; }; var processTerms = function (names, staticFunc, instanceFunc) { for (var i = 0; i < names.length; i++) { // Create constant static Name variables. $D[names[i].toUpperCase()] = $D[names[i].toUpperCase().substring(0, 3)] = i; // Create Name functions. $D[names[i]] = $D[names[i].substring(0, 3)] = staticFunc(i); // Create Name instance functions. $P[names[i]] = $P[names[i].substring(0, 3)] = instanceFunc(i); } }; processTerms(dx, sdf, df); processTerms(mx, month_static_functions, month_instance_functions); // Create date element functions and plural date element functions used with Date (eg. day(), days(), months()). var ef = function (j) { return function () { // if the .second() function was called earlier, the _orient // has alread been added. Just return this and reset _isSecond. if (this._isSecond) { this._isSecond = false; return this; } if (this._same) { this._same = this._is = false; var o1 = this.toObject(), o2 = (arguments[0] || new Date()).toObject(), v = "", k = j.toLowerCase(); // the substr trick with -1 doesn't work in IE8 or less k = (k[k.length-1] === "s") ? k.substring(0,k.length-1) : k; for (var m = (px.length - 1); m > -1; m--) { v = px[m].toLowerCase(); if (o1[v] !== o2[v]) { return false; } if (k === v) { break; } } return true; } if (j.substring(j.length - 1) !== "s") { j += "s"; } if (this._move) { this._move = null; } return this["add" + j](this._orient); }; }; var nf = function (n) { return function () { this._dateElement = n; return this; }; }; for (var k = 0; k < px.length; k++) { de = px[k].toLowerCase(); if(de !== "weekday") { // Create date element functions and plural date element functions used with Date (eg. day(), days(), months()). $P[de] = $P[de + "s"] = ef(px[k]); // Create date element functions and plural date element functions used with Number (eg. day(), days(), months()). $N[de] = $N[de + "s"] = nf(de + "s"); } } $P._ss = ef("Second"); var nthfn = function (n) { return function (dayOfWeek) { if (this._same) { return this._ss(arguments[0]); } if (dayOfWeek || dayOfWeek === 0) { return this.moveToNthOccurrence(dayOfWeek, n); } this._nth = n; // if the operator is 'second' add the _orient, then deal with it later... if (n === 2 && (dayOfWeek === undefined || dayOfWeek === null)) { this._isSecond = true; return this.addSeconds(this._orient); } return this; }; }; for (var l = 0; l < nth.length; l++) { $P[nth[l]] = (l === 0) ? nthfn(-1) : nthfn(l); } }()); (function () { "use strict"; Date.Parsing = { Exception: function (s) { this.message = "Parse error at '" + s.substring(0, 10) + " ...'"; } }; var $P = Date.Parsing; var dayOffsets = { standard: [0,31,59,90,120,151,181,212,243,273,304,334], leap: [0,31,60,91,121,152,182,213,244,274,305,335] }; $P.isLeapYear = function(year) { return ((year % 4 === 0) && (year % 100 !== 0)) || (year % 400 === 0); }; var utils = { multiReplace : function (str, hash ) { var key; for (key in hash) { if (Object.prototype.hasOwnProperty.call(hash, key)) { var regex; if (typeof hash[key] === "function") { } else { regex = (hash[key] instanceof RegExp) ? hash[key] : new RegExp(hash[key], "g"); } str = str.replace(regex, key); } } return str; }, getDayOfYearFromWeek : function (obj) { var d, jan4, offset; obj.weekDay = (!obj.weekDay && obj.weekDay !== 0) ? 1 : obj.weekDay; d = new Date(obj.year, 0, 4); jan4 = d.getDay() === 0 ? 7 : d.getDay(); // JS is 0 indexed on Sunday. offset = jan4+3; obj.dayOfYear = ((obj.week * 7) + (obj.weekDay === 0 ? 7 : obj.weekDay))-offset; return obj; }, getDayOfYear : function (obj, dayOffset) { if (!obj.dayOfYear) { obj = utils.getDayOfYearFromWeek(obj); } for (var i=0;i <= dayOffset.length;i++) { if (obj.dayOfYear < dayOffset[i] || i === dayOffset.length) { obj.day = obj.day ? obj.day : (obj.dayOfYear - dayOffset[i-1]); break; } else { obj.month = i; } } return obj; }, adjustForTimeZone : function (obj, date) { var offset; if (obj.zone.toUpperCase() === "Z" || (obj.zone_hours === 0 && obj.zone_minutes === 0)) { // it's UTC/GML so work out the current timeszone offset offset = -date.getTimezoneOffset(); } else { offset = (obj.zone_hours*60) + (obj.zone_minutes || 0); if (obj.zone_sign === "+") { offset *= -1; } offset -= date.getTimezoneOffset(); } date.setMinutes(date.getMinutes()+offset); return date; }, setDefaults : function (obj) { obj.year = obj.year || Date.today().getFullYear(); obj.hours = obj.hours || 0; obj.minutes = obj.minutes || 0; obj.seconds = obj.seconds || 0; obj.milliseconds = obj.milliseconds || 0; if (!(!obj.month && (obj.week || obj.dayOfYear))) { // if we have a month, or if we don't but don't have the day calculation data obj.month = obj.month || 0; obj.day = obj.day || 1; } return obj; }, dataNum: function (data, mod, explict, postProcess) { var dataNum = data*1; if (mod) { if (postProcess) { return data ? mod(data)*1 : data; } else { return data ? mod(dataNum) : data; } } else if (!explict){ return data ? dataNum : data; } else { return (data && typeof data !== "undefined") ? dataNum : data; } }, timeDataProcess: function (obj) { var timeObj = {}; for (var x in obj.data) { if (obj.data.hasOwnProperty(x)) { timeObj[x] = obj.ignore[x] ? obj.data[x] : utils.dataNum(obj.data[x], obj.mods[x], obj.explict[x], obj.postProcess[x]); } } if (obj.data.secmins) { obj.data.secmins = obj.data.secmins.replace(",", ".") * 60; if (!timeObj.minutes) { timeObj.minutes = obj.data.secmins; } else if (!timeObj.seconds) { timeObj.seconds = obj.data.secmins; } delete obj.secmins; } return timeObj; }, buildTimeObjectFromData: function (data) { var time = utils.timeDataProcess({ data: { year : data[1], month : data[5], day : data[7], week : data[8], dayOfYear : data[10], hours : data[15], zone_hours : data[23], zone_minutes : data[24], zone : data[21], zone_sign : data[22], weekDay : data[9], minutes: data[16], seconds: data[19], milliseconds: data[20], secmins: data[18] }, mods: { month: function(data) { return data-1; }, weekDay: function (data) { data = Math.abs(data); return (data === 7 ? 0 : data); }, minutes: function (data) { return data.replace(":",""); }, seconds: function (data) { return Math.floor( (data.replace(":","").replace(",","."))*1 ); }, milliseconds: function (data) { return (data.replace(",",".")*1000); } }, postProcess: { minutes: true, seconds: true, milliseconds: true }, explict: { zone_hours: true, zone_minutes: true }, ignore: { zone: true, zone_sign: true, secmins: true } }); return time; }, addToHash: function (hash, keys, data) { keys = keys; data = data; var len = keys.length; for (var i = 0; i < len; i++) { hash[keys[i]] = data[i]; } return hash; }, combineRegex: function (r1, r2) { return new RegExp("(("+r1.source+")\\s("+r2.source+"))"); }, getDateNthString: function(add, last, inc){ if (add) { return Date.today().addDays(inc).toString("d"); } else if (last) { return Date.today().last()[inc]().toString("d"); } }, buildRegexData: function (array) { var arr = []; var len = array.length; for (var i=0; i < len; i++) { if (Object.prototype.toString.call(array[i]) === '[object Array]') { // oldIE compat version of Array.isArray arr.push(this.combineRegex(array[i][0], array[i][1])); } else { arr.push(array[i]); } } return arr; } }; $P.processTimeObject = function (obj) { var date, dayOffset; utils.setDefaults(obj); dayOffset = ($P.isLeapYear(obj.year)) ? dayOffsets.leap : dayOffsets.standard; if (!obj.month && (obj.week || obj.dayOfYear)) { utils.getDayOfYear(obj, dayOffset); } else { obj.dayOfYear = dayOffset[obj.month] + obj.day; } date = new Date(obj.year, obj.month, obj.day, obj.hours, obj.minutes, obj.seconds, obj.milliseconds); if (obj.zone) { utils.adjustForTimeZone(obj, date); // adjust (and calculate) for timezone } return date; }; $P.ISO = { regex : /^([\+-]?\d{4}(?!\d{2}\b))((-?)((0[1-9]|1[0-2])(\3([12]\d|0[1-9]|3[01]))?|W([0-4]\d|5[0-3])(-?[1-7])?|(00[1-9]|0[1-9]\d|[12]\d{2}|3([0-5]\d|6[1-6])))([T\s]((([01]\d|2[0-4])((:?)[0-5]\d)?|24\:?00)([\.,]\d+(?!:))?)?(\17[0-5]\d([\.,]\d+)?)?\s?([zZ]|([\+-])([01]\d|2[0-3]):?([0-5]\d)?)?)?)?$/, parse : function (s) { var time, data = s.match(this.regex); if (!data || !data.length) { return null; } time = utils.buildTimeObjectFromData(data); if (!time.year || (!time.year && (!time.month && !time.day) && (!time.week && !time.dayOfYear)) ) { return null; } return $P.processTimeObject(time); } }; $P.Numeric = { isNumeric: function (e){return!isNaN(parseFloat(e))&&isFinite(e);}, regex: /\b([0-1]?[0-9])([0-3]?[0-9])([0-2]?[0-9]?[0-9][0-9])\b/i, parse: function (s) { var data, i, time = {}, order = Date.CultureInfo.dateElementOrder.split(""); if (!(this.isNumeric(s)) || // if it's non-numeric OR (s[0] === "+" && s[0] === "-")) { // It's an arithmatic string (eg +/-1000) return null; } if (s.length < 5 && s.indexOf(".") < 0 && s.indexOf("/") < 0) { // assume it's just a year. time.year = s; return $P.processTimeObject(time); } data = s.match(this.regex); if (!data || !data.length) { return null; } for (i=0; i < order.length; i++) { switch(order[i]) { case "d": time.day = data[i+1]; break; case "m": time.month = (data[i+1]-1); break; case "y": time.year = data[i+1]; break; } } return $P.processTimeObject(time); } }; $P.Normalizer = { regexData: function () { var $R = Date.CultureInfo.regexPatterns; return utils.buildRegexData([ $R.tomorrow, $R.yesterday, [$R.past, $R.mon], [$R.past, $R.tue], [$R.past, $R.wed], [$R.past, $R.thu], [$R.past, $R.fri], [$R.past, $R.sat], [$R.past, $R.sun] ]); }, basicReplaceHash : function() { var $R = Date.CultureInfo.regexPatterns; return { "January": $R.jan.source, "February": $R.feb, "March": $R.mar, "April": $R.apr, "May": $R.may, "June": $R.jun, "July": $R.jul, "August": $R.aug, "September": $R.sep, "October": $R.oct, "November": $R.nov, "December": $R.dec, "": /\bat\b/gi, " ": /\s{2,}/, "am": $R.inTheMorning, "9am": $R.thisMorning, "pm": $R.inTheEvening, "7pm":$R.thisEvening }; }, keys : function(){ return [ utils.getDateNthString(true, false, 1), // tomorrow utils.getDateNthString(true, false, -1), // yesterday utils.getDateNthString(false, true, "monday"), //last mon utils.getDateNthString(false, true, "tuesday"), //last tues utils.getDateNthString(false, true, "wednesday"), //last wed utils.getDateNthString(false, true, "thursday"), //last thurs utils.getDateNthString(false, true, "friday"), //last fri utils.getDateNthString(false, true, "saturday"), //last sat utils.getDateNthString(false, true, "sunday") //last sun ]; }, buildRegexFunctions: function () { var $R = Date.CultureInfo.regexPatterns; var __ = Date.i18n.__; var tomorrowRE = new RegExp("(\\b\\d\\d?("+__("AM")+"|"+__("PM")+")? )("+$R.tomorrow.source.slice(1)+")", "i"); // adapted tomorrow regex for AM PM relative dates var todayRE = new RegExp($R.today.source + "(?!\\s*([+-]))\\b"); // today, but excludes the math operators (eg "today + 2h") this.replaceFuncs = [ [todayRE, function (full) { return (full.length > 1) ? Date.today().toString("d") : full; }], [tomorrowRE, function(full, m1) { var t = Date.today().addDays(1).toString("d"); return (t + " " + m1); }], [$R.amThisMorning, function(str, am){return am;}], [$R.pmThisEvening, function(str, pm){return pm;}] ]; }, buildReplaceData: function () { this.buildRegexFunctions(); this.replaceHash = utils.addToHash(this.basicReplaceHash(), this.keys(), this.regexData()); }, stringReplaceFuncs: function (s) { for (var i=0; i < this.replaceFuncs.length; i++) { s = s.replace(this.replaceFuncs[i][0], this.replaceFuncs[i][1]); } return s; }, parse: function (s) { s = this.stringReplaceFuncs(s); s = utils.multiReplace(s, this.replaceHash); try { var n = s.split(/([\s\-\.\,\/\x27]+)/); if (n.length === 3 && $P.Numeric.isNumeric(n[0]) && $P.Numeric.isNumeric(n[2]) && (n[2].length >= 4)) { // ok, so we're dealing with x/year. But that's not a full date. // This fixes wonky dateElementOrder parsing when set to dmy order. if (Date.CultureInfo.dateElementOrder[0] === "d") { s = "1/" + n[0] + "/" + n[2]; // set to 1st of month and normalize the seperator } } } catch (e) {} return s; } }; $P.Normalizer.buildReplaceData(); }()); (function () { var $P = Date.Parsing; var _ = $P.Operators = { // // Tokenizers // rtoken: function (r) { // regex token return function (s) { var mx = s.match(r); if (mx) { return ([ mx[0], s.substring(mx[0].length) ]); } else { throw new $P.Exception(s); } }; }, token: function () { // whitespace-eating token return function (s) { return _.rtoken(new RegExp("^\\s*" + s + "\\s*"))(s); }; }, stoken: function (s) { // string token return _.rtoken(new RegExp("^" + s)); }, // Atomic Operators until: function (p) { return function (s) { var qx = [], rx = null; while (s.length) { try { rx = p.call(this, s); } catch (e) { qx.push(rx[0]); s = rx[1]; continue; } break; } return [ qx, s ]; }; }, many: function (p) { return function (s) { var rx = [], r = null; while (s.length) { try { r = p.call(this, s); } catch (e) { return [ rx, s ]; } rx.push(r[0]); s = r[1]; } return [ rx, s ]; }; }, // generator operators -- see below optional: function (p) { return function (s) { var r = null; try { r = p.call(this, s); } catch (e) { return [ null, s ]; } return [ r[0], r[1] ]; }; }, not: function (p) { return function (s) { try { p.call(this, s); } catch (e) { return [null, s]; } throw new $P.Exception(s); }; }, ignore: function (p) { return p ? function (s) { var r = null; r = p.call(this, s); return [null, r[1]]; } : null; }, product: function () { var px = arguments[0], qx = Array.prototype.slice.call(arguments, 1), rx = []; for (var i = 0 ; i < px.length ; i++) { rx.push(_.each(px[i], qx)); } return rx; }, cache: function (rule) { var cache = {}, cache_length = 0, cache_keys = [], CACHE_MAX = Date.Config.CACHE_MAX || 100000, r = null; var cacheCheck = function () { if (cache_length === CACHE_MAX) { // kill several keys, don't want to have to do this all the time... for (var i=0; i < 10; i++) { var key = cache_keys.shift(); if (key) { delete cache[key]; cache_length--; } } } }; return function (s) { cacheCheck(); try { r = cache[s] = (cache[s] || rule.call(this, s)); } catch (e) { r = cache[s] = e; } cache_length++; cache_keys.push(s); if (r instanceof $P.Exception) { throw r; } else { return r; } }; }, // vector operators -- see below any: function () { var px = arguments; return function (s) { var r = null; for (var i = 0; i < px.length; i++) { if (px[i] == null) { continue; } try { r = (px[i].call(this, s)); } catch (e) { r = null; } if (r) { return r; } } throw new $P.Exception(s); }; }, each: function () { var px = arguments; return function (s) { var rx = [], r = null; for (var i = 0; i < px.length ; i++) { if (px[i] == null) { continue; } try { r = (px[i].call(this, s)); } catch (e) { throw new $P.Exception(s); } rx.push(r[0]); s = r[1]; } return [ rx, s]; }; }, all: function () { var px = arguments, _ = _; return _.each(_.optional(px)); }, // delimited operators sequence: function (px, d, c) { d = d || _.rtoken(/^\s*/); c = c || null; if (px.length === 1) { return px[0]; } return function (s) { var r = null, q = null; var rx = []; for (var i = 0; i < px.length ; i++) { try { r = px[i].call(this, s); } catch (e) { break; } rx.push(r[0]); try { q = d.call(this, r[1]); } catch (ex) { q = null; break; } s = q[1]; } if (!r) { throw new $P.Exception(s); } if (q) { throw new $P.Exception(q[1]); } if (c) { try { r = c.call(this, r[1]); } catch (ey) { throw new $P.Exception(r[1]); } } return [ rx, (r?r[1]:s) ]; }; }, // // Composite Operators // between: function (d1, p, d2) { d2 = d2 || d1; var _fn = _.each(_.ignore(d1), p, _.ignore(d2)); return function (s) { var rx = _fn.call(this, s); return [[rx[0][0], r[0][2]], rx[1]]; }; }, list: function (p, d, c) { d = d || _.rtoken(/^\s*/); c = c || null; return (p instanceof Array ? _.each(_.product(p.slice(0, -1), _.ignore(d)), p.slice(-1), _.ignore(c)) : _.each(_.many(_.each(p, _.ignore(d))), px, _.ignore(c))); }, set: function (px, d, c) { d = d || _.rtoken(/^\s*/); c = c || null; return function (s) { // r is the current match, best the current 'best' match // which means it parsed the most amount of input var r = null, p = null, q = null, rx = null, best = [[], s], last = false; // go through the rules in the given set for (var i = 0; i < px.length ; i++) { // last is a flag indicating whether this must be the last element // if there is only 1 element, then it MUST be the last one q = null; p = null; r = null; last = (px.length === 1); // first, we try simply to match the current pattern // if not, try the next pattern try { r = px[i].call(this, s); } catch (e) { continue; } // since we are matching against a set of elements, the first // thing to do is to add r[0] to matched elements rx = [[r[0]], r[1]]; // if we matched and there is still input to parse and // we don't already know this is the last element, // we're going to next check for the delimiter ... // if there's none, or if there's no input left to parse // than this must be the last element after all ... if (r[1].length > 0 && ! last) { try { q = d.call(this, r[1]); } catch (ex) { last = true; } } else { last = true; } // if we parsed the delimiter and now there's no more input, // that means we shouldn't have parsed the delimiter at all // so don't update r and mark this as the last element ... if (!last && q[1].length === 0) { last = true; } // so, if this isn't the last element, we're going to see if // we can get any more matches from the remaining (unmatched) // elements ... if (!last) { // build a list of the remaining rules we can match against, // i.e., all but the one we just matched against var qx = []; for (var j = 0; j < px.length ; j++) { if (i !== j) { qx.push(px[j]); } } // now invoke recursively set with the remaining input // note that we don't include the closing delimiter ... // we'll check for that ourselves at the end p = _.set(qx, d).call(this, q[1]); // if we got a non-empty set as a result ... // (otw rx already contains everything we want to match) if (p[0].length > 0) { // update current result, which is stored in rx ... // basically, pick up the remaining text from p[1] // and concat the result from p[0] so that we don't // get endless nesting ... rx[0] = rx[0].concat(p[0]); rx[1] = p[1]; } } // at this point, rx either contains the last matched element // or the entire matched set that starts with this element. // now we just check to see if this variation is better than // our best so far, in terms of how much of the input is parsed if (rx[1].length < best[1].length) { best = rx; } // if we've parsed all the input, then we're finished if (best[1].length === 0) { break; } } // so now we've either gone through all the patterns trying them // as the initial match; or we found one that parsed the entire // input string ... // if best has no matches, just return empty set ... if (best[0].length === 0) { return best; } // if a closing delimiter is provided, then we have to check it also if (c) { // we try this even if there is no remaining input because the pattern // may well be optional or match empty input ... try { q = c.call(this, best[1]); } catch (ey) { throw new $P.Exception(best[1]); } // it parsed ... be sure to update the best match remaining input best[1] = q[1]; } // if we're here, either there was no closing delimiter or we parsed it // so now we have the best match; just return it! return best; }; }, forward: function (gr, fname) { return function (s) { return gr[fname].call(this, s); }; }, // // Translation Operators // replace: function (rule, repl) { return function (s) { var r = rule.call(this, s); return [repl, r[1]]; }; }, process: function (rule, fn) { return function (s) { var r = rule.call(this, s); return [fn.call(this, r[0]), r[1]]; }; }, min: function (min, rule) { return function (s) { var rx = rule.call(this, s); if (rx[0].length < min) { throw new $P.Exception(s); } return rx; }; } }; // Generator Operators And Vector Operators // Generators are operators that have a signature of F(R) => R, // taking a given rule and returning another rule, such as // ignore, which parses a given rule and throws away the result. // Vector operators are those that have a signature of F(R1,R2,...) => R, // take a list of rules and returning a new rule, such as each. // Generator operators are converted (via the following _generator // function) into functions that can also take a list or array of rules // and return an array of new rules as though the function had been // called on each rule in turn (which is what actually happens). // This allows generators to be used with vector operators more easily. // Example: // each(ignore(foo, bar)) instead of each(ignore(foo), ignore(bar)) // This also turns generators into vector operators, which allows // constructs like: // not(cache(foo, bar)) var _generator = function (op) { function gen() { var args = null, rx = [], px, i; if (arguments.length > 1) { args = Array.prototype.slice.call(arguments); } else if (arguments[0] instanceof Array) { args = arguments[0]; } if (args) { px = args.shift(); if (px.length > 0) { args.unshift(px[i]); rx.push(op.apply(null, args)); args.shift(); return rx; } } else { return op.apply(null, arguments); } } return gen; }; var gx = "optional not ignore cache".split(/\s/); for (var i = 0 ; i < gx.length ; i++) { _[gx[i]] = _generator(_[gx[i]]); } var _vector = function (op) { return function () { if (arguments[0] instanceof Array) { return op.apply(null, arguments[0]); } else { return op.apply(null, arguments); } }; }; var vx = "each any all".split(/\s/); for (var j = 0 ; j < vx.length ; j++) { _[vx[j]] = _vector(_[vx[j]]); } }()); (function () { var $D = Date; var flattenAndCompact = function (ax) { var rx = []; for (var i = 0; i < ax.length; i++) { if (ax[i] instanceof Array) { rx = rx.concat(flattenAndCompact(ax[i])); } else { if (ax[i]) { rx.push(ax[i]); } } } return rx; }; var parseMeridian = function () { if (this.meridian && (this.hour || this.hour === 0)) { if (this.meridian === "a" && this.hour > 11 && Date.Config.strict24hr){ throw "Invalid hour and meridian combination"; } else if (this.meridian === "p" && this.hour < 12 && Date.Config.strict24hr){ throw "Invalid hour and meridian combination"; } else if (this.meridian === "p" && this.hour < 12) { this.hour = this.hour + 12; } else if (this.meridian === "a" && this.hour === 12) { this.hour = 0; } } }; var setDefaults = function () { var now = new Date(); if ((this.hour || this.minute) && (!this.month && !this.year && !this.day)) { this.day = now.getDate(); } if (!this.year) { this.year = now.getFullYear(); } if (!this.month && this.month !== 0) { this.month = now.getMonth(); } if (!this.day) { this.day = 1; } if (!this.hour) { this.hour = 0; } if (!this.minute) { this.minute = 0; } if (!this.second) { this.second = 0; } if (!this.millisecond) { this.millisecond = 0; } }; var finishUtils = { getToday: function () { if (this.now || "hour minute second".indexOf(this.unit) !== -1) { return new Date(); } else { return $D.today(); } }, setDaysFromWeekday: function (today, orient){ var gap; orient = orient || 1; this.unit = "day"; gap = ($D.getDayNumberFromName(this.weekday) - today.getDay()); this.days = gap ? ((gap + (orient * 7)) % 7) : (orient * 7); return this; }, setMonthsFromMonth: function (today, orient) { var gap; orient = orient || 1; this.unit = "month"; gap = (this.month - today.getMonth()); this.months = gap ? ((gap + (orient * 12)) % 12) : (orient * 12); this.month = null; return this; }, setDMYFromWeekday: function () { var d = Date[this.weekday](); this.day = d.getDate(); if (!this.month) { this.month = d.getMonth(); } this.year = d.getFullYear(); return this; }, setUnitValue: function (orient) { if (!this.value && this.operator && this.operator !== null && this[this.unit + "s"] && this[this.unit + "s"] !== null) { this[this.unit + "s"] = this[this.unit + "s"] + ((this.operator === "add") ? 1 : -1) + (this.value||0) * orient; } else if (this[this.unit + "s"] == null || this.operator != null) { if (!this.value) { this.value = 1; } this[this.unit + "s"] = this.value * orient; } }, generateDateFromWeeks: function () { var weekday = (this.weekday !== undefined) ? this.weekday : "today"; var d = Date[weekday]().addWeeks(this.weeks); if (this.now) { d.setTimeToNow(); } return d; } }; $D.Translator = { hour: function (s) { return function () { this.hour = Number(s); }; }, minute: function (s) { return function () { this.minute = Number(s); }; }, second: function (s) { return function () { this.second = Number(s); }; }, /* for ss.s format */ secondAndMillisecond: function (s) { return function () { var mx = s.match(/^([0-5][0-9])\.([0-9]{1,3})/); this.second = Number(mx[1]); this.millisecond = Number(mx[2]); }; }, meridian: function (s) { return function () { this.meridian = s.slice(0, 1).toLowerCase(); }; }, timezone: function (s) { return function () { var n = s.replace(/[^\d\+\-]/g, ""); if (n.length) { this.timezoneOffset = Number(n); } else { this.timezone = s.toLowerCase(); } }; }, day: function (x) { var s = x[0]; return function () { this.day = Number(s.match(/\d+/)[0]); if (this.day < 1) { throw "invalid day"; } }; }, month: function (s) { return function () { this.month = (s.length === 3) ? "jan feb mar apr may jun jul aug sep oct nov dec".indexOf(s)/4 : Number(s) - 1; if (this.month < 0) { throw "invalid month"; } }; }, year: function (s) { return function () { var n = Number(s); this.year = ((s.length > 2) ? n : (n + (((n + 2000) < Date.CultureInfo.twoDigitYearMax) ? 2000 : 1900))); }; }, rday: function (s) { return function () { switch (s) { case "yesterday": this.days = -1; break; case "tomorrow": this.days = 1; break; case "today": this.days = 0; break; case "now": this.days = 0; this.now = true; break; } }; }, finishExact: function (x) { var d; x = (x instanceof Array) ? x : [x]; for (var i = 0 ; i < x.length ; i++) { if (x[i]) { x[i].call(this); } } setDefaults.call(this); parseMeridian.call(this); if (this.day > $D.getDaysInMonth(this.year, this.month)) { throw new RangeError(this.day + " is not a valid value for days."); } d = new Date(this.year, this.month, this.day, this.hour, this.minute, this.second, this.millisecond); if (this.year < 100) { d.setFullYear(this.year); // means years less that 100 are process correctly. JS will parse it otherwise as 1900-1999. } if (this.timezone) { d.set({ timezone: this.timezone }); } else if (this.timezoneOffset) { d.set({ timezoneOffset: this.timezoneOffset }); } return d; }, finish: function (x) { var today, expression, orient, temp; x = (x instanceof Array) ? flattenAndCompact(x) : [ x ]; if (x.length === 0) { return null; } for (var i = 0 ; i < x.length ; i++) { if (typeof x[i] === "function") { x[i].call(this); } } if (this.now && !this.unit && !this.operator) { return new Date(); } else { today = finishUtils.getToday.call(this); } expression = !!(this.days && this.days !== null || this.orient || this.operator); orient = ((this.orient === "past" || this.operator === "subtract") ? -1 : 1); if (this.month && this.unit === "week") { this.value = this.month + 1; delete this.month; delete this.day; } if ((this.month || this.month === 0) && "year day hour minute second".indexOf(this.unit) !== -1) { if (!this.value) { this.value = this.month + 1; } this.month = null; expression = true; } if (!expression && this.weekday && !this.day && !this.days) { finishUtils.setDMYFromWeekday.call(this); } if (expression && this.weekday && this.unit !== "month" && this.unit !== "week") { finishUtils.setDaysFromWeekday.call(this, today, orient); } if (this.weekday && this.unit !== "week" && !this.day && !this.days) { temp = Date[this.weekday](); this.day = temp.getDate(); if (temp.getMonth() !== today.getMonth()) { this.month = temp.getMonth(); } } if (this.month && this.unit === "day" && this.operator) { if (!this.value) { this.value = (this.month + 1); } this.month = null; } if (this.value != null && this.month != null && this.year != null) { this.day = this.value * 1; } if (this.month && !this.day && this.value) { today.set({ day: this.value * 1 }); if (!expression) { this.day = this.value * 1; } } if (!this.month && this.value && this.unit === "month" && !this.now) { this.month = this.value; expression = true; } if (expression && (this.month || this.month === 0) && this.unit !== "year") { finishUtils.setMonthsFromMonth.call(this, today, orient); } if (!this.unit) { this.unit = "day"; } finishUtils.setUnitValue.call(this, orient); parseMeridian.call(this); if ((this.month || this.month === 0) && !this.day) { this.day = 1; } if (!this.orient && !this.operator && this.unit === "week" && this.value && !this.day && !this.month) { return Date.today().setWeek(this.value); } if (this.unit === "week" && this.weeks && !this.day && !this.month) { return finishUtils.generateDateFromWeeks.call(this); } if (expression && this.timezone && this.day && this.days) { this.day = this.days; } if (expression){ today.add(this); } else { today.set(this); } if (this.timezone) { this.timezone = this.timezone.toUpperCase(); var offset = $D.getTimezoneOffset(this.timezone); var timezone; if (today.hasDaylightSavingTime()) { // lets check that we're being sane with timezone setting timezone = $D.getTimezoneAbbreviation(offset, today.isDaylightSavingTime()); if (timezone !== this.timezone) { // bugger, we're in a place where things like EST vs EDT matters. if (today.isDaylightSavingTime()) { today.addHours(-1); } else { today.addHours(1); } } } today.setTimezoneOffset(offset); } return today; } }; }()); (function () { var $D = Date; $D.Grammar = {}; var _ = $D.Parsing.Operators, g = $D.Grammar, t = $D.Translator, _fn; // Allow rolling up into general purpose rules _fn = function () { return _.each(_.any.apply(null, arguments), _.not(g.ctoken2("timeContext"))); }; g.datePartDelimiter = _.rtoken(/^([\s\-\.\,\/\x27]+)/); g.timePartDelimiter = _.stoken(":"); g.whiteSpace = _.rtoken(/^\s*/); g.generalDelimiter = _.rtoken(/^(([\s\,]|at|@|on)+)/); var _C = {}; g.ctoken = function (keys) { var fn = _C[keys]; if (! fn) { var c = Date.CultureInfo.regexPatterns; var kx = keys.split(/\s+/), px = []; for (var i = 0; i < kx.length ; i++) { px.push(_.replace(_.rtoken(c[kx[i]]), kx[i])); } fn = _C[keys] = _.any.apply(null, px); } return fn; }; g.ctoken2 = function (key) { return _.rtoken(Date.CultureInfo.regexPatterns[key]); }; var cacheProcessRtoken = function (key, token, type, eachToken) { if (eachToken) { g[key] = _.cache(_.process(_.each(_.rtoken(token),_.optional(g.ctoken2(eachToken))), type)); } else { g[key] = _.cache(_.process(_.rtoken(token), type)); } }; var cacheProcessCtoken = function (token, type) { return _.cache(_.process(g.ctoken2(token), type)); }; var _F = {}; //function cache var _get = function (f) { _F[f] = (_F[f] || g.format(f)[0]); return _F[f]; }; g.allformats = function (fx) { var rx = []; if (fx instanceof Array) { for (var i = 0; i < fx.length; i++) { rx.push(_get(fx[i])); } } else { rx.push(_get(fx)); } return rx; }; g.formats = function (fx) { if (fx instanceof Array) { var rx = []; for (var i = 0 ; i < fx.length ; i++) { rx.push(_get(fx[i])); } return _.any.apply(null, rx); } else { return _get(fx); } }; var grammarFormats = { timeFormats: function(){ var i, RTokenKeys = [ "h", "hh", "H", "HH", "m", "mm", "s", "ss", "ss.s", "z", "zz" ], RToken = [ /^(0[0-9]|1[0-2]|[1-9])/, /^(0[0-9]|1[0-2])/, /^([0-1][0-9]|2[0-3]|[0-9])/, /^([0-1][0-9]|2[0-3])/, /^([0-5][0-9]|[0-9])/, /^[0-5][0-9]/, /^([0-5][0-9]|[0-9])/, /^[0-5][0-9]/, /^[0-5][0-9]\.[0-9]{1,3}/, /^((\+|\-)\s*\d\d\d\d)|((\+|\-)\d\d\:?\d\d)/, /^((\+|\-)\s*\d\d\d\d)|((\+|\-)\d\d\:?\d\d)/ ], tokens = [ t.hour, t.hour, t.hour, t.hour, t.minute, t.minute, t.second, t.second, t.secondAndMillisecond, t.timezone, t.timezone ]; for (i=0; i < RTokenKeys.length; i++) { cacheProcessRtoken(RTokenKeys[i], RToken[i], tokens[i]); } g.hms = _.cache(_.sequence([g.H, g.m, g.s], g.timePartDelimiter)); g.t = cacheProcessCtoken("shortMeridian", t.meridian); g.tt = cacheProcessCtoken("longMeridian", t.meridian); g.zzz = cacheProcessCtoken("timezone", t.timezone); g.timeSuffix = _.each(_.ignore(g.whiteSpace), _.set([ g.tt, g.zzz ])); g.time = _.each(_.optional(_.ignore(_.stoken("T"))), g.hms, g.timeSuffix); }, dateFormats: function () { // pre-loaded rules for different date part order preferences var _setfn = function () { return _.set(arguments, g.datePartDelimiter); }; var i, RTokenKeys = [ "d", "dd", "M", "MM", "y", "yy", "yyy", "yyyy" ], RToken = [ /^([0-2]\d|3[0-1]|\d)/, /^([0-2]\d|3[0-1])/, /^(1[0-2]|0\d|\d)/, /^(1[0-2]|0\d)/, /^(\d+)/, /^(\d\d)/, /^(\d\d?\d?\d?)/, /^(\d\d\d\d)/ ], tokens = [ t.day, t.day, t.month, t.month, t.year, t.year, t.year, t.year ], eachToken = [ "ordinalSuffix", "ordinalSuffix" ]; for (i=0; i < RTokenKeys.length; i++) { cacheProcessRtoken(RTokenKeys[i], RToken[i], tokens[i], eachToken[i]); } g.MMM = g.MMMM = _.cache(_.process(g.ctoken("jan feb mar apr may jun jul aug sep oct nov dec"), t.month)); g.ddd = g.dddd = _.cache(_.process(g.ctoken("sun mon tue wed thu fri sat"), function (s) { return function () { this.weekday = s; }; } )); g.day = _fn(g.d, g.dd); g.month = _fn(g.M, g.MMM); g.year = _fn(g.yyyy, g.yy); g.mdy = _setfn(g.ddd, g.month, g.day, g.year); g.ymd = _setfn(g.ddd, g.year, g.month, g.day); g.dmy = _setfn(g.ddd, g.day, g.month, g.year); g.date = function (s) { return ((g[Date.CultureInfo.dateElementOrder] || g.mdy).call(this, s)); }; }, relative: function () { // relative date / time expressions g.orientation = _.process(g.ctoken("past future"), function (s) { return function () { this.orient = s; }; } ); g.operator = _.process(g.ctoken("add subtract"), function (s) { return function () { this.operator = s; }; } ); g.rday = _.process(g.ctoken("yesterday tomorrow today now"), t.rday); g.unit = _.process(g.ctoken("second minute hour day week month year"), function (s) { return function () { this.unit = s; }; } ); } }; g.buildGrammarFormats = function () { // these need to be rebuilt every time the language changes. _C = {}; grammarFormats.timeFormats(); grammarFormats.dateFormats(); grammarFormats.relative(); g.value = _.process(_.rtoken(/^([-+]?\d+)?(st|nd|rd|th)?/), function (s) { return function () { this.value = s.replace(/\D/g, ""); }; } ); g.expression = _.set([g.rday, g.operator, g.value, g.unit, g.orientation, g.ddd, g.MMM ]); g.format = _.process(_.many( _.any( // translate format specifiers into grammar rules _.process( _.rtoken(/^(dd?d?d?(?!e)|MM?M?M?|yy?y?y?|hh?|HH?|mm?|ss?|tt?|zz?z?)/), function (fmt) { if (g[fmt]) { return g[fmt]; } else { throw $D.Parsing.Exception(fmt); } } ), // translate separator tokens into token rules _.process(_.rtoken(/^[^dMyhHmstz]+/), // all legal separators function (s) { return _.ignore(_.stoken(s)); } ) ) ), // construct the parser ... function (rules) { return _.process(_.each.apply(null, rules), t.finishExact); } ); // starting rule for general purpose grammar g._start = _.process(_.set([ g.date, g.time, g.expression ], g.generalDelimiter, g.whiteSpace), t.finish); }; g.buildGrammarFormats(); // parsing date format specifiers - ex: "h:m:s tt" // this little guy will generate a custom parser based // on the format string, ex: g.format("h:m:s tt") // check for these formats first g._formats = g.formats([ "\"yyyy-MM-ddTHH:mm:ssZ\"", "yyyy-MM-ddTHH:mm:ss.sz", "yyyy-MM-ddTHH:mm:ssZ", "yyyy-MM-ddTHH:mm:ssz", "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-ddTHH:mmZ", "yyyy-MM-ddTHH:mmz", "yyyy-MM-ddTHH:mm", "ddd, MMM dd, yyyy H:mm:ss tt", "ddd MMM d yyyy HH:mm:ss zzz", "MMddyyyy", "ddMMyyyy", "Mddyyyy", "ddMyyyy", "Mdyyyy", "dMyyyy", "yyyy", "Mdyy", "dMyy", "d" ]); // real starting rule: tries selected formats first, // then general purpose rule g.start = function (s) { try { var r = g._formats.call({}, s); if (r[1].length === 0) { return r; } } catch (e) {} return g._start.call({}, s); }; }()); (function () { var $D = Date; /** * @desc Converts the specified string value into its JavaScript Date equivalent using CultureInfo specific format information. * * Example

	///////////
	// Dates //
	///////////

	// 15-Oct-2004
	var d1 = Date.parse("10/15/2004");

	// 15-Oct-2004
	var d1 = Date.parse("15-Oct-2004");

	// 15-Oct-2004
	var d1 = Date.parse("2004.10.15");

	//Fri Oct 15, 2004
	var d1 = Date.parse("Fri Oct 15, 2004");

	///////////
	// Times //
	///////////

	// Today at 10 PM.
	var d1 = Date.parse("10 PM");

	// Today at 10:30 PM.
	var d1 = Date.parse("10:30 P.M.");

	// Today at 6 AM.
	var d1 = Date.parse("06am");

	/////////////////////
	// Dates and Times //
	/////////////////////

	// 8-July-2004 @ 10:30 PM
	var d1 = Date.parse("July 8th, 2004, 10:30 PM");

	// 1-July-2004 @ 10:30 PM
	var d1 = Date.parse("2004-07-01T22:30:00");

	////////////////////
	// Relative Dates //
	////////////////////

	// Returns today's date. The string "today" is culture specific.
	var d1 = Date.parse("today");

	// Returns yesterday's date. The string "yesterday" is culture specific.
	var d1 = Date.parse("yesterday");

	// Returns the date of the next thursday.
	var d1 = Date.parse("Next thursday");

	// Returns the date of the most previous monday.
	var d1 = Date.parse("last monday");

	// Returns today's day + one year.
	var d1 = Date.parse("next year");

	///////////////
	// Date Math //
	///////////////

	// Today + 2 days
	var d1 = Date.parse("t+2");

	// Today + 2 days
	var d1 = Date.parse("today + 2 days");

	// Today + 3 months
	var d1 = Date.parse("t+3m");

	// Today - 1 year
	var d1 = Date.parse("today - 1 year");

	// Today - 1 year
	var d1 = Date.parse("t-1y"); 


	/////////////////////////////
	// Partial Dates and Times //
	/////////////////////////////

	// July 15th of this year.
	var d1 = Date.parse("July 15");

	// 15th day of current day and year.
	var d1 = Date.parse("15");

	// July 1st of current year at 10pm.
	var d1 = Date.parse("7/1 10pm");
	
* * @param {String} The string value to convert into a Date object [Required] * @return {Date} A Date object or null if the string cannot be converted into a Date. */ var parseUtils = { removeOrds: function (s) { ords = s.match(/\b(\d+)(?:st|nd|rd|th)\b/); // find ordinal matches s = ((ords && ords.length === 2) ? s.replace(ords[0], ords[1]) : s); return s; }, grammarParser: function (s) { var r = null; try { r = $D.Grammar.start.call({}, s.replace(/^\s*(\S*(\s+\S+)*)\s*$/, "$1")); } catch (e) { return null; } return ((r[1].length === 0) ? r[0] : null); }, nativeFallback: function(s) { var t; try { // ok we haven't parsed it, last ditch attempt with the built-in parser. t = Date._parse(s); return (t || t === 0) ? new Date(t) : null; } catch (e) { return null; } } }; function parse (s) { var d; if (!s) { return null; } if (s instanceof Date) { return s.clone(); } if (s.length >= 4 && s.charAt(0) !== "0" && s.charAt(0) !== "+"&& s.charAt(0) !== "-") { // ie: 2004 will pass, 0800 won't. // Start with specific formats d = $D.Parsing.ISO.parse(s) || $D.Parsing.Numeric.parse(s); } if (d instanceof Date && !isNaN(d.getTime())) { return d; } else { // find ordinal dates (1st, 3rd, 8th, etc and remove them as they cause parsing issues) s = $D.Parsing.Normalizer.parse(parseUtils.removeOrds(s)); d = parseUtils.grammarParser(s); if (d !== null) { return d; } else { return parseUtils.nativeFallback(s); } } } if (!$D._parse) { $D._parse = $D.parse; } $D.parse = parse; Date.getParseFunction = function (fx) { var fns = Date.Grammar.allformats(fx); return function (s) { var r = null; for (var i = 0; i < fns.length; i++) { try { r = fns[i].call({}, s); } catch (e) { continue; } if (r[1].length === 0) { return r[0]; } } return null; }; }; /** * Converts the specified string value into its JavaScript Date equivalent using the specified format {String} or formats {Array} and the CultureInfo specific format information. * The format of the string value must match one of the supplied formats exactly. * * Example

	// 15-Oct-2004
	var d1 = Date.parseExact("10/15/2004", "M/d/yyyy");

	// 15-Oct-2004
	var d1 = Date.parse("15-Oct-2004", "M-ddd-yyyy");

	// 15-Oct-2004
	var d1 = Date.parse("2004.10.15", "yyyy.MM.dd");

	// Multiple formats
	var d1 = Date.parseExact("10/15/2004", ["M/d/yyyy", "MMMM d, yyyy"]);
	
* * @param {String} The string value to convert into a Date object [Required]. * @param {Object} The expected format {String} or an array of expected formats {Array} of the date string [Required]. * @return {Date} A Date object or null if the string cannot be converted into a Date. */ $D.parseExact = function (s, fx) { return $D.getParseFunction(fx)(s); }; }()); (function () { var $D = Date, $P = $D.prototype, // $C = $D.CultureInfo, // not used atm p = function (s, l) { if (!l) { l = 2; } return ("000" + s).slice(l * -1); }; /** * Converts a PHP format string to Java/.NET format string. * A PHP format string can be used with ._format or .format. * A Java/.NET format string can be used with .toString(). * The .parseExact function will only accept a Java/.NET format string * * Example * var f1 = "%m/%d/%y" * var f2 = Date.normalizeFormat(f1); // "MM/dd/yy" * * new Date().format(f1); // "04/13/08" * new Date()._format(f1); // "04/13/08" * new Date().toString(f2); // "04/13/08" * * var date = Date.parseExact("04/13/08", f2); // Sun Apr 13 2008 * * @param {String} A PHP format string consisting of one or more format spcifiers. * @return {String} The PHP format converted to a Java/.NET format string. */ var normalizerSubstitutions = { "d" : "dd", "%d": "dd", "D" : "ddd", "%a": "ddd", "j" : "dddd", "l" : "dddd", "%A": "dddd", "S" : "S", "F" : "MMMM", "%B": "MMMM", "m" : "MM", "%m": "MM", "M" : "MMM", "%b": "MMM", "%h": "MMM", "n" : "M", "Y" : "yyyy", "%Y": "yyyy", "y" : "yy", "%y": "yy", "g" : "h", "%I": "h", "G" : "H", "h" : "hh", "H" : "HH", "%H": "HH", "i" : "mm", "%M": "mm", "s" : "ss", "%S": "ss", "%r": "hh:mm tt", "%R": "H:mm", "%T": "H:mm:ss", "%X": "t", "%x": "d", "%e": "d", "%D": "MM/dd/yy", "%n": "\\n", "%t": "\\t", "e" : "z", "T" : "z", "%z": "z", "%Z": "z", "Z" : "ZZ", "N" : "u", "w" : "u", "%w": "u", "W" : "W", "%V": "W" }; var normalizer = { substitutes: function (m) { return normalizerSubstitutions[m]; }, interpreted: function (m, x) { var y; switch (m) { case "%u": return x.getDay() + 1; case "z": return x.getOrdinalNumber(); case "%j": return p(x.getOrdinalNumber(), 3); case "%U": var d1 = x.clone().set({month: 0, day: 1}).addDays(-1).moveToDayOfWeek(0), d2 = x.clone().addDays(1).moveToDayOfWeek(0, -1); return (d2 < d1) ? "00" : p((d2.getOrdinalNumber() - d1.getOrdinalNumber()) / 7 + 1); case "%W": return p(x.getWeek()); case "t": return $D.getDaysInMonth(x.getFullYear(), x.getMonth()); case "o": case "%G": return x.setWeek(x.getISOWeek()).toString("yyyy"); case "%g": return x._format("%G").slice(-2); case "a": case "%p": return t("tt").toLowerCase(); case "A": return t("tt").toUpperCase(); case "u": return p(x.getMilliseconds(), 3); case "I": return (x.isDaylightSavingTime()) ? 1 : 0; case "O": return x.getUTCOffset(); case "P": y = x.getUTCOffset(); return y.substring(0, y.length - 2) + ":" + y.substring(y.length - 2); case "B": var now = new Date(); return Math.floor(((now.getHours() * 3600) + (now.getMinutes() * 60) + now.getSeconds() + (now.getTimezoneOffset() + 60) * 60) / 86.4); case "c": return x.toISOString().replace(/\"/g, ""); case "U": return $D.strtotime("now"); case "%c": return t("d") + " " + t("t"); case "%C": return Math.floor(x.getFullYear() / 100 + 1); } }, shouldOverrideDefaults: function (m) { switch (m) { case "%e": return true; default: return false; } }, parse: function (m, context) { var formatString, c = context || new Date(); formatString = normalizer.substitutes(m); if (formatString) { return formatString; } formatString = normalizer.interpreted(m, c); if (formatString) { return formatString; } else { return m; } } }; $D.normalizeFormat = function (format, context) { return format.replace(/(%|\\)?.|%%/g, function(t){ return normalizer.parse(t, context); }); }; /** * Format a local Unix timestamp according to locale settings * * Example: * Date.strftime("%m/%d/%y", new Date()); // "04/13/08" * Date.strftime("c", "2008-04-13T17:52:03Z"); // "04/13/08" * * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @param {Number|String} The number representing the number of seconds that have elapsed since January 1, 1970 (local time). * @return {String} A string representation of the current Date object. */ $D.strftime = function (format, time) { var d = Date.parse(time); return d._format(format); }; /** * Parse any textual datetime description into a Unix timestamp. * A Unix timestamp is the number of seconds that have elapsed since January 1, 1970 (midnight UTC/GMT). * * Example: * Date.strtotime("04/13/08"); // 1208044800 * Date.strtotime("1970-01-01T00:00:00Z"); // 0 * * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @param {Object} A string or date object. * @return {String} A string representation of the current Date object. */ $D.strtotime = function (time) { var d = $D.parse(time); return Math.round($D.UTC(d.getUTCFullYear(), d.getUTCMonth(), d.getUTCDate(), d.getUTCHours(), d.getUTCMinutes(), d.getUTCSeconds(), d.getUTCMilliseconds()) / 1000); }; /** * Converts the value of the current Date object to its equivalent string representation using a PHP/Unix style of date format specifiers. * Format Specifiers * Format Description Example * ------ --------------------------------------------------------------------------- ----------------------- * %a abbreviated weekday name according to the current localed "Mon" through "Sun" * %A full weekday name according to the current localed "Sunday" through "Saturday" * %b abbreviated month name according to the current localed "Jan" through "Dec" * %B full month name according to the current locale "January" through "December" * %c preferred date and time representation for the current locale "4/13/2008 12:33 PM" * %C century number (the year divided by 100 and truncated to an integer) "00" to "99" * %d day of the month as a decimal number "01" to "31" * %D same as %m/%d/%y "04/13/08" * %e day of the month as a decimal number, a single digit is preceded by a space "1" to "31" * %g like %G, but without the century "08" * %G The 4-digit year corresponding to the ISO week number (see %V). "2008" * This has the same format and value as %Y, except that if the ISO week number * belongs to the previous or next year, that year is used instead. * %h same as %b "Jan" through "Dec" * %H hour as a decimal number using a 24-hour clock. "00" to "23" * %I hour as a decimal number using a 12-hour clock. "01" to "12" * %j day of the year as a decimal number. "001" to "366" * %m month as a decimal number. "01" to "12" * %M minute as a decimal number. "00" to "59" * %n newline character "\n" * %p either "am" or "pm" according to the given time value, or the "am" or "pm" * corresponding strings for the current locale. * %r time in a.m. and p.m. notation "8:44 PM" * %R time in 24 hour notation "20:44" * %S second as a decimal number "00" to "59" * %t tab character "\t" * %T current time, equal to %H:%M:%S "12:49:11" * %u weekday as a decimal number ["1", "7"], with "1" representing Monday "1" to "7" * %U week number of the current year as a decimal number, starting with the "0" to ("52" or "53") * first Sunday as the first day of the first week * %V The ISO 8601:1988 week number of the current year as a decimal number, "00" to ("52" or "53") * range 01 to 53, where week 1 is the first week that has at least 4 days * in the current year, and with Monday as the first day of the week. * (Use %G or %g for the year component that corresponds to the week number * for the specified timestamp.) * %W week number of the current year as a decimal number, starting with the "00" to ("52" or "53") * first Monday as the first day of the first week * %w day of the week as a decimal, Sunday being "0" "0" to "6" * %x preferred date representation for the current locale without the time "4/13/2008" * %X preferred time representation for the current locale without the date "12:53:05" * %y year as a decimal number without a century "00" "99" * %Y year as a decimal number including the century "2008" * %Z time zone or name or abbreviation "UTC", "EST", "PST" * %z same as %Z * %% a literal "%" characters "%" * d Day of the month, 2 digits with leading zeros "01" to "31" * D A textual representation of a day, three letters "Mon" through "Sun" * j Day of the month without leading zeros "1" to "31" * l A full textual representation of the day of the week (lowercase "L") "Sunday" through "Saturday" * N ISO-8601 numeric representation of the day of the week (added in PHP 5.1.0) "1" (for Monday) through "7" (for Sunday) * S English ordinal suffix for the day of the month, 2 characters "st", "nd", "rd" or "th". Works well with j * w Numeric representation of the day of the week "0" (for Sunday) through "6" (for Saturday) * z The day of the year (starting from "0") "0" through "365" * W ISO-8601 week number of year, weeks starting on Monday "00" to ("52" or "53") * F A full textual representation of a month, such as January or March "January" through "December" * m Numeric representation of a month, with leading zeros "01" through "12" * M A short textual representation of a month, three letters "Jan" through "Dec" * n Numeric representation of a month, without leading zeros "1" through "12" * t Number of days in the given month "28" through "31" * L Whether it's a leap year "1" if it is a leap year, "0" otherwise * o ISO-8601 year number. This has the same value as Y, except that if the "2008" * ISO week number (W) belongs to the previous or next year, that year * is used instead. * Y A full numeric representation of a year, 4 digits "2008" * y A two digit representation of a year "08" * a Lowercase Ante meridiem and Post meridiem "am" or "pm" * A Uppercase Ante meridiem and Post meridiem "AM" or "PM" * B Swatch Internet time "000" through "999" * g 12-hour format of an hour without leading zeros "1" through "12" * G 24-hour format of an hour without leading zeros "0" through "23" * h 12-hour format of an hour with leading zeros "01" through "12" * H 24-hour format of an hour with leading zeros "00" through "23" * i Minutes with leading zeros "00" to "59" * s Seconds, with leading zeros "00" through "59" * u Milliseconds "54321" * e Timezone identifier "UTC", "EST", "PST" * I Whether or not the date is in daylight saving time (uppercase i) "1" if Daylight Saving Time, "0" otherwise * O Difference to Greenwich time (GMT) in hours "+0200", "-0600" * P Difference to Greenwich time (GMT) with colon between hours and minutes "+02:00", "-06:00" * T Timezone abbreviation "UTC", "EST", "PST" * Z Timezone offset in seconds. The offset for timezones west of UTC is "-43200" through "50400" * always negative, and for those east of UTC is always positive. * c ISO 8601 date "2004-02-12T15:19:21+00:00" * r RFC 2822 formatted date "Thu, 21 Dec 2000 16:01:07 +0200" * U Seconds since the Unix Epoch (January 1 1970 00:00:00 GMT) "0" * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @return {String} A string representation of the current Date object. */ var formatReplace = function (context) { return function (m) { var formatString, override = false; if (m.charAt(0) === "\\" || m.substring(0, 2) === "%%") { return m.replace("\\", "").replace("%%", "%"); } override = normalizer.shouldOverrideDefaults(m); formatString = $D.normalizeFormat(m, context); if (formatString) { return context.toString(formatString, override); } }; }; $P._format = function (format) { var formatter = formatReplace(this); if (!format) { return this._toString(); } else { return format.replace(/(%|\\)?.|%%/g, formatter); } }; if (!$P.format) { $P.format = $P._format; } }()); (function () { "use strict"; var gFn = function (attr) { return function () { return this[attr]; }; }; var sFn = function (attr) { return function (val) { this[attr] = val; return this; }; }; var attrs = ["years", "months", "days", "hours", "minutes", "seconds", "milliseconds"]; var addSetFuncs = function (context, attrs) { for (var i = 0; i < attrs.length ; i++) { var $a = attrs[i], $b = $a.slice(0, 1).toUpperCase() + $a.slice(1); context.prototype[$a] = 0; context.prototype["get" + $b] = gFn($a); context.prototype["set" + $b] = sFn($a); } }; /** * new TimeSpan(milliseconds); * new TimeSpan(days, hours, minutes, seconds); * new TimeSpan(days, hours, minutes, seconds, milliseconds); */ var TimeSpan = function (days, hours, minutes, seconds, milliseconds) { if (arguments.length === 1 && typeof days === "number") { var orient = (days < 0) ? -1 : +1; var millsLeft = Math.abs(days); this.setDays(Math.floor(millsLeft / 86400000) * orient); millsLeft = millsLeft % 86400000; this.setHours(Math.floor(millsLeft / 3600000) * orient); millsLeft = millsLeft % 3600000; this.setMinutes(Math.floor(millsLeft / 60000) * orient); millsLeft = millsLeft % 60000; this.setSeconds(Math.floor(millsLeft / 1000) * orient); millsLeft = millsLeft % 1000; this.setMilliseconds(millsLeft * orient); } else { this.set(days, hours, minutes, seconds, milliseconds); } this.getTotalMilliseconds = function () { return (this.getDays() * 86400000) + (this.getHours() * 3600000) + (this.getMinutes() * 60000) + (this.getSeconds() * 1000); }; this.compareTo = function (time) { var t1 = new Date(1970, 1, 1, this.getHours(), this.getMinutes(), this.getSeconds()), t2; if (time === null) { t2 = new Date(1970, 1, 1, 0, 0, 0); } else { t2 = new Date(1970, 1, 1, time.getHours(), time.getMinutes(), time.getSeconds()); } return (t1 < t2) ? -1 : (t1 > t2) ? 1 : 0; }; this.equals = function (time) { return (this.compareTo(time) === 0); }; this.add = function (time) { return (time === null) ? this : this.addSeconds(time.getTotalMilliseconds() / 1000); }; this.subtract = function (time) { return (time === null) ? this : this.addSeconds(-time.getTotalMilliseconds() / 1000); }; this.addDays = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 86400000)); }; this.addHours = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 3600000)); }; this.addMinutes = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 60000)); }; this.addSeconds = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 1000)); }; this.addMilliseconds = function (n) { return new TimeSpan(this.getTotalMilliseconds() + n); }; this.get12HourHour = function () { return (this.getHours() > 12) ? this.getHours() - 12 : (this.getHours() === 0) ? 12 : this.getHours(); }; this.getDesignator = function () { return (this.getHours() < 12) ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator; }; this.toString = function (format) { this._toString = function () { if (this.getDays() !== null && this.getDays() > 0) { return this.getDays() + "." + this.getHours() + ":" + this.p(this.getMinutes()) + ":" + this.p(this.getSeconds()); } else { return this.getHours() + ":" + this.p(this.getMinutes()) + ":" + this.p(this.getSeconds()); } }; this.p = function (s) { return (s.toString().length < 2) ? "0" + s : s; }; var me = this; return format ? format.replace(/dd?|HH?|hh?|mm?|ss?|tt?/g, function (format) { switch (format) { case "d": return me.getDays(); case "dd": return me.p(me.getDays()); case "H": return me.getHours(); case "HH": return me.p(me.getHours()); case "h": return me.get12HourHour(); case "hh": return me.p(me.get12HourHour()); case "m": return me.getMinutes(); case "mm": return me.p(me.getMinutes()); case "s": return me.getSeconds(); case "ss": return me.p(me.getSeconds()); case "t": return ((me.getHours() < 12) ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator).substring(0, 1); case "tt": return (me.getHours() < 12) ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator; } } ) : this._toString(); }; return this; }; addSetFuncs(TimeSpan, attrs.slice(2)); TimeSpan.prototype.set = function (days, hours, minutes, seconds, milliseconds){ this.setDays(days || this.getDays()); this.setHours(hours || this.getHours()); this.setMinutes(minutes || this.getMinutes()); this.setSeconds(seconds || this.getSeconds()); this.setMilliseconds(milliseconds || this.getMilliseconds()); }; /** * Gets the time of day for this date instances. * @return {TimeSpan} TimeSpan */ Date.prototype.getTimeOfDay = function () { return new TimeSpan(0, this.getHours(), this.getMinutes(), this.getSeconds(), this.getMilliseconds()); }; Date.TimeSpan = TimeSpan; if (typeof window !== "undefined" ) { // keeping API compatible for v1.x window.TimeSpan = TimeSpan; } }()); (function () { "use strict"; var attrs = ["years", "months", "days", "hours", "minutes", "seconds", "milliseconds"]; var gFn = function (attr) { return function () { return this[attr]; }; }; var sFn = function (attr) { return function (val) { this[attr] = val; return this; }; }; var addSetFuncs = function (context, attrs) { for (var i = 0; i < attrs.length ; i++) { var $a = attrs[i], $b = $a.slice(0, 1).toUpperCase() + $a.slice(1); context.prototype[$a] = 0; context.prototype["get" + $b] = gFn($a); context.prototype["set" + $b] = sFn($a); } }; var setMonthsAndYears = function (orient, d1, d2, context) { function inc() { d1.addMonths(-orient); context.months++; if (context.months === 12) { context.years++; context.months = 0; } } if (orient === +1) { while (d1 > d2) { inc(); } } else { while (d1 < d2) { inc(); } } context.months--; context.months *= orient; context.years *= orient; }; var adjustForDST = function(orient, startDate, endDate) { var hasDSTMismatch = (false === (startDate.isDaylightSavingTime() === endDate.isDaylightSavingTime())); if (hasDSTMismatch && orient === 1) { startDate.addHours(-1); } else if (hasDSTMismatch) { startDate.addHours(1); } }; /** * TimePeriod(startDate, endDate); * TimePeriod(years, months, days, hours, minutes, seconds, milliseconds); */ var TimePeriod = function (years, months, days, hours, minutes, seconds, milliseconds) { if (arguments.length === 7) { this.set(years, months, days, hours, minutes, seconds, milliseconds); } else if (arguments.length === 2 && arguments[0] instanceof Date && arguments[1] instanceof Date) { var startDate = arguments[0].clone(); var endDate = arguments[1].clone(); var orient = (startDate > endDate) ? +1 : -1; this.dates = { start: arguments[0].clone(), end: arguments[1].clone() }; setMonthsAndYears(orient, startDate, endDate, this); adjustForDST(orient, startDate, endDate); // // TODO - adjust for DST var diff = endDate - startDate; if (diff !== 0) { var ts = new TimeSpan(diff); this.set(this.years, this.months, ts.getDays(), ts.getHours(), ts.getMinutes(), ts.getSeconds(), ts.getMilliseconds()); } } return this; }; // create all the set functions. addSetFuncs(TimePeriod, attrs); TimePeriod.prototype.set = function (years, months, days, hours, minutes, seconds, milliseconds){ this.setYears(years || this.getYears()); this.setMonths(months || this.getMonths()); this.setDays(days || this.getDays()); this.setHours(hours || this.getHours()); this.setMinutes(minutes || this.getMinutes()); this.setSeconds(seconds || this.getSeconds()); this.setMilliseconds(milliseconds || this.getMilliseconds()); }; Date.TimePeriod = TimePeriod; if (typeof window !== "undefined") { // keeping API compatible for v1.x window.TimePeriod = TimePeriod; } }()); ================================================ FILE: build/date-ar-EG.js ================================================ /** * @overview datejs * @version 1.0.0-rc3 * @author Gregory Wild-Smith * @copyright 2015 Gregory Wild-Smith * @license MIT * @homepage https://github.com/abritinthebay/datejs */ /* * DateJS Culture String File * Country Code: ar-EG * Name: Arabic (Egypt) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["ar-EG"] = { "name": "ar-EG", "englishName": "Arabic (Egypt)", "nativeName": "العربية (مصر)", "Sunday": "الاحد", "Monday": "الاثنين", "Tuesday": "الثلاثاء", "Wednesday": "الاربعاء", "Thursday": "الخميس", "Friday": "الجمعة", "Saturday": "السبت", "Sun": "الاحد", "Mon": "الاثنين", "Tue": "الثلاثاء", "Wed": "الاربعاء", "Thu": "الخميس", "Fri": "الجمعة", "Sat": "السبت", "Su": "أ", "Mo": "ا", "Tu": "ث", "We": "أ", "Th": "خ", "Fr": "ج", "Sa": "س", "S_Sun_Initial": "أ", "M_Mon_Initial": "ا", "T_Tue_Initial": "ث", "W_Wed_Initial": "أ", "T_Thu_Initial": "خ", "F_Fri_Initial": "ج", "S_Sat_Initial": "س", "January": "يناير", "February": "فبراير", "March": "مارس", "April": "ابريل", "May": "مايو", "June": "يونيو", "July": "يوليو", "August": "اغسطس", "September": "سبتمبر", "October": "اكتوبر", "November": "نوفمبر", "December": "ديسمبر", "Jan_Abbr": "يناير", "Feb_Abbr": "فبراير", "Mar_Abbr": "مارس", "Apr_Abbr": "ابريل", "May_Abbr": "مايو", "Jun_Abbr": "يونيو", "Jul_Abbr": "يوليو", "Aug_Abbr": "اغسطس", "Sep_Abbr": "سبتمبر", "Oct_Abbr": "اكتوبر", "Nov_Abbr": "نوفمبر", "Dec_Abbr": "ديسمبر", "AM": "ص", "PM": "م", "firstDayOfWeek": 6, "twoDigitYearMax": 2029, "mdy": "dmy", "M/d/yyyy": "dd/MM/yyyy", "dddd, MMMM dd, yyyy": "dd MMMM, yyyy", "h:mm tt": "hh:mm tt", "h:mm:ss tt": "hh:mm:ss tt", "dddd, MMMM dd, yyyy h:mm:ss tt": "dd MMMM, yyyy hh:mm:ss tt", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "dd MMMM", "MMMM, yyyy": "MMMM, yyyy", "/jan(uary)?/": "يناير", "/feb(ruary)?/": "فبراير", "/mar(ch)?/": "مارس", "/apr(il)?/": "ابريل", "/may/": "مايو", "/jun(e)?/": "يونيو", "/jul(y)?/": "يوليو", "/aug(ust)?/": "اغسطس", "/sep(t(ember)?)?/": "سبتمبر", "/oct(ober)?/": "اكتوبر", "/nov(ember)?/": "نوفمبر", "/dec(ember)?/": "ديسمبر", "/^su(n(day)?)?/": "^الاحد", "/^mo(n(day)?)?/": "^ا(1)?", "/^tu(e(s(day)?)?)?/": "^الثلاثاء", "/^we(d(nesday)?)?/": "^الاربعاء", "/^th(u(r(s(day)?)?)?)?/": "^الخميس", "/^fr(i(day)?)?/": "^الجمعة", "/^sa(t(urday)?)?/": "^السبت", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "ar-EG"; /** * @overview datejs * @version 1.0.0-rc3 * @author Gregory Wild-Smith * @copyright 2015 Gregory Wild-Smith * @license MIT * @homepage https://github.com/abritinthebay/datejs */(function () { var $D = Date; var lang = Date.CultureStrings ? Date.CultureStrings.lang : null; var loggedKeys = {}; // for debug purposes. var getText = { getFromKey: function (key, countryCode) { var output; if (Date.CultureStrings && Date.CultureStrings[countryCode] && Date.CultureStrings[countryCode][key]) { output = Date.CultureStrings[countryCode][key]; } else { output = getText.buildFromDefault(key); } if (key.charAt(0) === "/") { // Assume it's a regex output = getText.buildFromRegex(key, countryCode); } return output; }, getFromObjectValues: function (obj, countryCode) { var key, output = {}; for(key in obj) { if (obj.hasOwnProperty(key)) { output[key] = getText.getFromKey(obj[key], countryCode); } } return output; }, getFromObjectKeys: function (obj, countryCode) { var key, output = {}; for(key in obj) { if (obj.hasOwnProperty(key)) { output[getText.getFromKey(key, countryCode)] = obj[key]; } } return output; }, getFromArray: function (arr, countryCode) { var output = []; for (var i=0; i < arr.length; i++){ if (i in arr) { output[i] = getText.getFromKey(arr[i], countryCode); } } return output; }, buildFromDefault: function (key) { var output, length, split, last; switch(key) { case "name": output = "en-US"; break; case "englishName": output = "English (United States)"; break; case "nativeName": output = "English (United States)"; break; case "twoDigitYearMax": output = 2049; break; case "firstDayOfWeek": output = 0; break; default: output = key; split = key.split("_"); length = split.length; if (length > 1 && key.charAt(0) !== "/") { // if the key isn't a regex and it has a split. last = split[(length - 1)].toLowerCase(); if (last === "initial" || last === "abbr") { output = split[0]; } } break; } return output; }, buildFromRegex: function (key, countryCode) { var output; if (Date.CultureStrings && Date.CultureStrings[countryCode] && Date.CultureStrings[countryCode][key]) { output = new RegExp(Date.CultureStrings[countryCode][key], "i"); } else { output = new RegExp(key.replace(new RegExp("/", "g"),""), "i"); } return output; } }; var shallowMerge = function (obj1, obj2) { for (var attrname in obj2) { if (obj2.hasOwnProperty(attrname)) { obj1[attrname] = obj2[attrname]; } } }; var __ = function (key, language) { var countryCode = (language) ? language : lang; loggedKeys[key] = key; if (typeof key === "object") { if (key instanceof Array) { return getText.getFromArray(key, countryCode); } else { return getText.getFromObjectKeys(key, countryCode); } } else { return getText.getFromKey(key, countryCode); } }; var loadI18nScript = function (code) { // paatterned after jQuery's getScript. var url = Date.Config.i18n + code + ".js"; var head = document.getElementsByTagName("head")[0] || document.documentElement; var script = document.createElement("script"); script.src = url; var completed = false; var events = { done: function (){} // placeholder function }; // Attach handlers for all browsers script.onload = script.onreadystatechange = function() { if ( !completed && (!this.readyState || this.readyState === "loaded" || this.readyState === "complete") ) { events.done(); head.removeChild(script); } }; setTimeout(function() { head.insertBefore(script, head.firstChild); }, 0); // allows return to execute first return { done: function (cb) { events.done = function() { if (cb) { setTimeout(cb,0); } }; } }; }; var buildInfo = { buildFromMethodHash: function (obj) { var key; for(key in obj) { if (obj.hasOwnProperty(key)) { obj[key] = buildInfo[obj[key]](); } } return obj; }, timeZoneDST: function () { var DST = { "CHADT": "+1345", "NZDT": "+1300", "AEDT": "+1100", "ACDT": "+1030", "AZST": "+0500", "IRDT": "+0430", "EEST": "+0300", "CEST": "+0200", "BST": "+0100", "PMDT": "-0200", "ADT": "-0300", "NDT": "-0230", "EDT": "-0400", "CDT": "-0500", "MDT": "-0600", "PDT": "-0700", "AKDT": "-0800", "HADT": "-0900" }; return __(DST); }, timeZoneStandard: function () { var standard = { "LINT": "+1400", "TOT": "+1300", "CHAST": "+1245", "NZST": "+1200", "NFT": "+1130", "SBT": "+1100", "AEST": "+1000", "ACST": "+0930", "JST": "+0900", "CWST": "+0845", "CT": "+0800", "ICT": "+0700", "MMT": "+0630", "BST": "+0600", "NPT": "+0545", "IST": "+0530", "PKT": "+0500", "AFT": "+0430", "MSK": "+0400", "IRST": "+0330", "FET": "+0300", "EET": "+0200", "CET": "+0100", "GMT": "+0000", "UTC": "+0000", "CVT": "-0100", "GST": "-0200", "BRT": "-0300", "NST": "-0330", "AST": "-0400", "EST": "-0500", "CST": "-0600", "MST": "-0700", "PST": "-0800", "AKST": "-0900", "MIT": "-0930", "HST": "-1000", "SST": "-1100", "BIT": "-1200" }; return __(standard); }, timeZones: function (data) { var zone; data.timezones = []; for (zone in data.abbreviatedTimeZoneStandard) { if (data.abbreviatedTimeZoneStandard.hasOwnProperty(zone)) { data.timezones.push({ name: zone, offset: data.abbreviatedTimeZoneStandard[zone]}); } } for (zone in data.abbreviatedTimeZoneDST) { if (data.abbreviatedTimeZoneDST.hasOwnProperty(zone)) { data.timezones.push({ name: zone, offset: data.abbreviatedTimeZoneDST[zone], dst: true}); } } return data.timezones; }, days: function () { return __(["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"]); }, dayAbbr: function () { return __(["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"]); }, dayShortNames: function () { return __(["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"]); }, dayFirstLetters: function () { return __(["S_Sun_Initial", "M_Mon_Initial", "T_Tues_Initial", "W_Wed_Initial", "T_Thu_Initial", "F_Fri_Initial", "S_Sat_Initial"]); }, months: function () { return __(["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"]); }, monthAbbr: function () { return __(["Jan_Abbr", "Feb_Abbr", "Mar_Abbr", "Apr_Abbr", "May_Abbr", "Jun_Abbr", "Jul_Abbr", "Aug_Abbr", "Sep_Abbr", "Oct_Abbr", "Nov_Abbr", "Dec_Abbr"]); }, formatPatterns: function () { return getText.getFromObjectValues({ shortDate: "M/d/yyyy", longDate: "dddd, MMMM dd, yyyy", shortTime: "h:mm tt", longTime: "h:mm:ss tt", fullDateTime: "dddd, MMMM dd, yyyy h:mm:ss tt", sortableDateTime: "yyyy-MM-ddTHH:mm:ss", universalSortableDateTime: "yyyy-MM-dd HH:mm:ssZ", rfc1123: "ddd, dd MMM yyyy HH:mm:ss", monthDay: "MMMM dd", yearMonth: "MMMM, yyyy" }, Date.i18n.currentLanguage()); }, regex: function () { return getText.getFromObjectValues({ inTheMorning: "/( in the )(morn(ing)?)\\b/", thisMorning: "/(this )(morn(ing)?)\\b/", amThisMorning: "/(\b\\d(am)? )(this )(morn(ing)?)/", inTheEvening: "/( in the )(even(ing)?)\\b/", thisEvening: "/(this )(even(ing)?)\\b/", pmThisEvening: "/(\b\\d(pm)? )(this )(even(ing)?)/", jan: "/jan(uary)?/", feb: "/feb(ruary)?/", mar: "/mar(ch)?/", apr: "/apr(il)?/", may: "/may/", jun: "/jun(e)?/", jul: "/jul(y)?/", aug: "/aug(ust)?/", sep: "/sep(t(ember)?)?/", oct: "/oct(ober)?/", nov: "/nov(ember)?/", dec: "/dec(ember)?/", sun: "/^su(n(day)?)?/", mon: "/^mo(n(day)?)?/", tue: "/^tu(e(s(day)?)?)?/", wed: "/^we(d(nesday)?)?/", thu: "/^th(u(r(s(day)?)?)?)?/", fri: "/fr(i(day)?)?/", sat: "/^sa(t(urday)?)?/", future: "/^next/", past: "/^last|past|prev(ious)?/", add: "/^(\\+|aft(er)?|from|hence)/", subtract: "/^(\\-|bef(ore)?|ago)/", yesterday: "/^yes(terday)?/", today: "/^t(od(ay)?)?/", tomorrow: "/^tom(orrow)?/", now: "/^n(ow)?/", millisecond: "/^ms|milli(second)?s?/", second: "/^sec(ond)?s?/", minute: "/^mn|min(ute)?s?/", hour: "/^h(our)?s?/", week: "/^w(eek)?s?/", month: "/^m(onth)?s?/", day: "/^d(ay)?s?/", year: "/^y(ear)?s?/", shortMeridian: "/^(a|p)/", longMeridian: "/^(a\\.?m?\\.?|p\\.?m?\\.?)/", timezone: "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/", ordinalSuffix: "/^\\s*(st|nd|rd|th)/", timeContext: "/^\\s*(\\:|a(?!u|p)|p)/" }, Date.i18n.currentLanguage()); } }; var CultureInfo = function () { var info = getText.getFromObjectValues({ name: "name", englishName: "englishName", nativeName: "nativeName", amDesignator: "AM", pmDesignator: "PM", firstDayOfWeek: "firstDayOfWeek", twoDigitYearMax: "twoDigitYearMax", dateElementOrder: "mdy" }, Date.i18n.currentLanguage()); var constructedInfo = buildInfo.buildFromMethodHash({ dayNames: "days", abbreviatedDayNames: "dayAbbr", shortestDayNames: "dayShortNames", firstLetterDayNames: "dayFirstLetters", monthNames: "months", abbreviatedMonthNames: "monthAbbr", formatPatterns: "formatPatterns", regexPatterns: "regex", abbreviatedTimeZoneDST: "timeZoneDST", abbreviatedTimeZoneStandard: "timeZoneStandard" }); shallowMerge(info, constructedInfo); buildInfo.timeZones(info); return info; }; $D.i18n = { __: function (key, lang) { return __(key, lang); }, currentLanguage: function () { return lang || "en-US"; }, setLanguage: function (code, force, cb) { var async = false; if (force || code === "en-US" || (!!Date.CultureStrings && !!Date.CultureStrings[code])) { lang = code; Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings.lang = code; Date.CultureInfo = new CultureInfo(); } else { if (!(!!Date.CultureStrings && !!Date.CultureStrings[code])) { if (typeof exports !== "undefined" && this.exports !== exports) { // we're in a Node enviroment, load it using require try { require("../i18n/" + code + ".js"); lang = code; Date.CultureStrings.lang = code; Date.CultureInfo = new CultureInfo(); } catch (e) { // var str = "The language for '" + code + "' could not be loaded by Node. It likely does not exist."; throw new Error("The DateJS IETF language tag '" + code + "' could not be loaded by Node. It likely does not exist."); } } else if (Date.Config && Date.Config.i18n) { // we know the location of the files, so lets load them async = true; loadI18nScript(code).done(function(){ lang = code; Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings.lang = code; Date.CultureInfo = new CultureInfo(); $D.Parsing.Normalizer.buildReplaceData(); // because this is async if ($D.Grammar) { $D.Grammar.buildGrammarFormats(); // so we can parse those strings... } if (cb) { setTimeout(cb,0); } }); } else { Date.console.error("The DateJS IETF language tag '" + code + "' is not available and has not been loaded."); return false; } } } $D.Parsing.Normalizer.buildReplaceData(); // rebuild normalizer strings if ($D.Grammar) { $D.Grammar.buildGrammarFormats(); // so we can parse those strings... } if (!async && cb) { setTimeout(cb,0); } }, getLoggedKeys: function () { return loggedKeys; }, updateCultureInfo: function () { Date.CultureInfo = new CultureInfo(); } }; $D.i18n.updateCultureInfo(); // run automatically }()); (function () { var $D = Date, $P = $D.prototype, p = function (s, l) { if (!l) { l = 2; } return ("000" + s).slice(l * -1); }; if (typeof window !== "undefined" && typeof window.console !== "undefined" && typeof window.console.log !== "undefined") { $D.console = console; // used only to raise non-critical errors if available } else { // set mock so we don't give errors. $D.console = { log: function(){}, error: function(){} }; } $D.Config = $D.Config || {}; $D.initOverloads = function() { /** * Overload of Date.now. Allows an alternate call for Date.now where it returns the * current Date as an object rather than just milliseconds since the Unix Epoch. * * Also provides an implementation of now() for browsers (IE<9) that don't have it. * * Backwards compatible so with work with either: * Date.now() [returns ms] * or * Date.now(true) [returns Date] */ if (!$D.now) { $D._now = function now() { return new Date().getTime(); }; } else if (!$D._now) { $D._now = $D.now; } $D.now = function (returnObj) { if (returnObj) { return $D.present(); } else { return $D._now(); } }; if ( !$P.toISOString ) { $P.toISOString = function() { return this.getUTCFullYear() + "-" + p(this.getUTCMonth() + 1) + "-" + p(this.getUTCDate()) + "T" + p(this.getUTCHours()) + ":" + p(this.getUTCMinutes()) + ":" + p(this.getUTCSeconds()) + "." + String( (this.getUTCMilliseconds()/1000).toFixed(3)).slice(2, 5) + "Z"; }; } // private if ( $P._toString === undefined ){ $P._toString = $P.toString; } }; $D.initOverloads(); /** * Gets a date that is set to the current date. The time is set to the start of the day (00:00 or 12:00 AM). * @return {Date} The current date. */ $D.today = function () { return new Date().clearTime(); }; /** * Gets a date that is set to the current date and time (same as new Date, but chainable) * @return {Date} The current date. */ $D.present = function () { return new Date(); }; /** * Compares the first date to the second date and returns an number indication of their relative values. * @param {Date} First Date object to compare [Required]. * @param {Date} Second Date object to compare to [Required]. * @return {Number} -1 = date1 is lessthan date2. 0 = values are equal. 1 = date1 is greaterthan date2. */ $D.compare = function (date1, date2) { if (isNaN(date1) || isNaN(date2)) { throw new Error(date1 + " - " + date2); } else if (date1 instanceof Date && date2 instanceof Date) { return (date1 < date2) ? -1 : (date1 > date2) ? 1 : 0; } else { throw new TypeError(date1 + " - " + date2); } }; /** * Compares the first Date object to the second Date object and returns true if they are equal. * @param {Date} First Date object to compare [Required] * @param {Date} Second Date object to compare to [Required] * @return {Boolean} true if dates are equal. false if they are not equal. */ $D.equals = function (date1, date2) { return (date1.compareTo(date2) === 0); }; /** * Gets the language appropriate day name when given the day number(0-6) * eg - 0 == Sunday * @return {String} The day name */ $D.getDayName = function (n) { return Date.CultureInfo.dayNames[n]; }; /** * Gets the day number (0-6) if given a CultureInfo specific string which is a valid dayName, abbreviatedDayName or shortestDayName (two char). * @param {String} The name of the day (eg. "Monday, "Mon", "tuesday", "tue", "We", "we"). * @return {Number} The day number */ $D.getDayNumberFromName = function (name) { var n = Date.CultureInfo.dayNames, m = Date.CultureInfo.abbreviatedDayNames, o = Date.CultureInfo.shortestDayNames, s = name.toLowerCase(); for (var i = 0; i < n.length; i++) { if (n[i].toLowerCase() === s || m[i].toLowerCase() === s || o[i].toLowerCase() === s) { return i; } } return -1; }; /** * Gets the month number (0-11) if given a Culture Info specific string which is a valid monthName or abbreviatedMonthName. * @param {String} The name of the month (eg. "February, "Feb", "october", "oct"). * @return {Number} The day number */ $D.getMonthNumberFromName = function (name) { var n = Date.CultureInfo.monthNames, m = Date.CultureInfo.abbreviatedMonthNames, s = name.toLowerCase(); for (var i = 0; i < n.length; i++) { if (n[i].toLowerCase() === s || m[i].toLowerCase() === s) { return i; } } return -1; }; /** * Gets the language appropriate month name when given the month number(0-11) * eg - 0 == January * @return {String} The month name */ $D.getMonthName = function (n) { return Date.CultureInfo.monthNames[n]; }; /** * Determines if the current date instance is within a LeapYear. * @param {Number} The year. * @return {Boolean} true if date is within a LeapYear, otherwise false. */ $D.isLeapYear = function (year) { return ((year % 4 === 0 && year % 100 !== 0) || year % 400 === 0); }; /** * Gets the number of days in the month, given a year and month value. Automatically corrects for LeapYear. * @param {Number} The year. * @param {Number} The month (0-11). * @return {Number} The number of days in the month. */ $D.getDaysInMonth = function (year, month) { if (!month && $D.validateMonth(year)) { month = year; year = Date.today().getFullYear(); } return [31, ($D.isLeapYear(year) ? 29 : 28), 31, 30, 31, 30, 31, 31, 30, 31, 30, 31][month]; }; $P.getDaysInMonth = function () { return $D.getDaysInMonth(this.getFullYear(), this.getMonth()); }; $D.getTimezoneAbbreviation = function (offset, dst) { var p, n = (dst || false) ? Date.CultureInfo.abbreviatedTimeZoneDST : Date.CultureInfo.abbreviatedTimeZoneStandard; for (p in n) { if (n.hasOwnProperty(p)) { if (n[p] === offset) { return p; } } } return null; }; $D.getTimezoneOffset = function (name, dst) { var i, a =[], z = Date.CultureInfo.timezones; if (!name) { name = (new Date()).getTimezone();} for (i = 0; i < z.length; i++) { if (z[i].name === name.toUpperCase()) { a.push(i); } } if (!z[a[0]]) { return null; } if (a.length === 1 || !dst) { return z[a[0]].offset; } else { for (i=0; i < a.length; i++) { if (z[a[i]].dst) { return z[a[i]].offset; } } } }; $D.getQuarter = function (d) { d = d || new Date(); // If no date supplied, use today var q = [1,2,3,4]; return q[Math.floor(d.getMonth() / 3)]; // ~~~ is a bitwise op. Faster than Math.floor }; $D.getDaysLeftInQuarter = function (d) { d = d || new Date(); var qEnd = new Date(d); qEnd.setMonth(qEnd.getMonth() + 3 - qEnd.getMonth() % 3, 0); return Math.floor((qEnd - d) / 8.64e7); }; // private var validate = function (n, min, max, name) { name = name ? name : "Object"; if (typeof n === "undefined") { return false; } else if (typeof n !== "number") { throw new TypeError(n + " is not a Number."); } else if (n < min || n > max) { // As failing validation is *not* an exceptional circumstance // lets not throw a RangeError Exception here. // It's semantically correct but it's not sensible. return false; } return true; }; /** * Validates the number is within an acceptable range for milliseconds [0-999]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateMillisecond = function (value) { return validate(value, 0, 999, "millisecond"); }; /** * Validates the number is within an acceptable range for seconds [0-59]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateSecond = function (value) { return validate(value, 0, 59, "second"); }; /** * Validates the number is within an acceptable range for minutes [0-59]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateMinute = function (value) { return validate(value, 0, 59, "minute"); }; /** * Validates the number is within an acceptable range for hours [0-23]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateHour = function (value) { return validate(value, 0, 23, "hour"); }; /** * Validates the number is within an acceptable range for the days in a month [0-MaxDaysInMonth]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateDay = function (value, year, month) { if (year === undefined || year === null || month === undefined || month === null) { return false;} return validate(value, 1, $D.getDaysInMonth(year, month), "day"); }; /** * Validates the number is within an acceptable range for months [0-11]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateWeek = function (value) { return validate(value, 0, 53, "week"); }; /** * Validates the number is within an acceptable range for months [0-11]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateMonth = function (value) { return validate(value, 0, 11, "month"); }; /** * Validates the number is within an acceptable range for years. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateYear = function (value) { /** * Per ECMAScript spec the range of times supported by Date objects is * exactly -100,000,000 days to +100,000,000 days measured relative to * midnight at the beginning of 01 January, 1970 UTC. * This gives a range of 8,640,000,000,000,000 milliseconds to either * side of 01 January, 1970 UTC. * * Earliest possible date: Tue, 20 Apr 271,822 B.C. 00:00:00 UTC * Latest possible date: Sat, 13 Sep 275,760 00:00:00 UTC */ return validate(value, -271822, 275760, "year"); }; $D.validateTimezone = function(value) { var timezones = {"ACDT":1,"ACST":1,"ACT":1,"ADT":1,"AEDT":1,"AEST":1,"AFT":1,"AKDT":1,"AKST":1,"AMST":1,"AMT":1,"ART":1,"AST":1,"AWDT":1,"AWST":1,"AZOST":1,"AZT":1,"BDT":1,"BIOT":1,"BIT":1,"BOT":1,"BRT":1,"BST":1,"BTT":1,"CAT":1,"CCT":1,"CDT":1,"CEDT":1,"CEST":1,"CET":1,"CHADT":1,"CHAST":1,"CHOT":1,"ChST":1,"CHUT":1,"CIST":1,"CIT":1,"CKT":1,"CLST":1,"CLT":1,"COST":1,"COT":1,"CST":1,"CT":1,"CVT":1,"CWST":1,"CXT":1,"DAVT":1,"DDUT":1,"DFT":1,"EASST":1,"EAST":1,"EAT":1,"ECT":1,"EDT":1,"EEDT":1,"EEST":1,"EET":1,"EGST":1,"EGT":1,"EIT":1,"EST":1,"FET":1,"FJT":1,"FKST":1,"FKT":1,"FNT":1,"GALT":1,"GAMT":1,"GET":1,"GFT":1,"GILT":1,"GIT":1,"GMT":1,"GST":1,"GYT":1,"HADT":1,"HAEC":1,"HAST":1,"HKT":1,"HMT":1,"HOVT":1,"HST":1,"ICT":1,"IDT":1,"IOT":1,"IRDT":1,"IRKT":1,"IRST":1,"IST":1,"JST":1,"KGT":1,"KOST":1,"KRAT":1,"KST":1,"LHST":1,"LINT":1,"MAGT":1,"MART":1,"MAWT":1,"MDT":1,"MET":1,"MEST":1,"MHT":1,"MIST":1,"MIT":1,"MMT":1,"MSK":1,"MST":1,"MUT":1,"MVT":1,"MYT":1,"NCT":1,"NDT":1,"NFT":1,"NPT":1,"NST":1,"NT":1,"NUT":1,"NZDT":1,"NZST":1,"OMST":1,"ORAT":1,"PDT":1,"PET":1,"PETT":1,"PGT":1,"PHOT":1,"PHT":1,"PKT":1,"PMDT":1,"PMST":1,"PONT":1,"PST":1,"PYST":1,"PYT":1,"RET":1,"ROTT":1,"SAKT":1,"SAMT":1,"SAST":1,"SBT":1,"SCT":1,"SGT":1,"SLST":1,"SRT":1,"SST":1,"SYOT":1,"TAHT":1,"THA":1,"TFT":1,"TJT":1,"TKT":1,"TLT":1,"TMT":1,"TOT":1,"TVT":1,"UCT":1,"ULAT":1,"UTC":1,"UYST":1,"UYT":1,"UZT":1,"VET":1,"VLAT":1,"VOLT":1,"VOST":1,"VUT":1,"WAKT":1,"WAST":1,"WAT":1,"WEDT":1,"WEST":1,"WET":1,"WST":1,"YAKT":1,"YEKT":1,"Z":1}; return (timezones[value] === 1); }; $D.validateTimezoneOffset= function(value) { // timezones go from +14hrs to -12hrs, the +X hours are negative offsets. return (value > -841 && value < 721); }; }()); (function () { var $D = Date, $P = $D.prototype, p = function (s, l) { if (!l) { l = 2; } return ("000" + s).slice(l * -1); }; var validateConfigObject = function (obj) { var result = {}, self = this, prop, testFunc; testFunc = function (prop, func, value) { if (prop === "day") { var month = (obj.month !== undefined) ? obj.month : self.getMonth(); var year = (obj.year !== undefined) ? obj.year : self.getFullYear(); return $D[func](value, year, month); } else { return $D[func](value); } }; for (prop in obj) { if (Object.prototype.hasOwnProperty.call(obj, prop)) { var func = "validate" + prop.charAt(0).toUpperCase() + prop.slice(1); if ($D[func] && obj[prop] !== null && testFunc(prop, func, obj[prop])) { result[prop] = obj[prop]; } } } return result; }; /** * Resets the time of this Date object to 12:00 AM (00:00), which is the start of the day. * @param {Boolean} .clone() this date instance before clearing Time * @return {Date} this */ $P.clearTime = function () { this.setHours(0); this.setMinutes(0); this.setSeconds(0); this.setMilliseconds(0); return this; }; /** * Resets the time of this Date object to the current time ('now'). * @return {Date} this */ $P.setTimeToNow = function () { var n = new Date(); this.setHours(n.getHours()); this.setMinutes(n.getMinutes()); this.setSeconds(n.getSeconds()); this.setMilliseconds(n.getMilliseconds()); return this; }; /** * Returns a new Date object that is an exact date and time copy of the original instance. * @return {Date} A new Date instance */ $P.clone = function () { return new Date(this.getTime()); }; /** * Compares this instance to a Date object and returns an number indication of their relative values. * @param {Date} Date object to compare [Required] * @return {Number} -1 = this is lessthan date. 0 = values are equal. 1 = this is greaterthan date. */ $P.compareTo = function (date) { return Date.compare(this, date); }; /** * Compares this instance to another Date object and returns true if they are equal. * @param {Date} Date object to compare. If no date to compare, new Date() [now] is used. * @return {Boolean} true if dates are equal. false if they are not equal. */ $P.equals = function (date) { return Date.equals(this, (date !== undefined ? date : new Date())); }; /** * Determines if this instance is between a range of two dates or equal to either the start or end dates. * @param {Date} Start of range [Required] * @param {Date} End of range [Required] * @return {Boolean} true is this is between or equal to the start and end dates, else false */ $P.between = function (start, end) { return this.getTime() >= start.getTime() && this.getTime() <= end.getTime(); }; /** * Determines if this date occurs after the date to compare to. * @param {Date} Date object to compare. If no date to compare, new Date() ("now") is used. * @return {Boolean} true if this date instance is greater than the date to compare to (or "now"), otherwise false. */ $P.isAfter = function (date) { return this.compareTo(date || new Date()) === 1; }; /** * Determines if this date occurs before the date to compare to. * @param {Date} Date object to compare. If no date to compare, new Date() ("now") is used. * @return {Boolean} true if this date instance is less than the date to compare to (or "now"). */ $P.isBefore = function (date) { return (this.compareTo(date || new Date()) === -1); }; /** * Determines if the current Date instance occurs today. * @return {Boolean} true if this date instance is 'today', otherwise false. */ /** * Determines if the current Date instance occurs on the same Date as the supplied 'date'. * If no 'date' to compare to is provided, the current Date instance is compared to 'today'. * @param {date} Date object to compare. If no date to compare, the current Date ("now") is used. * @return {Boolean} true if this Date instance occurs on the same Day as the supplied 'date'. */ $P.isToday = $P.isSameDay = function (date) { return this.clone().clearTime().equals((date || new Date()).clone().clearTime()); }; /** * Adds the specified number of milliseconds to this instance. * @param {Number} The number of milliseconds to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addMilliseconds = function (value) { if (!value) { return this; } this.setTime(this.getTime() + value * 1); return this; }; /** * Adds the specified number of seconds to this instance. * @param {Number} The number of seconds to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addSeconds = function (value) { if (!value) { return this; } return this.addMilliseconds(value * 1000); }; /** * Adds the specified number of seconds to this instance. * @param {Number} The number of seconds to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addMinutes = function (value) { if (!value) { return this; } return this.addMilliseconds(value * 60000); // 60*1000 }; /** * Adds the specified number of hours to this instance. * @param {Number} The number of hours to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addHours = function (value) { if (!value) { return this; } return this.addMilliseconds(value * 3600000); // 60*60*1000 }; /** * Adds the specified number of days to this instance. * @param {Number} The number of days to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addDays = function (value) { if (!value) { return this; } this.setDate(this.getDate() + value * 1); return this; }; /** * Adds the specified number of weekdays (ie - not sat or sun) to this instance. * @param {Number} The number of days to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addWeekdays = function (value) { if (!value) { return this; } var day = this.getDay(); var weeks = (Math.ceil(Math.abs(value)/7)); if (day === 0 || day === 6) { if (value > 0) { this.next().monday(); this.addDays(-1); day = this.getDay(); } } if (value < 0) { while (value < 0) { this.addDays(-1); day = this.getDay(); if (day !== 0 && day !== 6) { value++; } } return this; } else if (value > 5 || (6-day) <= value) { value = value + (weeks * 2); } return this.addDays(value); }; /** * Adds the specified number of weeks to this instance. * @param {Number} The number of weeks to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addWeeks = function (value) { if (!value) { return this; } return this.addDays(value * 7); }; /** * Adds the specified number of months to this instance. * @param {Number} The number of months to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addMonths = function (value) { if (!value) { return this; } var n = this.getDate(); this.setDate(1); this.setMonth(this.getMonth() + value * 1); this.setDate(Math.min(n, $D.getDaysInMonth(this.getFullYear(), this.getMonth()))); return this; }; $P.addQuarters = function (value) { if (!value) { return this; } // note this will take you to the same point in the quarter as you are now. // i.e. - if you are 15 days into the quarter you'll be 15 days into the resulting one. // bonus: this allows adding fractional quarters return this.addMonths(value * 3); }; /** * Adds the specified number of years to this instance. * @param {Number} The number of years to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addYears = function (value) { if (!value) { return this; } return this.addMonths(value * 12); }; /** * Adds (or subtracts) to the value of the years, months, weeks, days, hours, minutes, seconds, milliseconds of the date instance using given configuration object. Positive and Negative values allowed. * Example

	Date.today().add( { days: 1, months: 1 } )

	new Date().add( { years: -1 } )
	
* @param {Object} Configuration object containing attributes (months, days, etc.) * @return {Date} this */ $P.add = function (config) { if (typeof config === "number") { this._orient = config; return this; } var x = config; if (x.day) { // If we should be a different date than today (eg: for 'tomorrow -1d', etc). // Should only effect parsing, not direct usage (eg, Finish and FinishExact) if ((x.day - this.getDate()) !== 0) { this.setDate(x.day); } } if (x.milliseconds) { this.addMilliseconds(x.milliseconds); } if (x.seconds) { this.addSeconds(x.seconds); } if (x.minutes) { this.addMinutes(x.minutes); } if (x.hours) { this.addHours(x.hours); } if (x.weeks) { this.addWeeks(x.weeks); } if (x.months) { this.addMonths(x.months); } if (x.years) { this.addYears(x.years); } if (x.days) { this.addDays(x.days); } return this; }; /** * Get the week number. Week one (1) is the week which contains the first Thursday of the year. Monday is considered the first day of the week. * The .getWeek() function does NOT convert the date to UTC. The local datetime is used. * Please use .getISOWeek() to get the week of the UTC converted date. * @return {Number} 1 to 53 */ $P.getWeek = function (utc) { // Create a copy of this date object var self, target = new Date(this.valueOf()); if (utc) { target.addMinutes(target.getTimezoneOffset()); self = target.clone(); } else { self = this; } // ISO week date weeks start on monday // so correct the day number var dayNr = (self.getDay() + 6) % 7; // ISO 8601 states that week 1 is the week // with the first thursday of that year. // Set the target date to the thursday in the target week target.setDate(target.getDate() - dayNr + 3); // Store the millisecond value of the target date var firstThursday = target.valueOf(); // Set the target to the first thursday of the year // First set the target to january first target.setMonth(0, 1); // Not a thursday? Correct the date to the next thursday if (target.getDay() !== 4) { target.setMonth(0, 1 + ((4 - target.getDay()) + 7) % 7); } // The weeknumber is the number of weeks between the // first thursday of the year and the thursday in the target week return 1 + Math.ceil((firstThursday - target) / 604800000); // 604800000 = 7 * 24 * 3600 * 1000 }; /** * Get the ISO 8601 week number. Week one ("01") is the week which contains the first Thursday of the year. Monday is considered the first day of the week. * The .getISOWeek() function does convert the date to it's UTC value. Please use .getWeek() to get the week of the local date. * @return {String} "01" to "53" */ $P.getISOWeek = function () { return p(this.getWeek(true)); }; /** * Moves the date to Monday of the week set. Week one (1) is the week which contains the first Thursday of the year. * @param {Number} A Number (1 to 53) that represents the week of the year. * @return {Date} this */ $P.setWeek = function (n) { if ((n - this.getWeek()) === 0) { if (this.getDay() !== 1) { return this.moveToDayOfWeek(1, (this.getDay() > 1 ? -1 : 1)); } else { return this; } } else { return this.moveToDayOfWeek(1, (this.getDay() > 1 ? -1 : 1)).addWeeks(n - this.getWeek()); } }; $P.setQuarter = function (qtr) { var month = Math.abs(((qtr-1) * 3) + 1); return this.setMonth(month, 1); }; $P.getQuarter = function () { return Date.getQuarter(this); }; $P.getDaysLeftInQuarter = function () { return Date.getDaysLeftInQuarter(this); }; /** * Moves the date to the next n'th occurrence of the dayOfWeek starting from the beginning of the month. The number (-1) is a magic number and will return the last occurrence of the dayOfWeek in the month. * @param {Number} The dayOfWeek to move to * @param {Number} The n'th occurrence to move to. Use (-1) to return the last occurrence in the month * @return {Date} this */ $P.moveToNthOccurrence = function (dayOfWeek, occurrence) { if (dayOfWeek === "Weekday") { if (occurrence > 0) { this.moveToFirstDayOfMonth(); if (this.is().weekday()) { occurrence -= 1; } } else if (occurrence < 0) { this.moveToLastDayOfMonth(); if (this.is().weekday()) { occurrence += 1; } } else { return this; } return this.addWeekdays(occurrence); } var shift = 0; if (occurrence > 0) { shift = occurrence - 1; } else if (occurrence === -1) { this.moveToLastDayOfMonth(); if (this.getDay() !== dayOfWeek) { this.moveToDayOfWeek(dayOfWeek, -1); } return this; } return this.moveToFirstDayOfMonth().addDays(-1).moveToDayOfWeek(dayOfWeek, +1).addWeeks(shift); }; var moveToN = function (getFunc, addFunc, nVal) { return function (value, orient) { var diff = (value - this[getFunc]() + nVal * (orient || +1)) % nVal; return this[addFunc]((diff === 0) ? diff += nVal * (orient || +1) : diff); }; }; /** * Move to the next or last dayOfWeek based on the orient value. * @param {Number} The dayOfWeek to move to * @param {Number} Forward (+1) or Back (-1). Defaults to +1. [Optional] * @return {Date} this */ $P.moveToDayOfWeek = moveToN("getDay", "addDays", 7); /** * Move to the next or last month based on the orient value. * @param {Number} The month to move to. 0 = January, 11 = December * @param {Number} Forward (+1) or Back (-1). Defaults to +1. [Optional] * @return {Date} this */ $P.moveToMonth = moveToN("getMonth", "addMonths", 12); /** * Get the Ordinate of the current day ("th", "st", "rd"). * @return {String} */ $P.getOrdinate = function () { var num = this.getDate(); return ord(num); }; /** * Get the Ordinal day (numeric day number) of the year, adjusted for leap year. * @return {Number} 1 through 365 (366 in leap years) */ $P.getOrdinalNumber = function () { return Math.ceil((this.clone().clearTime() - new Date(this.getFullYear(), 0, 1)) / 86400000) + 1; }; /** * Get the time zone abbreviation of the current date. * @return {String} The abbreviated time zone name (e.g. "EST") */ $P.getTimezone = function () { return $D.getTimezoneAbbreviation(this.getUTCOffset(), this.isDaylightSavingTime()); }; $P.setTimezoneOffset = function (offset) { var here = this.getTimezoneOffset(), there = Number(offset) * -6 / 10; return (there || there === 0) ? this.addMinutes(there - here) : this; }; $P.setTimezone = function (offset) { return this.setTimezoneOffset($D.getTimezoneOffset(offset)); }; /** * Indicates whether Daylight Saving Time is observed in the current time zone. * @return {Boolean} true|false */ $P.hasDaylightSavingTime = function () { return (Date.today().set({month: 0, day: 1}).getTimezoneOffset() !== Date.today().set({month: 6, day: 1}).getTimezoneOffset()); }; /** * Indicates whether this Date instance is within the Daylight Saving Time range for the current time zone. * @return {Boolean} true|false */ $P.isDaylightSavingTime = function () { return Date.today().set({month: 0, day: 1}).getTimezoneOffset() !== this.getTimezoneOffset(); }; /** * Get the offset from UTC of the current date. * @return {String} The 4-character offset string prefixed with + or - (e.g. "-0500") */ $P.getUTCOffset = function (offset) { var n = (offset || this.getTimezoneOffset()) * -10 / 6, r; if (n < 0) { r = (n - 10000).toString(); return r.charAt(0) + r.substr(2); } else { r = (n + 10000).toString(); return "+" + r.substr(1); } }; /** * Returns the number of milliseconds between this date and date. * @param {Date} Defaults to now * @return {Number} The diff in milliseconds */ $P.getElapsed = function (date) { return (date || new Date()) - this; }; /** * Set the value of year, month, day, hour, minute, second, millisecond of date instance using given configuration object. * Example

	Date.today().set( { day: 20, month: 1 } )

	new Date().set( { millisecond: 0 } )
	
* * @param {Object} Configuration object containing attributes (month, day, etc.) * @return {Date} this */ $P.set = function (config) { config = validateConfigObject.call(this, config); var key; for (key in config) { if (Object.prototype.hasOwnProperty.call(config, key)) { var name = key.charAt(0).toUpperCase() + key.slice(1); var addFunc, getFunc; if (key !== "week" && key !== "month" && key !== "timezone" && key !== "timezoneOffset") { name += "s"; } addFunc = "add" + name; getFunc = "get" + name; if (key === "month") { addFunc = addFunc + "s"; } else if (key === "year"){ getFunc = "getFullYear"; } if (key !== "day" && key !== "timezone" && key !== "timezoneOffset" && key !== "week" && key !== "hour") { this[addFunc](config[key] - this[getFunc]()); } else if ( key === "timezone"|| key === "timezoneOffset" || key === "week" || key === "hour") { this["set"+name](config[key]); } } } // day has to go last because you can't validate the day without first knowing the month if (config.day) { this.addDays(config.day - this.getDate()); } return this; }; /** * Moves the date to the first day of the month. * @return {Date} this */ $P.moveToFirstDayOfMonth = function () { return this.set({ day: 1 }); }; /** * Moves the date to the last day of the month. * @return {Date} this */ $P.moveToLastDayOfMonth = function () { return this.set({ day: $D.getDaysInMonth(this.getFullYear(), this.getMonth())}); }; /** * Converts the value of the current Date object to its equivalent string representation. * Format Specifiers * CUSTOM DATE AND TIME FORMAT STRINGS * Format Description Example * ------ --------------------------------------------------------------------------- ----------------------- * s The seconds of the minute between 0-59. "0" to "59" * ss The seconds of the minute with leading zero if required. "00" to "59" * * m The minute of the hour between 0-59. "0" or "59" * mm The minute of the hour with leading zero if required. "00" or "59" * * h The hour of the day between 1-12. "1" to "12" * hh The hour of the day with leading zero if required. "01" to "12" * * H The hour of the day between 0-23. "0" to "23" * HH The hour of the day with leading zero if required. "00" to "23" * * d The day of the month between 1 and 31. "1" to "31" * dd The day of the month with leading zero if required. "01" to "31" * ddd Abbreviated day name. Date.CultureInfo.abbreviatedDayNames. "Mon" to "Sun" * dddd The full day name. Date.CultureInfo.dayNames. "Monday" to "Sunday" * * M The month of the year between 1-12. "1" to "12" * MM The month of the year with leading zero if required. "01" to "12" * MMM Abbreviated month name. Date.CultureInfo.abbreviatedMonthNames. "Jan" to "Dec" * MMMM The full month name. Date.CultureInfo.monthNames. "January" to "December" * * yy The year as a two-digit number. "99" or "08" * yyyy The full four digit year. "1999" or "2008" * * t Displays the first character of the A.M./P.M. designator. "A" or "P" * Date.CultureInfo.amDesignator or Date.CultureInfo.pmDesignator * tt Displays the A.M./P.M. designator. "AM" or "PM" * Date.CultureInfo.amDesignator or Date.CultureInfo.pmDesignator * * S The ordinal suffix ("st, "nd", "rd" or "th") of the current day. "st, "nd", "rd" or "th" * * STANDARD DATE AND TIME FORMAT STRINGS * Format Description Example *------ --------------------------------------------------------------------------- ----------------------- * d The CultureInfo shortDate Format Pattern "M/d/yyyy" * D The CultureInfo longDate Format Pattern "dddd, MMMM dd, yyyy" * F The CultureInfo fullDateTime Format Pattern "dddd, MMMM dd, yyyy h:mm:ss tt" * m The CultureInfo monthDay Format Pattern "MMMM dd" * r The CultureInfo rfc1123 Format Pattern "ddd, dd MMM yyyy HH:mm:ss GMT" * s The CultureInfo sortableDateTime Format Pattern "yyyy-MM-ddTHH:mm:ss" * t The CultureInfo shortTime Format Pattern "h:mm tt" * T The CultureInfo longTime Format Pattern "h:mm:ss tt" * u The CultureInfo universalSortableDateTime Format Pattern "yyyy-MM-dd HH:mm:ssZ" * y The CultureInfo yearMonth Format Pattern "MMMM, yyyy" * * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @return {String} A string representation of the current Date object. */ var ord = function (n) { switch (n * 1) { case 1: case 21: case 31: return "st"; case 2: case 22: return "nd"; case 3: case 23: return "rd"; default: return "th"; } }; var parseStandardFormats = function (format) { var y, c = Date.CultureInfo.formatPatterns; switch (format) { case "d": return this.toString(c.shortDate); case "D": return this.toString(c.longDate); case "F": return this.toString(c.fullDateTime); case "m": return this.toString(c.monthDay); case "r": case "R": y = this.clone().addMinutes(this.getTimezoneOffset()); return y.toString(c.rfc1123) + " GMT"; case "s": return this.toString(c.sortableDateTime); case "t": return this.toString(c.shortTime); case "T": return this.toString(c.longTime); case "u": y = this.clone().addMinutes(this.getTimezoneOffset()); return y.toString(c.universalSortableDateTime); case "y": return this.toString(c.yearMonth); default: return false; } }; var parseFormatStringsClosure = function (context) { return function (m) { if (m.charAt(0) === "\\") { return m.replace("\\", ""); } switch (m) { case "hh": return p(context.getHours() < 13 ? (context.getHours() === 0 ? 12 : context.getHours()) : (context.getHours() - 12)); case "h": return context.getHours() < 13 ? (context.getHours() === 0 ? 12 : context.getHours()) : (context.getHours() - 12); case "HH": return p(context.getHours()); case "H": return context.getHours(); case "mm": return p(context.getMinutes()); case "m": return context.getMinutes(); case "ss": return p(context.getSeconds()); case "s": return context.getSeconds(); case "yyyy": return p(context.getFullYear(), 4); case "yy": return p(context.getFullYear()); case "y": return context.getFullYear(); case "E": case "dddd": return Date.CultureInfo.dayNames[context.getDay()]; case "ddd": return Date.CultureInfo.abbreviatedDayNames[context.getDay()]; case "dd": return p(context.getDate()); case "d": return context.getDate(); case "MMMM": return Date.CultureInfo.monthNames[context.getMonth()]; case "MMM": return Date.CultureInfo.abbreviatedMonthNames[context.getMonth()]; case "MM": return p((context.getMonth() + 1)); case "M": return context.getMonth() + 1; case "t": return context.getHours() < 12 ? Date.CultureInfo.amDesignator.substring(0, 1) : Date.CultureInfo.pmDesignator.substring(0, 1); case "tt": return context.getHours() < 12 ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator; case "S": return ord(context.getDate()); case "W": return context.getWeek(); case "WW": return context.getISOWeek(); case "Q": return "Q" + context.getQuarter(); case "q": return String(context.getQuarter()); case "z": return context.getTimezone(); case "Z": case "X": return Date.getTimezoneOffset(context.getTimezone()); case "ZZ": // Timezone offset in seconds return context.getTimezoneOffset() * -60; case "u": return context.getDay(); case "L": return ($D.isLeapYear(context.getFullYear())) ? 1 : 0; case "B": // Swatch Internet Time (.beats) return "@"+((context.getUTCSeconds() + (context.getUTCMinutes()*60) + ((context.getUTCHours()+1)*3600))/86.4); default: return m; } }; }; $P.toString = function (format, ignoreStandards) { // Standard Date and Time Format Strings. Formats pulled from CultureInfo file and // may vary by culture. if (!ignoreStandards && format && format.length === 1) { output = parseStandardFormats.call(this, format); if (output) { return output; } } var parseFormatStrings = parseFormatStringsClosure(this); return format ? format.replace(/((\\)?(dd?d?d?|MM?M?M?|yy?y?y?|hh?|HH?|mm?|ss?|tt?|S|q|Q|WW?W?W?)(?![^\[]*\]))/g, parseFormatStrings).replace(/\[|\]/g, "") : this._toString(); }; }()); /************************************************************* * SugarPak - Domain Specific Language - Syntactical Sugar * *************************************************************/ (function () { var $D = Date, $P = $D.prototype, $N = Number.prototype; // private $P._orient = +1; // private $P._nth = null; // private $P._is = false; // private $P._same = false; // private $P._isSecond = false; // private $N._dateElement = "days"; /** * Moves the date to the next instance of a date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.today().next().friday();
	Date.today().next().fri();
	Date.today().next().march();
	Date.today().next().mar();
	Date.today().next().week();
	
* * @return {Date} date */ $P.next = function () { this._move = true; this._orient = +1; return this; }; /** * Creates a new Date (Date.today()) and moves the date to the next instance of the date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.next().friday();
	Date.next().fri();
	Date.next().march();
	Date.next().mar();
	Date.next().week();
	
* * @return {Date} date */ $D.next = function () { return $D.today().next(); }; /** * Moves the date to the previous instance of a date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.today().last().friday();
	Date.today().last().fri();
	Date.today().last().march();
	Date.today().last().mar();
	Date.today().last().week();
	
* * @return {Date} date */ $P.last = $P.prev = $P.previous = function () { this._move = true; this._orient = -1; return this; }; /** * Creates a new Date (Date.today()) and moves the date to the previous instance of the date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.last().friday();
	Date.last().fri();
	Date.previous().march();
	Date.prev().mar();
	Date.last().week();
	
* * @return {Date} date */ $D.last = $D.prev = $D.previous = function () { return $D.today().last(); }; /** * Performs a equality check when followed by either a month name, day name or .weekday() function. * Example

	Date.today().is().friday(); // true|false
	Date.today().is().fri();
	Date.today().is().march();
	Date.today().is().mar();
	
* * @return {Boolean} true|false */ $P.is = function () { this._is = true; return this; }; /** * Determines if two date objects occur on/in exactly the same instance of the subsequent date part function. * The function .same() must be followed by a date part function (example: .day(), .month(), .year(), etc). * * An optional Date can be passed in the date part function. If now date is passed as a parameter, 'Now' is used. * * The following example demonstrates how to determine if two dates fall on the exact same day. * * Example

	var d1 = Date.today(); // today at 00:00
	var d2 = new Date();   // exactly now.

	// Do they occur on the same day?
	d1.same().day(d2); // true
	
	// Do they occur on the same hour?
	d1.same().hour(d2); // false, unless d2 hour is '00' (midnight).
	
	// What if it's the same day, but one year apart?
	var nextYear = Date.today().add(1).year();

	d1.same().day(nextYear); // false, because the dates must occur on the exact same day. 
	
* * Scenario: Determine if a given date occurs during some week period 2 months from now. * * Example

	var future = Date.today().add(2).months();
	return someDate.same().week(future); // true|false;
	
* * @return {Boolean} true|false */ $P.same = function () { this._same = true; this._isSecond = false; return this; }; /** * Determines if the current date/time occurs during Today. Must be preceded by the .is() function. * Example

	someDate.is().today();    // true|false
	new Date().is().today();  // true
	Date.today().is().today();// true
	Date.today().add(-1).day().is().today(); // false
	
* * @return {Boolean} true|false */ $P.today = function () { return this.same().day(); }; /** * Determines if the current date is a weekday. This function must be preceded by the .is() function. * Example

	Date.today().is().weekday(); // true|false
	
* * @return {Boolean} true|false */ $P.weekday = function () { if (this._nth) { return df("Weekday").call(this); } if (this._move) { return this.addWeekdays(this._orient); } if (this._is) { this._is = false; return (!this.is().sat() && !this.is().sun()); } return false; }; /** * Determines if the current date is on the weekend. This function must be preceded by the .is() function. * Example

	Date.today().is().weekend(); // true|false
	
* * @return {Boolean} true|false */ $P.weekend = function () { if (this._is) { this._is = false; return (this.is().sat() || this.is().sun()); } return false; }; /** * Sets the Time of the current Date instance. A string "6:15 pm" or config object {hour:18, minute:15} are accepted. * Example

	// Set time to 6:15pm with a String
	Date.today().at("6:15pm");

	// Set time to 6:15pm with a config object
	Date.today().at({hour:18, minute:15});
	
* * @return {Date} date */ $P.at = function (time) { return (typeof time === "string") ? $D.parse(this.toString("d") + " " + time) : this.set(time); }; /** * Creates a new Date() and adds this (Number) to the date based on the preceding date element function (eg. second|minute|hour|day|month|year). * Example

	// Undeclared Numbers must be wrapped with parentheses. Requirment of JavaScript.
	(3).days().fromNow();
	(6).months().fromNow();

	// Declared Number variables do not require parentheses. 
	var n = 6;
	n.months().fromNow();
	
* * @return {Date} A new Date instance */ $N.fromNow = $N.after = function (date) { var c = {}; c[this._dateElement] = this; return ((!date) ? new Date() : date.clone()).add(c); }; /** * Creates a new Date() and subtract this (Number) from the date based on the preceding date element function (eg. second|minute|hour|day|month|year). * Example

	// Undeclared Numbers must be wrapped with parentheses. Requirment of JavaScript.
	(3).days().ago();
	(6).months().ago();

	// Declared Number variables do not require parentheses. 
	var n = 6;
	n.months().ago();
	
* * @return {Date} A new Date instance */ $N.ago = $N.before = function (date) { var c = {}, s = (this._dateElement[this._dateElement.length-1] !== "s") ? this._dateElement + "s" : this._dateElement; c[s] = this * -1; return ((!date) ? new Date() : date.clone()).add(c); }; // Do NOT modify the following string tokens. These tokens are used to build dynamic functions. // All culture-specific strings can be found in the CultureInfo files. var dx = ("sunday monday tuesday wednesday thursday friday saturday").split(/\s/), mx = ("january february march april may june july august september october november december").split(/\s/), px = ("Millisecond Second Minute Hour Day Week Month Year Quarter Weekday").split(/\s/), pxf = ("Milliseconds Seconds Minutes Hours Date Week Month FullYear Quarter").split(/\s/), nth = ("final first second third fourth fifth").split(/\s/), de; /** * Returns an object literal of all the date parts. * Example

	var o = new Date().toObject();
	
	// { year: 2008, month: 4, week: 20, day: 13, hour: 18, minute: 9, second: 32, millisecond: 812 }
	
	// The object properties can be referenced directly from the object.
	
	alert(o.day);  // alerts "13"
	alert(o.year); // alerts "2008"
	
* * @return {Date} An object literal representing the original date object. */ $P.toObject = function () { var o = {}; for (var i = 0; i < px.length; i++) { if (this["get" + pxf[i]]) { o[px[i].toLowerCase()] = this["get" + pxf[i]](); } } return o; }; /** * Returns a date created from an object literal. Ignores the .week property if set in the config. * Example

	var o = new Date().toObject();
	
	return Date.fromObject(o); // will return the same date. 

	var o2 = {month: 1, day: 20, hour: 18}; // birthday party!
	Date.fromObject(o2);
	
* * @return {Date} An object literal representing the original date object. */ $D.fromObject = function(config) { config.week = null; return Date.today().set(config); }; // Create day name functions and abbreviated day name functions (eg. monday(), friday(), fri()). var df = function (n) { return function () { if (this._is) { this._is = false; return this.getDay() === n; } if (this._move) { this._move = null; } if (this._nth !== null) { // If the .second() function was called earlier, remove the _orient // from the date, and then continue. // This is required because 'second' can be used in two different context. // // Example // // Date.today().add(1).second(); // Date.march().second().monday(); // // Things get crazy with the following... // Date.march().add(1).second().second().monday(); // but it works!! // if (this._isSecond) { this.addSeconds(this._orient * -1); } // make sure we reset _isSecond this._isSecond = false; var ntemp = this._nth; this._nth = null; var temp = this.clone().moveToLastDayOfMonth(); this.moveToNthOccurrence(n, ntemp); if (this > temp) { throw new RangeError($D.getDayName(n) + " does not occur " + ntemp + " times in the month of " + $D.getMonthName(temp.getMonth()) + " " + temp.getFullYear() + "."); } return this; } return this.moveToDayOfWeek(n, this._orient); }; }; var sdf = function (n) { return function () { var t = $D.today(), shift = n - t.getDay(); if (n === 0 && Date.CultureInfo.firstDayOfWeek === 1 && t.getDay() !== 0) { shift = shift + 7; } return t.addDays(shift); }; }; // Create month name functions and abbreviated month name functions (eg. january(), march(), mar()). var month_instance_functions = function (n) { return function () { if (this._is) { this._is = false; return this.getMonth() === n; } return this.moveToMonth(n, this._orient); }; }; var month_static_functions = function (n) { return function () { return $D.today().set({ month: n, day: 1 }); }; }; var processTerms = function (names, staticFunc, instanceFunc) { for (var i = 0; i < names.length; i++) { // Create constant static Name variables. $D[names[i].toUpperCase()] = $D[names[i].toUpperCase().substring(0, 3)] = i; // Create Name functions. $D[names[i]] = $D[names[i].substring(0, 3)] = staticFunc(i); // Create Name instance functions. $P[names[i]] = $P[names[i].substring(0, 3)] = instanceFunc(i); } }; processTerms(dx, sdf, df); processTerms(mx, month_static_functions, month_instance_functions); // Create date element functions and plural date element functions used with Date (eg. day(), days(), months()). var ef = function (j) { return function () { // if the .second() function was called earlier, the _orient // has alread been added. Just return this and reset _isSecond. if (this._isSecond) { this._isSecond = false; return this; } if (this._same) { this._same = this._is = false; var o1 = this.toObject(), o2 = (arguments[0] || new Date()).toObject(), v = "", k = j.toLowerCase(); // the substr trick with -1 doesn't work in IE8 or less k = (k[k.length-1] === "s") ? k.substring(0,k.length-1) : k; for (var m = (px.length - 1); m > -1; m--) { v = px[m].toLowerCase(); if (o1[v] !== o2[v]) { return false; } if (k === v) { break; } } return true; } if (j.substring(j.length - 1) !== "s") { j += "s"; } if (this._move) { this._move = null; } return this["add" + j](this._orient); }; }; var nf = function (n) { return function () { this._dateElement = n; return this; }; }; for (var k = 0; k < px.length; k++) { de = px[k].toLowerCase(); if(de !== "weekday") { // Create date element functions and plural date element functions used with Date (eg. day(), days(), months()). $P[de] = $P[de + "s"] = ef(px[k]); // Create date element functions and plural date element functions used with Number (eg. day(), days(), months()). $N[de] = $N[de + "s"] = nf(de + "s"); } } $P._ss = ef("Second"); var nthfn = function (n) { return function (dayOfWeek) { if (this._same) { return this._ss(arguments[0]); } if (dayOfWeek || dayOfWeek === 0) { return this.moveToNthOccurrence(dayOfWeek, n); } this._nth = n; // if the operator is 'second' add the _orient, then deal with it later... if (n === 2 && (dayOfWeek === undefined || dayOfWeek === null)) { this._isSecond = true; return this.addSeconds(this._orient); } return this; }; }; for (var l = 0; l < nth.length; l++) { $P[nth[l]] = (l === 0) ? nthfn(-1) : nthfn(l); } }()); (function () { "use strict"; Date.Parsing = { Exception: function (s) { this.message = "Parse error at '" + s.substring(0, 10) + " ...'"; } }; var $P = Date.Parsing; var dayOffsets = { standard: [0,31,59,90,120,151,181,212,243,273,304,334], leap: [0,31,60,91,121,152,182,213,244,274,305,335] }; $P.isLeapYear = function(year) { return ((year % 4 === 0) && (year % 100 !== 0)) || (year % 400 === 0); }; var utils = { multiReplace : function (str, hash ) { var key; for (key in hash) { if (Object.prototype.hasOwnProperty.call(hash, key)) { var regex; if (typeof hash[key] === "function") { } else { regex = (hash[key] instanceof RegExp) ? hash[key] : new RegExp(hash[key], "g"); } str = str.replace(regex, key); } } return str; }, getDayOfYearFromWeek : function (obj) { var d, jan4, offset; obj.weekDay = (!obj.weekDay && obj.weekDay !== 0) ? 1 : obj.weekDay; d = new Date(obj.year, 0, 4); jan4 = d.getDay() === 0 ? 7 : d.getDay(); // JS is 0 indexed on Sunday. offset = jan4+3; obj.dayOfYear = ((obj.week * 7) + (obj.weekDay === 0 ? 7 : obj.weekDay))-offset; return obj; }, getDayOfYear : function (obj, dayOffset) { if (!obj.dayOfYear) { obj = utils.getDayOfYearFromWeek(obj); } for (var i=0;i <= dayOffset.length;i++) { if (obj.dayOfYear < dayOffset[i] || i === dayOffset.length) { obj.day = obj.day ? obj.day : (obj.dayOfYear - dayOffset[i-1]); break; } else { obj.month = i; } } return obj; }, adjustForTimeZone : function (obj, date) { var offset; if (obj.zone.toUpperCase() === "Z" || (obj.zone_hours === 0 && obj.zone_minutes === 0)) { // it's UTC/GML so work out the current timeszone offset offset = -date.getTimezoneOffset(); } else { offset = (obj.zone_hours*60) + (obj.zone_minutes || 0); if (obj.zone_sign === "+") { offset *= -1; } offset -= date.getTimezoneOffset(); } date.setMinutes(date.getMinutes()+offset); return date; }, setDefaults : function (obj) { obj.year = obj.year || Date.today().getFullYear(); obj.hours = obj.hours || 0; obj.minutes = obj.minutes || 0; obj.seconds = obj.seconds || 0; obj.milliseconds = obj.milliseconds || 0; if (!(!obj.month && (obj.week || obj.dayOfYear))) { // if we have a month, or if we don't but don't have the day calculation data obj.month = obj.month || 0; obj.day = obj.day || 1; } return obj; }, dataNum: function (data, mod, explict, postProcess) { var dataNum = data*1; if (mod) { if (postProcess) { return data ? mod(data)*1 : data; } else { return data ? mod(dataNum) : data; } } else if (!explict){ return data ? dataNum : data; } else { return (data && typeof data !== "undefined") ? dataNum : data; } }, timeDataProcess: function (obj) { var timeObj = {}; for (var x in obj.data) { if (obj.data.hasOwnProperty(x)) { timeObj[x] = obj.ignore[x] ? obj.data[x] : utils.dataNum(obj.data[x], obj.mods[x], obj.explict[x], obj.postProcess[x]); } } if (obj.data.secmins) { obj.data.secmins = obj.data.secmins.replace(",", ".") * 60; if (!timeObj.minutes) { timeObj.minutes = obj.data.secmins; } else if (!timeObj.seconds) { timeObj.seconds = obj.data.secmins; } delete obj.secmins; } return timeObj; }, buildTimeObjectFromData: function (data) { var time = utils.timeDataProcess({ data: { year : data[1], month : data[5], day : data[7], week : data[8], dayOfYear : data[10], hours : data[15], zone_hours : data[23], zone_minutes : data[24], zone : data[21], zone_sign : data[22], weekDay : data[9], minutes: data[16], seconds: data[19], milliseconds: data[20], secmins: data[18] }, mods: { month: function(data) { return data-1; }, weekDay: function (data) { data = Math.abs(data); return (data === 7 ? 0 : data); }, minutes: function (data) { return data.replace(":",""); }, seconds: function (data) { return Math.floor( (data.replace(":","").replace(",","."))*1 ); }, milliseconds: function (data) { return (data.replace(",",".")*1000); } }, postProcess: { minutes: true, seconds: true, milliseconds: true }, explict: { zone_hours: true, zone_minutes: true }, ignore: { zone: true, zone_sign: true, secmins: true } }); return time; }, addToHash: function (hash, keys, data) { keys = keys; data = data; var len = keys.length; for (var i = 0; i < len; i++) { hash[keys[i]] = data[i]; } return hash; }, combineRegex: function (r1, r2) { return new RegExp("(("+r1.source+")\\s("+r2.source+"))"); }, getDateNthString: function(add, last, inc){ if (add) { return Date.today().addDays(inc).toString("d"); } else if (last) { return Date.today().last()[inc]().toString("d"); } }, buildRegexData: function (array) { var arr = []; var len = array.length; for (var i=0; i < len; i++) { if (Object.prototype.toString.call(array[i]) === '[object Array]') { // oldIE compat version of Array.isArray arr.push(this.combineRegex(array[i][0], array[i][1])); } else { arr.push(array[i]); } } return arr; } }; $P.processTimeObject = function (obj) { var date, dayOffset; utils.setDefaults(obj); dayOffset = ($P.isLeapYear(obj.year)) ? dayOffsets.leap : dayOffsets.standard; if (!obj.month && (obj.week || obj.dayOfYear)) { utils.getDayOfYear(obj, dayOffset); } else { obj.dayOfYear = dayOffset[obj.month] + obj.day; } date = new Date(obj.year, obj.month, obj.day, obj.hours, obj.minutes, obj.seconds, obj.milliseconds); if (obj.zone) { utils.adjustForTimeZone(obj, date); // adjust (and calculate) for timezone } return date; }; $P.ISO = { regex : /^([\+-]?\d{4}(?!\d{2}\b))((-?)((0[1-9]|1[0-2])(\3([12]\d|0[1-9]|3[01]))?|W([0-4]\d|5[0-3])(-?[1-7])?|(00[1-9]|0[1-9]\d|[12]\d{2}|3([0-5]\d|6[1-6])))([T\s]((([01]\d|2[0-4])((:?)[0-5]\d)?|24\:?00)([\.,]\d+(?!:))?)?(\17[0-5]\d([\.,]\d+)?)?\s?([zZ]|([\+-])([01]\d|2[0-3]):?([0-5]\d)?)?)?)?$/, parse : function (s) { var time, data = s.match(this.regex); if (!data || !data.length) { return null; } time = utils.buildTimeObjectFromData(data); if (!time.year || (!time.year && (!time.month && !time.day) && (!time.week && !time.dayOfYear)) ) { return null; } return $P.processTimeObject(time); } }; $P.Numeric = { isNumeric: function (e){return!isNaN(parseFloat(e))&&isFinite(e);}, regex: /\b([0-1]?[0-9])([0-3]?[0-9])([0-2]?[0-9]?[0-9][0-9])\b/i, parse: function (s) { var data, i, time = {}, order = Date.CultureInfo.dateElementOrder.split(""); if (!(this.isNumeric(s)) || // if it's non-numeric OR (s[0] === "+" && s[0] === "-")) { // It's an arithmatic string (eg +/-1000) return null; } if (s.length < 5 && s.indexOf(".") < 0 && s.indexOf("/") < 0) { // assume it's just a year. time.year = s; return $P.processTimeObject(time); } data = s.match(this.regex); if (!data || !data.length) { return null; } for (i=0; i < order.length; i++) { switch(order[i]) { case "d": time.day = data[i+1]; break; case "m": time.month = (data[i+1]-1); break; case "y": time.year = data[i+1]; break; } } return $P.processTimeObject(time); } }; $P.Normalizer = { regexData: function () { var $R = Date.CultureInfo.regexPatterns; return utils.buildRegexData([ $R.tomorrow, $R.yesterday, [$R.past, $R.mon], [$R.past, $R.tue], [$R.past, $R.wed], [$R.past, $R.thu], [$R.past, $R.fri], [$R.past, $R.sat], [$R.past, $R.sun] ]); }, basicReplaceHash : function() { var $R = Date.CultureInfo.regexPatterns; return { "January": $R.jan.source, "February": $R.feb, "March": $R.mar, "April": $R.apr, "May": $R.may, "June": $R.jun, "July": $R.jul, "August": $R.aug, "September": $R.sep, "October": $R.oct, "November": $R.nov, "December": $R.dec, "": /\bat\b/gi, " ": /\s{2,}/, "am": $R.inTheMorning, "9am": $R.thisMorning, "pm": $R.inTheEvening, "7pm":$R.thisEvening }; }, keys : function(){ return [ utils.getDateNthString(true, false, 1), // tomorrow utils.getDateNthString(true, false, -1), // yesterday utils.getDateNthString(false, true, "monday"), //last mon utils.getDateNthString(false, true, "tuesday"), //last tues utils.getDateNthString(false, true, "wednesday"), //last wed utils.getDateNthString(false, true, "thursday"), //last thurs utils.getDateNthString(false, true, "friday"), //last fri utils.getDateNthString(false, true, "saturday"), //last sat utils.getDateNthString(false, true, "sunday") //last sun ]; }, buildRegexFunctions: function () { var $R = Date.CultureInfo.regexPatterns; var __ = Date.i18n.__; var tomorrowRE = new RegExp("(\\b\\d\\d?("+__("AM")+"|"+__("PM")+")? )("+$R.tomorrow.source.slice(1)+")", "i"); // adapted tomorrow regex for AM PM relative dates var todayRE = new RegExp($R.today.source + "(?!\\s*([+-]))\\b"); // today, but excludes the math operators (eg "today + 2h") this.replaceFuncs = [ [todayRE, function (full) { return (full.length > 1) ? Date.today().toString("d") : full; }], [tomorrowRE, function(full, m1) { var t = Date.today().addDays(1).toString("d"); return (t + " " + m1); }], [$R.amThisMorning, function(str, am){return am;}], [$R.pmThisEvening, function(str, pm){return pm;}] ]; }, buildReplaceData: function () { this.buildRegexFunctions(); this.replaceHash = utils.addToHash(this.basicReplaceHash(), this.keys(), this.regexData()); }, stringReplaceFuncs: function (s) { for (var i=0; i < this.replaceFuncs.length; i++) { s = s.replace(this.replaceFuncs[i][0], this.replaceFuncs[i][1]); } return s; }, parse: function (s) { s = this.stringReplaceFuncs(s); s = utils.multiReplace(s, this.replaceHash); try { var n = s.split(/([\s\-\.\,\/\x27]+)/); if (n.length === 3 && $P.Numeric.isNumeric(n[0]) && $P.Numeric.isNumeric(n[2]) && (n[2].length >= 4)) { // ok, so we're dealing with x/year. But that's not a full date. // This fixes wonky dateElementOrder parsing when set to dmy order. if (Date.CultureInfo.dateElementOrder[0] === "d") { s = "1/" + n[0] + "/" + n[2]; // set to 1st of month and normalize the seperator } } } catch (e) {} return s; } }; $P.Normalizer.buildReplaceData(); }()); (function () { var $P = Date.Parsing; var _ = $P.Operators = { // // Tokenizers // rtoken: function (r) { // regex token return function (s) { var mx = s.match(r); if (mx) { return ([ mx[0], s.substring(mx[0].length) ]); } else { throw new $P.Exception(s); } }; }, token: function () { // whitespace-eating token return function (s) { return _.rtoken(new RegExp("^\\s*" + s + "\\s*"))(s); }; }, stoken: function (s) { // string token return _.rtoken(new RegExp("^" + s)); }, // Atomic Operators until: function (p) { return function (s) { var qx = [], rx = null; while (s.length) { try { rx = p.call(this, s); } catch (e) { qx.push(rx[0]); s = rx[1]; continue; } break; } return [ qx, s ]; }; }, many: function (p) { return function (s) { var rx = [], r = null; while (s.length) { try { r = p.call(this, s); } catch (e) { return [ rx, s ]; } rx.push(r[0]); s = r[1]; } return [ rx, s ]; }; }, // generator operators -- see below optional: function (p) { return function (s) { var r = null; try { r = p.call(this, s); } catch (e) { return [ null, s ]; } return [ r[0], r[1] ]; }; }, not: function (p) { return function (s) { try { p.call(this, s); } catch (e) { return [null, s]; } throw new $P.Exception(s); }; }, ignore: function (p) { return p ? function (s) { var r = null; r = p.call(this, s); return [null, r[1]]; } : null; }, product: function () { var px = arguments[0], qx = Array.prototype.slice.call(arguments, 1), rx = []; for (var i = 0 ; i < px.length ; i++) { rx.push(_.each(px[i], qx)); } return rx; }, cache: function (rule) { var cache = {}, cache_length = 0, cache_keys = [], CACHE_MAX = Date.Config.CACHE_MAX || 100000, r = null; var cacheCheck = function () { if (cache_length === CACHE_MAX) { // kill several keys, don't want to have to do this all the time... for (var i=0; i < 10; i++) { var key = cache_keys.shift(); if (key) { delete cache[key]; cache_length--; } } } }; return function (s) { cacheCheck(); try { r = cache[s] = (cache[s] || rule.call(this, s)); } catch (e) { r = cache[s] = e; } cache_length++; cache_keys.push(s); if (r instanceof $P.Exception) { throw r; } else { return r; } }; }, // vector operators -- see below any: function () { var px = arguments; return function (s) { var r = null; for (var i = 0; i < px.length; i++) { if (px[i] == null) { continue; } try { r = (px[i].call(this, s)); } catch (e) { r = null; } if (r) { return r; } } throw new $P.Exception(s); }; }, each: function () { var px = arguments; return function (s) { var rx = [], r = null; for (var i = 0; i < px.length ; i++) { if (px[i] == null) { continue; } try { r = (px[i].call(this, s)); } catch (e) { throw new $P.Exception(s); } rx.push(r[0]); s = r[1]; } return [ rx, s]; }; }, all: function () { var px = arguments, _ = _; return _.each(_.optional(px)); }, // delimited operators sequence: function (px, d, c) { d = d || _.rtoken(/^\s*/); c = c || null; if (px.length === 1) { return px[0]; } return function (s) { var r = null, q = null; var rx = []; for (var i = 0; i < px.length ; i++) { try { r = px[i].call(this, s); } catch (e) { break; } rx.push(r[0]); try { q = d.call(this, r[1]); } catch (ex) { q = null; break; } s = q[1]; } if (!r) { throw new $P.Exception(s); } if (q) { throw new $P.Exception(q[1]); } if (c) { try { r = c.call(this, r[1]); } catch (ey) { throw new $P.Exception(r[1]); } } return [ rx, (r?r[1]:s) ]; }; }, // // Composite Operators // between: function (d1, p, d2) { d2 = d2 || d1; var _fn = _.each(_.ignore(d1), p, _.ignore(d2)); return function (s) { var rx = _fn.call(this, s); return [[rx[0][0], r[0][2]], rx[1]]; }; }, list: function (p, d, c) { d = d || _.rtoken(/^\s*/); c = c || null; return (p instanceof Array ? _.each(_.product(p.slice(0, -1), _.ignore(d)), p.slice(-1), _.ignore(c)) : _.each(_.many(_.each(p, _.ignore(d))), px, _.ignore(c))); }, set: function (px, d, c) { d = d || _.rtoken(/^\s*/); c = c || null; return function (s) { // r is the current match, best the current 'best' match // which means it parsed the most amount of input var r = null, p = null, q = null, rx = null, best = [[], s], last = false; // go through the rules in the given set for (var i = 0; i < px.length ; i++) { // last is a flag indicating whether this must be the last element // if there is only 1 element, then it MUST be the last one q = null; p = null; r = null; last = (px.length === 1); // first, we try simply to match the current pattern // if not, try the next pattern try { r = px[i].call(this, s); } catch (e) { continue; } // since we are matching against a set of elements, the first // thing to do is to add r[0] to matched elements rx = [[r[0]], r[1]]; // if we matched and there is still input to parse and // we don't already know this is the last element, // we're going to next check for the delimiter ... // if there's none, or if there's no input left to parse // than this must be the last element after all ... if (r[1].length > 0 && ! last) { try { q = d.call(this, r[1]); } catch (ex) { last = true; } } else { last = true; } // if we parsed the delimiter and now there's no more input, // that means we shouldn't have parsed the delimiter at all // so don't update r and mark this as the last element ... if (!last && q[1].length === 0) { last = true; } // so, if this isn't the last element, we're going to see if // we can get any more matches from the remaining (unmatched) // elements ... if (!last) { // build a list of the remaining rules we can match against, // i.e., all but the one we just matched against var qx = []; for (var j = 0; j < px.length ; j++) { if (i !== j) { qx.push(px[j]); } } // now invoke recursively set with the remaining input // note that we don't include the closing delimiter ... // we'll check for that ourselves at the end p = _.set(qx, d).call(this, q[1]); // if we got a non-empty set as a result ... // (otw rx already contains everything we want to match) if (p[0].length > 0) { // update current result, which is stored in rx ... // basically, pick up the remaining text from p[1] // and concat the result from p[0] so that we don't // get endless nesting ... rx[0] = rx[0].concat(p[0]); rx[1] = p[1]; } } // at this point, rx either contains the last matched element // or the entire matched set that starts with this element. // now we just check to see if this variation is better than // our best so far, in terms of how much of the input is parsed if (rx[1].length < best[1].length) { best = rx; } // if we've parsed all the input, then we're finished if (best[1].length === 0) { break; } } // so now we've either gone through all the patterns trying them // as the initial match; or we found one that parsed the entire // input string ... // if best has no matches, just return empty set ... if (best[0].length === 0) { return best; } // if a closing delimiter is provided, then we have to check it also if (c) { // we try this even if there is no remaining input because the pattern // may well be optional or match empty input ... try { q = c.call(this, best[1]); } catch (ey) { throw new $P.Exception(best[1]); } // it parsed ... be sure to update the best match remaining input best[1] = q[1]; } // if we're here, either there was no closing delimiter or we parsed it // so now we have the best match; just return it! return best; }; }, forward: function (gr, fname) { return function (s) { return gr[fname].call(this, s); }; }, // // Translation Operators // replace: function (rule, repl) { return function (s) { var r = rule.call(this, s); return [repl, r[1]]; }; }, process: function (rule, fn) { return function (s) { var r = rule.call(this, s); return [fn.call(this, r[0]), r[1]]; }; }, min: function (min, rule) { return function (s) { var rx = rule.call(this, s); if (rx[0].length < min) { throw new $P.Exception(s); } return rx; }; } }; // Generator Operators And Vector Operators // Generators are operators that have a signature of F(R) => R, // taking a given rule and returning another rule, such as // ignore, which parses a given rule and throws away the result. // Vector operators are those that have a signature of F(R1,R2,...) => R, // take a list of rules and returning a new rule, such as each. // Generator operators are converted (via the following _generator // function) into functions that can also take a list or array of rules // and return an array of new rules as though the function had been // called on each rule in turn (which is what actually happens). // This allows generators to be used with vector operators more easily. // Example: // each(ignore(foo, bar)) instead of each(ignore(foo), ignore(bar)) // This also turns generators into vector operators, which allows // constructs like: // not(cache(foo, bar)) var _generator = function (op) { function gen() { var args = null, rx = [], px, i; if (arguments.length > 1) { args = Array.prototype.slice.call(arguments); } else if (arguments[0] instanceof Array) { args = arguments[0]; } if (args) { px = args.shift(); if (px.length > 0) { args.unshift(px[i]); rx.push(op.apply(null, args)); args.shift(); return rx; } } else { return op.apply(null, arguments); } } return gen; }; var gx = "optional not ignore cache".split(/\s/); for (var i = 0 ; i < gx.length ; i++) { _[gx[i]] = _generator(_[gx[i]]); } var _vector = function (op) { return function () { if (arguments[0] instanceof Array) { return op.apply(null, arguments[0]); } else { return op.apply(null, arguments); } }; }; var vx = "each any all".split(/\s/); for (var j = 0 ; j < vx.length ; j++) { _[vx[j]] = _vector(_[vx[j]]); } }()); (function () { var $D = Date; var flattenAndCompact = function (ax) { var rx = []; for (var i = 0; i < ax.length; i++) { if (ax[i] instanceof Array) { rx = rx.concat(flattenAndCompact(ax[i])); } else { if (ax[i]) { rx.push(ax[i]); } } } return rx; }; var parseMeridian = function () { if (this.meridian && (this.hour || this.hour === 0)) { if (this.meridian === "a" && this.hour > 11 && Date.Config.strict24hr){ throw "Invalid hour and meridian combination"; } else if (this.meridian === "p" && this.hour < 12 && Date.Config.strict24hr){ throw "Invalid hour and meridian combination"; } else if (this.meridian === "p" && this.hour < 12) { this.hour = this.hour + 12; } else if (this.meridian === "a" && this.hour === 12) { this.hour = 0; } } }; var setDefaults = function () { var now = new Date(); if ((this.hour || this.minute) && (!this.month && !this.year && !this.day)) { this.day = now.getDate(); } if (!this.year) { this.year = now.getFullYear(); } if (!this.month && this.month !== 0) { this.month = now.getMonth(); } if (!this.day) { this.day = 1; } if (!this.hour) { this.hour = 0; } if (!this.minute) { this.minute = 0; } if (!this.second) { this.second = 0; } if (!this.millisecond) { this.millisecond = 0; } }; var finishUtils = { getToday: function () { if (this.now || "hour minute second".indexOf(this.unit) !== -1) { return new Date(); } else { return $D.today(); } }, setDaysFromWeekday: function (today, orient){ var gap; orient = orient || 1; this.unit = "day"; gap = ($D.getDayNumberFromName(this.weekday) - today.getDay()); this.days = gap ? ((gap + (orient * 7)) % 7) : (orient * 7); return this; }, setMonthsFromMonth: function (today, orient) { var gap; orient = orient || 1; this.unit = "month"; gap = (this.month - today.getMonth()); this.months = gap ? ((gap + (orient * 12)) % 12) : (orient * 12); this.month = null; return this; }, setDMYFromWeekday: function () { var d = Date[this.weekday](); this.day = d.getDate(); if (!this.month) { this.month = d.getMonth(); } this.year = d.getFullYear(); return this; }, setUnitValue: function (orient) { if (!this.value && this.operator && this.operator !== null && this[this.unit + "s"] && this[this.unit + "s"] !== null) { this[this.unit + "s"] = this[this.unit + "s"] + ((this.operator === "add") ? 1 : -1) + (this.value||0) * orient; } else if (this[this.unit + "s"] == null || this.operator != null) { if (!this.value) { this.value = 1; } this[this.unit + "s"] = this.value * orient; } }, generateDateFromWeeks: function () { var weekday = (this.weekday !== undefined) ? this.weekday : "today"; var d = Date[weekday]().addWeeks(this.weeks); if (this.now) { d.setTimeToNow(); } return d; } }; $D.Translator = { hour: function (s) { return function () { this.hour = Number(s); }; }, minute: function (s) { return function () { this.minute = Number(s); }; }, second: function (s) { return function () { this.second = Number(s); }; }, /* for ss.s format */ secondAndMillisecond: function (s) { return function () { var mx = s.match(/^([0-5][0-9])\.([0-9]{1,3})/); this.second = Number(mx[1]); this.millisecond = Number(mx[2]); }; }, meridian: function (s) { return function () { this.meridian = s.slice(0, 1).toLowerCase(); }; }, timezone: function (s) { return function () { var n = s.replace(/[^\d\+\-]/g, ""); if (n.length) { this.timezoneOffset = Number(n); } else { this.timezone = s.toLowerCase(); } }; }, day: function (x) { var s = x[0]; return function () { this.day = Number(s.match(/\d+/)[0]); if (this.day < 1) { throw "invalid day"; } }; }, month: function (s) { return function () { this.month = (s.length === 3) ? "jan feb mar apr may jun jul aug sep oct nov dec".indexOf(s)/4 : Number(s) - 1; if (this.month < 0) { throw "invalid month"; } }; }, year: function (s) { return function () { var n = Number(s); this.year = ((s.length > 2) ? n : (n + (((n + 2000) < Date.CultureInfo.twoDigitYearMax) ? 2000 : 1900))); }; }, rday: function (s) { return function () { switch (s) { case "yesterday": this.days = -1; break; case "tomorrow": this.days = 1; break; case "today": this.days = 0; break; case "now": this.days = 0; this.now = true; break; } }; }, finishExact: function (x) { var d; x = (x instanceof Array) ? x : [x]; for (var i = 0 ; i < x.length ; i++) { if (x[i]) { x[i].call(this); } } setDefaults.call(this); parseMeridian.call(this); if (this.day > $D.getDaysInMonth(this.year, this.month)) { throw new RangeError(this.day + " is not a valid value for days."); } d = new Date(this.year, this.month, this.day, this.hour, this.minute, this.second, this.millisecond); if (this.year < 100) { d.setFullYear(this.year); // means years less that 100 are process correctly. JS will parse it otherwise as 1900-1999. } if (this.timezone) { d.set({ timezone: this.timezone }); } else if (this.timezoneOffset) { d.set({ timezoneOffset: this.timezoneOffset }); } return d; }, finish: function (x) { var today, expression, orient, temp; x = (x instanceof Array) ? flattenAndCompact(x) : [ x ]; if (x.length === 0) { return null; } for (var i = 0 ; i < x.length ; i++) { if (typeof x[i] === "function") { x[i].call(this); } } if (this.now && !this.unit && !this.operator) { return new Date(); } else { today = finishUtils.getToday.call(this); } expression = !!(this.days && this.days !== null || this.orient || this.operator); orient = ((this.orient === "past" || this.operator === "subtract") ? -1 : 1); if (this.month && this.unit === "week") { this.value = this.month + 1; delete this.month; delete this.day; } if ((this.month || this.month === 0) && "year day hour minute second".indexOf(this.unit) !== -1) { if (!this.value) { this.value = this.month + 1; } this.month = null; expression = true; } if (!expression && this.weekday && !this.day && !this.days) { finishUtils.setDMYFromWeekday.call(this); } if (expression && this.weekday && this.unit !== "month" && this.unit !== "week") { finishUtils.setDaysFromWeekday.call(this, today, orient); } if (this.weekday && this.unit !== "week" && !this.day && !this.days) { temp = Date[this.weekday](); this.day = temp.getDate(); if (temp.getMonth() !== today.getMonth()) { this.month = temp.getMonth(); } } if (this.month && this.unit === "day" && this.operator) { if (!this.value) { this.value = (this.month + 1); } this.month = null; } if (this.value != null && this.month != null && this.year != null) { this.day = this.value * 1; } if (this.month && !this.day && this.value) { today.set({ day: this.value * 1 }); if (!expression) { this.day = this.value * 1; } } if (!this.month && this.value && this.unit === "month" && !this.now) { this.month = this.value; expression = true; } if (expression && (this.month || this.month === 0) && this.unit !== "year") { finishUtils.setMonthsFromMonth.call(this, today, orient); } if (!this.unit) { this.unit = "day"; } finishUtils.setUnitValue.call(this, orient); parseMeridian.call(this); if ((this.month || this.month === 0) && !this.day) { this.day = 1; } if (!this.orient && !this.operator && this.unit === "week" && this.value && !this.day && !this.month) { return Date.today().setWeek(this.value); } if (this.unit === "week" && this.weeks && !this.day && !this.month) { return finishUtils.generateDateFromWeeks.call(this); } if (expression && this.timezone && this.day && this.days) { this.day = this.days; } if (expression){ today.add(this); } else { today.set(this); } if (this.timezone) { this.timezone = this.timezone.toUpperCase(); var offset = $D.getTimezoneOffset(this.timezone); var timezone; if (today.hasDaylightSavingTime()) { // lets check that we're being sane with timezone setting timezone = $D.getTimezoneAbbreviation(offset, today.isDaylightSavingTime()); if (timezone !== this.timezone) { // bugger, we're in a place where things like EST vs EDT matters. if (today.isDaylightSavingTime()) { today.addHours(-1); } else { today.addHours(1); } } } today.setTimezoneOffset(offset); } return today; } }; }()); (function () { var $D = Date; $D.Grammar = {}; var _ = $D.Parsing.Operators, g = $D.Grammar, t = $D.Translator, _fn; // Allow rolling up into general purpose rules _fn = function () { return _.each(_.any.apply(null, arguments), _.not(g.ctoken2("timeContext"))); }; g.datePartDelimiter = _.rtoken(/^([\s\-\.\,\/\x27]+)/); g.timePartDelimiter = _.stoken(":"); g.whiteSpace = _.rtoken(/^\s*/); g.generalDelimiter = _.rtoken(/^(([\s\,]|at|@|on)+)/); var _C = {}; g.ctoken = function (keys) { var fn = _C[keys]; if (! fn) { var c = Date.CultureInfo.regexPatterns; var kx = keys.split(/\s+/), px = []; for (var i = 0; i < kx.length ; i++) { px.push(_.replace(_.rtoken(c[kx[i]]), kx[i])); } fn = _C[keys] = _.any.apply(null, px); } return fn; }; g.ctoken2 = function (key) { return _.rtoken(Date.CultureInfo.regexPatterns[key]); }; var cacheProcessRtoken = function (key, token, type, eachToken) { if (eachToken) { g[key] = _.cache(_.process(_.each(_.rtoken(token),_.optional(g.ctoken2(eachToken))), type)); } else { g[key] = _.cache(_.process(_.rtoken(token), type)); } }; var cacheProcessCtoken = function (token, type) { return _.cache(_.process(g.ctoken2(token), type)); }; var _F = {}; //function cache var _get = function (f) { _F[f] = (_F[f] || g.format(f)[0]); return _F[f]; }; g.allformats = function (fx) { var rx = []; if (fx instanceof Array) { for (var i = 0; i < fx.length; i++) { rx.push(_get(fx[i])); } } else { rx.push(_get(fx)); } return rx; }; g.formats = function (fx) { if (fx instanceof Array) { var rx = []; for (var i = 0 ; i < fx.length ; i++) { rx.push(_get(fx[i])); } return _.any.apply(null, rx); } else { return _get(fx); } }; var grammarFormats = { timeFormats: function(){ var i, RTokenKeys = [ "h", "hh", "H", "HH", "m", "mm", "s", "ss", "ss.s", "z", "zz" ], RToken = [ /^(0[0-9]|1[0-2]|[1-9])/, /^(0[0-9]|1[0-2])/, /^([0-1][0-9]|2[0-3]|[0-9])/, /^([0-1][0-9]|2[0-3])/, /^([0-5][0-9]|[0-9])/, /^[0-5][0-9]/, /^([0-5][0-9]|[0-9])/, /^[0-5][0-9]/, /^[0-5][0-9]\.[0-9]{1,3}/, /^((\+|\-)\s*\d\d\d\d)|((\+|\-)\d\d\:?\d\d)/, /^((\+|\-)\s*\d\d\d\d)|((\+|\-)\d\d\:?\d\d)/ ], tokens = [ t.hour, t.hour, t.hour, t.hour, t.minute, t.minute, t.second, t.second, t.secondAndMillisecond, t.timezone, t.timezone ]; for (i=0; i < RTokenKeys.length; i++) { cacheProcessRtoken(RTokenKeys[i], RToken[i], tokens[i]); } g.hms = _.cache(_.sequence([g.H, g.m, g.s], g.timePartDelimiter)); g.t = cacheProcessCtoken("shortMeridian", t.meridian); g.tt = cacheProcessCtoken("longMeridian", t.meridian); g.zzz = cacheProcessCtoken("timezone", t.timezone); g.timeSuffix = _.each(_.ignore(g.whiteSpace), _.set([ g.tt, g.zzz ])); g.time = _.each(_.optional(_.ignore(_.stoken("T"))), g.hms, g.timeSuffix); }, dateFormats: function () { // pre-loaded rules for different date part order preferences var _setfn = function () { return _.set(arguments, g.datePartDelimiter); }; var i, RTokenKeys = [ "d", "dd", "M", "MM", "y", "yy", "yyy", "yyyy" ], RToken = [ /^([0-2]\d|3[0-1]|\d)/, /^([0-2]\d|3[0-1])/, /^(1[0-2]|0\d|\d)/, /^(1[0-2]|0\d)/, /^(\d+)/, /^(\d\d)/, /^(\d\d?\d?\d?)/, /^(\d\d\d\d)/ ], tokens = [ t.day, t.day, t.month, t.month, t.year, t.year, t.year, t.year ], eachToken = [ "ordinalSuffix", "ordinalSuffix" ]; for (i=0; i < RTokenKeys.length; i++) { cacheProcessRtoken(RTokenKeys[i], RToken[i], tokens[i], eachToken[i]); } g.MMM = g.MMMM = _.cache(_.process(g.ctoken("jan feb mar apr may jun jul aug sep oct nov dec"), t.month)); g.ddd = g.dddd = _.cache(_.process(g.ctoken("sun mon tue wed thu fri sat"), function (s) { return function () { this.weekday = s; }; } )); g.day = _fn(g.d, g.dd); g.month = _fn(g.M, g.MMM); g.year = _fn(g.yyyy, g.yy); g.mdy = _setfn(g.ddd, g.month, g.day, g.year); g.ymd = _setfn(g.ddd, g.year, g.month, g.day); g.dmy = _setfn(g.ddd, g.day, g.month, g.year); g.date = function (s) { return ((g[Date.CultureInfo.dateElementOrder] || g.mdy).call(this, s)); }; }, relative: function () { // relative date / time expressions g.orientation = _.process(g.ctoken("past future"), function (s) { return function () { this.orient = s; }; } ); g.operator = _.process(g.ctoken("add subtract"), function (s) { return function () { this.operator = s; }; } ); g.rday = _.process(g.ctoken("yesterday tomorrow today now"), t.rday); g.unit = _.process(g.ctoken("second minute hour day week month year"), function (s) { return function () { this.unit = s; }; } ); } }; g.buildGrammarFormats = function () { // these need to be rebuilt every time the language changes. _C = {}; grammarFormats.timeFormats(); grammarFormats.dateFormats(); grammarFormats.relative(); g.value = _.process(_.rtoken(/^([-+]?\d+)?(st|nd|rd|th)?/), function (s) { return function () { this.value = s.replace(/\D/g, ""); }; } ); g.expression = _.set([g.rday, g.operator, g.value, g.unit, g.orientation, g.ddd, g.MMM ]); g.format = _.process(_.many( _.any( // translate format specifiers into grammar rules _.process( _.rtoken(/^(dd?d?d?(?!e)|MM?M?M?|yy?y?y?|hh?|HH?|mm?|ss?|tt?|zz?z?)/), function (fmt) { if (g[fmt]) { return g[fmt]; } else { throw $D.Parsing.Exception(fmt); } } ), // translate separator tokens into token rules _.process(_.rtoken(/^[^dMyhHmstz]+/), // all legal separators function (s) { return _.ignore(_.stoken(s)); } ) ) ), // construct the parser ... function (rules) { return _.process(_.each.apply(null, rules), t.finishExact); } ); // starting rule for general purpose grammar g._start = _.process(_.set([ g.date, g.time, g.expression ], g.generalDelimiter, g.whiteSpace), t.finish); }; g.buildGrammarFormats(); // parsing date format specifiers - ex: "h:m:s tt" // this little guy will generate a custom parser based // on the format string, ex: g.format("h:m:s tt") // check for these formats first g._formats = g.formats([ "\"yyyy-MM-ddTHH:mm:ssZ\"", "yyyy-MM-ddTHH:mm:ss.sz", "yyyy-MM-ddTHH:mm:ssZ", "yyyy-MM-ddTHH:mm:ssz", "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-ddTHH:mmZ", "yyyy-MM-ddTHH:mmz", "yyyy-MM-ddTHH:mm", "ddd, MMM dd, yyyy H:mm:ss tt", "ddd MMM d yyyy HH:mm:ss zzz", "MMddyyyy", "ddMMyyyy", "Mddyyyy", "ddMyyyy", "Mdyyyy", "dMyyyy", "yyyy", "Mdyy", "dMyy", "d" ]); // real starting rule: tries selected formats first, // then general purpose rule g.start = function (s) { try { var r = g._formats.call({}, s); if (r[1].length === 0) { return r; } } catch (e) {} return g._start.call({}, s); }; }()); (function () { var $D = Date; /** * @desc Converts the specified string value into its JavaScript Date equivalent using CultureInfo specific format information. * * Example

	///////////
	// Dates //
	///////////

	// 15-Oct-2004
	var d1 = Date.parse("10/15/2004");

	// 15-Oct-2004
	var d1 = Date.parse("15-Oct-2004");

	// 15-Oct-2004
	var d1 = Date.parse("2004.10.15");

	//Fri Oct 15, 2004
	var d1 = Date.parse("Fri Oct 15, 2004");

	///////////
	// Times //
	///////////

	// Today at 10 PM.
	var d1 = Date.parse("10 PM");

	// Today at 10:30 PM.
	var d1 = Date.parse("10:30 P.M.");

	// Today at 6 AM.
	var d1 = Date.parse("06am");

	/////////////////////
	// Dates and Times //
	/////////////////////

	// 8-July-2004 @ 10:30 PM
	var d1 = Date.parse("July 8th, 2004, 10:30 PM");

	// 1-July-2004 @ 10:30 PM
	var d1 = Date.parse("2004-07-01T22:30:00");

	////////////////////
	// Relative Dates //
	////////////////////

	// Returns today's date. The string "today" is culture specific.
	var d1 = Date.parse("today");

	// Returns yesterday's date. The string "yesterday" is culture specific.
	var d1 = Date.parse("yesterday");

	// Returns the date of the next thursday.
	var d1 = Date.parse("Next thursday");

	// Returns the date of the most previous monday.
	var d1 = Date.parse("last monday");

	// Returns today's day + one year.
	var d1 = Date.parse("next year");

	///////////////
	// Date Math //
	///////////////

	// Today + 2 days
	var d1 = Date.parse("t+2");

	// Today + 2 days
	var d1 = Date.parse("today + 2 days");

	// Today + 3 months
	var d1 = Date.parse("t+3m");

	// Today - 1 year
	var d1 = Date.parse("today - 1 year");

	// Today - 1 year
	var d1 = Date.parse("t-1y"); 


	/////////////////////////////
	// Partial Dates and Times //
	/////////////////////////////

	// July 15th of this year.
	var d1 = Date.parse("July 15");

	// 15th day of current day and year.
	var d1 = Date.parse("15");

	// July 1st of current year at 10pm.
	var d1 = Date.parse("7/1 10pm");
	
* * @param {String} The string value to convert into a Date object [Required] * @return {Date} A Date object or null if the string cannot be converted into a Date. */ var parseUtils = { removeOrds: function (s) { ords = s.match(/\b(\d+)(?:st|nd|rd|th)\b/); // find ordinal matches s = ((ords && ords.length === 2) ? s.replace(ords[0], ords[1]) : s); return s; }, grammarParser: function (s) { var r = null; try { r = $D.Grammar.start.call({}, s.replace(/^\s*(\S*(\s+\S+)*)\s*$/, "$1")); } catch (e) { return null; } return ((r[1].length === 0) ? r[0] : null); }, nativeFallback: function(s) { var t; try { // ok we haven't parsed it, last ditch attempt with the built-in parser. t = Date._parse(s); return (t || t === 0) ? new Date(t) : null; } catch (e) { return null; } } }; function parse (s) { var d; if (!s) { return null; } if (s instanceof Date) { return s.clone(); } if (s.length >= 4 && s.charAt(0) !== "0" && s.charAt(0) !== "+"&& s.charAt(0) !== "-") { // ie: 2004 will pass, 0800 won't. // Start with specific formats d = $D.Parsing.ISO.parse(s) || $D.Parsing.Numeric.parse(s); } if (d instanceof Date && !isNaN(d.getTime())) { return d; } else { // find ordinal dates (1st, 3rd, 8th, etc and remove them as they cause parsing issues) s = $D.Parsing.Normalizer.parse(parseUtils.removeOrds(s)); d = parseUtils.grammarParser(s); if (d !== null) { return d; } else { return parseUtils.nativeFallback(s); } } } if (!$D._parse) { $D._parse = $D.parse; } $D.parse = parse; Date.getParseFunction = function (fx) { var fns = Date.Grammar.allformats(fx); return function (s) { var r = null; for (var i = 0; i < fns.length; i++) { try { r = fns[i].call({}, s); } catch (e) { continue; } if (r[1].length === 0) { return r[0]; } } return null; }; }; /** * Converts the specified string value into its JavaScript Date equivalent using the specified format {String} or formats {Array} and the CultureInfo specific format information. * The format of the string value must match one of the supplied formats exactly. * * Example

	// 15-Oct-2004
	var d1 = Date.parseExact("10/15/2004", "M/d/yyyy");

	// 15-Oct-2004
	var d1 = Date.parse("15-Oct-2004", "M-ddd-yyyy");

	// 15-Oct-2004
	var d1 = Date.parse("2004.10.15", "yyyy.MM.dd");

	// Multiple formats
	var d1 = Date.parseExact("10/15/2004", ["M/d/yyyy", "MMMM d, yyyy"]);
	
* * @param {String} The string value to convert into a Date object [Required]. * @param {Object} The expected format {String} or an array of expected formats {Array} of the date string [Required]. * @return {Date} A Date object or null if the string cannot be converted into a Date. */ $D.parseExact = function (s, fx) { return $D.getParseFunction(fx)(s); }; }()); (function () { var $D = Date, $P = $D.prototype, // $C = $D.CultureInfo, // not used atm p = function (s, l) { if (!l) { l = 2; } return ("000" + s).slice(l * -1); }; /** * Converts a PHP format string to Java/.NET format string. * A PHP format string can be used with ._format or .format. * A Java/.NET format string can be used with .toString(). * The .parseExact function will only accept a Java/.NET format string * * Example * var f1 = "%m/%d/%y" * var f2 = Date.normalizeFormat(f1); // "MM/dd/yy" * * new Date().format(f1); // "04/13/08" * new Date()._format(f1); // "04/13/08" * new Date().toString(f2); // "04/13/08" * * var date = Date.parseExact("04/13/08", f2); // Sun Apr 13 2008 * * @param {String} A PHP format string consisting of one or more format spcifiers. * @return {String} The PHP format converted to a Java/.NET format string. */ var normalizerSubstitutions = { "d" : "dd", "%d": "dd", "D" : "ddd", "%a": "ddd", "j" : "dddd", "l" : "dddd", "%A": "dddd", "S" : "S", "F" : "MMMM", "%B": "MMMM", "m" : "MM", "%m": "MM", "M" : "MMM", "%b": "MMM", "%h": "MMM", "n" : "M", "Y" : "yyyy", "%Y": "yyyy", "y" : "yy", "%y": "yy", "g" : "h", "%I": "h", "G" : "H", "h" : "hh", "H" : "HH", "%H": "HH", "i" : "mm", "%M": "mm", "s" : "ss", "%S": "ss", "%r": "hh:mm tt", "%R": "H:mm", "%T": "H:mm:ss", "%X": "t", "%x": "d", "%e": "d", "%D": "MM/dd/yy", "%n": "\\n", "%t": "\\t", "e" : "z", "T" : "z", "%z": "z", "%Z": "z", "Z" : "ZZ", "N" : "u", "w" : "u", "%w": "u", "W" : "W", "%V": "W" }; var normalizer = { substitutes: function (m) { return normalizerSubstitutions[m]; }, interpreted: function (m, x) { var y; switch (m) { case "%u": return x.getDay() + 1; case "z": return x.getOrdinalNumber(); case "%j": return p(x.getOrdinalNumber(), 3); case "%U": var d1 = x.clone().set({month: 0, day: 1}).addDays(-1).moveToDayOfWeek(0), d2 = x.clone().addDays(1).moveToDayOfWeek(0, -1); return (d2 < d1) ? "00" : p((d2.getOrdinalNumber() - d1.getOrdinalNumber()) / 7 + 1); case "%W": return p(x.getWeek()); case "t": return $D.getDaysInMonth(x.getFullYear(), x.getMonth()); case "o": case "%G": return x.setWeek(x.getISOWeek()).toString("yyyy"); case "%g": return x._format("%G").slice(-2); case "a": case "%p": return t("tt").toLowerCase(); case "A": return t("tt").toUpperCase(); case "u": return p(x.getMilliseconds(), 3); case "I": return (x.isDaylightSavingTime()) ? 1 : 0; case "O": return x.getUTCOffset(); case "P": y = x.getUTCOffset(); return y.substring(0, y.length - 2) + ":" + y.substring(y.length - 2); case "B": var now = new Date(); return Math.floor(((now.getHours() * 3600) + (now.getMinutes() * 60) + now.getSeconds() + (now.getTimezoneOffset() + 60) * 60) / 86.4); case "c": return x.toISOString().replace(/\"/g, ""); case "U": return $D.strtotime("now"); case "%c": return t("d") + " " + t("t"); case "%C": return Math.floor(x.getFullYear() / 100 + 1); } }, shouldOverrideDefaults: function (m) { switch (m) { case "%e": return true; default: return false; } }, parse: function (m, context) { var formatString, c = context || new Date(); formatString = normalizer.substitutes(m); if (formatString) { return formatString; } formatString = normalizer.interpreted(m, c); if (formatString) { return formatString; } else { return m; } } }; $D.normalizeFormat = function (format, context) { return format.replace(/(%|\\)?.|%%/g, function(t){ return normalizer.parse(t, context); }); }; /** * Format a local Unix timestamp according to locale settings * * Example: * Date.strftime("%m/%d/%y", new Date()); // "04/13/08" * Date.strftime("c", "2008-04-13T17:52:03Z"); // "04/13/08" * * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @param {Number|String} The number representing the number of seconds that have elapsed since January 1, 1970 (local time). * @return {String} A string representation of the current Date object. */ $D.strftime = function (format, time) { var d = Date.parse(time); return d._format(format); }; /** * Parse any textual datetime description into a Unix timestamp. * A Unix timestamp is the number of seconds that have elapsed since January 1, 1970 (midnight UTC/GMT). * * Example: * Date.strtotime("04/13/08"); // 1208044800 * Date.strtotime("1970-01-01T00:00:00Z"); // 0 * * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @param {Object} A string or date object. * @return {String} A string representation of the current Date object. */ $D.strtotime = function (time) { var d = $D.parse(time); return Math.round($D.UTC(d.getUTCFullYear(), d.getUTCMonth(), d.getUTCDate(), d.getUTCHours(), d.getUTCMinutes(), d.getUTCSeconds(), d.getUTCMilliseconds()) / 1000); }; /** * Converts the value of the current Date object to its equivalent string representation using a PHP/Unix style of date format specifiers. * Format Specifiers * Format Description Example * ------ --------------------------------------------------------------------------- ----------------------- * %a abbreviated weekday name according to the current localed "Mon" through "Sun" * %A full weekday name according to the current localed "Sunday" through "Saturday" * %b abbreviated month name according to the current localed "Jan" through "Dec" * %B full month name according to the current locale "January" through "December" * %c preferred date and time representation for the current locale "4/13/2008 12:33 PM" * %C century number (the year divided by 100 and truncated to an integer) "00" to "99" * %d day of the month as a decimal number "01" to "31" * %D same as %m/%d/%y "04/13/08" * %e day of the month as a decimal number, a single digit is preceded by a space "1" to "31" * %g like %G, but without the century "08" * %G The 4-digit year corresponding to the ISO week number (see %V). "2008" * This has the same format and value as %Y, except that if the ISO week number * belongs to the previous or next year, that year is used instead. * %h same as %b "Jan" through "Dec" * %H hour as a decimal number using a 24-hour clock. "00" to "23" * %I hour as a decimal number using a 12-hour clock. "01" to "12" * %j day of the year as a decimal number. "001" to "366" * %m month as a decimal number. "01" to "12" * %M minute as a decimal number. "00" to "59" * %n newline character "\n" * %p either "am" or "pm" according to the given time value, or the "am" or "pm" * corresponding strings for the current locale. * %r time in a.m. and p.m. notation "8:44 PM" * %R time in 24 hour notation "20:44" * %S second as a decimal number "00" to "59" * %t tab character "\t" * %T current time, equal to %H:%M:%S "12:49:11" * %u weekday as a decimal number ["1", "7"], with "1" representing Monday "1" to "7" * %U week number of the current year as a decimal number, starting with the "0" to ("52" or "53") * first Sunday as the first day of the first week * %V The ISO 8601:1988 week number of the current year as a decimal number, "00" to ("52" or "53") * range 01 to 53, where week 1 is the first week that has at least 4 days * in the current year, and with Monday as the first day of the week. * (Use %G or %g for the year component that corresponds to the week number * for the specified timestamp.) * %W week number of the current year as a decimal number, starting with the "00" to ("52" or "53") * first Monday as the first day of the first week * %w day of the week as a decimal, Sunday being "0" "0" to "6" * %x preferred date representation for the current locale without the time "4/13/2008" * %X preferred time representation for the current locale without the date "12:53:05" * %y year as a decimal number without a century "00" "99" * %Y year as a decimal number including the century "2008" * %Z time zone or name or abbreviation "UTC", "EST", "PST" * %z same as %Z * %% a literal "%" characters "%" * d Day of the month, 2 digits with leading zeros "01" to "31" * D A textual representation of a day, three letters "Mon" through "Sun" * j Day of the month without leading zeros "1" to "31" * l A full textual representation of the day of the week (lowercase "L") "Sunday" through "Saturday" * N ISO-8601 numeric representation of the day of the week (added in PHP 5.1.0) "1" (for Monday) through "7" (for Sunday) * S English ordinal suffix for the day of the month, 2 characters "st", "nd", "rd" or "th". Works well with j * w Numeric representation of the day of the week "0" (for Sunday) through "6" (for Saturday) * z The day of the year (starting from "0") "0" through "365" * W ISO-8601 week number of year, weeks starting on Monday "00" to ("52" or "53") * F A full textual representation of a month, such as January or March "January" through "December" * m Numeric representation of a month, with leading zeros "01" through "12" * M A short textual representation of a month, three letters "Jan" through "Dec" * n Numeric representation of a month, without leading zeros "1" through "12" * t Number of days in the given month "28" through "31" * L Whether it's a leap year "1" if it is a leap year, "0" otherwise * o ISO-8601 year number. This has the same value as Y, except that if the "2008" * ISO week number (W) belongs to the previous or next year, that year * is used instead. * Y A full numeric representation of a year, 4 digits "2008" * y A two digit representation of a year "08" * a Lowercase Ante meridiem and Post meridiem "am" or "pm" * A Uppercase Ante meridiem and Post meridiem "AM" or "PM" * B Swatch Internet time "000" through "999" * g 12-hour format of an hour without leading zeros "1" through "12" * G 24-hour format of an hour without leading zeros "0" through "23" * h 12-hour format of an hour with leading zeros "01" through "12" * H 24-hour format of an hour with leading zeros "00" through "23" * i Minutes with leading zeros "00" to "59" * s Seconds, with leading zeros "00" through "59" * u Milliseconds "54321" * e Timezone identifier "UTC", "EST", "PST" * I Whether or not the date is in daylight saving time (uppercase i) "1" if Daylight Saving Time, "0" otherwise * O Difference to Greenwich time (GMT) in hours "+0200", "-0600" * P Difference to Greenwich time (GMT) with colon between hours and minutes "+02:00", "-06:00" * T Timezone abbreviation "UTC", "EST", "PST" * Z Timezone offset in seconds. The offset for timezones west of UTC is "-43200" through "50400" * always negative, and for those east of UTC is always positive. * c ISO 8601 date "2004-02-12T15:19:21+00:00" * r RFC 2822 formatted date "Thu, 21 Dec 2000 16:01:07 +0200" * U Seconds since the Unix Epoch (January 1 1970 00:00:00 GMT) "0" * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @return {String} A string representation of the current Date object. */ var formatReplace = function (context) { return function (m) { var formatString, override = false; if (m.charAt(0) === "\\" || m.substring(0, 2) === "%%") { return m.replace("\\", "").replace("%%", "%"); } override = normalizer.shouldOverrideDefaults(m); formatString = $D.normalizeFormat(m, context); if (formatString) { return context.toString(formatString, override); } }; }; $P._format = function (format) { var formatter = formatReplace(this); if (!format) { return this._toString(); } else { return format.replace(/(%|\\)?.|%%/g, formatter); } }; if (!$P.format) { $P.format = $P._format; } }()); (function () { "use strict"; var gFn = function (attr) { return function () { return this[attr]; }; }; var sFn = function (attr) { return function (val) { this[attr] = val; return this; }; }; var attrs = ["years", "months", "days", "hours", "minutes", "seconds", "milliseconds"]; var addSetFuncs = function (context, attrs) { for (var i = 0; i < attrs.length ; i++) { var $a = attrs[i], $b = $a.slice(0, 1).toUpperCase() + $a.slice(1); context.prototype[$a] = 0; context.prototype["get" + $b] = gFn($a); context.prototype["set" + $b] = sFn($a); } }; /** * new TimeSpan(milliseconds); * new TimeSpan(days, hours, minutes, seconds); * new TimeSpan(days, hours, minutes, seconds, milliseconds); */ var TimeSpan = function (days, hours, minutes, seconds, milliseconds) { if (arguments.length === 1 && typeof days === "number") { var orient = (days < 0) ? -1 : +1; var millsLeft = Math.abs(days); this.setDays(Math.floor(millsLeft / 86400000) * orient); millsLeft = millsLeft % 86400000; this.setHours(Math.floor(millsLeft / 3600000) * orient); millsLeft = millsLeft % 3600000; this.setMinutes(Math.floor(millsLeft / 60000) * orient); millsLeft = millsLeft % 60000; this.setSeconds(Math.floor(millsLeft / 1000) * orient); millsLeft = millsLeft % 1000; this.setMilliseconds(millsLeft * orient); } else { this.set(days, hours, minutes, seconds, milliseconds); } this.getTotalMilliseconds = function () { return (this.getDays() * 86400000) + (this.getHours() * 3600000) + (this.getMinutes() * 60000) + (this.getSeconds() * 1000); }; this.compareTo = function (time) { var t1 = new Date(1970, 1, 1, this.getHours(), this.getMinutes(), this.getSeconds()), t2; if (time === null) { t2 = new Date(1970, 1, 1, 0, 0, 0); } else { t2 = new Date(1970, 1, 1, time.getHours(), time.getMinutes(), time.getSeconds()); } return (t1 < t2) ? -1 : (t1 > t2) ? 1 : 0; }; this.equals = function (time) { return (this.compareTo(time) === 0); }; this.add = function (time) { return (time === null) ? this : this.addSeconds(time.getTotalMilliseconds() / 1000); }; this.subtract = function (time) { return (time === null) ? this : this.addSeconds(-time.getTotalMilliseconds() / 1000); }; this.addDays = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 86400000)); }; this.addHours = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 3600000)); }; this.addMinutes = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 60000)); }; this.addSeconds = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 1000)); }; this.addMilliseconds = function (n) { return new TimeSpan(this.getTotalMilliseconds() + n); }; this.get12HourHour = function () { return (this.getHours() > 12) ? this.getHours() - 12 : (this.getHours() === 0) ? 12 : this.getHours(); }; this.getDesignator = function () { return (this.getHours() < 12) ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator; }; this.toString = function (format) { this._toString = function () { if (this.getDays() !== null && this.getDays() > 0) { return this.getDays() + "." + this.getHours() + ":" + this.p(this.getMinutes()) + ":" + this.p(this.getSeconds()); } else { return this.getHours() + ":" + this.p(this.getMinutes()) + ":" + this.p(this.getSeconds()); } }; this.p = function (s) { return (s.toString().length < 2) ? "0" + s : s; }; var me = this; return format ? format.replace(/dd?|HH?|hh?|mm?|ss?|tt?/g, function (format) { switch (format) { case "d": return me.getDays(); case "dd": return me.p(me.getDays()); case "H": return me.getHours(); case "HH": return me.p(me.getHours()); case "h": return me.get12HourHour(); case "hh": return me.p(me.get12HourHour()); case "m": return me.getMinutes(); case "mm": return me.p(me.getMinutes()); case "s": return me.getSeconds(); case "ss": return me.p(me.getSeconds()); case "t": return ((me.getHours() < 12) ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator).substring(0, 1); case "tt": return (me.getHours() < 12) ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator; } } ) : this._toString(); }; return this; }; addSetFuncs(TimeSpan, attrs.slice(2)); TimeSpan.prototype.set = function (days, hours, minutes, seconds, milliseconds){ this.setDays(days || this.getDays()); this.setHours(hours || this.getHours()); this.setMinutes(minutes || this.getMinutes()); this.setSeconds(seconds || this.getSeconds()); this.setMilliseconds(milliseconds || this.getMilliseconds()); }; /** * Gets the time of day for this date instances. * @return {TimeSpan} TimeSpan */ Date.prototype.getTimeOfDay = function () { return new TimeSpan(0, this.getHours(), this.getMinutes(), this.getSeconds(), this.getMilliseconds()); }; Date.TimeSpan = TimeSpan; if (typeof window !== "undefined" ) { // keeping API compatible for v1.x window.TimeSpan = TimeSpan; } }()); (function () { "use strict"; var attrs = ["years", "months", "days", "hours", "minutes", "seconds", "milliseconds"]; var gFn = function (attr) { return function () { return this[attr]; }; }; var sFn = function (attr) { return function (val) { this[attr] = val; return this; }; }; var addSetFuncs = function (context, attrs) { for (var i = 0; i < attrs.length ; i++) { var $a = attrs[i], $b = $a.slice(0, 1).toUpperCase() + $a.slice(1); context.prototype[$a] = 0; context.prototype["get" + $b] = gFn($a); context.prototype["set" + $b] = sFn($a); } }; var setMonthsAndYears = function (orient, d1, d2, context) { function inc() { d1.addMonths(-orient); context.months++; if (context.months === 12) { context.years++; context.months = 0; } } if (orient === +1) { while (d1 > d2) { inc(); } } else { while (d1 < d2) { inc(); } } context.months--; context.months *= orient; context.years *= orient; }; var adjustForDST = function(orient, startDate, endDate) { var hasDSTMismatch = (false === (startDate.isDaylightSavingTime() === endDate.isDaylightSavingTime())); if (hasDSTMismatch && orient === 1) { startDate.addHours(-1); } else if (hasDSTMismatch) { startDate.addHours(1); } }; /** * TimePeriod(startDate, endDate); * TimePeriod(years, months, days, hours, minutes, seconds, milliseconds); */ var TimePeriod = function (years, months, days, hours, minutes, seconds, milliseconds) { if (arguments.length === 7) { this.set(years, months, days, hours, minutes, seconds, milliseconds); } else if (arguments.length === 2 && arguments[0] instanceof Date && arguments[1] instanceof Date) { var startDate = arguments[0].clone(); var endDate = arguments[1].clone(); var orient = (startDate > endDate) ? +1 : -1; this.dates = { start: arguments[0].clone(), end: arguments[1].clone() }; setMonthsAndYears(orient, startDate, endDate, this); adjustForDST(orient, startDate, endDate); // // TODO - adjust for DST var diff = endDate - startDate; if (diff !== 0) { var ts = new TimeSpan(diff); this.set(this.years, this.months, ts.getDays(), ts.getHours(), ts.getMinutes(), ts.getSeconds(), ts.getMilliseconds()); } } return this; }; // create all the set functions. addSetFuncs(TimePeriod, attrs); TimePeriod.prototype.set = function (years, months, days, hours, minutes, seconds, milliseconds){ this.setYears(years || this.getYears()); this.setMonths(months || this.getMonths()); this.setDays(days || this.getDays()); this.setHours(hours || this.getHours()); this.setMinutes(minutes || this.getMinutes()); this.setSeconds(seconds || this.getSeconds()); this.setMilliseconds(milliseconds || this.getMilliseconds()); }; Date.TimePeriod = TimePeriod; if (typeof window !== "undefined") { // keeping API compatible for v1.x window.TimePeriod = TimePeriod; } }()); ================================================ FILE: build/date-ar-IQ.js ================================================ /** * @overview datejs * @version 1.0.0-rc3 * @author Gregory Wild-Smith * @copyright 2015 Gregory Wild-Smith * @license MIT * @homepage https://github.com/abritinthebay/datejs */ /* * DateJS Culture String File * Country Code: ar-IQ * Name: Arabic (Iraq) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["ar-IQ"] = { "name": "ar-IQ", "englishName": "Arabic (Iraq)", "nativeName": "العربية (العراق)", "Sunday": "الاحد", "Monday": "الاثنين", "Tuesday": "الثلاثاء", "Wednesday": "الاربعاء", "Thursday": "الخميس", "Friday": "الجمعة", "Saturday": "السبت", "Sun": "الاحد", "Mon": "الاثنين", "Tue": "الثلاثاء", "Wed": "الاربعاء", "Thu": "الخميس", "Fri": "الجمعة", "Sat": "السبت", "Su": "أ", "Mo": "ا", "Tu": "ث", "We": "أ", "Th": "خ", "Fr": "ج", "Sa": "س", "S_Sun_Initial": "أ", "M_Mon_Initial": "ا", "T_Tue_Initial": "ث", "W_Wed_Initial": "أ", "T_Thu_Initial": "خ", "F_Fri_Initial": "ج", "S_Sat_Initial": "س", "January": "كانون الثاني", "February": "شباط", "March": "آذار", "April": "نيسان", "May": "أيار", "June": "حزيران", "July": "تموز", "August": "آب", "September": "أيلول", "October": "تشرين الأول", "November": "تشرين الثاني", "December": "كانون الأول", "Jan_Abbr": "كانون الثاني", "Feb_Abbr": "شباط", "Mar_Abbr": "آذار", "Apr_Abbr": "نيسان", "May_Abbr": "أيار", "Jun_Abbr": "حزيران", "Jul_Abbr": "تموز", "Aug_Abbr": "آب", "Sep_Abbr": "أيلول", "Oct_Abbr": "تشرين الأول", "Nov_Abbr": "تشرين الثاني", "Dec_Abbr": "كانون الأول", "AM": "ص", "PM": "م", "firstDayOfWeek": 6, "twoDigitYearMax": 2029, "mdy": "dmy", "M/d/yyyy": "dd/MM/yyyy", "dddd, MMMM dd, yyyy": "dd MMMM, yyyy", "h:mm tt": "hh:mm tt", "h:mm:ss tt": "hh:mm:ss tt", "dddd, MMMM dd, yyyy h:mm:ss tt": "dd MMMM, yyyy hh:mm:ss tt", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "dd MMMM", "MMMM, yyyy": "MMMM, yyyy", "/jan(uary)?/": "كانون الثاني", "/feb(ruary)?/": "شباط", "/mar(ch)?/": "آذار", "/apr(il)?/": "نيسان", "/may/": "أيار", "/jun(e)?/": "حزيران", "/jul(y)?/": "تموز", "/aug(ust)?/": "آب", "/sep(t(ember)?)?/": "أيلول", "/oct(ober)?/": "تشرين الأول", "/nov(ember)?/": "تشرين الثاني", "/dec(ember)?/": "كانون الأول", "/^su(n(day)?)?/": "^الاحد", "/^mo(n(day)?)?/": "^ا(1)?", "/^tu(e(s(day)?)?)?/": "^الثلاثاء", "/^we(d(nesday)?)?/": "^الاربعاء", "/^th(u(r(s(day)?)?)?)?/": "^الخميس", "/^fr(i(day)?)?/": "^الجمعة", "/^sa(t(urday)?)?/": "^السبت", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "ar-IQ"; /** * @overview datejs * @version 1.0.0-rc3 * @author Gregory Wild-Smith * @copyright 2015 Gregory Wild-Smith * @license MIT * @homepage https://github.com/abritinthebay/datejs */(function () { var $D = Date; var lang = Date.CultureStrings ? Date.CultureStrings.lang : null; var loggedKeys = {}; // for debug purposes. var getText = { getFromKey: function (key, countryCode) { var output; if (Date.CultureStrings && Date.CultureStrings[countryCode] && Date.CultureStrings[countryCode][key]) { output = Date.CultureStrings[countryCode][key]; } else { output = getText.buildFromDefault(key); } if (key.charAt(0) === "/") { // Assume it's a regex output = getText.buildFromRegex(key, countryCode); } return output; }, getFromObjectValues: function (obj, countryCode) { var key, output = {}; for(key in obj) { if (obj.hasOwnProperty(key)) { output[key] = getText.getFromKey(obj[key], countryCode); } } return output; }, getFromObjectKeys: function (obj, countryCode) { var key, output = {}; for(key in obj) { if (obj.hasOwnProperty(key)) { output[getText.getFromKey(key, countryCode)] = obj[key]; } } return output; }, getFromArray: function (arr, countryCode) { var output = []; for (var i=0; i < arr.length; i++){ if (i in arr) { output[i] = getText.getFromKey(arr[i], countryCode); } } return output; }, buildFromDefault: function (key) { var output, length, split, last; switch(key) { case "name": output = "en-US"; break; case "englishName": output = "English (United States)"; break; case "nativeName": output = "English (United States)"; break; case "twoDigitYearMax": output = 2049; break; case "firstDayOfWeek": output = 0; break; default: output = key; split = key.split("_"); length = split.length; if (length > 1 && key.charAt(0) !== "/") { // if the key isn't a regex and it has a split. last = split[(length - 1)].toLowerCase(); if (last === "initial" || last === "abbr") { output = split[0]; } } break; } return output; }, buildFromRegex: function (key, countryCode) { var output; if (Date.CultureStrings && Date.CultureStrings[countryCode] && Date.CultureStrings[countryCode][key]) { output = new RegExp(Date.CultureStrings[countryCode][key], "i"); } else { output = new RegExp(key.replace(new RegExp("/", "g"),""), "i"); } return output; } }; var shallowMerge = function (obj1, obj2) { for (var attrname in obj2) { if (obj2.hasOwnProperty(attrname)) { obj1[attrname] = obj2[attrname]; } } }; var __ = function (key, language) { var countryCode = (language) ? language : lang; loggedKeys[key] = key; if (typeof key === "object") { if (key instanceof Array) { return getText.getFromArray(key, countryCode); } else { return getText.getFromObjectKeys(key, countryCode); } } else { return getText.getFromKey(key, countryCode); } }; var loadI18nScript = function (code) { // paatterned after jQuery's getScript. var url = Date.Config.i18n + code + ".js"; var head = document.getElementsByTagName("head")[0] || document.documentElement; var script = document.createElement("script"); script.src = url; var completed = false; var events = { done: function (){} // placeholder function }; // Attach handlers for all browsers script.onload = script.onreadystatechange = function() { if ( !completed && (!this.readyState || this.readyState === "loaded" || this.readyState === "complete") ) { events.done(); head.removeChild(script); } }; setTimeout(function() { head.insertBefore(script, head.firstChild); }, 0); // allows return to execute first return { done: function (cb) { events.done = function() { if (cb) { setTimeout(cb,0); } }; } }; }; var buildInfo = { buildFromMethodHash: function (obj) { var key; for(key in obj) { if (obj.hasOwnProperty(key)) { obj[key] = buildInfo[obj[key]](); } } return obj; }, timeZoneDST: function () { var DST = { "CHADT": "+1345", "NZDT": "+1300", "AEDT": "+1100", "ACDT": "+1030", "AZST": "+0500", "IRDT": "+0430", "EEST": "+0300", "CEST": "+0200", "BST": "+0100", "PMDT": "-0200", "ADT": "-0300", "NDT": "-0230", "EDT": "-0400", "CDT": "-0500", "MDT": "-0600", "PDT": "-0700", "AKDT": "-0800", "HADT": "-0900" }; return __(DST); }, timeZoneStandard: function () { var standard = { "LINT": "+1400", "TOT": "+1300", "CHAST": "+1245", "NZST": "+1200", "NFT": "+1130", "SBT": "+1100", "AEST": "+1000", "ACST": "+0930", "JST": "+0900", "CWST": "+0845", "CT": "+0800", "ICT": "+0700", "MMT": "+0630", "BST": "+0600", "NPT": "+0545", "IST": "+0530", "PKT": "+0500", "AFT": "+0430", "MSK": "+0400", "IRST": "+0330", "FET": "+0300", "EET": "+0200", "CET": "+0100", "GMT": "+0000", "UTC": "+0000", "CVT": "-0100", "GST": "-0200", "BRT": "-0300", "NST": "-0330", "AST": "-0400", "EST": "-0500", "CST": "-0600", "MST": "-0700", "PST": "-0800", "AKST": "-0900", "MIT": "-0930", "HST": "-1000", "SST": "-1100", "BIT": "-1200" }; return __(standard); }, timeZones: function (data) { var zone; data.timezones = []; for (zone in data.abbreviatedTimeZoneStandard) { if (data.abbreviatedTimeZoneStandard.hasOwnProperty(zone)) { data.timezones.push({ name: zone, offset: data.abbreviatedTimeZoneStandard[zone]}); } } for (zone in data.abbreviatedTimeZoneDST) { if (data.abbreviatedTimeZoneDST.hasOwnProperty(zone)) { data.timezones.push({ name: zone, offset: data.abbreviatedTimeZoneDST[zone], dst: true}); } } return data.timezones; }, days: function () { return __(["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"]); }, dayAbbr: function () { return __(["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"]); }, dayShortNames: function () { return __(["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"]); }, dayFirstLetters: function () { return __(["S_Sun_Initial", "M_Mon_Initial", "T_Tues_Initial", "W_Wed_Initial", "T_Thu_Initial", "F_Fri_Initial", "S_Sat_Initial"]); }, months: function () { return __(["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"]); }, monthAbbr: function () { return __(["Jan_Abbr", "Feb_Abbr", "Mar_Abbr", "Apr_Abbr", "May_Abbr", "Jun_Abbr", "Jul_Abbr", "Aug_Abbr", "Sep_Abbr", "Oct_Abbr", "Nov_Abbr", "Dec_Abbr"]); }, formatPatterns: function () { return getText.getFromObjectValues({ shortDate: "M/d/yyyy", longDate: "dddd, MMMM dd, yyyy", shortTime: "h:mm tt", longTime: "h:mm:ss tt", fullDateTime: "dddd, MMMM dd, yyyy h:mm:ss tt", sortableDateTime: "yyyy-MM-ddTHH:mm:ss", universalSortableDateTime: "yyyy-MM-dd HH:mm:ssZ", rfc1123: "ddd, dd MMM yyyy HH:mm:ss", monthDay: "MMMM dd", yearMonth: "MMMM, yyyy" }, Date.i18n.currentLanguage()); }, regex: function () { return getText.getFromObjectValues({ inTheMorning: "/( in the )(morn(ing)?)\\b/", thisMorning: "/(this )(morn(ing)?)\\b/", amThisMorning: "/(\b\\d(am)? )(this )(morn(ing)?)/", inTheEvening: "/( in the )(even(ing)?)\\b/", thisEvening: "/(this )(even(ing)?)\\b/", pmThisEvening: "/(\b\\d(pm)? )(this )(even(ing)?)/", jan: "/jan(uary)?/", feb: "/feb(ruary)?/", mar: "/mar(ch)?/", apr: "/apr(il)?/", may: "/may/", jun: "/jun(e)?/", jul: "/jul(y)?/", aug: "/aug(ust)?/", sep: "/sep(t(ember)?)?/", oct: "/oct(ober)?/", nov: "/nov(ember)?/", dec: "/dec(ember)?/", sun: "/^su(n(day)?)?/", mon: "/^mo(n(day)?)?/", tue: "/^tu(e(s(day)?)?)?/", wed: "/^we(d(nesday)?)?/", thu: "/^th(u(r(s(day)?)?)?)?/", fri: "/fr(i(day)?)?/", sat: "/^sa(t(urday)?)?/", future: "/^next/", past: "/^last|past|prev(ious)?/", add: "/^(\\+|aft(er)?|from|hence)/", subtract: "/^(\\-|bef(ore)?|ago)/", yesterday: "/^yes(terday)?/", today: "/^t(od(ay)?)?/", tomorrow: "/^tom(orrow)?/", now: "/^n(ow)?/", millisecond: "/^ms|milli(second)?s?/", second: "/^sec(ond)?s?/", minute: "/^mn|min(ute)?s?/", hour: "/^h(our)?s?/", week: "/^w(eek)?s?/", month: "/^m(onth)?s?/", day: "/^d(ay)?s?/", year: "/^y(ear)?s?/", shortMeridian: "/^(a|p)/", longMeridian: "/^(a\\.?m?\\.?|p\\.?m?\\.?)/", timezone: "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/", ordinalSuffix: "/^\\s*(st|nd|rd|th)/", timeContext: "/^\\s*(\\:|a(?!u|p)|p)/" }, Date.i18n.currentLanguage()); } }; var CultureInfo = function () { var info = getText.getFromObjectValues({ name: "name", englishName: "englishName", nativeName: "nativeName", amDesignator: "AM", pmDesignator: "PM", firstDayOfWeek: "firstDayOfWeek", twoDigitYearMax: "twoDigitYearMax", dateElementOrder: "mdy" }, Date.i18n.currentLanguage()); var constructedInfo = buildInfo.buildFromMethodHash({ dayNames: "days", abbreviatedDayNames: "dayAbbr", shortestDayNames: "dayShortNames", firstLetterDayNames: "dayFirstLetters", monthNames: "months", abbreviatedMonthNames: "monthAbbr", formatPatterns: "formatPatterns", regexPatterns: "regex", abbreviatedTimeZoneDST: "timeZoneDST", abbreviatedTimeZoneStandard: "timeZoneStandard" }); shallowMerge(info, constructedInfo); buildInfo.timeZones(info); return info; }; $D.i18n = { __: function (key, lang) { return __(key, lang); }, currentLanguage: function () { return lang || "en-US"; }, setLanguage: function (code, force, cb) { var async = false; if (force || code === "en-US" || (!!Date.CultureStrings && !!Date.CultureStrings[code])) { lang = code; Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings.lang = code; Date.CultureInfo = new CultureInfo(); } else { if (!(!!Date.CultureStrings && !!Date.CultureStrings[code])) { if (typeof exports !== "undefined" && this.exports !== exports) { // we're in a Node enviroment, load it using require try { require("../i18n/" + code + ".js"); lang = code; Date.CultureStrings.lang = code; Date.CultureInfo = new CultureInfo(); } catch (e) { // var str = "The language for '" + code + "' could not be loaded by Node. It likely does not exist."; throw new Error("The DateJS IETF language tag '" + code + "' could not be loaded by Node. It likely does not exist."); } } else if (Date.Config && Date.Config.i18n) { // we know the location of the files, so lets load them async = true; loadI18nScript(code).done(function(){ lang = code; Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings.lang = code; Date.CultureInfo = new CultureInfo(); $D.Parsing.Normalizer.buildReplaceData(); // because this is async if ($D.Grammar) { $D.Grammar.buildGrammarFormats(); // so we can parse those strings... } if (cb) { setTimeout(cb,0); } }); } else { Date.console.error("The DateJS IETF language tag '" + code + "' is not available and has not been loaded."); return false; } } } $D.Parsing.Normalizer.buildReplaceData(); // rebuild normalizer strings if ($D.Grammar) { $D.Grammar.buildGrammarFormats(); // so we can parse those strings... } if (!async && cb) { setTimeout(cb,0); } }, getLoggedKeys: function () { return loggedKeys; }, updateCultureInfo: function () { Date.CultureInfo = new CultureInfo(); } }; $D.i18n.updateCultureInfo(); // run automatically }()); (function () { var $D = Date, $P = $D.prototype, p = function (s, l) { if (!l) { l = 2; } return ("000" + s).slice(l * -1); }; if (typeof window !== "undefined" && typeof window.console !== "undefined" && typeof window.console.log !== "undefined") { $D.console = console; // used only to raise non-critical errors if available } else { // set mock so we don't give errors. $D.console = { log: function(){}, error: function(){} }; } $D.Config = $D.Config || {}; $D.initOverloads = function() { /** * Overload of Date.now. Allows an alternate call for Date.now where it returns the * current Date as an object rather than just milliseconds since the Unix Epoch. * * Also provides an implementation of now() for browsers (IE<9) that don't have it. * * Backwards compatible so with work with either: * Date.now() [returns ms] * or * Date.now(true) [returns Date] */ if (!$D.now) { $D._now = function now() { return new Date().getTime(); }; } else if (!$D._now) { $D._now = $D.now; } $D.now = function (returnObj) { if (returnObj) { return $D.present(); } else { return $D._now(); } }; if ( !$P.toISOString ) { $P.toISOString = function() { return this.getUTCFullYear() + "-" + p(this.getUTCMonth() + 1) + "-" + p(this.getUTCDate()) + "T" + p(this.getUTCHours()) + ":" + p(this.getUTCMinutes()) + ":" + p(this.getUTCSeconds()) + "." + String( (this.getUTCMilliseconds()/1000).toFixed(3)).slice(2, 5) + "Z"; }; } // private if ( $P._toString === undefined ){ $P._toString = $P.toString; } }; $D.initOverloads(); /** * Gets a date that is set to the current date. The time is set to the start of the day (00:00 or 12:00 AM). * @return {Date} The current date. */ $D.today = function () { return new Date().clearTime(); }; /** * Gets a date that is set to the current date and time (same as new Date, but chainable) * @return {Date} The current date. */ $D.present = function () { return new Date(); }; /** * Compares the first date to the second date and returns an number indication of their relative values. * @param {Date} First Date object to compare [Required]. * @param {Date} Second Date object to compare to [Required]. * @return {Number} -1 = date1 is lessthan date2. 0 = values are equal. 1 = date1 is greaterthan date2. */ $D.compare = function (date1, date2) { if (isNaN(date1) || isNaN(date2)) { throw new Error(date1 + " - " + date2); } else if (date1 instanceof Date && date2 instanceof Date) { return (date1 < date2) ? -1 : (date1 > date2) ? 1 : 0; } else { throw new TypeError(date1 + " - " + date2); } }; /** * Compares the first Date object to the second Date object and returns true if they are equal. * @param {Date} First Date object to compare [Required] * @param {Date} Second Date object to compare to [Required] * @return {Boolean} true if dates are equal. false if they are not equal. */ $D.equals = function (date1, date2) { return (date1.compareTo(date2) === 0); }; /** * Gets the language appropriate day name when given the day number(0-6) * eg - 0 == Sunday * @return {String} The day name */ $D.getDayName = function (n) { return Date.CultureInfo.dayNames[n]; }; /** * Gets the day number (0-6) if given a CultureInfo specific string which is a valid dayName, abbreviatedDayName or shortestDayName (two char). * @param {String} The name of the day (eg. "Monday, "Mon", "tuesday", "tue", "We", "we"). * @return {Number} The day number */ $D.getDayNumberFromName = function (name) { var n = Date.CultureInfo.dayNames, m = Date.CultureInfo.abbreviatedDayNames, o = Date.CultureInfo.shortestDayNames, s = name.toLowerCase(); for (var i = 0; i < n.length; i++) { if (n[i].toLowerCase() === s || m[i].toLowerCase() === s || o[i].toLowerCase() === s) { return i; } } return -1; }; /** * Gets the month number (0-11) if given a Culture Info specific string which is a valid monthName or abbreviatedMonthName. * @param {String} The name of the month (eg. "February, "Feb", "october", "oct"). * @return {Number} The day number */ $D.getMonthNumberFromName = function (name) { var n = Date.CultureInfo.monthNames, m = Date.CultureInfo.abbreviatedMonthNames, s = name.toLowerCase(); for (var i = 0; i < n.length; i++) { if (n[i].toLowerCase() === s || m[i].toLowerCase() === s) { return i; } } return -1; }; /** * Gets the language appropriate month name when given the month number(0-11) * eg - 0 == January * @return {String} The month name */ $D.getMonthName = function (n) { return Date.CultureInfo.monthNames[n]; }; /** * Determines if the current date instance is within a LeapYear. * @param {Number} The year. * @return {Boolean} true if date is within a LeapYear, otherwise false. */ $D.isLeapYear = function (year) { return ((year % 4 === 0 && year % 100 !== 0) || year % 400 === 0); }; /** * Gets the number of days in the month, given a year and month value. Automatically corrects for LeapYear. * @param {Number} The year. * @param {Number} The month (0-11). * @return {Number} The number of days in the month. */ $D.getDaysInMonth = function (year, month) { if (!month && $D.validateMonth(year)) { month = year; year = Date.today().getFullYear(); } return [31, ($D.isLeapYear(year) ? 29 : 28), 31, 30, 31, 30, 31, 31, 30, 31, 30, 31][month]; }; $P.getDaysInMonth = function () { return $D.getDaysInMonth(this.getFullYear(), this.getMonth()); }; $D.getTimezoneAbbreviation = function (offset, dst) { var p, n = (dst || false) ? Date.CultureInfo.abbreviatedTimeZoneDST : Date.CultureInfo.abbreviatedTimeZoneStandard; for (p in n) { if (n.hasOwnProperty(p)) { if (n[p] === offset) { return p; } } } return null; }; $D.getTimezoneOffset = function (name, dst) { var i, a =[], z = Date.CultureInfo.timezones; if (!name) { name = (new Date()).getTimezone();} for (i = 0; i < z.length; i++) { if (z[i].name === name.toUpperCase()) { a.push(i); } } if (!z[a[0]]) { return null; } if (a.length === 1 || !dst) { return z[a[0]].offset; } else { for (i=0; i < a.length; i++) { if (z[a[i]].dst) { return z[a[i]].offset; } } } }; $D.getQuarter = function (d) { d = d || new Date(); // If no date supplied, use today var q = [1,2,3,4]; return q[Math.floor(d.getMonth() / 3)]; // ~~~ is a bitwise op. Faster than Math.floor }; $D.getDaysLeftInQuarter = function (d) { d = d || new Date(); var qEnd = new Date(d); qEnd.setMonth(qEnd.getMonth() + 3 - qEnd.getMonth() % 3, 0); return Math.floor((qEnd - d) / 8.64e7); }; // private var validate = function (n, min, max, name) { name = name ? name : "Object"; if (typeof n === "undefined") { return false; } else if (typeof n !== "number") { throw new TypeError(n + " is not a Number."); } else if (n < min || n > max) { // As failing validation is *not* an exceptional circumstance // lets not throw a RangeError Exception here. // It's semantically correct but it's not sensible. return false; } return true; }; /** * Validates the number is within an acceptable range for milliseconds [0-999]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateMillisecond = function (value) { return validate(value, 0, 999, "millisecond"); }; /** * Validates the number is within an acceptable range for seconds [0-59]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateSecond = function (value) { return validate(value, 0, 59, "second"); }; /** * Validates the number is within an acceptable range for minutes [0-59]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateMinute = function (value) { return validate(value, 0, 59, "minute"); }; /** * Validates the number is within an acceptable range for hours [0-23]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateHour = function (value) { return validate(value, 0, 23, "hour"); }; /** * Validates the number is within an acceptable range for the days in a month [0-MaxDaysInMonth]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateDay = function (value, year, month) { if (year === undefined || year === null || month === undefined || month === null) { return false;} return validate(value, 1, $D.getDaysInMonth(year, month), "day"); }; /** * Validates the number is within an acceptable range for months [0-11]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateWeek = function (value) { return validate(value, 0, 53, "week"); }; /** * Validates the number is within an acceptable range for months [0-11]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateMonth = function (value) { return validate(value, 0, 11, "month"); }; /** * Validates the number is within an acceptable range for years. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateYear = function (value) { /** * Per ECMAScript spec the range of times supported by Date objects is * exactly -100,000,000 days to +100,000,000 days measured relative to * midnight at the beginning of 01 January, 1970 UTC. * This gives a range of 8,640,000,000,000,000 milliseconds to either * side of 01 January, 1970 UTC. * * Earliest possible date: Tue, 20 Apr 271,822 B.C. 00:00:00 UTC * Latest possible date: Sat, 13 Sep 275,760 00:00:00 UTC */ return validate(value, -271822, 275760, "year"); }; $D.validateTimezone = function(value) { var timezones = {"ACDT":1,"ACST":1,"ACT":1,"ADT":1,"AEDT":1,"AEST":1,"AFT":1,"AKDT":1,"AKST":1,"AMST":1,"AMT":1,"ART":1,"AST":1,"AWDT":1,"AWST":1,"AZOST":1,"AZT":1,"BDT":1,"BIOT":1,"BIT":1,"BOT":1,"BRT":1,"BST":1,"BTT":1,"CAT":1,"CCT":1,"CDT":1,"CEDT":1,"CEST":1,"CET":1,"CHADT":1,"CHAST":1,"CHOT":1,"ChST":1,"CHUT":1,"CIST":1,"CIT":1,"CKT":1,"CLST":1,"CLT":1,"COST":1,"COT":1,"CST":1,"CT":1,"CVT":1,"CWST":1,"CXT":1,"DAVT":1,"DDUT":1,"DFT":1,"EASST":1,"EAST":1,"EAT":1,"ECT":1,"EDT":1,"EEDT":1,"EEST":1,"EET":1,"EGST":1,"EGT":1,"EIT":1,"EST":1,"FET":1,"FJT":1,"FKST":1,"FKT":1,"FNT":1,"GALT":1,"GAMT":1,"GET":1,"GFT":1,"GILT":1,"GIT":1,"GMT":1,"GST":1,"GYT":1,"HADT":1,"HAEC":1,"HAST":1,"HKT":1,"HMT":1,"HOVT":1,"HST":1,"ICT":1,"IDT":1,"IOT":1,"IRDT":1,"IRKT":1,"IRST":1,"IST":1,"JST":1,"KGT":1,"KOST":1,"KRAT":1,"KST":1,"LHST":1,"LINT":1,"MAGT":1,"MART":1,"MAWT":1,"MDT":1,"MET":1,"MEST":1,"MHT":1,"MIST":1,"MIT":1,"MMT":1,"MSK":1,"MST":1,"MUT":1,"MVT":1,"MYT":1,"NCT":1,"NDT":1,"NFT":1,"NPT":1,"NST":1,"NT":1,"NUT":1,"NZDT":1,"NZST":1,"OMST":1,"ORAT":1,"PDT":1,"PET":1,"PETT":1,"PGT":1,"PHOT":1,"PHT":1,"PKT":1,"PMDT":1,"PMST":1,"PONT":1,"PST":1,"PYST":1,"PYT":1,"RET":1,"ROTT":1,"SAKT":1,"SAMT":1,"SAST":1,"SBT":1,"SCT":1,"SGT":1,"SLST":1,"SRT":1,"SST":1,"SYOT":1,"TAHT":1,"THA":1,"TFT":1,"TJT":1,"TKT":1,"TLT":1,"TMT":1,"TOT":1,"TVT":1,"UCT":1,"ULAT":1,"UTC":1,"UYST":1,"UYT":1,"UZT":1,"VET":1,"VLAT":1,"VOLT":1,"VOST":1,"VUT":1,"WAKT":1,"WAST":1,"WAT":1,"WEDT":1,"WEST":1,"WET":1,"WST":1,"YAKT":1,"YEKT":1,"Z":1}; return (timezones[value] === 1); }; $D.validateTimezoneOffset= function(value) { // timezones go from +14hrs to -12hrs, the +X hours are negative offsets. return (value > -841 && value < 721); }; }()); (function () { var $D = Date, $P = $D.prototype, p = function (s, l) { if (!l) { l = 2; } return ("000" + s).slice(l * -1); }; var validateConfigObject = function (obj) { var result = {}, self = this, prop, testFunc; testFunc = function (prop, func, value) { if (prop === "day") { var month = (obj.month !== undefined) ? obj.month : self.getMonth(); var year = (obj.year !== undefined) ? obj.year : self.getFullYear(); return $D[func](value, year, month); } else { return $D[func](value); } }; for (prop in obj) { if (Object.prototype.hasOwnProperty.call(obj, prop)) { var func = "validate" + prop.charAt(0).toUpperCase() + prop.slice(1); if ($D[func] && obj[prop] !== null && testFunc(prop, func, obj[prop])) { result[prop] = obj[prop]; } } } return result; }; /** * Resets the time of this Date object to 12:00 AM (00:00), which is the start of the day. * @param {Boolean} .clone() this date instance before clearing Time * @return {Date} this */ $P.clearTime = function () { this.setHours(0); this.setMinutes(0); this.setSeconds(0); this.setMilliseconds(0); return this; }; /** * Resets the time of this Date object to the current time ('now'). * @return {Date} this */ $P.setTimeToNow = function () { var n = new Date(); this.setHours(n.getHours()); this.setMinutes(n.getMinutes()); this.setSeconds(n.getSeconds()); this.setMilliseconds(n.getMilliseconds()); return this; }; /** * Returns a new Date object that is an exact date and time copy of the original instance. * @return {Date} A new Date instance */ $P.clone = function () { return new Date(this.getTime()); }; /** * Compares this instance to a Date object and returns an number indication of their relative values. * @param {Date} Date object to compare [Required] * @return {Number} -1 = this is lessthan date. 0 = values are equal. 1 = this is greaterthan date. */ $P.compareTo = function (date) { return Date.compare(this, date); }; /** * Compares this instance to another Date object and returns true if they are equal. * @param {Date} Date object to compare. If no date to compare, new Date() [now] is used. * @return {Boolean} true if dates are equal. false if they are not equal. */ $P.equals = function (date) { return Date.equals(this, (date !== undefined ? date : new Date())); }; /** * Determines if this instance is between a range of two dates or equal to either the start or end dates. * @param {Date} Start of range [Required] * @param {Date} End of range [Required] * @return {Boolean} true is this is between or equal to the start and end dates, else false */ $P.between = function (start, end) { return this.getTime() >= start.getTime() && this.getTime() <= end.getTime(); }; /** * Determines if this date occurs after the date to compare to. * @param {Date} Date object to compare. If no date to compare, new Date() ("now") is used. * @return {Boolean} true if this date instance is greater than the date to compare to (or "now"), otherwise false. */ $P.isAfter = function (date) { return this.compareTo(date || new Date()) === 1; }; /** * Determines if this date occurs before the date to compare to. * @param {Date} Date object to compare. If no date to compare, new Date() ("now") is used. * @return {Boolean} true if this date instance is less than the date to compare to (or "now"). */ $P.isBefore = function (date) { return (this.compareTo(date || new Date()) === -1); }; /** * Determines if the current Date instance occurs today. * @return {Boolean} true if this date instance is 'today', otherwise false. */ /** * Determines if the current Date instance occurs on the same Date as the supplied 'date'. * If no 'date' to compare to is provided, the current Date instance is compared to 'today'. * @param {date} Date object to compare. If no date to compare, the current Date ("now") is used. * @return {Boolean} true if this Date instance occurs on the same Day as the supplied 'date'. */ $P.isToday = $P.isSameDay = function (date) { return this.clone().clearTime().equals((date || new Date()).clone().clearTime()); }; /** * Adds the specified number of milliseconds to this instance. * @param {Number} The number of milliseconds to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addMilliseconds = function (value) { if (!value) { return this; } this.setTime(this.getTime() + value * 1); return this; }; /** * Adds the specified number of seconds to this instance. * @param {Number} The number of seconds to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addSeconds = function (value) { if (!value) { return this; } return this.addMilliseconds(value * 1000); }; /** * Adds the specified number of seconds to this instance. * @param {Number} The number of seconds to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addMinutes = function (value) { if (!value) { return this; } return this.addMilliseconds(value * 60000); // 60*1000 }; /** * Adds the specified number of hours to this instance. * @param {Number} The number of hours to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addHours = function (value) { if (!value) { return this; } return this.addMilliseconds(value * 3600000); // 60*60*1000 }; /** * Adds the specified number of days to this instance. * @param {Number} The number of days to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addDays = function (value) { if (!value) { return this; } this.setDate(this.getDate() + value * 1); return this; }; /** * Adds the specified number of weekdays (ie - not sat or sun) to this instance. * @param {Number} The number of days to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addWeekdays = function (value) { if (!value) { return this; } var day = this.getDay(); var weeks = (Math.ceil(Math.abs(value)/7)); if (day === 0 || day === 6) { if (value > 0) { this.next().monday(); this.addDays(-1); day = this.getDay(); } } if (value < 0) { while (value < 0) { this.addDays(-1); day = this.getDay(); if (day !== 0 && day !== 6) { value++; } } return this; } else if (value > 5 || (6-day) <= value) { value = value + (weeks * 2); } return this.addDays(value); }; /** * Adds the specified number of weeks to this instance. * @param {Number} The number of weeks to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addWeeks = function (value) { if (!value) { return this; } return this.addDays(value * 7); }; /** * Adds the specified number of months to this instance. * @param {Number} The number of months to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addMonths = function (value) { if (!value) { return this; } var n = this.getDate(); this.setDate(1); this.setMonth(this.getMonth() + value * 1); this.setDate(Math.min(n, $D.getDaysInMonth(this.getFullYear(), this.getMonth()))); return this; }; $P.addQuarters = function (value) { if (!value) { return this; } // note this will take you to the same point in the quarter as you are now. // i.e. - if you are 15 days into the quarter you'll be 15 days into the resulting one. // bonus: this allows adding fractional quarters return this.addMonths(value * 3); }; /** * Adds the specified number of years to this instance. * @param {Number} The number of years to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addYears = function (value) { if (!value) { return this; } return this.addMonths(value * 12); }; /** * Adds (or subtracts) to the value of the years, months, weeks, days, hours, minutes, seconds, milliseconds of the date instance using given configuration object. Positive and Negative values allowed. * Example

	Date.today().add( { days: 1, months: 1 } )

	new Date().add( { years: -1 } )
	
* @param {Object} Configuration object containing attributes (months, days, etc.) * @return {Date} this */ $P.add = function (config) { if (typeof config === "number") { this._orient = config; return this; } var x = config; if (x.day) { // If we should be a different date than today (eg: for 'tomorrow -1d', etc). // Should only effect parsing, not direct usage (eg, Finish and FinishExact) if ((x.day - this.getDate()) !== 0) { this.setDate(x.day); } } if (x.milliseconds) { this.addMilliseconds(x.milliseconds); } if (x.seconds) { this.addSeconds(x.seconds); } if (x.minutes) { this.addMinutes(x.minutes); } if (x.hours) { this.addHours(x.hours); } if (x.weeks) { this.addWeeks(x.weeks); } if (x.months) { this.addMonths(x.months); } if (x.years) { this.addYears(x.years); } if (x.days) { this.addDays(x.days); } return this; }; /** * Get the week number. Week one (1) is the week which contains the first Thursday of the year. Monday is considered the first day of the week. * The .getWeek() function does NOT convert the date to UTC. The local datetime is used. * Please use .getISOWeek() to get the week of the UTC converted date. * @return {Number} 1 to 53 */ $P.getWeek = function (utc) { // Create a copy of this date object var self, target = new Date(this.valueOf()); if (utc) { target.addMinutes(target.getTimezoneOffset()); self = target.clone(); } else { self = this; } // ISO week date weeks start on monday // so correct the day number var dayNr = (self.getDay() + 6) % 7; // ISO 8601 states that week 1 is the week // with the first thursday of that year. // Set the target date to the thursday in the target week target.setDate(target.getDate() - dayNr + 3); // Store the millisecond value of the target date var firstThursday = target.valueOf(); // Set the target to the first thursday of the year // First set the target to january first target.setMonth(0, 1); // Not a thursday? Correct the date to the next thursday if (target.getDay() !== 4) { target.setMonth(0, 1 + ((4 - target.getDay()) + 7) % 7); } // The weeknumber is the number of weeks between the // first thursday of the year and the thursday in the target week return 1 + Math.ceil((firstThursday - target) / 604800000); // 604800000 = 7 * 24 * 3600 * 1000 }; /** * Get the ISO 8601 week number. Week one ("01") is the week which contains the first Thursday of the year. Monday is considered the first day of the week. * The .getISOWeek() function does convert the date to it's UTC value. Please use .getWeek() to get the week of the local date. * @return {String} "01" to "53" */ $P.getISOWeek = function () { return p(this.getWeek(true)); }; /** * Moves the date to Monday of the week set. Week one (1) is the week which contains the first Thursday of the year. * @param {Number} A Number (1 to 53) that represents the week of the year. * @return {Date} this */ $P.setWeek = function (n) { if ((n - this.getWeek()) === 0) { if (this.getDay() !== 1) { return this.moveToDayOfWeek(1, (this.getDay() > 1 ? -1 : 1)); } else { return this; } } else { return this.moveToDayOfWeek(1, (this.getDay() > 1 ? -1 : 1)).addWeeks(n - this.getWeek()); } }; $P.setQuarter = function (qtr) { var month = Math.abs(((qtr-1) * 3) + 1); return this.setMonth(month, 1); }; $P.getQuarter = function () { return Date.getQuarter(this); }; $P.getDaysLeftInQuarter = function () { return Date.getDaysLeftInQuarter(this); }; /** * Moves the date to the next n'th occurrence of the dayOfWeek starting from the beginning of the month. The number (-1) is a magic number and will return the last occurrence of the dayOfWeek in the month. * @param {Number} The dayOfWeek to move to * @param {Number} The n'th occurrence to move to. Use (-1) to return the last occurrence in the month * @return {Date} this */ $P.moveToNthOccurrence = function (dayOfWeek, occurrence) { if (dayOfWeek === "Weekday") { if (occurrence > 0) { this.moveToFirstDayOfMonth(); if (this.is().weekday()) { occurrence -= 1; } } else if (occurrence < 0) { this.moveToLastDayOfMonth(); if (this.is().weekday()) { occurrence += 1; } } else { return this; } return this.addWeekdays(occurrence); } var shift = 0; if (occurrence > 0) { shift = occurrence - 1; } else if (occurrence === -1) { this.moveToLastDayOfMonth(); if (this.getDay() !== dayOfWeek) { this.moveToDayOfWeek(dayOfWeek, -1); } return this; } return this.moveToFirstDayOfMonth().addDays(-1).moveToDayOfWeek(dayOfWeek, +1).addWeeks(shift); }; var moveToN = function (getFunc, addFunc, nVal) { return function (value, orient) { var diff = (value - this[getFunc]() + nVal * (orient || +1)) % nVal; return this[addFunc]((diff === 0) ? diff += nVal * (orient || +1) : diff); }; }; /** * Move to the next or last dayOfWeek based on the orient value. * @param {Number} The dayOfWeek to move to * @param {Number} Forward (+1) or Back (-1). Defaults to +1. [Optional] * @return {Date} this */ $P.moveToDayOfWeek = moveToN("getDay", "addDays", 7); /** * Move to the next or last month based on the orient value. * @param {Number} The month to move to. 0 = January, 11 = December * @param {Number} Forward (+1) or Back (-1). Defaults to +1. [Optional] * @return {Date} this */ $P.moveToMonth = moveToN("getMonth", "addMonths", 12); /** * Get the Ordinate of the current day ("th", "st", "rd"). * @return {String} */ $P.getOrdinate = function () { var num = this.getDate(); return ord(num); }; /** * Get the Ordinal day (numeric day number) of the year, adjusted for leap year. * @return {Number} 1 through 365 (366 in leap years) */ $P.getOrdinalNumber = function () { return Math.ceil((this.clone().clearTime() - new Date(this.getFullYear(), 0, 1)) / 86400000) + 1; }; /** * Get the time zone abbreviation of the current date. * @return {String} The abbreviated time zone name (e.g. "EST") */ $P.getTimezone = function () { return $D.getTimezoneAbbreviation(this.getUTCOffset(), this.isDaylightSavingTime()); }; $P.setTimezoneOffset = function (offset) { var here = this.getTimezoneOffset(), there = Number(offset) * -6 / 10; return (there || there === 0) ? this.addMinutes(there - here) : this; }; $P.setTimezone = function (offset) { return this.setTimezoneOffset($D.getTimezoneOffset(offset)); }; /** * Indicates whether Daylight Saving Time is observed in the current time zone. * @return {Boolean} true|false */ $P.hasDaylightSavingTime = function () { return (Date.today().set({month: 0, day: 1}).getTimezoneOffset() !== Date.today().set({month: 6, day: 1}).getTimezoneOffset()); }; /** * Indicates whether this Date instance is within the Daylight Saving Time range for the current time zone. * @return {Boolean} true|false */ $P.isDaylightSavingTime = function () { return Date.today().set({month: 0, day: 1}).getTimezoneOffset() !== this.getTimezoneOffset(); }; /** * Get the offset from UTC of the current date. * @return {String} The 4-character offset string prefixed with + or - (e.g. "-0500") */ $P.getUTCOffset = function (offset) { var n = (offset || this.getTimezoneOffset()) * -10 / 6, r; if (n < 0) { r = (n - 10000).toString(); return r.charAt(0) + r.substr(2); } else { r = (n + 10000).toString(); return "+" + r.substr(1); } }; /** * Returns the number of milliseconds between this date and date. * @param {Date} Defaults to now * @return {Number} The diff in milliseconds */ $P.getElapsed = function (date) { return (date || new Date()) - this; }; /** * Set the value of year, month, day, hour, minute, second, millisecond of date instance using given configuration object. * Example

	Date.today().set( { day: 20, month: 1 } )

	new Date().set( { millisecond: 0 } )
	
* * @param {Object} Configuration object containing attributes (month, day, etc.) * @return {Date} this */ $P.set = function (config) { config = validateConfigObject.call(this, config); var key; for (key in config) { if (Object.prototype.hasOwnProperty.call(config, key)) { var name = key.charAt(0).toUpperCase() + key.slice(1); var addFunc, getFunc; if (key !== "week" && key !== "month" && key !== "timezone" && key !== "timezoneOffset") { name += "s"; } addFunc = "add" + name; getFunc = "get" + name; if (key === "month") { addFunc = addFunc + "s"; } else if (key === "year"){ getFunc = "getFullYear"; } if (key !== "day" && key !== "timezone" && key !== "timezoneOffset" && key !== "week" && key !== "hour") { this[addFunc](config[key] - this[getFunc]()); } else if ( key === "timezone"|| key === "timezoneOffset" || key === "week" || key === "hour") { this["set"+name](config[key]); } } } // day has to go last because you can't validate the day without first knowing the month if (config.day) { this.addDays(config.day - this.getDate()); } return this; }; /** * Moves the date to the first day of the month. * @return {Date} this */ $P.moveToFirstDayOfMonth = function () { return this.set({ day: 1 }); }; /** * Moves the date to the last day of the month. * @return {Date} this */ $P.moveToLastDayOfMonth = function () { return this.set({ day: $D.getDaysInMonth(this.getFullYear(), this.getMonth())}); }; /** * Converts the value of the current Date object to its equivalent string representation. * Format Specifiers * CUSTOM DATE AND TIME FORMAT STRINGS * Format Description Example * ------ --------------------------------------------------------------------------- ----------------------- * s The seconds of the minute between 0-59. "0" to "59" * ss The seconds of the minute with leading zero if required. "00" to "59" * * m The minute of the hour between 0-59. "0" or "59" * mm The minute of the hour with leading zero if required. "00" or "59" * * h The hour of the day between 1-12. "1" to "12" * hh The hour of the day with leading zero if required. "01" to "12" * * H The hour of the day between 0-23. "0" to "23" * HH The hour of the day with leading zero if required. "00" to "23" * * d The day of the month between 1 and 31. "1" to "31" * dd The day of the month with leading zero if required. "01" to "31" * ddd Abbreviated day name. Date.CultureInfo.abbreviatedDayNames. "Mon" to "Sun" * dddd The full day name. Date.CultureInfo.dayNames. "Monday" to "Sunday" * * M The month of the year between 1-12. "1" to "12" * MM The month of the year with leading zero if required. "01" to "12" * MMM Abbreviated month name. Date.CultureInfo.abbreviatedMonthNames. "Jan" to "Dec" * MMMM The full month name. Date.CultureInfo.monthNames. "January" to "December" * * yy The year as a two-digit number. "99" or "08" * yyyy The full four digit year. "1999" or "2008" * * t Displays the first character of the A.M./P.M. designator. "A" or "P" * Date.CultureInfo.amDesignator or Date.CultureInfo.pmDesignator * tt Displays the A.M./P.M. designator. "AM" or "PM" * Date.CultureInfo.amDesignator or Date.CultureInfo.pmDesignator * * S The ordinal suffix ("st, "nd", "rd" or "th") of the current day. "st, "nd", "rd" or "th" * * STANDARD DATE AND TIME FORMAT STRINGS * Format Description Example *------ --------------------------------------------------------------------------- ----------------------- * d The CultureInfo shortDate Format Pattern "M/d/yyyy" * D The CultureInfo longDate Format Pattern "dddd, MMMM dd, yyyy" * F The CultureInfo fullDateTime Format Pattern "dddd, MMMM dd, yyyy h:mm:ss tt" * m The CultureInfo monthDay Format Pattern "MMMM dd" * r The CultureInfo rfc1123 Format Pattern "ddd, dd MMM yyyy HH:mm:ss GMT" * s The CultureInfo sortableDateTime Format Pattern "yyyy-MM-ddTHH:mm:ss" * t The CultureInfo shortTime Format Pattern "h:mm tt" * T The CultureInfo longTime Format Pattern "h:mm:ss tt" * u The CultureInfo universalSortableDateTime Format Pattern "yyyy-MM-dd HH:mm:ssZ" * y The CultureInfo yearMonth Format Pattern "MMMM, yyyy" * * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @return {String} A string representation of the current Date object. */ var ord = function (n) { switch (n * 1) { case 1: case 21: case 31: return "st"; case 2: case 22: return "nd"; case 3: case 23: return "rd"; default: return "th"; } }; var parseStandardFormats = function (format) { var y, c = Date.CultureInfo.formatPatterns; switch (format) { case "d": return this.toString(c.shortDate); case "D": return this.toString(c.longDate); case "F": return this.toString(c.fullDateTime); case "m": return this.toString(c.monthDay); case "r": case "R": y = this.clone().addMinutes(this.getTimezoneOffset()); return y.toString(c.rfc1123) + " GMT"; case "s": return this.toString(c.sortableDateTime); case "t": return this.toString(c.shortTime); case "T": return this.toString(c.longTime); case "u": y = this.clone().addMinutes(this.getTimezoneOffset()); return y.toString(c.universalSortableDateTime); case "y": return this.toString(c.yearMonth); default: return false; } }; var parseFormatStringsClosure = function (context) { return function (m) { if (m.charAt(0) === "\\") { return m.replace("\\", ""); } switch (m) { case "hh": return p(context.getHours() < 13 ? (context.getHours() === 0 ? 12 : context.getHours()) : (context.getHours() - 12)); case "h": return context.getHours() < 13 ? (context.getHours() === 0 ? 12 : context.getHours()) : (context.getHours() - 12); case "HH": return p(context.getHours()); case "H": return context.getHours(); case "mm": return p(context.getMinutes()); case "m": return context.getMinutes(); case "ss": return p(context.getSeconds()); case "s": return context.getSeconds(); case "yyyy": return p(context.getFullYear(), 4); case "yy": return p(context.getFullYear()); case "y": return context.getFullYear(); case "E": case "dddd": return Date.CultureInfo.dayNames[context.getDay()]; case "ddd": return Date.CultureInfo.abbreviatedDayNames[context.getDay()]; case "dd": return p(context.getDate()); case "d": return context.getDate(); case "MMMM": return Date.CultureInfo.monthNames[context.getMonth()]; case "MMM": return Date.CultureInfo.abbreviatedMonthNames[context.getMonth()]; case "MM": return p((context.getMonth() + 1)); case "M": return context.getMonth() + 1; case "t": return context.getHours() < 12 ? Date.CultureInfo.amDesignator.substring(0, 1) : Date.CultureInfo.pmDesignator.substring(0, 1); case "tt": return context.getHours() < 12 ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator; case "S": return ord(context.getDate()); case "W": return context.getWeek(); case "WW": return context.getISOWeek(); case "Q": return "Q" + context.getQuarter(); case "q": return String(context.getQuarter()); case "z": return context.getTimezone(); case "Z": case "X": return Date.getTimezoneOffset(context.getTimezone()); case "ZZ": // Timezone offset in seconds return context.getTimezoneOffset() * -60; case "u": return context.getDay(); case "L": return ($D.isLeapYear(context.getFullYear())) ? 1 : 0; case "B": // Swatch Internet Time (.beats) return "@"+((context.getUTCSeconds() + (context.getUTCMinutes()*60) + ((context.getUTCHours()+1)*3600))/86.4); default: return m; } }; }; $P.toString = function (format, ignoreStandards) { // Standard Date and Time Format Strings. Formats pulled from CultureInfo file and // may vary by culture. if (!ignoreStandards && format && format.length === 1) { output = parseStandardFormats.call(this, format); if (output) { return output; } } var parseFormatStrings = parseFormatStringsClosure(this); return format ? format.replace(/((\\)?(dd?d?d?|MM?M?M?|yy?y?y?|hh?|HH?|mm?|ss?|tt?|S|q|Q|WW?W?W?)(?![^\[]*\]))/g, parseFormatStrings).replace(/\[|\]/g, "") : this._toString(); }; }()); /************************************************************* * SugarPak - Domain Specific Language - Syntactical Sugar * *************************************************************/ (function () { var $D = Date, $P = $D.prototype, $N = Number.prototype; // private $P._orient = +1; // private $P._nth = null; // private $P._is = false; // private $P._same = false; // private $P._isSecond = false; // private $N._dateElement = "days"; /** * Moves the date to the next instance of a date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.today().next().friday();
	Date.today().next().fri();
	Date.today().next().march();
	Date.today().next().mar();
	Date.today().next().week();
	
* * @return {Date} date */ $P.next = function () { this._move = true; this._orient = +1; return this; }; /** * Creates a new Date (Date.today()) and moves the date to the next instance of the date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.next().friday();
	Date.next().fri();
	Date.next().march();
	Date.next().mar();
	Date.next().week();
	
* * @return {Date} date */ $D.next = function () { return $D.today().next(); }; /** * Moves the date to the previous instance of a date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.today().last().friday();
	Date.today().last().fri();
	Date.today().last().march();
	Date.today().last().mar();
	Date.today().last().week();
	
* * @return {Date} date */ $P.last = $P.prev = $P.previous = function () { this._move = true; this._orient = -1; return this; }; /** * Creates a new Date (Date.today()) and moves the date to the previous instance of the date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.last().friday();
	Date.last().fri();
	Date.previous().march();
	Date.prev().mar();
	Date.last().week();
	
* * @return {Date} date */ $D.last = $D.prev = $D.previous = function () { return $D.today().last(); }; /** * Performs a equality check when followed by either a month name, day name or .weekday() function. * Example

	Date.today().is().friday(); // true|false
	Date.today().is().fri();
	Date.today().is().march();
	Date.today().is().mar();
	
* * @return {Boolean} true|false */ $P.is = function () { this._is = true; return this; }; /** * Determines if two date objects occur on/in exactly the same instance of the subsequent date part function. * The function .same() must be followed by a date part function (example: .day(), .month(), .year(), etc). * * An optional Date can be passed in the date part function. If now date is passed as a parameter, 'Now' is used. * * The following example demonstrates how to determine if two dates fall on the exact same day. * * Example

	var d1 = Date.today(); // today at 00:00
	var d2 = new Date();   // exactly now.

	// Do they occur on the same day?
	d1.same().day(d2); // true
	
	// Do they occur on the same hour?
	d1.same().hour(d2); // false, unless d2 hour is '00' (midnight).
	
	// What if it's the same day, but one year apart?
	var nextYear = Date.today().add(1).year();

	d1.same().day(nextYear); // false, because the dates must occur on the exact same day. 
	
* * Scenario: Determine if a given date occurs during some week period 2 months from now. * * Example

	var future = Date.today().add(2).months();
	return someDate.same().week(future); // true|false;
	
* * @return {Boolean} true|false */ $P.same = function () { this._same = true; this._isSecond = false; return this; }; /** * Determines if the current date/time occurs during Today. Must be preceded by the .is() function. * Example

	someDate.is().today();    // true|false
	new Date().is().today();  // true
	Date.today().is().today();// true
	Date.today().add(-1).day().is().today(); // false
	
* * @return {Boolean} true|false */ $P.today = function () { return this.same().day(); }; /** * Determines if the current date is a weekday. This function must be preceded by the .is() function. * Example

	Date.today().is().weekday(); // true|false
	
* * @return {Boolean} true|false */ $P.weekday = function () { if (this._nth) { return df("Weekday").call(this); } if (this._move) { return this.addWeekdays(this._orient); } if (this._is) { this._is = false; return (!this.is().sat() && !this.is().sun()); } return false; }; /** * Determines if the current date is on the weekend. This function must be preceded by the .is() function. * Example

	Date.today().is().weekend(); // true|false
	
* * @return {Boolean} true|false */ $P.weekend = function () { if (this._is) { this._is = false; return (this.is().sat() || this.is().sun()); } return false; }; /** * Sets the Time of the current Date instance. A string "6:15 pm" or config object {hour:18, minute:15} are accepted. * Example

	// Set time to 6:15pm with a String
	Date.today().at("6:15pm");

	// Set time to 6:15pm with a config object
	Date.today().at({hour:18, minute:15});
	
* * @return {Date} date */ $P.at = function (time) { return (typeof time === "string") ? $D.parse(this.toString("d") + " " + time) : this.set(time); }; /** * Creates a new Date() and adds this (Number) to the date based on the preceding date element function (eg. second|minute|hour|day|month|year). * Example

	// Undeclared Numbers must be wrapped with parentheses. Requirment of JavaScript.
	(3).days().fromNow();
	(6).months().fromNow();

	// Declared Number variables do not require parentheses. 
	var n = 6;
	n.months().fromNow();
	
* * @return {Date} A new Date instance */ $N.fromNow = $N.after = function (date) { var c = {}; c[this._dateElement] = this; return ((!date) ? new Date() : date.clone()).add(c); }; /** * Creates a new Date() and subtract this (Number) from the date based on the preceding date element function (eg. second|minute|hour|day|month|year). * Example

	// Undeclared Numbers must be wrapped with parentheses. Requirment of JavaScript.
	(3).days().ago();
	(6).months().ago();

	// Declared Number variables do not require parentheses. 
	var n = 6;
	n.months().ago();
	
* * @return {Date} A new Date instance */ $N.ago = $N.before = function (date) { var c = {}, s = (this._dateElement[this._dateElement.length-1] !== "s") ? this._dateElement + "s" : this._dateElement; c[s] = this * -1; return ((!date) ? new Date() : date.clone()).add(c); }; // Do NOT modify the following string tokens. These tokens are used to build dynamic functions. // All culture-specific strings can be found in the CultureInfo files. var dx = ("sunday monday tuesday wednesday thursday friday saturday").split(/\s/), mx = ("january february march april may june july august september october november december").split(/\s/), px = ("Millisecond Second Minute Hour Day Week Month Year Quarter Weekday").split(/\s/), pxf = ("Milliseconds Seconds Minutes Hours Date Week Month FullYear Quarter").split(/\s/), nth = ("final first second third fourth fifth").split(/\s/), de; /** * Returns an object literal of all the date parts. * Example

	var o = new Date().toObject();
	
	// { year: 2008, month: 4, week: 20, day: 13, hour: 18, minute: 9, second: 32, millisecond: 812 }
	
	// The object properties can be referenced directly from the object.
	
	alert(o.day);  // alerts "13"
	alert(o.year); // alerts "2008"
	
* * @return {Date} An object literal representing the original date object. */ $P.toObject = function () { var o = {}; for (var i = 0; i < px.length; i++) { if (this["get" + pxf[i]]) { o[px[i].toLowerCase()] = this["get" + pxf[i]](); } } return o; }; /** * Returns a date created from an object literal. Ignores the .week property if set in the config. * Example

	var o = new Date().toObject();
	
	return Date.fromObject(o); // will return the same date. 

	var o2 = {month: 1, day: 20, hour: 18}; // birthday party!
	Date.fromObject(o2);
	
* * @return {Date} An object literal representing the original date object. */ $D.fromObject = function(config) { config.week = null; return Date.today().set(config); }; // Create day name functions and abbreviated day name functions (eg. monday(), friday(), fri()). var df = function (n) { return function () { if (this._is) { this._is = false; return this.getDay() === n; } if (this._move) { this._move = null; } if (this._nth !== null) { // If the .second() function was called earlier, remove the _orient // from the date, and then continue. // This is required because 'second' can be used in two different context. // // Example // // Date.today().add(1).second(); // Date.march().second().monday(); // // Things get crazy with the following... // Date.march().add(1).second().second().monday(); // but it works!! // if (this._isSecond) { this.addSeconds(this._orient * -1); } // make sure we reset _isSecond this._isSecond = false; var ntemp = this._nth; this._nth = null; var temp = this.clone().moveToLastDayOfMonth(); this.moveToNthOccurrence(n, ntemp); if (this > temp) { throw new RangeError($D.getDayName(n) + " does not occur " + ntemp + " times in the month of " + $D.getMonthName(temp.getMonth()) + " " + temp.getFullYear() + "."); } return this; } return this.moveToDayOfWeek(n, this._orient); }; }; var sdf = function (n) { return function () { var t = $D.today(), shift = n - t.getDay(); if (n === 0 && Date.CultureInfo.firstDayOfWeek === 1 && t.getDay() !== 0) { shift = shift + 7; } return t.addDays(shift); }; }; // Create month name functions and abbreviated month name functions (eg. january(), march(), mar()). var month_instance_functions = function (n) { return function () { if (this._is) { this._is = false; return this.getMonth() === n; } return this.moveToMonth(n, this._orient); }; }; var month_static_functions = function (n) { return function () { return $D.today().set({ month: n, day: 1 }); }; }; var processTerms = function (names, staticFunc, instanceFunc) { for (var i = 0; i < names.length; i++) { // Create constant static Name variables. $D[names[i].toUpperCase()] = $D[names[i].toUpperCase().substring(0, 3)] = i; // Create Name functions. $D[names[i]] = $D[names[i].substring(0, 3)] = staticFunc(i); // Create Name instance functions. $P[names[i]] = $P[names[i].substring(0, 3)] = instanceFunc(i); } }; processTerms(dx, sdf, df); processTerms(mx, month_static_functions, month_instance_functions); // Create date element functions and plural date element functions used with Date (eg. day(), days(), months()). var ef = function (j) { return function () { // if the .second() function was called earlier, the _orient // has alread been added. Just return this and reset _isSecond. if (this._isSecond) { this._isSecond = false; return this; } if (this._same) { this._same = this._is = false; var o1 = this.toObject(), o2 = (arguments[0] || new Date()).toObject(), v = "", k = j.toLowerCase(); // the substr trick with -1 doesn't work in IE8 or less k = (k[k.length-1] === "s") ? k.substring(0,k.length-1) : k; for (var m = (px.length - 1); m > -1; m--) { v = px[m].toLowerCase(); if (o1[v] !== o2[v]) { return false; } if (k === v) { break; } } return true; } if (j.substring(j.length - 1) !== "s") { j += "s"; } if (this._move) { this._move = null; } return this["add" + j](this._orient); }; }; var nf = function (n) { return function () { this._dateElement = n; return this; }; }; for (var k = 0; k < px.length; k++) { de = px[k].toLowerCase(); if(de !== "weekday") { // Create date element functions and plural date element functions used with Date (eg. day(), days(), months()). $P[de] = $P[de + "s"] = ef(px[k]); // Create date element functions and plural date element functions used with Number (eg. day(), days(), months()). $N[de] = $N[de + "s"] = nf(de + "s"); } } $P._ss = ef("Second"); var nthfn = function (n) { return function (dayOfWeek) { if (this._same) { return this._ss(arguments[0]); } if (dayOfWeek || dayOfWeek === 0) { return this.moveToNthOccurrence(dayOfWeek, n); } this._nth = n; // if the operator is 'second' add the _orient, then deal with it later... if (n === 2 && (dayOfWeek === undefined || dayOfWeek === null)) { this._isSecond = true; return this.addSeconds(this._orient); } return this; }; }; for (var l = 0; l < nth.length; l++) { $P[nth[l]] = (l === 0) ? nthfn(-1) : nthfn(l); } }()); (function () { "use strict"; Date.Parsing = { Exception: function (s) { this.message = "Parse error at '" + s.substring(0, 10) + " ...'"; } }; var $P = Date.Parsing; var dayOffsets = { standard: [0,31,59,90,120,151,181,212,243,273,304,334], leap: [0,31,60,91,121,152,182,213,244,274,305,335] }; $P.isLeapYear = function(year) { return ((year % 4 === 0) && (year % 100 !== 0)) || (year % 400 === 0); }; var utils = { multiReplace : function (str, hash ) { var key; for (key in hash) { if (Object.prototype.hasOwnProperty.call(hash, key)) { var regex; if (typeof hash[key] === "function") { } else { regex = (hash[key] instanceof RegExp) ? hash[key] : new RegExp(hash[key], "g"); } str = str.replace(regex, key); } } return str; }, getDayOfYearFromWeek : function (obj) { var d, jan4, offset; obj.weekDay = (!obj.weekDay && obj.weekDay !== 0) ? 1 : obj.weekDay; d = new Date(obj.year, 0, 4); jan4 = d.getDay() === 0 ? 7 : d.getDay(); // JS is 0 indexed on Sunday. offset = jan4+3; obj.dayOfYear = ((obj.week * 7) + (obj.weekDay === 0 ? 7 : obj.weekDay))-offset; return obj; }, getDayOfYear : function (obj, dayOffset) { if (!obj.dayOfYear) { obj = utils.getDayOfYearFromWeek(obj); } for (var i=0;i <= dayOffset.length;i++) { if (obj.dayOfYear < dayOffset[i] || i === dayOffset.length) { obj.day = obj.day ? obj.day : (obj.dayOfYear - dayOffset[i-1]); break; } else { obj.month = i; } } return obj; }, adjustForTimeZone : function (obj, date) { var offset; if (obj.zone.toUpperCase() === "Z" || (obj.zone_hours === 0 && obj.zone_minutes === 0)) { // it's UTC/GML so work out the current timeszone offset offset = -date.getTimezoneOffset(); } else { offset = (obj.zone_hours*60) + (obj.zone_minutes || 0); if (obj.zone_sign === "+") { offset *= -1; } offset -= date.getTimezoneOffset(); } date.setMinutes(date.getMinutes()+offset); return date; }, setDefaults : function (obj) { obj.year = obj.year || Date.today().getFullYear(); obj.hours = obj.hours || 0; obj.minutes = obj.minutes || 0; obj.seconds = obj.seconds || 0; obj.milliseconds = obj.milliseconds || 0; if (!(!obj.month && (obj.week || obj.dayOfYear))) { // if we have a month, or if we don't but don't have the day calculation data obj.month = obj.month || 0; obj.day = obj.day || 1; } return obj; }, dataNum: function (data, mod, explict, postProcess) { var dataNum = data*1; if (mod) { if (postProcess) { return data ? mod(data)*1 : data; } else { return data ? mod(dataNum) : data; } } else if (!explict){ return data ? dataNum : data; } else { return (data && typeof data !== "undefined") ? dataNum : data; } }, timeDataProcess: function (obj) { var timeObj = {}; for (var x in obj.data) { if (obj.data.hasOwnProperty(x)) { timeObj[x] = obj.ignore[x] ? obj.data[x] : utils.dataNum(obj.data[x], obj.mods[x], obj.explict[x], obj.postProcess[x]); } } if (obj.data.secmins) { obj.data.secmins = obj.data.secmins.replace(",", ".") * 60; if (!timeObj.minutes) { timeObj.minutes = obj.data.secmins; } else if (!timeObj.seconds) { timeObj.seconds = obj.data.secmins; } delete obj.secmins; } return timeObj; }, buildTimeObjectFromData: function (data) { var time = utils.timeDataProcess({ data: { year : data[1], month : data[5], day : data[7], week : data[8], dayOfYear : data[10], hours : data[15], zone_hours : data[23], zone_minutes : data[24], zone : data[21], zone_sign : data[22], weekDay : data[9], minutes: data[16], seconds: data[19], milliseconds: data[20], secmins: data[18] }, mods: { month: function(data) { return data-1; }, weekDay: function (data) { data = Math.abs(data); return (data === 7 ? 0 : data); }, minutes: function (data) { return data.replace(":",""); }, seconds: function (data) { return Math.floor( (data.replace(":","").replace(",","."))*1 ); }, milliseconds: function (data) { return (data.replace(",",".")*1000); } }, postProcess: { minutes: true, seconds: true, milliseconds: true }, explict: { zone_hours: true, zone_minutes: true }, ignore: { zone: true, zone_sign: true, secmins: true } }); return time; }, addToHash: function (hash, keys, data) { keys = keys; data = data; var len = keys.length; for (var i = 0; i < len; i++) { hash[keys[i]] = data[i]; } return hash; }, combineRegex: function (r1, r2) { return new RegExp("(("+r1.source+")\\s("+r2.source+"))"); }, getDateNthString: function(add, last, inc){ if (add) { return Date.today().addDays(inc).toString("d"); } else if (last) { return Date.today().last()[inc]().toString("d"); } }, buildRegexData: function (array) { var arr = []; var len = array.length; for (var i=0; i < len; i++) { if (Object.prototype.toString.call(array[i]) === '[object Array]') { // oldIE compat version of Array.isArray arr.push(this.combineRegex(array[i][0], array[i][1])); } else { arr.push(array[i]); } } return arr; } }; $P.processTimeObject = function (obj) { var date, dayOffset; utils.setDefaults(obj); dayOffset = ($P.isLeapYear(obj.year)) ? dayOffsets.leap : dayOffsets.standard; if (!obj.month && (obj.week || obj.dayOfYear)) { utils.getDayOfYear(obj, dayOffset); } else { obj.dayOfYear = dayOffset[obj.month] + obj.day; } date = new Date(obj.year, obj.month, obj.day, obj.hours, obj.minutes, obj.seconds, obj.milliseconds); if (obj.zone) { utils.adjustForTimeZone(obj, date); // adjust (and calculate) for timezone } return date; }; $P.ISO = { regex : /^([\+-]?\d{4}(?!\d{2}\b))((-?)((0[1-9]|1[0-2])(\3([12]\d|0[1-9]|3[01]))?|W([0-4]\d|5[0-3])(-?[1-7])?|(00[1-9]|0[1-9]\d|[12]\d{2}|3([0-5]\d|6[1-6])))([T\s]((([01]\d|2[0-4])((:?)[0-5]\d)?|24\:?00)([\.,]\d+(?!:))?)?(\17[0-5]\d([\.,]\d+)?)?\s?([zZ]|([\+-])([01]\d|2[0-3]):?([0-5]\d)?)?)?)?$/, parse : function (s) { var time, data = s.match(this.regex); if (!data || !data.length) { return null; } time = utils.buildTimeObjectFromData(data); if (!time.year || (!time.year && (!time.month && !time.day) && (!time.week && !time.dayOfYear)) ) { return null; } return $P.processTimeObject(time); } }; $P.Numeric = { isNumeric: function (e){return!isNaN(parseFloat(e))&&isFinite(e);}, regex: /\b([0-1]?[0-9])([0-3]?[0-9])([0-2]?[0-9]?[0-9][0-9])\b/i, parse: function (s) { var data, i, time = {}, order = Date.CultureInfo.dateElementOrder.split(""); if (!(this.isNumeric(s)) || // if it's non-numeric OR (s[0] === "+" && s[0] === "-")) { // It's an arithmatic string (eg +/-1000) return null; } if (s.length < 5 && s.indexOf(".") < 0 && s.indexOf("/") < 0) { // assume it's just a year. time.year = s; return $P.processTimeObject(time); } data = s.match(this.regex); if (!data || !data.length) { return null; } for (i=0; i < order.length; i++) { switch(order[i]) { case "d": time.day = data[i+1]; break; case "m": time.month = (data[i+1]-1); break; case "y": time.year = data[i+1]; break; } } return $P.processTimeObject(time); } }; $P.Normalizer = { regexData: function () { var $R = Date.CultureInfo.regexPatterns; return utils.buildRegexData([ $R.tomorrow, $R.yesterday, [$R.past, $R.mon], [$R.past, $R.tue], [$R.past, $R.wed], [$R.past, $R.thu], [$R.past, $R.fri], [$R.past, $R.sat], [$R.past, $R.sun] ]); }, basicReplaceHash : function() { var $R = Date.CultureInfo.regexPatterns; return { "January": $R.jan.source, "February": $R.feb, "March": $R.mar, "April": $R.apr, "May": $R.may, "June": $R.jun, "July": $R.jul, "August": $R.aug, "September": $R.sep, "October": $R.oct, "November": $R.nov, "December": $R.dec, "": /\bat\b/gi, " ": /\s{2,}/, "am": $R.inTheMorning, "9am": $R.thisMorning, "pm": $R.inTheEvening, "7pm":$R.thisEvening }; }, keys : function(){ return [ utils.getDateNthString(true, false, 1), // tomorrow utils.getDateNthString(true, false, -1), // yesterday utils.getDateNthString(false, true, "monday"), //last mon utils.getDateNthString(false, true, "tuesday"), //last tues utils.getDateNthString(false, true, "wednesday"), //last wed utils.getDateNthString(false, true, "thursday"), //last thurs utils.getDateNthString(false, true, "friday"), //last fri utils.getDateNthString(false, true, "saturday"), //last sat utils.getDateNthString(false, true, "sunday") //last sun ]; }, buildRegexFunctions: function () { var $R = Date.CultureInfo.regexPatterns; var __ = Date.i18n.__; var tomorrowRE = new RegExp("(\\b\\d\\d?("+__("AM")+"|"+__("PM")+")? )("+$R.tomorrow.source.slice(1)+")", "i"); // adapted tomorrow regex for AM PM relative dates var todayRE = new RegExp($R.today.source + "(?!\\s*([+-]))\\b"); // today, but excludes the math operators (eg "today + 2h") this.replaceFuncs = [ [todayRE, function (full) { return (full.length > 1) ? Date.today().toString("d") : full; }], [tomorrowRE, function(full, m1) { var t = Date.today().addDays(1).toString("d"); return (t + " " + m1); }], [$R.amThisMorning, function(str, am){return am;}], [$R.pmThisEvening, function(str, pm){return pm;}] ]; }, buildReplaceData: function () { this.buildRegexFunctions(); this.replaceHash = utils.addToHash(this.basicReplaceHash(), this.keys(), this.regexData()); }, stringReplaceFuncs: function (s) { for (var i=0; i < this.replaceFuncs.length; i++) { s = s.replace(this.replaceFuncs[i][0], this.replaceFuncs[i][1]); } return s; }, parse: function (s) { s = this.stringReplaceFuncs(s); s = utils.multiReplace(s, this.replaceHash); try { var n = s.split(/([\s\-\.\,\/\x27]+)/); if (n.length === 3 && $P.Numeric.isNumeric(n[0]) && $P.Numeric.isNumeric(n[2]) && (n[2].length >= 4)) { // ok, so we're dealing with x/year. But that's not a full date. // This fixes wonky dateElementOrder parsing when set to dmy order. if (Date.CultureInfo.dateElementOrder[0] === "d") { s = "1/" + n[0] + "/" + n[2]; // set to 1st of month and normalize the seperator } } } catch (e) {} return s; } }; $P.Normalizer.buildReplaceData(); }()); (function () { var $P = Date.Parsing; var _ = $P.Operators = { // // Tokenizers // rtoken: function (r) { // regex token return function (s) { var mx = s.match(r); if (mx) { return ([ mx[0], s.substring(mx[0].length) ]); } else { throw new $P.Exception(s); } }; }, token: function () { // whitespace-eating token return function (s) { return _.rtoken(new RegExp("^\\s*" + s + "\\s*"))(s); }; }, stoken: function (s) { // string token return _.rtoken(new RegExp("^" + s)); }, // Atomic Operators until: function (p) { return function (s) { var qx = [], rx = null; while (s.length) { try { rx = p.call(this, s); } catch (e) { qx.push(rx[0]); s = rx[1]; continue; } break; } return [ qx, s ]; }; }, many: function (p) { return function (s) { var rx = [], r = null; while (s.length) { try { r = p.call(this, s); } catch (e) { return [ rx, s ]; } rx.push(r[0]); s = r[1]; } return [ rx, s ]; }; }, // generator operators -- see below optional: function (p) { return function (s) { var r = null; try { r = p.call(this, s); } catch (e) { return [ null, s ]; } return [ r[0], r[1] ]; }; }, not: function (p) { return function (s) { try { p.call(this, s); } catch (e) { return [null, s]; } throw new $P.Exception(s); }; }, ignore: function (p) { return p ? function (s) { var r = null; r = p.call(this, s); return [null, r[1]]; } : null; }, product: function () { var px = arguments[0], qx = Array.prototype.slice.call(arguments, 1), rx = []; for (var i = 0 ; i < px.length ; i++) { rx.push(_.each(px[i], qx)); } return rx; }, cache: function (rule) { var cache = {}, cache_length = 0, cache_keys = [], CACHE_MAX = Date.Config.CACHE_MAX || 100000, r = null; var cacheCheck = function () { if (cache_length === CACHE_MAX) { // kill several keys, don't want to have to do this all the time... for (var i=0; i < 10; i++) { var key = cache_keys.shift(); if (key) { delete cache[key]; cache_length--; } } } }; return function (s) { cacheCheck(); try { r = cache[s] = (cache[s] || rule.call(this, s)); } catch (e) { r = cache[s] = e; } cache_length++; cache_keys.push(s); if (r instanceof $P.Exception) { throw r; } else { return r; } }; }, // vector operators -- see below any: function () { var px = arguments; return function (s) { var r = null; for (var i = 0; i < px.length; i++) { if (px[i] == null) { continue; } try { r = (px[i].call(this, s)); } catch (e) { r = null; } if (r) { return r; } } throw new $P.Exception(s); }; }, each: function () { var px = arguments; return function (s) { var rx = [], r = null; for (var i = 0; i < px.length ; i++) { if (px[i] == null) { continue; } try { r = (px[i].call(this, s)); } catch (e) { throw new $P.Exception(s); } rx.push(r[0]); s = r[1]; } return [ rx, s]; }; }, all: function () { var px = arguments, _ = _; return _.each(_.optional(px)); }, // delimited operators sequence: function (px, d, c) { d = d || _.rtoken(/^\s*/); c = c || null; if (px.length === 1) { return px[0]; } return function (s) { var r = null, q = null; var rx = []; for (var i = 0; i < px.length ; i++) { try { r = px[i].call(this, s); } catch (e) { break; } rx.push(r[0]); try { q = d.call(this, r[1]); } catch (ex) { q = null; break; } s = q[1]; } if (!r) { throw new $P.Exception(s); } if (q) { throw new $P.Exception(q[1]); } if (c) { try { r = c.call(this, r[1]); } catch (ey) { throw new $P.Exception(r[1]); } } return [ rx, (r?r[1]:s) ]; }; }, // // Composite Operators // between: function (d1, p, d2) { d2 = d2 || d1; var _fn = _.each(_.ignore(d1), p, _.ignore(d2)); return function (s) { var rx = _fn.call(this, s); return [[rx[0][0], r[0][2]], rx[1]]; }; }, list: function (p, d, c) { d = d || _.rtoken(/^\s*/); c = c || null; return (p instanceof Array ? _.each(_.product(p.slice(0, -1), _.ignore(d)), p.slice(-1), _.ignore(c)) : _.each(_.many(_.each(p, _.ignore(d))), px, _.ignore(c))); }, set: function (px, d, c) { d = d || _.rtoken(/^\s*/); c = c || null; return function (s) { // r is the current match, best the current 'best' match // which means it parsed the most amount of input var r = null, p = null, q = null, rx = null, best = [[], s], last = false; // go through the rules in the given set for (var i = 0; i < px.length ; i++) { // last is a flag indicating whether this must be the last element // if there is only 1 element, then it MUST be the last one q = null; p = null; r = null; last = (px.length === 1); // first, we try simply to match the current pattern // if not, try the next pattern try { r = px[i].call(this, s); } catch (e) { continue; } // since we are matching against a set of elements, the first // thing to do is to add r[0] to matched elements rx = [[r[0]], r[1]]; // if we matched and there is still input to parse and // we don't already know this is the last element, // we're going to next check for the delimiter ... // if there's none, or if there's no input left to parse // than this must be the last element after all ... if (r[1].length > 0 && ! last) { try { q = d.call(this, r[1]); } catch (ex) { last = true; } } else { last = true; } // if we parsed the delimiter and now there's no more input, // that means we shouldn't have parsed the delimiter at all // so don't update r and mark this as the last element ... if (!last && q[1].length === 0) { last = true; } // so, if this isn't the last element, we're going to see if // we can get any more matches from the remaining (unmatched) // elements ... if (!last) { // build a list of the remaining rules we can match against, // i.e., all but the one we just matched against var qx = []; for (var j = 0; j < px.length ; j++) { if (i !== j) { qx.push(px[j]); } } // now invoke recursively set with the remaining input // note that we don't include the closing delimiter ... // we'll check for that ourselves at the end p = _.set(qx, d).call(this, q[1]); // if we got a non-empty set as a result ... // (otw rx already contains everything we want to match) if (p[0].length > 0) { // update current result, which is stored in rx ... // basically, pick up the remaining text from p[1] // and concat the result from p[0] so that we don't // get endless nesting ... rx[0] = rx[0].concat(p[0]); rx[1] = p[1]; } } // at this point, rx either contains the last matched element // or the entire matched set that starts with this element. // now we just check to see if this variation is better than // our best so far, in terms of how much of the input is parsed if (rx[1].length < best[1].length) { best = rx; } // if we've parsed all the input, then we're finished if (best[1].length === 0) { break; } } // so now we've either gone through all the patterns trying them // as the initial match; or we found one that parsed the entire // input string ... // if best has no matches, just return empty set ... if (best[0].length === 0) { return best; } // if a closing delimiter is provided, then we have to check it also if (c) { // we try this even if there is no remaining input because the pattern // may well be optional or match empty input ... try { q = c.call(this, best[1]); } catch (ey) { throw new $P.Exception(best[1]); } // it parsed ... be sure to update the best match remaining input best[1] = q[1]; } // if we're here, either there was no closing delimiter or we parsed it // so now we have the best match; just return it! return best; }; }, forward: function (gr, fname) { return function (s) { return gr[fname].call(this, s); }; }, // // Translation Operators // replace: function (rule, repl) { return function (s) { var r = rule.call(this, s); return [repl, r[1]]; }; }, process: function (rule, fn) { return function (s) { var r = rule.call(this, s); return [fn.call(this, r[0]), r[1]]; }; }, min: function (min, rule) { return function (s) { var rx = rule.call(this, s); if (rx[0].length < min) { throw new $P.Exception(s); } return rx; }; } }; // Generator Operators And Vector Operators // Generators are operators that have a signature of F(R) => R, // taking a given rule and returning another rule, such as // ignore, which parses a given rule and throws away the result. // Vector operators are those that have a signature of F(R1,R2,...) => R, // take a list of rules and returning a new rule, such as each. // Generator operators are converted (via the following _generator // function) into functions that can also take a list or array of rules // and return an array of new rules as though the function had been // called on each rule in turn (which is what actually happens). // This allows generators to be used with vector operators more easily. // Example: // each(ignore(foo, bar)) instead of each(ignore(foo), ignore(bar)) // This also turns generators into vector operators, which allows // constructs like: // not(cache(foo, bar)) var _generator = function (op) { function gen() { var args = null, rx = [], px, i; if (arguments.length > 1) { args = Array.prototype.slice.call(arguments); } else if (arguments[0] instanceof Array) { args = arguments[0]; } if (args) { px = args.shift(); if (px.length > 0) { args.unshift(px[i]); rx.push(op.apply(null, args)); args.shift(); return rx; } } else { return op.apply(null, arguments); } } return gen; }; var gx = "optional not ignore cache".split(/\s/); for (var i = 0 ; i < gx.length ; i++) { _[gx[i]] = _generator(_[gx[i]]); } var _vector = function (op) { return function () { if (arguments[0] instanceof Array) { return op.apply(null, arguments[0]); } else { return op.apply(null, arguments); } }; }; var vx = "each any all".split(/\s/); for (var j = 0 ; j < vx.length ; j++) { _[vx[j]] = _vector(_[vx[j]]); } }()); (function () { var $D = Date; var flattenAndCompact = function (ax) { var rx = []; for (var i = 0; i < ax.length; i++) { if (ax[i] instanceof Array) { rx = rx.concat(flattenAndCompact(ax[i])); } else { if (ax[i]) { rx.push(ax[i]); } } } return rx; }; var parseMeridian = function () { if (this.meridian && (this.hour || this.hour === 0)) { if (this.meridian === "a" && this.hour > 11 && Date.Config.strict24hr){ throw "Invalid hour and meridian combination"; } else if (this.meridian === "p" && this.hour < 12 && Date.Config.strict24hr){ throw "Invalid hour and meridian combination"; } else if (this.meridian === "p" && this.hour < 12) { this.hour = this.hour + 12; } else if (this.meridian === "a" && this.hour === 12) { this.hour = 0; } } }; var setDefaults = function () { var now = new Date(); if ((this.hour || this.minute) && (!this.month && !this.year && !this.day)) { this.day = now.getDate(); } if (!this.year) { this.year = now.getFullYear(); } if (!this.month && this.month !== 0) { this.month = now.getMonth(); } if (!this.day) { this.day = 1; } if (!this.hour) { this.hour = 0; } if (!this.minute) { this.minute = 0; } if (!this.second) { this.second = 0; } if (!this.millisecond) { this.millisecond = 0; } }; var finishUtils = { getToday: function () { if (this.now || "hour minute second".indexOf(this.unit) !== -1) { return new Date(); } else { return $D.today(); } }, setDaysFromWeekday: function (today, orient){ var gap; orient = orient || 1; this.unit = "day"; gap = ($D.getDayNumberFromName(this.weekday) - today.getDay()); this.days = gap ? ((gap + (orient * 7)) % 7) : (orient * 7); return this; }, setMonthsFromMonth: function (today, orient) { var gap; orient = orient || 1; this.unit = "month"; gap = (this.month - today.getMonth()); this.months = gap ? ((gap + (orient * 12)) % 12) : (orient * 12); this.month = null; return this; }, setDMYFromWeekday: function () { var d = Date[this.weekday](); this.day = d.getDate(); if (!this.month) { this.month = d.getMonth(); } this.year = d.getFullYear(); return this; }, setUnitValue: function (orient) { if (!this.value && this.operator && this.operator !== null && this[this.unit + "s"] && this[this.unit + "s"] !== null) { this[this.unit + "s"] = this[this.unit + "s"] + ((this.operator === "add") ? 1 : -1) + (this.value||0) * orient; } else if (this[this.unit + "s"] == null || this.operator != null) { if (!this.value) { this.value = 1; } this[this.unit + "s"] = this.value * orient; } }, generateDateFromWeeks: function () { var weekday = (this.weekday !== undefined) ? this.weekday : "today"; var d = Date[weekday]().addWeeks(this.weeks); if (this.now) { d.setTimeToNow(); } return d; } }; $D.Translator = { hour: function (s) { return function () { this.hour = Number(s); }; }, minute: function (s) { return function () { this.minute = Number(s); }; }, second: function (s) { return function () { this.second = Number(s); }; }, /* for ss.s format */ secondAndMillisecond: function (s) { return function () { var mx = s.match(/^([0-5][0-9])\.([0-9]{1,3})/); this.second = Number(mx[1]); this.millisecond = Number(mx[2]); }; }, meridian: function (s) { return function () { this.meridian = s.slice(0, 1).toLowerCase(); }; }, timezone: function (s) { return function () { var n = s.replace(/[^\d\+\-]/g, ""); if (n.length) { this.timezoneOffset = Number(n); } else { this.timezone = s.toLowerCase(); } }; }, day: function (x) { var s = x[0]; return function () { this.day = Number(s.match(/\d+/)[0]); if (this.day < 1) { throw "invalid day"; } }; }, month: function (s) { return function () { this.month = (s.length === 3) ? "jan feb mar apr may jun jul aug sep oct nov dec".indexOf(s)/4 : Number(s) - 1; if (this.month < 0) { throw "invalid month"; } }; }, year: function (s) { return function () { var n = Number(s); this.year = ((s.length > 2) ? n : (n + (((n + 2000) < Date.CultureInfo.twoDigitYearMax) ? 2000 : 1900))); }; }, rday: function (s) { return function () { switch (s) { case "yesterday": this.days = -1; break; case "tomorrow": this.days = 1; break; case "today": this.days = 0; break; case "now": this.days = 0; this.now = true; break; } }; }, finishExact: function (x) { var d; x = (x instanceof Array) ? x : [x]; for (var i = 0 ; i < x.length ; i++) { if (x[i]) { x[i].call(this); } } setDefaults.call(this); parseMeridian.call(this); if (this.day > $D.getDaysInMonth(this.year, this.month)) { throw new RangeError(this.day + " is not a valid value for days."); } d = new Date(this.year, this.month, this.day, this.hour, this.minute, this.second, this.millisecond); if (this.year < 100) { d.setFullYear(this.year); // means years less that 100 are process correctly. JS will parse it otherwise as 1900-1999. } if (this.timezone) { d.set({ timezone: this.timezone }); } else if (this.timezoneOffset) { d.set({ timezoneOffset: this.timezoneOffset }); } return d; }, finish: function (x) { var today, expression, orient, temp; x = (x instanceof Array) ? flattenAndCompact(x) : [ x ]; if (x.length === 0) { return null; } for (var i = 0 ; i < x.length ; i++) { if (typeof x[i] === "function") { x[i].call(this); } } if (this.now && !this.unit && !this.operator) { return new Date(); } else { today = finishUtils.getToday.call(this); } expression = !!(this.days && this.days !== null || this.orient || this.operator); orient = ((this.orient === "past" || this.operator === "subtract") ? -1 : 1); if (this.month && this.unit === "week") { this.value = this.month + 1; delete this.month; delete this.day; } if ((this.month || this.month === 0) && "year day hour minute second".indexOf(this.unit) !== -1) { if (!this.value) { this.value = this.month + 1; } this.month = null; expression = true; } if (!expression && this.weekday && !this.day && !this.days) { finishUtils.setDMYFromWeekday.call(this); } if (expression && this.weekday && this.unit !== "month" && this.unit !== "week") { finishUtils.setDaysFromWeekday.call(this, today, orient); } if (this.weekday && this.unit !== "week" && !this.day && !this.days) { temp = Date[this.weekday](); this.day = temp.getDate(); if (temp.getMonth() !== today.getMonth()) { this.month = temp.getMonth(); } } if (this.month && this.unit === "day" && this.operator) { if (!this.value) { this.value = (this.month + 1); } this.month = null; } if (this.value != null && this.month != null && this.year != null) { this.day = this.value * 1; } if (this.month && !this.day && this.value) { today.set({ day: this.value * 1 }); if (!expression) { this.day = this.value * 1; } } if (!this.month && this.value && this.unit === "month" && !this.now) { this.month = this.value; expression = true; } if (expression && (this.month || this.month === 0) && this.unit !== "year") { finishUtils.setMonthsFromMonth.call(this, today, orient); } if (!this.unit) { this.unit = "day"; } finishUtils.setUnitValue.call(this, orient); parseMeridian.call(this); if ((this.month || this.month === 0) && !this.day) { this.day = 1; } if (!this.orient && !this.operator && this.unit === "week" && this.value && !this.day && !this.month) { return Date.today().setWeek(this.value); } if (this.unit === "week" && this.weeks && !this.day && !this.month) { return finishUtils.generateDateFromWeeks.call(this); } if (expression && this.timezone && this.day && this.days) { this.day = this.days; } if (expression){ today.add(this); } else { today.set(this); } if (this.timezone) { this.timezone = this.timezone.toUpperCase(); var offset = $D.getTimezoneOffset(this.timezone); var timezone; if (today.hasDaylightSavingTime()) { // lets check that we're being sane with timezone setting timezone = $D.getTimezoneAbbreviation(offset, today.isDaylightSavingTime()); if (timezone !== this.timezone) { // bugger, we're in a place where things like EST vs EDT matters. if (today.isDaylightSavingTime()) { today.addHours(-1); } else { today.addHours(1); } } } today.setTimezoneOffset(offset); } return today; } }; }()); (function () { var $D = Date; $D.Grammar = {}; var _ = $D.Parsing.Operators, g = $D.Grammar, t = $D.Translator, _fn; // Allow rolling up into general purpose rules _fn = function () { return _.each(_.any.apply(null, arguments), _.not(g.ctoken2("timeContext"))); }; g.datePartDelimiter = _.rtoken(/^([\s\-\.\,\/\x27]+)/); g.timePartDelimiter = _.stoken(":"); g.whiteSpace = _.rtoken(/^\s*/); g.generalDelimiter = _.rtoken(/^(([\s\,]|at|@|on)+)/); var _C = {}; g.ctoken = function (keys) { var fn = _C[keys]; if (! fn) { var c = Date.CultureInfo.regexPatterns; var kx = keys.split(/\s+/), px = []; for (var i = 0; i < kx.length ; i++) { px.push(_.replace(_.rtoken(c[kx[i]]), kx[i])); } fn = _C[keys] = _.any.apply(null, px); } return fn; }; g.ctoken2 = function (key) { return _.rtoken(Date.CultureInfo.regexPatterns[key]); }; var cacheProcessRtoken = function (key, token, type, eachToken) { if (eachToken) { g[key] = _.cache(_.process(_.each(_.rtoken(token),_.optional(g.ctoken2(eachToken))), type)); } else { g[key] = _.cache(_.process(_.rtoken(token), type)); } }; var cacheProcessCtoken = function (token, type) { return _.cache(_.process(g.ctoken2(token), type)); }; var _F = {}; //function cache var _get = function (f) { _F[f] = (_F[f] || g.format(f)[0]); return _F[f]; }; g.allformats = function (fx) { var rx = []; if (fx instanceof Array) { for (var i = 0; i < fx.length; i++) { rx.push(_get(fx[i])); } } else { rx.push(_get(fx)); } return rx; }; g.formats = function (fx) { if (fx instanceof Array) { var rx = []; for (var i = 0 ; i < fx.length ; i++) { rx.push(_get(fx[i])); } return _.any.apply(null, rx); } else { return _get(fx); } }; var grammarFormats = { timeFormats: function(){ var i, RTokenKeys = [ "h", "hh", "H", "HH", "m", "mm", "s", "ss", "ss.s", "z", "zz" ], RToken = [ /^(0[0-9]|1[0-2]|[1-9])/, /^(0[0-9]|1[0-2])/, /^([0-1][0-9]|2[0-3]|[0-9])/, /^([0-1][0-9]|2[0-3])/, /^([0-5][0-9]|[0-9])/, /^[0-5][0-9]/, /^([0-5][0-9]|[0-9])/, /^[0-5][0-9]/, /^[0-5][0-9]\.[0-9]{1,3}/, /^((\+|\-)\s*\d\d\d\d)|((\+|\-)\d\d\:?\d\d)/, /^((\+|\-)\s*\d\d\d\d)|((\+|\-)\d\d\:?\d\d)/ ], tokens = [ t.hour, t.hour, t.hour, t.hour, t.minute, t.minute, t.second, t.second, t.secondAndMillisecond, t.timezone, t.timezone ]; for (i=0; i < RTokenKeys.length; i++) { cacheProcessRtoken(RTokenKeys[i], RToken[i], tokens[i]); } g.hms = _.cache(_.sequence([g.H, g.m, g.s], g.timePartDelimiter)); g.t = cacheProcessCtoken("shortMeridian", t.meridian); g.tt = cacheProcessCtoken("longMeridian", t.meridian); g.zzz = cacheProcessCtoken("timezone", t.timezone); g.timeSuffix = _.each(_.ignore(g.whiteSpace), _.set([ g.tt, g.zzz ])); g.time = _.each(_.optional(_.ignore(_.stoken("T"))), g.hms, g.timeSuffix); }, dateFormats: function () { // pre-loaded rules for different date part order preferences var _setfn = function () { return _.set(arguments, g.datePartDelimiter); }; var i, RTokenKeys = [ "d", "dd", "M", "MM", "y", "yy", "yyy", "yyyy" ], RToken = [ /^([0-2]\d|3[0-1]|\d)/, /^([0-2]\d|3[0-1])/, /^(1[0-2]|0\d|\d)/, /^(1[0-2]|0\d)/, /^(\d+)/, /^(\d\d)/, /^(\d\d?\d?\d?)/, /^(\d\d\d\d)/ ], tokens = [ t.day, t.day, t.month, t.month, t.year, t.year, t.year, t.year ], eachToken = [ "ordinalSuffix", "ordinalSuffix" ]; for (i=0; i < RTokenKeys.length; i++) { cacheProcessRtoken(RTokenKeys[i], RToken[i], tokens[i], eachToken[i]); } g.MMM = g.MMMM = _.cache(_.process(g.ctoken("jan feb mar apr may jun jul aug sep oct nov dec"), t.month)); g.ddd = g.dddd = _.cache(_.process(g.ctoken("sun mon tue wed thu fri sat"), function (s) { return function () { this.weekday = s; }; } )); g.day = _fn(g.d, g.dd); g.month = _fn(g.M, g.MMM); g.year = _fn(g.yyyy, g.yy); g.mdy = _setfn(g.ddd, g.month, g.day, g.year); g.ymd = _setfn(g.ddd, g.year, g.month, g.day); g.dmy = _setfn(g.ddd, g.day, g.month, g.year); g.date = function (s) { return ((g[Date.CultureInfo.dateElementOrder] || g.mdy).call(this, s)); }; }, relative: function () { // relative date / time expressions g.orientation = _.process(g.ctoken("past future"), function (s) { return function () { this.orient = s; }; } ); g.operator = _.process(g.ctoken("add subtract"), function (s) { return function () { this.operator = s; }; } ); g.rday = _.process(g.ctoken("yesterday tomorrow today now"), t.rday); g.unit = _.process(g.ctoken("second minute hour day week month year"), function (s) { return function () { this.unit = s; }; } ); } }; g.buildGrammarFormats = function () { // these need to be rebuilt every time the language changes. _C = {}; grammarFormats.timeFormats(); grammarFormats.dateFormats(); grammarFormats.relative(); g.value = _.process(_.rtoken(/^([-+]?\d+)?(st|nd|rd|th)?/), function (s) { return function () { this.value = s.replace(/\D/g, ""); }; } ); g.expression = _.set([g.rday, g.operator, g.value, g.unit, g.orientation, g.ddd, g.MMM ]); g.format = _.process(_.many( _.any( // translate format specifiers into grammar rules _.process( _.rtoken(/^(dd?d?d?(?!e)|MM?M?M?|yy?y?y?|hh?|HH?|mm?|ss?|tt?|zz?z?)/), function (fmt) { if (g[fmt]) { return g[fmt]; } else { throw $D.Parsing.Exception(fmt); } } ), // translate separator tokens into token rules _.process(_.rtoken(/^[^dMyhHmstz]+/), // all legal separators function (s) { return _.ignore(_.stoken(s)); } ) ) ), // construct the parser ... function (rules) { return _.process(_.each.apply(null, rules), t.finishExact); } ); // starting rule for general purpose grammar g._start = _.process(_.set([ g.date, g.time, g.expression ], g.generalDelimiter, g.whiteSpace), t.finish); }; g.buildGrammarFormats(); // parsing date format specifiers - ex: "h:m:s tt" // this little guy will generate a custom parser based // on the format string, ex: g.format("h:m:s tt") // check for these formats first g._formats = g.formats([ "\"yyyy-MM-ddTHH:mm:ssZ\"", "yyyy-MM-ddTHH:mm:ss.sz", "yyyy-MM-ddTHH:mm:ssZ", "yyyy-MM-ddTHH:mm:ssz", "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-ddTHH:mmZ", "yyyy-MM-ddTHH:mmz", "yyyy-MM-ddTHH:mm", "ddd, MMM dd, yyyy H:mm:ss tt", "ddd MMM d yyyy HH:mm:ss zzz", "MMddyyyy", "ddMMyyyy", "Mddyyyy", "ddMyyyy", "Mdyyyy", "dMyyyy", "yyyy", "Mdyy", "dMyy", "d" ]); // real starting rule: tries selected formats first, // then general purpose rule g.start = function (s) { try { var r = g._formats.call({}, s); if (r[1].length === 0) { return r; } } catch (e) {} return g._start.call({}, s); }; }()); (function () { var $D = Date; /** * @desc Converts the specified string value into its JavaScript Date equivalent using CultureInfo specific format information. * * Example

	///////////
	// Dates //
	///////////

	// 15-Oct-2004
	var d1 = Date.parse("10/15/2004");

	// 15-Oct-2004
	var d1 = Date.parse("15-Oct-2004");

	// 15-Oct-2004
	var d1 = Date.parse("2004.10.15");

	//Fri Oct 15, 2004
	var d1 = Date.parse("Fri Oct 15, 2004");

	///////////
	// Times //
	///////////

	// Today at 10 PM.
	var d1 = Date.parse("10 PM");

	// Today at 10:30 PM.
	var d1 = Date.parse("10:30 P.M.");

	// Today at 6 AM.
	var d1 = Date.parse("06am");

	/////////////////////
	// Dates and Times //
	/////////////////////

	// 8-July-2004 @ 10:30 PM
	var d1 = Date.parse("July 8th, 2004, 10:30 PM");

	// 1-July-2004 @ 10:30 PM
	var d1 = Date.parse("2004-07-01T22:30:00");

	////////////////////
	// Relative Dates //
	////////////////////

	// Returns today's date. The string "today" is culture specific.
	var d1 = Date.parse("today");

	// Returns yesterday's date. The string "yesterday" is culture specific.
	var d1 = Date.parse("yesterday");

	// Returns the date of the next thursday.
	var d1 = Date.parse("Next thursday");

	// Returns the date of the most previous monday.
	var d1 = Date.parse("last monday");

	// Returns today's day + one year.
	var d1 = Date.parse("next year");

	///////////////
	// Date Math //
	///////////////

	// Today + 2 days
	var d1 = Date.parse("t+2");

	// Today + 2 days
	var d1 = Date.parse("today + 2 days");

	// Today + 3 months
	var d1 = Date.parse("t+3m");

	// Today - 1 year
	var d1 = Date.parse("today - 1 year");

	// Today - 1 year
	var d1 = Date.parse("t-1y"); 


	/////////////////////////////
	// Partial Dates and Times //
	/////////////////////////////

	// July 15th of this year.
	var d1 = Date.parse("July 15");

	// 15th day of current day and year.
	var d1 = Date.parse("15");

	// July 1st of current year at 10pm.
	var d1 = Date.parse("7/1 10pm");
	
* * @param {String} The string value to convert into a Date object [Required] * @return {Date} A Date object or null if the string cannot be converted into a Date. */ var parseUtils = { removeOrds: function (s) { ords = s.match(/\b(\d+)(?:st|nd|rd|th)\b/); // find ordinal matches s = ((ords && ords.length === 2) ? s.replace(ords[0], ords[1]) : s); return s; }, grammarParser: function (s) { var r = null; try { r = $D.Grammar.start.call({}, s.replace(/^\s*(\S*(\s+\S+)*)\s*$/, "$1")); } catch (e) { return null; } return ((r[1].length === 0) ? r[0] : null); }, nativeFallback: function(s) { var t; try { // ok we haven't parsed it, last ditch attempt with the built-in parser. t = Date._parse(s); return (t || t === 0) ? new Date(t) : null; } catch (e) { return null; } } }; function parse (s) { var d; if (!s) { return null; } if (s instanceof Date) { return s.clone(); } if (s.length >= 4 && s.charAt(0) !== "0" && s.charAt(0) !== "+"&& s.charAt(0) !== "-") { // ie: 2004 will pass, 0800 won't. // Start with specific formats d = $D.Parsing.ISO.parse(s) || $D.Parsing.Numeric.parse(s); } if (d instanceof Date && !isNaN(d.getTime())) { return d; } else { // find ordinal dates (1st, 3rd, 8th, etc and remove them as they cause parsing issues) s = $D.Parsing.Normalizer.parse(parseUtils.removeOrds(s)); d = parseUtils.grammarParser(s); if (d !== null) { return d; } else { return parseUtils.nativeFallback(s); } } } if (!$D._parse) { $D._parse = $D.parse; } $D.parse = parse; Date.getParseFunction = function (fx) { var fns = Date.Grammar.allformats(fx); return function (s) { var r = null; for (var i = 0; i < fns.length; i++) { try { r = fns[i].call({}, s); } catch (e) { continue; } if (r[1].length === 0) { return r[0]; } } return null; }; }; /** * Converts the specified string value into its JavaScript Date equivalent using the specified format {String} or formats {Array} and the CultureInfo specific format information. * The format of the string value must match one of the supplied formats exactly. * * Example

	// 15-Oct-2004
	var d1 = Date.parseExact("10/15/2004", "M/d/yyyy");

	// 15-Oct-2004
	var d1 = Date.parse("15-Oct-2004", "M-ddd-yyyy");

	// 15-Oct-2004
	var d1 = Date.parse("2004.10.15", "yyyy.MM.dd");

	// Multiple formats
	var d1 = Date.parseExact("10/15/2004", ["M/d/yyyy", "MMMM d, yyyy"]);
	
* * @param {String} The string value to convert into a Date object [Required]. * @param {Object} The expected format {String} or an array of expected formats {Array} of the date string [Required]. * @return {Date} A Date object or null if the string cannot be converted into a Date. */ $D.parseExact = function (s, fx) { return $D.getParseFunction(fx)(s); }; }()); (function () { var $D = Date, $P = $D.prototype, // $C = $D.CultureInfo, // not used atm p = function (s, l) { if (!l) { l = 2; } return ("000" + s).slice(l * -1); }; /** * Converts a PHP format string to Java/.NET format string. * A PHP format string can be used with ._format or .format. * A Java/.NET format string can be used with .toString(). * The .parseExact function will only accept a Java/.NET format string * * Example * var f1 = "%m/%d/%y" * var f2 = Date.normalizeFormat(f1); // "MM/dd/yy" * * new Date().format(f1); // "04/13/08" * new Date()._format(f1); // "04/13/08" * new Date().toString(f2); // "04/13/08" * * var date = Date.parseExact("04/13/08", f2); // Sun Apr 13 2008 * * @param {String} A PHP format string consisting of one or more format spcifiers. * @return {String} The PHP format converted to a Java/.NET format string. */ var normalizerSubstitutions = { "d" : "dd", "%d": "dd", "D" : "ddd", "%a": "ddd", "j" : "dddd", "l" : "dddd", "%A": "dddd", "S" : "S", "F" : "MMMM", "%B": "MMMM", "m" : "MM", "%m": "MM", "M" : "MMM", "%b": "MMM", "%h": "MMM", "n" : "M", "Y" : "yyyy", "%Y": "yyyy", "y" : "yy", "%y": "yy", "g" : "h", "%I": "h", "G" : "H", "h" : "hh", "H" : "HH", "%H": "HH", "i" : "mm", "%M": "mm", "s" : "ss", "%S": "ss", "%r": "hh:mm tt", "%R": "H:mm", "%T": "H:mm:ss", "%X": "t", "%x": "d", "%e": "d", "%D": "MM/dd/yy", "%n": "\\n", "%t": "\\t", "e" : "z", "T" : "z", "%z": "z", "%Z": "z", "Z" : "ZZ", "N" : "u", "w" : "u", "%w": "u", "W" : "W", "%V": "W" }; var normalizer = { substitutes: function (m) { return normalizerSubstitutions[m]; }, interpreted: function (m, x) { var y; switch (m) { case "%u": return x.getDay() + 1; case "z": return x.getOrdinalNumber(); case "%j": return p(x.getOrdinalNumber(), 3); case "%U": var d1 = x.clone().set({month: 0, day: 1}).addDays(-1).moveToDayOfWeek(0), d2 = x.clone().addDays(1).moveToDayOfWeek(0, -1); return (d2 < d1) ? "00" : p((d2.getOrdinalNumber() - d1.getOrdinalNumber()) / 7 + 1); case "%W": return p(x.getWeek()); case "t": return $D.getDaysInMonth(x.getFullYear(), x.getMonth()); case "o": case "%G": return x.setWeek(x.getISOWeek()).toString("yyyy"); case "%g": return x._format("%G").slice(-2); case "a": case "%p": return t("tt").toLowerCase(); case "A": return t("tt").toUpperCase(); case "u": return p(x.getMilliseconds(), 3); case "I": return (x.isDaylightSavingTime()) ? 1 : 0; case "O": return x.getUTCOffset(); case "P": y = x.getUTCOffset(); return y.substring(0, y.length - 2) + ":" + y.substring(y.length - 2); case "B": var now = new Date(); return Math.floor(((now.getHours() * 3600) + (now.getMinutes() * 60) + now.getSeconds() + (now.getTimezoneOffset() + 60) * 60) / 86.4); case "c": return x.toISOString().replace(/\"/g, ""); case "U": return $D.strtotime("now"); case "%c": return t("d") + " " + t("t"); case "%C": return Math.floor(x.getFullYear() / 100 + 1); } }, shouldOverrideDefaults: function (m) { switch (m) { case "%e": return true; default: return false; } }, parse: function (m, context) { var formatString, c = context || new Date(); formatString = normalizer.substitutes(m); if (formatString) { return formatString; } formatString = normalizer.interpreted(m, c); if (formatString) { return formatString; } else { return m; } } }; $D.normalizeFormat = function (format, context) { return format.replace(/(%|\\)?.|%%/g, function(t){ return normalizer.parse(t, context); }); }; /** * Format a local Unix timestamp according to locale settings * * Example: * Date.strftime("%m/%d/%y", new Date()); // "04/13/08" * Date.strftime("c", "2008-04-13T17:52:03Z"); // "04/13/08" * * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @param {Number|String} The number representing the number of seconds that have elapsed since January 1, 1970 (local time). * @return {String} A string representation of the current Date object. */ $D.strftime = function (format, time) { var d = Date.parse(time); return d._format(format); }; /** * Parse any textual datetime description into a Unix timestamp. * A Unix timestamp is the number of seconds that have elapsed since January 1, 1970 (midnight UTC/GMT). * * Example: * Date.strtotime("04/13/08"); // 1208044800 * Date.strtotime("1970-01-01T00:00:00Z"); // 0 * * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @param {Object} A string or date object. * @return {String} A string representation of the current Date object. */ $D.strtotime = function (time) { var d = $D.parse(time); return Math.round($D.UTC(d.getUTCFullYear(), d.getUTCMonth(), d.getUTCDate(), d.getUTCHours(), d.getUTCMinutes(), d.getUTCSeconds(), d.getUTCMilliseconds()) / 1000); }; /** * Converts the value of the current Date object to its equivalent string representation using a PHP/Unix style of date format specifiers. * Format Specifiers * Format Description Example * ------ --------------------------------------------------------------------------- ----------------------- * %a abbreviated weekday name according to the current localed "Mon" through "Sun" * %A full weekday name according to the current localed "Sunday" through "Saturday" * %b abbreviated month name according to the current localed "Jan" through "Dec" * %B full month name according to the current locale "January" through "December" * %c preferred date and time representation for the current locale "4/13/2008 12:33 PM" * %C century number (the year divided by 100 and truncated to an integer) "00" to "99" * %d day of the month as a decimal number "01" to "31" * %D same as %m/%d/%y "04/13/08" * %e day of the month as a decimal number, a single digit is preceded by a space "1" to "31" * %g like %G, but without the century "08" * %G The 4-digit year corresponding to the ISO week number (see %V). "2008" * This has the same format and value as %Y, except that if the ISO week number * belongs to the previous or next year, that year is used instead. * %h same as %b "Jan" through "Dec" * %H hour as a decimal number using a 24-hour clock. "00" to "23" * %I hour as a decimal number using a 12-hour clock. "01" to "12" * %j day of the year as a decimal number. "001" to "366" * %m month as a decimal number. "01" to "12" * %M minute as a decimal number. "00" to "59" * %n newline character "\n" * %p either "am" or "pm" according to the given time value, or the "am" or "pm" * corresponding strings for the current locale. * %r time in a.m. and p.m. notation "8:44 PM" * %R time in 24 hour notation "20:44" * %S second as a decimal number "00" to "59" * %t tab character "\t" * %T current time, equal to %H:%M:%S "12:49:11" * %u weekday as a decimal number ["1", "7"], with "1" representing Monday "1" to "7" * %U week number of the current year as a decimal number, starting with the "0" to ("52" or "53") * first Sunday as the first day of the first week * %V The ISO 8601:1988 week number of the current year as a decimal number, "00" to ("52" or "53") * range 01 to 53, where week 1 is the first week that has at least 4 days * in the current year, and with Monday as the first day of the week. * (Use %G or %g for the year component that corresponds to the week number * for the specified timestamp.) * %W week number of the current year as a decimal number, starting with the "00" to ("52" or "53") * first Monday as the first day of the first week * %w day of the week as a decimal, Sunday being "0" "0" to "6" * %x preferred date representation for the current locale without the time "4/13/2008" * %X preferred time representation for the current locale without the date "12:53:05" * %y year as a decimal number without a century "00" "99" * %Y year as a decimal number including the century "2008" * %Z time zone or name or abbreviation "UTC", "EST", "PST" * %z same as %Z * %% a literal "%" characters "%" * d Day of the month, 2 digits with leading zeros "01" to "31" * D A textual representation of a day, three letters "Mon" through "Sun" * j Day of the month without leading zeros "1" to "31" * l A full textual representation of the day of the week (lowercase "L") "Sunday" through "Saturday" * N ISO-8601 numeric representation of the day of the week (added in PHP 5.1.0) "1" (for Monday) through "7" (for Sunday) * S English ordinal suffix for the day of the month, 2 characters "st", "nd", "rd" or "th". Works well with j * w Numeric representation of the day of the week "0" (for Sunday) through "6" (for Saturday) * z The day of the year (starting from "0") "0" through "365" * W ISO-8601 week number of year, weeks starting on Monday "00" to ("52" or "53") * F A full textual representation of a month, such as January or March "January" through "December" * m Numeric representation of a month, with leading zeros "01" through "12" * M A short textual representation of a month, three letters "Jan" through "Dec" * n Numeric representation of a month, without leading zeros "1" through "12" * t Number of days in the given month "28" through "31" * L Whether it's a leap year "1" if it is a leap year, "0" otherwise * o ISO-8601 year number. This has the same value as Y, except that if the "2008" * ISO week number (W) belongs to the previous or next year, that year * is used instead. * Y A full numeric representation of a year, 4 digits "2008" * y A two digit representation of a year "08" * a Lowercase Ante meridiem and Post meridiem "am" or "pm" * A Uppercase Ante meridiem and Post meridiem "AM" or "PM" * B Swatch Internet time "000" through "999" * g 12-hour format of an hour without leading zeros "1" through "12" * G 24-hour format of an hour without leading zeros "0" through "23" * h 12-hour format of an hour with leading zeros "01" through "12" * H 24-hour format of an hour with leading zeros "00" through "23" * i Minutes with leading zeros "00" to "59" * s Seconds, with leading zeros "00" through "59" * u Milliseconds "54321" * e Timezone identifier "UTC", "EST", "PST" * I Whether or not the date is in daylight saving time (uppercase i) "1" if Daylight Saving Time, "0" otherwise * O Difference to Greenwich time (GMT) in hours "+0200", "-0600" * P Difference to Greenwich time (GMT) with colon between hours and minutes "+02:00", "-06:00" * T Timezone abbreviation "UTC", "EST", "PST" * Z Timezone offset in seconds. The offset for timezones west of UTC is "-43200" through "50400" * always negative, and for those east of UTC is always positive. * c ISO 8601 date "2004-02-12T15:19:21+00:00" * r RFC 2822 formatted date "Thu, 21 Dec 2000 16:01:07 +0200" * U Seconds since the Unix Epoch (January 1 1970 00:00:00 GMT) "0" * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @return {String} A string representation of the current Date object. */ var formatReplace = function (context) { return function (m) { var formatString, override = false; if (m.charAt(0) === "\\" || m.substring(0, 2) === "%%") { return m.replace("\\", "").replace("%%", "%"); } override = normalizer.shouldOverrideDefaults(m); formatString = $D.normalizeFormat(m, context); if (formatString) { return context.toString(formatString, override); } }; }; $P._format = function (format) { var formatter = formatReplace(this); if (!format) { return this._toString(); } else { return format.replace(/(%|\\)?.|%%/g, formatter); } }; if (!$P.format) { $P.format = $P._format; } }()); (function () { "use strict"; var gFn = function (attr) { return function () { return this[attr]; }; }; var sFn = function (attr) { return function (val) { this[attr] = val; return this; }; }; var attrs = ["years", "months", "days", "hours", "minutes", "seconds", "milliseconds"]; var addSetFuncs = function (context, attrs) { for (var i = 0; i < attrs.length ; i++) { var $a = attrs[i], $b = $a.slice(0, 1).toUpperCase() + $a.slice(1); context.prototype[$a] = 0; context.prototype["get" + $b] = gFn($a); context.prototype["set" + $b] = sFn($a); } }; /** * new TimeSpan(milliseconds); * new TimeSpan(days, hours, minutes, seconds); * new TimeSpan(days, hours, minutes, seconds, milliseconds); */ var TimeSpan = function (days, hours, minutes, seconds, milliseconds) { if (arguments.length === 1 && typeof days === "number") { var orient = (days < 0) ? -1 : +1; var millsLeft = Math.abs(days); this.setDays(Math.floor(millsLeft / 86400000) * orient); millsLeft = millsLeft % 86400000; this.setHours(Math.floor(millsLeft / 3600000) * orient); millsLeft = millsLeft % 3600000; this.setMinutes(Math.floor(millsLeft / 60000) * orient); millsLeft = millsLeft % 60000; this.setSeconds(Math.floor(millsLeft / 1000) * orient); millsLeft = millsLeft % 1000; this.setMilliseconds(millsLeft * orient); } else { this.set(days, hours, minutes, seconds, milliseconds); } this.getTotalMilliseconds = function () { return (this.getDays() * 86400000) + (this.getHours() * 3600000) + (this.getMinutes() * 60000) + (this.getSeconds() * 1000); }; this.compareTo = function (time) { var t1 = new Date(1970, 1, 1, this.getHours(), this.getMinutes(), this.getSeconds()), t2; if (time === null) { t2 = new Date(1970, 1, 1, 0, 0, 0); } else { t2 = new Date(1970, 1, 1, time.getHours(), time.getMinutes(), time.getSeconds()); } return (t1 < t2) ? -1 : (t1 > t2) ? 1 : 0; }; this.equals = function (time) { return (this.compareTo(time) === 0); }; this.add = function (time) { return (time === null) ? this : this.addSeconds(time.getTotalMilliseconds() / 1000); }; this.subtract = function (time) { return (time === null) ? this : this.addSeconds(-time.getTotalMilliseconds() / 1000); }; this.addDays = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 86400000)); }; this.addHours = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 3600000)); }; this.addMinutes = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 60000)); }; this.addSeconds = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 1000)); }; this.addMilliseconds = function (n) { return new TimeSpan(this.getTotalMilliseconds() + n); }; this.get12HourHour = function () { return (this.getHours() > 12) ? this.getHours() - 12 : (this.getHours() === 0) ? 12 : this.getHours(); }; this.getDesignator = function () { return (this.getHours() < 12) ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator; }; this.toString = function (format) { this._toString = function () { if (this.getDays() !== null && this.getDays() > 0) { return this.getDays() + "." + this.getHours() + ":" + this.p(this.getMinutes()) + ":" + this.p(this.getSeconds()); } else { return this.getHours() + ":" + this.p(this.getMinutes()) + ":" + this.p(this.getSeconds()); } }; this.p = function (s) { return (s.toString().length < 2) ? "0" + s : s; }; var me = this; return format ? format.replace(/dd?|HH?|hh?|mm?|ss?|tt?/g, function (format) { switch (format) { case "d": return me.getDays(); case "dd": return me.p(me.getDays()); case "H": return me.getHours(); case "HH": return me.p(me.getHours()); case "h": return me.get12HourHour(); case "hh": return me.p(me.get12HourHour()); case "m": return me.getMinutes(); case "mm": return me.p(me.getMinutes()); case "s": return me.getSeconds(); case "ss": return me.p(me.getSeconds()); case "t": return ((me.getHours() < 12) ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator).substring(0, 1); case "tt": return (me.getHours() < 12) ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator; } } ) : this._toString(); }; return this; }; addSetFuncs(TimeSpan, attrs.slice(2)); TimeSpan.prototype.set = function (days, hours, minutes, seconds, milliseconds){ this.setDays(days || this.getDays()); this.setHours(hours || this.getHours()); this.setMinutes(minutes || this.getMinutes()); this.setSeconds(seconds || this.getSeconds()); this.setMilliseconds(milliseconds || this.getMilliseconds()); }; /** * Gets the time of day for this date instances. * @return {TimeSpan} TimeSpan */ Date.prototype.getTimeOfDay = function () { return new TimeSpan(0, this.getHours(), this.getMinutes(), this.getSeconds(), this.getMilliseconds()); }; Date.TimeSpan = TimeSpan; if (typeof window !== "undefined" ) { // keeping API compatible for v1.x window.TimeSpan = TimeSpan; } }()); (function () { "use strict"; var attrs = ["years", "months", "days", "hours", "minutes", "seconds", "milliseconds"]; var gFn = function (attr) { return function () { return this[attr]; }; }; var sFn = function (attr) { return function (val) { this[attr] = val; return this; }; }; var addSetFuncs = function (context, attrs) { for (var i = 0; i < attrs.length ; i++) { var $a = attrs[i], $b = $a.slice(0, 1).toUpperCase() + $a.slice(1); context.prototype[$a] = 0; context.prototype["get" + $b] = gFn($a); context.prototype["set" + $b] = sFn($a); } }; var setMonthsAndYears = function (orient, d1, d2, context) { function inc() { d1.addMonths(-orient); context.months++; if (context.months === 12) { context.years++; context.months = 0; } } if (orient === +1) { while (d1 > d2) { inc(); } } else { while (d1 < d2) { inc(); } } context.months--; context.months *= orient; context.years *= orient; }; var adjustForDST = function(orient, startDate, endDate) { var hasDSTMismatch = (false === (startDate.isDaylightSavingTime() === endDate.isDaylightSavingTime())); if (hasDSTMismatch && orient === 1) { startDate.addHours(-1); } else if (hasDSTMismatch) { startDate.addHours(1); } }; /** * TimePeriod(startDate, endDate); * TimePeriod(years, months, days, hours, minutes, seconds, milliseconds); */ var TimePeriod = function (years, months, days, hours, minutes, seconds, milliseconds) { if (arguments.length === 7) { this.set(years, months, days, hours, minutes, seconds, milliseconds); } else if (arguments.length === 2 && arguments[0] instanceof Date && arguments[1] instanceof Date) { var startDate = arguments[0].clone(); var endDate = arguments[1].clone(); var orient = (startDate > endDate) ? +1 : -1; this.dates = { start: arguments[0].clone(), end: arguments[1].clone() }; setMonthsAndYears(orient, startDate, endDate, this); adjustForDST(orient, startDate, endDate); // // TODO - adjust for DST var diff = endDate - startDate; if (diff !== 0) { var ts = new TimeSpan(diff); this.set(this.years, this.months, ts.getDays(), ts.getHours(), ts.getMinutes(), ts.getSeconds(), ts.getMilliseconds()); } } return this; }; // create all the set functions. addSetFuncs(TimePeriod, attrs); TimePeriod.prototype.set = function (years, months, days, hours, minutes, seconds, milliseconds){ this.setYears(years || this.getYears()); this.setMonths(months || this.getMonths()); this.setDays(days || this.getDays()); this.setHours(hours || this.getHours()); this.setMinutes(minutes || this.getMinutes()); this.setSeconds(seconds || this.getSeconds()); this.setMilliseconds(milliseconds || this.getMilliseconds()); }; Date.TimePeriod = TimePeriod; if (typeof window !== "undefined") { // keeping API compatible for v1.x window.TimePeriod = TimePeriod; } }()); ================================================ FILE: build/date-ar-JO.js ================================================ /** * @overview datejs * @version 1.0.0-rc3 * @author Gregory Wild-Smith * @copyright 2015 Gregory Wild-Smith * @license MIT * @homepage https://github.com/abritinthebay/datejs */ /* * DateJS Culture String File * Country Code: ar-JO * Name: Arabic (Jordan) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["ar-JO"] = { "name": "ar-JO", "englishName": "Arabic (Jordan)", "nativeName": "العربية (الأردن)", "Sunday": "الاحد", "Monday": "الاثنين", "Tuesday": "الثلاثاء", "Wednesday": "الاربعاء", "Thursday": "الخميس", "Friday": "الجمعة", "Saturday": "السبت", "Sun": "الاحد", "Mon": "الاثنين", "Tue": "الثلاثاء", "Wed": "الاربعاء", "Thu": "الخميس", "Fri": "الجمعة", "Sat": "السبت", "Su": "أ", "Mo": "ا", "Tu": "ث", "We": "أ", "Th": "خ", "Fr": "ج", "Sa": "س", "S_Sun_Initial": "أ", "M_Mon_Initial": "ا", "T_Tue_Initial": "ث", "W_Wed_Initial": "أ", "T_Thu_Initial": "خ", "F_Fri_Initial": "ج", "S_Sat_Initial": "س", "January": "كانون الثاني", "February": "شباط", "March": "آذار", "April": "نيسان", "May": "أيار", "June": "حزيران", "July": "تموز", "August": "آب", "September": "أيلول", "October": "تشرين الأول", "November": "تشرين الثاني", "December": "كانون الأول", "Jan_Abbr": "كانون الثاني", "Feb_Abbr": "شباط", "Mar_Abbr": "آذار", "Apr_Abbr": "نيسان", "May_Abbr": "أيار", "Jun_Abbr": "حزيران", "Jul_Abbr": "تموز", "Aug_Abbr": "آب", "Sep_Abbr": "أيلول", "Oct_Abbr": "تشرين الأول", "Nov_Abbr": "تشرين الثاني", "Dec_Abbr": "كانون الأول", "AM": "ص", "PM": "م", "firstDayOfWeek": 6, "twoDigitYearMax": 2029, "mdy": "dmy", "M/d/yyyy": "dd/MM/yyyy", "dddd, MMMM dd, yyyy": "dd MMMM, yyyy", "h:mm tt": "hh:mm tt", "h:mm:ss tt": "hh:mm:ss tt", "dddd, MMMM dd, yyyy h:mm:ss tt": "dd MMMM, yyyy hh:mm:ss tt", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "dd MMMM", "MMMM, yyyy": "MMMM, yyyy", "/jan(uary)?/": "كانون الثاني", "/feb(ruary)?/": "شباط", "/mar(ch)?/": "آذار", "/apr(il)?/": "نيسان", "/may/": "أيار", "/jun(e)?/": "حزيران", "/jul(y)?/": "تموز", "/aug(ust)?/": "آب", "/sep(t(ember)?)?/": "أيلول", "/oct(ober)?/": "تشرين الأول", "/nov(ember)?/": "تشرين الثاني", "/dec(ember)?/": "كانون الأول", "/^su(n(day)?)?/": "^الاحد", "/^mo(n(day)?)?/": "^ا(1)?", "/^tu(e(s(day)?)?)?/": "^الثلاثاء", "/^we(d(nesday)?)?/": "^الاربعاء", "/^th(u(r(s(day)?)?)?)?/": "^الخميس", "/^fr(i(day)?)?/": "^الجمعة", "/^sa(t(urday)?)?/": "^السبت", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "ar-JO"; /** * @overview datejs * @version 1.0.0-rc3 * @author Gregory Wild-Smith * @copyright 2015 Gregory Wild-Smith * @license MIT * @homepage https://github.com/abritinthebay/datejs */(function () { var $D = Date; var lang = Date.CultureStrings ? Date.CultureStrings.lang : null; var loggedKeys = {}; // for debug purposes. var getText = { getFromKey: function (key, countryCode) { var output; if (Date.CultureStrings && Date.CultureStrings[countryCode] && Date.CultureStrings[countryCode][key]) { output = Date.CultureStrings[countryCode][key]; } else { output = getText.buildFromDefault(key); } if (key.charAt(0) === "/") { // Assume it's a regex output = getText.buildFromRegex(key, countryCode); } return output; }, getFromObjectValues: function (obj, countryCode) { var key, output = {}; for(key in obj) { if (obj.hasOwnProperty(key)) { output[key] = getText.getFromKey(obj[key], countryCode); } } return output; }, getFromObjectKeys: function (obj, countryCode) { var key, output = {}; for(key in obj) { if (obj.hasOwnProperty(key)) { output[getText.getFromKey(key, countryCode)] = obj[key]; } } return output; }, getFromArray: function (arr, countryCode) { var output = []; for (var i=0; i < arr.length; i++){ if (i in arr) { output[i] = getText.getFromKey(arr[i], countryCode); } } return output; }, buildFromDefault: function (key) { var output, length, split, last; switch(key) { case "name": output = "en-US"; break; case "englishName": output = "English (United States)"; break; case "nativeName": output = "English (United States)"; break; case "twoDigitYearMax": output = 2049; break; case "firstDayOfWeek": output = 0; break; default: output = key; split = key.split("_"); length = split.length; if (length > 1 && key.charAt(0) !== "/") { // if the key isn't a regex and it has a split. last = split[(length - 1)].toLowerCase(); if (last === "initial" || last === "abbr") { output = split[0]; } } break; } return output; }, buildFromRegex: function (key, countryCode) { var output; if (Date.CultureStrings && Date.CultureStrings[countryCode] && Date.CultureStrings[countryCode][key]) { output = new RegExp(Date.CultureStrings[countryCode][key], "i"); } else { output = new RegExp(key.replace(new RegExp("/", "g"),""), "i"); } return output; } }; var shallowMerge = function (obj1, obj2) { for (var attrname in obj2) { if (obj2.hasOwnProperty(attrname)) { obj1[attrname] = obj2[attrname]; } } }; var __ = function (key, language) { var countryCode = (language) ? language : lang; loggedKeys[key] = key; if (typeof key === "object") { if (key instanceof Array) { return getText.getFromArray(key, countryCode); } else { return getText.getFromObjectKeys(key, countryCode); } } else { return getText.getFromKey(key, countryCode); } }; var loadI18nScript = function (code) { // paatterned after jQuery's getScript. var url = Date.Config.i18n + code + ".js"; var head = document.getElementsByTagName("head")[0] || document.documentElement; var script = document.createElement("script"); script.src = url; var completed = false; var events = { done: function (){} // placeholder function }; // Attach handlers for all browsers script.onload = script.onreadystatechange = function() { if ( !completed && (!this.readyState || this.readyState === "loaded" || this.readyState === "complete") ) { events.done(); head.removeChild(script); } }; setTimeout(function() { head.insertBefore(script, head.firstChild); }, 0); // allows return to execute first return { done: function (cb) { events.done = function() { if (cb) { setTimeout(cb,0); } }; } }; }; var buildInfo = { buildFromMethodHash: function (obj) { var key; for(key in obj) { if (obj.hasOwnProperty(key)) { obj[key] = buildInfo[obj[key]](); } } return obj; }, timeZoneDST: function () { var DST = { "CHADT": "+1345", "NZDT": "+1300", "AEDT": "+1100", "ACDT": "+1030", "AZST": "+0500", "IRDT": "+0430", "EEST": "+0300", "CEST": "+0200", "BST": "+0100", "PMDT": "-0200", "ADT": "-0300", "NDT": "-0230", "EDT": "-0400", "CDT": "-0500", "MDT": "-0600", "PDT": "-0700", "AKDT": "-0800", "HADT": "-0900" }; return __(DST); }, timeZoneStandard: function () { var standard = { "LINT": "+1400", "TOT": "+1300", "CHAST": "+1245", "NZST": "+1200", "NFT": "+1130", "SBT": "+1100", "AEST": "+1000", "ACST": "+0930", "JST": "+0900", "CWST": "+0845", "CT": "+0800", "ICT": "+0700", "MMT": "+0630", "BST": "+0600", "NPT": "+0545", "IST": "+0530", "PKT": "+0500", "AFT": "+0430", "MSK": "+0400", "IRST": "+0330", "FET": "+0300", "EET": "+0200", "CET": "+0100", "GMT": "+0000", "UTC": "+0000", "CVT": "-0100", "GST": "-0200", "BRT": "-0300", "NST": "-0330", "AST": "-0400", "EST": "-0500", "CST": "-0600", "MST": "-0700", "PST": "-0800", "AKST": "-0900", "MIT": "-0930", "HST": "-1000", "SST": "-1100", "BIT": "-1200" }; return __(standard); }, timeZones: function (data) { var zone; data.timezones = []; for (zone in data.abbreviatedTimeZoneStandard) { if (data.abbreviatedTimeZoneStandard.hasOwnProperty(zone)) { data.timezones.push({ name: zone, offset: data.abbreviatedTimeZoneStandard[zone]}); } } for (zone in data.abbreviatedTimeZoneDST) { if (data.abbreviatedTimeZoneDST.hasOwnProperty(zone)) { data.timezones.push({ name: zone, offset: data.abbreviatedTimeZoneDST[zone], dst: true}); } } return data.timezones; }, days: function () { return __(["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"]); }, dayAbbr: function () { return __(["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"]); }, dayShortNames: function () { return __(["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"]); }, dayFirstLetters: function () { return __(["S_Sun_Initial", "M_Mon_Initial", "T_Tues_Initial", "W_Wed_Initial", "T_Thu_Initial", "F_Fri_Initial", "S_Sat_Initial"]); }, months: function () { return __(["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"]); }, monthAbbr: function () { return __(["Jan_Abbr", "Feb_Abbr", "Mar_Abbr", "Apr_Abbr", "May_Abbr", "Jun_Abbr", "Jul_Abbr", "Aug_Abbr", "Sep_Abbr", "Oct_Abbr", "Nov_Abbr", "Dec_Abbr"]); }, formatPatterns: function () { return getText.getFromObjectValues({ shortDate: "M/d/yyyy", longDate: "dddd, MMMM dd, yyyy", shortTime: "h:mm tt", longTime: "h:mm:ss tt", fullDateTime: "dddd, MMMM dd, yyyy h:mm:ss tt", sortableDateTime: "yyyy-MM-ddTHH:mm:ss", universalSortableDateTime: "yyyy-MM-dd HH:mm:ssZ", rfc1123: "ddd, dd MMM yyyy HH:mm:ss", monthDay: "MMMM dd", yearMonth: "MMMM, yyyy" }, Date.i18n.currentLanguage()); }, regex: function () { return getText.getFromObjectValues({ inTheMorning: "/( in the )(morn(ing)?)\\b/", thisMorning: "/(this )(morn(ing)?)\\b/", amThisMorning: "/(\b\\d(am)? )(this )(morn(ing)?)/", inTheEvening: "/( in the )(even(ing)?)\\b/", thisEvening: "/(this )(even(ing)?)\\b/", pmThisEvening: "/(\b\\d(pm)? )(this )(even(ing)?)/", jan: "/jan(uary)?/", feb: "/feb(ruary)?/", mar: "/mar(ch)?/", apr: "/apr(il)?/", may: "/may/", jun: "/jun(e)?/", jul: "/jul(y)?/", aug: "/aug(ust)?/", sep: "/sep(t(ember)?)?/", oct: "/oct(ober)?/", nov: "/nov(ember)?/", dec: "/dec(ember)?/", sun: "/^su(n(day)?)?/", mon: "/^mo(n(day)?)?/", tue: "/^tu(e(s(day)?)?)?/", wed: "/^we(d(nesday)?)?/", thu: "/^th(u(r(s(day)?)?)?)?/", fri: "/fr(i(day)?)?/", sat: "/^sa(t(urday)?)?/", future: "/^next/", past: "/^last|past|prev(ious)?/", add: "/^(\\+|aft(er)?|from|hence)/", subtract: "/^(\\-|bef(ore)?|ago)/", yesterday: "/^yes(terday)?/", today: "/^t(od(ay)?)?/", tomorrow: "/^tom(orrow)?/", now: "/^n(ow)?/", millisecond: "/^ms|milli(second)?s?/", second: "/^sec(ond)?s?/", minute: "/^mn|min(ute)?s?/", hour: "/^h(our)?s?/", week: "/^w(eek)?s?/", month: "/^m(onth)?s?/", day: "/^d(ay)?s?/", year: "/^y(ear)?s?/", shortMeridian: "/^(a|p)/", longMeridian: "/^(a\\.?m?\\.?|p\\.?m?\\.?)/", timezone: "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/", ordinalSuffix: "/^\\s*(st|nd|rd|th)/", timeContext: "/^\\s*(\\:|a(?!u|p)|p)/" }, Date.i18n.currentLanguage()); } }; var CultureInfo = function () { var info = getText.getFromObjectValues({ name: "name", englishName: "englishName", nativeName: "nativeName", amDesignator: "AM", pmDesignator: "PM", firstDayOfWeek: "firstDayOfWeek", twoDigitYearMax: "twoDigitYearMax", dateElementOrder: "mdy" }, Date.i18n.currentLanguage()); var constructedInfo = buildInfo.buildFromMethodHash({ dayNames: "days", abbreviatedDayNames: "dayAbbr", shortestDayNames: "dayShortNames", firstLetterDayNames: "dayFirstLetters", monthNames: "months", abbreviatedMonthNames: "monthAbbr", formatPatterns: "formatPatterns", regexPatterns: "regex", abbreviatedTimeZoneDST: "timeZoneDST", abbreviatedTimeZoneStandard: "timeZoneStandard" }); shallowMerge(info, constructedInfo); buildInfo.timeZones(info); return info; }; $D.i18n = { __: function (key, lang) { return __(key, lang); }, currentLanguage: function () { return lang || "en-US"; }, setLanguage: function (code, force, cb) { var async = false; if (force || code === "en-US" || (!!Date.CultureStrings && !!Date.CultureStrings[code])) { lang = code; Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings.lang = code; Date.CultureInfo = new CultureInfo(); } else { if (!(!!Date.CultureStrings && !!Date.CultureStrings[code])) { if (typeof exports !== "undefined" && this.exports !== exports) { // we're in a Node enviroment, load it using require try { require("../i18n/" + code + ".js"); lang = code; Date.CultureStrings.lang = code; Date.CultureInfo = new CultureInfo(); } catch (e) { // var str = "The language for '" + code + "' could not be loaded by Node. It likely does not exist."; throw new Error("The DateJS IETF language tag '" + code + "' could not be loaded by Node. It likely does not exist."); } } else if (Date.Config && Date.Config.i18n) { // we know the location of the files, so lets load them async = true; loadI18nScript(code).done(function(){ lang = code; Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings.lang = code; Date.CultureInfo = new CultureInfo(); $D.Parsing.Normalizer.buildReplaceData(); // because this is async if ($D.Grammar) { $D.Grammar.buildGrammarFormats(); // so we can parse those strings... } if (cb) { setTimeout(cb,0); } }); } else { Date.console.error("The DateJS IETF language tag '" + code + "' is not available and has not been loaded."); return false; } } } $D.Parsing.Normalizer.buildReplaceData(); // rebuild normalizer strings if ($D.Grammar) { $D.Grammar.buildGrammarFormats(); // so we can parse those strings... } if (!async && cb) { setTimeout(cb,0); } }, getLoggedKeys: function () { return loggedKeys; }, updateCultureInfo: function () { Date.CultureInfo = new CultureInfo(); } }; $D.i18n.updateCultureInfo(); // run automatically }()); (function () { var $D = Date, $P = $D.prototype, p = function (s, l) { if (!l) { l = 2; } return ("000" + s).slice(l * -1); }; if (typeof window !== "undefined" && typeof window.console !== "undefined" && typeof window.console.log !== "undefined") { $D.console = console; // used only to raise non-critical errors if available } else { // set mock so we don't give errors. $D.console = { log: function(){}, error: function(){} }; } $D.Config = $D.Config || {}; $D.initOverloads = function() { /** * Overload of Date.now. Allows an alternate call for Date.now where it returns the * current Date as an object rather than just milliseconds since the Unix Epoch. * * Also provides an implementation of now() for browsers (IE<9) that don't have it. * * Backwards compatible so with work with either: * Date.now() [returns ms] * or * Date.now(true) [returns Date] */ if (!$D.now) { $D._now = function now() { return new Date().getTime(); }; } else if (!$D._now) { $D._now = $D.now; } $D.now = function (returnObj) { if (returnObj) { return $D.present(); } else { return $D._now(); } }; if ( !$P.toISOString ) { $P.toISOString = function() { return this.getUTCFullYear() + "-" + p(this.getUTCMonth() + 1) + "-" + p(this.getUTCDate()) + "T" + p(this.getUTCHours()) + ":" + p(this.getUTCMinutes()) + ":" + p(this.getUTCSeconds()) + "." + String( (this.getUTCMilliseconds()/1000).toFixed(3)).slice(2, 5) + "Z"; }; } // private if ( $P._toString === undefined ){ $P._toString = $P.toString; } }; $D.initOverloads(); /** * Gets a date that is set to the current date. The time is set to the start of the day (00:00 or 12:00 AM). * @return {Date} The current date. */ $D.today = function () { return new Date().clearTime(); }; /** * Gets a date that is set to the current date and time (same as new Date, but chainable) * @return {Date} The current date. */ $D.present = function () { return new Date(); }; /** * Compares the first date to the second date and returns an number indication of their relative values. * @param {Date} First Date object to compare [Required]. * @param {Date} Second Date object to compare to [Required]. * @return {Number} -1 = date1 is lessthan date2. 0 = values are equal. 1 = date1 is greaterthan date2. */ $D.compare = function (date1, date2) { if (isNaN(date1) || isNaN(date2)) { throw new Error(date1 + " - " + date2); } else if (date1 instanceof Date && date2 instanceof Date) { return (date1 < date2) ? -1 : (date1 > date2) ? 1 : 0; } else { throw new TypeError(date1 + " - " + date2); } }; /** * Compares the first Date object to the second Date object and returns true if they are equal. * @param {Date} First Date object to compare [Required] * @param {Date} Second Date object to compare to [Required] * @return {Boolean} true if dates are equal. false if they are not equal. */ $D.equals = function (date1, date2) { return (date1.compareTo(date2) === 0); }; /** * Gets the language appropriate day name when given the day number(0-6) * eg - 0 == Sunday * @return {String} The day name */ $D.getDayName = function (n) { return Date.CultureInfo.dayNames[n]; }; /** * Gets the day number (0-6) if given a CultureInfo specific string which is a valid dayName, abbreviatedDayName or shortestDayName (two char). * @param {String} The name of the day (eg. "Monday, "Mon", "tuesday", "tue", "We", "we"). * @return {Number} The day number */ $D.getDayNumberFromName = function (name) { var n = Date.CultureInfo.dayNames, m = Date.CultureInfo.abbreviatedDayNames, o = Date.CultureInfo.shortestDayNames, s = name.toLowerCase(); for (var i = 0; i < n.length; i++) { if (n[i].toLowerCase() === s || m[i].toLowerCase() === s || o[i].toLowerCase() === s) { return i; } } return -1; }; /** * Gets the month number (0-11) if given a Culture Info specific string which is a valid monthName or abbreviatedMonthName. * @param {String} The name of the month (eg. "February, "Feb", "october", "oct"). * @return {Number} The day number */ $D.getMonthNumberFromName = function (name) { var n = Date.CultureInfo.monthNames, m = Date.CultureInfo.abbreviatedMonthNames, s = name.toLowerCase(); for (var i = 0; i < n.length; i++) { if (n[i].toLowerCase() === s || m[i].toLowerCase() === s) { return i; } } return -1; }; /** * Gets the language appropriate month name when given the month number(0-11) * eg - 0 == January * @return {String} The month name */ $D.getMonthName = function (n) { return Date.CultureInfo.monthNames[n]; }; /** * Determines if the current date instance is within a LeapYear. * @param {Number} The year. * @return {Boolean} true if date is within a LeapYear, otherwise false. */ $D.isLeapYear = function (year) { return ((year % 4 === 0 && year % 100 !== 0) || year % 400 === 0); }; /** * Gets the number of days in the month, given a year and month value. Automatically corrects for LeapYear. * @param {Number} The year. * @param {Number} The month (0-11). * @return {Number} The number of days in the month. */ $D.getDaysInMonth = function (year, month) { if (!month && $D.validateMonth(year)) { month = year; year = Date.today().getFullYear(); } return [31, ($D.isLeapYear(year) ? 29 : 28), 31, 30, 31, 30, 31, 31, 30, 31, 30, 31][month]; }; $P.getDaysInMonth = function () { return $D.getDaysInMonth(this.getFullYear(), this.getMonth()); }; $D.getTimezoneAbbreviation = function (offset, dst) { var p, n = (dst || false) ? Date.CultureInfo.abbreviatedTimeZoneDST : Date.CultureInfo.abbreviatedTimeZoneStandard; for (p in n) { if (n.hasOwnProperty(p)) { if (n[p] === offset) { return p; } } } return null; }; $D.getTimezoneOffset = function (name, dst) { var i, a =[], z = Date.CultureInfo.timezones; if (!name) { name = (new Date()).getTimezone();} for (i = 0; i < z.length; i++) { if (z[i].name === name.toUpperCase()) { a.push(i); } } if (!z[a[0]]) { return null; } if (a.length === 1 || !dst) { return z[a[0]].offset; } else { for (i=0; i < a.length; i++) { if (z[a[i]].dst) { return z[a[i]].offset; } } } }; $D.getQuarter = function (d) { d = d || new Date(); // If no date supplied, use today var q = [1,2,3,4]; return q[Math.floor(d.getMonth() / 3)]; // ~~~ is a bitwise op. Faster than Math.floor }; $D.getDaysLeftInQuarter = function (d) { d = d || new Date(); var qEnd = new Date(d); qEnd.setMonth(qEnd.getMonth() + 3 - qEnd.getMonth() % 3, 0); return Math.floor((qEnd - d) / 8.64e7); }; // private var validate = function (n, min, max, name) { name = name ? name : "Object"; if (typeof n === "undefined") { return false; } else if (typeof n !== "number") { throw new TypeError(n + " is not a Number."); } else if (n < min || n > max) { // As failing validation is *not* an exceptional circumstance // lets not throw a RangeError Exception here. // It's semantically correct but it's not sensible. return false; } return true; }; /** * Validates the number is within an acceptable range for milliseconds [0-999]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateMillisecond = function (value) { return validate(value, 0, 999, "millisecond"); }; /** * Validates the number is within an acceptable range for seconds [0-59]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateSecond = function (value) { return validate(value, 0, 59, "second"); }; /** * Validates the number is within an acceptable range for minutes [0-59]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateMinute = function (value) { return validate(value, 0, 59, "minute"); }; /** * Validates the number is within an acceptable range for hours [0-23]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateHour = function (value) { return validate(value, 0, 23, "hour"); }; /** * Validates the number is within an acceptable range for the days in a month [0-MaxDaysInMonth]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateDay = function (value, year, month) { if (year === undefined || year === null || month === undefined || month === null) { return false;} return validate(value, 1, $D.getDaysInMonth(year, month), "day"); }; /** * Validates the number is within an acceptable range for months [0-11]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateWeek = function (value) { return validate(value, 0, 53, "week"); }; /** * Validates the number is within an acceptable range for months [0-11]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateMonth = function (value) { return validate(value, 0, 11, "month"); }; /** * Validates the number is within an acceptable range for years. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateYear = function (value) { /** * Per ECMAScript spec the range of times supported by Date objects is * exactly -100,000,000 days to +100,000,000 days measured relative to * midnight at the beginning of 01 January, 1970 UTC. * This gives a range of 8,640,000,000,000,000 milliseconds to either * side of 01 January, 1970 UTC. * * Earliest possible date: Tue, 20 Apr 271,822 B.C. 00:00:00 UTC * Latest possible date: Sat, 13 Sep 275,760 00:00:00 UTC */ return validate(value, -271822, 275760, "year"); }; $D.validateTimezone = function(value) { var timezones = {"ACDT":1,"ACST":1,"ACT":1,"ADT":1,"AEDT":1,"AEST":1,"AFT":1,"AKDT":1,"AKST":1,"AMST":1,"AMT":1,"ART":1,"AST":1,"AWDT":1,"AWST":1,"AZOST":1,"AZT":1,"BDT":1,"BIOT":1,"BIT":1,"BOT":1,"BRT":1,"BST":1,"BTT":1,"CAT":1,"CCT":1,"CDT":1,"CEDT":1,"CEST":1,"CET":1,"CHADT":1,"CHAST":1,"CHOT":1,"ChST":1,"CHUT":1,"CIST":1,"CIT":1,"CKT":1,"CLST":1,"CLT":1,"COST":1,"COT":1,"CST":1,"CT":1,"CVT":1,"CWST":1,"CXT":1,"DAVT":1,"DDUT":1,"DFT":1,"EASST":1,"EAST":1,"EAT":1,"ECT":1,"EDT":1,"EEDT":1,"EEST":1,"EET":1,"EGST":1,"EGT":1,"EIT":1,"EST":1,"FET":1,"FJT":1,"FKST":1,"FKT":1,"FNT":1,"GALT":1,"GAMT":1,"GET":1,"GFT":1,"GILT":1,"GIT":1,"GMT":1,"GST":1,"GYT":1,"HADT":1,"HAEC":1,"HAST":1,"HKT":1,"HMT":1,"HOVT":1,"HST":1,"ICT":1,"IDT":1,"IOT":1,"IRDT":1,"IRKT":1,"IRST":1,"IST":1,"JST":1,"KGT":1,"KOST":1,"KRAT":1,"KST":1,"LHST":1,"LINT":1,"MAGT":1,"MART":1,"MAWT":1,"MDT":1,"MET":1,"MEST":1,"MHT":1,"MIST":1,"MIT":1,"MMT":1,"MSK":1,"MST":1,"MUT":1,"MVT":1,"MYT":1,"NCT":1,"NDT":1,"NFT":1,"NPT":1,"NST":1,"NT":1,"NUT":1,"NZDT":1,"NZST":1,"OMST":1,"ORAT":1,"PDT":1,"PET":1,"PETT":1,"PGT":1,"PHOT":1,"PHT":1,"PKT":1,"PMDT":1,"PMST":1,"PONT":1,"PST":1,"PYST":1,"PYT":1,"RET":1,"ROTT":1,"SAKT":1,"SAMT":1,"SAST":1,"SBT":1,"SCT":1,"SGT":1,"SLST":1,"SRT":1,"SST":1,"SYOT":1,"TAHT":1,"THA":1,"TFT":1,"TJT":1,"TKT":1,"TLT":1,"TMT":1,"TOT":1,"TVT":1,"UCT":1,"ULAT":1,"UTC":1,"UYST":1,"UYT":1,"UZT":1,"VET":1,"VLAT":1,"VOLT":1,"VOST":1,"VUT":1,"WAKT":1,"WAST":1,"WAT":1,"WEDT":1,"WEST":1,"WET":1,"WST":1,"YAKT":1,"YEKT":1,"Z":1}; return (timezones[value] === 1); }; $D.validateTimezoneOffset= function(value) { // timezones go from +14hrs to -12hrs, the +X hours are negative offsets. return (value > -841 && value < 721); }; }()); (function () { var $D = Date, $P = $D.prototype, p = function (s, l) { if (!l) { l = 2; } return ("000" + s).slice(l * -1); }; var validateConfigObject = function (obj) { var result = {}, self = this, prop, testFunc; testFunc = function (prop, func, value) { if (prop === "day") { var month = (obj.month !== undefined) ? obj.month : self.getMonth(); var year = (obj.year !== undefined) ? obj.year : self.getFullYear(); return $D[func](value, year, month); } else { return $D[func](value); } }; for (prop in obj) { if (Object.prototype.hasOwnProperty.call(obj, prop)) { var func = "validate" + prop.charAt(0).toUpperCase() + prop.slice(1); if ($D[func] && obj[prop] !== null && testFunc(prop, func, obj[prop])) { result[prop] = obj[prop]; } } } return result; }; /** * Resets the time of this Date object to 12:00 AM (00:00), which is the start of the day. * @param {Boolean} .clone() this date instance before clearing Time * @return {Date} this */ $P.clearTime = function () { this.setHours(0); this.setMinutes(0); this.setSeconds(0); this.setMilliseconds(0); return this; }; /** * Resets the time of this Date object to the current time ('now'). * @return {Date} this */ $P.setTimeToNow = function () { var n = new Date(); this.setHours(n.getHours()); this.setMinutes(n.getMinutes()); this.setSeconds(n.getSeconds()); this.setMilliseconds(n.getMilliseconds()); return this; }; /** * Returns a new Date object that is an exact date and time copy of the original instance. * @return {Date} A new Date instance */ $P.clone = function () { return new Date(this.getTime()); }; /** * Compares this instance to a Date object and returns an number indication of their relative values. * @param {Date} Date object to compare [Required] * @return {Number} -1 = this is lessthan date. 0 = values are equal. 1 = this is greaterthan date. */ $P.compareTo = function (date) { return Date.compare(this, date); }; /** * Compares this instance to another Date object and returns true if they are equal. * @param {Date} Date object to compare. If no date to compare, new Date() [now] is used. * @return {Boolean} true if dates are equal. false if they are not equal. */ $P.equals = function (date) { return Date.equals(this, (date !== undefined ? date : new Date())); }; /** * Determines if this instance is between a range of two dates or equal to either the start or end dates. * @param {Date} Start of range [Required] * @param {Date} End of range [Required] * @return {Boolean} true is this is between or equal to the start and end dates, else false */ $P.between = function (start, end) { return this.getTime() >= start.getTime() && this.getTime() <= end.getTime(); }; /** * Determines if this date occurs after the date to compare to. * @param {Date} Date object to compare. If no date to compare, new Date() ("now") is used. * @return {Boolean} true if this date instance is greater than the date to compare to (or "now"), otherwise false. */ $P.isAfter = function (date) { return this.compareTo(date || new Date()) === 1; }; /** * Determines if this date occurs before the date to compare to. * @param {Date} Date object to compare. If no date to compare, new Date() ("now") is used. * @return {Boolean} true if this date instance is less than the date to compare to (or "now"). */ $P.isBefore = function (date) { return (this.compareTo(date || new Date()) === -1); }; /** * Determines if the current Date instance occurs today. * @return {Boolean} true if this date instance is 'today', otherwise false. */ /** * Determines if the current Date instance occurs on the same Date as the supplied 'date'. * If no 'date' to compare to is provided, the current Date instance is compared to 'today'. * @param {date} Date object to compare. If no date to compare, the current Date ("now") is used. * @return {Boolean} true if this Date instance occurs on the same Day as the supplied 'date'. */ $P.isToday = $P.isSameDay = function (date) { return this.clone().clearTime().equals((date || new Date()).clone().clearTime()); }; /** * Adds the specified number of milliseconds to this instance. * @param {Number} The number of milliseconds to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addMilliseconds = function (value) { if (!value) { return this; } this.setTime(this.getTime() + value * 1); return this; }; /** * Adds the specified number of seconds to this instance. * @param {Number} The number of seconds to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addSeconds = function (value) { if (!value) { return this; } return this.addMilliseconds(value * 1000); }; /** * Adds the specified number of seconds to this instance. * @param {Number} The number of seconds to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addMinutes = function (value) { if (!value) { return this; } return this.addMilliseconds(value * 60000); // 60*1000 }; /** * Adds the specified number of hours to this instance. * @param {Number} The number of hours to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addHours = function (value) { if (!value) { return this; } return this.addMilliseconds(value * 3600000); // 60*60*1000 }; /** * Adds the specified number of days to this instance. * @param {Number} The number of days to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addDays = function (value) { if (!value) { return this; } this.setDate(this.getDate() + value * 1); return this; }; /** * Adds the specified number of weekdays (ie - not sat or sun) to this instance. * @param {Number} The number of days to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addWeekdays = function (value) { if (!value) { return this; } var day = this.getDay(); var weeks = (Math.ceil(Math.abs(value)/7)); if (day === 0 || day === 6) { if (value > 0) { this.next().monday(); this.addDays(-1); day = this.getDay(); } } if (value < 0) { while (value < 0) { this.addDays(-1); day = this.getDay(); if (day !== 0 && day !== 6) { value++; } } return this; } else if (value > 5 || (6-day) <= value) { value = value + (weeks * 2); } return this.addDays(value); }; /** * Adds the specified number of weeks to this instance. * @param {Number} The number of weeks to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addWeeks = function (value) { if (!value) { return this; } return this.addDays(value * 7); }; /** * Adds the specified number of months to this instance. * @param {Number} The number of months to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addMonths = function (value) { if (!value) { return this; } var n = this.getDate(); this.setDate(1); this.setMonth(this.getMonth() + value * 1); this.setDate(Math.min(n, $D.getDaysInMonth(this.getFullYear(), this.getMonth()))); return this; }; $P.addQuarters = function (value) { if (!value) { return this; } // note this will take you to the same point in the quarter as you are now. // i.e. - if you are 15 days into the quarter you'll be 15 days into the resulting one. // bonus: this allows adding fractional quarters return this.addMonths(value * 3); }; /** * Adds the specified number of years to this instance. * @param {Number} The number of years to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addYears = function (value) { if (!value) { return this; } return this.addMonths(value * 12); }; /** * Adds (or subtracts) to the value of the years, months, weeks, days, hours, minutes, seconds, milliseconds of the date instance using given configuration object. Positive and Negative values allowed. * Example

	Date.today().add( { days: 1, months: 1 } )

	new Date().add( { years: -1 } )
	
* @param {Object} Configuration object containing attributes (months, days, etc.) * @return {Date} this */ $P.add = function (config) { if (typeof config === "number") { this._orient = config; return this; } var x = config; if (x.day) { // If we should be a different date than today (eg: for 'tomorrow -1d', etc). // Should only effect parsing, not direct usage (eg, Finish and FinishExact) if ((x.day - this.getDate()) !== 0) { this.setDate(x.day); } } if (x.milliseconds) { this.addMilliseconds(x.milliseconds); } if (x.seconds) { this.addSeconds(x.seconds); } if (x.minutes) { this.addMinutes(x.minutes); } if (x.hours) { this.addHours(x.hours); } if (x.weeks) { this.addWeeks(x.weeks); } if (x.months) { this.addMonths(x.months); } if (x.years) { this.addYears(x.years); } if (x.days) { this.addDays(x.days); } return this; }; /** * Get the week number. Week one (1) is the week which contains the first Thursday of the year. Monday is considered the first day of the week. * The .getWeek() function does NOT convert the date to UTC. The local datetime is used. * Please use .getISOWeek() to get the week of the UTC converted date. * @return {Number} 1 to 53 */ $P.getWeek = function (utc) { // Create a copy of this date object var self, target = new Date(this.valueOf()); if (utc) { target.addMinutes(target.getTimezoneOffset()); self = target.clone(); } else { self = this; } // ISO week date weeks start on monday // so correct the day number var dayNr = (self.getDay() + 6) % 7; // ISO 8601 states that week 1 is the week // with the first thursday of that year. // Set the target date to the thursday in the target week target.setDate(target.getDate() - dayNr + 3); // Store the millisecond value of the target date var firstThursday = target.valueOf(); // Set the target to the first thursday of the year // First set the target to january first target.setMonth(0, 1); // Not a thursday? Correct the date to the next thursday if (target.getDay() !== 4) { target.setMonth(0, 1 + ((4 - target.getDay()) + 7) % 7); } // The weeknumber is the number of weeks between the // first thursday of the year and the thursday in the target week return 1 + Math.ceil((firstThursday - target) / 604800000); // 604800000 = 7 * 24 * 3600 * 1000 }; /** * Get the ISO 8601 week number. Week one ("01") is the week which contains the first Thursday of the year. Monday is considered the first day of the week. * The .getISOWeek() function does convert the date to it's UTC value. Please use .getWeek() to get the week of the local date. * @return {String} "01" to "53" */ $P.getISOWeek = function () { return p(this.getWeek(true)); }; /** * Moves the date to Monday of the week set. Week one (1) is the week which contains the first Thursday of the year. * @param {Number} A Number (1 to 53) that represents the week of the year. * @return {Date} this */ $P.setWeek = function (n) { if ((n - this.getWeek()) === 0) { if (this.getDay() !== 1) { return this.moveToDayOfWeek(1, (this.getDay() > 1 ? -1 : 1)); } else { return this; } } else { return this.moveToDayOfWeek(1, (this.getDay() > 1 ? -1 : 1)).addWeeks(n - this.getWeek()); } }; $P.setQuarter = function (qtr) { var month = Math.abs(((qtr-1) * 3) + 1); return this.setMonth(month, 1); }; $P.getQuarter = function () { return Date.getQuarter(this); }; $P.getDaysLeftInQuarter = function () { return Date.getDaysLeftInQuarter(this); }; /** * Moves the date to the next n'th occurrence of the dayOfWeek starting from the beginning of the month. The number (-1) is a magic number and will return the last occurrence of the dayOfWeek in the month. * @param {Number} The dayOfWeek to move to * @param {Number} The n'th occurrence to move to. Use (-1) to return the last occurrence in the month * @return {Date} this */ $P.moveToNthOccurrence = function (dayOfWeek, occurrence) { if (dayOfWeek === "Weekday") { if (occurrence > 0) { this.moveToFirstDayOfMonth(); if (this.is().weekday()) { occurrence -= 1; } } else if (occurrence < 0) { this.moveToLastDayOfMonth(); if (this.is().weekday()) { occurrence += 1; } } else { return this; } return this.addWeekdays(occurrence); } var shift = 0; if (occurrence > 0) { shift = occurrence - 1; } else if (occurrence === -1) { this.moveToLastDayOfMonth(); if (this.getDay() !== dayOfWeek) { this.moveToDayOfWeek(dayOfWeek, -1); } return this; } return this.moveToFirstDayOfMonth().addDays(-1).moveToDayOfWeek(dayOfWeek, +1).addWeeks(shift); }; var moveToN = function (getFunc, addFunc, nVal) { return function (value, orient) { var diff = (value - this[getFunc]() + nVal * (orient || +1)) % nVal; return this[addFunc]((diff === 0) ? diff += nVal * (orient || +1) : diff); }; }; /** * Move to the next or last dayOfWeek based on the orient value. * @param {Number} The dayOfWeek to move to * @param {Number} Forward (+1) or Back (-1). Defaults to +1. [Optional] * @return {Date} this */ $P.moveToDayOfWeek = moveToN("getDay", "addDays", 7); /** * Move to the next or last month based on the orient value. * @param {Number} The month to move to. 0 = January, 11 = December * @param {Number} Forward (+1) or Back (-1). Defaults to +1. [Optional] * @return {Date} this */ $P.moveToMonth = moveToN("getMonth", "addMonths", 12); /** * Get the Ordinate of the current day ("th", "st", "rd"). * @return {String} */ $P.getOrdinate = function () { var num = this.getDate(); return ord(num); }; /** * Get the Ordinal day (numeric day number) of the year, adjusted for leap year. * @return {Number} 1 through 365 (366 in leap years) */ $P.getOrdinalNumber = function () { return Math.ceil((this.clone().clearTime() - new Date(this.getFullYear(), 0, 1)) / 86400000) + 1; }; /** * Get the time zone abbreviation of the current date. * @return {String} The abbreviated time zone name (e.g. "EST") */ $P.getTimezone = function () { return $D.getTimezoneAbbreviation(this.getUTCOffset(), this.isDaylightSavingTime()); }; $P.setTimezoneOffset = function (offset) { var here = this.getTimezoneOffset(), there = Number(offset) * -6 / 10; return (there || there === 0) ? this.addMinutes(there - here) : this; }; $P.setTimezone = function (offset) { return this.setTimezoneOffset($D.getTimezoneOffset(offset)); }; /** * Indicates whether Daylight Saving Time is observed in the current time zone. * @return {Boolean} true|false */ $P.hasDaylightSavingTime = function () { return (Date.today().set({month: 0, day: 1}).getTimezoneOffset() !== Date.today().set({month: 6, day: 1}).getTimezoneOffset()); }; /** * Indicates whether this Date instance is within the Daylight Saving Time range for the current time zone. * @return {Boolean} true|false */ $P.isDaylightSavingTime = function () { return Date.today().set({month: 0, day: 1}).getTimezoneOffset() !== this.getTimezoneOffset(); }; /** * Get the offset from UTC of the current date. * @return {String} The 4-character offset string prefixed with + or - (e.g. "-0500") */ $P.getUTCOffset = function (offset) { var n = (offset || this.getTimezoneOffset()) * -10 / 6, r; if (n < 0) { r = (n - 10000).toString(); return r.charAt(0) + r.substr(2); } else { r = (n + 10000).toString(); return "+" + r.substr(1); } }; /** * Returns the number of milliseconds between this date and date. * @param {Date} Defaults to now * @return {Number} The diff in milliseconds */ $P.getElapsed = function (date) { return (date || new Date()) - this; }; /** * Set the value of year, month, day, hour, minute, second, millisecond of date instance using given configuration object. * Example

	Date.today().set( { day: 20, month: 1 } )

	new Date().set( { millisecond: 0 } )
	
* * @param {Object} Configuration object containing attributes (month, day, etc.) * @return {Date} this */ $P.set = function (config) { config = validateConfigObject.call(this, config); var key; for (key in config) { if (Object.prototype.hasOwnProperty.call(config, key)) { var name = key.charAt(0).toUpperCase() + key.slice(1); var addFunc, getFunc; if (key !== "week" && key !== "month" && key !== "timezone" && key !== "timezoneOffset") { name += "s"; } addFunc = "add" + name; getFunc = "get" + name; if (key === "month") { addFunc = addFunc + "s"; } else if (key === "year"){ getFunc = "getFullYear"; } if (key !== "day" && key !== "timezone" && key !== "timezoneOffset" && key !== "week" && key !== "hour") { this[addFunc](config[key] - this[getFunc]()); } else if ( key === "timezone"|| key === "timezoneOffset" || key === "week" || key === "hour") { this["set"+name](config[key]); } } } // day has to go last because you can't validate the day without first knowing the month if (config.day) { this.addDays(config.day - this.getDate()); } return this; }; /** * Moves the date to the first day of the month. * @return {Date} this */ $P.moveToFirstDayOfMonth = function () { return this.set({ day: 1 }); }; /** * Moves the date to the last day of the month. * @return {Date} this */ $P.moveToLastDayOfMonth = function () { return this.set({ day: $D.getDaysInMonth(this.getFullYear(), this.getMonth())}); }; /** * Converts the value of the current Date object to its equivalent string representation. * Format Specifiers * CUSTOM DATE AND TIME FORMAT STRINGS * Format Description Example * ------ --------------------------------------------------------------------------- ----------------------- * s The seconds of the minute between 0-59. "0" to "59" * ss The seconds of the minute with leading zero if required. "00" to "59" * * m The minute of the hour between 0-59. "0" or "59" * mm The minute of the hour with leading zero if required. "00" or "59" * * h The hour of the day between 1-12. "1" to "12" * hh The hour of the day with leading zero if required. "01" to "12" * * H The hour of the day between 0-23. "0" to "23" * HH The hour of the day with leading zero if required. "00" to "23" * * d The day of the month between 1 and 31. "1" to "31" * dd The day of the month with leading zero if required. "01" to "31" * ddd Abbreviated day name. Date.CultureInfo.abbreviatedDayNames. "Mon" to "Sun" * dddd The full day name. Date.CultureInfo.dayNames. "Monday" to "Sunday" * * M The month of the year between 1-12. "1" to "12" * MM The month of the year with leading zero if required. "01" to "12" * MMM Abbreviated month name. Date.CultureInfo.abbreviatedMonthNames. "Jan" to "Dec" * MMMM The full month name. Date.CultureInfo.monthNames. "January" to "December" * * yy The year as a two-digit number. "99" or "08" * yyyy The full four digit year. "1999" or "2008" * * t Displays the first character of the A.M./P.M. designator. "A" or "P" * Date.CultureInfo.amDesignator or Date.CultureInfo.pmDesignator * tt Displays the A.M./P.M. designator. "AM" or "PM" * Date.CultureInfo.amDesignator or Date.CultureInfo.pmDesignator * * S The ordinal suffix ("st, "nd", "rd" or "th") of the current day. "st, "nd", "rd" or "th" * * STANDARD DATE AND TIME FORMAT STRINGS * Format Description Example *------ --------------------------------------------------------------------------- ----------------------- * d The CultureInfo shortDate Format Pattern "M/d/yyyy" * D The CultureInfo longDate Format Pattern "dddd, MMMM dd, yyyy" * F The CultureInfo fullDateTime Format Pattern "dddd, MMMM dd, yyyy h:mm:ss tt" * m The CultureInfo monthDay Format Pattern "MMMM dd" * r The CultureInfo rfc1123 Format Pattern "ddd, dd MMM yyyy HH:mm:ss GMT" * s The CultureInfo sortableDateTime Format Pattern "yyyy-MM-ddTHH:mm:ss" * t The CultureInfo shortTime Format Pattern "h:mm tt" * T The CultureInfo longTime Format Pattern "h:mm:ss tt" * u The CultureInfo universalSortableDateTime Format Pattern "yyyy-MM-dd HH:mm:ssZ" * y The CultureInfo yearMonth Format Pattern "MMMM, yyyy" * * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @return {String} A string representation of the current Date object. */ var ord = function (n) { switch (n * 1) { case 1: case 21: case 31: return "st"; case 2: case 22: return "nd"; case 3: case 23: return "rd"; default: return "th"; } }; var parseStandardFormats = function (format) { var y, c = Date.CultureInfo.formatPatterns; switch (format) { case "d": return this.toString(c.shortDate); case "D": return this.toString(c.longDate); case "F": return this.toString(c.fullDateTime); case "m": return this.toString(c.monthDay); case "r": case "R": y = this.clone().addMinutes(this.getTimezoneOffset()); return y.toString(c.rfc1123) + " GMT"; case "s": return this.toString(c.sortableDateTime); case "t": return this.toString(c.shortTime); case "T": return this.toString(c.longTime); case "u": y = this.clone().addMinutes(this.getTimezoneOffset()); return y.toString(c.universalSortableDateTime); case "y": return this.toString(c.yearMonth); default: return false; } }; var parseFormatStringsClosure = function (context) { return function (m) { if (m.charAt(0) === "\\") { return m.replace("\\", ""); } switch (m) { case "hh": return p(context.getHours() < 13 ? (context.getHours() === 0 ? 12 : context.getHours()) : (context.getHours() - 12)); case "h": return context.getHours() < 13 ? (context.getHours() === 0 ? 12 : context.getHours()) : (context.getHours() - 12); case "HH": return p(context.getHours()); case "H": return context.getHours(); case "mm": return p(context.getMinutes()); case "m": return context.getMinutes(); case "ss": return p(context.getSeconds()); case "s": return context.getSeconds(); case "yyyy": return p(context.getFullYear(), 4); case "yy": return p(context.getFullYear()); case "y": return context.getFullYear(); case "E": case "dddd": return Date.CultureInfo.dayNames[context.getDay()]; case "ddd": return Date.CultureInfo.abbreviatedDayNames[context.getDay()]; case "dd": return p(context.getDate()); case "d": return context.getDate(); case "MMMM": return Date.CultureInfo.monthNames[context.getMonth()]; case "MMM": return Date.CultureInfo.abbreviatedMonthNames[context.getMonth()]; case "MM": return p((context.getMonth() + 1)); case "M": return context.getMonth() + 1; case "t": return context.getHours() < 12 ? Date.CultureInfo.amDesignator.substring(0, 1) : Date.CultureInfo.pmDesignator.substring(0, 1); case "tt": return context.getHours() < 12 ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator; case "S": return ord(context.getDate()); case "W": return context.getWeek(); case "WW": return context.getISOWeek(); case "Q": return "Q" + context.getQuarter(); case "q": return String(context.getQuarter()); case "z": return context.getTimezone(); case "Z": case "X": return Date.getTimezoneOffset(context.getTimezone()); case "ZZ": // Timezone offset in seconds return context.getTimezoneOffset() * -60; case "u": return context.getDay(); case "L": return ($D.isLeapYear(context.getFullYear())) ? 1 : 0; case "B": // Swatch Internet Time (.beats) return "@"+((context.getUTCSeconds() + (context.getUTCMinutes()*60) + ((context.getUTCHours()+1)*3600))/86.4); default: return m; } }; }; $P.toString = function (format, ignoreStandards) { // Standard Date and Time Format Strings. Formats pulled from CultureInfo file and // may vary by culture. if (!ignoreStandards && format && format.length === 1) { output = parseStandardFormats.call(this, format); if (output) { return output; } } var parseFormatStrings = parseFormatStringsClosure(this); return format ? format.replace(/((\\)?(dd?d?d?|MM?M?M?|yy?y?y?|hh?|HH?|mm?|ss?|tt?|S|q|Q|WW?W?W?)(?![^\[]*\]))/g, parseFormatStrings).replace(/\[|\]/g, "") : this._toString(); }; }()); /************************************************************* * SugarPak - Domain Specific Language - Syntactical Sugar * *************************************************************/ (function () { var $D = Date, $P = $D.prototype, $N = Number.prototype; // private $P._orient = +1; // private $P._nth = null; // private $P._is = false; // private $P._same = false; // private $P._isSecond = false; // private $N._dateElement = "days"; /** * Moves the date to the next instance of a date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.today().next().friday();
	Date.today().next().fri();
	Date.today().next().march();
	Date.today().next().mar();
	Date.today().next().week();
	
* * @return {Date} date */ $P.next = function () { this._move = true; this._orient = +1; return this; }; /** * Creates a new Date (Date.today()) and moves the date to the next instance of the date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.next().friday();
	Date.next().fri();
	Date.next().march();
	Date.next().mar();
	Date.next().week();
	
* * @return {Date} date */ $D.next = function () { return $D.today().next(); }; /** * Moves the date to the previous instance of a date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.today().last().friday();
	Date.today().last().fri();
	Date.today().last().march();
	Date.today().last().mar();
	Date.today().last().week();
	
* * @return {Date} date */ $P.last = $P.prev = $P.previous = function () { this._move = true; this._orient = -1; return this; }; /** * Creates a new Date (Date.today()) and moves the date to the previous instance of the date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.last().friday();
	Date.last().fri();
	Date.previous().march();
	Date.prev().mar();
	Date.last().week();
	
* * @return {Date} date */ $D.last = $D.prev = $D.previous = function () { return $D.today().last(); }; /** * Performs a equality check when followed by either a month name, day name or .weekday() function. * Example

	Date.today().is().friday(); // true|false
	Date.today().is().fri();
	Date.today().is().march();
	Date.today().is().mar();
	
* * @return {Boolean} true|false */ $P.is = function () { this._is = true; return this; }; /** * Determines if two date objects occur on/in exactly the same instance of the subsequent date part function. * The function .same() must be followed by a date part function (example: .day(), .month(), .year(), etc). * * An optional Date can be passed in the date part function. If now date is passed as a parameter, 'Now' is used. * * The following example demonstrates how to determine if two dates fall on the exact same day. * * Example

	var d1 = Date.today(); // today at 00:00
	var d2 = new Date();   // exactly now.

	// Do they occur on the same day?
	d1.same().day(d2); // true
	
	// Do they occur on the same hour?
	d1.same().hour(d2); // false, unless d2 hour is '00' (midnight).
	
	// What if it's the same day, but one year apart?
	var nextYear = Date.today().add(1).year();

	d1.same().day(nextYear); // false, because the dates must occur on the exact same day. 
	
* * Scenario: Determine if a given date occurs during some week period 2 months from now. * * Example

	var future = Date.today().add(2).months();
	return someDate.same().week(future); // true|false;
	
* * @return {Boolean} true|false */ $P.same = function () { this._same = true; this._isSecond = false; return this; }; /** * Determines if the current date/time occurs during Today. Must be preceded by the .is() function. * Example

	someDate.is().today();    // true|false
	new Date().is().today();  // true
	Date.today().is().today();// true
	Date.today().add(-1).day().is().today(); // false
	
* * @return {Boolean} true|false */ $P.today = function () { return this.same().day(); }; /** * Determines if the current date is a weekday. This function must be preceded by the .is() function. * Example

	Date.today().is().weekday(); // true|false
	
* * @return {Boolean} true|false */ $P.weekday = function () { if (this._nth) { return df("Weekday").call(this); } if (this._move) { return this.addWeekdays(this._orient); } if (this._is) { this._is = false; return (!this.is().sat() && !this.is().sun()); } return false; }; /** * Determines if the current date is on the weekend. This function must be preceded by the .is() function. * Example

	Date.today().is().weekend(); // true|false
	
* * @return {Boolean} true|false */ $P.weekend = function () { if (this._is) { this._is = false; return (this.is().sat() || this.is().sun()); } return false; }; /** * Sets the Time of the current Date instance. A string "6:15 pm" or config object {hour:18, minute:15} are accepted. * Example

	// Set time to 6:15pm with a String
	Date.today().at("6:15pm");

	// Set time to 6:15pm with a config object
	Date.today().at({hour:18, minute:15});
	
* * @return {Date} date */ $P.at = function (time) { return (typeof time === "string") ? $D.parse(this.toString("d") + " " + time) : this.set(time); }; /** * Creates a new Date() and adds this (Number) to the date based on the preceding date element function (eg. second|minute|hour|day|month|year). * Example

	// Undeclared Numbers must be wrapped with parentheses. Requirment of JavaScript.
	(3).days().fromNow();
	(6).months().fromNow();

	// Declared Number variables do not require parentheses. 
	var n = 6;
	n.months().fromNow();
	
* * @return {Date} A new Date instance */ $N.fromNow = $N.after = function (date) { var c = {}; c[this._dateElement] = this; return ((!date) ? new Date() : date.clone()).add(c); }; /** * Creates a new Date() and subtract this (Number) from the date based on the preceding date element function (eg. second|minute|hour|day|month|year). * Example

	// Undeclared Numbers must be wrapped with parentheses. Requirment of JavaScript.
	(3).days().ago();
	(6).months().ago();

	// Declared Number variables do not require parentheses. 
	var n = 6;
	n.months().ago();
	
* * @return {Date} A new Date instance */ $N.ago = $N.before = function (date) { var c = {}, s = (this._dateElement[this._dateElement.length-1] !== "s") ? this._dateElement + "s" : this._dateElement; c[s] = this * -1; return ((!date) ? new Date() : date.clone()).add(c); }; // Do NOT modify the following string tokens. These tokens are used to build dynamic functions. // All culture-specific strings can be found in the CultureInfo files. var dx = ("sunday monday tuesday wednesday thursday friday saturday").split(/\s/), mx = ("january february march april may june july august september october november december").split(/\s/), px = ("Millisecond Second Minute Hour Day Week Month Year Quarter Weekday").split(/\s/), pxf = ("Milliseconds Seconds Minutes Hours Date Week Month FullYear Quarter").split(/\s/), nth = ("final first second third fourth fifth").split(/\s/), de; /** * Returns an object literal of all the date parts. * Example

	var o = new Date().toObject();
	
	// { year: 2008, month: 4, week: 20, day: 13, hour: 18, minute: 9, second: 32, millisecond: 812 }
	
	// The object properties can be referenced directly from the object.
	
	alert(o.day);  // alerts "13"
	alert(o.year); // alerts "2008"
	
* * @return {Date} An object literal representing the original date object. */ $P.toObject = function () { var o = {}; for (var i = 0; i < px.length; i++) { if (this["get" + pxf[i]]) { o[px[i].toLowerCase()] = this["get" + pxf[i]](); } } return o; }; /** * Returns a date created from an object literal. Ignores the .week property if set in the config. * Example

	var o = new Date().toObject();
	
	return Date.fromObject(o); // will return the same date. 

	var o2 = {month: 1, day: 20, hour: 18}; // birthday party!
	Date.fromObject(o2);
	
* * @return {Date} An object literal representing the original date object. */ $D.fromObject = function(config) { config.week = null; return Date.today().set(config); }; // Create day name functions and abbreviated day name functions (eg. monday(), friday(), fri()). var df = function (n) { return function () { if (this._is) { this._is = false; return this.getDay() === n; } if (this._move) { this._move = null; } if (this._nth !== null) { // If the .second() function was called earlier, remove the _orient // from the date, and then continue. // This is required because 'second' can be used in two different context. // // Example // // Date.today().add(1).second(); // Date.march().second().monday(); // // Things get crazy with the following... // Date.march().add(1).second().second().monday(); // but it works!! // if (this._isSecond) { this.addSeconds(this._orient * -1); } // make sure we reset _isSecond this._isSecond = false; var ntemp = this._nth; this._nth = null; var temp = this.clone().moveToLastDayOfMonth(); this.moveToNthOccurrence(n, ntemp); if (this > temp) { throw new RangeError($D.getDayName(n) + " does not occur " + ntemp + " times in the month of " + $D.getMonthName(temp.getMonth()) + " " + temp.getFullYear() + "."); } return this; } return this.moveToDayOfWeek(n, this._orient); }; }; var sdf = function (n) { return function () { var t = $D.today(), shift = n - t.getDay(); if (n === 0 && Date.CultureInfo.firstDayOfWeek === 1 && t.getDay() !== 0) { shift = shift + 7; } return t.addDays(shift); }; }; // Create month name functions and abbreviated month name functions (eg. january(), march(), mar()). var month_instance_functions = function (n) { return function () { if (this._is) { this._is = false; return this.getMonth() === n; } return this.moveToMonth(n, this._orient); }; }; var month_static_functions = function (n) { return function () { return $D.today().set({ month: n, day: 1 }); }; }; var processTerms = function (names, staticFunc, instanceFunc) { for (var i = 0; i < names.length; i++) { // Create constant static Name variables. $D[names[i].toUpperCase()] = $D[names[i].toUpperCase().substring(0, 3)] = i; // Create Name functions. $D[names[i]] = $D[names[i].substring(0, 3)] = staticFunc(i); // Create Name instance functions. $P[names[i]] = $P[names[i].substring(0, 3)] = instanceFunc(i); } }; processTerms(dx, sdf, df); processTerms(mx, month_static_functions, month_instance_functions); // Create date element functions and plural date element functions used with Date (eg. day(), days(), months()). var ef = function (j) { return function () { // if the .second() function was called earlier, the _orient // has alread been added. Just return this and reset _isSecond. if (this._isSecond) { this._isSecond = false; return this; } if (this._same) { this._same = this._is = false; var o1 = this.toObject(), o2 = (arguments[0] || new Date()).toObject(), v = "", k = j.toLowerCase(); // the substr trick with -1 doesn't work in IE8 or less k = (k[k.length-1] === "s") ? k.substring(0,k.length-1) : k; for (var m = (px.length - 1); m > -1; m--) { v = px[m].toLowerCase(); if (o1[v] !== o2[v]) { return false; } if (k === v) { break; } } return true; } if (j.substring(j.length - 1) !== "s") { j += "s"; } if (this._move) { this._move = null; } return this["add" + j](this._orient); }; }; var nf = function (n) { return function () { this._dateElement = n; return this; }; }; for (var k = 0; k < px.length; k++) { de = px[k].toLowerCase(); if(de !== "weekday") { // Create date element functions and plural date element functions used with Date (eg. day(), days(), months()). $P[de] = $P[de + "s"] = ef(px[k]); // Create date element functions and plural date element functions used with Number (eg. day(), days(), months()). $N[de] = $N[de + "s"] = nf(de + "s"); } } $P._ss = ef("Second"); var nthfn = function (n) { return function (dayOfWeek) { if (this._same) { return this._ss(arguments[0]); } if (dayOfWeek || dayOfWeek === 0) { return this.moveToNthOccurrence(dayOfWeek, n); } this._nth = n; // if the operator is 'second' add the _orient, then deal with it later... if (n === 2 && (dayOfWeek === undefined || dayOfWeek === null)) { this._isSecond = true; return this.addSeconds(this._orient); } return this; }; }; for (var l = 0; l < nth.length; l++) { $P[nth[l]] = (l === 0) ? nthfn(-1) : nthfn(l); } }()); (function () { "use strict"; Date.Parsing = { Exception: function (s) { this.message = "Parse error at '" + s.substring(0, 10) + " ...'"; } }; var $P = Date.Parsing; var dayOffsets = { standard: [0,31,59,90,120,151,181,212,243,273,304,334], leap: [0,31,60,91,121,152,182,213,244,274,305,335] }; $P.isLeapYear = function(year) { return ((year % 4 === 0) && (year % 100 !== 0)) || (year % 400 === 0); }; var utils = { multiReplace : function (str, hash ) { var key; for (key in hash) { if (Object.prototype.hasOwnProperty.call(hash, key)) { var regex; if (typeof hash[key] === "function") { } else { regex = (hash[key] instanceof RegExp) ? hash[key] : new RegExp(hash[key], "g"); } str = str.replace(regex, key); } } return str; }, getDayOfYearFromWeek : function (obj) { var d, jan4, offset; obj.weekDay = (!obj.weekDay && obj.weekDay !== 0) ? 1 : obj.weekDay; d = new Date(obj.year, 0, 4); jan4 = d.getDay() === 0 ? 7 : d.getDay(); // JS is 0 indexed on Sunday. offset = jan4+3; obj.dayOfYear = ((obj.week * 7) + (obj.weekDay === 0 ? 7 : obj.weekDay))-offset; return obj; }, getDayOfYear : function (obj, dayOffset) { if (!obj.dayOfYear) { obj = utils.getDayOfYearFromWeek(obj); } for (var i=0;i <= dayOffset.length;i++) { if (obj.dayOfYear < dayOffset[i] || i === dayOffset.length) { obj.day = obj.day ? obj.day : (obj.dayOfYear - dayOffset[i-1]); break; } else { obj.month = i; } } return obj; }, adjustForTimeZone : function (obj, date) { var offset; if (obj.zone.toUpperCase() === "Z" || (obj.zone_hours === 0 && obj.zone_minutes === 0)) { // it's UTC/GML so work out the current timeszone offset offset = -date.getTimezoneOffset(); } else { offset = (obj.zone_hours*60) + (obj.zone_minutes || 0); if (obj.zone_sign === "+") { offset *= -1; } offset -= date.getTimezoneOffset(); } date.setMinutes(date.getMinutes()+offset); return date; }, setDefaults : function (obj) { obj.year = obj.year || Date.today().getFullYear(); obj.hours = obj.hours || 0; obj.minutes = obj.minutes || 0; obj.seconds = obj.seconds || 0; obj.milliseconds = obj.milliseconds || 0; if (!(!obj.month && (obj.week || obj.dayOfYear))) { // if we have a month, or if we don't but don't have the day calculation data obj.month = obj.month || 0; obj.day = obj.day || 1; } return obj; }, dataNum: function (data, mod, explict, postProcess) { var dataNum = data*1; if (mod) { if (postProcess) { return data ? mod(data)*1 : data; } else { return data ? mod(dataNum) : data; } } else if (!explict){ return data ? dataNum : data; } else { return (data && typeof data !== "undefined") ? dataNum : data; } }, timeDataProcess: function (obj) { var timeObj = {}; for (var x in obj.data) { if (obj.data.hasOwnProperty(x)) { timeObj[x] = obj.ignore[x] ? obj.data[x] : utils.dataNum(obj.data[x], obj.mods[x], obj.explict[x], obj.postProcess[x]); } } if (obj.data.secmins) { obj.data.secmins = obj.data.secmins.replace(",", ".") * 60; if (!timeObj.minutes) { timeObj.minutes = obj.data.secmins; } else if (!timeObj.seconds) { timeObj.seconds = obj.data.secmins; } delete obj.secmins; } return timeObj; }, buildTimeObjectFromData: function (data) { var time = utils.timeDataProcess({ data: { year : data[1], month : data[5], day : data[7], week : data[8], dayOfYear : data[10], hours : data[15], zone_hours : data[23], zone_minutes : data[24], zone : data[21], zone_sign : data[22], weekDay : data[9], minutes: data[16], seconds: data[19], milliseconds: data[20], secmins: data[18] }, mods: { month: function(data) { return data-1; }, weekDay: function (data) { data = Math.abs(data); return (data === 7 ? 0 : data); }, minutes: function (data) { return data.replace(":",""); }, seconds: function (data) { return Math.floor( (data.replace(":","").replace(",","."))*1 ); }, milliseconds: function (data) { return (data.replace(",",".")*1000); } }, postProcess: { minutes: true, seconds: true, milliseconds: true }, explict: { zone_hours: true, zone_minutes: true }, ignore: { zone: true, zone_sign: true, secmins: true } }); return time; }, addToHash: function (hash, keys, data) { keys = keys; data = data; var len = keys.length; for (var i = 0; i < len; i++) { hash[keys[i]] = data[i]; } return hash; }, combineRegex: function (r1, r2) { return new RegExp("(("+r1.source+")\\s("+r2.source+"))"); }, getDateNthString: function(add, last, inc){ if (add) { return Date.today().addDays(inc).toString("d"); } else if (last) { return Date.today().last()[inc]().toString("d"); } }, buildRegexData: function (array) { var arr = []; var len = array.length; for (var i=0; i < len; i++) { if (Object.prototype.toString.call(array[i]) === '[object Array]') { // oldIE compat version of Array.isArray arr.push(this.combineRegex(array[i][0], array[i][1])); } else { arr.push(array[i]); } } return arr; } }; $P.processTimeObject = function (obj) { var date, dayOffset; utils.setDefaults(obj); dayOffset = ($P.isLeapYear(obj.year)) ? dayOffsets.leap : dayOffsets.standard; if (!obj.month && (obj.week || obj.dayOfYear)) { utils.getDayOfYear(obj, dayOffset); } else { obj.dayOfYear = dayOffset[obj.month] + obj.day; } date = new Date(obj.year, obj.month, obj.day, obj.hours, obj.minutes, obj.seconds, obj.milliseconds); if (obj.zone) { utils.adjustForTimeZone(obj, date); // adjust (and calculate) for timezone } return date; }; $P.ISO = { regex : /^([\+-]?\d{4}(?!\d{2}\b))((-?)((0[1-9]|1[0-2])(\3([12]\d|0[1-9]|3[01]))?|W([0-4]\d|5[0-3])(-?[1-7])?|(00[1-9]|0[1-9]\d|[12]\d{2}|3([0-5]\d|6[1-6])))([T\s]((([01]\d|2[0-4])((:?)[0-5]\d)?|24\:?00)([\.,]\d+(?!:))?)?(\17[0-5]\d([\.,]\d+)?)?\s?([zZ]|([\+-])([01]\d|2[0-3]):?([0-5]\d)?)?)?)?$/, parse : function (s) { var time, data = s.match(this.regex); if (!data || !data.length) { return null; } time = utils.buildTimeObjectFromData(data); if (!time.year || (!time.year && (!time.month && !time.day) && (!time.week && !time.dayOfYear)) ) { return null; } return $P.processTimeObject(time); } }; $P.Numeric = { isNumeric: function (e){return!isNaN(parseFloat(e))&&isFinite(e);}, regex: /\b([0-1]?[0-9])([0-3]?[0-9])([0-2]?[0-9]?[0-9][0-9])\b/i, parse: function (s) { var data, i, time = {}, order = Date.CultureInfo.dateElementOrder.split(""); if (!(this.isNumeric(s)) || // if it's non-numeric OR (s[0] === "+" && s[0] === "-")) { // It's an arithmatic string (eg +/-1000) return null; } if (s.length < 5 && s.indexOf(".") < 0 && s.indexOf("/") < 0) { // assume it's just a year. time.year = s; return $P.processTimeObject(time); } data = s.match(this.regex); if (!data || !data.length) { return null; } for (i=0; i < order.length; i++) { switch(order[i]) { case "d": time.day = data[i+1]; break; case "m": time.month = (data[i+1]-1); break; case "y": time.year = data[i+1]; break; } } return $P.processTimeObject(time); } }; $P.Normalizer = { regexData: function () { var $R = Date.CultureInfo.regexPatterns; return utils.buildRegexData([ $R.tomorrow, $R.yesterday, [$R.past, $R.mon], [$R.past, $R.tue], [$R.past, $R.wed], [$R.past, $R.thu], [$R.past, $R.fri], [$R.past, $R.sat], [$R.past, $R.sun] ]); }, basicReplaceHash : function() { var $R = Date.CultureInfo.regexPatterns; return { "January": $R.jan.source, "February": $R.feb, "March": $R.mar, "April": $R.apr, "May": $R.may, "June": $R.jun, "July": $R.jul, "August": $R.aug, "September": $R.sep, "October": $R.oct, "November": $R.nov, "December": $R.dec, "": /\bat\b/gi, " ": /\s{2,}/, "am": $R.inTheMorning, "9am": $R.thisMorning, "pm": $R.inTheEvening, "7pm":$R.thisEvening }; }, keys : function(){ return [ utils.getDateNthString(true, false, 1), // tomorrow utils.getDateNthString(true, false, -1), // yesterday utils.getDateNthString(false, true, "monday"), //last mon utils.getDateNthString(false, true, "tuesday"), //last tues utils.getDateNthString(false, true, "wednesday"), //last wed utils.getDateNthString(false, true, "thursday"), //last thurs utils.getDateNthString(false, true, "friday"), //last fri utils.getDateNthString(false, true, "saturday"), //last sat utils.getDateNthString(false, true, "sunday") //last sun ]; }, buildRegexFunctions: function () { var $R = Date.CultureInfo.regexPatterns; var __ = Date.i18n.__; var tomorrowRE = new RegExp("(\\b\\d\\d?("+__("AM")+"|"+__("PM")+")? )("+$R.tomorrow.source.slice(1)+")", "i"); // adapted tomorrow regex for AM PM relative dates var todayRE = new RegExp($R.today.source + "(?!\\s*([+-]))\\b"); // today, but excludes the math operators (eg "today + 2h") this.replaceFuncs = [ [todayRE, function (full) { return (full.length > 1) ? Date.today().toString("d") : full; }], [tomorrowRE, function(full, m1) { var t = Date.today().addDays(1).toString("d"); return (t + " " + m1); }], [$R.amThisMorning, function(str, am){return am;}], [$R.pmThisEvening, function(str, pm){return pm;}] ]; }, buildReplaceData: function () { this.buildRegexFunctions(); this.replaceHash = utils.addToHash(this.basicReplaceHash(), this.keys(), this.regexData()); }, stringReplaceFuncs: function (s) { for (var i=0; i < this.replaceFuncs.length; i++) { s = s.replace(this.replaceFuncs[i][0], this.replaceFuncs[i][1]); } return s; }, parse: function (s) { s = this.stringReplaceFuncs(s); s = utils.multiReplace(s, this.replaceHash); try { var n = s.split(/([\s\-\.\,\/\x27]+)/); if (n.length === 3 && $P.Numeric.isNumeric(n[0]) && $P.Numeric.isNumeric(n[2]) && (n[2].length >= 4)) { // ok, so we're dealing with x/year. But that's not a full date. // This fixes wonky dateElementOrder parsing when set to dmy order. if (Date.CultureInfo.dateElementOrder[0] === "d") { s = "1/" + n[0] + "/" + n[2]; // set to 1st of month and normalize the seperator } } } catch (e) {} return s; } }; $P.Normalizer.buildReplaceData(); }()); (function () { var $P = Date.Parsing; var _ = $P.Operators = { // // Tokenizers // rtoken: function (r) { // regex token return function (s) { var mx = s.match(r); if (mx) { return ([ mx[0], s.substring(mx[0].length) ]); } else { throw new $P.Exception(s); } }; }, token: function () { // whitespace-eating token return function (s) { return _.rtoken(new RegExp("^\\s*" + s + "\\s*"))(s); }; }, stoken: function (s) { // string token return _.rtoken(new RegExp("^" + s)); }, // Atomic Operators until: function (p) { return function (s) { var qx = [], rx = null; while (s.length) { try { rx = p.call(this, s); } catch (e) { qx.push(rx[0]); s = rx[1]; continue; } break; } return [ qx, s ]; }; }, many: function (p) { return function (s) { var rx = [], r = null; while (s.length) { try { r = p.call(this, s); } catch (e) { return [ rx, s ]; } rx.push(r[0]); s = r[1]; } return [ rx, s ]; }; }, // generator operators -- see below optional: function (p) { return function (s) { var r = null; try { r = p.call(this, s); } catch (e) { return [ null, s ]; } return [ r[0], r[1] ]; }; }, not: function (p) { return function (s) { try { p.call(this, s); } catch (e) { return [null, s]; } throw new $P.Exception(s); }; }, ignore: function (p) { return p ? function (s) { var r = null; r = p.call(this, s); return [null, r[1]]; } : null; }, product: function () { var px = arguments[0], qx = Array.prototype.slice.call(arguments, 1), rx = []; for (var i = 0 ; i < px.length ; i++) { rx.push(_.each(px[i], qx)); } return rx; }, cache: function (rule) { var cache = {}, cache_length = 0, cache_keys = [], CACHE_MAX = Date.Config.CACHE_MAX || 100000, r = null; var cacheCheck = function () { if (cache_length === CACHE_MAX) { // kill several keys, don't want to have to do this all the time... for (var i=0; i < 10; i++) { var key = cache_keys.shift(); if (key) { delete cache[key]; cache_length--; } } } }; return function (s) { cacheCheck(); try { r = cache[s] = (cache[s] || rule.call(this, s)); } catch (e) { r = cache[s] = e; } cache_length++; cache_keys.push(s); if (r instanceof $P.Exception) { throw r; } else { return r; } }; }, // vector operators -- see below any: function () { var px = arguments; return function (s) { var r = null; for (var i = 0; i < px.length; i++) { if (px[i] == null) { continue; } try { r = (px[i].call(this, s)); } catch (e) { r = null; } if (r) { return r; } } throw new $P.Exception(s); }; }, each: function () { var px = arguments; return function (s) { var rx = [], r = null; for (var i = 0; i < px.length ; i++) { if (px[i] == null) { continue; } try { r = (px[i].call(this, s)); } catch (e) { throw new $P.Exception(s); } rx.push(r[0]); s = r[1]; } return [ rx, s]; }; }, all: function () { var px = arguments, _ = _; return _.each(_.optional(px)); }, // delimited operators sequence: function (px, d, c) { d = d || _.rtoken(/^\s*/); c = c || null; if (px.length === 1) { return px[0]; } return function (s) { var r = null, q = null; var rx = []; for (var i = 0; i < px.length ; i++) { try { r = px[i].call(this, s); } catch (e) { break; } rx.push(r[0]); try { q = d.call(this, r[1]); } catch (ex) { q = null; break; } s = q[1]; } if (!r) { throw new $P.Exception(s); } if (q) { throw new $P.Exception(q[1]); } if (c) { try { r = c.call(this, r[1]); } catch (ey) { throw new $P.Exception(r[1]); } } return [ rx, (r?r[1]:s) ]; }; }, // // Composite Operators // between: function (d1, p, d2) { d2 = d2 || d1; var _fn = _.each(_.ignore(d1), p, _.ignore(d2)); return function (s) { var rx = _fn.call(this, s); return [[rx[0][0], r[0][2]], rx[1]]; }; }, list: function (p, d, c) { d = d || _.rtoken(/^\s*/); c = c || null; return (p instanceof Array ? _.each(_.product(p.slice(0, -1), _.ignore(d)), p.slice(-1), _.ignore(c)) : _.each(_.many(_.each(p, _.ignore(d))), px, _.ignore(c))); }, set: function (px, d, c) { d = d || _.rtoken(/^\s*/); c = c || null; return function (s) { // r is the current match, best the current 'best' match // which means it parsed the most amount of input var r = null, p = null, q = null, rx = null, best = [[], s], last = false; // go through the rules in the given set for (var i = 0; i < px.length ; i++) { // last is a flag indicating whether this must be the last element // if there is only 1 element, then it MUST be the last one q = null; p = null; r = null; last = (px.length === 1); // first, we try simply to match the current pattern // if not, try the next pattern try { r = px[i].call(this, s); } catch (e) { continue; } // since we are matching against a set of elements, the first // thing to do is to add r[0] to matched elements rx = [[r[0]], r[1]]; // if we matched and there is still input to parse and // we don't already know this is the last element, // we're going to next check for the delimiter ... // if there's none, or if there's no input left to parse // than this must be the last element after all ... if (r[1].length > 0 && ! last) { try { q = d.call(this, r[1]); } catch (ex) { last = true; } } else { last = true; } // if we parsed the delimiter and now there's no more input, // that means we shouldn't have parsed the delimiter at all // so don't update r and mark this as the last element ... if (!last && q[1].length === 0) { last = true; } // so, if this isn't the last element, we're going to see if // we can get any more matches from the remaining (unmatched) // elements ... if (!last) { // build a list of the remaining rules we can match against, // i.e., all but the one we just matched against var qx = []; for (var j = 0; j < px.length ; j++) { if (i !== j) { qx.push(px[j]); } } // now invoke recursively set with the remaining input // note that we don't include the closing delimiter ... // we'll check for that ourselves at the end p = _.set(qx, d).call(this, q[1]); // if we got a non-empty set as a result ... // (otw rx already contains everything we want to match) if (p[0].length > 0) { // update current result, which is stored in rx ... // basically, pick up the remaining text from p[1] // and concat the result from p[0] so that we don't // get endless nesting ... rx[0] = rx[0].concat(p[0]); rx[1] = p[1]; } } // at this point, rx either contains the last matched element // or the entire matched set that starts with this element. // now we just check to see if this variation is better than // our best so far, in terms of how much of the input is parsed if (rx[1].length < best[1].length) { best = rx; } // if we've parsed all the input, then we're finished if (best[1].length === 0) { break; } } // so now we've either gone through all the patterns trying them // as the initial match; or we found one that parsed the entire // input string ... // if best has no matches, just return empty set ... if (best[0].length === 0) { return best; } // if a closing delimiter is provided, then we have to check it also if (c) { // we try this even if there is no remaining input because the pattern // may well be optional or match empty input ... try { q = c.call(this, best[1]); } catch (ey) { throw new $P.Exception(best[1]); } // it parsed ... be sure to update the best match remaining input best[1] = q[1]; } // if we're here, either there was no closing delimiter or we parsed it // so now we have the best match; just return it! return best; }; }, forward: function (gr, fname) { return function (s) { return gr[fname].call(this, s); }; }, // // Translation Operators // replace: function (rule, repl) { return function (s) { var r = rule.call(this, s); return [repl, r[1]]; }; }, process: function (rule, fn) { return function (s) { var r = rule.call(this, s); return [fn.call(this, r[0]), r[1]]; }; }, min: function (min, rule) { return function (s) { var rx = rule.call(this, s); if (rx[0].length < min) { throw new $P.Exception(s); } return rx; }; } }; // Generator Operators And Vector Operators // Generators are operators that have a signature of F(R) => R, // taking a given rule and returning another rule, such as // ignore, which parses a given rule and throws away the result. // Vector operators are those that have a signature of F(R1,R2,...) => R, // take a list of rules and returning a new rule, such as each. // Generator operators are converted (via the following _generator // function) into functions that can also take a list or array of rules // and return an array of new rules as though the function had been // called on each rule in turn (which is what actually happens). // This allows generators to be used with vector operators more easily. // Example: // each(ignore(foo, bar)) instead of each(ignore(foo), ignore(bar)) // This also turns generators into vector operators, which allows // constructs like: // not(cache(foo, bar)) var _generator = function (op) { function gen() { var args = null, rx = [], px, i; if (arguments.length > 1) { args = Array.prototype.slice.call(arguments); } else if (arguments[0] instanceof Array) { args = arguments[0]; } if (args) { px = args.shift(); if (px.length > 0) { args.unshift(px[i]); rx.push(op.apply(null, args)); args.shift(); return rx; } } else { return op.apply(null, arguments); } } return gen; }; var gx = "optional not ignore cache".split(/\s/); for (var i = 0 ; i < gx.length ; i++) { _[gx[i]] = _generator(_[gx[i]]); } var _vector = function (op) { return function () { if (arguments[0] instanceof Array) { return op.apply(null, arguments[0]); } else { return op.apply(null, arguments); } }; }; var vx = "each any all".split(/\s/); for (var j = 0 ; j < vx.length ; j++) { _[vx[j]] = _vector(_[vx[j]]); } }()); (function () { var $D = Date; var flattenAndCompact = function (ax) { var rx = []; for (var i = 0; i < ax.length; i++) { if (ax[i] instanceof Array) { rx = rx.concat(flattenAndCompact(ax[i])); } else { if (ax[i]) { rx.push(ax[i]); } } } return rx; }; var parseMeridian = function () { if (this.meridian && (this.hour || this.hour === 0)) { if (this.meridian === "a" && this.hour > 11 && Date.Config.strict24hr){ throw "Invalid hour and meridian combination"; } else if (this.meridian === "p" && this.hour < 12 && Date.Config.strict24hr){ throw "Invalid hour and meridian combination"; } else if (this.meridian === "p" && this.hour < 12) { this.hour = this.hour + 12; } else if (this.meridian === "a" && this.hour === 12) { this.hour = 0; } } }; var setDefaults = function () { var now = new Date(); if ((this.hour || this.minute) && (!this.month && !this.year && !this.day)) { this.day = now.getDate(); } if (!this.year) { this.year = now.getFullYear(); } if (!this.month && this.month !== 0) { this.month = now.getMonth(); } if (!this.day) { this.day = 1; } if (!this.hour) { this.hour = 0; } if (!this.minute) { this.minute = 0; } if (!this.second) { this.second = 0; } if (!this.millisecond) { this.millisecond = 0; } }; var finishUtils = { getToday: function () { if (this.now || "hour minute second".indexOf(this.unit) !== -1) { return new Date(); } else { return $D.today(); } }, setDaysFromWeekday: function (today, orient){ var gap; orient = orient || 1; this.unit = "day"; gap = ($D.getDayNumberFromName(this.weekday) - today.getDay()); this.days = gap ? ((gap + (orient * 7)) % 7) : (orient * 7); return this; }, setMonthsFromMonth: function (today, orient) { var gap; orient = orient || 1; this.unit = "month"; gap = (this.month - today.getMonth()); this.months = gap ? ((gap + (orient * 12)) % 12) : (orient * 12); this.month = null; return this; }, setDMYFromWeekday: function () { var d = Date[this.weekday](); this.day = d.getDate(); if (!this.month) { this.month = d.getMonth(); } this.year = d.getFullYear(); return this; }, setUnitValue: function (orient) { if (!this.value && this.operator && this.operator !== null && this[this.unit + "s"] && this[this.unit + "s"] !== null) { this[this.unit + "s"] = this[this.unit + "s"] + ((this.operator === "add") ? 1 : -1) + (this.value||0) * orient; } else if (this[this.unit + "s"] == null || this.operator != null) { if (!this.value) { this.value = 1; } this[this.unit + "s"] = this.value * orient; } }, generateDateFromWeeks: function () { var weekday = (this.weekday !== undefined) ? this.weekday : "today"; var d = Date[weekday]().addWeeks(this.weeks); if (this.now) { d.setTimeToNow(); } return d; } }; $D.Translator = { hour: function (s) { return function () { this.hour = Number(s); }; }, minute: function (s) { return function () { this.minute = Number(s); }; }, second: function (s) { return function () { this.second = Number(s); }; }, /* for ss.s format */ secondAndMillisecond: function (s) { return function () { var mx = s.match(/^([0-5][0-9])\.([0-9]{1,3})/); this.second = Number(mx[1]); this.millisecond = Number(mx[2]); }; }, meridian: function (s) { return function () { this.meridian = s.slice(0, 1).toLowerCase(); }; }, timezone: function (s) { return function () { var n = s.replace(/[^\d\+\-]/g, ""); if (n.length) { this.timezoneOffset = Number(n); } else { this.timezone = s.toLowerCase(); } }; }, day: function (x) { var s = x[0]; return function () { this.day = Number(s.match(/\d+/)[0]); if (this.day < 1) { throw "invalid day"; } }; }, month: function (s) { return function () { this.month = (s.length === 3) ? "jan feb mar apr may jun jul aug sep oct nov dec".indexOf(s)/4 : Number(s) - 1; if (this.month < 0) { throw "invalid month"; } }; }, year: function (s) { return function () { var n = Number(s); this.year = ((s.length > 2) ? n : (n + (((n + 2000) < Date.CultureInfo.twoDigitYearMax) ? 2000 : 1900))); }; }, rday: function (s) { return function () { switch (s) { case "yesterday": this.days = -1; break; case "tomorrow": this.days = 1; break; case "today": this.days = 0; break; case "now": this.days = 0; this.now = true; break; } }; }, finishExact: function (x) { var d; x = (x instanceof Array) ? x : [x]; for (var i = 0 ; i < x.length ; i++) { if (x[i]) { x[i].call(this); } } setDefaults.call(this); parseMeridian.call(this); if (this.day > $D.getDaysInMonth(this.year, this.month)) { throw new RangeError(this.day + " is not a valid value for days."); } d = new Date(this.year, this.month, this.day, this.hour, this.minute, this.second, this.millisecond); if (this.year < 100) { d.setFullYear(this.year); // means years less that 100 are process correctly. JS will parse it otherwise as 1900-1999. } if (this.timezone) { d.set({ timezone: this.timezone }); } else if (this.timezoneOffset) { d.set({ timezoneOffset: this.timezoneOffset }); } return d; }, finish: function (x) { var today, expression, orient, temp; x = (x instanceof Array) ? flattenAndCompact(x) : [ x ]; if (x.length === 0) { return null; } for (var i = 0 ; i < x.length ; i++) { if (typeof x[i] === "function") { x[i].call(this); } } if (this.now && !this.unit && !this.operator) { return new Date(); } else { today = finishUtils.getToday.call(this); } expression = !!(this.days && this.days !== null || this.orient || this.operator); orient = ((this.orient === "past" || this.operator === "subtract") ? -1 : 1); if (this.month && this.unit === "week") { this.value = this.month + 1; delete this.month; delete this.day; } if ((this.month || this.month === 0) && "year day hour minute second".indexOf(this.unit) !== -1) { if (!this.value) { this.value = this.month + 1; } this.month = null; expression = true; } if (!expression && this.weekday && !this.day && !this.days) { finishUtils.setDMYFromWeekday.call(this); } if (expression && this.weekday && this.unit !== "month" && this.unit !== "week") { finishUtils.setDaysFromWeekday.call(this, today, orient); } if (this.weekday && this.unit !== "week" && !this.day && !this.days) { temp = Date[this.weekday](); this.day = temp.getDate(); if (temp.getMonth() !== today.getMonth()) { this.month = temp.getMonth(); } } if (this.month && this.unit === "day" && this.operator) { if (!this.value) { this.value = (this.month + 1); } this.month = null; } if (this.value != null && this.month != null && this.year != null) { this.day = this.value * 1; } if (this.month && !this.day && this.value) { today.set({ day: this.value * 1 }); if (!expression) { this.day = this.value * 1; } } if (!this.month && this.value && this.unit === "month" && !this.now) { this.month = this.value; expression = true; } if (expression && (this.month || this.month === 0) && this.unit !== "year") { finishUtils.setMonthsFromMonth.call(this, today, orient); } if (!this.unit) { this.unit = "day"; } finishUtils.setUnitValue.call(this, orient); parseMeridian.call(this); if ((this.month || this.month === 0) && !this.day) { this.day = 1; } if (!this.orient && !this.operator && this.unit === "week" && this.value && !this.day && !this.month) { return Date.today().setWeek(this.value); } if (this.unit === "week" && this.weeks && !this.day && !this.month) { return finishUtils.generateDateFromWeeks.call(this); } if (expression && this.timezone && this.day && this.days) { this.day = this.days; } if (expression){ today.add(this); } else { today.set(this); } if (this.timezone) { this.timezone = this.timezone.toUpperCase(); var offset = $D.getTimezoneOffset(this.timezone); var timezone; if (today.hasDaylightSavingTime()) { // lets check that we're being sane with timezone setting timezone = $D.getTimezoneAbbreviation(offset, today.isDaylightSavingTime()); if (timezone !== this.timezone) { // bugger, we're in a place where things like EST vs EDT matters. if (today.isDaylightSavingTime()) { today.addHours(-1); } else { today.addHours(1); } } } today.setTimezoneOffset(offset); } return today; } }; }()); (function () { var $D = Date; $D.Grammar = {}; var _ = $D.Parsing.Operators, g = $D.Grammar, t = $D.Translator, _fn; // Allow rolling up into general purpose rules _fn = function () { return _.each(_.any.apply(null, arguments), _.not(g.ctoken2("timeContext"))); }; g.datePartDelimiter = _.rtoken(/^([\s\-\.\,\/\x27]+)/); g.timePartDelimiter = _.stoken(":"); g.whiteSpace = _.rtoken(/^\s*/); g.generalDelimiter = _.rtoken(/^(([\s\,]|at|@|on)+)/); var _C = {}; g.ctoken = function (keys) { var fn = _C[keys]; if (! fn) { var c = Date.CultureInfo.regexPatterns; var kx = keys.split(/\s+/), px = []; for (var i = 0; i < kx.length ; i++) { px.push(_.replace(_.rtoken(c[kx[i]]), kx[i])); } fn = _C[keys] = _.any.apply(null, px); } return fn; }; g.ctoken2 = function (key) { return _.rtoken(Date.CultureInfo.regexPatterns[key]); }; var cacheProcessRtoken = function (key, token, type, eachToken) { if (eachToken) { g[key] = _.cache(_.process(_.each(_.rtoken(token),_.optional(g.ctoken2(eachToken))), type)); } else { g[key] = _.cache(_.process(_.rtoken(token), type)); } }; var cacheProcessCtoken = function (token, type) { return _.cache(_.process(g.ctoken2(token), type)); }; var _F = {}; //function cache var _get = function (f) { _F[f] = (_F[f] || g.format(f)[0]); return _F[f]; }; g.allformats = function (fx) { var rx = []; if (fx instanceof Array) { for (var i = 0; i < fx.length; i++) { rx.push(_get(fx[i])); } } else { rx.push(_get(fx)); } return rx; }; g.formats = function (fx) { if (fx instanceof Array) { var rx = []; for (var i = 0 ; i < fx.length ; i++) { rx.push(_get(fx[i])); } return _.any.apply(null, rx); } else { return _get(fx); } }; var grammarFormats = { timeFormats: function(){ var i, RTokenKeys = [ "h", "hh", "H", "HH", "m", "mm", "s", "ss", "ss.s", "z", "zz" ], RToken = [ /^(0[0-9]|1[0-2]|[1-9])/, /^(0[0-9]|1[0-2])/, /^([0-1][0-9]|2[0-3]|[0-9])/, /^([0-1][0-9]|2[0-3])/, /^([0-5][0-9]|[0-9])/, /^[0-5][0-9]/, /^([0-5][0-9]|[0-9])/, /^[0-5][0-9]/, /^[0-5][0-9]\.[0-9]{1,3}/, /^((\+|\-)\s*\d\d\d\d)|((\+|\-)\d\d\:?\d\d)/, /^((\+|\-)\s*\d\d\d\d)|((\+|\-)\d\d\:?\d\d)/ ], tokens = [ t.hour, t.hour, t.hour, t.hour, t.minute, t.minute, t.second, t.second, t.secondAndMillisecond, t.timezone, t.timezone ]; for (i=0; i < RTokenKeys.length; i++) { cacheProcessRtoken(RTokenKeys[i], RToken[i], tokens[i]); } g.hms = _.cache(_.sequence([g.H, g.m, g.s], g.timePartDelimiter)); g.t = cacheProcessCtoken("shortMeridian", t.meridian); g.tt = cacheProcessCtoken("longMeridian", t.meridian); g.zzz = cacheProcessCtoken("timezone", t.timezone); g.timeSuffix = _.each(_.ignore(g.whiteSpace), _.set([ g.tt, g.zzz ])); g.time = _.each(_.optional(_.ignore(_.stoken("T"))), g.hms, g.timeSuffix); }, dateFormats: function () { // pre-loaded rules for different date part order preferences var _setfn = function () { return _.set(arguments, g.datePartDelimiter); }; var i, RTokenKeys = [ "d", "dd", "M", "MM", "y", "yy", "yyy", "yyyy" ], RToken = [ /^([0-2]\d|3[0-1]|\d)/, /^([0-2]\d|3[0-1])/, /^(1[0-2]|0\d|\d)/, /^(1[0-2]|0\d)/, /^(\d+)/, /^(\d\d)/, /^(\d\d?\d?\d?)/, /^(\d\d\d\d)/ ], tokens = [ t.day, t.day, t.month, t.month, t.year, t.year, t.year, t.year ], eachToken = [ "ordinalSuffix", "ordinalSuffix" ]; for (i=0; i < RTokenKeys.length; i++) { cacheProcessRtoken(RTokenKeys[i], RToken[i], tokens[i], eachToken[i]); } g.MMM = g.MMMM = _.cache(_.process(g.ctoken("jan feb mar apr may jun jul aug sep oct nov dec"), t.month)); g.ddd = g.dddd = _.cache(_.process(g.ctoken("sun mon tue wed thu fri sat"), function (s) { return function () { this.weekday = s; }; } )); g.day = _fn(g.d, g.dd); g.month = _fn(g.M, g.MMM); g.year = _fn(g.yyyy, g.yy); g.mdy = _setfn(g.ddd, g.month, g.day, g.year); g.ymd = _setfn(g.ddd, g.year, g.month, g.day); g.dmy = _setfn(g.ddd, g.day, g.month, g.year); g.date = function (s) { return ((g[Date.CultureInfo.dateElementOrder] || g.mdy).call(this, s)); }; }, relative: function () { // relative date / time expressions g.orientation = _.process(g.ctoken("past future"), function (s) { return function () { this.orient = s; }; } ); g.operator = _.process(g.ctoken("add subtract"), function (s) { return function () { this.operator = s; }; } ); g.rday = _.process(g.ctoken("yesterday tomorrow today now"), t.rday); g.unit = _.process(g.ctoken("second minute hour day week month year"), function (s) { return function () { this.unit = s; }; } ); } }; g.buildGrammarFormats = function () { // these need to be rebuilt every time the language changes. _C = {}; grammarFormats.timeFormats(); grammarFormats.dateFormats(); grammarFormats.relative(); g.value = _.process(_.rtoken(/^([-+]?\d+)?(st|nd|rd|th)?/), function (s) { return function () { this.value = s.replace(/\D/g, ""); }; } ); g.expression = _.set([g.rday, g.operator, g.value, g.unit, g.orientation, g.ddd, g.MMM ]); g.format = _.process(_.many( _.any( // translate format specifiers into grammar rules _.process( _.rtoken(/^(dd?d?d?(?!e)|MM?M?M?|yy?y?y?|hh?|HH?|mm?|ss?|tt?|zz?z?)/), function (fmt) { if (g[fmt]) { return g[fmt]; } else { throw $D.Parsing.Exception(fmt); } } ), // translate separator tokens into token rules _.process(_.rtoken(/^[^dMyhHmstz]+/), // all legal separators function (s) { return _.ignore(_.stoken(s)); } ) ) ), // construct the parser ... function (rules) { return _.process(_.each.apply(null, rules), t.finishExact); } ); // starting rule for general purpose grammar g._start = _.process(_.set([ g.date, g.time, g.expression ], g.generalDelimiter, g.whiteSpace), t.finish); }; g.buildGrammarFormats(); // parsing date format specifiers - ex: "h:m:s tt" // this little guy will generate a custom parser based // on the format string, ex: g.format("h:m:s tt") // check for these formats first g._formats = g.formats([ "\"yyyy-MM-ddTHH:mm:ssZ\"", "yyyy-MM-ddTHH:mm:ss.sz", "yyyy-MM-ddTHH:mm:ssZ", "yyyy-MM-ddTHH:mm:ssz", "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-ddTHH:mmZ", "yyyy-MM-ddTHH:mmz", "yyyy-MM-ddTHH:mm", "ddd, MMM dd, yyyy H:mm:ss tt", "ddd MMM d yyyy HH:mm:ss zzz", "MMddyyyy", "ddMMyyyy", "Mddyyyy", "ddMyyyy", "Mdyyyy", "dMyyyy", "yyyy", "Mdyy", "dMyy", "d" ]); // real starting rule: tries selected formats first, // then general purpose rule g.start = function (s) { try { var r = g._formats.call({}, s); if (r[1].length === 0) { return r; } } catch (e) {} return g._start.call({}, s); }; }()); (function () { var $D = Date; /** * @desc Converts the specified string value into its JavaScript Date equivalent using CultureInfo specific format information. * * Example

	///////////
	// Dates //
	///////////

	// 15-Oct-2004
	var d1 = Date.parse("10/15/2004");

	// 15-Oct-2004
	var d1 = Date.parse("15-Oct-2004");

	// 15-Oct-2004
	var d1 = Date.parse("2004.10.15");

	//Fri Oct 15, 2004
	var d1 = Date.parse("Fri Oct 15, 2004");

	///////////
	// Times //
	///////////

	// Today at 10 PM.
	var d1 = Date.parse("10 PM");

	// Today at 10:30 PM.
	var d1 = Date.parse("10:30 P.M.");

	// Today at 6 AM.
	var d1 = Date.parse("06am");

	/////////////////////
	// Dates and Times //
	/////////////////////

	// 8-July-2004 @ 10:30 PM
	var d1 = Date.parse("July 8th, 2004, 10:30 PM");

	// 1-July-2004 @ 10:30 PM
	var d1 = Date.parse("2004-07-01T22:30:00");

	////////////////////
	// Relative Dates //
	////////////////////

	// Returns today's date. The string "today" is culture specific.
	var d1 = Date.parse("today");

	// Returns yesterday's date. The string "yesterday" is culture specific.
	var d1 = Date.parse("yesterday");

	// Returns the date of the next thursday.
	var d1 = Date.parse("Next thursday");

	// Returns the date of the most previous monday.
	var d1 = Date.parse("last monday");

	// Returns today's day + one year.
	var d1 = Date.parse("next year");

	///////////////
	// Date Math //
	///////////////

	// Today + 2 days
	var d1 = Date.parse("t+2");

	// Today + 2 days
	var d1 = Date.parse("today + 2 days");

	// Today + 3 months
	var d1 = Date.parse("t+3m");

	// Today - 1 year
	var d1 = Date.parse("today - 1 year");

	// Today - 1 year
	var d1 = Date.parse("t-1y"); 


	/////////////////////////////
	// Partial Dates and Times //
	/////////////////////////////

	// July 15th of this year.
	var d1 = Date.parse("July 15");

	// 15th day of current day and year.
	var d1 = Date.parse("15");

	// July 1st of current year at 10pm.
	var d1 = Date.parse("7/1 10pm");
	
* * @param {String} The string value to convert into a Date object [Required] * @return {Date} A Date object or null if the string cannot be converted into a Date. */ var parseUtils = { removeOrds: function (s) { ords = s.match(/\b(\d+)(?:st|nd|rd|th)\b/); // find ordinal matches s = ((ords && ords.length === 2) ? s.replace(ords[0], ords[1]) : s); return s; }, grammarParser: function (s) { var r = null; try { r = $D.Grammar.start.call({}, s.replace(/^\s*(\S*(\s+\S+)*)\s*$/, "$1")); } catch (e) { return null; } return ((r[1].length === 0) ? r[0] : null); }, nativeFallback: function(s) { var t; try { // ok we haven't parsed it, last ditch attempt with the built-in parser. t = Date._parse(s); return (t || t === 0) ? new Date(t) : null; } catch (e) { return null; } } }; function parse (s) { var d; if (!s) { return null; } if (s instanceof Date) { return s.clone(); } if (s.length >= 4 && s.charAt(0) !== "0" && s.charAt(0) !== "+"&& s.charAt(0) !== "-") { // ie: 2004 will pass, 0800 won't. // Start with specific formats d = $D.Parsing.ISO.parse(s) || $D.Parsing.Numeric.parse(s); } if (d instanceof Date && !isNaN(d.getTime())) { return d; } else { // find ordinal dates (1st, 3rd, 8th, etc and remove them as they cause parsing issues) s = $D.Parsing.Normalizer.parse(parseUtils.removeOrds(s)); d = parseUtils.grammarParser(s); if (d !== null) { return d; } else { return parseUtils.nativeFallback(s); } } } if (!$D._parse) { $D._parse = $D.parse; } $D.parse = parse; Date.getParseFunction = function (fx) { var fns = Date.Grammar.allformats(fx); return function (s) { var r = null; for (var i = 0; i < fns.length; i++) { try { r = fns[i].call({}, s); } catch (e) { continue; } if (r[1].length === 0) { return r[0]; } } return null; }; }; /** * Converts the specified string value into its JavaScript Date equivalent using the specified format {String} or formats {Array} and the CultureInfo specific format information. * The format of the string value must match one of the supplied formats exactly. * * Example

	// 15-Oct-2004
	var d1 = Date.parseExact("10/15/2004", "M/d/yyyy");

	// 15-Oct-2004
	var d1 = Date.parse("15-Oct-2004", "M-ddd-yyyy");

	// 15-Oct-2004
	var d1 = Date.parse("2004.10.15", "yyyy.MM.dd");

	// Multiple formats
	var d1 = Date.parseExact("10/15/2004", ["M/d/yyyy", "MMMM d, yyyy"]);
	
* * @param {String} The string value to convert into a Date object [Required]. * @param {Object} The expected format {String} or an array of expected formats {Array} of the date string [Required]. * @return {Date} A Date object or null if the string cannot be converted into a Date. */ $D.parseExact = function (s, fx) { return $D.getParseFunction(fx)(s); }; }()); (function () { var $D = Date, $P = $D.prototype, // $C = $D.CultureInfo, // not used atm p = function (s, l) { if (!l) { l = 2; } return ("000" + s).slice(l * -1); }; /** * Converts a PHP format string to Java/.NET format string. * A PHP format string can be used with ._format or .format. * A Java/.NET format string can be used with .toString(). * The .parseExact function will only accept a Java/.NET format string * * Example * var f1 = "%m/%d/%y" * var f2 = Date.normalizeFormat(f1); // "MM/dd/yy" * * new Date().format(f1); // "04/13/08" * new Date()._format(f1); // "04/13/08" * new Date().toString(f2); // "04/13/08" * * var date = Date.parseExact("04/13/08", f2); // Sun Apr 13 2008 * * @param {String} A PHP format string consisting of one or more format spcifiers. * @return {String} The PHP format converted to a Java/.NET format string. */ var normalizerSubstitutions = { "d" : "dd", "%d": "dd", "D" : "ddd", "%a": "ddd", "j" : "dddd", "l" : "dddd", "%A": "dddd", "S" : "S", "F" : "MMMM", "%B": "MMMM", "m" : "MM", "%m": "MM", "M" : "MMM", "%b": "MMM", "%h": "MMM", "n" : "M", "Y" : "yyyy", "%Y": "yyyy", "y" : "yy", "%y": "yy", "g" : "h", "%I": "h", "G" : "H", "h" : "hh", "H" : "HH", "%H": "HH", "i" : "mm", "%M": "mm", "s" : "ss", "%S": "ss", "%r": "hh:mm tt", "%R": "H:mm", "%T": "H:mm:ss", "%X": "t", "%x": "d", "%e": "d", "%D": "MM/dd/yy", "%n": "\\n", "%t": "\\t", "e" : "z", "T" : "z", "%z": "z", "%Z": "z", "Z" : "ZZ", "N" : "u", "w" : "u", "%w": "u", "W" : "W", "%V": "W" }; var normalizer = { substitutes: function (m) { return normalizerSubstitutions[m]; }, interpreted: function (m, x) { var y; switch (m) { case "%u": return x.getDay() + 1; case "z": return x.getOrdinalNumber(); case "%j": return p(x.getOrdinalNumber(), 3); case "%U": var d1 = x.clone().set({month: 0, day: 1}).addDays(-1).moveToDayOfWeek(0), d2 = x.clone().addDays(1).moveToDayOfWeek(0, -1); return (d2 < d1) ? "00" : p((d2.getOrdinalNumber() - d1.getOrdinalNumber()) / 7 + 1); case "%W": return p(x.getWeek()); case "t": return $D.getDaysInMonth(x.getFullYear(), x.getMonth()); case "o": case "%G": return x.setWeek(x.getISOWeek()).toString("yyyy"); case "%g": return x._format("%G").slice(-2); case "a": case "%p": return t("tt").toLowerCase(); case "A": return t("tt").toUpperCase(); case "u": return p(x.getMilliseconds(), 3); case "I": return (x.isDaylightSavingTime()) ? 1 : 0; case "O": return x.getUTCOffset(); case "P": y = x.getUTCOffset(); return y.substring(0, y.length - 2) + ":" + y.substring(y.length - 2); case "B": var now = new Date(); return Math.floor(((now.getHours() * 3600) + (now.getMinutes() * 60) + now.getSeconds() + (now.getTimezoneOffset() + 60) * 60) / 86.4); case "c": return x.toISOString().replace(/\"/g, ""); case "U": return $D.strtotime("now"); case "%c": return t("d") + " " + t("t"); case "%C": return Math.floor(x.getFullYear() / 100 + 1); } }, shouldOverrideDefaults: function (m) { switch (m) { case "%e": return true; default: return false; } }, parse: function (m, context) { var formatString, c = context || new Date(); formatString = normalizer.substitutes(m); if (formatString) { return formatString; } formatString = normalizer.interpreted(m, c); if (formatString) { return formatString; } else { return m; } } }; $D.normalizeFormat = function (format, context) { return format.replace(/(%|\\)?.|%%/g, function(t){ return normalizer.parse(t, context); }); }; /** * Format a local Unix timestamp according to locale settings * * Example: * Date.strftime("%m/%d/%y", new Date()); // "04/13/08" * Date.strftime("c", "2008-04-13T17:52:03Z"); // "04/13/08" * * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @param {Number|String} The number representing the number of seconds that have elapsed since January 1, 1970 (local time). * @return {String} A string representation of the current Date object. */ $D.strftime = function (format, time) { var d = Date.parse(time); return d._format(format); }; /** * Parse any textual datetime description into a Unix timestamp. * A Unix timestamp is the number of seconds that have elapsed since January 1, 1970 (midnight UTC/GMT). * * Example: * Date.strtotime("04/13/08"); // 1208044800 * Date.strtotime("1970-01-01T00:00:00Z"); // 0 * * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @param {Object} A string or date object. * @return {String} A string representation of the current Date object. */ $D.strtotime = function (time) { var d = $D.parse(time); return Math.round($D.UTC(d.getUTCFullYear(), d.getUTCMonth(), d.getUTCDate(), d.getUTCHours(), d.getUTCMinutes(), d.getUTCSeconds(), d.getUTCMilliseconds()) / 1000); }; /** * Converts the value of the current Date object to its equivalent string representation using a PHP/Unix style of date format specifiers. * Format Specifiers * Format Description Example * ------ --------------------------------------------------------------------------- ----------------------- * %a abbreviated weekday name according to the current localed "Mon" through "Sun" * %A full weekday name according to the current localed "Sunday" through "Saturday" * %b abbreviated month name according to the current localed "Jan" through "Dec" * %B full month name according to the current locale "January" through "December" * %c preferred date and time representation for the current locale "4/13/2008 12:33 PM" * %C century number (the year divided by 100 and truncated to an integer) "00" to "99" * %d day of the month as a decimal number "01" to "31" * %D same as %m/%d/%y "04/13/08" * %e day of the month as a decimal number, a single digit is preceded by a space "1" to "31" * %g like %G, but without the century "08" * %G The 4-digit year corresponding to the ISO week number (see %V). "2008" * This has the same format and value as %Y, except that if the ISO week number * belongs to the previous or next year, that year is used instead. * %h same as %b "Jan" through "Dec" * %H hour as a decimal number using a 24-hour clock. "00" to "23" * %I hour as a decimal number using a 12-hour clock. "01" to "12" * %j day of the year as a decimal number. "001" to "366" * %m month as a decimal number. "01" to "12" * %M minute as a decimal number. "00" to "59" * %n newline character "\n" * %p either "am" or "pm" according to the given time value, or the "am" or "pm" * corresponding strings for the current locale. * %r time in a.m. and p.m. notation "8:44 PM" * %R time in 24 hour notation "20:44" * %S second as a decimal number "00" to "59" * %t tab character "\t" * %T current time, equal to %H:%M:%S "12:49:11" * %u weekday as a decimal number ["1", "7"], with "1" representing Monday "1" to "7" * %U week number of the current year as a decimal number, starting with the "0" to ("52" or "53") * first Sunday as the first day of the first week * %V The ISO 8601:1988 week number of the current year as a decimal number, "00" to ("52" or "53") * range 01 to 53, where week 1 is the first week that has at least 4 days * in the current year, and with Monday as the first day of the week. * (Use %G or %g for the year component that corresponds to the week number * for the specified timestamp.) * %W week number of the current year as a decimal number, starting with the "00" to ("52" or "53") * first Monday as the first day of the first week * %w day of the week as a decimal, Sunday being "0" "0" to "6" * %x preferred date representation for the current locale without the time "4/13/2008" * %X preferred time representation for the current locale without the date "12:53:05" * %y year as a decimal number without a century "00" "99" * %Y year as a decimal number including the century "2008" * %Z time zone or name or abbreviation "UTC", "EST", "PST" * %z same as %Z * %% a literal "%" characters "%" * d Day of the month, 2 digits with leading zeros "01" to "31" * D A textual representation of a day, three letters "Mon" through "Sun" * j Day of the month without leading zeros "1" to "31" * l A full textual representation of the day of the week (lowercase "L") "Sunday" through "Saturday" * N ISO-8601 numeric representation of the day of the week (added in PHP 5.1.0) "1" (for Monday) through "7" (for Sunday) * S English ordinal suffix for the day of the month, 2 characters "st", "nd", "rd" or "th". Works well with j * w Numeric representation of the day of the week "0" (for Sunday) through "6" (for Saturday) * z The day of the year (starting from "0") "0" through "365" * W ISO-8601 week number of year, weeks starting on Monday "00" to ("52" or "53") * F A full textual representation of a month, such as January or March "January" through "December" * m Numeric representation of a month, with leading zeros "01" through "12" * M A short textual representation of a month, three letters "Jan" through "Dec" * n Numeric representation of a month, without leading zeros "1" through "12" * t Number of days in the given month "28" through "31" * L Whether it's a leap year "1" if it is a leap year, "0" otherwise * o ISO-8601 year number. This has the same value as Y, except that if the "2008" * ISO week number (W) belongs to the previous or next year, that year * is used instead. * Y A full numeric representation of a year, 4 digits "2008" * y A two digit representation of a year "08" * a Lowercase Ante meridiem and Post meridiem "am" or "pm" * A Uppercase Ante meridiem and Post meridiem "AM" or "PM" * B Swatch Internet time "000" through "999" * g 12-hour format of an hour without leading zeros "1" through "12" * G 24-hour format of an hour without leading zeros "0" through "23" * h 12-hour format of an hour with leading zeros "01" through "12" * H 24-hour format of an hour with leading zeros "00" through "23" * i Minutes with leading zeros "00" to "59" * s Seconds, with leading zeros "00" through "59" * u Milliseconds "54321" * e Timezone identifier "UTC", "EST", "PST" * I Whether or not the date is in daylight saving time (uppercase i) "1" if Daylight Saving Time, "0" otherwise * O Difference to Greenwich time (GMT) in hours "+0200", "-0600" * P Difference to Greenwich time (GMT) with colon between hours and minutes "+02:00", "-06:00" * T Timezone abbreviation "UTC", "EST", "PST" * Z Timezone offset in seconds. The offset for timezones west of UTC is "-43200" through "50400" * always negative, and for those east of UTC is always positive. * c ISO 8601 date "2004-02-12T15:19:21+00:00" * r RFC 2822 formatted date "Thu, 21 Dec 2000 16:01:07 +0200" * U Seconds since the Unix Epoch (January 1 1970 00:00:00 GMT) "0" * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @return {String} A string representation of the current Date object. */ var formatReplace = function (context) { return function (m) { var formatString, override = false; if (m.charAt(0) === "\\" || m.substring(0, 2) === "%%") { return m.replace("\\", "").replace("%%", "%"); } override = normalizer.shouldOverrideDefaults(m); formatString = $D.normalizeFormat(m, context); if (formatString) { return context.toString(formatString, override); } }; }; $P._format = function (format) { var formatter = formatReplace(this); if (!format) { return this._toString(); } else { return format.replace(/(%|\\)?.|%%/g, formatter); } }; if (!$P.format) { $P.format = $P._format; } }()); (function () { "use strict"; var gFn = function (attr) { return function () { return this[attr]; }; }; var sFn = function (attr) { return function (val) { this[attr] = val; return this; }; }; var attrs = ["years", "months", "days", "hours", "minutes", "seconds", "milliseconds"]; var addSetFuncs = function (context, attrs) { for (var i = 0; i < attrs.length ; i++) { var $a = attrs[i], $b = $a.slice(0, 1).toUpperCase() + $a.slice(1); context.prototype[$a] = 0; context.prototype["get" + $b] = gFn($a); context.prototype["set" + $b] = sFn($a); } }; /** * new TimeSpan(milliseconds); * new TimeSpan(days, hours, minutes, seconds); * new TimeSpan(days, hours, minutes, seconds, milliseconds); */ var TimeSpan = function (days, hours, minutes, seconds, milliseconds) { if (arguments.length === 1 && typeof days === "number") { var orient = (days < 0) ? -1 : +1; var millsLeft = Math.abs(days); this.setDays(Math.floor(millsLeft / 86400000) * orient); millsLeft = millsLeft % 86400000; this.setHours(Math.floor(millsLeft / 3600000) * orient); millsLeft = millsLeft % 3600000; this.setMinutes(Math.floor(millsLeft / 60000) * orient); millsLeft = millsLeft % 60000; this.setSeconds(Math.floor(millsLeft / 1000) * orient); millsLeft = millsLeft % 1000; this.setMilliseconds(millsLeft * orient); } else { this.set(days, hours, minutes, seconds, milliseconds); } this.getTotalMilliseconds = function () { return (this.getDays() * 86400000) + (this.getHours() * 3600000) + (this.getMinutes() * 60000) + (this.getSeconds() * 1000); }; this.compareTo = function (time) { var t1 = new Date(1970, 1, 1, this.getHours(), this.getMinutes(), this.getSeconds()), t2; if (time === null) { t2 = new Date(1970, 1, 1, 0, 0, 0); } else { t2 = new Date(1970, 1, 1, time.getHours(), time.getMinutes(), time.getSeconds()); } return (t1 < t2) ? -1 : (t1 > t2) ? 1 : 0; }; this.equals = function (time) { return (this.compareTo(time) === 0); }; this.add = function (time) { return (time === null) ? this : this.addSeconds(time.getTotalMilliseconds() / 1000); }; this.subtract = function (time) { return (time === null) ? this : this.addSeconds(-time.getTotalMilliseconds() / 1000); }; this.addDays = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 86400000)); }; this.addHours = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 3600000)); }; this.addMinutes = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 60000)); }; this.addSeconds = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 1000)); }; this.addMilliseconds = function (n) { return new TimeSpan(this.getTotalMilliseconds() + n); }; this.get12HourHour = function () { return (this.getHours() > 12) ? this.getHours() - 12 : (this.getHours() === 0) ? 12 : this.getHours(); }; this.getDesignator = function () { return (this.getHours() < 12) ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator; }; this.toString = function (format) { this._toString = function () { if (this.getDays() !== null && this.getDays() > 0) { return this.getDays() + "." + this.getHours() + ":" + this.p(this.getMinutes()) + ":" + this.p(this.getSeconds()); } else { return this.getHours() + ":" + this.p(this.getMinutes()) + ":" + this.p(this.getSeconds()); } }; this.p = function (s) { return (s.toString().length < 2) ? "0" + s : s; }; var me = this; return format ? format.replace(/dd?|HH?|hh?|mm?|ss?|tt?/g, function (format) { switch (format) { case "d": return me.getDays(); case "dd": return me.p(me.getDays()); case "H": return me.getHours(); case "HH": return me.p(me.getHours()); case "h": return me.get12HourHour(); case "hh": return me.p(me.get12HourHour()); case "m": return me.getMinutes(); case "mm": return me.p(me.getMinutes()); case "s": return me.getSeconds(); case "ss": return me.p(me.getSeconds()); case "t": return ((me.getHours() < 12) ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator).substring(0, 1); case "tt": return (me.getHours() < 12) ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator; } } ) : this._toString(); }; return this; }; addSetFuncs(TimeSpan, attrs.slice(2)); TimeSpan.prototype.set = function (days, hours, minutes, seconds, milliseconds){ this.setDays(days || this.getDays()); this.setHours(hours || this.getHours()); this.setMinutes(minutes || this.getMinutes()); this.setSeconds(seconds || this.getSeconds()); this.setMilliseconds(milliseconds || this.getMilliseconds()); }; /** * Gets the time of day for this date instances. * @return {TimeSpan} TimeSpan */ Date.prototype.getTimeOfDay = function () { return new TimeSpan(0, this.getHours(), this.getMinutes(), this.getSeconds(), this.getMilliseconds()); }; Date.TimeSpan = TimeSpan; if (typeof window !== "undefined" ) { // keeping API compatible for v1.x window.TimeSpan = TimeSpan; } }()); (function () { "use strict"; var attrs = ["years", "months", "days", "hours", "minutes", "seconds", "milliseconds"]; var gFn = function (attr) { return function () { return this[attr]; }; }; var sFn = function (attr) { return function (val) { this[attr] = val; return this; }; }; var addSetFuncs = function (context, attrs) { for (var i = 0; i < attrs.length ; i++) { var $a = attrs[i], $b = $a.slice(0, 1).toUpperCase() + $a.slice(1); context.prototype[$a] = 0; context.prototype["get" + $b] = gFn($a); context.prototype["set" + $b] = sFn($a); } }; var setMonthsAndYears = function (orient, d1, d2, context) { function inc() { d1.addMonths(-orient); context.months++; if (context.months === 12) { context.years++; context.months = 0; } } if (orient === +1) { while (d1 > d2) { inc(); } } else { while (d1 < d2) { inc(); } } context.months--; context.months *= orient; context.years *= orient; }; var adjustForDST = function(orient, startDate, endDate) { var hasDSTMismatch = (false === (startDate.isDaylightSavingTime() === endDate.isDaylightSavingTime())); if (hasDSTMismatch && orient === 1) { startDate.addHours(-1); } else if (hasDSTMismatch) { startDate.addHours(1); } }; /** * TimePeriod(startDate, endDate); * TimePeriod(years, months, days, hours, minutes, seconds, milliseconds); */ var TimePeriod = function (years, months, days, hours, minutes, seconds, milliseconds) { if (arguments.length === 7) { this.set(years, months, days, hours, minutes, seconds, milliseconds); } else if (arguments.length === 2 && arguments[0] instanceof Date && arguments[1] instanceof Date) { var startDate = arguments[0].clone(); var endDate = arguments[1].clone(); var orient = (startDate > endDate) ? +1 : -1; this.dates = { start: arguments[0].clone(), end: arguments[1].clone() }; setMonthsAndYears(orient, startDate, endDate, this); adjustForDST(orient, startDate, endDate); // // TODO - adjust for DST var diff = endDate - startDate; if (diff !== 0) { var ts = new TimeSpan(diff); this.set(this.years, this.months, ts.getDays(), ts.getHours(), ts.getMinutes(), ts.getSeconds(), ts.getMilliseconds()); } } return this; }; // create all the set functions. addSetFuncs(TimePeriod, attrs); TimePeriod.prototype.set = function (years, months, days, hours, minutes, seconds, milliseconds){ this.setYears(years || this.getYears()); this.setMonths(months || this.getMonths()); this.setDays(days || this.getDays()); this.setHours(hours || this.getHours()); this.setMinutes(minutes || this.getMinutes()); this.setSeconds(seconds || this.getSeconds()); this.setMilliseconds(milliseconds || this.getMilliseconds()); }; Date.TimePeriod = TimePeriod; if (typeof window !== "undefined") { // keeping API compatible for v1.x window.TimePeriod = TimePeriod; } }()); ================================================ FILE: build/date-ar-KW.js ================================================ /** * @overview datejs * @version 1.0.0-rc3 * @author Gregory Wild-Smith * @copyright 2015 Gregory Wild-Smith * @license MIT * @homepage https://github.com/abritinthebay/datejs */ /* * DateJS Culture String File * Country Code: ar-KW * Name: Arabic (Kuwait) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["ar-KW"] = { "name": "ar-KW", "englishName": "Arabic (Kuwait)", "nativeName": "العربية (الكويت)", "Sunday": "الاحد", "Monday": "الاثنين", "Tuesday": "الثلاثاء", "Wednesday": "الاربعاء", "Thursday": "الخميس", "Friday": "الجمعة", "Saturday": "السبت", "Sun": "الاحد", "Mon": "الاثنين", "Tue": "الثلاثاء", "Wed": "الاربعاء", "Thu": "الخميس", "Fri": "الجمعة", "Sat": "السبت", "Su": "أ", "Mo": "ا", "Tu": "ث", "We": "أ", "Th": "خ", "Fr": "ج", "Sa": "س", "S_Sun_Initial": "أ", "M_Mon_Initial": "ا", "T_Tue_Initial": "ث", "W_Wed_Initial": "أ", "T_Thu_Initial": "خ", "F_Fri_Initial": "ج", "S_Sat_Initial": "س", "January": "يناير", "February": "فبراير", "March": "مارس", "April": "ابريل", "May": "مايو", "June": "يونيو", "July": "يوليو", "August": "اغسطس", "September": "سبتمبر", "October": "اكتوبر", "November": "نوفمبر", "December": "ديسمبر", "Jan_Abbr": "يناير", "Feb_Abbr": "فبراير", "Mar_Abbr": "مارس", "Apr_Abbr": "ابريل", "May_Abbr": "مايو", "Jun_Abbr": "يونيو", "Jul_Abbr": "يوليو", "Aug_Abbr": "اغسطس", "Sep_Abbr": "سبتمبر", "Oct_Abbr": "اكتوبر", "Nov_Abbr": "نوفمبر", "Dec_Abbr": "ديسمبر", "AM": "ص", "PM": "م", "firstDayOfWeek": 6, "twoDigitYearMax": 2029, "mdy": "dmy", "M/d/yyyy": "dd/MM/yyyy", "dddd, MMMM dd, yyyy": "dd MMMM, yyyy", "h:mm tt": "hh:mm tt", "h:mm:ss tt": "hh:mm:ss tt", "dddd, MMMM dd, yyyy h:mm:ss tt": "dd MMMM, yyyy hh:mm:ss tt", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "dd MMMM", "MMMM, yyyy": "MMMM, yyyy", "/jan(uary)?/": "يناير", "/feb(ruary)?/": "فبراير", "/mar(ch)?/": "مارس", "/apr(il)?/": "ابريل", "/may/": "مايو", "/jun(e)?/": "يونيو", "/jul(y)?/": "يوليو", "/aug(ust)?/": "اغسطس", "/sep(t(ember)?)?/": "سبتمبر", "/oct(ober)?/": "اكتوبر", "/nov(ember)?/": "نوفمبر", "/dec(ember)?/": "ديسمبر", "/^su(n(day)?)?/": "^الاحد", "/^mo(n(day)?)?/": "^ا(1)?", "/^tu(e(s(day)?)?)?/": "^الثلاثاء", "/^we(d(nesday)?)?/": "^الاربعاء", "/^th(u(r(s(day)?)?)?)?/": "^الخميس", "/^fr(i(day)?)?/": "^الجمعة", "/^sa(t(urday)?)?/": "^السبت", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "ar-KW"; /** * @overview datejs * @version 1.0.0-rc3 * @author Gregory Wild-Smith * @copyright 2015 Gregory Wild-Smith * @license MIT * @homepage https://github.com/abritinthebay/datejs */(function () { var $D = Date; var lang = Date.CultureStrings ? Date.CultureStrings.lang : null; var loggedKeys = {}; // for debug purposes. var getText = { getFromKey: function (key, countryCode) { var output; if (Date.CultureStrings && Date.CultureStrings[countryCode] && Date.CultureStrings[countryCode][key]) { output = Date.CultureStrings[countryCode][key]; } else { output = getText.buildFromDefault(key); } if (key.charAt(0) === "/") { // Assume it's a regex output = getText.buildFromRegex(key, countryCode); } return output; }, getFromObjectValues: function (obj, countryCode) { var key, output = {}; for(key in obj) { if (obj.hasOwnProperty(key)) { output[key] = getText.getFromKey(obj[key], countryCode); } } return output; }, getFromObjectKeys: function (obj, countryCode) { var key, output = {}; for(key in obj) { if (obj.hasOwnProperty(key)) { output[getText.getFromKey(key, countryCode)] = obj[key]; } } return output; }, getFromArray: function (arr, countryCode) { var output = []; for (var i=0; i < arr.length; i++){ if (i in arr) { output[i] = getText.getFromKey(arr[i], countryCode); } } return output; }, buildFromDefault: function (key) { var output, length, split, last; switch(key) { case "name": output = "en-US"; break; case "englishName": output = "English (United States)"; break; case "nativeName": output = "English (United States)"; break; case "twoDigitYearMax": output = 2049; break; case "firstDayOfWeek": output = 0; break; default: output = key; split = key.split("_"); length = split.length; if (length > 1 && key.charAt(0) !== "/") { // if the key isn't a regex and it has a split. last = split[(length - 1)].toLowerCase(); if (last === "initial" || last === "abbr") { output = split[0]; } } break; } return output; }, buildFromRegex: function (key, countryCode) { var output; if (Date.CultureStrings && Date.CultureStrings[countryCode] && Date.CultureStrings[countryCode][key]) { output = new RegExp(Date.CultureStrings[countryCode][key], "i"); } else { output = new RegExp(key.replace(new RegExp("/", "g"),""), "i"); } return output; } }; var shallowMerge = function (obj1, obj2) { for (var attrname in obj2) { if (obj2.hasOwnProperty(attrname)) { obj1[attrname] = obj2[attrname]; } } }; var __ = function (key, language) { var countryCode = (language) ? language : lang; loggedKeys[key] = key; if (typeof key === "object") { if (key instanceof Array) { return getText.getFromArray(key, countryCode); } else { return getText.getFromObjectKeys(key, countryCode); } } else { return getText.getFromKey(key, countryCode); } }; var loadI18nScript = function (code) { // paatterned after jQuery's getScript. var url = Date.Config.i18n + code + ".js"; var head = document.getElementsByTagName("head")[0] || document.documentElement; var script = document.createElement("script"); script.src = url; var completed = false; var events = { done: function (){} // placeholder function }; // Attach handlers for all browsers script.onload = script.onreadystatechange = function() { if ( !completed && (!this.readyState || this.readyState === "loaded" || this.readyState === "complete") ) { events.done(); head.removeChild(script); } }; setTimeout(function() { head.insertBefore(script, head.firstChild); }, 0); // allows return to execute first return { done: function (cb) { events.done = function() { if (cb) { setTimeout(cb,0); } }; } }; }; var buildInfo = { buildFromMethodHash: function (obj) { var key; for(key in obj) { if (obj.hasOwnProperty(key)) { obj[key] = buildInfo[obj[key]](); } } return obj; }, timeZoneDST: function () { var DST = { "CHADT": "+1345", "NZDT": "+1300", "AEDT": "+1100", "ACDT": "+1030", "AZST": "+0500", "IRDT": "+0430", "EEST": "+0300", "CEST": "+0200", "BST": "+0100", "PMDT": "-0200", "ADT": "-0300", "NDT": "-0230", "EDT": "-0400", "CDT": "-0500", "MDT": "-0600", "PDT": "-0700", "AKDT": "-0800", "HADT": "-0900" }; return __(DST); }, timeZoneStandard: function () { var standard = { "LINT": "+1400", "TOT": "+1300", "CHAST": "+1245", "NZST": "+1200", "NFT": "+1130", "SBT": "+1100", "AEST": "+1000", "ACST": "+0930", "JST": "+0900", "CWST": "+0845", "CT": "+0800", "ICT": "+0700", "MMT": "+0630", "BST": "+0600", "NPT": "+0545", "IST": "+0530", "PKT": "+0500", "AFT": "+0430", "MSK": "+0400", "IRST": "+0330", "FET": "+0300", "EET": "+0200", "CET": "+0100", "GMT": "+0000", "UTC": "+0000", "CVT": "-0100", "GST": "-0200", "BRT": "-0300", "NST": "-0330", "AST": "-0400", "EST": "-0500", "CST": "-0600", "MST": "-0700", "PST": "-0800", "AKST": "-0900", "MIT": "-0930", "HST": "-1000", "SST": "-1100", "BIT": "-1200" }; return __(standard); }, timeZones: function (data) { var zone; data.timezones = []; for (zone in data.abbreviatedTimeZoneStandard) { if (data.abbreviatedTimeZoneStandard.hasOwnProperty(zone)) { data.timezones.push({ name: zone, offset: data.abbreviatedTimeZoneStandard[zone]}); } } for (zone in data.abbreviatedTimeZoneDST) { if (data.abbreviatedTimeZoneDST.hasOwnProperty(zone)) { data.timezones.push({ name: zone, offset: data.abbreviatedTimeZoneDST[zone], dst: true}); } } return data.timezones; }, days: function () { return __(["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"]); }, dayAbbr: function () { return __(["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"]); }, dayShortNames: function () { return __(["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"]); }, dayFirstLetters: function () { return __(["S_Sun_Initial", "M_Mon_Initial", "T_Tues_Initial", "W_Wed_Initial", "T_Thu_Initial", "F_Fri_Initial", "S_Sat_Initial"]); }, months: function () { return __(["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"]); }, monthAbbr: function () { return __(["Jan_Abbr", "Feb_Abbr", "Mar_Abbr", "Apr_Abbr", "May_Abbr", "Jun_Abbr", "Jul_Abbr", "Aug_Abbr", "Sep_Abbr", "Oct_Abbr", "Nov_Abbr", "Dec_Abbr"]); }, formatPatterns: function () { return getText.getFromObjectValues({ shortDate: "M/d/yyyy", longDate: "dddd, MMMM dd, yyyy", shortTime: "h:mm tt", longTime: "h:mm:ss tt", fullDateTime: "dddd, MMMM dd, yyyy h:mm:ss tt", sortableDateTime: "yyyy-MM-ddTHH:mm:ss", universalSortableDateTime: "yyyy-MM-dd HH:mm:ssZ", rfc1123: "ddd, dd MMM yyyy HH:mm:ss", monthDay: "MMMM dd", yearMonth: "MMMM, yyyy" }, Date.i18n.currentLanguage()); }, regex: function () { return getText.getFromObjectValues({ inTheMorning: "/( in the )(morn(ing)?)\\b/", thisMorning: "/(this )(morn(ing)?)\\b/", amThisMorning: "/(\b\\d(am)? )(this )(morn(ing)?)/", inTheEvening: "/( in the )(even(ing)?)\\b/", thisEvening: "/(this )(even(ing)?)\\b/", pmThisEvening: "/(\b\\d(pm)? )(this )(even(ing)?)/", jan: "/jan(uary)?/", feb: "/feb(ruary)?/", mar: "/mar(ch)?/", apr: "/apr(il)?/", may: "/may/", jun: "/jun(e)?/", jul: "/jul(y)?/", aug: "/aug(ust)?/", sep: "/sep(t(ember)?)?/", oct: "/oct(ober)?/", nov: "/nov(ember)?/", dec: "/dec(ember)?/", sun: "/^su(n(day)?)?/", mon: "/^mo(n(day)?)?/", tue: "/^tu(e(s(day)?)?)?/", wed: "/^we(d(nesday)?)?/", thu: "/^th(u(r(s(day)?)?)?)?/", fri: "/fr(i(day)?)?/", sat: "/^sa(t(urday)?)?/", future: "/^next/", past: "/^last|past|prev(ious)?/", add: "/^(\\+|aft(er)?|from|hence)/", subtract: "/^(\\-|bef(ore)?|ago)/", yesterday: "/^yes(terday)?/", today: "/^t(od(ay)?)?/", tomorrow: "/^tom(orrow)?/", now: "/^n(ow)?/", millisecond: "/^ms|milli(second)?s?/", second: "/^sec(ond)?s?/", minute: "/^mn|min(ute)?s?/", hour: "/^h(our)?s?/", week: "/^w(eek)?s?/", month: "/^m(onth)?s?/", day: "/^d(ay)?s?/", year: "/^y(ear)?s?/", shortMeridian: "/^(a|p)/", longMeridian: "/^(a\\.?m?\\.?|p\\.?m?\\.?)/", timezone: "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/", ordinalSuffix: "/^\\s*(st|nd|rd|th)/", timeContext: "/^\\s*(\\:|a(?!u|p)|p)/" }, Date.i18n.currentLanguage()); } }; var CultureInfo = function () { var info = getText.getFromObjectValues({ name: "name", englishName: "englishName", nativeName: "nativeName", amDesignator: "AM", pmDesignator: "PM", firstDayOfWeek: "firstDayOfWeek", twoDigitYearMax: "twoDigitYearMax", dateElementOrder: "mdy" }, Date.i18n.currentLanguage()); var constructedInfo = buildInfo.buildFromMethodHash({ dayNames: "days", abbreviatedDayNames: "dayAbbr", shortestDayNames: "dayShortNames", firstLetterDayNames: "dayFirstLetters", monthNames: "months", abbreviatedMonthNames: "monthAbbr", formatPatterns: "formatPatterns", regexPatterns: "regex", abbreviatedTimeZoneDST: "timeZoneDST", abbreviatedTimeZoneStandard: "timeZoneStandard" }); shallowMerge(info, constructedInfo); buildInfo.timeZones(info); return info; }; $D.i18n = { __: function (key, lang) { return __(key, lang); }, currentLanguage: function () { return lang || "en-US"; }, setLanguage: function (code, force, cb) { var async = false; if (force || code === "en-US" || (!!Date.CultureStrings && !!Date.CultureStrings[code])) { lang = code; Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings.lang = code; Date.CultureInfo = new CultureInfo(); } else { if (!(!!Date.CultureStrings && !!Date.CultureStrings[code])) { if (typeof exports !== "undefined" && this.exports !== exports) { // we're in a Node enviroment, load it using require try { require("../i18n/" + code + ".js"); lang = code; Date.CultureStrings.lang = code; Date.CultureInfo = new CultureInfo(); } catch (e) { // var str = "The language for '" + code + "' could not be loaded by Node. It likely does not exist."; throw new Error("The DateJS IETF language tag '" + code + "' could not be loaded by Node. It likely does not exist."); } } else if (Date.Config && Date.Config.i18n) { // we know the location of the files, so lets load them async = true; loadI18nScript(code).done(function(){ lang = code; Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings.lang = code; Date.CultureInfo = new CultureInfo(); $D.Parsing.Normalizer.buildReplaceData(); // because this is async if ($D.Grammar) { $D.Grammar.buildGrammarFormats(); // so we can parse those strings... } if (cb) { setTimeout(cb,0); } }); } else { Date.console.error("The DateJS IETF language tag '" + code + "' is not available and has not been loaded."); return false; } } } $D.Parsing.Normalizer.buildReplaceData(); // rebuild normalizer strings if ($D.Grammar) { $D.Grammar.buildGrammarFormats(); // so we can parse those strings... } if (!async && cb) { setTimeout(cb,0); } }, getLoggedKeys: function () { return loggedKeys; }, updateCultureInfo: function () { Date.CultureInfo = new CultureInfo(); } }; $D.i18n.updateCultureInfo(); // run automatically }()); (function () { var $D = Date, $P = $D.prototype, p = function (s, l) { if (!l) { l = 2; } return ("000" + s).slice(l * -1); }; if (typeof window !== "undefined" && typeof window.console !== "undefined" && typeof window.console.log !== "undefined") { $D.console = console; // used only to raise non-critical errors if available } else { // set mock so we don't give errors. $D.console = { log: function(){}, error: function(){} }; } $D.Config = $D.Config || {}; $D.initOverloads = function() { /** * Overload of Date.now. Allows an alternate call for Date.now where it returns the * current Date as an object rather than just milliseconds since the Unix Epoch. * * Also provides an implementation of now() for browsers (IE<9) that don't have it. * * Backwards compatible so with work with either: * Date.now() [returns ms] * or * Date.now(true) [returns Date] */ if (!$D.now) { $D._now = function now() { return new Date().getTime(); }; } else if (!$D._now) { $D._now = $D.now; } $D.now = function (returnObj) { if (returnObj) { return $D.present(); } else { return $D._now(); } }; if ( !$P.toISOString ) { $P.toISOString = function() { return this.getUTCFullYear() + "-" + p(this.getUTCMonth() + 1) + "-" + p(this.getUTCDate()) + "T" + p(this.getUTCHours()) + ":" + p(this.getUTCMinutes()) + ":" + p(this.getUTCSeconds()) + "." + String( (this.getUTCMilliseconds()/1000).toFixed(3)).slice(2, 5) + "Z"; }; } // private if ( $P._toString === undefined ){ $P._toString = $P.toString; } }; $D.initOverloads(); /** * Gets a date that is set to the current date. The time is set to the start of the day (00:00 or 12:00 AM). * @return {Date} The current date. */ $D.today = function () { return new Date().clearTime(); }; /** * Gets a date that is set to the current date and time (same as new Date, but chainable) * @return {Date} The current date. */ $D.present = function () { return new Date(); }; /** * Compares the first date to the second date and returns an number indication of their relative values. * @param {Date} First Date object to compare [Required]. * @param {Date} Second Date object to compare to [Required]. * @return {Number} -1 = date1 is lessthan date2. 0 = values are equal. 1 = date1 is greaterthan date2. */ $D.compare = function (date1, date2) { if (isNaN(date1) || isNaN(date2)) { throw new Error(date1 + " - " + date2); } else if (date1 instanceof Date && date2 instanceof Date) { return (date1 < date2) ? -1 : (date1 > date2) ? 1 : 0; } else { throw new TypeError(date1 + " - " + date2); } }; /** * Compares the first Date object to the second Date object and returns true if they are equal. * @param {Date} First Date object to compare [Required] * @param {Date} Second Date object to compare to [Required] * @return {Boolean} true if dates are equal. false if they are not equal. */ $D.equals = function (date1, date2) { return (date1.compareTo(date2) === 0); }; /** * Gets the language appropriate day name when given the day number(0-6) * eg - 0 == Sunday * @return {String} The day name */ $D.getDayName = function (n) { return Date.CultureInfo.dayNames[n]; }; /** * Gets the day number (0-6) if given a CultureInfo specific string which is a valid dayName, abbreviatedDayName or shortestDayName (two char). * @param {String} The name of the day (eg. "Monday, "Mon", "tuesday", "tue", "We", "we"). * @return {Number} The day number */ $D.getDayNumberFromName = function (name) { var n = Date.CultureInfo.dayNames, m = Date.CultureInfo.abbreviatedDayNames, o = Date.CultureInfo.shortestDayNames, s = name.toLowerCase(); for (var i = 0; i < n.length; i++) { if (n[i].toLowerCase() === s || m[i].toLowerCase() === s || o[i].toLowerCase() === s) { return i; } } return -1; }; /** * Gets the month number (0-11) if given a Culture Info specific string which is a valid monthName or abbreviatedMonthName. * @param {String} The name of the month (eg. "February, "Feb", "october", "oct"). * @return {Number} The day number */ $D.getMonthNumberFromName = function (name) { var n = Date.CultureInfo.monthNames, m = Date.CultureInfo.abbreviatedMonthNames, s = name.toLowerCase(); for (var i = 0; i < n.length; i++) { if (n[i].toLowerCase() === s || m[i].toLowerCase() === s) { return i; } } return -1; }; /** * Gets the language appropriate month name when given the month number(0-11) * eg - 0 == January * @return {String} The month name */ $D.getMonthName = function (n) { return Date.CultureInfo.monthNames[n]; }; /** * Determines if the current date instance is within a LeapYear. * @param {Number} The year. * @return {Boolean} true if date is within a LeapYear, otherwise false. */ $D.isLeapYear = function (year) { return ((year % 4 === 0 && year % 100 !== 0) || year % 400 === 0); }; /** * Gets the number of days in the month, given a year and month value. Automatically corrects for LeapYear. * @param {Number} The year. * @param {Number} The month (0-11). * @return {Number} The number of days in the month. */ $D.getDaysInMonth = function (year, month) { if (!month && $D.validateMonth(year)) { month = year; year = Date.today().getFullYear(); } return [31, ($D.isLeapYear(year) ? 29 : 28), 31, 30, 31, 30, 31, 31, 30, 31, 30, 31][month]; }; $P.getDaysInMonth = function () { return $D.getDaysInMonth(this.getFullYear(), this.getMonth()); }; $D.getTimezoneAbbreviation = function (offset, dst) { var p, n = (dst || false) ? Date.CultureInfo.abbreviatedTimeZoneDST : Date.CultureInfo.abbreviatedTimeZoneStandard; for (p in n) { if (n.hasOwnProperty(p)) { if (n[p] === offset) { return p; } } } return null; }; $D.getTimezoneOffset = function (name, dst) { var i, a =[], z = Date.CultureInfo.timezones; if (!name) { name = (new Date()).getTimezone();} for (i = 0; i < z.length; i++) { if (z[i].name === name.toUpperCase()) { a.push(i); } } if (!z[a[0]]) { return null; } if (a.length === 1 || !dst) { return z[a[0]].offset; } else { for (i=0; i < a.length; i++) { if (z[a[i]].dst) { return z[a[i]].offset; } } } }; $D.getQuarter = function (d) { d = d || new Date(); // If no date supplied, use today var q = [1,2,3,4]; return q[Math.floor(d.getMonth() / 3)]; // ~~~ is a bitwise op. Faster than Math.floor }; $D.getDaysLeftInQuarter = function (d) { d = d || new Date(); var qEnd = new Date(d); qEnd.setMonth(qEnd.getMonth() + 3 - qEnd.getMonth() % 3, 0); return Math.floor((qEnd - d) / 8.64e7); }; // private var validate = function (n, min, max, name) { name = name ? name : "Object"; if (typeof n === "undefined") { return false; } else if (typeof n !== "number") { throw new TypeError(n + " is not a Number."); } else if (n < min || n > max) { // As failing validation is *not* an exceptional circumstance // lets not throw a RangeError Exception here. // It's semantically correct but it's not sensible. return false; } return true; }; /** * Validates the number is within an acceptable range for milliseconds [0-999]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateMillisecond = function (value) { return validate(value, 0, 999, "millisecond"); }; /** * Validates the number is within an acceptable range for seconds [0-59]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateSecond = function (value) { return validate(value, 0, 59, "second"); }; /** * Validates the number is within an acceptable range for minutes [0-59]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateMinute = function (value) { return validate(value, 0, 59, "minute"); }; /** * Validates the number is within an acceptable range for hours [0-23]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateHour = function (value) { return validate(value, 0, 23, "hour"); }; /** * Validates the number is within an acceptable range for the days in a month [0-MaxDaysInMonth]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateDay = function (value, year, month) { if (year === undefined || year === null || month === undefined || month === null) { return false;} return validate(value, 1, $D.getDaysInMonth(year, month), "day"); }; /** * Validates the number is within an acceptable range for months [0-11]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateWeek = function (value) { return validate(value, 0, 53, "week"); }; /** * Validates the number is within an acceptable range for months [0-11]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateMonth = function (value) { return validate(value, 0, 11, "month"); }; /** * Validates the number is within an acceptable range for years. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateYear = function (value) { /** * Per ECMAScript spec the range of times supported by Date objects is * exactly -100,000,000 days to +100,000,000 days measured relative to * midnight at the beginning of 01 January, 1970 UTC. * This gives a range of 8,640,000,000,000,000 milliseconds to either * side of 01 January, 1970 UTC. * * Earliest possible date: Tue, 20 Apr 271,822 B.C. 00:00:00 UTC * Latest possible date: Sat, 13 Sep 275,760 00:00:00 UTC */ return validate(value, -271822, 275760, "year"); }; $D.validateTimezone = function(value) { var timezones = {"ACDT":1,"ACST":1,"ACT":1,"ADT":1,"AEDT":1,"AEST":1,"AFT":1,"AKDT":1,"AKST":1,"AMST":1,"AMT":1,"ART":1,"AST":1,"AWDT":1,"AWST":1,"AZOST":1,"AZT":1,"BDT":1,"BIOT":1,"BIT":1,"BOT":1,"BRT":1,"BST":1,"BTT":1,"CAT":1,"CCT":1,"CDT":1,"CEDT":1,"CEST":1,"CET":1,"CHADT":1,"CHAST":1,"CHOT":1,"ChST":1,"CHUT":1,"CIST":1,"CIT":1,"CKT":1,"CLST":1,"CLT":1,"COST":1,"COT":1,"CST":1,"CT":1,"CVT":1,"CWST":1,"CXT":1,"DAVT":1,"DDUT":1,"DFT":1,"EASST":1,"EAST":1,"EAT":1,"ECT":1,"EDT":1,"EEDT":1,"EEST":1,"EET":1,"EGST":1,"EGT":1,"EIT":1,"EST":1,"FET":1,"FJT":1,"FKST":1,"FKT":1,"FNT":1,"GALT":1,"GAMT":1,"GET":1,"GFT":1,"GILT":1,"GIT":1,"GMT":1,"GST":1,"GYT":1,"HADT":1,"HAEC":1,"HAST":1,"HKT":1,"HMT":1,"HOVT":1,"HST":1,"ICT":1,"IDT":1,"IOT":1,"IRDT":1,"IRKT":1,"IRST":1,"IST":1,"JST":1,"KGT":1,"KOST":1,"KRAT":1,"KST":1,"LHST":1,"LINT":1,"MAGT":1,"MART":1,"MAWT":1,"MDT":1,"MET":1,"MEST":1,"MHT":1,"MIST":1,"MIT":1,"MMT":1,"MSK":1,"MST":1,"MUT":1,"MVT":1,"MYT":1,"NCT":1,"NDT":1,"NFT":1,"NPT":1,"NST":1,"NT":1,"NUT":1,"NZDT":1,"NZST":1,"OMST":1,"ORAT":1,"PDT":1,"PET":1,"PETT":1,"PGT":1,"PHOT":1,"PHT":1,"PKT":1,"PMDT":1,"PMST":1,"PONT":1,"PST":1,"PYST":1,"PYT":1,"RET":1,"ROTT":1,"SAKT":1,"SAMT":1,"SAST":1,"SBT":1,"SCT":1,"SGT":1,"SLST":1,"SRT":1,"SST":1,"SYOT":1,"TAHT":1,"THA":1,"TFT":1,"TJT":1,"TKT":1,"TLT":1,"TMT":1,"TOT":1,"TVT":1,"UCT":1,"ULAT":1,"UTC":1,"UYST":1,"UYT":1,"UZT":1,"VET":1,"VLAT":1,"VOLT":1,"VOST":1,"VUT":1,"WAKT":1,"WAST":1,"WAT":1,"WEDT":1,"WEST":1,"WET":1,"WST":1,"YAKT":1,"YEKT":1,"Z":1}; return (timezones[value] === 1); }; $D.validateTimezoneOffset= function(value) { // timezones go from +14hrs to -12hrs, the +X hours are negative offsets. return (value > -841 && value < 721); }; }()); (function () { var $D = Date, $P = $D.prototype, p = function (s, l) { if (!l) { l = 2; } return ("000" + s).slice(l * -1); }; var validateConfigObject = function (obj) { var result = {}, self = this, prop, testFunc; testFunc = function (prop, func, value) { if (prop === "day") { var month = (obj.month !== undefined) ? obj.month : self.getMonth(); var year = (obj.year !== undefined) ? obj.year : self.getFullYear(); return $D[func](value, year, month); } else { return $D[func](value); } }; for (prop in obj) { if (Object.prototype.hasOwnProperty.call(obj, prop)) { var func = "validate" + prop.charAt(0).toUpperCase() + prop.slice(1); if ($D[func] && obj[prop] !== null && testFunc(prop, func, obj[prop])) { result[prop] = obj[prop]; } } } return result; }; /** * Resets the time of this Date object to 12:00 AM (00:00), which is the start of the day. * @param {Boolean} .clone() this date instance before clearing Time * @return {Date} this */ $P.clearTime = function () { this.setHours(0); this.setMinutes(0); this.setSeconds(0); this.setMilliseconds(0); return this; }; /** * Resets the time of this Date object to the current time ('now'). * @return {Date} this */ $P.setTimeToNow = function () { var n = new Date(); this.setHours(n.getHours()); this.setMinutes(n.getMinutes()); this.setSeconds(n.getSeconds()); this.setMilliseconds(n.getMilliseconds()); return this; }; /** * Returns a new Date object that is an exact date and time copy of the original instance. * @return {Date} A new Date instance */ $P.clone = function () { return new Date(this.getTime()); }; /** * Compares this instance to a Date object and returns an number indication of their relative values. * @param {Date} Date object to compare [Required] * @return {Number} -1 = this is lessthan date. 0 = values are equal. 1 = this is greaterthan date. */ $P.compareTo = function (date) { return Date.compare(this, date); }; /** * Compares this instance to another Date object and returns true if they are equal. * @param {Date} Date object to compare. If no date to compare, new Date() [now] is used. * @return {Boolean} true if dates are equal. false if they are not equal. */ $P.equals = function (date) { return Date.equals(this, (date !== undefined ? date : new Date())); }; /** * Determines if this instance is between a range of two dates or equal to either the start or end dates. * @param {Date} Start of range [Required] * @param {Date} End of range [Required] * @return {Boolean} true is this is between or equal to the start and end dates, else false */ $P.between = function (start, end) { return this.getTime() >= start.getTime() && this.getTime() <= end.getTime(); }; /** * Determines if this date occurs after the date to compare to. * @param {Date} Date object to compare. If no date to compare, new Date() ("now") is used. * @return {Boolean} true if this date instance is greater than the date to compare to (or "now"), otherwise false. */ $P.isAfter = function (date) { return this.compareTo(date || new Date()) === 1; }; /** * Determines if this date occurs before the date to compare to. * @param {Date} Date object to compare. If no date to compare, new Date() ("now") is used. * @return {Boolean} true if this date instance is less than the date to compare to (or "now"). */ $P.isBefore = function (date) { return (this.compareTo(date || new Date()) === -1); }; /** * Determines if the current Date instance occurs today. * @return {Boolean} true if this date instance is 'today', otherwise false. */ /** * Determines if the current Date instance occurs on the same Date as the supplied 'date'. * If no 'date' to compare to is provided, the current Date instance is compared to 'today'. * @param {date} Date object to compare. If no date to compare, the current Date ("now") is used. * @return {Boolean} true if this Date instance occurs on the same Day as the supplied 'date'. */ $P.isToday = $P.isSameDay = function (date) { return this.clone().clearTime().equals((date || new Date()).clone().clearTime()); }; /** * Adds the specified number of milliseconds to this instance. * @param {Number} The number of milliseconds to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addMilliseconds = function (value) { if (!value) { return this; } this.setTime(this.getTime() + value * 1); return this; }; /** * Adds the specified number of seconds to this instance. * @param {Number} The number of seconds to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addSeconds = function (value) { if (!value) { return this; } return this.addMilliseconds(value * 1000); }; /** * Adds the specified number of seconds to this instance. * @param {Number} The number of seconds to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addMinutes = function (value) { if (!value) { return this; } return this.addMilliseconds(value * 60000); // 60*1000 }; /** * Adds the specified number of hours to this instance. * @param {Number} The number of hours to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addHours = function (value) { if (!value) { return this; } return this.addMilliseconds(value * 3600000); // 60*60*1000 }; /** * Adds the specified number of days to this instance. * @param {Number} The number of days to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addDays = function (value) { if (!value) { return this; } this.setDate(this.getDate() + value * 1); return this; }; /** * Adds the specified number of weekdays (ie - not sat or sun) to this instance. * @param {Number} The number of days to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addWeekdays = function (value) { if (!value) { return this; } var day = this.getDay(); var weeks = (Math.ceil(Math.abs(value)/7)); if (day === 0 || day === 6) { if (value > 0) { this.next().monday(); this.addDays(-1); day = this.getDay(); } } if (value < 0) { while (value < 0) { this.addDays(-1); day = this.getDay(); if (day !== 0 && day !== 6) { value++; } } return this; } else if (value > 5 || (6-day) <= value) { value = value + (weeks * 2); } return this.addDays(value); }; /** * Adds the specified number of weeks to this instance. * @param {Number} The number of weeks to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addWeeks = function (value) { if (!value) { return this; } return this.addDays(value * 7); }; /** * Adds the specified number of months to this instance. * @param {Number} The number of months to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addMonths = function (value) { if (!value) { return this; } var n = this.getDate(); this.setDate(1); this.setMonth(this.getMonth() + value * 1); this.setDate(Math.min(n, $D.getDaysInMonth(this.getFullYear(), this.getMonth()))); return this; }; $P.addQuarters = function (value) { if (!value) { return this; } // note this will take you to the same point in the quarter as you are now. // i.e. - if you are 15 days into the quarter you'll be 15 days into the resulting one. // bonus: this allows adding fractional quarters return this.addMonths(value * 3); }; /** * Adds the specified number of years to this instance. * @param {Number} The number of years to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addYears = function (value) { if (!value) { return this; } return this.addMonths(value * 12); }; /** * Adds (or subtracts) to the value of the years, months, weeks, days, hours, minutes, seconds, milliseconds of the date instance using given configuration object. Positive and Negative values allowed. * Example

	Date.today().add( { days: 1, months: 1 } )

	new Date().add( { years: -1 } )
	
* @param {Object} Configuration object containing attributes (months, days, etc.) * @return {Date} this */ $P.add = function (config) { if (typeof config === "number") { this._orient = config; return this; } var x = config; if (x.day) { // If we should be a different date than today (eg: for 'tomorrow -1d', etc). // Should only effect parsing, not direct usage (eg, Finish and FinishExact) if ((x.day - this.getDate()) !== 0) { this.setDate(x.day); } } if (x.milliseconds) { this.addMilliseconds(x.milliseconds); } if (x.seconds) { this.addSeconds(x.seconds); } if (x.minutes) { this.addMinutes(x.minutes); } if (x.hours) { this.addHours(x.hours); } if (x.weeks) { this.addWeeks(x.weeks); } if (x.months) { this.addMonths(x.months); } if (x.years) { this.addYears(x.years); } if (x.days) { this.addDays(x.days); } return this; }; /** * Get the week number. Week one (1) is the week which contains the first Thursday of the year. Monday is considered the first day of the week. * The .getWeek() function does NOT convert the date to UTC. The local datetime is used. * Please use .getISOWeek() to get the week of the UTC converted date. * @return {Number} 1 to 53 */ $P.getWeek = function (utc) { // Create a copy of this date object var self, target = new Date(this.valueOf()); if (utc) { target.addMinutes(target.getTimezoneOffset()); self = target.clone(); } else { self = this; } // ISO week date weeks start on monday // so correct the day number var dayNr = (self.getDay() + 6) % 7; // ISO 8601 states that week 1 is the week // with the first thursday of that year. // Set the target date to the thursday in the target week target.setDate(target.getDate() - dayNr + 3); // Store the millisecond value of the target date var firstThursday = target.valueOf(); // Set the target to the first thursday of the year // First set the target to january first target.setMonth(0, 1); // Not a thursday? Correct the date to the next thursday if (target.getDay() !== 4) { target.setMonth(0, 1 + ((4 - target.getDay()) + 7) % 7); } // The weeknumber is the number of weeks between the // first thursday of the year and the thursday in the target week return 1 + Math.ceil((firstThursday - target) / 604800000); // 604800000 = 7 * 24 * 3600 * 1000 }; /** * Get the ISO 8601 week number. Week one ("01") is the week which contains the first Thursday of the year. Monday is considered the first day of the week. * The .getISOWeek() function does convert the date to it's UTC value. Please use .getWeek() to get the week of the local date. * @return {String} "01" to "53" */ $P.getISOWeek = function () { return p(this.getWeek(true)); }; /** * Moves the date to Monday of the week set. Week one (1) is the week which contains the first Thursday of the year. * @param {Number} A Number (1 to 53) that represents the week of the year. * @return {Date} this */ $P.setWeek = function (n) { if ((n - this.getWeek()) === 0) { if (this.getDay() !== 1) { return this.moveToDayOfWeek(1, (this.getDay() > 1 ? -1 : 1)); } else { return this; } } else { return this.moveToDayOfWeek(1, (this.getDay() > 1 ? -1 : 1)).addWeeks(n - this.getWeek()); } }; $P.setQuarter = function (qtr) { var month = Math.abs(((qtr-1) * 3) + 1); return this.setMonth(month, 1); }; $P.getQuarter = function () { return Date.getQuarter(this); }; $P.getDaysLeftInQuarter = function () { return Date.getDaysLeftInQuarter(this); }; /** * Moves the date to the next n'th occurrence of the dayOfWeek starting from the beginning of the month. The number (-1) is a magic number and will return the last occurrence of the dayOfWeek in the month. * @param {Number} The dayOfWeek to move to * @param {Number} The n'th occurrence to move to. Use (-1) to return the last occurrence in the month * @return {Date} this */ $P.moveToNthOccurrence = function (dayOfWeek, occurrence) { if (dayOfWeek === "Weekday") { if (occurrence > 0) { this.moveToFirstDayOfMonth(); if (this.is().weekday()) { occurrence -= 1; } } else if (occurrence < 0) { this.moveToLastDayOfMonth(); if (this.is().weekday()) { occurrence += 1; } } else { return this; } return this.addWeekdays(occurrence); } var shift = 0; if (occurrence > 0) { shift = occurrence - 1; } else if (occurrence === -1) { this.moveToLastDayOfMonth(); if (this.getDay() !== dayOfWeek) { this.moveToDayOfWeek(dayOfWeek, -1); } return this; } return this.moveToFirstDayOfMonth().addDays(-1).moveToDayOfWeek(dayOfWeek, +1).addWeeks(shift); }; var moveToN = function (getFunc, addFunc, nVal) { return function (value, orient) { var diff = (value - this[getFunc]() + nVal * (orient || +1)) % nVal; return this[addFunc]((diff === 0) ? diff += nVal * (orient || +1) : diff); }; }; /** * Move to the next or last dayOfWeek based on the orient value. * @param {Number} The dayOfWeek to move to * @param {Number} Forward (+1) or Back (-1). Defaults to +1. [Optional] * @return {Date} this */ $P.moveToDayOfWeek = moveToN("getDay", "addDays", 7); /** * Move to the next or last month based on the orient value. * @param {Number} The month to move to. 0 = January, 11 = December * @param {Number} Forward (+1) or Back (-1). Defaults to +1. [Optional] * @return {Date} this */ $P.moveToMonth = moveToN("getMonth", "addMonths", 12); /** * Get the Ordinate of the current day ("th", "st", "rd"). * @return {String} */ $P.getOrdinate = function () { var num = this.getDate(); return ord(num); }; /** * Get the Ordinal day (numeric day number) of the year, adjusted for leap year. * @return {Number} 1 through 365 (366 in leap years) */ $P.getOrdinalNumber = function () { return Math.ceil((this.clone().clearTime() - new Date(this.getFullYear(), 0, 1)) / 86400000) + 1; }; /** * Get the time zone abbreviation of the current date. * @return {String} The abbreviated time zone name (e.g. "EST") */ $P.getTimezone = function () { return $D.getTimezoneAbbreviation(this.getUTCOffset(), this.isDaylightSavingTime()); }; $P.setTimezoneOffset = function (offset) { var here = this.getTimezoneOffset(), there = Number(offset) * -6 / 10; return (there || there === 0) ? this.addMinutes(there - here) : this; }; $P.setTimezone = function (offset) { return this.setTimezoneOffset($D.getTimezoneOffset(offset)); }; /** * Indicates whether Daylight Saving Time is observed in the current time zone. * @return {Boolean} true|false */ $P.hasDaylightSavingTime = function () { return (Date.today().set({month: 0, day: 1}).getTimezoneOffset() !== Date.today().set({month: 6, day: 1}).getTimezoneOffset()); }; /** * Indicates whether this Date instance is within the Daylight Saving Time range for the current time zone. * @return {Boolean} true|false */ $P.isDaylightSavingTime = function () { return Date.today().set({month: 0, day: 1}).getTimezoneOffset() !== this.getTimezoneOffset(); }; /** * Get the offset from UTC of the current date. * @return {String} The 4-character offset string prefixed with + or - (e.g. "-0500") */ $P.getUTCOffset = function (offset) { var n = (offset || this.getTimezoneOffset()) * -10 / 6, r; if (n < 0) { r = (n - 10000).toString(); return r.charAt(0) + r.substr(2); } else { r = (n + 10000).toString(); return "+" + r.substr(1); } }; /** * Returns the number of milliseconds between this date and date. * @param {Date} Defaults to now * @return {Number} The diff in milliseconds */ $P.getElapsed = function (date) { return (date || new Date()) - this; }; /** * Set the value of year, month, day, hour, minute, second, millisecond of date instance using given configuration object. * Example

	Date.today().set( { day: 20, month: 1 } )

	new Date().set( { millisecond: 0 } )
	
* * @param {Object} Configuration object containing attributes (month, day, etc.) * @return {Date} this */ $P.set = function (config) { config = validateConfigObject.call(this, config); var key; for (key in config) { if (Object.prototype.hasOwnProperty.call(config, key)) { var name = key.charAt(0).toUpperCase() + key.slice(1); var addFunc, getFunc; if (key !== "week" && key !== "month" && key !== "timezone" && key !== "timezoneOffset") { name += "s"; } addFunc = "add" + name; getFunc = "get" + name; if (key === "month") { addFunc = addFunc + "s"; } else if (key === "year"){ getFunc = "getFullYear"; } if (key !== "day" && key !== "timezone" && key !== "timezoneOffset" && key !== "week" && key !== "hour") { this[addFunc](config[key] - this[getFunc]()); } else if ( key === "timezone"|| key === "timezoneOffset" || key === "week" || key === "hour") { this["set"+name](config[key]); } } } // day has to go last because you can't validate the day without first knowing the month if (config.day) { this.addDays(config.day - this.getDate()); } return this; }; /** * Moves the date to the first day of the month. * @return {Date} this */ $P.moveToFirstDayOfMonth = function () { return this.set({ day: 1 }); }; /** * Moves the date to the last day of the month. * @return {Date} this */ $P.moveToLastDayOfMonth = function () { return this.set({ day: $D.getDaysInMonth(this.getFullYear(), this.getMonth())}); }; /** * Converts the value of the current Date object to its equivalent string representation. * Format Specifiers * CUSTOM DATE AND TIME FORMAT STRINGS * Format Description Example * ------ --------------------------------------------------------------------------- ----------------------- * s The seconds of the minute between 0-59. "0" to "59" * ss The seconds of the minute with leading zero if required. "00" to "59" * * m The minute of the hour between 0-59. "0" or "59" * mm The minute of the hour with leading zero if required. "00" or "59" * * h The hour of the day between 1-12. "1" to "12" * hh The hour of the day with leading zero if required. "01" to "12" * * H The hour of the day between 0-23. "0" to "23" * HH The hour of the day with leading zero if required. "00" to "23" * * d The day of the month between 1 and 31. "1" to "31" * dd The day of the month with leading zero if required. "01" to "31" * ddd Abbreviated day name. Date.CultureInfo.abbreviatedDayNames. "Mon" to "Sun" * dddd The full day name. Date.CultureInfo.dayNames. "Monday" to "Sunday" * * M The month of the year between 1-12. "1" to "12" * MM The month of the year with leading zero if required. "01" to "12" * MMM Abbreviated month name. Date.CultureInfo.abbreviatedMonthNames. "Jan" to "Dec" * MMMM The full month name. Date.CultureInfo.monthNames. "January" to "December" * * yy The year as a two-digit number. "99" or "08" * yyyy The full four digit year. "1999" or "2008" * * t Displays the first character of the A.M./P.M. designator. "A" or "P" * Date.CultureInfo.amDesignator or Date.CultureInfo.pmDesignator * tt Displays the A.M./P.M. designator. "AM" or "PM" * Date.CultureInfo.amDesignator or Date.CultureInfo.pmDesignator * * S The ordinal suffix ("st, "nd", "rd" or "th") of the current day. "st, "nd", "rd" or "th" * * STANDARD DATE AND TIME FORMAT STRINGS * Format Description Example *------ --------------------------------------------------------------------------- ----------------------- * d The CultureInfo shortDate Format Pattern "M/d/yyyy" * D The CultureInfo longDate Format Pattern "dddd, MMMM dd, yyyy" * F The CultureInfo fullDateTime Format Pattern "dddd, MMMM dd, yyyy h:mm:ss tt" * m The CultureInfo monthDay Format Pattern "MMMM dd" * r The CultureInfo rfc1123 Format Pattern "ddd, dd MMM yyyy HH:mm:ss GMT" * s The CultureInfo sortableDateTime Format Pattern "yyyy-MM-ddTHH:mm:ss" * t The CultureInfo shortTime Format Pattern "h:mm tt" * T The CultureInfo longTime Format Pattern "h:mm:ss tt" * u The CultureInfo universalSortableDateTime Format Pattern "yyyy-MM-dd HH:mm:ssZ" * y The CultureInfo yearMonth Format Pattern "MMMM, yyyy" * * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @return {String} A string representation of the current Date object. */ var ord = function (n) { switch (n * 1) { case 1: case 21: case 31: return "st"; case 2: case 22: return "nd"; case 3: case 23: return "rd"; default: return "th"; } }; var parseStandardFormats = function (format) { var y, c = Date.CultureInfo.formatPatterns; switch (format) { case "d": return this.toString(c.shortDate); case "D": return this.toString(c.longDate); case "F": return this.toString(c.fullDateTime); case "m": return this.toString(c.monthDay); case "r": case "R": y = this.clone().addMinutes(this.getTimezoneOffset()); return y.toString(c.rfc1123) + " GMT"; case "s": return this.toString(c.sortableDateTime); case "t": return this.toString(c.shortTime); case "T": return this.toString(c.longTime); case "u": y = this.clone().addMinutes(this.getTimezoneOffset()); return y.toString(c.universalSortableDateTime); case "y": return this.toString(c.yearMonth); default: return false; } }; var parseFormatStringsClosure = function (context) { return function (m) { if (m.charAt(0) === "\\") { return m.replace("\\", ""); } switch (m) { case "hh": return p(context.getHours() < 13 ? (context.getHours() === 0 ? 12 : context.getHours()) : (context.getHours() - 12)); case "h": return context.getHours() < 13 ? (context.getHours() === 0 ? 12 : context.getHours()) : (context.getHours() - 12); case "HH": return p(context.getHours()); case "H": return context.getHours(); case "mm": return p(context.getMinutes()); case "m": return context.getMinutes(); case "ss": return p(context.getSeconds()); case "s": return context.getSeconds(); case "yyyy": return p(context.getFullYear(), 4); case "yy": return p(context.getFullYear()); case "y": return context.getFullYear(); case "E": case "dddd": return Date.CultureInfo.dayNames[context.getDay()]; case "ddd": return Date.CultureInfo.abbreviatedDayNames[context.getDay()]; case "dd": return p(context.getDate()); case "d": return context.getDate(); case "MMMM": return Date.CultureInfo.monthNames[context.getMonth()]; case "MMM": return Date.CultureInfo.abbreviatedMonthNames[context.getMonth()]; case "MM": return p((context.getMonth() + 1)); case "M": return context.getMonth() + 1; case "t": return context.getHours() < 12 ? Date.CultureInfo.amDesignator.substring(0, 1) : Date.CultureInfo.pmDesignator.substring(0, 1); case "tt": return context.getHours() < 12 ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator; case "S": return ord(context.getDate()); case "W": return context.getWeek(); case "WW": return context.getISOWeek(); case "Q": return "Q" + context.getQuarter(); case "q": return String(context.getQuarter()); case "z": return context.getTimezone(); case "Z": case "X": return Date.getTimezoneOffset(context.getTimezone()); case "ZZ": // Timezone offset in seconds return context.getTimezoneOffset() * -60; case "u": return context.getDay(); case "L": return ($D.isLeapYear(context.getFullYear())) ? 1 : 0; case "B": // Swatch Internet Time (.beats) return "@"+((context.getUTCSeconds() + (context.getUTCMinutes()*60) + ((context.getUTCHours()+1)*3600))/86.4); default: return m; } }; }; $P.toString = function (format, ignoreStandards) { // Standard Date and Time Format Strings. Formats pulled from CultureInfo file and // may vary by culture. if (!ignoreStandards && format && format.length === 1) { output = parseStandardFormats.call(this, format); if (output) { return output; } } var parseFormatStrings = parseFormatStringsClosure(this); return format ? format.replace(/((\\)?(dd?d?d?|MM?M?M?|yy?y?y?|hh?|HH?|mm?|ss?|tt?|S|q|Q|WW?W?W?)(?![^\[]*\]))/g, parseFormatStrings).replace(/\[|\]/g, "") : this._toString(); }; }()); /************************************************************* * SugarPak - Domain Specific Language - Syntactical Sugar * *************************************************************/ (function () { var $D = Date, $P = $D.prototype, $N = Number.prototype; // private $P._orient = +1; // private $P._nth = null; // private $P._is = false; // private $P._same = false; // private $P._isSecond = false; // private $N._dateElement = "days"; /** * Moves the date to the next instance of a date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.today().next().friday();
	Date.today().next().fri();
	Date.today().next().march();
	Date.today().next().mar();
	Date.today().next().week();
	
* * @return {Date} date */ $P.next = function () { this._move = true; this._orient = +1; return this; }; /** * Creates a new Date (Date.today()) and moves the date to the next instance of the date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.next().friday();
	Date.next().fri();
	Date.next().march();
	Date.next().mar();
	Date.next().week();
	
* * @return {Date} date */ $D.next = function () { return $D.today().next(); }; /** * Moves the date to the previous instance of a date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.today().last().friday();
	Date.today().last().fri();
	Date.today().last().march();
	Date.today().last().mar();
	Date.today().last().week();
	
* * @return {Date} date */ $P.last = $P.prev = $P.previous = function () { this._move = true; this._orient = -1; return this; }; /** * Creates a new Date (Date.today()) and moves the date to the previous instance of the date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.last().friday();
	Date.last().fri();
	Date.previous().march();
	Date.prev().mar();
	Date.last().week();
	
* * @return {Date} date */ $D.last = $D.prev = $D.previous = function () { return $D.today().last(); }; /** * Performs a equality check when followed by either a month name, day name or .weekday() function. * Example

	Date.today().is().friday(); // true|false
	Date.today().is().fri();
	Date.today().is().march();
	Date.today().is().mar();
	
* * @return {Boolean} true|false */ $P.is = function () { this._is = true; return this; }; /** * Determines if two date objects occur on/in exactly the same instance of the subsequent date part function. * The function .same() must be followed by a date part function (example: .day(), .month(), .year(), etc). * * An optional Date can be passed in the date part function. If now date is passed as a parameter, 'Now' is used. * * The following example demonstrates how to determine if two dates fall on the exact same day. * * Example

	var d1 = Date.today(); // today at 00:00
	var d2 = new Date();   // exactly now.

	// Do they occur on the same day?
	d1.same().day(d2); // true
	
	// Do they occur on the same hour?
	d1.same().hour(d2); // false, unless d2 hour is '00' (midnight).
	
	// What if it's the same day, but one year apart?
	var nextYear = Date.today().add(1).year();

	d1.same().day(nextYear); // false, because the dates must occur on the exact same day. 
	
* * Scenario: Determine if a given date occurs during some week period 2 months from now. * * Example

	var future = Date.today().add(2).months();
	return someDate.same().week(future); // true|false;
	
* * @return {Boolean} true|false */ $P.same = function () { this._same = true; this._isSecond = false; return this; }; /** * Determines if the current date/time occurs during Today. Must be preceded by the .is() function. * Example

	someDate.is().today();    // true|false
	new Date().is().today();  // true
	Date.today().is().today();// true
	Date.today().add(-1).day().is().today(); // false
	
* * @return {Boolean} true|false */ $P.today = function () { return this.same().day(); }; /** * Determines if the current date is a weekday. This function must be preceded by the .is() function. * Example

	Date.today().is().weekday(); // true|false
	
* * @return {Boolean} true|false */ $P.weekday = function () { if (this._nth) { return df("Weekday").call(this); } if (this._move) { return this.addWeekdays(this._orient); } if (this._is) { this._is = false; return (!this.is().sat() && !this.is().sun()); } return false; }; /** * Determines if the current date is on the weekend. This function must be preceded by the .is() function. * Example

	Date.today().is().weekend(); // true|false
	
* * @return {Boolean} true|false */ $P.weekend = function () { if (this._is) { this._is = false; return (this.is().sat() || this.is().sun()); } return false; }; /** * Sets the Time of the current Date instance. A string "6:15 pm" or config object {hour:18, minute:15} are accepted. * Example

	// Set time to 6:15pm with a String
	Date.today().at("6:15pm");

	// Set time to 6:15pm with a config object
	Date.today().at({hour:18, minute:15});
	
* * @return {Date} date */ $P.at = function (time) { return (typeof time === "string") ? $D.parse(this.toString("d") + " " + time) : this.set(time); }; /** * Creates a new Date() and adds this (Number) to the date based on the preceding date element function (eg. second|minute|hour|day|month|year). * Example

	// Undeclared Numbers must be wrapped with parentheses. Requirment of JavaScript.
	(3).days().fromNow();
	(6).months().fromNow();

	// Declared Number variables do not require parentheses. 
	var n = 6;
	n.months().fromNow();
	
* * @return {Date} A new Date instance */ $N.fromNow = $N.after = function (date) { var c = {}; c[this._dateElement] = this; return ((!date) ? new Date() : date.clone()).add(c); }; /** * Creates a new Date() and subtract this (Number) from the date based on the preceding date element function (eg. second|minute|hour|day|month|year). * Example

	// Undeclared Numbers must be wrapped with parentheses. Requirment of JavaScript.
	(3).days().ago();
	(6).months().ago();

	// Declared Number variables do not require parentheses. 
	var n = 6;
	n.months().ago();
	
* * @return {Date} A new Date instance */ $N.ago = $N.before = function (date) { var c = {}, s = (this._dateElement[this._dateElement.length-1] !== "s") ? this._dateElement + "s" : this._dateElement; c[s] = this * -1; return ((!date) ? new Date() : date.clone()).add(c); }; // Do NOT modify the following string tokens. These tokens are used to build dynamic functions. // All culture-specific strings can be found in the CultureInfo files. var dx = ("sunday monday tuesday wednesday thursday friday saturday").split(/\s/), mx = ("january february march april may june july august september october november december").split(/\s/), px = ("Millisecond Second Minute Hour Day Week Month Year Quarter Weekday").split(/\s/), pxf = ("Milliseconds Seconds Minutes Hours Date Week Month FullYear Quarter").split(/\s/), nth = ("final first second third fourth fifth").split(/\s/), de; /** * Returns an object literal of all the date parts. * Example

	var o = new Date().toObject();
	
	// { year: 2008, month: 4, week: 20, day: 13, hour: 18, minute: 9, second: 32, millisecond: 812 }
	
	// The object properties can be referenced directly from the object.
	
	alert(o.day);  // alerts "13"
	alert(o.year); // alerts "2008"
	
* * @return {Date} An object literal representing the original date object. */ $P.toObject = function () { var o = {}; for (var i = 0; i < px.length; i++) { if (this["get" + pxf[i]]) { o[px[i].toLowerCase()] = this["get" + pxf[i]](); } } return o; }; /** * Returns a date created from an object literal. Ignores the .week property if set in the config. * Example

	var o = new Date().toObject();
	
	return Date.fromObject(o); // will return the same date. 

	var o2 = {month: 1, day: 20, hour: 18}; // birthday party!
	Date.fromObject(o2);
	
* * @return {Date} An object literal representing the original date object. */ $D.fromObject = function(config) { config.week = null; return Date.today().set(config); }; // Create day name functions and abbreviated day name functions (eg. monday(), friday(), fri()). var df = function (n) { return function () { if (this._is) { this._is = false; return this.getDay() === n; } if (this._move) { this._move = null; } if (this._nth !== null) { // If the .second() function was called earlier, remove the _orient // from the date, and then continue. // This is required because 'second' can be used in two different context. // // Example // // Date.today().add(1).second(); // Date.march().second().monday(); // // Things get crazy with the following... // Date.march().add(1).second().second().monday(); // but it works!! // if (this._isSecond) { this.addSeconds(this._orient * -1); } // make sure we reset _isSecond this._isSecond = false; var ntemp = this._nth; this._nth = null; var temp = this.clone().moveToLastDayOfMonth(); this.moveToNthOccurrence(n, ntemp); if (this > temp) { throw new RangeError($D.getDayName(n) + " does not occur " + ntemp + " times in the month of " + $D.getMonthName(temp.getMonth()) + " " + temp.getFullYear() + "."); } return this; } return this.moveToDayOfWeek(n, this._orient); }; }; var sdf = function (n) { return function () { var t = $D.today(), shift = n - t.getDay(); if (n === 0 && Date.CultureInfo.firstDayOfWeek === 1 && t.getDay() !== 0) { shift = shift + 7; } return t.addDays(shift); }; }; // Create month name functions and abbreviated month name functions (eg. january(), march(), mar()). var month_instance_functions = function (n) { return function () { if (this._is) { this._is = false; return this.getMonth() === n; } return this.moveToMonth(n, this._orient); }; }; var month_static_functions = function (n) { return function () { return $D.today().set({ month: n, day: 1 }); }; }; var processTerms = function (names, staticFunc, instanceFunc) { for (var i = 0; i < names.length; i++) { // Create constant static Name variables. $D[names[i].toUpperCase()] = $D[names[i].toUpperCase().substring(0, 3)] = i; // Create Name functions. $D[names[i]] = $D[names[i].substring(0, 3)] = staticFunc(i); // Create Name instance functions. $P[names[i]] = $P[names[i].substring(0, 3)] = instanceFunc(i); } }; processTerms(dx, sdf, df); processTerms(mx, month_static_functions, month_instance_functions); // Create date element functions and plural date element functions used with Date (eg. day(), days(), months()). var ef = function (j) { return function () { // if the .second() function was called earlier, the _orient // has alread been added. Just return this and reset _isSecond. if (this._isSecond) { this._isSecond = false; return this; } if (this._same) { this._same = this._is = false; var o1 = this.toObject(), o2 = (arguments[0] || new Date()).toObject(), v = "", k = j.toLowerCase(); // the substr trick with -1 doesn't work in IE8 or less k = (k[k.length-1] === "s") ? k.substring(0,k.length-1) : k; for (var m = (px.length - 1); m > -1; m--) { v = px[m].toLowerCase(); if (o1[v] !== o2[v]) { return false; } if (k === v) { break; } } return true; } if (j.substring(j.length - 1) !== "s") { j += "s"; } if (this._move) { this._move = null; } return this["add" + j](this._orient); }; }; var nf = function (n) { return function () { this._dateElement = n; return this; }; }; for (var k = 0; k < px.length; k++) { de = px[k].toLowerCase(); if(de !== "weekday") { // Create date element functions and plural date element functions used with Date (eg. day(), days(), months()). $P[de] = $P[de + "s"] = ef(px[k]); // Create date element functions and plural date element functions used with Number (eg. day(), days(), months()). $N[de] = $N[de + "s"] = nf(de + "s"); } } $P._ss = ef("Second"); var nthfn = function (n) { return function (dayOfWeek) { if (this._same) { return this._ss(arguments[0]); } if (dayOfWeek || dayOfWeek === 0) { return this.moveToNthOccurrence(dayOfWeek, n); } this._nth = n; // if the operator is 'second' add the _orient, then deal with it later... if (n === 2 && (dayOfWeek === undefined || dayOfWeek === null)) { this._isSecond = true; return this.addSeconds(this._orient); } return this; }; }; for (var l = 0; l < nth.length; l++) { $P[nth[l]] = (l === 0) ? nthfn(-1) : nthfn(l); } }()); (function () { "use strict"; Date.Parsing = { Exception: function (s) { this.message = "Parse error at '" + s.substring(0, 10) + " ...'"; } }; var $P = Date.Parsing; var dayOffsets = { standard: [0,31,59,90,120,151,181,212,243,273,304,334], leap: [0,31,60,91,121,152,182,213,244,274,305,335] }; $P.isLeapYear = function(year) { return ((year % 4 === 0) && (year % 100 !== 0)) || (year % 400 === 0); }; var utils = { multiReplace : function (str, hash ) { var key; for (key in hash) { if (Object.prototype.hasOwnProperty.call(hash, key)) { var regex; if (typeof hash[key] === "function") { } else { regex = (hash[key] instanceof RegExp) ? hash[key] : new RegExp(hash[key], "g"); } str = str.replace(regex, key); } } return str; }, getDayOfYearFromWeek : function (obj) { var d, jan4, offset; obj.weekDay = (!obj.weekDay && obj.weekDay !== 0) ? 1 : obj.weekDay; d = new Date(obj.year, 0, 4); jan4 = d.getDay() === 0 ? 7 : d.getDay(); // JS is 0 indexed on Sunday. offset = jan4+3; obj.dayOfYear = ((obj.week * 7) + (obj.weekDay === 0 ? 7 : obj.weekDay))-offset; return obj; }, getDayOfYear : function (obj, dayOffset) { if (!obj.dayOfYear) { obj = utils.getDayOfYearFromWeek(obj); } for (var i=0;i <= dayOffset.length;i++) { if (obj.dayOfYear < dayOffset[i] || i === dayOffset.length) { obj.day = obj.day ? obj.day : (obj.dayOfYear - dayOffset[i-1]); break; } else { obj.month = i; } } return obj; }, adjustForTimeZone : function (obj, date) { var offset; if (obj.zone.toUpperCase() === "Z" || (obj.zone_hours === 0 && obj.zone_minutes === 0)) { // it's UTC/GML so work out the current timeszone offset offset = -date.getTimezoneOffset(); } else { offset = (obj.zone_hours*60) + (obj.zone_minutes || 0); if (obj.zone_sign === "+") { offset *= -1; } offset -= date.getTimezoneOffset(); } date.setMinutes(date.getMinutes()+offset); return date; }, setDefaults : function (obj) { obj.year = obj.year || Date.today().getFullYear(); obj.hours = obj.hours || 0; obj.minutes = obj.minutes || 0; obj.seconds = obj.seconds || 0; obj.milliseconds = obj.milliseconds || 0; if (!(!obj.month && (obj.week || obj.dayOfYear))) { // if we have a month, or if we don't but don't have the day calculation data obj.month = obj.month || 0; obj.day = obj.day || 1; } return obj; }, dataNum: function (data, mod, explict, postProcess) { var dataNum = data*1; if (mod) { if (postProcess) { return data ? mod(data)*1 : data; } else { return data ? mod(dataNum) : data; } } else if (!explict){ return data ? dataNum : data; } else { return (data && typeof data !== "undefined") ? dataNum : data; } }, timeDataProcess: function (obj) { var timeObj = {}; for (var x in obj.data) { if (obj.data.hasOwnProperty(x)) { timeObj[x] = obj.ignore[x] ? obj.data[x] : utils.dataNum(obj.data[x], obj.mods[x], obj.explict[x], obj.postProcess[x]); } } if (obj.data.secmins) { obj.data.secmins = obj.data.secmins.replace(",", ".") * 60; if (!timeObj.minutes) { timeObj.minutes = obj.data.secmins; } else if (!timeObj.seconds) { timeObj.seconds = obj.data.secmins; } delete obj.secmins; } return timeObj; }, buildTimeObjectFromData: function (data) { var time = utils.timeDataProcess({ data: { year : data[1], month : data[5], day : data[7], week : data[8], dayOfYear : data[10], hours : data[15], zone_hours : data[23], zone_minutes : data[24], zone : data[21], zone_sign : data[22], weekDay : data[9], minutes: data[16], seconds: data[19], milliseconds: data[20], secmins: data[18] }, mods: { month: function(data) { return data-1; }, weekDay: function (data) { data = Math.abs(data); return (data === 7 ? 0 : data); }, minutes: function (data) { return data.replace(":",""); }, seconds: function (data) { return Math.floor( (data.replace(":","").replace(",","."))*1 ); }, milliseconds: function (data) { return (data.replace(",",".")*1000); } }, postProcess: { minutes: true, seconds: true, milliseconds: true }, explict: { zone_hours: true, zone_minutes: true }, ignore: { zone: true, zone_sign: true, secmins: true } }); return time; }, addToHash: function (hash, keys, data) { keys = keys; data = data; var len = keys.length; for (var i = 0; i < len; i++) { hash[keys[i]] = data[i]; } return hash; }, combineRegex: function (r1, r2) { return new RegExp("(("+r1.source+")\\s("+r2.source+"))"); }, getDateNthString: function(add, last, inc){ if (add) { return Date.today().addDays(inc).toString("d"); } else if (last) { return Date.today().last()[inc]().toString("d"); } }, buildRegexData: function (array) { var arr = []; var len = array.length; for (var i=0; i < len; i++) { if (Object.prototype.toString.call(array[i]) === '[object Array]') { // oldIE compat version of Array.isArray arr.push(this.combineRegex(array[i][0], array[i][1])); } else { arr.push(array[i]); } } return arr; } }; $P.processTimeObject = function (obj) { var date, dayOffset; utils.setDefaults(obj); dayOffset = ($P.isLeapYear(obj.year)) ? dayOffsets.leap : dayOffsets.standard; if (!obj.month && (obj.week || obj.dayOfYear)) { utils.getDayOfYear(obj, dayOffset); } else { obj.dayOfYear = dayOffset[obj.month] + obj.day; } date = new Date(obj.year, obj.month, obj.day, obj.hours, obj.minutes, obj.seconds, obj.milliseconds); if (obj.zone) { utils.adjustForTimeZone(obj, date); // adjust (and calculate) for timezone } return date; }; $P.ISO = { regex : /^([\+-]?\d{4}(?!\d{2}\b))((-?)((0[1-9]|1[0-2])(\3([12]\d|0[1-9]|3[01]))?|W([0-4]\d|5[0-3])(-?[1-7])?|(00[1-9]|0[1-9]\d|[12]\d{2}|3([0-5]\d|6[1-6])))([T\s]((([01]\d|2[0-4])((:?)[0-5]\d)?|24\:?00)([\.,]\d+(?!:))?)?(\17[0-5]\d([\.,]\d+)?)?\s?([zZ]|([\+-])([01]\d|2[0-3]):?([0-5]\d)?)?)?)?$/, parse : function (s) { var time, data = s.match(this.regex); if (!data || !data.length) { return null; } time = utils.buildTimeObjectFromData(data); if (!time.year || (!time.year && (!time.month && !time.day) && (!time.week && !time.dayOfYear)) ) { return null; } return $P.processTimeObject(time); } }; $P.Numeric = { isNumeric: function (e){return!isNaN(parseFloat(e))&&isFinite(e);}, regex: /\b([0-1]?[0-9])([0-3]?[0-9])([0-2]?[0-9]?[0-9][0-9])\b/i, parse: function (s) { var data, i, time = {}, order = Date.CultureInfo.dateElementOrder.split(""); if (!(this.isNumeric(s)) || // if it's non-numeric OR (s[0] === "+" && s[0] === "-")) { // It's an arithmatic string (eg +/-1000) return null; } if (s.length < 5 && s.indexOf(".") < 0 && s.indexOf("/") < 0) { // assume it's just a year. time.year = s; return $P.processTimeObject(time); } data = s.match(this.regex); if (!data || !data.length) { return null; } for (i=0; i < order.length; i++) { switch(order[i]) { case "d": time.day = data[i+1]; break; case "m": time.month = (data[i+1]-1); break; case "y": time.year = data[i+1]; break; } } return $P.processTimeObject(time); } }; $P.Normalizer = { regexData: function () { var $R = Date.CultureInfo.regexPatterns; return utils.buildRegexData([ $R.tomorrow, $R.yesterday, [$R.past, $R.mon], [$R.past, $R.tue], [$R.past, $R.wed], [$R.past, $R.thu], [$R.past, $R.fri], [$R.past, $R.sat], [$R.past, $R.sun] ]); }, basicReplaceHash : function() { var $R = Date.CultureInfo.regexPatterns; return { "January": $R.jan.source, "February": $R.feb, "March": $R.mar, "April": $R.apr, "May": $R.may, "June": $R.jun, "July": $R.jul, "August": $R.aug, "September": $R.sep, "October": $R.oct, "November": $R.nov, "December": $R.dec, "": /\bat\b/gi, " ": /\s{2,}/, "am": $R.inTheMorning, "9am": $R.thisMorning, "pm": $R.inTheEvening, "7pm":$R.thisEvening }; }, keys : function(){ return [ utils.getDateNthString(true, false, 1), // tomorrow utils.getDateNthString(true, false, -1), // yesterday utils.getDateNthString(false, true, "monday"), //last mon utils.getDateNthString(false, true, "tuesday"), //last tues utils.getDateNthString(false, true, "wednesday"), //last wed utils.getDateNthString(false, true, "thursday"), //last thurs utils.getDateNthString(false, true, "friday"), //last fri utils.getDateNthString(false, true, "saturday"), //last sat utils.getDateNthString(false, true, "sunday") //last sun ]; }, buildRegexFunctions: function () { var $R = Date.CultureInfo.regexPatterns; var __ = Date.i18n.__; var tomorrowRE = new RegExp("(\\b\\d\\d?("+__("AM")+"|"+__("PM")+")? )("+$R.tomorrow.source.slice(1)+")", "i"); // adapted tomorrow regex for AM PM relative dates var todayRE = new RegExp($R.today.source + "(?!\\s*([+-]))\\b"); // today, but excludes the math operators (eg "today + 2h") this.replaceFuncs = [ [todayRE, function (full) { return (full.length > 1) ? Date.today().toString("d") : full; }], [tomorrowRE, function(full, m1) { var t = Date.today().addDays(1).toString("d"); return (t + " " + m1); }], [$R.amThisMorning, function(str, am){return am;}], [$R.pmThisEvening, function(str, pm){return pm;}] ]; }, buildReplaceData: function () { this.buildRegexFunctions(); this.replaceHash = utils.addToHash(this.basicReplaceHash(), this.keys(), this.regexData()); }, stringReplaceFuncs: function (s) { for (var i=0; i < this.replaceFuncs.length; i++) { s = s.replace(this.replaceFuncs[i][0], this.replaceFuncs[i][1]); } return s; }, parse: function (s) { s = this.stringReplaceFuncs(s); s = utils.multiReplace(s, this.replaceHash); try { var n = s.split(/([\s\-\.\,\/\x27]+)/); if (n.length === 3 && $P.Numeric.isNumeric(n[0]) && $P.Numeric.isNumeric(n[2]) && (n[2].length >= 4)) { // ok, so we're dealing with x/year. But that's not a full date. // This fixes wonky dateElementOrder parsing when set to dmy order. if (Date.CultureInfo.dateElementOrder[0] === "d") { s = "1/" + n[0] + "/" + n[2]; // set to 1st of month and normalize the seperator } } } catch (e) {} return s; } }; $P.Normalizer.buildReplaceData(); }()); (function () { var $P = Date.Parsing; var _ = $P.Operators = { // // Tokenizers // rtoken: function (r) { // regex token return function (s) { var mx = s.match(r); if (mx) { return ([ mx[0], s.substring(mx[0].length) ]); } else { throw new $P.Exception(s); } }; }, token: function () { // whitespace-eating token return function (s) { return _.rtoken(new RegExp("^\\s*" + s + "\\s*"))(s); }; }, stoken: function (s) { // string token return _.rtoken(new RegExp("^" + s)); }, // Atomic Operators until: function (p) { return function (s) { var qx = [], rx = null; while (s.length) { try { rx = p.call(this, s); } catch (e) { qx.push(rx[0]); s = rx[1]; continue; } break; } return [ qx, s ]; }; }, many: function (p) { return function (s) { var rx = [], r = null; while (s.length) { try { r = p.call(this, s); } catch (e) { return [ rx, s ]; } rx.push(r[0]); s = r[1]; } return [ rx, s ]; }; }, // generator operators -- see below optional: function (p) { return function (s) { var r = null; try { r = p.call(this, s); } catch (e) { return [ null, s ]; } return [ r[0], r[1] ]; }; }, not: function (p) { return function (s) { try { p.call(this, s); } catch (e) { return [null, s]; } throw new $P.Exception(s); }; }, ignore: function (p) { return p ? function (s) { var r = null; r = p.call(this, s); return [null, r[1]]; } : null; }, product: function () { var px = arguments[0], qx = Array.prototype.slice.call(arguments, 1), rx = []; for (var i = 0 ; i < px.length ; i++) { rx.push(_.each(px[i], qx)); } return rx; }, cache: function (rule) { var cache = {}, cache_length = 0, cache_keys = [], CACHE_MAX = Date.Config.CACHE_MAX || 100000, r = null; var cacheCheck = function () { if (cache_length === CACHE_MAX) { // kill several keys, don't want to have to do this all the time... for (var i=0; i < 10; i++) { var key = cache_keys.shift(); if (key) { delete cache[key]; cache_length--; } } } }; return function (s) { cacheCheck(); try { r = cache[s] = (cache[s] || rule.call(this, s)); } catch (e) { r = cache[s] = e; } cache_length++; cache_keys.push(s); if (r instanceof $P.Exception) { throw r; } else { return r; } }; }, // vector operators -- see below any: function () { var px = arguments; return function (s) { var r = null; for (var i = 0; i < px.length; i++) { if (px[i] == null) { continue; } try { r = (px[i].call(this, s)); } catch (e) { r = null; } if (r) { return r; } } throw new $P.Exception(s); }; }, each: function () { var px = arguments; return function (s) { var rx = [], r = null; for (var i = 0; i < px.length ; i++) { if (px[i] == null) { continue; } try { r = (px[i].call(this, s)); } catch (e) { throw new $P.Exception(s); } rx.push(r[0]); s = r[1]; } return [ rx, s]; }; }, all: function () { var px = arguments, _ = _; return _.each(_.optional(px)); }, // delimited operators sequence: function (px, d, c) { d = d || _.rtoken(/^\s*/); c = c || null; if (px.length === 1) { return px[0]; } return function (s) { var r = null, q = null; var rx = []; for (var i = 0; i < px.length ; i++) { try { r = px[i].call(this, s); } catch (e) { break; } rx.push(r[0]); try { q = d.call(this, r[1]); } catch (ex) { q = null; break; } s = q[1]; } if (!r) { throw new $P.Exception(s); } if (q) { throw new $P.Exception(q[1]); } if (c) { try { r = c.call(this, r[1]); } catch (ey) { throw new $P.Exception(r[1]); } } return [ rx, (r?r[1]:s) ]; }; }, // // Composite Operators // between: function (d1, p, d2) { d2 = d2 || d1; var _fn = _.each(_.ignore(d1), p, _.ignore(d2)); return function (s) { var rx = _fn.call(this, s); return [[rx[0][0], r[0][2]], rx[1]]; }; }, list: function (p, d, c) { d = d || _.rtoken(/^\s*/); c = c || null; return (p instanceof Array ? _.each(_.product(p.slice(0, -1), _.ignore(d)), p.slice(-1), _.ignore(c)) : _.each(_.many(_.each(p, _.ignore(d))), px, _.ignore(c))); }, set: function (px, d, c) { d = d || _.rtoken(/^\s*/); c = c || null; return function (s) { // r is the current match, best the current 'best' match // which means it parsed the most amount of input var r = null, p = null, q = null, rx = null, best = [[], s], last = false; // go through the rules in the given set for (var i = 0; i < px.length ; i++) { // last is a flag indicating whether this must be the last element // if there is only 1 element, then it MUST be the last one q = null; p = null; r = null; last = (px.length === 1); // first, we try simply to match the current pattern // if not, try the next pattern try { r = px[i].call(this, s); } catch (e) { continue; } // since we are matching against a set of elements, the first // thing to do is to add r[0] to matched elements rx = [[r[0]], r[1]]; // if we matched and there is still input to parse and // we don't already know this is the last element, // we're going to next check for the delimiter ... // if there's none, or if there's no input left to parse // than this must be the last element after all ... if (r[1].length > 0 && ! last) { try { q = d.call(this, r[1]); } catch (ex) { last = true; } } else { last = true; } // if we parsed the delimiter and now there's no more input, // that means we shouldn't have parsed the delimiter at all // so don't update r and mark this as the last element ... if (!last && q[1].length === 0) { last = true; } // so, if this isn't the last element, we're going to see if // we can get any more matches from the remaining (unmatched) // elements ... if (!last) { // build a list of the remaining rules we can match against, // i.e., all but the one we just matched against var qx = []; for (var j = 0; j < px.length ; j++) { if (i !== j) { qx.push(px[j]); } } // now invoke recursively set with the remaining input // note that we don't include the closing delimiter ... // we'll check for that ourselves at the end p = _.set(qx, d).call(this, q[1]); // if we got a non-empty set as a result ... // (otw rx already contains everything we want to match) if (p[0].length > 0) { // update current result, which is stored in rx ... // basically, pick up the remaining text from p[1] // and concat the result from p[0] so that we don't // get endless nesting ... rx[0] = rx[0].concat(p[0]); rx[1] = p[1]; } } // at this point, rx either contains the last matched element // or the entire matched set that starts with this element. // now we just check to see if this variation is better than // our best so far, in terms of how much of the input is parsed if (rx[1].length < best[1].length) { best = rx; } // if we've parsed all the input, then we're finished if (best[1].length === 0) { break; } } // so now we've either gone through all the patterns trying them // as the initial match; or we found one that parsed the entire // input string ... // if best has no matches, just return empty set ... if (best[0].length === 0) { return best; } // if a closing delimiter is provided, then we have to check it also if (c) { // we try this even if there is no remaining input because the pattern // may well be optional or match empty input ... try { q = c.call(this, best[1]); } catch (ey) { throw new $P.Exception(best[1]); } // it parsed ... be sure to update the best match remaining input best[1] = q[1]; } // if we're here, either there was no closing delimiter or we parsed it // so now we have the best match; just return it! return best; }; }, forward: function (gr, fname) { return function (s) { return gr[fname].call(this, s); }; }, // // Translation Operators // replace: function (rule, repl) { return function (s) { var r = rule.call(this, s); return [repl, r[1]]; }; }, process: function (rule, fn) { return function (s) { var r = rule.call(this, s); return [fn.call(this, r[0]), r[1]]; }; }, min: function (min, rule) { return function (s) { var rx = rule.call(this, s); if (rx[0].length < min) { throw new $P.Exception(s); } return rx; }; } }; // Generator Operators And Vector Operators // Generators are operators that have a signature of F(R) => R, // taking a given rule and returning another rule, such as // ignore, which parses a given rule and throws away the result. // Vector operators are those that have a signature of F(R1,R2,...) => R, // take a list of rules and returning a new rule, such as each. // Generator operators are converted (via the following _generator // function) into functions that can also take a list or array of rules // and return an array of new rules as though the function had been // called on each rule in turn (which is what actually happens). // This allows generators to be used with vector operators more easily. // Example: // each(ignore(foo, bar)) instead of each(ignore(foo), ignore(bar)) // This also turns generators into vector operators, which allows // constructs like: // not(cache(foo, bar)) var _generator = function (op) { function gen() { var args = null, rx = [], px, i; if (arguments.length > 1) { args = Array.prototype.slice.call(arguments); } else if (arguments[0] instanceof Array) { args = arguments[0]; } if (args) { px = args.shift(); if (px.length > 0) { args.unshift(px[i]); rx.push(op.apply(null, args)); args.shift(); return rx; } } else { return op.apply(null, arguments); } } return gen; }; var gx = "optional not ignore cache".split(/\s/); for (var i = 0 ; i < gx.length ; i++) { _[gx[i]] = _generator(_[gx[i]]); } var _vector = function (op) { return function () { if (arguments[0] instanceof Array) { return op.apply(null, arguments[0]); } else { return op.apply(null, arguments); } }; }; var vx = "each any all".split(/\s/); for (var j = 0 ; j < vx.length ; j++) { _[vx[j]] = _vector(_[vx[j]]); } }()); (function () { var $D = Date; var flattenAndCompact = function (ax) { var rx = []; for (var i = 0; i < ax.length; i++) { if (ax[i] instanceof Array) { rx = rx.concat(flattenAndCompact(ax[i])); } else { if (ax[i]) { rx.push(ax[i]); } } } return rx; }; var parseMeridian = function () { if (this.meridian && (this.hour || this.hour === 0)) { if (this.meridian === "a" && this.hour > 11 && Date.Config.strict24hr){ throw "Invalid hour and meridian combination"; } else if (this.meridian === "p" && this.hour < 12 && Date.Config.strict24hr){ throw "Invalid hour and meridian combination"; } else if (this.meridian === "p" && this.hour < 12) { this.hour = this.hour + 12; } else if (this.meridian === "a" && this.hour === 12) { this.hour = 0; } } }; var setDefaults = function () { var now = new Date(); if ((this.hour || this.minute) && (!this.month && !this.year && !this.day)) { this.day = now.getDate(); } if (!this.year) { this.year = now.getFullYear(); } if (!this.month && this.month !== 0) { this.month = now.getMonth(); } if (!this.day) { this.day = 1; } if (!this.hour) { this.hour = 0; } if (!this.minute) { this.minute = 0; } if (!this.second) { this.second = 0; } if (!this.millisecond) { this.millisecond = 0; } }; var finishUtils = { getToday: function () { if (this.now || "hour minute second".indexOf(this.unit) !== -1) { return new Date(); } else { return $D.today(); } }, setDaysFromWeekday: function (today, orient){ var gap; orient = orient || 1; this.unit = "day"; gap = ($D.getDayNumberFromName(this.weekday) - today.getDay()); this.days = gap ? ((gap + (orient * 7)) % 7) : (orient * 7); return this; }, setMonthsFromMonth: function (today, orient) { var gap; orient = orient || 1; this.unit = "month"; gap = (this.month - today.getMonth()); this.months = gap ? ((gap + (orient * 12)) % 12) : (orient * 12); this.month = null; return this; }, setDMYFromWeekday: function () { var d = Date[this.weekday](); this.day = d.getDate(); if (!this.month) { this.month = d.getMonth(); } this.year = d.getFullYear(); return this; }, setUnitValue: function (orient) { if (!this.value && this.operator && this.operator !== null && this[this.unit + "s"] && this[this.unit + "s"] !== null) { this[this.unit + "s"] = this[this.unit + "s"] + ((this.operator === "add") ? 1 : -1) + (this.value||0) * orient; } else if (this[this.unit + "s"] == null || this.operator != null) { if (!this.value) { this.value = 1; } this[this.unit + "s"] = this.value * orient; } }, generateDateFromWeeks: function () { var weekday = (this.weekday !== undefined) ? this.weekday : "today"; var d = Date[weekday]().addWeeks(this.weeks); if (this.now) { d.setTimeToNow(); } return d; } }; $D.Translator = { hour: function (s) { return function () { this.hour = Number(s); }; }, minute: function (s) { return function () { this.minute = Number(s); }; }, second: function (s) { return function () { this.second = Number(s); }; }, /* for ss.s format */ secondAndMillisecond: function (s) { return function () { var mx = s.match(/^([0-5][0-9])\.([0-9]{1,3})/); this.second = Number(mx[1]); this.millisecond = Number(mx[2]); }; }, meridian: function (s) { return function () { this.meridian = s.slice(0, 1).toLowerCase(); }; }, timezone: function (s) { return function () { var n = s.replace(/[^\d\+\-]/g, ""); if (n.length) { this.timezoneOffset = Number(n); } else { this.timezone = s.toLowerCase(); } }; }, day: function (x) { var s = x[0]; return function () { this.day = Number(s.match(/\d+/)[0]); if (this.day < 1) { throw "invalid day"; } }; }, month: function (s) { return function () { this.month = (s.length === 3) ? "jan feb mar apr may jun jul aug sep oct nov dec".indexOf(s)/4 : Number(s) - 1; if (this.month < 0) { throw "invalid month"; } }; }, year: function (s) { return function () { var n = Number(s); this.year = ((s.length > 2) ? n : (n + (((n + 2000) < Date.CultureInfo.twoDigitYearMax) ? 2000 : 1900))); }; }, rday: function (s) { return function () { switch (s) { case "yesterday": this.days = -1; break; case "tomorrow": this.days = 1; break; case "today": this.days = 0; break; case "now": this.days = 0; this.now = true; break; } }; }, finishExact: function (x) { var d; x = (x instanceof Array) ? x : [x]; for (var i = 0 ; i < x.length ; i++) { if (x[i]) { x[i].call(this); } } setDefaults.call(this); parseMeridian.call(this); if (this.day > $D.getDaysInMonth(this.year, this.month)) { throw new RangeError(this.day + " is not a valid value for days."); } d = new Date(this.year, this.month, this.day, this.hour, this.minute, this.second, this.millisecond); if (this.year < 100) { d.setFullYear(this.year); // means years less that 100 are process correctly. JS will parse it otherwise as 1900-1999. } if (this.timezone) { d.set({ timezone: this.timezone }); } else if (this.timezoneOffset) { d.set({ timezoneOffset: this.timezoneOffset }); } return d; }, finish: function (x) { var today, expression, orient, temp; x = (x instanceof Array) ? flattenAndCompact(x) : [ x ]; if (x.length === 0) { return null; } for (var i = 0 ; i < x.length ; i++) { if (typeof x[i] === "function") { x[i].call(this); } } if (this.now && !this.unit && !this.operator) { return new Date(); } else { today = finishUtils.getToday.call(this); } expression = !!(this.days && this.days !== null || this.orient || this.operator); orient = ((this.orient === "past" || this.operator === "subtract") ? -1 : 1); if (this.month && this.unit === "week") { this.value = this.month + 1; delete this.month; delete this.day; } if ((this.month || this.month === 0) && "year day hour minute second".indexOf(this.unit) !== -1) { if (!this.value) { this.value = this.month + 1; } this.month = null; expression = true; } if (!expression && this.weekday && !this.day && !this.days) { finishUtils.setDMYFromWeekday.call(this); } if (expression && this.weekday && this.unit !== "month" && this.unit !== "week") { finishUtils.setDaysFromWeekday.call(this, today, orient); } if (this.weekday && this.unit !== "week" && !this.day && !this.days) { temp = Date[this.weekday](); this.day = temp.getDate(); if (temp.getMonth() !== today.getMonth()) { this.month = temp.getMonth(); } } if (this.month && this.unit === "day" && this.operator) { if (!this.value) { this.value = (this.month + 1); } this.month = null; } if (this.value != null && this.month != null && this.year != null) { this.day = this.value * 1; } if (this.month && !this.day && this.value) { today.set({ day: this.value * 1 }); if (!expression) { this.day = this.value * 1; } } if (!this.month && this.value && this.unit === "month" && !this.now) { this.month = this.value; expression = true; } if (expression && (this.month || this.month === 0) && this.unit !== "year") { finishUtils.setMonthsFromMonth.call(this, today, orient); } if (!this.unit) { this.unit = "day"; } finishUtils.setUnitValue.call(this, orient); parseMeridian.call(this); if ((this.month || this.month === 0) && !this.day) { this.day = 1; } if (!this.orient && !this.operator && this.unit === "week" && this.value && !this.day && !this.month) { return Date.today().setWeek(this.value); } if (this.unit === "week" && this.weeks && !this.day && !this.month) { return finishUtils.generateDateFromWeeks.call(this); } if (expression && this.timezone && this.day && this.days) { this.day = this.days; } if (expression){ today.add(this); } else { today.set(this); } if (this.timezone) { this.timezone = this.timezone.toUpperCase(); var offset = $D.getTimezoneOffset(this.timezone); var timezone; if (today.hasDaylightSavingTime()) { // lets check that we're being sane with timezone setting timezone = $D.getTimezoneAbbreviation(offset, today.isDaylightSavingTime()); if (timezone !== this.timezone) { // bugger, we're in a place where things like EST vs EDT matters. if (today.isDaylightSavingTime()) { today.addHours(-1); } else { today.addHours(1); } } } today.setTimezoneOffset(offset); } return today; } }; }()); (function () { var $D = Date; $D.Grammar = {}; var _ = $D.Parsing.Operators, g = $D.Grammar, t = $D.Translator, _fn; // Allow rolling up into general purpose rules _fn = function () { return _.each(_.any.apply(null, arguments), _.not(g.ctoken2("timeContext"))); }; g.datePartDelimiter = _.rtoken(/^([\s\-\.\,\/\x27]+)/); g.timePartDelimiter = _.stoken(":"); g.whiteSpace = _.rtoken(/^\s*/); g.generalDelimiter = _.rtoken(/^(([\s\,]|at|@|on)+)/); var _C = {}; g.ctoken = function (keys) { var fn = _C[keys]; if (! fn) { var c = Date.CultureInfo.regexPatterns; var kx = keys.split(/\s+/), px = []; for (var i = 0; i < kx.length ; i++) { px.push(_.replace(_.rtoken(c[kx[i]]), kx[i])); } fn = _C[keys] = _.any.apply(null, px); } return fn; }; g.ctoken2 = function (key) { return _.rtoken(Date.CultureInfo.regexPatterns[key]); }; var cacheProcessRtoken = function (key, token, type, eachToken) { if (eachToken) { g[key] = _.cache(_.process(_.each(_.rtoken(token),_.optional(g.ctoken2(eachToken))), type)); } else { g[key] = _.cache(_.process(_.rtoken(token), type)); } }; var cacheProcessCtoken = function (token, type) { return _.cache(_.process(g.ctoken2(token), type)); }; var _F = {}; //function cache var _get = function (f) { _F[f] = (_F[f] || g.format(f)[0]); return _F[f]; }; g.allformats = function (fx) { var rx = []; if (fx instanceof Array) { for (var i = 0; i < fx.length; i++) { rx.push(_get(fx[i])); } } else { rx.push(_get(fx)); } return rx; }; g.formats = function (fx) { if (fx instanceof Array) { var rx = []; for (var i = 0 ; i < fx.length ; i++) { rx.push(_get(fx[i])); } return _.any.apply(null, rx); } else { return _get(fx); } }; var grammarFormats = { timeFormats: function(){ var i, RTokenKeys = [ "h", "hh", "H", "HH", "m", "mm", "s", "ss", "ss.s", "z", "zz" ], RToken = [ /^(0[0-9]|1[0-2]|[1-9])/, /^(0[0-9]|1[0-2])/, /^([0-1][0-9]|2[0-3]|[0-9])/, /^([0-1][0-9]|2[0-3])/, /^([0-5][0-9]|[0-9])/, /^[0-5][0-9]/, /^([0-5][0-9]|[0-9])/, /^[0-5][0-9]/, /^[0-5][0-9]\.[0-9]{1,3}/, /^((\+|\-)\s*\d\d\d\d)|((\+|\-)\d\d\:?\d\d)/, /^((\+|\-)\s*\d\d\d\d)|((\+|\-)\d\d\:?\d\d)/ ], tokens = [ t.hour, t.hour, t.hour, t.hour, t.minute, t.minute, t.second, t.second, t.secondAndMillisecond, t.timezone, t.timezone ]; for (i=0; i < RTokenKeys.length; i++) { cacheProcessRtoken(RTokenKeys[i], RToken[i], tokens[i]); } g.hms = _.cache(_.sequence([g.H, g.m, g.s], g.timePartDelimiter)); g.t = cacheProcessCtoken("shortMeridian", t.meridian); g.tt = cacheProcessCtoken("longMeridian", t.meridian); g.zzz = cacheProcessCtoken("timezone", t.timezone); g.timeSuffix = _.each(_.ignore(g.whiteSpace), _.set([ g.tt, g.zzz ])); g.time = _.each(_.optional(_.ignore(_.stoken("T"))), g.hms, g.timeSuffix); }, dateFormats: function () { // pre-loaded rules for different date part order preferences var _setfn = function () { return _.set(arguments, g.datePartDelimiter); }; var i, RTokenKeys = [ "d", "dd", "M", "MM", "y", "yy", "yyy", "yyyy" ], RToken = [ /^([0-2]\d|3[0-1]|\d)/, /^([0-2]\d|3[0-1])/, /^(1[0-2]|0\d|\d)/, /^(1[0-2]|0\d)/, /^(\d+)/, /^(\d\d)/, /^(\d\d?\d?\d?)/, /^(\d\d\d\d)/ ], tokens = [ t.day, t.day, t.month, t.month, t.year, t.year, t.year, t.year ], eachToken = [ "ordinalSuffix", "ordinalSuffix" ]; for (i=0; i < RTokenKeys.length; i++) { cacheProcessRtoken(RTokenKeys[i], RToken[i], tokens[i], eachToken[i]); } g.MMM = g.MMMM = _.cache(_.process(g.ctoken("jan feb mar apr may jun jul aug sep oct nov dec"), t.month)); g.ddd = g.dddd = _.cache(_.process(g.ctoken("sun mon tue wed thu fri sat"), function (s) { return function () { this.weekday = s; }; } )); g.day = _fn(g.d, g.dd); g.month = _fn(g.M, g.MMM); g.year = _fn(g.yyyy, g.yy); g.mdy = _setfn(g.ddd, g.month, g.day, g.year); g.ymd = _setfn(g.ddd, g.year, g.month, g.day); g.dmy = _setfn(g.ddd, g.day, g.month, g.year); g.date = function (s) { return ((g[Date.CultureInfo.dateElementOrder] || g.mdy).call(this, s)); }; }, relative: function () { // relative date / time expressions g.orientation = _.process(g.ctoken("past future"), function (s) { return function () { this.orient = s; }; } ); g.operator = _.process(g.ctoken("add subtract"), function (s) { return function () { this.operator = s; }; } ); g.rday = _.process(g.ctoken("yesterday tomorrow today now"), t.rday); g.unit = _.process(g.ctoken("second minute hour day week month year"), function (s) { return function () { this.unit = s; }; } ); } }; g.buildGrammarFormats = function () { // these need to be rebuilt every time the language changes. _C = {}; grammarFormats.timeFormats(); grammarFormats.dateFormats(); grammarFormats.relative(); g.value = _.process(_.rtoken(/^([-+]?\d+)?(st|nd|rd|th)?/), function (s) { return function () { this.value = s.replace(/\D/g, ""); }; } ); g.expression = _.set([g.rday, g.operator, g.value, g.unit, g.orientation, g.ddd, g.MMM ]); g.format = _.process(_.many( _.any( // translate format specifiers into grammar rules _.process( _.rtoken(/^(dd?d?d?(?!e)|MM?M?M?|yy?y?y?|hh?|HH?|mm?|ss?|tt?|zz?z?)/), function (fmt) { if (g[fmt]) { return g[fmt]; } else { throw $D.Parsing.Exception(fmt); } } ), // translate separator tokens into token rules _.process(_.rtoken(/^[^dMyhHmstz]+/), // all legal separators function (s) { return _.ignore(_.stoken(s)); } ) ) ), // construct the parser ... function (rules) { return _.process(_.each.apply(null, rules), t.finishExact); } ); // starting rule for general purpose grammar g._start = _.process(_.set([ g.date, g.time, g.expression ], g.generalDelimiter, g.whiteSpace), t.finish); }; g.buildGrammarFormats(); // parsing date format specifiers - ex: "h:m:s tt" // this little guy will generate a custom parser based // on the format string, ex: g.format("h:m:s tt") // check for these formats first g._formats = g.formats([ "\"yyyy-MM-ddTHH:mm:ssZ\"", "yyyy-MM-ddTHH:mm:ss.sz", "yyyy-MM-ddTHH:mm:ssZ", "yyyy-MM-ddTHH:mm:ssz", "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-ddTHH:mmZ", "yyyy-MM-ddTHH:mmz", "yyyy-MM-ddTHH:mm", "ddd, MMM dd, yyyy H:mm:ss tt", "ddd MMM d yyyy HH:mm:ss zzz", "MMddyyyy", "ddMMyyyy", "Mddyyyy", "ddMyyyy", "Mdyyyy", "dMyyyy", "yyyy", "Mdyy", "dMyy", "d" ]); // real starting rule: tries selected formats first, // then general purpose rule g.start = function (s) { try { var r = g._formats.call({}, s); if (r[1].length === 0) { return r; } } catch (e) {} return g._start.call({}, s); }; }()); (function () { var $D = Date; /** * @desc Converts the specified string value into its JavaScript Date equivalent using CultureInfo specific format information. * * Example

	///////////
	// Dates //
	///////////

	// 15-Oct-2004
	var d1 = Date.parse("10/15/2004");

	// 15-Oct-2004
	var d1 = Date.parse("15-Oct-2004");

	// 15-Oct-2004
	var d1 = Date.parse("2004.10.15");

	//Fri Oct 15, 2004
	var d1 = Date.parse("Fri Oct 15, 2004");

	///////////
	// Times //
	///////////

	// Today at 10 PM.
	var d1 = Date.parse("10 PM");

	// Today at 10:30 PM.
	var d1 = Date.parse("10:30 P.M.");

	// Today at 6 AM.
	var d1 = Date.parse("06am");

	/////////////////////
	// Dates and Times //
	/////////////////////

	// 8-July-2004 @ 10:30 PM
	var d1 = Date.parse("July 8th, 2004, 10:30 PM");

	// 1-July-2004 @ 10:30 PM
	var d1 = Date.parse("2004-07-01T22:30:00");

	////////////////////
	// Relative Dates //
	////////////////////

	// Returns today's date. The string "today" is culture specific.
	var d1 = Date.parse("today");

	// Returns yesterday's date. The string "yesterday" is culture specific.
	var d1 = Date.parse("yesterday");

	// Returns the date of the next thursday.
	var d1 = Date.parse("Next thursday");

	// Returns the date of the most previous monday.
	var d1 = Date.parse("last monday");

	// Returns today's day + one year.
	var d1 = Date.parse("next year");

	///////////////
	// Date Math //
	///////////////

	// Today + 2 days
	var d1 = Date.parse("t+2");

	// Today + 2 days
	var d1 = Date.parse("today + 2 days");

	// Today + 3 months
	var d1 = Date.parse("t+3m");

	// Today - 1 year
	var d1 = Date.parse("today - 1 year");

	// Today - 1 year
	var d1 = Date.parse("t-1y"); 


	/////////////////////////////
	// Partial Dates and Times //
	/////////////////////////////

	// July 15th of this year.
	var d1 = Date.parse("July 15");

	// 15th day of current day and year.
	var d1 = Date.parse("15");

	// July 1st of current year at 10pm.
	var d1 = Date.parse("7/1 10pm");
	
* * @param {String} The string value to convert into a Date object [Required] * @return {Date} A Date object or null if the string cannot be converted into a Date. */ var parseUtils = { removeOrds: function (s) { ords = s.match(/\b(\d+)(?:st|nd|rd|th)\b/); // find ordinal matches s = ((ords && ords.length === 2) ? s.replace(ords[0], ords[1]) : s); return s; }, grammarParser: function (s) { var r = null; try { r = $D.Grammar.start.call({}, s.replace(/^\s*(\S*(\s+\S+)*)\s*$/, "$1")); } catch (e) { return null; } return ((r[1].length === 0) ? r[0] : null); }, nativeFallback: function(s) { var t; try { // ok we haven't parsed it, last ditch attempt with the built-in parser. t = Date._parse(s); return (t || t === 0) ? new Date(t) : null; } catch (e) { return null; } } }; function parse (s) { var d; if (!s) { return null; } if (s instanceof Date) { return s.clone(); } if (s.length >= 4 && s.charAt(0) !== "0" && s.charAt(0) !== "+"&& s.charAt(0) !== "-") { // ie: 2004 will pass, 0800 won't. // Start with specific formats d = $D.Parsing.ISO.parse(s) || $D.Parsing.Numeric.parse(s); } if (d instanceof Date && !isNaN(d.getTime())) { return d; } else { // find ordinal dates (1st, 3rd, 8th, etc and remove them as they cause parsing issues) s = $D.Parsing.Normalizer.parse(parseUtils.removeOrds(s)); d = parseUtils.grammarParser(s); if (d !== null) { return d; } else { return parseUtils.nativeFallback(s); } } } if (!$D._parse) { $D._parse = $D.parse; } $D.parse = parse; Date.getParseFunction = function (fx) { var fns = Date.Grammar.allformats(fx); return function (s) { var r = null; for (var i = 0; i < fns.length; i++) { try { r = fns[i].call({}, s); } catch (e) { continue; } if (r[1].length === 0) { return r[0]; } } return null; }; }; /** * Converts the specified string value into its JavaScript Date equivalent using the specified format {String} or formats {Array} and the CultureInfo specific format information. * The format of the string value must match one of the supplied formats exactly. * * Example

	// 15-Oct-2004
	var d1 = Date.parseExact("10/15/2004", "M/d/yyyy");

	// 15-Oct-2004
	var d1 = Date.parse("15-Oct-2004", "M-ddd-yyyy");

	// 15-Oct-2004
	var d1 = Date.parse("2004.10.15", "yyyy.MM.dd");

	// Multiple formats
	var d1 = Date.parseExact("10/15/2004", ["M/d/yyyy", "MMMM d, yyyy"]);
	
* * @param {String} The string value to convert into a Date object [Required]. * @param {Object} The expected format {String} or an array of expected formats {Array} of the date string [Required]. * @return {Date} A Date object or null if the string cannot be converted into a Date. */ $D.parseExact = function (s, fx) { return $D.getParseFunction(fx)(s); }; }()); (function () { var $D = Date, $P = $D.prototype, // $C = $D.CultureInfo, // not used atm p = function (s, l) { if (!l) { l = 2; } return ("000" + s).slice(l * -1); }; /** * Converts a PHP format string to Java/.NET format string. * A PHP format string can be used with ._format or .format. * A Java/.NET format string can be used with .toString(). * The .parseExact function will only accept a Java/.NET format string * * Example * var f1 = "%m/%d/%y" * var f2 = Date.normalizeFormat(f1); // "MM/dd/yy" * * new Date().format(f1); // "04/13/08" * new Date()._format(f1); // "04/13/08" * new Date().toString(f2); // "04/13/08" * * var date = Date.parseExact("04/13/08", f2); // Sun Apr 13 2008 * * @param {String} A PHP format string consisting of one or more format spcifiers. * @return {String} The PHP format converted to a Java/.NET format string. */ var normalizerSubstitutions = { "d" : "dd", "%d": "dd", "D" : "ddd", "%a": "ddd", "j" : "dddd", "l" : "dddd", "%A": "dddd", "S" : "S", "F" : "MMMM", "%B": "MMMM", "m" : "MM", "%m": "MM", "M" : "MMM", "%b": "MMM", "%h": "MMM", "n" : "M", "Y" : "yyyy", "%Y": "yyyy", "y" : "yy", "%y": "yy", "g" : "h", "%I": "h", "G" : "H", "h" : "hh", "H" : "HH", "%H": "HH", "i" : "mm", "%M": "mm", "s" : "ss", "%S": "ss", "%r": "hh:mm tt", "%R": "H:mm", "%T": "H:mm:ss", "%X": "t", "%x": "d", "%e": "d", "%D": "MM/dd/yy", "%n": "\\n", "%t": "\\t", "e" : "z", "T" : "z", "%z": "z", "%Z": "z", "Z" : "ZZ", "N" : "u", "w" : "u", "%w": "u", "W" : "W", "%V": "W" }; var normalizer = { substitutes: function (m) { return normalizerSubstitutions[m]; }, interpreted: function (m, x) { var y; switch (m) { case "%u": return x.getDay() + 1; case "z": return x.getOrdinalNumber(); case "%j": return p(x.getOrdinalNumber(), 3); case "%U": var d1 = x.clone().set({month: 0, day: 1}).addDays(-1).moveToDayOfWeek(0), d2 = x.clone().addDays(1).moveToDayOfWeek(0, -1); return (d2 < d1) ? "00" : p((d2.getOrdinalNumber() - d1.getOrdinalNumber()) / 7 + 1); case "%W": return p(x.getWeek()); case "t": return $D.getDaysInMonth(x.getFullYear(), x.getMonth()); case "o": case "%G": return x.setWeek(x.getISOWeek()).toString("yyyy"); case "%g": return x._format("%G").slice(-2); case "a": case "%p": return t("tt").toLowerCase(); case "A": return t("tt").toUpperCase(); case "u": return p(x.getMilliseconds(), 3); case "I": return (x.isDaylightSavingTime()) ? 1 : 0; case "O": return x.getUTCOffset(); case "P": y = x.getUTCOffset(); return y.substring(0, y.length - 2) + ":" + y.substring(y.length - 2); case "B": var now = new Date(); return Math.floor(((now.getHours() * 3600) + (now.getMinutes() * 60) + now.getSeconds() + (now.getTimezoneOffset() + 60) * 60) / 86.4); case "c": return x.toISOString().replace(/\"/g, ""); case "U": return $D.strtotime("now"); case "%c": return t("d") + " " + t("t"); case "%C": return Math.floor(x.getFullYear() / 100 + 1); } }, shouldOverrideDefaults: function (m) { switch (m) { case "%e": return true; default: return false; } }, parse: function (m, context) { var formatString, c = context || new Date(); formatString = normalizer.substitutes(m); if (formatString) { return formatString; } formatString = normalizer.interpreted(m, c); if (formatString) { return formatString; } else { return m; } } }; $D.normalizeFormat = function (format, context) { return format.replace(/(%|\\)?.|%%/g, function(t){ return normalizer.parse(t, context); }); }; /** * Format a local Unix timestamp according to locale settings * * Example: * Date.strftime("%m/%d/%y", new Date()); // "04/13/08" * Date.strftime("c", "2008-04-13T17:52:03Z"); // "04/13/08" * * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @param {Number|String} The number representing the number of seconds that have elapsed since January 1, 1970 (local time). * @return {String} A string representation of the current Date object. */ $D.strftime = function (format, time) { var d = Date.parse(time); return d._format(format); }; /** * Parse any textual datetime description into a Unix timestamp. * A Unix timestamp is the number of seconds that have elapsed since January 1, 1970 (midnight UTC/GMT). * * Example: * Date.strtotime("04/13/08"); // 1208044800 * Date.strtotime("1970-01-01T00:00:00Z"); // 0 * * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @param {Object} A string or date object. * @return {String} A string representation of the current Date object. */ $D.strtotime = function (time) { var d = $D.parse(time); return Math.round($D.UTC(d.getUTCFullYear(), d.getUTCMonth(), d.getUTCDate(), d.getUTCHours(), d.getUTCMinutes(), d.getUTCSeconds(), d.getUTCMilliseconds()) / 1000); }; /** * Converts the value of the current Date object to its equivalent string representation using a PHP/Unix style of date format specifiers. * Format Specifiers * Format Description Example * ------ --------------------------------------------------------------------------- ----------------------- * %a abbreviated weekday name according to the current localed "Mon" through "Sun" * %A full weekday name according to the current localed "Sunday" through "Saturday" * %b abbreviated month name according to the current localed "Jan" through "Dec" * %B full month name according to the current locale "January" through "December" * %c preferred date and time representation for the current locale "4/13/2008 12:33 PM" * %C century number (the year divided by 100 and truncated to an integer) "00" to "99" * %d day of the month as a decimal number "01" to "31" * %D same as %m/%d/%y "04/13/08" * %e day of the month as a decimal number, a single digit is preceded by a space "1" to "31" * %g like %G, but without the century "08" * %G The 4-digit year corresponding to the ISO week number (see %V). "2008" * This has the same format and value as %Y, except that if the ISO week number * belongs to the previous or next year, that year is used instead. * %h same as %b "Jan" through "Dec" * %H hour as a decimal number using a 24-hour clock. "00" to "23" * %I hour as a decimal number using a 12-hour clock. "01" to "12" * %j day of the year as a decimal number. "001" to "366" * %m month as a decimal number. "01" to "12" * %M minute as a decimal number. "00" to "59" * %n newline character "\n" * %p either "am" or "pm" according to the given time value, or the "am" or "pm" * corresponding strings for the current locale. * %r time in a.m. and p.m. notation "8:44 PM" * %R time in 24 hour notation "20:44" * %S second as a decimal number "00" to "59" * %t tab character "\t" * %T current time, equal to %H:%M:%S "12:49:11" * %u weekday as a decimal number ["1", "7"], with "1" representing Monday "1" to "7" * %U week number of the current year as a decimal number, starting with the "0" to ("52" or "53") * first Sunday as the first day of the first week * %V The ISO 8601:1988 week number of the current year as a decimal number, "00" to ("52" or "53") * range 01 to 53, where week 1 is the first week that has at least 4 days * in the current year, and with Monday as the first day of the week. * (Use %G or %g for the year component that corresponds to the week number * for the specified timestamp.) * %W week number of the current year as a decimal number, starting with the "00" to ("52" or "53") * first Monday as the first day of the first week * %w day of the week as a decimal, Sunday being "0" "0" to "6" * %x preferred date representation for the current locale without the time "4/13/2008" * %X preferred time representation for the current locale without the date "12:53:05" * %y year as a decimal number without a century "00" "99" * %Y year as a decimal number including the century "2008" * %Z time zone or name or abbreviation "UTC", "EST", "PST" * %z same as %Z * %% a literal "%" characters "%" * d Day of the month, 2 digits with leading zeros "01" to "31" * D A textual representation of a day, three letters "Mon" through "Sun" * j Day of the month without leading zeros "1" to "31" * l A full textual representation of the day of the week (lowercase "L") "Sunday" through "Saturday" * N ISO-8601 numeric representation of the day of the week (added in PHP 5.1.0) "1" (for Monday) through "7" (for Sunday) * S English ordinal suffix for the day of the month, 2 characters "st", "nd", "rd" or "th". Works well with j * w Numeric representation of the day of the week "0" (for Sunday) through "6" (for Saturday) * z The day of the year (starting from "0") "0" through "365" * W ISO-8601 week number of year, weeks starting on Monday "00" to ("52" or "53") * F A full textual representation of a month, such as January or March "January" through "December" * m Numeric representation of a month, with leading zeros "01" through "12" * M A short textual representation of a month, three letters "Jan" through "Dec" * n Numeric representation of a month, without leading zeros "1" through "12" * t Number of days in the given month "28" through "31" * L Whether it's a leap year "1" if it is a leap year, "0" otherwise * o ISO-8601 year number. This has the same value as Y, except that if the "2008" * ISO week number (W) belongs to the previous or next year, that year * is used instead. * Y A full numeric representation of a year, 4 digits "2008" * y A two digit representation of a year "08" * a Lowercase Ante meridiem and Post meridiem "am" or "pm" * A Uppercase Ante meridiem and Post meridiem "AM" or "PM" * B Swatch Internet time "000" through "999" * g 12-hour format of an hour without leading zeros "1" through "12" * G 24-hour format of an hour without leading zeros "0" through "23" * h 12-hour format of an hour with leading zeros "01" through "12" * H 24-hour format of an hour with leading zeros "00" through "23" * i Minutes with leading zeros "00" to "59" * s Seconds, with leading zeros "00" through "59" * u Milliseconds "54321" * e Timezone identifier "UTC", "EST", "PST" * I Whether or not the date is in daylight saving time (uppercase i) "1" if Daylight Saving Time, "0" otherwise * O Difference to Greenwich time (GMT) in hours "+0200", "-0600" * P Difference to Greenwich time (GMT) with colon between hours and minutes "+02:00", "-06:00" * T Timezone abbreviation "UTC", "EST", "PST" * Z Timezone offset in seconds. The offset for timezones west of UTC is "-43200" through "50400" * always negative, and for those east of UTC is always positive. * c ISO 8601 date "2004-02-12T15:19:21+00:00" * r RFC 2822 formatted date "Thu, 21 Dec 2000 16:01:07 +0200" * U Seconds since the Unix Epoch (January 1 1970 00:00:00 GMT) "0" * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @return {String} A string representation of the current Date object. */ var formatReplace = function (context) { return function (m) { var formatString, override = false; if (m.charAt(0) === "\\" || m.substring(0, 2) === "%%") { return m.replace("\\", "").replace("%%", "%"); } override = normalizer.shouldOverrideDefaults(m); formatString = $D.normalizeFormat(m, context); if (formatString) { return context.toString(formatString, override); } }; }; $P._format = function (format) { var formatter = formatReplace(this); if (!format) { return this._toString(); } else { return format.replace(/(%|\\)?.|%%/g, formatter); } }; if (!$P.format) { $P.format = $P._format; } }()); (function () { "use strict"; var gFn = function (attr) { return function () { return this[attr]; }; }; var sFn = function (attr) { return function (val) { this[attr] = val; return this; }; }; var attrs = ["years", "months", "days", "hours", "minutes", "seconds", "milliseconds"]; var addSetFuncs = function (context, attrs) { for (var i = 0; i < attrs.length ; i++) { var $a = attrs[i], $b = $a.slice(0, 1).toUpperCase() + $a.slice(1); context.prototype[$a] = 0; context.prototype["get" + $b] = gFn($a); context.prototype["set" + $b] = sFn($a); } }; /** * new TimeSpan(milliseconds); * new TimeSpan(days, hours, minutes, seconds); * new TimeSpan(days, hours, minutes, seconds, milliseconds); */ var TimeSpan = function (days, hours, minutes, seconds, milliseconds) { if (arguments.length === 1 && typeof days === "number") { var orient = (days < 0) ? -1 : +1; var millsLeft = Math.abs(days); this.setDays(Math.floor(millsLeft / 86400000) * orient); millsLeft = millsLeft % 86400000; this.setHours(Math.floor(millsLeft / 3600000) * orient); millsLeft = millsLeft % 3600000; this.setMinutes(Math.floor(millsLeft / 60000) * orient); millsLeft = millsLeft % 60000; this.setSeconds(Math.floor(millsLeft / 1000) * orient); millsLeft = millsLeft % 1000; this.setMilliseconds(millsLeft * orient); } else { this.set(days, hours, minutes, seconds, milliseconds); } this.getTotalMilliseconds = function () { return (this.getDays() * 86400000) + (this.getHours() * 3600000) + (this.getMinutes() * 60000) + (this.getSeconds() * 1000); }; this.compareTo = function (time) { var t1 = new Date(1970, 1, 1, this.getHours(), this.getMinutes(), this.getSeconds()), t2; if (time === null) { t2 = new Date(1970, 1, 1, 0, 0, 0); } else { t2 = new Date(1970, 1, 1, time.getHours(), time.getMinutes(), time.getSeconds()); } return (t1 < t2) ? -1 : (t1 > t2) ? 1 : 0; }; this.equals = function (time) { return (this.compareTo(time) === 0); }; this.add = function (time) { return (time === null) ? this : this.addSeconds(time.getTotalMilliseconds() / 1000); }; this.subtract = function (time) { return (time === null) ? this : this.addSeconds(-time.getTotalMilliseconds() / 1000); }; this.addDays = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 86400000)); }; this.addHours = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 3600000)); }; this.addMinutes = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 60000)); }; this.addSeconds = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 1000)); }; this.addMilliseconds = function (n) { return new TimeSpan(this.getTotalMilliseconds() + n); }; this.get12HourHour = function () { return (this.getHours() > 12) ? this.getHours() - 12 : (this.getHours() === 0) ? 12 : this.getHours(); }; this.getDesignator = function () { return (this.getHours() < 12) ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator; }; this.toString = function (format) { this._toString = function () { if (this.getDays() !== null && this.getDays() > 0) { return this.getDays() + "." + this.getHours() + ":" + this.p(this.getMinutes()) + ":" + this.p(this.getSeconds()); } else { return this.getHours() + ":" + this.p(this.getMinutes()) + ":" + this.p(this.getSeconds()); } }; this.p = function (s) { return (s.toString().length < 2) ? "0" + s : s; }; var me = this; return format ? format.replace(/dd?|HH?|hh?|mm?|ss?|tt?/g, function (format) { switch (format) { case "d": return me.getDays(); case "dd": return me.p(me.getDays()); case "H": return me.getHours(); case "HH": return me.p(me.getHours()); case "h": return me.get12HourHour(); case "hh": return me.p(me.get12HourHour()); case "m": return me.getMinutes(); case "mm": return me.p(me.getMinutes()); case "s": return me.getSeconds(); case "ss": return me.p(me.getSeconds()); case "t": return ((me.getHours() < 12) ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator).substring(0, 1); case "tt": return (me.getHours() < 12) ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator; } } ) : this._toString(); }; return this; }; addSetFuncs(TimeSpan, attrs.slice(2)); TimeSpan.prototype.set = function (days, hours, minutes, seconds, milliseconds){ this.setDays(days || this.getDays()); this.setHours(hours || this.getHours()); this.setMinutes(minutes || this.getMinutes()); this.setSeconds(seconds || this.getSeconds()); this.setMilliseconds(milliseconds || this.getMilliseconds()); }; /** * Gets the time of day for this date instances. * @return {TimeSpan} TimeSpan */ Date.prototype.getTimeOfDay = function () { return new TimeSpan(0, this.getHours(), this.getMinutes(), this.getSeconds(), this.getMilliseconds()); }; Date.TimeSpan = TimeSpan; if (typeof window !== "undefined" ) { // keeping API compatible for v1.x window.TimeSpan = TimeSpan; } }()); (function () { "use strict"; var attrs = ["years", "months", "days", "hours", "minutes", "seconds", "milliseconds"]; var gFn = function (attr) { return function () { return this[attr]; }; }; var sFn = function (attr) { return function (val) { this[attr] = val; return this; }; }; var addSetFuncs = function (context, attrs) { for (var i = 0; i < attrs.length ; i++) { var $a = attrs[i], $b = $a.slice(0, 1).toUpperCase() + $a.slice(1); context.prototype[$a] = 0; context.prototype["get" + $b] = gFn($a); context.prototype["set" + $b] = sFn($a); } }; var setMonthsAndYears = function (orient, d1, d2, context) { function inc() { d1.addMonths(-orient); context.months++; if (context.months === 12) { context.years++; context.months = 0; } } if (orient === +1) { while (d1 > d2) { inc(); } } else { while (d1 < d2) { inc(); } } context.months--; context.months *= orient; context.years *= orient; }; var adjustForDST = function(orient, startDate, endDate) { var hasDSTMismatch = (false === (startDate.isDaylightSavingTime() === endDate.isDaylightSavingTime())); if (hasDSTMismatch && orient === 1) { startDate.addHours(-1); } else if (hasDSTMismatch) { startDate.addHours(1); } }; /** * TimePeriod(startDate, endDate); * TimePeriod(years, months, days, hours, minutes, seconds, milliseconds); */ var TimePeriod = function (years, months, days, hours, minutes, seconds, milliseconds) { if (arguments.length === 7) { this.set(years, months, days, hours, minutes, seconds, milliseconds); } else if (arguments.length === 2 && arguments[0] instanceof Date && arguments[1] instanceof Date) { var startDate = arguments[0].clone(); var endDate = arguments[1].clone(); var orient = (startDate > endDate) ? +1 : -1; this.dates = { start: arguments[0].clone(), end: arguments[1].clone() }; setMonthsAndYears(orient, startDate, endDate, this); adjustForDST(orient, startDate, endDate); // // TODO - adjust for DST var diff = endDate - startDate; if (diff !== 0) { var ts = new TimeSpan(diff); this.set(this.years, this.months, ts.getDays(), ts.getHours(), ts.getMinutes(), ts.getSeconds(), ts.getMilliseconds()); } } return this; }; // create all the set functions. addSetFuncs(TimePeriod, attrs); TimePeriod.prototype.set = function (years, months, days, hours, minutes, seconds, milliseconds){ this.setYears(years || this.getYears()); this.setMonths(months || this.getMonths()); this.setDays(days || this.getDays()); this.setHours(hours || this.getHours()); this.setMinutes(minutes || this.getMinutes()); this.setSeconds(seconds || this.getSeconds()); this.setMilliseconds(milliseconds || this.getMilliseconds()); }; Date.TimePeriod = TimePeriod; if (typeof window !== "undefined") { // keeping API compatible for v1.x window.TimePeriod = TimePeriod; } }()); ================================================ FILE: build/date-ar-LB.js ================================================ /** * @overview datejs * @version 1.0.0-rc3 * @author Gregory Wild-Smith * @copyright 2015 Gregory Wild-Smith * @license MIT * @homepage https://github.com/abritinthebay/datejs */ /* * DateJS Culture String File * Country Code: ar-LB * Name: Arabic (Lebanon) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["ar-LB"] = { "name": "ar-LB", "englishName": "Arabic (Lebanon)", "nativeName": "العربية (لبنان)", "Sunday": "الاحد", "Monday": "الاثنين", "Tuesday": "الثلاثاء", "Wednesday": "الاربعاء", "Thursday": "الخميس", "Friday": "الجمعة", "Saturday": "السبت", "Sun": "الاحد", "Mon": "الاثنين", "Tue": "الثلاثاء", "Wed": "الاربعاء", "Thu": "الخميس", "Fri": "الجمعة", "Sat": "السبت", "Su": "أ", "Mo": "ا", "Tu": "ث", "We": "أ", "Th": "خ", "Fr": "ج", "Sa": "س", "S_Sun_Initial": "أ", "M_Mon_Initial": "ا", "T_Tue_Initial": "ث", "W_Wed_Initial": "أ", "T_Thu_Initial": "خ", "F_Fri_Initial": "ج", "S_Sat_Initial": "س", "January": "كانون الثاني", "February": "شباط", "March": "آذار", "April": "نيسان", "May": "أيار", "June": "حزيران", "July": "تموز", "August": "آب", "September": "أيلول", "October": "تشرين الأول", "November": "تشرين الثاني", "December": "كانون الأول", "Jan_Abbr": "كانون الثاني", "Feb_Abbr": "شباط", "Mar_Abbr": "آذار", "Apr_Abbr": "نيسان", "May_Abbr": "أيار", "Jun_Abbr": "حزيران", "Jul_Abbr": "تموز", "Aug_Abbr": "آب", "Sep_Abbr": "أيلول", "Oct_Abbr": "تشرين الأول", "Nov_Abbr": "تشرين الثاني", "Dec_Abbr": "كانون الأول", "AM": "ص", "PM": "م", "firstDayOfWeek": 1, "twoDigitYearMax": 2029, "mdy": "dmy", "M/d/yyyy": "dd/MM/yyyy", "dddd, MMMM dd, yyyy": "dd MMMM, yyyy", "h:mm tt": "hh:mm tt", "h:mm:ss tt": "hh:mm:ss tt", "dddd, MMMM dd, yyyy h:mm:ss tt": "dd MMMM, yyyy hh:mm:ss tt", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "dd MMMM", "MMMM, yyyy": "MMMM, yyyy", "/jan(uary)?/": "كانون الثاني", "/feb(ruary)?/": "شباط", "/mar(ch)?/": "آذار", "/apr(il)?/": "نيسان", "/may/": "أيار", "/jun(e)?/": "حزيران", "/jul(y)?/": "تموز", "/aug(ust)?/": "آب", "/sep(t(ember)?)?/": "أيلول", "/oct(ober)?/": "تشرين الأول", "/nov(ember)?/": "تشرين الثاني", "/dec(ember)?/": "كانون الأول", "/^su(n(day)?)?/": "^الاحد", "/^mo(n(day)?)?/": "^ا(1)?", "/^tu(e(s(day)?)?)?/": "^الثلاثاء", "/^we(d(nesday)?)?/": "^الاربعاء", "/^th(u(r(s(day)?)?)?)?/": "^الخميس", "/^fr(i(day)?)?/": "^الجمعة", "/^sa(t(urday)?)?/": "^السبت", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "ar-LB"; /** * @overview datejs * @version 1.0.0-rc3 * @author Gregory Wild-Smith * @copyright 2015 Gregory Wild-Smith * @license MIT * @homepage https://github.com/abritinthebay/datejs */(function () { var $D = Date; var lang = Date.CultureStrings ? Date.CultureStrings.lang : null; var loggedKeys = {}; // for debug purposes. var getText = { getFromKey: function (key, countryCode) { var output; if (Date.CultureStrings && Date.CultureStrings[countryCode] && Date.CultureStrings[countryCode][key]) { output = Date.CultureStrings[countryCode][key]; } else { output = getText.buildFromDefault(key); } if (key.charAt(0) === "/") { // Assume it's a regex output = getText.buildFromRegex(key, countryCode); } return output; }, getFromObjectValues: function (obj, countryCode) { var key, output = {}; for(key in obj) { if (obj.hasOwnProperty(key)) { output[key] = getText.getFromKey(obj[key], countryCode); } } return output; }, getFromObjectKeys: function (obj, countryCode) { var key, output = {}; for(key in obj) { if (obj.hasOwnProperty(key)) { output[getText.getFromKey(key, countryCode)] = obj[key]; } } return output; }, getFromArray: function (arr, countryCode) { var output = []; for (var i=0; i < arr.length; i++){ if (i in arr) { output[i] = getText.getFromKey(arr[i], countryCode); } } return output; }, buildFromDefault: function (key) { var output, length, split, last; switch(key) { case "name": output = "en-US"; break; case "englishName": output = "English (United States)"; break; case "nativeName": output = "English (United States)"; break; case "twoDigitYearMax": output = 2049; break; case "firstDayOfWeek": output = 0; break; default: output = key; split = key.split("_"); length = split.length; if (length > 1 && key.charAt(0) !== "/") { // if the key isn't a regex and it has a split. last = split[(length - 1)].toLowerCase(); if (last === "initial" || last === "abbr") { output = split[0]; } } break; } return output; }, buildFromRegex: function (key, countryCode) { var output; if (Date.CultureStrings && Date.CultureStrings[countryCode] && Date.CultureStrings[countryCode][key]) { output = new RegExp(Date.CultureStrings[countryCode][key], "i"); } else { output = new RegExp(key.replace(new RegExp("/", "g"),""), "i"); } return output; } }; var shallowMerge = function (obj1, obj2) { for (var attrname in obj2) { if (obj2.hasOwnProperty(attrname)) { obj1[attrname] = obj2[attrname]; } } }; var __ = function (key, language) { var countryCode = (language) ? language : lang; loggedKeys[key] = key; if (typeof key === "object") { if (key instanceof Array) { return getText.getFromArray(key, countryCode); } else { return getText.getFromObjectKeys(key, countryCode); } } else { return getText.getFromKey(key, countryCode); } }; var loadI18nScript = function (code) { // paatterned after jQuery's getScript. var url = Date.Config.i18n + code + ".js"; var head = document.getElementsByTagName("head")[0] || document.documentElement; var script = document.createElement("script"); script.src = url; var completed = false; var events = { done: function (){} // placeholder function }; // Attach handlers for all browsers script.onload = script.onreadystatechange = function() { if ( !completed && (!this.readyState || this.readyState === "loaded" || this.readyState === "complete") ) { events.done(); head.removeChild(script); } }; setTimeout(function() { head.insertBefore(script, head.firstChild); }, 0); // allows return to execute first return { done: function (cb) { events.done = function() { if (cb) { setTimeout(cb,0); } }; } }; }; var buildInfo = { buildFromMethodHash: function (obj) { var key; for(key in obj) { if (obj.hasOwnProperty(key)) { obj[key] = buildInfo[obj[key]](); } } return obj; }, timeZoneDST: function () { var DST = { "CHADT": "+1345", "NZDT": "+1300", "AEDT": "+1100", "ACDT": "+1030", "AZST": "+0500", "IRDT": "+0430", "EEST": "+0300", "CEST": "+0200", "BST": "+0100", "PMDT": "-0200", "ADT": "-0300", "NDT": "-0230", "EDT": "-0400", "CDT": "-0500", "MDT": "-0600", "PDT": "-0700", "AKDT": "-0800", "HADT": "-0900" }; return __(DST); }, timeZoneStandard: function () { var standard = { "LINT": "+1400", "TOT": "+1300", "CHAST": "+1245", "NZST": "+1200", "NFT": "+1130", "SBT": "+1100", "AEST": "+1000", "ACST": "+0930", "JST": "+0900", "CWST": "+0845", "CT": "+0800", "ICT": "+0700", "MMT": "+0630", "BST": "+0600", "NPT": "+0545", "IST": "+0530", "PKT": "+0500", "AFT": "+0430", "MSK": "+0400", "IRST": "+0330", "FET": "+0300", "EET": "+0200", "CET": "+0100", "GMT": "+0000", "UTC": "+0000", "CVT": "-0100", "GST": "-0200", "BRT": "-0300", "NST": "-0330", "AST": "-0400", "EST": "-0500", "CST": "-0600", "MST": "-0700", "PST": "-0800", "AKST": "-0900", "MIT": "-0930", "HST": "-1000", "SST": "-1100", "BIT": "-1200" }; return __(standard); }, timeZones: function (data) { var zone; data.timezones = []; for (zone in data.abbreviatedTimeZoneStandard) { if (data.abbreviatedTimeZoneStandard.hasOwnProperty(zone)) { data.timezones.push({ name: zone, offset: data.abbreviatedTimeZoneStandard[zone]}); } } for (zone in data.abbreviatedTimeZoneDST) { if (data.abbreviatedTimeZoneDST.hasOwnProperty(zone)) { data.timezones.push({ name: zone, offset: data.abbreviatedTimeZoneDST[zone], dst: true}); } } return data.timezones; }, days: function () { return __(["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"]); }, dayAbbr: function () { return __(["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"]); }, dayShortNames: function () { return __(["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"]); }, dayFirstLetters: function () { return __(["S_Sun_Initial", "M_Mon_Initial", "T_Tues_Initial", "W_Wed_Initial", "T_Thu_Initial", "F_Fri_Initial", "S_Sat_Initial"]); }, months: function () { return __(["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"]); }, monthAbbr: function () { return __(["Jan_Abbr", "Feb_Abbr", "Mar_Abbr", "Apr_Abbr", "May_Abbr", "Jun_Abbr", "Jul_Abbr", "Aug_Abbr", "Sep_Abbr", "Oct_Abbr", "Nov_Abbr", "Dec_Abbr"]); }, formatPatterns: function () { return getText.getFromObjectValues({ shortDate: "M/d/yyyy", longDate: "dddd, MMMM dd, yyyy", shortTime: "h:mm tt", longTime: "h:mm:ss tt", fullDateTime: "dddd, MMMM dd, yyyy h:mm:ss tt", sortableDateTime: "yyyy-MM-ddTHH:mm:ss", universalSortableDateTime: "yyyy-MM-dd HH:mm:ssZ", rfc1123: "ddd, dd MMM yyyy HH:mm:ss", monthDay: "MMMM dd", yearMonth: "MMMM, yyyy" }, Date.i18n.currentLanguage()); }, regex: function () { return getText.getFromObjectValues({ inTheMorning: "/( in the )(morn(ing)?)\\b/", thisMorning: "/(this )(morn(ing)?)\\b/", amThisMorning: "/(\b\\d(am)? )(this )(morn(ing)?)/", inTheEvening: "/( in the )(even(ing)?)\\b/", thisEvening: "/(this )(even(ing)?)\\b/", pmThisEvening: "/(\b\\d(pm)? )(this )(even(ing)?)/", jan: "/jan(uary)?/", feb: "/feb(ruary)?/", mar: "/mar(ch)?/", apr: "/apr(il)?/", may: "/may/", jun: "/jun(e)?/", jul: "/jul(y)?/", aug: "/aug(ust)?/", sep: "/sep(t(ember)?)?/", oct: "/oct(ober)?/", nov: "/nov(ember)?/", dec: "/dec(ember)?/", sun: "/^su(n(day)?)?/", mon: "/^mo(n(day)?)?/", tue: "/^tu(e(s(day)?)?)?/", wed: "/^we(d(nesday)?)?/", thu: "/^th(u(r(s(day)?)?)?)?/", fri: "/fr(i(day)?)?/", sat: "/^sa(t(urday)?)?/", future: "/^next/", past: "/^last|past|prev(ious)?/", add: "/^(\\+|aft(er)?|from|hence)/", subtract: "/^(\\-|bef(ore)?|ago)/", yesterday: "/^yes(terday)?/", today: "/^t(od(ay)?)?/", tomorrow: "/^tom(orrow)?/", now: "/^n(ow)?/", millisecond: "/^ms|milli(second)?s?/", second: "/^sec(ond)?s?/", minute: "/^mn|min(ute)?s?/", hour: "/^h(our)?s?/", week: "/^w(eek)?s?/", month: "/^m(onth)?s?/", day: "/^d(ay)?s?/", year: "/^y(ear)?s?/", shortMeridian: "/^(a|p)/", longMeridian: "/^(a\\.?m?\\.?|p\\.?m?\\.?)/", timezone: "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/", ordinalSuffix: "/^\\s*(st|nd|rd|th)/", timeContext: "/^\\s*(\\:|a(?!u|p)|p)/" }, Date.i18n.currentLanguage()); } }; var CultureInfo = function () { var info = getText.getFromObjectValues({ name: "name", englishName: "englishName", nativeName: "nativeName", amDesignator: "AM", pmDesignator: "PM", firstDayOfWeek: "firstDayOfWeek", twoDigitYearMax: "twoDigitYearMax", dateElementOrder: "mdy" }, Date.i18n.currentLanguage()); var constructedInfo = buildInfo.buildFromMethodHash({ dayNames: "days", abbreviatedDayNames: "dayAbbr", shortestDayNames: "dayShortNames", firstLetterDayNames: "dayFirstLetters", monthNames: "months", abbreviatedMonthNames: "monthAbbr", formatPatterns: "formatPatterns", regexPatterns: "regex", abbreviatedTimeZoneDST: "timeZoneDST", abbreviatedTimeZoneStandard: "timeZoneStandard" }); shallowMerge(info, constructedInfo); buildInfo.timeZones(info); return info; }; $D.i18n = { __: function (key, lang) { return __(key, lang); }, currentLanguage: function () { return lang || "en-US"; }, setLanguage: function (code, force, cb) { var async = false; if (force || code === "en-US" || (!!Date.CultureStrings && !!Date.CultureStrings[code])) { lang = code; Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings.lang = code; Date.CultureInfo = new CultureInfo(); } else { if (!(!!Date.CultureStrings && !!Date.CultureStrings[code])) { if (typeof exports !== "undefined" && this.exports !== exports) { // we're in a Node enviroment, load it using require try { require("../i18n/" + code + ".js"); lang = code; Date.CultureStrings.lang = code; Date.CultureInfo = new CultureInfo(); } catch (e) { // var str = "The language for '" + code + "' could not be loaded by Node. It likely does not exist."; throw new Error("The DateJS IETF language tag '" + code + "' could not be loaded by Node. It likely does not exist."); } } else if (Date.Config && Date.Config.i18n) { // we know the location of the files, so lets load them async = true; loadI18nScript(code).done(function(){ lang = code; Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings.lang = code; Date.CultureInfo = new CultureInfo(); $D.Parsing.Normalizer.buildReplaceData(); // because this is async if ($D.Grammar) { $D.Grammar.buildGrammarFormats(); // so we can parse those strings... } if (cb) { setTimeout(cb,0); } }); } else { Date.console.error("The DateJS IETF language tag '" + code + "' is not available and has not been loaded."); return false; } } } $D.Parsing.Normalizer.buildReplaceData(); // rebuild normalizer strings if ($D.Grammar) { $D.Grammar.buildGrammarFormats(); // so we can parse those strings... } if (!async && cb) { setTimeout(cb,0); } }, getLoggedKeys: function () { return loggedKeys; }, updateCultureInfo: function () { Date.CultureInfo = new CultureInfo(); } }; $D.i18n.updateCultureInfo(); // run automatically }()); (function () { var $D = Date, $P = $D.prototype, p = function (s, l) { if (!l) { l = 2; } return ("000" + s).slice(l * -1); }; if (typeof window !== "undefined" && typeof window.console !== "undefined" && typeof window.console.log !== "undefined") { $D.console = console; // used only to raise non-critical errors if available } else { // set mock so we don't give errors. $D.console = { log: function(){}, error: function(){} }; } $D.Config = $D.Config || {}; $D.initOverloads = function() { /** * Overload of Date.now. Allows an alternate call for Date.now where it returns the * current Date as an object rather than just milliseconds since the Unix Epoch. * * Also provides an implementation of now() for browsers (IE<9) that don't have it. * * Backwards compatible so with work with either: * Date.now() [returns ms] * or * Date.now(true) [returns Date] */ if (!$D.now) { $D._now = function now() { return new Date().getTime(); }; } else if (!$D._now) { $D._now = $D.now; } $D.now = function (returnObj) { if (returnObj) { return $D.present(); } else { return $D._now(); } }; if ( !$P.toISOString ) { $P.toISOString = function() { return this.getUTCFullYear() + "-" + p(this.getUTCMonth() + 1) + "-" + p(this.getUTCDate()) + "T" + p(this.getUTCHours()) + ":" + p(this.getUTCMinutes()) + ":" + p(this.getUTCSeconds()) + "." + String( (this.getUTCMilliseconds()/1000).toFixed(3)).slice(2, 5) + "Z"; }; } // private if ( $P._toString === undefined ){ $P._toString = $P.toString; } }; $D.initOverloads(); /** * Gets a date that is set to the current date. The time is set to the start of the day (00:00 or 12:00 AM). * @return {Date} The current date. */ $D.today = function () { return new Date().clearTime(); }; /** * Gets a date that is set to the current date and time (same as new Date, but chainable) * @return {Date} The current date. */ $D.present = function () { return new Date(); }; /** * Compares the first date to the second date and returns an number indication of their relative values. * @param {Date} First Date object to compare [Required]. * @param {Date} Second Date object to compare to [Required]. * @return {Number} -1 = date1 is lessthan date2. 0 = values are equal. 1 = date1 is greaterthan date2. */ $D.compare = function (date1, date2) { if (isNaN(date1) || isNaN(date2)) { throw new Error(date1 + " - " + date2); } else if (date1 instanceof Date && date2 instanceof Date) { return (date1 < date2) ? -1 : (date1 > date2) ? 1 : 0; } else { throw new TypeError(date1 + " - " + date2); } }; /** * Compares the first Date object to the second Date object and returns true if they are equal. * @param {Date} First Date object to compare [Required] * @param {Date} Second Date object to compare to [Required] * @return {Boolean} true if dates are equal. false if they are not equal. */ $D.equals = function (date1, date2) { return (date1.compareTo(date2) === 0); }; /** * Gets the language appropriate day name when given the day number(0-6) * eg - 0 == Sunday * @return {String} The day name */ $D.getDayName = function (n) { return Date.CultureInfo.dayNames[n]; }; /** * Gets the day number (0-6) if given a CultureInfo specific string which is a valid dayName, abbreviatedDayName or shortestDayName (two char). * @param {String} The name of the day (eg. "Monday, "Mon", "tuesday", "tue", "We", "we"). * @return {Number} The day number */ $D.getDayNumberFromName = function (name) { var n = Date.CultureInfo.dayNames, m = Date.CultureInfo.abbreviatedDayNames, o = Date.CultureInfo.shortestDayNames, s = name.toLowerCase(); for (var i = 0; i < n.length; i++) { if (n[i].toLowerCase() === s || m[i].toLowerCase() === s || o[i].toLowerCase() === s) { return i; } } return -1; }; /** * Gets the month number (0-11) if given a Culture Info specific string which is a valid monthName or abbreviatedMonthName. * @param {String} The name of the month (eg. "February, "Feb", "october", "oct"). * @return {Number} The day number */ $D.getMonthNumberFromName = function (name) { var n = Date.CultureInfo.monthNames, m = Date.CultureInfo.abbreviatedMonthNames, s = name.toLowerCase(); for (var i = 0; i < n.length; i++) { if (n[i].toLowerCase() === s || m[i].toLowerCase() === s) { return i; } } return -1; }; /** * Gets the language appropriate month name when given the month number(0-11) * eg - 0 == January * @return {String} The month name */ $D.getMonthName = function (n) { return Date.CultureInfo.monthNames[n]; }; /** * Determines if the current date instance is within a LeapYear. * @param {Number} The year. * @return {Boolean} true if date is within a LeapYear, otherwise false. */ $D.isLeapYear = function (year) { return ((year % 4 === 0 && year % 100 !== 0) || year % 400 === 0); }; /** * Gets the number of days in the month, given a year and month value. Automatically corrects for LeapYear. * @param {Number} The year. * @param {Number} The month (0-11). * @return {Number} The number of days in the month. */ $D.getDaysInMonth = function (year, month) { if (!month && $D.validateMonth(year)) { month = year; year = Date.today().getFullYear(); } return [31, ($D.isLeapYear(year) ? 29 : 28), 31, 30, 31, 30, 31, 31, 30, 31, 30, 31][month]; }; $P.getDaysInMonth = function () { return $D.getDaysInMonth(this.getFullYear(), this.getMonth()); }; $D.getTimezoneAbbreviation = function (offset, dst) { var p, n = (dst || false) ? Date.CultureInfo.abbreviatedTimeZoneDST : Date.CultureInfo.abbreviatedTimeZoneStandard; for (p in n) { if (n.hasOwnProperty(p)) { if (n[p] === offset) { return p; } } } return null; }; $D.getTimezoneOffset = function (name, dst) { var i, a =[], z = Date.CultureInfo.timezones; if (!name) { name = (new Date()).getTimezone();} for (i = 0; i < z.length; i++) { if (z[i].name === name.toUpperCase()) { a.push(i); } } if (!z[a[0]]) { return null; } if (a.length === 1 || !dst) { return z[a[0]].offset; } else { for (i=0; i < a.length; i++) { if (z[a[i]].dst) { return z[a[i]].offset; } } } }; $D.getQuarter = function (d) { d = d || new Date(); // If no date supplied, use today var q = [1,2,3,4]; return q[Math.floor(d.getMonth() / 3)]; // ~~~ is a bitwise op. Faster than Math.floor }; $D.getDaysLeftInQuarter = function (d) { d = d || new Date(); var qEnd = new Date(d); qEnd.setMonth(qEnd.getMonth() + 3 - qEnd.getMonth() % 3, 0); return Math.floor((qEnd - d) / 8.64e7); }; // private var validate = function (n, min, max, name) { name = name ? name : "Object"; if (typeof n === "undefined") { return false; } else if (typeof n !== "number") { throw new TypeError(n + " is not a Number."); } else if (n < min || n > max) { // As failing validation is *not* an exceptional circumstance // lets not throw a RangeError Exception here. // It's semantically correct but it's not sensible. return false; } return true; }; /** * Validates the number is within an acceptable range for milliseconds [0-999]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateMillisecond = function (value) { return validate(value, 0, 999, "millisecond"); }; /** * Validates the number is within an acceptable range for seconds [0-59]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateSecond = function (value) { return validate(value, 0, 59, "second"); }; /** * Validates the number is within an acceptable range for minutes [0-59]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateMinute = function (value) { return validate(value, 0, 59, "minute"); }; /** * Validates the number is within an acceptable range for hours [0-23]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateHour = function (value) { return validate(value, 0, 23, "hour"); }; /** * Validates the number is within an acceptable range for the days in a month [0-MaxDaysInMonth]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateDay = function (value, year, month) { if (year === undefined || year === null || month === undefined || month === null) { return false;} return validate(value, 1, $D.getDaysInMonth(year, month), "day"); }; /** * Validates the number is within an acceptable range for months [0-11]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateWeek = function (value) { return validate(value, 0, 53, "week"); }; /** * Validates the number is within an acceptable range for months [0-11]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateMonth = function (value) { return validate(value, 0, 11, "month"); }; /** * Validates the number is within an acceptable range for years. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateYear = function (value) { /** * Per ECMAScript spec the range of times supported by Date objects is * exactly -100,000,000 days to +100,000,000 days measured relative to * midnight at the beginning of 01 January, 1970 UTC. * This gives a range of 8,640,000,000,000,000 milliseconds to either * side of 01 January, 1970 UTC. * * Earliest possible date: Tue, 20 Apr 271,822 B.C. 00:00:00 UTC * Latest possible date: Sat, 13 Sep 275,760 00:00:00 UTC */ return validate(value, -271822, 275760, "year"); }; $D.validateTimezone = function(value) { var timezones = {"ACDT":1,"ACST":1,"ACT":1,"ADT":1,"AEDT":1,"AEST":1,"AFT":1,"AKDT":1,"AKST":1,"AMST":1,"AMT":1,"ART":1,"AST":1,"AWDT":1,"AWST":1,"AZOST":1,"AZT":1,"BDT":1,"BIOT":1,"BIT":1,"BOT":1,"BRT":1,"BST":1,"BTT":1,"CAT":1,"CCT":1,"CDT":1,"CEDT":1,"CEST":1,"CET":1,"CHADT":1,"CHAST":1,"CHOT":1,"ChST":1,"CHUT":1,"CIST":1,"CIT":1,"CKT":1,"CLST":1,"CLT":1,"COST":1,"COT":1,"CST":1,"CT":1,"CVT":1,"CWST":1,"CXT":1,"DAVT":1,"DDUT":1,"DFT":1,"EASST":1,"EAST":1,"EAT":1,"ECT":1,"EDT":1,"EEDT":1,"EEST":1,"EET":1,"EGST":1,"EGT":1,"EIT":1,"EST":1,"FET":1,"FJT":1,"FKST":1,"FKT":1,"FNT":1,"GALT":1,"GAMT":1,"GET":1,"GFT":1,"GILT":1,"GIT":1,"GMT":1,"GST":1,"GYT":1,"HADT":1,"HAEC":1,"HAST":1,"HKT":1,"HMT":1,"HOVT":1,"HST":1,"ICT":1,"IDT":1,"IOT":1,"IRDT":1,"IRKT":1,"IRST":1,"IST":1,"JST":1,"KGT":1,"KOST":1,"KRAT":1,"KST":1,"LHST":1,"LINT":1,"MAGT":1,"MART":1,"MAWT":1,"MDT":1,"MET":1,"MEST":1,"MHT":1,"MIST":1,"MIT":1,"MMT":1,"MSK":1,"MST":1,"MUT":1,"MVT":1,"MYT":1,"NCT":1,"NDT":1,"NFT":1,"NPT":1,"NST":1,"NT":1,"NUT":1,"NZDT":1,"NZST":1,"OMST":1,"ORAT":1,"PDT":1,"PET":1,"PETT":1,"PGT":1,"PHOT":1,"PHT":1,"PKT":1,"PMDT":1,"PMST":1,"PONT":1,"PST":1,"PYST":1,"PYT":1,"RET":1,"ROTT":1,"SAKT":1,"SAMT":1,"SAST":1,"SBT":1,"SCT":1,"SGT":1,"SLST":1,"SRT":1,"SST":1,"SYOT":1,"TAHT":1,"THA":1,"TFT":1,"TJT":1,"TKT":1,"TLT":1,"TMT":1,"TOT":1,"TVT":1,"UCT":1,"ULAT":1,"UTC":1,"UYST":1,"UYT":1,"UZT":1,"VET":1,"VLAT":1,"VOLT":1,"VOST":1,"VUT":1,"WAKT":1,"WAST":1,"WAT":1,"WEDT":1,"WEST":1,"WET":1,"WST":1,"YAKT":1,"YEKT":1,"Z":1}; return (timezones[value] === 1); }; $D.validateTimezoneOffset= function(value) { // timezones go from +14hrs to -12hrs, the +X hours are negative offsets. return (value > -841 && value < 721); }; }()); (function () { var $D = Date, $P = $D.prototype, p = function (s, l) { if (!l) { l = 2; } return ("000" + s).slice(l * -1); }; var validateConfigObject = function (obj) { var result = {}, self = this, prop, testFunc; testFunc = function (prop, func, value) { if (prop === "day") { var month = (obj.month !== undefined) ? obj.month : self.getMonth(); var year = (obj.year !== undefined) ? obj.year : self.getFullYear(); return $D[func](value, year, month); } else { return $D[func](value); } }; for (prop in obj) { if (Object.prototype.hasOwnProperty.call(obj, prop)) { var func = "validate" + prop.charAt(0).toUpperCase() + prop.slice(1); if ($D[func] && obj[prop] !== null && testFunc(prop, func, obj[prop])) { result[prop] = obj[prop]; } } } return result; }; /** * Resets the time of this Date object to 12:00 AM (00:00), which is the start of the day. * @param {Boolean} .clone() this date instance before clearing Time * @return {Date} this */ $P.clearTime = function () { this.setHours(0); this.setMinutes(0); this.setSeconds(0); this.setMilliseconds(0); return this; }; /** * Resets the time of this Date object to the current time ('now'). * @return {Date} this */ $P.setTimeToNow = function () { var n = new Date(); this.setHours(n.getHours()); this.setMinutes(n.getMinutes()); this.setSeconds(n.getSeconds()); this.setMilliseconds(n.getMilliseconds()); return this; }; /** * Returns a new Date object that is an exact date and time copy of the original instance. * @return {Date} A new Date instance */ $P.clone = function () { return new Date(this.getTime()); }; /** * Compares this instance to a Date object and returns an number indication of their relative values. * @param {Date} Date object to compare [Required] * @return {Number} -1 = this is lessthan date. 0 = values are equal. 1 = this is greaterthan date. */ $P.compareTo = function (date) { return Date.compare(this, date); }; /** * Compares this instance to another Date object and returns true if they are equal. * @param {Date} Date object to compare. If no date to compare, new Date() [now] is used. * @return {Boolean} true if dates are equal. false if they are not equal. */ $P.equals = function (date) { return Date.equals(this, (date !== undefined ? date : new Date())); }; /** * Determines if this instance is between a range of two dates or equal to either the start or end dates. * @param {Date} Start of range [Required] * @param {Date} End of range [Required] * @return {Boolean} true is this is between or equal to the start and end dates, else false */ $P.between = function (start, end) { return this.getTime() >= start.getTime() && this.getTime() <= end.getTime(); }; /** * Determines if this date occurs after the date to compare to. * @param {Date} Date object to compare. If no date to compare, new Date() ("now") is used. * @return {Boolean} true if this date instance is greater than the date to compare to (or "now"), otherwise false. */ $P.isAfter = function (date) { return this.compareTo(date || new Date()) === 1; }; /** * Determines if this date occurs before the date to compare to. * @param {Date} Date object to compare. If no date to compare, new Date() ("now") is used. * @return {Boolean} true if this date instance is less than the date to compare to (or "now"). */ $P.isBefore = function (date) { return (this.compareTo(date || new Date()) === -1); }; /** * Determines if the current Date instance occurs today. * @return {Boolean} true if this date instance is 'today', otherwise false. */ /** * Determines if the current Date instance occurs on the same Date as the supplied 'date'. * If no 'date' to compare to is provided, the current Date instance is compared to 'today'. * @param {date} Date object to compare. If no date to compare, the current Date ("now") is used. * @return {Boolean} true if this Date instance occurs on the same Day as the supplied 'date'. */ $P.isToday = $P.isSameDay = function (date) { return this.clone().clearTime().equals((date || new Date()).clone().clearTime()); }; /** * Adds the specified number of milliseconds to this instance. * @param {Number} The number of milliseconds to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addMilliseconds = function (value) { if (!value) { return this; } this.setTime(this.getTime() + value * 1); return this; }; /** * Adds the specified number of seconds to this instance. * @param {Number} The number of seconds to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addSeconds = function (value) { if (!value) { return this; } return this.addMilliseconds(value * 1000); }; /** * Adds the specified number of seconds to this instance. * @param {Number} The number of seconds to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addMinutes = function (value) { if (!value) { return this; } return this.addMilliseconds(value * 60000); // 60*1000 }; /** * Adds the specified number of hours to this instance. * @param {Number} The number of hours to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addHours = function (value) { if (!value) { return this; } return this.addMilliseconds(value * 3600000); // 60*60*1000 }; /** * Adds the specified number of days to this instance. * @param {Number} The number of days to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addDays = function (value) { if (!value) { return this; } this.setDate(this.getDate() + value * 1); return this; }; /** * Adds the specified number of weekdays (ie - not sat or sun) to this instance. * @param {Number} The number of days to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addWeekdays = function (value) { if (!value) { return this; } var day = this.getDay(); var weeks = (Math.ceil(Math.abs(value)/7)); if (day === 0 || day === 6) { if (value > 0) { this.next().monday(); this.addDays(-1); day = this.getDay(); } } if (value < 0) { while (value < 0) { this.addDays(-1); day = this.getDay(); if (day !== 0 && day !== 6) { value++; } } return this; } else if (value > 5 || (6-day) <= value) { value = value + (weeks * 2); } return this.addDays(value); }; /** * Adds the specified number of weeks to this instance. * @param {Number} The number of weeks to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addWeeks = function (value) { if (!value) { return this; } return this.addDays(value * 7); }; /** * Adds the specified number of months to this instance. * @param {Number} The number of months to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addMonths = function (value) { if (!value) { return this; } var n = this.getDate(); this.setDate(1); this.setMonth(this.getMonth() + value * 1); this.setDate(Math.min(n, $D.getDaysInMonth(this.getFullYear(), this.getMonth()))); return this; }; $P.addQuarters = function (value) { if (!value) { return this; } // note this will take you to the same point in the quarter as you are now. // i.e. - if you are 15 days into the quarter you'll be 15 days into the resulting one. // bonus: this allows adding fractional quarters return this.addMonths(value * 3); }; /** * Adds the specified number of years to this instance. * @param {Number} The number of years to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addYears = function (value) { if (!value) { return this; } return this.addMonths(value * 12); }; /** * Adds (or subtracts) to the value of the years, months, weeks, days, hours, minutes, seconds, milliseconds of the date instance using given configuration object. Positive and Negative values allowed. * Example

	Date.today().add( { days: 1, months: 1 } )

	new Date().add( { years: -1 } )
	
* @param {Object} Configuration object containing attributes (months, days, etc.) * @return {Date} this */ $P.add = function (config) { if (typeof config === "number") { this._orient = config; return this; } var x = config; if (x.day) { // If we should be a different date than today (eg: for 'tomorrow -1d', etc). // Should only effect parsing, not direct usage (eg, Finish and FinishExact) if ((x.day - this.getDate()) !== 0) { this.setDate(x.day); } } if (x.milliseconds) { this.addMilliseconds(x.milliseconds); } if (x.seconds) { this.addSeconds(x.seconds); } if (x.minutes) { this.addMinutes(x.minutes); } if (x.hours) { this.addHours(x.hours); } if (x.weeks) { this.addWeeks(x.weeks); } if (x.months) { this.addMonths(x.months); } if (x.years) { this.addYears(x.years); } if (x.days) { this.addDays(x.days); } return this; }; /** * Get the week number. Week one (1) is the week which contains the first Thursday of the year. Monday is considered the first day of the week. * The .getWeek() function does NOT convert the date to UTC. The local datetime is used. * Please use .getISOWeek() to get the week of the UTC converted date. * @return {Number} 1 to 53 */ $P.getWeek = function (utc) { // Create a copy of this date object var self, target = new Date(this.valueOf()); if (utc) { target.addMinutes(target.getTimezoneOffset()); self = target.clone(); } else { self = this; } // ISO week date weeks start on monday // so correct the day number var dayNr = (self.getDay() + 6) % 7; // ISO 8601 states that week 1 is the week // with the first thursday of that year. // Set the target date to the thursday in the target week target.setDate(target.getDate() - dayNr + 3); // Store the millisecond value of the target date var firstThursday = target.valueOf(); // Set the target to the first thursday of the year // First set the target to january first target.setMonth(0, 1); // Not a thursday? Correct the date to the next thursday if (target.getDay() !== 4) { target.setMonth(0, 1 + ((4 - target.getDay()) + 7) % 7); } // The weeknumber is the number of weeks between the // first thursday of the year and the thursday in the target week return 1 + Math.ceil((firstThursday - target) / 604800000); // 604800000 = 7 * 24 * 3600 * 1000 }; /** * Get the ISO 8601 week number. Week one ("01") is the week which contains the first Thursday of the year. Monday is considered the first day of the week. * The .getISOWeek() function does convert the date to it's UTC value. Please use .getWeek() to get the week of the local date. * @return {String} "01" to "53" */ $P.getISOWeek = function () { return p(this.getWeek(true)); }; /** * Moves the date to Monday of the week set. Week one (1) is the week which contains the first Thursday of the year. * @param {Number} A Number (1 to 53) that represents the week of the year. * @return {Date} this */ $P.setWeek = function (n) { if ((n - this.getWeek()) === 0) { if (this.getDay() !== 1) { return this.moveToDayOfWeek(1, (this.getDay() > 1 ? -1 : 1)); } else { return this; } } else { return this.moveToDayOfWeek(1, (this.getDay() > 1 ? -1 : 1)).addWeeks(n - this.getWeek()); } }; $P.setQuarter = function (qtr) { var month = Math.abs(((qtr-1) * 3) + 1); return this.setMonth(month, 1); }; $P.getQuarter = function () { return Date.getQuarter(this); }; $P.getDaysLeftInQuarter = function () { return Date.getDaysLeftInQuarter(this); }; /** * Moves the date to the next n'th occurrence of the dayOfWeek starting from the beginning of the month. The number (-1) is a magic number and will return the last occurrence of the dayOfWeek in the month. * @param {Number} The dayOfWeek to move to * @param {Number} The n'th occurrence to move to. Use (-1) to return the last occurrence in the month * @return {Date} this */ $P.moveToNthOccurrence = function (dayOfWeek, occurrence) { if (dayOfWeek === "Weekday") { if (occurrence > 0) { this.moveToFirstDayOfMonth(); if (this.is().weekday()) { occurrence -= 1; } } else if (occurrence < 0) { this.moveToLastDayOfMonth(); if (this.is().weekday()) { occurrence += 1; } } else { return this; } return this.addWeekdays(occurrence); } var shift = 0; if (occurrence > 0) { shift = occurrence - 1; } else if (occurrence === -1) { this.moveToLastDayOfMonth(); if (this.getDay() !== dayOfWeek) { this.moveToDayOfWeek(dayOfWeek, -1); } return this; } return this.moveToFirstDayOfMonth().addDays(-1).moveToDayOfWeek(dayOfWeek, +1).addWeeks(shift); }; var moveToN = function (getFunc, addFunc, nVal) { return function (value, orient) { var diff = (value - this[getFunc]() + nVal * (orient || +1)) % nVal; return this[addFunc]((diff === 0) ? diff += nVal * (orient || +1) : diff); }; }; /** * Move to the next or last dayOfWeek based on the orient value. * @param {Number} The dayOfWeek to move to * @param {Number} Forward (+1) or Back (-1). Defaults to +1. [Optional] * @return {Date} this */ $P.moveToDayOfWeek = moveToN("getDay", "addDays", 7); /** * Move to the next or last month based on the orient value. * @param {Number} The month to move to. 0 = January, 11 = December * @param {Number} Forward (+1) or Back (-1). Defaults to +1. [Optional] * @return {Date} this */ $P.moveToMonth = moveToN("getMonth", "addMonths", 12); /** * Get the Ordinate of the current day ("th", "st", "rd"). * @return {String} */ $P.getOrdinate = function () { var num = this.getDate(); return ord(num); }; /** * Get the Ordinal day (numeric day number) of the year, adjusted for leap year. * @return {Number} 1 through 365 (366 in leap years) */ $P.getOrdinalNumber = function () { return Math.ceil((this.clone().clearTime() - new Date(this.getFullYear(), 0, 1)) / 86400000) + 1; }; /** * Get the time zone abbreviation of the current date. * @return {String} The abbreviated time zone name (e.g. "EST") */ $P.getTimezone = function () { return $D.getTimezoneAbbreviation(this.getUTCOffset(), this.isDaylightSavingTime()); }; $P.setTimezoneOffset = function (offset) { var here = this.getTimezoneOffset(), there = Number(offset) * -6 / 10; return (there || there === 0) ? this.addMinutes(there - here) : this; }; $P.setTimezone = function (offset) { return this.setTimezoneOffset($D.getTimezoneOffset(offset)); }; /** * Indicates whether Daylight Saving Time is observed in the current time zone. * @return {Boolean} true|false */ $P.hasDaylightSavingTime = function () { return (Date.today().set({month: 0, day: 1}).getTimezoneOffset() !== Date.today().set({month: 6, day: 1}).getTimezoneOffset()); }; /** * Indicates whether this Date instance is within the Daylight Saving Time range for the current time zone. * @return {Boolean} true|false */ $P.isDaylightSavingTime = function () { return Date.today().set({month: 0, day: 1}).getTimezoneOffset() !== this.getTimezoneOffset(); }; /** * Get the offset from UTC of the current date. * @return {String} The 4-character offset string prefixed with + or - (e.g. "-0500") */ $P.getUTCOffset = function (offset) { var n = (offset || this.getTimezoneOffset()) * -10 / 6, r; if (n < 0) { r = (n - 10000).toString(); return r.charAt(0) + r.substr(2); } else { r = (n + 10000).toString(); return "+" + r.substr(1); } }; /** * Returns the number of milliseconds between this date and date. * @param {Date} Defaults to now * @return {Number} The diff in milliseconds */ $P.getElapsed = function (date) { return (date || new Date()) - this; }; /** * Set the value of year, month, day, hour, minute, second, millisecond of date instance using given configuration object. * Example

	Date.today().set( { day: 20, month: 1 } )

	new Date().set( { millisecond: 0 } )
	
* * @param {Object} Configuration object containing attributes (month, day, etc.) * @return {Date} this */ $P.set = function (config) { config = validateConfigObject.call(this, config); var key; for (key in config) { if (Object.prototype.hasOwnProperty.call(config, key)) { var name = key.charAt(0).toUpperCase() + key.slice(1); var addFunc, getFunc; if (key !== "week" && key !== "month" && key !== "timezone" && key !== "timezoneOffset") { name += "s"; } addFunc = "add" + name; getFunc = "get" + name; if (key === "month") { addFunc = addFunc + "s"; } else if (key === "year"){ getFunc = "getFullYear"; } if (key !== "day" && key !== "timezone" && key !== "timezoneOffset" && key !== "week" && key !== "hour") { this[addFunc](config[key] - this[getFunc]()); } else if ( key === "timezone"|| key === "timezoneOffset" || key === "week" || key === "hour") { this["set"+name](config[key]); } } } // day has to go last because you can't validate the day without first knowing the month if (config.day) { this.addDays(config.day - this.getDate()); } return this; }; /** * Moves the date to the first day of the month. * @return {Date} this */ $P.moveToFirstDayOfMonth = function () { return this.set({ day: 1 }); }; /** * Moves the date to the last day of the month. * @return {Date} this */ $P.moveToLastDayOfMonth = function () { return this.set({ day: $D.getDaysInMonth(this.getFullYear(), this.getMonth())}); }; /** * Converts the value of the current Date object to its equivalent string representation. * Format Specifiers * CUSTOM DATE AND TIME FORMAT STRINGS * Format Description Example * ------ --------------------------------------------------------------------------- ----------------------- * s The seconds of the minute between 0-59. "0" to "59" * ss The seconds of the minute with leading zero if required. "00" to "59" * * m The minute of the hour between 0-59. "0" or "59" * mm The minute of the hour with leading zero if required. "00" or "59" * * h The hour of the day between 1-12. "1" to "12" * hh The hour of the day with leading zero if required. "01" to "12" * * H The hour of the day between 0-23. "0" to "23" * HH The hour of the day with leading zero if required. "00" to "23" * * d The day of the month between 1 and 31. "1" to "31" * dd The day of the month with leading zero if required. "01" to "31" * ddd Abbreviated day name. Date.CultureInfo.abbreviatedDayNames. "Mon" to "Sun" * dddd The full day name. Date.CultureInfo.dayNames. "Monday" to "Sunday" * * M The month of the year between 1-12. "1" to "12" * MM The month of the year with leading zero if required. "01" to "12" * MMM Abbreviated month name. Date.CultureInfo.abbreviatedMonthNames. "Jan" to "Dec" * MMMM The full month name. Date.CultureInfo.monthNames. "January" to "December" * * yy The year as a two-digit number. "99" or "08" * yyyy The full four digit year. "1999" or "2008" * * t Displays the first character of the A.M./P.M. designator. "A" or "P" * Date.CultureInfo.amDesignator or Date.CultureInfo.pmDesignator * tt Displays the A.M./P.M. designator. "AM" or "PM" * Date.CultureInfo.amDesignator or Date.CultureInfo.pmDesignator * * S The ordinal suffix ("st, "nd", "rd" or "th") of the current day. "st, "nd", "rd" or "th" * * STANDARD DATE AND TIME FORMAT STRINGS * Format Description Example *------ --------------------------------------------------------------------------- ----------------------- * d The CultureInfo shortDate Format Pattern "M/d/yyyy" * D The CultureInfo longDate Format Pattern "dddd, MMMM dd, yyyy" * F The CultureInfo fullDateTime Format Pattern "dddd, MMMM dd, yyyy h:mm:ss tt" * m The CultureInfo monthDay Format Pattern "MMMM dd" * r The CultureInfo rfc1123 Format Pattern "ddd, dd MMM yyyy HH:mm:ss GMT" * s The CultureInfo sortableDateTime Format Pattern "yyyy-MM-ddTHH:mm:ss" * t The CultureInfo shortTime Format Pattern "h:mm tt" * T The CultureInfo longTime Format Pattern "h:mm:ss tt" * u The CultureInfo universalSortableDateTime Format Pattern "yyyy-MM-dd HH:mm:ssZ" * y The CultureInfo yearMonth Format Pattern "MMMM, yyyy" * * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @return {String} A string representation of the current Date object. */ var ord = function (n) { switch (n * 1) { case 1: case 21: case 31: return "st"; case 2: case 22: return "nd"; case 3: case 23: return "rd"; default: return "th"; } }; var parseStandardFormats = function (format) { var y, c = Date.CultureInfo.formatPatterns; switch (format) { case "d": return this.toString(c.shortDate); case "D": return this.toString(c.longDate); case "F": return this.toString(c.fullDateTime); case "m": return this.toString(c.monthDay); case "r": case "R": y = this.clone().addMinutes(this.getTimezoneOffset()); return y.toString(c.rfc1123) + " GMT"; case "s": return this.toString(c.sortableDateTime); case "t": return this.toString(c.shortTime); case "T": return this.toString(c.longTime); case "u": y = this.clone().addMinutes(this.getTimezoneOffset()); return y.toString(c.universalSortableDateTime); case "y": return this.toString(c.yearMonth); default: return false; } }; var parseFormatStringsClosure = function (context) { return function (m) { if (m.charAt(0) === "\\") { return m.replace("\\", ""); } switch (m) { case "hh": return p(context.getHours() < 13 ? (context.getHours() === 0 ? 12 : context.getHours()) : (context.getHours() - 12)); case "h": return context.getHours() < 13 ? (context.getHours() === 0 ? 12 : context.getHours()) : (context.getHours() - 12); case "HH": return p(context.getHours()); case "H": return context.getHours(); case "mm": return p(context.getMinutes()); case "m": return context.getMinutes(); case "ss": return p(context.getSeconds()); case "s": return context.getSeconds(); case "yyyy": return p(context.getFullYear(), 4); case "yy": return p(context.getFullYear()); case "y": return context.getFullYear(); case "E": case "dddd": return Date.CultureInfo.dayNames[context.getDay()]; case "ddd": return Date.CultureInfo.abbreviatedDayNames[context.getDay()]; case "dd": return p(context.getDate()); case "d": return context.getDate(); case "MMMM": return Date.CultureInfo.monthNames[context.getMonth()]; case "MMM": return Date.CultureInfo.abbreviatedMonthNames[context.getMonth()]; case "MM": return p((context.getMonth() + 1)); case "M": return context.getMonth() + 1; case "t": return context.getHours() < 12 ? Date.CultureInfo.amDesignator.substring(0, 1) : Date.CultureInfo.pmDesignator.substring(0, 1); case "tt": return context.getHours() < 12 ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator; case "S": return ord(context.getDate()); case "W": return context.getWeek(); case "WW": return context.getISOWeek(); case "Q": return "Q" + context.getQuarter(); case "q": return String(context.getQuarter()); case "z": return context.getTimezone(); case "Z": case "X": return Date.getTimezoneOffset(context.getTimezone()); case "ZZ": // Timezone offset in seconds return context.getTimezoneOffset() * -60; case "u": return context.getDay(); case "L": return ($D.isLeapYear(context.getFullYear())) ? 1 : 0; case "B": // Swatch Internet Time (.beats) return "@"+((context.getUTCSeconds() + (context.getUTCMinutes()*60) + ((context.getUTCHours()+1)*3600))/86.4); default: return m; } }; }; $P.toString = function (format, ignoreStandards) { // Standard Date and Time Format Strings. Formats pulled from CultureInfo file and // may vary by culture. if (!ignoreStandards && format && format.length === 1) { output = parseStandardFormats.call(this, format); if (output) { return output; } } var parseFormatStrings = parseFormatStringsClosure(this); return format ? format.replace(/((\\)?(dd?d?d?|MM?M?M?|yy?y?y?|hh?|HH?|mm?|ss?|tt?|S|q|Q|WW?W?W?)(?![^\[]*\]))/g, parseFormatStrings).replace(/\[|\]/g, "") : this._toString(); }; }()); /************************************************************* * SugarPak - Domain Specific Language - Syntactical Sugar * *************************************************************/ (function () { var $D = Date, $P = $D.prototype, $N = Number.prototype; // private $P._orient = +1; // private $P._nth = null; // private $P._is = false; // private $P._same = false; // private $P._isSecond = false; // private $N._dateElement = "days"; /** * Moves the date to the next instance of a date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.today().next().friday();
	Date.today().next().fri();
	Date.today().next().march();
	Date.today().next().mar();
	Date.today().next().week();
	
* * @return {Date} date */ $P.next = function () { this._move = true; this._orient = +1; return this; }; /** * Creates a new Date (Date.today()) and moves the date to the next instance of the date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.next().friday();
	Date.next().fri();
	Date.next().march();
	Date.next().mar();
	Date.next().week();
	
* * @return {Date} date */ $D.next = function () { return $D.today().next(); }; /** * Moves the date to the previous instance of a date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.today().last().friday();
	Date.today().last().fri();
	Date.today().last().march();
	Date.today().last().mar();
	Date.today().last().week();
	
* * @return {Date} date */ $P.last = $P.prev = $P.previous = function () { this._move = true; this._orient = -1; return this; }; /** * Creates a new Date (Date.today()) and moves the date to the previous instance of the date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.last().friday();
	Date.last().fri();
	Date.previous().march();
	Date.prev().mar();
	Date.last().week();
	
* * @return {Date} date */ $D.last = $D.prev = $D.previous = function () { return $D.today().last(); }; /** * Performs a equality check when followed by either a month name, day name or .weekday() function. * Example

	Date.today().is().friday(); // true|false
	Date.today().is().fri();
	Date.today().is().march();
	Date.today().is().mar();
	
* * @return {Boolean} true|false */ $P.is = function () { this._is = true; return this; }; /** * Determines if two date objects occur on/in exactly the same instance of the subsequent date part function. * The function .same() must be followed by a date part function (example: .day(), .month(), .year(), etc). * * An optional Date can be passed in the date part function. If now date is passed as a parameter, 'Now' is used. * * The following example demonstrates how to determine if two dates fall on the exact same day. * * Example

	var d1 = Date.today(); // today at 00:00
	var d2 = new Date();   // exactly now.

	// Do they occur on the same day?
	d1.same().day(d2); // true
	
	// Do they occur on the same hour?
	d1.same().hour(d2); // false, unless d2 hour is '00' (midnight).
	
	// What if it's the same day, but one year apart?
	var nextYear = Date.today().add(1).year();

	d1.same().day(nextYear); // false, because the dates must occur on the exact same day. 
	
* * Scenario: Determine if a given date occurs during some week period 2 months from now. * * Example

	var future = Date.today().add(2).months();
	return someDate.same().week(future); // true|false;
	
* * @return {Boolean} true|false */ $P.same = function () { this._same = true; this._isSecond = false; return this; }; /** * Determines if the current date/time occurs during Today. Must be preceded by the .is() function. * Example

	someDate.is().today();    // true|false
	new Date().is().today();  // true
	Date.today().is().today();// true
	Date.today().add(-1).day().is().today(); // false
	
* * @return {Boolean} true|false */ $P.today = function () { return this.same().day(); }; /** * Determines if the current date is a weekday. This function must be preceded by the .is() function. * Example

	Date.today().is().weekday(); // true|false
	
* * @return {Boolean} true|false */ $P.weekday = function () { if (this._nth) { return df("Weekday").call(this); } if (this._move) { return this.addWeekdays(this._orient); } if (this._is) { this._is = false; return (!this.is().sat() && !this.is().sun()); } return false; }; /** * Determines if the current date is on the weekend. This function must be preceded by the .is() function. * Example

	Date.today().is().weekend(); // true|false
	
* * @return {Boolean} true|false */ $P.weekend = function () { if (this._is) { this._is = false; return (this.is().sat() || this.is().sun()); } return false; }; /** * Sets the Time of the current Date instance. A string "6:15 pm" or config object {hour:18, minute:15} are accepted. * Example

	// Set time to 6:15pm with a String
	Date.today().at("6:15pm");

	// Set time to 6:15pm with a config object
	Date.today().at({hour:18, minute:15});
	
* * @return {Date} date */ $P.at = function (time) { return (typeof time === "string") ? $D.parse(this.toString("d") + " " + time) : this.set(time); }; /** * Creates a new Date() and adds this (Number) to the date based on the preceding date element function (eg. second|minute|hour|day|month|year). * Example

	// Undeclared Numbers must be wrapped with parentheses. Requirment of JavaScript.
	(3).days().fromNow();
	(6).months().fromNow();

	// Declared Number variables do not require parentheses. 
	var n = 6;
	n.months().fromNow();
	
* * @return {Date} A new Date instance */ $N.fromNow = $N.after = function (date) { var c = {}; c[this._dateElement] = this; return ((!date) ? new Date() : date.clone()).add(c); }; /** * Creates a new Date() and subtract this (Number) from the date based on the preceding date element function (eg. second|minute|hour|day|month|year). * Example

	// Undeclared Numbers must be wrapped with parentheses. Requirment of JavaScript.
	(3).days().ago();
	(6).months().ago();

	// Declared Number variables do not require parentheses. 
	var n = 6;
	n.months().ago();
	
* * @return {Date} A new Date instance */ $N.ago = $N.before = function (date) { var c = {}, s = (this._dateElement[this._dateElement.length-1] !== "s") ? this._dateElement + "s" : this._dateElement; c[s] = this * -1; return ((!date) ? new Date() : date.clone()).add(c); }; // Do NOT modify the following string tokens. These tokens are used to build dynamic functions. // All culture-specific strings can be found in the CultureInfo files. var dx = ("sunday monday tuesday wednesday thursday friday saturday").split(/\s/), mx = ("january february march april may june july august september october november december").split(/\s/), px = ("Millisecond Second Minute Hour Day Week Month Year Quarter Weekday").split(/\s/), pxf = ("Milliseconds Seconds Minutes Hours Date Week Month FullYear Quarter").split(/\s/), nth = ("final first second third fourth fifth").split(/\s/), de; /** * Returns an object literal of all the date parts. * Example

	var o = new Date().toObject();
	
	// { year: 2008, month: 4, week: 20, day: 13, hour: 18, minute: 9, second: 32, millisecond: 812 }
	
	// The object properties can be referenced directly from the object.
	
	alert(o.day);  // alerts "13"
	alert(o.year); // alerts "2008"
	
* * @return {Date} An object literal representing the original date object. */ $P.toObject = function () { var o = {}; for (var i = 0; i < px.length; i++) { if (this["get" + pxf[i]]) { o[px[i].toLowerCase()] = this["get" + pxf[i]](); } } return o; }; /** * Returns a date created from an object literal. Ignores the .week property if set in the config. * Example

	var o = new Date().toObject();
	
	return Date.fromObject(o); // will return the same date. 

	var o2 = {month: 1, day: 20, hour: 18}; // birthday party!
	Date.fromObject(o2);
	
* * @return {Date} An object literal representing the original date object. */ $D.fromObject = function(config) { config.week = null; return Date.today().set(config); }; // Create day name functions and abbreviated day name functions (eg. monday(), friday(), fri()). var df = function (n) { return function () { if (this._is) { this._is = false; return this.getDay() === n; } if (this._move) { this._move = null; } if (this._nth !== null) { // If the .second() function was called earlier, remove the _orient // from the date, and then continue. // This is required because 'second' can be used in two different context. // // Example // // Date.today().add(1).second(); // Date.march().second().monday(); // // Things get crazy with the following... // Date.march().add(1).second().second().monday(); // but it works!! // if (this._isSecond) { this.addSeconds(this._orient * -1); } // make sure we reset _isSecond this._isSecond = false; var ntemp = this._nth; this._nth = null; var temp = this.clone().moveToLastDayOfMonth(); this.moveToNthOccurrence(n, ntemp); if (this > temp) { throw new RangeError($D.getDayName(n) + " does not occur " + ntemp + " times in the month of " + $D.getMonthName(temp.getMonth()) + " " + temp.getFullYear() + "."); } return this; } return this.moveToDayOfWeek(n, this._orient); }; }; var sdf = function (n) { return function () { var t = $D.today(), shift = n - t.getDay(); if (n === 0 && Date.CultureInfo.firstDayOfWeek === 1 && t.getDay() !== 0) { shift = shift + 7; } return t.addDays(shift); }; }; // Create month name functions and abbreviated month name functions (eg. january(), march(), mar()). var month_instance_functions = function (n) { return function () { if (this._is) { this._is = false; return this.getMonth() === n; } return this.moveToMonth(n, this._orient); }; }; var month_static_functions = function (n) { return function () { return $D.today().set({ month: n, day: 1 }); }; }; var processTerms = function (names, staticFunc, instanceFunc) { for (var i = 0; i < names.length; i++) { // Create constant static Name variables. $D[names[i].toUpperCase()] = $D[names[i].toUpperCase().substring(0, 3)] = i; // Create Name functions. $D[names[i]] = $D[names[i].substring(0, 3)] = staticFunc(i); // Create Name instance functions. $P[names[i]] = $P[names[i].substring(0, 3)] = instanceFunc(i); } }; processTerms(dx, sdf, df); processTerms(mx, month_static_functions, month_instance_functions); // Create date element functions and plural date element functions used with Date (eg. day(), days(), months()). var ef = function (j) { return function () { // if the .second() function was called earlier, the _orient // has alread been added. Just return this and reset _isSecond. if (this._isSecond) { this._isSecond = false; return this; } if (this._same) { this._same = this._is = false; var o1 = this.toObject(), o2 = (arguments[0] || new Date()).toObject(), v = "", k = j.toLowerCase(); // the substr trick with -1 doesn't work in IE8 or less k = (k[k.length-1] === "s") ? k.substring(0,k.length-1) : k; for (var m = (px.length - 1); m > -1; m--) { v = px[m].toLowerCase(); if (o1[v] !== o2[v]) { return false; } if (k === v) { break; } } return true; } if (j.substring(j.length - 1) !== "s") { j += "s"; } if (this._move) { this._move = null; } return this["add" + j](this._orient); }; }; var nf = function (n) { return function () { this._dateElement = n; return this; }; }; for (var k = 0; k < px.length; k++) { de = px[k].toLowerCase(); if(de !== "weekday") { // Create date element functions and plural date element functions used with Date (eg. day(), days(), months()). $P[de] = $P[de + "s"] = ef(px[k]); // Create date element functions and plural date element functions used with Number (eg. day(), days(), months()). $N[de] = $N[de + "s"] = nf(de + "s"); } } $P._ss = ef("Second"); var nthfn = function (n) { return function (dayOfWeek) { if (this._same) { return this._ss(arguments[0]); } if (dayOfWeek || dayOfWeek === 0) { return this.moveToNthOccurrence(dayOfWeek, n); } this._nth = n; // if the operator is 'second' add the _orient, then deal with it later... if (n === 2 && (dayOfWeek === undefined || dayOfWeek === null)) { this._isSecond = true; return this.addSeconds(this._orient); } return this; }; }; for (var l = 0; l < nth.length; l++) { $P[nth[l]] = (l === 0) ? nthfn(-1) : nthfn(l); } }()); (function () { "use strict"; Date.Parsing = { Exception: function (s) { this.message = "Parse error at '" + s.substring(0, 10) + " ...'"; } }; var $P = Date.Parsing; var dayOffsets = { standard: [0,31,59,90,120,151,181,212,243,273,304,334], leap: [0,31,60,91,121,152,182,213,244,274,305,335] }; $P.isLeapYear = function(year) { return ((year % 4 === 0) && (year % 100 !== 0)) || (year % 400 === 0); }; var utils = { multiReplace : function (str, hash ) { var key; for (key in hash) { if (Object.prototype.hasOwnProperty.call(hash, key)) { var regex; if (typeof hash[key] === "function") { } else { regex = (hash[key] instanceof RegExp) ? hash[key] : new RegExp(hash[key], "g"); } str = str.replace(regex, key); } } return str; }, getDayOfYearFromWeek : function (obj) { var d, jan4, offset; obj.weekDay = (!obj.weekDay && obj.weekDay !== 0) ? 1 : obj.weekDay; d = new Date(obj.year, 0, 4); jan4 = d.getDay() === 0 ? 7 : d.getDay(); // JS is 0 indexed on Sunday. offset = jan4+3; obj.dayOfYear = ((obj.week * 7) + (obj.weekDay === 0 ? 7 : obj.weekDay))-offset; return obj; }, getDayOfYear : function (obj, dayOffset) { if (!obj.dayOfYear) { obj = utils.getDayOfYearFromWeek(obj); } for (var i=0;i <= dayOffset.length;i++) { if (obj.dayOfYear < dayOffset[i] || i === dayOffset.length) { obj.day = obj.day ? obj.day : (obj.dayOfYear - dayOffset[i-1]); break; } else { obj.month = i; } } return obj; }, adjustForTimeZone : function (obj, date) { var offset; if (obj.zone.toUpperCase() === "Z" || (obj.zone_hours === 0 && obj.zone_minutes === 0)) { // it's UTC/GML so work out the current timeszone offset offset = -date.getTimezoneOffset(); } else { offset = (obj.zone_hours*60) + (obj.zone_minutes || 0); if (obj.zone_sign === "+") { offset *= -1; } offset -= date.getTimezoneOffset(); } date.setMinutes(date.getMinutes()+offset); return date; }, setDefaults : function (obj) { obj.year = obj.year || Date.today().getFullYear(); obj.hours = obj.hours || 0; obj.minutes = obj.minutes || 0; obj.seconds = obj.seconds || 0; obj.milliseconds = obj.milliseconds || 0; if (!(!obj.month && (obj.week || obj.dayOfYear))) { // if we have a month, or if we don't but don't have the day calculation data obj.month = obj.month || 0; obj.day = obj.day || 1; } return obj; }, dataNum: function (data, mod, explict, postProcess) { var dataNum = data*1; if (mod) { if (postProcess) { return data ? mod(data)*1 : data; } else { return data ? mod(dataNum) : data; } } else if (!explict){ return data ? dataNum : data; } else { return (data && typeof data !== "undefined") ? dataNum : data; } }, timeDataProcess: function (obj) { var timeObj = {}; for (var x in obj.data) { if (obj.data.hasOwnProperty(x)) { timeObj[x] = obj.ignore[x] ? obj.data[x] : utils.dataNum(obj.data[x], obj.mods[x], obj.explict[x], obj.postProcess[x]); } } if (obj.data.secmins) { obj.data.secmins = obj.data.secmins.replace(",", ".") * 60; if (!timeObj.minutes) { timeObj.minutes = obj.data.secmins; } else if (!timeObj.seconds) { timeObj.seconds = obj.data.secmins; } delete obj.secmins; } return timeObj; }, buildTimeObjectFromData: function (data) { var time = utils.timeDataProcess({ data: { year : data[1], month : data[5], day : data[7], week : data[8], dayOfYear : data[10], hours : data[15], zone_hours : data[23], zone_minutes : data[24], zone : data[21], zone_sign : data[22], weekDay : data[9], minutes: data[16], seconds: data[19], milliseconds: data[20], secmins: data[18] }, mods: { month: function(data) { return data-1; }, weekDay: function (data) { data = Math.abs(data); return (data === 7 ? 0 : data); }, minutes: function (data) { return data.replace(":",""); }, seconds: function (data) { return Math.floor( (data.replace(":","").replace(",","."))*1 ); }, milliseconds: function (data) { return (data.replace(",",".")*1000); } }, postProcess: { minutes: true, seconds: true, milliseconds: true }, explict: { zone_hours: true, zone_minutes: true }, ignore: { zone: true, zone_sign: true, secmins: true } }); return time; }, addToHash: function (hash, keys, data) { keys = keys; data = data; var len = keys.length; for (var i = 0; i < len; i++) { hash[keys[i]] = data[i]; } return hash; }, combineRegex: function (r1, r2) { return new RegExp("(("+r1.source+")\\s("+r2.source+"))"); }, getDateNthString: function(add, last, inc){ if (add) { return Date.today().addDays(inc).toString("d"); } else if (last) { return Date.today().last()[inc]().toString("d"); } }, buildRegexData: function (array) { var arr = []; var len = array.length; for (var i=0; i < len; i++) { if (Object.prototype.toString.call(array[i]) === '[object Array]') { // oldIE compat version of Array.isArray arr.push(this.combineRegex(array[i][0], array[i][1])); } else { arr.push(array[i]); } } return arr; } }; $P.processTimeObject = function (obj) { var date, dayOffset; utils.setDefaults(obj); dayOffset = ($P.isLeapYear(obj.year)) ? dayOffsets.leap : dayOffsets.standard; if (!obj.month && (obj.week || obj.dayOfYear)) { utils.getDayOfYear(obj, dayOffset); } else { obj.dayOfYear = dayOffset[obj.month] + obj.day; } date = new Date(obj.year, obj.month, obj.day, obj.hours, obj.minutes, obj.seconds, obj.milliseconds); if (obj.zone) { utils.adjustForTimeZone(obj, date); // adjust (and calculate) for timezone } return date; }; $P.ISO = { regex : /^([\+-]?\d{4}(?!\d{2}\b))((-?)((0[1-9]|1[0-2])(\3([12]\d|0[1-9]|3[01]))?|W([0-4]\d|5[0-3])(-?[1-7])?|(00[1-9]|0[1-9]\d|[12]\d{2}|3([0-5]\d|6[1-6])))([T\s]((([01]\d|2[0-4])((:?)[0-5]\d)?|24\:?00)([\.,]\d+(?!:))?)?(\17[0-5]\d([\.,]\d+)?)?\s?([zZ]|([\+-])([01]\d|2[0-3]):?([0-5]\d)?)?)?)?$/, parse : function (s) { var time, data = s.match(this.regex); if (!data || !data.length) { return null; } time = utils.buildTimeObjectFromData(data); if (!time.year || (!time.year && (!time.month && !time.day) && (!time.week && !time.dayOfYear)) ) { return null; } return $P.processTimeObject(time); } }; $P.Numeric = { isNumeric: function (e){return!isNaN(parseFloat(e))&&isFinite(e);}, regex: /\b([0-1]?[0-9])([0-3]?[0-9])([0-2]?[0-9]?[0-9][0-9])\b/i, parse: function (s) { var data, i, time = {}, order = Date.CultureInfo.dateElementOrder.split(""); if (!(this.isNumeric(s)) || // if it's non-numeric OR (s[0] === "+" && s[0] === "-")) { // It's an arithmatic string (eg +/-1000) return null; } if (s.length < 5 && s.indexOf(".") < 0 && s.indexOf("/") < 0) { // assume it's just a year. time.year = s; return $P.processTimeObject(time); } data = s.match(this.regex); if (!data || !data.length) { return null; } for (i=0; i < order.length; i++) { switch(order[i]) { case "d": time.day = data[i+1]; break; case "m": time.month = (data[i+1]-1); break; case "y": time.year = data[i+1]; break; } } return $P.processTimeObject(time); } }; $P.Normalizer = { regexData: function () { var $R = Date.CultureInfo.regexPatterns; return utils.buildRegexData([ $R.tomorrow, $R.yesterday, [$R.past, $R.mon], [$R.past, $R.tue], [$R.past, $R.wed], [$R.past, $R.thu], [$R.past, $R.fri], [$R.past, $R.sat], [$R.past, $R.sun] ]); }, basicReplaceHash : function() { var $R = Date.CultureInfo.regexPatterns; return { "January": $R.jan.source, "February": $R.feb, "March": $R.mar, "April": $R.apr, "May": $R.may, "June": $R.jun, "July": $R.jul, "August": $R.aug, "September": $R.sep, "October": $R.oct, "November": $R.nov, "December": $R.dec, "": /\bat\b/gi, " ": /\s{2,}/, "am": $R.inTheMorning, "9am": $R.thisMorning, "pm": $R.inTheEvening, "7pm":$R.thisEvening }; }, keys : function(){ return [ utils.getDateNthString(true, false, 1), // tomorrow utils.getDateNthString(true, false, -1), // yesterday utils.getDateNthString(false, true, "monday"), //last mon utils.getDateNthString(false, true, "tuesday"), //last tues utils.getDateNthString(false, true, "wednesday"), //last wed utils.getDateNthString(false, true, "thursday"), //last thurs utils.getDateNthString(false, true, "friday"), //last fri utils.getDateNthString(false, true, "saturday"), //last sat utils.getDateNthString(false, true, "sunday") //last sun ]; }, buildRegexFunctions: function () { var $R = Date.CultureInfo.regexPatterns; var __ = Date.i18n.__; var tomorrowRE = new RegExp("(\\b\\d\\d?("+__("AM")+"|"+__("PM")+")? )("+$R.tomorrow.source.slice(1)+")", "i"); // adapted tomorrow regex for AM PM relative dates var todayRE = new RegExp($R.today.source + "(?!\\s*([+-]))\\b"); // today, but excludes the math operators (eg "today + 2h") this.replaceFuncs = [ [todayRE, function (full) { return (full.length > 1) ? Date.today().toString("d") : full; }], [tomorrowRE, function(full, m1) { var t = Date.today().addDays(1).toString("d"); return (t + " " + m1); }], [$R.amThisMorning, function(str, am){return am;}], [$R.pmThisEvening, function(str, pm){return pm;}] ]; }, buildReplaceData: function () { this.buildRegexFunctions(); this.replaceHash = utils.addToHash(this.basicReplaceHash(), this.keys(), this.regexData()); }, stringReplaceFuncs: function (s) { for (var i=0; i < this.replaceFuncs.length; i++) { s = s.replace(this.replaceFuncs[i][0], this.replaceFuncs[i][1]); } return s; }, parse: function (s) { s = this.stringReplaceFuncs(s); s = utils.multiReplace(s, this.replaceHash); try { var n = s.split(/([\s\-\.\,\/\x27]+)/); if (n.length === 3 && $P.Numeric.isNumeric(n[0]) && $P.Numeric.isNumeric(n[2]) && (n[2].length >= 4)) { // ok, so we're dealing with x/year. But that's not a full date. // This fixes wonky dateElementOrder parsing when set to dmy order. if (Date.CultureInfo.dateElementOrder[0] === "d") { s = "1/" + n[0] + "/" + n[2]; // set to 1st of month and normalize the seperator } } } catch (e) {} return s; } }; $P.Normalizer.buildReplaceData(); }()); (function () { var $P = Date.Parsing; var _ = $P.Operators = { // // Tokenizers // rtoken: function (r) { // regex token return function (s) { var mx = s.match(r); if (mx) { return ([ mx[0], s.substring(mx[0].length) ]); } else { throw new $P.Exception(s); } }; }, token: function () { // whitespace-eating token return function (s) { return _.rtoken(new RegExp("^\\s*" + s + "\\s*"))(s); }; }, stoken: function (s) { // string token return _.rtoken(new RegExp("^" + s)); }, // Atomic Operators until: function (p) { return function (s) { var qx = [], rx = null; while (s.length) { try { rx = p.call(this, s); } catch (e) { qx.push(rx[0]); s = rx[1]; continue; } break; } return [ qx, s ]; }; }, many: function (p) { return function (s) { var rx = [], r = null; while (s.length) { try { r = p.call(this, s); } catch (e) { return [ rx, s ]; } rx.push(r[0]); s = r[1]; } return [ rx, s ]; }; }, // generator operators -- see below optional: function (p) { return function (s) { var r = null; try { r = p.call(this, s); } catch (e) { return [ null, s ]; } return [ r[0], r[1] ]; }; }, not: function (p) { return function (s) { try { p.call(this, s); } catch (e) { return [null, s]; } throw new $P.Exception(s); }; }, ignore: function (p) { return p ? function (s) { var r = null; r = p.call(this, s); return [null, r[1]]; } : null; }, product: function () { var px = arguments[0], qx = Array.prototype.slice.call(arguments, 1), rx = []; for (var i = 0 ; i < px.length ; i++) { rx.push(_.each(px[i], qx)); } return rx; }, cache: function (rule) { var cache = {}, cache_length = 0, cache_keys = [], CACHE_MAX = Date.Config.CACHE_MAX || 100000, r = null; var cacheCheck = function () { if (cache_length === CACHE_MAX) { // kill several keys, don't want to have to do this all the time... for (var i=0; i < 10; i++) { var key = cache_keys.shift(); if (key) { delete cache[key]; cache_length--; } } } }; return function (s) { cacheCheck(); try { r = cache[s] = (cache[s] || rule.call(this, s)); } catch (e) { r = cache[s] = e; } cache_length++; cache_keys.push(s); if (r instanceof $P.Exception) { throw r; } else { return r; } }; }, // vector operators -- see below any: function () { var px = arguments; return function (s) { var r = null; for (var i = 0; i < px.length; i++) { if (px[i] == null) { continue; } try { r = (px[i].call(this, s)); } catch (e) { r = null; } if (r) { return r; } } throw new $P.Exception(s); }; }, each: function () { var px = arguments; return function (s) { var rx = [], r = null; for (var i = 0; i < px.length ; i++) { if (px[i] == null) { continue; } try { r = (px[i].call(this, s)); } catch (e) { throw new $P.Exception(s); } rx.push(r[0]); s = r[1]; } return [ rx, s]; }; }, all: function () { var px = arguments, _ = _; return _.each(_.optional(px)); }, // delimited operators sequence: function (px, d, c) { d = d || _.rtoken(/^\s*/); c = c || null; if (px.length === 1) { return px[0]; } return function (s) { var r = null, q = null; var rx = []; for (var i = 0; i < px.length ; i++) { try { r = px[i].call(this, s); } catch (e) { break; } rx.push(r[0]); try { q = d.call(this, r[1]); } catch (ex) { q = null; break; } s = q[1]; } if (!r) { throw new $P.Exception(s); } if (q) { throw new $P.Exception(q[1]); } if (c) { try { r = c.call(this, r[1]); } catch (ey) { throw new $P.Exception(r[1]); } } return [ rx, (r?r[1]:s) ]; }; }, // // Composite Operators // between: function (d1, p, d2) { d2 = d2 || d1; var _fn = _.each(_.ignore(d1), p, _.ignore(d2)); return function (s) { var rx = _fn.call(this, s); return [[rx[0][0], r[0][2]], rx[1]]; }; }, list: function (p, d, c) { d = d || _.rtoken(/^\s*/); c = c || null; return (p instanceof Array ? _.each(_.product(p.slice(0, -1), _.ignore(d)), p.slice(-1), _.ignore(c)) : _.each(_.many(_.each(p, _.ignore(d))), px, _.ignore(c))); }, set: function (px, d, c) { d = d || _.rtoken(/^\s*/); c = c || null; return function (s) { // r is the current match, best the current 'best' match // which means it parsed the most amount of input var r = null, p = null, q = null, rx = null, best = [[], s], last = false; // go through the rules in the given set for (var i = 0; i < px.length ; i++) { // last is a flag indicating whether this must be the last element // if there is only 1 element, then it MUST be the last one q = null; p = null; r = null; last = (px.length === 1); // first, we try simply to match the current pattern // if not, try the next pattern try { r = px[i].call(this, s); } catch (e) { continue; } // since we are matching against a set of elements, the first // thing to do is to add r[0] to matched elements rx = [[r[0]], r[1]]; // if we matched and there is still input to parse and // we don't already know this is the last element, // we're going to next check for the delimiter ... // if there's none, or if there's no input left to parse // than this must be the last element after all ... if (r[1].length > 0 && ! last) { try { q = d.call(this, r[1]); } catch (ex) { last = true; } } else { last = true; } // if we parsed the delimiter and now there's no more input, // that means we shouldn't have parsed the delimiter at all // so don't update r and mark this as the last element ... if (!last && q[1].length === 0) { last = true; } // so, if this isn't the last element, we're going to see if // we can get any more matches from the remaining (unmatched) // elements ... if (!last) { // build a list of the remaining rules we can match against, // i.e., all but the one we just matched against var qx = []; for (var j = 0; j < px.length ; j++) { if (i !== j) { qx.push(px[j]); } } // now invoke recursively set with the remaining input // note that we don't include the closing delimiter ... // we'll check for that ourselves at the end p = _.set(qx, d).call(this, q[1]); // if we got a non-empty set as a result ... // (otw rx already contains everything we want to match) if (p[0].length > 0) { // update current result, which is stored in rx ... // basically, pick up the remaining text from p[1] // and concat the result from p[0] so that we don't // get endless nesting ... rx[0] = rx[0].concat(p[0]); rx[1] = p[1]; } } // at this point, rx either contains the last matched element // or the entire matched set that starts with this element. // now we just check to see if this variation is better than // our best so far, in terms of how much of the input is parsed if (rx[1].length < best[1].length) { best = rx; } // if we've parsed all the input, then we're finished if (best[1].length === 0) { break; } } // so now we've either gone through all the patterns trying them // as the initial match; or we found one that parsed the entire // input string ... // if best has no matches, just return empty set ... if (best[0].length === 0) { return best; } // if a closing delimiter is provided, then we have to check it also if (c) { // we try this even if there is no remaining input because the pattern // may well be optional or match empty input ... try { q = c.call(this, best[1]); } catch (ey) { throw new $P.Exception(best[1]); } // it parsed ... be sure to update the best match remaining input best[1] = q[1]; } // if we're here, either there was no closing delimiter or we parsed it // so now we have the best match; just return it! return best; }; }, forward: function (gr, fname) { return function (s) { return gr[fname].call(this, s); }; }, // // Translation Operators // replace: function (rule, repl) { return function (s) { var r = rule.call(this, s); return [repl, r[1]]; }; }, process: function (rule, fn) { return function (s) { var r = rule.call(this, s); return [fn.call(this, r[0]), r[1]]; }; }, min: function (min, rule) { return function (s) { var rx = rule.call(this, s); if (rx[0].length < min) { throw new $P.Exception(s); } return rx; }; } }; // Generator Operators And Vector Operators // Generators are operators that have a signature of F(R) => R, // taking a given rule and returning another rule, such as // ignore, which parses a given rule and throws away the result. // Vector operators are those that have a signature of F(R1,R2,...) => R, // take a list of rules and returning a new rule, such as each. // Generator operators are converted (via the following _generator // function) into functions that can also take a list or array of rules // and return an array of new rules as though the function had been // called on each rule in turn (which is what actually happens). // This allows generators to be used with vector operators more easily. // Example: // each(ignore(foo, bar)) instead of each(ignore(foo), ignore(bar)) // This also turns generators into vector operators, which allows // constructs like: // not(cache(foo, bar)) var _generator = function (op) { function gen() { var args = null, rx = [], px, i; if (arguments.length > 1) { args = Array.prototype.slice.call(arguments); } else if (arguments[0] instanceof Array) { args = arguments[0]; } if (args) { px = args.shift(); if (px.length > 0) { args.unshift(px[i]); rx.push(op.apply(null, args)); args.shift(); return rx; } } else { return op.apply(null, arguments); } } return gen; }; var gx = "optional not ignore cache".split(/\s/); for (var i = 0 ; i < gx.length ; i++) { _[gx[i]] = _generator(_[gx[i]]); } var _vector = function (op) { return function () { if (arguments[0] instanceof Array) { return op.apply(null, arguments[0]); } else { return op.apply(null, arguments); } }; }; var vx = "each any all".split(/\s/); for (var j = 0 ; j < vx.length ; j++) { _[vx[j]] = _vector(_[vx[j]]); } }()); (function () { var $D = Date; var flattenAndCompact = function (ax) { var rx = []; for (var i = 0; i < ax.length; i++) { if (ax[i] instanceof Array) { rx = rx.concat(flattenAndCompact(ax[i])); } else { if (ax[i]) { rx.push(ax[i]); } } } return rx; }; var parseMeridian = function () { if (this.meridian && (this.hour || this.hour === 0)) { if (this.meridian === "a" && this.hour > 11 && Date.Config.strict24hr){ throw "Invalid hour and meridian combination"; } else if (this.meridian === "p" && this.hour < 12 && Date.Config.strict24hr){ throw "Invalid hour and meridian combination"; } else if (this.meridian === "p" && this.hour < 12) { this.hour = this.hour + 12; } else if (this.meridian === "a" && this.hour === 12) { this.hour = 0; } } }; var setDefaults = function () { var now = new Date(); if ((this.hour || this.minute) && (!this.month && !this.year && !this.day)) { this.day = now.getDate(); } if (!this.year) { this.year = now.getFullYear(); } if (!this.month && this.month !== 0) { this.month = now.getMonth(); } if (!this.day) { this.day = 1; } if (!this.hour) { this.hour = 0; } if (!this.minute) { this.minute = 0; } if (!this.second) { this.second = 0; } if (!this.millisecond) { this.millisecond = 0; } }; var finishUtils = { getToday: function () { if (this.now || "hour minute second".indexOf(this.unit) !== -1) { return new Date(); } else { return $D.today(); } }, setDaysFromWeekday: function (today, orient){ var gap; orient = orient || 1; this.unit = "day"; gap = ($D.getDayNumberFromName(this.weekday) - today.getDay()); this.days = gap ? ((gap + (orient * 7)) % 7) : (orient * 7); return this; }, setMonthsFromMonth: function (today, orient) { var gap; orient = orient || 1; this.unit = "month"; gap = (this.month - today.getMonth()); this.months = gap ? ((gap + (orient * 12)) % 12) : (orient * 12); this.month = null; return this; }, setDMYFromWeekday: function () { var d = Date[this.weekday](); this.day = d.getDate(); if (!this.month) { this.month = d.getMonth(); } this.year = d.getFullYear(); return this; }, setUnitValue: function (orient) { if (!this.value && this.operator && this.operator !== null && this[this.unit + "s"] && this[this.unit + "s"] !== null) { this[this.unit + "s"] = this[this.unit + "s"] + ((this.operator === "add") ? 1 : -1) + (this.value||0) * orient; } else if (this[this.unit + "s"] == null || this.operator != null) { if (!this.value) { this.value = 1; } this[this.unit + "s"] = this.value * orient; } }, generateDateFromWeeks: function () { var weekday = (this.weekday !== undefined) ? this.weekday : "today"; var d = Date[weekday]().addWeeks(this.weeks); if (this.now) { d.setTimeToNow(); } return d; } }; $D.Translator = { hour: function (s) { return function () { this.hour = Number(s); }; }, minute: function (s) { return function () { this.minute = Number(s); }; }, second: function (s) { return function () { this.second = Number(s); }; }, /* for ss.s format */ secondAndMillisecond: function (s) { return function () { var mx = s.match(/^([0-5][0-9])\.([0-9]{1,3})/); this.second = Number(mx[1]); this.millisecond = Number(mx[2]); }; }, meridian: function (s) { return function () { this.meridian = s.slice(0, 1).toLowerCase(); }; }, timezone: function (s) { return function () { var n = s.replace(/[^\d\+\-]/g, ""); if (n.length) { this.timezoneOffset = Number(n); } else { this.timezone = s.toLowerCase(); } }; }, day: function (x) { var s = x[0]; return function () { this.day = Number(s.match(/\d+/)[0]); if (this.day < 1) { throw "invalid day"; } }; }, month: function (s) { return function () { this.month = (s.length === 3) ? "jan feb mar apr may jun jul aug sep oct nov dec".indexOf(s)/4 : Number(s) - 1; if (this.month < 0) { throw "invalid month"; } }; }, year: function (s) { return function () { var n = Number(s); this.year = ((s.length > 2) ? n : (n + (((n + 2000) < Date.CultureInfo.twoDigitYearMax) ? 2000 : 1900))); }; }, rday: function (s) { return function () { switch (s) { case "yesterday": this.days = -1; break; case "tomorrow": this.days = 1; break; case "today": this.days = 0; break; case "now": this.days = 0; this.now = true; break; } }; }, finishExact: function (x) { var d; x = (x instanceof Array) ? x : [x]; for (var i = 0 ; i < x.length ; i++) { if (x[i]) { x[i].call(this); } } setDefaults.call(this); parseMeridian.call(this); if (this.day > $D.getDaysInMonth(this.year, this.month)) { throw new RangeError(this.day + " is not a valid value for days."); } d = new Date(this.year, this.month, this.day, this.hour, this.minute, this.second, this.millisecond); if (this.year < 100) { d.setFullYear(this.year); // means years less that 100 are process correctly. JS will parse it otherwise as 1900-1999. } if (this.timezone) { d.set({ timezone: this.timezone }); } else if (this.timezoneOffset) { d.set({ timezoneOffset: this.timezoneOffset }); } return d; }, finish: function (x) { var today, expression, orient, temp; x = (x instanceof Array) ? flattenAndCompact(x) : [ x ]; if (x.length === 0) { return null; } for (var i = 0 ; i < x.length ; i++) { if (typeof x[i] === "function") { x[i].call(this); } } if (this.now && !this.unit && !this.operator) { return new Date(); } else { today = finishUtils.getToday.call(this); } expression = !!(this.days && this.days !== null || this.orient || this.operator); orient = ((this.orient === "past" || this.operator === "subtract") ? -1 : 1); if (this.month && this.unit === "week") { this.value = this.month + 1; delete this.month; delete this.day; } if ((this.month || this.month === 0) && "year day hour minute second".indexOf(this.unit) !== -1) { if (!this.value) { this.value = this.month + 1; } this.month = null; expression = true; } if (!expression && this.weekday && !this.day && !this.days) { finishUtils.setDMYFromWeekday.call(this); } if (expression && this.weekday && this.unit !== "month" && this.unit !== "week") { finishUtils.setDaysFromWeekday.call(this, today, orient); } if (this.weekday && this.unit !== "week" && !this.day && !this.days) { temp = Date[this.weekday](); this.day = temp.getDate(); if (temp.getMonth() !== today.getMonth()) { this.month = temp.getMonth(); } } if (this.month && this.unit === "day" && this.operator) { if (!this.value) { this.value = (this.month + 1); } this.month = null; } if (this.value != null && this.month != null && this.year != null) { this.day = this.value * 1; } if (this.month && !this.day && this.value) { today.set({ day: this.value * 1 }); if (!expression) { this.day = this.value * 1; } } if (!this.month && this.value && this.unit === "month" && !this.now) { this.month = this.value; expression = true; } if (expression && (this.month || this.month === 0) && this.unit !== "year") { finishUtils.setMonthsFromMonth.call(this, today, orient); } if (!this.unit) { this.unit = "day"; } finishUtils.setUnitValue.call(this, orient); parseMeridian.call(this); if ((this.month || this.month === 0) && !this.day) { this.day = 1; } if (!this.orient && !this.operator && this.unit === "week" && this.value && !this.day && !this.month) { return Date.today().setWeek(this.value); } if (this.unit === "week" && this.weeks && !this.day && !this.month) { return finishUtils.generateDateFromWeeks.call(this); } if (expression && this.timezone && this.day && this.days) { this.day = this.days; } if (expression){ today.add(this); } else { today.set(this); } if (this.timezone) { this.timezone = this.timezone.toUpperCase(); var offset = $D.getTimezoneOffset(this.timezone); var timezone; if (today.hasDaylightSavingTime()) { // lets check that we're being sane with timezone setting timezone = $D.getTimezoneAbbreviation(offset, today.isDaylightSavingTime()); if (timezone !== this.timezone) { // bugger, we're in a place where things like EST vs EDT matters. if (today.isDaylightSavingTime()) { today.addHours(-1); } else { today.addHours(1); } } } today.setTimezoneOffset(offset); } return today; } }; }()); (function () { var $D = Date; $D.Grammar = {}; var _ = $D.Parsing.Operators, g = $D.Grammar, t = $D.Translator, _fn; // Allow rolling up into general purpose rules _fn = function () { return _.each(_.any.apply(null, arguments), _.not(g.ctoken2("timeContext"))); }; g.datePartDelimiter = _.rtoken(/^([\s\-\.\,\/\x27]+)/); g.timePartDelimiter = _.stoken(":"); g.whiteSpace = _.rtoken(/^\s*/); g.generalDelimiter = _.rtoken(/^(([\s\,]|at|@|on)+)/); var _C = {}; g.ctoken = function (keys) { var fn = _C[keys]; if (! fn) { var c = Date.CultureInfo.regexPatterns; var kx = keys.split(/\s+/), px = []; for (var i = 0; i < kx.length ; i++) { px.push(_.replace(_.rtoken(c[kx[i]]), kx[i])); } fn = _C[keys] = _.any.apply(null, px); } return fn; }; g.ctoken2 = function (key) { return _.rtoken(Date.CultureInfo.regexPatterns[key]); }; var cacheProcessRtoken = function (key, token, type, eachToken) { if (eachToken) { g[key] = _.cache(_.process(_.each(_.rtoken(token),_.optional(g.ctoken2(eachToken))), type)); } else { g[key] = _.cache(_.process(_.rtoken(token), type)); } }; var cacheProcessCtoken = function (token, type) { return _.cache(_.process(g.ctoken2(token), type)); }; var _F = {}; //function cache var _get = function (f) { _F[f] = (_F[f] || g.format(f)[0]); return _F[f]; }; g.allformats = function (fx) { var rx = []; if (fx instanceof Array) { for (var i = 0; i < fx.length; i++) { rx.push(_get(fx[i])); } } else { rx.push(_get(fx)); } return rx; }; g.formats = function (fx) { if (fx instanceof Array) { var rx = []; for (var i = 0 ; i < fx.length ; i++) { rx.push(_get(fx[i])); } return _.any.apply(null, rx); } else { return _get(fx); } }; var grammarFormats = { timeFormats: function(){ var i, RTokenKeys = [ "h", "hh", "H", "HH", "m", "mm", "s", "ss", "ss.s", "z", "zz" ], RToken = [ /^(0[0-9]|1[0-2]|[1-9])/, /^(0[0-9]|1[0-2])/, /^([0-1][0-9]|2[0-3]|[0-9])/, /^([0-1][0-9]|2[0-3])/, /^([0-5][0-9]|[0-9])/, /^[0-5][0-9]/, /^([0-5][0-9]|[0-9])/, /^[0-5][0-9]/, /^[0-5][0-9]\.[0-9]{1,3}/, /^((\+|\-)\s*\d\d\d\d)|((\+|\-)\d\d\:?\d\d)/, /^((\+|\-)\s*\d\d\d\d)|((\+|\-)\d\d\:?\d\d)/ ], tokens = [ t.hour, t.hour, t.hour, t.hour, t.minute, t.minute, t.second, t.second, t.secondAndMillisecond, t.timezone, t.timezone ]; for (i=0; i < RTokenKeys.length; i++) { cacheProcessRtoken(RTokenKeys[i], RToken[i], tokens[i]); } g.hms = _.cache(_.sequence([g.H, g.m, g.s], g.timePartDelimiter)); g.t = cacheProcessCtoken("shortMeridian", t.meridian); g.tt = cacheProcessCtoken("longMeridian", t.meridian); g.zzz = cacheProcessCtoken("timezone", t.timezone); g.timeSuffix = _.each(_.ignore(g.whiteSpace), _.set([ g.tt, g.zzz ])); g.time = _.each(_.optional(_.ignore(_.stoken("T"))), g.hms, g.timeSuffix); }, dateFormats: function () { // pre-loaded rules for different date part order preferences var _setfn = function () { return _.set(arguments, g.datePartDelimiter); }; var i, RTokenKeys = [ "d", "dd", "M", "MM", "y", "yy", "yyy", "yyyy" ], RToken = [ /^([0-2]\d|3[0-1]|\d)/, /^([0-2]\d|3[0-1])/, /^(1[0-2]|0\d|\d)/, /^(1[0-2]|0\d)/, /^(\d+)/, /^(\d\d)/, /^(\d\d?\d?\d?)/, /^(\d\d\d\d)/ ], tokens = [ t.day, t.day, t.month, t.month, t.year, t.year, t.year, t.year ], eachToken = [ "ordinalSuffix", "ordinalSuffix" ]; for (i=0; i < RTokenKeys.length; i++) { cacheProcessRtoken(RTokenKeys[i], RToken[i], tokens[i], eachToken[i]); } g.MMM = g.MMMM = _.cache(_.process(g.ctoken("jan feb mar apr may jun jul aug sep oct nov dec"), t.month)); g.ddd = g.dddd = _.cache(_.process(g.ctoken("sun mon tue wed thu fri sat"), function (s) { return function () { this.weekday = s; }; } )); g.day = _fn(g.d, g.dd); g.month = _fn(g.M, g.MMM); g.year = _fn(g.yyyy, g.yy); g.mdy = _setfn(g.ddd, g.month, g.day, g.year); g.ymd = _setfn(g.ddd, g.year, g.month, g.day); g.dmy = _setfn(g.ddd, g.day, g.month, g.year); g.date = function (s) { return ((g[Date.CultureInfo.dateElementOrder] || g.mdy).call(this, s)); }; }, relative: function () { // relative date / time expressions g.orientation = _.process(g.ctoken("past future"), function (s) { return function () { this.orient = s; }; } ); g.operator = _.process(g.ctoken("add subtract"), function (s) { return function () { this.operator = s; }; } ); g.rday = _.process(g.ctoken("yesterday tomorrow today now"), t.rday); g.unit = _.process(g.ctoken("second minute hour day week month year"), function (s) { return function () { this.unit = s; }; } ); } }; g.buildGrammarFormats = function () { // these need to be rebuilt every time the language changes. _C = {}; grammarFormats.timeFormats(); grammarFormats.dateFormats(); grammarFormats.relative(); g.value = _.process(_.rtoken(/^([-+]?\d+)?(st|nd|rd|th)?/), function (s) { return function () { this.value = s.replace(/\D/g, ""); }; } ); g.expression = _.set([g.rday, g.operator, g.value, g.unit, g.orientation, g.ddd, g.MMM ]); g.format = _.process(_.many( _.any( // translate format specifiers into grammar rules _.process( _.rtoken(/^(dd?d?d?(?!e)|MM?M?M?|yy?y?y?|hh?|HH?|mm?|ss?|tt?|zz?z?)/), function (fmt) { if (g[fmt]) { return g[fmt]; } else { throw $D.Parsing.Exception(fmt); } } ), // translate separator tokens into token rules _.process(_.rtoken(/^[^dMyhHmstz]+/), // all legal separators function (s) { return _.ignore(_.stoken(s)); } ) ) ), // construct the parser ... function (rules) { return _.process(_.each.apply(null, rules), t.finishExact); } ); // starting rule for general purpose grammar g._start = _.process(_.set([ g.date, g.time, g.expression ], g.generalDelimiter, g.whiteSpace), t.finish); }; g.buildGrammarFormats(); // parsing date format specifiers - ex: "h:m:s tt" // this little guy will generate a custom parser based // on the format string, ex: g.format("h:m:s tt") // check for these formats first g._formats = g.formats([ "\"yyyy-MM-ddTHH:mm:ssZ\"", "yyyy-MM-ddTHH:mm:ss.sz", "yyyy-MM-ddTHH:mm:ssZ", "yyyy-MM-ddTHH:mm:ssz", "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-ddTHH:mmZ", "yyyy-MM-ddTHH:mmz", "yyyy-MM-ddTHH:mm", "ddd, MMM dd, yyyy H:mm:ss tt", "ddd MMM d yyyy HH:mm:ss zzz", "MMddyyyy", "ddMMyyyy", "Mddyyyy", "ddMyyyy", "Mdyyyy", "dMyyyy", "yyyy", "Mdyy", "dMyy", "d" ]); // real starting rule: tries selected formats first, // then general purpose rule g.start = function (s) { try { var r = g._formats.call({}, s); if (r[1].length === 0) { return r; } } catch (e) {} return g._start.call({}, s); }; }()); (function () { var $D = Date; /** * @desc Converts the specified string value into its JavaScript Date equivalent using CultureInfo specific format information. * * Example

	///////////
	// Dates //
	///////////

	// 15-Oct-2004
	var d1 = Date.parse("10/15/2004");

	// 15-Oct-2004
	var d1 = Date.parse("15-Oct-2004");

	// 15-Oct-2004
	var d1 = Date.parse("2004.10.15");

	//Fri Oct 15, 2004
	var d1 = Date.parse("Fri Oct 15, 2004");

	///////////
	// Times //
	///////////

	// Today at 10 PM.
	var d1 = Date.parse("10 PM");

	// Today at 10:30 PM.
	var d1 = Date.parse("10:30 P.M.");

	// Today at 6 AM.
	var d1 = Date.parse("06am");

	/////////////////////
	// Dates and Times //
	/////////////////////

	// 8-July-2004 @ 10:30 PM
	var d1 = Date.parse("July 8th, 2004, 10:30 PM");

	// 1-July-2004 @ 10:30 PM
	var d1 = Date.parse("2004-07-01T22:30:00");

	////////////////////
	// Relative Dates //
	////////////////////

	// Returns today's date. The string "today" is culture specific.
	var d1 = Date.parse("today");

	// Returns yesterday's date. The string "yesterday" is culture specific.
	var d1 = Date.parse("yesterday");

	// Returns the date of the next thursday.
	var d1 = Date.parse("Next thursday");

	// Returns the date of the most previous monday.
	var d1 = Date.parse("last monday");

	// Returns today's day + one year.
	var d1 = Date.parse("next year");

	///////////////
	// Date Math //
	///////////////

	// Today + 2 days
	var d1 = Date.parse("t+2");

	// Today + 2 days
	var d1 = Date.parse("today + 2 days");

	// Today + 3 months
	var d1 = Date.parse("t+3m");

	// Today - 1 year
	var d1 = Date.parse("today - 1 year");

	// Today - 1 year
	var d1 = Date.parse("t-1y"); 


	/////////////////////////////
	// Partial Dates and Times //
	/////////////////////////////

	// July 15th of this year.
	var d1 = Date.parse("July 15");

	// 15th day of current day and year.
	var d1 = Date.parse("15");

	// July 1st of current year at 10pm.
	var d1 = Date.parse("7/1 10pm");
	
* * @param {String} The string value to convert into a Date object [Required] * @return {Date} A Date object or null if the string cannot be converted into a Date. */ var parseUtils = { removeOrds: function (s) { ords = s.match(/\b(\d+)(?:st|nd|rd|th)\b/); // find ordinal matches s = ((ords && ords.length === 2) ? s.replace(ords[0], ords[1]) : s); return s; }, grammarParser: function (s) { var r = null; try { r = $D.Grammar.start.call({}, s.replace(/^\s*(\S*(\s+\S+)*)\s*$/, "$1")); } catch (e) { return null; } return ((r[1].length === 0) ? r[0] : null); }, nativeFallback: function(s) { var t; try { // ok we haven't parsed it, last ditch attempt with the built-in parser. t = Date._parse(s); return (t || t === 0) ? new Date(t) : null; } catch (e) { return null; } } }; function parse (s) { var d; if (!s) { return null; } if (s instanceof Date) { return s.clone(); } if (s.length >= 4 && s.charAt(0) !== "0" && s.charAt(0) !== "+"&& s.charAt(0) !== "-") { // ie: 2004 will pass, 0800 won't. // Start with specific formats d = $D.Parsing.ISO.parse(s) || $D.Parsing.Numeric.parse(s); } if (d instanceof Date && !isNaN(d.getTime())) { return d; } else { // find ordinal dates (1st, 3rd, 8th, etc and remove them as they cause parsing issues) s = $D.Parsing.Normalizer.parse(parseUtils.removeOrds(s)); d = parseUtils.grammarParser(s); if (d !== null) { return d; } else { return parseUtils.nativeFallback(s); } } } if (!$D._parse) { $D._parse = $D.parse; } $D.parse = parse; Date.getParseFunction = function (fx) { var fns = Date.Grammar.allformats(fx); return function (s) { var r = null; for (var i = 0; i < fns.length; i++) { try { r = fns[i].call({}, s); } catch (e) { continue; } if (r[1].length === 0) { return r[0]; } } return null; }; }; /** * Converts the specified string value into its JavaScript Date equivalent using the specified format {String} or formats {Array} and the CultureInfo specific format information. * The format of the string value must match one of the supplied formats exactly. * * Example

	// 15-Oct-2004
	var d1 = Date.parseExact("10/15/2004", "M/d/yyyy");

	// 15-Oct-2004
	var d1 = Date.parse("15-Oct-2004", "M-ddd-yyyy");

	// 15-Oct-2004
	var d1 = Date.parse("2004.10.15", "yyyy.MM.dd");

	// Multiple formats
	var d1 = Date.parseExact("10/15/2004", ["M/d/yyyy", "MMMM d, yyyy"]);
	
* * @param {String} The string value to convert into a Date object [Required]. * @param {Object} The expected format {String} or an array of expected formats {Array} of the date string [Required]. * @return {Date} A Date object or null if the string cannot be converted into a Date. */ $D.parseExact = function (s, fx) { return $D.getParseFunction(fx)(s); }; }()); (function () { var $D = Date, $P = $D.prototype, // $C = $D.CultureInfo, // not used atm p = function (s, l) { if (!l) { l = 2; } return ("000" + s).slice(l * -1); }; /** * Converts a PHP format string to Java/.NET format string. * A PHP format string can be used with ._format or .format. * A Java/.NET format string can be used with .toString(). * The .parseExact function will only accept a Java/.NET format string * * Example * var f1 = "%m/%d/%y" * var f2 = Date.normalizeFormat(f1); // "MM/dd/yy" * * new Date().format(f1); // "04/13/08" * new Date()._format(f1); // "04/13/08" * new Date().toString(f2); // "04/13/08" * * var date = Date.parseExact("04/13/08", f2); // Sun Apr 13 2008 * * @param {String} A PHP format string consisting of one or more format spcifiers. * @return {String} The PHP format converted to a Java/.NET format string. */ var normalizerSubstitutions = { "d" : "dd", "%d": "dd", "D" : "ddd", "%a": "ddd", "j" : "dddd", "l" : "dddd", "%A": "dddd", "S" : "S", "F" : "MMMM", "%B": "MMMM", "m" : "MM", "%m": "MM", "M" : "MMM", "%b": "MMM", "%h": "MMM", "n" : "M", "Y" : "yyyy", "%Y": "yyyy", "y" : "yy", "%y": "yy", "g" : "h", "%I": "h", "G" : "H", "h" : "hh", "H" : "HH", "%H": "HH", "i" : "mm", "%M": "mm", "s" : "ss", "%S": "ss", "%r": "hh:mm tt", "%R": "H:mm", "%T": "H:mm:ss", "%X": "t", "%x": "d", "%e": "d", "%D": "MM/dd/yy", "%n": "\\n", "%t": "\\t", "e" : "z", "T" : "z", "%z": "z", "%Z": "z", "Z" : "ZZ", "N" : "u", "w" : "u", "%w": "u", "W" : "W", "%V": "W" }; var normalizer = { substitutes: function (m) { return normalizerSubstitutions[m]; }, interpreted: function (m, x) { var y; switch (m) { case "%u": return x.getDay() + 1; case "z": return x.getOrdinalNumber(); case "%j": return p(x.getOrdinalNumber(), 3); case "%U": var d1 = x.clone().set({month: 0, day: 1}).addDays(-1).moveToDayOfWeek(0), d2 = x.clone().addDays(1).moveToDayOfWeek(0, -1); return (d2 < d1) ? "00" : p((d2.getOrdinalNumber() - d1.getOrdinalNumber()) / 7 + 1); case "%W": return p(x.getWeek()); case "t": return $D.getDaysInMonth(x.getFullYear(), x.getMonth()); case "o": case "%G": return x.setWeek(x.getISOWeek()).toString("yyyy"); case "%g": return x._format("%G").slice(-2); case "a": case "%p": return t("tt").toLowerCase(); case "A": return t("tt").toUpperCase(); case "u": return p(x.getMilliseconds(), 3); case "I": return (x.isDaylightSavingTime()) ? 1 : 0; case "O": return x.getUTCOffset(); case "P": y = x.getUTCOffset(); return y.substring(0, y.length - 2) + ":" + y.substring(y.length - 2); case "B": var now = new Date(); return Math.floor(((now.getHours() * 3600) + (now.getMinutes() * 60) + now.getSeconds() + (now.getTimezoneOffset() + 60) * 60) / 86.4); case "c": return x.toISOString().replace(/\"/g, ""); case "U": return $D.strtotime("now"); case "%c": return t("d") + " " + t("t"); case "%C": return Math.floor(x.getFullYear() / 100 + 1); } }, shouldOverrideDefaults: function (m) { switch (m) { case "%e": return true; default: return false; } }, parse: function (m, context) { var formatString, c = context || new Date(); formatString = normalizer.substitutes(m); if (formatString) { return formatString; } formatString = normalizer.interpreted(m, c); if (formatString) { return formatString; } else { return m; } } }; $D.normalizeFormat = function (format, context) { return format.replace(/(%|\\)?.|%%/g, function(t){ return normalizer.parse(t, context); }); }; /** * Format a local Unix timestamp according to locale settings * * Example: * Date.strftime("%m/%d/%y", new Date()); // "04/13/08" * Date.strftime("c", "2008-04-13T17:52:03Z"); // "04/13/08" * * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @param {Number|String} The number representing the number of seconds that have elapsed since January 1, 1970 (local time). * @return {String} A string representation of the current Date object. */ $D.strftime = function (format, time) { var d = Date.parse(time); return d._format(format); }; /** * Parse any textual datetime description into a Unix timestamp. * A Unix timestamp is the number of seconds that have elapsed since January 1, 1970 (midnight UTC/GMT). * * Example: * Date.strtotime("04/13/08"); // 1208044800 * Date.strtotime("1970-01-01T00:00:00Z"); // 0 * * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @param {Object} A string or date object. * @return {String} A string representation of the current Date object. */ $D.strtotime = function (time) { var d = $D.parse(time); return Math.round($D.UTC(d.getUTCFullYear(), d.getUTCMonth(), d.getUTCDate(), d.getUTCHours(), d.getUTCMinutes(), d.getUTCSeconds(), d.getUTCMilliseconds()) / 1000); }; /** * Converts the value of the current Date object to its equivalent string representation using a PHP/Unix style of date format specifiers. * Format Specifiers * Format Description Example * ------ --------------------------------------------------------------------------- ----------------------- * %a abbreviated weekday name according to the current localed "Mon" through "Sun" * %A full weekday name according to the current localed "Sunday" through "Saturday" * %b abbreviated month name according to the current localed "Jan" through "Dec" * %B full month name according to the current locale "January" through "December" * %c preferred date and time representation for the current locale "4/13/2008 12:33 PM" * %C century number (the year divided by 100 and truncated to an integer) "00" to "99" * %d day of the month as a decimal number "01" to "31" * %D same as %m/%d/%y "04/13/08" * %e day of the month as a decimal number, a single digit is preceded by a space "1" to "31" * %g like %G, but without the century "08" * %G The 4-digit year corresponding to the ISO week number (see %V). "2008" * This has the same format and value as %Y, except that if the ISO week number * belongs to the previous or next year, that year is used instead. * %h same as %b "Jan" through "Dec" * %H hour as a decimal number using a 24-hour clock. "00" to "23" * %I hour as a decimal number using a 12-hour clock. "01" to "12" * %j day of the year as a decimal number. "001" to "366" * %m month as a decimal number. "01" to "12" * %M minute as a decimal number. "00" to "59" * %n newline character "\n" * %p either "am" or "pm" according to the given time value, or the "am" or "pm" * corresponding strings for the current locale. * %r time in a.m. and p.m. notation "8:44 PM" * %R time in 24 hour notation "20:44" * %S second as a decimal number "00" to "59" * %t tab character "\t" * %T current time, equal to %H:%M:%S "12:49:11" * %u weekday as a decimal number ["1", "7"], with "1" representing Monday "1" to "7" * %U week number of the current year as a decimal number, starting with the "0" to ("52" or "53") * first Sunday as the first day of the first week * %V The ISO 8601:1988 week number of the current year as a decimal number, "00" to ("52" or "53") * range 01 to 53, where week 1 is the first week that has at least 4 days * in the current year, and with Monday as the first day of the week. * (Use %G or %g for the year component that corresponds to the week number * for the specified timestamp.) * %W week number of the current year as a decimal number, starting with the "00" to ("52" or "53") * first Monday as the first day of the first week * %w day of the week as a decimal, Sunday being "0" "0" to "6" * %x preferred date representation for the current locale without the time "4/13/2008" * %X preferred time representation for the current locale without the date "12:53:05" * %y year as a decimal number without a century "00" "99" * %Y year as a decimal number including the century "2008" * %Z time zone or name or abbreviation "UTC", "EST", "PST" * %z same as %Z * %% a literal "%" characters "%" * d Day of the month, 2 digits with leading zeros "01" to "31" * D A textual representation of a day, three letters "Mon" through "Sun" * j Day of the month without leading zeros "1" to "31" * l A full textual representation of the day of the week (lowercase "L") "Sunday" through "Saturday" * N ISO-8601 numeric representation of the day of the week (added in PHP 5.1.0) "1" (for Monday) through "7" (for Sunday) * S English ordinal suffix for the day of the month, 2 characters "st", "nd", "rd" or "th". Works well with j * w Numeric representation of the day of the week "0" (for Sunday) through "6" (for Saturday) * z The day of the year (starting from "0") "0" through "365" * W ISO-8601 week number of year, weeks starting on Monday "00" to ("52" or "53") * F A full textual representation of a month, such as January or March "January" through "December" * m Numeric representation of a month, with leading zeros "01" through "12" * M A short textual representation of a month, three letters "Jan" through "Dec" * n Numeric representation of a month, without leading zeros "1" through "12" * t Number of days in the given month "28" through "31" * L Whether it's a leap year "1" if it is a leap year, "0" otherwise * o ISO-8601 year number. This has the same value as Y, except that if the "2008" * ISO week number (W) belongs to the previous or next year, that year * is used instead. * Y A full numeric representation of a year, 4 digits "2008" * y A two digit representation of a year "08" * a Lowercase Ante meridiem and Post meridiem "am" or "pm" * A Uppercase Ante meridiem and Post meridiem "AM" or "PM" * B Swatch Internet time "000" through "999" * g 12-hour format of an hour without leading zeros "1" through "12" * G 24-hour format of an hour without leading zeros "0" through "23" * h 12-hour format of an hour with leading zeros "01" through "12" * H 24-hour format of an hour with leading zeros "00" through "23" * i Minutes with leading zeros "00" to "59" * s Seconds, with leading zeros "00" through "59" * u Milliseconds "54321" * e Timezone identifier "UTC", "EST", "PST" * I Whether or not the date is in daylight saving time (uppercase i) "1" if Daylight Saving Time, "0" otherwise * O Difference to Greenwich time (GMT) in hours "+0200", "-0600" * P Difference to Greenwich time (GMT) with colon between hours and minutes "+02:00", "-06:00" * T Timezone abbreviation "UTC", "EST", "PST" * Z Timezone offset in seconds. The offset for timezones west of UTC is "-43200" through "50400" * always negative, and for those east of UTC is always positive. * c ISO 8601 date "2004-02-12T15:19:21+00:00" * r RFC 2822 formatted date "Thu, 21 Dec 2000 16:01:07 +0200" * U Seconds since the Unix Epoch (January 1 1970 00:00:00 GMT) "0" * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @return {String} A string representation of the current Date object. */ var formatReplace = function (context) { return function (m) { var formatString, override = false; if (m.charAt(0) === "\\" || m.substring(0, 2) === "%%") { return m.replace("\\", "").replace("%%", "%"); } override = normalizer.shouldOverrideDefaults(m); formatString = $D.normalizeFormat(m, context); if (formatString) { return context.toString(formatString, override); } }; }; $P._format = function (format) { var formatter = formatReplace(this); if (!format) { return this._toString(); } else { return format.replace(/(%|\\)?.|%%/g, formatter); } }; if (!$P.format) { $P.format = $P._format; } }()); (function () { "use strict"; var gFn = function (attr) { return function () { return this[attr]; }; }; var sFn = function (attr) { return function (val) { this[attr] = val; return this; }; }; var attrs = ["years", "months", "days", "hours", "minutes", "seconds", "milliseconds"]; var addSetFuncs = function (context, attrs) { for (var i = 0; i < attrs.length ; i++) { var $a = attrs[i], $b = $a.slice(0, 1).toUpperCase() + $a.slice(1); context.prototype[$a] = 0; context.prototype["get" + $b] = gFn($a); context.prototype["set" + $b] = sFn($a); } }; /** * new TimeSpan(milliseconds); * new TimeSpan(days, hours, minutes, seconds); * new TimeSpan(days, hours, minutes, seconds, milliseconds); */ var TimeSpan = function (days, hours, minutes, seconds, milliseconds) { if (arguments.length === 1 && typeof days === "number") { var orient = (days < 0) ? -1 : +1; var millsLeft = Math.abs(days); this.setDays(Math.floor(millsLeft / 86400000) * orient); millsLeft = millsLeft % 86400000; this.setHours(Math.floor(millsLeft / 3600000) * orient); millsLeft = millsLeft % 3600000; this.setMinutes(Math.floor(millsLeft / 60000) * orient); millsLeft = millsLeft % 60000; this.setSeconds(Math.floor(millsLeft / 1000) * orient); millsLeft = millsLeft % 1000; this.setMilliseconds(millsLeft * orient); } else { this.set(days, hours, minutes, seconds, milliseconds); } this.getTotalMilliseconds = function () { return (this.getDays() * 86400000) + (this.getHours() * 3600000) + (this.getMinutes() * 60000) + (this.getSeconds() * 1000); }; this.compareTo = function (time) { var t1 = new Date(1970, 1, 1, this.getHours(), this.getMinutes(), this.getSeconds()), t2; if (time === null) { t2 = new Date(1970, 1, 1, 0, 0, 0); } else { t2 = new Date(1970, 1, 1, time.getHours(), time.getMinutes(), time.getSeconds()); } return (t1 < t2) ? -1 : (t1 > t2) ? 1 : 0; }; this.equals = function (time) { return (this.compareTo(time) === 0); }; this.add = function (time) { return (time === null) ? this : this.addSeconds(time.getTotalMilliseconds() / 1000); }; this.subtract = function (time) { return (time === null) ? this : this.addSeconds(-time.getTotalMilliseconds() / 1000); }; this.addDays = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 86400000)); }; this.addHours = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 3600000)); }; this.addMinutes = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 60000)); }; this.addSeconds = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 1000)); }; this.addMilliseconds = function (n) { return new TimeSpan(this.getTotalMilliseconds() + n); }; this.get12HourHour = function () { return (this.getHours() > 12) ? this.getHours() - 12 : (this.getHours() === 0) ? 12 : this.getHours(); }; this.getDesignator = function () { return (this.getHours() < 12) ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator; }; this.toString = function (format) { this._toString = function () { if (this.getDays() !== null && this.getDays() > 0) { return this.getDays() + "." + this.getHours() + ":" + this.p(this.getMinutes()) + ":" + this.p(this.getSeconds()); } else { return this.getHours() + ":" + this.p(this.getMinutes()) + ":" + this.p(this.getSeconds()); } }; this.p = function (s) { return (s.toString().length < 2) ? "0" + s : s; }; var me = this; return format ? format.replace(/dd?|HH?|hh?|mm?|ss?|tt?/g, function (format) { switch (format) { case "d": return me.getDays(); case "dd": return me.p(me.getDays()); case "H": return me.getHours(); case "HH": return me.p(me.getHours()); case "h": return me.get12HourHour(); case "hh": return me.p(me.get12HourHour()); case "m": return me.getMinutes(); case "mm": return me.p(me.getMinutes()); case "s": return me.getSeconds(); case "ss": return me.p(me.getSeconds()); case "t": return ((me.getHours() < 12) ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator).substring(0, 1); case "tt": return (me.getHours() < 12) ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator; } } ) : this._toString(); }; return this; }; addSetFuncs(TimeSpan, attrs.slice(2)); TimeSpan.prototype.set = function (days, hours, minutes, seconds, milliseconds){ this.setDays(days || this.getDays()); this.setHours(hours || this.getHours()); this.setMinutes(minutes || this.getMinutes()); this.setSeconds(seconds || this.getSeconds()); this.setMilliseconds(milliseconds || this.getMilliseconds()); }; /** * Gets the time of day for this date instances. * @return {TimeSpan} TimeSpan */ Date.prototype.getTimeOfDay = function () { return new TimeSpan(0, this.getHours(), this.getMinutes(), this.getSeconds(), this.getMilliseconds()); }; Date.TimeSpan = TimeSpan; if (typeof window !== "undefined" ) { // keeping API compatible for v1.x window.TimeSpan = TimeSpan; } }()); (function () { "use strict"; var attrs = ["years", "months", "days", "hours", "minutes", "seconds", "milliseconds"]; var gFn = function (attr) { return function () { return this[attr]; }; }; var sFn = function (attr) { return function (val) { this[attr] = val; return this; }; }; var addSetFuncs = function (context, attrs) { for (var i = 0; i < attrs.length ; i++) { var $a = attrs[i], $b = $a.slice(0, 1).toUpperCase() + $a.slice(1); context.prototype[$a] = 0; context.prototype["get" + $b] = gFn($a); context.prototype["set" + $b] = sFn($a); } }; var setMonthsAndYears = function (orient, d1, d2, context) { function inc() { d1.addMonths(-orient); context.months++; if (context.months === 12) { context.years++; context.months = 0; } } if (orient === +1) { while (d1 > d2) { inc(); } } else { while (d1 < d2) { inc(); } } context.months--; context.months *= orient; context.years *= orient; }; var adjustForDST = function(orient, startDate, endDate) { var hasDSTMismatch = (false === (startDate.isDaylightSavingTime() === endDate.isDaylightSavingTime())); if (hasDSTMismatch && orient === 1) { startDate.addHours(-1); } else if (hasDSTMismatch) { startDate.addHours(1); } }; /** * TimePeriod(startDate, endDate); * TimePeriod(years, months, days, hours, minutes, seconds, milliseconds); */ var TimePeriod = function (years, months, days, hours, minutes, seconds, milliseconds) { if (arguments.length === 7) { this.set(years, months, days, hours, minutes, seconds, milliseconds); } else if (arguments.length === 2 && arguments[0] instanceof Date && arguments[1] instanceof Date) { var startDate = arguments[0].clone(); var endDate = arguments[1].clone(); var orient = (startDate > endDate) ? +1 : -1; this.dates = { start: arguments[0].clone(), end: arguments[1].clone() }; setMonthsAndYears(orient, startDate, endDate, this); adjustForDST(orient, startDate, endDate); // // TODO - adjust for DST var diff = endDate - startDate; if (diff !== 0) { var ts = new TimeSpan(diff); this.set(this.years, this.months, ts.getDays(), ts.getHours(), ts.getMinutes(), ts.getSeconds(), ts.getMilliseconds()); } } return this; }; // create all the set functions. addSetFuncs(TimePeriod, attrs); TimePeriod.prototype.set = function (years, months, days, hours, minutes, seconds, milliseconds){ this.setYears(years || this.getYears()); this.setMonths(months || this.getMonths()); this.setDays(days || this.getDays()); this.setHours(hours || this.getHours()); this.setMinutes(minutes || this.getMinutes()); this.setSeconds(seconds || this.getSeconds()); this.setMilliseconds(milliseconds || this.getMilliseconds()); }; Date.TimePeriod = TimePeriod; if (typeof window !== "undefined") { // keeping API compatible for v1.x window.TimePeriod = TimePeriod; } }()); ================================================ FILE: build/date-ar-LY.js ================================================ /** * @overview datejs * @version 1.0.0-rc3 * @author Gregory Wild-Smith * @copyright 2015 Gregory Wild-Smith * @license MIT * @homepage https://github.com/abritinthebay/datejs */ /* * DateJS Culture String File * Country Code: ar-LY * Name: Arabic (Libya) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["ar-LY"] = { "name": "ar-LY", "englishName": "Arabic (Libya)", "nativeName": "العربية (ليبيا)", "Sunday": "الاحد", "Monday": "الاثنين", "Tuesday": "الثلاثاء", "Wednesday": "الاربعاء", "Thursday": "الخميس", "Friday": "الجمعة", "Saturday": "السبت", "Sun": "الاحد", "Mon": "الاثنين", "Tue": "الثلاثاء", "Wed": "الاربعاء", "Thu": "الخميس", "Fri": "الجمعة", "Sat": "السبت", "Su": "أ", "Mo": "ا", "Tu": "ث", "We": "أ", "Th": "خ", "Fr": "ج", "Sa": "س", "S_Sun_Initial": "أ", "M_Mon_Initial": "ا", "T_Tue_Initial": "ث", "W_Wed_Initial": "أ", "T_Thu_Initial": "خ", "F_Fri_Initial": "ج", "S_Sat_Initial": "س", "January": "يناير", "February": "فبراير", "March": "مارس", "April": "ابريل", "May": "مايو", "June": "يونيو", "July": "يوليو", "August": "اغسطس", "September": "سبتمبر", "October": "اكتوبر", "November": "نوفمبر", "December": "ديسمبر", "Jan_Abbr": "يناير", "Feb_Abbr": "فبراير", "Mar_Abbr": "مارس", "Apr_Abbr": "ابريل", "May_Abbr": "مايو", "Jun_Abbr": "يونيو", "Jul_Abbr": "يوليو", "Aug_Abbr": "اغسطس", "Sep_Abbr": "سبتمبر", "Oct_Abbr": "اكتوبر", "Nov_Abbr": "نوفمبر", "Dec_Abbr": "ديسمبر", "AM": "ص", "PM": "م", "firstDayOfWeek": 6, "twoDigitYearMax": 2029, "mdy": "dmy", "M/d/yyyy": "dd/MM/yyyy", "dddd, MMMM dd, yyyy": "dd MMMM, yyyy", "h:mm tt": "hh:mm tt", "h:mm:ss tt": "hh:mm:ss tt", "dddd, MMMM dd, yyyy h:mm:ss tt": "dd MMMM, yyyy hh:mm:ss tt", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "dd MMMM", "MMMM, yyyy": "MMMM, yyyy", "/jan(uary)?/": "يناير", "/feb(ruary)?/": "فبراير", "/mar(ch)?/": "مارس", "/apr(il)?/": "ابريل", "/may/": "مايو", "/jun(e)?/": "يونيو", "/jul(y)?/": "يوليو", "/aug(ust)?/": "اغسطس", "/sep(t(ember)?)?/": "سبتمبر", "/oct(ober)?/": "اكتوبر", "/nov(ember)?/": "نوفمبر", "/dec(ember)?/": "ديسمبر", "/^su(n(day)?)?/": "^الاحد", "/^mo(n(day)?)?/": "^ا(1)?", "/^tu(e(s(day)?)?)?/": "^الثلاثاء", "/^we(d(nesday)?)?/": "^الاربعاء", "/^th(u(r(s(day)?)?)?)?/": "^الخميس", "/^fr(i(day)?)?/": "^الجمعة", "/^sa(t(urday)?)?/": "^السبت", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "ar-LY"; /** * @overview datejs * @version 1.0.0-rc3 * @author Gregory Wild-Smith * @copyright 2015 Gregory Wild-Smith * @license MIT * @homepage https://github.com/abritinthebay/datejs */(function () { var $D = Date; var lang = Date.CultureStrings ? Date.CultureStrings.lang : null; var loggedKeys = {}; // for debug purposes. var getText = { getFromKey: function (key, countryCode) { var output; if (Date.CultureStrings && Date.CultureStrings[countryCode] && Date.CultureStrings[countryCode][key]) { output = Date.CultureStrings[countryCode][key]; } else { output = getText.buildFromDefault(key); } if (key.charAt(0) === "/") { // Assume it's a regex output = getText.buildFromRegex(key, countryCode); } return output; }, getFromObjectValues: function (obj, countryCode) { var key, output = {}; for(key in obj) { if (obj.hasOwnProperty(key)) { output[key] = getText.getFromKey(obj[key], countryCode); } } return output; }, getFromObjectKeys: function (obj, countryCode) { var key, output = {}; for(key in obj) { if (obj.hasOwnProperty(key)) { output[getText.getFromKey(key, countryCode)] = obj[key]; } } return output; }, getFromArray: function (arr, countryCode) { var output = []; for (var i=0; i < arr.length; i++){ if (i in arr) { output[i] = getText.getFromKey(arr[i], countryCode); } } return output; }, buildFromDefault: function (key) { var output, length, split, last; switch(key) { case "name": output = "en-US"; break; case "englishName": output = "English (United States)"; break; case "nativeName": output = "English (United States)"; break; case "twoDigitYearMax": output = 2049; break; case "firstDayOfWeek": output = 0; break; default: output = key; split = key.split("_"); length = split.length; if (length > 1 && key.charAt(0) !== "/") { // if the key isn't a regex and it has a split. last = split[(length - 1)].toLowerCase(); if (last === "initial" || last === "abbr") { output = split[0]; } } break; } return output; }, buildFromRegex: function (key, countryCode) { var output; if (Date.CultureStrings && Date.CultureStrings[countryCode] && Date.CultureStrings[countryCode][key]) { output = new RegExp(Date.CultureStrings[countryCode][key], "i"); } else { output = new RegExp(key.replace(new RegExp("/", "g"),""), "i"); } return output; } }; var shallowMerge = function (obj1, obj2) { for (var attrname in obj2) { if (obj2.hasOwnProperty(attrname)) { obj1[attrname] = obj2[attrname]; } } }; var __ = function (key, language) { var countryCode = (language) ? language : lang; loggedKeys[key] = key; if (typeof key === "object") { if (key instanceof Array) { return getText.getFromArray(key, countryCode); } else { return getText.getFromObjectKeys(key, countryCode); } } else { return getText.getFromKey(key, countryCode); } }; var loadI18nScript = function (code) { // paatterned after jQuery's getScript. var url = Date.Config.i18n + code + ".js"; var head = document.getElementsByTagName("head")[0] || document.documentElement; var script = document.createElement("script"); script.src = url; var completed = false; var events = { done: function (){} // placeholder function }; // Attach handlers for all browsers script.onload = script.onreadystatechange = function() { if ( !completed && (!this.readyState || this.readyState === "loaded" || this.readyState === "complete") ) { events.done(); head.removeChild(script); } }; setTimeout(function() { head.insertBefore(script, head.firstChild); }, 0); // allows return to execute first return { done: function (cb) { events.done = function() { if (cb) { setTimeout(cb,0); } }; } }; }; var buildInfo = { buildFromMethodHash: function (obj) { var key; for(key in obj) { if (obj.hasOwnProperty(key)) { obj[key] = buildInfo[obj[key]](); } } return obj; }, timeZoneDST: function () { var DST = { "CHADT": "+1345", "NZDT": "+1300", "AEDT": "+1100", "ACDT": "+1030", "AZST": "+0500", "IRDT": "+0430", "EEST": "+0300", "CEST": "+0200", "BST": "+0100", "PMDT": "-0200", "ADT": "-0300", "NDT": "-0230", "EDT": "-0400", "CDT": "-0500", "MDT": "-0600", "PDT": "-0700", "AKDT": "-0800", "HADT": "-0900" }; return __(DST); }, timeZoneStandard: function () { var standard = { "LINT": "+1400", "TOT": "+1300", "CHAST": "+1245", "NZST": "+1200", "NFT": "+1130", "SBT": "+1100", "AEST": "+1000", "ACST": "+0930", "JST": "+0900", "CWST": "+0845", "CT": "+0800", "ICT": "+0700", "MMT": "+0630", "BST": "+0600", "NPT": "+0545", "IST": "+0530", "PKT": "+0500", "AFT": "+0430", "MSK": "+0400", "IRST": "+0330", "FET": "+0300", "EET": "+0200", "CET": "+0100", "GMT": "+0000", "UTC": "+0000", "CVT": "-0100", "GST": "-0200", "BRT": "-0300", "NST": "-0330", "AST": "-0400", "EST": "-0500", "CST": "-0600", "MST": "-0700", "PST": "-0800", "AKST": "-0900", "MIT": "-0930", "HST": "-1000", "SST": "-1100", "BIT": "-1200" }; return __(standard); }, timeZones: function (data) { var zone; data.timezones = []; for (zone in data.abbreviatedTimeZoneStandard) { if (data.abbreviatedTimeZoneStandard.hasOwnProperty(zone)) { data.timezones.push({ name: zone, offset: data.abbreviatedTimeZoneStandard[zone]}); } } for (zone in data.abbreviatedTimeZoneDST) { if (data.abbreviatedTimeZoneDST.hasOwnProperty(zone)) { data.timezones.push({ name: zone, offset: data.abbreviatedTimeZoneDST[zone], dst: true}); } } return data.timezones; }, days: function () { return __(["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"]); }, dayAbbr: function () { return __(["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"]); }, dayShortNames: function () { return __(["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"]); }, dayFirstLetters: function () { return __(["S_Sun_Initial", "M_Mon_Initial", "T_Tues_Initial", "W_Wed_Initial", "T_Thu_Initial", "F_Fri_Initial", "S_Sat_Initial"]); }, months: function () { return __(["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"]); }, monthAbbr: function () { return __(["Jan_Abbr", "Feb_Abbr", "Mar_Abbr", "Apr_Abbr", "May_Abbr", "Jun_Abbr", "Jul_Abbr", "Aug_Abbr", "Sep_Abbr", "Oct_Abbr", "Nov_Abbr", "Dec_Abbr"]); }, formatPatterns: function () { return getText.getFromObjectValues({ shortDate: "M/d/yyyy", longDate: "dddd, MMMM dd, yyyy", shortTime: "h:mm tt", longTime: "h:mm:ss tt", fullDateTime: "dddd, MMMM dd, yyyy h:mm:ss tt", sortableDateTime: "yyyy-MM-ddTHH:mm:ss", universalSortableDateTime: "yyyy-MM-dd HH:mm:ssZ", rfc1123: "ddd, dd MMM yyyy HH:mm:ss", monthDay: "MMMM dd", yearMonth: "MMMM, yyyy" }, Date.i18n.currentLanguage()); }, regex: function () { return getText.getFromObjectValues({ inTheMorning: "/( in the )(morn(ing)?)\\b/", thisMorning: "/(this )(morn(ing)?)\\b/", amThisMorning: "/(\b\\d(am)? )(this )(morn(ing)?)/", inTheEvening: "/( in the )(even(ing)?)\\b/", thisEvening: "/(this )(even(ing)?)\\b/", pmThisEvening: "/(\b\\d(pm)? )(this )(even(ing)?)/", jan: "/jan(uary)?/", feb: "/feb(ruary)?/", mar: "/mar(ch)?/", apr: "/apr(il)?/", may: "/may/", jun: "/jun(e)?/", jul: "/jul(y)?/", aug: "/aug(ust)?/", sep: "/sep(t(ember)?)?/", oct: "/oct(ober)?/", nov: "/nov(ember)?/", dec: "/dec(ember)?/", sun: "/^su(n(day)?)?/", mon: "/^mo(n(day)?)?/", tue: "/^tu(e(s(day)?)?)?/", wed: "/^we(d(nesday)?)?/", thu: "/^th(u(r(s(day)?)?)?)?/", fri: "/fr(i(day)?)?/", sat: "/^sa(t(urday)?)?/", future: "/^next/", past: "/^last|past|prev(ious)?/", add: "/^(\\+|aft(er)?|from|hence)/", subtract: "/^(\\-|bef(ore)?|ago)/", yesterday: "/^yes(terday)?/", today: "/^t(od(ay)?)?/", tomorrow: "/^tom(orrow)?/", now: "/^n(ow)?/", millisecond: "/^ms|milli(second)?s?/", second: "/^sec(ond)?s?/", minute: "/^mn|min(ute)?s?/", hour: "/^h(our)?s?/", week: "/^w(eek)?s?/", month: "/^m(onth)?s?/", day: "/^d(ay)?s?/", year: "/^y(ear)?s?/", shortMeridian: "/^(a|p)/", longMeridian: "/^(a\\.?m?\\.?|p\\.?m?\\.?)/", timezone: "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/", ordinalSuffix: "/^\\s*(st|nd|rd|th)/", timeContext: "/^\\s*(\\:|a(?!u|p)|p)/" }, Date.i18n.currentLanguage()); } }; var CultureInfo = function () { var info = getText.getFromObjectValues({ name: "name", englishName: "englishName", nativeName: "nativeName", amDesignator: "AM", pmDesignator: "PM", firstDayOfWeek: "firstDayOfWeek", twoDigitYearMax: "twoDigitYearMax", dateElementOrder: "mdy" }, Date.i18n.currentLanguage()); var constructedInfo = buildInfo.buildFromMethodHash({ dayNames: "days", abbreviatedDayNames: "dayAbbr", shortestDayNames: "dayShortNames", firstLetterDayNames: "dayFirstLetters", monthNames: "months", abbreviatedMonthNames: "monthAbbr", formatPatterns: "formatPatterns", regexPatterns: "regex", abbreviatedTimeZoneDST: "timeZoneDST", abbreviatedTimeZoneStandard: "timeZoneStandard" }); shallowMerge(info, constructedInfo); buildInfo.timeZones(info); return info; }; $D.i18n = { __: function (key, lang) { return __(key, lang); }, currentLanguage: function () { return lang || "en-US"; }, setLanguage: function (code, force, cb) { var async = false; if (force || code === "en-US" || (!!Date.CultureStrings && !!Date.CultureStrings[code])) { lang = code; Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings.lang = code; Date.CultureInfo = new CultureInfo(); } else { if (!(!!Date.CultureStrings && !!Date.CultureStrings[code])) { if (typeof exports !== "undefined" && this.exports !== exports) { // we're in a Node enviroment, load it using require try { require("../i18n/" + code + ".js"); lang = code; Date.CultureStrings.lang = code; Date.CultureInfo = new CultureInfo(); } catch (e) { // var str = "The language for '" + code + "' could not be loaded by Node. It likely does not exist."; throw new Error("The DateJS IETF language tag '" + code + "' could not be loaded by Node. It likely does not exist."); } } else if (Date.Config && Date.Config.i18n) { // we know the location of the files, so lets load them async = true; loadI18nScript(code).done(function(){ lang = code; Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings.lang = code; Date.CultureInfo = new CultureInfo(); $D.Parsing.Normalizer.buildReplaceData(); // because this is async if ($D.Grammar) { $D.Grammar.buildGrammarFormats(); // so we can parse those strings... } if (cb) { setTimeout(cb,0); } }); } else { Date.console.error("The DateJS IETF language tag '" + code + "' is not available and has not been loaded."); return false; } } } $D.Parsing.Normalizer.buildReplaceData(); // rebuild normalizer strings if ($D.Grammar) { $D.Grammar.buildGrammarFormats(); // so we can parse those strings... } if (!async && cb) { setTimeout(cb,0); } }, getLoggedKeys: function () { return loggedKeys; }, updateCultureInfo: function () { Date.CultureInfo = new CultureInfo(); } }; $D.i18n.updateCultureInfo(); // run automatically }()); (function () { var $D = Date, $P = $D.prototype, p = function (s, l) { if (!l) { l = 2; } return ("000" + s).slice(l * -1); }; if (typeof window !== "undefined" && typeof window.console !== "undefined" && typeof window.console.log !== "undefined") { $D.console = console; // used only to raise non-critical errors if available } else { // set mock so we don't give errors. $D.console = { log: function(){}, error: function(){} }; } $D.Config = $D.Config || {}; $D.initOverloads = function() { /** * Overload of Date.now. Allows an alternate call for Date.now where it returns the * current Date as an object rather than just milliseconds since the Unix Epoch. * * Also provides an implementation of now() for browsers (IE<9) that don't have it. * * Backwards compatible so with work with either: * Date.now() [returns ms] * or * Date.now(true) [returns Date] */ if (!$D.now) { $D._now = function now() { return new Date().getTime(); }; } else if (!$D._now) { $D._now = $D.now; } $D.now = function (returnObj) { if (returnObj) { return $D.present(); } else { return $D._now(); } }; if ( !$P.toISOString ) { $P.toISOString = function() { return this.getUTCFullYear() + "-" + p(this.getUTCMonth() + 1) + "-" + p(this.getUTCDate()) + "T" + p(this.getUTCHours()) + ":" + p(this.getUTCMinutes()) + ":" + p(this.getUTCSeconds()) + "." + String( (this.getUTCMilliseconds()/1000).toFixed(3)).slice(2, 5) + "Z"; }; } // private if ( $P._toString === undefined ){ $P._toString = $P.toString; } }; $D.initOverloads(); /** * Gets a date that is set to the current date. The time is set to the start of the day (00:00 or 12:00 AM). * @return {Date} The current date. */ $D.today = function () { return new Date().clearTime(); }; /** * Gets a date that is set to the current date and time (same as new Date, but chainable) * @return {Date} The current date. */ $D.present = function () { return new Date(); }; /** * Compares the first date to the second date and returns an number indication of their relative values. * @param {Date} First Date object to compare [Required]. * @param {Date} Second Date object to compare to [Required]. * @return {Number} -1 = date1 is lessthan date2. 0 = values are equal. 1 = date1 is greaterthan date2. */ $D.compare = function (date1, date2) { if (isNaN(date1) || isNaN(date2)) { throw new Error(date1 + " - " + date2); } else if (date1 instanceof Date && date2 instanceof Date) { return (date1 < date2) ? -1 : (date1 > date2) ? 1 : 0; } else { throw new TypeError(date1 + " - " + date2); } }; /** * Compares the first Date object to the second Date object and returns true if they are equal. * @param {Date} First Date object to compare [Required] * @param {Date} Second Date object to compare to [Required] * @return {Boolean} true if dates are equal. false if they are not equal. */ $D.equals = function (date1, date2) { return (date1.compareTo(date2) === 0); }; /** * Gets the language appropriate day name when given the day number(0-6) * eg - 0 == Sunday * @return {String} The day name */ $D.getDayName = function (n) { return Date.CultureInfo.dayNames[n]; }; /** * Gets the day number (0-6) if given a CultureInfo specific string which is a valid dayName, abbreviatedDayName or shortestDayName (two char). * @param {String} The name of the day (eg. "Monday, "Mon", "tuesday", "tue", "We", "we"). * @return {Number} The day number */ $D.getDayNumberFromName = function (name) { var n = Date.CultureInfo.dayNames, m = Date.CultureInfo.abbreviatedDayNames, o = Date.CultureInfo.shortestDayNames, s = name.toLowerCase(); for (var i = 0; i < n.length; i++) { if (n[i].toLowerCase() === s || m[i].toLowerCase() === s || o[i].toLowerCase() === s) { return i; } } return -1; }; /** * Gets the month number (0-11) if given a Culture Info specific string which is a valid monthName or abbreviatedMonthName. * @param {String} The name of the month (eg. "February, "Feb", "october", "oct"). * @return {Number} The day number */ $D.getMonthNumberFromName = function (name) { var n = Date.CultureInfo.monthNames, m = Date.CultureInfo.abbreviatedMonthNames, s = name.toLowerCase(); for (var i = 0; i < n.length; i++) { if (n[i].toLowerCase() === s || m[i].toLowerCase() === s) { return i; } } return -1; }; /** * Gets the language appropriate month name when given the month number(0-11) * eg - 0 == January * @return {String} The month name */ $D.getMonthName = function (n) { return Date.CultureInfo.monthNames[n]; }; /** * Determines if the current date instance is within a LeapYear. * @param {Number} The year. * @return {Boolean} true if date is within a LeapYear, otherwise false. */ $D.isLeapYear = function (year) { return ((year % 4 === 0 && year % 100 !== 0) || year % 400 === 0); }; /** * Gets the number of days in the month, given a year and month value. Automatically corrects for LeapYear. * @param {Number} The year. * @param {Number} The month (0-11). * @return {Number} The number of days in the month. */ $D.getDaysInMonth = function (year, month) { if (!month && $D.validateMonth(year)) { month = year; year = Date.today().getFullYear(); } return [31, ($D.isLeapYear(year) ? 29 : 28), 31, 30, 31, 30, 31, 31, 30, 31, 30, 31][month]; }; $P.getDaysInMonth = function () { return $D.getDaysInMonth(this.getFullYear(), this.getMonth()); }; $D.getTimezoneAbbreviation = function (offset, dst) { var p, n = (dst || false) ? Date.CultureInfo.abbreviatedTimeZoneDST : Date.CultureInfo.abbreviatedTimeZoneStandard; for (p in n) { if (n.hasOwnProperty(p)) { if (n[p] === offset) { return p; } } } return null; }; $D.getTimezoneOffset = function (name, dst) { var i, a =[], z = Date.CultureInfo.timezones; if (!name) { name = (new Date()).getTimezone();} for (i = 0; i < z.length; i++) { if (z[i].name === name.toUpperCase()) { a.push(i); } } if (!z[a[0]]) { return null; } if (a.length === 1 || !dst) { return z[a[0]].offset; } else { for (i=0; i < a.length; i++) { if (z[a[i]].dst) { return z[a[i]].offset; } } } }; $D.getQuarter = function (d) { d = d || new Date(); // If no date supplied, use today var q = [1,2,3,4]; return q[Math.floor(d.getMonth() / 3)]; // ~~~ is a bitwise op. Faster than Math.floor }; $D.getDaysLeftInQuarter = function (d) { d = d || new Date(); var qEnd = new Date(d); qEnd.setMonth(qEnd.getMonth() + 3 - qEnd.getMonth() % 3, 0); return Math.floor((qEnd - d) / 8.64e7); }; // private var validate = function (n, min, max, name) { name = name ? name : "Object"; if (typeof n === "undefined") { return false; } else if (typeof n !== "number") { throw new TypeError(n + " is not a Number."); } else if (n < min || n > max) { // As failing validation is *not* an exceptional circumstance // lets not throw a RangeError Exception here. // It's semantically correct but it's not sensible. return false; } return true; }; /** * Validates the number is within an acceptable range for milliseconds [0-999]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateMillisecond = function (value) { return validate(value, 0, 999, "millisecond"); }; /** * Validates the number is within an acceptable range for seconds [0-59]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateSecond = function (value) { return validate(value, 0, 59, "second"); }; /** * Validates the number is within an acceptable range for minutes [0-59]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateMinute = function (value) { return validate(value, 0, 59, "minute"); }; /** * Validates the number is within an acceptable range for hours [0-23]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateHour = function (value) { return validate(value, 0, 23, "hour"); }; /** * Validates the number is within an acceptable range for the days in a month [0-MaxDaysInMonth]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateDay = function (value, year, month) { if (year === undefined || year === null || month === undefined || month === null) { return false;} return validate(value, 1, $D.getDaysInMonth(year, month), "day"); }; /** * Validates the number is within an acceptable range for months [0-11]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateWeek = function (value) { return validate(value, 0, 53, "week"); }; /** * Validates the number is within an acceptable range for months [0-11]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateMonth = function (value) { return validate(value, 0, 11, "month"); }; /** * Validates the number is within an acceptable range for years. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateYear = function (value) { /** * Per ECMAScript spec the range of times supported by Date objects is * exactly -100,000,000 days to +100,000,000 days measured relative to * midnight at the beginning of 01 January, 1970 UTC. * This gives a range of 8,640,000,000,000,000 milliseconds to either * side of 01 January, 1970 UTC. * * Earliest possible date: Tue, 20 Apr 271,822 B.C. 00:00:00 UTC * Latest possible date: Sat, 13 Sep 275,760 00:00:00 UTC */ return validate(value, -271822, 275760, "year"); }; $D.validateTimezone = function(value) { var timezones = {"ACDT":1,"ACST":1,"ACT":1,"ADT":1,"AEDT":1,"AEST":1,"AFT":1,"AKDT":1,"AKST":1,"AMST":1,"AMT":1,"ART":1,"AST":1,"AWDT":1,"AWST":1,"AZOST":1,"AZT":1,"BDT":1,"BIOT":1,"BIT":1,"BOT":1,"BRT":1,"BST":1,"BTT":1,"CAT":1,"CCT":1,"CDT":1,"CEDT":1,"CEST":1,"CET":1,"CHADT":1,"CHAST":1,"CHOT":1,"ChST":1,"CHUT":1,"CIST":1,"CIT":1,"CKT":1,"CLST":1,"CLT":1,"COST":1,"COT":1,"CST":1,"CT":1,"CVT":1,"CWST":1,"CXT":1,"DAVT":1,"DDUT":1,"DFT":1,"EASST":1,"EAST":1,"EAT":1,"ECT":1,"EDT":1,"EEDT":1,"EEST":1,"EET":1,"EGST":1,"EGT":1,"EIT":1,"EST":1,"FET":1,"FJT":1,"FKST":1,"FKT":1,"FNT":1,"GALT":1,"GAMT":1,"GET":1,"GFT":1,"GILT":1,"GIT":1,"GMT":1,"GST":1,"GYT":1,"HADT":1,"HAEC":1,"HAST":1,"HKT":1,"HMT":1,"HOVT":1,"HST":1,"ICT":1,"IDT":1,"IOT":1,"IRDT":1,"IRKT":1,"IRST":1,"IST":1,"JST":1,"KGT":1,"KOST":1,"KRAT":1,"KST":1,"LHST":1,"LINT":1,"MAGT":1,"MART":1,"MAWT":1,"MDT":1,"MET":1,"MEST":1,"MHT":1,"MIST":1,"MIT":1,"MMT":1,"MSK":1,"MST":1,"MUT":1,"MVT":1,"MYT":1,"NCT":1,"NDT":1,"NFT":1,"NPT":1,"NST":1,"NT":1,"NUT":1,"NZDT":1,"NZST":1,"OMST":1,"ORAT":1,"PDT":1,"PET":1,"PETT":1,"PGT":1,"PHOT":1,"PHT":1,"PKT":1,"PMDT":1,"PMST":1,"PONT":1,"PST":1,"PYST":1,"PYT":1,"RET":1,"ROTT":1,"SAKT":1,"SAMT":1,"SAST":1,"SBT":1,"SCT":1,"SGT":1,"SLST":1,"SRT":1,"SST":1,"SYOT":1,"TAHT":1,"THA":1,"TFT":1,"TJT":1,"TKT":1,"TLT":1,"TMT":1,"TOT":1,"TVT":1,"UCT":1,"ULAT":1,"UTC":1,"UYST":1,"UYT":1,"UZT":1,"VET":1,"VLAT":1,"VOLT":1,"VOST":1,"VUT":1,"WAKT":1,"WAST":1,"WAT":1,"WEDT":1,"WEST":1,"WET":1,"WST":1,"YAKT":1,"YEKT":1,"Z":1}; return (timezones[value] === 1); }; $D.validateTimezoneOffset= function(value) { // timezones go from +14hrs to -12hrs, the +X hours are negative offsets. return (value > -841 && value < 721); }; }()); (function () { var $D = Date, $P = $D.prototype, p = function (s, l) { if (!l) { l = 2; } return ("000" + s).slice(l * -1); }; var validateConfigObject = function (obj) { var result = {}, self = this, prop, testFunc; testFunc = function (prop, func, value) { if (prop === "day") { var month = (obj.month !== undefined) ? obj.month : self.getMonth(); var year = (obj.year !== undefined) ? obj.year : self.getFullYear(); return $D[func](value, year, month); } else { return $D[func](value); } }; for (prop in obj) { if (Object.prototype.hasOwnProperty.call(obj, prop)) { var func = "validate" + prop.charAt(0).toUpperCase() + prop.slice(1); if ($D[func] && obj[prop] !== null && testFunc(prop, func, obj[prop])) { result[prop] = obj[prop]; } } } return result; }; /** * Resets the time of this Date object to 12:00 AM (00:00), which is the start of the day. * @param {Boolean} .clone() this date instance before clearing Time * @return {Date} this */ $P.clearTime = function () { this.setHours(0); this.setMinutes(0); this.setSeconds(0); this.setMilliseconds(0); return this; }; /** * Resets the time of this Date object to the current time ('now'). * @return {Date} this */ $P.setTimeToNow = function () { var n = new Date(); this.setHours(n.getHours()); this.setMinutes(n.getMinutes()); this.setSeconds(n.getSeconds()); this.setMilliseconds(n.getMilliseconds()); return this; }; /** * Returns a new Date object that is an exact date and time copy of the original instance. * @return {Date} A new Date instance */ $P.clone = function () { return new Date(this.getTime()); }; /** * Compares this instance to a Date object and returns an number indication of their relative values. * @param {Date} Date object to compare [Required] * @return {Number} -1 = this is lessthan date. 0 = values are equal. 1 = this is greaterthan date. */ $P.compareTo = function (date) { return Date.compare(this, date); }; /** * Compares this instance to another Date object and returns true if they are equal. * @param {Date} Date object to compare. If no date to compare, new Date() [now] is used. * @return {Boolean} true if dates are equal. false if they are not equal. */ $P.equals = function (date) { return Date.equals(this, (date !== undefined ? date : new Date())); }; /** * Determines if this instance is between a range of two dates or equal to either the start or end dates. * @param {Date} Start of range [Required] * @param {Date} End of range [Required] * @return {Boolean} true is this is between or equal to the start and end dates, else false */ $P.between = function (start, end) { return this.getTime() >= start.getTime() && this.getTime() <= end.getTime(); }; /** * Determines if this date occurs after the date to compare to. * @param {Date} Date object to compare. If no date to compare, new Date() ("now") is used. * @return {Boolean} true if this date instance is greater than the date to compare to (or "now"), otherwise false. */ $P.isAfter = function (date) { return this.compareTo(date || new Date()) === 1; }; /** * Determines if this date occurs before the date to compare to. * @param {Date} Date object to compare. If no date to compare, new Date() ("now") is used. * @return {Boolean} true if this date instance is less than the date to compare to (or "now"). */ $P.isBefore = function (date) { return (this.compareTo(date || new Date()) === -1); }; /** * Determines if the current Date instance occurs today. * @return {Boolean} true if this date instance is 'today', otherwise false. */ /** * Determines if the current Date instance occurs on the same Date as the supplied 'date'. * If no 'date' to compare to is provided, the current Date instance is compared to 'today'. * @param {date} Date object to compare. If no date to compare, the current Date ("now") is used. * @return {Boolean} true if this Date instance occurs on the same Day as the supplied 'date'. */ $P.isToday = $P.isSameDay = function (date) { return this.clone().clearTime().equals((date || new Date()).clone().clearTime()); }; /** * Adds the specified number of milliseconds to this instance. * @param {Number} The number of milliseconds to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addMilliseconds = function (value) { if (!value) { return this; } this.setTime(this.getTime() + value * 1); return this; }; /** * Adds the specified number of seconds to this instance. * @param {Number} The number of seconds to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addSeconds = function (value) { if (!value) { return this; } return this.addMilliseconds(value * 1000); }; /** * Adds the specified number of seconds to this instance. * @param {Number} The number of seconds to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addMinutes = function (value) { if (!value) { return this; } return this.addMilliseconds(value * 60000); // 60*1000 }; /** * Adds the specified number of hours to this instance. * @param {Number} The number of hours to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addHours = function (value) { if (!value) { return this; } return this.addMilliseconds(value * 3600000); // 60*60*1000 }; /** * Adds the specified number of days to this instance. * @param {Number} The number of days to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addDays = function (value) { if (!value) { return this; } this.setDate(this.getDate() + value * 1); return this; }; /** * Adds the specified number of weekdays (ie - not sat or sun) to this instance. * @param {Number} The number of days to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addWeekdays = function (value) { if (!value) { return this; } var day = this.getDay(); var weeks = (Math.ceil(Math.abs(value)/7)); if (day === 0 || day === 6) { if (value > 0) { this.next().monday(); this.addDays(-1); day = this.getDay(); } } if (value < 0) { while (value < 0) { this.addDays(-1); day = this.getDay(); if (day !== 0 && day !== 6) { value++; } } return this; } else if (value > 5 || (6-day) <= value) { value = value + (weeks * 2); } return this.addDays(value); }; /** * Adds the specified number of weeks to this instance. * @param {Number} The number of weeks to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addWeeks = function (value) { if (!value) { return this; } return this.addDays(value * 7); }; /** * Adds the specified number of months to this instance. * @param {Number} The number of months to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addMonths = function (value) { if (!value) { return this; } var n = this.getDate(); this.setDate(1); this.setMonth(this.getMonth() + value * 1); this.setDate(Math.min(n, $D.getDaysInMonth(this.getFullYear(), this.getMonth()))); return this; }; $P.addQuarters = function (value) { if (!value) { return this; } // note this will take you to the same point in the quarter as you are now. // i.e. - if you are 15 days into the quarter you'll be 15 days into the resulting one. // bonus: this allows adding fractional quarters return this.addMonths(value * 3); }; /** * Adds the specified number of years to this instance. * @param {Number} The number of years to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addYears = function (value) { if (!value) { return this; } return this.addMonths(value * 12); }; /** * Adds (or subtracts) to the value of the years, months, weeks, days, hours, minutes, seconds, milliseconds of the date instance using given configuration object. Positive and Negative values allowed. * Example

	Date.today().add( { days: 1, months: 1 } )

	new Date().add( { years: -1 } )
	
* @param {Object} Configuration object containing attributes (months, days, etc.) * @return {Date} this */ $P.add = function (config) { if (typeof config === "number") { this._orient = config; return this; } var x = config; if (x.day) { // If we should be a different date than today (eg: for 'tomorrow -1d', etc). // Should only effect parsing, not direct usage (eg, Finish and FinishExact) if ((x.day - this.getDate()) !== 0) { this.setDate(x.day); } } if (x.milliseconds) { this.addMilliseconds(x.milliseconds); } if (x.seconds) { this.addSeconds(x.seconds); } if (x.minutes) { this.addMinutes(x.minutes); } if (x.hours) { this.addHours(x.hours); } if (x.weeks) { this.addWeeks(x.weeks); } if (x.months) { this.addMonths(x.months); } if (x.years) { this.addYears(x.years); } if (x.days) { this.addDays(x.days); } return this; }; /** * Get the week number. Week one (1) is the week which contains the first Thursday of the year. Monday is considered the first day of the week. * The .getWeek() function does NOT convert the date to UTC. The local datetime is used. * Please use .getISOWeek() to get the week of the UTC converted date. * @return {Number} 1 to 53 */ $P.getWeek = function (utc) { // Create a copy of this date object var self, target = new Date(this.valueOf()); if (utc) { target.addMinutes(target.getTimezoneOffset()); self = target.clone(); } else { self = this; } // ISO week date weeks start on monday // so correct the day number var dayNr = (self.getDay() + 6) % 7; // ISO 8601 states that week 1 is the week // with the first thursday of that year. // Set the target date to the thursday in the target week target.setDate(target.getDate() - dayNr + 3); // Store the millisecond value of the target date var firstThursday = target.valueOf(); // Set the target to the first thursday of the year // First set the target to january first target.setMonth(0, 1); // Not a thursday? Correct the date to the next thursday if (target.getDay() !== 4) { target.setMonth(0, 1 + ((4 - target.getDay()) + 7) % 7); } // The weeknumber is the number of weeks between the // first thursday of the year and the thursday in the target week return 1 + Math.ceil((firstThursday - target) / 604800000); // 604800000 = 7 * 24 * 3600 * 1000 }; /** * Get the ISO 8601 week number. Week one ("01") is the week which contains the first Thursday of the year. Monday is considered the first day of the week. * The .getISOWeek() function does convert the date to it's UTC value. Please use .getWeek() to get the week of the local date. * @return {String} "01" to "53" */ $P.getISOWeek = function () { return p(this.getWeek(true)); }; /** * Moves the date to Monday of the week set. Week one (1) is the week which contains the first Thursday of the year. * @param {Number} A Number (1 to 53) that represents the week of the year. * @return {Date} this */ $P.setWeek = function (n) { if ((n - this.getWeek()) === 0) { if (this.getDay() !== 1) { return this.moveToDayOfWeek(1, (this.getDay() > 1 ? -1 : 1)); } else { return this; } } else { return this.moveToDayOfWeek(1, (this.getDay() > 1 ? -1 : 1)).addWeeks(n - this.getWeek()); } }; $P.setQuarter = function (qtr) { var month = Math.abs(((qtr-1) * 3) + 1); return this.setMonth(month, 1); }; $P.getQuarter = function () { return Date.getQuarter(this); }; $P.getDaysLeftInQuarter = function () { return Date.getDaysLeftInQuarter(this); }; /** * Moves the date to the next n'th occurrence of the dayOfWeek starting from the beginning of the month. The number (-1) is a magic number and will return the last occurrence of the dayOfWeek in the month. * @param {Number} The dayOfWeek to move to * @param {Number} The n'th occurrence to move to. Use (-1) to return the last occurrence in the month * @return {Date} this */ $P.moveToNthOccurrence = function (dayOfWeek, occurrence) { if (dayOfWeek === "Weekday") { if (occurrence > 0) { this.moveToFirstDayOfMonth(); if (this.is().weekday()) { occurrence -= 1; } } else if (occurrence < 0) { this.moveToLastDayOfMonth(); if (this.is().weekday()) { occurrence += 1; } } else { return this; } return this.addWeekdays(occurrence); } var shift = 0; if (occurrence > 0) { shift = occurrence - 1; } else if (occurrence === -1) { this.moveToLastDayOfMonth(); if (this.getDay() !== dayOfWeek) { this.moveToDayOfWeek(dayOfWeek, -1); } return this; } return this.moveToFirstDayOfMonth().addDays(-1).moveToDayOfWeek(dayOfWeek, +1).addWeeks(shift); }; var moveToN = function (getFunc, addFunc, nVal) { return function (value, orient) { var diff = (value - this[getFunc]() + nVal * (orient || +1)) % nVal; return this[addFunc]((diff === 0) ? diff += nVal * (orient || +1) : diff); }; }; /** * Move to the next or last dayOfWeek based on the orient value. * @param {Number} The dayOfWeek to move to * @param {Number} Forward (+1) or Back (-1). Defaults to +1. [Optional] * @return {Date} this */ $P.moveToDayOfWeek = moveToN("getDay", "addDays", 7); /** * Move to the next or last month based on the orient value. * @param {Number} The month to move to. 0 = January, 11 = December * @param {Number} Forward (+1) or Back (-1). Defaults to +1. [Optional] * @return {Date} this */ $P.moveToMonth = moveToN("getMonth", "addMonths", 12); /** * Get the Ordinate of the current day ("th", "st", "rd"). * @return {String} */ $P.getOrdinate = function () { var num = this.getDate(); return ord(num); }; /** * Get the Ordinal day (numeric day number) of the year, adjusted for leap year. * @return {Number} 1 through 365 (366 in leap years) */ $P.getOrdinalNumber = function () { return Math.ceil((this.clone().clearTime() - new Date(this.getFullYear(), 0, 1)) / 86400000) + 1; }; /** * Get the time zone abbreviation of the current date. * @return {String} The abbreviated time zone name (e.g. "EST") */ $P.getTimezone = function () { return $D.getTimezoneAbbreviation(this.getUTCOffset(), this.isDaylightSavingTime()); }; $P.setTimezoneOffset = function (offset) { var here = this.getTimezoneOffset(), there = Number(offset) * -6 / 10; return (there || there === 0) ? this.addMinutes(there - here) : this; }; $P.setTimezone = function (offset) { return this.setTimezoneOffset($D.getTimezoneOffset(offset)); }; /** * Indicates whether Daylight Saving Time is observed in the current time zone. * @return {Boolean} true|false */ $P.hasDaylightSavingTime = function () { return (Date.today().set({month: 0, day: 1}).getTimezoneOffset() !== Date.today().set({month: 6, day: 1}).getTimezoneOffset()); }; /** * Indicates whether this Date instance is within the Daylight Saving Time range for the current time zone. * @return {Boolean} true|false */ $P.isDaylightSavingTime = function () { return Date.today().set({month: 0, day: 1}).getTimezoneOffset() !== this.getTimezoneOffset(); }; /** * Get the offset from UTC of the current date. * @return {String} The 4-character offset string prefixed with + or - (e.g. "-0500") */ $P.getUTCOffset = function (offset) { var n = (offset || this.getTimezoneOffset()) * -10 / 6, r; if (n < 0) { r = (n - 10000).toString(); return r.charAt(0) + r.substr(2); } else { r = (n + 10000).toString(); return "+" + r.substr(1); } }; /** * Returns the number of milliseconds between this date and date. * @param {Date} Defaults to now * @return {Number} The diff in milliseconds */ $P.getElapsed = function (date) { return (date || new Date()) - this; }; /** * Set the value of year, month, day, hour, minute, second, millisecond of date instance using given configuration object. * Example

	Date.today().set( { day: 20, month: 1 } )

	new Date().set( { millisecond: 0 } )
	
* * @param {Object} Configuration object containing attributes (month, day, etc.) * @return {Date} this */ $P.set = function (config) { config = validateConfigObject.call(this, config); var key; for (key in config) { if (Object.prototype.hasOwnProperty.call(config, key)) { var name = key.charAt(0).toUpperCase() + key.slice(1); var addFunc, getFunc; if (key !== "week" && key !== "month" && key !== "timezone" && key !== "timezoneOffset") { name += "s"; } addFunc = "add" + name; getFunc = "get" + name; if (key === "month") { addFunc = addFunc + "s"; } else if (key === "year"){ getFunc = "getFullYear"; } if (key !== "day" && key !== "timezone" && key !== "timezoneOffset" && key !== "week" && key !== "hour") { this[addFunc](config[key] - this[getFunc]()); } else if ( key === "timezone"|| key === "timezoneOffset" || key === "week" || key === "hour") { this["set"+name](config[key]); } } } // day has to go last because you can't validate the day without first knowing the month if (config.day) { this.addDays(config.day - this.getDate()); } return this; }; /** * Moves the date to the first day of the month. * @return {Date} this */ $P.moveToFirstDayOfMonth = function () { return this.set({ day: 1 }); }; /** * Moves the date to the last day of the month. * @return {Date} this */ $P.moveToLastDayOfMonth = function () { return this.set({ day: $D.getDaysInMonth(this.getFullYear(), this.getMonth())}); }; /** * Converts the value of the current Date object to its equivalent string representation. * Format Specifiers * CUSTOM DATE AND TIME FORMAT STRINGS * Format Description Example * ------ --------------------------------------------------------------------------- ----------------------- * s The seconds of the minute between 0-59. "0" to "59" * ss The seconds of the minute with leading zero if required. "00" to "59" * * m The minute of the hour between 0-59. "0" or "59" * mm The minute of the hour with leading zero if required. "00" or "59" * * h The hour of the day between 1-12. "1" to "12" * hh The hour of the day with leading zero if required. "01" to "12" * * H The hour of the day between 0-23. "0" to "23" * HH The hour of the day with leading zero if required. "00" to "23" * * d The day of the month between 1 and 31. "1" to "31" * dd The day of the month with leading zero if required. "01" to "31" * ddd Abbreviated day name. Date.CultureInfo.abbreviatedDayNames. "Mon" to "Sun" * dddd The full day name. Date.CultureInfo.dayNames. "Monday" to "Sunday" * * M The month of the year between 1-12. "1" to "12" * MM The month of the year with leading zero if required. "01" to "12" * MMM Abbreviated month name. Date.CultureInfo.abbreviatedMonthNames. "Jan" to "Dec" * MMMM The full month name. Date.CultureInfo.monthNames. "January" to "December" * * yy The year as a two-digit number. "99" or "08" * yyyy The full four digit year. "1999" or "2008" * * t Displays the first character of the A.M./P.M. designator. "A" or "P" * Date.CultureInfo.amDesignator or Date.CultureInfo.pmDesignator * tt Displays the A.M./P.M. designator. "AM" or "PM" * Date.CultureInfo.amDesignator or Date.CultureInfo.pmDesignator * * S The ordinal suffix ("st, "nd", "rd" or "th") of the current day. "st, "nd", "rd" or "th" * * STANDARD DATE AND TIME FORMAT STRINGS * Format Description Example *------ --------------------------------------------------------------------------- ----------------------- * d The CultureInfo shortDate Format Pattern "M/d/yyyy" * D The CultureInfo longDate Format Pattern "dddd, MMMM dd, yyyy" * F The CultureInfo fullDateTime Format Pattern "dddd, MMMM dd, yyyy h:mm:ss tt" * m The CultureInfo monthDay Format Pattern "MMMM dd" * r The CultureInfo rfc1123 Format Pattern "ddd, dd MMM yyyy HH:mm:ss GMT" * s The CultureInfo sortableDateTime Format Pattern "yyyy-MM-ddTHH:mm:ss" * t The CultureInfo shortTime Format Pattern "h:mm tt" * T The CultureInfo longTime Format Pattern "h:mm:ss tt" * u The CultureInfo universalSortableDateTime Format Pattern "yyyy-MM-dd HH:mm:ssZ" * y The CultureInfo yearMonth Format Pattern "MMMM, yyyy" * * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @return {String} A string representation of the current Date object. */ var ord = function (n) { switch (n * 1) { case 1: case 21: case 31: return "st"; case 2: case 22: return "nd"; case 3: case 23: return "rd"; default: return "th"; } }; var parseStandardFormats = function (format) { var y, c = Date.CultureInfo.formatPatterns; switch (format) { case "d": return this.toString(c.shortDate); case "D": return this.toString(c.longDate); case "F": return this.toString(c.fullDateTime); case "m": return this.toString(c.monthDay); case "r": case "R": y = this.clone().addMinutes(this.getTimezoneOffset()); return y.toString(c.rfc1123) + " GMT"; case "s": return this.toString(c.sortableDateTime); case "t": return this.toString(c.shortTime); case "T": return this.toString(c.longTime); case "u": y = this.clone().addMinutes(this.getTimezoneOffset()); return y.toString(c.universalSortableDateTime); case "y": return this.toString(c.yearMonth); default: return false; } }; var parseFormatStringsClosure = function (context) { return function (m) { if (m.charAt(0) === "\\") { return m.replace("\\", ""); } switch (m) { case "hh": return p(context.getHours() < 13 ? (context.getHours() === 0 ? 12 : context.getHours()) : (context.getHours() - 12)); case "h": return context.getHours() < 13 ? (context.getHours() === 0 ? 12 : context.getHours()) : (context.getHours() - 12); case "HH": return p(context.getHours()); case "H": return context.getHours(); case "mm": return p(context.getMinutes()); case "m": return context.getMinutes(); case "ss": return p(context.getSeconds()); case "s": return context.getSeconds(); case "yyyy": return p(context.getFullYear(), 4); case "yy": return p(context.getFullYear()); case "y": return context.getFullYear(); case "E": case "dddd": return Date.CultureInfo.dayNames[context.getDay()]; case "ddd": return Date.CultureInfo.abbreviatedDayNames[context.getDay()]; case "dd": return p(context.getDate()); case "d": return context.getDate(); case "MMMM": return Date.CultureInfo.monthNames[context.getMonth()]; case "MMM": return Date.CultureInfo.abbreviatedMonthNames[context.getMonth()]; case "MM": return p((context.getMonth() + 1)); case "M": return context.getMonth() + 1; case "t": return context.getHours() < 12 ? Date.CultureInfo.amDesignator.substring(0, 1) : Date.CultureInfo.pmDesignator.substring(0, 1); case "tt": return context.getHours() < 12 ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator; case "S": return ord(context.getDate()); case "W": return context.getWeek(); case "WW": return context.getISOWeek(); case "Q": return "Q" + context.getQuarter(); case "q": return String(context.getQuarter()); case "z": return context.getTimezone(); case "Z": case "X": return Date.getTimezoneOffset(context.getTimezone()); case "ZZ": // Timezone offset in seconds return context.getTimezoneOffset() * -60; case "u": return context.getDay(); case "L": return ($D.isLeapYear(context.getFullYear())) ? 1 : 0; case "B": // Swatch Internet Time (.beats) return "@"+((context.getUTCSeconds() + (context.getUTCMinutes()*60) + ((context.getUTCHours()+1)*3600))/86.4); default: return m; } }; }; $P.toString = function (format, ignoreStandards) { // Standard Date and Time Format Strings. Formats pulled from CultureInfo file and // may vary by culture. if (!ignoreStandards && format && format.length === 1) { output = parseStandardFormats.call(this, format); if (output) { return output; } } var parseFormatStrings = parseFormatStringsClosure(this); return format ? format.replace(/((\\)?(dd?d?d?|MM?M?M?|yy?y?y?|hh?|HH?|mm?|ss?|tt?|S|q|Q|WW?W?W?)(?![^\[]*\]))/g, parseFormatStrings).replace(/\[|\]/g, "") : this._toString(); }; }()); /************************************************************* * SugarPak - Domain Specific Language - Syntactical Sugar * *************************************************************/ (function () { var $D = Date, $P = $D.prototype, $N = Number.prototype; // private $P._orient = +1; // private $P._nth = null; // private $P._is = false; // private $P._same = false; // private $P._isSecond = false; // private $N._dateElement = "days"; /** * Moves the date to the next instance of a date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.today().next().friday();
	Date.today().next().fri();
	Date.today().next().march();
	Date.today().next().mar();
	Date.today().next().week();
	
* * @return {Date} date */ $P.next = function () { this._move = true; this._orient = +1; return this; }; /** * Creates a new Date (Date.today()) and moves the date to the next instance of the date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.next().friday();
	Date.next().fri();
	Date.next().march();
	Date.next().mar();
	Date.next().week();
	
* * @return {Date} date */ $D.next = function () { return $D.today().next(); }; /** * Moves the date to the previous instance of a date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.today().last().friday();
	Date.today().last().fri();
	Date.today().last().march();
	Date.today().last().mar();
	Date.today().last().week();
	
* * @return {Date} date */ $P.last = $P.prev = $P.previous = function () { this._move = true; this._orient = -1; return this; }; /** * Creates a new Date (Date.today()) and moves the date to the previous instance of the date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.last().friday();
	Date.last().fri();
	Date.previous().march();
	Date.prev().mar();
	Date.last().week();
	
* * @return {Date} date */ $D.last = $D.prev = $D.previous = function () { return $D.today().last(); }; /** * Performs a equality check when followed by either a month name, day name or .weekday() function. * Example

	Date.today().is().friday(); // true|false
	Date.today().is().fri();
	Date.today().is().march();
	Date.today().is().mar();
	
* * @return {Boolean} true|false */ $P.is = function () { this._is = true; return this; }; /** * Determines if two date objects occur on/in exactly the same instance of the subsequent date part function. * The function .same() must be followed by a date part function (example: .day(), .month(), .year(), etc). * * An optional Date can be passed in the date part function. If now date is passed as a parameter, 'Now' is used. * * The following example demonstrates how to determine if two dates fall on the exact same day. * * Example

	var d1 = Date.today(); // today at 00:00
	var d2 = new Date();   // exactly now.

	// Do they occur on the same day?
	d1.same().day(d2); // true
	
	// Do they occur on the same hour?
	d1.same().hour(d2); // false, unless d2 hour is '00' (midnight).
	
	// What if it's the same day, but one year apart?
	var nextYear = Date.today().add(1).year();

	d1.same().day(nextYear); // false, because the dates must occur on the exact same day. 
	
* * Scenario: Determine if a given date occurs during some week period 2 months from now. * * Example

	var future = Date.today().add(2).months();
	return someDate.same().week(future); // true|false;
	
* * @return {Boolean} true|false */ $P.same = function () { this._same = true; this._isSecond = false; return this; }; /** * Determines if the current date/time occurs during Today. Must be preceded by the .is() function. * Example

	someDate.is().today();    // true|false
	new Date().is().today();  // true
	Date.today().is().today();// true
	Date.today().add(-1).day().is().today(); // false
	
* * @return {Boolean} true|false */ $P.today = function () { return this.same().day(); }; /** * Determines if the current date is a weekday. This function must be preceded by the .is() function. * Example

	Date.today().is().weekday(); // true|false
	
* * @return {Boolean} true|false */ $P.weekday = function () { if (this._nth) { return df("Weekday").call(this); } if (this._move) { return this.addWeekdays(this._orient); } if (this._is) { this._is = false; return (!this.is().sat() && !this.is().sun()); } return false; }; /** * Determines if the current date is on the weekend. This function must be preceded by the .is() function. * Example

	Date.today().is().weekend(); // true|false
	
* * @return {Boolean} true|false */ $P.weekend = function () { if (this._is) { this._is = false; return (this.is().sat() || this.is().sun()); } return false; }; /** * Sets the Time of the current Date instance. A string "6:15 pm" or config object {hour:18, minute:15} are accepted. * Example

	// Set time to 6:15pm with a String
	Date.today().at("6:15pm");

	// Set time to 6:15pm with a config object
	Date.today().at({hour:18, minute:15});
	
* * @return {Date} date */ $P.at = function (time) { return (typeof time === "string") ? $D.parse(this.toString("d") + " " + time) : this.set(time); }; /** * Creates a new Date() and adds this (Number) to the date based on the preceding date element function (eg. second|minute|hour|day|month|year). * Example

	// Undeclared Numbers must be wrapped with parentheses. Requirment of JavaScript.
	(3).days().fromNow();
	(6).months().fromNow();

	// Declared Number variables do not require parentheses. 
	var n = 6;
	n.months().fromNow();
	
* * @return {Date} A new Date instance */ $N.fromNow = $N.after = function (date) { var c = {}; c[this._dateElement] = this; return ((!date) ? new Date() : date.clone()).add(c); }; /** * Creates a new Date() and subtract this (Number) from the date based on the preceding date element function (eg. second|minute|hour|day|month|year). * Example

	// Undeclared Numbers must be wrapped with parentheses. Requirment of JavaScript.
	(3).days().ago();
	(6).months().ago();

	// Declared Number variables do not require parentheses. 
	var n = 6;
	n.months().ago();
	
* * @return {Date} A new Date instance */ $N.ago = $N.before = function (date) { var c = {}, s = (this._dateElement[this._dateElement.length-1] !== "s") ? this._dateElement + "s" : this._dateElement; c[s] = this * -1; return ((!date) ? new Date() : date.clone()).add(c); }; // Do NOT modify the following string tokens. These tokens are used to build dynamic functions. // All culture-specific strings can be found in the CultureInfo files. var dx = ("sunday monday tuesday wednesday thursday friday saturday").split(/\s/), mx = ("january february march april may june july august september october november december").split(/\s/), px = ("Millisecond Second Minute Hour Day Week Month Year Quarter Weekday").split(/\s/), pxf = ("Milliseconds Seconds Minutes Hours Date Week Month FullYear Quarter").split(/\s/), nth = ("final first second third fourth fifth").split(/\s/), de; /** * Returns an object literal of all the date parts. * Example

	var o = new Date().toObject();
	
	// { year: 2008, month: 4, week: 20, day: 13, hour: 18, minute: 9, second: 32, millisecond: 812 }
	
	// The object properties can be referenced directly from the object.
	
	alert(o.day);  // alerts "13"
	alert(o.year); // alerts "2008"
	
* * @return {Date} An object literal representing the original date object. */ $P.toObject = function () { var o = {}; for (var i = 0; i < px.length; i++) { if (this["get" + pxf[i]]) { o[px[i].toLowerCase()] = this["get" + pxf[i]](); } } return o; }; /** * Returns a date created from an object literal. Ignores the .week property if set in the config. * Example

	var o = new Date().toObject();
	
	return Date.fromObject(o); // will return the same date. 

	var o2 = {month: 1, day: 20, hour: 18}; // birthday party!
	Date.fromObject(o2);
	
* * @return {Date} An object literal representing the original date object. */ $D.fromObject = function(config) { config.week = null; return Date.today().set(config); }; // Create day name functions and abbreviated day name functions (eg. monday(), friday(), fri()). var df = function (n) { return function () { if (this._is) { this._is = false; return this.getDay() === n; } if (this._move) { this._move = null; } if (this._nth !== null) { // If the .second() function was called earlier, remove the _orient // from the date, and then continue. // This is required because 'second' can be used in two different context. // // Example // // Date.today().add(1).second(); // Date.march().second().monday(); // // Things get crazy with the following... // Date.march().add(1).second().second().monday(); // but it works!! // if (this._isSecond) { this.addSeconds(this._orient * -1); } // make sure we reset _isSecond this._isSecond = false; var ntemp = this._nth; this._nth = null; var temp = this.clone().moveToLastDayOfMonth(); this.moveToNthOccurrence(n, ntemp); if (this > temp) { throw new RangeError($D.getDayName(n) + " does not occur " + ntemp + " times in the month of " + $D.getMonthName(temp.getMonth()) + " " + temp.getFullYear() + "."); } return this; } return this.moveToDayOfWeek(n, this._orient); }; }; var sdf = function (n) { return function () { var t = $D.today(), shift = n - t.getDay(); if (n === 0 && Date.CultureInfo.firstDayOfWeek === 1 && t.getDay() !== 0) { shift = shift + 7; } return t.addDays(shift); }; }; // Create month name functions and abbreviated month name functions (eg. january(), march(), mar()). var month_instance_functions = function (n) { return function () { if (this._is) { this._is = false; return this.getMonth() === n; } return this.moveToMonth(n, this._orient); }; }; var month_static_functions = function (n) { return function () { return $D.today().set({ month: n, day: 1 }); }; }; var processTerms = function (names, staticFunc, instanceFunc) { for (var i = 0; i < names.length; i++) { // Create constant static Name variables. $D[names[i].toUpperCase()] = $D[names[i].toUpperCase().substring(0, 3)] = i; // Create Name functions. $D[names[i]] = $D[names[i].substring(0, 3)] = staticFunc(i); // Create Name instance functions. $P[names[i]] = $P[names[i].substring(0, 3)] = instanceFunc(i); } }; processTerms(dx, sdf, df); processTerms(mx, month_static_functions, month_instance_functions); // Create date element functions and plural date element functions used with Date (eg. day(), days(), months()). var ef = function (j) { return function () { // if the .second() function was called earlier, the _orient // has alread been added. Just return this and reset _isSecond. if (this._isSecond) { this._isSecond = false; return this; } if (this._same) { this._same = this._is = false; var o1 = this.toObject(), o2 = (arguments[0] || new Date()).toObject(), v = "", k = j.toLowerCase(); // the substr trick with -1 doesn't work in IE8 or less k = (k[k.length-1] === "s") ? k.substring(0,k.length-1) : k; for (var m = (px.length - 1); m > -1; m--) { v = px[m].toLowerCase(); if (o1[v] !== o2[v]) { return false; } if (k === v) { break; } } return true; } if (j.substring(j.length - 1) !== "s") { j += "s"; } if (this._move) { this._move = null; } return this["add" + j](this._orient); }; }; var nf = function (n) { return function () { this._dateElement = n; return this; }; }; for (var k = 0; k < px.length; k++) { de = px[k].toLowerCase(); if(de !== "weekday") { // Create date element functions and plural date element functions used with Date (eg. day(), days(), months()). $P[de] = $P[de + "s"] = ef(px[k]); // Create date element functions and plural date element functions used with Number (eg. day(), days(), months()). $N[de] = $N[de + "s"] = nf(de + "s"); } } $P._ss = ef("Second"); var nthfn = function (n) { return function (dayOfWeek) { if (this._same) { return this._ss(arguments[0]); } if (dayOfWeek || dayOfWeek === 0) { return this.moveToNthOccurrence(dayOfWeek, n); } this._nth = n; // if the operator is 'second' add the _orient, then deal with it later... if (n === 2 && (dayOfWeek === undefined || dayOfWeek === null)) { this._isSecond = true; return this.addSeconds(this._orient); } return this; }; }; for (var l = 0; l < nth.length; l++) { $P[nth[l]] = (l === 0) ? nthfn(-1) : nthfn(l); } }()); (function () { "use strict"; Date.Parsing = { Exception: function (s) { this.message = "Parse error at '" + s.substring(0, 10) + " ...'"; } }; var $P = Date.Parsing; var dayOffsets = { standard: [0,31,59,90,120,151,181,212,243,273,304,334], leap: [0,31,60,91,121,152,182,213,244,274,305,335] }; $P.isLeapYear = function(year) { return ((year % 4 === 0) && (year % 100 !== 0)) || (year % 400 === 0); }; var utils = { multiReplace : function (str, hash ) { var key; for (key in hash) { if (Object.prototype.hasOwnProperty.call(hash, key)) { var regex; if (typeof hash[key] === "function") { } else { regex = (hash[key] instanceof RegExp) ? hash[key] : new RegExp(hash[key], "g"); } str = str.replace(regex, key); } } return str; }, getDayOfYearFromWeek : function (obj) { var d, jan4, offset; obj.weekDay = (!obj.weekDay && obj.weekDay !== 0) ? 1 : obj.weekDay; d = new Date(obj.year, 0, 4); jan4 = d.getDay() === 0 ? 7 : d.getDay(); // JS is 0 indexed on Sunday. offset = jan4+3; obj.dayOfYear = ((obj.week * 7) + (obj.weekDay === 0 ? 7 : obj.weekDay))-offset; return obj; }, getDayOfYear : function (obj, dayOffset) { if (!obj.dayOfYear) { obj = utils.getDayOfYearFromWeek(obj); } for (var i=0;i <= dayOffset.length;i++) { if (obj.dayOfYear < dayOffset[i] || i === dayOffset.length) { obj.day = obj.day ? obj.day : (obj.dayOfYear - dayOffset[i-1]); break; } else { obj.month = i; } } return obj; }, adjustForTimeZone : function (obj, date) { var offset; if (obj.zone.toUpperCase() === "Z" || (obj.zone_hours === 0 && obj.zone_minutes === 0)) { // it's UTC/GML so work out the current timeszone offset offset = -date.getTimezoneOffset(); } else { offset = (obj.zone_hours*60) + (obj.zone_minutes || 0); if (obj.zone_sign === "+") { offset *= -1; } offset -= date.getTimezoneOffset(); } date.setMinutes(date.getMinutes()+offset); return date; }, setDefaults : function (obj) { obj.year = obj.year || Date.today().getFullYear(); obj.hours = obj.hours || 0; obj.minutes = obj.minutes || 0; obj.seconds = obj.seconds || 0; obj.milliseconds = obj.milliseconds || 0; if (!(!obj.month && (obj.week || obj.dayOfYear))) { // if we have a month, or if we don't but don't have the day calculation data obj.month = obj.month || 0; obj.day = obj.day || 1; } return obj; }, dataNum: function (data, mod, explict, postProcess) { var dataNum = data*1; if (mod) { if (postProcess) { return data ? mod(data)*1 : data; } else { return data ? mod(dataNum) : data; } } else if (!explict){ return data ? dataNum : data; } else { return (data && typeof data !== "undefined") ? dataNum : data; } }, timeDataProcess: function (obj) { var timeObj = {}; for (var x in obj.data) { if (obj.data.hasOwnProperty(x)) { timeObj[x] = obj.ignore[x] ? obj.data[x] : utils.dataNum(obj.data[x], obj.mods[x], obj.explict[x], obj.postProcess[x]); } } if (obj.data.secmins) { obj.data.secmins = obj.data.secmins.replace(",", ".") * 60; if (!timeObj.minutes) { timeObj.minutes = obj.data.secmins; } else if (!timeObj.seconds) { timeObj.seconds = obj.data.secmins; } delete obj.secmins; } return timeObj; }, buildTimeObjectFromData: function (data) { var time = utils.timeDataProcess({ data: { year : data[1], month : data[5], day : data[7], week : data[8], dayOfYear : data[10], hours : data[15], zone_hours : data[23], zone_minutes : data[24], zone : data[21], zone_sign : data[22], weekDay : data[9], minutes: data[16], seconds: data[19], milliseconds: data[20], secmins: data[18] }, mods: { month: function(data) { return data-1; }, weekDay: function (data) { data = Math.abs(data); return (data === 7 ? 0 : data); }, minutes: function (data) { return data.replace(":",""); }, seconds: function (data) { return Math.floor( (data.replace(":","").replace(",","."))*1 ); }, milliseconds: function (data) { return (data.replace(",",".")*1000); } }, postProcess: { minutes: true, seconds: true, milliseconds: true }, explict: { zone_hours: true, zone_minutes: true }, ignore: { zone: true, zone_sign: true, secmins: true } }); return time; }, addToHash: function (hash, keys, data) { keys = keys; data = data; var len = keys.length; for (var i = 0; i < len; i++) { hash[keys[i]] = data[i]; } return hash; }, combineRegex: function (r1, r2) { return new RegExp("(("+r1.source+")\\s("+r2.source+"))"); }, getDateNthString: function(add, last, inc){ if (add) { return Date.today().addDays(inc).toString("d"); } else if (last) { return Date.today().last()[inc]().toString("d"); } }, buildRegexData: function (array) { var arr = []; var len = array.length; for (var i=0; i < len; i++) { if (Object.prototype.toString.call(array[i]) === '[object Array]') { // oldIE compat version of Array.isArray arr.push(this.combineRegex(array[i][0], array[i][1])); } else { arr.push(array[i]); } } return arr; } }; $P.processTimeObject = function (obj) { var date, dayOffset; utils.setDefaults(obj); dayOffset = ($P.isLeapYear(obj.year)) ? dayOffsets.leap : dayOffsets.standard; if (!obj.month && (obj.week || obj.dayOfYear)) { utils.getDayOfYear(obj, dayOffset); } else { obj.dayOfYear = dayOffset[obj.month] + obj.day; } date = new Date(obj.year, obj.month, obj.day, obj.hours, obj.minutes, obj.seconds, obj.milliseconds); if (obj.zone) { utils.adjustForTimeZone(obj, date); // adjust (and calculate) for timezone } return date; }; $P.ISO = { regex : /^([\+-]?\d{4}(?!\d{2}\b))((-?)((0[1-9]|1[0-2])(\3([12]\d|0[1-9]|3[01]))?|W([0-4]\d|5[0-3])(-?[1-7])?|(00[1-9]|0[1-9]\d|[12]\d{2}|3([0-5]\d|6[1-6])))([T\s]((([01]\d|2[0-4])((:?)[0-5]\d)?|24\:?00)([\.,]\d+(?!:))?)?(\17[0-5]\d([\.,]\d+)?)?\s?([zZ]|([\+-])([01]\d|2[0-3]):?([0-5]\d)?)?)?)?$/, parse : function (s) { var time, data = s.match(this.regex); if (!data || !data.length) { return null; } time = utils.buildTimeObjectFromData(data); if (!time.year || (!time.year && (!time.month && !time.day) && (!time.week && !time.dayOfYear)) ) { return null; } return $P.processTimeObject(time); } }; $P.Numeric = { isNumeric: function (e){return!isNaN(parseFloat(e))&&isFinite(e);}, regex: /\b([0-1]?[0-9])([0-3]?[0-9])([0-2]?[0-9]?[0-9][0-9])\b/i, parse: function (s) { var data, i, time = {}, order = Date.CultureInfo.dateElementOrder.split(""); if (!(this.isNumeric(s)) || // if it's non-numeric OR (s[0] === "+" && s[0] === "-")) { // It's an arithmatic string (eg +/-1000) return null; } if (s.length < 5 && s.indexOf(".") < 0 && s.indexOf("/") < 0) { // assume it's just a year. time.year = s; return $P.processTimeObject(time); } data = s.match(this.regex); if (!data || !data.length) { return null; } for (i=0; i < order.length; i++) { switch(order[i]) { case "d": time.day = data[i+1]; break; case "m": time.month = (data[i+1]-1); break; case "y": time.year = data[i+1]; break; } } return $P.processTimeObject(time); } }; $P.Normalizer = { regexData: function () { var $R = Date.CultureInfo.regexPatterns; return utils.buildRegexData([ $R.tomorrow, $R.yesterday, [$R.past, $R.mon], [$R.past, $R.tue], [$R.past, $R.wed], [$R.past, $R.thu], [$R.past, $R.fri], [$R.past, $R.sat], [$R.past, $R.sun] ]); }, basicReplaceHash : function() { var $R = Date.CultureInfo.regexPatterns; return { "January": $R.jan.source, "February": $R.feb, "March": $R.mar, "April": $R.apr, "May": $R.may, "June": $R.jun, "July": $R.jul, "August": $R.aug, "September": $R.sep, "October": $R.oct, "November": $R.nov, "December": $R.dec, "": /\bat\b/gi, " ": /\s{2,}/, "am": $R.inTheMorning, "9am": $R.thisMorning, "pm": $R.inTheEvening, "7pm":$R.thisEvening }; }, keys : function(){ return [ utils.getDateNthString(true, false, 1), // tomorrow utils.getDateNthString(true, false, -1), // yesterday utils.getDateNthString(false, true, "monday"), //last mon utils.getDateNthString(false, true, "tuesday"), //last tues utils.getDateNthString(false, true, "wednesday"), //last wed utils.getDateNthString(false, true, "thursday"), //last thurs utils.getDateNthString(false, true, "friday"), //last fri utils.getDateNthString(false, true, "saturday"), //last sat utils.getDateNthString(false, true, "sunday") //last sun ]; }, buildRegexFunctions: function () { var $R = Date.CultureInfo.regexPatterns; var __ = Date.i18n.__; var tomorrowRE = new RegExp("(\\b\\d\\d?("+__("AM")+"|"+__("PM")+")? )("+$R.tomorrow.source.slice(1)+")", "i"); // adapted tomorrow regex for AM PM relative dates var todayRE = new RegExp($R.today.source + "(?!\\s*([+-]))\\b"); // today, but excludes the math operators (eg "today + 2h") this.replaceFuncs = [ [todayRE, function (full) { return (full.length > 1) ? Date.today().toString("d") : full; }], [tomorrowRE, function(full, m1) { var t = Date.today().addDays(1).toString("d"); return (t + " " + m1); }], [$R.amThisMorning, function(str, am){return am;}], [$R.pmThisEvening, function(str, pm){return pm;}] ]; }, buildReplaceData: function () { this.buildRegexFunctions(); this.replaceHash = utils.addToHash(this.basicReplaceHash(), this.keys(), this.regexData()); }, stringReplaceFuncs: function (s) { for (var i=0; i < this.replaceFuncs.length; i++) { s = s.replace(this.replaceFuncs[i][0], this.replaceFuncs[i][1]); } return s; }, parse: function (s) { s = this.stringReplaceFuncs(s); s = utils.multiReplace(s, this.replaceHash); try { var n = s.split(/([\s\-\.\,\/\x27]+)/); if (n.length === 3 && $P.Numeric.isNumeric(n[0]) && $P.Numeric.isNumeric(n[2]) && (n[2].length >= 4)) { // ok, so we're dealing with x/year. But that's not a full date. // This fixes wonky dateElementOrder parsing when set to dmy order. if (Date.CultureInfo.dateElementOrder[0] === "d") { s = "1/" + n[0] + "/" + n[2]; // set to 1st of month and normalize the seperator } } } catch (e) {} return s; } }; $P.Normalizer.buildReplaceData(); }()); (function () { var $P = Date.Parsing; var _ = $P.Operators = { // // Tokenizers // rtoken: function (r) { // regex token return function (s) { var mx = s.match(r); if (mx) { return ([ mx[0], s.substring(mx[0].length) ]); } else { throw new $P.Exception(s); } }; }, token: function () { // whitespace-eating token return function (s) { return _.rtoken(new RegExp("^\\s*" + s + "\\s*"))(s); }; }, stoken: function (s) { // string token return _.rtoken(new RegExp("^" + s)); }, // Atomic Operators until: function (p) { return function (s) { var qx = [], rx = null; while (s.length) { try { rx = p.call(this, s); } catch (e) { qx.push(rx[0]); s = rx[1]; continue; } break; } return [ qx, s ]; }; }, many: function (p) { return function (s) { var rx = [], r = null; while (s.length) { try { r = p.call(this, s); } catch (e) { return [ rx, s ]; } rx.push(r[0]); s = r[1]; } return [ rx, s ]; }; }, // generator operators -- see below optional: function (p) { return function (s) { var r = null; try { r = p.call(this, s); } catch (e) { return [ null, s ]; } return [ r[0], r[1] ]; }; }, not: function (p) { return function (s) { try { p.call(this, s); } catch (e) { return [null, s]; } throw new $P.Exception(s); }; }, ignore: function (p) { return p ? function (s) { var r = null; r = p.call(this, s); return [null, r[1]]; } : null; }, product: function () { var px = arguments[0], qx = Array.prototype.slice.call(arguments, 1), rx = []; for (var i = 0 ; i < px.length ; i++) { rx.push(_.each(px[i], qx)); } return rx; }, cache: function (rule) { var cache = {}, cache_length = 0, cache_keys = [], CACHE_MAX = Date.Config.CACHE_MAX || 100000, r = null; var cacheCheck = function () { if (cache_length === CACHE_MAX) { // kill several keys, don't want to have to do this all the time... for (var i=0; i < 10; i++) { var key = cache_keys.shift(); if (key) { delete cache[key]; cache_length--; } } } }; return function (s) { cacheCheck(); try { r = cache[s] = (cache[s] || rule.call(this, s)); } catch (e) { r = cache[s] = e; } cache_length++; cache_keys.push(s); if (r instanceof $P.Exception) { throw r; } else { return r; } }; }, // vector operators -- see below any: function () { var px = arguments; return function (s) { var r = null; for (var i = 0; i < px.length; i++) { if (px[i] == null) { continue; } try { r = (px[i].call(this, s)); } catch (e) { r = null; } if (r) { return r; } } throw new $P.Exception(s); }; }, each: function () { var px = arguments; return function (s) { var rx = [], r = null; for (var i = 0; i < px.length ; i++) { if (px[i] == null) { continue; } try { r = (px[i].call(this, s)); } catch (e) { throw new $P.Exception(s); } rx.push(r[0]); s = r[1]; } return [ rx, s]; }; }, all: function () { var px = arguments, _ = _; return _.each(_.optional(px)); }, // delimited operators sequence: function (px, d, c) { d = d || _.rtoken(/^\s*/); c = c || null; if (px.length === 1) { return px[0]; } return function (s) { var r = null, q = null; var rx = []; for (var i = 0; i < px.length ; i++) { try { r = px[i].call(this, s); } catch (e) { break; } rx.push(r[0]); try { q = d.call(this, r[1]); } catch (ex) { q = null; break; } s = q[1]; } if (!r) { throw new $P.Exception(s); } if (q) { throw new $P.Exception(q[1]); } if (c) { try { r = c.call(this, r[1]); } catch (ey) { throw new $P.Exception(r[1]); } } return [ rx, (r?r[1]:s) ]; }; }, // // Composite Operators // between: function (d1, p, d2) { d2 = d2 || d1; var _fn = _.each(_.ignore(d1), p, _.ignore(d2)); return function (s) { var rx = _fn.call(this, s); return [[rx[0][0], r[0][2]], rx[1]]; }; }, list: function (p, d, c) { d = d || _.rtoken(/^\s*/); c = c || null; return (p instanceof Array ? _.each(_.product(p.slice(0, -1), _.ignore(d)), p.slice(-1), _.ignore(c)) : _.each(_.many(_.each(p, _.ignore(d))), px, _.ignore(c))); }, set: function (px, d, c) { d = d || _.rtoken(/^\s*/); c = c || null; return function (s) { // r is the current match, best the current 'best' match // which means it parsed the most amount of input var r = null, p = null, q = null, rx = null, best = [[], s], last = false; // go through the rules in the given set for (var i = 0; i < px.length ; i++) { // last is a flag indicating whether this must be the last element // if there is only 1 element, then it MUST be the last one q = null; p = null; r = null; last = (px.length === 1); // first, we try simply to match the current pattern // if not, try the next pattern try { r = px[i].call(this, s); } catch (e) { continue; } // since we are matching against a set of elements, the first // thing to do is to add r[0] to matched elements rx = [[r[0]], r[1]]; // if we matched and there is still input to parse and // we don't already know this is the last element, // we're going to next check for the delimiter ... // if there's none, or if there's no input left to parse // than this must be the last element after all ... if (r[1].length > 0 && ! last) { try { q = d.call(this, r[1]); } catch (ex) { last = true; } } else { last = true; } // if we parsed the delimiter and now there's no more input, // that means we shouldn't have parsed the delimiter at all // so don't update r and mark this as the last element ... if (!last && q[1].length === 0) { last = true; } // so, if this isn't the last element, we're going to see if // we can get any more matches from the remaining (unmatched) // elements ... if (!last) { // build a list of the remaining rules we can match against, // i.e., all but the one we just matched against var qx = []; for (var j = 0; j < px.length ; j++) { if (i !== j) { qx.push(px[j]); } } // now invoke recursively set with the remaining input // note that we don't include the closing delimiter ... // we'll check for that ourselves at the end p = _.set(qx, d).call(this, q[1]); // if we got a non-empty set as a result ... // (otw rx already contains everything we want to match) if (p[0].length > 0) { // update current result, which is stored in rx ... // basically, pick up the remaining text from p[1] // and concat the result from p[0] so that we don't // get endless nesting ... rx[0] = rx[0].concat(p[0]); rx[1] = p[1]; } } // at this point, rx either contains the last matched element // or the entire matched set that starts with this element. // now we just check to see if this variation is better than // our best so far, in terms of how much of the input is parsed if (rx[1].length < best[1].length) { best = rx; } // if we've parsed all the input, then we're finished if (best[1].length === 0) { break; } } // so now we've either gone through all the patterns trying them // as the initial match; or we found one that parsed the entire // input string ... // if best has no matches, just return empty set ... if (best[0].length === 0) { return best; } // if a closing delimiter is provided, then we have to check it also if (c) { // we try this even if there is no remaining input because the pattern // may well be optional or match empty input ... try { q = c.call(this, best[1]); } catch (ey) { throw new $P.Exception(best[1]); } // it parsed ... be sure to update the best match remaining input best[1] = q[1]; } // if we're here, either there was no closing delimiter or we parsed it // so now we have the best match; just return it! return best; }; }, forward: function (gr, fname) { return function (s) { return gr[fname].call(this, s); }; }, // // Translation Operators // replace: function (rule, repl) { return function (s) { var r = rule.call(this, s); return [repl, r[1]]; }; }, process: function (rule, fn) { return function (s) { var r = rule.call(this, s); return [fn.call(this, r[0]), r[1]]; }; }, min: function (min, rule) { return function (s) { var rx = rule.call(this, s); if (rx[0].length < min) { throw new $P.Exception(s); } return rx; }; } }; // Generator Operators And Vector Operators // Generators are operators that have a signature of F(R) => R, // taking a given rule and returning another rule, such as // ignore, which parses a given rule and throws away the result. // Vector operators are those that have a signature of F(R1,R2,...) => R, // take a list of rules and returning a new rule, such as each. // Generator operators are converted (via the following _generator // function) into functions that can also take a list or array of rules // and return an array of new rules as though the function had been // called on each rule in turn (which is what actually happens). // This allows generators to be used with vector operators more easily. // Example: // each(ignore(foo, bar)) instead of each(ignore(foo), ignore(bar)) // This also turns generators into vector operators, which allows // constructs like: // not(cache(foo, bar)) var _generator = function (op) { function gen() { var args = null, rx = [], px, i; if (arguments.length > 1) { args = Array.prototype.slice.call(arguments); } else if (arguments[0] instanceof Array) { args = arguments[0]; } if (args) { px = args.shift(); if (px.length > 0) { args.unshift(px[i]); rx.push(op.apply(null, args)); args.shift(); return rx; } } else { return op.apply(null, arguments); } } return gen; }; var gx = "optional not ignore cache".split(/\s/); for (var i = 0 ; i < gx.length ; i++) { _[gx[i]] = _generator(_[gx[i]]); } var _vector = function (op) { return function () { if (arguments[0] instanceof Array) { return op.apply(null, arguments[0]); } else { return op.apply(null, arguments); } }; }; var vx = "each any all".split(/\s/); for (var j = 0 ; j < vx.length ; j++) { _[vx[j]] = _vector(_[vx[j]]); } }()); (function () { var $D = Date; var flattenAndCompact = function (ax) { var rx = []; for (var i = 0; i < ax.length; i++) { if (ax[i] instanceof Array) { rx = rx.concat(flattenAndCompact(ax[i])); } else { if (ax[i]) { rx.push(ax[i]); } } } return rx; }; var parseMeridian = function () { if (this.meridian && (this.hour || this.hour === 0)) { if (this.meridian === "a" && this.hour > 11 && Date.Config.strict24hr){ throw "Invalid hour and meridian combination"; } else if (this.meridian === "p" && this.hour < 12 && Date.Config.strict24hr){ throw "Invalid hour and meridian combination"; } else if (this.meridian === "p" && this.hour < 12) { this.hour = this.hour + 12; } else if (this.meridian === "a" && this.hour === 12) { this.hour = 0; } } }; var setDefaults = function () { var now = new Date(); if ((this.hour || this.minute) && (!this.month && !this.year && !this.day)) { this.day = now.getDate(); } if (!this.year) { this.year = now.getFullYear(); } if (!this.month && this.month !== 0) { this.month = now.getMonth(); } if (!this.day) { this.day = 1; } if (!this.hour) { this.hour = 0; } if (!this.minute) { this.minute = 0; } if (!this.second) { this.second = 0; } if (!this.millisecond) { this.millisecond = 0; } }; var finishUtils = { getToday: function () { if (this.now || "hour minute second".indexOf(this.unit) !== -1) { return new Date(); } else { return $D.today(); } }, setDaysFromWeekday: function (today, orient){ var gap; orient = orient || 1; this.unit = "day"; gap = ($D.getDayNumberFromName(this.weekday) - today.getDay()); this.days = gap ? ((gap + (orient * 7)) % 7) : (orient * 7); return this; }, setMonthsFromMonth: function (today, orient) { var gap; orient = orient || 1; this.unit = "month"; gap = (this.month - today.getMonth()); this.months = gap ? ((gap + (orient * 12)) % 12) : (orient * 12); this.month = null; return this; }, setDMYFromWeekday: function () { var d = Date[this.weekday](); this.day = d.getDate(); if (!this.month) { this.month = d.getMonth(); } this.year = d.getFullYear(); return this; }, setUnitValue: function (orient) { if (!this.value && this.operator && this.operator !== null && this[this.unit + "s"] && this[this.unit + "s"] !== null) { this[this.unit + "s"] = this[this.unit + "s"] + ((this.operator === "add") ? 1 : -1) + (this.value||0) * orient; } else if (this[this.unit + "s"] == null || this.operator != null) { if (!this.value) { this.value = 1; } this[this.unit + "s"] = this.value * orient; } }, generateDateFromWeeks: function () { var weekday = (this.weekday !== undefined) ? this.weekday : "today"; var d = Date[weekday]().addWeeks(this.weeks); if (this.now) { d.setTimeToNow(); } return d; } }; $D.Translator = { hour: function (s) { return function () { this.hour = Number(s); }; }, minute: function (s) { return function () { this.minute = Number(s); }; }, second: function (s) { return function () { this.second = Number(s); }; }, /* for ss.s format */ secondAndMillisecond: function (s) { return function () { var mx = s.match(/^([0-5][0-9])\.([0-9]{1,3})/); this.second = Number(mx[1]); this.millisecond = Number(mx[2]); }; }, meridian: function (s) { return function () { this.meridian = s.slice(0, 1).toLowerCase(); }; }, timezone: function (s) { return function () { var n = s.replace(/[^\d\+\-]/g, ""); if (n.length) { this.timezoneOffset = Number(n); } else { this.timezone = s.toLowerCase(); } }; }, day: function (x) { var s = x[0]; return function () { this.day = Number(s.match(/\d+/)[0]); if (this.day < 1) { throw "invalid day"; } }; }, month: function (s) { return function () { this.month = (s.length === 3) ? "jan feb mar apr may jun jul aug sep oct nov dec".indexOf(s)/4 : Number(s) - 1; if (this.month < 0) { throw "invalid month"; } }; }, year: function (s) { return function () { var n = Number(s); this.year = ((s.length > 2) ? n : (n + (((n + 2000) < Date.CultureInfo.twoDigitYearMax) ? 2000 : 1900))); }; }, rday: function (s) { return function () { switch (s) { case "yesterday": this.days = -1; break; case "tomorrow": this.days = 1; break; case "today": this.days = 0; break; case "now": this.days = 0; this.now = true; break; } }; }, finishExact: function (x) { var d; x = (x instanceof Array) ? x : [x]; for (var i = 0 ; i < x.length ; i++) { if (x[i]) { x[i].call(this); } } setDefaults.call(this); parseMeridian.call(this); if (this.day > $D.getDaysInMonth(this.year, this.month)) { throw new RangeError(this.day + " is not a valid value for days."); } d = new Date(this.year, this.month, this.day, this.hour, this.minute, this.second, this.millisecond); if (this.year < 100) { d.setFullYear(this.year); // means years less that 100 are process correctly. JS will parse it otherwise as 1900-1999. } if (this.timezone) { d.set({ timezone: this.timezone }); } else if (this.timezoneOffset) { d.set({ timezoneOffset: this.timezoneOffset }); } return d; }, finish: function (x) { var today, expression, orient, temp; x = (x instanceof Array) ? flattenAndCompact(x) : [ x ]; if (x.length === 0) { return null; } for (var i = 0 ; i < x.length ; i++) { if (typeof x[i] === "function") { x[i].call(this); } } if (this.now && !this.unit && !this.operator) { return new Date(); } else { today = finishUtils.getToday.call(this); } expression = !!(this.days && this.days !== null || this.orient || this.operator); orient = ((this.orient === "past" || this.operator === "subtract") ? -1 : 1); if (this.month && this.unit === "week") { this.value = this.month + 1; delete this.month; delete this.day; } if ((this.month || this.month === 0) && "year day hour minute second".indexOf(this.unit) !== -1) { if (!this.value) { this.value = this.month + 1; } this.month = null; expression = true; } if (!expression && this.weekday && !this.day && !this.days) { finishUtils.setDMYFromWeekday.call(this); } if (expression && this.weekday && this.unit !== "month" && this.unit !== "week") { finishUtils.setDaysFromWeekday.call(this, today, orient); } if (this.weekday && this.unit !== "week" && !this.day && !this.days) { temp = Date[this.weekday](); this.day = temp.getDate(); if (temp.getMonth() !== today.getMonth()) { this.month = temp.getMonth(); } } if (this.month && this.unit === "day" && this.operator) { if (!this.value) { this.value = (this.month + 1); } this.month = null; } if (this.value != null && this.month != null && this.year != null) { this.day = this.value * 1; } if (this.month && !this.day && this.value) { today.set({ day: this.value * 1 }); if (!expression) { this.day = this.value * 1; } } if (!this.month && this.value && this.unit === "month" && !this.now) { this.month = this.value; expression = true; } if (expression && (this.month || this.month === 0) && this.unit !== "year") { finishUtils.setMonthsFromMonth.call(this, today, orient); } if (!this.unit) { this.unit = "day"; } finishUtils.setUnitValue.call(this, orient); parseMeridian.call(this); if ((this.month || this.month === 0) && !this.day) { this.day = 1; } if (!this.orient && !this.operator && this.unit === "week" && this.value && !this.day && !this.month) { return Date.today().setWeek(this.value); } if (this.unit === "week" && this.weeks && !this.day && !this.month) { return finishUtils.generateDateFromWeeks.call(this); } if (expression && this.timezone && this.day && this.days) { this.day = this.days; } if (expression){ today.add(this); } else { today.set(this); } if (this.timezone) { this.timezone = this.timezone.toUpperCase(); var offset = $D.getTimezoneOffset(this.timezone); var timezone; if (today.hasDaylightSavingTime()) { // lets check that we're being sane with timezone setting timezone = $D.getTimezoneAbbreviation(offset, today.isDaylightSavingTime()); if (timezone !== this.timezone) { // bugger, we're in a place where things like EST vs EDT matters. if (today.isDaylightSavingTime()) { today.addHours(-1); } else { today.addHours(1); } } } today.setTimezoneOffset(offset); } return today; } }; }()); (function () { var $D = Date; $D.Grammar = {}; var _ = $D.Parsing.Operators, g = $D.Grammar, t = $D.Translator, _fn; // Allow rolling up into general purpose rules _fn = function () { return _.each(_.any.apply(null, arguments), _.not(g.ctoken2("timeContext"))); }; g.datePartDelimiter = _.rtoken(/^([\s\-\.\,\/\x27]+)/); g.timePartDelimiter = _.stoken(":"); g.whiteSpace = _.rtoken(/^\s*/); g.generalDelimiter = _.rtoken(/^(([\s\,]|at|@|on)+)/); var _C = {}; g.ctoken = function (keys) { var fn = _C[keys]; if (! fn) { var c = Date.CultureInfo.regexPatterns; var kx = keys.split(/\s+/), px = []; for (var i = 0; i < kx.length ; i++) { px.push(_.replace(_.rtoken(c[kx[i]]), kx[i])); } fn = _C[keys] = _.any.apply(null, px); } return fn; }; g.ctoken2 = function (key) { return _.rtoken(Date.CultureInfo.regexPatterns[key]); }; var cacheProcessRtoken = function (key, token, type, eachToken) { if (eachToken) { g[key] = _.cache(_.process(_.each(_.rtoken(token),_.optional(g.ctoken2(eachToken))), type)); } else { g[key] = _.cache(_.process(_.rtoken(token), type)); } }; var cacheProcessCtoken = function (token, type) { return _.cache(_.process(g.ctoken2(token), type)); }; var _F = {}; //function cache var _get = function (f) { _F[f] = (_F[f] || g.format(f)[0]); return _F[f]; }; g.allformats = function (fx) { var rx = []; if (fx instanceof Array) { for (var i = 0; i < fx.length; i++) { rx.push(_get(fx[i])); } } else { rx.push(_get(fx)); } return rx; }; g.formats = function (fx) { if (fx instanceof Array) { var rx = []; for (var i = 0 ; i < fx.length ; i++) { rx.push(_get(fx[i])); } return _.any.apply(null, rx); } else { return _get(fx); } }; var grammarFormats = { timeFormats: function(){ var i, RTokenKeys = [ "h", "hh", "H", "HH", "m", "mm", "s", "ss", "ss.s", "z", "zz" ], RToken = [ /^(0[0-9]|1[0-2]|[1-9])/, /^(0[0-9]|1[0-2])/, /^([0-1][0-9]|2[0-3]|[0-9])/, /^([0-1][0-9]|2[0-3])/, /^([0-5][0-9]|[0-9])/, /^[0-5][0-9]/, /^([0-5][0-9]|[0-9])/, /^[0-5][0-9]/, /^[0-5][0-9]\.[0-9]{1,3}/, /^((\+|\-)\s*\d\d\d\d)|((\+|\-)\d\d\:?\d\d)/, /^((\+|\-)\s*\d\d\d\d)|((\+|\-)\d\d\:?\d\d)/ ], tokens = [ t.hour, t.hour, t.hour, t.hour, t.minute, t.minute, t.second, t.second, t.secondAndMillisecond, t.timezone, t.timezone ]; for (i=0; i < RTokenKeys.length; i++) { cacheProcessRtoken(RTokenKeys[i], RToken[i], tokens[i]); } g.hms = _.cache(_.sequence([g.H, g.m, g.s], g.timePartDelimiter)); g.t = cacheProcessCtoken("shortMeridian", t.meridian); g.tt = cacheProcessCtoken("longMeridian", t.meridian); g.zzz = cacheProcessCtoken("timezone", t.timezone); g.timeSuffix = _.each(_.ignore(g.whiteSpace), _.set([ g.tt, g.zzz ])); g.time = _.each(_.optional(_.ignore(_.stoken("T"))), g.hms, g.timeSuffix); }, dateFormats: function () { // pre-loaded rules for different date part order preferences var _setfn = function () { return _.set(arguments, g.datePartDelimiter); }; var i, RTokenKeys = [ "d", "dd", "M", "MM", "y", "yy", "yyy", "yyyy" ], RToken = [ /^([0-2]\d|3[0-1]|\d)/, /^([0-2]\d|3[0-1])/, /^(1[0-2]|0\d|\d)/, /^(1[0-2]|0\d)/, /^(\d+)/, /^(\d\d)/, /^(\d\d?\d?\d?)/, /^(\d\d\d\d)/ ], tokens = [ t.day, t.day, t.month, t.month, t.year, t.year, t.year, t.year ], eachToken = [ "ordinalSuffix", "ordinalSuffix" ]; for (i=0; i < RTokenKeys.length; i++) { cacheProcessRtoken(RTokenKeys[i], RToken[i], tokens[i], eachToken[i]); } g.MMM = g.MMMM = _.cache(_.process(g.ctoken("jan feb mar apr may jun jul aug sep oct nov dec"), t.month)); g.ddd = g.dddd = _.cache(_.process(g.ctoken("sun mon tue wed thu fri sat"), function (s) { return function () { this.weekday = s; }; } )); g.day = _fn(g.d, g.dd); g.month = _fn(g.M, g.MMM); g.year = _fn(g.yyyy, g.yy); g.mdy = _setfn(g.ddd, g.month, g.day, g.year); g.ymd = _setfn(g.ddd, g.year, g.month, g.day); g.dmy = _setfn(g.ddd, g.day, g.month, g.year); g.date = function (s) { return ((g[Date.CultureInfo.dateElementOrder] || g.mdy).call(this, s)); }; }, relative: function () { // relative date / time expressions g.orientation = _.process(g.ctoken("past future"), function (s) { return function () { this.orient = s; }; } ); g.operator = _.process(g.ctoken("add subtract"), function (s) { return function () { this.operator = s; }; } ); g.rday = _.process(g.ctoken("yesterday tomorrow today now"), t.rday); g.unit = _.process(g.ctoken("second minute hour day week month year"), function (s) { return function () { this.unit = s; }; } ); } }; g.buildGrammarFormats = function () { // these need to be rebuilt every time the language changes. _C = {}; grammarFormats.timeFormats(); grammarFormats.dateFormats(); grammarFormats.relative(); g.value = _.process(_.rtoken(/^([-+]?\d+)?(st|nd|rd|th)?/), function (s) { return function () { this.value = s.replace(/\D/g, ""); }; } ); g.expression = _.set([g.rday, g.operator, g.value, g.unit, g.orientation, g.ddd, g.MMM ]); g.format = _.process(_.many( _.any( // translate format specifiers into grammar rules _.process( _.rtoken(/^(dd?d?d?(?!e)|MM?M?M?|yy?y?y?|hh?|HH?|mm?|ss?|tt?|zz?z?)/), function (fmt) { if (g[fmt]) { return g[fmt]; } else { throw $D.Parsing.Exception(fmt); } } ), // translate separator tokens into token rules _.process(_.rtoken(/^[^dMyhHmstz]+/), // all legal separators function (s) { return _.ignore(_.stoken(s)); } ) ) ), // construct the parser ... function (rules) { return _.process(_.each.apply(null, rules), t.finishExact); } ); // starting rule for general purpose grammar g._start = _.process(_.set([ g.date, g.time, g.expression ], g.generalDelimiter, g.whiteSpace), t.finish); }; g.buildGrammarFormats(); // parsing date format specifiers - ex: "h:m:s tt" // this little guy will generate a custom parser based // on the format string, ex: g.format("h:m:s tt") // check for these formats first g._formats = g.formats([ "\"yyyy-MM-ddTHH:mm:ssZ\"", "yyyy-MM-ddTHH:mm:ss.sz", "yyyy-MM-ddTHH:mm:ssZ", "yyyy-MM-ddTHH:mm:ssz", "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-ddTHH:mmZ", "yyyy-MM-ddTHH:mmz", "yyyy-MM-ddTHH:mm", "ddd, MMM dd, yyyy H:mm:ss tt", "ddd MMM d yyyy HH:mm:ss zzz", "MMddyyyy", "ddMMyyyy", "Mddyyyy", "ddMyyyy", "Mdyyyy", "dMyyyy", "yyyy", "Mdyy", "dMyy", "d" ]); // real starting rule: tries selected formats first, // then general purpose rule g.start = function (s) { try { var r = g._formats.call({}, s); if (r[1].length === 0) { return r; } } catch (e) {} return g._start.call({}, s); }; }()); (function () { var $D = Date; /** * @desc Converts the specified string value into its JavaScript Date equivalent using CultureInfo specific format information. * * Example

	///////////
	// Dates //
	///////////

	// 15-Oct-2004
	var d1 = Date.parse("10/15/2004");

	// 15-Oct-2004
	var d1 = Date.parse("15-Oct-2004");

	// 15-Oct-2004
	var d1 = Date.parse("2004.10.15");

	//Fri Oct 15, 2004
	var d1 = Date.parse("Fri Oct 15, 2004");

	///////////
	// Times //
	///////////

	// Today at 10 PM.
	var d1 = Date.parse("10 PM");

	// Today at 10:30 PM.
	var d1 = Date.parse("10:30 P.M.");

	// Today at 6 AM.
	var d1 = Date.parse("06am");

	/////////////////////
	// Dates and Times //
	/////////////////////

	// 8-July-2004 @ 10:30 PM
	var d1 = Date.parse("July 8th, 2004, 10:30 PM");

	// 1-July-2004 @ 10:30 PM
	var d1 = Date.parse("2004-07-01T22:30:00");

	////////////////////
	// Relative Dates //
	////////////////////

	// Returns today's date. The string "today" is culture specific.
	var d1 = Date.parse("today");

	// Returns yesterday's date. The string "yesterday" is culture specific.
	var d1 = Date.parse("yesterday");

	// Returns the date of the next thursday.
	var d1 = Date.parse("Next thursday");

	// Returns the date of the most previous monday.
	var d1 = Date.parse("last monday");

	// Returns today's day + one year.
	var d1 = Date.parse("next year");

	///////////////
	// Date Math //
	///////////////

	// Today + 2 days
	var d1 = Date.parse("t+2");

	// Today + 2 days
	var d1 = Date.parse("today + 2 days");

	// Today + 3 months
	var d1 = Date.parse("t+3m");

	// Today - 1 year
	var d1 = Date.parse("today - 1 year");

	// Today - 1 year
	var d1 = Date.parse("t-1y"); 


	/////////////////////////////
	// Partial Dates and Times //
	/////////////////////////////

	// July 15th of this year.
	var d1 = Date.parse("July 15");

	// 15th day of current day and year.
	var d1 = Date.parse("15");

	// July 1st of current year at 10pm.
	var d1 = Date.parse("7/1 10pm");
	
* * @param {String} The string value to convert into a Date object [Required] * @return {Date} A Date object or null if the string cannot be converted into a Date. */ var parseUtils = { removeOrds: function (s) { ords = s.match(/\b(\d+)(?:st|nd|rd|th)\b/); // find ordinal matches s = ((ords && ords.length === 2) ? s.replace(ords[0], ords[1]) : s); return s; }, grammarParser: function (s) { var r = null; try { r = $D.Grammar.start.call({}, s.replace(/^\s*(\S*(\s+\S+)*)\s*$/, "$1")); } catch (e) { return null; } return ((r[1].length === 0) ? r[0] : null); }, nativeFallback: function(s) { var t; try { // ok we haven't parsed it, last ditch attempt with the built-in parser. t = Date._parse(s); return (t || t === 0) ? new Date(t) : null; } catch (e) { return null; } } }; function parse (s) { var d; if (!s) { return null; } if (s instanceof Date) { return s.clone(); } if (s.length >= 4 && s.charAt(0) !== "0" && s.charAt(0) !== "+"&& s.charAt(0) !== "-") { // ie: 2004 will pass, 0800 won't. // Start with specific formats d = $D.Parsing.ISO.parse(s) || $D.Parsing.Numeric.parse(s); } if (d instanceof Date && !isNaN(d.getTime())) { return d; } else { // find ordinal dates (1st, 3rd, 8th, etc and remove them as they cause parsing issues) s = $D.Parsing.Normalizer.parse(parseUtils.removeOrds(s)); d = parseUtils.grammarParser(s); if (d !== null) { return d; } else { return parseUtils.nativeFallback(s); } } } if (!$D._parse) { $D._parse = $D.parse; } $D.parse = parse; Date.getParseFunction = function (fx) { var fns = Date.Grammar.allformats(fx); return function (s) { var r = null; for (var i = 0; i < fns.length; i++) { try { r = fns[i].call({}, s); } catch (e) { continue; } if (r[1].length === 0) { return r[0]; } } return null; }; }; /** * Converts the specified string value into its JavaScript Date equivalent using the specified format {String} or formats {Array} and the CultureInfo specific format information. * The format of the string value must match one of the supplied formats exactly. * * Example

	// 15-Oct-2004
	var d1 = Date.parseExact("10/15/2004", "M/d/yyyy");

	// 15-Oct-2004
	var d1 = Date.parse("15-Oct-2004", "M-ddd-yyyy");

	// 15-Oct-2004
	var d1 = Date.parse("2004.10.15", "yyyy.MM.dd");

	// Multiple formats
	var d1 = Date.parseExact("10/15/2004", ["M/d/yyyy", "MMMM d, yyyy"]);
	
* * @param {String} The string value to convert into a Date object [Required]. * @param {Object} The expected format {String} or an array of expected formats {Array} of the date string [Required]. * @return {Date} A Date object or null if the string cannot be converted into a Date. */ $D.parseExact = function (s, fx) { return $D.getParseFunction(fx)(s); }; }()); (function () { var $D = Date, $P = $D.prototype, // $C = $D.CultureInfo, // not used atm p = function (s, l) { if (!l) { l = 2; } return ("000" + s).slice(l * -1); }; /** * Converts a PHP format string to Java/.NET format string. * A PHP format string can be used with ._format or .format. * A Java/.NET format string can be used with .toString(). * The .parseExact function will only accept a Java/.NET format string * * Example * var f1 = "%m/%d/%y" * var f2 = Date.normalizeFormat(f1); // "MM/dd/yy" * * new Date().format(f1); // "04/13/08" * new Date()._format(f1); // "04/13/08" * new Date().toString(f2); // "04/13/08" * * var date = Date.parseExact("04/13/08", f2); // Sun Apr 13 2008 * * @param {String} A PHP format string consisting of one or more format spcifiers. * @return {String} The PHP format converted to a Java/.NET format string. */ var normalizerSubstitutions = { "d" : "dd", "%d": "dd", "D" : "ddd", "%a": "ddd", "j" : "dddd", "l" : "dddd", "%A": "dddd", "S" : "S", "F" : "MMMM", "%B": "MMMM", "m" : "MM", "%m": "MM", "M" : "MMM", "%b": "MMM", "%h": "MMM", "n" : "M", "Y" : "yyyy", "%Y": "yyyy", "y" : "yy", "%y": "yy", "g" : "h", "%I": "h", "G" : "H", "h" : "hh", "H" : "HH", "%H": "HH", "i" : "mm", "%M": "mm", "s" : "ss", "%S": "ss", "%r": "hh:mm tt", "%R": "H:mm", "%T": "H:mm:ss", "%X": "t", "%x": "d", "%e": "d", "%D": "MM/dd/yy", "%n": "\\n", "%t": "\\t", "e" : "z", "T" : "z", "%z": "z", "%Z": "z", "Z" : "ZZ", "N" : "u", "w" : "u", "%w": "u", "W" : "W", "%V": "W" }; var normalizer = { substitutes: function (m) { return normalizerSubstitutions[m]; }, interpreted: function (m, x) { var y; switch (m) { case "%u": return x.getDay() + 1; case "z": return x.getOrdinalNumber(); case "%j": return p(x.getOrdinalNumber(), 3); case "%U": var d1 = x.clone().set({month: 0, day: 1}).addDays(-1).moveToDayOfWeek(0), d2 = x.clone().addDays(1).moveToDayOfWeek(0, -1); return (d2 < d1) ? "00" : p((d2.getOrdinalNumber() - d1.getOrdinalNumber()) / 7 + 1); case "%W": return p(x.getWeek()); case "t": return $D.getDaysInMonth(x.getFullYear(), x.getMonth()); case "o": case "%G": return x.setWeek(x.getISOWeek()).toString("yyyy"); case "%g": return x._format("%G").slice(-2); case "a": case "%p": return t("tt").toLowerCase(); case "A": return t("tt").toUpperCase(); case "u": return p(x.getMilliseconds(), 3); case "I": return (x.isDaylightSavingTime()) ? 1 : 0; case "O": return x.getUTCOffset(); case "P": y = x.getUTCOffset(); return y.substring(0, y.length - 2) + ":" + y.substring(y.length - 2); case "B": var now = new Date(); return Math.floor(((now.getHours() * 3600) + (now.getMinutes() * 60) + now.getSeconds() + (now.getTimezoneOffset() + 60) * 60) / 86.4); case "c": return x.toISOString().replace(/\"/g, ""); case "U": return $D.strtotime("now"); case "%c": return t("d") + " " + t("t"); case "%C": return Math.floor(x.getFullYear() / 100 + 1); } }, shouldOverrideDefaults: function (m) { switch (m) { case "%e": return true; default: return false; } }, parse: function (m, context) { var formatString, c = context || new Date(); formatString = normalizer.substitutes(m); if (formatString) { return formatString; } formatString = normalizer.interpreted(m, c); if (formatString) { return formatString; } else { return m; } } }; $D.normalizeFormat = function (format, context) { return format.replace(/(%|\\)?.|%%/g, function(t){ return normalizer.parse(t, context); }); }; /** * Format a local Unix timestamp according to locale settings * * Example: * Date.strftime("%m/%d/%y", new Date()); // "04/13/08" * Date.strftime("c", "2008-04-13T17:52:03Z"); // "04/13/08" * * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @param {Number|String} The number representing the number of seconds that have elapsed since January 1, 1970 (local time). * @return {String} A string representation of the current Date object. */ $D.strftime = function (format, time) { var d = Date.parse(time); return d._format(format); }; /** * Parse any textual datetime description into a Unix timestamp. * A Unix timestamp is the number of seconds that have elapsed since January 1, 1970 (midnight UTC/GMT). * * Example: * Date.strtotime("04/13/08"); // 1208044800 * Date.strtotime("1970-01-01T00:00:00Z"); // 0 * * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @param {Object} A string or date object. * @return {String} A string representation of the current Date object. */ $D.strtotime = function (time) { var d = $D.parse(time); return Math.round($D.UTC(d.getUTCFullYear(), d.getUTCMonth(), d.getUTCDate(), d.getUTCHours(), d.getUTCMinutes(), d.getUTCSeconds(), d.getUTCMilliseconds()) / 1000); }; /** * Converts the value of the current Date object to its equivalent string representation using a PHP/Unix style of date format specifiers. * Format Specifiers * Format Description Example * ------ --------------------------------------------------------------------------- ----------------------- * %a abbreviated weekday name according to the current localed "Mon" through "Sun" * %A full weekday name according to the current localed "Sunday" through "Saturday" * %b abbreviated month name according to the current localed "Jan" through "Dec" * %B full month name according to the current locale "January" through "December" * %c preferred date and time representation for the current locale "4/13/2008 12:33 PM" * %C century number (the year divided by 100 and truncated to an integer) "00" to "99" * %d day of the month as a decimal number "01" to "31" * %D same as %m/%d/%y "04/13/08" * %e day of the month as a decimal number, a single digit is preceded by a space "1" to "31" * %g like %G, but without the century "08" * %G The 4-digit year corresponding to the ISO week number (see %V). "2008" * This has the same format and value as %Y, except that if the ISO week number * belongs to the previous or next year, that year is used instead. * %h same as %b "Jan" through "Dec" * %H hour as a decimal number using a 24-hour clock. "00" to "23" * %I hour as a decimal number using a 12-hour clock. "01" to "12" * %j day of the year as a decimal number. "001" to "366" * %m month as a decimal number. "01" to "12" * %M minute as a decimal number. "00" to "59" * %n newline character "\n" * %p either "am" or "pm" according to the given time value, or the "am" or "pm" * corresponding strings for the current locale. * %r time in a.m. and p.m. notation "8:44 PM" * %R time in 24 hour notation "20:44" * %S second as a decimal number "00" to "59" * %t tab character "\t" * %T current time, equal to %H:%M:%S "12:49:11" * %u weekday as a decimal number ["1", "7"], with "1" representing Monday "1" to "7" * %U week number of the current year as a decimal number, starting with the "0" to ("52" or "53") * first Sunday as the first day of the first week * %V The ISO 8601:1988 week number of the current year as a decimal number, "00" to ("52" or "53") * range 01 to 53, where week 1 is the first week that has at least 4 days * in the current year, and with Monday as the first day of the week. * (Use %G or %g for the year component that corresponds to the week number * for the specified timestamp.) * %W week number of the current year as a decimal number, starting with the "00" to ("52" or "53") * first Monday as the first day of the first week * %w day of the week as a decimal, Sunday being "0" "0" to "6" * %x preferred date representation for the current locale without the time "4/13/2008" * %X preferred time representation for the current locale without the date "12:53:05" * %y year as a decimal number without a century "00" "99" * %Y year as a decimal number including the century "2008" * %Z time zone or name or abbreviation "UTC", "EST", "PST" * %z same as %Z * %% a literal "%" characters "%" * d Day of the month, 2 digits with leading zeros "01" to "31" * D A textual representation of a day, three letters "Mon" through "Sun" * j Day of the month without leading zeros "1" to "31" * l A full textual representation of the day of the week (lowercase "L") "Sunday" through "Saturday" * N ISO-8601 numeric representation of the day of the week (added in PHP 5.1.0) "1" (for Monday) through "7" (for Sunday) * S English ordinal suffix for the day of the month, 2 characters "st", "nd", "rd" or "th". Works well with j * w Numeric representation of the day of the week "0" (for Sunday) through "6" (for Saturday) * z The day of the year (starting from "0") "0" through "365" * W ISO-8601 week number of year, weeks starting on Monday "00" to ("52" or "53") * F A full textual representation of a month, such as January or March "January" through "December" * m Numeric representation of a month, with leading zeros "01" through "12" * M A short textual representation of a month, three letters "Jan" through "Dec" * n Numeric representation of a month, without leading zeros "1" through "12" * t Number of days in the given month "28" through "31" * L Whether it's a leap year "1" if it is a leap year, "0" otherwise * o ISO-8601 year number. This has the same value as Y, except that if the "2008" * ISO week number (W) belongs to the previous or next year, that year * is used instead. * Y A full numeric representation of a year, 4 digits "2008" * y A two digit representation of a year "08" * a Lowercase Ante meridiem and Post meridiem "am" or "pm" * A Uppercase Ante meridiem and Post meridiem "AM" or "PM" * B Swatch Internet time "000" through "999" * g 12-hour format of an hour without leading zeros "1" through "12" * G 24-hour format of an hour without leading zeros "0" through "23" * h 12-hour format of an hour with leading zeros "01" through "12" * H 24-hour format of an hour with leading zeros "00" through "23" * i Minutes with leading zeros "00" to "59" * s Seconds, with leading zeros "00" through "59" * u Milliseconds "54321" * e Timezone identifier "UTC", "EST", "PST" * I Whether or not the date is in daylight saving time (uppercase i) "1" if Daylight Saving Time, "0" otherwise * O Difference to Greenwich time (GMT) in hours "+0200", "-0600" * P Difference to Greenwich time (GMT) with colon between hours and minutes "+02:00", "-06:00" * T Timezone abbreviation "UTC", "EST", "PST" * Z Timezone offset in seconds. The offset for timezones west of UTC is "-43200" through "50400" * always negative, and for those east of UTC is always positive. * c ISO 8601 date "2004-02-12T15:19:21+00:00" * r RFC 2822 formatted date "Thu, 21 Dec 2000 16:01:07 +0200" * U Seconds since the Unix Epoch (January 1 1970 00:00:00 GMT) "0" * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @return {String} A string representation of the current Date object. */ var formatReplace = function (context) { return function (m) { var formatString, override = false; if (m.charAt(0) === "\\" || m.substring(0, 2) === "%%") { return m.replace("\\", "").replace("%%", "%"); } override = normalizer.shouldOverrideDefaults(m); formatString = $D.normalizeFormat(m, context); if (formatString) { return context.toString(formatString, override); } }; }; $P._format = function (format) { var formatter = formatReplace(this); if (!format) { return this._toString(); } else { return format.replace(/(%|\\)?.|%%/g, formatter); } }; if (!$P.format) { $P.format = $P._format; } }()); (function () { "use strict"; var gFn = function (attr) { return function () { return this[attr]; }; }; var sFn = function (attr) { return function (val) { this[attr] = val; return this; }; }; var attrs = ["years", "months", "days", "hours", "minutes", "seconds", "milliseconds"]; var addSetFuncs = function (context, attrs) { for (var i = 0; i < attrs.length ; i++) { var $a = attrs[i], $b = $a.slice(0, 1).toUpperCase() + $a.slice(1); context.prototype[$a] = 0; context.prototype["get" + $b] = gFn($a); context.prototype["set" + $b] = sFn($a); } }; /** * new TimeSpan(milliseconds); * new TimeSpan(days, hours, minutes, seconds); * new TimeSpan(days, hours, minutes, seconds, milliseconds); */ var TimeSpan = function (days, hours, minutes, seconds, milliseconds) { if (arguments.length === 1 && typeof days === "number") { var orient = (days < 0) ? -1 : +1; var millsLeft = Math.abs(days); this.setDays(Math.floor(millsLeft / 86400000) * orient); millsLeft = millsLeft % 86400000; this.setHours(Math.floor(millsLeft / 3600000) * orient); millsLeft = millsLeft % 3600000; this.setMinutes(Math.floor(millsLeft / 60000) * orient); millsLeft = millsLeft % 60000; this.setSeconds(Math.floor(millsLeft / 1000) * orient); millsLeft = millsLeft % 1000; this.setMilliseconds(millsLeft * orient); } else { this.set(days, hours, minutes, seconds, milliseconds); } this.getTotalMilliseconds = function () { return (this.getDays() * 86400000) + (this.getHours() * 3600000) + (this.getMinutes() * 60000) + (this.getSeconds() * 1000); }; this.compareTo = function (time) { var t1 = new Date(1970, 1, 1, this.getHours(), this.getMinutes(), this.getSeconds()), t2; if (time === null) { t2 = new Date(1970, 1, 1, 0, 0, 0); } else { t2 = new Date(1970, 1, 1, time.getHours(), time.getMinutes(), time.getSeconds()); } return (t1 < t2) ? -1 : (t1 > t2) ? 1 : 0; }; this.equals = function (time) { return (this.compareTo(time) === 0); }; this.add = function (time) { return (time === null) ? this : this.addSeconds(time.getTotalMilliseconds() / 1000); }; this.subtract = function (time) { return (time === null) ? this : this.addSeconds(-time.getTotalMilliseconds() / 1000); }; this.addDays = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 86400000)); }; this.addHours = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 3600000)); }; this.addMinutes = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 60000)); }; this.addSeconds = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 1000)); }; this.addMilliseconds = function (n) { return new TimeSpan(this.getTotalMilliseconds() + n); }; this.get12HourHour = function () { return (this.getHours() > 12) ? this.getHours() - 12 : (this.getHours() === 0) ? 12 : this.getHours(); }; this.getDesignator = function () { return (this.getHours() < 12) ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator; }; this.toString = function (format) { this._toString = function () { if (this.getDays() !== null && this.getDays() > 0) { return this.getDays() + "." + this.getHours() + ":" + this.p(this.getMinutes()) + ":" + this.p(this.getSeconds()); } else { return this.getHours() + ":" + this.p(this.getMinutes()) + ":" + this.p(this.getSeconds()); } }; this.p = function (s) { return (s.toString().length < 2) ? "0" + s : s; }; var me = this; return format ? format.replace(/dd?|HH?|hh?|mm?|ss?|tt?/g, function (format) { switch (format) { case "d": return me.getDays(); case "dd": return me.p(me.getDays()); case "H": return me.getHours(); case "HH": return me.p(me.getHours()); case "h": return me.get12HourHour(); case "hh": return me.p(me.get12HourHour()); case "m": return me.getMinutes(); case "mm": return me.p(me.getMinutes()); case "s": return me.getSeconds(); case "ss": return me.p(me.getSeconds()); case "t": return ((me.getHours() < 12) ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator).substring(0, 1); case "tt": return (me.getHours() < 12) ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator; } } ) : this._toString(); }; return this; }; addSetFuncs(TimeSpan, attrs.slice(2)); TimeSpan.prototype.set = function (days, hours, minutes, seconds, milliseconds){ this.setDays(days || this.getDays()); this.setHours(hours || this.getHours()); this.setMinutes(minutes || this.getMinutes()); this.setSeconds(seconds || this.getSeconds()); this.setMilliseconds(milliseconds || this.getMilliseconds()); }; /** * Gets the time of day for this date instances. * @return {TimeSpan} TimeSpan */ Date.prototype.getTimeOfDay = function () { return new TimeSpan(0, this.getHours(), this.getMinutes(), this.getSeconds(), this.getMilliseconds()); }; Date.TimeSpan = TimeSpan; if (typeof window !== "undefined" ) { // keeping API compatible for v1.x window.TimeSpan = TimeSpan; } }()); (function () { "use strict"; var attrs = ["years", "months", "days", "hours", "minutes", "seconds", "milliseconds"]; var gFn = function (attr) { return function () { return this[attr]; }; }; var sFn = function (attr) { return function (val) { this[attr] = val; return this; }; }; var addSetFuncs = function (context, attrs) { for (var i = 0; i < attrs.length ; i++) { var $a = attrs[i], $b = $a.slice(0, 1).toUpperCase() + $a.slice(1); context.prototype[$a] = 0; context.prototype["get" + $b] = gFn($a); context.prototype["set" + $b] = sFn($a); } }; var setMonthsAndYears = function (orient, d1, d2, context) { function inc() { d1.addMonths(-orient); context.months++; if (context.months === 12) { context.years++; context.months = 0; } } if (orient === +1) { while (d1 > d2) { inc(); } } else { while (d1 < d2) { inc(); } } context.months--; context.months *= orient; context.years *= orient; }; var adjustForDST = function(orient, startDate, endDate) { var hasDSTMismatch = (false === (startDate.isDaylightSavingTime() === endDate.isDaylightSavingTime())); if (hasDSTMismatch && orient === 1) { startDate.addHours(-1); } else if (hasDSTMismatch) { startDate.addHours(1); } }; /** * TimePeriod(startDate, endDate); * TimePeriod(years, months, days, hours, minutes, seconds, milliseconds); */ var TimePeriod = function (years, months, days, hours, minutes, seconds, milliseconds) { if (arguments.length === 7) { this.set(years, months, days, hours, minutes, seconds, milliseconds); } else if (arguments.length === 2 && arguments[0] instanceof Date && arguments[1] instanceof Date) { var startDate = arguments[0].clone(); var endDate = arguments[1].clone(); var orient = (startDate > endDate) ? +1 : -1; this.dates = { start: arguments[0].clone(), end: arguments[1].clone() }; setMonthsAndYears(orient, startDate, endDate, this); adjustForDST(orient, startDate, endDate); // // TODO - adjust for DST var diff = endDate - startDate; if (diff !== 0) { var ts = new TimeSpan(diff); this.set(this.years, this.months, ts.getDays(), ts.getHours(), ts.getMinutes(), ts.getSeconds(), ts.getMilliseconds()); } } return this; }; // create all the set functions. addSetFuncs(TimePeriod, attrs); TimePeriod.prototype.set = function (years, months, days, hours, minutes, seconds, milliseconds){ this.setYears(years || this.getYears()); this.setMonths(months || this.getMonths()); this.setDays(days || this.getDays()); this.setHours(hours || this.getHours()); this.setMinutes(minutes || this.getMinutes()); this.setSeconds(seconds || this.getSeconds()); this.setMilliseconds(milliseconds || this.getMilliseconds()); }; Date.TimePeriod = TimePeriod; if (typeof window !== "undefined") { // keeping API compatible for v1.x window.TimePeriod = TimePeriod; } }()); ================================================ FILE: build/date-ar-MA.js ================================================ /** * @overview datejs * @version 1.0.0-rc3 * @author Gregory Wild-Smith * @copyright 2015 Gregory Wild-Smith * @license MIT * @homepage https://github.com/abritinthebay/datejs */ /* * DateJS Culture String File * Country Code: ar-MA * Name: Arabic (Morocco) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["ar-MA"] = { "name": "ar-MA", "englishName": "Arabic (Morocco)", "nativeName": "العربية (المملكة المغربية)", "Sunday": "الاحد", "Monday": "الاثنين", "Tuesday": "الثلاثاء", "Wednesday": "الاربعاء", "Thursday": "الخميس", "Friday": "الجمعة", "Saturday": "السبت", "Sun": "الاحد", "Mon": "الاثنين", "Tue": "الثلاثاء", "Wed": "الاربعاء", "Thu": "الخميس", "Fri": "الجمعة", "Sat": "السبت", "Su": "أ", "Mo": "ا", "Tu": "ث", "We": "أ", "Th": "خ", "Fr": "ج", "Sa": "س", "S_Sun_Initial": "أ", "M_Mon_Initial": "ا", "T_Tue_Initial": "ث", "W_Wed_Initial": "أ", "T_Thu_Initial": "خ", "F_Fri_Initial": "ج", "S_Sat_Initial": "س", "January": "يناير", "February": "فبراير", "March": "مارس", "April": "ابريل", "May": "ماي", "June": "يونيو", "July": "يوليوز", "August": "غشت", "September": "شتنبر", "October": "اكتوبر", "November": "نونبر", "December": "دجنبر", "Jan_Abbr": "يناير", "Feb_Abbr": "فبراير", "Mar_Abbr": "مارس", "Apr_Abbr": "ابريل", "May_Abbr": "ماي", "Jun_Abbr": "يونيو", "Jul_Abbr": "يوليوز", "Aug_Abbr": "غشت", "Sep_Abbr": "شتنبر", "Oct_Abbr": "اكتوبر", "Nov_Abbr": "نونبر", "Dec_Abbr": "دجنبر", "AM": "ص", "PM": "م", "firstDayOfWeek": 1, "twoDigitYearMax": 2029, "mdy": "dmy", "M/d/yyyy": "dd-MM-yyyy", "dddd, MMMM dd, yyyy": "dd MMMM, yyyy", "h:mm tt": "H:mm", "h:mm:ss tt": "H:mm:ss", "dddd, MMMM dd, yyyy h:mm:ss tt": "dd MMMM, yyyy H:mm:ss", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "dd MMMM", "MMMM, yyyy": "MMMM, yyyy", "/jan(uary)?/": "يناير", "/feb(ruary)?/": "فبراير", "/mar(ch)?/": "مارس", "/apr(il)?/": "ابريل", "/may/": "ماي", "/jun(e)?/": "يونيو", "/jul(y)?/": "يوليوز", "/aug(ust)?/": "غشت", "/sep(t(ember)?)?/": "شتنبر", "/oct(ober)?/": "اكتوبر", "/nov(ember)?/": "نونبر", "/dec(ember)?/": "دجنبر", "/^su(n(day)?)?/": "^الاحد", "/^mo(n(day)?)?/": "^ا(1)?", "/^tu(e(s(day)?)?)?/": "^الثلاثاء", "/^we(d(nesday)?)?/": "^الاربعاء", "/^th(u(r(s(day)?)?)?)?/": "^الخميس", "/^fr(i(day)?)?/": "^الجمعة", "/^sa(t(urday)?)?/": "^السبت", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "ar-MA"; /** * @overview datejs * @version 1.0.0-rc3 * @author Gregory Wild-Smith * @copyright 2015 Gregory Wild-Smith * @license MIT * @homepage https://github.com/abritinthebay/datejs */(function () { var $D = Date; var lang = Date.CultureStrings ? Date.CultureStrings.lang : null; var loggedKeys = {}; // for debug purposes. var getText = { getFromKey: function (key, countryCode) { var output; if (Date.CultureStrings && Date.CultureStrings[countryCode] && Date.CultureStrings[countryCode][key]) { output = Date.CultureStrings[countryCode][key]; } else { output = getText.buildFromDefault(key); } if (key.charAt(0) === "/") { // Assume it's a regex output = getText.buildFromRegex(key, countryCode); } return output; }, getFromObjectValues: function (obj, countryCode) { var key, output = {}; for(key in obj) { if (obj.hasOwnProperty(key)) { output[key] = getText.getFromKey(obj[key], countryCode); } } return output; }, getFromObjectKeys: function (obj, countryCode) { var key, output = {}; for(key in obj) { if (obj.hasOwnProperty(key)) { output[getText.getFromKey(key, countryCode)] = obj[key]; } } return output; }, getFromArray: function (arr, countryCode) { var output = []; for (var i=0; i < arr.length; i++){ if (i in arr) { output[i] = getText.getFromKey(arr[i], countryCode); } } return output; }, buildFromDefault: function (key) { var output, length, split, last; switch(key) { case "name": output = "en-US"; break; case "englishName": output = "English (United States)"; break; case "nativeName": output = "English (United States)"; break; case "twoDigitYearMax": output = 2049; break; case "firstDayOfWeek": output = 0; break; default: output = key; split = key.split("_"); length = split.length; if (length > 1 && key.charAt(0) !== "/") { // if the key isn't a regex and it has a split. last = split[(length - 1)].toLowerCase(); if (last === "initial" || last === "abbr") { output = split[0]; } } break; } return output; }, buildFromRegex: function (key, countryCode) { var output; if (Date.CultureStrings && Date.CultureStrings[countryCode] && Date.CultureStrings[countryCode][key]) { output = new RegExp(Date.CultureStrings[countryCode][key], "i"); } else { output = new RegExp(key.replace(new RegExp("/", "g"),""), "i"); } return output; } }; var shallowMerge = function (obj1, obj2) { for (var attrname in obj2) { if (obj2.hasOwnProperty(attrname)) { obj1[attrname] = obj2[attrname]; } } }; var __ = function (key, language) { var countryCode = (language) ? language : lang; loggedKeys[key] = key; if (typeof key === "object") { if (key instanceof Array) { return getText.getFromArray(key, countryCode); } else { return getText.getFromObjectKeys(key, countryCode); } } else { return getText.getFromKey(key, countryCode); } }; var loadI18nScript = function (code) { // paatterned after jQuery's getScript. var url = Date.Config.i18n + code + ".js"; var head = document.getElementsByTagName("head")[0] || document.documentElement; var script = document.createElement("script"); script.src = url; var completed = false; var events = { done: function (){} // placeholder function }; // Attach handlers for all browsers script.onload = script.onreadystatechange = function() { if ( !completed && (!this.readyState || this.readyState === "loaded" || this.readyState === "complete") ) { events.done(); head.removeChild(script); } }; setTimeout(function() { head.insertBefore(script, head.firstChild); }, 0); // allows return to execute first return { done: function (cb) { events.done = function() { if (cb) { setTimeout(cb,0); } }; } }; }; var buildInfo = { buildFromMethodHash: function (obj) { var key; for(key in obj) { if (obj.hasOwnProperty(key)) { obj[key] = buildInfo[obj[key]](); } } return obj; }, timeZoneDST: function () { var DST = { "CHADT": "+1345", "NZDT": "+1300", "AEDT": "+1100", "ACDT": "+1030", "AZST": "+0500", "IRDT": "+0430", "EEST": "+0300", "CEST": "+0200", "BST": "+0100", "PMDT": "-0200", "ADT": "-0300", "NDT": "-0230", "EDT": "-0400", "CDT": "-0500", "MDT": "-0600", "PDT": "-0700", "AKDT": "-0800", "HADT": "-0900" }; return __(DST); }, timeZoneStandard: function () { var standard = { "LINT": "+1400", "TOT": "+1300", "CHAST": "+1245", "NZST": "+1200", "NFT": "+1130", "SBT": "+1100", "AEST": "+1000", "ACST": "+0930", "JST": "+0900", "CWST": "+0845", "CT": "+0800", "ICT": "+0700", "MMT": "+0630", "BST": "+0600", "NPT": "+0545", "IST": "+0530", "PKT": "+0500", "AFT": "+0430", "MSK": "+0400", "IRST": "+0330", "FET": "+0300", "EET": "+0200", "CET": "+0100", "GMT": "+0000", "UTC": "+0000", "CVT": "-0100", "GST": "-0200", "BRT": "-0300", "NST": "-0330", "AST": "-0400", "EST": "-0500", "CST": "-0600", "MST": "-0700", "PST": "-0800", "AKST": "-0900", "MIT": "-0930", "HST": "-1000", "SST": "-1100", "BIT": "-1200" }; return __(standard); }, timeZones: function (data) { var zone; data.timezones = []; for (zone in data.abbreviatedTimeZoneStandard) { if (data.abbreviatedTimeZoneStandard.hasOwnProperty(zone)) { data.timezones.push({ name: zone, offset: data.abbreviatedTimeZoneStandard[zone]}); } } for (zone in data.abbreviatedTimeZoneDST) { if (data.abbreviatedTimeZoneDST.hasOwnProperty(zone)) { data.timezones.push({ name: zone, offset: data.abbreviatedTimeZoneDST[zone], dst: true}); } } return data.timezones; }, days: function () { return __(["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"]); }, dayAbbr: function () { return __(["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"]); }, dayShortNames: function () { return __(["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"]); }, dayFirstLetters: function () { return __(["S_Sun_Initial", "M_Mon_Initial", "T_Tues_Initial", "W_Wed_Initial", "T_Thu_Initial", "F_Fri_Initial", "S_Sat_Initial"]); }, months: function () { return __(["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"]); }, monthAbbr: function () { return __(["Jan_Abbr", "Feb_Abbr", "Mar_Abbr", "Apr_Abbr", "May_Abbr", "Jun_Abbr", "Jul_Abbr", "Aug_Abbr", "Sep_Abbr", "Oct_Abbr", "Nov_Abbr", "Dec_Abbr"]); }, formatPatterns: function () { return getText.getFromObjectValues({ shortDate: "M/d/yyyy", longDate: "dddd, MMMM dd, yyyy", shortTime: "h:mm tt", longTime: "h:mm:ss tt", fullDateTime: "dddd, MMMM dd, yyyy h:mm:ss tt", sortableDateTime: "yyyy-MM-ddTHH:mm:ss", universalSortableDateTime: "yyyy-MM-dd HH:mm:ssZ", rfc1123: "ddd, dd MMM yyyy HH:mm:ss", monthDay: "MMMM dd", yearMonth: "MMMM, yyyy" }, Date.i18n.currentLanguage()); }, regex: function () { return getText.getFromObjectValues({ inTheMorning: "/( in the )(morn(ing)?)\\b/", thisMorning: "/(this )(morn(ing)?)\\b/", amThisMorning: "/(\b\\d(am)? )(this )(morn(ing)?)/", inTheEvening: "/( in the )(even(ing)?)\\b/", thisEvening: "/(this )(even(ing)?)\\b/", pmThisEvening: "/(\b\\d(pm)? )(this )(even(ing)?)/", jan: "/jan(uary)?/", feb: "/feb(ruary)?/", mar: "/mar(ch)?/", apr: "/apr(il)?/", may: "/may/", jun: "/jun(e)?/", jul: "/jul(y)?/", aug: "/aug(ust)?/", sep: "/sep(t(ember)?)?/", oct: "/oct(ober)?/", nov: "/nov(ember)?/", dec: "/dec(ember)?/", sun: "/^su(n(day)?)?/", mon: "/^mo(n(day)?)?/", tue: "/^tu(e(s(day)?)?)?/", wed: "/^we(d(nesday)?)?/", thu: "/^th(u(r(s(day)?)?)?)?/", fri: "/fr(i(day)?)?/", sat: "/^sa(t(urday)?)?/", future: "/^next/", past: "/^last|past|prev(ious)?/", add: "/^(\\+|aft(er)?|from|hence)/", subtract: "/^(\\-|bef(ore)?|ago)/", yesterday: "/^yes(terday)?/", today: "/^t(od(ay)?)?/", tomorrow: "/^tom(orrow)?/", now: "/^n(ow)?/", millisecond: "/^ms|milli(second)?s?/", second: "/^sec(ond)?s?/", minute: "/^mn|min(ute)?s?/", hour: "/^h(our)?s?/", week: "/^w(eek)?s?/", month: "/^m(onth)?s?/", day: "/^d(ay)?s?/", year: "/^y(ear)?s?/", shortMeridian: "/^(a|p)/", longMeridian: "/^(a\\.?m?\\.?|p\\.?m?\\.?)/", timezone: "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/", ordinalSuffix: "/^\\s*(st|nd|rd|th)/", timeContext: "/^\\s*(\\:|a(?!u|p)|p)/" }, Date.i18n.currentLanguage()); } }; var CultureInfo = function () { var info = getText.getFromObjectValues({ name: "name", englishName: "englishName", nativeName: "nativeName", amDesignator: "AM", pmDesignator: "PM", firstDayOfWeek: "firstDayOfWeek", twoDigitYearMax: "twoDigitYearMax", dateElementOrder: "mdy" }, Date.i18n.currentLanguage()); var constructedInfo = buildInfo.buildFromMethodHash({ dayNames: "days", abbreviatedDayNames: "dayAbbr", shortestDayNames: "dayShortNames", firstLetterDayNames: "dayFirstLetters", monthNames: "months", abbreviatedMonthNames: "monthAbbr", formatPatterns: "formatPatterns", regexPatterns: "regex", abbreviatedTimeZoneDST: "timeZoneDST", abbreviatedTimeZoneStandard: "timeZoneStandard" }); shallowMerge(info, constructedInfo); buildInfo.timeZones(info); return info; }; $D.i18n = { __: function (key, lang) { return __(key, lang); }, currentLanguage: function () { return lang || "en-US"; }, setLanguage: function (code, force, cb) { var async = false; if (force || code === "en-US" || (!!Date.CultureStrings && !!Date.CultureStrings[code])) { lang = code; Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings.lang = code; Date.CultureInfo = new CultureInfo(); } else { if (!(!!Date.CultureStrings && !!Date.CultureStrings[code])) { if (typeof exports !== "undefined" && this.exports !== exports) { // we're in a Node enviroment, load it using require try { require("../i18n/" + code + ".js"); lang = code; Date.CultureStrings.lang = code; Date.CultureInfo = new CultureInfo(); } catch (e) { // var str = "The language for '" + code + "' could not be loaded by Node. It likely does not exist."; throw new Error("The DateJS IETF language tag '" + code + "' could not be loaded by Node. It likely does not exist."); } } else if (Date.Config && Date.Config.i18n) { // we know the location of the files, so lets load them async = true; loadI18nScript(code).done(function(){ lang = code; Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings.lang = code; Date.CultureInfo = new CultureInfo(); $D.Parsing.Normalizer.buildReplaceData(); // because this is async if ($D.Grammar) { $D.Grammar.buildGrammarFormats(); // so we can parse those strings... } if (cb) { setTimeout(cb,0); } }); } else { Date.console.error("The DateJS IETF language tag '" + code + "' is not available and has not been loaded."); return false; } } } $D.Parsing.Normalizer.buildReplaceData(); // rebuild normalizer strings if ($D.Grammar) { $D.Grammar.buildGrammarFormats(); // so we can parse those strings... } if (!async && cb) { setTimeout(cb,0); } }, getLoggedKeys: function () { return loggedKeys; }, updateCultureInfo: function () { Date.CultureInfo = new CultureInfo(); } }; $D.i18n.updateCultureInfo(); // run automatically }()); (function () { var $D = Date, $P = $D.prototype, p = function (s, l) { if (!l) { l = 2; } return ("000" + s).slice(l * -1); }; if (typeof window !== "undefined" && typeof window.console !== "undefined" && typeof window.console.log !== "undefined") { $D.console = console; // used only to raise non-critical errors if available } else { // set mock so we don't give errors. $D.console = { log: function(){}, error: function(){} }; } $D.Config = $D.Config || {}; $D.initOverloads = function() { /** * Overload of Date.now. Allows an alternate call for Date.now where it returns the * current Date as an object rather than just milliseconds since the Unix Epoch. * * Also provides an implementation of now() for browsers (IE<9) that don't have it. * * Backwards compatible so with work with either: * Date.now() [returns ms] * or * Date.now(true) [returns Date] */ if (!$D.now) { $D._now = function now() { return new Date().getTime(); }; } else if (!$D._now) { $D._now = $D.now; } $D.now = function (returnObj) { if (returnObj) { return $D.present(); } else { return $D._now(); } }; if ( !$P.toISOString ) { $P.toISOString = function() { return this.getUTCFullYear() + "-" + p(this.getUTCMonth() + 1) + "-" + p(this.getUTCDate()) + "T" + p(this.getUTCHours()) + ":" + p(this.getUTCMinutes()) + ":" + p(this.getUTCSeconds()) + "." + String( (this.getUTCMilliseconds()/1000).toFixed(3)).slice(2, 5) + "Z"; }; } // private if ( $P._toString === undefined ){ $P._toString = $P.toString; } }; $D.initOverloads(); /** * Gets a date that is set to the current date. The time is set to the start of the day (00:00 or 12:00 AM). * @return {Date} The current date. */ $D.today = function () { return new Date().clearTime(); }; /** * Gets a date that is set to the current date and time (same as new Date, but chainable) * @return {Date} The current date. */ $D.present = function () { return new Date(); }; /** * Compares the first date to the second date and returns an number indication of their relative values. * @param {Date} First Date object to compare [Required]. * @param {Date} Second Date object to compare to [Required]. * @return {Number} -1 = date1 is lessthan date2. 0 = values are equal. 1 = date1 is greaterthan date2. */ $D.compare = function (date1, date2) { if (isNaN(date1) || isNaN(date2)) { throw new Error(date1 + " - " + date2); } else if (date1 instanceof Date && date2 instanceof Date) { return (date1 < date2) ? -1 : (date1 > date2) ? 1 : 0; } else { throw new TypeError(date1 + " - " + date2); } }; /** * Compares the first Date object to the second Date object and returns true if they are equal. * @param {Date} First Date object to compare [Required] * @param {Date} Second Date object to compare to [Required] * @return {Boolean} true if dates are equal. false if they are not equal. */ $D.equals = function (date1, date2) { return (date1.compareTo(date2) === 0); }; /** * Gets the language appropriate day name when given the day number(0-6) * eg - 0 == Sunday * @return {String} The day name */ $D.getDayName = function (n) { return Date.CultureInfo.dayNames[n]; }; /** * Gets the day number (0-6) if given a CultureInfo specific string which is a valid dayName, abbreviatedDayName or shortestDayName (two char). * @param {String} The name of the day (eg. "Monday, "Mon", "tuesday", "tue", "We", "we"). * @return {Number} The day number */ $D.getDayNumberFromName = function (name) { var n = Date.CultureInfo.dayNames, m = Date.CultureInfo.abbreviatedDayNames, o = Date.CultureInfo.shortestDayNames, s = name.toLowerCase(); for (var i = 0; i < n.length; i++) { if (n[i].toLowerCase() === s || m[i].toLowerCase() === s || o[i].toLowerCase() === s) { return i; } } return -1; }; /** * Gets the month number (0-11) if given a Culture Info specific string which is a valid monthName or abbreviatedMonthName. * @param {String} The name of the month (eg. "February, "Feb", "october", "oct"). * @return {Number} The day number */ $D.getMonthNumberFromName = function (name) { var n = Date.CultureInfo.monthNames, m = Date.CultureInfo.abbreviatedMonthNames, s = name.toLowerCase(); for (var i = 0; i < n.length; i++) { if (n[i].toLowerCase() === s || m[i].toLowerCase() === s) { return i; } } return -1; }; /** * Gets the language appropriate month name when given the month number(0-11) * eg - 0 == January * @return {String} The month name */ $D.getMonthName = function (n) { return Date.CultureInfo.monthNames[n]; }; /** * Determines if the current date instance is within a LeapYear. * @param {Number} The year. * @return {Boolean} true if date is within a LeapYear, otherwise false. */ $D.isLeapYear = function (year) { return ((year % 4 === 0 && year % 100 !== 0) || year % 400 === 0); }; /** * Gets the number of days in the month, given a year and month value. Automatically corrects for LeapYear. * @param {Number} The year. * @param {Number} The month (0-11). * @return {Number} The number of days in the month. */ $D.getDaysInMonth = function (year, month) { if (!month && $D.validateMonth(year)) { month = year; year = Date.today().getFullYear(); } return [31, ($D.isLeapYear(year) ? 29 : 28), 31, 30, 31, 30, 31, 31, 30, 31, 30, 31][month]; }; $P.getDaysInMonth = function () { return $D.getDaysInMonth(this.getFullYear(), this.getMonth()); }; $D.getTimezoneAbbreviation = function (offset, dst) { var p, n = (dst || false) ? Date.CultureInfo.abbreviatedTimeZoneDST : Date.CultureInfo.abbreviatedTimeZoneStandard; for (p in n) { if (n.hasOwnProperty(p)) { if (n[p] === offset) { return p; } } } return null; }; $D.getTimezoneOffset = function (name, dst) { var i, a =[], z = Date.CultureInfo.timezones; if (!name) { name = (new Date()).getTimezone();} for (i = 0; i < z.length; i++) { if (z[i].name === name.toUpperCase()) { a.push(i); } } if (!z[a[0]]) { return null; } if (a.length === 1 || !dst) { return z[a[0]].offset; } else { for (i=0; i < a.length; i++) { if (z[a[i]].dst) { return z[a[i]].offset; } } } }; $D.getQuarter = function (d) { d = d || new Date(); // If no date supplied, use today var q = [1,2,3,4]; return q[Math.floor(d.getMonth() / 3)]; // ~~~ is a bitwise op. Faster than Math.floor }; $D.getDaysLeftInQuarter = function (d) { d = d || new Date(); var qEnd = new Date(d); qEnd.setMonth(qEnd.getMonth() + 3 - qEnd.getMonth() % 3, 0); return Math.floor((qEnd - d) / 8.64e7); }; // private var validate = function (n, min, max, name) { name = name ? name : "Object"; if (typeof n === "undefined") { return false; } else if (typeof n !== "number") { throw new TypeError(n + " is not a Number."); } else if (n < min || n > max) { // As failing validation is *not* an exceptional circumstance // lets not throw a RangeError Exception here. // It's semantically correct but it's not sensible. return false; } return true; }; /** * Validates the number is within an acceptable range for milliseconds [0-999]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateMillisecond = function (value) { return validate(value, 0, 999, "millisecond"); }; /** * Validates the number is within an acceptable range for seconds [0-59]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateSecond = function (value) { return validate(value, 0, 59, "second"); }; /** * Validates the number is within an acceptable range for minutes [0-59]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateMinute = function (value) { return validate(value, 0, 59, "minute"); }; /** * Validates the number is within an acceptable range for hours [0-23]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateHour = function (value) { return validate(value, 0, 23, "hour"); }; /** * Validates the number is within an acceptable range for the days in a month [0-MaxDaysInMonth]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateDay = function (value, year, month) { if (year === undefined || year === null || month === undefined || month === null) { return false;} return validate(value, 1, $D.getDaysInMonth(year, month), "day"); }; /** * Validates the number is within an acceptable range for months [0-11]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateWeek = function (value) { return validate(value, 0, 53, "week"); }; /** * Validates the number is within an acceptable range for months [0-11]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateMonth = function (value) { return validate(value, 0, 11, "month"); }; /** * Validates the number is within an acceptable range for years. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateYear = function (value) { /** * Per ECMAScript spec the range of times supported by Date objects is * exactly -100,000,000 days to +100,000,000 days measured relative to * midnight at the beginning of 01 January, 1970 UTC. * This gives a range of 8,640,000,000,000,000 milliseconds to either * side of 01 January, 1970 UTC. * * Earliest possible date: Tue, 20 Apr 271,822 B.C. 00:00:00 UTC * Latest possible date: Sat, 13 Sep 275,760 00:00:00 UTC */ return validate(value, -271822, 275760, "year"); }; $D.validateTimezone = function(value) { var timezones = {"ACDT":1,"ACST":1,"ACT":1,"ADT":1,"AEDT":1,"AEST":1,"AFT":1,"AKDT":1,"AKST":1,"AMST":1,"AMT":1,"ART":1,"AST":1,"AWDT":1,"AWST":1,"AZOST":1,"AZT":1,"BDT":1,"BIOT":1,"BIT":1,"BOT":1,"BRT":1,"BST":1,"BTT":1,"CAT":1,"CCT":1,"CDT":1,"CEDT":1,"CEST":1,"CET":1,"CHADT":1,"CHAST":1,"CHOT":1,"ChST":1,"CHUT":1,"CIST":1,"CIT":1,"CKT":1,"CLST":1,"CLT":1,"COST":1,"COT":1,"CST":1,"CT":1,"CVT":1,"CWST":1,"CXT":1,"DAVT":1,"DDUT":1,"DFT":1,"EASST":1,"EAST":1,"EAT":1,"ECT":1,"EDT":1,"EEDT":1,"EEST":1,"EET":1,"EGST":1,"EGT":1,"EIT":1,"EST":1,"FET":1,"FJT":1,"FKST":1,"FKT":1,"FNT":1,"GALT":1,"GAMT":1,"GET":1,"GFT":1,"GILT":1,"GIT":1,"GMT":1,"GST":1,"GYT":1,"HADT":1,"HAEC":1,"HAST":1,"HKT":1,"HMT":1,"HOVT":1,"HST":1,"ICT":1,"IDT":1,"IOT":1,"IRDT":1,"IRKT":1,"IRST":1,"IST":1,"JST":1,"KGT":1,"KOST":1,"KRAT":1,"KST":1,"LHST":1,"LINT":1,"MAGT":1,"MART":1,"MAWT":1,"MDT":1,"MET":1,"MEST":1,"MHT":1,"MIST":1,"MIT":1,"MMT":1,"MSK":1,"MST":1,"MUT":1,"MVT":1,"MYT":1,"NCT":1,"NDT":1,"NFT":1,"NPT":1,"NST":1,"NT":1,"NUT":1,"NZDT":1,"NZST":1,"OMST":1,"ORAT":1,"PDT":1,"PET":1,"PETT":1,"PGT":1,"PHOT":1,"PHT":1,"PKT":1,"PMDT":1,"PMST":1,"PONT":1,"PST":1,"PYST":1,"PYT":1,"RET":1,"ROTT":1,"SAKT":1,"SAMT":1,"SAST":1,"SBT":1,"SCT":1,"SGT":1,"SLST":1,"SRT":1,"SST":1,"SYOT":1,"TAHT":1,"THA":1,"TFT":1,"TJT":1,"TKT":1,"TLT":1,"TMT":1,"TOT":1,"TVT":1,"UCT":1,"ULAT":1,"UTC":1,"UYST":1,"UYT":1,"UZT":1,"VET":1,"VLAT":1,"VOLT":1,"VOST":1,"VUT":1,"WAKT":1,"WAST":1,"WAT":1,"WEDT":1,"WEST":1,"WET":1,"WST":1,"YAKT":1,"YEKT":1,"Z":1}; return (timezones[value] === 1); }; $D.validateTimezoneOffset= function(value) { // timezones go from +14hrs to -12hrs, the +X hours are negative offsets. return (value > -841 && value < 721); }; }()); (function () { var $D = Date, $P = $D.prototype, p = function (s, l) { if (!l) { l = 2; } return ("000" + s).slice(l * -1); }; var validateConfigObject = function (obj) { var result = {}, self = this, prop, testFunc; testFunc = function (prop, func, value) { if (prop === "day") { var month = (obj.month !== undefined) ? obj.month : self.getMonth(); var year = (obj.year !== undefined) ? obj.year : self.getFullYear(); return $D[func](value, year, month); } else { return $D[func](value); } }; for (prop in obj) { if (Object.prototype.hasOwnProperty.call(obj, prop)) { var func = "validate" + prop.charAt(0).toUpperCase() + prop.slice(1); if ($D[func] && obj[prop] !== null && testFunc(prop, func, obj[prop])) { result[prop] = obj[prop]; } } } return result; }; /** * Resets the time of this Date object to 12:00 AM (00:00), which is the start of the day. * @param {Boolean} .clone() this date instance before clearing Time * @return {Date} this */ $P.clearTime = function () { this.setHours(0); this.setMinutes(0); this.setSeconds(0); this.setMilliseconds(0); return this; }; /** * Resets the time of this Date object to the current time ('now'). * @return {Date} this */ $P.setTimeToNow = function () { var n = new Date(); this.setHours(n.getHours()); this.setMinutes(n.getMinutes()); this.setSeconds(n.getSeconds()); this.setMilliseconds(n.getMilliseconds()); return this; }; /** * Returns a new Date object that is an exact date and time copy of the original instance. * @return {Date} A new Date instance */ $P.clone = function () { return new Date(this.getTime()); }; /** * Compares this instance to a Date object and returns an number indication of their relative values. * @param {Date} Date object to compare [Required] * @return {Number} -1 = this is lessthan date. 0 = values are equal. 1 = this is greaterthan date. */ $P.compareTo = function (date) { return Date.compare(this, date); }; /** * Compares this instance to another Date object and returns true if they are equal. * @param {Date} Date object to compare. If no date to compare, new Date() [now] is used. * @return {Boolean} true if dates are equal. false if they are not equal. */ $P.equals = function (date) { return Date.equals(this, (date !== undefined ? date : new Date())); }; /** * Determines if this instance is between a range of two dates or equal to either the start or end dates. * @param {Date} Start of range [Required] * @param {Date} End of range [Required] * @return {Boolean} true is this is between or equal to the start and end dates, else false */ $P.between = function (start, end) { return this.getTime() >= start.getTime() && this.getTime() <= end.getTime(); }; /** * Determines if this date occurs after the date to compare to. * @param {Date} Date object to compare. If no date to compare, new Date() ("now") is used. * @return {Boolean} true if this date instance is greater than the date to compare to (or "now"), otherwise false. */ $P.isAfter = function (date) { return this.compareTo(date || new Date()) === 1; }; /** * Determines if this date occurs before the date to compare to. * @param {Date} Date object to compare. If no date to compare, new Date() ("now") is used. * @return {Boolean} true if this date instance is less than the date to compare to (or "now"). */ $P.isBefore = function (date) { return (this.compareTo(date || new Date()) === -1); }; /** * Determines if the current Date instance occurs today. * @return {Boolean} true if this date instance is 'today', otherwise false. */ /** * Determines if the current Date instance occurs on the same Date as the supplied 'date'. * If no 'date' to compare to is provided, the current Date instance is compared to 'today'. * @param {date} Date object to compare. If no date to compare, the current Date ("now") is used. * @return {Boolean} true if this Date instance occurs on the same Day as the supplied 'date'. */ $P.isToday = $P.isSameDay = function (date) { return this.clone().clearTime().equals((date || new Date()).clone().clearTime()); }; /** * Adds the specified number of milliseconds to this instance. * @param {Number} The number of milliseconds to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addMilliseconds = function (value) { if (!value) { return this; } this.setTime(this.getTime() + value * 1); return this; }; /** * Adds the specified number of seconds to this instance. * @param {Number} The number of seconds to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addSeconds = function (value) { if (!value) { return this; } return this.addMilliseconds(value * 1000); }; /** * Adds the specified number of seconds to this instance. * @param {Number} The number of seconds to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addMinutes = function (value) { if (!value) { return this; } return this.addMilliseconds(value * 60000); // 60*1000 }; /** * Adds the specified number of hours to this instance. * @param {Number} The number of hours to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addHours = function (value) { if (!value) { return this; } return this.addMilliseconds(value * 3600000); // 60*60*1000 }; /** * Adds the specified number of days to this instance. * @param {Number} The number of days to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addDays = function (value) { if (!value) { return this; } this.setDate(this.getDate() + value * 1); return this; }; /** * Adds the specified number of weekdays (ie - not sat or sun) to this instance. * @param {Number} The number of days to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addWeekdays = function (value) { if (!value) { return this; } var day = this.getDay(); var weeks = (Math.ceil(Math.abs(value)/7)); if (day === 0 || day === 6) { if (value > 0) { this.next().monday(); this.addDays(-1); day = this.getDay(); } } if (value < 0) { while (value < 0) { this.addDays(-1); day = this.getDay(); if (day !== 0 && day !== 6) { value++; } } return this; } else if (value > 5 || (6-day) <= value) { value = value + (weeks * 2); } return this.addDays(value); }; /** * Adds the specified number of weeks to this instance. * @param {Number} The number of weeks to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addWeeks = function (value) { if (!value) { return this; } return this.addDays(value * 7); }; /** * Adds the specified number of months to this instance. * @param {Number} The number of months to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addMonths = function (value) { if (!value) { return this; } var n = this.getDate(); this.setDate(1); this.setMonth(this.getMonth() + value * 1); this.setDate(Math.min(n, $D.getDaysInMonth(this.getFullYear(), this.getMonth()))); return this; }; $P.addQuarters = function (value) { if (!value) { return this; } // note this will take you to the same point in the quarter as you are now. // i.e. - if you are 15 days into the quarter you'll be 15 days into the resulting one. // bonus: this allows adding fractional quarters return this.addMonths(value * 3); }; /** * Adds the specified number of years to this instance. * @param {Number} The number of years to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addYears = function (value) { if (!value) { return this; } return this.addMonths(value * 12); }; /** * Adds (or subtracts) to the value of the years, months, weeks, days, hours, minutes, seconds, milliseconds of the date instance using given configuration object. Positive and Negative values allowed. * Example

	Date.today().add( { days: 1, months: 1 } )

	new Date().add( { years: -1 } )
	
* @param {Object} Configuration object containing attributes (months, days, etc.) * @return {Date} this */ $P.add = function (config) { if (typeof config === "number") { this._orient = config; return this; } var x = config; if (x.day) { // If we should be a different date than today (eg: for 'tomorrow -1d', etc). // Should only effect parsing, not direct usage (eg, Finish and FinishExact) if ((x.day - this.getDate()) !== 0) { this.setDate(x.day); } } if (x.milliseconds) { this.addMilliseconds(x.milliseconds); } if (x.seconds) { this.addSeconds(x.seconds); } if (x.minutes) { this.addMinutes(x.minutes); } if (x.hours) { this.addHours(x.hours); } if (x.weeks) { this.addWeeks(x.weeks); } if (x.months) { this.addMonths(x.months); } if (x.years) { this.addYears(x.years); } if (x.days) { this.addDays(x.days); } return this; }; /** * Get the week number. Week one (1) is the week which contains the first Thursday of the year. Monday is considered the first day of the week. * The .getWeek() function does NOT convert the date to UTC. The local datetime is used. * Please use .getISOWeek() to get the week of the UTC converted date. * @return {Number} 1 to 53 */ $P.getWeek = function (utc) { // Create a copy of this date object var self, target = new Date(this.valueOf()); if (utc) { target.addMinutes(target.getTimezoneOffset()); self = target.clone(); } else { self = this; } // ISO week date weeks start on monday // so correct the day number var dayNr = (self.getDay() + 6) % 7; // ISO 8601 states that week 1 is the week // with the first thursday of that year. // Set the target date to the thursday in the target week target.setDate(target.getDate() - dayNr + 3); // Store the millisecond value of the target date var firstThursday = target.valueOf(); // Set the target to the first thursday of the year // First set the target to january first target.setMonth(0, 1); // Not a thursday? Correct the date to the next thursday if (target.getDay() !== 4) { target.setMonth(0, 1 + ((4 - target.getDay()) + 7) % 7); } // The weeknumber is the number of weeks between the // first thursday of the year and the thursday in the target week return 1 + Math.ceil((firstThursday - target) / 604800000); // 604800000 = 7 * 24 * 3600 * 1000 }; /** * Get the ISO 8601 week number. Week one ("01") is the week which contains the first Thursday of the year. Monday is considered the first day of the week. * The .getISOWeek() function does convert the date to it's UTC value. Please use .getWeek() to get the week of the local date. * @return {String} "01" to "53" */ $P.getISOWeek = function () { return p(this.getWeek(true)); }; /** * Moves the date to Monday of the week set. Week one (1) is the week which contains the first Thursday of the year. * @param {Number} A Number (1 to 53) that represents the week of the year. * @return {Date} this */ $P.setWeek = function (n) { if ((n - this.getWeek()) === 0) { if (this.getDay() !== 1) { return this.moveToDayOfWeek(1, (this.getDay() > 1 ? -1 : 1)); } else { return this; } } else { return this.moveToDayOfWeek(1, (this.getDay() > 1 ? -1 : 1)).addWeeks(n - this.getWeek()); } }; $P.setQuarter = function (qtr) { var month = Math.abs(((qtr-1) * 3) + 1); return this.setMonth(month, 1); }; $P.getQuarter = function () { return Date.getQuarter(this); }; $P.getDaysLeftInQuarter = function () { return Date.getDaysLeftInQuarter(this); }; /** * Moves the date to the next n'th occurrence of the dayOfWeek starting from the beginning of the month. The number (-1) is a magic number and will return the last occurrence of the dayOfWeek in the month. * @param {Number} The dayOfWeek to move to * @param {Number} The n'th occurrence to move to. Use (-1) to return the last occurrence in the month * @return {Date} this */ $P.moveToNthOccurrence = function (dayOfWeek, occurrence) { if (dayOfWeek === "Weekday") { if (occurrence > 0) { this.moveToFirstDayOfMonth(); if (this.is().weekday()) { occurrence -= 1; } } else if (occurrence < 0) { this.moveToLastDayOfMonth(); if (this.is().weekday()) { occurrence += 1; } } else { return this; } return this.addWeekdays(occurrence); } var shift = 0; if (occurrence > 0) { shift = occurrence - 1; } else if (occurrence === -1) { this.moveToLastDayOfMonth(); if (this.getDay() !== dayOfWeek) { this.moveToDayOfWeek(dayOfWeek, -1); } return this; } return this.moveToFirstDayOfMonth().addDays(-1).moveToDayOfWeek(dayOfWeek, +1).addWeeks(shift); }; var moveToN = function (getFunc, addFunc, nVal) { return function (value, orient) { var diff = (value - this[getFunc]() + nVal * (orient || +1)) % nVal; return this[addFunc]((diff === 0) ? diff += nVal * (orient || +1) : diff); }; }; /** * Move to the next or last dayOfWeek based on the orient value. * @param {Number} The dayOfWeek to move to * @param {Number} Forward (+1) or Back (-1). Defaults to +1. [Optional] * @return {Date} this */ $P.moveToDayOfWeek = moveToN("getDay", "addDays", 7); /** * Move to the next or last month based on the orient value. * @param {Number} The month to move to. 0 = January, 11 = December * @param {Number} Forward (+1) or Back (-1). Defaults to +1. [Optional] * @return {Date} this */ $P.moveToMonth = moveToN("getMonth", "addMonths", 12); /** * Get the Ordinate of the current day ("th", "st", "rd"). * @return {String} */ $P.getOrdinate = function () { var num = this.getDate(); return ord(num); }; /** * Get the Ordinal day (numeric day number) of the year, adjusted for leap year. * @return {Number} 1 through 365 (366 in leap years) */ $P.getOrdinalNumber = function () { return Math.ceil((this.clone().clearTime() - new Date(this.getFullYear(), 0, 1)) / 86400000) + 1; }; /** * Get the time zone abbreviation of the current date. * @return {String} The abbreviated time zone name (e.g. "EST") */ $P.getTimezone = function () { return $D.getTimezoneAbbreviation(this.getUTCOffset(), this.isDaylightSavingTime()); }; $P.setTimezoneOffset = function (offset) { var here = this.getTimezoneOffset(), there = Number(offset) * -6 / 10; return (there || there === 0) ? this.addMinutes(there - here) : this; }; $P.setTimezone = function (offset) { return this.setTimezoneOffset($D.getTimezoneOffset(offset)); }; /** * Indicates whether Daylight Saving Time is observed in the current time zone. * @return {Boolean} true|false */ $P.hasDaylightSavingTime = function () { return (Date.today().set({month: 0, day: 1}).getTimezoneOffset() !== Date.today().set({month: 6, day: 1}).getTimezoneOffset()); }; /** * Indicates whether this Date instance is within the Daylight Saving Time range for the current time zone. * @return {Boolean} true|false */ $P.isDaylightSavingTime = function () { return Date.today().set({month: 0, day: 1}).getTimezoneOffset() !== this.getTimezoneOffset(); }; /** * Get the offset from UTC of the current date. * @return {String} The 4-character offset string prefixed with + or - (e.g. "-0500") */ $P.getUTCOffset = function (offset) { var n = (offset || this.getTimezoneOffset()) * -10 / 6, r; if (n < 0) { r = (n - 10000).toString(); return r.charAt(0) + r.substr(2); } else { r = (n + 10000).toString(); return "+" + r.substr(1); } }; /** * Returns the number of milliseconds between this date and date. * @param {Date} Defaults to now * @return {Number} The diff in milliseconds */ $P.getElapsed = function (date) { return (date || new Date()) - this; }; /** * Set the value of year, month, day, hour, minute, second, millisecond of date instance using given configuration object. * Example

	Date.today().set( { day: 20, month: 1 } )

	new Date().set( { millisecond: 0 } )
	
* * @param {Object} Configuration object containing attributes (month, day, etc.) * @return {Date} this */ $P.set = function (config) { config = validateConfigObject.call(this, config); var key; for (key in config) { if (Object.prototype.hasOwnProperty.call(config, key)) { var name = key.charAt(0).toUpperCase() + key.slice(1); var addFunc, getFunc; if (key !== "week" && key !== "month" && key !== "timezone" && key !== "timezoneOffset") { name += "s"; } addFunc = "add" + name; getFunc = "get" + name; if (key === "month") { addFunc = addFunc + "s"; } else if (key === "year"){ getFunc = "getFullYear"; } if (key !== "day" && key !== "timezone" && key !== "timezoneOffset" && key !== "week" && key !== "hour") { this[addFunc](config[key] - this[getFunc]()); } else if ( key === "timezone"|| key === "timezoneOffset" || key === "week" || key === "hour") { this["set"+name](config[key]); } } } // day has to go last because you can't validate the day without first knowing the month if (config.day) { this.addDays(config.day - this.getDate()); } return this; }; /** * Moves the date to the first day of the month. * @return {Date} this */ $P.moveToFirstDayOfMonth = function () { return this.set({ day: 1 }); }; /** * Moves the date to the last day of the month. * @return {Date} this */ $P.moveToLastDayOfMonth = function () { return this.set({ day: $D.getDaysInMonth(this.getFullYear(), this.getMonth())}); }; /** * Converts the value of the current Date object to its equivalent string representation. * Format Specifiers * CUSTOM DATE AND TIME FORMAT STRINGS * Format Description Example * ------ --------------------------------------------------------------------------- ----------------------- * s The seconds of the minute between 0-59. "0" to "59" * ss The seconds of the minute with leading zero if required. "00" to "59" * * m The minute of the hour between 0-59. "0" or "59" * mm The minute of the hour with leading zero if required. "00" or "59" * * h The hour of the day between 1-12. "1" to "12" * hh The hour of the day with leading zero if required. "01" to "12" * * H The hour of the day between 0-23. "0" to "23" * HH The hour of the day with leading zero if required. "00" to "23" * * d The day of the month between 1 and 31. "1" to "31" * dd The day of the month with leading zero if required. "01" to "31" * ddd Abbreviated day name. Date.CultureInfo.abbreviatedDayNames. "Mon" to "Sun" * dddd The full day name. Date.CultureInfo.dayNames. "Monday" to "Sunday" * * M The month of the year between 1-12. "1" to "12" * MM The month of the year with leading zero if required. "01" to "12" * MMM Abbreviated month name. Date.CultureInfo.abbreviatedMonthNames. "Jan" to "Dec" * MMMM The full month name. Date.CultureInfo.monthNames. "January" to "December" * * yy The year as a two-digit number. "99" or "08" * yyyy The full four digit year. "1999" or "2008" * * t Displays the first character of the A.M./P.M. designator. "A" or "P" * Date.CultureInfo.amDesignator or Date.CultureInfo.pmDesignator * tt Displays the A.M./P.M. designator. "AM" or "PM" * Date.CultureInfo.amDesignator or Date.CultureInfo.pmDesignator * * S The ordinal suffix ("st, "nd", "rd" or "th") of the current day. "st, "nd", "rd" or "th" * * STANDARD DATE AND TIME FORMAT STRINGS * Format Description Example *------ --------------------------------------------------------------------------- ----------------------- * d The CultureInfo shortDate Format Pattern "M/d/yyyy" * D The CultureInfo longDate Format Pattern "dddd, MMMM dd, yyyy" * F The CultureInfo fullDateTime Format Pattern "dddd, MMMM dd, yyyy h:mm:ss tt" * m The CultureInfo monthDay Format Pattern "MMMM dd" * r The CultureInfo rfc1123 Format Pattern "ddd, dd MMM yyyy HH:mm:ss GMT" * s The CultureInfo sortableDateTime Format Pattern "yyyy-MM-ddTHH:mm:ss" * t The CultureInfo shortTime Format Pattern "h:mm tt" * T The CultureInfo longTime Format Pattern "h:mm:ss tt" * u The CultureInfo universalSortableDateTime Format Pattern "yyyy-MM-dd HH:mm:ssZ" * y The CultureInfo yearMonth Format Pattern "MMMM, yyyy" * * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @return {String} A string representation of the current Date object. */ var ord = function (n) { switch (n * 1) { case 1: case 21: case 31: return "st"; case 2: case 22: return "nd"; case 3: case 23: return "rd"; default: return "th"; } }; var parseStandardFormats = function (format) { var y, c = Date.CultureInfo.formatPatterns; switch (format) { case "d": return this.toString(c.shortDate); case "D": return this.toString(c.longDate); case "F": return this.toString(c.fullDateTime); case "m": return this.toString(c.monthDay); case "r": case "R": y = this.clone().addMinutes(this.getTimezoneOffset()); return y.toString(c.rfc1123) + " GMT"; case "s": return this.toString(c.sortableDateTime); case "t": return this.toString(c.shortTime); case "T": return this.toString(c.longTime); case "u": y = this.clone().addMinutes(this.getTimezoneOffset()); return y.toString(c.universalSortableDateTime); case "y": return this.toString(c.yearMonth); default: return false; } }; var parseFormatStringsClosure = function (context) { return function (m) { if (m.charAt(0) === "\\") { return m.replace("\\", ""); } switch (m) { case "hh": return p(context.getHours() < 13 ? (context.getHours() === 0 ? 12 : context.getHours()) : (context.getHours() - 12)); case "h": return context.getHours() < 13 ? (context.getHours() === 0 ? 12 : context.getHours()) : (context.getHours() - 12); case "HH": return p(context.getHours()); case "H": return context.getHours(); case "mm": return p(context.getMinutes()); case "m": return context.getMinutes(); case "ss": return p(context.getSeconds()); case "s": return context.getSeconds(); case "yyyy": return p(context.getFullYear(), 4); case "yy": return p(context.getFullYear()); case "y": return context.getFullYear(); case "E": case "dddd": return Date.CultureInfo.dayNames[context.getDay()]; case "ddd": return Date.CultureInfo.abbreviatedDayNames[context.getDay()]; case "dd": return p(context.getDate()); case "d": return context.getDate(); case "MMMM": return Date.CultureInfo.monthNames[context.getMonth()]; case "MMM": return Date.CultureInfo.abbreviatedMonthNames[context.getMonth()]; case "MM": return p((context.getMonth() + 1)); case "M": return context.getMonth() + 1; case "t": return context.getHours() < 12 ? Date.CultureInfo.amDesignator.substring(0, 1) : Date.CultureInfo.pmDesignator.substring(0, 1); case "tt": return context.getHours() < 12 ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator; case "S": return ord(context.getDate()); case "W": return context.getWeek(); case "WW": return context.getISOWeek(); case "Q": return "Q" + context.getQuarter(); case "q": return String(context.getQuarter()); case "z": return context.getTimezone(); case "Z": case "X": return Date.getTimezoneOffset(context.getTimezone()); case "ZZ": // Timezone offset in seconds return context.getTimezoneOffset() * -60; case "u": return context.getDay(); case "L": return ($D.isLeapYear(context.getFullYear())) ? 1 : 0; case "B": // Swatch Internet Time (.beats) return "@"+((context.getUTCSeconds() + (context.getUTCMinutes()*60) + ((context.getUTCHours()+1)*3600))/86.4); default: return m; } }; }; $P.toString = function (format, ignoreStandards) { // Standard Date and Time Format Strings. Formats pulled from CultureInfo file and // may vary by culture. if (!ignoreStandards && format && format.length === 1) { output = parseStandardFormats.call(this, format); if (output) { return output; } } var parseFormatStrings = parseFormatStringsClosure(this); return format ? format.replace(/((\\)?(dd?d?d?|MM?M?M?|yy?y?y?|hh?|HH?|mm?|ss?|tt?|S|q|Q|WW?W?W?)(?![^\[]*\]))/g, parseFormatStrings).replace(/\[|\]/g, "") : this._toString(); }; }()); /************************************************************* * SugarPak - Domain Specific Language - Syntactical Sugar * *************************************************************/ (function () { var $D = Date, $P = $D.prototype, $N = Number.prototype; // private $P._orient = +1; // private $P._nth = null; // private $P._is = false; // private $P._same = false; // private $P._isSecond = false; // private $N._dateElement = "days"; /** * Moves the date to the next instance of a date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.today().next().friday();
	Date.today().next().fri();
	Date.today().next().march();
	Date.today().next().mar();
	Date.today().next().week();
	
* * @return {Date} date */ $P.next = function () { this._move = true; this._orient = +1; return this; }; /** * Creates a new Date (Date.today()) and moves the date to the next instance of the date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.next().friday();
	Date.next().fri();
	Date.next().march();
	Date.next().mar();
	Date.next().week();
	
* * @return {Date} date */ $D.next = function () { return $D.today().next(); }; /** * Moves the date to the previous instance of a date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.today().last().friday();
	Date.today().last().fri();
	Date.today().last().march();
	Date.today().last().mar();
	Date.today().last().week();
	
* * @return {Date} date */ $P.last = $P.prev = $P.previous = function () { this._move = true; this._orient = -1; return this; }; /** * Creates a new Date (Date.today()) and moves the date to the previous instance of the date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.last().friday();
	Date.last().fri();
	Date.previous().march();
	Date.prev().mar();
	Date.last().week();
	
* * @return {Date} date */ $D.last = $D.prev = $D.previous = function () { return $D.today().last(); }; /** * Performs a equality check when followed by either a month name, day name or .weekday() function. * Example

	Date.today().is().friday(); // true|false
	Date.today().is().fri();
	Date.today().is().march();
	Date.today().is().mar();
	
* * @return {Boolean} true|false */ $P.is = function () { this._is = true; return this; }; /** * Determines if two date objects occur on/in exactly the same instance of the subsequent date part function. * The function .same() must be followed by a date part function (example: .day(), .month(), .year(), etc). * * An optional Date can be passed in the date part function. If now date is passed as a parameter, 'Now' is used. * * The following example demonstrates how to determine if two dates fall on the exact same day. * * Example

	var d1 = Date.today(); // today at 00:00
	var d2 = new Date();   // exactly now.

	// Do they occur on the same day?
	d1.same().day(d2); // true
	
	// Do they occur on the same hour?
	d1.same().hour(d2); // false, unless d2 hour is '00' (midnight).
	
	// What if it's the same day, but one year apart?
	var nextYear = Date.today().add(1).year();

	d1.same().day(nextYear); // false, because the dates must occur on the exact same day. 
	
* * Scenario: Determine if a given date occurs during some week period 2 months from now. * * Example

	var future = Date.today().add(2).months();
	return someDate.same().week(future); // true|false;
	
* * @return {Boolean} true|false */ $P.same = function () { this._same = true; this._isSecond = false; return this; }; /** * Determines if the current date/time occurs during Today. Must be preceded by the .is() function. * Example

	someDate.is().today();    // true|false
	new Date().is().today();  // true
	Date.today().is().today();// true
	Date.today().add(-1).day().is().today(); // false
	
* * @return {Boolean} true|false */ $P.today = function () { return this.same().day(); }; /** * Determines if the current date is a weekday. This function must be preceded by the .is() function. * Example

	Date.today().is().weekday(); // true|false
	
* * @return {Boolean} true|false */ $P.weekday = function () { if (this._nth) { return df("Weekday").call(this); } if (this._move) { return this.addWeekdays(this._orient); } if (this._is) { this._is = false; return (!this.is().sat() && !this.is().sun()); } return false; }; /** * Determines if the current date is on the weekend. This function must be preceded by the .is() function. * Example

	Date.today().is().weekend(); // true|false
	
* * @return {Boolean} true|false */ $P.weekend = function () { if (this._is) { this._is = false; return (this.is().sat() || this.is().sun()); } return false; }; /** * Sets the Time of the current Date instance. A string "6:15 pm" or config object {hour:18, minute:15} are accepted. * Example

	// Set time to 6:15pm with a String
	Date.today().at("6:15pm");

	// Set time to 6:15pm with a config object
	Date.today().at({hour:18, minute:15});
	
* * @return {Date} date */ $P.at = function (time) { return (typeof time === "string") ? $D.parse(this.toString("d") + " " + time) : this.set(time); }; /** * Creates a new Date() and adds this (Number) to the date based on the preceding date element function (eg. second|minute|hour|day|month|year). * Example

	// Undeclared Numbers must be wrapped with parentheses. Requirment of JavaScript.
	(3).days().fromNow();
	(6).months().fromNow();

	// Declared Number variables do not require parentheses. 
	var n = 6;
	n.months().fromNow();
	
* * @return {Date} A new Date instance */ $N.fromNow = $N.after = function (date) { var c = {}; c[this._dateElement] = this; return ((!date) ? new Date() : date.clone()).add(c); }; /** * Creates a new Date() and subtract this (Number) from the date based on the preceding date element function (eg. second|minute|hour|day|month|year). * Example

	// Undeclared Numbers must be wrapped with parentheses. Requirment of JavaScript.
	(3).days().ago();
	(6).months().ago();

	// Declared Number variables do not require parentheses. 
	var n = 6;
	n.months().ago();
	
* * @return {Date} A new Date instance */ $N.ago = $N.before = function (date) { var c = {}, s = (this._dateElement[this._dateElement.length-1] !== "s") ? this._dateElement + "s" : this._dateElement; c[s] = this * -1; return ((!date) ? new Date() : date.clone()).add(c); }; // Do NOT modify the following string tokens. These tokens are used to build dynamic functions. // All culture-specific strings can be found in the CultureInfo files. var dx = ("sunday monday tuesday wednesday thursday friday saturday").split(/\s/), mx = ("january february march april may june july august september october november december").split(/\s/), px = ("Millisecond Second Minute Hour Day Week Month Year Quarter Weekday").split(/\s/), pxf = ("Milliseconds Seconds Minutes Hours Date Week Month FullYear Quarter").split(/\s/), nth = ("final first second third fourth fifth").split(/\s/), de; /** * Returns an object literal of all the date parts. * Example

	var o = new Date().toObject();
	
	// { year: 2008, month: 4, week: 20, day: 13, hour: 18, minute: 9, second: 32, millisecond: 812 }
	
	// The object properties can be referenced directly from the object.
	
	alert(o.day);  // alerts "13"
	alert(o.year); // alerts "2008"
	
* * @return {Date} An object literal representing the original date object. */ $P.toObject = function () { var o = {}; for (var i = 0; i < px.length; i++) { if (this["get" + pxf[i]]) { o[px[i].toLowerCase()] = this["get" + pxf[i]](); } } return o; }; /** * Returns a date created from an object literal. Ignores the .week property if set in the config. * Example

	var o = new Date().toObject();
	
	return Date.fromObject(o); // will return the same date. 

	var o2 = {month: 1, day: 20, hour: 18}; // birthday party!
	Date.fromObject(o2);
	
* * @return {Date} An object literal representing the original date object. */ $D.fromObject = function(config) { config.week = null; return Date.today().set(config); }; // Create day name functions and abbreviated day name functions (eg. monday(), friday(), fri()). var df = function (n) { return function () { if (this._is) { this._is = false; return this.getDay() === n; } if (this._move) { this._move = null; } if (this._nth !== null) { // If the .second() function was called earlier, remove the _orient // from the date, and then continue. // This is required because 'second' can be used in two different context. // // Example // // Date.today().add(1).second(); // Date.march().second().monday(); // // Things get crazy with the following... // Date.march().add(1).second().second().monday(); // but it works!! // if (this._isSecond) { this.addSeconds(this._orient * -1); } // make sure we reset _isSecond this._isSecond = false; var ntemp = this._nth; this._nth = null; var temp = this.clone().moveToLastDayOfMonth(); this.moveToNthOccurrence(n, ntemp); if (this > temp) { throw new RangeError($D.getDayName(n) + " does not occur " + ntemp + " times in the month of " + $D.getMonthName(temp.getMonth()) + " " + temp.getFullYear() + "."); } return this; } return this.moveToDayOfWeek(n, this._orient); }; }; var sdf = function (n) { return function () { var t = $D.today(), shift = n - t.getDay(); if (n === 0 && Date.CultureInfo.firstDayOfWeek === 1 && t.getDay() !== 0) { shift = shift + 7; } return t.addDays(shift); }; }; // Create month name functions and abbreviated month name functions (eg. january(), march(), mar()). var month_instance_functions = function (n) { return function () { if (this._is) { this._is = false; return this.getMonth() === n; } return this.moveToMonth(n, this._orient); }; }; var month_static_functions = function (n) { return function () { return $D.today().set({ month: n, day: 1 }); }; }; var processTerms = function (names, staticFunc, instanceFunc) { for (var i = 0; i < names.length; i++) { // Create constant static Name variables. $D[names[i].toUpperCase()] = $D[names[i].toUpperCase().substring(0, 3)] = i; // Create Name functions. $D[names[i]] = $D[names[i].substring(0, 3)] = staticFunc(i); // Create Name instance functions. $P[names[i]] = $P[names[i].substring(0, 3)] = instanceFunc(i); } }; processTerms(dx, sdf, df); processTerms(mx, month_static_functions, month_instance_functions); // Create date element functions and plural date element functions used with Date (eg. day(), days(), months()). var ef = function (j) { return function () { // if the .second() function was called earlier, the _orient // has alread been added. Just return this and reset _isSecond. if (this._isSecond) { this._isSecond = false; return this; } if (this._same) { this._same = this._is = false; var o1 = this.toObject(), o2 = (arguments[0] || new Date()).toObject(), v = "", k = j.toLowerCase(); // the substr trick with -1 doesn't work in IE8 or less k = (k[k.length-1] === "s") ? k.substring(0,k.length-1) : k; for (var m = (px.length - 1); m > -1; m--) { v = px[m].toLowerCase(); if (o1[v] !== o2[v]) { return false; } if (k === v) { break; } } return true; } if (j.substring(j.length - 1) !== "s") { j += "s"; } if (this._move) { this._move = null; } return this["add" + j](this._orient); }; }; var nf = function (n) { return function () { this._dateElement = n; return this; }; }; for (var k = 0; k < px.length; k++) { de = px[k].toLowerCase(); if(de !== "weekday") { // Create date element functions and plural date element functions used with Date (eg. day(), days(), months()). $P[de] = $P[de + "s"] = ef(px[k]); // Create date element functions and plural date element functions used with Number (eg. day(), days(), months()). $N[de] = $N[de + "s"] = nf(de + "s"); } } $P._ss = ef("Second"); var nthfn = function (n) { return function (dayOfWeek) { if (this._same) { return this._ss(arguments[0]); } if (dayOfWeek || dayOfWeek === 0) { return this.moveToNthOccurrence(dayOfWeek, n); } this._nth = n; // if the operator is 'second' add the _orient, then deal with it later... if (n === 2 && (dayOfWeek === undefined || dayOfWeek === null)) { this._isSecond = true; return this.addSeconds(this._orient); } return this; }; }; for (var l = 0; l < nth.length; l++) { $P[nth[l]] = (l === 0) ? nthfn(-1) : nthfn(l); } }()); (function () { "use strict"; Date.Parsing = { Exception: function (s) { this.message = "Parse error at '" + s.substring(0, 10) + " ...'"; } }; var $P = Date.Parsing; var dayOffsets = { standard: [0,31,59,90,120,151,181,212,243,273,304,334], leap: [0,31,60,91,121,152,182,213,244,274,305,335] }; $P.isLeapYear = function(year) { return ((year % 4 === 0) && (year % 100 !== 0)) || (year % 400 === 0); }; var utils = { multiReplace : function (str, hash ) { var key; for (key in hash) { if (Object.prototype.hasOwnProperty.call(hash, key)) { var regex; if (typeof hash[key] === "function") { } else { regex = (hash[key] instanceof RegExp) ? hash[key] : new RegExp(hash[key], "g"); } str = str.replace(regex, key); } } return str; }, getDayOfYearFromWeek : function (obj) { var d, jan4, offset; obj.weekDay = (!obj.weekDay && obj.weekDay !== 0) ? 1 : obj.weekDay; d = new Date(obj.year, 0, 4); jan4 = d.getDay() === 0 ? 7 : d.getDay(); // JS is 0 indexed on Sunday. offset = jan4+3; obj.dayOfYear = ((obj.week * 7) + (obj.weekDay === 0 ? 7 : obj.weekDay))-offset; return obj; }, getDayOfYear : function (obj, dayOffset) { if (!obj.dayOfYear) { obj = utils.getDayOfYearFromWeek(obj); } for (var i=0;i <= dayOffset.length;i++) { if (obj.dayOfYear < dayOffset[i] || i === dayOffset.length) { obj.day = obj.day ? obj.day : (obj.dayOfYear - dayOffset[i-1]); break; } else { obj.month = i; } } return obj; }, adjustForTimeZone : function (obj, date) { var offset; if (obj.zone.toUpperCase() === "Z" || (obj.zone_hours === 0 && obj.zone_minutes === 0)) { // it's UTC/GML so work out the current timeszone offset offset = -date.getTimezoneOffset(); } else { offset = (obj.zone_hours*60) + (obj.zone_minutes || 0); if (obj.zone_sign === "+") { offset *= -1; } offset -= date.getTimezoneOffset(); } date.setMinutes(date.getMinutes()+offset); return date; }, setDefaults : function (obj) { obj.year = obj.year || Date.today().getFullYear(); obj.hours = obj.hours || 0; obj.minutes = obj.minutes || 0; obj.seconds = obj.seconds || 0; obj.milliseconds = obj.milliseconds || 0; if (!(!obj.month && (obj.week || obj.dayOfYear))) { // if we have a month, or if we don't but don't have the day calculation data obj.month = obj.month || 0; obj.day = obj.day || 1; } return obj; }, dataNum: function (data, mod, explict, postProcess) { var dataNum = data*1; if (mod) { if (postProcess) { return data ? mod(data)*1 : data; } else { return data ? mod(dataNum) : data; } } else if (!explict){ return data ? dataNum : data; } else { return (data && typeof data !== "undefined") ? dataNum : data; } }, timeDataProcess: function (obj) { var timeObj = {}; for (var x in obj.data) { if (obj.data.hasOwnProperty(x)) { timeObj[x] = obj.ignore[x] ? obj.data[x] : utils.dataNum(obj.data[x], obj.mods[x], obj.explict[x], obj.postProcess[x]); } } if (obj.data.secmins) { obj.data.secmins = obj.data.secmins.replace(",", ".") * 60; if (!timeObj.minutes) { timeObj.minutes = obj.data.secmins; } else if (!timeObj.seconds) { timeObj.seconds = obj.data.secmins; } delete obj.secmins; } return timeObj; }, buildTimeObjectFromData: function (data) { var time = utils.timeDataProcess({ data: { year : data[1], month : data[5], day : data[7], week : data[8], dayOfYear : data[10], hours : data[15], zone_hours : data[23], zone_minutes : data[24], zone : data[21], zone_sign : data[22], weekDay : data[9], minutes: data[16], seconds: data[19], milliseconds: data[20], secmins: data[18] }, mods: { month: function(data) { return data-1; }, weekDay: function (data) { data = Math.abs(data); return (data === 7 ? 0 : data); }, minutes: function (data) { return data.replace(":",""); }, seconds: function (data) { return Math.floor( (data.replace(":","").replace(",","."))*1 ); }, milliseconds: function (data) { return (data.replace(",",".")*1000); } }, postProcess: { minutes: true, seconds: true, milliseconds: true }, explict: { zone_hours: true, zone_minutes: true }, ignore: { zone: true, zone_sign: true, secmins: true } }); return time; }, addToHash: function (hash, keys, data) { keys = keys; data = data; var len = keys.length; for (var i = 0; i < len; i++) { hash[keys[i]] = data[i]; } return hash; }, combineRegex: function (r1, r2) { return new RegExp("(("+r1.source+")\\s("+r2.source+"))"); }, getDateNthString: function(add, last, inc){ if (add) { return Date.today().addDays(inc).toString("d"); } else if (last) { return Date.today().last()[inc]().toString("d"); } }, buildRegexData: function (array) { var arr = []; var len = array.length; for (var i=0; i < len; i++) { if (Object.prototype.toString.call(array[i]) === '[object Array]') { // oldIE compat version of Array.isArray arr.push(this.combineRegex(array[i][0], array[i][1])); } else { arr.push(array[i]); } } return arr; } }; $P.processTimeObject = function (obj) { var date, dayOffset; utils.setDefaults(obj); dayOffset = ($P.isLeapYear(obj.year)) ? dayOffsets.leap : dayOffsets.standard; if (!obj.month && (obj.week || obj.dayOfYear)) { utils.getDayOfYear(obj, dayOffset); } else { obj.dayOfYear = dayOffset[obj.month] + obj.day; } date = new Date(obj.year, obj.month, obj.day, obj.hours, obj.minutes, obj.seconds, obj.milliseconds); if (obj.zone) { utils.adjustForTimeZone(obj, date); // adjust (and calculate) for timezone } return date; }; $P.ISO = { regex : /^([\+-]?\d{4}(?!\d{2}\b))((-?)((0[1-9]|1[0-2])(\3([12]\d|0[1-9]|3[01]))?|W([0-4]\d|5[0-3])(-?[1-7])?|(00[1-9]|0[1-9]\d|[12]\d{2}|3([0-5]\d|6[1-6])))([T\s]((([01]\d|2[0-4])((:?)[0-5]\d)?|24\:?00)([\.,]\d+(?!:))?)?(\17[0-5]\d([\.,]\d+)?)?\s?([zZ]|([\+-])([01]\d|2[0-3]):?([0-5]\d)?)?)?)?$/, parse : function (s) { var time, data = s.match(this.regex); if (!data || !data.length) { return null; } time = utils.buildTimeObjectFromData(data); if (!time.year || (!time.year && (!time.month && !time.day) && (!time.week && !time.dayOfYear)) ) { return null; } return $P.processTimeObject(time); } }; $P.Numeric = { isNumeric: function (e){return!isNaN(parseFloat(e))&&isFinite(e);}, regex: /\b([0-1]?[0-9])([0-3]?[0-9])([0-2]?[0-9]?[0-9][0-9])\b/i, parse: function (s) { var data, i, time = {}, order = Date.CultureInfo.dateElementOrder.split(""); if (!(this.isNumeric(s)) || // if it's non-numeric OR (s[0] === "+" && s[0] === "-")) { // It's an arithmatic string (eg +/-1000) return null; } if (s.length < 5 && s.indexOf(".") < 0 && s.indexOf("/") < 0) { // assume it's just a year. time.year = s; return $P.processTimeObject(time); } data = s.match(this.regex); if (!data || !data.length) { return null; } for (i=0; i < order.length; i++) { switch(order[i]) { case "d": time.day = data[i+1]; break; case "m": time.month = (data[i+1]-1); break; case "y": time.year = data[i+1]; break; } } return $P.processTimeObject(time); } }; $P.Normalizer = { regexData: function () { var $R = Date.CultureInfo.regexPatterns; return utils.buildRegexData([ $R.tomorrow, $R.yesterday, [$R.past, $R.mon], [$R.past, $R.tue], [$R.past, $R.wed], [$R.past, $R.thu], [$R.past, $R.fri], [$R.past, $R.sat], [$R.past, $R.sun] ]); }, basicReplaceHash : function() { var $R = Date.CultureInfo.regexPatterns; return { "January": $R.jan.source, "February": $R.feb, "March": $R.mar, "April": $R.apr, "May": $R.may, "June": $R.jun, "July": $R.jul, "August": $R.aug, "September": $R.sep, "October": $R.oct, "November": $R.nov, "December": $R.dec, "": /\bat\b/gi, " ": /\s{2,}/, "am": $R.inTheMorning, "9am": $R.thisMorning, "pm": $R.inTheEvening, "7pm":$R.thisEvening }; }, keys : function(){ return [ utils.getDateNthString(true, false, 1), // tomorrow utils.getDateNthString(true, false, -1), // yesterday utils.getDateNthString(false, true, "monday"), //last mon utils.getDateNthString(false, true, "tuesday"), //last tues utils.getDateNthString(false, true, "wednesday"), //last wed utils.getDateNthString(false, true, "thursday"), //last thurs utils.getDateNthString(false, true, "friday"), //last fri utils.getDateNthString(false, true, "saturday"), //last sat utils.getDateNthString(false, true, "sunday") //last sun ]; }, buildRegexFunctions: function () { var $R = Date.CultureInfo.regexPatterns; var __ = Date.i18n.__; var tomorrowRE = new RegExp("(\\b\\d\\d?("+__("AM")+"|"+__("PM")+")? )("+$R.tomorrow.source.slice(1)+")", "i"); // adapted tomorrow regex for AM PM relative dates var todayRE = new RegExp($R.today.source + "(?!\\s*([+-]))\\b"); // today, but excludes the math operators (eg "today + 2h") this.replaceFuncs = [ [todayRE, function (full) { return (full.length > 1) ? Date.today().toString("d") : full; }], [tomorrowRE, function(full, m1) { var t = Date.today().addDays(1).toString("d"); return (t + " " + m1); }], [$R.amThisMorning, function(str, am){return am;}], [$R.pmThisEvening, function(str, pm){return pm;}] ]; }, buildReplaceData: function () { this.buildRegexFunctions(); this.replaceHash = utils.addToHash(this.basicReplaceHash(), this.keys(), this.regexData()); }, stringReplaceFuncs: function (s) { for (var i=0; i < this.replaceFuncs.length; i++) { s = s.replace(this.replaceFuncs[i][0], this.replaceFuncs[i][1]); } return s; }, parse: function (s) { s = this.stringReplaceFuncs(s); s = utils.multiReplace(s, this.replaceHash); try { var n = s.split(/([\s\-\.\,\/\x27]+)/); if (n.length === 3 && $P.Numeric.isNumeric(n[0]) && $P.Numeric.isNumeric(n[2]) && (n[2].length >= 4)) { // ok, so we're dealing with x/year. But that's not a full date. // This fixes wonky dateElementOrder parsing when set to dmy order. if (Date.CultureInfo.dateElementOrder[0] === "d") { s = "1/" + n[0] + "/" + n[2]; // set to 1st of month and normalize the seperator } } } catch (e) {} return s; } }; $P.Normalizer.buildReplaceData(); }()); (function () { var $P = Date.Parsing; var _ = $P.Operators = { // // Tokenizers // rtoken: function (r) { // regex token return function (s) { var mx = s.match(r); if (mx) { return ([ mx[0], s.substring(mx[0].length) ]); } else { throw new $P.Exception(s); } }; }, token: function () { // whitespace-eating token return function (s) { return _.rtoken(new RegExp("^\\s*" + s + "\\s*"))(s); }; }, stoken: function (s) { // string token return _.rtoken(new RegExp("^" + s)); }, // Atomic Operators until: function (p) { return function (s) { var qx = [], rx = null; while (s.length) { try { rx = p.call(this, s); } catch (e) { qx.push(rx[0]); s = rx[1]; continue; } break; } return [ qx, s ]; }; }, many: function (p) { return function (s) { var rx = [], r = null; while (s.length) { try { r = p.call(this, s); } catch (e) { return [ rx, s ]; } rx.push(r[0]); s = r[1]; } return [ rx, s ]; }; }, // generator operators -- see below optional: function (p) { return function (s) { var r = null; try { r = p.call(this, s); } catch (e) { return [ null, s ]; } return [ r[0], r[1] ]; }; }, not: function (p) { return function (s) { try { p.call(this, s); } catch (e) { return [null, s]; } throw new $P.Exception(s); }; }, ignore: function (p) { return p ? function (s) { var r = null; r = p.call(this, s); return [null, r[1]]; } : null; }, product: function () { var px = arguments[0], qx = Array.prototype.slice.call(arguments, 1), rx = []; for (var i = 0 ; i < px.length ; i++) { rx.push(_.each(px[i], qx)); } return rx; }, cache: function (rule) { var cache = {}, cache_length = 0, cache_keys = [], CACHE_MAX = Date.Config.CACHE_MAX || 100000, r = null; var cacheCheck = function () { if (cache_length === CACHE_MAX) { // kill several keys, don't want to have to do this all the time... for (var i=0; i < 10; i++) { var key = cache_keys.shift(); if (key) { delete cache[key]; cache_length--; } } } }; return function (s) { cacheCheck(); try { r = cache[s] = (cache[s] || rule.call(this, s)); } catch (e) { r = cache[s] = e; } cache_length++; cache_keys.push(s); if (r instanceof $P.Exception) { throw r; } else { return r; } }; }, // vector operators -- see below any: function () { var px = arguments; return function (s) { var r = null; for (var i = 0; i < px.length; i++) { if (px[i] == null) { continue; } try { r = (px[i].call(this, s)); } catch (e) { r = null; } if (r) { return r; } } throw new $P.Exception(s); }; }, each: function () { var px = arguments; return function (s) { var rx = [], r = null; for (var i = 0; i < px.length ; i++) { if (px[i] == null) { continue; } try { r = (px[i].call(this, s)); } catch (e) { throw new $P.Exception(s); } rx.push(r[0]); s = r[1]; } return [ rx, s]; }; }, all: function () { var px = arguments, _ = _; return _.each(_.optional(px)); }, // delimited operators sequence: function (px, d, c) { d = d || _.rtoken(/^\s*/); c = c || null; if (px.length === 1) { return px[0]; } return function (s) { var r = null, q = null; var rx = []; for (var i = 0; i < px.length ; i++) { try { r = px[i].call(this, s); } catch (e) { break; } rx.push(r[0]); try { q = d.call(this, r[1]); } catch (ex) { q = null; break; } s = q[1]; } if (!r) { throw new $P.Exception(s); } if (q) { throw new $P.Exception(q[1]); } if (c) { try { r = c.call(this, r[1]); } catch (ey) { throw new $P.Exception(r[1]); } } return [ rx, (r?r[1]:s) ]; }; }, // // Composite Operators // between: function (d1, p, d2) { d2 = d2 || d1; var _fn = _.each(_.ignore(d1), p, _.ignore(d2)); return function (s) { var rx = _fn.call(this, s); return [[rx[0][0], r[0][2]], rx[1]]; }; }, list: function (p, d, c) { d = d || _.rtoken(/^\s*/); c = c || null; return (p instanceof Array ? _.each(_.product(p.slice(0, -1), _.ignore(d)), p.slice(-1), _.ignore(c)) : _.each(_.many(_.each(p, _.ignore(d))), px, _.ignore(c))); }, set: function (px, d, c) { d = d || _.rtoken(/^\s*/); c = c || null; return function (s) { // r is the current match, best the current 'best' match // which means it parsed the most amount of input var r = null, p = null, q = null, rx = null, best = [[], s], last = false; // go through the rules in the given set for (var i = 0; i < px.length ; i++) { // last is a flag indicating whether this must be the last element // if there is only 1 element, then it MUST be the last one q = null; p = null; r = null; last = (px.length === 1); // first, we try simply to match the current pattern // if not, try the next pattern try { r = px[i].call(this, s); } catch (e) { continue; } // since we are matching against a set of elements, the first // thing to do is to add r[0] to matched elements rx = [[r[0]], r[1]]; // if we matched and there is still input to parse and // we don't already know this is the last element, // we're going to next check for the delimiter ... // if there's none, or if there's no input left to parse // than this must be the last element after all ... if (r[1].length > 0 && ! last) { try { q = d.call(this, r[1]); } catch (ex) { last = true; } } else { last = true; } // if we parsed the delimiter and now there's no more input, // that means we shouldn't have parsed the delimiter at all // so don't update r and mark this as the last element ... if (!last && q[1].length === 0) { last = true; } // so, if this isn't the last element, we're going to see if // we can get any more matches from the remaining (unmatched) // elements ... if (!last) { // build a list of the remaining rules we can match against, // i.e., all but the one we just matched against var qx = []; for (var j = 0; j < px.length ; j++) { if (i !== j) { qx.push(px[j]); } } // now invoke recursively set with the remaining input // note that we don't include the closing delimiter ... // we'll check for that ourselves at the end p = _.set(qx, d).call(this, q[1]); // if we got a non-empty set as a result ... // (otw rx already contains everything we want to match) if (p[0].length > 0) { // update current result, which is stored in rx ... // basically, pick up the remaining text from p[1] // and concat the result from p[0] so that we don't // get endless nesting ... rx[0] = rx[0].concat(p[0]); rx[1] = p[1]; } } // at this point, rx either contains the last matched element // or the entire matched set that starts with this element. // now we just check to see if this variation is better than // our best so far, in terms of how much of the input is parsed if (rx[1].length < best[1].length) { best = rx; } // if we've parsed all the input, then we're finished if (best[1].length === 0) { break; } } // so now we've either gone through all the patterns trying them // as the initial match; or we found one that parsed the entire // input string ... // if best has no matches, just return empty set ... if (best[0].length === 0) { return best; } // if a closing delimiter is provided, then we have to check it also if (c) { // we try this even if there is no remaining input because the pattern // may well be optional or match empty input ... try { q = c.call(this, best[1]); } catch (ey) { throw new $P.Exception(best[1]); } // it parsed ... be sure to update the best match remaining input best[1] = q[1]; } // if we're here, either there was no closing delimiter or we parsed it // so now we have the best match; just return it! return best; }; }, forward: function (gr, fname) { return function (s) { return gr[fname].call(this, s); }; }, // // Translation Operators // replace: function (rule, repl) { return function (s) { var r = rule.call(this, s); return [repl, r[1]]; }; }, process: function (rule, fn) { return function (s) { var r = rule.call(this, s); return [fn.call(this, r[0]), r[1]]; }; }, min: function (min, rule) { return function (s) { var rx = rule.call(this, s); if (rx[0].length < min) { throw new $P.Exception(s); } return rx; }; } }; // Generator Operators And Vector Operators // Generators are operators that have a signature of F(R) => R, // taking a given rule and returning another rule, such as // ignore, which parses a given rule and throws away the result. // Vector operators are those that have a signature of F(R1,R2,...) => R, // take a list of rules and returning a new rule, such as each. // Generator operators are converted (via the following _generator // function) into functions that can also take a list or array of rules // and return an array of new rules as though the function had been // called on each rule in turn (which is what actually happens). // This allows generators to be used with vector operators more easily. // Example: // each(ignore(foo, bar)) instead of each(ignore(foo), ignore(bar)) // This also turns generators into vector operators, which allows // constructs like: // not(cache(foo, bar)) var _generator = function (op) { function gen() { var args = null, rx = [], px, i; if (arguments.length > 1) { args = Array.prototype.slice.call(arguments); } else if (arguments[0] instanceof Array) { args = arguments[0]; } if (args) { px = args.shift(); if (px.length > 0) { args.unshift(px[i]); rx.push(op.apply(null, args)); args.shift(); return rx; } } else { return op.apply(null, arguments); } } return gen; }; var gx = "optional not ignore cache".split(/\s/); for (var i = 0 ; i < gx.length ; i++) { _[gx[i]] = _generator(_[gx[i]]); } var _vector = function (op) { return function () { if (arguments[0] instanceof Array) { return op.apply(null, arguments[0]); } else { return op.apply(null, arguments); } }; }; var vx = "each any all".split(/\s/); for (var j = 0 ; j < vx.length ; j++) { _[vx[j]] = _vector(_[vx[j]]); } }()); (function () { var $D = Date; var flattenAndCompact = function (ax) { var rx = []; for (var i = 0; i < ax.length; i++) { if (ax[i] instanceof Array) { rx = rx.concat(flattenAndCompact(ax[i])); } else { if (ax[i]) { rx.push(ax[i]); } } } return rx; }; var parseMeridian = function () { if (this.meridian && (this.hour || this.hour === 0)) { if (this.meridian === "a" && this.hour > 11 && Date.Config.strict24hr){ throw "Invalid hour and meridian combination"; } else if (this.meridian === "p" && this.hour < 12 && Date.Config.strict24hr){ throw "Invalid hour and meridian combination"; } else if (this.meridian === "p" && this.hour < 12) { this.hour = this.hour + 12; } else if (this.meridian === "a" && this.hour === 12) { this.hour = 0; } } }; var setDefaults = function () { var now = new Date(); if ((this.hour || this.minute) && (!this.month && !this.year && !this.day)) { this.day = now.getDate(); } if (!this.year) { this.year = now.getFullYear(); } if (!this.month && this.month !== 0) { this.month = now.getMonth(); } if (!this.day) { this.day = 1; } if (!this.hour) { this.hour = 0; } if (!this.minute) { this.minute = 0; } if (!this.second) { this.second = 0; } if (!this.millisecond) { this.millisecond = 0; } }; var finishUtils = { getToday: function () { if (this.now || "hour minute second".indexOf(this.unit) !== -1) { return new Date(); } else { return $D.today(); } }, setDaysFromWeekday: function (today, orient){ var gap; orient = orient || 1; this.unit = "day"; gap = ($D.getDayNumberFromName(this.weekday) - today.getDay()); this.days = gap ? ((gap + (orient * 7)) % 7) : (orient * 7); return this; }, setMonthsFromMonth: function (today, orient) { var gap; orient = orient || 1; this.unit = "month"; gap = (this.month - today.getMonth()); this.months = gap ? ((gap + (orient * 12)) % 12) : (orient * 12); this.month = null; return this; }, setDMYFromWeekday: function () { var d = Date[this.weekday](); this.day = d.getDate(); if (!this.month) { this.month = d.getMonth(); } this.year = d.getFullYear(); return this; }, setUnitValue: function (orient) { if (!this.value && this.operator && this.operator !== null && this[this.unit + "s"] && this[this.unit + "s"] !== null) { this[this.unit + "s"] = this[this.unit + "s"] + ((this.operator === "add") ? 1 : -1) + (this.value||0) * orient; } else if (this[this.unit + "s"] == null || this.operator != null) { if (!this.value) { this.value = 1; } this[this.unit + "s"] = this.value * orient; } }, generateDateFromWeeks: function () { var weekday = (this.weekday !== undefined) ? this.weekday : "today"; var d = Date[weekday]().addWeeks(this.weeks); if (this.now) { d.setTimeToNow(); } return d; } }; $D.Translator = { hour: function (s) { return function () { this.hour = Number(s); }; }, minute: function (s) { return function () { this.minute = Number(s); }; }, second: function (s) { return function () { this.second = Number(s); }; }, /* for ss.s format */ secondAndMillisecond: function (s) { return function () { var mx = s.match(/^([0-5][0-9])\.([0-9]{1,3})/); this.second = Number(mx[1]); this.millisecond = Number(mx[2]); }; }, meridian: function (s) { return function () { this.meridian = s.slice(0, 1).toLowerCase(); }; }, timezone: function (s) { return function () { var n = s.replace(/[^\d\+\-]/g, ""); if (n.length) { this.timezoneOffset = Number(n); } else { this.timezone = s.toLowerCase(); } }; }, day: function (x) { var s = x[0]; return function () { this.day = Number(s.match(/\d+/)[0]); if (this.day < 1) { throw "invalid day"; } }; }, month: function (s) { return function () { this.month = (s.length === 3) ? "jan feb mar apr may jun jul aug sep oct nov dec".indexOf(s)/4 : Number(s) - 1; if (this.month < 0) { throw "invalid month"; } }; }, year: function (s) { return function () { var n = Number(s); this.year = ((s.length > 2) ? n : (n + (((n + 2000) < Date.CultureInfo.twoDigitYearMax) ? 2000 : 1900))); }; }, rday: function (s) { return function () { switch (s) { case "yesterday": this.days = -1; break; case "tomorrow": this.days = 1; break; case "today": this.days = 0; break; case "now": this.days = 0; this.now = true; break; } }; }, finishExact: function (x) { var d; x = (x instanceof Array) ? x : [x]; for (var i = 0 ; i < x.length ; i++) { if (x[i]) { x[i].call(this); } } setDefaults.call(this); parseMeridian.call(this); if (this.day > $D.getDaysInMonth(this.year, this.month)) { throw new RangeError(this.day + " is not a valid value for days."); } d = new Date(this.year, this.month, this.day, this.hour, this.minute, this.second, this.millisecond); if (this.year < 100) { d.setFullYear(this.year); // means years less that 100 are process correctly. JS will parse it otherwise as 1900-1999. } if (this.timezone) { d.set({ timezone: this.timezone }); } else if (this.timezoneOffset) { d.set({ timezoneOffset: this.timezoneOffset }); } return d; }, finish: function (x) { var today, expression, orient, temp; x = (x instanceof Array) ? flattenAndCompact(x) : [ x ]; if (x.length === 0) { return null; } for (var i = 0 ; i < x.length ; i++) { if (typeof x[i] === "function") { x[i].call(this); } } if (this.now && !this.unit && !this.operator) { return new Date(); } else { today = finishUtils.getToday.call(this); } expression = !!(this.days && this.days !== null || this.orient || this.operator); orient = ((this.orient === "past" || this.operator === "subtract") ? -1 : 1); if (this.month && this.unit === "week") { this.value = this.month + 1; delete this.month; delete this.day; } if ((this.month || this.month === 0) && "year day hour minute second".indexOf(this.unit) !== -1) { if (!this.value) { this.value = this.month + 1; } this.month = null; expression = true; } if (!expression && this.weekday && !this.day && !this.days) { finishUtils.setDMYFromWeekday.call(this); } if (expression && this.weekday && this.unit !== "month" && this.unit !== "week") { finishUtils.setDaysFromWeekday.call(this, today, orient); } if (this.weekday && this.unit !== "week" && !this.day && !this.days) { temp = Date[this.weekday](); this.day = temp.getDate(); if (temp.getMonth() !== today.getMonth()) { this.month = temp.getMonth(); } } if (this.month && this.unit === "day" && this.operator) { if (!this.value) { this.value = (this.month + 1); } this.month = null; } if (this.value != null && this.month != null && this.year != null) { this.day = this.value * 1; } if (this.month && !this.day && this.value) { today.set({ day: this.value * 1 }); if (!expression) { this.day = this.value * 1; } } if (!this.month && this.value && this.unit === "month" && !this.now) { this.month = this.value; expression = true; } if (expression && (this.month || this.month === 0) && this.unit !== "year") { finishUtils.setMonthsFromMonth.call(this, today, orient); } if (!this.unit) { this.unit = "day"; } finishUtils.setUnitValue.call(this, orient); parseMeridian.call(this); if ((this.month || this.month === 0) && !this.day) { this.day = 1; } if (!this.orient && !this.operator && this.unit === "week" && this.value && !this.day && !this.month) { return Date.today().setWeek(this.value); } if (this.unit === "week" && this.weeks && !this.day && !this.month) { return finishUtils.generateDateFromWeeks.call(this); } if (expression && this.timezone && this.day && this.days) { this.day = this.days; } if (expression){ today.add(this); } else { today.set(this); } if (this.timezone) { this.timezone = this.timezone.toUpperCase(); var offset = $D.getTimezoneOffset(this.timezone); var timezone; if (today.hasDaylightSavingTime()) { // lets check that we're being sane with timezone setting timezone = $D.getTimezoneAbbreviation(offset, today.isDaylightSavingTime()); if (timezone !== this.timezone) { // bugger, we're in a place where things like EST vs EDT matters. if (today.isDaylightSavingTime()) { today.addHours(-1); } else { today.addHours(1); } } } today.setTimezoneOffset(offset); } return today; } }; }()); (function () { var $D = Date; $D.Grammar = {}; var _ = $D.Parsing.Operators, g = $D.Grammar, t = $D.Translator, _fn; // Allow rolling up into general purpose rules _fn = function () { return _.each(_.any.apply(null, arguments), _.not(g.ctoken2("timeContext"))); }; g.datePartDelimiter = _.rtoken(/^([\s\-\.\,\/\x27]+)/); g.timePartDelimiter = _.stoken(":"); g.whiteSpace = _.rtoken(/^\s*/); g.generalDelimiter = _.rtoken(/^(([\s\,]|at|@|on)+)/); var _C = {}; g.ctoken = function (keys) { var fn = _C[keys]; if (! fn) { var c = Date.CultureInfo.regexPatterns; var kx = keys.split(/\s+/), px = []; for (var i = 0; i < kx.length ; i++) { px.push(_.replace(_.rtoken(c[kx[i]]), kx[i])); } fn = _C[keys] = _.any.apply(null, px); } return fn; }; g.ctoken2 = function (key) { return _.rtoken(Date.CultureInfo.regexPatterns[key]); }; var cacheProcessRtoken = function (key, token, type, eachToken) { if (eachToken) { g[key] = _.cache(_.process(_.each(_.rtoken(token),_.optional(g.ctoken2(eachToken))), type)); } else { g[key] = _.cache(_.process(_.rtoken(token), type)); } }; var cacheProcessCtoken = function (token, type) { return _.cache(_.process(g.ctoken2(token), type)); }; var _F = {}; //function cache var _get = function (f) { _F[f] = (_F[f] || g.format(f)[0]); return _F[f]; }; g.allformats = function (fx) { var rx = []; if (fx instanceof Array) { for (var i = 0; i < fx.length; i++) { rx.push(_get(fx[i])); } } else { rx.push(_get(fx)); } return rx; }; g.formats = function (fx) { if (fx instanceof Array) { var rx = []; for (var i = 0 ; i < fx.length ; i++) { rx.push(_get(fx[i])); } return _.any.apply(null, rx); } else { return _get(fx); } }; var grammarFormats = { timeFormats: function(){ var i, RTokenKeys = [ "h", "hh", "H", "HH", "m", "mm", "s", "ss", "ss.s", "z", "zz" ], RToken = [ /^(0[0-9]|1[0-2]|[1-9])/, /^(0[0-9]|1[0-2])/, /^([0-1][0-9]|2[0-3]|[0-9])/, /^([0-1][0-9]|2[0-3])/, /^([0-5][0-9]|[0-9])/, /^[0-5][0-9]/, /^([0-5][0-9]|[0-9])/, /^[0-5][0-9]/, /^[0-5][0-9]\.[0-9]{1,3}/, /^((\+|\-)\s*\d\d\d\d)|((\+|\-)\d\d\:?\d\d)/, /^((\+|\-)\s*\d\d\d\d)|((\+|\-)\d\d\:?\d\d)/ ], tokens = [ t.hour, t.hour, t.hour, t.hour, t.minute, t.minute, t.second, t.second, t.secondAndMillisecond, t.timezone, t.timezone ]; for (i=0; i < RTokenKeys.length; i++) { cacheProcessRtoken(RTokenKeys[i], RToken[i], tokens[i]); } g.hms = _.cache(_.sequence([g.H, g.m, g.s], g.timePartDelimiter)); g.t = cacheProcessCtoken("shortMeridian", t.meridian); g.tt = cacheProcessCtoken("longMeridian", t.meridian); g.zzz = cacheProcessCtoken("timezone", t.timezone); g.timeSuffix = _.each(_.ignore(g.whiteSpace), _.set([ g.tt, g.zzz ])); g.time = _.each(_.optional(_.ignore(_.stoken("T"))), g.hms, g.timeSuffix); }, dateFormats: function () { // pre-loaded rules for different date part order preferences var _setfn = function () { return _.set(arguments, g.datePartDelimiter); }; var i, RTokenKeys = [ "d", "dd", "M", "MM", "y", "yy", "yyy", "yyyy" ], RToken = [ /^([0-2]\d|3[0-1]|\d)/, /^([0-2]\d|3[0-1])/, /^(1[0-2]|0\d|\d)/, /^(1[0-2]|0\d)/, /^(\d+)/, /^(\d\d)/, /^(\d\d?\d?\d?)/, /^(\d\d\d\d)/ ], tokens = [ t.day, t.day, t.month, t.month, t.year, t.year, t.year, t.year ], eachToken = [ "ordinalSuffix", "ordinalSuffix" ]; for (i=0; i < RTokenKeys.length; i++) { cacheProcessRtoken(RTokenKeys[i], RToken[i], tokens[i], eachToken[i]); } g.MMM = g.MMMM = _.cache(_.process(g.ctoken("jan feb mar apr may jun jul aug sep oct nov dec"), t.month)); g.ddd = g.dddd = _.cache(_.process(g.ctoken("sun mon tue wed thu fri sat"), function (s) { return function () { this.weekday = s; }; } )); g.day = _fn(g.d, g.dd); g.month = _fn(g.M, g.MMM); g.year = _fn(g.yyyy, g.yy); g.mdy = _setfn(g.ddd, g.month, g.day, g.year); g.ymd = _setfn(g.ddd, g.year, g.month, g.day); g.dmy = _setfn(g.ddd, g.day, g.month, g.year); g.date = function (s) { return ((g[Date.CultureInfo.dateElementOrder] || g.mdy).call(this, s)); }; }, relative: function () { // relative date / time expressions g.orientation = _.process(g.ctoken("past future"), function (s) { return function () { this.orient = s; }; } ); g.operator = _.process(g.ctoken("add subtract"), function (s) { return function () { this.operator = s; }; } ); g.rday = _.process(g.ctoken("yesterday tomorrow today now"), t.rday); g.unit = _.process(g.ctoken("second minute hour day week month year"), function (s) { return function () { this.unit = s; }; } ); } }; g.buildGrammarFormats = function () { // these need to be rebuilt every time the language changes. _C = {}; grammarFormats.timeFormats(); grammarFormats.dateFormats(); grammarFormats.relative(); g.value = _.process(_.rtoken(/^([-+]?\d+)?(st|nd|rd|th)?/), function (s) { return function () { this.value = s.replace(/\D/g, ""); }; } ); g.expression = _.set([g.rday, g.operator, g.value, g.unit, g.orientation, g.ddd, g.MMM ]); g.format = _.process(_.many( _.any( // translate format specifiers into grammar rules _.process( _.rtoken(/^(dd?d?d?(?!e)|MM?M?M?|yy?y?y?|hh?|HH?|mm?|ss?|tt?|zz?z?)/), function (fmt) { if (g[fmt]) { return g[fmt]; } else { throw $D.Parsing.Exception(fmt); } } ), // translate separator tokens into token rules _.process(_.rtoken(/^[^dMyhHmstz]+/), // all legal separators function (s) { return _.ignore(_.stoken(s)); } ) ) ), // construct the parser ... function (rules) { return _.process(_.each.apply(null, rules), t.finishExact); } ); // starting rule for general purpose grammar g._start = _.process(_.set([ g.date, g.time, g.expression ], g.generalDelimiter, g.whiteSpace), t.finish); }; g.buildGrammarFormats(); // parsing date format specifiers - ex: "h:m:s tt" // this little guy will generate a custom parser based // on the format string, ex: g.format("h:m:s tt") // check for these formats first g._formats = g.formats([ "\"yyyy-MM-ddTHH:mm:ssZ\"", "yyyy-MM-ddTHH:mm:ss.sz", "yyyy-MM-ddTHH:mm:ssZ", "yyyy-MM-ddTHH:mm:ssz", "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-ddTHH:mmZ", "yyyy-MM-ddTHH:mmz", "yyyy-MM-ddTHH:mm", "ddd, MMM dd, yyyy H:mm:ss tt", "ddd MMM d yyyy HH:mm:ss zzz", "MMddyyyy", "ddMMyyyy", "Mddyyyy", "ddMyyyy", "Mdyyyy", "dMyyyy", "yyyy", "Mdyy", "dMyy", "d" ]); // real starting rule: tries selected formats first, // then general purpose rule g.start = function (s) { try { var r = g._formats.call({}, s); if (r[1].length === 0) { return r; } } catch (e) {} return g._start.call({}, s); }; }()); (function () { var $D = Date; /** * @desc Converts the specified string value into its JavaScript Date equivalent using CultureInfo specific format information. * * Example

	///////////
	// Dates //
	///////////

	// 15-Oct-2004
	var d1 = Date.parse("10/15/2004");

	// 15-Oct-2004
	var d1 = Date.parse("15-Oct-2004");

	// 15-Oct-2004
	var d1 = Date.parse("2004.10.15");

	//Fri Oct 15, 2004
	var d1 = Date.parse("Fri Oct 15, 2004");

	///////////
	// Times //
	///////////

	// Today at 10 PM.
	var d1 = Date.parse("10 PM");

	// Today at 10:30 PM.
	var d1 = Date.parse("10:30 P.M.");

	// Today at 6 AM.
	var d1 = Date.parse("06am");

	/////////////////////
	// Dates and Times //
	/////////////////////

	// 8-July-2004 @ 10:30 PM
	var d1 = Date.parse("July 8th, 2004, 10:30 PM");

	// 1-July-2004 @ 10:30 PM
	var d1 = Date.parse("2004-07-01T22:30:00");

	////////////////////
	// Relative Dates //
	////////////////////

	// Returns today's date. The string "today" is culture specific.
	var d1 = Date.parse("today");

	// Returns yesterday's date. The string "yesterday" is culture specific.
	var d1 = Date.parse("yesterday");

	// Returns the date of the next thursday.
	var d1 = Date.parse("Next thursday");

	// Returns the date of the most previous monday.
	var d1 = Date.parse("last monday");

	// Returns today's day + one year.
	var d1 = Date.parse("next year");

	///////////////
	// Date Math //
	///////////////

	// Today + 2 days
	var d1 = Date.parse("t+2");

	// Today + 2 days
	var d1 = Date.parse("today + 2 days");

	// Today + 3 months
	var d1 = Date.parse("t+3m");

	// Today - 1 year
	var d1 = Date.parse("today - 1 year");

	// Today - 1 year
	var d1 = Date.parse("t-1y"); 


	/////////////////////////////
	// Partial Dates and Times //
	/////////////////////////////

	// July 15th of this year.
	var d1 = Date.parse("July 15");

	// 15th day of current day and year.
	var d1 = Date.parse("15");

	// July 1st of current year at 10pm.
	var d1 = Date.parse("7/1 10pm");
	
* * @param {String} The string value to convert into a Date object [Required] * @return {Date} A Date object or null if the string cannot be converted into a Date. */ var parseUtils = { removeOrds: function (s) { ords = s.match(/\b(\d+)(?:st|nd|rd|th)\b/); // find ordinal matches s = ((ords && ords.length === 2) ? s.replace(ords[0], ords[1]) : s); return s; }, grammarParser: function (s) { var r = null; try { r = $D.Grammar.start.call({}, s.replace(/^\s*(\S*(\s+\S+)*)\s*$/, "$1")); } catch (e) { return null; } return ((r[1].length === 0) ? r[0] : null); }, nativeFallback: function(s) { var t; try { // ok we haven't parsed it, last ditch attempt with the built-in parser. t = Date._parse(s); return (t || t === 0) ? new Date(t) : null; } catch (e) { return null; } } }; function parse (s) { var d; if (!s) { return null; } if (s instanceof Date) { return s.clone(); } if (s.length >= 4 && s.charAt(0) !== "0" && s.charAt(0) !== "+"&& s.charAt(0) !== "-") { // ie: 2004 will pass, 0800 won't. // Start with specific formats d = $D.Parsing.ISO.parse(s) || $D.Parsing.Numeric.parse(s); } if (d instanceof Date && !isNaN(d.getTime())) { return d; } else { // find ordinal dates (1st, 3rd, 8th, etc and remove them as they cause parsing issues) s = $D.Parsing.Normalizer.parse(parseUtils.removeOrds(s)); d = parseUtils.grammarParser(s); if (d !== null) { return d; } else { return parseUtils.nativeFallback(s); } } } if (!$D._parse) { $D._parse = $D.parse; } $D.parse = parse; Date.getParseFunction = function (fx) { var fns = Date.Grammar.allformats(fx); return function (s) { var r = null; for (var i = 0; i < fns.length; i++) { try { r = fns[i].call({}, s); } catch (e) { continue; } if (r[1].length === 0) { return r[0]; } } return null; }; }; /** * Converts the specified string value into its JavaScript Date equivalent using the specified format {String} or formats {Array} and the CultureInfo specific format information. * The format of the string value must match one of the supplied formats exactly. * * Example

	// 15-Oct-2004
	var d1 = Date.parseExact("10/15/2004", "M/d/yyyy");

	// 15-Oct-2004
	var d1 = Date.parse("15-Oct-2004", "M-ddd-yyyy");

	// 15-Oct-2004
	var d1 = Date.parse("2004.10.15", "yyyy.MM.dd");

	// Multiple formats
	var d1 = Date.parseExact("10/15/2004", ["M/d/yyyy", "MMMM d, yyyy"]);
	
* * @param {String} The string value to convert into a Date object [Required]. * @param {Object} The expected format {String} or an array of expected formats {Array} of the date string [Required]. * @return {Date} A Date object or null if the string cannot be converted into a Date. */ $D.parseExact = function (s, fx) { return $D.getParseFunction(fx)(s); }; }()); (function () { var $D = Date, $P = $D.prototype, // $C = $D.CultureInfo, // not used atm p = function (s, l) { if (!l) { l = 2; } return ("000" + s).slice(l * -1); }; /** * Converts a PHP format string to Java/.NET format string. * A PHP format string can be used with ._format or .format. * A Java/.NET format string can be used with .toString(). * The .parseExact function will only accept a Java/.NET format string * * Example * var f1 = "%m/%d/%y" * var f2 = Date.normalizeFormat(f1); // "MM/dd/yy" * * new Date().format(f1); // "04/13/08" * new Date()._format(f1); // "04/13/08" * new Date().toString(f2); // "04/13/08" * * var date = Date.parseExact("04/13/08", f2); // Sun Apr 13 2008 * * @param {String} A PHP format string consisting of one or more format spcifiers. * @return {String} The PHP format converted to a Java/.NET format string. */ var normalizerSubstitutions = { "d" : "dd", "%d": "dd", "D" : "ddd", "%a": "ddd", "j" : "dddd", "l" : "dddd", "%A": "dddd", "S" : "S", "F" : "MMMM", "%B": "MMMM", "m" : "MM", "%m": "MM", "M" : "MMM", "%b": "MMM", "%h": "MMM", "n" : "M", "Y" : "yyyy", "%Y": "yyyy", "y" : "yy", "%y": "yy", "g" : "h", "%I": "h", "G" : "H", "h" : "hh", "H" : "HH", "%H": "HH", "i" : "mm", "%M": "mm", "s" : "ss", "%S": "ss", "%r": "hh:mm tt", "%R": "H:mm", "%T": "H:mm:ss", "%X": "t", "%x": "d", "%e": "d", "%D": "MM/dd/yy", "%n": "\\n", "%t": "\\t", "e" : "z", "T" : "z", "%z": "z", "%Z": "z", "Z" : "ZZ", "N" : "u", "w" : "u", "%w": "u", "W" : "W", "%V": "W" }; var normalizer = { substitutes: function (m) { return normalizerSubstitutions[m]; }, interpreted: function (m, x) { var y; switch (m) { case "%u": return x.getDay() + 1; case "z": return x.getOrdinalNumber(); case "%j": return p(x.getOrdinalNumber(), 3); case "%U": var d1 = x.clone().set({month: 0, day: 1}).addDays(-1).moveToDayOfWeek(0), d2 = x.clone().addDays(1).moveToDayOfWeek(0, -1); return (d2 < d1) ? "00" : p((d2.getOrdinalNumber() - d1.getOrdinalNumber()) / 7 + 1); case "%W": return p(x.getWeek()); case "t": return $D.getDaysInMonth(x.getFullYear(), x.getMonth()); case "o": case "%G": return x.setWeek(x.getISOWeek()).toString("yyyy"); case "%g": return x._format("%G").slice(-2); case "a": case "%p": return t("tt").toLowerCase(); case "A": return t("tt").toUpperCase(); case "u": return p(x.getMilliseconds(), 3); case "I": return (x.isDaylightSavingTime()) ? 1 : 0; case "O": return x.getUTCOffset(); case "P": y = x.getUTCOffset(); return y.substring(0, y.length - 2) + ":" + y.substring(y.length - 2); case "B": var now = new Date(); return Math.floor(((now.getHours() * 3600) + (now.getMinutes() * 60) + now.getSeconds() + (now.getTimezoneOffset() + 60) * 60) / 86.4); case "c": return x.toISOString().replace(/\"/g, ""); case "U": return $D.strtotime("now"); case "%c": return t("d") + " " + t("t"); case "%C": return Math.floor(x.getFullYear() / 100 + 1); } }, shouldOverrideDefaults: function (m) { switch (m) { case "%e": return true; default: return false; } }, parse: function (m, context) { var formatString, c = context || new Date(); formatString = normalizer.substitutes(m); if (formatString) { return formatString; } formatString = normalizer.interpreted(m, c); if (formatString) { return formatString; } else { return m; } } }; $D.normalizeFormat = function (format, context) { return format.replace(/(%|\\)?.|%%/g, function(t){ return normalizer.parse(t, context); }); }; /** * Format a local Unix timestamp according to locale settings * * Example: * Date.strftime("%m/%d/%y", new Date()); // "04/13/08" * Date.strftime("c", "2008-04-13T17:52:03Z"); // "04/13/08" * * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @param {Number|String} The number representing the number of seconds that have elapsed since January 1, 1970 (local time). * @return {String} A string representation of the current Date object. */ $D.strftime = function (format, time) { var d = Date.parse(time); return d._format(format); }; /** * Parse any textual datetime description into a Unix timestamp. * A Unix timestamp is the number of seconds that have elapsed since January 1, 1970 (midnight UTC/GMT). * * Example: * Date.strtotime("04/13/08"); // 1208044800 * Date.strtotime("1970-01-01T00:00:00Z"); // 0 * * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @param {Object} A string or date object. * @return {String} A string representation of the current Date object. */ $D.strtotime = function (time) { var d = $D.parse(time); return Math.round($D.UTC(d.getUTCFullYear(), d.getUTCMonth(), d.getUTCDate(), d.getUTCHours(), d.getUTCMinutes(), d.getUTCSeconds(), d.getUTCMilliseconds()) / 1000); }; /** * Converts the value of the current Date object to its equivalent string representation using a PHP/Unix style of date format specifiers. * Format Specifiers * Format Description Example * ------ --------------------------------------------------------------------------- ----------------------- * %a abbreviated weekday name according to the current localed "Mon" through "Sun" * %A full weekday name according to the current localed "Sunday" through "Saturday" * %b abbreviated month name according to the current localed "Jan" through "Dec" * %B full month name according to the current locale "January" through "December" * %c preferred date and time representation for the current locale "4/13/2008 12:33 PM" * %C century number (the year divided by 100 and truncated to an integer) "00" to "99" * %d day of the month as a decimal number "01" to "31" * %D same as %m/%d/%y "04/13/08" * %e day of the month as a decimal number, a single digit is preceded by a space "1" to "31" * %g like %G, but without the century "08" * %G The 4-digit year corresponding to the ISO week number (see %V). "2008" * This has the same format and value as %Y, except that if the ISO week number * belongs to the previous or next year, that year is used instead. * %h same as %b "Jan" through "Dec" * %H hour as a decimal number using a 24-hour clock. "00" to "23" * %I hour as a decimal number using a 12-hour clock. "01" to "12" * %j day of the year as a decimal number. "001" to "366" * %m month as a decimal number. "01" to "12" * %M minute as a decimal number. "00" to "59" * %n newline character "\n" * %p either "am" or "pm" according to the given time value, or the "am" or "pm" * corresponding strings for the current locale. * %r time in a.m. and p.m. notation "8:44 PM" * %R time in 24 hour notation "20:44" * %S second as a decimal number "00" to "59" * %t tab character "\t" * %T current time, equal to %H:%M:%S "12:49:11" * %u weekday as a decimal number ["1", "7"], with "1" representing Monday "1" to "7" * %U week number of the current year as a decimal number, starting with the "0" to ("52" or "53") * first Sunday as the first day of the first week * %V The ISO 8601:1988 week number of the current year as a decimal number, "00" to ("52" or "53") * range 01 to 53, where week 1 is the first week that has at least 4 days * in the current year, and with Monday as the first day of the week. * (Use %G or %g for the year component that corresponds to the week number * for the specified timestamp.) * %W week number of the current year as a decimal number, starting with the "00" to ("52" or "53") * first Monday as the first day of the first week * %w day of the week as a decimal, Sunday being "0" "0" to "6" * %x preferred date representation for the current locale without the time "4/13/2008" * %X preferred time representation for the current locale without the date "12:53:05" * %y year as a decimal number without a century "00" "99" * %Y year as a decimal number including the century "2008" * %Z time zone or name or abbreviation "UTC", "EST", "PST" * %z same as %Z * %% a literal "%" characters "%" * d Day of the month, 2 digits with leading zeros "01" to "31" * D A textual representation of a day, three letters "Mon" through "Sun" * j Day of the month without leading zeros "1" to "31" * l A full textual representation of the day of the week (lowercase "L") "Sunday" through "Saturday" * N ISO-8601 numeric representation of the day of the week (added in PHP 5.1.0) "1" (for Monday) through "7" (for Sunday) * S English ordinal suffix for the day of the month, 2 characters "st", "nd", "rd" or "th". Works well with j * w Numeric representation of the day of the week "0" (for Sunday) through "6" (for Saturday) * z The day of the year (starting from "0") "0" through "365" * W ISO-8601 week number of year, weeks starting on Monday "00" to ("52" or "53") * F A full textual representation of a month, such as January or March "January" through "December" * m Numeric representation of a month, with leading zeros "01" through "12" * M A short textual representation of a month, three letters "Jan" through "Dec" * n Numeric representation of a month, without leading zeros "1" through "12" * t Number of days in the given month "28" through "31" * L Whether it's a leap year "1" if it is a leap year, "0" otherwise * o ISO-8601 year number. This has the same value as Y, except that if the "2008" * ISO week number (W) belongs to the previous or next year, that year * is used instead. * Y A full numeric representation of a year, 4 digits "2008" * y A two digit representation of a year "08" * a Lowercase Ante meridiem and Post meridiem "am" or "pm" * A Uppercase Ante meridiem and Post meridiem "AM" or "PM" * B Swatch Internet time "000" through "999" * g 12-hour format of an hour without leading zeros "1" through "12" * G 24-hour format of an hour without leading zeros "0" through "23" * h 12-hour format of an hour with leading zeros "01" through "12" * H 24-hour format of an hour with leading zeros "00" through "23" * i Minutes with leading zeros "00" to "59" * s Seconds, with leading zeros "00" through "59" * u Milliseconds "54321" * e Timezone identifier "UTC", "EST", "PST" * I Whether or not the date is in daylight saving time (uppercase i) "1" if Daylight Saving Time, "0" otherwise * O Difference to Greenwich time (GMT) in hours "+0200", "-0600" * P Difference to Greenwich time (GMT) with colon between hours and minutes "+02:00", "-06:00" * T Timezone abbreviation "UTC", "EST", "PST" * Z Timezone offset in seconds. The offset for timezones west of UTC is "-43200" through "50400" * always negative, and for those east of UTC is always positive. * c ISO 8601 date "2004-02-12T15:19:21+00:00" * r RFC 2822 formatted date "Thu, 21 Dec 2000 16:01:07 +0200" * U Seconds since the Unix Epoch (January 1 1970 00:00:00 GMT) "0" * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @return {String} A string representation of the current Date object. */ var formatReplace = function (context) { return function (m) { var formatString, override = false; if (m.charAt(0) === "\\" || m.substring(0, 2) === "%%") { return m.replace("\\", "").replace("%%", "%"); } override = normalizer.shouldOverrideDefaults(m); formatString = $D.normalizeFormat(m, context); if (formatString) { return context.toString(formatString, override); } }; }; $P._format = function (format) { var formatter = formatReplace(this); if (!format) { return this._toString(); } else { return format.replace(/(%|\\)?.|%%/g, formatter); } }; if (!$P.format) { $P.format = $P._format; } }()); (function () { "use strict"; var gFn = function (attr) { return function () { return this[attr]; }; }; var sFn = function (attr) { return function (val) { this[attr] = val; return this; }; }; var attrs = ["years", "months", "days", "hours", "minutes", "seconds", "milliseconds"]; var addSetFuncs = function (context, attrs) { for (var i = 0; i < attrs.length ; i++) { var $a = attrs[i], $b = $a.slice(0, 1).toUpperCase() + $a.slice(1); context.prototype[$a] = 0; context.prototype["get" + $b] = gFn($a); context.prototype["set" + $b] = sFn($a); } }; /** * new TimeSpan(milliseconds); * new TimeSpan(days, hours, minutes, seconds); * new TimeSpan(days, hours, minutes, seconds, milliseconds); */ var TimeSpan = function (days, hours, minutes, seconds, milliseconds) { if (arguments.length === 1 && typeof days === "number") { var orient = (days < 0) ? -1 : +1; var millsLeft = Math.abs(days); this.setDays(Math.floor(millsLeft / 86400000) * orient); millsLeft = millsLeft % 86400000; this.setHours(Math.floor(millsLeft / 3600000) * orient); millsLeft = millsLeft % 3600000; this.setMinutes(Math.floor(millsLeft / 60000) * orient); millsLeft = millsLeft % 60000; this.setSeconds(Math.floor(millsLeft / 1000) * orient); millsLeft = millsLeft % 1000; this.setMilliseconds(millsLeft * orient); } else { this.set(days, hours, minutes, seconds, milliseconds); } this.getTotalMilliseconds = function () { return (this.getDays() * 86400000) + (this.getHours() * 3600000) + (this.getMinutes() * 60000) + (this.getSeconds() * 1000); }; this.compareTo = function (time) { var t1 = new Date(1970, 1, 1, this.getHours(), this.getMinutes(), this.getSeconds()), t2; if (time === null) { t2 = new Date(1970, 1, 1, 0, 0, 0); } else { t2 = new Date(1970, 1, 1, time.getHours(), time.getMinutes(), time.getSeconds()); } return (t1 < t2) ? -1 : (t1 > t2) ? 1 : 0; }; this.equals = function (time) { return (this.compareTo(time) === 0); }; this.add = function (time) { return (time === null) ? this : this.addSeconds(time.getTotalMilliseconds() / 1000); }; this.subtract = function (time) { return (time === null) ? this : this.addSeconds(-time.getTotalMilliseconds() / 1000); }; this.addDays = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 86400000)); }; this.addHours = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 3600000)); }; this.addMinutes = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 60000)); }; this.addSeconds = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 1000)); }; this.addMilliseconds = function (n) { return new TimeSpan(this.getTotalMilliseconds() + n); }; this.get12HourHour = function () { return (this.getHours() > 12) ? this.getHours() - 12 : (this.getHours() === 0) ? 12 : this.getHours(); }; this.getDesignator = function () { return (this.getHours() < 12) ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator; }; this.toString = function (format) { this._toString = function () { if (this.getDays() !== null && this.getDays() > 0) { return this.getDays() + "." + this.getHours() + ":" + this.p(this.getMinutes()) + ":" + this.p(this.getSeconds()); } else { return this.getHours() + ":" + this.p(this.getMinutes()) + ":" + this.p(this.getSeconds()); } }; this.p = function (s) { return (s.toString().length < 2) ? "0" + s : s; }; var me = this; return format ? format.replace(/dd?|HH?|hh?|mm?|ss?|tt?/g, function (format) { switch (format) { case "d": return me.getDays(); case "dd": return me.p(me.getDays()); case "H": return me.getHours(); case "HH": return me.p(me.getHours()); case "h": return me.get12HourHour(); case "hh": return me.p(me.get12HourHour()); case "m": return me.getMinutes(); case "mm": return me.p(me.getMinutes()); case "s": return me.getSeconds(); case "ss": return me.p(me.getSeconds()); case "t": return ((me.getHours() < 12) ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator).substring(0, 1); case "tt": return (me.getHours() < 12) ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator; } } ) : this._toString(); }; return this; }; addSetFuncs(TimeSpan, attrs.slice(2)); TimeSpan.prototype.set = function (days, hours, minutes, seconds, milliseconds){ this.setDays(days || this.getDays()); this.setHours(hours || this.getHours()); this.setMinutes(minutes || this.getMinutes()); this.setSeconds(seconds || this.getSeconds()); this.setMilliseconds(milliseconds || this.getMilliseconds()); }; /** * Gets the time of day for this date instances. * @return {TimeSpan} TimeSpan */ Date.prototype.getTimeOfDay = function () { return new TimeSpan(0, this.getHours(), this.getMinutes(), this.getSeconds(), this.getMilliseconds()); }; Date.TimeSpan = TimeSpan; if (typeof window !== "undefined" ) { // keeping API compatible for v1.x window.TimeSpan = TimeSpan; } }()); (function () { "use strict"; var attrs = ["years", "months", "days", "hours", "minutes", "seconds", "milliseconds"]; var gFn = function (attr) { return function () { return this[attr]; }; }; var sFn = function (attr) { return function (val) { this[attr] = val; return this; }; }; var addSetFuncs = function (context, attrs) { for (var i = 0; i < attrs.length ; i++) { var $a = attrs[i], $b = $a.slice(0, 1).toUpperCase() + $a.slice(1); context.prototype[$a] = 0; context.prototype["get" + $b] = gFn($a); context.prototype["set" + $b] = sFn($a); } }; var setMonthsAndYears = function (orient, d1, d2, context) { function inc() { d1.addMonths(-orient); context.months++; if (context.months === 12) { context.years++; context.months = 0; } } if (orient === +1) { while (d1 > d2) { inc(); } } else { while (d1 < d2) { inc(); } } context.months--; context.months *= orient; context.years *= orient; }; var adjustForDST = function(orient, startDate, endDate) { var hasDSTMismatch = (false === (startDate.isDaylightSavingTime() === endDate.isDaylightSavingTime())); if (hasDSTMismatch && orient === 1) { startDate.addHours(-1); } else if (hasDSTMismatch) { startDate.addHours(1); } }; /** * TimePeriod(startDate, endDate); * TimePeriod(years, months, days, hours, minutes, seconds, milliseconds); */ var TimePeriod = function (years, months, days, hours, minutes, seconds, milliseconds) { if (arguments.length === 7) { this.set(years, months, days, hours, minutes, seconds, milliseconds); } else if (arguments.length === 2 && arguments[0] instanceof Date && arguments[1] instanceof Date) { var startDate = arguments[0].clone(); var endDate = arguments[1].clone(); var orient = (startDate > endDate) ? +1 : -1; this.dates = { start: arguments[0].clone(), end: arguments[1].clone() }; setMonthsAndYears(orient, startDate, endDate, this); adjustForDST(orient, startDate, endDate); // // TODO - adjust for DST var diff = endDate - startDate; if (diff !== 0) { var ts = new TimeSpan(diff); this.set(this.years, this.months, ts.getDays(), ts.getHours(), ts.getMinutes(), ts.getSeconds(), ts.getMilliseconds()); } } return this; }; // create all the set functions. addSetFuncs(TimePeriod, attrs); TimePeriod.prototype.set = function (years, months, days, hours, minutes, seconds, milliseconds){ this.setYears(years || this.getYears()); this.setMonths(months || this.getMonths()); this.setDays(days || this.getDays()); this.setHours(hours || this.getHours()); this.setMinutes(minutes || this.getMinutes()); this.setSeconds(seconds || this.getSeconds()); this.setMilliseconds(milliseconds || this.getMilliseconds()); }; Date.TimePeriod = TimePeriod; if (typeof window !== "undefined") { // keeping API compatible for v1.x window.TimePeriod = TimePeriod; } }()); ================================================ FILE: build/date-ar-OM.js ================================================ /** * @overview datejs * @version 1.0.0-rc3 * @author Gregory Wild-Smith * @copyright 2015 Gregory Wild-Smith * @license MIT * @homepage https://github.com/abritinthebay/datejs */ /* * DateJS Culture String File * Country Code: ar-OM * Name: Arabic (Oman) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["ar-OM"] = { "name": "ar-OM", "englishName": "Arabic (Oman)", "nativeName": "العربية (عمان)", "Sunday": "الاحد", "Monday": "الاثنين", "Tuesday": "الثلاثاء", "Wednesday": "الاربعاء", "Thursday": "الخميس", "Friday": "الجمعة", "Saturday": "السبت", "Sun": "الاحد", "Mon": "الاثنين", "Tue": "الثلاثاء", "Wed": "الاربعاء", "Thu": "الخميس", "Fri": "الجمعة", "Sat": "السبت", "Su": "أ", "Mo": "ا", "Tu": "ث", "We": "أ", "Th": "خ", "Fr": "ج", "Sa": "س", "S_Sun_Initial": "أ", "M_Mon_Initial": "ا", "T_Tue_Initial": "ث", "W_Wed_Initial": "أ", "T_Thu_Initial": "خ", "F_Fri_Initial": "ج", "S_Sat_Initial": "س", "January": "يناير", "February": "فبراير", "March": "مارس", "April": "ابريل", "May": "مايو", "June": "يونيو", "July": "يوليو", "August": "اغسطس", "September": "سبتمبر", "October": "اكتوبر", "November": "نوفمبر", "December": "ديسمبر", "Jan_Abbr": "يناير", "Feb_Abbr": "فبراير", "Mar_Abbr": "مارس", "Apr_Abbr": "ابريل", "May_Abbr": "مايو", "Jun_Abbr": "يونيو", "Jul_Abbr": "يوليو", "Aug_Abbr": "اغسطس", "Sep_Abbr": "سبتمبر", "Oct_Abbr": "اكتوبر", "Nov_Abbr": "نوفمبر", "Dec_Abbr": "ديسمبر", "AM": "ص", "PM": "م", "firstDayOfWeek": 6, "twoDigitYearMax": 2029, "mdy": "dmy", "M/d/yyyy": "dd/MM/yyyy", "dddd, MMMM dd, yyyy": "dd MMMM, yyyy", "h:mm tt": "hh:mm tt", "h:mm:ss tt": "hh:mm:ss tt", "dddd, MMMM dd, yyyy h:mm:ss tt": "dd MMMM, yyyy hh:mm:ss tt", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "dd MMMM", "MMMM, yyyy": "MMMM, yyyy", "/jan(uary)?/": "يناير", "/feb(ruary)?/": "فبراير", "/mar(ch)?/": "مارس", "/apr(il)?/": "ابريل", "/may/": "مايو", "/jun(e)?/": "يونيو", "/jul(y)?/": "يوليو", "/aug(ust)?/": "اغسطس", "/sep(t(ember)?)?/": "سبتمبر", "/oct(ober)?/": "اكتوبر", "/nov(ember)?/": "نوفمبر", "/dec(ember)?/": "ديسمبر", "/^su(n(day)?)?/": "^الاحد", "/^mo(n(day)?)?/": "^ا(1)?", "/^tu(e(s(day)?)?)?/": "^الثلاثاء", "/^we(d(nesday)?)?/": "^الاربعاء", "/^th(u(r(s(day)?)?)?)?/": "^الخميس", "/^fr(i(day)?)?/": "^الجمعة", "/^sa(t(urday)?)?/": "^السبت", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "ar-OM"; /** * @overview datejs * @version 1.0.0-rc3 * @author Gregory Wild-Smith * @copyright 2015 Gregory Wild-Smith * @license MIT * @homepage https://github.com/abritinthebay/datejs */(function () { var $D = Date; var lang = Date.CultureStrings ? Date.CultureStrings.lang : null; var loggedKeys = {}; // for debug purposes. var getText = { getFromKey: function (key, countryCode) { var output; if (Date.CultureStrings && Date.CultureStrings[countryCode] && Date.CultureStrings[countryCode][key]) { output = Date.CultureStrings[countryCode][key]; } else { output = getText.buildFromDefault(key); } if (key.charAt(0) === "/") { // Assume it's a regex output = getText.buildFromRegex(key, countryCode); } return output; }, getFromObjectValues: function (obj, countryCode) { var key, output = {}; for(key in obj) { if (obj.hasOwnProperty(key)) { output[key] = getText.getFromKey(obj[key], countryCode); } } return output; }, getFromObjectKeys: function (obj, countryCode) { var key, output = {}; for(key in obj) { if (obj.hasOwnProperty(key)) { output[getText.getFromKey(key, countryCode)] = obj[key]; } } return output; }, getFromArray: function (arr, countryCode) { var output = []; for (var i=0; i < arr.length; i++){ if (i in arr) { output[i] = getText.getFromKey(arr[i], countryCode); } } return output; }, buildFromDefault: function (key) { var output, length, split, last; switch(key) { case "name": output = "en-US"; break; case "englishName": output = "English (United States)"; break; case "nativeName": output = "English (United States)"; break; case "twoDigitYearMax": output = 2049; break; case "firstDayOfWeek": output = 0; break; default: output = key; split = key.split("_"); length = split.length; if (length > 1 && key.charAt(0) !== "/") { // if the key isn't a regex and it has a split. last = split[(length - 1)].toLowerCase(); if (last === "initial" || last === "abbr") { output = split[0]; } } break; } return output; }, buildFromRegex: function (key, countryCode) { var output; if (Date.CultureStrings && Date.CultureStrings[countryCode] && Date.CultureStrings[countryCode][key]) { output = new RegExp(Date.CultureStrings[countryCode][key], "i"); } else { output = new RegExp(key.replace(new RegExp("/", "g"),""), "i"); } return output; } }; var shallowMerge = function (obj1, obj2) { for (var attrname in obj2) { if (obj2.hasOwnProperty(attrname)) { obj1[attrname] = obj2[attrname]; } } }; var __ = function (key, language) { var countryCode = (language) ? language : lang; loggedKeys[key] = key; if (typeof key === "object") { if (key instanceof Array) { return getText.getFromArray(key, countryCode); } else { return getText.getFromObjectKeys(key, countryCode); } } else { return getText.getFromKey(key, countryCode); } }; var loadI18nScript = function (code) { // paatterned after jQuery's getScript. var url = Date.Config.i18n + code + ".js"; var head = document.getElementsByTagName("head")[0] || document.documentElement; var script = document.createElement("script"); script.src = url; var completed = false; var events = { done: function (){} // placeholder function }; // Attach handlers for all browsers script.onload = script.onreadystatechange = function() { if ( !completed && (!this.readyState || this.readyState === "loaded" || this.readyState === "complete") ) { events.done(); head.removeChild(script); } }; setTimeout(function() { head.insertBefore(script, head.firstChild); }, 0); // allows return to execute first return { done: function (cb) { events.done = function() { if (cb) { setTimeout(cb,0); } }; } }; }; var buildInfo = { buildFromMethodHash: function (obj) { var key; for(key in obj) { if (obj.hasOwnProperty(key)) { obj[key] = buildInfo[obj[key]](); } } return obj; }, timeZoneDST: function () { var DST = { "CHADT": "+1345", "NZDT": "+1300", "AEDT": "+1100", "ACDT": "+1030", "AZST": "+0500", "IRDT": "+0430", "EEST": "+0300", "CEST": "+0200", "BST": "+0100", "PMDT": "-0200", "ADT": "-0300", "NDT": "-0230", "EDT": "-0400", "CDT": "-0500", "MDT": "-0600", "PDT": "-0700", "AKDT": "-0800", "HADT": "-0900" }; return __(DST); }, timeZoneStandard: function () { var standard = { "LINT": "+1400", "TOT": "+1300", "CHAST": "+1245", "NZST": "+1200", "NFT": "+1130", "SBT": "+1100", "AEST": "+1000", "ACST": "+0930", "JST": "+0900", "CWST": "+0845", "CT": "+0800", "ICT": "+0700", "MMT": "+0630", "BST": "+0600", "NPT": "+0545", "IST": "+0530", "PKT": "+0500", "AFT": "+0430", "MSK": "+0400", "IRST": "+0330", "FET": "+0300", "EET": "+0200", "CET": "+0100", "GMT": "+0000", "UTC": "+0000", "CVT": "-0100", "GST": "-0200", "BRT": "-0300", "NST": "-0330", "AST": "-0400", "EST": "-0500", "CST": "-0600", "MST": "-0700", "PST": "-0800", "AKST": "-0900", "MIT": "-0930", "HST": "-1000", "SST": "-1100", "BIT": "-1200" }; return __(standard); }, timeZones: function (data) { var zone; data.timezones = []; for (zone in data.abbreviatedTimeZoneStandard) { if (data.abbreviatedTimeZoneStandard.hasOwnProperty(zone)) { data.timezones.push({ name: zone, offset: data.abbreviatedTimeZoneStandard[zone]}); } } for (zone in data.abbreviatedTimeZoneDST) { if (data.abbreviatedTimeZoneDST.hasOwnProperty(zone)) { data.timezones.push({ name: zone, offset: data.abbreviatedTimeZoneDST[zone], dst: true}); } } return data.timezones; }, days: function () { return __(["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"]); }, dayAbbr: function () { return __(["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"]); }, dayShortNames: function () { return __(["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"]); }, dayFirstLetters: function () { return __(["S_Sun_Initial", "M_Mon_Initial", "T_Tues_Initial", "W_Wed_Initial", "T_Thu_Initial", "F_Fri_Initial", "S_Sat_Initial"]); }, months: function () { return __(["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"]); }, monthAbbr: function () { return __(["Jan_Abbr", "Feb_Abbr", "Mar_Abbr", "Apr_Abbr", "May_Abbr", "Jun_Abbr", "Jul_Abbr", "Aug_Abbr", "Sep_Abbr", "Oct_Abbr", "Nov_Abbr", "Dec_Abbr"]); }, formatPatterns: function () { return getText.getFromObjectValues({ shortDate: "M/d/yyyy", longDate: "dddd, MMMM dd, yyyy", shortTime: "h:mm tt", longTime: "h:mm:ss tt", fullDateTime: "dddd, MMMM dd, yyyy h:mm:ss tt", sortableDateTime: "yyyy-MM-ddTHH:mm:ss", universalSortableDateTime: "yyyy-MM-dd HH:mm:ssZ", rfc1123: "ddd, dd MMM yyyy HH:mm:ss", monthDay: "MMMM dd", yearMonth: "MMMM, yyyy" }, Date.i18n.currentLanguage()); }, regex: function () { return getText.getFromObjectValues({ inTheMorning: "/( in the )(morn(ing)?)\\b/", thisMorning: "/(this )(morn(ing)?)\\b/", amThisMorning: "/(\b\\d(am)? )(this )(morn(ing)?)/", inTheEvening: "/( in the )(even(ing)?)\\b/", thisEvening: "/(this )(even(ing)?)\\b/", pmThisEvening: "/(\b\\d(pm)? )(this )(even(ing)?)/", jan: "/jan(uary)?/", feb: "/feb(ruary)?/", mar: "/mar(ch)?/", apr: "/apr(il)?/", may: "/may/", jun: "/jun(e)?/", jul: "/jul(y)?/", aug: "/aug(ust)?/", sep: "/sep(t(ember)?)?/", oct: "/oct(ober)?/", nov: "/nov(ember)?/", dec: "/dec(ember)?/", sun: "/^su(n(day)?)?/", mon: "/^mo(n(day)?)?/", tue: "/^tu(e(s(day)?)?)?/", wed: "/^we(d(nesday)?)?/", thu: "/^th(u(r(s(day)?)?)?)?/", fri: "/fr(i(day)?)?/", sat: "/^sa(t(urday)?)?/", future: "/^next/", past: "/^last|past|prev(ious)?/", add: "/^(\\+|aft(er)?|from|hence)/", subtract: "/^(\\-|bef(ore)?|ago)/", yesterday: "/^yes(terday)?/", today: "/^t(od(ay)?)?/", tomorrow: "/^tom(orrow)?/", now: "/^n(ow)?/", millisecond: "/^ms|milli(second)?s?/", second: "/^sec(ond)?s?/", minute: "/^mn|min(ute)?s?/", hour: "/^h(our)?s?/", week: "/^w(eek)?s?/", month: "/^m(onth)?s?/", day: "/^d(ay)?s?/", year: "/^y(ear)?s?/", shortMeridian: "/^(a|p)/", longMeridian: "/^(a\\.?m?\\.?|p\\.?m?\\.?)/", timezone: "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/", ordinalSuffix: "/^\\s*(st|nd|rd|th)/", timeContext: "/^\\s*(\\:|a(?!u|p)|p)/" }, Date.i18n.currentLanguage()); } }; var CultureInfo = function () { var info = getText.getFromObjectValues({ name: "name", englishName: "englishName", nativeName: "nativeName", amDesignator: "AM", pmDesignator: "PM", firstDayOfWeek: "firstDayOfWeek", twoDigitYearMax: "twoDigitYearMax", dateElementOrder: "mdy" }, Date.i18n.currentLanguage()); var constructedInfo = buildInfo.buildFromMethodHash({ dayNames: "days", abbreviatedDayNames: "dayAbbr", shortestDayNames: "dayShortNames", firstLetterDayNames: "dayFirstLetters", monthNames: "months", abbreviatedMonthNames: "monthAbbr", formatPatterns: "formatPatterns", regexPatterns: "regex", abbreviatedTimeZoneDST: "timeZoneDST", abbreviatedTimeZoneStandard: "timeZoneStandard" }); shallowMerge(info, constructedInfo); buildInfo.timeZones(info); return info; }; $D.i18n = { __: function (key, lang) { return __(key, lang); }, currentLanguage: function () { return lang || "en-US"; }, setLanguage: function (code, force, cb) { var async = false; if (force || code === "en-US" || (!!Date.CultureStrings && !!Date.CultureStrings[code])) { lang = code; Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings.lang = code; Date.CultureInfo = new CultureInfo(); } else { if (!(!!Date.CultureStrings && !!Date.CultureStrings[code])) { if (typeof exports !== "undefined" && this.exports !== exports) { // we're in a Node enviroment, load it using require try { require("../i18n/" + code + ".js"); lang = code; Date.CultureStrings.lang = code; Date.CultureInfo = new CultureInfo(); } catch (e) { // var str = "The language for '" + code + "' could not be loaded by Node. It likely does not exist."; throw new Error("The DateJS IETF language tag '" + code + "' could not be loaded by Node. It likely does not exist."); } } else if (Date.Config && Date.Config.i18n) { // we know the location of the files, so lets load them async = true; loadI18nScript(code).done(function(){ lang = code; Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings.lang = code; Date.CultureInfo = new CultureInfo(); $D.Parsing.Normalizer.buildReplaceData(); // because this is async if ($D.Grammar) { $D.Grammar.buildGrammarFormats(); // so we can parse those strings... } if (cb) { setTimeout(cb,0); } }); } else { Date.console.error("The DateJS IETF language tag '" + code + "' is not available and has not been loaded."); return false; } } } $D.Parsing.Normalizer.buildReplaceData(); // rebuild normalizer strings if ($D.Grammar) { $D.Grammar.buildGrammarFormats(); // so we can parse those strings... } if (!async && cb) { setTimeout(cb,0); } }, getLoggedKeys: function () { return loggedKeys; }, updateCultureInfo: function () { Date.CultureInfo = new CultureInfo(); } }; $D.i18n.updateCultureInfo(); // run automatically }()); (function () { var $D = Date, $P = $D.prototype, p = function (s, l) { if (!l) { l = 2; } return ("000" + s).slice(l * -1); }; if (typeof window !== "undefined" && typeof window.console !== "undefined" && typeof window.console.log !== "undefined") { $D.console = console; // used only to raise non-critical errors if available } else { // set mock so we don't give errors. $D.console = { log: function(){}, error: function(){} }; } $D.Config = $D.Config || {}; $D.initOverloads = function() { /** * Overload of Date.now. Allows an alternate call for Date.now where it returns the * current Date as an object rather than just milliseconds since the Unix Epoch. * * Also provides an implementation of now() for browsers (IE<9) that don't have it. * * Backwards compatible so with work with either: * Date.now() [returns ms] * or * Date.now(true) [returns Date] */ if (!$D.now) { $D._now = function now() { return new Date().getTime(); }; } else if (!$D._now) { $D._now = $D.now; } $D.now = function (returnObj) { if (returnObj) { return $D.present(); } else { return $D._now(); } }; if ( !$P.toISOString ) { $P.toISOString = function() { return this.getUTCFullYear() + "-" + p(this.getUTCMonth() + 1) + "-" + p(this.getUTCDate()) + "T" + p(this.getUTCHours()) + ":" + p(this.getUTCMinutes()) + ":" + p(this.getUTCSeconds()) + "." + String( (this.getUTCMilliseconds()/1000).toFixed(3)).slice(2, 5) + "Z"; }; } // private if ( $P._toString === undefined ){ $P._toString = $P.toString; } }; $D.initOverloads(); /** * Gets a date that is set to the current date. The time is set to the start of the day (00:00 or 12:00 AM). * @return {Date} The current date. */ $D.today = function () { return new Date().clearTime(); }; /** * Gets a date that is set to the current date and time (same as new Date, but chainable) * @return {Date} The current date. */ $D.present = function () { return new Date(); }; /** * Compares the first date to the second date and returns an number indication of their relative values. * @param {Date} First Date object to compare [Required]. * @param {Date} Second Date object to compare to [Required]. * @return {Number} -1 = date1 is lessthan date2. 0 = values are equal. 1 = date1 is greaterthan date2. */ $D.compare = function (date1, date2) { if (isNaN(date1) || isNaN(date2)) { throw new Error(date1 + " - " + date2); } else if (date1 instanceof Date && date2 instanceof Date) { return (date1 < date2) ? -1 : (date1 > date2) ? 1 : 0; } else { throw new TypeError(date1 + " - " + date2); } }; /** * Compares the first Date object to the second Date object and returns true if they are equal. * @param {Date} First Date object to compare [Required] * @param {Date} Second Date object to compare to [Required] * @return {Boolean} true if dates are equal. false if they are not equal. */ $D.equals = function (date1, date2) { return (date1.compareTo(date2) === 0); }; /** * Gets the language appropriate day name when given the day number(0-6) * eg - 0 == Sunday * @return {String} The day name */ $D.getDayName = function (n) { return Date.CultureInfo.dayNames[n]; }; /** * Gets the day number (0-6) if given a CultureInfo specific string which is a valid dayName, abbreviatedDayName or shortestDayName (two char). * @param {String} The name of the day (eg. "Monday, "Mon", "tuesday", "tue", "We", "we"). * @return {Number} The day number */ $D.getDayNumberFromName = function (name) { var n = Date.CultureInfo.dayNames, m = Date.CultureInfo.abbreviatedDayNames, o = Date.CultureInfo.shortestDayNames, s = name.toLowerCase(); for (var i = 0; i < n.length; i++) { if (n[i].toLowerCase() === s || m[i].toLowerCase() === s || o[i].toLowerCase() === s) { return i; } } return -1; }; /** * Gets the month number (0-11) if given a Culture Info specific string which is a valid monthName or abbreviatedMonthName. * @param {String} The name of the month (eg. "February, "Feb", "october", "oct"). * @return {Number} The day number */ $D.getMonthNumberFromName = function (name) { var n = Date.CultureInfo.monthNames, m = Date.CultureInfo.abbreviatedMonthNames, s = name.toLowerCase(); for (var i = 0; i < n.length; i++) { if (n[i].toLowerCase() === s || m[i].toLowerCase() === s) { return i; } } return -1; }; /** * Gets the language appropriate month name when given the month number(0-11) * eg - 0 == January * @return {String} The month name */ $D.getMonthName = function (n) { return Date.CultureInfo.monthNames[n]; }; /** * Determines if the current date instance is within a LeapYear. * @param {Number} The year. * @return {Boolean} true if date is within a LeapYear, otherwise false. */ $D.isLeapYear = function (year) { return ((year % 4 === 0 && year % 100 !== 0) || year % 400 === 0); }; /** * Gets the number of days in the month, given a year and month value. Automatically corrects for LeapYear. * @param {Number} The year. * @param {Number} The month (0-11). * @return {Number} The number of days in the month. */ $D.getDaysInMonth = function (year, month) { if (!month && $D.validateMonth(year)) { month = year; year = Date.today().getFullYear(); } return [31, ($D.isLeapYear(year) ? 29 : 28), 31, 30, 31, 30, 31, 31, 30, 31, 30, 31][month]; }; $P.getDaysInMonth = function () { return $D.getDaysInMonth(this.getFullYear(), this.getMonth()); }; $D.getTimezoneAbbreviation = function (offset, dst) { var p, n = (dst || false) ? Date.CultureInfo.abbreviatedTimeZoneDST : Date.CultureInfo.abbreviatedTimeZoneStandard; for (p in n) { if (n.hasOwnProperty(p)) { if (n[p] === offset) { return p; } } } return null; }; $D.getTimezoneOffset = function (name, dst) { var i, a =[], z = Date.CultureInfo.timezones; if (!name) { name = (new Date()).getTimezone();} for (i = 0; i < z.length; i++) { if (z[i].name === name.toUpperCase()) { a.push(i); } } if (!z[a[0]]) { return null; } if (a.length === 1 || !dst) { return z[a[0]].offset; } else { for (i=0; i < a.length; i++) { if (z[a[i]].dst) { return z[a[i]].offset; } } } }; $D.getQuarter = function (d) { d = d || new Date(); // If no date supplied, use today var q = [1,2,3,4]; return q[Math.floor(d.getMonth() / 3)]; // ~~~ is a bitwise op. Faster than Math.floor }; $D.getDaysLeftInQuarter = function (d) { d = d || new Date(); var qEnd = new Date(d); qEnd.setMonth(qEnd.getMonth() + 3 - qEnd.getMonth() % 3, 0); return Math.floor((qEnd - d) / 8.64e7); }; // private var validate = function (n, min, max, name) { name = name ? name : "Object"; if (typeof n === "undefined") { return false; } else if (typeof n !== "number") { throw new TypeError(n + " is not a Number."); } else if (n < min || n > max) { // As failing validation is *not* an exceptional circumstance // lets not throw a RangeError Exception here. // It's semantically correct but it's not sensible. return false; } return true; }; /** * Validates the number is within an acceptable range for milliseconds [0-999]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateMillisecond = function (value) { return validate(value, 0, 999, "millisecond"); }; /** * Validates the number is within an acceptable range for seconds [0-59]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateSecond = function (value) { return validate(value, 0, 59, "second"); }; /** * Validates the number is within an acceptable range for minutes [0-59]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateMinute = function (value) { return validate(value, 0, 59, "minute"); }; /** * Validates the number is within an acceptable range for hours [0-23]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateHour = function (value) { return validate(value, 0, 23, "hour"); }; /** * Validates the number is within an acceptable range for the days in a month [0-MaxDaysInMonth]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateDay = function (value, year, month) { if (year === undefined || year === null || month === undefined || month === null) { return false;} return validate(value, 1, $D.getDaysInMonth(year, month), "day"); }; /** * Validates the number is within an acceptable range for months [0-11]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateWeek = function (value) { return validate(value, 0, 53, "week"); }; /** * Validates the number is within an acceptable range for months [0-11]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateMonth = function (value) { return validate(value, 0, 11, "month"); }; /** * Validates the number is within an acceptable range for years. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateYear = function (value) { /** * Per ECMAScript spec the range of times supported by Date objects is * exactly -100,000,000 days to +100,000,000 days measured relative to * midnight at the beginning of 01 January, 1970 UTC. * This gives a range of 8,640,000,000,000,000 milliseconds to either * side of 01 January, 1970 UTC. * * Earliest possible date: Tue, 20 Apr 271,822 B.C. 00:00:00 UTC * Latest possible date: Sat, 13 Sep 275,760 00:00:00 UTC */ return validate(value, -271822, 275760, "year"); }; $D.validateTimezone = function(value) { var timezones = {"ACDT":1,"ACST":1,"ACT":1,"ADT":1,"AEDT":1,"AEST":1,"AFT":1,"AKDT":1,"AKST":1,"AMST":1,"AMT":1,"ART":1,"AST":1,"AWDT":1,"AWST":1,"AZOST":1,"AZT":1,"BDT":1,"BIOT":1,"BIT":1,"BOT":1,"BRT":1,"BST":1,"BTT":1,"CAT":1,"CCT":1,"CDT":1,"CEDT":1,"CEST":1,"CET":1,"CHADT":1,"CHAST":1,"CHOT":1,"ChST":1,"CHUT":1,"CIST":1,"CIT":1,"CKT":1,"CLST":1,"CLT":1,"COST":1,"COT":1,"CST":1,"CT":1,"CVT":1,"CWST":1,"CXT":1,"DAVT":1,"DDUT":1,"DFT":1,"EASST":1,"EAST":1,"EAT":1,"ECT":1,"EDT":1,"EEDT":1,"EEST":1,"EET":1,"EGST":1,"EGT":1,"EIT":1,"EST":1,"FET":1,"FJT":1,"FKST":1,"FKT":1,"FNT":1,"GALT":1,"GAMT":1,"GET":1,"GFT":1,"GILT":1,"GIT":1,"GMT":1,"GST":1,"GYT":1,"HADT":1,"HAEC":1,"HAST":1,"HKT":1,"HMT":1,"HOVT":1,"HST":1,"ICT":1,"IDT":1,"IOT":1,"IRDT":1,"IRKT":1,"IRST":1,"IST":1,"JST":1,"KGT":1,"KOST":1,"KRAT":1,"KST":1,"LHST":1,"LINT":1,"MAGT":1,"MART":1,"MAWT":1,"MDT":1,"MET":1,"MEST":1,"MHT":1,"MIST":1,"MIT":1,"MMT":1,"MSK":1,"MST":1,"MUT":1,"MVT":1,"MYT":1,"NCT":1,"NDT":1,"NFT":1,"NPT":1,"NST":1,"NT":1,"NUT":1,"NZDT":1,"NZST":1,"OMST":1,"ORAT":1,"PDT":1,"PET":1,"PETT":1,"PGT":1,"PHOT":1,"PHT":1,"PKT":1,"PMDT":1,"PMST":1,"PONT":1,"PST":1,"PYST":1,"PYT":1,"RET":1,"ROTT":1,"SAKT":1,"SAMT":1,"SAST":1,"SBT":1,"SCT":1,"SGT":1,"SLST":1,"SRT":1,"SST":1,"SYOT":1,"TAHT":1,"THA":1,"TFT":1,"TJT":1,"TKT":1,"TLT":1,"TMT":1,"TOT":1,"TVT":1,"UCT":1,"ULAT":1,"UTC":1,"UYST":1,"UYT":1,"UZT":1,"VET":1,"VLAT":1,"VOLT":1,"VOST":1,"VUT":1,"WAKT":1,"WAST":1,"WAT":1,"WEDT":1,"WEST":1,"WET":1,"WST":1,"YAKT":1,"YEKT":1,"Z":1}; return (timezones[value] === 1); }; $D.validateTimezoneOffset= function(value) { // timezones go from +14hrs to -12hrs, the +X hours are negative offsets. return (value > -841 && value < 721); }; }()); (function () { var $D = Date, $P = $D.prototype, p = function (s, l) { if (!l) { l = 2; } return ("000" + s).slice(l * -1); }; var validateConfigObject = function (obj) { var result = {}, self = this, prop, testFunc; testFunc = function (prop, func, value) { if (prop === "day") { var month = (obj.month !== undefined) ? obj.month : self.getMonth(); var year = (obj.year !== undefined) ? obj.year : self.getFullYear(); return $D[func](value, year, month); } else { return $D[func](value); } }; for (prop in obj) { if (Object.prototype.hasOwnProperty.call(obj, prop)) { var func = "validate" + prop.charAt(0).toUpperCase() + prop.slice(1); if ($D[func] && obj[prop] !== null && testFunc(prop, func, obj[prop])) { result[prop] = obj[prop]; } } } return result; }; /** * Resets the time of this Date object to 12:00 AM (00:00), which is the start of the day. * @param {Boolean} .clone() this date instance before clearing Time * @return {Date} this */ $P.clearTime = function () { this.setHours(0); this.setMinutes(0); this.setSeconds(0); this.setMilliseconds(0); return this; }; /** * Resets the time of this Date object to the current time ('now'). * @return {Date} this */ $P.setTimeToNow = function () { var n = new Date(); this.setHours(n.getHours()); this.setMinutes(n.getMinutes()); this.setSeconds(n.getSeconds()); this.setMilliseconds(n.getMilliseconds()); return this; }; /** * Returns a new Date object that is an exact date and time copy of the original instance. * @return {Date} A new Date instance */ $P.clone = function () { return new Date(this.getTime()); }; /** * Compares this instance to a Date object and returns an number indication of their relative values. * @param {Date} Date object to compare [Required] * @return {Number} -1 = this is lessthan date. 0 = values are equal. 1 = this is greaterthan date. */ $P.compareTo = function (date) { return Date.compare(this, date); }; /** * Compares this instance to another Date object and returns true if they are equal. * @param {Date} Date object to compare. If no date to compare, new Date() [now] is used. * @return {Boolean} true if dates are equal. false if they are not equal. */ $P.equals = function (date) { return Date.equals(this, (date !== undefined ? date : new Date())); }; /** * Determines if this instance is between a range of two dates or equal to either the start or end dates. * @param {Date} Start of range [Required] * @param {Date} End of range [Required] * @return {Boolean} true is this is between or equal to the start and end dates, else false */ $P.between = function (start, end) { return this.getTime() >= start.getTime() && this.getTime() <= end.getTime(); }; /** * Determines if this date occurs after the date to compare to. * @param {Date} Date object to compare. If no date to compare, new Date() ("now") is used. * @return {Boolean} true if this date instance is greater than the date to compare to (or "now"), otherwise false. */ $P.isAfter = function (date) { return this.compareTo(date || new Date()) === 1; }; /** * Determines if this date occurs before the date to compare to. * @param {Date} Date object to compare. If no date to compare, new Date() ("now") is used. * @return {Boolean} true if this date instance is less than the date to compare to (or "now"). */ $P.isBefore = function (date) { return (this.compareTo(date || new Date()) === -1); }; /** * Determines if the current Date instance occurs today. * @return {Boolean} true if this date instance is 'today', otherwise false. */ /** * Determines if the current Date instance occurs on the same Date as the supplied 'date'. * If no 'date' to compare to is provided, the current Date instance is compared to 'today'. * @param {date} Date object to compare. If no date to compare, the current Date ("now") is used. * @return {Boolean} true if this Date instance occurs on the same Day as the supplied 'date'. */ $P.isToday = $P.isSameDay = function (date) { return this.clone().clearTime().equals((date || new Date()).clone().clearTime()); }; /** * Adds the specified number of milliseconds to this instance. * @param {Number} The number of milliseconds to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addMilliseconds = function (value) { if (!value) { return this; } this.setTime(this.getTime() + value * 1); return this; }; /** * Adds the specified number of seconds to this instance. * @param {Number} The number of seconds to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addSeconds = function (value) { if (!value) { return this; } return this.addMilliseconds(value * 1000); }; /** * Adds the specified number of seconds to this instance. * @param {Number} The number of seconds to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addMinutes = function (value) { if (!value) { return this; } return this.addMilliseconds(value * 60000); // 60*1000 }; /** * Adds the specified number of hours to this instance. * @param {Number} The number of hours to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addHours = function (value) { if (!value) { return this; } return this.addMilliseconds(value * 3600000); // 60*60*1000 }; /** * Adds the specified number of days to this instance. * @param {Number} The number of days to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addDays = function (value) { if (!value) { return this; } this.setDate(this.getDate() + value * 1); return this; }; /** * Adds the specified number of weekdays (ie - not sat or sun) to this instance. * @param {Number} The number of days to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addWeekdays = function (value) { if (!value) { return this; } var day = this.getDay(); var weeks = (Math.ceil(Math.abs(value)/7)); if (day === 0 || day === 6) { if (value > 0) { this.next().monday(); this.addDays(-1); day = this.getDay(); } } if (value < 0) { while (value < 0) { this.addDays(-1); day = this.getDay(); if (day !== 0 && day !== 6) { value++; } } return this; } else if (value > 5 || (6-day) <= value) { value = value + (weeks * 2); } return this.addDays(value); }; /** * Adds the specified number of weeks to this instance. * @param {Number} The number of weeks to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addWeeks = function (value) { if (!value) { return this; } return this.addDays(value * 7); }; /** * Adds the specified number of months to this instance. * @param {Number} The number of months to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addMonths = function (value) { if (!value) { return this; } var n = this.getDate(); this.setDate(1); this.setMonth(this.getMonth() + value * 1); this.setDate(Math.min(n, $D.getDaysInMonth(this.getFullYear(), this.getMonth()))); return this; }; $P.addQuarters = function (value) { if (!value) { return this; } // note this will take you to the same point in the quarter as you are now. // i.e. - if you are 15 days into the quarter you'll be 15 days into the resulting one. // bonus: this allows adding fractional quarters return this.addMonths(value * 3); }; /** * Adds the specified number of years to this instance. * @param {Number} The number of years to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addYears = function (value) { if (!value) { return this; } return this.addMonths(value * 12); }; /** * Adds (or subtracts) to the value of the years, months, weeks, days, hours, minutes, seconds, milliseconds of the date instance using given configuration object. Positive and Negative values allowed. * Example

	Date.today().add( { days: 1, months: 1 } )

	new Date().add( { years: -1 } )
	
* @param {Object} Configuration object containing attributes (months, days, etc.) * @return {Date} this */ $P.add = function (config) { if (typeof config === "number") { this._orient = config; return this; } var x = config; if (x.day) { // If we should be a different date than today (eg: for 'tomorrow -1d', etc). // Should only effect parsing, not direct usage (eg, Finish and FinishExact) if ((x.day - this.getDate()) !== 0) { this.setDate(x.day); } } if (x.milliseconds) { this.addMilliseconds(x.milliseconds); } if (x.seconds) { this.addSeconds(x.seconds); } if (x.minutes) { this.addMinutes(x.minutes); } if (x.hours) { this.addHours(x.hours); } if (x.weeks) { this.addWeeks(x.weeks); } if (x.months) { this.addMonths(x.months); } if (x.years) { this.addYears(x.years); } if (x.days) { this.addDays(x.days); } return this; }; /** * Get the week number. Week one (1) is the week which contains the first Thursday of the year. Monday is considered the first day of the week. * The .getWeek() function does NOT convert the date to UTC. The local datetime is used. * Please use .getISOWeek() to get the week of the UTC converted date. * @return {Number} 1 to 53 */ $P.getWeek = function (utc) { // Create a copy of this date object var self, target = new Date(this.valueOf()); if (utc) { target.addMinutes(target.getTimezoneOffset()); self = target.clone(); } else { self = this; } // ISO week date weeks start on monday // so correct the day number var dayNr = (self.getDay() + 6) % 7; // ISO 8601 states that week 1 is the week // with the first thursday of that year. // Set the target date to the thursday in the target week target.setDate(target.getDate() - dayNr + 3); // Store the millisecond value of the target date var firstThursday = target.valueOf(); // Set the target to the first thursday of the year // First set the target to january first target.setMonth(0, 1); // Not a thursday? Correct the date to the next thursday if (target.getDay() !== 4) { target.setMonth(0, 1 + ((4 - target.getDay()) + 7) % 7); } // The weeknumber is the number of weeks between the // first thursday of the year and the thursday in the target week return 1 + Math.ceil((firstThursday - target) / 604800000); // 604800000 = 7 * 24 * 3600 * 1000 }; /** * Get the ISO 8601 week number. Week one ("01") is the week which contains the first Thursday of the year. Monday is considered the first day of the week. * The .getISOWeek() function does convert the date to it's UTC value. Please use .getWeek() to get the week of the local date. * @return {String} "01" to "53" */ $P.getISOWeek = function () { return p(this.getWeek(true)); }; /** * Moves the date to Monday of the week set. Week one (1) is the week which contains the first Thursday of the year. * @param {Number} A Number (1 to 53) that represents the week of the year. * @return {Date} this */ $P.setWeek = function (n) { if ((n - this.getWeek()) === 0) { if (this.getDay() !== 1) { return this.moveToDayOfWeek(1, (this.getDay() > 1 ? -1 : 1)); } else { return this; } } else { return this.moveToDayOfWeek(1, (this.getDay() > 1 ? -1 : 1)).addWeeks(n - this.getWeek()); } }; $P.setQuarter = function (qtr) { var month = Math.abs(((qtr-1) * 3) + 1); return this.setMonth(month, 1); }; $P.getQuarter = function () { return Date.getQuarter(this); }; $P.getDaysLeftInQuarter = function () { return Date.getDaysLeftInQuarter(this); }; /** * Moves the date to the next n'th occurrence of the dayOfWeek starting from the beginning of the month. The number (-1) is a magic number and will return the last occurrence of the dayOfWeek in the month. * @param {Number} The dayOfWeek to move to * @param {Number} The n'th occurrence to move to. Use (-1) to return the last occurrence in the month * @return {Date} this */ $P.moveToNthOccurrence = function (dayOfWeek, occurrence) { if (dayOfWeek === "Weekday") { if (occurrence > 0) { this.moveToFirstDayOfMonth(); if (this.is().weekday()) { occurrence -= 1; } } else if (occurrence < 0) { this.moveToLastDayOfMonth(); if (this.is().weekday()) { occurrence += 1; } } else { return this; } return this.addWeekdays(occurrence); } var shift = 0; if (occurrence > 0) { shift = occurrence - 1; } else if (occurrence === -1) { this.moveToLastDayOfMonth(); if (this.getDay() !== dayOfWeek) { this.moveToDayOfWeek(dayOfWeek, -1); } return this; } return this.moveToFirstDayOfMonth().addDays(-1).moveToDayOfWeek(dayOfWeek, +1).addWeeks(shift); }; var moveToN = function (getFunc, addFunc, nVal) { return function (value, orient) { var diff = (value - this[getFunc]() + nVal * (orient || +1)) % nVal; return this[addFunc]((diff === 0) ? diff += nVal * (orient || +1) : diff); }; }; /** * Move to the next or last dayOfWeek based on the orient value. * @param {Number} The dayOfWeek to move to * @param {Number} Forward (+1) or Back (-1). Defaults to +1. [Optional] * @return {Date} this */ $P.moveToDayOfWeek = moveToN("getDay", "addDays", 7); /** * Move to the next or last month based on the orient value. * @param {Number} The month to move to. 0 = January, 11 = December * @param {Number} Forward (+1) or Back (-1). Defaults to +1. [Optional] * @return {Date} this */ $P.moveToMonth = moveToN("getMonth", "addMonths", 12); /** * Get the Ordinate of the current day ("th", "st", "rd"). * @return {String} */ $P.getOrdinate = function () { var num = this.getDate(); return ord(num); }; /** * Get the Ordinal day (numeric day number) of the year, adjusted for leap year. * @return {Number} 1 through 365 (366 in leap years) */ $P.getOrdinalNumber = function () { return Math.ceil((this.clone().clearTime() - new Date(this.getFullYear(), 0, 1)) / 86400000) + 1; }; /** * Get the time zone abbreviation of the current date. * @return {String} The abbreviated time zone name (e.g. "EST") */ $P.getTimezone = function () { return $D.getTimezoneAbbreviation(this.getUTCOffset(), this.isDaylightSavingTime()); }; $P.setTimezoneOffset = function (offset) { var here = this.getTimezoneOffset(), there = Number(offset) * -6 / 10; return (there || there === 0) ? this.addMinutes(there - here) : this; }; $P.setTimezone = function (offset) { return this.setTimezoneOffset($D.getTimezoneOffset(offset)); }; /** * Indicates whether Daylight Saving Time is observed in the current time zone. * @return {Boolean} true|false */ $P.hasDaylightSavingTime = function () { return (Date.today().set({month: 0, day: 1}).getTimezoneOffset() !== Date.today().set({month: 6, day: 1}).getTimezoneOffset()); }; /** * Indicates whether this Date instance is within the Daylight Saving Time range for the current time zone. * @return {Boolean} true|false */ $P.isDaylightSavingTime = function () { return Date.today().set({month: 0, day: 1}).getTimezoneOffset() !== this.getTimezoneOffset(); }; /** * Get the offset from UTC of the current date. * @return {String} The 4-character offset string prefixed with + or - (e.g. "-0500") */ $P.getUTCOffset = function (offset) { var n = (offset || this.getTimezoneOffset()) * -10 / 6, r; if (n < 0) { r = (n - 10000).toString(); return r.charAt(0) + r.substr(2); } else { r = (n + 10000).toString(); return "+" + r.substr(1); } }; /** * Returns the number of milliseconds between this date and date. * @param {Date} Defaults to now * @return {Number} The diff in milliseconds */ $P.getElapsed = function (date) { return (date || new Date()) - this; }; /** * Set the value of year, month, day, hour, minute, second, millisecond of date instance using given configuration object. * Example

	Date.today().set( { day: 20, month: 1 } )

	new Date().set( { millisecond: 0 } )
	
* * @param {Object} Configuration object containing attributes (month, day, etc.) * @return {Date} this */ $P.set = function (config) { config = validateConfigObject.call(this, config); var key; for (key in config) { if (Object.prototype.hasOwnProperty.call(config, key)) { var name = key.charAt(0).toUpperCase() + key.slice(1); var addFunc, getFunc; if (key !== "week" && key !== "month" && key !== "timezone" && key !== "timezoneOffset") { name += "s"; } addFunc = "add" + name; getFunc = "get" + name; if (key === "month") { addFunc = addFunc + "s"; } else if (key === "year"){ getFunc = "getFullYear"; } if (key !== "day" && key !== "timezone" && key !== "timezoneOffset" && key !== "week" && key !== "hour") { this[addFunc](config[key] - this[getFunc]()); } else if ( key === "timezone"|| key === "timezoneOffset" || key === "week" || key === "hour") { this["set"+name](config[key]); } } } // day has to go last because you can't validate the day without first knowing the month if (config.day) { this.addDays(config.day - this.getDate()); } return this; }; /** * Moves the date to the first day of the month. * @return {Date} this */ $P.moveToFirstDayOfMonth = function () { return this.set({ day: 1 }); }; /** * Moves the date to the last day of the month. * @return {Date} this */ $P.moveToLastDayOfMonth = function () { return this.set({ day: $D.getDaysInMonth(this.getFullYear(), this.getMonth())}); }; /** * Converts the value of the current Date object to its equivalent string representation. * Format Specifiers * CUSTOM DATE AND TIME FORMAT STRINGS * Format Description Example * ------ --------------------------------------------------------------------------- ----------------------- * s The seconds of the minute between 0-59. "0" to "59" * ss The seconds of the minute with leading zero if required. "00" to "59" * * m The minute of the hour between 0-59. "0" or "59" * mm The minute of the hour with leading zero if required. "00" or "59" * * h The hour of the day between 1-12. "1" to "12" * hh The hour of the day with leading zero if required. "01" to "12" * * H The hour of the day between 0-23. "0" to "23" * HH The hour of the day with leading zero if required. "00" to "23" * * d The day of the month between 1 and 31. "1" to "31" * dd The day of the month with leading zero if required. "01" to "31" * ddd Abbreviated day name. Date.CultureInfo.abbreviatedDayNames. "Mon" to "Sun" * dddd The full day name. Date.CultureInfo.dayNames. "Monday" to "Sunday" * * M The month of the year between 1-12. "1" to "12" * MM The month of the year with leading zero if required. "01" to "12" * MMM Abbreviated month name. Date.CultureInfo.abbreviatedMonthNames. "Jan" to "Dec" * MMMM The full month name. Date.CultureInfo.monthNames. "January" to "December" * * yy The year as a two-digit number. "99" or "08" * yyyy The full four digit year. "1999" or "2008" * * t Displays the first character of the A.M./P.M. designator. "A" or "P" * Date.CultureInfo.amDesignator or Date.CultureInfo.pmDesignator * tt Displays the A.M./P.M. designator. "AM" or "PM" * Date.CultureInfo.amDesignator or Date.CultureInfo.pmDesignator * * S The ordinal suffix ("st, "nd", "rd" or "th") of the current day. "st, "nd", "rd" or "th" * * STANDARD DATE AND TIME FORMAT STRINGS * Format Description Example *------ --------------------------------------------------------------------------- ----------------------- * d The CultureInfo shortDate Format Pattern "M/d/yyyy" * D The CultureInfo longDate Format Pattern "dddd, MMMM dd, yyyy" * F The CultureInfo fullDateTime Format Pattern "dddd, MMMM dd, yyyy h:mm:ss tt" * m The CultureInfo monthDay Format Pattern "MMMM dd" * r The CultureInfo rfc1123 Format Pattern "ddd, dd MMM yyyy HH:mm:ss GMT" * s The CultureInfo sortableDateTime Format Pattern "yyyy-MM-ddTHH:mm:ss" * t The CultureInfo shortTime Format Pattern "h:mm tt" * T The CultureInfo longTime Format Pattern "h:mm:ss tt" * u The CultureInfo universalSortableDateTime Format Pattern "yyyy-MM-dd HH:mm:ssZ" * y The CultureInfo yearMonth Format Pattern "MMMM, yyyy" * * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @return {String} A string representation of the current Date object. */ var ord = function (n) { switch (n * 1) { case 1: case 21: case 31: return "st"; case 2: case 22: return "nd"; case 3: case 23: return "rd"; default: return "th"; } }; var parseStandardFormats = function (format) { var y, c = Date.CultureInfo.formatPatterns; switch (format) { case "d": return this.toString(c.shortDate); case "D": return this.toString(c.longDate); case "F": return this.toString(c.fullDateTime); case "m": return this.toString(c.monthDay); case "r": case "R": y = this.clone().addMinutes(this.getTimezoneOffset()); return y.toString(c.rfc1123) + " GMT"; case "s": return this.toString(c.sortableDateTime); case "t": return this.toString(c.shortTime); case "T": return this.toString(c.longTime); case "u": y = this.clone().addMinutes(this.getTimezoneOffset()); return y.toString(c.universalSortableDateTime); case "y": return this.toString(c.yearMonth); default: return false; } }; var parseFormatStringsClosure = function (context) { return function (m) { if (m.charAt(0) === "\\") { return m.replace("\\", ""); } switch (m) { case "hh": return p(context.getHours() < 13 ? (context.getHours() === 0 ? 12 : context.getHours()) : (context.getHours() - 12)); case "h": return context.getHours() < 13 ? (context.getHours() === 0 ? 12 : context.getHours()) : (context.getHours() - 12); case "HH": return p(context.getHours()); case "H": return context.getHours(); case "mm": return p(context.getMinutes()); case "m": return context.getMinutes(); case "ss": return p(context.getSeconds()); case "s": return context.getSeconds(); case "yyyy": return p(context.getFullYear(), 4); case "yy": return p(context.getFullYear()); case "y": return context.getFullYear(); case "E": case "dddd": return Date.CultureInfo.dayNames[context.getDay()]; case "ddd": return Date.CultureInfo.abbreviatedDayNames[context.getDay()]; case "dd": return p(context.getDate()); case "d": return context.getDate(); case "MMMM": return Date.CultureInfo.monthNames[context.getMonth()]; case "MMM": return Date.CultureInfo.abbreviatedMonthNames[context.getMonth()]; case "MM": return p((context.getMonth() + 1)); case "M": return context.getMonth() + 1; case "t": return context.getHours() < 12 ? Date.CultureInfo.amDesignator.substring(0, 1) : Date.CultureInfo.pmDesignator.substring(0, 1); case "tt": return context.getHours() < 12 ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator; case "S": return ord(context.getDate()); case "W": return context.getWeek(); case "WW": return context.getISOWeek(); case "Q": return "Q" + context.getQuarter(); case "q": return String(context.getQuarter()); case "z": return context.getTimezone(); case "Z": case "X": return Date.getTimezoneOffset(context.getTimezone()); case "ZZ": // Timezone offset in seconds return context.getTimezoneOffset() * -60; case "u": return context.getDay(); case "L": return ($D.isLeapYear(context.getFullYear())) ? 1 : 0; case "B": // Swatch Internet Time (.beats) return "@"+((context.getUTCSeconds() + (context.getUTCMinutes()*60) + ((context.getUTCHours()+1)*3600))/86.4); default: return m; } }; }; $P.toString = function (format, ignoreStandards) { // Standard Date and Time Format Strings. Formats pulled from CultureInfo file and // may vary by culture. if (!ignoreStandards && format && format.length === 1) { output = parseStandardFormats.call(this, format); if (output) { return output; } } var parseFormatStrings = parseFormatStringsClosure(this); return format ? format.replace(/((\\)?(dd?d?d?|MM?M?M?|yy?y?y?|hh?|HH?|mm?|ss?|tt?|S|q|Q|WW?W?W?)(?![^\[]*\]))/g, parseFormatStrings).replace(/\[|\]/g, "") : this._toString(); }; }()); /************************************************************* * SugarPak - Domain Specific Language - Syntactical Sugar * *************************************************************/ (function () { var $D = Date, $P = $D.prototype, $N = Number.prototype; // private $P._orient = +1; // private $P._nth = null; // private $P._is = false; // private $P._same = false; // private $P._isSecond = false; // private $N._dateElement = "days"; /** * Moves the date to the next instance of a date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.today().next().friday();
	Date.today().next().fri();
	Date.today().next().march();
	Date.today().next().mar();
	Date.today().next().week();
	
* * @return {Date} date */ $P.next = function () { this._move = true; this._orient = +1; return this; }; /** * Creates a new Date (Date.today()) and moves the date to the next instance of the date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.next().friday();
	Date.next().fri();
	Date.next().march();
	Date.next().mar();
	Date.next().week();
	
* * @return {Date} date */ $D.next = function () { return $D.today().next(); }; /** * Moves the date to the previous instance of a date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.today().last().friday();
	Date.today().last().fri();
	Date.today().last().march();
	Date.today().last().mar();
	Date.today().last().week();
	
* * @return {Date} date */ $P.last = $P.prev = $P.previous = function () { this._move = true; this._orient = -1; return this; }; /** * Creates a new Date (Date.today()) and moves the date to the previous instance of the date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.last().friday();
	Date.last().fri();
	Date.previous().march();
	Date.prev().mar();
	Date.last().week();
	
* * @return {Date} date */ $D.last = $D.prev = $D.previous = function () { return $D.today().last(); }; /** * Performs a equality check when followed by either a month name, day name or .weekday() function. * Example

	Date.today().is().friday(); // true|false
	Date.today().is().fri();
	Date.today().is().march();
	Date.today().is().mar();
	
* * @return {Boolean} true|false */ $P.is = function () { this._is = true; return this; }; /** * Determines if two date objects occur on/in exactly the same instance of the subsequent date part function. * The function .same() must be followed by a date part function (example: .day(), .month(), .year(), etc). * * An optional Date can be passed in the date part function. If now date is passed as a parameter, 'Now' is used. * * The following example demonstrates how to determine if two dates fall on the exact same day. * * Example

	var d1 = Date.today(); // today at 00:00
	var d2 = new Date();   // exactly now.

	// Do they occur on the same day?
	d1.same().day(d2); // true
	
	// Do they occur on the same hour?
	d1.same().hour(d2); // false, unless d2 hour is '00' (midnight).
	
	// What if it's the same day, but one year apart?
	var nextYear = Date.today().add(1).year();

	d1.same().day(nextYear); // false, because the dates must occur on the exact same day. 
	
* * Scenario: Determine if a given date occurs during some week period 2 months from now. * * Example

	var future = Date.today().add(2).months();
	return someDate.same().week(future); // true|false;
	
* * @return {Boolean} true|false */ $P.same = function () { this._same = true; this._isSecond = false; return this; }; /** * Determines if the current date/time occurs during Today. Must be preceded by the .is() function. * Example

	someDate.is().today();    // true|false
	new Date().is().today();  // true
	Date.today().is().today();// true
	Date.today().add(-1).day().is().today(); // false
	
* * @return {Boolean} true|false */ $P.today = function () { return this.same().day(); }; /** * Determines if the current date is a weekday. This function must be preceded by the .is() function. * Example

	Date.today().is().weekday(); // true|false
	
* * @return {Boolean} true|false */ $P.weekday = function () { if (this._nth) { return df("Weekday").call(this); } if (this._move) { return this.addWeekdays(this._orient); } if (this._is) { this._is = false; return (!this.is().sat() && !this.is().sun()); } return false; }; /** * Determines if the current date is on the weekend. This function must be preceded by the .is() function. * Example

	Date.today().is().weekend(); // true|false
	
* * @return {Boolean} true|false */ $P.weekend = function () { if (this._is) { this._is = false; return (this.is().sat() || this.is().sun()); } return false; }; /** * Sets the Time of the current Date instance. A string "6:15 pm" or config object {hour:18, minute:15} are accepted. * Example

	// Set time to 6:15pm with a String
	Date.today().at("6:15pm");

	// Set time to 6:15pm with a config object
	Date.today().at({hour:18, minute:15});
	
* * @return {Date} date */ $P.at = function (time) { return (typeof time === "string") ? $D.parse(this.toString("d") + " " + time) : this.set(time); }; /** * Creates a new Date() and adds this (Number) to the date based on the preceding date element function (eg. second|minute|hour|day|month|year). * Example

	// Undeclared Numbers must be wrapped with parentheses. Requirment of JavaScript.
	(3).days().fromNow();
	(6).months().fromNow();

	// Declared Number variables do not require parentheses. 
	var n = 6;
	n.months().fromNow();
	
* * @return {Date} A new Date instance */ $N.fromNow = $N.after = function (date) { var c = {}; c[this._dateElement] = this; return ((!date) ? new Date() : date.clone()).add(c); }; /** * Creates a new Date() and subtract this (Number) from the date based on the preceding date element function (eg. second|minute|hour|day|month|year). * Example

	// Undeclared Numbers must be wrapped with parentheses. Requirment of JavaScript.
	(3).days().ago();
	(6).months().ago();

	// Declared Number variables do not require parentheses. 
	var n = 6;
	n.months().ago();
	
* * @return {Date} A new Date instance */ $N.ago = $N.before = function (date) { var c = {}, s = (this._dateElement[this._dateElement.length-1] !== "s") ? this._dateElement + "s" : this._dateElement; c[s] = this * -1; return ((!date) ? new Date() : date.clone()).add(c); }; // Do NOT modify the following string tokens. These tokens are used to build dynamic functions. // All culture-specific strings can be found in the CultureInfo files. var dx = ("sunday monday tuesday wednesday thursday friday saturday").split(/\s/), mx = ("january february march april may june july august september october november december").split(/\s/), px = ("Millisecond Second Minute Hour Day Week Month Year Quarter Weekday").split(/\s/), pxf = ("Milliseconds Seconds Minutes Hours Date Week Month FullYear Quarter").split(/\s/), nth = ("final first second third fourth fifth").split(/\s/), de; /** * Returns an object literal of all the date parts. * Example

	var o = new Date().toObject();
	
	// { year: 2008, month: 4, week: 20, day: 13, hour: 18, minute: 9, second: 32, millisecond: 812 }
	
	// The object properties can be referenced directly from the object.
	
	alert(o.day);  // alerts "13"
	alert(o.year); // alerts "2008"
	
* * @return {Date} An object literal representing the original date object. */ $P.toObject = function () { var o = {}; for (var i = 0; i < px.length; i++) { if (this["get" + pxf[i]]) { o[px[i].toLowerCase()] = this["get" + pxf[i]](); } } return o; }; /** * Returns a date created from an object literal. Ignores the .week property if set in the config. * Example

	var o = new Date().toObject();
	
	return Date.fromObject(o); // will return the same date. 

	var o2 = {month: 1, day: 20, hour: 18}; // birthday party!
	Date.fromObject(o2);
	
* * @return {Date} An object literal representing the original date object. */ $D.fromObject = function(config) { config.week = null; return Date.today().set(config); }; // Create day name functions and abbreviated day name functions (eg. monday(), friday(), fri()). var df = function (n) { return function () { if (this._is) { this._is = false; return this.getDay() === n; } if (this._move) { this._move = null; } if (this._nth !== null) { // If the .second() function was called earlier, remove the _orient // from the date, and then continue. // This is required because 'second' can be used in two different context. // // Example // // Date.today().add(1).second(); // Date.march().second().monday(); // // Things get crazy with the following... // Date.march().add(1).second().second().monday(); // but it works!! // if (this._isSecond) { this.addSeconds(this._orient * -1); } // make sure we reset _isSecond this._isSecond = false; var ntemp = this._nth; this._nth = null; var temp = this.clone().moveToLastDayOfMonth(); this.moveToNthOccurrence(n, ntemp); if (this > temp) { throw new RangeError($D.getDayName(n) + " does not occur " + ntemp + " times in the month of " + $D.getMonthName(temp.getMonth()) + " " + temp.getFullYear() + "."); } return this; } return this.moveToDayOfWeek(n, this._orient); }; }; var sdf = function (n) { return function () { var t = $D.today(), shift = n - t.getDay(); if (n === 0 && Date.CultureInfo.firstDayOfWeek === 1 && t.getDay() !== 0) { shift = shift + 7; } return t.addDays(shift); }; }; // Create month name functions and abbreviated month name functions (eg. january(), march(), mar()). var month_instance_functions = function (n) { return function () { if (this._is) { this._is = false; return this.getMonth() === n; } return this.moveToMonth(n, this._orient); }; }; var month_static_functions = function (n) { return function () { return $D.today().set({ month: n, day: 1 }); }; }; var processTerms = function (names, staticFunc, instanceFunc) { for (var i = 0; i < names.length; i++) { // Create constant static Name variables. $D[names[i].toUpperCase()] = $D[names[i].toUpperCase().substring(0, 3)] = i; // Create Name functions. $D[names[i]] = $D[names[i].substring(0, 3)] = staticFunc(i); // Create Name instance functions. $P[names[i]] = $P[names[i].substring(0, 3)] = instanceFunc(i); } }; processTerms(dx, sdf, df); processTerms(mx, month_static_functions, month_instance_functions); // Create date element functions and plural date element functions used with Date (eg. day(), days(), months()). var ef = function (j) { return function () { // if the .second() function was called earlier, the _orient // has alread been added. Just return this and reset _isSecond. if (this._isSecond) { this._isSecond = false; return this; } if (this._same) { this._same = this._is = false; var o1 = this.toObject(), o2 = (arguments[0] || new Date()).toObject(), v = "", k = j.toLowerCase(); // the substr trick with -1 doesn't work in IE8 or less k = (k[k.length-1] === "s") ? k.substring(0,k.length-1) : k; for (var m = (px.length - 1); m > -1; m--) { v = px[m].toLowerCase(); if (o1[v] !== o2[v]) { return false; } if (k === v) { break; } } return true; } if (j.substring(j.length - 1) !== "s") { j += "s"; } if (this._move) { this._move = null; } return this["add" + j](this._orient); }; }; var nf = function (n) { return function () { this._dateElement = n; return this; }; }; for (var k = 0; k < px.length; k++) { de = px[k].toLowerCase(); if(de !== "weekday") { // Create date element functions and plural date element functions used with Date (eg. day(), days(), months()). $P[de] = $P[de + "s"] = ef(px[k]); // Create date element functions and plural date element functions used with Number (eg. day(), days(), months()). $N[de] = $N[de + "s"] = nf(de + "s"); } } $P._ss = ef("Second"); var nthfn = function (n) { return function (dayOfWeek) { if (this._same) { return this._ss(arguments[0]); } if (dayOfWeek || dayOfWeek === 0) { return this.moveToNthOccurrence(dayOfWeek, n); } this._nth = n; // if the operator is 'second' add the _orient, then deal with it later... if (n === 2 && (dayOfWeek === undefined || dayOfWeek === null)) { this._isSecond = true; return this.addSeconds(this._orient); } return this; }; }; for (var l = 0; l < nth.length; l++) { $P[nth[l]] = (l === 0) ? nthfn(-1) : nthfn(l); } }()); (function () { "use strict"; Date.Parsing = { Exception: function (s) { this.message = "Parse error at '" + s.substring(0, 10) + " ...'"; } }; var $P = Date.Parsing; var dayOffsets = { standard: [0,31,59,90,120,151,181,212,243,273,304,334], leap: [0,31,60,91,121,152,182,213,244,274,305,335] }; $P.isLeapYear = function(year) { return ((year % 4 === 0) && (year % 100 !== 0)) || (year % 400 === 0); }; var utils = { multiReplace : function (str, hash ) { var key; for (key in hash) { if (Object.prototype.hasOwnProperty.call(hash, key)) { var regex; if (typeof hash[key] === "function") { } else { regex = (hash[key] instanceof RegExp) ? hash[key] : new RegExp(hash[key], "g"); } str = str.replace(regex, key); } } return str; }, getDayOfYearFromWeek : function (obj) { var d, jan4, offset; obj.weekDay = (!obj.weekDay && obj.weekDay !== 0) ? 1 : obj.weekDay; d = new Date(obj.year, 0, 4); jan4 = d.getDay() === 0 ? 7 : d.getDay(); // JS is 0 indexed on Sunday. offset = jan4+3; obj.dayOfYear = ((obj.week * 7) + (obj.weekDay === 0 ? 7 : obj.weekDay))-offset; return obj; }, getDayOfYear : function (obj, dayOffset) { if (!obj.dayOfYear) { obj = utils.getDayOfYearFromWeek(obj); } for (var i=0;i <= dayOffset.length;i++) { if (obj.dayOfYear < dayOffset[i] || i === dayOffset.length) { obj.day = obj.day ? obj.day : (obj.dayOfYear - dayOffset[i-1]); break; } else { obj.month = i; } } return obj; }, adjustForTimeZone : function (obj, date) { var offset; if (obj.zone.toUpperCase() === "Z" || (obj.zone_hours === 0 && obj.zone_minutes === 0)) { // it's UTC/GML so work out the current timeszone offset offset = -date.getTimezoneOffset(); } else { offset = (obj.zone_hours*60) + (obj.zone_minutes || 0); if (obj.zone_sign === "+") { offset *= -1; } offset -= date.getTimezoneOffset(); } date.setMinutes(date.getMinutes()+offset); return date; }, setDefaults : function (obj) { obj.year = obj.year || Date.today().getFullYear(); obj.hours = obj.hours || 0; obj.minutes = obj.minutes || 0; obj.seconds = obj.seconds || 0; obj.milliseconds = obj.milliseconds || 0; if (!(!obj.month && (obj.week || obj.dayOfYear))) { // if we have a month, or if we don't but don't have the day calculation data obj.month = obj.month || 0; obj.day = obj.day || 1; } return obj; }, dataNum: function (data, mod, explict, postProcess) { var dataNum = data*1; if (mod) { if (postProcess) { return data ? mod(data)*1 : data; } else { return data ? mod(dataNum) : data; } } else if (!explict){ return data ? dataNum : data; } else { return (data && typeof data !== "undefined") ? dataNum : data; } }, timeDataProcess: function (obj) { var timeObj = {}; for (var x in obj.data) { if (obj.data.hasOwnProperty(x)) { timeObj[x] = obj.ignore[x] ? obj.data[x] : utils.dataNum(obj.data[x], obj.mods[x], obj.explict[x], obj.postProcess[x]); } } if (obj.data.secmins) { obj.data.secmins = obj.data.secmins.replace(",", ".") * 60; if (!timeObj.minutes) { timeObj.minutes = obj.data.secmins; } else if (!timeObj.seconds) { timeObj.seconds = obj.data.secmins; } delete obj.secmins; } return timeObj; }, buildTimeObjectFromData: function (data) { var time = utils.timeDataProcess({ data: { year : data[1], month : data[5], day : data[7], week : data[8], dayOfYear : data[10], hours : data[15], zone_hours : data[23], zone_minutes : data[24], zone : data[21], zone_sign : data[22], weekDay : data[9], minutes: data[16], seconds: data[19], milliseconds: data[20], secmins: data[18] }, mods: { month: function(data) { return data-1; }, weekDay: function (data) { data = Math.abs(data); return (data === 7 ? 0 : data); }, minutes: function (data) { return data.replace(":",""); }, seconds: function (data) { return Math.floor( (data.replace(":","").replace(",","."))*1 ); }, milliseconds: function (data) { return (data.replace(",",".")*1000); } }, postProcess: { minutes: true, seconds: true, milliseconds: true }, explict: { zone_hours: true, zone_minutes: true }, ignore: { zone: true, zone_sign: true, secmins: true } }); return time; }, addToHash: function (hash, keys, data) { keys = keys; data = data; var len = keys.length; for (var i = 0; i < len; i++) { hash[keys[i]] = data[i]; } return hash; }, combineRegex: function (r1, r2) { return new RegExp("(("+r1.source+")\\s("+r2.source+"))"); }, getDateNthString: function(add, last, inc){ if (add) { return Date.today().addDays(inc).toString("d"); } else if (last) { return Date.today().last()[inc]().toString("d"); } }, buildRegexData: function (array) { var arr = []; var len = array.length; for (var i=0; i < len; i++) { if (Object.prototype.toString.call(array[i]) === '[object Array]') { // oldIE compat version of Array.isArray arr.push(this.combineRegex(array[i][0], array[i][1])); } else { arr.push(array[i]); } } return arr; } }; $P.processTimeObject = function (obj) { var date, dayOffset; utils.setDefaults(obj); dayOffset = ($P.isLeapYear(obj.year)) ? dayOffsets.leap : dayOffsets.standard; if (!obj.month && (obj.week || obj.dayOfYear)) { utils.getDayOfYear(obj, dayOffset); } else { obj.dayOfYear = dayOffset[obj.month] + obj.day; } date = new Date(obj.year, obj.month, obj.day, obj.hours, obj.minutes, obj.seconds, obj.milliseconds); if (obj.zone) { utils.adjustForTimeZone(obj, date); // adjust (and calculate) for timezone } return date; }; $P.ISO = { regex : /^([\+-]?\d{4}(?!\d{2}\b))((-?)((0[1-9]|1[0-2])(\3([12]\d|0[1-9]|3[01]))?|W([0-4]\d|5[0-3])(-?[1-7])?|(00[1-9]|0[1-9]\d|[12]\d{2}|3([0-5]\d|6[1-6])))([T\s]((([01]\d|2[0-4])((:?)[0-5]\d)?|24\:?00)([\.,]\d+(?!:))?)?(\17[0-5]\d([\.,]\d+)?)?\s?([zZ]|([\+-])([01]\d|2[0-3]):?([0-5]\d)?)?)?)?$/, parse : function (s) { var time, data = s.match(this.regex); if (!data || !data.length) { return null; } time = utils.buildTimeObjectFromData(data); if (!time.year || (!time.year && (!time.month && !time.day) && (!time.week && !time.dayOfYear)) ) { return null; } return $P.processTimeObject(time); } }; $P.Numeric = { isNumeric: function (e){return!isNaN(parseFloat(e))&&isFinite(e);}, regex: /\b([0-1]?[0-9])([0-3]?[0-9])([0-2]?[0-9]?[0-9][0-9])\b/i, parse: function (s) { var data, i, time = {}, order = Date.CultureInfo.dateElementOrder.split(""); if (!(this.isNumeric(s)) || // if it's non-numeric OR (s[0] === "+" && s[0] === "-")) { // It's an arithmatic string (eg +/-1000) return null; } if (s.length < 5 && s.indexOf(".") < 0 && s.indexOf("/") < 0) { // assume it's just a year. time.year = s; return $P.processTimeObject(time); } data = s.match(this.regex); if (!data || !data.length) { return null; } for (i=0; i < order.length; i++) { switch(order[i]) { case "d": time.day = data[i+1]; break; case "m": time.month = (data[i+1]-1); break; case "y": time.year = data[i+1]; break; } } return $P.processTimeObject(time); } }; $P.Normalizer = { regexData: function () { var $R = Date.CultureInfo.regexPatterns; return utils.buildRegexData([ $R.tomorrow, $R.yesterday, [$R.past, $R.mon], [$R.past, $R.tue], [$R.past, $R.wed], [$R.past, $R.thu], [$R.past, $R.fri], [$R.past, $R.sat], [$R.past, $R.sun] ]); }, basicReplaceHash : function() { var $R = Date.CultureInfo.regexPatterns; return { "January": $R.jan.source, "February": $R.feb, "March": $R.mar, "April": $R.apr, "May": $R.may, "June": $R.jun, "July": $R.jul, "August": $R.aug, "September": $R.sep, "October": $R.oct, "November": $R.nov, "December": $R.dec, "": /\bat\b/gi, " ": /\s{2,}/, "am": $R.inTheMorning, "9am": $R.thisMorning, "pm": $R.inTheEvening, "7pm":$R.thisEvening }; }, keys : function(){ return [ utils.getDateNthString(true, false, 1), // tomorrow utils.getDateNthString(true, false, -1), // yesterday utils.getDateNthString(false, true, "monday"), //last mon utils.getDateNthString(false, true, "tuesday"), //last tues utils.getDateNthString(false, true, "wednesday"), //last wed utils.getDateNthString(false, true, "thursday"), //last thurs utils.getDateNthString(false, true, "friday"), //last fri utils.getDateNthString(false, true, "saturday"), //last sat utils.getDateNthString(false, true, "sunday") //last sun ]; }, buildRegexFunctions: function () { var $R = Date.CultureInfo.regexPatterns; var __ = Date.i18n.__; var tomorrowRE = new RegExp("(\\b\\d\\d?("+__("AM")+"|"+__("PM")+")? )("+$R.tomorrow.source.slice(1)+")", "i"); // adapted tomorrow regex for AM PM relative dates var todayRE = new RegExp($R.today.source + "(?!\\s*([+-]))\\b"); // today, but excludes the math operators (eg "today + 2h") this.replaceFuncs = [ [todayRE, function (full) { return (full.length > 1) ? Date.today().toString("d") : full; }], [tomorrowRE, function(full, m1) { var t = Date.today().addDays(1).toString("d"); return (t + " " + m1); }], [$R.amThisMorning, function(str, am){return am;}], [$R.pmThisEvening, function(str, pm){return pm;}] ]; }, buildReplaceData: function () { this.buildRegexFunctions(); this.replaceHash = utils.addToHash(this.basicReplaceHash(), this.keys(), this.regexData()); }, stringReplaceFuncs: function (s) { for (var i=0; i < this.replaceFuncs.length; i++) { s = s.replace(this.replaceFuncs[i][0], this.replaceFuncs[i][1]); } return s; }, parse: function (s) { s = this.stringReplaceFuncs(s); s = utils.multiReplace(s, this.replaceHash); try { var n = s.split(/([\s\-\.\,\/\x27]+)/); if (n.length === 3 && $P.Numeric.isNumeric(n[0]) && $P.Numeric.isNumeric(n[2]) && (n[2].length >= 4)) { // ok, so we're dealing with x/year. But that's not a full date. // This fixes wonky dateElementOrder parsing when set to dmy order. if (Date.CultureInfo.dateElementOrder[0] === "d") { s = "1/" + n[0] + "/" + n[2]; // set to 1st of month and normalize the seperator } } } catch (e) {} return s; } }; $P.Normalizer.buildReplaceData(); }()); (function () { var $P = Date.Parsing; var _ = $P.Operators = { // // Tokenizers // rtoken: function (r) { // regex token return function (s) { var mx = s.match(r); if (mx) { return ([ mx[0], s.substring(mx[0].length) ]); } else { throw new $P.Exception(s); } }; }, token: function () { // whitespace-eating token return function (s) { return _.rtoken(new RegExp("^\\s*" + s + "\\s*"))(s); }; }, stoken: function (s) { // string token return _.rtoken(new RegExp("^" + s)); }, // Atomic Operators until: function (p) { return function (s) { var qx = [], rx = null; while (s.length) { try { rx = p.call(this, s); } catch (e) { qx.push(rx[0]); s = rx[1]; continue; } break; } return [ qx, s ]; }; }, many: function (p) { return function (s) { var rx = [], r = null; while (s.length) { try { r = p.call(this, s); } catch (e) { return [ rx, s ]; } rx.push(r[0]); s = r[1]; } return [ rx, s ]; }; }, // generator operators -- see below optional: function (p) { return function (s) { var r = null; try { r = p.call(this, s); } catch (e) { return [ null, s ]; } return [ r[0], r[1] ]; }; }, not: function (p) { return function (s) { try { p.call(this, s); } catch (e) { return [null, s]; } throw new $P.Exception(s); }; }, ignore: function (p) { return p ? function (s) { var r = null; r = p.call(this, s); return [null, r[1]]; } : null; }, product: function () { var px = arguments[0], qx = Array.prototype.slice.call(arguments, 1), rx = []; for (var i = 0 ; i < px.length ; i++) { rx.push(_.each(px[i], qx)); } return rx; }, cache: function (rule) { var cache = {}, cache_length = 0, cache_keys = [], CACHE_MAX = Date.Config.CACHE_MAX || 100000, r = null; var cacheCheck = function () { if (cache_length === CACHE_MAX) { // kill several keys, don't want to have to do this all the time... for (var i=0; i < 10; i++) { var key = cache_keys.shift(); if (key) { delete cache[key]; cache_length--; } } } }; return function (s) { cacheCheck(); try { r = cache[s] = (cache[s] || rule.call(this, s)); } catch (e) { r = cache[s] = e; } cache_length++; cache_keys.push(s); if (r instanceof $P.Exception) { throw r; } else { return r; } }; }, // vector operators -- see below any: function () { var px = arguments; return function (s) { var r = null; for (var i = 0; i < px.length; i++) { if (px[i] == null) { continue; } try { r = (px[i].call(this, s)); } catch (e) { r = null; } if (r) { return r; } } throw new $P.Exception(s); }; }, each: function () { var px = arguments; return function (s) { var rx = [], r = null; for (var i = 0; i < px.length ; i++) { if (px[i] == null) { continue; } try { r = (px[i].call(this, s)); } catch (e) { throw new $P.Exception(s); } rx.push(r[0]); s = r[1]; } return [ rx, s]; }; }, all: function () { var px = arguments, _ = _; return _.each(_.optional(px)); }, // delimited operators sequence: function (px, d, c) { d = d || _.rtoken(/^\s*/); c = c || null; if (px.length === 1) { return px[0]; } return function (s) { var r = null, q = null; var rx = []; for (var i = 0; i < px.length ; i++) { try { r = px[i].call(this, s); } catch (e) { break; } rx.push(r[0]); try { q = d.call(this, r[1]); } catch (ex) { q = null; break; } s = q[1]; } if (!r) { throw new $P.Exception(s); } if (q) { throw new $P.Exception(q[1]); } if (c) { try { r = c.call(this, r[1]); } catch (ey) { throw new $P.Exception(r[1]); } } return [ rx, (r?r[1]:s) ]; }; }, // // Composite Operators // between: function (d1, p, d2) { d2 = d2 || d1; var _fn = _.each(_.ignore(d1), p, _.ignore(d2)); return function (s) { var rx = _fn.call(this, s); return [[rx[0][0], r[0][2]], rx[1]]; }; }, list: function (p, d, c) { d = d || _.rtoken(/^\s*/); c = c || null; return (p instanceof Array ? _.each(_.product(p.slice(0, -1), _.ignore(d)), p.slice(-1), _.ignore(c)) : _.each(_.many(_.each(p, _.ignore(d))), px, _.ignore(c))); }, set: function (px, d, c) { d = d || _.rtoken(/^\s*/); c = c || null; return function (s) { // r is the current match, best the current 'best' match // which means it parsed the most amount of input var r = null, p = null, q = null, rx = null, best = [[], s], last = false; // go through the rules in the given set for (var i = 0; i < px.length ; i++) { // last is a flag indicating whether this must be the last element // if there is only 1 element, then it MUST be the last one q = null; p = null; r = null; last = (px.length === 1); // first, we try simply to match the current pattern // if not, try the next pattern try { r = px[i].call(this, s); } catch (e) { continue; } // since we are matching against a set of elements, the first // thing to do is to add r[0] to matched elements rx = [[r[0]], r[1]]; // if we matched and there is still input to parse and // we don't already know this is the last element, // we're going to next check for the delimiter ... // if there's none, or if there's no input left to parse // than this must be the last element after all ... if (r[1].length > 0 && ! last) { try { q = d.call(this, r[1]); } catch (ex) { last = true; } } else { last = true; } // if we parsed the delimiter and now there's no more input, // that means we shouldn't have parsed the delimiter at all // so don't update r and mark this as the last element ... if (!last && q[1].length === 0) { last = true; } // so, if this isn't the last element, we're going to see if // we can get any more matches from the remaining (unmatched) // elements ... if (!last) { // build a list of the remaining rules we can match against, // i.e., all but the one we just matched against var qx = []; for (var j = 0; j < px.length ; j++) { if (i !== j) { qx.push(px[j]); } } // now invoke recursively set with the remaining input // note that we don't include the closing delimiter ... // we'll check for that ourselves at the end p = _.set(qx, d).call(this, q[1]); // if we got a non-empty set as a result ... // (otw rx already contains everything we want to match) if (p[0].length > 0) { // update current result, which is stored in rx ... // basically, pick up the remaining text from p[1] // and concat the result from p[0] so that we don't // get endless nesting ... rx[0] = rx[0].concat(p[0]); rx[1] = p[1]; } } // at this point, rx either contains the last matched element // or the entire matched set that starts with this element. // now we just check to see if this variation is better than // our best so far, in terms of how much of the input is parsed if (rx[1].length < best[1].length) { best = rx; } // if we've parsed all the input, then we're finished if (best[1].length === 0) { break; } } // so now we've either gone through all the patterns trying them // as the initial match; or we found one that parsed the entire // input string ... // if best has no matches, just return empty set ... if (best[0].length === 0) { return best; } // if a closing delimiter is provided, then we have to check it also if (c) { // we try this even if there is no remaining input because the pattern // may well be optional or match empty input ... try { q = c.call(this, best[1]); } catch (ey) { throw new $P.Exception(best[1]); } // it parsed ... be sure to update the best match remaining input best[1] = q[1]; } // if we're here, either there was no closing delimiter or we parsed it // so now we have the best match; just return it! return best; }; }, forward: function (gr, fname) { return function (s) { return gr[fname].call(this, s); }; }, // // Translation Operators // replace: function (rule, repl) { return function (s) { var r = rule.call(this, s); return [repl, r[1]]; }; }, process: function (rule, fn) { return function (s) { var r = rule.call(this, s); return [fn.call(this, r[0]), r[1]]; }; }, min: function (min, rule) { return function (s) { var rx = rule.call(this, s); if (rx[0].length < min) { throw new $P.Exception(s); } return rx; }; } }; // Generator Operators And Vector Operators // Generators are operators that have a signature of F(R) => R, // taking a given rule and returning another rule, such as // ignore, which parses a given rule and throws away the result. // Vector operators are those that have a signature of F(R1,R2,...) => R, // take a list of rules and returning a new rule, such as each. // Generator operators are converted (via the following _generator // function) into functions that can also take a list or array of rules // and return an array of new rules as though the function had been // called on each rule in turn (which is what actually happens). // This allows generators to be used with vector operators more easily. // Example: // each(ignore(foo, bar)) instead of each(ignore(foo), ignore(bar)) // This also turns generators into vector operators, which allows // constructs like: // not(cache(foo, bar)) var _generator = function (op) { function gen() { var args = null, rx = [], px, i; if (arguments.length > 1) { args = Array.prototype.slice.call(arguments); } else if (arguments[0] instanceof Array) { args = arguments[0]; } if (args) { px = args.shift(); if (px.length > 0) { args.unshift(px[i]); rx.push(op.apply(null, args)); args.shift(); return rx; } } else { return op.apply(null, arguments); } } return gen; }; var gx = "optional not ignore cache".split(/\s/); for (var i = 0 ; i < gx.length ; i++) { _[gx[i]] = _generator(_[gx[i]]); } var _vector = function (op) { return function () { if (arguments[0] instanceof Array) { return op.apply(null, arguments[0]); } else { return op.apply(null, arguments); } }; }; var vx = "each any all".split(/\s/); for (var j = 0 ; j < vx.length ; j++) { _[vx[j]] = _vector(_[vx[j]]); } }()); (function () { var $D = Date; var flattenAndCompact = function (ax) { var rx = []; for (var i = 0; i < ax.length; i++) { if (ax[i] instanceof Array) { rx = rx.concat(flattenAndCompact(ax[i])); } else { if (ax[i]) { rx.push(ax[i]); } } } return rx; }; var parseMeridian = function () { if (this.meridian && (this.hour || this.hour === 0)) { if (this.meridian === "a" && this.hour > 11 && Date.Config.strict24hr){ throw "Invalid hour and meridian combination"; } else if (this.meridian === "p" && this.hour < 12 && Date.Config.strict24hr){ throw "Invalid hour and meridian combination"; } else if (this.meridian === "p" && this.hour < 12) { this.hour = this.hour + 12; } else if (this.meridian === "a" && this.hour === 12) { this.hour = 0; } } }; var setDefaults = function () { var now = new Date(); if ((this.hour || this.minute) && (!this.month && !this.year && !this.day)) { this.day = now.getDate(); } if (!this.year) { this.year = now.getFullYear(); } if (!this.month && this.month !== 0) { this.month = now.getMonth(); } if (!this.day) { this.day = 1; } if (!this.hour) { this.hour = 0; } if (!this.minute) { this.minute = 0; } if (!this.second) { this.second = 0; } if (!this.millisecond) { this.millisecond = 0; } }; var finishUtils = { getToday: function () { if (this.now || "hour minute second".indexOf(this.unit) !== -1) { return new Date(); } else { return $D.today(); } }, setDaysFromWeekday: function (today, orient){ var gap; orient = orient || 1; this.unit = "day"; gap = ($D.getDayNumberFromName(this.weekday) - today.getDay()); this.days = gap ? ((gap + (orient * 7)) % 7) : (orient * 7); return this; }, setMonthsFromMonth: function (today, orient) { var gap; orient = orient || 1; this.unit = "month"; gap = (this.month - today.getMonth()); this.months = gap ? ((gap + (orient * 12)) % 12) : (orient * 12); this.month = null; return this; }, setDMYFromWeekday: function () { var d = Date[this.weekday](); this.day = d.getDate(); if (!this.month) { this.month = d.getMonth(); } this.year = d.getFullYear(); return this; }, setUnitValue: function (orient) { if (!this.value && this.operator && this.operator !== null && this[this.unit + "s"] && this[this.unit + "s"] !== null) { this[this.unit + "s"] = this[this.unit + "s"] + ((this.operator === "add") ? 1 : -1) + (this.value||0) * orient; } else if (this[this.unit + "s"] == null || this.operator != null) { if (!this.value) { this.value = 1; } this[this.unit + "s"] = this.value * orient; } }, generateDateFromWeeks: function () { var weekday = (this.weekday !== undefined) ? this.weekday : "today"; var d = Date[weekday]().addWeeks(this.weeks); if (this.now) { d.setTimeToNow(); } return d; } }; $D.Translator = { hour: function (s) { return function () { this.hour = Number(s); }; }, minute: function (s) { return function () { this.minute = Number(s); }; }, second: function (s) { return function () { this.second = Number(s); }; }, /* for ss.s format */ secondAndMillisecond: function (s) { return function () { var mx = s.match(/^([0-5][0-9])\.([0-9]{1,3})/); this.second = Number(mx[1]); this.millisecond = Number(mx[2]); }; }, meridian: function (s) { return function () { this.meridian = s.slice(0, 1).toLowerCase(); }; }, timezone: function (s) { return function () { var n = s.replace(/[^\d\+\-]/g, ""); if (n.length) { this.timezoneOffset = Number(n); } else { this.timezone = s.toLowerCase(); } }; }, day: function (x) { var s = x[0]; return function () { this.day = Number(s.match(/\d+/)[0]); if (this.day < 1) { throw "invalid day"; } }; }, month: function (s) { return function () { this.month = (s.length === 3) ? "jan feb mar apr may jun jul aug sep oct nov dec".indexOf(s)/4 : Number(s) - 1; if (this.month < 0) { throw "invalid month"; } }; }, year: function (s) { return function () { var n = Number(s); this.year = ((s.length > 2) ? n : (n + (((n + 2000) < Date.CultureInfo.twoDigitYearMax) ? 2000 : 1900))); }; }, rday: function (s) { return function () { switch (s) { case "yesterday": this.days = -1; break; case "tomorrow": this.days = 1; break; case "today": this.days = 0; break; case "now": this.days = 0; this.now = true; break; } }; }, finishExact: function (x) { var d; x = (x instanceof Array) ? x : [x]; for (var i = 0 ; i < x.length ; i++) { if (x[i]) { x[i].call(this); } } setDefaults.call(this); parseMeridian.call(this); if (this.day > $D.getDaysInMonth(this.year, this.month)) { throw new RangeError(this.day + " is not a valid value for days."); } d = new Date(this.year, this.month, this.day, this.hour, this.minute, this.second, this.millisecond); if (this.year < 100) { d.setFullYear(this.year); // means years less that 100 are process correctly. JS will parse it otherwise as 1900-1999. } if (this.timezone) { d.set({ timezone: this.timezone }); } else if (this.timezoneOffset) { d.set({ timezoneOffset: this.timezoneOffset }); } return d; }, finish: function (x) { var today, expression, orient, temp; x = (x instanceof Array) ? flattenAndCompact(x) : [ x ]; if (x.length === 0) { return null; } for (var i = 0 ; i < x.length ; i++) { if (typeof x[i] === "function") { x[i].call(this); } } if (this.now && !this.unit && !this.operator) { return new Date(); } else { today = finishUtils.getToday.call(this); } expression = !!(this.days && this.days !== null || this.orient || this.operator); orient = ((this.orient === "past" || this.operator === "subtract") ? -1 : 1); if (this.month && this.unit === "week") { this.value = this.month + 1; delete this.month; delete this.day; } if ((this.month || this.month === 0) && "year day hour minute second".indexOf(this.unit) !== -1) { if (!this.value) { this.value = this.month + 1; } this.month = null; expression = true; } if (!expression && this.weekday && !this.day && !this.days) { finishUtils.setDMYFromWeekday.call(this); } if (expression && this.weekday && this.unit !== "month" && this.unit !== "week") { finishUtils.setDaysFromWeekday.call(this, today, orient); } if (this.weekday && this.unit !== "week" && !this.day && !this.days) { temp = Date[this.weekday](); this.day = temp.getDate(); if (temp.getMonth() !== today.getMonth()) { this.month = temp.getMonth(); } } if (this.month && this.unit === "day" && this.operator) { if (!this.value) { this.value = (this.month + 1); } this.month = null; } if (this.value != null && this.month != null && this.year != null) { this.day = this.value * 1; } if (this.month && !this.day && this.value) { today.set({ day: this.value * 1 }); if (!expression) { this.day = this.value * 1; } } if (!this.month && this.value && this.unit === "month" && !this.now) { this.month = this.value; expression = true; } if (expression && (this.month || this.month === 0) && this.unit !== "year") { finishUtils.setMonthsFromMonth.call(this, today, orient); } if (!this.unit) { this.unit = "day"; } finishUtils.setUnitValue.call(this, orient); parseMeridian.call(this); if ((this.month || this.month === 0) && !this.day) { this.day = 1; } if (!this.orient && !this.operator && this.unit === "week" && this.value && !this.day && !this.month) { return Date.today().setWeek(this.value); } if (this.unit === "week" && this.weeks && !this.day && !this.month) { return finishUtils.generateDateFromWeeks.call(this); } if (expression && this.timezone && this.day && this.days) { this.day = this.days; } if (expression){ today.add(this); } else { today.set(this); } if (this.timezone) { this.timezone = this.timezone.toUpperCase(); var offset = $D.getTimezoneOffset(this.timezone); var timezone; if (today.hasDaylightSavingTime()) { // lets check that we're being sane with timezone setting timezone = $D.getTimezoneAbbreviation(offset, today.isDaylightSavingTime()); if (timezone !== this.timezone) { // bugger, we're in a place where things like EST vs EDT matters. if (today.isDaylightSavingTime()) { today.addHours(-1); } else { today.addHours(1); } } } today.setTimezoneOffset(offset); } return today; } }; }()); (function () { var $D = Date; $D.Grammar = {}; var _ = $D.Parsing.Operators, g = $D.Grammar, t = $D.Translator, _fn; // Allow rolling up into general purpose rules _fn = function () { return _.each(_.any.apply(null, arguments), _.not(g.ctoken2("timeContext"))); }; g.datePartDelimiter = _.rtoken(/^([\s\-\.\,\/\x27]+)/); g.timePartDelimiter = _.stoken(":"); g.whiteSpace = _.rtoken(/^\s*/); g.generalDelimiter = _.rtoken(/^(([\s\,]|at|@|on)+)/); var _C = {}; g.ctoken = function (keys) { var fn = _C[keys]; if (! fn) { var c = Date.CultureInfo.regexPatterns; var kx = keys.split(/\s+/), px = []; for (var i = 0; i < kx.length ; i++) { px.push(_.replace(_.rtoken(c[kx[i]]), kx[i])); } fn = _C[keys] = _.any.apply(null, px); } return fn; }; g.ctoken2 = function (key) { return _.rtoken(Date.CultureInfo.regexPatterns[key]); }; var cacheProcessRtoken = function (key, token, type, eachToken) { if (eachToken) { g[key] = _.cache(_.process(_.each(_.rtoken(token),_.optional(g.ctoken2(eachToken))), type)); } else { g[key] = _.cache(_.process(_.rtoken(token), type)); } }; var cacheProcessCtoken = function (token, type) { return _.cache(_.process(g.ctoken2(token), type)); }; var _F = {}; //function cache var _get = function (f) { _F[f] = (_F[f] || g.format(f)[0]); return _F[f]; }; g.allformats = function (fx) { var rx = []; if (fx instanceof Array) { for (var i = 0; i < fx.length; i++) { rx.push(_get(fx[i])); } } else { rx.push(_get(fx)); } return rx; }; g.formats = function (fx) { if (fx instanceof Array) { var rx = []; for (var i = 0 ; i < fx.length ; i++) { rx.push(_get(fx[i])); } return _.any.apply(null, rx); } else { return _get(fx); } }; var grammarFormats = { timeFormats: function(){ var i, RTokenKeys = [ "h", "hh", "H", "HH", "m", "mm", "s", "ss", "ss.s", "z", "zz" ], RToken = [ /^(0[0-9]|1[0-2]|[1-9])/, /^(0[0-9]|1[0-2])/, /^([0-1][0-9]|2[0-3]|[0-9])/, /^([0-1][0-9]|2[0-3])/, /^([0-5][0-9]|[0-9])/, /^[0-5][0-9]/, /^([0-5][0-9]|[0-9])/, /^[0-5][0-9]/, /^[0-5][0-9]\.[0-9]{1,3}/, /^((\+|\-)\s*\d\d\d\d)|((\+|\-)\d\d\:?\d\d)/, /^((\+|\-)\s*\d\d\d\d)|((\+|\-)\d\d\:?\d\d)/ ], tokens = [ t.hour, t.hour, t.hour, t.hour, t.minute, t.minute, t.second, t.second, t.secondAndMillisecond, t.timezone, t.timezone ]; for (i=0; i < RTokenKeys.length; i++) { cacheProcessRtoken(RTokenKeys[i], RToken[i], tokens[i]); } g.hms = _.cache(_.sequence([g.H, g.m, g.s], g.timePartDelimiter)); g.t = cacheProcessCtoken("shortMeridian", t.meridian); g.tt = cacheProcessCtoken("longMeridian", t.meridian); g.zzz = cacheProcessCtoken("timezone", t.timezone); g.timeSuffix = _.each(_.ignore(g.whiteSpace), _.set([ g.tt, g.zzz ])); g.time = _.each(_.optional(_.ignore(_.stoken("T"))), g.hms, g.timeSuffix); }, dateFormats: function () { // pre-loaded rules for different date part order preferences var _setfn = function () { return _.set(arguments, g.datePartDelimiter); }; var i, RTokenKeys = [ "d", "dd", "M", "MM", "y", "yy", "yyy", "yyyy" ], RToken = [ /^([0-2]\d|3[0-1]|\d)/, /^([0-2]\d|3[0-1])/, /^(1[0-2]|0\d|\d)/, /^(1[0-2]|0\d)/, /^(\d+)/, /^(\d\d)/, /^(\d\d?\d?\d?)/, /^(\d\d\d\d)/ ], tokens = [ t.day, t.day, t.month, t.month, t.year, t.year, t.year, t.year ], eachToken = [ "ordinalSuffix", "ordinalSuffix" ]; for (i=0; i < RTokenKeys.length; i++) { cacheProcessRtoken(RTokenKeys[i], RToken[i], tokens[i], eachToken[i]); } g.MMM = g.MMMM = _.cache(_.process(g.ctoken("jan feb mar apr may jun jul aug sep oct nov dec"), t.month)); g.ddd = g.dddd = _.cache(_.process(g.ctoken("sun mon tue wed thu fri sat"), function (s) { return function () { this.weekday = s; }; } )); g.day = _fn(g.d, g.dd); g.month = _fn(g.M, g.MMM); g.year = _fn(g.yyyy, g.yy); g.mdy = _setfn(g.ddd, g.month, g.day, g.year); g.ymd = _setfn(g.ddd, g.year, g.month, g.day); g.dmy = _setfn(g.ddd, g.day, g.month, g.year); g.date = function (s) { return ((g[Date.CultureInfo.dateElementOrder] || g.mdy).call(this, s)); }; }, relative: function () { // relative date / time expressions g.orientation = _.process(g.ctoken("past future"), function (s) { return function () { this.orient = s; }; } ); g.operator = _.process(g.ctoken("add subtract"), function (s) { return function () { this.operator = s; }; } ); g.rday = _.process(g.ctoken("yesterday tomorrow today now"), t.rday); g.unit = _.process(g.ctoken("second minute hour day week month year"), function (s) { return function () { this.unit = s; }; } ); } }; g.buildGrammarFormats = function () { // these need to be rebuilt every time the language changes. _C = {}; grammarFormats.timeFormats(); grammarFormats.dateFormats(); grammarFormats.relative(); g.value = _.process(_.rtoken(/^([-+]?\d+)?(st|nd|rd|th)?/), function (s) { return function () { this.value = s.replace(/\D/g, ""); }; } ); g.expression = _.set([g.rday, g.operator, g.value, g.unit, g.orientation, g.ddd, g.MMM ]); g.format = _.process(_.many( _.any( // translate format specifiers into grammar rules _.process( _.rtoken(/^(dd?d?d?(?!e)|MM?M?M?|yy?y?y?|hh?|HH?|mm?|ss?|tt?|zz?z?)/), function (fmt) { if (g[fmt]) { return g[fmt]; } else { throw $D.Parsing.Exception(fmt); } } ), // translate separator tokens into token rules _.process(_.rtoken(/^[^dMyhHmstz]+/), // all legal separators function (s) { return _.ignore(_.stoken(s)); } ) ) ), // construct the parser ... function (rules) { return _.process(_.each.apply(null, rules), t.finishExact); } ); // starting rule for general purpose grammar g._start = _.process(_.set([ g.date, g.time, g.expression ], g.generalDelimiter, g.whiteSpace), t.finish); }; g.buildGrammarFormats(); // parsing date format specifiers - ex: "h:m:s tt" // this little guy will generate a custom parser based // on the format string, ex: g.format("h:m:s tt") // check for these formats first g._formats = g.formats([ "\"yyyy-MM-ddTHH:mm:ssZ\"", "yyyy-MM-ddTHH:mm:ss.sz", "yyyy-MM-ddTHH:mm:ssZ", "yyyy-MM-ddTHH:mm:ssz", "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-ddTHH:mmZ", "yyyy-MM-ddTHH:mmz", "yyyy-MM-ddTHH:mm", "ddd, MMM dd, yyyy H:mm:ss tt", "ddd MMM d yyyy HH:mm:ss zzz", "MMddyyyy", "ddMMyyyy", "Mddyyyy", "ddMyyyy", "Mdyyyy", "dMyyyy", "yyyy", "Mdyy", "dMyy", "d" ]); // real starting rule: tries selected formats first, // then general purpose rule g.start = function (s) { try { var r = g._formats.call({}, s); if (r[1].length === 0) { return r; } } catch (e) {} return g._start.call({}, s); }; }()); (function () { var $D = Date; /** * @desc Converts the specified string value into its JavaScript Date equivalent using CultureInfo specific format information. * * Example

	///////////
	// Dates //
	///////////

	// 15-Oct-2004
	var d1 = Date.parse("10/15/2004");

	// 15-Oct-2004
	var d1 = Date.parse("15-Oct-2004");

	// 15-Oct-2004
	var d1 = Date.parse("2004.10.15");

	//Fri Oct 15, 2004
	var d1 = Date.parse("Fri Oct 15, 2004");

	///////////
	// Times //
	///////////

	// Today at 10 PM.
	var d1 = Date.parse("10 PM");

	// Today at 10:30 PM.
	var d1 = Date.parse("10:30 P.M.");

	// Today at 6 AM.
	var d1 = Date.parse("06am");

	/////////////////////
	// Dates and Times //
	/////////////////////

	// 8-July-2004 @ 10:30 PM
	var d1 = Date.parse("July 8th, 2004, 10:30 PM");

	// 1-July-2004 @ 10:30 PM
	var d1 = Date.parse("2004-07-01T22:30:00");

	////////////////////
	// Relative Dates //
	////////////////////

	// Returns today's date. The string "today" is culture specific.
	var d1 = Date.parse("today");

	// Returns yesterday's date. The string "yesterday" is culture specific.
	var d1 = Date.parse("yesterday");

	// Returns the date of the next thursday.
	var d1 = Date.parse("Next thursday");

	// Returns the date of the most previous monday.
	var d1 = Date.parse("last monday");

	// Returns today's day + one year.
	var d1 = Date.parse("next year");

	///////////////
	// Date Math //
	///////////////

	// Today + 2 days
	var d1 = Date.parse("t+2");

	// Today + 2 days
	var d1 = Date.parse("today + 2 days");

	// Today + 3 months
	var d1 = Date.parse("t+3m");

	// Today - 1 year
	var d1 = Date.parse("today - 1 year");

	// Today - 1 year
	var d1 = Date.parse("t-1y"); 


	/////////////////////////////
	// Partial Dates and Times //
	/////////////////////////////

	// July 15th of this year.
	var d1 = Date.parse("July 15");

	// 15th day of current day and year.
	var d1 = Date.parse("15");

	// July 1st of current year at 10pm.
	var d1 = Date.parse("7/1 10pm");
	
* * @param {String} The string value to convert into a Date object [Required] * @return {Date} A Date object or null if the string cannot be converted into a Date. */ var parseUtils = { removeOrds: function (s) { ords = s.match(/\b(\d+)(?:st|nd|rd|th)\b/); // find ordinal matches s = ((ords && ords.length === 2) ? s.replace(ords[0], ords[1]) : s); return s; }, grammarParser: function (s) { var r = null; try { r = $D.Grammar.start.call({}, s.replace(/^\s*(\S*(\s+\S+)*)\s*$/, "$1")); } catch (e) { return null; } return ((r[1].length === 0) ? r[0] : null); }, nativeFallback: function(s) { var t; try { // ok we haven't parsed it, last ditch attempt with the built-in parser. t = Date._parse(s); return (t || t === 0) ? new Date(t) : null; } catch (e) { return null; } } }; function parse (s) { var d; if (!s) { return null; } if (s instanceof Date) { return s.clone(); } if (s.length >= 4 && s.charAt(0) !== "0" && s.charAt(0) !== "+"&& s.charAt(0) !== "-") { // ie: 2004 will pass, 0800 won't. // Start with specific formats d = $D.Parsing.ISO.parse(s) || $D.Parsing.Numeric.parse(s); } if (d instanceof Date && !isNaN(d.getTime())) { return d; } else { // find ordinal dates (1st, 3rd, 8th, etc and remove them as they cause parsing issues) s = $D.Parsing.Normalizer.parse(parseUtils.removeOrds(s)); d = parseUtils.grammarParser(s); if (d !== null) { return d; } else { return parseUtils.nativeFallback(s); } } } if (!$D._parse) { $D._parse = $D.parse; } $D.parse = parse; Date.getParseFunction = function (fx) { var fns = Date.Grammar.allformats(fx); return function (s) { var r = null; for (var i = 0; i < fns.length; i++) { try { r = fns[i].call({}, s); } catch (e) { continue; } if (r[1].length === 0) { return r[0]; } } return null; }; }; /** * Converts the specified string value into its JavaScript Date equivalent using the specified format {String} or formats {Array} and the CultureInfo specific format information. * The format of the string value must match one of the supplied formats exactly. * * Example

	// 15-Oct-2004
	var d1 = Date.parseExact("10/15/2004", "M/d/yyyy");

	// 15-Oct-2004
	var d1 = Date.parse("15-Oct-2004", "M-ddd-yyyy");

	// 15-Oct-2004
	var d1 = Date.parse("2004.10.15", "yyyy.MM.dd");

	// Multiple formats
	var d1 = Date.parseExact("10/15/2004", ["M/d/yyyy", "MMMM d, yyyy"]);
	
* * @param {String} The string value to convert into a Date object [Required]. * @param {Object} The expected format {String} or an array of expected formats {Array} of the date string [Required]. * @return {Date} A Date object or null if the string cannot be converted into a Date. */ $D.parseExact = function (s, fx) { return $D.getParseFunction(fx)(s); }; }()); (function () { var $D = Date, $P = $D.prototype, // $C = $D.CultureInfo, // not used atm p = function (s, l) { if (!l) { l = 2; } return ("000" + s).slice(l * -1); }; /** * Converts a PHP format string to Java/.NET format string. * A PHP format string can be used with ._format or .format. * A Java/.NET format string can be used with .toString(). * The .parseExact function will only accept a Java/.NET format string * * Example * var f1 = "%m/%d/%y" * var f2 = Date.normalizeFormat(f1); // "MM/dd/yy" * * new Date().format(f1); // "04/13/08" * new Date()._format(f1); // "04/13/08" * new Date().toString(f2); // "04/13/08" * * var date = Date.parseExact("04/13/08", f2); // Sun Apr 13 2008 * * @param {String} A PHP format string consisting of one or more format spcifiers. * @return {String} The PHP format converted to a Java/.NET format string. */ var normalizerSubstitutions = { "d" : "dd", "%d": "dd", "D" : "ddd", "%a": "ddd", "j" : "dddd", "l" : "dddd", "%A": "dddd", "S" : "S", "F" : "MMMM", "%B": "MMMM", "m" : "MM", "%m": "MM", "M" : "MMM", "%b": "MMM", "%h": "MMM", "n" : "M", "Y" : "yyyy", "%Y": "yyyy", "y" : "yy", "%y": "yy", "g" : "h", "%I": "h", "G" : "H", "h" : "hh", "H" : "HH", "%H": "HH", "i" : "mm", "%M": "mm", "s" : "ss", "%S": "ss", "%r": "hh:mm tt", "%R": "H:mm", "%T": "H:mm:ss", "%X": "t", "%x": "d", "%e": "d", "%D": "MM/dd/yy", "%n": "\\n", "%t": "\\t", "e" : "z", "T" : "z", "%z": "z", "%Z": "z", "Z" : "ZZ", "N" : "u", "w" : "u", "%w": "u", "W" : "W", "%V": "W" }; var normalizer = { substitutes: function (m) { return normalizerSubstitutions[m]; }, interpreted: function (m, x) { var y; switch (m) { case "%u": return x.getDay() + 1; case "z": return x.getOrdinalNumber(); case "%j": return p(x.getOrdinalNumber(), 3); case "%U": var d1 = x.clone().set({month: 0, day: 1}).addDays(-1).moveToDayOfWeek(0), d2 = x.clone().addDays(1).moveToDayOfWeek(0, -1); return (d2 < d1) ? "00" : p((d2.getOrdinalNumber() - d1.getOrdinalNumber()) / 7 + 1); case "%W": return p(x.getWeek()); case "t": return $D.getDaysInMonth(x.getFullYear(), x.getMonth()); case "o": case "%G": return x.setWeek(x.getISOWeek()).toString("yyyy"); case "%g": return x._format("%G").slice(-2); case "a": case "%p": return t("tt").toLowerCase(); case "A": return t("tt").toUpperCase(); case "u": return p(x.getMilliseconds(), 3); case "I": return (x.isDaylightSavingTime()) ? 1 : 0; case "O": return x.getUTCOffset(); case "P": y = x.getUTCOffset(); return y.substring(0, y.length - 2) + ":" + y.substring(y.length - 2); case "B": var now = new Date(); return Math.floor(((now.getHours() * 3600) + (now.getMinutes() * 60) + now.getSeconds() + (now.getTimezoneOffset() + 60) * 60) / 86.4); case "c": return x.toISOString().replace(/\"/g, ""); case "U": return $D.strtotime("now"); case "%c": return t("d") + " " + t("t"); case "%C": return Math.floor(x.getFullYear() / 100 + 1); } }, shouldOverrideDefaults: function (m) { switch (m) { case "%e": return true; default: return false; } }, parse: function (m, context) { var formatString, c = context || new Date(); formatString = normalizer.substitutes(m); if (formatString) { return formatString; } formatString = normalizer.interpreted(m, c); if (formatString) { return formatString; } else { return m; } } }; $D.normalizeFormat = function (format, context) { return format.replace(/(%|\\)?.|%%/g, function(t){ return normalizer.parse(t, context); }); }; /** * Format a local Unix timestamp according to locale settings * * Example: * Date.strftime("%m/%d/%y", new Date()); // "04/13/08" * Date.strftime("c", "2008-04-13T17:52:03Z"); // "04/13/08" * * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @param {Number|String} The number representing the number of seconds that have elapsed since January 1, 1970 (local time). * @return {String} A string representation of the current Date object. */ $D.strftime = function (format, time) { var d = Date.parse(time); return d._format(format); }; /** * Parse any textual datetime description into a Unix timestamp. * A Unix timestamp is the number of seconds that have elapsed since January 1, 1970 (midnight UTC/GMT). * * Example: * Date.strtotime("04/13/08"); // 1208044800 * Date.strtotime("1970-01-01T00:00:00Z"); // 0 * * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @param {Object} A string or date object. * @return {String} A string representation of the current Date object. */ $D.strtotime = function (time) { var d = $D.parse(time); return Math.round($D.UTC(d.getUTCFullYear(), d.getUTCMonth(), d.getUTCDate(), d.getUTCHours(), d.getUTCMinutes(), d.getUTCSeconds(), d.getUTCMilliseconds()) / 1000); }; /** * Converts the value of the current Date object to its equivalent string representation using a PHP/Unix style of date format specifiers. * Format Specifiers * Format Description Example * ------ --------------------------------------------------------------------------- ----------------------- * %a abbreviated weekday name according to the current localed "Mon" through "Sun" * %A full weekday name according to the current localed "Sunday" through "Saturday" * %b abbreviated month name according to the current localed "Jan" through "Dec" * %B full month name according to the current locale "January" through "December" * %c preferred date and time representation for the current locale "4/13/2008 12:33 PM" * %C century number (the year divided by 100 and truncated to an integer) "00" to "99" * %d day of the month as a decimal number "01" to "31" * %D same as %m/%d/%y "04/13/08" * %e day of the month as a decimal number, a single digit is preceded by a space "1" to "31" * %g like %G, but without the century "08" * %G The 4-digit year corresponding to the ISO week number (see %V). "2008" * This has the same format and value as %Y, except that if the ISO week number * belongs to the previous or next year, that year is used instead. * %h same as %b "Jan" through "Dec" * %H hour as a decimal number using a 24-hour clock. "00" to "23" * %I hour as a decimal number using a 12-hour clock. "01" to "12" * %j day of the year as a decimal number. "001" to "366" * %m month as a decimal number. "01" to "12" * %M minute as a decimal number. "00" to "59" * %n newline character "\n" * %p either "am" or "pm" according to the given time value, or the "am" or "pm" * corresponding strings for the current locale. * %r time in a.m. and p.m. notation "8:44 PM" * %R time in 24 hour notation "20:44" * %S second as a decimal number "00" to "59" * %t tab character "\t" * %T current time, equal to %H:%M:%S "12:49:11" * %u weekday as a decimal number ["1", "7"], with "1" representing Monday "1" to "7" * %U week number of the current year as a decimal number, starting with the "0" to ("52" or "53") * first Sunday as the first day of the first week * %V The ISO 8601:1988 week number of the current year as a decimal number, "00" to ("52" or "53") * range 01 to 53, where week 1 is the first week that has at least 4 days * in the current year, and with Monday as the first day of the week. * (Use %G or %g for the year component that corresponds to the week number * for the specified timestamp.) * %W week number of the current year as a decimal number, starting with the "00" to ("52" or "53") * first Monday as the first day of the first week * %w day of the week as a decimal, Sunday being "0" "0" to "6" * %x preferred date representation for the current locale without the time "4/13/2008" * %X preferred time representation for the current locale without the date "12:53:05" * %y year as a decimal number without a century "00" "99" * %Y year as a decimal number including the century "2008" * %Z time zone or name or abbreviation "UTC", "EST", "PST" * %z same as %Z * %% a literal "%" characters "%" * d Day of the month, 2 digits with leading zeros "01" to "31" * D A textual representation of a day, three letters "Mon" through "Sun" * j Day of the month without leading zeros "1" to "31" * l A full textual representation of the day of the week (lowercase "L") "Sunday" through "Saturday" * N ISO-8601 numeric representation of the day of the week (added in PHP 5.1.0) "1" (for Monday) through "7" (for Sunday) * S English ordinal suffix for the day of the month, 2 characters "st", "nd", "rd" or "th". Works well with j * w Numeric representation of the day of the week "0" (for Sunday) through "6" (for Saturday) * z The day of the year (starting from "0") "0" through "365" * W ISO-8601 week number of year, weeks starting on Monday "00" to ("52" or "53") * F A full textual representation of a month, such as January or March "January" through "December" * m Numeric representation of a month, with leading zeros "01" through "12" * M A short textual representation of a month, three letters "Jan" through "Dec" * n Numeric representation of a month, without leading zeros "1" through "12" * t Number of days in the given month "28" through "31" * L Whether it's a leap year "1" if it is a leap year, "0" otherwise * o ISO-8601 year number. This has the same value as Y, except that if the "2008" * ISO week number (W) belongs to the previous or next year, that year * is used instead. * Y A full numeric representation of a year, 4 digits "2008" * y A two digit representation of a year "08" * a Lowercase Ante meridiem and Post meridiem "am" or "pm" * A Uppercase Ante meridiem and Post meridiem "AM" or "PM" * B Swatch Internet time "000" through "999" * g 12-hour format of an hour without leading zeros "1" through "12" * G 24-hour format of an hour without leading zeros "0" through "23" * h 12-hour format of an hour with leading zeros "01" through "12" * H 24-hour format of an hour with leading zeros "00" through "23" * i Minutes with leading zeros "00" to "59" * s Seconds, with leading zeros "00" through "59" * u Milliseconds "54321" * e Timezone identifier "UTC", "EST", "PST" * I Whether or not the date is in daylight saving time (uppercase i) "1" if Daylight Saving Time, "0" otherwise * O Difference to Greenwich time (GMT) in hours "+0200", "-0600" * P Difference to Greenwich time (GMT) with colon between hours and minutes "+02:00", "-06:00" * T Timezone abbreviation "UTC", "EST", "PST" * Z Timezone offset in seconds. The offset for timezones west of UTC is "-43200" through "50400" * always negative, and for those east of UTC is always positive. * c ISO 8601 date "2004-02-12T15:19:21+00:00" * r RFC 2822 formatted date "Thu, 21 Dec 2000 16:01:07 +0200" * U Seconds since the Unix Epoch (January 1 1970 00:00:00 GMT) "0" * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @return {String} A string representation of the current Date object. */ var formatReplace = function (context) { return function (m) { var formatString, override = false; if (m.charAt(0) === "\\" || m.substring(0, 2) === "%%") { return m.replace("\\", "").replace("%%", "%"); } override = normalizer.shouldOverrideDefaults(m); formatString = $D.normalizeFormat(m, context); if (formatString) { return context.toString(formatString, override); } }; }; $P._format = function (format) { var formatter = formatReplace(this); if (!format) { return this._toString(); } else { return format.replace(/(%|\\)?.|%%/g, formatter); } }; if (!$P.format) { $P.format = $P._format; } }()); (function () { "use strict"; var gFn = function (attr) { return function () { return this[attr]; }; }; var sFn = function (attr) { return function (val) { this[attr] = val; return this; }; }; var attrs = ["years", "months", "days", "hours", "minutes", "seconds", "milliseconds"]; var addSetFuncs = function (context, attrs) { for (var i = 0; i < attrs.length ; i++) { var $a = attrs[i], $b = $a.slice(0, 1).toUpperCase() + $a.slice(1); context.prototype[$a] = 0; context.prototype["get" + $b] = gFn($a); context.prototype["set" + $b] = sFn($a); } }; /** * new TimeSpan(milliseconds); * new TimeSpan(days, hours, minutes, seconds); * new TimeSpan(days, hours, minutes, seconds, milliseconds); */ var TimeSpan = function (days, hours, minutes, seconds, milliseconds) { if (arguments.length === 1 && typeof days === "number") { var orient = (days < 0) ? -1 : +1; var millsLeft = Math.abs(days); this.setDays(Math.floor(millsLeft / 86400000) * orient); millsLeft = millsLeft % 86400000; this.setHours(Math.floor(millsLeft / 3600000) * orient); millsLeft = millsLeft % 3600000; this.setMinutes(Math.floor(millsLeft / 60000) * orient); millsLeft = millsLeft % 60000; this.setSeconds(Math.floor(millsLeft / 1000) * orient); millsLeft = millsLeft % 1000; this.setMilliseconds(millsLeft * orient); } else { this.set(days, hours, minutes, seconds, milliseconds); } this.getTotalMilliseconds = function () { return (this.getDays() * 86400000) + (this.getHours() * 3600000) + (this.getMinutes() * 60000) + (this.getSeconds() * 1000); }; this.compareTo = function (time) { var t1 = new Date(1970, 1, 1, this.getHours(), this.getMinutes(), this.getSeconds()), t2; if (time === null) { t2 = new Date(1970, 1, 1, 0, 0, 0); } else { t2 = new Date(1970, 1, 1, time.getHours(), time.getMinutes(), time.getSeconds()); } return (t1 < t2) ? -1 : (t1 > t2) ? 1 : 0; }; this.equals = function (time) { return (this.compareTo(time) === 0); }; this.add = function (time) { return (time === null) ? this : this.addSeconds(time.getTotalMilliseconds() / 1000); }; this.subtract = function (time) { return (time === null) ? this : this.addSeconds(-time.getTotalMilliseconds() / 1000); }; this.addDays = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 86400000)); }; this.addHours = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 3600000)); }; this.addMinutes = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 60000)); }; this.addSeconds = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 1000)); }; this.addMilliseconds = function (n) { return new TimeSpan(this.getTotalMilliseconds() + n); }; this.get12HourHour = function () { return (this.getHours() > 12) ? this.getHours() - 12 : (this.getHours() === 0) ? 12 : this.getHours(); }; this.getDesignator = function () { return (this.getHours() < 12) ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator; }; this.toString = function (format) { this._toString = function () { if (this.getDays() !== null && this.getDays() > 0) { return this.getDays() + "." + this.getHours() + ":" + this.p(this.getMinutes()) + ":" + this.p(this.getSeconds()); } else { return this.getHours() + ":" + this.p(this.getMinutes()) + ":" + this.p(this.getSeconds()); } }; this.p = function (s) { return (s.toString().length < 2) ? "0" + s : s; }; var me = this; return format ? format.replace(/dd?|HH?|hh?|mm?|ss?|tt?/g, function (format) { switch (format) { case "d": return me.getDays(); case "dd": return me.p(me.getDays()); case "H": return me.getHours(); case "HH": return me.p(me.getHours()); case "h": return me.get12HourHour(); case "hh": return me.p(me.get12HourHour()); case "m": return me.getMinutes(); case "mm": return me.p(me.getMinutes()); case "s": return me.getSeconds(); case "ss": return me.p(me.getSeconds()); case "t": return ((me.getHours() < 12) ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator).substring(0, 1); case "tt": return (me.getHours() < 12) ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator; } } ) : this._toString(); }; return this; }; addSetFuncs(TimeSpan, attrs.slice(2)); TimeSpan.prototype.set = function (days, hours, minutes, seconds, milliseconds){ this.setDays(days || this.getDays()); this.setHours(hours || this.getHours()); this.setMinutes(minutes || this.getMinutes()); this.setSeconds(seconds || this.getSeconds()); this.setMilliseconds(milliseconds || this.getMilliseconds()); }; /** * Gets the time of day for this date instances. * @return {TimeSpan} TimeSpan */ Date.prototype.getTimeOfDay = function () { return new TimeSpan(0, this.getHours(), this.getMinutes(), this.getSeconds(), this.getMilliseconds()); }; Date.TimeSpan = TimeSpan; if (typeof window !== "undefined" ) { // keeping API compatible for v1.x window.TimeSpan = TimeSpan; } }()); (function () { "use strict"; var attrs = ["years", "months", "days", "hours", "minutes", "seconds", "milliseconds"]; var gFn = function (attr) { return function () { return this[attr]; }; }; var sFn = function (attr) { return function (val) { this[attr] = val; return this; }; }; var addSetFuncs = function (context, attrs) { for (var i = 0; i < attrs.length ; i++) { var $a = attrs[i], $b = $a.slice(0, 1).toUpperCase() + $a.slice(1); context.prototype[$a] = 0; context.prototype["get" + $b] = gFn($a); context.prototype["set" + $b] = sFn($a); } }; var setMonthsAndYears = function (orient, d1, d2, context) { function inc() { d1.addMonths(-orient); context.months++; if (context.months === 12) { context.years++; context.months = 0; } } if (orient === +1) { while (d1 > d2) { inc(); } } else { while (d1 < d2) { inc(); } } context.months--; context.months *= orient; context.years *= orient; }; var adjustForDST = function(orient, startDate, endDate) { var hasDSTMismatch = (false === (startDate.isDaylightSavingTime() === endDate.isDaylightSavingTime())); if (hasDSTMismatch && orient === 1) { startDate.addHours(-1); } else if (hasDSTMismatch) { startDate.addHours(1); } }; /** * TimePeriod(startDate, endDate); * TimePeriod(years, months, days, hours, minutes, seconds, milliseconds); */ var TimePeriod = function (years, months, days, hours, minutes, seconds, milliseconds) { if (arguments.length === 7) { this.set(years, months, days, hours, minutes, seconds, milliseconds); } else if (arguments.length === 2 && arguments[0] instanceof Date && arguments[1] instanceof Date) { var startDate = arguments[0].clone(); var endDate = arguments[1].clone(); var orient = (startDate > endDate) ? +1 : -1; this.dates = { start: arguments[0].clone(), end: arguments[1].clone() }; setMonthsAndYears(orient, startDate, endDate, this); adjustForDST(orient, startDate, endDate); // // TODO - adjust for DST var diff = endDate - startDate; if (diff !== 0) { var ts = new TimeSpan(diff); this.set(this.years, this.months, ts.getDays(), ts.getHours(), ts.getMinutes(), ts.getSeconds(), ts.getMilliseconds()); } } return this; }; // create all the set functions. addSetFuncs(TimePeriod, attrs); TimePeriod.prototype.set = function (years, months, days, hours, minutes, seconds, milliseconds){ this.setYears(years || this.getYears()); this.setMonths(months || this.getMonths()); this.setDays(days || this.getDays()); this.setHours(hours || this.getHours()); this.setMinutes(minutes || this.getMinutes()); this.setSeconds(seconds || this.getSeconds()); this.setMilliseconds(milliseconds || this.getMilliseconds()); }; Date.TimePeriod = TimePeriod; if (typeof window !== "undefined") { // keeping API compatible for v1.x window.TimePeriod = TimePeriod; } }()); ================================================ FILE: build/date-ar-QA.js ================================================ /** * @overview datejs * @version 1.0.0-rc3 * @author Gregory Wild-Smith * @copyright 2015 Gregory Wild-Smith * @license MIT * @homepage https://github.com/abritinthebay/datejs */ /* * DateJS Culture String File * Country Code: ar-QA * Name: Arabic (Qatar) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["ar-QA"] = { "name": "ar-QA", "englishName": "Arabic (Qatar)", "nativeName": "العربية (قطر)", "Sunday": "الاحد", "Monday": "الاثنين", "Tuesday": "الثلاثاء", "Wednesday": "الاربعاء", "Thursday": "الخميس", "Friday": "الجمعة", "Saturday": "السبت", "Sun": "الاحد", "Mon": "الاثنين", "Tue": "الثلاثاء", "Wed": "الاربعاء", "Thu": "الخميس", "Fri": "الجمعة", "Sat": "السبت", "Su": "أ", "Mo": "ا", "Tu": "ث", "We": "أ", "Th": "خ", "Fr": "ج", "Sa": "س", "S_Sun_Initial": "أ", "M_Mon_Initial": "ا", "T_Tue_Initial": "ث", "W_Wed_Initial": "أ", "T_Thu_Initial": "خ", "F_Fri_Initial": "ج", "S_Sat_Initial": "س", "January": "يناير", "February": "فبراير", "March": "مارس", "April": "ابريل", "May": "مايو", "June": "يونيو", "July": "يوليو", "August": "اغسطس", "September": "سبتمبر", "October": "اكتوبر", "November": "نوفمبر", "December": "ديسمبر", "Jan_Abbr": "يناير", "Feb_Abbr": "فبراير", "Mar_Abbr": "مارس", "Apr_Abbr": "ابريل", "May_Abbr": "مايو", "Jun_Abbr": "يونيو", "Jul_Abbr": "يوليو", "Aug_Abbr": "اغسطس", "Sep_Abbr": "سبتمبر", "Oct_Abbr": "اكتوبر", "Nov_Abbr": "نوفمبر", "Dec_Abbr": "ديسمبر", "AM": "ص", "PM": "م", "firstDayOfWeek": 6, "twoDigitYearMax": 2029, "mdy": "dmy", "M/d/yyyy": "dd/MM/yyyy", "dddd, MMMM dd, yyyy": "dd MMMM, yyyy", "h:mm tt": "hh:mm tt", "h:mm:ss tt": "hh:mm:ss tt", "dddd, MMMM dd, yyyy h:mm:ss tt": "dd MMMM, yyyy hh:mm:ss tt", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "dd MMMM", "MMMM, yyyy": "MMMM, yyyy", "/jan(uary)?/": "يناير", "/feb(ruary)?/": "فبراير", "/mar(ch)?/": "مارس", "/apr(il)?/": "ابريل", "/may/": "مايو", "/jun(e)?/": "يونيو", "/jul(y)?/": "يوليو", "/aug(ust)?/": "اغسطس", "/sep(t(ember)?)?/": "سبتمبر", "/oct(ober)?/": "اكتوبر", "/nov(ember)?/": "نوفمبر", "/dec(ember)?/": "ديسمبر", "/^su(n(day)?)?/": "^الاحد", "/^mo(n(day)?)?/": "^ا(1)?", "/^tu(e(s(day)?)?)?/": "^الثلاثاء", "/^we(d(nesday)?)?/": "^الاربعاء", "/^th(u(r(s(day)?)?)?)?/": "^الخميس", "/^fr(i(day)?)?/": "^الجمعة", "/^sa(t(urday)?)?/": "^السبت", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "ar-QA"; /** * @overview datejs * @version 1.0.0-rc3 * @author Gregory Wild-Smith * @copyright 2015 Gregory Wild-Smith * @license MIT * @homepage https://github.com/abritinthebay/datejs */(function () { var $D = Date; var lang = Date.CultureStrings ? Date.CultureStrings.lang : null; var loggedKeys = {}; // for debug purposes. var getText = { getFromKey: function (key, countryCode) { var output; if (Date.CultureStrings && Date.CultureStrings[countryCode] && Date.CultureStrings[countryCode][key]) { output = Date.CultureStrings[countryCode][key]; } else { output = getText.buildFromDefault(key); } if (key.charAt(0) === "/") { // Assume it's a regex output = getText.buildFromRegex(key, countryCode); } return output; }, getFromObjectValues: function (obj, countryCode) { var key, output = {}; for(key in obj) { if (obj.hasOwnProperty(key)) { output[key] = getText.getFromKey(obj[key], countryCode); } } return output; }, getFromObjectKeys: function (obj, countryCode) { var key, output = {}; for(key in obj) { if (obj.hasOwnProperty(key)) { output[getText.getFromKey(key, countryCode)] = obj[key]; } } return output; }, getFromArray: function (arr, countryCode) { var output = []; for (var i=0; i < arr.length; i++){ if (i in arr) { output[i] = getText.getFromKey(arr[i], countryCode); } } return output; }, buildFromDefault: function (key) { var output, length, split, last; switch(key) { case "name": output = "en-US"; break; case "englishName": output = "English (United States)"; break; case "nativeName": output = "English (United States)"; break; case "twoDigitYearMax": output = 2049; break; case "firstDayOfWeek": output = 0; break; default: output = key; split = key.split("_"); length = split.length; if (length > 1 && key.charAt(0) !== "/") { // if the key isn't a regex and it has a split. last = split[(length - 1)].toLowerCase(); if (last === "initial" || last === "abbr") { output = split[0]; } } break; } return output; }, buildFromRegex: function (key, countryCode) { var output; if (Date.CultureStrings && Date.CultureStrings[countryCode] && Date.CultureStrings[countryCode][key]) { output = new RegExp(Date.CultureStrings[countryCode][key], "i"); } else { output = new RegExp(key.replace(new RegExp("/", "g"),""), "i"); } return output; } }; var shallowMerge = function (obj1, obj2) { for (var attrname in obj2) { if (obj2.hasOwnProperty(attrname)) { obj1[attrname] = obj2[attrname]; } } }; var __ = function (key, language) { var countryCode = (language) ? language : lang; loggedKeys[key] = key; if (typeof key === "object") { if (key instanceof Array) { return getText.getFromArray(key, countryCode); } else { return getText.getFromObjectKeys(key, countryCode); } } else { return getText.getFromKey(key, countryCode); } }; var loadI18nScript = function (code) { // paatterned after jQuery's getScript. var url = Date.Config.i18n + code + ".js"; var head = document.getElementsByTagName("head")[0] || document.documentElement; var script = document.createElement("script"); script.src = url; var completed = false; var events = { done: function (){} // placeholder function }; // Attach handlers for all browsers script.onload = script.onreadystatechange = function() { if ( !completed && (!this.readyState || this.readyState === "loaded" || this.readyState === "complete") ) { events.done(); head.removeChild(script); } }; setTimeout(function() { head.insertBefore(script, head.firstChild); }, 0); // allows return to execute first return { done: function (cb) { events.done = function() { if (cb) { setTimeout(cb,0); } }; } }; }; var buildInfo = { buildFromMethodHash: function (obj) { var key; for(key in obj) { if (obj.hasOwnProperty(key)) { obj[key] = buildInfo[obj[key]](); } } return obj; }, timeZoneDST: function () { var DST = { "CHADT": "+1345", "NZDT": "+1300", "AEDT": "+1100", "ACDT": "+1030", "AZST": "+0500", "IRDT": "+0430", "EEST": "+0300", "CEST": "+0200", "BST": "+0100", "PMDT": "-0200", "ADT": "-0300", "NDT": "-0230", "EDT": "-0400", "CDT": "-0500", "MDT": "-0600", "PDT": "-0700", "AKDT": "-0800", "HADT": "-0900" }; return __(DST); }, timeZoneStandard: function () { var standard = { "LINT": "+1400", "TOT": "+1300", "CHAST": "+1245", "NZST": "+1200", "NFT": "+1130", "SBT": "+1100", "AEST": "+1000", "ACST": "+0930", "JST": "+0900", "CWST": "+0845", "CT": "+0800", "ICT": "+0700", "MMT": "+0630", "BST": "+0600", "NPT": "+0545", "IST": "+0530", "PKT": "+0500", "AFT": "+0430", "MSK": "+0400", "IRST": "+0330", "FET": "+0300", "EET": "+0200", "CET": "+0100", "GMT": "+0000", "UTC": "+0000", "CVT": "-0100", "GST": "-0200", "BRT": "-0300", "NST": "-0330", "AST": "-0400", "EST": "-0500", "CST": "-0600", "MST": "-0700", "PST": "-0800", "AKST": "-0900", "MIT": "-0930", "HST": "-1000", "SST": "-1100", "BIT": "-1200" }; return __(standard); }, timeZones: function (data) { var zone; data.timezones = []; for (zone in data.abbreviatedTimeZoneStandard) { if (data.abbreviatedTimeZoneStandard.hasOwnProperty(zone)) { data.timezones.push({ name: zone, offset: data.abbreviatedTimeZoneStandard[zone]}); } } for (zone in data.abbreviatedTimeZoneDST) { if (data.abbreviatedTimeZoneDST.hasOwnProperty(zone)) { data.timezones.push({ name: zone, offset: data.abbreviatedTimeZoneDST[zone], dst: true}); } } return data.timezones; }, days: function () { return __(["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"]); }, dayAbbr: function () { return __(["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"]); }, dayShortNames: function () { return __(["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"]); }, dayFirstLetters: function () { return __(["S_Sun_Initial", "M_Mon_Initial", "T_Tues_Initial", "W_Wed_Initial", "T_Thu_Initial", "F_Fri_Initial", "S_Sat_Initial"]); }, months: function () { return __(["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"]); }, monthAbbr: function () { return __(["Jan_Abbr", "Feb_Abbr", "Mar_Abbr", "Apr_Abbr", "May_Abbr", "Jun_Abbr", "Jul_Abbr", "Aug_Abbr", "Sep_Abbr", "Oct_Abbr", "Nov_Abbr", "Dec_Abbr"]); }, formatPatterns: function () { return getText.getFromObjectValues({ shortDate: "M/d/yyyy", longDate: "dddd, MMMM dd, yyyy", shortTime: "h:mm tt", longTime: "h:mm:ss tt", fullDateTime: "dddd, MMMM dd, yyyy h:mm:ss tt", sortableDateTime: "yyyy-MM-ddTHH:mm:ss", universalSortableDateTime: "yyyy-MM-dd HH:mm:ssZ", rfc1123: "ddd, dd MMM yyyy HH:mm:ss", monthDay: "MMMM dd", yearMonth: "MMMM, yyyy" }, Date.i18n.currentLanguage()); }, regex: function () { return getText.getFromObjectValues({ inTheMorning: "/( in the )(morn(ing)?)\\b/", thisMorning: "/(this )(morn(ing)?)\\b/", amThisMorning: "/(\b\\d(am)? )(this )(morn(ing)?)/", inTheEvening: "/( in the )(even(ing)?)\\b/", thisEvening: "/(this )(even(ing)?)\\b/", pmThisEvening: "/(\b\\d(pm)? )(this )(even(ing)?)/", jan: "/jan(uary)?/", feb: "/feb(ruary)?/", mar: "/mar(ch)?/", apr: "/apr(il)?/", may: "/may/", jun: "/jun(e)?/", jul: "/jul(y)?/", aug: "/aug(ust)?/", sep: "/sep(t(ember)?)?/", oct: "/oct(ober)?/", nov: "/nov(ember)?/", dec: "/dec(ember)?/", sun: "/^su(n(day)?)?/", mon: "/^mo(n(day)?)?/", tue: "/^tu(e(s(day)?)?)?/", wed: "/^we(d(nesday)?)?/", thu: "/^th(u(r(s(day)?)?)?)?/", fri: "/fr(i(day)?)?/", sat: "/^sa(t(urday)?)?/", future: "/^next/", past: "/^last|past|prev(ious)?/", add: "/^(\\+|aft(er)?|from|hence)/", subtract: "/^(\\-|bef(ore)?|ago)/", yesterday: "/^yes(terday)?/", today: "/^t(od(ay)?)?/", tomorrow: "/^tom(orrow)?/", now: "/^n(ow)?/", millisecond: "/^ms|milli(second)?s?/", second: "/^sec(ond)?s?/", minute: "/^mn|min(ute)?s?/", hour: "/^h(our)?s?/", week: "/^w(eek)?s?/", month: "/^m(onth)?s?/", day: "/^d(ay)?s?/", year: "/^y(ear)?s?/", shortMeridian: "/^(a|p)/", longMeridian: "/^(a\\.?m?\\.?|p\\.?m?\\.?)/", timezone: "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/", ordinalSuffix: "/^\\s*(st|nd|rd|th)/", timeContext: "/^\\s*(\\:|a(?!u|p)|p)/" }, Date.i18n.currentLanguage()); } }; var CultureInfo = function () { var info = getText.getFromObjectValues({ name: "name", englishName: "englishName", nativeName: "nativeName", amDesignator: "AM", pmDesignator: "PM", firstDayOfWeek: "firstDayOfWeek", twoDigitYearMax: "twoDigitYearMax", dateElementOrder: "mdy" }, Date.i18n.currentLanguage()); var constructedInfo = buildInfo.buildFromMethodHash({ dayNames: "days", abbreviatedDayNames: "dayAbbr", shortestDayNames: "dayShortNames", firstLetterDayNames: "dayFirstLetters", monthNames: "months", abbreviatedMonthNames: "monthAbbr", formatPatterns: "formatPatterns", regexPatterns: "regex", abbreviatedTimeZoneDST: "timeZoneDST", abbreviatedTimeZoneStandard: "timeZoneStandard" }); shallowMerge(info, constructedInfo); buildInfo.timeZones(info); return info; }; $D.i18n = { __: function (key, lang) { return __(key, lang); }, currentLanguage: function () { return lang || "en-US"; }, setLanguage: function (code, force, cb) { var async = false; if (force || code === "en-US" || (!!Date.CultureStrings && !!Date.CultureStrings[code])) { lang = code; Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings.lang = code; Date.CultureInfo = new CultureInfo(); } else { if (!(!!Date.CultureStrings && !!Date.CultureStrings[code])) { if (typeof exports !== "undefined" && this.exports !== exports) { // we're in a Node enviroment, load it using require try { require("../i18n/" + code + ".js"); lang = code; Date.CultureStrings.lang = code; Date.CultureInfo = new CultureInfo(); } catch (e) { // var str = "The language for '" + code + "' could not be loaded by Node. It likely does not exist."; throw new Error("The DateJS IETF language tag '" + code + "' could not be loaded by Node. It likely does not exist."); } } else if (Date.Config && Date.Config.i18n) { // we know the location of the files, so lets load them async = true; loadI18nScript(code).done(function(){ lang = code; Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings.lang = code; Date.CultureInfo = new CultureInfo(); $D.Parsing.Normalizer.buildReplaceData(); // because this is async if ($D.Grammar) { $D.Grammar.buildGrammarFormats(); // so we can parse those strings... } if (cb) { setTimeout(cb,0); } }); } else { Date.console.error("The DateJS IETF language tag '" + code + "' is not available and has not been loaded."); return false; } } } $D.Parsing.Normalizer.buildReplaceData(); // rebuild normalizer strings if ($D.Grammar) { $D.Grammar.buildGrammarFormats(); // so we can parse those strings... } if (!async && cb) { setTimeout(cb,0); } }, getLoggedKeys: function () { return loggedKeys; }, updateCultureInfo: function () { Date.CultureInfo = new CultureInfo(); } }; $D.i18n.updateCultureInfo(); // run automatically }()); (function () { var $D = Date, $P = $D.prototype, p = function (s, l) { if (!l) { l = 2; } return ("000" + s).slice(l * -1); }; if (typeof window !== "undefined" && typeof window.console !== "undefined" && typeof window.console.log !== "undefined") { $D.console = console; // used only to raise non-critical errors if available } else { // set mock so we don't give errors. $D.console = { log: function(){}, error: function(){} }; } $D.Config = $D.Config || {}; $D.initOverloads = function() { /** * Overload of Date.now. Allows an alternate call for Date.now where it returns the * current Date as an object rather than just milliseconds since the Unix Epoch. * * Also provides an implementation of now() for browsers (IE<9) that don't have it. * * Backwards compatible so with work with either: * Date.now() [returns ms] * or * Date.now(true) [returns Date] */ if (!$D.now) { $D._now = function now() { return new Date().getTime(); }; } else if (!$D._now) { $D._now = $D.now; } $D.now = function (returnObj) { if (returnObj) { return $D.present(); } else { return $D._now(); } }; if ( !$P.toISOString ) { $P.toISOString = function() { return this.getUTCFullYear() + "-" + p(this.getUTCMonth() + 1) + "-" + p(this.getUTCDate()) + "T" + p(this.getUTCHours()) + ":" + p(this.getUTCMinutes()) + ":" + p(this.getUTCSeconds()) + "." + String( (this.getUTCMilliseconds()/1000).toFixed(3)).slice(2, 5) + "Z"; }; } // private if ( $P._toString === undefined ){ $P._toString = $P.toString; } }; $D.initOverloads(); /** * Gets a date that is set to the current date. The time is set to the start of the day (00:00 or 12:00 AM). * @return {Date} The current date. */ $D.today = function () { return new Date().clearTime(); }; /** * Gets a date that is set to the current date and time (same as new Date, but chainable) * @return {Date} The current date. */ $D.present = function () { return new Date(); }; /** * Compares the first date to the second date and returns an number indication of their relative values. * @param {Date} First Date object to compare [Required]. * @param {Date} Second Date object to compare to [Required]. * @return {Number} -1 = date1 is lessthan date2. 0 = values are equal. 1 = date1 is greaterthan date2. */ $D.compare = function (date1, date2) { if (isNaN(date1) || isNaN(date2)) { throw new Error(date1 + " - " + date2); } else if (date1 instanceof Date && date2 instanceof Date) { return (date1 < date2) ? -1 : (date1 > date2) ? 1 : 0; } else { throw new TypeError(date1 + " - " + date2); } }; /** * Compares the first Date object to the second Date object and returns true if they are equal. * @param {Date} First Date object to compare [Required] * @param {Date} Second Date object to compare to [Required] * @return {Boolean} true if dates are equal. false if they are not equal. */ $D.equals = function (date1, date2) { return (date1.compareTo(date2) === 0); }; /** * Gets the language appropriate day name when given the day number(0-6) * eg - 0 == Sunday * @return {String} The day name */ $D.getDayName = function (n) { return Date.CultureInfo.dayNames[n]; }; /** * Gets the day number (0-6) if given a CultureInfo specific string which is a valid dayName, abbreviatedDayName or shortestDayName (two char). * @param {String} The name of the day (eg. "Monday, "Mon", "tuesday", "tue", "We", "we"). * @return {Number} The day number */ $D.getDayNumberFromName = function (name) { var n = Date.CultureInfo.dayNames, m = Date.CultureInfo.abbreviatedDayNames, o = Date.CultureInfo.shortestDayNames, s = name.toLowerCase(); for (var i = 0; i < n.length; i++) { if (n[i].toLowerCase() === s || m[i].toLowerCase() === s || o[i].toLowerCase() === s) { return i; } } return -1; }; /** * Gets the month number (0-11) if given a Culture Info specific string which is a valid monthName or abbreviatedMonthName. * @param {String} The name of the month (eg. "February, "Feb", "october", "oct"). * @return {Number} The day number */ $D.getMonthNumberFromName = function (name) { var n = Date.CultureInfo.monthNames, m = Date.CultureInfo.abbreviatedMonthNames, s = name.toLowerCase(); for (var i = 0; i < n.length; i++) { if (n[i].toLowerCase() === s || m[i].toLowerCase() === s) { return i; } } return -1; }; /** * Gets the language appropriate month name when given the month number(0-11) * eg - 0 == January * @return {String} The month name */ $D.getMonthName = function (n) { return Date.CultureInfo.monthNames[n]; }; /** * Determines if the current date instance is within a LeapYear. * @param {Number} The year. * @return {Boolean} true if date is within a LeapYear, otherwise false. */ $D.isLeapYear = function (year) { return ((year % 4 === 0 && year % 100 !== 0) || year % 400 === 0); }; /** * Gets the number of days in the month, given a year and month value. Automatically corrects for LeapYear. * @param {Number} The year. * @param {Number} The month (0-11). * @return {Number} The number of days in the month. */ $D.getDaysInMonth = function (year, month) { if (!month && $D.validateMonth(year)) { month = year; year = Date.today().getFullYear(); } return [31, ($D.isLeapYear(year) ? 29 : 28), 31, 30, 31, 30, 31, 31, 30, 31, 30, 31][month]; }; $P.getDaysInMonth = function () { return $D.getDaysInMonth(this.getFullYear(), this.getMonth()); }; $D.getTimezoneAbbreviation = function (offset, dst) { var p, n = (dst || false) ? Date.CultureInfo.abbreviatedTimeZoneDST : Date.CultureInfo.abbreviatedTimeZoneStandard; for (p in n) { if (n.hasOwnProperty(p)) { if (n[p] === offset) { return p; } } } return null; }; $D.getTimezoneOffset = function (name, dst) { var i, a =[], z = Date.CultureInfo.timezones; if (!name) { name = (new Date()).getTimezone();} for (i = 0; i < z.length; i++) { if (z[i].name === name.toUpperCase()) { a.push(i); } } if (!z[a[0]]) { return null; } if (a.length === 1 || !dst) { return z[a[0]].offset; } else { for (i=0; i < a.length; i++) { if (z[a[i]].dst) { return z[a[i]].offset; } } } }; $D.getQuarter = function (d) { d = d || new Date(); // If no date supplied, use today var q = [1,2,3,4]; return q[Math.floor(d.getMonth() / 3)]; // ~~~ is a bitwise op. Faster than Math.floor }; $D.getDaysLeftInQuarter = function (d) { d = d || new Date(); var qEnd = new Date(d); qEnd.setMonth(qEnd.getMonth() + 3 - qEnd.getMonth() % 3, 0); return Math.floor((qEnd - d) / 8.64e7); }; // private var validate = function (n, min, max, name) { name = name ? name : "Object"; if (typeof n === "undefined") { return false; } else if (typeof n !== "number") { throw new TypeError(n + " is not a Number."); } else if (n < min || n > max) { // As failing validation is *not* an exceptional circumstance // lets not throw a RangeError Exception here. // It's semantically correct but it's not sensible. return false; } return true; }; /** * Validates the number is within an acceptable range for milliseconds [0-999]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateMillisecond = function (value) { return validate(value, 0, 999, "millisecond"); }; /** * Validates the number is within an acceptable range for seconds [0-59]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateSecond = function (value) { return validate(value, 0, 59, "second"); }; /** * Validates the number is within an acceptable range for minutes [0-59]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateMinute = function (value) { return validate(value, 0, 59, "minute"); }; /** * Validates the number is within an acceptable range for hours [0-23]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateHour = function (value) { return validate(value, 0, 23, "hour"); }; /** * Validates the number is within an acceptable range for the days in a month [0-MaxDaysInMonth]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateDay = function (value, year, month) { if (year === undefined || year === null || month === undefined || month === null) { return false;} return validate(value, 1, $D.getDaysInMonth(year, month), "day"); }; /** * Validates the number is within an acceptable range for months [0-11]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateWeek = function (value) { return validate(value, 0, 53, "week"); }; /** * Validates the number is within an acceptable range for months [0-11]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateMonth = function (value) { return validate(value, 0, 11, "month"); }; /** * Validates the number is within an acceptable range for years. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateYear = function (value) { /** * Per ECMAScript spec the range of times supported by Date objects is * exactly -100,000,000 days to +100,000,000 days measured relative to * midnight at the beginning of 01 January, 1970 UTC. * This gives a range of 8,640,000,000,000,000 milliseconds to either * side of 01 January, 1970 UTC. * * Earliest possible date: Tue, 20 Apr 271,822 B.C. 00:00:00 UTC * Latest possible date: Sat, 13 Sep 275,760 00:00:00 UTC */ return validate(value, -271822, 275760, "year"); }; $D.validateTimezone = function(value) { var timezones = {"ACDT":1,"ACST":1,"ACT":1,"ADT":1,"AEDT":1,"AEST":1,"AFT":1,"AKDT":1,"AKST":1,"AMST":1,"AMT":1,"ART":1,"AST":1,"AWDT":1,"AWST":1,"AZOST":1,"AZT":1,"BDT":1,"BIOT":1,"BIT":1,"BOT":1,"BRT":1,"BST":1,"BTT":1,"CAT":1,"CCT":1,"CDT":1,"CEDT":1,"CEST":1,"CET":1,"CHADT":1,"CHAST":1,"CHOT":1,"ChST":1,"CHUT":1,"CIST":1,"CIT":1,"CKT":1,"CLST":1,"CLT":1,"COST":1,"COT":1,"CST":1,"CT":1,"CVT":1,"CWST":1,"CXT":1,"DAVT":1,"DDUT":1,"DFT":1,"EASST":1,"EAST":1,"EAT":1,"ECT":1,"EDT":1,"EEDT":1,"EEST":1,"EET":1,"EGST":1,"EGT":1,"EIT":1,"EST":1,"FET":1,"FJT":1,"FKST":1,"FKT":1,"FNT":1,"GALT":1,"GAMT":1,"GET":1,"GFT":1,"GILT":1,"GIT":1,"GMT":1,"GST":1,"GYT":1,"HADT":1,"HAEC":1,"HAST":1,"HKT":1,"HMT":1,"HOVT":1,"HST":1,"ICT":1,"IDT":1,"IOT":1,"IRDT":1,"IRKT":1,"IRST":1,"IST":1,"JST":1,"KGT":1,"KOST":1,"KRAT":1,"KST":1,"LHST":1,"LINT":1,"MAGT":1,"MART":1,"MAWT":1,"MDT":1,"MET":1,"MEST":1,"MHT":1,"MIST":1,"MIT":1,"MMT":1,"MSK":1,"MST":1,"MUT":1,"MVT":1,"MYT":1,"NCT":1,"NDT":1,"NFT":1,"NPT":1,"NST":1,"NT":1,"NUT":1,"NZDT":1,"NZST":1,"OMST":1,"ORAT":1,"PDT":1,"PET":1,"PETT":1,"PGT":1,"PHOT":1,"PHT":1,"PKT":1,"PMDT":1,"PMST":1,"PONT":1,"PST":1,"PYST":1,"PYT":1,"RET":1,"ROTT":1,"SAKT":1,"SAMT":1,"SAST":1,"SBT":1,"SCT":1,"SGT":1,"SLST":1,"SRT":1,"SST":1,"SYOT":1,"TAHT":1,"THA":1,"TFT":1,"TJT":1,"TKT":1,"TLT":1,"TMT":1,"TOT":1,"TVT":1,"UCT":1,"ULAT":1,"UTC":1,"UYST":1,"UYT":1,"UZT":1,"VET":1,"VLAT":1,"VOLT":1,"VOST":1,"VUT":1,"WAKT":1,"WAST":1,"WAT":1,"WEDT":1,"WEST":1,"WET":1,"WST":1,"YAKT":1,"YEKT":1,"Z":1}; return (timezones[value] === 1); }; $D.validateTimezoneOffset= function(value) { // timezones go from +14hrs to -12hrs, the +X hours are negative offsets. return (value > -841 && value < 721); }; }()); (function () { var $D = Date, $P = $D.prototype, p = function (s, l) { if (!l) { l = 2; } return ("000" + s).slice(l * -1); }; var validateConfigObject = function (obj) { var result = {}, self = this, prop, testFunc; testFunc = function (prop, func, value) { if (prop === "day") { var month = (obj.month !== undefined) ? obj.month : self.getMonth(); var year = (obj.year !== undefined) ? obj.year : self.getFullYear(); return $D[func](value, year, month); } else { return $D[func](value); } }; for (prop in obj) { if (Object.prototype.hasOwnProperty.call(obj, prop)) { var func = "validate" + prop.charAt(0).toUpperCase() + prop.slice(1); if ($D[func] && obj[prop] !== null && testFunc(prop, func, obj[prop])) { result[prop] = obj[prop]; } } } return result; }; /** * Resets the time of this Date object to 12:00 AM (00:00), which is the start of the day. * @param {Boolean} .clone() this date instance before clearing Time * @return {Date} this */ $P.clearTime = function () { this.setHours(0); this.setMinutes(0); this.setSeconds(0); this.setMilliseconds(0); return this; }; /** * Resets the time of this Date object to the current time ('now'). * @return {Date} this */ $P.setTimeToNow = function () { var n = new Date(); this.setHours(n.getHours()); this.setMinutes(n.getMinutes()); this.setSeconds(n.getSeconds()); this.setMilliseconds(n.getMilliseconds()); return this; }; /** * Returns a new Date object that is an exact date and time copy of the original instance. * @return {Date} A new Date instance */ $P.clone = function () { return new Date(this.getTime()); }; /** * Compares this instance to a Date object and returns an number indication of their relative values. * @param {Date} Date object to compare [Required] * @return {Number} -1 = this is lessthan date. 0 = values are equal. 1 = this is greaterthan date. */ $P.compareTo = function (date) { return Date.compare(this, date); }; /** * Compares this instance to another Date object and returns true if they are equal. * @param {Date} Date object to compare. If no date to compare, new Date() [now] is used. * @return {Boolean} true if dates are equal. false if they are not equal. */ $P.equals = function (date) { return Date.equals(this, (date !== undefined ? date : new Date())); }; /** * Determines if this instance is between a range of two dates or equal to either the start or end dates. * @param {Date} Start of range [Required] * @param {Date} End of range [Required] * @return {Boolean} true is this is between or equal to the start and end dates, else false */ $P.between = function (start, end) { return this.getTime() >= start.getTime() && this.getTime() <= end.getTime(); }; /** * Determines if this date occurs after the date to compare to. * @param {Date} Date object to compare. If no date to compare, new Date() ("now") is used. * @return {Boolean} true if this date instance is greater than the date to compare to (or "now"), otherwise false. */ $P.isAfter = function (date) { return this.compareTo(date || new Date()) === 1; }; /** * Determines if this date occurs before the date to compare to. * @param {Date} Date object to compare. If no date to compare, new Date() ("now") is used. * @return {Boolean} true if this date instance is less than the date to compare to (or "now"). */ $P.isBefore = function (date) { return (this.compareTo(date || new Date()) === -1); }; /** * Determines if the current Date instance occurs today. * @return {Boolean} true if this date instance is 'today', otherwise false. */ /** * Determines if the current Date instance occurs on the same Date as the supplied 'date'. * If no 'date' to compare to is provided, the current Date instance is compared to 'today'. * @param {date} Date object to compare. If no date to compare, the current Date ("now") is used. * @return {Boolean} true if this Date instance occurs on the same Day as the supplied 'date'. */ $P.isToday = $P.isSameDay = function (date) { return this.clone().clearTime().equals((date || new Date()).clone().clearTime()); }; /** * Adds the specified number of milliseconds to this instance. * @param {Number} The number of milliseconds to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addMilliseconds = function (value) { if (!value) { return this; } this.setTime(this.getTime() + value * 1); return this; }; /** * Adds the specified number of seconds to this instance. * @param {Number} The number of seconds to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addSeconds = function (value) { if (!value) { return this; } return this.addMilliseconds(value * 1000); }; /** * Adds the specified number of seconds to this instance. * @param {Number} The number of seconds to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addMinutes = function (value) { if (!value) { return this; } return this.addMilliseconds(value * 60000); // 60*1000 }; /** * Adds the specified number of hours to this instance. * @param {Number} The number of hours to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addHours = function (value) { if (!value) { return this; } return this.addMilliseconds(value * 3600000); // 60*60*1000 }; /** * Adds the specified number of days to this instance. * @param {Number} The number of days to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addDays = function (value) { if (!value) { return this; } this.setDate(this.getDate() + value * 1); return this; }; /** * Adds the specified number of weekdays (ie - not sat or sun) to this instance. * @param {Number} The number of days to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addWeekdays = function (value) { if (!value) { return this; } var day = this.getDay(); var weeks = (Math.ceil(Math.abs(value)/7)); if (day === 0 || day === 6) { if (value > 0) { this.next().monday(); this.addDays(-1); day = this.getDay(); } } if (value < 0) { while (value < 0) { this.addDays(-1); day = this.getDay(); if (day !== 0 && day !== 6) { value++; } } return this; } else if (value > 5 || (6-day) <= value) { value = value + (weeks * 2); } return this.addDays(value); }; /** * Adds the specified number of weeks to this instance. * @param {Number} The number of weeks to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addWeeks = function (value) { if (!value) { return this; } return this.addDays(value * 7); }; /** * Adds the specified number of months to this instance. * @param {Number} The number of months to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addMonths = function (value) { if (!value) { return this; } var n = this.getDate(); this.setDate(1); this.setMonth(this.getMonth() + value * 1); this.setDate(Math.min(n, $D.getDaysInMonth(this.getFullYear(), this.getMonth()))); return this; }; $P.addQuarters = function (value) { if (!value) { return this; } // note this will take you to the same point in the quarter as you are now. // i.e. - if you are 15 days into the quarter you'll be 15 days into the resulting one. // bonus: this allows adding fractional quarters return this.addMonths(value * 3); }; /** * Adds the specified number of years to this instance. * @param {Number} The number of years to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addYears = function (value) { if (!value) { return this; } return this.addMonths(value * 12); }; /** * Adds (or subtracts) to the value of the years, months, weeks, days, hours, minutes, seconds, milliseconds of the date instance using given configuration object. Positive and Negative values allowed. * Example

	Date.today().add( { days: 1, months: 1 } )

	new Date().add( { years: -1 } )
	
* @param {Object} Configuration object containing attributes (months, days, etc.) * @return {Date} this */ $P.add = function (config) { if (typeof config === "number") { this._orient = config; return this; } var x = config; if (x.day) { // If we should be a different date than today (eg: for 'tomorrow -1d', etc). // Should only effect parsing, not direct usage (eg, Finish and FinishExact) if ((x.day - this.getDate()) !== 0) { this.setDate(x.day); } } if (x.milliseconds) { this.addMilliseconds(x.milliseconds); } if (x.seconds) { this.addSeconds(x.seconds); } if (x.minutes) { this.addMinutes(x.minutes); } if (x.hours) { this.addHours(x.hours); } if (x.weeks) { this.addWeeks(x.weeks); } if (x.months) { this.addMonths(x.months); } if (x.years) { this.addYears(x.years); } if (x.days) { this.addDays(x.days); } return this; }; /** * Get the week number. Week one (1) is the week which contains the first Thursday of the year. Monday is considered the first day of the week. * The .getWeek() function does NOT convert the date to UTC. The local datetime is used. * Please use .getISOWeek() to get the week of the UTC converted date. * @return {Number} 1 to 53 */ $P.getWeek = function (utc) { // Create a copy of this date object var self, target = new Date(this.valueOf()); if (utc) { target.addMinutes(target.getTimezoneOffset()); self = target.clone(); } else { self = this; } // ISO week date weeks start on monday // so correct the day number var dayNr = (self.getDay() + 6) % 7; // ISO 8601 states that week 1 is the week // with the first thursday of that year. // Set the target date to the thursday in the target week target.setDate(target.getDate() - dayNr + 3); // Store the millisecond value of the target date var firstThursday = target.valueOf(); // Set the target to the first thursday of the year // First set the target to january first target.setMonth(0, 1); // Not a thursday? Correct the date to the next thursday if (target.getDay() !== 4) { target.setMonth(0, 1 + ((4 - target.getDay()) + 7) % 7); } // The weeknumber is the number of weeks between the // first thursday of the year and the thursday in the target week return 1 + Math.ceil((firstThursday - target) / 604800000); // 604800000 = 7 * 24 * 3600 * 1000 }; /** * Get the ISO 8601 week number. Week one ("01") is the week which contains the first Thursday of the year. Monday is considered the first day of the week. * The .getISOWeek() function does convert the date to it's UTC value. Please use .getWeek() to get the week of the local date. * @return {String} "01" to "53" */ $P.getISOWeek = function () { return p(this.getWeek(true)); }; /** * Moves the date to Monday of the week set. Week one (1) is the week which contains the first Thursday of the year. * @param {Number} A Number (1 to 53) that represents the week of the year. * @return {Date} this */ $P.setWeek = function (n) { if ((n - this.getWeek()) === 0) { if (this.getDay() !== 1) { return this.moveToDayOfWeek(1, (this.getDay() > 1 ? -1 : 1)); } else { return this; } } else { return this.moveToDayOfWeek(1, (this.getDay() > 1 ? -1 : 1)).addWeeks(n - this.getWeek()); } }; $P.setQuarter = function (qtr) { var month = Math.abs(((qtr-1) * 3) + 1); return this.setMonth(month, 1); }; $P.getQuarter = function () { return Date.getQuarter(this); }; $P.getDaysLeftInQuarter = function () { return Date.getDaysLeftInQuarter(this); }; /** * Moves the date to the next n'th occurrence of the dayOfWeek starting from the beginning of the month. The number (-1) is a magic number and will return the last occurrence of the dayOfWeek in the month. * @param {Number} The dayOfWeek to move to * @param {Number} The n'th occurrence to move to. Use (-1) to return the last occurrence in the month * @return {Date} this */ $P.moveToNthOccurrence = function (dayOfWeek, occurrence) { if (dayOfWeek === "Weekday") { if (occurrence > 0) { this.moveToFirstDayOfMonth(); if (this.is().weekday()) { occurrence -= 1; } } else if (occurrence < 0) { this.moveToLastDayOfMonth(); if (this.is().weekday()) { occurrence += 1; } } else { return this; } return this.addWeekdays(occurrence); } var shift = 0; if (occurrence > 0) { shift = occurrence - 1; } else if (occurrence === -1) { this.moveToLastDayOfMonth(); if (this.getDay() !== dayOfWeek) { this.moveToDayOfWeek(dayOfWeek, -1); } return this; } return this.moveToFirstDayOfMonth().addDays(-1).moveToDayOfWeek(dayOfWeek, +1).addWeeks(shift); }; var moveToN = function (getFunc, addFunc, nVal) { return function (value, orient) { var diff = (value - this[getFunc]() + nVal * (orient || +1)) % nVal; return this[addFunc]((diff === 0) ? diff += nVal * (orient || +1) : diff); }; }; /** * Move to the next or last dayOfWeek based on the orient value. * @param {Number} The dayOfWeek to move to * @param {Number} Forward (+1) or Back (-1). Defaults to +1. [Optional] * @return {Date} this */ $P.moveToDayOfWeek = moveToN("getDay", "addDays", 7); /** * Move to the next or last month based on the orient value. * @param {Number} The month to move to. 0 = January, 11 = December * @param {Number} Forward (+1) or Back (-1). Defaults to +1. [Optional] * @return {Date} this */ $P.moveToMonth = moveToN("getMonth", "addMonths", 12); /** * Get the Ordinate of the current day ("th", "st", "rd"). * @return {String} */ $P.getOrdinate = function () { var num = this.getDate(); return ord(num); }; /** * Get the Ordinal day (numeric day number) of the year, adjusted for leap year. * @return {Number} 1 through 365 (366 in leap years) */ $P.getOrdinalNumber = function () { return Math.ceil((this.clone().clearTime() - new Date(this.getFullYear(), 0, 1)) / 86400000) + 1; }; /** * Get the time zone abbreviation of the current date. * @return {String} The abbreviated time zone name (e.g. "EST") */ $P.getTimezone = function () { return $D.getTimezoneAbbreviation(this.getUTCOffset(), this.isDaylightSavingTime()); }; $P.setTimezoneOffset = function (offset) { var here = this.getTimezoneOffset(), there = Number(offset) * -6 / 10; return (there || there === 0) ? this.addMinutes(there - here) : this; }; $P.setTimezone = function (offset) { return this.setTimezoneOffset($D.getTimezoneOffset(offset)); }; /** * Indicates whether Daylight Saving Time is observed in the current time zone. * @return {Boolean} true|false */ $P.hasDaylightSavingTime = function () { return (Date.today().set({month: 0, day: 1}).getTimezoneOffset() !== Date.today().set({month: 6, day: 1}).getTimezoneOffset()); }; /** * Indicates whether this Date instance is within the Daylight Saving Time range for the current time zone. * @return {Boolean} true|false */ $P.isDaylightSavingTime = function () { return Date.today().set({month: 0, day: 1}).getTimezoneOffset() !== this.getTimezoneOffset(); }; /** * Get the offset from UTC of the current date. * @return {String} The 4-character offset string prefixed with + or - (e.g. "-0500") */ $P.getUTCOffset = function (offset) { var n = (offset || this.getTimezoneOffset()) * -10 / 6, r; if (n < 0) { r = (n - 10000).toString(); return r.charAt(0) + r.substr(2); } else { r = (n + 10000).toString(); return "+" + r.substr(1); } }; /** * Returns the number of milliseconds between this date and date. * @param {Date} Defaults to now * @return {Number} The diff in milliseconds */ $P.getElapsed = function (date) { return (date || new Date()) - this; }; /** * Set the value of year, month, day, hour, minute, second, millisecond of date instance using given configuration object. * Example

	Date.today().set( { day: 20, month: 1 } )

	new Date().set( { millisecond: 0 } )
	
* * @param {Object} Configuration object containing attributes (month, day, etc.) * @return {Date} this */ $P.set = function (config) { config = validateConfigObject.call(this, config); var key; for (key in config) { if (Object.prototype.hasOwnProperty.call(config, key)) { var name = key.charAt(0).toUpperCase() + key.slice(1); var addFunc, getFunc; if (key !== "week" && key !== "month" && key !== "timezone" && key !== "timezoneOffset") { name += "s"; } addFunc = "add" + name; getFunc = "get" + name; if (key === "month") { addFunc = addFunc + "s"; } else if (key === "year"){ getFunc = "getFullYear"; } if (key !== "day" && key !== "timezone" && key !== "timezoneOffset" && key !== "week" && key !== "hour") { this[addFunc](config[key] - this[getFunc]()); } else if ( key === "timezone"|| key === "timezoneOffset" || key === "week" || key === "hour") { this["set"+name](config[key]); } } } // day has to go last because you can't validate the day without first knowing the month if (config.day) { this.addDays(config.day - this.getDate()); } return this; }; /** * Moves the date to the first day of the month. * @return {Date} this */ $P.moveToFirstDayOfMonth = function () { return this.set({ day: 1 }); }; /** * Moves the date to the last day of the month. * @return {Date} this */ $P.moveToLastDayOfMonth = function () { return this.set({ day: $D.getDaysInMonth(this.getFullYear(), this.getMonth())}); }; /** * Converts the value of the current Date object to its equivalent string representation. * Format Specifiers * CUSTOM DATE AND TIME FORMAT STRINGS * Format Description Example * ------ --------------------------------------------------------------------------- ----------------------- * s The seconds of the minute between 0-59. "0" to "59" * ss The seconds of the minute with leading zero if required. "00" to "59" * * m The minute of the hour between 0-59. "0" or "59" * mm The minute of the hour with leading zero if required. "00" or "59" * * h The hour of the day between 1-12. "1" to "12" * hh The hour of the day with leading zero if required. "01" to "12" * * H The hour of the day between 0-23. "0" to "23" * HH The hour of the day with leading zero if required. "00" to "23" * * d The day of the month between 1 and 31. "1" to "31" * dd The day of the month with leading zero if required. "01" to "31" * ddd Abbreviated day name. Date.CultureInfo.abbreviatedDayNames. "Mon" to "Sun" * dddd The full day name. Date.CultureInfo.dayNames. "Monday" to "Sunday" * * M The month of the year between 1-12. "1" to "12" * MM The month of the year with leading zero if required. "01" to "12" * MMM Abbreviated month name. Date.CultureInfo.abbreviatedMonthNames. "Jan" to "Dec" * MMMM The full month name. Date.CultureInfo.monthNames. "January" to "December" * * yy The year as a two-digit number. "99" or "08" * yyyy The full four digit year. "1999" or "2008" * * t Displays the first character of the A.M./P.M. designator. "A" or "P" * Date.CultureInfo.amDesignator or Date.CultureInfo.pmDesignator * tt Displays the A.M./P.M. designator. "AM" or "PM" * Date.CultureInfo.amDesignator or Date.CultureInfo.pmDesignator * * S The ordinal suffix ("st, "nd", "rd" or "th") of the current day. "st, "nd", "rd" or "th" * * STANDARD DATE AND TIME FORMAT STRINGS * Format Description Example *------ --------------------------------------------------------------------------- ----------------------- * d The CultureInfo shortDate Format Pattern "M/d/yyyy" * D The CultureInfo longDate Format Pattern "dddd, MMMM dd, yyyy" * F The CultureInfo fullDateTime Format Pattern "dddd, MMMM dd, yyyy h:mm:ss tt" * m The CultureInfo monthDay Format Pattern "MMMM dd" * r The CultureInfo rfc1123 Format Pattern "ddd, dd MMM yyyy HH:mm:ss GMT" * s The CultureInfo sortableDateTime Format Pattern "yyyy-MM-ddTHH:mm:ss" * t The CultureInfo shortTime Format Pattern "h:mm tt" * T The CultureInfo longTime Format Pattern "h:mm:ss tt" * u The CultureInfo universalSortableDateTime Format Pattern "yyyy-MM-dd HH:mm:ssZ" * y The CultureInfo yearMonth Format Pattern "MMMM, yyyy" * * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @return {String} A string representation of the current Date object. */ var ord = function (n) { switch (n * 1) { case 1: case 21: case 31: return "st"; case 2: case 22: return "nd"; case 3: case 23: return "rd"; default: return "th"; } }; var parseStandardFormats = function (format) { var y, c = Date.CultureInfo.formatPatterns; switch (format) { case "d": return this.toString(c.shortDate); case "D": return this.toString(c.longDate); case "F": return this.toString(c.fullDateTime); case "m": return this.toString(c.monthDay); case "r": case "R": y = this.clone().addMinutes(this.getTimezoneOffset()); return y.toString(c.rfc1123) + " GMT"; case "s": return this.toString(c.sortableDateTime); case "t": return this.toString(c.shortTime); case "T": return this.toString(c.longTime); case "u": y = this.clone().addMinutes(this.getTimezoneOffset()); return y.toString(c.universalSortableDateTime); case "y": return this.toString(c.yearMonth); default: return false; } }; var parseFormatStringsClosure = function (context) { return function (m) { if (m.charAt(0) === "\\") { return m.replace("\\", ""); } switch (m) { case "hh": return p(context.getHours() < 13 ? (context.getHours() === 0 ? 12 : context.getHours()) : (context.getHours() - 12)); case "h": return context.getHours() < 13 ? (context.getHours() === 0 ? 12 : context.getHours()) : (context.getHours() - 12); case "HH": return p(context.getHours()); case "H": return context.getHours(); case "mm": return p(context.getMinutes()); case "m": return context.getMinutes(); case "ss": return p(context.getSeconds()); case "s": return context.getSeconds(); case "yyyy": return p(context.getFullYear(), 4); case "yy": return p(context.getFullYear()); case "y": return context.getFullYear(); case "E": case "dddd": return Date.CultureInfo.dayNames[context.getDay()]; case "ddd": return Date.CultureInfo.abbreviatedDayNames[context.getDay()]; case "dd": return p(context.getDate()); case "d": return context.getDate(); case "MMMM": return Date.CultureInfo.monthNames[context.getMonth()]; case "MMM": return Date.CultureInfo.abbreviatedMonthNames[context.getMonth()]; case "MM": return p((context.getMonth() + 1)); case "M": return context.getMonth() + 1; case "t": return context.getHours() < 12 ? Date.CultureInfo.amDesignator.substring(0, 1) : Date.CultureInfo.pmDesignator.substring(0, 1); case "tt": return context.getHours() < 12 ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator; case "S": return ord(context.getDate()); case "W": return context.getWeek(); case "WW": return context.getISOWeek(); case "Q": return "Q" + context.getQuarter(); case "q": return String(context.getQuarter()); case "z": return context.getTimezone(); case "Z": case "X": return Date.getTimezoneOffset(context.getTimezone()); case "ZZ": // Timezone offset in seconds return context.getTimezoneOffset() * -60; case "u": return context.getDay(); case "L": return ($D.isLeapYear(context.getFullYear())) ? 1 : 0; case "B": // Swatch Internet Time (.beats) return "@"+((context.getUTCSeconds() + (context.getUTCMinutes()*60) + ((context.getUTCHours()+1)*3600))/86.4); default: return m; } }; }; $P.toString = function (format, ignoreStandards) { // Standard Date and Time Format Strings. Formats pulled from CultureInfo file and // may vary by culture. if (!ignoreStandards && format && format.length === 1) { output = parseStandardFormats.call(this, format); if (output) { return output; } } var parseFormatStrings = parseFormatStringsClosure(this); return format ? format.replace(/((\\)?(dd?d?d?|MM?M?M?|yy?y?y?|hh?|HH?|mm?|ss?|tt?|S|q|Q|WW?W?W?)(?![^\[]*\]))/g, parseFormatStrings).replace(/\[|\]/g, "") : this._toString(); }; }()); /************************************************************* * SugarPak - Domain Specific Language - Syntactical Sugar * *************************************************************/ (function () { var $D = Date, $P = $D.prototype, $N = Number.prototype; // private $P._orient = +1; // private $P._nth = null; // private $P._is = false; // private $P._same = false; // private $P._isSecond = false; // private $N._dateElement = "days"; /** * Moves the date to the next instance of a date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.today().next().friday();
	Date.today().next().fri();
	Date.today().next().march();
	Date.today().next().mar();
	Date.today().next().week();
	
* * @return {Date} date */ $P.next = function () { this._move = true; this._orient = +1; return this; }; /** * Creates a new Date (Date.today()) and moves the date to the next instance of the date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.next().friday();
	Date.next().fri();
	Date.next().march();
	Date.next().mar();
	Date.next().week();
	
* * @return {Date} date */ $D.next = function () { return $D.today().next(); }; /** * Moves the date to the previous instance of a date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.today().last().friday();
	Date.today().last().fri();
	Date.today().last().march();
	Date.today().last().mar();
	Date.today().last().week();
	
* * @return {Date} date */ $P.last = $P.prev = $P.previous = function () { this._move = true; this._orient = -1; return this; }; /** * Creates a new Date (Date.today()) and moves the date to the previous instance of the date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.last().friday();
	Date.last().fri();
	Date.previous().march();
	Date.prev().mar();
	Date.last().week();
	
* * @return {Date} date */ $D.last = $D.prev = $D.previous = function () { return $D.today().last(); }; /** * Performs a equality check when followed by either a month name, day name or .weekday() function. * Example

	Date.today().is().friday(); // true|false
	Date.today().is().fri();
	Date.today().is().march();
	Date.today().is().mar();
	
* * @return {Boolean} true|false */ $P.is = function () { this._is = true; return this; }; /** * Determines if two date objects occur on/in exactly the same instance of the subsequent date part function. * The function .same() must be followed by a date part function (example: .day(), .month(), .year(), etc). * * An optional Date can be passed in the date part function. If now date is passed as a parameter, 'Now' is used. * * The following example demonstrates how to determine if two dates fall on the exact same day. * * Example

	var d1 = Date.today(); // today at 00:00
	var d2 = new Date();   // exactly now.

	// Do they occur on the same day?
	d1.same().day(d2); // true
	
	// Do they occur on the same hour?
	d1.same().hour(d2); // false, unless d2 hour is '00' (midnight).
	
	// What if it's the same day, but one year apart?
	var nextYear = Date.today().add(1).year();

	d1.same().day(nextYear); // false, because the dates must occur on the exact same day. 
	
* * Scenario: Determine if a given date occurs during some week period 2 months from now. * * Example

	var future = Date.today().add(2).months();
	return someDate.same().week(future); // true|false;
	
* * @return {Boolean} true|false */ $P.same = function () { this._same = true; this._isSecond = false; return this; }; /** * Determines if the current date/time occurs during Today. Must be preceded by the .is() function. * Example

	someDate.is().today();    // true|false
	new Date().is().today();  // true
	Date.today().is().today();// true
	Date.today().add(-1).day().is().today(); // false
	
* * @return {Boolean} true|false */ $P.today = function () { return this.same().day(); }; /** * Determines if the current date is a weekday. This function must be preceded by the .is() function. * Example

	Date.today().is().weekday(); // true|false
	
* * @return {Boolean} true|false */ $P.weekday = function () { if (this._nth) { return df("Weekday").call(this); } if (this._move) { return this.addWeekdays(this._orient); } if (this._is) { this._is = false; return (!this.is().sat() && !this.is().sun()); } return false; }; /** * Determines if the current date is on the weekend. This function must be preceded by the .is() function. * Example

	Date.today().is().weekend(); // true|false
	
* * @return {Boolean} true|false */ $P.weekend = function () { if (this._is) { this._is = false; return (this.is().sat() || this.is().sun()); } return false; }; /** * Sets the Time of the current Date instance. A string "6:15 pm" or config object {hour:18, minute:15} are accepted. * Example

	// Set time to 6:15pm with a String
	Date.today().at("6:15pm");

	// Set time to 6:15pm with a config object
	Date.today().at({hour:18, minute:15});
	
* * @return {Date} date */ $P.at = function (time) { return (typeof time === "string") ? $D.parse(this.toString("d") + " " + time) : this.set(time); }; /** * Creates a new Date() and adds this (Number) to the date based on the preceding date element function (eg. second|minute|hour|day|month|year). * Example

	// Undeclared Numbers must be wrapped with parentheses. Requirment of JavaScript.
	(3).days().fromNow();
	(6).months().fromNow();

	// Declared Number variables do not require parentheses. 
	var n = 6;
	n.months().fromNow();
	
* * @return {Date} A new Date instance */ $N.fromNow = $N.after = function (date) { var c = {}; c[this._dateElement] = this; return ((!date) ? new Date() : date.clone()).add(c); }; /** * Creates a new Date() and subtract this (Number) from the date based on the preceding date element function (eg. second|minute|hour|day|month|year). * Example

	// Undeclared Numbers must be wrapped with parentheses. Requirment of JavaScript.
	(3).days().ago();
	(6).months().ago();

	// Declared Number variables do not require parentheses. 
	var n = 6;
	n.months().ago();
	
* * @return {Date} A new Date instance */ $N.ago = $N.before = function (date) { var c = {}, s = (this._dateElement[this._dateElement.length-1] !== "s") ? this._dateElement + "s" : this._dateElement; c[s] = this * -1; return ((!date) ? new Date() : date.clone()).add(c); }; // Do NOT modify the following string tokens. These tokens are used to build dynamic functions. // All culture-specific strings can be found in the CultureInfo files. var dx = ("sunday monday tuesday wednesday thursday friday saturday").split(/\s/), mx = ("january february march april may june july august september october november december").split(/\s/), px = ("Millisecond Second Minute Hour Day Week Month Year Quarter Weekday").split(/\s/), pxf = ("Milliseconds Seconds Minutes Hours Date Week Month FullYear Quarter").split(/\s/), nth = ("final first second third fourth fifth").split(/\s/), de; /** * Returns an object literal of all the date parts. * Example

	var o = new Date().toObject();
	
	// { year: 2008, month: 4, week: 20, day: 13, hour: 18, minute: 9, second: 32, millisecond: 812 }
	
	// The object properties can be referenced directly from the object.
	
	alert(o.day);  // alerts "13"
	alert(o.year); // alerts "2008"
	
* * @return {Date} An object literal representing the original date object. */ $P.toObject = function () { var o = {}; for (var i = 0; i < px.length; i++) { if (this["get" + pxf[i]]) { o[px[i].toLowerCase()] = this["get" + pxf[i]](); } } return o; }; /** * Returns a date created from an object literal. Ignores the .week property if set in the config. * Example

	var o = new Date().toObject();
	
	return Date.fromObject(o); // will return the same date. 

	var o2 = {month: 1, day: 20, hour: 18}; // birthday party!
	Date.fromObject(o2);
	
* * @return {Date} An object literal representing the original date object. */ $D.fromObject = function(config) { config.week = null; return Date.today().set(config); }; // Create day name functions and abbreviated day name functions (eg. monday(), friday(), fri()). var df = function (n) { return function () { if (this._is) { this._is = false; return this.getDay() === n; } if (this._move) { this._move = null; } if (this._nth !== null) { // If the .second() function was called earlier, remove the _orient // from the date, and then continue. // This is required because 'second' can be used in two different context. // // Example // // Date.today().add(1).second(); // Date.march().second().monday(); // // Things get crazy with the following... // Date.march().add(1).second().second().monday(); // but it works!! // if (this._isSecond) { this.addSeconds(this._orient * -1); } // make sure we reset _isSecond this._isSecond = false; var ntemp = this._nth; this._nth = null; var temp = this.clone().moveToLastDayOfMonth(); this.moveToNthOccurrence(n, ntemp); if (this > temp) { throw new RangeError($D.getDayName(n) + " does not occur " + ntemp + " times in the month of " + $D.getMonthName(temp.getMonth()) + " " + temp.getFullYear() + "."); } return this; } return this.moveToDayOfWeek(n, this._orient); }; }; var sdf = function (n) { return function () { var t = $D.today(), shift = n - t.getDay(); if (n === 0 && Date.CultureInfo.firstDayOfWeek === 1 && t.getDay() !== 0) { shift = shift + 7; } return t.addDays(shift); }; }; // Create month name functions and abbreviated month name functions (eg. january(), march(), mar()). var month_instance_functions = function (n) { return function () { if (this._is) { this._is = false; return this.getMonth() === n; } return this.moveToMonth(n, this._orient); }; }; var month_static_functions = function (n) { return function () { return $D.today().set({ month: n, day: 1 }); }; }; var processTerms = function (names, staticFunc, instanceFunc) { for (var i = 0; i < names.length; i++) { // Create constant static Name variables. $D[names[i].toUpperCase()] = $D[names[i].toUpperCase().substring(0, 3)] = i; // Create Name functions. $D[names[i]] = $D[names[i].substring(0, 3)] = staticFunc(i); // Create Name instance functions. $P[names[i]] = $P[names[i].substring(0, 3)] = instanceFunc(i); } }; processTerms(dx, sdf, df); processTerms(mx, month_static_functions, month_instance_functions); // Create date element functions and plural date element functions used with Date (eg. day(), days(), months()). var ef = function (j) { return function () { // if the .second() function was called earlier, the _orient // has alread been added. Just return this and reset _isSecond. if (this._isSecond) { this._isSecond = false; return this; } if (this._same) { this._same = this._is = false; var o1 = this.toObject(), o2 = (arguments[0] || new Date()).toObject(), v = "", k = j.toLowerCase(); // the substr trick with -1 doesn't work in IE8 or less k = (k[k.length-1] === "s") ? k.substring(0,k.length-1) : k; for (var m = (px.length - 1); m > -1; m--) { v = px[m].toLowerCase(); if (o1[v] !== o2[v]) { return false; } if (k === v) { break; } } return true; } if (j.substring(j.length - 1) !== "s") { j += "s"; } if (this._move) { this._move = null; } return this["add" + j](this._orient); }; }; var nf = function (n) { return function () { this._dateElement = n; return this; }; }; for (var k = 0; k < px.length; k++) { de = px[k].toLowerCase(); if(de !== "weekday") { // Create date element functions and plural date element functions used with Date (eg. day(), days(), months()). $P[de] = $P[de + "s"] = ef(px[k]); // Create date element functions and plural date element functions used with Number (eg. day(), days(), months()). $N[de] = $N[de + "s"] = nf(de + "s"); } } $P._ss = ef("Second"); var nthfn = function (n) { return function (dayOfWeek) { if (this._same) { return this._ss(arguments[0]); } if (dayOfWeek || dayOfWeek === 0) { return this.moveToNthOccurrence(dayOfWeek, n); } this._nth = n; // if the operator is 'second' add the _orient, then deal with it later... if (n === 2 && (dayOfWeek === undefined || dayOfWeek === null)) { this._isSecond = true; return this.addSeconds(this._orient); } return this; }; }; for (var l = 0; l < nth.length; l++) { $P[nth[l]] = (l === 0) ? nthfn(-1) : nthfn(l); } }()); (function () { "use strict"; Date.Parsing = { Exception: function (s) { this.message = "Parse error at '" + s.substring(0, 10) + " ...'"; } }; var $P = Date.Parsing; var dayOffsets = { standard: [0,31,59,90,120,151,181,212,243,273,304,334], leap: [0,31,60,91,121,152,182,213,244,274,305,335] }; $P.isLeapYear = function(year) { return ((year % 4 === 0) && (year % 100 !== 0)) || (year % 400 === 0); }; var utils = { multiReplace : function (str, hash ) { var key; for (key in hash) { if (Object.prototype.hasOwnProperty.call(hash, key)) { var regex; if (typeof hash[key] === "function") { } else { regex = (hash[key] instanceof RegExp) ? hash[key] : new RegExp(hash[key], "g"); } str = str.replace(regex, key); } } return str; }, getDayOfYearFromWeek : function (obj) { var d, jan4, offset; obj.weekDay = (!obj.weekDay && obj.weekDay !== 0) ? 1 : obj.weekDay; d = new Date(obj.year, 0, 4); jan4 = d.getDay() === 0 ? 7 : d.getDay(); // JS is 0 indexed on Sunday. offset = jan4+3; obj.dayOfYear = ((obj.week * 7) + (obj.weekDay === 0 ? 7 : obj.weekDay))-offset; return obj; }, getDayOfYear : function (obj, dayOffset) { if (!obj.dayOfYear) { obj = utils.getDayOfYearFromWeek(obj); } for (var i=0;i <= dayOffset.length;i++) { if (obj.dayOfYear < dayOffset[i] || i === dayOffset.length) { obj.day = obj.day ? obj.day : (obj.dayOfYear - dayOffset[i-1]); break; } else { obj.month = i; } } return obj; }, adjustForTimeZone : function (obj, date) { var offset; if (obj.zone.toUpperCase() === "Z" || (obj.zone_hours === 0 && obj.zone_minutes === 0)) { // it's UTC/GML so work out the current timeszone offset offset = -date.getTimezoneOffset(); } else { offset = (obj.zone_hours*60) + (obj.zone_minutes || 0); if (obj.zone_sign === "+") { offset *= -1; } offset -= date.getTimezoneOffset(); } date.setMinutes(date.getMinutes()+offset); return date; }, setDefaults : function (obj) { obj.year = obj.year || Date.today().getFullYear(); obj.hours = obj.hours || 0; obj.minutes = obj.minutes || 0; obj.seconds = obj.seconds || 0; obj.milliseconds = obj.milliseconds || 0; if (!(!obj.month && (obj.week || obj.dayOfYear))) { // if we have a month, or if we don't but don't have the day calculation data obj.month = obj.month || 0; obj.day = obj.day || 1; } return obj; }, dataNum: function (data, mod, explict, postProcess) { var dataNum = data*1; if (mod) { if (postProcess) { return data ? mod(data)*1 : data; } else { return data ? mod(dataNum) : data; } } else if (!explict){ return data ? dataNum : data; } else { return (data && typeof data !== "undefined") ? dataNum : data; } }, timeDataProcess: function (obj) { var timeObj = {}; for (var x in obj.data) { if (obj.data.hasOwnProperty(x)) { timeObj[x] = obj.ignore[x] ? obj.data[x] : utils.dataNum(obj.data[x], obj.mods[x], obj.explict[x], obj.postProcess[x]); } } if (obj.data.secmins) { obj.data.secmins = obj.data.secmins.replace(",", ".") * 60; if (!timeObj.minutes) { timeObj.minutes = obj.data.secmins; } else if (!timeObj.seconds) { timeObj.seconds = obj.data.secmins; } delete obj.secmins; } return timeObj; }, buildTimeObjectFromData: function (data) { var time = utils.timeDataProcess({ data: { year : data[1], month : data[5], day : data[7], week : data[8], dayOfYear : data[10], hours : data[15], zone_hours : data[23], zone_minutes : data[24], zone : data[21], zone_sign : data[22], weekDay : data[9], minutes: data[16], seconds: data[19], milliseconds: data[20], secmins: data[18] }, mods: { month: function(data) { return data-1; }, weekDay: function (data) { data = Math.abs(data); return (data === 7 ? 0 : data); }, minutes: function (data) { return data.replace(":",""); }, seconds: function (data) { return Math.floor( (data.replace(":","").replace(",","."))*1 ); }, milliseconds: function (data) { return (data.replace(",",".")*1000); } }, postProcess: { minutes: true, seconds: true, milliseconds: true }, explict: { zone_hours: true, zone_minutes: true }, ignore: { zone: true, zone_sign: true, secmins: true } }); return time; }, addToHash: function (hash, keys, data) { keys = keys; data = data; var len = keys.length; for (var i = 0; i < len; i++) { hash[keys[i]] = data[i]; } return hash; }, combineRegex: function (r1, r2) { return new RegExp("(("+r1.source+")\\s("+r2.source+"))"); }, getDateNthString: function(add, last, inc){ if (add) { return Date.today().addDays(inc).toString("d"); } else if (last) { return Date.today().last()[inc]().toString("d"); } }, buildRegexData: function (array) { var arr = []; var len = array.length; for (var i=0; i < len; i++) { if (Object.prototype.toString.call(array[i]) === '[object Array]') { // oldIE compat version of Array.isArray arr.push(this.combineRegex(array[i][0], array[i][1])); } else { arr.push(array[i]); } } return arr; } }; $P.processTimeObject = function (obj) { var date, dayOffset; utils.setDefaults(obj); dayOffset = ($P.isLeapYear(obj.year)) ? dayOffsets.leap : dayOffsets.standard; if (!obj.month && (obj.week || obj.dayOfYear)) { utils.getDayOfYear(obj, dayOffset); } else { obj.dayOfYear = dayOffset[obj.month] + obj.day; } date = new Date(obj.year, obj.month, obj.day, obj.hours, obj.minutes, obj.seconds, obj.milliseconds); if (obj.zone) { utils.adjustForTimeZone(obj, date); // adjust (and calculate) for timezone } return date; }; $P.ISO = { regex : /^([\+-]?\d{4}(?!\d{2}\b))((-?)((0[1-9]|1[0-2])(\3([12]\d|0[1-9]|3[01]))?|W([0-4]\d|5[0-3])(-?[1-7])?|(00[1-9]|0[1-9]\d|[12]\d{2}|3([0-5]\d|6[1-6])))([T\s]((([01]\d|2[0-4])((:?)[0-5]\d)?|24\:?00)([\.,]\d+(?!:))?)?(\17[0-5]\d([\.,]\d+)?)?\s?([zZ]|([\+-])([01]\d|2[0-3]):?([0-5]\d)?)?)?)?$/, parse : function (s) { var time, data = s.match(this.regex); if (!data || !data.length) { return null; } time = utils.buildTimeObjectFromData(data); if (!time.year || (!time.year && (!time.month && !time.day) && (!time.week && !time.dayOfYear)) ) { return null; } return $P.processTimeObject(time); } }; $P.Numeric = { isNumeric: function (e){return!isNaN(parseFloat(e))&&isFinite(e);}, regex: /\b([0-1]?[0-9])([0-3]?[0-9])([0-2]?[0-9]?[0-9][0-9])\b/i, parse: function (s) { var data, i, time = {}, order = Date.CultureInfo.dateElementOrder.split(""); if (!(this.isNumeric(s)) || // if it's non-numeric OR (s[0] === "+" && s[0] === "-")) { // It's an arithmatic string (eg +/-1000) return null; } if (s.length < 5 && s.indexOf(".") < 0 && s.indexOf("/") < 0) { // assume it's just a year. time.year = s; return $P.processTimeObject(time); } data = s.match(this.regex); if (!data || !data.length) { return null; } for (i=0; i < order.length; i++) { switch(order[i]) { case "d": time.day = data[i+1]; break; case "m": time.month = (data[i+1]-1); break; case "y": time.year = data[i+1]; break; } } return $P.processTimeObject(time); } }; $P.Normalizer = { regexData: function () { var $R = Date.CultureInfo.regexPatterns; return utils.buildRegexData([ $R.tomorrow, $R.yesterday, [$R.past, $R.mon], [$R.past, $R.tue], [$R.past, $R.wed], [$R.past, $R.thu], [$R.past, $R.fri], [$R.past, $R.sat], [$R.past, $R.sun] ]); }, basicReplaceHash : function() { var $R = Date.CultureInfo.regexPatterns; return { "January": $R.jan.source, "February": $R.feb, "March": $R.mar, "April": $R.apr, "May": $R.may, "June": $R.jun, "July": $R.jul, "August": $R.aug, "September": $R.sep, "October": $R.oct, "November": $R.nov, "December": $R.dec, "": /\bat\b/gi, " ": /\s{2,}/, "am": $R.inTheMorning, "9am": $R.thisMorning, "pm": $R.inTheEvening, "7pm":$R.thisEvening }; }, keys : function(){ return [ utils.getDateNthString(true, false, 1), // tomorrow utils.getDateNthString(true, false, -1), // yesterday utils.getDateNthString(false, true, "monday"), //last mon utils.getDateNthString(false, true, "tuesday"), //last tues utils.getDateNthString(false, true, "wednesday"), //last wed utils.getDateNthString(false, true, "thursday"), //last thurs utils.getDateNthString(false, true, "friday"), //last fri utils.getDateNthString(false, true, "saturday"), //last sat utils.getDateNthString(false, true, "sunday") //last sun ]; }, buildRegexFunctions: function () { var $R = Date.CultureInfo.regexPatterns; var __ = Date.i18n.__; var tomorrowRE = new RegExp("(\\b\\d\\d?("+__("AM")+"|"+__("PM")+")? )("+$R.tomorrow.source.slice(1)+")", "i"); // adapted tomorrow regex for AM PM relative dates var todayRE = new RegExp($R.today.source + "(?!\\s*([+-]))\\b"); // today, but excludes the math operators (eg "today + 2h") this.replaceFuncs = [ [todayRE, function (full) { return (full.length > 1) ? Date.today().toString("d") : full; }], [tomorrowRE, function(full, m1) { var t = Date.today().addDays(1).toString("d"); return (t + " " + m1); }], [$R.amThisMorning, function(str, am){return am;}], [$R.pmThisEvening, function(str, pm){return pm;}] ]; }, buildReplaceData: function () { this.buildRegexFunctions(); this.replaceHash = utils.addToHash(this.basicReplaceHash(), this.keys(), this.regexData()); }, stringReplaceFuncs: function (s) { for (var i=0; i < this.replaceFuncs.length; i++) { s = s.replace(this.replaceFuncs[i][0], this.replaceFuncs[i][1]); } return s; }, parse: function (s) { s = this.stringReplaceFuncs(s); s = utils.multiReplace(s, this.replaceHash); try { var n = s.split(/([\s\-\.\,\/\x27]+)/); if (n.length === 3 && $P.Numeric.isNumeric(n[0]) && $P.Numeric.isNumeric(n[2]) && (n[2].length >= 4)) { // ok, so we're dealing with x/year. But that's not a full date. // This fixes wonky dateElementOrder parsing when set to dmy order. if (Date.CultureInfo.dateElementOrder[0] === "d") { s = "1/" + n[0] + "/" + n[2]; // set to 1st of month and normalize the seperator } } } catch (e) {} return s; } }; $P.Normalizer.buildReplaceData(); }()); (function () { var $P = Date.Parsing; var _ = $P.Operators = { // // Tokenizers // rtoken: function (r) { // regex token return function (s) { var mx = s.match(r); if (mx) { return ([ mx[0], s.substring(mx[0].length) ]); } else { throw new $P.Exception(s); } }; }, token: function () { // whitespace-eating token return function (s) { return _.rtoken(new RegExp("^\\s*" + s + "\\s*"))(s); }; }, stoken: function (s) { // string token return _.rtoken(new RegExp("^" + s)); }, // Atomic Operators until: function (p) { return function (s) { var qx = [], rx = null; while (s.length) { try { rx = p.call(this, s); } catch (e) { qx.push(rx[0]); s = rx[1]; continue; } break; } return [ qx, s ]; }; }, many: function (p) { return function (s) { var rx = [], r = null; while (s.length) { try { r = p.call(this, s); } catch (e) { return [ rx, s ]; } rx.push(r[0]); s = r[1]; } return [ rx, s ]; }; }, // generator operators -- see below optional: function (p) { return function (s) { var r = null; try { r = p.call(this, s); } catch (e) { return [ null, s ]; } return [ r[0], r[1] ]; }; }, not: function (p) { return function (s) { try { p.call(this, s); } catch (e) { return [null, s]; } throw new $P.Exception(s); }; }, ignore: function (p) { return p ? function (s) { var r = null; r = p.call(this, s); return [null, r[1]]; } : null; }, product: function () { var px = arguments[0], qx = Array.prototype.slice.call(arguments, 1), rx = []; for (var i = 0 ; i < px.length ; i++) { rx.push(_.each(px[i], qx)); } return rx; }, cache: function (rule) { var cache = {}, cache_length = 0, cache_keys = [], CACHE_MAX = Date.Config.CACHE_MAX || 100000, r = null; var cacheCheck = function () { if (cache_length === CACHE_MAX) { // kill several keys, don't want to have to do this all the time... for (var i=0; i < 10; i++) { var key = cache_keys.shift(); if (key) { delete cache[key]; cache_length--; } } } }; return function (s) { cacheCheck(); try { r = cache[s] = (cache[s] || rule.call(this, s)); } catch (e) { r = cache[s] = e; } cache_length++; cache_keys.push(s); if (r instanceof $P.Exception) { throw r; } else { return r; } }; }, // vector operators -- see below any: function () { var px = arguments; return function (s) { var r = null; for (var i = 0; i < px.length; i++) { if (px[i] == null) { continue; } try { r = (px[i].call(this, s)); } catch (e) { r = null; } if (r) { return r; } } throw new $P.Exception(s); }; }, each: function () { var px = arguments; return function (s) { var rx = [], r = null; for (var i = 0; i < px.length ; i++) { if (px[i] == null) { continue; } try { r = (px[i].call(this, s)); } catch (e) { throw new $P.Exception(s); } rx.push(r[0]); s = r[1]; } return [ rx, s]; }; }, all: function () { var px = arguments, _ = _; return _.each(_.optional(px)); }, // delimited operators sequence: function (px, d, c) { d = d || _.rtoken(/^\s*/); c = c || null; if (px.length === 1) { return px[0]; } return function (s) { var r = null, q = null; var rx = []; for (var i = 0; i < px.length ; i++) { try { r = px[i].call(this, s); } catch (e) { break; } rx.push(r[0]); try { q = d.call(this, r[1]); } catch (ex) { q = null; break; } s = q[1]; } if (!r) { throw new $P.Exception(s); } if (q) { throw new $P.Exception(q[1]); } if (c) { try { r = c.call(this, r[1]); } catch (ey) { throw new $P.Exception(r[1]); } } return [ rx, (r?r[1]:s) ]; }; }, // // Composite Operators // between: function (d1, p, d2) { d2 = d2 || d1; var _fn = _.each(_.ignore(d1), p, _.ignore(d2)); return function (s) { var rx = _fn.call(this, s); return [[rx[0][0], r[0][2]], rx[1]]; }; }, list: function (p, d, c) { d = d || _.rtoken(/^\s*/); c = c || null; return (p instanceof Array ? _.each(_.product(p.slice(0, -1), _.ignore(d)), p.slice(-1), _.ignore(c)) : _.each(_.many(_.each(p, _.ignore(d))), px, _.ignore(c))); }, set: function (px, d, c) { d = d || _.rtoken(/^\s*/); c = c || null; return function (s) { // r is the current match, best the current 'best' match // which means it parsed the most amount of input var r = null, p = null, q = null, rx = null, best = [[], s], last = false; // go through the rules in the given set for (var i = 0; i < px.length ; i++) { // last is a flag indicating whether this must be the last element // if there is only 1 element, then it MUST be the last one q = null; p = null; r = null; last = (px.length === 1); // first, we try simply to match the current pattern // if not, try the next pattern try { r = px[i].call(this, s); } catch (e) { continue; } // since we are matching against a set of elements, the first // thing to do is to add r[0] to matched elements rx = [[r[0]], r[1]]; // if we matched and there is still input to parse and // we don't already know this is the last element, // we're going to next check for the delimiter ... // if there's none, or if there's no input left to parse // than this must be the last element after all ... if (r[1].length > 0 && ! last) { try { q = d.call(this, r[1]); } catch (ex) { last = true; } } else { last = true; } // if we parsed the delimiter and now there's no more input, // that means we shouldn't have parsed the delimiter at all // so don't update r and mark this as the last element ... if (!last && q[1].length === 0) { last = true; } // so, if this isn't the last element, we're going to see if // we can get any more matches from the remaining (unmatched) // elements ... if (!last) { // build a list of the remaining rules we can match against, // i.e., all but the one we just matched against var qx = []; for (var j = 0; j < px.length ; j++) { if (i !== j) { qx.push(px[j]); } } // now invoke recursively set with the remaining input // note that we don't include the closing delimiter ... // we'll check for that ourselves at the end p = _.set(qx, d).call(this, q[1]); // if we got a non-empty set as a result ... // (otw rx already contains everything we want to match) if (p[0].length > 0) { // update current result, which is stored in rx ... // basically, pick up the remaining text from p[1] // and concat the result from p[0] so that we don't // get endless nesting ... rx[0] = rx[0].concat(p[0]); rx[1] = p[1]; } } // at this point, rx either contains the last matched element // or the entire matched set that starts with this element. // now we just check to see if this variation is better than // our best so far, in terms of how much of the input is parsed if (rx[1].length < best[1].length) { best = rx; } // if we've parsed all the input, then we're finished if (best[1].length === 0) { break; } } // so now we've either gone through all the patterns trying them // as the initial match; or we found one that parsed the entire // input string ... // if best has no matches, just return empty set ... if (best[0].length === 0) { return best; } // if a closing delimiter is provided, then we have to check it also if (c) { // we try this even if there is no remaining input because the pattern // may well be optional or match empty input ... try { q = c.call(this, best[1]); } catch (ey) { throw new $P.Exception(best[1]); } // it parsed ... be sure to update the best match remaining input best[1] = q[1]; } // if we're here, either there was no closing delimiter or we parsed it // so now we have the best match; just return it! return best; }; }, forward: function (gr, fname) { return function (s) { return gr[fname].call(this, s); }; }, // // Translation Operators // replace: function (rule, repl) { return function (s) { var r = rule.call(this, s); return [repl, r[1]]; }; }, process: function (rule, fn) { return function (s) { var r = rule.call(this, s); return [fn.call(this, r[0]), r[1]]; }; }, min: function (min, rule) { return function (s) { var rx = rule.call(this, s); if (rx[0].length < min) { throw new $P.Exception(s); } return rx; }; } }; // Generator Operators And Vector Operators // Generators are operators that have a signature of F(R) => R, // taking a given rule and returning another rule, such as // ignore, which parses a given rule and throws away the result. // Vector operators are those that have a signature of F(R1,R2,...) => R, // take a list of rules and returning a new rule, such as each. // Generator operators are converted (via the following _generator // function) into functions that can also take a list or array of rules // and return an array of new rules as though the function had been // called on each rule in turn (which is what actually happens). // This allows generators to be used with vector operators more easily. // Example: // each(ignore(foo, bar)) instead of each(ignore(foo), ignore(bar)) // This also turns generators into vector operators, which allows // constructs like: // not(cache(foo, bar)) var _generator = function (op) { function gen() { var args = null, rx = [], px, i; if (arguments.length > 1) { args = Array.prototype.slice.call(arguments); } else if (arguments[0] instanceof Array) { args = arguments[0]; } if (args) { px = args.shift(); if (px.length > 0) { args.unshift(px[i]); rx.push(op.apply(null, args)); args.shift(); return rx; } } else { return op.apply(null, arguments); } } return gen; }; var gx = "optional not ignore cache".split(/\s/); for (var i = 0 ; i < gx.length ; i++) { _[gx[i]] = _generator(_[gx[i]]); } var _vector = function (op) { return function () { if (arguments[0] instanceof Array) { return op.apply(null, arguments[0]); } else { return op.apply(null, arguments); } }; }; var vx = "each any all".split(/\s/); for (var j = 0 ; j < vx.length ; j++) { _[vx[j]] = _vector(_[vx[j]]); } }()); (function () { var $D = Date; var flattenAndCompact = function (ax) { var rx = []; for (var i = 0; i < ax.length; i++) { if (ax[i] instanceof Array) { rx = rx.concat(flattenAndCompact(ax[i])); } else { if (ax[i]) { rx.push(ax[i]); } } } return rx; }; var parseMeridian = function () { if (this.meridian && (this.hour || this.hour === 0)) { if (this.meridian === "a" && this.hour > 11 && Date.Config.strict24hr){ throw "Invalid hour and meridian combination"; } else if (this.meridian === "p" && this.hour < 12 && Date.Config.strict24hr){ throw "Invalid hour and meridian combination"; } else if (this.meridian === "p" && this.hour < 12) { this.hour = this.hour + 12; } else if (this.meridian === "a" && this.hour === 12) { this.hour = 0; } } }; var setDefaults = function () { var now = new Date(); if ((this.hour || this.minute) && (!this.month && !this.year && !this.day)) { this.day = now.getDate(); } if (!this.year) { this.year = now.getFullYear(); } if (!this.month && this.month !== 0) { this.month = now.getMonth(); } if (!this.day) { this.day = 1; } if (!this.hour) { this.hour = 0; } if (!this.minute) { this.minute = 0; } if (!this.second) { this.second = 0; } if (!this.millisecond) { this.millisecond = 0; } }; var finishUtils = { getToday: function () { if (this.now || "hour minute second".indexOf(this.unit) !== -1) { return new Date(); } else { return $D.today(); } }, setDaysFromWeekday: function (today, orient){ var gap; orient = orient || 1; this.unit = "day"; gap = ($D.getDayNumberFromName(this.weekday) - today.getDay()); this.days = gap ? ((gap + (orient * 7)) % 7) : (orient * 7); return this; }, setMonthsFromMonth: function (today, orient) { var gap; orient = orient || 1; this.unit = "month"; gap = (this.month - today.getMonth()); this.months = gap ? ((gap + (orient * 12)) % 12) : (orient * 12); this.month = null; return this; }, setDMYFromWeekday: function () { var d = Date[this.weekday](); this.day = d.getDate(); if (!this.month) { this.month = d.getMonth(); } this.year = d.getFullYear(); return this; }, setUnitValue: function (orient) { if (!this.value && this.operator && this.operator !== null && this[this.unit + "s"] && this[this.unit + "s"] !== null) { this[this.unit + "s"] = this[this.unit + "s"] + ((this.operator === "add") ? 1 : -1) + (this.value||0) * orient; } else if (this[this.unit + "s"] == null || this.operator != null) { if (!this.value) { this.value = 1; } this[this.unit + "s"] = this.value * orient; } }, generateDateFromWeeks: function () { var weekday = (this.weekday !== undefined) ? this.weekday : "today"; var d = Date[weekday]().addWeeks(this.weeks); if (this.now) { d.setTimeToNow(); } return d; } }; $D.Translator = { hour: function (s) { return function () { this.hour = Number(s); }; }, minute: function (s) { return function () { this.minute = Number(s); }; }, second: function (s) { return function () { this.second = Number(s); }; }, /* for ss.s format */ secondAndMillisecond: function (s) { return function () { var mx = s.match(/^([0-5][0-9])\.([0-9]{1,3})/); this.second = Number(mx[1]); this.millisecond = Number(mx[2]); }; }, meridian: function (s) { return function () { this.meridian = s.slice(0, 1).toLowerCase(); }; }, timezone: function (s) { return function () { var n = s.replace(/[^\d\+\-]/g, ""); if (n.length) { this.timezoneOffset = Number(n); } else { this.timezone = s.toLowerCase(); } }; }, day: function (x) { var s = x[0]; return function () { this.day = Number(s.match(/\d+/)[0]); if (this.day < 1) { throw "invalid day"; } }; }, month: function (s) { return function () { this.month = (s.length === 3) ? "jan feb mar apr may jun jul aug sep oct nov dec".indexOf(s)/4 : Number(s) - 1; if (this.month < 0) { throw "invalid month"; } }; }, year: function (s) { return function () { var n = Number(s); this.year = ((s.length > 2) ? n : (n + (((n + 2000) < Date.CultureInfo.twoDigitYearMax) ? 2000 : 1900))); }; }, rday: function (s) { return function () { switch (s) { case "yesterday": this.days = -1; break; case "tomorrow": this.days = 1; break; case "today": this.days = 0; break; case "now": this.days = 0; this.now = true; break; } }; }, finishExact: function (x) { var d; x = (x instanceof Array) ? x : [x]; for (var i = 0 ; i < x.length ; i++) { if (x[i]) { x[i].call(this); } } setDefaults.call(this); parseMeridian.call(this); if (this.day > $D.getDaysInMonth(this.year, this.month)) { throw new RangeError(this.day + " is not a valid value for days."); } d = new Date(this.year, this.month, this.day, this.hour, this.minute, this.second, this.millisecond); if (this.year < 100) { d.setFullYear(this.year); // means years less that 100 are process correctly. JS will parse it otherwise as 1900-1999. } if (this.timezone) { d.set({ timezone: this.timezone }); } else if (this.timezoneOffset) { d.set({ timezoneOffset: this.timezoneOffset }); } return d; }, finish: function (x) { var today, expression, orient, temp; x = (x instanceof Array) ? flattenAndCompact(x) : [ x ]; if (x.length === 0) { return null; } for (var i = 0 ; i < x.length ; i++) { if (typeof x[i] === "function") { x[i].call(this); } } if (this.now && !this.unit && !this.operator) { return new Date(); } else { today = finishUtils.getToday.call(this); } expression = !!(this.days && this.days !== null || this.orient || this.operator); orient = ((this.orient === "past" || this.operator === "subtract") ? -1 : 1); if (this.month && this.unit === "week") { this.value = this.month + 1; delete this.month; delete this.day; } if ((this.month || this.month === 0) && "year day hour minute second".indexOf(this.unit) !== -1) { if (!this.value) { this.value = this.month + 1; } this.month = null; expression = true; } if (!expression && this.weekday && !this.day && !this.days) { finishUtils.setDMYFromWeekday.call(this); } if (expression && this.weekday && this.unit !== "month" && this.unit !== "week") { finishUtils.setDaysFromWeekday.call(this, today, orient); } if (this.weekday && this.unit !== "week" && !this.day && !this.days) { temp = Date[this.weekday](); this.day = temp.getDate(); if (temp.getMonth() !== today.getMonth()) { this.month = temp.getMonth(); } } if (this.month && this.unit === "day" && this.operator) { if (!this.value) { this.value = (this.month + 1); } this.month = null; } if (this.value != null && this.month != null && this.year != null) { this.day = this.value * 1; } if (this.month && !this.day && this.value) { today.set({ day: this.value * 1 }); if (!expression) { this.day = this.value * 1; } } if (!this.month && this.value && this.unit === "month" && !this.now) { this.month = this.value; expression = true; } if (expression && (this.month || this.month === 0) && this.unit !== "year") { finishUtils.setMonthsFromMonth.call(this, today, orient); } if (!this.unit) { this.unit = "day"; } finishUtils.setUnitValue.call(this, orient); parseMeridian.call(this); if ((this.month || this.month === 0) && !this.day) { this.day = 1; } if (!this.orient && !this.operator && this.unit === "week" && this.value && !this.day && !this.month) { return Date.today().setWeek(this.value); } if (this.unit === "week" && this.weeks && !this.day && !this.month) { return finishUtils.generateDateFromWeeks.call(this); } if (expression && this.timezone && this.day && this.days) { this.day = this.days; } if (expression){ today.add(this); } else { today.set(this); } if (this.timezone) { this.timezone = this.timezone.toUpperCase(); var offset = $D.getTimezoneOffset(this.timezone); var timezone; if (today.hasDaylightSavingTime()) { // lets check that we're being sane with timezone setting timezone = $D.getTimezoneAbbreviation(offset, today.isDaylightSavingTime()); if (timezone !== this.timezone) { // bugger, we're in a place where things like EST vs EDT matters. if (today.isDaylightSavingTime()) { today.addHours(-1); } else { today.addHours(1); } } } today.setTimezoneOffset(offset); } return today; } }; }()); (function () { var $D = Date; $D.Grammar = {}; var _ = $D.Parsing.Operators, g = $D.Grammar, t = $D.Translator, _fn; // Allow rolling up into general purpose rules _fn = function () { return _.each(_.any.apply(null, arguments), _.not(g.ctoken2("timeContext"))); }; g.datePartDelimiter = _.rtoken(/^([\s\-\.\,\/\x27]+)/); g.timePartDelimiter = _.stoken(":"); g.whiteSpace = _.rtoken(/^\s*/); g.generalDelimiter = _.rtoken(/^(([\s\,]|at|@|on)+)/); var _C = {}; g.ctoken = function (keys) { var fn = _C[keys]; if (! fn) { var c = Date.CultureInfo.regexPatterns; var kx = keys.split(/\s+/), px = []; for (var i = 0; i < kx.length ; i++) { px.push(_.replace(_.rtoken(c[kx[i]]), kx[i])); } fn = _C[keys] = _.any.apply(null, px); } return fn; }; g.ctoken2 = function (key) { return _.rtoken(Date.CultureInfo.regexPatterns[key]); }; var cacheProcessRtoken = function (key, token, type, eachToken) { if (eachToken) { g[key] = _.cache(_.process(_.each(_.rtoken(token),_.optional(g.ctoken2(eachToken))), type)); } else { g[key] = _.cache(_.process(_.rtoken(token), type)); } }; var cacheProcessCtoken = function (token, type) { return _.cache(_.process(g.ctoken2(token), type)); }; var _F = {}; //function cache var _get = function (f) { _F[f] = (_F[f] || g.format(f)[0]); return _F[f]; }; g.allformats = function (fx) { var rx = []; if (fx instanceof Array) { for (var i = 0; i < fx.length; i++) { rx.push(_get(fx[i])); } } else { rx.push(_get(fx)); } return rx; }; g.formats = function (fx) { if (fx instanceof Array) { var rx = []; for (var i = 0 ; i < fx.length ; i++) { rx.push(_get(fx[i])); } return _.any.apply(null, rx); } else { return _get(fx); } }; var grammarFormats = { timeFormats: function(){ var i, RTokenKeys = [ "h", "hh", "H", "HH", "m", "mm", "s", "ss", "ss.s", "z", "zz" ], RToken = [ /^(0[0-9]|1[0-2]|[1-9])/, /^(0[0-9]|1[0-2])/, /^([0-1][0-9]|2[0-3]|[0-9])/, /^([0-1][0-9]|2[0-3])/, /^([0-5][0-9]|[0-9])/, /^[0-5][0-9]/, /^([0-5][0-9]|[0-9])/, /^[0-5][0-9]/, /^[0-5][0-9]\.[0-9]{1,3}/, /^((\+|\-)\s*\d\d\d\d)|((\+|\-)\d\d\:?\d\d)/, /^((\+|\-)\s*\d\d\d\d)|((\+|\-)\d\d\:?\d\d)/ ], tokens = [ t.hour, t.hour, t.hour, t.hour, t.minute, t.minute, t.second, t.second, t.secondAndMillisecond, t.timezone, t.timezone ]; for (i=0; i < RTokenKeys.length; i++) { cacheProcessRtoken(RTokenKeys[i], RToken[i], tokens[i]); } g.hms = _.cache(_.sequence([g.H, g.m, g.s], g.timePartDelimiter)); g.t = cacheProcessCtoken("shortMeridian", t.meridian); g.tt = cacheProcessCtoken("longMeridian", t.meridian); g.zzz = cacheProcessCtoken("timezone", t.timezone); g.timeSuffix = _.each(_.ignore(g.whiteSpace), _.set([ g.tt, g.zzz ])); g.time = _.each(_.optional(_.ignore(_.stoken("T"))), g.hms, g.timeSuffix); }, dateFormats: function () { // pre-loaded rules for different date part order preferences var _setfn = function () { return _.set(arguments, g.datePartDelimiter); }; var i, RTokenKeys = [ "d", "dd", "M", "MM", "y", "yy", "yyy", "yyyy" ], RToken = [ /^([0-2]\d|3[0-1]|\d)/, /^([0-2]\d|3[0-1])/, /^(1[0-2]|0\d|\d)/, /^(1[0-2]|0\d)/, /^(\d+)/, /^(\d\d)/, /^(\d\d?\d?\d?)/, /^(\d\d\d\d)/ ], tokens = [ t.day, t.day, t.month, t.month, t.year, t.year, t.year, t.year ], eachToken = [ "ordinalSuffix", "ordinalSuffix" ]; for (i=0; i < RTokenKeys.length; i++) { cacheProcessRtoken(RTokenKeys[i], RToken[i], tokens[i], eachToken[i]); } g.MMM = g.MMMM = _.cache(_.process(g.ctoken("jan feb mar apr may jun jul aug sep oct nov dec"), t.month)); g.ddd = g.dddd = _.cache(_.process(g.ctoken("sun mon tue wed thu fri sat"), function (s) { return function () { this.weekday = s; }; } )); g.day = _fn(g.d, g.dd); g.month = _fn(g.M, g.MMM); g.year = _fn(g.yyyy, g.yy); g.mdy = _setfn(g.ddd, g.month, g.day, g.year); g.ymd = _setfn(g.ddd, g.year, g.month, g.day); g.dmy = _setfn(g.ddd, g.day, g.month, g.year); g.date = function (s) { return ((g[Date.CultureInfo.dateElementOrder] || g.mdy).call(this, s)); }; }, relative: function () { // relative date / time expressions g.orientation = _.process(g.ctoken("past future"), function (s) { return function () { this.orient = s; }; } ); g.operator = _.process(g.ctoken("add subtract"), function (s) { return function () { this.operator = s; }; } ); g.rday = _.process(g.ctoken("yesterday tomorrow today now"), t.rday); g.unit = _.process(g.ctoken("second minute hour day week month year"), function (s) { return function () { this.unit = s; }; } ); } }; g.buildGrammarFormats = function () { // these need to be rebuilt every time the language changes. _C = {}; grammarFormats.timeFormats(); grammarFormats.dateFormats(); grammarFormats.relative(); g.value = _.process(_.rtoken(/^([-+]?\d+)?(st|nd|rd|th)?/), function (s) { return function () { this.value = s.replace(/\D/g, ""); }; } ); g.expression = _.set([g.rday, g.operator, g.value, g.unit, g.orientation, g.ddd, g.MMM ]); g.format = _.process(_.many( _.any( // translate format specifiers into grammar rules _.process( _.rtoken(/^(dd?d?d?(?!e)|MM?M?M?|yy?y?y?|hh?|HH?|mm?|ss?|tt?|zz?z?)/), function (fmt) { if (g[fmt]) { return g[fmt]; } else { throw $D.Parsing.Exception(fmt); } } ), // translate separator tokens into token rules _.process(_.rtoken(/^[^dMyhHmstz]+/), // all legal separators function (s) { return _.ignore(_.stoken(s)); } ) ) ), // construct the parser ... function (rules) { return _.process(_.each.apply(null, rules), t.finishExact); } ); // starting rule for general purpose grammar g._start = _.process(_.set([ g.date, g.time, g.expression ], g.generalDelimiter, g.whiteSpace), t.finish); }; g.buildGrammarFormats(); // parsing date format specifiers - ex: "h:m:s tt" // this little guy will generate a custom parser based // on the format string, ex: g.format("h:m:s tt") // check for these formats first g._formats = g.formats([ "\"yyyy-MM-ddTHH:mm:ssZ\"", "yyyy-MM-ddTHH:mm:ss.sz", "yyyy-MM-ddTHH:mm:ssZ", "yyyy-MM-ddTHH:mm:ssz", "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-ddTHH:mmZ", "yyyy-MM-ddTHH:mmz", "yyyy-MM-ddTHH:mm", "ddd, MMM dd, yyyy H:mm:ss tt", "ddd MMM d yyyy HH:mm:ss zzz", "MMddyyyy", "ddMMyyyy", "Mddyyyy", "ddMyyyy", "Mdyyyy", "dMyyyy", "yyyy", "Mdyy", "dMyy", "d" ]); // real starting rule: tries selected formats first, // then general purpose rule g.start = function (s) { try { var r = g._formats.call({}, s); if (r[1].length === 0) { return r; } } catch (e) {} return g._start.call({}, s); }; }()); (function () { var $D = Date; /** * @desc Converts the specified string value into its JavaScript Date equivalent using CultureInfo specific format information. * * Example

	///////////
	// Dates //
	///////////

	// 15-Oct-2004
	var d1 = Date.parse("10/15/2004");

	// 15-Oct-2004
	var d1 = Date.parse("15-Oct-2004");

	// 15-Oct-2004
	var d1 = Date.parse("2004.10.15");

	//Fri Oct 15, 2004
	var d1 = Date.parse("Fri Oct 15, 2004");

	///////////
	// Times //
	///////////

	// Today at 10 PM.
	var d1 = Date.parse("10 PM");

	// Today at 10:30 PM.
	var d1 = Date.parse("10:30 P.M.");

	// Today at 6 AM.
	var d1 = Date.parse("06am");

	/////////////////////
	// Dates and Times //
	/////////////////////

	// 8-July-2004 @ 10:30 PM
	var d1 = Date.parse("July 8th, 2004, 10:30 PM");

	// 1-July-2004 @ 10:30 PM
	var d1 = Date.parse("2004-07-01T22:30:00");

	////////////////////
	// Relative Dates //
	////////////////////

	// Returns today's date. The string "today" is culture specific.
	var d1 = Date.parse("today");

	// Returns yesterday's date. The string "yesterday" is culture specific.
	var d1 = Date.parse("yesterday");

	// Returns the date of the next thursday.
	var d1 = Date.parse("Next thursday");

	// Returns the date of the most previous monday.
	var d1 = Date.parse("last monday");

	// Returns today's day + one year.
	var d1 = Date.parse("next year");

	///////////////
	// Date Math //
	///////////////

	// Today + 2 days
	var d1 = Date.parse("t+2");

	// Today + 2 days
	var d1 = Date.parse("today + 2 days");

	// Today + 3 months
	var d1 = Date.parse("t+3m");

	// Today - 1 year
	var d1 = Date.parse("today - 1 year");

	// Today - 1 year
	var d1 = Date.parse("t-1y"); 


	/////////////////////////////
	// Partial Dates and Times //
	/////////////////////////////

	// July 15th of this year.
	var d1 = Date.parse("July 15");

	// 15th day of current day and year.
	var d1 = Date.parse("15");

	// July 1st of current year at 10pm.
	var d1 = Date.parse("7/1 10pm");
	
* * @param {String} The string value to convert into a Date object [Required] * @return {Date} A Date object or null if the string cannot be converted into a Date. */ var parseUtils = { removeOrds: function (s) { ords = s.match(/\b(\d+)(?:st|nd|rd|th)\b/); // find ordinal matches s = ((ords && ords.length === 2) ? s.replace(ords[0], ords[1]) : s); return s; }, grammarParser: function (s) { var r = null; try { r = $D.Grammar.start.call({}, s.replace(/^\s*(\S*(\s+\S+)*)\s*$/, "$1")); } catch (e) { return null; } return ((r[1].length === 0) ? r[0] : null); }, nativeFallback: function(s) { var t; try { // ok we haven't parsed it, last ditch attempt with the built-in parser. t = Date._parse(s); return (t || t === 0) ? new Date(t) : null; } catch (e) { return null; } } }; function parse (s) { var d; if (!s) { return null; } if (s instanceof Date) { return s.clone(); } if (s.length >= 4 && s.charAt(0) !== "0" && s.charAt(0) !== "+"&& s.charAt(0) !== "-") { // ie: 2004 will pass, 0800 won't. // Start with specific formats d = $D.Parsing.ISO.parse(s) || $D.Parsing.Numeric.parse(s); } if (d instanceof Date && !isNaN(d.getTime())) { return d; } else { // find ordinal dates (1st, 3rd, 8th, etc and remove them as they cause parsing issues) s = $D.Parsing.Normalizer.parse(parseUtils.removeOrds(s)); d = parseUtils.grammarParser(s); if (d !== null) { return d; } else { return parseUtils.nativeFallback(s); } } } if (!$D._parse) { $D._parse = $D.parse; } $D.parse = parse; Date.getParseFunction = function (fx) { var fns = Date.Grammar.allformats(fx); return function (s) { var r = null; for (var i = 0; i < fns.length; i++) { try { r = fns[i].call({}, s); } catch (e) { continue; } if (r[1].length === 0) { return r[0]; } } return null; }; }; /** * Converts the specified string value into its JavaScript Date equivalent using the specified format {String} or formats {Array} and the CultureInfo specific format information. * The format of the string value must match one of the supplied formats exactly. * * Example

	// 15-Oct-2004
	var d1 = Date.parseExact("10/15/2004", "M/d/yyyy");

	// 15-Oct-2004
	var d1 = Date.parse("15-Oct-2004", "M-ddd-yyyy");

	// 15-Oct-2004
	var d1 = Date.parse("2004.10.15", "yyyy.MM.dd");

	// Multiple formats
	var d1 = Date.parseExact("10/15/2004", ["M/d/yyyy", "MMMM d, yyyy"]);
	
* * @param {String} The string value to convert into a Date object [Required]. * @param {Object} The expected format {String} or an array of expected formats {Array} of the date string [Required]. * @return {Date} A Date object or null if the string cannot be converted into a Date. */ $D.parseExact = function (s, fx) { return $D.getParseFunction(fx)(s); }; }()); (function () { var $D = Date, $P = $D.prototype, // $C = $D.CultureInfo, // not used atm p = function (s, l) { if (!l) { l = 2; } return ("000" + s).slice(l * -1); }; /** * Converts a PHP format string to Java/.NET format string. * A PHP format string can be used with ._format or .format. * A Java/.NET format string can be used with .toString(). * The .parseExact function will only accept a Java/.NET format string * * Example * var f1 = "%m/%d/%y" * var f2 = Date.normalizeFormat(f1); // "MM/dd/yy" * * new Date().format(f1); // "04/13/08" * new Date()._format(f1); // "04/13/08" * new Date().toString(f2); // "04/13/08" * * var date = Date.parseExact("04/13/08", f2); // Sun Apr 13 2008 * * @param {String} A PHP format string consisting of one or more format spcifiers. * @return {String} The PHP format converted to a Java/.NET format string. */ var normalizerSubstitutions = { "d" : "dd", "%d": "dd", "D" : "ddd", "%a": "ddd", "j" : "dddd", "l" : "dddd", "%A": "dddd", "S" : "S", "F" : "MMMM", "%B": "MMMM", "m" : "MM", "%m": "MM", "M" : "MMM", "%b": "MMM", "%h": "MMM", "n" : "M", "Y" : "yyyy", "%Y": "yyyy", "y" : "yy", "%y": "yy", "g" : "h", "%I": "h", "G" : "H", "h" : "hh", "H" : "HH", "%H": "HH", "i" : "mm", "%M": "mm", "s" : "ss", "%S": "ss", "%r": "hh:mm tt", "%R": "H:mm", "%T": "H:mm:ss", "%X": "t", "%x": "d", "%e": "d", "%D": "MM/dd/yy", "%n": "\\n", "%t": "\\t", "e" : "z", "T" : "z", "%z": "z", "%Z": "z", "Z" : "ZZ", "N" : "u", "w" : "u", "%w": "u", "W" : "W", "%V": "W" }; var normalizer = { substitutes: function (m) { return normalizerSubstitutions[m]; }, interpreted: function (m, x) { var y; switch (m) { case "%u": return x.getDay() + 1; case "z": return x.getOrdinalNumber(); case "%j": return p(x.getOrdinalNumber(), 3); case "%U": var d1 = x.clone().set({month: 0, day: 1}).addDays(-1).moveToDayOfWeek(0), d2 = x.clone().addDays(1).moveToDayOfWeek(0, -1); return (d2 < d1) ? "00" : p((d2.getOrdinalNumber() - d1.getOrdinalNumber()) / 7 + 1); case "%W": return p(x.getWeek()); case "t": return $D.getDaysInMonth(x.getFullYear(), x.getMonth()); case "o": case "%G": return x.setWeek(x.getISOWeek()).toString("yyyy"); case "%g": return x._format("%G").slice(-2); case "a": case "%p": return t("tt").toLowerCase(); case "A": return t("tt").toUpperCase(); case "u": return p(x.getMilliseconds(), 3); case "I": return (x.isDaylightSavingTime()) ? 1 : 0; case "O": return x.getUTCOffset(); case "P": y = x.getUTCOffset(); return y.substring(0, y.length - 2) + ":" + y.substring(y.length - 2); case "B": var now = new Date(); return Math.floor(((now.getHours() * 3600) + (now.getMinutes() * 60) + now.getSeconds() + (now.getTimezoneOffset() + 60) * 60) / 86.4); case "c": return x.toISOString().replace(/\"/g, ""); case "U": return $D.strtotime("now"); case "%c": return t("d") + " " + t("t"); case "%C": return Math.floor(x.getFullYear() / 100 + 1); } }, shouldOverrideDefaults: function (m) { switch (m) { case "%e": return true; default: return false; } }, parse: function (m, context) { var formatString, c = context || new Date(); formatString = normalizer.substitutes(m); if (formatString) { return formatString; } formatString = normalizer.interpreted(m, c); if (formatString) { return formatString; } else { return m; } } }; $D.normalizeFormat = function (format, context) { return format.replace(/(%|\\)?.|%%/g, function(t){ return normalizer.parse(t, context); }); }; /** * Format a local Unix timestamp according to locale settings * * Example: * Date.strftime("%m/%d/%y", new Date()); // "04/13/08" * Date.strftime("c", "2008-04-13T17:52:03Z"); // "04/13/08" * * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @param {Number|String} The number representing the number of seconds that have elapsed since January 1, 1970 (local time). * @return {String} A string representation of the current Date object. */ $D.strftime = function (format, time) { var d = Date.parse(time); return d._format(format); }; /** * Parse any textual datetime description into a Unix timestamp. * A Unix timestamp is the number of seconds that have elapsed since January 1, 1970 (midnight UTC/GMT). * * Example: * Date.strtotime("04/13/08"); // 1208044800 * Date.strtotime("1970-01-01T00:00:00Z"); // 0 * * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @param {Object} A string or date object. * @return {String} A string representation of the current Date object. */ $D.strtotime = function (time) { var d = $D.parse(time); return Math.round($D.UTC(d.getUTCFullYear(), d.getUTCMonth(), d.getUTCDate(), d.getUTCHours(), d.getUTCMinutes(), d.getUTCSeconds(), d.getUTCMilliseconds()) / 1000); }; /** * Converts the value of the current Date object to its equivalent string representation using a PHP/Unix style of date format specifiers. * Format Specifiers * Format Description Example * ------ --------------------------------------------------------------------------- ----------------------- * %a abbreviated weekday name according to the current localed "Mon" through "Sun" * %A full weekday name according to the current localed "Sunday" through "Saturday" * %b abbreviated month name according to the current localed "Jan" through "Dec" * %B full month name according to the current locale "January" through "December" * %c preferred date and time representation for the current locale "4/13/2008 12:33 PM" * %C century number (the year divided by 100 and truncated to an integer) "00" to "99" * %d day of the month as a decimal number "01" to "31" * %D same as %m/%d/%y "04/13/08" * %e day of the month as a decimal number, a single digit is preceded by a space "1" to "31" * %g like %G, but without the century "08" * %G The 4-digit year corresponding to the ISO week number (see %V). "2008" * This has the same format and value as %Y, except that if the ISO week number * belongs to the previous or next year, that year is used instead. * %h same as %b "Jan" through "Dec" * %H hour as a decimal number using a 24-hour clock. "00" to "23" * %I hour as a decimal number using a 12-hour clock. "01" to "12" * %j day of the year as a decimal number. "001" to "366" * %m month as a decimal number. "01" to "12" * %M minute as a decimal number. "00" to "59" * %n newline character "\n" * %p either "am" or "pm" according to the given time value, or the "am" or "pm" * corresponding strings for the current locale. * %r time in a.m. and p.m. notation "8:44 PM" * %R time in 24 hour notation "20:44" * %S second as a decimal number "00" to "59" * %t tab character "\t" * %T current time, equal to %H:%M:%S "12:49:11" * %u weekday as a decimal number ["1", "7"], with "1" representing Monday "1" to "7" * %U week number of the current year as a decimal number, starting with the "0" to ("52" or "53") * first Sunday as the first day of the first week * %V The ISO 8601:1988 week number of the current year as a decimal number, "00" to ("52" or "53") * range 01 to 53, where week 1 is the first week that has at least 4 days * in the current year, and with Monday as the first day of the week. * (Use %G or %g for the year component that corresponds to the week number * for the specified timestamp.) * %W week number of the current year as a decimal number, starting with the "00" to ("52" or "53") * first Monday as the first day of the first week * %w day of the week as a decimal, Sunday being "0" "0" to "6" * %x preferred date representation for the current locale without the time "4/13/2008" * %X preferred time representation for the current locale without the date "12:53:05" * %y year as a decimal number without a century "00" "99" * %Y year as a decimal number including the century "2008" * %Z time zone or name or abbreviation "UTC", "EST", "PST" * %z same as %Z * %% a literal "%" characters "%" * d Day of the month, 2 digits with leading zeros "01" to "31" * D A textual representation of a day, three letters "Mon" through "Sun" * j Day of the month without leading zeros "1" to "31" * l A full textual representation of the day of the week (lowercase "L") "Sunday" through "Saturday" * N ISO-8601 numeric representation of the day of the week (added in PHP 5.1.0) "1" (for Monday) through "7" (for Sunday) * S English ordinal suffix for the day of the month, 2 characters "st", "nd", "rd" or "th". Works well with j * w Numeric representation of the day of the week "0" (for Sunday) through "6" (for Saturday) * z The day of the year (starting from "0") "0" through "365" * W ISO-8601 week number of year, weeks starting on Monday "00" to ("52" or "53") * F A full textual representation of a month, such as January or March "January" through "December" * m Numeric representation of a month, with leading zeros "01" through "12" * M A short textual representation of a month, three letters "Jan" through "Dec" * n Numeric representation of a month, without leading zeros "1" through "12" * t Number of days in the given month "28" through "31" * L Whether it's a leap year "1" if it is a leap year, "0" otherwise * o ISO-8601 year number. This has the same value as Y, except that if the "2008" * ISO week number (W) belongs to the previous or next year, that year * is used instead. * Y A full numeric representation of a year, 4 digits "2008" * y A two digit representation of a year "08" * a Lowercase Ante meridiem and Post meridiem "am" or "pm" * A Uppercase Ante meridiem and Post meridiem "AM" or "PM" * B Swatch Internet time "000" through "999" * g 12-hour format of an hour without leading zeros "1" through "12" * G 24-hour format of an hour without leading zeros "0" through "23" * h 12-hour format of an hour with leading zeros "01" through "12" * H 24-hour format of an hour with leading zeros "00" through "23" * i Minutes with leading zeros "00" to "59" * s Seconds, with leading zeros "00" through "59" * u Milliseconds "54321" * e Timezone identifier "UTC", "EST", "PST" * I Whether or not the date is in daylight saving time (uppercase i) "1" if Daylight Saving Time, "0" otherwise * O Difference to Greenwich time (GMT) in hours "+0200", "-0600" * P Difference to Greenwich time (GMT) with colon between hours and minutes "+02:00", "-06:00" * T Timezone abbreviation "UTC", "EST", "PST" * Z Timezone offset in seconds. The offset for timezones west of UTC is "-43200" through "50400" * always negative, and for those east of UTC is always positive. * c ISO 8601 date "2004-02-12T15:19:21+00:00" * r RFC 2822 formatted date "Thu, 21 Dec 2000 16:01:07 +0200" * U Seconds since the Unix Epoch (January 1 1970 00:00:00 GMT) "0" * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @return {String} A string representation of the current Date object. */ var formatReplace = function (context) { return function (m) { var formatString, override = false; if (m.charAt(0) === "\\" || m.substring(0, 2) === "%%") { return m.replace("\\", "").replace("%%", "%"); } override = normalizer.shouldOverrideDefaults(m); formatString = $D.normalizeFormat(m, context); if (formatString) { return context.toString(formatString, override); } }; }; $P._format = function (format) { var formatter = formatReplace(this); if (!format) { return this._toString(); } else { return format.replace(/(%|\\)?.|%%/g, formatter); } }; if (!$P.format) { $P.format = $P._format; } }()); (function () { "use strict"; var gFn = function (attr) { return function () { return this[attr]; }; }; var sFn = function (attr) { return function (val) { this[attr] = val; return this; }; }; var attrs = ["years", "months", "days", "hours", "minutes", "seconds", "milliseconds"]; var addSetFuncs = function (context, attrs) { for (var i = 0; i < attrs.length ; i++) { var $a = attrs[i], $b = $a.slice(0, 1).toUpperCase() + $a.slice(1); context.prototype[$a] = 0; context.prototype["get" + $b] = gFn($a); context.prototype["set" + $b] = sFn($a); } }; /** * new TimeSpan(milliseconds); * new TimeSpan(days, hours, minutes, seconds); * new TimeSpan(days, hours, minutes, seconds, milliseconds); */ var TimeSpan = function (days, hours, minutes, seconds, milliseconds) { if (arguments.length === 1 && typeof days === "number") { var orient = (days < 0) ? -1 : +1; var millsLeft = Math.abs(days); this.setDays(Math.floor(millsLeft / 86400000) * orient); millsLeft = millsLeft % 86400000; this.setHours(Math.floor(millsLeft / 3600000) * orient); millsLeft = millsLeft % 3600000; this.setMinutes(Math.floor(millsLeft / 60000) * orient); millsLeft = millsLeft % 60000; this.setSeconds(Math.floor(millsLeft / 1000) * orient); millsLeft = millsLeft % 1000; this.setMilliseconds(millsLeft * orient); } else { this.set(days, hours, minutes, seconds, milliseconds); } this.getTotalMilliseconds = function () { return (this.getDays() * 86400000) + (this.getHours() * 3600000) + (this.getMinutes() * 60000) + (this.getSeconds() * 1000); }; this.compareTo = function (time) { var t1 = new Date(1970, 1, 1, this.getHours(), this.getMinutes(), this.getSeconds()), t2; if (time === null) { t2 = new Date(1970, 1, 1, 0, 0, 0); } else { t2 = new Date(1970, 1, 1, time.getHours(), time.getMinutes(), time.getSeconds()); } return (t1 < t2) ? -1 : (t1 > t2) ? 1 : 0; }; this.equals = function (time) { return (this.compareTo(time) === 0); }; this.add = function (time) { return (time === null) ? this : this.addSeconds(time.getTotalMilliseconds() / 1000); }; this.subtract = function (time) { return (time === null) ? this : this.addSeconds(-time.getTotalMilliseconds() / 1000); }; this.addDays = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 86400000)); }; this.addHours = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 3600000)); }; this.addMinutes = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 60000)); }; this.addSeconds = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 1000)); }; this.addMilliseconds = function (n) { return new TimeSpan(this.getTotalMilliseconds() + n); }; this.get12HourHour = function () { return (this.getHours() > 12) ? this.getHours() - 12 : (this.getHours() === 0) ? 12 : this.getHours(); }; this.getDesignator = function () { return (this.getHours() < 12) ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator; }; this.toString = function (format) { this._toString = function () { if (this.getDays() !== null && this.getDays() > 0) { return this.getDays() + "." + this.getHours() + ":" + this.p(this.getMinutes()) + ":" + this.p(this.getSeconds()); } else { return this.getHours() + ":" + this.p(this.getMinutes()) + ":" + this.p(this.getSeconds()); } }; this.p = function (s) { return (s.toString().length < 2) ? "0" + s : s; }; var me = this; return format ? format.replace(/dd?|HH?|hh?|mm?|ss?|tt?/g, function (format) { switch (format) { case "d": return me.getDays(); case "dd": return me.p(me.getDays()); case "H": return me.getHours(); case "HH": return me.p(me.getHours()); case "h": return me.get12HourHour(); case "hh": return me.p(me.get12HourHour()); case "m": return me.getMinutes(); case "mm": return me.p(me.getMinutes()); case "s": return me.getSeconds(); case "ss": return me.p(me.getSeconds()); case "t": return ((me.getHours() < 12) ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator).substring(0, 1); case "tt": return (me.getHours() < 12) ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator; } } ) : this._toString(); }; return this; }; addSetFuncs(TimeSpan, attrs.slice(2)); TimeSpan.prototype.set = function (days, hours, minutes, seconds, milliseconds){ this.setDays(days || this.getDays()); this.setHours(hours || this.getHours()); this.setMinutes(minutes || this.getMinutes()); this.setSeconds(seconds || this.getSeconds()); this.setMilliseconds(milliseconds || this.getMilliseconds()); }; /** * Gets the time of day for this date instances. * @return {TimeSpan} TimeSpan */ Date.prototype.getTimeOfDay = function () { return new TimeSpan(0, this.getHours(), this.getMinutes(), this.getSeconds(), this.getMilliseconds()); }; Date.TimeSpan = TimeSpan; if (typeof window !== "undefined" ) { // keeping API compatible for v1.x window.TimeSpan = TimeSpan; } }()); (function () { "use strict"; var attrs = ["years", "months", "days", "hours", "minutes", "seconds", "milliseconds"]; var gFn = function (attr) { return function () { return this[attr]; }; }; var sFn = function (attr) { return function (val) { this[attr] = val; return this; }; }; var addSetFuncs = function (context, attrs) { for (var i = 0; i < attrs.length ; i++) { var $a = attrs[i], $b = $a.slice(0, 1).toUpperCase() + $a.slice(1); context.prototype[$a] = 0; context.prototype["get" + $b] = gFn($a); context.prototype["set" + $b] = sFn($a); } }; var setMonthsAndYears = function (orient, d1, d2, context) { function inc() { d1.addMonths(-orient); context.months++; if (context.months === 12) { context.years++; context.months = 0; } } if (orient === +1) { while (d1 > d2) { inc(); } } else { while (d1 < d2) { inc(); } } context.months--; context.months *= orient; context.years *= orient; }; var adjustForDST = function(orient, startDate, endDate) { var hasDSTMismatch = (false === (startDate.isDaylightSavingTime() === endDate.isDaylightSavingTime())); if (hasDSTMismatch && orient === 1) { startDate.addHours(-1); } else if (hasDSTMismatch) { startDate.addHours(1); } }; /** * TimePeriod(startDate, endDate); * TimePeriod(years, months, days, hours, minutes, seconds, milliseconds); */ var TimePeriod = function (years, months, days, hours, minutes, seconds, milliseconds) { if (arguments.length === 7) { this.set(years, months, days, hours, minutes, seconds, milliseconds); } else if (arguments.length === 2 && arguments[0] instanceof Date && arguments[1] instanceof Date) { var startDate = arguments[0].clone(); var endDate = arguments[1].clone(); var orient = (startDate > endDate) ? +1 : -1; this.dates = { start: arguments[0].clone(), end: arguments[1].clone() }; setMonthsAndYears(orient, startDate, endDate, this); adjustForDST(orient, startDate, endDate); // // TODO - adjust for DST var diff = endDate - startDate; if (diff !== 0) { var ts = new TimeSpan(diff); this.set(this.years, this.months, ts.getDays(), ts.getHours(), ts.getMinutes(), ts.getSeconds(), ts.getMilliseconds()); } } return this; }; // create all the set functions. addSetFuncs(TimePeriod, attrs); TimePeriod.prototype.set = function (years, months, days, hours, minutes, seconds, milliseconds){ this.setYears(years || this.getYears()); this.setMonths(months || this.getMonths()); this.setDays(days || this.getDays()); this.setHours(hours || this.getHours()); this.setMinutes(minutes || this.getMinutes()); this.setSeconds(seconds || this.getSeconds()); this.setMilliseconds(milliseconds || this.getMilliseconds()); }; Date.TimePeriod = TimePeriod; if (typeof window !== "undefined") { // keeping API compatible for v1.x window.TimePeriod = TimePeriod; } }()); ================================================ FILE: build/date-ar-SA.js ================================================ /** * @overview datejs * @version 1.0.0-rc3 * @author Gregory Wild-Smith * @copyright 2015 Gregory Wild-Smith * @license MIT * @homepage https://github.com/abritinthebay/datejs */ /* * DateJS Culture String File * Country Code: ar-SA * Name: Arabic (Saudi Arabia) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["ar-SA"] = { "name": "ar-SA", "englishName": "Arabic (Saudi Arabia)", "nativeName": "العربية (المملكة العربية السعودية)", "Sunday": "الاحد", "Monday": "الاثنين", "Tuesday": "الثلاثاء", "Wednesday": "الاربعاء", "Thursday": "الخميس", "Friday": "الجمعة", "Saturday": "السبت", "Sun": "الاحد", "Mon": "الاثنين", "Tue": "الثلاثاء", "Wed": "الاربعاء", "Thu": "الخميس", "Fri": "الجمعة", "Sat": "السبت", "Su": "ح", "Mo": "ن", "Tu": "ث", "We": "ر", "Th": "خ", "Fr": "ج", "Sa": "س", "S_Sun_Initial": "ح", "M_Mon_Initial": "ن", "T_Tue_Initial": "ث", "W_Wed_Initial": "ر", "T_Thu_Initial": "خ", "F_Fri_Initial": "ج", "S_Sat_Initial": "س", "January": "محرم", "February": "صفر", "March": "ربيع الأول", "April": "ربيع الثاني", "May": "جمادى الأولى", "June": "جمادى الثانية", "July": "رجب", "August": "شعبان", "September": "رمضان", "October": "شوال", "November": "ذو القعدة", "December": "ذو الحجة", "Jan_Abbr": "محرم", "Feb_Abbr": "صفر", "Mar_Abbr": "ربيع الاول", "Apr_Abbr": "ربيع الثاني", "May_Abbr": "جمادى الاولى", "Jun_Abbr": "جمادى الثانية", "Jul_Abbr": "رجب", "Aug_Abbr": "شعبان", "Sep_Abbr": "رمضان", "Oct_Abbr": "شوال", "Nov_Abbr": "ذو القعدة", "Dec_Abbr": "ذو الحجة", "AM": "ص", "PM": "م", "firstDayOfWeek": 6, "twoDigitYearMax": 1451, "mdy": "dmy", "M/d/yyyy": "dd/MM/yy", "dddd, MMMM dd, yyyy": "dd/MMMM/yyyy", "h:mm tt": "hh:mm tt", "h:mm:ss tt": "hh:mm:ss tt", "dddd, MMMM dd, yyyy h:mm:ss tt": "dd/MMMM/yyyy hh:mm:ss tt", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "dd MMMM", "MMMM, yyyy": "MMMM, yyyy", "/jan(uary)?/": "محرم", "/feb(ruary)?/": "صفر", "/mar(ch)?/": "ربيع الأول", "/apr(il)?/": "ربيع الثاني", "/may/": "جمادى الأولى", "/jun(e)?/": "جمادى الثانية", "/jul(y)?/": "رجب", "/aug(ust)?/": "شعبان", "/sep(t(ember)?)?/": "رمضان", "/oct(ober)?/": "شوال", "/nov(ember)?/": "ذو القعدة", "/dec(ember)?/": "ذو الحجة", "/^su(n(day)?)?/": "^الاحد", "/^mo(n(day)?)?/": "^الاثنين", "/^tu(e(s(day)?)?)?/": "^الثلاثاء", "/^we(d(nesday)?)?/": "^الاربعاء", "/^th(u(r(s(day)?)?)?)?/": "^الخميس", "/^fr(i(day)?)?/": "^الجمعة", "/^sa(t(urday)?)?/": "^السبت", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "ar-SA"; /** * @overview datejs * @version 1.0.0-rc3 * @author Gregory Wild-Smith * @copyright 2015 Gregory Wild-Smith * @license MIT * @homepage https://github.com/abritinthebay/datejs */(function () { var $D = Date; var lang = Date.CultureStrings ? Date.CultureStrings.lang : null; var loggedKeys = {}; // for debug purposes. var getText = { getFromKey: function (key, countryCode) { var output; if (Date.CultureStrings && Date.CultureStrings[countryCode] && Date.CultureStrings[countryCode][key]) { output = Date.CultureStrings[countryCode][key]; } else { output = getText.buildFromDefault(key); } if (key.charAt(0) === "/") { // Assume it's a regex output = getText.buildFromRegex(key, countryCode); } return output; }, getFromObjectValues: function (obj, countryCode) { var key, output = {}; for(key in obj) { if (obj.hasOwnProperty(key)) { output[key] = getText.getFromKey(obj[key], countryCode); } } return output; }, getFromObjectKeys: function (obj, countryCode) { var key, output = {}; for(key in obj) { if (obj.hasOwnProperty(key)) { output[getText.getFromKey(key, countryCode)] = obj[key]; } } return output; }, getFromArray: function (arr, countryCode) { var output = []; for (var i=0; i < arr.length; i++){ if (i in arr) { output[i] = getText.getFromKey(arr[i], countryCode); } } return output; }, buildFromDefault: function (key) { var output, length, split, last; switch(key) { case "name": output = "en-US"; break; case "englishName": output = "English (United States)"; break; case "nativeName": output = "English (United States)"; break; case "twoDigitYearMax": output = 2049; break; case "firstDayOfWeek": output = 0; break; default: output = key; split = key.split("_"); length = split.length; if (length > 1 && key.charAt(0) !== "/") { // if the key isn't a regex and it has a split. last = split[(length - 1)].toLowerCase(); if (last === "initial" || last === "abbr") { output = split[0]; } } break; } return output; }, buildFromRegex: function (key, countryCode) { var output; if (Date.CultureStrings && Date.CultureStrings[countryCode] && Date.CultureStrings[countryCode][key]) { output = new RegExp(Date.CultureStrings[countryCode][key], "i"); } else { output = new RegExp(key.replace(new RegExp("/", "g"),""), "i"); } return output; } }; var shallowMerge = function (obj1, obj2) { for (var attrname in obj2) { if (obj2.hasOwnProperty(attrname)) { obj1[attrname] = obj2[attrname]; } } }; var __ = function (key, language) { var countryCode = (language) ? language : lang; loggedKeys[key] = key; if (typeof key === "object") { if (key instanceof Array) { return getText.getFromArray(key, countryCode); } else { return getText.getFromObjectKeys(key, countryCode); } } else { return getText.getFromKey(key, countryCode); } }; var loadI18nScript = function (code) { // paatterned after jQuery's getScript. var url = Date.Config.i18n + code + ".js"; var head = document.getElementsByTagName("head")[0] || document.documentElement; var script = document.createElement("script"); script.src = url; var completed = false; var events = { done: function (){} // placeholder function }; // Attach handlers for all browsers script.onload = script.onreadystatechange = function() { if ( !completed && (!this.readyState || this.readyState === "loaded" || this.readyState === "complete") ) { events.done(); head.removeChild(script); } }; setTimeout(function() { head.insertBefore(script, head.firstChild); }, 0); // allows return to execute first return { done: function (cb) { events.done = function() { if (cb) { setTimeout(cb,0); } }; } }; }; var buildInfo = { buildFromMethodHash: function (obj) { var key; for(key in obj) { if (obj.hasOwnProperty(key)) { obj[key] = buildInfo[obj[key]](); } } return obj; }, timeZoneDST: function () { var DST = { "CHADT": "+1345", "NZDT": "+1300", "AEDT": "+1100", "ACDT": "+1030", "AZST": "+0500", "IRDT": "+0430", "EEST": "+0300", "CEST": "+0200", "BST": "+0100", "PMDT": "-0200", "ADT": "-0300", "NDT": "-0230", "EDT": "-0400", "CDT": "-0500", "MDT": "-0600", "PDT": "-0700", "AKDT": "-0800", "HADT": "-0900" }; return __(DST); }, timeZoneStandard: function () { var standard = { "LINT": "+1400", "TOT": "+1300", "CHAST": "+1245", "NZST": "+1200", "NFT": "+1130", "SBT": "+1100", "AEST": "+1000", "ACST": "+0930", "JST": "+0900", "CWST": "+0845", "CT": "+0800", "ICT": "+0700", "MMT": "+0630", "BST": "+0600", "NPT": "+0545", "IST": "+0530", "PKT": "+0500", "AFT": "+0430", "MSK": "+0400", "IRST": "+0330", "FET": "+0300", "EET": "+0200", "CET": "+0100", "GMT": "+0000", "UTC": "+0000", "CVT": "-0100", "GST": "-0200", "BRT": "-0300", "NST": "-0330", "AST": "-0400", "EST": "-0500", "CST": "-0600", "MST": "-0700", "PST": "-0800", "AKST": "-0900", "MIT": "-0930", "HST": "-1000", "SST": "-1100", "BIT": "-1200" }; return __(standard); }, timeZones: function (data) { var zone; data.timezones = []; for (zone in data.abbreviatedTimeZoneStandard) { if (data.abbreviatedTimeZoneStandard.hasOwnProperty(zone)) { data.timezones.push({ name: zone, offset: data.abbreviatedTimeZoneStandard[zone]}); } } for (zone in data.abbreviatedTimeZoneDST) { if (data.abbreviatedTimeZoneDST.hasOwnProperty(zone)) { data.timezones.push({ name: zone, offset: data.abbreviatedTimeZoneDST[zone], dst: true}); } } return data.timezones; }, days: function () { return __(["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"]); }, dayAbbr: function () { return __(["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"]); }, dayShortNames: function () { return __(["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"]); }, dayFirstLetters: function () { return __(["S_Sun_Initial", "M_Mon_Initial", "T_Tues_Initial", "W_Wed_Initial", "T_Thu_Initial", "F_Fri_Initial", "S_Sat_Initial"]); }, months: function () { return __(["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"]); }, monthAbbr: function () { return __(["Jan_Abbr", "Feb_Abbr", "Mar_Abbr", "Apr_Abbr", "May_Abbr", "Jun_Abbr", "Jul_Abbr", "Aug_Abbr", "Sep_Abbr", "Oct_Abbr", "Nov_Abbr", "Dec_Abbr"]); }, formatPatterns: function () { return getText.getFromObjectValues({ shortDate: "M/d/yyyy", longDate: "dddd, MMMM dd, yyyy", shortTime: "h:mm tt", longTime: "h:mm:ss tt", fullDateTime: "dddd, MMMM dd, yyyy h:mm:ss tt", sortableDateTime: "yyyy-MM-ddTHH:mm:ss", universalSortableDateTime: "yyyy-MM-dd HH:mm:ssZ", rfc1123: "ddd, dd MMM yyyy HH:mm:ss", monthDay: "MMMM dd", yearMonth: "MMMM, yyyy" }, Date.i18n.currentLanguage()); }, regex: function () { return getText.getFromObjectValues({ inTheMorning: "/( in the )(morn(ing)?)\\b/", thisMorning: "/(this )(morn(ing)?)\\b/", amThisMorning: "/(\b\\d(am)? )(this )(morn(ing)?)/", inTheEvening: "/( in the )(even(ing)?)\\b/", thisEvening: "/(this )(even(ing)?)\\b/", pmThisEvening: "/(\b\\d(pm)? )(this )(even(ing)?)/", jan: "/jan(uary)?/", feb: "/feb(ruary)?/", mar: "/mar(ch)?/", apr: "/apr(il)?/", may: "/may/", jun: "/jun(e)?/", jul: "/jul(y)?/", aug: "/aug(ust)?/", sep: "/sep(t(ember)?)?/", oct: "/oct(ober)?/", nov: "/nov(ember)?/", dec: "/dec(ember)?/", sun: "/^su(n(day)?)?/", mon: "/^mo(n(day)?)?/", tue: "/^tu(e(s(day)?)?)?/", wed: "/^we(d(nesday)?)?/", thu: "/^th(u(r(s(day)?)?)?)?/", fri: "/fr(i(day)?)?/", sat: "/^sa(t(urday)?)?/", future: "/^next/", past: "/^last|past|prev(ious)?/", add: "/^(\\+|aft(er)?|from|hence)/", subtract: "/^(\\-|bef(ore)?|ago)/", yesterday: "/^yes(terday)?/", today: "/^t(od(ay)?)?/", tomorrow: "/^tom(orrow)?/", now: "/^n(ow)?/", millisecond: "/^ms|milli(second)?s?/", second: "/^sec(ond)?s?/", minute: "/^mn|min(ute)?s?/", hour: "/^h(our)?s?/", week: "/^w(eek)?s?/", month: "/^m(onth)?s?/", day: "/^d(ay)?s?/", year: "/^y(ear)?s?/", shortMeridian: "/^(a|p)/", longMeridian: "/^(a\\.?m?\\.?|p\\.?m?\\.?)/", timezone: "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/", ordinalSuffix: "/^\\s*(st|nd|rd|th)/", timeContext: "/^\\s*(\\:|a(?!u|p)|p)/" }, Date.i18n.currentLanguage()); } }; var CultureInfo = function () { var info = getText.getFromObjectValues({ name: "name", englishName: "englishName", nativeName: "nativeName", amDesignator: "AM", pmDesignator: "PM", firstDayOfWeek: "firstDayOfWeek", twoDigitYearMax: "twoDigitYearMax", dateElementOrder: "mdy" }, Date.i18n.currentLanguage()); var constructedInfo = buildInfo.buildFromMethodHash({ dayNames: "days", abbreviatedDayNames: "dayAbbr", shortestDayNames: "dayShortNames", firstLetterDayNames: "dayFirstLetters", monthNames: "months", abbreviatedMonthNames: "monthAbbr", formatPatterns: "formatPatterns", regexPatterns: "regex", abbreviatedTimeZoneDST: "timeZoneDST", abbreviatedTimeZoneStandard: "timeZoneStandard" }); shallowMerge(info, constructedInfo); buildInfo.timeZones(info); return info; }; $D.i18n = { __: function (key, lang) { return __(key, lang); }, currentLanguage: function () { return lang || "en-US"; }, setLanguage: function (code, force, cb) { var async = false; if (force || code === "en-US" || (!!Date.CultureStrings && !!Date.CultureStrings[code])) { lang = code; Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings.lang = code; Date.CultureInfo = new CultureInfo(); } else { if (!(!!Date.CultureStrings && !!Date.CultureStrings[code])) { if (typeof exports !== "undefined" && this.exports !== exports) { // we're in a Node enviroment, load it using require try { require("../i18n/" + code + ".js"); lang = code; Date.CultureStrings.lang = code; Date.CultureInfo = new CultureInfo(); } catch (e) { // var str = "The language for '" + code + "' could not be loaded by Node. It likely does not exist."; throw new Error("The DateJS IETF language tag '" + code + "' could not be loaded by Node. It likely does not exist."); } } else if (Date.Config && Date.Config.i18n) { // we know the location of the files, so lets load them async = true; loadI18nScript(code).done(function(){ lang = code; Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings.lang = code; Date.CultureInfo = new CultureInfo(); $D.Parsing.Normalizer.buildReplaceData(); // because this is async if ($D.Grammar) { $D.Grammar.buildGrammarFormats(); // so we can parse those strings... } if (cb) { setTimeout(cb,0); } }); } else { Date.console.error("The DateJS IETF language tag '" + code + "' is not available and has not been loaded."); return false; } } } $D.Parsing.Normalizer.buildReplaceData(); // rebuild normalizer strings if ($D.Grammar) { $D.Grammar.buildGrammarFormats(); // so we can parse those strings... } if (!async && cb) { setTimeout(cb,0); } }, getLoggedKeys: function () { return loggedKeys; }, updateCultureInfo: function () { Date.CultureInfo = new CultureInfo(); } }; $D.i18n.updateCultureInfo(); // run automatically }()); (function () { var $D = Date, $P = $D.prototype, p = function (s, l) { if (!l) { l = 2; } return ("000" + s).slice(l * -1); }; if (typeof window !== "undefined" && typeof window.console !== "undefined" && typeof window.console.log !== "undefined") { $D.console = console; // used only to raise non-critical errors if available } else { // set mock so we don't give errors. $D.console = { log: function(){}, error: function(){} }; } $D.Config = $D.Config || {}; $D.initOverloads = function() { /** * Overload of Date.now. Allows an alternate call for Date.now where it returns the * current Date as an object rather than just milliseconds since the Unix Epoch. * * Also provides an implementation of now() for browsers (IE<9) that don't have it. * * Backwards compatible so with work with either: * Date.now() [returns ms] * or * Date.now(true) [returns Date] */ if (!$D.now) { $D._now = function now() { return new Date().getTime(); }; } else if (!$D._now) { $D._now = $D.now; } $D.now = function (returnObj) { if (returnObj) { return $D.present(); } else { return $D._now(); } }; if ( !$P.toISOString ) { $P.toISOString = function() { return this.getUTCFullYear() + "-" + p(this.getUTCMonth() + 1) + "-" + p(this.getUTCDate()) + "T" + p(this.getUTCHours()) + ":" + p(this.getUTCMinutes()) + ":" + p(this.getUTCSeconds()) + "." + String( (this.getUTCMilliseconds()/1000).toFixed(3)).slice(2, 5) + "Z"; }; } // private if ( $P._toString === undefined ){ $P._toString = $P.toString; } }; $D.initOverloads(); /** * Gets a date that is set to the current date. The time is set to the start of the day (00:00 or 12:00 AM). * @return {Date} The current date. */ $D.today = function () { return new Date().clearTime(); }; /** * Gets a date that is set to the current date and time (same as new Date, but chainable) * @return {Date} The current date. */ $D.present = function () { return new Date(); }; /** * Compares the first date to the second date and returns an number indication of their relative values. * @param {Date} First Date object to compare [Required]. * @param {Date} Second Date object to compare to [Required]. * @return {Number} -1 = date1 is lessthan date2. 0 = values are equal. 1 = date1 is greaterthan date2. */ $D.compare = function (date1, date2) { if (isNaN(date1) || isNaN(date2)) { throw new Error(date1 + " - " + date2); } else if (date1 instanceof Date && date2 instanceof Date) { return (date1 < date2) ? -1 : (date1 > date2) ? 1 : 0; } else { throw new TypeError(date1 + " - " + date2); } }; /** * Compares the first Date object to the second Date object and returns true if they are equal. * @param {Date} First Date object to compare [Required] * @param {Date} Second Date object to compare to [Required] * @return {Boolean} true if dates are equal. false if they are not equal. */ $D.equals = function (date1, date2) { return (date1.compareTo(date2) === 0); }; /** * Gets the language appropriate day name when given the day number(0-6) * eg - 0 == Sunday * @return {String} The day name */ $D.getDayName = function (n) { return Date.CultureInfo.dayNames[n]; }; /** * Gets the day number (0-6) if given a CultureInfo specific string which is a valid dayName, abbreviatedDayName or shortestDayName (two char). * @param {String} The name of the day (eg. "Monday, "Mon", "tuesday", "tue", "We", "we"). * @return {Number} The day number */ $D.getDayNumberFromName = function (name) { var n = Date.CultureInfo.dayNames, m = Date.CultureInfo.abbreviatedDayNames, o = Date.CultureInfo.shortestDayNames, s = name.toLowerCase(); for (var i = 0; i < n.length; i++) { if (n[i].toLowerCase() === s || m[i].toLowerCase() === s || o[i].toLowerCase() === s) { return i; } } return -1; }; /** * Gets the month number (0-11) if given a Culture Info specific string which is a valid monthName or abbreviatedMonthName. * @param {String} The name of the month (eg. "February, "Feb", "october", "oct"). * @return {Number} The day number */ $D.getMonthNumberFromName = function (name) { var n = Date.CultureInfo.monthNames, m = Date.CultureInfo.abbreviatedMonthNames, s = name.toLowerCase(); for (var i = 0; i < n.length; i++) { if (n[i].toLowerCase() === s || m[i].toLowerCase() === s) { return i; } } return -1; }; /** * Gets the language appropriate month name when given the month number(0-11) * eg - 0 == January * @return {String} The month name */ $D.getMonthName = function (n) { return Date.CultureInfo.monthNames[n]; }; /** * Determines if the current date instance is within a LeapYear. * @param {Number} The year. * @return {Boolean} true if date is within a LeapYear, otherwise false. */ $D.isLeapYear = function (year) { return ((year % 4 === 0 && year % 100 !== 0) || year % 400 === 0); }; /** * Gets the number of days in the month, given a year and month value. Automatically corrects for LeapYear. * @param {Number} The year. * @param {Number} The month (0-11). * @return {Number} The number of days in the month. */ $D.getDaysInMonth = function (year, month) { if (!month && $D.validateMonth(year)) { month = year; year = Date.today().getFullYear(); } return [31, ($D.isLeapYear(year) ? 29 : 28), 31, 30, 31, 30, 31, 31, 30, 31, 30, 31][month]; }; $P.getDaysInMonth = function () { return $D.getDaysInMonth(this.getFullYear(), this.getMonth()); }; $D.getTimezoneAbbreviation = function (offset, dst) { var p, n = (dst || false) ? Date.CultureInfo.abbreviatedTimeZoneDST : Date.CultureInfo.abbreviatedTimeZoneStandard; for (p in n) { if (n.hasOwnProperty(p)) { if (n[p] === offset) { return p; } } } return null; }; $D.getTimezoneOffset = function (name, dst) { var i, a =[], z = Date.CultureInfo.timezones; if (!name) { name = (new Date()).getTimezone();} for (i = 0; i < z.length; i++) { if (z[i].name === name.toUpperCase()) { a.push(i); } } if (!z[a[0]]) { return null; } if (a.length === 1 || !dst) { return z[a[0]].offset; } else { for (i=0; i < a.length; i++) { if (z[a[i]].dst) { return z[a[i]].offset; } } } }; $D.getQuarter = function (d) { d = d || new Date(); // If no date supplied, use today var q = [1,2,3,4]; return q[Math.floor(d.getMonth() / 3)]; // ~~~ is a bitwise op. Faster than Math.floor }; $D.getDaysLeftInQuarter = function (d) { d = d || new Date(); var qEnd = new Date(d); qEnd.setMonth(qEnd.getMonth() + 3 - qEnd.getMonth() % 3, 0); return Math.floor((qEnd - d) / 8.64e7); }; // private var validate = function (n, min, max, name) { name = name ? name : "Object"; if (typeof n === "undefined") { return false; } else if (typeof n !== "number") { throw new TypeError(n + " is not a Number."); } else if (n < min || n > max) { // As failing validation is *not* an exceptional circumstance // lets not throw a RangeError Exception here. // It's semantically correct but it's not sensible. return false; } return true; }; /** * Validates the number is within an acceptable range for milliseconds [0-999]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateMillisecond = function (value) { return validate(value, 0, 999, "millisecond"); }; /** * Validates the number is within an acceptable range for seconds [0-59]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateSecond = function (value) { return validate(value, 0, 59, "second"); }; /** * Validates the number is within an acceptable range for minutes [0-59]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateMinute = function (value) { return validate(value, 0, 59, "minute"); }; /** * Validates the number is within an acceptable range for hours [0-23]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateHour = function (value) { return validate(value, 0, 23, "hour"); }; /** * Validates the number is within an acceptable range for the days in a month [0-MaxDaysInMonth]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateDay = function (value, year, month) { if (year === undefined || year === null || month === undefined || month === null) { return false;} return validate(value, 1, $D.getDaysInMonth(year, month), "day"); }; /** * Validates the number is within an acceptable range for months [0-11]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateWeek = function (value) { return validate(value, 0, 53, "week"); }; /** * Validates the number is within an acceptable range for months [0-11]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateMonth = function (value) { return validate(value, 0, 11, "month"); }; /** * Validates the number is within an acceptable range for years. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateYear = function (value) { /** * Per ECMAScript spec the range of times supported by Date objects is * exactly -100,000,000 days to +100,000,000 days measured relative to * midnight at the beginning of 01 January, 1970 UTC. * This gives a range of 8,640,000,000,000,000 milliseconds to either * side of 01 January, 1970 UTC. * * Earliest possible date: Tue, 20 Apr 271,822 B.C. 00:00:00 UTC * Latest possible date: Sat, 13 Sep 275,760 00:00:00 UTC */ return validate(value, -271822, 275760, "year"); }; $D.validateTimezone = function(value) { var timezones = {"ACDT":1,"ACST":1,"ACT":1,"ADT":1,"AEDT":1,"AEST":1,"AFT":1,"AKDT":1,"AKST":1,"AMST":1,"AMT":1,"ART":1,"AST":1,"AWDT":1,"AWST":1,"AZOST":1,"AZT":1,"BDT":1,"BIOT":1,"BIT":1,"BOT":1,"BRT":1,"BST":1,"BTT":1,"CAT":1,"CCT":1,"CDT":1,"CEDT":1,"CEST":1,"CET":1,"CHADT":1,"CHAST":1,"CHOT":1,"ChST":1,"CHUT":1,"CIST":1,"CIT":1,"CKT":1,"CLST":1,"CLT":1,"COST":1,"COT":1,"CST":1,"CT":1,"CVT":1,"CWST":1,"CXT":1,"DAVT":1,"DDUT":1,"DFT":1,"EASST":1,"EAST":1,"EAT":1,"ECT":1,"EDT":1,"EEDT":1,"EEST":1,"EET":1,"EGST":1,"EGT":1,"EIT":1,"EST":1,"FET":1,"FJT":1,"FKST":1,"FKT":1,"FNT":1,"GALT":1,"GAMT":1,"GET":1,"GFT":1,"GILT":1,"GIT":1,"GMT":1,"GST":1,"GYT":1,"HADT":1,"HAEC":1,"HAST":1,"HKT":1,"HMT":1,"HOVT":1,"HST":1,"ICT":1,"IDT":1,"IOT":1,"IRDT":1,"IRKT":1,"IRST":1,"IST":1,"JST":1,"KGT":1,"KOST":1,"KRAT":1,"KST":1,"LHST":1,"LINT":1,"MAGT":1,"MART":1,"MAWT":1,"MDT":1,"MET":1,"MEST":1,"MHT":1,"MIST":1,"MIT":1,"MMT":1,"MSK":1,"MST":1,"MUT":1,"MVT":1,"MYT":1,"NCT":1,"NDT":1,"NFT":1,"NPT":1,"NST":1,"NT":1,"NUT":1,"NZDT":1,"NZST":1,"OMST":1,"ORAT":1,"PDT":1,"PET":1,"PETT":1,"PGT":1,"PHOT":1,"PHT":1,"PKT":1,"PMDT":1,"PMST":1,"PONT":1,"PST":1,"PYST":1,"PYT":1,"RET":1,"ROTT":1,"SAKT":1,"SAMT":1,"SAST":1,"SBT":1,"SCT":1,"SGT":1,"SLST":1,"SRT":1,"SST":1,"SYOT":1,"TAHT":1,"THA":1,"TFT":1,"TJT":1,"TKT":1,"TLT":1,"TMT":1,"TOT":1,"TVT":1,"UCT":1,"ULAT":1,"UTC":1,"UYST":1,"UYT":1,"UZT":1,"VET":1,"VLAT":1,"VOLT":1,"VOST":1,"VUT":1,"WAKT":1,"WAST":1,"WAT":1,"WEDT":1,"WEST":1,"WET":1,"WST":1,"YAKT":1,"YEKT":1,"Z":1}; return (timezones[value] === 1); }; $D.validateTimezoneOffset= function(value) { // timezones go from +14hrs to -12hrs, the +X hours are negative offsets. return (value > -841 && value < 721); }; }()); (function () { var $D = Date, $P = $D.prototype, p = function (s, l) { if (!l) { l = 2; } return ("000" + s).slice(l * -1); }; var validateConfigObject = function (obj) { var result = {}, self = this, prop, testFunc; testFunc = function (prop, func, value) { if (prop === "day") { var month = (obj.month !== undefined) ? obj.month : self.getMonth(); var year = (obj.year !== undefined) ? obj.year : self.getFullYear(); return $D[func](value, year, month); } else { return $D[func](value); } }; for (prop in obj) { if (Object.prototype.hasOwnProperty.call(obj, prop)) { var func = "validate" + prop.charAt(0).toUpperCase() + prop.slice(1); if ($D[func] && obj[prop] !== null && testFunc(prop, func, obj[prop])) { result[prop] = obj[prop]; } } } return result; }; /** * Resets the time of this Date object to 12:00 AM (00:00), which is the start of the day. * @param {Boolean} .clone() this date instance before clearing Time * @return {Date} this */ $P.clearTime = function () { this.setHours(0); this.setMinutes(0); this.setSeconds(0); this.setMilliseconds(0); return this; }; /** * Resets the time of this Date object to the current time ('now'). * @return {Date} this */ $P.setTimeToNow = function () { var n = new Date(); this.setHours(n.getHours()); this.setMinutes(n.getMinutes()); this.setSeconds(n.getSeconds()); this.setMilliseconds(n.getMilliseconds()); return this; }; /** * Returns a new Date object that is an exact date and time copy of the original instance. * @return {Date} A new Date instance */ $P.clone = function () { return new Date(this.getTime()); }; /** * Compares this instance to a Date object and returns an number indication of their relative values. * @param {Date} Date object to compare [Required] * @return {Number} -1 = this is lessthan date. 0 = values are equal. 1 = this is greaterthan date. */ $P.compareTo = function (date) { return Date.compare(this, date); }; /** * Compares this instance to another Date object and returns true if they are equal. * @param {Date} Date object to compare. If no date to compare, new Date() [now] is used. * @return {Boolean} true if dates are equal. false if they are not equal. */ $P.equals = function (date) { return Date.equals(this, (date !== undefined ? date : new Date())); }; /** * Determines if this instance is between a range of two dates or equal to either the start or end dates. * @param {Date} Start of range [Required] * @param {Date} End of range [Required] * @return {Boolean} true is this is between or equal to the start and end dates, else false */ $P.between = function (start, end) { return this.getTime() >= start.getTime() && this.getTime() <= end.getTime(); }; /** * Determines if this date occurs after the date to compare to. * @param {Date} Date object to compare. If no date to compare, new Date() ("now") is used. * @return {Boolean} true if this date instance is greater than the date to compare to (or "now"), otherwise false. */ $P.isAfter = function (date) { return this.compareTo(date || new Date()) === 1; }; /** * Determines if this date occurs before the date to compare to. * @param {Date} Date object to compare. If no date to compare, new Date() ("now") is used. * @return {Boolean} true if this date instance is less than the date to compare to (or "now"). */ $P.isBefore = function (date) { return (this.compareTo(date || new Date()) === -1); }; /** * Determines if the current Date instance occurs today. * @return {Boolean} true if this date instance is 'today', otherwise false. */ /** * Determines if the current Date instance occurs on the same Date as the supplied 'date'. * If no 'date' to compare to is provided, the current Date instance is compared to 'today'. * @param {date} Date object to compare. If no date to compare, the current Date ("now") is used. * @return {Boolean} true if this Date instance occurs on the same Day as the supplied 'date'. */ $P.isToday = $P.isSameDay = function (date) { return this.clone().clearTime().equals((date || new Date()).clone().clearTime()); }; /** * Adds the specified number of milliseconds to this instance. * @param {Number} The number of milliseconds to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addMilliseconds = function (value) { if (!value) { return this; } this.setTime(this.getTime() + value * 1); return this; }; /** * Adds the specified number of seconds to this instance. * @param {Number} The number of seconds to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addSeconds = function (value) { if (!value) { return this; } return this.addMilliseconds(value * 1000); }; /** * Adds the specified number of seconds to this instance. * @param {Number} The number of seconds to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addMinutes = function (value) { if (!value) { return this; } return this.addMilliseconds(value * 60000); // 60*1000 }; /** * Adds the specified number of hours to this instance. * @param {Number} The number of hours to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addHours = function (value) { if (!value) { return this; } return this.addMilliseconds(value * 3600000); // 60*60*1000 }; /** * Adds the specified number of days to this instance. * @param {Number} The number of days to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addDays = function (value) { if (!value) { return this; } this.setDate(this.getDate() + value * 1); return this; }; /** * Adds the specified number of weekdays (ie - not sat or sun) to this instance. * @param {Number} The number of days to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addWeekdays = function (value) { if (!value) { return this; } var day = this.getDay(); var weeks = (Math.ceil(Math.abs(value)/7)); if (day === 0 || day === 6) { if (value > 0) { this.next().monday(); this.addDays(-1); day = this.getDay(); } } if (value < 0) { while (value < 0) { this.addDays(-1); day = this.getDay(); if (day !== 0 && day !== 6) { value++; } } return this; } else if (value > 5 || (6-day) <= value) { value = value + (weeks * 2); } return this.addDays(value); }; /** * Adds the specified number of weeks to this instance. * @param {Number} The number of weeks to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addWeeks = function (value) { if (!value) { return this; } return this.addDays(value * 7); }; /** * Adds the specified number of months to this instance. * @param {Number} The number of months to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addMonths = function (value) { if (!value) { return this; } var n = this.getDate(); this.setDate(1); this.setMonth(this.getMonth() + value * 1); this.setDate(Math.min(n, $D.getDaysInMonth(this.getFullYear(), this.getMonth()))); return this; }; $P.addQuarters = function (value) { if (!value) { return this; } // note this will take you to the same point in the quarter as you are now. // i.e. - if you are 15 days into the quarter you'll be 15 days into the resulting one. // bonus: this allows adding fractional quarters return this.addMonths(value * 3); }; /** * Adds the specified number of years to this instance. * @param {Number} The number of years to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addYears = function (value) { if (!value) { return this; } return this.addMonths(value * 12); }; /** * Adds (or subtracts) to the value of the years, months, weeks, days, hours, minutes, seconds, milliseconds of the date instance using given configuration object. Positive and Negative values allowed. * Example

	Date.today().add( { days: 1, months: 1 } )

	new Date().add( { years: -1 } )
	
* @param {Object} Configuration object containing attributes (months, days, etc.) * @return {Date} this */ $P.add = function (config) { if (typeof config === "number") { this._orient = config; return this; } var x = config; if (x.day) { // If we should be a different date than today (eg: for 'tomorrow -1d', etc). // Should only effect parsing, not direct usage (eg, Finish and FinishExact) if ((x.day - this.getDate()) !== 0) { this.setDate(x.day); } } if (x.milliseconds) { this.addMilliseconds(x.milliseconds); } if (x.seconds) { this.addSeconds(x.seconds); } if (x.minutes) { this.addMinutes(x.minutes); } if (x.hours) { this.addHours(x.hours); } if (x.weeks) { this.addWeeks(x.weeks); } if (x.months) { this.addMonths(x.months); } if (x.years) { this.addYears(x.years); } if (x.days) { this.addDays(x.days); } return this; }; /** * Get the week number. Week one (1) is the week which contains the first Thursday of the year. Monday is considered the first day of the week. * The .getWeek() function does NOT convert the date to UTC. The local datetime is used. * Please use .getISOWeek() to get the week of the UTC converted date. * @return {Number} 1 to 53 */ $P.getWeek = function (utc) { // Create a copy of this date object var self, target = new Date(this.valueOf()); if (utc) { target.addMinutes(target.getTimezoneOffset()); self = target.clone(); } else { self = this; } // ISO week date weeks start on monday // so correct the day number var dayNr = (self.getDay() + 6) % 7; // ISO 8601 states that week 1 is the week // with the first thursday of that year. // Set the target date to the thursday in the target week target.setDate(target.getDate() - dayNr + 3); // Store the millisecond value of the target date var firstThursday = target.valueOf(); // Set the target to the first thursday of the year // First set the target to january first target.setMonth(0, 1); // Not a thursday? Correct the date to the next thursday if (target.getDay() !== 4) { target.setMonth(0, 1 + ((4 - target.getDay()) + 7) % 7); } // The weeknumber is the number of weeks between the // first thursday of the year and the thursday in the target week return 1 + Math.ceil((firstThursday - target) / 604800000); // 604800000 = 7 * 24 * 3600 * 1000 }; /** * Get the ISO 8601 week number. Week one ("01") is the week which contains the first Thursday of the year. Monday is considered the first day of the week. * The .getISOWeek() function does convert the date to it's UTC value. Please use .getWeek() to get the week of the local date. * @return {String} "01" to "53" */ $P.getISOWeek = function () { return p(this.getWeek(true)); }; /** * Moves the date to Monday of the week set. Week one (1) is the week which contains the first Thursday of the year. * @param {Number} A Number (1 to 53) that represents the week of the year. * @return {Date} this */ $P.setWeek = function (n) { if ((n - this.getWeek()) === 0) { if (this.getDay() !== 1) { return this.moveToDayOfWeek(1, (this.getDay() > 1 ? -1 : 1)); } else { return this; } } else { return this.moveToDayOfWeek(1, (this.getDay() > 1 ? -1 : 1)).addWeeks(n - this.getWeek()); } }; $P.setQuarter = function (qtr) { var month = Math.abs(((qtr-1) * 3) + 1); return this.setMonth(month, 1); }; $P.getQuarter = function () { return Date.getQuarter(this); }; $P.getDaysLeftInQuarter = function () { return Date.getDaysLeftInQuarter(this); }; /** * Moves the date to the next n'th occurrence of the dayOfWeek starting from the beginning of the month. The number (-1) is a magic number and will return the last occurrence of the dayOfWeek in the month. * @param {Number} The dayOfWeek to move to * @param {Number} The n'th occurrence to move to. Use (-1) to return the last occurrence in the month * @return {Date} this */ $P.moveToNthOccurrence = function (dayOfWeek, occurrence) { if (dayOfWeek === "Weekday") { if (occurrence > 0) { this.moveToFirstDayOfMonth(); if (this.is().weekday()) { occurrence -= 1; } } else if (occurrence < 0) { this.moveToLastDayOfMonth(); if (this.is().weekday()) { occurrence += 1; } } else { return this; } return this.addWeekdays(occurrence); } var shift = 0; if (occurrence > 0) { shift = occurrence - 1; } else if (occurrence === -1) { this.moveToLastDayOfMonth(); if (this.getDay() !== dayOfWeek) { this.moveToDayOfWeek(dayOfWeek, -1); } return this; } return this.moveToFirstDayOfMonth().addDays(-1).moveToDayOfWeek(dayOfWeek, +1).addWeeks(shift); }; var moveToN = function (getFunc, addFunc, nVal) { return function (value, orient) { var diff = (value - this[getFunc]() + nVal * (orient || +1)) % nVal; return this[addFunc]((diff === 0) ? diff += nVal * (orient || +1) : diff); }; }; /** * Move to the next or last dayOfWeek based on the orient value. * @param {Number} The dayOfWeek to move to * @param {Number} Forward (+1) or Back (-1). Defaults to +1. [Optional] * @return {Date} this */ $P.moveToDayOfWeek = moveToN("getDay", "addDays", 7); /** * Move to the next or last month based on the orient value. * @param {Number} The month to move to. 0 = January, 11 = December * @param {Number} Forward (+1) or Back (-1). Defaults to +1. [Optional] * @return {Date} this */ $P.moveToMonth = moveToN("getMonth", "addMonths", 12); /** * Get the Ordinate of the current day ("th", "st", "rd"). * @return {String} */ $P.getOrdinate = function () { var num = this.getDate(); return ord(num); }; /** * Get the Ordinal day (numeric day number) of the year, adjusted for leap year. * @return {Number} 1 through 365 (366 in leap years) */ $P.getOrdinalNumber = function () { return Math.ceil((this.clone().clearTime() - new Date(this.getFullYear(), 0, 1)) / 86400000) + 1; }; /** * Get the time zone abbreviation of the current date. * @return {String} The abbreviated time zone name (e.g. "EST") */ $P.getTimezone = function () { return $D.getTimezoneAbbreviation(this.getUTCOffset(), this.isDaylightSavingTime()); }; $P.setTimezoneOffset = function (offset) { var here = this.getTimezoneOffset(), there = Number(offset) * -6 / 10; return (there || there === 0) ? this.addMinutes(there - here) : this; }; $P.setTimezone = function (offset) { return this.setTimezoneOffset($D.getTimezoneOffset(offset)); }; /** * Indicates whether Daylight Saving Time is observed in the current time zone. * @return {Boolean} true|false */ $P.hasDaylightSavingTime = function () { return (Date.today().set({month: 0, day: 1}).getTimezoneOffset() !== Date.today().set({month: 6, day: 1}).getTimezoneOffset()); }; /** * Indicates whether this Date instance is within the Daylight Saving Time range for the current time zone. * @return {Boolean} true|false */ $P.isDaylightSavingTime = function () { return Date.today().set({month: 0, day: 1}).getTimezoneOffset() !== this.getTimezoneOffset(); }; /** * Get the offset from UTC of the current date. * @return {String} The 4-character offset string prefixed with + or - (e.g. "-0500") */ $P.getUTCOffset = function (offset) { var n = (offset || this.getTimezoneOffset()) * -10 / 6, r; if (n < 0) { r = (n - 10000).toString(); return r.charAt(0) + r.substr(2); } else { r = (n + 10000).toString(); return "+" + r.substr(1); } }; /** * Returns the number of milliseconds between this date and date. * @param {Date} Defaults to now * @return {Number} The diff in milliseconds */ $P.getElapsed = function (date) { return (date || new Date()) - this; }; /** * Set the value of year, month, day, hour, minute, second, millisecond of date instance using given configuration object. * Example

	Date.today().set( { day: 20, month: 1 } )

	new Date().set( { millisecond: 0 } )
	
* * @param {Object} Configuration object containing attributes (month, day, etc.) * @return {Date} this */ $P.set = function (config) { config = validateConfigObject.call(this, config); var key; for (key in config) { if (Object.prototype.hasOwnProperty.call(config, key)) { var name = key.charAt(0).toUpperCase() + key.slice(1); var addFunc, getFunc; if (key !== "week" && key !== "month" && key !== "timezone" && key !== "timezoneOffset") { name += "s"; } addFunc = "add" + name; getFunc = "get" + name; if (key === "month") { addFunc = addFunc + "s"; } else if (key === "year"){ getFunc = "getFullYear"; } if (key !== "day" && key !== "timezone" && key !== "timezoneOffset" && key !== "week" && key !== "hour") { this[addFunc](config[key] - this[getFunc]()); } else if ( key === "timezone"|| key === "timezoneOffset" || key === "week" || key === "hour") { this["set"+name](config[key]); } } } // day has to go last because you can't validate the day without first knowing the month if (config.day) { this.addDays(config.day - this.getDate()); } return this; }; /** * Moves the date to the first day of the month. * @return {Date} this */ $P.moveToFirstDayOfMonth = function () { return this.set({ day: 1 }); }; /** * Moves the date to the last day of the month. * @return {Date} this */ $P.moveToLastDayOfMonth = function () { return this.set({ day: $D.getDaysInMonth(this.getFullYear(), this.getMonth())}); }; /** * Converts the value of the current Date object to its equivalent string representation. * Format Specifiers * CUSTOM DATE AND TIME FORMAT STRINGS * Format Description Example * ------ --------------------------------------------------------------------------- ----------------------- * s The seconds of the minute between 0-59. "0" to "59" * ss The seconds of the minute with leading zero if required. "00" to "59" * * m The minute of the hour between 0-59. "0" or "59" * mm The minute of the hour with leading zero if required. "00" or "59" * * h The hour of the day between 1-12. "1" to "12" * hh The hour of the day with leading zero if required. "01" to "12" * * H The hour of the day between 0-23. "0" to "23" * HH The hour of the day with leading zero if required. "00" to "23" * * d The day of the month between 1 and 31. "1" to "31" * dd The day of the month with leading zero if required. "01" to "31" * ddd Abbreviated day name. Date.CultureInfo.abbreviatedDayNames. "Mon" to "Sun" * dddd The full day name. Date.CultureInfo.dayNames. "Monday" to "Sunday" * * M The month of the year between 1-12. "1" to "12" * MM The month of the year with leading zero if required. "01" to "12" * MMM Abbreviated month name. Date.CultureInfo.abbreviatedMonthNames. "Jan" to "Dec" * MMMM The full month name. Date.CultureInfo.monthNames. "January" to "December" * * yy The year as a two-digit number. "99" or "08" * yyyy The full four digit year. "1999" or "2008" * * t Displays the first character of the A.M./P.M. designator. "A" or "P" * Date.CultureInfo.amDesignator or Date.CultureInfo.pmDesignator * tt Displays the A.M./P.M. designator. "AM" or "PM" * Date.CultureInfo.amDesignator or Date.CultureInfo.pmDesignator * * S The ordinal suffix ("st, "nd", "rd" or "th") of the current day. "st, "nd", "rd" or "th" * * STANDARD DATE AND TIME FORMAT STRINGS * Format Description Example *------ --------------------------------------------------------------------------- ----------------------- * d The CultureInfo shortDate Format Pattern "M/d/yyyy" * D The CultureInfo longDate Format Pattern "dddd, MMMM dd, yyyy" * F The CultureInfo fullDateTime Format Pattern "dddd, MMMM dd, yyyy h:mm:ss tt" * m The CultureInfo monthDay Format Pattern "MMMM dd" * r The CultureInfo rfc1123 Format Pattern "ddd, dd MMM yyyy HH:mm:ss GMT" * s The CultureInfo sortableDateTime Format Pattern "yyyy-MM-ddTHH:mm:ss" * t The CultureInfo shortTime Format Pattern "h:mm tt" * T The CultureInfo longTime Format Pattern "h:mm:ss tt" * u The CultureInfo universalSortableDateTime Format Pattern "yyyy-MM-dd HH:mm:ssZ" * y The CultureInfo yearMonth Format Pattern "MMMM, yyyy" * * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @return {String} A string representation of the current Date object. */ var ord = function (n) { switch (n * 1) { case 1: case 21: case 31: return "st"; case 2: case 22: return "nd"; case 3: case 23: return "rd"; default: return "th"; } }; var parseStandardFormats = function (format) { var y, c = Date.CultureInfo.formatPatterns; switch (format) { case "d": return this.toString(c.shortDate); case "D": return this.toString(c.longDate); case "F": return this.toString(c.fullDateTime); case "m": return this.toString(c.monthDay); case "r": case "R": y = this.clone().addMinutes(this.getTimezoneOffset()); return y.toString(c.rfc1123) + " GMT"; case "s": return this.toString(c.sortableDateTime); case "t": return this.toString(c.shortTime); case "T": return this.toString(c.longTime); case "u": y = this.clone().addMinutes(this.getTimezoneOffset()); return y.toString(c.universalSortableDateTime); case "y": return this.toString(c.yearMonth); default: return false; } }; var parseFormatStringsClosure = function (context) { return function (m) { if (m.charAt(0) === "\\") { return m.replace("\\", ""); } switch (m) { case "hh": return p(context.getHours() < 13 ? (context.getHours() === 0 ? 12 : context.getHours()) : (context.getHours() - 12)); case "h": return context.getHours() < 13 ? (context.getHours() === 0 ? 12 : context.getHours()) : (context.getHours() - 12); case "HH": return p(context.getHours()); case "H": return context.getHours(); case "mm": return p(context.getMinutes()); case "m": return context.getMinutes(); case "ss": return p(context.getSeconds()); case "s": return context.getSeconds(); case "yyyy": return p(context.getFullYear(), 4); case "yy": return p(context.getFullYear()); case "y": return context.getFullYear(); case "E": case "dddd": return Date.CultureInfo.dayNames[context.getDay()]; case "ddd": return Date.CultureInfo.abbreviatedDayNames[context.getDay()]; case "dd": return p(context.getDate()); case "d": return context.getDate(); case "MMMM": return Date.CultureInfo.monthNames[context.getMonth()]; case "MMM": return Date.CultureInfo.abbreviatedMonthNames[context.getMonth()]; case "MM": return p((context.getMonth() + 1)); case "M": return context.getMonth() + 1; case "t": return context.getHours() < 12 ? Date.CultureInfo.amDesignator.substring(0, 1) : Date.CultureInfo.pmDesignator.substring(0, 1); case "tt": return context.getHours() < 12 ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator; case "S": return ord(context.getDate()); case "W": return context.getWeek(); case "WW": return context.getISOWeek(); case "Q": return "Q" + context.getQuarter(); case "q": return String(context.getQuarter()); case "z": return context.getTimezone(); case "Z": case "X": return Date.getTimezoneOffset(context.getTimezone()); case "ZZ": // Timezone offset in seconds return context.getTimezoneOffset() * -60; case "u": return context.getDay(); case "L": return ($D.isLeapYear(context.getFullYear())) ? 1 : 0; case "B": // Swatch Internet Time (.beats) return "@"+((context.getUTCSeconds() + (context.getUTCMinutes()*60) + ((context.getUTCHours()+1)*3600))/86.4); default: return m; } }; }; $P.toString = function (format, ignoreStandards) { // Standard Date and Time Format Strings. Formats pulled from CultureInfo file and // may vary by culture. if (!ignoreStandards && format && format.length === 1) { output = parseStandardFormats.call(this, format); if (output) { return output; } } var parseFormatStrings = parseFormatStringsClosure(this); return format ? format.replace(/((\\)?(dd?d?d?|MM?M?M?|yy?y?y?|hh?|HH?|mm?|ss?|tt?|S|q|Q|WW?W?W?)(?![^\[]*\]))/g, parseFormatStrings).replace(/\[|\]/g, "") : this._toString(); }; }()); /************************************************************* * SugarPak - Domain Specific Language - Syntactical Sugar * *************************************************************/ (function () { var $D = Date, $P = $D.prototype, $N = Number.prototype; // private $P._orient = +1; // private $P._nth = null; // private $P._is = false; // private $P._same = false; // private $P._isSecond = false; // private $N._dateElement = "days"; /** * Moves the date to the next instance of a date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.today().next().friday();
	Date.today().next().fri();
	Date.today().next().march();
	Date.today().next().mar();
	Date.today().next().week();
	
* * @return {Date} date */ $P.next = function () { this._move = true; this._orient = +1; return this; }; /** * Creates a new Date (Date.today()) and moves the date to the next instance of the date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.next().friday();
	Date.next().fri();
	Date.next().march();
	Date.next().mar();
	Date.next().week();
	
* * @return {Date} date */ $D.next = function () { return $D.today().next(); }; /** * Moves the date to the previous instance of a date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.today().last().friday();
	Date.today().last().fri();
	Date.today().last().march();
	Date.today().last().mar();
	Date.today().last().week();
	
* * @return {Date} date */ $P.last = $P.prev = $P.previous = function () { this._move = true; this._orient = -1; return this; }; /** * Creates a new Date (Date.today()) and moves the date to the previous instance of the date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.last().friday();
	Date.last().fri();
	Date.previous().march();
	Date.prev().mar();
	Date.last().week();
	
* * @return {Date} date */ $D.last = $D.prev = $D.previous = function () { return $D.today().last(); }; /** * Performs a equality check when followed by either a month name, day name or .weekday() function. * Example

	Date.today().is().friday(); // true|false
	Date.today().is().fri();
	Date.today().is().march();
	Date.today().is().mar();
	
* * @return {Boolean} true|false */ $P.is = function () { this._is = true; return this; }; /** * Determines if two date objects occur on/in exactly the same instance of the subsequent date part function. * The function .same() must be followed by a date part function (example: .day(), .month(), .year(), etc). * * An optional Date can be passed in the date part function. If now date is passed as a parameter, 'Now' is used. * * The following example demonstrates how to determine if two dates fall on the exact same day. * * Example

	var d1 = Date.today(); // today at 00:00
	var d2 = new Date();   // exactly now.

	// Do they occur on the same day?
	d1.same().day(d2); // true
	
	// Do they occur on the same hour?
	d1.same().hour(d2); // false, unless d2 hour is '00' (midnight).
	
	// What if it's the same day, but one year apart?
	var nextYear = Date.today().add(1).year();

	d1.same().day(nextYear); // false, because the dates must occur on the exact same day. 
	
* * Scenario: Determine if a given date occurs during some week period 2 months from now. * * Example

	var future = Date.today().add(2).months();
	return someDate.same().week(future); // true|false;
	
* * @return {Boolean} true|false */ $P.same = function () { this._same = true; this._isSecond = false; return this; }; /** * Determines if the current date/time occurs during Today. Must be preceded by the .is() function. * Example

	someDate.is().today();    // true|false
	new Date().is().today();  // true
	Date.today().is().today();// true
	Date.today().add(-1).day().is().today(); // false
	
* * @return {Boolean} true|false */ $P.today = function () { return this.same().day(); }; /** * Determines if the current date is a weekday. This function must be preceded by the .is() function. * Example

	Date.today().is().weekday(); // true|false
	
* * @return {Boolean} true|false */ $P.weekday = function () { if (this._nth) { return df("Weekday").call(this); } if (this._move) { return this.addWeekdays(this._orient); } if (this._is) { this._is = false; return (!this.is().sat() && !this.is().sun()); } return false; }; /** * Determines if the current date is on the weekend. This function must be preceded by the .is() function. * Example

	Date.today().is().weekend(); // true|false
	
* * @return {Boolean} true|false */ $P.weekend = function () { if (this._is) { this._is = false; return (this.is().sat() || this.is().sun()); } return false; }; /** * Sets the Time of the current Date instance. A string "6:15 pm" or config object {hour:18, minute:15} are accepted. * Example

	// Set time to 6:15pm with a String
	Date.today().at("6:15pm");

	// Set time to 6:15pm with a config object
	Date.today().at({hour:18, minute:15});
	
* * @return {Date} date */ $P.at = function (time) { return (typeof time === "string") ? $D.parse(this.toString("d") + " " + time) : this.set(time); }; /** * Creates a new Date() and adds this (Number) to the date based on the preceding date element function (eg. second|minute|hour|day|month|year). * Example

	// Undeclared Numbers must be wrapped with parentheses. Requirment of JavaScript.
	(3).days().fromNow();
	(6).months().fromNow();

	// Declared Number variables do not require parentheses. 
	var n = 6;
	n.months().fromNow();
	
* * @return {Date} A new Date instance */ $N.fromNow = $N.after = function (date) { var c = {}; c[this._dateElement] = this; return ((!date) ? new Date() : date.clone()).add(c); }; /** * Creates a new Date() and subtract this (Number) from the date based on the preceding date element function (eg. second|minute|hour|day|month|year). * Example

	// Undeclared Numbers must be wrapped with parentheses. Requirment of JavaScript.
	(3).days().ago();
	(6).months().ago();

	// Declared Number variables do not require parentheses. 
	var n = 6;
	n.months().ago();
	
* * @return {Date} A new Date instance */ $N.ago = $N.before = function (date) { var c = {}, s = (this._dateElement[this._dateElement.length-1] !== "s") ? this._dateElement + "s" : this._dateElement; c[s] = this * -1; return ((!date) ? new Date() : date.clone()).add(c); }; // Do NOT modify the following string tokens. These tokens are used to build dynamic functions. // All culture-specific strings can be found in the CultureInfo files. var dx = ("sunday monday tuesday wednesday thursday friday saturday").split(/\s/), mx = ("january february march april may june july august september october november december").split(/\s/), px = ("Millisecond Second Minute Hour Day Week Month Year Quarter Weekday").split(/\s/), pxf = ("Milliseconds Seconds Minutes Hours Date Week Month FullYear Quarter").split(/\s/), nth = ("final first second third fourth fifth").split(/\s/), de; /** * Returns an object literal of all the date parts. * Example

	var o = new Date().toObject();
	
	// { year: 2008, month: 4, week: 20, day: 13, hour: 18, minute: 9, second: 32, millisecond: 812 }
	
	// The object properties can be referenced directly from the object.
	
	alert(o.day);  // alerts "13"
	alert(o.year); // alerts "2008"
	
* * @return {Date} An object literal representing the original date object. */ $P.toObject = function () { var o = {}; for (var i = 0; i < px.length; i++) { if (this["get" + pxf[i]]) { o[px[i].toLowerCase()] = this["get" + pxf[i]](); } } return o; }; /** * Returns a date created from an object literal. Ignores the .week property if set in the config. * Example

	var o = new Date().toObject();
	
	return Date.fromObject(o); // will return the same date. 

	var o2 = {month: 1, day: 20, hour: 18}; // birthday party!
	Date.fromObject(o2);
	
* * @return {Date} An object literal representing the original date object. */ $D.fromObject = function(config) { config.week = null; return Date.today().set(config); }; // Create day name functions and abbreviated day name functions (eg. monday(), friday(), fri()). var df = function (n) { return function () { if (this._is) { this._is = false; return this.getDay() === n; } if (this._move) { this._move = null; } if (this._nth !== null) { // If the .second() function was called earlier, remove the _orient // from the date, and then continue. // This is required because 'second' can be used in two different context. // // Example // // Date.today().add(1).second(); // Date.march().second().monday(); // // Things get crazy with the following... // Date.march().add(1).second().second().monday(); // but it works!! // if (this._isSecond) { this.addSeconds(this._orient * -1); } // make sure we reset _isSecond this._isSecond = false; var ntemp = this._nth; this._nth = null; var temp = this.clone().moveToLastDayOfMonth(); this.moveToNthOccurrence(n, ntemp); if (this > temp) { throw new RangeError($D.getDayName(n) + " does not occur " + ntemp + " times in the month of " + $D.getMonthName(temp.getMonth()) + " " + temp.getFullYear() + "."); } return this; } return this.moveToDayOfWeek(n, this._orient); }; }; var sdf = function (n) { return function () { var t = $D.today(), shift = n - t.getDay(); if (n === 0 && Date.CultureInfo.firstDayOfWeek === 1 && t.getDay() !== 0) { shift = shift + 7; } return t.addDays(shift); }; }; // Create month name functions and abbreviated month name functions (eg. january(), march(), mar()). var month_instance_functions = function (n) { return function () { if (this._is) { this._is = false; return this.getMonth() === n; } return this.moveToMonth(n, this._orient); }; }; var month_static_functions = function (n) { return function () { return $D.today().set({ month: n, day: 1 }); }; }; var processTerms = function (names, staticFunc, instanceFunc) { for (var i = 0; i < names.length; i++) { // Create constant static Name variables. $D[names[i].toUpperCase()] = $D[names[i].toUpperCase().substring(0, 3)] = i; // Create Name functions. $D[names[i]] = $D[names[i].substring(0, 3)] = staticFunc(i); // Create Name instance functions. $P[names[i]] = $P[names[i].substring(0, 3)] = instanceFunc(i); } }; processTerms(dx, sdf, df); processTerms(mx, month_static_functions, month_instance_functions); // Create date element functions and plural date element functions used with Date (eg. day(), days(), months()). var ef = function (j) { return function () { // if the .second() function was called earlier, the _orient // has alread been added. Just return this and reset _isSecond. if (this._isSecond) { this._isSecond = false; return this; } if (this._same) { this._same = this._is = false; var o1 = this.toObject(), o2 = (arguments[0] || new Date()).toObject(), v = "", k = j.toLowerCase(); // the substr trick with -1 doesn't work in IE8 or less k = (k[k.length-1] === "s") ? k.substring(0,k.length-1) : k; for (var m = (px.length - 1); m > -1; m--) { v = px[m].toLowerCase(); if (o1[v] !== o2[v]) { return false; } if (k === v) { break; } } return true; } if (j.substring(j.length - 1) !== "s") { j += "s"; } if (this._move) { this._move = null; } return this["add" + j](this._orient); }; }; var nf = function (n) { return function () { this._dateElement = n; return this; }; }; for (var k = 0; k < px.length; k++) { de = px[k].toLowerCase(); if(de !== "weekday") { // Create date element functions and plural date element functions used with Date (eg. day(), days(), months()). $P[de] = $P[de + "s"] = ef(px[k]); // Create date element functions and plural date element functions used with Number (eg. day(), days(), months()). $N[de] = $N[de + "s"] = nf(de + "s"); } } $P._ss = ef("Second"); var nthfn = function (n) { return function (dayOfWeek) { if (this._same) { return this._ss(arguments[0]); } if (dayOfWeek || dayOfWeek === 0) { return this.moveToNthOccurrence(dayOfWeek, n); } this._nth = n; // if the operator is 'second' add the _orient, then deal with it later... if (n === 2 && (dayOfWeek === undefined || dayOfWeek === null)) { this._isSecond = true; return this.addSeconds(this._orient); } return this; }; }; for (var l = 0; l < nth.length; l++) { $P[nth[l]] = (l === 0) ? nthfn(-1) : nthfn(l); } }()); (function () { "use strict"; Date.Parsing = { Exception: function (s) { this.message = "Parse error at '" + s.substring(0, 10) + " ...'"; } }; var $P = Date.Parsing; var dayOffsets = { standard: [0,31,59,90,120,151,181,212,243,273,304,334], leap: [0,31,60,91,121,152,182,213,244,274,305,335] }; $P.isLeapYear = function(year) { return ((year % 4 === 0) && (year % 100 !== 0)) || (year % 400 === 0); }; var utils = { multiReplace : function (str, hash ) { var key; for (key in hash) { if (Object.prototype.hasOwnProperty.call(hash, key)) { var regex; if (typeof hash[key] === "function") { } else { regex = (hash[key] instanceof RegExp) ? hash[key] : new RegExp(hash[key], "g"); } str = str.replace(regex, key); } } return str; }, getDayOfYearFromWeek : function (obj) { var d, jan4, offset; obj.weekDay = (!obj.weekDay && obj.weekDay !== 0) ? 1 : obj.weekDay; d = new Date(obj.year, 0, 4); jan4 = d.getDay() === 0 ? 7 : d.getDay(); // JS is 0 indexed on Sunday. offset = jan4+3; obj.dayOfYear = ((obj.week * 7) + (obj.weekDay === 0 ? 7 : obj.weekDay))-offset; return obj; }, getDayOfYear : function (obj, dayOffset) { if (!obj.dayOfYear) { obj = utils.getDayOfYearFromWeek(obj); } for (var i=0;i <= dayOffset.length;i++) { if (obj.dayOfYear < dayOffset[i] || i === dayOffset.length) { obj.day = obj.day ? obj.day : (obj.dayOfYear - dayOffset[i-1]); break; } else { obj.month = i; } } return obj; }, adjustForTimeZone : function (obj, date) { var offset; if (obj.zone.toUpperCase() === "Z" || (obj.zone_hours === 0 && obj.zone_minutes === 0)) { // it's UTC/GML so work out the current timeszone offset offset = -date.getTimezoneOffset(); } else { offset = (obj.zone_hours*60) + (obj.zone_minutes || 0); if (obj.zone_sign === "+") { offset *= -1; } offset -= date.getTimezoneOffset(); } date.setMinutes(date.getMinutes()+offset); return date; }, setDefaults : function (obj) { obj.year = obj.year || Date.today().getFullYear(); obj.hours = obj.hours || 0; obj.minutes = obj.minutes || 0; obj.seconds = obj.seconds || 0; obj.milliseconds = obj.milliseconds || 0; if (!(!obj.month && (obj.week || obj.dayOfYear))) { // if we have a month, or if we don't but don't have the day calculation data obj.month = obj.month || 0; obj.day = obj.day || 1; } return obj; }, dataNum: function (data, mod, explict, postProcess) { var dataNum = data*1; if (mod) { if (postProcess) { return data ? mod(data)*1 : data; } else { return data ? mod(dataNum) : data; } } else if (!explict){ return data ? dataNum : data; } else { return (data && typeof data !== "undefined") ? dataNum : data; } }, timeDataProcess: function (obj) { var timeObj = {}; for (var x in obj.data) { if (obj.data.hasOwnProperty(x)) { timeObj[x] = obj.ignore[x] ? obj.data[x] : utils.dataNum(obj.data[x], obj.mods[x], obj.explict[x], obj.postProcess[x]); } } if (obj.data.secmins) { obj.data.secmins = obj.data.secmins.replace(",", ".") * 60; if (!timeObj.minutes) { timeObj.minutes = obj.data.secmins; } else if (!timeObj.seconds) { timeObj.seconds = obj.data.secmins; } delete obj.secmins; } return timeObj; }, buildTimeObjectFromData: function (data) { var time = utils.timeDataProcess({ data: { year : data[1], month : data[5], day : data[7], week : data[8], dayOfYear : data[10], hours : data[15], zone_hours : data[23], zone_minutes : data[24], zone : data[21], zone_sign : data[22], weekDay : data[9], minutes: data[16], seconds: data[19], milliseconds: data[20], secmins: data[18] }, mods: { month: function(data) { return data-1; }, weekDay: function (data) { data = Math.abs(data); return (data === 7 ? 0 : data); }, minutes: function (data) { return data.replace(":",""); }, seconds: function (data) { return Math.floor( (data.replace(":","").replace(",","."))*1 ); }, milliseconds: function (data) { return (data.replace(",",".")*1000); } }, postProcess: { minutes: true, seconds: true, milliseconds: true }, explict: { zone_hours: true, zone_minutes: true }, ignore: { zone: true, zone_sign: true, secmins: true } }); return time; }, addToHash: function (hash, keys, data) { keys = keys; data = data; var len = keys.length; for (var i = 0; i < len; i++) { hash[keys[i]] = data[i]; } return hash; }, combineRegex: function (r1, r2) { return new RegExp("(("+r1.source+")\\s("+r2.source+"))"); }, getDateNthString: function(add, last, inc){ if (add) { return Date.today().addDays(inc).toString("d"); } else if (last) { return Date.today().last()[inc]().toString("d"); } }, buildRegexData: function (array) { var arr = []; var len = array.length; for (var i=0; i < len; i++) { if (Object.prototype.toString.call(array[i]) === '[object Array]') { // oldIE compat version of Array.isArray arr.push(this.combineRegex(array[i][0], array[i][1])); } else { arr.push(array[i]); } } return arr; } }; $P.processTimeObject = function (obj) { var date, dayOffset; utils.setDefaults(obj); dayOffset = ($P.isLeapYear(obj.year)) ? dayOffsets.leap : dayOffsets.standard; if (!obj.month && (obj.week || obj.dayOfYear)) { utils.getDayOfYear(obj, dayOffset); } else { obj.dayOfYear = dayOffset[obj.month] + obj.day; } date = new Date(obj.year, obj.month, obj.day, obj.hours, obj.minutes, obj.seconds, obj.milliseconds); if (obj.zone) { utils.adjustForTimeZone(obj, date); // adjust (and calculate) for timezone } return date; }; $P.ISO = { regex : /^([\+-]?\d{4}(?!\d{2}\b))((-?)((0[1-9]|1[0-2])(\3([12]\d|0[1-9]|3[01]))?|W([0-4]\d|5[0-3])(-?[1-7])?|(00[1-9]|0[1-9]\d|[12]\d{2}|3([0-5]\d|6[1-6])))([T\s]((([01]\d|2[0-4])((:?)[0-5]\d)?|24\:?00)([\.,]\d+(?!:))?)?(\17[0-5]\d([\.,]\d+)?)?\s?([zZ]|([\+-])([01]\d|2[0-3]):?([0-5]\d)?)?)?)?$/, parse : function (s) { var time, data = s.match(this.regex); if (!data || !data.length) { return null; } time = utils.buildTimeObjectFromData(data); if (!time.year || (!time.year && (!time.month && !time.day) && (!time.week && !time.dayOfYear)) ) { return null; } return $P.processTimeObject(time); } }; $P.Numeric = { isNumeric: function (e){return!isNaN(parseFloat(e))&&isFinite(e);}, regex: /\b([0-1]?[0-9])([0-3]?[0-9])([0-2]?[0-9]?[0-9][0-9])\b/i, parse: function (s) { var data, i, time = {}, order = Date.CultureInfo.dateElementOrder.split(""); if (!(this.isNumeric(s)) || // if it's non-numeric OR (s[0] === "+" && s[0] === "-")) { // It's an arithmatic string (eg +/-1000) return null; } if (s.length < 5 && s.indexOf(".") < 0 && s.indexOf("/") < 0) { // assume it's just a year. time.year = s; return $P.processTimeObject(time); } data = s.match(this.regex); if (!data || !data.length) { return null; } for (i=0; i < order.length; i++) { switch(order[i]) { case "d": time.day = data[i+1]; break; case "m": time.month = (data[i+1]-1); break; case "y": time.year = data[i+1]; break; } } return $P.processTimeObject(time); } }; $P.Normalizer = { regexData: function () { var $R = Date.CultureInfo.regexPatterns; return utils.buildRegexData([ $R.tomorrow, $R.yesterday, [$R.past, $R.mon], [$R.past, $R.tue], [$R.past, $R.wed], [$R.past, $R.thu], [$R.past, $R.fri], [$R.past, $R.sat], [$R.past, $R.sun] ]); }, basicReplaceHash : function() { var $R = Date.CultureInfo.regexPatterns; return { "January": $R.jan.source, "February": $R.feb, "March": $R.mar, "April": $R.apr, "May": $R.may, "June": $R.jun, "July": $R.jul, "August": $R.aug, "September": $R.sep, "October": $R.oct, "November": $R.nov, "December": $R.dec, "": /\bat\b/gi, " ": /\s{2,}/, "am": $R.inTheMorning, "9am": $R.thisMorning, "pm": $R.inTheEvening, "7pm":$R.thisEvening }; }, keys : function(){ return [ utils.getDateNthString(true, false, 1), // tomorrow utils.getDateNthString(true, false, -1), // yesterday utils.getDateNthString(false, true, "monday"), //last mon utils.getDateNthString(false, true, "tuesday"), //last tues utils.getDateNthString(false, true, "wednesday"), //last wed utils.getDateNthString(false, true, "thursday"), //last thurs utils.getDateNthString(false, true, "friday"), //last fri utils.getDateNthString(false, true, "saturday"), //last sat utils.getDateNthString(false, true, "sunday") //last sun ]; }, buildRegexFunctions: function () { var $R = Date.CultureInfo.regexPatterns; var __ = Date.i18n.__; var tomorrowRE = new RegExp("(\\b\\d\\d?("+__("AM")+"|"+__("PM")+")? )("+$R.tomorrow.source.slice(1)+")", "i"); // adapted tomorrow regex for AM PM relative dates var todayRE = new RegExp($R.today.source + "(?!\\s*([+-]))\\b"); // today, but excludes the math operators (eg "today + 2h") this.replaceFuncs = [ [todayRE, function (full) { return (full.length > 1) ? Date.today().toString("d") : full; }], [tomorrowRE, function(full, m1) { var t = Date.today().addDays(1).toString("d"); return (t + " " + m1); }], [$R.amThisMorning, function(str, am){return am;}], [$R.pmThisEvening, function(str, pm){return pm;}] ]; }, buildReplaceData: function () { this.buildRegexFunctions(); this.replaceHash = utils.addToHash(this.basicReplaceHash(), this.keys(), this.regexData()); }, stringReplaceFuncs: function (s) { for (var i=0; i < this.replaceFuncs.length; i++) { s = s.replace(this.replaceFuncs[i][0], this.replaceFuncs[i][1]); } return s; }, parse: function (s) { s = this.stringReplaceFuncs(s); s = utils.multiReplace(s, this.replaceHash); try { var n = s.split(/([\s\-\.\,\/\x27]+)/); if (n.length === 3 && $P.Numeric.isNumeric(n[0]) && $P.Numeric.isNumeric(n[2]) && (n[2].length >= 4)) { // ok, so we're dealing with x/year. But that's not a full date. // This fixes wonky dateElementOrder parsing when set to dmy order. if (Date.CultureInfo.dateElementOrder[0] === "d") { s = "1/" + n[0] + "/" + n[2]; // set to 1st of month and normalize the seperator } } } catch (e) {} return s; } }; $P.Normalizer.buildReplaceData(); }()); (function () { var $P = Date.Parsing; var _ = $P.Operators = { // // Tokenizers // rtoken: function (r) { // regex token return function (s) { var mx = s.match(r); if (mx) { return ([ mx[0], s.substring(mx[0].length) ]); } else { throw new $P.Exception(s); } }; }, token: function () { // whitespace-eating token return function (s) { return _.rtoken(new RegExp("^\\s*" + s + "\\s*"))(s); }; }, stoken: function (s) { // string token return _.rtoken(new RegExp("^" + s)); }, // Atomic Operators until: function (p) { return function (s) { var qx = [], rx = null; while (s.length) { try { rx = p.call(this, s); } catch (e) { qx.push(rx[0]); s = rx[1]; continue; } break; } return [ qx, s ]; }; }, many: function (p) { return function (s) { var rx = [], r = null; while (s.length) { try { r = p.call(this, s); } catch (e) { return [ rx, s ]; } rx.push(r[0]); s = r[1]; } return [ rx, s ]; }; }, // generator operators -- see below optional: function (p) { return function (s) { var r = null; try { r = p.call(this, s); } catch (e) { return [ null, s ]; } return [ r[0], r[1] ]; }; }, not: function (p) { return function (s) { try { p.call(this, s); } catch (e) { return [null, s]; } throw new $P.Exception(s); }; }, ignore: function (p) { return p ? function (s) { var r = null; r = p.call(this, s); return [null, r[1]]; } : null; }, product: function () { var px = arguments[0], qx = Array.prototype.slice.call(arguments, 1), rx = []; for (var i = 0 ; i < px.length ; i++) { rx.push(_.each(px[i], qx)); } return rx; }, cache: function (rule) { var cache = {}, cache_length = 0, cache_keys = [], CACHE_MAX = Date.Config.CACHE_MAX || 100000, r = null; var cacheCheck = function () { if (cache_length === CACHE_MAX) { // kill several keys, don't want to have to do this all the time... for (var i=0; i < 10; i++) { var key = cache_keys.shift(); if (key) { delete cache[key]; cache_length--; } } } }; return function (s) { cacheCheck(); try { r = cache[s] = (cache[s] || rule.call(this, s)); } catch (e) { r = cache[s] = e; } cache_length++; cache_keys.push(s); if (r instanceof $P.Exception) { throw r; } else { return r; } }; }, // vector operators -- see below any: function () { var px = arguments; return function (s) { var r = null; for (var i = 0; i < px.length; i++) { if (px[i] == null) { continue; } try { r = (px[i].call(this, s)); } catch (e) { r = null; } if (r) { return r; } } throw new $P.Exception(s); }; }, each: function () { var px = arguments; return function (s) { var rx = [], r = null; for (var i = 0; i < px.length ; i++) { if (px[i] == null) { continue; } try { r = (px[i].call(this, s)); } catch (e) { throw new $P.Exception(s); } rx.push(r[0]); s = r[1]; } return [ rx, s]; }; }, all: function () { var px = arguments, _ = _; return _.each(_.optional(px)); }, // delimited operators sequence: function (px, d, c) { d = d || _.rtoken(/^\s*/); c = c || null; if (px.length === 1) { return px[0]; } return function (s) { var r = null, q = null; var rx = []; for (var i = 0; i < px.length ; i++) { try { r = px[i].call(this, s); } catch (e) { break; } rx.push(r[0]); try { q = d.call(this, r[1]); } catch (ex) { q = null; break; } s = q[1]; } if (!r) { throw new $P.Exception(s); } if (q) { throw new $P.Exception(q[1]); } if (c) { try { r = c.call(this, r[1]); } catch (ey) { throw new $P.Exception(r[1]); } } return [ rx, (r?r[1]:s) ]; }; }, // // Composite Operators // between: function (d1, p, d2) { d2 = d2 || d1; var _fn = _.each(_.ignore(d1), p, _.ignore(d2)); return function (s) { var rx = _fn.call(this, s); return [[rx[0][0], r[0][2]], rx[1]]; }; }, list: function (p, d, c) { d = d || _.rtoken(/^\s*/); c = c || null; return (p instanceof Array ? _.each(_.product(p.slice(0, -1), _.ignore(d)), p.slice(-1), _.ignore(c)) : _.each(_.many(_.each(p, _.ignore(d))), px, _.ignore(c))); }, set: function (px, d, c) { d = d || _.rtoken(/^\s*/); c = c || null; return function (s) { // r is the current match, best the current 'best' match // which means it parsed the most amount of input var r = null, p = null, q = null, rx = null, best = [[], s], last = false; // go through the rules in the given set for (var i = 0; i < px.length ; i++) { // last is a flag indicating whether this must be the last element // if there is only 1 element, then it MUST be the last one q = null; p = null; r = null; last = (px.length === 1); // first, we try simply to match the current pattern // if not, try the next pattern try { r = px[i].call(this, s); } catch (e) { continue; } // since we are matching against a set of elements, the first // thing to do is to add r[0] to matched elements rx = [[r[0]], r[1]]; // if we matched and there is still input to parse and // we don't already know this is the last element, // we're going to next check for the delimiter ... // if there's none, or if there's no input left to parse // than this must be the last element after all ... if (r[1].length > 0 && ! last) { try { q = d.call(this, r[1]); } catch (ex) { last = true; } } else { last = true; } // if we parsed the delimiter and now there's no more input, // that means we shouldn't have parsed the delimiter at all // so don't update r and mark this as the last element ... if (!last && q[1].length === 0) { last = true; } // so, if this isn't the last element, we're going to see if // we can get any more matches from the remaining (unmatched) // elements ... if (!last) { // build a list of the remaining rules we can match against, // i.e., all but the one we just matched against var qx = []; for (var j = 0; j < px.length ; j++) { if (i !== j) { qx.push(px[j]); } } // now invoke recursively set with the remaining input // note that we don't include the closing delimiter ... // we'll check for that ourselves at the end p = _.set(qx, d).call(this, q[1]); // if we got a non-empty set as a result ... // (otw rx already contains everything we want to match) if (p[0].length > 0) { // update current result, which is stored in rx ... // basically, pick up the remaining text from p[1] // and concat the result from p[0] so that we don't // get endless nesting ... rx[0] = rx[0].concat(p[0]); rx[1] = p[1]; } } // at this point, rx either contains the last matched element // or the entire matched set that starts with this element. // now we just check to see if this variation is better than // our best so far, in terms of how much of the input is parsed if (rx[1].length < best[1].length) { best = rx; } // if we've parsed all the input, then we're finished if (best[1].length === 0) { break; } } // so now we've either gone through all the patterns trying them // as the initial match; or we found one that parsed the entire // input string ... // if best has no matches, just return empty set ... if (best[0].length === 0) { return best; } // if a closing delimiter is provided, then we have to check it also if (c) { // we try this even if there is no remaining input because the pattern // may well be optional or match empty input ... try { q = c.call(this, best[1]); } catch (ey) { throw new $P.Exception(best[1]); } // it parsed ... be sure to update the best match remaining input best[1] = q[1]; } // if we're here, either there was no closing delimiter or we parsed it // so now we have the best match; just return it! return best; }; }, forward: function (gr, fname) { return function (s) { return gr[fname].call(this, s); }; }, // // Translation Operators // replace: function (rule, repl) { return function (s) { var r = rule.call(this, s); return [repl, r[1]]; }; }, process: function (rule, fn) { return function (s) { var r = rule.call(this, s); return [fn.call(this, r[0]), r[1]]; }; }, min: function (min, rule) { return function (s) { var rx = rule.call(this, s); if (rx[0].length < min) { throw new $P.Exception(s); } return rx; }; } }; // Generator Operators And Vector Operators // Generators are operators that have a signature of F(R) => R, // taking a given rule and returning another rule, such as // ignore, which parses a given rule and throws away the result. // Vector operators are those that have a signature of F(R1,R2,...) => R, // take a list of rules and returning a new rule, such as each. // Generator operators are converted (via the following _generator // function) into functions that can also take a list or array of rules // and return an array of new rules as though the function had been // called on each rule in turn (which is what actually happens). // This allows generators to be used with vector operators more easily. // Example: // each(ignore(foo, bar)) instead of each(ignore(foo), ignore(bar)) // This also turns generators into vector operators, which allows // constructs like: // not(cache(foo, bar)) var _generator = function (op) { function gen() { var args = null, rx = [], px, i; if (arguments.length > 1) { args = Array.prototype.slice.call(arguments); } else if (arguments[0] instanceof Array) { args = arguments[0]; } if (args) { px = args.shift(); if (px.length > 0) { args.unshift(px[i]); rx.push(op.apply(null, args)); args.shift(); return rx; } } else { return op.apply(null, arguments); } } return gen; }; var gx = "optional not ignore cache".split(/\s/); for (var i = 0 ; i < gx.length ; i++) { _[gx[i]] = _generator(_[gx[i]]); } var _vector = function (op) { return function () { if (arguments[0] instanceof Array) { return op.apply(null, arguments[0]); } else { return op.apply(null, arguments); } }; }; var vx = "each any all".split(/\s/); for (var j = 0 ; j < vx.length ; j++) { _[vx[j]] = _vector(_[vx[j]]); } }()); (function () { var $D = Date; var flattenAndCompact = function (ax) { var rx = []; for (var i = 0; i < ax.length; i++) { if (ax[i] instanceof Array) { rx = rx.concat(flattenAndCompact(ax[i])); } else { if (ax[i]) { rx.push(ax[i]); } } } return rx; }; var parseMeridian = function () { if (this.meridian && (this.hour || this.hour === 0)) { if (this.meridian === "a" && this.hour > 11 && Date.Config.strict24hr){ throw "Invalid hour and meridian combination"; } else if (this.meridian === "p" && this.hour < 12 && Date.Config.strict24hr){ throw "Invalid hour and meridian combination"; } else if (this.meridian === "p" && this.hour < 12) { this.hour = this.hour + 12; } else if (this.meridian === "a" && this.hour === 12) { this.hour = 0; } } }; var setDefaults = function () { var now = new Date(); if ((this.hour || this.minute) && (!this.month && !this.year && !this.day)) { this.day = now.getDate(); } if (!this.year) { this.year = now.getFullYear(); } if (!this.month && this.month !== 0) { this.month = now.getMonth(); } if (!this.day) { this.day = 1; } if (!this.hour) { this.hour = 0; } if (!this.minute) { this.minute = 0; } if (!this.second) { this.second = 0; } if (!this.millisecond) { this.millisecond = 0; } }; var finishUtils = { getToday: function () { if (this.now || "hour minute second".indexOf(this.unit) !== -1) { return new Date(); } else { return $D.today(); } }, setDaysFromWeekday: function (today, orient){ var gap; orient = orient || 1; this.unit = "day"; gap = ($D.getDayNumberFromName(this.weekday) - today.getDay()); this.days = gap ? ((gap + (orient * 7)) % 7) : (orient * 7); return this; }, setMonthsFromMonth: function (today, orient) { var gap; orient = orient || 1; this.unit = "month"; gap = (this.month - today.getMonth()); this.months = gap ? ((gap + (orient * 12)) % 12) : (orient * 12); this.month = null; return this; }, setDMYFromWeekday: function () { var d = Date[this.weekday](); this.day = d.getDate(); if (!this.month) { this.month = d.getMonth(); } this.year = d.getFullYear(); return this; }, setUnitValue: function (orient) { if (!this.value && this.operator && this.operator !== null && this[this.unit + "s"] && this[this.unit + "s"] !== null) { this[this.unit + "s"] = this[this.unit + "s"] + ((this.operator === "add") ? 1 : -1) + (this.value||0) * orient; } else if (this[this.unit + "s"] == null || this.operator != null) { if (!this.value) { this.value = 1; } this[this.unit + "s"] = this.value * orient; } }, generateDateFromWeeks: function () { var weekday = (this.weekday !== undefined) ? this.weekday : "today"; var d = Date[weekday]().addWeeks(this.weeks); if (this.now) { d.setTimeToNow(); } return d; } }; $D.Translator = { hour: function (s) { return function () { this.hour = Number(s); }; }, minute: function (s) { return function () { this.minute = Number(s); }; }, second: function (s) { return function () { this.second = Number(s); }; }, /* for ss.s format */ secondAndMillisecond: function (s) { return function () { var mx = s.match(/^([0-5][0-9])\.([0-9]{1,3})/); this.second = Number(mx[1]); this.millisecond = Number(mx[2]); }; }, meridian: function (s) { return function () { this.meridian = s.slice(0, 1).toLowerCase(); }; }, timezone: function (s) { return function () { var n = s.replace(/[^\d\+\-]/g, ""); if (n.length) { this.timezoneOffset = Number(n); } else { this.timezone = s.toLowerCase(); } }; }, day: function (x) { var s = x[0]; return function () { this.day = Number(s.match(/\d+/)[0]); if (this.day < 1) { throw "invalid day"; } }; }, month: function (s) { return function () { this.month = (s.length === 3) ? "jan feb mar apr may jun jul aug sep oct nov dec".indexOf(s)/4 : Number(s) - 1; if (this.month < 0) { throw "invalid month"; } }; }, year: function (s) { return function () { var n = Number(s); this.year = ((s.length > 2) ? n : (n + (((n + 2000) < Date.CultureInfo.twoDigitYearMax) ? 2000 : 1900))); }; }, rday: function (s) { return function () { switch (s) { case "yesterday": this.days = -1; break; case "tomorrow": this.days = 1; break; case "today": this.days = 0; break; case "now": this.days = 0; this.now = true; break; } }; }, finishExact: function (x) { var d; x = (x instanceof Array) ? x : [x]; for (var i = 0 ; i < x.length ; i++) { if (x[i]) { x[i].call(this); } } setDefaults.call(this); parseMeridian.call(this); if (this.day > $D.getDaysInMonth(this.year, this.month)) { throw new RangeError(this.day + " is not a valid value for days."); } d = new Date(this.year, this.month, this.day, this.hour, this.minute, this.second, this.millisecond); if (this.year < 100) { d.setFullYear(this.year); // means years less that 100 are process correctly. JS will parse it otherwise as 1900-1999. } if (this.timezone) { d.set({ timezone: this.timezone }); } else if (this.timezoneOffset) { d.set({ timezoneOffset: this.timezoneOffset }); } return d; }, finish: function (x) { var today, expression, orient, temp; x = (x instanceof Array) ? flattenAndCompact(x) : [ x ]; if (x.length === 0) { return null; } for (var i = 0 ; i < x.length ; i++) { if (typeof x[i] === "function") { x[i].call(this); } } if (this.now && !this.unit && !this.operator) { return new Date(); } else { today = finishUtils.getToday.call(this); } expression = !!(this.days && this.days !== null || this.orient || this.operator); orient = ((this.orient === "past" || this.operator === "subtract") ? -1 : 1); if (this.month && this.unit === "week") { this.value = this.month + 1; delete this.month; delete this.day; } if ((this.month || this.month === 0) && "year day hour minute second".indexOf(this.unit) !== -1) { if (!this.value) { this.value = this.month + 1; } this.month = null; expression = true; } if (!expression && this.weekday && !this.day && !this.days) { finishUtils.setDMYFromWeekday.call(this); } if (expression && this.weekday && this.unit !== "month" && this.unit !== "week") { finishUtils.setDaysFromWeekday.call(this, today, orient); } if (this.weekday && this.unit !== "week" && !this.day && !this.days) { temp = Date[this.weekday](); this.day = temp.getDate(); if (temp.getMonth() !== today.getMonth()) { this.month = temp.getMonth(); } } if (this.month && this.unit === "day" && this.operator) { if (!this.value) { this.value = (this.month + 1); } this.month = null; } if (this.value != null && this.month != null && this.year != null) { this.day = this.value * 1; } if (this.month && !this.day && this.value) { today.set({ day: this.value * 1 }); if (!expression) { this.day = this.value * 1; } } if (!this.month && this.value && this.unit === "month" && !this.now) { this.month = this.value; expression = true; } if (expression && (this.month || this.month === 0) && this.unit !== "year") { finishUtils.setMonthsFromMonth.call(this, today, orient); } if (!this.unit) { this.unit = "day"; } finishUtils.setUnitValue.call(this, orient); parseMeridian.call(this); if ((this.month || this.month === 0) && !this.day) { this.day = 1; } if (!this.orient && !this.operator && this.unit === "week" && this.value && !this.day && !this.month) { return Date.today().setWeek(this.value); } if (this.unit === "week" && this.weeks && !this.day && !this.month) { return finishUtils.generateDateFromWeeks.call(this); } if (expression && this.timezone && this.day && this.days) { this.day = this.days; } if (expression){ today.add(this); } else { today.set(this); } if (this.timezone) { this.timezone = this.timezone.toUpperCase(); var offset = $D.getTimezoneOffset(this.timezone); var timezone; if (today.hasDaylightSavingTime()) { // lets check that we're being sane with timezone setting timezone = $D.getTimezoneAbbreviation(offset, today.isDaylightSavingTime()); if (timezone !== this.timezone) { // bugger, we're in a place where things like EST vs EDT matters. if (today.isDaylightSavingTime()) { today.addHours(-1); } else { today.addHours(1); } } } today.setTimezoneOffset(offset); } return today; } }; }()); (function () { var $D = Date; $D.Grammar = {}; var _ = $D.Parsing.Operators, g = $D.Grammar, t = $D.Translator, _fn; // Allow rolling up into general purpose rules _fn = function () { return _.each(_.any.apply(null, arguments), _.not(g.ctoken2("timeContext"))); }; g.datePartDelimiter = _.rtoken(/^([\s\-\.\,\/\x27]+)/); g.timePartDelimiter = _.stoken(":"); g.whiteSpace = _.rtoken(/^\s*/); g.generalDelimiter = _.rtoken(/^(([\s\,]|at|@|on)+)/); var _C = {}; g.ctoken = function (keys) { var fn = _C[keys]; if (! fn) { var c = Date.CultureInfo.regexPatterns; var kx = keys.split(/\s+/), px = []; for (var i = 0; i < kx.length ; i++) { px.push(_.replace(_.rtoken(c[kx[i]]), kx[i])); } fn = _C[keys] = _.any.apply(null, px); } return fn; }; g.ctoken2 = function (key) { return _.rtoken(Date.CultureInfo.regexPatterns[key]); }; var cacheProcessRtoken = function (key, token, type, eachToken) { if (eachToken) { g[key] = _.cache(_.process(_.each(_.rtoken(token),_.optional(g.ctoken2(eachToken))), type)); } else { g[key] = _.cache(_.process(_.rtoken(token), type)); } }; var cacheProcessCtoken = function (token, type) { return _.cache(_.process(g.ctoken2(token), type)); }; var _F = {}; //function cache var _get = function (f) { _F[f] = (_F[f] || g.format(f)[0]); return _F[f]; }; g.allformats = function (fx) { var rx = []; if (fx instanceof Array) { for (var i = 0; i < fx.length; i++) { rx.push(_get(fx[i])); } } else { rx.push(_get(fx)); } return rx; }; g.formats = function (fx) { if (fx instanceof Array) { var rx = []; for (var i = 0 ; i < fx.length ; i++) { rx.push(_get(fx[i])); } return _.any.apply(null, rx); } else { return _get(fx); } }; var grammarFormats = { timeFormats: function(){ var i, RTokenKeys = [ "h", "hh", "H", "HH", "m", "mm", "s", "ss", "ss.s", "z", "zz" ], RToken = [ /^(0[0-9]|1[0-2]|[1-9])/, /^(0[0-9]|1[0-2])/, /^([0-1][0-9]|2[0-3]|[0-9])/, /^([0-1][0-9]|2[0-3])/, /^([0-5][0-9]|[0-9])/, /^[0-5][0-9]/, /^([0-5][0-9]|[0-9])/, /^[0-5][0-9]/, /^[0-5][0-9]\.[0-9]{1,3}/, /^((\+|\-)\s*\d\d\d\d)|((\+|\-)\d\d\:?\d\d)/, /^((\+|\-)\s*\d\d\d\d)|((\+|\-)\d\d\:?\d\d)/ ], tokens = [ t.hour, t.hour, t.hour, t.hour, t.minute, t.minute, t.second, t.second, t.secondAndMillisecond, t.timezone, t.timezone ]; for (i=0; i < RTokenKeys.length; i++) { cacheProcessRtoken(RTokenKeys[i], RToken[i], tokens[i]); } g.hms = _.cache(_.sequence([g.H, g.m, g.s], g.timePartDelimiter)); g.t = cacheProcessCtoken("shortMeridian", t.meridian); g.tt = cacheProcessCtoken("longMeridian", t.meridian); g.zzz = cacheProcessCtoken("timezone", t.timezone); g.timeSuffix = _.each(_.ignore(g.whiteSpace), _.set([ g.tt, g.zzz ])); g.time = _.each(_.optional(_.ignore(_.stoken("T"))), g.hms, g.timeSuffix); }, dateFormats: function () { // pre-loaded rules for different date part order preferences var _setfn = function () { return _.set(arguments, g.datePartDelimiter); }; var i, RTokenKeys = [ "d", "dd", "M", "MM", "y", "yy", "yyy", "yyyy" ], RToken = [ /^([0-2]\d|3[0-1]|\d)/, /^([0-2]\d|3[0-1])/, /^(1[0-2]|0\d|\d)/, /^(1[0-2]|0\d)/, /^(\d+)/, /^(\d\d)/, /^(\d\d?\d?\d?)/, /^(\d\d\d\d)/ ], tokens = [ t.day, t.day, t.month, t.month, t.year, t.year, t.year, t.year ], eachToken = [ "ordinalSuffix", "ordinalSuffix" ]; for (i=0; i < RTokenKeys.length; i++) { cacheProcessRtoken(RTokenKeys[i], RToken[i], tokens[i], eachToken[i]); } g.MMM = g.MMMM = _.cache(_.process(g.ctoken("jan feb mar apr may jun jul aug sep oct nov dec"), t.month)); g.ddd = g.dddd = _.cache(_.process(g.ctoken("sun mon tue wed thu fri sat"), function (s) { return function () { this.weekday = s; }; } )); g.day = _fn(g.d, g.dd); g.month = _fn(g.M, g.MMM); g.year = _fn(g.yyyy, g.yy); g.mdy = _setfn(g.ddd, g.month, g.day, g.year); g.ymd = _setfn(g.ddd, g.year, g.month, g.day); g.dmy = _setfn(g.ddd, g.day, g.month, g.year); g.date = function (s) { return ((g[Date.CultureInfo.dateElementOrder] || g.mdy).call(this, s)); }; }, relative: function () { // relative date / time expressions g.orientation = _.process(g.ctoken("past future"), function (s) { return function () { this.orient = s; }; } ); g.operator = _.process(g.ctoken("add subtract"), function (s) { return function () { this.operator = s; }; } ); g.rday = _.process(g.ctoken("yesterday tomorrow today now"), t.rday); g.unit = _.process(g.ctoken("second minute hour day week month year"), function (s) { return function () { this.unit = s; }; } ); } }; g.buildGrammarFormats = function () { // these need to be rebuilt every time the language changes. _C = {}; grammarFormats.timeFormats(); grammarFormats.dateFormats(); grammarFormats.relative(); g.value = _.process(_.rtoken(/^([-+]?\d+)?(st|nd|rd|th)?/), function (s) { return function () { this.value = s.replace(/\D/g, ""); }; } ); g.expression = _.set([g.rday, g.operator, g.value, g.unit, g.orientation, g.ddd, g.MMM ]); g.format = _.process(_.many( _.any( // translate format specifiers into grammar rules _.process( _.rtoken(/^(dd?d?d?(?!e)|MM?M?M?|yy?y?y?|hh?|HH?|mm?|ss?|tt?|zz?z?)/), function (fmt) { if (g[fmt]) { return g[fmt]; } else { throw $D.Parsing.Exception(fmt); } } ), // translate separator tokens into token rules _.process(_.rtoken(/^[^dMyhHmstz]+/), // all legal separators function (s) { return _.ignore(_.stoken(s)); } ) ) ), // construct the parser ... function (rules) { return _.process(_.each.apply(null, rules), t.finishExact); } ); // starting rule for general purpose grammar g._start = _.process(_.set([ g.date, g.time, g.expression ], g.generalDelimiter, g.whiteSpace), t.finish); }; g.buildGrammarFormats(); // parsing date format specifiers - ex: "h:m:s tt" // this little guy will generate a custom parser based // on the format string, ex: g.format("h:m:s tt") // check for these formats first g._formats = g.formats([ "\"yyyy-MM-ddTHH:mm:ssZ\"", "yyyy-MM-ddTHH:mm:ss.sz", "yyyy-MM-ddTHH:mm:ssZ", "yyyy-MM-ddTHH:mm:ssz", "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-ddTHH:mmZ", "yyyy-MM-ddTHH:mmz", "yyyy-MM-ddTHH:mm", "ddd, MMM dd, yyyy H:mm:ss tt", "ddd MMM d yyyy HH:mm:ss zzz", "MMddyyyy", "ddMMyyyy", "Mddyyyy", "ddMyyyy", "Mdyyyy", "dMyyyy", "yyyy", "Mdyy", "dMyy", "d" ]); // real starting rule: tries selected formats first, // then general purpose rule g.start = function (s) { try { var r = g._formats.call({}, s); if (r[1].length === 0) { return r; } } catch (e) {} return g._start.call({}, s); }; }()); (function () { var $D = Date; /** * @desc Converts the specified string value into its JavaScript Date equivalent using CultureInfo specific format information. * * Example

	///////////
	// Dates //
	///////////

	// 15-Oct-2004
	var d1 = Date.parse("10/15/2004");

	// 15-Oct-2004
	var d1 = Date.parse("15-Oct-2004");

	// 15-Oct-2004
	var d1 = Date.parse("2004.10.15");

	//Fri Oct 15, 2004
	var d1 = Date.parse("Fri Oct 15, 2004");

	///////////
	// Times //
	///////////

	// Today at 10 PM.
	var d1 = Date.parse("10 PM");

	// Today at 10:30 PM.
	var d1 = Date.parse("10:30 P.M.");

	// Today at 6 AM.
	var d1 = Date.parse("06am");

	/////////////////////
	// Dates and Times //
	/////////////////////

	// 8-July-2004 @ 10:30 PM
	var d1 = Date.parse("July 8th, 2004, 10:30 PM");

	// 1-July-2004 @ 10:30 PM
	var d1 = Date.parse("2004-07-01T22:30:00");

	////////////////////
	// Relative Dates //
	////////////////////

	// Returns today's date. The string "today" is culture specific.
	var d1 = Date.parse("today");

	// Returns yesterday's date. The string "yesterday" is culture specific.
	var d1 = Date.parse("yesterday");

	// Returns the date of the next thursday.
	var d1 = Date.parse("Next thursday");

	// Returns the date of the most previous monday.
	var d1 = Date.parse("last monday");

	// Returns today's day + one year.
	var d1 = Date.parse("next year");

	///////////////
	// Date Math //
	///////////////

	// Today + 2 days
	var d1 = Date.parse("t+2");

	// Today + 2 days
	var d1 = Date.parse("today + 2 days");

	// Today + 3 months
	var d1 = Date.parse("t+3m");

	// Today - 1 year
	var d1 = Date.parse("today - 1 year");

	// Today - 1 year
	var d1 = Date.parse("t-1y"); 


	/////////////////////////////
	// Partial Dates and Times //
	/////////////////////////////

	// July 15th of this year.
	var d1 = Date.parse("July 15");

	// 15th day of current day and year.
	var d1 = Date.parse("15");

	// July 1st of current year at 10pm.
	var d1 = Date.parse("7/1 10pm");
	
* * @param {String} The string value to convert into a Date object [Required] * @return {Date} A Date object or null if the string cannot be converted into a Date. */ var parseUtils = { removeOrds: function (s) { ords = s.match(/\b(\d+)(?:st|nd|rd|th)\b/); // find ordinal matches s = ((ords && ords.length === 2) ? s.replace(ords[0], ords[1]) : s); return s; }, grammarParser: function (s) { var r = null; try { r = $D.Grammar.start.call({}, s.replace(/^\s*(\S*(\s+\S+)*)\s*$/, "$1")); } catch (e) { return null; } return ((r[1].length === 0) ? r[0] : null); }, nativeFallback: function(s) { var t; try { // ok we haven't parsed it, last ditch attempt with the built-in parser. t = Date._parse(s); return (t || t === 0) ? new Date(t) : null; } catch (e) { return null; } } }; function parse (s) { var d; if (!s) { return null; } if (s instanceof Date) { return s.clone(); } if (s.length >= 4 && s.charAt(0) !== "0" && s.charAt(0) !== "+"&& s.charAt(0) !== "-") { // ie: 2004 will pass, 0800 won't. // Start with specific formats d = $D.Parsing.ISO.parse(s) || $D.Parsing.Numeric.parse(s); } if (d instanceof Date && !isNaN(d.getTime())) { return d; } else { // find ordinal dates (1st, 3rd, 8th, etc and remove them as they cause parsing issues) s = $D.Parsing.Normalizer.parse(parseUtils.removeOrds(s)); d = parseUtils.grammarParser(s); if (d !== null) { return d; } else { return parseUtils.nativeFallback(s); } } } if (!$D._parse) { $D._parse = $D.parse; } $D.parse = parse; Date.getParseFunction = function (fx) { var fns = Date.Grammar.allformats(fx); return function (s) { var r = null; for (var i = 0; i < fns.length; i++) { try { r = fns[i].call({}, s); } catch (e) { continue; } if (r[1].length === 0) { return r[0]; } } return null; }; }; /** * Converts the specified string value into its JavaScript Date equivalent using the specified format {String} or formats {Array} and the CultureInfo specific format information. * The format of the string value must match one of the supplied formats exactly. * * Example

	// 15-Oct-2004
	var d1 = Date.parseExact("10/15/2004", "M/d/yyyy");

	// 15-Oct-2004
	var d1 = Date.parse("15-Oct-2004", "M-ddd-yyyy");

	// 15-Oct-2004
	var d1 = Date.parse("2004.10.15", "yyyy.MM.dd");

	// Multiple formats
	var d1 = Date.parseExact("10/15/2004", ["M/d/yyyy", "MMMM d, yyyy"]);
	
* * @param {String} The string value to convert into a Date object [Required]. * @param {Object} The expected format {String} or an array of expected formats {Array} of the date string [Required]. * @return {Date} A Date object or null if the string cannot be converted into a Date. */ $D.parseExact = function (s, fx) { return $D.getParseFunction(fx)(s); }; }()); (function () { var $D = Date, $P = $D.prototype, // $C = $D.CultureInfo, // not used atm p = function (s, l) { if (!l) { l = 2; } return ("000" + s).slice(l * -1); }; /** * Converts a PHP format string to Java/.NET format string. * A PHP format string can be used with ._format or .format. * A Java/.NET format string can be used with .toString(). * The .parseExact function will only accept a Java/.NET format string * * Example * var f1 = "%m/%d/%y" * var f2 = Date.normalizeFormat(f1); // "MM/dd/yy" * * new Date().format(f1); // "04/13/08" * new Date()._format(f1); // "04/13/08" * new Date().toString(f2); // "04/13/08" * * var date = Date.parseExact("04/13/08", f2); // Sun Apr 13 2008 * * @param {String} A PHP format string consisting of one or more format spcifiers. * @return {String} The PHP format converted to a Java/.NET format string. */ var normalizerSubstitutions = { "d" : "dd", "%d": "dd", "D" : "ddd", "%a": "ddd", "j" : "dddd", "l" : "dddd", "%A": "dddd", "S" : "S", "F" : "MMMM", "%B": "MMMM", "m" : "MM", "%m": "MM", "M" : "MMM", "%b": "MMM", "%h": "MMM", "n" : "M", "Y" : "yyyy", "%Y": "yyyy", "y" : "yy", "%y": "yy", "g" : "h", "%I": "h", "G" : "H", "h" : "hh", "H" : "HH", "%H": "HH", "i" : "mm", "%M": "mm", "s" : "ss", "%S": "ss", "%r": "hh:mm tt", "%R": "H:mm", "%T": "H:mm:ss", "%X": "t", "%x": "d", "%e": "d", "%D": "MM/dd/yy", "%n": "\\n", "%t": "\\t", "e" : "z", "T" : "z", "%z": "z", "%Z": "z", "Z" : "ZZ", "N" : "u", "w" : "u", "%w": "u", "W" : "W", "%V": "W" }; var normalizer = { substitutes: function (m) { return normalizerSubstitutions[m]; }, interpreted: function (m, x) { var y; switch (m) { case "%u": return x.getDay() + 1; case "z": return x.getOrdinalNumber(); case "%j": return p(x.getOrdinalNumber(), 3); case "%U": var d1 = x.clone().set({month: 0, day: 1}).addDays(-1).moveToDayOfWeek(0), d2 = x.clone().addDays(1).moveToDayOfWeek(0, -1); return (d2 < d1) ? "00" : p((d2.getOrdinalNumber() - d1.getOrdinalNumber()) / 7 + 1); case "%W": return p(x.getWeek()); case "t": return $D.getDaysInMonth(x.getFullYear(), x.getMonth()); case "o": case "%G": return x.setWeek(x.getISOWeek()).toString("yyyy"); case "%g": return x._format("%G").slice(-2); case "a": case "%p": return t("tt").toLowerCase(); case "A": return t("tt").toUpperCase(); case "u": return p(x.getMilliseconds(), 3); case "I": return (x.isDaylightSavingTime()) ? 1 : 0; case "O": return x.getUTCOffset(); case "P": y = x.getUTCOffset(); return y.substring(0, y.length - 2) + ":" + y.substring(y.length - 2); case "B": var now = new Date(); return Math.floor(((now.getHours() * 3600) + (now.getMinutes() * 60) + now.getSeconds() + (now.getTimezoneOffset() + 60) * 60) / 86.4); case "c": return x.toISOString().replace(/\"/g, ""); case "U": return $D.strtotime("now"); case "%c": return t("d") + " " + t("t"); case "%C": return Math.floor(x.getFullYear() / 100 + 1); } }, shouldOverrideDefaults: function (m) { switch (m) { case "%e": return true; default: return false; } }, parse: function (m, context) { var formatString, c = context || new Date(); formatString = normalizer.substitutes(m); if (formatString) { return formatString; } formatString = normalizer.interpreted(m, c); if (formatString) { return formatString; } else { return m; } } }; $D.normalizeFormat = function (format, context) { return format.replace(/(%|\\)?.|%%/g, function(t){ return normalizer.parse(t, context); }); }; /** * Format a local Unix timestamp according to locale settings * * Example: * Date.strftime("%m/%d/%y", new Date()); // "04/13/08" * Date.strftime("c", "2008-04-13T17:52:03Z"); // "04/13/08" * * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @param {Number|String} The number representing the number of seconds that have elapsed since January 1, 1970 (local time). * @return {String} A string representation of the current Date object. */ $D.strftime = function (format, time) { var d = Date.parse(time); return d._format(format); }; /** * Parse any textual datetime description into a Unix timestamp. * A Unix timestamp is the number of seconds that have elapsed since January 1, 1970 (midnight UTC/GMT). * * Example: * Date.strtotime("04/13/08"); // 1208044800 * Date.strtotime("1970-01-01T00:00:00Z"); // 0 * * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @param {Object} A string or date object. * @return {String} A string representation of the current Date object. */ $D.strtotime = function (time) { var d = $D.parse(time); return Math.round($D.UTC(d.getUTCFullYear(), d.getUTCMonth(), d.getUTCDate(), d.getUTCHours(), d.getUTCMinutes(), d.getUTCSeconds(), d.getUTCMilliseconds()) / 1000); }; /** * Converts the value of the current Date object to its equivalent string representation using a PHP/Unix style of date format specifiers. * Format Specifiers * Format Description Example * ------ --------------------------------------------------------------------------- ----------------------- * %a abbreviated weekday name according to the current localed "Mon" through "Sun" * %A full weekday name according to the current localed "Sunday" through "Saturday" * %b abbreviated month name according to the current localed "Jan" through "Dec" * %B full month name according to the current locale "January" through "December" * %c preferred date and time representation for the current locale "4/13/2008 12:33 PM" * %C century number (the year divided by 100 and truncated to an integer) "00" to "99" * %d day of the month as a decimal number "01" to "31" * %D same as %m/%d/%y "04/13/08" * %e day of the month as a decimal number, a single digit is preceded by a space "1" to "31" * %g like %G, but without the century "08" * %G The 4-digit year corresponding to the ISO week number (see %V). "2008" * This has the same format and value as %Y, except that if the ISO week number * belongs to the previous or next year, that year is used instead. * %h same as %b "Jan" through "Dec" * %H hour as a decimal number using a 24-hour clock. "00" to "23" * %I hour as a decimal number using a 12-hour clock. "01" to "12" * %j day of the year as a decimal number. "001" to "366" * %m month as a decimal number. "01" to "12" * %M minute as a decimal number. "00" to "59" * %n newline character "\n" * %p either "am" or "pm" according to the given time value, or the "am" or "pm" * corresponding strings for the current locale. * %r time in a.m. and p.m. notation "8:44 PM" * %R time in 24 hour notation "20:44" * %S second as a decimal number "00" to "59" * %t tab character "\t" * %T current time, equal to %H:%M:%S "12:49:11" * %u weekday as a decimal number ["1", "7"], with "1" representing Monday "1" to "7" * %U week number of the current year as a decimal number, starting with the "0" to ("52" or "53") * first Sunday as the first day of the first week * %V The ISO 8601:1988 week number of the current year as a decimal number, "00" to ("52" or "53") * range 01 to 53, where week 1 is the first week that has at least 4 days * in the current year, and with Monday as the first day of the week. * (Use %G or %g for the year component that corresponds to the week number * for the specified timestamp.) * %W week number of the current year as a decimal number, starting with the "00" to ("52" or "53") * first Monday as the first day of the first week * %w day of the week as a decimal, Sunday being "0" "0" to "6" * %x preferred date representation for the current locale without the time "4/13/2008" * %X preferred time representation for the current locale without the date "12:53:05" * %y year as a decimal number without a century "00" "99" * %Y year as a decimal number including the century "2008" * %Z time zone or name or abbreviation "UTC", "EST", "PST" * %z same as %Z * %% a literal "%" characters "%" * d Day of the month, 2 digits with leading zeros "01" to "31" * D A textual representation of a day, three letters "Mon" through "Sun" * j Day of the month without leading zeros "1" to "31" * l A full textual representation of the day of the week (lowercase "L") "Sunday" through "Saturday" * N ISO-8601 numeric representation of the day of the week (added in PHP 5.1.0) "1" (for Monday) through "7" (for Sunday) * S English ordinal suffix for the day of the month, 2 characters "st", "nd", "rd" or "th". Works well with j * w Numeric representation of the day of the week "0" (for Sunday) through "6" (for Saturday) * z The day of the year (starting from "0") "0" through "365" * W ISO-8601 week number of year, weeks starting on Monday "00" to ("52" or "53") * F A full textual representation of a month, such as January or March "January" through "December" * m Numeric representation of a month, with leading zeros "01" through "12" * M A short textual representation of a month, three letters "Jan" through "Dec" * n Numeric representation of a month, without leading zeros "1" through "12" * t Number of days in the given month "28" through "31" * L Whether it's a leap year "1" if it is a leap year, "0" otherwise * o ISO-8601 year number. This has the same value as Y, except that if the "2008" * ISO week number (W) belongs to the previous or next year, that year * is used instead. * Y A full numeric representation of a year, 4 digits "2008" * y A two digit representation of a year "08" * a Lowercase Ante meridiem and Post meridiem "am" or "pm" * A Uppercase Ante meridiem and Post meridiem "AM" or "PM" * B Swatch Internet time "000" through "999" * g 12-hour format of an hour without leading zeros "1" through "12" * G 24-hour format of an hour without leading zeros "0" through "23" * h 12-hour format of an hour with leading zeros "01" through "12" * H 24-hour format of an hour with leading zeros "00" through "23" * i Minutes with leading zeros "00" to "59" * s Seconds, with leading zeros "00" through "59" * u Milliseconds "54321" * e Timezone identifier "UTC", "EST", "PST" * I Whether or not the date is in daylight saving time (uppercase i) "1" if Daylight Saving Time, "0" otherwise * O Difference to Greenwich time (GMT) in hours "+0200", "-0600" * P Difference to Greenwich time (GMT) with colon between hours and minutes "+02:00", "-06:00" * T Timezone abbreviation "UTC", "EST", "PST" * Z Timezone offset in seconds. The offset for timezones west of UTC is "-43200" through "50400" * always negative, and for those east of UTC is always positive. * c ISO 8601 date "2004-02-12T15:19:21+00:00" * r RFC 2822 formatted date "Thu, 21 Dec 2000 16:01:07 +0200" * U Seconds since the Unix Epoch (January 1 1970 00:00:00 GMT) "0" * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @return {String} A string representation of the current Date object. */ var formatReplace = function (context) { return function (m) { var formatString, override = false; if (m.charAt(0) === "\\" || m.substring(0, 2) === "%%") { return m.replace("\\", "").replace("%%", "%"); } override = normalizer.shouldOverrideDefaults(m); formatString = $D.normalizeFormat(m, context); if (formatString) { return context.toString(formatString, override); } }; }; $P._format = function (format) { var formatter = formatReplace(this); if (!format) { return this._toString(); } else { return format.replace(/(%|\\)?.|%%/g, formatter); } }; if (!$P.format) { $P.format = $P._format; } }()); (function () { "use strict"; var gFn = function (attr) { return function () { return this[attr]; }; }; var sFn = function (attr) { return function (val) { this[attr] = val; return this; }; }; var attrs = ["years", "months", "days", "hours", "minutes", "seconds", "milliseconds"]; var addSetFuncs = function (context, attrs) { for (var i = 0; i < attrs.length ; i++) { var $a = attrs[i], $b = $a.slice(0, 1).toUpperCase() + $a.slice(1); context.prototype[$a] = 0; context.prototype["get" + $b] = gFn($a); context.prototype["set" + $b] = sFn($a); } }; /** * new TimeSpan(milliseconds); * new TimeSpan(days, hours, minutes, seconds); * new TimeSpan(days, hours, minutes, seconds, milliseconds); */ var TimeSpan = function (days, hours, minutes, seconds, milliseconds) { if (arguments.length === 1 && typeof days === "number") { var orient = (days < 0) ? -1 : +1; var millsLeft = Math.abs(days); this.setDays(Math.floor(millsLeft / 86400000) * orient); millsLeft = millsLeft % 86400000; this.setHours(Math.floor(millsLeft / 3600000) * orient); millsLeft = millsLeft % 3600000; this.setMinutes(Math.floor(millsLeft / 60000) * orient); millsLeft = millsLeft % 60000; this.setSeconds(Math.floor(millsLeft / 1000) * orient); millsLeft = millsLeft % 1000; this.setMilliseconds(millsLeft * orient); } else { this.set(days, hours, minutes, seconds, milliseconds); } this.getTotalMilliseconds = function () { return (this.getDays() * 86400000) + (this.getHours() * 3600000) + (this.getMinutes() * 60000) + (this.getSeconds() * 1000); }; this.compareTo = function (time) { var t1 = new Date(1970, 1, 1, this.getHours(), this.getMinutes(), this.getSeconds()), t2; if (time === null) { t2 = new Date(1970, 1, 1, 0, 0, 0); } else { t2 = new Date(1970, 1, 1, time.getHours(), time.getMinutes(), time.getSeconds()); } return (t1 < t2) ? -1 : (t1 > t2) ? 1 : 0; }; this.equals = function (time) { return (this.compareTo(time) === 0); }; this.add = function (time) { return (time === null) ? this : this.addSeconds(time.getTotalMilliseconds() / 1000); }; this.subtract = function (time) { return (time === null) ? this : this.addSeconds(-time.getTotalMilliseconds() / 1000); }; this.addDays = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 86400000)); }; this.addHours = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 3600000)); }; this.addMinutes = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 60000)); }; this.addSeconds = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 1000)); }; this.addMilliseconds = function (n) { return new TimeSpan(this.getTotalMilliseconds() + n); }; this.get12HourHour = function () { return (this.getHours() > 12) ? this.getHours() - 12 : (this.getHours() === 0) ? 12 : this.getHours(); }; this.getDesignator = function () { return (this.getHours() < 12) ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator; }; this.toString = function (format) { this._toString = function () { if (this.getDays() !== null && this.getDays() > 0) { return this.getDays() + "." + this.getHours() + ":" + this.p(this.getMinutes()) + ":" + this.p(this.getSeconds()); } else { return this.getHours() + ":" + this.p(this.getMinutes()) + ":" + this.p(this.getSeconds()); } }; this.p = function (s) { return (s.toString().length < 2) ? "0" + s : s; }; var me = this; return format ? format.replace(/dd?|HH?|hh?|mm?|ss?|tt?/g, function (format) { switch (format) { case "d": return me.getDays(); case "dd": return me.p(me.getDays()); case "H": return me.getHours(); case "HH": return me.p(me.getHours()); case "h": return me.get12HourHour(); case "hh": return me.p(me.get12HourHour()); case "m": return me.getMinutes(); case "mm": return me.p(me.getMinutes()); case "s": return me.getSeconds(); case "ss": return me.p(me.getSeconds()); case "t": return ((me.getHours() < 12) ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator).substring(0, 1); case "tt": return (me.getHours() < 12) ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator; } } ) : this._toString(); }; return this; }; addSetFuncs(TimeSpan, attrs.slice(2)); TimeSpan.prototype.set = function (days, hours, minutes, seconds, milliseconds){ this.setDays(days || this.getDays()); this.setHours(hours || this.getHours()); this.setMinutes(minutes || this.getMinutes()); this.setSeconds(seconds || this.getSeconds()); this.setMilliseconds(milliseconds || this.getMilliseconds()); }; /** * Gets the time of day for this date instances. * @return {TimeSpan} TimeSpan */ Date.prototype.getTimeOfDay = function () { return new TimeSpan(0, this.getHours(), this.getMinutes(), this.getSeconds(), this.getMilliseconds()); }; Date.TimeSpan = TimeSpan; if (typeof window !== "undefined" ) { // keeping API compatible for v1.x window.TimeSpan = TimeSpan; } }()); (function () { "use strict"; var attrs = ["years", "months", "days", "hours", "minutes", "seconds", "milliseconds"]; var gFn = function (attr) { return function () { return this[attr]; }; }; var sFn = function (attr) { return function (val) { this[attr] = val; return this; }; }; var addSetFuncs = function (context, attrs) { for (var i = 0; i < attrs.length ; i++) { var $a = attrs[i], $b = $a.slice(0, 1).toUpperCase() + $a.slice(1); context.prototype[$a] = 0; context.prototype["get" + $b] = gFn($a); context.prototype["set" + $b] = sFn($a); } }; var setMonthsAndYears = function (orient, d1, d2, context) { function inc() { d1.addMonths(-orient); context.months++; if (context.months === 12) { context.years++; context.months = 0; } } if (orient === +1) { while (d1 > d2) { inc(); } } else { while (d1 < d2) { inc(); } } context.months--; context.months *= orient; context.years *= orient; }; var adjustForDST = function(orient, startDate, endDate) { var hasDSTMismatch = (false === (startDate.isDaylightSavingTime() === endDate.isDaylightSavingTime())); if (hasDSTMismatch && orient === 1) { startDate.addHours(-1); } else if (hasDSTMismatch) { startDate.addHours(1); } }; /** * TimePeriod(startDate, endDate); * TimePeriod(years, months, days, hours, minutes, seconds, milliseconds); */ var TimePeriod = function (years, months, days, hours, minutes, seconds, milliseconds) { if (arguments.length === 7) { this.set(years, months, days, hours, minutes, seconds, milliseconds); } else if (arguments.length === 2 && arguments[0] instanceof Date && arguments[1] instanceof Date) { var startDate = arguments[0].clone(); var endDate = arguments[1].clone(); var orient = (startDate > endDate) ? +1 : -1; this.dates = { start: arguments[0].clone(), end: arguments[1].clone() }; setMonthsAndYears(orient, startDate, endDate, this); adjustForDST(orient, startDate, endDate); // // TODO - adjust for DST var diff = endDate - startDate; if (diff !== 0) { var ts = new TimeSpan(diff); this.set(this.years, this.months, ts.getDays(), ts.getHours(), ts.getMinutes(), ts.getSeconds(), ts.getMilliseconds()); } } return this; }; // create all the set functions. addSetFuncs(TimePeriod, attrs); TimePeriod.prototype.set = function (years, months, days, hours, minutes, seconds, milliseconds){ this.setYears(years || this.getYears()); this.setMonths(months || this.getMonths()); this.setDays(days || this.getDays()); this.setHours(hours || this.getHours()); this.setMinutes(minutes || this.getMinutes()); this.setSeconds(seconds || this.getSeconds()); this.setMilliseconds(milliseconds || this.getMilliseconds()); }; Date.TimePeriod = TimePeriod; if (typeof window !== "undefined") { // keeping API compatible for v1.x window.TimePeriod = TimePeriod; } }()); ================================================ FILE: build/date-ar-SY.js ================================================ /** * @overview datejs * @version 1.0.0-rc3 * @author Gregory Wild-Smith * @copyright 2015 Gregory Wild-Smith * @license MIT * @homepage https://github.com/abritinthebay/datejs */ /* * DateJS Culture String File * Country Code: ar-SY * Name: Arabic (Syria) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["ar-SY"] = { "name": "ar-SY", "englishName": "Arabic (Syria)", "nativeName": "العربية (سوريا)", "Sunday": "الاحد", "Monday": "الاثنين", "Tuesday": "الثلاثاء", "Wednesday": "الاربعاء", "Thursday": "الخميس", "Friday": "الجمعة", "Saturday": "السبت", "Sun": "الاحد", "Mon": "الاثنين", "Tue": "الثلاثاء", "Wed": "الاربعاء", "Thu": "الخميس", "Fri": "الجمعة", "Sat": "السبت", "Su": "أ", "Mo": "ا", "Tu": "ث", "We": "أ", "Th": "خ", "Fr": "ج", "Sa": "س", "S_Sun_Initial": "أ", "M_Mon_Initial": "ا", "T_Tue_Initial": "ث", "W_Wed_Initial": "أ", "T_Thu_Initial": "خ", "F_Fri_Initial": "ج", "S_Sat_Initial": "س", "January": "كانون الثاني", "February": "شباط", "March": "آذار", "April": "نيسان", "May": "أيار", "June": "حزيران", "July": "تموز", "August": "آب", "September": "أيلول", "October": "تشرين الأول", "November": "تشرين الثاني", "December": "كانون الأول", "Jan_Abbr": "كانون الثاني", "Feb_Abbr": "شباط", "Mar_Abbr": "آذار", "Apr_Abbr": "نيسان", "May_Abbr": "أيار", "Jun_Abbr": "حزيران", "Jul_Abbr": "تموز", "Aug_Abbr": "آب", "Sep_Abbr": "أيلول", "Oct_Abbr": "تشرين الأول", "Nov_Abbr": "تشرين الثاني", "Dec_Abbr": "كانون الأول", "AM": "ص", "PM": "م", "firstDayOfWeek": 6, "twoDigitYearMax": 2029, "mdy": "dmy", "M/d/yyyy": "dd/MM/yyyy", "dddd, MMMM dd, yyyy": "dd MMMM, yyyy", "h:mm tt": "hh:mm tt", "h:mm:ss tt": "hh:mm:ss tt", "dddd, MMMM dd, yyyy h:mm:ss tt": "dd MMMM, yyyy hh:mm:ss tt", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "dd MMMM", "MMMM, yyyy": "MMMM, yyyy", "/jan(uary)?/": "كانون الثاني", "/feb(ruary)?/": "شباط", "/mar(ch)?/": "آذار", "/apr(il)?/": "نيسان", "/may/": "أيار", "/jun(e)?/": "حزيران", "/jul(y)?/": "تموز", "/aug(ust)?/": "آب", "/sep(t(ember)?)?/": "أيلول", "/oct(ober)?/": "تشرين الأول", "/nov(ember)?/": "تشرين الثاني", "/dec(ember)?/": "كانون الأول", "/^su(n(day)?)?/": "^الاحد", "/^mo(n(day)?)?/": "^ا(1)?", "/^tu(e(s(day)?)?)?/": "^الثلاثاء", "/^we(d(nesday)?)?/": "^الاربعاء", "/^th(u(r(s(day)?)?)?)?/": "^الخميس", "/^fr(i(day)?)?/": "^الجمعة", "/^sa(t(urday)?)?/": "^السبت", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "ar-SY"; /** * @overview datejs * @version 1.0.0-rc3 * @author Gregory Wild-Smith * @copyright 2015 Gregory Wild-Smith * @license MIT * @homepage https://github.com/abritinthebay/datejs */(function () { var $D = Date; var lang = Date.CultureStrings ? Date.CultureStrings.lang : null; var loggedKeys = {}; // for debug purposes. var getText = { getFromKey: function (key, countryCode) { var output; if (Date.CultureStrings && Date.CultureStrings[countryCode] && Date.CultureStrings[countryCode][key]) { output = Date.CultureStrings[countryCode][key]; } else { output = getText.buildFromDefault(key); } if (key.charAt(0) === "/") { // Assume it's a regex output = getText.buildFromRegex(key, countryCode); } return output; }, getFromObjectValues: function (obj, countryCode) { var key, output = {}; for(key in obj) { if (obj.hasOwnProperty(key)) { output[key] = getText.getFromKey(obj[key], countryCode); } } return output; }, getFromObjectKeys: function (obj, countryCode) { var key, output = {}; for(key in obj) { if (obj.hasOwnProperty(key)) { output[getText.getFromKey(key, countryCode)] = obj[key]; } } return output; }, getFromArray: function (arr, countryCode) { var output = []; for (var i=0; i < arr.length; i++){ if (i in arr) { output[i] = getText.getFromKey(arr[i], countryCode); } } return output; }, buildFromDefault: function (key) { var output, length, split, last; switch(key) { case "name": output = "en-US"; break; case "englishName": output = "English (United States)"; break; case "nativeName": output = "English (United States)"; break; case "twoDigitYearMax": output = 2049; break; case "firstDayOfWeek": output = 0; break; default: output = key; split = key.split("_"); length = split.length; if (length > 1 && key.charAt(0) !== "/") { // if the key isn't a regex and it has a split. last = split[(length - 1)].toLowerCase(); if (last === "initial" || last === "abbr") { output = split[0]; } } break; } return output; }, buildFromRegex: function (key, countryCode) { var output; if (Date.CultureStrings && Date.CultureStrings[countryCode] && Date.CultureStrings[countryCode][key]) { output = new RegExp(Date.CultureStrings[countryCode][key], "i"); } else { output = new RegExp(key.replace(new RegExp("/", "g"),""), "i"); } return output; } }; var shallowMerge = function (obj1, obj2) { for (var attrname in obj2) { if (obj2.hasOwnProperty(attrname)) { obj1[attrname] = obj2[attrname]; } } }; var __ = function (key, language) { var countryCode = (language) ? language : lang; loggedKeys[key] = key; if (typeof key === "object") { if (key instanceof Array) { return getText.getFromArray(key, countryCode); } else { return getText.getFromObjectKeys(key, countryCode); } } else { return getText.getFromKey(key, countryCode); } }; var loadI18nScript = function (code) { // paatterned after jQuery's getScript. var url = Date.Config.i18n + code + ".js"; var head = document.getElementsByTagName("head")[0] || document.documentElement; var script = document.createElement("script"); script.src = url; var completed = false; var events = { done: function (){} // placeholder function }; // Attach handlers for all browsers script.onload = script.onreadystatechange = function() { if ( !completed && (!this.readyState || this.readyState === "loaded" || this.readyState === "complete") ) { events.done(); head.removeChild(script); } }; setTimeout(function() { head.insertBefore(script, head.firstChild); }, 0); // allows return to execute first return { done: function (cb) { events.done = function() { if (cb) { setTimeout(cb,0); } }; } }; }; var buildInfo = { buildFromMethodHash: function (obj) { var key; for(key in obj) { if (obj.hasOwnProperty(key)) { obj[key] = buildInfo[obj[key]](); } } return obj; }, timeZoneDST: function () { var DST = { "CHADT": "+1345", "NZDT": "+1300", "AEDT": "+1100", "ACDT": "+1030", "AZST": "+0500", "IRDT": "+0430", "EEST": "+0300", "CEST": "+0200", "BST": "+0100", "PMDT": "-0200", "ADT": "-0300", "NDT": "-0230", "EDT": "-0400", "CDT": "-0500", "MDT": "-0600", "PDT": "-0700", "AKDT": "-0800", "HADT": "-0900" }; return __(DST); }, timeZoneStandard: function () { var standard = { "LINT": "+1400", "TOT": "+1300", "CHAST": "+1245", "NZST": "+1200", "NFT": "+1130", "SBT": "+1100", "AEST": "+1000", "ACST": "+0930", "JST": "+0900", "CWST": "+0845", "CT": "+0800", "ICT": "+0700", "MMT": "+0630", "BST": "+0600", "NPT": "+0545", "IST": "+0530", "PKT": "+0500", "AFT": "+0430", "MSK": "+0400", "IRST": "+0330", "FET": "+0300", "EET": "+0200", "CET": "+0100", "GMT": "+0000", "UTC": "+0000", "CVT": "-0100", "GST": "-0200", "BRT": "-0300", "NST": "-0330", "AST": "-0400", "EST": "-0500", "CST": "-0600", "MST": "-0700", "PST": "-0800", "AKST": "-0900", "MIT": "-0930", "HST": "-1000", "SST": "-1100", "BIT": "-1200" }; return __(standard); }, timeZones: function (data) { var zone; data.timezones = []; for (zone in data.abbreviatedTimeZoneStandard) { if (data.abbreviatedTimeZoneStandard.hasOwnProperty(zone)) { data.timezones.push({ name: zone, offset: data.abbreviatedTimeZoneStandard[zone]}); } } for (zone in data.abbreviatedTimeZoneDST) { if (data.abbreviatedTimeZoneDST.hasOwnProperty(zone)) { data.timezones.push({ name: zone, offset: data.abbreviatedTimeZoneDST[zone], dst: true}); } } return data.timezones; }, days: function () { return __(["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"]); }, dayAbbr: function () { return __(["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"]); }, dayShortNames: function () { return __(["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"]); }, dayFirstLetters: function () { return __(["S_Sun_Initial", "M_Mon_Initial", "T_Tues_Initial", "W_Wed_Initial", "T_Thu_Initial", "F_Fri_Initial", "S_Sat_Initial"]); }, months: function () { return __(["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"]); }, monthAbbr: function () { return __(["Jan_Abbr", "Feb_Abbr", "Mar_Abbr", "Apr_Abbr", "May_Abbr", "Jun_Abbr", "Jul_Abbr", "Aug_Abbr", "Sep_Abbr", "Oct_Abbr", "Nov_Abbr", "Dec_Abbr"]); }, formatPatterns: function () { return getText.getFromObjectValues({ shortDate: "M/d/yyyy", longDate: "dddd, MMMM dd, yyyy", shortTime: "h:mm tt", longTime: "h:mm:ss tt", fullDateTime: "dddd, MMMM dd, yyyy h:mm:ss tt", sortableDateTime: "yyyy-MM-ddTHH:mm:ss", universalSortableDateTime: "yyyy-MM-dd HH:mm:ssZ", rfc1123: "ddd, dd MMM yyyy HH:mm:ss", monthDay: "MMMM dd", yearMonth: "MMMM, yyyy" }, Date.i18n.currentLanguage()); }, regex: function () { return getText.getFromObjectValues({ inTheMorning: "/( in the )(morn(ing)?)\\b/", thisMorning: "/(this )(morn(ing)?)\\b/", amThisMorning: "/(\b\\d(am)? )(this )(morn(ing)?)/", inTheEvening: "/( in the )(even(ing)?)\\b/", thisEvening: "/(this )(even(ing)?)\\b/", pmThisEvening: "/(\b\\d(pm)? )(this )(even(ing)?)/", jan: "/jan(uary)?/", feb: "/feb(ruary)?/", mar: "/mar(ch)?/", apr: "/apr(il)?/", may: "/may/", jun: "/jun(e)?/", jul: "/jul(y)?/", aug: "/aug(ust)?/", sep: "/sep(t(ember)?)?/", oct: "/oct(ober)?/", nov: "/nov(ember)?/", dec: "/dec(ember)?/", sun: "/^su(n(day)?)?/", mon: "/^mo(n(day)?)?/", tue: "/^tu(e(s(day)?)?)?/", wed: "/^we(d(nesday)?)?/", thu: "/^th(u(r(s(day)?)?)?)?/", fri: "/fr(i(day)?)?/", sat: "/^sa(t(urday)?)?/", future: "/^next/", past: "/^last|past|prev(ious)?/", add: "/^(\\+|aft(er)?|from|hence)/", subtract: "/^(\\-|bef(ore)?|ago)/", yesterday: "/^yes(terday)?/", today: "/^t(od(ay)?)?/", tomorrow: "/^tom(orrow)?/", now: "/^n(ow)?/", millisecond: "/^ms|milli(second)?s?/", second: "/^sec(ond)?s?/", minute: "/^mn|min(ute)?s?/", hour: "/^h(our)?s?/", week: "/^w(eek)?s?/", month: "/^m(onth)?s?/", day: "/^d(ay)?s?/", year: "/^y(ear)?s?/", shortMeridian: "/^(a|p)/", longMeridian: "/^(a\\.?m?\\.?|p\\.?m?\\.?)/", timezone: "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/", ordinalSuffix: "/^\\s*(st|nd|rd|th)/", timeContext: "/^\\s*(\\:|a(?!u|p)|p)/" }, Date.i18n.currentLanguage()); } }; var CultureInfo = function () { var info = getText.getFromObjectValues({ name: "name", englishName: "englishName", nativeName: "nativeName", amDesignator: "AM", pmDesignator: "PM", firstDayOfWeek: "firstDayOfWeek", twoDigitYearMax: "twoDigitYearMax", dateElementOrder: "mdy" }, Date.i18n.currentLanguage()); var constructedInfo = buildInfo.buildFromMethodHash({ dayNames: "days", abbreviatedDayNames: "dayAbbr", shortestDayNames: "dayShortNames", firstLetterDayNames: "dayFirstLetters", monthNames: "months", abbreviatedMonthNames: "monthAbbr", formatPatterns: "formatPatterns", regexPatterns: "regex", abbreviatedTimeZoneDST: "timeZoneDST", abbreviatedTimeZoneStandard: "timeZoneStandard" }); shallowMerge(info, constructedInfo); buildInfo.timeZones(info); return info; }; $D.i18n = { __: function (key, lang) { return __(key, lang); }, currentLanguage: function () { return lang || "en-US"; }, setLanguage: function (code, force, cb) { var async = false; if (force || code === "en-US" || (!!Date.CultureStrings && !!Date.CultureStrings[code])) { lang = code; Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings.lang = code; Date.CultureInfo = new CultureInfo(); } else { if (!(!!Date.CultureStrings && !!Date.CultureStrings[code])) { if (typeof exports !== "undefined" && this.exports !== exports) { // we're in a Node enviroment, load it using require try { require("../i18n/" + code + ".js"); lang = code; Date.CultureStrings.lang = code; Date.CultureInfo = new CultureInfo(); } catch (e) { // var str = "The language for '" + code + "' could not be loaded by Node. It likely does not exist."; throw new Error("The DateJS IETF language tag '" + code + "' could not be loaded by Node. It likely does not exist."); } } else if (Date.Config && Date.Config.i18n) { // we know the location of the files, so lets load them async = true; loadI18nScript(code).done(function(){ lang = code; Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings.lang = code; Date.CultureInfo = new CultureInfo(); $D.Parsing.Normalizer.buildReplaceData(); // because this is async if ($D.Grammar) { $D.Grammar.buildGrammarFormats(); // so we can parse those strings... } if (cb) { setTimeout(cb,0); } }); } else { Date.console.error("The DateJS IETF language tag '" + code + "' is not available and has not been loaded."); return false; } } } $D.Parsing.Normalizer.buildReplaceData(); // rebuild normalizer strings if ($D.Grammar) { $D.Grammar.buildGrammarFormats(); // so we can parse those strings... } if (!async && cb) { setTimeout(cb,0); } }, getLoggedKeys: function () { return loggedKeys; }, updateCultureInfo: function () { Date.CultureInfo = new CultureInfo(); } }; $D.i18n.updateCultureInfo(); // run automatically }()); (function () { var $D = Date, $P = $D.prototype, p = function (s, l) { if (!l) { l = 2; } return ("000" + s).slice(l * -1); }; if (typeof window !== "undefined" && typeof window.console !== "undefined" && typeof window.console.log !== "undefined") { $D.console = console; // used only to raise non-critical errors if available } else { // set mock so we don't give errors. $D.console = { log: function(){}, error: function(){} }; } $D.Config = $D.Config || {}; $D.initOverloads = function() { /** * Overload of Date.now. Allows an alternate call for Date.now where it returns the * current Date as an object rather than just milliseconds since the Unix Epoch. * * Also provides an implementation of now() for browsers (IE<9) that don't have it. * * Backwards compatible so with work with either: * Date.now() [returns ms] * or * Date.now(true) [returns Date] */ if (!$D.now) { $D._now = function now() { return new Date().getTime(); }; } else if (!$D._now) { $D._now = $D.now; } $D.now = function (returnObj) { if (returnObj) { return $D.present(); } else { return $D._now(); } }; if ( !$P.toISOString ) { $P.toISOString = function() { return this.getUTCFullYear() + "-" + p(this.getUTCMonth() + 1) + "-" + p(this.getUTCDate()) + "T" + p(this.getUTCHours()) + ":" + p(this.getUTCMinutes()) + ":" + p(this.getUTCSeconds()) + "." + String( (this.getUTCMilliseconds()/1000).toFixed(3)).slice(2, 5) + "Z"; }; } // private if ( $P._toString === undefined ){ $P._toString = $P.toString; } }; $D.initOverloads(); /** * Gets a date that is set to the current date. The time is set to the start of the day (00:00 or 12:00 AM). * @return {Date} The current date. */ $D.today = function () { return new Date().clearTime(); }; /** * Gets a date that is set to the current date and time (same as new Date, but chainable) * @return {Date} The current date. */ $D.present = function () { return new Date(); }; /** * Compares the first date to the second date and returns an number indication of their relative values. * @param {Date} First Date object to compare [Required]. * @param {Date} Second Date object to compare to [Required]. * @return {Number} -1 = date1 is lessthan date2. 0 = values are equal. 1 = date1 is greaterthan date2. */ $D.compare = function (date1, date2) { if (isNaN(date1) || isNaN(date2)) { throw new Error(date1 + " - " + date2); } else if (date1 instanceof Date && date2 instanceof Date) { return (date1 < date2) ? -1 : (date1 > date2) ? 1 : 0; } else { throw new TypeError(date1 + " - " + date2); } }; /** * Compares the first Date object to the second Date object and returns true if they are equal. * @param {Date} First Date object to compare [Required] * @param {Date} Second Date object to compare to [Required] * @return {Boolean} true if dates are equal. false if they are not equal. */ $D.equals = function (date1, date2) { return (date1.compareTo(date2) === 0); }; /** * Gets the language appropriate day name when given the day number(0-6) * eg - 0 == Sunday * @return {String} The day name */ $D.getDayName = function (n) { return Date.CultureInfo.dayNames[n]; }; /** * Gets the day number (0-6) if given a CultureInfo specific string which is a valid dayName, abbreviatedDayName or shortestDayName (two char). * @param {String} The name of the day (eg. "Monday, "Mon", "tuesday", "tue", "We", "we"). * @return {Number} The day number */ $D.getDayNumberFromName = function (name) { var n = Date.CultureInfo.dayNames, m = Date.CultureInfo.abbreviatedDayNames, o = Date.CultureInfo.shortestDayNames, s = name.toLowerCase(); for (var i = 0; i < n.length; i++) { if (n[i].toLowerCase() === s || m[i].toLowerCase() === s || o[i].toLowerCase() === s) { return i; } } return -1; }; /** * Gets the month number (0-11) if given a Culture Info specific string which is a valid monthName or abbreviatedMonthName. * @param {String} The name of the month (eg. "February, "Feb", "october", "oct"). * @return {Number} The day number */ $D.getMonthNumberFromName = function (name) { var n = Date.CultureInfo.monthNames, m = Date.CultureInfo.abbreviatedMonthNames, s = name.toLowerCase(); for (var i = 0; i < n.length; i++) { if (n[i].toLowerCase() === s || m[i].toLowerCase() === s) { return i; } } return -1; }; /** * Gets the language appropriate month name when given the month number(0-11) * eg - 0 == January * @return {String} The month name */ $D.getMonthName = function (n) { return Date.CultureInfo.monthNames[n]; }; /** * Determines if the current date instance is within a LeapYear. * @param {Number} The year. * @return {Boolean} true if date is within a LeapYear, otherwise false. */ $D.isLeapYear = function (year) { return ((year % 4 === 0 && year % 100 !== 0) || year % 400 === 0); }; /** * Gets the number of days in the month, given a year and month value. Automatically corrects for LeapYear. * @param {Number} The year. * @param {Number} The month (0-11). * @return {Number} The number of days in the month. */ $D.getDaysInMonth = function (year, month) { if (!month && $D.validateMonth(year)) { month = year; year = Date.today().getFullYear(); } return [31, ($D.isLeapYear(year) ? 29 : 28), 31, 30, 31, 30, 31, 31, 30, 31, 30, 31][month]; }; $P.getDaysInMonth = function () { return $D.getDaysInMonth(this.getFullYear(), this.getMonth()); }; $D.getTimezoneAbbreviation = function (offset, dst) { var p, n = (dst || false) ? Date.CultureInfo.abbreviatedTimeZoneDST : Date.CultureInfo.abbreviatedTimeZoneStandard; for (p in n) { if (n.hasOwnProperty(p)) { if (n[p] === offset) { return p; } } } return null; }; $D.getTimezoneOffset = function (name, dst) { var i, a =[], z = Date.CultureInfo.timezones; if (!name) { name = (new Date()).getTimezone();} for (i = 0; i < z.length; i++) { if (z[i].name === name.toUpperCase()) { a.push(i); } } if (!z[a[0]]) { return null; } if (a.length === 1 || !dst) { return z[a[0]].offset; } else { for (i=0; i < a.length; i++) { if (z[a[i]].dst) { return z[a[i]].offset; } } } }; $D.getQuarter = function (d) { d = d || new Date(); // If no date supplied, use today var q = [1,2,3,4]; return q[Math.floor(d.getMonth() / 3)]; // ~~~ is a bitwise op. Faster than Math.floor }; $D.getDaysLeftInQuarter = function (d) { d = d || new Date(); var qEnd = new Date(d); qEnd.setMonth(qEnd.getMonth() + 3 - qEnd.getMonth() % 3, 0); return Math.floor((qEnd - d) / 8.64e7); }; // private var validate = function (n, min, max, name) { name = name ? name : "Object"; if (typeof n === "undefined") { return false; } else if (typeof n !== "number") { throw new TypeError(n + " is not a Number."); } else if (n < min || n > max) { // As failing validation is *not* an exceptional circumstance // lets not throw a RangeError Exception here. // It's semantically correct but it's not sensible. return false; } return true; }; /** * Validates the number is within an acceptable range for milliseconds [0-999]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateMillisecond = function (value) { return validate(value, 0, 999, "millisecond"); }; /** * Validates the number is within an acceptable range for seconds [0-59]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateSecond = function (value) { return validate(value, 0, 59, "second"); }; /** * Validates the number is within an acceptable range for minutes [0-59]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateMinute = function (value) { return validate(value, 0, 59, "minute"); }; /** * Validates the number is within an acceptable range for hours [0-23]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateHour = function (value) { return validate(value, 0, 23, "hour"); }; /** * Validates the number is within an acceptable range for the days in a month [0-MaxDaysInMonth]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateDay = function (value, year, month) { if (year === undefined || year === null || month === undefined || month === null) { return false;} return validate(value, 1, $D.getDaysInMonth(year, month), "day"); }; /** * Validates the number is within an acceptable range for months [0-11]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateWeek = function (value) { return validate(value, 0, 53, "week"); }; /** * Validates the number is within an acceptable range for months [0-11]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateMonth = function (value) { return validate(value, 0, 11, "month"); }; /** * Validates the number is within an acceptable range for years. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateYear = function (value) { /** * Per ECMAScript spec the range of times supported by Date objects is * exactly -100,000,000 days to +100,000,000 days measured relative to * midnight at the beginning of 01 January, 1970 UTC. * This gives a range of 8,640,000,000,000,000 milliseconds to either * side of 01 January, 1970 UTC. * * Earliest possible date: Tue, 20 Apr 271,822 B.C. 00:00:00 UTC * Latest possible date: Sat, 13 Sep 275,760 00:00:00 UTC */ return validate(value, -271822, 275760, "year"); }; $D.validateTimezone = function(value) { var timezones = {"ACDT":1,"ACST":1,"ACT":1,"ADT":1,"AEDT":1,"AEST":1,"AFT":1,"AKDT":1,"AKST":1,"AMST":1,"AMT":1,"ART":1,"AST":1,"AWDT":1,"AWST":1,"AZOST":1,"AZT":1,"BDT":1,"BIOT":1,"BIT":1,"BOT":1,"BRT":1,"BST":1,"BTT":1,"CAT":1,"CCT":1,"CDT":1,"CEDT":1,"CEST":1,"CET":1,"CHADT":1,"CHAST":1,"CHOT":1,"ChST":1,"CHUT":1,"CIST":1,"CIT":1,"CKT":1,"CLST":1,"CLT":1,"COST":1,"COT":1,"CST":1,"CT":1,"CVT":1,"CWST":1,"CXT":1,"DAVT":1,"DDUT":1,"DFT":1,"EASST":1,"EAST":1,"EAT":1,"ECT":1,"EDT":1,"EEDT":1,"EEST":1,"EET":1,"EGST":1,"EGT":1,"EIT":1,"EST":1,"FET":1,"FJT":1,"FKST":1,"FKT":1,"FNT":1,"GALT":1,"GAMT":1,"GET":1,"GFT":1,"GILT":1,"GIT":1,"GMT":1,"GST":1,"GYT":1,"HADT":1,"HAEC":1,"HAST":1,"HKT":1,"HMT":1,"HOVT":1,"HST":1,"ICT":1,"IDT":1,"IOT":1,"IRDT":1,"IRKT":1,"IRST":1,"IST":1,"JST":1,"KGT":1,"KOST":1,"KRAT":1,"KST":1,"LHST":1,"LINT":1,"MAGT":1,"MART":1,"MAWT":1,"MDT":1,"MET":1,"MEST":1,"MHT":1,"MIST":1,"MIT":1,"MMT":1,"MSK":1,"MST":1,"MUT":1,"MVT":1,"MYT":1,"NCT":1,"NDT":1,"NFT":1,"NPT":1,"NST":1,"NT":1,"NUT":1,"NZDT":1,"NZST":1,"OMST":1,"ORAT":1,"PDT":1,"PET":1,"PETT":1,"PGT":1,"PHOT":1,"PHT":1,"PKT":1,"PMDT":1,"PMST":1,"PONT":1,"PST":1,"PYST":1,"PYT":1,"RET":1,"ROTT":1,"SAKT":1,"SAMT":1,"SAST":1,"SBT":1,"SCT":1,"SGT":1,"SLST":1,"SRT":1,"SST":1,"SYOT":1,"TAHT":1,"THA":1,"TFT":1,"TJT":1,"TKT":1,"TLT":1,"TMT":1,"TOT":1,"TVT":1,"UCT":1,"ULAT":1,"UTC":1,"UYST":1,"UYT":1,"UZT":1,"VET":1,"VLAT":1,"VOLT":1,"VOST":1,"VUT":1,"WAKT":1,"WAST":1,"WAT":1,"WEDT":1,"WEST":1,"WET":1,"WST":1,"YAKT":1,"YEKT":1,"Z":1}; return (timezones[value] === 1); }; $D.validateTimezoneOffset= function(value) { // timezones go from +14hrs to -12hrs, the +X hours are negative offsets. return (value > -841 && value < 721); }; }()); (function () { var $D = Date, $P = $D.prototype, p = function (s, l) { if (!l) { l = 2; } return ("000" + s).slice(l * -1); }; var validateConfigObject = function (obj) { var result = {}, self = this, prop, testFunc; testFunc = function (prop, func, value) { if (prop === "day") { var month = (obj.month !== undefined) ? obj.month : self.getMonth(); var year = (obj.year !== undefined) ? obj.year : self.getFullYear(); return $D[func](value, year, month); } else { return $D[func](value); } }; for (prop in obj) { if (Object.prototype.hasOwnProperty.call(obj, prop)) { var func = "validate" + prop.charAt(0).toUpperCase() + prop.slice(1); if ($D[func] && obj[prop] !== null && testFunc(prop, func, obj[prop])) { result[prop] = obj[prop]; } } } return result; }; /** * Resets the time of this Date object to 12:00 AM (00:00), which is the start of the day. * @param {Boolean} .clone() this date instance before clearing Time * @return {Date} this */ $P.clearTime = function () { this.setHours(0); this.setMinutes(0); this.setSeconds(0); this.setMilliseconds(0); return this; }; /** * Resets the time of this Date object to the current time ('now'). * @return {Date} this */ $P.setTimeToNow = function () { var n = new Date(); this.setHours(n.getHours()); this.setMinutes(n.getMinutes()); this.setSeconds(n.getSeconds()); this.setMilliseconds(n.getMilliseconds()); return this; }; /** * Returns a new Date object that is an exact date and time copy of the original instance. * @return {Date} A new Date instance */ $P.clone = function () { return new Date(this.getTime()); }; /** * Compares this instance to a Date object and returns an number indication of their relative values. * @param {Date} Date object to compare [Required] * @return {Number} -1 = this is lessthan date. 0 = values are equal. 1 = this is greaterthan date. */ $P.compareTo = function (date) { return Date.compare(this, date); }; /** * Compares this instance to another Date object and returns true if they are equal. * @param {Date} Date object to compare. If no date to compare, new Date() [now] is used. * @return {Boolean} true if dates are equal. false if they are not equal. */ $P.equals = function (date) { return Date.equals(this, (date !== undefined ? date : new Date())); }; /** * Determines if this instance is between a range of two dates or equal to either the start or end dates. * @param {Date} Start of range [Required] * @param {Date} End of range [Required] * @return {Boolean} true is this is between or equal to the start and end dates, else false */ $P.between = function (start, end) { return this.getTime() >= start.getTime() && this.getTime() <= end.getTime(); }; /** * Determines if this date occurs after the date to compare to. * @param {Date} Date object to compare. If no date to compare, new Date() ("now") is used. * @return {Boolean} true if this date instance is greater than the date to compare to (or "now"), otherwise false. */ $P.isAfter = function (date) { return this.compareTo(date || new Date()) === 1; }; /** * Determines if this date occurs before the date to compare to. * @param {Date} Date object to compare. If no date to compare, new Date() ("now") is used. * @return {Boolean} true if this date instance is less than the date to compare to (or "now"). */ $P.isBefore = function (date) { return (this.compareTo(date || new Date()) === -1); }; /** * Determines if the current Date instance occurs today. * @return {Boolean} true if this date instance is 'today', otherwise false. */ /** * Determines if the current Date instance occurs on the same Date as the supplied 'date'. * If no 'date' to compare to is provided, the current Date instance is compared to 'today'. * @param {date} Date object to compare. If no date to compare, the current Date ("now") is used. * @return {Boolean} true if this Date instance occurs on the same Day as the supplied 'date'. */ $P.isToday = $P.isSameDay = function (date) { return this.clone().clearTime().equals((date || new Date()).clone().clearTime()); }; /** * Adds the specified number of milliseconds to this instance. * @param {Number} The number of milliseconds to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addMilliseconds = function (value) { if (!value) { return this; } this.setTime(this.getTime() + value * 1); return this; }; /** * Adds the specified number of seconds to this instance. * @param {Number} The number of seconds to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addSeconds = function (value) { if (!value) { return this; } return this.addMilliseconds(value * 1000); }; /** * Adds the specified number of seconds to this instance. * @param {Number} The number of seconds to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addMinutes = function (value) { if (!value) { return this; } return this.addMilliseconds(value * 60000); // 60*1000 }; /** * Adds the specified number of hours to this instance. * @param {Number} The number of hours to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addHours = function (value) { if (!value) { return this; } return this.addMilliseconds(value * 3600000); // 60*60*1000 }; /** * Adds the specified number of days to this instance. * @param {Number} The number of days to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addDays = function (value) { if (!value) { return this; } this.setDate(this.getDate() + value * 1); return this; }; /** * Adds the specified number of weekdays (ie - not sat or sun) to this instance. * @param {Number} The number of days to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addWeekdays = function (value) { if (!value) { return this; } var day = this.getDay(); var weeks = (Math.ceil(Math.abs(value)/7)); if (day === 0 || day === 6) { if (value > 0) { this.next().monday(); this.addDays(-1); day = this.getDay(); } } if (value < 0) { while (value < 0) { this.addDays(-1); day = this.getDay(); if (day !== 0 && day !== 6) { value++; } } return this; } else if (value > 5 || (6-day) <= value) { value = value + (weeks * 2); } return this.addDays(value); }; /** * Adds the specified number of weeks to this instance. * @param {Number} The number of weeks to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addWeeks = function (value) { if (!value) { return this; } return this.addDays(value * 7); }; /** * Adds the specified number of months to this instance. * @param {Number} The number of months to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addMonths = function (value) { if (!value) { return this; } var n = this.getDate(); this.setDate(1); this.setMonth(this.getMonth() + value * 1); this.setDate(Math.min(n, $D.getDaysInMonth(this.getFullYear(), this.getMonth()))); return this; }; $P.addQuarters = function (value) { if (!value) { return this; } // note this will take you to the same point in the quarter as you are now. // i.e. - if you are 15 days into the quarter you'll be 15 days into the resulting one. // bonus: this allows adding fractional quarters return this.addMonths(value * 3); }; /** * Adds the specified number of years to this instance. * @param {Number} The number of years to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addYears = function (value) { if (!value) { return this; } return this.addMonths(value * 12); }; /** * Adds (or subtracts) to the value of the years, months, weeks, days, hours, minutes, seconds, milliseconds of the date instance using given configuration object. Positive and Negative values allowed. * Example

	Date.today().add( { days: 1, months: 1 } )

	new Date().add( { years: -1 } )
	
* @param {Object} Configuration object containing attributes (months, days, etc.) * @return {Date} this */ $P.add = function (config) { if (typeof config === "number") { this._orient = config; return this; } var x = config; if (x.day) { // If we should be a different date than today (eg: for 'tomorrow -1d', etc). // Should only effect parsing, not direct usage (eg, Finish and FinishExact) if ((x.day - this.getDate()) !== 0) { this.setDate(x.day); } } if (x.milliseconds) { this.addMilliseconds(x.milliseconds); } if (x.seconds) { this.addSeconds(x.seconds); } if (x.minutes) { this.addMinutes(x.minutes); } if (x.hours) { this.addHours(x.hours); } if (x.weeks) { this.addWeeks(x.weeks); } if (x.months) { this.addMonths(x.months); } if (x.years) { this.addYears(x.years); } if (x.days) { this.addDays(x.days); } return this; }; /** * Get the week number. Week one (1) is the week which contains the first Thursday of the year. Monday is considered the first day of the week. * The .getWeek() function does NOT convert the date to UTC. The local datetime is used. * Please use .getISOWeek() to get the week of the UTC converted date. * @return {Number} 1 to 53 */ $P.getWeek = function (utc) { // Create a copy of this date object var self, target = new Date(this.valueOf()); if (utc) { target.addMinutes(target.getTimezoneOffset()); self = target.clone(); } else { self = this; } // ISO week date weeks start on monday // so correct the day number var dayNr = (self.getDay() + 6) % 7; // ISO 8601 states that week 1 is the week // with the first thursday of that year. // Set the target date to the thursday in the target week target.setDate(target.getDate() - dayNr + 3); // Store the millisecond value of the target date var firstThursday = target.valueOf(); // Set the target to the first thursday of the year // First set the target to january first target.setMonth(0, 1); // Not a thursday? Correct the date to the next thursday if (target.getDay() !== 4) { target.setMonth(0, 1 + ((4 - target.getDay()) + 7) % 7); } // The weeknumber is the number of weeks between the // first thursday of the year and the thursday in the target week return 1 + Math.ceil((firstThursday - target) / 604800000); // 604800000 = 7 * 24 * 3600 * 1000 }; /** * Get the ISO 8601 week number. Week one ("01") is the week which contains the first Thursday of the year. Monday is considered the first day of the week. * The .getISOWeek() function does convert the date to it's UTC value. Please use .getWeek() to get the week of the local date. * @return {String} "01" to "53" */ $P.getISOWeek = function () { return p(this.getWeek(true)); }; /** * Moves the date to Monday of the week set. Week one (1) is the week which contains the first Thursday of the year. * @param {Number} A Number (1 to 53) that represents the week of the year. * @return {Date} this */ $P.setWeek = function (n) { if ((n - this.getWeek()) === 0) { if (this.getDay() !== 1) { return this.moveToDayOfWeek(1, (this.getDay() > 1 ? -1 : 1)); } else { return this; } } else { return this.moveToDayOfWeek(1, (this.getDay() > 1 ? -1 : 1)).addWeeks(n - this.getWeek()); } }; $P.setQuarter = function (qtr) { var month = Math.abs(((qtr-1) * 3) + 1); return this.setMonth(month, 1); }; $P.getQuarter = function () { return Date.getQuarter(this); }; $P.getDaysLeftInQuarter = function () { return Date.getDaysLeftInQuarter(this); }; /** * Moves the date to the next n'th occurrence of the dayOfWeek starting from the beginning of the month. The number (-1) is a magic number and will return the last occurrence of the dayOfWeek in the month. * @param {Number} The dayOfWeek to move to * @param {Number} The n'th occurrence to move to. Use (-1) to return the last occurrence in the month * @return {Date} this */ $P.moveToNthOccurrence = function (dayOfWeek, occurrence) { if (dayOfWeek === "Weekday") { if (occurrence > 0) { this.moveToFirstDayOfMonth(); if (this.is().weekday()) { occurrence -= 1; } } else if (occurrence < 0) { this.moveToLastDayOfMonth(); if (this.is().weekday()) { occurrence += 1; } } else { return this; } return this.addWeekdays(occurrence); } var shift = 0; if (occurrence > 0) { shift = occurrence - 1; } else if (occurrence === -1) { this.moveToLastDayOfMonth(); if (this.getDay() !== dayOfWeek) { this.moveToDayOfWeek(dayOfWeek, -1); } return this; } return this.moveToFirstDayOfMonth().addDays(-1).moveToDayOfWeek(dayOfWeek, +1).addWeeks(shift); }; var moveToN = function (getFunc, addFunc, nVal) { return function (value, orient) { var diff = (value - this[getFunc]() + nVal * (orient || +1)) % nVal; return this[addFunc]((diff === 0) ? diff += nVal * (orient || +1) : diff); }; }; /** * Move to the next or last dayOfWeek based on the orient value. * @param {Number} The dayOfWeek to move to * @param {Number} Forward (+1) or Back (-1). Defaults to +1. [Optional] * @return {Date} this */ $P.moveToDayOfWeek = moveToN("getDay", "addDays", 7); /** * Move to the next or last month based on the orient value. * @param {Number} The month to move to. 0 = January, 11 = December * @param {Number} Forward (+1) or Back (-1). Defaults to +1. [Optional] * @return {Date} this */ $P.moveToMonth = moveToN("getMonth", "addMonths", 12); /** * Get the Ordinate of the current day ("th", "st", "rd"). * @return {String} */ $P.getOrdinate = function () { var num = this.getDate(); return ord(num); }; /** * Get the Ordinal day (numeric day number) of the year, adjusted for leap year. * @return {Number} 1 through 365 (366 in leap years) */ $P.getOrdinalNumber = function () { return Math.ceil((this.clone().clearTime() - new Date(this.getFullYear(), 0, 1)) / 86400000) + 1; }; /** * Get the time zone abbreviation of the current date. * @return {String} The abbreviated time zone name (e.g. "EST") */ $P.getTimezone = function () { return $D.getTimezoneAbbreviation(this.getUTCOffset(), this.isDaylightSavingTime()); }; $P.setTimezoneOffset = function (offset) { var here = this.getTimezoneOffset(), there = Number(offset) * -6 / 10; return (there || there === 0) ? this.addMinutes(there - here) : this; }; $P.setTimezone = function (offset) { return this.setTimezoneOffset($D.getTimezoneOffset(offset)); }; /** * Indicates whether Daylight Saving Time is observed in the current time zone. * @return {Boolean} true|false */ $P.hasDaylightSavingTime = function () { return (Date.today().set({month: 0, day: 1}).getTimezoneOffset() !== Date.today().set({month: 6, day: 1}).getTimezoneOffset()); }; /** * Indicates whether this Date instance is within the Daylight Saving Time range for the current time zone. * @return {Boolean} true|false */ $P.isDaylightSavingTime = function () { return Date.today().set({month: 0, day: 1}).getTimezoneOffset() !== this.getTimezoneOffset(); }; /** * Get the offset from UTC of the current date. * @return {String} The 4-character offset string prefixed with + or - (e.g. "-0500") */ $P.getUTCOffset = function (offset) { var n = (offset || this.getTimezoneOffset()) * -10 / 6, r; if (n < 0) { r = (n - 10000).toString(); return r.charAt(0) + r.substr(2); } else { r = (n + 10000).toString(); return "+" + r.substr(1); } }; /** * Returns the number of milliseconds between this date and date. * @param {Date} Defaults to now * @return {Number} The diff in milliseconds */ $P.getElapsed = function (date) { return (date || new Date()) - this; }; /** * Set the value of year, month, day, hour, minute, second, millisecond of date instance using given configuration object. * Example

	Date.today().set( { day: 20, month: 1 } )

	new Date().set( { millisecond: 0 } )
	
* * @param {Object} Configuration object containing attributes (month, day, etc.) * @return {Date} this */ $P.set = function (config) { config = validateConfigObject.call(this, config); var key; for (key in config) { if (Object.prototype.hasOwnProperty.call(config, key)) { var name = key.charAt(0).toUpperCase() + key.slice(1); var addFunc, getFunc; if (key !== "week" && key !== "month" && key !== "timezone" && key !== "timezoneOffset") { name += "s"; } addFunc = "add" + name; getFunc = "get" + name; if (key === "month") { addFunc = addFunc + "s"; } else if (key === "year"){ getFunc = "getFullYear"; } if (key !== "day" && key !== "timezone" && key !== "timezoneOffset" && key !== "week" && key !== "hour") { this[addFunc](config[key] - this[getFunc]()); } else if ( key === "timezone"|| key === "timezoneOffset" || key === "week" || key === "hour") { this["set"+name](config[key]); } } } // day has to go last because you can't validate the day without first knowing the month if (config.day) { this.addDays(config.day - this.getDate()); } return this; }; /** * Moves the date to the first day of the month. * @return {Date} this */ $P.moveToFirstDayOfMonth = function () { return this.set({ day: 1 }); }; /** * Moves the date to the last day of the month. * @return {Date} this */ $P.moveToLastDayOfMonth = function () { return this.set({ day: $D.getDaysInMonth(this.getFullYear(), this.getMonth())}); }; /** * Converts the value of the current Date object to its equivalent string representation. * Format Specifiers * CUSTOM DATE AND TIME FORMAT STRINGS * Format Description Example * ------ --------------------------------------------------------------------------- ----------------------- * s The seconds of the minute between 0-59. "0" to "59" * ss The seconds of the minute with leading zero if required. "00" to "59" * * m The minute of the hour between 0-59. "0" or "59" * mm The minute of the hour with leading zero if required. "00" or "59" * * h The hour of the day between 1-12. "1" to "12" * hh The hour of the day with leading zero if required. "01" to "12" * * H The hour of the day between 0-23. "0" to "23" * HH The hour of the day with leading zero if required. "00" to "23" * * d The day of the month between 1 and 31. "1" to "31" * dd The day of the month with leading zero if required. "01" to "31" * ddd Abbreviated day name. Date.CultureInfo.abbreviatedDayNames. "Mon" to "Sun" * dddd The full day name. Date.CultureInfo.dayNames. "Monday" to "Sunday" * * M The month of the year between 1-12. "1" to "12" * MM The month of the year with leading zero if required. "01" to "12" * MMM Abbreviated month name. Date.CultureInfo.abbreviatedMonthNames. "Jan" to "Dec" * MMMM The full month name. Date.CultureInfo.monthNames. "January" to "December" * * yy The year as a two-digit number. "99" or "08" * yyyy The full four digit year. "1999" or "2008" * * t Displays the first character of the A.M./P.M. designator. "A" or "P" * Date.CultureInfo.amDesignator or Date.CultureInfo.pmDesignator * tt Displays the A.M./P.M. designator. "AM" or "PM" * Date.CultureInfo.amDesignator or Date.CultureInfo.pmDesignator * * S The ordinal suffix ("st, "nd", "rd" or "th") of the current day. "st, "nd", "rd" or "th" * * STANDARD DATE AND TIME FORMAT STRINGS * Format Description Example *------ --------------------------------------------------------------------------- ----------------------- * d The CultureInfo shortDate Format Pattern "M/d/yyyy" * D The CultureInfo longDate Format Pattern "dddd, MMMM dd, yyyy" * F The CultureInfo fullDateTime Format Pattern "dddd, MMMM dd, yyyy h:mm:ss tt" * m The CultureInfo monthDay Format Pattern "MMMM dd" * r The CultureInfo rfc1123 Format Pattern "ddd, dd MMM yyyy HH:mm:ss GMT" * s The CultureInfo sortableDateTime Format Pattern "yyyy-MM-ddTHH:mm:ss" * t The CultureInfo shortTime Format Pattern "h:mm tt" * T The CultureInfo longTime Format Pattern "h:mm:ss tt" * u The CultureInfo universalSortableDateTime Format Pattern "yyyy-MM-dd HH:mm:ssZ" * y The CultureInfo yearMonth Format Pattern "MMMM, yyyy" * * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @return {String} A string representation of the current Date object. */ var ord = function (n) { switch (n * 1) { case 1: case 21: case 31: return "st"; case 2: case 22: return "nd"; case 3: case 23: return "rd"; default: return "th"; } }; var parseStandardFormats = function (format) { var y, c = Date.CultureInfo.formatPatterns; switch (format) { case "d": return this.toString(c.shortDate); case "D": return this.toString(c.longDate); case "F": return this.toString(c.fullDateTime); case "m": return this.toString(c.monthDay); case "r": case "R": y = this.clone().addMinutes(this.getTimezoneOffset()); return y.toString(c.rfc1123) + " GMT"; case "s": return this.toString(c.sortableDateTime); case "t": return this.toString(c.shortTime); case "T": return this.toString(c.longTime); case "u": y = this.clone().addMinutes(this.getTimezoneOffset()); return y.toString(c.universalSortableDateTime); case "y": return this.toString(c.yearMonth); default: return false; } }; var parseFormatStringsClosure = function (context) { return function (m) { if (m.charAt(0) === "\\") { return m.replace("\\", ""); } switch (m) { case "hh": return p(context.getHours() < 13 ? (context.getHours() === 0 ? 12 : context.getHours()) : (context.getHours() - 12)); case "h": return context.getHours() < 13 ? (context.getHours() === 0 ? 12 : context.getHours()) : (context.getHours() - 12); case "HH": return p(context.getHours()); case "H": return context.getHours(); case "mm": return p(context.getMinutes()); case "m": return context.getMinutes(); case "ss": return p(context.getSeconds()); case "s": return context.getSeconds(); case "yyyy": return p(context.getFullYear(), 4); case "yy": return p(context.getFullYear()); case "y": return context.getFullYear(); case "E": case "dddd": return Date.CultureInfo.dayNames[context.getDay()]; case "ddd": return Date.CultureInfo.abbreviatedDayNames[context.getDay()]; case "dd": return p(context.getDate()); case "d": return context.getDate(); case "MMMM": return Date.CultureInfo.monthNames[context.getMonth()]; case "MMM": return Date.CultureInfo.abbreviatedMonthNames[context.getMonth()]; case "MM": return p((context.getMonth() + 1)); case "M": return context.getMonth() + 1; case "t": return context.getHours() < 12 ? Date.CultureInfo.amDesignator.substring(0, 1) : Date.CultureInfo.pmDesignator.substring(0, 1); case "tt": return context.getHours() < 12 ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator; case "S": return ord(context.getDate()); case "W": return context.getWeek(); case "WW": return context.getISOWeek(); case "Q": return "Q" + context.getQuarter(); case "q": return String(context.getQuarter()); case "z": return context.getTimezone(); case "Z": case "X": return Date.getTimezoneOffset(context.getTimezone()); case "ZZ": // Timezone offset in seconds return context.getTimezoneOffset() * -60; case "u": return context.getDay(); case "L": return ($D.isLeapYear(context.getFullYear())) ? 1 : 0; case "B": // Swatch Internet Time (.beats) return "@"+((context.getUTCSeconds() + (context.getUTCMinutes()*60) + ((context.getUTCHours()+1)*3600))/86.4); default: return m; } }; }; $P.toString = function (format, ignoreStandards) { // Standard Date and Time Format Strings. Formats pulled from CultureInfo file and // may vary by culture. if (!ignoreStandards && format && format.length === 1) { output = parseStandardFormats.call(this, format); if (output) { return output; } } var parseFormatStrings = parseFormatStringsClosure(this); return format ? format.replace(/((\\)?(dd?d?d?|MM?M?M?|yy?y?y?|hh?|HH?|mm?|ss?|tt?|S|q|Q|WW?W?W?)(?![^\[]*\]))/g, parseFormatStrings).replace(/\[|\]/g, "") : this._toString(); }; }()); /************************************************************* * SugarPak - Domain Specific Language - Syntactical Sugar * *************************************************************/ (function () { var $D = Date, $P = $D.prototype, $N = Number.prototype; // private $P._orient = +1; // private $P._nth = null; // private $P._is = false; // private $P._same = false; // private $P._isSecond = false; // private $N._dateElement = "days"; /** * Moves the date to the next instance of a date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.today().next().friday();
	Date.today().next().fri();
	Date.today().next().march();
	Date.today().next().mar();
	Date.today().next().week();
	
* * @return {Date} date */ $P.next = function () { this._move = true; this._orient = +1; return this; }; /** * Creates a new Date (Date.today()) and moves the date to the next instance of the date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.next().friday();
	Date.next().fri();
	Date.next().march();
	Date.next().mar();
	Date.next().week();
	
* * @return {Date} date */ $D.next = function () { return $D.today().next(); }; /** * Moves the date to the previous instance of a date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.today().last().friday();
	Date.today().last().fri();
	Date.today().last().march();
	Date.today().last().mar();
	Date.today().last().week();
	
* * @return {Date} date */ $P.last = $P.prev = $P.previous = function () { this._move = true; this._orient = -1; return this; }; /** * Creates a new Date (Date.today()) and moves the date to the previous instance of the date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.last().friday();
	Date.last().fri();
	Date.previous().march();
	Date.prev().mar();
	Date.last().week();
	
* * @return {Date} date */ $D.last = $D.prev = $D.previous = function () { return $D.today().last(); }; /** * Performs a equality check when followed by either a month name, day name or .weekday() function. * Example

	Date.today().is().friday(); // true|false
	Date.today().is().fri();
	Date.today().is().march();
	Date.today().is().mar();
	
* * @return {Boolean} true|false */ $P.is = function () { this._is = true; return this; }; /** * Determines if two date objects occur on/in exactly the same instance of the subsequent date part function. * The function .same() must be followed by a date part function (example: .day(), .month(), .year(), etc). * * An optional Date can be passed in the date part function. If now date is passed as a parameter, 'Now' is used. * * The following example demonstrates how to determine if two dates fall on the exact same day. * * Example

	var d1 = Date.today(); // today at 00:00
	var d2 = new Date();   // exactly now.

	// Do they occur on the same day?
	d1.same().day(d2); // true
	
	// Do they occur on the same hour?
	d1.same().hour(d2); // false, unless d2 hour is '00' (midnight).
	
	// What if it's the same day, but one year apart?
	var nextYear = Date.today().add(1).year();

	d1.same().day(nextYear); // false, because the dates must occur on the exact same day. 
	
* * Scenario: Determine if a given date occurs during some week period 2 months from now. * * Example

	var future = Date.today().add(2).months();
	return someDate.same().week(future); // true|false;
	
* * @return {Boolean} true|false */ $P.same = function () { this._same = true; this._isSecond = false; return this; }; /** * Determines if the current date/time occurs during Today. Must be preceded by the .is() function. * Example

	someDate.is().today();    // true|false
	new Date().is().today();  // true
	Date.today().is().today();// true
	Date.today().add(-1).day().is().today(); // false
	
* * @return {Boolean} true|false */ $P.today = function () { return this.same().day(); }; /** * Determines if the current date is a weekday. This function must be preceded by the .is() function. * Example

	Date.today().is().weekday(); // true|false
	
* * @return {Boolean} true|false */ $P.weekday = function () { if (this._nth) { return df("Weekday").call(this); } if (this._move) { return this.addWeekdays(this._orient); } if (this._is) { this._is = false; return (!this.is().sat() && !this.is().sun()); } return false; }; /** * Determines if the current date is on the weekend. This function must be preceded by the .is() function. * Example

	Date.today().is().weekend(); // true|false
	
* * @return {Boolean} true|false */ $P.weekend = function () { if (this._is) { this._is = false; return (this.is().sat() || this.is().sun()); } return false; }; /** * Sets the Time of the current Date instance. A string "6:15 pm" or config object {hour:18, minute:15} are accepted. * Example

	// Set time to 6:15pm with a String
	Date.today().at("6:15pm");

	// Set time to 6:15pm with a config object
	Date.today().at({hour:18, minute:15});
	
* * @return {Date} date */ $P.at = function (time) { return (typeof time === "string") ? $D.parse(this.toString("d") + " " + time) : this.set(time); }; /** * Creates a new Date() and adds this (Number) to the date based on the preceding date element function (eg. second|minute|hour|day|month|year). * Example

	// Undeclared Numbers must be wrapped with parentheses. Requirment of JavaScript.
	(3).days().fromNow();
	(6).months().fromNow();

	// Declared Number variables do not require parentheses. 
	var n = 6;
	n.months().fromNow();
	
* * @return {Date} A new Date instance */ $N.fromNow = $N.after = function (date) { var c = {}; c[this._dateElement] = this; return ((!date) ? new Date() : date.clone()).add(c); }; /** * Creates a new Date() and subtract this (Number) from the date based on the preceding date element function (eg. second|minute|hour|day|month|year). * Example

	// Undeclared Numbers must be wrapped with parentheses. Requirment of JavaScript.
	(3).days().ago();
	(6).months().ago();

	// Declared Number variables do not require parentheses. 
	var n = 6;
	n.months().ago();
	
* * @return {Date} A new Date instance */ $N.ago = $N.before = function (date) { var c = {}, s = (this._dateElement[this._dateElement.length-1] !== "s") ? this._dateElement + "s" : this._dateElement; c[s] = this * -1; return ((!date) ? new Date() : date.clone()).add(c); }; // Do NOT modify the following string tokens. These tokens are used to build dynamic functions. // All culture-specific strings can be found in the CultureInfo files. var dx = ("sunday monday tuesday wednesday thursday friday saturday").split(/\s/), mx = ("january february march april may june july august september october november december").split(/\s/), px = ("Millisecond Second Minute Hour Day Week Month Year Quarter Weekday").split(/\s/), pxf = ("Milliseconds Seconds Minutes Hours Date Week Month FullYear Quarter").split(/\s/), nth = ("final first second third fourth fifth").split(/\s/), de; /** * Returns an object literal of all the date parts. * Example

	var o = new Date().toObject();
	
	// { year: 2008, month: 4, week: 20, day: 13, hour: 18, minute: 9, second: 32, millisecond: 812 }
	
	// The object properties can be referenced directly from the object.
	
	alert(o.day);  // alerts "13"
	alert(o.year); // alerts "2008"
	
* * @return {Date} An object literal representing the original date object. */ $P.toObject = function () { var o = {}; for (var i = 0; i < px.length; i++) { if (this["get" + pxf[i]]) { o[px[i].toLowerCase()] = this["get" + pxf[i]](); } } return o; }; /** * Returns a date created from an object literal. Ignores the .week property if set in the config. * Example

	var o = new Date().toObject();
	
	return Date.fromObject(o); // will return the same date. 

	var o2 = {month: 1, day: 20, hour: 18}; // birthday party!
	Date.fromObject(o2);
	
* * @return {Date} An object literal representing the original date object. */ $D.fromObject = function(config) { config.week = null; return Date.today().set(config); }; // Create day name functions and abbreviated day name functions (eg. monday(), friday(), fri()). var df = function (n) { return function () { if (this._is) { this._is = false; return this.getDay() === n; } if (this._move) { this._move = null; } if (this._nth !== null) { // If the .second() function was called earlier, remove the _orient // from the date, and then continue. // This is required because 'second' can be used in two different context. // // Example // // Date.today().add(1).second(); // Date.march().second().monday(); // // Things get crazy with the following... // Date.march().add(1).second().second().monday(); // but it works!! // if (this._isSecond) { this.addSeconds(this._orient * -1); } // make sure we reset _isSecond this._isSecond = false; var ntemp = this._nth; this._nth = null; var temp = this.clone().moveToLastDayOfMonth(); this.moveToNthOccurrence(n, ntemp); if (this > temp) { throw new RangeError($D.getDayName(n) + " does not occur " + ntemp + " times in the month of " + $D.getMonthName(temp.getMonth()) + " " + temp.getFullYear() + "."); } return this; } return this.moveToDayOfWeek(n, this._orient); }; }; var sdf = function (n) { return function () { var t = $D.today(), shift = n - t.getDay(); if (n === 0 && Date.CultureInfo.firstDayOfWeek === 1 && t.getDay() !== 0) { shift = shift + 7; } return t.addDays(shift); }; }; // Create month name functions and abbreviated month name functions (eg. january(), march(), mar()). var month_instance_functions = function (n) { return function () { if (this._is) { this._is = false; return this.getMonth() === n; } return this.moveToMonth(n, this._orient); }; }; var month_static_functions = function (n) { return function () { return $D.today().set({ month: n, day: 1 }); }; }; var processTerms = function (names, staticFunc, instanceFunc) { for (var i = 0; i < names.length; i++) { // Create constant static Name variables. $D[names[i].toUpperCase()] = $D[names[i].toUpperCase().substring(0, 3)] = i; // Create Name functions. $D[names[i]] = $D[names[i].substring(0, 3)] = staticFunc(i); // Create Name instance functions. $P[names[i]] = $P[names[i].substring(0, 3)] = instanceFunc(i); } }; processTerms(dx, sdf, df); processTerms(mx, month_static_functions, month_instance_functions); // Create date element functions and plural date element functions used with Date (eg. day(), days(), months()). var ef = function (j) { return function () { // if the .second() function was called earlier, the _orient // has alread been added. Just return this and reset _isSecond. if (this._isSecond) { this._isSecond = false; return this; } if (this._same) { this._same = this._is = false; var o1 = this.toObject(), o2 = (arguments[0] || new Date()).toObject(), v = "", k = j.toLowerCase(); // the substr trick with -1 doesn't work in IE8 or less k = (k[k.length-1] === "s") ? k.substring(0,k.length-1) : k; for (var m = (px.length - 1); m > -1; m--) { v = px[m].toLowerCase(); if (o1[v] !== o2[v]) { return false; } if (k === v) { break; } } return true; } if (j.substring(j.length - 1) !== "s") { j += "s"; } if (this._move) { this._move = null; } return this["add" + j](this._orient); }; }; var nf = function (n) { return function () { this._dateElement = n; return this; }; }; for (var k = 0; k < px.length; k++) { de = px[k].toLowerCase(); if(de !== "weekday") { // Create date element functions and plural date element functions used with Date (eg. day(), days(), months()). $P[de] = $P[de + "s"] = ef(px[k]); // Create date element functions and plural date element functions used with Number (eg. day(), days(), months()). $N[de] = $N[de + "s"] = nf(de + "s"); } } $P._ss = ef("Second"); var nthfn = function (n) { return function (dayOfWeek) { if (this._same) { return this._ss(arguments[0]); } if (dayOfWeek || dayOfWeek === 0) { return this.moveToNthOccurrence(dayOfWeek, n); } this._nth = n; // if the operator is 'second' add the _orient, then deal with it later... if (n === 2 && (dayOfWeek === undefined || dayOfWeek === null)) { this._isSecond = true; return this.addSeconds(this._orient); } return this; }; }; for (var l = 0; l < nth.length; l++) { $P[nth[l]] = (l === 0) ? nthfn(-1) : nthfn(l); } }()); (function () { "use strict"; Date.Parsing = { Exception: function (s) { this.message = "Parse error at '" + s.substring(0, 10) + " ...'"; } }; var $P = Date.Parsing; var dayOffsets = { standard: [0,31,59,90,120,151,181,212,243,273,304,334], leap: [0,31,60,91,121,152,182,213,244,274,305,335] }; $P.isLeapYear = function(year) { return ((year % 4 === 0) && (year % 100 !== 0)) || (year % 400 === 0); }; var utils = { multiReplace : function (str, hash ) { var key; for (key in hash) { if (Object.prototype.hasOwnProperty.call(hash, key)) { var regex; if (typeof hash[key] === "function") { } else { regex = (hash[key] instanceof RegExp) ? hash[key] : new RegExp(hash[key], "g"); } str = str.replace(regex, key); } } return str; }, getDayOfYearFromWeek : function (obj) { var d, jan4, offset; obj.weekDay = (!obj.weekDay && obj.weekDay !== 0) ? 1 : obj.weekDay; d = new Date(obj.year, 0, 4); jan4 = d.getDay() === 0 ? 7 : d.getDay(); // JS is 0 indexed on Sunday. offset = jan4+3; obj.dayOfYear = ((obj.week * 7) + (obj.weekDay === 0 ? 7 : obj.weekDay))-offset; return obj; }, getDayOfYear : function (obj, dayOffset) { if (!obj.dayOfYear) { obj = utils.getDayOfYearFromWeek(obj); } for (var i=0;i <= dayOffset.length;i++) { if (obj.dayOfYear < dayOffset[i] || i === dayOffset.length) { obj.day = obj.day ? obj.day : (obj.dayOfYear - dayOffset[i-1]); break; } else { obj.month = i; } } return obj; }, adjustForTimeZone : function (obj, date) { var offset; if (obj.zone.toUpperCase() === "Z" || (obj.zone_hours === 0 && obj.zone_minutes === 0)) { // it's UTC/GML so work out the current timeszone offset offset = -date.getTimezoneOffset(); } else { offset = (obj.zone_hours*60) + (obj.zone_minutes || 0); if (obj.zone_sign === "+") { offset *= -1; } offset -= date.getTimezoneOffset(); } date.setMinutes(date.getMinutes()+offset); return date; }, setDefaults : function (obj) { obj.year = obj.year || Date.today().getFullYear(); obj.hours = obj.hours || 0; obj.minutes = obj.minutes || 0; obj.seconds = obj.seconds || 0; obj.milliseconds = obj.milliseconds || 0; if (!(!obj.month && (obj.week || obj.dayOfYear))) { // if we have a month, or if we don't but don't have the day calculation data obj.month = obj.month || 0; obj.day = obj.day || 1; } return obj; }, dataNum: function (data, mod, explict, postProcess) { var dataNum = data*1; if (mod) { if (postProcess) { return data ? mod(data)*1 : data; } else { return data ? mod(dataNum) : data; } } else if (!explict){ return data ? dataNum : data; } else { return (data && typeof data !== "undefined") ? dataNum : data; } }, timeDataProcess: function (obj) { var timeObj = {}; for (var x in obj.data) { if (obj.data.hasOwnProperty(x)) { timeObj[x] = obj.ignore[x] ? obj.data[x] : utils.dataNum(obj.data[x], obj.mods[x], obj.explict[x], obj.postProcess[x]); } } if (obj.data.secmins) { obj.data.secmins = obj.data.secmins.replace(",", ".") * 60; if (!timeObj.minutes) { timeObj.minutes = obj.data.secmins; } else if (!timeObj.seconds) { timeObj.seconds = obj.data.secmins; } delete obj.secmins; } return timeObj; }, buildTimeObjectFromData: function (data) { var time = utils.timeDataProcess({ data: { year : data[1], month : data[5], day : data[7], week : data[8], dayOfYear : data[10], hours : data[15], zone_hours : data[23], zone_minutes : data[24], zone : data[21], zone_sign : data[22], weekDay : data[9], minutes: data[16], seconds: data[19], milliseconds: data[20], secmins: data[18] }, mods: { month: function(data) { return data-1; }, weekDay: function (data) { data = Math.abs(data); return (data === 7 ? 0 : data); }, minutes: function (data) { return data.replace(":",""); }, seconds: function (data) { return Math.floor( (data.replace(":","").replace(",","."))*1 ); }, milliseconds: function (data) { return (data.replace(",",".")*1000); } }, postProcess: { minutes: true, seconds: true, milliseconds: true }, explict: { zone_hours: true, zone_minutes: true }, ignore: { zone: true, zone_sign: true, secmins: true } }); return time; }, addToHash: function (hash, keys, data) { keys = keys; data = data; var len = keys.length; for (var i = 0; i < len; i++) { hash[keys[i]] = data[i]; } return hash; }, combineRegex: function (r1, r2) { return new RegExp("(("+r1.source+")\\s("+r2.source+"))"); }, getDateNthString: function(add, last, inc){ if (add) { return Date.today().addDays(inc).toString("d"); } else if (last) { return Date.today().last()[inc]().toString("d"); } }, buildRegexData: function (array) { var arr = []; var len = array.length; for (var i=0; i < len; i++) { if (Object.prototype.toString.call(array[i]) === '[object Array]') { // oldIE compat version of Array.isArray arr.push(this.combineRegex(array[i][0], array[i][1])); } else { arr.push(array[i]); } } return arr; } }; $P.processTimeObject = function (obj) { var date, dayOffset; utils.setDefaults(obj); dayOffset = ($P.isLeapYear(obj.year)) ? dayOffsets.leap : dayOffsets.standard; if (!obj.month && (obj.week || obj.dayOfYear)) { utils.getDayOfYear(obj, dayOffset); } else { obj.dayOfYear = dayOffset[obj.month] + obj.day; } date = new Date(obj.year, obj.month, obj.day, obj.hours, obj.minutes, obj.seconds, obj.milliseconds); if (obj.zone) { utils.adjustForTimeZone(obj, date); // adjust (and calculate) for timezone } return date; }; $P.ISO = { regex : /^([\+-]?\d{4}(?!\d{2}\b))((-?)((0[1-9]|1[0-2])(\3([12]\d|0[1-9]|3[01]))?|W([0-4]\d|5[0-3])(-?[1-7])?|(00[1-9]|0[1-9]\d|[12]\d{2}|3([0-5]\d|6[1-6])))([T\s]((([01]\d|2[0-4])((:?)[0-5]\d)?|24\:?00)([\.,]\d+(?!:))?)?(\17[0-5]\d([\.,]\d+)?)?\s?([zZ]|([\+-])([01]\d|2[0-3]):?([0-5]\d)?)?)?)?$/, parse : function (s) { var time, data = s.match(this.regex); if (!data || !data.length) { return null; } time = utils.buildTimeObjectFromData(data); if (!time.year || (!time.year && (!time.month && !time.day) && (!time.week && !time.dayOfYear)) ) { return null; } return $P.processTimeObject(time); } }; $P.Numeric = { isNumeric: function (e){return!isNaN(parseFloat(e))&&isFinite(e);}, regex: /\b([0-1]?[0-9])([0-3]?[0-9])([0-2]?[0-9]?[0-9][0-9])\b/i, parse: function (s) { var data, i, time = {}, order = Date.CultureInfo.dateElementOrder.split(""); if (!(this.isNumeric(s)) || // if it's non-numeric OR (s[0] === "+" && s[0] === "-")) { // It's an arithmatic string (eg +/-1000) return null; } if (s.length < 5 && s.indexOf(".") < 0 && s.indexOf("/") < 0) { // assume it's just a year. time.year = s; return $P.processTimeObject(time); } data = s.match(this.regex); if (!data || !data.length) { return null; } for (i=0; i < order.length; i++) { switch(order[i]) { case "d": time.day = data[i+1]; break; case "m": time.month = (data[i+1]-1); break; case "y": time.year = data[i+1]; break; } } return $P.processTimeObject(time); } }; $P.Normalizer = { regexData: function () { var $R = Date.CultureInfo.regexPatterns; return utils.buildRegexData([ $R.tomorrow, $R.yesterday, [$R.past, $R.mon], [$R.past, $R.tue], [$R.past, $R.wed], [$R.past, $R.thu], [$R.past, $R.fri], [$R.past, $R.sat], [$R.past, $R.sun] ]); }, basicReplaceHash : function() { var $R = Date.CultureInfo.regexPatterns; return { "January": $R.jan.source, "February": $R.feb, "March": $R.mar, "April": $R.apr, "May": $R.may, "June": $R.jun, "July": $R.jul, "August": $R.aug, "September": $R.sep, "October": $R.oct, "November": $R.nov, "December": $R.dec, "": /\bat\b/gi, " ": /\s{2,}/, "am": $R.inTheMorning, "9am": $R.thisMorning, "pm": $R.inTheEvening, "7pm":$R.thisEvening }; }, keys : function(){ return [ utils.getDateNthString(true, false, 1), // tomorrow utils.getDateNthString(true, false, -1), // yesterday utils.getDateNthString(false, true, "monday"), //last mon utils.getDateNthString(false, true, "tuesday"), //last tues utils.getDateNthString(false, true, "wednesday"), //last wed utils.getDateNthString(false, true, "thursday"), //last thurs utils.getDateNthString(false, true, "friday"), //last fri utils.getDateNthString(false, true, "saturday"), //last sat utils.getDateNthString(false, true, "sunday") //last sun ]; }, buildRegexFunctions: function () { var $R = Date.CultureInfo.regexPatterns; var __ = Date.i18n.__; var tomorrowRE = new RegExp("(\\b\\d\\d?("+__("AM")+"|"+__("PM")+")? )("+$R.tomorrow.source.slice(1)+")", "i"); // adapted tomorrow regex for AM PM relative dates var todayRE = new RegExp($R.today.source + "(?!\\s*([+-]))\\b"); // today, but excludes the math operators (eg "today + 2h") this.replaceFuncs = [ [todayRE, function (full) { return (full.length > 1) ? Date.today().toString("d") : full; }], [tomorrowRE, function(full, m1) { var t = Date.today().addDays(1).toString("d"); return (t + " " + m1); }], [$R.amThisMorning, function(str, am){return am;}], [$R.pmThisEvening, function(str, pm){return pm;}] ]; }, buildReplaceData: function () { this.buildRegexFunctions(); this.replaceHash = utils.addToHash(this.basicReplaceHash(), this.keys(), this.regexData()); }, stringReplaceFuncs: function (s) { for (var i=0; i < this.replaceFuncs.length; i++) { s = s.replace(this.replaceFuncs[i][0], this.replaceFuncs[i][1]); } return s; }, parse: function (s) { s = this.stringReplaceFuncs(s); s = utils.multiReplace(s, this.replaceHash); try { var n = s.split(/([\s\-\.\,\/\x27]+)/); if (n.length === 3 && $P.Numeric.isNumeric(n[0]) && $P.Numeric.isNumeric(n[2]) && (n[2].length >= 4)) { // ok, so we're dealing with x/year. But that's not a full date. // This fixes wonky dateElementOrder parsing when set to dmy order. if (Date.CultureInfo.dateElementOrder[0] === "d") { s = "1/" + n[0] + "/" + n[2]; // set to 1st of month and normalize the seperator } } } catch (e) {} return s; } }; $P.Normalizer.buildReplaceData(); }()); (function () { var $P = Date.Parsing; var _ = $P.Operators = { // // Tokenizers // rtoken: function (r) { // regex token return function (s) { var mx = s.match(r); if (mx) { return ([ mx[0], s.substring(mx[0].length) ]); } else { throw new $P.Exception(s); } }; }, token: function () { // whitespace-eating token return function (s) { return _.rtoken(new RegExp("^\\s*" + s + "\\s*"))(s); }; }, stoken: function (s) { // string token return _.rtoken(new RegExp("^" + s)); }, // Atomic Operators until: function (p) { return function (s) { var qx = [], rx = null; while (s.length) { try { rx = p.call(this, s); } catch (e) { qx.push(rx[0]); s = rx[1]; continue; } break; } return [ qx, s ]; }; }, many: function (p) { return function (s) { var rx = [], r = null; while (s.length) { try { r = p.call(this, s); } catch (e) { return [ rx, s ]; } rx.push(r[0]); s = r[1]; } return [ rx, s ]; }; }, // generator operators -- see below optional: function (p) { return function (s) { var r = null; try { r = p.call(this, s); } catch (e) { return [ null, s ]; } return [ r[0], r[1] ]; }; }, not: function (p) { return function (s) { try { p.call(this, s); } catch (e) { return [null, s]; } throw new $P.Exception(s); }; }, ignore: function (p) { return p ? function (s) { var r = null; r = p.call(this, s); return [null, r[1]]; } : null; }, product: function () { var px = arguments[0], qx = Array.prototype.slice.call(arguments, 1), rx = []; for (var i = 0 ; i < px.length ; i++) { rx.push(_.each(px[i], qx)); } return rx; }, cache: function (rule) { var cache = {}, cache_length = 0, cache_keys = [], CACHE_MAX = Date.Config.CACHE_MAX || 100000, r = null; var cacheCheck = function () { if (cache_length === CACHE_MAX) { // kill several keys, don't want to have to do this all the time... for (var i=0; i < 10; i++) { var key = cache_keys.shift(); if (key) { delete cache[key]; cache_length--; } } } }; return function (s) { cacheCheck(); try { r = cache[s] = (cache[s] || rule.call(this, s)); } catch (e) { r = cache[s] = e; } cache_length++; cache_keys.push(s); if (r instanceof $P.Exception) { throw r; } else { return r; } }; }, // vector operators -- see below any: function () { var px = arguments; return function (s) { var r = null; for (var i = 0; i < px.length; i++) { if (px[i] == null) { continue; } try { r = (px[i].call(this, s)); } catch (e) { r = null; } if (r) { return r; } } throw new $P.Exception(s); }; }, each: function () { var px = arguments; return function (s) { var rx = [], r = null; for (var i = 0; i < px.length ; i++) { if (px[i] == null) { continue; } try { r = (px[i].call(this, s)); } catch (e) { throw new $P.Exception(s); } rx.push(r[0]); s = r[1]; } return [ rx, s]; }; }, all: function () { var px = arguments, _ = _; return _.each(_.optional(px)); }, // delimited operators sequence: function (px, d, c) { d = d || _.rtoken(/^\s*/); c = c || null; if (px.length === 1) { return px[0]; } return function (s) { var r = null, q = null; var rx = []; for (var i = 0; i < px.length ; i++) { try { r = px[i].call(this, s); } catch (e) { break; } rx.push(r[0]); try { q = d.call(this, r[1]); } catch (ex) { q = null; break; } s = q[1]; } if (!r) { throw new $P.Exception(s); } if (q) { throw new $P.Exception(q[1]); } if (c) { try { r = c.call(this, r[1]); } catch (ey) { throw new $P.Exception(r[1]); } } return [ rx, (r?r[1]:s) ]; }; }, // // Composite Operators // between: function (d1, p, d2) { d2 = d2 || d1; var _fn = _.each(_.ignore(d1), p, _.ignore(d2)); return function (s) { var rx = _fn.call(this, s); return [[rx[0][0], r[0][2]], rx[1]]; }; }, list: function (p, d, c) { d = d || _.rtoken(/^\s*/); c = c || null; return (p instanceof Array ? _.each(_.product(p.slice(0, -1), _.ignore(d)), p.slice(-1), _.ignore(c)) : _.each(_.many(_.each(p, _.ignore(d))), px, _.ignore(c))); }, set: function (px, d, c) { d = d || _.rtoken(/^\s*/); c = c || null; return function (s) { // r is the current match, best the current 'best' match // which means it parsed the most amount of input var r = null, p = null, q = null, rx = null, best = [[], s], last = false; // go through the rules in the given set for (var i = 0; i < px.length ; i++) { // last is a flag indicating whether this must be the last element // if there is only 1 element, then it MUST be the last one q = null; p = null; r = null; last = (px.length === 1); // first, we try simply to match the current pattern // if not, try the next pattern try { r = px[i].call(this, s); } catch (e) { continue; } // since we are matching against a set of elements, the first // thing to do is to add r[0] to matched elements rx = [[r[0]], r[1]]; // if we matched and there is still input to parse and // we don't already know this is the last element, // we're going to next check for the delimiter ... // if there's none, or if there's no input left to parse // than this must be the last element after all ... if (r[1].length > 0 && ! last) { try { q = d.call(this, r[1]); } catch (ex) { last = true; } } else { last = true; } // if we parsed the delimiter and now there's no more input, // that means we shouldn't have parsed the delimiter at all // so don't update r and mark this as the last element ... if (!last && q[1].length === 0) { last = true; } // so, if this isn't the last element, we're going to see if // we can get any more matches from the remaining (unmatched) // elements ... if (!last) { // build a list of the remaining rules we can match against, // i.e., all but the one we just matched against var qx = []; for (var j = 0; j < px.length ; j++) { if (i !== j) { qx.push(px[j]); } } // now invoke recursively set with the remaining input // note that we don't include the closing delimiter ... // we'll check for that ourselves at the end p = _.set(qx, d).call(this, q[1]); // if we got a non-empty set as a result ... // (otw rx already contains everything we want to match) if (p[0].length > 0) { // update current result, which is stored in rx ... // basically, pick up the remaining text from p[1] // and concat the result from p[0] so that we don't // get endless nesting ... rx[0] = rx[0].concat(p[0]); rx[1] = p[1]; } } // at this point, rx either contains the last matched element // or the entire matched set that starts with this element. // now we just check to see if this variation is better than // our best so far, in terms of how much of the input is parsed if (rx[1].length < best[1].length) { best = rx; } // if we've parsed all the input, then we're finished if (best[1].length === 0) { break; } } // so now we've either gone through all the patterns trying them // as the initial match; or we found one that parsed the entire // input string ... // if best has no matches, just return empty set ... if (best[0].length === 0) { return best; } // if a closing delimiter is provided, then we have to check it also if (c) { // we try this even if there is no remaining input because the pattern // may well be optional or match empty input ... try { q = c.call(this, best[1]); } catch (ey) { throw new $P.Exception(best[1]); } // it parsed ... be sure to update the best match remaining input best[1] = q[1]; } // if we're here, either there was no closing delimiter or we parsed it // so now we have the best match; just return it! return best; }; }, forward: function (gr, fname) { return function (s) { return gr[fname].call(this, s); }; }, // // Translation Operators // replace: function (rule, repl) { return function (s) { var r = rule.call(this, s); return [repl, r[1]]; }; }, process: function (rule, fn) { return function (s) { var r = rule.call(this, s); return [fn.call(this, r[0]), r[1]]; }; }, min: function (min, rule) { return function (s) { var rx = rule.call(this, s); if (rx[0].length < min) { throw new $P.Exception(s); } return rx; }; } }; // Generator Operators And Vector Operators // Generators are operators that have a signature of F(R) => R, // taking a given rule and returning another rule, such as // ignore, which parses a given rule and throws away the result. // Vector operators are those that have a signature of F(R1,R2,...) => R, // take a list of rules and returning a new rule, such as each. // Generator operators are converted (via the following _generator // function) into functions that can also take a list or array of rules // and return an array of new rules as though the function had been // called on each rule in turn (which is what actually happens). // This allows generators to be used with vector operators more easily. // Example: // each(ignore(foo, bar)) instead of each(ignore(foo), ignore(bar)) // This also turns generators into vector operators, which allows // constructs like: // not(cache(foo, bar)) var _generator = function (op) { function gen() { var args = null, rx = [], px, i; if (arguments.length > 1) { args = Array.prototype.slice.call(arguments); } else if (arguments[0] instanceof Array) { args = arguments[0]; } if (args) { px = args.shift(); if (px.length > 0) { args.unshift(px[i]); rx.push(op.apply(null, args)); args.shift(); return rx; } } else { return op.apply(null, arguments); } } return gen; }; var gx = "optional not ignore cache".split(/\s/); for (var i = 0 ; i < gx.length ; i++) { _[gx[i]] = _generator(_[gx[i]]); } var _vector = function (op) { return function () { if (arguments[0] instanceof Array) { return op.apply(null, arguments[0]); } else { return op.apply(null, arguments); } }; }; var vx = "each any all".split(/\s/); for (var j = 0 ; j < vx.length ; j++) { _[vx[j]] = _vector(_[vx[j]]); } }()); (function () { var $D = Date; var flattenAndCompact = function (ax) { var rx = []; for (var i = 0; i < ax.length; i++) { if (ax[i] instanceof Array) { rx = rx.concat(flattenAndCompact(ax[i])); } else { if (ax[i]) { rx.push(ax[i]); } } } return rx; }; var parseMeridian = function () { if (this.meridian && (this.hour || this.hour === 0)) { if (this.meridian === "a" && this.hour > 11 && Date.Config.strict24hr){ throw "Invalid hour and meridian combination"; } else if (this.meridian === "p" && this.hour < 12 && Date.Config.strict24hr){ throw "Invalid hour and meridian combination"; } else if (this.meridian === "p" && this.hour < 12) { this.hour = this.hour + 12; } else if (this.meridian === "a" && this.hour === 12) { this.hour = 0; } } }; var setDefaults = function () { var now = new Date(); if ((this.hour || this.minute) && (!this.month && !this.year && !this.day)) { this.day = now.getDate(); } if (!this.year) { this.year = now.getFullYear(); } if (!this.month && this.month !== 0) { this.month = now.getMonth(); } if (!this.day) { this.day = 1; } if (!this.hour) { this.hour = 0; } if (!this.minute) { this.minute = 0; } if (!this.second) { this.second = 0; } if (!this.millisecond) { this.millisecond = 0; } }; var finishUtils = { getToday: function () { if (this.now || "hour minute second".indexOf(this.unit) !== -1) { return new Date(); } else { return $D.today(); } }, setDaysFromWeekday: function (today, orient){ var gap; orient = orient || 1; this.unit = "day"; gap = ($D.getDayNumberFromName(this.weekday) - today.getDay()); this.days = gap ? ((gap + (orient * 7)) % 7) : (orient * 7); return this; }, setMonthsFromMonth: function (today, orient) { var gap; orient = orient || 1; this.unit = "month"; gap = (this.month - today.getMonth()); this.months = gap ? ((gap + (orient * 12)) % 12) : (orient * 12); this.month = null; return this; }, setDMYFromWeekday: function () { var d = Date[this.weekday](); this.day = d.getDate(); if (!this.month) { this.month = d.getMonth(); } this.year = d.getFullYear(); return this; }, setUnitValue: function (orient) { if (!this.value && this.operator && this.operator !== null && this[this.unit + "s"] && this[this.unit + "s"] !== null) { this[this.unit + "s"] = this[this.unit + "s"] + ((this.operator === "add") ? 1 : -1) + (this.value||0) * orient; } else if (this[this.unit + "s"] == null || this.operator != null) { if (!this.value) { this.value = 1; } this[this.unit + "s"] = this.value * orient; } }, generateDateFromWeeks: function () { var weekday = (this.weekday !== undefined) ? this.weekday : "today"; var d = Date[weekday]().addWeeks(this.weeks); if (this.now) { d.setTimeToNow(); } return d; } }; $D.Translator = { hour: function (s) { return function () { this.hour = Number(s); }; }, minute: function (s) { return function () { this.minute = Number(s); }; }, second: function (s) { return function () { this.second = Number(s); }; }, /* for ss.s format */ secondAndMillisecond: function (s) { return function () { var mx = s.match(/^([0-5][0-9])\.([0-9]{1,3})/); this.second = Number(mx[1]); this.millisecond = Number(mx[2]); }; }, meridian: function (s) { return function () { this.meridian = s.slice(0, 1).toLowerCase(); }; }, timezone: function (s) { return function () { var n = s.replace(/[^\d\+\-]/g, ""); if (n.length) { this.timezoneOffset = Number(n); } else { this.timezone = s.toLowerCase(); } }; }, day: function (x) { var s = x[0]; return function () { this.day = Number(s.match(/\d+/)[0]); if (this.day < 1) { throw "invalid day"; } }; }, month: function (s) { return function () { this.month = (s.length === 3) ? "jan feb mar apr may jun jul aug sep oct nov dec".indexOf(s)/4 : Number(s) - 1; if (this.month < 0) { throw "invalid month"; } }; }, year: function (s) { return function () { var n = Number(s); this.year = ((s.length > 2) ? n : (n + (((n + 2000) < Date.CultureInfo.twoDigitYearMax) ? 2000 : 1900))); }; }, rday: function (s) { return function () { switch (s) { case "yesterday": this.days = -1; break; case "tomorrow": this.days = 1; break; case "today": this.days = 0; break; case "now": this.days = 0; this.now = true; break; } }; }, finishExact: function (x) { var d; x = (x instanceof Array) ? x : [x]; for (var i = 0 ; i < x.length ; i++) { if (x[i]) { x[i].call(this); } } setDefaults.call(this); parseMeridian.call(this); if (this.day > $D.getDaysInMonth(this.year, this.month)) { throw new RangeError(this.day + " is not a valid value for days."); } d = new Date(this.year, this.month, this.day, this.hour, this.minute, this.second, this.millisecond); if (this.year < 100) { d.setFullYear(this.year); // means years less that 100 are process correctly. JS will parse it otherwise as 1900-1999. } if (this.timezone) { d.set({ timezone: this.timezone }); } else if (this.timezoneOffset) { d.set({ timezoneOffset: this.timezoneOffset }); } return d; }, finish: function (x) { var today, expression, orient, temp; x = (x instanceof Array) ? flattenAndCompact(x) : [ x ]; if (x.length === 0) { return null; } for (var i = 0 ; i < x.length ; i++) { if (typeof x[i] === "function") { x[i].call(this); } } if (this.now && !this.unit && !this.operator) { return new Date(); } else { today = finishUtils.getToday.call(this); } expression = !!(this.days && this.days !== null || this.orient || this.operator); orient = ((this.orient === "past" || this.operator === "subtract") ? -1 : 1); if (this.month && this.unit === "week") { this.value = this.month + 1; delete this.month; delete this.day; } if ((this.month || this.month === 0) && "year day hour minute second".indexOf(this.unit) !== -1) { if (!this.value) { this.value = this.month + 1; } this.month = null; expression = true; } if (!expression && this.weekday && !this.day && !this.days) { finishUtils.setDMYFromWeekday.call(this); } if (expression && this.weekday && this.unit !== "month" && this.unit !== "week") { finishUtils.setDaysFromWeekday.call(this, today, orient); } if (this.weekday && this.unit !== "week" && !this.day && !this.days) { temp = Date[this.weekday](); this.day = temp.getDate(); if (temp.getMonth() !== today.getMonth()) { this.month = temp.getMonth(); } } if (this.month && this.unit === "day" && this.operator) { if (!this.value) { this.value = (this.month + 1); } this.month = null; } if (this.value != null && this.month != null && this.year != null) { this.day = this.value * 1; } if (this.month && !this.day && this.value) { today.set({ day: this.value * 1 }); if (!expression) { this.day = this.value * 1; } } if (!this.month && this.value && this.unit === "month" && !this.now) { this.month = this.value; expression = true; } if (expression && (this.month || this.month === 0) && this.unit !== "year") { finishUtils.setMonthsFromMonth.call(this, today, orient); } if (!this.unit) { this.unit = "day"; } finishUtils.setUnitValue.call(this, orient); parseMeridian.call(this); if ((this.month || this.month === 0) && !this.day) { this.day = 1; } if (!this.orient && !this.operator && this.unit === "week" && this.value && !this.day && !this.month) { return Date.today().setWeek(this.value); } if (this.unit === "week" && this.weeks && !this.day && !this.month) { return finishUtils.generateDateFromWeeks.call(this); } if (expression && this.timezone && this.day && this.days) { this.day = this.days; } if (expression){ today.add(this); } else { today.set(this); } if (this.timezone) { this.timezone = this.timezone.toUpperCase(); var offset = $D.getTimezoneOffset(this.timezone); var timezone; if (today.hasDaylightSavingTime()) { // lets check that we're being sane with timezone setting timezone = $D.getTimezoneAbbreviation(offset, today.isDaylightSavingTime()); if (timezone !== this.timezone) { // bugger, we're in a place where things like EST vs EDT matters. if (today.isDaylightSavingTime()) { today.addHours(-1); } else { today.addHours(1); } } } today.setTimezoneOffset(offset); } return today; } }; }()); (function () { var $D = Date; $D.Grammar = {}; var _ = $D.Parsing.Operators, g = $D.Grammar, t = $D.Translator, _fn; // Allow rolling up into general purpose rules _fn = function () { return _.each(_.any.apply(null, arguments), _.not(g.ctoken2("timeContext"))); }; g.datePartDelimiter = _.rtoken(/^([\s\-\.\,\/\x27]+)/); g.timePartDelimiter = _.stoken(":"); g.whiteSpace = _.rtoken(/^\s*/); g.generalDelimiter = _.rtoken(/^(([\s\,]|at|@|on)+)/); var _C = {}; g.ctoken = function (keys) { var fn = _C[keys]; if (! fn) { var c = Date.CultureInfo.regexPatterns; var kx = keys.split(/\s+/), px = []; for (var i = 0; i < kx.length ; i++) { px.push(_.replace(_.rtoken(c[kx[i]]), kx[i])); } fn = _C[keys] = _.any.apply(null, px); } return fn; }; g.ctoken2 = function (key) { return _.rtoken(Date.CultureInfo.regexPatterns[key]); }; var cacheProcessRtoken = function (key, token, type, eachToken) { if (eachToken) { g[key] = _.cache(_.process(_.each(_.rtoken(token),_.optional(g.ctoken2(eachToken))), type)); } else { g[key] = _.cache(_.process(_.rtoken(token), type)); } }; var cacheProcessCtoken = function (token, type) { return _.cache(_.process(g.ctoken2(token), type)); }; var _F = {}; //function cache var _get = function (f) { _F[f] = (_F[f] || g.format(f)[0]); return _F[f]; }; g.allformats = function (fx) { var rx = []; if (fx instanceof Array) { for (var i = 0; i < fx.length; i++) { rx.push(_get(fx[i])); } } else { rx.push(_get(fx)); } return rx; }; g.formats = function (fx) { if (fx instanceof Array) { var rx = []; for (var i = 0 ; i < fx.length ; i++) { rx.push(_get(fx[i])); } return _.any.apply(null, rx); } else { return _get(fx); } }; var grammarFormats = { timeFormats: function(){ var i, RTokenKeys = [ "h", "hh", "H", "HH", "m", "mm", "s", "ss", "ss.s", "z", "zz" ], RToken = [ /^(0[0-9]|1[0-2]|[1-9])/, /^(0[0-9]|1[0-2])/, /^([0-1][0-9]|2[0-3]|[0-9])/, /^([0-1][0-9]|2[0-3])/, /^([0-5][0-9]|[0-9])/, /^[0-5][0-9]/, /^([0-5][0-9]|[0-9])/, /^[0-5][0-9]/, /^[0-5][0-9]\.[0-9]{1,3}/, /^((\+|\-)\s*\d\d\d\d)|((\+|\-)\d\d\:?\d\d)/, /^((\+|\-)\s*\d\d\d\d)|((\+|\-)\d\d\:?\d\d)/ ], tokens = [ t.hour, t.hour, t.hour, t.hour, t.minute, t.minute, t.second, t.second, t.secondAndMillisecond, t.timezone, t.timezone ]; for (i=0; i < RTokenKeys.length; i++) { cacheProcessRtoken(RTokenKeys[i], RToken[i], tokens[i]); } g.hms = _.cache(_.sequence([g.H, g.m, g.s], g.timePartDelimiter)); g.t = cacheProcessCtoken("shortMeridian", t.meridian); g.tt = cacheProcessCtoken("longMeridian", t.meridian); g.zzz = cacheProcessCtoken("timezone", t.timezone); g.timeSuffix = _.each(_.ignore(g.whiteSpace), _.set([ g.tt, g.zzz ])); g.time = _.each(_.optional(_.ignore(_.stoken("T"))), g.hms, g.timeSuffix); }, dateFormats: function () { // pre-loaded rules for different date part order preferences var _setfn = function () { return _.set(arguments, g.datePartDelimiter); }; var i, RTokenKeys = [ "d", "dd", "M", "MM", "y", "yy", "yyy", "yyyy" ], RToken = [ /^([0-2]\d|3[0-1]|\d)/, /^([0-2]\d|3[0-1])/, /^(1[0-2]|0\d|\d)/, /^(1[0-2]|0\d)/, /^(\d+)/, /^(\d\d)/, /^(\d\d?\d?\d?)/, /^(\d\d\d\d)/ ], tokens = [ t.day, t.day, t.month, t.month, t.year, t.year, t.year, t.year ], eachToken = [ "ordinalSuffix", "ordinalSuffix" ]; for (i=0; i < RTokenKeys.length; i++) { cacheProcessRtoken(RTokenKeys[i], RToken[i], tokens[i], eachToken[i]); } g.MMM = g.MMMM = _.cache(_.process(g.ctoken("jan feb mar apr may jun jul aug sep oct nov dec"), t.month)); g.ddd = g.dddd = _.cache(_.process(g.ctoken("sun mon tue wed thu fri sat"), function (s) { return function () { this.weekday = s; }; } )); g.day = _fn(g.d, g.dd); g.month = _fn(g.M, g.MMM); g.year = _fn(g.yyyy, g.yy); g.mdy = _setfn(g.ddd, g.month, g.day, g.year); g.ymd = _setfn(g.ddd, g.year, g.month, g.day); g.dmy = _setfn(g.ddd, g.day, g.month, g.year); g.date = function (s) { return ((g[Date.CultureInfo.dateElementOrder] || g.mdy).call(this, s)); }; }, relative: function () { // relative date / time expressions g.orientation = _.process(g.ctoken("past future"), function (s) { return function () { this.orient = s; }; } ); g.operator = _.process(g.ctoken("add subtract"), function (s) { return function () { this.operator = s; }; } ); g.rday = _.process(g.ctoken("yesterday tomorrow today now"), t.rday); g.unit = _.process(g.ctoken("second minute hour day week month year"), function (s) { return function () { this.unit = s; }; } ); } }; g.buildGrammarFormats = function () { // these need to be rebuilt every time the language changes. _C = {}; grammarFormats.timeFormats(); grammarFormats.dateFormats(); grammarFormats.relative(); g.value = _.process(_.rtoken(/^([-+]?\d+)?(st|nd|rd|th)?/), function (s) { return function () { this.value = s.replace(/\D/g, ""); }; } ); g.expression = _.set([g.rday, g.operator, g.value, g.unit, g.orientation, g.ddd, g.MMM ]); g.format = _.process(_.many( _.any( // translate format specifiers into grammar rules _.process( _.rtoken(/^(dd?d?d?(?!e)|MM?M?M?|yy?y?y?|hh?|HH?|mm?|ss?|tt?|zz?z?)/), function (fmt) { if (g[fmt]) { return g[fmt]; } else { throw $D.Parsing.Exception(fmt); } } ), // translate separator tokens into token rules _.process(_.rtoken(/^[^dMyhHmstz]+/), // all legal separators function (s) { return _.ignore(_.stoken(s)); } ) ) ), // construct the parser ... function (rules) { return _.process(_.each.apply(null, rules), t.finishExact); } ); // starting rule for general purpose grammar g._start = _.process(_.set([ g.date, g.time, g.expression ], g.generalDelimiter, g.whiteSpace), t.finish); }; g.buildGrammarFormats(); // parsing date format specifiers - ex: "h:m:s tt" // this little guy will generate a custom parser based // on the format string, ex: g.format("h:m:s tt") // check for these formats first g._formats = g.formats([ "\"yyyy-MM-ddTHH:mm:ssZ\"", "yyyy-MM-ddTHH:mm:ss.sz", "yyyy-MM-ddTHH:mm:ssZ", "yyyy-MM-ddTHH:mm:ssz", "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-ddTHH:mmZ", "yyyy-MM-ddTHH:mmz", "yyyy-MM-ddTHH:mm", "ddd, MMM dd, yyyy H:mm:ss tt", "ddd MMM d yyyy HH:mm:ss zzz", "MMddyyyy", "ddMMyyyy", "Mddyyyy", "ddMyyyy", "Mdyyyy", "dMyyyy", "yyyy", "Mdyy", "dMyy", "d" ]); // real starting rule: tries selected formats first, // then general purpose rule g.start = function (s) { try { var r = g._formats.call({}, s); if (r[1].length === 0) { return r; } } catch (e) {} return g._start.call({}, s); }; }()); (function () { var $D = Date; /** * @desc Converts the specified string value into its JavaScript Date equivalent using CultureInfo specific format information. * * Example

	///////////
	// Dates //
	///////////

	// 15-Oct-2004
	var d1 = Date.parse("10/15/2004");

	// 15-Oct-2004
	var d1 = Date.parse("15-Oct-2004");

	// 15-Oct-2004
	var d1 = Date.parse("2004.10.15");

	//Fri Oct 15, 2004
	var d1 = Date.parse("Fri Oct 15, 2004");

	///////////
	// Times //
	///////////

	// Today at 10 PM.
	var d1 = Date.parse("10 PM");

	// Today at 10:30 PM.
	var d1 = Date.parse("10:30 P.M.");

	// Today at 6 AM.
	var d1 = Date.parse("06am");

	/////////////////////
	// Dates and Times //
	/////////////////////

	// 8-July-2004 @ 10:30 PM
	var d1 = Date.parse("July 8th, 2004, 10:30 PM");

	// 1-July-2004 @ 10:30 PM
	var d1 = Date.parse("2004-07-01T22:30:00");

	////////////////////
	// Relative Dates //
	////////////////////

	// Returns today's date. The string "today" is culture specific.
	var d1 = Date.parse("today");

	// Returns yesterday's date. The string "yesterday" is culture specific.
	var d1 = Date.parse("yesterday");

	// Returns the date of the next thursday.
	var d1 = Date.parse("Next thursday");

	// Returns the date of the most previous monday.
	var d1 = Date.parse("last monday");

	// Returns today's day + one year.
	var d1 = Date.parse("next year");

	///////////////
	// Date Math //
	///////////////

	// Today + 2 days
	var d1 = Date.parse("t+2");

	// Today + 2 days
	var d1 = Date.parse("today + 2 days");

	// Today + 3 months
	var d1 = Date.parse("t+3m");

	// Today - 1 year
	var d1 = Date.parse("today - 1 year");

	// Today - 1 year
	var d1 = Date.parse("t-1y"); 


	/////////////////////////////
	// Partial Dates and Times //
	/////////////////////////////

	// July 15th of this year.
	var d1 = Date.parse("July 15");

	// 15th day of current day and year.
	var d1 = Date.parse("15");

	// July 1st of current year at 10pm.
	var d1 = Date.parse("7/1 10pm");
	
* * @param {String} The string value to convert into a Date object [Required] * @return {Date} A Date object or null if the string cannot be converted into a Date. */ var parseUtils = { removeOrds: function (s) { ords = s.match(/\b(\d+)(?:st|nd|rd|th)\b/); // find ordinal matches s = ((ords && ords.length === 2) ? s.replace(ords[0], ords[1]) : s); return s; }, grammarParser: function (s) { var r = null; try { r = $D.Grammar.start.call({}, s.replace(/^\s*(\S*(\s+\S+)*)\s*$/, "$1")); } catch (e) { return null; } return ((r[1].length === 0) ? r[0] : null); }, nativeFallback: function(s) { var t; try { // ok we haven't parsed it, last ditch attempt with the built-in parser. t = Date._parse(s); return (t || t === 0) ? new Date(t) : null; } catch (e) { return null; } } }; function parse (s) { var d; if (!s) { return null; } if (s instanceof Date) { return s.clone(); } if (s.length >= 4 && s.charAt(0) !== "0" && s.charAt(0) !== "+"&& s.charAt(0) !== "-") { // ie: 2004 will pass, 0800 won't. // Start with specific formats d = $D.Parsing.ISO.parse(s) || $D.Parsing.Numeric.parse(s); } if (d instanceof Date && !isNaN(d.getTime())) { return d; } else { // find ordinal dates (1st, 3rd, 8th, etc and remove them as they cause parsing issues) s = $D.Parsing.Normalizer.parse(parseUtils.removeOrds(s)); d = parseUtils.grammarParser(s); if (d !== null) { return d; } else { return parseUtils.nativeFallback(s); } } } if (!$D._parse) { $D._parse = $D.parse; } $D.parse = parse; Date.getParseFunction = function (fx) { var fns = Date.Grammar.allformats(fx); return function (s) { var r = null; for (var i = 0; i < fns.length; i++) { try { r = fns[i].call({}, s); } catch (e) { continue; } if (r[1].length === 0) { return r[0]; } } return null; }; }; /** * Converts the specified string value into its JavaScript Date equivalent using the specified format {String} or formats {Array} and the CultureInfo specific format information. * The format of the string value must match one of the supplied formats exactly. * * Example

	// 15-Oct-2004
	var d1 = Date.parseExact("10/15/2004", "M/d/yyyy");

	// 15-Oct-2004
	var d1 = Date.parse("15-Oct-2004", "M-ddd-yyyy");

	// 15-Oct-2004
	var d1 = Date.parse("2004.10.15", "yyyy.MM.dd");

	// Multiple formats
	var d1 = Date.parseExact("10/15/2004", ["M/d/yyyy", "MMMM d, yyyy"]);
	
* * @param {String} The string value to convert into a Date object [Required]. * @param {Object} The expected format {String} or an array of expected formats {Array} of the date string [Required]. * @return {Date} A Date object or null if the string cannot be converted into a Date. */ $D.parseExact = function (s, fx) { return $D.getParseFunction(fx)(s); }; }()); (function () { var $D = Date, $P = $D.prototype, // $C = $D.CultureInfo, // not used atm p = function (s, l) { if (!l) { l = 2; } return ("000" + s).slice(l * -1); }; /** * Converts a PHP format string to Java/.NET format string. * A PHP format string can be used with ._format or .format. * A Java/.NET format string can be used with .toString(). * The .parseExact function will only accept a Java/.NET format string * * Example * var f1 = "%m/%d/%y" * var f2 = Date.normalizeFormat(f1); // "MM/dd/yy" * * new Date().format(f1); // "04/13/08" * new Date()._format(f1); // "04/13/08" * new Date().toString(f2); // "04/13/08" * * var date = Date.parseExact("04/13/08", f2); // Sun Apr 13 2008 * * @param {String} A PHP format string consisting of one or more format spcifiers. * @return {String} The PHP format converted to a Java/.NET format string. */ var normalizerSubstitutions = { "d" : "dd", "%d": "dd", "D" : "ddd", "%a": "ddd", "j" : "dddd", "l" : "dddd", "%A": "dddd", "S" : "S", "F" : "MMMM", "%B": "MMMM", "m" : "MM", "%m": "MM", "M" : "MMM", "%b": "MMM", "%h": "MMM", "n" : "M", "Y" : "yyyy", "%Y": "yyyy", "y" : "yy", "%y": "yy", "g" : "h", "%I": "h", "G" : "H", "h" : "hh", "H" : "HH", "%H": "HH", "i" : "mm", "%M": "mm", "s" : "ss", "%S": "ss", "%r": "hh:mm tt", "%R": "H:mm", "%T": "H:mm:ss", "%X": "t", "%x": "d", "%e": "d", "%D": "MM/dd/yy", "%n": "\\n", "%t": "\\t", "e" : "z", "T" : "z", "%z": "z", "%Z": "z", "Z" : "ZZ", "N" : "u", "w" : "u", "%w": "u", "W" : "W", "%V": "W" }; var normalizer = { substitutes: function (m) { return normalizerSubstitutions[m]; }, interpreted: function (m, x) { var y; switch (m) { case "%u": return x.getDay() + 1; case "z": return x.getOrdinalNumber(); case "%j": return p(x.getOrdinalNumber(), 3); case "%U": var d1 = x.clone().set({month: 0, day: 1}).addDays(-1).moveToDayOfWeek(0), d2 = x.clone().addDays(1).moveToDayOfWeek(0, -1); return (d2 < d1) ? "00" : p((d2.getOrdinalNumber() - d1.getOrdinalNumber()) / 7 + 1); case "%W": return p(x.getWeek()); case "t": return $D.getDaysInMonth(x.getFullYear(), x.getMonth()); case "o": case "%G": return x.setWeek(x.getISOWeek()).toString("yyyy"); case "%g": return x._format("%G").slice(-2); case "a": case "%p": return t("tt").toLowerCase(); case "A": return t("tt").toUpperCase(); case "u": return p(x.getMilliseconds(), 3); case "I": return (x.isDaylightSavingTime()) ? 1 : 0; case "O": return x.getUTCOffset(); case "P": y = x.getUTCOffset(); return y.substring(0, y.length - 2) + ":" + y.substring(y.length - 2); case "B": var now = new Date(); return Math.floor(((now.getHours() * 3600) + (now.getMinutes() * 60) + now.getSeconds() + (now.getTimezoneOffset() + 60) * 60) / 86.4); case "c": return x.toISOString().replace(/\"/g, ""); case "U": return $D.strtotime("now"); case "%c": return t("d") + " " + t("t"); case "%C": return Math.floor(x.getFullYear() / 100 + 1); } }, shouldOverrideDefaults: function (m) { switch (m) { case "%e": return true; default: return false; } }, parse: function (m, context) { var formatString, c = context || new Date(); formatString = normalizer.substitutes(m); if (formatString) { return formatString; } formatString = normalizer.interpreted(m, c); if (formatString) { return formatString; } else { return m; } } }; $D.normalizeFormat = function (format, context) { return format.replace(/(%|\\)?.|%%/g, function(t){ return normalizer.parse(t, context); }); }; /** * Format a local Unix timestamp according to locale settings * * Example: * Date.strftime("%m/%d/%y", new Date()); // "04/13/08" * Date.strftime("c", "2008-04-13T17:52:03Z"); // "04/13/08" * * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @param {Number|String} The number representing the number of seconds that have elapsed since January 1, 1970 (local time). * @return {String} A string representation of the current Date object. */ $D.strftime = function (format, time) { var d = Date.parse(time); return d._format(format); }; /** * Parse any textual datetime description into a Unix timestamp. * A Unix timestamp is the number of seconds that have elapsed since January 1, 1970 (midnight UTC/GMT). * * Example: * Date.strtotime("04/13/08"); // 1208044800 * Date.strtotime("1970-01-01T00:00:00Z"); // 0 * * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @param {Object} A string or date object. * @return {String} A string representation of the current Date object. */ $D.strtotime = function (time) { var d = $D.parse(time); return Math.round($D.UTC(d.getUTCFullYear(), d.getUTCMonth(), d.getUTCDate(), d.getUTCHours(), d.getUTCMinutes(), d.getUTCSeconds(), d.getUTCMilliseconds()) / 1000); }; /** * Converts the value of the current Date object to its equivalent string representation using a PHP/Unix style of date format specifiers. * Format Specifiers * Format Description Example * ------ --------------------------------------------------------------------------- ----------------------- * %a abbreviated weekday name according to the current localed "Mon" through "Sun" * %A full weekday name according to the current localed "Sunday" through "Saturday" * %b abbreviated month name according to the current localed "Jan" through "Dec" * %B full month name according to the current locale "January" through "December" * %c preferred date and time representation for the current locale "4/13/2008 12:33 PM" * %C century number (the year divided by 100 and truncated to an integer) "00" to "99" * %d day of the month as a decimal number "01" to "31" * %D same as %m/%d/%y "04/13/08" * %e day of the month as a decimal number, a single digit is preceded by a space "1" to "31" * %g like %G, but without the century "08" * %G The 4-digit year corresponding to the ISO week number (see %V). "2008" * This has the same format and value as %Y, except that if the ISO week number * belongs to the previous or next year, that year is used instead. * %h same as %b "Jan" through "Dec" * %H hour as a decimal number using a 24-hour clock. "00" to "23" * %I hour as a decimal number using a 12-hour clock. "01" to "12" * %j day of the year as a decimal number. "001" to "366" * %m month as a decimal number. "01" to "12" * %M minute as a decimal number. "00" to "59" * %n newline character "\n" * %p either "am" or "pm" according to the given time value, or the "am" or "pm" * corresponding strings for the current locale. * %r time in a.m. and p.m. notation "8:44 PM" * %R time in 24 hour notation "20:44" * %S second as a decimal number "00" to "59" * %t tab character "\t" * %T current time, equal to %H:%M:%S "12:49:11" * %u weekday as a decimal number ["1", "7"], with "1" representing Monday "1" to "7" * %U week number of the current year as a decimal number, starting with the "0" to ("52" or "53") * first Sunday as the first day of the first week * %V The ISO 8601:1988 week number of the current year as a decimal number, "00" to ("52" or "53") * range 01 to 53, where week 1 is the first week that has at least 4 days * in the current year, and with Monday as the first day of the week. * (Use %G or %g for the year component that corresponds to the week number * for the specified timestamp.) * %W week number of the current year as a decimal number, starting with the "00" to ("52" or "53") * first Monday as the first day of the first week * %w day of the week as a decimal, Sunday being "0" "0" to "6" * %x preferred date representation for the current locale without the time "4/13/2008" * %X preferred time representation for the current locale without the date "12:53:05" * %y year as a decimal number without a century "00" "99" * %Y year as a decimal number including the century "2008" * %Z time zone or name or abbreviation "UTC", "EST", "PST" * %z same as %Z * %% a literal "%" characters "%" * d Day of the month, 2 digits with leading zeros "01" to "31" * D A textual representation of a day, three letters "Mon" through "Sun" * j Day of the month without leading zeros "1" to "31" * l A full textual representation of the day of the week (lowercase "L") "Sunday" through "Saturday" * N ISO-8601 numeric representation of the day of the week (added in PHP 5.1.0) "1" (for Monday) through "7" (for Sunday) * S English ordinal suffix for the day of the month, 2 characters "st", "nd", "rd" or "th". Works well with j * w Numeric representation of the day of the week "0" (for Sunday) through "6" (for Saturday) * z The day of the year (starting from "0") "0" through "365" * W ISO-8601 week number of year, weeks starting on Monday "00" to ("52" or "53") * F A full textual representation of a month, such as January or March "January" through "December" * m Numeric representation of a month, with leading zeros "01" through "12" * M A short textual representation of a month, three letters "Jan" through "Dec" * n Numeric representation of a month, without leading zeros "1" through "12" * t Number of days in the given month "28" through "31" * L Whether it's a leap year "1" if it is a leap year, "0" otherwise * o ISO-8601 year number. This has the same value as Y, except that if the "2008" * ISO week number (W) belongs to the previous or next year, that year * is used instead. * Y A full numeric representation of a year, 4 digits "2008" * y A two digit representation of a year "08" * a Lowercase Ante meridiem and Post meridiem "am" or "pm" * A Uppercase Ante meridiem and Post meridiem "AM" or "PM" * B Swatch Internet time "000" through "999" * g 12-hour format of an hour without leading zeros "1" through "12" * G 24-hour format of an hour without leading zeros "0" through "23" * h 12-hour format of an hour with leading zeros "01" through "12" * H 24-hour format of an hour with leading zeros "00" through "23" * i Minutes with leading zeros "00" to "59" * s Seconds, with leading zeros "00" through "59" * u Milliseconds "54321" * e Timezone identifier "UTC", "EST", "PST" * I Whether or not the date is in daylight saving time (uppercase i) "1" if Daylight Saving Time, "0" otherwise * O Difference to Greenwich time (GMT) in hours "+0200", "-0600" * P Difference to Greenwich time (GMT) with colon between hours and minutes "+02:00", "-06:00" * T Timezone abbreviation "UTC", "EST", "PST" * Z Timezone offset in seconds. The offset for timezones west of UTC is "-43200" through "50400" * always negative, and for those east of UTC is always positive. * c ISO 8601 date "2004-02-12T15:19:21+00:00" * r RFC 2822 formatted date "Thu, 21 Dec 2000 16:01:07 +0200" * U Seconds since the Unix Epoch (January 1 1970 00:00:00 GMT) "0" * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @return {String} A string representation of the current Date object. */ var formatReplace = function (context) { return function (m) { var formatString, override = false; if (m.charAt(0) === "\\" || m.substring(0, 2) === "%%") { return m.replace("\\", "").replace("%%", "%"); } override = normalizer.shouldOverrideDefaults(m); formatString = $D.normalizeFormat(m, context); if (formatString) { return context.toString(formatString, override); } }; }; $P._format = function (format) { var formatter = formatReplace(this); if (!format) { return this._toString(); } else { return format.replace(/(%|\\)?.|%%/g, formatter); } }; if (!$P.format) { $P.format = $P._format; } }()); (function () { "use strict"; var gFn = function (attr) { return function () { return this[attr]; }; }; var sFn = function (attr) { return function (val) { this[attr] = val; return this; }; }; var attrs = ["years", "months", "days", "hours", "minutes", "seconds", "milliseconds"]; var addSetFuncs = function (context, attrs) { for (var i = 0; i < attrs.length ; i++) { var $a = attrs[i], $b = $a.slice(0, 1).toUpperCase() + $a.slice(1); context.prototype[$a] = 0; context.prototype["get" + $b] = gFn($a); context.prototype["set" + $b] = sFn($a); } }; /** * new TimeSpan(milliseconds); * new TimeSpan(days, hours, minutes, seconds); * new TimeSpan(days, hours, minutes, seconds, milliseconds); */ var TimeSpan = function (days, hours, minutes, seconds, milliseconds) { if (arguments.length === 1 && typeof days === "number") { var orient = (days < 0) ? -1 : +1; var millsLeft = Math.abs(days); this.setDays(Math.floor(millsLeft / 86400000) * orient); millsLeft = millsLeft % 86400000; this.setHours(Math.floor(millsLeft / 3600000) * orient); millsLeft = millsLeft % 3600000; this.setMinutes(Math.floor(millsLeft / 60000) * orient); millsLeft = millsLeft % 60000; this.setSeconds(Math.floor(millsLeft / 1000) * orient); millsLeft = millsLeft % 1000; this.setMilliseconds(millsLeft * orient); } else { this.set(days, hours, minutes, seconds, milliseconds); } this.getTotalMilliseconds = function () { return (this.getDays() * 86400000) + (this.getHours() * 3600000) + (this.getMinutes() * 60000) + (this.getSeconds() * 1000); }; this.compareTo = function (time) { var t1 = new Date(1970, 1, 1, this.getHours(), this.getMinutes(), this.getSeconds()), t2; if (time === null) { t2 = new Date(1970, 1, 1, 0, 0, 0); } else { t2 = new Date(1970, 1, 1, time.getHours(), time.getMinutes(), time.getSeconds()); } return (t1 < t2) ? -1 : (t1 > t2) ? 1 : 0; }; this.equals = function (time) { return (this.compareTo(time) === 0); }; this.add = function (time) { return (time === null) ? this : this.addSeconds(time.getTotalMilliseconds() / 1000); }; this.subtract = function (time) { return (time === null) ? this : this.addSeconds(-time.getTotalMilliseconds() / 1000); }; this.addDays = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 86400000)); }; this.addHours = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 3600000)); }; this.addMinutes = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 60000)); }; this.addSeconds = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 1000)); }; this.addMilliseconds = function (n) { return new TimeSpan(this.getTotalMilliseconds() + n); }; this.get12HourHour = function () { return (this.getHours() > 12) ? this.getHours() - 12 : (this.getHours() === 0) ? 12 : this.getHours(); }; this.getDesignator = function () { return (this.getHours() < 12) ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator; }; this.toString = function (format) { this._toString = function () { if (this.getDays() !== null && this.getDays() > 0) { return this.getDays() + "." + this.getHours() + ":" + this.p(this.getMinutes()) + ":" + this.p(this.getSeconds()); } else { return this.getHours() + ":" + this.p(this.getMinutes()) + ":" + this.p(this.getSeconds()); } }; this.p = function (s) { return (s.toString().length < 2) ? "0" + s : s; }; var me = this; return format ? format.replace(/dd?|HH?|hh?|mm?|ss?|tt?/g, function (format) { switch (format) { case "d": return me.getDays(); case "dd": return me.p(me.getDays()); case "H": return me.getHours(); case "HH": return me.p(me.getHours()); case "h": return me.get12HourHour(); case "hh": return me.p(me.get12HourHour()); case "m": return me.getMinutes(); case "mm": return me.p(me.getMinutes()); case "s": return me.getSeconds(); case "ss": return me.p(me.getSeconds()); case "t": return ((me.getHours() < 12) ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator).substring(0, 1); case "tt": return (me.getHours() < 12) ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator; } } ) : this._toString(); }; return this; }; addSetFuncs(TimeSpan, attrs.slice(2)); TimeSpan.prototype.set = function (days, hours, minutes, seconds, milliseconds){ this.setDays(days || this.getDays()); this.setHours(hours || this.getHours()); this.setMinutes(minutes || this.getMinutes()); this.setSeconds(seconds || this.getSeconds()); this.setMilliseconds(milliseconds || this.getMilliseconds()); }; /** * Gets the time of day for this date instances. * @return {TimeSpan} TimeSpan */ Date.prototype.getTimeOfDay = function () { return new TimeSpan(0, this.getHours(), this.getMinutes(), this.getSeconds(), this.getMilliseconds()); }; Date.TimeSpan = TimeSpan; if (typeof window !== "undefined" ) { // keeping API compatible for v1.x window.TimeSpan = TimeSpan; } }()); (function () { "use strict"; var attrs = ["years", "months", "days", "hours", "minutes", "seconds", "milliseconds"]; var gFn = function (attr) { return function () { return this[attr]; }; }; var sFn = function (attr) { return function (val) { this[attr] = val; return this; }; }; var addSetFuncs = function (context, attrs) { for (var i = 0; i < attrs.length ; i++) { var $a = attrs[i], $b = $a.slice(0, 1).toUpperCase() + $a.slice(1); context.prototype[$a] = 0; context.prototype["get" + $b] = gFn($a); context.prototype["set" + $b] = sFn($a); } }; var setMonthsAndYears = function (orient, d1, d2, context) { function inc() { d1.addMonths(-orient); context.months++; if (context.months === 12) { context.years++; context.months = 0; } } if (orient === +1) { while (d1 > d2) { inc(); } } else { while (d1 < d2) { inc(); } } context.months--; context.months *= orient; context.years *= orient; }; var adjustForDST = function(orient, startDate, endDate) { var hasDSTMismatch = (false === (startDate.isDaylightSavingTime() === endDate.isDaylightSavingTime())); if (hasDSTMismatch && orient === 1) { startDate.addHours(-1); } else if (hasDSTMismatch) { startDate.addHours(1); } }; /** * TimePeriod(startDate, endDate); * TimePeriod(years, months, days, hours, minutes, seconds, milliseconds); */ var TimePeriod = function (years, months, days, hours, minutes, seconds, milliseconds) { if (arguments.length === 7) { this.set(years, months, days, hours, minutes, seconds, milliseconds); } else if (arguments.length === 2 && arguments[0] instanceof Date && arguments[1] instanceof Date) { var startDate = arguments[0].clone(); var endDate = arguments[1].clone(); var orient = (startDate > endDate) ? +1 : -1; this.dates = { start: arguments[0].clone(), end: arguments[1].clone() }; setMonthsAndYears(orient, startDate, endDate, this); adjustForDST(orient, startDate, endDate); // // TODO - adjust for DST var diff = endDate - startDate; if (diff !== 0) { var ts = new TimeSpan(diff); this.set(this.years, this.months, ts.getDays(), ts.getHours(), ts.getMinutes(), ts.getSeconds(), ts.getMilliseconds()); } } return this; }; // create all the set functions. addSetFuncs(TimePeriod, attrs); TimePeriod.prototype.set = function (years, months, days, hours, minutes, seconds, milliseconds){ this.setYears(years || this.getYears()); this.setMonths(months || this.getMonths()); this.setDays(days || this.getDays()); this.setHours(hours || this.getHours()); this.setMinutes(minutes || this.getMinutes()); this.setSeconds(seconds || this.getSeconds()); this.setMilliseconds(milliseconds || this.getMilliseconds()); }; Date.TimePeriod = TimePeriod; if (typeof window !== "undefined") { // keeping API compatible for v1.x window.TimePeriod = TimePeriod; } }()); ================================================ FILE: build/date-ar-TN.js ================================================ /** * @overview datejs * @version 1.0.0-rc3 * @author Gregory Wild-Smith * @copyright 2015 Gregory Wild-Smith * @license MIT * @homepage https://github.com/abritinthebay/datejs */ /* * DateJS Culture String File * Country Code: ar-TN * Name: Arabic (Tunisia) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["ar-TN"] = { "name": "ar-TN", "englishName": "Arabic (Tunisia)", "nativeName": "العربية (تونس)", "Sunday": "الاحد", "Monday": "الاثنين", "Tuesday": "الثلاثاء", "Wednesday": "الاربعاء", "Thursday": "الخميس", "Friday": "الجمعة", "Saturday": "السبت", "Sun": "الاحد", "Mon": "الاثنين", "Tue": "الثلاثاء", "Wed": "الاربعاء", "Thu": "الخميس", "Fri": "الجمعة", "Sat": "السبت", "Su": "أ", "Mo": "ا", "Tu": "ث", "We": "أ", "Th": "خ", "Fr": "ج", "Sa": "س", "S_Sun_Initial": "أ", "M_Mon_Initial": "ا", "T_Tue_Initial": "ث", "W_Wed_Initial": "أ", "T_Thu_Initial": "خ", "F_Fri_Initial": "ج", "S_Sat_Initial": "س", "January": "جانفي", "February": "فيفري", "March": "مارس", "April": "افريل", "May": "ماي", "June": "جوان", "July": "جويلية", "August": "اوت", "September": "سبتمبر", "October": "اكتوبر", "November": "نوفمبر", "December": "ديسمبر", "Jan_Abbr": "جانفي", "Feb_Abbr": "فيفري", "Mar_Abbr": "مارس", "Apr_Abbr": "افريل", "May_Abbr": "ماي", "Jun_Abbr": "جوان", "Jul_Abbr": "جويلية", "Aug_Abbr": "اوت", "Sep_Abbr": "سبتمبر", "Oct_Abbr": "اكتوبر", "Nov_Abbr": "نوفمبر", "Dec_Abbr": "ديسمبر", "AM": "ص", "PM": "م", "firstDayOfWeek": 1, "twoDigitYearMax": 2029, "mdy": "dmy", "M/d/yyyy": "dd-MM-yyyy", "dddd, MMMM dd, yyyy": "dd MMMM, yyyy", "h:mm tt": "H:mm", "h:mm:ss tt": "H:mm:ss", "dddd, MMMM dd, yyyy h:mm:ss tt": "dd MMMM, yyyy H:mm:ss", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "dd MMMM", "MMMM, yyyy": "MMMM, yyyy", "/jan(uary)?/": "جانفي", "/feb(ruary)?/": "فيفري", "/mar(ch)?/": "مارس", "/apr(il)?/": "افريل", "/may/": "ماي", "/jun(e)?/": "جوان", "/jul(y)?/": "جويلية", "/aug(ust)?/": "اوت", "/sep(t(ember)?)?/": "سبتمبر", "/oct(ober)?/": "اكتوبر", "/nov(ember)?/": "نوفمبر", "/dec(ember)?/": "ديسمبر", "/^su(n(day)?)?/": "^الاحد", "/^mo(n(day)?)?/": "^ا(1)?", "/^tu(e(s(day)?)?)?/": "^الثلاثاء", "/^we(d(nesday)?)?/": "^الاربعاء", "/^th(u(r(s(day)?)?)?)?/": "^الخميس", "/^fr(i(day)?)?/": "^الجمعة", "/^sa(t(urday)?)?/": "^السبت", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "ar-TN"; /** * @overview datejs * @version 1.0.0-rc3 * @author Gregory Wild-Smith * @copyright 2015 Gregory Wild-Smith * @license MIT * @homepage https://github.com/abritinthebay/datejs */(function () { var $D = Date; var lang = Date.CultureStrings ? Date.CultureStrings.lang : null; var loggedKeys = {}; // for debug purposes. var getText = { getFromKey: function (key, countryCode) { var output; if (Date.CultureStrings && Date.CultureStrings[countryCode] && Date.CultureStrings[countryCode][key]) { output = Date.CultureStrings[countryCode][key]; } else { output = getText.buildFromDefault(key); } if (key.charAt(0) === "/") { // Assume it's a regex output = getText.buildFromRegex(key, countryCode); } return output; }, getFromObjectValues: function (obj, countryCode) { var key, output = {}; for(key in obj) { if (obj.hasOwnProperty(key)) { output[key] = getText.getFromKey(obj[key], countryCode); } } return output; }, getFromObjectKeys: function (obj, countryCode) { var key, output = {}; for(key in obj) { if (obj.hasOwnProperty(key)) { output[getText.getFromKey(key, countryCode)] = obj[key]; } } return output; }, getFromArray: function (arr, countryCode) { var output = []; for (var i=0; i < arr.length; i++){ if (i in arr) { output[i] = getText.getFromKey(arr[i], countryCode); } } return output; }, buildFromDefault: function (key) { var output, length, split, last; switch(key) { case "name": output = "en-US"; break; case "englishName": output = "English (United States)"; break; case "nativeName": output = "English (United States)"; break; case "twoDigitYearMax": output = 2049; break; case "firstDayOfWeek": output = 0; break; default: output = key; split = key.split("_"); length = split.length; if (length > 1 && key.charAt(0) !== "/") { // if the key isn't a regex and it has a split. last = split[(length - 1)].toLowerCase(); if (last === "initial" || last === "abbr") { output = split[0]; } } break; } return output; }, buildFromRegex: function (key, countryCode) { var output; if (Date.CultureStrings && Date.CultureStrings[countryCode] && Date.CultureStrings[countryCode][key]) { output = new RegExp(Date.CultureStrings[countryCode][key], "i"); } else { output = new RegExp(key.replace(new RegExp("/", "g"),""), "i"); } return output; } }; var shallowMerge = function (obj1, obj2) { for (var attrname in obj2) { if (obj2.hasOwnProperty(attrname)) { obj1[attrname] = obj2[attrname]; } } }; var __ = function (key, language) { var countryCode = (language) ? language : lang; loggedKeys[key] = key; if (typeof key === "object") { if (key instanceof Array) { return getText.getFromArray(key, countryCode); } else { return getText.getFromObjectKeys(key, countryCode); } } else { return getText.getFromKey(key, countryCode); } }; var loadI18nScript = function (code) { // paatterned after jQuery's getScript. var url = Date.Config.i18n + code + ".js"; var head = document.getElementsByTagName("head")[0] || document.documentElement; var script = document.createElement("script"); script.src = url; var completed = false; var events = { done: function (){} // placeholder function }; // Attach handlers for all browsers script.onload = script.onreadystatechange = function() { if ( !completed && (!this.readyState || this.readyState === "loaded" || this.readyState === "complete") ) { events.done(); head.removeChild(script); } }; setTimeout(function() { head.insertBefore(script, head.firstChild); }, 0); // allows return to execute first return { done: function (cb) { events.done = function() { if (cb) { setTimeout(cb,0); } }; } }; }; var buildInfo = { buildFromMethodHash: function (obj) { var key; for(key in obj) { if (obj.hasOwnProperty(key)) { obj[key] = buildInfo[obj[key]](); } } return obj; }, timeZoneDST: function () { var DST = { "CHADT": "+1345", "NZDT": "+1300", "AEDT": "+1100", "ACDT": "+1030", "AZST": "+0500", "IRDT": "+0430", "EEST": "+0300", "CEST": "+0200", "BST": "+0100", "PMDT": "-0200", "ADT": "-0300", "NDT": "-0230", "EDT": "-0400", "CDT": "-0500", "MDT": "-0600", "PDT": "-0700", "AKDT": "-0800", "HADT": "-0900" }; return __(DST); }, timeZoneStandard: function () { var standard = { "LINT": "+1400", "TOT": "+1300", "CHAST": "+1245", "NZST": "+1200", "NFT": "+1130", "SBT": "+1100", "AEST": "+1000", "ACST": "+0930", "JST": "+0900", "CWST": "+0845", "CT": "+0800", "ICT": "+0700", "MMT": "+0630", "BST": "+0600", "NPT": "+0545", "IST": "+0530", "PKT": "+0500", "AFT": "+0430", "MSK": "+0400", "IRST": "+0330", "FET": "+0300", "EET": "+0200", "CET": "+0100", "GMT": "+0000", "UTC": "+0000", "CVT": "-0100", "GST": "-0200", "BRT": "-0300", "NST": "-0330", "AST": "-0400", "EST": "-0500", "CST": "-0600", "MST": "-0700", "PST": "-0800", "AKST": "-0900", "MIT": "-0930", "HST": "-1000", "SST": "-1100", "BIT": "-1200" }; return __(standard); }, timeZones: function (data) { var zone; data.timezones = []; for (zone in data.abbreviatedTimeZoneStandard) { if (data.abbreviatedTimeZoneStandard.hasOwnProperty(zone)) { data.timezones.push({ name: zone, offset: data.abbreviatedTimeZoneStandard[zone]}); } } for (zone in data.abbreviatedTimeZoneDST) { if (data.abbreviatedTimeZoneDST.hasOwnProperty(zone)) { data.timezones.push({ name: zone, offset: data.abbreviatedTimeZoneDST[zone], dst: true}); } } return data.timezones; }, days: function () { return __(["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"]); }, dayAbbr: function () { return __(["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"]); }, dayShortNames: function () { return __(["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"]); }, dayFirstLetters: function () { return __(["S_Sun_Initial", "M_Mon_Initial", "T_Tues_Initial", "W_Wed_Initial", "T_Thu_Initial", "F_Fri_Initial", "S_Sat_Initial"]); }, months: function () { return __(["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"]); }, monthAbbr: function () { return __(["Jan_Abbr", "Feb_Abbr", "Mar_Abbr", "Apr_Abbr", "May_Abbr", "Jun_Abbr", "Jul_Abbr", "Aug_Abbr", "Sep_Abbr", "Oct_Abbr", "Nov_Abbr", "Dec_Abbr"]); }, formatPatterns: function () { return getText.getFromObjectValues({ shortDate: "M/d/yyyy", longDate: "dddd, MMMM dd, yyyy", shortTime: "h:mm tt", longTime: "h:mm:ss tt", fullDateTime: "dddd, MMMM dd, yyyy h:mm:ss tt", sortableDateTime: "yyyy-MM-ddTHH:mm:ss", universalSortableDateTime: "yyyy-MM-dd HH:mm:ssZ", rfc1123: "ddd, dd MMM yyyy HH:mm:ss", monthDay: "MMMM dd", yearMonth: "MMMM, yyyy" }, Date.i18n.currentLanguage()); }, regex: function () { return getText.getFromObjectValues({ inTheMorning: "/( in the )(morn(ing)?)\\b/", thisMorning: "/(this )(morn(ing)?)\\b/", amThisMorning: "/(\b\\d(am)? )(this )(morn(ing)?)/", inTheEvening: "/( in the )(even(ing)?)\\b/", thisEvening: "/(this )(even(ing)?)\\b/", pmThisEvening: "/(\b\\d(pm)? )(this )(even(ing)?)/", jan: "/jan(uary)?/", feb: "/feb(ruary)?/", mar: "/mar(ch)?/", apr: "/apr(il)?/", may: "/may/", jun: "/jun(e)?/", jul: "/jul(y)?/", aug: "/aug(ust)?/", sep: "/sep(t(ember)?)?/", oct: "/oct(ober)?/", nov: "/nov(ember)?/", dec: "/dec(ember)?/", sun: "/^su(n(day)?)?/", mon: "/^mo(n(day)?)?/", tue: "/^tu(e(s(day)?)?)?/", wed: "/^we(d(nesday)?)?/", thu: "/^th(u(r(s(day)?)?)?)?/", fri: "/fr(i(day)?)?/", sat: "/^sa(t(urday)?)?/", future: "/^next/", past: "/^last|past|prev(ious)?/", add: "/^(\\+|aft(er)?|from|hence)/", subtract: "/^(\\-|bef(ore)?|ago)/", yesterday: "/^yes(terday)?/", today: "/^t(od(ay)?)?/", tomorrow: "/^tom(orrow)?/", now: "/^n(ow)?/", millisecond: "/^ms|milli(second)?s?/", second: "/^sec(ond)?s?/", minute: "/^mn|min(ute)?s?/", hour: "/^h(our)?s?/", week: "/^w(eek)?s?/", month: "/^m(onth)?s?/", day: "/^d(ay)?s?/", year: "/^y(ear)?s?/", shortMeridian: "/^(a|p)/", longMeridian: "/^(a\\.?m?\\.?|p\\.?m?\\.?)/", timezone: "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/", ordinalSuffix: "/^\\s*(st|nd|rd|th)/", timeContext: "/^\\s*(\\:|a(?!u|p)|p)/" }, Date.i18n.currentLanguage()); } }; var CultureInfo = function () { var info = getText.getFromObjectValues({ name: "name", englishName: "englishName", nativeName: "nativeName", amDesignator: "AM", pmDesignator: "PM", firstDayOfWeek: "firstDayOfWeek", twoDigitYearMax: "twoDigitYearMax", dateElementOrder: "mdy" }, Date.i18n.currentLanguage()); var constructedInfo = buildInfo.buildFromMethodHash({ dayNames: "days", abbreviatedDayNames: "dayAbbr", shortestDayNames: "dayShortNames", firstLetterDayNames: "dayFirstLetters", monthNames: "months", abbreviatedMonthNames: "monthAbbr", formatPatterns: "formatPatterns", regexPatterns: "regex", abbreviatedTimeZoneDST: "timeZoneDST", abbreviatedTimeZoneStandard: "timeZoneStandard" }); shallowMerge(info, constructedInfo); buildInfo.timeZones(info); return info; }; $D.i18n = { __: function (key, lang) { return __(key, lang); }, currentLanguage: function () { return lang || "en-US"; }, setLanguage: function (code, force, cb) { var async = false; if (force || code === "en-US" || (!!Date.CultureStrings && !!Date.CultureStrings[code])) { lang = code; Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings.lang = code; Date.CultureInfo = new CultureInfo(); } else { if (!(!!Date.CultureStrings && !!Date.CultureStrings[code])) { if (typeof exports !== "undefined" && this.exports !== exports) { // we're in a Node enviroment, load it using require try { require("../i18n/" + code + ".js"); lang = code; Date.CultureStrings.lang = code; Date.CultureInfo = new CultureInfo(); } catch (e) { // var str = "The language for '" + code + "' could not be loaded by Node. It likely does not exist."; throw new Error("The DateJS IETF language tag '" + code + "' could not be loaded by Node. It likely does not exist."); } } else if (Date.Config && Date.Config.i18n) { // we know the location of the files, so lets load them async = true; loadI18nScript(code).done(function(){ lang = code; Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings.lang = code; Date.CultureInfo = new CultureInfo(); $D.Parsing.Normalizer.buildReplaceData(); // because this is async if ($D.Grammar) { $D.Grammar.buildGrammarFormats(); // so we can parse those strings... } if (cb) { setTimeout(cb,0); } }); } else { Date.console.error("The DateJS IETF language tag '" + code + "' is not available and has not been loaded."); return false; } } } $D.Parsing.Normalizer.buildReplaceData(); // rebuild normalizer strings if ($D.Grammar) { $D.Grammar.buildGrammarFormats(); // so we can parse those strings... } if (!async && cb) { setTimeout(cb,0); } }, getLoggedKeys: function () { return loggedKeys; }, updateCultureInfo: function () { Date.CultureInfo = new CultureInfo(); } }; $D.i18n.updateCultureInfo(); // run automatically }()); (function () { var $D = Date, $P = $D.prototype, p = function (s, l) { if (!l) { l = 2; } return ("000" + s).slice(l * -1); }; if (typeof window !== "undefined" && typeof window.console !== "undefined" && typeof window.console.log !== "undefined") { $D.console = console; // used only to raise non-critical errors if available } else { // set mock so we don't give errors. $D.console = { log: function(){}, error: function(){} }; } $D.Config = $D.Config || {}; $D.initOverloads = function() { /** * Overload of Date.now. Allows an alternate call for Date.now where it returns the * current Date as an object rather than just milliseconds since the Unix Epoch. * * Also provides an implementation of now() for browsers (IE<9) that don't have it. * * Backwards compatible so with work with either: * Date.now() [returns ms] * or * Date.now(true) [returns Date] */ if (!$D.now) { $D._now = function now() { return new Date().getTime(); }; } else if (!$D._now) { $D._now = $D.now; } $D.now = function (returnObj) { if (returnObj) { return $D.present(); } else { return $D._now(); } }; if ( !$P.toISOString ) { $P.toISOString = function() { return this.getUTCFullYear() + "-" + p(this.getUTCMonth() + 1) + "-" + p(this.getUTCDate()) + "T" + p(this.getUTCHours()) + ":" + p(this.getUTCMinutes()) + ":" + p(this.getUTCSeconds()) + "." + String( (this.getUTCMilliseconds()/1000).toFixed(3)).slice(2, 5) + "Z"; }; } // private if ( $P._toString === undefined ){ $P._toString = $P.toString; } }; $D.initOverloads(); /** * Gets a date that is set to the current date. The time is set to the start of the day (00:00 or 12:00 AM). * @return {Date} The current date. */ $D.today = function () { return new Date().clearTime(); }; /** * Gets a date that is set to the current date and time (same as new Date, but chainable) * @return {Date} The current date. */ $D.present = function () { return new Date(); }; /** * Compares the first date to the second date and returns an number indication of their relative values. * @param {Date} First Date object to compare [Required]. * @param {Date} Second Date object to compare to [Required]. * @return {Number} -1 = date1 is lessthan date2. 0 = values are equal. 1 = date1 is greaterthan date2. */ $D.compare = function (date1, date2) { if (isNaN(date1) || isNaN(date2)) { throw new Error(date1 + " - " + date2); } else if (date1 instanceof Date && date2 instanceof Date) { return (date1 < date2) ? -1 : (date1 > date2) ? 1 : 0; } else { throw new TypeError(date1 + " - " + date2); } }; /** * Compares the first Date object to the second Date object and returns true if they are equal. * @param {Date} First Date object to compare [Required] * @param {Date} Second Date object to compare to [Required] * @return {Boolean} true if dates are equal. false if they are not equal. */ $D.equals = function (date1, date2) { return (date1.compareTo(date2) === 0); }; /** * Gets the language appropriate day name when given the day number(0-6) * eg - 0 == Sunday * @return {String} The day name */ $D.getDayName = function (n) { return Date.CultureInfo.dayNames[n]; }; /** * Gets the day number (0-6) if given a CultureInfo specific string which is a valid dayName, abbreviatedDayName or shortestDayName (two char). * @param {String} The name of the day (eg. "Monday, "Mon", "tuesday", "tue", "We", "we"). * @return {Number} The day number */ $D.getDayNumberFromName = function (name) { var n = Date.CultureInfo.dayNames, m = Date.CultureInfo.abbreviatedDayNames, o = Date.CultureInfo.shortestDayNames, s = name.toLowerCase(); for (var i = 0; i < n.length; i++) { if (n[i].toLowerCase() === s || m[i].toLowerCase() === s || o[i].toLowerCase() === s) { return i; } } return -1; }; /** * Gets the month number (0-11) if given a Culture Info specific string which is a valid monthName or abbreviatedMonthName. * @param {String} The name of the month (eg. "February, "Feb", "october", "oct"). * @return {Number} The day number */ $D.getMonthNumberFromName = function (name) { var n = Date.CultureInfo.monthNames, m = Date.CultureInfo.abbreviatedMonthNames, s = name.toLowerCase(); for (var i = 0; i < n.length; i++) { if (n[i].toLowerCase() === s || m[i].toLowerCase() === s) { return i; } } return -1; }; /** * Gets the language appropriate month name when given the month number(0-11) * eg - 0 == January * @return {String} The month name */ $D.getMonthName = function (n) { return Date.CultureInfo.monthNames[n]; }; /** * Determines if the current date instance is within a LeapYear. * @param {Number} The year. * @return {Boolean} true if date is within a LeapYear, otherwise false. */ $D.isLeapYear = function (year) { return ((year % 4 === 0 && year % 100 !== 0) || year % 400 === 0); }; /** * Gets the number of days in the month, given a year and month value. Automatically corrects for LeapYear. * @param {Number} The year. * @param {Number} The month (0-11). * @return {Number} The number of days in the month. */ $D.getDaysInMonth = function (year, month) { if (!month && $D.validateMonth(year)) { month = year; year = Date.today().getFullYear(); } return [31, ($D.isLeapYear(year) ? 29 : 28), 31, 30, 31, 30, 31, 31, 30, 31, 30, 31][month]; }; $P.getDaysInMonth = function () { return $D.getDaysInMonth(this.getFullYear(), this.getMonth()); }; $D.getTimezoneAbbreviation = function (offset, dst) { var p, n = (dst || false) ? Date.CultureInfo.abbreviatedTimeZoneDST : Date.CultureInfo.abbreviatedTimeZoneStandard; for (p in n) { if (n.hasOwnProperty(p)) { if (n[p] === offset) { return p; } } } return null; }; $D.getTimezoneOffset = function (name, dst) { var i, a =[], z = Date.CultureInfo.timezones; if (!name) { name = (new Date()).getTimezone();} for (i = 0; i < z.length; i++) { if (z[i].name === name.toUpperCase()) { a.push(i); } } if (!z[a[0]]) { return null; } if (a.length === 1 || !dst) { return z[a[0]].offset; } else { for (i=0; i < a.length; i++) { if (z[a[i]].dst) { return z[a[i]].offset; } } } }; $D.getQuarter = function (d) { d = d || new Date(); // If no date supplied, use today var q = [1,2,3,4]; return q[Math.floor(d.getMonth() / 3)]; // ~~~ is a bitwise op. Faster than Math.floor }; $D.getDaysLeftInQuarter = function (d) { d = d || new Date(); var qEnd = new Date(d); qEnd.setMonth(qEnd.getMonth() + 3 - qEnd.getMonth() % 3, 0); return Math.floor((qEnd - d) / 8.64e7); }; // private var validate = function (n, min, max, name) { name = name ? name : "Object"; if (typeof n === "undefined") { return false; } else if (typeof n !== "number") { throw new TypeError(n + " is not a Number."); } else if (n < min || n > max) { // As failing validation is *not* an exceptional circumstance // lets not throw a RangeError Exception here. // It's semantically correct but it's not sensible. return false; } return true; }; /** * Validates the number is within an acceptable range for milliseconds [0-999]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateMillisecond = function (value) { return validate(value, 0, 999, "millisecond"); }; /** * Validates the number is within an acceptable range for seconds [0-59]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateSecond = function (value) { return validate(value, 0, 59, "second"); }; /** * Validates the number is within an acceptable range for minutes [0-59]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateMinute = function (value) { return validate(value, 0, 59, "minute"); }; /** * Validates the number is within an acceptable range for hours [0-23]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateHour = function (value) { return validate(value, 0, 23, "hour"); }; /** * Validates the number is within an acceptable range for the days in a month [0-MaxDaysInMonth]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateDay = function (value, year, month) { if (year === undefined || year === null || month === undefined || month === null) { return false;} return validate(value, 1, $D.getDaysInMonth(year, month), "day"); }; /** * Validates the number is within an acceptable range for months [0-11]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateWeek = function (value) { return validate(value, 0, 53, "week"); }; /** * Validates the number is within an acceptable range for months [0-11]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateMonth = function (value) { return validate(value, 0, 11, "month"); }; /** * Validates the number is within an acceptable range for years. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateYear = function (value) { /** * Per ECMAScript spec the range of times supported by Date objects is * exactly -100,000,000 days to +100,000,000 days measured relative to * midnight at the beginning of 01 January, 1970 UTC. * This gives a range of 8,640,000,000,000,000 milliseconds to either * side of 01 January, 1970 UTC. * * Earliest possible date: Tue, 20 Apr 271,822 B.C. 00:00:00 UTC * Latest possible date: Sat, 13 Sep 275,760 00:00:00 UTC */ return validate(value, -271822, 275760, "year"); }; $D.validateTimezone = function(value) { var timezones = {"ACDT":1,"ACST":1,"ACT":1,"ADT":1,"AEDT":1,"AEST":1,"AFT":1,"AKDT":1,"AKST":1,"AMST":1,"AMT":1,"ART":1,"AST":1,"AWDT":1,"AWST":1,"AZOST":1,"AZT":1,"BDT":1,"BIOT":1,"BIT":1,"BOT":1,"BRT":1,"BST":1,"BTT":1,"CAT":1,"CCT":1,"CDT":1,"CEDT":1,"CEST":1,"CET":1,"CHADT":1,"CHAST":1,"CHOT":1,"ChST":1,"CHUT":1,"CIST":1,"CIT":1,"CKT":1,"CLST":1,"CLT":1,"COST":1,"COT":1,"CST":1,"CT":1,"CVT":1,"CWST":1,"CXT":1,"DAVT":1,"DDUT":1,"DFT":1,"EASST":1,"EAST":1,"EAT":1,"ECT":1,"EDT":1,"EEDT":1,"EEST":1,"EET":1,"EGST":1,"EGT":1,"EIT":1,"EST":1,"FET":1,"FJT":1,"FKST":1,"FKT":1,"FNT":1,"GALT":1,"GAMT":1,"GET":1,"GFT":1,"GILT":1,"GIT":1,"GMT":1,"GST":1,"GYT":1,"HADT":1,"HAEC":1,"HAST":1,"HKT":1,"HMT":1,"HOVT":1,"HST":1,"ICT":1,"IDT":1,"IOT":1,"IRDT":1,"IRKT":1,"IRST":1,"IST":1,"JST":1,"KGT":1,"KOST":1,"KRAT":1,"KST":1,"LHST":1,"LINT":1,"MAGT":1,"MART":1,"MAWT":1,"MDT":1,"MET":1,"MEST":1,"MHT":1,"MIST":1,"MIT":1,"MMT":1,"MSK":1,"MST":1,"MUT":1,"MVT":1,"MYT":1,"NCT":1,"NDT":1,"NFT":1,"NPT":1,"NST":1,"NT":1,"NUT":1,"NZDT":1,"NZST":1,"OMST":1,"ORAT":1,"PDT":1,"PET":1,"PETT":1,"PGT":1,"PHOT":1,"PHT":1,"PKT":1,"PMDT":1,"PMST":1,"PONT":1,"PST":1,"PYST":1,"PYT":1,"RET":1,"ROTT":1,"SAKT":1,"SAMT":1,"SAST":1,"SBT":1,"SCT":1,"SGT":1,"SLST":1,"SRT":1,"SST":1,"SYOT":1,"TAHT":1,"THA":1,"TFT":1,"TJT":1,"TKT":1,"TLT":1,"TMT":1,"TOT":1,"TVT":1,"UCT":1,"ULAT":1,"UTC":1,"UYST":1,"UYT":1,"UZT":1,"VET":1,"VLAT":1,"VOLT":1,"VOST":1,"VUT":1,"WAKT":1,"WAST":1,"WAT":1,"WEDT":1,"WEST":1,"WET":1,"WST":1,"YAKT":1,"YEKT":1,"Z":1}; return (timezones[value] === 1); }; $D.validateTimezoneOffset= function(value) { // timezones go from +14hrs to -12hrs, the +X hours are negative offsets. return (value > -841 && value < 721); }; }()); (function () { var $D = Date, $P = $D.prototype, p = function (s, l) { if (!l) { l = 2; } return ("000" + s).slice(l * -1); }; var validateConfigObject = function (obj) { var result = {}, self = this, prop, testFunc; testFunc = function (prop, func, value) { if (prop === "day") { var month = (obj.month !== undefined) ? obj.month : self.getMonth(); var year = (obj.year !== undefined) ? obj.year : self.getFullYear(); return $D[func](value, year, month); } else { return $D[func](value); } }; for (prop in obj) { if (Object.prototype.hasOwnProperty.call(obj, prop)) { var func = "validate" + prop.charAt(0).toUpperCase() + prop.slice(1); if ($D[func] && obj[prop] !== null && testFunc(prop, func, obj[prop])) { result[prop] = obj[prop]; } } } return result; }; /** * Resets the time of this Date object to 12:00 AM (00:00), which is the start of the day. * @param {Boolean} .clone() this date instance before clearing Time * @return {Date} this */ $P.clearTime = function () { this.setHours(0); this.setMinutes(0); this.setSeconds(0); this.setMilliseconds(0); return this; }; /** * Resets the time of this Date object to the current time ('now'). * @return {Date} this */ $P.setTimeToNow = function () { var n = new Date(); this.setHours(n.getHours()); this.setMinutes(n.getMinutes()); this.setSeconds(n.getSeconds()); this.setMilliseconds(n.getMilliseconds()); return this; }; /** * Returns a new Date object that is an exact date and time copy of the original instance. * @return {Date} A new Date instance */ $P.clone = function () { return new Date(this.getTime()); }; /** * Compares this instance to a Date object and returns an number indication of their relative values. * @param {Date} Date object to compare [Required] * @return {Number} -1 = this is lessthan date. 0 = values are equal. 1 = this is greaterthan date. */ $P.compareTo = function (date) { return Date.compare(this, date); }; /** * Compares this instance to another Date object and returns true if they are equal. * @param {Date} Date object to compare. If no date to compare, new Date() [now] is used. * @return {Boolean} true if dates are equal. false if they are not equal. */ $P.equals = function (date) { return Date.equals(this, (date !== undefined ? date : new Date())); }; /** * Determines if this instance is between a range of two dates or equal to either the start or end dates. * @param {Date} Start of range [Required] * @param {Date} End of range [Required] * @return {Boolean} true is this is between or equal to the start and end dates, else false */ $P.between = function (start, end) { return this.getTime() >= start.getTime() && this.getTime() <= end.getTime(); }; /** * Determines if this date occurs after the date to compare to. * @param {Date} Date object to compare. If no date to compare, new Date() ("now") is used. * @return {Boolean} true if this date instance is greater than the date to compare to (or "now"), otherwise false. */ $P.isAfter = function (date) { return this.compareTo(date || new Date()) === 1; }; /** * Determines if this date occurs before the date to compare to. * @param {Date} Date object to compare. If no date to compare, new Date() ("now") is used. * @return {Boolean} true if this date instance is less than the date to compare to (or "now"). */ $P.isBefore = function (date) { return (this.compareTo(date || new Date()) === -1); }; /** * Determines if the current Date instance occurs today. * @return {Boolean} true if this date instance is 'today', otherwise false. */ /** * Determines if the current Date instance occurs on the same Date as the supplied 'date'. * If no 'date' to compare to is provided, the current Date instance is compared to 'today'. * @param {date} Date object to compare. If no date to compare, the current Date ("now") is used. * @return {Boolean} true if this Date instance occurs on the same Day as the supplied 'date'. */ $P.isToday = $P.isSameDay = function (date) { return this.clone().clearTime().equals((date || new Date()).clone().clearTime()); }; /** * Adds the specified number of milliseconds to this instance. * @param {Number} The number of milliseconds to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addMilliseconds = function (value) { if (!value) { return this; } this.setTime(this.getTime() + value * 1); return this; }; /** * Adds the specified number of seconds to this instance. * @param {Number} The number of seconds to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addSeconds = function (value) { if (!value) { return this; } return this.addMilliseconds(value * 1000); }; /** * Adds the specified number of seconds to this instance. * @param {Number} The number of seconds to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addMinutes = function (value) { if (!value) { return this; } return this.addMilliseconds(value * 60000); // 60*1000 }; /** * Adds the specified number of hours to this instance. * @param {Number} The number of hours to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addHours = function (value) { if (!value) { return this; } return this.addMilliseconds(value * 3600000); // 60*60*1000 }; /** * Adds the specified number of days to this instance. * @param {Number} The number of days to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addDays = function (value) { if (!value) { return this; } this.setDate(this.getDate() + value * 1); return this; }; /** * Adds the specified number of weekdays (ie - not sat or sun) to this instance. * @param {Number} The number of days to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addWeekdays = function (value) { if (!value) { return this; } var day = this.getDay(); var weeks = (Math.ceil(Math.abs(value)/7)); if (day === 0 || day === 6) { if (value > 0) { this.next().monday(); this.addDays(-1); day = this.getDay(); } } if (value < 0) { while (value < 0) { this.addDays(-1); day = this.getDay(); if (day !== 0 && day !== 6) { value++; } } return this; } else if (value > 5 || (6-day) <= value) { value = value + (weeks * 2); } return this.addDays(value); }; /** * Adds the specified number of weeks to this instance. * @param {Number} The number of weeks to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addWeeks = function (value) { if (!value) { return this; } return this.addDays(value * 7); }; /** * Adds the specified number of months to this instance. * @param {Number} The number of months to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addMonths = function (value) { if (!value) { return this; } var n = this.getDate(); this.setDate(1); this.setMonth(this.getMonth() + value * 1); this.setDate(Math.min(n, $D.getDaysInMonth(this.getFullYear(), this.getMonth()))); return this; }; $P.addQuarters = function (value) { if (!value) { return this; } // note this will take you to the same point in the quarter as you are now. // i.e. - if you are 15 days into the quarter you'll be 15 days into the resulting one. // bonus: this allows adding fractional quarters return this.addMonths(value * 3); }; /** * Adds the specified number of years to this instance. * @param {Number} The number of years to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addYears = function (value) { if (!value) { return this; } return this.addMonths(value * 12); }; /** * Adds (or subtracts) to the value of the years, months, weeks, days, hours, minutes, seconds, milliseconds of the date instance using given configuration object. Positive and Negative values allowed. * Example

	Date.today().add( { days: 1, months: 1 } )

	new Date().add( { years: -1 } )
	
* @param {Object} Configuration object containing attributes (months, days, etc.) * @return {Date} this */ $P.add = function (config) { if (typeof config === "number") { this._orient = config; return this; } var x = config; if (x.day) { // If we should be a different date than today (eg: for 'tomorrow -1d', etc). // Should only effect parsing, not direct usage (eg, Finish and FinishExact) if ((x.day - this.getDate()) !== 0) { this.setDate(x.day); } } if (x.milliseconds) { this.addMilliseconds(x.milliseconds); } if (x.seconds) { this.addSeconds(x.seconds); } if (x.minutes) { this.addMinutes(x.minutes); } if (x.hours) { this.addHours(x.hours); } if (x.weeks) { this.addWeeks(x.weeks); } if (x.months) { this.addMonths(x.months); } if (x.years) { this.addYears(x.years); } if (x.days) { this.addDays(x.days); } return this; }; /** * Get the week number. Week one (1) is the week which contains the first Thursday of the year. Monday is considered the first day of the week. * The .getWeek() function does NOT convert the date to UTC. The local datetime is used. * Please use .getISOWeek() to get the week of the UTC converted date. * @return {Number} 1 to 53 */ $P.getWeek = function (utc) { // Create a copy of this date object var self, target = new Date(this.valueOf()); if (utc) { target.addMinutes(target.getTimezoneOffset()); self = target.clone(); } else { self = this; } // ISO week date weeks start on monday // so correct the day number var dayNr = (self.getDay() + 6) % 7; // ISO 8601 states that week 1 is the week // with the first thursday of that year. // Set the target date to the thursday in the target week target.setDate(target.getDate() - dayNr + 3); // Store the millisecond value of the target date var firstThursday = target.valueOf(); // Set the target to the first thursday of the year // First set the target to january first target.setMonth(0, 1); // Not a thursday? Correct the date to the next thursday if (target.getDay() !== 4) { target.setMonth(0, 1 + ((4 - target.getDay()) + 7) % 7); } // The weeknumber is the number of weeks between the // first thursday of the year and the thursday in the target week return 1 + Math.ceil((firstThursday - target) / 604800000); // 604800000 = 7 * 24 * 3600 * 1000 }; /** * Get the ISO 8601 week number. Week one ("01") is the week which contains the first Thursday of the year. Monday is considered the first day of the week. * The .getISOWeek() function does convert the date to it's UTC value. Please use .getWeek() to get the week of the local date. * @return {String} "01" to "53" */ $P.getISOWeek = function () { return p(this.getWeek(true)); }; /** * Moves the date to Monday of the week set. Week one (1) is the week which contains the first Thursday of the year. * @param {Number} A Number (1 to 53) that represents the week of the year. * @return {Date} this */ $P.setWeek = function (n) { if ((n - this.getWeek()) === 0) { if (this.getDay() !== 1) { return this.moveToDayOfWeek(1, (this.getDay() > 1 ? -1 : 1)); } else { return this; } } else { return this.moveToDayOfWeek(1, (this.getDay() > 1 ? -1 : 1)).addWeeks(n - this.getWeek()); } }; $P.setQuarter = function (qtr) { var month = Math.abs(((qtr-1) * 3) + 1); return this.setMonth(month, 1); }; $P.getQuarter = function () { return Date.getQuarter(this); }; $P.getDaysLeftInQuarter = function () { return Date.getDaysLeftInQuarter(this); }; /** * Moves the date to the next n'th occurrence of the dayOfWeek starting from the beginning of the month. The number (-1) is a magic number and will return the last occurrence of the dayOfWeek in the month. * @param {Number} The dayOfWeek to move to * @param {Number} The n'th occurrence to move to. Use (-1) to return the last occurrence in the month * @return {Date} this */ $P.moveToNthOccurrence = function (dayOfWeek, occurrence) { if (dayOfWeek === "Weekday") { if (occurrence > 0) { this.moveToFirstDayOfMonth(); if (this.is().weekday()) { occurrence -= 1; } } else if (occurrence < 0) { this.moveToLastDayOfMonth(); if (this.is().weekday()) { occurrence += 1; } } else { return this; } return this.addWeekdays(occurrence); } var shift = 0; if (occurrence > 0) { shift = occurrence - 1; } else if (occurrence === -1) { this.moveToLastDayOfMonth(); if (this.getDay() !== dayOfWeek) { this.moveToDayOfWeek(dayOfWeek, -1); } return this; } return this.moveToFirstDayOfMonth().addDays(-1).moveToDayOfWeek(dayOfWeek, +1).addWeeks(shift); }; var moveToN = function (getFunc, addFunc, nVal) { return function (value, orient) { var diff = (value - this[getFunc]() + nVal * (orient || +1)) % nVal; return this[addFunc]((diff === 0) ? diff += nVal * (orient || +1) : diff); }; }; /** * Move to the next or last dayOfWeek based on the orient value. * @param {Number} The dayOfWeek to move to * @param {Number} Forward (+1) or Back (-1). Defaults to +1. [Optional] * @return {Date} this */ $P.moveToDayOfWeek = moveToN("getDay", "addDays", 7); /** * Move to the next or last month based on the orient value. * @param {Number} The month to move to. 0 = January, 11 = December * @param {Number} Forward (+1) or Back (-1). Defaults to +1. [Optional] * @return {Date} this */ $P.moveToMonth = moveToN("getMonth", "addMonths", 12); /** * Get the Ordinate of the current day ("th", "st", "rd"). * @return {String} */ $P.getOrdinate = function () { var num = this.getDate(); return ord(num); }; /** * Get the Ordinal day (numeric day number) of the year, adjusted for leap year. * @return {Number} 1 through 365 (366 in leap years) */ $P.getOrdinalNumber = function () { return Math.ceil((this.clone().clearTime() - new Date(this.getFullYear(), 0, 1)) / 86400000) + 1; }; /** * Get the time zone abbreviation of the current date. * @return {String} The abbreviated time zone name (e.g. "EST") */ $P.getTimezone = function () { return $D.getTimezoneAbbreviation(this.getUTCOffset(), this.isDaylightSavingTime()); }; $P.setTimezoneOffset = function (offset) { var here = this.getTimezoneOffset(), there = Number(offset) * -6 / 10; return (there || there === 0) ? this.addMinutes(there - here) : this; }; $P.setTimezone = function (offset) { return this.setTimezoneOffset($D.getTimezoneOffset(offset)); }; /** * Indicates whether Daylight Saving Time is observed in the current time zone. * @return {Boolean} true|false */ $P.hasDaylightSavingTime = function () { return (Date.today().set({month: 0, day: 1}).getTimezoneOffset() !== Date.today().set({month: 6, day: 1}).getTimezoneOffset()); }; /** * Indicates whether this Date instance is within the Daylight Saving Time range for the current time zone. * @return {Boolean} true|false */ $P.isDaylightSavingTime = function () { return Date.today().set({month: 0, day: 1}).getTimezoneOffset() !== this.getTimezoneOffset(); }; /** * Get the offset from UTC of the current date. * @return {String} The 4-character offset string prefixed with + or - (e.g. "-0500") */ $P.getUTCOffset = function (offset) { var n = (offset || this.getTimezoneOffset()) * -10 / 6, r; if (n < 0) { r = (n - 10000).toString(); return r.charAt(0) + r.substr(2); } else { r = (n + 10000).toString(); return "+" + r.substr(1); } }; /** * Returns the number of milliseconds between this date and date. * @param {Date} Defaults to now * @return {Number} The diff in milliseconds */ $P.getElapsed = function (date) { return (date || new Date()) - this; }; /** * Set the value of year, month, day, hour, minute, second, millisecond of date instance using given configuration object. * Example

	Date.today().set( { day: 20, month: 1 } )

	new Date().set( { millisecond: 0 } )
	
* * @param {Object} Configuration object containing attributes (month, day, etc.) * @return {Date} this */ $P.set = function (config) { config = validateConfigObject.call(this, config); var key; for (key in config) { if (Object.prototype.hasOwnProperty.call(config, key)) { var name = key.charAt(0).toUpperCase() + key.slice(1); var addFunc, getFunc; if (key !== "week" && key !== "month" && key !== "timezone" && key !== "timezoneOffset") { name += "s"; } addFunc = "add" + name; getFunc = "get" + name; if (key === "month") { addFunc = addFunc + "s"; } else if (key === "year"){ getFunc = "getFullYear"; } if (key !== "day" && key !== "timezone" && key !== "timezoneOffset" && key !== "week" && key !== "hour") { this[addFunc](config[key] - this[getFunc]()); } else if ( key === "timezone"|| key === "timezoneOffset" || key === "week" || key === "hour") { this["set"+name](config[key]); } } } // day has to go last because you can't validate the day without first knowing the month if (config.day) { this.addDays(config.day - this.getDate()); } return this; }; /** * Moves the date to the first day of the month. * @return {Date} this */ $P.moveToFirstDayOfMonth = function () { return this.set({ day: 1 }); }; /** * Moves the date to the last day of the month. * @return {Date} this */ $P.moveToLastDayOfMonth = function () { return this.set({ day: $D.getDaysInMonth(this.getFullYear(), this.getMonth())}); }; /** * Converts the value of the current Date object to its equivalent string representation. * Format Specifiers * CUSTOM DATE AND TIME FORMAT STRINGS * Format Description Example * ------ --------------------------------------------------------------------------- ----------------------- * s The seconds of the minute between 0-59. "0" to "59" * ss The seconds of the minute with leading zero if required. "00" to "59" * * m The minute of the hour between 0-59. "0" or "59" * mm The minute of the hour with leading zero if required. "00" or "59" * * h The hour of the day between 1-12. "1" to "12" * hh The hour of the day with leading zero if required. "01" to "12" * * H The hour of the day between 0-23. "0" to "23" * HH The hour of the day with leading zero if required. "00" to "23" * * d The day of the month between 1 and 31. "1" to "31" * dd The day of the month with leading zero if required. "01" to "31" * ddd Abbreviated day name. Date.CultureInfo.abbreviatedDayNames. "Mon" to "Sun" * dddd The full day name. Date.CultureInfo.dayNames. "Monday" to "Sunday" * * M The month of the year between 1-12. "1" to "12" * MM The month of the year with leading zero if required. "01" to "12" * MMM Abbreviated month name. Date.CultureInfo.abbreviatedMonthNames. "Jan" to "Dec" * MMMM The full month name. Date.CultureInfo.monthNames. "January" to "December" * * yy The year as a two-digit number. "99" or "08" * yyyy The full four digit year. "1999" or "2008" * * t Displays the first character of the A.M./P.M. designator. "A" or "P" * Date.CultureInfo.amDesignator or Date.CultureInfo.pmDesignator * tt Displays the A.M./P.M. designator. "AM" or "PM" * Date.CultureInfo.amDesignator or Date.CultureInfo.pmDesignator * * S The ordinal suffix ("st, "nd", "rd" or "th") of the current day. "st, "nd", "rd" or "th" * * STANDARD DATE AND TIME FORMAT STRINGS * Format Description Example *------ --------------------------------------------------------------------------- ----------------------- * d The CultureInfo shortDate Format Pattern "M/d/yyyy" * D The CultureInfo longDate Format Pattern "dddd, MMMM dd, yyyy" * F The CultureInfo fullDateTime Format Pattern "dddd, MMMM dd, yyyy h:mm:ss tt" * m The CultureInfo monthDay Format Pattern "MMMM dd" * r The CultureInfo rfc1123 Format Pattern "ddd, dd MMM yyyy HH:mm:ss GMT" * s The CultureInfo sortableDateTime Format Pattern "yyyy-MM-ddTHH:mm:ss" * t The CultureInfo shortTime Format Pattern "h:mm tt" * T The CultureInfo longTime Format Pattern "h:mm:ss tt" * u The CultureInfo universalSortableDateTime Format Pattern "yyyy-MM-dd HH:mm:ssZ" * y The CultureInfo yearMonth Format Pattern "MMMM, yyyy" * * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @return {String} A string representation of the current Date object. */ var ord = function (n) { switch (n * 1) { case 1: case 21: case 31: return "st"; case 2: case 22: return "nd"; case 3: case 23: return "rd"; default: return "th"; } }; var parseStandardFormats = function (format) { var y, c = Date.CultureInfo.formatPatterns; switch (format) { case "d": return this.toString(c.shortDate); case "D": return this.toString(c.longDate); case "F": return this.toString(c.fullDateTime); case "m": return this.toString(c.monthDay); case "r": case "R": y = this.clone().addMinutes(this.getTimezoneOffset()); return y.toString(c.rfc1123) + " GMT"; case "s": return this.toString(c.sortableDateTime); case "t": return this.toString(c.shortTime); case "T": return this.toString(c.longTime); case "u": y = this.clone().addMinutes(this.getTimezoneOffset()); return y.toString(c.universalSortableDateTime); case "y": return this.toString(c.yearMonth); default: return false; } }; var parseFormatStringsClosure = function (context) { return function (m) { if (m.charAt(0) === "\\") { return m.replace("\\", ""); } switch (m) { case "hh": return p(context.getHours() < 13 ? (context.getHours() === 0 ? 12 : context.getHours()) : (context.getHours() - 12)); case "h": return context.getHours() < 13 ? (context.getHours() === 0 ? 12 : context.getHours()) : (context.getHours() - 12); case "HH": return p(context.getHours()); case "H": return context.getHours(); case "mm": return p(context.getMinutes()); case "m": return context.getMinutes(); case "ss": return p(context.getSeconds()); case "s": return context.getSeconds(); case "yyyy": return p(context.getFullYear(), 4); case "yy": return p(context.getFullYear()); case "y": return context.getFullYear(); case "E": case "dddd": return Date.CultureInfo.dayNames[context.getDay()]; case "ddd": return Date.CultureInfo.abbreviatedDayNames[context.getDay()]; case "dd": return p(context.getDate()); case "d": return context.getDate(); case "MMMM": return Date.CultureInfo.monthNames[context.getMonth()]; case "MMM": return Date.CultureInfo.abbreviatedMonthNames[context.getMonth()]; case "MM": return p((context.getMonth() + 1)); case "M": return context.getMonth() + 1; case "t": return context.getHours() < 12 ? Date.CultureInfo.amDesignator.substring(0, 1) : Date.CultureInfo.pmDesignator.substring(0, 1); case "tt": return context.getHours() < 12 ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator; case "S": return ord(context.getDate()); case "W": return context.getWeek(); case "WW": return context.getISOWeek(); case "Q": return "Q" + context.getQuarter(); case "q": return String(context.getQuarter()); case "z": return context.getTimezone(); case "Z": case "X": return Date.getTimezoneOffset(context.getTimezone()); case "ZZ": // Timezone offset in seconds return context.getTimezoneOffset() * -60; case "u": return context.getDay(); case "L": return ($D.isLeapYear(context.getFullYear())) ? 1 : 0; case "B": // Swatch Internet Time (.beats) return "@"+((context.getUTCSeconds() + (context.getUTCMinutes()*60) + ((context.getUTCHours()+1)*3600))/86.4); default: return m; } }; }; $P.toString = function (format, ignoreStandards) { // Standard Date and Time Format Strings. Formats pulled from CultureInfo file and // may vary by culture. if (!ignoreStandards && format && format.length === 1) { output = parseStandardFormats.call(this, format); if (output) { return output; } } var parseFormatStrings = parseFormatStringsClosure(this); return format ? format.replace(/((\\)?(dd?d?d?|MM?M?M?|yy?y?y?|hh?|HH?|mm?|ss?|tt?|S|q|Q|WW?W?W?)(?![^\[]*\]))/g, parseFormatStrings).replace(/\[|\]/g, "") : this._toString(); }; }()); /************************************************************* * SugarPak - Domain Specific Language - Syntactical Sugar * *************************************************************/ (function () { var $D = Date, $P = $D.prototype, $N = Number.prototype; // private $P._orient = +1; // private $P._nth = null; // private $P._is = false; // private $P._same = false; // private $P._isSecond = false; // private $N._dateElement = "days"; /** * Moves the date to the next instance of a date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.today().next().friday();
	Date.today().next().fri();
	Date.today().next().march();
	Date.today().next().mar();
	Date.today().next().week();
	
* * @return {Date} date */ $P.next = function () { this._move = true; this._orient = +1; return this; }; /** * Creates a new Date (Date.today()) and moves the date to the next instance of the date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.next().friday();
	Date.next().fri();
	Date.next().march();
	Date.next().mar();
	Date.next().week();
	
* * @return {Date} date */ $D.next = function () { return $D.today().next(); }; /** * Moves the date to the previous instance of a date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.today().last().friday();
	Date.today().last().fri();
	Date.today().last().march();
	Date.today().last().mar();
	Date.today().last().week();
	
* * @return {Date} date */ $P.last = $P.prev = $P.previous = function () { this._move = true; this._orient = -1; return this; }; /** * Creates a new Date (Date.today()) and moves the date to the previous instance of the date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.last().friday();
	Date.last().fri();
	Date.previous().march();
	Date.prev().mar();
	Date.last().week();
	
* * @return {Date} date */ $D.last = $D.prev = $D.previous = function () { return $D.today().last(); }; /** * Performs a equality check when followed by either a month name, day name or .weekday() function. * Example

	Date.today().is().friday(); // true|false
	Date.today().is().fri();
	Date.today().is().march();
	Date.today().is().mar();
	
* * @return {Boolean} true|false */ $P.is = function () { this._is = true; return this; }; /** * Determines if two date objects occur on/in exactly the same instance of the subsequent date part function. * The function .same() must be followed by a date part function (example: .day(), .month(), .year(), etc). * * An optional Date can be passed in the date part function. If now date is passed as a parameter, 'Now' is used. * * The following example demonstrates how to determine if two dates fall on the exact same day. * * Example

	var d1 = Date.today(); // today at 00:00
	var d2 = new Date();   // exactly now.

	// Do they occur on the same day?
	d1.same().day(d2); // true
	
	// Do they occur on the same hour?
	d1.same().hour(d2); // false, unless d2 hour is '00' (midnight).
	
	// What if it's the same day, but one year apart?
	var nextYear = Date.today().add(1).year();

	d1.same().day(nextYear); // false, because the dates must occur on the exact same day. 
	
* * Scenario: Determine if a given date occurs during some week period 2 months from now. * * Example

	var future = Date.today().add(2).months();
	return someDate.same().week(future); // true|false;
	
* * @return {Boolean} true|false */ $P.same = function () { this._same = true; this._isSecond = false; return this; }; /** * Determines if the current date/time occurs during Today. Must be preceded by the .is() function. * Example

	someDate.is().today();    // true|false
	new Date().is().today();  // true
	Date.today().is().today();// true
	Date.today().add(-1).day().is().today(); // false
	
* * @return {Boolean} true|false */ $P.today = function () { return this.same().day(); }; /** * Determines if the current date is a weekday. This function must be preceded by the .is() function. * Example

	Date.today().is().weekday(); // true|false
	
* * @return {Boolean} true|false */ $P.weekday = function () { if (this._nth) { return df("Weekday").call(this); } if (this._move) { return this.addWeekdays(this._orient); } if (this._is) { this._is = false; return (!this.is().sat() && !this.is().sun()); } return false; }; /** * Determines if the current date is on the weekend. This function must be preceded by the .is() function. * Example

	Date.today().is().weekend(); // true|false
	
* * @return {Boolean} true|false */ $P.weekend = function () { if (this._is) { this._is = false; return (this.is().sat() || this.is().sun()); } return false; }; /** * Sets the Time of the current Date instance. A string "6:15 pm" or config object {hour:18, minute:15} are accepted. * Example

	// Set time to 6:15pm with a String
	Date.today().at("6:15pm");

	// Set time to 6:15pm with a config object
	Date.today().at({hour:18, minute:15});
	
* * @return {Date} date */ $P.at = function (time) { return (typeof time === "string") ? $D.parse(this.toString("d") + " " + time) : this.set(time); }; /** * Creates a new Date() and adds this (Number) to the date based on the preceding date element function (eg. second|minute|hour|day|month|year). * Example

	// Undeclared Numbers must be wrapped with parentheses. Requirment of JavaScript.
	(3).days().fromNow();
	(6).months().fromNow();

	// Declared Number variables do not require parentheses. 
	var n = 6;
	n.months().fromNow();
	
* * @return {Date} A new Date instance */ $N.fromNow = $N.after = function (date) { var c = {}; c[this._dateElement] = this; return ((!date) ? new Date() : date.clone()).add(c); }; /** * Creates a new Date() and subtract this (Number) from the date based on the preceding date element function (eg. second|minute|hour|day|month|year). * Example

	// Undeclared Numbers must be wrapped with parentheses. Requirment of JavaScript.
	(3).days().ago();
	(6).months().ago();

	// Declared Number variables do not require parentheses. 
	var n = 6;
	n.months().ago();
	
* * @return {Date} A new Date instance */ $N.ago = $N.before = function (date) { var c = {}, s = (this._dateElement[this._dateElement.length-1] !== "s") ? this._dateElement + "s" : this._dateElement; c[s] = this * -1; return ((!date) ? new Date() : date.clone()).add(c); }; // Do NOT modify the following string tokens. These tokens are used to build dynamic functions. // All culture-specific strings can be found in the CultureInfo files. var dx = ("sunday monday tuesday wednesday thursday friday saturday").split(/\s/), mx = ("january february march april may june july august september october november december").split(/\s/), px = ("Millisecond Second Minute Hour Day Week Month Year Quarter Weekday").split(/\s/), pxf = ("Milliseconds Seconds Minutes Hours Date Week Month FullYear Quarter").split(/\s/), nth = ("final first second third fourth fifth").split(/\s/), de; /** * Returns an object literal of all the date parts. * Example

	var o = new Date().toObject();
	
	// { year: 2008, month: 4, week: 20, day: 13, hour: 18, minute: 9, second: 32, millisecond: 812 }
	
	// The object properties can be referenced directly from the object.
	
	alert(o.day);  // alerts "13"
	alert(o.year); // alerts "2008"
	
* * @return {Date} An object literal representing the original date object. */ $P.toObject = function () { var o = {}; for (var i = 0; i < px.length; i++) { if (this["get" + pxf[i]]) { o[px[i].toLowerCase()] = this["get" + pxf[i]](); } } return o; }; /** * Returns a date created from an object literal. Ignores the .week property if set in the config. * Example

	var o = new Date().toObject();
	
	return Date.fromObject(o); // will return the same date. 

	var o2 = {month: 1, day: 20, hour: 18}; // birthday party!
	Date.fromObject(o2);
	
* * @return {Date} An object literal representing the original date object. */ $D.fromObject = function(config) { config.week = null; return Date.today().set(config); }; // Create day name functions and abbreviated day name functions (eg. monday(), friday(), fri()). var df = function (n) { return function () { if (this._is) { this._is = false; return this.getDay() === n; } if (this._move) { this._move = null; } if (this._nth !== null) { // If the .second() function was called earlier, remove the _orient // from the date, and then continue. // This is required because 'second' can be used in two different context. // // Example // // Date.today().add(1).second(); // Date.march().second().monday(); // // Things get crazy with the following... // Date.march().add(1).second().second().monday(); // but it works!! // if (this._isSecond) { this.addSeconds(this._orient * -1); } // make sure we reset _isSecond this._isSecond = false; var ntemp = this._nth; this._nth = null; var temp = this.clone().moveToLastDayOfMonth(); this.moveToNthOccurrence(n, ntemp); if (this > temp) { throw new RangeError($D.getDayName(n) + " does not occur " + ntemp + " times in the month of " + $D.getMonthName(temp.getMonth()) + " " + temp.getFullYear() + "."); } return this; } return this.moveToDayOfWeek(n, this._orient); }; }; var sdf = function (n) { return function () { var t = $D.today(), shift = n - t.getDay(); if (n === 0 && Date.CultureInfo.firstDayOfWeek === 1 && t.getDay() !== 0) { shift = shift + 7; } return t.addDays(shift); }; }; // Create month name functions and abbreviated month name functions (eg. january(), march(), mar()). var month_instance_functions = function (n) { return function () { if (this._is) { this._is = false; return this.getMonth() === n; } return this.moveToMonth(n, this._orient); }; }; var month_static_functions = function (n) { return function () { return $D.today().set({ month: n, day: 1 }); }; }; var processTerms = function (names, staticFunc, instanceFunc) { for (var i = 0; i < names.length; i++) { // Create constant static Name variables. $D[names[i].toUpperCase()] = $D[names[i].toUpperCase().substring(0, 3)] = i; // Create Name functions. $D[names[i]] = $D[names[i].substring(0, 3)] = staticFunc(i); // Create Name instance functions. $P[names[i]] = $P[names[i].substring(0, 3)] = instanceFunc(i); } }; processTerms(dx, sdf, df); processTerms(mx, month_static_functions, month_instance_functions); // Create date element functions and plural date element functions used with Date (eg. day(), days(), months()). var ef = function (j) { return function () { // if the .second() function was called earlier, the _orient // has alread been added. Just return this and reset _isSecond. if (this._isSecond) { this._isSecond = false; return this; } if (this._same) { this._same = this._is = false; var o1 = this.toObject(), o2 = (arguments[0] || new Date()).toObject(), v = "", k = j.toLowerCase(); // the substr trick with -1 doesn't work in IE8 or less k = (k[k.length-1] === "s") ? k.substring(0,k.length-1) : k; for (var m = (px.length - 1); m > -1; m--) { v = px[m].toLowerCase(); if (o1[v] !== o2[v]) { return false; } if (k === v) { break; } } return true; } if (j.substring(j.length - 1) !== "s") { j += "s"; } if (this._move) { this._move = null; } return this["add" + j](this._orient); }; }; var nf = function (n) { return function () { this._dateElement = n; return this; }; }; for (var k = 0; k < px.length; k++) { de = px[k].toLowerCase(); if(de !== "weekday") { // Create date element functions and plural date element functions used with Date (eg. day(), days(), months()). $P[de] = $P[de + "s"] = ef(px[k]); // Create date element functions and plural date element functions used with Number (eg. day(), days(), months()). $N[de] = $N[de + "s"] = nf(de + "s"); } } $P._ss = ef("Second"); var nthfn = function (n) { return function (dayOfWeek) { if (this._same) { return this._ss(arguments[0]); } if (dayOfWeek || dayOfWeek === 0) { return this.moveToNthOccurrence(dayOfWeek, n); } this._nth = n; // if the operator is 'second' add the _orient, then deal with it later... if (n === 2 && (dayOfWeek === undefined || dayOfWeek === null)) { this._isSecond = true; return this.addSeconds(this._orient); } return this; }; }; for (var l = 0; l < nth.length; l++) { $P[nth[l]] = (l === 0) ? nthfn(-1) : nthfn(l); } }()); (function () { "use strict"; Date.Parsing = { Exception: function (s) { this.message = "Parse error at '" + s.substring(0, 10) + " ...'"; } }; var $P = Date.Parsing; var dayOffsets = { standard: [0,31,59,90,120,151,181,212,243,273,304,334], leap: [0,31,60,91,121,152,182,213,244,274,305,335] }; $P.isLeapYear = function(year) { return ((year % 4 === 0) && (year % 100 !== 0)) || (year % 400 === 0); }; var utils = { multiReplace : function (str, hash ) { var key; for (key in hash) { if (Object.prototype.hasOwnProperty.call(hash, key)) { var regex; if (typeof hash[key] === "function") { } else { regex = (hash[key] instanceof RegExp) ? hash[key] : new RegExp(hash[key], "g"); } str = str.replace(regex, key); } } return str; }, getDayOfYearFromWeek : function (obj) { var d, jan4, offset; obj.weekDay = (!obj.weekDay && obj.weekDay !== 0) ? 1 : obj.weekDay; d = new Date(obj.year, 0, 4); jan4 = d.getDay() === 0 ? 7 : d.getDay(); // JS is 0 indexed on Sunday. offset = jan4+3; obj.dayOfYear = ((obj.week * 7) + (obj.weekDay === 0 ? 7 : obj.weekDay))-offset; return obj; }, getDayOfYear : function (obj, dayOffset) { if (!obj.dayOfYear) { obj = utils.getDayOfYearFromWeek(obj); } for (var i=0;i <= dayOffset.length;i++) { if (obj.dayOfYear < dayOffset[i] || i === dayOffset.length) { obj.day = obj.day ? obj.day : (obj.dayOfYear - dayOffset[i-1]); break; } else { obj.month = i; } } return obj; }, adjustForTimeZone : function (obj, date) { var offset; if (obj.zone.toUpperCase() === "Z" || (obj.zone_hours === 0 && obj.zone_minutes === 0)) { // it's UTC/GML so work out the current timeszone offset offset = -date.getTimezoneOffset(); } else { offset = (obj.zone_hours*60) + (obj.zone_minutes || 0); if (obj.zone_sign === "+") { offset *= -1; } offset -= date.getTimezoneOffset(); } date.setMinutes(date.getMinutes()+offset); return date; }, setDefaults : function (obj) { obj.year = obj.year || Date.today().getFullYear(); obj.hours = obj.hours || 0; obj.minutes = obj.minutes || 0; obj.seconds = obj.seconds || 0; obj.milliseconds = obj.milliseconds || 0; if (!(!obj.month && (obj.week || obj.dayOfYear))) { // if we have a month, or if we don't but don't have the day calculation data obj.month = obj.month || 0; obj.day = obj.day || 1; } return obj; }, dataNum: function (data, mod, explict, postProcess) { var dataNum = data*1; if (mod) { if (postProcess) { return data ? mod(data)*1 : data; } else { return data ? mod(dataNum) : data; } } else if (!explict){ return data ? dataNum : data; } else { return (data && typeof data !== "undefined") ? dataNum : data; } }, timeDataProcess: function (obj) { var timeObj = {}; for (var x in obj.data) { if (obj.data.hasOwnProperty(x)) { timeObj[x] = obj.ignore[x] ? obj.data[x] : utils.dataNum(obj.data[x], obj.mods[x], obj.explict[x], obj.postProcess[x]); } } if (obj.data.secmins) { obj.data.secmins = obj.data.secmins.replace(",", ".") * 60; if (!timeObj.minutes) { timeObj.minutes = obj.data.secmins; } else if (!timeObj.seconds) { timeObj.seconds = obj.data.secmins; } delete obj.secmins; } return timeObj; }, buildTimeObjectFromData: function (data) { var time = utils.timeDataProcess({ data: { year : data[1], month : data[5], day : data[7], week : data[8], dayOfYear : data[10], hours : data[15], zone_hours : data[23], zone_minutes : data[24], zone : data[21], zone_sign : data[22], weekDay : data[9], minutes: data[16], seconds: data[19], milliseconds: data[20], secmins: data[18] }, mods: { month: function(data) { return data-1; }, weekDay: function (data) { data = Math.abs(data); return (data === 7 ? 0 : data); }, minutes: function (data) { return data.replace(":",""); }, seconds: function (data) { return Math.floor( (data.replace(":","").replace(",","."))*1 ); }, milliseconds: function (data) { return (data.replace(",",".")*1000); } }, postProcess: { minutes: true, seconds: true, milliseconds: true }, explict: { zone_hours: true, zone_minutes: true }, ignore: { zone: true, zone_sign: true, secmins: true } }); return time; }, addToHash: function (hash, keys, data) { keys = keys; data = data; var len = keys.length; for (var i = 0; i < len; i++) { hash[keys[i]] = data[i]; } return hash; }, combineRegex: function (r1, r2) { return new RegExp("(("+r1.source+")\\s("+r2.source+"))"); }, getDateNthString: function(add, last, inc){ if (add) { return Date.today().addDays(inc).toString("d"); } else if (last) { return Date.today().last()[inc]().toString("d"); } }, buildRegexData: function (array) { var arr = []; var len = array.length; for (var i=0; i < len; i++) { if (Object.prototype.toString.call(array[i]) === '[object Array]') { // oldIE compat version of Array.isArray arr.push(this.combineRegex(array[i][0], array[i][1])); } else { arr.push(array[i]); } } return arr; } }; $P.processTimeObject = function (obj) { var date, dayOffset; utils.setDefaults(obj); dayOffset = ($P.isLeapYear(obj.year)) ? dayOffsets.leap : dayOffsets.standard; if (!obj.month && (obj.week || obj.dayOfYear)) { utils.getDayOfYear(obj, dayOffset); } else { obj.dayOfYear = dayOffset[obj.month] + obj.day; } date = new Date(obj.year, obj.month, obj.day, obj.hours, obj.minutes, obj.seconds, obj.milliseconds); if (obj.zone) { utils.adjustForTimeZone(obj, date); // adjust (and calculate) for timezone } return date; }; $P.ISO = { regex : /^([\+-]?\d{4}(?!\d{2}\b))((-?)((0[1-9]|1[0-2])(\3([12]\d|0[1-9]|3[01]))?|W([0-4]\d|5[0-3])(-?[1-7])?|(00[1-9]|0[1-9]\d|[12]\d{2}|3([0-5]\d|6[1-6])))([T\s]((([01]\d|2[0-4])((:?)[0-5]\d)?|24\:?00)([\.,]\d+(?!:))?)?(\17[0-5]\d([\.,]\d+)?)?\s?([zZ]|([\+-])([01]\d|2[0-3]):?([0-5]\d)?)?)?)?$/, parse : function (s) { var time, data = s.match(this.regex); if (!data || !data.length) { return null; } time = utils.buildTimeObjectFromData(data); if (!time.year || (!time.year && (!time.month && !time.day) && (!time.week && !time.dayOfYear)) ) { return null; } return $P.processTimeObject(time); } }; $P.Numeric = { isNumeric: function (e){return!isNaN(parseFloat(e))&&isFinite(e);}, regex: /\b([0-1]?[0-9])([0-3]?[0-9])([0-2]?[0-9]?[0-9][0-9])\b/i, parse: function (s) { var data, i, time = {}, order = Date.CultureInfo.dateElementOrder.split(""); if (!(this.isNumeric(s)) || // if it's non-numeric OR (s[0] === "+" && s[0] === "-")) { // It's an arithmatic string (eg +/-1000) return null; } if (s.length < 5 && s.indexOf(".") < 0 && s.indexOf("/") < 0) { // assume it's just a year. time.year = s; return $P.processTimeObject(time); } data = s.match(this.regex); if (!data || !data.length) { return null; } for (i=0; i < order.length; i++) { switch(order[i]) { case "d": time.day = data[i+1]; break; case "m": time.month = (data[i+1]-1); break; case "y": time.year = data[i+1]; break; } } return $P.processTimeObject(time); } }; $P.Normalizer = { regexData: function () { var $R = Date.CultureInfo.regexPatterns; return utils.buildRegexData([ $R.tomorrow, $R.yesterday, [$R.past, $R.mon], [$R.past, $R.tue], [$R.past, $R.wed], [$R.past, $R.thu], [$R.past, $R.fri], [$R.past, $R.sat], [$R.past, $R.sun] ]); }, basicReplaceHash : function() { var $R = Date.CultureInfo.regexPatterns; return { "January": $R.jan.source, "February": $R.feb, "March": $R.mar, "April": $R.apr, "May": $R.may, "June": $R.jun, "July": $R.jul, "August": $R.aug, "September": $R.sep, "October": $R.oct, "November": $R.nov, "December": $R.dec, "": /\bat\b/gi, " ": /\s{2,}/, "am": $R.inTheMorning, "9am": $R.thisMorning, "pm": $R.inTheEvening, "7pm":$R.thisEvening }; }, keys : function(){ return [ utils.getDateNthString(true, false, 1), // tomorrow utils.getDateNthString(true, false, -1), // yesterday utils.getDateNthString(false, true, "monday"), //last mon utils.getDateNthString(false, true, "tuesday"), //last tues utils.getDateNthString(false, true, "wednesday"), //last wed utils.getDateNthString(false, true, "thursday"), //last thurs utils.getDateNthString(false, true, "friday"), //last fri utils.getDateNthString(false, true, "saturday"), //last sat utils.getDateNthString(false, true, "sunday") //last sun ]; }, buildRegexFunctions: function () { var $R = Date.CultureInfo.regexPatterns; var __ = Date.i18n.__; var tomorrowRE = new RegExp("(\\b\\d\\d?("+__("AM")+"|"+__("PM")+")? )("+$R.tomorrow.source.slice(1)+")", "i"); // adapted tomorrow regex for AM PM relative dates var todayRE = new RegExp($R.today.source + "(?!\\s*([+-]))\\b"); // today, but excludes the math operators (eg "today + 2h") this.replaceFuncs = [ [todayRE, function (full) { return (full.length > 1) ? Date.today().toString("d") : full; }], [tomorrowRE, function(full, m1) { var t = Date.today().addDays(1).toString("d"); return (t + " " + m1); }], [$R.amThisMorning, function(str, am){return am;}], [$R.pmThisEvening, function(str, pm){return pm;}] ]; }, buildReplaceData: function () { this.buildRegexFunctions(); this.replaceHash = utils.addToHash(this.basicReplaceHash(), this.keys(), this.regexData()); }, stringReplaceFuncs: function (s) { for (var i=0; i < this.replaceFuncs.length; i++) { s = s.replace(this.replaceFuncs[i][0], this.replaceFuncs[i][1]); } return s; }, parse: function (s) { s = this.stringReplaceFuncs(s); s = utils.multiReplace(s, this.replaceHash); try { var n = s.split(/([\s\-\.\,\/\x27]+)/); if (n.length === 3 && $P.Numeric.isNumeric(n[0]) && $P.Numeric.isNumeric(n[2]) && (n[2].length >= 4)) { // ok, so we're dealing with x/year. But that's not a full date. // This fixes wonky dateElementOrder parsing when set to dmy order. if (Date.CultureInfo.dateElementOrder[0] === "d") { s = "1/" + n[0] + "/" + n[2]; // set to 1st of month and normalize the seperator } } } catch (e) {} return s; } }; $P.Normalizer.buildReplaceData(); }()); (function () { var $P = Date.Parsing; var _ = $P.Operators = { // // Tokenizers // rtoken: function (r) { // regex token return function (s) { var mx = s.match(r); if (mx) { return ([ mx[0], s.substring(mx[0].length) ]); } else { throw new $P.Exception(s); } }; }, token: function () { // whitespace-eating token return function (s) { return _.rtoken(new RegExp("^\\s*" + s + "\\s*"))(s); }; }, stoken: function (s) { // string token return _.rtoken(new RegExp("^" + s)); }, // Atomic Operators until: function (p) { return function (s) { var qx = [], rx = null; while (s.length) { try { rx = p.call(this, s); } catch (e) { qx.push(rx[0]); s = rx[1]; continue; } break; } return [ qx, s ]; }; }, many: function (p) { return function (s) { var rx = [], r = null; while (s.length) { try { r = p.call(this, s); } catch (e) { return [ rx, s ]; } rx.push(r[0]); s = r[1]; } return [ rx, s ]; }; }, // generator operators -- see below optional: function (p) { return function (s) { var r = null; try { r = p.call(this, s); } catch (e) { return [ null, s ]; } return [ r[0], r[1] ]; }; }, not: function (p) { return function (s) { try { p.call(this, s); } catch (e) { return [null, s]; } throw new $P.Exception(s); }; }, ignore: function (p) { return p ? function (s) { var r = null; r = p.call(this, s); return [null, r[1]]; } : null; }, product: function () { var px = arguments[0], qx = Array.prototype.slice.call(arguments, 1), rx = []; for (var i = 0 ; i < px.length ; i++) { rx.push(_.each(px[i], qx)); } return rx; }, cache: function (rule) { var cache = {}, cache_length = 0, cache_keys = [], CACHE_MAX = Date.Config.CACHE_MAX || 100000, r = null; var cacheCheck = function () { if (cache_length === CACHE_MAX) { // kill several keys, don't want to have to do this all the time... for (var i=0; i < 10; i++) { var key = cache_keys.shift(); if (key) { delete cache[key]; cache_length--; } } } }; return function (s) { cacheCheck(); try { r = cache[s] = (cache[s] || rule.call(this, s)); } catch (e) { r = cache[s] = e; } cache_length++; cache_keys.push(s); if (r instanceof $P.Exception) { throw r; } else { return r; } }; }, // vector operators -- see below any: function () { var px = arguments; return function (s) { var r = null; for (var i = 0; i < px.length; i++) { if (px[i] == null) { continue; } try { r = (px[i].call(this, s)); } catch (e) { r = null; } if (r) { return r; } } throw new $P.Exception(s); }; }, each: function () { var px = arguments; return function (s) { var rx = [], r = null; for (var i = 0; i < px.length ; i++) { if (px[i] == null) { continue; } try { r = (px[i].call(this, s)); } catch (e) { throw new $P.Exception(s); } rx.push(r[0]); s = r[1]; } return [ rx, s]; }; }, all: function () { var px = arguments, _ = _; return _.each(_.optional(px)); }, // delimited operators sequence: function (px, d, c) { d = d || _.rtoken(/^\s*/); c = c || null; if (px.length === 1) { return px[0]; } return function (s) { var r = null, q = null; var rx = []; for (var i = 0; i < px.length ; i++) { try { r = px[i].call(this, s); } catch (e) { break; } rx.push(r[0]); try { q = d.call(this, r[1]); } catch (ex) { q = null; break; } s = q[1]; } if (!r) { throw new $P.Exception(s); } if (q) { throw new $P.Exception(q[1]); } if (c) { try { r = c.call(this, r[1]); } catch (ey) { throw new $P.Exception(r[1]); } } return [ rx, (r?r[1]:s) ]; }; }, // // Composite Operators // between: function (d1, p, d2) { d2 = d2 || d1; var _fn = _.each(_.ignore(d1), p, _.ignore(d2)); return function (s) { var rx = _fn.call(this, s); return [[rx[0][0], r[0][2]], rx[1]]; }; }, list: function (p, d, c) { d = d || _.rtoken(/^\s*/); c = c || null; return (p instanceof Array ? _.each(_.product(p.slice(0, -1), _.ignore(d)), p.slice(-1), _.ignore(c)) : _.each(_.many(_.each(p, _.ignore(d))), px, _.ignore(c))); }, set: function (px, d, c) { d = d || _.rtoken(/^\s*/); c = c || null; return function (s) { // r is the current match, best the current 'best' match // which means it parsed the most amount of input var r = null, p = null, q = null, rx = null, best = [[], s], last = false; // go through the rules in the given set for (var i = 0; i < px.length ; i++) { // last is a flag indicating whether this must be the last element // if there is only 1 element, then it MUST be the last one q = null; p = null; r = null; last = (px.length === 1); // first, we try simply to match the current pattern // if not, try the next pattern try { r = px[i].call(this, s); } catch (e) { continue; } // since we are matching against a set of elements, the first // thing to do is to add r[0] to matched elements rx = [[r[0]], r[1]]; // if we matched and there is still input to parse and // we don't already know this is the last element, // we're going to next check for the delimiter ... // if there's none, or if there's no input left to parse // than this must be the last element after all ... if (r[1].length > 0 && ! last) { try { q = d.call(this, r[1]); } catch (ex) { last = true; } } else { last = true; } // if we parsed the delimiter and now there's no more input, // that means we shouldn't have parsed the delimiter at all // so don't update r and mark this as the last element ... if (!last && q[1].length === 0) { last = true; } // so, if this isn't the last element, we're going to see if // we can get any more matches from the remaining (unmatched) // elements ... if (!last) { // build a list of the remaining rules we can match against, // i.e., all but the one we just matched against var qx = []; for (var j = 0; j < px.length ; j++) { if (i !== j) { qx.push(px[j]); } } // now invoke recursively set with the remaining input // note that we don't include the closing delimiter ... // we'll check for that ourselves at the end p = _.set(qx, d).call(this, q[1]); // if we got a non-empty set as a result ... // (otw rx already contains everything we want to match) if (p[0].length > 0) { // update current result, which is stored in rx ... // basically, pick up the remaining text from p[1] // and concat the result from p[0] so that we don't // get endless nesting ... rx[0] = rx[0].concat(p[0]); rx[1] = p[1]; } } // at this point, rx either contains the last matched element // or the entire matched set that starts with this element. // now we just check to see if this variation is better than // our best so far, in terms of how much of the input is parsed if (rx[1].length < best[1].length) { best = rx; } // if we've parsed all the input, then we're finished if (best[1].length === 0) { break; } } // so now we've either gone through all the patterns trying them // as the initial match; or we found one that parsed the entire // input string ... // if best has no matches, just return empty set ... if (best[0].length === 0) { return best; } // if a closing delimiter is provided, then we have to check it also if (c) { // we try this even if there is no remaining input because the pattern // may well be optional or match empty input ... try { q = c.call(this, best[1]); } catch (ey) { throw new $P.Exception(best[1]); } // it parsed ... be sure to update the best match remaining input best[1] = q[1]; } // if we're here, either there was no closing delimiter or we parsed it // so now we have the best match; just return it! return best; }; }, forward: function (gr, fname) { return function (s) { return gr[fname].call(this, s); }; }, // // Translation Operators // replace: function (rule, repl) { return function (s) { var r = rule.call(this, s); return [repl, r[1]]; }; }, process: function (rule, fn) { return function (s) { var r = rule.call(this, s); return [fn.call(this, r[0]), r[1]]; }; }, min: function (min, rule) { return function (s) { var rx = rule.call(this, s); if (rx[0].length < min) { throw new $P.Exception(s); } return rx; }; } }; // Generator Operators And Vector Operators // Generators are operators that have a signature of F(R) => R, // taking a given rule and returning another rule, such as // ignore, which parses a given rule and throws away the result. // Vector operators are those that have a signature of F(R1,R2,...) => R, // take a list of rules and returning a new rule, such as each. // Generator operators are converted (via the following _generator // function) into functions that can also take a list or array of rules // and return an array of new rules as though the function had been // called on each rule in turn (which is what actually happens). // This allows generators to be used with vector operators more easily. // Example: // each(ignore(foo, bar)) instead of each(ignore(foo), ignore(bar)) // This also turns generators into vector operators, which allows // constructs like: // not(cache(foo, bar)) var _generator = function (op) { function gen() { var args = null, rx = [], px, i; if (arguments.length > 1) { args = Array.prototype.slice.call(arguments); } else if (arguments[0] instanceof Array) { args = arguments[0]; } if (args) { px = args.shift(); if (px.length > 0) { args.unshift(px[i]); rx.push(op.apply(null, args)); args.shift(); return rx; } } else { return op.apply(null, arguments); } } return gen; }; var gx = "optional not ignore cache".split(/\s/); for (var i = 0 ; i < gx.length ; i++) { _[gx[i]] = _generator(_[gx[i]]); } var _vector = function (op) { return function () { if (arguments[0] instanceof Array) { return op.apply(null, arguments[0]); } else { return op.apply(null, arguments); } }; }; var vx = "each any all".split(/\s/); for (var j = 0 ; j < vx.length ; j++) { _[vx[j]] = _vector(_[vx[j]]); } }()); (function () { var $D = Date; var flattenAndCompact = function (ax) { var rx = []; for (var i = 0; i < ax.length; i++) { if (ax[i] instanceof Array) { rx = rx.concat(flattenAndCompact(ax[i])); } else { if (ax[i]) { rx.push(ax[i]); } } } return rx; }; var parseMeridian = function () { if (this.meridian && (this.hour || this.hour === 0)) { if (this.meridian === "a" && this.hour > 11 && Date.Config.strict24hr){ throw "Invalid hour and meridian combination"; } else if (this.meridian === "p" && this.hour < 12 && Date.Config.strict24hr){ throw "Invalid hour and meridian combination"; } else if (this.meridian === "p" && this.hour < 12) { this.hour = this.hour + 12; } else if (this.meridian === "a" && this.hour === 12) { this.hour = 0; } } }; var setDefaults = function () { var now = new Date(); if ((this.hour || this.minute) && (!this.month && !this.year && !this.day)) { this.day = now.getDate(); } if (!this.year) { this.year = now.getFullYear(); } if (!this.month && this.month !== 0) { this.month = now.getMonth(); } if (!this.day) { this.day = 1; } if (!this.hour) { this.hour = 0; } if (!this.minute) { this.minute = 0; } if (!this.second) { this.second = 0; } if (!this.millisecond) { this.millisecond = 0; } }; var finishUtils = { getToday: function () { if (this.now || "hour minute second".indexOf(this.unit) !== -1) { return new Date(); } else { return $D.today(); } }, setDaysFromWeekday: function (today, orient){ var gap; orient = orient || 1; this.unit = "day"; gap = ($D.getDayNumberFromName(this.weekday) - today.getDay()); this.days = gap ? ((gap + (orient * 7)) % 7) : (orient * 7); return this; }, setMonthsFromMonth: function (today, orient) { var gap; orient = orient || 1; this.unit = "month"; gap = (this.month - today.getMonth()); this.months = gap ? ((gap + (orient * 12)) % 12) : (orient * 12); this.month = null; return this; }, setDMYFromWeekday: function () { var d = Date[this.weekday](); this.day = d.getDate(); if (!this.month) { this.month = d.getMonth(); } this.year = d.getFullYear(); return this; }, setUnitValue: function (orient) { if (!this.value && this.operator && this.operator !== null && this[this.unit + "s"] && this[this.unit + "s"] !== null) { this[this.unit + "s"] = this[this.unit + "s"] + ((this.operator === "add") ? 1 : -1) + (this.value||0) * orient; } else if (this[this.unit + "s"] == null || this.operator != null) { if (!this.value) { this.value = 1; } this[this.unit + "s"] = this.value * orient; } }, generateDateFromWeeks: function () { var weekday = (this.weekday !== undefined) ? this.weekday : "today"; var d = Date[weekday]().addWeeks(this.weeks); if (this.now) { d.setTimeToNow(); } return d; } }; $D.Translator = { hour: function (s) { return function () { this.hour = Number(s); }; }, minute: function (s) { return function () { this.minute = Number(s); }; }, second: function (s) { return function () { this.second = Number(s); }; }, /* for ss.s format */ secondAndMillisecond: function (s) { return function () { var mx = s.match(/^([0-5][0-9])\.([0-9]{1,3})/); this.second = Number(mx[1]); this.millisecond = Number(mx[2]); }; }, meridian: function (s) { return function () { this.meridian = s.slice(0, 1).toLowerCase(); }; }, timezone: function (s) { return function () { var n = s.replace(/[^\d\+\-]/g, ""); if (n.length) { this.timezoneOffset = Number(n); } else { this.timezone = s.toLowerCase(); } }; }, day: function (x) { var s = x[0]; return function () { this.day = Number(s.match(/\d+/)[0]); if (this.day < 1) { throw "invalid day"; } }; }, month: function (s) { return function () { this.month = (s.length === 3) ? "jan feb mar apr may jun jul aug sep oct nov dec".indexOf(s)/4 : Number(s) - 1; if (this.month < 0) { throw "invalid month"; } }; }, year: function (s) { return function () { var n = Number(s); this.year = ((s.length > 2) ? n : (n + (((n + 2000) < Date.CultureInfo.twoDigitYearMax) ? 2000 : 1900))); }; }, rday: function (s) { return function () { switch (s) { case "yesterday": this.days = -1; break; case "tomorrow": this.days = 1; break; case "today": this.days = 0; break; case "now": this.days = 0; this.now = true; break; } }; }, finishExact: function (x) { var d; x = (x instanceof Array) ? x : [x]; for (var i = 0 ; i < x.length ; i++) { if (x[i]) { x[i].call(this); } } setDefaults.call(this); parseMeridian.call(this); if (this.day > $D.getDaysInMonth(this.year, this.month)) { throw new RangeError(this.day + " is not a valid value for days."); } d = new Date(this.year, this.month, this.day, this.hour, this.minute, this.second, this.millisecond); if (this.year < 100) { d.setFullYear(this.year); // means years less that 100 are process correctly. JS will parse it otherwise as 1900-1999. } if (this.timezone) { d.set({ timezone: this.timezone }); } else if (this.timezoneOffset) { d.set({ timezoneOffset: this.timezoneOffset }); } return d; }, finish: function (x) { var today, expression, orient, temp; x = (x instanceof Array) ? flattenAndCompact(x) : [ x ]; if (x.length === 0) { return null; } for (var i = 0 ; i < x.length ; i++) { if (typeof x[i] === "function") { x[i].call(this); } } if (this.now && !this.unit && !this.operator) { return new Date(); } else { today = finishUtils.getToday.call(this); } expression = !!(this.days && this.days !== null || this.orient || this.operator); orient = ((this.orient === "past" || this.operator === "subtract") ? -1 : 1); if (this.month && this.unit === "week") { this.value = this.month + 1; delete this.month; delete this.day; } if ((this.month || this.month === 0) && "year day hour minute second".indexOf(this.unit) !== -1) { if (!this.value) { this.value = this.month + 1; } this.month = null; expression = true; } if (!expression && this.weekday && !this.day && !this.days) { finishUtils.setDMYFromWeekday.call(this); } if (expression && this.weekday && this.unit !== "month" && this.unit !== "week") { finishUtils.setDaysFromWeekday.call(this, today, orient); } if (this.weekday && this.unit !== "week" && !this.day && !this.days) { temp = Date[this.weekday](); this.day = temp.getDate(); if (temp.getMonth() !== today.getMonth()) { this.month = temp.getMonth(); } } if (this.month && this.unit === "day" && this.operator) { if (!this.value) { this.value = (this.month + 1); } this.month = null; } if (this.value != null && this.month != null && this.year != null) { this.day = this.value * 1; } if (this.month && !this.day && this.value) { today.set({ day: this.value * 1 }); if (!expression) { this.day = this.value * 1; } } if (!this.month && this.value && this.unit === "month" && !this.now) { this.month = this.value; expression = true; } if (expression && (this.month || this.month === 0) && this.unit !== "year") { finishUtils.setMonthsFromMonth.call(this, today, orient); } if (!this.unit) { this.unit = "day"; } finishUtils.setUnitValue.call(this, orient); parseMeridian.call(this); if ((this.month || this.month === 0) && !this.day) { this.day = 1; } if (!this.orient && !this.operator && this.unit === "week" && this.value && !this.day && !this.month) { return Date.today().setWeek(this.value); } if (this.unit === "week" && this.weeks && !this.day && !this.month) { return finishUtils.generateDateFromWeeks.call(this); } if (expression && this.timezone && this.day && this.days) { this.day = this.days; } if (expression){ today.add(this); } else { today.set(this); } if (this.timezone) { this.timezone = this.timezone.toUpperCase(); var offset = $D.getTimezoneOffset(this.timezone); var timezone; if (today.hasDaylightSavingTime()) { // lets check that we're being sane with timezone setting timezone = $D.getTimezoneAbbreviation(offset, today.isDaylightSavingTime()); if (timezone !== this.timezone) { // bugger, we're in a place where things like EST vs EDT matters. if (today.isDaylightSavingTime()) { today.addHours(-1); } else { today.addHours(1); } } } today.setTimezoneOffset(offset); } return today; } }; }()); (function () { var $D = Date; $D.Grammar = {}; var _ = $D.Parsing.Operators, g = $D.Grammar, t = $D.Translator, _fn; // Allow rolling up into general purpose rules _fn = function () { return _.each(_.any.apply(null, arguments), _.not(g.ctoken2("timeContext"))); }; g.datePartDelimiter = _.rtoken(/^([\s\-\.\,\/\x27]+)/); g.timePartDelimiter = _.stoken(":"); g.whiteSpace = _.rtoken(/^\s*/); g.generalDelimiter = _.rtoken(/^(([\s\,]|at|@|on)+)/); var _C = {}; g.ctoken = function (keys) { var fn = _C[keys]; if (! fn) { var c = Date.CultureInfo.regexPatterns; var kx = keys.split(/\s+/), px = []; for (var i = 0; i < kx.length ; i++) { px.push(_.replace(_.rtoken(c[kx[i]]), kx[i])); } fn = _C[keys] = _.any.apply(null, px); } return fn; }; g.ctoken2 = function (key) { return _.rtoken(Date.CultureInfo.regexPatterns[key]); }; var cacheProcessRtoken = function (key, token, type, eachToken) { if (eachToken) { g[key] = _.cache(_.process(_.each(_.rtoken(token),_.optional(g.ctoken2(eachToken))), type)); } else { g[key] = _.cache(_.process(_.rtoken(token), type)); } }; var cacheProcessCtoken = function (token, type) { return _.cache(_.process(g.ctoken2(token), type)); }; var _F = {}; //function cache var _get = function (f) { _F[f] = (_F[f] || g.format(f)[0]); return _F[f]; }; g.allformats = function (fx) { var rx = []; if (fx instanceof Array) { for (var i = 0; i < fx.length; i++) { rx.push(_get(fx[i])); } } else { rx.push(_get(fx)); } return rx; }; g.formats = function (fx) { if (fx instanceof Array) { var rx = []; for (var i = 0 ; i < fx.length ; i++) { rx.push(_get(fx[i])); } return _.any.apply(null, rx); } else { return _get(fx); } }; var grammarFormats = { timeFormats: function(){ var i, RTokenKeys = [ "h", "hh", "H", "HH", "m", "mm", "s", "ss", "ss.s", "z", "zz" ], RToken = [ /^(0[0-9]|1[0-2]|[1-9])/, /^(0[0-9]|1[0-2])/, /^([0-1][0-9]|2[0-3]|[0-9])/, /^([0-1][0-9]|2[0-3])/, /^([0-5][0-9]|[0-9])/, /^[0-5][0-9]/, /^([0-5][0-9]|[0-9])/, /^[0-5][0-9]/, /^[0-5][0-9]\.[0-9]{1,3}/, /^((\+|\-)\s*\d\d\d\d)|((\+|\-)\d\d\:?\d\d)/, /^((\+|\-)\s*\d\d\d\d)|((\+|\-)\d\d\:?\d\d)/ ], tokens = [ t.hour, t.hour, t.hour, t.hour, t.minute, t.minute, t.second, t.second, t.secondAndMillisecond, t.timezone, t.timezone ]; for (i=0; i < RTokenKeys.length; i++) { cacheProcessRtoken(RTokenKeys[i], RToken[i], tokens[i]); } g.hms = _.cache(_.sequence([g.H, g.m, g.s], g.timePartDelimiter)); g.t = cacheProcessCtoken("shortMeridian", t.meridian); g.tt = cacheProcessCtoken("longMeridian", t.meridian); g.zzz = cacheProcessCtoken("timezone", t.timezone); g.timeSuffix = _.each(_.ignore(g.whiteSpace), _.set([ g.tt, g.zzz ])); g.time = _.each(_.optional(_.ignore(_.stoken("T"))), g.hms, g.timeSuffix); }, dateFormats: function () { // pre-loaded rules for different date part order preferences var _setfn = function () { return _.set(arguments, g.datePartDelimiter); }; var i, RTokenKeys = [ "d", "dd", "M", "MM", "y", "yy", "yyy", "yyyy" ], RToken = [ /^([0-2]\d|3[0-1]|\d)/, /^([0-2]\d|3[0-1])/, /^(1[0-2]|0\d|\d)/, /^(1[0-2]|0\d)/, /^(\d+)/, /^(\d\d)/, /^(\d\d?\d?\d?)/, /^(\d\d\d\d)/ ], tokens = [ t.day, t.day, t.month, t.month, t.year, t.year, t.year, t.year ], eachToken = [ "ordinalSuffix", "ordinalSuffix" ]; for (i=0; i < RTokenKeys.length; i++) { cacheProcessRtoken(RTokenKeys[i], RToken[i], tokens[i], eachToken[i]); } g.MMM = g.MMMM = _.cache(_.process(g.ctoken("jan feb mar apr may jun jul aug sep oct nov dec"), t.month)); g.ddd = g.dddd = _.cache(_.process(g.ctoken("sun mon tue wed thu fri sat"), function (s) { return function () { this.weekday = s; }; } )); g.day = _fn(g.d, g.dd); g.month = _fn(g.M, g.MMM); g.year = _fn(g.yyyy, g.yy); g.mdy = _setfn(g.ddd, g.month, g.day, g.year); g.ymd = _setfn(g.ddd, g.year, g.month, g.day); g.dmy = _setfn(g.ddd, g.day, g.month, g.year); g.date = function (s) { return ((g[Date.CultureInfo.dateElementOrder] || g.mdy).call(this, s)); }; }, relative: function () { // relative date / time expressions g.orientation = _.process(g.ctoken("past future"), function (s) { return function () { this.orient = s; }; } ); g.operator = _.process(g.ctoken("add subtract"), function (s) { return function () { this.operator = s; }; } ); g.rday = _.process(g.ctoken("yesterday tomorrow today now"), t.rday); g.unit = _.process(g.ctoken("second minute hour day week month year"), function (s) { return function () { this.unit = s; }; } ); } }; g.buildGrammarFormats = function () { // these need to be rebuilt every time the language changes. _C = {}; grammarFormats.timeFormats(); grammarFormats.dateFormats(); grammarFormats.relative(); g.value = _.process(_.rtoken(/^([-+]?\d+)?(st|nd|rd|th)?/), function (s) { return function () { this.value = s.replace(/\D/g, ""); }; } ); g.expression = _.set([g.rday, g.operator, g.value, g.unit, g.orientation, g.ddd, g.MMM ]); g.format = _.process(_.many( _.any( // translate format specifiers into grammar rules _.process( _.rtoken(/^(dd?d?d?(?!e)|MM?M?M?|yy?y?y?|hh?|HH?|mm?|ss?|tt?|zz?z?)/), function (fmt) { if (g[fmt]) { return g[fmt]; } else { throw $D.Parsing.Exception(fmt); } } ), // translate separator tokens into token rules _.process(_.rtoken(/^[^dMyhHmstz]+/), // all legal separators function (s) { return _.ignore(_.stoken(s)); } ) ) ), // construct the parser ... function (rules) { return _.process(_.each.apply(null, rules), t.finishExact); } ); // starting rule for general purpose grammar g._start = _.process(_.set([ g.date, g.time, g.expression ], g.generalDelimiter, g.whiteSpace), t.finish); }; g.buildGrammarFormats(); // parsing date format specifiers - ex: "h:m:s tt" // this little guy will generate a custom parser based // on the format string, ex: g.format("h:m:s tt") // check for these formats first g._formats = g.formats([ "\"yyyy-MM-ddTHH:mm:ssZ\"", "yyyy-MM-ddTHH:mm:ss.sz", "yyyy-MM-ddTHH:mm:ssZ", "yyyy-MM-ddTHH:mm:ssz", "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-ddTHH:mmZ", "yyyy-MM-ddTHH:mmz", "yyyy-MM-ddTHH:mm", "ddd, MMM dd, yyyy H:mm:ss tt", "ddd MMM d yyyy HH:mm:ss zzz", "MMddyyyy", "ddMMyyyy", "Mddyyyy", "ddMyyyy", "Mdyyyy", "dMyyyy", "yyyy", "Mdyy", "dMyy", "d" ]); // real starting rule: tries selected formats first, // then general purpose rule g.start = function (s) { try { var r = g._formats.call({}, s); if (r[1].length === 0) { return r; } } catch (e) {} return g._start.call({}, s); }; }()); (function () { var $D = Date; /** * @desc Converts the specified string value into its JavaScript Date equivalent using CultureInfo specific format information. * * Example

	///////////
	// Dates //
	///////////

	// 15-Oct-2004
	var d1 = Date.parse("10/15/2004");

	// 15-Oct-2004
	var d1 = Date.parse("15-Oct-2004");

	// 15-Oct-2004
	var d1 = Date.parse("2004.10.15");

	//Fri Oct 15, 2004
	var d1 = Date.parse("Fri Oct 15, 2004");

	///////////
	// Times //
	///////////

	// Today at 10 PM.
	var d1 = Date.parse("10 PM");

	// Today at 10:30 PM.
	var d1 = Date.parse("10:30 P.M.");

	// Today at 6 AM.
	var d1 = Date.parse("06am");

	/////////////////////
	// Dates and Times //
	/////////////////////

	// 8-July-2004 @ 10:30 PM
	var d1 = Date.parse("July 8th, 2004, 10:30 PM");

	// 1-July-2004 @ 10:30 PM
	var d1 = Date.parse("2004-07-01T22:30:00");

	////////////////////
	// Relative Dates //
	////////////////////

	// Returns today's date. The string "today" is culture specific.
	var d1 = Date.parse("today");

	// Returns yesterday's date. The string "yesterday" is culture specific.
	var d1 = Date.parse("yesterday");

	// Returns the date of the next thursday.
	var d1 = Date.parse("Next thursday");

	// Returns the date of the most previous monday.
	var d1 = Date.parse("last monday");

	// Returns today's day + one year.
	var d1 = Date.parse("next year");

	///////////////
	// Date Math //
	///////////////

	// Today + 2 days
	var d1 = Date.parse("t+2");

	// Today + 2 days
	var d1 = Date.parse("today + 2 days");

	// Today + 3 months
	var d1 = Date.parse("t+3m");

	// Today - 1 year
	var d1 = Date.parse("today - 1 year");

	// Today - 1 year
	var d1 = Date.parse("t-1y"); 


	/////////////////////////////
	// Partial Dates and Times //
	/////////////////////////////

	// July 15th of this year.
	var d1 = Date.parse("July 15");

	// 15th day of current day and year.
	var d1 = Date.parse("15");

	// July 1st of current year at 10pm.
	var d1 = Date.parse("7/1 10pm");
	
* * @param {String} The string value to convert into a Date object [Required] * @return {Date} A Date object or null if the string cannot be converted into a Date. */ var parseUtils = { removeOrds: function (s) { ords = s.match(/\b(\d+)(?:st|nd|rd|th)\b/); // find ordinal matches s = ((ords && ords.length === 2) ? s.replace(ords[0], ords[1]) : s); return s; }, grammarParser: function (s) { var r = null; try { r = $D.Grammar.start.call({}, s.replace(/^\s*(\S*(\s+\S+)*)\s*$/, "$1")); } catch (e) { return null; } return ((r[1].length === 0) ? r[0] : null); }, nativeFallback: function(s) { var t; try { // ok we haven't parsed it, last ditch attempt with the built-in parser. t = Date._parse(s); return (t || t === 0) ? new Date(t) : null; } catch (e) { return null; } } }; function parse (s) { var d; if (!s) { return null; } if (s instanceof Date) { return s.clone(); } if (s.length >= 4 && s.charAt(0) !== "0" && s.charAt(0) !== "+"&& s.charAt(0) !== "-") { // ie: 2004 will pass, 0800 won't. // Start with specific formats d = $D.Parsing.ISO.parse(s) || $D.Parsing.Numeric.parse(s); } if (d instanceof Date && !isNaN(d.getTime())) { return d; } else { // find ordinal dates (1st, 3rd, 8th, etc and remove them as they cause parsing issues) s = $D.Parsing.Normalizer.parse(parseUtils.removeOrds(s)); d = parseUtils.grammarParser(s); if (d !== null) { return d; } else { return parseUtils.nativeFallback(s); } } } if (!$D._parse) { $D._parse = $D.parse; } $D.parse = parse; Date.getParseFunction = function (fx) { var fns = Date.Grammar.allformats(fx); return function (s) { var r = null; for (var i = 0; i < fns.length; i++) { try { r = fns[i].call({}, s); } catch (e) { continue; } if (r[1].length === 0) { return r[0]; } } return null; }; }; /** * Converts the specified string value into its JavaScript Date equivalent using the specified format {String} or formats {Array} and the CultureInfo specific format information. * The format of the string value must match one of the supplied formats exactly. * * Example

	// 15-Oct-2004
	var d1 = Date.parseExact("10/15/2004", "M/d/yyyy");

	// 15-Oct-2004
	var d1 = Date.parse("15-Oct-2004", "M-ddd-yyyy");

	// 15-Oct-2004
	var d1 = Date.parse("2004.10.15", "yyyy.MM.dd");

	// Multiple formats
	var d1 = Date.parseExact("10/15/2004", ["M/d/yyyy", "MMMM d, yyyy"]);
	
* * @param {String} The string value to convert into a Date object [Required]. * @param {Object} The expected format {String} or an array of expected formats {Array} of the date string [Required]. * @return {Date} A Date object or null if the string cannot be converted into a Date. */ $D.parseExact = function (s, fx) { return $D.getParseFunction(fx)(s); }; }()); (function () { var $D = Date, $P = $D.prototype, // $C = $D.CultureInfo, // not used atm p = function (s, l) { if (!l) { l = 2; } return ("000" + s).slice(l * -1); }; /** * Converts a PHP format string to Java/.NET format string. * A PHP format string can be used with ._format or .format. * A Java/.NET format string can be used with .toString(). * The .parseExact function will only accept a Java/.NET format string * * Example * var f1 = "%m/%d/%y" * var f2 = Date.normalizeFormat(f1); // "MM/dd/yy" * * new Date().format(f1); // "04/13/08" * new Date()._format(f1); // "04/13/08" * new Date().toString(f2); // "04/13/08" * * var date = Date.parseExact("04/13/08", f2); // Sun Apr 13 2008 * * @param {String} A PHP format string consisting of one or more format spcifiers. * @return {String} The PHP format converted to a Java/.NET format string. */ var normalizerSubstitutions = { "d" : "dd", "%d": "dd", "D" : "ddd", "%a": "ddd", "j" : "dddd", "l" : "dddd", "%A": "dddd", "S" : "S", "F" : "MMMM", "%B": "MMMM", "m" : "MM", "%m": "MM", "M" : "MMM", "%b": "MMM", "%h": "MMM", "n" : "M", "Y" : "yyyy", "%Y": "yyyy", "y" : "yy", "%y": "yy", "g" : "h", "%I": "h", "G" : "H", "h" : "hh", "H" : "HH", "%H": "HH", "i" : "mm", "%M": "mm", "s" : "ss", "%S": "ss", "%r": "hh:mm tt", "%R": "H:mm", "%T": "H:mm:ss", "%X": "t", "%x": "d", "%e": "d", "%D": "MM/dd/yy", "%n": "\\n", "%t": "\\t", "e" : "z", "T" : "z", "%z": "z", "%Z": "z", "Z" : "ZZ", "N" : "u", "w" : "u", "%w": "u", "W" : "W", "%V": "W" }; var normalizer = { substitutes: function (m) { return normalizerSubstitutions[m]; }, interpreted: function (m, x) { var y; switch (m) { case "%u": return x.getDay() + 1; case "z": return x.getOrdinalNumber(); case "%j": return p(x.getOrdinalNumber(), 3); case "%U": var d1 = x.clone().set({month: 0, day: 1}).addDays(-1).moveToDayOfWeek(0), d2 = x.clone().addDays(1).moveToDayOfWeek(0, -1); return (d2 < d1) ? "00" : p((d2.getOrdinalNumber() - d1.getOrdinalNumber()) / 7 + 1); case "%W": return p(x.getWeek()); case "t": return $D.getDaysInMonth(x.getFullYear(), x.getMonth()); case "o": case "%G": return x.setWeek(x.getISOWeek()).toString("yyyy"); case "%g": return x._format("%G").slice(-2); case "a": case "%p": return t("tt").toLowerCase(); case "A": return t("tt").toUpperCase(); case "u": return p(x.getMilliseconds(), 3); case "I": return (x.isDaylightSavingTime()) ? 1 : 0; case "O": return x.getUTCOffset(); case "P": y = x.getUTCOffset(); return y.substring(0, y.length - 2) + ":" + y.substring(y.length - 2); case "B": var now = new Date(); return Math.floor(((now.getHours() * 3600) + (now.getMinutes() * 60) + now.getSeconds() + (now.getTimezoneOffset() + 60) * 60) / 86.4); case "c": return x.toISOString().replace(/\"/g, ""); case "U": return $D.strtotime("now"); case "%c": return t("d") + " " + t("t"); case "%C": return Math.floor(x.getFullYear() / 100 + 1); } }, shouldOverrideDefaults: function (m) { switch (m) { case "%e": return true; default: return false; } }, parse: function (m, context) { var formatString, c = context || new Date(); formatString = normalizer.substitutes(m); if (formatString) { return formatString; } formatString = normalizer.interpreted(m, c); if (formatString) { return formatString; } else { return m; } } }; $D.normalizeFormat = function (format, context) { return format.replace(/(%|\\)?.|%%/g, function(t){ return normalizer.parse(t, context); }); }; /** * Format a local Unix timestamp according to locale settings * * Example: * Date.strftime("%m/%d/%y", new Date()); // "04/13/08" * Date.strftime("c", "2008-04-13T17:52:03Z"); // "04/13/08" * * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @param {Number|String} The number representing the number of seconds that have elapsed since January 1, 1970 (local time). * @return {String} A string representation of the current Date object. */ $D.strftime = function (format, time) { var d = Date.parse(time); return d._format(format); }; /** * Parse any textual datetime description into a Unix timestamp. * A Unix timestamp is the number of seconds that have elapsed since January 1, 1970 (midnight UTC/GMT). * * Example: * Date.strtotime("04/13/08"); // 1208044800 * Date.strtotime("1970-01-01T00:00:00Z"); // 0 * * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @param {Object} A string or date object. * @return {String} A string representation of the current Date object. */ $D.strtotime = function (time) { var d = $D.parse(time); return Math.round($D.UTC(d.getUTCFullYear(), d.getUTCMonth(), d.getUTCDate(), d.getUTCHours(), d.getUTCMinutes(), d.getUTCSeconds(), d.getUTCMilliseconds()) / 1000); }; /** * Converts the value of the current Date object to its equivalent string representation using a PHP/Unix style of date format specifiers. * Format Specifiers * Format Description Example * ------ --------------------------------------------------------------------------- ----------------------- * %a abbreviated weekday name according to the current localed "Mon" through "Sun" * %A full weekday name according to the current localed "Sunday" through "Saturday" * %b abbreviated month name according to the current localed "Jan" through "Dec" * %B full month name according to the current locale "January" through "December" * %c preferred date and time representation for the current locale "4/13/2008 12:33 PM" * %C century number (the year divided by 100 and truncated to an integer) "00" to "99" * %d day of the month as a decimal number "01" to "31" * %D same as %m/%d/%y "04/13/08" * %e day of the month as a decimal number, a single digit is preceded by a space "1" to "31" * %g like %G, but without the century "08" * %G The 4-digit year corresponding to the ISO week number (see %V). "2008" * This has the same format and value as %Y, except that if the ISO week number * belongs to the previous or next year, that year is used instead. * %h same as %b "Jan" through "Dec" * %H hour as a decimal number using a 24-hour clock. "00" to "23" * %I hour as a decimal number using a 12-hour clock. "01" to "12" * %j day of the year as a decimal number. "001" to "366" * %m month as a decimal number. "01" to "12" * %M minute as a decimal number. "00" to "59" * %n newline character "\n" * %p either "am" or "pm" according to the given time value, or the "am" or "pm" * corresponding strings for the current locale. * %r time in a.m. and p.m. notation "8:44 PM" * %R time in 24 hour notation "20:44" * %S second as a decimal number "00" to "59" * %t tab character "\t" * %T current time, equal to %H:%M:%S "12:49:11" * %u weekday as a decimal number ["1", "7"], with "1" representing Monday "1" to "7" * %U week number of the current year as a decimal number, starting with the "0" to ("52" or "53") * first Sunday as the first day of the first week * %V The ISO 8601:1988 week number of the current year as a decimal number, "00" to ("52" or "53") * range 01 to 53, where week 1 is the first week that has at least 4 days * in the current year, and with Monday as the first day of the week. * (Use %G or %g for the year component that corresponds to the week number * for the specified timestamp.) * %W week number of the current year as a decimal number, starting with the "00" to ("52" or "53") * first Monday as the first day of the first week * %w day of the week as a decimal, Sunday being "0" "0" to "6" * %x preferred date representation for the current locale without the time "4/13/2008" * %X preferred time representation for the current locale without the date "12:53:05" * %y year as a decimal number without a century "00" "99" * %Y year as a decimal number including the century "2008" * %Z time zone or name or abbreviation "UTC", "EST", "PST" * %z same as %Z * %% a literal "%" characters "%" * d Day of the month, 2 digits with leading zeros "01" to "31" * D A textual representation of a day, three letters "Mon" through "Sun" * j Day of the month without leading zeros "1" to "31" * l A full textual representation of the day of the week (lowercase "L") "Sunday" through "Saturday" * N ISO-8601 numeric representation of the day of the week (added in PHP 5.1.0) "1" (for Monday) through "7" (for Sunday) * S English ordinal suffix for the day of the month, 2 characters "st", "nd", "rd" or "th". Works well with j * w Numeric representation of the day of the week "0" (for Sunday) through "6" (for Saturday) * z The day of the year (starting from "0") "0" through "365" * W ISO-8601 week number of year, weeks starting on Monday "00" to ("52" or "53") * F A full textual representation of a month, such as January or March "January" through "December" * m Numeric representation of a month, with leading zeros "01" through "12" * M A short textual representation of a month, three letters "Jan" through "Dec" * n Numeric representation of a month, without leading zeros "1" through "12" * t Number of days in the given month "28" through "31" * L Whether it's a leap year "1" if it is a leap year, "0" otherwise * o ISO-8601 year number. This has the same value as Y, except that if the "2008" * ISO week number (W) belongs to the previous or next year, that year * is used instead. * Y A full numeric representation of a year, 4 digits "2008" * y A two digit representation of a year "08" * a Lowercase Ante meridiem and Post meridiem "am" or "pm" * A Uppercase Ante meridiem and Post meridiem "AM" or "PM" * B Swatch Internet time "000" through "999" * g 12-hour format of an hour without leading zeros "1" through "12" * G 24-hour format of an hour without leading zeros "0" through "23" * h 12-hour format of an hour with leading zeros "01" through "12" * H 24-hour format of an hour with leading zeros "00" through "23" * i Minutes with leading zeros "00" to "59" * s Seconds, with leading zeros "00" through "59" * u Milliseconds "54321" * e Timezone identifier "UTC", "EST", "PST" * I Whether or not the date is in daylight saving time (uppercase i) "1" if Daylight Saving Time, "0" otherwise * O Difference to Greenwich time (GMT) in hours "+0200", "-0600" * P Difference to Greenwich time (GMT) with colon between hours and minutes "+02:00", "-06:00" * T Timezone abbreviation "UTC", "EST", "PST" * Z Timezone offset in seconds. The offset for timezones west of UTC is "-43200" through "50400" * always negative, and for those east of UTC is always positive. * c ISO 8601 date "2004-02-12T15:19:21+00:00" * r RFC 2822 formatted date "Thu, 21 Dec 2000 16:01:07 +0200" * U Seconds since the Unix Epoch (January 1 1970 00:00:00 GMT) "0" * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @return {String} A string representation of the current Date object. */ var formatReplace = function (context) { return function (m) { var formatString, override = false; if (m.charAt(0) === "\\" || m.substring(0, 2) === "%%") { return m.replace("\\", "").replace("%%", "%"); } override = normalizer.shouldOverrideDefaults(m); formatString = $D.normalizeFormat(m, context); if (formatString) { return context.toString(formatString, override); } }; }; $P._format = function (format) { var formatter = formatReplace(this); if (!format) { return this._toString(); } else { return format.replace(/(%|\\)?.|%%/g, formatter); } }; if (!$P.format) { $P.format = $P._format; } }()); (function () { "use strict"; var gFn = function (attr) { return function () { return this[attr]; }; }; var sFn = function (attr) { return function (val) { this[attr] = val; return this; }; }; var attrs = ["years", "months", "days", "hours", "minutes", "seconds", "milliseconds"]; var addSetFuncs = function (context, attrs) { for (var i = 0; i < attrs.length ; i++) { var $a = attrs[i], $b = $a.slice(0, 1).toUpperCase() + $a.slice(1); context.prototype[$a] = 0; context.prototype["get" + $b] = gFn($a); context.prototype["set" + $b] = sFn($a); } }; /** * new TimeSpan(milliseconds); * new TimeSpan(days, hours, minutes, seconds); * new TimeSpan(days, hours, minutes, seconds, milliseconds); */ var TimeSpan = function (days, hours, minutes, seconds, milliseconds) { if (arguments.length === 1 && typeof days === "number") { var orient = (days < 0) ? -1 : +1; var millsLeft = Math.abs(days); this.setDays(Math.floor(millsLeft / 86400000) * orient); millsLeft = millsLeft % 86400000; this.setHours(Math.floor(millsLeft / 3600000) * orient); millsLeft = millsLeft % 3600000; this.setMinutes(Math.floor(millsLeft / 60000) * orient); millsLeft = millsLeft % 60000; this.setSeconds(Math.floor(millsLeft / 1000) * orient); millsLeft = millsLeft % 1000; this.setMilliseconds(millsLeft * orient); } else { this.set(days, hours, minutes, seconds, milliseconds); } this.getTotalMilliseconds = function () { return (this.getDays() * 86400000) + (this.getHours() * 3600000) + (this.getMinutes() * 60000) + (this.getSeconds() * 1000); }; this.compareTo = function (time) { var t1 = new Date(1970, 1, 1, this.getHours(), this.getMinutes(), this.getSeconds()), t2; if (time === null) { t2 = new Date(1970, 1, 1, 0, 0, 0); } else { t2 = new Date(1970, 1, 1, time.getHours(), time.getMinutes(), time.getSeconds()); } return (t1 < t2) ? -1 : (t1 > t2) ? 1 : 0; }; this.equals = function (time) { return (this.compareTo(time) === 0); }; this.add = function (time) { return (time === null) ? this : this.addSeconds(time.getTotalMilliseconds() / 1000); }; this.subtract = function (time) { return (time === null) ? this : this.addSeconds(-time.getTotalMilliseconds() / 1000); }; this.addDays = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 86400000)); }; this.addHours = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 3600000)); }; this.addMinutes = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 60000)); }; this.addSeconds = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 1000)); }; this.addMilliseconds = function (n) { return new TimeSpan(this.getTotalMilliseconds() + n); }; this.get12HourHour = function () { return (this.getHours() > 12) ? this.getHours() - 12 : (this.getHours() === 0) ? 12 : this.getHours(); }; this.getDesignator = function () { return (this.getHours() < 12) ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator; }; this.toString = function (format) { this._toString = function () { if (this.getDays() !== null && this.getDays() > 0) { return this.getDays() + "." + this.getHours() + ":" + this.p(this.getMinutes()) + ":" + this.p(this.getSeconds()); } else { return this.getHours() + ":" + this.p(this.getMinutes()) + ":" + this.p(this.getSeconds()); } }; this.p = function (s) { return (s.toString().length < 2) ? "0" + s : s; }; var me = this; return format ? format.replace(/dd?|HH?|hh?|mm?|ss?|tt?/g, function (format) { switch (format) { case "d": return me.getDays(); case "dd": return me.p(me.getDays()); case "H": return me.getHours(); case "HH": return me.p(me.getHours()); case "h": return me.get12HourHour(); case "hh": return me.p(me.get12HourHour()); case "m": return me.getMinutes(); case "mm": return me.p(me.getMinutes()); case "s": return me.getSeconds(); case "ss": return me.p(me.getSeconds()); case "t": return ((me.getHours() < 12) ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator).substring(0, 1); case "tt": return (me.getHours() < 12) ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator; } } ) : this._toString(); }; return this; }; addSetFuncs(TimeSpan, attrs.slice(2)); TimeSpan.prototype.set = function (days, hours, minutes, seconds, milliseconds){ this.setDays(days || this.getDays()); this.setHours(hours || this.getHours()); this.setMinutes(minutes || this.getMinutes()); this.setSeconds(seconds || this.getSeconds()); this.setMilliseconds(milliseconds || this.getMilliseconds()); }; /** * Gets the time of day for this date instances. * @return {TimeSpan} TimeSpan */ Date.prototype.getTimeOfDay = function () { return new TimeSpan(0, this.getHours(), this.getMinutes(), this.getSeconds(), this.getMilliseconds()); }; Date.TimeSpan = TimeSpan; if (typeof window !== "undefined" ) { // keeping API compatible for v1.x window.TimeSpan = TimeSpan; } }()); (function () { "use strict"; var attrs = ["years", "months", "days", "hours", "minutes", "seconds", "milliseconds"]; var gFn = function (attr) { return function () { return this[attr]; }; }; var sFn = function (attr) { return function (val) { this[attr] = val; return this; }; }; var addSetFuncs = function (context, attrs) { for (var i = 0; i < attrs.length ; i++) { var $a = attrs[i], $b = $a.slice(0, 1).toUpperCase() + $a.slice(1); context.prototype[$a] = 0; context.prototype["get" + $b] = gFn($a); context.prototype["set" + $b] = sFn($a); } }; var setMonthsAndYears = function (orient, d1, d2, context) { function inc() { d1.addMonths(-orient); context.months++; if (context.months === 12) { context.years++; context.months = 0; } } if (orient === +1) { while (d1 > d2) { inc(); } } else { while (d1 < d2) { inc(); } } context.months--; context.months *= orient; context.years *= orient; }; var adjustForDST = function(orient, startDate, endDate) { var hasDSTMismatch = (false === (startDate.isDaylightSavingTime() === endDate.isDaylightSavingTime())); if (hasDSTMismatch && orient === 1) { startDate.addHours(-1); } else if (hasDSTMismatch) { startDate.addHours(1); } }; /** * TimePeriod(startDate, endDate); * TimePeriod(years, months, days, hours, minutes, seconds, milliseconds); */ var TimePeriod = function (years, months, days, hours, minutes, seconds, milliseconds) { if (arguments.length === 7) { this.set(years, months, days, hours, minutes, seconds, milliseconds); } else if (arguments.length === 2 && arguments[0] instanceof Date && arguments[1] instanceof Date) { var startDate = arguments[0].clone(); var endDate = arguments[1].clone(); var orient = (startDate > endDate) ? +1 : -1; this.dates = { start: arguments[0].clone(), end: arguments[1].clone() }; setMonthsAndYears(orient, startDate, endDate, this); adjustForDST(orient, startDate, endDate); // // TODO - adjust for DST var diff = endDate - startDate; if (diff !== 0) { var ts = new TimeSpan(diff); this.set(this.years, this.months, ts.getDays(), ts.getHours(), ts.getMinutes(), ts.getSeconds(), ts.getMilliseconds()); } } return this; }; // create all the set functions. addSetFuncs(TimePeriod, attrs); TimePeriod.prototype.set = function (years, months, days, hours, minutes, seconds, milliseconds){ this.setYears(years || this.getYears()); this.setMonths(months || this.getMonths()); this.setDays(days || this.getDays()); this.setHours(hours || this.getHours()); this.setMinutes(minutes || this.getMinutes()); this.setSeconds(seconds || this.getSeconds()); this.setMilliseconds(milliseconds || this.getMilliseconds()); }; Date.TimePeriod = TimePeriod; if (typeof window !== "undefined") { // keeping API compatible for v1.x window.TimePeriod = TimePeriod; } }()); ================================================ FILE: build/date-ar-YE.js ================================================ /** * @overview datejs * @version 1.0.0-rc3 * @author Gregory Wild-Smith * @copyright 2015 Gregory Wild-Smith * @license MIT * @homepage https://github.com/abritinthebay/datejs */ /* * DateJS Culture String File * Country Code: ar-YE * Name: Arabic (Yemen) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["ar-YE"] = { "name": "ar-YE", "englishName": "Arabic (Yemen)", "nativeName": "العربية (اليمن)", "Sunday": "الاحد", "Monday": "الاثنين", "Tuesday": "الثلاثاء", "Wednesday": "الاربعاء", "Thursday": "الخميس", "Friday": "الجمعة", "Saturday": "السبت", "Sun": "الاحد", "Mon": "الاثنين", "Tue": "الثلاثاء", "Wed": "الاربعاء", "Thu": "الخميس", "Fri": "الجمعة", "Sat": "السبت", "Su": "أ", "Mo": "ا", "Tu": "ث", "We": "أ", "Th": "خ", "Fr": "ج", "Sa": "س", "S_Sun_Initial": "أ", "M_Mon_Initial": "ا", "T_Tue_Initial": "ث", "W_Wed_Initial": "أ", "T_Thu_Initial": "خ", "F_Fri_Initial": "ج", "S_Sat_Initial": "س", "January": "يناير", "February": "فبراير", "March": "مارس", "April": "ابريل", "May": "مايو", "June": "يونيو", "July": "يوليو", "August": "اغسطس", "September": "سبتمبر", "October": "اكتوبر", "November": "نوفمبر", "December": "ديسمبر", "Jan_Abbr": "يناير", "Feb_Abbr": "فبراير", "Mar_Abbr": "مارس", "Apr_Abbr": "ابريل", "May_Abbr": "مايو", "Jun_Abbr": "يونيو", "Jul_Abbr": "يوليو", "Aug_Abbr": "اغسطس", "Sep_Abbr": "سبتمبر", "Oct_Abbr": "اكتوبر", "Nov_Abbr": "نوفمبر", "Dec_Abbr": "ديسمبر", "AM": "ص", "PM": "م", "firstDayOfWeek": 6, "twoDigitYearMax": 2029, "mdy": "dmy", "M/d/yyyy": "dd/MM/yyyy", "dddd, MMMM dd, yyyy": "dd MMMM, yyyy", "h:mm tt": "hh:mm tt", "h:mm:ss tt": "hh:mm:ss tt", "dddd, MMMM dd, yyyy h:mm:ss tt": "dd MMMM, yyyy hh:mm:ss tt", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "dd MMMM", "MMMM, yyyy": "MMMM, yyyy", "/jan(uary)?/": "يناير", "/feb(ruary)?/": "فبراير", "/mar(ch)?/": "مارس", "/apr(il)?/": "ابريل", "/may/": "مايو", "/jun(e)?/": "يونيو", "/jul(y)?/": "يوليو", "/aug(ust)?/": "اغسطس", "/sep(t(ember)?)?/": "سبتمبر", "/oct(ober)?/": "اكتوبر", "/nov(ember)?/": "نوفمبر", "/dec(ember)?/": "ديسمبر", "/^su(n(day)?)?/": "^الاحد", "/^mo(n(day)?)?/": "^ا(1)?", "/^tu(e(s(day)?)?)?/": "^الثلاثاء", "/^we(d(nesday)?)?/": "^الاربعاء", "/^th(u(r(s(day)?)?)?)?/": "^الخميس", "/^fr(i(day)?)?/": "^الجمعة", "/^sa(t(urday)?)?/": "^السبت", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "ar-YE"; /** * @overview datejs * @version 1.0.0-rc3 * @author Gregory Wild-Smith * @copyright 2015 Gregory Wild-Smith * @license MIT * @homepage https://github.com/abritinthebay/datejs */(function () { var $D = Date; var lang = Date.CultureStrings ? Date.CultureStrings.lang : null; var loggedKeys = {}; // for debug purposes. var getText = { getFromKey: function (key, countryCode) { var output; if (Date.CultureStrings && Date.CultureStrings[countryCode] && Date.CultureStrings[countryCode][key]) { output = Date.CultureStrings[countryCode][key]; } else { output = getText.buildFromDefault(key); } if (key.charAt(0) === "/") { // Assume it's a regex output = getText.buildFromRegex(key, countryCode); } return output; }, getFromObjectValues: function (obj, countryCode) { var key, output = {}; for(key in obj) { if (obj.hasOwnProperty(key)) { output[key] = getText.getFromKey(obj[key], countryCode); } } return output; }, getFromObjectKeys: function (obj, countryCode) { var key, output = {}; for(key in obj) { if (obj.hasOwnProperty(key)) { output[getText.getFromKey(key, countryCode)] = obj[key]; } } return output; }, getFromArray: function (arr, countryCode) { var output = []; for (var i=0; i < arr.length; i++){ if (i in arr) { output[i] = getText.getFromKey(arr[i], countryCode); } } return output; }, buildFromDefault: function (key) { var output, length, split, last; switch(key) { case "name": output = "en-US"; break; case "englishName": output = "English (United States)"; break; case "nativeName": output = "English (United States)"; break; case "twoDigitYearMax": output = 2049; break; case "firstDayOfWeek": output = 0; break; default: output = key; split = key.split("_"); length = split.length; if (length > 1 && key.charAt(0) !== "/") { // if the key isn't a regex and it has a split. last = split[(length - 1)].toLowerCase(); if (last === "initial" || last === "abbr") { output = split[0]; } } break; } return output; }, buildFromRegex: function (key, countryCode) { var output; if (Date.CultureStrings && Date.CultureStrings[countryCode] && Date.CultureStrings[countryCode][key]) { output = new RegExp(Date.CultureStrings[countryCode][key], "i"); } else { output = new RegExp(key.replace(new RegExp("/", "g"),""), "i"); } return output; } }; var shallowMerge = function (obj1, obj2) { for (var attrname in obj2) { if (obj2.hasOwnProperty(attrname)) { obj1[attrname] = obj2[attrname]; } } }; var __ = function (key, language) { var countryCode = (language) ? language : lang; loggedKeys[key] = key; if (typeof key === "object") { if (key instanceof Array) { return getText.getFromArray(key, countryCode); } else { return getText.getFromObjectKeys(key, countryCode); } } else { return getText.getFromKey(key, countryCode); } }; var loadI18nScript = function (code) { // paatterned after jQuery's getScript. var url = Date.Config.i18n + code + ".js"; var head = document.getElementsByTagName("head")[0] || document.documentElement; var script = document.createElement("script"); script.src = url; var completed = false; var events = { done: function (){} // placeholder function }; // Attach handlers for all browsers script.onload = script.onreadystatechange = function() { if ( !completed && (!this.readyState || this.readyState === "loaded" || this.readyState === "complete") ) { events.done(); head.removeChild(script); } }; setTimeout(function() { head.insertBefore(script, head.firstChild); }, 0); // allows return to execute first return { done: function (cb) { events.done = function() { if (cb) { setTimeout(cb,0); } }; } }; }; var buildInfo = { buildFromMethodHash: function (obj) { var key; for(key in obj) { if (obj.hasOwnProperty(key)) { obj[key] = buildInfo[obj[key]](); } } return obj; }, timeZoneDST: function () { var DST = { "CHADT": "+1345", "NZDT": "+1300", "AEDT": "+1100", "ACDT": "+1030", "AZST": "+0500", "IRDT": "+0430", "EEST": "+0300", "CEST": "+0200", "BST": "+0100", "PMDT": "-0200", "ADT": "-0300", "NDT": "-0230", "EDT": "-0400", "CDT": "-0500", "MDT": "-0600", "PDT": "-0700", "AKDT": "-0800", "HADT": "-0900" }; return __(DST); }, timeZoneStandard: function () { var standard = { "LINT": "+1400", "TOT": "+1300", "CHAST": "+1245", "NZST": "+1200", "NFT": "+1130", "SBT": "+1100", "AEST": "+1000", "ACST": "+0930", "JST": "+0900", "CWST": "+0845", "CT": "+0800", "ICT": "+0700", "MMT": "+0630", "BST": "+0600", "NPT": "+0545", "IST": "+0530", "PKT": "+0500", "AFT": "+0430", "MSK": "+0400", "IRST": "+0330", "FET": "+0300", "EET": "+0200", "CET": "+0100", "GMT": "+0000", "UTC": "+0000", "CVT": "-0100", "GST": "-0200", "BRT": "-0300", "NST": "-0330", "AST": "-0400", "EST": "-0500", "CST": "-0600", "MST": "-0700", "PST": "-0800", "AKST": "-0900", "MIT": "-0930", "HST": "-1000", "SST": "-1100", "BIT": "-1200" }; return __(standard); }, timeZones: function (data) { var zone; data.timezones = []; for (zone in data.abbreviatedTimeZoneStandard) { if (data.abbreviatedTimeZoneStandard.hasOwnProperty(zone)) { data.timezones.push({ name: zone, offset: data.abbreviatedTimeZoneStandard[zone]}); } } for (zone in data.abbreviatedTimeZoneDST) { if (data.abbreviatedTimeZoneDST.hasOwnProperty(zone)) { data.timezones.push({ name: zone, offset: data.abbreviatedTimeZoneDST[zone], dst: true}); } } return data.timezones; }, days: function () { return __(["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"]); }, dayAbbr: function () { return __(["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"]); }, dayShortNames: function () { return __(["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"]); }, dayFirstLetters: function () { return __(["S_Sun_Initial", "M_Mon_Initial", "T_Tues_Initial", "W_Wed_Initial", "T_Thu_Initial", "F_Fri_Initial", "S_Sat_Initial"]); }, months: function () { return __(["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"]); }, monthAbbr: function () { return __(["Jan_Abbr", "Feb_Abbr", "Mar_Abbr", "Apr_Abbr", "May_Abbr", "Jun_Abbr", "Jul_Abbr", "Aug_Abbr", "Sep_Abbr", "Oct_Abbr", "Nov_Abbr", "Dec_Abbr"]); }, formatPatterns: function () { return getText.getFromObjectValues({ shortDate: "M/d/yyyy", longDate: "dddd, MMMM dd, yyyy", shortTime: "h:mm tt", longTime: "h:mm:ss tt", fullDateTime: "dddd, MMMM dd, yyyy h:mm:ss tt", sortableDateTime: "yyyy-MM-ddTHH:mm:ss", universalSortableDateTime: "yyyy-MM-dd HH:mm:ssZ", rfc1123: "ddd, dd MMM yyyy HH:mm:ss", monthDay: "MMMM dd", yearMonth: "MMMM, yyyy" }, Date.i18n.currentLanguage()); }, regex: function () { return getText.getFromObjectValues({ inTheMorning: "/( in the )(morn(ing)?)\\b/", thisMorning: "/(this )(morn(ing)?)\\b/", amThisMorning: "/(\b\\d(am)? )(this )(morn(ing)?)/", inTheEvening: "/( in the )(even(ing)?)\\b/", thisEvening: "/(this )(even(ing)?)\\b/", pmThisEvening: "/(\b\\d(pm)? )(this )(even(ing)?)/", jan: "/jan(uary)?/", feb: "/feb(ruary)?/", mar: "/mar(ch)?/", apr: "/apr(il)?/", may: "/may/", jun: "/jun(e)?/", jul: "/jul(y)?/", aug: "/aug(ust)?/", sep: "/sep(t(ember)?)?/", oct: "/oct(ober)?/", nov: "/nov(ember)?/", dec: "/dec(ember)?/", sun: "/^su(n(day)?)?/", mon: "/^mo(n(day)?)?/", tue: "/^tu(e(s(day)?)?)?/", wed: "/^we(d(nesday)?)?/", thu: "/^th(u(r(s(day)?)?)?)?/", fri: "/fr(i(day)?)?/", sat: "/^sa(t(urday)?)?/", future: "/^next/", past: "/^last|past|prev(ious)?/", add: "/^(\\+|aft(er)?|from|hence)/", subtract: "/^(\\-|bef(ore)?|ago)/", yesterday: "/^yes(terday)?/", today: "/^t(od(ay)?)?/", tomorrow: "/^tom(orrow)?/", now: "/^n(ow)?/", millisecond: "/^ms|milli(second)?s?/", second: "/^sec(ond)?s?/", minute: "/^mn|min(ute)?s?/", hour: "/^h(our)?s?/", week: "/^w(eek)?s?/", month: "/^m(onth)?s?/", day: "/^d(ay)?s?/", year: "/^y(ear)?s?/", shortMeridian: "/^(a|p)/", longMeridian: "/^(a\\.?m?\\.?|p\\.?m?\\.?)/", timezone: "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/", ordinalSuffix: "/^\\s*(st|nd|rd|th)/", timeContext: "/^\\s*(\\:|a(?!u|p)|p)/" }, Date.i18n.currentLanguage()); } }; var CultureInfo = function () { var info = getText.getFromObjectValues({ name: "name", englishName: "englishName", nativeName: "nativeName", amDesignator: "AM", pmDesignator: "PM", firstDayOfWeek: "firstDayOfWeek", twoDigitYearMax: "twoDigitYearMax", dateElementOrder: "mdy" }, Date.i18n.currentLanguage()); var constructedInfo = buildInfo.buildFromMethodHash({ dayNames: "days", abbreviatedDayNames: "dayAbbr", shortestDayNames: "dayShortNames", firstLetterDayNames: "dayFirstLetters", monthNames: "months", abbreviatedMonthNames: "monthAbbr", formatPatterns: "formatPatterns", regexPatterns: "regex", abbreviatedTimeZoneDST: "timeZoneDST", abbreviatedTimeZoneStandard: "timeZoneStandard" }); shallowMerge(info, constructedInfo); buildInfo.timeZones(info); return info; }; $D.i18n = { __: function (key, lang) { return __(key, lang); }, currentLanguage: function () { return lang || "en-US"; }, setLanguage: function (code, force, cb) { var async = false; if (force || code === "en-US" || (!!Date.CultureStrings && !!Date.CultureStrings[code])) { lang = code; Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings.lang = code; Date.CultureInfo = new CultureInfo(); } else { if (!(!!Date.CultureStrings && !!Date.CultureStrings[code])) { if (typeof exports !== "undefined" && this.exports !== exports) { // we're in a Node enviroment, load it using require try { require("../i18n/" + code + ".js"); lang = code; Date.CultureStrings.lang = code; Date.CultureInfo = new CultureInfo(); } catch (e) { // var str = "The language for '" + code + "' could not be loaded by Node. It likely does not exist."; throw new Error("The DateJS IETF language tag '" + code + "' could not be loaded by Node. It likely does not exist."); } } else if (Date.Config && Date.Config.i18n) { // we know the location of the files, so lets load them async = true; loadI18nScript(code).done(function(){ lang = code; Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings.lang = code; Date.CultureInfo = new CultureInfo(); $D.Parsing.Normalizer.buildReplaceData(); // because this is async if ($D.Grammar) { $D.Grammar.buildGrammarFormats(); // so we can parse those strings... } if (cb) { setTimeout(cb,0); } }); } else { Date.console.error("The DateJS IETF language tag '" + code + "' is not available and has not been loaded."); return false; } } } $D.Parsing.Normalizer.buildReplaceData(); // rebuild normalizer strings if ($D.Grammar) { $D.Grammar.buildGrammarFormats(); // so we can parse those strings... } if (!async && cb) { setTimeout(cb,0); } }, getLoggedKeys: function () { return loggedKeys; }, updateCultureInfo: function () { Date.CultureInfo = new CultureInfo(); } }; $D.i18n.updateCultureInfo(); // run automatically }()); (function () { var $D = Date, $P = $D.prototype, p = function (s, l) { if (!l) { l = 2; } return ("000" + s).slice(l * -1); }; if (typeof window !== "undefined" && typeof window.console !== "undefined" && typeof window.console.log !== "undefined") { $D.console = console; // used only to raise non-critical errors if available } else { // set mock so we don't give errors. $D.console = { log: function(){}, error: function(){} }; } $D.Config = $D.Config || {}; $D.initOverloads = function() { /** * Overload of Date.now. Allows an alternate call for Date.now where it returns the * current Date as an object rather than just milliseconds since the Unix Epoch. * * Also provides an implementation of now() for browsers (IE<9) that don't have it. * * Backwards compatible so with work with either: * Date.now() [returns ms] * or * Date.now(true) [returns Date] */ if (!$D.now) { $D._now = function now() { return new Date().getTime(); }; } else if (!$D._now) { $D._now = $D.now; } $D.now = function (returnObj) { if (returnObj) { return $D.present(); } else { return $D._now(); } }; if ( !$P.toISOString ) { $P.toISOString = function() { return this.getUTCFullYear() + "-" + p(this.getUTCMonth() + 1) + "-" + p(this.getUTCDate()) + "T" + p(this.getUTCHours()) + ":" + p(this.getUTCMinutes()) + ":" + p(this.getUTCSeconds()) + "." + String( (this.getUTCMilliseconds()/1000).toFixed(3)).slice(2, 5) + "Z"; }; } // private if ( $P._toString === undefined ){ $P._toString = $P.toString; } }; $D.initOverloads(); /** * Gets a date that is set to the current date. The time is set to the start of the day (00:00 or 12:00 AM). * @return {Date} The current date. */ $D.today = function () { return new Date().clearTime(); }; /** * Gets a date that is set to the current date and time (same as new Date, but chainable) * @return {Date} The current date. */ $D.present = function () { return new Date(); }; /** * Compares the first date to the second date and returns an number indication of their relative values. * @param {Date} First Date object to compare [Required]. * @param {Date} Second Date object to compare to [Required]. * @return {Number} -1 = date1 is lessthan date2. 0 = values are equal. 1 = date1 is greaterthan date2. */ $D.compare = function (date1, date2) { if (isNaN(date1) || isNaN(date2)) { throw new Error(date1 + " - " + date2); } else if (date1 instanceof Date && date2 instanceof Date) { return (date1 < date2) ? -1 : (date1 > date2) ? 1 : 0; } else { throw new TypeError(date1 + " - " + date2); } }; /** * Compares the first Date object to the second Date object and returns true if they are equal. * @param {Date} First Date object to compare [Required] * @param {Date} Second Date object to compare to [Required] * @return {Boolean} true if dates are equal. false if they are not equal. */ $D.equals = function (date1, date2) { return (date1.compareTo(date2) === 0); }; /** * Gets the language appropriate day name when given the day number(0-6) * eg - 0 == Sunday * @return {String} The day name */ $D.getDayName = function (n) { return Date.CultureInfo.dayNames[n]; }; /** * Gets the day number (0-6) if given a CultureInfo specific string which is a valid dayName, abbreviatedDayName or shortestDayName (two char). * @param {String} The name of the day (eg. "Monday, "Mon", "tuesday", "tue", "We", "we"). * @return {Number} The day number */ $D.getDayNumberFromName = function (name) { var n = Date.CultureInfo.dayNames, m = Date.CultureInfo.abbreviatedDayNames, o = Date.CultureInfo.shortestDayNames, s = name.toLowerCase(); for (var i = 0; i < n.length; i++) { if (n[i].toLowerCase() === s || m[i].toLowerCase() === s || o[i].toLowerCase() === s) { return i; } } return -1; }; /** * Gets the month number (0-11) if given a Culture Info specific string which is a valid monthName or abbreviatedMonthName. * @param {String} The name of the month (eg. "February, "Feb", "october", "oct"). * @return {Number} The day number */ $D.getMonthNumberFromName = function (name) { var n = Date.CultureInfo.monthNames, m = Date.CultureInfo.abbreviatedMonthNames, s = name.toLowerCase(); for (var i = 0; i < n.length; i++) { if (n[i].toLowerCase() === s || m[i].toLowerCase() === s) { return i; } } return -1; }; /** * Gets the language appropriate month name when given the month number(0-11) * eg - 0 == January * @return {String} The month name */ $D.getMonthName = function (n) { return Date.CultureInfo.monthNames[n]; }; /** * Determines if the current date instance is within a LeapYear. * @param {Number} The year. * @return {Boolean} true if date is within a LeapYear, otherwise false. */ $D.isLeapYear = function (year) { return ((year % 4 === 0 && year % 100 !== 0) || year % 400 === 0); }; /** * Gets the number of days in the month, given a year and month value. Automatically corrects for LeapYear. * @param {Number} The year. * @param {Number} The month (0-11). * @return {Number} The number of days in the month. */ $D.getDaysInMonth = function (year, month) { if (!month && $D.validateMonth(year)) { month = year; year = Date.today().getFullYear(); } return [31, ($D.isLeapYear(year) ? 29 : 28), 31, 30, 31, 30, 31, 31, 30, 31, 30, 31][month]; }; $P.getDaysInMonth = function () { return $D.getDaysInMonth(this.getFullYear(), this.getMonth()); }; $D.getTimezoneAbbreviation = function (offset, dst) { var p, n = (dst || false) ? Date.CultureInfo.abbreviatedTimeZoneDST : Date.CultureInfo.abbreviatedTimeZoneStandard; for (p in n) { if (n.hasOwnProperty(p)) { if (n[p] === offset) { return p; } } } return null; }; $D.getTimezoneOffset = function (name, dst) { var i, a =[], z = Date.CultureInfo.timezones; if (!name) { name = (new Date()).getTimezone();} for (i = 0; i < z.length; i++) { if (z[i].name === name.toUpperCase()) { a.push(i); } } if (!z[a[0]]) { return null; } if (a.length === 1 || !dst) { return z[a[0]].offset; } else { for (i=0; i < a.length; i++) { if (z[a[i]].dst) { return z[a[i]].offset; } } } }; $D.getQuarter = function (d) { d = d || new Date(); // If no date supplied, use today var q = [1,2,3,4]; return q[Math.floor(d.getMonth() / 3)]; // ~~~ is a bitwise op. Faster than Math.floor }; $D.getDaysLeftInQuarter = function (d) { d = d || new Date(); var qEnd = new Date(d); qEnd.setMonth(qEnd.getMonth() + 3 - qEnd.getMonth() % 3, 0); return Math.floor((qEnd - d) / 8.64e7); }; // private var validate = function (n, min, max, name) { name = name ? name : "Object"; if (typeof n === "undefined") { return false; } else if (typeof n !== "number") { throw new TypeError(n + " is not a Number."); } else if (n < min || n > max) { // As failing validation is *not* an exceptional circumstance // lets not throw a RangeError Exception here. // It's semantically correct but it's not sensible. return false; } return true; }; /** * Validates the number is within an acceptable range for milliseconds [0-999]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateMillisecond = function (value) { return validate(value, 0, 999, "millisecond"); }; /** * Validates the number is within an acceptable range for seconds [0-59]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateSecond = function (value) { return validate(value, 0, 59, "second"); }; /** * Validates the number is within an acceptable range for minutes [0-59]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateMinute = function (value) { return validate(value, 0, 59, "minute"); }; /** * Validates the number is within an acceptable range for hours [0-23]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateHour = function (value) { return validate(value, 0, 23, "hour"); }; /** * Validates the number is within an acceptable range for the days in a month [0-MaxDaysInMonth]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateDay = function (value, year, month) { if (year === undefined || year === null || month === undefined || month === null) { return false;} return validate(value, 1, $D.getDaysInMonth(year, month), "day"); }; /** * Validates the number is within an acceptable range for months [0-11]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateWeek = function (value) { return validate(value, 0, 53, "week"); }; /** * Validates the number is within an acceptable range for months [0-11]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateMonth = function (value) { return validate(value, 0, 11, "month"); }; /** * Validates the number is within an acceptable range for years. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateYear = function (value) { /** * Per ECMAScript spec the range of times supported by Date objects is * exactly -100,000,000 days to +100,000,000 days measured relative to * midnight at the beginning of 01 January, 1970 UTC. * This gives a range of 8,640,000,000,000,000 milliseconds to either * side of 01 January, 1970 UTC. * * Earliest possible date: Tue, 20 Apr 271,822 B.C. 00:00:00 UTC * Latest possible date: Sat, 13 Sep 275,760 00:00:00 UTC */ return validate(value, -271822, 275760, "year"); }; $D.validateTimezone = function(value) { var timezones = {"ACDT":1,"ACST":1,"ACT":1,"ADT":1,"AEDT":1,"AEST":1,"AFT":1,"AKDT":1,"AKST":1,"AMST":1,"AMT":1,"ART":1,"AST":1,"AWDT":1,"AWST":1,"AZOST":1,"AZT":1,"BDT":1,"BIOT":1,"BIT":1,"BOT":1,"BRT":1,"BST":1,"BTT":1,"CAT":1,"CCT":1,"CDT":1,"CEDT":1,"CEST":1,"CET":1,"CHADT":1,"CHAST":1,"CHOT":1,"ChST":1,"CHUT":1,"CIST":1,"CIT":1,"CKT":1,"CLST":1,"CLT":1,"COST":1,"COT":1,"CST":1,"CT":1,"CVT":1,"CWST":1,"CXT":1,"DAVT":1,"DDUT":1,"DFT":1,"EASST":1,"EAST":1,"EAT":1,"ECT":1,"EDT":1,"EEDT":1,"EEST":1,"EET":1,"EGST":1,"EGT":1,"EIT":1,"EST":1,"FET":1,"FJT":1,"FKST":1,"FKT":1,"FNT":1,"GALT":1,"GAMT":1,"GET":1,"GFT":1,"GILT":1,"GIT":1,"GMT":1,"GST":1,"GYT":1,"HADT":1,"HAEC":1,"HAST":1,"HKT":1,"HMT":1,"HOVT":1,"HST":1,"ICT":1,"IDT":1,"IOT":1,"IRDT":1,"IRKT":1,"IRST":1,"IST":1,"JST":1,"KGT":1,"KOST":1,"KRAT":1,"KST":1,"LHST":1,"LINT":1,"MAGT":1,"MART":1,"MAWT":1,"MDT":1,"MET":1,"MEST":1,"MHT":1,"MIST":1,"MIT":1,"MMT":1,"MSK":1,"MST":1,"MUT":1,"MVT":1,"MYT":1,"NCT":1,"NDT":1,"NFT":1,"NPT":1,"NST":1,"NT":1,"NUT":1,"NZDT":1,"NZST":1,"OMST":1,"ORAT":1,"PDT":1,"PET":1,"PETT":1,"PGT":1,"PHOT":1,"PHT":1,"PKT":1,"PMDT":1,"PMST":1,"PONT":1,"PST":1,"PYST":1,"PYT":1,"RET":1,"ROTT":1,"SAKT":1,"SAMT":1,"SAST":1,"SBT":1,"SCT":1,"SGT":1,"SLST":1,"SRT":1,"SST":1,"SYOT":1,"TAHT":1,"THA":1,"TFT":1,"TJT":1,"TKT":1,"TLT":1,"TMT":1,"TOT":1,"TVT":1,"UCT":1,"ULAT":1,"UTC":1,"UYST":1,"UYT":1,"UZT":1,"VET":1,"VLAT":1,"VOLT":1,"VOST":1,"VUT":1,"WAKT":1,"WAST":1,"WAT":1,"WEDT":1,"WEST":1,"WET":1,"WST":1,"YAKT":1,"YEKT":1,"Z":1}; return (timezones[value] === 1); }; $D.validateTimezoneOffset= function(value) { // timezones go from +14hrs to -12hrs, the +X hours are negative offsets. return (value > -841 && value < 721); }; }()); (function () { var $D = Date, $P = $D.prototype, p = function (s, l) { if (!l) { l = 2; } return ("000" + s).slice(l * -1); }; var validateConfigObject = function (obj) { var result = {}, self = this, prop, testFunc; testFunc = function (prop, func, value) { if (prop === "day") { var month = (obj.month !== undefined) ? obj.month : self.getMonth(); var year = (obj.year !== undefined) ? obj.year : self.getFullYear(); return $D[func](value, year, month); } else { return $D[func](value); } }; for (prop in obj) { if (Object.prototype.hasOwnProperty.call(obj, prop)) { var func = "validate" + prop.charAt(0).toUpperCase() + prop.slice(1); if ($D[func] && obj[prop] !== null && testFunc(prop, func, obj[prop])) { result[prop] = obj[prop]; } } } return result; }; /** * Resets the time of this Date object to 12:00 AM (00:00), which is the start of the day. * @param {Boolean} .clone() this date instance before clearing Time * @return {Date} this */ $P.clearTime = function () { this.setHours(0); this.setMinutes(0); this.setSeconds(0); this.setMilliseconds(0); return this; }; /** * Resets the time of this Date object to the current time ('now'). * @return {Date} this */ $P.setTimeToNow = function () { var n = new Date(); this.setHours(n.getHours()); this.setMinutes(n.getMinutes()); this.setSeconds(n.getSeconds()); this.setMilliseconds(n.getMilliseconds()); return this; }; /** * Returns a new Date object that is an exact date and time copy of the original instance. * @return {Date} A new Date instance */ $P.clone = function () { return new Date(this.getTime()); }; /** * Compares this instance to a Date object and returns an number indication of their relative values. * @param {Date} Date object to compare [Required] * @return {Number} -1 = this is lessthan date. 0 = values are equal. 1 = this is greaterthan date. */ $P.compareTo = function (date) { return Date.compare(this, date); }; /** * Compares this instance to another Date object and returns true if they are equal. * @param {Date} Date object to compare. If no date to compare, new Date() [now] is used. * @return {Boolean} true if dates are equal. false if they are not equal. */ $P.equals = function (date) { return Date.equals(this, (date !== undefined ? date : new Date())); }; /** * Determines if this instance is between a range of two dates or equal to either the start or end dates. * @param {Date} Start of range [Required] * @param {Date} End of range [Required] * @return {Boolean} true is this is between or equal to the start and end dates, else false */ $P.between = function (start, end) { return this.getTime() >= start.getTime() && this.getTime() <= end.getTime(); }; /** * Determines if this date occurs after the date to compare to. * @param {Date} Date object to compare. If no date to compare, new Date() ("now") is used. * @return {Boolean} true if this date instance is greater than the date to compare to (or "now"), otherwise false. */ $P.isAfter = function (date) { return this.compareTo(date || new Date()) === 1; }; /** * Determines if this date occurs before the date to compare to. * @param {Date} Date object to compare. If no date to compare, new Date() ("now") is used. * @return {Boolean} true if this date instance is less than the date to compare to (or "now"). */ $P.isBefore = function (date) { return (this.compareTo(date || new Date()) === -1); }; /** * Determines if the current Date instance occurs today. * @return {Boolean} true if this date instance is 'today', otherwise false. */ /** * Determines if the current Date instance occurs on the same Date as the supplied 'date'. * If no 'date' to compare to is provided, the current Date instance is compared to 'today'. * @param {date} Date object to compare. If no date to compare, the current Date ("now") is used. * @return {Boolean} true if this Date instance occurs on the same Day as the supplied 'date'. */ $P.isToday = $P.isSameDay = function (date) { return this.clone().clearTime().equals((date || new Date()).clone().clearTime()); }; /** * Adds the specified number of milliseconds to this instance. * @param {Number} The number of milliseconds to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addMilliseconds = function (value) { if (!value) { return this; } this.setTime(this.getTime() + value * 1); return this; }; /** * Adds the specified number of seconds to this instance. * @param {Number} The number of seconds to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addSeconds = function (value) { if (!value) { return this; } return this.addMilliseconds(value * 1000); }; /** * Adds the specified number of seconds to this instance. * @param {Number} The number of seconds to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addMinutes = function (value) { if (!value) { return this; } return this.addMilliseconds(value * 60000); // 60*1000 }; /** * Adds the specified number of hours to this instance. * @param {Number} The number of hours to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addHours = function (value) { if (!value) { return this; } return this.addMilliseconds(value * 3600000); // 60*60*1000 }; /** * Adds the specified number of days to this instance. * @param {Number} The number of days to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addDays = function (value) { if (!value) { return this; } this.setDate(this.getDate() + value * 1); return this; }; /** * Adds the specified number of weekdays (ie - not sat or sun) to this instance. * @param {Number} The number of days to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addWeekdays = function (value) { if (!value) { return this; } var day = this.getDay(); var weeks = (Math.ceil(Math.abs(value)/7)); if (day === 0 || day === 6) { if (value > 0) { this.next().monday(); this.addDays(-1); day = this.getDay(); } } if (value < 0) { while (value < 0) { this.addDays(-1); day = this.getDay(); if (day !== 0 && day !== 6) { value++; } } return this; } else if (value > 5 || (6-day) <= value) { value = value + (weeks * 2); } return this.addDays(value); }; /** * Adds the specified number of weeks to this instance. * @param {Number} The number of weeks to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addWeeks = function (value) { if (!value) { return this; } return this.addDays(value * 7); }; /** * Adds the specified number of months to this instance. * @param {Number} The number of months to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addMonths = function (value) { if (!value) { return this; } var n = this.getDate(); this.setDate(1); this.setMonth(this.getMonth() + value * 1); this.setDate(Math.min(n, $D.getDaysInMonth(this.getFullYear(), this.getMonth()))); return this; }; $P.addQuarters = function (value) { if (!value) { return this; } // note this will take you to the same point in the quarter as you are now. // i.e. - if you are 15 days into the quarter you'll be 15 days into the resulting one. // bonus: this allows adding fractional quarters return this.addMonths(value * 3); }; /** * Adds the specified number of years to this instance. * @param {Number} The number of years to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addYears = function (value) { if (!value) { return this; } return this.addMonths(value * 12); }; /** * Adds (or subtracts) to the value of the years, months, weeks, days, hours, minutes, seconds, milliseconds of the date instance using given configuration object. Positive and Negative values allowed. * Example

	Date.today().add( { days: 1, months: 1 } )

	new Date().add( { years: -1 } )
	
* @param {Object} Configuration object containing attributes (months, days, etc.) * @return {Date} this */ $P.add = function (config) { if (typeof config === "number") { this._orient = config; return this; } var x = config; if (x.day) { // If we should be a different date than today (eg: for 'tomorrow -1d', etc). // Should only effect parsing, not direct usage (eg, Finish and FinishExact) if ((x.day - this.getDate()) !== 0) { this.setDate(x.day); } } if (x.milliseconds) { this.addMilliseconds(x.milliseconds); } if (x.seconds) { this.addSeconds(x.seconds); } if (x.minutes) { this.addMinutes(x.minutes); } if (x.hours) { this.addHours(x.hours); } if (x.weeks) { this.addWeeks(x.weeks); } if (x.months) { this.addMonths(x.months); } if (x.years) { this.addYears(x.years); } if (x.days) { this.addDays(x.days); } return this; }; /** * Get the week number. Week one (1) is the week which contains the first Thursday of the year. Monday is considered the first day of the week. * The .getWeek() function does NOT convert the date to UTC. The local datetime is used. * Please use .getISOWeek() to get the week of the UTC converted date. * @return {Number} 1 to 53 */ $P.getWeek = function (utc) { // Create a copy of this date object var self, target = new Date(this.valueOf()); if (utc) { target.addMinutes(target.getTimezoneOffset()); self = target.clone(); } else { self = this; } // ISO week date weeks start on monday // so correct the day number var dayNr = (self.getDay() + 6) % 7; // ISO 8601 states that week 1 is the week // with the first thursday of that year. // Set the target date to the thursday in the target week target.setDate(target.getDate() - dayNr + 3); // Store the millisecond value of the target date var firstThursday = target.valueOf(); // Set the target to the first thursday of the year // First set the target to january first target.setMonth(0, 1); // Not a thursday? Correct the date to the next thursday if (target.getDay() !== 4) { target.setMonth(0, 1 + ((4 - target.getDay()) + 7) % 7); } // The weeknumber is the number of weeks between the // first thursday of the year and the thursday in the target week return 1 + Math.ceil((firstThursday - target) / 604800000); // 604800000 = 7 * 24 * 3600 * 1000 }; /** * Get the ISO 8601 week number. Week one ("01") is the week which contains the first Thursday of the year. Monday is considered the first day of the week. * The .getISOWeek() function does convert the date to it's UTC value. Please use .getWeek() to get the week of the local date. * @return {String} "01" to "53" */ $P.getISOWeek = function () { return p(this.getWeek(true)); }; /** * Moves the date to Monday of the week set. Week one (1) is the week which contains the first Thursday of the year. * @param {Number} A Number (1 to 53) that represents the week of the year. * @return {Date} this */ $P.setWeek = function (n) { if ((n - this.getWeek()) === 0) { if (this.getDay() !== 1) { return this.moveToDayOfWeek(1, (this.getDay() > 1 ? -1 : 1)); } else { return this; } } else { return this.moveToDayOfWeek(1, (this.getDay() > 1 ? -1 : 1)).addWeeks(n - this.getWeek()); } }; $P.setQuarter = function (qtr) { var month = Math.abs(((qtr-1) * 3) + 1); return this.setMonth(month, 1); }; $P.getQuarter = function () { return Date.getQuarter(this); }; $P.getDaysLeftInQuarter = function () { return Date.getDaysLeftInQuarter(this); }; /** * Moves the date to the next n'th occurrence of the dayOfWeek starting from the beginning of the month. The number (-1) is a magic number and will return the last occurrence of the dayOfWeek in the month. * @param {Number} The dayOfWeek to move to * @param {Number} The n'th occurrence to move to. Use (-1) to return the last occurrence in the month * @return {Date} this */ $P.moveToNthOccurrence = function (dayOfWeek, occurrence) { if (dayOfWeek === "Weekday") { if (occurrence > 0) { this.moveToFirstDayOfMonth(); if (this.is().weekday()) { occurrence -= 1; } } else if (occurrence < 0) { this.moveToLastDayOfMonth(); if (this.is().weekday()) { occurrence += 1; } } else { return this; } return this.addWeekdays(occurrence); } var shift = 0; if (occurrence > 0) { shift = occurrence - 1; } else if (occurrence === -1) { this.moveToLastDayOfMonth(); if (this.getDay() !== dayOfWeek) { this.moveToDayOfWeek(dayOfWeek, -1); } return this; } return this.moveToFirstDayOfMonth().addDays(-1).moveToDayOfWeek(dayOfWeek, +1).addWeeks(shift); }; var moveToN = function (getFunc, addFunc, nVal) { return function (value, orient) { var diff = (value - this[getFunc]() + nVal * (orient || +1)) % nVal; return this[addFunc]((diff === 0) ? diff += nVal * (orient || +1) : diff); }; }; /** * Move to the next or last dayOfWeek based on the orient value. * @param {Number} The dayOfWeek to move to * @param {Number} Forward (+1) or Back (-1). Defaults to +1. [Optional] * @return {Date} this */ $P.moveToDayOfWeek = moveToN("getDay", "addDays", 7); /** * Move to the next or last month based on the orient value. * @param {Number} The month to move to. 0 = January, 11 = December * @param {Number} Forward (+1) or Back (-1). Defaults to +1. [Optional] * @return {Date} this */ $P.moveToMonth = moveToN("getMonth", "addMonths", 12); /** * Get the Ordinate of the current day ("th", "st", "rd"). * @return {String} */ $P.getOrdinate = function () { var num = this.getDate(); return ord(num); }; /** * Get the Ordinal day (numeric day number) of the year, adjusted for leap year. * @return {Number} 1 through 365 (366 in leap years) */ $P.getOrdinalNumber = function () { return Math.ceil((this.clone().clearTime() - new Date(this.getFullYear(), 0, 1)) / 86400000) + 1; }; /** * Get the time zone abbreviation of the current date. * @return {String} The abbreviated time zone name (e.g. "EST") */ $P.getTimezone = function () { return $D.getTimezoneAbbreviation(this.getUTCOffset(), this.isDaylightSavingTime()); }; $P.setTimezoneOffset = function (offset) { var here = this.getTimezoneOffset(), there = Number(offset) * -6 / 10; return (there || there === 0) ? this.addMinutes(there - here) : this; }; $P.setTimezone = function (offset) { return this.setTimezoneOffset($D.getTimezoneOffset(offset)); }; /** * Indicates whether Daylight Saving Time is observed in the current time zone. * @return {Boolean} true|false */ $P.hasDaylightSavingTime = function () { return (Date.today().set({month: 0, day: 1}).getTimezoneOffset() !== Date.today().set({month: 6, day: 1}).getTimezoneOffset()); }; /** * Indicates whether this Date instance is within the Daylight Saving Time range for the current time zone. * @return {Boolean} true|false */ $P.isDaylightSavingTime = function () { return Date.today().set({month: 0, day: 1}).getTimezoneOffset() !== this.getTimezoneOffset(); }; /** * Get the offset from UTC of the current date. * @return {String} The 4-character offset string prefixed with + or - (e.g. "-0500") */ $P.getUTCOffset = function (offset) { var n = (offset || this.getTimezoneOffset()) * -10 / 6, r; if (n < 0) { r = (n - 10000).toString(); return r.charAt(0) + r.substr(2); } else { r = (n + 10000).toString(); return "+" + r.substr(1); } }; /** * Returns the number of milliseconds between this date and date. * @param {Date} Defaults to now * @return {Number} The diff in milliseconds */ $P.getElapsed = function (date) { return (date || new Date()) - this; }; /** * Set the value of year, month, day, hour, minute, second, millisecond of date instance using given configuration object. * Example

	Date.today().set( { day: 20, month: 1 } )

	new Date().set( { millisecond: 0 } )
	
* * @param {Object} Configuration object containing attributes (month, day, etc.) * @return {Date} this */ $P.set = function (config) { config = validateConfigObject.call(this, config); var key; for (key in config) { if (Object.prototype.hasOwnProperty.call(config, key)) { var name = key.charAt(0).toUpperCase() + key.slice(1); var addFunc, getFunc; if (key !== "week" && key !== "month" && key !== "timezone" && key !== "timezoneOffset") { name += "s"; } addFunc = "add" + name; getFunc = "get" + name; if (key === "month") { addFunc = addFunc + "s"; } else if (key === "year"){ getFunc = "getFullYear"; } if (key !== "day" && key !== "timezone" && key !== "timezoneOffset" && key !== "week" && key !== "hour") { this[addFunc](config[key] - this[getFunc]()); } else if ( key === "timezone"|| key === "timezoneOffset" || key === "week" || key === "hour") { this["set"+name](config[key]); } } } // day has to go last because you can't validate the day without first knowing the month if (config.day) { this.addDays(config.day - this.getDate()); } return this; }; /** * Moves the date to the first day of the month. * @return {Date} this */ $P.moveToFirstDayOfMonth = function () { return this.set({ day: 1 }); }; /** * Moves the date to the last day of the month. * @return {Date} this */ $P.moveToLastDayOfMonth = function () { return this.set({ day: $D.getDaysInMonth(this.getFullYear(), this.getMonth())}); }; /** * Converts the value of the current Date object to its equivalent string representation. * Format Specifiers * CUSTOM DATE AND TIME FORMAT STRINGS * Format Description Example * ------ --------------------------------------------------------------------------- ----------------------- * s The seconds of the minute between 0-59. "0" to "59" * ss The seconds of the minute with leading zero if required. "00" to "59" * * m The minute of the hour between 0-59. "0" or "59" * mm The minute of the hour with leading zero if required. "00" or "59" * * h The hour of the day between 1-12. "1" to "12" * hh The hour of the day with leading zero if required. "01" to "12" * * H The hour of the day between 0-23. "0" to "23" * HH The hour of the day with leading zero if required. "00" to "23" * * d The day of the month between 1 and 31. "1" to "31" * dd The day of the month with leading zero if required. "01" to "31" * ddd Abbreviated day name. Date.CultureInfo.abbreviatedDayNames. "Mon" to "Sun" * dddd The full day name. Date.CultureInfo.dayNames. "Monday" to "Sunday" * * M The month of the year between 1-12. "1" to "12" * MM The month of the year with leading zero if required. "01" to "12" * MMM Abbreviated month name. Date.CultureInfo.abbreviatedMonthNames. "Jan" to "Dec" * MMMM The full month name. Date.CultureInfo.monthNames. "January" to "December" * * yy The year as a two-digit number. "99" or "08" * yyyy The full four digit year. "1999" or "2008" * * t Displays the first character of the A.M./P.M. designator. "A" or "P" * Date.CultureInfo.amDesignator or Date.CultureInfo.pmDesignator * tt Displays the A.M./P.M. designator. "AM" or "PM" * Date.CultureInfo.amDesignator or Date.CultureInfo.pmDesignator * * S The ordinal suffix ("st, "nd", "rd" or "th") of the current day. "st, "nd", "rd" or "th" * * STANDARD DATE AND TIME FORMAT STRINGS * Format Description Example *------ --------------------------------------------------------------------------- ----------------------- * d The CultureInfo shortDate Format Pattern "M/d/yyyy" * D The CultureInfo longDate Format Pattern "dddd, MMMM dd, yyyy" * F The CultureInfo fullDateTime Format Pattern "dddd, MMMM dd, yyyy h:mm:ss tt" * m The CultureInfo monthDay Format Pattern "MMMM dd" * r The CultureInfo rfc1123 Format Pattern "ddd, dd MMM yyyy HH:mm:ss GMT" * s The CultureInfo sortableDateTime Format Pattern "yyyy-MM-ddTHH:mm:ss" * t The CultureInfo shortTime Format Pattern "h:mm tt" * T The CultureInfo longTime Format Pattern "h:mm:ss tt" * u The CultureInfo universalSortableDateTime Format Pattern "yyyy-MM-dd HH:mm:ssZ" * y The CultureInfo yearMonth Format Pattern "MMMM, yyyy" * * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @return {String} A string representation of the current Date object. */ var ord = function (n) { switch (n * 1) { case 1: case 21: case 31: return "st"; case 2: case 22: return "nd"; case 3: case 23: return "rd"; default: return "th"; } }; var parseStandardFormats = function (format) { var y, c = Date.CultureInfo.formatPatterns; switch (format) { case "d": return this.toString(c.shortDate); case "D": return this.toString(c.longDate); case "F": return this.toString(c.fullDateTime); case "m": return this.toString(c.monthDay); case "r": case "R": y = this.clone().addMinutes(this.getTimezoneOffset()); return y.toString(c.rfc1123) + " GMT"; case "s": return this.toString(c.sortableDateTime); case "t": return this.toString(c.shortTime); case "T": return this.toString(c.longTime); case "u": y = this.clone().addMinutes(this.getTimezoneOffset()); return y.toString(c.universalSortableDateTime); case "y": return this.toString(c.yearMonth); default: return false; } }; var parseFormatStringsClosure = function (context) { return function (m) { if (m.charAt(0) === "\\") { return m.replace("\\", ""); } switch (m) { case "hh": return p(context.getHours() < 13 ? (context.getHours() === 0 ? 12 : context.getHours()) : (context.getHours() - 12)); case "h": return context.getHours() < 13 ? (context.getHours() === 0 ? 12 : context.getHours()) : (context.getHours() - 12); case "HH": return p(context.getHours()); case "H": return context.getHours(); case "mm": return p(context.getMinutes()); case "m": return context.getMinutes(); case "ss": return p(context.getSeconds()); case "s": return context.getSeconds(); case "yyyy": return p(context.getFullYear(), 4); case "yy": return p(context.getFullYear()); case "y": return context.getFullYear(); case "E": case "dddd": return Date.CultureInfo.dayNames[context.getDay()]; case "ddd": return Date.CultureInfo.abbreviatedDayNames[context.getDay()]; case "dd": return p(context.getDate()); case "d": return context.getDate(); case "MMMM": return Date.CultureInfo.monthNames[context.getMonth()]; case "MMM": return Date.CultureInfo.abbreviatedMonthNames[context.getMonth()]; case "MM": return p((context.getMonth() + 1)); case "M": return context.getMonth() + 1; case "t": return context.getHours() < 12 ? Date.CultureInfo.amDesignator.substring(0, 1) : Date.CultureInfo.pmDesignator.substring(0, 1); case "tt": return context.getHours() < 12 ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator; case "S": return ord(context.getDate()); case "W": return context.getWeek(); case "WW": return context.getISOWeek(); case "Q": return "Q" + context.getQuarter(); case "q": return String(context.getQuarter()); case "z": return context.getTimezone(); case "Z": case "X": return Date.getTimezoneOffset(context.getTimezone()); case "ZZ": // Timezone offset in seconds return context.getTimezoneOffset() * -60; case "u": return context.getDay(); case "L": return ($D.isLeapYear(context.getFullYear())) ? 1 : 0; case "B": // Swatch Internet Time (.beats) return "@"+((context.getUTCSeconds() + (context.getUTCMinutes()*60) + ((context.getUTCHours()+1)*3600))/86.4); default: return m; } }; }; $P.toString = function (format, ignoreStandards) { // Standard Date and Time Format Strings. Formats pulled from CultureInfo file and // may vary by culture. if (!ignoreStandards && format && format.length === 1) { output = parseStandardFormats.call(this, format); if (output) { return output; } } var parseFormatStrings = parseFormatStringsClosure(this); return format ? format.replace(/((\\)?(dd?d?d?|MM?M?M?|yy?y?y?|hh?|HH?|mm?|ss?|tt?|S|q|Q|WW?W?W?)(?![^\[]*\]))/g, parseFormatStrings).replace(/\[|\]/g, "") : this._toString(); }; }()); /************************************************************* * SugarPak - Domain Specific Language - Syntactical Sugar * *************************************************************/ (function () { var $D = Date, $P = $D.prototype, $N = Number.prototype; // private $P._orient = +1; // private $P._nth = null; // private $P._is = false; // private $P._same = false; // private $P._isSecond = false; // private $N._dateElement = "days"; /** * Moves the date to the next instance of a date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.today().next().friday();
	Date.today().next().fri();
	Date.today().next().march();
	Date.today().next().mar();
	Date.today().next().week();
	
* * @return {Date} date */ $P.next = function () { this._move = true; this._orient = +1; return this; }; /** * Creates a new Date (Date.today()) and moves the date to the next instance of the date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.next().friday();
	Date.next().fri();
	Date.next().march();
	Date.next().mar();
	Date.next().week();
	
* * @return {Date} date */ $D.next = function () { return $D.today().next(); }; /** * Moves the date to the previous instance of a date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.today().last().friday();
	Date.today().last().fri();
	Date.today().last().march();
	Date.today().last().mar();
	Date.today().last().week();
	
* * @return {Date} date */ $P.last = $P.prev = $P.previous = function () { this._move = true; this._orient = -1; return this; }; /** * Creates a new Date (Date.today()) and moves the date to the previous instance of the date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.last().friday();
	Date.last().fri();
	Date.previous().march();
	Date.prev().mar();
	Date.last().week();
	
* * @return {Date} date */ $D.last = $D.prev = $D.previous = function () { return $D.today().last(); }; /** * Performs a equality check when followed by either a month name, day name or .weekday() function. * Example

	Date.today().is().friday(); // true|false
	Date.today().is().fri();
	Date.today().is().march();
	Date.today().is().mar();
	
* * @return {Boolean} true|false */ $P.is = function () { this._is = true; return this; }; /** * Determines if two date objects occur on/in exactly the same instance of the subsequent date part function. * The function .same() must be followed by a date part function (example: .day(), .month(), .year(), etc). * * An optional Date can be passed in the date part function. If now date is passed as a parameter, 'Now' is used. * * The following example demonstrates how to determine if two dates fall on the exact same day. * * Example

	var d1 = Date.today(); // today at 00:00
	var d2 = new Date();   // exactly now.

	// Do they occur on the same day?
	d1.same().day(d2); // true
	
	// Do they occur on the same hour?
	d1.same().hour(d2); // false, unless d2 hour is '00' (midnight).
	
	// What if it's the same day, but one year apart?
	var nextYear = Date.today().add(1).year();

	d1.same().day(nextYear); // false, because the dates must occur on the exact same day. 
	
* * Scenario: Determine if a given date occurs during some week period 2 months from now. * * Example

	var future = Date.today().add(2).months();
	return someDate.same().week(future); // true|false;
	
* * @return {Boolean} true|false */ $P.same = function () { this._same = true; this._isSecond = false; return this; }; /** * Determines if the current date/time occurs during Today. Must be preceded by the .is() function. * Example

	someDate.is().today();    // true|false
	new Date().is().today();  // true
	Date.today().is().today();// true
	Date.today().add(-1).day().is().today(); // false
	
* * @return {Boolean} true|false */ $P.today = function () { return this.same().day(); }; /** * Determines if the current date is a weekday. This function must be preceded by the .is() function. * Example

	Date.today().is().weekday(); // true|false
	
* * @return {Boolean} true|false */ $P.weekday = function () { if (this._nth) { return df("Weekday").call(this); } if (this._move) { return this.addWeekdays(this._orient); } if (this._is) { this._is = false; return (!this.is().sat() && !this.is().sun()); } return false; }; /** * Determines if the current date is on the weekend. This function must be preceded by the .is() function. * Example

	Date.today().is().weekend(); // true|false
	
* * @return {Boolean} true|false */ $P.weekend = function () { if (this._is) { this._is = false; return (this.is().sat() || this.is().sun()); } return false; }; /** * Sets the Time of the current Date instance. A string "6:15 pm" or config object {hour:18, minute:15} are accepted. * Example

	// Set time to 6:15pm with a String
	Date.today().at("6:15pm");

	// Set time to 6:15pm with a config object
	Date.today().at({hour:18, minute:15});
	
* * @return {Date} date */ $P.at = function (time) { return (typeof time === "string") ? $D.parse(this.toString("d") + " " + time) : this.set(time); }; /** * Creates a new Date() and adds this (Number) to the date based on the preceding date element function (eg. second|minute|hour|day|month|year). * Example

	// Undeclared Numbers must be wrapped with parentheses. Requirment of JavaScript.
	(3).days().fromNow();
	(6).months().fromNow();

	// Declared Number variables do not require parentheses. 
	var n = 6;
	n.months().fromNow();
	
* * @return {Date} A new Date instance */ $N.fromNow = $N.after = function (date) { var c = {}; c[this._dateElement] = this; return ((!date) ? new Date() : date.clone()).add(c); }; /** * Creates a new Date() and subtract this (Number) from the date based on the preceding date element function (eg. second|minute|hour|day|month|year). * Example

	// Undeclared Numbers must be wrapped with parentheses. Requirment of JavaScript.
	(3).days().ago();
	(6).months().ago();

	// Declared Number variables do not require parentheses. 
	var n = 6;
	n.months().ago();
	
* * @return {Date} A new Date instance */ $N.ago = $N.before = function (date) { var c = {}, s = (this._dateElement[this._dateElement.length-1] !== "s") ? this._dateElement + "s" : this._dateElement; c[s] = this * -1; return ((!date) ? new Date() : date.clone()).add(c); }; // Do NOT modify the following string tokens. These tokens are used to build dynamic functions. // All culture-specific strings can be found in the CultureInfo files. var dx = ("sunday monday tuesday wednesday thursday friday saturday").split(/\s/), mx = ("january february march april may june july august september october november december").split(/\s/), px = ("Millisecond Second Minute Hour Day Week Month Year Quarter Weekday").split(/\s/), pxf = ("Milliseconds Seconds Minutes Hours Date Week Month FullYear Quarter").split(/\s/), nth = ("final first second third fourth fifth").split(/\s/), de; /** * Returns an object literal of all the date parts. * Example

	var o = new Date().toObject();
	
	// { year: 2008, month: 4, week: 20, day: 13, hour: 18, minute: 9, second: 32, millisecond: 812 }
	
	// The object properties can be referenced directly from the object.
	
	alert(o.day);  // alerts "13"
	alert(o.year); // alerts "2008"
	
* * @return {Date} An object literal representing the original date object. */ $P.toObject = function () { var o = {}; for (var i = 0; i < px.length; i++) { if (this["get" + pxf[i]]) { o[px[i].toLowerCase()] = this["get" + pxf[i]](); } } return o; }; /** * Returns a date created from an object literal. Ignores the .week property if set in the config. * Example

	var o = new Date().toObject();
	
	return Date.fromObject(o); // will return the same date. 

	var o2 = {month: 1, day: 20, hour: 18}; // birthday party!
	Date.fromObject(o2);
	
* * @return {Date} An object literal representing the original date object. */ $D.fromObject = function(config) { config.week = null; return Date.today().set(config); }; // Create day name functions and abbreviated day name functions (eg. monday(), friday(), fri()). var df = function (n) { return function () { if (this._is) { this._is = false; return this.getDay() === n; } if (this._move) { this._move = null; } if (this._nth !== null) { // If the .second() function was called earlier, remove the _orient // from the date, and then continue. // This is required because 'second' can be used in two different context. // // Example // // Date.today().add(1).second(); // Date.march().second().monday(); // // Things get crazy with the following... // Date.march().add(1).second().second().monday(); // but it works!! // if (this._isSecond) { this.addSeconds(this._orient * -1); } // make sure we reset _isSecond this._isSecond = false; var ntemp = this._nth; this._nth = null; var temp = this.clone().moveToLastDayOfMonth(); this.moveToNthOccurrence(n, ntemp); if (this > temp) { throw new RangeError($D.getDayName(n) + " does not occur " + ntemp + " times in the month of " + $D.getMonthName(temp.getMonth()) + " " + temp.getFullYear() + "."); } return this; } return this.moveToDayOfWeek(n, this._orient); }; }; var sdf = function (n) { return function () { var t = $D.today(), shift = n - t.getDay(); if (n === 0 && Date.CultureInfo.firstDayOfWeek === 1 && t.getDay() !== 0) { shift = shift + 7; } return t.addDays(shift); }; }; // Create month name functions and abbreviated month name functions (eg. january(), march(), mar()). var month_instance_functions = function (n) { return function () { if (this._is) { this._is = false; return this.getMonth() === n; } return this.moveToMonth(n, this._orient); }; }; var month_static_functions = function (n) { return function () { return $D.today().set({ month: n, day: 1 }); }; }; var processTerms = function (names, staticFunc, instanceFunc) { for (var i = 0; i < names.length; i++) { // Create constant static Name variables. $D[names[i].toUpperCase()] = $D[names[i].toUpperCase().substring(0, 3)] = i; // Create Name functions. $D[names[i]] = $D[names[i].substring(0, 3)] = staticFunc(i); // Create Name instance functions. $P[names[i]] = $P[names[i].substring(0, 3)] = instanceFunc(i); } }; processTerms(dx, sdf, df); processTerms(mx, month_static_functions, month_instance_functions); // Create date element functions and plural date element functions used with Date (eg. day(), days(), months()). var ef = function (j) { return function () { // if the .second() function was called earlier, the _orient // has alread been added. Just return this and reset _isSecond. if (this._isSecond) { this._isSecond = false; return this; } if (this._same) { this._same = this._is = false; var o1 = this.toObject(), o2 = (arguments[0] || new Date()).toObject(), v = "", k = j.toLowerCase(); // the substr trick with -1 doesn't work in IE8 or less k = (k[k.length-1] === "s") ? k.substring(0,k.length-1) : k; for (var m = (px.length - 1); m > -1; m--) { v = px[m].toLowerCase(); if (o1[v] !== o2[v]) { return false; } if (k === v) { break; } } return true; } if (j.substring(j.length - 1) !== "s") { j += "s"; } if (this._move) { this._move = null; } return this["add" + j](this._orient); }; }; var nf = function (n) { return function () { this._dateElement = n; return this; }; }; for (var k = 0; k < px.length; k++) { de = px[k].toLowerCase(); if(de !== "weekday") { // Create date element functions and plural date element functions used with Date (eg. day(), days(), months()). $P[de] = $P[de + "s"] = ef(px[k]); // Create date element functions and plural date element functions used with Number (eg. day(), days(), months()). $N[de] = $N[de + "s"] = nf(de + "s"); } } $P._ss = ef("Second"); var nthfn = function (n) { return function (dayOfWeek) { if (this._same) { return this._ss(arguments[0]); } if (dayOfWeek || dayOfWeek === 0) { return this.moveToNthOccurrence(dayOfWeek, n); } this._nth = n; // if the operator is 'second' add the _orient, then deal with it later... if (n === 2 && (dayOfWeek === undefined || dayOfWeek === null)) { this._isSecond = true; return this.addSeconds(this._orient); } return this; }; }; for (var l = 0; l < nth.length; l++) { $P[nth[l]] = (l === 0) ? nthfn(-1) : nthfn(l); } }()); (function () { "use strict"; Date.Parsing = { Exception: function (s) { this.message = "Parse error at '" + s.substring(0, 10) + " ...'"; } }; var $P = Date.Parsing; var dayOffsets = { standard: [0,31,59,90,120,151,181,212,243,273,304,334], leap: [0,31,60,91,121,152,182,213,244,274,305,335] }; $P.isLeapYear = function(year) { return ((year % 4 === 0) && (year % 100 !== 0)) || (year % 400 === 0); }; var utils = { multiReplace : function (str, hash ) { var key; for (key in hash) { if (Object.prototype.hasOwnProperty.call(hash, key)) { var regex; if (typeof hash[key] === "function") { } else { regex = (hash[key] instanceof RegExp) ? hash[key] : new RegExp(hash[key], "g"); } str = str.replace(regex, key); } } return str; }, getDayOfYearFromWeek : function (obj) { var d, jan4, offset; obj.weekDay = (!obj.weekDay && obj.weekDay !== 0) ? 1 : obj.weekDay; d = new Date(obj.year, 0, 4); jan4 = d.getDay() === 0 ? 7 : d.getDay(); // JS is 0 indexed on Sunday. offset = jan4+3; obj.dayOfYear = ((obj.week * 7) + (obj.weekDay === 0 ? 7 : obj.weekDay))-offset; return obj; }, getDayOfYear : function (obj, dayOffset) { if (!obj.dayOfYear) { obj = utils.getDayOfYearFromWeek(obj); } for (var i=0;i <= dayOffset.length;i++) { if (obj.dayOfYear < dayOffset[i] || i === dayOffset.length) { obj.day = obj.day ? obj.day : (obj.dayOfYear - dayOffset[i-1]); break; } else { obj.month = i; } } return obj; }, adjustForTimeZone : function (obj, date) { var offset; if (obj.zone.toUpperCase() === "Z" || (obj.zone_hours === 0 && obj.zone_minutes === 0)) { // it's UTC/GML so work out the current timeszone offset offset = -date.getTimezoneOffset(); } else { offset = (obj.zone_hours*60) + (obj.zone_minutes || 0); if (obj.zone_sign === "+") { offset *= -1; } offset -= date.getTimezoneOffset(); } date.setMinutes(date.getMinutes()+offset); return date; }, setDefaults : function (obj) { obj.year = obj.year || Date.today().getFullYear(); obj.hours = obj.hours || 0; obj.minutes = obj.minutes || 0; obj.seconds = obj.seconds || 0; obj.milliseconds = obj.milliseconds || 0; if (!(!obj.month && (obj.week || obj.dayOfYear))) { // if we have a month, or if we don't but don't have the day calculation data obj.month = obj.month || 0; obj.day = obj.day || 1; } return obj; }, dataNum: function (data, mod, explict, postProcess) { var dataNum = data*1; if (mod) { if (postProcess) { return data ? mod(data)*1 : data; } else { return data ? mod(dataNum) : data; } } else if (!explict){ return data ? dataNum : data; } else { return (data && typeof data !== "undefined") ? dataNum : data; } }, timeDataProcess: function (obj) { var timeObj = {}; for (var x in obj.data) { if (obj.data.hasOwnProperty(x)) { timeObj[x] = obj.ignore[x] ? obj.data[x] : utils.dataNum(obj.data[x], obj.mods[x], obj.explict[x], obj.postProcess[x]); } } if (obj.data.secmins) { obj.data.secmins = obj.data.secmins.replace(",", ".") * 60; if (!timeObj.minutes) { timeObj.minutes = obj.data.secmins; } else if (!timeObj.seconds) { timeObj.seconds = obj.data.secmins; } delete obj.secmins; } return timeObj; }, buildTimeObjectFromData: function (data) { var time = utils.timeDataProcess({ data: { year : data[1], month : data[5], day : data[7], week : data[8], dayOfYear : data[10], hours : data[15], zone_hours : data[23], zone_minutes : data[24], zone : data[21], zone_sign : data[22], weekDay : data[9], minutes: data[16], seconds: data[19], milliseconds: data[20], secmins: data[18] }, mods: { month: function(data) { return data-1; }, weekDay: function (data) { data = Math.abs(data); return (data === 7 ? 0 : data); }, minutes: function (data) { return data.replace(":",""); }, seconds: function (data) { return Math.floor( (data.replace(":","").replace(",","."))*1 ); }, milliseconds: function (data) { return (data.replace(",",".")*1000); } }, postProcess: { minutes: true, seconds: true, milliseconds: true }, explict: { zone_hours: true, zone_minutes: true }, ignore: { zone: true, zone_sign: true, secmins: true } }); return time; }, addToHash: function (hash, keys, data) { keys = keys; data = data; var len = keys.length; for (var i = 0; i < len; i++) { hash[keys[i]] = data[i]; } return hash; }, combineRegex: function (r1, r2) { return new RegExp("(("+r1.source+")\\s("+r2.source+"))"); }, getDateNthString: function(add, last, inc){ if (add) { return Date.today().addDays(inc).toString("d"); } else if (last) { return Date.today().last()[inc]().toString("d"); } }, buildRegexData: function (array) { var arr = []; var len = array.length; for (var i=0; i < len; i++) { if (Object.prototype.toString.call(array[i]) === '[object Array]') { // oldIE compat version of Array.isArray arr.push(this.combineRegex(array[i][0], array[i][1])); } else { arr.push(array[i]); } } return arr; } }; $P.processTimeObject = function (obj) { var date, dayOffset; utils.setDefaults(obj); dayOffset = ($P.isLeapYear(obj.year)) ? dayOffsets.leap : dayOffsets.standard; if (!obj.month && (obj.week || obj.dayOfYear)) { utils.getDayOfYear(obj, dayOffset); } else { obj.dayOfYear = dayOffset[obj.month] + obj.day; } date = new Date(obj.year, obj.month, obj.day, obj.hours, obj.minutes, obj.seconds, obj.milliseconds); if (obj.zone) { utils.adjustForTimeZone(obj, date); // adjust (and calculate) for timezone } return date; }; $P.ISO = { regex : /^([\+-]?\d{4}(?!\d{2}\b))((-?)((0[1-9]|1[0-2])(\3([12]\d|0[1-9]|3[01]))?|W([0-4]\d|5[0-3])(-?[1-7])?|(00[1-9]|0[1-9]\d|[12]\d{2}|3([0-5]\d|6[1-6])))([T\s]((([01]\d|2[0-4])((:?)[0-5]\d)?|24\:?00)([\.,]\d+(?!:))?)?(\17[0-5]\d([\.,]\d+)?)?\s?([zZ]|([\+-])([01]\d|2[0-3]):?([0-5]\d)?)?)?)?$/, parse : function (s) { var time, data = s.match(this.regex); if (!data || !data.length) { return null; } time = utils.buildTimeObjectFromData(data); if (!time.year || (!time.year && (!time.month && !time.day) && (!time.week && !time.dayOfYear)) ) { return null; } return $P.processTimeObject(time); } }; $P.Numeric = { isNumeric: function (e){return!isNaN(parseFloat(e))&&isFinite(e);}, regex: /\b([0-1]?[0-9])([0-3]?[0-9])([0-2]?[0-9]?[0-9][0-9])\b/i, parse: function (s) { var data, i, time = {}, order = Date.CultureInfo.dateElementOrder.split(""); if (!(this.isNumeric(s)) || // if it's non-numeric OR (s[0] === "+" && s[0] === "-")) { // It's an arithmatic string (eg +/-1000) return null; } if (s.length < 5 && s.indexOf(".") < 0 && s.indexOf("/") < 0) { // assume it's just a year. time.year = s; return $P.processTimeObject(time); } data = s.match(this.regex); if (!data || !data.length) { return null; } for (i=0; i < order.length; i++) { switch(order[i]) { case "d": time.day = data[i+1]; break; case "m": time.month = (data[i+1]-1); break; case "y": time.year = data[i+1]; break; } } return $P.processTimeObject(time); } }; $P.Normalizer = { regexData: function () { var $R = Date.CultureInfo.regexPatterns; return utils.buildRegexData([ $R.tomorrow, $R.yesterday, [$R.past, $R.mon], [$R.past, $R.tue], [$R.past, $R.wed], [$R.past, $R.thu], [$R.past, $R.fri], [$R.past, $R.sat], [$R.past, $R.sun] ]); }, basicReplaceHash : function() { var $R = Date.CultureInfo.regexPatterns; return { "January": $R.jan.source, "February": $R.feb, "March": $R.mar, "April": $R.apr, "May": $R.may, "June": $R.jun, "July": $R.jul, "August": $R.aug, "September": $R.sep, "October": $R.oct, "November": $R.nov, "December": $R.dec, "": /\bat\b/gi, " ": /\s{2,}/, "am": $R.inTheMorning, "9am": $R.thisMorning, "pm": $R.inTheEvening, "7pm":$R.thisEvening }; }, keys : function(){ return [ utils.getDateNthString(true, false, 1), // tomorrow utils.getDateNthString(true, false, -1), // yesterday utils.getDateNthString(false, true, "monday"), //last mon utils.getDateNthString(false, true, "tuesday"), //last tues utils.getDateNthString(false, true, "wednesday"), //last wed utils.getDateNthString(false, true, "thursday"), //last thurs utils.getDateNthString(false, true, "friday"), //last fri utils.getDateNthString(false, true, "saturday"), //last sat utils.getDateNthString(false, true, "sunday") //last sun ]; }, buildRegexFunctions: function () { var $R = Date.CultureInfo.regexPatterns; var __ = Date.i18n.__; var tomorrowRE = new RegExp("(\\b\\d\\d?("+__("AM")+"|"+__("PM")+")? )("+$R.tomorrow.source.slice(1)+")", "i"); // adapted tomorrow regex for AM PM relative dates var todayRE = new RegExp($R.today.source + "(?!\\s*([+-]))\\b"); // today, but excludes the math operators (eg "today + 2h") this.replaceFuncs = [ [todayRE, function (full) { return (full.length > 1) ? Date.today().toString("d") : full; }], [tomorrowRE, function(full, m1) { var t = Date.today().addDays(1).toString("d"); return (t + " " + m1); }], [$R.amThisMorning, function(str, am){return am;}], [$R.pmThisEvening, function(str, pm){return pm;}] ]; }, buildReplaceData: function () { this.buildRegexFunctions(); this.replaceHash = utils.addToHash(this.basicReplaceHash(), this.keys(), this.regexData()); }, stringReplaceFuncs: function (s) { for (var i=0; i < this.replaceFuncs.length; i++) { s = s.replace(this.replaceFuncs[i][0], this.replaceFuncs[i][1]); } return s; }, parse: function (s) { s = this.stringReplaceFuncs(s); s = utils.multiReplace(s, this.replaceHash); try { var n = s.split(/([\s\-\.\,\/\x27]+)/); if (n.length === 3 && $P.Numeric.isNumeric(n[0]) && $P.Numeric.isNumeric(n[2]) && (n[2].length >= 4)) { // ok, so we're dealing with x/year. But that's not a full date. // This fixes wonky dateElementOrder parsing when set to dmy order. if (Date.CultureInfo.dateElementOrder[0] === "d") { s = "1/" + n[0] + "/" + n[2]; // set to 1st of month and normalize the seperator } } } catch (e) {} return s; } }; $P.Normalizer.buildReplaceData(); }()); (function () { var $P = Date.Parsing; var _ = $P.Operators = { // // Tokenizers // rtoken: function (r) { // regex token return function (s) { var mx = s.match(r); if (mx) { return ([ mx[0], s.substring(mx[0].length) ]); } else { throw new $P.Exception(s); } }; }, token: function () { // whitespace-eating token return function (s) { return _.rtoken(new RegExp("^\\s*" + s + "\\s*"))(s); }; }, stoken: function (s) { // string token return _.rtoken(new RegExp("^" + s)); }, // Atomic Operators until: function (p) { return function (s) { var qx = [], rx = null; while (s.length) { try { rx = p.call(this, s); } catch (e) { qx.push(rx[0]); s = rx[1]; continue; } break; } return [ qx, s ]; }; }, many: function (p) { return function (s) { var rx = [], r = null; while (s.length) { try { r = p.call(this, s); } catch (e) { return [ rx, s ]; } rx.push(r[0]); s = r[1]; } return [ rx, s ]; }; }, // generator operators -- see below optional: function (p) { return function (s) { var r = null; try { r = p.call(this, s); } catch (e) { return [ null, s ]; } return [ r[0], r[1] ]; }; }, not: function (p) { return function (s) { try { p.call(this, s); } catch (e) { return [null, s]; } throw new $P.Exception(s); }; }, ignore: function (p) { return p ? function (s) { var r = null; r = p.call(this, s); return [null, r[1]]; } : null; }, product: function () { var px = arguments[0], qx = Array.prototype.slice.call(arguments, 1), rx = []; for (var i = 0 ; i < px.length ; i++) { rx.push(_.each(px[i], qx)); } return rx; }, cache: function (rule) { var cache = {}, cache_length = 0, cache_keys = [], CACHE_MAX = Date.Config.CACHE_MAX || 100000, r = null; var cacheCheck = function () { if (cache_length === CACHE_MAX) { // kill several keys, don't want to have to do this all the time... for (var i=0; i < 10; i++) { var key = cache_keys.shift(); if (key) { delete cache[key]; cache_length--; } } } }; return function (s) { cacheCheck(); try { r = cache[s] = (cache[s] || rule.call(this, s)); } catch (e) { r = cache[s] = e; } cache_length++; cache_keys.push(s); if (r instanceof $P.Exception) { throw r; } else { return r; } }; }, // vector operators -- see below any: function () { var px = arguments; return function (s) { var r = null; for (var i = 0; i < px.length; i++) { if (px[i] == null) { continue; } try { r = (px[i].call(this, s)); } catch (e) { r = null; } if (r) { return r; } } throw new $P.Exception(s); }; }, each: function () { var px = arguments; return function (s) { var rx = [], r = null; for (var i = 0; i < px.length ; i++) { if (px[i] == null) { continue; } try { r = (px[i].call(this, s)); } catch (e) { throw new $P.Exception(s); } rx.push(r[0]); s = r[1]; } return [ rx, s]; }; }, all: function () { var px = arguments, _ = _; return _.each(_.optional(px)); }, // delimited operators sequence: function (px, d, c) { d = d || _.rtoken(/^\s*/); c = c || null; if (px.length === 1) { return px[0]; } return function (s) { var r = null, q = null; var rx = []; for (var i = 0; i < px.length ; i++) { try { r = px[i].call(this, s); } catch (e) { break; } rx.push(r[0]); try { q = d.call(this, r[1]); } catch (ex) { q = null; break; } s = q[1]; } if (!r) { throw new $P.Exception(s); } if (q) { throw new $P.Exception(q[1]); } if (c) { try { r = c.call(this, r[1]); } catch (ey) { throw new $P.Exception(r[1]); } } return [ rx, (r?r[1]:s) ]; }; }, // // Composite Operators // between: function (d1, p, d2) { d2 = d2 || d1; var _fn = _.each(_.ignore(d1), p, _.ignore(d2)); return function (s) { var rx = _fn.call(this, s); return [[rx[0][0], r[0][2]], rx[1]]; }; }, list: function (p, d, c) { d = d || _.rtoken(/^\s*/); c = c || null; return (p instanceof Array ? _.each(_.product(p.slice(0, -1), _.ignore(d)), p.slice(-1), _.ignore(c)) : _.each(_.many(_.each(p, _.ignore(d))), px, _.ignore(c))); }, set: function (px, d, c) { d = d || _.rtoken(/^\s*/); c = c || null; return function (s) { // r is the current match, best the current 'best' match // which means it parsed the most amount of input var r = null, p = null, q = null, rx = null, best = [[], s], last = false; // go through the rules in the given set for (var i = 0; i < px.length ; i++) { // last is a flag indicating whether this must be the last element // if there is only 1 element, then it MUST be the last one q = null; p = null; r = null; last = (px.length === 1); // first, we try simply to match the current pattern // if not, try the next pattern try { r = px[i].call(this, s); } catch (e) { continue; } // since we are matching against a set of elements, the first // thing to do is to add r[0] to matched elements rx = [[r[0]], r[1]]; // if we matched and there is still input to parse and // we don't already know this is the last element, // we're going to next check for the delimiter ... // if there's none, or if there's no input left to parse // than this must be the last element after all ... if (r[1].length > 0 && ! last) { try { q = d.call(this, r[1]); } catch (ex) { last = true; } } else { last = true; } // if we parsed the delimiter and now there's no more input, // that means we shouldn't have parsed the delimiter at all // so don't update r and mark this as the last element ... if (!last && q[1].length === 0) { last = true; } // so, if this isn't the last element, we're going to see if // we can get any more matches from the remaining (unmatched) // elements ... if (!last) { // build a list of the remaining rules we can match against, // i.e., all but the one we just matched against var qx = []; for (var j = 0; j < px.length ; j++) { if (i !== j) { qx.push(px[j]); } } // now invoke recursively set with the remaining input // note that we don't include the closing delimiter ... // we'll check for that ourselves at the end p = _.set(qx, d).call(this, q[1]); // if we got a non-empty set as a result ... // (otw rx already contains everything we want to match) if (p[0].length > 0) { // update current result, which is stored in rx ... // basically, pick up the remaining text from p[1] // and concat the result from p[0] so that we don't // get endless nesting ... rx[0] = rx[0].concat(p[0]); rx[1] = p[1]; } } // at this point, rx either contains the last matched element // or the entire matched set that starts with this element. // now we just check to see if this variation is better than // our best so far, in terms of how much of the input is parsed if (rx[1].length < best[1].length) { best = rx; } // if we've parsed all the input, then we're finished if (best[1].length === 0) { break; } } // so now we've either gone through all the patterns trying them // as the initial match; or we found one that parsed the entire // input string ... // if best has no matches, just return empty set ... if (best[0].length === 0) { return best; } // if a closing delimiter is provided, then we have to check it also if (c) { // we try this even if there is no remaining input because the pattern // may well be optional or match empty input ... try { q = c.call(this, best[1]); } catch (ey) { throw new $P.Exception(best[1]); } // it parsed ... be sure to update the best match remaining input best[1] = q[1]; } // if we're here, either there was no closing delimiter or we parsed it // so now we have the best match; just return it! return best; }; }, forward: function (gr, fname) { return function (s) { return gr[fname].call(this, s); }; }, // // Translation Operators // replace: function (rule, repl) { return function (s) { var r = rule.call(this, s); return [repl, r[1]]; }; }, process: function (rule, fn) { return function (s) { var r = rule.call(this, s); return [fn.call(this, r[0]), r[1]]; }; }, min: function (min, rule) { return function (s) { var rx = rule.call(this, s); if (rx[0].length < min) { throw new $P.Exception(s); } return rx; }; } }; // Generator Operators And Vector Operators // Generators are operators that have a signature of F(R) => R, // taking a given rule and returning another rule, such as // ignore, which parses a given rule and throws away the result. // Vector operators are those that have a signature of F(R1,R2,...) => R, // take a list of rules and returning a new rule, such as each. // Generator operators are converted (via the following _generator // function) into functions that can also take a list or array of rules // and return an array of new rules as though the function had been // called on each rule in turn (which is what actually happens). // This allows generators to be used with vector operators more easily. // Example: // each(ignore(foo, bar)) instead of each(ignore(foo), ignore(bar)) // This also turns generators into vector operators, which allows // constructs like: // not(cache(foo, bar)) var _generator = function (op) { function gen() { var args = null, rx = [], px, i; if (arguments.length > 1) { args = Array.prototype.slice.call(arguments); } else if (arguments[0] instanceof Array) { args = arguments[0]; } if (args) { px = args.shift(); if (px.length > 0) { args.unshift(px[i]); rx.push(op.apply(null, args)); args.shift(); return rx; } } else { return op.apply(null, arguments); } } return gen; }; var gx = "optional not ignore cache".split(/\s/); for (var i = 0 ; i < gx.length ; i++) { _[gx[i]] = _generator(_[gx[i]]); } var _vector = function (op) { return function () { if (arguments[0] instanceof Array) { return op.apply(null, arguments[0]); } else { return op.apply(null, arguments); } }; }; var vx = "each any all".split(/\s/); for (var j = 0 ; j < vx.length ; j++) { _[vx[j]] = _vector(_[vx[j]]); } }()); (function () { var $D = Date; var flattenAndCompact = function (ax) { var rx = []; for (var i = 0; i < ax.length; i++) { if (ax[i] instanceof Array) { rx = rx.concat(flattenAndCompact(ax[i])); } else { if (ax[i]) { rx.push(ax[i]); } } } return rx; }; var parseMeridian = function () { if (this.meridian && (this.hour || this.hour === 0)) { if (this.meridian === "a" && this.hour > 11 && Date.Config.strict24hr){ throw "Invalid hour and meridian combination"; } else if (this.meridian === "p" && this.hour < 12 && Date.Config.strict24hr){ throw "Invalid hour and meridian combination"; } else if (this.meridian === "p" && this.hour < 12) { this.hour = this.hour + 12; } else if (this.meridian === "a" && this.hour === 12) { this.hour = 0; } } }; var setDefaults = function () { var now = new Date(); if ((this.hour || this.minute) && (!this.month && !this.year && !this.day)) { this.day = now.getDate(); } if (!this.year) { this.year = now.getFullYear(); } if (!this.month && this.month !== 0) { this.month = now.getMonth(); } if (!this.day) { this.day = 1; } if (!this.hour) { this.hour = 0; } if (!this.minute) { this.minute = 0; } if (!this.second) { this.second = 0; } if (!this.millisecond) { this.millisecond = 0; } }; var finishUtils = { getToday: function () { if (this.now || "hour minute second".indexOf(this.unit) !== -1) { return new Date(); } else { return $D.today(); } }, setDaysFromWeekday: function (today, orient){ var gap; orient = orient || 1; this.unit = "day"; gap = ($D.getDayNumberFromName(this.weekday) - today.getDay()); this.days = gap ? ((gap + (orient * 7)) % 7) : (orient * 7); return this; }, setMonthsFromMonth: function (today, orient) { var gap; orient = orient || 1; this.unit = "month"; gap = (this.month - today.getMonth()); this.months = gap ? ((gap + (orient * 12)) % 12) : (orient * 12); this.month = null; return this; }, setDMYFromWeekday: function () { var d = Date[this.weekday](); this.day = d.getDate(); if (!this.month) { this.month = d.getMonth(); } this.year = d.getFullYear(); return this; }, setUnitValue: function (orient) { if (!this.value && this.operator && this.operator !== null && this[this.unit + "s"] && this[this.unit + "s"] !== null) { this[this.unit + "s"] = this[this.unit + "s"] + ((this.operator === "add") ? 1 : -1) + (this.value||0) * orient; } else if (this[this.unit + "s"] == null || this.operator != null) { if (!this.value) { this.value = 1; } this[this.unit + "s"] = this.value * orient; } }, generateDateFromWeeks: function () { var weekday = (this.weekday !== undefined) ? this.weekday : "today"; var d = Date[weekday]().addWeeks(this.weeks); if (this.now) { d.setTimeToNow(); } return d; } }; $D.Translator = { hour: function (s) { return function () { this.hour = Number(s); }; }, minute: function (s) { return function () { this.minute = Number(s); }; }, second: function (s) { return function () { this.second = Number(s); }; }, /* for ss.s format */ secondAndMillisecond: function (s) { return function () { var mx = s.match(/^([0-5][0-9])\.([0-9]{1,3})/); this.second = Number(mx[1]); this.millisecond = Number(mx[2]); }; }, meridian: function (s) { return function () { this.meridian = s.slice(0, 1).toLowerCase(); }; }, timezone: function (s) { return function () { var n = s.replace(/[^\d\+\-]/g, ""); if (n.length) { this.timezoneOffset = Number(n); } else { this.timezone = s.toLowerCase(); } }; }, day: function (x) { var s = x[0]; return function () { this.day = Number(s.match(/\d+/)[0]); if (this.day < 1) { throw "invalid day"; } }; }, month: function (s) { return function () { this.month = (s.length === 3) ? "jan feb mar apr may jun jul aug sep oct nov dec".indexOf(s)/4 : Number(s) - 1; if (this.month < 0) { throw "invalid month"; } }; }, year: function (s) { return function () { var n = Number(s); this.year = ((s.length > 2) ? n : (n + (((n + 2000) < Date.CultureInfo.twoDigitYearMax) ? 2000 : 1900))); }; }, rday: function (s) { return function () { switch (s) { case "yesterday": this.days = -1; break; case "tomorrow": this.days = 1; break; case "today": this.days = 0; break; case "now": this.days = 0; this.now = true; break; } }; }, finishExact: function (x) { var d; x = (x instanceof Array) ? x : [x]; for (var i = 0 ; i < x.length ; i++) { if (x[i]) { x[i].call(this); } } setDefaults.call(this); parseMeridian.call(this); if (this.day > $D.getDaysInMonth(this.year, this.month)) { throw new RangeError(this.day + " is not a valid value for days."); } d = new Date(this.year, this.month, this.day, this.hour, this.minute, this.second, this.millisecond); if (this.year < 100) { d.setFullYear(this.year); // means years less that 100 are process correctly. JS will parse it otherwise as 1900-1999. } if (this.timezone) { d.set({ timezone: this.timezone }); } else if (this.timezoneOffset) { d.set({ timezoneOffset: this.timezoneOffset }); } return d; }, finish: function (x) { var today, expression, orient, temp; x = (x instanceof Array) ? flattenAndCompact(x) : [ x ]; if (x.length === 0) { return null; } for (var i = 0 ; i < x.length ; i++) { if (typeof x[i] === "function") { x[i].call(this); } } if (this.now && !this.unit && !this.operator) { return new Date(); } else { today = finishUtils.getToday.call(this); } expression = !!(this.days && this.days !== null || this.orient || this.operator); orient = ((this.orient === "past" || this.operator === "subtract") ? -1 : 1); if (this.month && this.unit === "week") { this.value = this.month + 1; delete this.month; delete this.day; } if ((this.month || this.month === 0) && "year day hour minute second".indexOf(this.unit) !== -1) { if (!this.value) { this.value = this.month + 1; } this.month = null; expression = true; } if (!expression && this.weekday && !this.day && !this.days) { finishUtils.setDMYFromWeekday.call(this); } if (expression && this.weekday && this.unit !== "month" && this.unit !== "week") { finishUtils.setDaysFromWeekday.call(this, today, orient); } if (this.weekday && this.unit !== "week" && !this.day && !this.days) { temp = Date[this.weekday](); this.day = temp.getDate(); if (temp.getMonth() !== today.getMonth()) { this.month = temp.getMonth(); } } if (this.month && this.unit === "day" && this.operator) { if (!this.value) { this.value = (this.month + 1); } this.month = null; } if (this.value != null && this.month != null && this.year != null) { this.day = this.value * 1; } if (this.month && !this.day && this.value) { today.set({ day: this.value * 1 }); if (!expression) { this.day = this.value * 1; } } if (!this.month && this.value && this.unit === "month" && !this.now) { this.month = this.value; expression = true; } if (expression && (this.month || this.month === 0) && this.unit !== "year") { finishUtils.setMonthsFromMonth.call(this, today, orient); } if (!this.unit) { this.unit = "day"; } finishUtils.setUnitValue.call(this, orient); parseMeridian.call(this); if ((this.month || this.month === 0) && !this.day) { this.day = 1; } if (!this.orient && !this.operator && this.unit === "week" && this.value && !this.day && !this.month) { return Date.today().setWeek(this.value); } if (this.unit === "week" && this.weeks && !this.day && !this.month) { return finishUtils.generateDateFromWeeks.call(this); } if (expression && this.timezone && this.day && this.days) { this.day = this.days; } if (expression){ today.add(this); } else { today.set(this); } if (this.timezone) { this.timezone = this.timezone.toUpperCase(); var offset = $D.getTimezoneOffset(this.timezone); var timezone; if (today.hasDaylightSavingTime()) { // lets check that we're being sane with timezone setting timezone = $D.getTimezoneAbbreviation(offset, today.isDaylightSavingTime()); if (timezone !== this.timezone) { // bugger, we're in a place where things like EST vs EDT matters. if (today.isDaylightSavingTime()) { today.addHours(-1); } else { today.addHours(1); } } } today.setTimezoneOffset(offset); } return today; } }; }()); (function () { var $D = Date; $D.Grammar = {}; var _ = $D.Parsing.Operators, g = $D.Grammar, t = $D.Translator, _fn; // Allow rolling up into general purpose rules _fn = function () { return _.each(_.any.apply(null, arguments), _.not(g.ctoken2("timeContext"))); }; g.datePartDelimiter = _.rtoken(/^([\s\-\.\,\/\x27]+)/); g.timePartDelimiter = _.stoken(":"); g.whiteSpace = _.rtoken(/^\s*/); g.generalDelimiter = _.rtoken(/^(([\s\,]|at|@|on)+)/); var _C = {}; g.ctoken = function (keys) { var fn = _C[keys]; if (! fn) { var c = Date.CultureInfo.regexPatterns; var kx = keys.split(/\s+/), px = []; for (var i = 0; i < kx.length ; i++) { px.push(_.replace(_.rtoken(c[kx[i]]), kx[i])); } fn = _C[keys] = _.any.apply(null, px); } return fn; }; g.ctoken2 = function (key) { return _.rtoken(Date.CultureInfo.regexPatterns[key]); }; var cacheProcessRtoken = function (key, token, type, eachToken) { if (eachToken) { g[key] = _.cache(_.process(_.each(_.rtoken(token),_.optional(g.ctoken2(eachToken))), type)); } else { g[key] = _.cache(_.process(_.rtoken(token), type)); } }; var cacheProcessCtoken = function (token, type) { return _.cache(_.process(g.ctoken2(token), type)); }; var _F = {}; //function cache var _get = function (f) { _F[f] = (_F[f] || g.format(f)[0]); return _F[f]; }; g.allformats = function (fx) { var rx = []; if (fx instanceof Array) { for (var i = 0; i < fx.length; i++) { rx.push(_get(fx[i])); } } else { rx.push(_get(fx)); } return rx; }; g.formats = function (fx) { if (fx instanceof Array) { var rx = []; for (var i = 0 ; i < fx.length ; i++) { rx.push(_get(fx[i])); } return _.any.apply(null, rx); } else { return _get(fx); } }; var grammarFormats = { timeFormats: function(){ var i, RTokenKeys = [ "h", "hh", "H", "HH", "m", "mm", "s", "ss", "ss.s", "z", "zz" ], RToken = [ /^(0[0-9]|1[0-2]|[1-9])/, /^(0[0-9]|1[0-2])/, /^([0-1][0-9]|2[0-3]|[0-9])/, /^([0-1][0-9]|2[0-3])/, /^([0-5][0-9]|[0-9])/, /^[0-5][0-9]/, /^([0-5][0-9]|[0-9])/, /^[0-5][0-9]/, /^[0-5][0-9]\.[0-9]{1,3}/, /^((\+|\-)\s*\d\d\d\d)|((\+|\-)\d\d\:?\d\d)/, /^((\+|\-)\s*\d\d\d\d)|((\+|\-)\d\d\:?\d\d)/ ], tokens = [ t.hour, t.hour, t.hour, t.hour, t.minute, t.minute, t.second, t.second, t.secondAndMillisecond, t.timezone, t.timezone ]; for (i=0; i < RTokenKeys.length; i++) { cacheProcessRtoken(RTokenKeys[i], RToken[i], tokens[i]); } g.hms = _.cache(_.sequence([g.H, g.m, g.s], g.timePartDelimiter)); g.t = cacheProcessCtoken("shortMeridian", t.meridian); g.tt = cacheProcessCtoken("longMeridian", t.meridian); g.zzz = cacheProcessCtoken("timezone", t.timezone); g.timeSuffix = _.each(_.ignore(g.whiteSpace), _.set([ g.tt, g.zzz ])); g.time = _.each(_.optional(_.ignore(_.stoken("T"))), g.hms, g.timeSuffix); }, dateFormats: function () { // pre-loaded rules for different date part order preferences var _setfn = function () { return _.set(arguments, g.datePartDelimiter); }; var i, RTokenKeys = [ "d", "dd", "M", "MM", "y", "yy", "yyy", "yyyy" ], RToken = [ /^([0-2]\d|3[0-1]|\d)/, /^([0-2]\d|3[0-1])/, /^(1[0-2]|0\d|\d)/, /^(1[0-2]|0\d)/, /^(\d+)/, /^(\d\d)/, /^(\d\d?\d?\d?)/, /^(\d\d\d\d)/ ], tokens = [ t.day, t.day, t.month, t.month, t.year, t.year, t.year, t.year ], eachToken = [ "ordinalSuffix", "ordinalSuffix" ]; for (i=0; i < RTokenKeys.length; i++) { cacheProcessRtoken(RTokenKeys[i], RToken[i], tokens[i], eachToken[i]); } g.MMM = g.MMMM = _.cache(_.process(g.ctoken("jan feb mar apr may jun jul aug sep oct nov dec"), t.month)); g.ddd = g.dddd = _.cache(_.process(g.ctoken("sun mon tue wed thu fri sat"), function (s) { return function () { this.weekday = s; }; } )); g.day = _fn(g.d, g.dd); g.month = _fn(g.M, g.MMM); g.year = _fn(g.yyyy, g.yy); g.mdy = _setfn(g.ddd, g.month, g.day, g.year); g.ymd = _setfn(g.ddd, g.year, g.month, g.day); g.dmy = _setfn(g.ddd, g.day, g.month, g.year); g.date = function (s) { return ((g[Date.CultureInfo.dateElementOrder] || g.mdy).call(this, s)); }; }, relative: function () { // relative date / time expressions g.orientation = _.process(g.ctoken("past future"), function (s) { return function () { this.orient = s; }; } ); g.operator = _.process(g.ctoken("add subtract"), function (s) { return function () { this.operator = s; }; } ); g.rday = _.process(g.ctoken("yesterday tomorrow today now"), t.rday); g.unit = _.process(g.ctoken("second minute hour day week month year"), function (s) { return function () { this.unit = s; }; } ); } }; g.buildGrammarFormats = function () { // these need to be rebuilt every time the language changes. _C = {}; grammarFormats.timeFormats(); grammarFormats.dateFormats(); grammarFormats.relative(); g.value = _.process(_.rtoken(/^([-+]?\d+)?(st|nd|rd|th)?/), function (s) { return function () { this.value = s.replace(/\D/g, ""); }; } ); g.expression = _.set([g.rday, g.operator, g.value, g.unit, g.orientation, g.ddd, g.MMM ]); g.format = _.process(_.many( _.any( // translate format specifiers into grammar rules _.process( _.rtoken(/^(dd?d?d?(?!e)|MM?M?M?|yy?y?y?|hh?|HH?|mm?|ss?|tt?|zz?z?)/), function (fmt) { if (g[fmt]) { return g[fmt]; } else { throw $D.Parsing.Exception(fmt); } } ), // translate separator tokens into token rules _.process(_.rtoken(/^[^dMyhHmstz]+/), // all legal separators function (s) { return _.ignore(_.stoken(s)); } ) ) ), // construct the parser ... function (rules) { return _.process(_.each.apply(null, rules), t.finishExact); } ); // starting rule for general purpose grammar g._start = _.process(_.set([ g.date, g.time, g.expression ], g.generalDelimiter, g.whiteSpace), t.finish); }; g.buildGrammarFormats(); // parsing date format specifiers - ex: "h:m:s tt" // this little guy will generate a custom parser based // on the format string, ex: g.format("h:m:s tt") // check for these formats first g._formats = g.formats([ "\"yyyy-MM-ddTHH:mm:ssZ\"", "yyyy-MM-ddTHH:mm:ss.sz", "yyyy-MM-ddTHH:mm:ssZ", "yyyy-MM-ddTHH:mm:ssz", "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-ddTHH:mmZ", "yyyy-MM-ddTHH:mmz", "yyyy-MM-ddTHH:mm", "ddd, MMM dd, yyyy H:mm:ss tt", "ddd MMM d yyyy HH:mm:ss zzz", "MMddyyyy", "ddMMyyyy", "Mddyyyy", "ddMyyyy", "Mdyyyy", "dMyyyy", "yyyy", "Mdyy", "dMyy", "d" ]); // real starting rule: tries selected formats first, // then general purpose rule g.start = function (s) { try { var r = g._formats.call({}, s); if (r[1].length === 0) { return r; } } catch (e) {} return g._start.call({}, s); }; }()); (function () { var $D = Date; /** * @desc Converts the specified string value into its JavaScript Date equivalent using CultureInfo specific format information. * * Example

	///////////
	// Dates //
	///////////

	// 15-Oct-2004
	var d1 = Date.parse("10/15/2004");

	// 15-Oct-2004
	var d1 = Date.parse("15-Oct-2004");

	// 15-Oct-2004
	var d1 = Date.parse("2004.10.15");

	//Fri Oct 15, 2004
	var d1 = Date.parse("Fri Oct 15, 2004");

	///////////
	// Times //
	///////////

	// Today at 10 PM.
	var d1 = Date.parse("10 PM");

	// Today at 10:30 PM.
	var d1 = Date.parse("10:30 P.M.");

	// Today at 6 AM.
	var d1 = Date.parse("06am");

	/////////////////////
	// Dates and Times //
	/////////////////////

	// 8-July-2004 @ 10:30 PM
	var d1 = Date.parse("July 8th, 2004, 10:30 PM");

	// 1-July-2004 @ 10:30 PM
	var d1 = Date.parse("2004-07-01T22:30:00");

	////////////////////
	// Relative Dates //
	////////////////////

	// Returns today's date. The string "today" is culture specific.
	var d1 = Date.parse("today");

	// Returns yesterday's date. The string "yesterday" is culture specific.
	var d1 = Date.parse("yesterday");

	// Returns the date of the next thursday.
	var d1 = Date.parse("Next thursday");

	// Returns the date of the most previous monday.
	var d1 = Date.parse("last monday");

	// Returns today's day + one year.
	var d1 = Date.parse("next year");

	///////////////
	// Date Math //
	///////////////

	// Today + 2 days
	var d1 = Date.parse("t+2");

	// Today + 2 days
	var d1 = Date.parse("today + 2 days");

	// Today + 3 months
	var d1 = Date.parse("t+3m");

	// Today - 1 year
	var d1 = Date.parse("today - 1 year");

	// Today - 1 year
	var d1 = Date.parse("t-1y"); 


	/////////////////////////////
	// Partial Dates and Times //
	/////////////////////////////

	// July 15th of this year.
	var d1 = Date.parse("July 15");

	// 15th day of current day and year.
	var d1 = Date.parse("15");

	// July 1st of current year at 10pm.
	var d1 = Date.parse("7/1 10pm");
	
* * @param {String} The string value to convert into a Date object [Required] * @return {Date} A Date object or null if the string cannot be converted into a Date. */ var parseUtils = { removeOrds: function (s) { ords = s.match(/\b(\d+)(?:st|nd|rd|th)\b/); // find ordinal matches s = ((ords && ords.length === 2) ? s.replace(ords[0], ords[1]) : s); return s; }, grammarParser: function (s) { var r = null; try { r = $D.Grammar.start.call({}, s.replace(/^\s*(\S*(\s+\S+)*)\s*$/, "$1")); } catch (e) { return null; } return ((r[1].length === 0) ? r[0] : null); }, nativeFallback: function(s) { var t; try { // ok we haven't parsed it, last ditch attempt with the built-in parser. t = Date._parse(s); return (t || t === 0) ? new Date(t) : null; } catch (e) { return null; } } }; function parse (s) { var d; if (!s) { return null; } if (s instanceof Date) { return s.clone(); } if (s.length >= 4 && s.charAt(0) !== "0" && s.charAt(0) !== "+"&& s.charAt(0) !== "-") { // ie: 2004 will pass, 0800 won't. // Start with specific formats d = $D.Parsing.ISO.parse(s) || $D.Parsing.Numeric.parse(s); } if (d instanceof Date && !isNaN(d.getTime())) { return d; } else { // find ordinal dates (1st, 3rd, 8th, etc and remove them as they cause parsing issues) s = $D.Parsing.Normalizer.parse(parseUtils.removeOrds(s)); d = parseUtils.grammarParser(s); if (d !== null) { return d; } else { return parseUtils.nativeFallback(s); } } } if (!$D._parse) { $D._parse = $D.parse; } $D.parse = parse; Date.getParseFunction = function (fx) { var fns = Date.Grammar.allformats(fx); return function (s) { var r = null; for (var i = 0; i < fns.length; i++) { try { r = fns[i].call({}, s); } catch (e) { continue; } if (r[1].length === 0) { return r[0]; } } return null; }; }; /** * Converts the specified string value into its JavaScript Date equivalent using the specified format {String} or formats {Array} and the CultureInfo specific format information. * The format of the string value must match one of the supplied formats exactly. * * Example

	// 15-Oct-2004
	var d1 = Date.parseExact("10/15/2004", "M/d/yyyy");

	// 15-Oct-2004
	var d1 = Date.parse("15-Oct-2004", "M-ddd-yyyy");

	// 15-Oct-2004
	var d1 = Date.parse("2004.10.15", "yyyy.MM.dd");

	// Multiple formats
	var d1 = Date.parseExact("10/15/2004", ["M/d/yyyy", "MMMM d, yyyy"]);
	
* * @param {String} The string value to convert into a Date object [Required]. * @param {Object} The expected format {String} or an array of expected formats {Array} of the date string [Required]. * @return {Date} A Date object or null if the string cannot be converted into a Date. */ $D.parseExact = function (s, fx) { return $D.getParseFunction(fx)(s); }; }()); (function () { var $D = Date, $P = $D.prototype, // $C = $D.CultureInfo, // not used atm p = function (s, l) { if (!l) { l = 2; } return ("000" + s).slice(l * -1); }; /** * Converts a PHP format string to Java/.NET format string. * A PHP format string can be used with ._format or .format. * A Java/.NET format string can be used with .toString(). * The .parseExact function will only accept a Java/.NET format string * * Example * var f1 = "%m/%d/%y" * var f2 = Date.normalizeFormat(f1); // "MM/dd/yy" * * new Date().format(f1); // "04/13/08" * new Date()._format(f1); // "04/13/08" * new Date().toString(f2); // "04/13/08" * * var date = Date.parseExact("04/13/08", f2); // Sun Apr 13 2008 * * @param {String} A PHP format string consisting of one or more format spcifiers. * @return {String} The PHP format converted to a Java/.NET format string. */ var normalizerSubstitutions = { "d" : "dd", "%d": "dd", "D" : "ddd", "%a": "ddd", "j" : "dddd", "l" : "dddd", "%A": "dddd", "S" : "S", "F" : "MMMM", "%B": "MMMM", "m" : "MM", "%m": "MM", "M" : "MMM", "%b": "MMM", "%h": "MMM", "n" : "M", "Y" : "yyyy", "%Y": "yyyy", "y" : "yy", "%y": "yy", "g" : "h", "%I": "h", "G" : "H", "h" : "hh", "H" : "HH", "%H": "HH", "i" : "mm", "%M": "mm", "s" : "ss", "%S": "ss", "%r": "hh:mm tt", "%R": "H:mm", "%T": "H:mm:ss", "%X": "t", "%x": "d", "%e": "d", "%D": "MM/dd/yy", "%n": "\\n", "%t": "\\t", "e" : "z", "T" : "z", "%z": "z", "%Z": "z", "Z" : "ZZ", "N" : "u", "w" : "u", "%w": "u", "W" : "W", "%V": "W" }; var normalizer = { substitutes: function (m) { return normalizerSubstitutions[m]; }, interpreted: function (m, x) { var y; switch (m) { case "%u": return x.getDay() + 1; case "z": return x.getOrdinalNumber(); case "%j": return p(x.getOrdinalNumber(), 3); case "%U": var d1 = x.clone().set({month: 0, day: 1}).addDays(-1).moveToDayOfWeek(0), d2 = x.clone().addDays(1).moveToDayOfWeek(0, -1); return (d2 < d1) ? "00" : p((d2.getOrdinalNumber() - d1.getOrdinalNumber()) / 7 + 1); case "%W": return p(x.getWeek()); case "t": return $D.getDaysInMonth(x.getFullYear(), x.getMonth()); case "o": case "%G": return x.setWeek(x.getISOWeek()).toString("yyyy"); case "%g": return x._format("%G").slice(-2); case "a": case "%p": return t("tt").toLowerCase(); case "A": return t("tt").toUpperCase(); case "u": return p(x.getMilliseconds(), 3); case "I": return (x.isDaylightSavingTime()) ? 1 : 0; case "O": return x.getUTCOffset(); case "P": y = x.getUTCOffset(); return y.substring(0, y.length - 2) + ":" + y.substring(y.length - 2); case "B": var now = new Date(); return Math.floor(((now.getHours() * 3600) + (now.getMinutes() * 60) + now.getSeconds() + (now.getTimezoneOffset() + 60) * 60) / 86.4); case "c": return x.toISOString().replace(/\"/g, ""); case "U": return $D.strtotime("now"); case "%c": return t("d") + " " + t("t"); case "%C": return Math.floor(x.getFullYear() / 100 + 1); } }, shouldOverrideDefaults: function (m) { switch (m) { case "%e": return true; default: return false; } }, parse: function (m, context) { var formatString, c = context || new Date(); formatString = normalizer.substitutes(m); if (formatString) { return formatString; } formatString = normalizer.interpreted(m, c); if (formatString) { return formatString; } else { return m; } } }; $D.normalizeFormat = function (format, context) { return format.replace(/(%|\\)?.|%%/g, function(t){ return normalizer.parse(t, context); }); }; /** * Format a local Unix timestamp according to locale settings * * Example: * Date.strftime("%m/%d/%y", new Date()); // "04/13/08" * Date.strftime("c", "2008-04-13T17:52:03Z"); // "04/13/08" * * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @param {Number|String} The number representing the number of seconds that have elapsed since January 1, 1970 (local time). * @return {String} A string representation of the current Date object. */ $D.strftime = function (format, time) { var d = Date.parse(time); return d._format(format); }; /** * Parse any textual datetime description into a Unix timestamp. * A Unix timestamp is the number of seconds that have elapsed since January 1, 1970 (midnight UTC/GMT). * * Example: * Date.strtotime("04/13/08"); // 1208044800 * Date.strtotime("1970-01-01T00:00:00Z"); // 0 * * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @param {Object} A string or date object. * @return {String} A string representation of the current Date object. */ $D.strtotime = function (time) { var d = $D.parse(time); return Math.round($D.UTC(d.getUTCFullYear(), d.getUTCMonth(), d.getUTCDate(), d.getUTCHours(), d.getUTCMinutes(), d.getUTCSeconds(), d.getUTCMilliseconds()) / 1000); }; /** * Converts the value of the current Date object to its equivalent string representation using a PHP/Unix style of date format specifiers. * Format Specifiers * Format Description Example * ------ --------------------------------------------------------------------------- ----------------------- * %a abbreviated weekday name according to the current localed "Mon" through "Sun" * %A full weekday name according to the current localed "Sunday" through "Saturday" * %b abbreviated month name according to the current localed "Jan" through "Dec" * %B full month name according to the current locale "January" through "December" * %c preferred date and time representation for the current locale "4/13/2008 12:33 PM" * %C century number (the year divided by 100 and truncated to an integer) "00" to "99" * %d day of the month as a decimal number "01" to "31" * %D same as %m/%d/%y "04/13/08" * %e day of the month as a decimal number, a single digit is preceded by a space "1" to "31" * %g like %G, but without the century "08" * %G The 4-digit year corresponding to the ISO week number (see %V). "2008" * This has the same format and value as %Y, except that if the ISO week number * belongs to the previous or next year, that year is used instead. * %h same as %b "Jan" through "Dec" * %H hour as a decimal number using a 24-hour clock. "00" to "23" * %I hour as a decimal number using a 12-hour clock. "01" to "12" * %j day of the year as a decimal number. "001" to "366" * %m month as a decimal number. "01" to "12" * %M minute as a decimal number. "00" to "59" * %n newline character "\n" * %p either "am" or "pm" according to the given time value, or the "am" or "pm" * corresponding strings for the current locale. * %r time in a.m. and p.m. notation "8:44 PM" * %R time in 24 hour notation "20:44" * %S second as a decimal number "00" to "59" * %t tab character "\t" * %T current time, equal to %H:%M:%S "12:49:11" * %u weekday as a decimal number ["1", "7"], with "1" representing Monday "1" to "7" * %U week number of the current year as a decimal number, starting with the "0" to ("52" or "53") * first Sunday as the first day of the first week * %V The ISO 8601:1988 week number of the current year as a decimal number, "00" to ("52" or "53") * range 01 to 53, where week 1 is the first week that has at least 4 days * in the current year, and with Monday as the first day of the week. * (Use %G or %g for the year component that corresponds to the week number * for the specified timestamp.) * %W week number of the current year as a decimal number, starting with the "00" to ("52" or "53") * first Monday as the first day of the first week * %w day of the week as a decimal, Sunday being "0" "0" to "6" * %x preferred date representation for the current locale without the time "4/13/2008" * %X preferred time representation for the current locale without the date "12:53:05" * %y year as a decimal number without a century "00" "99" * %Y year as a decimal number including the century "2008" * %Z time zone or name or abbreviation "UTC", "EST", "PST" * %z same as %Z * %% a literal "%" characters "%" * d Day of the month, 2 digits with leading zeros "01" to "31" * D A textual representation of a day, three letters "Mon" through "Sun" * j Day of the month without leading zeros "1" to "31" * l A full textual representation of the day of the week (lowercase "L") "Sunday" through "Saturday" * N ISO-8601 numeric representation of the day of the week (added in PHP 5.1.0) "1" (for Monday) through "7" (for Sunday) * S English ordinal suffix for the day of the month, 2 characters "st", "nd", "rd" or "th". Works well with j * w Numeric representation of the day of the week "0" (for Sunday) through "6" (for Saturday) * z The day of the year (starting from "0") "0" through "365" * W ISO-8601 week number of year, weeks starting on Monday "00" to ("52" or "53") * F A full textual representation of a month, such as January or March "January" through "December" * m Numeric representation of a month, with leading zeros "01" through "12" * M A short textual representation of a month, three letters "Jan" through "Dec" * n Numeric representation of a month, without leading zeros "1" through "12" * t Number of days in the given month "28" through "31" * L Whether it's a leap year "1" if it is a leap year, "0" otherwise * o ISO-8601 year number. This has the same value as Y, except that if the "2008" * ISO week number (W) belongs to the previous or next year, that year * is used instead. * Y A full numeric representation of a year, 4 digits "2008" * y A two digit representation of a year "08" * a Lowercase Ante meridiem and Post meridiem "am" or "pm" * A Uppercase Ante meridiem and Post meridiem "AM" or "PM" * B Swatch Internet time "000" through "999" * g 12-hour format of an hour without leading zeros "1" through "12" * G 24-hour format of an hour without leading zeros "0" through "23" * h 12-hour format of an hour with leading zeros "01" through "12" * H 24-hour format of an hour with leading zeros "00" through "23" * i Minutes with leading zeros "00" to "59" * s Seconds, with leading zeros "00" through "59" * u Milliseconds "54321" * e Timezone identifier "UTC", "EST", "PST" * I Whether or not the date is in daylight saving time (uppercase i) "1" if Daylight Saving Time, "0" otherwise * O Difference to Greenwich time (GMT) in hours "+0200", "-0600" * P Difference to Greenwich time (GMT) with colon between hours and minutes "+02:00", "-06:00" * T Timezone abbreviation "UTC", "EST", "PST" * Z Timezone offset in seconds. The offset for timezones west of UTC is "-43200" through "50400" * always negative, and for those east of UTC is always positive. * c ISO 8601 date "2004-02-12T15:19:21+00:00" * r RFC 2822 formatted date "Thu, 21 Dec 2000 16:01:07 +0200" * U Seconds since the Unix Epoch (January 1 1970 00:00:00 GMT) "0" * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @return {String} A string representation of the current Date object. */ var formatReplace = function (context) { return function (m) { var formatString, override = false; if (m.charAt(0) === "\\" || m.substring(0, 2) === "%%") { return m.replace("\\", "").replace("%%", "%"); } override = normalizer.shouldOverrideDefaults(m); formatString = $D.normalizeFormat(m, context); if (formatString) { return context.toString(formatString, override); } }; }; $P._format = function (format) { var formatter = formatReplace(this); if (!format) { return this._toString(); } else { return format.replace(/(%|\\)?.|%%/g, formatter); } }; if (!$P.format) { $P.format = $P._format; } }()); (function () { "use strict"; var gFn = function (attr) { return function () { return this[attr]; }; }; var sFn = function (attr) { return function (val) { this[attr] = val; return this; }; }; var attrs = ["years", "months", "days", "hours", "minutes", "seconds", "milliseconds"]; var addSetFuncs = function (context, attrs) { for (var i = 0; i < attrs.length ; i++) { var $a = attrs[i], $b = $a.slice(0, 1).toUpperCase() + $a.slice(1); context.prototype[$a] = 0; context.prototype["get" + $b] = gFn($a); context.prototype["set" + $b] = sFn($a); } }; /** * new TimeSpan(milliseconds); * new TimeSpan(days, hours, minutes, seconds); * new TimeSpan(days, hours, minutes, seconds, milliseconds); */ var TimeSpan = function (days, hours, minutes, seconds, milliseconds) { if (arguments.length === 1 && typeof days === "number") { var orient = (days < 0) ? -1 : +1; var millsLeft = Math.abs(days); this.setDays(Math.floor(millsLeft / 86400000) * orient); millsLeft = millsLeft % 86400000; this.setHours(Math.floor(millsLeft / 3600000) * orient); millsLeft = millsLeft % 3600000; this.setMinutes(Math.floor(millsLeft / 60000) * orient); millsLeft = millsLeft % 60000; this.setSeconds(Math.floor(millsLeft / 1000) * orient); millsLeft = millsLeft % 1000; this.setMilliseconds(millsLeft * orient); } else { this.set(days, hours, minutes, seconds, milliseconds); } this.getTotalMilliseconds = function () { return (this.getDays() * 86400000) + (this.getHours() * 3600000) + (this.getMinutes() * 60000) + (this.getSeconds() * 1000); }; this.compareTo = function (time) { var t1 = new Date(1970, 1, 1, this.getHours(), this.getMinutes(), this.getSeconds()), t2; if (time === null) { t2 = new Date(1970, 1, 1, 0, 0, 0); } else { t2 = new Date(1970, 1, 1, time.getHours(), time.getMinutes(), time.getSeconds()); } return (t1 < t2) ? -1 : (t1 > t2) ? 1 : 0; }; this.equals = function (time) { return (this.compareTo(time) === 0); }; this.add = function (time) { return (time === null) ? this : this.addSeconds(time.getTotalMilliseconds() / 1000); }; this.subtract = function (time) { return (time === null) ? this : this.addSeconds(-time.getTotalMilliseconds() / 1000); }; this.addDays = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 86400000)); }; this.addHours = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 3600000)); }; this.addMinutes = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 60000)); }; this.addSeconds = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 1000)); }; this.addMilliseconds = function (n) { return new TimeSpan(this.getTotalMilliseconds() + n); }; this.get12HourHour = function () { return (this.getHours() > 12) ? this.getHours() - 12 : (this.getHours() === 0) ? 12 : this.getHours(); }; this.getDesignator = function () { return (this.getHours() < 12) ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator; }; this.toString = function (format) { this._toString = function () { if (this.getDays() !== null && this.getDays() > 0) { return this.getDays() + "." + this.getHours() + ":" + this.p(this.getMinutes()) + ":" + this.p(this.getSeconds()); } else { return this.getHours() + ":" + this.p(this.getMinutes()) + ":" + this.p(this.getSeconds()); } }; this.p = function (s) { return (s.toString().length < 2) ? "0" + s : s; }; var me = this; return format ? format.replace(/dd?|HH?|hh?|mm?|ss?|tt?/g, function (format) { switch (format) { case "d": return me.getDays(); case "dd": return me.p(me.getDays()); case "H": return me.getHours(); case "HH": return me.p(me.getHours()); case "h": return me.get12HourHour(); case "hh": return me.p(me.get12HourHour()); case "m": return me.getMinutes(); case "mm": return me.p(me.getMinutes()); case "s": return me.getSeconds(); case "ss": return me.p(me.getSeconds()); case "t": return ((me.getHours() < 12) ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator).substring(0, 1); case "tt": return (me.getHours() < 12) ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator; } } ) : this._toString(); }; return this; }; addSetFuncs(TimeSpan, attrs.slice(2)); TimeSpan.prototype.set = function (days, hours, minutes, seconds, milliseconds){ this.setDays(days || this.getDays()); this.setHours(hours || this.getHours()); this.setMinutes(minutes || this.getMinutes()); this.setSeconds(seconds || this.getSeconds()); this.setMilliseconds(milliseconds || this.getMilliseconds()); }; /** * Gets the time of day for this date instances. * @return {TimeSpan} TimeSpan */ Date.prototype.getTimeOfDay = function () { return new TimeSpan(0, this.getHours(), this.getMinutes(), this.getSeconds(), this.getMilliseconds()); }; Date.TimeSpan = TimeSpan; if (typeof window !== "undefined" ) { // keeping API compatible for v1.x window.TimeSpan = TimeSpan; } }()); (function () { "use strict"; var attrs = ["years", "months", "days", "hours", "minutes", "seconds", "milliseconds"]; var gFn = function (attr) { return function () { return this[attr]; }; }; var sFn = function (attr) { return function (val) { this[attr] = val; return this; }; }; var addSetFuncs = function (context, attrs) { for (var i = 0; i < attrs.length ; i++) { var $a = attrs[i], $b = $a.slice(0, 1).toUpperCase() + $a.slice(1); context.prototype[$a] = 0; context.prototype["get" + $b] = gFn($a); context.prototype["set" + $b] = sFn($a); } }; var setMonthsAndYears = function (orient, d1, d2, context) { function inc() { d1.addMonths(-orient); context.months++; if (context.months === 12) { context.years++; context.months = 0; } } if (orient === +1) { while (d1 > d2) { inc(); } } else { while (d1 < d2) { inc(); } } context.months--; context.months *= orient; context.years *= orient; }; var adjustForDST = function(orient, startDate, endDate) { var hasDSTMismatch = (false === (startDate.isDaylightSavingTime() === endDate.isDaylightSavingTime())); if (hasDSTMismatch && orient === 1) { startDate.addHours(-1); } else if (hasDSTMismatch) { startDate.addHours(1); } }; /** * TimePeriod(startDate, endDate); * TimePeriod(years, months, days, hours, minutes, seconds, milliseconds); */ var TimePeriod = function (years, months, days, hours, minutes, seconds, milliseconds) { if (arguments.length === 7) { this.set(years, months, days, hours, minutes, seconds, milliseconds); } else if (arguments.length === 2 && arguments[0] instanceof Date && arguments[1] instanceof Date) { var startDate = arguments[0].clone(); var endDate = arguments[1].clone(); var orient = (startDate > endDate) ? +1 : -1; this.dates = { start: arguments[0].clone(), end: arguments[1].clone() }; setMonthsAndYears(orient, startDate, endDate, this); adjustForDST(orient, startDate, endDate); // // TODO - adjust for DST var diff = endDate - startDate; if (diff !== 0) { var ts = new TimeSpan(diff); this.set(this.years, this.months, ts.getDays(), ts.getHours(), ts.getMinutes(), ts.getSeconds(), ts.getMilliseconds()); } } return this; }; // create all the set functions. addSetFuncs(TimePeriod, attrs); TimePeriod.prototype.set = function (years, months, days, hours, minutes, seconds, milliseconds){ this.setYears(years || this.getYears()); this.setMonths(months || this.getMonths()); this.setDays(days || this.getDays()); this.setHours(hours || this.getHours()); this.setMinutes(minutes || this.getMinutes()); this.setSeconds(seconds || this.getSeconds()); this.setMilliseconds(milliseconds || this.getMilliseconds()); }; Date.TimePeriod = TimePeriod; if (typeof window !== "undefined") { // keeping API compatible for v1.x window.TimePeriod = TimePeriod; } }()); ================================================ FILE: build/date-az-Cyrl-AZ.js ================================================ /** * @overview datejs * @version 1.0.0-rc3 * @author Gregory Wild-Smith * @copyright 2015 Gregory Wild-Smith * @license MIT * @homepage https://github.com/abritinthebay/datejs */ /* * DateJS Culture String File * Country Code: az-Cyrl-AZ * Name: Azeri (Cyrillic, Azerbaijan) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["az-Cyrl-AZ"] = { "name": "az-Cyrl-AZ", "englishName": "Azeri (Cyrillic, Azerbaijan)", "nativeName": "Азәрбајҹан (Азәрбајҹан)", "Sunday": "Базар", "Monday": "Базар ертәси", "Tuesday": "Чәршәнбә ахшамы", "Wednesday": "Чәршәнбә", "Thursday": "Ҹүмә ахшамы", "Friday": "Ҹүмә", "Saturday": "Шәнбә", "Sun": "Б", "Mon": "Бе", "Tue": "Ча", "Wed": "Ч", "Thu": "Ҹа", "Fri": "Ҹ", "Sat": "Ш", "Su": "Б", "Mo": "Бе", "Tu": "Ча", "We": "Ч", "Th": "Ҹа", "Fr": "Ҹ", "Sa": "Ш", "S_Sun_Initial": "Б", "M_Mon_Initial": "Б", "T_Tue_Initial": "Ч", "W_Wed_Initial": "Ч", "T_Thu_Initial": "Ҹ", "F_Fri_Initial": "Ҹ", "S_Sat_Initial": "Ш", "January": "Јанвар", "February": "Феврал", "March": "Март", "April": "Апрел", "May": "Мај", "June": "Ијун", "July": "Ијул", "August": "Август", "September": "Сентјабр", "October": "Октјабр", "November": "Нојабр", "December": "Декабр", "Jan_Abbr": "Јан", "Feb_Abbr": "Фев", "Mar_Abbr": "Мар", "Apr_Abbr": "Апр", "May_Abbr": "Мај", "Jun_Abbr": "Ијун", "Jul_Abbr": "Ијул", "Aug_Abbr": "Авг", "Sep_Abbr": "Сен", "Oct_Abbr": "Окт", "Nov_Abbr": "Ноя", "Dec_Abbr": "Дек", "AM": "", "PM": "", "firstDayOfWeek": 1, "twoDigitYearMax": 2029, "mdy": "dmy", "M/d/yyyy": "dd.MM.yyyy", "dddd, MMMM dd, yyyy": "d MMMM yyyy", "h:mm tt": "H:mm", "h:mm:ss tt": "H:mm:ss", "dddd, MMMM dd, yyyy h:mm:ss tt": "d MMMM yyyy H:mm:ss", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "d MMMM", "MMMM, yyyy": "MMMM yyyy", "/jan(uary)?/": "јан(вар)?", "/feb(ruary)?/": "фев(рал)?", "/mar(ch)?/": "мар(т)?", "/apr(il)?/": "апр(ел)?", "/may/": "мај", "/jun(e)?/": "ијун", "/jul(y)?/": "ијул", "/aug(ust)?/": "авг(уст)?", "/sep(t(ember)?)?/": "сен(тјабр)?", "/oct(ober)?/": "окт(јабр)?", "/nov(ember)?/": "нојабр", "/dec(ember)?/": "дек(абр)?", "/^su(n(day)?)?/": "^базар", "/^mo(n(day)?)?/": "^базар ертәси", "/^tu(e(s(day)?)?)?/": "^чәршәнбә ахшамы", "/^we(d(nesday)?)?/": "^чәршәнбә", "/^th(u(r(s(day)?)?)?)?/": "^ҹүмә ахшамы", "/^fr(i(day)?)?/": "^ҹүмә", "/^sa(t(urday)?)?/": "^шәнбә", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "az-Cyrl-AZ"; /** * @overview datejs * @version 1.0.0-rc3 * @author Gregory Wild-Smith * @copyright 2015 Gregory Wild-Smith * @license MIT * @homepage https://github.com/abritinthebay/datejs */(function () { var $D = Date; var lang = Date.CultureStrings ? Date.CultureStrings.lang : null; var loggedKeys = {}; // for debug purposes. var getText = { getFromKey: function (key, countryCode) { var output; if (Date.CultureStrings && Date.CultureStrings[countryCode] && Date.CultureStrings[countryCode][key]) { output = Date.CultureStrings[countryCode][key]; } else { output = getText.buildFromDefault(key); } if (key.charAt(0) === "/") { // Assume it's a regex output = getText.buildFromRegex(key, countryCode); } return output; }, getFromObjectValues: function (obj, countryCode) { var key, output = {}; for(key in obj) { if (obj.hasOwnProperty(key)) { output[key] = getText.getFromKey(obj[key], countryCode); } } return output; }, getFromObjectKeys: function (obj, countryCode) { var key, output = {}; for(key in obj) { if (obj.hasOwnProperty(key)) { output[getText.getFromKey(key, countryCode)] = obj[key]; } } return output; }, getFromArray: function (arr, countryCode) { var output = []; for (var i=0; i < arr.length; i++){ if (i in arr) { output[i] = getText.getFromKey(arr[i], countryCode); } } return output; }, buildFromDefault: function (key) { var output, length, split, last; switch(key) { case "name": output = "en-US"; break; case "englishName": output = "English (United States)"; break; case "nativeName": output = "English (United States)"; break; case "twoDigitYearMax": output = 2049; break; case "firstDayOfWeek": output = 0; break; default: output = key; split = key.split("_"); length = split.length; if (length > 1 && key.charAt(0) !== "/") { // if the key isn't a regex and it has a split. last = split[(length - 1)].toLowerCase(); if (last === "initial" || last === "abbr") { output = split[0]; } } break; } return output; }, buildFromRegex: function (key, countryCode) { var output; if (Date.CultureStrings && Date.CultureStrings[countryCode] && Date.CultureStrings[countryCode][key]) { output = new RegExp(Date.CultureStrings[countryCode][key], "i"); } else { output = new RegExp(key.replace(new RegExp("/", "g"),""), "i"); } return output; } }; var shallowMerge = function (obj1, obj2) { for (var attrname in obj2) { if (obj2.hasOwnProperty(attrname)) { obj1[attrname] = obj2[attrname]; } } }; var __ = function (key, language) { var countryCode = (language) ? language : lang; loggedKeys[key] = key; if (typeof key === "object") { if (key instanceof Array) { return getText.getFromArray(key, countryCode); } else { return getText.getFromObjectKeys(key, countryCode); } } else { return getText.getFromKey(key, countryCode); } }; var loadI18nScript = function (code) { // paatterned after jQuery's getScript. var url = Date.Config.i18n + code + ".js"; var head = document.getElementsByTagName("head")[0] || document.documentElement; var script = document.createElement("script"); script.src = url; var completed = false; var events = { done: function (){} // placeholder function }; // Attach handlers for all browsers script.onload = script.onreadystatechange = function() { if ( !completed && (!this.readyState || this.readyState === "loaded" || this.readyState === "complete") ) { events.done(); head.removeChild(script); } }; setTimeout(function() { head.insertBefore(script, head.firstChild); }, 0); // allows return to execute first return { done: function (cb) { events.done = function() { if (cb) { setTimeout(cb,0); } }; } }; }; var buildInfo = { buildFromMethodHash: function (obj) { var key; for(key in obj) { if (obj.hasOwnProperty(key)) { obj[key] = buildInfo[obj[key]](); } } return obj; }, timeZoneDST: function () { var DST = { "CHADT": "+1345", "NZDT": "+1300", "AEDT": "+1100", "ACDT": "+1030", "AZST": "+0500", "IRDT": "+0430", "EEST": "+0300", "CEST": "+0200", "BST": "+0100", "PMDT": "-0200", "ADT": "-0300", "NDT": "-0230", "EDT": "-0400", "CDT": "-0500", "MDT": "-0600", "PDT": "-0700", "AKDT": "-0800", "HADT": "-0900" }; return __(DST); }, timeZoneStandard: function () { var standard = { "LINT": "+1400", "TOT": "+1300", "CHAST": "+1245", "NZST": "+1200", "NFT": "+1130", "SBT": "+1100", "AEST": "+1000", "ACST": "+0930", "JST": "+0900", "CWST": "+0845", "CT": "+0800", "ICT": "+0700", "MMT": "+0630", "BST": "+0600", "NPT": "+0545", "IST": "+0530", "PKT": "+0500", "AFT": "+0430", "MSK": "+0400", "IRST": "+0330", "FET": "+0300", "EET": "+0200", "CET": "+0100", "GMT": "+0000", "UTC": "+0000", "CVT": "-0100", "GST": "-0200", "BRT": "-0300", "NST": "-0330", "AST": "-0400", "EST": "-0500", "CST": "-0600", "MST": "-0700", "PST": "-0800", "AKST": "-0900", "MIT": "-0930", "HST": "-1000", "SST": "-1100", "BIT": "-1200" }; return __(standard); }, timeZones: function (data) { var zone; data.timezones = []; for (zone in data.abbreviatedTimeZoneStandard) { if (data.abbreviatedTimeZoneStandard.hasOwnProperty(zone)) { data.timezones.push({ name: zone, offset: data.abbreviatedTimeZoneStandard[zone]}); } } for (zone in data.abbreviatedTimeZoneDST) { if (data.abbreviatedTimeZoneDST.hasOwnProperty(zone)) { data.timezones.push({ name: zone, offset: data.abbreviatedTimeZoneDST[zone], dst: true}); } } return data.timezones; }, days: function () { return __(["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"]); }, dayAbbr: function () { return __(["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"]); }, dayShortNames: function () { return __(["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"]); }, dayFirstLetters: function () { return __(["S_Sun_Initial", "M_Mon_Initial", "T_Tues_Initial", "W_Wed_Initial", "T_Thu_Initial", "F_Fri_Initial", "S_Sat_Initial"]); }, months: function () { return __(["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"]); }, monthAbbr: function () { return __(["Jan_Abbr", "Feb_Abbr", "Mar_Abbr", "Apr_Abbr", "May_Abbr", "Jun_Abbr", "Jul_Abbr", "Aug_Abbr", "Sep_Abbr", "Oct_Abbr", "Nov_Abbr", "Dec_Abbr"]); }, formatPatterns: function () { return getText.getFromObjectValues({ shortDate: "M/d/yyyy", longDate: "dddd, MMMM dd, yyyy", shortTime: "h:mm tt", longTime: "h:mm:ss tt", fullDateTime: "dddd, MMMM dd, yyyy h:mm:ss tt", sortableDateTime: "yyyy-MM-ddTHH:mm:ss", universalSortableDateTime: "yyyy-MM-dd HH:mm:ssZ", rfc1123: "ddd, dd MMM yyyy HH:mm:ss", monthDay: "MMMM dd", yearMonth: "MMMM, yyyy" }, Date.i18n.currentLanguage()); }, regex: function () { return getText.getFromObjectValues({ inTheMorning: "/( in the )(morn(ing)?)\\b/", thisMorning: "/(this )(morn(ing)?)\\b/", amThisMorning: "/(\b\\d(am)? )(this )(morn(ing)?)/", inTheEvening: "/( in the )(even(ing)?)\\b/", thisEvening: "/(this )(even(ing)?)\\b/", pmThisEvening: "/(\b\\d(pm)? )(this )(even(ing)?)/", jan: "/jan(uary)?/", feb: "/feb(ruary)?/", mar: "/mar(ch)?/", apr: "/apr(il)?/", may: "/may/", jun: "/jun(e)?/", jul: "/jul(y)?/", aug: "/aug(ust)?/", sep: "/sep(t(ember)?)?/", oct: "/oct(ober)?/", nov: "/nov(ember)?/", dec: "/dec(ember)?/", sun: "/^su(n(day)?)?/", mon: "/^mo(n(day)?)?/", tue: "/^tu(e(s(day)?)?)?/", wed: "/^we(d(nesday)?)?/", thu: "/^th(u(r(s(day)?)?)?)?/", fri: "/fr(i(day)?)?/", sat: "/^sa(t(urday)?)?/", future: "/^next/", past: "/^last|past|prev(ious)?/", add: "/^(\\+|aft(er)?|from|hence)/", subtract: "/^(\\-|bef(ore)?|ago)/", yesterday: "/^yes(terday)?/", today: "/^t(od(ay)?)?/", tomorrow: "/^tom(orrow)?/", now: "/^n(ow)?/", millisecond: "/^ms|milli(second)?s?/", second: "/^sec(ond)?s?/", minute: "/^mn|min(ute)?s?/", hour: "/^h(our)?s?/", week: "/^w(eek)?s?/", month: "/^m(onth)?s?/", day: "/^d(ay)?s?/", year: "/^y(ear)?s?/", shortMeridian: "/^(a|p)/", longMeridian: "/^(a\\.?m?\\.?|p\\.?m?\\.?)/", timezone: "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/", ordinalSuffix: "/^\\s*(st|nd|rd|th)/", timeContext: "/^\\s*(\\:|a(?!u|p)|p)/" }, Date.i18n.currentLanguage()); } }; var CultureInfo = function () { var info = getText.getFromObjectValues({ name: "name", englishName: "englishName", nativeName: "nativeName", amDesignator: "AM", pmDesignator: "PM", firstDayOfWeek: "firstDayOfWeek", twoDigitYearMax: "twoDigitYearMax", dateElementOrder: "mdy" }, Date.i18n.currentLanguage()); var constructedInfo = buildInfo.buildFromMethodHash({ dayNames: "days", abbreviatedDayNames: "dayAbbr", shortestDayNames: "dayShortNames", firstLetterDayNames: "dayFirstLetters", monthNames: "months", abbreviatedMonthNames: "monthAbbr", formatPatterns: "formatPatterns", regexPatterns: "regex", abbreviatedTimeZoneDST: "timeZoneDST", abbreviatedTimeZoneStandard: "timeZoneStandard" }); shallowMerge(info, constructedInfo); buildInfo.timeZones(info); return info; }; $D.i18n = { __: function (key, lang) { return __(key, lang); }, currentLanguage: function () { return lang || "en-US"; }, setLanguage: function (code, force, cb) { var async = false; if (force || code === "en-US" || (!!Date.CultureStrings && !!Date.CultureStrings[code])) { lang = code; Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings.lang = code; Date.CultureInfo = new CultureInfo(); } else { if (!(!!Date.CultureStrings && !!Date.CultureStrings[code])) { if (typeof exports !== "undefined" && this.exports !== exports) { // we're in a Node enviroment, load it using require try { require("../i18n/" + code + ".js"); lang = code; Date.CultureStrings.lang = code; Date.CultureInfo = new CultureInfo(); } catch (e) { // var str = "The language for '" + code + "' could not be loaded by Node. It likely does not exist."; throw new Error("The DateJS IETF language tag '" + code + "' could not be loaded by Node. It likely does not exist."); } } else if (Date.Config && Date.Config.i18n) { // we know the location of the files, so lets load them async = true; loadI18nScript(code).done(function(){ lang = code; Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings.lang = code; Date.CultureInfo = new CultureInfo(); $D.Parsing.Normalizer.buildReplaceData(); // because this is async if ($D.Grammar) { $D.Grammar.buildGrammarFormats(); // so we can parse those strings... } if (cb) { setTimeout(cb,0); } }); } else { Date.console.error("The DateJS IETF language tag '" + code + "' is not available and has not been loaded."); return false; } } } $D.Parsing.Normalizer.buildReplaceData(); // rebuild normalizer strings if ($D.Grammar) { $D.Grammar.buildGrammarFormats(); // so we can parse those strings... } if (!async && cb) { setTimeout(cb,0); } }, getLoggedKeys: function () { return loggedKeys; }, updateCultureInfo: function () { Date.CultureInfo = new CultureInfo(); } }; $D.i18n.updateCultureInfo(); // run automatically }()); (function () { var $D = Date, $P = $D.prototype, p = function (s, l) { if (!l) { l = 2; } return ("000" + s).slice(l * -1); }; if (typeof window !== "undefined" && typeof window.console !== "undefined" && typeof window.console.log !== "undefined") { $D.console = console; // used only to raise non-critical errors if available } else { // set mock so we don't give errors. $D.console = { log: function(){}, error: function(){} }; } $D.Config = $D.Config || {}; $D.initOverloads = function() { /** * Overload of Date.now. Allows an alternate call for Date.now where it returns the * current Date as an object rather than just milliseconds since the Unix Epoch. * * Also provides an implementation of now() for browsers (IE<9) that don't have it. * * Backwards compatible so with work with either: * Date.now() [returns ms] * or * Date.now(true) [returns Date] */ if (!$D.now) { $D._now = function now() { return new Date().getTime(); }; } else if (!$D._now) { $D._now = $D.now; } $D.now = function (returnObj) { if (returnObj) { return $D.present(); } else { return $D._now(); } }; if ( !$P.toISOString ) { $P.toISOString = function() { return this.getUTCFullYear() + "-" + p(this.getUTCMonth() + 1) + "-" + p(this.getUTCDate()) + "T" + p(this.getUTCHours()) + ":" + p(this.getUTCMinutes()) + ":" + p(this.getUTCSeconds()) + "." + String( (this.getUTCMilliseconds()/1000).toFixed(3)).slice(2, 5) + "Z"; }; } // private if ( $P._toString === undefined ){ $P._toString = $P.toString; } }; $D.initOverloads(); /** * Gets a date that is set to the current date. The time is set to the start of the day (00:00 or 12:00 AM). * @return {Date} The current date. */ $D.today = function () { return new Date().clearTime(); }; /** * Gets a date that is set to the current date and time (same as new Date, but chainable) * @return {Date} The current date. */ $D.present = function () { return new Date(); }; /** * Compares the first date to the second date and returns an number indication of their relative values. * @param {Date} First Date object to compare [Required]. * @param {Date} Second Date object to compare to [Required]. * @return {Number} -1 = date1 is lessthan date2. 0 = values are equal. 1 = date1 is greaterthan date2. */ $D.compare = function (date1, date2) { if (isNaN(date1) || isNaN(date2)) { throw new Error(date1 + " - " + date2); } else if (date1 instanceof Date && date2 instanceof Date) { return (date1 < date2) ? -1 : (date1 > date2) ? 1 : 0; } else { throw new TypeError(date1 + " - " + date2); } }; /** * Compares the first Date object to the second Date object and returns true if they are equal. * @param {Date} First Date object to compare [Required] * @param {Date} Second Date object to compare to [Required] * @return {Boolean} true if dates are equal. false if they are not equal. */ $D.equals = function (date1, date2) { return (date1.compareTo(date2) === 0); }; /** * Gets the language appropriate day name when given the day number(0-6) * eg - 0 == Sunday * @return {String} The day name */ $D.getDayName = function (n) { return Date.CultureInfo.dayNames[n]; }; /** * Gets the day number (0-6) if given a CultureInfo specific string which is a valid dayName, abbreviatedDayName or shortestDayName (two char). * @param {String} The name of the day (eg. "Monday, "Mon", "tuesday", "tue", "We", "we"). * @return {Number} The day number */ $D.getDayNumberFromName = function (name) { var n = Date.CultureInfo.dayNames, m = Date.CultureInfo.abbreviatedDayNames, o = Date.CultureInfo.shortestDayNames, s = name.toLowerCase(); for (var i = 0; i < n.length; i++) { if (n[i].toLowerCase() === s || m[i].toLowerCase() === s || o[i].toLowerCase() === s) { return i; } } return -1; }; /** * Gets the month number (0-11) if given a Culture Info specific string which is a valid monthName or abbreviatedMonthName. * @param {String} The name of the month (eg. "February, "Feb", "october", "oct"). * @return {Number} The day number */ $D.getMonthNumberFromName = function (name) { var n = Date.CultureInfo.monthNames, m = Date.CultureInfo.abbreviatedMonthNames, s = name.toLowerCase(); for (var i = 0; i < n.length; i++) { if (n[i].toLowerCase() === s || m[i].toLowerCase() === s) { return i; } } return -1; }; /** * Gets the language appropriate month name when given the month number(0-11) * eg - 0 == January * @return {String} The month name */ $D.getMonthName = function (n) { return Date.CultureInfo.monthNames[n]; }; /** * Determines if the current date instance is within a LeapYear. * @param {Number} The year. * @return {Boolean} true if date is within a LeapYear, otherwise false. */ $D.isLeapYear = function (year) { return ((year % 4 === 0 && year % 100 !== 0) || year % 400 === 0); }; /** * Gets the number of days in the month, given a year and month value. Automatically corrects for LeapYear. * @param {Number} The year. * @param {Number} The month (0-11). * @return {Number} The number of days in the month. */ $D.getDaysInMonth = function (year, month) { if (!month && $D.validateMonth(year)) { month = year; year = Date.today().getFullYear(); } return [31, ($D.isLeapYear(year) ? 29 : 28), 31, 30, 31, 30, 31, 31, 30, 31, 30, 31][month]; }; $P.getDaysInMonth = function () { return $D.getDaysInMonth(this.getFullYear(), this.getMonth()); }; $D.getTimezoneAbbreviation = function (offset, dst) { var p, n = (dst || false) ? Date.CultureInfo.abbreviatedTimeZoneDST : Date.CultureInfo.abbreviatedTimeZoneStandard; for (p in n) { if (n.hasOwnProperty(p)) { if (n[p] === offset) { return p; } } } return null; }; $D.getTimezoneOffset = function (name, dst) { var i, a =[], z = Date.CultureInfo.timezones; if (!name) { name = (new Date()).getTimezone();} for (i = 0; i < z.length; i++) { if (z[i].name === name.toUpperCase()) { a.push(i); } } if (!z[a[0]]) { return null; } if (a.length === 1 || !dst) { return z[a[0]].offset; } else { for (i=0; i < a.length; i++) { if (z[a[i]].dst) { return z[a[i]].offset; } } } }; $D.getQuarter = function (d) { d = d || new Date(); // If no date supplied, use today var q = [1,2,3,4]; return q[Math.floor(d.getMonth() / 3)]; // ~~~ is a bitwise op. Faster than Math.floor }; $D.getDaysLeftInQuarter = function (d) { d = d || new Date(); var qEnd = new Date(d); qEnd.setMonth(qEnd.getMonth() + 3 - qEnd.getMonth() % 3, 0); return Math.floor((qEnd - d) / 8.64e7); }; // private var validate = function (n, min, max, name) { name = name ? name : "Object"; if (typeof n === "undefined") { return false; } else if (typeof n !== "number") { throw new TypeError(n + " is not a Number."); } else if (n < min || n > max) { // As failing validation is *not* an exceptional circumstance // lets not throw a RangeError Exception here. // It's semantically correct but it's not sensible. return false; } return true; }; /** * Validates the number is within an acceptable range for milliseconds [0-999]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateMillisecond = function (value) { return validate(value, 0, 999, "millisecond"); }; /** * Validates the number is within an acceptable range for seconds [0-59]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateSecond = function (value) { return validate(value, 0, 59, "second"); }; /** * Validates the number is within an acceptable range for minutes [0-59]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateMinute = function (value) { return validate(value, 0, 59, "minute"); }; /** * Validates the number is within an acceptable range for hours [0-23]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateHour = function (value) { return validate(value, 0, 23, "hour"); }; /** * Validates the number is within an acceptable range for the days in a month [0-MaxDaysInMonth]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateDay = function (value, year, month) { if (year === undefined || year === null || month === undefined || month === null) { return false;} return validate(value, 1, $D.getDaysInMonth(year, month), "day"); }; /** * Validates the number is within an acceptable range for months [0-11]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateWeek = function (value) { return validate(value, 0, 53, "week"); }; /** * Validates the number is within an acceptable range for months [0-11]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateMonth = function (value) { return validate(value, 0, 11, "month"); }; /** * Validates the number is within an acceptable range for years. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateYear = function (value) { /** * Per ECMAScript spec the range of times supported by Date objects is * exactly -100,000,000 days to +100,000,000 days measured relative to * midnight at the beginning of 01 January, 1970 UTC. * This gives a range of 8,640,000,000,000,000 milliseconds to either * side of 01 January, 1970 UTC. * * Earliest possible date: Tue, 20 Apr 271,822 B.C. 00:00:00 UTC * Latest possible date: Sat, 13 Sep 275,760 00:00:00 UTC */ return validate(value, -271822, 275760, "year"); }; $D.validateTimezone = function(value) { var timezones = {"ACDT":1,"ACST":1,"ACT":1,"ADT":1,"AEDT":1,"AEST":1,"AFT":1,"AKDT":1,"AKST":1,"AMST":1,"AMT":1,"ART":1,"AST":1,"AWDT":1,"AWST":1,"AZOST":1,"AZT":1,"BDT":1,"BIOT":1,"BIT":1,"BOT":1,"BRT":1,"BST":1,"BTT":1,"CAT":1,"CCT":1,"CDT":1,"CEDT":1,"CEST":1,"CET":1,"CHADT":1,"CHAST":1,"CHOT":1,"ChST":1,"CHUT":1,"CIST":1,"CIT":1,"CKT":1,"CLST":1,"CLT":1,"COST":1,"COT":1,"CST":1,"CT":1,"CVT":1,"CWST":1,"CXT":1,"DAVT":1,"DDUT":1,"DFT":1,"EASST":1,"EAST":1,"EAT":1,"ECT":1,"EDT":1,"EEDT":1,"EEST":1,"EET":1,"EGST":1,"EGT":1,"EIT":1,"EST":1,"FET":1,"FJT":1,"FKST":1,"FKT":1,"FNT":1,"GALT":1,"GAMT":1,"GET":1,"GFT":1,"GILT":1,"GIT":1,"GMT":1,"GST":1,"GYT":1,"HADT":1,"HAEC":1,"HAST":1,"HKT":1,"HMT":1,"HOVT":1,"HST":1,"ICT":1,"IDT":1,"IOT":1,"IRDT":1,"IRKT":1,"IRST":1,"IST":1,"JST":1,"KGT":1,"KOST":1,"KRAT":1,"KST":1,"LHST":1,"LINT":1,"MAGT":1,"MART":1,"MAWT":1,"MDT":1,"MET":1,"MEST":1,"MHT":1,"MIST":1,"MIT":1,"MMT":1,"MSK":1,"MST":1,"MUT":1,"MVT":1,"MYT":1,"NCT":1,"NDT":1,"NFT":1,"NPT":1,"NST":1,"NT":1,"NUT":1,"NZDT":1,"NZST":1,"OMST":1,"ORAT":1,"PDT":1,"PET":1,"PETT":1,"PGT":1,"PHOT":1,"PHT":1,"PKT":1,"PMDT":1,"PMST":1,"PONT":1,"PST":1,"PYST":1,"PYT":1,"RET":1,"ROTT":1,"SAKT":1,"SAMT":1,"SAST":1,"SBT":1,"SCT":1,"SGT":1,"SLST":1,"SRT":1,"SST":1,"SYOT":1,"TAHT":1,"THA":1,"TFT":1,"TJT":1,"TKT":1,"TLT":1,"TMT":1,"TOT":1,"TVT":1,"UCT":1,"ULAT":1,"UTC":1,"UYST":1,"UYT":1,"UZT":1,"VET":1,"VLAT":1,"VOLT":1,"VOST":1,"VUT":1,"WAKT":1,"WAST":1,"WAT":1,"WEDT":1,"WEST":1,"WET":1,"WST":1,"YAKT":1,"YEKT":1,"Z":1}; return (timezones[value] === 1); }; $D.validateTimezoneOffset= function(value) { // timezones go from +14hrs to -12hrs, the +X hours are negative offsets. return (value > -841 && value < 721); }; }()); (function () { var $D = Date, $P = $D.prototype, p = function (s, l) { if (!l) { l = 2; } return ("000" + s).slice(l * -1); }; var validateConfigObject = function (obj) { var result = {}, self = this, prop, testFunc; testFunc = function (prop, func, value) { if (prop === "day") { var month = (obj.month !== undefined) ? obj.month : self.getMonth(); var year = (obj.year !== undefined) ? obj.year : self.getFullYear(); return $D[func](value, year, month); } else { return $D[func](value); } }; for (prop in obj) { if (Object.prototype.hasOwnProperty.call(obj, prop)) { var func = "validate" + prop.charAt(0).toUpperCase() + prop.slice(1); if ($D[func] && obj[prop] !== null && testFunc(prop, func, obj[prop])) { result[prop] = obj[prop]; } } } return result; }; /** * Resets the time of this Date object to 12:00 AM (00:00), which is the start of the day. * @param {Boolean} .clone() this date instance before clearing Time * @return {Date} this */ $P.clearTime = function () { this.setHours(0); this.setMinutes(0); this.setSeconds(0); this.setMilliseconds(0); return this; }; /** * Resets the time of this Date object to the current time ('now'). * @return {Date} this */ $P.setTimeToNow = function () { var n = new Date(); this.setHours(n.getHours()); this.setMinutes(n.getMinutes()); this.setSeconds(n.getSeconds()); this.setMilliseconds(n.getMilliseconds()); return this; }; /** * Returns a new Date object that is an exact date and time copy of the original instance. * @return {Date} A new Date instance */ $P.clone = function () { return new Date(this.getTime()); }; /** * Compares this instance to a Date object and returns an number indication of their relative values. * @param {Date} Date object to compare [Required] * @return {Number} -1 = this is lessthan date. 0 = values are equal. 1 = this is greaterthan date. */ $P.compareTo = function (date) { return Date.compare(this, date); }; /** * Compares this instance to another Date object and returns true if they are equal. * @param {Date} Date object to compare. If no date to compare, new Date() [now] is used. * @return {Boolean} true if dates are equal. false if they are not equal. */ $P.equals = function (date) { return Date.equals(this, (date !== undefined ? date : new Date())); }; /** * Determines if this instance is between a range of two dates or equal to either the start or end dates. * @param {Date} Start of range [Required] * @param {Date} End of range [Required] * @return {Boolean} true is this is between or equal to the start and end dates, else false */ $P.between = function (start, end) { return this.getTime() >= start.getTime() && this.getTime() <= end.getTime(); }; /** * Determines if this date occurs after the date to compare to. * @param {Date} Date object to compare. If no date to compare, new Date() ("now") is used. * @return {Boolean} true if this date instance is greater than the date to compare to (or "now"), otherwise false. */ $P.isAfter = function (date) { return this.compareTo(date || new Date()) === 1; }; /** * Determines if this date occurs before the date to compare to. * @param {Date} Date object to compare. If no date to compare, new Date() ("now") is used. * @return {Boolean} true if this date instance is less than the date to compare to (or "now"). */ $P.isBefore = function (date) { return (this.compareTo(date || new Date()) === -1); }; /** * Determines if the current Date instance occurs today. * @return {Boolean} true if this date instance is 'today', otherwise false. */ /** * Determines if the current Date instance occurs on the same Date as the supplied 'date'. * If no 'date' to compare to is provided, the current Date instance is compared to 'today'. * @param {date} Date object to compare. If no date to compare, the current Date ("now") is used. * @return {Boolean} true if this Date instance occurs on the same Day as the supplied 'date'. */ $P.isToday = $P.isSameDay = function (date) { return this.clone().clearTime().equals((date || new Date()).clone().clearTime()); }; /** * Adds the specified number of milliseconds to this instance. * @param {Number} The number of milliseconds to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addMilliseconds = function (value) { if (!value) { return this; } this.setTime(this.getTime() + value * 1); return this; }; /** * Adds the specified number of seconds to this instance. * @param {Number} The number of seconds to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addSeconds = function (value) { if (!value) { return this; } return this.addMilliseconds(value * 1000); }; /** * Adds the specified number of seconds to this instance. * @param {Number} The number of seconds to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addMinutes = function (value) { if (!value) { return this; } return this.addMilliseconds(value * 60000); // 60*1000 }; /** * Adds the specified number of hours to this instance. * @param {Number} The number of hours to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addHours = function (value) { if (!value) { return this; } return this.addMilliseconds(value * 3600000); // 60*60*1000 }; /** * Adds the specified number of days to this instance. * @param {Number} The number of days to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addDays = function (value) { if (!value) { return this; } this.setDate(this.getDate() + value * 1); return this; }; /** * Adds the specified number of weekdays (ie - not sat or sun) to this instance. * @param {Number} The number of days to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addWeekdays = function (value) { if (!value) { return this; } var day = this.getDay(); var weeks = (Math.ceil(Math.abs(value)/7)); if (day === 0 || day === 6) { if (value > 0) { this.next().monday(); this.addDays(-1); day = this.getDay(); } } if (value < 0) { while (value < 0) { this.addDays(-1); day = this.getDay(); if (day !== 0 && day !== 6) { value++; } } return this; } else if (value > 5 || (6-day) <= value) { value = value + (weeks * 2); } return this.addDays(value); }; /** * Adds the specified number of weeks to this instance. * @param {Number} The number of weeks to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addWeeks = function (value) { if (!value) { return this; } return this.addDays(value * 7); }; /** * Adds the specified number of months to this instance. * @param {Number} The number of months to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addMonths = function (value) { if (!value) { return this; } var n = this.getDate(); this.setDate(1); this.setMonth(this.getMonth() + value * 1); this.setDate(Math.min(n, $D.getDaysInMonth(this.getFullYear(), this.getMonth()))); return this; }; $P.addQuarters = function (value) { if (!value) { return this; } // note this will take you to the same point in the quarter as you are now. // i.e. - if you are 15 days into the quarter you'll be 15 days into the resulting one. // bonus: this allows adding fractional quarters return this.addMonths(value * 3); }; /** * Adds the specified number of years to this instance. * @param {Number} The number of years to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addYears = function (value) { if (!value) { return this; } return this.addMonths(value * 12); }; /** * Adds (or subtracts) to the value of the years, months, weeks, days, hours, minutes, seconds, milliseconds of the date instance using given configuration object. Positive and Negative values allowed. * Example

	Date.today().add( { days: 1, months: 1 } )

	new Date().add( { years: -1 } )
	
* @param {Object} Configuration object containing attributes (months, days, etc.) * @return {Date} this */ $P.add = function (config) { if (typeof config === "number") { this._orient = config; return this; } var x = config; if (x.day) { // If we should be a different date than today (eg: for 'tomorrow -1d', etc). // Should only effect parsing, not direct usage (eg, Finish and FinishExact) if ((x.day - this.getDate()) !== 0) { this.setDate(x.day); } } if (x.milliseconds) { this.addMilliseconds(x.milliseconds); } if (x.seconds) { this.addSeconds(x.seconds); } if (x.minutes) { this.addMinutes(x.minutes); } if (x.hours) { this.addHours(x.hours); } if (x.weeks) { this.addWeeks(x.weeks); } if (x.months) { this.addMonths(x.months); } if (x.years) { this.addYears(x.years); } if (x.days) { this.addDays(x.days); } return this; }; /** * Get the week number. Week one (1) is the week which contains the first Thursday of the year. Monday is considered the first day of the week. * The .getWeek() function does NOT convert the date to UTC. The local datetime is used. * Please use .getISOWeek() to get the week of the UTC converted date. * @return {Number} 1 to 53 */ $P.getWeek = function (utc) { // Create a copy of this date object var self, target = new Date(this.valueOf()); if (utc) { target.addMinutes(target.getTimezoneOffset()); self = target.clone(); } else { self = this; } // ISO week date weeks start on monday // so correct the day number var dayNr = (self.getDay() + 6) % 7; // ISO 8601 states that week 1 is the week // with the first thursday of that year. // Set the target date to the thursday in the target week target.setDate(target.getDate() - dayNr + 3); // Store the millisecond value of the target date var firstThursday = target.valueOf(); // Set the target to the first thursday of the year // First set the target to january first target.setMonth(0, 1); // Not a thursday? Correct the date to the next thursday if (target.getDay() !== 4) { target.setMonth(0, 1 + ((4 - target.getDay()) + 7) % 7); } // The weeknumber is the number of weeks between the // first thursday of the year and the thursday in the target week return 1 + Math.ceil((firstThursday - target) / 604800000); // 604800000 = 7 * 24 * 3600 * 1000 }; /** * Get the ISO 8601 week number. Week one ("01") is the week which contains the first Thursday of the year. Monday is considered the first day of the week. * The .getISOWeek() function does convert the date to it's UTC value. Please use .getWeek() to get the week of the local date. * @return {String} "01" to "53" */ $P.getISOWeek = function () { return p(this.getWeek(true)); }; /** * Moves the date to Monday of the week set. Week one (1) is the week which contains the first Thursday of the year. * @param {Number} A Number (1 to 53) that represents the week of the year. * @return {Date} this */ $P.setWeek = function (n) { if ((n - this.getWeek()) === 0) { if (this.getDay() !== 1) { return this.moveToDayOfWeek(1, (this.getDay() > 1 ? -1 : 1)); } else { return this; } } else { return this.moveToDayOfWeek(1, (this.getDay() > 1 ? -1 : 1)).addWeeks(n - this.getWeek()); } }; $P.setQuarter = function (qtr) { var month = Math.abs(((qtr-1) * 3) + 1); return this.setMonth(month, 1); }; $P.getQuarter = function () { return Date.getQuarter(this); }; $P.getDaysLeftInQuarter = function () { return Date.getDaysLeftInQuarter(this); }; /** * Moves the date to the next n'th occurrence of the dayOfWeek starting from the beginning of the month. The number (-1) is a magic number and will return the last occurrence of the dayOfWeek in the month. * @param {Number} The dayOfWeek to move to * @param {Number} The n'th occurrence to move to. Use (-1) to return the last occurrence in the month * @return {Date} this */ $P.moveToNthOccurrence = function (dayOfWeek, occurrence) { if (dayOfWeek === "Weekday") { if (occurrence > 0) { this.moveToFirstDayOfMonth(); if (this.is().weekday()) { occurrence -= 1; } } else if (occurrence < 0) { this.moveToLastDayOfMonth(); if (this.is().weekday()) { occurrence += 1; } } else { return this; } return this.addWeekdays(occurrence); } var shift = 0; if (occurrence > 0) { shift = occurrence - 1; } else if (occurrence === -1) { this.moveToLastDayOfMonth(); if (this.getDay() !== dayOfWeek) { this.moveToDayOfWeek(dayOfWeek, -1); } return this; } return this.moveToFirstDayOfMonth().addDays(-1).moveToDayOfWeek(dayOfWeek, +1).addWeeks(shift); }; var moveToN = function (getFunc, addFunc, nVal) { return function (value, orient) { var diff = (value - this[getFunc]() + nVal * (orient || +1)) % nVal; return this[addFunc]((diff === 0) ? diff += nVal * (orient || +1) : diff); }; }; /** * Move to the next or last dayOfWeek based on the orient value. * @param {Number} The dayOfWeek to move to * @param {Number} Forward (+1) or Back (-1). Defaults to +1. [Optional] * @return {Date} this */ $P.moveToDayOfWeek = moveToN("getDay", "addDays", 7); /** * Move to the next or last month based on the orient value. * @param {Number} The month to move to. 0 = January, 11 = December * @param {Number} Forward (+1) or Back (-1). Defaults to +1. [Optional] * @return {Date} this */ $P.moveToMonth = moveToN("getMonth", "addMonths", 12); /** * Get the Ordinate of the current day ("th", "st", "rd"). * @return {String} */ $P.getOrdinate = function () { var num = this.getDate(); return ord(num); }; /** * Get the Ordinal day (numeric day number) of the year, adjusted for leap year. * @return {Number} 1 through 365 (366 in leap years) */ $P.getOrdinalNumber = function () { return Math.ceil((this.clone().clearTime() - new Date(this.getFullYear(), 0, 1)) / 86400000) + 1; }; /** * Get the time zone abbreviation of the current date. * @return {String} The abbreviated time zone name (e.g. "EST") */ $P.getTimezone = function () { return $D.getTimezoneAbbreviation(this.getUTCOffset(), this.isDaylightSavingTime()); }; $P.setTimezoneOffset = function (offset) { var here = this.getTimezoneOffset(), there = Number(offset) * -6 / 10; return (there || there === 0) ? this.addMinutes(there - here) : this; }; $P.setTimezone = function (offset) { return this.setTimezoneOffset($D.getTimezoneOffset(offset)); }; /** * Indicates whether Daylight Saving Time is observed in the current time zone. * @return {Boolean} true|false */ $P.hasDaylightSavingTime = function () { return (Date.today().set({month: 0, day: 1}).getTimezoneOffset() !== Date.today().set({month: 6, day: 1}).getTimezoneOffset()); }; /** * Indicates whether this Date instance is within the Daylight Saving Time range for the current time zone. * @return {Boolean} true|false */ $P.isDaylightSavingTime = function () { return Date.today().set({month: 0, day: 1}).getTimezoneOffset() !== this.getTimezoneOffset(); }; /** * Get the offset from UTC of the current date. * @return {String} The 4-character offset string prefixed with + or - (e.g. "-0500") */ $P.getUTCOffset = function (offset) { var n = (offset || this.getTimezoneOffset()) * -10 / 6, r; if (n < 0) { r = (n - 10000).toString(); return r.charAt(0) + r.substr(2); } else { r = (n + 10000).toString(); return "+" + r.substr(1); } }; /** * Returns the number of milliseconds between this date and date. * @param {Date} Defaults to now * @return {Number} The diff in milliseconds */ $P.getElapsed = function (date) { return (date || new Date()) - this; }; /** * Set the value of year, month, day, hour, minute, second, millisecond of date instance using given configuration object. * Example

	Date.today().set( { day: 20, month: 1 } )

	new Date().set( { millisecond: 0 } )
	
* * @param {Object} Configuration object containing attributes (month, day, etc.) * @return {Date} this */ $P.set = function (config) { config = validateConfigObject.call(this, config); var key; for (key in config) { if (Object.prototype.hasOwnProperty.call(config, key)) { var name = key.charAt(0).toUpperCase() + key.slice(1); var addFunc, getFunc; if (key !== "week" && key !== "month" && key !== "timezone" && key !== "timezoneOffset") { name += "s"; } addFunc = "add" + name; getFunc = "get" + name; if (key === "month") { addFunc = addFunc + "s"; } else if (key === "year"){ getFunc = "getFullYear"; } if (key !== "day" && key !== "timezone" && key !== "timezoneOffset" && key !== "week" && key !== "hour") { this[addFunc](config[key] - this[getFunc]()); } else if ( key === "timezone"|| key === "timezoneOffset" || key === "week" || key === "hour") { this["set"+name](config[key]); } } } // day has to go last because you can't validate the day without first knowing the month if (config.day) { this.addDays(config.day - this.getDate()); } return this; }; /** * Moves the date to the first day of the month. * @return {Date} this */ $P.moveToFirstDayOfMonth = function () { return this.set({ day: 1 }); }; /** * Moves the date to the last day of the month. * @return {Date} this */ $P.moveToLastDayOfMonth = function () { return this.set({ day: $D.getDaysInMonth(this.getFullYear(), this.getMonth())}); }; /** * Converts the value of the current Date object to its equivalent string representation. * Format Specifiers * CUSTOM DATE AND TIME FORMAT STRINGS * Format Description Example * ------ --------------------------------------------------------------------------- ----------------------- * s The seconds of the minute between 0-59. "0" to "59" * ss The seconds of the minute with leading zero if required. "00" to "59" * * m The minute of the hour between 0-59. "0" or "59" * mm The minute of the hour with leading zero if required. "00" or "59" * * h The hour of the day between 1-12. "1" to "12" * hh The hour of the day with leading zero if required. "01" to "12" * * H The hour of the day between 0-23. "0" to "23" * HH The hour of the day with leading zero if required. "00" to "23" * * d The day of the month between 1 and 31. "1" to "31" * dd The day of the month with leading zero if required. "01" to "31" * ddd Abbreviated day name. Date.CultureInfo.abbreviatedDayNames. "Mon" to "Sun" * dddd The full day name. Date.CultureInfo.dayNames. "Monday" to "Sunday" * * M The month of the year between 1-12. "1" to "12" * MM The month of the year with leading zero if required. "01" to "12" * MMM Abbreviated month name. Date.CultureInfo.abbreviatedMonthNames. "Jan" to "Dec" * MMMM The full month name. Date.CultureInfo.monthNames. "January" to "December" * * yy The year as a two-digit number. "99" or "08" * yyyy The full four digit year. "1999" or "2008" * * t Displays the first character of the A.M./P.M. designator. "A" or "P" * Date.CultureInfo.amDesignator or Date.CultureInfo.pmDesignator * tt Displays the A.M./P.M. designator. "AM" or "PM" * Date.CultureInfo.amDesignator or Date.CultureInfo.pmDesignator * * S The ordinal suffix ("st, "nd", "rd" or "th") of the current day. "st, "nd", "rd" or "th" * * STANDARD DATE AND TIME FORMAT STRINGS * Format Description Example *------ --------------------------------------------------------------------------- ----------------------- * d The CultureInfo shortDate Format Pattern "M/d/yyyy" * D The CultureInfo longDate Format Pattern "dddd, MMMM dd, yyyy" * F The CultureInfo fullDateTime Format Pattern "dddd, MMMM dd, yyyy h:mm:ss tt" * m The CultureInfo monthDay Format Pattern "MMMM dd" * r The CultureInfo rfc1123 Format Pattern "ddd, dd MMM yyyy HH:mm:ss GMT" * s The CultureInfo sortableDateTime Format Pattern "yyyy-MM-ddTHH:mm:ss" * t The CultureInfo shortTime Format Pattern "h:mm tt" * T The CultureInfo longTime Format Pattern "h:mm:ss tt" * u The CultureInfo universalSortableDateTime Format Pattern "yyyy-MM-dd HH:mm:ssZ" * y The CultureInfo yearMonth Format Pattern "MMMM, yyyy" * * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @return {String} A string representation of the current Date object. */ var ord = function (n) { switch (n * 1) { case 1: case 21: case 31: return "st"; case 2: case 22: return "nd"; case 3: case 23: return "rd"; default: return "th"; } }; var parseStandardFormats = function (format) { var y, c = Date.CultureInfo.formatPatterns; switch (format) { case "d": return this.toString(c.shortDate); case "D": return this.toString(c.longDate); case "F": return this.toString(c.fullDateTime); case "m": return this.toString(c.monthDay); case "r": case "R": y = this.clone().addMinutes(this.getTimezoneOffset()); return y.toString(c.rfc1123) + " GMT"; case "s": return this.toString(c.sortableDateTime); case "t": return this.toString(c.shortTime); case "T": return this.toString(c.longTime); case "u": y = this.clone().addMinutes(this.getTimezoneOffset()); return y.toString(c.universalSortableDateTime); case "y": return this.toString(c.yearMonth); default: return false; } }; var parseFormatStringsClosure = function (context) { return function (m) { if (m.charAt(0) === "\\") { return m.replace("\\", ""); } switch (m) { case "hh": return p(context.getHours() < 13 ? (context.getHours() === 0 ? 12 : context.getHours()) : (context.getHours() - 12)); case "h": return context.getHours() < 13 ? (context.getHours() === 0 ? 12 : context.getHours()) : (context.getHours() - 12); case "HH": return p(context.getHours()); case "H": return context.getHours(); case "mm": return p(context.getMinutes()); case "m": return context.getMinutes(); case "ss": return p(context.getSeconds()); case "s": return context.getSeconds(); case "yyyy": return p(context.getFullYear(), 4); case "yy": return p(context.getFullYear()); case "y": return context.getFullYear(); case "E": case "dddd": return Date.CultureInfo.dayNames[context.getDay()]; case "ddd": return Date.CultureInfo.abbreviatedDayNames[context.getDay()]; case "dd": return p(context.getDate()); case "d": return context.getDate(); case "MMMM": return Date.CultureInfo.monthNames[context.getMonth()]; case "MMM": return Date.CultureInfo.abbreviatedMonthNames[context.getMonth()]; case "MM": return p((context.getMonth() + 1)); case "M": return context.getMonth() + 1; case "t": return context.getHours() < 12 ? Date.CultureInfo.amDesignator.substring(0, 1) : Date.CultureInfo.pmDesignator.substring(0, 1); case "tt": return context.getHours() < 12 ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator; case "S": return ord(context.getDate()); case "W": return context.getWeek(); case "WW": return context.getISOWeek(); case "Q": return "Q" + context.getQuarter(); case "q": return String(context.getQuarter()); case "z": return context.getTimezone(); case "Z": case "X": return Date.getTimezoneOffset(context.getTimezone()); case "ZZ": // Timezone offset in seconds return context.getTimezoneOffset() * -60; case "u": return context.getDay(); case "L": return ($D.isLeapYear(context.getFullYear())) ? 1 : 0; case "B": // Swatch Internet Time (.beats) return "@"+((context.getUTCSeconds() + (context.getUTCMinutes()*60) + ((context.getUTCHours()+1)*3600))/86.4); default: return m; } }; }; $P.toString = function (format, ignoreStandards) { // Standard Date and Time Format Strings. Formats pulled from CultureInfo file and // may vary by culture. if (!ignoreStandards && format && format.length === 1) { output = parseStandardFormats.call(this, format); if (output) { return output; } } var parseFormatStrings = parseFormatStringsClosure(this); return format ? format.replace(/((\\)?(dd?d?d?|MM?M?M?|yy?y?y?|hh?|HH?|mm?|ss?|tt?|S|q|Q|WW?W?W?)(?![^\[]*\]))/g, parseFormatStrings).replace(/\[|\]/g, "") : this._toString(); }; }()); /************************************************************* * SugarPak - Domain Specific Language - Syntactical Sugar * *************************************************************/ (function () { var $D = Date, $P = $D.prototype, $N = Number.prototype; // private $P._orient = +1; // private $P._nth = null; // private $P._is = false; // private $P._same = false; // private $P._isSecond = false; // private $N._dateElement = "days"; /** * Moves the date to the next instance of a date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.today().next().friday();
	Date.today().next().fri();
	Date.today().next().march();
	Date.today().next().mar();
	Date.today().next().week();
	
* * @return {Date} date */ $P.next = function () { this._move = true; this._orient = +1; return this; }; /** * Creates a new Date (Date.today()) and moves the date to the next instance of the date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.next().friday();
	Date.next().fri();
	Date.next().march();
	Date.next().mar();
	Date.next().week();
	
* * @return {Date} date */ $D.next = function () { return $D.today().next(); }; /** * Moves the date to the previous instance of a date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.today().last().friday();
	Date.today().last().fri();
	Date.today().last().march();
	Date.today().last().mar();
	Date.today().last().week();
	
* * @return {Date} date */ $P.last = $P.prev = $P.previous = function () { this._move = true; this._orient = -1; return this; }; /** * Creates a new Date (Date.today()) and moves the date to the previous instance of the date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.last().friday();
	Date.last().fri();
	Date.previous().march();
	Date.prev().mar();
	Date.last().week();
	
* * @return {Date} date */ $D.last = $D.prev = $D.previous = function () { return $D.today().last(); }; /** * Performs a equality check when followed by either a month name, day name or .weekday() function. * Example

	Date.today().is().friday(); // true|false
	Date.today().is().fri();
	Date.today().is().march();
	Date.today().is().mar();
	
* * @return {Boolean} true|false */ $P.is = function () { this._is = true; return this; }; /** * Determines if two date objects occur on/in exactly the same instance of the subsequent date part function. * The function .same() must be followed by a date part function (example: .day(), .month(), .year(), etc). * * An optional Date can be passed in the date part function. If now date is passed as a parameter, 'Now' is used. * * The following example demonstrates how to determine if two dates fall on the exact same day. * * Example

	var d1 = Date.today(); // today at 00:00
	var d2 = new Date();   // exactly now.

	// Do they occur on the same day?
	d1.same().day(d2); // true
	
	// Do they occur on the same hour?
	d1.same().hour(d2); // false, unless d2 hour is '00' (midnight).
	
	// What if it's the same day, but one year apart?
	var nextYear = Date.today().add(1).year();

	d1.same().day(nextYear); // false, because the dates must occur on the exact same day. 
	
* * Scenario: Determine if a given date occurs during some week period 2 months from now. * * Example

	var future = Date.today().add(2).months();
	return someDate.same().week(future); // true|false;
	
* * @return {Boolean} true|false */ $P.same = function () { this._same = true; this._isSecond = false; return this; }; /** * Determines if the current date/time occurs during Today. Must be preceded by the .is() function. * Example

	someDate.is().today();    // true|false
	new Date().is().today();  // true
	Date.today().is().today();// true
	Date.today().add(-1).day().is().today(); // false
	
* * @return {Boolean} true|false */ $P.today = function () { return this.same().day(); }; /** * Determines if the current date is a weekday. This function must be preceded by the .is() function. * Example

	Date.today().is().weekday(); // true|false
	
* * @return {Boolean} true|false */ $P.weekday = function () { if (this._nth) { return df("Weekday").call(this); } if (this._move) { return this.addWeekdays(this._orient); } if (this._is) { this._is = false; return (!this.is().sat() && !this.is().sun()); } return false; }; /** * Determines if the current date is on the weekend. This function must be preceded by the .is() function. * Example

	Date.today().is().weekend(); // true|false
	
* * @return {Boolean} true|false */ $P.weekend = function () { if (this._is) { this._is = false; return (this.is().sat() || this.is().sun()); } return false; }; /** * Sets the Time of the current Date instance. A string "6:15 pm" or config object {hour:18, minute:15} are accepted. * Example

	// Set time to 6:15pm with a String
	Date.today().at("6:15pm");

	// Set time to 6:15pm with a config object
	Date.today().at({hour:18, minute:15});
	
* * @return {Date} date */ $P.at = function (time) { return (typeof time === "string") ? $D.parse(this.toString("d") + " " + time) : this.set(time); }; /** * Creates a new Date() and adds this (Number) to the date based on the preceding date element function (eg. second|minute|hour|day|month|year). * Example

	// Undeclared Numbers must be wrapped with parentheses. Requirment of JavaScript.
	(3).days().fromNow();
	(6).months().fromNow();

	// Declared Number variables do not require parentheses. 
	var n = 6;
	n.months().fromNow();
	
* * @return {Date} A new Date instance */ $N.fromNow = $N.after = function (date) { var c = {}; c[this._dateElement] = this; return ((!date) ? new Date() : date.clone()).add(c); }; /** * Creates a new Date() and subtract this (Number) from the date based on the preceding date element function (eg. second|minute|hour|day|month|year). * Example

	// Undeclared Numbers must be wrapped with parentheses. Requirment of JavaScript.
	(3).days().ago();
	(6).months().ago();

	// Declared Number variables do not require parentheses. 
	var n = 6;
	n.months().ago();
	
* * @return {Date} A new Date instance */ $N.ago = $N.before = function (date) { var c = {}, s = (this._dateElement[this._dateElement.length-1] !== "s") ? this._dateElement + "s" : this._dateElement; c[s] = this * -1; return ((!date) ? new Date() : date.clone()).add(c); }; // Do NOT modify the following string tokens. These tokens are used to build dynamic functions. // All culture-specific strings can be found in the CultureInfo files. var dx = ("sunday monday tuesday wednesday thursday friday saturday").split(/\s/), mx = ("january february march april may june july august september october november december").split(/\s/), px = ("Millisecond Second Minute Hour Day Week Month Year Quarter Weekday").split(/\s/), pxf = ("Milliseconds Seconds Minutes Hours Date Week Month FullYear Quarter").split(/\s/), nth = ("final first second third fourth fifth").split(/\s/), de; /** * Returns an object literal of all the date parts. * Example

	var o = new Date().toObject();
	
	// { year: 2008, month: 4, week: 20, day: 13, hour: 18, minute: 9, second: 32, millisecond: 812 }
	
	// The object properties can be referenced directly from the object.
	
	alert(o.day);  // alerts "13"
	alert(o.year); // alerts "2008"
	
* * @return {Date} An object literal representing the original date object. */ $P.toObject = function () { var o = {}; for (var i = 0; i < px.length; i++) { if (this["get" + pxf[i]]) { o[px[i].toLowerCase()] = this["get" + pxf[i]](); } } return o; }; /** * Returns a date created from an object literal. Ignores the .week property if set in the config. * Example

	var o = new Date().toObject();
	
	return Date.fromObject(o); // will return the same date. 

	var o2 = {month: 1, day: 20, hour: 18}; // birthday party!
	Date.fromObject(o2);
	
* * @return {Date} An object literal representing the original date object. */ $D.fromObject = function(config) { config.week = null; return Date.today().set(config); }; // Create day name functions and abbreviated day name functions (eg. monday(), friday(), fri()). var df = function (n) { return function () { if (this._is) { this._is = false; return this.getDay() === n; } if (this._move) { this._move = null; } if (this._nth !== null) { // If the .second() function was called earlier, remove the _orient // from the date, and then continue. // This is required because 'second' can be used in two different context. // // Example // // Date.today().add(1).second(); // Date.march().second().monday(); // // Things get crazy with the following... // Date.march().add(1).second().second().monday(); // but it works!! // if (this._isSecond) { this.addSeconds(this._orient * -1); } // make sure we reset _isSecond this._isSecond = false; var ntemp = this._nth; this._nth = null; var temp = this.clone().moveToLastDayOfMonth(); this.moveToNthOccurrence(n, ntemp); if (this > temp) { throw new RangeError($D.getDayName(n) + " does not occur " + ntemp + " times in the month of " + $D.getMonthName(temp.getMonth()) + " " + temp.getFullYear() + "."); } return this; } return this.moveToDayOfWeek(n, this._orient); }; }; var sdf = function (n) { return function () { var t = $D.today(), shift = n - t.getDay(); if (n === 0 && Date.CultureInfo.firstDayOfWeek === 1 && t.getDay() !== 0) { shift = shift + 7; } return t.addDays(shift); }; }; // Create month name functions and abbreviated month name functions (eg. january(), march(), mar()). var month_instance_functions = function (n) { return function () { if (this._is) { this._is = false; return this.getMonth() === n; } return this.moveToMonth(n, this._orient); }; }; var month_static_functions = function (n) { return function () { return $D.today().set({ month: n, day: 1 }); }; }; var processTerms = function (names, staticFunc, instanceFunc) { for (var i = 0; i < names.length; i++) { // Create constant static Name variables. $D[names[i].toUpperCase()] = $D[names[i].toUpperCase().substring(0, 3)] = i; // Create Name functions. $D[names[i]] = $D[names[i].substring(0, 3)] = staticFunc(i); // Create Name instance functions. $P[names[i]] = $P[names[i].substring(0, 3)] = instanceFunc(i); } }; processTerms(dx, sdf, df); processTerms(mx, month_static_functions, month_instance_functions); // Create date element functions and plural date element functions used with Date (eg. day(), days(), months()). var ef = function (j) { return function () { // if the .second() function was called earlier, the _orient // has alread been added. Just return this and reset _isSecond. if (this._isSecond) { this._isSecond = false; return this; } if (this._same) { this._same = this._is = false; var o1 = this.toObject(), o2 = (arguments[0] || new Date()).toObject(), v = "", k = j.toLowerCase(); // the substr trick with -1 doesn't work in IE8 or less k = (k[k.length-1] === "s") ? k.substring(0,k.length-1) : k; for (var m = (px.length - 1); m > -1; m--) { v = px[m].toLowerCase(); if (o1[v] !== o2[v]) { return false; } if (k === v) { break; } } return true; } if (j.substring(j.length - 1) !== "s") { j += "s"; } if (this._move) { this._move = null; } return this["add" + j](this._orient); }; }; var nf = function (n) { return function () { this._dateElement = n; return this; }; }; for (var k = 0; k < px.length; k++) { de = px[k].toLowerCase(); if(de !== "weekday") { // Create date element functions and plural date element functions used with Date (eg. day(), days(), months()). $P[de] = $P[de + "s"] = ef(px[k]); // Create date element functions and plural date element functions used with Number (eg. day(), days(), months()). $N[de] = $N[de + "s"] = nf(de + "s"); } } $P._ss = ef("Second"); var nthfn = function (n) { return function (dayOfWeek) { if (this._same) { return this._ss(arguments[0]); } if (dayOfWeek || dayOfWeek === 0) { return this.moveToNthOccurrence(dayOfWeek, n); } this._nth = n; // if the operator is 'second' add the _orient, then deal with it later... if (n === 2 && (dayOfWeek === undefined || dayOfWeek === null)) { this._isSecond = true; return this.addSeconds(this._orient); } return this; }; }; for (var l = 0; l < nth.length; l++) { $P[nth[l]] = (l === 0) ? nthfn(-1) : nthfn(l); } }()); (function () { "use strict"; Date.Parsing = { Exception: function (s) { this.message = "Parse error at '" + s.substring(0, 10) + " ...'"; } }; var $P = Date.Parsing; var dayOffsets = { standard: [0,31,59,90,120,151,181,212,243,273,304,334], leap: [0,31,60,91,121,152,182,213,244,274,305,335] }; $P.isLeapYear = function(year) { return ((year % 4 === 0) && (year % 100 !== 0)) || (year % 400 === 0); }; var utils = { multiReplace : function (str, hash ) { var key; for (key in hash) { if (Object.prototype.hasOwnProperty.call(hash, key)) { var regex; if (typeof hash[key] === "function") { } else { regex = (hash[key] instanceof RegExp) ? hash[key] : new RegExp(hash[key], "g"); } str = str.replace(regex, key); } } return str; }, getDayOfYearFromWeek : function (obj) { var d, jan4, offset; obj.weekDay = (!obj.weekDay && obj.weekDay !== 0) ? 1 : obj.weekDay; d = new Date(obj.year, 0, 4); jan4 = d.getDay() === 0 ? 7 : d.getDay(); // JS is 0 indexed on Sunday. offset = jan4+3; obj.dayOfYear = ((obj.week * 7) + (obj.weekDay === 0 ? 7 : obj.weekDay))-offset; return obj; }, getDayOfYear : function (obj, dayOffset) { if (!obj.dayOfYear) { obj = utils.getDayOfYearFromWeek(obj); } for (var i=0;i <= dayOffset.length;i++) { if (obj.dayOfYear < dayOffset[i] || i === dayOffset.length) { obj.day = obj.day ? obj.day : (obj.dayOfYear - dayOffset[i-1]); break; } else { obj.month = i; } } return obj; }, adjustForTimeZone : function (obj, date) { var offset; if (obj.zone.toUpperCase() === "Z" || (obj.zone_hours === 0 && obj.zone_minutes === 0)) { // it's UTC/GML so work out the current timeszone offset offset = -date.getTimezoneOffset(); } else { offset = (obj.zone_hours*60) + (obj.zone_minutes || 0); if (obj.zone_sign === "+") { offset *= -1; } offset -= date.getTimezoneOffset(); } date.setMinutes(date.getMinutes()+offset); return date; }, setDefaults : function (obj) { obj.year = obj.year || Date.today().getFullYear(); obj.hours = obj.hours || 0; obj.minutes = obj.minutes || 0; obj.seconds = obj.seconds || 0; obj.milliseconds = obj.milliseconds || 0; if (!(!obj.month && (obj.week || obj.dayOfYear))) { // if we have a month, or if we don't but don't have the day calculation data obj.month = obj.month || 0; obj.day = obj.day || 1; } return obj; }, dataNum: function (data, mod, explict, postProcess) { var dataNum = data*1; if (mod) { if (postProcess) { return data ? mod(data)*1 : data; } else { return data ? mod(dataNum) : data; } } else if (!explict){ return data ? dataNum : data; } else { return (data && typeof data !== "undefined") ? dataNum : data; } }, timeDataProcess: function (obj) { var timeObj = {}; for (var x in obj.data) { if (obj.data.hasOwnProperty(x)) { timeObj[x] = obj.ignore[x] ? obj.data[x] : utils.dataNum(obj.data[x], obj.mods[x], obj.explict[x], obj.postProcess[x]); } } if (obj.data.secmins) { obj.data.secmins = obj.data.secmins.replace(",", ".") * 60; if (!timeObj.minutes) { timeObj.minutes = obj.data.secmins; } else if (!timeObj.seconds) { timeObj.seconds = obj.data.secmins; } delete obj.secmins; } return timeObj; }, buildTimeObjectFromData: function (data) { var time = utils.timeDataProcess({ data: { year : data[1], month : data[5], day : data[7], week : data[8], dayOfYear : data[10], hours : data[15], zone_hours : data[23], zone_minutes : data[24], zone : data[21], zone_sign : data[22], weekDay : data[9], minutes: data[16], seconds: data[19], milliseconds: data[20], secmins: data[18] }, mods: { month: function(data) { return data-1; }, weekDay: function (data) { data = Math.abs(data); return (data === 7 ? 0 : data); }, minutes: function (data) { return data.replace(":",""); }, seconds: function (data) { return Math.floor( (data.replace(":","").replace(",","."))*1 ); }, milliseconds: function (data) { return (data.replace(",",".")*1000); } }, postProcess: { minutes: true, seconds: true, milliseconds: true }, explict: { zone_hours: true, zone_minutes: true }, ignore: { zone: true, zone_sign: true, secmins: true } }); return time; }, addToHash: function (hash, keys, data) { keys = keys; data = data; var len = keys.length; for (var i = 0; i < len; i++) { hash[keys[i]] = data[i]; } return hash; }, combineRegex: function (r1, r2) { return new RegExp("(("+r1.source+")\\s("+r2.source+"))"); }, getDateNthString: function(add, last, inc){ if (add) { return Date.today().addDays(inc).toString("d"); } else if (last) { return Date.today().last()[inc]().toString("d"); } }, buildRegexData: function (array) { var arr = []; var len = array.length; for (var i=0; i < len; i++) { if (Object.prototype.toString.call(array[i]) === '[object Array]') { // oldIE compat version of Array.isArray arr.push(this.combineRegex(array[i][0], array[i][1])); } else { arr.push(array[i]); } } return arr; } }; $P.processTimeObject = function (obj) { var date, dayOffset; utils.setDefaults(obj); dayOffset = ($P.isLeapYear(obj.year)) ? dayOffsets.leap : dayOffsets.standard; if (!obj.month && (obj.week || obj.dayOfYear)) { utils.getDayOfYear(obj, dayOffset); } else { obj.dayOfYear = dayOffset[obj.month] + obj.day; } date = new Date(obj.year, obj.month, obj.day, obj.hours, obj.minutes, obj.seconds, obj.milliseconds); if (obj.zone) { utils.adjustForTimeZone(obj, date); // adjust (and calculate) for timezone } return date; }; $P.ISO = { regex : /^([\+-]?\d{4}(?!\d{2}\b))((-?)((0[1-9]|1[0-2])(\3([12]\d|0[1-9]|3[01]))?|W([0-4]\d|5[0-3])(-?[1-7])?|(00[1-9]|0[1-9]\d|[12]\d{2}|3([0-5]\d|6[1-6])))([T\s]((([01]\d|2[0-4])((:?)[0-5]\d)?|24\:?00)([\.,]\d+(?!:))?)?(\17[0-5]\d([\.,]\d+)?)?\s?([zZ]|([\+-])([01]\d|2[0-3]):?([0-5]\d)?)?)?)?$/, parse : function (s) { var time, data = s.match(this.regex); if (!data || !data.length) { return null; } time = utils.buildTimeObjectFromData(data); if (!time.year || (!time.year && (!time.month && !time.day) && (!time.week && !time.dayOfYear)) ) { return null; } return $P.processTimeObject(time); } }; $P.Numeric = { isNumeric: function (e){return!isNaN(parseFloat(e))&&isFinite(e);}, regex: /\b([0-1]?[0-9])([0-3]?[0-9])([0-2]?[0-9]?[0-9][0-9])\b/i, parse: function (s) { var data, i, time = {}, order = Date.CultureInfo.dateElementOrder.split(""); if (!(this.isNumeric(s)) || // if it's non-numeric OR (s[0] === "+" && s[0] === "-")) { // It's an arithmatic string (eg +/-1000) return null; } if (s.length < 5 && s.indexOf(".") < 0 && s.indexOf("/") < 0) { // assume it's just a year. time.year = s; return $P.processTimeObject(time); } data = s.match(this.regex); if (!data || !data.length) { return null; } for (i=0; i < order.length; i++) { switch(order[i]) { case "d": time.day = data[i+1]; break; case "m": time.month = (data[i+1]-1); break; case "y": time.year = data[i+1]; break; } } return $P.processTimeObject(time); } }; $P.Normalizer = { regexData: function () { var $R = Date.CultureInfo.regexPatterns; return utils.buildRegexData([ $R.tomorrow, $R.yesterday, [$R.past, $R.mon], [$R.past, $R.tue], [$R.past, $R.wed], [$R.past, $R.thu], [$R.past, $R.fri], [$R.past, $R.sat], [$R.past, $R.sun] ]); }, basicReplaceHash : function() { var $R = Date.CultureInfo.regexPatterns; return { "January": $R.jan.source, "February": $R.feb, "March": $R.mar, "April": $R.apr, "May": $R.may, "June": $R.jun, "July": $R.jul, "August": $R.aug, "September": $R.sep, "October": $R.oct, "November": $R.nov, "December": $R.dec, "": /\bat\b/gi, " ": /\s{2,}/, "am": $R.inTheMorning, "9am": $R.thisMorning, "pm": $R.inTheEvening, "7pm":$R.thisEvening }; }, keys : function(){ return [ utils.getDateNthString(true, false, 1), // tomorrow utils.getDateNthString(true, false, -1), // yesterday utils.getDateNthString(false, true, "monday"), //last mon utils.getDateNthString(false, true, "tuesday"), //last tues utils.getDateNthString(false, true, "wednesday"), //last wed utils.getDateNthString(false, true, "thursday"), //last thurs utils.getDateNthString(false, true, "friday"), //last fri utils.getDateNthString(false, true, "saturday"), //last sat utils.getDateNthString(false, true, "sunday") //last sun ]; }, buildRegexFunctions: function () { var $R = Date.CultureInfo.regexPatterns; var __ = Date.i18n.__; var tomorrowRE = new RegExp("(\\b\\d\\d?("+__("AM")+"|"+__("PM")+")? )("+$R.tomorrow.source.slice(1)+")", "i"); // adapted tomorrow regex for AM PM relative dates var todayRE = new RegExp($R.today.source + "(?!\\s*([+-]))\\b"); // today, but excludes the math operators (eg "today + 2h") this.replaceFuncs = [ [todayRE, function (full) { return (full.length > 1) ? Date.today().toString("d") : full; }], [tomorrowRE, function(full, m1) { var t = Date.today().addDays(1).toString("d"); return (t + " " + m1); }], [$R.amThisMorning, function(str, am){return am;}], [$R.pmThisEvening, function(str, pm){return pm;}] ]; }, buildReplaceData: function () { this.buildRegexFunctions(); this.replaceHash = utils.addToHash(this.basicReplaceHash(), this.keys(), this.regexData()); }, stringReplaceFuncs: function (s) { for (var i=0; i < this.replaceFuncs.length; i++) { s = s.replace(this.replaceFuncs[i][0], this.replaceFuncs[i][1]); } return s; }, parse: function (s) { s = this.stringReplaceFuncs(s); s = utils.multiReplace(s, this.replaceHash); try { var n = s.split(/([\s\-\.\,\/\x27]+)/); if (n.length === 3 && $P.Numeric.isNumeric(n[0]) && $P.Numeric.isNumeric(n[2]) && (n[2].length >= 4)) { // ok, so we're dealing with x/year. But that's not a full date. // This fixes wonky dateElementOrder parsing when set to dmy order. if (Date.CultureInfo.dateElementOrder[0] === "d") { s = "1/" + n[0] + "/" + n[2]; // set to 1st of month and normalize the seperator } } } catch (e) {} return s; } }; $P.Normalizer.buildReplaceData(); }()); (function () { var $P = Date.Parsing; var _ = $P.Operators = { // // Tokenizers // rtoken: function (r) { // regex token return function (s) { var mx = s.match(r); if (mx) { return ([ mx[0], s.substring(mx[0].length) ]); } else { throw new $P.Exception(s); } }; }, token: function () { // whitespace-eating token return function (s) { return _.rtoken(new RegExp("^\\s*" + s + "\\s*"))(s); }; }, stoken: function (s) { // string token return _.rtoken(new RegExp("^" + s)); }, // Atomic Operators until: function (p) { return function (s) { var qx = [], rx = null; while (s.length) { try { rx = p.call(this, s); } catch (e) { qx.push(rx[0]); s = rx[1]; continue; } break; } return [ qx, s ]; }; }, many: function (p) { return function (s) { var rx = [], r = null; while (s.length) { try { r = p.call(this, s); } catch (e) { return [ rx, s ]; } rx.push(r[0]); s = r[1]; } return [ rx, s ]; }; }, // generator operators -- see below optional: function (p) { return function (s) { var r = null; try { r = p.call(this, s); } catch (e) { return [ null, s ]; } return [ r[0], r[1] ]; }; }, not: function (p) { return function (s) { try { p.call(this, s); } catch (e) { return [null, s]; } throw new $P.Exception(s); }; }, ignore: function (p) { return p ? function (s) { var r = null; r = p.call(this, s); return [null, r[1]]; } : null; }, product: function () { var px = arguments[0], qx = Array.prototype.slice.call(arguments, 1), rx = []; for (var i = 0 ; i < px.length ; i++) { rx.push(_.each(px[i], qx)); } return rx; }, cache: function (rule) { var cache = {}, cache_length = 0, cache_keys = [], CACHE_MAX = Date.Config.CACHE_MAX || 100000, r = null; var cacheCheck = function () { if (cache_length === CACHE_MAX) { // kill several keys, don't want to have to do this all the time... for (var i=0; i < 10; i++) { var key = cache_keys.shift(); if (key) { delete cache[key]; cache_length--; } } } }; return function (s) { cacheCheck(); try { r = cache[s] = (cache[s] || rule.call(this, s)); } catch (e) { r = cache[s] = e; } cache_length++; cache_keys.push(s); if (r instanceof $P.Exception) { throw r; } else { return r; } }; }, // vector operators -- see below any: function () { var px = arguments; return function (s) { var r = null; for (var i = 0; i < px.length; i++) { if (px[i] == null) { continue; } try { r = (px[i].call(this, s)); } catch (e) { r = null; } if (r) { return r; } } throw new $P.Exception(s); }; }, each: function () { var px = arguments; return function (s) { var rx = [], r = null; for (var i = 0; i < px.length ; i++) { if (px[i] == null) { continue; } try { r = (px[i].call(this, s)); } catch (e) { throw new $P.Exception(s); } rx.push(r[0]); s = r[1]; } return [ rx, s]; }; }, all: function () { var px = arguments, _ = _; return _.each(_.optional(px)); }, // delimited operators sequence: function (px, d, c) { d = d || _.rtoken(/^\s*/); c = c || null; if (px.length === 1) { return px[0]; } return function (s) { var r = null, q = null; var rx = []; for (var i = 0; i < px.length ; i++) { try { r = px[i].call(this, s); } catch (e) { break; } rx.push(r[0]); try { q = d.call(this, r[1]); } catch (ex) { q = null; break; } s = q[1]; } if (!r) { throw new $P.Exception(s); } if (q) { throw new $P.Exception(q[1]); } if (c) { try { r = c.call(this, r[1]); } catch (ey) { throw new $P.Exception(r[1]); } } return [ rx, (r?r[1]:s) ]; }; }, // // Composite Operators // between: function (d1, p, d2) { d2 = d2 || d1; var _fn = _.each(_.ignore(d1), p, _.ignore(d2)); return function (s) { var rx = _fn.call(this, s); return [[rx[0][0], r[0][2]], rx[1]]; }; }, list: function (p, d, c) { d = d || _.rtoken(/^\s*/); c = c || null; return (p instanceof Array ? _.each(_.product(p.slice(0, -1), _.ignore(d)), p.slice(-1), _.ignore(c)) : _.each(_.many(_.each(p, _.ignore(d))), px, _.ignore(c))); }, set: function (px, d, c) { d = d || _.rtoken(/^\s*/); c = c || null; return function (s) { // r is the current match, best the current 'best' match // which means it parsed the most amount of input var r = null, p = null, q = null, rx = null, best = [[], s], last = false; // go through the rules in the given set for (var i = 0; i < px.length ; i++) { // last is a flag indicating whether this must be the last element // if there is only 1 element, then it MUST be the last one q = null; p = null; r = null; last = (px.length === 1); // first, we try simply to match the current pattern // if not, try the next pattern try { r = px[i].call(this, s); } catch (e) { continue; } // since we are matching against a set of elements, the first // thing to do is to add r[0] to matched elements rx = [[r[0]], r[1]]; // if we matched and there is still input to parse and // we don't already know this is the last element, // we're going to next check for the delimiter ... // if there's none, or if there's no input left to parse // than this must be the last element after all ... if (r[1].length > 0 && ! last) { try { q = d.call(this, r[1]); } catch (ex) { last = true; } } else { last = true; } // if we parsed the delimiter and now there's no more input, // that means we shouldn't have parsed the delimiter at all // so don't update r and mark this as the last element ... if (!last && q[1].length === 0) { last = true; } // so, if this isn't the last element, we're going to see if // we can get any more matches from the remaining (unmatched) // elements ... if (!last) { // build a list of the remaining rules we can match against, // i.e., all but the one we just matched against var qx = []; for (var j = 0; j < px.length ; j++) { if (i !== j) { qx.push(px[j]); } } // now invoke recursively set with the remaining input // note that we don't include the closing delimiter ... // we'll check for that ourselves at the end p = _.set(qx, d).call(this, q[1]); // if we got a non-empty set as a result ... // (otw rx already contains everything we want to match) if (p[0].length > 0) { // update current result, which is stored in rx ... // basically, pick up the remaining text from p[1] // and concat the result from p[0] so that we don't // get endless nesting ... rx[0] = rx[0].concat(p[0]); rx[1] = p[1]; } } // at this point, rx either contains the last matched element // or the entire matched set that starts with this element. // now we just check to see if this variation is better than // our best so far, in terms of how much of the input is parsed if (rx[1].length < best[1].length) { best = rx; } // if we've parsed all the input, then we're finished if (best[1].length === 0) { break; } } // so now we've either gone through all the patterns trying them // as the initial match; or we found one that parsed the entire // input string ... // if best has no matches, just return empty set ... if (best[0].length === 0) { return best; } // if a closing delimiter is provided, then we have to check it also if (c) { // we try this even if there is no remaining input because the pattern // may well be optional or match empty input ... try { q = c.call(this, best[1]); } catch (ey) { throw new $P.Exception(best[1]); } // it parsed ... be sure to update the best match remaining input best[1] = q[1]; } // if we're here, either there was no closing delimiter or we parsed it // so now we have the best match; just return it! return best; }; }, forward: function (gr, fname) { return function (s) { return gr[fname].call(this, s); }; }, // // Translation Operators // replace: function (rule, repl) { return function (s) { var r = rule.call(this, s); return [repl, r[1]]; }; }, process: function (rule, fn) { return function (s) { var r = rule.call(this, s); return [fn.call(this, r[0]), r[1]]; }; }, min: function (min, rule) { return function (s) { var rx = rule.call(this, s); if (rx[0].length < min) { throw new $P.Exception(s); } return rx; }; } }; // Generator Operators And Vector Operators // Generators are operators that have a signature of F(R) => R, // taking a given rule and returning another rule, such as // ignore, which parses a given rule and throws away the result. // Vector operators are those that have a signature of F(R1,R2,...) => R, // take a list of rules and returning a new rule, such as each. // Generator operators are converted (via the following _generator // function) into functions that can also take a list or array of rules // and return an array of new rules as though the function had been // called on each rule in turn (which is what actually happens). // This allows generators to be used with vector operators more easily. // Example: // each(ignore(foo, bar)) instead of each(ignore(foo), ignore(bar)) // This also turns generators into vector operators, which allows // constructs like: // not(cache(foo, bar)) var _generator = function (op) { function gen() { var args = null, rx = [], px, i; if (arguments.length > 1) { args = Array.prototype.slice.call(arguments); } else if (arguments[0] instanceof Array) { args = arguments[0]; } if (args) { px = args.shift(); if (px.length > 0) { args.unshift(px[i]); rx.push(op.apply(null, args)); args.shift(); return rx; } } else { return op.apply(null, arguments); } } return gen; }; var gx = "optional not ignore cache".split(/\s/); for (var i = 0 ; i < gx.length ; i++) { _[gx[i]] = _generator(_[gx[i]]); } var _vector = function (op) { return function () { if (arguments[0] instanceof Array) { return op.apply(null, arguments[0]); } else { return op.apply(null, arguments); } }; }; var vx = "each any all".split(/\s/); for (var j = 0 ; j < vx.length ; j++) { _[vx[j]] = _vector(_[vx[j]]); } }()); (function () { var $D = Date; var flattenAndCompact = function (ax) { var rx = []; for (var i = 0; i < ax.length; i++) { if (ax[i] instanceof Array) { rx = rx.concat(flattenAndCompact(ax[i])); } else { if (ax[i]) { rx.push(ax[i]); } } } return rx; }; var parseMeridian = function () { if (this.meridian && (this.hour || this.hour === 0)) { if (this.meridian === "a" && this.hour > 11 && Date.Config.strict24hr){ throw "Invalid hour and meridian combination"; } else if (this.meridian === "p" && this.hour < 12 && Date.Config.strict24hr){ throw "Invalid hour and meridian combination"; } else if (this.meridian === "p" && this.hour < 12) { this.hour = this.hour + 12; } else if (this.meridian === "a" && this.hour === 12) { this.hour = 0; } } }; var setDefaults = function () { var now = new Date(); if ((this.hour || this.minute) && (!this.month && !this.year && !this.day)) { this.day = now.getDate(); } if (!this.year) { this.year = now.getFullYear(); } if (!this.month && this.month !== 0) { this.month = now.getMonth(); } if (!this.day) { this.day = 1; } if (!this.hour) { this.hour = 0; } if (!this.minute) { this.minute = 0; } if (!this.second) { this.second = 0; } if (!this.millisecond) { this.millisecond = 0; } }; var finishUtils = { getToday: function () { if (this.now || "hour minute second".indexOf(this.unit) !== -1) { return new Date(); } else { return $D.today(); } }, setDaysFromWeekday: function (today, orient){ var gap; orient = orient || 1; this.unit = "day"; gap = ($D.getDayNumberFromName(this.weekday) - today.getDay()); this.days = gap ? ((gap + (orient * 7)) % 7) : (orient * 7); return this; }, setMonthsFromMonth: function (today, orient) { var gap; orient = orient || 1; this.unit = "month"; gap = (this.month - today.getMonth()); this.months = gap ? ((gap + (orient * 12)) % 12) : (orient * 12); this.month = null; return this; }, setDMYFromWeekday: function () { var d = Date[this.weekday](); this.day = d.getDate(); if (!this.month) { this.month = d.getMonth(); } this.year = d.getFullYear(); return this; }, setUnitValue: function (orient) { if (!this.value && this.operator && this.operator !== null && this[this.unit + "s"] && this[this.unit + "s"] !== null) { this[this.unit + "s"] = this[this.unit + "s"] + ((this.operator === "add") ? 1 : -1) + (this.value||0) * orient; } else if (this[this.unit + "s"] == null || this.operator != null) { if (!this.value) { this.value = 1; } this[this.unit + "s"] = this.value * orient; } }, generateDateFromWeeks: function () { var weekday = (this.weekday !== undefined) ? this.weekday : "today"; var d = Date[weekday]().addWeeks(this.weeks); if (this.now) { d.setTimeToNow(); } return d; } }; $D.Translator = { hour: function (s) { return function () { this.hour = Number(s); }; }, minute: function (s) { return function () { this.minute = Number(s); }; }, second: function (s) { return function () { this.second = Number(s); }; }, /* for ss.s format */ secondAndMillisecond: function (s) { return function () { var mx = s.match(/^([0-5][0-9])\.([0-9]{1,3})/); this.second = Number(mx[1]); this.millisecond = Number(mx[2]); }; }, meridian: function (s) { return function () { this.meridian = s.slice(0, 1).toLowerCase(); }; }, timezone: function (s) { return function () { var n = s.replace(/[^\d\+\-]/g, ""); if (n.length) { this.timezoneOffset = Number(n); } else { this.timezone = s.toLowerCase(); } }; }, day: function (x) { var s = x[0]; return function () { this.day = Number(s.match(/\d+/)[0]); if (this.day < 1) { throw "invalid day"; } }; }, month: function (s) { return function () { this.month = (s.length === 3) ? "jan feb mar apr may jun jul aug sep oct nov dec".indexOf(s)/4 : Number(s) - 1; if (this.month < 0) { throw "invalid month"; } }; }, year: function (s) { return function () { var n = Number(s); this.year = ((s.length > 2) ? n : (n + (((n + 2000) < Date.CultureInfo.twoDigitYearMax) ? 2000 : 1900))); }; }, rday: function (s) { return function () { switch (s) { case "yesterday": this.days = -1; break; case "tomorrow": this.days = 1; break; case "today": this.days = 0; break; case "now": this.days = 0; this.now = true; break; } }; }, finishExact: function (x) { var d; x = (x instanceof Array) ? x : [x]; for (var i = 0 ; i < x.length ; i++) { if (x[i]) { x[i].call(this); } } setDefaults.call(this); parseMeridian.call(this); if (this.day > $D.getDaysInMonth(this.year, this.month)) { throw new RangeError(this.day + " is not a valid value for days."); } d = new Date(this.year, this.month, this.day, this.hour, this.minute, this.second, this.millisecond); if (this.year < 100) { d.setFullYear(this.year); // means years less that 100 are process correctly. JS will parse it otherwise as 1900-1999. } if (this.timezone) { d.set({ timezone: this.timezone }); } else if (this.timezoneOffset) { d.set({ timezoneOffset: this.timezoneOffset }); } return d; }, finish: function (x) { var today, expression, orient, temp; x = (x instanceof Array) ? flattenAndCompact(x) : [ x ]; if (x.length === 0) { return null; } for (var i = 0 ; i < x.length ; i++) { if (typeof x[i] === "function") { x[i].call(this); } } if (this.now && !this.unit && !this.operator) { return new Date(); } else { today = finishUtils.getToday.call(this); } expression = !!(this.days && this.days !== null || this.orient || this.operator); orient = ((this.orient === "past" || this.operator === "subtract") ? -1 : 1); if (this.month && this.unit === "week") { this.value = this.month + 1; delete this.month; delete this.day; } if ((this.month || this.month === 0) && "year day hour minute second".indexOf(this.unit) !== -1) { if (!this.value) { this.value = this.month + 1; } this.month = null; expression = true; } if (!expression && this.weekday && !this.day && !this.days) { finishUtils.setDMYFromWeekday.call(this); } if (expression && this.weekday && this.unit !== "month" && this.unit !== "week") { finishUtils.setDaysFromWeekday.call(this, today, orient); } if (this.weekday && this.unit !== "week" && !this.day && !this.days) { temp = Date[this.weekday](); this.day = temp.getDate(); if (temp.getMonth() !== today.getMonth()) { this.month = temp.getMonth(); } } if (this.month && this.unit === "day" && this.operator) { if (!this.value) { this.value = (this.month + 1); } this.month = null; } if (this.value != null && this.month != null && this.year != null) { this.day = this.value * 1; } if (this.month && !this.day && this.value) { today.set({ day: this.value * 1 }); if (!expression) { this.day = this.value * 1; } } if (!this.month && this.value && this.unit === "month" && !this.now) { this.month = this.value; expression = true; } if (expression && (this.month || this.month === 0) && this.unit !== "year") { finishUtils.setMonthsFromMonth.call(this, today, orient); } if (!this.unit) { this.unit = "day"; } finishUtils.setUnitValue.call(this, orient); parseMeridian.call(this); if ((this.month || this.month === 0) && !this.day) { this.day = 1; } if (!this.orient && !this.operator && this.unit === "week" && this.value && !this.day && !this.month) { return Date.today().setWeek(this.value); } if (this.unit === "week" && this.weeks && !this.day && !this.month) { return finishUtils.generateDateFromWeeks.call(this); } if (expression && this.timezone && this.day && this.days) { this.day = this.days; } if (expression){ today.add(this); } else { today.set(this); } if (this.timezone) { this.timezone = this.timezone.toUpperCase(); var offset = $D.getTimezoneOffset(this.timezone); var timezone; if (today.hasDaylightSavingTime()) { // lets check that we're being sane with timezone setting timezone = $D.getTimezoneAbbreviation(offset, today.isDaylightSavingTime()); if (timezone !== this.timezone) { // bugger, we're in a place where things like EST vs EDT matters. if (today.isDaylightSavingTime()) { today.addHours(-1); } else { today.addHours(1); } } } today.setTimezoneOffset(offset); } return today; } }; }()); (function () { var $D = Date; $D.Grammar = {}; var _ = $D.Parsing.Operators, g = $D.Grammar, t = $D.Translator, _fn; // Allow rolling up into general purpose rules _fn = function () { return _.each(_.any.apply(null, arguments), _.not(g.ctoken2("timeContext"))); }; g.datePartDelimiter = _.rtoken(/^([\s\-\.\,\/\x27]+)/); g.timePartDelimiter = _.stoken(":"); g.whiteSpace = _.rtoken(/^\s*/); g.generalDelimiter = _.rtoken(/^(([\s\,]|at|@|on)+)/); var _C = {}; g.ctoken = function (keys) { var fn = _C[keys]; if (! fn) { var c = Date.CultureInfo.regexPatterns; var kx = keys.split(/\s+/), px = []; for (var i = 0; i < kx.length ; i++) { px.push(_.replace(_.rtoken(c[kx[i]]), kx[i])); } fn = _C[keys] = _.any.apply(null, px); } return fn; }; g.ctoken2 = function (key) { return _.rtoken(Date.CultureInfo.regexPatterns[key]); }; var cacheProcessRtoken = function (key, token, type, eachToken) { if (eachToken) { g[key] = _.cache(_.process(_.each(_.rtoken(token),_.optional(g.ctoken2(eachToken))), type)); } else { g[key] = _.cache(_.process(_.rtoken(token), type)); } }; var cacheProcessCtoken = function (token, type) { return _.cache(_.process(g.ctoken2(token), type)); }; var _F = {}; //function cache var _get = function (f) { _F[f] = (_F[f] || g.format(f)[0]); return _F[f]; }; g.allformats = function (fx) { var rx = []; if (fx instanceof Array) { for (var i = 0; i < fx.length; i++) { rx.push(_get(fx[i])); } } else { rx.push(_get(fx)); } return rx; }; g.formats = function (fx) { if (fx instanceof Array) { var rx = []; for (var i = 0 ; i < fx.length ; i++) { rx.push(_get(fx[i])); } return _.any.apply(null, rx); } else { return _get(fx); } }; var grammarFormats = { timeFormats: function(){ var i, RTokenKeys = [ "h", "hh", "H", "HH", "m", "mm", "s", "ss", "ss.s", "z", "zz" ], RToken = [ /^(0[0-9]|1[0-2]|[1-9])/, /^(0[0-9]|1[0-2])/, /^([0-1][0-9]|2[0-3]|[0-9])/, /^([0-1][0-9]|2[0-3])/, /^([0-5][0-9]|[0-9])/, /^[0-5][0-9]/, /^([0-5][0-9]|[0-9])/, /^[0-5][0-9]/, /^[0-5][0-9]\.[0-9]{1,3}/, /^((\+|\-)\s*\d\d\d\d)|((\+|\-)\d\d\:?\d\d)/, /^((\+|\-)\s*\d\d\d\d)|((\+|\-)\d\d\:?\d\d)/ ], tokens = [ t.hour, t.hour, t.hour, t.hour, t.minute, t.minute, t.second, t.second, t.secondAndMillisecond, t.timezone, t.timezone ]; for (i=0; i < RTokenKeys.length; i++) { cacheProcessRtoken(RTokenKeys[i], RToken[i], tokens[i]); } g.hms = _.cache(_.sequence([g.H, g.m, g.s], g.timePartDelimiter)); g.t = cacheProcessCtoken("shortMeridian", t.meridian); g.tt = cacheProcessCtoken("longMeridian", t.meridian); g.zzz = cacheProcessCtoken("timezone", t.timezone); g.timeSuffix = _.each(_.ignore(g.whiteSpace), _.set([ g.tt, g.zzz ])); g.time = _.each(_.optional(_.ignore(_.stoken("T"))), g.hms, g.timeSuffix); }, dateFormats: function () { // pre-loaded rules for different date part order preferences var _setfn = function () { return _.set(arguments, g.datePartDelimiter); }; var i, RTokenKeys = [ "d", "dd", "M", "MM", "y", "yy", "yyy", "yyyy" ], RToken = [ /^([0-2]\d|3[0-1]|\d)/, /^([0-2]\d|3[0-1])/, /^(1[0-2]|0\d|\d)/, /^(1[0-2]|0\d)/, /^(\d+)/, /^(\d\d)/, /^(\d\d?\d?\d?)/, /^(\d\d\d\d)/ ], tokens = [ t.day, t.day, t.month, t.month, t.year, t.year, t.year, t.year ], eachToken = [ "ordinalSuffix", "ordinalSuffix" ]; for (i=0; i < RTokenKeys.length; i++) { cacheProcessRtoken(RTokenKeys[i], RToken[i], tokens[i], eachToken[i]); } g.MMM = g.MMMM = _.cache(_.process(g.ctoken("jan feb mar apr may jun jul aug sep oct nov dec"), t.month)); g.ddd = g.dddd = _.cache(_.process(g.ctoken("sun mon tue wed thu fri sat"), function (s) { return function () { this.weekday = s; }; } )); g.day = _fn(g.d, g.dd); g.month = _fn(g.M, g.MMM); g.year = _fn(g.yyyy, g.yy); g.mdy = _setfn(g.ddd, g.month, g.day, g.year); g.ymd = _setfn(g.ddd, g.year, g.month, g.day); g.dmy = _setfn(g.ddd, g.day, g.month, g.year); g.date = function (s) { return ((g[Date.CultureInfo.dateElementOrder] || g.mdy).call(this, s)); }; }, relative: function () { // relative date / time expressions g.orientation = _.process(g.ctoken("past future"), function (s) { return function () { this.orient = s; }; } ); g.operator = _.process(g.ctoken("add subtract"), function (s) { return function () { this.operator = s; }; } ); g.rday = _.process(g.ctoken("yesterday tomorrow today now"), t.rday); g.unit = _.process(g.ctoken("second minute hour day week month year"), function (s) { return function () { this.unit = s; }; } ); } }; g.buildGrammarFormats = function () { // these need to be rebuilt every time the language changes. _C = {}; grammarFormats.timeFormats(); grammarFormats.dateFormats(); grammarFormats.relative(); g.value = _.process(_.rtoken(/^([-+]?\d+)?(st|nd|rd|th)?/), function (s) { return function () { this.value = s.replace(/\D/g, ""); }; } ); g.expression = _.set([g.rday, g.operator, g.value, g.unit, g.orientation, g.ddd, g.MMM ]); g.format = _.process(_.many( _.any( // translate format specifiers into grammar rules _.process( _.rtoken(/^(dd?d?d?(?!e)|MM?M?M?|yy?y?y?|hh?|HH?|mm?|ss?|tt?|zz?z?)/), function (fmt) { if (g[fmt]) { return g[fmt]; } else { throw $D.Parsing.Exception(fmt); } } ), // translate separator tokens into token rules _.process(_.rtoken(/^[^dMyhHmstz]+/), // all legal separators function (s) { return _.ignore(_.stoken(s)); } ) ) ), // construct the parser ... function (rules) { return _.process(_.each.apply(null, rules), t.finishExact); } ); // starting rule for general purpose grammar g._start = _.process(_.set([ g.date, g.time, g.expression ], g.generalDelimiter, g.whiteSpace), t.finish); }; g.buildGrammarFormats(); // parsing date format specifiers - ex: "h:m:s tt" // this little guy will generate a custom parser based // on the format string, ex: g.format("h:m:s tt") // check for these formats first g._formats = g.formats([ "\"yyyy-MM-ddTHH:mm:ssZ\"", "yyyy-MM-ddTHH:mm:ss.sz", "yyyy-MM-ddTHH:mm:ssZ", "yyyy-MM-ddTHH:mm:ssz", "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-ddTHH:mmZ", "yyyy-MM-ddTHH:mmz", "yyyy-MM-ddTHH:mm", "ddd, MMM dd, yyyy H:mm:ss tt", "ddd MMM d yyyy HH:mm:ss zzz", "MMddyyyy", "ddMMyyyy", "Mddyyyy", "ddMyyyy", "Mdyyyy", "dMyyyy", "yyyy", "Mdyy", "dMyy", "d" ]); // real starting rule: tries selected formats first, // then general purpose rule g.start = function (s) { try { var r = g._formats.call({}, s); if (r[1].length === 0) { return r; } } catch (e) {} return g._start.call({}, s); }; }()); (function () { var $D = Date; /** * @desc Converts the specified string value into its JavaScript Date equivalent using CultureInfo specific format information. * * Example

	///////////
	// Dates //
	///////////

	// 15-Oct-2004
	var d1 = Date.parse("10/15/2004");

	// 15-Oct-2004
	var d1 = Date.parse("15-Oct-2004");

	// 15-Oct-2004
	var d1 = Date.parse("2004.10.15");

	//Fri Oct 15, 2004
	var d1 = Date.parse("Fri Oct 15, 2004");

	///////////
	// Times //
	///////////

	// Today at 10 PM.
	var d1 = Date.parse("10 PM");

	// Today at 10:30 PM.
	var d1 = Date.parse("10:30 P.M.");

	// Today at 6 AM.
	var d1 = Date.parse("06am");

	/////////////////////
	// Dates and Times //
	/////////////////////

	// 8-July-2004 @ 10:30 PM
	var d1 = Date.parse("July 8th, 2004, 10:30 PM");

	// 1-July-2004 @ 10:30 PM
	var d1 = Date.parse("2004-07-01T22:30:00");

	////////////////////
	// Relative Dates //
	////////////////////

	// Returns today's date. The string "today" is culture specific.
	var d1 = Date.parse("today");

	// Returns yesterday's date. The string "yesterday" is culture specific.
	var d1 = Date.parse("yesterday");

	// Returns the date of the next thursday.
	var d1 = Date.parse("Next thursday");

	// Returns the date of the most previous monday.
	var d1 = Date.parse("last monday");

	// Returns today's day + one year.
	var d1 = Date.parse("next year");

	///////////////
	// Date Math //
	///////////////

	// Today + 2 days
	var d1 = Date.parse("t+2");

	// Today + 2 days
	var d1 = Date.parse("today + 2 days");

	// Today + 3 months
	var d1 = Date.parse("t+3m");

	// Today - 1 year
	var d1 = Date.parse("today - 1 year");

	// Today - 1 year
	var d1 = Date.parse("t-1y"); 


	/////////////////////////////
	// Partial Dates and Times //
	/////////////////////////////

	// July 15th of this year.
	var d1 = Date.parse("July 15");

	// 15th day of current day and year.
	var d1 = Date.parse("15");

	// July 1st of current year at 10pm.
	var d1 = Date.parse("7/1 10pm");
	
* * @param {String} The string value to convert into a Date object [Required] * @return {Date} A Date object or null if the string cannot be converted into a Date. */ var parseUtils = { removeOrds: function (s) { ords = s.match(/\b(\d+)(?:st|nd|rd|th)\b/); // find ordinal matches s = ((ords && ords.length === 2) ? s.replace(ords[0], ords[1]) : s); return s; }, grammarParser: function (s) { var r = null; try { r = $D.Grammar.start.call({}, s.replace(/^\s*(\S*(\s+\S+)*)\s*$/, "$1")); } catch (e) { return null; } return ((r[1].length === 0) ? r[0] : null); }, nativeFallback: function(s) { var t; try { // ok we haven't parsed it, last ditch attempt with the built-in parser. t = Date._parse(s); return (t || t === 0) ? new Date(t) : null; } catch (e) { return null; } } }; function parse (s) { var d; if (!s) { return null; } if (s instanceof Date) { return s.clone(); } if (s.length >= 4 && s.charAt(0) !== "0" && s.charAt(0) !== "+"&& s.charAt(0) !== "-") { // ie: 2004 will pass, 0800 won't. // Start with specific formats d = $D.Parsing.ISO.parse(s) || $D.Parsing.Numeric.parse(s); } if (d instanceof Date && !isNaN(d.getTime())) { return d; } else { // find ordinal dates (1st, 3rd, 8th, etc and remove them as they cause parsing issues) s = $D.Parsing.Normalizer.parse(parseUtils.removeOrds(s)); d = parseUtils.grammarParser(s); if (d !== null) { return d; } else { return parseUtils.nativeFallback(s); } } } if (!$D._parse) { $D._parse = $D.parse; } $D.parse = parse; Date.getParseFunction = function (fx) { var fns = Date.Grammar.allformats(fx); return function (s) { var r = null; for (var i = 0; i < fns.length; i++) { try { r = fns[i].call({}, s); } catch (e) { continue; } if (r[1].length === 0) { return r[0]; } } return null; }; }; /** * Converts the specified string value into its JavaScript Date equivalent using the specified format {String} or formats {Array} and the CultureInfo specific format information. * The format of the string value must match one of the supplied formats exactly. * * Example

	// 15-Oct-2004
	var d1 = Date.parseExact("10/15/2004", "M/d/yyyy");

	// 15-Oct-2004
	var d1 = Date.parse("15-Oct-2004", "M-ddd-yyyy");

	// 15-Oct-2004
	var d1 = Date.parse("2004.10.15", "yyyy.MM.dd");

	// Multiple formats
	var d1 = Date.parseExact("10/15/2004", ["M/d/yyyy", "MMMM d, yyyy"]);
	
* * @param {String} The string value to convert into a Date object [Required]. * @param {Object} The expected format {String} or an array of expected formats {Array} of the date string [Required]. * @return {Date} A Date object or null if the string cannot be converted into a Date. */ $D.parseExact = function (s, fx) { return $D.getParseFunction(fx)(s); }; }()); (function () { var $D = Date, $P = $D.prototype, // $C = $D.CultureInfo, // not used atm p = function (s, l) { if (!l) { l = 2; } return ("000" + s).slice(l * -1); }; /** * Converts a PHP format string to Java/.NET format string. * A PHP format string can be used with ._format or .format. * A Java/.NET format string can be used with .toString(). * The .parseExact function will only accept a Java/.NET format string * * Example * var f1 = "%m/%d/%y" * var f2 = Date.normalizeFormat(f1); // "MM/dd/yy" * * new Date().format(f1); // "04/13/08" * new Date()._format(f1); // "04/13/08" * new Date().toString(f2); // "04/13/08" * * var date = Date.parseExact("04/13/08", f2); // Sun Apr 13 2008 * * @param {String} A PHP format string consisting of one or more format spcifiers. * @return {String} The PHP format converted to a Java/.NET format string. */ var normalizerSubstitutions = { "d" : "dd", "%d": "dd", "D" : "ddd", "%a": "ddd", "j" : "dddd", "l" : "dddd", "%A": "dddd", "S" : "S", "F" : "MMMM", "%B": "MMMM", "m" : "MM", "%m": "MM", "M" : "MMM", "%b": "MMM", "%h": "MMM", "n" : "M", "Y" : "yyyy", "%Y": "yyyy", "y" : "yy", "%y": "yy", "g" : "h", "%I": "h", "G" : "H", "h" : "hh", "H" : "HH", "%H": "HH", "i" : "mm", "%M": "mm", "s" : "ss", "%S": "ss", "%r": "hh:mm tt", "%R": "H:mm", "%T": "H:mm:ss", "%X": "t", "%x": "d", "%e": "d", "%D": "MM/dd/yy", "%n": "\\n", "%t": "\\t", "e" : "z", "T" : "z", "%z": "z", "%Z": "z", "Z" : "ZZ", "N" : "u", "w" : "u", "%w": "u", "W" : "W", "%V": "W" }; var normalizer = { substitutes: function (m) { return normalizerSubstitutions[m]; }, interpreted: function (m, x) { var y; switch (m) { case "%u": return x.getDay() + 1; case "z": return x.getOrdinalNumber(); case "%j": return p(x.getOrdinalNumber(), 3); case "%U": var d1 = x.clone().set({month: 0, day: 1}).addDays(-1).moveToDayOfWeek(0), d2 = x.clone().addDays(1).moveToDayOfWeek(0, -1); return (d2 < d1) ? "00" : p((d2.getOrdinalNumber() - d1.getOrdinalNumber()) / 7 + 1); case "%W": return p(x.getWeek()); case "t": return $D.getDaysInMonth(x.getFullYear(), x.getMonth()); case "o": case "%G": return x.setWeek(x.getISOWeek()).toString("yyyy"); case "%g": return x._format("%G").slice(-2); case "a": case "%p": return t("tt").toLowerCase(); case "A": return t("tt").toUpperCase(); case "u": return p(x.getMilliseconds(), 3); case "I": return (x.isDaylightSavingTime()) ? 1 : 0; case "O": return x.getUTCOffset(); case "P": y = x.getUTCOffset(); return y.substring(0, y.length - 2) + ":" + y.substring(y.length - 2); case "B": var now = new Date(); return Math.floor(((now.getHours() * 3600) + (now.getMinutes() * 60) + now.getSeconds() + (now.getTimezoneOffset() + 60) * 60) / 86.4); case "c": return x.toISOString().replace(/\"/g, ""); case "U": return $D.strtotime("now"); case "%c": return t("d") + " " + t("t"); case "%C": return Math.floor(x.getFullYear() / 100 + 1); } }, shouldOverrideDefaults: function (m) { switch (m) { case "%e": return true; default: return false; } }, parse: function (m, context) { var formatString, c = context || new Date(); formatString = normalizer.substitutes(m); if (formatString) { return formatString; } formatString = normalizer.interpreted(m, c); if (formatString) { return formatString; } else { return m; } } }; $D.normalizeFormat = function (format, context) { return format.replace(/(%|\\)?.|%%/g, function(t){ return normalizer.parse(t, context); }); }; /** * Format a local Unix timestamp according to locale settings * * Example: * Date.strftime("%m/%d/%y", new Date()); // "04/13/08" * Date.strftime("c", "2008-04-13T17:52:03Z"); // "04/13/08" * * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @param {Number|String} The number representing the number of seconds that have elapsed since January 1, 1970 (local time). * @return {String} A string representation of the current Date object. */ $D.strftime = function (format, time) { var d = Date.parse(time); return d._format(format); }; /** * Parse any textual datetime description into a Unix timestamp. * A Unix timestamp is the number of seconds that have elapsed since January 1, 1970 (midnight UTC/GMT). * * Example: * Date.strtotime("04/13/08"); // 1208044800 * Date.strtotime("1970-01-01T00:00:00Z"); // 0 * * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @param {Object} A string or date object. * @return {String} A string representation of the current Date object. */ $D.strtotime = function (time) { var d = $D.parse(time); return Math.round($D.UTC(d.getUTCFullYear(), d.getUTCMonth(), d.getUTCDate(), d.getUTCHours(), d.getUTCMinutes(), d.getUTCSeconds(), d.getUTCMilliseconds()) / 1000); }; /** * Converts the value of the current Date object to its equivalent string representation using a PHP/Unix style of date format specifiers. * Format Specifiers * Format Description Example * ------ --------------------------------------------------------------------------- ----------------------- * %a abbreviated weekday name according to the current localed "Mon" through "Sun" * %A full weekday name according to the current localed "Sunday" through "Saturday" * %b abbreviated month name according to the current localed "Jan" through "Dec" * %B full month name according to the current locale "January" through "December" * %c preferred date and time representation for the current locale "4/13/2008 12:33 PM" * %C century number (the year divided by 100 and truncated to an integer) "00" to "99" * %d day of the month as a decimal number "01" to "31" * %D same as %m/%d/%y "04/13/08" * %e day of the month as a decimal number, a single digit is preceded by a space "1" to "31" * %g like %G, but without the century "08" * %G The 4-digit year corresponding to the ISO week number (see %V). "2008" * This has the same format and value as %Y, except that if the ISO week number * belongs to the previous or next year, that year is used instead. * %h same as %b "Jan" through "Dec" * %H hour as a decimal number using a 24-hour clock. "00" to "23" * %I hour as a decimal number using a 12-hour clock. "01" to "12" * %j day of the year as a decimal number. "001" to "366" * %m month as a decimal number. "01" to "12" * %M minute as a decimal number. "00" to "59" * %n newline character "\n" * %p either "am" or "pm" according to the given time value, or the "am" or "pm" * corresponding strings for the current locale. * %r time in a.m. and p.m. notation "8:44 PM" * %R time in 24 hour notation "20:44" * %S second as a decimal number "00" to "59" * %t tab character "\t" * %T current time, equal to %H:%M:%S "12:49:11" * %u weekday as a decimal number ["1", "7"], with "1" representing Monday "1" to "7" * %U week number of the current year as a decimal number, starting with the "0" to ("52" or "53") * first Sunday as the first day of the first week * %V The ISO 8601:1988 week number of the current year as a decimal number, "00" to ("52" or "53") * range 01 to 53, where week 1 is the first week that has at least 4 days * in the current year, and with Monday as the first day of the week. * (Use %G or %g for the year component that corresponds to the week number * for the specified timestamp.) * %W week number of the current year as a decimal number, starting with the "00" to ("52" or "53") * first Monday as the first day of the first week * %w day of the week as a decimal, Sunday being "0" "0" to "6" * %x preferred date representation for the current locale without the time "4/13/2008" * %X preferred time representation for the current locale without the date "12:53:05" * %y year as a decimal number without a century "00" "99" * %Y year as a decimal number including the century "2008" * %Z time zone or name or abbreviation "UTC", "EST", "PST" * %z same as %Z * %% a literal "%" characters "%" * d Day of the month, 2 digits with leading zeros "01" to "31" * D A textual representation of a day, three letters "Mon" through "Sun" * j Day of the month without leading zeros "1" to "31" * l A full textual representation of the day of the week (lowercase "L") "Sunday" through "Saturday" * N ISO-8601 numeric representation of the day of the week (added in PHP 5.1.0) "1" (for Monday) through "7" (for Sunday) * S English ordinal suffix for the day of the month, 2 characters "st", "nd", "rd" or "th". Works well with j * w Numeric representation of the day of the week "0" (for Sunday) through "6" (for Saturday) * z The day of the year (starting from "0") "0" through "365" * W ISO-8601 week number of year, weeks starting on Monday "00" to ("52" or "53") * F A full textual representation of a month, such as January or March "January" through "December" * m Numeric representation of a month, with leading zeros "01" through "12" * M A short textual representation of a month, three letters "Jan" through "Dec" * n Numeric representation of a month, without leading zeros "1" through "12" * t Number of days in the given month "28" through "31" * L Whether it's a leap year "1" if it is a leap year, "0" otherwise * o ISO-8601 year number. This has the same value as Y, except that if the "2008" * ISO week number (W) belongs to the previous or next year, that year * is used instead. * Y A full numeric representation of a year, 4 digits "2008" * y A two digit representation of a year "08" * a Lowercase Ante meridiem and Post meridiem "am" or "pm" * A Uppercase Ante meridiem and Post meridiem "AM" or "PM" * B Swatch Internet time "000" through "999" * g 12-hour format of an hour without leading zeros "1" through "12" * G 24-hour format of an hour without leading zeros "0" through "23" * h 12-hour format of an hour with leading zeros "01" through "12" * H 24-hour format of an hour with leading zeros "00" through "23" * i Minutes with leading zeros "00" to "59" * s Seconds, with leading zeros "00" through "59" * u Milliseconds "54321" * e Timezone identifier "UTC", "EST", "PST" * I Whether or not the date is in daylight saving time (uppercase i) "1" if Daylight Saving Time, "0" otherwise * O Difference to Greenwich time (GMT) in hours "+0200", "-0600" * P Difference to Greenwich time (GMT) with colon between hours and minutes "+02:00", "-06:00" * T Timezone abbreviation "UTC", "EST", "PST" * Z Timezone offset in seconds. The offset for timezones west of UTC is "-43200" through "50400" * always negative, and for those east of UTC is always positive. * c ISO 8601 date "2004-02-12T15:19:21+00:00" * r RFC 2822 formatted date "Thu, 21 Dec 2000 16:01:07 +0200" * U Seconds since the Unix Epoch (January 1 1970 00:00:00 GMT) "0" * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @return {String} A string representation of the current Date object. */ var formatReplace = function (context) { return function (m) { var formatString, override = false; if (m.charAt(0) === "\\" || m.substring(0, 2) === "%%") { return m.replace("\\", "").replace("%%", "%"); } override = normalizer.shouldOverrideDefaults(m); formatString = $D.normalizeFormat(m, context); if (formatString) { return context.toString(formatString, override); } }; }; $P._format = function (format) { var formatter = formatReplace(this); if (!format) { return this._toString(); } else { return format.replace(/(%|\\)?.|%%/g, formatter); } }; if (!$P.format) { $P.format = $P._format; } }()); (function () { "use strict"; var gFn = function (attr) { return function () { return this[attr]; }; }; var sFn = function (attr) { return function (val) { this[attr] = val; return this; }; }; var attrs = ["years", "months", "days", "hours", "minutes", "seconds", "milliseconds"]; var addSetFuncs = function (context, attrs) { for (var i = 0; i < attrs.length ; i++) { var $a = attrs[i], $b = $a.slice(0, 1).toUpperCase() + $a.slice(1); context.prototype[$a] = 0; context.prototype["get" + $b] = gFn($a); context.prototype["set" + $b] = sFn($a); } }; /** * new TimeSpan(milliseconds); * new TimeSpan(days, hours, minutes, seconds); * new TimeSpan(days, hours, minutes, seconds, milliseconds); */ var TimeSpan = function (days, hours, minutes, seconds, milliseconds) { if (arguments.length === 1 && typeof days === "number") { var orient = (days < 0) ? -1 : +1; var millsLeft = Math.abs(days); this.setDays(Math.floor(millsLeft / 86400000) * orient); millsLeft = millsLeft % 86400000; this.setHours(Math.floor(millsLeft / 3600000) * orient); millsLeft = millsLeft % 3600000; this.setMinutes(Math.floor(millsLeft / 60000) * orient); millsLeft = millsLeft % 60000; this.setSeconds(Math.floor(millsLeft / 1000) * orient); millsLeft = millsLeft % 1000; this.setMilliseconds(millsLeft * orient); } else { this.set(days, hours, minutes, seconds, milliseconds); } this.getTotalMilliseconds = function () { return (this.getDays() * 86400000) + (this.getHours() * 3600000) + (this.getMinutes() * 60000) + (this.getSeconds() * 1000); }; this.compareTo = function (time) { var t1 = new Date(1970, 1, 1, this.getHours(), this.getMinutes(), this.getSeconds()), t2; if (time === null) { t2 = new Date(1970, 1, 1, 0, 0, 0); } else { t2 = new Date(1970, 1, 1, time.getHours(), time.getMinutes(), time.getSeconds()); } return (t1 < t2) ? -1 : (t1 > t2) ? 1 : 0; }; this.equals = function (time) { return (this.compareTo(time) === 0); }; this.add = function (time) { return (time === null) ? this : this.addSeconds(time.getTotalMilliseconds() / 1000); }; this.subtract = function (time) { return (time === null) ? this : this.addSeconds(-time.getTotalMilliseconds() / 1000); }; this.addDays = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 86400000)); }; this.addHours = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 3600000)); }; this.addMinutes = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 60000)); }; this.addSeconds = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 1000)); }; this.addMilliseconds = function (n) { return new TimeSpan(this.getTotalMilliseconds() + n); }; this.get12HourHour = function () { return (this.getHours() > 12) ? this.getHours() - 12 : (this.getHours() === 0) ? 12 : this.getHours(); }; this.getDesignator = function () { return (this.getHours() < 12) ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator; }; this.toString = function (format) { this._toString = function () { if (this.getDays() !== null && this.getDays() > 0) { return this.getDays() + "." + this.getHours() + ":" + this.p(this.getMinutes()) + ":" + this.p(this.getSeconds()); } else { return this.getHours() + ":" + this.p(this.getMinutes()) + ":" + this.p(this.getSeconds()); } }; this.p = function (s) { return (s.toString().length < 2) ? "0" + s : s; }; var me = this; return format ? format.replace(/dd?|HH?|hh?|mm?|ss?|tt?/g, function (format) { switch (format) { case "d": return me.getDays(); case "dd": return me.p(me.getDays()); case "H": return me.getHours(); case "HH": return me.p(me.getHours()); case "h": return me.get12HourHour(); case "hh": return me.p(me.get12HourHour()); case "m": return me.getMinutes(); case "mm": return me.p(me.getMinutes()); case "s": return me.getSeconds(); case "ss": return me.p(me.getSeconds()); case "t": return ((me.getHours() < 12) ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator).substring(0, 1); case "tt": return (me.getHours() < 12) ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator; } } ) : this._toString(); }; return this; }; addSetFuncs(TimeSpan, attrs.slice(2)); TimeSpan.prototype.set = function (days, hours, minutes, seconds, milliseconds){ this.setDays(days || this.getDays()); this.setHours(hours || this.getHours()); this.setMinutes(minutes || this.getMinutes()); this.setSeconds(seconds || this.getSeconds()); this.setMilliseconds(milliseconds || this.getMilliseconds()); }; /** * Gets the time of day for this date instances. * @return {TimeSpan} TimeSpan */ Date.prototype.getTimeOfDay = function () { return new TimeSpan(0, this.getHours(), this.getMinutes(), this.getSeconds(), this.getMilliseconds()); }; Date.TimeSpan = TimeSpan; if (typeof window !== "undefined" ) { // keeping API compatible for v1.x window.TimeSpan = TimeSpan; } }()); (function () { "use strict"; var attrs = ["years", "months", "days", "hours", "minutes", "seconds", "milliseconds"]; var gFn = function (attr) { return function () { return this[attr]; }; }; var sFn = function (attr) { return function (val) { this[attr] = val; return this; }; }; var addSetFuncs = function (context, attrs) { for (var i = 0; i < attrs.length ; i++) { var $a = attrs[i], $b = $a.slice(0, 1).toUpperCase() + $a.slice(1); context.prototype[$a] = 0; context.prototype["get" + $b] = gFn($a); context.prototype["set" + $b] = sFn($a); } }; var setMonthsAndYears = function (orient, d1, d2, context) { function inc() { d1.addMonths(-orient); context.months++; if (context.months === 12) { context.years++; context.months = 0; } } if (orient === +1) { while (d1 > d2) { inc(); } } else { while (d1 < d2) { inc(); } } context.months--; context.months *= orient; context.years *= orient; }; var adjustForDST = function(orient, startDate, endDate) { var hasDSTMismatch = (false === (startDate.isDaylightSavingTime() === endDate.isDaylightSavingTime())); if (hasDSTMismatch && orient === 1) { startDate.addHours(-1); } else if (hasDSTMismatch) { startDate.addHours(1); } }; /** * TimePeriod(startDate, endDate); * TimePeriod(years, months, days, hours, minutes, seconds, milliseconds); */ var TimePeriod = function (years, months, days, hours, minutes, seconds, milliseconds) { if (arguments.length === 7) { this.set(years, months, days, hours, minutes, seconds, milliseconds); } else if (arguments.length === 2 && arguments[0] instanceof Date && arguments[1] instanceof Date) { var startDate = arguments[0].clone(); var endDate = arguments[1].clone(); var orient = (startDate > endDate) ? +1 : -1; this.dates = { start: arguments[0].clone(), end: arguments[1].clone() }; setMonthsAndYears(orient, startDate, endDate, this); adjustForDST(orient, startDate, endDate); // // TODO - adjust for DST var diff = endDate - startDate; if (diff !== 0) { var ts = new TimeSpan(diff); this.set(this.years, this.months, ts.getDays(), ts.getHours(), ts.getMinutes(), ts.getSeconds(), ts.getMilliseconds()); } } return this; }; // create all the set functions. addSetFuncs(TimePeriod, attrs); TimePeriod.prototype.set = function (years, months, days, hours, minutes, seconds, milliseconds){ this.setYears(years || this.getYears()); this.setMonths(months || this.getMonths()); this.setDays(days || this.getDays()); this.setHours(hours || this.getHours()); this.setMinutes(minutes || this.getMinutes()); this.setSeconds(seconds || this.getSeconds()); this.setMilliseconds(milliseconds || this.getMilliseconds()); }; Date.TimePeriod = TimePeriod; if (typeof window !== "undefined") { // keeping API compatible for v1.x window.TimePeriod = TimePeriod; } }()); ================================================ FILE: build/date-az-Latn-AZ.js ================================================ /** * @overview datejs * @version 1.0.0-rc3 * @author Gregory Wild-Smith * @copyright 2015 Gregory Wild-Smith * @license MIT * @homepage https://github.com/abritinthebay/datejs */ /* * DateJS Culture String File * Country Code: az-Latn-AZ * Name: Azeri (Latin, Azerbaijan) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["az-Latn-AZ"] = { "name": "az-Latn-AZ", "englishName": "Azeri (Latin, Azerbaijan)", "nativeName": "Azərbaycan­ılı (Azərbaycanca)", "Sunday": "Bazar", "Monday": "Bazar ertəsi", "Tuesday": "Çərşənbə axşamı", "Wednesday": "Çərşənbə", "Thursday": "Cümə axşamı", "Friday": "Cümə", "Saturday": "Şənbə", "Sun": "B", "Mon": "Be", "Tue": "Ça", "Wed": "Ç", "Thu": "Ca", "Fri": "C", "Sat": "Ş", "Su": "B", "Mo": "Be", "Tu": "Ça", "We": "Ç", "Th": "Ca", "Fr": "C", "Sa": "Ş", "S_Sun_Initial": "B", "M_Mon_Initial": "B", "T_Tue_Initial": "Ç", "W_Wed_Initial": "Ç", "T_Thu_Initial": "C", "F_Fri_Initial": "C", "S_Sat_Initial": "Ş", "January": "Yanvar", "February": "Fevral", "March": "Mart", "April": "Aprel", "May": "May", "June": "İyun", "July": "İyul", "August": "Avgust", "September": "Sentyabr", "October": "Oktyabr", "November": "Noyabr", "December": "Dekabr", "Jan_Abbr": "Yan", "Feb_Abbr": "Fev", "Mar_Abbr": "Mar", "Apr_Abbr": "Apr", "May_Abbr": "May", "Jun_Abbr": "İyun", "Jul_Abbr": "İyul", "Aug_Abbr": "Avg", "Sep_Abbr": "Sen", "Oct_Abbr": "Okt", "Nov_Abbr": "Noy", "Dec_Abbr": "Dek", "AM": "", "PM": "", "firstDayOfWeek": 1, "twoDigitYearMax": 2029, "mdy": "dmy", "M/d/yyyy": "dd.MM.yyyy", "dddd, MMMM dd, yyyy": "d MMMM yyyy", "h:mm tt": "H:mm", "h:mm:ss tt": "H:mm:ss", "dddd, MMMM dd, yyyy h:mm:ss tt": "d MMMM yyyy H:mm:ss", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "d MMMM", "MMMM, yyyy": "MMMM yyyy", "/jan(uary)?/": "yan(var)?", "/feb(ruary)?/": "fev(ral)?", "/mar(ch)?/": "mar(t)?", "/apr(il)?/": "apr(el)?", "/may/": "may", "/jun(e)?/": "iyun", "/jul(y)?/": "iyul", "/aug(ust)?/": "avg(ust)?", "/sep(t(ember)?)?/": "sen(tyabr)?", "/oct(ober)?/": "okt(yabr)?", "/nov(ember)?/": "noy(abr)?", "/dec(ember)?/": "dek(abr)?", "/^su(n(day)?)?/": "^bazar", "/^mo(n(day)?)?/": "^bazar ertəsi", "/^tu(e(s(day)?)?)?/": "^çərşənbə axşamı", "/^we(d(nesday)?)?/": "^çərşənbə", "/^th(u(r(s(day)?)?)?)?/": "^cümə axşamı", "/^fr(i(day)?)?/": "^cümə", "/^sa(t(urday)?)?/": "^şənbə", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "az-Latn-AZ"; /** * @overview datejs * @version 1.0.0-rc3 * @author Gregory Wild-Smith * @copyright 2015 Gregory Wild-Smith * @license MIT * @homepage https://github.com/abritinthebay/datejs */(function () { var $D = Date; var lang = Date.CultureStrings ? Date.CultureStrings.lang : null; var loggedKeys = {}; // for debug purposes. var getText = { getFromKey: function (key, countryCode) { var output; if (Date.CultureStrings && Date.CultureStrings[countryCode] && Date.CultureStrings[countryCode][key]) { output = Date.CultureStrings[countryCode][key]; } else { output = getText.buildFromDefault(key); } if (key.charAt(0) === "/") { // Assume it's a regex output = getText.buildFromRegex(key, countryCode); } return output; }, getFromObjectValues: function (obj, countryCode) { var key, output = {}; for(key in obj) { if (obj.hasOwnProperty(key)) { output[key] = getText.getFromKey(obj[key], countryCode); } } return output; }, getFromObjectKeys: function (obj, countryCode) { var key, output = {}; for(key in obj) { if (obj.hasOwnProperty(key)) { output[getText.getFromKey(key, countryCode)] = obj[key]; } } return output; }, getFromArray: function (arr, countryCode) { var output = []; for (var i=0; i < arr.length; i++){ if (i in arr) { output[i] = getText.getFromKey(arr[i], countryCode); } } return output; }, buildFromDefault: function (key) { var output, length, split, last; switch(key) { case "name": output = "en-US"; break; case "englishName": output = "English (United States)"; break; case "nativeName": output = "English (United States)"; break; case "twoDigitYearMax": output = 2049; break; case "firstDayOfWeek": output = 0; break; default: output = key; split = key.split("_"); length = split.length; if (length > 1 && key.charAt(0) !== "/") { // if the key isn't a regex and it has a split. last = split[(length - 1)].toLowerCase(); if (last === "initial" || last === "abbr") { output = split[0]; } } break; } return output; }, buildFromRegex: function (key, countryCode) { var output; if (Date.CultureStrings && Date.CultureStrings[countryCode] && Date.CultureStrings[countryCode][key]) { output = new RegExp(Date.CultureStrings[countryCode][key], "i"); } else { output = new RegExp(key.replace(new RegExp("/", "g"),""), "i"); } return output; } }; var shallowMerge = function (obj1, obj2) { for (var attrname in obj2) { if (obj2.hasOwnProperty(attrname)) { obj1[attrname] = obj2[attrname]; } } }; var __ = function (key, language) { var countryCode = (language) ? language : lang; loggedKeys[key] = key; if (typeof key === "object") { if (key instanceof Array) { return getText.getFromArray(key, countryCode); } else { return getText.getFromObjectKeys(key, countryCode); } } else { return getText.getFromKey(key, countryCode); } }; var loadI18nScript = function (code) { // paatterned after jQuery's getScript. var url = Date.Config.i18n + code + ".js"; var head = document.getElementsByTagName("head")[0] || document.documentElement; var script = document.createElement("script"); script.src = url; var completed = false; var events = { done: function (){} // placeholder function }; // Attach handlers for all browsers script.onload = script.onreadystatechange = function() { if ( !completed && (!this.readyState || this.readyState === "loaded" || this.readyState === "complete") ) { events.done(); head.removeChild(script); } }; setTimeout(function() { head.insertBefore(script, head.firstChild); }, 0); // allows return to execute first return { done: function (cb) { events.done = function() { if (cb) { setTimeout(cb,0); } }; } }; }; var buildInfo = { buildFromMethodHash: function (obj) { var key; for(key in obj) { if (obj.hasOwnProperty(key)) { obj[key] = buildInfo[obj[key]](); } } return obj; }, timeZoneDST: function () { var DST = { "CHADT": "+1345", "NZDT": "+1300", "AEDT": "+1100", "ACDT": "+1030", "AZST": "+0500", "IRDT": "+0430", "EEST": "+0300", "CEST": "+0200", "BST": "+0100", "PMDT": "-0200", "ADT": "-0300", "NDT": "-0230", "EDT": "-0400", "CDT": "-0500", "MDT": "-0600", "PDT": "-0700", "AKDT": "-0800", "HADT": "-0900" }; return __(DST); }, timeZoneStandard: function () { var standard = { "LINT": "+1400", "TOT": "+1300", "CHAST": "+1245", "NZST": "+1200", "NFT": "+1130", "SBT": "+1100", "AEST": "+1000", "ACST": "+0930", "JST": "+0900", "CWST": "+0845", "CT": "+0800", "ICT": "+0700", "MMT": "+0630", "BST": "+0600", "NPT": "+0545", "IST": "+0530", "PKT": "+0500", "AFT": "+0430", "MSK": "+0400", "IRST": "+0330", "FET": "+0300", "EET": "+0200", "CET": "+0100", "GMT": "+0000", "UTC": "+0000", "CVT": "-0100", "GST": "-0200", "BRT": "-0300", "NST": "-0330", "AST": "-0400", "EST": "-0500", "CST": "-0600", "MST": "-0700", "PST": "-0800", "AKST": "-0900", "MIT": "-0930", "HST": "-1000", "SST": "-1100", "BIT": "-1200" }; return __(standard); }, timeZones: function (data) { var zone; data.timezones = []; for (zone in data.abbreviatedTimeZoneStandard) { if (data.abbreviatedTimeZoneStandard.hasOwnProperty(zone)) { data.timezones.push({ name: zone, offset: data.abbreviatedTimeZoneStandard[zone]}); } } for (zone in data.abbreviatedTimeZoneDST) { if (data.abbreviatedTimeZoneDST.hasOwnProperty(zone)) { data.timezones.push({ name: zone, offset: data.abbreviatedTimeZoneDST[zone], dst: true}); } } return data.timezones; }, days: function () { return __(["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"]); }, dayAbbr: function () { return __(["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"]); }, dayShortNames: function () { return __(["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"]); }, dayFirstLetters: function () { return __(["S_Sun_Initial", "M_Mon_Initial", "T_Tues_Initial", "W_Wed_Initial", "T_Thu_Initial", "F_Fri_Initial", "S_Sat_Initial"]); }, months: function () { return __(["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"]); }, monthAbbr: function () { return __(["Jan_Abbr", "Feb_Abbr", "Mar_Abbr", "Apr_Abbr", "May_Abbr", "Jun_Abbr", "Jul_Abbr", "Aug_Abbr", "Sep_Abbr", "Oct_Abbr", "Nov_Abbr", "Dec_Abbr"]); }, formatPatterns: function () { return getText.getFromObjectValues({ shortDate: "M/d/yyyy", longDate: "dddd, MMMM dd, yyyy", shortTime: "h:mm tt", longTime: "h:mm:ss tt", fullDateTime: "dddd, MMMM dd, yyyy h:mm:ss tt", sortableDateTime: "yyyy-MM-ddTHH:mm:ss", universalSortableDateTime: "yyyy-MM-dd HH:mm:ssZ", rfc1123: "ddd, dd MMM yyyy HH:mm:ss", monthDay: "MMMM dd", yearMonth: "MMMM, yyyy" }, Date.i18n.currentLanguage()); }, regex: function () { return getText.getFromObjectValues({ inTheMorning: "/( in the )(morn(ing)?)\\b/", thisMorning: "/(this )(morn(ing)?)\\b/", amThisMorning: "/(\b\\d(am)? )(this )(morn(ing)?)/", inTheEvening: "/( in the )(even(ing)?)\\b/", thisEvening: "/(this )(even(ing)?)\\b/", pmThisEvening: "/(\b\\d(pm)? )(this )(even(ing)?)/", jan: "/jan(uary)?/", feb: "/feb(ruary)?/", mar: "/mar(ch)?/", apr: "/apr(il)?/", may: "/may/", jun: "/jun(e)?/", jul: "/jul(y)?/", aug: "/aug(ust)?/", sep: "/sep(t(ember)?)?/", oct: "/oct(ober)?/", nov: "/nov(ember)?/", dec: "/dec(ember)?/", sun: "/^su(n(day)?)?/", mon: "/^mo(n(day)?)?/", tue: "/^tu(e(s(day)?)?)?/", wed: "/^we(d(nesday)?)?/", thu: "/^th(u(r(s(day)?)?)?)?/", fri: "/fr(i(day)?)?/", sat: "/^sa(t(urday)?)?/", future: "/^next/", past: "/^last|past|prev(ious)?/", add: "/^(\\+|aft(er)?|from|hence)/", subtract: "/^(\\-|bef(ore)?|ago)/", yesterday: "/^yes(terday)?/", today: "/^t(od(ay)?)?/", tomorrow: "/^tom(orrow)?/", now: "/^n(ow)?/", millisecond: "/^ms|milli(second)?s?/", second: "/^sec(ond)?s?/", minute: "/^mn|min(ute)?s?/", hour: "/^h(our)?s?/", week: "/^w(eek)?s?/", month: "/^m(onth)?s?/", day: "/^d(ay)?s?/", year: "/^y(ear)?s?/", shortMeridian: "/^(a|p)/", longMeridian: "/^(a\\.?m?\\.?|p\\.?m?\\.?)/", timezone: "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/", ordinalSuffix: "/^\\s*(st|nd|rd|th)/", timeContext: "/^\\s*(\\:|a(?!u|p)|p)/" }, Date.i18n.currentLanguage()); } }; var CultureInfo = function () { var info = getText.getFromObjectValues({ name: "name", englishName: "englishName", nativeName: "nativeName", amDesignator: "AM", pmDesignator: "PM", firstDayOfWeek: "firstDayOfWeek", twoDigitYearMax: "twoDigitYearMax", dateElementOrder: "mdy" }, Date.i18n.currentLanguage()); var constructedInfo = buildInfo.buildFromMethodHash({ dayNames: "days", abbreviatedDayNames: "dayAbbr", shortestDayNames: "dayShortNames", firstLetterDayNames: "dayFirstLetters", monthNames: "months", abbreviatedMonthNames: "monthAbbr", formatPatterns: "formatPatterns", regexPatterns: "regex", abbreviatedTimeZoneDST: "timeZoneDST", abbreviatedTimeZoneStandard: "timeZoneStandard" }); shallowMerge(info, constructedInfo); buildInfo.timeZones(info); return info; }; $D.i18n = { __: function (key, lang) { return __(key, lang); }, currentLanguage: function () { return lang || "en-US"; }, setLanguage: function (code, force, cb) { var async = false; if (force || code === "en-US" || (!!Date.CultureStrings && !!Date.CultureStrings[code])) { lang = code; Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings.lang = code; Date.CultureInfo = new CultureInfo(); } else { if (!(!!Date.CultureStrings && !!Date.CultureStrings[code])) { if (typeof exports !== "undefined" && this.exports !== exports) { // we're in a Node enviroment, load it using require try { require("../i18n/" + code + ".js"); lang = code; Date.CultureStrings.lang = code; Date.CultureInfo = new CultureInfo(); } catch (e) { // var str = "The language for '" + code + "' could not be loaded by Node. It likely does not exist."; throw new Error("The DateJS IETF language tag '" + code + "' could not be loaded by Node. It likely does not exist."); } } else if (Date.Config && Date.Config.i18n) { // we know the location of the files, so lets load them async = true; loadI18nScript(code).done(function(){ lang = code; Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings.lang = code; Date.CultureInfo = new CultureInfo(); $D.Parsing.Normalizer.buildReplaceData(); // because this is async if ($D.Grammar) { $D.Grammar.buildGrammarFormats(); // so we can parse those strings... } if (cb) { setTimeout(cb,0); } }); } else { Date.console.error("The DateJS IETF language tag '" + code + "' is not available and has not been loaded."); return false; } } } $D.Parsing.Normalizer.buildReplaceData(); // rebuild normalizer strings if ($D.Grammar) { $D.Grammar.buildGrammarFormats(); // so we can parse those strings... } if (!async && cb) { setTimeout(cb,0); } }, getLoggedKeys: function () { return loggedKeys; }, updateCultureInfo: function () { Date.CultureInfo = new CultureInfo(); } }; $D.i18n.updateCultureInfo(); // run automatically }()); (function () { var $D = Date, $P = $D.prototype, p = function (s, l) { if (!l) { l = 2; } return ("000" + s).slice(l * -1); }; if (typeof window !== "undefined" && typeof window.console !== "undefined" && typeof window.console.log !== "undefined") { $D.console = console; // used only to raise non-critical errors if available } else { // set mock so we don't give errors. $D.console = { log: function(){}, error: function(){} }; } $D.Config = $D.Config || {}; $D.initOverloads = function() { /** * Overload of Date.now. Allows an alternate call for Date.now where it returns the * current Date as an object rather than just milliseconds since the Unix Epoch. * * Also provides an implementation of now() for browsers (IE<9) that don't have it. * * Backwards compatible so with work with either: * Date.now() [returns ms] * or * Date.now(true) [returns Date] */ if (!$D.now) { $D._now = function now() { return new Date().getTime(); }; } else if (!$D._now) { $D._now = $D.now; } $D.now = function (returnObj) { if (returnObj) { return $D.present(); } else { return $D._now(); } }; if ( !$P.toISOString ) { $P.toISOString = function() { return this.getUTCFullYear() + "-" + p(this.getUTCMonth() + 1) + "-" + p(this.getUTCDate()) + "T" + p(this.getUTCHours()) + ":" + p(this.getUTCMinutes()) + ":" + p(this.getUTCSeconds()) + "." + String( (this.getUTCMilliseconds()/1000).toFixed(3)).slice(2, 5) + "Z"; }; } // private if ( $P._toString === undefined ){ $P._toString = $P.toString; } }; $D.initOverloads(); /** * Gets a date that is set to the current date. The time is set to the start of the day (00:00 or 12:00 AM). * @return {Date} The current date. */ $D.today = function () { return new Date().clearTime(); }; /** * Gets a date that is set to the current date and time (same as new Date, but chainable) * @return {Date} The current date. */ $D.present = function () { return new Date(); }; /** * Compares the first date to the second date and returns an number indication of their relative values. * @param {Date} First Date object to compare [Required]. * @param {Date} Second Date object to compare to [Required]. * @return {Number} -1 = date1 is lessthan date2. 0 = values are equal. 1 = date1 is greaterthan date2. */ $D.compare = function (date1, date2) { if (isNaN(date1) || isNaN(date2)) { throw new Error(date1 + " - " + date2); } else if (date1 instanceof Date && date2 instanceof Date) { return (date1 < date2) ? -1 : (date1 > date2) ? 1 : 0; } else { throw new TypeError(date1 + " - " + date2); } }; /** * Compares the first Date object to the second Date object and returns true if they are equal. * @param {Date} First Date object to compare [Required] * @param {Date} Second Date object to compare to [Required] * @return {Boolean} true if dates are equal. false if they are not equal. */ $D.equals = function (date1, date2) { return (date1.compareTo(date2) === 0); }; /** * Gets the language appropriate day name when given the day number(0-6) * eg - 0 == Sunday * @return {String} The day name */ $D.getDayName = function (n) { return Date.CultureInfo.dayNames[n]; }; /** * Gets the day number (0-6) if given a CultureInfo specific string which is a valid dayName, abbreviatedDayName or shortestDayName (two char). * @param {String} The name of the day (eg. "Monday, "Mon", "tuesday", "tue", "We", "we"). * @return {Number} The day number */ $D.getDayNumberFromName = function (name) { var n = Date.CultureInfo.dayNames, m = Date.CultureInfo.abbreviatedDayNames, o = Date.CultureInfo.shortestDayNames, s = name.toLowerCase(); for (var i = 0; i < n.length; i++) { if (n[i].toLowerCase() === s || m[i].toLowerCase() === s || o[i].toLowerCase() === s) { return i; } } return -1; }; /** * Gets the month number (0-11) if given a Culture Info specific string which is a valid monthName or abbreviatedMonthName. * @param {String} The name of the month (eg. "February, "Feb", "october", "oct"). * @return {Number} The day number */ $D.getMonthNumberFromName = function (name) { var n = Date.CultureInfo.monthNames, m = Date.CultureInfo.abbreviatedMonthNames, s = name.toLowerCase(); for (var i = 0; i < n.length; i++) { if (n[i].toLowerCase() === s || m[i].toLowerCase() === s) { return i; } } return -1; }; /** * Gets the language appropriate month name when given the month number(0-11) * eg - 0 == January * @return {String} The month name */ $D.getMonthName = function (n) { return Date.CultureInfo.monthNames[n]; }; /** * Determines if the current date instance is within a LeapYear. * @param {Number} The year. * @return {Boolean} true if date is within a LeapYear, otherwise false. */ $D.isLeapYear = function (year) { return ((year % 4 === 0 && year % 100 !== 0) || year % 400 === 0); }; /** * Gets the number of days in the month, given a year and month value. Automatically corrects for LeapYear. * @param {Number} The year. * @param {Number} The month (0-11). * @return {Number} The number of days in the month. */ $D.getDaysInMonth = function (year, month) { if (!month && $D.validateMonth(year)) { month = year; year = Date.today().getFullYear(); } return [31, ($D.isLeapYear(year) ? 29 : 28), 31, 30, 31, 30, 31, 31, 30, 31, 30, 31][month]; }; $P.getDaysInMonth = function () { return $D.getDaysInMonth(this.getFullYear(), this.getMonth()); }; $D.getTimezoneAbbreviation = function (offset, dst) { var p, n = (dst || false) ? Date.CultureInfo.abbreviatedTimeZoneDST : Date.CultureInfo.abbreviatedTimeZoneStandard; for (p in n) { if (n.hasOwnProperty(p)) { if (n[p] === offset) { return p; } } } return null; }; $D.getTimezoneOffset = function (name, dst) { var i, a =[], z = Date.CultureInfo.timezones; if (!name) { name = (new Date()).getTimezone();} for (i = 0; i < z.length; i++) { if (z[i].name === name.toUpperCase()) { a.push(i); } } if (!z[a[0]]) { return null; } if (a.length === 1 || !dst) { return z[a[0]].offset; } else { for (i=0; i < a.length; i++) { if (z[a[i]].dst) { return z[a[i]].offset; } } } }; $D.getQuarter = function (d) { d = d || new Date(); // If no date supplied, use today var q = [1,2,3,4]; return q[Math.floor(d.getMonth() / 3)]; // ~~~ is a bitwise op. Faster than Math.floor }; $D.getDaysLeftInQuarter = function (d) { d = d || new Date(); var qEnd = new Date(d); qEnd.setMonth(qEnd.getMonth() + 3 - qEnd.getMonth() % 3, 0); return Math.floor((qEnd - d) / 8.64e7); }; // private var validate = function (n, min, max, name) { name = name ? name : "Object"; if (typeof n === "undefined") { return false; } else if (typeof n !== "number") { throw new TypeError(n + " is not a Number."); } else if (n < min || n > max) { // As failing validation is *not* an exceptional circumstance // lets not throw a RangeError Exception here. // It's semantically correct but it's not sensible. return false; } return true; }; /** * Validates the number is within an acceptable range for milliseconds [0-999]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateMillisecond = function (value) { return validate(value, 0, 999, "millisecond"); }; /** * Validates the number is within an acceptable range for seconds [0-59]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateSecond = function (value) { return validate(value, 0, 59, "second"); }; /** * Validates the number is within an acceptable range for minutes [0-59]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateMinute = function (value) { return validate(value, 0, 59, "minute"); }; /** * Validates the number is within an acceptable range for hours [0-23]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateHour = function (value) { return validate(value, 0, 23, "hour"); }; /** * Validates the number is within an acceptable range for the days in a month [0-MaxDaysInMonth]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateDay = function (value, year, month) { if (year === undefined || year === null || month === undefined || month === null) { return false;} return validate(value, 1, $D.getDaysInMonth(year, month), "day"); }; /** * Validates the number is within an acceptable range for months [0-11]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateWeek = function (value) { return validate(value, 0, 53, "week"); }; /** * Validates the number is within an acceptable range for months [0-11]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateMonth = function (value) { return validate(value, 0, 11, "month"); }; /** * Validates the number is within an acceptable range for years. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateYear = function (value) { /** * Per ECMAScript spec the range of times supported by Date objects is * exactly -100,000,000 days to +100,000,000 days measured relative to * midnight at the beginning of 01 January, 1970 UTC. * This gives a range of 8,640,000,000,000,000 milliseconds to either * side of 01 January, 1970 UTC. * * Earliest possible date: Tue, 20 Apr 271,822 B.C. 00:00:00 UTC * Latest possible date: Sat, 13 Sep 275,760 00:00:00 UTC */ return validate(value, -271822, 275760, "year"); }; $D.validateTimezone = function(value) { var timezones = {"ACDT":1,"ACST":1,"ACT":1,"ADT":1,"AEDT":1,"AEST":1,"AFT":1,"AKDT":1,"AKST":1,"AMST":1,"AMT":1,"ART":1,"AST":1,"AWDT":1,"AWST":1,"AZOST":1,"AZT":1,"BDT":1,"BIOT":1,"BIT":1,"BOT":1,"BRT":1,"BST":1,"BTT":1,"CAT":1,"CCT":1,"CDT":1,"CEDT":1,"CEST":1,"CET":1,"CHADT":1,"CHAST":1,"CHOT":1,"ChST":1,"CHUT":1,"CIST":1,"CIT":1,"CKT":1,"CLST":1,"CLT":1,"COST":1,"COT":1,"CST":1,"CT":1,"CVT":1,"CWST":1,"CXT":1,"DAVT":1,"DDUT":1,"DFT":1,"EASST":1,"EAST":1,"EAT":1,"ECT":1,"EDT":1,"EEDT":1,"EEST":1,"EET":1,"EGST":1,"EGT":1,"EIT":1,"EST":1,"FET":1,"FJT":1,"FKST":1,"FKT":1,"FNT":1,"GALT":1,"GAMT":1,"GET":1,"GFT":1,"GILT":1,"GIT":1,"GMT":1,"GST":1,"GYT":1,"HADT":1,"HAEC":1,"HAST":1,"HKT":1,"HMT":1,"HOVT":1,"HST":1,"ICT":1,"IDT":1,"IOT":1,"IRDT":1,"IRKT":1,"IRST":1,"IST":1,"JST":1,"KGT":1,"KOST":1,"KRAT":1,"KST":1,"LHST":1,"LINT":1,"MAGT":1,"MART":1,"MAWT":1,"MDT":1,"MET":1,"MEST":1,"MHT":1,"MIST":1,"MIT":1,"MMT":1,"MSK":1,"MST":1,"MUT":1,"MVT":1,"MYT":1,"NCT":1,"NDT":1,"NFT":1,"NPT":1,"NST":1,"NT":1,"NUT":1,"NZDT":1,"NZST":1,"OMST":1,"ORAT":1,"PDT":1,"PET":1,"PETT":1,"PGT":1,"PHOT":1,"PHT":1,"PKT":1,"PMDT":1,"PMST":1,"PONT":1,"PST":1,"PYST":1,"PYT":1,"RET":1,"ROTT":1,"SAKT":1,"SAMT":1,"SAST":1,"SBT":1,"SCT":1,"SGT":1,"SLST":1,"SRT":1,"SST":1,"SYOT":1,"TAHT":1,"THA":1,"TFT":1,"TJT":1,"TKT":1,"TLT":1,"TMT":1,"TOT":1,"TVT":1,"UCT":1,"ULAT":1,"UTC":1,"UYST":1,"UYT":1,"UZT":1,"VET":1,"VLAT":1,"VOLT":1,"VOST":1,"VUT":1,"WAKT":1,"WAST":1,"WAT":1,"WEDT":1,"WEST":1,"WET":1,"WST":1,"YAKT":1,"YEKT":1,"Z":1}; return (timezones[value] === 1); }; $D.validateTimezoneOffset= function(value) { // timezones go from +14hrs to -12hrs, the +X hours are negative offsets. return (value > -841 && value < 721); }; }()); (function () { var $D = Date, $P = $D.prototype, p = function (s, l) { if (!l) { l = 2; } return ("000" + s).slice(l * -1); }; var validateConfigObject = function (obj) { var result = {}, self = this, prop, testFunc; testFunc = function (prop, func, value) { if (prop === "day") { var month = (obj.month !== undefined) ? obj.month : self.getMonth(); var year = (obj.year !== undefined) ? obj.year : self.getFullYear(); return $D[func](value, year, month); } else { return $D[func](value); } }; for (prop in obj) { if (Object.prototype.hasOwnProperty.call(obj, prop)) { var func = "validate" + prop.charAt(0).toUpperCase() + prop.slice(1); if ($D[func] && obj[prop] !== null && testFunc(prop, func, obj[prop])) { result[prop] = obj[prop]; } } } return result; }; /** * Resets the time of this Date object to 12:00 AM (00:00), which is the start of the day. * @param {Boolean} .clone() this date instance before clearing Time * @return {Date} this */ $P.clearTime = function () { this.setHours(0); this.setMinutes(0); this.setSeconds(0); this.setMilliseconds(0); return this; }; /** * Resets the time of this Date object to the current time ('now'). * @return {Date} this */ $P.setTimeToNow = function () { var n = new Date(); this.setHours(n.getHours()); this.setMinutes(n.getMinutes()); this.setSeconds(n.getSeconds()); this.setMilliseconds(n.getMilliseconds()); return this; }; /** * Returns a new Date object that is an exact date and time copy of the original instance. * @return {Date} A new Date instance */ $P.clone = function () { return new Date(this.getTime()); }; /** * Compares this instance to a Date object and returns an number indication of their relative values. * @param {Date} Date object to compare [Required] * @return {Number} -1 = this is lessthan date. 0 = values are equal. 1 = this is greaterthan date. */ $P.compareTo = function (date) { return Date.compare(this, date); }; /** * Compares this instance to another Date object and returns true if they are equal. * @param {Date} Date object to compare. If no date to compare, new Date() [now] is used. * @return {Boolean} true if dates are equal. false if they are not equal. */ $P.equals = function (date) { return Date.equals(this, (date !== undefined ? date : new Date())); }; /** * Determines if this instance is between a range of two dates or equal to either the start or end dates. * @param {Date} Start of range [Required] * @param {Date} End of range [Required] * @return {Boolean} true is this is between or equal to the start and end dates, else false */ $P.between = function (start, end) { return this.getTime() >= start.getTime() && this.getTime() <= end.getTime(); }; /** * Determines if this date occurs after the date to compare to. * @param {Date} Date object to compare. If no date to compare, new Date() ("now") is used. * @return {Boolean} true if this date instance is greater than the date to compare to (or "now"), otherwise false. */ $P.isAfter = function (date) { return this.compareTo(date || new Date()) === 1; }; /** * Determines if this date occurs before the date to compare to. * @param {Date} Date object to compare. If no date to compare, new Date() ("now") is used. * @return {Boolean} true if this date instance is less than the date to compare to (or "now"). */ $P.isBefore = function (date) { return (this.compareTo(date || new Date()) === -1); }; /** * Determines if the current Date instance occurs today. * @return {Boolean} true if this date instance is 'today', otherwise false. */ /** * Determines if the current Date instance occurs on the same Date as the supplied 'date'. * If no 'date' to compare to is provided, the current Date instance is compared to 'today'. * @param {date} Date object to compare. If no date to compare, the current Date ("now") is used. * @return {Boolean} true if this Date instance occurs on the same Day as the supplied 'date'. */ $P.isToday = $P.isSameDay = function (date) { return this.clone().clearTime().equals((date || new Date()).clone().clearTime()); }; /** * Adds the specified number of milliseconds to this instance. * @param {Number} The number of milliseconds to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addMilliseconds = function (value) { if (!value) { return this; } this.setTime(this.getTime() + value * 1); return this; }; /** * Adds the specified number of seconds to this instance. * @param {Number} The number of seconds to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addSeconds = function (value) { if (!value) { return this; } return this.addMilliseconds(value * 1000); }; /** * Adds the specified number of seconds to this instance. * @param {Number} The number of seconds to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addMinutes = function (value) { if (!value) { return this; } return this.addMilliseconds(value * 60000); // 60*1000 }; /** * Adds the specified number of hours to this instance. * @param {Number} The number of hours to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addHours = function (value) { if (!value) { return this; } return this.addMilliseconds(value * 3600000); // 60*60*1000 }; /** * Adds the specified number of days to this instance. * @param {Number} The number of days to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addDays = function (value) { if (!value) { return this; } this.setDate(this.getDate() + value * 1); return this; }; /** * Adds the specified number of weekdays (ie - not sat or sun) to this instance. * @param {Number} The number of days to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addWeekdays = function (value) { if (!value) { return this; } var day = this.getDay(); var weeks = (Math.ceil(Math.abs(value)/7)); if (day === 0 || day === 6) { if (value > 0) { this.next().monday(); this.addDays(-1); day = this.getDay(); } } if (value < 0) { while (value < 0) { this.addDays(-1); day = this.getDay(); if (day !== 0 && day !== 6) { value++; } } return this; } else if (value > 5 || (6-day) <= value) { value = value + (weeks * 2); } return this.addDays(value); }; /** * Adds the specified number of weeks to this instance. * @param {Number} The number of weeks to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addWeeks = function (value) { if (!value) { return this; } return this.addDays(value * 7); }; /** * Adds the specified number of months to this instance. * @param {Number} The number of months to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addMonths = function (value) { if (!value) { return this; } var n = this.getDate(); this.setDate(1); this.setMonth(this.getMonth() + value * 1); this.setDate(Math.min(n, $D.getDaysInMonth(this.getFullYear(), this.getMonth()))); return this; }; $P.addQuarters = function (value) { if (!value) { return this; } // note this will take you to the same point in the quarter as you are now. // i.e. - if you are 15 days into the quarter you'll be 15 days into the resulting one. // bonus: this allows adding fractional quarters return this.addMonths(value * 3); }; /** * Adds the specified number of years to this instance. * @param {Number} The number of years to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addYears = function (value) { if (!value) { return this; } return this.addMonths(value * 12); }; /** * Adds (or subtracts) to the value of the years, months, weeks, days, hours, minutes, seconds, milliseconds of the date instance using given configuration object. Positive and Negative values allowed. * Example

	Date.today().add( { days: 1, months: 1 } )

	new Date().add( { years: -1 } )
	
* @param {Object} Configuration object containing attributes (months, days, etc.) * @return {Date} this */ $P.add = function (config) { if (typeof config === "number") { this._orient = config; return this; } var x = config; if (x.day) { // If we should be a different date than today (eg: for 'tomorrow -1d', etc). // Should only effect parsing, not direct usage (eg, Finish and FinishExact) if ((x.day - this.getDate()) !== 0) { this.setDate(x.day); } } if (x.milliseconds) { this.addMilliseconds(x.milliseconds); } if (x.seconds) { this.addSeconds(x.seconds); } if (x.minutes) { this.addMinutes(x.minutes); } if (x.hours) { this.addHours(x.hours); } if (x.weeks) { this.addWeeks(x.weeks); } if (x.months) { this.addMonths(x.months); } if (x.years) { this.addYears(x.years); } if (x.days) { this.addDays(x.days); } return this; }; /** * Get the week number. Week one (1) is the week which contains the first Thursday of the year. Monday is considered the first day of the week. * The .getWeek() function does NOT convert the date to UTC. The local datetime is used. * Please use .getISOWeek() to get the week of the UTC converted date. * @return {Number} 1 to 53 */ $P.getWeek = function (utc) { // Create a copy of this date object var self, target = new Date(this.valueOf()); if (utc) { target.addMinutes(target.getTimezoneOffset()); self = target.clone(); } else { self = this; } // ISO week date weeks start on monday // so correct the day number var dayNr = (self.getDay() + 6) % 7; // ISO 8601 states that week 1 is the week // with the first thursday of that year. // Set the target date to the thursday in the target week target.setDate(target.getDate() - dayNr + 3); // Store the millisecond value of the target date var firstThursday = target.valueOf(); // Set the target to the first thursday of the year // First set the target to january first target.setMonth(0, 1); // Not a thursday? Correct the date to the next thursday if (target.getDay() !== 4) { target.setMonth(0, 1 + ((4 - target.getDay()) + 7) % 7); } // The weeknumber is the number of weeks between the // first thursday of the year and the thursday in the target week return 1 + Math.ceil((firstThursday - target) / 604800000); // 604800000 = 7 * 24 * 3600 * 1000 }; /** * Get the ISO 8601 week number. Week one ("01") is the week which contains the first Thursday of the year. Monday is considered the first day of the week. * The .getISOWeek() function does convert the date to it's UTC value. Please use .getWeek() to get the week of the local date. * @return {String} "01" to "53" */ $P.getISOWeek = function () { return p(this.getWeek(true)); }; /** * Moves the date to Monday of the week set. Week one (1) is the week which contains the first Thursday of the year. * @param {Number} A Number (1 to 53) that represents the week of the year. * @return {Date} this */ $P.setWeek = function (n) { if ((n - this.getWeek()) === 0) { if (this.getDay() !== 1) { return this.moveToDayOfWeek(1, (this.getDay() > 1 ? -1 : 1)); } else { return this; } } else { return this.moveToDayOfWeek(1, (this.getDay() > 1 ? -1 : 1)).addWeeks(n - this.getWeek()); } }; $P.setQuarter = function (qtr) { var month = Math.abs(((qtr-1) * 3) + 1); return this.setMonth(month, 1); }; $P.getQuarter = function () { return Date.getQuarter(this); }; $P.getDaysLeftInQuarter = function () { return Date.getDaysLeftInQuarter(this); }; /** * Moves the date to the next n'th occurrence of the dayOfWeek starting from the beginning of the month. The number (-1) is a magic number and will return the last occurrence of the dayOfWeek in the month. * @param {Number} The dayOfWeek to move to * @param {Number} The n'th occurrence to move to. Use (-1) to return the last occurrence in the month * @return {Date} this */ $P.moveToNthOccurrence = function (dayOfWeek, occurrence) { if (dayOfWeek === "Weekday") { if (occurrence > 0) { this.moveToFirstDayOfMonth(); if (this.is().weekday()) { occurrence -= 1; } } else if (occurrence < 0) { this.moveToLastDayOfMonth(); if (this.is().weekday()) { occurrence += 1; } } else { return this; } return this.addWeekdays(occurrence); } var shift = 0; if (occurrence > 0) { shift = occurrence - 1; } else if (occurrence === -1) { this.moveToLastDayOfMonth(); if (this.getDay() !== dayOfWeek) { this.moveToDayOfWeek(dayOfWeek, -1); } return this; } return this.moveToFirstDayOfMonth().addDays(-1).moveToDayOfWeek(dayOfWeek, +1).addWeeks(shift); }; var moveToN = function (getFunc, addFunc, nVal) { return function (value, orient) { var diff = (value - this[getFunc]() + nVal * (orient || +1)) % nVal; return this[addFunc]((diff === 0) ? diff += nVal * (orient || +1) : diff); }; }; /** * Move to the next or last dayOfWeek based on the orient value. * @param {Number} The dayOfWeek to move to * @param {Number} Forward (+1) or Back (-1). Defaults to +1. [Optional] * @return {Date} this */ $P.moveToDayOfWeek = moveToN("getDay", "addDays", 7); /** * Move to the next or last month based on the orient value. * @param {Number} The month to move to. 0 = January, 11 = December * @param {Number} Forward (+1) or Back (-1). Defaults to +1. [Optional] * @return {Date} this */ $P.moveToMonth = moveToN("getMonth", "addMonths", 12); /** * Get the Ordinate of the current day ("th", "st", "rd"). * @return {String} */ $P.getOrdinate = function () { var num = this.getDate(); return ord(num); }; /** * Get the Ordinal day (numeric day number) of the year, adjusted for leap year. * @return {Number} 1 through 365 (366 in leap years) */ $P.getOrdinalNumber = function () { return Math.ceil((this.clone().clearTime() - new Date(this.getFullYear(), 0, 1)) / 86400000) + 1; }; /** * Get the time zone abbreviation of the current date. * @return {String} The abbreviated time zone name (e.g. "EST") */ $P.getTimezone = function () { return $D.getTimezoneAbbreviation(this.getUTCOffset(), this.isDaylightSavingTime()); }; $P.setTimezoneOffset = function (offset) { var here = this.getTimezoneOffset(), there = Number(offset) * -6 / 10; return (there || there === 0) ? this.addMinutes(there - here) : this; }; $P.setTimezone = function (offset) { return this.setTimezoneOffset($D.getTimezoneOffset(offset)); }; /** * Indicates whether Daylight Saving Time is observed in the current time zone. * @return {Boolean} true|false */ $P.hasDaylightSavingTime = function () { return (Date.today().set({month: 0, day: 1}).getTimezoneOffset() !== Date.today().set({month: 6, day: 1}).getTimezoneOffset()); }; /** * Indicates whether this Date instance is within the Daylight Saving Time range for the current time zone. * @return {Boolean} true|false */ $P.isDaylightSavingTime = function () { return Date.today().set({month: 0, day: 1}).getTimezoneOffset() !== this.getTimezoneOffset(); }; /** * Get the offset from UTC of the current date. * @return {String} The 4-character offset string prefixed with + or - (e.g. "-0500") */ $P.getUTCOffset = function (offset) { var n = (offset || this.getTimezoneOffset()) * -10 / 6, r; if (n < 0) { r = (n - 10000).toString(); return r.charAt(0) + r.substr(2); } else { r = (n + 10000).toString(); return "+" + r.substr(1); } }; /** * Returns the number of milliseconds between this date and date. * @param {Date} Defaults to now * @return {Number} The diff in milliseconds */ $P.getElapsed = function (date) { return (date || new Date()) - this; }; /** * Set the value of year, month, day, hour, minute, second, millisecond of date instance using given configuration object. * Example

	Date.today().set( { day: 20, month: 1 } )

	new Date().set( { millisecond: 0 } )
	
* * @param {Object} Configuration object containing attributes (month, day, etc.) * @return {Date} this */ $P.set = function (config) { config = validateConfigObject.call(this, config); var key; for (key in config) { if (Object.prototype.hasOwnProperty.call(config, key)) { var name = key.charAt(0).toUpperCase() + key.slice(1); var addFunc, getFunc; if (key !== "week" && key !== "month" && key !== "timezone" && key !== "timezoneOffset") { name += "s"; } addFunc = "add" + name; getFunc = "get" + name; if (key === "month") { addFunc = addFunc + "s"; } else if (key === "year"){ getFunc = "getFullYear"; } if (key !== "day" && key !== "timezone" && key !== "timezoneOffset" && key !== "week" && key !== "hour") { this[addFunc](config[key] - this[getFunc]()); } else if ( key === "timezone"|| key === "timezoneOffset" || key === "week" || key === "hour") { this["set"+name](config[key]); } } } // day has to go last because you can't validate the day without first knowing the month if (config.day) { this.addDays(config.day - this.getDate()); } return this; }; /** * Moves the date to the first day of the month. * @return {Date} this */ $P.moveToFirstDayOfMonth = function () { return this.set({ day: 1 }); }; /** * Moves the date to the last day of the month. * @return {Date} this */ $P.moveToLastDayOfMonth = function () { return this.set({ day: $D.getDaysInMonth(this.getFullYear(), this.getMonth())}); }; /** * Converts the value of the current Date object to its equivalent string representation. * Format Specifiers * CUSTOM DATE AND TIME FORMAT STRINGS * Format Description Example * ------ --------------------------------------------------------------------------- ----------------------- * s The seconds of the minute between 0-59. "0" to "59" * ss The seconds of the minute with leading zero if required. "00" to "59" * * m The minute of the hour between 0-59. "0" or "59" * mm The minute of the hour with leading zero if required. "00" or "59" * * h The hour of the day between 1-12. "1" to "12" * hh The hour of the day with leading zero if required. "01" to "12" * * H The hour of the day between 0-23. "0" to "23" * HH The hour of the day with leading zero if required. "00" to "23" * * d The day of the month between 1 and 31. "1" to "31" * dd The day of the month with leading zero if required. "01" to "31" * ddd Abbreviated day name. Date.CultureInfo.abbreviatedDayNames. "Mon" to "Sun" * dddd The full day name. Date.CultureInfo.dayNames. "Monday" to "Sunday" * * M The month of the year between 1-12. "1" to "12" * MM The month of the year with leading zero if required. "01" to "12" * MMM Abbreviated month name. Date.CultureInfo.abbreviatedMonthNames. "Jan" to "Dec" * MMMM The full month name. Date.CultureInfo.monthNames. "January" to "December" * * yy The year as a two-digit number. "99" or "08" * yyyy The full four digit year. "1999" or "2008" * * t Displays the first character of the A.M./P.M. designator. "A" or "P" * Date.CultureInfo.amDesignator or Date.CultureInfo.pmDesignator * tt Displays the A.M./P.M. designator. "AM" or "PM" * Date.CultureInfo.amDesignator or Date.CultureInfo.pmDesignator * * S The ordinal suffix ("st, "nd", "rd" or "th") of the current day. "st, "nd", "rd" or "th" * * STANDARD DATE AND TIME FORMAT STRINGS * Format Description Example *------ --------------------------------------------------------------------------- ----------------------- * d The CultureInfo shortDate Format Pattern "M/d/yyyy" * D The CultureInfo longDate Format Pattern "dddd, MMMM dd, yyyy" * F The CultureInfo fullDateTime Format Pattern "dddd, MMMM dd, yyyy h:mm:ss tt" * m The CultureInfo monthDay Format Pattern "MMMM dd" * r The CultureInfo rfc1123 Format Pattern "ddd, dd MMM yyyy HH:mm:ss GMT" * s The CultureInfo sortableDateTime Format Pattern "yyyy-MM-ddTHH:mm:ss" * t The CultureInfo shortTime Format Pattern "h:mm tt" * T The CultureInfo longTime Format Pattern "h:mm:ss tt" * u The CultureInfo universalSortableDateTime Format Pattern "yyyy-MM-dd HH:mm:ssZ" * y The CultureInfo yearMonth Format Pattern "MMMM, yyyy" * * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @return {String} A string representation of the current Date object. */ var ord = function (n) { switch (n * 1) { case 1: case 21: case 31: return "st"; case 2: case 22: return "nd"; case 3: case 23: return "rd"; default: return "th"; } }; var parseStandardFormats = function (format) { var y, c = Date.CultureInfo.formatPatterns; switch (format) { case "d": return this.toString(c.shortDate); case "D": return this.toString(c.longDate); case "F": return this.toString(c.fullDateTime); case "m": return this.toString(c.monthDay); case "r": case "R": y = this.clone().addMinutes(this.getTimezoneOffset()); return y.toString(c.rfc1123) + " GMT"; case "s": return this.toString(c.sortableDateTime); case "t": return this.toString(c.shortTime); case "T": return this.toString(c.longTime); case "u": y = this.clone().addMinutes(this.getTimezoneOffset()); return y.toString(c.universalSortableDateTime); case "y": return this.toString(c.yearMonth); default: return false; } }; var parseFormatStringsClosure = function (context) { return function (m) { if (m.charAt(0) === "\\") { return m.replace("\\", ""); } switch (m) { case "hh": return p(context.getHours() < 13 ? (context.getHours() === 0 ? 12 : context.getHours()) : (context.getHours() - 12)); case "h": return context.getHours() < 13 ? (context.getHours() === 0 ? 12 : context.getHours()) : (context.getHours() - 12); case "HH": return p(context.getHours()); case "H": return context.getHours(); case "mm": return p(context.getMinutes()); case "m": return context.getMinutes(); case "ss": return p(context.getSeconds()); case "s": return context.getSeconds(); case "yyyy": return p(context.getFullYear(), 4); case "yy": return p(context.getFullYear()); case "y": return context.getFullYear(); case "E": case "dddd": return Date.CultureInfo.dayNames[context.getDay()]; case "ddd": return Date.CultureInfo.abbreviatedDayNames[context.getDay()]; case "dd": return p(context.getDate()); case "d": return context.getDate(); case "MMMM": return Date.CultureInfo.monthNames[context.getMonth()]; case "MMM": return Date.CultureInfo.abbreviatedMonthNames[context.getMonth()]; case "MM": return p((context.getMonth() + 1)); case "M": return context.getMonth() + 1; case "t": return context.getHours() < 12 ? Date.CultureInfo.amDesignator.substring(0, 1) : Date.CultureInfo.pmDesignator.substring(0, 1); case "tt": return context.getHours() < 12 ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator; case "S": return ord(context.getDate()); case "W": return context.getWeek(); case "WW": return context.getISOWeek(); case "Q": return "Q" + context.getQuarter(); case "q": return String(context.getQuarter()); case "z": return context.getTimezone(); case "Z": case "X": return Date.getTimezoneOffset(context.getTimezone()); case "ZZ": // Timezone offset in seconds return context.getTimezoneOffset() * -60; case "u": return context.getDay(); case "L": return ($D.isLeapYear(context.getFullYear())) ? 1 : 0; case "B": // Swatch Internet Time (.beats) return "@"+((context.getUTCSeconds() + (context.getUTCMinutes()*60) + ((context.getUTCHours()+1)*3600))/86.4); default: return m; } }; }; $P.toString = function (format, ignoreStandards) { // Standard Date and Time Format Strings. Formats pulled from CultureInfo file and // may vary by culture. if (!ignoreStandards && format && format.length === 1) { output = parseStandardFormats.call(this, format); if (output) { return output; } } var parseFormatStrings = parseFormatStringsClosure(this); return format ? format.replace(/((\\)?(dd?d?d?|MM?M?M?|yy?y?y?|hh?|HH?|mm?|ss?|tt?|S|q|Q|WW?W?W?)(?![^\[]*\]))/g, parseFormatStrings).replace(/\[|\]/g, "") : this._toString(); }; }()); /************************************************************* * SugarPak - Domain Specific Language - Syntactical Sugar * *************************************************************/ (function () { var $D = Date, $P = $D.prototype, $N = Number.prototype; // private $P._orient = +1; // private $P._nth = null; // private $P._is = false; // private $P._same = false; // private $P._isSecond = false; // private $N._dateElement = "days"; /** * Moves the date to the next instance of a date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.today().next().friday();
	Date.today().next().fri();
	Date.today().next().march();
	Date.today().next().mar();
	Date.today().next().week();
	
* * @return {Date} date */ $P.next = function () { this._move = true; this._orient = +1; return this; }; /** * Creates a new Date (Date.today()) and moves the date to the next instance of the date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.next().friday();
	Date.next().fri();
	Date.next().march();
	Date.next().mar();
	Date.next().week();
	
* * @return {Date} date */ $D.next = function () { return $D.today().next(); }; /** * Moves the date to the previous instance of a date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.today().last().friday();
	Date.today().last().fri();
	Date.today().last().march();
	Date.today().last().mar();
	Date.today().last().week();
	
* * @return {Date} date */ $P.last = $P.prev = $P.previous = function () { this._move = true; this._orient = -1; return this; }; /** * Creates a new Date (Date.today()) and moves the date to the previous instance of the date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.last().friday();
	Date.last().fri();
	Date.previous().march();
	Date.prev().mar();
	Date.last().week();
	
* * @return {Date} date */ $D.last = $D.prev = $D.previous = function () { return $D.today().last(); }; /** * Performs a equality check when followed by either a month name, day name or .weekday() function. * Example

	Date.today().is().friday(); // true|false
	Date.today().is().fri();
	Date.today().is().march();
	Date.today().is().mar();
	
* * @return {Boolean} true|false */ $P.is = function () { this._is = true; return this; }; /** * Determines if two date objects occur on/in exactly the same instance of the subsequent date part function. * The function .same() must be followed by a date part function (example: .day(), .month(), .year(), etc). * * An optional Date can be passed in the date part function. If now date is passed as a parameter, 'Now' is used. * * The following example demonstrates how to determine if two dates fall on the exact same day. * * Example

	var d1 = Date.today(); // today at 00:00
	var d2 = new Date();   // exactly now.

	// Do they occur on the same day?
	d1.same().day(d2); // true
	
	// Do they occur on the same hour?
	d1.same().hour(d2); // false, unless d2 hour is '00' (midnight).
	
	// What if it's the same day, but one year apart?
	var nextYear = Date.today().add(1).year();

	d1.same().day(nextYear); // false, because the dates must occur on the exact same day. 
	
* * Scenario: Determine if a given date occurs during some week period 2 months from now. * * Example

	var future = Date.today().add(2).months();
	return someDate.same().week(future); // true|false;
	
* * @return {Boolean} true|false */ $P.same = function () { this._same = true; this._isSecond = false; return this; }; /** * Determines if the current date/time occurs during Today. Must be preceded by the .is() function. * Example

	someDate.is().today();    // true|false
	new Date().is().today();  // true
	Date.today().is().today();// true
	Date.today().add(-1).day().is().today(); // false
	
* * @return {Boolean} true|false */ $P.today = function () { return this.same().day(); }; /** * Determines if the current date is a weekday. This function must be preceded by the .is() function. * Example

	Date.today().is().weekday(); // true|false
	
* * @return {Boolean} true|false */ $P.weekday = function () { if (this._nth) { return df("Weekday").call(this); } if (this._move) { return this.addWeekdays(this._orient); } if (this._is) { this._is = false; return (!this.is().sat() && !this.is().sun()); } return false; }; /** * Determines if the current date is on the weekend. This function must be preceded by the .is() function. * Example

	Date.today().is().weekend(); // true|false
	
* * @return {Boolean} true|false */ $P.weekend = function () { if (this._is) { this._is = false; return (this.is().sat() || this.is().sun()); } return false; }; /** * Sets the Time of the current Date instance. A string "6:15 pm" or config object {hour:18, minute:15} are accepted. * Example

	// Set time to 6:15pm with a String
	Date.today().at("6:15pm");

	// Set time to 6:15pm with a config object
	Date.today().at({hour:18, minute:15});
	
* * @return {Date} date */ $P.at = function (time) { return (typeof time === "string") ? $D.parse(this.toString("d") + " " + time) : this.set(time); }; /** * Creates a new Date() and adds this (Number) to the date based on the preceding date element function (eg. second|minute|hour|day|month|year). * Example

	// Undeclared Numbers must be wrapped with parentheses. Requirment of JavaScript.
	(3).days().fromNow();
	(6).months().fromNow();

	// Declared Number variables do not require parentheses. 
	var n = 6;
	n.months().fromNow();
	
* * @return {Date} A new Date instance */ $N.fromNow = $N.after = function (date) { var c = {}; c[this._dateElement] = this; return ((!date) ? new Date() : date.clone()).add(c); }; /** * Creates a new Date() and subtract this (Number) from the date based on the preceding date element function (eg. second|minute|hour|day|month|year). * Example

	// Undeclared Numbers must be wrapped with parentheses. Requirment of JavaScript.
	(3).days().ago();
	(6).months().ago();

	// Declared Number variables do not require parentheses. 
	var n = 6;
	n.months().ago();
	
* * @return {Date} A new Date instance */ $N.ago = $N.before = function (date) { var c = {}, s = (this._dateElement[this._dateElement.length-1] !== "s") ? this._dateElement + "s" : this._dateElement; c[s] = this * -1; return ((!date) ? new Date() : date.clone()).add(c); }; // Do NOT modify the following string tokens. These tokens are used to build dynamic functions. // All culture-specific strings can be found in the CultureInfo files. var dx = ("sunday monday tuesday wednesday thursday friday saturday").split(/\s/), mx = ("january february march april may june july august september october november december").split(/\s/), px = ("Millisecond Second Minute Hour Day Week Month Year Quarter Weekday").split(/\s/), pxf = ("Milliseconds Seconds Minutes Hours Date Week Month FullYear Quarter").split(/\s/), nth = ("final first second third fourth fifth").split(/\s/), de; /** * Returns an object literal of all the date parts. * Example

	var o = new Date().toObject();
	
	// { year: 2008, month: 4, week: 20, day: 13, hour: 18, minute: 9, second: 32, millisecond: 812 }
	
	// The object properties can be referenced directly from the object.
	
	alert(o.day);  // alerts "13"
	alert(o.year); // alerts "2008"
	
* * @return {Date} An object literal representing the original date object. */ $P.toObject = function () { var o = {}; for (var i = 0; i < px.length; i++) { if (this["get" + pxf[i]]) { o[px[i].toLowerCase()] = this["get" + pxf[i]](); } } return o; }; /** * Returns a date created from an object literal. Ignores the .week property if set in the config. * Example

	var o = new Date().toObject();
	
	return Date.fromObject(o); // will return the same date. 

	var o2 = {month: 1, day: 20, hour: 18}; // birthday party!
	Date.fromObject(o2);
	
* * @return {Date} An object literal representing the original date object. */ $D.fromObject = function(config) { config.week = null; return Date.today().set(config); }; // Create day name functions and abbreviated day name functions (eg. monday(), friday(), fri()). var df = function (n) { return function () { if (this._is) { this._is = false; return this.getDay() === n; } if (this._move) { this._move = null; } if (this._nth !== null) { // If the .second() function was called earlier, remove the _orient // from the date, and then continue. // This is required because 'second' can be used in two different context. // // Example // // Date.today().add(1).second(); // Date.march().second().monday(); // // Things get crazy with the following... // Date.march().add(1).second().second().monday(); // but it works!! // if (this._isSecond) { this.addSeconds(this._orient * -1); } // make sure we reset _isSecond this._isSecond = false; var ntemp = this._nth; this._nth = null; var temp = this.clone().moveToLastDayOfMonth(); this.moveToNthOccurrence(n, ntemp); if (this > temp) { throw new RangeError($D.getDayName(n) + " does not occur " + ntemp + " times in the month of " + $D.getMonthName(temp.getMonth()) + " " + temp.getFullYear() + "."); } return this; } return this.moveToDayOfWeek(n, this._orient); }; }; var sdf = function (n) { return function () { var t = $D.today(), shift = n - t.getDay(); if (n === 0 && Date.CultureInfo.firstDayOfWeek === 1 && t.getDay() !== 0) { shift = shift + 7; } return t.addDays(shift); }; }; // Create month name functions and abbreviated month name functions (eg. january(), march(), mar()). var month_instance_functions = function (n) { return function () { if (this._is) { this._is = false; return this.getMonth() === n; } return this.moveToMonth(n, this._orient); }; }; var month_static_functions = function (n) { return function () { return $D.today().set({ month: n, day: 1 }); }; }; var processTerms = function (names, staticFunc, instanceFunc) { for (var i = 0; i < names.length; i++) { // Create constant static Name variables. $D[names[i].toUpperCase()] = $D[names[i].toUpperCase().substring(0, 3)] = i; // Create Name functions. $D[names[i]] = $D[names[i].substring(0, 3)] = staticFunc(i); // Create Name instance functions. $P[names[i]] = $P[names[i].substring(0, 3)] = instanceFunc(i); } }; processTerms(dx, sdf, df); processTerms(mx, month_static_functions, month_instance_functions); // Create date element functions and plural date element functions used with Date (eg. day(), days(), months()). var ef = function (j) { return function () { // if the .second() function was called earlier, the _orient // has alread been added. Just return this and reset _isSecond. if (this._isSecond) { this._isSecond = false; return this; } if (this._same) { this._same = this._is = false; var o1 = this.toObject(), o2 = (arguments[0] || new Date()).toObject(), v = "", k = j.toLowerCase(); // the substr trick with -1 doesn't work in IE8 or less k = (k[k.length-1] === "s") ? k.substring(0,k.length-1) : k; for (var m = (px.length - 1); m > -1; m--) { v = px[m].toLowerCase(); if (o1[v] !== o2[v]) { return false; } if (k === v) { break; } } return true; } if (j.substring(j.length - 1) !== "s") { j += "s"; } if (this._move) { this._move = null; } return this["add" + j](this._orient); }; }; var nf = function (n) { return function () { this._dateElement = n; return this; }; }; for (var k = 0; k < px.length; k++) { de = px[k].toLowerCase(); if(de !== "weekday") { // Create date element functions and plural date element functions used with Date (eg. day(), days(), months()). $P[de] = $P[de + "s"] = ef(px[k]); // Create date element functions and plural date element functions used with Number (eg. day(), days(), months()). $N[de] = $N[de + "s"] = nf(de + "s"); } } $P._ss = ef("Second"); var nthfn = function (n) { return function (dayOfWeek) { if (this._same) { return this._ss(arguments[0]); } if (dayOfWeek || dayOfWeek === 0) { return this.moveToNthOccurrence(dayOfWeek, n); } this._nth = n; // if the operator is 'second' add the _orient, then deal with it later... if (n === 2 && (dayOfWeek === undefined || dayOfWeek === null)) { this._isSecond = true; return this.addSeconds(this._orient); } return this; }; }; for (var l = 0; l < nth.length; l++) { $P[nth[l]] = (l === 0) ? nthfn(-1) : nthfn(l); } }()); (function () { "use strict"; Date.Parsing = { Exception: function (s) { this.message = "Parse error at '" + s.substring(0, 10) + " ...'"; } }; var $P = Date.Parsing; var dayOffsets = { standard: [0,31,59,90,120,151,181,212,243,273,304,334], leap: [0,31,60,91,121,152,182,213,244,274,305,335] }; $P.isLeapYear = function(year) { return ((year % 4 === 0) && (year % 100 !== 0)) || (year % 400 === 0); }; var utils = { multiReplace : function (str, hash ) { var key; for (key in hash) { if (Object.prototype.hasOwnProperty.call(hash, key)) { var regex; if (typeof hash[key] === "function") { } else { regex = (hash[key] instanceof RegExp) ? hash[key] : new RegExp(hash[key], "g"); } str = str.replace(regex, key); } } return str; }, getDayOfYearFromWeek : function (obj) { var d, jan4, offset; obj.weekDay = (!obj.weekDay && obj.weekDay !== 0) ? 1 : obj.weekDay; d = new Date(obj.year, 0, 4); jan4 = d.getDay() === 0 ? 7 : d.getDay(); // JS is 0 indexed on Sunday. offset = jan4+3; obj.dayOfYear = ((obj.week * 7) + (obj.weekDay === 0 ? 7 : obj.weekDay))-offset; return obj; }, getDayOfYear : function (obj, dayOffset) { if (!obj.dayOfYear) { obj = utils.getDayOfYearFromWeek(obj); } for (var i=0;i <= dayOffset.length;i++) { if (obj.dayOfYear < dayOffset[i] || i === dayOffset.length) { obj.day = obj.day ? obj.day : (obj.dayOfYear - dayOffset[i-1]); break; } else { obj.month = i; } } return obj; }, adjustForTimeZone : function (obj, date) { var offset; if (obj.zone.toUpperCase() === "Z" || (obj.zone_hours === 0 && obj.zone_minutes === 0)) { // it's UTC/GML so work out the current timeszone offset offset = -date.getTimezoneOffset(); } else { offset = (obj.zone_hours*60) + (obj.zone_minutes || 0); if (obj.zone_sign === "+") { offset *= -1; } offset -= date.getTimezoneOffset(); } date.setMinutes(date.getMinutes()+offset); return date; }, setDefaults : function (obj) { obj.year = obj.year || Date.today().getFullYear(); obj.hours = obj.hours || 0; obj.minutes = obj.minutes || 0; obj.seconds = obj.seconds || 0; obj.milliseconds = obj.milliseconds || 0; if (!(!obj.month && (obj.week || obj.dayOfYear))) { // if we have a month, or if we don't but don't have the day calculation data obj.month = obj.month || 0; obj.day = obj.day || 1; } return obj; }, dataNum: function (data, mod, explict, postProcess) { var dataNum = data*1; if (mod) { if (postProcess) { return data ? mod(data)*1 : data; } else { return data ? mod(dataNum) : data; } } else if (!explict){ return data ? dataNum : data; } else { return (data && typeof data !== "undefined") ? dataNum : data; } }, timeDataProcess: function (obj) { var timeObj = {}; for (var x in obj.data) { if (obj.data.hasOwnProperty(x)) { timeObj[x] = obj.ignore[x] ? obj.data[x] : utils.dataNum(obj.data[x], obj.mods[x], obj.explict[x], obj.postProcess[x]); } } if (obj.data.secmins) { obj.data.secmins = obj.data.secmins.replace(",", ".") * 60; if (!timeObj.minutes) { timeObj.minutes = obj.data.secmins; } else if (!timeObj.seconds) { timeObj.seconds = obj.data.secmins; } delete obj.secmins; } return timeObj; }, buildTimeObjectFromData: function (data) { var time = utils.timeDataProcess({ data: { year : data[1], month : data[5], day : data[7], week : data[8], dayOfYear : data[10], hours : data[15], zone_hours : data[23], zone_minutes : data[24], zone : data[21], zone_sign : data[22], weekDay : data[9], minutes: data[16], seconds: data[19], milliseconds: data[20], secmins: data[18] }, mods: { month: function(data) { return data-1; }, weekDay: function (data) { data = Math.abs(data); return (data === 7 ? 0 : data); }, minutes: function (data) { return data.replace(":",""); }, seconds: function (data) { return Math.floor( (data.replace(":","").replace(",","."))*1 ); }, milliseconds: function (data) { return (data.replace(",",".")*1000); } }, postProcess: { minutes: true, seconds: true, milliseconds: true }, explict: { zone_hours: true, zone_minutes: true }, ignore: { zone: true, zone_sign: true, secmins: true } }); return time; }, addToHash: function (hash, keys, data) { keys = keys; data = data; var len = keys.length; for (var i = 0; i < len; i++) { hash[keys[i]] = data[i]; } return hash; }, combineRegex: function (r1, r2) { return new RegExp("(("+r1.source+")\\s("+r2.source+"))"); }, getDateNthString: function(add, last, inc){ if (add) { return Date.today().addDays(inc).toString("d"); } else if (last) { return Date.today().last()[inc]().toString("d"); } }, buildRegexData: function (array) { var arr = []; var len = array.length; for (var i=0; i < len; i++) { if (Object.prototype.toString.call(array[i]) === '[object Array]') { // oldIE compat version of Array.isArray arr.push(this.combineRegex(array[i][0], array[i][1])); } else { arr.push(array[i]); } } return arr; } }; $P.processTimeObject = function (obj) { var date, dayOffset; utils.setDefaults(obj); dayOffset = ($P.isLeapYear(obj.year)) ? dayOffsets.leap : dayOffsets.standard; if (!obj.month && (obj.week || obj.dayOfYear)) { utils.getDayOfYear(obj, dayOffset); } else { obj.dayOfYear = dayOffset[obj.month] + obj.day; } date = new Date(obj.year, obj.month, obj.day, obj.hours, obj.minutes, obj.seconds, obj.milliseconds); if (obj.zone) { utils.adjustForTimeZone(obj, date); // adjust (and calculate) for timezone } return date; }; $P.ISO = { regex : /^([\+-]?\d{4}(?!\d{2}\b))((-?)((0[1-9]|1[0-2])(\3([12]\d|0[1-9]|3[01]))?|W([0-4]\d|5[0-3])(-?[1-7])?|(00[1-9]|0[1-9]\d|[12]\d{2}|3([0-5]\d|6[1-6])))([T\s]((([01]\d|2[0-4])((:?)[0-5]\d)?|24\:?00)([\.,]\d+(?!:))?)?(\17[0-5]\d([\.,]\d+)?)?\s?([zZ]|([\+-])([01]\d|2[0-3]):?([0-5]\d)?)?)?)?$/, parse : function (s) { var time, data = s.match(this.regex); if (!data || !data.length) { return null; } time = utils.buildTimeObjectFromData(data); if (!time.year || (!time.year && (!time.month && !time.day) && (!time.week && !time.dayOfYear)) ) { return null; } return $P.processTimeObject(time); } }; $P.Numeric = { isNumeric: function (e){return!isNaN(parseFloat(e))&&isFinite(e);}, regex: /\b([0-1]?[0-9])([0-3]?[0-9])([0-2]?[0-9]?[0-9][0-9])\b/i, parse: function (s) { var data, i, time = {}, order = Date.CultureInfo.dateElementOrder.split(""); if (!(this.isNumeric(s)) || // if it's non-numeric OR (s[0] === "+" && s[0] === "-")) { // It's an arithmatic string (eg +/-1000) return null; } if (s.length < 5 && s.indexOf(".") < 0 && s.indexOf("/") < 0) { // assume it's just a year. time.year = s; return $P.processTimeObject(time); } data = s.match(this.regex); if (!data || !data.length) { return null; } for (i=0; i < order.length; i++) { switch(order[i]) { case "d": time.day = data[i+1]; break; case "m": time.month = (data[i+1]-1); break; case "y": time.year = data[i+1]; break; } } return $P.processTimeObject(time); } }; $P.Normalizer = { regexData: function () { var $R = Date.CultureInfo.regexPatterns; return utils.buildRegexData([ $R.tomorrow, $R.yesterday, [$R.past, $R.mon], [$R.past, $R.tue], [$R.past, $R.wed], [$R.past, $R.thu], [$R.past, $R.fri], [$R.past, $R.sat], [$R.past, $R.sun] ]); }, basicReplaceHash : function() { var $R = Date.CultureInfo.regexPatterns; return { "January": $R.jan.source, "February": $R.feb, "March": $R.mar, "April": $R.apr, "May": $R.may, "June": $R.jun, "July": $R.jul, "August": $R.aug, "September": $R.sep, "October": $R.oct, "November": $R.nov, "December": $R.dec, "": /\bat\b/gi, " ": /\s{2,}/, "am": $R.inTheMorning, "9am": $R.thisMorning, "pm": $R.inTheEvening, "7pm":$R.thisEvening }; }, keys : function(){ return [ utils.getDateNthString(true, false, 1), // tomorrow utils.getDateNthString(true, false, -1), // yesterday utils.getDateNthString(false, true, "monday"), //last mon utils.getDateNthString(false, true, "tuesday"), //last tues utils.getDateNthString(false, true, "wednesday"), //last wed utils.getDateNthString(false, true, "thursday"), //last thurs utils.getDateNthString(false, true, "friday"), //last fri utils.getDateNthString(false, true, "saturday"), //last sat utils.getDateNthString(false, true, "sunday") //last sun ]; }, buildRegexFunctions: function () { var $R = Date.CultureInfo.regexPatterns; var __ = Date.i18n.__; var tomorrowRE = new RegExp("(\\b\\d\\d?("+__("AM")+"|"+__("PM")+")? )("+$R.tomorrow.source.slice(1)+")", "i"); // adapted tomorrow regex for AM PM relative dates var todayRE = new RegExp($R.today.source + "(?!\\s*([+-]))\\b"); // today, but excludes the math operators (eg "today + 2h") this.replaceFuncs = [ [todayRE, function (full) { return (full.length > 1) ? Date.today().toString("d") : full; }], [tomorrowRE, function(full, m1) { var t = Date.today().addDays(1).toString("d"); return (t + " " + m1); }], [$R.amThisMorning, function(str, am){return am;}], [$R.pmThisEvening, function(str, pm){return pm;}] ]; }, buildReplaceData: function () { this.buildRegexFunctions(); this.replaceHash = utils.addToHash(this.basicReplaceHash(), this.keys(), this.regexData()); }, stringReplaceFuncs: function (s) { for (var i=0; i < this.replaceFuncs.length; i++) { s = s.replace(this.replaceFuncs[i][0], this.replaceFuncs[i][1]); } return s; }, parse: function (s) { s = this.stringReplaceFuncs(s); s = utils.multiReplace(s, this.replaceHash); try { var n = s.split(/([\s\-\.\,\/\x27]+)/); if (n.length === 3 && $P.Numeric.isNumeric(n[0]) && $P.Numeric.isNumeric(n[2]) && (n[2].length >= 4)) { // ok, so we're dealing with x/year. But that's not a full date. // This fixes wonky dateElementOrder parsing when set to dmy order. if (Date.CultureInfo.dateElementOrder[0] === "d") { s = "1/" + n[0] + "/" + n[2]; // set to 1st of month and normalize the seperator } } } catch (e) {} return s; } }; $P.Normalizer.buildReplaceData(); }()); (function () { var $P = Date.Parsing; var _ = $P.Operators = { // // Tokenizers // rtoken: function (r) { // regex token return function (s) { var mx = s.match(r); if (mx) { return ([ mx[0], s.substring(mx[0].length) ]); } else { throw new $P.Exception(s); } }; }, token: function () { // whitespace-eating token return function (s) { return _.rtoken(new RegExp("^\\s*" + s + "\\s*"))(s); }; }, stoken: function (s) { // string token return _.rtoken(new RegExp("^" + s)); }, // Atomic Operators until: function (p) { return function (s) { var qx = [], rx = null; while (s.length) { try { rx = p.call(this, s); } catch (e) { qx.push(rx[0]); s = rx[1]; continue; } break; } return [ qx, s ]; }; }, many: function (p) { return function (s) { var rx = [], r = null; while (s.length) { try { r = p.call(this, s); } catch (e) { return [ rx, s ]; } rx.push(r[0]); s = r[1]; } return [ rx, s ]; }; }, // generator operators -- see below optional: function (p) { return function (s) { var r = null; try { r = p.call(this, s); } catch (e) { return [ null, s ]; } return [ r[0], r[1] ]; }; }, not: function (p) { return function (s) { try { p.call(this, s); } catch (e) { return [null, s]; } throw new $P.Exception(s); }; }, ignore: function (p) { return p ? function (s) { var r = null; r = p.call(this, s); return [null, r[1]]; } : null; }, product: function () { var px = arguments[0], qx = Array.prototype.slice.call(arguments, 1), rx = []; for (var i = 0 ; i < px.length ; i++) { rx.push(_.each(px[i], qx)); } return rx; }, cache: function (rule) { var cache = {}, cache_length = 0, cache_keys = [], CACHE_MAX = Date.Config.CACHE_MAX || 100000, r = null; var cacheCheck = function () { if (cache_length === CACHE_MAX) { // kill several keys, don't want to have to do this all the time... for (var i=0; i < 10; i++) { var key = cache_keys.shift(); if (key) { delete cache[key]; cache_length--; } } } }; return function (s) { cacheCheck(); try { r = cache[s] = (cache[s] || rule.call(this, s)); } catch (e) { r = cache[s] = e; } cache_length++; cache_keys.push(s); if (r instanceof $P.Exception) { throw r; } else { return r; } }; }, // vector operators -- see below any: function () { var px = arguments; return function (s) { var r = null; for (var i = 0; i < px.length; i++) { if (px[i] == null) { continue; } try { r = (px[i].call(this, s)); } catch (e) { r = null; } if (r) { return r; } } throw new $P.Exception(s); }; }, each: function () { var px = arguments; return function (s) { var rx = [], r = null; for (var i = 0; i < px.length ; i++) { if (px[i] == null) { continue; } try { r = (px[i].call(this, s)); } catch (e) { throw new $P.Exception(s); } rx.push(r[0]); s = r[1]; } return [ rx, s]; }; }, all: function () { var px = arguments, _ = _; return _.each(_.optional(px)); }, // delimited operators sequence: function (px, d, c) { d = d || _.rtoken(/^\s*/); c = c || null; if (px.length === 1) { return px[0]; } return function (s) { var r = null, q = null; var rx = []; for (var i = 0; i < px.length ; i++) { try { r = px[i].call(this, s); } catch (e) { break; } rx.push(r[0]); try { q = d.call(this, r[1]); } catch (ex) { q = null; break; } s = q[1]; } if (!r) { throw new $P.Exception(s); } if (q) { throw new $P.Exception(q[1]); } if (c) { try { r = c.call(this, r[1]); } catch (ey) { throw new $P.Exception(r[1]); } } return [ rx, (r?r[1]:s) ]; }; }, // // Composite Operators // between: function (d1, p, d2) { d2 = d2 || d1; var _fn = _.each(_.ignore(d1), p, _.ignore(d2)); return function (s) { var rx = _fn.call(this, s); return [[rx[0][0], r[0][2]], rx[1]]; }; }, list: function (p, d, c) { d = d || _.rtoken(/^\s*/); c = c || null; return (p instanceof Array ? _.each(_.product(p.slice(0, -1), _.ignore(d)), p.slice(-1), _.ignore(c)) : _.each(_.many(_.each(p, _.ignore(d))), px, _.ignore(c))); }, set: function (px, d, c) { d = d || _.rtoken(/^\s*/); c = c || null; return function (s) { // r is the current match, best the current 'best' match // which means it parsed the most amount of input var r = null, p = null, q = null, rx = null, best = [[], s], last = false; // go through the rules in the given set for (var i = 0; i < px.length ; i++) { // last is a flag indicating whether this must be the last element // if there is only 1 element, then it MUST be the last one q = null; p = null; r = null; last = (px.length === 1); // first, we try simply to match the current pattern // if not, try the next pattern try { r = px[i].call(this, s); } catch (e) { continue; } // since we are matching against a set of elements, the first // thing to do is to add r[0] to matched elements rx = [[r[0]], r[1]]; // if we matched and there is still input to parse and // we don't already know this is the last element, // we're going to next check for the delimiter ... // if there's none, or if there's no input left to parse // than this must be the last element after all ... if (r[1].length > 0 && ! last) { try { q = d.call(this, r[1]); } catch (ex) { last = true; } } else { last = true; } // if we parsed the delimiter and now there's no more input, // that means we shouldn't have parsed the delimiter at all // so don't update r and mark this as the last element ... if (!last && q[1].length === 0) { last = true; } // so, if this isn't the last element, we're going to see if // we can get any more matches from the remaining (unmatched) // elements ... if (!last) { // build a list of the remaining rules we can match against, // i.e., all but the one we just matched against var qx = []; for (var j = 0; j < px.length ; j++) { if (i !== j) { qx.push(px[j]); } } // now invoke recursively set with the remaining input // note that we don't include the closing delimiter ... // we'll check for that ourselves at the end p = _.set(qx, d).call(this, q[1]); // if we got a non-empty set as a result ... // (otw rx already contains everything we want to match) if (p[0].length > 0) { // update current result, which is stored in rx ... // basically, pick up the remaining text from p[1] // and concat the result from p[0] so that we don't // get endless nesting ... rx[0] = rx[0].concat(p[0]); rx[1] = p[1]; } } // at this point, rx either contains the last matched element // or the entire matched set that starts with this element. // now we just check to see if this variation is better than // our best so far, in terms of how much of the input is parsed if (rx[1].length < best[1].length) { best = rx; } // if we've parsed all the input, then we're finished if (best[1].length === 0) { break; } } // so now we've either gone through all the patterns trying them // as the initial match; or we found one that parsed the entire // input string ... // if best has no matches, just return empty set ... if (best[0].length === 0) { return best; } // if a closing delimiter is provided, then we have to check it also if (c) { // we try this even if there is no remaining input because the pattern // may well be optional or match empty input ... try { q = c.call(this, best[1]); } catch (ey) { throw new $P.Exception(best[1]); } // it parsed ... be sure to update the best match remaining input best[1] = q[1]; } // if we're here, either there was no closing delimiter or we parsed it // so now we have the best match; just return it! return best; }; }, forward: function (gr, fname) { return function (s) { return gr[fname].call(this, s); }; }, // // Translation Operators // replace: function (rule, repl) { return function (s) { var r = rule.call(this, s); return [repl, r[1]]; }; }, process: function (rule, fn) { return function (s) { var r = rule.call(this, s); return [fn.call(this, r[0]), r[1]]; }; }, min: function (min, rule) { return function (s) { var rx = rule.call(this, s); if (rx[0].length < min) { throw new $P.Exception(s); } return rx; }; } }; // Generator Operators And Vector Operators // Generators are operators that have a signature of F(R) => R, // taking a given rule and returning another rule, such as // ignore, which parses a given rule and throws away the result. // Vector operators are those that have a signature of F(R1,R2,...) => R, // take a list of rules and returning a new rule, such as each. // Generator operators are converted (via the following _generator // function) into functions that can also take a list or array of rules // and return an array of new rules as though the function had been // called on each rule in turn (which is what actually happens). // This allows generators to be used with vector operators more easily. // Example: // each(ignore(foo, bar)) instead of each(ignore(foo), ignore(bar)) // This also turns generators into vector operators, which allows // constructs like: // not(cache(foo, bar)) var _generator = function (op) { function gen() { var args = null, rx = [], px, i; if (arguments.length > 1) { args = Array.prototype.slice.call(arguments); } else if (arguments[0] instanceof Array) { args = arguments[0]; } if (args) { px = args.shift(); if (px.length > 0) { args.unshift(px[i]); rx.push(op.apply(null, args)); args.shift(); return rx; } } else { return op.apply(null, arguments); } } return gen; }; var gx = "optional not ignore cache".split(/\s/); for (var i = 0 ; i < gx.length ; i++) { _[gx[i]] = _generator(_[gx[i]]); } var _vector = function (op) { return function () { if (arguments[0] instanceof Array) { return op.apply(null, arguments[0]); } else { return op.apply(null, arguments); } }; }; var vx = "each any all".split(/\s/); for (var j = 0 ; j < vx.length ; j++) { _[vx[j]] = _vector(_[vx[j]]); } }()); (function () { var $D = Date; var flattenAndCompact = function (ax) { var rx = []; for (var i = 0; i < ax.length; i++) { if (ax[i] instanceof Array) { rx = rx.concat(flattenAndCompact(ax[i])); } else { if (ax[i]) { rx.push(ax[i]); } } } return rx; }; var parseMeridian = function () { if (this.meridian && (this.hour || this.hour === 0)) { if (this.meridian === "a" && this.hour > 11 && Date.Config.strict24hr){ throw "Invalid hour and meridian combination"; } else if (this.meridian === "p" && this.hour < 12 && Date.Config.strict24hr){ throw "Invalid hour and meridian combination"; } else if (this.meridian === "p" && this.hour < 12) { this.hour = this.hour + 12; } else if (this.meridian === "a" && this.hour === 12) { this.hour = 0; } } }; var setDefaults = function () { var now = new Date(); if ((this.hour || this.minute) && (!this.month && !this.year && !this.day)) { this.day = now.getDate(); } if (!this.year) { this.year = now.getFullYear(); } if (!this.month && this.month !== 0) { this.month = now.getMonth(); } if (!this.day) { this.day = 1; } if (!this.hour) { this.hour = 0; } if (!this.minute) { this.minute = 0; } if (!this.second) { this.second = 0; } if (!this.millisecond) { this.millisecond = 0; } }; var finishUtils = { getToday: function () { if (this.now || "hour minute second".indexOf(this.unit) !== -1) { return new Date(); } else { return $D.today(); } }, setDaysFromWeekday: function (today, orient){ var gap; orient = orient || 1; this.unit = "day"; gap = ($D.getDayNumberFromName(this.weekday) - today.getDay()); this.days = gap ? ((gap + (orient * 7)) % 7) : (orient * 7); return this; }, setMonthsFromMonth: function (today, orient) { var gap; orient = orient || 1; this.unit = "month"; gap = (this.month - today.getMonth()); this.months = gap ? ((gap + (orient * 12)) % 12) : (orient * 12); this.month = null; return this; }, setDMYFromWeekday: function () { var d = Date[this.weekday](); this.day = d.getDate(); if (!this.month) { this.month = d.getMonth(); } this.year = d.getFullYear(); return this; }, setUnitValue: function (orient) { if (!this.value && this.operator && this.operator !== null && this[this.unit + "s"] && this[this.unit + "s"] !== null) { this[this.unit + "s"] = this[this.unit + "s"] + ((this.operator === "add") ? 1 : -1) + (this.value||0) * orient; } else if (this[this.unit + "s"] == null || this.operator != null) { if (!this.value) { this.value = 1; } this[this.unit + "s"] = this.value * orient; } }, generateDateFromWeeks: function () { var weekday = (this.weekday !== undefined) ? this.weekday : "today"; var d = Date[weekday]().addWeeks(this.weeks); if (this.now) { d.setTimeToNow(); } return d; } }; $D.Translator = { hour: function (s) { return function () { this.hour = Number(s); }; }, minute: function (s) { return function () { this.minute = Number(s); }; }, second: function (s) { return function () { this.second = Number(s); }; }, /* for ss.s format */ secondAndMillisecond: function (s) { return function () { var mx = s.match(/^([0-5][0-9])\.([0-9]{1,3})/); this.second = Number(mx[1]); this.millisecond = Number(mx[2]); }; }, meridian: function (s) { return function () { this.meridian = s.slice(0, 1).toLowerCase(); }; }, timezone: function (s) { return function () { var n = s.replace(/[^\d\+\-]/g, ""); if (n.length) { this.timezoneOffset = Number(n); } else { this.timezone = s.toLowerCase(); } }; }, day: function (x) { var s = x[0]; return function () { this.day = Number(s.match(/\d+/)[0]); if (this.day < 1) { throw "invalid day"; } }; }, month: function (s) { return function () { this.month = (s.length === 3) ? "jan feb mar apr may jun jul aug sep oct nov dec".indexOf(s)/4 : Number(s) - 1; if (this.month < 0) { throw "invalid month"; } }; }, year: function (s) { return function () { var n = Number(s); this.year = ((s.length > 2) ? n : (n + (((n + 2000) < Date.CultureInfo.twoDigitYearMax) ? 2000 : 1900))); }; }, rday: function (s) { return function () { switch (s) { case "yesterday": this.days = -1; break; case "tomorrow": this.days = 1; break; case "today": this.days = 0; break; case "now": this.days = 0; this.now = true; break; } }; }, finishExact: function (x) { var d; x = (x instanceof Array) ? x : [x]; for (var i = 0 ; i < x.length ; i++) { if (x[i]) { x[i].call(this); } } setDefaults.call(this); parseMeridian.call(this); if (this.day > $D.getDaysInMonth(this.year, this.month)) { throw new RangeError(this.day + " is not a valid value for days."); } d = new Date(this.year, this.month, this.day, this.hour, this.minute, this.second, this.millisecond); if (this.year < 100) { d.setFullYear(this.year); // means years less that 100 are process correctly. JS will parse it otherwise as 1900-1999. } if (this.timezone) { d.set({ timezone: this.timezone }); } else if (this.timezoneOffset) { d.set({ timezoneOffset: this.timezoneOffset }); } return d; }, finish: function (x) { var today, expression, orient, temp; x = (x instanceof Array) ? flattenAndCompact(x) : [ x ]; if (x.length === 0) { return null; } for (var i = 0 ; i < x.length ; i++) { if (typeof x[i] === "function") { x[i].call(this); } } if (this.now && !this.unit && !this.operator) { return new Date(); } else { today = finishUtils.getToday.call(this); } expression = !!(this.days && this.days !== null || this.orient || this.operator); orient = ((this.orient === "past" || this.operator === "subtract") ? -1 : 1); if (this.month && this.unit === "week") { this.value = this.month + 1; delete this.month; delete this.day; } if ((this.month || this.month === 0) && "year day hour minute second".indexOf(this.unit) !== -1) { if (!this.value) { this.value = this.month + 1; } this.month = null; expression = true; } if (!expression && this.weekday && !this.day && !this.days) { finishUtils.setDMYFromWeekday.call(this); } if (expression && this.weekday && this.unit !== "month" && this.unit !== "week") { finishUtils.setDaysFromWeekday.call(this, today, orient); } if (this.weekday && this.unit !== "week" && !this.day && !this.days) { temp = Date[this.weekday](); this.day = temp.getDate(); if (temp.getMonth() !== today.getMonth()) { this.month = temp.getMonth(); } } if (this.month && this.unit === "day" && this.operator) { if (!this.value) { this.value = (this.month + 1); } this.month = null; } if (this.value != null && this.month != null && this.year != null) { this.day = this.value * 1; } if (this.month && !this.day && this.value) { today.set({ day: this.value * 1 }); if (!expression) { this.day = this.value * 1; } } if (!this.month && this.value && this.unit === "month" && !this.now) { this.month = this.value; expression = true; } if (expression && (this.month || this.month === 0) && this.unit !== "year") { finishUtils.setMonthsFromMonth.call(this, today, orient); } if (!this.unit) { this.unit = "day"; } finishUtils.setUnitValue.call(this, orient); parseMeridian.call(this); if ((this.month || this.month === 0) && !this.day) { this.day = 1; } if (!this.orient && !this.operator && this.unit === "week" && this.value && !this.day && !this.month) { return Date.today().setWeek(this.value); } if (this.unit === "week" && this.weeks && !this.day && !this.month) { return finishUtils.generateDateFromWeeks.call(this); } if (expression && this.timezone && this.day && this.days) { this.day = this.days; } if (expression){ today.add(this); } else { today.set(this); } if (this.timezone) { this.timezone = this.timezone.toUpperCase(); var offset = $D.getTimezoneOffset(this.timezone); var timezone; if (today.hasDaylightSavingTime()) { // lets check that we're being sane with timezone setting timezone = $D.getTimezoneAbbreviation(offset, today.isDaylightSavingTime()); if (timezone !== this.timezone) { // bugger, we're in a place where things like EST vs EDT matters. if (today.isDaylightSavingTime()) { today.addHours(-1); } else { today.addHours(1); } } } today.setTimezoneOffset(offset); } return today; } }; }()); (function () { var $D = Date; $D.Grammar = {}; var _ = $D.Parsing.Operators, g = $D.Grammar, t = $D.Translator, _fn; // Allow rolling up into general purpose rules _fn = function () { return _.each(_.any.apply(null, arguments), _.not(g.ctoken2("timeContext"))); }; g.datePartDelimiter = _.rtoken(/^([\s\-\.\,\/\x27]+)/); g.timePartDelimiter = _.stoken(":"); g.whiteSpace = _.rtoken(/^\s*/); g.generalDelimiter = _.rtoken(/^(([\s\,]|at|@|on)+)/); var _C = {}; g.ctoken = function (keys) { var fn = _C[keys]; if (! fn) { var c = Date.CultureInfo.regexPatterns; var kx = keys.split(/\s+/), px = []; for (var i = 0; i < kx.length ; i++) { px.push(_.replace(_.rtoken(c[kx[i]]), kx[i])); } fn = _C[keys] = _.any.apply(null, px); } return fn; }; g.ctoken2 = function (key) { return _.rtoken(Date.CultureInfo.regexPatterns[key]); }; var cacheProcessRtoken = function (key, token, type, eachToken) { if (eachToken) { g[key] = _.cache(_.process(_.each(_.rtoken(token),_.optional(g.ctoken2(eachToken))), type)); } else { g[key] = _.cache(_.process(_.rtoken(token), type)); } }; var cacheProcessCtoken = function (token, type) { return _.cache(_.process(g.ctoken2(token), type)); }; var _F = {}; //function cache var _get = function (f) { _F[f] = (_F[f] || g.format(f)[0]); return _F[f]; }; g.allformats = function (fx) { var rx = []; if (fx instanceof Array) { for (var i = 0; i < fx.length; i++) { rx.push(_get(fx[i])); } } else { rx.push(_get(fx)); } return rx; }; g.formats = function (fx) { if (fx instanceof Array) { var rx = []; for (var i = 0 ; i < fx.length ; i++) { rx.push(_get(fx[i])); } return _.any.apply(null, rx); } else { return _get(fx); } }; var grammarFormats = { timeFormats: function(){ var i, RTokenKeys = [ "h", "hh", "H", "HH", "m", "mm", "s", "ss", "ss.s", "z", "zz" ], RToken = [ /^(0[0-9]|1[0-2]|[1-9])/, /^(0[0-9]|1[0-2])/, /^([0-1][0-9]|2[0-3]|[0-9])/, /^([0-1][0-9]|2[0-3])/, /^([0-5][0-9]|[0-9])/, /^[0-5][0-9]/, /^([0-5][0-9]|[0-9])/, /^[0-5][0-9]/, /^[0-5][0-9]\.[0-9]{1,3}/, /^((\+|\-)\s*\d\d\d\d)|((\+|\-)\d\d\:?\d\d)/, /^((\+|\-)\s*\d\d\d\d)|((\+|\-)\d\d\:?\d\d)/ ], tokens = [ t.hour, t.hour, t.hour, t.hour, t.minute, t.minute, t.second, t.second, t.secondAndMillisecond, t.timezone, t.timezone ]; for (i=0; i < RTokenKeys.length; i++) { cacheProcessRtoken(RTokenKeys[i], RToken[i], tokens[i]); } g.hms = _.cache(_.sequence([g.H, g.m, g.s], g.timePartDelimiter)); g.t = cacheProcessCtoken("shortMeridian", t.meridian); g.tt = cacheProcessCtoken("longMeridian", t.meridian); g.zzz = cacheProcessCtoken("timezone", t.timezone); g.timeSuffix = _.each(_.ignore(g.whiteSpace), _.set([ g.tt, g.zzz ])); g.time = _.each(_.optional(_.ignore(_.stoken("T"))), g.hms, g.timeSuffix); }, dateFormats: function () { // pre-loaded rules for different date part order preferences var _setfn = function () { return _.set(arguments, g.datePartDelimiter); }; var i, RTokenKeys = [ "d", "dd", "M", "MM", "y", "yy", "yyy", "yyyy" ], RToken = [ /^([0-2]\d|3[0-1]|\d)/, /^([0-2]\d|3[0-1])/, /^(1[0-2]|0\d|\d)/, /^(1[0-2]|0\d)/, /^(\d+)/, /^(\d\d)/, /^(\d\d?\d?\d?)/, /^(\d\d\d\d)/ ], tokens = [ t.day, t.day, t.month, t.month, t.year, t.year, t.year, t.year ], eachToken = [ "ordinalSuffix", "ordinalSuffix" ]; for (i=0; i < RTokenKeys.length; i++) { cacheProcessRtoken(RTokenKeys[i], RToken[i], tokens[i], eachToken[i]); } g.MMM = g.MMMM = _.cache(_.process(g.ctoken("jan feb mar apr may jun jul aug sep oct nov dec"), t.month)); g.ddd = g.dddd = _.cache(_.process(g.ctoken("sun mon tue wed thu fri sat"), function (s) { return function () { this.weekday = s; }; } )); g.day = _fn(g.d, g.dd); g.month = _fn(g.M, g.MMM); g.year = _fn(g.yyyy, g.yy); g.mdy = _setfn(g.ddd, g.month, g.day, g.year); g.ymd = _setfn(g.ddd, g.year, g.month, g.day); g.dmy = _setfn(g.ddd, g.day, g.month, g.year); g.date = function (s) { return ((g[Date.CultureInfo.dateElementOrder] || g.mdy).call(this, s)); }; }, relative: function () { // relative date / time expressions g.orientation = _.process(g.ctoken("past future"), function (s) { return function () { this.orient = s; }; } ); g.operator = _.process(g.ctoken("add subtract"), function (s) { return function () { this.operator = s; }; } ); g.rday = _.process(g.ctoken("yesterday tomorrow today now"), t.rday); g.unit = _.process(g.ctoken("second minute hour day week month year"), function (s) { return function () { this.unit = s; }; } ); } }; g.buildGrammarFormats = function () { // these need to be rebuilt every time the language changes. _C = {}; grammarFormats.timeFormats(); grammarFormats.dateFormats(); grammarFormats.relative(); g.value = _.process(_.rtoken(/^([-+]?\d+)?(st|nd|rd|th)?/), function (s) { return function () { this.value = s.replace(/\D/g, ""); }; } ); g.expression = _.set([g.rday, g.operator, g.value, g.unit, g.orientation, g.ddd, g.MMM ]); g.format = _.process(_.many( _.any( // translate format specifiers into grammar rules _.process( _.rtoken(/^(dd?d?d?(?!e)|MM?M?M?|yy?y?y?|hh?|HH?|mm?|ss?|tt?|zz?z?)/), function (fmt) { if (g[fmt]) { return g[fmt]; } else { throw $D.Parsing.Exception(fmt); } } ), // translate separator tokens into token rules _.process(_.rtoken(/^[^dMyhHmstz]+/), // all legal separators function (s) { return _.ignore(_.stoken(s)); } ) ) ), // construct the parser ... function (rules) { return _.process(_.each.apply(null, rules), t.finishExact); } ); // starting rule for general purpose grammar g._start = _.process(_.set([ g.date, g.time, g.expression ], g.generalDelimiter, g.whiteSpace), t.finish); }; g.buildGrammarFormats(); // parsing date format specifiers - ex: "h:m:s tt" // this little guy will generate a custom parser based // on the format string, ex: g.format("h:m:s tt") // check for these formats first g._formats = g.formats([ "\"yyyy-MM-ddTHH:mm:ssZ\"", "yyyy-MM-ddTHH:mm:ss.sz", "yyyy-MM-ddTHH:mm:ssZ", "yyyy-MM-ddTHH:mm:ssz", "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-ddTHH:mmZ", "yyyy-MM-ddTHH:mmz", "yyyy-MM-ddTHH:mm", "ddd, MMM dd, yyyy H:mm:ss tt", "ddd MMM d yyyy HH:mm:ss zzz", "MMddyyyy", "ddMMyyyy", "Mddyyyy", "ddMyyyy", "Mdyyyy", "dMyyyy", "yyyy", "Mdyy", "dMyy", "d" ]); // real starting rule: tries selected formats first, // then general purpose rule g.start = function (s) { try { var r = g._formats.call({}, s); if (r[1].length === 0) { return r; } } catch (e) {} return g._start.call({}, s); }; }()); (function () { var $D = Date; /** * @desc Converts the specified string value into its JavaScript Date equivalent using CultureInfo specific format information. * * Example

	///////////
	// Dates //
	///////////

	// 15-Oct-2004
	var d1 = Date.parse("10/15/2004");

	// 15-Oct-2004
	var d1 = Date.parse("15-Oct-2004");

	// 15-Oct-2004
	var d1 = Date.parse("2004.10.15");

	//Fri Oct 15, 2004
	var d1 = Date.parse("Fri Oct 15, 2004");

	///////////
	// Times //
	///////////

	// Today at 10 PM.
	var d1 = Date.parse("10 PM");

	// Today at 10:30 PM.
	var d1 = Date.parse("10:30 P.M.");

	// Today at 6 AM.
	var d1 = Date.parse("06am");

	/////////////////////
	// Dates and Times //
	/////////////////////

	// 8-July-2004 @ 10:30 PM
	var d1 = Date.parse("July 8th, 2004, 10:30 PM");

	// 1-July-2004 @ 10:30 PM
	var d1 = Date.parse("2004-07-01T22:30:00");

	////////////////////
	// Relative Dates //
	////////////////////

	// Returns today's date. The string "today" is culture specific.
	var d1 = Date.parse("today");

	// Returns yesterday's date. The string "yesterday" is culture specific.
	var d1 = Date.parse("yesterday");

	// Returns the date of the next thursday.
	var d1 = Date.parse("Next thursday");

	// Returns the date of the most previous monday.
	var d1 = Date.parse("last monday");

	// Returns today's day + one year.
	var d1 = Date.parse("next year");

	///////////////
	// Date Math //
	///////////////

	// Today + 2 days
	var d1 = Date.parse("t+2");

	// Today + 2 days
	var d1 = Date.parse("today + 2 days");

	// Today + 3 months
	var d1 = Date.parse("t+3m");

	// Today - 1 year
	var d1 = Date.parse("today - 1 year");

	// Today - 1 year
	var d1 = Date.parse("t-1y"); 


	/////////////////////////////
	// Partial Dates and Times //
	/////////////////////////////

	// July 15th of this year.
	var d1 = Date.parse("July 15");

	// 15th day of current day and year.
	var d1 = Date.parse("15");

	// July 1st of current year at 10pm.
	var d1 = Date.parse("7/1 10pm");
	
* * @param {String} The string value to convert into a Date object [Required] * @return {Date} A Date object or null if the string cannot be converted into a Date. */ var parseUtils = { removeOrds: function (s) { ords = s.match(/\b(\d+)(?:st|nd|rd|th)\b/); // find ordinal matches s = ((ords && ords.length === 2) ? s.replace(ords[0], ords[1]) : s); return s; }, grammarParser: function (s) { var r = null; try { r = $D.Grammar.start.call({}, s.replace(/^\s*(\S*(\s+\S+)*)\s*$/, "$1")); } catch (e) { return null; } return ((r[1].length === 0) ? r[0] : null); }, nativeFallback: function(s) { var t; try { // ok we haven't parsed it, last ditch attempt with the built-in parser. t = Date._parse(s); return (t || t === 0) ? new Date(t) : null; } catch (e) { return null; } } }; function parse (s) { var d; if (!s) { return null; } if (s instanceof Date) { return s.clone(); } if (s.length >= 4 && s.charAt(0) !== "0" && s.charAt(0) !== "+"&& s.charAt(0) !== "-") { // ie: 2004 will pass, 0800 won't. // Start with specific formats d = $D.Parsing.ISO.parse(s) || $D.Parsing.Numeric.parse(s); } if (d instanceof Date && !isNaN(d.getTime())) { return d; } else { // find ordinal dates (1st, 3rd, 8th, etc and remove them as they cause parsing issues) s = $D.Parsing.Normalizer.parse(parseUtils.removeOrds(s)); d = parseUtils.grammarParser(s); if (d !== null) { return d; } else { return parseUtils.nativeFallback(s); } } } if (!$D._parse) { $D._parse = $D.parse; } $D.parse = parse; Date.getParseFunction = function (fx) { var fns = Date.Grammar.allformats(fx); return function (s) { var r = null; for (var i = 0; i < fns.length; i++) { try { r = fns[i].call({}, s); } catch (e) { continue; } if (r[1].length === 0) { return r[0]; } } return null; }; }; /** * Converts the specified string value into its JavaScript Date equivalent using the specified format {String} or formats {Array} and the CultureInfo specific format information. * The format of the string value must match one of the supplied formats exactly. * * Example

	// 15-Oct-2004
	var d1 = Date.parseExact("10/15/2004", "M/d/yyyy");

	// 15-Oct-2004
	var d1 = Date.parse("15-Oct-2004", "M-ddd-yyyy");

	// 15-Oct-2004
	var d1 = Date.parse("2004.10.15", "yyyy.MM.dd");

	// Multiple formats
	var d1 = Date.parseExact("10/15/2004", ["M/d/yyyy", "MMMM d, yyyy"]);
	
* * @param {String} The string value to convert into a Date object [Required]. * @param {Object} The expected format {String} or an array of expected formats {Array} of the date string [Required]. * @return {Date} A Date object or null if the string cannot be converted into a Date. */ $D.parseExact = function (s, fx) { return $D.getParseFunction(fx)(s); }; }()); (function () { var $D = Date, $P = $D.prototype, // $C = $D.CultureInfo, // not used atm p = function (s, l) { if (!l) { l = 2; } return ("000" + s).slice(l * -1); }; /** * Converts a PHP format string to Java/.NET format string. * A PHP format string can be used with ._format or .format. * A Java/.NET format string can be used with .toString(). * The .parseExact function will only accept a Java/.NET format string * * Example * var f1 = "%m/%d/%y" * var f2 = Date.normalizeFormat(f1); // "MM/dd/yy" * * new Date().format(f1); // "04/13/08" * new Date()._format(f1); // "04/13/08" * new Date().toString(f2); // "04/13/08" * * var date = Date.parseExact("04/13/08", f2); // Sun Apr 13 2008 * * @param {String} A PHP format string consisting of one or more format spcifiers. * @return {String} The PHP format converted to a Java/.NET format string. */ var normalizerSubstitutions = { "d" : "dd", "%d": "dd", "D" : "ddd", "%a": "ddd", "j" : "dddd", "l" : "dddd", "%A": "dddd", "S" : "S", "F" : "MMMM", "%B": "MMMM", "m" : "MM", "%m": "MM", "M" : "MMM", "%b": "MMM", "%h": "MMM", "n" : "M", "Y" : "yyyy", "%Y": "yyyy", "y" : "yy", "%y": "yy", "g" : "h", "%I": "h", "G" : "H", "h" : "hh", "H" : "HH", "%H": "HH", "i" : "mm", "%M": "mm", "s" : "ss", "%S": "ss", "%r": "hh:mm tt", "%R": "H:mm", "%T": "H:mm:ss", "%X": "t", "%x": "d", "%e": "d", "%D": "MM/dd/yy", "%n": "\\n", "%t": "\\t", "e" : "z", "T" : "z", "%z": "z", "%Z": "z", "Z" : "ZZ", "N" : "u", "w" : "u", "%w": "u", "W" : "W", "%V": "W" }; var normalizer = { substitutes: function (m) { return normalizerSubstitutions[m]; }, interpreted: function (m, x) { var y; switch (m) { case "%u": return x.getDay() + 1; case "z": return x.getOrdinalNumber(); case "%j": return p(x.getOrdinalNumber(), 3); case "%U": var d1 = x.clone().set({month: 0, day: 1}).addDays(-1).moveToDayOfWeek(0), d2 = x.clone().addDays(1).moveToDayOfWeek(0, -1); return (d2 < d1) ? "00" : p((d2.getOrdinalNumber() - d1.getOrdinalNumber()) / 7 + 1); case "%W": return p(x.getWeek()); case "t": return $D.getDaysInMonth(x.getFullYear(), x.getMonth()); case "o": case "%G": return x.setWeek(x.getISOWeek()).toString("yyyy"); case "%g": return x._format("%G").slice(-2); case "a": case "%p": return t("tt").toLowerCase(); case "A": return t("tt").toUpperCase(); case "u": return p(x.getMilliseconds(), 3); case "I": return (x.isDaylightSavingTime()) ? 1 : 0; case "O": return x.getUTCOffset(); case "P": y = x.getUTCOffset(); return y.substring(0, y.length - 2) + ":" + y.substring(y.length - 2); case "B": var now = new Date(); return Math.floor(((now.getHours() * 3600) + (now.getMinutes() * 60) + now.getSeconds() + (now.getTimezoneOffset() + 60) * 60) / 86.4); case "c": return x.toISOString().replace(/\"/g, ""); case "U": return $D.strtotime("now"); case "%c": return t("d") + " " + t("t"); case "%C": return Math.floor(x.getFullYear() / 100 + 1); } }, shouldOverrideDefaults: function (m) { switch (m) { case "%e": return true; default: return false; } }, parse: function (m, context) { var formatString, c = context || new Date(); formatString = normalizer.substitutes(m); if (formatString) { return formatString; } formatString = normalizer.interpreted(m, c); if (formatString) { return formatString; } else { return m; } } }; $D.normalizeFormat = function (format, context) { return format.replace(/(%|\\)?.|%%/g, function(t){ return normalizer.parse(t, context); }); }; /** * Format a local Unix timestamp according to locale settings * * Example: * Date.strftime("%m/%d/%y", new Date()); // "04/13/08" * Date.strftime("c", "2008-04-13T17:52:03Z"); // "04/13/08" * * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @param {Number|String} The number representing the number of seconds that have elapsed since January 1, 1970 (local time). * @return {String} A string representation of the current Date object. */ $D.strftime = function (format, time) { var d = Date.parse(time); return d._format(format); }; /** * Parse any textual datetime description into a Unix timestamp. * A Unix timestamp is the number of seconds that have elapsed since January 1, 1970 (midnight UTC/GMT). * * Example: * Date.strtotime("04/13/08"); // 1208044800 * Date.strtotime("1970-01-01T00:00:00Z"); // 0 * * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @param {Object} A string or date object. * @return {String} A string representation of the current Date object. */ $D.strtotime = function (time) { var d = $D.parse(time); return Math.round($D.UTC(d.getUTCFullYear(), d.getUTCMonth(), d.getUTCDate(), d.getUTCHours(), d.getUTCMinutes(), d.getUTCSeconds(), d.getUTCMilliseconds()) / 1000); }; /** * Converts the value of the current Date object to its equivalent string representation using a PHP/Unix style of date format specifiers. * Format Specifiers * Format Description Example * ------ --------------------------------------------------------------------------- ----------------------- * %a abbreviated weekday name according to the current localed "Mon" through "Sun" * %A full weekday name according to the current localed "Sunday" through "Saturday" * %b abbreviated month name according to the current localed "Jan" through "Dec" * %B full month name according to the current locale "January" through "December" * %c preferred date and time representation for the current locale "4/13/2008 12:33 PM" * %C century number (the year divided by 100 and truncated to an integer) "00" to "99" * %d day of the month as a decimal number "01" to "31" * %D same as %m/%d/%y "04/13/08" * %e day of the month as a decimal number, a single digit is preceded by a space "1" to "31" * %g like %G, but without the century "08" * %G The 4-digit year corresponding to the ISO week number (see %V). "2008" * This has the same format and value as %Y, except that if the ISO week number * belongs to the previous or next year, that year is used instead. * %h same as %b "Jan" through "Dec" * %H hour as a decimal number using a 24-hour clock. "00" to "23" * %I hour as a decimal number using a 12-hour clock. "01" to "12" * %j day of the year as a decimal number. "001" to "366" * %m month as a decimal number. "01" to "12" * %M minute as a decimal number. "00" to "59" * %n newline character "\n" * %p either "am" or "pm" according to the given time value, or the "am" or "pm" * corresponding strings for the current locale. * %r time in a.m. and p.m. notation "8:44 PM" * %R time in 24 hour notation "20:44" * %S second as a decimal number "00" to "59" * %t tab character "\t" * %T current time, equal to %H:%M:%S "12:49:11" * %u weekday as a decimal number ["1", "7"], with "1" representing Monday "1" to "7" * %U week number of the current year as a decimal number, starting with the "0" to ("52" or "53") * first Sunday as the first day of the first week * %V The ISO 8601:1988 week number of the current year as a decimal number, "00" to ("52" or "53") * range 01 to 53, where week 1 is the first week that has at least 4 days * in the current year, and with Monday as the first day of the week. * (Use %G or %g for the year component that corresponds to the week number * for the specified timestamp.) * %W week number of the current year as a decimal number, starting with the "00" to ("52" or "53") * first Monday as the first day of the first week * %w day of the week as a decimal, Sunday being "0" "0" to "6" * %x preferred date representation for the current locale without the time "4/13/2008" * %X preferred time representation for the current locale without the date "12:53:05" * %y year as a decimal number without a century "00" "99" * %Y year as a decimal number including the century "2008" * %Z time zone or name or abbreviation "UTC", "EST", "PST" * %z same as %Z * %% a literal "%" characters "%" * d Day of the month, 2 digits with leading zeros "01" to "31" * D A textual representation of a day, three letters "Mon" through "Sun" * j Day of the month without leading zeros "1" to "31" * l A full textual representation of the day of the week (lowercase "L") "Sunday" through "Saturday" * N ISO-8601 numeric representation of the day of the week (added in PHP 5.1.0) "1" (for Monday) through "7" (for Sunday) * S English ordinal suffix for the day of the month, 2 characters "st", "nd", "rd" or "th". Works well with j * w Numeric representation of the day of the week "0" (for Sunday) through "6" (for Saturday) * z The day of the year (starting from "0") "0" through "365" * W ISO-8601 week number of year, weeks starting on Monday "00" to ("52" or "53") * F A full textual representation of a month, such as January or March "January" through "December" * m Numeric representation of a month, with leading zeros "01" through "12" * M A short textual representation of a month, three letters "Jan" through "Dec" * n Numeric representation of a month, without leading zeros "1" through "12" * t Number of days in the given month "28" through "31" * L Whether it's a leap year "1" if it is a leap year, "0" otherwise * o ISO-8601 year number. This has the same value as Y, except that if the "2008" * ISO week number (W) belongs to the previous or next year, that year * is used instead. * Y A full numeric representation of a year, 4 digits "2008" * y A two digit representation of a year "08" * a Lowercase Ante meridiem and Post meridiem "am" or "pm" * A Uppercase Ante meridiem and Post meridiem "AM" or "PM" * B Swatch Internet time "000" through "999" * g 12-hour format of an hour without leading zeros "1" through "12" * G 24-hour format of an hour without leading zeros "0" through "23" * h 12-hour format of an hour with leading zeros "01" through "12" * H 24-hour format of an hour with leading zeros "00" through "23" * i Minutes with leading zeros "00" to "59" * s Seconds, with leading zeros "00" through "59" * u Milliseconds "54321" * e Timezone identifier "UTC", "EST", "PST" * I Whether or not the date is in daylight saving time (uppercase i) "1" if Daylight Saving Time, "0" otherwise * O Difference to Greenwich time (GMT) in hours "+0200", "-0600" * P Difference to Greenwich time (GMT) with colon between hours and minutes "+02:00", "-06:00" * T Timezone abbreviation "UTC", "EST", "PST" * Z Timezone offset in seconds. The offset for timezones west of UTC is "-43200" through "50400" * always negative, and for those east of UTC is always positive. * c ISO 8601 date "2004-02-12T15:19:21+00:00" * r RFC 2822 formatted date "Thu, 21 Dec 2000 16:01:07 +0200" * U Seconds since the Unix Epoch (January 1 1970 00:00:00 GMT) "0" * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @return {String} A string representation of the current Date object. */ var formatReplace = function (context) { return function (m) { var formatString, override = false; if (m.charAt(0) === "\\" || m.substring(0, 2) === "%%") { return m.replace("\\", "").replace("%%", "%"); } override = normalizer.shouldOverrideDefaults(m); formatString = $D.normalizeFormat(m, context); if (formatString) { return context.toString(formatString, override); } }; }; $P._format = function (format) { var formatter = formatReplace(this); if (!format) { return this._toString(); } else { return format.replace(/(%|\\)?.|%%/g, formatter); } }; if (!$P.format) { $P.format = $P._format; } }()); (function () { "use strict"; var gFn = function (attr) { return function () { return this[attr]; }; }; var sFn = function (attr) { return function (val) { this[attr] = val; return this; }; }; var attrs = ["years", "months", "days", "hours", "minutes", "seconds", "milliseconds"]; var addSetFuncs = function (context, attrs) { for (var i = 0; i < attrs.length ; i++) { var $a = attrs[i], $b = $a.slice(0, 1).toUpperCase() + $a.slice(1); context.prototype[$a] = 0; context.prototype["get" + $b] = gFn($a); context.prototype["set" + $b] = sFn($a); } }; /** * new TimeSpan(milliseconds); * new TimeSpan(days, hours, minutes, seconds); * new TimeSpan(days, hours, minutes, seconds, milliseconds); */ var TimeSpan = function (days, hours, minutes, seconds, milliseconds) { if (arguments.length === 1 && typeof days === "number") { var orient = (days < 0) ? -1 : +1; var millsLeft = Math.abs(days); this.setDays(Math.floor(millsLeft / 86400000) * orient); millsLeft = millsLeft % 86400000; this.setHours(Math.floor(millsLeft / 3600000) * orient); millsLeft = millsLeft % 3600000; this.setMinutes(Math.floor(millsLeft / 60000) * orient); millsLeft = millsLeft % 60000; this.setSeconds(Math.floor(millsLeft / 1000) * orient); millsLeft = millsLeft % 1000; this.setMilliseconds(millsLeft * orient); } else { this.set(days, hours, minutes, seconds, milliseconds); } this.getTotalMilliseconds = function () { return (this.getDays() * 86400000) + (this.getHours() * 3600000) + (this.getMinutes() * 60000) + (this.getSeconds() * 1000); }; this.compareTo = function (time) { var t1 = new Date(1970, 1, 1, this.getHours(), this.getMinutes(), this.getSeconds()), t2; if (time === null) { t2 = new Date(1970, 1, 1, 0, 0, 0); } else { t2 = new Date(1970, 1, 1, time.getHours(), time.getMinutes(), time.getSeconds()); } return (t1 < t2) ? -1 : (t1 > t2) ? 1 : 0; }; this.equals = function (time) { return (this.compareTo(time) === 0); }; this.add = function (time) { return (time === null) ? this : this.addSeconds(time.getTotalMilliseconds() / 1000); }; this.subtract = function (time) { return (time === null) ? this : this.addSeconds(-time.getTotalMilliseconds() / 1000); }; this.addDays = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 86400000)); }; this.addHours = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 3600000)); }; this.addMinutes = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 60000)); }; this.addSeconds = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 1000)); }; this.addMilliseconds = function (n) { return new TimeSpan(this.getTotalMilliseconds() + n); }; this.get12HourHour = function () { return (this.getHours() > 12) ? this.getHours() - 12 : (this.getHours() === 0) ? 12 : this.getHours(); }; this.getDesignator = function () { return (this.getHours() < 12) ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator; }; this.toString = function (format) { this._toString = function () { if (this.getDays() !== null && this.getDays() > 0) { return this.getDays() + "." + this.getHours() + ":" + this.p(this.getMinutes()) + ":" + this.p(this.getSeconds()); } else { return this.getHours() + ":" + this.p(this.getMinutes()) + ":" + this.p(this.getSeconds()); } }; this.p = function (s) { return (s.toString().length < 2) ? "0" + s : s; }; var me = this; return format ? format.replace(/dd?|HH?|hh?|mm?|ss?|tt?/g, function (format) { switch (format) { case "d": return me.getDays(); case "dd": return me.p(me.getDays()); case "H": return me.getHours(); case "HH": return me.p(me.getHours()); case "h": return me.get12HourHour(); case "hh": return me.p(me.get12HourHour()); case "m": return me.getMinutes(); case "mm": return me.p(me.getMinutes()); case "s": return me.getSeconds(); case "ss": return me.p(me.getSeconds()); case "t": return ((me.getHours() < 12) ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator).substring(0, 1); case "tt": return (me.getHours() < 12) ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator; } } ) : this._toString(); }; return this; }; addSetFuncs(TimeSpan, attrs.slice(2)); TimeSpan.prototype.set = function (days, hours, minutes, seconds, milliseconds){ this.setDays(days || this.getDays()); this.setHours(hours || this.getHours()); this.setMinutes(minutes || this.getMinutes()); this.setSeconds(seconds || this.getSeconds()); this.setMilliseconds(milliseconds || this.getMilliseconds()); }; /** * Gets the time of day for this date instances. * @return {TimeSpan} TimeSpan */ Date.prototype.getTimeOfDay = function () { return new TimeSpan(0, this.getHours(), this.getMinutes(), this.getSeconds(), this.getMilliseconds()); }; Date.TimeSpan = TimeSpan; if (typeof window !== "undefined" ) { // keeping API compatible for v1.x window.TimeSpan = TimeSpan; } }()); (function () { "use strict"; var attrs = ["years", "months", "days", "hours", "minutes", "seconds", "milliseconds"]; var gFn = function (attr) { return function () { return this[attr]; }; }; var sFn = function (attr) { return function (val) { this[attr] = val; return this; }; }; var addSetFuncs = function (context, attrs) { for (var i = 0; i < attrs.length ; i++) { var $a = attrs[i], $b = $a.slice(0, 1).toUpperCase() + $a.slice(1); context.prototype[$a] = 0; context.prototype["get" + $b] = gFn($a); context.prototype["set" + $b] = sFn($a); } }; var setMonthsAndYears = function (orient, d1, d2, context) { function inc() { d1.addMonths(-orient); context.months++; if (context.months === 12) { context.years++; context.months = 0; } } if (orient === +1) { while (d1 > d2) { inc(); } } else { while (d1 < d2) { inc(); } } context.months--; context.months *= orient; context.years *= orient; }; var adjustForDST = function(orient, startDate, endDate) { var hasDSTMismatch = (false === (startDate.isDaylightSavingTime() === endDate.isDaylightSavingTime())); if (hasDSTMismatch && orient === 1) { startDate.addHours(-1); } else if (hasDSTMismatch) { startDate.addHours(1); } }; /** * TimePeriod(startDate, endDate); * TimePeriod(years, months, days, hours, minutes, seconds, milliseconds); */ var TimePeriod = function (years, months, days, hours, minutes, seconds, milliseconds) { if (arguments.length === 7) { this.set(years, months, days, hours, minutes, seconds, milliseconds); } else if (arguments.length === 2 && arguments[0] instanceof Date && arguments[1] instanceof Date) { var startDate = arguments[0].clone(); var endDate = arguments[1].clone(); var orient = (startDate > endDate) ? +1 : -1; this.dates = { start: arguments[0].clone(), end: arguments[1].clone() }; setMonthsAndYears(orient, startDate, endDate, this); adjustForDST(orient, startDate, endDate); // // TODO - adjust for DST var diff = endDate - startDate; if (diff !== 0) { var ts = new TimeSpan(diff); this.set(this.years, this.months, ts.getDays(), ts.getHours(), ts.getMinutes(), ts.getSeconds(), ts.getMilliseconds()); } } return this; }; // create all the set functions. addSetFuncs(TimePeriod, attrs); TimePeriod.prototype.set = function (years, months, days, hours, minutes, seconds, milliseconds){ this.setYears(years || this.getYears()); this.setMonths(months || this.getMonths()); this.setDays(days || this.getDays()); this.setHours(hours || this.getHours()); this.setMinutes(minutes || this.getMinutes()); this.setSeconds(seconds || this.getSeconds()); this.setMilliseconds(milliseconds || this.getMilliseconds()); }; Date.TimePeriod = TimePeriod; if (typeof window !== "undefined") { // keeping API compatible for v1.x window.TimePeriod = TimePeriod; } }()); ================================================ FILE: build/date-be-BY.js ================================================ /** * @overview datejs * @version 1.0.0-rc3 * @author Gregory Wild-Smith * @copyright 2015 Gregory Wild-Smith * @license MIT * @homepage https://github.com/abritinthebay/datejs */ /* * DateJS Culture String File * Country Code: be-BY * Name: Belarusian (Belarus) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["be-BY"] = { "name": "be-BY", "englishName": "Belarusian (Belarus)", "nativeName": "Беларускі (Беларусь)", "Sunday": "нядзеля", "Monday": "панядзелак", "Tuesday": "аўторак", "Wednesday": "серада", "Thursday": "чацвер", "Friday": "пятніца", "Saturday": "субота", "Sun": "нд", "Mon": "пн", "Tue": "аў", "Wed": "ср", "Thu": "чц", "Fri": "пт", "Sat": "сб", "Su": "нд", "Mo": "пн", "Tu": "аў", "We": "ср", "Th": "чц", "Fr": "пт", "Sa": "сб", "S_Sun_Initial": "н", "M_Mon_Initial": "п", "T_Tue_Initial": "а", "W_Wed_Initial": "с", "T_Thu_Initial": "ч", "F_Fri_Initial": "п", "S_Sat_Initial": "с", "January": "Студзень", "February": "Люты", "March": "Сакавік", "April": "Красавік", "May": "Май", "June": "Чэрвень", "July": "Ліпень", "August": "Жнівень", "September": "Верасень", "October": "Кастрычнік", "November": "Лістапад", "December": "Снежань", "Jan_Abbr": "Сту", "Feb_Abbr": "Лют", "Mar_Abbr": "Сак", "Apr_Abbr": "Кра", "May_Abbr": "Май", "Jun_Abbr": "Чэр", "Jul_Abbr": "Ліп", "Aug_Abbr": "Жні", "Sep_Abbr": "Вер", "Oct_Abbr": "Кас", "Nov_Abbr": "Ліс", "Dec_Abbr": "Сне", "AM": "", "PM": "", "firstDayOfWeek": 1, "twoDigitYearMax": 2029, "mdy": "dmy", "M/d/yyyy": "dd.MM.yyyy", "dddd, MMMM dd, yyyy": "d MMMM yyyy", "h:mm tt": "H:mm", "h:mm:ss tt": "H:mm:ss", "dddd, MMMM dd, yyyy h:mm:ss tt": "d MMMM yyyy H:mm:ss", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "d MMMM", "MMMM, yyyy": "MMMM yyyy", "/jan(uary)?/": "сту(дзень)?", "/feb(ruary)?/": "лют(ы)?", "/mar(ch)?/": "сак(авік)?", "/apr(il)?/": "кра(савік)?", "/may/": "май", "/jun(e)?/": "чэр(вень)?", "/jul(y)?/": "ліп(ень)?", "/aug(ust)?/": "жні(вень)?", "/sep(t(ember)?)?/": "вер(асень)?", "/oct(ober)?/": "кас(трычнік)?", "/nov(ember)?/": "ліс(тапад)?", "/dec(ember)?/": "сне(жань)?", "/^su(n(day)?)?/": "^нядзеля", "/^mo(n(day)?)?/": "^панядзелак", "/^tu(e(s(day)?)?)?/": "^аўторак", "/^we(d(nesday)?)?/": "^серада", "/^th(u(r(s(day)?)?)?)?/": "^чацвер", "/^fr(i(day)?)?/": "^пятніца", "/^sa(t(urday)?)?/": "^субота", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "be-BY"; /** * @overview datejs * @version 1.0.0-rc3 * @author Gregory Wild-Smith * @copyright 2015 Gregory Wild-Smith * @license MIT * @homepage https://github.com/abritinthebay/datejs */(function () { var $D = Date; var lang = Date.CultureStrings ? Date.CultureStrings.lang : null; var loggedKeys = {}; // for debug purposes. var getText = { getFromKey: function (key, countryCode) { var output; if (Date.CultureStrings && Date.CultureStrings[countryCode] && Date.CultureStrings[countryCode][key]) { output = Date.CultureStrings[countryCode][key]; } else { output = getText.buildFromDefault(key); } if (key.charAt(0) === "/") { // Assume it's a regex output = getText.buildFromRegex(key, countryCode); } return output; }, getFromObjectValues: function (obj, countryCode) { var key, output = {}; for(key in obj) { if (obj.hasOwnProperty(key)) { output[key] = getText.getFromKey(obj[key], countryCode); } } return output; }, getFromObjectKeys: function (obj, countryCode) { var key, output = {}; for(key in obj) { if (obj.hasOwnProperty(key)) { output[getText.getFromKey(key, countryCode)] = obj[key]; } } return output; }, getFromArray: function (arr, countryCode) { var output = []; for (var i=0; i < arr.length; i++){ if (i in arr) { output[i] = getText.getFromKey(arr[i], countryCode); } } return output; }, buildFromDefault: function (key) { var output, length, split, last; switch(key) { case "name": output = "en-US"; break; case "englishName": output = "English (United States)"; break; case "nativeName": output = "English (United States)"; break; case "twoDigitYearMax": output = 2049; break; case "firstDayOfWeek": output = 0; break; default: output = key; split = key.split("_"); length = split.length; if (length > 1 && key.charAt(0) !== "/") { // if the key isn't a regex and it has a split. last = split[(length - 1)].toLowerCase(); if (last === "initial" || last === "abbr") { output = split[0]; } } break; } return output; }, buildFromRegex: function (key, countryCode) { var output; if (Date.CultureStrings && Date.CultureStrings[countryCode] && Date.CultureStrings[countryCode][key]) { output = new RegExp(Date.CultureStrings[countryCode][key], "i"); } else { output = new RegExp(key.replace(new RegExp("/", "g"),""), "i"); } return output; } }; var shallowMerge = function (obj1, obj2) { for (var attrname in obj2) { if (obj2.hasOwnProperty(attrname)) { obj1[attrname] = obj2[attrname]; } } }; var __ = function (key, language) { var countryCode = (language) ? language : lang; loggedKeys[key] = key; if (typeof key === "object") { if (key instanceof Array) { return getText.getFromArray(key, countryCode); } else { return getText.getFromObjectKeys(key, countryCode); } } else { return getText.getFromKey(key, countryCode); } }; var loadI18nScript = function (code) { // paatterned after jQuery's getScript. var url = Date.Config.i18n + code + ".js"; var head = document.getElementsByTagName("head")[0] || document.documentElement; var script = document.createElement("script"); script.src = url; var completed = false; var events = { done: function (){} // placeholder function }; // Attach handlers for all browsers script.onload = script.onreadystatechange = function() { if ( !completed && (!this.readyState || this.readyState === "loaded" || this.readyState === "complete") ) { events.done(); head.removeChild(script); } }; setTimeout(function() { head.insertBefore(script, head.firstChild); }, 0); // allows return to execute first return { done: function (cb) { events.done = function() { if (cb) { setTimeout(cb,0); } }; } }; }; var buildInfo = { buildFromMethodHash: function (obj) { var key; for(key in obj) { if (obj.hasOwnProperty(key)) { obj[key] = buildInfo[obj[key]](); } } return obj; }, timeZoneDST: function () { var DST = { "CHADT": "+1345", "NZDT": "+1300", "AEDT": "+1100", "ACDT": "+1030", "AZST": "+0500", "IRDT": "+0430", "EEST": "+0300", "CEST": "+0200", "BST": "+0100", "PMDT": "-0200", "ADT": "-0300", "NDT": "-0230", "EDT": "-0400", "CDT": "-0500", "MDT": "-0600", "PDT": "-0700", "AKDT": "-0800", "HADT": "-0900" }; return __(DST); }, timeZoneStandard: function () { var standard = { "LINT": "+1400", "TOT": "+1300", "CHAST": "+1245", "NZST": "+1200", "NFT": "+1130", "SBT": "+1100", "AEST": "+1000", "ACST": "+0930", "JST": "+0900", "CWST": "+0845", "CT": "+0800", "ICT": "+0700", "MMT": "+0630", "BST": "+0600", "NPT": "+0545", "IST": "+0530", "PKT": "+0500", "AFT": "+0430", "MSK": "+0400", "IRST": "+0330", "FET": "+0300", "EET": "+0200", "CET": "+0100", "GMT": "+0000", "UTC": "+0000", "CVT": "-0100", "GST": "-0200", "BRT": "-0300", "NST": "-0330", "AST": "-0400", "EST": "-0500", "CST": "-0600", "MST": "-0700", "PST": "-0800", "AKST": "-0900", "MIT": "-0930", "HST": "-1000", "SST": "-1100", "BIT": "-1200" }; return __(standard); }, timeZones: function (data) { var zone; data.timezones = []; for (zone in data.abbreviatedTimeZoneStandard) { if (data.abbreviatedTimeZoneStandard.hasOwnProperty(zone)) { data.timezones.push({ name: zone, offset: data.abbreviatedTimeZoneStandard[zone]}); } } for (zone in data.abbreviatedTimeZoneDST) { if (data.abbreviatedTimeZoneDST.hasOwnProperty(zone)) { data.timezones.push({ name: zone, offset: data.abbreviatedTimeZoneDST[zone], dst: true}); } } return data.timezones; }, days: function () { return __(["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"]); }, dayAbbr: function () { return __(["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"]); }, dayShortNames: function () { return __(["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"]); }, dayFirstLetters: function () { return __(["S_Sun_Initial", "M_Mon_Initial", "T_Tues_Initial", "W_Wed_Initial", "T_Thu_Initial", "F_Fri_Initial", "S_Sat_Initial"]); }, months: function () { return __(["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"]); }, monthAbbr: function () { return __(["Jan_Abbr", "Feb_Abbr", "Mar_Abbr", "Apr_Abbr", "May_Abbr", "Jun_Abbr", "Jul_Abbr", "Aug_Abbr", "Sep_Abbr", "Oct_Abbr", "Nov_Abbr", "Dec_Abbr"]); }, formatPatterns: function () { return getText.getFromObjectValues({ shortDate: "M/d/yyyy", longDate: "dddd, MMMM dd, yyyy", shortTime: "h:mm tt", longTime: "h:mm:ss tt", fullDateTime: "dddd, MMMM dd, yyyy h:mm:ss tt", sortableDateTime: "yyyy-MM-ddTHH:mm:ss", universalSortableDateTime: "yyyy-MM-dd HH:mm:ssZ", rfc1123: "ddd, dd MMM yyyy HH:mm:ss", monthDay: "MMMM dd", yearMonth: "MMMM, yyyy" }, Date.i18n.currentLanguage()); }, regex: function () { return getText.getFromObjectValues({ inTheMorning: "/( in the )(morn(ing)?)\\b/", thisMorning: "/(this )(morn(ing)?)\\b/", amThisMorning: "/(\b\\d(am)? )(this )(morn(ing)?)/", inTheEvening: "/( in the )(even(ing)?)\\b/", thisEvening: "/(this )(even(ing)?)\\b/", pmThisEvening: "/(\b\\d(pm)? )(this )(even(ing)?)/", jan: "/jan(uary)?/", feb: "/feb(ruary)?/", mar: "/mar(ch)?/", apr: "/apr(il)?/", may: "/may/", jun: "/jun(e)?/", jul: "/jul(y)?/", aug: "/aug(ust)?/", sep: "/sep(t(ember)?)?/", oct: "/oct(ober)?/", nov: "/nov(ember)?/", dec: "/dec(ember)?/", sun: "/^su(n(day)?)?/", mon: "/^mo(n(day)?)?/", tue: "/^tu(e(s(day)?)?)?/", wed: "/^we(d(nesday)?)?/", thu: "/^th(u(r(s(day)?)?)?)?/", fri: "/fr(i(day)?)?/", sat: "/^sa(t(urday)?)?/", future: "/^next/", past: "/^last|past|prev(ious)?/", add: "/^(\\+|aft(er)?|from|hence)/", subtract: "/^(\\-|bef(ore)?|ago)/", yesterday: "/^yes(terday)?/", today: "/^t(od(ay)?)?/", tomorrow: "/^tom(orrow)?/", now: "/^n(ow)?/", millisecond: "/^ms|milli(second)?s?/", second: "/^sec(ond)?s?/", minute: "/^mn|min(ute)?s?/", hour: "/^h(our)?s?/", week: "/^w(eek)?s?/", month: "/^m(onth)?s?/", day: "/^d(ay)?s?/", year: "/^y(ear)?s?/", shortMeridian: "/^(a|p)/", longMeridian: "/^(a\\.?m?\\.?|p\\.?m?\\.?)/", timezone: "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/", ordinalSuffix: "/^\\s*(st|nd|rd|th)/", timeContext: "/^\\s*(\\:|a(?!u|p)|p)/" }, Date.i18n.currentLanguage()); } }; var CultureInfo = function () { var info = getText.getFromObjectValues({ name: "name", englishName: "englishName", nativeName: "nativeName", amDesignator: "AM", pmDesignator: "PM", firstDayOfWeek: "firstDayOfWeek", twoDigitYearMax: "twoDigitYearMax", dateElementOrder: "mdy" }, Date.i18n.currentLanguage()); var constructedInfo = buildInfo.buildFromMethodHash({ dayNames: "days", abbreviatedDayNames: "dayAbbr", shortestDayNames: "dayShortNames", firstLetterDayNames: "dayFirstLetters", monthNames: "months", abbreviatedMonthNames: "monthAbbr", formatPatterns: "formatPatterns", regexPatterns: "regex", abbreviatedTimeZoneDST: "timeZoneDST", abbreviatedTimeZoneStandard: "timeZoneStandard" }); shallowMerge(info, constructedInfo); buildInfo.timeZones(info); return info; }; $D.i18n = { __: function (key, lang) { return __(key, lang); }, currentLanguage: function () { return lang || "en-US"; }, setLanguage: function (code, force, cb) { var async = false; if (force || code === "en-US" || (!!Date.CultureStrings && !!Date.CultureStrings[code])) { lang = code; Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings.lang = code; Date.CultureInfo = new CultureInfo(); } else { if (!(!!Date.CultureStrings && !!Date.CultureStrings[code])) { if (typeof exports !== "undefined" && this.exports !== exports) { // we're in a Node enviroment, load it using require try { require("../i18n/" + code + ".js"); lang = code; Date.CultureStrings.lang = code; Date.CultureInfo = new CultureInfo(); } catch (e) { // var str = "The language for '" + code + "' could not be loaded by Node. It likely does not exist."; throw new Error("The DateJS IETF language tag '" + code + "' could not be loaded by Node. It likely does not exist."); } } else if (Date.Config && Date.Config.i18n) { // we know the location of the files, so lets load them async = true; loadI18nScript(code).done(function(){ lang = code; Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings.lang = code; Date.CultureInfo = new CultureInfo(); $D.Parsing.Normalizer.buildReplaceData(); // because this is async if ($D.Grammar) { $D.Grammar.buildGrammarFormats(); // so we can parse those strings... } if (cb) { setTimeout(cb,0); } }); } else { Date.console.error("The DateJS IETF language tag '" + code + "' is not available and has not been loaded."); return false; } } } $D.Parsing.Normalizer.buildReplaceData(); // rebuild normalizer strings if ($D.Grammar) { $D.Grammar.buildGrammarFormats(); // so we can parse those strings... } if (!async && cb) { setTimeout(cb,0); } }, getLoggedKeys: function () { return loggedKeys; }, updateCultureInfo: function () { Date.CultureInfo = new CultureInfo(); } }; $D.i18n.updateCultureInfo(); // run automatically }()); (function () { var $D = Date, $P = $D.prototype, p = function (s, l) { if (!l) { l = 2; } return ("000" + s).slice(l * -1); }; if (typeof window !== "undefined" && typeof window.console !== "undefined" && typeof window.console.log !== "undefined") { $D.console = console; // used only to raise non-critical errors if available } else { // set mock so we don't give errors. $D.console = { log: function(){}, error: function(){} }; } $D.Config = $D.Config || {}; $D.initOverloads = function() { /** * Overload of Date.now. Allows an alternate call for Date.now where it returns the * current Date as an object rather than just milliseconds since the Unix Epoch. * * Also provides an implementation of now() for browsers (IE<9) that don't have it. * * Backwards compatible so with work with either: * Date.now() [returns ms] * or * Date.now(true) [returns Date] */ if (!$D.now) { $D._now = function now() { return new Date().getTime(); }; } else if (!$D._now) { $D._now = $D.now; } $D.now = function (returnObj) { if (returnObj) { return $D.present(); } else { return $D._now(); } }; if ( !$P.toISOString ) { $P.toISOString = function() { return this.getUTCFullYear() + "-" + p(this.getUTCMonth() + 1) + "-" + p(this.getUTCDate()) + "T" + p(this.getUTCHours()) + ":" + p(this.getUTCMinutes()) + ":" + p(this.getUTCSeconds()) + "." + String( (this.getUTCMilliseconds()/1000).toFixed(3)).slice(2, 5) + "Z"; }; } // private if ( $P._toString === undefined ){ $P._toString = $P.toString; } }; $D.initOverloads(); /** * Gets a date that is set to the current date. The time is set to the start of the day (00:00 or 12:00 AM). * @return {Date} The current date. */ $D.today = function () { return new Date().clearTime(); }; /** * Gets a date that is set to the current date and time (same as new Date, but chainable) * @return {Date} The current date. */ $D.present = function () { return new Date(); }; /** * Compares the first date to the second date and returns an number indication of their relative values. * @param {Date} First Date object to compare [Required]. * @param {Date} Second Date object to compare to [Required]. * @return {Number} -1 = date1 is lessthan date2. 0 = values are equal. 1 = date1 is greaterthan date2. */ $D.compare = function (date1, date2) { if (isNaN(date1) || isNaN(date2)) { throw new Error(date1 + " - " + date2); } else if (date1 instanceof Date && date2 instanceof Date) { return (date1 < date2) ? -1 : (date1 > date2) ? 1 : 0; } else { throw new TypeError(date1 + " - " + date2); } }; /** * Compares the first Date object to the second Date object and returns true if they are equal. * @param {Date} First Date object to compare [Required] * @param {Date} Second Date object to compare to [Required] * @return {Boolean} true if dates are equal. false if they are not equal. */ $D.equals = function (date1, date2) { return (date1.compareTo(date2) === 0); }; /** * Gets the language appropriate day name when given the day number(0-6) * eg - 0 == Sunday * @return {String} The day name */ $D.getDayName = function (n) { return Date.CultureInfo.dayNames[n]; }; /** * Gets the day number (0-6) if given a CultureInfo specific string which is a valid dayName, abbreviatedDayName or shortestDayName (two char). * @param {String} The name of the day (eg. "Monday, "Mon", "tuesday", "tue", "We", "we"). * @return {Number} The day number */ $D.getDayNumberFromName = function (name) { var n = Date.CultureInfo.dayNames, m = Date.CultureInfo.abbreviatedDayNames, o = Date.CultureInfo.shortestDayNames, s = name.toLowerCase(); for (var i = 0; i < n.length; i++) { if (n[i].toLowerCase() === s || m[i].toLowerCase() === s || o[i].toLowerCase() === s) { return i; } } return -1; }; /** * Gets the month number (0-11) if given a Culture Info specific string which is a valid monthName or abbreviatedMonthName. * @param {String} The name of the month (eg. "February, "Feb", "october", "oct"). * @return {Number} The day number */ $D.getMonthNumberFromName = function (name) { var n = Date.CultureInfo.monthNames, m = Date.CultureInfo.abbreviatedMonthNames, s = name.toLowerCase(); for (var i = 0; i < n.length; i++) { if (n[i].toLowerCase() === s || m[i].toLowerCase() === s) { return i; } } return -1; }; /** * Gets the language appropriate month name when given the month number(0-11) * eg - 0 == January * @return {String} The month name */ $D.getMonthName = function (n) { return Date.CultureInfo.monthNames[n]; }; /** * Determines if the current date instance is within a LeapYear. * @param {Number} The year. * @return {Boolean} true if date is within a LeapYear, otherwise false. */ $D.isLeapYear = function (year) { return ((year % 4 === 0 && year % 100 !== 0) || year % 400 === 0); }; /** * Gets the number of days in the month, given a year and month value. Automatically corrects for LeapYear. * @param {Number} The year. * @param {Number} The month (0-11). * @return {Number} The number of days in the month. */ $D.getDaysInMonth = function (year, month) { if (!month && $D.validateMonth(year)) { month = year; year = Date.today().getFullYear(); } return [31, ($D.isLeapYear(year) ? 29 : 28), 31, 30, 31, 30, 31, 31, 30, 31, 30, 31][month]; }; $P.getDaysInMonth = function () { return $D.getDaysInMonth(this.getFullYear(), this.getMonth()); }; $D.getTimezoneAbbreviation = function (offset, dst) { var p, n = (dst || false) ? Date.CultureInfo.abbreviatedTimeZoneDST : Date.CultureInfo.abbreviatedTimeZoneStandard; for (p in n) { if (n.hasOwnProperty(p)) { if (n[p] === offset) { return p; } } } return null; }; $D.getTimezoneOffset = function (name, dst) { var i, a =[], z = Date.CultureInfo.timezones; if (!name) { name = (new Date()).getTimezone();} for (i = 0; i < z.length; i++) { if (z[i].name === name.toUpperCase()) { a.push(i); } } if (!z[a[0]]) { return null; } if (a.length === 1 || !dst) { return z[a[0]].offset; } else { for (i=0; i < a.length; i++) { if (z[a[i]].dst) { return z[a[i]].offset; } } } }; $D.getQuarter = function (d) { d = d || new Date(); // If no date supplied, use today var q = [1,2,3,4]; return q[Math.floor(d.getMonth() / 3)]; // ~~~ is a bitwise op. Faster than Math.floor }; $D.getDaysLeftInQuarter = function (d) { d = d || new Date(); var qEnd = new Date(d); qEnd.setMonth(qEnd.getMonth() + 3 - qEnd.getMonth() % 3, 0); return Math.floor((qEnd - d) / 8.64e7); }; // private var validate = function (n, min, max, name) { name = name ? name : "Object"; if (typeof n === "undefined") { return false; } else if (typeof n !== "number") { throw new TypeError(n + " is not a Number."); } else if (n < min || n > max) { // As failing validation is *not* an exceptional circumstance // lets not throw a RangeError Exception here. // It's semantically correct but it's not sensible. return false; } return true; }; /** * Validates the number is within an acceptable range for milliseconds [0-999]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateMillisecond = function (value) { return validate(value, 0, 999, "millisecond"); }; /** * Validates the number is within an acceptable range for seconds [0-59]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateSecond = function (value) { return validate(value, 0, 59, "second"); }; /** * Validates the number is within an acceptable range for minutes [0-59]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateMinute = function (value) { return validate(value, 0, 59, "minute"); }; /** * Validates the number is within an acceptable range for hours [0-23]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateHour = function (value) { return validate(value, 0, 23, "hour"); }; /** * Validates the number is within an acceptable range for the days in a month [0-MaxDaysInMonth]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateDay = function (value, year, month) { if (year === undefined || year === null || month === undefined || month === null) { return false;} return validate(value, 1, $D.getDaysInMonth(year, month), "day"); }; /** * Validates the number is within an acceptable range for months [0-11]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateWeek = function (value) { return validate(value, 0, 53, "week"); }; /** * Validates the number is within an acceptable range for months [0-11]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateMonth = function (value) { return validate(value, 0, 11, "month"); }; /** * Validates the number is within an acceptable range for years. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateYear = function (value) { /** * Per ECMAScript spec the range of times supported by Date objects is * exactly -100,000,000 days to +100,000,000 days measured relative to * midnight at the beginning of 01 January, 1970 UTC. * This gives a range of 8,640,000,000,000,000 milliseconds to either * side of 01 January, 1970 UTC. * * Earliest possible date: Tue, 20 Apr 271,822 B.C. 00:00:00 UTC * Latest possible date: Sat, 13 Sep 275,760 00:00:00 UTC */ return validate(value, -271822, 275760, "year"); }; $D.validateTimezone = function(value) { var timezones = {"ACDT":1,"ACST":1,"ACT":1,"ADT":1,"AEDT":1,"AEST":1,"AFT":1,"AKDT":1,"AKST":1,"AMST":1,"AMT":1,"ART":1,"AST":1,"AWDT":1,"AWST":1,"AZOST":1,"AZT":1,"BDT":1,"BIOT":1,"BIT":1,"BOT":1,"BRT":1,"BST":1,"BTT":1,"CAT":1,"CCT":1,"CDT":1,"CEDT":1,"CEST":1,"CET":1,"CHADT":1,"CHAST":1,"CHOT":1,"ChST":1,"CHUT":1,"CIST":1,"CIT":1,"CKT":1,"CLST":1,"CLT":1,"COST":1,"COT":1,"CST":1,"CT":1,"CVT":1,"CWST":1,"CXT":1,"DAVT":1,"DDUT":1,"DFT":1,"EASST":1,"EAST":1,"EAT":1,"ECT":1,"EDT":1,"EEDT":1,"EEST":1,"EET":1,"EGST":1,"EGT":1,"EIT":1,"EST":1,"FET":1,"FJT":1,"FKST":1,"FKT":1,"FNT":1,"GALT":1,"GAMT":1,"GET":1,"GFT":1,"GILT":1,"GIT":1,"GMT":1,"GST":1,"GYT":1,"HADT":1,"HAEC":1,"HAST":1,"HKT":1,"HMT":1,"HOVT":1,"HST":1,"ICT":1,"IDT":1,"IOT":1,"IRDT":1,"IRKT":1,"IRST":1,"IST":1,"JST":1,"KGT":1,"KOST":1,"KRAT":1,"KST":1,"LHST":1,"LINT":1,"MAGT":1,"MART":1,"MAWT":1,"MDT":1,"MET":1,"MEST":1,"MHT":1,"MIST":1,"MIT":1,"MMT":1,"MSK":1,"MST":1,"MUT":1,"MVT":1,"MYT":1,"NCT":1,"NDT":1,"NFT":1,"NPT":1,"NST":1,"NT":1,"NUT":1,"NZDT":1,"NZST":1,"OMST":1,"ORAT":1,"PDT":1,"PET":1,"PETT":1,"PGT":1,"PHOT":1,"PHT":1,"PKT":1,"PMDT":1,"PMST":1,"PONT":1,"PST":1,"PYST":1,"PYT":1,"RET":1,"ROTT":1,"SAKT":1,"SAMT":1,"SAST":1,"SBT":1,"SCT":1,"SGT":1,"SLST":1,"SRT":1,"SST":1,"SYOT":1,"TAHT":1,"THA":1,"TFT":1,"TJT":1,"TKT":1,"TLT":1,"TMT":1,"TOT":1,"TVT":1,"UCT":1,"ULAT":1,"UTC":1,"UYST":1,"UYT":1,"UZT":1,"VET":1,"VLAT":1,"VOLT":1,"VOST":1,"VUT":1,"WAKT":1,"WAST":1,"WAT":1,"WEDT":1,"WEST":1,"WET":1,"WST":1,"YAKT":1,"YEKT":1,"Z":1}; return (timezones[value] === 1); }; $D.validateTimezoneOffset= function(value) { // timezones go from +14hrs to -12hrs, the +X hours are negative offsets. return (value > -841 && value < 721); }; }()); (function () { var $D = Date, $P = $D.prototype, p = function (s, l) { if (!l) { l = 2; } return ("000" + s).slice(l * -1); }; var validateConfigObject = function (obj) { var result = {}, self = this, prop, testFunc; testFunc = function (prop, func, value) { if (prop === "day") { var month = (obj.month !== undefined) ? obj.month : self.getMonth(); var year = (obj.year !== undefined) ? obj.year : self.getFullYear(); return $D[func](value, year, month); } else { return $D[func](value); } }; for (prop in obj) { if (Object.prototype.hasOwnProperty.call(obj, prop)) { var func = "validate" + prop.charAt(0).toUpperCase() + prop.slice(1); if ($D[func] && obj[prop] !== null && testFunc(prop, func, obj[prop])) { result[prop] = obj[prop]; } } } return result; }; /** * Resets the time of this Date object to 12:00 AM (00:00), which is the start of the day. * @param {Boolean} .clone() this date instance before clearing Time * @return {Date} this */ $P.clearTime = function () { this.setHours(0); this.setMinutes(0); this.setSeconds(0); this.setMilliseconds(0); return this; }; /** * Resets the time of this Date object to the current time ('now'). * @return {Date} this */ $P.setTimeToNow = function () { var n = new Date(); this.setHours(n.getHours()); this.setMinutes(n.getMinutes()); this.setSeconds(n.getSeconds()); this.setMilliseconds(n.getMilliseconds()); return this; }; /** * Returns a new Date object that is an exact date and time copy of the original instance. * @return {Date} A new Date instance */ $P.clone = function () { return new Date(this.getTime()); }; /** * Compares this instance to a Date object and returns an number indication of their relative values. * @param {Date} Date object to compare [Required] * @return {Number} -1 = this is lessthan date. 0 = values are equal. 1 = this is greaterthan date. */ $P.compareTo = function (date) { return Date.compare(this, date); }; /** * Compares this instance to another Date object and returns true if they are equal. * @param {Date} Date object to compare. If no date to compare, new Date() [now] is used. * @return {Boolean} true if dates are equal. false if they are not equal. */ $P.equals = function (date) { return Date.equals(this, (date !== undefined ? date : new Date())); }; /** * Determines if this instance is between a range of two dates or equal to either the start or end dates. * @param {Date} Start of range [Required] * @param {Date} End of range [Required] * @return {Boolean} true is this is between or equal to the start and end dates, else false */ $P.between = function (start, end) { return this.getTime() >= start.getTime() && this.getTime() <= end.getTime(); }; /** * Determines if this date occurs after the date to compare to. * @param {Date} Date object to compare. If no date to compare, new Date() ("now") is used. * @return {Boolean} true if this date instance is greater than the date to compare to (or "now"), otherwise false. */ $P.isAfter = function (date) { return this.compareTo(date || new Date()) === 1; }; /** * Determines if this date occurs before the date to compare to. * @param {Date} Date object to compare. If no date to compare, new Date() ("now") is used. * @return {Boolean} true if this date instance is less than the date to compare to (or "now"). */ $P.isBefore = function (date) { return (this.compareTo(date || new Date()) === -1); }; /** * Determines if the current Date instance occurs today. * @return {Boolean} true if this date instance is 'today', otherwise false. */ /** * Determines if the current Date instance occurs on the same Date as the supplied 'date'. * If no 'date' to compare to is provided, the current Date instance is compared to 'today'. * @param {date} Date object to compare. If no date to compare, the current Date ("now") is used. * @return {Boolean} true if this Date instance occurs on the same Day as the supplied 'date'. */ $P.isToday = $P.isSameDay = function (date) { return this.clone().clearTime().equals((date || new Date()).clone().clearTime()); }; /** * Adds the specified number of milliseconds to this instance. * @param {Number} The number of milliseconds to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addMilliseconds = function (value) { if (!value) { return this; } this.setTime(this.getTime() + value * 1); return this; }; /** * Adds the specified number of seconds to this instance. * @param {Number} The number of seconds to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addSeconds = function (value) { if (!value) { return this; } return this.addMilliseconds(value * 1000); }; /** * Adds the specified number of seconds to this instance. * @param {Number} The number of seconds to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addMinutes = function (value) { if (!value) { return this; } return this.addMilliseconds(value * 60000); // 60*1000 }; /** * Adds the specified number of hours to this instance. * @param {Number} The number of hours to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addHours = function (value) { if (!value) { return this; } return this.addMilliseconds(value * 3600000); // 60*60*1000 }; /** * Adds the specified number of days to this instance. * @param {Number} The number of days to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addDays = function (value) { if (!value) { return this; } this.setDate(this.getDate() + value * 1); return this; }; /** * Adds the specified number of weekdays (ie - not sat or sun) to this instance. * @param {Number} The number of days to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addWeekdays = function (value) { if (!value) { return this; } var day = this.getDay(); var weeks = (Math.ceil(Math.abs(value)/7)); if (day === 0 || day === 6) { if (value > 0) { this.next().monday(); this.addDays(-1); day = this.getDay(); } } if (value < 0) { while (value < 0) { this.addDays(-1); day = this.getDay(); if (day !== 0 && day !== 6) { value++; } } return this; } else if (value > 5 || (6-day) <= value) { value = value + (weeks * 2); } return this.addDays(value); }; /** * Adds the specified number of weeks to this instance. * @param {Number} The number of weeks to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addWeeks = function (value) { if (!value) { return this; } return this.addDays(value * 7); }; /** * Adds the specified number of months to this instance. * @param {Number} The number of months to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addMonths = function (value) { if (!value) { return this; } var n = this.getDate(); this.setDate(1); this.setMonth(this.getMonth() + value * 1); this.setDate(Math.min(n, $D.getDaysInMonth(this.getFullYear(), this.getMonth()))); return this; }; $P.addQuarters = function (value) { if (!value) { return this; } // note this will take you to the same point in the quarter as you are now. // i.e. - if you are 15 days into the quarter you'll be 15 days into the resulting one. // bonus: this allows adding fractional quarters return this.addMonths(value * 3); }; /** * Adds the specified number of years to this instance. * @param {Number} The number of years to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addYears = function (value) { if (!value) { return this; } return this.addMonths(value * 12); }; /** * Adds (or subtracts) to the value of the years, months, weeks, days, hours, minutes, seconds, milliseconds of the date instance using given configuration object. Positive and Negative values allowed. * Example

	Date.today().add( { days: 1, months: 1 } )

	new Date().add( { years: -1 } )
	
* @param {Object} Configuration object containing attributes (months, days, etc.) * @return {Date} this */ $P.add = function (config) { if (typeof config === "number") { this._orient = config; return this; } var x = config; if (x.day) { // If we should be a different date than today (eg: for 'tomorrow -1d', etc). // Should only effect parsing, not direct usage (eg, Finish and FinishExact) if ((x.day - this.getDate()) !== 0) { this.setDate(x.day); } } if (x.milliseconds) { this.addMilliseconds(x.milliseconds); } if (x.seconds) { this.addSeconds(x.seconds); } if (x.minutes) { this.addMinutes(x.minutes); } if (x.hours) { this.addHours(x.hours); } if (x.weeks) { this.addWeeks(x.weeks); } if (x.months) { this.addMonths(x.months); } if (x.years) { this.addYears(x.years); } if (x.days) { this.addDays(x.days); } return this; }; /** * Get the week number. Week one (1) is the week which contains the first Thursday of the year. Monday is considered the first day of the week. * The .getWeek() function does NOT convert the date to UTC. The local datetime is used. * Please use .getISOWeek() to get the week of the UTC converted date. * @return {Number} 1 to 53 */ $P.getWeek = function (utc) { // Create a copy of this date object var self, target = new Date(this.valueOf()); if (utc) { target.addMinutes(target.getTimezoneOffset()); self = target.clone(); } else { self = this; } // ISO week date weeks start on monday // so correct the day number var dayNr = (self.getDay() + 6) % 7; // ISO 8601 states that week 1 is the week // with the first thursday of that year. // Set the target date to the thursday in the target week target.setDate(target.getDate() - dayNr + 3); // Store the millisecond value of the target date var firstThursday = target.valueOf(); // Set the target to the first thursday of the year // First set the target to january first target.setMonth(0, 1); // Not a thursday? Correct the date to the next thursday if (target.getDay() !== 4) { target.setMonth(0, 1 + ((4 - target.getDay()) + 7) % 7); } // The weeknumber is the number of weeks between the // first thursday of the year and the thursday in the target week return 1 + Math.ceil((firstThursday - target) / 604800000); // 604800000 = 7 * 24 * 3600 * 1000 }; /** * Get the ISO 8601 week number. Week one ("01") is the week which contains the first Thursday of the year. Monday is considered the first day of the week. * The .getISOWeek() function does convert the date to it's UTC value. Please use .getWeek() to get the week of the local date. * @return {String} "01" to "53" */ $P.getISOWeek = function () { return p(this.getWeek(true)); }; /** * Moves the date to Monday of the week set. Week one (1) is the week which contains the first Thursday of the year. * @param {Number} A Number (1 to 53) that represents the week of the year. * @return {Date} this */ $P.setWeek = function (n) { if ((n - this.getWeek()) === 0) { if (this.getDay() !== 1) { return this.moveToDayOfWeek(1, (this.getDay() > 1 ? -1 : 1)); } else { return this; } } else { return this.moveToDayOfWeek(1, (this.getDay() > 1 ? -1 : 1)).addWeeks(n - this.getWeek()); } }; $P.setQuarter = function (qtr) { var month = Math.abs(((qtr-1) * 3) + 1); return this.setMonth(month, 1); }; $P.getQuarter = function () { return Date.getQuarter(this); }; $P.getDaysLeftInQuarter = function () { return Date.getDaysLeftInQuarter(this); }; /** * Moves the date to the next n'th occurrence of the dayOfWeek starting from the beginning of the month. The number (-1) is a magic number and will return the last occurrence of the dayOfWeek in the month. * @param {Number} The dayOfWeek to move to * @param {Number} The n'th occurrence to move to. Use (-1) to return the last occurrence in the month * @return {Date} this */ $P.moveToNthOccurrence = function (dayOfWeek, occurrence) { if (dayOfWeek === "Weekday") { if (occurrence > 0) { this.moveToFirstDayOfMonth(); if (this.is().weekday()) { occurrence -= 1; } } else if (occurrence < 0) { this.moveToLastDayOfMonth(); if (this.is().weekday()) { occurrence += 1; } } else { return this; } return this.addWeekdays(occurrence); } var shift = 0; if (occurrence > 0) { shift = occurrence - 1; } else if (occurrence === -1) { this.moveToLastDayOfMonth(); if (this.getDay() !== dayOfWeek) { this.moveToDayOfWeek(dayOfWeek, -1); } return this; } return this.moveToFirstDayOfMonth().addDays(-1).moveToDayOfWeek(dayOfWeek, +1).addWeeks(shift); }; var moveToN = function (getFunc, addFunc, nVal) { return function (value, orient) { var diff = (value - this[getFunc]() + nVal * (orient || +1)) % nVal; return this[addFunc]((diff === 0) ? diff += nVal * (orient || +1) : diff); }; }; /** * Move to the next or last dayOfWeek based on the orient value. * @param {Number} The dayOfWeek to move to * @param {Number} Forward (+1) or Back (-1). Defaults to +1. [Optional] * @return {Date} this */ $P.moveToDayOfWeek = moveToN("getDay", "addDays", 7); /** * Move to the next or last month based on the orient value. * @param {Number} The month to move to. 0 = January, 11 = December * @param {Number} Forward (+1) or Back (-1). Defaults to +1. [Optional] * @return {Date} this */ $P.moveToMonth = moveToN("getMonth", "addMonths", 12); /** * Get the Ordinate of the current day ("th", "st", "rd"). * @return {String} */ $P.getOrdinate = function () { var num = this.getDate(); return ord(num); }; /** * Get the Ordinal day (numeric day number) of the year, adjusted for leap year. * @return {Number} 1 through 365 (366 in leap years) */ $P.getOrdinalNumber = function () { return Math.ceil((this.clone().clearTime() - new Date(this.getFullYear(), 0, 1)) / 86400000) + 1; }; /** * Get the time zone abbreviation of the current date. * @return {String} The abbreviated time zone name (e.g. "EST") */ $P.getTimezone = function () { return $D.getTimezoneAbbreviation(this.getUTCOffset(), this.isDaylightSavingTime()); }; $P.setTimezoneOffset = function (offset) { var here = this.getTimezoneOffset(), there = Number(offset) * -6 / 10; return (there || there === 0) ? this.addMinutes(there - here) : this; }; $P.setTimezone = function (offset) { return this.setTimezoneOffset($D.getTimezoneOffset(offset)); }; /** * Indicates whether Daylight Saving Time is observed in the current time zone. * @return {Boolean} true|false */ $P.hasDaylightSavingTime = function () { return (Date.today().set({month: 0, day: 1}).getTimezoneOffset() !== Date.today().set({month: 6, day: 1}).getTimezoneOffset()); }; /** * Indicates whether this Date instance is within the Daylight Saving Time range for the current time zone. * @return {Boolean} true|false */ $P.isDaylightSavingTime = function () { return Date.today().set({month: 0, day: 1}).getTimezoneOffset() !== this.getTimezoneOffset(); }; /** * Get the offset from UTC of the current date. * @return {String} The 4-character offset string prefixed with + or - (e.g. "-0500") */ $P.getUTCOffset = function (offset) { var n = (offset || this.getTimezoneOffset()) * -10 / 6, r; if (n < 0) { r = (n - 10000).toString(); return r.charAt(0) + r.substr(2); } else { r = (n + 10000).toString(); return "+" + r.substr(1); } }; /** * Returns the number of milliseconds between this date and date. * @param {Date} Defaults to now * @return {Number} The diff in milliseconds */ $P.getElapsed = function (date) { return (date || new Date()) - this; }; /** * Set the value of year, month, day, hour, minute, second, millisecond of date instance using given configuration object. * Example

	Date.today().set( { day: 20, month: 1 } )

	new Date().set( { millisecond: 0 } )
	
* * @param {Object} Configuration object containing attributes (month, day, etc.) * @return {Date} this */ $P.set = function (config) { config = validateConfigObject.call(this, config); var key; for (key in config) { if (Object.prototype.hasOwnProperty.call(config, key)) { var name = key.charAt(0).toUpperCase() + key.slice(1); var addFunc, getFunc; if (key !== "week" && key !== "month" && key !== "timezone" && key !== "timezoneOffset") { name += "s"; } addFunc = "add" + name; getFunc = "get" + name; if (key === "month") { addFunc = addFunc + "s"; } else if (key === "year"){ getFunc = "getFullYear"; } if (key !== "day" && key !== "timezone" && key !== "timezoneOffset" && key !== "week" && key !== "hour") { this[addFunc](config[key] - this[getFunc]()); } else if ( key === "timezone"|| key === "timezoneOffset" || key === "week" || key === "hour") { this["set"+name](config[key]); } } } // day has to go last because you can't validate the day without first knowing the month if (config.day) { this.addDays(config.day - this.getDate()); } return this; }; /** * Moves the date to the first day of the month. * @return {Date} this */ $P.moveToFirstDayOfMonth = function () { return this.set({ day: 1 }); }; /** * Moves the date to the last day of the month. * @return {Date} this */ $P.moveToLastDayOfMonth = function () { return this.set({ day: $D.getDaysInMonth(this.getFullYear(), this.getMonth())}); }; /** * Converts the value of the current Date object to its equivalent string representation. * Format Specifiers * CUSTOM DATE AND TIME FORMAT STRINGS * Format Description Example * ------ --------------------------------------------------------------------------- ----------------------- * s The seconds of the minute between 0-59. "0" to "59" * ss The seconds of the minute with leading zero if required. "00" to "59" * * m The minute of the hour between 0-59. "0" or "59" * mm The minute of the hour with leading zero if required. "00" or "59" * * h The hour of the day between 1-12. "1" to "12" * hh The hour of the day with leading zero if required. "01" to "12" * * H The hour of the day between 0-23. "0" to "23" * HH The hour of the day with leading zero if required. "00" to "23" * * d The day of the month between 1 and 31. "1" to "31" * dd The day of the month with leading zero if required. "01" to "31" * ddd Abbreviated day name. Date.CultureInfo.abbreviatedDayNames. "Mon" to "Sun" * dddd The full day name. Date.CultureInfo.dayNames. "Monday" to "Sunday" * * M The month of the year between 1-12. "1" to "12" * MM The month of the year with leading zero if required. "01" to "12" * MMM Abbreviated month name. Date.CultureInfo.abbreviatedMonthNames. "Jan" to "Dec" * MMMM The full month name. Date.CultureInfo.monthNames. "January" to "December" * * yy The year as a two-digit number. "99" or "08" * yyyy The full four digit year. "1999" or "2008" * * t Displays the first character of the A.M./P.M. designator. "A" or "P" * Date.CultureInfo.amDesignator or Date.CultureInfo.pmDesignator * tt Displays the A.M./P.M. designator. "AM" or "PM" * Date.CultureInfo.amDesignator or Date.CultureInfo.pmDesignator * * S The ordinal suffix ("st, "nd", "rd" or "th") of the current day. "st, "nd", "rd" or "th" * * STANDARD DATE AND TIME FORMAT STRINGS * Format Description Example *------ --------------------------------------------------------------------------- ----------------------- * d The CultureInfo shortDate Format Pattern "M/d/yyyy" * D The CultureInfo longDate Format Pattern "dddd, MMMM dd, yyyy" * F The CultureInfo fullDateTime Format Pattern "dddd, MMMM dd, yyyy h:mm:ss tt" * m The CultureInfo monthDay Format Pattern "MMMM dd" * r The CultureInfo rfc1123 Format Pattern "ddd, dd MMM yyyy HH:mm:ss GMT" * s The CultureInfo sortableDateTime Format Pattern "yyyy-MM-ddTHH:mm:ss" * t The CultureInfo shortTime Format Pattern "h:mm tt" * T The CultureInfo longTime Format Pattern "h:mm:ss tt" * u The CultureInfo universalSortableDateTime Format Pattern "yyyy-MM-dd HH:mm:ssZ" * y The CultureInfo yearMonth Format Pattern "MMMM, yyyy" * * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @return {String} A string representation of the current Date object. */ var ord = function (n) { switch (n * 1) { case 1: case 21: case 31: return "st"; case 2: case 22: return "nd"; case 3: case 23: return "rd"; default: return "th"; } }; var parseStandardFormats = function (format) { var y, c = Date.CultureInfo.formatPatterns; switch (format) { case "d": return this.toString(c.shortDate); case "D": return this.toString(c.longDate); case "F": return this.toString(c.fullDateTime); case "m": return this.toString(c.monthDay); case "r": case "R": y = this.clone().addMinutes(this.getTimezoneOffset()); return y.toString(c.rfc1123) + " GMT"; case "s": return this.toString(c.sortableDateTime); case "t": return this.toString(c.shortTime); case "T": return this.toString(c.longTime); case "u": y = this.clone().addMinutes(this.getTimezoneOffset()); return y.toString(c.universalSortableDateTime); case "y": return this.toString(c.yearMonth); default: return false; } }; var parseFormatStringsClosure = function (context) { return function (m) { if (m.charAt(0) === "\\") { return m.replace("\\", ""); } switch (m) { case "hh": return p(context.getHours() < 13 ? (context.getHours() === 0 ? 12 : context.getHours()) : (context.getHours() - 12)); case "h": return context.getHours() < 13 ? (context.getHours() === 0 ? 12 : context.getHours()) : (context.getHours() - 12); case "HH": return p(context.getHours()); case "H": return context.getHours(); case "mm": return p(context.getMinutes()); case "m": return context.getMinutes(); case "ss": return p(context.getSeconds()); case "s": return context.getSeconds(); case "yyyy": return p(context.getFullYear(), 4); case "yy": return p(context.getFullYear()); case "y": return context.getFullYear(); case "E": case "dddd": return Date.CultureInfo.dayNames[context.getDay()]; case "ddd": return Date.CultureInfo.abbreviatedDayNames[context.getDay()]; case "dd": return p(context.getDate()); case "d": return context.getDate(); case "MMMM": return Date.CultureInfo.monthNames[context.getMonth()]; case "MMM": return Date.CultureInfo.abbreviatedMonthNames[context.getMonth()]; case "MM": return p((context.getMonth() + 1)); case "M": return context.getMonth() + 1; case "t": return context.getHours() < 12 ? Date.CultureInfo.amDesignator.substring(0, 1) : Date.CultureInfo.pmDesignator.substring(0, 1); case "tt": return context.getHours() < 12 ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator; case "S": return ord(context.getDate()); case "W": return context.getWeek(); case "WW": return context.getISOWeek(); case "Q": return "Q" + context.getQuarter(); case "q": return String(context.getQuarter()); case "z": return context.getTimezone(); case "Z": case "X": return Date.getTimezoneOffset(context.getTimezone()); case "ZZ": // Timezone offset in seconds return context.getTimezoneOffset() * -60; case "u": return context.getDay(); case "L": return ($D.isLeapYear(context.getFullYear())) ? 1 : 0; case "B": // Swatch Internet Time (.beats) return "@"+((context.getUTCSeconds() + (context.getUTCMinutes()*60) + ((context.getUTCHours()+1)*3600))/86.4); default: return m; } }; }; $P.toString = function (format, ignoreStandards) { // Standard Date and Time Format Strings. Formats pulled from CultureInfo file and // may vary by culture. if (!ignoreStandards && format && format.length === 1) { output = parseStandardFormats.call(this, format); if (output) { return output; } } var parseFormatStrings = parseFormatStringsClosure(this); return format ? format.replace(/((\\)?(dd?d?d?|MM?M?M?|yy?y?y?|hh?|HH?|mm?|ss?|tt?|S|q|Q|WW?W?W?)(?![^\[]*\]))/g, parseFormatStrings).replace(/\[|\]/g, "") : this._toString(); }; }()); /************************************************************* * SugarPak - Domain Specific Language - Syntactical Sugar * *************************************************************/ (function () { var $D = Date, $P = $D.prototype, $N = Number.prototype; // private $P._orient = +1; // private $P._nth = null; // private $P._is = false; // private $P._same = false; // private $P._isSecond = false; // private $N._dateElement = "days"; /** * Moves the date to the next instance of a date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.today().next().friday();
	Date.today().next().fri();
	Date.today().next().march();
	Date.today().next().mar();
	Date.today().next().week();
	
* * @return {Date} date */ $P.next = function () { this._move = true; this._orient = +1; return this; }; /** * Creates a new Date (Date.today()) and moves the date to the next instance of the date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.next().friday();
	Date.next().fri();
	Date.next().march();
	Date.next().mar();
	Date.next().week();
	
* * @return {Date} date */ $D.next = function () { return $D.today().next(); }; /** * Moves the date to the previous instance of a date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.today().last().friday();
	Date.today().last().fri();
	Date.today().last().march();
	Date.today().last().mar();
	Date.today().last().week();
	
* * @return {Date} date */ $P.last = $P.prev = $P.previous = function () { this._move = true; this._orient = -1; return this; }; /** * Creates a new Date (Date.today()) and moves the date to the previous instance of the date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.last().friday();
	Date.last().fri();
	Date.previous().march();
	Date.prev().mar();
	Date.last().week();
	
* * @return {Date} date */ $D.last = $D.prev = $D.previous = function () { return $D.today().last(); }; /** * Performs a equality check when followed by either a month name, day name or .weekday() function. * Example

	Date.today().is().friday(); // true|false
	Date.today().is().fri();
	Date.today().is().march();
	Date.today().is().mar();
	
* * @return {Boolean} true|false */ $P.is = function () { this._is = true; return this; }; /** * Determines if two date objects occur on/in exactly the same instance of the subsequent date part function. * The function .same() must be followed by a date part function (example: .day(), .month(), .year(), etc). * * An optional Date can be passed in the date part function. If now date is passed as a parameter, 'Now' is used. * * The following example demonstrates how to determine if two dates fall on the exact same day. * * Example

	var d1 = Date.today(); // today at 00:00
	var d2 = new Date();   // exactly now.

	// Do they occur on the same day?
	d1.same().day(d2); // true
	
	// Do they occur on the same hour?
	d1.same().hour(d2); // false, unless d2 hour is '00' (midnight).
	
	// What if it's the same day, but one year apart?
	var nextYear = Date.today().add(1).year();

	d1.same().day(nextYear); // false, because the dates must occur on the exact same day. 
	
* * Scenario: Determine if a given date occurs during some week period 2 months from now. * * Example

	var future = Date.today().add(2).months();
	return someDate.same().week(future); // true|false;
	
* * @return {Boolean} true|false */ $P.same = function () { this._same = true; this._isSecond = false; return this; }; /** * Determines if the current date/time occurs during Today. Must be preceded by the .is() function. * Example

	someDate.is().today();    // true|false
	new Date().is().today();  // true
	Date.today().is().today();// true
	Date.today().add(-1).day().is().today(); // false
	
* * @return {Boolean} true|false */ $P.today = function () { return this.same().day(); }; /** * Determines if the current date is a weekday. This function must be preceded by the .is() function. * Example

	Date.today().is().weekday(); // true|false
	
* * @return {Boolean} true|false */ $P.weekday = function () { if (this._nth) { return df("Weekday").call(this); } if (this._move) { return this.addWeekdays(this._orient); } if (this._is) { this._is = false; return (!this.is().sat() && !this.is().sun()); } return false; }; /** * Determines if the current date is on the weekend. This function must be preceded by the .is() function. * Example

	Date.today().is().weekend(); // true|false
	
* * @return {Boolean} true|false */ $P.weekend = function () { if (this._is) { this._is = false; return (this.is().sat() || this.is().sun()); } return false; }; /** * Sets the Time of the current Date instance. A string "6:15 pm" or config object {hour:18, minute:15} are accepted. * Example

	// Set time to 6:15pm with a String
	Date.today().at("6:15pm");

	// Set time to 6:15pm with a config object
	Date.today().at({hour:18, minute:15});
	
* * @return {Date} date */ $P.at = function (time) { return (typeof time === "string") ? $D.parse(this.toString("d") + " " + time) : this.set(time); }; /** * Creates a new Date() and adds this (Number) to the date based on the preceding date element function (eg. second|minute|hour|day|month|year). * Example

	// Undeclared Numbers must be wrapped with parentheses. Requirment of JavaScript.
	(3).days().fromNow();
	(6).months().fromNow();

	// Declared Number variables do not require parentheses. 
	var n = 6;
	n.months().fromNow();
	
* * @return {Date} A new Date instance */ $N.fromNow = $N.after = function (date) { var c = {}; c[this._dateElement] = this; return ((!date) ? new Date() : date.clone()).add(c); }; /** * Creates a new Date() and subtract this (Number) from the date based on the preceding date element function (eg. second|minute|hour|day|month|year). * Example

	// Undeclared Numbers must be wrapped with parentheses. Requirment of JavaScript.
	(3).days().ago();
	(6).months().ago();

	// Declared Number variables do not require parentheses. 
	var n = 6;
	n.months().ago();
	
* * @return {Date} A new Date instance */ $N.ago = $N.before = function (date) { var c = {}, s = (this._dateElement[this._dateElement.length-1] !== "s") ? this._dateElement + "s" : this._dateElement; c[s] = this * -1; return ((!date) ? new Date() : date.clone()).add(c); }; // Do NOT modify the following string tokens. These tokens are used to build dynamic functions. // All culture-specific strings can be found in the CultureInfo files. var dx = ("sunday monday tuesday wednesday thursday friday saturday").split(/\s/), mx = ("january february march april may june july august september october november december").split(/\s/), px = ("Millisecond Second Minute Hour Day Week Month Year Quarter Weekday").split(/\s/), pxf = ("Milliseconds Seconds Minutes Hours Date Week Month FullYear Quarter").split(/\s/), nth = ("final first second third fourth fifth").split(/\s/), de; /** * Returns an object literal of all the date parts. * Example

	var o = new Date().toObject();
	
	// { year: 2008, month: 4, week: 20, day: 13, hour: 18, minute: 9, second: 32, millisecond: 812 }
	
	// The object properties can be referenced directly from the object.
	
	alert(o.day);  // alerts "13"
	alert(o.year); // alerts "2008"
	
* * @return {Date} An object literal representing the original date object. */ $P.toObject = function () { var o = {}; for (var i = 0; i < px.length; i++) { if (this["get" + pxf[i]]) { o[px[i].toLowerCase()] = this["get" + pxf[i]](); } } return o; }; /** * Returns a date created from an object literal. Ignores the .week property if set in the config. * Example

	var o = new Date().toObject();
	
	return Date.fromObject(o); // will return the same date. 

	var o2 = {month: 1, day: 20, hour: 18}; // birthday party!
	Date.fromObject(o2);
	
* * @return {Date} An object literal representing the original date object. */ $D.fromObject = function(config) { config.week = null; return Date.today().set(config); }; // Create day name functions and abbreviated day name functions (eg. monday(), friday(), fri()). var df = function (n) { return function () { if (this._is) { this._is = false; return this.getDay() === n; } if (this._move) { this._move = null; } if (this._nth !== null) { // If the .second() function was called earlier, remove the _orient // from the date, and then continue. // This is required because 'second' can be used in two different context. // // Example // // Date.today().add(1).second(); // Date.march().second().monday(); // // Things get crazy with the following... // Date.march().add(1).second().second().monday(); // but it works!! // if (this._isSecond) { this.addSeconds(this._orient * -1); } // make sure we reset _isSecond this._isSecond = false; var ntemp = this._nth; this._nth = null; var temp = this.clone().moveToLastDayOfMonth(); this.moveToNthOccurrence(n, ntemp); if (this > temp) { throw new RangeError($D.getDayName(n) + " does not occur " + ntemp + " times in the month of " + $D.getMonthName(temp.getMonth()) + " " + temp.getFullYear() + "."); } return this; } return this.moveToDayOfWeek(n, this._orient); }; }; var sdf = function (n) { return function () { var t = $D.today(), shift = n - t.getDay(); if (n === 0 && Date.CultureInfo.firstDayOfWeek === 1 && t.getDay() !== 0) { shift = shift + 7; } return t.addDays(shift); }; }; // Create month name functions and abbreviated month name functions (eg. january(), march(), mar()). var month_instance_functions = function (n) { return function () { if (this._is) { this._is = false; return this.getMonth() === n; } return this.moveToMonth(n, this._orient); }; }; var month_static_functions = function (n) { return function () { return $D.today().set({ month: n, day: 1 }); }; }; var processTerms = function (names, staticFunc, instanceFunc) { for (var i = 0; i < names.length; i++) { // Create constant static Name variables. $D[names[i].toUpperCase()] = $D[names[i].toUpperCase().substring(0, 3)] = i; // Create Name functions. $D[names[i]] = $D[names[i].substring(0, 3)] = staticFunc(i); // Create Name instance functions. $P[names[i]] = $P[names[i].substring(0, 3)] = instanceFunc(i); } }; processTerms(dx, sdf, df); processTerms(mx, month_static_functions, month_instance_functions); // Create date element functions and plural date element functions used with Date (eg. day(), days(), months()). var ef = function (j) { return function () { // if the .second() function was called earlier, the _orient // has alread been added. Just return this and reset _isSecond. if (this._isSecond) { this._isSecond = false; return this; } if (this._same) { this._same = this._is = false; var o1 = this.toObject(), o2 = (arguments[0] || new Date()).toObject(), v = "", k = j.toLowerCase(); // the substr trick with -1 doesn't work in IE8 or less k = (k[k.length-1] === "s") ? k.substring(0,k.length-1) : k; for (var m = (px.length - 1); m > -1; m--) { v = px[m].toLowerCase(); if (o1[v] !== o2[v]) { return false; } if (k === v) { break; } } return true; } if (j.substring(j.length - 1) !== "s") { j += "s"; } if (this._move) { this._move = null; } return this["add" + j](this._orient); }; }; var nf = function (n) { return function () { this._dateElement = n; return this; }; }; for (var k = 0; k < px.length; k++) { de = px[k].toLowerCase(); if(de !== "weekday") { // Create date element functions and plural date element functions used with Date (eg. day(), days(), months()). $P[de] = $P[de + "s"] = ef(px[k]); // Create date element functions and plural date element functions used with Number (eg. day(), days(), months()). $N[de] = $N[de + "s"] = nf(de + "s"); } } $P._ss = ef("Second"); var nthfn = function (n) { return function (dayOfWeek) { if (this._same) { return this._ss(arguments[0]); } if (dayOfWeek || dayOfWeek === 0) { return this.moveToNthOccurrence(dayOfWeek, n); } this._nth = n; // if the operator is 'second' add the _orient, then deal with it later... if (n === 2 && (dayOfWeek === undefined || dayOfWeek === null)) { this._isSecond = true; return this.addSeconds(this._orient); } return this; }; }; for (var l = 0; l < nth.length; l++) { $P[nth[l]] = (l === 0) ? nthfn(-1) : nthfn(l); } }()); (function () { "use strict"; Date.Parsing = { Exception: function (s) { this.message = "Parse error at '" + s.substring(0, 10) + " ...'"; } }; var $P = Date.Parsing; var dayOffsets = { standard: [0,31,59,90,120,151,181,212,243,273,304,334], leap: [0,31,60,91,121,152,182,213,244,274,305,335] }; $P.isLeapYear = function(year) { return ((year % 4 === 0) && (year % 100 !== 0)) || (year % 400 === 0); }; var utils = { multiReplace : function (str, hash ) { var key; for (key in hash) { if (Object.prototype.hasOwnProperty.call(hash, key)) { var regex; if (typeof hash[key] === "function") { } else { regex = (hash[key] instanceof RegExp) ? hash[key] : new RegExp(hash[key], "g"); } str = str.replace(regex, key); } } return str; }, getDayOfYearFromWeek : function (obj) { var d, jan4, offset; obj.weekDay = (!obj.weekDay && obj.weekDay !== 0) ? 1 : obj.weekDay; d = new Date(obj.year, 0, 4); jan4 = d.getDay() === 0 ? 7 : d.getDay(); // JS is 0 indexed on Sunday. offset = jan4+3; obj.dayOfYear = ((obj.week * 7) + (obj.weekDay === 0 ? 7 : obj.weekDay))-offset; return obj; }, getDayOfYear : function (obj, dayOffset) { if (!obj.dayOfYear) { obj = utils.getDayOfYearFromWeek(obj); } for (var i=0;i <= dayOffset.length;i++) { if (obj.dayOfYear < dayOffset[i] || i === dayOffset.length) { obj.day = obj.day ? obj.day : (obj.dayOfYear - dayOffset[i-1]); break; } else { obj.month = i; } } return obj; }, adjustForTimeZone : function (obj, date) { var offset; if (obj.zone.toUpperCase() === "Z" || (obj.zone_hours === 0 && obj.zone_minutes === 0)) { // it's UTC/GML so work out the current timeszone offset offset = -date.getTimezoneOffset(); } else { offset = (obj.zone_hours*60) + (obj.zone_minutes || 0); if (obj.zone_sign === "+") { offset *= -1; } offset -= date.getTimezoneOffset(); } date.setMinutes(date.getMinutes()+offset); return date; }, setDefaults : function (obj) { obj.year = obj.year || Date.today().getFullYear(); obj.hours = obj.hours || 0; obj.minutes = obj.minutes || 0; obj.seconds = obj.seconds || 0; obj.milliseconds = obj.milliseconds || 0; if (!(!obj.month && (obj.week || obj.dayOfYear))) { // if we have a month, or if we don't but don't have the day calculation data obj.month = obj.month || 0; obj.day = obj.day || 1; } return obj; }, dataNum: function (data, mod, explict, postProcess) { var dataNum = data*1; if (mod) { if (postProcess) { return data ? mod(data)*1 : data; } else { return data ? mod(dataNum) : data; } } else if (!explict){ return data ? dataNum : data; } else { return (data && typeof data !== "undefined") ? dataNum : data; } }, timeDataProcess: function (obj) { var timeObj = {}; for (var x in obj.data) { if (obj.data.hasOwnProperty(x)) { timeObj[x] = obj.ignore[x] ? obj.data[x] : utils.dataNum(obj.data[x], obj.mods[x], obj.explict[x], obj.postProcess[x]); } } if (obj.data.secmins) { obj.data.secmins = obj.data.secmins.replace(",", ".") * 60; if (!timeObj.minutes) { timeObj.minutes = obj.data.secmins; } else if (!timeObj.seconds) { timeObj.seconds = obj.data.secmins; } delete obj.secmins; } return timeObj; }, buildTimeObjectFromData: function (data) { var time = utils.timeDataProcess({ data: { year : data[1], month : data[5], day : data[7], week : data[8], dayOfYear : data[10], hours : data[15], zone_hours : data[23], zone_minutes : data[24], zone : data[21], zone_sign : data[22], weekDay : data[9], minutes: data[16], seconds: data[19], milliseconds: data[20], secmins: data[18] }, mods: { month: function(data) { return data-1; }, weekDay: function (data) { data = Math.abs(data); return (data === 7 ? 0 : data); }, minutes: function (data) { return data.replace(":",""); }, seconds: function (data) { return Math.floor( (data.replace(":","").replace(",","."))*1 ); }, milliseconds: function (data) { return (data.replace(",",".")*1000); } }, postProcess: { minutes: true, seconds: true, milliseconds: true }, explict: { zone_hours: true, zone_minutes: true }, ignore: { zone: true, zone_sign: true, secmins: true } }); return time; }, addToHash: function (hash, keys, data) { keys = keys; data = data; var len = keys.length; for (var i = 0; i < len; i++) { hash[keys[i]] = data[i]; } return hash; }, combineRegex: function (r1, r2) { return new RegExp("(("+r1.source+")\\s("+r2.source+"))"); }, getDateNthString: function(add, last, inc){ if (add) { return Date.today().addDays(inc).toString("d"); } else if (last) { return Date.today().last()[inc]().toString("d"); } }, buildRegexData: function (array) { var arr = []; var len = array.length; for (var i=0; i < len; i++) { if (Object.prototype.toString.call(array[i]) === '[object Array]') { // oldIE compat version of Array.isArray arr.push(this.combineRegex(array[i][0], array[i][1])); } else { arr.push(array[i]); } } return arr; } }; $P.processTimeObject = function (obj) { var date, dayOffset; utils.setDefaults(obj); dayOffset = ($P.isLeapYear(obj.year)) ? dayOffsets.leap : dayOffsets.standard; if (!obj.month && (obj.week || obj.dayOfYear)) { utils.getDayOfYear(obj, dayOffset); } else { obj.dayOfYear = dayOffset[obj.month] + obj.day; } date = new Date(obj.year, obj.month, obj.day, obj.hours, obj.minutes, obj.seconds, obj.milliseconds); if (obj.zone) { utils.adjustForTimeZone(obj, date); // adjust (and calculate) for timezone } return date; }; $P.ISO = { regex : /^([\+-]?\d{4}(?!\d{2}\b))((-?)((0[1-9]|1[0-2])(\3([12]\d|0[1-9]|3[01]))?|W([0-4]\d|5[0-3])(-?[1-7])?|(00[1-9]|0[1-9]\d|[12]\d{2}|3([0-5]\d|6[1-6])))([T\s]((([01]\d|2[0-4])((:?)[0-5]\d)?|24\:?00)([\.,]\d+(?!:))?)?(\17[0-5]\d([\.,]\d+)?)?\s?([zZ]|([\+-])([01]\d|2[0-3]):?([0-5]\d)?)?)?)?$/, parse : function (s) { var time, data = s.match(this.regex); if (!data || !data.length) { return null; } time = utils.buildTimeObjectFromData(data); if (!time.year || (!time.year && (!time.month && !time.day) && (!time.week && !time.dayOfYear)) ) { return null; } return $P.processTimeObject(time); } }; $P.Numeric = { isNumeric: function (e){return!isNaN(parseFloat(e))&&isFinite(e);}, regex: /\b([0-1]?[0-9])([0-3]?[0-9])([0-2]?[0-9]?[0-9][0-9])\b/i, parse: function (s) { var data, i, time = {}, order = Date.CultureInfo.dateElementOrder.split(""); if (!(this.isNumeric(s)) || // if it's non-numeric OR (s[0] === "+" && s[0] === "-")) { // It's an arithmatic string (eg +/-1000) return null; } if (s.length < 5 && s.indexOf(".") < 0 && s.indexOf("/") < 0) { // assume it's just a year. time.year = s; return $P.processTimeObject(time); } data = s.match(this.regex); if (!data || !data.length) { return null; } for (i=0; i < order.length; i++) { switch(order[i]) { case "d": time.day = data[i+1]; break; case "m": time.month = (data[i+1]-1); break; case "y": time.year = data[i+1]; break; } } return $P.processTimeObject(time); } }; $P.Normalizer = { regexData: function () { var $R = Date.CultureInfo.regexPatterns; return utils.buildRegexData([ $R.tomorrow, $R.yesterday, [$R.past, $R.mon], [$R.past, $R.tue], [$R.past, $R.wed], [$R.past, $R.thu], [$R.past, $R.fri], [$R.past, $R.sat], [$R.past, $R.sun] ]); }, basicReplaceHash : function() { var $R = Date.CultureInfo.regexPatterns; return { "January": $R.jan.source, "February": $R.feb, "March": $R.mar, "April": $R.apr, "May": $R.may, "June": $R.jun, "July": $R.jul, "August": $R.aug, "September": $R.sep, "October": $R.oct, "November": $R.nov, "December": $R.dec, "": /\bat\b/gi, " ": /\s{2,}/, "am": $R.inTheMorning, "9am": $R.thisMorning, "pm": $R.inTheEvening, "7pm":$R.thisEvening }; }, keys : function(){ return [ utils.getDateNthString(true, false, 1), // tomorrow utils.getDateNthString(true, false, -1), // yesterday utils.getDateNthString(false, true, "monday"), //last mon utils.getDateNthString(false, true, "tuesday"), //last tues utils.getDateNthString(false, true, "wednesday"), //last wed utils.getDateNthString(false, true, "thursday"), //last thurs utils.getDateNthString(false, true, "friday"), //last fri utils.getDateNthString(false, true, "saturday"), //last sat utils.getDateNthString(false, true, "sunday") //last sun ]; }, buildRegexFunctions: function () { var $R = Date.CultureInfo.regexPatterns; var __ = Date.i18n.__; var tomorrowRE = new RegExp("(\\b\\d\\d?("+__("AM")+"|"+__("PM")+")? )("+$R.tomorrow.source.slice(1)+")", "i"); // adapted tomorrow regex for AM PM relative dates var todayRE = new RegExp($R.today.source + "(?!\\s*([+-]))\\b"); // today, but excludes the math operators (eg "today + 2h") this.replaceFuncs = [ [todayRE, function (full) { return (full.length > 1) ? Date.today().toString("d") : full; }], [tomorrowRE, function(full, m1) { var t = Date.today().addDays(1).toString("d"); return (t + " " + m1); }], [$R.amThisMorning, function(str, am){return am;}], [$R.pmThisEvening, function(str, pm){return pm;}] ]; }, buildReplaceData: function () { this.buildRegexFunctions(); this.replaceHash = utils.addToHash(this.basicReplaceHash(), this.keys(), this.regexData()); }, stringReplaceFuncs: function (s) { for (var i=0; i < this.replaceFuncs.length; i++) { s = s.replace(this.replaceFuncs[i][0], this.replaceFuncs[i][1]); } return s; }, parse: function (s) { s = this.stringReplaceFuncs(s); s = utils.multiReplace(s, this.replaceHash); try { var n = s.split(/([\s\-\.\,\/\x27]+)/); if (n.length === 3 && $P.Numeric.isNumeric(n[0]) && $P.Numeric.isNumeric(n[2]) && (n[2].length >= 4)) { // ok, so we're dealing with x/year. But that's not a full date. // This fixes wonky dateElementOrder parsing when set to dmy order. if (Date.CultureInfo.dateElementOrder[0] === "d") { s = "1/" + n[0] + "/" + n[2]; // set to 1st of month and normalize the seperator } } } catch (e) {} return s; } }; $P.Normalizer.buildReplaceData(); }()); (function () { var $P = Date.Parsing; var _ = $P.Operators = { // // Tokenizers // rtoken: function (r) { // regex token return function (s) { var mx = s.match(r); if (mx) { return ([ mx[0], s.substring(mx[0].length) ]); } else { throw new $P.Exception(s); } }; }, token: function () { // whitespace-eating token return function (s) { return _.rtoken(new RegExp("^\\s*" + s + "\\s*"))(s); }; }, stoken: function (s) { // string token return _.rtoken(new RegExp("^" + s)); }, // Atomic Operators until: function (p) { return function (s) { var qx = [], rx = null; while (s.length) { try { rx = p.call(this, s); } catch (e) { qx.push(rx[0]); s = rx[1]; continue; } break; } return [ qx, s ]; }; }, many: function (p) { return function (s) { var rx = [], r = null; while (s.length) { try { r = p.call(this, s); } catch (e) { return [ rx, s ]; } rx.push(r[0]); s = r[1]; } return [ rx, s ]; }; }, // generator operators -- see below optional: function (p) { return function (s) { var r = null; try { r = p.call(this, s); } catch (e) { return [ null, s ]; } return [ r[0], r[1] ]; }; }, not: function (p) { return function (s) { try { p.call(this, s); } catch (e) { return [null, s]; } throw new $P.Exception(s); }; }, ignore: function (p) { return p ? function (s) { var r = null; r = p.call(this, s); return [null, r[1]]; } : null; }, product: function () { var px = arguments[0], qx = Array.prototype.slice.call(arguments, 1), rx = []; for (var i = 0 ; i < px.length ; i++) { rx.push(_.each(px[i], qx)); } return rx; }, cache: function (rule) { var cache = {}, cache_length = 0, cache_keys = [], CACHE_MAX = Date.Config.CACHE_MAX || 100000, r = null; var cacheCheck = function () { if (cache_length === CACHE_MAX) { // kill several keys, don't want to have to do this all the time... for (var i=0; i < 10; i++) { var key = cache_keys.shift(); if (key) { delete cache[key]; cache_length--; } } } }; return function (s) { cacheCheck(); try { r = cache[s] = (cache[s] || rule.call(this, s)); } catch (e) { r = cache[s] = e; } cache_length++; cache_keys.push(s); if (r instanceof $P.Exception) { throw r; } else { return r; } }; }, // vector operators -- see below any: function () { var px = arguments; return function (s) { var r = null; for (var i = 0; i < px.length; i++) { if (px[i] == null) { continue; } try { r = (px[i].call(this, s)); } catch (e) { r = null; } if (r) { return r; } } throw new $P.Exception(s); }; }, each: function () { var px = arguments; return function (s) { var rx = [], r = null; for (var i = 0; i < px.length ; i++) { if (px[i] == null) { continue; } try { r = (px[i].call(this, s)); } catch (e) { throw new $P.Exception(s); } rx.push(r[0]); s = r[1]; } return [ rx, s]; }; }, all: function () { var px = arguments, _ = _; return _.each(_.optional(px)); }, // delimited operators sequence: function (px, d, c) { d = d || _.rtoken(/^\s*/); c = c || null; if (px.length === 1) { return px[0]; } return function (s) { var r = null, q = null; var rx = []; for (var i = 0; i < px.length ; i++) { try { r = px[i].call(this, s); } catch (e) { break; } rx.push(r[0]); try { q = d.call(this, r[1]); } catch (ex) { q = null; break; } s = q[1]; } if (!r) { throw new $P.Exception(s); } if (q) { throw new $P.Exception(q[1]); } if (c) { try { r = c.call(this, r[1]); } catch (ey) { throw new $P.Exception(r[1]); } } return [ rx, (r?r[1]:s) ]; }; }, // // Composite Operators // between: function (d1, p, d2) { d2 = d2 || d1; var _fn = _.each(_.ignore(d1), p, _.ignore(d2)); return function (s) { var rx = _fn.call(this, s); return [[rx[0][0], r[0][2]], rx[1]]; }; }, list: function (p, d, c) { d = d || _.rtoken(/^\s*/); c = c || null; return (p instanceof Array ? _.each(_.product(p.slice(0, -1), _.ignore(d)), p.slice(-1), _.ignore(c)) : _.each(_.many(_.each(p, _.ignore(d))), px, _.ignore(c))); }, set: function (px, d, c) { d = d || _.rtoken(/^\s*/); c = c || null; return function (s) { // r is the current match, best the current 'best' match // which means it parsed the most amount of input var r = null, p = null, q = null, rx = null, best = [[], s], last = false; // go through the rules in the given set for (var i = 0; i < px.length ; i++) { // last is a flag indicating whether this must be the last element // if there is only 1 element, then it MUST be the last one q = null; p = null; r = null; last = (px.length === 1); // first, we try simply to match the current pattern // if not, try the next pattern try { r = px[i].call(this, s); } catch (e) { continue; } // since we are matching against a set of elements, the first // thing to do is to add r[0] to matched elements rx = [[r[0]], r[1]]; // if we matched and there is still input to parse and // we don't already know this is the last element, // we're going to next check for the delimiter ... // if there's none, or if there's no input left to parse // than this must be the last element after all ... if (r[1].length > 0 && ! last) { try { q = d.call(this, r[1]); } catch (ex) { last = true; } } else { last = true; } // if we parsed the delimiter and now there's no more input, // that means we shouldn't have parsed the delimiter at all // so don't update r and mark this as the last element ... if (!last && q[1].length === 0) { last = true; } // so, if this isn't the last element, we're going to see if // we can get any more matches from the remaining (unmatched) // elements ... if (!last) { // build a list of the remaining rules we can match against, // i.e., all but the one we just matched against var qx = []; for (var j = 0; j < px.length ; j++) { if (i !== j) { qx.push(px[j]); } } // now invoke recursively set with the remaining input // note that we don't include the closing delimiter ... // we'll check for that ourselves at the end p = _.set(qx, d).call(this, q[1]); // if we got a non-empty set as a result ... // (otw rx already contains everything we want to match) if (p[0].length > 0) { // update current result, which is stored in rx ... // basically, pick up the remaining text from p[1] // and concat the result from p[0] so that we don't // get endless nesting ... rx[0] = rx[0].concat(p[0]); rx[1] = p[1]; } } // at this point, rx either contains the last matched element // or the entire matched set that starts with this element. // now we just check to see if this variation is better than // our best so far, in terms of how much of the input is parsed if (rx[1].length < best[1].length) { best = rx; } // if we've parsed all the input, then we're finished if (best[1].length === 0) { break; } } // so now we've either gone through all the patterns trying them // as the initial match; or we found one that parsed the entire // input string ... // if best has no matches, just return empty set ... if (best[0].length === 0) { return best; } // if a closing delimiter is provided, then we have to check it also if (c) { // we try this even if there is no remaining input because the pattern // may well be optional or match empty input ... try { q = c.call(this, best[1]); } catch (ey) { throw new $P.Exception(best[1]); } // it parsed ... be sure to update the best match remaining input best[1] = q[1]; } // if we're here, either there was no closing delimiter or we parsed it // so now we have the best match; just return it! return best; }; }, forward: function (gr, fname) { return function (s) { return gr[fname].call(this, s); }; }, // // Translation Operators // replace: function (rule, repl) { return function (s) { var r = rule.call(this, s); return [repl, r[1]]; }; }, process: function (rule, fn) { return function (s) { var r = rule.call(this, s); return [fn.call(this, r[0]), r[1]]; }; }, min: function (min, rule) { return function (s) { var rx = rule.call(this, s); if (rx[0].length < min) { throw new $P.Exception(s); } return rx; }; } }; // Generator Operators And Vector Operators // Generators are operators that have a signature of F(R) => R, // taking a given rule and returning another rule, such as // ignore, which parses a given rule and throws away the result. // Vector operators are those that have a signature of F(R1,R2,...) => R, // take a list of rules and returning a new rule, such as each. // Generator operators are converted (via the following _generator // function) into functions that can also take a list or array of rules // and return an array of new rules as though the function had been // called on each rule in turn (which is what actually happens). // This allows generators to be used with vector operators more easily. // Example: // each(ignore(foo, bar)) instead of each(ignore(foo), ignore(bar)) // This also turns generators into vector operators, which allows // constructs like: // not(cache(foo, bar)) var _generator = function (op) { function gen() { var args = null, rx = [], px, i; if (arguments.length > 1) { args = Array.prototype.slice.call(arguments); } else if (arguments[0] instanceof Array) { args = arguments[0]; } if (args) { px = args.shift(); if (px.length > 0) { args.unshift(px[i]); rx.push(op.apply(null, args)); args.shift(); return rx; } } else { return op.apply(null, arguments); } } return gen; }; var gx = "optional not ignore cache".split(/\s/); for (var i = 0 ; i < gx.length ; i++) { _[gx[i]] = _generator(_[gx[i]]); } var _vector = function (op) { return function () { if (arguments[0] instanceof Array) { return op.apply(null, arguments[0]); } else { return op.apply(null, arguments); } }; }; var vx = "each any all".split(/\s/); for (var j = 0 ; j < vx.length ; j++) { _[vx[j]] = _vector(_[vx[j]]); } }()); (function () { var $D = Date; var flattenAndCompact = function (ax) { var rx = []; for (var i = 0; i < ax.length; i++) { if (ax[i] instanceof Array) { rx = rx.concat(flattenAndCompact(ax[i])); } else { if (ax[i]) { rx.push(ax[i]); } } } return rx; }; var parseMeridian = function () { if (this.meridian && (this.hour || this.hour === 0)) { if (this.meridian === "a" && this.hour > 11 && Date.Config.strict24hr){ throw "Invalid hour and meridian combination"; } else if (this.meridian === "p" && this.hour < 12 && Date.Config.strict24hr){ throw "Invalid hour and meridian combination"; } else if (this.meridian === "p" && this.hour < 12) { this.hour = this.hour + 12; } else if (this.meridian === "a" && this.hour === 12) { this.hour = 0; } } }; var setDefaults = function () { var now = new Date(); if ((this.hour || this.minute) && (!this.month && !this.year && !this.day)) { this.day = now.getDate(); } if (!this.year) { this.year = now.getFullYear(); } if (!this.month && this.month !== 0) { this.month = now.getMonth(); } if (!this.day) { this.day = 1; } if (!this.hour) { this.hour = 0; } if (!this.minute) { this.minute = 0; } if (!this.second) { this.second = 0; } if (!this.millisecond) { this.millisecond = 0; } }; var finishUtils = { getToday: function () { if (this.now || "hour minute second".indexOf(this.unit) !== -1) { return new Date(); } else { return $D.today(); } }, setDaysFromWeekday: function (today, orient){ var gap; orient = orient || 1; this.unit = "day"; gap = ($D.getDayNumberFromName(this.weekday) - today.getDay()); this.days = gap ? ((gap + (orient * 7)) % 7) : (orient * 7); return this; }, setMonthsFromMonth: function (today, orient) { var gap; orient = orient || 1; this.unit = "month"; gap = (this.month - today.getMonth()); this.months = gap ? ((gap + (orient * 12)) % 12) : (orient * 12); this.month = null; return this; }, setDMYFromWeekday: function () { var d = Date[this.weekday](); this.day = d.getDate(); if (!this.month) { this.month = d.getMonth(); } this.year = d.getFullYear(); return this; }, setUnitValue: function (orient) { if (!this.value && this.operator && this.operator !== null && this[this.unit + "s"] && this[this.unit + "s"] !== null) { this[this.unit + "s"] = this[this.unit + "s"] + ((this.operator === "add") ? 1 : -1) + (this.value||0) * orient; } else if (this[this.unit + "s"] == null || this.operator != null) { if (!this.value) { this.value = 1; } this[this.unit + "s"] = this.value * orient; } }, generateDateFromWeeks: function () { var weekday = (this.weekday !== undefined) ? this.weekday : "today"; var d = Date[weekday]().addWeeks(this.weeks); if (this.now) { d.setTimeToNow(); } return d; } }; $D.Translator = { hour: function (s) { return function () { this.hour = Number(s); }; }, minute: function (s) { return function () { this.minute = Number(s); }; }, second: function (s) { return function () { this.second = Number(s); }; }, /* for ss.s format */ secondAndMillisecond: function (s) { return function () { var mx = s.match(/^([0-5][0-9])\.([0-9]{1,3})/); this.second = Number(mx[1]); this.millisecond = Number(mx[2]); }; }, meridian: function (s) { return function () { this.meridian = s.slice(0, 1).toLowerCase(); }; }, timezone: function (s) { return function () { var n = s.replace(/[^\d\+\-]/g, ""); if (n.length) { this.timezoneOffset = Number(n); } else { this.timezone = s.toLowerCase(); } }; }, day: function (x) { var s = x[0]; return function () { this.day = Number(s.match(/\d+/)[0]); if (this.day < 1) { throw "invalid day"; } }; }, month: function (s) { return function () { this.month = (s.length === 3) ? "jan feb mar apr may jun jul aug sep oct nov dec".indexOf(s)/4 : Number(s) - 1; if (this.month < 0) { throw "invalid month"; } }; }, year: function (s) { return function () { var n = Number(s); this.year = ((s.length > 2) ? n : (n + (((n + 2000) < Date.CultureInfo.twoDigitYearMax) ? 2000 : 1900))); }; }, rday: function (s) { return function () { switch (s) { case "yesterday": this.days = -1; break; case "tomorrow": this.days = 1; break; case "today": this.days = 0; break; case "now": this.days = 0; this.now = true; break; } }; }, finishExact: function (x) { var d; x = (x instanceof Array) ? x : [x]; for (var i = 0 ; i < x.length ; i++) { if (x[i]) { x[i].call(this); } } setDefaults.call(this); parseMeridian.call(this); if (this.day > $D.getDaysInMonth(this.year, this.month)) { throw new RangeError(this.day + " is not a valid value for days."); } d = new Date(this.year, this.month, this.day, this.hour, this.minute, this.second, this.millisecond); if (this.year < 100) { d.setFullYear(this.year); // means years less that 100 are process correctly. JS will parse it otherwise as 1900-1999. } if (this.timezone) { d.set({ timezone: this.timezone }); } else if (this.timezoneOffset) { d.set({ timezoneOffset: this.timezoneOffset }); } return d; }, finish: function (x) { var today, expression, orient, temp; x = (x instanceof Array) ? flattenAndCompact(x) : [ x ]; if (x.length === 0) { return null; } for (var i = 0 ; i < x.length ; i++) { if (typeof x[i] === "function") { x[i].call(this); } } if (this.now && !this.unit && !this.operator) { return new Date(); } else { today = finishUtils.getToday.call(this); } expression = !!(this.days && this.days !== null || this.orient || this.operator); orient = ((this.orient === "past" || this.operator === "subtract") ? -1 : 1); if (this.month && this.unit === "week") { this.value = this.month + 1; delete this.month; delete this.day; } if ((this.month || this.month === 0) && "year day hour minute second".indexOf(this.unit) !== -1) { if (!this.value) { this.value = this.month + 1; } this.month = null; expression = true; } if (!expression && this.weekday && !this.day && !this.days) { finishUtils.setDMYFromWeekday.call(this); } if (expression && this.weekday && this.unit !== "month" && this.unit !== "week") { finishUtils.setDaysFromWeekday.call(this, today, orient); } if (this.weekday && this.unit !== "week" && !this.day && !this.days) { temp = Date[this.weekday](); this.day = temp.getDate(); if (temp.getMonth() !== today.getMonth()) { this.month = temp.getMonth(); } } if (this.month && this.unit === "day" && this.operator) { if (!this.value) { this.value = (this.month + 1); } this.month = null; } if (this.value != null && this.month != null && this.year != null) { this.day = this.value * 1; } if (this.month && !this.day && this.value) { today.set({ day: this.value * 1 }); if (!expression) { this.day = this.value * 1; } } if (!this.month && this.value && this.unit === "month" && !this.now) { this.month = this.value; expression = true; } if (expression && (this.month || this.month === 0) && this.unit !== "year") { finishUtils.setMonthsFromMonth.call(this, today, orient); } if (!this.unit) { this.unit = "day"; } finishUtils.setUnitValue.call(this, orient); parseMeridian.call(this); if ((this.month || this.month === 0) && !this.day) { this.day = 1; } if (!this.orient && !this.operator && this.unit === "week" && this.value && !this.day && !this.month) { return Date.today().setWeek(this.value); } if (this.unit === "week" && this.weeks && !this.day && !this.month) { return finishUtils.generateDateFromWeeks.call(this); } if (expression && this.timezone && this.day && this.days) { this.day = this.days; } if (expression){ today.add(this); } else { today.set(this); } if (this.timezone) { this.timezone = this.timezone.toUpperCase(); var offset = $D.getTimezoneOffset(this.timezone); var timezone; if (today.hasDaylightSavingTime()) { // lets check that we're being sane with timezone setting timezone = $D.getTimezoneAbbreviation(offset, today.isDaylightSavingTime()); if (timezone !== this.timezone) { // bugger, we're in a place where things like EST vs EDT matters. if (today.isDaylightSavingTime()) { today.addHours(-1); } else { today.addHours(1); } } } today.setTimezoneOffset(offset); } return today; } }; }()); (function () { var $D = Date; $D.Grammar = {}; var _ = $D.Parsing.Operators, g = $D.Grammar, t = $D.Translator, _fn; // Allow rolling up into general purpose rules _fn = function () { return _.each(_.any.apply(null, arguments), _.not(g.ctoken2("timeContext"))); }; g.datePartDelimiter = _.rtoken(/^([\s\-\.\,\/\x27]+)/); g.timePartDelimiter = _.stoken(":"); g.whiteSpace = _.rtoken(/^\s*/); g.generalDelimiter = _.rtoken(/^(([\s\,]|at|@|on)+)/); var _C = {}; g.ctoken = function (keys) { var fn = _C[keys]; if (! fn) { var c = Date.CultureInfo.regexPatterns; var kx = keys.split(/\s+/), px = []; for (var i = 0; i < kx.length ; i++) { px.push(_.replace(_.rtoken(c[kx[i]]), kx[i])); } fn = _C[keys] = _.any.apply(null, px); } return fn; }; g.ctoken2 = function (key) { return _.rtoken(Date.CultureInfo.regexPatterns[key]); }; var cacheProcessRtoken = function (key, token, type, eachToken) { if (eachToken) { g[key] = _.cache(_.process(_.each(_.rtoken(token),_.optional(g.ctoken2(eachToken))), type)); } else { g[key] = _.cache(_.process(_.rtoken(token), type)); } }; var cacheProcessCtoken = function (token, type) { return _.cache(_.process(g.ctoken2(token), type)); }; var _F = {}; //function cache var _get = function (f) { _F[f] = (_F[f] || g.format(f)[0]); return _F[f]; }; g.allformats = function (fx) { var rx = []; if (fx instanceof Array) { for (var i = 0; i < fx.length; i++) { rx.push(_get(fx[i])); } } else { rx.push(_get(fx)); } return rx; }; g.formats = function (fx) { if (fx instanceof Array) { var rx = []; for (var i = 0 ; i < fx.length ; i++) { rx.push(_get(fx[i])); } return _.any.apply(null, rx); } else { return _get(fx); } }; var grammarFormats = { timeFormats: function(){ var i, RTokenKeys = [ "h", "hh", "H", "HH", "m", "mm", "s", "ss", "ss.s", "z", "zz" ], RToken = [ /^(0[0-9]|1[0-2]|[1-9])/, /^(0[0-9]|1[0-2])/, /^([0-1][0-9]|2[0-3]|[0-9])/, /^([0-1][0-9]|2[0-3])/, /^([0-5][0-9]|[0-9])/, /^[0-5][0-9]/, /^([0-5][0-9]|[0-9])/, /^[0-5][0-9]/, /^[0-5][0-9]\.[0-9]{1,3}/, /^((\+|\-)\s*\d\d\d\d)|((\+|\-)\d\d\:?\d\d)/, /^((\+|\-)\s*\d\d\d\d)|((\+|\-)\d\d\:?\d\d)/ ], tokens = [ t.hour, t.hour, t.hour, t.hour, t.minute, t.minute, t.second, t.second, t.secondAndMillisecond, t.timezone, t.timezone ]; for (i=0; i < RTokenKeys.length; i++) { cacheProcessRtoken(RTokenKeys[i], RToken[i], tokens[i]); } g.hms = _.cache(_.sequence([g.H, g.m, g.s], g.timePartDelimiter)); g.t = cacheProcessCtoken("shortMeridian", t.meridian); g.tt = cacheProcessCtoken("longMeridian", t.meridian); g.zzz = cacheProcessCtoken("timezone", t.timezone); g.timeSuffix = _.each(_.ignore(g.whiteSpace), _.set([ g.tt, g.zzz ])); g.time = _.each(_.optional(_.ignore(_.stoken("T"))), g.hms, g.timeSuffix); }, dateFormats: function () { // pre-loaded rules for different date part order preferences var _setfn = function () { return _.set(arguments, g.datePartDelimiter); }; var i, RTokenKeys = [ "d", "dd", "M", "MM", "y", "yy", "yyy", "yyyy" ], RToken = [ /^([0-2]\d|3[0-1]|\d)/, /^([0-2]\d|3[0-1])/, /^(1[0-2]|0\d|\d)/, /^(1[0-2]|0\d)/, /^(\d+)/, /^(\d\d)/, /^(\d\d?\d?\d?)/, /^(\d\d\d\d)/ ], tokens = [ t.day, t.day, t.month, t.month, t.year, t.year, t.year, t.year ], eachToken = [ "ordinalSuffix", "ordinalSuffix" ]; for (i=0; i < RTokenKeys.length; i++) { cacheProcessRtoken(RTokenKeys[i], RToken[i], tokens[i], eachToken[i]); } g.MMM = g.MMMM = _.cache(_.process(g.ctoken("jan feb mar apr may jun jul aug sep oct nov dec"), t.month)); g.ddd = g.dddd = _.cache(_.process(g.ctoken("sun mon tue wed thu fri sat"), function (s) { return function () { this.weekday = s; }; } )); g.day = _fn(g.d, g.dd); g.month = _fn(g.M, g.MMM); g.year = _fn(g.yyyy, g.yy); g.mdy = _setfn(g.ddd, g.month, g.day, g.year); g.ymd = _setfn(g.ddd, g.year, g.month, g.day); g.dmy = _setfn(g.ddd, g.day, g.month, g.year); g.date = function (s) { return ((g[Date.CultureInfo.dateElementOrder] || g.mdy).call(this, s)); }; }, relative: function () { // relative date / time expressions g.orientation = _.process(g.ctoken("past future"), function (s) { return function () { this.orient = s; }; } ); g.operator = _.process(g.ctoken("add subtract"), function (s) { return function () { this.operator = s; }; } ); g.rday = _.process(g.ctoken("yesterday tomorrow today now"), t.rday); g.unit = _.process(g.ctoken("second minute hour day week month year"), function (s) { return function () { this.unit = s; }; } ); } }; g.buildGrammarFormats = function () { // these need to be rebuilt every time the language changes. _C = {}; grammarFormats.timeFormats(); grammarFormats.dateFormats(); grammarFormats.relative(); g.value = _.process(_.rtoken(/^([-+]?\d+)?(st|nd|rd|th)?/), function (s) { return function () { this.value = s.replace(/\D/g, ""); }; } ); g.expression = _.set([g.rday, g.operator, g.value, g.unit, g.orientation, g.ddd, g.MMM ]); g.format = _.process(_.many( _.any( // translate format specifiers into grammar rules _.process( _.rtoken(/^(dd?d?d?(?!e)|MM?M?M?|yy?y?y?|hh?|HH?|mm?|ss?|tt?|zz?z?)/), function (fmt) { if (g[fmt]) { return g[fmt]; } else { throw $D.Parsing.Exception(fmt); } } ), // translate separator tokens into token rules _.process(_.rtoken(/^[^dMyhHmstz]+/), // all legal separators function (s) { return _.ignore(_.stoken(s)); } ) ) ), // construct the parser ... function (rules) { return _.process(_.each.apply(null, rules), t.finishExact); } ); // starting rule for general purpose grammar g._start = _.process(_.set([ g.date, g.time, g.expression ], g.generalDelimiter, g.whiteSpace), t.finish); }; g.buildGrammarFormats(); // parsing date format specifiers - ex: "h:m:s tt" // this little guy will generate a custom parser based // on the format string, ex: g.format("h:m:s tt") // check for these formats first g._formats = g.formats([ "\"yyyy-MM-ddTHH:mm:ssZ\"", "yyyy-MM-ddTHH:mm:ss.sz", "yyyy-MM-ddTHH:mm:ssZ", "yyyy-MM-ddTHH:mm:ssz", "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-ddTHH:mmZ", "yyyy-MM-ddTHH:mmz", "yyyy-MM-ddTHH:mm", "ddd, MMM dd, yyyy H:mm:ss tt", "ddd MMM d yyyy HH:mm:ss zzz", "MMddyyyy", "ddMMyyyy", "Mddyyyy", "ddMyyyy", "Mdyyyy", "dMyyyy", "yyyy", "Mdyy", "dMyy", "d" ]); // real starting rule: tries selected formats first, // then general purpose rule g.start = function (s) { try { var r = g._formats.call({}, s); if (r[1].length === 0) { return r; } } catch (e) {} return g._start.call({}, s); }; }()); (function () { var $D = Date; /** * @desc Converts the specified string value into its JavaScript Date equivalent using CultureInfo specific format information. * * Example

	///////////
	// Dates //
	///////////

	// 15-Oct-2004
	var d1 = Date.parse("10/15/2004");

	// 15-Oct-2004
	var d1 = Date.parse("15-Oct-2004");

	// 15-Oct-2004
	var d1 = Date.parse("2004.10.15");

	//Fri Oct 15, 2004
	var d1 = Date.parse("Fri Oct 15, 2004");

	///////////
	// Times //
	///////////

	// Today at 10 PM.
	var d1 = Date.parse("10 PM");

	// Today at 10:30 PM.
	var d1 = Date.parse("10:30 P.M.");

	// Today at 6 AM.
	var d1 = Date.parse("06am");

	/////////////////////
	// Dates and Times //
	/////////////////////

	// 8-July-2004 @ 10:30 PM
	var d1 = Date.parse("July 8th, 2004, 10:30 PM");

	// 1-July-2004 @ 10:30 PM
	var d1 = Date.parse("2004-07-01T22:30:00");

	////////////////////
	// Relative Dates //
	////////////////////

	// Returns today's date. The string "today" is culture specific.
	var d1 = Date.parse("today");

	// Returns yesterday's date. The string "yesterday" is culture specific.
	var d1 = Date.parse("yesterday");

	// Returns the date of the next thursday.
	var d1 = Date.parse("Next thursday");

	// Returns the date of the most previous monday.
	var d1 = Date.parse("last monday");

	// Returns today's day + one year.
	var d1 = Date.parse("next year");

	///////////////
	// Date Math //
	///////////////

	// Today + 2 days
	var d1 = Date.parse("t+2");

	// Today + 2 days
	var d1 = Date.parse("today + 2 days");

	// Today + 3 months
	var d1 = Date.parse("t+3m");

	// Today - 1 year
	var d1 = Date.parse("today - 1 year");

	// Today - 1 year
	var d1 = Date.parse("t-1y"); 


	/////////////////////////////
	// Partial Dates and Times //
	/////////////////////////////

	// July 15th of this year.
	var d1 = Date.parse("July 15");

	// 15th day of current day and year.
	var d1 = Date.parse("15");

	// July 1st of current year at 10pm.
	var d1 = Date.parse("7/1 10pm");
	
* * @param {String} The string value to convert into a Date object [Required] * @return {Date} A Date object or null if the string cannot be converted into a Date. */ var parseUtils = { removeOrds: function (s) { ords = s.match(/\b(\d+)(?:st|nd|rd|th)\b/); // find ordinal matches s = ((ords && ords.length === 2) ? s.replace(ords[0], ords[1]) : s); return s; }, grammarParser: function (s) { var r = null; try { r = $D.Grammar.start.call({}, s.replace(/^\s*(\S*(\s+\S+)*)\s*$/, "$1")); } catch (e) { return null; } return ((r[1].length === 0) ? r[0] : null); }, nativeFallback: function(s) { var t; try { // ok we haven't parsed it, last ditch attempt with the built-in parser. t = Date._parse(s); return (t || t === 0) ? new Date(t) : null; } catch (e) { return null; } } }; function parse (s) { var d; if (!s) { return null; } if (s instanceof Date) { return s.clone(); } if (s.length >= 4 && s.charAt(0) !== "0" && s.charAt(0) !== "+"&& s.charAt(0) !== "-") { // ie: 2004 will pass, 0800 won't. // Start with specific formats d = $D.Parsing.ISO.parse(s) || $D.Parsing.Numeric.parse(s); } if (d instanceof Date && !isNaN(d.getTime())) { return d; } else { // find ordinal dates (1st, 3rd, 8th, etc and remove them as they cause parsing issues) s = $D.Parsing.Normalizer.parse(parseUtils.removeOrds(s)); d = parseUtils.grammarParser(s); if (d !== null) { return d; } else { return parseUtils.nativeFallback(s); } } } if (!$D._parse) { $D._parse = $D.parse; } $D.parse = parse; Date.getParseFunction = function (fx) { var fns = Date.Grammar.allformats(fx); return function (s) { var r = null; for (var i = 0; i < fns.length; i++) { try { r = fns[i].call({}, s); } catch (e) { continue; } if (r[1].length === 0) { return r[0]; } } return null; }; }; /** * Converts the specified string value into its JavaScript Date equivalent using the specified format {String} or formats {Array} and the CultureInfo specific format information. * The format of the string value must match one of the supplied formats exactly. * * Example

	// 15-Oct-2004
	var d1 = Date.parseExact("10/15/2004", "M/d/yyyy");

	// 15-Oct-2004
	var d1 = Date.parse("15-Oct-2004", "M-ddd-yyyy");

	// 15-Oct-2004
	var d1 = Date.parse("2004.10.15", "yyyy.MM.dd");

	// Multiple formats
	var d1 = Date.parseExact("10/15/2004", ["M/d/yyyy", "MMMM d, yyyy"]);
	
* * @param {String} The string value to convert into a Date object [Required]. * @param {Object} The expected format {String} or an array of expected formats {Array} of the date string [Required]. * @return {Date} A Date object or null if the string cannot be converted into a Date. */ $D.parseExact = function (s, fx) { return $D.getParseFunction(fx)(s); }; }()); (function () { var $D = Date, $P = $D.prototype, // $C = $D.CultureInfo, // not used atm p = function (s, l) { if (!l) { l = 2; } return ("000" + s).slice(l * -1); }; /** * Converts a PHP format string to Java/.NET format string. * A PHP format string can be used with ._format or .format. * A Java/.NET format string can be used with .toString(). * The .parseExact function will only accept a Java/.NET format string * * Example * var f1 = "%m/%d/%y" * var f2 = Date.normalizeFormat(f1); // "MM/dd/yy" * * new Date().format(f1); // "04/13/08" * new Date()._format(f1); // "04/13/08" * new Date().toString(f2); // "04/13/08" * * var date = Date.parseExact("04/13/08", f2); // Sun Apr 13 2008 * * @param {String} A PHP format string consisting of one or more format spcifiers. * @return {String} The PHP format converted to a Java/.NET format string. */ var normalizerSubstitutions = { "d" : "dd", "%d": "dd", "D" : "ddd", "%a": "ddd", "j" : "dddd", "l" : "dddd", "%A": "dddd", "S" : "S", "F" : "MMMM", "%B": "MMMM", "m" : "MM", "%m": "MM", "M" : "MMM", "%b": "MMM", "%h": "MMM", "n" : "M", "Y" : "yyyy", "%Y": "yyyy", "y" : "yy", "%y": "yy", "g" : "h", "%I": "h", "G" : "H", "h" : "hh", "H" : "HH", "%H": "HH", "i" : "mm", "%M": "mm", "s" : "ss", "%S": "ss", "%r": "hh:mm tt", "%R": "H:mm", "%T": "H:mm:ss", "%X": "t", "%x": "d", "%e": "d", "%D": "MM/dd/yy", "%n": "\\n", "%t": "\\t", "e" : "z", "T" : "z", "%z": "z", "%Z": "z", "Z" : "ZZ", "N" : "u", "w" : "u", "%w": "u", "W" : "W", "%V": "W" }; var normalizer = { substitutes: function (m) { return normalizerSubstitutions[m]; }, interpreted: function (m, x) { var y; switch (m) { case "%u": return x.getDay() + 1; case "z": return x.getOrdinalNumber(); case "%j": return p(x.getOrdinalNumber(), 3); case "%U": var d1 = x.clone().set({month: 0, day: 1}).addDays(-1).moveToDayOfWeek(0), d2 = x.clone().addDays(1).moveToDayOfWeek(0, -1); return (d2 < d1) ? "00" : p((d2.getOrdinalNumber() - d1.getOrdinalNumber()) / 7 + 1); case "%W": return p(x.getWeek()); case "t": return $D.getDaysInMonth(x.getFullYear(), x.getMonth()); case "o": case "%G": return x.setWeek(x.getISOWeek()).toString("yyyy"); case "%g": return x._format("%G").slice(-2); case "a": case "%p": return t("tt").toLowerCase(); case "A": return t("tt").toUpperCase(); case "u": return p(x.getMilliseconds(), 3); case "I": return (x.isDaylightSavingTime()) ? 1 : 0; case "O": return x.getUTCOffset(); case "P": y = x.getUTCOffset(); return y.substring(0, y.length - 2) + ":" + y.substring(y.length - 2); case "B": var now = new Date(); return Math.floor(((now.getHours() * 3600) + (now.getMinutes() * 60) + now.getSeconds() + (now.getTimezoneOffset() + 60) * 60) / 86.4); case "c": return x.toISOString().replace(/\"/g, ""); case "U": return $D.strtotime("now"); case "%c": return t("d") + " " + t("t"); case "%C": return Math.floor(x.getFullYear() / 100 + 1); } }, shouldOverrideDefaults: function (m) { switch (m) { case "%e": return true; default: return false; } }, parse: function (m, context) { var formatString, c = context || new Date(); formatString = normalizer.substitutes(m); if (formatString) { return formatString; } formatString = normalizer.interpreted(m, c); if (formatString) { return formatString; } else { return m; } } }; $D.normalizeFormat = function (format, context) { return format.replace(/(%|\\)?.|%%/g, function(t){ return normalizer.parse(t, context); }); }; /** * Format a local Unix timestamp according to locale settings * * Example: * Date.strftime("%m/%d/%y", new Date()); // "04/13/08" * Date.strftime("c", "2008-04-13T17:52:03Z"); // "04/13/08" * * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @param {Number|String} The number representing the number of seconds that have elapsed since January 1, 1970 (local time). * @return {String} A string representation of the current Date object. */ $D.strftime = function (format, time) { var d = Date.parse(time); return d._format(format); }; /** * Parse any textual datetime description into a Unix timestamp. * A Unix timestamp is the number of seconds that have elapsed since January 1, 1970 (midnight UTC/GMT). * * Example: * Date.strtotime("04/13/08"); // 1208044800 * Date.strtotime("1970-01-01T00:00:00Z"); // 0 * * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @param {Object} A string or date object. * @return {String} A string representation of the current Date object. */ $D.strtotime = function (time) { var d = $D.parse(time); return Math.round($D.UTC(d.getUTCFullYear(), d.getUTCMonth(), d.getUTCDate(), d.getUTCHours(), d.getUTCMinutes(), d.getUTCSeconds(), d.getUTCMilliseconds()) / 1000); }; /** * Converts the value of the current Date object to its equivalent string representation using a PHP/Unix style of date format specifiers. * Format Specifiers * Format Description Example * ------ --------------------------------------------------------------------------- ----------------------- * %a abbreviated weekday name according to the current localed "Mon" through "Sun" * %A full weekday name according to the current localed "Sunday" through "Saturday" * %b abbreviated month name according to the current localed "Jan" through "Dec" * %B full month name according to the current locale "January" through "December" * %c preferred date and time representation for the current locale "4/13/2008 12:33 PM" * %C century number (the year divided by 100 and truncated to an integer) "00" to "99" * %d day of the month as a decimal number "01" to "31" * %D same as %m/%d/%y "04/13/08" * %e day of the month as a decimal number, a single digit is preceded by a space "1" to "31" * %g like %G, but without the century "08" * %G The 4-digit year corresponding to the ISO week number (see %V). "2008" * This has the same format and value as %Y, except that if the ISO week number * belongs to the previous or next year, that year is used instead. * %h same as %b "Jan" through "Dec" * %H hour as a decimal number using a 24-hour clock. "00" to "23" * %I hour as a decimal number using a 12-hour clock. "01" to "12" * %j day of the year as a decimal number. "001" to "366" * %m month as a decimal number. "01" to "12" * %M minute as a decimal number. "00" to "59" * %n newline character "\n" * %p either "am" or "pm" according to the given time value, or the "am" or "pm" * corresponding strings for the current locale. * %r time in a.m. and p.m. notation "8:44 PM" * %R time in 24 hour notation "20:44" * %S second as a decimal number "00" to "59" * %t tab character "\t" * %T current time, equal to %H:%M:%S "12:49:11" * %u weekday as a decimal number ["1", "7"], with "1" representing Monday "1" to "7" * %U week number of the current year as a decimal number, starting with the "0" to ("52" or "53") * first Sunday as the first day of the first week * %V The ISO 8601:1988 week number of the current year as a decimal number, "00" to ("52" or "53") * range 01 to 53, where week 1 is the first week that has at least 4 days * in the current year, and with Monday as the first day of the week. * (Use %G or %g for the year component that corresponds to the week number * for the specified timestamp.) * %W week number of the current year as a decimal number, starting with the "00" to ("52" or "53") * first Monday as the first day of the first week * %w day of the week as a decimal, Sunday being "0" "0" to "6" * %x preferred date representation for the current locale without the time "4/13/2008" * %X preferred time representation for the current locale without the date "12:53:05" * %y year as a decimal number without a century "00" "99" * %Y year as a decimal number including the century "2008" * %Z time zone or name or abbreviation "UTC", "EST", "PST" * %z same as %Z * %% a literal "%" characters "%" * d Day of the month, 2 digits with leading zeros "01" to "31" * D A textual representation of a day, three letters "Mon" through "Sun" * j Day of the month without leading zeros "1" to "31" * l A full textual representation of the day of the week (lowercase "L") "Sunday" through "Saturday" * N ISO-8601 numeric representation of the day of the week (added in PHP 5.1.0) "1" (for Monday) through "7" (for Sunday) * S English ordinal suffix for the day of the month, 2 characters "st", "nd", "rd" or "th". Works well with j * w Numeric representation of the day of the week "0" (for Sunday) through "6" (for Saturday) * z The day of the year (starting from "0") "0" through "365" * W ISO-8601 week number of year, weeks starting on Monday "00" to ("52" or "53") * F A full textual representation of a month, such as January or March "January" through "December" * m Numeric representation of a month, with leading zeros "01" through "12" * M A short textual representation of a month, three letters "Jan" through "Dec" * n Numeric representation of a month, without leading zeros "1" through "12" * t Number of days in the given month "28" through "31" * L Whether it's a leap year "1" if it is a leap year, "0" otherwise * o ISO-8601 year number. This has the same value as Y, except that if the "2008" * ISO week number (W) belongs to the previous or next year, that year * is used instead. * Y A full numeric representation of a year, 4 digits "2008" * y A two digit representation of a year "08" * a Lowercase Ante meridiem and Post meridiem "am" or "pm" * A Uppercase Ante meridiem and Post meridiem "AM" or "PM" * B Swatch Internet time "000" through "999" * g 12-hour format of an hour without leading zeros "1" through "12" * G 24-hour format of an hour without leading zeros "0" through "23" * h 12-hour format of an hour with leading zeros "01" through "12" * H 24-hour format of an hour with leading zeros "00" through "23" * i Minutes with leading zeros "00" to "59" * s Seconds, with leading zeros "00" through "59" * u Milliseconds "54321" * e Timezone identifier "UTC", "EST", "PST" * I Whether or not the date is in daylight saving time (uppercase i) "1" if Daylight Saving Time, "0" otherwise * O Difference to Greenwich time (GMT) in hours "+0200", "-0600" * P Difference to Greenwich time (GMT) with colon between hours and minutes "+02:00", "-06:00" * T Timezone abbreviation "UTC", "EST", "PST" * Z Timezone offset in seconds. The offset for timezones west of UTC is "-43200" through "50400" * always negative, and for those east of UTC is always positive. * c ISO 8601 date "2004-02-12T15:19:21+00:00" * r RFC 2822 formatted date "Thu, 21 Dec 2000 16:01:07 +0200" * U Seconds since the Unix Epoch (January 1 1970 00:00:00 GMT) "0" * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @return {String} A string representation of the current Date object. */ var formatReplace = function (context) { return function (m) { var formatString, override = false; if (m.charAt(0) === "\\" || m.substring(0, 2) === "%%") { return m.replace("\\", "").replace("%%", "%"); } override = normalizer.shouldOverrideDefaults(m); formatString = $D.normalizeFormat(m, context); if (formatString) { return context.toString(formatString, override); } }; }; $P._format = function (format) { var formatter = formatReplace(this); if (!format) { return this._toString(); } else { return format.replace(/(%|\\)?.|%%/g, formatter); } }; if (!$P.format) { $P.format = $P._format; } }()); (function () { "use strict"; var gFn = function (attr) { return function () { return this[attr]; }; }; var sFn = function (attr) { return function (val) { this[attr] = val; return this; }; }; var attrs = ["years", "months", "days", "hours", "minutes", "seconds", "milliseconds"]; var addSetFuncs = function (context, attrs) { for (var i = 0; i < attrs.length ; i++) { var $a = attrs[i], $b = $a.slice(0, 1).toUpperCase() + $a.slice(1); context.prototype[$a] = 0; context.prototype["get" + $b] = gFn($a); context.prototype["set" + $b] = sFn($a); } }; /** * new TimeSpan(milliseconds); * new TimeSpan(days, hours, minutes, seconds); * new TimeSpan(days, hours, minutes, seconds, milliseconds); */ var TimeSpan = function (days, hours, minutes, seconds, milliseconds) { if (arguments.length === 1 && typeof days === "number") { var orient = (days < 0) ? -1 : +1; var millsLeft = Math.abs(days); this.setDays(Math.floor(millsLeft / 86400000) * orient); millsLeft = millsLeft % 86400000; this.setHours(Math.floor(millsLeft / 3600000) * orient); millsLeft = millsLeft % 3600000; this.setMinutes(Math.floor(millsLeft / 60000) * orient); millsLeft = millsLeft % 60000; this.setSeconds(Math.floor(millsLeft / 1000) * orient); millsLeft = millsLeft % 1000; this.setMilliseconds(millsLeft * orient); } else { this.set(days, hours, minutes, seconds, milliseconds); } this.getTotalMilliseconds = function () { return (this.getDays() * 86400000) + (this.getHours() * 3600000) + (this.getMinutes() * 60000) + (this.getSeconds() * 1000); }; this.compareTo = function (time) { var t1 = new Date(1970, 1, 1, this.getHours(), this.getMinutes(), this.getSeconds()), t2; if (time === null) { t2 = new Date(1970, 1, 1, 0, 0, 0); } else { t2 = new Date(1970, 1, 1, time.getHours(), time.getMinutes(), time.getSeconds()); } return (t1 < t2) ? -1 : (t1 > t2) ? 1 : 0; }; this.equals = function (time) { return (this.compareTo(time) === 0); }; this.add = function (time) { return (time === null) ? this : this.addSeconds(time.getTotalMilliseconds() / 1000); }; this.subtract = function (time) { return (time === null) ? this : this.addSeconds(-time.getTotalMilliseconds() / 1000); }; this.addDays = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 86400000)); }; this.addHours = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 3600000)); }; this.addMinutes = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 60000)); }; this.addSeconds = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 1000)); }; this.addMilliseconds = function (n) { return new TimeSpan(this.getTotalMilliseconds() + n); }; this.get12HourHour = function () { return (this.getHours() > 12) ? this.getHours() - 12 : (this.getHours() === 0) ? 12 : this.getHours(); }; this.getDesignator = function () { return (this.getHours() < 12) ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator; }; this.toString = function (format) { this._toString = function () { if (this.getDays() !== null && this.getDays() > 0) { return this.getDays() + "." + this.getHours() + ":" + this.p(this.getMinutes()) + ":" + this.p(this.getSeconds()); } else { return this.getHours() + ":" + this.p(this.getMinutes()) + ":" + this.p(this.getSeconds()); } }; this.p = function (s) { return (s.toString().length < 2) ? "0" + s : s; }; var me = this; return format ? format.replace(/dd?|HH?|hh?|mm?|ss?|tt?/g, function (format) { switch (format) { case "d": return me.getDays(); case "dd": return me.p(me.getDays()); case "H": return me.getHours(); case "HH": return me.p(me.getHours()); case "h": return me.get12HourHour(); case "hh": return me.p(me.get12HourHour()); case "m": return me.getMinutes(); case "mm": return me.p(me.getMinutes()); case "s": return me.getSeconds(); case "ss": return me.p(me.getSeconds()); case "t": return ((me.getHours() < 12) ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator).substring(0, 1); case "tt": return (me.getHours() < 12) ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator; } } ) : this._toString(); }; return this; }; addSetFuncs(TimeSpan, attrs.slice(2)); TimeSpan.prototype.set = function (days, hours, minutes, seconds, milliseconds){ this.setDays(days || this.getDays()); this.setHours(hours || this.getHours()); this.setMinutes(minutes || this.getMinutes()); this.setSeconds(seconds || this.getSeconds()); this.setMilliseconds(milliseconds || this.getMilliseconds()); }; /** * Gets the time of day for this date instances. * @return {TimeSpan} TimeSpan */ Date.prototype.getTimeOfDay = function () { return new TimeSpan(0, this.getHours(), this.getMinutes(), this.getSeconds(), this.getMilliseconds()); }; Date.TimeSpan = TimeSpan; if (typeof window !== "undefined" ) { // keeping API compatible for v1.x window.TimeSpan = TimeSpan; } }()); (function () { "use strict"; var attrs = ["years", "months", "days", "hours", "minutes", "seconds", "milliseconds"]; var gFn = function (attr) { return function () { return this[attr]; }; }; var sFn = function (attr) { return function (val) { this[attr] = val; return this; }; }; var addSetFuncs = function (context, attrs) { for (var i = 0; i < attrs.length ; i++) { var $a = attrs[i], $b = $a.slice(0, 1).toUpperCase() + $a.slice(1); context.prototype[$a] = 0; context.prototype["get" + $b] = gFn($a); context.prototype["set" + $b] = sFn($a); } }; var setMonthsAndYears = function (orient, d1, d2, context) { function inc() { d1.addMonths(-orient); context.months++; if (context.months === 12) { context.years++; context.months = 0; } } if (orient === +1) { while (d1 > d2) { inc(); } } else { while (d1 < d2) { inc(); } } context.months--; context.months *= orient; context.years *= orient; }; var adjustForDST = function(orient, startDate, endDate) { var hasDSTMismatch = (false === (startDate.isDaylightSavingTime() === endDate.isDaylightSavingTime())); if (hasDSTMismatch && orient === 1) { startDate.addHours(-1); } else if (hasDSTMismatch) { startDate.addHours(1); } }; /** * TimePeriod(startDate, endDate); * TimePeriod(years, months, days, hours, minutes, seconds, milliseconds); */ var TimePeriod = function (years, months, days, hours, minutes, seconds, milliseconds) { if (arguments.length === 7) { this.set(years, months, days, hours, minutes, seconds, milliseconds); } else if (arguments.length === 2 && arguments[0] instanceof Date && arguments[1] instanceof Date) { var startDate = arguments[0].clone(); var endDate = arguments[1].clone(); var orient = (startDate > endDate) ? +1 : -1; this.dates = { start: arguments[0].clone(), end: arguments[1].clone() }; setMonthsAndYears(orient, startDate, endDate, this); adjustForDST(orient, startDate, endDate); // // TODO - adjust for DST var diff = endDate - startDate; if (diff !== 0) { var ts = new TimeSpan(diff); this.set(this.years, this.months, ts.getDays(), ts.getHours(), ts.getMinutes(), ts.getSeconds(), ts.getMilliseconds()); } } return this; }; // create all the set functions. addSetFuncs(TimePeriod, attrs); TimePeriod.prototype.set = function (years, months, days, hours, minutes, seconds, milliseconds){ this.setYears(years || this.getYears()); this.setMonths(months || this.getMonths()); this.setDays(days || this.getDays()); this.setHours(hours || this.getHours()); this.setMinutes(minutes || this.getMinutes()); this.setSeconds(seconds || this.getSeconds()); this.setMilliseconds(milliseconds || this.getMilliseconds()); }; Date.TimePeriod = TimePeriod; if (typeof window !== "undefined") { // keeping API compatible for v1.x window.TimePeriod = TimePeriod; } }()); ================================================ FILE: build/date-bg-BG.js ================================================ /** * @overview datejs * @version 1.0.0-rc3 * @author Gregory Wild-Smith * @copyright 2015 Gregory Wild-Smith * @license MIT * @homepage https://github.com/abritinthebay/datejs */ /* * DateJS Culture String File * Country Code: bg-BG * Name: Bulgarian (Bulgaria) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["bg-BG"] = { "name": "bg-BG", "englishName": "Bulgarian (Bulgaria)", "nativeName": "български (България)", "Sunday": "неделя", "Monday": "понеделник", "Tuesday": "вторник", "Wednesday": "сряда", "Thursday": "четвъртък", "Friday": "петък", "Saturday": "събота", "Sun": "Нд", "Mon": "Пн", "Tue": "Вт", "Wed": "Ср", "Thu": "Чт", "Fri": "Пт", "Sat": "Сб", "Su": "не", "Mo": "по", "Tu": "вт", "We": "ср", "Th": "че", "Fr": "пе", "Sa": "съ", "S_Sun_Initial": "н", "M_Mon_Initial": "п", "T_Tue_Initial": "в", "W_Wed_Initial": "с", "T_Thu_Initial": "ч", "F_Fri_Initial": "п", "S_Sat_Initial": "с", "January": "Януари", "February": "Февруари", "March": "Март", "April": "Април", "May": "Май", "June": "Юни", "July": "Юли", "August": "Август", "September": "Септември", "October": "Октомври", "November": "Ноември", "December": "Декември", "Jan_Abbr": "Януари", "Feb_Abbr": "Февруари", "Mar_Abbr": "Март", "Apr_Abbr": "Април", "May_Abbr": "Май", "Jun_Abbr": "Юни", "Jul_Abbr": "Юли", "Aug_Abbr": "Август", "Sep_Abbr": "Септември", "Oct_Abbr": "Октомври", "Nov_Abbr": "Ноември", "Dec_Abbr": "Декември", "AM": "", "PM": "", "firstDayOfWeek": 1, "twoDigitYearMax": 2029, "mdy": "dmy", "M/d/yyyy": "dd.M.yyyy 'г.'", "dddd, MMMM dd, yyyy": "dd MMMM yyyy 'г.'", "h:mm tt": "HH:mm", "h:mm:ss tt": "HH:mm:ss", "dddd, MMMM dd, yyyy h:mm:ss tt": "dd MMMM yyyy 'г.' HH:mm:ss", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "dd MMMM", "MMMM, yyyy": "MMMM yyyy 'г.'", "/jan(uary)?/": "януари", "/feb(ruary)?/": "февруари", "/mar(ch)?/": "март", "/apr(il)?/": "април", "/may/": "май", "/jun(e)?/": "юни", "/jul(y)?/": "юли", "/aug(ust)?/": "август", "/sep(t(ember)?)?/": "септември", "/oct(ober)?/": "октомври", "/nov(ember)?/": "ноември", "/dec(ember)?/": "декември", "/^su(n(day)?)?/": "^не((деля)?)?", "/^mo(n(day)?)?/": "^по((неделник)?)?", "/^tu(e(s(day)?)?)?/": "^вторник", "/^we(d(nesday)?)?/": "^сряда", "/^th(u(r(s(day)?)?)?)?/": "^че((твъртък)?)?", "/^fr(i(day)?)?/": "^пе((тък)?)?", "/^sa(t(urday)?)?/": "^съ((бота)?)?", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "bg-BG"; /** * @overview datejs * @version 1.0.0-rc3 * @author Gregory Wild-Smith * @copyright 2015 Gregory Wild-Smith * @license MIT * @homepage https://github.com/abritinthebay/datejs */(function () { var $D = Date; var lang = Date.CultureStrings ? Date.CultureStrings.lang : null; var loggedKeys = {}; // for debug purposes. var getText = { getFromKey: function (key, countryCode) { var output; if (Date.CultureStrings && Date.CultureStrings[countryCode] && Date.CultureStrings[countryCode][key]) { output = Date.CultureStrings[countryCode][key]; } else { output = getText.buildFromDefault(key); } if (key.charAt(0) === "/") { // Assume it's a regex output = getText.buildFromRegex(key, countryCode); } return output; }, getFromObjectValues: function (obj, countryCode) { var key, output = {}; for(key in obj) { if (obj.hasOwnProperty(key)) { output[key] = getText.getFromKey(obj[key], countryCode); } } return output; }, getFromObjectKeys: function (obj, countryCode) { var key, output = {}; for(key in obj) { if (obj.hasOwnProperty(key)) { output[getText.getFromKey(key, countryCode)] = obj[key]; } } return output; }, getFromArray: function (arr, countryCode) { var output = []; for (var i=0; i < arr.length; i++){ if (i in arr) { output[i] = getText.getFromKey(arr[i], countryCode); } } return output; }, buildFromDefault: function (key) { var output, length, split, last; switch(key) { case "name": output = "en-US"; break; case "englishName": output = "English (United States)"; break; case "nativeName": output = "English (United States)"; break; case "twoDigitYearMax": output = 2049; break; case "firstDayOfWeek": output = 0; break; default: output = key; split = key.split("_"); length = split.length; if (length > 1 && key.charAt(0) !== "/") { // if the key isn't a regex and it has a split. last = split[(length - 1)].toLowerCase(); if (last === "initial" || last === "abbr") { output = split[0]; } } break; } return output; }, buildFromRegex: function (key, countryCode) { var output; if (Date.CultureStrings && Date.CultureStrings[countryCode] && Date.CultureStrings[countryCode][key]) { output = new RegExp(Date.CultureStrings[countryCode][key], "i"); } else { output = new RegExp(key.replace(new RegExp("/", "g"),""), "i"); } return output; } }; var shallowMerge = function (obj1, obj2) { for (var attrname in obj2) { if (obj2.hasOwnProperty(attrname)) { obj1[attrname] = obj2[attrname]; } } }; var __ = function (key, language) { var countryCode = (language) ? language : lang; loggedKeys[key] = key; if (typeof key === "object") { if (key instanceof Array) { return getText.getFromArray(key, countryCode); } else { return getText.getFromObjectKeys(key, countryCode); } } else { return getText.getFromKey(key, countryCode); } }; var loadI18nScript = function (code) { // paatterned after jQuery's getScript. var url = Date.Config.i18n + code + ".js"; var head = document.getElementsByTagName("head")[0] || document.documentElement; var script = document.createElement("script"); script.src = url; var completed = false; var events = { done: function (){} // placeholder function }; // Attach handlers for all browsers script.onload = script.onreadystatechange = function() { if ( !completed && (!this.readyState || this.readyState === "loaded" || this.readyState === "complete") ) { events.done(); head.removeChild(script); } }; setTimeout(function() { head.insertBefore(script, head.firstChild); }, 0); // allows return to execute first return { done: function (cb) { events.done = function() { if (cb) { setTimeout(cb,0); } }; } }; }; var buildInfo = { buildFromMethodHash: function (obj) { var key; for(key in obj) { if (obj.hasOwnProperty(key)) { obj[key] = buildInfo[obj[key]](); } } return obj; }, timeZoneDST: function () { var DST = { "CHADT": "+1345", "NZDT": "+1300", "AEDT": "+1100", "ACDT": "+1030", "AZST": "+0500", "IRDT": "+0430", "EEST": "+0300", "CEST": "+0200", "BST": "+0100", "PMDT": "-0200", "ADT": "-0300", "NDT": "-0230", "EDT": "-0400", "CDT": "-0500", "MDT": "-0600", "PDT": "-0700", "AKDT": "-0800", "HADT": "-0900" }; return __(DST); }, timeZoneStandard: function () { var standard = { "LINT": "+1400", "TOT": "+1300", "CHAST": "+1245", "NZST": "+1200", "NFT": "+1130", "SBT": "+1100", "AEST": "+1000", "ACST": "+0930", "JST": "+0900", "CWST": "+0845", "CT": "+0800", "ICT": "+0700", "MMT": "+0630", "BST": "+0600", "NPT": "+0545", "IST": "+0530", "PKT": "+0500", "AFT": "+0430", "MSK": "+0400", "IRST": "+0330", "FET": "+0300", "EET": "+0200", "CET": "+0100", "GMT": "+0000", "UTC": "+0000", "CVT": "-0100", "GST": "-0200", "BRT": "-0300", "NST": "-0330", "AST": "-0400", "EST": "-0500", "CST": "-0600", "MST": "-0700", "PST": "-0800", "AKST": "-0900", "MIT": "-0930", "HST": "-1000", "SST": "-1100", "BIT": "-1200" }; return __(standard); }, timeZones: function (data) { var zone; data.timezones = []; for (zone in data.abbreviatedTimeZoneStandard) { if (data.abbreviatedTimeZoneStandard.hasOwnProperty(zone)) { data.timezones.push({ name: zone, offset: data.abbreviatedTimeZoneStandard[zone]}); } } for (zone in data.abbreviatedTimeZoneDST) { if (data.abbreviatedTimeZoneDST.hasOwnProperty(zone)) { data.timezones.push({ name: zone, offset: data.abbreviatedTimeZoneDST[zone], dst: true}); } } return data.timezones; }, days: function () { return __(["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"]); }, dayAbbr: function () { return __(["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"]); }, dayShortNames: function () { return __(["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"]); }, dayFirstLetters: function () { return __(["S_Sun_Initial", "M_Mon_Initial", "T_Tues_Initial", "W_Wed_Initial", "T_Thu_Initial", "F_Fri_Initial", "S_Sat_Initial"]); }, months: function () { return __(["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"]); }, monthAbbr: function () { return __(["Jan_Abbr", "Feb_Abbr", "Mar_Abbr", "Apr_Abbr", "May_Abbr", "Jun_Abbr", "Jul_Abbr", "Aug_Abbr", "Sep_Abbr", "Oct_Abbr", "Nov_Abbr", "Dec_Abbr"]); }, formatPatterns: function () { return getText.getFromObjectValues({ shortDate: "M/d/yyyy", longDate: "dddd, MMMM dd, yyyy", shortTime: "h:mm tt", longTime: "h:mm:ss tt", fullDateTime: "dddd, MMMM dd, yyyy h:mm:ss tt", sortableDateTime: "yyyy-MM-ddTHH:mm:ss", universalSortableDateTime: "yyyy-MM-dd HH:mm:ssZ", rfc1123: "ddd, dd MMM yyyy HH:mm:ss", monthDay: "MMMM dd", yearMonth: "MMMM, yyyy" }, Date.i18n.currentLanguage()); }, regex: function () { return getText.getFromObjectValues({ inTheMorning: "/( in the )(morn(ing)?)\\b/", thisMorning: "/(this )(morn(ing)?)\\b/", amThisMorning: "/(\b\\d(am)? )(this )(morn(ing)?)/", inTheEvening: "/( in the )(even(ing)?)\\b/", thisEvening: "/(this )(even(ing)?)\\b/", pmThisEvening: "/(\b\\d(pm)? )(this )(even(ing)?)/", jan: "/jan(uary)?/", feb: "/feb(ruary)?/", mar: "/mar(ch)?/", apr: "/apr(il)?/", may: "/may/", jun: "/jun(e)?/", jul: "/jul(y)?/", aug: "/aug(ust)?/", sep: "/sep(t(ember)?)?/", oct: "/oct(ober)?/", nov: "/nov(ember)?/", dec: "/dec(ember)?/", sun: "/^su(n(day)?)?/", mon: "/^mo(n(day)?)?/", tue: "/^tu(e(s(day)?)?)?/", wed: "/^we(d(nesday)?)?/", thu: "/^th(u(r(s(day)?)?)?)?/", fri: "/fr(i(day)?)?/", sat: "/^sa(t(urday)?)?/", future: "/^next/", past: "/^last|past|prev(ious)?/", add: "/^(\\+|aft(er)?|from|hence)/", subtract: "/^(\\-|bef(ore)?|ago)/", yesterday: "/^yes(terday)?/", today: "/^t(od(ay)?)?/", tomorrow: "/^tom(orrow)?/", now: "/^n(ow)?/", millisecond: "/^ms|milli(second)?s?/", second: "/^sec(ond)?s?/", minute: "/^mn|min(ute)?s?/", hour: "/^h(our)?s?/", week: "/^w(eek)?s?/", month: "/^m(onth)?s?/", day: "/^d(ay)?s?/", year: "/^y(ear)?s?/", shortMeridian: "/^(a|p)/", longMeridian: "/^(a\\.?m?\\.?|p\\.?m?\\.?)/", timezone: "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/", ordinalSuffix: "/^\\s*(st|nd|rd|th)/", timeContext: "/^\\s*(\\:|a(?!u|p)|p)/" }, Date.i18n.currentLanguage()); } }; var CultureInfo = function () { var info = getText.getFromObjectValues({ name: "name", englishName: "englishName", nativeName: "nativeName", amDesignator: "AM", pmDesignator: "PM", firstDayOfWeek: "firstDayOfWeek", twoDigitYearMax: "twoDigitYearMax", dateElementOrder: "mdy" }, Date.i18n.currentLanguage()); var constructedInfo = buildInfo.buildFromMethodHash({ dayNames: "days", abbreviatedDayNames: "dayAbbr", shortestDayNames: "dayShortNames", firstLetterDayNames: "dayFirstLetters", monthNames: "months", abbreviatedMonthNames: "monthAbbr", formatPatterns: "formatPatterns", regexPatterns: "regex", abbreviatedTimeZoneDST: "timeZoneDST", abbreviatedTimeZoneStandard: "timeZoneStandard" }); shallowMerge(info, constructedInfo); buildInfo.timeZones(info); return info; }; $D.i18n = { __: function (key, lang) { return __(key, lang); }, currentLanguage: function () { return lang || "en-US"; }, setLanguage: function (code, force, cb) { var async = false; if (force || code === "en-US" || (!!Date.CultureStrings && !!Date.CultureStrings[code])) { lang = code; Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings.lang = code; Date.CultureInfo = new CultureInfo(); } else { if (!(!!Date.CultureStrings && !!Date.CultureStrings[code])) { if (typeof exports !== "undefined" && this.exports !== exports) { // we're in a Node enviroment, load it using require try { require("../i18n/" + code + ".js"); lang = code; Date.CultureStrings.lang = code; Date.CultureInfo = new CultureInfo(); } catch (e) { // var str = "The language for '" + code + "' could not be loaded by Node. It likely does not exist."; throw new Error("The DateJS IETF language tag '" + code + "' could not be loaded by Node. It likely does not exist."); } } else if (Date.Config && Date.Config.i18n) { // we know the location of the files, so lets load them async = true; loadI18nScript(code).done(function(){ lang = code; Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings.lang = code; Date.CultureInfo = new CultureInfo(); $D.Parsing.Normalizer.buildReplaceData(); // because this is async if ($D.Grammar) { $D.Grammar.buildGrammarFormats(); // so we can parse those strings... } if (cb) { setTimeout(cb,0); } }); } else { Date.console.error("The DateJS IETF language tag '" + code + "' is not available and has not been loaded."); return false; } } } $D.Parsing.Normalizer.buildReplaceData(); // rebuild normalizer strings if ($D.Grammar) { $D.Grammar.buildGrammarFormats(); // so we can parse those strings... } if (!async && cb) { setTimeout(cb,0); } }, getLoggedKeys: function () { return loggedKeys; }, updateCultureInfo: function () { Date.CultureInfo = new CultureInfo(); } }; $D.i18n.updateCultureInfo(); // run automatically }()); (function () { var $D = Date, $P = $D.prototype, p = function (s, l) { if (!l) { l = 2; } return ("000" + s).slice(l * -1); }; if (typeof window !== "undefined" && typeof window.console !== "undefined" && typeof window.console.log !== "undefined") { $D.console = console; // used only to raise non-critical errors if available } else { // set mock so we don't give errors. $D.console = { log: function(){}, error: function(){} }; } $D.Config = $D.Config || {}; $D.initOverloads = function() { /** * Overload of Date.now. Allows an alternate call for Date.now where it returns the * current Date as an object rather than just milliseconds since the Unix Epoch. * * Also provides an implementation of now() for browsers (IE<9) that don't have it. * * Backwards compatible so with work with either: * Date.now() [returns ms] * or * Date.now(true) [returns Date] */ if (!$D.now) { $D._now = function now() { return new Date().getTime(); }; } else if (!$D._now) { $D._now = $D.now; } $D.now = function (returnObj) { if (returnObj) { return $D.present(); } else { return $D._now(); } }; if ( !$P.toISOString ) { $P.toISOString = function() { return this.getUTCFullYear() + "-" + p(this.getUTCMonth() + 1) + "-" + p(this.getUTCDate()) + "T" + p(this.getUTCHours()) + ":" + p(this.getUTCMinutes()) + ":" + p(this.getUTCSeconds()) + "." + String( (this.getUTCMilliseconds()/1000).toFixed(3)).slice(2, 5) + "Z"; }; } // private if ( $P._toString === undefined ){ $P._toString = $P.toString; } }; $D.initOverloads(); /** * Gets a date that is set to the current date. The time is set to the start of the day (00:00 or 12:00 AM). * @return {Date} The current date. */ $D.today = function () { return new Date().clearTime(); }; /** * Gets a date that is set to the current date and time (same as new Date, but chainable) * @return {Date} The current date. */ $D.present = function () { return new Date(); }; /** * Compares the first date to the second date and returns an number indication of their relative values. * @param {Date} First Date object to compare [Required]. * @param {Date} Second Date object to compare to [Required]. * @return {Number} -1 = date1 is lessthan date2. 0 = values are equal. 1 = date1 is greaterthan date2. */ $D.compare = function (date1, date2) { if (isNaN(date1) || isNaN(date2)) { throw new Error(date1 + " - " + date2); } else if (date1 instanceof Date && date2 instanceof Date) { return (date1 < date2) ? -1 : (date1 > date2) ? 1 : 0; } else { throw new TypeError(date1 + " - " + date2); } }; /** * Compares the first Date object to the second Date object and returns true if they are equal. * @param {Date} First Date object to compare [Required] * @param {Date} Second Date object to compare to [Required] * @return {Boolean} true if dates are equal. false if they are not equal. */ $D.equals = function (date1, date2) { return (date1.compareTo(date2) === 0); }; /** * Gets the language appropriate day name when given the day number(0-6) * eg - 0 == Sunday * @return {String} The day name */ $D.getDayName = function (n) { return Date.CultureInfo.dayNames[n]; }; /** * Gets the day number (0-6) if given a CultureInfo specific string which is a valid dayName, abbreviatedDayName or shortestDayName (two char). * @param {String} The name of the day (eg. "Monday, "Mon", "tuesday", "tue", "We", "we"). * @return {Number} The day number */ $D.getDayNumberFromName = function (name) { var n = Date.CultureInfo.dayNames, m = Date.CultureInfo.abbreviatedDayNames, o = Date.CultureInfo.shortestDayNames, s = name.toLowerCase(); for (var i = 0; i < n.length; i++) { if (n[i].toLowerCase() === s || m[i].toLowerCase() === s || o[i].toLowerCase() === s) { return i; } } return -1; }; /** * Gets the month number (0-11) if given a Culture Info specific string which is a valid monthName or abbreviatedMonthName. * @param {String} The name of the month (eg. "February, "Feb", "october", "oct"). * @return {Number} The day number */ $D.getMonthNumberFromName = function (name) { var n = Date.CultureInfo.monthNames, m = Date.CultureInfo.abbreviatedMonthNames, s = name.toLowerCase(); for (var i = 0; i < n.length; i++) { if (n[i].toLowerCase() === s || m[i].toLowerCase() === s) { return i; } } return -1; }; /** * Gets the language appropriate month name when given the month number(0-11) * eg - 0 == January * @return {String} The month name */ $D.getMonthName = function (n) { return Date.CultureInfo.monthNames[n]; }; /** * Determines if the current date instance is within a LeapYear. * @param {Number} The year. * @return {Boolean} true if date is within a LeapYear, otherwise false. */ $D.isLeapYear = function (year) { return ((year % 4 === 0 && year % 100 !== 0) || year % 400 === 0); }; /** * Gets the number of days in the month, given a year and month value. Automatically corrects for LeapYear. * @param {Number} The year. * @param {Number} The month (0-11). * @return {Number} The number of days in the month. */ $D.getDaysInMonth = function (year, month) { if (!month && $D.validateMonth(year)) { month = year; year = Date.today().getFullYear(); } return [31, ($D.isLeapYear(year) ? 29 : 28), 31, 30, 31, 30, 31, 31, 30, 31, 30, 31][month]; }; $P.getDaysInMonth = function () { return $D.getDaysInMonth(this.getFullYear(), this.getMonth()); }; $D.getTimezoneAbbreviation = function (offset, dst) { var p, n = (dst || false) ? Date.CultureInfo.abbreviatedTimeZoneDST : Date.CultureInfo.abbreviatedTimeZoneStandard; for (p in n) { if (n.hasOwnProperty(p)) { if (n[p] === offset) { return p; } } } return null; }; $D.getTimezoneOffset = function (name, dst) { var i, a =[], z = Date.CultureInfo.timezones; if (!name) { name = (new Date()).getTimezone();} for (i = 0; i < z.length; i++) { if (z[i].name === name.toUpperCase()) { a.push(i); } } if (!z[a[0]]) { return null; } if (a.length === 1 || !dst) { return z[a[0]].offset; } else { for (i=0; i < a.length; i++) { if (z[a[i]].dst) { return z[a[i]].offset; } } } }; $D.getQuarter = function (d) { d = d || new Date(); // If no date supplied, use today var q = [1,2,3,4]; return q[Math.floor(d.getMonth() / 3)]; // ~~~ is a bitwise op. Faster than Math.floor }; $D.getDaysLeftInQuarter = function (d) { d = d || new Date(); var qEnd = new Date(d); qEnd.setMonth(qEnd.getMonth() + 3 - qEnd.getMonth() % 3, 0); return Math.floor((qEnd - d) / 8.64e7); }; // private var validate = function (n, min, max, name) { name = name ? name : "Object"; if (typeof n === "undefined") { return false; } else if (typeof n !== "number") { throw new TypeError(n + " is not a Number."); } else if (n < min || n > max) { // As failing validation is *not* an exceptional circumstance // lets not throw a RangeError Exception here. // It's semantically correct but it's not sensible. return false; } return true; }; /** * Validates the number is within an acceptable range for milliseconds [0-999]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateMillisecond = function (value) { return validate(value, 0, 999, "millisecond"); }; /** * Validates the number is within an acceptable range for seconds [0-59]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateSecond = function (value) { return validate(value, 0, 59, "second"); }; /** * Validates the number is within an acceptable range for minutes [0-59]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateMinute = function (value) { return validate(value, 0, 59, "minute"); }; /** * Validates the number is within an acceptable range for hours [0-23]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateHour = function (value) { return validate(value, 0, 23, "hour"); }; /** * Validates the number is within an acceptable range for the days in a month [0-MaxDaysInMonth]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateDay = function (value, year, month) { if (year === undefined || year === null || month === undefined || month === null) { return false;} return validate(value, 1, $D.getDaysInMonth(year, month), "day"); }; /** * Validates the number is within an acceptable range for months [0-11]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateWeek = function (value) { return validate(value, 0, 53, "week"); }; /** * Validates the number is within an acceptable range for months [0-11]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateMonth = function (value) { return validate(value, 0, 11, "month"); }; /** * Validates the number is within an acceptable range for years. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateYear = function (value) { /** * Per ECMAScript spec the range of times supported by Date objects is * exactly -100,000,000 days to +100,000,000 days measured relative to * midnight at the beginning of 01 January, 1970 UTC. * This gives a range of 8,640,000,000,000,000 milliseconds to either * side of 01 January, 1970 UTC. * * Earliest possible date: Tue, 20 Apr 271,822 B.C. 00:00:00 UTC * Latest possible date: Sat, 13 Sep 275,760 00:00:00 UTC */ return validate(value, -271822, 275760, "year"); }; $D.validateTimezone = function(value) { var timezones = {"ACDT":1,"ACST":1,"ACT":1,"ADT":1,"AEDT":1,"AEST":1,"AFT":1,"AKDT":1,"AKST":1,"AMST":1,"AMT":1,"ART":1,"AST":1,"AWDT":1,"AWST":1,"AZOST":1,"AZT":1,"BDT":1,"BIOT":1,"BIT":1,"BOT":1,"BRT":1,"BST":1,"BTT":1,"CAT":1,"CCT":1,"CDT":1,"CEDT":1,"CEST":1,"CET":1,"CHADT":1,"CHAST":1,"CHOT":1,"ChST":1,"CHUT":1,"CIST":1,"CIT":1,"CKT":1,"CLST":1,"CLT":1,"COST":1,"COT":1,"CST":1,"CT":1,"CVT":1,"CWST":1,"CXT":1,"DAVT":1,"DDUT":1,"DFT":1,"EASST":1,"EAST":1,"EAT":1,"ECT":1,"EDT":1,"EEDT":1,"EEST":1,"EET":1,"EGST":1,"EGT":1,"EIT":1,"EST":1,"FET":1,"FJT":1,"FKST":1,"FKT":1,"FNT":1,"GALT":1,"GAMT":1,"GET":1,"GFT":1,"GILT":1,"GIT":1,"GMT":1,"GST":1,"GYT":1,"HADT":1,"HAEC":1,"HAST":1,"HKT":1,"HMT":1,"HOVT":1,"HST":1,"ICT":1,"IDT":1,"IOT":1,"IRDT":1,"IRKT":1,"IRST":1,"IST":1,"JST":1,"KGT":1,"KOST":1,"KRAT":1,"KST":1,"LHST":1,"LINT":1,"MAGT":1,"MART":1,"MAWT":1,"MDT":1,"MET":1,"MEST":1,"MHT":1,"MIST":1,"MIT":1,"MMT":1,"MSK":1,"MST":1,"MUT":1,"MVT":1,"MYT":1,"NCT":1,"NDT":1,"NFT":1,"NPT":1,"NST":1,"NT":1,"NUT":1,"NZDT":1,"NZST":1,"OMST":1,"ORAT":1,"PDT":1,"PET":1,"PETT":1,"PGT":1,"PHOT":1,"PHT":1,"PKT":1,"PMDT":1,"PMST":1,"PONT":1,"PST":1,"PYST":1,"PYT":1,"RET":1,"ROTT":1,"SAKT":1,"SAMT":1,"SAST":1,"SBT":1,"SCT":1,"SGT":1,"SLST":1,"SRT":1,"SST":1,"SYOT":1,"TAHT":1,"THA":1,"TFT":1,"TJT":1,"TKT":1,"TLT":1,"TMT":1,"TOT":1,"TVT":1,"UCT":1,"ULAT":1,"UTC":1,"UYST":1,"UYT":1,"UZT":1,"VET":1,"VLAT":1,"VOLT":1,"VOST":1,"VUT":1,"WAKT":1,"WAST":1,"WAT":1,"WEDT":1,"WEST":1,"WET":1,"WST":1,"YAKT":1,"YEKT":1,"Z":1}; return (timezones[value] === 1); }; $D.validateTimezoneOffset= function(value) { // timezones go from +14hrs to -12hrs, the +X hours are negative offsets. return (value > -841 && value < 721); }; }()); (function () { var $D = Date, $P = $D.prototype, p = function (s, l) { if (!l) { l = 2; } return ("000" + s).slice(l * -1); }; var validateConfigObject = function (obj) { var result = {}, self = this, prop, testFunc; testFunc = function (prop, func, value) { if (prop === "day") { var month = (obj.month !== undefined) ? obj.month : self.getMonth(); var year = (obj.year !== undefined) ? obj.year : self.getFullYear(); return $D[func](value, year, month); } else { return $D[func](value); } }; for (prop in obj) { if (Object.prototype.hasOwnProperty.call(obj, prop)) { var func = "validate" + prop.charAt(0).toUpperCase() + prop.slice(1); if ($D[func] && obj[prop] !== null && testFunc(prop, func, obj[prop])) { result[prop] = obj[prop]; } } } return result; }; /** * Resets the time of this Date object to 12:00 AM (00:00), which is the start of the day. * @param {Boolean} .clone() this date instance before clearing Time * @return {Date} this */ $P.clearTime = function () { this.setHours(0); this.setMinutes(0); this.setSeconds(0); this.setMilliseconds(0); return this; }; /** * Resets the time of this Date object to the current time ('now'). * @return {Date} this */ $P.setTimeToNow = function () { var n = new Date(); this.setHours(n.getHours()); this.setMinutes(n.getMinutes()); this.setSeconds(n.getSeconds()); this.setMilliseconds(n.getMilliseconds()); return this; }; /** * Returns a new Date object that is an exact date and time copy of the original instance. * @return {Date} A new Date instance */ $P.clone = function () { return new Date(this.getTime()); }; /** * Compares this instance to a Date object and returns an number indication of their relative values. * @param {Date} Date object to compare [Required] * @return {Number} -1 = this is lessthan date. 0 = values are equal. 1 = this is greaterthan date. */ $P.compareTo = function (date) { return Date.compare(this, date); }; /** * Compares this instance to another Date object and returns true if they are equal. * @param {Date} Date object to compare. If no date to compare, new Date() [now] is used. * @return {Boolean} true if dates are equal. false if they are not equal. */ $P.equals = function (date) { return Date.equals(this, (date !== undefined ? date : new Date())); }; /** * Determines if this instance is between a range of two dates or equal to either the start or end dates. * @param {Date} Start of range [Required] * @param {Date} End of range [Required] * @return {Boolean} true is this is between or equal to the start and end dates, else false */ $P.between = function (start, end) { return this.getTime() >= start.getTime() && this.getTime() <= end.getTime(); }; /** * Determines if this date occurs after the date to compare to. * @param {Date} Date object to compare. If no date to compare, new Date() ("now") is used. * @return {Boolean} true if this date instance is greater than the date to compare to (or "now"), otherwise false. */ $P.isAfter = function (date) { return this.compareTo(date || new Date()) === 1; }; /** * Determines if this date occurs before the date to compare to. * @param {Date} Date object to compare. If no date to compare, new Date() ("now") is used. * @return {Boolean} true if this date instance is less than the date to compare to (or "now"). */ $P.isBefore = function (date) { return (this.compareTo(date || new Date()) === -1); }; /** * Determines if the current Date instance occurs today. * @return {Boolean} true if this date instance is 'today', otherwise false. */ /** * Determines if the current Date instance occurs on the same Date as the supplied 'date'. * If no 'date' to compare to is provided, the current Date instance is compared to 'today'. * @param {date} Date object to compare. If no date to compare, the current Date ("now") is used. * @return {Boolean} true if this Date instance occurs on the same Day as the supplied 'date'. */ $P.isToday = $P.isSameDay = function (date) { return this.clone().clearTime().equals((date || new Date()).clone().clearTime()); }; /** * Adds the specified number of milliseconds to this instance. * @param {Number} The number of milliseconds to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addMilliseconds = function (value) { if (!value) { return this; } this.setTime(this.getTime() + value * 1); return this; }; /** * Adds the specified number of seconds to this instance. * @param {Number} The number of seconds to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addSeconds = function (value) { if (!value) { return this; } return this.addMilliseconds(value * 1000); }; /** * Adds the specified number of seconds to this instance. * @param {Number} The number of seconds to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addMinutes = function (value) { if (!value) { return this; } return this.addMilliseconds(value * 60000); // 60*1000 }; /** * Adds the specified number of hours to this instance. * @param {Number} The number of hours to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addHours = function (value) { if (!value) { return this; } return this.addMilliseconds(value * 3600000); // 60*60*1000 }; /** * Adds the specified number of days to this instance. * @param {Number} The number of days to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addDays = function (value) { if (!value) { return this; } this.setDate(this.getDate() + value * 1); return this; }; /** * Adds the specified number of weekdays (ie - not sat or sun) to this instance. * @param {Number} The number of days to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addWeekdays = function (value) { if (!value) { return this; } var day = this.getDay(); var weeks = (Math.ceil(Math.abs(value)/7)); if (day === 0 || day === 6) { if (value > 0) { this.next().monday(); this.addDays(-1); day = this.getDay(); } } if (value < 0) { while (value < 0) { this.addDays(-1); day = this.getDay(); if (day !== 0 && day !== 6) { value++; } } return this; } else if (value > 5 || (6-day) <= value) { value = value + (weeks * 2); } return this.addDays(value); }; /** * Adds the specified number of weeks to this instance. * @param {Number} The number of weeks to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addWeeks = function (value) { if (!value) { return this; } return this.addDays(value * 7); }; /** * Adds the specified number of months to this instance. * @param {Number} The number of months to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addMonths = function (value) { if (!value) { return this; } var n = this.getDate(); this.setDate(1); this.setMonth(this.getMonth() + value * 1); this.setDate(Math.min(n, $D.getDaysInMonth(this.getFullYear(), this.getMonth()))); return this; }; $P.addQuarters = function (value) { if (!value) { return this; } // note this will take you to the same point in the quarter as you are now. // i.e. - if you are 15 days into the quarter you'll be 15 days into the resulting one. // bonus: this allows adding fractional quarters return this.addMonths(value * 3); }; /** * Adds the specified number of years to this instance. * @param {Number} The number of years to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addYears = function (value) { if (!value) { return this; } return this.addMonths(value * 12); }; /** * Adds (or subtracts) to the value of the years, months, weeks, days, hours, minutes, seconds, milliseconds of the date instance using given configuration object. Positive and Negative values allowed. * Example

	Date.today().add( { days: 1, months: 1 } )

	new Date().add( { years: -1 } )
	
* @param {Object} Configuration object containing attributes (months, days, etc.) * @return {Date} this */ $P.add = function (config) { if (typeof config === "number") { this._orient = config; return this; } var x = config; if (x.day) { // If we should be a different date than today (eg: for 'tomorrow -1d', etc). // Should only effect parsing, not direct usage (eg, Finish and FinishExact) if ((x.day - this.getDate()) !== 0) { this.setDate(x.day); } } if (x.milliseconds) { this.addMilliseconds(x.milliseconds); } if (x.seconds) { this.addSeconds(x.seconds); } if (x.minutes) { this.addMinutes(x.minutes); } if (x.hours) { this.addHours(x.hours); } if (x.weeks) { this.addWeeks(x.weeks); } if (x.months) { this.addMonths(x.months); } if (x.years) { this.addYears(x.years); } if (x.days) { this.addDays(x.days); } return this; }; /** * Get the week number. Week one (1) is the week which contains the first Thursday of the year. Monday is considered the first day of the week. * The .getWeek() function does NOT convert the date to UTC. The local datetime is used. * Please use .getISOWeek() to get the week of the UTC converted date. * @return {Number} 1 to 53 */ $P.getWeek = function (utc) { // Create a copy of this date object var self, target = new Date(this.valueOf()); if (utc) { target.addMinutes(target.getTimezoneOffset()); self = target.clone(); } else { self = this; } // ISO week date weeks start on monday // so correct the day number var dayNr = (self.getDay() + 6) % 7; // ISO 8601 states that week 1 is the week // with the first thursday of that year. // Set the target date to the thursday in the target week target.setDate(target.getDate() - dayNr + 3); // Store the millisecond value of the target date var firstThursday = target.valueOf(); // Set the target to the first thursday of the year // First set the target to january first target.setMonth(0, 1); // Not a thursday? Correct the date to the next thursday if (target.getDay() !== 4) { target.setMonth(0, 1 + ((4 - target.getDay()) + 7) % 7); } // The weeknumber is the number of weeks between the // first thursday of the year and the thursday in the target week return 1 + Math.ceil((firstThursday - target) / 604800000); // 604800000 = 7 * 24 * 3600 * 1000 }; /** * Get the ISO 8601 week number. Week one ("01") is the week which contains the first Thursday of the year. Monday is considered the first day of the week. * The .getISOWeek() function does convert the date to it's UTC value. Please use .getWeek() to get the week of the local date. * @return {String} "01" to "53" */ $P.getISOWeek = function () { return p(this.getWeek(true)); }; /** * Moves the date to Monday of the week set. Week one (1) is the week which contains the first Thursday of the year. * @param {Number} A Number (1 to 53) that represents the week of the year. * @return {Date} this */ $P.setWeek = function (n) { if ((n - this.getWeek()) === 0) { if (this.getDay() !== 1) { return this.moveToDayOfWeek(1, (this.getDay() > 1 ? -1 : 1)); } else { return this; } } else { return this.moveToDayOfWeek(1, (this.getDay() > 1 ? -1 : 1)).addWeeks(n - this.getWeek()); } }; $P.setQuarter = function (qtr) { var month = Math.abs(((qtr-1) * 3) + 1); return this.setMonth(month, 1); }; $P.getQuarter = function () { return Date.getQuarter(this); }; $P.getDaysLeftInQuarter = function () { return Date.getDaysLeftInQuarter(this); }; /** * Moves the date to the next n'th occurrence of the dayOfWeek starting from the beginning of the month. The number (-1) is a magic number and will return the last occurrence of the dayOfWeek in the month. * @param {Number} The dayOfWeek to move to * @param {Number} The n'th occurrence to move to. Use (-1) to return the last occurrence in the month * @return {Date} this */ $P.moveToNthOccurrence = function (dayOfWeek, occurrence) { if (dayOfWeek === "Weekday") { if (occurrence > 0) { this.moveToFirstDayOfMonth(); if (this.is().weekday()) { occurrence -= 1; } } else if (occurrence < 0) { this.moveToLastDayOfMonth(); if (this.is().weekday()) { occurrence += 1; } } else { return this; } return this.addWeekdays(occurrence); } var shift = 0; if (occurrence > 0) { shift = occurrence - 1; } else if (occurrence === -1) { this.moveToLastDayOfMonth(); if (this.getDay() !== dayOfWeek) { this.moveToDayOfWeek(dayOfWeek, -1); } return this; } return this.moveToFirstDayOfMonth().addDays(-1).moveToDayOfWeek(dayOfWeek, +1).addWeeks(shift); }; var moveToN = function (getFunc, addFunc, nVal) { return function (value, orient) { var diff = (value - this[getFunc]() + nVal * (orient || +1)) % nVal; return this[addFunc]((diff === 0) ? diff += nVal * (orient || +1) : diff); }; }; /** * Move to the next or last dayOfWeek based on the orient value. * @param {Number} The dayOfWeek to move to * @param {Number} Forward (+1) or Back (-1). Defaults to +1. [Optional] * @return {Date} this */ $P.moveToDayOfWeek = moveToN("getDay", "addDays", 7); /** * Move to the next or last month based on the orient value. * @param {Number} The month to move to. 0 = January, 11 = December * @param {Number} Forward (+1) or Back (-1). Defaults to +1. [Optional] * @return {Date} this */ $P.moveToMonth = moveToN("getMonth", "addMonths", 12); /** * Get the Ordinate of the current day ("th", "st", "rd"). * @return {String} */ $P.getOrdinate = function () { var num = this.getDate(); return ord(num); }; /** * Get the Ordinal day (numeric day number) of the year, adjusted for leap year. * @return {Number} 1 through 365 (366 in leap years) */ $P.getOrdinalNumber = function () { return Math.ceil((this.clone().clearTime() - new Date(this.getFullYear(), 0, 1)) / 86400000) + 1; }; /** * Get the time zone abbreviation of the current date. * @return {String} The abbreviated time zone name (e.g. "EST") */ $P.getTimezone = function () { return $D.getTimezoneAbbreviation(this.getUTCOffset(), this.isDaylightSavingTime()); }; $P.setTimezoneOffset = function (offset) { var here = this.getTimezoneOffset(), there = Number(offset) * -6 / 10; return (there || there === 0) ? this.addMinutes(there - here) : this; }; $P.setTimezone = function (offset) { return this.setTimezoneOffset($D.getTimezoneOffset(offset)); }; /** * Indicates whether Daylight Saving Time is observed in the current time zone. * @return {Boolean} true|false */ $P.hasDaylightSavingTime = function () { return (Date.today().set({month: 0, day: 1}).getTimezoneOffset() !== Date.today().set({month: 6, day: 1}).getTimezoneOffset()); }; /** * Indicates whether this Date instance is within the Daylight Saving Time range for the current time zone. * @return {Boolean} true|false */ $P.isDaylightSavingTime = function () { return Date.today().set({month: 0, day: 1}).getTimezoneOffset() !== this.getTimezoneOffset(); }; /** * Get the offset from UTC of the current date. * @return {String} The 4-character offset string prefixed with + or - (e.g. "-0500") */ $P.getUTCOffset = function (offset) { var n = (offset || this.getTimezoneOffset()) * -10 / 6, r; if (n < 0) { r = (n - 10000).toString(); return r.charAt(0) + r.substr(2); } else { r = (n + 10000).toString(); return "+" + r.substr(1); } }; /** * Returns the number of milliseconds between this date and date. * @param {Date} Defaults to now * @return {Number} The diff in milliseconds */ $P.getElapsed = function (date) { return (date || new Date()) - this; }; /** * Set the value of year, month, day, hour, minute, second, millisecond of date instance using given configuration object. * Example

	Date.today().set( { day: 20, month: 1 } )

	new Date().set( { millisecond: 0 } )
	
* * @param {Object} Configuration object containing attributes (month, day, etc.) * @return {Date} this */ $P.set = function (config) { config = validateConfigObject.call(this, config); var key; for (key in config) { if (Object.prototype.hasOwnProperty.call(config, key)) { var name = key.charAt(0).toUpperCase() + key.slice(1); var addFunc, getFunc; if (key !== "week" && key !== "month" && key !== "timezone" && key !== "timezoneOffset") { name += "s"; } addFunc = "add" + name; getFunc = "get" + name; if (key === "month") { addFunc = addFunc + "s"; } else if (key === "year"){ getFunc = "getFullYear"; } if (key !== "day" && key !== "timezone" && key !== "timezoneOffset" && key !== "week" && key !== "hour") { this[addFunc](config[key] - this[getFunc]()); } else if ( key === "timezone"|| key === "timezoneOffset" || key === "week" || key === "hour") { this["set"+name](config[key]); } } } // day has to go last because you can't validate the day without first knowing the month if (config.day) { this.addDays(config.day - this.getDate()); } return this; }; /** * Moves the date to the first day of the month. * @return {Date} this */ $P.moveToFirstDayOfMonth = function () { return this.set({ day: 1 }); }; /** * Moves the date to the last day of the month. * @return {Date} this */ $P.moveToLastDayOfMonth = function () { return this.set({ day: $D.getDaysInMonth(this.getFullYear(), this.getMonth())}); }; /** * Converts the value of the current Date object to its equivalent string representation. * Format Specifiers * CUSTOM DATE AND TIME FORMAT STRINGS * Format Description Example * ------ --------------------------------------------------------------------------- ----------------------- * s The seconds of the minute between 0-59. "0" to "59" * ss The seconds of the minute with leading zero if required. "00" to "59" * * m The minute of the hour between 0-59. "0" or "59" * mm The minute of the hour with leading zero if required. "00" or "59" * * h The hour of the day between 1-12. "1" to "12" * hh The hour of the day with leading zero if required. "01" to "12" * * H The hour of the day between 0-23. "0" to "23" * HH The hour of the day with leading zero if required. "00" to "23" * * d The day of the month between 1 and 31. "1" to "31" * dd The day of the month with leading zero if required. "01" to "31" * ddd Abbreviated day name. Date.CultureInfo.abbreviatedDayNames. "Mon" to "Sun" * dddd The full day name. Date.CultureInfo.dayNames. "Monday" to "Sunday" * * M The month of the year between 1-12. "1" to "12" * MM The month of the year with leading zero if required. "01" to "12" * MMM Abbreviated month name. Date.CultureInfo.abbreviatedMonthNames. "Jan" to "Dec" * MMMM The full month name. Date.CultureInfo.monthNames. "January" to "December" * * yy The year as a two-digit number. "99" or "08" * yyyy The full four digit year. "1999" or "2008" * * t Displays the first character of the A.M./P.M. designator. "A" or "P" * Date.CultureInfo.amDesignator or Date.CultureInfo.pmDesignator * tt Displays the A.M./P.M. designator. "AM" or "PM" * Date.CultureInfo.amDesignator or Date.CultureInfo.pmDesignator * * S The ordinal suffix ("st, "nd", "rd" or "th") of the current day. "st, "nd", "rd" or "th" * * STANDARD DATE AND TIME FORMAT STRINGS * Format Description Example *------ --------------------------------------------------------------------------- ----------------------- * d The CultureInfo shortDate Format Pattern "M/d/yyyy" * D The CultureInfo longDate Format Pattern "dddd, MMMM dd, yyyy" * F The CultureInfo fullDateTime Format Pattern "dddd, MMMM dd, yyyy h:mm:ss tt" * m The CultureInfo monthDay Format Pattern "MMMM dd" * r The CultureInfo rfc1123 Format Pattern "ddd, dd MMM yyyy HH:mm:ss GMT" * s The CultureInfo sortableDateTime Format Pattern "yyyy-MM-ddTHH:mm:ss" * t The CultureInfo shortTime Format Pattern "h:mm tt" * T The CultureInfo longTime Format Pattern "h:mm:ss tt" * u The CultureInfo universalSortableDateTime Format Pattern "yyyy-MM-dd HH:mm:ssZ" * y The CultureInfo yearMonth Format Pattern "MMMM, yyyy" * * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @return {String} A string representation of the current Date object. */ var ord = function (n) { switch (n * 1) { case 1: case 21: case 31: return "st"; case 2: case 22: return "nd"; case 3: case 23: return "rd"; default: return "th"; } }; var parseStandardFormats = function (format) { var y, c = Date.CultureInfo.formatPatterns; switch (format) { case "d": return this.toString(c.shortDate); case "D": return this.toString(c.longDate); case "F": return this.toString(c.fullDateTime); case "m": return this.toString(c.monthDay); case "r": case "R": y = this.clone().addMinutes(this.getTimezoneOffset()); return y.toString(c.rfc1123) + " GMT"; case "s": return this.toString(c.sortableDateTime); case "t": return this.toString(c.shortTime); case "T": return this.toString(c.longTime); case "u": y = this.clone().addMinutes(this.getTimezoneOffset()); return y.toString(c.universalSortableDateTime); case "y": return this.toString(c.yearMonth); default: return false; } }; var parseFormatStringsClosure = function (context) { return function (m) { if (m.charAt(0) === "\\") { return m.replace("\\", ""); } switch (m) { case "hh": return p(context.getHours() < 13 ? (context.getHours() === 0 ? 12 : context.getHours()) : (context.getHours() - 12)); case "h": return context.getHours() < 13 ? (context.getHours() === 0 ? 12 : context.getHours()) : (context.getHours() - 12); case "HH": return p(context.getHours()); case "H": return context.getHours(); case "mm": return p(context.getMinutes()); case "m": return context.getMinutes(); case "ss": return p(context.getSeconds()); case "s": return context.getSeconds(); case "yyyy": return p(context.getFullYear(), 4); case "yy": return p(context.getFullYear()); case "y": return context.getFullYear(); case "E": case "dddd": return Date.CultureInfo.dayNames[context.getDay()]; case "ddd": return Date.CultureInfo.abbreviatedDayNames[context.getDay()]; case "dd": return p(context.getDate()); case "d": return context.getDate(); case "MMMM": return Date.CultureInfo.monthNames[context.getMonth()]; case "MMM": return Date.CultureInfo.abbreviatedMonthNames[context.getMonth()]; case "MM": return p((context.getMonth() + 1)); case "M": return context.getMonth() + 1; case "t": return context.getHours() < 12 ? Date.CultureInfo.amDesignator.substring(0, 1) : Date.CultureInfo.pmDesignator.substring(0, 1); case "tt": return context.getHours() < 12 ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator; case "S": return ord(context.getDate()); case "W": return context.getWeek(); case "WW": return context.getISOWeek(); case "Q": return "Q" + context.getQuarter(); case "q": return String(context.getQuarter()); case "z": return context.getTimezone(); case "Z": case "X": return Date.getTimezoneOffset(context.getTimezone()); case "ZZ": // Timezone offset in seconds return context.getTimezoneOffset() * -60; case "u": return context.getDay(); case "L": return ($D.isLeapYear(context.getFullYear())) ? 1 : 0; case "B": // Swatch Internet Time (.beats) return "@"+((context.getUTCSeconds() + (context.getUTCMinutes()*60) + ((context.getUTCHours()+1)*3600))/86.4); default: return m; } }; }; $P.toString = function (format, ignoreStandards) { // Standard Date and Time Format Strings. Formats pulled from CultureInfo file and // may vary by culture. if (!ignoreStandards && format && format.length === 1) { output = parseStandardFormats.call(this, format); if (output) { return output; } } var parseFormatStrings = parseFormatStringsClosure(this); return format ? format.replace(/((\\)?(dd?d?d?|MM?M?M?|yy?y?y?|hh?|HH?|mm?|ss?|tt?|S|q|Q|WW?W?W?)(?![^\[]*\]))/g, parseFormatStrings).replace(/\[|\]/g, "") : this._toString(); }; }()); /************************************************************* * SugarPak - Domain Specific Language - Syntactical Sugar * *************************************************************/ (function () { var $D = Date, $P = $D.prototype, $N = Number.prototype; // private $P._orient = +1; // private $P._nth = null; // private $P._is = false; // private $P._same = false; // private $P._isSecond = false; // private $N._dateElement = "days"; /** * Moves the date to the next instance of a date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.today().next().friday();
	Date.today().next().fri();
	Date.today().next().march();
	Date.today().next().mar();
	Date.today().next().week();
	
* * @return {Date} date */ $P.next = function () { this._move = true; this._orient = +1; return this; }; /** * Creates a new Date (Date.today()) and moves the date to the next instance of the date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.next().friday();
	Date.next().fri();
	Date.next().march();
	Date.next().mar();
	Date.next().week();
	
* * @return {Date} date */ $D.next = function () { return $D.today().next(); }; /** * Moves the date to the previous instance of a date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.today().last().friday();
	Date.today().last().fri();
	Date.today().last().march();
	Date.today().last().mar();
	Date.today().last().week();
	
* * @return {Date} date */ $P.last = $P.prev = $P.previous = function () { this._move = true; this._orient = -1; return this; }; /** * Creates a new Date (Date.today()) and moves the date to the previous instance of the date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.last().friday();
	Date.last().fri();
	Date.previous().march();
	Date.prev().mar();
	Date.last().week();
	
* * @return {Date} date */ $D.last = $D.prev = $D.previous = function () { return $D.today().last(); }; /** * Performs a equality check when followed by either a month name, day name or .weekday() function. * Example

	Date.today().is().friday(); // true|false
	Date.today().is().fri();
	Date.today().is().march();
	Date.today().is().mar();
	
* * @return {Boolean} true|false */ $P.is = function () { this._is = true; return this; }; /** * Determines if two date objects occur on/in exactly the same instance of the subsequent date part function. * The function .same() must be followed by a date part function (example: .day(), .month(), .year(), etc). * * An optional Date can be passed in the date part function. If now date is passed as a parameter, 'Now' is used. * * The following example demonstrates how to determine if two dates fall on the exact same day. * * Example

	var d1 = Date.today(); // today at 00:00
	var d2 = new Date();   // exactly now.

	// Do they occur on the same day?
	d1.same().day(d2); // true
	
	// Do they occur on the same hour?
	d1.same().hour(d2); // false, unless d2 hour is '00' (midnight).
	
	// What if it's the same day, but one year apart?
	var nextYear = Date.today().add(1).year();

	d1.same().day(nextYear); // false, because the dates must occur on the exact same day. 
	
* * Scenario: Determine if a given date occurs during some week period 2 months from now. * * Example

	var future = Date.today().add(2).months();
	return someDate.same().week(future); // true|false;
	
* * @return {Boolean} true|false */ $P.same = function () { this._same = true; this._isSecond = false; return this; }; /** * Determines if the current date/time occurs during Today. Must be preceded by the .is() function. * Example

	someDate.is().today();    // true|false
	new Date().is().today();  // true
	Date.today().is().today();// true
	Date.today().add(-1).day().is().today(); // false
	
* * @return {Boolean} true|false */ $P.today = function () { return this.same().day(); }; /** * Determines if the current date is a weekday. This function must be preceded by the .is() function. * Example

	Date.today().is().weekday(); // true|false
	
* * @return {Boolean} true|false */ $P.weekday = function () { if (this._nth) { return df("Weekday").call(this); } if (this._move) { return this.addWeekdays(this._orient); } if (this._is) { this._is = false; return (!this.is().sat() && !this.is().sun()); } return false; }; /** * Determines if the current date is on the weekend. This function must be preceded by the .is() function. * Example

	Date.today().is().weekend(); // true|false
	
* * @return {Boolean} true|false */ $P.weekend = function () { if (this._is) { this._is = false; return (this.is().sat() || this.is().sun()); } return false; }; /** * Sets the Time of the current Date instance. A string "6:15 pm" or config object {hour:18, minute:15} are accepted. * Example

	// Set time to 6:15pm with a String
	Date.today().at("6:15pm");

	// Set time to 6:15pm with a config object
	Date.today().at({hour:18, minute:15});
	
* * @return {Date} date */ $P.at = function (time) { return (typeof time === "string") ? $D.parse(this.toString("d") + " " + time) : this.set(time); }; /** * Creates a new Date() and adds this (Number) to the date based on the preceding date element function (eg. second|minute|hour|day|month|year). * Example

	// Undeclared Numbers must be wrapped with parentheses. Requirment of JavaScript.
	(3).days().fromNow();
	(6).months().fromNow();

	// Declared Number variables do not require parentheses. 
	var n = 6;
	n.months().fromNow();
	
* * @return {Date} A new Date instance */ $N.fromNow = $N.after = function (date) { var c = {}; c[this._dateElement] = this; return ((!date) ? new Date() : date.clone()).add(c); }; /** * Creates a new Date() and subtract this (Number) from the date based on the preceding date element function (eg. second|minute|hour|day|month|year). * Example

	// Undeclared Numbers must be wrapped with parentheses. Requirment of JavaScript.
	(3).days().ago();
	(6).months().ago();

	// Declared Number variables do not require parentheses. 
	var n = 6;
	n.months().ago();
	
* * @return {Date} A new Date instance */ $N.ago = $N.before = function (date) { var c = {}, s = (this._dateElement[this._dateElement.length-1] !== "s") ? this._dateElement + "s" : this._dateElement; c[s] = this * -1; return ((!date) ? new Date() : date.clone()).add(c); }; // Do NOT modify the following string tokens. These tokens are used to build dynamic functions. // All culture-specific strings can be found in the CultureInfo files. var dx = ("sunday monday tuesday wednesday thursday friday saturday").split(/\s/), mx = ("january february march april may june july august september october november december").split(/\s/), px = ("Millisecond Second Minute Hour Day Week Month Year Quarter Weekday").split(/\s/), pxf = ("Milliseconds Seconds Minutes Hours Date Week Month FullYear Quarter").split(/\s/), nth = ("final first second third fourth fifth").split(/\s/), de; /** * Returns an object literal of all the date parts. * Example

	var o = new Date().toObject();
	
	// { year: 2008, month: 4, week: 20, day: 13, hour: 18, minute: 9, second: 32, millisecond: 812 }
	
	// The object properties can be referenced directly from the object.
	
	alert(o.day);  // alerts "13"
	alert(o.year); // alerts "2008"
	
* * @return {Date} An object literal representing the original date object. */ $P.toObject = function () { var o = {}; for (var i = 0; i < px.length; i++) { if (this["get" + pxf[i]]) { o[px[i].toLowerCase()] = this["get" + pxf[i]](); } } return o; }; /** * Returns a date created from an object literal. Ignores the .week property if set in the config. * Example

	var o = new Date().toObject();
	
	return Date.fromObject(o); // will return the same date. 

	var o2 = {month: 1, day: 20, hour: 18}; // birthday party!
	Date.fromObject(o2);
	
* * @return {Date} An object literal representing the original date object. */ $D.fromObject = function(config) { config.week = null; return Date.today().set(config); }; // Create day name functions and abbreviated day name functions (eg. monday(), friday(), fri()). var df = function (n) { return function () { if (this._is) { this._is = false; return this.getDay() === n; } if (this._move) { this._move = null; } if (this._nth !== null) { // If the .second() function was called earlier, remove the _orient // from the date, and then continue. // This is required because 'second' can be used in two different context. // // Example // // Date.today().add(1).second(); // Date.march().second().monday(); // // Things get crazy with the following... // Date.march().add(1).second().second().monday(); // but it works!! // if (this._isSecond) { this.addSeconds(this._orient * -1); } // make sure we reset _isSecond this._isSecond = false; var ntemp = this._nth; this._nth = null; var temp = this.clone().moveToLastDayOfMonth(); this.moveToNthOccurrence(n, ntemp); if (this > temp) { throw new RangeError($D.getDayName(n) + " does not occur " + ntemp + " times in the month of " + $D.getMonthName(temp.getMonth()) + " " + temp.getFullYear() + "."); } return this; } return this.moveToDayOfWeek(n, this._orient); }; }; var sdf = function (n) { return function () { var t = $D.today(), shift = n - t.getDay(); if (n === 0 && Date.CultureInfo.firstDayOfWeek === 1 && t.getDay() !== 0) { shift = shift + 7; } return t.addDays(shift); }; }; // Create month name functions and abbreviated month name functions (eg. january(), march(), mar()). var month_instance_functions = function (n) { return function () { if (this._is) { this._is = false; return this.getMonth() === n; } return this.moveToMonth(n, this._orient); }; }; var month_static_functions = function (n) { return function () { return $D.today().set({ month: n, day: 1 }); }; }; var processTerms = function (names, staticFunc, instanceFunc) { for (var i = 0; i < names.length; i++) { // Create constant static Name variables. $D[names[i].toUpperCase()] = $D[names[i].toUpperCase().substring(0, 3)] = i; // Create Name functions. $D[names[i]] = $D[names[i].substring(0, 3)] = staticFunc(i); // Create Name instance functions. $P[names[i]] = $P[names[i].substring(0, 3)] = instanceFunc(i); } }; processTerms(dx, sdf, df); processTerms(mx, month_static_functions, month_instance_functions); // Create date element functions and plural date element functions used with Date (eg. day(), days(), months()). var ef = function (j) { return function () { // if the .second() function was called earlier, the _orient // has alread been added. Just return this and reset _isSecond. if (this._isSecond) { this._isSecond = false; return this; } if (this._same) { this._same = this._is = false; var o1 = this.toObject(), o2 = (arguments[0] || new Date()).toObject(), v = "", k = j.toLowerCase(); // the substr trick with -1 doesn't work in IE8 or less k = (k[k.length-1] === "s") ? k.substring(0,k.length-1) : k; for (var m = (px.length - 1); m > -1; m--) { v = px[m].toLowerCase(); if (o1[v] !== o2[v]) { return false; } if (k === v) { break; } } return true; } if (j.substring(j.length - 1) !== "s") { j += "s"; } if (this._move) { this._move = null; } return this["add" + j](this._orient); }; }; var nf = function (n) { return function () { this._dateElement = n; return this; }; }; for (var k = 0; k < px.length; k++) { de = px[k].toLowerCase(); if(de !== "weekday") { // Create date element functions and plural date element functions used with Date (eg. day(), days(), months()). $P[de] = $P[de + "s"] = ef(px[k]); // Create date element functions and plural date element functions used with Number (eg. day(), days(), months()). $N[de] = $N[de + "s"] = nf(de + "s"); } } $P._ss = ef("Second"); var nthfn = function (n) { return function (dayOfWeek) { if (this._same) { return this._ss(arguments[0]); } if (dayOfWeek || dayOfWeek === 0) { return this.moveToNthOccurrence(dayOfWeek, n); } this._nth = n; // if the operator is 'second' add the _orient, then deal with it later... if (n === 2 && (dayOfWeek === undefined || dayOfWeek === null)) { this._isSecond = true; return this.addSeconds(this._orient); } return this; }; }; for (var l = 0; l < nth.length; l++) { $P[nth[l]] = (l === 0) ? nthfn(-1) : nthfn(l); } }()); (function () { "use strict"; Date.Parsing = { Exception: function (s) { this.message = "Parse error at '" + s.substring(0, 10) + " ...'"; } }; var $P = Date.Parsing; var dayOffsets = { standard: [0,31,59,90,120,151,181,212,243,273,304,334], leap: [0,31,60,91,121,152,182,213,244,274,305,335] }; $P.isLeapYear = function(year) { return ((year % 4 === 0) && (year % 100 !== 0)) || (year % 400 === 0); }; var utils = { multiReplace : function (str, hash ) { var key; for (key in hash) { if (Object.prototype.hasOwnProperty.call(hash, key)) { var regex; if (typeof hash[key] === "function") { } else { regex = (hash[key] instanceof RegExp) ? hash[key] : new RegExp(hash[key], "g"); } str = str.replace(regex, key); } } return str; }, getDayOfYearFromWeek : function (obj) { var d, jan4, offset; obj.weekDay = (!obj.weekDay && obj.weekDay !== 0) ? 1 : obj.weekDay; d = new Date(obj.year, 0, 4); jan4 = d.getDay() === 0 ? 7 : d.getDay(); // JS is 0 indexed on Sunday. offset = jan4+3; obj.dayOfYear = ((obj.week * 7) + (obj.weekDay === 0 ? 7 : obj.weekDay))-offset; return obj; }, getDayOfYear : function (obj, dayOffset) { if (!obj.dayOfYear) { obj = utils.getDayOfYearFromWeek(obj); } for (var i=0;i <= dayOffset.length;i++) { if (obj.dayOfYear < dayOffset[i] || i === dayOffset.length) { obj.day = obj.day ? obj.day : (obj.dayOfYear - dayOffset[i-1]); break; } else { obj.month = i; } } return obj; }, adjustForTimeZone : function (obj, date) { var offset; if (obj.zone.toUpperCase() === "Z" || (obj.zone_hours === 0 && obj.zone_minutes === 0)) { // it's UTC/GML so work out the current timeszone offset offset = -date.getTimezoneOffset(); } else { offset = (obj.zone_hours*60) + (obj.zone_minutes || 0); if (obj.zone_sign === "+") { offset *= -1; } offset -= date.getTimezoneOffset(); } date.setMinutes(date.getMinutes()+offset); return date; }, setDefaults : function (obj) { obj.year = obj.year || Date.today().getFullYear(); obj.hours = obj.hours || 0; obj.minutes = obj.minutes || 0; obj.seconds = obj.seconds || 0; obj.milliseconds = obj.milliseconds || 0; if (!(!obj.month && (obj.week || obj.dayOfYear))) { // if we have a month, or if we don't but don't have the day calculation data obj.month = obj.month || 0; obj.day = obj.day || 1; } return obj; }, dataNum: function (data, mod, explict, postProcess) { var dataNum = data*1; if (mod) { if (postProcess) { return data ? mod(data)*1 : data; } else { return data ? mod(dataNum) : data; } } else if (!explict){ return data ? dataNum : data; } else { return (data && typeof data !== "undefined") ? dataNum : data; } }, timeDataProcess: function (obj) { var timeObj = {}; for (var x in obj.data) { if (obj.data.hasOwnProperty(x)) { timeObj[x] = obj.ignore[x] ? obj.data[x] : utils.dataNum(obj.data[x], obj.mods[x], obj.explict[x], obj.postProcess[x]); } } if (obj.data.secmins) { obj.data.secmins = obj.data.secmins.replace(",", ".") * 60; if (!timeObj.minutes) { timeObj.minutes = obj.data.secmins; } else if (!timeObj.seconds) { timeObj.seconds = obj.data.secmins; } delete obj.secmins; } return timeObj; }, buildTimeObjectFromData: function (data) { var time = utils.timeDataProcess({ data: { year : data[1], month : data[5], day : data[7], week : data[8], dayOfYear : data[10], hours : data[15], zone_hours : data[23], zone_minutes : data[24], zone : data[21], zone_sign : data[22], weekDay : data[9], minutes: data[16], seconds: data[19], milliseconds: data[20], secmins: data[18] }, mods: { month: function(data) { return data-1; }, weekDay: function (data) { data = Math.abs(data); return (data === 7 ? 0 : data); }, minutes: function (data) { return data.replace(":",""); }, seconds: function (data) { return Math.floor( (data.replace(":","").replace(",","."))*1 ); }, milliseconds: function (data) { return (data.replace(",",".")*1000); } }, postProcess: { minutes: true, seconds: true, milliseconds: true }, explict: { zone_hours: true, zone_minutes: true }, ignore: { zone: true, zone_sign: true, secmins: true } }); return time; }, addToHash: function (hash, keys, data) { keys = keys; data = data; var len = keys.length; for (var i = 0; i < len; i++) { hash[keys[i]] = data[i]; } return hash; }, combineRegex: function (r1, r2) { return new RegExp("(("+r1.source+")\\s("+r2.source+"))"); }, getDateNthString: function(add, last, inc){ if (add) { return Date.today().addDays(inc).toString("d"); } else if (last) { return Date.today().last()[inc]().toString("d"); } }, buildRegexData: function (array) { var arr = []; var len = array.length; for (var i=0; i < len; i++) { if (Object.prototype.toString.call(array[i]) === '[object Array]') { // oldIE compat version of Array.isArray arr.push(this.combineRegex(array[i][0], array[i][1])); } else { arr.push(array[i]); } } return arr; } }; $P.processTimeObject = function (obj) { var date, dayOffset; utils.setDefaults(obj); dayOffset = ($P.isLeapYear(obj.year)) ? dayOffsets.leap : dayOffsets.standard; if (!obj.month && (obj.week || obj.dayOfYear)) { utils.getDayOfYear(obj, dayOffset); } else { obj.dayOfYear = dayOffset[obj.month] + obj.day; } date = new Date(obj.year, obj.month, obj.day, obj.hours, obj.minutes, obj.seconds, obj.milliseconds); if (obj.zone) { utils.adjustForTimeZone(obj, date); // adjust (and calculate) for timezone } return date; }; $P.ISO = { regex : /^([\+-]?\d{4}(?!\d{2}\b))((-?)((0[1-9]|1[0-2])(\3([12]\d|0[1-9]|3[01]))?|W([0-4]\d|5[0-3])(-?[1-7])?|(00[1-9]|0[1-9]\d|[12]\d{2}|3([0-5]\d|6[1-6])))([T\s]((([01]\d|2[0-4])((:?)[0-5]\d)?|24\:?00)([\.,]\d+(?!:))?)?(\17[0-5]\d([\.,]\d+)?)?\s?([zZ]|([\+-])([01]\d|2[0-3]):?([0-5]\d)?)?)?)?$/, parse : function (s) { var time, data = s.match(this.regex); if (!data || !data.length) { return null; } time = utils.buildTimeObjectFromData(data); if (!time.year || (!time.year && (!time.month && !time.day) && (!time.week && !time.dayOfYear)) ) { return null; } return $P.processTimeObject(time); } }; $P.Numeric = { isNumeric: function (e){return!isNaN(parseFloat(e))&&isFinite(e);}, regex: /\b([0-1]?[0-9])([0-3]?[0-9])([0-2]?[0-9]?[0-9][0-9])\b/i, parse: function (s) { var data, i, time = {}, order = Date.CultureInfo.dateElementOrder.split(""); if (!(this.isNumeric(s)) || // if it's non-numeric OR (s[0] === "+" && s[0] === "-")) { // It's an arithmatic string (eg +/-1000) return null; } if (s.length < 5 && s.indexOf(".") < 0 && s.indexOf("/") < 0) { // assume it's just a year. time.year = s; return $P.processTimeObject(time); } data = s.match(this.regex); if (!data || !data.length) { return null; } for (i=0; i < order.length; i++) { switch(order[i]) { case "d": time.day = data[i+1]; break; case "m": time.month = (data[i+1]-1); break; case "y": time.year = data[i+1]; break; } } return $P.processTimeObject(time); } }; $P.Normalizer = { regexData: function () { var $R = Date.CultureInfo.regexPatterns; return utils.buildRegexData([ $R.tomorrow, $R.yesterday, [$R.past, $R.mon], [$R.past, $R.tue], [$R.past, $R.wed], [$R.past, $R.thu], [$R.past, $R.fri], [$R.past, $R.sat], [$R.past, $R.sun] ]); }, basicReplaceHash : function() { var $R = Date.CultureInfo.regexPatterns; return { "January": $R.jan.source, "February": $R.feb, "March": $R.mar, "April": $R.apr, "May": $R.may, "June": $R.jun, "July": $R.jul, "August": $R.aug, "September": $R.sep, "October": $R.oct, "November": $R.nov, "December": $R.dec, "": /\bat\b/gi, " ": /\s{2,}/, "am": $R.inTheMorning, "9am": $R.thisMorning, "pm": $R.inTheEvening, "7pm":$R.thisEvening }; }, keys : function(){ return [ utils.getDateNthString(true, false, 1), // tomorrow utils.getDateNthString(true, false, -1), // yesterday utils.getDateNthString(false, true, "monday"), //last mon utils.getDateNthString(false, true, "tuesday"), //last tues utils.getDateNthString(false, true, "wednesday"), //last wed utils.getDateNthString(false, true, "thursday"), //last thurs utils.getDateNthString(false, true, "friday"), //last fri utils.getDateNthString(false, true, "saturday"), //last sat utils.getDateNthString(false, true, "sunday") //last sun ]; }, buildRegexFunctions: function () { var $R = Date.CultureInfo.regexPatterns; var __ = Date.i18n.__; var tomorrowRE = new RegExp("(\\b\\d\\d?("+__("AM")+"|"+__("PM")+")? )("+$R.tomorrow.source.slice(1)+")", "i"); // adapted tomorrow regex for AM PM relative dates var todayRE = new RegExp($R.today.source + "(?!\\s*([+-]))\\b"); // today, but excludes the math operators (eg "today + 2h") this.replaceFuncs = [ [todayRE, function (full) { return (full.length > 1) ? Date.today().toString("d") : full; }], [tomorrowRE, function(full, m1) { var t = Date.today().addDays(1).toString("d"); return (t + " " + m1); }], [$R.amThisMorning, function(str, am){return am;}], [$R.pmThisEvening, function(str, pm){return pm;}] ]; }, buildReplaceData: function () { this.buildRegexFunctions(); this.replaceHash = utils.addToHash(this.basicReplaceHash(), this.keys(), this.regexData()); }, stringReplaceFuncs: function (s) { for (var i=0; i < this.replaceFuncs.length; i++) { s = s.replace(this.replaceFuncs[i][0], this.replaceFuncs[i][1]); } return s; }, parse: function (s) { s = this.stringReplaceFuncs(s); s = utils.multiReplace(s, this.replaceHash); try { var n = s.split(/([\s\-\.\,\/\x27]+)/); if (n.length === 3 && $P.Numeric.isNumeric(n[0]) && $P.Numeric.isNumeric(n[2]) && (n[2].length >= 4)) { // ok, so we're dealing with x/year. But that's not a full date. // This fixes wonky dateElementOrder parsing when set to dmy order. if (Date.CultureInfo.dateElementOrder[0] === "d") { s = "1/" + n[0] + "/" + n[2]; // set to 1st of month and normalize the seperator } } } catch (e) {} return s; } }; $P.Normalizer.buildReplaceData(); }()); (function () { var $P = Date.Parsing; var _ = $P.Operators = { // // Tokenizers // rtoken: function (r) { // regex token return function (s) { var mx = s.match(r); if (mx) { return ([ mx[0], s.substring(mx[0].length) ]); } else { throw new $P.Exception(s); } }; }, token: function () { // whitespace-eating token return function (s) { return _.rtoken(new RegExp("^\\s*" + s + "\\s*"))(s); }; }, stoken: function (s) { // string token return _.rtoken(new RegExp("^" + s)); }, // Atomic Operators until: function (p) { return function (s) { var qx = [], rx = null; while (s.length) { try { rx = p.call(this, s); } catch (e) { qx.push(rx[0]); s = rx[1]; continue; } break; } return [ qx, s ]; }; }, many: function (p) { return function (s) { var rx = [], r = null; while (s.length) { try { r = p.call(this, s); } catch (e) { return [ rx, s ]; } rx.push(r[0]); s = r[1]; } return [ rx, s ]; }; }, // generator operators -- see below optional: function (p) { return function (s) { var r = null; try { r = p.call(this, s); } catch (e) { return [ null, s ]; } return [ r[0], r[1] ]; }; }, not: function (p) { return function (s) { try { p.call(this, s); } catch (e) { return [null, s]; } throw new $P.Exception(s); }; }, ignore: function (p) { return p ? function (s) { var r = null; r = p.call(this, s); return [null, r[1]]; } : null; }, product: function () { var px = arguments[0], qx = Array.prototype.slice.call(arguments, 1), rx = []; for (var i = 0 ; i < px.length ; i++) { rx.push(_.each(px[i], qx)); } return rx; }, cache: function (rule) { var cache = {}, cache_length = 0, cache_keys = [], CACHE_MAX = Date.Config.CACHE_MAX || 100000, r = null; var cacheCheck = function () { if (cache_length === CACHE_MAX) { // kill several keys, don't want to have to do this all the time... for (var i=0; i < 10; i++) { var key = cache_keys.shift(); if (key) { delete cache[key]; cache_length--; } } } }; return function (s) { cacheCheck(); try { r = cache[s] = (cache[s] || rule.call(this, s)); } catch (e) { r = cache[s] = e; } cache_length++; cache_keys.push(s); if (r instanceof $P.Exception) { throw r; } else { return r; } }; }, // vector operators -- see below any: function () { var px = arguments; return function (s) { var r = null; for (var i = 0; i < px.length; i++) { if (px[i] == null) { continue; } try { r = (px[i].call(this, s)); } catch (e) { r = null; } if (r) { return r; } } throw new $P.Exception(s); }; }, each: function () { var px = arguments; return function (s) { var rx = [], r = null; for (var i = 0; i < px.length ; i++) { if (px[i] == null) { continue; } try { r = (px[i].call(this, s)); } catch (e) { throw new $P.Exception(s); } rx.push(r[0]); s = r[1]; } return [ rx, s]; }; }, all: function () { var px = arguments, _ = _; return _.each(_.optional(px)); }, // delimited operators sequence: function (px, d, c) { d = d || _.rtoken(/^\s*/); c = c || null; if (px.length === 1) { return px[0]; } return function (s) { var r = null, q = null; var rx = []; for (var i = 0; i < px.length ; i++) { try { r = px[i].call(this, s); } catch (e) { break; } rx.push(r[0]); try { q = d.call(this, r[1]); } catch (ex) { q = null; break; } s = q[1]; } if (!r) { throw new $P.Exception(s); } if (q) { throw new $P.Exception(q[1]); } if (c) { try { r = c.call(this, r[1]); } catch (ey) { throw new $P.Exception(r[1]); } } return [ rx, (r?r[1]:s) ]; }; }, // // Composite Operators // between: function (d1, p, d2) { d2 = d2 || d1; var _fn = _.each(_.ignore(d1), p, _.ignore(d2)); return function (s) { var rx = _fn.call(this, s); return [[rx[0][0], r[0][2]], rx[1]]; }; }, list: function (p, d, c) { d = d || _.rtoken(/^\s*/); c = c || null; return (p instanceof Array ? _.each(_.product(p.slice(0, -1), _.ignore(d)), p.slice(-1), _.ignore(c)) : _.each(_.many(_.each(p, _.ignore(d))), px, _.ignore(c))); }, set: function (px, d, c) { d = d || _.rtoken(/^\s*/); c = c || null; return function (s) { // r is the current match, best the current 'best' match // which means it parsed the most amount of input var r = null, p = null, q = null, rx = null, best = [[], s], last = false; // go through the rules in the given set for (var i = 0; i < px.length ; i++) { // last is a flag indicating whether this must be the last element // if there is only 1 element, then it MUST be the last one q = null; p = null; r = null; last = (px.length === 1); // first, we try simply to match the current pattern // if not, try the next pattern try { r = px[i].call(this, s); } catch (e) { continue; } // since we are matching against a set of elements, the first // thing to do is to add r[0] to matched elements rx = [[r[0]], r[1]]; // if we matched and there is still input to parse and // we don't already know this is the last element, // we're going to next check for the delimiter ... // if there's none, or if there's no input left to parse // than this must be the last element after all ... if (r[1].length > 0 && ! last) { try { q = d.call(this, r[1]); } catch (ex) { last = true; } } else { last = true; } // if we parsed the delimiter and now there's no more input, // that means we shouldn't have parsed the delimiter at all // so don't update r and mark this as the last element ... if (!last && q[1].length === 0) { last = true; } // so, if this isn't the last element, we're going to see if // we can get any more matches from the remaining (unmatched) // elements ... if (!last) { // build a list of the remaining rules we can match against, // i.e., all but the one we just matched against var qx = []; for (var j = 0; j < px.length ; j++) { if (i !== j) { qx.push(px[j]); } } // now invoke recursively set with the remaining input // note that we don't include the closing delimiter ... // we'll check for that ourselves at the end p = _.set(qx, d).call(this, q[1]); // if we got a non-empty set as a result ... // (otw rx already contains everything we want to match) if (p[0].length > 0) { // update current result, which is stored in rx ... // basically, pick up the remaining text from p[1] // and concat the result from p[0] so that we don't // get endless nesting ... rx[0] = rx[0].concat(p[0]); rx[1] = p[1]; } } // at this point, rx either contains the last matched element // or the entire matched set that starts with this element. // now we just check to see if this variation is better than // our best so far, in terms of how much of the input is parsed if (rx[1].length < best[1].length) { best = rx; } // if we've parsed all the input, then we're finished if (best[1].length === 0) { break; } } // so now we've either gone through all the patterns trying them // as the initial match; or we found one that parsed the entire // input string ... // if best has no matches, just return empty set ... if (best[0].length === 0) { return best; } // if a closing delimiter is provided, then we have to check it also if (c) { // we try this even if there is no remaining input because the pattern // may well be optional or match empty input ... try { q = c.call(this, best[1]); } catch (ey) { throw new $P.Exception(best[1]); } // it parsed ... be sure to update the best match remaining input best[1] = q[1]; } // if we're here, either there was no closing delimiter or we parsed it // so now we have the best match; just return it! return best; }; }, forward: function (gr, fname) { return function (s) { return gr[fname].call(this, s); }; }, // // Translation Operators // replace: function (rule, repl) { return function (s) { var r = rule.call(this, s); return [repl, r[1]]; }; }, process: function (rule, fn) { return function (s) { var r = rule.call(this, s); return [fn.call(this, r[0]), r[1]]; }; }, min: function (min, rule) { return function (s) { var rx = rule.call(this, s); if (rx[0].length < min) { throw new $P.Exception(s); } return rx; }; } }; // Generator Operators And Vector Operators // Generators are operators that have a signature of F(R) => R, // taking a given rule and returning another rule, such as // ignore, which parses a given rule and throws away the result. // Vector operators are those that have a signature of F(R1,R2,...) => R, // take a list of rules and returning a new rule, such as each. // Generator operators are converted (via the following _generator // function) into functions that can also take a list or array of rules // and return an array of new rules as though the function had been // called on each rule in turn (which is what actually happens). // This allows generators to be used with vector operators more easily. // Example: // each(ignore(foo, bar)) instead of each(ignore(foo), ignore(bar)) // This also turns generators into vector operators, which allows // constructs like: // not(cache(foo, bar)) var _generator = function (op) { function gen() { var args = null, rx = [], px, i; if (arguments.length > 1) { args = Array.prototype.slice.call(arguments); } else if (arguments[0] instanceof Array) { args = arguments[0]; } if (args) { px = args.shift(); if (px.length > 0) { args.unshift(px[i]); rx.push(op.apply(null, args)); args.shift(); return rx; } } else { return op.apply(null, arguments); } } return gen; }; var gx = "optional not ignore cache".split(/\s/); for (var i = 0 ; i < gx.length ; i++) { _[gx[i]] = _generator(_[gx[i]]); } var _vector = function (op) { return function () { if (arguments[0] instanceof Array) { return op.apply(null, arguments[0]); } else { return op.apply(null, arguments); } }; }; var vx = "each any all".split(/\s/); for (var j = 0 ; j < vx.length ; j++) { _[vx[j]] = _vector(_[vx[j]]); } }()); (function () { var $D = Date; var flattenAndCompact = function (ax) { var rx = []; for (var i = 0; i < ax.length; i++) { if (ax[i] instanceof Array) { rx = rx.concat(flattenAndCompact(ax[i])); } else { if (ax[i]) { rx.push(ax[i]); } } } return rx; }; var parseMeridian = function () { if (this.meridian && (this.hour || this.hour === 0)) { if (this.meridian === "a" && this.hour > 11 && Date.Config.strict24hr){ throw "Invalid hour and meridian combination"; } else if (this.meridian === "p" && this.hour < 12 && Date.Config.strict24hr){ throw "Invalid hour and meridian combination"; } else if (this.meridian === "p" && this.hour < 12) { this.hour = this.hour + 12; } else if (this.meridian === "a" && this.hour === 12) { this.hour = 0; } } }; var setDefaults = function () { var now = new Date(); if ((this.hour || this.minute) && (!this.month && !this.year && !this.day)) { this.day = now.getDate(); } if (!this.year) { this.year = now.getFullYear(); } if (!this.month && this.month !== 0) { this.month = now.getMonth(); } if (!this.day) { this.day = 1; } if (!this.hour) { this.hour = 0; } if (!this.minute) { this.minute = 0; } if (!this.second) { this.second = 0; } if (!this.millisecond) { this.millisecond = 0; } }; var finishUtils = { getToday: function () { if (this.now || "hour minute second".indexOf(this.unit) !== -1) { return new Date(); } else { return $D.today(); } }, setDaysFromWeekday: function (today, orient){ var gap; orient = orient || 1; this.unit = "day"; gap = ($D.getDayNumberFromName(this.weekday) - today.getDay()); this.days = gap ? ((gap + (orient * 7)) % 7) : (orient * 7); return this; }, setMonthsFromMonth: function (today, orient) { var gap; orient = orient || 1; this.unit = "month"; gap = (this.month - today.getMonth()); this.months = gap ? ((gap + (orient * 12)) % 12) : (orient * 12); this.month = null; return this; }, setDMYFromWeekday: function () { var d = Date[this.weekday](); this.day = d.getDate(); if (!this.month) { this.month = d.getMonth(); } this.year = d.getFullYear(); return this; }, setUnitValue: function (orient) { if (!this.value && this.operator && this.operator !== null && this[this.unit + "s"] && this[this.unit + "s"] !== null) { this[this.unit + "s"] = this[this.unit + "s"] + ((this.operator === "add") ? 1 : -1) + (this.value||0) * orient; } else if (this[this.unit + "s"] == null || this.operator != null) { if (!this.value) { this.value = 1; } this[this.unit + "s"] = this.value * orient; } }, generateDateFromWeeks: function () { var weekday = (this.weekday !== undefined) ? this.weekday : "today"; var d = Date[weekday]().addWeeks(this.weeks); if (this.now) { d.setTimeToNow(); } return d; } }; $D.Translator = { hour: function (s) { return function () { this.hour = Number(s); }; }, minute: function (s) { return function () { this.minute = Number(s); }; }, second: function (s) { return function () { this.second = Number(s); }; }, /* for ss.s format */ secondAndMillisecond: function (s) { return function () { var mx = s.match(/^([0-5][0-9])\.([0-9]{1,3})/); this.second = Number(mx[1]); this.millisecond = Number(mx[2]); }; }, meridian: function (s) { return function () { this.meridian = s.slice(0, 1).toLowerCase(); }; }, timezone: function (s) { return function () { var n = s.replace(/[^\d\+\-]/g, ""); if (n.length) { this.timezoneOffset = Number(n); } else { this.timezone = s.toLowerCase(); } }; }, day: function (x) { var s = x[0]; return function () { this.day = Number(s.match(/\d+/)[0]); if (this.day < 1) { throw "invalid day"; } }; }, month: function (s) { return function () { this.month = (s.length === 3) ? "jan feb mar apr may jun jul aug sep oct nov dec".indexOf(s)/4 : Number(s) - 1; if (this.month < 0) { throw "invalid month"; } }; }, year: function (s) { return function () { var n = Number(s); this.year = ((s.length > 2) ? n : (n + (((n + 2000) < Date.CultureInfo.twoDigitYearMax) ? 2000 : 1900))); }; }, rday: function (s) { return function () { switch (s) { case "yesterday": this.days = -1; break; case "tomorrow": this.days = 1; break; case "today": this.days = 0; break; case "now": this.days = 0; this.now = true; break; } }; }, finishExact: function (x) { var d; x = (x instanceof Array) ? x : [x]; for (var i = 0 ; i < x.length ; i++) { if (x[i]) { x[i].call(this); } } setDefaults.call(this); parseMeridian.call(this); if (this.day > $D.getDaysInMonth(this.year, this.month)) { throw new RangeError(this.day + " is not a valid value for days."); } d = new Date(this.year, this.month, this.day, this.hour, this.minute, this.second, this.millisecond); if (this.year < 100) { d.setFullYear(this.year); // means years less that 100 are process correctly. JS will parse it otherwise as 1900-1999. } if (this.timezone) { d.set({ timezone: this.timezone }); } else if (this.timezoneOffset) { d.set({ timezoneOffset: this.timezoneOffset }); } return d; }, finish: function (x) { var today, expression, orient, temp; x = (x instanceof Array) ? flattenAndCompact(x) : [ x ]; if (x.length === 0) { return null; } for (var i = 0 ; i < x.length ; i++) { if (typeof x[i] === "function") { x[i].call(this); } } if (this.now && !this.unit && !this.operator) { return new Date(); } else { today = finishUtils.getToday.call(this); } expression = !!(this.days && this.days !== null || this.orient || this.operator); orient = ((this.orient === "past" || this.operator === "subtract") ? -1 : 1); if (this.month && this.unit === "week") { this.value = this.month + 1; delete this.month; delete this.day; } if ((this.month || this.month === 0) && "year day hour minute second".indexOf(this.unit) !== -1) { if (!this.value) { this.value = this.month + 1; } this.month = null; expression = true; } if (!expression && this.weekday && !this.day && !this.days) { finishUtils.setDMYFromWeekday.call(this); } if (expression && this.weekday && this.unit !== "month" && this.unit !== "week") { finishUtils.setDaysFromWeekday.call(this, today, orient); } if (this.weekday && this.unit !== "week" && !this.day && !this.days) { temp = Date[this.weekday](); this.day = temp.getDate(); if (temp.getMonth() !== today.getMonth()) { this.month = temp.getMonth(); } } if (this.month && this.unit === "day" && this.operator) { if (!this.value) { this.value = (this.month + 1); } this.month = null; } if (this.value != null && this.month != null && this.year != null) { this.day = this.value * 1; } if (this.month && !this.day && this.value) { today.set({ day: this.value * 1 }); if (!expression) { this.day = this.value * 1; } } if (!this.month && this.value && this.unit === "month" && !this.now) { this.month = this.value; expression = true; } if (expression && (this.month || this.month === 0) && this.unit !== "year") { finishUtils.setMonthsFromMonth.call(this, today, orient); } if (!this.unit) { this.unit = "day"; } finishUtils.setUnitValue.call(this, orient); parseMeridian.call(this); if ((this.month || this.month === 0) && !this.day) { this.day = 1; } if (!this.orient && !this.operator && this.unit === "week" && this.value && !this.day && !this.month) { return Date.today().setWeek(this.value); } if (this.unit === "week" && this.weeks && !this.day && !this.month) { return finishUtils.generateDateFromWeeks.call(this); } if (expression && this.timezone && this.day && this.days) { this.day = this.days; } if (expression){ today.add(this); } else { today.set(this); } if (this.timezone) { this.timezone = this.timezone.toUpperCase(); var offset = $D.getTimezoneOffset(this.timezone); var timezone; if (today.hasDaylightSavingTime()) { // lets check that we're being sane with timezone setting timezone = $D.getTimezoneAbbreviation(offset, today.isDaylightSavingTime()); if (timezone !== this.timezone) { // bugger, we're in a place where things like EST vs EDT matters. if (today.isDaylightSavingTime()) { today.addHours(-1); } else { today.addHours(1); } } } today.setTimezoneOffset(offset); } return today; } }; }()); (function () { var $D = Date; $D.Grammar = {}; var _ = $D.Parsing.Operators, g = $D.Grammar, t = $D.Translator, _fn; // Allow rolling up into general purpose rules _fn = function () { return _.each(_.any.apply(null, arguments), _.not(g.ctoken2("timeContext"))); }; g.datePartDelimiter = _.rtoken(/^([\s\-\.\,\/\x27]+)/); g.timePartDelimiter = _.stoken(":"); g.whiteSpace = _.rtoken(/^\s*/); g.generalDelimiter = _.rtoken(/^(([\s\,]|at|@|on)+)/); var _C = {}; g.ctoken = function (keys) { var fn = _C[keys]; if (! fn) { var c = Date.CultureInfo.regexPatterns; var kx = keys.split(/\s+/), px = []; for (var i = 0; i < kx.length ; i++) { px.push(_.replace(_.rtoken(c[kx[i]]), kx[i])); } fn = _C[keys] = _.any.apply(null, px); } return fn; }; g.ctoken2 = function (key) { return _.rtoken(Date.CultureInfo.regexPatterns[key]); }; var cacheProcessRtoken = function (key, token, type, eachToken) { if (eachToken) { g[key] = _.cache(_.process(_.each(_.rtoken(token),_.optional(g.ctoken2(eachToken))), type)); } else { g[key] = _.cache(_.process(_.rtoken(token), type)); } }; var cacheProcessCtoken = function (token, type) { return _.cache(_.process(g.ctoken2(token), type)); }; var _F = {}; //function cache var _get = function (f) { _F[f] = (_F[f] || g.format(f)[0]); return _F[f]; }; g.allformats = function (fx) { var rx = []; if (fx instanceof Array) { for (var i = 0; i < fx.length; i++) { rx.push(_get(fx[i])); } } else { rx.push(_get(fx)); } return rx; }; g.formats = function (fx) { if (fx instanceof Array) { var rx = []; for (var i = 0 ; i < fx.length ; i++) { rx.push(_get(fx[i])); } return _.any.apply(null, rx); } else { return _get(fx); } }; var grammarFormats = { timeFormats: function(){ var i, RTokenKeys = [ "h", "hh", "H", "HH", "m", "mm", "s", "ss", "ss.s", "z", "zz" ], RToken = [ /^(0[0-9]|1[0-2]|[1-9])/, /^(0[0-9]|1[0-2])/, /^([0-1][0-9]|2[0-3]|[0-9])/, /^([0-1][0-9]|2[0-3])/, /^([0-5][0-9]|[0-9])/, /^[0-5][0-9]/, /^([0-5][0-9]|[0-9])/, /^[0-5][0-9]/, /^[0-5][0-9]\.[0-9]{1,3}/, /^((\+|\-)\s*\d\d\d\d)|((\+|\-)\d\d\:?\d\d)/, /^((\+|\-)\s*\d\d\d\d)|((\+|\-)\d\d\:?\d\d)/ ], tokens = [ t.hour, t.hour, t.hour, t.hour, t.minute, t.minute, t.second, t.second, t.secondAndMillisecond, t.timezone, t.timezone ]; for (i=0; i < RTokenKeys.length; i++) { cacheProcessRtoken(RTokenKeys[i], RToken[i], tokens[i]); } g.hms = _.cache(_.sequence([g.H, g.m, g.s], g.timePartDelimiter)); g.t = cacheProcessCtoken("shortMeridian", t.meridian); g.tt = cacheProcessCtoken("longMeridian", t.meridian); g.zzz = cacheProcessCtoken("timezone", t.timezone); g.timeSuffix = _.each(_.ignore(g.whiteSpace), _.set([ g.tt, g.zzz ])); g.time = _.each(_.optional(_.ignore(_.stoken("T"))), g.hms, g.timeSuffix); }, dateFormats: function () { // pre-loaded rules for different date part order preferences var _setfn = function () { return _.set(arguments, g.datePartDelimiter); }; var i, RTokenKeys = [ "d", "dd", "M", "MM", "y", "yy", "yyy", "yyyy" ], RToken = [ /^([0-2]\d|3[0-1]|\d)/, /^([0-2]\d|3[0-1])/, /^(1[0-2]|0\d|\d)/, /^(1[0-2]|0\d)/, /^(\d+)/, /^(\d\d)/, /^(\d\d?\d?\d?)/, /^(\d\d\d\d)/ ], tokens = [ t.day, t.day, t.month, t.month, t.year, t.year, t.year, t.year ], eachToken = [ "ordinalSuffix", "ordinalSuffix" ]; for (i=0; i < RTokenKeys.length; i++) { cacheProcessRtoken(RTokenKeys[i], RToken[i], tokens[i], eachToken[i]); } g.MMM = g.MMMM = _.cache(_.process(g.ctoken("jan feb mar apr may jun jul aug sep oct nov dec"), t.month)); g.ddd = g.dddd = _.cache(_.process(g.ctoken("sun mon tue wed thu fri sat"), function (s) { return function () { this.weekday = s; }; } )); g.day = _fn(g.d, g.dd); g.month = _fn(g.M, g.MMM); g.year = _fn(g.yyyy, g.yy); g.mdy = _setfn(g.ddd, g.month, g.day, g.year); g.ymd = _setfn(g.ddd, g.year, g.month, g.day); g.dmy = _setfn(g.ddd, g.day, g.month, g.year); g.date = function (s) { return ((g[Date.CultureInfo.dateElementOrder] || g.mdy).call(this, s)); }; }, relative: function () { // relative date / time expressions g.orientation = _.process(g.ctoken("past future"), function (s) { return function () { this.orient = s; }; } ); g.operator = _.process(g.ctoken("add subtract"), function (s) { return function () { this.operator = s; }; } ); g.rday = _.process(g.ctoken("yesterday tomorrow today now"), t.rday); g.unit = _.process(g.ctoken("second minute hour day week month year"), function (s) { return function () { this.unit = s; }; } ); } }; g.buildGrammarFormats = function () { // these need to be rebuilt every time the language changes. _C = {}; grammarFormats.timeFormats(); grammarFormats.dateFormats(); grammarFormats.relative(); g.value = _.process(_.rtoken(/^([-+]?\d+)?(st|nd|rd|th)?/), function (s) { return function () { this.value = s.replace(/\D/g, ""); }; } ); g.expression = _.set([g.rday, g.operator, g.value, g.unit, g.orientation, g.ddd, g.MMM ]); g.format = _.process(_.many( _.any( // translate format specifiers into grammar rules _.process( _.rtoken(/^(dd?d?d?(?!e)|MM?M?M?|yy?y?y?|hh?|HH?|mm?|ss?|tt?|zz?z?)/), function (fmt) { if (g[fmt]) { return g[fmt]; } else { throw $D.Parsing.Exception(fmt); } } ), // translate separator tokens into token rules _.process(_.rtoken(/^[^dMyhHmstz]+/), // all legal separators function (s) { return _.ignore(_.stoken(s)); } ) ) ), // construct the parser ... function (rules) { return _.process(_.each.apply(null, rules), t.finishExact); } ); // starting rule for general purpose grammar g._start = _.process(_.set([ g.date, g.time, g.expression ], g.generalDelimiter, g.whiteSpace), t.finish); }; g.buildGrammarFormats(); // parsing date format specifiers - ex: "h:m:s tt" // this little guy will generate a custom parser based // on the format string, ex: g.format("h:m:s tt") // check for these formats first g._formats = g.formats([ "\"yyyy-MM-ddTHH:mm:ssZ\"", "yyyy-MM-ddTHH:mm:ss.sz", "yyyy-MM-ddTHH:mm:ssZ", "yyyy-MM-ddTHH:mm:ssz", "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-ddTHH:mmZ", "yyyy-MM-ddTHH:mmz", "yyyy-MM-ddTHH:mm", "ddd, MMM dd, yyyy H:mm:ss tt", "ddd MMM d yyyy HH:mm:ss zzz", "MMddyyyy", "ddMMyyyy", "Mddyyyy", "ddMyyyy", "Mdyyyy", "dMyyyy", "yyyy", "Mdyy", "dMyy", "d" ]); // real starting rule: tries selected formats first, // then general purpose rule g.start = function (s) { try { var r = g._formats.call({}, s); if (r[1].length === 0) { return r; } } catch (e) {} return g._start.call({}, s); }; }()); (function () { var $D = Date; /** * @desc Converts the specified string value into its JavaScript Date equivalent using CultureInfo specific format information. * * Example

	///////////
	// Dates //
	///////////

	// 15-Oct-2004
	var d1 = Date.parse("10/15/2004");

	// 15-Oct-2004
	var d1 = Date.parse("15-Oct-2004");

	// 15-Oct-2004
	var d1 = Date.parse("2004.10.15");

	//Fri Oct 15, 2004
	var d1 = Date.parse("Fri Oct 15, 2004");

	///////////
	// Times //
	///////////

	// Today at 10 PM.
	var d1 = Date.parse("10 PM");

	// Today at 10:30 PM.
	var d1 = Date.parse("10:30 P.M.");

	// Today at 6 AM.
	var d1 = Date.parse("06am");

	/////////////////////
	// Dates and Times //
	/////////////////////

	// 8-July-2004 @ 10:30 PM
	var d1 = Date.parse("July 8th, 2004, 10:30 PM");

	// 1-July-2004 @ 10:30 PM
	var d1 = Date.parse("2004-07-01T22:30:00");

	////////////////////
	// Relative Dates //
	////////////////////

	// Returns today's date. The string "today" is culture specific.
	var d1 = Date.parse("today");

	// Returns yesterday's date. The string "yesterday" is culture specific.
	var d1 = Date.parse("yesterday");

	// Returns the date of the next thursday.
	var d1 = Date.parse("Next thursday");

	// Returns the date of the most previous monday.
	var d1 = Date.parse("last monday");

	// Returns today's day + one year.
	var d1 = Date.parse("next year");

	///////////////
	// Date Math //
	///////////////

	// Today + 2 days
	var d1 = Date.parse("t+2");

	// Today + 2 days
	var d1 = Date.parse("today + 2 days");

	// Today + 3 months
	var d1 = Date.parse("t+3m");

	// Today - 1 year
	var d1 = Date.parse("today - 1 year");

	// Today - 1 year
	var d1 = Date.parse("t-1y"); 


	/////////////////////////////
	// Partial Dates and Times //
	/////////////////////////////

	// July 15th of this year.
	var d1 = Date.parse("July 15");

	// 15th day of current day and year.
	var d1 = Date.parse("15");

	// July 1st of current year at 10pm.
	var d1 = Date.parse("7/1 10pm");
	
* * @param {String} The string value to convert into a Date object [Required] * @return {Date} A Date object or null if the string cannot be converted into a Date. */ var parseUtils = { removeOrds: function (s) { ords = s.match(/\b(\d+)(?:st|nd|rd|th)\b/); // find ordinal matches s = ((ords && ords.length === 2) ? s.replace(ords[0], ords[1]) : s); return s; }, grammarParser: function (s) { var r = null; try { r = $D.Grammar.start.call({}, s.replace(/^\s*(\S*(\s+\S+)*)\s*$/, "$1")); } catch (e) { return null; } return ((r[1].length === 0) ? r[0] : null); }, nativeFallback: function(s) { var t; try { // ok we haven't parsed it, last ditch attempt with the built-in parser. t = Date._parse(s); return (t || t === 0) ? new Date(t) : null; } catch (e) { return null; } } }; function parse (s) { var d; if (!s) { return null; } if (s instanceof Date) { return s.clone(); } if (s.length >= 4 && s.charAt(0) !== "0" && s.charAt(0) !== "+"&& s.charAt(0) !== "-") { // ie: 2004 will pass, 0800 won't. // Start with specific formats d = $D.Parsing.ISO.parse(s) || $D.Parsing.Numeric.parse(s); } if (d instanceof Date && !isNaN(d.getTime())) { return d; } else { // find ordinal dates (1st, 3rd, 8th, etc and remove them as they cause parsing issues) s = $D.Parsing.Normalizer.parse(parseUtils.removeOrds(s)); d = parseUtils.grammarParser(s); if (d !== null) { return d; } else { return parseUtils.nativeFallback(s); } } } if (!$D._parse) { $D._parse = $D.parse; } $D.parse = parse; Date.getParseFunction = function (fx) { var fns = Date.Grammar.allformats(fx); return function (s) { var r = null; for (var i = 0; i < fns.length; i++) { try { r = fns[i].call({}, s); } catch (e) { continue; } if (r[1].length === 0) { return r[0]; } } return null; }; }; /** * Converts the specified string value into its JavaScript Date equivalent using the specified format {String} or formats {Array} and the CultureInfo specific format information. * The format of the string value must match one of the supplied formats exactly. * * Example

	// 15-Oct-2004
	var d1 = Date.parseExact("10/15/2004", "M/d/yyyy");

	// 15-Oct-2004
	var d1 = Date.parse("15-Oct-2004", "M-ddd-yyyy");

	// 15-Oct-2004
	var d1 = Date.parse("2004.10.15", "yyyy.MM.dd");

	// Multiple formats
	var d1 = Date.parseExact("10/15/2004", ["M/d/yyyy", "MMMM d, yyyy"]);
	
* * @param {String} The string value to convert into a Date object [Required]. * @param {Object} The expected format {String} or an array of expected formats {Array} of the date string [Required]. * @return {Date} A Date object or null if the string cannot be converted into a Date. */ $D.parseExact = function (s, fx) { return $D.getParseFunction(fx)(s); }; }()); (function () { var $D = Date, $P = $D.prototype, // $C = $D.CultureInfo, // not used atm p = function (s, l) { if (!l) { l = 2; } return ("000" + s).slice(l * -1); }; /** * Converts a PHP format string to Java/.NET format string. * A PHP format string can be used with ._format or .format. * A Java/.NET format string can be used with .toString(). * The .parseExact function will only accept a Java/.NET format string * * Example * var f1 = "%m/%d/%y" * var f2 = Date.normalizeFormat(f1); // "MM/dd/yy" * * new Date().format(f1); // "04/13/08" * new Date()._format(f1); // "04/13/08" * new Date().toString(f2); // "04/13/08" * * var date = Date.parseExact("04/13/08", f2); // Sun Apr 13 2008 * * @param {String} A PHP format string consisting of one or more format spcifiers. * @return {String} The PHP format converted to a Java/.NET format string. */ var normalizerSubstitutions = { "d" : "dd", "%d": "dd", "D" : "ddd", "%a": "ddd", "j" : "dddd", "l" : "dddd", "%A": "dddd", "S" : "S", "F" : "MMMM", "%B": "MMMM", "m" : "MM", "%m": "MM", "M" : "MMM", "%b": "MMM", "%h": "MMM", "n" : "M", "Y" : "yyyy", "%Y": "yyyy", "y" : "yy", "%y": "yy", "g" : "h", "%I": "h", "G" : "H", "h" : "hh", "H" : "HH", "%H": "HH", "i" : "mm", "%M": "mm", "s" : "ss", "%S": "ss", "%r": "hh:mm tt", "%R": "H:mm", "%T": "H:mm:ss", "%X": "t", "%x": "d", "%e": "d", "%D": "MM/dd/yy", "%n": "\\n", "%t": "\\t", "e" : "z", "T" : "z", "%z": "z", "%Z": "z", "Z" : "ZZ", "N" : "u", "w" : "u", "%w": "u", "W" : "W", "%V": "W" }; var normalizer = { substitutes: function (m) { return normalizerSubstitutions[m]; }, interpreted: function (m, x) { var y; switch (m) { case "%u": return x.getDay() + 1; case "z": return x.getOrdinalNumber(); case "%j": return p(x.getOrdinalNumber(), 3); case "%U": var d1 = x.clone().set({month: 0, day: 1}).addDays(-1).moveToDayOfWeek(0), d2 = x.clone().addDays(1).moveToDayOfWeek(0, -1); return (d2 < d1) ? "00" : p((d2.getOrdinalNumber() - d1.getOrdinalNumber()) / 7 + 1); case "%W": return p(x.getWeek()); case "t": return $D.getDaysInMonth(x.getFullYear(), x.getMonth()); case "o": case "%G": return x.setWeek(x.getISOWeek()).toString("yyyy"); case "%g": return x._format("%G").slice(-2); case "a": case "%p": return t("tt").toLowerCase(); case "A": return t("tt").toUpperCase(); case "u": return p(x.getMilliseconds(), 3); case "I": return (x.isDaylightSavingTime()) ? 1 : 0; case "O": return x.getUTCOffset(); case "P": y = x.getUTCOffset(); return y.substring(0, y.length - 2) + ":" + y.substring(y.length - 2); case "B": var now = new Date(); return Math.floor(((now.getHours() * 3600) + (now.getMinutes() * 60) + now.getSeconds() + (now.getTimezoneOffset() + 60) * 60) / 86.4); case "c": return x.toISOString().replace(/\"/g, ""); case "U": return $D.strtotime("now"); case "%c": return t("d") + " " + t("t"); case "%C": return Math.floor(x.getFullYear() / 100 + 1); } }, shouldOverrideDefaults: function (m) { switch (m) { case "%e": return true; default: return false; } }, parse: function (m, context) { var formatString, c = context || new Date(); formatString = normalizer.substitutes(m); if (formatString) { return formatString; } formatString = normalizer.interpreted(m, c); if (formatString) { return formatString; } else { return m; } } }; $D.normalizeFormat = function (format, context) { return format.replace(/(%|\\)?.|%%/g, function(t){ return normalizer.parse(t, context); }); }; /** * Format a local Unix timestamp according to locale settings * * Example: * Date.strftime("%m/%d/%y", new Date()); // "04/13/08" * Date.strftime("c", "2008-04-13T17:52:03Z"); // "04/13/08" * * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @param {Number|String} The number representing the number of seconds that have elapsed since January 1, 1970 (local time). * @return {String} A string representation of the current Date object. */ $D.strftime = function (format, time) { var d = Date.parse(time); return d._format(format); }; /** * Parse any textual datetime description into a Unix timestamp. * A Unix timestamp is the number of seconds that have elapsed since January 1, 1970 (midnight UTC/GMT). * * Example: * Date.strtotime("04/13/08"); // 1208044800 * Date.strtotime("1970-01-01T00:00:00Z"); // 0 * * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @param {Object} A string or date object. * @return {String} A string representation of the current Date object. */ $D.strtotime = function (time) { var d = $D.parse(time); return Math.round($D.UTC(d.getUTCFullYear(), d.getUTCMonth(), d.getUTCDate(), d.getUTCHours(), d.getUTCMinutes(), d.getUTCSeconds(), d.getUTCMilliseconds()) / 1000); }; /** * Converts the value of the current Date object to its equivalent string representation using a PHP/Unix style of date format specifiers. * Format Specifiers * Format Description Example * ------ --------------------------------------------------------------------------- ----------------------- * %a abbreviated weekday name according to the current localed "Mon" through "Sun" * %A full weekday name according to the current localed "Sunday" through "Saturday" * %b abbreviated month name according to the current localed "Jan" through "Dec" * %B full month name according to the current locale "January" through "December" * %c preferred date and time representation for the current locale "4/13/2008 12:33 PM" * %C century number (the year divided by 100 and truncated to an integer) "00" to "99" * %d day of the month as a decimal number "01" to "31" * %D same as %m/%d/%y "04/13/08" * %e day of the month as a decimal number, a single digit is preceded by a space "1" to "31" * %g like %G, but without the century "08" * %G The 4-digit year corresponding to the ISO week number (see %V). "2008" * This has the same format and value as %Y, except that if the ISO week number * belongs to the previous or next year, that year is used instead. * %h same as %b "Jan" through "Dec" * %H hour as a decimal number using a 24-hour clock. "00" to "23" * %I hour as a decimal number using a 12-hour clock. "01" to "12" * %j day of the year as a decimal number. "001" to "366" * %m month as a decimal number. "01" to "12" * %M minute as a decimal number. "00" to "59" * %n newline character "\n" * %p either "am" or "pm" according to the given time value, or the "am" or "pm" * corresponding strings for the current locale. * %r time in a.m. and p.m. notation "8:44 PM" * %R time in 24 hour notation "20:44" * %S second as a decimal number "00" to "59" * %t tab character "\t" * %T current time, equal to %H:%M:%S "12:49:11" * %u weekday as a decimal number ["1", "7"], with "1" representing Monday "1" to "7" * %U week number of the current year as a decimal number, starting with the "0" to ("52" or "53") * first Sunday as the first day of the first week * %V The ISO 8601:1988 week number of the current year as a decimal number, "00" to ("52" or "53") * range 01 to 53, where week 1 is the first week that has at least 4 days * in the current year, and with Monday as the first day of the week. * (Use %G or %g for the year component that corresponds to the week number * for the specified timestamp.) * %W week number of the current year as a decimal number, starting with the "00" to ("52" or "53") * first Monday as the first day of the first week * %w day of the week as a decimal, Sunday being "0" "0" to "6" * %x preferred date representation for the current locale without the time "4/13/2008" * %X preferred time representation for the current locale without the date "12:53:05" * %y year as a decimal number without a century "00" "99" * %Y year as a decimal number including the century "2008" * %Z time zone or name or abbreviation "UTC", "EST", "PST" * %z same as %Z * %% a literal "%" characters "%" * d Day of the month, 2 digits with leading zeros "01" to "31" * D A textual representation of a day, three letters "Mon" through "Sun" * j Day of the month without leading zeros "1" to "31" * l A full textual representation of the day of the week (lowercase "L") "Sunday" through "Saturday" * N ISO-8601 numeric representation of the day of the week (added in PHP 5.1.0) "1" (for Monday) through "7" (for Sunday) * S English ordinal suffix for the day of the month, 2 characters "st", "nd", "rd" or "th". Works well with j * w Numeric representation of the day of the week "0" (for Sunday) through "6" (for Saturday) * z The day of the year (starting from "0") "0" through "365" * W ISO-8601 week number of year, weeks starting on Monday "00" to ("52" or "53") * F A full textual representation of a month, such as January or March "January" through "December" * m Numeric representation of a month, with leading zeros "01" through "12" * M A short textual representation of a month, three letters "Jan" through "Dec" * n Numeric representation of a month, without leading zeros "1" through "12" * t Number of days in the given month "28" through "31" * L Whether it's a leap year "1" if it is a leap year, "0" otherwise * o ISO-8601 year number. This has the same value as Y, except that if the "2008" * ISO week number (W) belongs to the previous or next year, that year * is used instead. * Y A full numeric representation of a year, 4 digits "2008" * y A two digit representation of a year "08" * a Lowercase Ante meridiem and Post meridiem "am" or "pm" * A Uppercase Ante meridiem and Post meridiem "AM" or "PM" * B Swatch Internet time "000" through "999" * g 12-hour format of an hour without leading zeros "1" through "12" * G 24-hour format of an hour without leading zeros "0" through "23" * h 12-hour format of an hour with leading zeros "01" through "12" * H 24-hour format of an hour with leading zeros "00" through "23" * i Minutes with leading zeros "00" to "59" * s Seconds, with leading zeros "00" through "59" * u Milliseconds "54321" * e Timezone identifier "UTC", "EST", "PST" * I Whether or not the date is in daylight saving time (uppercase i) "1" if Daylight Saving Time, "0" otherwise * O Difference to Greenwich time (GMT) in hours "+0200", "-0600" * P Difference to Greenwich time (GMT) with colon between hours and minutes "+02:00", "-06:00" * T Timezone abbreviation "UTC", "EST", "PST" * Z Timezone offset in seconds. The offset for timezones west of UTC is "-43200" through "50400" * always negative, and for those east of UTC is always positive. * c ISO 8601 date "2004-02-12T15:19:21+00:00" * r RFC 2822 formatted date "Thu, 21 Dec 2000 16:01:07 +0200" * U Seconds since the Unix Epoch (January 1 1970 00:00:00 GMT) "0" * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @return {String} A string representation of the current Date object. */ var formatReplace = function (context) { return function (m) { var formatString, override = false; if (m.charAt(0) === "\\" || m.substring(0, 2) === "%%") { return m.replace("\\", "").replace("%%", "%"); } override = normalizer.shouldOverrideDefaults(m); formatString = $D.normalizeFormat(m, context); if (formatString) { return context.toString(formatString, override); } }; }; $P._format = function (format) { var formatter = formatReplace(this); if (!format) { return this._toString(); } else { return format.replace(/(%|\\)?.|%%/g, formatter); } }; if (!$P.format) { $P.format = $P._format; } }()); (function () { "use strict"; var gFn = function (attr) { return function () { return this[attr]; }; }; var sFn = function (attr) { return function (val) { this[attr] = val; return this; }; }; var attrs = ["years", "months", "days", "hours", "minutes", "seconds", "milliseconds"]; var addSetFuncs = function (context, attrs) { for (var i = 0; i < attrs.length ; i++) { var $a = attrs[i], $b = $a.slice(0, 1).toUpperCase() + $a.slice(1); context.prototype[$a] = 0; context.prototype["get" + $b] = gFn($a); context.prototype["set" + $b] = sFn($a); } }; /** * new TimeSpan(milliseconds); * new TimeSpan(days, hours, minutes, seconds); * new TimeSpan(days, hours, minutes, seconds, milliseconds); */ var TimeSpan = function (days, hours, minutes, seconds, milliseconds) { if (arguments.length === 1 && typeof days === "number") { var orient = (days < 0) ? -1 : +1; var millsLeft = Math.abs(days); this.setDays(Math.floor(millsLeft / 86400000) * orient); millsLeft = millsLeft % 86400000; this.setHours(Math.floor(millsLeft / 3600000) * orient); millsLeft = millsLeft % 3600000; this.setMinutes(Math.floor(millsLeft / 60000) * orient); millsLeft = millsLeft % 60000; this.setSeconds(Math.floor(millsLeft / 1000) * orient); millsLeft = millsLeft % 1000; this.setMilliseconds(millsLeft * orient); } else { this.set(days, hours, minutes, seconds, milliseconds); } this.getTotalMilliseconds = function () { return (this.getDays() * 86400000) + (this.getHours() * 3600000) + (this.getMinutes() * 60000) + (this.getSeconds() * 1000); }; this.compareTo = function (time) { var t1 = new Date(1970, 1, 1, this.getHours(), this.getMinutes(), this.getSeconds()), t2; if (time === null) { t2 = new Date(1970, 1, 1, 0, 0, 0); } else { t2 = new Date(1970, 1, 1, time.getHours(), time.getMinutes(), time.getSeconds()); } return (t1 < t2) ? -1 : (t1 > t2) ? 1 : 0; }; this.equals = function (time) { return (this.compareTo(time) === 0); }; this.add = function (time) { return (time === null) ? this : this.addSeconds(time.getTotalMilliseconds() / 1000); }; this.subtract = function (time) { return (time === null) ? this : this.addSeconds(-time.getTotalMilliseconds() / 1000); }; this.addDays = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 86400000)); }; this.addHours = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 3600000)); }; this.addMinutes = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 60000)); }; this.addSeconds = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 1000)); }; this.addMilliseconds = function (n) { return new TimeSpan(this.getTotalMilliseconds() + n); }; this.get12HourHour = function () { return (this.getHours() > 12) ? this.getHours() - 12 : (this.getHours() === 0) ? 12 : this.getHours(); }; this.getDesignator = function () { return (this.getHours() < 12) ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator; }; this.toString = function (format) { this._toString = function () { if (this.getDays() !== null && this.getDays() > 0) { return this.getDays() + "." + this.getHours() + ":" + this.p(this.getMinutes()) + ":" + this.p(this.getSeconds()); } else { return this.getHours() + ":" + this.p(this.getMinutes()) + ":" + this.p(this.getSeconds()); } }; this.p = function (s) { return (s.toString().length < 2) ? "0" + s : s; }; var me = this; return format ? format.replace(/dd?|HH?|hh?|mm?|ss?|tt?/g, function (format) { switch (format) { case "d": return me.getDays(); case "dd": return me.p(me.getDays()); case "H": return me.getHours(); case "HH": return me.p(me.getHours()); case "h": return me.get12HourHour(); case "hh": return me.p(me.get12HourHour()); case "m": return me.getMinutes(); case "mm": return me.p(me.getMinutes()); case "s": return me.getSeconds(); case "ss": return me.p(me.getSeconds()); case "t": return ((me.getHours() < 12) ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator).substring(0, 1); case "tt": return (me.getHours() < 12) ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator; } } ) : this._toString(); }; return this; }; addSetFuncs(TimeSpan, attrs.slice(2)); TimeSpan.prototype.set = function (days, hours, minutes, seconds, milliseconds){ this.setDays(days || this.getDays()); this.setHours(hours || this.getHours()); this.setMinutes(minutes || this.getMinutes()); this.setSeconds(seconds || this.getSeconds()); this.setMilliseconds(milliseconds || this.getMilliseconds()); }; /** * Gets the time of day for this date instances. * @return {TimeSpan} TimeSpan */ Date.prototype.getTimeOfDay = function () { return new TimeSpan(0, this.getHours(), this.getMinutes(), this.getSeconds(), this.getMilliseconds()); }; Date.TimeSpan = TimeSpan; if (typeof window !== "undefined" ) { // keeping API compatible for v1.x window.TimeSpan = TimeSpan; } }()); (function () { "use strict"; var attrs = ["years", "months", "days", "hours", "minutes", "seconds", "milliseconds"]; var gFn = function (attr) { return function () { return this[attr]; }; }; var sFn = function (attr) { return function (val) { this[attr] = val; return this; }; }; var addSetFuncs = function (context, attrs) { for (var i = 0; i < attrs.length ; i++) { var $a = attrs[i], $b = $a.slice(0, 1).toUpperCase() + $a.slice(1); context.prototype[$a] = 0; context.prototype["get" + $b] = gFn($a); context.prototype["set" + $b] = sFn($a); } }; var setMonthsAndYears = function (orient, d1, d2, context) { function inc() { d1.addMonths(-orient); context.months++; if (context.months === 12) { context.years++; context.months = 0; } } if (orient === +1) { while (d1 > d2) { inc(); } } else { while (d1 < d2) { inc(); } } context.months--; context.months *= orient; context.years *= orient; }; var adjustForDST = function(orient, startDate, endDate) { var hasDSTMismatch = (false === (startDate.isDaylightSavingTime() === endDate.isDaylightSavingTime())); if (hasDSTMismatch && orient === 1) { startDate.addHours(-1); } else if (hasDSTMismatch) { startDate.addHours(1); } }; /** * TimePeriod(startDate, endDate); * TimePeriod(years, months, days, hours, minutes, seconds, milliseconds); */ var TimePeriod = function (years, months, days, hours, minutes, seconds, milliseconds) { if (arguments.length === 7) { this.set(years, months, days, hours, minutes, seconds, milliseconds); } else if (arguments.length === 2 && arguments[0] instanceof Date && arguments[1] instanceof Date) { var startDate = arguments[0].clone(); var endDate = arguments[1].clone(); var orient = (startDate > endDate) ? +1 : -1; this.dates = { start: arguments[0].clone(), end: arguments[1].clone() }; setMonthsAndYears(orient, startDate, endDate, this); adjustForDST(orient, startDate, endDate); // // TODO - adjust for DST var diff = endDate - startDate; if (diff !== 0) { var ts = new TimeSpan(diff); this.set(this.years, this.months, ts.getDays(), ts.getHours(), ts.getMinutes(), ts.getSeconds(), ts.getMilliseconds()); } } return this; }; // create all the set functions. addSetFuncs(TimePeriod, attrs); TimePeriod.prototype.set = function (years, months, days, hours, minutes, seconds, milliseconds){ this.setYears(years || this.getYears()); this.setMonths(months || this.getMonths()); this.setDays(days || this.getDays()); this.setHours(hours || this.getHours()); this.setMinutes(minutes || this.getMinutes()); this.setSeconds(seconds || this.getSeconds()); this.setMilliseconds(milliseconds || this.getMilliseconds()); }; Date.TimePeriod = TimePeriod; if (typeof window !== "undefined") { // keeping API compatible for v1.x window.TimePeriod = TimePeriod; } }()); ================================================ FILE: build/date-bs-Latn-BA.js ================================================ /** * @overview datejs * @version 1.0.0-rc3 * @author Gregory Wild-Smith * @copyright 2015 Gregory Wild-Smith * @license MIT * @homepage https://github.com/abritinthebay/datejs */ /* * DateJS Culture String File * Country Code: bs-Latn-BA * Name: Bosnian (Bosnia and Herzegovina) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["bs-Latn-BA"] = { "name": "bs-Latn-BA", "englishName": "Bosnian (Bosnia and Herzegovina)", "nativeName": "bosanski (Bosna i Hercegovina)", "Sunday": "nedjelja", "Monday": "ponedjeljak", "Tuesday": "utorak", "Wednesday": "srijeda", "Thursday": "četvrtak", "Friday": "petak", "Saturday": "subota", "Sun": "ned", "Mon": "pon", "Tue": "uto", "Wed": "sri", "Thu": "čet", "Fri": "pet", "Sat": "sub", "Su": "ned", "Mo": "pon", "Tu": "uto", "We": "sri", "Th": "čet", "Fr": "pet", "Sa": "sub", "S_Sun_Initial": "n", "M_Mon_Initial": "p", "T_Tue_Initial": "u", "W_Wed_Initial": "s", "T_Thu_Initial": "č", "F_Fri_Initial": "p", "S_Sat_Initial": "s", "January": "januar", "February": "februar", "March": "mart", "April": "april", "May": "maj", "June": "jun", "July": "jul", "August": "avgust", "September": "septembar", "October": "oktobar", "November": "novembar", "December": "decembar", "Jan_Abbr": "jan", "Feb_Abbr": "feb", "Mar_Abbr": "mar", "Apr_Abbr": "apr", "May_Abbr": "maj", "Jun_Abbr": "jun", "Jul_Abbr": "jul", "Aug_Abbr": "avg", "Sep_Abbr": "sep", "Oct_Abbr": "okt", "Nov_Abbr": "nov", "Dec_Abbr": "dec", "AM": "", "PM": "", "firstDayOfWeek": 1, "twoDigitYearMax": 2029, "mdy": "dmy", "M/d/yyyy": "d.M.yyyy", "dddd, MMMM dd, yyyy": "d. MMMM yyyy", "h:mm tt": "H:mm:ss", "h:mm:ss tt": "H:mm:ss", "dddd, MMMM dd, yyyy h:mm:ss tt": "d. MMMM yyyy H:mm:ss", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "MMMM dd", "MMMM, yyyy": "MMMM yyyy", "/jan(uary)?/": "jan(uar)?", "/feb(ruary)?/": "feb(ruar)?", "/mar(ch)?/": "mar(t)?", "/apr(il)?/": "apr(il)?", "/may/": "maj", "/jun(e)?/": "jun", "/jul(y)?/": "jul", "/aug(ust)?/": "avg(ust)?", "/sep(t(ember)?)?/": "sep(tembar)?", "/oct(ober)?/": "okt(obar)?", "/nov(ember)?/": "nov(embar)?", "/dec(ember)?/": "dec(embar)?", "/^su(n(day)?)?/": "^nedjelja", "/^mo(n(day)?)?/": "^ponedjeljak", "/^tu(e(s(day)?)?)?/": "^utorak", "/^we(d(nesday)?)?/": "^srijeda", "/^th(u(r(s(day)?)?)?)?/": "^četvrtak", "/^fr(i(day)?)?/": "^petak", "/^sa(t(urday)?)?/": "^subota", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "bs-Latn-BA"; /** * @overview datejs * @version 1.0.0-rc3 * @author Gregory Wild-Smith * @copyright 2015 Gregory Wild-Smith * @license MIT * @homepage https://github.com/abritinthebay/datejs */(function () { var $D = Date; var lang = Date.CultureStrings ? Date.CultureStrings.lang : null; var loggedKeys = {}; // for debug purposes. var getText = { getFromKey: function (key, countryCode) { var output; if (Date.CultureStrings && Date.CultureStrings[countryCode] && Date.CultureStrings[countryCode][key]) { output = Date.CultureStrings[countryCode][key]; } else { output = getText.buildFromDefault(key); } if (key.charAt(0) === "/") { // Assume it's a regex output = getText.buildFromRegex(key, countryCode); } return output; }, getFromObjectValues: function (obj, countryCode) { var key, output = {}; for(key in obj) { if (obj.hasOwnProperty(key)) { output[key] = getText.getFromKey(obj[key], countryCode); } } return output; }, getFromObjectKeys: function (obj, countryCode) { var key, output = {}; for(key in obj) { if (obj.hasOwnProperty(key)) { output[getText.getFromKey(key, countryCode)] = obj[key]; } } return output; }, getFromArray: function (arr, countryCode) { var output = []; for (var i=0; i < arr.length; i++){ if (i in arr) { output[i] = getText.getFromKey(arr[i], countryCode); } } return output; }, buildFromDefault: function (key) { var output, length, split, last; switch(key) { case "name": output = "en-US"; break; case "englishName": output = "English (United States)"; break; case "nativeName": output = "English (United States)"; break; case "twoDigitYearMax": output = 2049; break; case "firstDayOfWeek": output = 0; break; default: output = key; split = key.split("_"); length = split.length; if (length > 1 && key.charAt(0) !== "/") { // if the key isn't a regex and it has a split. last = split[(length - 1)].toLowerCase(); if (last === "initial" || last === "abbr") { output = split[0]; } } break; } return output; }, buildFromRegex: function (key, countryCode) { var output; if (Date.CultureStrings && Date.CultureStrings[countryCode] && Date.CultureStrings[countryCode][key]) { output = new RegExp(Date.CultureStrings[countryCode][key], "i"); } else { output = new RegExp(key.replace(new RegExp("/", "g"),""), "i"); } return output; } }; var shallowMerge = function (obj1, obj2) { for (var attrname in obj2) { if (obj2.hasOwnProperty(attrname)) { obj1[attrname] = obj2[attrname]; } } }; var __ = function (key, language) { var countryCode = (language) ? language : lang; loggedKeys[key] = key; if (typeof key === "object") { if (key instanceof Array) { return getText.getFromArray(key, countryCode); } else { return getText.getFromObjectKeys(key, countryCode); } } else { return getText.getFromKey(key, countryCode); } }; var loadI18nScript = function (code) { // paatterned after jQuery's getScript. var url = Date.Config.i18n + code + ".js"; var head = document.getElementsByTagName("head")[0] || document.documentElement; var script = document.createElement("script"); script.src = url; var completed = false; var events = { done: function (){} // placeholder function }; // Attach handlers for all browsers script.onload = script.onreadystatechange = function() { if ( !completed && (!this.readyState || this.readyState === "loaded" || this.readyState === "complete") ) { events.done(); head.removeChild(script); } }; setTimeout(function() { head.insertBefore(script, head.firstChild); }, 0); // allows return to execute first return { done: function (cb) { events.done = function() { if (cb) { setTimeout(cb,0); } }; } }; }; var buildInfo = { buildFromMethodHash: function (obj) { var key; for(key in obj) { if (obj.hasOwnProperty(key)) { obj[key] = buildInfo[obj[key]](); } } return obj; }, timeZoneDST: function () { var DST = { "CHADT": "+1345", "NZDT": "+1300", "AEDT": "+1100", "ACDT": "+1030", "AZST": "+0500", "IRDT": "+0430", "EEST": "+0300", "CEST": "+0200", "BST": "+0100", "PMDT": "-0200", "ADT": "-0300", "NDT": "-0230", "EDT": "-0400", "CDT": "-0500", "MDT": "-0600", "PDT": "-0700", "AKDT": "-0800", "HADT": "-0900" }; return __(DST); }, timeZoneStandard: function () { var standard = { "LINT": "+1400", "TOT": "+1300", "CHAST": "+1245", "NZST": "+1200", "NFT": "+1130", "SBT": "+1100", "AEST": "+1000", "ACST": "+0930", "JST": "+0900", "CWST": "+0845", "CT": "+0800", "ICT": "+0700", "MMT": "+0630", "BST": "+0600", "NPT": "+0545", "IST": "+0530", "PKT": "+0500", "AFT": "+0430", "MSK": "+0400", "IRST": "+0330", "FET": "+0300", "EET": "+0200", "CET": "+0100", "GMT": "+0000", "UTC": "+0000", "CVT": "-0100", "GST": "-0200", "BRT": "-0300", "NST": "-0330", "AST": "-0400", "EST": "-0500", "CST": "-0600", "MST": "-0700", "PST": "-0800", "AKST": "-0900", "MIT": "-0930", "HST": "-1000", "SST": "-1100", "BIT": "-1200" }; return __(standard); }, timeZones: function (data) { var zone; data.timezones = []; for (zone in data.abbreviatedTimeZoneStandard) { if (data.abbreviatedTimeZoneStandard.hasOwnProperty(zone)) { data.timezones.push({ name: zone, offset: data.abbreviatedTimeZoneStandard[zone]}); } } for (zone in data.abbreviatedTimeZoneDST) { if (data.abbreviatedTimeZoneDST.hasOwnProperty(zone)) { data.timezones.push({ name: zone, offset: data.abbreviatedTimeZoneDST[zone], dst: true}); } } return data.timezones; }, days: function () { return __(["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"]); }, dayAbbr: function () { return __(["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"]); }, dayShortNames: function () { return __(["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"]); }, dayFirstLetters: function () { return __(["S_Sun_Initial", "M_Mon_Initial", "T_Tues_Initial", "W_Wed_Initial", "T_Thu_Initial", "F_Fri_Initial", "S_Sat_Initial"]); }, months: function () { return __(["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"]); }, monthAbbr: function () { return __(["Jan_Abbr", "Feb_Abbr", "Mar_Abbr", "Apr_Abbr", "May_Abbr", "Jun_Abbr", "Jul_Abbr", "Aug_Abbr", "Sep_Abbr", "Oct_Abbr", "Nov_Abbr", "Dec_Abbr"]); }, formatPatterns: function () { return getText.getFromObjectValues({ shortDate: "M/d/yyyy", longDate: "dddd, MMMM dd, yyyy", shortTime: "h:mm tt", longTime: "h:mm:ss tt", fullDateTime: "dddd, MMMM dd, yyyy h:mm:ss tt", sortableDateTime: "yyyy-MM-ddTHH:mm:ss", universalSortableDateTime: "yyyy-MM-dd HH:mm:ssZ", rfc1123: "ddd, dd MMM yyyy HH:mm:ss", monthDay: "MMMM dd", yearMonth: "MMMM, yyyy" }, Date.i18n.currentLanguage()); }, regex: function () { return getText.getFromObjectValues({ inTheMorning: "/( in the )(morn(ing)?)\\b/", thisMorning: "/(this )(morn(ing)?)\\b/", amThisMorning: "/(\b\\d(am)? )(this )(morn(ing)?)/", inTheEvening: "/( in the )(even(ing)?)\\b/", thisEvening: "/(this )(even(ing)?)\\b/", pmThisEvening: "/(\b\\d(pm)? )(this )(even(ing)?)/", jan: "/jan(uary)?/", feb: "/feb(ruary)?/", mar: "/mar(ch)?/", apr: "/apr(il)?/", may: "/may/", jun: "/jun(e)?/", jul: "/jul(y)?/", aug: "/aug(ust)?/", sep: "/sep(t(ember)?)?/", oct: "/oct(ober)?/", nov: "/nov(ember)?/", dec: "/dec(ember)?/", sun: "/^su(n(day)?)?/", mon: "/^mo(n(day)?)?/", tue: "/^tu(e(s(day)?)?)?/", wed: "/^we(d(nesday)?)?/", thu: "/^th(u(r(s(day)?)?)?)?/", fri: "/fr(i(day)?)?/", sat: "/^sa(t(urday)?)?/", future: "/^next/", past: "/^last|past|prev(ious)?/", add: "/^(\\+|aft(er)?|from|hence)/", subtract: "/^(\\-|bef(ore)?|ago)/", yesterday: "/^yes(terday)?/", today: "/^t(od(ay)?)?/", tomorrow: "/^tom(orrow)?/", now: "/^n(ow)?/", millisecond: "/^ms|milli(second)?s?/", second: "/^sec(ond)?s?/", minute: "/^mn|min(ute)?s?/", hour: "/^h(our)?s?/", week: "/^w(eek)?s?/", month: "/^m(onth)?s?/", day: "/^d(ay)?s?/", year: "/^y(ear)?s?/", shortMeridian: "/^(a|p)/", longMeridian: "/^(a\\.?m?\\.?|p\\.?m?\\.?)/", timezone: "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/", ordinalSuffix: "/^\\s*(st|nd|rd|th)/", timeContext: "/^\\s*(\\:|a(?!u|p)|p)/" }, Date.i18n.currentLanguage()); } }; var CultureInfo = function () { var info = getText.getFromObjectValues({ name: "name", englishName: "englishName", nativeName: "nativeName", amDesignator: "AM", pmDesignator: "PM", firstDayOfWeek: "firstDayOfWeek", twoDigitYearMax: "twoDigitYearMax", dateElementOrder: "mdy" }, Date.i18n.currentLanguage()); var constructedInfo = buildInfo.buildFromMethodHash({ dayNames: "days", abbreviatedDayNames: "dayAbbr", shortestDayNames: "dayShortNames", firstLetterDayNames: "dayFirstLetters", monthNames: "months", abbreviatedMonthNames: "monthAbbr", formatPatterns: "formatPatterns", regexPatterns: "regex", abbreviatedTimeZoneDST: "timeZoneDST", abbreviatedTimeZoneStandard: "timeZoneStandard" }); shallowMerge(info, constructedInfo); buildInfo.timeZones(info); return info; }; $D.i18n = { __: function (key, lang) { return __(key, lang); }, currentLanguage: function () { return lang || "en-US"; }, setLanguage: function (code, force, cb) { var async = false; if (force || code === "en-US" || (!!Date.CultureStrings && !!Date.CultureStrings[code])) { lang = code; Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings.lang = code; Date.CultureInfo = new CultureInfo(); } else { if (!(!!Date.CultureStrings && !!Date.CultureStrings[code])) { if (typeof exports !== "undefined" && this.exports !== exports) { // we're in a Node enviroment, load it using require try { require("../i18n/" + code + ".js"); lang = code; Date.CultureStrings.lang = code; Date.CultureInfo = new CultureInfo(); } catch (e) { // var str = "The language for '" + code + "' could not be loaded by Node. It likely does not exist."; throw new Error("The DateJS IETF language tag '" + code + "' could not be loaded by Node. It likely does not exist."); } } else if (Date.Config && Date.Config.i18n) { // we know the location of the files, so lets load them async = true; loadI18nScript(code).done(function(){ lang = code; Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings.lang = code; Date.CultureInfo = new CultureInfo(); $D.Parsing.Normalizer.buildReplaceData(); // because this is async if ($D.Grammar) { $D.Grammar.buildGrammarFormats(); // so we can parse those strings... } if (cb) { setTimeout(cb,0); } }); } else { Date.console.error("The DateJS IETF language tag '" + code + "' is not available and has not been loaded."); return false; } } } $D.Parsing.Normalizer.buildReplaceData(); // rebuild normalizer strings if ($D.Grammar) { $D.Grammar.buildGrammarFormats(); // so we can parse those strings... } if (!async && cb) { setTimeout(cb,0); } }, getLoggedKeys: function () { return loggedKeys; }, updateCultureInfo: function () { Date.CultureInfo = new CultureInfo(); } }; $D.i18n.updateCultureInfo(); // run automatically }()); (function () { var $D = Date, $P = $D.prototype, p = function (s, l) { if (!l) { l = 2; } return ("000" + s).slice(l * -1); }; if (typeof window !== "undefined" && typeof window.console !== "undefined" && typeof window.console.log !== "undefined") { $D.console = console; // used only to raise non-critical errors if available } else { // set mock so we don't give errors. $D.console = { log: function(){}, error: function(){} }; } $D.Config = $D.Config || {}; $D.initOverloads = function() { /** * Overload of Date.now. Allows an alternate call for Date.now where it returns the * current Date as an object rather than just milliseconds since the Unix Epoch. * * Also provides an implementation of now() for browsers (IE<9) that don't have it. * * Backwards compatible so with work with either: * Date.now() [returns ms] * or * Date.now(true) [returns Date] */ if (!$D.now) { $D._now = function now() { return new Date().getTime(); }; } else if (!$D._now) { $D._now = $D.now; } $D.now = function (returnObj) { if (returnObj) { return $D.present(); } else { return $D._now(); } }; if ( !$P.toISOString ) { $P.toISOString = function() { return this.getUTCFullYear() + "-" + p(this.getUTCMonth() + 1) + "-" + p(this.getUTCDate()) + "T" + p(this.getUTCHours()) + ":" + p(this.getUTCMinutes()) + ":" + p(this.getUTCSeconds()) + "." + String( (this.getUTCMilliseconds()/1000).toFixed(3)).slice(2, 5) + "Z"; }; } // private if ( $P._toString === undefined ){ $P._toString = $P.toString; } }; $D.initOverloads(); /** * Gets a date that is set to the current date. The time is set to the start of the day (00:00 or 12:00 AM). * @return {Date} The current date. */ $D.today = function () { return new Date().clearTime(); }; /** * Gets a date that is set to the current date and time (same as new Date, but chainable) * @return {Date} The current date. */ $D.present = function () { return new Date(); }; /** * Compares the first date to the second date and returns an number indication of their relative values. * @param {Date} First Date object to compare [Required]. * @param {Date} Second Date object to compare to [Required]. * @return {Number} -1 = date1 is lessthan date2. 0 = values are equal. 1 = date1 is greaterthan date2. */ $D.compare = function (date1, date2) { if (isNaN(date1) || isNaN(date2)) { throw new Error(date1 + " - " + date2); } else if (date1 instanceof Date && date2 instanceof Date) { return (date1 < date2) ? -1 : (date1 > date2) ? 1 : 0; } else { throw new TypeError(date1 + " - " + date2); } }; /** * Compares the first Date object to the second Date object and returns true if they are equal. * @param {Date} First Date object to compare [Required] * @param {Date} Second Date object to compare to [Required] * @return {Boolean} true if dates are equal. false if they are not equal. */ $D.equals = function (date1, date2) { return (date1.compareTo(date2) === 0); }; /** * Gets the language appropriate day name when given the day number(0-6) * eg - 0 == Sunday * @return {String} The day name */ $D.getDayName = function (n) { return Date.CultureInfo.dayNames[n]; }; /** * Gets the day number (0-6) if given a CultureInfo specific string which is a valid dayName, abbreviatedDayName or shortestDayName (two char). * @param {String} The name of the day (eg. "Monday, "Mon", "tuesday", "tue", "We", "we"). * @return {Number} The day number */ $D.getDayNumberFromName = function (name) { var n = Date.CultureInfo.dayNames, m = Date.CultureInfo.abbreviatedDayNames, o = Date.CultureInfo.shortestDayNames, s = name.toLowerCase(); for (var i = 0; i < n.length; i++) { if (n[i].toLowerCase() === s || m[i].toLowerCase() === s || o[i].toLowerCase() === s) { return i; } } return -1; }; /** * Gets the month number (0-11) if given a Culture Info specific string which is a valid monthName or abbreviatedMonthName. * @param {String} The name of the month (eg. "February, "Feb", "october", "oct"). * @return {Number} The day number */ $D.getMonthNumberFromName = function (name) { var n = Date.CultureInfo.monthNames, m = Date.CultureInfo.abbreviatedMonthNames, s = name.toLowerCase(); for (var i = 0; i < n.length; i++) { if (n[i].toLowerCase() === s || m[i].toLowerCase() === s) { return i; } } return -1; }; /** * Gets the language appropriate month name when given the month number(0-11) * eg - 0 == January * @return {String} The month name */ $D.getMonthName = function (n) { return Date.CultureInfo.monthNames[n]; }; /** * Determines if the current date instance is within a LeapYear. * @param {Number} The year. * @return {Boolean} true if date is within a LeapYear, otherwise false. */ $D.isLeapYear = function (year) { return ((year % 4 === 0 && year % 100 !== 0) || year % 400 === 0); }; /** * Gets the number of days in the month, given a year and month value. Automatically corrects for LeapYear. * @param {Number} The year. * @param {Number} The month (0-11). * @return {Number} The number of days in the month. */ $D.getDaysInMonth = function (year, month) { if (!month && $D.validateMonth(year)) { month = year; year = Date.today().getFullYear(); } return [31, ($D.isLeapYear(year) ? 29 : 28), 31, 30, 31, 30, 31, 31, 30, 31, 30, 31][month]; }; $P.getDaysInMonth = function () { return $D.getDaysInMonth(this.getFullYear(), this.getMonth()); }; $D.getTimezoneAbbreviation = function (offset, dst) { var p, n = (dst || false) ? Date.CultureInfo.abbreviatedTimeZoneDST : Date.CultureInfo.abbreviatedTimeZoneStandard; for (p in n) { if (n.hasOwnProperty(p)) { if (n[p] === offset) { return p; } } } return null; }; $D.getTimezoneOffset = function (name, dst) { var i, a =[], z = Date.CultureInfo.timezones; if (!name) { name = (new Date()).getTimezone();} for (i = 0; i < z.length; i++) { if (z[i].name === name.toUpperCase()) { a.push(i); } } if (!z[a[0]]) { return null; } if (a.length === 1 || !dst) { return z[a[0]].offset; } else { for (i=0; i < a.length; i++) { if (z[a[i]].dst) { return z[a[i]].offset; } } } }; $D.getQuarter = function (d) { d = d || new Date(); // If no date supplied, use today var q = [1,2,3,4]; return q[Math.floor(d.getMonth() / 3)]; // ~~~ is a bitwise op. Faster than Math.floor }; $D.getDaysLeftInQuarter = function (d) { d = d || new Date(); var qEnd = new Date(d); qEnd.setMonth(qEnd.getMonth() + 3 - qEnd.getMonth() % 3, 0); return Math.floor((qEnd - d) / 8.64e7); }; // private var validate = function (n, min, max, name) { name = name ? name : "Object"; if (typeof n === "undefined") { return false; } else if (typeof n !== "number") { throw new TypeError(n + " is not a Number."); } else if (n < min || n > max) { // As failing validation is *not* an exceptional circumstance // lets not throw a RangeError Exception here. // It's semantically correct but it's not sensible. return false; } return true; }; /** * Validates the number is within an acceptable range for milliseconds [0-999]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateMillisecond = function (value) { return validate(value, 0, 999, "millisecond"); }; /** * Validates the number is within an acceptable range for seconds [0-59]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateSecond = function (value) { return validate(value, 0, 59, "second"); }; /** * Validates the number is within an acceptable range for minutes [0-59]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateMinute = function (value) { return validate(value, 0, 59, "minute"); }; /** * Validates the number is within an acceptable range for hours [0-23]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateHour = function (value) { return validate(value, 0, 23, "hour"); }; /** * Validates the number is within an acceptable range for the days in a month [0-MaxDaysInMonth]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateDay = function (value, year, month) { if (year === undefined || year === null || month === undefined || month === null) { return false;} return validate(value, 1, $D.getDaysInMonth(year, month), "day"); }; /** * Validates the number is within an acceptable range for months [0-11]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateWeek = function (value) { return validate(value, 0, 53, "week"); }; /** * Validates the number is within an acceptable range for months [0-11]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateMonth = function (value) { return validate(value, 0, 11, "month"); }; /** * Validates the number is within an acceptable range for years. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateYear = function (value) { /** * Per ECMAScript spec the range of times supported by Date objects is * exactly -100,000,000 days to +100,000,000 days measured relative to * midnight at the beginning of 01 January, 1970 UTC. * This gives a range of 8,640,000,000,000,000 milliseconds to either * side of 01 January, 1970 UTC. * * Earliest possible date: Tue, 20 Apr 271,822 B.C. 00:00:00 UTC * Latest possible date: Sat, 13 Sep 275,760 00:00:00 UTC */ return validate(value, -271822, 275760, "year"); }; $D.validateTimezone = function(value) { var timezones = {"ACDT":1,"ACST":1,"ACT":1,"ADT":1,"AEDT":1,"AEST":1,"AFT":1,"AKDT":1,"AKST":1,"AMST":1,"AMT":1,"ART":1,"AST":1,"AWDT":1,"AWST":1,"AZOST":1,"AZT":1,"BDT":1,"BIOT":1,"BIT":1,"BOT":1,"BRT":1,"BST":1,"BTT":1,"CAT":1,"CCT":1,"CDT":1,"CEDT":1,"CEST":1,"CET":1,"CHADT":1,"CHAST":1,"CHOT":1,"ChST":1,"CHUT":1,"CIST":1,"CIT":1,"CKT":1,"CLST":1,"CLT":1,"COST":1,"COT":1,"CST":1,"CT":1,"CVT":1,"CWST":1,"CXT":1,"DAVT":1,"DDUT":1,"DFT":1,"EASST":1,"EAST":1,"EAT":1,"ECT":1,"EDT":1,"EEDT":1,"EEST":1,"EET":1,"EGST":1,"EGT":1,"EIT":1,"EST":1,"FET":1,"FJT":1,"FKST":1,"FKT":1,"FNT":1,"GALT":1,"GAMT":1,"GET":1,"GFT":1,"GILT":1,"GIT":1,"GMT":1,"GST":1,"GYT":1,"HADT":1,"HAEC":1,"HAST":1,"HKT":1,"HMT":1,"HOVT":1,"HST":1,"ICT":1,"IDT":1,"IOT":1,"IRDT":1,"IRKT":1,"IRST":1,"IST":1,"JST":1,"KGT":1,"KOST":1,"KRAT":1,"KST":1,"LHST":1,"LINT":1,"MAGT":1,"MART":1,"MAWT":1,"MDT":1,"MET":1,"MEST":1,"MHT":1,"MIST":1,"MIT":1,"MMT":1,"MSK":1,"MST":1,"MUT":1,"MVT":1,"MYT":1,"NCT":1,"NDT":1,"NFT":1,"NPT":1,"NST":1,"NT":1,"NUT":1,"NZDT":1,"NZST":1,"OMST":1,"ORAT":1,"PDT":1,"PET":1,"PETT":1,"PGT":1,"PHOT":1,"PHT":1,"PKT":1,"PMDT":1,"PMST":1,"PONT":1,"PST":1,"PYST":1,"PYT":1,"RET":1,"ROTT":1,"SAKT":1,"SAMT":1,"SAST":1,"SBT":1,"SCT":1,"SGT":1,"SLST":1,"SRT":1,"SST":1,"SYOT":1,"TAHT":1,"THA":1,"TFT":1,"TJT":1,"TKT":1,"TLT":1,"TMT":1,"TOT":1,"TVT":1,"UCT":1,"ULAT":1,"UTC":1,"UYST":1,"UYT":1,"UZT":1,"VET":1,"VLAT":1,"VOLT":1,"VOST":1,"VUT":1,"WAKT":1,"WAST":1,"WAT":1,"WEDT":1,"WEST":1,"WET":1,"WST":1,"YAKT":1,"YEKT":1,"Z":1}; return (timezones[value] === 1); }; $D.validateTimezoneOffset= function(value) { // timezones go from +14hrs to -12hrs, the +X hours are negative offsets. return (value > -841 && value < 721); }; }()); (function () { var $D = Date, $P = $D.prototype, p = function (s, l) { if (!l) { l = 2; } return ("000" + s).slice(l * -1); }; var validateConfigObject = function (obj) { var result = {}, self = this, prop, testFunc; testFunc = function (prop, func, value) { if (prop === "day") { var month = (obj.month !== undefined) ? obj.month : self.getMonth(); var year = (obj.year !== undefined) ? obj.year : self.getFullYear(); return $D[func](value, year, month); } else { return $D[func](value); } }; for (prop in obj) { if (Object.prototype.hasOwnProperty.call(obj, prop)) { var func = "validate" + prop.charAt(0).toUpperCase() + prop.slice(1); if ($D[func] && obj[prop] !== null && testFunc(prop, func, obj[prop])) { result[prop] = obj[prop]; } } } return result; }; /** * Resets the time of this Date object to 12:00 AM (00:00), which is the start of the day. * @param {Boolean} .clone() this date instance before clearing Time * @return {Date} this */ $P.clearTime = function () { this.setHours(0); this.setMinutes(0); this.setSeconds(0); this.setMilliseconds(0); return this; }; /** * Resets the time of this Date object to the current time ('now'). * @return {Date} this */ $P.setTimeToNow = function () { var n = new Date(); this.setHours(n.getHours()); this.setMinutes(n.getMinutes()); this.setSeconds(n.getSeconds()); this.setMilliseconds(n.getMilliseconds()); return this; }; /** * Returns a new Date object that is an exact date and time copy of the original instance. * @return {Date} A new Date instance */ $P.clone = function () { return new Date(this.getTime()); }; /** * Compares this instance to a Date object and returns an number indication of their relative values. * @param {Date} Date object to compare [Required] * @return {Number} -1 = this is lessthan date. 0 = values are equal. 1 = this is greaterthan date. */ $P.compareTo = function (date) { return Date.compare(this, date); }; /** * Compares this instance to another Date object and returns true if they are equal. * @param {Date} Date object to compare. If no date to compare, new Date() [now] is used. * @return {Boolean} true if dates are equal. false if they are not equal. */ $P.equals = function (date) { return Date.equals(this, (date !== undefined ? date : new Date())); }; /** * Determines if this instance is between a range of two dates or equal to either the start or end dates. * @param {Date} Start of range [Required] * @param {Date} End of range [Required] * @return {Boolean} true is this is between or equal to the start and end dates, else false */ $P.between = function (start, end) { return this.getTime() >= start.getTime() && this.getTime() <= end.getTime(); }; /** * Determines if this date occurs after the date to compare to. * @param {Date} Date object to compare. If no date to compare, new Date() ("now") is used. * @return {Boolean} true if this date instance is greater than the date to compare to (or "now"), otherwise false. */ $P.isAfter = function (date) { return this.compareTo(date || new Date()) === 1; }; /** * Determines if this date occurs before the date to compare to. * @param {Date} Date object to compare. If no date to compare, new Date() ("now") is used. * @return {Boolean} true if this date instance is less than the date to compare to (or "now"). */ $P.isBefore = function (date) { return (this.compareTo(date || new Date()) === -1); }; /** * Determines if the current Date instance occurs today. * @return {Boolean} true if this date instance is 'today', otherwise false. */ /** * Determines if the current Date instance occurs on the same Date as the supplied 'date'. * If no 'date' to compare to is provided, the current Date instance is compared to 'today'. * @param {date} Date object to compare. If no date to compare, the current Date ("now") is used. * @return {Boolean} true if this Date instance occurs on the same Day as the supplied 'date'. */ $P.isToday = $P.isSameDay = function (date) { return this.clone().clearTime().equals((date || new Date()).clone().clearTime()); }; /** * Adds the specified number of milliseconds to this instance. * @param {Number} The number of milliseconds to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addMilliseconds = function (value) { if (!value) { return this; } this.setTime(this.getTime() + value * 1); return this; }; /** * Adds the specified number of seconds to this instance. * @param {Number} The number of seconds to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addSeconds = function (value) { if (!value) { return this; } return this.addMilliseconds(value * 1000); }; /** * Adds the specified number of seconds to this instance. * @param {Number} The number of seconds to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addMinutes = function (value) { if (!value) { return this; } return this.addMilliseconds(value * 60000); // 60*1000 }; /** * Adds the specified number of hours to this instance. * @param {Number} The number of hours to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addHours = function (value) { if (!value) { return this; } return this.addMilliseconds(value * 3600000); // 60*60*1000 }; /** * Adds the specified number of days to this instance. * @param {Number} The number of days to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addDays = function (value) { if (!value) { return this; } this.setDate(this.getDate() + value * 1); return this; }; /** * Adds the specified number of weekdays (ie - not sat or sun) to this instance. * @param {Number} The number of days to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addWeekdays = function (value) { if (!value) { return this; } var day = this.getDay(); var weeks = (Math.ceil(Math.abs(value)/7)); if (day === 0 || day === 6) { if (value > 0) { this.next().monday(); this.addDays(-1); day = this.getDay(); } } if (value < 0) { while (value < 0) { this.addDays(-1); day = this.getDay(); if (day !== 0 && day !== 6) { value++; } } return this; } else if (value > 5 || (6-day) <= value) { value = value + (weeks * 2); } return this.addDays(value); }; /** * Adds the specified number of weeks to this instance. * @param {Number} The number of weeks to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addWeeks = function (value) { if (!value) { return this; } return this.addDays(value * 7); }; /** * Adds the specified number of months to this instance. * @param {Number} The number of months to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addMonths = function (value) { if (!value) { return this; } var n = this.getDate(); this.setDate(1); this.setMonth(this.getMonth() + value * 1); this.setDate(Math.min(n, $D.getDaysInMonth(this.getFullYear(), this.getMonth()))); return this; }; $P.addQuarters = function (value) { if (!value) { return this; } // note this will take you to the same point in the quarter as you are now. // i.e. - if you are 15 days into the quarter you'll be 15 days into the resulting one. // bonus: this allows adding fractional quarters return this.addMonths(value * 3); }; /** * Adds the specified number of years to this instance. * @param {Number} The number of years to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addYears = function (value) { if (!value) { return this; } return this.addMonths(value * 12); }; /** * Adds (or subtracts) to the value of the years, months, weeks, days, hours, minutes, seconds, milliseconds of the date instance using given configuration object. Positive and Negative values allowed. * Example

	Date.today().add( { days: 1, months: 1 } )

	new Date().add( { years: -1 } )
	
* @param {Object} Configuration object containing attributes (months, days, etc.) * @return {Date} this */ $P.add = function (config) { if (typeof config === "number") { this._orient = config; return this; } var x = config; if (x.day) { // If we should be a different date than today (eg: for 'tomorrow -1d', etc). // Should only effect parsing, not direct usage (eg, Finish and FinishExact) if ((x.day - this.getDate()) !== 0) { this.setDate(x.day); } } if (x.milliseconds) { this.addMilliseconds(x.milliseconds); } if (x.seconds) { this.addSeconds(x.seconds); } if (x.minutes) { this.addMinutes(x.minutes); } if (x.hours) { this.addHours(x.hours); } if (x.weeks) { this.addWeeks(x.weeks); } if (x.months) { this.addMonths(x.months); } if (x.years) { this.addYears(x.years); } if (x.days) { this.addDays(x.days); } return this; }; /** * Get the week number. Week one (1) is the week which contains the first Thursday of the year. Monday is considered the first day of the week. * The .getWeek() function does NOT convert the date to UTC. The local datetime is used. * Please use .getISOWeek() to get the week of the UTC converted date. * @return {Number} 1 to 53 */ $P.getWeek = function (utc) { // Create a copy of this date object var self, target = new Date(this.valueOf()); if (utc) { target.addMinutes(target.getTimezoneOffset()); self = target.clone(); } else { self = this; } // ISO week date weeks start on monday // so correct the day number var dayNr = (self.getDay() + 6) % 7; // ISO 8601 states that week 1 is the week // with the first thursday of that year. // Set the target date to the thursday in the target week target.setDate(target.getDate() - dayNr + 3); // Store the millisecond value of the target date var firstThursday = target.valueOf(); // Set the target to the first thursday of the year // First set the target to january first target.setMonth(0, 1); // Not a thursday? Correct the date to the next thursday if (target.getDay() !== 4) { target.setMonth(0, 1 + ((4 - target.getDay()) + 7) % 7); } // The weeknumber is the number of weeks between the // first thursday of the year and the thursday in the target week return 1 + Math.ceil((firstThursday - target) / 604800000); // 604800000 = 7 * 24 * 3600 * 1000 }; /** * Get the ISO 8601 week number. Week one ("01") is the week which contains the first Thursday of the year. Monday is considered the first day of the week. * The .getISOWeek() function does convert the date to it's UTC value. Please use .getWeek() to get the week of the local date. * @return {String} "01" to "53" */ $P.getISOWeek = function () { return p(this.getWeek(true)); }; /** * Moves the date to Monday of the week set. Week one (1) is the week which contains the first Thursday of the year. * @param {Number} A Number (1 to 53) that represents the week of the year. * @return {Date} this */ $P.setWeek = function (n) { if ((n - this.getWeek()) === 0) { if (this.getDay() !== 1) { return this.moveToDayOfWeek(1, (this.getDay() > 1 ? -1 : 1)); } else { return this; } } else { return this.moveToDayOfWeek(1, (this.getDay() > 1 ? -1 : 1)).addWeeks(n - this.getWeek()); } }; $P.setQuarter = function (qtr) { var month = Math.abs(((qtr-1) * 3) + 1); return this.setMonth(month, 1); }; $P.getQuarter = function () { return Date.getQuarter(this); }; $P.getDaysLeftInQuarter = function () { return Date.getDaysLeftInQuarter(this); }; /** * Moves the date to the next n'th occurrence of the dayOfWeek starting from the beginning of the month. The number (-1) is a magic number and will return the last occurrence of the dayOfWeek in the month. * @param {Number} The dayOfWeek to move to * @param {Number} The n'th occurrence to move to. Use (-1) to return the last occurrence in the month * @return {Date} this */ $P.moveToNthOccurrence = function (dayOfWeek, occurrence) { if (dayOfWeek === "Weekday") { if (occurrence > 0) { this.moveToFirstDayOfMonth(); if (this.is().weekday()) { occurrence -= 1; } } else if (occurrence < 0) { this.moveToLastDayOfMonth(); if (this.is().weekday()) { occurrence += 1; } } else { return this; } return this.addWeekdays(occurrence); } var shift = 0; if (occurrence > 0) { shift = occurrence - 1; } else if (occurrence === -1) { this.moveToLastDayOfMonth(); if (this.getDay() !== dayOfWeek) { this.moveToDayOfWeek(dayOfWeek, -1); } return this; } return this.moveToFirstDayOfMonth().addDays(-1).moveToDayOfWeek(dayOfWeek, +1).addWeeks(shift); }; var moveToN = function (getFunc, addFunc, nVal) { return function (value, orient) { var diff = (value - this[getFunc]() + nVal * (orient || +1)) % nVal; return this[addFunc]((diff === 0) ? diff += nVal * (orient || +1) : diff); }; }; /** * Move to the next or last dayOfWeek based on the orient value. * @param {Number} The dayOfWeek to move to * @param {Number} Forward (+1) or Back (-1). Defaults to +1. [Optional] * @return {Date} this */ $P.moveToDayOfWeek = moveToN("getDay", "addDays", 7); /** * Move to the next or last month based on the orient value. * @param {Number} The month to move to. 0 = January, 11 = December * @param {Number} Forward (+1) or Back (-1). Defaults to +1. [Optional] * @return {Date} this */ $P.moveToMonth = moveToN("getMonth", "addMonths", 12); /** * Get the Ordinate of the current day ("th", "st", "rd"). * @return {String} */ $P.getOrdinate = function () { var num = this.getDate(); return ord(num); }; /** * Get the Ordinal day (numeric day number) of the year, adjusted for leap year. * @return {Number} 1 through 365 (366 in leap years) */ $P.getOrdinalNumber = function () { return Math.ceil((this.clone().clearTime() - new Date(this.getFullYear(), 0, 1)) / 86400000) + 1; }; /** * Get the time zone abbreviation of the current date. * @return {String} The abbreviated time zone name (e.g. "EST") */ $P.getTimezone = function () { return $D.getTimezoneAbbreviation(this.getUTCOffset(), this.isDaylightSavingTime()); }; $P.setTimezoneOffset = function (offset) { var here = this.getTimezoneOffset(), there = Number(offset) * -6 / 10; return (there || there === 0) ? this.addMinutes(there - here) : this; }; $P.setTimezone = function (offset) { return this.setTimezoneOffset($D.getTimezoneOffset(offset)); }; /** * Indicates whether Daylight Saving Time is observed in the current time zone. * @return {Boolean} true|false */ $P.hasDaylightSavingTime = function () { return (Date.today().set({month: 0, day: 1}).getTimezoneOffset() !== Date.today().set({month: 6, day: 1}).getTimezoneOffset()); }; /** * Indicates whether this Date instance is within the Daylight Saving Time range for the current time zone. * @return {Boolean} true|false */ $P.isDaylightSavingTime = function () { return Date.today().set({month: 0, day: 1}).getTimezoneOffset() !== this.getTimezoneOffset(); }; /** * Get the offset from UTC of the current date. * @return {String} The 4-character offset string prefixed with + or - (e.g. "-0500") */ $P.getUTCOffset = function (offset) { var n = (offset || this.getTimezoneOffset()) * -10 / 6, r; if (n < 0) { r = (n - 10000).toString(); return r.charAt(0) + r.substr(2); } else { r = (n + 10000).toString(); return "+" + r.substr(1); } }; /** * Returns the number of milliseconds between this date and date. * @param {Date} Defaults to now * @return {Number} The diff in milliseconds */ $P.getElapsed = function (date) { return (date || new Date()) - this; }; /** * Set the value of year, month, day, hour, minute, second, millisecond of date instance using given configuration object. * Example

	Date.today().set( { day: 20, month: 1 } )

	new Date().set( { millisecond: 0 } )
	
* * @param {Object} Configuration object containing attributes (month, day, etc.) * @return {Date} this */ $P.set = function (config) { config = validateConfigObject.call(this, config); var key; for (key in config) { if (Object.prototype.hasOwnProperty.call(config, key)) { var name = key.charAt(0).toUpperCase() + key.slice(1); var addFunc, getFunc; if (key !== "week" && key !== "month" && key !== "timezone" && key !== "timezoneOffset") { name += "s"; } addFunc = "add" + name; getFunc = "get" + name; if (key === "month") { addFunc = addFunc + "s"; } else if (key === "year"){ getFunc = "getFullYear"; } if (key !== "day" && key !== "timezone" && key !== "timezoneOffset" && key !== "week" && key !== "hour") { this[addFunc](config[key] - this[getFunc]()); } else if ( key === "timezone"|| key === "timezoneOffset" || key === "week" || key === "hour") { this["set"+name](config[key]); } } } // day has to go last because you can't validate the day without first knowing the month if (config.day) { this.addDays(config.day - this.getDate()); } return this; }; /** * Moves the date to the first day of the month. * @return {Date} this */ $P.moveToFirstDayOfMonth = function () { return this.set({ day: 1 }); }; /** * Moves the date to the last day of the month. * @return {Date} this */ $P.moveToLastDayOfMonth = function () { return this.set({ day: $D.getDaysInMonth(this.getFullYear(), this.getMonth())}); }; /** * Converts the value of the current Date object to its equivalent string representation. * Format Specifiers * CUSTOM DATE AND TIME FORMAT STRINGS * Format Description Example * ------ --------------------------------------------------------------------------- ----------------------- * s The seconds of the minute between 0-59. "0" to "59" * ss The seconds of the minute with leading zero if required. "00" to "59" * * m The minute of the hour between 0-59. "0" or "59" * mm The minute of the hour with leading zero if required. "00" or "59" * * h The hour of the day between 1-12. "1" to "12" * hh The hour of the day with leading zero if required. "01" to "12" * * H The hour of the day between 0-23. "0" to "23" * HH The hour of the day with leading zero if required. "00" to "23" * * d The day of the month between 1 and 31. "1" to "31" * dd The day of the month with leading zero if required. "01" to "31" * ddd Abbreviated day name. Date.CultureInfo.abbreviatedDayNames. "Mon" to "Sun" * dddd The full day name. Date.CultureInfo.dayNames. "Monday" to "Sunday" * * M The month of the year between 1-12. "1" to "12" * MM The month of the year with leading zero if required. "01" to "12" * MMM Abbreviated month name. Date.CultureInfo.abbreviatedMonthNames. "Jan" to "Dec" * MMMM The full month name. Date.CultureInfo.monthNames. "January" to "December" * * yy The year as a two-digit number. "99" or "08" * yyyy The full four digit year. "1999" or "2008" * * t Displays the first character of the A.M./P.M. designator. "A" or "P" * Date.CultureInfo.amDesignator or Date.CultureInfo.pmDesignator * tt Displays the A.M./P.M. designator. "AM" or "PM" * Date.CultureInfo.amDesignator or Date.CultureInfo.pmDesignator * * S The ordinal suffix ("st, "nd", "rd" or "th") of the current day. "st, "nd", "rd" or "th" * * STANDARD DATE AND TIME FORMAT STRINGS * Format Description Example *------ --------------------------------------------------------------------------- ----------------------- * d The CultureInfo shortDate Format Pattern "M/d/yyyy" * D The CultureInfo longDate Format Pattern "dddd, MMMM dd, yyyy" * F The CultureInfo fullDateTime Format Pattern "dddd, MMMM dd, yyyy h:mm:ss tt" * m The CultureInfo monthDay Format Pattern "MMMM dd" * r The CultureInfo rfc1123 Format Pattern "ddd, dd MMM yyyy HH:mm:ss GMT" * s The CultureInfo sortableDateTime Format Pattern "yyyy-MM-ddTHH:mm:ss" * t The CultureInfo shortTime Format Pattern "h:mm tt" * T The CultureInfo longTime Format Pattern "h:mm:ss tt" * u The CultureInfo universalSortableDateTime Format Pattern "yyyy-MM-dd HH:mm:ssZ" * y The CultureInfo yearMonth Format Pattern "MMMM, yyyy" * * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @return {String} A string representation of the current Date object. */ var ord = function (n) { switch (n * 1) { case 1: case 21: case 31: return "st"; case 2: case 22: return "nd"; case 3: case 23: return "rd"; default: return "th"; } }; var parseStandardFormats = function (format) { var y, c = Date.CultureInfo.formatPatterns; switch (format) { case "d": return this.toString(c.shortDate); case "D": return this.toString(c.longDate); case "F": return this.toString(c.fullDateTime); case "m": return this.toString(c.monthDay); case "r": case "R": y = this.clone().addMinutes(this.getTimezoneOffset()); return y.toString(c.rfc1123) + " GMT"; case "s": return this.toString(c.sortableDateTime); case "t": return this.toString(c.shortTime); case "T": return this.toString(c.longTime); case "u": y = this.clone().addMinutes(this.getTimezoneOffset()); return y.toString(c.universalSortableDateTime); case "y": return this.toString(c.yearMonth); default: return false; } }; var parseFormatStringsClosure = function (context) { return function (m) { if (m.charAt(0) === "\\") { return m.replace("\\", ""); } switch (m) { case "hh": return p(context.getHours() < 13 ? (context.getHours() === 0 ? 12 : context.getHours()) : (context.getHours() - 12)); case "h": return context.getHours() < 13 ? (context.getHours() === 0 ? 12 : context.getHours()) : (context.getHours() - 12); case "HH": return p(context.getHours()); case "H": return context.getHours(); case "mm": return p(context.getMinutes()); case "m": return context.getMinutes(); case "ss": return p(context.getSeconds()); case "s": return context.getSeconds(); case "yyyy": return p(context.getFullYear(), 4); case "yy": return p(context.getFullYear()); case "y": return context.getFullYear(); case "E": case "dddd": return Date.CultureInfo.dayNames[context.getDay()]; case "ddd": return Date.CultureInfo.abbreviatedDayNames[context.getDay()]; case "dd": return p(context.getDate()); case "d": return context.getDate(); case "MMMM": return Date.CultureInfo.monthNames[context.getMonth()]; case "MMM": return Date.CultureInfo.abbreviatedMonthNames[context.getMonth()]; case "MM": return p((context.getMonth() + 1)); case "M": return context.getMonth() + 1; case "t": return context.getHours() < 12 ? Date.CultureInfo.amDesignator.substring(0, 1) : Date.CultureInfo.pmDesignator.substring(0, 1); case "tt": return context.getHours() < 12 ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator; case "S": return ord(context.getDate()); case "W": return context.getWeek(); case "WW": return context.getISOWeek(); case "Q": return "Q" + context.getQuarter(); case "q": return String(context.getQuarter()); case "z": return context.getTimezone(); case "Z": case "X": return Date.getTimezoneOffset(context.getTimezone()); case "ZZ": // Timezone offset in seconds return context.getTimezoneOffset() * -60; case "u": return context.getDay(); case "L": return ($D.isLeapYear(context.getFullYear())) ? 1 : 0; case "B": // Swatch Internet Time (.beats) return "@"+((context.getUTCSeconds() + (context.getUTCMinutes()*60) + ((context.getUTCHours()+1)*3600))/86.4); default: return m; } }; }; $P.toString = function (format, ignoreStandards) { // Standard Date and Time Format Strings. Formats pulled from CultureInfo file and // may vary by culture. if (!ignoreStandards && format && format.length === 1) { output = parseStandardFormats.call(this, format); if (output) { return output; } } var parseFormatStrings = parseFormatStringsClosure(this); return format ? format.replace(/((\\)?(dd?d?d?|MM?M?M?|yy?y?y?|hh?|HH?|mm?|ss?|tt?|S|q|Q|WW?W?W?)(?![^\[]*\]))/g, parseFormatStrings).replace(/\[|\]/g, "") : this._toString(); }; }()); /************************************************************* * SugarPak - Domain Specific Language - Syntactical Sugar * *************************************************************/ (function () { var $D = Date, $P = $D.prototype, $N = Number.prototype; // private $P._orient = +1; // private $P._nth = null; // private $P._is = false; // private $P._same = false; // private $P._isSecond = false; // private $N._dateElement = "days"; /** * Moves the date to the next instance of a date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.today().next().friday();
	Date.today().next().fri();
	Date.today().next().march();
	Date.today().next().mar();
	Date.today().next().week();
	
* * @return {Date} date */ $P.next = function () { this._move = true; this._orient = +1; return this; }; /** * Creates a new Date (Date.today()) and moves the date to the next instance of the date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.next().friday();
	Date.next().fri();
	Date.next().march();
	Date.next().mar();
	Date.next().week();
	
* * @return {Date} date */ $D.next = function () { return $D.today().next(); }; /** * Moves the date to the previous instance of a date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.today().last().friday();
	Date.today().last().fri();
	Date.today().last().march();
	Date.today().last().mar();
	Date.today().last().week();
	
* * @return {Date} date */ $P.last = $P.prev = $P.previous = function () { this._move = true; this._orient = -1; return this; }; /** * Creates a new Date (Date.today()) and moves the date to the previous instance of the date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.last().friday();
	Date.last().fri();
	Date.previous().march();
	Date.prev().mar();
	Date.last().week();
	
* * @return {Date} date */ $D.last = $D.prev = $D.previous = function () { return $D.today().last(); }; /** * Performs a equality check when followed by either a month name, day name or .weekday() function. * Example

	Date.today().is().friday(); // true|false
	Date.today().is().fri();
	Date.today().is().march();
	Date.today().is().mar();
	
* * @return {Boolean} true|false */ $P.is = function () { this._is = true; return this; }; /** * Determines if two date objects occur on/in exactly the same instance of the subsequent date part function. * The function .same() must be followed by a date part function (example: .day(), .month(), .year(), etc). * * An optional Date can be passed in the date part function. If now date is passed as a parameter, 'Now' is used. * * The following example demonstrates how to determine if two dates fall on the exact same day. * * Example

	var d1 = Date.today(); // today at 00:00
	var d2 = new Date();   // exactly now.

	// Do they occur on the same day?
	d1.same().day(d2); // true
	
	// Do they occur on the same hour?
	d1.same().hour(d2); // false, unless d2 hour is '00' (midnight).
	
	// What if it's the same day, but one year apart?
	var nextYear = Date.today().add(1).year();

	d1.same().day(nextYear); // false, because the dates must occur on the exact same day. 
	
* * Scenario: Determine if a given date occurs during some week period 2 months from now. * * Example

	var future = Date.today().add(2).months();
	return someDate.same().week(future); // true|false;
	
* * @return {Boolean} true|false */ $P.same = function () { this._same = true; this._isSecond = false; return this; }; /** * Determines if the current date/time occurs during Today. Must be preceded by the .is() function. * Example

	someDate.is().today();    // true|false
	new Date().is().today();  // true
	Date.today().is().today();// true
	Date.today().add(-1).day().is().today(); // false
	
* * @return {Boolean} true|false */ $P.today = function () { return this.same().day(); }; /** * Determines if the current date is a weekday. This function must be preceded by the .is() function. * Example

	Date.today().is().weekday(); // true|false
	
* * @return {Boolean} true|false */ $P.weekday = function () { if (this._nth) { return df("Weekday").call(this); } if (this._move) { return this.addWeekdays(this._orient); } if (this._is) { this._is = false; return (!this.is().sat() && !this.is().sun()); } return false; }; /** * Determines if the current date is on the weekend. This function must be preceded by the .is() function. * Example

	Date.today().is().weekend(); // true|false
	
* * @return {Boolean} true|false */ $P.weekend = function () { if (this._is) { this._is = false; return (this.is().sat() || this.is().sun()); } return false; }; /** * Sets the Time of the current Date instance. A string "6:15 pm" or config object {hour:18, minute:15} are accepted. * Example

	// Set time to 6:15pm with a String
	Date.today().at("6:15pm");

	// Set time to 6:15pm with a config object
	Date.today().at({hour:18, minute:15});
	
* * @return {Date} date */ $P.at = function (time) { return (typeof time === "string") ? $D.parse(this.toString("d") + " " + time) : this.set(time); }; /** * Creates a new Date() and adds this (Number) to the date based on the preceding date element function (eg. second|minute|hour|day|month|year). * Example

	// Undeclared Numbers must be wrapped with parentheses. Requirment of JavaScript.
	(3).days().fromNow();
	(6).months().fromNow();

	// Declared Number variables do not require parentheses. 
	var n = 6;
	n.months().fromNow();
	
* * @return {Date} A new Date instance */ $N.fromNow = $N.after = function (date) { var c = {}; c[this._dateElement] = this; return ((!date) ? new Date() : date.clone()).add(c); }; /** * Creates a new Date() and subtract this (Number) from the date based on the preceding date element function (eg. second|minute|hour|day|month|year). * Example

	// Undeclared Numbers must be wrapped with parentheses. Requirment of JavaScript.
	(3).days().ago();
	(6).months().ago();

	// Declared Number variables do not require parentheses. 
	var n = 6;
	n.months().ago();
	
* * @return {Date} A new Date instance */ $N.ago = $N.before = function (date) { var c = {}, s = (this._dateElement[this._dateElement.length-1] !== "s") ? this._dateElement + "s" : this._dateElement; c[s] = this * -1; return ((!date) ? new Date() : date.clone()).add(c); }; // Do NOT modify the following string tokens. These tokens are used to build dynamic functions. // All culture-specific strings can be found in the CultureInfo files. var dx = ("sunday monday tuesday wednesday thursday friday saturday").split(/\s/), mx = ("january february march april may june july august september october november december").split(/\s/), px = ("Millisecond Second Minute Hour Day Week Month Year Quarter Weekday").split(/\s/), pxf = ("Milliseconds Seconds Minutes Hours Date Week Month FullYear Quarter").split(/\s/), nth = ("final first second third fourth fifth").split(/\s/), de; /** * Returns an object literal of all the date parts. * Example

	var o = new Date().toObject();
	
	// { year: 2008, month: 4, week: 20, day: 13, hour: 18, minute: 9, second: 32, millisecond: 812 }
	
	// The object properties can be referenced directly from the object.
	
	alert(o.day);  // alerts "13"
	alert(o.year); // alerts "2008"
	
* * @return {Date} An object literal representing the original date object. */ $P.toObject = function () { var o = {}; for (var i = 0; i < px.length; i++) { if (this["get" + pxf[i]]) { o[px[i].toLowerCase()] = this["get" + pxf[i]](); } } return o; }; /** * Returns a date created from an object literal. Ignores the .week property if set in the config. * Example

	var o = new Date().toObject();
	
	return Date.fromObject(o); // will return the same date. 

	var o2 = {month: 1, day: 20, hour: 18}; // birthday party!
	Date.fromObject(o2);
	
* * @return {Date} An object literal representing the original date object. */ $D.fromObject = function(config) { config.week = null; return Date.today().set(config); }; // Create day name functions and abbreviated day name functions (eg. monday(), friday(), fri()). var df = function (n) { return function () { if (this._is) { this._is = false; return this.getDay() === n; } if (this._move) { this._move = null; } if (this._nth !== null) { // If the .second() function was called earlier, remove the _orient // from the date, and then continue. // This is required because 'second' can be used in two different context. // // Example // // Date.today().add(1).second(); // Date.march().second().monday(); // // Things get crazy with the following... // Date.march().add(1).second().second().monday(); // but it works!! // if (this._isSecond) { this.addSeconds(this._orient * -1); } // make sure we reset _isSecond this._isSecond = false; var ntemp = this._nth; this._nth = null; var temp = this.clone().moveToLastDayOfMonth(); this.moveToNthOccurrence(n, ntemp); if (this > temp) { throw new RangeError($D.getDayName(n) + " does not occur " + ntemp + " times in the month of " + $D.getMonthName(temp.getMonth()) + " " + temp.getFullYear() + "."); } return this; } return this.moveToDayOfWeek(n, this._orient); }; }; var sdf = function (n) { return function () { var t = $D.today(), shift = n - t.getDay(); if (n === 0 && Date.CultureInfo.firstDayOfWeek === 1 && t.getDay() !== 0) { shift = shift + 7; } return t.addDays(shift); }; }; // Create month name functions and abbreviated month name functions (eg. january(), march(), mar()). var month_instance_functions = function (n) { return function () { if (this._is) { this._is = false; return this.getMonth() === n; } return this.moveToMonth(n, this._orient); }; }; var month_static_functions = function (n) { return function () { return $D.today().set({ month: n, day: 1 }); }; }; var processTerms = function (names, staticFunc, instanceFunc) { for (var i = 0; i < names.length; i++) { // Create constant static Name variables. $D[names[i].toUpperCase()] = $D[names[i].toUpperCase().substring(0, 3)] = i; // Create Name functions. $D[names[i]] = $D[names[i].substring(0, 3)] = staticFunc(i); // Create Name instance functions. $P[names[i]] = $P[names[i].substring(0, 3)] = instanceFunc(i); } }; processTerms(dx, sdf, df); processTerms(mx, month_static_functions, month_instance_functions); // Create date element functions and plural date element functions used with Date (eg. day(), days(), months()). var ef = function (j) { return function () { // if the .second() function was called earlier, the _orient // has alread been added. Just return this and reset _isSecond. if (this._isSecond) { this._isSecond = false; return this; } if (this._same) { this._same = this._is = false; var o1 = this.toObject(), o2 = (arguments[0] || new Date()).toObject(), v = "", k = j.toLowerCase(); // the substr trick with -1 doesn't work in IE8 or less k = (k[k.length-1] === "s") ? k.substring(0,k.length-1) : k; for (var m = (px.length - 1); m > -1; m--) { v = px[m].toLowerCase(); if (o1[v] !== o2[v]) { return false; } if (k === v) { break; } } return true; } if (j.substring(j.length - 1) !== "s") { j += "s"; } if (this._move) { this._move = null; } return this["add" + j](this._orient); }; }; var nf = function (n) { return function () { this._dateElement = n; return this; }; }; for (var k = 0; k < px.length; k++) { de = px[k].toLowerCase(); if(de !== "weekday") { // Create date element functions and plural date element functions used with Date (eg. day(), days(), months()). $P[de] = $P[de + "s"] = ef(px[k]); // Create date element functions and plural date element functions used with Number (eg. day(), days(), months()). $N[de] = $N[de + "s"] = nf(de + "s"); } } $P._ss = ef("Second"); var nthfn = function (n) { return function (dayOfWeek) { if (this._same) { return this._ss(arguments[0]); } if (dayOfWeek || dayOfWeek === 0) { return this.moveToNthOccurrence(dayOfWeek, n); } this._nth = n; // if the operator is 'second' add the _orient, then deal with it later... if (n === 2 && (dayOfWeek === undefined || dayOfWeek === null)) { this._isSecond = true; return this.addSeconds(this._orient); } return this; }; }; for (var l = 0; l < nth.length; l++) { $P[nth[l]] = (l === 0) ? nthfn(-1) : nthfn(l); } }()); (function () { "use strict"; Date.Parsing = { Exception: function (s) { this.message = "Parse error at '" + s.substring(0, 10) + " ...'"; } }; var $P = Date.Parsing; var dayOffsets = { standard: [0,31,59,90,120,151,181,212,243,273,304,334], leap: [0,31,60,91,121,152,182,213,244,274,305,335] }; $P.isLeapYear = function(year) { return ((year % 4 === 0) && (year % 100 !== 0)) || (year % 400 === 0); }; var utils = { multiReplace : function (str, hash ) { var key; for (key in hash) { if (Object.prototype.hasOwnProperty.call(hash, key)) { var regex; if (typeof hash[key] === "function") { } else { regex = (hash[key] instanceof RegExp) ? hash[key] : new RegExp(hash[key], "g"); } str = str.replace(regex, key); } } return str; }, getDayOfYearFromWeek : function (obj) { var d, jan4, offset; obj.weekDay = (!obj.weekDay && obj.weekDay !== 0) ? 1 : obj.weekDay; d = new Date(obj.year, 0, 4); jan4 = d.getDay() === 0 ? 7 : d.getDay(); // JS is 0 indexed on Sunday. offset = jan4+3; obj.dayOfYear = ((obj.week * 7) + (obj.weekDay === 0 ? 7 : obj.weekDay))-offset; return obj; }, getDayOfYear : function (obj, dayOffset) { if (!obj.dayOfYear) { obj = utils.getDayOfYearFromWeek(obj); } for (var i=0;i <= dayOffset.length;i++) { if (obj.dayOfYear < dayOffset[i] || i === dayOffset.length) { obj.day = obj.day ? obj.day : (obj.dayOfYear - dayOffset[i-1]); break; } else { obj.month = i; } } return obj; }, adjustForTimeZone : function (obj, date) { var offset; if (obj.zone.toUpperCase() === "Z" || (obj.zone_hours === 0 && obj.zone_minutes === 0)) { // it's UTC/GML so work out the current timeszone offset offset = -date.getTimezoneOffset(); } else { offset = (obj.zone_hours*60) + (obj.zone_minutes || 0); if (obj.zone_sign === "+") { offset *= -1; } offset -= date.getTimezoneOffset(); } date.setMinutes(date.getMinutes()+offset); return date; }, setDefaults : function (obj) { obj.year = obj.year || Date.today().getFullYear(); obj.hours = obj.hours || 0; obj.minutes = obj.minutes || 0; obj.seconds = obj.seconds || 0; obj.milliseconds = obj.milliseconds || 0; if (!(!obj.month && (obj.week || obj.dayOfYear))) { // if we have a month, or if we don't but don't have the day calculation data obj.month = obj.month || 0; obj.day = obj.day || 1; } return obj; }, dataNum: function (data, mod, explict, postProcess) { var dataNum = data*1; if (mod) { if (postProcess) { return data ? mod(data)*1 : data; } else { return data ? mod(dataNum) : data; } } else if (!explict){ return data ? dataNum : data; } else { return (data && typeof data !== "undefined") ? dataNum : data; } }, timeDataProcess: function (obj) { var timeObj = {}; for (var x in obj.data) { if (obj.data.hasOwnProperty(x)) { timeObj[x] = obj.ignore[x] ? obj.data[x] : utils.dataNum(obj.data[x], obj.mods[x], obj.explict[x], obj.postProcess[x]); } } if (obj.data.secmins) { obj.data.secmins = obj.data.secmins.replace(",", ".") * 60; if (!timeObj.minutes) { timeObj.minutes = obj.data.secmins; } else if (!timeObj.seconds) { timeObj.seconds = obj.data.secmins; } delete obj.secmins; } return timeObj; }, buildTimeObjectFromData: function (data) { var time = utils.timeDataProcess({ data: { year : data[1], month : data[5], day : data[7], week : data[8], dayOfYear : data[10], hours : data[15], zone_hours : data[23], zone_minutes : data[24], zone : data[21], zone_sign : data[22], weekDay : data[9], minutes: data[16], seconds: data[19], milliseconds: data[20], secmins: data[18] }, mods: { month: function(data) { return data-1; }, weekDay: function (data) { data = Math.abs(data); return (data === 7 ? 0 : data); }, minutes: function (data) { return data.replace(":",""); }, seconds: function (data) { return Math.floor( (data.replace(":","").replace(",","."))*1 ); }, milliseconds: function (data) { return (data.replace(",",".")*1000); } }, postProcess: { minutes: true, seconds: true, milliseconds: true }, explict: { zone_hours: true, zone_minutes: true }, ignore: { zone: true, zone_sign: true, secmins: true } }); return time; }, addToHash: function (hash, keys, data) { keys = keys; data = data; var len = keys.length; for (var i = 0; i < len; i++) { hash[keys[i]] = data[i]; } return hash; }, combineRegex: function (r1, r2) { return new RegExp("(("+r1.source+")\\s("+r2.source+"))"); }, getDateNthString: function(add, last, inc){ if (add) { return Date.today().addDays(inc).toString("d"); } else if (last) { return Date.today().last()[inc]().toString("d"); } }, buildRegexData: function (array) { var arr = []; var len = array.length; for (var i=0; i < len; i++) { if (Object.prototype.toString.call(array[i]) === '[object Array]') { // oldIE compat version of Array.isArray arr.push(this.combineRegex(array[i][0], array[i][1])); } else { arr.push(array[i]); } } return arr; } }; $P.processTimeObject = function (obj) { var date, dayOffset; utils.setDefaults(obj); dayOffset = ($P.isLeapYear(obj.year)) ? dayOffsets.leap : dayOffsets.standard; if (!obj.month && (obj.week || obj.dayOfYear)) { utils.getDayOfYear(obj, dayOffset); } else { obj.dayOfYear = dayOffset[obj.month] + obj.day; } date = new Date(obj.year, obj.month, obj.day, obj.hours, obj.minutes, obj.seconds, obj.milliseconds); if (obj.zone) { utils.adjustForTimeZone(obj, date); // adjust (and calculate) for timezone } return date; }; $P.ISO = { regex : /^([\+-]?\d{4}(?!\d{2}\b))((-?)((0[1-9]|1[0-2])(\3([12]\d|0[1-9]|3[01]))?|W([0-4]\d|5[0-3])(-?[1-7])?|(00[1-9]|0[1-9]\d|[12]\d{2}|3([0-5]\d|6[1-6])))([T\s]((([01]\d|2[0-4])((:?)[0-5]\d)?|24\:?00)([\.,]\d+(?!:))?)?(\17[0-5]\d([\.,]\d+)?)?\s?([zZ]|([\+-])([01]\d|2[0-3]):?([0-5]\d)?)?)?)?$/, parse : function (s) { var time, data = s.match(this.regex); if (!data || !data.length) { return null; } time = utils.buildTimeObjectFromData(data); if (!time.year || (!time.year && (!time.month && !time.day) && (!time.week && !time.dayOfYear)) ) { return null; } return $P.processTimeObject(time); } }; $P.Numeric = { isNumeric: function (e){return!isNaN(parseFloat(e))&&isFinite(e);}, regex: /\b([0-1]?[0-9])([0-3]?[0-9])([0-2]?[0-9]?[0-9][0-9])\b/i, parse: function (s) { var data, i, time = {}, order = Date.CultureInfo.dateElementOrder.split(""); if (!(this.isNumeric(s)) || // if it's non-numeric OR (s[0] === "+" && s[0] === "-")) { // It's an arithmatic string (eg +/-1000) return null; } if (s.length < 5 && s.indexOf(".") < 0 && s.indexOf("/") < 0) { // assume it's just a year. time.year = s; return $P.processTimeObject(time); } data = s.match(this.regex); if (!data || !data.length) { return null; } for (i=0; i < order.length; i++) { switch(order[i]) { case "d": time.day = data[i+1]; break; case "m": time.month = (data[i+1]-1); break; case "y": time.year = data[i+1]; break; } } return $P.processTimeObject(time); } }; $P.Normalizer = { regexData: function () { var $R = Date.CultureInfo.regexPatterns; return utils.buildRegexData([ $R.tomorrow, $R.yesterday, [$R.past, $R.mon], [$R.past, $R.tue], [$R.past, $R.wed], [$R.past, $R.thu], [$R.past, $R.fri], [$R.past, $R.sat], [$R.past, $R.sun] ]); }, basicReplaceHash : function() { var $R = Date.CultureInfo.regexPatterns; return { "January": $R.jan.source, "February": $R.feb, "March": $R.mar, "April": $R.apr, "May": $R.may, "June": $R.jun, "July": $R.jul, "August": $R.aug, "September": $R.sep, "October": $R.oct, "November": $R.nov, "December": $R.dec, "": /\bat\b/gi, " ": /\s{2,}/, "am": $R.inTheMorning, "9am": $R.thisMorning, "pm": $R.inTheEvening, "7pm":$R.thisEvening }; }, keys : function(){ return [ utils.getDateNthString(true, false, 1), // tomorrow utils.getDateNthString(true, false, -1), // yesterday utils.getDateNthString(false, true, "monday"), //last mon utils.getDateNthString(false, true, "tuesday"), //last tues utils.getDateNthString(false, true, "wednesday"), //last wed utils.getDateNthString(false, true, "thursday"), //last thurs utils.getDateNthString(false, true, "friday"), //last fri utils.getDateNthString(false, true, "saturday"), //last sat utils.getDateNthString(false, true, "sunday") //last sun ]; }, buildRegexFunctions: function () { var $R = Date.CultureInfo.regexPatterns; var __ = Date.i18n.__; var tomorrowRE = new RegExp("(\\b\\d\\d?("+__("AM")+"|"+__("PM")+")? )("+$R.tomorrow.source.slice(1)+")", "i"); // adapted tomorrow regex for AM PM relative dates var todayRE = new RegExp($R.today.source + "(?!\\s*([+-]))\\b"); // today, but excludes the math operators (eg "today + 2h") this.replaceFuncs = [ [todayRE, function (full) { return (full.length > 1) ? Date.today().toString("d") : full; }], [tomorrowRE, function(full, m1) { var t = Date.today().addDays(1).toString("d"); return (t + " " + m1); }], [$R.amThisMorning, function(str, am){return am;}], [$R.pmThisEvening, function(str, pm){return pm;}] ]; }, buildReplaceData: function () { this.buildRegexFunctions(); this.replaceHash = utils.addToHash(this.basicReplaceHash(), this.keys(), this.regexData()); }, stringReplaceFuncs: function (s) { for (var i=0; i < this.replaceFuncs.length; i++) { s = s.replace(this.replaceFuncs[i][0], this.replaceFuncs[i][1]); } return s; }, parse: function (s) { s = this.stringReplaceFuncs(s); s = utils.multiReplace(s, this.replaceHash); try { var n = s.split(/([\s\-\.\,\/\x27]+)/); if (n.length === 3 && $P.Numeric.isNumeric(n[0]) && $P.Numeric.isNumeric(n[2]) && (n[2].length >= 4)) { // ok, so we're dealing with x/year. But that's not a full date. // This fixes wonky dateElementOrder parsing when set to dmy order. if (Date.CultureInfo.dateElementOrder[0] === "d") { s = "1/" + n[0] + "/" + n[2]; // set to 1st of month and normalize the seperator } } } catch (e) {} return s; } }; $P.Normalizer.buildReplaceData(); }()); (function () { var $P = Date.Parsing; var _ = $P.Operators = { // // Tokenizers // rtoken: function (r) { // regex token return function (s) { var mx = s.match(r); if (mx) { return ([ mx[0], s.substring(mx[0].length) ]); } else { throw new $P.Exception(s); } }; }, token: function () { // whitespace-eating token return function (s) { return _.rtoken(new RegExp("^\\s*" + s + "\\s*"))(s); }; }, stoken: function (s) { // string token return _.rtoken(new RegExp("^" + s)); }, // Atomic Operators until: function (p) { return function (s) { var qx = [], rx = null; while (s.length) { try { rx = p.call(this, s); } catch (e) { qx.push(rx[0]); s = rx[1]; continue; } break; } return [ qx, s ]; }; }, many: function (p) { return function (s) { var rx = [], r = null; while (s.length) { try { r = p.call(this, s); } catch (e) { return [ rx, s ]; } rx.push(r[0]); s = r[1]; } return [ rx, s ]; }; }, // generator operators -- see below optional: function (p) { return function (s) { var r = null; try { r = p.call(this, s); } catch (e) { return [ null, s ]; } return [ r[0], r[1] ]; }; }, not: function (p) { return function (s) { try { p.call(this, s); } catch (e) { return [null, s]; } throw new $P.Exception(s); }; }, ignore: function (p) { return p ? function (s) { var r = null; r = p.call(this, s); return [null, r[1]]; } : null; }, product: function () { var px = arguments[0], qx = Array.prototype.slice.call(arguments, 1), rx = []; for (var i = 0 ; i < px.length ; i++) { rx.push(_.each(px[i], qx)); } return rx; }, cache: function (rule) { var cache = {}, cache_length = 0, cache_keys = [], CACHE_MAX = Date.Config.CACHE_MAX || 100000, r = null; var cacheCheck = function () { if (cache_length === CACHE_MAX) { // kill several keys, don't want to have to do this all the time... for (var i=0; i < 10; i++) { var key = cache_keys.shift(); if (key) { delete cache[key]; cache_length--; } } } }; return function (s) { cacheCheck(); try { r = cache[s] = (cache[s] || rule.call(this, s)); } catch (e) { r = cache[s] = e; } cache_length++; cache_keys.push(s); if (r instanceof $P.Exception) { throw r; } else { return r; } }; }, // vector operators -- see below any: function () { var px = arguments; return function (s) { var r = null; for (var i = 0; i < px.length; i++) { if (px[i] == null) { continue; } try { r = (px[i].call(this, s)); } catch (e) { r = null; } if (r) { return r; } } throw new $P.Exception(s); }; }, each: function () { var px = arguments; return function (s) { var rx = [], r = null; for (var i = 0; i < px.length ; i++) { if (px[i] == null) { continue; } try { r = (px[i].call(this, s)); } catch (e) { throw new $P.Exception(s); } rx.push(r[0]); s = r[1]; } return [ rx, s]; }; }, all: function () { var px = arguments, _ = _; return _.each(_.optional(px)); }, // delimited operators sequence: function (px, d, c) { d = d || _.rtoken(/^\s*/); c = c || null; if (px.length === 1) { return px[0]; } return function (s) { var r = null, q = null; var rx = []; for (var i = 0; i < px.length ; i++) { try { r = px[i].call(this, s); } catch (e) { break; } rx.push(r[0]); try { q = d.call(this, r[1]); } catch (ex) { q = null; break; } s = q[1]; } if (!r) { throw new $P.Exception(s); } if (q) { throw new $P.Exception(q[1]); } if (c) { try { r = c.call(this, r[1]); } catch (ey) { throw new $P.Exception(r[1]); } } return [ rx, (r?r[1]:s) ]; }; }, // // Composite Operators // between: function (d1, p, d2) { d2 = d2 || d1; var _fn = _.each(_.ignore(d1), p, _.ignore(d2)); return function (s) { var rx = _fn.call(this, s); return [[rx[0][0], r[0][2]], rx[1]]; }; }, list: function (p, d, c) { d = d || _.rtoken(/^\s*/); c = c || null; return (p instanceof Array ? _.each(_.product(p.slice(0, -1), _.ignore(d)), p.slice(-1), _.ignore(c)) : _.each(_.many(_.each(p, _.ignore(d))), px, _.ignore(c))); }, set: function (px, d, c) { d = d || _.rtoken(/^\s*/); c = c || null; return function (s) { // r is the current match, best the current 'best' match // which means it parsed the most amount of input var r = null, p = null, q = null, rx = null, best = [[], s], last = false; // go through the rules in the given set for (var i = 0; i < px.length ; i++) { // last is a flag indicating whether this must be the last element // if there is only 1 element, then it MUST be the last one q = null; p = null; r = null; last = (px.length === 1); // first, we try simply to match the current pattern // if not, try the next pattern try { r = px[i].call(this, s); } catch (e) { continue; } // since we are matching against a set of elements, the first // thing to do is to add r[0] to matched elements rx = [[r[0]], r[1]]; // if we matched and there is still input to parse and // we don't already know this is the last element, // we're going to next check for the delimiter ... // if there's none, or if there's no input left to parse // than this must be the last element after all ... if (r[1].length > 0 && ! last) { try { q = d.call(this, r[1]); } catch (ex) { last = true; } } else { last = true; } // if we parsed the delimiter and now there's no more input, // that means we shouldn't have parsed the delimiter at all // so don't update r and mark this as the last element ... if (!last && q[1].length === 0) { last = true; } // so, if this isn't the last element, we're going to see if // we can get any more matches from the remaining (unmatched) // elements ... if (!last) { // build a list of the remaining rules we can match against, // i.e., all but the one we just matched against var qx = []; for (var j = 0; j < px.length ; j++) { if (i !== j) { qx.push(px[j]); } } // now invoke recursively set with the remaining input // note that we don't include the closing delimiter ... // we'll check for that ourselves at the end p = _.set(qx, d).call(this, q[1]); // if we got a non-empty set as a result ... // (otw rx already contains everything we want to match) if (p[0].length > 0) { // update current result, which is stored in rx ... // basically, pick up the remaining text from p[1] // and concat the result from p[0] so that we don't // get endless nesting ... rx[0] = rx[0].concat(p[0]); rx[1] = p[1]; } } // at this point, rx either contains the last matched element // or the entire matched set that starts with this element. // now we just check to see if this variation is better than // our best so far, in terms of how much of the input is parsed if (rx[1].length < best[1].length) { best = rx; } // if we've parsed all the input, then we're finished if (best[1].length === 0) { break; } } // so now we've either gone through all the patterns trying them // as the initial match; or we found one that parsed the entire // input string ... // if best has no matches, just return empty set ... if (best[0].length === 0) { return best; } // if a closing delimiter is provided, then we have to check it also if (c) { // we try this even if there is no remaining input because the pattern // may well be optional or match empty input ... try { q = c.call(this, best[1]); } catch (ey) { throw new $P.Exception(best[1]); } // it parsed ... be sure to update the best match remaining input best[1] = q[1]; } // if we're here, either there was no closing delimiter or we parsed it // so now we have the best match; just return it! return best; }; }, forward: function (gr, fname) { return function (s) { return gr[fname].call(this, s); }; }, // // Translation Operators // replace: function (rule, repl) { return function (s) { var r = rule.call(this, s); return [repl, r[1]]; }; }, process: function (rule, fn) { return function (s) { var r = rule.call(this, s); return [fn.call(this, r[0]), r[1]]; }; }, min: function (min, rule) { return function (s) { var rx = rule.call(this, s); if (rx[0].length < min) { throw new $P.Exception(s); } return rx; }; } }; // Generator Operators And Vector Operators // Generators are operators that have a signature of F(R) => R, // taking a given rule and returning another rule, such as // ignore, which parses a given rule and throws away the result. // Vector operators are those that have a signature of F(R1,R2,...) => R, // take a list of rules and returning a new rule, such as each. // Generator operators are converted (via the following _generator // function) into functions that can also take a list or array of rules // and return an array of new rules as though the function had been // called on each rule in turn (which is what actually happens). // This allows generators to be used with vector operators more easily. // Example: // each(ignore(foo, bar)) instead of each(ignore(foo), ignore(bar)) // This also turns generators into vector operators, which allows // constructs like: // not(cache(foo, bar)) var _generator = function (op) { function gen() { var args = null, rx = [], px, i; if (arguments.length > 1) { args = Array.prototype.slice.call(arguments); } else if (arguments[0] instanceof Array) { args = arguments[0]; } if (args) { px = args.shift(); if (px.length > 0) { args.unshift(px[i]); rx.push(op.apply(null, args)); args.shift(); return rx; } } else { return op.apply(null, arguments); } } return gen; }; var gx = "optional not ignore cache".split(/\s/); for (var i = 0 ; i < gx.length ; i++) { _[gx[i]] = _generator(_[gx[i]]); } var _vector = function (op) { return function () { if (arguments[0] instanceof Array) { return op.apply(null, arguments[0]); } else { return op.apply(null, arguments); } }; }; var vx = "each any all".split(/\s/); for (var j = 0 ; j < vx.length ; j++) { _[vx[j]] = _vector(_[vx[j]]); } }()); (function () { var $D = Date; var flattenAndCompact = function (ax) { var rx = []; for (var i = 0; i < ax.length; i++) { if (ax[i] instanceof Array) { rx = rx.concat(flattenAndCompact(ax[i])); } else { if (ax[i]) { rx.push(ax[i]); } } } return rx; }; var parseMeridian = function () { if (this.meridian && (this.hour || this.hour === 0)) { if (this.meridian === "a" && this.hour > 11 && Date.Config.strict24hr){ throw "Invalid hour and meridian combination"; } else if (this.meridian === "p" && this.hour < 12 && Date.Config.strict24hr){ throw "Invalid hour and meridian combination"; } else if (this.meridian === "p" && this.hour < 12) { this.hour = this.hour + 12; } else if (this.meridian === "a" && this.hour === 12) { this.hour = 0; } } }; var setDefaults = function () { var now = new Date(); if ((this.hour || this.minute) && (!this.month && !this.year && !this.day)) { this.day = now.getDate(); } if (!this.year) { this.year = now.getFullYear(); } if (!this.month && this.month !== 0) { this.month = now.getMonth(); } if (!this.day) { this.day = 1; } if (!this.hour) { this.hour = 0; } if (!this.minute) { this.minute = 0; } if (!this.second) { this.second = 0; } if (!this.millisecond) { this.millisecond = 0; } }; var finishUtils = { getToday: function () { if (this.now || "hour minute second".indexOf(this.unit) !== -1) { return new Date(); } else { return $D.today(); } }, setDaysFromWeekday: function (today, orient){ var gap; orient = orient || 1; this.unit = "day"; gap = ($D.getDayNumberFromName(this.weekday) - today.getDay()); this.days = gap ? ((gap + (orient * 7)) % 7) : (orient * 7); return this; }, setMonthsFromMonth: function (today, orient) { var gap; orient = orient || 1; this.unit = "month"; gap = (this.month - today.getMonth()); this.months = gap ? ((gap + (orient * 12)) % 12) : (orient * 12); this.month = null; return this; }, setDMYFromWeekday: function () { var d = Date[this.weekday](); this.day = d.getDate(); if (!this.month) { this.month = d.getMonth(); } this.year = d.getFullYear(); return this; }, setUnitValue: function (orient) { if (!this.value && this.operator && this.operator !== null && this[this.unit + "s"] && this[this.unit + "s"] !== null) { this[this.unit + "s"] = this[this.unit + "s"] + ((this.operator === "add") ? 1 : -1) + (this.value||0) * orient; } else if (this[this.unit + "s"] == null || this.operator != null) { if (!this.value) { this.value = 1; } this[this.unit + "s"] = this.value * orient; } }, generateDateFromWeeks: function () { var weekday = (this.weekday !== undefined) ? this.weekday : "today"; var d = Date[weekday]().addWeeks(this.weeks); if (this.now) { d.setTimeToNow(); } return d; } }; $D.Translator = { hour: function (s) { return function () { this.hour = Number(s); }; }, minute: function (s) { return function () { this.minute = Number(s); }; }, second: function (s) { return function () { this.second = Number(s); }; }, /* for ss.s format */ secondAndMillisecond: function (s) { return function () { var mx = s.match(/^([0-5][0-9])\.([0-9]{1,3})/); this.second = Number(mx[1]); this.millisecond = Number(mx[2]); }; }, meridian: function (s) { return function () { this.meridian = s.slice(0, 1).toLowerCase(); }; }, timezone: function (s) { return function () { var n = s.replace(/[^\d\+\-]/g, ""); if (n.length) { this.timezoneOffset = Number(n); } else { this.timezone = s.toLowerCase(); } }; }, day: function (x) { var s = x[0]; return function () { this.day = Number(s.match(/\d+/)[0]); if (this.day < 1) { throw "invalid day"; } }; }, month: function (s) { return function () { this.month = (s.length === 3) ? "jan feb mar apr may jun jul aug sep oct nov dec".indexOf(s)/4 : Number(s) - 1; if (this.month < 0) { throw "invalid month"; } }; }, year: function (s) { return function () { var n = Number(s); this.year = ((s.length > 2) ? n : (n + (((n + 2000) < Date.CultureInfo.twoDigitYearMax) ? 2000 : 1900))); }; }, rday: function (s) { return function () { switch (s) { case "yesterday": this.days = -1; break; case "tomorrow": this.days = 1; break; case "today": this.days = 0; break; case "now": this.days = 0; this.now = true; break; } }; }, finishExact: function (x) { var d; x = (x instanceof Array) ? x : [x]; for (var i = 0 ; i < x.length ; i++) { if (x[i]) { x[i].call(this); } } setDefaults.call(this); parseMeridian.call(this); if (this.day > $D.getDaysInMonth(this.year, this.month)) { throw new RangeError(this.day + " is not a valid value for days."); } d = new Date(this.year, this.month, this.day, this.hour, this.minute, this.second, this.millisecond); if (this.year < 100) { d.setFullYear(this.year); // means years less that 100 are process correctly. JS will parse it otherwise as 1900-1999. } if (this.timezone) { d.set({ timezone: this.timezone }); } else if (this.timezoneOffset) { d.set({ timezoneOffset: this.timezoneOffset }); } return d; }, finish: function (x) { var today, expression, orient, temp; x = (x instanceof Array) ? flattenAndCompact(x) : [ x ]; if (x.length === 0) { return null; } for (var i = 0 ; i < x.length ; i++) { if (typeof x[i] === "function") { x[i].call(this); } } if (this.now && !this.unit && !this.operator) { return new Date(); } else { today = finishUtils.getToday.call(this); } expression = !!(this.days && this.days !== null || this.orient || this.operator); orient = ((this.orient === "past" || this.operator === "subtract") ? -1 : 1); if (this.month && this.unit === "week") { this.value = this.month + 1; delete this.month; delete this.day; } if ((this.month || this.month === 0) && "year day hour minute second".indexOf(this.unit) !== -1) { if (!this.value) { this.value = this.month + 1; } this.month = null; expression = true; } if (!expression && this.weekday && !this.day && !this.days) { finishUtils.setDMYFromWeekday.call(this); } if (expression && this.weekday && this.unit !== "month" && this.unit !== "week") { finishUtils.setDaysFromWeekday.call(this, today, orient); } if (this.weekday && this.unit !== "week" && !this.day && !this.days) { temp = Date[this.weekday](); this.day = temp.getDate(); if (temp.getMonth() !== today.getMonth()) { this.month = temp.getMonth(); } } if (this.month && this.unit === "day" && this.operator) { if (!this.value) { this.value = (this.month + 1); } this.month = null; } if (this.value != null && this.month != null && this.year != null) { this.day = this.value * 1; } if (this.month && !this.day && this.value) { today.set({ day: this.value * 1 }); if (!expression) { this.day = this.value * 1; } } if (!this.month && this.value && this.unit === "month" && !this.now) { this.month = this.value; expression = true; } if (expression && (this.month || this.month === 0) && this.unit !== "year") { finishUtils.setMonthsFromMonth.call(this, today, orient); } if (!this.unit) { this.unit = "day"; } finishUtils.setUnitValue.call(this, orient); parseMeridian.call(this); if ((this.month || this.month === 0) && !this.day) { this.day = 1; } if (!this.orient && !this.operator && this.unit === "week" && this.value && !this.day && !this.month) { return Date.today().setWeek(this.value); } if (this.unit === "week" && this.weeks && !this.day && !this.month) { return finishUtils.generateDateFromWeeks.call(this); } if (expression && this.timezone && this.day && this.days) { this.day = this.days; } if (expression){ today.add(this); } else { today.set(this); } if (this.timezone) { this.timezone = this.timezone.toUpperCase(); var offset = $D.getTimezoneOffset(this.timezone); var timezone; if (today.hasDaylightSavingTime()) { // lets check that we're being sane with timezone setting timezone = $D.getTimezoneAbbreviation(offset, today.isDaylightSavingTime()); if (timezone !== this.timezone) { // bugger, we're in a place where things like EST vs EDT matters. if (today.isDaylightSavingTime()) { today.addHours(-1); } else { today.addHours(1); } } } today.setTimezoneOffset(offset); } return today; } }; }()); (function () { var $D = Date; $D.Grammar = {}; var _ = $D.Parsing.Operators, g = $D.Grammar, t = $D.Translator, _fn; // Allow rolling up into general purpose rules _fn = function () { return _.each(_.any.apply(null, arguments), _.not(g.ctoken2("timeContext"))); }; g.datePartDelimiter = _.rtoken(/^([\s\-\.\,\/\x27]+)/); g.timePartDelimiter = _.stoken(":"); g.whiteSpace = _.rtoken(/^\s*/); g.generalDelimiter = _.rtoken(/^(([\s\,]|at|@|on)+)/); var _C = {}; g.ctoken = function (keys) { var fn = _C[keys]; if (! fn) { var c = Date.CultureInfo.regexPatterns; var kx = keys.split(/\s+/), px = []; for (var i = 0; i < kx.length ; i++) { px.push(_.replace(_.rtoken(c[kx[i]]), kx[i])); } fn = _C[keys] = _.any.apply(null, px); } return fn; }; g.ctoken2 = function (key) { return _.rtoken(Date.CultureInfo.regexPatterns[key]); }; var cacheProcessRtoken = function (key, token, type, eachToken) { if (eachToken) { g[key] = _.cache(_.process(_.each(_.rtoken(token),_.optional(g.ctoken2(eachToken))), type)); } else { g[key] = _.cache(_.process(_.rtoken(token), type)); } }; var cacheProcessCtoken = function (token, type) { return _.cache(_.process(g.ctoken2(token), type)); }; var _F = {}; //function cache var _get = function (f) { _F[f] = (_F[f] || g.format(f)[0]); return _F[f]; }; g.allformats = function (fx) { var rx = []; if (fx instanceof Array) { for (var i = 0; i < fx.length; i++) { rx.push(_get(fx[i])); } } else { rx.push(_get(fx)); } return rx; }; g.formats = function (fx) { if (fx instanceof Array) { var rx = []; for (var i = 0 ; i < fx.length ; i++) { rx.push(_get(fx[i])); } return _.any.apply(null, rx); } else { return _get(fx); } }; var grammarFormats = { timeFormats: function(){ var i, RTokenKeys = [ "h", "hh", "H", "HH", "m", "mm", "s", "ss", "ss.s", "z", "zz" ], RToken = [ /^(0[0-9]|1[0-2]|[1-9])/, /^(0[0-9]|1[0-2])/, /^([0-1][0-9]|2[0-3]|[0-9])/, /^([0-1][0-9]|2[0-3])/, /^([0-5][0-9]|[0-9])/, /^[0-5][0-9]/, /^([0-5][0-9]|[0-9])/, /^[0-5][0-9]/, /^[0-5][0-9]\.[0-9]{1,3}/, /^((\+|\-)\s*\d\d\d\d)|((\+|\-)\d\d\:?\d\d)/, /^((\+|\-)\s*\d\d\d\d)|((\+|\-)\d\d\:?\d\d)/ ], tokens = [ t.hour, t.hour, t.hour, t.hour, t.minute, t.minute, t.second, t.second, t.secondAndMillisecond, t.timezone, t.timezone ]; for (i=0; i < RTokenKeys.length; i++) { cacheProcessRtoken(RTokenKeys[i], RToken[i], tokens[i]); } g.hms = _.cache(_.sequence([g.H, g.m, g.s], g.timePartDelimiter)); g.t = cacheProcessCtoken("shortMeridian", t.meridian); g.tt = cacheProcessCtoken("longMeridian", t.meridian); g.zzz = cacheProcessCtoken("timezone", t.timezone); g.timeSuffix = _.each(_.ignore(g.whiteSpace), _.set([ g.tt, g.zzz ])); g.time = _.each(_.optional(_.ignore(_.stoken("T"))), g.hms, g.timeSuffix); }, dateFormats: function () { // pre-loaded rules for different date part order preferences var _setfn = function () { return _.set(arguments, g.datePartDelimiter); }; var i, RTokenKeys = [ "d", "dd", "M", "MM", "y", "yy", "yyy", "yyyy" ], RToken = [ /^([0-2]\d|3[0-1]|\d)/, /^([0-2]\d|3[0-1])/, /^(1[0-2]|0\d|\d)/, /^(1[0-2]|0\d)/, /^(\d+)/, /^(\d\d)/, /^(\d\d?\d?\d?)/, /^(\d\d\d\d)/ ], tokens = [ t.day, t.day, t.month, t.month, t.year, t.year, t.year, t.year ], eachToken = [ "ordinalSuffix", "ordinalSuffix" ]; for (i=0; i < RTokenKeys.length; i++) { cacheProcessRtoken(RTokenKeys[i], RToken[i], tokens[i], eachToken[i]); } g.MMM = g.MMMM = _.cache(_.process(g.ctoken("jan feb mar apr may jun jul aug sep oct nov dec"), t.month)); g.ddd = g.dddd = _.cache(_.process(g.ctoken("sun mon tue wed thu fri sat"), function (s) { return function () { this.weekday = s; }; } )); g.day = _fn(g.d, g.dd); g.month = _fn(g.M, g.MMM); g.year = _fn(g.yyyy, g.yy); g.mdy = _setfn(g.ddd, g.month, g.day, g.year); g.ymd = _setfn(g.ddd, g.year, g.month, g.day); g.dmy = _setfn(g.ddd, g.day, g.month, g.year); g.date = function (s) { return ((g[Date.CultureInfo.dateElementOrder] || g.mdy).call(this, s)); }; }, relative: function () { // relative date / time expressions g.orientation = _.process(g.ctoken("past future"), function (s) { return function () { this.orient = s; }; } ); g.operator = _.process(g.ctoken("add subtract"), function (s) { return function () { this.operator = s; }; } ); g.rday = _.process(g.ctoken("yesterday tomorrow today now"), t.rday); g.unit = _.process(g.ctoken("second minute hour day week month year"), function (s) { return function () { this.unit = s; }; } ); } }; g.buildGrammarFormats = function () { // these need to be rebuilt every time the language changes. _C = {}; grammarFormats.timeFormats(); grammarFormats.dateFormats(); grammarFormats.relative(); g.value = _.process(_.rtoken(/^([-+]?\d+)?(st|nd|rd|th)?/), function (s) { return function () { this.value = s.replace(/\D/g, ""); }; } ); g.expression = _.set([g.rday, g.operator, g.value, g.unit, g.orientation, g.ddd, g.MMM ]); g.format = _.process(_.many( _.any( // translate format specifiers into grammar rules _.process( _.rtoken(/^(dd?d?d?(?!e)|MM?M?M?|yy?y?y?|hh?|HH?|mm?|ss?|tt?|zz?z?)/), function (fmt) { if (g[fmt]) { return g[fmt]; } else { throw $D.Parsing.Exception(fmt); } } ), // translate separator tokens into token rules _.process(_.rtoken(/^[^dMyhHmstz]+/), // all legal separators function (s) { return _.ignore(_.stoken(s)); } ) ) ), // construct the parser ... function (rules) { return _.process(_.each.apply(null, rules), t.finishExact); } ); // starting rule for general purpose grammar g._start = _.process(_.set([ g.date, g.time, g.expression ], g.generalDelimiter, g.whiteSpace), t.finish); }; g.buildGrammarFormats(); // parsing date format specifiers - ex: "h:m:s tt" // this little guy will generate a custom parser based // on the format string, ex: g.format("h:m:s tt") // check for these formats first g._formats = g.formats([ "\"yyyy-MM-ddTHH:mm:ssZ\"", "yyyy-MM-ddTHH:mm:ss.sz", "yyyy-MM-ddTHH:mm:ssZ", "yyyy-MM-ddTHH:mm:ssz", "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-ddTHH:mmZ", "yyyy-MM-ddTHH:mmz", "yyyy-MM-ddTHH:mm", "ddd, MMM dd, yyyy H:mm:ss tt", "ddd MMM d yyyy HH:mm:ss zzz", "MMddyyyy", "ddMMyyyy", "Mddyyyy", "ddMyyyy", "Mdyyyy", "dMyyyy", "yyyy", "Mdyy", "dMyy", "d" ]); // real starting rule: tries selected formats first, // then general purpose rule g.start = function (s) { try { var r = g._formats.call({}, s); if (r[1].length === 0) { return r; } } catch (e) {} return g._start.call({}, s); }; }()); (function () { var $D = Date; /** * @desc Converts the specified string value into its JavaScript Date equivalent using CultureInfo specific format information. * * Example

	///////////
	// Dates //
	///////////

	// 15-Oct-2004
	var d1 = Date.parse("10/15/2004");

	// 15-Oct-2004
	var d1 = Date.parse("15-Oct-2004");

	// 15-Oct-2004
	var d1 = Date.parse("2004.10.15");

	//Fri Oct 15, 2004
	var d1 = Date.parse("Fri Oct 15, 2004");

	///////////
	// Times //
	///////////

	// Today at 10 PM.
	var d1 = Date.parse("10 PM");

	// Today at 10:30 PM.
	var d1 = Date.parse("10:30 P.M.");

	// Today at 6 AM.
	var d1 = Date.parse("06am");

	/////////////////////
	// Dates and Times //
	/////////////////////

	// 8-July-2004 @ 10:30 PM
	var d1 = Date.parse("July 8th, 2004, 10:30 PM");

	// 1-July-2004 @ 10:30 PM
	var d1 = Date.parse("2004-07-01T22:30:00");

	////////////////////
	// Relative Dates //
	////////////////////

	// Returns today's date. The string "today" is culture specific.
	var d1 = Date.parse("today");

	// Returns yesterday's date. The string "yesterday" is culture specific.
	var d1 = Date.parse("yesterday");

	// Returns the date of the next thursday.
	var d1 = Date.parse("Next thursday");

	// Returns the date of the most previous monday.
	var d1 = Date.parse("last monday");

	// Returns today's day + one year.
	var d1 = Date.parse("next year");

	///////////////
	// Date Math //
	///////////////

	// Today + 2 days
	var d1 = Date.parse("t+2");

	// Today + 2 days
	var d1 = Date.parse("today + 2 days");

	// Today + 3 months
	var d1 = Date.parse("t+3m");

	// Today - 1 year
	var d1 = Date.parse("today - 1 year");

	// Today - 1 year
	var d1 = Date.parse("t-1y"); 


	/////////////////////////////
	// Partial Dates and Times //
	/////////////////////////////

	// July 15th of this year.
	var d1 = Date.parse("July 15");

	// 15th day of current day and year.
	var d1 = Date.parse("15");

	// July 1st of current year at 10pm.
	var d1 = Date.parse("7/1 10pm");
	
* * @param {String} The string value to convert into a Date object [Required] * @return {Date} A Date object or null if the string cannot be converted into a Date. */ var parseUtils = { removeOrds: function (s) { ords = s.match(/\b(\d+)(?:st|nd|rd|th)\b/); // find ordinal matches s = ((ords && ords.length === 2) ? s.replace(ords[0], ords[1]) : s); return s; }, grammarParser: function (s) { var r = null; try { r = $D.Grammar.start.call({}, s.replace(/^\s*(\S*(\s+\S+)*)\s*$/, "$1")); } catch (e) { return null; } return ((r[1].length === 0) ? r[0] : null); }, nativeFallback: function(s) { var t; try { // ok we haven't parsed it, last ditch attempt with the built-in parser. t = Date._parse(s); return (t || t === 0) ? new Date(t) : null; } catch (e) { return null; } } }; function parse (s) { var d; if (!s) { return null; } if (s instanceof Date) { return s.clone(); } if (s.length >= 4 && s.charAt(0) !== "0" && s.charAt(0) !== "+"&& s.charAt(0) !== "-") { // ie: 2004 will pass, 0800 won't. // Start with specific formats d = $D.Parsing.ISO.parse(s) || $D.Parsing.Numeric.parse(s); } if (d instanceof Date && !isNaN(d.getTime())) { return d; } else { // find ordinal dates (1st, 3rd, 8th, etc and remove them as they cause parsing issues) s = $D.Parsing.Normalizer.parse(parseUtils.removeOrds(s)); d = parseUtils.grammarParser(s); if (d !== null) { return d; } else { return parseUtils.nativeFallback(s); } } } if (!$D._parse) { $D._parse = $D.parse; } $D.parse = parse; Date.getParseFunction = function (fx) { var fns = Date.Grammar.allformats(fx); return function (s) { var r = null; for (var i = 0; i < fns.length; i++) { try { r = fns[i].call({}, s); } catch (e) { continue; } if (r[1].length === 0) { return r[0]; } } return null; }; }; /** * Converts the specified string value into its JavaScript Date equivalent using the specified format {String} or formats {Array} and the CultureInfo specific format information. * The format of the string value must match one of the supplied formats exactly. * * Example

	// 15-Oct-2004
	var d1 = Date.parseExact("10/15/2004", "M/d/yyyy");

	// 15-Oct-2004
	var d1 = Date.parse("15-Oct-2004", "M-ddd-yyyy");

	// 15-Oct-2004
	var d1 = Date.parse("2004.10.15", "yyyy.MM.dd");

	// Multiple formats
	var d1 = Date.parseExact("10/15/2004", ["M/d/yyyy", "MMMM d, yyyy"]);
	
* * @param {String} The string value to convert into a Date object [Required]. * @param {Object} The expected format {String} or an array of expected formats {Array} of the date string [Required]. * @return {Date} A Date object or null if the string cannot be converted into a Date. */ $D.parseExact = function (s, fx) { return $D.getParseFunction(fx)(s); }; }()); (function () { var $D = Date, $P = $D.prototype, // $C = $D.CultureInfo, // not used atm p = function (s, l) { if (!l) { l = 2; } return ("000" + s).slice(l * -1); }; /** * Converts a PHP format string to Java/.NET format string. * A PHP format string can be used with ._format or .format. * A Java/.NET format string can be used with .toString(). * The .parseExact function will only accept a Java/.NET format string * * Example * var f1 = "%m/%d/%y" * var f2 = Date.normalizeFormat(f1); // "MM/dd/yy" * * new Date().format(f1); // "04/13/08" * new Date()._format(f1); // "04/13/08" * new Date().toString(f2); // "04/13/08" * * var date = Date.parseExact("04/13/08", f2); // Sun Apr 13 2008 * * @param {String} A PHP format string consisting of one or more format spcifiers. * @return {String} The PHP format converted to a Java/.NET format string. */ var normalizerSubstitutions = { "d" : "dd", "%d": "dd", "D" : "ddd", "%a": "ddd", "j" : "dddd", "l" : "dddd", "%A": "dddd", "S" : "S", "F" : "MMMM", "%B": "MMMM", "m" : "MM", "%m": "MM", "M" : "MMM", "%b": "MMM", "%h": "MMM", "n" : "M", "Y" : "yyyy", "%Y": "yyyy", "y" : "yy", "%y": "yy", "g" : "h", "%I": "h", "G" : "H", "h" : "hh", "H" : "HH", "%H": "HH", "i" : "mm", "%M": "mm", "s" : "ss", "%S": "ss", "%r": "hh:mm tt", "%R": "H:mm", "%T": "H:mm:ss", "%X": "t", "%x": "d", "%e": "d", "%D": "MM/dd/yy", "%n": "\\n", "%t": "\\t", "e" : "z", "T" : "z", "%z": "z", "%Z": "z", "Z" : "ZZ", "N" : "u", "w" : "u", "%w": "u", "W" : "W", "%V": "W" }; var normalizer = { substitutes: function (m) { return normalizerSubstitutions[m]; }, interpreted: function (m, x) { var y; switch (m) { case "%u": return x.getDay() + 1; case "z": return x.getOrdinalNumber(); case "%j": return p(x.getOrdinalNumber(), 3); case "%U": var d1 = x.clone().set({month: 0, day: 1}).addDays(-1).moveToDayOfWeek(0), d2 = x.clone().addDays(1).moveToDayOfWeek(0, -1); return (d2 < d1) ? "00" : p((d2.getOrdinalNumber() - d1.getOrdinalNumber()) / 7 + 1); case "%W": return p(x.getWeek()); case "t": return $D.getDaysInMonth(x.getFullYear(), x.getMonth()); case "o": case "%G": return x.setWeek(x.getISOWeek()).toString("yyyy"); case "%g": return x._format("%G").slice(-2); case "a": case "%p": return t("tt").toLowerCase(); case "A": return t("tt").toUpperCase(); case "u": return p(x.getMilliseconds(), 3); case "I": return (x.isDaylightSavingTime()) ? 1 : 0; case "O": return x.getUTCOffset(); case "P": y = x.getUTCOffset(); return y.substring(0, y.length - 2) + ":" + y.substring(y.length - 2); case "B": var now = new Date(); return Math.floor(((now.getHours() * 3600) + (now.getMinutes() * 60) + now.getSeconds() + (now.getTimezoneOffset() + 60) * 60) / 86.4); case "c": return x.toISOString().replace(/\"/g, ""); case "U": return $D.strtotime("now"); case "%c": return t("d") + " " + t("t"); case "%C": return Math.floor(x.getFullYear() / 100 + 1); } }, shouldOverrideDefaults: function (m) { switch (m) { case "%e": return true; default: return false; } }, parse: function (m, context) { var formatString, c = context || new Date(); formatString = normalizer.substitutes(m); if (formatString) { return formatString; } formatString = normalizer.interpreted(m, c); if (formatString) { return formatString; } else { return m; } } }; $D.normalizeFormat = function (format, context) { return format.replace(/(%|\\)?.|%%/g, function(t){ return normalizer.parse(t, context); }); }; /** * Format a local Unix timestamp according to locale settings * * Example: * Date.strftime("%m/%d/%y", new Date()); // "04/13/08" * Date.strftime("c", "2008-04-13T17:52:03Z"); // "04/13/08" * * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @param {Number|String} The number representing the number of seconds that have elapsed since January 1, 1970 (local time). * @return {String} A string representation of the current Date object. */ $D.strftime = function (format, time) { var d = Date.parse(time); return d._format(format); }; /** * Parse any textual datetime description into a Unix timestamp. * A Unix timestamp is the number of seconds that have elapsed since January 1, 1970 (midnight UTC/GMT). * * Example: * Date.strtotime("04/13/08"); // 1208044800 * Date.strtotime("1970-01-01T00:00:00Z"); // 0 * * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @param {Object} A string or date object. * @return {String} A string representation of the current Date object. */ $D.strtotime = function (time) { var d = $D.parse(time); return Math.round($D.UTC(d.getUTCFullYear(), d.getUTCMonth(), d.getUTCDate(), d.getUTCHours(), d.getUTCMinutes(), d.getUTCSeconds(), d.getUTCMilliseconds()) / 1000); }; /** * Converts the value of the current Date object to its equivalent string representation using a PHP/Unix style of date format specifiers. * Format Specifiers * Format Description Example * ------ --------------------------------------------------------------------------- ----------------------- * %a abbreviated weekday name according to the current localed "Mon" through "Sun" * %A full weekday name according to the current localed "Sunday" through "Saturday" * %b abbreviated month name according to the current localed "Jan" through "Dec" * %B full month name according to the current locale "January" through "December" * %c preferred date and time representation for the current locale "4/13/2008 12:33 PM" * %C century number (the year divided by 100 and truncated to an integer) "00" to "99" * %d day of the month as a decimal number "01" to "31" * %D same as %m/%d/%y "04/13/08" * %e day of the month as a decimal number, a single digit is preceded by a space "1" to "31" * %g like %G, but without the century "08" * %G The 4-digit year corresponding to the ISO week number (see %V). "2008" * This has the same format and value as %Y, except that if the ISO week number * belongs to the previous or next year, that year is used instead. * %h same as %b "Jan" through "Dec" * %H hour as a decimal number using a 24-hour clock. "00" to "23" * %I hour as a decimal number using a 12-hour clock. "01" to "12" * %j day of the year as a decimal number. "001" to "366" * %m month as a decimal number. "01" to "12" * %M minute as a decimal number. "00" to "59" * %n newline character "\n" * %p either "am" or "pm" according to the given time value, or the "am" or "pm" * corresponding strings for the current locale. * %r time in a.m. and p.m. notation "8:44 PM" * %R time in 24 hour notation "20:44" * %S second as a decimal number "00" to "59" * %t tab character "\t" * %T current time, equal to %H:%M:%S "12:49:11" * %u weekday as a decimal number ["1", "7"], with "1" representing Monday "1" to "7" * %U week number of the current year as a decimal number, starting with the "0" to ("52" or "53") * first Sunday as the first day of the first week * %V The ISO 8601:1988 week number of the current year as a decimal number, "00" to ("52" or "53") * range 01 to 53, where week 1 is the first week that has at least 4 days * in the current year, and with Monday as the first day of the week. * (Use %G or %g for the year component that corresponds to the week number * for the specified timestamp.) * %W week number of the current year as a decimal number, starting with the "00" to ("52" or "53") * first Monday as the first day of the first week * %w day of the week as a decimal, Sunday being "0" "0" to "6" * %x preferred date representation for the current locale without the time "4/13/2008" * %X preferred time representation for the current locale without the date "12:53:05" * %y year as a decimal number without a century "00" "99" * %Y year as a decimal number including the century "2008" * %Z time zone or name or abbreviation "UTC", "EST", "PST" * %z same as %Z * %% a literal "%" characters "%" * d Day of the month, 2 digits with leading zeros "01" to "31" * D A textual representation of a day, three letters "Mon" through "Sun" * j Day of the month without leading zeros "1" to "31" * l A full textual representation of the day of the week (lowercase "L") "Sunday" through "Saturday" * N ISO-8601 numeric representation of the day of the week (added in PHP 5.1.0) "1" (for Monday) through "7" (for Sunday) * S English ordinal suffix for the day of the month, 2 characters "st", "nd", "rd" or "th". Works well with j * w Numeric representation of the day of the week "0" (for Sunday) through "6" (for Saturday) * z The day of the year (starting from "0") "0" through "365" * W ISO-8601 week number of year, weeks starting on Monday "00" to ("52" or "53") * F A full textual representation of a month, such as January or March "January" through "December" * m Numeric representation of a month, with leading zeros "01" through "12" * M A short textual representation of a month, three letters "Jan" through "Dec" * n Numeric representation of a month, without leading zeros "1" through "12" * t Number of days in the given month "28" through "31" * L Whether it's a leap year "1" if it is a leap year, "0" otherwise * o ISO-8601 year number. This has the same value as Y, except that if the "2008" * ISO week number (W) belongs to the previous or next year, that year * is used instead. * Y A full numeric representation of a year, 4 digits "2008" * y A two digit representation of a year "08" * a Lowercase Ante meridiem and Post meridiem "am" or "pm" * A Uppercase Ante meridiem and Post meridiem "AM" or "PM" * B Swatch Internet time "000" through "999" * g 12-hour format of an hour without leading zeros "1" through "12" * G 24-hour format of an hour without leading zeros "0" through "23" * h 12-hour format of an hour with leading zeros "01" through "12" * H 24-hour format of an hour with leading zeros "00" through "23" * i Minutes with leading zeros "00" to "59" * s Seconds, with leading zeros "00" through "59" * u Milliseconds "54321" * e Timezone identifier "UTC", "EST", "PST" * I Whether or not the date is in daylight saving time (uppercase i) "1" if Daylight Saving Time, "0" otherwise * O Difference to Greenwich time (GMT) in hours "+0200", "-0600" * P Difference to Greenwich time (GMT) with colon between hours and minutes "+02:00", "-06:00" * T Timezone abbreviation "UTC", "EST", "PST" * Z Timezone offset in seconds. The offset for timezones west of UTC is "-43200" through "50400" * always negative, and for those east of UTC is always positive. * c ISO 8601 date "2004-02-12T15:19:21+00:00" * r RFC 2822 formatted date "Thu, 21 Dec 2000 16:01:07 +0200" * U Seconds since the Unix Epoch (January 1 1970 00:00:00 GMT) "0" * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @return {String} A string representation of the current Date object. */ var formatReplace = function (context) { return function (m) { var formatString, override = false; if (m.charAt(0) === "\\" || m.substring(0, 2) === "%%") { return m.replace("\\", "").replace("%%", "%"); } override = normalizer.shouldOverrideDefaults(m); formatString = $D.normalizeFormat(m, context); if (formatString) { return context.toString(formatString, override); } }; }; $P._format = function (format) { var formatter = formatReplace(this); if (!format) { return this._toString(); } else { return format.replace(/(%|\\)?.|%%/g, formatter); } }; if (!$P.format) { $P.format = $P._format; } }()); (function () { "use strict"; var gFn = function (attr) { return function () { return this[attr]; }; }; var sFn = function (attr) { return function (val) { this[attr] = val; return this; }; }; var attrs = ["years", "months", "days", "hours", "minutes", "seconds", "milliseconds"]; var addSetFuncs = function (context, attrs) { for (var i = 0; i < attrs.length ; i++) { var $a = attrs[i], $b = $a.slice(0, 1).toUpperCase() + $a.slice(1); context.prototype[$a] = 0; context.prototype["get" + $b] = gFn($a); context.prototype["set" + $b] = sFn($a); } }; /** * new TimeSpan(milliseconds); * new TimeSpan(days, hours, minutes, seconds); * new TimeSpan(days, hours, minutes, seconds, milliseconds); */ var TimeSpan = function (days, hours, minutes, seconds, milliseconds) { if (arguments.length === 1 && typeof days === "number") { var orient = (days < 0) ? -1 : +1; var millsLeft = Math.abs(days); this.setDays(Math.floor(millsLeft / 86400000) * orient); millsLeft = millsLeft % 86400000; this.setHours(Math.floor(millsLeft / 3600000) * orient); millsLeft = millsLeft % 3600000; this.setMinutes(Math.floor(millsLeft / 60000) * orient); millsLeft = millsLeft % 60000; this.setSeconds(Math.floor(millsLeft / 1000) * orient); millsLeft = millsLeft % 1000; this.setMilliseconds(millsLeft * orient); } else { this.set(days, hours, minutes, seconds, milliseconds); } this.getTotalMilliseconds = function () { return (this.getDays() * 86400000) + (this.getHours() * 3600000) + (this.getMinutes() * 60000) + (this.getSeconds() * 1000); }; this.compareTo = function (time) { var t1 = new Date(1970, 1, 1, this.getHours(), this.getMinutes(), this.getSeconds()), t2; if (time === null) { t2 = new Date(1970, 1, 1, 0, 0, 0); } else { t2 = new Date(1970, 1, 1, time.getHours(), time.getMinutes(), time.getSeconds()); } return (t1 < t2) ? -1 : (t1 > t2) ? 1 : 0; }; this.equals = function (time) { return (this.compareTo(time) === 0); }; this.add = function (time) { return (time === null) ? this : this.addSeconds(time.getTotalMilliseconds() / 1000); }; this.subtract = function (time) { return (time === null) ? this : this.addSeconds(-time.getTotalMilliseconds() / 1000); }; this.addDays = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 86400000)); }; this.addHours = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 3600000)); }; this.addMinutes = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 60000)); }; this.addSeconds = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 1000)); }; this.addMilliseconds = function (n) { return new TimeSpan(this.getTotalMilliseconds() + n); }; this.get12HourHour = function () { return (this.getHours() > 12) ? this.getHours() - 12 : (this.getHours() === 0) ? 12 : this.getHours(); }; this.getDesignator = function () { return (this.getHours() < 12) ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator; }; this.toString = function (format) { this._toString = function () { if (this.getDays() !== null && this.getDays() > 0) { return this.getDays() + "." + this.getHours() + ":" + this.p(this.getMinutes()) + ":" + this.p(this.getSeconds()); } else { return this.getHours() + ":" + this.p(this.getMinutes()) + ":" + this.p(this.getSeconds()); } }; this.p = function (s) { return (s.toString().length < 2) ? "0" + s : s; }; var me = this; return format ? format.replace(/dd?|HH?|hh?|mm?|ss?|tt?/g, function (format) { switch (format) { case "d": return me.getDays(); case "dd": return me.p(me.getDays()); case "H": return me.getHours(); case "HH": return me.p(me.getHours()); case "h": return me.get12HourHour(); case "hh": return me.p(me.get12HourHour()); case "m": return me.getMinutes(); case "mm": return me.p(me.getMinutes()); case "s": return me.getSeconds(); case "ss": return me.p(me.getSeconds()); case "t": return ((me.getHours() < 12) ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator).substring(0, 1); case "tt": return (me.getHours() < 12) ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator; } } ) : this._toString(); }; return this; }; addSetFuncs(TimeSpan, attrs.slice(2)); TimeSpan.prototype.set = function (days, hours, minutes, seconds, milliseconds){ this.setDays(days || this.getDays()); this.setHours(hours || this.getHours()); this.setMinutes(minutes || this.getMinutes()); this.setSeconds(seconds || this.getSeconds()); this.setMilliseconds(milliseconds || this.getMilliseconds()); }; /** * Gets the time of day for this date instances. * @return {TimeSpan} TimeSpan */ Date.prototype.getTimeOfDay = function () { return new TimeSpan(0, this.getHours(), this.getMinutes(), this.getSeconds(), this.getMilliseconds()); }; Date.TimeSpan = TimeSpan; if (typeof window !== "undefined" ) { // keeping API compatible for v1.x window.TimeSpan = TimeSpan; } }()); (function () { "use strict"; var attrs = ["years", "months", "days", "hours", "minutes", "seconds", "milliseconds"]; var gFn = function (attr) { return function () { return this[attr]; }; }; var sFn = function (attr) { return function (val) { this[attr] = val; return this; }; }; var addSetFuncs = function (context, attrs) { for (var i = 0; i < attrs.length ; i++) { var $a = attrs[i], $b = $a.slice(0, 1).toUpperCase() + $a.slice(1); context.prototype[$a] = 0; context.prototype["get" + $b] = gFn($a); context.prototype["set" + $b] = sFn($a); } }; var setMonthsAndYears = function (orient, d1, d2, context) { function inc() { d1.addMonths(-orient); context.months++; if (context.months === 12) { context.years++; context.months = 0; } } if (orient === +1) { while (d1 > d2) { inc(); } } else { while (d1 < d2) { inc(); } } context.months--; context.months *= orient; context.years *= orient; }; var adjustForDST = function(orient, startDate, endDate) { var hasDSTMismatch = (false === (startDate.isDaylightSavingTime() === endDate.isDaylightSavingTime())); if (hasDSTMismatch && orient === 1) { startDate.addHours(-1); } else if (hasDSTMismatch) { startDate.addHours(1); } }; /** * TimePeriod(startDate, endDate); * TimePeriod(years, months, days, hours, minutes, seconds, milliseconds); */ var TimePeriod = function (years, months, days, hours, minutes, seconds, milliseconds) { if (arguments.length === 7) { this.set(years, months, days, hours, minutes, seconds, milliseconds); } else if (arguments.length === 2 && arguments[0] instanceof Date && arguments[1] instanceof Date) { var startDate = arguments[0].clone(); var endDate = arguments[1].clone(); var orient = (startDate > endDate) ? +1 : -1; this.dates = { start: arguments[0].clone(), end: arguments[1].clone() }; setMonthsAndYears(orient, startDate, endDate, this); adjustForDST(orient, startDate, endDate); // // TODO - adjust for DST var diff = endDate - startDate; if (diff !== 0) { var ts = new TimeSpan(diff); this.set(this.years, this.months, ts.getDays(), ts.getHours(), ts.getMinutes(), ts.getSeconds(), ts.getMilliseconds()); } } return this; }; // create all the set functions. addSetFuncs(TimePeriod, attrs); TimePeriod.prototype.set = function (years, months, days, hours, minutes, seconds, milliseconds){ this.setYears(years || this.getYears()); this.setMonths(months || this.getMonths()); this.setDays(days || this.getDays()); this.setHours(hours || this.getHours()); this.setMinutes(minutes || this.getMinutes()); this.setSeconds(seconds || this.getSeconds()); this.setMilliseconds(milliseconds || this.getMilliseconds()); }; Date.TimePeriod = TimePeriod; if (typeof window !== "undefined") { // keeping API compatible for v1.x window.TimePeriod = TimePeriod; } }()); ================================================ FILE: build/date-ca-ES.js ================================================ /** * @overview datejs * @version 1.0.0-rc3 * @author Gregory Wild-Smith * @copyright 2015 Gregory Wild-Smith * @license MIT * @homepage https://github.com/abritinthebay/datejs */ /* * DateJS Culture String File * Country Code: ca-ES * Name: Catalan (Catalan) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["ca-ES"] = { "name": "ca-ES", "englishName": "Catalan (Catalan)", "nativeName": "català (català)", "Sunday": "diumenge", "Monday": "dilluns", "Tuesday": "dimarts", "Wednesday": "dimecres", "Thursday": "dijous", "Friday": "divendres", "Saturday": "dissabte", "Sun": "dg.", "Mon": "dl.", "Tue": "dt.", "Wed": "dc.", "Thu": "dj.", "Fri": "dv.", "Sat": "ds.", "Su": "dg", "Mo": "dl", "Tu": "dt", "We": "dc", "Th": "dj", "Fr": "dv", "Sa": "ds", "S_Sun_Initial": "d", "M_Mon_Initial": "d", "T_Tue_Initial": "d", "W_Wed_Initial": "d", "T_Thu_Initial": "d", "F_Fri_Initial": "d", "S_Sat_Initial": "d", "January": "gener", "February": "febrer", "March": "març", "April": "abril", "May": "maig", "June": "juny", "July": "juliol", "August": "agost", "September": "setembre", "October": "octubre", "November": "novembre", "December": "desembre", "Jan_Abbr": "gen", "Feb_Abbr": "feb", "Mar_Abbr": "març", "Apr_Abbr": "abr", "May_Abbr": "maig", "Jun_Abbr": "juny", "Jul_Abbr": "jul", "Aug_Abbr": "ag", "Sep_Abbr": "set", "Oct_Abbr": "oct", "Nov_Abbr": "nov", "Dec_Abbr": "des", "AM": "", "PM": "", "firstDayOfWeek": 1, "twoDigitYearMax": 2029, "mdy": "dmy", "M/d/yyyy": "dd/MM/yyyy", "dddd, MMMM dd, yyyy": "dddd, d' / 'MMMM' / 'yyyy", "h:mm tt": "HH:mm", "h:mm:ss tt": "HH:mm:ss", "dddd, MMMM dd, yyyy h:mm:ss tt": "dddd, d' / 'MMMM' / 'yyyy HH:mm:ss", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "dd MMMM", "MMMM, yyyy": "MMMM' / 'yyyy", "/jan(uary)?/": "gen(er)?", "/feb(ruary)?/": "feb(rer)?", "/mar(ch)?/": "març", "/apr(il)?/": "abr(il)?", "/may/": "maig", "/jun(e)?/": "juny", "/jul(y)?/": "jul(iol)?", "/aug(ust)?/": "ag(ost)?", "/sep(t(ember)?)?/": "set(embre)?", "/oct(ober)?/": "oct(ubre)?", "/nov(ember)?/": "nov(embre)?", "/dec(ember)?/": "des(embre)?", "/^su(n(day)?)?/": "^dg((.(umenge)?)?)?", "/^mo(n(day)?)?/": "^dl((.(lluns)?)?)?", "/^tu(e(s(day)?)?)?/": "^dt((.(marts)?)?)?", "/^we(d(nesday)?)?/": "^dc((.(mecres)?)?)?", "/^th(u(r(s(day)?)?)?)?/": "^dj((.(jous)?)?)?", "/^fr(i(day)?)?/": "^dv((.(vendres)?)?)?", "/^sa(t(urday)?)?/": "^ds((.(ssabte)?)?)?", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "ca-ES"; /** * @overview datejs * @version 1.0.0-rc3 * @author Gregory Wild-Smith * @copyright 2015 Gregory Wild-Smith * @license MIT * @homepage https://github.com/abritinthebay/datejs */(function () { var $D = Date; var lang = Date.CultureStrings ? Date.CultureStrings.lang : null; var loggedKeys = {}; // for debug purposes. var getText = { getFromKey: function (key, countryCode) { var output; if (Date.CultureStrings && Date.CultureStrings[countryCode] && Date.CultureStrings[countryCode][key]) { output = Date.CultureStrings[countryCode][key]; } else { output = getText.buildFromDefault(key); } if (key.charAt(0) === "/") { // Assume it's a regex output = getText.buildFromRegex(key, countryCode); } return output; }, getFromObjectValues: function (obj, countryCode) { var key, output = {}; for(key in obj) { if (obj.hasOwnProperty(key)) { output[key] = getText.getFromKey(obj[key], countryCode); } } return output; }, getFromObjectKeys: function (obj, countryCode) { var key, output = {}; for(key in obj) { if (obj.hasOwnProperty(key)) { output[getText.getFromKey(key, countryCode)] = obj[key]; } } return output; }, getFromArray: function (arr, countryCode) { var output = []; for (var i=0; i < arr.length; i++){ if (i in arr) { output[i] = getText.getFromKey(arr[i], countryCode); } } return output; }, buildFromDefault: function (key) { var output, length, split, last; switch(key) { case "name": output = "en-US"; break; case "englishName": output = "English (United States)"; break; case "nativeName": output = "English (United States)"; break; case "twoDigitYearMax": output = 2049; break; case "firstDayOfWeek": output = 0; break; default: output = key; split = key.split("_"); length = split.length; if (length > 1 && key.charAt(0) !== "/") { // if the key isn't a regex and it has a split. last = split[(length - 1)].toLowerCase(); if (last === "initial" || last === "abbr") { output = split[0]; } } break; } return output; }, buildFromRegex: function (key, countryCode) { var output; if (Date.CultureStrings && Date.CultureStrings[countryCode] && Date.CultureStrings[countryCode][key]) { output = new RegExp(Date.CultureStrings[countryCode][key], "i"); } else { output = new RegExp(key.replace(new RegExp("/", "g"),""), "i"); } return output; } }; var shallowMerge = function (obj1, obj2) { for (var attrname in obj2) { if (obj2.hasOwnProperty(attrname)) { obj1[attrname] = obj2[attrname]; } } }; var __ = function (key, language) { var countryCode = (language) ? language : lang; loggedKeys[key] = key; if (typeof key === "object") { if (key instanceof Array) { return getText.getFromArray(key, countryCode); } else { return getText.getFromObjectKeys(key, countryCode); } } else { return getText.getFromKey(key, countryCode); } }; var loadI18nScript = function (code) { // paatterned after jQuery's getScript. var url = Date.Config.i18n + code + ".js"; var head = document.getElementsByTagName("head")[0] || document.documentElement; var script = document.createElement("script"); script.src = url; var completed = false; var events = { done: function (){} // placeholder function }; // Attach handlers for all browsers script.onload = script.onreadystatechange = function() { if ( !completed && (!this.readyState || this.readyState === "loaded" || this.readyState === "complete") ) { events.done(); head.removeChild(script); } }; setTimeout(function() { head.insertBefore(script, head.firstChild); }, 0); // allows return to execute first return { done: function (cb) { events.done = function() { if (cb) { setTimeout(cb,0); } }; } }; }; var buildInfo = { buildFromMethodHash: function (obj) { var key; for(key in obj) { if (obj.hasOwnProperty(key)) { obj[key] = buildInfo[obj[key]](); } } return obj; }, timeZoneDST: function () { var DST = { "CHADT": "+1345", "NZDT": "+1300", "AEDT": "+1100", "ACDT": "+1030", "AZST": "+0500", "IRDT": "+0430", "EEST": "+0300", "CEST": "+0200", "BST": "+0100", "PMDT": "-0200", "ADT": "-0300", "NDT": "-0230", "EDT": "-0400", "CDT": "-0500", "MDT": "-0600", "PDT": "-0700", "AKDT": "-0800", "HADT": "-0900" }; return __(DST); }, timeZoneStandard: function () { var standard = { "LINT": "+1400", "TOT": "+1300", "CHAST": "+1245", "NZST": "+1200", "NFT": "+1130", "SBT": "+1100", "AEST": "+1000", "ACST": "+0930", "JST": "+0900", "CWST": "+0845", "CT": "+0800", "ICT": "+0700", "MMT": "+0630", "BST": "+0600", "NPT": "+0545", "IST": "+0530", "PKT": "+0500", "AFT": "+0430", "MSK": "+0400", "IRST": "+0330", "FET": "+0300", "EET": "+0200", "CET": "+0100", "GMT": "+0000", "UTC": "+0000", "CVT": "-0100", "GST": "-0200", "BRT": "-0300", "NST": "-0330", "AST": "-0400", "EST": "-0500", "CST": "-0600", "MST": "-0700", "PST": "-0800", "AKST": "-0900", "MIT": "-0930", "HST": "-1000", "SST": "-1100", "BIT": "-1200" }; return __(standard); }, timeZones: function (data) { var zone; data.timezones = []; for (zone in data.abbreviatedTimeZoneStandard) { if (data.abbreviatedTimeZoneStandard.hasOwnProperty(zone)) { data.timezones.push({ name: zone, offset: data.abbreviatedTimeZoneStandard[zone]}); } } for (zone in data.abbreviatedTimeZoneDST) { if (data.abbreviatedTimeZoneDST.hasOwnProperty(zone)) { data.timezones.push({ name: zone, offset: data.abbreviatedTimeZoneDST[zone], dst: true}); } } return data.timezones; }, days: function () { return __(["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"]); }, dayAbbr: function () { return __(["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"]); }, dayShortNames: function () { return __(["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"]); }, dayFirstLetters: function () { return __(["S_Sun_Initial", "M_Mon_Initial", "T_Tues_Initial", "W_Wed_Initial", "T_Thu_Initial", "F_Fri_Initial", "S_Sat_Initial"]); }, months: function () { return __(["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"]); }, monthAbbr: function () { return __(["Jan_Abbr", "Feb_Abbr", "Mar_Abbr", "Apr_Abbr", "May_Abbr", "Jun_Abbr", "Jul_Abbr", "Aug_Abbr", "Sep_Abbr", "Oct_Abbr", "Nov_Abbr", "Dec_Abbr"]); }, formatPatterns: function () { return getText.getFromObjectValues({ shortDate: "M/d/yyyy", longDate: "dddd, MMMM dd, yyyy", shortTime: "h:mm tt", longTime: "h:mm:ss tt", fullDateTime: "dddd, MMMM dd, yyyy h:mm:ss tt", sortableDateTime: "yyyy-MM-ddTHH:mm:ss", universalSortableDateTime: "yyyy-MM-dd HH:mm:ssZ", rfc1123: "ddd, dd MMM yyyy HH:mm:ss", monthDay: "MMMM dd", yearMonth: "MMMM, yyyy" }, Date.i18n.currentLanguage()); }, regex: function () { return getText.getFromObjectValues({ inTheMorning: "/( in the )(morn(ing)?)\\b/", thisMorning: "/(this )(morn(ing)?)\\b/", amThisMorning: "/(\b\\d(am)? )(this )(morn(ing)?)/", inTheEvening: "/( in the )(even(ing)?)\\b/", thisEvening: "/(this )(even(ing)?)\\b/", pmThisEvening: "/(\b\\d(pm)? )(this )(even(ing)?)/", jan: "/jan(uary)?/", feb: "/feb(ruary)?/", mar: "/mar(ch)?/", apr: "/apr(il)?/", may: "/may/", jun: "/jun(e)?/", jul: "/jul(y)?/", aug: "/aug(ust)?/", sep: "/sep(t(ember)?)?/", oct: "/oct(ober)?/", nov: "/nov(ember)?/", dec: "/dec(ember)?/", sun: "/^su(n(day)?)?/", mon: "/^mo(n(day)?)?/", tue: "/^tu(e(s(day)?)?)?/", wed: "/^we(d(nesday)?)?/", thu: "/^th(u(r(s(day)?)?)?)?/", fri: "/fr(i(day)?)?/", sat: "/^sa(t(urday)?)?/", future: "/^next/", past: "/^last|past|prev(ious)?/", add: "/^(\\+|aft(er)?|from|hence)/", subtract: "/^(\\-|bef(ore)?|ago)/", yesterday: "/^yes(terday)?/", today: "/^t(od(ay)?)?/", tomorrow: "/^tom(orrow)?/", now: "/^n(ow)?/", millisecond: "/^ms|milli(second)?s?/", second: "/^sec(ond)?s?/", minute: "/^mn|min(ute)?s?/", hour: "/^h(our)?s?/", week: "/^w(eek)?s?/", month: "/^m(onth)?s?/", day: "/^d(ay)?s?/", year: "/^y(ear)?s?/", shortMeridian: "/^(a|p)/", longMeridian: "/^(a\\.?m?\\.?|p\\.?m?\\.?)/", timezone: "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/", ordinalSuffix: "/^\\s*(st|nd|rd|th)/", timeContext: "/^\\s*(\\:|a(?!u|p)|p)/" }, Date.i18n.currentLanguage()); } }; var CultureInfo = function () { var info = getText.getFromObjectValues({ name: "name", englishName: "englishName", nativeName: "nativeName", amDesignator: "AM", pmDesignator: "PM", firstDayOfWeek: "firstDayOfWeek", twoDigitYearMax: "twoDigitYearMax", dateElementOrder: "mdy" }, Date.i18n.currentLanguage()); var constructedInfo = buildInfo.buildFromMethodHash({ dayNames: "days", abbreviatedDayNames: "dayAbbr", shortestDayNames: "dayShortNames", firstLetterDayNames: "dayFirstLetters", monthNames: "months", abbreviatedMonthNames: "monthAbbr", formatPatterns: "formatPatterns", regexPatterns: "regex", abbreviatedTimeZoneDST: "timeZoneDST", abbreviatedTimeZoneStandard: "timeZoneStandard" }); shallowMerge(info, constructedInfo); buildInfo.timeZones(info); return info; }; $D.i18n = { __: function (key, lang) { return __(key, lang); }, currentLanguage: function () { return lang || "en-US"; }, setLanguage: function (code, force, cb) { var async = false; if (force || code === "en-US" || (!!Date.CultureStrings && !!Date.CultureStrings[code])) { lang = code; Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings.lang = code; Date.CultureInfo = new CultureInfo(); } else { if (!(!!Date.CultureStrings && !!Date.CultureStrings[code])) { if (typeof exports !== "undefined" && this.exports !== exports) { // we're in a Node enviroment, load it using require try { require("../i18n/" + code + ".js"); lang = code; Date.CultureStrings.lang = code; Date.CultureInfo = new CultureInfo(); } catch (e) { // var str = "The language for '" + code + "' could not be loaded by Node. It likely does not exist."; throw new Error("The DateJS IETF language tag '" + code + "' could not be loaded by Node. It likely does not exist."); } } else if (Date.Config && Date.Config.i18n) { // we know the location of the files, so lets load them async = true; loadI18nScript(code).done(function(){ lang = code; Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings.lang = code; Date.CultureInfo = new CultureInfo(); $D.Parsing.Normalizer.buildReplaceData(); // because this is async if ($D.Grammar) { $D.Grammar.buildGrammarFormats(); // so we can parse those strings... } if (cb) { setTimeout(cb,0); } }); } else { Date.console.error("The DateJS IETF language tag '" + code + "' is not available and has not been loaded."); return false; } } } $D.Parsing.Normalizer.buildReplaceData(); // rebuild normalizer strings if ($D.Grammar) { $D.Grammar.buildGrammarFormats(); // so we can parse those strings... } if (!async && cb) { setTimeout(cb,0); } }, getLoggedKeys: function () { return loggedKeys; }, updateCultureInfo: function () { Date.CultureInfo = new CultureInfo(); } }; $D.i18n.updateCultureInfo(); // run automatically }()); (function () { var $D = Date, $P = $D.prototype, p = function (s, l) { if (!l) { l = 2; } return ("000" + s).slice(l * -1); }; if (typeof window !== "undefined" && typeof window.console !== "undefined" && typeof window.console.log !== "undefined") { $D.console = console; // used only to raise non-critical errors if available } else { // set mock so we don't give errors. $D.console = { log: function(){}, error: function(){} }; } $D.Config = $D.Config || {}; $D.initOverloads = function() { /** * Overload of Date.now. Allows an alternate call for Date.now where it returns the * current Date as an object rather than just milliseconds since the Unix Epoch. * * Also provides an implementation of now() for browsers (IE<9) that don't have it. * * Backwards compatible so with work with either: * Date.now() [returns ms] * or * Date.now(true) [returns Date] */ if (!$D.now) { $D._now = function now() { return new Date().getTime(); }; } else if (!$D._now) { $D._now = $D.now; } $D.now = function (returnObj) { if (returnObj) { return $D.present(); } else { return $D._now(); } }; if ( !$P.toISOString ) { $P.toISOString = function() { return this.getUTCFullYear() + "-" + p(this.getUTCMonth() + 1) + "-" + p(this.getUTCDate()) + "T" + p(this.getUTCHours()) + ":" + p(this.getUTCMinutes()) + ":" + p(this.getUTCSeconds()) + "." + String( (this.getUTCMilliseconds()/1000).toFixed(3)).slice(2, 5) + "Z"; }; } // private if ( $P._toString === undefined ){ $P._toString = $P.toString; } }; $D.initOverloads(); /** * Gets a date that is set to the current date. The time is set to the start of the day (00:00 or 12:00 AM). * @return {Date} The current date. */ $D.today = function () { return new Date().clearTime(); }; /** * Gets a date that is set to the current date and time (same as new Date, but chainable) * @return {Date} The current date. */ $D.present = function () { return new Date(); }; /** * Compares the first date to the second date and returns an number indication of their relative values. * @param {Date} First Date object to compare [Required]. * @param {Date} Second Date object to compare to [Required]. * @return {Number} -1 = date1 is lessthan date2. 0 = values are equal. 1 = date1 is greaterthan date2. */ $D.compare = function (date1, date2) { if (isNaN(date1) || isNaN(date2)) { throw new Error(date1 + " - " + date2); } else if (date1 instanceof Date && date2 instanceof Date) { return (date1 < date2) ? -1 : (date1 > date2) ? 1 : 0; } else { throw new TypeError(date1 + " - " + date2); } }; /** * Compares the first Date object to the second Date object and returns true if they are equal. * @param {Date} First Date object to compare [Required] * @param {Date} Second Date object to compare to [Required] * @return {Boolean} true if dates are equal. false if they are not equal. */ $D.equals = function (date1, date2) { return (date1.compareTo(date2) === 0); }; /** * Gets the language appropriate day name when given the day number(0-6) * eg - 0 == Sunday * @return {String} The day name */ $D.getDayName = function (n) { return Date.CultureInfo.dayNames[n]; }; /** * Gets the day number (0-6) if given a CultureInfo specific string which is a valid dayName, abbreviatedDayName or shortestDayName (two char). * @param {String} The name of the day (eg. "Monday, "Mon", "tuesday", "tue", "We", "we"). * @return {Number} The day number */ $D.getDayNumberFromName = function (name) { var n = Date.CultureInfo.dayNames, m = Date.CultureInfo.abbreviatedDayNames, o = Date.CultureInfo.shortestDayNames, s = name.toLowerCase(); for (var i = 0; i < n.length; i++) { if (n[i].toLowerCase() === s || m[i].toLowerCase() === s || o[i].toLowerCase() === s) { return i; } } return -1; }; /** * Gets the month number (0-11) if given a Culture Info specific string which is a valid monthName or abbreviatedMonthName. * @param {String} The name of the month (eg. "February, "Feb", "october", "oct"). * @return {Number} The day number */ $D.getMonthNumberFromName = function (name) { var n = Date.CultureInfo.monthNames, m = Date.CultureInfo.abbreviatedMonthNames, s = name.toLowerCase(); for (var i = 0; i < n.length; i++) { if (n[i].toLowerCase() === s || m[i].toLowerCase() === s) { return i; } } return -1; }; /** * Gets the language appropriate month name when given the month number(0-11) * eg - 0 == January * @return {String} The month name */ $D.getMonthName = function (n) { return Date.CultureInfo.monthNames[n]; }; /** * Determines if the current date instance is within a LeapYear. * @param {Number} The year. * @return {Boolean} true if date is within a LeapYear, otherwise false. */ $D.isLeapYear = function (year) { return ((year % 4 === 0 && year % 100 !== 0) || year % 400 === 0); }; /** * Gets the number of days in the month, given a year and month value. Automatically corrects for LeapYear. * @param {Number} The year. * @param {Number} The month (0-11). * @return {Number} The number of days in the month. */ $D.getDaysInMonth = function (year, month) { if (!month && $D.validateMonth(year)) { month = year; year = Date.today().getFullYear(); } return [31, ($D.isLeapYear(year) ? 29 : 28), 31, 30, 31, 30, 31, 31, 30, 31, 30, 31][month]; }; $P.getDaysInMonth = function () { return $D.getDaysInMonth(this.getFullYear(), this.getMonth()); }; $D.getTimezoneAbbreviation = function (offset, dst) { var p, n = (dst || false) ? Date.CultureInfo.abbreviatedTimeZoneDST : Date.CultureInfo.abbreviatedTimeZoneStandard; for (p in n) { if (n.hasOwnProperty(p)) { if (n[p] === offset) { return p; } } } return null; }; $D.getTimezoneOffset = function (name, dst) { var i, a =[], z = Date.CultureInfo.timezones; if (!name) { name = (new Date()).getTimezone();} for (i = 0; i < z.length; i++) { if (z[i].name === name.toUpperCase()) { a.push(i); } } if (!z[a[0]]) { return null; } if (a.length === 1 || !dst) { return z[a[0]].offset; } else { for (i=0; i < a.length; i++) { if (z[a[i]].dst) { return z[a[i]].offset; } } } }; $D.getQuarter = function (d) { d = d || new Date(); // If no date supplied, use today var q = [1,2,3,4]; return q[Math.floor(d.getMonth() / 3)]; // ~~~ is a bitwise op. Faster than Math.floor }; $D.getDaysLeftInQuarter = function (d) { d = d || new Date(); var qEnd = new Date(d); qEnd.setMonth(qEnd.getMonth() + 3 - qEnd.getMonth() % 3, 0); return Math.floor((qEnd - d) / 8.64e7); }; // private var validate = function (n, min, max, name) { name = name ? name : "Object"; if (typeof n === "undefined") { return false; } else if (typeof n !== "number") { throw new TypeError(n + " is not a Number."); } else if (n < min || n > max) { // As failing validation is *not* an exceptional circumstance // lets not throw a RangeError Exception here. // It's semantically correct but it's not sensible. return false; } return true; }; /** * Validates the number is within an acceptable range for milliseconds [0-999]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateMillisecond = function (value) { return validate(value, 0, 999, "millisecond"); }; /** * Validates the number is within an acceptable range for seconds [0-59]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateSecond = function (value) { return validate(value, 0, 59, "second"); }; /** * Validates the number is within an acceptable range for minutes [0-59]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateMinute = function (value) { return validate(value, 0, 59, "minute"); }; /** * Validates the number is within an acceptable range for hours [0-23]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateHour = function (value) { return validate(value, 0, 23, "hour"); }; /** * Validates the number is within an acceptable range for the days in a month [0-MaxDaysInMonth]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateDay = function (value, year, month) { if (year === undefined || year === null || month === undefined || month === null) { return false;} return validate(value, 1, $D.getDaysInMonth(year, month), "day"); }; /** * Validates the number is within an acceptable range for months [0-11]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateWeek = function (value) { return validate(value, 0, 53, "week"); }; /** * Validates the number is within an acceptable range for months [0-11]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateMonth = function (value) { return validate(value, 0, 11, "month"); }; /** * Validates the number is within an acceptable range for years. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateYear = function (value) { /** * Per ECMAScript spec the range of times supported by Date objects is * exactly -100,000,000 days to +100,000,000 days measured relative to * midnight at the beginning of 01 January, 1970 UTC. * This gives a range of 8,640,000,000,000,000 milliseconds to either * side of 01 January, 1970 UTC. * * Earliest possible date: Tue, 20 Apr 271,822 B.C. 00:00:00 UTC * Latest possible date: Sat, 13 Sep 275,760 00:00:00 UTC */ return validate(value, -271822, 275760, "year"); }; $D.validateTimezone = function(value) { var timezones = {"ACDT":1,"ACST":1,"ACT":1,"ADT":1,"AEDT":1,"AEST":1,"AFT":1,"AKDT":1,"AKST":1,"AMST":1,"AMT":1,"ART":1,"AST":1,"AWDT":1,"AWST":1,"AZOST":1,"AZT":1,"BDT":1,"BIOT":1,"BIT":1,"BOT":1,"BRT":1,"BST":1,"BTT":1,"CAT":1,"CCT":1,"CDT":1,"CEDT":1,"CEST":1,"CET":1,"CHADT":1,"CHAST":1,"CHOT":1,"ChST":1,"CHUT":1,"CIST":1,"CIT":1,"CKT":1,"CLST":1,"CLT":1,"COST":1,"COT":1,"CST":1,"CT":1,"CVT":1,"CWST":1,"CXT":1,"DAVT":1,"DDUT":1,"DFT":1,"EASST":1,"EAST":1,"EAT":1,"ECT":1,"EDT":1,"EEDT":1,"EEST":1,"EET":1,"EGST":1,"EGT":1,"EIT":1,"EST":1,"FET":1,"FJT":1,"FKST":1,"FKT":1,"FNT":1,"GALT":1,"GAMT":1,"GET":1,"GFT":1,"GILT":1,"GIT":1,"GMT":1,"GST":1,"GYT":1,"HADT":1,"HAEC":1,"HAST":1,"HKT":1,"HMT":1,"HOVT":1,"HST":1,"ICT":1,"IDT":1,"IOT":1,"IRDT":1,"IRKT":1,"IRST":1,"IST":1,"JST":1,"KGT":1,"KOST":1,"KRAT":1,"KST":1,"LHST":1,"LINT":1,"MAGT":1,"MART":1,"MAWT":1,"MDT":1,"MET":1,"MEST":1,"MHT":1,"MIST":1,"MIT":1,"MMT":1,"MSK":1,"MST":1,"MUT":1,"MVT":1,"MYT":1,"NCT":1,"NDT":1,"NFT":1,"NPT":1,"NST":1,"NT":1,"NUT":1,"NZDT":1,"NZST":1,"OMST":1,"ORAT":1,"PDT":1,"PET":1,"PETT":1,"PGT":1,"PHOT":1,"PHT":1,"PKT":1,"PMDT":1,"PMST":1,"PONT":1,"PST":1,"PYST":1,"PYT":1,"RET":1,"ROTT":1,"SAKT":1,"SAMT":1,"SAST":1,"SBT":1,"SCT":1,"SGT":1,"SLST":1,"SRT":1,"SST":1,"SYOT":1,"TAHT":1,"THA":1,"TFT":1,"TJT":1,"TKT":1,"TLT":1,"TMT":1,"TOT":1,"TVT":1,"UCT":1,"ULAT":1,"UTC":1,"UYST":1,"UYT":1,"UZT":1,"VET":1,"VLAT":1,"VOLT":1,"VOST":1,"VUT":1,"WAKT":1,"WAST":1,"WAT":1,"WEDT":1,"WEST":1,"WET":1,"WST":1,"YAKT":1,"YEKT":1,"Z":1}; return (timezones[value] === 1); }; $D.validateTimezoneOffset= function(value) { // timezones go from +14hrs to -12hrs, the +X hours are negative offsets. return (value > -841 && value < 721); }; }()); (function () { var $D = Date, $P = $D.prototype, p = function (s, l) { if (!l) { l = 2; } return ("000" + s).slice(l * -1); }; var validateConfigObject = function (obj) { var result = {}, self = this, prop, testFunc; testFunc = function (prop, func, value) { if (prop === "day") { var month = (obj.month !== undefined) ? obj.month : self.getMonth(); var year = (obj.year !== undefined) ? obj.year : self.getFullYear(); return $D[func](value, year, month); } else { return $D[func](value); } }; for (prop in obj) { if (Object.prototype.hasOwnProperty.call(obj, prop)) { var func = "validate" + prop.charAt(0).toUpperCase() + prop.slice(1); if ($D[func] && obj[prop] !== null && testFunc(prop, func, obj[prop])) { result[prop] = obj[prop]; } } } return result; }; /** * Resets the time of this Date object to 12:00 AM (00:00), which is the start of the day. * @param {Boolean} .clone() this date instance before clearing Time * @return {Date} this */ $P.clearTime = function () { this.setHours(0); this.setMinutes(0); this.setSeconds(0); this.setMilliseconds(0); return this; }; /** * Resets the time of this Date object to the current time ('now'). * @return {Date} this */ $P.setTimeToNow = function () { var n = new Date(); this.setHours(n.getHours()); this.setMinutes(n.getMinutes()); this.setSeconds(n.getSeconds()); this.setMilliseconds(n.getMilliseconds()); return this; }; /** * Returns a new Date object that is an exact date and time copy of the original instance. * @return {Date} A new Date instance */ $P.clone = function () { return new Date(this.getTime()); }; /** * Compares this instance to a Date object and returns an number indication of their relative values. * @param {Date} Date object to compare [Required] * @return {Number} -1 = this is lessthan date. 0 = values are equal. 1 = this is greaterthan date. */ $P.compareTo = function (date) { return Date.compare(this, date); }; /** * Compares this instance to another Date object and returns true if they are equal. * @param {Date} Date object to compare. If no date to compare, new Date() [now] is used. * @return {Boolean} true if dates are equal. false if they are not equal. */ $P.equals = function (date) { return Date.equals(this, (date !== undefined ? date : new Date())); }; /** * Determines if this instance is between a range of two dates or equal to either the start or end dates. * @param {Date} Start of range [Required] * @param {Date} End of range [Required] * @return {Boolean} true is this is between or equal to the start and end dates, else false */ $P.between = function (start, end) { return this.getTime() >= start.getTime() && this.getTime() <= end.getTime(); }; /** * Determines if this date occurs after the date to compare to. * @param {Date} Date object to compare. If no date to compare, new Date() ("now") is used. * @return {Boolean} true if this date instance is greater than the date to compare to (or "now"), otherwise false. */ $P.isAfter = function (date) { return this.compareTo(date || new Date()) === 1; }; /** * Determines if this date occurs before the date to compare to. * @param {Date} Date object to compare. If no date to compare, new Date() ("now") is used. * @return {Boolean} true if this date instance is less than the date to compare to (or "now"). */ $P.isBefore = function (date) { return (this.compareTo(date || new Date()) === -1); }; /** * Determines if the current Date instance occurs today. * @return {Boolean} true if this date instance is 'today', otherwise false. */ /** * Determines if the current Date instance occurs on the same Date as the supplied 'date'. * If no 'date' to compare to is provided, the current Date instance is compared to 'today'. * @param {date} Date object to compare. If no date to compare, the current Date ("now") is used. * @return {Boolean} true if this Date instance occurs on the same Day as the supplied 'date'. */ $P.isToday = $P.isSameDay = function (date) { return this.clone().clearTime().equals((date || new Date()).clone().clearTime()); }; /** * Adds the specified number of milliseconds to this instance. * @param {Number} The number of milliseconds to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addMilliseconds = function (value) { if (!value) { return this; } this.setTime(this.getTime() + value * 1); return this; }; /** * Adds the specified number of seconds to this instance. * @param {Number} The number of seconds to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addSeconds = function (value) { if (!value) { return this; } return this.addMilliseconds(value * 1000); }; /** * Adds the specified number of seconds to this instance. * @param {Number} The number of seconds to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addMinutes = function (value) { if (!value) { return this; } return this.addMilliseconds(value * 60000); // 60*1000 }; /** * Adds the specified number of hours to this instance. * @param {Number} The number of hours to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addHours = function (value) { if (!value) { return this; } return this.addMilliseconds(value * 3600000); // 60*60*1000 }; /** * Adds the specified number of days to this instance. * @param {Number} The number of days to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addDays = function (value) { if (!value) { return this; } this.setDate(this.getDate() + value * 1); return this; }; /** * Adds the specified number of weekdays (ie - not sat or sun) to this instance. * @param {Number} The number of days to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addWeekdays = function (value) { if (!value) { return this; } var day = this.getDay(); var weeks = (Math.ceil(Math.abs(value)/7)); if (day === 0 || day === 6) { if (value > 0) { this.next().monday(); this.addDays(-1); day = this.getDay(); } } if (value < 0) { while (value < 0) { this.addDays(-1); day = this.getDay(); if (day !== 0 && day !== 6) { value++; } } return this; } else if (value > 5 || (6-day) <= value) { value = value + (weeks * 2); } return this.addDays(value); }; /** * Adds the specified number of weeks to this instance. * @param {Number} The number of weeks to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addWeeks = function (value) { if (!value) { return this; } return this.addDays(value * 7); }; /** * Adds the specified number of months to this instance. * @param {Number} The number of months to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addMonths = function (value) { if (!value) { return this; } var n = this.getDate(); this.setDate(1); this.setMonth(this.getMonth() + value * 1); this.setDate(Math.min(n, $D.getDaysInMonth(this.getFullYear(), this.getMonth()))); return this; }; $P.addQuarters = function (value) { if (!value) { return this; } // note this will take you to the same point in the quarter as you are now. // i.e. - if you are 15 days into the quarter you'll be 15 days into the resulting one. // bonus: this allows adding fractional quarters return this.addMonths(value * 3); }; /** * Adds the specified number of years to this instance. * @param {Number} The number of years to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addYears = function (value) { if (!value) { return this; } return this.addMonths(value * 12); }; /** * Adds (or subtracts) to the value of the years, months, weeks, days, hours, minutes, seconds, milliseconds of the date instance using given configuration object. Positive and Negative values allowed. * Example

	Date.today().add( { days: 1, months: 1 } )

	new Date().add( { years: -1 } )
	
* @param {Object} Configuration object containing attributes (months, days, etc.) * @return {Date} this */ $P.add = function (config) { if (typeof config === "number") { this._orient = config; return this; } var x = config; if (x.day) { // If we should be a different date than today (eg: for 'tomorrow -1d', etc). // Should only effect parsing, not direct usage (eg, Finish and FinishExact) if ((x.day - this.getDate()) !== 0) { this.setDate(x.day); } } if (x.milliseconds) { this.addMilliseconds(x.milliseconds); } if (x.seconds) { this.addSeconds(x.seconds); } if (x.minutes) { this.addMinutes(x.minutes); } if (x.hours) { this.addHours(x.hours); } if (x.weeks) { this.addWeeks(x.weeks); } if (x.months) { this.addMonths(x.months); } if (x.years) { this.addYears(x.years); } if (x.days) { this.addDays(x.days); } return this; }; /** * Get the week number. Week one (1) is the week which contains the first Thursday of the year. Monday is considered the first day of the week. * The .getWeek() function does NOT convert the date to UTC. The local datetime is used. * Please use .getISOWeek() to get the week of the UTC converted date. * @return {Number} 1 to 53 */ $P.getWeek = function (utc) { // Create a copy of this date object var self, target = new Date(this.valueOf()); if (utc) { target.addMinutes(target.getTimezoneOffset()); self = target.clone(); } else { self = this; } // ISO week date weeks start on monday // so correct the day number var dayNr = (self.getDay() + 6) % 7; // ISO 8601 states that week 1 is the week // with the first thursday of that year. // Set the target date to the thursday in the target week target.setDate(target.getDate() - dayNr + 3); // Store the millisecond value of the target date var firstThursday = target.valueOf(); // Set the target to the first thursday of the year // First set the target to january first target.setMonth(0, 1); // Not a thursday? Correct the date to the next thursday if (target.getDay() !== 4) { target.setMonth(0, 1 + ((4 - target.getDay()) + 7) % 7); } // The weeknumber is the number of weeks between the // first thursday of the year and the thursday in the target week return 1 + Math.ceil((firstThursday - target) / 604800000); // 604800000 = 7 * 24 * 3600 * 1000 }; /** * Get the ISO 8601 week number. Week one ("01") is the week which contains the first Thursday of the year. Monday is considered the first day of the week. * The .getISOWeek() function does convert the date to it's UTC value. Please use .getWeek() to get the week of the local date. * @return {String} "01" to "53" */ $P.getISOWeek = function () { return p(this.getWeek(true)); }; /** * Moves the date to Monday of the week set. Week one (1) is the week which contains the first Thursday of the year. * @param {Number} A Number (1 to 53) that represents the week of the year. * @return {Date} this */ $P.setWeek = function (n) { if ((n - this.getWeek()) === 0) { if (this.getDay() !== 1) { return this.moveToDayOfWeek(1, (this.getDay() > 1 ? -1 : 1)); } else { return this; } } else { return this.moveToDayOfWeek(1, (this.getDay() > 1 ? -1 : 1)).addWeeks(n - this.getWeek()); } }; $P.setQuarter = function (qtr) { var month = Math.abs(((qtr-1) * 3) + 1); return this.setMonth(month, 1); }; $P.getQuarter = function () { return Date.getQuarter(this); }; $P.getDaysLeftInQuarter = function () { return Date.getDaysLeftInQuarter(this); }; /** * Moves the date to the next n'th occurrence of the dayOfWeek starting from the beginning of the month. The number (-1) is a magic number and will return the last occurrence of the dayOfWeek in the month. * @param {Number} The dayOfWeek to move to * @param {Number} The n'th occurrence to move to. Use (-1) to return the last occurrence in the month * @return {Date} this */ $P.moveToNthOccurrence = function (dayOfWeek, occurrence) { if (dayOfWeek === "Weekday") { if (occurrence > 0) { this.moveToFirstDayOfMonth(); if (this.is().weekday()) { occurrence -= 1; } } else if (occurrence < 0) { this.moveToLastDayOfMonth(); if (this.is().weekday()) { occurrence += 1; } } else { return this; } return this.addWeekdays(occurrence); } var shift = 0; if (occurrence > 0) { shift = occurrence - 1; } else if (occurrence === -1) { this.moveToLastDayOfMonth(); if (this.getDay() !== dayOfWeek) { this.moveToDayOfWeek(dayOfWeek, -1); } return this; } return this.moveToFirstDayOfMonth().addDays(-1).moveToDayOfWeek(dayOfWeek, +1).addWeeks(shift); }; var moveToN = function (getFunc, addFunc, nVal) { return function (value, orient) { var diff = (value - this[getFunc]() + nVal * (orient || +1)) % nVal; return this[addFunc]((diff === 0) ? diff += nVal * (orient || +1) : diff); }; }; /** * Move to the next or last dayOfWeek based on the orient value. * @param {Number} The dayOfWeek to move to * @param {Number} Forward (+1) or Back (-1). Defaults to +1. [Optional] * @return {Date} this */ $P.moveToDayOfWeek = moveToN("getDay", "addDays", 7); /** * Move to the next or last month based on the orient value. * @param {Number} The month to move to. 0 = January, 11 = December * @param {Number} Forward (+1) or Back (-1). Defaults to +1. [Optional] * @return {Date} this */ $P.moveToMonth = moveToN("getMonth", "addMonths", 12); /** * Get the Ordinate of the current day ("th", "st", "rd"). * @return {String} */ $P.getOrdinate = function () { var num = this.getDate(); return ord(num); }; /** * Get the Ordinal day (numeric day number) of the year, adjusted for leap year. * @return {Number} 1 through 365 (366 in leap years) */ $P.getOrdinalNumber = function () { return Math.ceil((this.clone().clearTime() - new Date(this.getFullYear(), 0, 1)) / 86400000) + 1; }; /** * Get the time zone abbreviation of the current date. * @return {String} The abbreviated time zone name (e.g. "EST") */ $P.getTimezone = function () { return $D.getTimezoneAbbreviation(this.getUTCOffset(), this.isDaylightSavingTime()); }; $P.setTimezoneOffset = function (offset) { var here = this.getTimezoneOffset(), there = Number(offset) * -6 / 10; return (there || there === 0) ? this.addMinutes(there - here) : this; }; $P.setTimezone = function (offset) { return this.setTimezoneOffset($D.getTimezoneOffset(offset)); }; /** * Indicates whether Daylight Saving Time is observed in the current time zone. * @return {Boolean} true|false */ $P.hasDaylightSavingTime = function () { return (Date.today().set({month: 0, day: 1}).getTimezoneOffset() !== Date.today().set({month: 6, day: 1}).getTimezoneOffset()); }; /** * Indicates whether this Date instance is within the Daylight Saving Time range for the current time zone. * @return {Boolean} true|false */ $P.isDaylightSavingTime = function () { return Date.today().set({month: 0, day: 1}).getTimezoneOffset() !== this.getTimezoneOffset(); }; /** * Get the offset from UTC of the current date. * @return {String} The 4-character offset string prefixed with + or - (e.g. "-0500") */ $P.getUTCOffset = function (offset) { var n = (offset || this.getTimezoneOffset()) * -10 / 6, r; if (n < 0) { r = (n - 10000).toString(); return r.charAt(0) + r.substr(2); } else { r = (n + 10000).toString(); return "+" + r.substr(1); } }; /** * Returns the number of milliseconds between this date and date. * @param {Date} Defaults to now * @return {Number} The diff in milliseconds */ $P.getElapsed = function (date) { return (date || new Date()) - this; }; /** * Set the value of year, month, day, hour, minute, second, millisecond of date instance using given configuration object. * Example

	Date.today().set( { day: 20, month: 1 } )

	new Date().set( { millisecond: 0 } )
	
* * @param {Object} Configuration object containing attributes (month, day, etc.) * @return {Date} this */ $P.set = function (config) { config = validateConfigObject.call(this, config); var key; for (key in config) { if (Object.prototype.hasOwnProperty.call(config, key)) { var name = key.charAt(0).toUpperCase() + key.slice(1); var addFunc, getFunc; if (key !== "week" && key !== "month" && key !== "timezone" && key !== "timezoneOffset") { name += "s"; } addFunc = "add" + name; getFunc = "get" + name; if (key === "month") { addFunc = addFunc + "s"; } else if (key === "year"){ getFunc = "getFullYear"; } if (key !== "day" && key !== "timezone" && key !== "timezoneOffset" && key !== "week" && key !== "hour") { this[addFunc](config[key] - this[getFunc]()); } else if ( key === "timezone"|| key === "timezoneOffset" || key === "week" || key === "hour") { this["set"+name](config[key]); } } } // day has to go last because you can't validate the day without first knowing the month if (config.day) { this.addDays(config.day - this.getDate()); } return this; }; /** * Moves the date to the first day of the month. * @return {Date} this */ $P.moveToFirstDayOfMonth = function () { return this.set({ day: 1 }); }; /** * Moves the date to the last day of the month. * @return {Date} this */ $P.moveToLastDayOfMonth = function () { return this.set({ day: $D.getDaysInMonth(this.getFullYear(), this.getMonth())}); }; /** * Converts the value of the current Date object to its equivalent string representation. * Format Specifiers * CUSTOM DATE AND TIME FORMAT STRINGS * Format Description Example * ------ --------------------------------------------------------------------------- ----------------------- * s The seconds of the minute between 0-59. "0" to "59" * ss The seconds of the minute with leading zero if required. "00" to "59" * * m The minute of the hour between 0-59. "0" or "59" * mm The minute of the hour with leading zero if required. "00" or "59" * * h The hour of the day between 1-12. "1" to "12" * hh The hour of the day with leading zero if required. "01" to "12" * * H The hour of the day between 0-23. "0" to "23" * HH The hour of the day with leading zero if required. "00" to "23" * * d The day of the month between 1 and 31. "1" to "31" * dd The day of the month with leading zero if required. "01" to "31" * ddd Abbreviated day name. Date.CultureInfo.abbreviatedDayNames. "Mon" to "Sun" * dddd The full day name. Date.CultureInfo.dayNames. "Monday" to "Sunday" * * M The month of the year between 1-12. "1" to "12" * MM The month of the year with leading zero if required. "01" to "12" * MMM Abbreviated month name. Date.CultureInfo.abbreviatedMonthNames. "Jan" to "Dec" * MMMM The full month name. Date.CultureInfo.monthNames. "January" to "December" * * yy The year as a two-digit number. "99" or "08" * yyyy The full four digit year. "1999" or "2008" * * t Displays the first character of the A.M./P.M. designator. "A" or "P" * Date.CultureInfo.amDesignator or Date.CultureInfo.pmDesignator * tt Displays the A.M./P.M. designator. "AM" or "PM" * Date.CultureInfo.amDesignator or Date.CultureInfo.pmDesignator * * S The ordinal suffix ("st, "nd", "rd" or "th") of the current day. "st, "nd", "rd" or "th" * * STANDARD DATE AND TIME FORMAT STRINGS * Format Description Example *------ --------------------------------------------------------------------------- ----------------------- * d The CultureInfo shortDate Format Pattern "M/d/yyyy" * D The CultureInfo longDate Format Pattern "dddd, MMMM dd, yyyy" * F The CultureInfo fullDateTime Format Pattern "dddd, MMMM dd, yyyy h:mm:ss tt" * m The CultureInfo monthDay Format Pattern "MMMM dd" * r The CultureInfo rfc1123 Format Pattern "ddd, dd MMM yyyy HH:mm:ss GMT" * s The CultureInfo sortableDateTime Format Pattern "yyyy-MM-ddTHH:mm:ss" * t The CultureInfo shortTime Format Pattern "h:mm tt" * T The CultureInfo longTime Format Pattern "h:mm:ss tt" * u The CultureInfo universalSortableDateTime Format Pattern "yyyy-MM-dd HH:mm:ssZ" * y The CultureInfo yearMonth Format Pattern "MMMM, yyyy" * * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @return {String} A string representation of the current Date object. */ var ord = function (n) { switch (n * 1) { case 1: case 21: case 31: return "st"; case 2: case 22: return "nd"; case 3: case 23: return "rd"; default: return "th"; } }; var parseStandardFormats = function (format) { var y, c = Date.CultureInfo.formatPatterns; switch (format) { case "d": return this.toString(c.shortDate); case "D": return this.toString(c.longDate); case "F": return this.toString(c.fullDateTime); case "m": return this.toString(c.monthDay); case "r": case "R": y = this.clone().addMinutes(this.getTimezoneOffset()); return y.toString(c.rfc1123) + " GMT"; case "s": return this.toString(c.sortableDateTime); case "t": return this.toString(c.shortTime); case "T": return this.toString(c.longTime); case "u": y = this.clone().addMinutes(this.getTimezoneOffset()); return y.toString(c.universalSortableDateTime); case "y": return this.toString(c.yearMonth); default: return false; } }; var parseFormatStringsClosure = function (context) { return function (m) { if (m.charAt(0) === "\\") { return m.replace("\\", ""); } switch (m) { case "hh": return p(context.getHours() < 13 ? (context.getHours() === 0 ? 12 : context.getHours()) : (context.getHours() - 12)); case "h": return context.getHours() < 13 ? (context.getHours() === 0 ? 12 : context.getHours()) : (context.getHours() - 12); case "HH": return p(context.getHours()); case "H": return context.getHours(); case "mm": return p(context.getMinutes()); case "m": return context.getMinutes(); case "ss": return p(context.getSeconds()); case "s": return context.getSeconds(); case "yyyy": return p(context.getFullYear(), 4); case "yy": return p(context.getFullYear()); case "y": return context.getFullYear(); case "E": case "dddd": return Date.CultureInfo.dayNames[context.getDay()]; case "ddd": return Date.CultureInfo.abbreviatedDayNames[context.getDay()]; case "dd": return p(context.getDate()); case "d": return context.getDate(); case "MMMM": return Date.CultureInfo.monthNames[context.getMonth()]; case "MMM": return Date.CultureInfo.abbreviatedMonthNames[context.getMonth()]; case "MM": return p((context.getMonth() + 1)); case "M": return context.getMonth() + 1; case "t": return context.getHours() < 12 ? Date.CultureInfo.amDesignator.substring(0, 1) : Date.CultureInfo.pmDesignator.substring(0, 1); case "tt": return context.getHours() < 12 ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator; case "S": return ord(context.getDate()); case "W": return context.getWeek(); case "WW": return context.getISOWeek(); case "Q": return "Q" + context.getQuarter(); case "q": return String(context.getQuarter()); case "z": return context.getTimezone(); case "Z": case "X": return Date.getTimezoneOffset(context.getTimezone()); case "ZZ": // Timezone offset in seconds return context.getTimezoneOffset() * -60; case "u": return context.getDay(); case "L": return ($D.isLeapYear(context.getFullYear())) ? 1 : 0; case "B": // Swatch Internet Time (.beats) return "@"+((context.getUTCSeconds() + (context.getUTCMinutes()*60) + ((context.getUTCHours()+1)*3600))/86.4); default: return m; } }; }; $P.toString = function (format, ignoreStandards) { // Standard Date and Time Format Strings. Formats pulled from CultureInfo file and // may vary by culture. if (!ignoreStandards && format && format.length === 1) { output = parseStandardFormats.call(this, format); if (output) { return output; } } var parseFormatStrings = parseFormatStringsClosure(this); return format ? format.replace(/((\\)?(dd?d?d?|MM?M?M?|yy?y?y?|hh?|HH?|mm?|ss?|tt?|S|q|Q|WW?W?W?)(?![^\[]*\]))/g, parseFormatStrings).replace(/\[|\]/g, "") : this._toString(); }; }()); /************************************************************* * SugarPak - Domain Specific Language - Syntactical Sugar * *************************************************************/ (function () { var $D = Date, $P = $D.prototype, $N = Number.prototype; // private $P._orient = +1; // private $P._nth = null; // private $P._is = false; // private $P._same = false; // private $P._isSecond = false; // private $N._dateElement = "days"; /** * Moves the date to the next instance of a date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.today().next().friday();
	Date.today().next().fri();
	Date.today().next().march();
	Date.today().next().mar();
	Date.today().next().week();
	
* * @return {Date} date */ $P.next = function () { this._move = true; this._orient = +1; return this; }; /** * Creates a new Date (Date.today()) and moves the date to the next instance of the date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.next().friday();
	Date.next().fri();
	Date.next().march();
	Date.next().mar();
	Date.next().week();
	
* * @return {Date} date */ $D.next = function () { return $D.today().next(); }; /** * Moves the date to the previous instance of a date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.today().last().friday();
	Date.today().last().fri();
	Date.today().last().march();
	Date.today().last().mar();
	Date.today().last().week();
	
* * @return {Date} date */ $P.last = $P.prev = $P.previous = function () { this._move = true; this._orient = -1; return this; }; /** * Creates a new Date (Date.today()) and moves the date to the previous instance of the date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.last().friday();
	Date.last().fri();
	Date.previous().march();
	Date.prev().mar();
	Date.last().week();
	
* * @return {Date} date */ $D.last = $D.prev = $D.previous = function () { return $D.today().last(); }; /** * Performs a equality check when followed by either a month name, day name or .weekday() function. * Example

	Date.today().is().friday(); // true|false
	Date.today().is().fri();
	Date.today().is().march();
	Date.today().is().mar();
	
* * @return {Boolean} true|false */ $P.is = function () { this._is = true; return this; }; /** * Determines if two date objects occur on/in exactly the same instance of the subsequent date part function. * The function .same() must be followed by a date part function (example: .day(), .month(), .year(), etc). * * An optional Date can be passed in the date part function. If now date is passed as a parameter, 'Now' is used. * * The following example demonstrates how to determine if two dates fall on the exact same day. * * Example

	var d1 = Date.today(); // today at 00:00
	var d2 = new Date();   // exactly now.

	// Do they occur on the same day?
	d1.same().day(d2); // true
	
	// Do they occur on the same hour?
	d1.same().hour(d2); // false, unless d2 hour is '00' (midnight).
	
	// What if it's the same day, but one year apart?
	var nextYear = Date.today().add(1).year();

	d1.same().day(nextYear); // false, because the dates must occur on the exact same day. 
	
* * Scenario: Determine if a given date occurs during some week period 2 months from now. * * Example

	var future = Date.today().add(2).months();
	return someDate.same().week(future); // true|false;
	
* * @return {Boolean} true|false */ $P.same = function () { this._same = true; this._isSecond = false; return this; }; /** * Determines if the current date/time occurs during Today. Must be preceded by the .is() function. * Example

	someDate.is().today();    // true|false
	new Date().is().today();  // true
	Date.today().is().today();// true
	Date.today().add(-1).day().is().today(); // false
	
* * @return {Boolean} true|false */ $P.today = function () { return this.same().day(); }; /** * Determines if the current date is a weekday. This function must be preceded by the .is() function. * Example

	Date.today().is().weekday(); // true|false
	
* * @return {Boolean} true|false */ $P.weekday = function () { if (this._nth) { return df("Weekday").call(this); } if (this._move) { return this.addWeekdays(this._orient); } if (this._is) { this._is = false; return (!this.is().sat() && !this.is().sun()); } return false; }; /** * Determines if the current date is on the weekend. This function must be preceded by the .is() function. * Example

	Date.today().is().weekend(); // true|false
	
* * @return {Boolean} true|false */ $P.weekend = function () { if (this._is) { this._is = false; return (this.is().sat() || this.is().sun()); } return false; }; /** * Sets the Time of the current Date instance. A string "6:15 pm" or config object {hour:18, minute:15} are accepted. * Example

	// Set time to 6:15pm with a String
	Date.today().at("6:15pm");

	// Set time to 6:15pm with a config object
	Date.today().at({hour:18, minute:15});
	
* * @return {Date} date */ $P.at = function (time) { return (typeof time === "string") ? $D.parse(this.toString("d") + " " + time) : this.set(time); }; /** * Creates a new Date() and adds this (Number) to the date based on the preceding date element function (eg. second|minute|hour|day|month|year). * Example

	// Undeclared Numbers must be wrapped with parentheses. Requirment of JavaScript.
	(3).days().fromNow();
	(6).months().fromNow();

	// Declared Number variables do not require parentheses. 
	var n = 6;
	n.months().fromNow();
	
* * @return {Date} A new Date instance */ $N.fromNow = $N.after = function (date) { var c = {}; c[this._dateElement] = this; return ((!date) ? new Date() : date.clone()).add(c); }; /** * Creates a new Date() and subtract this (Number) from the date based on the preceding date element function (eg. second|minute|hour|day|month|year). * Example

	// Undeclared Numbers must be wrapped with parentheses. Requirment of JavaScript.
	(3).days().ago();
	(6).months().ago();

	// Declared Number variables do not require parentheses. 
	var n = 6;
	n.months().ago();
	
* * @return {Date} A new Date instance */ $N.ago = $N.before = function (date) { var c = {}, s = (this._dateElement[this._dateElement.length-1] !== "s") ? this._dateElement + "s" : this._dateElement; c[s] = this * -1; return ((!date) ? new Date() : date.clone()).add(c); }; // Do NOT modify the following string tokens. These tokens are used to build dynamic functions. // All culture-specific strings can be found in the CultureInfo files. var dx = ("sunday monday tuesday wednesday thursday friday saturday").split(/\s/), mx = ("january february march april may june july august september october november december").split(/\s/), px = ("Millisecond Second Minute Hour Day Week Month Year Quarter Weekday").split(/\s/), pxf = ("Milliseconds Seconds Minutes Hours Date Week Month FullYear Quarter").split(/\s/), nth = ("final first second third fourth fifth").split(/\s/), de; /** * Returns an object literal of all the date parts. * Example

	var o = new Date().toObject();
	
	// { year: 2008, month: 4, week: 20, day: 13, hour: 18, minute: 9, second: 32, millisecond: 812 }
	
	// The object properties can be referenced directly from the object.
	
	alert(o.day);  // alerts "13"
	alert(o.year); // alerts "2008"
	
* * @return {Date} An object literal representing the original date object. */ $P.toObject = function () { var o = {}; for (var i = 0; i < px.length; i++) { if (this["get" + pxf[i]]) { o[px[i].toLowerCase()] = this["get" + pxf[i]](); } } return o; }; /** * Returns a date created from an object literal. Ignores the .week property if set in the config. * Example

	var o = new Date().toObject();
	
	return Date.fromObject(o); // will return the same date. 

	var o2 = {month: 1, day: 20, hour: 18}; // birthday party!
	Date.fromObject(o2);
	
* * @return {Date} An object literal representing the original date object. */ $D.fromObject = function(config) { config.week = null; return Date.today().set(config); }; // Create day name functions and abbreviated day name functions (eg. monday(), friday(), fri()). var df = function (n) { return function () { if (this._is) { this._is = false; return this.getDay() === n; } if (this._move) { this._move = null; } if (this._nth !== null) { // If the .second() function was called earlier, remove the _orient // from the date, and then continue. // This is required because 'second' can be used in two different context. // // Example // // Date.today().add(1).second(); // Date.march().second().monday(); // // Things get crazy with the following... // Date.march().add(1).second().second().monday(); // but it works!! // if (this._isSecond) { this.addSeconds(this._orient * -1); } // make sure we reset _isSecond this._isSecond = false; var ntemp = this._nth; this._nth = null; var temp = this.clone().moveToLastDayOfMonth(); this.moveToNthOccurrence(n, ntemp); if (this > temp) { throw new RangeError($D.getDayName(n) + " does not occur " + ntemp + " times in the month of " + $D.getMonthName(temp.getMonth()) + " " + temp.getFullYear() + "."); } return this; } return this.moveToDayOfWeek(n, this._orient); }; }; var sdf = function (n) { return function () { var t = $D.today(), shift = n - t.getDay(); if (n === 0 && Date.CultureInfo.firstDayOfWeek === 1 && t.getDay() !== 0) { shift = shift + 7; } return t.addDays(shift); }; }; // Create month name functions and abbreviated month name functions (eg. january(), march(), mar()). var month_instance_functions = function (n) { return function () { if (this._is) { this._is = false; return this.getMonth() === n; } return this.moveToMonth(n, this._orient); }; }; var month_static_functions = function (n) { return function () { return $D.today().set({ month: n, day: 1 }); }; }; var processTerms = function (names, staticFunc, instanceFunc) { for (var i = 0; i < names.length; i++) { // Create constant static Name variables. $D[names[i].toUpperCase()] = $D[names[i].toUpperCase().substring(0, 3)] = i; // Create Name functions. $D[names[i]] = $D[names[i].substring(0, 3)] = staticFunc(i); // Create Name instance functions. $P[names[i]] = $P[names[i].substring(0, 3)] = instanceFunc(i); } }; processTerms(dx, sdf, df); processTerms(mx, month_static_functions, month_instance_functions); // Create date element functions and plural date element functions used with Date (eg. day(), days(), months()). var ef = function (j) { return function () { // if the .second() function was called earlier, the _orient // has alread been added. Just return this and reset _isSecond. if (this._isSecond) { this._isSecond = false; return this; } if (this._same) { this._same = this._is = false; var o1 = this.toObject(), o2 = (arguments[0] || new Date()).toObject(), v = "", k = j.toLowerCase(); // the substr trick with -1 doesn't work in IE8 or less k = (k[k.length-1] === "s") ? k.substring(0,k.length-1) : k; for (var m = (px.length - 1); m > -1; m--) { v = px[m].toLowerCase(); if (o1[v] !== o2[v]) { return false; } if (k === v) { break; } } return true; } if (j.substring(j.length - 1) !== "s") { j += "s"; } if (this._move) { this._move = null; } return this["add" + j](this._orient); }; }; var nf = function (n) { return function () { this._dateElement = n; return this; }; }; for (var k = 0; k < px.length; k++) { de = px[k].toLowerCase(); if(de !== "weekday") { // Create date element functions and plural date element functions used with Date (eg. day(), days(), months()). $P[de] = $P[de + "s"] = ef(px[k]); // Create date element functions and plural date element functions used with Number (eg. day(), days(), months()). $N[de] = $N[de + "s"] = nf(de + "s"); } } $P._ss = ef("Second"); var nthfn = function (n) { return function (dayOfWeek) { if (this._same) { return this._ss(arguments[0]); } if (dayOfWeek || dayOfWeek === 0) { return this.moveToNthOccurrence(dayOfWeek, n); } this._nth = n; // if the operator is 'second' add the _orient, then deal with it later... if (n === 2 && (dayOfWeek === undefined || dayOfWeek === null)) { this._isSecond = true; return this.addSeconds(this._orient); } return this; }; }; for (var l = 0; l < nth.length; l++) { $P[nth[l]] = (l === 0) ? nthfn(-1) : nthfn(l); } }()); (function () { "use strict"; Date.Parsing = { Exception: function (s) { this.message = "Parse error at '" + s.substring(0, 10) + " ...'"; } }; var $P = Date.Parsing; var dayOffsets = { standard: [0,31,59,90,120,151,181,212,243,273,304,334], leap: [0,31,60,91,121,152,182,213,244,274,305,335] }; $P.isLeapYear = function(year) { return ((year % 4 === 0) && (year % 100 !== 0)) || (year % 400 === 0); }; var utils = { multiReplace : function (str, hash ) { var key; for (key in hash) { if (Object.prototype.hasOwnProperty.call(hash, key)) { var regex; if (typeof hash[key] === "function") { } else { regex = (hash[key] instanceof RegExp) ? hash[key] : new RegExp(hash[key], "g"); } str = str.replace(regex, key); } } return str; }, getDayOfYearFromWeek : function (obj) { var d, jan4, offset; obj.weekDay = (!obj.weekDay && obj.weekDay !== 0) ? 1 : obj.weekDay; d = new Date(obj.year, 0, 4); jan4 = d.getDay() === 0 ? 7 : d.getDay(); // JS is 0 indexed on Sunday. offset = jan4+3; obj.dayOfYear = ((obj.week * 7) + (obj.weekDay === 0 ? 7 : obj.weekDay))-offset; return obj; }, getDayOfYear : function (obj, dayOffset) { if (!obj.dayOfYear) { obj = utils.getDayOfYearFromWeek(obj); } for (var i=0;i <= dayOffset.length;i++) { if (obj.dayOfYear < dayOffset[i] || i === dayOffset.length) { obj.day = obj.day ? obj.day : (obj.dayOfYear - dayOffset[i-1]); break; } else { obj.month = i; } } return obj; }, adjustForTimeZone : function (obj, date) { var offset; if (obj.zone.toUpperCase() === "Z" || (obj.zone_hours === 0 && obj.zone_minutes === 0)) { // it's UTC/GML so work out the current timeszone offset offset = -date.getTimezoneOffset(); } else { offset = (obj.zone_hours*60) + (obj.zone_minutes || 0); if (obj.zone_sign === "+") { offset *= -1; } offset -= date.getTimezoneOffset(); } date.setMinutes(date.getMinutes()+offset); return date; }, setDefaults : function (obj) { obj.year = obj.year || Date.today().getFullYear(); obj.hours = obj.hours || 0; obj.minutes = obj.minutes || 0; obj.seconds = obj.seconds || 0; obj.milliseconds = obj.milliseconds || 0; if (!(!obj.month && (obj.week || obj.dayOfYear))) { // if we have a month, or if we don't but don't have the day calculation data obj.month = obj.month || 0; obj.day = obj.day || 1; } return obj; }, dataNum: function (data, mod, explict, postProcess) { var dataNum = data*1; if (mod) { if (postProcess) { return data ? mod(data)*1 : data; } else { return data ? mod(dataNum) : data; } } else if (!explict){ return data ? dataNum : data; } else { return (data && typeof data !== "undefined") ? dataNum : data; } }, timeDataProcess: function (obj) { var timeObj = {}; for (var x in obj.data) { if (obj.data.hasOwnProperty(x)) { timeObj[x] = obj.ignore[x] ? obj.data[x] : utils.dataNum(obj.data[x], obj.mods[x], obj.explict[x], obj.postProcess[x]); } } if (obj.data.secmins) { obj.data.secmins = obj.data.secmins.replace(",", ".") * 60; if (!timeObj.minutes) { timeObj.minutes = obj.data.secmins; } else if (!timeObj.seconds) { timeObj.seconds = obj.data.secmins; } delete obj.secmins; } return timeObj; }, buildTimeObjectFromData: function (data) { var time = utils.timeDataProcess({ data: { year : data[1], month : data[5], day : data[7], week : data[8], dayOfYear : data[10], hours : data[15], zone_hours : data[23], zone_minutes : data[24], zone : data[21], zone_sign : data[22], weekDay : data[9], minutes: data[16], seconds: data[19], milliseconds: data[20], secmins: data[18] }, mods: { month: function(data) { return data-1; }, weekDay: function (data) { data = Math.abs(data); return (data === 7 ? 0 : data); }, minutes: function (data) { return data.replace(":",""); }, seconds: function (data) { return Math.floor( (data.replace(":","").replace(",","."))*1 ); }, milliseconds: function (data) { return (data.replace(",",".")*1000); } }, postProcess: { minutes: true, seconds: true, milliseconds: true }, explict: { zone_hours: true, zone_minutes: true }, ignore: { zone: true, zone_sign: true, secmins: true } }); return time; }, addToHash: function (hash, keys, data) { keys = keys; data = data; var len = keys.length; for (var i = 0; i < len; i++) { hash[keys[i]] = data[i]; } return hash; }, combineRegex: function (r1, r2) { return new RegExp("(("+r1.source+")\\s("+r2.source+"))"); }, getDateNthString: function(add, last, inc){ if (add) { return Date.today().addDays(inc).toString("d"); } else if (last) { return Date.today().last()[inc]().toString("d"); } }, buildRegexData: function (array) { var arr = []; var len = array.length; for (var i=0; i < len; i++) { if (Object.prototype.toString.call(array[i]) === '[object Array]') { // oldIE compat version of Array.isArray arr.push(this.combineRegex(array[i][0], array[i][1])); } else { arr.push(array[i]); } } return arr; } }; $P.processTimeObject = function (obj) { var date, dayOffset; utils.setDefaults(obj); dayOffset = ($P.isLeapYear(obj.year)) ? dayOffsets.leap : dayOffsets.standard; if (!obj.month && (obj.week || obj.dayOfYear)) { utils.getDayOfYear(obj, dayOffset); } else { obj.dayOfYear = dayOffset[obj.month] + obj.day; } date = new Date(obj.year, obj.month, obj.day, obj.hours, obj.minutes, obj.seconds, obj.milliseconds); if (obj.zone) { utils.adjustForTimeZone(obj, date); // adjust (and calculate) for timezone } return date; }; $P.ISO = { regex : /^([\+-]?\d{4}(?!\d{2}\b))((-?)((0[1-9]|1[0-2])(\3([12]\d|0[1-9]|3[01]))?|W([0-4]\d|5[0-3])(-?[1-7])?|(00[1-9]|0[1-9]\d|[12]\d{2}|3([0-5]\d|6[1-6])))([T\s]((([01]\d|2[0-4])((:?)[0-5]\d)?|24\:?00)([\.,]\d+(?!:))?)?(\17[0-5]\d([\.,]\d+)?)?\s?([zZ]|([\+-])([01]\d|2[0-3]):?([0-5]\d)?)?)?)?$/, parse : function (s) { var time, data = s.match(this.regex); if (!data || !data.length) { return null; } time = utils.buildTimeObjectFromData(data); if (!time.year || (!time.year && (!time.month && !time.day) && (!time.week && !time.dayOfYear)) ) { return null; } return $P.processTimeObject(time); } }; $P.Numeric = { isNumeric: function (e){return!isNaN(parseFloat(e))&&isFinite(e);}, regex: /\b([0-1]?[0-9])([0-3]?[0-9])([0-2]?[0-9]?[0-9][0-9])\b/i, parse: function (s) { var data, i, time = {}, order = Date.CultureInfo.dateElementOrder.split(""); if (!(this.isNumeric(s)) || // if it's non-numeric OR (s[0] === "+" && s[0] === "-")) { // It's an arithmatic string (eg +/-1000) return null; } if (s.length < 5 && s.indexOf(".") < 0 && s.indexOf("/") < 0) { // assume it's just a year. time.year = s; return $P.processTimeObject(time); } data = s.match(this.regex); if (!data || !data.length) { return null; } for (i=0; i < order.length; i++) { switch(order[i]) { case "d": time.day = data[i+1]; break; case "m": time.month = (data[i+1]-1); break; case "y": time.year = data[i+1]; break; } } return $P.processTimeObject(time); } }; $P.Normalizer = { regexData: function () { var $R = Date.CultureInfo.regexPatterns; return utils.buildRegexData([ $R.tomorrow, $R.yesterday, [$R.past, $R.mon], [$R.past, $R.tue], [$R.past, $R.wed], [$R.past, $R.thu], [$R.past, $R.fri], [$R.past, $R.sat], [$R.past, $R.sun] ]); }, basicReplaceHash : function() { var $R = Date.CultureInfo.regexPatterns; return { "January": $R.jan.source, "February": $R.feb, "March": $R.mar, "April": $R.apr, "May": $R.may, "June": $R.jun, "July": $R.jul, "August": $R.aug, "September": $R.sep, "October": $R.oct, "November": $R.nov, "December": $R.dec, "": /\bat\b/gi, " ": /\s{2,}/, "am": $R.inTheMorning, "9am": $R.thisMorning, "pm": $R.inTheEvening, "7pm":$R.thisEvening }; }, keys : function(){ return [ utils.getDateNthString(true, false, 1), // tomorrow utils.getDateNthString(true, false, -1), // yesterday utils.getDateNthString(false, true, "monday"), //last mon utils.getDateNthString(false, true, "tuesday"), //last tues utils.getDateNthString(false, true, "wednesday"), //last wed utils.getDateNthString(false, true, "thursday"), //last thurs utils.getDateNthString(false, true, "friday"), //last fri utils.getDateNthString(false, true, "saturday"), //last sat utils.getDateNthString(false, true, "sunday") //last sun ]; }, buildRegexFunctions: function () { var $R = Date.CultureInfo.regexPatterns; var __ = Date.i18n.__; var tomorrowRE = new RegExp("(\\b\\d\\d?("+__("AM")+"|"+__("PM")+")? )("+$R.tomorrow.source.slice(1)+")", "i"); // adapted tomorrow regex for AM PM relative dates var todayRE = new RegExp($R.today.source + "(?!\\s*([+-]))\\b"); // today, but excludes the math operators (eg "today + 2h") this.replaceFuncs = [ [todayRE, function (full) { return (full.length > 1) ? Date.today().toString("d") : full; }], [tomorrowRE, function(full, m1) { var t = Date.today().addDays(1).toString("d"); return (t + " " + m1); }], [$R.amThisMorning, function(str, am){return am;}], [$R.pmThisEvening, function(str, pm){return pm;}] ]; }, buildReplaceData: function () { this.buildRegexFunctions(); this.replaceHash = utils.addToHash(this.basicReplaceHash(), this.keys(), this.regexData()); }, stringReplaceFuncs: function (s) { for (var i=0; i < this.replaceFuncs.length; i++) { s = s.replace(this.replaceFuncs[i][0], this.replaceFuncs[i][1]); } return s; }, parse: function (s) { s = this.stringReplaceFuncs(s); s = utils.multiReplace(s, this.replaceHash); try { var n = s.split(/([\s\-\.\,\/\x27]+)/); if (n.length === 3 && $P.Numeric.isNumeric(n[0]) && $P.Numeric.isNumeric(n[2]) && (n[2].length >= 4)) { // ok, so we're dealing with x/year. But that's not a full date. // This fixes wonky dateElementOrder parsing when set to dmy order. if (Date.CultureInfo.dateElementOrder[0] === "d") { s = "1/" + n[0] + "/" + n[2]; // set to 1st of month and normalize the seperator } } } catch (e) {} return s; } }; $P.Normalizer.buildReplaceData(); }()); (function () { var $P = Date.Parsing; var _ = $P.Operators = { // // Tokenizers // rtoken: function (r) { // regex token return function (s) { var mx = s.match(r); if (mx) { return ([ mx[0], s.substring(mx[0].length) ]); } else { throw new $P.Exception(s); } }; }, token: function () { // whitespace-eating token return function (s) { return _.rtoken(new RegExp("^\\s*" + s + "\\s*"))(s); }; }, stoken: function (s) { // string token return _.rtoken(new RegExp("^" + s)); }, // Atomic Operators until: function (p) { return function (s) { var qx = [], rx = null; while (s.length) { try { rx = p.call(this, s); } catch (e) { qx.push(rx[0]); s = rx[1]; continue; } break; } return [ qx, s ]; }; }, many: function (p) { return function (s) { var rx = [], r = null; while (s.length) { try { r = p.call(this, s); } catch (e) { return [ rx, s ]; } rx.push(r[0]); s = r[1]; } return [ rx, s ]; }; }, // generator operators -- see below optional: function (p) { return function (s) { var r = null; try { r = p.call(this, s); } catch (e) { return [ null, s ]; } return [ r[0], r[1] ]; }; }, not: function (p) { return function (s) { try { p.call(this, s); } catch (e) { return [null, s]; } throw new $P.Exception(s); }; }, ignore: function (p) { return p ? function (s) { var r = null; r = p.call(this, s); return [null, r[1]]; } : null; }, product: function () { var px = arguments[0], qx = Array.prototype.slice.call(arguments, 1), rx = []; for (var i = 0 ; i < px.length ; i++) { rx.push(_.each(px[i], qx)); } return rx; }, cache: function (rule) { var cache = {}, cache_length = 0, cache_keys = [], CACHE_MAX = Date.Config.CACHE_MAX || 100000, r = null; var cacheCheck = function () { if (cache_length === CACHE_MAX) { // kill several keys, don't want to have to do this all the time... for (var i=0; i < 10; i++) { var key = cache_keys.shift(); if (key) { delete cache[key]; cache_length--; } } } }; return function (s) { cacheCheck(); try { r = cache[s] = (cache[s] || rule.call(this, s)); } catch (e) { r = cache[s] = e; } cache_length++; cache_keys.push(s); if (r instanceof $P.Exception) { throw r; } else { return r; } }; }, // vector operators -- see below any: function () { var px = arguments; return function (s) { var r = null; for (var i = 0; i < px.length; i++) { if (px[i] == null) { continue; } try { r = (px[i].call(this, s)); } catch (e) { r = null; } if (r) { return r; } } throw new $P.Exception(s); }; }, each: function () { var px = arguments; return function (s) { var rx = [], r = null; for (var i = 0; i < px.length ; i++) { if (px[i] == null) { continue; } try { r = (px[i].call(this, s)); } catch (e) { throw new $P.Exception(s); } rx.push(r[0]); s = r[1]; } return [ rx, s]; }; }, all: function () { var px = arguments, _ = _; return _.each(_.optional(px)); }, // delimited operators sequence: function (px, d, c) { d = d || _.rtoken(/^\s*/); c = c || null; if (px.length === 1) { return px[0]; } return function (s) { var r = null, q = null; var rx = []; for (var i = 0; i < px.length ; i++) { try { r = px[i].call(this, s); } catch (e) { break; } rx.push(r[0]); try { q = d.call(this, r[1]); } catch (ex) { q = null; break; } s = q[1]; } if (!r) { throw new $P.Exception(s); } if (q) { throw new $P.Exception(q[1]); } if (c) { try { r = c.call(this, r[1]); } catch (ey) { throw new $P.Exception(r[1]); } } return [ rx, (r?r[1]:s) ]; }; }, // // Composite Operators // between: function (d1, p, d2) { d2 = d2 || d1; var _fn = _.each(_.ignore(d1), p, _.ignore(d2)); return function (s) { var rx = _fn.call(this, s); return [[rx[0][0], r[0][2]], rx[1]]; }; }, list: function (p, d, c) { d = d || _.rtoken(/^\s*/); c = c || null; return (p instanceof Array ? _.each(_.product(p.slice(0, -1), _.ignore(d)), p.slice(-1), _.ignore(c)) : _.each(_.many(_.each(p, _.ignore(d))), px, _.ignore(c))); }, set: function (px, d, c) { d = d || _.rtoken(/^\s*/); c = c || null; return function (s) { // r is the current match, best the current 'best' match // which means it parsed the most amount of input var r = null, p = null, q = null, rx = null, best = [[], s], last = false; // go through the rules in the given set for (var i = 0; i < px.length ; i++) { // last is a flag indicating whether this must be the last element // if there is only 1 element, then it MUST be the last one q = null; p = null; r = null; last = (px.length === 1); // first, we try simply to match the current pattern // if not, try the next pattern try { r = px[i].call(this, s); } catch (e) { continue; } // since we are matching against a set of elements, the first // thing to do is to add r[0] to matched elements rx = [[r[0]], r[1]]; // if we matched and there is still input to parse and // we don't already know this is the last element, // we're going to next check for the delimiter ... // if there's none, or if there's no input left to parse // than this must be the last element after all ... if (r[1].length > 0 && ! last) { try { q = d.call(this, r[1]); } catch (ex) { last = true; } } else { last = true; } // if we parsed the delimiter and now there's no more input, // that means we shouldn't have parsed the delimiter at all // so don't update r and mark this as the last element ... if (!last && q[1].length === 0) { last = true; } // so, if this isn't the last element, we're going to see if // we can get any more matches from the remaining (unmatched) // elements ... if (!last) { // build a list of the remaining rules we can match against, // i.e., all but the one we just matched against var qx = []; for (var j = 0; j < px.length ; j++) { if (i !== j) { qx.push(px[j]); } } // now invoke recursively set with the remaining input // note that we don't include the closing delimiter ... // we'll check for that ourselves at the end p = _.set(qx, d).call(this, q[1]); // if we got a non-empty set as a result ... // (otw rx already contains everything we want to match) if (p[0].length > 0) { // update current result, which is stored in rx ... // basically, pick up the remaining text from p[1] // and concat the result from p[0] so that we don't // get endless nesting ... rx[0] = rx[0].concat(p[0]); rx[1] = p[1]; } } // at this point, rx either contains the last matched element // or the entire matched set that starts with this element. // now we just check to see if this variation is better than // our best so far, in terms of how much of the input is parsed if (rx[1].length < best[1].length) { best = rx; } // if we've parsed all the input, then we're finished if (best[1].length === 0) { break; } } // so now we've either gone through all the patterns trying them // as the initial match; or we found one that parsed the entire // input string ... // if best has no matches, just return empty set ... if (best[0].length === 0) { return best; } // if a closing delimiter is provided, then we have to check it also if (c) { // we try this even if there is no remaining input because the pattern // may well be optional or match empty input ... try { q = c.call(this, best[1]); } catch (ey) { throw new $P.Exception(best[1]); } // it parsed ... be sure to update the best match remaining input best[1] = q[1]; } // if we're here, either there was no closing delimiter or we parsed it // so now we have the best match; just return it! return best; }; }, forward: function (gr, fname) { return function (s) { return gr[fname].call(this, s); }; }, // // Translation Operators // replace: function (rule, repl) { return function (s) { var r = rule.call(this, s); return [repl, r[1]]; }; }, process: function (rule, fn) { return function (s) { var r = rule.call(this, s); return [fn.call(this, r[0]), r[1]]; }; }, min: function (min, rule) { return function (s) { var rx = rule.call(this, s); if (rx[0].length < min) { throw new $P.Exception(s); } return rx; }; } }; // Generator Operators And Vector Operators // Generators are operators that have a signature of F(R) => R, // taking a given rule and returning another rule, such as // ignore, which parses a given rule and throws away the result. // Vector operators are those that have a signature of F(R1,R2,...) => R, // take a list of rules and returning a new rule, such as each. // Generator operators are converted (via the following _generator // function) into functions that can also take a list or array of rules // and return an array of new rules as though the function had been // called on each rule in turn (which is what actually happens). // This allows generators to be used with vector operators more easily. // Example: // each(ignore(foo, bar)) instead of each(ignore(foo), ignore(bar)) // This also turns generators into vector operators, which allows // constructs like: // not(cache(foo, bar)) var _generator = function (op) { function gen() { var args = null, rx = [], px, i; if (arguments.length > 1) { args = Array.prototype.slice.call(arguments); } else if (arguments[0] instanceof Array) { args = arguments[0]; } if (args) { px = args.shift(); if (px.length > 0) { args.unshift(px[i]); rx.push(op.apply(null, args)); args.shift(); return rx; } } else { return op.apply(null, arguments); } } return gen; }; var gx = "optional not ignore cache".split(/\s/); for (var i = 0 ; i < gx.length ; i++) { _[gx[i]] = _generator(_[gx[i]]); } var _vector = function (op) { return function () { if (arguments[0] instanceof Array) { return op.apply(null, arguments[0]); } else { return op.apply(null, arguments); } }; }; var vx = "each any all".split(/\s/); for (var j = 0 ; j < vx.length ; j++) { _[vx[j]] = _vector(_[vx[j]]); } }()); (function () { var $D = Date; var flattenAndCompact = function (ax) { var rx = []; for (var i = 0; i < ax.length; i++) { if (ax[i] instanceof Array) { rx = rx.concat(flattenAndCompact(ax[i])); } else { if (ax[i]) { rx.push(ax[i]); } } } return rx; }; var parseMeridian = function () { if (this.meridian && (this.hour || this.hour === 0)) { if (this.meridian === "a" && this.hour > 11 && Date.Config.strict24hr){ throw "Invalid hour and meridian combination"; } else if (this.meridian === "p" && this.hour < 12 && Date.Config.strict24hr){ throw "Invalid hour and meridian combination"; } else if (this.meridian === "p" && this.hour < 12) { this.hour = this.hour + 12; } else if (this.meridian === "a" && this.hour === 12) { this.hour = 0; } } }; var setDefaults = function () { var now = new Date(); if ((this.hour || this.minute) && (!this.month && !this.year && !this.day)) { this.day = now.getDate(); } if (!this.year) { this.year = now.getFullYear(); } if (!this.month && this.month !== 0) { this.month = now.getMonth(); } if (!this.day) { this.day = 1; } if (!this.hour) { this.hour = 0; } if (!this.minute) { this.minute = 0; } if (!this.second) { this.second = 0; } if (!this.millisecond) { this.millisecond = 0; } }; var finishUtils = { getToday: function () { if (this.now || "hour minute second".indexOf(this.unit) !== -1) { return new Date(); } else { return $D.today(); } }, setDaysFromWeekday: function (today, orient){ var gap; orient = orient || 1; this.unit = "day"; gap = ($D.getDayNumberFromName(this.weekday) - today.getDay()); this.days = gap ? ((gap + (orient * 7)) % 7) : (orient * 7); return this; }, setMonthsFromMonth: function (today, orient) { var gap; orient = orient || 1; this.unit = "month"; gap = (this.month - today.getMonth()); this.months = gap ? ((gap + (orient * 12)) % 12) : (orient * 12); this.month = null; return this; }, setDMYFromWeekday: function () { var d = Date[this.weekday](); this.day = d.getDate(); if (!this.month) { this.month = d.getMonth(); } this.year = d.getFullYear(); return this; }, setUnitValue: function (orient) { if (!this.value && this.operator && this.operator !== null && this[this.unit + "s"] && this[this.unit + "s"] !== null) { this[this.unit + "s"] = this[this.unit + "s"] + ((this.operator === "add") ? 1 : -1) + (this.value||0) * orient; } else if (this[this.unit + "s"] == null || this.operator != null) { if (!this.value) { this.value = 1; } this[this.unit + "s"] = this.value * orient; } }, generateDateFromWeeks: function () { var weekday = (this.weekday !== undefined) ? this.weekday : "today"; var d = Date[weekday]().addWeeks(this.weeks); if (this.now) { d.setTimeToNow(); } return d; } }; $D.Translator = { hour: function (s) { return function () { this.hour = Number(s); }; }, minute: function (s) { return function () { this.minute = Number(s); }; }, second: function (s) { return function () { this.second = Number(s); }; }, /* for ss.s format */ secondAndMillisecond: function (s) { return function () { var mx = s.match(/^([0-5][0-9])\.([0-9]{1,3})/); this.second = Number(mx[1]); this.millisecond = Number(mx[2]); }; }, meridian: function (s) { return function () { this.meridian = s.slice(0, 1).toLowerCase(); }; }, timezone: function (s) { return function () { var n = s.replace(/[^\d\+\-]/g, ""); if (n.length) { this.timezoneOffset = Number(n); } else { this.timezone = s.toLowerCase(); } }; }, day: function (x) { var s = x[0]; return function () { this.day = Number(s.match(/\d+/)[0]); if (this.day < 1) { throw "invalid day"; } }; }, month: function (s) { return function () { this.month = (s.length === 3) ? "jan feb mar apr may jun jul aug sep oct nov dec".indexOf(s)/4 : Number(s) - 1; if (this.month < 0) { throw "invalid month"; } }; }, year: function (s) { return function () { var n = Number(s); this.year = ((s.length > 2) ? n : (n + (((n + 2000) < Date.CultureInfo.twoDigitYearMax) ? 2000 : 1900))); }; }, rday: function (s) { return function () { switch (s) { case "yesterday": this.days = -1; break; case "tomorrow": this.days = 1; break; case "today": this.days = 0; break; case "now": this.days = 0; this.now = true; break; } }; }, finishExact: function (x) { var d; x = (x instanceof Array) ? x : [x]; for (var i = 0 ; i < x.length ; i++) { if (x[i]) { x[i].call(this); } } setDefaults.call(this); parseMeridian.call(this); if (this.day > $D.getDaysInMonth(this.year, this.month)) { throw new RangeError(this.day + " is not a valid value for days."); } d = new Date(this.year, this.month, this.day, this.hour, this.minute, this.second, this.millisecond); if (this.year < 100) { d.setFullYear(this.year); // means years less that 100 are process correctly. JS will parse it otherwise as 1900-1999. } if (this.timezone) { d.set({ timezone: this.timezone }); } else if (this.timezoneOffset) { d.set({ timezoneOffset: this.timezoneOffset }); } return d; }, finish: function (x) { var today, expression, orient, temp; x = (x instanceof Array) ? flattenAndCompact(x) : [ x ]; if (x.length === 0) { return null; } for (var i = 0 ; i < x.length ; i++) { if (typeof x[i] === "function") { x[i].call(this); } } if (this.now && !this.unit && !this.operator) { return new Date(); } else { today = finishUtils.getToday.call(this); } expression = !!(this.days && this.days !== null || this.orient || this.operator); orient = ((this.orient === "past" || this.operator === "subtract") ? -1 : 1); if (this.month && this.unit === "week") { this.value = this.month + 1; delete this.month; delete this.day; } if ((this.month || this.month === 0) && "year day hour minute second".indexOf(this.unit) !== -1) { if (!this.value) { this.value = this.month + 1; } this.month = null; expression = true; } if (!expression && this.weekday && !this.day && !this.days) { finishUtils.setDMYFromWeekday.call(this); } if (expression && this.weekday && this.unit !== "month" && this.unit !== "week") { finishUtils.setDaysFromWeekday.call(this, today, orient); } if (this.weekday && this.unit !== "week" && !this.day && !this.days) { temp = Date[this.weekday](); this.day = temp.getDate(); if (temp.getMonth() !== today.getMonth()) { this.month = temp.getMonth(); } } if (this.month && this.unit === "day" && this.operator) { if (!this.value) { this.value = (this.month + 1); } this.month = null; } if (this.value != null && this.month != null && this.year != null) { this.day = this.value * 1; } if (this.month && !this.day && this.value) { today.set({ day: this.value * 1 }); if (!expression) { this.day = this.value * 1; } } if (!this.month && this.value && this.unit === "month" && !this.now) { this.month = this.value; expression = true; } if (expression && (this.month || this.month === 0) && this.unit !== "year") { finishUtils.setMonthsFromMonth.call(this, today, orient); } if (!this.unit) { this.unit = "day"; } finishUtils.setUnitValue.call(this, orient); parseMeridian.call(this); if ((this.month || this.month === 0) && !this.day) { this.day = 1; } if (!this.orient && !this.operator && this.unit === "week" && this.value && !this.day && !this.month) { return Date.today().setWeek(this.value); } if (this.unit === "week" && this.weeks && !this.day && !this.month) { return finishUtils.generateDateFromWeeks.call(this); } if (expression && this.timezone && this.day && this.days) { this.day = this.days; } if (expression){ today.add(this); } else { today.set(this); } if (this.timezone) { this.timezone = this.timezone.toUpperCase(); var offset = $D.getTimezoneOffset(this.timezone); var timezone; if (today.hasDaylightSavingTime()) { // lets check that we're being sane with timezone setting timezone = $D.getTimezoneAbbreviation(offset, today.isDaylightSavingTime()); if (timezone !== this.timezone) { // bugger, we're in a place where things like EST vs EDT matters. if (today.isDaylightSavingTime()) { today.addHours(-1); } else { today.addHours(1); } } } today.setTimezoneOffset(offset); } return today; } }; }()); (function () { var $D = Date; $D.Grammar = {}; var _ = $D.Parsing.Operators, g = $D.Grammar, t = $D.Translator, _fn; // Allow rolling up into general purpose rules _fn = function () { return _.each(_.any.apply(null, arguments), _.not(g.ctoken2("timeContext"))); }; g.datePartDelimiter = _.rtoken(/^([\s\-\.\,\/\x27]+)/); g.timePartDelimiter = _.stoken(":"); g.whiteSpace = _.rtoken(/^\s*/); g.generalDelimiter = _.rtoken(/^(([\s\,]|at|@|on)+)/); var _C = {}; g.ctoken = function (keys) { var fn = _C[keys]; if (! fn) { var c = Date.CultureInfo.regexPatterns; var kx = keys.split(/\s+/), px = []; for (var i = 0; i < kx.length ; i++) { px.push(_.replace(_.rtoken(c[kx[i]]), kx[i])); } fn = _C[keys] = _.any.apply(null, px); } return fn; }; g.ctoken2 = function (key) { return _.rtoken(Date.CultureInfo.regexPatterns[key]); }; var cacheProcessRtoken = function (key, token, type, eachToken) { if (eachToken) { g[key] = _.cache(_.process(_.each(_.rtoken(token),_.optional(g.ctoken2(eachToken))), type)); } else { g[key] = _.cache(_.process(_.rtoken(token), type)); } }; var cacheProcessCtoken = function (token, type) { return _.cache(_.process(g.ctoken2(token), type)); }; var _F = {}; //function cache var _get = function (f) { _F[f] = (_F[f] || g.format(f)[0]); return _F[f]; }; g.allformats = function (fx) { var rx = []; if (fx instanceof Array) { for (var i = 0; i < fx.length; i++) { rx.push(_get(fx[i])); } } else { rx.push(_get(fx)); } return rx; }; g.formats = function (fx) { if (fx instanceof Array) { var rx = []; for (var i = 0 ; i < fx.length ; i++) { rx.push(_get(fx[i])); } return _.any.apply(null, rx); } else { return _get(fx); } }; var grammarFormats = { timeFormats: function(){ var i, RTokenKeys = [ "h", "hh", "H", "HH", "m", "mm", "s", "ss", "ss.s", "z", "zz" ], RToken = [ /^(0[0-9]|1[0-2]|[1-9])/, /^(0[0-9]|1[0-2])/, /^([0-1][0-9]|2[0-3]|[0-9])/, /^([0-1][0-9]|2[0-3])/, /^([0-5][0-9]|[0-9])/, /^[0-5][0-9]/, /^([0-5][0-9]|[0-9])/, /^[0-5][0-9]/, /^[0-5][0-9]\.[0-9]{1,3}/, /^((\+|\-)\s*\d\d\d\d)|((\+|\-)\d\d\:?\d\d)/, /^((\+|\-)\s*\d\d\d\d)|((\+|\-)\d\d\:?\d\d)/ ], tokens = [ t.hour, t.hour, t.hour, t.hour, t.minute, t.minute, t.second, t.second, t.secondAndMillisecond, t.timezone, t.timezone ]; for (i=0; i < RTokenKeys.length; i++) { cacheProcessRtoken(RTokenKeys[i], RToken[i], tokens[i]); } g.hms = _.cache(_.sequence([g.H, g.m, g.s], g.timePartDelimiter)); g.t = cacheProcessCtoken("shortMeridian", t.meridian); g.tt = cacheProcessCtoken("longMeridian", t.meridian); g.zzz = cacheProcessCtoken("timezone", t.timezone); g.timeSuffix = _.each(_.ignore(g.whiteSpace), _.set([ g.tt, g.zzz ])); g.time = _.each(_.optional(_.ignore(_.stoken("T"))), g.hms, g.timeSuffix); }, dateFormats: function () { // pre-loaded rules for different date part order preferences var _setfn = function () { return _.set(arguments, g.datePartDelimiter); }; var i, RTokenKeys = [ "d", "dd", "M", "MM", "y", "yy", "yyy", "yyyy" ], RToken = [ /^([0-2]\d|3[0-1]|\d)/, /^([0-2]\d|3[0-1])/, /^(1[0-2]|0\d|\d)/, /^(1[0-2]|0\d)/, /^(\d+)/, /^(\d\d)/, /^(\d\d?\d?\d?)/, /^(\d\d\d\d)/ ], tokens = [ t.day, t.day, t.month, t.month, t.year, t.year, t.year, t.year ], eachToken = [ "ordinalSuffix", "ordinalSuffix" ]; for (i=0; i < RTokenKeys.length; i++) { cacheProcessRtoken(RTokenKeys[i], RToken[i], tokens[i], eachToken[i]); } g.MMM = g.MMMM = _.cache(_.process(g.ctoken("jan feb mar apr may jun jul aug sep oct nov dec"), t.month)); g.ddd = g.dddd = _.cache(_.process(g.ctoken("sun mon tue wed thu fri sat"), function (s) { return function () { this.weekday = s; }; } )); g.day = _fn(g.d, g.dd); g.month = _fn(g.M, g.MMM); g.year = _fn(g.yyyy, g.yy); g.mdy = _setfn(g.ddd, g.month, g.day, g.year); g.ymd = _setfn(g.ddd, g.year, g.month, g.day); g.dmy = _setfn(g.ddd, g.day, g.month, g.year); g.date = function (s) { return ((g[Date.CultureInfo.dateElementOrder] || g.mdy).call(this, s)); }; }, relative: function () { // relative date / time expressions g.orientation = _.process(g.ctoken("past future"), function (s) { return function () { this.orient = s; }; } ); g.operator = _.process(g.ctoken("add subtract"), function (s) { return function () { this.operator = s; }; } ); g.rday = _.process(g.ctoken("yesterday tomorrow today now"), t.rday); g.unit = _.process(g.ctoken("second minute hour day week month year"), function (s) { return function () { this.unit = s; }; } ); } }; g.buildGrammarFormats = function () { // these need to be rebuilt every time the language changes. _C = {}; grammarFormats.timeFormats(); grammarFormats.dateFormats(); grammarFormats.relative(); g.value = _.process(_.rtoken(/^([-+]?\d+)?(st|nd|rd|th)?/), function (s) { return function () { this.value = s.replace(/\D/g, ""); }; } ); g.expression = _.set([g.rday, g.operator, g.value, g.unit, g.orientation, g.ddd, g.MMM ]); g.format = _.process(_.many( _.any( // translate format specifiers into grammar rules _.process( _.rtoken(/^(dd?d?d?(?!e)|MM?M?M?|yy?y?y?|hh?|HH?|mm?|ss?|tt?|zz?z?)/), function (fmt) { if (g[fmt]) { return g[fmt]; } else { throw $D.Parsing.Exception(fmt); } } ), // translate separator tokens into token rules _.process(_.rtoken(/^[^dMyhHmstz]+/), // all legal separators function (s) { return _.ignore(_.stoken(s)); } ) ) ), // construct the parser ... function (rules) { return _.process(_.each.apply(null, rules), t.finishExact); } ); // starting rule for general purpose grammar g._start = _.process(_.set([ g.date, g.time, g.expression ], g.generalDelimiter, g.whiteSpace), t.finish); }; g.buildGrammarFormats(); // parsing date format specifiers - ex: "h:m:s tt" // this little guy will generate a custom parser based // on the format string, ex: g.format("h:m:s tt") // check for these formats first g._formats = g.formats([ "\"yyyy-MM-ddTHH:mm:ssZ\"", "yyyy-MM-ddTHH:mm:ss.sz", "yyyy-MM-ddTHH:mm:ssZ", "yyyy-MM-ddTHH:mm:ssz", "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-ddTHH:mmZ", "yyyy-MM-ddTHH:mmz", "yyyy-MM-ddTHH:mm", "ddd, MMM dd, yyyy H:mm:ss tt", "ddd MMM d yyyy HH:mm:ss zzz", "MMddyyyy", "ddMMyyyy", "Mddyyyy", "ddMyyyy", "Mdyyyy", "dMyyyy", "yyyy", "Mdyy", "dMyy", "d" ]); // real starting rule: tries selected formats first, // then general purpose rule g.start = function (s) { try { var r = g._formats.call({}, s); if (r[1].length === 0) { return r; } } catch (e) {} return g._start.call({}, s); }; }()); (function () { var $D = Date; /** * @desc Converts the specified string value into its JavaScript Date equivalent using CultureInfo specific format information. * * Example

	///////////
	// Dates //
	///////////

	// 15-Oct-2004
	var d1 = Date.parse("10/15/2004");

	// 15-Oct-2004
	var d1 = Date.parse("15-Oct-2004");

	// 15-Oct-2004
	var d1 = Date.parse("2004.10.15");

	//Fri Oct 15, 2004
	var d1 = Date.parse("Fri Oct 15, 2004");

	///////////
	// Times //
	///////////

	// Today at 10 PM.
	var d1 = Date.parse("10 PM");

	// Today at 10:30 PM.
	var d1 = Date.parse("10:30 P.M.");

	// Today at 6 AM.
	var d1 = Date.parse("06am");

	/////////////////////
	// Dates and Times //
	/////////////////////

	// 8-July-2004 @ 10:30 PM
	var d1 = Date.parse("July 8th, 2004, 10:30 PM");

	// 1-July-2004 @ 10:30 PM
	var d1 = Date.parse("2004-07-01T22:30:00");

	////////////////////
	// Relative Dates //
	////////////////////

	// Returns today's date. The string "today" is culture specific.
	var d1 = Date.parse("today");

	// Returns yesterday's date. The string "yesterday" is culture specific.
	var d1 = Date.parse("yesterday");

	// Returns the date of the next thursday.
	var d1 = Date.parse("Next thursday");

	// Returns the date of the most previous monday.
	var d1 = Date.parse("last monday");

	// Returns today's day + one year.
	var d1 = Date.parse("next year");

	///////////////
	// Date Math //
	///////////////

	// Today + 2 days
	var d1 = Date.parse("t+2");

	// Today + 2 days
	var d1 = Date.parse("today + 2 days");

	// Today + 3 months
	var d1 = Date.parse("t+3m");

	// Today - 1 year
	var d1 = Date.parse("today - 1 year");

	// Today - 1 year
	var d1 = Date.parse("t-1y"); 


	/////////////////////////////
	// Partial Dates and Times //
	/////////////////////////////

	// July 15th of this year.
	var d1 = Date.parse("July 15");

	// 15th day of current day and year.
	var d1 = Date.parse("15");

	// July 1st of current year at 10pm.
	var d1 = Date.parse("7/1 10pm");
	
* * @param {String} The string value to convert into a Date object [Required] * @return {Date} A Date object or null if the string cannot be converted into a Date. */ var parseUtils = { removeOrds: function (s) { ords = s.match(/\b(\d+)(?:st|nd|rd|th)\b/); // find ordinal matches s = ((ords && ords.length === 2) ? s.replace(ords[0], ords[1]) : s); return s; }, grammarParser: function (s) { var r = null; try { r = $D.Grammar.start.call({}, s.replace(/^\s*(\S*(\s+\S+)*)\s*$/, "$1")); } catch (e) { return null; } return ((r[1].length === 0) ? r[0] : null); }, nativeFallback: function(s) { var t; try { // ok we haven't parsed it, last ditch attempt with the built-in parser. t = Date._parse(s); return (t || t === 0) ? new Date(t) : null; } catch (e) { return null; } } }; function parse (s) { var d; if (!s) { return null; } if (s instanceof Date) { return s.clone(); } if (s.length >= 4 && s.charAt(0) !== "0" && s.charAt(0) !== "+"&& s.charAt(0) !== "-") { // ie: 2004 will pass, 0800 won't. // Start with specific formats d = $D.Parsing.ISO.parse(s) || $D.Parsing.Numeric.parse(s); } if (d instanceof Date && !isNaN(d.getTime())) { return d; } else { // find ordinal dates (1st, 3rd, 8th, etc and remove them as they cause parsing issues) s = $D.Parsing.Normalizer.parse(parseUtils.removeOrds(s)); d = parseUtils.grammarParser(s); if (d !== null) { return d; } else { return parseUtils.nativeFallback(s); } } } if (!$D._parse) { $D._parse = $D.parse; } $D.parse = parse; Date.getParseFunction = function (fx) { var fns = Date.Grammar.allformats(fx); return function (s) { var r = null; for (var i = 0; i < fns.length; i++) { try { r = fns[i].call({}, s); } catch (e) { continue; } if (r[1].length === 0) { return r[0]; } } return null; }; }; /** * Converts the specified string value into its JavaScript Date equivalent using the specified format {String} or formats {Array} and the CultureInfo specific format information. * The format of the string value must match one of the supplied formats exactly. * * Example

	// 15-Oct-2004
	var d1 = Date.parseExact("10/15/2004", "M/d/yyyy");

	// 15-Oct-2004
	var d1 = Date.parse("15-Oct-2004", "M-ddd-yyyy");

	// 15-Oct-2004
	var d1 = Date.parse("2004.10.15", "yyyy.MM.dd");

	// Multiple formats
	var d1 = Date.parseExact("10/15/2004", ["M/d/yyyy", "MMMM d, yyyy"]);
	
* * @param {String} The string value to convert into a Date object [Required]. * @param {Object} The expected format {String} or an array of expected formats {Array} of the date string [Required]. * @return {Date} A Date object or null if the string cannot be converted into a Date. */ $D.parseExact = function (s, fx) { return $D.getParseFunction(fx)(s); }; }()); (function () { var $D = Date, $P = $D.prototype, // $C = $D.CultureInfo, // not used atm p = function (s, l) { if (!l) { l = 2; } return ("000" + s).slice(l * -1); }; /** * Converts a PHP format string to Java/.NET format string. * A PHP format string can be used with ._format or .format. * A Java/.NET format string can be used with .toString(). * The .parseExact function will only accept a Java/.NET format string * * Example * var f1 = "%m/%d/%y" * var f2 = Date.normalizeFormat(f1); // "MM/dd/yy" * * new Date().format(f1); // "04/13/08" * new Date()._format(f1); // "04/13/08" * new Date().toString(f2); // "04/13/08" * * var date = Date.parseExact("04/13/08", f2); // Sun Apr 13 2008 * * @param {String} A PHP format string consisting of one or more format spcifiers. * @return {String} The PHP format converted to a Java/.NET format string. */ var normalizerSubstitutions = { "d" : "dd", "%d": "dd", "D" : "ddd", "%a": "ddd", "j" : "dddd", "l" : "dddd", "%A": "dddd", "S" : "S", "F" : "MMMM", "%B": "MMMM", "m" : "MM", "%m": "MM", "M" : "MMM", "%b": "MMM", "%h": "MMM", "n" : "M", "Y" : "yyyy", "%Y": "yyyy", "y" : "yy", "%y": "yy", "g" : "h", "%I": "h", "G" : "H", "h" : "hh", "H" : "HH", "%H": "HH", "i" : "mm", "%M": "mm", "s" : "ss", "%S": "ss", "%r": "hh:mm tt", "%R": "H:mm", "%T": "H:mm:ss", "%X": "t", "%x": "d", "%e": "d", "%D": "MM/dd/yy", "%n": "\\n", "%t": "\\t", "e" : "z", "T" : "z", "%z": "z", "%Z": "z", "Z" : "ZZ", "N" : "u", "w" : "u", "%w": "u", "W" : "W", "%V": "W" }; var normalizer = { substitutes: function (m) { return normalizerSubstitutions[m]; }, interpreted: function (m, x) { var y; switch (m) { case "%u": return x.getDay() + 1; case "z": return x.getOrdinalNumber(); case "%j": return p(x.getOrdinalNumber(), 3); case "%U": var d1 = x.clone().set({month: 0, day: 1}).addDays(-1).moveToDayOfWeek(0), d2 = x.clone().addDays(1).moveToDayOfWeek(0, -1); return (d2 < d1) ? "00" : p((d2.getOrdinalNumber() - d1.getOrdinalNumber()) / 7 + 1); case "%W": return p(x.getWeek()); case "t": return $D.getDaysInMonth(x.getFullYear(), x.getMonth()); case "o": case "%G": return x.setWeek(x.getISOWeek()).toString("yyyy"); case "%g": return x._format("%G").slice(-2); case "a": case "%p": return t("tt").toLowerCase(); case "A": return t("tt").toUpperCase(); case "u": return p(x.getMilliseconds(), 3); case "I": return (x.isDaylightSavingTime()) ? 1 : 0; case "O": return x.getUTCOffset(); case "P": y = x.getUTCOffset(); return y.substring(0, y.length - 2) + ":" + y.substring(y.length - 2); case "B": var now = new Date(); return Math.floor(((now.getHours() * 3600) + (now.getMinutes() * 60) + now.getSeconds() + (now.getTimezoneOffset() + 60) * 60) / 86.4); case "c": return x.toISOString().replace(/\"/g, ""); case "U": return $D.strtotime("now"); case "%c": return t("d") + " " + t("t"); case "%C": return Math.floor(x.getFullYear() / 100 + 1); } }, shouldOverrideDefaults: function (m) { switch (m) { case "%e": return true; default: return false; } }, parse: function (m, context) { var formatString, c = context || new Date(); formatString = normalizer.substitutes(m); if (formatString) { return formatString; } formatString = normalizer.interpreted(m, c); if (formatString) { return formatString; } else { return m; } } }; $D.normalizeFormat = function (format, context) { return format.replace(/(%|\\)?.|%%/g, function(t){ return normalizer.parse(t, context); }); }; /** * Format a local Unix timestamp according to locale settings * * Example: * Date.strftime("%m/%d/%y", new Date()); // "04/13/08" * Date.strftime("c", "2008-04-13T17:52:03Z"); // "04/13/08" * * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @param {Number|String} The number representing the number of seconds that have elapsed since January 1, 1970 (local time). * @return {String} A string representation of the current Date object. */ $D.strftime = function (format, time) { var d = Date.parse(time); return d._format(format); }; /** * Parse any textual datetime description into a Unix timestamp. * A Unix timestamp is the number of seconds that have elapsed since January 1, 1970 (midnight UTC/GMT). * * Example: * Date.strtotime("04/13/08"); // 1208044800 * Date.strtotime("1970-01-01T00:00:00Z"); // 0 * * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @param {Object} A string or date object. * @return {String} A string representation of the current Date object. */ $D.strtotime = function (time) { var d = $D.parse(time); return Math.round($D.UTC(d.getUTCFullYear(), d.getUTCMonth(), d.getUTCDate(), d.getUTCHours(), d.getUTCMinutes(), d.getUTCSeconds(), d.getUTCMilliseconds()) / 1000); }; /** * Converts the value of the current Date object to its equivalent string representation using a PHP/Unix style of date format specifiers. * Format Specifiers * Format Description Example * ------ --------------------------------------------------------------------------- ----------------------- * %a abbreviated weekday name according to the current localed "Mon" through "Sun" * %A full weekday name according to the current localed "Sunday" through "Saturday" * %b abbreviated month name according to the current localed "Jan" through "Dec" * %B full month name according to the current locale "January" through "December" * %c preferred date and time representation for the current locale "4/13/2008 12:33 PM" * %C century number (the year divided by 100 and truncated to an integer) "00" to "99" * %d day of the month as a decimal number "01" to "31" * %D same as %m/%d/%y "04/13/08" * %e day of the month as a decimal number, a single digit is preceded by a space "1" to "31" * %g like %G, but without the century "08" * %G The 4-digit year corresponding to the ISO week number (see %V). "2008" * This has the same format and value as %Y, except that if the ISO week number * belongs to the previous or next year, that year is used instead. * %h same as %b "Jan" through "Dec" * %H hour as a decimal number using a 24-hour clock. "00" to "23" * %I hour as a decimal number using a 12-hour clock. "01" to "12" * %j day of the year as a decimal number. "001" to "366" * %m month as a decimal number. "01" to "12" * %M minute as a decimal number. "00" to "59" * %n newline character "\n" * %p either "am" or "pm" according to the given time value, or the "am" or "pm" * corresponding strings for the current locale. * %r time in a.m. and p.m. notation "8:44 PM" * %R time in 24 hour notation "20:44" * %S second as a decimal number "00" to "59" * %t tab character "\t" * %T current time, equal to %H:%M:%S "12:49:11" * %u weekday as a decimal number ["1", "7"], with "1" representing Monday "1" to "7" * %U week number of the current year as a decimal number, starting with the "0" to ("52" or "53") * first Sunday as the first day of the first week * %V The ISO 8601:1988 week number of the current year as a decimal number, "00" to ("52" or "53") * range 01 to 53, where week 1 is the first week that has at least 4 days * in the current year, and with Monday as the first day of the week. * (Use %G or %g for the year component that corresponds to the week number * for the specified timestamp.) * %W week number of the current year as a decimal number, starting with the "00" to ("52" or "53") * first Monday as the first day of the first week * %w day of the week as a decimal, Sunday being "0" "0" to "6" * %x preferred date representation for the current locale without the time "4/13/2008" * %X preferred time representation for the current locale without the date "12:53:05" * %y year as a decimal number without a century "00" "99" * %Y year as a decimal number including the century "2008" * %Z time zone or name or abbreviation "UTC", "EST", "PST" * %z same as %Z * %% a literal "%" characters "%" * d Day of the month, 2 digits with leading zeros "01" to "31" * D A textual representation of a day, three letters "Mon" through "Sun" * j Day of the month without leading zeros "1" to "31" * l A full textual representation of the day of the week (lowercase "L") "Sunday" through "Saturday" * N ISO-8601 numeric representation of the day of the week (added in PHP 5.1.0) "1" (for Monday) through "7" (for Sunday) * S English ordinal suffix for the day of the month, 2 characters "st", "nd", "rd" or "th". Works well with j * w Numeric representation of the day of the week "0" (for Sunday) through "6" (for Saturday) * z The day of the year (starting from "0") "0" through "365" * W ISO-8601 week number of year, weeks starting on Monday "00" to ("52" or "53") * F A full textual representation of a month, such as January or March "January" through "December" * m Numeric representation of a month, with leading zeros "01" through "12" * M A short textual representation of a month, three letters "Jan" through "Dec" * n Numeric representation of a month, without leading zeros "1" through "12" * t Number of days in the given month "28" through "31" * L Whether it's a leap year "1" if it is a leap year, "0" otherwise * o ISO-8601 year number. This has the same value as Y, except that if the "2008" * ISO week number (W) belongs to the previous or next year, that year * is used instead. * Y A full numeric representation of a year, 4 digits "2008" * y A two digit representation of a year "08" * a Lowercase Ante meridiem and Post meridiem "am" or "pm" * A Uppercase Ante meridiem and Post meridiem "AM" or "PM" * B Swatch Internet time "000" through "999" * g 12-hour format of an hour without leading zeros "1" through "12" * G 24-hour format of an hour without leading zeros "0" through "23" * h 12-hour format of an hour with leading zeros "01" through "12" * H 24-hour format of an hour with leading zeros "00" through "23" * i Minutes with leading zeros "00" to "59" * s Seconds, with leading zeros "00" through "59" * u Milliseconds "54321" * e Timezone identifier "UTC", "EST", "PST" * I Whether or not the date is in daylight saving time (uppercase i) "1" if Daylight Saving Time, "0" otherwise * O Difference to Greenwich time (GMT) in hours "+0200", "-0600" * P Difference to Greenwich time (GMT) with colon between hours and minutes "+02:00", "-06:00" * T Timezone abbreviation "UTC", "EST", "PST" * Z Timezone offset in seconds. The offset for timezones west of UTC is "-43200" through "50400" * always negative, and for those east of UTC is always positive. * c ISO 8601 date "2004-02-12T15:19:21+00:00" * r RFC 2822 formatted date "Thu, 21 Dec 2000 16:01:07 +0200" * U Seconds since the Unix Epoch (January 1 1970 00:00:00 GMT) "0" * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @return {String} A string representation of the current Date object. */ var formatReplace = function (context) { return function (m) { var formatString, override = false; if (m.charAt(0) === "\\" || m.substring(0, 2) === "%%") { return m.replace("\\", "").replace("%%", "%"); } override = normalizer.shouldOverrideDefaults(m); formatString = $D.normalizeFormat(m, context); if (formatString) { return context.toString(formatString, override); } }; }; $P._format = function (format) { var formatter = formatReplace(this); if (!format) { return this._toString(); } else { return format.replace(/(%|\\)?.|%%/g, formatter); } }; if (!$P.format) { $P.format = $P._format; } }()); (function () { "use strict"; var gFn = function (attr) { return function () { return this[attr]; }; }; var sFn = function (attr) { return function (val) { this[attr] = val; return this; }; }; var attrs = ["years", "months", "days", "hours", "minutes", "seconds", "milliseconds"]; var addSetFuncs = function (context, attrs) { for (var i = 0; i < attrs.length ; i++) { var $a = attrs[i], $b = $a.slice(0, 1).toUpperCase() + $a.slice(1); context.prototype[$a] = 0; context.prototype["get" + $b] = gFn($a); context.prototype["set" + $b] = sFn($a); } }; /** * new TimeSpan(milliseconds); * new TimeSpan(days, hours, minutes, seconds); * new TimeSpan(days, hours, minutes, seconds, milliseconds); */ var TimeSpan = function (days, hours, minutes, seconds, milliseconds) { if (arguments.length === 1 && typeof days === "number") { var orient = (days < 0) ? -1 : +1; var millsLeft = Math.abs(days); this.setDays(Math.floor(millsLeft / 86400000) * orient); millsLeft = millsLeft % 86400000; this.setHours(Math.floor(millsLeft / 3600000) * orient); millsLeft = millsLeft % 3600000; this.setMinutes(Math.floor(millsLeft / 60000) * orient); millsLeft = millsLeft % 60000; this.setSeconds(Math.floor(millsLeft / 1000) * orient); millsLeft = millsLeft % 1000; this.setMilliseconds(millsLeft * orient); } else { this.set(days, hours, minutes, seconds, milliseconds); } this.getTotalMilliseconds = function () { return (this.getDays() * 86400000) + (this.getHours() * 3600000) + (this.getMinutes() * 60000) + (this.getSeconds() * 1000); }; this.compareTo = function (time) { var t1 = new Date(1970, 1, 1, this.getHours(), this.getMinutes(), this.getSeconds()), t2; if (time === null) { t2 = new Date(1970, 1, 1, 0, 0, 0); } else { t2 = new Date(1970, 1, 1, time.getHours(), time.getMinutes(), time.getSeconds()); } return (t1 < t2) ? -1 : (t1 > t2) ? 1 : 0; }; this.equals = function (time) { return (this.compareTo(time) === 0); }; this.add = function (time) { return (time === null) ? this : this.addSeconds(time.getTotalMilliseconds() / 1000); }; this.subtract = function (time) { return (time === null) ? this : this.addSeconds(-time.getTotalMilliseconds() / 1000); }; this.addDays = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 86400000)); }; this.addHours = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 3600000)); }; this.addMinutes = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 60000)); }; this.addSeconds = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 1000)); }; this.addMilliseconds = function (n) { return new TimeSpan(this.getTotalMilliseconds() + n); }; this.get12HourHour = function () { return (this.getHours() > 12) ? this.getHours() - 12 : (this.getHours() === 0) ? 12 : this.getHours(); }; this.getDesignator = function () { return (this.getHours() < 12) ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator; }; this.toString = function (format) { this._toString = function () { if (this.getDays() !== null && this.getDays() > 0) { return this.getDays() + "." + this.getHours() + ":" + this.p(this.getMinutes()) + ":" + this.p(this.getSeconds()); } else { return this.getHours() + ":" + this.p(this.getMinutes()) + ":" + this.p(this.getSeconds()); } }; this.p = function (s) { return (s.toString().length < 2) ? "0" + s : s; }; var me = this; return format ? format.replace(/dd?|HH?|hh?|mm?|ss?|tt?/g, function (format) { switch (format) { case "d": return me.getDays(); case "dd": return me.p(me.getDays()); case "H": return me.getHours(); case "HH": return me.p(me.getHours()); case "h": return me.get12HourHour(); case "hh": return me.p(me.get12HourHour()); case "m": return me.getMinutes(); case "mm": return me.p(me.getMinutes()); case "s": return me.getSeconds(); case "ss": return me.p(me.getSeconds()); case "t": return ((me.getHours() < 12) ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator).substring(0, 1); case "tt": return (me.getHours() < 12) ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator; } } ) : this._toString(); }; return this; }; addSetFuncs(TimeSpan, attrs.slice(2)); TimeSpan.prototype.set = function (days, hours, minutes, seconds, milliseconds){ this.setDays(days || this.getDays()); this.setHours(hours || this.getHours()); this.setMinutes(minutes || this.getMinutes()); this.setSeconds(seconds || this.getSeconds()); this.setMilliseconds(milliseconds || this.getMilliseconds()); }; /** * Gets the time of day for this date instances. * @return {TimeSpan} TimeSpan */ Date.prototype.getTimeOfDay = function () { return new TimeSpan(0, this.getHours(), this.getMinutes(), this.getSeconds(), this.getMilliseconds()); }; Date.TimeSpan = TimeSpan; if (typeof window !== "undefined" ) { // keeping API compatible for v1.x window.TimeSpan = TimeSpan; } }()); (function () { "use strict"; var attrs = ["years", "months", "days", "hours", "minutes", "seconds", "milliseconds"]; var gFn = function (attr) { return function () { return this[attr]; }; }; var sFn = function (attr) { return function (val) { this[attr] = val; return this; }; }; var addSetFuncs = function (context, attrs) { for (var i = 0; i < attrs.length ; i++) { var $a = attrs[i], $b = $a.slice(0, 1).toUpperCase() + $a.slice(1); context.prototype[$a] = 0; context.prototype["get" + $b] = gFn($a); context.prototype["set" + $b] = sFn($a); } }; var setMonthsAndYears = function (orient, d1, d2, context) { function inc() { d1.addMonths(-orient); context.months++; if (context.months === 12) { context.years++; context.months = 0; } } if (orient === +1) { while (d1 > d2) { inc(); } } else { while (d1 < d2) { inc(); } } context.months--; context.months *= orient; context.years *= orient; }; var adjustForDST = function(orient, startDate, endDate) { var hasDSTMismatch = (false === (startDate.isDaylightSavingTime() === endDate.isDaylightSavingTime())); if (hasDSTMismatch && orient === 1) { startDate.addHours(-1); } else if (hasDSTMismatch) { startDate.addHours(1); } }; /** * TimePeriod(startDate, endDate); * TimePeriod(years, months, days, hours, minutes, seconds, milliseconds); */ var TimePeriod = function (years, months, days, hours, minutes, seconds, milliseconds) { if (arguments.length === 7) { this.set(years, months, days, hours, minutes, seconds, milliseconds); } else if (arguments.length === 2 && arguments[0] instanceof Date && arguments[1] instanceof Date) { var startDate = arguments[0].clone(); var endDate = arguments[1].clone(); var orient = (startDate > endDate) ? +1 : -1; this.dates = { start: arguments[0].clone(), end: arguments[1].clone() }; setMonthsAndYears(orient, startDate, endDate, this); adjustForDST(orient, startDate, endDate); // // TODO - adjust for DST var diff = endDate - startDate; if (diff !== 0) { var ts = new TimeSpan(diff); this.set(this.years, this.months, ts.getDays(), ts.getHours(), ts.getMinutes(), ts.getSeconds(), ts.getMilliseconds()); } } return this; }; // create all the set functions. addSetFuncs(TimePeriod, attrs); TimePeriod.prototype.set = function (years, months, days, hours, minutes, seconds, milliseconds){ this.setYears(years || this.getYears()); this.setMonths(months || this.getMonths()); this.setDays(days || this.getDays()); this.setHours(hours || this.getHours()); this.setMinutes(minutes || this.getMinutes()); this.setSeconds(seconds || this.getSeconds()); this.setMilliseconds(milliseconds || this.getMilliseconds()); }; Date.TimePeriod = TimePeriod; if (typeof window !== "undefined") { // keeping API compatible for v1.x window.TimePeriod = TimePeriod; } }()); ================================================ FILE: build/date-cs-CZ.js ================================================ /** * @overview datejs * @version 1.0.0-rc3 * @author Gregory Wild-Smith * @copyright 2015 Gregory Wild-Smith * @license MIT * @homepage https://github.com/abritinthebay/datejs */ /* * DateJS Culture String File * Country Code: cs-CZ * Name: Czech (Czech Republic) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["cs-CZ"] = { "name": "cs-CZ", "englishName": "Czech (Czech Republic)", "nativeName": "čeština (Česká republika)", "Sunday": "neděle", "Monday": "pondělí", "Tuesday": "úterý", "Wednesday": "středa", "Thursday": "čtvrtek", "Friday": "pátek", "Saturday": "sobota", "Sun": "ne", "Mon": "po", "Tue": "út", "Wed": "st", "Thu": "čt", "Fri": "pá", "Sat": "so", "Su": "ne", "Mo": "po", "Tu": "út", "We": "st", "Th": "čt", "Fr": "pá", "Sa": "so", "S_Sun_Initial": "n", "M_Mon_Initial": "p", "T_Tue_Initial": "ú", "W_Wed_Initial": "s", "T_Thu_Initial": "č", "F_Fri_Initial": "p", "S_Sat_Initial": "s", "January": "leden", "February": "únor", "March": "březen", "April": "duben", "May": "květen", "June": "červen", "July": "červenec", "August": "srpen", "September": "září", "October": "říjen", "November": "listopad", "December": "prosinec", "Jan_Abbr": "I", "Feb_Abbr": "II", "Mar_Abbr": "III", "Apr_Abbr": "IV", "May_Abbr": "V", "Jun_Abbr": "VI", "Jul_Abbr": "VII", "Aug_Abbr": "VIII", "Sep_Abbr": "IX", "Oct_Abbr": "X", "Nov_Abbr": "XI", "Dec_Abbr": "XII", "AM": "dop.", "PM": "odp.", "firstDayOfWeek": 1, "twoDigitYearMax": 2029, "mdy": "dmy", "M/d/yyyy": "d.M.yyyy", "dddd, MMMM dd, yyyy": "d. MMMM yyyy", "h:mm tt": "H:mm", "h:mm:ss tt": "H:mm:ss", "dddd, MMMM dd, yyyy h:mm:ss tt": "d. MMMM yyyy H:mm:ss", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "dd MMMM", "MMMM, yyyy": "MMMM yyyy", "/jan(uary)?/": "leden", "/feb(ruary)?/": "únor", "/mar(ch)?/": "březen", "/apr(il)?/": "duben", "/may/": "květen", "/jun(e)?/": "červen", "/jul(y)?/": "červenec", "/aug(ust)?/": "srpen", "/sep(t(ember)?)?/": "září", "/oct(ober)?/": "říjen", "/nov(ember)?/": "listopad", "/dec(ember)?/": "prosinec", "/^su(n(day)?)?/": "^neděle", "/^mo(n(day)?)?/": "^pondělí", "/^tu(e(s(day)?)?)?/": "^úterý", "/^we(d(nesday)?)?/": "^středa", "/^th(u(r(s(day)?)?)?)?/": "^čtvrtek", "/^fr(i(day)?)?/": "^pátek", "/^sa(t(urday)?)?/": "^sobota", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "cs-CZ"; /** * @overview datejs * @version 1.0.0-rc3 * @author Gregory Wild-Smith * @copyright 2015 Gregory Wild-Smith * @license MIT * @homepage https://github.com/abritinthebay/datejs */(function () { var $D = Date; var lang = Date.CultureStrings ? Date.CultureStrings.lang : null; var loggedKeys = {}; // for debug purposes. var getText = { getFromKey: function (key, countryCode) { var output; if (Date.CultureStrings && Date.CultureStrings[countryCode] && Date.CultureStrings[countryCode][key]) { output = Date.CultureStrings[countryCode][key]; } else { output = getText.buildFromDefault(key); } if (key.charAt(0) === "/") { // Assume it's a regex output = getText.buildFromRegex(key, countryCode); } return output; }, getFromObjectValues: function (obj, countryCode) { var key, output = {}; for(key in obj) { if (obj.hasOwnProperty(key)) { output[key] = getText.getFromKey(obj[key], countryCode); } } return output; }, getFromObjectKeys: function (obj, countryCode) { var key, output = {}; for(key in obj) { if (obj.hasOwnProperty(key)) { output[getText.getFromKey(key, countryCode)] = obj[key]; } } return output; }, getFromArray: function (arr, countryCode) { var output = []; for (var i=0; i < arr.length; i++){ if (i in arr) { output[i] = getText.getFromKey(arr[i], countryCode); } } return output; }, buildFromDefault: function (key) { var output, length, split, last; switch(key) { case "name": output = "en-US"; break; case "englishName": output = "English (United States)"; break; case "nativeName": output = "English (United States)"; break; case "twoDigitYearMax": output = 2049; break; case "firstDayOfWeek": output = 0; break; default: output = key; split = key.split("_"); length = split.length; if (length > 1 && key.charAt(0) !== "/") { // if the key isn't a regex and it has a split. last = split[(length - 1)].toLowerCase(); if (last === "initial" || last === "abbr") { output = split[0]; } } break; } return output; }, buildFromRegex: function (key, countryCode) { var output; if (Date.CultureStrings && Date.CultureStrings[countryCode] && Date.CultureStrings[countryCode][key]) { output = new RegExp(Date.CultureStrings[countryCode][key], "i"); } else { output = new RegExp(key.replace(new RegExp("/", "g"),""), "i"); } return output; } }; var shallowMerge = function (obj1, obj2) { for (var attrname in obj2) { if (obj2.hasOwnProperty(attrname)) { obj1[attrname] = obj2[attrname]; } } }; var __ = function (key, language) { var countryCode = (language) ? language : lang; loggedKeys[key] = key; if (typeof key === "object") { if (key instanceof Array) { return getText.getFromArray(key, countryCode); } else { return getText.getFromObjectKeys(key, countryCode); } } else { return getText.getFromKey(key, countryCode); } }; var loadI18nScript = function (code) { // paatterned after jQuery's getScript. var url = Date.Config.i18n + code + ".js"; var head = document.getElementsByTagName("head")[0] || document.documentElement; var script = document.createElement("script"); script.src = url; var completed = false; var events = { done: function (){} // placeholder function }; // Attach handlers for all browsers script.onload = script.onreadystatechange = function() { if ( !completed && (!this.readyState || this.readyState === "loaded" || this.readyState === "complete") ) { events.done(); head.removeChild(script); } }; setTimeout(function() { head.insertBefore(script, head.firstChild); }, 0); // allows return to execute first return { done: function (cb) { events.done = function() { if (cb) { setTimeout(cb,0); } }; } }; }; var buildInfo = { buildFromMethodHash: function (obj) { var key; for(key in obj) { if (obj.hasOwnProperty(key)) { obj[key] = buildInfo[obj[key]](); } } return obj; }, timeZoneDST: function () { var DST = { "CHADT": "+1345", "NZDT": "+1300", "AEDT": "+1100", "ACDT": "+1030", "AZST": "+0500", "IRDT": "+0430", "EEST": "+0300", "CEST": "+0200", "BST": "+0100", "PMDT": "-0200", "ADT": "-0300", "NDT": "-0230", "EDT": "-0400", "CDT": "-0500", "MDT": "-0600", "PDT": "-0700", "AKDT": "-0800", "HADT": "-0900" }; return __(DST); }, timeZoneStandard: function () { var standard = { "LINT": "+1400", "TOT": "+1300", "CHAST": "+1245", "NZST": "+1200", "NFT": "+1130", "SBT": "+1100", "AEST": "+1000", "ACST": "+0930", "JST": "+0900", "CWST": "+0845", "CT": "+0800", "ICT": "+0700", "MMT": "+0630", "BST": "+0600", "NPT": "+0545", "IST": "+0530", "PKT": "+0500", "AFT": "+0430", "MSK": "+0400", "IRST": "+0330", "FET": "+0300", "EET": "+0200", "CET": "+0100", "GMT": "+0000", "UTC": "+0000", "CVT": "-0100", "GST": "-0200", "BRT": "-0300", "NST": "-0330", "AST": "-0400", "EST": "-0500", "CST": "-0600", "MST": "-0700", "PST": "-0800", "AKST": "-0900", "MIT": "-0930", "HST": "-1000", "SST": "-1100", "BIT": "-1200" }; return __(standard); }, timeZones: function (data) { var zone; data.timezones = []; for (zone in data.abbreviatedTimeZoneStandard) { if (data.abbreviatedTimeZoneStandard.hasOwnProperty(zone)) { data.timezones.push({ name: zone, offset: data.abbreviatedTimeZoneStandard[zone]}); } } for (zone in data.abbreviatedTimeZoneDST) { if (data.abbreviatedTimeZoneDST.hasOwnProperty(zone)) { data.timezones.push({ name: zone, offset: data.abbreviatedTimeZoneDST[zone], dst: true}); } } return data.timezones; }, days: function () { return __(["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"]); }, dayAbbr: function () { return __(["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"]); }, dayShortNames: function () { return __(["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"]); }, dayFirstLetters: function () { return __(["S_Sun_Initial", "M_Mon_Initial", "T_Tues_Initial", "W_Wed_Initial", "T_Thu_Initial", "F_Fri_Initial", "S_Sat_Initial"]); }, months: function () { return __(["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"]); }, monthAbbr: function () { return __(["Jan_Abbr", "Feb_Abbr", "Mar_Abbr", "Apr_Abbr", "May_Abbr", "Jun_Abbr", "Jul_Abbr", "Aug_Abbr", "Sep_Abbr", "Oct_Abbr", "Nov_Abbr", "Dec_Abbr"]); }, formatPatterns: function () { return getText.getFromObjectValues({ shortDate: "M/d/yyyy", longDate: "dddd, MMMM dd, yyyy", shortTime: "h:mm tt", longTime: "h:mm:ss tt", fullDateTime: "dddd, MMMM dd, yyyy h:mm:ss tt", sortableDateTime: "yyyy-MM-ddTHH:mm:ss", universalSortableDateTime: "yyyy-MM-dd HH:mm:ssZ", rfc1123: "ddd, dd MMM yyyy HH:mm:ss", monthDay: "MMMM dd", yearMonth: "MMMM, yyyy" }, Date.i18n.currentLanguage()); }, regex: function () { return getText.getFromObjectValues({ inTheMorning: "/( in the )(morn(ing)?)\\b/", thisMorning: "/(this )(morn(ing)?)\\b/", amThisMorning: "/(\b\\d(am)? )(this )(morn(ing)?)/", inTheEvening: "/( in the )(even(ing)?)\\b/", thisEvening: "/(this )(even(ing)?)\\b/", pmThisEvening: "/(\b\\d(pm)? )(this )(even(ing)?)/", jan: "/jan(uary)?/", feb: "/feb(ruary)?/", mar: "/mar(ch)?/", apr: "/apr(il)?/", may: "/may/", jun: "/jun(e)?/", jul: "/jul(y)?/", aug: "/aug(ust)?/", sep: "/sep(t(ember)?)?/", oct: "/oct(ober)?/", nov: "/nov(ember)?/", dec: "/dec(ember)?/", sun: "/^su(n(day)?)?/", mon: "/^mo(n(day)?)?/", tue: "/^tu(e(s(day)?)?)?/", wed: "/^we(d(nesday)?)?/", thu: "/^th(u(r(s(day)?)?)?)?/", fri: "/fr(i(day)?)?/", sat: "/^sa(t(urday)?)?/", future: "/^next/", past: "/^last|past|prev(ious)?/", add: "/^(\\+|aft(er)?|from|hence)/", subtract: "/^(\\-|bef(ore)?|ago)/", yesterday: "/^yes(terday)?/", today: "/^t(od(ay)?)?/", tomorrow: "/^tom(orrow)?/", now: "/^n(ow)?/", millisecond: "/^ms|milli(second)?s?/", second: "/^sec(ond)?s?/", minute: "/^mn|min(ute)?s?/", hour: "/^h(our)?s?/", week: "/^w(eek)?s?/", month: "/^m(onth)?s?/", day: "/^d(ay)?s?/", year: "/^y(ear)?s?/", shortMeridian: "/^(a|p)/", longMeridian: "/^(a\\.?m?\\.?|p\\.?m?\\.?)/", timezone: "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/", ordinalSuffix: "/^\\s*(st|nd|rd|th)/", timeContext: "/^\\s*(\\:|a(?!u|p)|p)/" }, Date.i18n.currentLanguage()); } }; var CultureInfo = function () { var info = getText.getFromObjectValues({ name: "name", englishName: "englishName", nativeName: "nativeName", amDesignator: "AM", pmDesignator: "PM", firstDayOfWeek: "firstDayOfWeek", twoDigitYearMax: "twoDigitYearMax", dateElementOrder: "mdy" }, Date.i18n.currentLanguage()); var constructedInfo = buildInfo.buildFromMethodHash({ dayNames: "days", abbreviatedDayNames: "dayAbbr", shortestDayNames: "dayShortNames", firstLetterDayNames: "dayFirstLetters", monthNames: "months", abbreviatedMonthNames: "monthAbbr", formatPatterns: "formatPatterns", regexPatterns: "regex", abbreviatedTimeZoneDST: "timeZoneDST", abbreviatedTimeZoneStandard: "timeZoneStandard" }); shallowMerge(info, constructedInfo); buildInfo.timeZones(info); return info; }; $D.i18n = { __: function (key, lang) { return __(key, lang); }, currentLanguage: function () { return lang || "en-US"; }, setLanguage: function (code, force, cb) { var async = false; if (force || code === "en-US" || (!!Date.CultureStrings && !!Date.CultureStrings[code])) { lang = code; Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings.lang = code; Date.CultureInfo = new CultureInfo(); } else { if (!(!!Date.CultureStrings && !!Date.CultureStrings[code])) { if (typeof exports !== "undefined" && this.exports !== exports) { // we're in a Node enviroment, load it using require try { require("../i18n/" + code + ".js"); lang = code; Date.CultureStrings.lang = code; Date.CultureInfo = new CultureInfo(); } catch (e) { // var str = "The language for '" + code + "' could not be loaded by Node. It likely does not exist."; throw new Error("The DateJS IETF language tag '" + code + "' could not be loaded by Node. It likely does not exist."); } } else if (Date.Config && Date.Config.i18n) { // we know the location of the files, so lets load them async = true; loadI18nScript(code).done(function(){ lang = code; Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings.lang = code; Date.CultureInfo = new CultureInfo(); $D.Parsing.Normalizer.buildReplaceData(); // because this is async if ($D.Grammar) { $D.Grammar.buildGrammarFormats(); // so we can parse those strings... } if (cb) { setTimeout(cb,0); } }); } else { Date.console.error("The DateJS IETF language tag '" + code + "' is not available and has not been loaded."); return false; } } } $D.Parsing.Normalizer.buildReplaceData(); // rebuild normalizer strings if ($D.Grammar) { $D.Grammar.buildGrammarFormats(); // so we can parse those strings... } if (!async && cb) { setTimeout(cb,0); } }, getLoggedKeys: function () { return loggedKeys; }, updateCultureInfo: function () { Date.CultureInfo = new CultureInfo(); } }; $D.i18n.updateCultureInfo(); // run automatically }()); (function () { var $D = Date, $P = $D.prototype, p = function (s, l) { if (!l) { l = 2; } return ("000" + s).slice(l * -1); }; if (typeof window !== "undefined" && typeof window.console !== "undefined" && typeof window.console.log !== "undefined") { $D.console = console; // used only to raise non-critical errors if available } else { // set mock so we don't give errors. $D.console = { log: function(){}, error: function(){} }; } $D.Config = $D.Config || {}; $D.initOverloads = function() { /** * Overload of Date.now. Allows an alternate call for Date.now where it returns the * current Date as an object rather than just milliseconds since the Unix Epoch. * * Also provides an implementation of now() for browsers (IE<9) that don't have it. * * Backwards compatible so with work with either: * Date.now() [returns ms] * or * Date.now(true) [returns Date] */ if (!$D.now) { $D._now = function now() { return new Date().getTime(); }; } else if (!$D._now) { $D._now = $D.now; } $D.now = function (returnObj) { if (returnObj) { return $D.present(); } else { return $D._now(); } }; if ( !$P.toISOString ) { $P.toISOString = function() { return this.getUTCFullYear() + "-" + p(this.getUTCMonth() + 1) + "-" + p(this.getUTCDate()) + "T" + p(this.getUTCHours()) + ":" + p(this.getUTCMinutes()) + ":" + p(this.getUTCSeconds()) + "." + String( (this.getUTCMilliseconds()/1000).toFixed(3)).slice(2, 5) + "Z"; }; } // private if ( $P._toString === undefined ){ $P._toString = $P.toString; } }; $D.initOverloads(); /** * Gets a date that is set to the current date. The time is set to the start of the day (00:00 or 12:00 AM). * @return {Date} The current date. */ $D.today = function () { return new Date().clearTime(); }; /** * Gets a date that is set to the current date and time (same as new Date, but chainable) * @return {Date} The current date. */ $D.present = function () { return new Date(); }; /** * Compares the first date to the second date and returns an number indication of their relative values. * @param {Date} First Date object to compare [Required]. * @param {Date} Second Date object to compare to [Required]. * @return {Number} -1 = date1 is lessthan date2. 0 = values are equal. 1 = date1 is greaterthan date2. */ $D.compare = function (date1, date2) { if (isNaN(date1) || isNaN(date2)) { throw new Error(date1 + " - " + date2); } else if (date1 instanceof Date && date2 instanceof Date) { return (date1 < date2) ? -1 : (date1 > date2) ? 1 : 0; } else { throw new TypeError(date1 + " - " + date2); } }; /** * Compares the first Date object to the second Date object and returns true if they are equal. * @param {Date} First Date object to compare [Required] * @param {Date} Second Date object to compare to [Required] * @return {Boolean} true if dates are equal. false if they are not equal. */ $D.equals = function (date1, date2) { return (date1.compareTo(date2) === 0); }; /** * Gets the language appropriate day name when given the day number(0-6) * eg - 0 == Sunday * @return {String} The day name */ $D.getDayName = function (n) { return Date.CultureInfo.dayNames[n]; }; /** * Gets the day number (0-6) if given a CultureInfo specific string which is a valid dayName, abbreviatedDayName or shortestDayName (two char). * @param {String} The name of the day (eg. "Monday, "Mon", "tuesday", "tue", "We", "we"). * @return {Number} The day number */ $D.getDayNumberFromName = function (name) { var n = Date.CultureInfo.dayNames, m = Date.CultureInfo.abbreviatedDayNames, o = Date.CultureInfo.shortestDayNames, s = name.toLowerCase(); for (var i = 0; i < n.length; i++) { if (n[i].toLowerCase() === s || m[i].toLowerCase() === s || o[i].toLowerCase() === s) { return i; } } return -1; }; /** * Gets the month number (0-11) if given a Culture Info specific string which is a valid monthName or abbreviatedMonthName. * @param {String} The name of the month (eg. "February, "Feb", "october", "oct"). * @return {Number} The day number */ $D.getMonthNumberFromName = function (name) { var n = Date.CultureInfo.monthNames, m = Date.CultureInfo.abbreviatedMonthNames, s = name.toLowerCase(); for (var i = 0; i < n.length; i++) { if (n[i].toLowerCase() === s || m[i].toLowerCase() === s) { return i; } } return -1; }; /** * Gets the language appropriate month name when given the month number(0-11) * eg - 0 == January * @return {String} The month name */ $D.getMonthName = function (n) { return Date.CultureInfo.monthNames[n]; }; /** * Determines if the current date instance is within a LeapYear. * @param {Number} The year. * @return {Boolean} true if date is within a LeapYear, otherwise false. */ $D.isLeapYear = function (year) { return ((year % 4 === 0 && year % 100 !== 0) || year % 400 === 0); }; /** * Gets the number of days in the month, given a year and month value. Automatically corrects for LeapYear. * @param {Number} The year. * @param {Number} The month (0-11). * @return {Number} The number of days in the month. */ $D.getDaysInMonth = function (year, month) { if (!month && $D.validateMonth(year)) { month = year; year = Date.today().getFullYear(); } return [31, ($D.isLeapYear(year) ? 29 : 28), 31, 30, 31, 30, 31, 31, 30, 31, 30, 31][month]; }; $P.getDaysInMonth = function () { return $D.getDaysInMonth(this.getFullYear(), this.getMonth()); }; $D.getTimezoneAbbreviation = function (offset, dst) { var p, n = (dst || false) ? Date.CultureInfo.abbreviatedTimeZoneDST : Date.CultureInfo.abbreviatedTimeZoneStandard; for (p in n) { if (n.hasOwnProperty(p)) { if (n[p] === offset) { return p; } } } return null; }; $D.getTimezoneOffset = function (name, dst) { var i, a =[], z = Date.CultureInfo.timezones; if (!name) { name = (new Date()).getTimezone();} for (i = 0; i < z.length; i++) { if (z[i].name === name.toUpperCase()) { a.push(i); } } if (!z[a[0]]) { return null; } if (a.length === 1 || !dst) { return z[a[0]].offset; } else { for (i=0; i < a.length; i++) { if (z[a[i]].dst) { return z[a[i]].offset; } } } }; $D.getQuarter = function (d) { d = d || new Date(); // If no date supplied, use today var q = [1,2,3,4]; return q[Math.floor(d.getMonth() / 3)]; // ~~~ is a bitwise op. Faster than Math.floor }; $D.getDaysLeftInQuarter = function (d) { d = d || new Date(); var qEnd = new Date(d); qEnd.setMonth(qEnd.getMonth() + 3 - qEnd.getMonth() % 3, 0); return Math.floor((qEnd - d) / 8.64e7); }; // private var validate = function (n, min, max, name) { name = name ? name : "Object"; if (typeof n === "undefined") { return false; } else if (typeof n !== "number") { throw new TypeError(n + " is not a Number."); } else if (n < min || n > max) { // As failing validation is *not* an exceptional circumstance // lets not throw a RangeError Exception here. // It's semantically correct but it's not sensible. return false; } return true; }; /** * Validates the number is within an acceptable range for milliseconds [0-999]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateMillisecond = function (value) { return validate(value, 0, 999, "millisecond"); }; /** * Validates the number is within an acceptable range for seconds [0-59]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateSecond = function (value) { return validate(value, 0, 59, "second"); }; /** * Validates the number is within an acceptable range for minutes [0-59]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateMinute = function (value) { return validate(value, 0, 59, "minute"); }; /** * Validates the number is within an acceptable range for hours [0-23]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateHour = function (value) { return validate(value, 0, 23, "hour"); }; /** * Validates the number is within an acceptable range for the days in a month [0-MaxDaysInMonth]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateDay = function (value, year, month) { if (year === undefined || year === null || month === undefined || month === null) { return false;} return validate(value, 1, $D.getDaysInMonth(year, month), "day"); }; /** * Validates the number is within an acceptable range for months [0-11]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateWeek = function (value) { return validate(value, 0, 53, "week"); }; /** * Validates the number is within an acceptable range for months [0-11]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateMonth = function (value) { return validate(value, 0, 11, "month"); }; /** * Validates the number is within an acceptable range for years. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateYear = function (value) { /** * Per ECMAScript spec the range of times supported by Date objects is * exactly -100,000,000 days to +100,000,000 days measured relative to * midnight at the beginning of 01 January, 1970 UTC. * This gives a range of 8,640,000,000,000,000 milliseconds to either * side of 01 January, 1970 UTC. * * Earliest possible date: Tue, 20 Apr 271,822 B.C. 00:00:00 UTC * Latest possible date: Sat, 13 Sep 275,760 00:00:00 UTC */ return validate(value, -271822, 275760, "year"); }; $D.validateTimezone = function(value) { var timezones = {"ACDT":1,"ACST":1,"ACT":1,"ADT":1,"AEDT":1,"AEST":1,"AFT":1,"AKDT":1,"AKST":1,"AMST":1,"AMT":1,"ART":1,"AST":1,"AWDT":1,"AWST":1,"AZOST":1,"AZT":1,"BDT":1,"BIOT":1,"BIT":1,"BOT":1,"BRT":1,"BST":1,"BTT":1,"CAT":1,"CCT":1,"CDT":1,"CEDT":1,"CEST":1,"CET":1,"CHADT":1,"CHAST":1,"CHOT":1,"ChST":1,"CHUT":1,"CIST":1,"CIT":1,"CKT":1,"CLST":1,"CLT":1,"COST":1,"COT":1,"CST":1,"CT":1,"CVT":1,"CWST":1,"CXT":1,"DAVT":1,"DDUT":1,"DFT":1,"EASST":1,"EAST":1,"EAT":1,"ECT":1,"EDT":1,"EEDT":1,"EEST":1,"EET":1,"EGST":1,"EGT":1,"EIT":1,"EST":1,"FET":1,"FJT":1,"FKST":1,"FKT":1,"FNT":1,"GALT":1,"GAMT":1,"GET":1,"GFT":1,"GILT":1,"GIT":1,"GMT":1,"GST":1,"GYT":1,"HADT":1,"HAEC":1,"HAST":1,"HKT":1,"HMT":1,"HOVT":1,"HST":1,"ICT":1,"IDT":1,"IOT":1,"IRDT":1,"IRKT":1,"IRST":1,"IST":1,"JST":1,"KGT":1,"KOST":1,"KRAT":1,"KST":1,"LHST":1,"LINT":1,"MAGT":1,"MART":1,"MAWT":1,"MDT":1,"MET":1,"MEST":1,"MHT":1,"MIST":1,"MIT":1,"MMT":1,"MSK":1,"MST":1,"MUT":1,"MVT":1,"MYT":1,"NCT":1,"NDT":1,"NFT":1,"NPT":1,"NST":1,"NT":1,"NUT":1,"NZDT":1,"NZST":1,"OMST":1,"ORAT":1,"PDT":1,"PET":1,"PETT":1,"PGT":1,"PHOT":1,"PHT":1,"PKT":1,"PMDT":1,"PMST":1,"PONT":1,"PST":1,"PYST":1,"PYT":1,"RET":1,"ROTT":1,"SAKT":1,"SAMT":1,"SAST":1,"SBT":1,"SCT":1,"SGT":1,"SLST":1,"SRT":1,"SST":1,"SYOT":1,"TAHT":1,"THA":1,"TFT":1,"TJT":1,"TKT":1,"TLT":1,"TMT":1,"TOT":1,"TVT":1,"UCT":1,"ULAT":1,"UTC":1,"UYST":1,"UYT":1,"UZT":1,"VET":1,"VLAT":1,"VOLT":1,"VOST":1,"VUT":1,"WAKT":1,"WAST":1,"WAT":1,"WEDT":1,"WEST":1,"WET":1,"WST":1,"YAKT":1,"YEKT":1,"Z":1}; return (timezones[value] === 1); }; $D.validateTimezoneOffset= function(value) { // timezones go from +14hrs to -12hrs, the +X hours are negative offsets. return (value > -841 && value < 721); }; }()); (function () { var $D = Date, $P = $D.prototype, p = function (s, l) { if (!l) { l = 2; } return ("000" + s).slice(l * -1); }; var validateConfigObject = function (obj) { var result = {}, self = this, prop, testFunc; testFunc = function (prop, func, value) { if (prop === "day") { var month = (obj.month !== undefined) ? obj.month : self.getMonth(); var year = (obj.year !== undefined) ? obj.year : self.getFullYear(); return $D[func](value, year, month); } else { return $D[func](value); } }; for (prop in obj) { if (Object.prototype.hasOwnProperty.call(obj, prop)) { var func = "validate" + prop.charAt(0).toUpperCase() + prop.slice(1); if ($D[func] && obj[prop] !== null && testFunc(prop, func, obj[prop])) { result[prop] = obj[prop]; } } } return result; }; /** * Resets the time of this Date object to 12:00 AM (00:00), which is the start of the day. * @param {Boolean} .clone() this date instance before clearing Time * @return {Date} this */ $P.clearTime = function () { this.setHours(0); this.setMinutes(0); this.setSeconds(0); this.setMilliseconds(0); return this; }; /** * Resets the time of this Date object to the current time ('now'). * @return {Date} this */ $P.setTimeToNow = function () { var n = new Date(); this.setHours(n.getHours()); this.setMinutes(n.getMinutes()); this.setSeconds(n.getSeconds()); this.setMilliseconds(n.getMilliseconds()); return this; }; /** * Returns a new Date object that is an exact date and time copy of the original instance. * @return {Date} A new Date instance */ $P.clone = function () { return new Date(this.getTime()); }; /** * Compares this instance to a Date object and returns an number indication of their relative values. * @param {Date} Date object to compare [Required] * @return {Number} -1 = this is lessthan date. 0 = values are equal. 1 = this is greaterthan date. */ $P.compareTo = function (date) { return Date.compare(this, date); }; /** * Compares this instance to another Date object and returns true if they are equal. * @param {Date} Date object to compare. If no date to compare, new Date() [now] is used. * @return {Boolean} true if dates are equal. false if they are not equal. */ $P.equals = function (date) { return Date.equals(this, (date !== undefined ? date : new Date())); }; /** * Determines if this instance is between a range of two dates or equal to either the start or end dates. * @param {Date} Start of range [Required] * @param {Date} End of range [Required] * @return {Boolean} true is this is between or equal to the start and end dates, else false */ $P.between = function (start, end) { return this.getTime() >= start.getTime() && this.getTime() <= end.getTime(); }; /** * Determines if this date occurs after the date to compare to. * @param {Date} Date object to compare. If no date to compare, new Date() ("now") is used. * @return {Boolean} true if this date instance is greater than the date to compare to (or "now"), otherwise false. */ $P.isAfter = function (date) { return this.compareTo(date || new Date()) === 1; }; /** * Determines if this date occurs before the date to compare to. * @param {Date} Date object to compare. If no date to compare, new Date() ("now") is used. * @return {Boolean} true if this date instance is less than the date to compare to (or "now"). */ $P.isBefore = function (date) { return (this.compareTo(date || new Date()) === -1); }; /** * Determines if the current Date instance occurs today. * @return {Boolean} true if this date instance is 'today', otherwise false. */ /** * Determines if the current Date instance occurs on the same Date as the supplied 'date'. * If no 'date' to compare to is provided, the current Date instance is compared to 'today'. * @param {date} Date object to compare. If no date to compare, the current Date ("now") is used. * @return {Boolean} true if this Date instance occurs on the same Day as the supplied 'date'. */ $P.isToday = $P.isSameDay = function (date) { return this.clone().clearTime().equals((date || new Date()).clone().clearTime()); }; /** * Adds the specified number of milliseconds to this instance. * @param {Number} The number of milliseconds to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addMilliseconds = function (value) { if (!value) { return this; } this.setTime(this.getTime() + value * 1); return this; }; /** * Adds the specified number of seconds to this instance. * @param {Number} The number of seconds to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addSeconds = function (value) { if (!value) { return this; } return this.addMilliseconds(value * 1000); }; /** * Adds the specified number of seconds to this instance. * @param {Number} The number of seconds to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addMinutes = function (value) { if (!value) { return this; } return this.addMilliseconds(value * 60000); // 60*1000 }; /** * Adds the specified number of hours to this instance. * @param {Number} The number of hours to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addHours = function (value) { if (!value) { return this; } return this.addMilliseconds(value * 3600000); // 60*60*1000 }; /** * Adds the specified number of days to this instance. * @param {Number} The number of days to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addDays = function (value) { if (!value) { return this; } this.setDate(this.getDate() + value * 1); return this; }; /** * Adds the specified number of weekdays (ie - not sat or sun) to this instance. * @param {Number} The number of days to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addWeekdays = function (value) { if (!value) { return this; } var day = this.getDay(); var weeks = (Math.ceil(Math.abs(value)/7)); if (day === 0 || day === 6) { if (value > 0) { this.next().monday(); this.addDays(-1); day = this.getDay(); } } if (value < 0) { while (value < 0) { this.addDays(-1); day = this.getDay(); if (day !== 0 && day !== 6) { value++; } } return this; } else if (value > 5 || (6-day) <= value) { value = value + (weeks * 2); } return this.addDays(value); }; /** * Adds the specified number of weeks to this instance. * @param {Number} The number of weeks to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addWeeks = function (value) { if (!value) { return this; } return this.addDays(value * 7); }; /** * Adds the specified number of months to this instance. * @param {Number} The number of months to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addMonths = function (value) { if (!value) { return this; } var n = this.getDate(); this.setDate(1); this.setMonth(this.getMonth() + value * 1); this.setDate(Math.min(n, $D.getDaysInMonth(this.getFullYear(), this.getMonth()))); return this; }; $P.addQuarters = function (value) { if (!value) { return this; } // note this will take you to the same point in the quarter as you are now. // i.e. - if you are 15 days into the quarter you'll be 15 days into the resulting one. // bonus: this allows adding fractional quarters return this.addMonths(value * 3); }; /** * Adds the specified number of years to this instance. * @param {Number} The number of years to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addYears = function (value) { if (!value) { return this; } return this.addMonths(value * 12); }; /** * Adds (or subtracts) to the value of the years, months, weeks, days, hours, minutes, seconds, milliseconds of the date instance using given configuration object. Positive and Negative values allowed. * Example

	Date.today().add( { days: 1, months: 1 } )

	new Date().add( { years: -1 } )
	
* @param {Object} Configuration object containing attributes (months, days, etc.) * @return {Date} this */ $P.add = function (config) { if (typeof config === "number") { this._orient = config; return this; } var x = config; if (x.day) { // If we should be a different date than today (eg: for 'tomorrow -1d', etc). // Should only effect parsing, not direct usage (eg, Finish and FinishExact) if ((x.day - this.getDate()) !== 0) { this.setDate(x.day); } } if (x.milliseconds) { this.addMilliseconds(x.milliseconds); } if (x.seconds) { this.addSeconds(x.seconds); } if (x.minutes) { this.addMinutes(x.minutes); } if (x.hours) { this.addHours(x.hours); } if (x.weeks) { this.addWeeks(x.weeks); } if (x.months) { this.addMonths(x.months); } if (x.years) { this.addYears(x.years); } if (x.days) { this.addDays(x.days); } return this; }; /** * Get the week number. Week one (1) is the week which contains the first Thursday of the year. Monday is considered the first day of the week. * The .getWeek() function does NOT convert the date to UTC. The local datetime is used. * Please use .getISOWeek() to get the week of the UTC converted date. * @return {Number} 1 to 53 */ $P.getWeek = function (utc) { // Create a copy of this date object var self, target = new Date(this.valueOf()); if (utc) { target.addMinutes(target.getTimezoneOffset()); self = target.clone(); } else { self = this; } // ISO week date weeks start on monday // so correct the day number var dayNr = (self.getDay() + 6) % 7; // ISO 8601 states that week 1 is the week // with the first thursday of that year. // Set the target date to the thursday in the target week target.setDate(target.getDate() - dayNr + 3); // Store the millisecond value of the target date var firstThursday = target.valueOf(); // Set the target to the first thursday of the year // First set the target to january first target.setMonth(0, 1); // Not a thursday? Correct the date to the next thursday if (target.getDay() !== 4) { target.setMonth(0, 1 + ((4 - target.getDay()) + 7) % 7); } // The weeknumber is the number of weeks between the // first thursday of the year and the thursday in the target week return 1 + Math.ceil((firstThursday - target) / 604800000); // 604800000 = 7 * 24 * 3600 * 1000 }; /** * Get the ISO 8601 week number. Week one ("01") is the week which contains the first Thursday of the year. Monday is considered the first day of the week. * The .getISOWeek() function does convert the date to it's UTC value. Please use .getWeek() to get the week of the local date. * @return {String} "01" to "53" */ $P.getISOWeek = function () { return p(this.getWeek(true)); }; /** * Moves the date to Monday of the week set. Week one (1) is the week which contains the first Thursday of the year. * @param {Number} A Number (1 to 53) that represents the week of the year. * @return {Date} this */ $P.setWeek = function (n) { if ((n - this.getWeek()) === 0) { if (this.getDay() !== 1) { return this.moveToDayOfWeek(1, (this.getDay() > 1 ? -1 : 1)); } else { return this; } } else { return this.moveToDayOfWeek(1, (this.getDay() > 1 ? -1 : 1)).addWeeks(n - this.getWeek()); } }; $P.setQuarter = function (qtr) { var month = Math.abs(((qtr-1) * 3) + 1); return this.setMonth(month, 1); }; $P.getQuarter = function () { return Date.getQuarter(this); }; $P.getDaysLeftInQuarter = function () { return Date.getDaysLeftInQuarter(this); }; /** * Moves the date to the next n'th occurrence of the dayOfWeek starting from the beginning of the month. The number (-1) is a magic number and will return the last occurrence of the dayOfWeek in the month. * @param {Number} The dayOfWeek to move to * @param {Number} The n'th occurrence to move to. Use (-1) to return the last occurrence in the month * @return {Date} this */ $P.moveToNthOccurrence = function (dayOfWeek, occurrence) { if (dayOfWeek === "Weekday") { if (occurrence > 0) { this.moveToFirstDayOfMonth(); if (this.is().weekday()) { occurrence -= 1; } } else if (occurrence < 0) { this.moveToLastDayOfMonth(); if (this.is().weekday()) { occurrence += 1; } } else { return this; } return this.addWeekdays(occurrence); } var shift = 0; if (occurrence > 0) { shift = occurrence - 1; } else if (occurrence === -1) { this.moveToLastDayOfMonth(); if (this.getDay() !== dayOfWeek) { this.moveToDayOfWeek(dayOfWeek, -1); } return this; } return this.moveToFirstDayOfMonth().addDays(-1).moveToDayOfWeek(dayOfWeek, +1).addWeeks(shift); }; var moveToN = function (getFunc, addFunc, nVal) { return function (value, orient) { var diff = (value - this[getFunc]() + nVal * (orient || +1)) % nVal; return this[addFunc]((diff === 0) ? diff += nVal * (orient || +1) : diff); }; }; /** * Move to the next or last dayOfWeek based on the orient value. * @param {Number} The dayOfWeek to move to * @param {Number} Forward (+1) or Back (-1). Defaults to +1. [Optional] * @return {Date} this */ $P.moveToDayOfWeek = moveToN("getDay", "addDays", 7); /** * Move to the next or last month based on the orient value. * @param {Number} The month to move to. 0 = January, 11 = December * @param {Number} Forward (+1) or Back (-1). Defaults to +1. [Optional] * @return {Date} this */ $P.moveToMonth = moveToN("getMonth", "addMonths", 12); /** * Get the Ordinate of the current day ("th", "st", "rd"). * @return {String} */ $P.getOrdinate = function () { var num = this.getDate(); return ord(num); }; /** * Get the Ordinal day (numeric day number) of the year, adjusted for leap year. * @return {Number} 1 through 365 (366 in leap years) */ $P.getOrdinalNumber = function () { return Math.ceil((this.clone().clearTime() - new Date(this.getFullYear(), 0, 1)) / 86400000) + 1; }; /** * Get the time zone abbreviation of the current date. * @return {String} The abbreviated time zone name (e.g. "EST") */ $P.getTimezone = function () { return $D.getTimezoneAbbreviation(this.getUTCOffset(), this.isDaylightSavingTime()); }; $P.setTimezoneOffset = function (offset) { var here = this.getTimezoneOffset(), there = Number(offset) * -6 / 10; return (there || there === 0) ? this.addMinutes(there - here) : this; }; $P.setTimezone = function (offset) { return this.setTimezoneOffset($D.getTimezoneOffset(offset)); }; /** * Indicates whether Daylight Saving Time is observed in the current time zone. * @return {Boolean} true|false */ $P.hasDaylightSavingTime = function () { return (Date.today().set({month: 0, day: 1}).getTimezoneOffset() !== Date.today().set({month: 6, day: 1}).getTimezoneOffset()); }; /** * Indicates whether this Date instance is within the Daylight Saving Time range for the current time zone. * @return {Boolean} true|false */ $P.isDaylightSavingTime = function () { return Date.today().set({month: 0, day: 1}).getTimezoneOffset() !== this.getTimezoneOffset(); }; /** * Get the offset from UTC of the current date. * @return {String} The 4-character offset string prefixed with + or - (e.g. "-0500") */ $P.getUTCOffset = function (offset) { var n = (offset || this.getTimezoneOffset()) * -10 / 6, r; if (n < 0) { r = (n - 10000).toString(); return r.charAt(0) + r.substr(2); } else { r = (n + 10000).toString(); return "+" + r.substr(1); } }; /** * Returns the number of milliseconds between this date and date. * @param {Date} Defaults to now * @return {Number} The diff in milliseconds */ $P.getElapsed = function (date) { return (date || new Date()) - this; }; /** * Set the value of year, month, day, hour, minute, second, millisecond of date instance using given configuration object. * Example

	Date.today().set( { day: 20, month: 1 } )

	new Date().set( { millisecond: 0 } )
	
* * @param {Object} Configuration object containing attributes (month, day, etc.) * @return {Date} this */ $P.set = function (config) { config = validateConfigObject.call(this, config); var key; for (key in config) { if (Object.prototype.hasOwnProperty.call(config, key)) { var name = key.charAt(0).toUpperCase() + key.slice(1); var addFunc, getFunc; if (key !== "week" && key !== "month" && key !== "timezone" && key !== "timezoneOffset") { name += "s"; } addFunc = "add" + name; getFunc = "get" + name; if (key === "month") { addFunc = addFunc + "s"; } else if (key === "year"){ getFunc = "getFullYear"; } if (key !== "day" && key !== "timezone" && key !== "timezoneOffset" && key !== "week" && key !== "hour") { this[addFunc](config[key] - this[getFunc]()); } else if ( key === "timezone"|| key === "timezoneOffset" || key === "week" || key === "hour") { this["set"+name](config[key]); } } } // day has to go last because you can't validate the day without first knowing the month if (config.day) { this.addDays(config.day - this.getDate()); } return this; }; /** * Moves the date to the first day of the month. * @return {Date} this */ $P.moveToFirstDayOfMonth = function () { return this.set({ day: 1 }); }; /** * Moves the date to the last day of the month. * @return {Date} this */ $P.moveToLastDayOfMonth = function () { return this.set({ day: $D.getDaysInMonth(this.getFullYear(), this.getMonth())}); }; /** * Converts the value of the current Date object to its equivalent string representation. * Format Specifiers * CUSTOM DATE AND TIME FORMAT STRINGS * Format Description Example * ------ --------------------------------------------------------------------------- ----------------------- * s The seconds of the minute between 0-59. "0" to "59" * ss The seconds of the minute with leading zero if required. "00" to "59" * * m The minute of the hour between 0-59. "0" or "59" * mm The minute of the hour with leading zero if required. "00" or "59" * * h The hour of the day between 1-12. "1" to "12" * hh The hour of the day with leading zero if required. "01" to "12" * * H The hour of the day between 0-23. "0" to "23" * HH The hour of the day with leading zero if required. "00" to "23" * * d The day of the month between 1 and 31. "1" to "31" * dd The day of the month with leading zero if required. "01" to "31" * ddd Abbreviated day name. Date.CultureInfo.abbreviatedDayNames. "Mon" to "Sun" * dddd The full day name. Date.CultureInfo.dayNames. "Monday" to "Sunday" * * M The month of the year between 1-12. "1" to "12" * MM The month of the year with leading zero if required. "01" to "12" * MMM Abbreviated month name. Date.CultureInfo.abbreviatedMonthNames. "Jan" to "Dec" * MMMM The full month name. Date.CultureInfo.monthNames. "January" to "December" * * yy The year as a two-digit number. "99" or "08" * yyyy The full four digit year. "1999" or "2008" * * t Displays the first character of the A.M./P.M. designator. "A" or "P" * Date.CultureInfo.amDesignator or Date.CultureInfo.pmDesignator * tt Displays the A.M./P.M. designator. "AM" or "PM" * Date.CultureInfo.amDesignator or Date.CultureInfo.pmDesignator * * S The ordinal suffix ("st, "nd", "rd" or "th") of the current day. "st, "nd", "rd" or "th" * * STANDARD DATE AND TIME FORMAT STRINGS * Format Description Example *------ --------------------------------------------------------------------------- ----------------------- * d The CultureInfo shortDate Format Pattern "M/d/yyyy" * D The CultureInfo longDate Format Pattern "dddd, MMMM dd, yyyy" * F The CultureInfo fullDateTime Format Pattern "dddd, MMMM dd, yyyy h:mm:ss tt" * m The CultureInfo monthDay Format Pattern "MMMM dd" * r The CultureInfo rfc1123 Format Pattern "ddd, dd MMM yyyy HH:mm:ss GMT" * s The CultureInfo sortableDateTime Format Pattern "yyyy-MM-ddTHH:mm:ss" * t The CultureInfo shortTime Format Pattern "h:mm tt" * T The CultureInfo longTime Format Pattern "h:mm:ss tt" * u The CultureInfo universalSortableDateTime Format Pattern "yyyy-MM-dd HH:mm:ssZ" * y The CultureInfo yearMonth Format Pattern "MMMM, yyyy" * * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @return {String} A string representation of the current Date object. */ var ord = function (n) { switch (n * 1) { case 1: case 21: case 31: return "st"; case 2: case 22: return "nd"; case 3: case 23: return "rd"; default: return "th"; } }; var parseStandardFormats = function (format) { var y, c = Date.CultureInfo.formatPatterns; switch (format) { case "d": return this.toString(c.shortDate); case "D": return this.toString(c.longDate); case "F": return this.toString(c.fullDateTime); case "m": return this.toString(c.monthDay); case "r": case "R": y = this.clone().addMinutes(this.getTimezoneOffset()); return y.toString(c.rfc1123) + " GMT"; case "s": return this.toString(c.sortableDateTime); case "t": return this.toString(c.shortTime); case "T": return this.toString(c.longTime); case "u": y = this.clone().addMinutes(this.getTimezoneOffset()); return y.toString(c.universalSortableDateTime); case "y": return this.toString(c.yearMonth); default: return false; } }; var parseFormatStringsClosure = function (context) { return function (m) { if (m.charAt(0) === "\\") { return m.replace("\\", ""); } switch (m) { case "hh": return p(context.getHours() < 13 ? (context.getHours() === 0 ? 12 : context.getHours()) : (context.getHours() - 12)); case "h": return context.getHours() < 13 ? (context.getHours() === 0 ? 12 : context.getHours()) : (context.getHours() - 12); case "HH": return p(context.getHours()); case "H": return context.getHours(); case "mm": return p(context.getMinutes()); case "m": return context.getMinutes(); case "ss": return p(context.getSeconds()); case "s": return context.getSeconds(); case "yyyy": return p(context.getFullYear(), 4); case "yy": return p(context.getFullYear()); case "y": return context.getFullYear(); case "E": case "dddd": return Date.CultureInfo.dayNames[context.getDay()]; case "ddd": return Date.CultureInfo.abbreviatedDayNames[context.getDay()]; case "dd": return p(context.getDate()); case "d": return context.getDate(); case "MMMM": return Date.CultureInfo.monthNames[context.getMonth()]; case "MMM": return Date.CultureInfo.abbreviatedMonthNames[context.getMonth()]; case "MM": return p((context.getMonth() + 1)); case "M": return context.getMonth() + 1; case "t": return context.getHours() < 12 ? Date.CultureInfo.amDesignator.substring(0, 1) : Date.CultureInfo.pmDesignator.substring(0, 1); case "tt": return context.getHours() < 12 ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator; case "S": return ord(context.getDate()); case "W": return context.getWeek(); case "WW": return context.getISOWeek(); case "Q": return "Q" + context.getQuarter(); case "q": return String(context.getQuarter()); case "z": return context.getTimezone(); case "Z": case "X": return Date.getTimezoneOffset(context.getTimezone()); case "ZZ": // Timezone offset in seconds return context.getTimezoneOffset() * -60; case "u": return context.getDay(); case "L": return ($D.isLeapYear(context.getFullYear())) ? 1 : 0; case "B": // Swatch Internet Time (.beats) return "@"+((context.getUTCSeconds() + (context.getUTCMinutes()*60) + ((context.getUTCHours()+1)*3600))/86.4); default: return m; } }; }; $P.toString = function (format, ignoreStandards) { // Standard Date and Time Format Strings. Formats pulled from CultureInfo file and // may vary by culture. if (!ignoreStandards && format && format.length === 1) { output = parseStandardFormats.call(this, format); if (output) { return output; } } var parseFormatStrings = parseFormatStringsClosure(this); return format ? format.replace(/((\\)?(dd?d?d?|MM?M?M?|yy?y?y?|hh?|HH?|mm?|ss?|tt?|S|q|Q|WW?W?W?)(?![^\[]*\]))/g, parseFormatStrings).replace(/\[|\]/g, "") : this._toString(); }; }()); /************************************************************* * SugarPak - Domain Specific Language - Syntactical Sugar * *************************************************************/ (function () { var $D = Date, $P = $D.prototype, $N = Number.prototype; // private $P._orient = +1; // private $P._nth = null; // private $P._is = false; // private $P._same = false; // private $P._isSecond = false; // private $N._dateElement = "days"; /** * Moves the date to the next instance of a date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.today().next().friday();
	Date.today().next().fri();
	Date.today().next().march();
	Date.today().next().mar();
	Date.today().next().week();
	
* * @return {Date} date */ $P.next = function () { this._move = true; this._orient = +1; return this; }; /** * Creates a new Date (Date.today()) and moves the date to the next instance of the date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.next().friday();
	Date.next().fri();
	Date.next().march();
	Date.next().mar();
	Date.next().week();
	
* * @return {Date} date */ $D.next = function () { return $D.today().next(); }; /** * Moves the date to the previous instance of a date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.today().last().friday();
	Date.today().last().fri();
	Date.today().last().march();
	Date.today().last().mar();
	Date.today().last().week();
	
* * @return {Date} date */ $P.last = $P.prev = $P.previous = function () { this._move = true; this._orient = -1; return this; }; /** * Creates a new Date (Date.today()) and moves the date to the previous instance of the date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.last().friday();
	Date.last().fri();
	Date.previous().march();
	Date.prev().mar();
	Date.last().week();
	
* * @return {Date} date */ $D.last = $D.prev = $D.previous = function () { return $D.today().last(); }; /** * Performs a equality check when followed by either a month name, day name or .weekday() function. * Example

	Date.today().is().friday(); // true|false
	Date.today().is().fri();
	Date.today().is().march();
	Date.today().is().mar();
	
* * @return {Boolean} true|false */ $P.is = function () { this._is = true; return this; }; /** * Determines if two date objects occur on/in exactly the same instance of the subsequent date part function. * The function .same() must be followed by a date part function (example: .day(), .month(), .year(), etc). * * An optional Date can be passed in the date part function. If now date is passed as a parameter, 'Now' is used. * * The following example demonstrates how to determine if two dates fall on the exact same day. * * Example

	var d1 = Date.today(); // today at 00:00
	var d2 = new Date();   // exactly now.

	// Do they occur on the same day?
	d1.same().day(d2); // true
	
	// Do they occur on the same hour?
	d1.same().hour(d2); // false, unless d2 hour is '00' (midnight).
	
	// What if it's the same day, but one year apart?
	var nextYear = Date.today().add(1).year();

	d1.same().day(nextYear); // false, because the dates must occur on the exact same day. 
	
* * Scenario: Determine if a given date occurs during some week period 2 months from now. * * Example

	var future = Date.today().add(2).months();
	return someDate.same().week(future); // true|false;
	
* * @return {Boolean} true|false */ $P.same = function () { this._same = true; this._isSecond = false; return this; }; /** * Determines if the current date/time occurs during Today. Must be preceded by the .is() function. * Example

	someDate.is().today();    // true|false
	new Date().is().today();  // true
	Date.today().is().today();// true
	Date.today().add(-1).day().is().today(); // false
	
* * @return {Boolean} true|false */ $P.today = function () { return this.same().day(); }; /** * Determines if the current date is a weekday. This function must be preceded by the .is() function. * Example

	Date.today().is().weekday(); // true|false
	
* * @return {Boolean} true|false */ $P.weekday = function () { if (this._nth) { return df("Weekday").call(this); } if (this._move) { return this.addWeekdays(this._orient); } if (this._is) { this._is = false; return (!this.is().sat() && !this.is().sun()); } return false; }; /** * Determines if the current date is on the weekend. This function must be preceded by the .is() function. * Example

	Date.today().is().weekend(); // true|false
	
* * @return {Boolean} true|false */ $P.weekend = function () { if (this._is) { this._is = false; return (this.is().sat() || this.is().sun()); } return false; }; /** * Sets the Time of the current Date instance. A string "6:15 pm" or config object {hour:18, minute:15} are accepted. * Example

	// Set time to 6:15pm with a String
	Date.today().at("6:15pm");

	// Set time to 6:15pm with a config object
	Date.today().at({hour:18, minute:15});
	
* * @return {Date} date */ $P.at = function (time) { return (typeof time === "string") ? $D.parse(this.toString("d") + " " + time) : this.set(time); }; /** * Creates a new Date() and adds this (Number) to the date based on the preceding date element function (eg. second|minute|hour|day|month|year). * Example

	// Undeclared Numbers must be wrapped with parentheses. Requirment of JavaScript.
	(3).days().fromNow();
	(6).months().fromNow();

	// Declared Number variables do not require parentheses. 
	var n = 6;
	n.months().fromNow();
	
* * @return {Date} A new Date instance */ $N.fromNow = $N.after = function (date) { var c = {}; c[this._dateElement] = this; return ((!date) ? new Date() : date.clone()).add(c); }; /** * Creates a new Date() and subtract this (Number) from the date based on the preceding date element function (eg. second|minute|hour|day|month|year). * Example

	// Undeclared Numbers must be wrapped with parentheses. Requirment of JavaScript.
	(3).days().ago();
	(6).months().ago();

	// Declared Number variables do not require parentheses. 
	var n = 6;
	n.months().ago();
	
* * @return {Date} A new Date instance */ $N.ago = $N.before = function (date) { var c = {}, s = (this._dateElement[this._dateElement.length-1] !== "s") ? this._dateElement + "s" : this._dateElement; c[s] = this * -1; return ((!date) ? new Date() : date.clone()).add(c); }; // Do NOT modify the following string tokens. These tokens are used to build dynamic functions. // All culture-specific strings can be found in the CultureInfo files. var dx = ("sunday monday tuesday wednesday thursday friday saturday").split(/\s/), mx = ("january february march april may june july august september october november december").split(/\s/), px = ("Millisecond Second Minute Hour Day Week Month Year Quarter Weekday").split(/\s/), pxf = ("Milliseconds Seconds Minutes Hours Date Week Month FullYear Quarter").split(/\s/), nth = ("final first second third fourth fifth").split(/\s/), de; /** * Returns an object literal of all the date parts. * Example

	var o = new Date().toObject();
	
	// { year: 2008, month: 4, week: 20, day: 13, hour: 18, minute: 9, second: 32, millisecond: 812 }
	
	// The object properties can be referenced directly from the object.
	
	alert(o.day);  // alerts "13"
	alert(o.year); // alerts "2008"
	
* * @return {Date} An object literal representing the original date object. */ $P.toObject = function () { var o = {}; for (var i = 0; i < px.length; i++) { if (this["get" + pxf[i]]) { o[px[i].toLowerCase()] = this["get" + pxf[i]](); } } return o; }; /** * Returns a date created from an object literal. Ignores the .week property if set in the config. * Example

	var o = new Date().toObject();
	
	return Date.fromObject(o); // will return the same date. 

	var o2 = {month: 1, day: 20, hour: 18}; // birthday party!
	Date.fromObject(o2);
	
* * @return {Date} An object literal representing the original date object. */ $D.fromObject = function(config) { config.week = null; return Date.today().set(config); }; // Create day name functions and abbreviated day name functions (eg. monday(), friday(), fri()). var df = function (n) { return function () { if (this._is) { this._is = false; return this.getDay() === n; } if (this._move) { this._move = null; } if (this._nth !== null) { // If the .second() function was called earlier, remove the _orient // from the date, and then continue. // This is required because 'second' can be used in two different context. // // Example // // Date.today().add(1).second(); // Date.march().second().monday(); // // Things get crazy with the following... // Date.march().add(1).second().second().monday(); // but it works!! // if (this._isSecond) { this.addSeconds(this._orient * -1); } // make sure we reset _isSecond this._isSecond = false; var ntemp = this._nth; this._nth = null; var temp = this.clone().moveToLastDayOfMonth(); this.moveToNthOccurrence(n, ntemp); if (this > temp) { throw new RangeError($D.getDayName(n) + " does not occur " + ntemp + " times in the month of " + $D.getMonthName(temp.getMonth()) + " " + temp.getFullYear() + "."); } return this; } return this.moveToDayOfWeek(n, this._orient); }; }; var sdf = function (n) { return function () { var t = $D.today(), shift = n - t.getDay(); if (n === 0 && Date.CultureInfo.firstDayOfWeek === 1 && t.getDay() !== 0) { shift = shift + 7; } return t.addDays(shift); }; }; // Create month name functions and abbreviated month name functions (eg. january(), march(), mar()). var month_instance_functions = function (n) { return function () { if (this._is) { this._is = false; return this.getMonth() === n; } return this.moveToMonth(n, this._orient); }; }; var month_static_functions = function (n) { return function () { return $D.today().set({ month: n, day: 1 }); }; }; var processTerms = function (names, staticFunc, instanceFunc) { for (var i = 0; i < names.length; i++) { // Create constant static Name variables. $D[names[i].toUpperCase()] = $D[names[i].toUpperCase().substring(0, 3)] = i; // Create Name functions. $D[names[i]] = $D[names[i].substring(0, 3)] = staticFunc(i); // Create Name instance functions. $P[names[i]] = $P[names[i].substring(0, 3)] = instanceFunc(i); } }; processTerms(dx, sdf, df); processTerms(mx, month_static_functions, month_instance_functions); // Create date element functions and plural date element functions used with Date (eg. day(), days(), months()). var ef = function (j) { return function () { // if the .second() function was called earlier, the _orient // has alread been added. Just return this and reset _isSecond. if (this._isSecond) { this._isSecond = false; return this; } if (this._same) { this._same = this._is = false; var o1 = this.toObject(), o2 = (arguments[0] || new Date()).toObject(), v = "", k = j.toLowerCase(); // the substr trick with -1 doesn't work in IE8 or less k = (k[k.length-1] === "s") ? k.substring(0,k.length-1) : k; for (var m = (px.length - 1); m > -1; m--) { v = px[m].toLowerCase(); if (o1[v] !== o2[v]) { return false; } if (k === v) { break; } } return true; } if (j.substring(j.length - 1) !== "s") { j += "s"; } if (this._move) { this._move = null; } return this["add" + j](this._orient); }; }; var nf = function (n) { return function () { this._dateElement = n; return this; }; }; for (var k = 0; k < px.length; k++) { de = px[k].toLowerCase(); if(de !== "weekday") { // Create date element functions and plural date element functions used with Date (eg. day(), days(), months()). $P[de] = $P[de + "s"] = ef(px[k]); // Create date element functions and plural date element functions used with Number (eg. day(), days(), months()). $N[de] = $N[de + "s"] = nf(de + "s"); } } $P._ss = ef("Second"); var nthfn = function (n) { return function (dayOfWeek) { if (this._same) { return this._ss(arguments[0]); } if (dayOfWeek || dayOfWeek === 0) { return this.moveToNthOccurrence(dayOfWeek, n); } this._nth = n; // if the operator is 'second' add the _orient, then deal with it later... if (n === 2 && (dayOfWeek === undefined || dayOfWeek === null)) { this._isSecond = true; return this.addSeconds(this._orient); } return this; }; }; for (var l = 0; l < nth.length; l++) { $P[nth[l]] = (l === 0) ? nthfn(-1) : nthfn(l); } }()); (function () { "use strict"; Date.Parsing = { Exception: function (s) { this.message = "Parse error at '" + s.substring(0, 10) + " ...'"; } }; var $P = Date.Parsing; var dayOffsets = { standard: [0,31,59,90,120,151,181,212,243,273,304,334], leap: [0,31,60,91,121,152,182,213,244,274,305,335] }; $P.isLeapYear = function(year) { return ((year % 4 === 0) && (year % 100 !== 0)) || (year % 400 === 0); }; var utils = { multiReplace : function (str, hash ) { var key; for (key in hash) { if (Object.prototype.hasOwnProperty.call(hash, key)) { var regex; if (typeof hash[key] === "function") { } else { regex = (hash[key] instanceof RegExp) ? hash[key] : new RegExp(hash[key], "g"); } str = str.replace(regex, key); } } return str; }, getDayOfYearFromWeek : function (obj) { var d, jan4, offset; obj.weekDay = (!obj.weekDay && obj.weekDay !== 0) ? 1 : obj.weekDay; d = new Date(obj.year, 0, 4); jan4 = d.getDay() === 0 ? 7 : d.getDay(); // JS is 0 indexed on Sunday. offset = jan4+3; obj.dayOfYear = ((obj.week * 7) + (obj.weekDay === 0 ? 7 : obj.weekDay))-offset; return obj; }, getDayOfYear : function (obj, dayOffset) { if (!obj.dayOfYear) { obj = utils.getDayOfYearFromWeek(obj); } for (var i=0;i <= dayOffset.length;i++) { if (obj.dayOfYear < dayOffset[i] || i === dayOffset.length) { obj.day = obj.day ? obj.day : (obj.dayOfYear - dayOffset[i-1]); break; } else { obj.month = i; } } return obj; }, adjustForTimeZone : function (obj, date) { var offset; if (obj.zone.toUpperCase() === "Z" || (obj.zone_hours === 0 && obj.zone_minutes === 0)) { // it's UTC/GML so work out the current timeszone offset offset = -date.getTimezoneOffset(); } else { offset = (obj.zone_hours*60) + (obj.zone_minutes || 0); if (obj.zone_sign === "+") { offset *= -1; } offset -= date.getTimezoneOffset(); } date.setMinutes(date.getMinutes()+offset); return date; }, setDefaults : function (obj) { obj.year = obj.year || Date.today().getFullYear(); obj.hours = obj.hours || 0; obj.minutes = obj.minutes || 0; obj.seconds = obj.seconds || 0; obj.milliseconds = obj.milliseconds || 0; if (!(!obj.month && (obj.week || obj.dayOfYear))) { // if we have a month, or if we don't but don't have the day calculation data obj.month = obj.month || 0; obj.day = obj.day || 1; } return obj; }, dataNum: function (data, mod, explict, postProcess) { var dataNum = data*1; if (mod) { if (postProcess) { return data ? mod(data)*1 : data; } else { return data ? mod(dataNum) : data; } } else if (!explict){ return data ? dataNum : data; } else { return (data && typeof data !== "undefined") ? dataNum : data; } }, timeDataProcess: function (obj) { var timeObj = {}; for (var x in obj.data) { if (obj.data.hasOwnProperty(x)) { timeObj[x] = obj.ignore[x] ? obj.data[x] : utils.dataNum(obj.data[x], obj.mods[x], obj.explict[x], obj.postProcess[x]); } } if (obj.data.secmins) { obj.data.secmins = obj.data.secmins.replace(",", ".") * 60; if (!timeObj.minutes) { timeObj.minutes = obj.data.secmins; } else if (!timeObj.seconds) { timeObj.seconds = obj.data.secmins; } delete obj.secmins; } return timeObj; }, buildTimeObjectFromData: function (data) { var time = utils.timeDataProcess({ data: { year : data[1], month : data[5], day : data[7], week : data[8], dayOfYear : data[10], hours : data[15], zone_hours : data[23], zone_minutes : data[24], zone : data[21], zone_sign : data[22], weekDay : data[9], minutes: data[16], seconds: data[19], milliseconds: data[20], secmins: data[18] }, mods: { month: function(data) { return data-1; }, weekDay: function (data) { data = Math.abs(data); return (data === 7 ? 0 : data); }, minutes: function (data) { return data.replace(":",""); }, seconds: function (data) { return Math.floor( (data.replace(":","").replace(",","."))*1 ); }, milliseconds: function (data) { return (data.replace(",",".")*1000); } }, postProcess: { minutes: true, seconds: true, milliseconds: true }, explict: { zone_hours: true, zone_minutes: true }, ignore: { zone: true, zone_sign: true, secmins: true } }); return time; }, addToHash: function (hash, keys, data) { keys = keys; data = data; var len = keys.length; for (var i = 0; i < len; i++) { hash[keys[i]] = data[i]; } return hash; }, combineRegex: function (r1, r2) { return new RegExp("(("+r1.source+")\\s("+r2.source+"))"); }, getDateNthString: function(add, last, inc){ if (add) { return Date.today().addDays(inc).toString("d"); } else if (last) { return Date.today().last()[inc]().toString("d"); } }, buildRegexData: function (array) { var arr = []; var len = array.length; for (var i=0; i < len; i++) { if (Object.prototype.toString.call(array[i]) === '[object Array]') { // oldIE compat version of Array.isArray arr.push(this.combineRegex(array[i][0], array[i][1])); } else { arr.push(array[i]); } } return arr; } }; $P.processTimeObject = function (obj) { var date, dayOffset; utils.setDefaults(obj); dayOffset = ($P.isLeapYear(obj.year)) ? dayOffsets.leap : dayOffsets.standard; if (!obj.month && (obj.week || obj.dayOfYear)) { utils.getDayOfYear(obj, dayOffset); } else { obj.dayOfYear = dayOffset[obj.month] + obj.day; } date = new Date(obj.year, obj.month, obj.day, obj.hours, obj.minutes, obj.seconds, obj.milliseconds); if (obj.zone) { utils.adjustForTimeZone(obj, date); // adjust (and calculate) for timezone } return date; }; $P.ISO = { regex : /^([\+-]?\d{4}(?!\d{2}\b))((-?)((0[1-9]|1[0-2])(\3([12]\d|0[1-9]|3[01]))?|W([0-4]\d|5[0-3])(-?[1-7])?|(00[1-9]|0[1-9]\d|[12]\d{2}|3([0-5]\d|6[1-6])))([T\s]((([01]\d|2[0-4])((:?)[0-5]\d)?|24\:?00)([\.,]\d+(?!:))?)?(\17[0-5]\d([\.,]\d+)?)?\s?([zZ]|([\+-])([01]\d|2[0-3]):?([0-5]\d)?)?)?)?$/, parse : function (s) { var time, data = s.match(this.regex); if (!data || !data.length) { return null; } time = utils.buildTimeObjectFromData(data); if (!time.year || (!time.year && (!time.month && !time.day) && (!time.week && !time.dayOfYear)) ) { return null; } return $P.processTimeObject(time); } }; $P.Numeric = { isNumeric: function (e){return!isNaN(parseFloat(e))&&isFinite(e);}, regex: /\b([0-1]?[0-9])([0-3]?[0-9])([0-2]?[0-9]?[0-9][0-9])\b/i, parse: function (s) { var data, i, time = {}, order = Date.CultureInfo.dateElementOrder.split(""); if (!(this.isNumeric(s)) || // if it's non-numeric OR (s[0] === "+" && s[0] === "-")) { // It's an arithmatic string (eg +/-1000) return null; } if (s.length < 5 && s.indexOf(".") < 0 && s.indexOf("/") < 0) { // assume it's just a year. time.year = s; return $P.processTimeObject(time); } data = s.match(this.regex); if (!data || !data.length) { return null; } for (i=0; i < order.length; i++) { switch(order[i]) { case "d": time.day = data[i+1]; break; case "m": time.month = (data[i+1]-1); break; case "y": time.year = data[i+1]; break; } } return $P.processTimeObject(time); } }; $P.Normalizer = { regexData: function () { var $R = Date.CultureInfo.regexPatterns; return utils.buildRegexData([ $R.tomorrow, $R.yesterday, [$R.past, $R.mon], [$R.past, $R.tue], [$R.past, $R.wed], [$R.past, $R.thu], [$R.past, $R.fri], [$R.past, $R.sat], [$R.past, $R.sun] ]); }, basicReplaceHash : function() { var $R = Date.CultureInfo.regexPatterns; return { "January": $R.jan.source, "February": $R.feb, "March": $R.mar, "April": $R.apr, "May": $R.may, "June": $R.jun, "July": $R.jul, "August": $R.aug, "September": $R.sep, "October": $R.oct, "November": $R.nov, "December": $R.dec, "": /\bat\b/gi, " ": /\s{2,}/, "am": $R.inTheMorning, "9am": $R.thisMorning, "pm": $R.inTheEvening, "7pm":$R.thisEvening }; }, keys : function(){ return [ utils.getDateNthString(true, false, 1), // tomorrow utils.getDateNthString(true, false, -1), // yesterday utils.getDateNthString(false, true, "monday"), //last mon utils.getDateNthString(false, true, "tuesday"), //last tues utils.getDateNthString(false, true, "wednesday"), //last wed utils.getDateNthString(false, true, "thursday"), //last thurs utils.getDateNthString(false, true, "friday"), //last fri utils.getDateNthString(false, true, "saturday"), //last sat utils.getDateNthString(false, true, "sunday") //last sun ]; }, buildRegexFunctions: function () { var $R = Date.CultureInfo.regexPatterns; var __ = Date.i18n.__; var tomorrowRE = new RegExp("(\\b\\d\\d?("+__("AM")+"|"+__("PM")+")? )("+$R.tomorrow.source.slice(1)+")", "i"); // adapted tomorrow regex for AM PM relative dates var todayRE = new RegExp($R.today.source + "(?!\\s*([+-]))\\b"); // today, but excludes the math operators (eg "today + 2h") this.replaceFuncs = [ [todayRE, function (full) { return (full.length > 1) ? Date.today().toString("d") : full; }], [tomorrowRE, function(full, m1) { var t = Date.today().addDays(1).toString("d"); return (t + " " + m1); }], [$R.amThisMorning, function(str, am){return am;}], [$R.pmThisEvening, function(str, pm){return pm;}] ]; }, buildReplaceData: function () { this.buildRegexFunctions(); this.replaceHash = utils.addToHash(this.basicReplaceHash(), this.keys(), this.regexData()); }, stringReplaceFuncs: function (s) { for (var i=0; i < this.replaceFuncs.length; i++) { s = s.replace(this.replaceFuncs[i][0], this.replaceFuncs[i][1]); } return s; }, parse: function (s) { s = this.stringReplaceFuncs(s); s = utils.multiReplace(s, this.replaceHash); try { var n = s.split(/([\s\-\.\,\/\x27]+)/); if (n.length === 3 && $P.Numeric.isNumeric(n[0]) && $P.Numeric.isNumeric(n[2]) && (n[2].length >= 4)) { // ok, so we're dealing with x/year. But that's not a full date. // This fixes wonky dateElementOrder parsing when set to dmy order. if (Date.CultureInfo.dateElementOrder[0] === "d") { s = "1/" + n[0] + "/" + n[2]; // set to 1st of month and normalize the seperator } } } catch (e) {} return s; } }; $P.Normalizer.buildReplaceData(); }()); (function () { var $P = Date.Parsing; var _ = $P.Operators = { // // Tokenizers // rtoken: function (r) { // regex token return function (s) { var mx = s.match(r); if (mx) { return ([ mx[0], s.substring(mx[0].length) ]); } else { throw new $P.Exception(s); } }; }, token: function () { // whitespace-eating token return function (s) { return _.rtoken(new RegExp("^\\s*" + s + "\\s*"))(s); }; }, stoken: function (s) { // string token return _.rtoken(new RegExp("^" + s)); }, // Atomic Operators until: function (p) { return function (s) { var qx = [], rx = null; while (s.length) { try { rx = p.call(this, s); } catch (e) { qx.push(rx[0]); s = rx[1]; continue; } break; } return [ qx, s ]; }; }, many: function (p) { return function (s) { var rx = [], r = null; while (s.length) { try { r = p.call(this, s); } catch (e) { return [ rx, s ]; } rx.push(r[0]); s = r[1]; } return [ rx, s ]; }; }, // generator operators -- see below optional: function (p) { return function (s) { var r = null; try { r = p.call(this, s); } catch (e) { return [ null, s ]; } return [ r[0], r[1] ]; }; }, not: function (p) { return function (s) { try { p.call(this, s); } catch (e) { return [null, s]; } throw new $P.Exception(s); }; }, ignore: function (p) { return p ? function (s) { var r = null; r = p.call(this, s); return [null, r[1]]; } : null; }, product: function () { var px = arguments[0], qx = Array.prototype.slice.call(arguments, 1), rx = []; for (var i = 0 ; i < px.length ; i++) { rx.push(_.each(px[i], qx)); } return rx; }, cache: function (rule) { var cache = {}, cache_length = 0, cache_keys = [], CACHE_MAX = Date.Config.CACHE_MAX || 100000, r = null; var cacheCheck = function () { if (cache_length === CACHE_MAX) { // kill several keys, don't want to have to do this all the time... for (var i=0; i < 10; i++) { var key = cache_keys.shift(); if (key) { delete cache[key]; cache_length--; } } } }; return function (s) { cacheCheck(); try { r = cache[s] = (cache[s] || rule.call(this, s)); } catch (e) { r = cache[s] = e; } cache_length++; cache_keys.push(s); if (r instanceof $P.Exception) { throw r; } else { return r; } }; }, // vector operators -- see below any: function () { var px = arguments; return function (s) { var r = null; for (var i = 0; i < px.length; i++) { if (px[i] == null) { continue; } try { r = (px[i].call(this, s)); } catch (e) { r = null; } if (r) { return r; } } throw new $P.Exception(s); }; }, each: function () { var px = arguments; return function (s) { var rx = [], r = null; for (var i = 0; i < px.length ; i++) { if (px[i] == null) { continue; } try { r = (px[i].call(this, s)); } catch (e) { throw new $P.Exception(s); } rx.push(r[0]); s = r[1]; } return [ rx, s]; }; }, all: function () { var px = arguments, _ = _; return _.each(_.optional(px)); }, // delimited operators sequence: function (px, d, c) { d = d || _.rtoken(/^\s*/); c = c || null; if (px.length === 1) { return px[0]; } return function (s) { var r = null, q = null; var rx = []; for (var i = 0; i < px.length ; i++) { try { r = px[i].call(this, s); } catch (e) { break; } rx.push(r[0]); try { q = d.call(this, r[1]); } catch (ex) { q = null; break; } s = q[1]; } if (!r) { throw new $P.Exception(s); } if (q) { throw new $P.Exception(q[1]); } if (c) { try { r = c.call(this, r[1]); } catch (ey) { throw new $P.Exception(r[1]); } } return [ rx, (r?r[1]:s) ]; }; }, // // Composite Operators // between: function (d1, p, d2) { d2 = d2 || d1; var _fn = _.each(_.ignore(d1), p, _.ignore(d2)); return function (s) { var rx = _fn.call(this, s); return [[rx[0][0], r[0][2]], rx[1]]; }; }, list: function (p, d, c) { d = d || _.rtoken(/^\s*/); c = c || null; return (p instanceof Array ? _.each(_.product(p.slice(0, -1), _.ignore(d)), p.slice(-1), _.ignore(c)) : _.each(_.many(_.each(p, _.ignore(d))), px, _.ignore(c))); }, set: function (px, d, c) { d = d || _.rtoken(/^\s*/); c = c || null; return function (s) { // r is the current match, best the current 'best' match // which means it parsed the most amount of input var r = null, p = null, q = null, rx = null, best = [[], s], last = false; // go through the rules in the given set for (var i = 0; i < px.length ; i++) { // last is a flag indicating whether this must be the last element // if there is only 1 element, then it MUST be the last one q = null; p = null; r = null; last = (px.length === 1); // first, we try simply to match the current pattern // if not, try the next pattern try { r = px[i].call(this, s); } catch (e) { continue; } // since we are matching against a set of elements, the first // thing to do is to add r[0] to matched elements rx = [[r[0]], r[1]]; // if we matched and there is still input to parse and // we don't already know this is the last element, // we're going to next check for the delimiter ... // if there's none, or if there's no input left to parse // than this must be the last element after all ... if (r[1].length > 0 && ! last) { try { q = d.call(this, r[1]); } catch (ex) { last = true; } } else { last = true; } // if we parsed the delimiter and now there's no more input, // that means we shouldn't have parsed the delimiter at all // so don't update r and mark this as the last element ... if (!last && q[1].length === 0) { last = true; } // so, if this isn't the last element, we're going to see if // we can get any more matches from the remaining (unmatched) // elements ... if (!last) { // build a list of the remaining rules we can match against, // i.e., all but the one we just matched against var qx = []; for (var j = 0; j < px.length ; j++) { if (i !== j) { qx.push(px[j]); } } // now invoke recursively set with the remaining input // note that we don't include the closing delimiter ... // we'll check for that ourselves at the end p = _.set(qx, d).call(this, q[1]); // if we got a non-empty set as a result ... // (otw rx already contains everything we want to match) if (p[0].length > 0) { // update current result, which is stored in rx ... // basically, pick up the remaining text from p[1] // and concat the result from p[0] so that we don't // get endless nesting ... rx[0] = rx[0].concat(p[0]); rx[1] = p[1]; } } // at this point, rx either contains the last matched element // or the entire matched set that starts with this element. // now we just check to see if this variation is better than // our best so far, in terms of how much of the input is parsed if (rx[1].length < best[1].length) { best = rx; } // if we've parsed all the input, then we're finished if (best[1].length === 0) { break; } } // so now we've either gone through all the patterns trying them // as the initial match; or we found one that parsed the entire // input string ... // if best has no matches, just return empty set ... if (best[0].length === 0) { return best; } // if a closing delimiter is provided, then we have to check it also if (c) { // we try this even if there is no remaining input because the pattern // may well be optional or match empty input ... try { q = c.call(this, best[1]); } catch (ey) { throw new $P.Exception(best[1]); } // it parsed ... be sure to update the best match remaining input best[1] = q[1]; } // if we're here, either there was no closing delimiter or we parsed it // so now we have the best match; just return it! return best; }; }, forward: function (gr, fname) { return function (s) { return gr[fname].call(this, s); }; }, // // Translation Operators // replace: function (rule, repl) { return function (s) { var r = rule.call(this, s); return [repl, r[1]]; }; }, process: function (rule, fn) { return function (s) { var r = rule.call(this, s); return [fn.call(this, r[0]), r[1]]; }; }, min: function (min, rule) { return function (s) { var rx = rule.call(this, s); if (rx[0].length < min) { throw new $P.Exception(s); } return rx; }; } }; // Generator Operators And Vector Operators // Generators are operators that have a signature of F(R) => R, // taking a given rule and returning another rule, such as // ignore, which parses a given rule and throws away the result. // Vector operators are those that have a signature of F(R1,R2,...) => R, // take a list of rules and returning a new rule, such as each. // Generator operators are converted (via the following _generator // function) into functions that can also take a list or array of rules // and return an array of new rules as though the function had been // called on each rule in turn (which is what actually happens). // This allows generators to be used with vector operators more easily. // Example: // each(ignore(foo, bar)) instead of each(ignore(foo), ignore(bar)) // This also turns generators into vector operators, which allows // constructs like: // not(cache(foo, bar)) var _generator = function (op) { function gen() { var args = null, rx = [], px, i; if (arguments.length > 1) { args = Array.prototype.slice.call(arguments); } else if (arguments[0] instanceof Array) { args = arguments[0]; } if (args) { px = args.shift(); if (px.length > 0) { args.unshift(px[i]); rx.push(op.apply(null, args)); args.shift(); return rx; } } else { return op.apply(null, arguments); } } return gen; }; var gx = "optional not ignore cache".split(/\s/); for (var i = 0 ; i < gx.length ; i++) { _[gx[i]] = _generator(_[gx[i]]); } var _vector = function (op) { return function () { if (arguments[0] instanceof Array) { return op.apply(null, arguments[0]); } else { return op.apply(null, arguments); } }; }; var vx = "each any all".split(/\s/); for (var j = 0 ; j < vx.length ; j++) { _[vx[j]] = _vector(_[vx[j]]); } }()); (function () { var $D = Date; var flattenAndCompact = function (ax) { var rx = []; for (var i = 0; i < ax.length; i++) { if (ax[i] instanceof Array) { rx = rx.concat(flattenAndCompact(ax[i])); } else { if (ax[i]) { rx.push(ax[i]); } } } return rx; }; var parseMeridian = function () { if (this.meridian && (this.hour || this.hour === 0)) { if (this.meridian === "a" && this.hour > 11 && Date.Config.strict24hr){ throw "Invalid hour and meridian combination"; } else if (this.meridian === "p" && this.hour < 12 && Date.Config.strict24hr){ throw "Invalid hour and meridian combination"; } else if (this.meridian === "p" && this.hour < 12) { this.hour = this.hour + 12; } else if (this.meridian === "a" && this.hour === 12) { this.hour = 0; } } }; var setDefaults = function () { var now = new Date(); if ((this.hour || this.minute) && (!this.month && !this.year && !this.day)) { this.day = now.getDate(); } if (!this.year) { this.year = now.getFullYear(); } if (!this.month && this.month !== 0) { this.month = now.getMonth(); } if (!this.day) { this.day = 1; } if (!this.hour) { this.hour = 0; } if (!this.minute) { this.minute = 0; } if (!this.second) { this.second = 0; } if (!this.millisecond) { this.millisecond = 0; } }; var finishUtils = { getToday: function () { if (this.now || "hour minute second".indexOf(this.unit) !== -1) { return new Date(); } else { return $D.today(); } }, setDaysFromWeekday: function (today, orient){ var gap; orient = orient || 1; this.unit = "day"; gap = ($D.getDayNumberFromName(this.weekday) - today.getDay()); this.days = gap ? ((gap + (orient * 7)) % 7) : (orient * 7); return this; }, setMonthsFromMonth: function (today, orient) { var gap; orient = orient || 1; this.unit = "month"; gap = (this.month - today.getMonth()); this.months = gap ? ((gap + (orient * 12)) % 12) : (orient * 12); this.month = null; return this; }, setDMYFromWeekday: function () { var d = Date[this.weekday](); this.day = d.getDate(); if (!this.month) { this.month = d.getMonth(); } this.year = d.getFullYear(); return this; }, setUnitValue: function (orient) { if (!this.value && this.operator && this.operator !== null && this[this.unit + "s"] && this[this.unit + "s"] !== null) { this[this.unit + "s"] = this[this.unit + "s"] + ((this.operator === "add") ? 1 : -1) + (this.value||0) * orient; } else if (this[this.unit + "s"] == null || this.operator != null) { if (!this.value) { this.value = 1; } this[this.unit + "s"] = this.value * orient; } }, generateDateFromWeeks: function () { var weekday = (this.weekday !== undefined) ? this.weekday : "today"; var d = Date[weekday]().addWeeks(this.weeks); if (this.now) { d.setTimeToNow(); } return d; } }; $D.Translator = { hour: function (s) { return function () { this.hour = Number(s); }; }, minute: function (s) { return function () { this.minute = Number(s); }; }, second: function (s) { return function () { this.second = Number(s); }; }, /* for ss.s format */ secondAndMillisecond: function (s) { return function () { var mx = s.match(/^([0-5][0-9])\.([0-9]{1,3})/); this.second = Number(mx[1]); this.millisecond = Number(mx[2]); }; }, meridian: function (s) { return function () { this.meridian = s.slice(0, 1).toLowerCase(); }; }, timezone: function (s) { return function () { var n = s.replace(/[^\d\+\-]/g, ""); if (n.length) { this.timezoneOffset = Number(n); } else { this.timezone = s.toLowerCase(); } }; }, day: function (x) { var s = x[0]; return function () { this.day = Number(s.match(/\d+/)[0]); if (this.day < 1) { throw "invalid day"; } }; }, month: function (s) { return function () { this.month = (s.length === 3) ? "jan feb mar apr may jun jul aug sep oct nov dec".indexOf(s)/4 : Number(s) - 1; if (this.month < 0) { throw "invalid month"; } }; }, year: function (s) { return function () { var n = Number(s); this.year = ((s.length > 2) ? n : (n + (((n + 2000) < Date.CultureInfo.twoDigitYearMax) ? 2000 : 1900))); }; }, rday: function (s) { return function () { switch (s) { case "yesterday": this.days = -1; break; case "tomorrow": this.days = 1; break; case "today": this.days = 0; break; case "now": this.days = 0; this.now = true; break; } }; }, finishExact: function (x) { var d; x = (x instanceof Array) ? x : [x]; for (var i = 0 ; i < x.length ; i++) { if (x[i]) { x[i].call(this); } } setDefaults.call(this); parseMeridian.call(this); if (this.day > $D.getDaysInMonth(this.year, this.month)) { throw new RangeError(this.day + " is not a valid value for days."); } d = new Date(this.year, this.month, this.day, this.hour, this.minute, this.second, this.millisecond); if (this.year < 100) { d.setFullYear(this.year); // means years less that 100 are process correctly. JS will parse it otherwise as 1900-1999. } if (this.timezone) { d.set({ timezone: this.timezone }); } else if (this.timezoneOffset) { d.set({ timezoneOffset: this.timezoneOffset }); } return d; }, finish: function (x) { var today, expression, orient, temp; x = (x instanceof Array) ? flattenAndCompact(x) : [ x ]; if (x.length === 0) { return null; } for (var i = 0 ; i < x.length ; i++) { if (typeof x[i] === "function") { x[i].call(this); } } if (this.now && !this.unit && !this.operator) { return new Date(); } else { today = finishUtils.getToday.call(this); } expression = !!(this.days && this.days !== null || this.orient || this.operator); orient = ((this.orient === "past" || this.operator === "subtract") ? -1 : 1); if (this.month && this.unit === "week") { this.value = this.month + 1; delete this.month; delete this.day; } if ((this.month || this.month === 0) && "year day hour minute second".indexOf(this.unit) !== -1) { if (!this.value) { this.value = this.month + 1; } this.month = null; expression = true; } if (!expression && this.weekday && !this.day && !this.days) { finishUtils.setDMYFromWeekday.call(this); } if (expression && this.weekday && this.unit !== "month" && this.unit !== "week") { finishUtils.setDaysFromWeekday.call(this, today, orient); } if (this.weekday && this.unit !== "week" && !this.day && !this.days) { temp = Date[this.weekday](); this.day = temp.getDate(); if (temp.getMonth() !== today.getMonth()) { this.month = temp.getMonth(); } } if (this.month && this.unit === "day" && this.operator) { if (!this.value) { this.value = (this.month + 1); } this.month = null; } if (this.value != null && this.month != null && this.year != null) { this.day = this.value * 1; } if (this.month && !this.day && this.value) { today.set({ day: this.value * 1 }); if (!expression) { this.day = this.value * 1; } } if (!this.month && this.value && this.unit === "month" && !this.now) { this.month = this.value; expression = true; } if (expression && (this.month || this.month === 0) && this.unit !== "year") { finishUtils.setMonthsFromMonth.call(this, today, orient); } if (!this.unit) { this.unit = "day"; } finishUtils.setUnitValue.call(this, orient); parseMeridian.call(this); if ((this.month || this.month === 0) && !this.day) { this.day = 1; } if (!this.orient && !this.operator && this.unit === "week" && this.value && !this.day && !this.month) { return Date.today().setWeek(this.value); } if (this.unit === "week" && this.weeks && !this.day && !this.month) { return finishUtils.generateDateFromWeeks.call(this); } if (expression && this.timezone && this.day && this.days) { this.day = this.days; } if (expression){ today.add(this); } else { today.set(this); } if (this.timezone) { this.timezone = this.timezone.toUpperCase(); var offset = $D.getTimezoneOffset(this.timezone); var timezone; if (today.hasDaylightSavingTime()) { // lets check that we're being sane with timezone setting timezone = $D.getTimezoneAbbreviation(offset, today.isDaylightSavingTime()); if (timezone !== this.timezone) { // bugger, we're in a place where things like EST vs EDT matters. if (today.isDaylightSavingTime()) { today.addHours(-1); } else { today.addHours(1); } } } today.setTimezoneOffset(offset); } return today; } }; }()); (function () { var $D = Date; $D.Grammar = {}; var _ = $D.Parsing.Operators, g = $D.Grammar, t = $D.Translator, _fn; // Allow rolling up into general purpose rules _fn = function () { return _.each(_.any.apply(null, arguments), _.not(g.ctoken2("timeContext"))); }; g.datePartDelimiter = _.rtoken(/^([\s\-\.\,\/\x27]+)/); g.timePartDelimiter = _.stoken(":"); g.whiteSpace = _.rtoken(/^\s*/); g.generalDelimiter = _.rtoken(/^(([\s\,]|at|@|on)+)/); var _C = {}; g.ctoken = function (keys) { var fn = _C[keys]; if (! fn) { var c = Date.CultureInfo.regexPatterns; var kx = keys.split(/\s+/), px = []; for (var i = 0; i < kx.length ; i++) { px.push(_.replace(_.rtoken(c[kx[i]]), kx[i])); } fn = _C[keys] = _.any.apply(null, px); } return fn; }; g.ctoken2 = function (key) { return _.rtoken(Date.CultureInfo.regexPatterns[key]); }; var cacheProcessRtoken = function (key, token, type, eachToken) { if (eachToken) { g[key] = _.cache(_.process(_.each(_.rtoken(token),_.optional(g.ctoken2(eachToken))), type)); } else { g[key] = _.cache(_.process(_.rtoken(token), type)); } }; var cacheProcessCtoken = function (token, type) { return _.cache(_.process(g.ctoken2(token), type)); }; var _F = {}; //function cache var _get = function (f) { _F[f] = (_F[f] || g.format(f)[0]); return _F[f]; }; g.allformats = function (fx) { var rx = []; if (fx instanceof Array) { for (var i = 0; i < fx.length; i++) { rx.push(_get(fx[i])); } } else { rx.push(_get(fx)); } return rx; }; g.formats = function (fx) { if (fx instanceof Array) { var rx = []; for (var i = 0 ; i < fx.length ; i++) { rx.push(_get(fx[i])); } return _.any.apply(null, rx); } else { return _get(fx); } }; var grammarFormats = { timeFormats: function(){ var i, RTokenKeys = [ "h", "hh", "H", "HH", "m", "mm", "s", "ss", "ss.s", "z", "zz" ], RToken = [ /^(0[0-9]|1[0-2]|[1-9])/, /^(0[0-9]|1[0-2])/, /^([0-1][0-9]|2[0-3]|[0-9])/, /^([0-1][0-9]|2[0-3])/, /^([0-5][0-9]|[0-9])/, /^[0-5][0-9]/, /^([0-5][0-9]|[0-9])/, /^[0-5][0-9]/, /^[0-5][0-9]\.[0-9]{1,3}/, /^((\+|\-)\s*\d\d\d\d)|((\+|\-)\d\d\:?\d\d)/, /^((\+|\-)\s*\d\d\d\d)|((\+|\-)\d\d\:?\d\d)/ ], tokens = [ t.hour, t.hour, t.hour, t.hour, t.minute, t.minute, t.second, t.second, t.secondAndMillisecond, t.timezone, t.timezone ]; for (i=0; i < RTokenKeys.length; i++) { cacheProcessRtoken(RTokenKeys[i], RToken[i], tokens[i]); } g.hms = _.cache(_.sequence([g.H, g.m, g.s], g.timePartDelimiter)); g.t = cacheProcessCtoken("shortMeridian", t.meridian); g.tt = cacheProcessCtoken("longMeridian", t.meridian); g.zzz = cacheProcessCtoken("timezone", t.timezone); g.timeSuffix = _.each(_.ignore(g.whiteSpace), _.set([ g.tt, g.zzz ])); g.time = _.each(_.optional(_.ignore(_.stoken("T"))), g.hms, g.timeSuffix); }, dateFormats: function () { // pre-loaded rules for different date part order preferences var _setfn = function () { return _.set(arguments, g.datePartDelimiter); }; var i, RTokenKeys = [ "d", "dd", "M", "MM", "y", "yy", "yyy", "yyyy" ], RToken = [ /^([0-2]\d|3[0-1]|\d)/, /^([0-2]\d|3[0-1])/, /^(1[0-2]|0\d|\d)/, /^(1[0-2]|0\d)/, /^(\d+)/, /^(\d\d)/, /^(\d\d?\d?\d?)/, /^(\d\d\d\d)/ ], tokens = [ t.day, t.day, t.month, t.month, t.year, t.year, t.year, t.year ], eachToken = [ "ordinalSuffix", "ordinalSuffix" ]; for (i=0; i < RTokenKeys.length; i++) { cacheProcessRtoken(RTokenKeys[i], RToken[i], tokens[i], eachToken[i]); } g.MMM = g.MMMM = _.cache(_.process(g.ctoken("jan feb mar apr may jun jul aug sep oct nov dec"), t.month)); g.ddd = g.dddd = _.cache(_.process(g.ctoken("sun mon tue wed thu fri sat"), function (s) { return function () { this.weekday = s; }; } )); g.day = _fn(g.d, g.dd); g.month = _fn(g.M, g.MMM); g.year = _fn(g.yyyy, g.yy); g.mdy = _setfn(g.ddd, g.month, g.day, g.year); g.ymd = _setfn(g.ddd, g.year, g.month, g.day); g.dmy = _setfn(g.ddd, g.day, g.month, g.year); g.date = function (s) { return ((g[Date.CultureInfo.dateElementOrder] || g.mdy).call(this, s)); }; }, relative: function () { // relative date / time expressions g.orientation = _.process(g.ctoken("past future"), function (s) { return function () { this.orient = s; }; } ); g.operator = _.process(g.ctoken("add subtract"), function (s) { return function () { this.operator = s; }; } ); g.rday = _.process(g.ctoken("yesterday tomorrow today now"), t.rday); g.unit = _.process(g.ctoken("second minute hour day week month year"), function (s) { return function () { this.unit = s; }; } ); } }; g.buildGrammarFormats = function () { // these need to be rebuilt every time the language changes. _C = {}; grammarFormats.timeFormats(); grammarFormats.dateFormats(); grammarFormats.relative(); g.value = _.process(_.rtoken(/^([-+]?\d+)?(st|nd|rd|th)?/), function (s) { return function () { this.value = s.replace(/\D/g, ""); }; } ); g.expression = _.set([g.rday, g.operator, g.value, g.unit, g.orientation, g.ddd, g.MMM ]); g.format = _.process(_.many( _.any( // translate format specifiers into grammar rules _.process( _.rtoken(/^(dd?d?d?(?!e)|MM?M?M?|yy?y?y?|hh?|HH?|mm?|ss?|tt?|zz?z?)/), function (fmt) { if (g[fmt]) { return g[fmt]; } else { throw $D.Parsing.Exception(fmt); } } ), // translate separator tokens into token rules _.process(_.rtoken(/^[^dMyhHmstz]+/), // all legal separators function (s) { return _.ignore(_.stoken(s)); } ) ) ), // construct the parser ... function (rules) { return _.process(_.each.apply(null, rules), t.finishExact); } ); // starting rule for general purpose grammar g._start = _.process(_.set([ g.date, g.time, g.expression ], g.generalDelimiter, g.whiteSpace), t.finish); }; g.buildGrammarFormats(); // parsing date format specifiers - ex: "h:m:s tt" // this little guy will generate a custom parser based // on the format string, ex: g.format("h:m:s tt") // check for these formats first g._formats = g.formats([ "\"yyyy-MM-ddTHH:mm:ssZ\"", "yyyy-MM-ddTHH:mm:ss.sz", "yyyy-MM-ddTHH:mm:ssZ", "yyyy-MM-ddTHH:mm:ssz", "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-ddTHH:mmZ", "yyyy-MM-ddTHH:mmz", "yyyy-MM-ddTHH:mm", "ddd, MMM dd, yyyy H:mm:ss tt", "ddd MMM d yyyy HH:mm:ss zzz", "MMddyyyy", "ddMMyyyy", "Mddyyyy", "ddMyyyy", "Mdyyyy", "dMyyyy", "yyyy", "Mdyy", "dMyy", "d" ]); // real starting rule: tries selected formats first, // then general purpose rule g.start = function (s) { try { var r = g._formats.call({}, s); if (r[1].length === 0) { return r; } } catch (e) {} return g._start.call({}, s); }; }()); (function () { var $D = Date; /** * @desc Converts the specified string value into its JavaScript Date equivalent using CultureInfo specific format information. * * Example

	///////////
	// Dates //
	///////////

	// 15-Oct-2004
	var d1 = Date.parse("10/15/2004");

	// 15-Oct-2004
	var d1 = Date.parse("15-Oct-2004");

	// 15-Oct-2004
	var d1 = Date.parse("2004.10.15");

	//Fri Oct 15, 2004
	var d1 = Date.parse("Fri Oct 15, 2004");

	///////////
	// Times //
	///////////

	// Today at 10 PM.
	var d1 = Date.parse("10 PM");

	// Today at 10:30 PM.
	var d1 = Date.parse("10:30 P.M.");

	// Today at 6 AM.
	var d1 = Date.parse("06am");

	/////////////////////
	// Dates and Times //
	/////////////////////

	// 8-July-2004 @ 10:30 PM
	var d1 = Date.parse("July 8th, 2004, 10:30 PM");

	// 1-July-2004 @ 10:30 PM
	var d1 = Date.parse("2004-07-01T22:30:00");

	////////////////////
	// Relative Dates //
	////////////////////

	// Returns today's date. The string "today" is culture specific.
	var d1 = Date.parse("today");

	// Returns yesterday's date. The string "yesterday" is culture specific.
	var d1 = Date.parse("yesterday");

	// Returns the date of the next thursday.
	var d1 = Date.parse("Next thursday");

	// Returns the date of the most previous monday.
	var d1 = Date.parse("last monday");

	// Returns today's day + one year.
	var d1 = Date.parse("next year");

	///////////////
	// Date Math //
	///////////////

	// Today + 2 days
	var d1 = Date.parse("t+2");

	// Today + 2 days
	var d1 = Date.parse("today + 2 days");

	// Today + 3 months
	var d1 = Date.parse("t+3m");

	// Today - 1 year
	var d1 = Date.parse("today - 1 year");

	// Today - 1 year
	var d1 = Date.parse("t-1y"); 


	/////////////////////////////
	// Partial Dates and Times //
	/////////////////////////////

	// July 15th of this year.
	var d1 = Date.parse("July 15");

	// 15th day of current day and year.
	var d1 = Date.parse("15");

	// July 1st of current year at 10pm.
	var d1 = Date.parse("7/1 10pm");
	
* * @param {String} The string value to convert into a Date object [Required] * @return {Date} A Date object or null if the string cannot be converted into a Date. */ var parseUtils = { removeOrds: function (s) { ords = s.match(/\b(\d+)(?:st|nd|rd|th)\b/); // find ordinal matches s = ((ords && ords.length === 2) ? s.replace(ords[0], ords[1]) : s); return s; }, grammarParser: function (s) { var r = null; try { r = $D.Grammar.start.call({}, s.replace(/^\s*(\S*(\s+\S+)*)\s*$/, "$1")); } catch (e) { return null; } return ((r[1].length === 0) ? r[0] : null); }, nativeFallback: function(s) { var t; try { // ok we haven't parsed it, last ditch attempt with the built-in parser. t = Date._parse(s); return (t || t === 0) ? new Date(t) : null; } catch (e) { return null; } } }; function parse (s) { var d; if (!s) { return null; } if (s instanceof Date) { return s.clone(); } if (s.length >= 4 && s.charAt(0) !== "0" && s.charAt(0) !== "+"&& s.charAt(0) !== "-") { // ie: 2004 will pass, 0800 won't. // Start with specific formats d = $D.Parsing.ISO.parse(s) || $D.Parsing.Numeric.parse(s); } if (d instanceof Date && !isNaN(d.getTime())) { return d; } else { // find ordinal dates (1st, 3rd, 8th, etc and remove them as they cause parsing issues) s = $D.Parsing.Normalizer.parse(parseUtils.removeOrds(s)); d = parseUtils.grammarParser(s); if (d !== null) { return d; } else { return parseUtils.nativeFallback(s); } } } if (!$D._parse) { $D._parse = $D.parse; } $D.parse = parse; Date.getParseFunction = function (fx) { var fns = Date.Grammar.allformats(fx); return function (s) { var r = null; for (var i = 0; i < fns.length; i++) { try { r = fns[i].call({}, s); } catch (e) { continue; } if (r[1].length === 0) { return r[0]; } } return null; }; }; /** * Converts the specified string value into its JavaScript Date equivalent using the specified format {String} or formats {Array} and the CultureInfo specific format information. * The format of the string value must match one of the supplied formats exactly. * * Example

	// 15-Oct-2004
	var d1 = Date.parseExact("10/15/2004", "M/d/yyyy");

	// 15-Oct-2004
	var d1 = Date.parse("15-Oct-2004", "M-ddd-yyyy");

	// 15-Oct-2004
	var d1 = Date.parse("2004.10.15", "yyyy.MM.dd");

	// Multiple formats
	var d1 = Date.parseExact("10/15/2004", ["M/d/yyyy", "MMMM d, yyyy"]);
	
* * @param {String} The string value to convert into a Date object [Required]. * @param {Object} The expected format {String} or an array of expected formats {Array} of the date string [Required]. * @return {Date} A Date object or null if the string cannot be converted into a Date. */ $D.parseExact = function (s, fx) { return $D.getParseFunction(fx)(s); }; }()); (function () { var $D = Date, $P = $D.prototype, // $C = $D.CultureInfo, // not used atm p = function (s, l) { if (!l) { l = 2; } return ("000" + s).slice(l * -1); }; /** * Converts a PHP format string to Java/.NET format string. * A PHP format string can be used with ._format or .format. * A Java/.NET format string can be used with .toString(). * The .parseExact function will only accept a Java/.NET format string * * Example * var f1 = "%m/%d/%y" * var f2 = Date.normalizeFormat(f1); // "MM/dd/yy" * * new Date().format(f1); // "04/13/08" * new Date()._format(f1); // "04/13/08" * new Date().toString(f2); // "04/13/08" * * var date = Date.parseExact("04/13/08", f2); // Sun Apr 13 2008 * * @param {String} A PHP format string consisting of one or more format spcifiers. * @return {String} The PHP format converted to a Java/.NET format string. */ var normalizerSubstitutions = { "d" : "dd", "%d": "dd", "D" : "ddd", "%a": "ddd", "j" : "dddd", "l" : "dddd", "%A": "dddd", "S" : "S", "F" : "MMMM", "%B": "MMMM", "m" : "MM", "%m": "MM", "M" : "MMM", "%b": "MMM", "%h": "MMM", "n" : "M", "Y" : "yyyy", "%Y": "yyyy", "y" : "yy", "%y": "yy", "g" : "h", "%I": "h", "G" : "H", "h" : "hh", "H" : "HH", "%H": "HH", "i" : "mm", "%M": "mm", "s" : "ss", "%S": "ss", "%r": "hh:mm tt", "%R": "H:mm", "%T": "H:mm:ss", "%X": "t", "%x": "d", "%e": "d", "%D": "MM/dd/yy", "%n": "\\n", "%t": "\\t", "e" : "z", "T" : "z", "%z": "z", "%Z": "z", "Z" : "ZZ", "N" : "u", "w" : "u", "%w": "u", "W" : "W", "%V": "W" }; var normalizer = { substitutes: function (m) { return normalizerSubstitutions[m]; }, interpreted: function (m, x) { var y; switch (m) { case "%u": return x.getDay() + 1; case "z": return x.getOrdinalNumber(); case "%j": return p(x.getOrdinalNumber(), 3); case "%U": var d1 = x.clone().set({month: 0, day: 1}).addDays(-1).moveToDayOfWeek(0), d2 = x.clone().addDays(1).moveToDayOfWeek(0, -1); return (d2 < d1) ? "00" : p((d2.getOrdinalNumber() - d1.getOrdinalNumber()) / 7 + 1); case "%W": return p(x.getWeek()); case "t": return $D.getDaysInMonth(x.getFullYear(), x.getMonth()); case "o": case "%G": return x.setWeek(x.getISOWeek()).toString("yyyy"); case "%g": return x._format("%G").slice(-2); case "a": case "%p": return t("tt").toLowerCase(); case "A": return t("tt").toUpperCase(); case "u": return p(x.getMilliseconds(), 3); case "I": return (x.isDaylightSavingTime()) ? 1 : 0; case "O": return x.getUTCOffset(); case "P": y = x.getUTCOffset(); return y.substring(0, y.length - 2) + ":" + y.substring(y.length - 2); case "B": var now = new Date(); return Math.floor(((now.getHours() * 3600) + (now.getMinutes() * 60) + now.getSeconds() + (now.getTimezoneOffset() + 60) * 60) / 86.4); case "c": return x.toISOString().replace(/\"/g, ""); case "U": return $D.strtotime("now"); case "%c": return t("d") + " " + t("t"); case "%C": return Math.floor(x.getFullYear() / 100 + 1); } }, shouldOverrideDefaults: function (m) { switch (m) { case "%e": return true; default: return false; } }, parse: function (m, context) { var formatString, c = context || new Date(); formatString = normalizer.substitutes(m); if (formatString) { return formatString; } formatString = normalizer.interpreted(m, c); if (formatString) { return formatString; } else { return m; } } }; $D.normalizeFormat = function (format, context) { return format.replace(/(%|\\)?.|%%/g, function(t){ return normalizer.parse(t, context); }); }; /** * Format a local Unix timestamp according to locale settings * * Example: * Date.strftime("%m/%d/%y", new Date()); // "04/13/08" * Date.strftime("c", "2008-04-13T17:52:03Z"); // "04/13/08" * * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @param {Number|String} The number representing the number of seconds that have elapsed since January 1, 1970 (local time). * @return {String} A string representation of the current Date object. */ $D.strftime = function (format, time) { var d = Date.parse(time); return d._format(format); }; /** * Parse any textual datetime description into a Unix timestamp. * A Unix timestamp is the number of seconds that have elapsed since January 1, 1970 (midnight UTC/GMT). * * Example: * Date.strtotime("04/13/08"); // 1208044800 * Date.strtotime("1970-01-01T00:00:00Z"); // 0 * * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @param {Object} A string or date object. * @return {String} A string representation of the current Date object. */ $D.strtotime = function (time) { var d = $D.parse(time); return Math.round($D.UTC(d.getUTCFullYear(), d.getUTCMonth(), d.getUTCDate(), d.getUTCHours(), d.getUTCMinutes(), d.getUTCSeconds(), d.getUTCMilliseconds()) / 1000); }; /** * Converts the value of the current Date object to its equivalent string representation using a PHP/Unix style of date format specifiers. * Format Specifiers * Format Description Example * ------ --------------------------------------------------------------------------- ----------------------- * %a abbreviated weekday name according to the current localed "Mon" through "Sun" * %A full weekday name according to the current localed "Sunday" through "Saturday" * %b abbreviated month name according to the current localed "Jan" through "Dec" * %B full month name according to the current locale "January" through "December" * %c preferred date and time representation for the current locale "4/13/2008 12:33 PM" * %C century number (the year divided by 100 and truncated to an integer) "00" to "99" * %d day of the month as a decimal number "01" to "31" * %D same as %m/%d/%y "04/13/08" * %e day of the month as a decimal number, a single digit is preceded by a space "1" to "31" * %g like %G, but without the century "08" * %G The 4-digit year corresponding to the ISO week number (see %V). "2008" * This has the same format and value as %Y, except that if the ISO week number * belongs to the previous or next year, that year is used instead. * %h same as %b "Jan" through "Dec" * %H hour as a decimal number using a 24-hour clock. "00" to "23" * %I hour as a decimal number using a 12-hour clock. "01" to "12" * %j day of the year as a decimal number. "001" to "366" * %m month as a decimal number. "01" to "12" * %M minute as a decimal number. "00" to "59" * %n newline character "\n" * %p either "am" or "pm" according to the given time value, or the "am" or "pm" * corresponding strings for the current locale. * %r time in a.m. and p.m. notation "8:44 PM" * %R time in 24 hour notation "20:44" * %S second as a decimal number "00" to "59" * %t tab character "\t" * %T current time, equal to %H:%M:%S "12:49:11" * %u weekday as a decimal number ["1", "7"], with "1" representing Monday "1" to "7" * %U week number of the current year as a decimal number, starting with the "0" to ("52" or "53") * first Sunday as the first day of the first week * %V The ISO 8601:1988 week number of the current year as a decimal number, "00" to ("52" or "53") * range 01 to 53, where week 1 is the first week that has at least 4 days * in the current year, and with Monday as the first day of the week. * (Use %G or %g for the year component that corresponds to the week number * for the specified timestamp.) * %W week number of the current year as a decimal number, starting with the "00" to ("52" or "53") * first Monday as the first day of the first week * %w day of the week as a decimal, Sunday being "0" "0" to "6" * %x preferred date representation for the current locale without the time "4/13/2008" * %X preferred time representation for the current locale without the date "12:53:05" * %y year as a decimal number without a century "00" "99" * %Y year as a decimal number including the century "2008" * %Z time zone or name or abbreviation "UTC", "EST", "PST" * %z same as %Z * %% a literal "%" characters "%" * d Day of the month, 2 digits with leading zeros "01" to "31" * D A textual representation of a day, three letters "Mon" through "Sun" * j Day of the month without leading zeros "1" to "31" * l A full textual representation of the day of the week (lowercase "L") "Sunday" through "Saturday" * N ISO-8601 numeric representation of the day of the week (added in PHP 5.1.0) "1" (for Monday) through "7" (for Sunday) * S English ordinal suffix for the day of the month, 2 characters "st", "nd", "rd" or "th". Works well with j * w Numeric representation of the day of the week "0" (for Sunday) through "6" (for Saturday) * z The day of the year (starting from "0") "0" through "365" * W ISO-8601 week number of year, weeks starting on Monday "00" to ("52" or "53") * F A full textual representation of a month, such as January or March "January" through "December" * m Numeric representation of a month, with leading zeros "01" through "12" * M A short textual representation of a month, three letters "Jan" through "Dec" * n Numeric representation of a month, without leading zeros "1" through "12" * t Number of days in the given month "28" through "31" * L Whether it's a leap year "1" if it is a leap year, "0" otherwise * o ISO-8601 year number. This has the same value as Y, except that if the "2008" * ISO week number (W) belongs to the previous or next year, that year * is used instead. * Y A full numeric representation of a year, 4 digits "2008" * y A two digit representation of a year "08" * a Lowercase Ante meridiem and Post meridiem "am" or "pm" * A Uppercase Ante meridiem and Post meridiem "AM" or "PM" * B Swatch Internet time "000" through "999" * g 12-hour format of an hour without leading zeros "1" through "12" * G 24-hour format of an hour without leading zeros "0" through "23" * h 12-hour format of an hour with leading zeros "01" through "12" * H 24-hour format of an hour with leading zeros "00" through "23" * i Minutes with leading zeros "00" to "59" * s Seconds, with leading zeros "00" through "59" * u Milliseconds "54321" * e Timezone identifier "UTC", "EST", "PST" * I Whether or not the date is in daylight saving time (uppercase i) "1" if Daylight Saving Time, "0" otherwise * O Difference to Greenwich time (GMT) in hours "+0200", "-0600" * P Difference to Greenwich time (GMT) with colon between hours and minutes "+02:00", "-06:00" * T Timezone abbreviation "UTC", "EST", "PST" * Z Timezone offset in seconds. The offset for timezones west of UTC is "-43200" through "50400" * always negative, and for those east of UTC is always positive. * c ISO 8601 date "2004-02-12T15:19:21+00:00" * r RFC 2822 formatted date "Thu, 21 Dec 2000 16:01:07 +0200" * U Seconds since the Unix Epoch (January 1 1970 00:00:00 GMT) "0" * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @return {String} A string representation of the current Date object. */ var formatReplace = function (context) { return function (m) { var formatString, override = false; if (m.charAt(0) === "\\" || m.substring(0, 2) === "%%") { return m.replace("\\", "").replace("%%", "%"); } override = normalizer.shouldOverrideDefaults(m); formatString = $D.normalizeFormat(m, context); if (formatString) { return context.toString(formatString, override); } }; }; $P._format = function (format) { var formatter = formatReplace(this); if (!format) { return this._toString(); } else { return format.replace(/(%|\\)?.|%%/g, formatter); } }; if (!$P.format) { $P.format = $P._format; } }()); (function () { "use strict"; var gFn = function (attr) { return function () { return this[attr]; }; }; var sFn = function (attr) { return function (val) { this[attr] = val; return this; }; }; var attrs = ["years", "months", "days", "hours", "minutes", "seconds", "milliseconds"]; var addSetFuncs = function (context, attrs) { for (var i = 0; i < attrs.length ; i++) { var $a = attrs[i], $b = $a.slice(0, 1).toUpperCase() + $a.slice(1); context.prototype[$a] = 0; context.prototype["get" + $b] = gFn($a); context.prototype["set" + $b] = sFn($a); } }; /** * new TimeSpan(milliseconds); * new TimeSpan(days, hours, minutes, seconds); * new TimeSpan(days, hours, minutes, seconds, milliseconds); */ var TimeSpan = function (days, hours, minutes, seconds, milliseconds) { if (arguments.length === 1 && typeof days === "number") { var orient = (days < 0) ? -1 : +1; var millsLeft = Math.abs(days); this.setDays(Math.floor(millsLeft / 86400000) * orient); millsLeft = millsLeft % 86400000; this.setHours(Math.floor(millsLeft / 3600000) * orient); millsLeft = millsLeft % 3600000; this.setMinutes(Math.floor(millsLeft / 60000) * orient); millsLeft = millsLeft % 60000; this.setSeconds(Math.floor(millsLeft / 1000) * orient); millsLeft = millsLeft % 1000; this.setMilliseconds(millsLeft * orient); } else { this.set(days, hours, minutes, seconds, milliseconds); } this.getTotalMilliseconds = function () { return (this.getDays() * 86400000) + (this.getHours() * 3600000) + (this.getMinutes() * 60000) + (this.getSeconds() * 1000); }; this.compareTo = function (time) { var t1 = new Date(1970, 1, 1, this.getHours(), this.getMinutes(), this.getSeconds()), t2; if (time === null) { t2 = new Date(1970, 1, 1, 0, 0, 0); } else { t2 = new Date(1970, 1, 1, time.getHours(), time.getMinutes(), time.getSeconds()); } return (t1 < t2) ? -1 : (t1 > t2) ? 1 : 0; }; this.equals = function (time) { return (this.compareTo(time) === 0); }; this.add = function (time) { return (time === null) ? this : this.addSeconds(time.getTotalMilliseconds() / 1000); }; this.subtract = function (time) { return (time === null) ? this : this.addSeconds(-time.getTotalMilliseconds() / 1000); }; this.addDays = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 86400000)); }; this.addHours = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 3600000)); }; this.addMinutes = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 60000)); }; this.addSeconds = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 1000)); }; this.addMilliseconds = function (n) { return new TimeSpan(this.getTotalMilliseconds() + n); }; this.get12HourHour = function () { return (this.getHours() > 12) ? this.getHours() - 12 : (this.getHours() === 0) ? 12 : this.getHours(); }; this.getDesignator = function () { return (this.getHours() < 12) ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator; }; this.toString = function (format) { this._toString = function () { if (this.getDays() !== null && this.getDays() > 0) { return this.getDays() + "." + this.getHours() + ":" + this.p(this.getMinutes()) + ":" + this.p(this.getSeconds()); } else { return this.getHours() + ":" + this.p(this.getMinutes()) + ":" + this.p(this.getSeconds()); } }; this.p = function (s) { return (s.toString().length < 2) ? "0" + s : s; }; var me = this; return format ? format.replace(/dd?|HH?|hh?|mm?|ss?|tt?/g, function (format) { switch (format) { case "d": return me.getDays(); case "dd": return me.p(me.getDays()); case "H": return me.getHours(); case "HH": return me.p(me.getHours()); case "h": return me.get12HourHour(); case "hh": return me.p(me.get12HourHour()); case "m": return me.getMinutes(); case "mm": return me.p(me.getMinutes()); case "s": return me.getSeconds(); case "ss": return me.p(me.getSeconds()); case "t": return ((me.getHours() < 12) ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator).substring(0, 1); case "tt": return (me.getHours() < 12) ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator; } } ) : this._toString(); }; return this; }; addSetFuncs(TimeSpan, attrs.slice(2)); TimeSpan.prototype.set = function (days, hours, minutes, seconds, milliseconds){ this.setDays(days || this.getDays()); this.setHours(hours || this.getHours()); this.setMinutes(minutes || this.getMinutes()); this.setSeconds(seconds || this.getSeconds()); this.setMilliseconds(milliseconds || this.getMilliseconds()); }; /** * Gets the time of day for this date instances. * @return {TimeSpan} TimeSpan */ Date.prototype.getTimeOfDay = function () { return new TimeSpan(0, this.getHours(), this.getMinutes(), this.getSeconds(), this.getMilliseconds()); }; Date.TimeSpan = TimeSpan; if (typeof window !== "undefined" ) { // keeping API compatible for v1.x window.TimeSpan = TimeSpan; } }()); (function () { "use strict"; var attrs = ["years", "months", "days", "hours", "minutes", "seconds", "milliseconds"]; var gFn = function (attr) { return function () { return this[attr]; }; }; var sFn = function (attr) { return function (val) { this[attr] = val; return this; }; }; var addSetFuncs = function (context, attrs) { for (var i = 0; i < attrs.length ; i++) { var $a = attrs[i], $b = $a.slice(0, 1).toUpperCase() + $a.slice(1); context.prototype[$a] = 0; context.prototype["get" + $b] = gFn($a); context.prototype["set" + $b] = sFn($a); } }; var setMonthsAndYears = function (orient, d1, d2, context) { function inc() { d1.addMonths(-orient); context.months++; if (context.months === 12) { context.years++; context.months = 0; } } if (orient === +1) { while (d1 > d2) { inc(); } } else { while (d1 < d2) { inc(); } } context.months--; context.months *= orient; context.years *= orient; }; var adjustForDST = function(orient, startDate, endDate) { var hasDSTMismatch = (false === (startDate.isDaylightSavingTime() === endDate.isDaylightSavingTime())); if (hasDSTMismatch && orient === 1) { startDate.addHours(-1); } else if (hasDSTMismatch) { startDate.addHours(1); } }; /** * TimePeriod(startDate, endDate); * TimePeriod(years, months, days, hours, minutes, seconds, milliseconds); */ var TimePeriod = function (years, months, days, hours, minutes, seconds, milliseconds) { if (arguments.length === 7) { this.set(years, months, days, hours, minutes, seconds, milliseconds); } else if (arguments.length === 2 && arguments[0] instanceof Date && arguments[1] instanceof Date) { var startDate = arguments[0].clone(); var endDate = arguments[1].clone(); var orient = (startDate > endDate) ? +1 : -1; this.dates = { start: arguments[0].clone(), end: arguments[1].clone() }; setMonthsAndYears(orient, startDate, endDate, this); adjustForDST(orient, startDate, endDate); // // TODO - adjust for DST var diff = endDate - startDate; if (diff !== 0) { var ts = new TimeSpan(diff); this.set(this.years, this.months, ts.getDays(), ts.getHours(), ts.getMinutes(), ts.getSeconds(), ts.getMilliseconds()); } } return this; }; // create all the set functions. addSetFuncs(TimePeriod, attrs); TimePeriod.prototype.set = function (years, months, days, hours, minutes, seconds, milliseconds){ this.setYears(years || this.getYears()); this.setMonths(months || this.getMonths()); this.setDays(days || this.getDays()); this.setHours(hours || this.getHours()); this.setMinutes(minutes || this.getMinutes()); this.setSeconds(seconds || this.getSeconds()); this.setMilliseconds(milliseconds || this.getMilliseconds()); }; Date.TimePeriod = TimePeriod; if (typeof window !== "undefined") { // keeping API compatible for v1.x window.TimePeriod = TimePeriod; } }()); ================================================ FILE: build/date-cy-GB.js ================================================ /** * @overview datejs * @version 1.0.0-rc3 * @author Gregory Wild-Smith * @copyright 2015 Gregory Wild-Smith * @license MIT * @homepage https://github.com/abritinthebay/datejs */ /* * DateJS Culture String File * Country Code: cy-GB * Name: Welsh (United Kingdom) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["cy-GB"] = { "name": "cy-GB", "englishName": "Welsh (United Kingdom)", "nativeName": "Cymraeg (y Deyrnas Unedig)", "Sunday": "Dydd Sul", "Monday": "Dydd Llun", "Tuesday": "Dydd Mawrth", "Wednesday": "Dydd Mercher", "Thursday": "Dydd Iau", "Friday": "Dydd Gwener", "Saturday": "Dydd Sadwrn", "Sun": "Sul", "Mon": "Llun", "Tue": "Maw", "Wed": "Mer", "Thu": "Iau", "Fri": "Gwe", "Sat": "Sad", "Su": "Sul", "Mo": "Llun", "Tu": "Maw", "We": "Mer", "Th": "Iau", "Fr": "Gwe", "Sa": "Sad", "S_Sun_Initial": "S", "M_Mon_Initial": "L", "T_Tue_Initial": "M", "W_Wed_Initial": "M", "T_Thu_Initial": "I", "F_Fri_Initial": "G", "S_Sat_Initial": "S", "January": "Ionawr", "February": "Chwefror", "March": "Mawrth", "April": "Ebrill", "May": "Mai", "June": "Mehefin", "July": "Gorffennaf", "August": "Awst", "September": "Medi", "October": "Hydref", "November": "Tachwedd", "December": "Rhagfyr", "Jan_Abbr": "Ion", "Feb_Abbr": "Chwe", "Mar_Abbr": "Maw", "Apr_Abbr": "Ebr", "May_Abbr": "Mai", "Jun_Abbr": "Meh", "Jul_Abbr": "Gor", "Aug_Abbr": "Aws", "Sep_Abbr": "Med", "Oct_Abbr": "Hyd", "Nov_Abbr": "Tach", "Dec_Abbr": "Rhag", "AM": "a.m.", "PM": "p.m.", "firstDayOfWeek": 1, "twoDigitYearMax": 2029, "mdy": "dmy", "M/d/yyyy": "dd/MM/yyyy", "dddd, MMMM dd, yyyy": "dd MMMM yyyy", "h:mm tt": "HH:mm:ss", "h:mm:ss tt": "HH:mm:ss", "dddd, MMMM dd, yyyy h:mm:ss tt": "dd MMMM yyyy HH:mm:ss", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "MMMM dd", "MMMM, yyyy": "MMMM yyyy", "/jan(uary)?/": "ion(awr)?", "/feb(ruary)?/": "chwe(fror)?", "/mar(ch)?/": "maw(rth)?", "/apr(il)?/": "ebr(ill)?", "/may/": "mai", "/jun(e)?/": "meh(efin)?", "/jul(y)?/": "gor(ffennaf)?", "/aug(ust)?/": "aws(t)?", "/sep(t(ember)?)?/": "med(i)?", "/oct(ober)?/": "hyd(ref)?", "/nov(ember)?/": "tach(wedd)?", "/dec(ember)?/": "rhag(fyr)?", "/^su(n(day)?)?/": "^dydd sul", "/^mo(n(day)?)?/": "^dydd llun", "/^tu(e(s(day)?)?)?/": "^dydd mawrth", "/^we(d(nesday)?)?/": "^dydd mercher", "/^th(u(r(s(day)?)?)?)?/": "^dydd iau", "/^fr(i(day)?)?/": "^dydd gwener", "/^sa(t(urday)?)?/": "^dydd sadwrn", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "cy-GB"; /** * @overview datejs * @version 1.0.0-rc3 * @author Gregory Wild-Smith * @copyright 2015 Gregory Wild-Smith * @license MIT * @homepage https://github.com/abritinthebay/datejs */(function () { var $D = Date; var lang = Date.CultureStrings ? Date.CultureStrings.lang : null; var loggedKeys = {}; // for debug purposes. var getText = { getFromKey: function (key, countryCode) { var output; if (Date.CultureStrings && Date.CultureStrings[countryCode] && Date.CultureStrings[countryCode][key]) { output = Date.CultureStrings[countryCode][key]; } else { output = getText.buildFromDefault(key); } if (key.charAt(0) === "/") { // Assume it's a regex output = getText.buildFromRegex(key, countryCode); } return output; }, getFromObjectValues: function (obj, countryCode) { var key, output = {}; for(key in obj) { if (obj.hasOwnProperty(key)) { output[key] = getText.getFromKey(obj[key], countryCode); } } return output; }, getFromObjectKeys: function (obj, countryCode) { var key, output = {}; for(key in obj) { if (obj.hasOwnProperty(key)) { output[getText.getFromKey(key, countryCode)] = obj[key]; } } return output; }, getFromArray: function (arr, countryCode) { var output = []; for (var i=0; i < arr.length; i++){ if (i in arr) { output[i] = getText.getFromKey(arr[i], countryCode); } } return output; }, buildFromDefault: function (key) { var output, length, split, last; switch(key) { case "name": output = "en-US"; break; case "englishName": output = "English (United States)"; break; case "nativeName": output = "English (United States)"; break; case "twoDigitYearMax": output = 2049; break; case "firstDayOfWeek": output = 0; break; default: output = key; split = key.split("_"); length = split.length; if (length > 1 && key.charAt(0) !== "/") { // if the key isn't a regex and it has a split. last = split[(length - 1)].toLowerCase(); if (last === "initial" || last === "abbr") { output = split[0]; } } break; } return output; }, buildFromRegex: function (key, countryCode) { var output; if (Date.CultureStrings && Date.CultureStrings[countryCode] && Date.CultureStrings[countryCode][key]) { output = new RegExp(Date.CultureStrings[countryCode][key], "i"); } else { output = new RegExp(key.replace(new RegExp("/", "g"),""), "i"); } return output; } }; var shallowMerge = function (obj1, obj2) { for (var attrname in obj2) { if (obj2.hasOwnProperty(attrname)) { obj1[attrname] = obj2[attrname]; } } }; var __ = function (key, language) { var countryCode = (language) ? language : lang; loggedKeys[key] = key; if (typeof key === "object") { if (key instanceof Array) { return getText.getFromArray(key, countryCode); } else { return getText.getFromObjectKeys(key, countryCode); } } else { return getText.getFromKey(key, countryCode); } }; var loadI18nScript = function (code) { // paatterned after jQuery's getScript. var url = Date.Config.i18n + code + ".js"; var head = document.getElementsByTagName("head")[0] || document.documentElement; var script = document.createElement("script"); script.src = url; var completed = false; var events = { done: function (){} // placeholder function }; // Attach handlers for all browsers script.onload = script.onreadystatechange = function() { if ( !completed && (!this.readyState || this.readyState === "loaded" || this.readyState === "complete") ) { events.done(); head.removeChild(script); } }; setTimeout(function() { head.insertBefore(script, head.firstChild); }, 0); // allows return to execute first return { done: function (cb) { events.done = function() { if (cb) { setTimeout(cb,0); } }; } }; }; var buildInfo = { buildFromMethodHash: function (obj) { var key; for(key in obj) { if (obj.hasOwnProperty(key)) { obj[key] = buildInfo[obj[key]](); } } return obj; }, timeZoneDST: function () { var DST = { "CHADT": "+1345", "NZDT": "+1300", "AEDT": "+1100", "ACDT": "+1030", "AZST": "+0500", "IRDT": "+0430", "EEST": "+0300", "CEST": "+0200", "BST": "+0100", "PMDT": "-0200", "ADT": "-0300", "NDT": "-0230", "EDT": "-0400", "CDT": "-0500", "MDT": "-0600", "PDT": "-0700", "AKDT": "-0800", "HADT": "-0900" }; return __(DST); }, timeZoneStandard: function () { var standard = { "LINT": "+1400", "TOT": "+1300", "CHAST": "+1245", "NZST": "+1200", "NFT": "+1130", "SBT": "+1100", "AEST": "+1000", "ACST": "+0930", "JST": "+0900", "CWST": "+0845", "CT": "+0800", "ICT": "+0700", "MMT": "+0630", "BST": "+0600", "NPT": "+0545", "IST": "+0530", "PKT": "+0500", "AFT": "+0430", "MSK": "+0400", "IRST": "+0330", "FET": "+0300", "EET": "+0200", "CET": "+0100", "GMT": "+0000", "UTC": "+0000", "CVT": "-0100", "GST": "-0200", "BRT": "-0300", "NST": "-0330", "AST": "-0400", "EST": "-0500", "CST": "-0600", "MST": "-0700", "PST": "-0800", "AKST": "-0900", "MIT": "-0930", "HST": "-1000", "SST": "-1100", "BIT": "-1200" }; return __(standard); }, timeZones: function (data) { var zone; data.timezones = []; for (zone in data.abbreviatedTimeZoneStandard) { if (data.abbreviatedTimeZoneStandard.hasOwnProperty(zone)) { data.timezones.push({ name: zone, offset: data.abbreviatedTimeZoneStandard[zone]}); } } for (zone in data.abbreviatedTimeZoneDST) { if (data.abbreviatedTimeZoneDST.hasOwnProperty(zone)) { data.timezones.push({ name: zone, offset: data.abbreviatedTimeZoneDST[zone], dst: true}); } } return data.timezones; }, days: function () { return __(["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"]); }, dayAbbr: function () { return __(["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"]); }, dayShortNames: function () { return __(["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"]); }, dayFirstLetters: function () { return __(["S_Sun_Initial", "M_Mon_Initial", "T_Tues_Initial", "W_Wed_Initial", "T_Thu_Initial", "F_Fri_Initial", "S_Sat_Initial"]); }, months: function () { return __(["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"]); }, monthAbbr: function () { return __(["Jan_Abbr", "Feb_Abbr", "Mar_Abbr", "Apr_Abbr", "May_Abbr", "Jun_Abbr", "Jul_Abbr", "Aug_Abbr", "Sep_Abbr", "Oct_Abbr", "Nov_Abbr", "Dec_Abbr"]); }, formatPatterns: function () { return getText.getFromObjectValues({ shortDate: "M/d/yyyy", longDate: "dddd, MMMM dd, yyyy", shortTime: "h:mm tt", longTime: "h:mm:ss tt", fullDateTime: "dddd, MMMM dd, yyyy h:mm:ss tt", sortableDateTime: "yyyy-MM-ddTHH:mm:ss", universalSortableDateTime: "yyyy-MM-dd HH:mm:ssZ", rfc1123: "ddd, dd MMM yyyy HH:mm:ss", monthDay: "MMMM dd", yearMonth: "MMMM, yyyy" }, Date.i18n.currentLanguage()); }, regex: function () { return getText.getFromObjectValues({ inTheMorning: "/( in the )(morn(ing)?)\\b/", thisMorning: "/(this )(morn(ing)?)\\b/", amThisMorning: "/(\b\\d(am)? )(this )(morn(ing)?)/", inTheEvening: "/( in the )(even(ing)?)\\b/", thisEvening: "/(this )(even(ing)?)\\b/", pmThisEvening: "/(\b\\d(pm)? )(this )(even(ing)?)/", jan: "/jan(uary)?/", feb: "/feb(ruary)?/", mar: "/mar(ch)?/", apr: "/apr(il)?/", may: "/may/", jun: "/jun(e)?/", jul: "/jul(y)?/", aug: "/aug(ust)?/", sep: "/sep(t(ember)?)?/", oct: "/oct(ober)?/", nov: "/nov(ember)?/", dec: "/dec(ember)?/", sun: "/^su(n(day)?)?/", mon: "/^mo(n(day)?)?/", tue: "/^tu(e(s(day)?)?)?/", wed: "/^we(d(nesday)?)?/", thu: "/^th(u(r(s(day)?)?)?)?/", fri: "/fr(i(day)?)?/", sat: "/^sa(t(urday)?)?/", future: "/^next/", past: "/^last|past|prev(ious)?/", add: "/^(\\+|aft(er)?|from|hence)/", subtract: "/^(\\-|bef(ore)?|ago)/", yesterday: "/^yes(terday)?/", today: "/^t(od(ay)?)?/", tomorrow: "/^tom(orrow)?/", now: "/^n(ow)?/", millisecond: "/^ms|milli(second)?s?/", second: "/^sec(ond)?s?/", minute: "/^mn|min(ute)?s?/", hour: "/^h(our)?s?/", week: "/^w(eek)?s?/", month: "/^m(onth)?s?/", day: "/^d(ay)?s?/", year: "/^y(ear)?s?/", shortMeridian: "/^(a|p)/", longMeridian: "/^(a\\.?m?\\.?|p\\.?m?\\.?)/", timezone: "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/", ordinalSuffix: "/^\\s*(st|nd|rd|th)/", timeContext: "/^\\s*(\\:|a(?!u|p)|p)/" }, Date.i18n.currentLanguage()); } }; var CultureInfo = function () { var info = getText.getFromObjectValues({ name: "name", englishName: "englishName", nativeName: "nativeName", amDesignator: "AM", pmDesignator: "PM", firstDayOfWeek: "firstDayOfWeek", twoDigitYearMax: "twoDigitYearMax", dateElementOrder: "mdy" }, Date.i18n.currentLanguage()); var constructedInfo = buildInfo.buildFromMethodHash({ dayNames: "days", abbreviatedDayNames: "dayAbbr", shortestDayNames: "dayShortNames", firstLetterDayNames: "dayFirstLetters", monthNames: "months", abbreviatedMonthNames: "monthAbbr", formatPatterns: "formatPatterns", regexPatterns: "regex", abbreviatedTimeZoneDST: "timeZoneDST", abbreviatedTimeZoneStandard: "timeZoneStandard" }); shallowMerge(info, constructedInfo); buildInfo.timeZones(info); return info; }; $D.i18n = { __: function (key, lang) { return __(key, lang); }, currentLanguage: function () { return lang || "en-US"; }, setLanguage: function (code, force, cb) { var async = false; if (force || code === "en-US" || (!!Date.CultureStrings && !!Date.CultureStrings[code])) { lang = code; Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings.lang = code; Date.CultureInfo = new CultureInfo(); } else { if (!(!!Date.CultureStrings && !!Date.CultureStrings[code])) { if (typeof exports !== "undefined" && this.exports !== exports) { // we're in a Node enviroment, load it using require try { require("../i18n/" + code + ".js"); lang = code; Date.CultureStrings.lang = code; Date.CultureInfo = new CultureInfo(); } catch (e) { // var str = "The language for '" + code + "' could not be loaded by Node. It likely does not exist."; throw new Error("The DateJS IETF language tag '" + code + "' could not be loaded by Node. It likely does not exist."); } } else if (Date.Config && Date.Config.i18n) { // we know the location of the files, so lets load them async = true; loadI18nScript(code).done(function(){ lang = code; Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings.lang = code; Date.CultureInfo = new CultureInfo(); $D.Parsing.Normalizer.buildReplaceData(); // because this is async if ($D.Grammar) { $D.Grammar.buildGrammarFormats(); // so we can parse those strings... } if (cb) { setTimeout(cb,0); } }); } else { Date.console.error("The DateJS IETF language tag '" + code + "' is not available and has not been loaded."); return false; } } } $D.Parsing.Normalizer.buildReplaceData(); // rebuild normalizer strings if ($D.Grammar) { $D.Grammar.buildGrammarFormats(); // so we can parse those strings... } if (!async && cb) { setTimeout(cb,0); } }, getLoggedKeys: function () { return loggedKeys; }, updateCultureInfo: function () { Date.CultureInfo = new CultureInfo(); } }; $D.i18n.updateCultureInfo(); // run automatically }()); (function () { var $D = Date, $P = $D.prototype, p = function (s, l) { if (!l) { l = 2; } return ("000" + s).slice(l * -1); }; if (typeof window !== "undefined" && typeof window.console !== "undefined" && typeof window.console.log !== "undefined") { $D.console = console; // used only to raise non-critical errors if available } else { // set mock so we don't give errors. $D.console = { log: function(){}, error: function(){} }; } $D.Config = $D.Config || {}; $D.initOverloads = function() { /** * Overload of Date.now. Allows an alternate call for Date.now where it returns the * current Date as an object rather than just milliseconds since the Unix Epoch. * * Also provides an implementation of now() for browsers (IE<9) that don't have it. * * Backwards compatible so with work with either: * Date.now() [returns ms] * or * Date.now(true) [returns Date] */ if (!$D.now) { $D._now = function now() { return new Date().getTime(); }; } else if (!$D._now) { $D._now = $D.now; } $D.now = function (returnObj) { if (returnObj) { return $D.present(); } else { return $D._now(); } }; if ( !$P.toISOString ) { $P.toISOString = function() { return this.getUTCFullYear() + "-" + p(this.getUTCMonth() + 1) + "-" + p(this.getUTCDate()) + "T" + p(this.getUTCHours()) + ":" + p(this.getUTCMinutes()) + ":" + p(this.getUTCSeconds()) + "." + String( (this.getUTCMilliseconds()/1000).toFixed(3)).slice(2, 5) + "Z"; }; } // private if ( $P._toString === undefined ){ $P._toString = $P.toString; } }; $D.initOverloads(); /** * Gets a date that is set to the current date. The time is set to the start of the day (00:00 or 12:00 AM). * @return {Date} The current date. */ $D.today = function () { return new Date().clearTime(); }; /** * Gets a date that is set to the current date and time (same as new Date, but chainable) * @return {Date} The current date. */ $D.present = function () { return new Date(); }; /** * Compares the first date to the second date and returns an number indication of their relative values. * @param {Date} First Date object to compare [Required]. * @param {Date} Second Date object to compare to [Required]. * @return {Number} -1 = date1 is lessthan date2. 0 = values are equal. 1 = date1 is greaterthan date2. */ $D.compare = function (date1, date2) { if (isNaN(date1) || isNaN(date2)) { throw new Error(date1 + " - " + date2); } else if (date1 instanceof Date && date2 instanceof Date) { return (date1 < date2) ? -1 : (date1 > date2) ? 1 : 0; } else { throw new TypeError(date1 + " - " + date2); } }; /** * Compares the first Date object to the second Date object and returns true if they are equal. * @param {Date} First Date object to compare [Required] * @param {Date} Second Date object to compare to [Required] * @return {Boolean} true if dates are equal. false if they are not equal. */ $D.equals = function (date1, date2) { return (date1.compareTo(date2) === 0); }; /** * Gets the language appropriate day name when given the day number(0-6) * eg - 0 == Sunday * @return {String} The day name */ $D.getDayName = function (n) { return Date.CultureInfo.dayNames[n]; }; /** * Gets the day number (0-6) if given a CultureInfo specific string which is a valid dayName, abbreviatedDayName or shortestDayName (two char). * @param {String} The name of the day (eg. "Monday, "Mon", "tuesday", "tue", "We", "we"). * @return {Number} The day number */ $D.getDayNumberFromName = function (name) { var n = Date.CultureInfo.dayNames, m = Date.CultureInfo.abbreviatedDayNames, o = Date.CultureInfo.shortestDayNames, s = name.toLowerCase(); for (var i = 0; i < n.length; i++) { if (n[i].toLowerCase() === s || m[i].toLowerCase() === s || o[i].toLowerCase() === s) { return i; } } return -1; }; /** * Gets the month number (0-11) if given a Culture Info specific string which is a valid monthName or abbreviatedMonthName. * @param {String} The name of the month (eg. "February, "Feb", "october", "oct"). * @return {Number} The day number */ $D.getMonthNumberFromName = function (name) { var n = Date.CultureInfo.monthNames, m = Date.CultureInfo.abbreviatedMonthNames, s = name.toLowerCase(); for (var i = 0; i < n.length; i++) { if (n[i].toLowerCase() === s || m[i].toLowerCase() === s) { return i; } } return -1; }; /** * Gets the language appropriate month name when given the month number(0-11) * eg - 0 == January * @return {String} The month name */ $D.getMonthName = function (n) { return Date.CultureInfo.monthNames[n]; }; /** * Determines if the current date instance is within a LeapYear. * @param {Number} The year. * @return {Boolean} true if date is within a LeapYear, otherwise false. */ $D.isLeapYear = function (year) { return ((year % 4 === 0 && year % 100 !== 0) || year % 400 === 0); }; /** * Gets the number of days in the month, given a year and month value. Automatically corrects for LeapYear. * @param {Number} The year. * @param {Number} The month (0-11). * @return {Number} The number of days in the month. */ $D.getDaysInMonth = function (year, month) { if (!month && $D.validateMonth(year)) { month = year; year = Date.today().getFullYear(); } return [31, ($D.isLeapYear(year) ? 29 : 28), 31, 30, 31, 30, 31, 31, 30, 31, 30, 31][month]; }; $P.getDaysInMonth = function () { return $D.getDaysInMonth(this.getFullYear(), this.getMonth()); }; $D.getTimezoneAbbreviation = function (offset, dst) { var p, n = (dst || false) ? Date.CultureInfo.abbreviatedTimeZoneDST : Date.CultureInfo.abbreviatedTimeZoneStandard; for (p in n) { if (n.hasOwnProperty(p)) { if (n[p] === offset) { return p; } } } return null; }; $D.getTimezoneOffset = function (name, dst) { var i, a =[], z = Date.CultureInfo.timezones; if (!name) { name = (new Date()).getTimezone();} for (i = 0; i < z.length; i++) { if (z[i].name === name.toUpperCase()) { a.push(i); } } if (!z[a[0]]) { return null; } if (a.length === 1 || !dst) { return z[a[0]].offset; } else { for (i=0; i < a.length; i++) { if (z[a[i]].dst) { return z[a[i]].offset; } } } }; $D.getQuarter = function (d) { d = d || new Date(); // If no date supplied, use today var q = [1,2,3,4]; return q[Math.floor(d.getMonth() / 3)]; // ~~~ is a bitwise op. Faster than Math.floor }; $D.getDaysLeftInQuarter = function (d) { d = d || new Date(); var qEnd = new Date(d); qEnd.setMonth(qEnd.getMonth() + 3 - qEnd.getMonth() % 3, 0); return Math.floor((qEnd - d) / 8.64e7); }; // private var validate = function (n, min, max, name) { name = name ? name : "Object"; if (typeof n === "undefined") { return false; } else if (typeof n !== "number") { throw new TypeError(n + " is not a Number."); } else if (n < min || n > max) { // As failing validation is *not* an exceptional circumstance // lets not throw a RangeError Exception here. // It's semantically correct but it's not sensible. return false; } return true; }; /** * Validates the number is within an acceptable range for milliseconds [0-999]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateMillisecond = function (value) { return validate(value, 0, 999, "millisecond"); }; /** * Validates the number is within an acceptable range for seconds [0-59]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateSecond = function (value) { return validate(value, 0, 59, "second"); }; /** * Validates the number is within an acceptable range for minutes [0-59]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateMinute = function (value) { return validate(value, 0, 59, "minute"); }; /** * Validates the number is within an acceptable range for hours [0-23]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateHour = function (value) { return validate(value, 0, 23, "hour"); }; /** * Validates the number is within an acceptable range for the days in a month [0-MaxDaysInMonth]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateDay = function (value, year, month) { if (year === undefined || year === null || month === undefined || month === null) { return false;} return validate(value, 1, $D.getDaysInMonth(year, month), "day"); }; /** * Validates the number is within an acceptable range for months [0-11]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateWeek = function (value) { return validate(value, 0, 53, "week"); }; /** * Validates the number is within an acceptable range for months [0-11]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateMonth = function (value) { return validate(value, 0, 11, "month"); }; /** * Validates the number is within an acceptable range for years. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateYear = function (value) { /** * Per ECMAScript spec the range of times supported by Date objects is * exactly -100,000,000 days to +100,000,000 days measured relative to * midnight at the beginning of 01 January, 1970 UTC. * This gives a range of 8,640,000,000,000,000 milliseconds to either * side of 01 January, 1970 UTC. * * Earliest possible date: Tue, 20 Apr 271,822 B.C. 00:00:00 UTC * Latest possible date: Sat, 13 Sep 275,760 00:00:00 UTC */ return validate(value, -271822, 275760, "year"); }; $D.validateTimezone = function(value) { var timezones = {"ACDT":1,"ACST":1,"ACT":1,"ADT":1,"AEDT":1,"AEST":1,"AFT":1,"AKDT":1,"AKST":1,"AMST":1,"AMT":1,"ART":1,"AST":1,"AWDT":1,"AWST":1,"AZOST":1,"AZT":1,"BDT":1,"BIOT":1,"BIT":1,"BOT":1,"BRT":1,"BST":1,"BTT":1,"CAT":1,"CCT":1,"CDT":1,"CEDT":1,"CEST":1,"CET":1,"CHADT":1,"CHAST":1,"CHOT":1,"ChST":1,"CHUT":1,"CIST":1,"CIT":1,"CKT":1,"CLST":1,"CLT":1,"COST":1,"COT":1,"CST":1,"CT":1,"CVT":1,"CWST":1,"CXT":1,"DAVT":1,"DDUT":1,"DFT":1,"EASST":1,"EAST":1,"EAT":1,"ECT":1,"EDT":1,"EEDT":1,"EEST":1,"EET":1,"EGST":1,"EGT":1,"EIT":1,"EST":1,"FET":1,"FJT":1,"FKST":1,"FKT":1,"FNT":1,"GALT":1,"GAMT":1,"GET":1,"GFT":1,"GILT":1,"GIT":1,"GMT":1,"GST":1,"GYT":1,"HADT":1,"HAEC":1,"HAST":1,"HKT":1,"HMT":1,"HOVT":1,"HST":1,"ICT":1,"IDT":1,"IOT":1,"IRDT":1,"IRKT":1,"IRST":1,"IST":1,"JST":1,"KGT":1,"KOST":1,"KRAT":1,"KST":1,"LHST":1,"LINT":1,"MAGT":1,"MART":1,"MAWT":1,"MDT":1,"MET":1,"MEST":1,"MHT":1,"MIST":1,"MIT":1,"MMT":1,"MSK":1,"MST":1,"MUT":1,"MVT":1,"MYT":1,"NCT":1,"NDT":1,"NFT":1,"NPT":1,"NST":1,"NT":1,"NUT":1,"NZDT":1,"NZST":1,"OMST":1,"ORAT":1,"PDT":1,"PET":1,"PETT":1,"PGT":1,"PHOT":1,"PHT":1,"PKT":1,"PMDT":1,"PMST":1,"PONT":1,"PST":1,"PYST":1,"PYT":1,"RET":1,"ROTT":1,"SAKT":1,"SAMT":1,"SAST":1,"SBT":1,"SCT":1,"SGT":1,"SLST":1,"SRT":1,"SST":1,"SYOT":1,"TAHT":1,"THA":1,"TFT":1,"TJT":1,"TKT":1,"TLT":1,"TMT":1,"TOT":1,"TVT":1,"UCT":1,"ULAT":1,"UTC":1,"UYST":1,"UYT":1,"UZT":1,"VET":1,"VLAT":1,"VOLT":1,"VOST":1,"VUT":1,"WAKT":1,"WAST":1,"WAT":1,"WEDT":1,"WEST":1,"WET":1,"WST":1,"YAKT":1,"YEKT":1,"Z":1}; return (timezones[value] === 1); }; $D.validateTimezoneOffset= function(value) { // timezones go from +14hrs to -12hrs, the +X hours are negative offsets. return (value > -841 && value < 721); }; }()); (function () { var $D = Date, $P = $D.prototype, p = function (s, l) { if (!l) { l = 2; } return ("000" + s).slice(l * -1); }; var validateConfigObject = function (obj) { var result = {}, self = this, prop, testFunc; testFunc = function (prop, func, value) { if (prop === "day") { var month = (obj.month !== undefined) ? obj.month : self.getMonth(); var year = (obj.year !== undefined) ? obj.year : self.getFullYear(); return $D[func](value, year, month); } else { return $D[func](value); } }; for (prop in obj) { if (Object.prototype.hasOwnProperty.call(obj, prop)) { var func = "validate" + prop.charAt(0).toUpperCase() + prop.slice(1); if ($D[func] && obj[prop] !== null && testFunc(prop, func, obj[prop])) { result[prop] = obj[prop]; } } } return result; }; /** * Resets the time of this Date object to 12:00 AM (00:00), which is the start of the day. * @param {Boolean} .clone() this date instance before clearing Time * @return {Date} this */ $P.clearTime = function () { this.setHours(0); this.setMinutes(0); this.setSeconds(0); this.setMilliseconds(0); return this; }; /** * Resets the time of this Date object to the current time ('now'). * @return {Date} this */ $P.setTimeToNow = function () { var n = new Date(); this.setHours(n.getHours()); this.setMinutes(n.getMinutes()); this.setSeconds(n.getSeconds()); this.setMilliseconds(n.getMilliseconds()); return this; }; /** * Returns a new Date object that is an exact date and time copy of the original instance. * @return {Date} A new Date instance */ $P.clone = function () { return new Date(this.getTime()); }; /** * Compares this instance to a Date object and returns an number indication of their relative values. * @param {Date} Date object to compare [Required] * @return {Number} -1 = this is lessthan date. 0 = values are equal. 1 = this is greaterthan date. */ $P.compareTo = function (date) { return Date.compare(this, date); }; /** * Compares this instance to another Date object and returns true if they are equal. * @param {Date} Date object to compare. If no date to compare, new Date() [now] is used. * @return {Boolean} true if dates are equal. false if they are not equal. */ $P.equals = function (date) { return Date.equals(this, (date !== undefined ? date : new Date())); }; /** * Determines if this instance is between a range of two dates or equal to either the start or end dates. * @param {Date} Start of range [Required] * @param {Date} End of range [Required] * @return {Boolean} true is this is between or equal to the start and end dates, else false */ $P.between = function (start, end) { return this.getTime() >= start.getTime() && this.getTime() <= end.getTime(); }; /** * Determines if this date occurs after the date to compare to. * @param {Date} Date object to compare. If no date to compare, new Date() ("now") is used. * @return {Boolean} true if this date instance is greater than the date to compare to (or "now"), otherwise false. */ $P.isAfter = function (date) { return this.compareTo(date || new Date()) === 1; }; /** * Determines if this date occurs before the date to compare to. * @param {Date} Date object to compare. If no date to compare, new Date() ("now") is used. * @return {Boolean} true if this date instance is less than the date to compare to (or "now"). */ $P.isBefore = function (date) { return (this.compareTo(date || new Date()) === -1); }; /** * Determines if the current Date instance occurs today. * @return {Boolean} true if this date instance is 'today', otherwise false. */ /** * Determines if the current Date instance occurs on the same Date as the supplied 'date'. * If no 'date' to compare to is provided, the current Date instance is compared to 'today'. * @param {date} Date object to compare. If no date to compare, the current Date ("now") is used. * @return {Boolean} true if this Date instance occurs on the same Day as the supplied 'date'. */ $P.isToday = $P.isSameDay = function (date) { return this.clone().clearTime().equals((date || new Date()).clone().clearTime()); }; /** * Adds the specified number of milliseconds to this instance. * @param {Number} The number of milliseconds to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addMilliseconds = function (value) { if (!value) { return this; } this.setTime(this.getTime() + value * 1); return this; }; /** * Adds the specified number of seconds to this instance. * @param {Number} The number of seconds to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addSeconds = function (value) { if (!value) { return this; } return this.addMilliseconds(value * 1000); }; /** * Adds the specified number of seconds to this instance. * @param {Number} The number of seconds to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addMinutes = function (value) { if (!value) { return this; } return this.addMilliseconds(value * 60000); // 60*1000 }; /** * Adds the specified number of hours to this instance. * @param {Number} The number of hours to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addHours = function (value) { if (!value) { return this; } return this.addMilliseconds(value * 3600000); // 60*60*1000 }; /** * Adds the specified number of days to this instance. * @param {Number} The number of days to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addDays = function (value) { if (!value) { return this; } this.setDate(this.getDate() + value * 1); return this; }; /** * Adds the specified number of weekdays (ie - not sat or sun) to this instance. * @param {Number} The number of days to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addWeekdays = function (value) { if (!value) { return this; } var day = this.getDay(); var weeks = (Math.ceil(Math.abs(value)/7)); if (day === 0 || day === 6) { if (value > 0) { this.next().monday(); this.addDays(-1); day = this.getDay(); } } if (value < 0) { while (value < 0) { this.addDays(-1); day = this.getDay(); if (day !== 0 && day !== 6) { value++; } } return this; } else if (value > 5 || (6-day) <= value) { value = value + (weeks * 2); } return this.addDays(value); }; /** * Adds the specified number of weeks to this instance. * @param {Number} The number of weeks to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addWeeks = function (value) { if (!value) { return this; } return this.addDays(value * 7); }; /** * Adds the specified number of months to this instance. * @param {Number} The number of months to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addMonths = function (value) { if (!value) { return this; } var n = this.getDate(); this.setDate(1); this.setMonth(this.getMonth() + value * 1); this.setDate(Math.min(n, $D.getDaysInMonth(this.getFullYear(), this.getMonth()))); return this; }; $P.addQuarters = function (value) { if (!value) { return this; } // note this will take you to the same point in the quarter as you are now. // i.e. - if you are 15 days into the quarter you'll be 15 days into the resulting one. // bonus: this allows adding fractional quarters return this.addMonths(value * 3); }; /** * Adds the specified number of years to this instance. * @param {Number} The number of years to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addYears = function (value) { if (!value) { return this; } return this.addMonths(value * 12); }; /** * Adds (or subtracts) to the value of the years, months, weeks, days, hours, minutes, seconds, milliseconds of the date instance using given configuration object. Positive and Negative values allowed. * Example

	Date.today().add( { days: 1, months: 1 } )

	new Date().add( { years: -1 } )
	
* @param {Object} Configuration object containing attributes (months, days, etc.) * @return {Date} this */ $P.add = function (config) { if (typeof config === "number") { this._orient = config; return this; } var x = config; if (x.day) { // If we should be a different date than today (eg: for 'tomorrow -1d', etc). // Should only effect parsing, not direct usage (eg, Finish and FinishExact) if ((x.day - this.getDate()) !== 0) { this.setDate(x.day); } } if (x.milliseconds) { this.addMilliseconds(x.milliseconds); } if (x.seconds) { this.addSeconds(x.seconds); } if (x.minutes) { this.addMinutes(x.minutes); } if (x.hours) { this.addHours(x.hours); } if (x.weeks) { this.addWeeks(x.weeks); } if (x.months) { this.addMonths(x.months); } if (x.years) { this.addYears(x.years); } if (x.days) { this.addDays(x.days); } return this; }; /** * Get the week number. Week one (1) is the week which contains the first Thursday of the year. Monday is considered the first day of the week. * The .getWeek() function does NOT convert the date to UTC. The local datetime is used. * Please use .getISOWeek() to get the week of the UTC converted date. * @return {Number} 1 to 53 */ $P.getWeek = function (utc) { // Create a copy of this date object var self, target = new Date(this.valueOf()); if (utc) { target.addMinutes(target.getTimezoneOffset()); self = target.clone(); } else { self = this; } // ISO week date weeks start on monday // so correct the day number var dayNr = (self.getDay() + 6) % 7; // ISO 8601 states that week 1 is the week // with the first thursday of that year. // Set the target date to the thursday in the target week target.setDate(target.getDate() - dayNr + 3); // Store the millisecond value of the target date var firstThursday = target.valueOf(); // Set the target to the first thursday of the year // First set the target to january first target.setMonth(0, 1); // Not a thursday? Correct the date to the next thursday if (target.getDay() !== 4) { target.setMonth(0, 1 + ((4 - target.getDay()) + 7) % 7); } // The weeknumber is the number of weeks between the // first thursday of the year and the thursday in the target week return 1 + Math.ceil((firstThursday - target) / 604800000); // 604800000 = 7 * 24 * 3600 * 1000 }; /** * Get the ISO 8601 week number. Week one ("01") is the week which contains the first Thursday of the year. Monday is considered the first day of the week. * The .getISOWeek() function does convert the date to it's UTC value. Please use .getWeek() to get the week of the local date. * @return {String} "01" to "53" */ $P.getISOWeek = function () { return p(this.getWeek(true)); }; /** * Moves the date to Monday of the week set. Week one (1) is the week which contains the first Thursday of the year. * @param {Number} A Number (1 to 53) that represents the week of the year. * @return {Date} this */ $P.setWeek = function (n) { if ((n - this.getWeek()) === 0) { if (this.getDay() !== 1) { return this.moveToDayOfWeek(1, (this.getDay() > 1 ? -1 : 1)); } else { return this; } } else { return this.moveToDayOfWeek(1, (this.getDay() > 1 ? -1 : 1)).addWeeks(n - this.getWeek()); } }; $P.setQuarter = function (qtr) { var month = Math.abs(((qtr-1) * 3) + 1); return this.setMonth(month, 1); }; $P.getQuarter = function () { return Date.getQuarter(this); }; $P.getDaysLeftInQuarter = function () { return Date.getDaysLeftInQuarter(this); }; /** * Moves the date to the next n'th occurrence of the dayOfWeek starting from the beginning of the month. The number (-1) is a magic number and will return the last occurrence of the dayOfWeek in the month. * @param {Number} The dayOfWeek to move to * @param {Number} The n'th occurrence to move to. Use (-1) to return the last occurrence in the month * @return {Date} this */ $P.moveToNthOccurrence = function (dayOfWeek, occurrence) { if (dayOfWeek === "Weekday") { if (occurrence > 0) { this.moveToFirstDayOfMonth(); if (this.is().weekday()) { occurrence -= 1; } } else if (occurrence < 0) { this.moveToLastDayOfMonth(); if (this.is().weekday()) { occurrence += 1; } } else { return this; } return this.addWeekdays(occurrence); } var shift = 0; if (occurrence > 0) { shift = occurrence - 1; } else if (occurrence === -1) { this.moveToLastDayOfMonth(); if (this.getDay() !== dayOfWeek) { this.moveToDayOfWeek(dayOfWeek, -1); } return this; } return this.moveToFirstDayOfMonth().addDays(-1).moveToDayOfWeek(dayOfWeek, +1).addWeeks(shift); }; var moveToN = function (getFunc, addFunc, nVal) { return function (value, orient) { var diff = (value - this[getFunc]() + nVal * (orient || +1)) % nVal; return this[addFunc]((diff === 0) ? diff += nVal * (orient || +1) : diff); }; }; /** * Move to the next or last dayOfWeek based on the orient value. * @param {Number} The dayOfWeek to move to * @param {Number} Forward (+1) or Back (-1). Defaults to +1. [Optional] * @return {Date} this */ $P.moveToDayOfWeek = moveToN("getDay", "addDays", 7); /** * Move to the next or last month based on the orient value. * @param {Number} The month to move to. 0 = January, 11 = December * @param {Number} Forward (+1) or Back (-1). Defaults to +1. [Optional] * @return {Date} this */ $P.moveToMonth = moveToN("getMonth", "addMonths", 12); /** * Get the Ordinate of the current day ("th", "st", "rd"). * @return {String} */ $P.getOrdinate = function () { var num = this.getDate(); return ord(num); }; /** * Get the Ordinal day (numeric day number) of the year, adjusted for leap year. * @return {Number} 1 through 365 (366 in leap years) */ $P.getOrdinalNumber = function () { return Math.ceil((this.clone().clearTime() - new Date(this.getFullYear(), 0, 1)) / 86400000) + 1; }; /** * Get the time zone abbreviation of the current date. * @return {String} The abbreviated time zone name (e.g. "EST") */ $P.getTimezone = function () { return $D.getTimezoneAbbreviation(this.getUTCOffset(), this.isDaylightSavingTime()); }; $P.setTimezoneOffset = function (offset) { var here = this.getTimezoneOffset(), there = Number(offset) * -6 / 10; return (there || there === 0) ? this.addMinutes(there - here) : this; }; $P.setTimezone = function (offset) { return this.setTimezoneOffset($D.getTimezoneOffset(offset)); }; /** * Indicates whether Daylight Saving Time is observed in the current time zone. * @return {Boolean} true|false */ $P.hasDaylightSavingTime = function () { return (Date.today().set({month: 0, day: 1}).getTimezoneOffset() !== Date.today().set({month: 6, day: 1}).getTimezoneOffset()); }; /** * Indicates whether this Date instance is within the Daylight Saving Time range for the current time zone. * @return {Boolean} true|false */ $P.isDaylightSavingTime = function () { return Date.today().set({month: 0, day: 1}).getTimezoneOffset() !== this.getTimezoneOffset(); }; /** * Get the offset from UTC of the current date. * @return {String} The 4-character offset string prefixed with + or - (e.g. "-0500") */ $P.getUTCOffset = function (offset) { var n = (offset || this.getTimezoneOffset()) * -10 / 6, r; if (n < 0) { r = (n - 10000).toString(); return r.charAt(0) + r.substr(2); } else { r = (n + 10000).toString(); return "+" + r.substr(1); } }; /** * Returns the number of milliseconds between this date and date. * @param {Date} Defaults to now * @return {Number} The diff in milliseconds */ $P.getElapsed = function (date) { return (date || new Date()) - this; }; /** * Set the value of year, month, day, hour, minute, second, millisecond of date instance using given configuration object. * Example

	Date.today().set( { day: 20, month: 1 } )

	new Date().set( { millisecond: 0 } )
	
* * @param {Object} Configuration object containing attributes (month, day, etc.) * @return {Date} this */ $P.set = function (config) { config = validateConfigObject.call(this, config); var key; for (key in config) { if (Object.prototype.hasOwnProperty.call(config, key)) { var name = key.charAt(0).toUpperCase() + key.slice(1); var addFunc, getFunc; if (key !== "week" && key !== "month" && key !== "timezone" && key !== "timezoneOffset") { name += "s"; } addFunc = "add" + name; getFunc = "get" + name; if (key === "month") { addFunc = addFunc + "s"; } else if (key === "year"){ getFunc = "getFullYear"; } if (key !== "day" && key !== "timezone" && key !== "timezoneOffset" && key !== "week" && key !== "hour") { this[addFunc](config[key] - this[getFunc]()); } else if ( key === "timezone"|| key === "timezoneOffset" || key === "week" || key === "hour") { this["set"+name](config[key]); } } } // day has to go last because you can't validate the day without first knowing the month if (config.day) { this.addDays(config.day - this.getDate()); } return this; }; /** * Moves the date to the first day of the month. * @return {Date} this */ $P.moveToFirstDayOfMonth = function () { return this.set({ day: 1 }); }; /** * Moves the date to the last day of the month. * @return {Date} this */ $P.moveToLastDayOfMonth = function () { return this.set({ day: $D.getDaysInMonth(this.getFullYear(), this.getMonth())}); }; /** * Converts the value of the current Date object to its equivalent string representation. * Format Specifiers * CUSTOM DATE AND TIME FORMAT STRINGS * Format Description Example * ------ --------------------------------------------------------------------------- ----------------------- * s The seconds of the minute between 0-59. "0" to "59" * ss The seconds of the minute with leading zero if required. "00" to "59" * * m The minute of the hour between 0-59. "0" or "59" * mm The minute of the hour with leading zero if required. "00" or "59" * * h The hour of the day between 1-12. "1" to "12" * hh The hour of the day with leading zero if required. "01" to "12" * * H The hour of the day between 0-23. "0" to "23" * HH The hour of the day with leading zero if required. "00" to "23" * * d The day of the month between 1 and 31. "1" to "31" * dd The day of the month with leading zero if required. "01" to "31" * ddd Abbreviated day name. Date.CultureInfo.abbreviatedDayNames. "Mon" to "Sun" * dddd The full day name. Date.CultureInfo.dayNames. "Monday" to "Sunday" * * M The month of the year between 1-12. "1" to "12" * MM The month of the year with leading zero if required. "01" to "12" * MMM Abbreviated month name. Date.CultureInfo.abbreviatedMonthNames. "Jan" to "Dec" * MMMM The full month name. Date.CultureInfo.monthNames. "January" to "December" * * yy The year as a two-digit number. "99" or "08" * yyyy The full four digit year. "1999" or "2008" * * t Displays the first character of the A.M./P.M. designator. "A" or "P" * Date.CultureInfo.amDesignator or Date.CultureInfo.pmDesignator * tt Displays the A.M./P.M. designator. "AM" or "PM" * Date.CultureInfo.amDesignator or Date.CultureInfo.pmDesignator * * S The ordinal suffix ("st, "nd", "rd" or "th") of the current day. "st, "nd", "rd" or "th" * * STANDARD DATE AND TIME FORMAT STRINGS * Format Description Example *------ --------------------------------------------------------------------------- ----------------------- * d The CultureInfo shortDate Format Pattern "M/d/yyyy" * D The CultureInfo longDate Format Pattern "dddd, MMMM dd, yyyy" * F The CultureInfo fullDateTime Format Pattern "dddd, MMMM dd, yyyy h:mm:ss tt" * m The CultureInfo monthDay Format Pattern "MMMM dd" * r The CultureInfo rfc1123 Format Pattern "ddd, dd MMM yyyy HH:mm:ss GMT" * s The CultureInfo sortableDateTime Format Pattern "yyyy-MM-ddTHH:mm:ss" * t The CultureInfo shortTime Format Pattern "h:mm tt" * T The CultureInfo longTime Format Pattern "h:mm:ss tt" * u The CultureInfo universalSortableDateTime Format Pattern "yyyy-MM-dd HH:mm:ssZ" * y The CultureInfo yearMonth Format Pattern "MMMM, yyyy" * * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @return {String} A string representation of the current Date object. */ var ord = function (n) { switch (n * 1) { case 1: case 21: case 31: return "st"; case 2: case 22: return "nd"; case 3: case 23: return "rd"; default: return "th"; } }; var parseStandardFormats = function (format) { var y, c = Date.CultureInfo.formatPatterns; switch (format) { case "d": return this.toString(c.shortDate); case "D": return this.toString(c.longDate); case "F": return this.toString(c.fullDateTime); case "m": return this.toString(c.monthDay); case "r": case "R": y = this.clone().addMinutes(this.getTimezoneOffset()); return y.toString(c.rfc1123) + " GMT"; case "s": return this.toString(c.sortableDateTime); case "t": return this.toString(c.shortTime); case "T": return this.toString(c.longTime); case "u": y = this.clone().addMinutes(this.getTimezoneOffset()); return y.toString(c.universalSortableDateTime); case "y": return this.toString(c.yearMonth); default: return false; } }; var parseFormatStringsClosure = function (context) { return function (m) { if (m.charAt(0) === "\\") { return m.replace("\\", ""); } switch (m) { case "hh": return p(context.getHours() < 13 ? (context.getHours() === 0 ? 12 : context.getHours()) : (context.getHours() - 12)); case "h": return context.getHours() < 13 ? (context.getHours() === 0 ? 12 : context.getHours()) : (context.getHours() - 12); case "HH": return p(context.getHours()); case "H": return context.getHours(); case "mm": return p(context.getMinutes()); case "m": return context.getMinutes(); case "ss": return p(context.getSeconds()); case "s": return context.getSeconds(); case "yyyy": return p(context.getFullYear(), 4); case "yy": return p(context.getFullYear()); case "y": return context.getFullYear(); case "E": case "dddd": return Date.CultureInfo.dayNames[context.getDay()]; case "ddd": return Date.CultureInfo.abbreviatedDayNames[context.getDay()]; case "dd": return p(context.getDate()); case "d": return context.getDate(); case "MMMM": return Date.CultureInfo.monthNames[context.getMonth()]; case "MMM": return Date.CultureInfo.abbreviatedMonthNames[context.getMonth()]; case "MM": return p((context.getMonth() + 1)); case "M": return context.getMonth() + 1; case "t": return context.getHours() < 12 ? Date.CultureInfo.amDesignator.substring(0, 1) : Date.CultureInfo.pmDesignator.substring(0, 1); case "tt": return context.getHours() < 12 ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator; case "S": return ord(context.getDate()); case "W": return context.getWeek(); case "WW": return context.getISOWeek(); case "Q": return "Q" + context.getQuarter(); case "q": return String(context.getQuarter()); case "z": return context.getTimezone(); case "Z": case "X": return Date.getTimezoneOffset(context.getTimezone()); case "ZZ": // Timezone offset in seconds return context.getTimezoneOffset() * -60; case "u": return context.getDay(); case "L": return ($D.isLeapYear(context.getFullYear())) ? 1 : 0; case "B": // Swatch Internet Time (.beats) return "@"+((context.getUTCSeconds() + (context.getUTCMinutes()*60) + ((context.getUTCHours()+1)*3600))/86.4); default: return m; } }; }; $P.toString = function (format, ignoreStandards) { // Standard Date and Time Format Strings. Formats pulled from CultureInfo file and // may vary by culture. if (!ignoreStandards && format && format.length === 1) { output = parseStandardFormats.call(this, format); if (output) { return output; } } var parseFormatStrings = parseFormatStringsClosure(this); return format ? format.replace(/((\\)?(dd?d?d?|MM?M?M?|yy?y?y?|hh?|HH?|mm?|ss?|tt?|S|q|Q|WW?W?W?)(?![^\[]*\]))/g, parseFormatStrings).replace(/\[|\]/g, "") : this._toString(); }; }()); /************************************************************* * SugarPak - Domain Specific Language - Syntactical Sugar * *************************************************************/ (function () { var $D = Date, $P = $D.prototype, $N = Number.prototype; // private $P._orient = +1; // private $P._nth = null; // private $P._is = false; // private $P._same = false; // private $P._isSecond = false; // private $N._dateElement = "days"; /** * Moves the date to the next instance of a date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.today().next().friday();
	Date.today().next().fri();
	Date.today().next().march();
	Date.today().next().mar();
	Date.today().next().week();
	
* * @return {Date} date */ $P.next = function () { this._move = true; this._orient = +1; return this; }; /** * Creates a new Date (Date.today()) and moves the date to the next instance of the date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.next().friday();
	Date.next().fri();
	Date.next().march();
	Date.next().mar();
	Date.next().week();
	
* * @return {Date} date */ $D.next = function () { return $D.today().next(); }; /** * Moves the date to the previous instance of a date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.today().last().friday();
	Date.today().last().fri();
	Date.today().last().march();
	Date.today().last().mar();
	Date.today().last().week();
	
* * @return {Date} date */ $P.last = $P.prev = $P.previous = function () { this._move = true; this._orient = -1; return this; }; /** * Creates a new Date (Date.today()) and moves the date to the previous instance of the date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.last().friday();
	Date.last().fri();
	Date.previous().march();
	Date.prev().mar();
	Date.last().week();
	
* * @return {Date} date */ $D.last = $D.prev = $D.previous = function () { return $D.today().last(); }; /** * Performs a equality check when followed by either a month name, day name or .weekday() function. * Example

	Date.today().is().friday(); // true|false
	Date.today().is().fri();
	Date.today().is().march();
	Date.today().is().mar();
	
* * @return {Boolean} true|false */ $P.is = function () { this._is = true; return this; }; /** * Determines if two date objects occur on/in exactly the same instance of the subsequent date part function. * The function .same() must be followed by a date part function (example: .day(), .month(), .year(), etc). * * An optional Date can be passed in the date part function. If now date is passed as a parameter, 'Now' is used. * * The following example demonstrates how to determine if two dates fall on the exact same day. * * Example

	var d1 = Date.today(); // today at 00:00
	var d2 = new Date();   // exactly now.

	// Do they occur on the same day?
	d1.same().day(d2); // true
	
	// Do they occur on the same hour?
	d1.same().hour(d2); // false, unless d2 hour is '00' (midnight).
	
	// What if it's the same day, but one year apart?
	var nextYear = Date.today().add(1).year();

	d1.same().day(nextYear); // false, because the dates must occur on the exact same day. 
	
* * Scenario: Determine if a given date occurs during some week period 2 months from now. * * Example

	var future = Date.today().add(2).months();
	return someDate.same().week(future); // true|false;
	
* * @return {Boolean} true|false */ $P.same = function () { this._same = true; this._isSecond = false; return this; }; /** * Determines if the current date/time occurs during Today. Must be preceded by the .is() function. * Example

	someDate.is().today();    // true|false
	new Date().is().today();  // true
	Date.today().is().today();// true
	Date.today().add(-1).day().is().today(); // false
	
* * @return {Boolean} true|false */ $P.today = function () { return this.same().day(); }; /** * Determines if the current date is a weekday. This function must be preceded by the .is() function. * Example

	Date.today().is().weekday(); // true|false
	
* * @return {Boolean} true|false */ $P.weekday = function () { if (this._nth) { return df("Weekday").call(this); } if (this._move) { return this.addWeekdays(this._orient); } if (this._is) { this._is = false; return (!this.is().sat() && !this.is().sun()); } return false; }; /** * Determines if the current date is on the weekend. This function must be preceded by the .is() function. * Example

	Date.today().is().weekend(); // true|false
	
* * @return {Boolean} true|false */ $P.weekend = function () { if (this._is) { this._is = false; return (this.is().sat() || this.is().sun()); } return false; }; /** * Sets the Time of the current Date instance. A string "6:15 pm" or config object {hour:18, minute:15} are accepted. * Example

	// Set time to 6:15pm with a String
	Date.today().at("6:15pm");

	// Set time to 6:15pm with a config object
	Date.today().at({hour:18, minute:15});
	
* * @return {Date} date */ $P.at = function (time) { return (typeof time === "string") ? $D.parse(this.toString("d") + " " + time) : this.set(time); }; /** * Creates a new Date() and adds this (Number) to the date based on the preceding date element function (eg. second|minute|hour|day|month|year). * Example

	// Undeclared Numbers must be wrapped with parentheses. Requirment of JavaScript.
	(3).days().fromNow();
	(6).months().fromNow();

	// Declared Number variables do not require parentheses. 
	var n = 6;
	n.months().fromNow();
	
* * @return {Date} A new Date instance */ $N.fromNow = $N.after = function (date) { var c = {}; c[this._dateElement] = this; return ((!date) ? new Date() : date.clone()).add(c); }; /** * Creates a new Date() and subtract this (Number) from the date based on the preceding date element function (eg. second|minute|hour|day|month|year). * Example

	// Undeclared Numbers must be wrapped with parentheses. Requirment of JavaScript.
	(3).days().ago();
	(6).months().ago();

	// Declared Number variables do not require parentheses. 
	var n = 6;
	n.months().ago();
	
* * @return {Date} A new Date instance */ $N.ago = $N.before = function (date) { var c = {}, s = (this._dateElement[this._dateElement.length-1] !== "s") ? this._dateElement + "s" : this._dateElement; c[s] = this * -1; return ((!date) ? new Date() : date.clone()).add(c); }; // Do NOT modify the following string tokens. These tokens are used to build dynamic functions. // All culture-specific strings can be found in the CultureInfo files. var dx = ("sunday monday tuesday wednesday thursday friday saturday").split(/\s/), mx = ("january february march april may june july august september october november december").split(/\s/), px = ("Millisecond Second Minute Hour Day Week Month Year Quarter Weekday").split(/\s/), pxf = ("Milliseconds Seconds Minutes Hours Date Week Month FullYear Quarter").split(/\s/), nth = ("final first second third fourth fifth").split(/\s/), de; /** * Returns an object literal of all the date parts. * Example

	var o = new Date().toObject();
	
	// { year: 2008, month: 4, week: 20, day: 13, hour: 18, minute: 9, second: 32, millisecond: 812 }
	
	// The object properties can be referenced directly from the object.
	
	alert(o.day);  // alerts "13"
	alert(o.year); // alerts "2008"
	
* * @return {Date} An object literal representing the original date object. */ $P.toObject = function () { var o = {}; for (var i = 0; i < px.length; i++) { if (this["get" + pxf[i]]) { o[px[i].toLowerCase()] = this["get" + pxf[i]](); } } return o; }; /** * Returns a date created from an object literal. Ignores the .week property if set in the config. * Example

	var o = new Date().toObject();
	
	return Date.fromObject(o); // will return the same date. 

	var o2 = {month: 1, day: 20, hour: 18}; // birthday party!
	Date.fromObject(o2);
	
* * @return {Date} An object literal representing the original date object. */ $D.fromObject = function(config) { config.week = null; return Date.today().set(config); }; // Create day name functions and abbreviated day name functions (eg. monday(), friday(), fri()). var df = function (n) { return function () { if (this._is) { this._is = false; return this.getDay() === n; } if (this._move) { this._move = null; } if (this._nth !== null) { // If the .second() function was called earlier, remove the _orient // from the date, and then continue. // This is required because 'second' can be used in two different context. // // Example // // Date.today().add(1).second(); // Date.march().second().monday(); // // Things get crazy with the following... // Date.march().add(1).second().second().monday(); // but it works!! // if (this._isSecond) { this.addSeconds(this._orient * -1); } // make sure we reset _isSecond this._isSecond = false; var ntemp = this._nth; this._nth = null; var temp = this.clone().moveToLastDayOfMonth(); this.moveToNthOccurrence(n, ntemp); if (this > temp) { throw new RangeError($D.getDayName(n) + " does not occur " + ntemp + " times in the month of " + $D.getMonthName(temp.getMonth()) + " " + temp.getFullYear() + "."); } return this; } return this.moveToDayOfWeek(n, this._orient); }; }; var sdf = function (n) { return function () { var t = $D.today(), shift = n - t.getDay(); if (n === 0 && Date.CultureInfo.firstDayOfWeek === 1 && t.getDay() !== 0) { shift = shift + 7; } return t.addDays(shift); }; }; // Create month name functions and abbreviated month name functions (eg. january(), march(), mar()). var month_instance_functions = function (n) { return function () { if (this._is) { this._is = false; return this.getMonth() === n; } return this.moveToMonth(n, this._orient); }; }; var month_static_functions = function (n) { return function () { return $D.today().set({ month: n, day: 1 }); }; }; var processTerms = function (names, staticFunc, instanceFunc) { for (var i = 0; i < names.length; i++) { // Create constant static Name variables. $D[names[i].toUpperCase()] = $D[names[i].toUpperCase().substring(0, 3)] = i; // Create Name functions. $D[names[i]] = $D[names[i].substring(0, 3)] = staticFunc(i); // Create Name instance functions. $P[names[i]] = $P[names[i].substring(0, 3)] = instanceFunc(i); } }; processTerms(dx, sdf, df); processTerms(mx, month_static_functions, month_instance_functions); // Create date element functions and plural date element functions used with Date (eg. day(), days(), months()). var ef = function (j) { return function () { // if the .second() function was called earlier, the _orient // has alread been added. Just return this and reset _isSecond. if (this._isSecond) { this._isSecond = false; return this; } if (this._same) { this._same = this._is = false; var o1 = this.toObject(), o2 = (arguments[0] || new Date()).toObject(), v = "", k = j.toLowerCase(); // the substr trick with -1 doesn't work in IE8 or less k = (k[k.length-1] === "s") ? k.substring(0,k.length-1) : k; for (var m = (px.length - 1); m > -1; m--) { v = px[m].toLowerCase(); if (o1[v] !== o2[v]) { return false; } if (k === v) { break; } } return true; } if (j.substring(j.length - 1) !== "s") { j += "s"; } if (this._move) { this._move = null; } return this["add" + j](this._orient); }; }; var nf = function (n) { return function () { this._dateElement = n; return this; }; }; for (var k = 0; k < px.length; k++) { de = px[k].toLowerCase(); if(de !== "weekday") { // Create date element functions and plural date element functions used with Date (eg. day(), days(), months()). $P[de] = $P[de + "s"] = ef(px[k]); // Create date element functions and plural date element functions used with Number (eg. day(), days(), months()). $N[de] = $N[de + "s"] = nf(de + "s"); } } $P._ss = ef("Second"); var nthfn = function (n) { return function (dayOfWeek) { if (this._same) { return this._ss(arguments[0]); } if (dayOfWeek || dayOfWeek === 0) { return this.moveToNthOccurrence(dayOfWeek, n); } this._nth = n; // if the operator is 'second' add the _orient, then deal with it later... if (n === 2 && (dayOfWeek === undefined || dayOfWeek === null)) { this._isSecond = true; return this.addSeconds(this._orient); } return this; }; }; for (var l = 0; l < nth.length; l++) { $P[nth[l]] = (l === 0) ? nthfn(-1) : nthfn(l); } }()); (function () { "use strict"; Date.Parsing = { Exception: function (s) { this.message = "Parse error at '" + s.substring(0, 10) + " ...'"; } }; var $P = Date.Parsing; var dayOffsets = { standard: [0,31,59,90,120,151,181,212,243,273,304,334], leap: [0,31,60,91,121,152,182,213,244,274,305,335] }; $P.isLeapYear = function(year) { return ((year % 4 === 0) && (year % 100 !== 0)) || (year % 400 === 0); }; var utils = { multiReplace : function (str, hash ) { var key; for (key in hash) { if (Object.prototype.hasOwnProperty.call(hash, key)) { var regex; if (typeof hash[key] === "function") { } else { regex = (hash[key] instanceof RegExp) ? hash[key] : new RegExp(hash[key], "g"); } str = str.replace(regex, key); } } return str; }, getDayOfYearFromWeek : function (obj) { var d, jan4, offset; obj.weekDay = (!obj.weekDay && obj.weekDay !== 0) ? 1 : obj.weekDay; d = new Date(obj.year, 0, 4); jan4 = d.getDay() === 0 ? 7 : d.getDay(); // JS is 0 indexed on Sunday. offset = jan4+3; obj.dayOfYear = ((obj.week * 7) + (obj.weekDay === 0 ? 7 : obj.weekDay))-offset; return obj; }, getDayOfYear : function (obj, dayOffset) { if (!obj.dayOfYear) { obj = utils.getDayOfYearFromWeek(obj); } for (var i=0;i <= dayOffset.length;i++) { if (obj.dayOfYear < dayOffset[i] || i === dayOffset.length) { obj.day = obj.day ? obj.day : (obj.dayOfYear - dayOffset[i-1]); break; } else { obj.month = i; } } return obj; }, adjustForTimeZone : function (obj, date) { var offset; if (obj.zone.toUpperCase() === "Z" || (obj.zone_hours === 0 && obj.zone_minutes === 0)) { // it's UTC/GML so work out the current timeszone offset offset = -date.getTimezoneOffset(); } else { offset = (obj.zone_hours*60) + (obj.zone_minutes || 0); if (obj.zone_sign === "+") { offset *= -1; } offset -= date.getTimezoneOffset(); } date.setMinutes(date.getMinutes()+offset); return date; }, setDefaults : function (obj) { obj.year = obj.year || Date.today().getFullYear(); obj.hours = obj.hours || 0; obj.minutes = obj.minutes || 0; obj.seconds = obj.seconds || 0; obj.milliseconds = obj.milliseconds || 0; if (!(!obj.month && (obj.week || obj.dayOfYear))) { // if we have a month, or if we don't but don't have the day calculation data obj.month = obj.month || 0; obj.day = obj.day || 1; } return obj; }, dataNum: function (data, mod, explict, postProcess) { var dataNum = data*1; if (mod) { if (postProcess) { return data ? mod(data)*1 : data; } else { return data ? mod(dataNum) : data; } } else if (!explict){ return data ? dataNum : data; } else { return (data && typeof data !== "undefined") ? dataNum : data; } }, timeDataProcess: function (obj) { var timeObj = {}; for (var x in obj.data) { if (obj.data.hasOwnProperty(x)) { timeObj[x] = obj.ignore[x] ? obj.data[x] : utils.dataNum(obj.data[x], obj.mods[x], obj.explict[x], obj.postProcess[x]); } } if (obj.data.secmins) { obj.data.secmins = obj.data.secmins.replace(",", ".") * 60; if (!timeObj.minutes) { timeObj.minutes = obj.data.secmins; } else if (!timeObj.seconds) { timeObj.seconds = obj.data.secmins; } delete obj.secmins; } return timeObj; }, buildTimeObjectFromData: function (data) { var time = utils.timeDataProcess({ data: { year : data[1], month : data[5], day : data[7], week : data[8], dayOfYear : data[10], hours : data[15], zone_hours : data[23], zone_minutes : data[24], zone : data[21], zone_sign : data[22], weekDay : data[9], minutes: data[16], seconds: data[19], milliseconds: data[20], secmins: data[18] }, mods: { month: function(data) { return data-1; }, weekDay: function (data) { data = Math.abs(data); return (data === 7 ? 0 : data); }, minutes: function (data) { return data.replace(":",""); }, seconds: function (data) { return Math.floor( (data.replace(":","").replace(",","."))*1 ); }, milliseconds: function (data) { return (data.replace(",",".")*1000); } }, postProcess: { minutes: true, seconds: true, milliseconds: true }, explict: { zone_hours: true, zone_minutes: true }, ignore: { zone: true, zone_sign: true, secmins: true } }); return time; }, addToHash: function (hash, keys, data) { keys = keys; data = data; var len = keys.length; for (var i = 0; i < len; i++) { hash[keys[i]] = data[i]; } return hash; }, combineRegex: function (r1, r2) { return new RegExp("(("+r1.source+")\\s("+r2.source+"))"); }, getDateNthString: function(add, last, inc){ if (add) { return Date.today().addDays(inc).toString("d"); } else if (last) { return Date.today().last()[inc]().toString("d"); } }, buildRegexData: function (array) { var arr = []; var len = array.length; for (var i=0; i < len; i++) { if (Object.prototype.toString.call(array[i]) === '[object Array]') { // oldIE compat version of Array.isArray arr.push(this.combineRegex(array[i][0], array[i][1])); } else { arr.push(array[i]); } } return arr; } }; $P.processTimeObject = function (obj) { var date, dayOffset; utils.setDefaults(obj); dayOffset = ($P.isLeapYear(obj.year)) ? dayOffsets.leap : dayOffsets.standard; if (!obj.month && (obj.week || obj.dayOfYear)) { utils.getDayOfYear(obj, dayOffset); } else { obj.dayOfYear = dayOffset[obj.month] + obj.day; } date = new Date(obj.year, obj.month, obj.day, obj.hours, obj.minutes, obj.seconds, obj.milliseconds); if (obj.zone) { utils.adjustForTimeZone(obj, date); // adjust (and calculate) for timezone } return date; }; $P.ISO = { regex : /^([\+-]?\d{4}(?!\d{2}\b))((-?)((0[1-9]|1[0-2])(\3([12]\d|0[1-9]|3[01]))?|W([0-4]\d|5[0-3])(-?[1-7])?|(00[1-9]|0[1-9]\d|[12]\d{2}|3([0-5]\d|6[1-6])))([T\s]((([01]\d|2[0-4])((:?)[0-5]\d)?|24\:?00)([\.,]\d+(?!:))?)?(\17[0-5]\d([\.,]\d+)?)?\s?([zZ]|([\+-])([01]\d|2[0-3]):?([0-5]\d)?)?)?)?$/, parse : function (s) { var time, data = s.match(this.regex); if (!data || !data.length) { return null; } time = utils.buildTimeObjectFromData(data); if (!time.year || (!time.year && (!time.month && !time.day) && (!time.week && !time.dayOfYear)) ) { return null; } return $P.processTimeObject(time); } }; $P.Numeric = { isNumeric: function (e){return!isNaN(parseFloat(e))&&isFinite(e);}, regex: /\b([0-1]?[0-9])([0-3]?[0-9])([0-2]?[0-9]?[0-9][0-9])\b/i, parse: function (s) { var data, i, time = {}, order = Date.CultureInfo.dateElementOrder.split(""); if (!(this.isNumeric(s)) || // if it's non-numeric OR (s[0] === "+" && s[0] === "-")) { // It's an arithmatic string (eg +/-1000) return null; } if (s.length < 5 && s.indexOf(".") < 0 && s.indexOf("/") < 0) { // assume it's just a year. time.year = s; return $P.processTimeObject(time); } data = s.match(this.regex); if (!data || !data.length) { return null; } for (i=0; i < order.length; i++) { switch(order[i]) { case "d": time.day = data[i+1]; break; case "m": time.month = (data[i+1]-1); break; case "y": time.year = data[i+1]; break; } } return $P.processTimeObject(time); } }; $P.Normalizer = { regexData: function () { var $R = Date.CultureInfo.regexPatterns; return utils.buildRegexData([ $R.tomorrow, $R.yesterday, [$R.past, $R.mon], [$R.past, $R.tue], [$R.past, $R.wed], [$R.past, $R.thu], [$R.past, $R.fri], [$R.past, $R.sat], [$R.past, $R.sun] ]); }, basicReplaceHash : function() { var $R = Date.CultureInfo.regexPatterns; return { "January": $R.jan.source, "February": $R.feb, "March": $R.mar, "April": $R.apr, "May": $R.may, "June": $R.jun, "July": $R.jul, "August": $R.aug, "September": $R.sep, "October": $R.oct, "November": $R.nov, "December": $R.dec, "": /\bat\b/gi, " ": /\s{2,}/, "am": $R.inTheMorning, "9am": $R.thisMorning, "pm": $R.inTheEvening, "7pm":$R.thisEvening }; }, keys : function(){ return [ utils.getDateNthString(true, false, 1), // tomorrow utils.getDateNthString(true, false, -1), // yesterday utils.getDateNthString(false, true, "monday"), //last mon utils.getDateNthString(false, true, "tuesday"), //last tues utils.getDateNthString(false, true, "wednesday"), //last wed utils.getDateNthString(false, true, "thursday"), //last thurs utils.getDateNthString(false, true, "friday"), //last fri utils.getDateNthString(false, true, "saturday"), //last sat utils.getDateNthString(false, true, "sunday") //last sun ]; }, buildRegexFunctions: function () { var $R = Date.CultureInfo.regexPatterns; var __ = Date.i18n.__; var tomorrowRE = new RegExp("(\\b\\d\\d?("+__("AM")+"|"+__("PM")+")? )("+$R.tomorrow.source.slice(1)+")", "i"); // adapted tomorrow regex for AM PM relative dates var todayRE = new RegExp($R.today.source + "(?!\\s*([+-]))\\b"); // today, but excludes the math operators (eg "today + 2h") this.replaceFuncs = [ [todayRE, function (full) { return (full.length > 1) ? Date.today().toString("d") : full; }], [tomorrowRE, function(full, m1) { var t = Date.today().addDays(1).toString("d"); return (t + " " + m1); }], [$R.amThisMorning, function(str, am){return am;}], [$R.pmThisEvening, function(str, pm){return pm;}] ]; }, buildReplaceData: function () { this.buildRegexFunctions(); this.replaceHash = utils.addToHash(this.basicReplaceHash(), this.keys(), this.regexData()); }, stringReplaceFuncs: function (s) { for (var i=0; i < this.replaceFuncs.length; i++) { s = s.replace(this.replaceFuncs[i][0], this.replaceFuncs[i][1]); } return s; }, parse: function (s) { s = this.stringReplaceFuncs(s); s = utils.multiReplace(s, this.replaceHash); try { var n = s.split(/([\s\-\.\,\/\x27]+)/); if (n.length === 3 && $P.Numeric.isNumeric(n[0]) && $P.Numeric.isNumeric(n[2]) && (n[2].length >= 4)) { // ok, so we're dealing with x/year. But that's not a full date. // This fixes wonky dateElementOrder parsing when set to dmy order. if (Date.CultureInfo.dateElementOrder[0] === "d") { s = "1/" + n[0] + "/" + n[2]; // set to 1st of month and normalize the seperator } } } catch (e) {} return s; } }; $P.Normalizer.buildReplaceData(); }()); (function () { var $P = Date.Parsing; var _ = $P.Operators = { // // Tokenizers // rtoken: function (r) { // regex token return function (s) { var mx = s.match(r); if (mx) { return ([ mx[0], s.substring(mx[0].length) ]); } else { throw new $P.Exception(s); } }; }, token: function () { // whitespace-eating token return function (s) { return _.rtoken(new RegExp("^\\s*" + s + "\\s*"))(s); }; }, stoken: function (s) { // string token return _.rtoken(new RegExp("^" + s)); }, // Atomic Operators until: function (p) { return function (s) { var qx = [], rx = null; while (s.length) { try { rx = p.call(this, s); } catch (e) { qx.push(rx[0]); s = rx[1]; continue; } break; } return [ qx, s ]; }; }, many: function (p) { return function (s) { var rx = [], r = null; while (s.length) { try { r = p.call(this, s); } catch (e) { return [ rx, s ]; } rx.push(r[0]); s = r[1]; } return [ rx, s ]; }; }, // generator operators -- see below optional: function (p) { return function (s) { var r = null; try { r = p.call(this, s); } catch (e) { return [ null, s ]; } return [ r[0], r[1] ]; }; }, not: function (p) { return function (s) { try { p.call(this, s); } catch (e) { return [null, s]; } throw new $P.Exception(s); }; }, ignore: function (p) { return p ? function (s) { var r = null; r = p.call(this, s); return [null, r[1]]; } : null; }, product: function () { var px = arguments[0], qx = Array.prototype.slice.call(arguments, 1), rx = []; for (var i = 0 ; i < px.length ; i++) { rx.push(_.each(px[i], qx)); } return rx; }, cache: function (rule) { var cache = {}, cache_length = 0, cache_keys = [], CACHE_MAX = Date.Config.CACHE_MAX || 100000, r = null; var cacheCheck = function () { if (cache_length === CACHE_MAX) { // kill several keys, don't want to have to do this all the time... for (var i=0; i < 10; i++) { var key = cache_keys.shift(); if (key) { delete cache[key]; cache_length--; } } } }; return function (s) { cacheCheck(); try { r = cache[s] = (cache[s] || rule.call(this, s)); } catch (e) { r = cache[s] = e; } cache_length++; cache_keys.push(s); if (r instanceof $P.Exception) { throw r; } else { return r; } }; }, // vector operators -- see below any: function () { var px = arguments; return function (s) { var r = null; for (var i = 0; i < px.length; i++) { if (px[i] == null) { continue; } try { r = (px[i].call(this, s)); } catch (e) { r = null; } if (r) { return r; } } throw new $P.Exception(s); }; }, each: function () { var px = arguments; return function (s) { var rx = [], r = null; for (var i = 0; i < px.length ; i++) { if (px[i] == null) { continue; } try { r = (px[i].call(this, s)); } catch (e) { throw new $P.Exception(s); } rx.push(r[0]); s = r[1]; } return [ rx, s]; }; }, all: function () { var px = arguments, _ = _; return _.each(_.optional(px)); }, // delimited operators sequence: function (px, d, c) { d = d || _.rtoken(/^\s*/); c = c || null; if (px.length === 1) { return px[0]; } return function (s) { var r = null, q = null; var rx = []; for (var i = 0; i < px.length ; i++) { try { r = px[i].call(this, s); } catch (e) { break; } rx.push(r[0]); try { q = d.call(this, r[1]); } catch (ex) { q = null; break; } s = q[1]; } if (!r) { throw new $P.Exception(s); } if (q) { throw new $P.Exception(q[1]); } if (c) { try { r = c.call(this, r[1]); } catch (ey) { throw new $P.Exception(r[1]); } } return [ rx, (r?r[1]:s) ]; }; }, // // Composite Operators // between: function (d1, p, d2) { d2 = d2 || d1; var _fn = _.each(_.ignore(d1), p, _.ignore(d2)); return function (s) { var rx = _fn.call(this, s); return [[rx[0][0], r[0][2]], rx[1]]; }; }, list: function (p, d, c) { d = d || _.rtoken(/^\s*/); c = c || null; return (p instanceof Array ? _.each(_.product(p.slice(0, -1), _.ignore(d)), p.slice(-1), _.ignore(c)) : _.each(_.many(_.each(p, _.ignore(d))), px, _.ignore(c))); }, set: function (px, d, c) { d = d || _.rtoken(/^\s*/); c = c || null; return function (s) { // r is the current match, best the current 'best' match // which means it parsed the most amount of input var r = null, p = null, q = null, rx = null, best = [[], s], last = false; // go through the rules in the given set for (var i = 0; i < px.length ; i++) { // last is a flag indicating whether this must be the last element // if there is only 1 element, then it MUST be the last one q = null; p = null; r = null; last = (px.length === 1); // first, we try simply to match the current pattern // if not, try the next pattern try { r = px[i].call(this, s); } catch (e) { continue; } // since we are matching against a set of elements, the first // thing to do is to add r[0] to matched elements rx = [[r[0]], r[1]]; // if we matched and there is still input to parse and // we don't already know this is the last element, // we're going to next check for the delimiter ... // if there's none, or if there's no input left to parse // than this must be the last element after all ... if (r[1].length > 0 && ! last) { try { q = d.call(this, r[1]); } catch (ex) { last = true; } } else { last = true; } // if we parsed the delimiter and now there's no more input, // that means we shouldn't have parsed the delimiter at all // so don't update r and mark this as the last element ... if (!last && q[1].length === 0) { last = true; } // so, if this isn't the last element, we're going to see if // we can get any more matches from the remaining (unmatched) // elements ... if (!last) { // build a list of the remaining rules we can match against, // i.e., all but the one we just matched against var qx = []; for (var j = 0; j < px.length ; j++) { if (i !== j) { qx.push(px[j]); } } // now invoke recursively set with the remaining input // note that we don't include the closing delimiter ... // we'll check for that ourselves at the end p = _.set(qx, d).call(this, q[1]); // if we got a non-empty set as a result ... // (otw rx already contains everything we want to match) if (p[0].length > 0) { // update current result, which is stored in rx ... // basically, pick up the remaining text from p[1] // and concat the result from p[0] so that we don't // get endless nesting ... rx[0] = rx[0].concat(p[0]); rx[1] = p[1]; } } // at this point, rx either contains the last matched element // or the entire matched set that starts with this element. // now we just check to see if this variation is better than // our best so far, in terms of how much of the input is parsed if (rx[1].length < best[1].length) { best = rx; } // if we've parsed all the input, then we're finished if (best[1].length === 0) { break; } } // so now we've either gone through all the patterns trying them // as the initial match; or we found one that parsed the entire // input string ... // if best has no matches, just return empty set ... if (best[0].length === 0) { return best; } // if a closing delimiter is provided, then we have to check it also if (c) { // we try this even if there is no remaining input because the pattern // may well be optional or match empty input ... try { q = c.call(this, best[1]); } catch (ey) { throw new $P.Exception(best[1]); } // it parsed ... be sure to update the best match remaining input best[1] = q[1]; } // if we're here, either there was no closing delimiter or we parsed it // so now we have the best match; just return it! return best; }; }, forward: function (gr, fname) { return function (s) { return gr[fname].call(this, s); }; }, // // Translation Operators // replace: function (rule, repl) { return function (s) { var r = rule.call(this, s); return [repl, r[1]]; }; }, process: function (rule, fn) { return function (s) { var r = rule.call(this, s); return [fn.call(this, r[0]), r[1]]; }; }, min: function (min, rule) { return function (s) { var rx = rule.call(this, s); if (rx[0].length < min) { throw new $P.Exception(s); } return rx; }; } }; // Generator Operators And Vector Operators // Generators are operators that have a signature of F(R) => R, // taking a given rule and returning another rule, such as // ignore, which parses a given rule and throws away the result. // Vector operators are those that have a signature of F(R1,R2,...) => R, // take a list of rules and returning a new rule, such as each. // Generator operators are converted (via the following _generator // function) into functions that can also take a list or array of rules // and return an array of new rules as though the function had been // called on each rule in turn (which is what actually happens). // This allows generators to be used with vector operators more easily. // Example: // each(ignore(foo, bar)) instead of each(ignore(foo), ignore(bar)) // This also turns generators into vector operators, which allows // constructs like: // not(cache(foo, bar)) var _generator = function (op) { function gen() { var args = null, rx = [], px, i; if (arguments.length > 1) { args = Array.prototype.slice.call(arguments); } else if (arguments[0] instanceof Array) { args = arguments[0]; } if (args) { px = args.shift(); if (px.length > 0) { args.unshift(px[i]); rx.push(op.apply(null, args)); args.shift(); return rx; } } else { return op.apply(null, arguments); } } return gen; }; var gx = "optional not ignore cache".split(/\s/); for (var i = 0 ; i < gx.length ; i++) { _[gx[i]] = _generator(_[gx[i]]); } var _vector = function (op) { return function () { if (arguments[0] instanceof Array) { return op.apply(null, arguments[0]); } else { return op.apply(null, arguments); } }; }; var vx = "each any all".split(/\s/); for (var j = 0 ; j < vx.length ; j++) { _[vx[j]] = _vector(_[vx[j]]); } }()); (function () { var $D = Date; var flattenAndCompact = function (ax) { var rx = []; for (var i = 0; i < ax.length; i++) { if (ax[i] instanceof Array) { rx = rx.concat(flattenAndCompact(ax[i])); } else { if (ax[i]) { rx.push(ax[i]); } } } return rx; }; var parseMeridian = function () { if (this.meridian && (this.hour || this.hour === 0)) { if (this.meridian === "a" && this.hour > 11 && Date.Config.strict24hr){ throw "Invalid hour and meridian combination"; } else if (this.meridian === "p" && this.hour < 12 && Date.Config.strict24hr){ throw "Invalid hour and meridian combination"; } else if (this.meridian === "p" && this.hour < 12) { this.hour = this.hour + 12; } else if (this.meridian === "a" && this.hour === 12) { this.hour = 0; } } }; var setDefaults = function () { var now = new Date(); if ((this.hour || this.minute) && (!this.month && !this.year && !this.day)) { this.day = now.getDate(); } if (!this.year) { this.year = now.getFullYear(); } if (!this.month && this.month !== 0) { this.month = now.getMonth(); } if (!this.day) { this.day = 1; } if (!this.hour) { this.hour = 0; } if (!this.minute) { this.minute = 0; } if (!this.second) { this.second = 0; } if (!this.millisecond) { this.millisecond = 0; } }; var finishUtils = { getToday: function () { if (this.now || "hour minute second".indexOf(this.unit) !== -1) { return new Date(); } else { return $D.today(); } }, setDaysFromWeekday: function (today, orient){ var gap; orient = orient || 1; this.unit = "day"; gap = ($D.getDayNumberFromName(this.weekday) - today.getDay()); this.days = gap ? ((gap + (orient * 7)) % 7) : (orient * 7); return this; }, setMonthsFromMonth: function (today, orient) { var gap; orient = orient || 1; this.unit = "month"; gap = (this.month - today.getMonth()); this.months = gap ? ((gap + (orient * 12)) % 12) : (orient * 12); this.month = null; return this; }, setDMYFromWeekday: function () { var d = Date[this.weekday](); this.day = d.getDate(); if (!this.month) { this.month = d.getMonth(); } this.year = d.getFullYear(); return this; }, setUnitValue: function (orient) { if (!this.value && this.operator && this.operator !== null && this[this.unit + "s"] && this[this.unit + "s"] !== null) { this[this.unit + "s"] = this[this.unit + "s"] + ((this.operator === "add") ? 1 : -1) + (this.value||0) * orient; } else if (this[this.unit + "s"] == null || this.operator != null) { if (!this.value) { this.value = 1; } this[this.unit + "s"] = this.value * orient; } }, generateDateFromWeeks: function () { var weekday = (this.weekday !== undefined) ? this.weekday : "today"; var d = Date[weekday]().addWeeks(this.weeks); if (this.now) { d.setTimeToNow(); } return d; } }; $D.Translator = { hour: function (s) { return function () { this.hour = Number(s); }; }, minute: function (s) { return function () { this.minute = Number(s); }; }, second: function (s) { return function () { this.second = Number(s); }; }, /* for ss.s format */ secondAndMillisecond: function (s) { return function () { var mx = s.match(/^([0-5][0-9])\.([0-9]{1,3})/); this.second = Number(mx[1]); this.millisecond = Number(mx[2]); }; }, meridian: function (s) { return function () { this.meridian = s.slice(0, 1).toLowerCase(); }; }, timezone: function (s) { return function () { var n = s.replace(/[^\d\+\-]/g, ""); if (n.length) { this.timezoneOffset = Number(n); } else { this.timezone = s.toLowerCase(); } }; }, day: function (x) { var s = x[0]; return function () { this.day = Number(s.match(/\d+/)[0]); if (this.day < 1) { throw "invalid day"; } }; }, month: function (s) { return function () { this.month = (s.length === 3) ? "jan feb mar apr may jun jul aug sep oct nov dec".indexOf(s)/4 : Number(s) - 1; if (this.month < 0) { throw "invalid month"; } }; }, year: function (s) { return function () { var n = Number(s); this.year = ((s.length > 2) ? n : (n + (((n + 2000) < Date.CultureInfo.twoDigitYearMax) ? 2000 : 1900))); }; }, rday: function (s) { return function () { switch (s) { case "yesterday": this.days = -1; break; case "tomorrow": this.days = 1; break; case "today": this.days = 0; break; case "now": this.days = 0; this.now = true; break; } }; }, finishExact: function (x) { var d; x = (x instanceof Array) ? x : [x]; for (var i = 0 ; i < x.length ; i++) { if (x[i]) { x[i].call(this); } } setDefaults.call(this); parseMeridian.call(this); if (this.day > $D.getDaysInMonth(this.year, this.month)) { throw new RangeError(this.day + " is not a valid value for days."); } d = new Date(this.year, this.month, this.day, this.hour, this.minute, this.second, this.millisecond); if (this.year < 100) { d.setFullYear(this.year); // means years less that 100 are process correctly. JS will parse it otherwise as 1900-1999. } if (this.timezone) { d.set({ timezone: this.timezone }); } else if (this.timezoneOffset) { d.set({ timezoneOffset: this.timezoneOffset }); } return d; }, finish: function (x) { var today, expression, orient, temp; x = (x instanceof Array) ? flattenAndCompact(x) : [ x ]; if (x.length === 0) { return null; } for (var i = 0 ; i < x.length ; i++) { if (typeof x[i] === "function") { x[i].call(this); } } if (this.now && !this.unit && !this.operator) { return new Date(); } else { today = finishUtils.getToday.call(this); } expression = !!(this.days && this.days !== null || this.orient || this.operator); orient = ((this.orient === "past" || this.operator === "subtract") ? -1 : 1); if (this.month && this.unit === "week") { this.value = this.month + 1; delete this.month; delete this.day; } if ((this.month || this.month === 0) && "year day hour minute second".indexOf(this.unit) !== -1) { if (!this.value) { this.value = this.month + 1; } this.month = null; expression = true; } if (!expression && this.weekday && !this.day && !this.days) { finishUtils.setDMYFromWeekday.call(this); } if (expression && this.weekday && this.unit !== "month" && this.unit !== "week") { finishUtils.setDaysFromWeekday.call(this, today, orient); } if (this.weekday && this.unit !== "week" && !this.day && !this.days) { temp = Date[this.weekday](); this.day = temp.getDate(); if (temp.getMonth() !== today.getMonth()) { this.month = temp.getMonth(); } } if (this.month && this.unit === "day" && this.operator) { if (!this.value) { this.value = (this.month + 1); } this.month = null; } if (this.value != null && this.month != null && this.year != null) { this.day = this.value * 1; } if (this.month && !this.day && this.value) { today.set({ day: this.value * 1 }); if (!expression) { this.day = this.value * 1; } } if (!this.month && this.value && this.unit === "month" && !this.now) { this.month = this.value; expression = true; } if (expression && (this.month || this.month === 0) && this.unit !== "year") { finishUtils.setMonthsFromMonth.call(this, today, orient); } if (!this.unit) { this.unit = "day"; } finishUtils.setUnitValue.call(this, orient); parseMeridian.call(this); if ((this.month || this.month === 0) && !this.day) { this.day = 1; } if (!this.orient && !this.operator && this.unit === "week" && this.value && !this.day && !this.month) { return Date.today().setWeek(this.value); } if (this.unit === "week" && this.weeks && !this.day && !this.month) { return finishUtils.generateDateFromWeeks.call(this); } if (expression && this.timezone && this.day && this.days) { this.day = this.days; } if (expression){ today.add(this); } else { today.set(this); } if (this.timezone) { this.timezone = this.timezone.toUpperCase(); var offset = $D.getTimezoneOffset(this.timezone); var timezone; if (today.hasDaylightSavingTime()) { // lets check that we're being sane with timezone setting timezone = $D.getTimezoneAbbreviation(offset, today.isDaylightSavingTime()); if (timezone !== this.timezone) { // bugger, we're in a place where things like EST vs EDT matters. if (today.isDaylightSavingTime()) { today.addHours(-1); } else { today.addHours(1); } } } today.setTimezoneOffset(offset); } return today; } }; }()); (function () { var $D = Date; $D.Grammar = {}; var _ = $D.Parsing.Operators, g = $D.Grammar, t = $D.Translator, _fn; // Allow rolling up into general purpose rules _fn = function () { return _.each(_.any.apply(null, arguments), _.not(g.ctoken2("timeContext"))); }; g.datePartDelimiter = _.rtoken(/^([\s\-\.\,\/\x27]+)/); g.timePartDelimiter = _.stoken(":"); g.whiteSpace = _.rtoken(/^\s*/); g.generalDelimiter = _.rtoken(/^(([\s\,]|at|@|on)+)/); var _C = {}; g.ctoken = function (keys) { var fn = _C[keys]; if (! fn) { var c = Date.CultureInfo.regexPatterns; var kx = keys.split(/\s+/), px = []; for (var i = 0; i < kx.length ; i++) { px.push(_.replace(_.rtoken(c[kx[i]]), kx[i])); } fn = _C[keys] = _.any.apply(null, px); } return fn; }; g.ctoken2 = function (key) { return _.rtoken(Date.CultureInfo.regexPatterns[key]); }; var cacheProcessRtoken = function (key, token, type, eachToken) { if (eachToken) { g[key] = _.cache(_.process(_.each(_.rtoken(token),_.optional(g.ctoken2(eachToken))), type)); } else { g[key] = _.cache(_.process(_.rtoken(token), type)); } }; var cacheProcessCtoken = function (token, type) { return _.cache(_.process(g.ctoken2(token), type)); }; var _F = {}; //function cache var _get = function (f) { _F[f] = (_F[f] || g.format(f)[0]); return _F[f]; }; g.allformats = function (fx) { var rx = []; if (fx instanceof Array) { for (var i = 0; i < fx.length; i++) { rx.push(_get(fx[i])); } } else { rx.push(_get(fx)); } return rx; }; g.formats = function (fx) { if (fx instanceof Array) { var rx = []; for (var i = 0 ; i < fx.length ; i++) { rx.push(_get(fx[i])); } return _.any.apply(null, rx); } else { return _get(fx); } }; var grammarFormats = { timeFormats: function(){ var i, RTokenKeys = [ "h", "hh", "H", "HH", "m", "mm", "s", "ss", "ss.s", "z", "zz" ], RToken = [ /^(0[0-9]|1[0-2]|[1-9])/, /^(0[0-9]|1[0-2])/, /^([0-1][0-9]|2[0-3]|[0-9])/, /^([0-1][0-9]|2[0-3])/, /^([0-5][0-9]|[0-9])/, /^[0-5][0-9]/, /^([0-5][0-9]|[0-9])/, /^[0-5][0-9]/, /^[0-5][0-9]\.[0-9]{1,3}/, /^((\+|\-)\s*\d\d\d\d)|((\+|\-)\d\d\:?\d\d)/, /^((\+|\-)\s*\d\d\d\d)|((\+|\-)\d\d\:?\d\d)/ ], tokens = [ t.hour, t.hour, t.hour, t.hour, t.minute, t.minute, t.second, t.second, t.secondAndMillisecond, t.timezone, t.timezone ]; for (i=0; i < RTokenKeys.length; i++) { cacheProcessRtoken(RTokenKeys[i], RToken[i], tokens[i]); } g.hms = _.cache(_.sequence([g.H, g.m, g.s], g.timePartDelimiter)); g.t = cacheProcessCtoken("shortMeridian", t.meridian); g.tt = cacheProcessCtoken("longMeridian", t.meridian); g.zzz = cacheProcessCtoken("timezone", t.timezone); g.timeSuffix = _.each(_.ignore(g.whiteSpace), _.set([ g.tt, g.zzz ])); g.time = _.each(_.optional(_.ignore(_.stoken("T"))), g.hms, g.timeSuffix); }, dateFormats: function () { // pre-loaded rules for different date part order preferences var _setfn = function () { return _.set(arguments, g.datePartDelimiter); }; var i, RTokenKeys = [ "d", "dd", "M", "MM", "y", "yy", "yyy", "yyyy" ], RToken = [ /^([0-2]\d|3[0-1]|\d)/, /^([0-2]\d|3[0-1])/, /^(1[0-2]|0\d|\d)/, /^(1[0-2]|0\d)/, /^(\d+)/, /^(\d\d)/, /^(\d\d?\d?\d?)/, /^(\d\d\d\d)/ ], tokens = [ t.day, t.day, t.month, t.month, t.year, t.year, t.year, t.year ], eachToken = [ "ordinalSuffix", "ordinalSuffix" ]; for (i=0; i < RTokenKeys.length; i++) { cacheProcessRtoken(RTokenKeys[i], RToken[i], tokens[i], eachToken[i]); } g.MMM = g.MMMM = _.cache(_.process(g.ctoken("jan feb mar apr may jun jul aug sep oct nov dec"), t.month)); g.ddd = g.dddd = _.cache(_.process(g.ctoken("sun mon tue wed thu fri sat"), function (s) { return function () { this.weekday = s; }; } )); g.day = _fn(g.d, g.dd); g.month = _fn(g.M, g.MMM); g.year = _fn(g.yyyy, g.yy); g.mdy = _setfn(g.ddd, g.month, g.day, g.year); g.ymd = _setfn(g.ddd, g.year, g.month, g.day); g.dmy = _setfn(g.ddd, g.day, g.month, g.year); g.date = function (s) { return ((g[Date.CultureInfo.dateElementOrder] || g.mdy).call(this, s)); }; }, relative: function () { // relative date / time expressions g.orientation = _.process(g.ctoken("past future"), function (s) { return function () { this.orient = s; }; } ); g.operator = _.process(g.ctoken("add subtract"), function (s) { return function () { this.operator = s; }; } ); g.rday = _.process(g.ctoken("yesterday tomorrow today now"), t.rday); g.unit = _.process(g.ctoken("second minute hour day week month year"), function (s) { return function () { this.unit = s; }; } ); } }; g.buildGrammarFormats = function () { // these need to be rebuilt every time the language changes. _C = {}; grammarFormats.timeFormats(); grammarFormats.dateFormats(); grammarFormats.relative(); g.value = _.process(_.rtoken(/^([-+]?\d+)?(st|nd|rd|th)?/), function (s) { return function () { this.value = s.replace(/\D/g, ""); }; } ); g.expression = _.set([g.rday, g.operator, g.value, g.unit, g.orientation, g.ddd, g.MMM ]); g.format = _.process(_.many( _.any( // translate format specifiers into grammar rules _.process( _.rtoken(/^(dd?d?d?(?!e)|MM?M?M?|yy?y?y?|hh?|HH?|mm?|ss?|tt?|zz?z?)/), function (fmt) { if (g[fmt]) { return g[fmt]; } else { throw $D.Parsing.Exception(fmt); } } ), // translate separator tokens into token rules _.process(_.rtoken(/^[^dMyhHmstz]+/), // all legal separators function (s) { return _.ignore(_.stoken(s)); } ) ) ), // construct the parser ... function (rules) { return _.process(_.each.apply(null, rules), t.finishExact); } ); // starting rule for general purpose grammar g._start = _.process(_.set([ g.date, g.time, g.expression ], g.generalDelimiter, g.whiteSpace), t.finish); }; g.buildGrammarFormats(); // parsing date format specifiers - ex: "h:m:s tt" // this little guy will generate a custom parser based // on the format string, ex: g.format("h:m:s tt") // check for these formats first g._formats = g.formats([ "\"yyyy-MM-ddTHH:mm:ssZ\"", "yyyy-MM-ddTHH:mm:ss.sz", "yyyy-MM-ddTHH:mm:ssZ", "yyyy-MM-ddTHH:mm:ssz", "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-ddTHH:mmZ", "yyyy-MM-ddTHH:mmz", "yyyy-MM-ddTHH:mm", "ddd, MMM dd, yyyy H:mm:ss tt", "ddd MMM d yyyy HH:mm:ss zzz", "MMddyyyy", "ddMMyyyy", "Mddyyyy", "ddMyyyy", "Mdyyyy", "dMyyyy", "yyyy", "Mdyy", "dMyy", "d" ]); // real starting rule: tries selected formats first, // then general purpose rule g.start = function (s) { try { var r = g._formats.call({}, s); if (r[1].length === 0) { return r; } } catch (e) {} return g._start.call({}, s); }; }()); (function () { var $D = Date; /** * @desc Converts the specified string value into its JavaScript Date equivalent using CultureInfo specific format information. * * Example

	///////////
	// Dates //
	///////////

	// 15-Oct-2004
	var d1 = Date.parse("10/15/2004");

	// 15-Oct-2004
	var d1 = Date.parse("15-Oct-2004");

	// 15-Oct-2004
	var d1 = Date.parse("2004.10.15");

	//Fri Oct 15, 2004
	var d1 = Date.parse("Fri Oct 15, 2004");

	///////////
	// Times //
	///////////

	// Today at 10 PM.
	var d1 = Date.parse("10 PM");

	// Today at 10:30 PM.
	var d1 = Date.parse("10:30 P.M.");

	// Today at 6 AM.
	var d1 = Date.parse("06am");

	/////////////////////
	// Dates and Times //
	/////////////////////

	// 8-July-2004 @ 10:30 PM
	var d1 = Date.parse("July 8th, 2004, 10:30 PM");

	// 1-July-2004 @ 10:30 PM
	var d1 = Date.parse("2004-07-01T22:30:00");

	////////////////////
	// Relative Dates //
	////////////////////

	// Returns today's date. The string "today" is culture specific.
	var d1 = Date.parse("today");

	// Returns yesterday's date. The string "yesterday" is culture specific.
	var d1 = Date.parse("yesterday");

	// Returns the date of the next thursday.
	var d1 = Date.parse("Next thursday");

	// Returns the date of the most previous monday.
	var d1 = Date.parse("last monday");

	// Returns today's day + one year.
	var d1 = Date.parse("next year");

	///////////////
	// Date Math //
	///////////////

	// Today + 2 days
	var d1 = Date.parse("t+2");

	// Today + 2 days
	var d1 = Date.parse("today + 2 days");

	// Today + 3 months
	var d1 = Date.parse("t+3m");

	// Today - 1 year
	var d1 = Date.parse("today - 1 year");

	// Today - 1 year
	var d1 = Date.parse("t-1y"); 


	/////////////////////////////
	// Partial Dates and Times //
	/////////////////////////////

	// July 15th of this year.
	var d1 = Date.parse("July 15");

	// 15th day of current day and year.
	var d1 = Date.parse("15");

	// July 1st of current year at 10pm.
	var d1 = Date.parse("7/1 10pm");
	
* * @param {String} The string value to convert into a Date object [Required] * @return {Date} A Date object or null if the string cannot be converted into a Date. */ var parseUtils = { removeOrds: function (s) { ords = s.match(/\b(\d+)(?:st|nd|rd|th)\b/); // find ordinal matches s = ((ords && ords.length === 2) ? s.replace(ords[0], ords[1]) : s); return s; }, grammarParser: function (s) { var r = null; try { r = $D.Grammar.start.call({}, s.replace(/^\s*(\S*(\s+\S+)*)\s*$/, "$1")); } catch (e) { return null; } return ((r[1].length === 0) ? r[0] : null); }, nativeFallback: function(s) { var t; try { // ok we haven't parsed it, last ditch attempt with the built-in parser. t = Date._parse(s); return (t || t === 0) ? new Date(t) : null; } catch (e) { return null; } } }; function parse (s) { var d; if (!s) { return null; } if (s instanceof Date) { return s.clone(); } if (s.length >= 4 && s.charAt(0) !== "0" && s.charAt(0) !== "+"&& s.charAt(0) !== "-") { // ie: 2004 will pass, 0800 won't. // Start with specific formats d = $D.Parsing.ISO.parse(s) || $D.Parsing.Numeric.parse(s); } if (d instanceof Date && !isNaN(d.getTime())) { return d; } else { // find ordinal dates (1st, 3rd, 8th, etc and remove them as they cause parsing issues) s = $D.Parsing.Normalizer.parse(parseUtils.removeOrds(s)); d = parseUtils.grammarParser(s); if (d !== null) { return d; } else { return parseUtils.nativeFallback(s); } } } if (!$D._parse) { $D._parse = $D.parse; } $D.parse = parse; Date.getParseFunction = function (fx) { var fns = Date.Grammar.allformats(fx); return function (s) { var r = null; for (var i = 0; i < fns.length; i++) { try { r = fns[i].call({}, s); } catch (e) { continue; } if (r[1].length === 0) { return r[0]; } } return null; }; }; /** * Converts the specified string value into its JavaScript Date equivalent using the specified format {String} or formats {Array} and the CultureInfo specific format information. * The format of the string value must match one of the supplied formats exactly. * * Example

	// 15-Oct-2004
	var d1 = Date.parseExact("10/15/2004", "M/d/yyyy");

	// 15-Oct-2004
	var d1 = Date.parse("15-Oct-2004", "M-ddd-yyyy");

	// 15-Oct-2004
	var d1 = Date.parse("2004.10.15", "yyyy.MM.dd");

	// Multiple formats
	var d1 = Date.parseExact("10/15/2004", ["M/d/yyyy", "MMMM d, yyyy"]);
	
* * @param {String} The string value to convert into a Date object [Required]. * @param {Object} The expected format {String} or an array of expected formats {Array} of the date string [Required]. * @return {Date} A Date object or null if the string cannot be converted into a Date. */ $D.parseExact = function (s, fx) { return $D.getParseFunction(fx)(s); }; }()); (function () { var $D = Date, $P = $D.prototype, // $C = $D.CultureInfo, // not used atm p = function (s, l) { if (!l) { l = 2; } return ("000" + s).slice(l * -1); }; /** * Converts a PHP format string to Java/.NET format string. * A PHP format string can be used with ._format or .format. * A Java/.NET format string can be used with .toString(). * The .parseExact function will only accept a Java/.NET format string * * Example * var f1 = "%m/%d/%y" * var f2 = Date.normalizeFormat(f1); // "MM/dd/yy" * * new Date().format(f1); // "04/13/08" * new Date()._format(f1); // "04/13/08" * new Date().toString(f2); // "04/13/08" * * var date = Date.parseExact("04/13/08", f2); // Sun Apr 13 2008 * * @param {String} A PHP format string consisting of one or more format spcifiers. * @return {String} The PHP format converted to a Java/.NET format string. */ var normalizerSubstitutions = { "d" : "dd", "%d": "dd", "D" : "ddd", "%a": "ddd", "j" : "dddd", "l" : "dddd", "%A": "dddd", "S" : "S", "F" : "MMMM", "%B": "MMMM", "m" : "MM", "%m": "MM", "M" : "MMM", "%b": "MMM", "%h": "MMM", "n" : "M", "Y" : "yyyy", "%Y": "yyyy", "y" : "yy", "%y": "yy", "g" : "h", "%I": "h", "G" : "H", "h" : "hh", "H" : "HH", "%H": "HH", "i" : "mm", "%M": "mm", "s" : "ss", "%S": "ss", "%r": "hh:mm tt", "%R": "H:mm", "%T": "H:mm:ss", "%X": "t", "%x": "d", "%e": "d", "%D": "MM/dd/yy", "%n": "\\n", "%t": "\\t", "e" : "z", "T" : "z", "%z": "z", "%Z": "z", "Z" : "ZZ", "N" : "u", "w" : "u", "%w": "u", "W" : "W", "%V": "W" }; var normalizer = { substitutes: function (m) { return normalizerSubstitutions[m]; }, interpreted: function (m, x) { var y; switch (m) { case "%u": return x.getDay() + 1; case "z": return x.getOrdinalNumber(); case "%j": return p(x.getOrdinalNumber(), 3); case "%U": var d1 = x.clone().set({month: 0, day: 1}).addDays(-1).moveToDayOfWeek(0), d2 = x.clone().addDays(1).moveToDayOfWeek(0, -1); return (d2 < d1) ? "00" : p((d2.getOrdinalNumber() - d1.getOrdinalNumber()) / 7 + 1); case "%W": return p(x.getWeek()); case "t": return $D.getDaysInMonth(x.getFullYear(), x.getMonth()); case "o": case "%G": return x.setWeek(x.getISOWeek()).toString("yyyy"); case "%g": return x._format("%G").slice(-2); case "a": case "%p": return t("tt").toLowerCase(); case "A": return t("tt").toUpperCase(); case "u": return p(x.getMilliseconds(), 3); case "I": return (x.isDaylightSavingTime()) ? 1 : 0; case "O": return x.getUTCOffset(); case "P": y = x.getUTCOffset(); return y.substring(0, y.length - 2) + ":" + y.substring(y.length - 2); case "B": var now = new Date(); return Math.floor(((now.getHours() * 3600) + (now.getMinutes() * 60) + now.getSeconds() + (now.getTimezoneOffset() + 60) * 60) / 86.4); case "c": return x.toISOString().replace(/\"/g, ""); case "U": return $D.strtotime("now"); case "%c": return t("d") + " " + t("t"); case "%C": return Math.floor(x.getFullYear() / 100 + 1); } }, shouldOverrideDefaults: function (m) { switch (m) { case "%e": return true; default: return false; } }, parse: function (m, context) { var formatString, c = context || new Date(); formatString = normalizer.substitutes(m); if (formatString) { return formatString; } formatString = normalizer.interpreted(m, c); if (formatString) { return formatString; } else { return m; } } }; $D.normalizeFormat = function (format, context) { return format.replace(/(%|\\)?.|%%/g, function(t){ return normalizer.parse(t, context); }); }; /** * Format a local Unix timestamp according to locale settings * * Example: * Date.strftime("%m/%d/%y", new Date()); // "04/13/08" * Date.strftime("c", "2008-04-13T17:52:03Z"); // "04/13/08" * * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @param {Number|String} The number representing the number of seconds that have elapsed since January 1, 1970 (local time). * @return {String} A string representation of the current Date object. */ $D.strftime = function (format, time) { var d = Date.parse(time); return d._format(format); }; /** * Parse any textual datetime description into a Unix timestamp. * A Unix timestamp is the number of seconds that have elapsed since January 1, 1970 (midnight UTC/GMT). * * Example: * Date.strtotime("04/13/08"); // 1208044800 * Date.strtotime("1970-01-01T00:00:00Z"); // 0 * * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @param {Object} A string or date object. * @return {String} A string representation of the current Date object. */ $D.strtotime = function (time) { var d = $D.parse(time); return Math.round($D.UTC(d.getUTCFullYear(), d.getUTCMonth(), d.getUTCDate(), d.getUTCHours(), d.getUTCMinutes(), d.getUTCSeconds(), d.getUTCMilliseconds()) / 1000); }; /** * Converts the value of the current Date object to its equivalent string representation using a PHP/Unix style of date format specifiers. * Format Specifiers * Format Description Example * ------ --------------------------------------------------------------------------- ----------------------- * %a abbreviated weekday name according to the current localed "Mon" through "Sun" * %A full weekday name according to the current localed "Sunday" through "Saturday" * %b abbreviated month name according to the current localed "Jan" through "Dec" * %B full month name according to the current locale "January" through "December" * %c preferred date and time representation for the current locale "4/13/2008 12:33 PM" * %C century number (the year divided by 100 and truncated to an integer) "00" to "99" * %d day of the month as a decimal number "01" to "31" * %D same as %m/%d/%y "04/13/08" * %e day of the month as a decimal number, a single digit is preceded by a space "1" to "31" * %g like %G, but without the century "08" * %G The 4-digit year corresponding to the ISO week number (see %V). "2008" * This has the same format and value as %Y, except that if the ISO week number * belongs to the previous or next year, that year is used instead. * %h same as %b "Jan" through "Dec" * %H hour as a decimal number using a 24-hour clock. "00" to "23" * %I hour as a decimal number using a 12-hour clock. "01" to "12" * %j day of the year as a decimal number. "001" to "366" * %m month as a decimal number. "01" to "12" * %M minute as a decimal number. "00" to "59" * %n newline character "\n" * %p either "am" or "pm" according to the given time value, or the "am" or "pm" * corresponding strings for the current locale. * %r time in a.m. and p.m. notation "8:44 PM" * %R time in 24 hour notation "20:44" * %S second as a decimal number "00" to "59" * %t tab character "\t" * %T current time, equal to %H:%M:%S "12:49:11" * %u weekday as a decimal number ["1", "7"], with "1" representing Monday "1" to "7" * %U week number of the current year as a decimal number, starting with the "0" to ("52" or "53") * first Sunday as the first day of the first week * %V The ISO 8601:1988 week number of the current year as a decimal number, "00" to ("52" or "53") * range 01 to 53, where week 1 is the first week that has at least 4 days * in the current year, and with Monday as the first day of the week. * (Use %G or %g for the year component that corresponds to the week number * for the specified timestamp.) * %W week number of the current year as a decimal number, starting with the "00" to ("52" or "53") * first Monday as the first day of the first week * %w day of the week as a decimal, Sunday being "0" "0" to "6" * %x preferred date representation for the current locale without the time "4/13/2008" * %X preferred time representation for the current locale without the date "12:53:05" * %y year as a decimal number without a century "00" "99" * %Y year as a decimal number including the century "2008" * %Z time zone or name or abbreviation "UTC", "EST", "PST" * %z same as %Z * %% a literal "%" characters "%" * d Day of the month, 2 digits with leading zeros "01" to "31" * D A textual representation of a day, three letters "Mon" through "Sun" * j Day of the month without leading zeros "1" to "31" * l A full textual representation of the day of the week (lowercase "L") "Sunday" through "Saturday" * N ISO-8601 numeric representation of the day of the week (added in PHP 5.1.0) "1" (for Monday) through "7" (for Sunday) * S English ordinal suffix for the day of the month, 2 characters "st", "nd", "rd" or "th". Works well with j * w Numeric representation of the day of the week "0" (for Sunday) through "6" (for Saturday) * z The day of the year (starting from "0") "0" through "365" * W ISO-8601 week number of year, weeks starting on Monday "00" to ("52" or "53") * F A full textual representation of a month, such as January or March "January" through "December" * m Numeric representation of a month, with leading zeros "01" through "12" * M A short textual representation of a month, three letters "Jan" through "Dec" * n Numeric representation of a month, without leading zeros "1" through "12" * t Number of days in the given month "28" through "31" * L Whether it's a leap year "1" if it is a leap year, "0" otherwise * o ISO-8601 year number. This has the same value as Y, except that if the "2008" * ISO week number (W) belongs to the previous or next year, that year * is used instead. * Y A full numeric representation of a year, 4 digits "2008" * y A two digit representation of a year "08" * a Lowercase Ante meridiem and Post meridiem "am" or "pm" * A Uppercase Ante meridiem and Post meridiem "AM" or "PM" * B Swatch Internet time "000" through "999" * g 12-hour format of an hour without leading zeros "1" through "12" * G 24-hour format of an hour without leading zeros "0" through "23" * h 12-hour format of an hour with leading zeros "01" through "12" * H 24-hour format of an hour with leading zeros "00" through "23" * i Minutes with leading zeros "00" to "59" * s Seconds, with leading zeros "00" through "59" * u Milliseconds "54321" * e Timezone identifier "UTC", "EST", "PST" * I Whether or not the date is in daylight saving time (uppercase i) "1" if Daylight Saving Time, "0" otherwise * O Difference to Greenwich time (GMT) in hours "+0200", "-0600" * P Difference to Greenwich time (GMT) with colon between hours and minutes "+02:00", "-06:00" * T Timezone abbreviation "UTC", "EST", "PST" * Z Timezone offset in seconds. The offset for timezones west of UTC is "-43200" through "50400" * always negative, and for those east of UTC is always positive. * c ISO 8601 date "2004-02-12T15:19:21+00:00" * r RFC 2822 formatted date "Thu, 21 Dec 2000 16:01:07 +0200" * U Seconds since the Unix Epoch (January 1 1970 00:00:00 GMT) "0" * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @return {String} A string representation of the current Date object. */ var formatReplace = function (context) { return function (m) { var formatString, override = false; if (m.charAt(0) === "\\" || m.substring(0, 2) === "%%") { return m.replace("\\", "").replace("%%", "%"); } override = normalizer.shouldOverrideDefaults(m); formatString = $D.normalizeFormat(m, context); if (formatString) { return context.toString(formatString, override); } }; }; $P._format = function (format) { var formatter = formatReplace(this); if (!format) { return this._toString(); } else { return format.replace(/(%|\\)?.|%%/g, formatter); } }; if (!$P.format) { $P.format = $P._format; } }()); (function () { "use strict"; var gFn = function (attr) { return function () { return this[attr]; }; }; var sFn = function (attr) { return function (val) { this[attr] = val; return this; }; }; var attrs = ["years", "months", "days", "hours", "minutes", "seconds", "milliseconds"]; var addSetFuncs = function (context, attrs) { for (var i = 0; i < attrs.length ; i++) { var $a = attrs[i], $b = $a.slice(0, 1).toUpperCase() + $a.slice(1); context.prototype[$a] = 0; context.prototype["get" + $b] = gFn($a); context.prototype["set" + $b] = sFn($a); } }; /** * new TimeSpan(milliseconds); * new TimeSpan(days, hours, minutes, seconds); * new TimeSpan(days, hours, minutes, seconds, milliseconds); */ var TimeSpan = function (days, hours, minutes, seconds, milliseconds) { if (arguments.length === 1 && typeof days === "number") { var orient = (days < 0) ? -1 : +1; var millsLeft = Math.abs(days); this.setDays(Math.floor(millsLeft / 86400000) * orient); millsLeft = millsLeft % 86400000; this.setHours(Math.floor(millsLeft / 3600000) * orient); millsLeft = millsLeft % 3600000; this.setMinutes(Math.floor(millsLeft / 60000) * orient); millsLeft = millsLeft % 60000; this.setSeconds(Math.floor(millsLeft / 1000) * orient); millsLeft = millsLeft % 1000; this.setMilliseconds(millsLeft * orient); } else { this.set(days, hours, minutes, seconds, milliseconds); } this.getTotalMilliseconds = function () { return (this.getDays() * 86400000) + (this.getHours() * 3600000) + (this.getMinutes() * 60000) + (this.getSeconds() * 1000); }; this.compareTo = function (time) { var t1 = new Date(1970, 1, 1, this.getHours(), this.getMinutes(), this.getSeconds()), t2; if (time === null) { t2 = new Date(1970, 1, 1, 0, 0, 0); } else { t2 = new Date(1970, 1, 1, time.getHours(), time.getMinutes(), time.getSeconds()); } return (t1 < t2) ? -1 : (t1 > t2) ? 1 : 0; }; this.equals = function (time) { return (this.compareTo(time) === 0); }; this.add = function (time) { return (time === null) ? this : this.addSeconds(time.getTotalMilliseconds() / 1000); }; this.subtract = function (time) { return (time === null) ? this : this.addSeconds(-time.getTotalMilliseconds() / 1000); }; this.addDays = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 86400000)); }; this.addHours = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 3600000)); }; this.addMinutes = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 60000)); }; this.addSeconds = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 1000)); }; this.addMilliseconds = function (n) { return new TimeSpan(this.getTotalMilliseconds() + n); }; this.get12HourHour = function () { return (this.getHours() > 12) ? this.getHours() - 12 : (this.getHours() === 0) ? 12 : this.getHours(); }; this.getDesignator = function () { return (this.getHours() < 12) ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator; }; this.toString = function (format) { this._toString = function () { if (this.getDays() !== null && this.getDays() > 0) { return this.getDays() + "." + this.getHours() + ":" + this.p(this.getMinutes()) + ":" + this.p(this.getSeconds()); } else { return this.getHours() + ":" + this.p(this.getMinutes()) + ":" + this.p(this.getSeconds()); } }; this.p = function (s) { return (s.toString().length < 2) ? "0" + s : s; }; var me = this; return format ? format.replace(/dd?|HH?|hh?|mm?|ss?|tt?/g, function (format) { switch (format) { case "d": return me.getDays(); case "dd": return me.p(me.getDays()); case "H": return me.getHours(); case "HH": return me.p(me.getHours()); case "h": return me.get12HourHour(); case "hh": return me.p(me.get12HourHour()); case "m": return me.getMinutes(); case "mm": return me.p(me.getMinutes()); case "s": return me.getSeconds(); case "ss": return me.p(me.getSeconds()); case "t": return ((me.getHours() < 12) ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator).substring(0, 1); case "tt": return (me.getHours() < 12) ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator; } } ) : this._toString(); }; return this; }; addSetFuncs(TimeSpan, attrs.slice(2)); TimeSpan.prototype.set = function (days, hours, minutes, seconds, milliseconds){ this.setDays(days || this.getDays()); this.setHours(hours || this.getHours()); this.setMinutes(minutes || this.getMinutes()); this.setSeconds(seconds || this.getSeconds()); this.setMilliseconds(milliseconds || this.getMilliseconds()); }; /** * Gets the time of day for this date instances. * @return {TimeSpan} TimeSpan */ Date.prototype.getTimeOfDay = function () { return new TimeSpan(0, this.getHours(), this.getMinutes(), this.getSeconds(), this.getMilliseconds()); }; Date.TimeSpan = TimeSpan; if (typeof window !== "undefined" ) { // keeping API compatible for v1.x window.TimeSpan = TimeSpan; } }()); (function () { "use strict"; var attrs = ["years", "months", "days", "hours", "minutes", "seconds", "milliseconds"]; var gFn = function (attr) { return function () { return this[attr]; }; }; var sFn = function (attr) { return function (val) { this[attr] = val; return this; }; }; var addSetFuncs = function (context, attrs) { for (var i = 0; i < attrs.length ; i++) { var $a = attrs[i], $b = $a.slice(0, 1).toUpperCase() + $a.slice(1); context.prototype[$a] = 0; context.prototype["get" + $b] = gFn($a); context.prototype["set" + $b] = sFn($a); } }; var setMonthsAndYears = function (orient, d1, d2, context) { function inc() { d1.addMonths(-orient); context.months++; if (context.months === 12) { context.years++; context.months = 0; } } if (orient === +1) { while (d1 > d2) { inc(); } } else { while (d1 < d2) { inc(); } } context.months--; context.months *= orient; context.years *= orient; }; var adjustForDST = function(orient, startDate, endDate) { var hasDSTMismatch = (false === (startDate.isDaylightSavingTime() === endDate.isDaylightSavingTime())); if (hasDSTMismatch && orient === 1) { startDate.addHours(-1); } else if (hasDSTMismatch) { startDate.addHours(1); } }; /** * TimePeriod(startDate, endDate); * TimePeriod(years, months, days, hours, minutes, seconds, milliseconds); */ var TimePeriod = function (years, months, days, hours, minutes, seconds, milliseconds) { if (arguments.length === 7) { this.set(years, months, days, hours, minutes, seconds, milliseconds); } else if (arguments.length === 2 && arguments[0] instanceof Date && arguments[1] instanceof Date) { var startDate = arguments[0].clone(); var endDate = arguments[1].clone(); var orient = (startDate > endDate) ? +1 : -1; this.dates = { start: arguments[0].clone(), end: arguments[1].clone() }; setMonthsAndYears(orient, startDate, endDate, this); adjustForDST(orient, startDate, endDate); // // TODO - adjust for DST var diff = endDate - startDate; if (diff !== 0) { var ts = new TimeSpan(diff); this.set(this.years, this.months, ts.getDays(), ts.getHours(), ts.getMinutes(), ts.getSeconds(), ts.getMilliseconds()); } } return this; }; // create all the set functions. addSetFuncs(TimePeriod, attrs); TimePeriod.prototype.set = function (years, months, days, hours, minutes, seconds, milliseconds){ this.setYears(years || this.getYears()); this.setMonths(months || this.getMonths()); this.setDays(days || this.getDays()); this.setHours(hours || this.getHours()); this.setMinutes(minutes || this.getMinutes()); this.setSeconds(seconds || this.getSeconds()); this.setMilliseconds(milliseconds || this.getMilliseconds()); }; Date.TimePeriod = TimePeriod; if (typeof window !== "undefined") { // keeping API compatible for v1.x window.TimePeriod = TimePeriod; } }()); ================================================ FILE: build/date-da-DK.js ================================================ /** * @overview datejs * @version 1.0.0-rc3 * @author Gregory Wild-Smith * @copyright 2015 Gregory Wild-Smith * @license MIT * @homepage https://github.com/abritinthebay/datejs */ /* * DateJS Culture String File * Country Code: da-DK * Name: Danish (Denmark) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["da-DK"] = { "name": "da-DK", "englishName": "Danish (Denmark)", "nativeName": "dansk (Danmark)", "Sunday": "søndag", "Monday": "mandag", "Tuesday": "tirsdag", "Wednesday": "onsdag", "Thursday": "torsdag", "Friday": "fredag", "Saturday": "lørdag", "Sun": "sø", "Mon": "ma", "Tue": "ti", "Wed": "on", "Thu": "to", "Fri": "fr", "Sat": "lø", "Su": "sø", "Mo": "ma", "Tu": "ti", "We": "on", "Th": "to", "Fr": "fr", "Sa": "lø", "S_Sun_Initial": "s", "M_Mon_Initial": "m", "T_Tue_Initial": "t", "W_Wed_Initial": "o", "T_Thu_Initial": "t", "F_Fri_Initial": "f", "S_Sat_Initial": "l", "January": "januar", "February": "februar", "March": "marts", "April": "april", "May": "maj", "June": "juni", "July": "juli", "August": "august", "September": "september", "October": "oktober", "November": "november", "December": "december", "Jan_Abbr": "jan", "Feb_Abbr": "feb", "Mar_Abbr": "mar", "Apr_Abbr": "apr", "May_Abbr": "maj", "Jun_Abbr": "jun", "Jul_Abbr": "jul", "Aug_Abbr": "aug", "Sep_Abbr": "sep", "Oct_Abbr": "okt", "Nov_Abbr": "nov", "Dec_Abbr": "dec", "AM": "", "PM": "", "firstDayOfWeek": 1, "twoDigitYearMax": 2029, "mdy": "dmy", "M/d/yyyy": "dd-MM-yyyy", "dddd, MMMM dd, yyyy": "d. MMMM yyyy", "h:mm tt": "HH:mm", "h:mm:ss tt": "HH:mm:ss", "dddd, MMMM dd, yyyy h:mm:ss tt": "d. MMMM yyyy HH:mm:ss", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "d. MMMM", "MMMM, yyyy": "MMMM yyyy", "/jan(uary)?/": "jan(uar)?", "/feb(ruary)?/": "feb(ruar)?", "/mar(ch)?/": "mar(ts)?", "/apr(il)?/": "apr(il)?", "/may/": "maj", "/jun(e)?/": "jun(i)?", "/jul(y)?/": "jul(i)?", "/aug(ust)?/": "aug(ust)?", "/sep(t(ember)?)?/": "sep(t(ember)?)?", "/oct(ober)?/": "okt(ober)?", "/nov(ember)?/": "nov(ember)?", "/dec(ember)?/": "dec(ember)?", "/^su(n(day)?)?/": "^søndag", "/^mo(n(day)?)?/": "^mandag", "/^tu(e(s(day)?)?)?/": "^tirsdag", "/^we(d(nesday)?)?/": "^onsdag", "/^th(u(r(s(day)?)?)?)?/": "^torsdag", "/^fr(i(day)?)?/": "^fredag", "/^sa(t(urday)?)?/": "^lørdag", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "da-DK"; /** * @overview datejs * @version 1.0.0-rc3 * @author Gregory Wild-Smith * @copyright 2015 Gregory Wild-Smith * @license MIT * @homepage https://github.com/abritinthebay/datejs */(function () { var $D = Date; var lang = Date.CultureStrings ? Date.CultureStrings.lang : null; var loggedKeys = {}; // for debug purposes. var getText = { getFromKey: function (key, countryCode) { var output; if (Date.CultureStrings && Date.CultureStrings[countryCode] && Date.CultureStrings[countryCode][key]) { output = Date.CultureStrings[countryCode][key]; } else { output = getText.buildFromDefault(key); } if (key.charAt(0) === "/") { // Assume it's a regex output = getText.buildFromRegex(key, countryCode); } return output; }, getFromObjectValues: function (obj, countryCode) { var key, output = {}; for(key in obj) { if (obj.hasOwnProperty(key)) { output[key] = getText.getFromKey(obj[key], countryCode); } } return output; }, getFromObjectKeys: function (obj, countryCode) { var key, output = {}; for(key in obj) { if (obj.hasOwnProperty(key)) { output[getText.getFromKey(key, countryCode)] = obj[key]; } } return output; }, getFromArray: function (arr, countryCode) { var output = []; for (var i=0; i < arr.length; i++){ if (i in arr) { output[i] = getText.getFromKey(arr[i], countryCode); } } return output; }, buildFromDefault: function (key) { var output, length, split, last; switch(key) { case "name": output = "en-US"; break; case "englishName": output = "English (United States)"; break; case "nativeName": output = "English (United States)"; break; case "twoDigitYearMax": output = 2049; break; case "firstDayOfWeek": output = 0; break; default: output = key; split = key.split("_"); length = split.length; if (length > 1 && key.charAt(0) !== "/") { // if the key isn't a regex and it has a split. last = split[(length - 1)].toLowerCase(); if (last === "initial" || last === "abbr") { output = split[0]; } } break; } return output; }, buildFromRegex: function (key, countryCode) { var output; if (Date.CultureStrings && Date.CultureStrings[countryCode] && Date.CultureStrings[countryCode][key]) { output = new RegExp(Date.CultureStrings[countryCode][key], "i"); } else { output = new RegExp(key.replace(new RegExp("/", "g"),""), "i"); } return output; } }; var shallowMerge = function (obj1, obj2) { for (var attrname in obj2) { if (obj2.hasOwnProperty(attrname)) { obj1[attrname] = obj2[attrname]; } } }; var __ = function (key, language) { var countryCode = (language) ? language : lang; loggedKeys[key] = key; if (typeof key === "object") { if (key instanceof Array) { return getText.getFromArray(key, countryCode); } else { return getText.getFromObjectKeys(key, countryCode); } } else { return getText.getFromKey(key, countryCode); } }; var loadI18nScript = function (code) { // paatterned after jQuery's getScript. var url = Date.Config.i18n + code + ".js"; var head = document.getElementsByTagName("head")[0] || document.documentElement; var script = document.createElement("script"); script.src = url; var completed = false; var events = { done: function (){} // placeholder function }; // Attach handlers for all browsers script.onload = script.onreadystatechange = function() { if ( !completed && (!this.readyState || this.readyState === "loaded" || this.readyState === "complete") ) { events.done(); head.removeChild(script); } }; setTimeout(function() { head.insertBefore(script, head.firstChild); }, 0); // allows return to execute first return { done: function (cb) { events.done = function() { if (cb) { setTimeout(cb,0); } }; } }; }; var buildInfo = { buildFromMethodHash: function (obj) { var key; for(key in obj) { if (obj.hasOwnProperty(key)) { obj[key] = buildInfo[obj[key]](); } } return obj; }, timeZoneDST: function () { var DST = { "CHADT": "+1345", "NZDT": "+1300", "AEDT": "+1100", "ACDT": "+1030", "AZST": "+0500", "IRDT": "+0430", "EEST": "+0300", "CEST": "+0200", "BST": "+0100", "PMDT": "-0200", "ADT": "-0300", "NDT": "-0230", "EDT": "-0400", "CDT": "-0500", "MDT": "-0600", "PDT": "-0700", "AKDT": "-0800", "HADT": "-0900" }; return __(DST); }, timeZoneStandard: function () { var standard = { "LINT": "+1400", "TOT": "+1300", "CHAST": "+1245", "NZST": "+1200", "NFT": "+1130", "SBT": "+1100", "AEST": "+1000", "ACST": "+0930", "JST": "+0900", "CWST": "+0845", "CT": "+0800", "ICT": "+0700", "MMT": "+0630", "BST": "+0600", "NPT": "+0545", "IST": "+0530", "PKT": "+0500", "AFT": "+0430", "MSK": "+0400", "IRST": "+0330", "FET": "+0300", "EET": "+0200", "CET": "+0100", "GMT": "+0000", "UTC": "+0000", "CVT": "-0100", "GST": "-0200", "BRT": "-0300", "NST": "-0330", "AST": "-0400", "EST": "-0500", "CST": "-0600", "MST": "-0700", "PST": "-0800", "AKST": "-0900", "MIT": "-0930", "HST": "-1000", "SST": "-1100", "BIT": "-1200" }; return __(standard); }, timeZones: function (data) { var zone; data.timezones = []; for (zone in data.abbreviatedTimeZoneStandard) { if (data.abbreviatedTimeZoneStandard.hasOwnProperty(zone)) { data.timezones.push({ name: zone, offset: data.abbreviatedTimeZoneStandard[zone]}); } } for (zone in data.abbreviatedTimeZoneDST) { if (data.abbreviatedTimeZoneDST.hasOwnProperty(zone)) { data.timezones.push({ name: zone, offset: data.abbreviatedTimeZoneDST[zone], dst: true}); } } return data.timezones; }, days: function () { return __(["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"]); }, dayAbbr: function () { return __(["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"]); }, dayShortNames: function () { return __(["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"]); }, dayFirstLetters: function () { return __(["S_Sun_Initial", "M_Mon_Initial", "T_Tues_Initial", "W_Wed_Initial", "T_Thu_Initial", "F_Fri_Initial", "S_Sat_Initial"]); }, months: function () { return __(["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"]); }, monthAbbr: function () { return __(["Jan_Abbr", "Feb_Abbr", "Mar_Abbr", "Apr_Abbr", "May_Abbr", "Jun_Abbr", "Jul_Abbr", "Aug_Abbr", "Sep_Abbr", "Oct_Abbr", "Nov_Abbr", "Dec_Abbr"]); }, formatPatterns: function () { return getText.getFromObjectValues({ shortDate: "M/d/yyyy", longDate: "dddd, MMMM dd, yyyy", shortTime: "h:mm tt", longTime: "h:mm:ss tt", fullDateTime: "dddd, MMMM dd, yyyy h:mm:ss tt", sortableDateTime: "yyyy-MM-ddTHH:mm:ss", universalSortableDateTime: "yyyy-MM-dd HH:mm:ssZ", rfc1123: "ddd, dd MMM yyyy HH:mm:ss", monthDay: "MMMM dd", yearMonth: "MMMM, yyyy" }, Date.i18n.currentLanguage()); }, regex: function () { return getText.getFromObjectValues({ inTheMorning: "/( in the )(morn(ing)?)\\b/", thisMorning: "/(this )(morn(ing)?)\\b/", amThisMorning: "/(\b\\d(am)? )(this )(morn(ing)?)/", inTheEvening: "/( in the )(even(ing)?)\\b/", thisEvening: "/(this )(even(ing)?)\\b/", pmThisEvening: "/(\b\\d(pm)? )(this )(even(ing)?)/", jan: "/jan(uary)?/", feb: "/feb(ruary)?/", mar: "/mar(ch)?/", apr: "/apr(il)?/", may: "/may/", jun: "/jun(e)?/", jul: "/jul(y)?/", aug: "/aug(ust)?/", sep: "/sep(t(ember)?)?/", oct: "/oct(ober)?/", nov: "/nov(ember)?/", dec: "/dec(ember)?/", sun: "/^su(n(day)?)?/", mon: "/^mo(n(day)?)?/", tue: "/^tu(e(s(day)?)?)?/", wed: "/^we(d(nesday)?)?/", thu: "/^th(u(r(s(day)?)?)?)?/", fri: "/fr(i(day)?)?/", sat: "/^sa(t(urday)?)?/", future: "/^next/", past: "/^last|past|prev(ious)?/", add: "/^(\\+|aft(er)?|from|hence)/", subtract: "/^(\\-|bef(ore)?|ago)/", yesterday: "/^yes(terday)?/", today: "/^t(od(ay)?)?/", tomorrow: "/^tom(orrow)?/", now: "/^n(ow)?/", millisecond: "/^ms|milli(second)?s?/", second: "/^sec(ond)?s?/", minute: "/^mn|min(ute)?s?/", hour: "/^h(our)?s?/", week: "/^w(eek)?s?/", month: "/^m(onth)?s?/", day: "/^d(ay)?s?/", year: "/^y(ear)?s?/", shortMeridian: "/^(a|p)/", longMeridian: "/^(a\\.?m?\\.?|p\\.?m?\\.?)/", timezone: "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/", ordinalSuffix: "/^\\s*(st|nd|rd|th)/", timeContext: "/^\\s*(\\:|a(?!u|p)|p)/" }, Date.i18n.currentLanguage()); } }; var CultureInfo = function () { var info = getText.getFromObjectValues({ name: "name", englishName: "englishName", nativeName: "nativeName", amDesignator: "AM", pmDesignator: "PM", firstDayOfWeek: "firstDayOfWeek", twoDigitYearMax: "twoDigitYearMax", dateElementOrder: "mdy" }, Date.i18n.currentLanguage()); var constructedInfo = buildInfo.buildFromMethodHash({ dayNames: "days", abbreviatedDayNames: "dayAbbr", shortestDayNames: "dayShortNames", firstLetterDayNames: "dayFirstLetters", monthNames: "months", abbreviatedMonthNames: "monthAbbr", formatPatterns: "formatPatterns", regexPatterns: "regex", abbreviatedTimeZoneDST: "timeZoneDST", abbreviatedTimeZoneStandard: "timeZoneStandard" }); shallowMerge(info, constructedInfo); buildInfo.timeZones(info); return info; }; $D.i18n = { __: function (key, lang) { return __(key, lang); }, currentLanguage: function () { return lang || "en-US"; }, setLanguage: function (code, force, cb) { var async = false; if (force || code === "en-US" || (!!Date.CultureStrings && !!Date.CultureStrings[code])) { lang = code; Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings.lang = code; Date.CultureInfo = new CultureInfo(); } else { if (!(!!Date.CultureStrings && !!Date.CultureStrings[code])) { if (typeof exports !== "undefined" && this.exports !== exports) { // we're in a Node enviroment, load it using require try { require("../i18n/" + code + ".js"); lang = code; Date.CultureStrings.lang = code; Date.CultureInfo = new CultureInfo(); } catch (e) { // var str = "The language for '" + code + "' could not be loaded by Node. It likely does not exist."; throw new Error("The DateJS IETF language tag '" + code + "' could not be loaded by Node. It likely does not exist."); } } else if (Date.Config && Date.Config.i18n) { // we know the location of the files, so lets load them async = true; loadI18nScript(code).done(function(){ lang = code; Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings.lang = code; Date.CultureInfo = new CultureInfo(); $D.Parsing.Normalizer.buildReplaceData(); // because this is async if ($D.Grammar) { $D.Grammar.buildGrammarFormats(); // so we can parse those strings... } if (cb) { setTimeout(cb,0); } }); } else { Date.console.error("The DateJS IETF language tag '" + code + "' is not available and has not been loaded."); return false; } } } $D.Parsing.Normalizer.buildReplaceData(); // rebuild normalizer strings if ($D.Grammar) { $D.Grammar.buildGrammarFormats(); // so we can parse those strings... } if (!async && cb) { setTimeout(cb,0); } }, getLoggedKeys: function () { return loggedKeys; }, updateCultureInfo: function () { Date.CultureInfo = new CultureInfo(); } }; $D.i18n.updateCultureInfo(); // run automatically }()); (function () { var $D = Date, $P = $D.prototype, p = function (s, l) { if (!l) { l = 2; } return ("000" + s).slice(l * -1); }; if (typeof window !== "undefined" && typeof window.console !== "undefined" && typeof window.console.log !== "undefined") { $D.console = console; // used only to raise non-critical errors if available } else { // set mock so we don't give errors. $D.console = { log: function(){}, error: function(){} }; } $D.Config = $D.Config || {}; $D.initOverloads = function() { /** * Overload of Date.now. Allows an alternate call for Date.now where it returns the * current Date as an object rather than just milliseconds since the Unix Epoch. * * Also provides an implementation of now() for browsers (IE<9) that don't have it. * * Backwards compatible so with work with either: * Date.now() [returns ms] * or * Date.now(true) [returns Date] */ if (!$D.now) { $D._now = function now() { return new Date().getTime(); }; } else if (!$D._now) { $D._now = $D.now; } $D.now = function (returnObj) { if (returnObj) { return $D.present(); } else { return $D._now(); } }; if ( !$P.toISOString ) { $P.toISOString = function() { return this.getUTCFullYear() + "-" + p(this.getUTCMonth() + 1) + "-" + p(this.getUTCDate()) + "T" + p(this.getUTCHours()) + ":" + p(this.getUTCMinutes()) + ":" + p(this.getUTCSeconds()) + "." + String( (this.getUTCMilliseconds()/1000).toFixed(3)).slice(2, 5) + "Z"; }; } // private if ( $P._toString === undefined ){ $P._toString = $P.toString; } }; $D.initOverloads(); /** * Gets a date that is set to the current date. The time is set to the start of the day (00:00 or 12:00 AM). * @return {Date} The current date. */ $D.today = function () { return new Date().clearTime(); }; /** * Gets a date that is set to the current date and time (same as new Date, but chainable) * @return {Date} The current date. */ $D.present = function () { return new Date(); }; /** * Compares the first date to the second date and returns an number indication of their relative values. * @param {Date} First Date object to compare [Required]. * @param {Date} Second Date object to compare to [Required]. * @return {Number} -1 = date1 is lessthan date2. 0 = values are equal. 1 = date1 is greaterthan date2. */ $D.compare = function (date1, date2) { if (isNaN(date1) || isNaN(date2)) { throw new Error(date1 + " - " + date2); } else if (date1 instanceof Date && date2 instanceof Date) { return (date1 < date2) ? -1 : (date1 > date2) ? 1 : 0; } else { throw new TypeError(date1 + " - " + date2); } }; /** * Compares the first Date object to the second Date object and returns true if they are equal. * @param {Date} First Date object to compare [Required] * @param {Date} Second Date object to compare to [Required] * @return {Boolean} true if dates are equal. false if they are not equal. */ $D.equals = function (date1, date2) { return (date1.compareTo(date2) === 0); }; /** * Gets the language appropriate day name when given the day number(0-6) * eg - 0 == Sunday * @return {String} The day name */ $D.getDayName = function (n) { return Date.CultureInfo.dayNames[n]; }; /** * Gets the day number (0-6) if given a CultureInfo specific string which is a valid dayName, abbreviatedDayName or shortestDayName (two char). * @param {String} The name of the day (eg. "Monday, "Mon", "tuesday", "tue", "We", "we"). * @return {Number} The day number */ $D.getDayNumberFromName = function (name) { var n = Date.CultureInfo.dayNames, m = Date.CultureInfo.abbreviatedDayNames, o = Date.CultureInfo.shortestDayNames, s = name.toLowerCase(); for (var i = 0; i < n.length; i++) { if (n[i].toLowerCase() === s || m[i].toLowerCase() === s || o[i].toLowerCase() === s) { return i; } } return -1; }; /** * Gets the month number (0-11) if given a Culture Info specific string which is a valid monthName or abbreviatedMonthName. * @param {String} The name of the month (eg. "February, "Feb", "october", "oct"). * @return {Number} The day number */ $D.getMonthNumberFromName = function (name) { var n = Date.CultureInfo.monthNames, m = Date.CultureInfo.abbreviatedMonthNames, s = name.toLowerCase(); for (var i = 0; i < n.length; i++) { if (n[i].toLowerCase() === s || m[i].toLowerCase() === s) { return i; } } return -1; }; /** * Gets the language appropriate month name when given the month number(0-11) * eg - 0 == January * @return {String} The month name */ $D.getMonthName = function (n) { return Date.CultureInfo.monthNames[n]; }; /** * Determines if the current date instance is within a LeapYear. * @param {Number} The year. * @return {Boolean} true if date is within a LeapYear, otherwise false. */ $D.isLeapYear = function (year) { return ((year % 4 === 0 && year % 100 !== 0) || year % 400 === 0); }; /** * Gets the number of days in the month, given a year and month value. Automatically corrects for LeapYear. * @param {Number} The year. * @param {Number} The month (0-11). * @return {Number} The number of days in the month. */ $D.getDaysInMonth = function (year, month) { if (!month && $D.validateMonth(year)) { month = year; year = Date.today().getFullYear(); } return [31, ($D.isLeapYear(year) ? 29 : 28), 31, 30, 31, 30, 31, 31, 30, 31, 30, 31][month]; }; $P.getDaysInMonth = function () { return $D.getDaysInMonth(this.getFullYear(), this.getMonth()); }; $D.getTimezoneAbbreviation = function (offset, dst) { var p, n = (dst || false) ? Date.CultureInfo.abbreviatedTimeZoneDST : Date.CultureInfo.abbreviatedTimeZoneStandard; for (p in n) { if (n.hasOwnProperty(p)) { if (n[p] === offset) { return p; } } } return null; }; $D.getTimezoneOffset = function (name, dst) { var i, a =[], z = Date.CultureInfo.timezones; if (!name) { name = (new Date()).getTimezone();} for (i = 0; i < z.length; i++) { if (z[i].name === name.toUpperCase()) { a.push(i); } } if (!z[a[0]]) { return null; } if (a.length === 1 || !dst) { return z[a[0]].offset; } else { for (i=0; i < a.length; i++) { if (z[a[i]].dst) { return z[a[i]].offset; } } } }; $D.getQuarter = function (d) { d = d || new Date(); // If no date supplied, use today var q = [1,2,3,4]; return q[Math.floor(d.getMonth() / 3)]; // ~~~ is a bitwise op. Faster than Math.floor }; $D.getDaysLeftInQuarter = function (d) { d = d || new Date(); var qEnd = new Date(d); qEnd.setMonth(qEnd.getMonth() + 3 - qEnd.getMonth() % 3, 0); return Math.floor((qEnd - d) / 8.64e7); }; // private var validate = function (n, min, max, name) { name = name ? name : "Object"; if (typeof n === "undefined") { return false; } else if (typeof n !== "number") { throw new TypeError(n + " is not a Number."); } else if (n < min || n > max) { // As failing validation is *not* an exceptional circumstance // lets not throw a RangeError Exception here. // It's semantically correct but it's not sensible. return false; } return true; }; /** * Validates the number is within an acceptable range for milliseconds [0-999]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateMillisecond = function (value) { return validate(value, 0, 999, "millisecond"); }; /** * Validates the number is within an acceptable range for seconds [0-59]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateSecond = function (value) { return validate(value, 0, 59, "second"); }; /** * Validates the number is within an acceptable range for minutes [0-59]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateMinute = function (value) { return validate(value, 0, 59, "minute"); }; /** * Validates the number is within an acceptable range for hours [0-23]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateHour = function (value) { return validate(value, 0, 23, "hour"); }; /** * Validates the number is within an acceptable range for the days in a month [0-MaxDaysInMonth]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateDay = function (value, year, month) { if (year === undefined || year === null || month === undefined || month === null) { return false;} return validate(value, 1, $D.getDaysInMonth(year, month), "day"); }; /** * Validates the number is within an acceptable range for months [0-11]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateWeek = function (value) { return validate(value, 0, 53, "week"); }; /** * Validates the number is within an acceptable range for months [0-11]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateMonth = function (value) { return validate(value, 0, 11, "month"); }; /** * Validates the number is within an acceptable range for years. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateYear = function (value) { /** * Per ECMAScript spec the range of times supported by Date objects is * exactly -100,000,000 days to +100,000,000 days measured relative to * midnight at the beginning of 01 January, 1970 UTC. * This gives a range of 8,640,000,000,000,000 milliseconds to either * side of 01 January, 1970 UTC. * * Earliest possible date: Tue, 20 Apr 271,822 B.C. 00:00:00 UTC * Latest possible date: Sat, 13 Sep 275,760 00:00:00 UTC */ return validate(value, -271822, 275760, "year"); }; $D.validateTimezone = function(value) { var timezones = {"ACDT":1,"ACST":1,"ACT":1,"ADT":1,"AEDT":1,"AEST":1,"AFT":1,"AKDT":1,"AKST":1,"AMST":1,"AMT":1,"ART":1,"AST":1,"AWDT":1,"AWST":1,"AZOST":1,"AZT":1,"BDT":1,"BIOT":1,"BIT":1,"BOT":1,"BRT":1,"BST":1,"BTT":1,"CAT":1,"CCT":1,"CDT":1,"CEDT":1,"CEST":1,"CET":1,"CHADT":1,"CHAST":1,"CHOT":1,"ChST":1,"CHUT":1,"CIST":1,"CIT":1,"CKT":1,"CLST":1,"CLT":1,"COST":1,"COT":1,"CST":1,"CT":1,"CVT":1,"CWST":1,"CXT":1,"DAVT":1,"DDUT":1,"DFT":1,"EASST":1,"EAST":1,"EAT":1,"ECT":1,"EDT":1,"EEDT":1,"EEST":1,"EET":1,"EGST":1,"EGT":1,"EIT":1,"EST":1,"FET":1,"FJT":1,"FKST":1,"FKT":1,"FNT":1,"GALT":1,"GAMT":1,"GET":1,"GFT":1,"GILT":1,"GIT":1,"GMT":1,"GST":1,"GYT":1,"HADT":1,"HAEC":1,"HAST":1,"HKT":1,"HMT":1,"HOVT":1,"HST":1,"ICT":1,"IDT":1,"IOT":1,"IRDT":1,"IRKT":1,"IRST":1,"IST":1,"JST":1,"KGT":1,"KOST":1,"KRAT":1,"KST":1,"LHST":1,"LINT":1,"MAGT":1,"MART":1,"MAWT":1,"MDT":1,"MET":1,"MEST":1,"MHT":1,"MIST":1,"MIT":1,"MMT":1,"MSK":1,"MST":1,"MUT":1,"MVT":1,"MYT":1,"NCT":1,"NDT":1,"NFT":1,"NPT":1,"NST":1,"NT":1,"NUT":1,"NZDT":1,"NZST":1,"OMST":1,"ORAT":1,"PDT":1,"PET":1,"PETT":1,"PGT":1,"PHOT":1,"PHT":1,"PKT":1,"PMDT":1,"PMST":1,"PONT":1,"PST":1,"PYST":1,"PYT":1,"RET":1,"ROTT":1,"SAKT":1,"SAMT":1,"SAST":1,"SBT":1,"SCT":1,"SGT":1,"SLST":1,"SRT":1,"SST":1,"SYOT":1,"TAHT":1,"THA":1,"TFT":1,"TJT":1,"TKT":1,"TLT":1,"TMT":1,"TOT":1,"TVT":1,"UCT":1,"ULAT":1,"UTC":1,"UYST":1,"UYT":1,"UZT":1,"VET":1,"VLAT":1,"VOLT":1,"VOST":1,"VUT":1,"WAKT":1,"WAST":1,"WAT":1,"WEDT":1,"WEST":1,"WET":1,"WST":1,"YAKT":1,"YEKT":1,"Z":1}; return (timezones[value] === 1); }; $D.validateTimezoneOffset= function(value) { // timezones go from +14hrs to -12hrs, the +X hours are negative offsets. return (value > -841 && value < 721); }; }()); (function () { var $D = Date, $P = $D.prototype, p = function (s, l) { if (!l) { l = 2; } return ("000" + s).slice(l * -1); }; var validateConfigObject = function (obj) { var result = {}, self = this, prop, testFunc; testFunc = function (prop, func, value) { if (prop === "day") { var month = (obj.month !== undefined) ? obj.month : self.getMonth(); var year = (obj.year !== undefined) ? obj.year : self.getFullYear(); return $D[func](value, year, month); } else { return $D[func](value); } }; for (prop in obj) { if (Object.prototype.hasOwnProperty.call(obj, prop)) { var func = "validate" + prop.charAt(0).toUpperCase() + prop.slice(1); if ($D[func] && obj[prop] !== null && testFunc(prop, func, obj[prop])) { result[prop] = obj[prop]; } } } return result; }; /** * Resets the time of this Date object to 12:00 AM (00:00), which is the start of the day. * @param {Boolean} .clone() this date instance before clearing Time * @return {Date} this */ $P.clearTime = function () { this.setHours(0); this.setMinutes(0); this.setSeconds(0); this.setMilliseconds(0); return this; }; /** * Resets the time of this Date object to the current time ('now'). * @return {Date} this */ $P.setTimeToNow = function () { var n = new Date(); this.setHours(n.getHours()); this.setMinutes(n.getMinutes()); this.setSeconds(n.getSeconds()); this.setMilliseconds(n.getMilliseconds()); return this; }; /** * Returns a new Date object that is an exact date and time copy of the original instance. * @return {Date} A new Date instance */ $P.clone = function () { return new Date(this.getTime()); }; /** * Compares this instance to a Date object and returns an number indication of their relative values. * @param {Date} Date object to compare [Required] * @return {Number} -1 = this is lessthan date. 0 = values are equal. 1 = this is greaterthan date. */ $P.compareTo = function (date) { return Date.compare(this, date); }; /** * Compares this instance to another Date object and returns true if they are equal. * @param {Date} Date object to compare. If no date to compare, new Date() [now] is used. * @return {Boolean} true if dates are equal. false if they are not equal. */ $P.equals = function (date) { return Date.equals(this, (date !== undefined ? date : new Date())); }; /** * Determines if this instance is between a range of two dates or equal to either the start or end dates. * @param {Date} Start of range [Required] * @param {Date} End of range [Required] * @return {Boolean} true is this is between or equal to the start and end dates, else false */ $P.between = function (start, end) { return this.getTime() >= start.getTime() && this.getTime() <= end.getTime(); }; /** * Determines if this date occurs after the date to compare to. * @param {Date} Date object to compare. If no date to compare, new Date() ("now") is used. * @return {Boolean} true if this date instance is greater than the date to compare to (or "now"), otherwise false. */ $P.isAfter = function (date) { return this.compareTo(date || new Date()) === 1; }; /** * Determines if this date occurs before the date to compare to. * @param {Date} Date object to compare. If no date to compare, new Date() ("now") is used. * @return {Boolean} true if this date instance is less than the date to compare to (or "now"). */ $P.isBefore = function (date) { return (this.compareTo(date || new Date()) === -1); }; /** * Determines if the current Date instance occurs today. * @return {Boolean} true if this date instance is 'today', otherwise false. */ /** * Determines if the current Date instance occurs on the same Date as the supplied 'date'. * If no 'date' to compare to is provided, the current Date instance is compared to 'today'. * @param {date} Date object to compare. If no date to compare, the current Date ("now") is used. * @return {Boolean} true if this Date instance occurs on the same Day as the supplied 'date'. */ $P.isToday = $P.isSameDay = function (date) { return this.clone().clearTime().equals((date || new Date()).clone().clearTime()); }; /** * Adds the specified number of milliseconds to this instance. * @param {Number} The number of milliseconds to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addMilliseconds = function (value) { if (!value) { return this; } this.setTime(this.getTime() + value * 1); return this; }; /** * Adds the specified number of seconds to this instance. * @param {Number} The number of seconds to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addSeconds = function (value) { if (!value) { return this; } return this.addMilliseconds(value * 1000); }; /** * Adds the specified number of seconds to this instance. * @param {Number} The number of seconds to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addMinutes = function (value) { if (!value) { return this; } return this.addMilliseconds(value * 60000); // 60*1000 }; /** * Adds the specified number of hours to this instance. * @param {Number} The number of hours to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addHours = function (value) { if (!value) { return this; } return this.addMilliseconds(value * 3600000); // 60*60*1000 }; /** * Adds the specified number of days to this instance. * @param {Number} The number of days to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addDays = function (value) { if (!value) { return this; } this.setDate(this.getDate() + value * 1); return this; }; /** * Adds the specified number of weekdays (ie - not sat or sun) to this instance. * @param {Number} The number of days to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addWeekdays = function (value) { if (!value) { return this; } var day = this.getDay(); var weeks = (Math.ceil(Math.abs(value)/7)); if (day === 0 || day === 6) { if (value > 0) { this.next().monday(); this.addDays(-1); day = this.getDay(); } } if (value < 0) { while (value < 0) { this.addDays(-1); day = this.getDay(); if (day !== 0 && day !== 6) { value++; } } return this; } else if (value > 5 || (6-day) <= value) { value = value + (weeks * 2); } return this.addDays(value); }; /** * Adds the specified number of weeks to this instance. * @param {Number} The number of weeks to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addWeeks = function (value) { if (!value) { return this; } return this.addDays(value * 7); }; /** * Adds the specified number of months to this instance. * @param {Number} The number of months to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addMonths = function (value) { if (!value) { return this; } var n = this.getDate(); this.setDate(1); this.setMonth(this.getMonth() + value * 1); this.setDate(Math.min(n, $D.getDaysInMonth(this.getFullYear(), this.getMonth()))); return this; }; $P.addQuarters = function (value) { if (!value) { return this; } // note this will take you to the same point in the quarter as you are now. // i.e. - if you are 15 days into the quarter you'll be 15 days into the resulting one. // bonus: this allows adding fractional quarters return this.addMonths(value * 3); }; /** * Adds the specified number of years to this instance. * @param {Number} The number of years to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addYears = function (value) { if (!value) { return this; } return this.addMonths(value * 12); }; /** * Adds (or subtracts) to the value of the years, months, weeks, days, hours, minutes, seconds, milliseconds of the date instance using given configuration object. Positive and Negative values allowed. * Example

	Date.today().add( { days: 1, months: 1 } )

	new Date().add( { years: -1 } )
	
* @param {Object} Configuration object containing attributes (months, days, etc.) * @return {Date} this */ $P.add = function (config) { if (typeof config === "number") { this._orient = config; return this; } var x = config; if (x.day) { // If we should be a different date than today (eg: for 'tomorrow -1d', etc). // Should only effect parsing, not direct usage (eg, Finish and FinishExact) if ((x.day - this.getDate()) !== 0) { this.setDate(x.day); } } if (x.milliseconds) { this.addMilliseconds(x.milliseconds); } if (x.seconds) { this.addSeconds(x.seconds); } if (x.minutes) { this.addMinutes(x.minutes); } if (x.hours) { this.addHours(x.hours); } if (x.weeks) { this.addWeeks(x.weeks); } if (x.months) { this.addMonths(x.months); } if (x.years) { this.addYears(x.years); } if (x.days) { this.addDays(x.days); } return this; }; /** * Get the week number. Week one (1) is the week which contains the first Thursday of the year. Monday is considered the first day of the week. * The .getWeek() function does NOT convert the date to UTC. The local datetime is used. * Please use .getISOWeek() to get the week of the UTC converted date. * @return {Number} 1 to 53 */ $P.getWeek = function (utc) { // Create a copy of this date object var self, target = new Date(this.valueOf()); if (utc) { target.addMinutes(target.getTimezoneOffset()); self = target.clone(); } else { self = this; } // ISO week date weeks start on monday // so correct the day number var dayNr = (self.getDay() + 6) % 7; // ISO 8601 states that week 1 is the week // with the first thursday of that year. // Set the target date to the thursday in the target week target.setDate(target.getDate() - dayNr + 3); // Store the millisecond value of the target date var firstThursday = target.valueOf(); // Set the target to the first thursday of the year // First set the target to january first target.setMonth(0, 1); // Not a thursday? Correct the date to the next thursday if (target.getDay() !== 4) { target.setMonth(0, 1 + ((4 - target.getDay()) + 7) % 7); } // The weeknumber is the number of weeks between the // first thursday of the year and the thursday in the target week return 1 + Math.ceil((firstThursday - target) / 604800000); // 604800000 = 7 * 24 * 3600 * 1000 }; /** * Get the ISO 8601 week number. Week one ("01") is the week which contains the first Thursday of the year. Monday is considered the first day of the week. * The .getISOWeek() function does convert the date to it's UTC value. Please use .getWeek() to get the week of the local date. * @return {String} "01" to "53" */ $P.getISOWeek = function () { return p(this.getWeek(true)); }; /** * Moves the date to Monday of the week set. Week one (1) is the week which contains the first Thursday of the year. * @param {Number} A Number (1 to 53) that represents the week of the year. * @return {Date} this */ $P.setWeek = function (n) { if ((n - this.getWeek()) === 0) { if (this.getDay() !== 1) { return this.moveToDayOfWeek(1, (this.getDay() > 1 ? -1 : 1)); } else { return this; } } else { return this.moveToDayOfWeek(1, (this.getDay() > 1 ? -1 : 1)).addWeeks(n - this.getWeek()); } }; $P.setQuarter = function (qtr) { var month = Math.abs(((qtr-1) * 3) + 1); return this.setMonth(month, 1); }; $P.getQuarter = function () { return Date.getQuarter(this); }; $P.getDaysLeftInQuarter = function () { return Date.getDaysLeftInQuarter(this); }; /** * Moves the date to the next n'th occurrence of the dayOfWeek starting from the beginning of the month. The number (-1) is a magic number and will return the last occurrence of the dayOfWeek in the month. * @param {Number} The dayOfWeek to move to * @param {Number} The n'th occurrence to move to. Use (-1) to return the last occurrence in the month * @return {Date} this */ $P.moveToNthOccurrence = function (dayOfWeek, occurrence) { if (dayOfWeek === "Weekday") { if (occurrence > 0) { this.moveToFirstDayOfMonth(); if (this.is().weekday()) { occurrence -= 1; } } else if (occurrence < 0) { this.moveToLastDayOfMonth(); if (this.is().weekday()) { occurrence += 1; } } else { return this; } return this.addWeekdays(occurrence); } var shift = 0; if (occurrence > 0) { shift = occurrence - 1; } else if (occurrence === -1) { this.moveToLastDayOfMonth(); if (this.getDay() !== dayOfWeek) { this.moveToDayOfWeek(dayOfWeek, -1); } return this; } return this.moveToFirstDayOfMonth().addDays(-1).moveToDayOfWeek(dayOfWeek, +1).addWeeks(shift); }; var moveToN = function (getFunc, addFunc, nVal) { return function (value, orient) { var diff = (value - this[getFunc]() + nVal * (orient || +1)) % nVal; return this[addFunc]((diff === 0) ? diff += nVal * (orient || +1) : diff); }; }; /** * Move to the next or last dayOfWeek based on the orient value. * @param {Number} The dayOfWeek to move to * @param {Number} Forward (+1) or Back (-1). Defaults to +1. [Optional] * @return {Date} this */ $P.moveToDayOfWeek = moveToN("getDay", "addDays", 7); /** * Move to the next or last month based on the orient value. * @param {Number} The month to move to. 0 = January, 11 = December * @param {Number} Forward (+1) or Back (-1). Defaults to +1. [Optional] * @return {Date} this */ $P.moveToMonth = moveToN("getMonth", "addMonths", 12); /** * Get the Ordinate of the current day ("th", "st", "rd"). * @return {String} */ $P.getOrdinate = function () { var num = this.getDate(); return ord(num); }; /** * Get the Ordinal day (numeric day number) of the year, adjusted for leap year. * @return {Number} 1 through 365 (366 in leap years) */ $P.getOrdinalNumber = function () { return Math.ceil((this.clone().clearTime() - new Date(this.getFullYear(), 0, 1)) / 86400000) + 1; }; /** * Get the time zone abbreviation of the current date. * @return {String} The abbreviated time zone name (e.g. "EST") */ $P.getTimezone = function () { return $D.getTimezoneAbbreviation(this.getUTCOffset(), this.isDaylightSavingTime()); }; $P.setTimezoneOffset = function (offset) { var here = this.getTimezoneOffset(), there = Number(offset) * -6 / 10; return (there || there === 0) ? this.addMinutes(there - here) : this; }; $P.setTimezone = function (offset) { return this.setTimezoneOffset($D.getTimezoneOffset(offset)); }; /** * Indicates whether Daylight Saving Time is observed in the current time zone. * @return {Boolean} true|false */ $P.hasDaylightSavingTime = function () { return (Date.today().set({month: 0, day: 1}).getTimezoneOffset() !== Date.today().set({month: 6, day: 1}).getTimezoneOffset()); }; /** * Indicates whether this Date instance is within the Daylight Saving Time range for the current time zone. * @return {Boolean} true|false */ $P.isDaylightSavingTime = function () { return Date.today().set({month: 0, day: 1}).getTimezoneOffset() !== this.getTimezoneOffset(); }; /** * Get the offset from UTC of the current date. * @return {String} The 4-character offset string prefixed with + or - (e.g. "-0500") */ $P.getUTCOffset = function (offset) { var n = (offset || this.getTimezoneOffset()) * -10 / 6, r; if (n < 0) { r = (n - 10000).toString(); return r.charAt(0) + r.substr(2); } else { r = (n + 10000).toString(); return "+" + r.substr(1); } }; /** * Returns the number of milliseconds between this date and date. * @param {Date} Defaults to now * @return {Number} The diff in milliseconds */ $P.getElapsed = function (date) { return (date || new Date()) - this; }; /** * Set the value of year, month, day, hour, minute, second, millisecond of date instance using given configuration object. * Example

	Date.today().set( { day: 20, month: 1 } )

	new Date().set( { millisecond: 0 } )
	
* * @param {Object} Configuration object containing attributes (month, day, etc.) * @return {Date} this */ $P.set = function (config) { config = validateConfigObject.call(this, config); var key; for (key in config) { if (Object.prototype.hasOwnProperty.call(config, key)) { var name = key.charAt(0).toUpperCase() + key.slice(1); var addFunc, getFunc; if (key !== "week" && key !== "month" && key !== "timezone" && key !== "timezoneOffset") { name += "s"; } addFunc = "add" + name; getFunc = "get" + name; if (key === "month") { addFunc = addFunc + "s"; } else if (key === "year"){ getFunc = "getFullYear"; } if (key !== "day" && key !== "timezone" && key !== "timezoneOffset" && key !== "week" && key !== "hour") { this[addFunc](config[key] - this[getFunc]()); } else if ( key === "timezone"|| key === "timezoneOffset" || key === "week" || key === "hour") { this["set"+name](config[key]); } } } // day has to go last because you can't validate the day without first knowing the month if (config.day) { this.addDays(config.day - this.getDate()); } return this; }; /** * Moves the date to the first day of the month. * @return {Date} this */ $P.moveToFirstDayOfMonth = function () { return this.set({ day: 1 }); }; /** * Moves the date to the last day of the month. * @return {Date} this */ $P.moveToLastDayOfMonth = function () { return this.set({ day: $D.getDaysInMonth(this.getFullYear(), this.getMonth())}); }; /** * Converts the value of the current Date object to its equivalent string representation. * Format Specifiers * CUSTOM DATE AND TIME FORMAT STRINGS * Format Description Example * ------ --------------------------------------------------------------------------- ----------------------- * s The seconds of the minute between 0-59. "0" to "59" * ss The seconds of the minute with leading zero if required. "00" to "59" * * m The minute of the hour between 0-59. "0" or "59" * mm The minute of the hour with leading zero if required. "00" or "59" * * h The hour of the day between 1-12. "1" to "12" * hh The hour of the day with leading zero if required. "01" to "12" * * H The hour of the day between 0-23. "0" to "23" * HH The hour of the day with leading zero if required. "00" to "23" * * d The day of the month between 1 and 31. "1" to "31" * dd The day of the month with leading zero if required. "01" to "31" * ddd Abbreviated day name. Date.CultureInfo.abbreviatedDayNames. "Mon" to "Sun" * dddd The full day name. Date.CultureInfo.dayNames. "Monday" to "Sunday" * * M The month of the year between 1-12. "1" to "12" * MM The month of the year with leading zero if required. "01" to "12" * MMM Abbreviated month name. Date.CultureInfo.abbreviatedMonthNames. "Jan" to "Dec" * MMMM The full month name. Date.CultureInfo.monthNames. "January" to "December" * * yy The year as a two-digit number. "99" or "08" * yyyy The full four digit year. "1999" or "2008" * * t Displays the first character of the A.M./P.M. designator. "A" or "P" * Date.CultureInfo.amDesignator or Date.CultureInfo.pmDesignator * tt Displays the A.M./P.M. designator. "AM" or "PM" * Date.CultureInfo.amDesignator or Date.CultureInfo.pmDesignator * * S The ordinal suffix ("st, "nd", "rd" or "th") of the current day. "st, "nd", "rd" or "th" * * STANDARD DATE AND TIME FORMAT STRINGS * Format Description Example *------ --------------------------------------------------------------------------- ----------------------- * d The CultureInfo shortDate Format Pattern "M/d/yyyy" * D The CultureInfo longDate Format Pattern "dddd, MMMM dd, yyyy" * F The CultureInfo fullDateTime Format Pattern "dddd, MMMM dd, yyyy h:mm:ss tt" * m The CultureInfo monthDay Format Pattern "MMMM dd" * r The CultureInfo rfc1123 Format Pattern "ddd, dd MMM yyyy HH:mm:ss GMT" * s The CultureInfo sortableDateTime Format Pattern "yyyy-MM-ddTHH:mm:ss" * t The CultureInfo shortTime Format Pattern "h:mm tt" * T The CultureInfo longTime Format Pattern "h:mm:ss tt" * u The CultureInfo universalSortableDateTime Format Pattern "yyyy-MM-dd HH:mm:ssZ" * y The CultureInfo yearMonth Format Pattern "MMMM, yyyy" * * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @return {String} A string representation of the current Date object. */ var ord = function (n) { switch (n * 1) { case 1: case 21: case 31: return "st"; case 2: case 22: return "nd"; case 3: case 23: return "rd"; default: return "th"; } }; var parseStandardFormats = function (format) { var y, c = Date.CultureInfo.formatPatterns; switch (format) { case "d": return this.toString(c.shortDate); case "D": return this.toString(c.longDate); case "F": return this.toString(c.fullDateTime); case "m": return this.toString(c.monthDay); case "r": case "R": y = this.clone().addMinutes(this.getTimezoneOffset()); return y.toString(c.rfc1123) + " GMT"; case "s": return this.toString(c.sortableDateTime); case "t": return this.toString(c.shortTime); case "T": return this.toString(c.longTime); case "u": y = this.clone().addMinutes(this.getTimezoneOffset()); return y.toString(c.universalSortableDateTime); case "y": return this.toString(c.yearMonth); default: return false; } }; var parseFormatStringsClosure = function (context) { return function (m) { if (m.charAt(0) === "\\") { return m.replace("\\", ""); } switch (m) { case "hh": return p(context.getHours() < 13 ? (context.getHours() === 0 ? 12 : context.getHours()) : (context.getHours() - 12)); case "h": return context.getHours() < 13 ? (context.getHours() === 0 ? 12 : context.getHours()) : (context.getHours() - 12); case "HH": return p(context.getHours()); case "H": return context.getHours(); case "mm": return p(context.getMinutes()); case "m": return context.getMinutes(); case "ss": return p(context.getSeconds()); case "s": return context.getSeconds(); case "yyyy": return p(context.getFullYear(), 4); case "yy": return p(context.getFullYear()); case "y": return context.getFullYear(); case "E": case "dddd": return Date.CultureInfo.dayNames[context.getDay()]; case "ddd": return Date.CultureInfo.abbreviatedDayNames[context.getDay()]; case "dd": return p(context.getDate()); case "d": return context.getDate(); case "MMMM": return Date.CultureInfo.monthNames[context.getMonth()]; case "MMM": return Date.CultureInfo.abbreviatedMonthNames[context.getMonth()]; case "MM": return p((context.getMonth() + 1)); case "M": return context.getMonth() + 1; case "t": return context.getHours() < 12 ? Date.CultureInfo.amDesignator.substring(0, 1) : Date.CultureInfo.pmDesignator.substring(0, 1); case "tt": return context.getHours() < 12 ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator; case "S": return ord(context.getDate()); case "W": return context.getWeek(); case "WW": return context.getISOWeek(); case "Q": return "Q" + context.getQuarter(); case "q": return String(context.getQuarter()); case "z": return context.getTimezone(); case "Z": case "X": return Date.getTimezoneOffset(context.getTimezone()); case "ZZ": // Timezone offset in seconds return context.getTimezoneOffset() * -60; case "u": return context.getDay(); case "L": return ($D.isLeapYear(context.getFullYear())) ? 1 : 0; case "B": // Swatch Internet Time (.beats) return "@"+((context.getUTCSeconds() + (context.getUTCMinutes()*60) + ((context.getUTCHours()+1)*3600))/86.4); default: return m; } }; }; $P.toString = function (format, ignoreStandards) { // Standard Date and Time Format Strings. Formats pulled from CultureInfo file and // may vary by culture. if (!ignoreStandards && format && format.length === 1) { output = parseStandardFormats.call(this, format); if (output) { return output; } } var parseFormatStrings = parseFormatStringsClosure(this); return format ? format.replace(/((\\)?(dd?d?d?|MM?M?M?|yy?y?y?|hh?|HH?|mm?|ss?|tt?|S|q|Q|WW?W?W?)(?![^\[]*\]))/g, parseFormatStrings).replace(/\[|\]/g, "") : this._toString(); }; }()); /************************************************************* * SugarPak - Domain Specific Language - Syntactical Sugar * *************************************************************/ (function () { var $D = Date, $P = $D.prototype, $N = Number.prototype; // private $P._orient = +1; // private $P._nth = null; // private $P._is = false; // private $P._same = false; // private $P._isSecond = false; // private $N._dateElement = "days"; /** * Moves the date to the next instance of a date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.today().next().friday();
	Date.today().next().fri();
	Date.today().next().march();
	Date.today().next().mar();
	Date.today().next().week();
	
* * @return {Date} date */ $P.next = function () { this._move = true; this._orient = +1; return this; }; /** * Creates a new Date (Date.today()) and moves the date to the next instance of the date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.next().friday();
	Date.next().fri();
	Date.next().march();
	Date.next().mar();
	Date.next().week();
	
* * @return {Date} date */ $D.next = function () { return $D.today().next(); }; /** * Moves the date to the previous instance of a date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.today().last().friday();
	Date.today().last().fri();
	Date.today().last().march();
	Date.today().last().mar();
	Date.today().last().week();
	
* * @return {Date} date */ $P.last = $P.prev = $P.previous = function () { this._move = true; this._orient = -1; return this; }; /** * Creates a new Date (Date.today()) and moves the date to the previous instance of the date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.last().friday();
	Date.last().fri();
	Date.previous().march();
	Date.prev().mar();
	Date.last().week();
	
* * @return {Date} date */ $D.last = $D.prev = $D.previous = function () { return $D.today().last(); }; /** * Performs a equality check when followed by either a month name, day name or .weekday() function. * Example

	Date.today().is().friday(); // true|false
	Date.today().is().fri();
	Date.today().is().march();
	Date.today().is().mar();
	
* * @return {Boolean} true|false */ $P.is = function () { this._is = true; return this; }; /** * Determines if two date objects occur on/in exactly the same instance of the subsequent date part function. * The function .same() must be followed by a date part function (example: .day(), .month(), .year(), etc). * * An optional Date can be passed in the date part function. If now date is passed as a parameter, 'Now' is used. * * The following example demonstrates how to determine if two dates fall on the exact same day. * * Example

	var d1 = Date.today(); // today at 00:00
	var d2 = new Date();   // exactly now.

	// Do they occur on the same day?
	d1.same().day(d2); // true
	
	// Do they occur on the same hour?
	d1.same().hour(d2); // false, unless d2 hour is '00' (midnight).
	
	// What if it's the same day, but one year apart?
	var nextYear = Date.today().add(1).year();

	d1.same().day(nextYear); // false, because the dates must occur on the exact same day. 
	
* * Scenario: Determine if a given date occurs during some week period 2 months from now. * * Example

	var future = Date.today().add(2).months();
	return someDate.same().week(future); // true|false;
	
* * @return {Boolean} true|false */ $P.same = function () { this._same = true; this._isSecond = false; return this; }; /** * Determines if the current date/time occurs during Today. Must be preceded by the .is() function. * Example

	someDate.is().today();    // true|false
	new Date().is().today();  // true
	Date.today().is().today();// true
	Date.today().add(-1).day().is().today(); // false
	
* * @return {Boolean} true|false */ $P.today = function () { return this.same().day(); }; /** * Determines if the current date is a weekday. This function must be preceded by the .is() function. * Example

	Date.today().is().weekday(); // true|false
	
* * @return {Boolean} true|false */ $P.weekday = function () { if (this._nth) { return df("Weekday").call(this); } if (this._move) { return this.addWeekdays(this._orient); } if (this._is) { this._is = false; return (!this.is().sat() && !this.is().sun()); } return false; }; /** * Determines if the current date is on the weekend. This function must be preceded by the .is() function. * Example

	Date.today().is().weekend(); // true|false
	
* * @return {Boolean} true|false */ $P.weekend = function () { if (this._is) { this._is = false; return (this.is().sat() || this.is().sun()); } return false; }; /** * Sets the Time of the current Date instance. A string "6:15 pm" or config object {hour:18, minute:15} are accepted. * Example

	// Set time to 6:15pm with a String
	Date.today().at("6:15pm");

	// Set time to 6:15pm with a config object
	Date.today().at({hour:18, minute:15});
	
* * @return {Date} date */ $P.at = function (time) { return (typeof time === "string") ? $D.parse(this.toString("d") + " " + time) : this.set(time); }; /** * Creates a new Date() and adds this (Number) to the date based on the preceding date element function (eg. second|minute|hour|day|month|year). * Example

	// Undeclared Numbers must be wrapped with parentheses. Requirment of JavaScript.
	(3).days().fromNow();
	(6).months().fromNow();

	// Declared Number variables do not require parentheses. 
	var n = 6;
	n.months().fromNow();
	
* * @return {Date} A new Date instance */ $N.fromNow = $N.after = function (date) { var c = {}; c[this._dateElement] = this; return ((!date) ? new Date() : date.clone()).add(c); }; /** * Creates a new Date() and subtract this (Number) from the date based on the preceding date element function (eg. second|minute|hour|day|month|year). * Example

	// Undeclared Numbers must be wrapped with parentheses. Requirment of JavaScript.
	(3).days().ago();
	(6).months().ago();

	// Declared Number variables do not require parentheses. 
	var n = 6;
	n.months().ago();
	
* * @return {Date} A new Date instance */ $N.ago = $N.before = function (date) { var c = {}, s = (this._dateElement[this._dateElement.length-1] !== "s") ? this._dateElement + "s" : this._dateElement; c[s] = this * -1; return ((!date) ? new Date() : date.clone()).add(c); }; // Do NOT modify the following string tokens. These tokens are used to build dynamic functions. // All culture-specific strings can be found in the CultureInfo files. var dx = ("sunday monday tuesday wednesday thursday friday saturday").split(/\s/), mx = ("january february march april may june july august september october november december").split(/\s/), px = ("Millisecond Second Minute Hour Day Week Month Year Quarter Weekday").split(/\s/), pxf = ("Milliseconds Seconds Minutes Hours Date Week Month FullYear Quarter").split(/\s/), nth = ("final first second third fourth fifth").split(/\s/), de; /** * Returns an object literal of all the date parts. * Example

	var o = new Date().toObject();
	
	// { year: 2008, month: 4, week: 20, day: 13, hour: 18, minute: 9, second: 32, millisecond: 812 }
	
	// The object properties can be referenced directly from the object.
	
	alert(o.day);  // alerts "13"
	alert(o.year); // alerts "2008"
	
* * @return {Date} An object literal representing the original date object. */ $P.toObject = function () { var o = {}; for (var i = 0; i < px.length; i++) { if (this["get" + pxf[i]]) { o[px[i].toLowerCase()] = this["get" + pxf[i]](); } } return o; }; /** * Returns a date created from an object literal. Ignores the .week property if set in the config. * Example

	var o = new Date().toObject();
	
	return Date.fromObject(o); // will return the same date. 

	var o2 = {month: 1, day: 20, hour: 18}; // birthday party!
	Date.fromObject(o2);
	
* * @return {Date} An object literal representing the original date object. */ $D.fromObject = function(config) { config.week = null; return Date.today().set(config); }; // Create day name functions and abbreviated day name functions (eg. monday(), friday(), fri()). var df = function (n) { return function () { if (this._is) { this._is = false; return this.getDay() === n; } if (this._move) { this._move = null; } if (this._nth !== null) { // If the .second() function was called earlier, remove the _orient // from the date, and then continue. // This is required because 'second' can be used in two different context. // // Example // // Date.today().add(1).second(); // Date.march().second().monday(); // // Things get crazy with the following... // Date.march().add(1).second().second().monday(); // but it works!! // if (this._isSecond) { this.addSeconds(this._orient * -1); } // make sure we reset _isSecond this._isSecond = false; var ntemp = this._nth; this._nth = null; var temp = this.clone().moveToLastDayOfMonth(); this.moveToNthOccurrence(n, ntemp); if (this > temp) { throw new RangeError($D.getDayName(n) + " does not occur " + ntemp + " times in the month of " + $D.getMonthName(temp.getMonth()) + " " + temp.getFullYear() + "."); } return this; } return this.moveToDayOfWeek(n, this._orient); }; }; var sdf = function (n) { return function () { var t = $D.today(), shift = n - t.getDay(); if (n === 0 && Date.CultureInfo.firstDayOfWeek === 1 && t.getDay() !== 0) { shift = shift + 7; } return t.addDays(shift); }; }; // Create month name functions and abbreviated month name functions (eg. january(), march(), mar()). var month_instance_functions = function (n) { return function () { if (this._is) { this._is = false; return this.getMonth() === n; } return this.moveToMonth(n, this._orient); }; }; var month_static_functions = function (n) { return function () { return $D.today().set({ month: n, day: 1 }); }; }; var processTerms = function (names, staticFunc, instanceFunc) { for (var i = 0; i < names.length; i++) { // Create constant static Name variables. $D[names[i].toUpperCase()] = $D[names[i].toUpperCase().substring(0, 3)] = i; // Create Name functions. $D[names[i]] = $D[names[i].substring(0, 3)] = staticFunc(i); // Create Name instance functions. $P[names[i]] = $P[names[i].substring(0, 3)] = instanceFunc(i); } }; processTerms(dx, sdf, df); processTerms(mx, month_static_functions, month_instance_functions); // Create date element functions and plural date element functions used with Date (eg. day(), days(), months()). var ef = function (j) { return function () { // if the .second() function was called earlier, the _orient // has alread been added. Just return this and reset _isSecond. if (this._isSecond) { this._isSecond = false; return this; } if (this._same) { this._same = this._is = false; var o1 = this.toObject(), o2 = (arguments[0] || new Date()).toObject(), v = "", k = j.toLowerCase(); // the substr trick with -1 doesn't work in IE8 or less k = (k[k.length-1] === "s") ? k.substring(0,k.length-1) : k; for (var m = (px.length - 1); m > -1; m--) { v = px[m].toLowerCase(); if (o1[v] !== o2[v]) { return false; } if (k === v) { break; } } return true; } if (j.substring(j.length - 1) !== "s") { j += "s"; } if (this._move) { this._move = null; } return this["add" + j](this._orient); }; }; var nf = function (n) { return function () { this._dateElement = n; return this; }; }; for (var k = 0; k < px.length; k++) { de = px[k].toLowerCase(); if(de !== "weekday") { // Create date element functions and plural date element functions used with Date (eg. day(), days(), months()). $P[de] = $P[de + "s"] = ef(px[k]); // Create date element functions and plural date element functions used with Number (eg. day(), days(), months()). $N[de] = $N[de + "s"] = nf(de + "s"); } } $P._ss = ef("Second"); var nthfn = function (n) { return function (dayOfWeek) { if (this._same) { return this._ss(arguments[0]); } if (dayOfWeek || dayOfWeek === 0) { return this.moveToNthOccurrence(dayOfWeek, n); } this._nth = n; // if the operator is 'second' add the _orient, then deal with it later... if (n === 2 && (dayOfWeek === undefined || dayOfWeek === null)) { this._isSecond = true; return this.addSeconds(this._orient); } return this; }; }; for (var l = 0; l < nth.length; l++) { $P[nth[l]] = (l === 0) ? nthfn(-1) : nthfn(l); } }()); (function () { "use strict"; Date.Parsing = { Exception: function (s) { this.message = "Parse error at '" + s.substring(0, 10) + " ...'"; } }; var $P = Date.Parsing; var dayOffsets = { standard: [0,31,59,90,120,151,181,212,243,273,304,334], leap: [0,31,60,91,121,152,182,213,244,274,305,335] }; $P.isLeapYear = function(year) { return ((year % 4 === 0) && (year % 100 !== 0)) || (year % 400 === 0); }; var utils = { multiReplace : function (str, hash ) { var key; for (key in hash) { if (Object.prototype.hasOwnProperty.call(hash, key)) { var regex; if (typeof hash[key] === "function") { } else { regex = (hash[key] instanceof RegExp) ? hash[key] : new RegExp(hash[key], "g"); } str = str.replace(regex, key); } } return str; }, getDayOfYearFromWeek : function (obj) { var d, jan4, offset; obj.weekDay = (!obj.weekDay && obj.weekDay !== 0) ? 1 : obj.weekDay; d = new Date(obj.year, 0, 4); jan4 = d.getDay() === 0 ? 7 : d.getDay(); // JS is 0 indexed on Sunday. offset = jan4+3; obj.dayOfYear = ((obj.week * 7) + (obj.weekDay === 0 ? 7 : obj.weekDay))-offset; return obj; }, getDayOfYear : function (obj, dayOffset) { if (!obj.dayOfYear) { obj = utils.getDayOfYearFromWeek(obj); } for (var i=0;i <= dayOffset.length;i++) { if (obj.dayOfYear < dayOffset[i] || i === dayOffset.length) { obj.day = obj.day ? obj.day : (obj.dayOfYear - dayOffset[i-1]); break; } else { obj.month = i; } } return obj; }, adjustForTimeZone : function (obj, date) { var offset; if (obj.zone.toUpperCase() === "Z" || (obj.zone_hours === 0 && obj.zone_minutes === 0)) { // it's UTC/GML so work out the current timeszone offset offset = -date.getTimezoneOffset(); } else { offset = (obj.zone_hours*60) + (obj.zone_minutes || 0); if (obj.zone_sign === "+") { offset *= -1; } offset -= date.getTimezoneOffset(); } date.setMinutes(date.getMinutes()+offset); return date; }, setDefaults : function (obj) { obj.year = obj.year || Date.today().getFullYear(); obj.hours = obj.hours || 0; obj.minutes = obj.minutes || 0; obj.seconds = obj.seconds || 0; obj.milliseconds = obj.milliseconds || 0; if (!(!obj.month && (obj.week || obj.dayOfYear))) { // if we have a month, or if we don't but don't have the day calculation data obj.month = obj.month || 0; obj.day = obj.day || 1; } return obj; }, dataNum: function (data, mod, explict, postProcess) { var dataNum = data*1; if (mod) { if (postProcess) { return data ? mod(data)*1 : data; } else { return data ? mod(dataNum) : data; } } else if (!explict){ return data ? dataNum : data; } else { return (data && typeof data !== "undefined") ? dataNum : data; } }, timeDataProcess: function (obj) { var timeObj = {}; for (var x in obj.data) { if (obj.data.hasOwnProperty(x)) { timeObj[x] = obj.ignore[x] ? obj.data[x] : utils.dataNum(obj.data[x], obj.mods[x], obj.explict[x], obj.postProcess[x]); } } if (obj.data.secmins) { obj.data.secmins = obj.data.secmins.replace(",", ".") * 60; if (!timeObj.minutes) { timeObj.minutes = obj.data.secmins; } else if (!timeObj.seconds) { timeObj.seconds = obj.data.secmins; } delete obj.secmins; } return timeObj; }, buildTimeObjectFromData: function (data) { var time = utils.timeDataProcess({ data: { year : data[1], month : data[5], day : data[7], week : data[8], dayOfYear : data[10], hours : data[15], zone_hours : data[23], zone_minutes : data[24], zone : data[21], zone_sign : data[22], weekDay : data[9], minutes: data[16], seconds: data[19], milliseconds: data[20], secmins: data[18] }, mods: { month: function(data) { return data-1; }, weekDay: function (data) { data = Math.abs(data); return (data === 7 ? 0 : data); }, minutes: function (data) { return data.replace(":",""); }, seconds: function (data) { return Math.floor( (data.replace(":","").replace(",","."))*1 ); }, milliseconds: function (data) { return (data.replace(",",".")*1000); } }, postProcess: { minutes: true, seconds: true, milliseconds: true }, explict: { zone_hours: true, zone_minutes: true }, ignore: { zone: true, zone_sign: true, secmins: true } }); return time; }, addToHash: function (hash, keys, data) { keys = keys; data = data; var len = keys.length; for (var i = 0; i < len; i++) { hash[keys[i]] = data[i]; } return hash; }, combineRegex: function (r1, r2) { return new RegExp("(("+r1.source+")\\s("+r2.source+"))"); }, getDateNthString: function(add, last, inc){ if (add) { return Date.today().addDays(inc).toString("d"); } else if (last) { return Date.today().last()[inc]().toString("d"); } }, buildRegexData: function (array) { var arr = []; var len = array.length; for (var i=0; i < len; i++) { if (Object.prototype.toString.call(array[i]) === '[object Array]') { // oldIE compat version of Array.isArray arr.push(this.combineRegex(array[i][0], array[i][1])); } else { arr.push(array[i]); } } return arr; } }; $P.processTimeObject = function (obj) { var date, dayOffset; utils.setDefaults(obj); dayOffset = ($P.isLeapYear(obj.year)) ? dayOffsets.leap : dayOffsets.standard; if (!obj.month && (obj.week || obj.dayOfYear)) { utils.getDayOfYear(obj, dayOffset); } else { obj.dayOfYear = dayOffset[obj.month] + obj.day; } date = new Date(obj.year, obj.month, obj.day, obj.hours, obj.minutes, obj.seconds, obj.milliseconds); if (obj.zone) { utils.adjustForTimeZone(obj, date); // adjust (and calculate) for timezone } return date; }; $P.ISO = { regex : /^([\+-]?\d{4}(?!\d{2}\b))((-?)((0[1-9]|1[0-2])(\3([12]\d|0[1-9]|3[01]))?|W([0-4]\d|5[0-3])(-?[1-7])?|(00[1-9]|0[1-9]\d|[12]\d{2}|3([0-5]\d|6[1-6])))([T\s]((([01]\d|2[0-4])((:?)[0-5]\d)?|24\:?00)([\.,]\d+(?!:))?)?(\17[0-5]\d([\.,]\d+)?)?\s?([zZ]|([\+-])([01]\d|2[0-3]):?([0-5]\d)?)?)?)?$/, parse : function (s) { var time, data = s.match(this.regex); if (!data || !data.length) { return null; } time = utils.buildTimeObjectFromData(data); if (!time.year || (!time.year && (!time.month && !time.day) && (!time.week && !time.dayOfYear)) ) { return null; } return $P.processTimeObject(time); } }; $P.Numeric = { isNumeric: function (e){return!isNaN(parseFloat(e))&&isFinite(e);}, regex: /\b([0-1]?[0-9])([0-3]?[0-9])([0-2]?[0-9]?[0-9][0-9])\b/i, parse: function (s) { var data, i, time = {}, order = Date.CultureInfo.dateElementOrder.split(""); if (!(this.isNumeric(s)) || // if it's non-numeric OR (s[0] === "+" && s[0] === "-")) { // It's an arithmatic string (eg +/-1000) return null; } if (s.length < 5 && s.indexOf(".") < 0 && s.indexOf("/") < 0) { // assume it's just a year. time.year = s; return $P.processTimeObject(time); } data = s.match(this.regex); if (!data || !data.length) { return null; } for (i=0; i < order.length; i++) { switch(order[i]) { case "d": time.day = data[i+1]; break; case "m": time.month = (data[i+1]-1); break; case "y": time.year = data[i+1]; break; } } return $P.processTimeObject(time); } }; $P.Normalizer = { regexData: function () { var $R = Date.CultureInfo.regexPatterns; return utils.buildRegexData([ $R.tomorrow, $R.yesterday, [$R.past, $R.mon], [$R.past, $R.tue], [$R.past, $R.wed], [$R.past, $R.thu], [$R.past, $R.fri], [$R.past, $R.sat], [$R.past, $R.sun] ]); }, basicReplaceHash : function() { var $R = Date.CultureInfo.regexPatterns; return { "January": $R.jan.source, "February": $R.feb, "March": $R.mar, "April": $R.apr, "May": $R.may, "June": $R.jun, "July": $R.jul, "August": $R.aug, "September": $R.sep, "October": $R.oct, "November": $R.nov, "December": $R.dec, "": /\bat\b/gi, " ": /\s{2,}/, "am": $R.inTheMorning, "9am": $R.thisMorning, "pm": $R.inTheEvening, "7pm":$R.thisEvening }; }, keys : function(){ return [ utils.getDateNthString(true, false, 1), // tomorrow utils.getDateNthString(true, false, -1), // yesterday utils.getDateNthString(false, true, "monday"), //last mon utils.getDateNthString(false, true, "tuesday"), //last tues utils.getDateNthString(false, true, "wednesday"), //last wed utils.getDateNthString(false, true, "thursday"), //last thurs utils.getDateNthString(false, true, "friday"), //last fri utils.getDateNthString(false, true, "saturday"), //last sat utils.getDateNthString(false, true, "sunday") //last sun ]; }, buildRegexFunctions: function () { var $R = Date.CultureInfo.regexPatterns; var __ = Date.i18n.__; var tomorrowRE = new RegExp("(\\b\\d\\d?("+__("AM")+"|"+__("PM")+")? )("+$R.tomorrow.source.slice(1)+")", "i"); // adapted tomorrow regex for AM PM relative dates var todayRE = new RegExp($R.today.source + "(?!\\s*([+-]))\\b"); // today, but excludes the math operators (eg "today + 2h") this.replaceFuncs = [ [todayRE, function (full) { return (full.length > 1) ? Date.today().toString("d") : full; }], [tomorrowRE, function(full, m1) { var t = Date.today().addDays(1).toString("d"); return (t + " " + m1); }], [$R.amThisMorning, function(str, am){return am;}], [$R.pmThisEvening, function(str, pm){return pm;}] ]; }, buildReplaceData: function () { this.buildRegexFunctions(); this.replaceHash = utils.addToHash(this.basicReplaceHash(), this.keys(), this.regexData()); }, stringReplaceFuncs: function (s) { for (var i=0; i < this.replaceFuncs.length; i++) { s = s.replace(this.replaceFuncs[i][0], this.replaceFuncs[i][1]); } return s; }, parse: function (s) { s = this.stringReplaceFuncs(s); s = utils.multiReplace(s, this.replaceHash); try { var n = s.split(/([\s\-\.\,\/\x27]+)/); if (n.length === 3 && $P.Numeric.isNumeric(n[0]) && $P.Numeric.isNumeric(n[2]) && (n[2].length >= 4)) { // ok, so we're dealing with x/year. But that's not a full date. // This fixes wonky dateElementOrder parsing when set to dmy order. if (Date.CultureInfo.dateElementOrder[0] === "d") { s = "1/" + n[0] + "/" + n[2]; // set to 1st of month and normalize the seperator } } } catch (e) {} return s; } }; $P.Normalizer.buildReplaceData(); }()); (function () { var $P = Date.Parsing; var _ = $P.Operators = { // // Tokenizers // rtoken: function (r) { // regex token return function (s) { var mx = s.match(r); if (mx) { return ([ mx[0], s.substring(mx[0].length) ]); } else { throw new $P.Exception(s); } }; }, token: function () { // whitespace-eating token return function (s) { return _.rtoken(new RegExp("^\\s*" + s + "\\s*"))(s); }; }, stoken: function (s) { // string token return _.rtoken(new RegExp("^" + s)); }, // Atomic Operators until: function (p) { return function (s) { var qx = [], rx = null; while (s.length) { try { rx = p.call(this, s); } catch (e) { qx.push(rx[0]); s = rx[1]; continue; } break; } return [ qx, s ]; }; }, many: function (p) { return function (s) { var rx = [], r = null; while (s.length) { try { r = p.call(this, s); } catch (e) { return [ rx, s ]; } rx.push(r[0]); s = r[1]; } return [ rx, s ]; }; }, // generator operators -- see below optional: function (p) { return function (s) { var r = null; try { r = p.call(this, s); } catch (e) { return [ null, s ]; } return [ r[0], r[1] ]; }; }, not: function (p) { return function (s) { try { p.call(this, s); } catch (e) { return [null, s]; } throw new $P.Exception(s); }; }, ignore: function (p) { return p ? function (s) { var r = null; r = p.call(this, s); return [null, r[1]]; } : null; }, product: function () { var px = arguments[0], qx = Array.prototype.slice.call(arguments, 1), rx = []; for (var i = 0 ; i < px.length ; i++) { rx.push(_.each(px[i], qx)); } return rx; }, cache: function (rule) { var cache = {}, cache_length = 0, cache_keys = [], CACHE_MAX = Date.Config.CACHE_MAX || 100000, r = null; var cacheCheck = function () { if (cache_length === CACHE_MAX) { // kill several keys, don't want to have to do this all the time... for (var i=0; i < 10; i++) { var key = cache_keys.shift(); if (key) { delete cache[key]; cache_length--; } } } }; return function (s) { cacheCheck(); try { r = cache[s] = (cache[s] || rule.call(this, s)); } catch (e) { r = cache[s] = e; } cache_length++; cache_keys.push(s); if (r instanceof $P.Exception) { throw r; } else { return r; } }; }, // vector operators -- see below any: function () { var px = arguments; return function (s) { var r = null; for (var i = 0; i < px.length; i++) { if (px[i] == null) { continue; } try { r = (px[i].call(this, s)); } catch (e) { r = null; } if (r) { return r; } } throw new $P.Exception(s); }; }, each: function () { var px = arguments; return function (s) { var rx = [], r = null; for (var i = 0; i < px.length ; i++) { if (px[i] == null) { continue; } try { r = (px[i].call(this, s)); } catch (e) { throw new $P.Exception(s); } rx.push(r[0]); s = r[1]; } return [ rx, s]; }; }, all: function () { var px = arguments, _ = _; return _.each(_.optional(px)); }, // delimited operators sequence: function (px, d, c) { d = d || _.rtoken(/^\s*/); c = c || null; if (px.length === 1) { return px[0]; } return function (s) { var r = null, q = null; var rx = []; for (var i = 0; i < px.length ; i++) { try { r = px[i].call(this, s); } catch (e) { break; } rx.push(r[0]); try { q = d.call(this, r[1]); } catch (ex) { q = null; break; } s = q[1]; } if (!r) { throw new $P.Exception(s); } if (q) { throw new $P.Exception(q[1]); } if (c) { try { r = c.call(this, r[1]); } catch (ey) { throw new $P.Exception(r[1]); } } return [ rx, (r?r[1]:s) ]; }; }, // // Composite Operators // between: function (d1, p, d2) { d2 = d2 || d1; var _fn = _.each(_.ignore(d1), p, _.ignore(d2)); return function (s) { var rx = _fn.call(this, s); return [[rx[0][0], r[0][2]], rx[1]]; }; }, list: function (p, d, c) { d = d || _.rtoken(/^\s*/); c = c || null; return (p instanceof Array ? _.each(_.product(p.slice(0, -1), _.ignore(d)), p.slice(-1), _.ignore(c)) : _.each(_.many(_.each(p, _.ignore(d))), px, _.ignore(c))); }, set: function (px, d, c) { d = d || _.rtoken(/^\s*/); c = c || null; return function (s) { // r is the current match, best the current 'best' match // which means it parsed the most amount of input var r = null, p = null, q = null, rx = null, best = [[], s], last = false; // go through the rules in the given set for (var i = 0; i < px.length ; i++) { // last is a flag indicating whether this must be the last element // if there is only 1 element, then it MUST be the last one q = null; p = null; r = null; last = (px.length === 1); // first, we try simply to match the current pattern // if not, try the next pattern try { r = px[i].call(this, s); } catch (e) { continue; } // since we are matching against a set of elements, the first // thing to do is to add r[0] to matched elements rx = [[r[0]], r[1]]; // if we matched and there is still input to parse and // we don't already know this is the last element, // we're going to next check for the delimiter ... // if there's none, or if there's no input left to parse // than this must be the last element after all ... if (r[1].length > 0 && ! last) { try { q = d.call(this, r[1]); } catch (ex) { last = true; } } else { last = true; } // if we parsed the delimiter and now there's no more input, // that means we shouldn't have parsed the delimiter at all // so don't update r and mark this as the last element ... if (!last && q[1].length === 0) { last = true; } // so, if this isn't the last element, we're going to see if // we can get any more matches from the remaining (unmatched) // elements ... if (!last) { // build a list of the remaining rules we can match against, // i.e., all but the one we just matched against var qx = []; for (var j = 0; j < px.length ; j++) { if (i !== j) { qx.push(px[j]); } } // now invoke recursively set with the remaining input // note that we don't include the closing delimiter ... // we'll check for that ourselves at the end p = _.set(qx, d).call(this, q[1]); // if we got a non-empty set as a result ... // (otw rx already contains everything we want to match) if (p[0].length > 0) { // update current result, which is stored in rx ... // basically, pick up the remaining text from p[1] // and concat the result from p[0] so that we don't // get endless nesting ... rx[0] = rx[0].concat(p[0]); rx[1] = p[1]; } } // at this point, rx either contains the last matched element // or the entire matched set that starts with this element. // now we just check to see if this variation is better than // our best so far, in terms of how much of the input is parsed if (rx[1].length < best[1].length) { best = rx; } // if we've parsed all the input, then we're finished if (best[1].length === 0) { break; } } // so now we've either gone through all the patterns trying them // as the initial match; or we found one that parsed the entire // input string ... // if best has no matches, just return empty set ... if (best[0].length === 0) { return best; } // if a closing delimiter is provided, then we have to check it also if (c) { // we try this even if there is no remaining input because the pattern // may well be optional or match empty input ... try { q = c.call(this, best[1]); } catch (ey) { throw new $P.Exception(best[1]); } // it parsed ... be sure to update the best match remaining input best[1] = q[1]; } // if we're here, either there was no closing delimiter or we parsed it // so now we have the best match; just return it! return best; }; }, forward: function (gr, fname) { return function (s) { return gr[fname].call(this, s); }; }, // // Translation Operators // replace: function (rule, repl) { return function (s) { var r = rule.call(this, s); return [repl, r[1]]; }; }, process: function (rule, fn) { return function (s) { var r = rule.call(this, s); return [fn.call(this, r[0]), r[1]]; }; }, min: function (min, rule) { return function (s) { var rx = rule.call(this, s); if (rx[0].length < min) { throw new $P.Exception(s); } return rx; }; } }; // Generator Operators And Vector Operators // Generators are operators that have a signature of F(R) => R, // taking a given rule and returning another rule, such as // ignore, which parses a given rule and throws away the result. // Vector operators are those that have a signature of F(R1,R2,...) => R, // take a list of rules and returning a new rule, such as each. // Generator operators are converted (via the following _generator // function) into functions that can also take a list or array of rules // and return an array of new rules as though the function had been // called on each rule in turn (which is what actually happens). // This allows generators to be used with vector operators more easily. // Example: // each(ignore(foo, bar)) instead of each(ignore(foo), ignore(bar)) // This also turns generators into vector operators, which allows // constructs like: // not(cache(foo, bar)) var _generator = function (op) { function gen() { var args = null, rx = [], px, i; if (arguments.length > 1) { args = Array.prototype.slice.call(arguments); } else if (arguments[0] instanceof Array) { args = arguments[0]; } if (args) { px = args.shift(); if (px.length > 0) { args.unshift(px[i]); rx.push(op.apply(null, args)); args.shift(); return rx; } } else { return op.apply(null, arguments); } } return gen; }; var gx = "optional not ignore cache".split(/\s/); for (var i = 0 ; i < gx.length ; i++) { _[gx[i]] = _generator(_[gx[i]]); } var _vector = function (op) { return function () { if (arguments[0] instanceof Array) { return op.apply(null, arguments[0]); } else { return op.apply(null, arguments); } }; }; var vx = "each any all".split(/\s/); for (var j = 0 ; j < vx.length ; j++) { _[vx[j]] = _vector(_[vx[j]]); } }()); (function () { var $D = Date; var flattenAndCompact = function (ax) { var rx = []; for (var i = 0; i < ax.length; i++) { if (ax[i] instanceof Array) { rx = rx.concat(flattenAndCompact(ax[i])); } else { if (ax[i]) { rx.push(ax[i]); } } } return rx; }; var parseMeridian = function () { if (this.meridian && (this.hour || this.hour === 0)) { if (this.meridian === "a" && this.hour > 11 && Date.Config.strict24hr){ throw "Invalid hour and meridian combination"; } else if (this.meridian === "p" && this.hour < 12 && Date.Config.strict24hr){ throw "Invalid hour and meridian combination"; } else if (this.meridian === "p" && this.hour < 12) { this.hour = this.hour + 12; } else if (this.meridian === "a" && this.hour === 12) { this.hour = 0; } } }; var setDefaults = function () { var now = new Date(); if ((this.hour || this.minute) && (!this.month && !this.year && !this.day)) { this.day = now.getDate(); } if (!this.year) { this.year = now.getFullYear(); } if (!this.month && this.month !== 0) { this.month = now.getMonth(); } if (!this.day) { this.day = 1; } if (!this.hour) { this.hour = 0; } if (!this.minute) { this.minute = 0; } if (!this.second) { this.second = 0; } if (!this.millisecond) { this.millisecond = 0; } }; var finishUtils = { getToday: function () { if (this.now || "hour minute second".indexOf(this.unit) !== -1) { return new Date(); } else { return $D.today(); } }, setDaysFromWeekday: function (today, orient){ var gap; orient = orient || 1; this.unit = "day"; gap = ($D.getDayNumberFromName(this.weekday) - today.getDay()); this.days = gap ? ((gap + (orient * 7)) % 7) : (orient * 7); return this; }, setMonthsFromMonth: function (today, orient) { var gap; orient = orient || 1; this.unit = "month"; gap = (this.month - today.getMonth()); this.months = gap ? ((gap + (orient * 12)) % 12) : (orient * 12); this.month = null; return this; }, setDMYFromWeekday: function () { var d = Date[this.weekday](); this.day = d.getDate(); if (!this.month) { this.month = d.getMonth(); } this.year = d.getFullYear(); return this; }, setUnitValue: function (orient) { if (!this.value && this.operator && this.operator !== null && this[this.unit + "s"] && this[this.unit + "s"] !== null) { this[this.unit + "s"] = this[this.unit + "s"] + ((this.operator === "add") ? 1 : -1) + (this.value||0) * orient; } else if (this[this.unit + "s"] == null || this.operator != null) { if (!this.value) { this.value = 1; } this[this.unit + "s"] = this.value * orient; } }, generateDateFromWeeks: function () { var weekday = (this.weekday !== undefined) ? this.weekday : "today"; var d = Date[weekday]().addWeeks(this.weeks); if (this.now) { d.setTimeToNow(); } return d; } }; $D.Translator = { hour: function (s) { return function () { this.hour = Number(s); }; }, minute: function (s) { return function () { this.minute = Number(s); }; }, second: function (s) { return function () { this.second = Number(s); }; }, /* for ss.s format */ secondAndMillisecond: function (s) { return function () { var mx = s.match(/^([0-5][0-9])\.([0-9]{1,3})/); this.second = Number(mx[1]); this.millisecond = Number(mx[2]); }; }, meridian: function (s) { return function () { this.meridian = s.slice(0, 1).toLowerCase(); }; }, timezone: function (s) { return function () { var n = s.replace(/[^\d\+\-]/g, ""); if (n.length) { this.timezoneOffset = Number(n); } else { this.timezone = s.toLowerCase(); } }; }, day: function (x) { var s = x[0]; return function () { this.day = Number(s.match(/\d+/)[0]); if (this.day < 1) { throw "invalid day"; } }; }, month: function (s) { return function () { this.month = (s.length === 3) ? "jan feb mar apr may jun jul aug sep oct nov dec".indexOf(s)/4 : Number(s) - 1; if (this.month < 0) { throw "invalid month"; } }; }, year: function (s) { return function () { var n = Number(s); this.year = ((s.length > 2) ? n : (n + (((n + 2000) < Date.CultureInfo.twoDigitYearMax) ? 2000 : 1900))); }; }, rday: function (s) { return function () { switch (s) { case "yesterday": this.days = -1; break; case "tomorrow": this.days = 1; break; case "today": this.days = 0; break; case "now": this.days = 0; this.now = true; break; } }; }, finishExact: function (x) { var d; x = (x instanceof Array) ? x : [x]; for (var i = 0 ; i < x.length ; i++) { if (x[i]) { x[i].call(this); } } setDefaults.call(this); parseMeridian.call(this); if (this.day > $D.getDaysInMonth(this.year, this.month)) { throw new RangeError(this.day + " is not a valid value for days."); } d = new Date(this.year, this.month, this.day, this.hour, this.minute, this.second, this.millisecond); if (this.year < 100) { d.setFullYear(this.year); // means years less that 100 are process correctly. JS will parse it otherwise as 1900-1999. } if (this.timezone) { d.set({ timezone: this.timezone }); } else if (this.timezoneOffset) { d.set({ timezoneOffset: this.timezoneOffset }); } return d; }, finish: function (x) { var today, expression, orient, temp; x = (x instanceof Array) ? flattenAndCompact(x) : [ x ]; if (x.length === 0) { return null; } for (var i = 0 ; i < x.length ; i++) { if (typeof x[i] === "function") { x[i].call(this); } } if (this.now && !this.unit && !this.operator) { return new Date(); } else { today = finishUtils.getToday.call(this); } expression = !!(this.days && this.days !== null || this.orient || this.operator); orient = ((this.orient === "past" || this.operator === "subtract") ? -1 : 1); if (this.month && this.unit === "week") { this.value = this.month + 1; delete this.month; delete this.day; } if ((this.month || this.month === 0) && "year day hour minute second".indexOf(this.unit) !== -1) { if (!this.value) { this.value = this.month + 1; } this.month = null; expression = true; } if (!expression && this.weekday && !this.day && !this.days) { finishUtils.setDMYFromWeekday.call(this); } if (expression && this.weekday && this.unit !== "month" && this.unit !== "week") { finishUtils.setDaysFromWeekday.call(this, today, orient); } if (this.weekday && this.unit !== "week" && !this.day && !this.days) { temp = Date[this.weekday](); this.day = temp.getDate(); if (temp.getMonth() !== today.getMonth()) { this.month = temp.getMonth(); } } if (this.month && this.unit === "day" && this.operator) { if (!this.value) { this.value = (this.month + 1); } this.month = null; } if (this.value != null && this.month != null && this.year != null) { this.day = this.value * 1; } if (this.month && !this.day && this.value) { today.set({ day: this.value * 1 }); if (!expression) { this.day = this.value * 1; } } if (!this.month && this.value && this.unit === "month" && !this.now) { this.month = this.value; expression = true; } if (expression && (this.month || this.month === 0) && this.unit !== "year") { finishUtils.setMonthsFromMonth.call(this, today, orient); } if (!this.unit) { this.unit = "day"; } finishUtils.setUnitValue.call(this, orient); parseMeridian.call(this); if ((this.month || this.month === 0) && !this.day) { this.day = 1; } if (!this.orient && !this.operator && this.unit === "week" && this.value && !this.day && !this.month) { return Date.today().setWeek(this.value); } if (this.unit === "week" && this.weeks && !this.day && !this.month) { return finishUtils.generateDateFromWeeks.call(this); } if (expression && this.timezone && this.day && this.days) { this.day = this.days; } if (expression){ today.add(this); } else { today.set(this); } if (this.timezone) { this.timezone = this.timezone.toUpperCase(); var offset = $D.getTimezoneOffset(this.timezone); var timezone; if (today.hasDaylightSavingTime()) { // lets check that we're being sane with timezone setting timezone = $D.getTimezoneAbbreviation(offset, today.isDaylightSavingTime()); if (timezone !== this.timezone) { // bugger, we're in a place where things like EST vs EDT matters. if (today.isDaylightSavingTime()) { today.addHours(-1); } else { today.addHours(1); } } } today.setTimezoneOffset(offset); } return today; } }; }()); (function () { var $D = Date; $D.Grammar = {}; var _ = $D.Parsing.Operators, g = $D.Grammar, t = $D.Translator, _fn; // Allow rolling up into general purpose rules _fn = function () { return _.each(_.any.apply(null, arguments), _.not(g.ctoken2("timeContext"))); }; g.datePartDelimiter = _.rtoken(/^([\s\-\.\,\/\x27]+)/); g.timePartDelimiter = _.stoken(":"); g.whiteSpace = _.rtoken(/^\s*/); g.generalDelimiter = _.rtoken(/^(([\s\,]|at|@|on)+)/); var _C = {}; g.ctoken = function (keys) { var fn = _C[keys]; if (! fn) { var c = Date.CultureInfo.regexPatterns; var kx = keys.split(/\s+/), px = []; for (var i = 0; i < kx.length ; i++) { px.push(_.replace(_.rtoken(c[kx[i]]), kx[i])); } fn = _C[keys] = _.any.apply(null, px); } return fn; }; g.ctoken2 = function (key) { return _.rtoken(Date.CultureInfo.regexPatterns[key]); }; var cacheProcessRtoken = function (key, token, type, eachToken) { if (eachToken) { g[key] = _.cache(_.process(_.each(_.rtoken(token),_.optional(g.ctoken2(eachToken))), type)); } else { g[key] = _.cache(_.process(_.rtoken(token), type)); } }; var cacheProcessCtoken = function (token, type) { return _.cache(_.process(g.ctoken2(token), type)); }; var _F = {}; //function cache var _get = function (f) { _F[f] = (_F[f] || g.format(f)[0]); return _F[f]; }; g.allformats = function (fx) { var rx = []; if (fx instanceof Array) { for (var i = 0; i < fx.length; i++) { rx.push(_get(fx[i])); } } else { rx.push(_get(fx)); } return rx; }; g.formats = function (fx) { if (fx instanceof Array) { var rx = []; for (var i = 0 ; i < fx.length ; i++) { rx.push(_get(fx[i])); } return _.any.apply(null, rx); } else { return _get(fx); } }; var grammarFormats = { timeFormats: function(){ var i, RTokenKeys = [ "h", "hh", "H", "HH", "m", "mm", "s", "ss", "ss.s", "z", "zz" ], RToken = [ /^(0[0-9]|1[0-2]|[1-9])/, /^(0[0-9]|1[0-2])/, /^([0-1][0-9]|2[0-3]|[0-9])/, /^([0-1][0-9]|2[0-3])/, /^([0-5][0-9]|[0-9])/, /^[0-5][0-9]/, /^([0-5][0-9]|[0-9])/, /^[0-5][0-9]/, /^[0-5][0-9]\.[0-9]{1,3}/, /^((\+|\-)\s*\d\d\d\d)|((\+|\-)\d\d\:?\d\d)/, /^((\+|\-)\s*\d\d\d\d)|((\+|\-)\d\d\:?\d\d)/ ], tokens = [ t.hour, t.hour, t.hour, t.hour, t.minute, t.minute, t.second, t.second, t.secondAndMillisecond, t.timezone, t.timezone ]; for (i=0; i < RTokenKeys.length; i++) { cacheProcessRtoken(RTokenKeys[i], RToken[i], tokens[i]); } g.hms = _.cache(_.sequence([g.H, g.m, g.s], g.timePartDelimiter)); g.t = cacheProcessCtoken("shortMeridian", t.meridian); g.tt = cacheProcessCtoken("longMeridian", t.meridian); g.zzz = cacheProcessCtoken("timezone", t.timezone); g.timeSuffix = _.each(_.ignore(g.whiteSpace), _.set([ g.tt, g.zzz ])); g.time = _.each(_.optional(_.ignore(_.stoken("T"))), g.hms, g.timeSuffix); }, dateFormats: function () { // pre-loaded rules for different date part order preferences var _setfn = function () { return _.set(arguments, g.datePartDelimiter); }; var i, RTokenKeys = [ "d", "dd", "M", "MM", "y", "yy", "yyy", "yyyy" ], RToken = [ /^([0-2]\d|3[0-1]|\d)/, /^([0-2]\d|3[0-1])/, /^(1[0-2]|0\d|\d)/, /^(1[0-2]|0\d)/, /^(\d+)/, /^(\d\d)/, /^(\d\d?\d?\d?)/, /^(\d\d\d\d)/ ], tokens = [ t.day, t.day, t.month, t.month, t.year, t.year, t.year, t.year ], eachToken = [ "ordinalSuffix", "ordinalSuffix" ]; for (i=0; i < RTokenKeys.length; i++) { cacheProcessRtoken(RTokenKeys[i], RToken[i], tokens[i], eachToken[i]); } g.MMM = g.MMMM = _.cache(_.process(g.ctoken("jan feb mar apr may jun jul aug sep oct nov dec"), t.month)); g.ddd = g.dddd = _.cache(_.process(g.ctoken("sun mon tue wed thu fri sat"), function (s) { return function () { this.weekday = s; }; } )); g.day = _fn(g.d, g.dd); g.month = _fn(g.M, g.MMM); g.year = _fn(g.yyyy, g.yy); g.mdy = _setfn(g.ddd, g.month, g.day, g.year); g.ymd = _setfn(g.ddd, g.year, g.month, g.day); g.dmy = _setfn(g.ddd, g.day, g.month, g.year); g.date = function (s) { return ((g[Date.CultureInfo.dateElementOrder] || g.mdy).call(this, s)); }; }, relative: function () { // relative date / time expressions g.orientation = _.process(g.ctoken("past future"), function (s) { return function () { this.orient = s; }; } ); g.operator = _.process(g.ctoken("add subtract"), function (s) { return function () { this.operator = s; }; } ); g.rday = _.process(g.ctoken("yesterday tomorrow today now"), t.rday); g.unit = _.process(g.ctoken("second minute hour day week month year"), function (s) { return function () { this.unit = s; }; } ); } }; g.buildGrammarFormats = function () { // these need to be rebuilt every time the language changes. _C = {}; grammarFormats.timeFormats(); grammarFormats.dateFormats(); grammarFormats.relative(); g.value = _.process(_.rtoken(/^([-+]?\d+)?(st|nd|rd|th)?/), function (s) { return function () { this.value = s.replace(/\D/g, ""); }; } ); g.expression = _.set([g.rday, g.operator, g.value, g.unit, g.orientation, g.ddd, g.MMM ]); g.format = _.process(_.many( _.any( // translate format specifiers into grammar rules _.process( _.rtoken(/^(dd?d?d?(?!e)|MM?M?M?|yy?y?y?|hh?|HH?|mm?|ss?|tt?|zz?z?)/), function (fmt) { if (g[fmt]) { return g[fmt]; } else { throw $D.Parsing.Exception(fmt); } } ), // translate separator tokens into token rules _.process(_.rtoken(/^[^dMyhHmstz]+/), // all legal separators function (s) { return _.ignore(_.stoken(s)); } ) ) ), // construct the parser ... function (rules) { return _.process(_.each.apply(null, rules), t.finishExact); } ); // starting rule for general purpose grammar g._start = _.process(_.set([ g.date, g.time, g.expression ], g.generalDelimiter, g.whiteSpace), t.finish); }; g.buildGrammarFormats(); // parsing date format specifiers - ex: "h:m:s tt" // this little guy will generate a custom parser based // on the format string, ex: g.format("h:m:s tt") // check for these formats first g._formats = g.formats([ "\"yyyy-MM-ddTHH:mm:ssZ\"", "yyyy-MM-ddTHH:mm:ss.sz", "yyyy-MM-ddTHH:mm:ssZ", "yyyy-MM-ddTHH:mm:ssz", "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-ddTHH:mmZ", "yyyy-MM-ddTHH:mmz", "yyyy-MM-ddTHH:mm", "ddd, MMM dd, yyyy H:mm:ss tt", "ddd MMM d yyyy HH:mm:ss zzz", "MMddyyyy", "ddMMyyyy", "Mddyyyy", "ddMyyyy", "Mdyyyy", "dMyyyy", "yyyy", "Mdyy", "dMyy", "d" ]); // real starting rule: tries selected formats first, // then general purpose rule g.start = function (s) { try { var r = g._formats.call({}, s); if (r[1].length === 0) { return r; } } catch (e) {} return g._start.call({}, s); }; }()); (function () { var $D = Date; /** * @desc Converts the specified string value into its JavaScript Date equivalent using CultureInfo specific format information. * * Example

	///////////
	// Dates //
	///////////

	// 15-Oct-2004
	var d1 = Date.parse("10/15/2004");

	// 15-Oct-2004
	var d1 = Date.parse("15-Oct-2004");

	// 15-Oct-2004
	var d1 = Date.parse("2004.10.15");

	//Fri Oct 15, 2004
	var d1 = Date.parse("Fri Oct 15, 2004");

	///////////
	// Times //
	///////////

	// Today at 10 PM.
	var d1 = Date.parse("10 PM");

	// Today at 10:30 PM.
	var d1 = Date.parse("10:30 P.M.");

	// Today at 6 AM.
	var d1 = Date.parse("06am");

	/////////////////////
	// Dates and Times //
	/////////////////////

	// 8-July-2004 @ 10:30 PM
	var d1 = Date.parse("July 8th, 2004, 10:30 PM");

	// 1-July-2004 @ 10:30 PM
	var d1 = Date.parse("2004-07-01T22:30:00");

	////////////////////
	// Relative Dates //
	////////////////////

	// Returns today's date. The string "today" is culture specific.
	var d1 = Date.parse("today");

	// Returns yesterday's date. The string "yesterday" is culture specific.
	var d1 = Date.parse("yesterday");

	// Returns the date of the next thursday.
	var d1 = Date.parse("Next thursday");

	// Returns the date of the most previous monday.
	var d1 = Date.parse("last monday");

	// Returns today's day + one year.
	var d1 = Date.parse("next year");

	///////////////
	// Date Math //
	///////////////

	// Today + 2 days
	var d1 = Date.parse("t+2");

	// Today + 2 days
	var d1 = Date.parse("today + 2 days");

	// Today + 3 months
	var d1 = Date.parse("t+3m");

	// Today - 1 year
	var d1 = Date.parse("today - 1 year");

	// Today - 1 year
	var d1 = Date.parse("t-1y"); 


	/////////////////////////////
	// Partial Dates and Times //
	/////////////////////////////

	// July 15th of this year.
	var d1 = Date.parse("July 15");

	// 15th day of current day and year.
	var d1 = Date.parse("15");

	// July 1st of current year at 10pm.
	var d1 = Date.parse("7/1 10pm");
	
* * @param {String} The string value to convert into a Date object [Required] * @return {Date} A Date object or null if the string cannot be converted into a Date. */ var parseUtils = { removeOrds: function (s) { ords = s.match(/\b(\d+)(?:st|nd|rd|th)\b/); // find ordinal matches s = ((ords && ords.length === 2) ? s.replace(ords[0], ords[1]) : s); return s; }, grammarParser: function (s) { var r = null; try { r = $D.Grammar.start.call({}, s.replace(/^\s*(\S*(\s+\S+)*)\s*$/, "$1")); } catch (e) { return null; } return ((r[1].length === 0) ? r[0] : null); }, nativeFallback: function(s) { var t; try { // ok we haven't parsed it, last ditch attempt with the built-in parser. t = Date._parse(s); return (t || t === 0) ? new Date(t) : null; } catch (e) { return null; } } }; function parse (s) { var d; if (!s) { return null; } if (s instanceof Date) { return s.clone(); } if (s.length >= 4 && s.charAt(0) !== "0" && s.charAt(0) !== "+"&& s.charAt(0) !== "-") { // ie: 2004 will pass, 0800 won't. // Start with specific formats d = $D.Parsing.ISO.parse(s) || $D.Parsing.Numeric.parse(s); } if (d instanceof Date && !isNaN(d.getTime())) { return d; } else { // find ordinal dates (1st, 3rd, 8th, etc and remove them as they cause parsing issues) s = $D.Parsing.Normalizer.parse(parseUtils.removeOrds(s)); d = parseUtils.grammarParser(s); if (d !== null) { return d; } else { return parseUtils.nativeFallback(s); } } } if (!$D._parse) { $D._parse = $D.parse; } $D.parse = parse; Date.getParseFunction = function (fx) { var fns = Date.Grammar.allformats(fx); return function (s) { var r = null; for (var i = 0; i < fns.length; i++) { try { r = fns[i].call({}, s); } catch (e) { continue; } if (r[1].length === 0) { return r[0]; } } return null; }; }; /** * Converts the specified string value into its JavaScript Date equivalent using the specified format {String} or formats {Array} and the CultureInfo specific format information. * The format of the string value must match one of the supplied formats exactly. * * Example

	// 15-Oct-2004
	var d1 = Date.parseExact("10/15/2004", "M/d/yyyy");

	// 15-Oct-2004
	var d1 = Date.parse("15-Oct-2004", "M-ddd-yyyy");

	// 15-Oct-2004
	var d1 = Date.parse("2004.10.15", "yyyy.MM.dd");

	// Multiple formats
	var d1 = Date.parseExact("10/15/2004", ["M/d/yyyy", "MMMM d, yyyy"]);
	
* * @param {String} The string value to convert into a Date object [Required]. * @param {Object} The expected format {String} or an array of expected formats {Array} of the date string [Required]. * @return {Date} A Date object or null if the string cannot be converted into a Date. */ $D.parseExact = function (s, fx) { return $D.getParseFunction(fx)(s); }; }()); (function () { var $D = Date, $P = $D.prototype, // $C = $D.CultureInfo, // not used atm p = function (s, l) { if (!l) { l = 2; } return ("000" + s).slice(l * -1); }; /** * Converts a PHP format string to Java/.NET format string. * A PHP format string can be used with ._format or .format. * A Java/.NET format string can be used with .toString(). * The .parseExact function will only accept a Java/.NET format string * * Example * var f1 = "%m/%d/%y" * var f2 = Date.normalizeFormat(f1); // "MM/dd/yy" * * new Date().format(f1); // "04/13/08" * new Date()._format(f1); // "04/13/08" * new Date().toString(f2); // "04/13/08" * * var date = Date.parseExact("04/13/08", f2); // Sun Apr 13 2008 * * @param {String} A PHP format string consisting of one or more format spcifiers. * @return {String} The PHP format converted to a Java/.NET format string. */ var normalizerSubstitutions = { "d" : "dd", "%d": "dd", "D" : "ddd", "%a": "ddd", "j" : "dddd", "l" : "dddd", "%A": "dddd", "S" : "S", "F" : "MMMM", "%B": "MMMM", "m" : "MM", "%m": "MM", "M" : "MMM", "%b": "MMM", "%h": "MMM", "n" : "M", "Y" : "yyyy", "%Y": "yyyy", "y" : "yy", "%y": "yy", "g" : "h", "%I": "h", "G" : "H", "h" : "hh", "H" : "HH", "%H": "HH", "i" : "mm", "%M": "mm", "s" : "ss", "%S": "ss", "%r": "hh:mm tt", "%R": "H:mm", "%T": "H:mm:ss", "%X": "t", "%x": "d", "%e": "d", "%D": "MM/dd/yy", "%n": "\\n", "%t": "\\t", "e" : "z", "T" : "z", "%z": "z", "%Z": "z", "Z" : "ZZ", "N" : "u", "w" : "u", "%w": "u", "W" : "W", "%V": "W" }; var normalizer = { substitutes: function (m) { return normalizerSubstitutions[m]; }, interpreted: function (m, x) { var y; switch (m) { case "%u": return x.getDay() + 1; case "z": return x.getOrdinalNumber(); case "%j": return p(x.getOrdinalNumber(), 3); case "%U": var d1 = x.clone().set({month: 0, day: 1}).addDays(-1).moveToDayOfWeek(0), d2 = x.clone().addDays(1).moveToDayOfWeek(0, -1); return (d2 < d1) ? "00" : p((d2.getOrdinalNumber() - d1.getOrdinalNumber()) / 7 + 1); case "%W": return p(x.getWeek()); case "t": return $D.getDaysInMonth(x.getFullYear(), x.getMonth()); case "o": case "%G": return x.setWeek(x.getISOWeek()).toString("yyyy"); case "%g": return x._format("%G").slice(-2); case "a": case "%p": return t("tt").toLowerCase(); case "A": return t("tt").toUpperCase(); case "u": return p(x.getMilliseconds(), 3); case "I": return (x.isDaylightSavingTime()) ? 1 : 0; case "O": return x.getUTCOffset(); case "P": y = x.getUTCOffset(); return y.substring(0, y.length - 2) + ":" + y.substring(y.length - 2); case "B": var now = new Date(); return Math.floor(((now.getHours() * 3600) + (now.getMinutes() * 60) + now.getSeconds() + (now.getTimezoneOffset() + 60) * 60) / 86.4); case "c": return x.toISOString().replace(/\"/g, ""); case "U": return $D.strtotime("now"); case "%c": return t("d") + " " + t("t"); case "%C": return Math.floor(x.getFullYear() / 100 + 1); } }, shouldOverrideDefaults: function (m) { switch (m) { case "%e": return true; default: return false; } }, parse: function (m, context) { var formatString, c = context || new Date(); formatString = normalizer.substitutes(m); if (formatString) { return formatString; } formatString = normalizer.interpreted(m, c); if (formatString) { return formatString; } else { return m; } } }; $D.normalizeFormat = function (format, context) { return format.replace(/(%|\\)?.|%%/g, function(t){ return normalizer.parse(t, context); }); }; /** * Format a local Unix timestamp according to locale settings * * Example: * Date.strftime("%m/%d/%y", new Date()); // "04/13/08" * Date.strftime("c", "2008-04-13T17:52:03Z"); // "04/13/08" * * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @param {Number|String} The number representing the number of seconds that have elapsed since January 1, 1970 (local time). * @return {String} A string representation of the current Date object. */ $D.strftime = function (format, time) { var d = Date.parse(time); return d._format(format); }; /** * Parse any textual datetime description into a Unix timestamp. * A Unix timestamp is the number of seconds that have elapsed since January 1, 1970 (midnight UTC/GMT). * * Example: * Date.strtotime("04/13/08"); // 1208044800 * Date.strtotime("1970-01-01T00:00:00Z"); // 0 * * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @param {Object} A string or date object. * @return {String} A string representation of the current Date object. */ $D.strtotime = function (time) { var d = $D.parse(time); return Math.round($D.UTC(d.getUTCFullYear(), d.getUTCMonth(), d.getUTCDate(), d.getUTCHours(), d.getUTCMinutes(), d.getUTCSeconds(), d.getUTCMilliseconds()) / 1000); }; /** * Converts the value of the current Date object to its equivalent string representation using a PHP/Unix style of date format specifiers. * Format Specifiers * Format Description Example * ------ --------------------------------------------------------------------------- ----------------------- * %a abbreviated weekday name according to the current localed "Mon" through "Sun" * %A full weekday name according to the current localed "Sunday" through "Saturday" * %b abbreviated month name according to the current localed "Jan" through "Dec" * %B full month name according to the current locale "January" through "December" * %c preferred date and time representation for the current locale "4/13/2008 12:33 PM" * %C century number (the year divided by 100 and truncated to an integer) "00" to "99" * %d day of the month as a decimal number "01" to "31" * %D same as %m/%d/%y "04/13/08" * %e day of the month as a decimal number, a single digit is preceded by a space "1" to "31" * %g like %G, but without the century "08" * %G The 4-digit year corresponding to the ISO week number (see %V). "2008" * This has the same format and value as %Y, except that if the ISO week number * belongs to the previous or next year, that year is used instead. * %h same as %b "Jan" through "Dec" * %H hour as a decimal number using a 24-hour clock. "00" to "23" * %I hour as a decimal number using a 12-hour clock. "01" to "12" * %j day of the year as a decimal number. "001" to "366" * %m month as a decimal number. "01" to "12" * %M minute as a decimal number. "00" to "59" * %n newline character "\n" * %p either "am" or "pm" according to the given time value, or the "am" or "pm" * corresponding strings for the current locale. * %r time in a.m. and p.m. notation "8:44 PM" * %R time in 24 hour notation "20:44" * %S second as a decimal number "00" to "59" * %t tab character "\t" * %T current time, equal to %H:%M:%S "12:49:11" * %u weekday as a decimal number ["1", "7"], with "1" representing Monday "1" to "7" * %U week number of the current year as a decimal number, starting with the "0" to ("52" or "53") * first Sunday as the first day of the first week * %V The ISO 8601:1988 week number of the current year as a decimal number, "00" to ("52" or "53") * range 01 to 53, where week 1 is the first week that has at least 4 days * in the current year, and with Monday as the first day of the week. * (Use %G or %g for the year component that corresponds to the week number * for the specified timestamp.) * %W week number of the current year as a decimal number, starting with the "00" to ("52" or "53") * first Monday as the first day of the first week * %w day of the week as a decimal, Sunday being "0" "0" to "6" * %x preferred date representation for the current locale without the time "4/13/2008" * %X preferred time representation for the current locale without the date "12:53:05" * %y year as a decimal number without a century "00" "99" * %Y year as a decimal number including the century "2008" * %Z time zone or name or abbreviation "UTC", "EST", "PST" * %z same as %Z * %% a literal "%" characters "%" * d Day of the month, 2 digits with leading zeros "01" to "31" * D A textual representation of a day, three letters "Mon" through "Sun" * j Day of the month without leading zeros "1" to "31" * l A full textual representation of the day of the week (lowercase "L") "Sunday" through "Saturday" * N ISO-8601 numeric representation of the day of the week (added in PHP 5.1.0) "1" (for Monday) through "7" (for Sunday) * S English ordinal suffix for the day of the month, 2 characters "st", "nd", "rd" or "th". Works well with j * w Numeric representation of the day of the week "0" (for Sunday) through "6" (for Saturday) * z The day of the year (starting from "0") "0" through "365" * W ISO-8601 week number of year, weeks starting on Monday "00" to ("52" or "53") * F A full textual representation of a month, such as January or March "January" through "December" * m Numeric representation of a month, with leading zeros "01" through "12" * M A short textual representation of a month, three letters "Jan" through "Dec" * n Numeric representation of a month, without leading zeros "1" through "12" * t Number of days in the given month "28" through "31" * L Whether it's a leap year "1" if it is a leap year, "0" otherwise * o ISO-8601 year number. This has the same value as Y, except that if the "2008" * ISO week number (W) belongs to the previous or next year, that year * is used instead. * Y A full numeric representation of a year, 4 digits "2008" * y A two digit representation of a year "08" * a Lowercase Ante meridiem and Post meridiem "am" or "pm" * A Uppercase Ante meridiem and Post meridiem "AM" or "PM" * B Swatch Internet time "000" through "999" * g 12-hour format of an hour without leading zeros "1" through "12" * G 24-hour format of an hour without leading zeros "0" through "23" * h 12-hour format of an hour with leading zeros "01" through "12" * H 24-hour format of an hour with leading zeros "00" through "23" * i Minutes with leading zeros "00" to "59" * s Seconds, with leading zeros "00" through "59" * u Milliseconds "54321" * e Timezone identifier "UTC", "EST", "PST" * I Whether or not the date is in daylight saving time (uppercase i) "1" if Daylight Saving Time, "0" otherwise * O Difference to Greenwich time (GMT) in hours "+0200", "-0600" * P Difference to Greenwich time (GMT) with colon between hours and minutes "+02:00", "-06:00" * T Timezone abbreviation "UTC", "EST", "PST" * Z Timezone offset in seconds. The offset for timezones west of UTC is "-43200" through "50400" * always negative, and for those east of UTC is always positive. * c ISO 8601 date "2004-02-12T15:19:21+00:00" * r RFC 2822 formatted date "Thu, 21 Dec 2000 16:01:07 +0200" * U Seconds since the Unix Epoch (January 1 1970 00:00:00 GMT) "0" * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @return {String} A string representation of the current Date object. */ var formatReplace = function (context) { return function (m) { var formatString, override = false; if (m.charAt(0) === "\\" || m.substring(0, 2) === "%%") { return m.replace("\\", "").replace("%%", "%"); } override = normalizer.shouldOverrideDefaults(m); formatString = $D.normalizeFormat(m, context); if (formatString) { return context.toString(formatString, override); } }; }; $P._format = function (format) { var formatter = formatReplace(this); if (!format) { return this._toString(); } else { return format.replace(/(%|\\)?.|%%/g, formatter); } }; if (!$P.format) { $P.format = $P._format; } }()); (function () { "use strict"; var gFn = function (attr) { return function () { return this[attr]; }; }; var sFn = function (attr) { return function (val) { this[attr] = val; return this; }; }; var attrs = ["years", "months", "days", "hours", "minutes", "seconds", "milliseconds"]; var addSetFuncs = function (context, attrs) { for (var i = 0; i < attrs.length ; i++) { var $a = attrs[i], $b = $a.slice(0, 1).toUpperCase() + $a.slice(1); context.prototype[$a] = 0; context.prototype["get" + $b] = gFn($a); context.prototype["set" + $b] = sFn($a); } }; /** * new TimeSpan(milliseconds); * new TimeSpan(days, hours, minutes, seconds); * new TimeSpan(days, hours, minutes, seconds, milliseconds); */ var TimeSpan = function (days, hours, minutes, seconds, milliseconds) { if (arguments.length === 1 && typeof days === "number") { var orient = (days < 0) ? -1 : +1; var millsLeft = Math.abs(days); this.setDays(Math.floor(millsLeft / 86400000) * orient); millsLeft = millsLeft % 86400000; this.setHours(Math.floor(millsLeft / 3600000) * orient); millsLeft = millsLeft % 3600000; this.setMinutes(Math.floor(millsLeft / 60000) * orient); millsLeft = millsLeft % 60000; this.setSeconds(Math.floor(millsLeft / 1000) * orient); millsLeft = millsLeft % 1000; this.setMilliseconds(millsLeft * orient); } else { this.set(days, hours, minutes, seconds, milliseconds); } this.getTotalMilliseconds = function () { return (this.getDays() * 86400000) + (this.getHours() * 3600000) + (this.getMinutes() * 60000) + (this.getSeconds() * 1000); }; this.compareTo = function (time) { var t1 = new Date(1970, 1, 1, this.getHours(), this.getMinutes(), this.getSeconds()), t2; if (time === null) { t2 = new Date(1970, 1, 1, 0, 0, 0); } else { t2 = new Date(1970, 1, 1, time.getHours(), time.getMinutes(), time.getSeconds()); } return (t1 < t2) ? -1 : (t1 > t2) ? 1 : 0; }; this.equals = function (time) { return (this.compareTo(time) === 0); }; this.add = function (time) { return (time === null) ? this : this.addSeconds(time.getTotalMilliseconds() / 1000); }; this.subtract = function (time) { return (time === null) ? this : this.addSeconds(-time.getTotalMilliseconds() / 1000); }; this.addDays = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 86400000)); }; this.addHours = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 3600000)); }; this.addMinutes = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 60000)); }; this.addSeconds = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 1000)); }; this.addMilliseconds = function (n) { return new TimeSpan(this.getTotalMilliseconds() + n); }; this.get12HourHour = function () { return (this.getHours() > 12) ? this.getHours() - 12 : (this.getHours() === 0) ? 12 : this.getHours(); }; this.getDesignator = function () { return (this.getHours() < 12) ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator; }; this.toString = function (format) { this._toString = function () { if (this.getDays() !== null && this.getDays() > 0) { return this.getDays() + "." + this.getHours() + ":" + this.p(this.getMinutes()) + ":" + this.p(this.getSeconds()); } else { return this.getHours() + ":" + this.p(this.getMinutes()) + ":" + this.p(this.getSeconds()); } }; this.p = function (s) { return (s.toString().length < 2) ? "0" + s : s; }; var me = this; return format ? format.replace(/dd?|HH?|hh?|mm?|ss?|tt?/g, function (format) { switch (format) { case "d": return me.getDays(); case "dd": return me.p(me.getDays()); case "H": return me.getHours(); case "HH": return me.p(me.getHours()); case "h": return me.get12HourHour(); case "hh": return me.p(me.get12HourHour()); case "m": return me.getMinutes(); case "mm": return me.p(me.getMinutes()); case "s": return me.getSeconds(); case "ss": return me.p(me.getSeconds()); case "t": return ((me.getHours() < 12) ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator).substring(0, 1); case "tt": return (me.getHours() < 12) ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator; } } ) : this._toString(); }; return this; }; addSetFuncs(TimeSpan, attrs.slice(2)); TimeSpan.prototype.set = function (days, hours, minutes, seconds, milliseconds){ this.setDays(days || this.getDays()); this.setHours(hours || this.getHours()); this.setMinutes(minutes || this.getMinutes()); this.setSeconds(seconds || this.getSeconds()); this.setMilliseconds(milliseconds || this.getMilliseconds()); }; /** * Gets the time of day for this date instances. * @return {TimeSpan} TimeSpan */ Date.prototype.getTimeOfDay = function () { return new TimeSpan(0, this.getHours(), this.getMinutes(), this.getSeconds(), this.getMilliseconds()); }; Date.TimeSpan = TimeSpan; if (typeof window !== "undefined" ) { // keeping API compatible for v1.x window.TimeSpan = TimeSpan; } }()); (function () { "use strict"; var attrs = ["years", "months", "days", "hours", "minutes", "seconds", "milliseconds"]; var gFn = function (attr) { return function () { return this[attr]; }; }; var sFn = function (attr) { return function (val) { this[attr] = val; return this; }; }; var addSetFuncs = function (context, attrs) { for (var i = 0; i < attrs.length ; i++) { var $a = attrs[i], $b = $a.slice(0, 1).toUpperCase() + $a.slice(1); context.prototype[$a] = 0; context.prototype["get" + $b] = gFn($a); context.prototype["set" + $b] = sFn($a); } }; var setMonthsAndYears = function (orient, d1, d2, context) { function inc() { d1.addMonths(-orient); context.months++; if (context.months === 12) { context.years++; context.months = 0; } } if (orient === +1) { while (d1 > d2) { inc(); } } else { while (d1 < d2) { inc(); } } context.months--; context.months *= orient; context.years *= orient; }; var adjustForDST = function(orient, startDate, endDate) { var hasDSTMismatch = (false === (startDate.isDaylightSavingTime() === endDate.isDaylightSavingTime())); if (hasDSTMismatch && orient === 1) { startDate.addHours(-1); } else if (hasDSTMismatch) { startDate.addHours(1); } }; /** * TimePeriod(startDate, endDate); * TimePeriod(years, months, days, hours, minutes, seconds, milliseconds); */ var TimePeriod = function (years, months, days, hours, minutes, seconds, milliseconds) { if (arguments.length === 7) { this.set(years, months, days, hours, minutes, seconds, milliseconds); } else if (arguments.length === 2 && arguments[0] instanceof Date && arguments[1] instanceof Date) { var startDate = arguments[0].clone(); var endDate = arguments[1].clone(); var orient = (startDate > endDate) ? +1 : -1; this.dates = { start: arguments[0].clone(), end: arguments[1].clone() }; setMonthsAndYears(orient, startDate, endDate, this); adjustForDST(orient, startDate, endDate); // // TODO - adjust for DST var diff = endDate - startDate; if (diff !== 0) { var ts = new TimeSpan(diff); this.set(this.years, this.months, ts.getDays(), ts.getHours(), ts.getMinutes(), ts.getSeconds(), ts.getMilliseconds()); } } return this; }; // create all the set functions. addSetFuncs(TimePeriod, attrs); TimePeriod.prototype.set = function (years, months, days, hours, minutes, seconds, milliseconds){ this.setYears(years || this.getYears()); this.setMonths(months || this.getMonths()); this.setDays(days || this.getDays()); this.setHours(hours || this.getHours()); this.setMinutes(minutes || this.getMinutes()); this.setSeconds(seconds || this.getSeconds()); this.setMilliseconds(milliseconds || this.getMilliseconds()); }; Date.TimePeriod = TimePeriod; if (typeof window !== "undefined") { // keeping API compatible for v1.x window.TimePeriod = TimePeriod; } }()); ================================================ FILE: build/date-de-AT.js ================================================ /** * @overview datejs * @version 1.0.0-rc3 * @author Gregory Wild-Smith * @copyright 2015 Gregory Wild-Smith * @license MIT * @homepage https://github.com/abritinthebay/datejs */ /* * DateJS Culture String File * Country Code: de-AT * Name: German (Austria) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["de-AT"] = { "name": "de-AT", "englishName": "German (Austria)", "nativeName": "Deutsch (Österreich)", "Sunday": "Sonntag", "Monday": "Montag", "Tuesday": "Dienstag", "Wednesday": "Mittwoch", "Thursday": "Donnerstag", "Friday": "Freitag", "Saturday": "Samstag", "Sun": "Son", "Mon": "Mon", "Tue": "Die", "Wed": "Mit", "Thu": "Don", "Fri": "Fre", "Sat": "Sam", "Su": "So", "Mo": "Mo", "Tu": "Di", "We": "Mi", "Th": "Do", "Fr": "Fr", "Sa": "Sa", "S_Sun_Initial": "S", "M_Mon_Initial": "M", "T_Tue_Initial": "D", "W_Wed_Initial": "M", "T_Thu_Initial": "D", "F_Fri_Initial": "F", "S_Sat_Initial": "S", "January": "Jänner", "February": "Februar", "March": "März", "April": "April", "May": "Mai", "June": "Juni", "July": "Juli", "August": "August", "September": "September", "October": "Oktober", "November": "November", "December": "Dezember", "Jan_Abbr": "J(ä|a)n", "Feb_Abbr": "Feb", "Mar_Abbr": "(M(a|ä)r|Mrz)", "Apr_Abbr": "Apr", "May_Abbr": "Mai", "Jun_Abbr": "Jun", "Jul_Abbr": "Jul", "Aug_Abbr": "Aug", "Sep_Abbr": "Sep", "Oct_Abbr": "Okt", "Nov_Abbr": "Nov", "Dec_Abbr": "Dez", "AM": "", "PM": "", "firstDayOfWeek": 1, "twoDigitYearMax": 2029, "mdy": "dmy", "M/d/yyyy": "dd.MM.yyyy", "dddd, MMMM dd, yyyy": "dddd, dd. MMMM yyyy", "h:mm tt": "HH:mm", "h:mm:ss tt": "HH:mm:ss", "dddd, MMMM dd, yyyy h:mm:ss tt": "dddd, dd. MMMM yyyy HH:mm:ss", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "dd MMMM", "MMMM, yyyy": "MMMM yyyy", "/jan(uary)?/": "jän(ner)?", "/feb(ruary)?/": "feb(ruar)?", "/mar(ch)?/": "mär(z)?", "/apr(il)?/": "apr(il)?", "/may/": "mai", "/jun(e)?/": "jun(i)?", "/jul(y)?/": "jul(i)?", "/aug(ust)?/": "aug(ust)?", "/sep(t(ember)?)?/": "sep(t(ember)?)?", "/oct(ober)?/": "okt(ober)?", "/nov(ember)?/": "nov(ember)?", "/dec(ember)?/": "dez(ember)?", "/^su(n(day)?)?/": "^sonntag", "/^mo(n(day)?)?/": "^montag", "/^tu(e(s(day)?)?)?/": "^dienstag", "/^we(d(nesday)?)?/": "^mittwoch", "/^th(u(r(s(day)?)?)?)?/": "^donnerstag", "/^fr(i(day)?)?/": "^freitag", "/^sa(t(urday)?)?/": "^samstag", "/^next/": "^nächste(r|s|n)?", "/^last|past|prev(ious)?/": "^letzte(r|s|n)?|vergangene(r|s|n)?|vorherige(r|s|n)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|(da)?nach(er)?|von|daher|in)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|(be|zu)?vor|früher)", "/^yes(terday)?/": "^gestern", "/^t(od(ay)?)?/": "^heute", "/^tom(orrow)?/": "^morgen", "/^n(ow)?/": "^jetzt|sofort|gleich", "/^ms|milli(second)?s?/": "^ms|milli(sekunde(n)?)?", "/^sec(ond)?s?/": "^sek(unde(n)?)?", "/^mn|min(ute)?s?/": "^mn|min(ute(n)?)?", "/^h(our)?s?/": "^h|st(d|unde(n)?)?", "/^w(eek)?s?/": "^w(oche(n)?)?", "/^m(onth)?s?/": "^m(onat(e)?)?", "/^d(ay)?s?/": "^d|t(ag(en)?)?", "/^y(ear)?s?/": "^y|j(ahr(en)?)?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "de-AT"; /** * @overview datejs * @version 1.0.0-rc3 * @author Gregory Wild-Smith * @copyright 2015 Gregory Wild-Smith * @license MIT * @homepage https://github.com/abritinthebay/datejs */(function () { var $D = Date; var lang = Date.CultureStrings ? Date.CultureStrings.lang : null; var loggedKeys = {}; // for debug purposes. var getText = { getFromKey: function (key, countryCode) { var output; if (Date.CultureStrings && Date.CultureStrings[countryCode] && Date.CultureStrings[countryCode][key]) { output = Date.CultureStrings[countryCode][key]; } else { output = getText.buildFromDefault(key); } if (key.charAt(0) === "/") { // Assume it's a regex output = getText.buildFromRegex(key, countryCode); } return output; }, getFromObjectValues: function (obj, countryCode) { var key, output = {}; for(key in obj) { if (obj.hasOwnProperty(key)) { output[key] = getText.getFromKey(obj[key], countryCode); } } return output; }, getFromObjectKeys: function (obj, countryCode) { var key, output = {}; for(key in obj) { if (obj.hasOwnProperty(key)) { output[getText.getFromKey(key, countryCode)] = obj[key]; } } return output; }, getFromArray: function (arr, countryCode) { var output = []; for (var i=0; i < arr.length; i++){ if (i in arr) { output[i] = getText.getFromKey(arr[i], countryCode); } } return output; }, buildFromDefault: function (key) { var output, length, split, last; switch(key) { case "name": output = "en-US"; break; case "englishName": output = "English (United States)"; break; case "nativeName": output = "English (United States)"; break; case "twoDigitYearMax": output = 2049; break; case "firstDayOfWeek": output = 0; break; default: output = key; split = key.split("_"); length = split.length; if (length > 1 && key.charAt(0) !== "/") { // if the key isn't a regex and it has a split. last = split[(length - 1)].toLowerCase(); if (last === "initial" || last === "abbr") { output = split[0]; } } break; } return output; }, buildFromRegex: function (key, countryCode) { var output; if (Date.CultureStrings && Date.CultureStrings[countryCode] && Date.CultureStrings[countryCode][key]) { output = new RegExp(Date.CultureStrings[countryCode][key], "i"); } else { output = new RegExp(key.replace(new RegExp("/", "g"),""), "i"); } return output; } }; var shallowMerge = function (obj1, obj2) { for (var attrname in obj2) { if (obj2.hasOwnProperty(attrname)) { obj1[attrname] = obj2[attrname]; } } }; var __ = function (key, language) { var countryCode = (language) ? language : lang; loggedKeys[key] = key; if (typeof key === "object") { if (key instanceof Array) { return getText.getFromArray(key, countryCode); } else { return getText.getFromObjectKeys(key, countryCode); } } else { return getText.getFromKey(key, countryCode); } }; var loadI18nScript = function (code) { // paatterned after jQuery's getScript. var url = Date.Config.i18n + code + ".js"; var head = document.getElementsByTagName("head")[0] || document.documentElement; var script = document.createElement("script"); script.src = url; var completed = false; var events = { done: function (){} // placeholder function }; // Attach handlers for all browsers script.onload = script.onreadystatechange = function() { if ( !completed && (!this.readyState || this.readyState === "loaded" || this.readyState === "complete") ) { events.done(); head.removeChild(script); } }; setTimeout(function() { head.insertBefore(script, head.firstChild); }, 0); // allows return to execute first return { done: function (cb) { events.done = function() { if (cb) { setTimeout(cb,0); } }; } }; }; var buildInfo = { buildFromMethodHash: function (obj) { var key; for(key in obj) { if (obj.hasOwnProperty(key)) { obj[key] = buildInfo[obj[key]](); } } return obj; }, timeZoneDST: function () { var DST = { "CHADT": "+1345", "NZDT": "+1300", "AEDT": "+1100", "ACDT": "+1030", "AZST": "+0500", "IRDT": "+0430", "EEST": "+0300", "CEST": "+0200", "BST": "+0100", "PMDT": "-0200", "ADT": "-0300", "NDT": "-0230", "EDT": "-0400", "CDT": "-0500", "MDT": "-0600", "PDT": "-0700", "AKDT": "-0800", "HADT": "-0900" }; return __(DST); }, timeZoneStandard: function () { var standard = { "LINT": "+1400", "TOT": "+1300", "CHAST": "+1245", "NZST": "+1200", "NFT": "+1130", "SBT": "+1100", "AEST": "+1000", "ACST": "+0930", "JST": "+0900", "CWST": "+0845", "CT": "+0800", "ICT": "+0700", "MMT": "+0630", "BST": "+0600", "NPT": "+0545", "IST": "+0530", "PKT": "+0500", "AFT": "+0430", "MSK": "+0400", "IRST": "+0330", "FET": "+0300", "EET": "+0200", "CET": "+0100", "GMT": "+0000", "UTC": "+0000", "CVT": "-0100", "GST": "-0200", "BRT": "-0300", "NST": "-0330", "AST": "-0400", "EST": "-0500", "CST": "-0600", "MST": "-0700", "PST": "-0800", "AKST": "-0900", "MIT": "-0930", "HST": "-1000", "SST": "-1100", "BIT": "-1200" }; return __(standard); }, timeZones: function (data) { var zone; data.timezones = []; for (zone in data.abbreviatedTimeZoneStandard) { if (data.abbreviatedTimeZoneStandard.hasOwnProperty(zone)) { data.timezones.push({ name: zone, offset: data.abbreviatedTimeZoneStandard[zone]}); } } for (zone in data.abbreviatedTimeZoneDST) { if (data.abbreviatedTimeZoneDST.hasOwnProperty(zone)) { data.timezones.push({ name: zone, offset: data.abbreviatedTimeZoneDST[zone], dst: true}); } } return data.timezones; }, days: function () { return __(["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"]); }, dayAbbr: function () { return __(["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"]); }, dayShortNames: function () { return __(["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"]); }, dayFirstLetters: function () { return __(["S_Sun_Initial", "M_Mon_Initial", "T_Tues_Initial", "W_Wed_Initial", "T_Thu_Initial", "F_Fri_Initial", "S_Sat_Initial"]); }, months: function () { return __(["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"]); }, monthAbbr: function () { return __(["Jan_Abbr", "Feb_Abbr", "Mar_Abbr", "Apr_Abbr", "May_Abbr", "Jun_Abbr", "Jul_Abbr", "Aug_Abbr", "Sep_Abbr", "Oct_Abbr", "Nov_Abbr", "Dec_Abbr"]); }, formatPatterns: function () { return getText.getFromObjectValues({ shortDate: "M/d/yyyy", longDate: "dddd, MMMM dd, yyyy", shortTime: "h:mm tt", longTime: "h:mm:ss tt", fullDateTime: "dddd, MMMM dd, yyyy h:mm:ss tt", sortableDateTime: "yyyy-MM-ddTHH:mm:ss", universalSortableDateTime: "yyyy-MM-dd HH:mm:ssZ", rfc1123: "ddd, dd MMM yyyy HH:mm:ss", monthDay: "MMMM dd", yearMonth: "MMMM, yyyy" }, Date.i18n.currentLanguage()); }, regex: function () { return getText.getFromObjectValues({ inTheMorning: "/( in the )(morn(ing)?)\\b/", thisMorning: "/(this )(morn(ing)?)\\b/", amThisMorning: "/(\b\\d(am)? )(this )(morn(ing)?)/", inTheEvening: "/( in the )(even(ing)?)\\b/", thisEvening: "/(this )(even(ing)?)\\b/", pmThisEvening: "/(\b\\d(pm)? )(this )(even(ing)?)/", jan: "/jan(uary)?/", feb: "/feb(ruary)?/", mar: "/mar(ch)?/", apr: "/apr(il)?/", may: "/may/", jun: "/jun(e)?/", jul: "/jul(y)?/", aug: "/aug(ust)?/", sep: "/sep(t(ember)?)?/", oct: "/oct(ober)?/", nov: "/nov(ember)?/", dec: "/dec(ember)?/", sun: "/^su(n(day)?)?/", mon: "/^mo(n(day)?)?/", tue: "/^tu(e(s(day)?)?)?/", wed: "/^we(d(nesday)?)?/", thu: "/^th(u(r(s(day)?)?)?)?/", fri: "/fr(i(day)?)?/", sat: "/^sa(t(urday)?)?/", future: "/^next/", past: "/^last|past|prev(ious)?/", add: "/^(\\+|aft(er)?|from|hence)/", subtract: "/^(\\-|bef(ore)?|ago)/", yesterday: "/^yes(terday)?/", today: "/^t(od(ay)?)?/", tomorrow: "/^tom(orrow)?/", now: "/^n(ow)?/", millisecond: "/^ms|milli(second)?s?/", second: "/^sec(ond)?s?/", minute: "/^mn|min(ute)?s?/", hour: "/^h(our)?s?/", week: "/^w(eek)?s?/", month: "/^m(onth)?s?/", day: "/^d(ay)?s?/", year: "/^y(ear)?s?/", shortMeridian: "/^(a|p)/", longMeridian: "/^(a\\.?m?\\.?|p\\.?m?\\.?)/", timezone: "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/", ordinalSuffix: "/^\\s*(st|nd|rd|th)/", timeContext: "/^\\s*(\\:|a(?!u|p)|p)/" }, Date.i18n.currentLanguage()); } }; var CultureInfo = function () { var info = getText.getFromObjectValues({ name: "name", englishName: "englishName", nativeName: "nativeName", amDesignator: "AM", pmDesignator: "PM", firstDayOfWeek: "firstDayOfWeek", twoDigitYearMax: "twoDigitYearMax", dateElementOrder: "mdy" }, Date.i18n.currentLanguage()); var constructedInfo = buildInfo.buildFromMethodHash({ dayNames: "days", abbreviatedDayNames: "dayAbbr", shortestDayNames: "dayShortNames", firstLetterDayNames: "dayFirstLetters", monthNames: "months", abbreviatedMonthNames: "monthAbbr", formatPatterns: "formatPatterns", regexPatterns: "regex", abbreviatedTimeZoneDST: "timeZoneDST", abbreviatedTimeZoneStandard: "timeZoneStandard" }); shallowMerge(info, constructedInfo); buildInfo.timeZones(info); return info; }; $D.i18n = { __: function (key, lang) { return __(key, lang); }, currentLanguage: function () { return lang || "en-US"; }, setLanguage: function (code, force, cb) { var async = false; if (force || code === "en-US" || (!!Date.CultureStrings && !!Date.CultureStrings[code])) { lang = code; Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings.lang = code; Date.CultureInfo = new CultureInfo(); } else { if (!(!!Date.CultureStrings && !!Date.CultureStrings[code])) { if (typeof exports !== "undefined" && this.exports !== exports) { // we're in a Node enviroment, load it using require try { require("../i18n/" + code + ".js"); lang = code; Date.CultureStrings.lang = code; Date.CultureInfo = new CultureInfo(); } catch (e) { // var str = "The language for '" + code + "' could not be loaded by Node. It likely does not exist."; throw new Error("The DateJS IETF language tag '" + code + "' could not be loaded by Node. It likely does not exist."); } } else if (Date.Config && Date.Config.i18n) { // we know the location of the files, so lets load them async = true; loadI18nScript(code).done(function(){ lang = code; Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings.lang = code; Date.CultureInfo = new CultureInfo(); $D.Parsing.Normalizer.buildReplaceData(); // because this is async if ($D.Grammar) { $D.Grammar.buildGrammarFormats(); // so we can parse those strings... } if (cb) { setTimeout(cb,0); } }); } else { Date.console.error("The DateJS IETF language tag '" + code + "' is not available and has not been loaded."); return false; } } } $D.Parsing.Normalizer.buildReplaceData(); // rebuild normalizer strings if ($D.Grammar) { $D.Grammar.buildGrammarFormats(); // so we can parse those strings... } if (!async && cb) { setTimeout(cb,0); } }, getLoggedKeys: function () { return loggedKeys; }, updateCultureInfo: function () { Date.CultureInfo = new CultureInfo(); } }; $D.i18n.updateCultureInfo(); // run automatically }()); (function () { var $D = Date, $P = $D.prototype, p = function (s, l) { if (!l) { l = 2; } return ("000" + s).slice(l * -1); }; if (typeof window !== "undefined" && typeof window.console !== "undefined" && typeof window.console.log !== "undefined") { $D.console = console; // used only to raise non-critical errors if available } else { // set mock so we don't give errors. $D.console = { log: function(){}, error: function(){} }; } $D.Config = $D.Config || {}; $D.initOverloads = function() { /** * Overload of Date.now. Allows an alternate call for Date.now where it returns the * current Date as an object rather than just milliseconds since the Unix Epoch. * * Also provides an implementation of now() for browsers (IE<9) that don't have it. * * Backwards compatible so with work with either: * Date.now() [returns ms] * or * Date.now(true) [returns Date] */ if (!$D.now) { $D._now = function now() { return new Date().getTime(); }; } else if (!$D._now) { $D._now = $D.now; } $D.now = function (returnObj) { if (returnObj) { return $D.present(); } else { return $D._now(); } }; if ( !$P.toISOString ) { $P.toISOString = function() { return this.getUTCFullYear() + "-" + p(this.getUTCMonth() + 1) + "-" + p(this.getUTCDate()) + "T" + p(this.getUTCHours()) + ":" + p(this.getUTCMinutes()) + ":" + p(this.getUTCSeconds()) + "." + String( (this.getUTCMilliseconds()/1000).toFixed(3)).slice(2, 5) + "Z"; }; } // private if ( $P._toString === undefined ){ $P._toString = $P.toString; } }; $D.initOverloads(); /** * Gets a date that is set to the current date. The time is set to the start of the day (00:00 or 12:00 AM). * @return {Date} The current date. */ $D.today = function () { return new Date().clearTime(); }; /** * Gets a date that is set to the current date and time (same as new Date, but chainable) * @return {Date} The current date. */ $D.present = function () { return new Date(); }; /** * Compares the first date to the second date and returns an number indication of their relative values. * @param {Date} First Date object to compare [Required]. * @param {Date} Second Date object to compare to [Required]. * @return {Number} -1 = date1 is lessthan date2. 0 = values are equal. 1 = date1 is greaterthan date2. */ $D.compare = function (date1, date2) { if (isNaN(date1) || isNaN(date2)) { throw new Error(date1 + " - " + date2); } else if (date1 instanceof Date && date2 instanceof Date) { return (date1 < date2) ? -1 : (date1 > date2) ? 1 : 0; } else { throw new TypeError(date1 + " - " + date2); } }; /** * Compares the first Date object to the second Date object and returns true if they are equal. * @param {Date} First Date object to compare [Required] * @param {Date} Second Date object to compare to [Required] * @return {Boolean} true if dates are equal. false if they are not equal. */ $D.equals = function (date1, date2) { return (date1.compareTo(date2) === 0); }; /** * Gets the language appropriate day name when given the day number(0-6) * eg - 0 == Sunday * @return {String} The day name */ $D.getDayName = function (n) { return Date.CultureInfo.dayNames[n]; }; /** * Gets the day number (0-6) if given a CultureInfo specific string which is a valid dayName, abbreviatedDayName or shortestDayName (two char). * @param {String} The name of the day (eg. "Monday, "Mon", "tuesday", "tue", "We", "we"). * @return {Number} The day number */ $D.getDayNumberFromName = function (name) { var n = Date.CultureInfo.dayNames, m = Date.CultureInfo.abbreviatedDayNames, o = Date.CultureInfo.shortestDayNames, s = name.toLowerCase(); for (var i = 0; i < n.length; i++) { if (n[i].toLowerCase() === s || m[i].toLowerCase() === s || o[i].toLowerCase() === s) { return i; } } return -1; }; /** * Gets the month number (0-11) if given a Culture Info specific string which is a valid monthName or abbreviatedMonthName. * @param {String} The name of the month (eg. "February, "Feb", "october", "oct"). * @return {Number} The day number */ $D.getMonthNumberFromName = function (name) { var n = Date.CultureInfo.monthNames, m = Date.CultureInfo.abbreviatedMonthNames, s = name.toLowerCase(); for (var i = 0; i < n.length; i++) { if (n[i].toLowerCase() === s || m[i].toLowerCase() === s) { return i; } } return -1; }; /** * Gets the language appropriate month name when given the month number(0-11) * eg - 0 == January * @return {String} The month name */ $D.getMonthName = function (n) { return Date.CultureInfo.monthNames[n]; }; /** * Determines if the current date instance is within a LeapYear. * @param {Number} The year. * @return {Boolean} true if date is within a LeapYear, otherwise false. */ $D.isLeapYear = function (year) { return ((year % 4 === 0 && year % 100 !== 0) || year % 400 === 0); }; /** * Gets the number of days in the month, given a year and month value. Automatically corrects for LeapYear. * @param {Number} The year. * @param {Number} The month (0-11). * @return {Number} The number of days in the month. */ $D.getDaysInMonth = function (year, month) { if (!month && $D.validateMonth(year)) { month = year; year = Date.today().getFullYear(); } return [31, ($D.isLeapYear(year) ? 29 : 28), 31, 30, 31, 30, 31, 31, 30, 31, 30, 31][month]; }; $P.getDaysInMonth = function () { return $D.getDaysInMonth(this.getFullYear(), this.getMonth()); }; $D.getTimezoneAbbreviation = function (offset, dst) { var p, n = (dst || false) ? Date.CultureInfo.abbreviatedTimeZoneDST : Date.CultureInfo.abbreviatedTimeZoneStandard; for (p in n) { if (n.hasOwnProperty(p)) { if (n[p] === offset) { return p; } } } return null; }; $D.getTimezoneOffset = function (name, dst) { var i, a =[], z = Date.CultureInfo.timezones; if (!name) { name = (new Date()).getTimezone();} for (i = 0; i < z.length; i++) { if (z[i].name === name.toUpperCase()) { a.push(i); } } if (!z[a[0]]) { return null; } if (a.length === 1 || !dst) { return z[a[0]].offset; } else { for (i=0; i < a.length; i++) { if (z[a[i]].dst) { return z[a[i]].offset; } } } }; $D.getQuarter = function (d) { d = d || new Date(); // If no date supplied, use today var q = [1,2,3,4]; return q[Math.floor(d.getMonth() / 3)]; // ~~~ is a bitwise op. Faster than Math.floor }; $D.getDaysLeftInQuarter = function (d) { d = d || new Date(); var qEnd = new Date(d); qEnd.setMonth(qEnd.getMonth() + 3 - qEnd.getMonth() % 3, 0); return Math.floor((qEnd - d) / 8.64e7); }; // private var validate = function (n, min, max, name) { name = name ? name : "Object"; if (typeof n === "undefined") { return false; } else if (typeof n !== "number") { throw new TypeError(n + " is not a Number."); } else if (n < min || n > max) { // As failing validation is *not* an exceptional circumstance // lets not throw a RangeError Exception here. // It's semantically correct but it's not sensible. return false; } return true; }; /** * Validates the number is within an acceptable range for milliseconds [0-999]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateMillisecond = function (value) { return validate(value, 0, 999, "millisecond"); }; /** * Validates the number is within an acceptable range for seconds [0-59]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateSecond = function (value) { return validate(value, 0, 59, "second"); }; /** * Validates the number is within an acceptable range for minutes [0-59]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateMinute = function (value) { return validate(value, 0, 59, "minute"); }; /** * Validates the number is within an acceptable range for hours [0-23]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateHour = function (value) { return validate(value, 0, 23, "hour"); }; /** * Validates the number is within an acceptable range for the days in a month [0-MaxDaysInMonth]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateDay = function (value, year, month) { if (year === undefined || year === null || month === undefined || month === null) { return false;} return validate(value, 1, $D.getDaysInMonth(year, month), "day"); }; /** * Validates the number is within an acceptable range for months [0-11]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateWeek = function (value) { return validate(value, 0, 53, "week"); }; /** * Validates the number is within an acceptable range for months [0-11]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateMonth = function (value) { return validate(value, 0, 11, "month"); }; /** * Validates the number is within an acceptable range for years. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateYear = function (value) { /** * Per ECMAScript spec the range of times supported by Date objects is * exactly -100,000,000 days to +100,000,000 days measured relative to * midnight at the beginning of 01 January, 1970 UTC. * This gives a range of 8,640,000,000,000,000 milliseconds to either * side of 01 January, 1970 UTC. * * Earliest possible date: Tue, 20 Apr 271,822 B.C. 00:00:00 UTC * Latest possible date: Sat, 13 Sep 275,760 00:00:00 UTC */ return validate(value, -271822, 275760, "year"); }; $D.validateTimezone = function(value) { var timezones = {"ACDT":1,"ACST":1,"ACT":1,"ADT":1,"AEDT":1,"AEST":1,"AFT":1,"AKDT":1,"AKST":1,"AMST":1,"AMT":1,"ART":1,"AST":1,"AWDT":1,"AWST":1,"AZOST":1,"AZT":1,"BDT":1,"BIOT":1,"BIT":1,"BOT":1,"BRT":1,"BST":1,"BTT":1,"CAT":1,"CCT":1,"CDT":1,"CEDT":1,"CEST":1,"CET":1,"CHADT":1,"CHAST":1,"CHOT":1,"ChST":1,"CHUT":1,"CIST":1,"CIT":1,"CKT":1,"CLST":1,"CLT":1,"COST":1,"COT":1,"CST":1,"CT":1,"CVT":1,"CWST":1,"CXT":1,"DAVT":1,"DDUT":1,"DFT":1,"EASST":1,"EAST":1,"EAT":1,"ECT":1,"EDT":1,"EEDT":1,"EEST":1,"EET":1,"EGST":1,"EGT":1,"EIT":1,"EST":1,"FET":1,"FJT":1,"FKST":1,"FKT":1,"FNT":1,"GALT":1,"GAMT":1,"GET":1,"GFT":1,"GILT":1,"GIT":1,"GMT":1,"GST":1,"GYT":1,"HADT":1,"HAEC":1,"HAST":1,"HKT":1,"HMT":1,"HOVT":1,"HST":1,"ICT":1,"IDT":1,"IOT":1,"IRDT":1,"IRKT":1,"IRST":1,"IST":1,"JST":1,"KGT":1,"KOST":1,"KRAT":1,"KST":1,"LHST":1,"LINT":1,"MAGT":1,"MART":1,"MAWT":1,"MDT":1,"MET":1,"MEST":1,"MHT":1,"MIST":1,"MIT":1,"MMT":1,"MSK":1,"MST":1,"MUT":1,"MVT":1,"MYT":1,"NCT":1,"NDT":1,"NFT":1,"NPT":1,"NST":1,"NT":1,"NUT":1,"NZDT":1,"NZST":1,"OMST":1,"ORAT":1,"PDT":1,"PET":1,"PETT":1,"PGT":1,"PHOT":1,"PHT":1,"PKT":1,"PMDT":1,"PMST":1,"PONT":1,"PST":1,"PYST":1,"PYT":1,"RET":1,"ROTT":1,"SAKT":1,"SAMT":1,"SAST":1,"SBT":1,"SCT":1,"SGT":1,"SLST":1,"SRT":1,"SST":1,"SYOT":1,"TAHT":1,"THA":1,"TFT":1,"TJT":1,"TKT":1,"TLT":1,"TMT":1,"TOT":1,"TVT":1,"UCT":1,"ULAT":1,"UTC":1,"UYST":1,"UYT":1,"UZT":1,"VET":1,"VLAT":1,"VOLT":1,"VOST":1,"VUT":1,"WAKT":1,"WAST":1,"WAT":1,"WEDT":1,"WEST":1,"WET":1,"WST":1,"YAKT":1,"YEKT":1,"Z":1}; return (timezones[value] === 1); }; $D.validateTimezoneOffset= function(value) { // timezones go from +14hrs to -12hrs, the +X hours are negative offsets. return (value > -841 && value < 721); }; }()); (function () { var $D = Date, $P = $D.prototype, p = function (s, l) { if (!l) { l = 2; } return ("000" + s).slice(l * -1); }; var validateConfigObject = function (obj) { var result = {}, self = this, prop, testFunc; testFunc = function (prop, func, value) { if (prop === "day") { var month = (obj.month !== undefined) ? obj.month : self.getMonth(); var year = (obj.year !== undefined) ? obj.year : self.getFullYear(); return $D[func](value, year, month); } else { return $D[func](value); } }; for (prop in obj) { if (Object.prototype.hasOwnProperty.call(obj, prop)) { var func = "validate" + prop.charAt(0).toUpperCase() + prop.slice(1); if ($D[func] && obj[prop] !== null && testFunc(prop, func, obj[prop])) { result[prop] = obj[prop]; } } } return result; }; /** * Resets the time of this Date object to 12:00 AM (00:00), which is the start of the day. * @param {Boolean} .clone() this date instance before clearing Time * @return {Date} this */ $P.clearTime = function () { this.setHours(0); this.setMinutes(0); this.setSeconds(0); this.setMilliseconds(0); return this; }; /** * Resets the time of this Date object to the current time ('now'). * @return {Date} this */ $P.setTimeToNow = function () { var n = new Date(); this.setHours(n.getHours()); this.setMinutes(n.getMinutes()); this.setSeconds(n.getSeconds()); this.setMilliseconds(n.getMilliseconds()); return this; }; /** * Returns a new Date object that is an exact date and time copy of the original instance. * @return {Date} A new Date instance */ $P.clone = function () { return new Date(this.getTime()); }; /** * Compares this instance to a Date object and returns an number indication of their relative values. * @param {Date} Date object to compare [Required] * @return {Number} -1 = this is lessthan date. 0 = values are equal. 1 = this is greaterthan date. */ $P.compareTo = function (date) { return Date.compare(this, date); }; /** * Compares this instance to another Date object and returns true if they are equal. * @param {Date} Date object to compare. If no date to compare, new Date() [now] is used. * @return {Boolean} true if dates are equal. false if they are not equal. */ $P.equals = function (date) { return Date.equals(this, (date !== undefined ? date : new Date())); }; /** * Determines if this instance is between a range of two dates or equal to either the start or end dates. * @param {Date} Start of range [Required] * @param {Date} End of range [Required] * @return {Boolean} true is this is between or equal to the start and end dates, else false */ $P.between = function (start, end) { return this.getTime() >= start.getTime() && this.getTime() <= end.getTime(); }; /** * Determines if this date occurs after the date to compare to. * @param {Date} Date object to compare. If no date to compare, new Date() ("now") is used. * @return {Boolean} true if this date instance is greater than the date to compare to (or "now"), otherwise false. */ $P.isAfter = function (date) { return this.compareTo(date || new Date()) === 1; }; /** * Determines if this date occurs before the date to compare to. * @param {Date} Date object to compare. If no date to compare, new Date() ("now") is used. * @return {Boolean} true if this date instance is less than the date to compare to (or "now"). */ $P.isBefore = function (date) { return (this.compareTo(date || new Date()) === -1); }; /** * Determines if the current Date instance occurs today. * @return {Boolean} true if this date instance is 'today', otherwise false. */ /** * Determines if the current Date instance occurs on the same Date as the supplied 'date'. * If no 'date' to compare to is provided, the current Date instance is compared to 'today'. * @param {date} Date object to compare. If no date to compare, the current Date ("now") is used. * @return {Boolean} true if this Date instance occurs on the same Day as the supplied 'date'. */ $P.isToday = $P.isSameDay = function (date) { return this.clone().clearTime().equals((date || new Date()).clone().clearTime()); }; /** * Adds the specified number of milliseconds to this instance. * @param {Number} The number of milliseconds to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addMilliseconds = function (value) { if (!value) { return this; } this.setTime(this.getTime() + value * 1); return this; }; /** * Adds the specified number of seconds to this instance. * @param {Number} The number of seconds to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addSeconds = function (value) { if (!value) { return this; } return this.addMilliseconds(value * 1000); }; /** * Adds the specified number of seconds to this instance. * @param {Number} The number of seconds to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addMinutes = function (value) { if (!value) { return this; } return this.addMilliseconds(value * 60000); // 60*1000 }; /** * Adds the specified number of hours to this instance. * @param {Number} The number of hours to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addHours = function (value) { if (!value) { return this; } return this.addMilliseconds(value * 3600000); // 60*60*1000 }; /** * Adds the specified number of days to this instance. * @param {Number} The number of days to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addDays = function (value) { if (!value) { return this; } this.setDate(this.getDate() + value * 1); return this; }; /** * Adds the specified number of weekdays (ie - not sat or sun) to this instance. * @param {Number} The number of days to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addWeekdays = function (value) { if (!value) { return this; } var day = this.getDay(); var weeks = (Math.ceil(Math.abs(value)/7)); if (day === 0 || day === 6) { if (value > 0) { this.next().monday(); this.addDays(-1); day = this.getDay(); } } if (value < 0) { while (value < 0) { this.addDays(-1); day = this.getDay(); if (day !== 0 && day !== 6) { value++; } } return this; } else if (value > 5 || (6-day) <= value) { value = value + (weeks * 2); } return this.addDays(value); }; /** * Adds the specified number of weeks to this instance. * @param {Number} The number of weeks to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addWeeks = function (value) { if (!value) { return this; } return this.addDays(value * 7); }; /** * Adds the specified number of months to this instance. * @param {Number} The number of months to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addMonths = function (value) { if (!value) { return this; } var n = this.getDate(); this.setDate(1); this.setMonth(this.getMonth() + value * 1); this.setDate(Math.min(n, $D.getDaysInMonth(this.getFullYear(), this.getMonth()))); return this; }; $P.addQuarters = function (value) { if (!value) { return this; } // note this will take you to the same point in the quarter as you are now. // i.e. - if you are 15 days into the quarter you'll be 15 days into the resulting one. // bonus: this allows adding fractional quarters return this.addMonths(value * 3); }; /** * Adds the specified number of years to this instance. * @param {Number} The number of years to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addYears = function (value) { if (!value) { return this; } return this.addMonths(value * 12); }; /** * Adds (or subtracts) to the value of the years, months, weeks, days, hours, minutes, seconds, milliseconds of the date instance using given configuration object. Positive and Negative values allowed. * Example

	Date.today().add( { days: 1, months: 1 } )

	new Date().add( { years: -1 } )
	
* @param {Object} Configuration object containing attributes (months, days, etc.) * @return {Date} this */ $P.add = function (config) { if (typeof config === "number") { this._orient = config; return this; } var x = config; if (x.day) { // If we should be a different date than today (eg: for 'tomorrow -1d', etc). // Should only effect parsing, not direct usage (eg, Finish and FinishExact) if ((x.day - this.getDate()) !== 0) { this.setDate(x.day); } } if (x.milliseconds) { this.addMilliseconds(x.milliseconds); } if (x.seconds) { this.addSeconds(x.seconds); } if (x.minutes) { this.addMinutes(x.minutes); } if (x.hours) { this.addHours(x.hours); } if (x.weeks) { this.addWeeks(x.weeks); } if (x.months) { this.addMonths(x.months); } if (x.years) { this.addYears(x.years); } if (x.days) { this.addDays(x.days); } return this; }; /** * Get the week number. Week one (1) is the week which contains the first Thursday of the year. Monday is considered the first day of the week. * The .getWeek() function does NOT convert the date to UTC. The local datetime is used. * Please use .getISOWeek() to get the week of the UTC converted date. * @return {Number} 1 to 53 */ $P.getWeek = function (utc) { // Create a copy of this date object var self, target = new Date(this.valueOf()); if (utc) { target.addMinutes(target.getTimezoneOffset()); self = target.clone(); } else { self = this; } // ISO week date weeks start on monday // so correct the day number var dayNr = (self.getDay() + 6) % 7; // ISO 8601 states that week 1 is the week // with the first thursday of that year. // Set the target date to the thursday in the target week target.setDate(target.getDate() - dayNr + 3); // Store the millisecond value of the target date var firstThursday = target.valueOf(); // Set the target to the first thursday of the year // First set the target to january first target.setMonth(0, 1); // Not a thursday? Correct the date to the next thursday if (target.getDay() !== 4) { target.setMonth(0, 1 + ((4 - target.getDay()) + 7) % 7); } // The weeknumber is the number of weeks between the // first thursday of the year and the thursday in the target week return 1 + Math.ceil((firstThursday - target) / 604800000); // 604800000 = 7 * 24 * 3600 * 1000 }; /** * Get the ISO 8601 week number. Week one ("01") is the week which contains the first Thursday of the year. Monday is considered the first day of the week. * The .getISOWeek() function does convert the date to it's UTC value. Please use .getWeek() to get the week of the local date. * @return {String} "01" to "53" */ $P.getISOWeek = function () { return p(this.getWeek(true)); }; /** * Moves the date to Monday of the week set. Week one (1) is the week which contains the first Thursday of the year. * @param {Number} A Number (1 to 53) that represents the week of the year. * @return {Date} this */ $P.setWeek = function (n) { if ((n - this.getWeek()) === 0) { if (this.getDay() !== 1) { return this.moveToDayOfWeek(1, (this.getDay() > 1 ? -1 : 1)); } else { return this; } } else { return this.moveToDayOfWeek(1, (this.getDay() > 1 ? -1 : 1)).addWeeks(n - this.getWeek()); } }; $P.setQuarter = function (qtr) { var month = Math.abs(((qtr-1) * 3) + 1); return this.setMonth(month, 1); }; $P.getQuarter = function () { return Date.getQuarter(this); }; $P.getDaysLeftInQuarter = function () { return Date.getDaysLeftInQuarter(this); }; /** * Moves the date to the next n'th occurrence of the dayOfWeek starting from the beginning of the month. The number (-1) is a magic number and will return the last occurrence of the dayOfWeek in the month. * @param {Number} The dayOfWeek to move to * @param {Number} The n'th occurrence to move to. Use (-1) to return the last occurrence in the month * @return {Date} this */ $P.moveToNthOccurrence = function (dayOfWeek, occurrence) { if (dayOfWeek === "Weekday") { if (occurrence > 0) { this.moveToFirstDayOfMonth(); if (this.is().weekday()) { occurrence -= 1; } } else if (occurrence < 0) { this.moveToLastDayOfMonth(); if (this.is().weekday()) { occurrence += 1; } } else { return this; } return this.addWeekdays(occurrence); } var shift = 0; if (occurrence > 0) { shift = occurrence - 1; } else if (occurrence === -1) { this.moveToLastDayOfMonth(); if (this.getDay() !== dayOfWeek) { this.moveToDayOfWeek(dayOfWeek, -1); } return this; } return this.moveToFirstDayOfMonth().addDays(-1).moveToDayOfWeek(dayOfWeek, +1).addWeeks(shift); }; var moveToN = function (getFunc, addFunc, nVal) { return function (value, orient) { var diff = (value - this[getFunc]() + nVal * (orient || +1)) % nVal; return this[addFunc]((diff === 0) ? diff += nVal * (orient || +1) : diff); }; }; /** * Move to the next or last dayOfWeek based on the orient value. * @param {Number} The dayOfWeek to move to * @param {Number} Forward (+1) or Back (-1). Defaults to +1. [Optional] * @return {Date} this */ $P.moveToDayOfWeek = moveToN("getDay", "addDays", 7); /** * Move to the next or last month based on the orient value. * @param {Number} The month to move to. 0 = January, 11 = December * @param {Number} Forward (+1) or Back (-1). Defaults to +1. [Optional] * @return {Date} this */ $P.moveToMonth = moveToN("getMonth", "addMonths", 12); /** * Get the Ordinate of the current day ("th", "st", "rd"). * @return {String} */ $P.getOrdinate = function () { var num = this.getDate(); return ord(num); }; /** * Get the Ordinal day (numeric day number) of the year, adjusted for leap year. * @return {Number} 1 through 365 (366 in leap years) */ $P.getOrdinalNumber = function () { return Math.ceil((this.clone().clearTime() - new Date(this.getFullYear(), 0, 1)) / 86400000) + 1; }; /** * Get the time zone abbreviation of the current date. * @return {String} The abbreviated time zone name (e.g. "EST") */ $P.getTimezone = function () { return $D.getTimezoneAbbreviation(this.getUTCOffset(), this.isDaylightSavingTime()); }; $P.setTimezoneOffset = function (offset) { var here = this.getTimezoneOffset(), there = Number(offset) * -6 / 10; return (there || there === 0) ? this.addMinutes(there - here) : this; }; $P.setTimezone = function (offset) { return this.setTimezoneOffset($D.getTimezoneOffset(offset)); }; /** * Indicates whether Daylight Saving Time is observed in the current time zone. * @return {Boolean} true|false */ $P.hasDaylightSavingTime = function () { return (Date.today().set({month: 0, day: 1}).getTimezoneOffset() !== Date.today().set({month: 6, day: 1}).getTimezoneOffset()); }; /** * Indicates whether this Date instance is within the Daylight Saving Time range for the current time zone. * @return {Boolean} true|false */ $P.isDaylightSavingTime = function () { return Date.today().set({month: 0, day: 1}).getTimezoneOffset() !== this.getTimezoneOffset(); }; /** * Get the offset from UTC of the current date. * @return {String} The 4-character offset string prefixed with + or - (e.g. "-0500") */ $P.getUTCOffset = function (offset) { var n = (offset || this.getTimezoneOffset()) * -10 / 6, r; if (n < 0) { r = (n - 10000).toString(); return r.charAt(0) + r.substr(2); } else { r = (n + 10000).toString(); return "+" + r.substr(1); } }; /** * Returns the number of milliseconds between this date and date. * @param {Date} Defaults to now * @return {Number} The diff in milliseconds */ $P.getElapsed = function (date) { return (date || new Date()) - this; }; /** * Set the value of year, month, day, hour, minute, second, millisecond of date instance using given configuration object. * Example

	Date.today().set( { day: 20, month: 1 } )

	new Date().set( { millisecond: 0 } )
	
* * @param {Object} Configuration object containing attributes (month, day, etc.) * @return {Date} this */ $P.set = function (config) { config = validateConfigObject.call(this, config); var key; for (key in config) { if (Object.prototype.hasOwnProperty.call(config, key)) { var name = key.charAt(0).toUpperCase() + key.slice(1); var addFunc, getFunc; if (key !== "week" && key !== "month" && key !== "timezone" && key !== "timezoneOffset") { name += "s"; } addFunc = "add" + name; getFunc = "get" + name; if (key === "month") { addFunc = addFunc + "s"; } else if (key === "year"){ getFunc = "getFullYear"; } if (key !== "day" && key !== "timezone" && key !== "timezoneOffset" && key !== "week" && key !== "hour") { this[addFunc](config[key] - this[getFunc]()); } else if ( key === "timezone"|| key === "timezoneOffset" || key === "week" || key === "hour") { this["set"+name](config[key]); } } } // day has to go last because you can't validate the day without first knowing the month if (config.day) { this.addDays(config.day - this.getDate()); } return this; }; /** * Moves the date to the first day of the month. * @return {Date} this */ $P.moveToFirstDayOfMonth = function () { return this.set({ day: 1 }); }; /** * Moves the date to the last day of the month. * @return {Date} this */ $P.moveToLastDayOfMonth = function () { return this.set({ day: $D.getDaysInMonth(this.getFullYear(), this.getMonth())}); }; /** * Converts the value of the current Date object to its equivalent string representation. * Format Specifiers * CUSTOM DATE AND TIME FORMAT STRINGS * Format Description Example * ------ --------------------------------------------------------------------------- ----------------------- * s The seconds of the minute between 0-59. "0" to "59" * ss The seconds of the minute with leading zero if required. "00" to "59" * * m The minute of the hour between 0-59. "0" or "59" * mm The minute of the hour with leading zero if required. "00" or "59" * * h The hour of the day between 1-12. "1" to "12" * hh The hour of the day with leading zero if required. "01" to "12" * * H The hour of the day between 0-23. "0" to "23" * HH The hour of the day with leading zero if required. "00" to "23" * * d The day of the month between 1 and 31. "1" to "31" * dd The day of the month with leading zero if required. "01" to "31" * ddd Abbreviated day name. Date.CultureInfo.abbreviatedDayNames. "Mon" to "Sun" * dddd The full day name. Date.CultureInfo.dayNames. "Monday" to "Sunday" * * M The month of the year between 1-12. "1" to "12" * MM The month of the year with leading zero if required. "01" to "12" * MMM Abbreviated month name. Date.CultureInfo.abbreviatedMonthNames. "Jan" to "Dec" * MMMM The full month name. Date.CultureInfo.monthNames. "January" to "December" * * yy The year as a two-digit number. "99" or "08" * yyyy The full four digit year. "1999" or "2008" * * t Displays the first character of the A.M./P.M. designator. "A" or "P" * Date.CultureInfo.amDesignator or Date.CultureInfo.pmDesignator * tt Displays the A.M./P.M. designator. "AM" or "PM" * Date.CultureInfo.amDesignator or Date.CultureInfo.pmDesignator * * S The ordinal suffix ("st, "nd", "rd" or "th") of the current day. "st, "nd", "rd" or "th" * * STANDARD DATE AND TIME FORMAT STRINGS * Format Description Example *------ --------------------------------------------------------------------------- ----------------------- * d The CultureInfo shortDate Format Pattern "M/d/yyyy" * D The CultureInfo longDate Format Pattern "dddd, MMMM dd, yyyy" * F The CultureInfo fullDateTime Format Pattern "dddd, MMMM dd, yyyy h:mm:ss tt" * m The CultureInfo monthDay Format Pattern "MMMM dd" * r The CultureInfo rfc1123 Format Pattern "ddd, dd MMM yyyy HH:mm:ss GMT" * s The CultureInfo sortableDateTime Format Pattern "yyyy-MM-ddTHH:mm:ss" * t The CultureInfo shortTime Format Pattern "h:mm tt" * T The CultureInfo longTime Format Pattern "h:mm:ss tt" * u The CultureInfo universalSortableDateTime Format Pattern "yyyy-MM-dd HH:mm:ssZ" * y The CultureInfo yearMonth Format Pattern "MMMM, yyyy" * * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @return {String} A string representation of the current Date object. */ var ord = function (n) { switch (n * 1) { case 1: case 21: case 31: return "st"; case 2: case 22: return "nd"; case 3: case 23: return "rd"; default: return "th"; } }; var parseStandardFormats = function (format) { var y, c = Date.CultureInfo.formatPatterns; switch (format) { case "d": return this.toString(c.shortDate); case "D": return this.toString(c.longDate); case "F": return this.toString(c.fullDateTime); case "m": return this.toString(c.monthDay); case "r": case "R": y = this.clone().addMinutes(this.getTimezoneOffset()); return y.toString(c.rfc1123) + " GMT"; case "s": return this.toString(c.sortableDateTime); case "t": return this.toString(c.shortTime); case "T": return this.toString(c.longTime); case "u": y = this.clone().addMinutes(this.getTimezoneOffset()); return y.toString(c.universalSortableDateTime); case "y": return this.toString(c.yearMonth); default: return false; } }; var parseFormatStringsClosure = function (context) { return function (m) { if (m.charAt(0) === "\\") { return m.replace("\\", ""); } switch (m) { case "hh": return p(context.getHours() < 13 ? (context.getHours() === 0 ? 12 : context.getHours()) : (context.getHours() - 12)); case "h": return context.getHours() < 13 ? (context.getHours() === 0 ? 12 : context.getHours()) : (context.getHours() - 12); case "HH": return p(context.getHours()); case "H": return context.getHours(); case "mm": return p(context.getMinutes()); case "m": return context.getMinutes(); case "ss": return p(context.getSeconds()); case "s": return context.getSeconds(); case "yyyy": return p(context.getFullYear(), 4); case "yy": return p(context.getFullYear()); case "y": return context.getFullYear(); case "E": case "dddd": return Date.CultureInfo.dayNames[context.getDay()]; case "ddd": return Date.CultureInfo.abbreviatedDayNames[context.getDay()]; case "dd": return p(context.getDate()); case "d": return context.getDate(); case "MMMM": return Date.CultureInfo.monthNames[context.getMonth()]; case "MMM": return Date.CultureInfo.abbreviatedMonthNames[context.getMonth()]; case "MM": return p((context.getMonth() + 1)); case "M": return context.getMonth() + 1; case "t": return context.getHours() < 12 ? Date.CultureInfo.amDesignator.substring(0, 1) : Date.CultureInfo.pmDesignator.substring(0, 1); case "tt": return context.getHours() < 12 ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator; case "S": return ord(context.getDate()); case "W": return context.getWeek(); case "WW": return context.getISOWeek(); case "Q": return "Q" + context.getQuarter(); case "q": return String(context.getQuarter()); case "z": return context.getTimezone(); case "Z": case "X": return Date.getTimezoneOffset(context.getTimezone()); case "ZZ": // Timezone offset in seconds return context.getTimezoneOffset() * -60; case "u": return context.getDay(); case "L": return ($D.isLeapYear(context.getFullYear())) ? 1 : 0; case "B": // Swatch Internet Time (.beats) return "@"+((context.getUTCSeconds() + (context.getUTCMinutes()*60) + ((context.getUTCHours()+1)*3600))/86.4); default: return m; } }; }; $P.toString = function (format, ignoreStandards) { // Standard Date and Time Format Strings. Formats pulled from CultureInfo file and // may vary by culture. if (!ignoreStandards && format && format.length === 1) { output = parseStandardFormats.call(this, format); if (output) { return output; } } var parseFormatStrings = parseFormatStringsClosure(this); return format ? format.replace(/((\\)?(dd?d?d?|MM?M?M?|yy?y?y?|hh?|HH?|mm?|ss?|tt?|S|q|Q|WW?W?W?)(?![^\[]*\]))/g, parseFormatStrings).replace(/\[|\]/g, "") : this._toString(); }; }()); /************************************************************* * SugarPak - Domain Specific Language - Syntactical Sugar * *************************************************************/ (function () { var $D = Date, $P = $D.prototype, $N = Number.prototype; // private $P._orient = +1; // private $P._nth = null; // private $P._is = false; // private $P._same = false; // private $P._isSecond = false; // private $N._dateElement = "days"; /** * Moves the date to the next instance of a date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.today().next().friday();
	Date.today().next().fri();
	Date.today().next().march();
	Date.today().next().mar();
	Date.today().next().week();
	
* * @return {Date} date */ $P.next = function () { this._move = true; this._orient = +1; return this; }; /** * Creates a new Date (Date.today()) and moves the date to the next instance of the date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.next().friday();
	Date.next().fri();
	Date.next().march();
	Date.next().mar();
	Date.next().week();
	
* * @return {Date} date */ $D.next = function () { return $D.today().next(); }; /** * Moves the date to the previous instance of a date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.today().last().friday();
	Date.today().last().fri();
	Date.today().last().march();
	Date.today().last().mar();
	Date.today().last().week();
	
* * @return {Date} date */ $P.last = $P.prev = $P.previous = function () { this._move = true; this._orient = -1; return this; }; /** * Creates a new Date (Date.today()) and moves the date to the previous instance of the date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.last().friday();
	Date.last().fri();
	Date.previous().march();
	Date.prev().mar();
	Date.last().week();
	
* * @return {Date} date */ $D.last = $D.prev = $D.previous = function () { return $D.today().last(); }; /** * Performs a equality check when followed by either a month name, day name or .weekday() function. * Example

	Date.today().is().friday(); // true|false
	Date.today().is().fri();
	Date.today().is().march();
	Date.today().is().mar();
	
* * @return {Boolean} true|false */ $P.is = function () { this._is = true; return this; }; /** * Determines if two date objects occur on/in exactly the same instance of the subsequent date part function. * The function .same() must be followed by a date part function (example: .day(), .month(), .year(), etc). * * An optional Date can be passed in the date part function. If now date is passed as a parameter, 'Now' is used. * * The following example demonstrates how to determine if two dates fall on the exact same day. * * Example

	var d1 = Date.today(); // today at 00:00
	var d2 = new Date();   // exactly now.

	// Do they occur on the same day?
	d1.same().day(d2); // true
	
	// Do they occur on the same hour?
	d1.same().hour(d2); // false, unless d2 hour is '00' (midnight).
	
	// What if it's the same day, but one year apart?
	var nextYear = Date.today().add(1).year();

	d1.same().day(nextYear); // false, because the dates must occur on the exact same day. 
	
* * Scenario: Determine if a given date occurs during some week period 2 months from now. * * Example

	var future = Date.today().add(2).months();
	return someDate.same().week(future); // true|false;
	
* * @return {Boolean} true|false */ $P.same = function () { this._same = true; this._isSecond = false; return this; }; /** * Determines if the current date/time occurs during Today. Must be preceded by the .is() function. * Example

	someDate.is().today();    // true|false
	new Date().is().today();  // true
	Date.today().is().today();// true
	Date.today().add(-1).day().is().today(); // false
	
* * @return {Boolean} true|false */ $P.today = function () { return this.same().day(); }; /** * Determines if the current date is a weekday. This function must be preceded by the .is() function. * Example

	Date.today().is().weekday(); // true|false
	
* * @return {Boolean} true|false */ $P.weekday = function () { if (this._nth) { return df("Weekday").call(this); } if (this._move) { return this.addWeekdays(this._orient); } if (this._is) { this._is = false; return (!this.is().sat() && !this.is().sun()); } return false; }; /** * Determines if the current date is on the weekend. This function must be preceded by the .is() function. * Example

	Date.today().is().weekend(); // true|false
	
* * @return {Boolean} true|false */ $P.weekend = function () { if (this._is) { this._is = false; return (this.is().sat() || this.is().sun()); } return false; }; /** * Sets the Time of the current Date instance. A string "6:15 pm" or config object {hour:18, minute:15} are accepted. * Example

	// Set time to 6:15pm with a String
	Date.today().at("6:15pm");

	// Set time to 6:15pm with a config object
	Date.today().at({hour:18, minute:15});
	
* * @return {Date} date */ $P.at = function (time) { return (typeof time === "string") ? $D.parse(this.toString("d") + " " + time) : this.set(time); }; /** * Creates a new Date() and adds this (Number) to the date based on the preceding date element function (eg. second|minute|hour|day|month|year). * Example

	// Undeclared Numbers must be wrapped with parentheses. Requirment of JavaScript.
	(3).days().fromNow();
	(6).months().fromNow();

	// Declared Number variables do not require parentheses. 
	var n = 6;
	n.months().fromNow();
	
* * @return {Date} A new Date instance */ $N.fromNow = $N.after = function (date) { var c = {}; c[this._dateElement] = this; return ((!date) ? new Date() : date.clone()).add(c); }; /** * Creates a new Date() and subtract this (Number) from the date based on the preceding date element function (eg. second|minute|hour|day|month|year). * Example

	// Undeclared Numbers must be wrapped with parentheses. Requirment of JavaScript.
	(3).days().ago();
	(6).months().ago();

	// Declared Number variables do not require parentheses. 
	var n = 6;
	n.months().ago();
	
* * @return {Date} A new Date instance */ $N.ago = $N.before = function (date) { var c = {}, s = (this._dateElement[this._dateElement.length-1] !== "s") ? this._dateElement + "s" : this._dateElement; c[s] = this * -1; return ((!date) ? new Date() : date.clone()).add(c); }; // Do NOT modify the following string tokens. These tokens are used to build dynamic functions. // All culture-specific strings can be found in the CultureInfo files. var dx = ("sunday monday tuesday wednesday thursday friday saturday").split(/\s/), mx = ("january february march april may june july august september october november december").split(/\s/), px = ("Millisecond Second Minute Hour Day Week Month Year Quarter Weekday").split(/\s/), pxf = ("Milliseconds Seconds Minutes Hours Date Week Month FullYear Quarter").split(/\s/), nth = ("final first second third fourth fifth").split(/\s/), de; /** * Returns an object literal of all the date parts. * Example

	var o = new Date().toObject();
	
	// { year: 2008, month: 4, week: 20, day: 13, hour: 18, minute: 9, second: 32, millisecond: 812 }
	
	// The object properties can be referenced directly from the object.
	
	alert(o.day);  // alerts "13"
	alert(o.year); // alerts "2008"
	
* * @return {Date} An object literal representing the original date object. */ $P.toObject = function () { var o = {}; for (var i = 0; i < px.length; i++) { if (this["get" + pxf[i]]) { o[px[i].toLowerCase()] = this["get" + pxf[i]](); } } return o; }; /** * Returns a date created from an object literal. Ignores the .week property if set in the config. * Example

	var o = new Date().toObject();
	
	return Date.fromObject(o); // will return the same date. 

	var o2 = {month: 1, day: 20, hour: 18}; // birthday party!
	Date.fromObject(o2);
	
* * @return {Date} An object literal representing the original date object. */ $D.fromObject = function(config) { config.week = null; return Date.today().set(config); }; // Create day name functions and abbreviated day name functions (eg. monday(), friday(), fri()). var df = function (n) { return function () { if (this._is) { this._is = false; return this.getDay() === n; } if (this._move) { this._move = null; } if (this._nth !== null) { // If the .second() function was called earlier, remove the _orient // from the date, and then continue. // This is required because 'second' can be used in two different context. // // Example // // Date.today().add(1).second(); // Date.march().second().monday(); // // Things get crazy with the following... // Date.march().add(1).second().second().monday(); // but it works!! // if (this._isSecond) { this.addSeconds(this._orient * -1); } // make sure we reset _isSecond this._isSecond = false; var ntemp = this._nth; this._nth = null; var temp = this.clone().moveToLastDayOfMonth(); this.moveToNthOccurrence(n, ntemp); if (this > temp) { throw new RangeError($D.getDayName(n) + " does not occur " + ntemp + " times in the month of " + $D.getMonthName(temp.getMonth()) + " " + temp.getFullYear() + "."); } return this; } return this.moveToDayOfWeek(n, this._orient); }; }; var sdf = function (n) { return function () { var t = $D.today(), shift = n - t.getDay(); if (n === 0 && Date.CultureInfo.firstDayOfWeek === 1 && t.getDay() !== 0) { shift = shift + 7; } return t.addDays(shift); }; }; // Create month name functions and abbreviated month name functions (eg. january(), march(), mar()). var month_instance_functions = function (n) { return function () { if (this._is) { this._is = false; return this.getMonth() === n; } return this.moveToMonth(n, this._orient); }; }; var month_static_functions = function (n) { return function () { return $D.today().set({ month: n, day: 1 }); }; }; var processTerms = function (names, staticFunc, instanceFunc) { for (var i = 0; i < names.length; i++) { // Create constant static Name variables. $D[names[i].toUpperCase()] = $D[names[i].toUpperCase().substring(0, 3)] = i; // Create Name functions. $D[names[i]] = $D[names[i].substring(0, 3)] = staticFunc(i); // Create Name instance functions. $P[names[i]] = $P[names[i].substring(0, 3)] = instanceFunc(i); } }; processTerms(dx, sdf, df); processTerms(mx, month_static_functions, month_instance_functions); // Create date element functions and plural date element functions used with Date (eg. day(), days(), months()). var ef = function (j) { return function () { // if the .second() function was called earlier, the _orient // has alread been added. Just return this and reset _isSecond. if (this._isSecond) { this._isSecond = false; return this; } if (this._same) { this._same = this._is = false; var o1 = this.toObject(), o2 = (arguments[0] || new Date()).toObject(), v = "", k = j.toLowerCase(); // the substr trick with -1 doesn't work in IE8 or less k = (k[k.length-1] === "s") ? k.substring(0,k.length-1) : k; for (var m = (px.length - 1); m > -1; m--) { v = px[m].toLowerCase(); if (o1[v] !== o2[v]) { return false; } if (k === v) { break; } } return true; } if (j.substring(j.length - 1) !== "s") { j += "s"; } if (this._move) { this._move = null; } return this["add" + j](this._orient); }; }; var nf = function (n) { return function () { this._dateElement = n; return this; }; }; for (var k = 0; k < px.length; k++) { de = px[k].toLowerCase(); if(de !== "weekday") { // Create date element functions and plural date element functions used with Date (eg. day(), days(), months()). $P[de] = $P[de + "s"] = ef(px[k]); // Create date element functions and plural date element functions used with Number (eg. day(), days(), months()). $N[de] = $N[de + "s"] = nf(de + "s"); } } $P._ss = ef("Second"); var nthfn = function (n) { return function (dayOfWeek) { if (this._same) { return this._ss(arguments[0]); } if (dayOfWeek || dayOfWeek === 0) { return this.moveToNthOccurrence(dayOfWeek, n); } this._nth = n; // if the operator is 'second' add the _orient, then deal with it later... if (n === 2 && (dayOfWeek === undefined || dayOfWeek === null)) { this._isSecond = true; return this.addSeconds(this._orient); } return this; }; }; for (var l = 0; l < nth.length; l++) { $P[nth[l]] = (l === 0) ? nthfn(-1) : nthfn(l); } }()); (function () { "use strict"; Date.Parsing = { Exception: function (s) { this.message = "Parse error at '" + s.substring(0, 10) + " ...'"; } }; var $P = Date.Parsing; var dayOffsets = { standard: [0,31,59,90,120,151,181,212,243,273,304,334], leap: [0,31,60,91,121,152,182,213,244,274,305,335] }; $P.isLeapYear = function(year) { return ((year % 4 === 0) && (year % 100 !== 0)) || (year % 400 === 0); }; var utils = { multiReplace : function (str, hash ) { var key; for (key in hash) { if (Object.prototype.hasOwnProperty.call(hash, key)) { var regex; if (typeof hash[key] === "function") { } else { regex = (hash[key] instanceof RegExp) ? hash[key] : new RegExp(hash[key], "g"); } str = str.replace(regex, key); } } return str; }, getDayOfYearFromWeek : function (obj) { var d, jan4, offset; obj.weekDay = (!obj.weekDay && obj.weekDay !== 0) ? 1 : obj.weekDay; d = new Date(obj.year, 0, 4); jan4 = d.getDay() === 0 ? 7 : d.getDay(); // JS is 0 indexed on Sunday. offset = jan4+3; obj.dayOfYear = ((obj.week * 7) + (obj.weekDay === 0 ? 7 : obj.weekDay))-offset; return obj; }, getDayOfYear : function (obj, dayOffset) { if (!obj.dayOfYear) { obj = utils.getDayOfYearFromWeek(obj); } for (var i=0;i <= dayOffset.length;i++) { if (obj.dayOfYear < dayOffset[i] || i === dayOffset.length) { obj.day = obj.day ? obj.day : (obj.dayOfYear - dayOffset[i-1]); break; } else { obj.month = i; } } return obj; }, adjustForTimeZone : function (obj, date) { var offset; if (obj.zone.toUpperCase() === "Z" || (obj.zone_hours === 0 && obj.zone_minutes === 0)) { // it's UTC/GML so work out the current timeszone offset offset = -date.getTimezoneOffset(); } else { offset = (obj.zone_hours*60) + (obj.zone_minutes || 0); if (obj.zone_sign === "+") { offset *= -1; } offset -= date.getTimezoneOffset(); } date.setMinutes(date.getMinutes()+offset); return date; }, setDefaults : function (obj) { obj.year = obj.year || Date.today().getFullYear(); obj.hours = obj.hours || 0; obj.minutes = obj.minutes || 0; obj.seconds = obj.seconds || 0; obj.milliseconds = obj.milliseconds || 0; if (!(!obj.month && (obj.week || obj.dayOfYear))) { // if we have a month, or if we don't but don't have the day calculation data obj.month = obj.month || 0; obj.day = obj.day || 1; } return obj; }, dataNum: function (data, mod, explict, postProcess) { var dataNum = data*1; if (mod) { if (postProcess) { return data ? mod(data)*1 : data; } else { return data ? mod(dataNum) : data; } } else if (!explict){ return data ? dataNum : data; } else { return (data && typeof data !== "undefined") ? dataNum : data; } }, timeDataProcess: function (obj) { var timeObj = {}; for (var x in obj.data) { if (obj.data.hasOwnProperty(x)) { timeObj[x] = obj.ignore[x] ? obj.data[x] : utils.dataNum(obj.data[x], obj.mods[x], obj.explict[x], obj.postProcess[x]); } } if (obj.data.secmins) { obj.data.secmins = obj.data.secmins.replace(",", ".") * 60; if (!timeObj.minutes) { timeObj.minutes = obj.data.secmins; } else if (!timeObj.seconds) { timeObj.seconds = obj.data.secmins; } delete obj.secmins; } return timeObj; }, buildTimeObjectFromData: function (data) { var time = utils.timeDataProcess({ data: { year : data[1], month : data[5], day : data[7], week : data[8], dayOfYear : data[10], hours : data[15], zone_hours : data[23], zone_minutes : data[24], zone : data[21], zone_sign : data[22], weekDay : data[9], minutes: data[16], seconds: data[19], milliseconds: data[20], secmins: data[18] }, mods: { month: function(data) { return data-1; }, weekDay: function (data) { data = Math.abs(data); return (data === 7 ? 0 : data); }, minutes: function (data) { return data.replace(":",""); }, seconds: function (data) { return Math.floor( (data.replace(":","").replace(",","."))*1 ); }, milliseconds: function (data) { return (data.replace(",",".")*1000); } }, postProcess: { minutes: true, seconds: true, milliseconds: true }, explict: { zone_hours: true, zone_minutes: true }, ignore: { zone: true, zone_sign: true, secmins: true } }); return time; }, addToHash: function (hash, keys, data) { keys = keys; data = data; var len = keys.length; for (var i = 0; i < len; i++) { hash[keys[i]] = data[i]; } return hash; }, combineRegex: function (r1, r2) { return new RegExp("(("+r1.source+")\\s("+r2.source+"))"); }, getDateNthString: function(add, last, inc){ if (add) { return Date.today().addDays(inc).toString("d"); } else if (last) { return Date.today().last()[inc]().toString("d"); } }, buildRegexData: function (array) { var arr = []; var len = array.length; for (var i=0; i < len; i++) { if (Object.prototype.toString.call(array[i]) === '[object Array]') { // oldIE compat version of Array.isArray arr.push(this.combineRegex(array[i][0], array[i][1])); } else { arr.push(array[i]); } } return arr; } }; $P.processTimeObject = function (obj) { var date, dayOffset; utils.setDefaults(obj); dayOffset = ($P.isLeapYear(obj.year)) ? dayOffsets.leap : dayOffsets.standard; if (!obj.month && (obj.week || obj.dayOfYear)) { utils.getDayOfYear(obj, dayOffset); } else { obj.dayOfYear = dayOffset[obj.month] + obj.day; } date = new Date(obj.year, obj.month, obj.day, obj.hours, obj.minutes, obj.seconds, obj.milliseconds); if (obj.zone) { utils.adjustForTimeZone(obj, date); // adjust (and calculate) for timezone } return date; }; $P.ISO = { regex : /^([\+-]?\d{4}(?!\d{2}\b))((-?)((0[1-9]|1[0-2])(\3([12]\d|0[1-9]|3[01]))?|W([0-4]\d|5[0-3])(-?[1-7])?|(00[1-9]|0[1-9]\d|[12]\d{2}|3([0-5]\d|6[1-6])))([T\s]((([01]\d|2[0-4])((:?)[0-5]\d)?|24\:?00)([\.,]\d+(?!:))?)?(\17[0-5]\d([\.,]\d+)?)?\s?([zZ]|([\+-])([01]\d|2[0-3]):?([0-5]\d)?)?)?)?$/, parse : function (s) { var time, data = s.match(this.regex); if (!data || !data.length) { return null; } time = utils.buildTimeObjectFromData(data); if (!time.year || (!time.year && (!time.month && !time.day) && (!time.week && !time.dayOfYear)) ) { return null; } return $P.processTimeObject(time); } }; $P.Numeric = { isNumeric: function (e){return!isNaN(parseFloat(e))&&isFinite(e);}, regex: /\b([0-1]?[0-9])([0-3]?[0-9])([0-2]?[0-9]?[0-9][0-9])\b/i, parse: function (s) { var data, i, time = {}, order = Date.CultureInfo.dateElementOrder.split(""); if (!(this.isNumeric(s)) || // if it's non-numeric OR (s[0] === "+" && s[0] === "-")) { // It's an arithmatic string (eg +/-1000) return null; } if (s.length < 5 && s.indexOf(".") < 0 && s.indexOf("/") < 0) { // assume it's just a year. time.year = s; return $P.processTimeObject(time); } data = s.match(this.regex); if (!data || !data.length) { return null; } for (i=0; i < order.length; i++) { switch(order[i]) { case "d": time.day = data[i+1]; break; case "m": time.month = (data[i+1]-1); break; case "y": time.year = data[i+1]; break; } } return $P.processTimeObject(time); } }; $P.Normalizer = { regexData: function () { var $R = Date.CultureInfo.regexPatterns; return utils.buildRegexData([ $R.tomorrow, $R.yesterday, [$R.past, $R.mon], [$R.past, $R.tue], [$R.past, $R.wed], [$R.past, $R.thu], [$R.past, $R.fri], [$R.past, $R.sat], [$R.past, $R.sun] ]); }, basicReplaceHash : function() { var $R = Date.CultureInfo.regexPatterns; return { "January": $R.jan.source, "February": $R.feb, "March": $R.mar, "April": $R.apr, "May": $R.may, "June": $R.jun, "July": $R.jul, "August": $R.aug, "September": $R.sep, "October": $R.oct, "November": $R.nov, "December": $R.dec, "": /\bat\b/gi, " ": /\s{2,}/, "am": $R.inTheMorning, "9am": $R.thisMorning, "pm": $R.inTheEvening, "7pm":$R.thisEvening }; }, keys : function(){ return [ utils.getDateNthString(true, false, 1), // tomorrow utils.getDateNthString(true, false, -1), // yesterday utils.getDateNthString(false, true, "monday"), //last mon utils.getDateNthString(false, true, "tuesday"), //last tues utils.getDateNthString(false, true, "wednesday"), //last wed utils.getDateNthString(false, true, "thursday"), //last thurs utils.getDateNthString(false, true, "friday"), //last fri utils.getDateNthString(false, true, "saturday"), //last sat utils.getDateNthString(false, true, "sunday") //last sun ]; }, buildRegexFunctions: function () { var $R = Date.CultureInfo.regexPatterns; var __ = Date.i18n.__; var tomorrowRE = new RegExp("(\\b\\d\\d?("+__("AM")+"|"+__("PM")+")? )("+$R.tomorrow.source.slice(1)+")", "i"); // adapted tomorrow regex for AM PM relative dates var todayRE = new RegExp($R.today.source + "(?!\\s*([+-]))\\b"); // today, but excludes the math operators (eg "today + 2h") this.replaceFuncs = [ [todayRE, function (full) { return (full.length > 1) ? Date.today().toString("d") : full; }], [tomorrowRE, function(full, m1) { var t = Date.today().addDays(1).toString("d"); return (t + " " + m1); }], [$R.amThisMorning, function(str, am){return am;}], [$R.pmThisEvening, function(str, pm){return pm;}] ]; }, buildReplaceData: function () { this.buildRegexFunctions(); this.replaceHash = utils.addToHash(this.basicReplaceHash(), this.keys(), this.regexData()); }, stringReplaceFuncs: function (s) { for (var i=0; i < this.replaceFuncs.length; i++) { s = s.replace(this.replaceFuncs[i][0], this.replaceFuncs[i][1]); } return s; }, parse: function (s) { s = this.stringReplaceFuncs(s); s = utils.multiReplace(s, this.replaceHash); try { var n = s.split(/([\s\-\.\,\/\x27]+)/); if (n.length === 3 && $P.Numeric.isNumeric(n[0]) && $P.Numeric.isNumeric(n[2]) && (n[2].length >= 4)) { // ok, so we're dealing with x/year. But that's not a full date. // This fixes wonky dateElementOrder parsing when set to dmy order. if (Date.CultureInfo.dateElementOrder[0] === "d") { s = "1/" + n[0] + "/" + n[2]; // set to 1st of month and normalize the seperator } } } catch (e) {} return s; } }; $P.Normalizer.buildReplaceData(); }()); (function () { var $P = Date.Parsing; var _ = $P.Operators = { // // Tokenizers // rtoken: function (r) { // regex token return function (s) { var mx = s.match(r); if (mx) { return ([ mx[0], s.substring(mx[0].length) ]); } else { throw new $P.Exception(s); } }; }, token: function () { // whitespace-eating token return function (s) { return _.rtoken(new RegExp("^\\s*" + s + "\\s*"))(s); }; }, stoken: function (s) { // string token return _.rtoken(new RegExp("^" + s)); }, // Atomic Operators until: function (p) { return function (s) { var qx = [], rx = null; while (s.length) { try { rx = p.call(this, s); } catch (e) { qx.push(rx[0]); s = rx[1]; continue; } break; } return [ qx, s ]; }; }, many: function (p) { return function (s) { var rx = [], r = null; while (s.length) { try { r = p.call(this, s); } catch (e) { return [ rx, s ]; } rx.push(r[0]); s = r[1]; } return [ rx, s ]; }; }, // generator operators -- see below optional: function (p) { return function (s) { var r = null; try { r = p.call(this, s); } catch (e) { return [ null, s ]; } return [ r[0], r[1] ]; }; }, not: function (p) { return function (s) { try { p.call(this, s); } catch (e) { return [null, s]; } throw new $P.Exception(s); }; }, ignore: function (p) { return p ? function (s) { var r = null; r = p.call(this, s); return [null, r[1]]; } : null; }, product: function () { var px = arguments[0], qx = Array.prototype.slice.call(arguments, 1), rx = []; for (var i = 0 ; i < px.length ; i++) { rx.push(_.each(px[i], qx)); } return rx; }, cache: function (rule) { var cache = {}, cache_length = 0, cache_keys = [], CACHE_MAX = Date.Config.CACHE_MAX || 100000, r = null; var cacheCheck = function () { if (cache_length === CACHE_MAX) { // kill several keys, don't want to have to do this all the time... for (var i=0; i < 10; i++) { var key = cache_keys.shift(); if (key) { delete cache[key]; cache_length--; } } } }; return function (s) { cacheCheck(); try { r = cache[s] = (cache[s] || rule.call(this, s)); } catch (e) { r = cache[s] = e; } cache_length++; cache_keys.push(s); if (r instanceof $P.Exception) { throw r; } else { return r; } }; }, // vector operators -- see below any: function () { var px = arguments; return function (s) { var r = null; for (var i = 0; i < px.length; i++) { if (px[i] == null) { continue; } try { r = (px[i].call(this, s)); } catch (e) { r = null; } if (r) { return r; } } throw new $P.Exception(s); }; }, each: function () { var px = arguments; return function (s) { var rx = [], r = null; for (var i = 0; i < px.length ; i++) { if (px[i] == null) { continue; } try { r = (px[i].call(this, s)); } catch (e) { throw new $P.Exception(s); } rx.push(r[0]); s = r[1]; } return [ rx, s]; }; }, all: function () { var px = arguments, _ = _; return _.each(_.optional(px)); }, // delimited operators sequence: function (px, d, c) { d = d || _.rtoken(/^\s*/); c = c || null; if (px.length === 1) { return px[0]; } return function (s) { var r = null, q = null; var rx = []; for (var i = 0; i < px.length ; i++) { try { r = px[i].call(this, s); } catch (e) { break; } rx.push(r[0]); try { q = d.call(this, r[1]); } catch (ex) { q = null; break; } s = q[1]; } if (!r) { throw new $P.Exception(s); } if (q) { throw new $P.Exception(q[1]); } if (c) { try { r = c.call(this, r[1]); } catch (ey) { throw new $P.Exception(r[1]); } } return [ rx, (r?r[1]:s) ]; }; }, // // Composite Operators // between: function (d1, p, d2) { d2 = d2 || d1; var _fn = _.each(_.ignore(d1), p, _.ignore(d2)); return function (s) { var rx = _fn.call(this, s); return [[rx[0][0], r[0][2]], rx[1]]; }; }, list: function (p, d, c) { d = d || _.rtoken(/^\s*/); c = c || null; return (p instanceof Array ? _.each(_.product(p.slice(0, -1), _.ignore(d)), p.slice(-1), _.ignore(c)) : _.each(_.many(_.each(p, _.ignore(d))), px, _.ignore(c))); }, set: function (px, d, c) { d = d || _.rtoken(/^\s*/); c = c || null; return function (s) { // r is the current match, best the current 'best' match // which means it parsed the most amount of input var r = null, p = null, q = null, rx = null, best = [[], s], last = false; // go through the rules in the given set for (var i = 0; i < px.length ; i++) { // last is a flag indicating whether this must be the last element // if there is only 1 element, then it MUST be the last one q = null; p = null; r = null; last = (px.length === 1); // first, we try simply to match the current pattern // if not, try the next pattern try { r = px[i].call(this, s); } catch (e) { continue; } // since we are matching against a set of elements, the first // thing to do is to add r[0] to matched elements rx = [[r[0]], r[1]]; // if we matched and there is still input to parse and // we don't already know this is the last element, // we're going to next check for the delimiter ... // if there's none, or if there's no input left to parse // than this must be the last element after all ... if (r[1].length > 0 && ! last) { try { q = d.call(this, r[1]); } catch (ex) { last = true; } } else { last = true; } // if we parsed the delimiter and now there's no more input, // that means we shouldn't have parsed the delimiter at all // so don't update r and mark this as the last element ... if (!last && q[1].length === 0) { last = true; } // so, if this isn't the last element, we're going to see if // we can get any more matches from the remaining (unmatched) // elements ... if (!last) { // build a list of the remaining rules we can match against, // i.e., all but the one we just matched against var qx = []; for (var j = 0; j < px.length ; j++) { if (i !== j) { qx.push(px[j]); } } // now invoke recursively set with the remaining input // note that we don't include the closing delimiter ... // we'll check for that ourselves at the end p = _.set(qx, d).call(this, q[1]); // if we got a non-empty set as a result ... // (otw rx already contains everything we want to match) if (p[0].length > 0) { // update current result, which is stored in rx ... // basically, pick up the remaining text from p[1] // and concat the result from p[0] so that we don't // get endless nesting ... rx[0] = rx[0].concat(p[0]); rx[1] = p[1]; } } // at this point, rx either contains the last matched element // or the entire matched set that starts with this element. // now we just check to see if this variation is better than // our best so far, in terms of how much of the input is parsed if (rx[1].length < best[1].length) { best = rx; } // if we've parsed all the input, then we're finished if (best[1].length === 0) { break; } } // so now we've either gone through all the patterns trying them // as the initial match; or we found one that parsed the entire // input string ... // if best has no matches, just return empty set ... if (best[0].length === 0) { return best; } // if a closing delimiter is provided, then we have to check it also if (c) { // we try this even if there is no remaining input because the pattern // may well be optional or match empty input ... try { q = c.call(this, best[1]); } catch (ey) { throw new $P.Exception(best[1]); } // it parsed ... be sure to update the best match remaining input best[1] = q[1]; } // if we're here, either there was no closing delimiter or we parsed it // so now we have the best match; just return it! return best; }; }, forward: function (gr, fname) { return function (s) { return gr[fname].call(this, s); }; }, // // Translation Operators // replace: function (rule, repl) { return function (s) { var r = rule.call(this, s); return [repl, r[1]]; }; }, process: function (rule, fn) { return function (s) { var r = rule.call(this, s); return [fn.call(this, r[0]), r[1]]; }; }, min: function (min, rule) { return function (s) { var rx = rule.call(this, s); if (rx[0].length < min) { throw new $P.Exception(s); } return rx; }; } }; // Generator Operators And Vector Operators // Generators are operators that have a signature of F(R) => R, // taking a given rule and returning another rule, such as // ignore, which parses a given rule and throws away the result. // Vector operators are those that have a signature of F(R1,R2,...) => R, // take a list of rules and returning a new rule, such as each. // Generator operators are converted (via the following _generator // function) into functions that can also take a list or array of rules // and return an array of new rules as though the function had been // called on each rule in turn (which is what actually happens). // This allows generators to be used with vector operators more easily. // Example: // each(ignore(foo, bar)) instead of each(ignore(foo), ignore(bar)) // This also turns generators into vector operators, which allows // constructs like: // not(cache(foo, bar)) var _generator = function (op) { function gen() { var args = null, rx = [], px, i; if (arguments.length > 1) { args = Array.prototype.slice.call(arguments); } else if (arguments[0] instanceof Array) { args = arguments[0]; } if (args) { px = args.shift(); if (px.length > 0) { args.unshift(px[i]); rx.push(op.apply(null, args)); args.shift(); return rx; } } else { return op.apply(null, arguments); } } return gen; }; var gx = "optional not ignore cache".split(/\s/); for (var i = 0 ; i < gx.length ; i++) { _[gx[i]] = _generator(_[gx[i]]); } var _vector = function (op) { return function () { if (arguments[0] instanceof Array) { return op.apply(null, arguments[0]); } else { return op.apply(null, arguments); } }; }; var vx = "each any all".split(/\s/); for (var j = 0 ; j < vx.length ; j++) { _[vx[j]] = _vector(_[vx[j]]); } }()); (function () { var $D = Date; var flattenAndCompact = function (ax) { var rx = []; for (var i = 0; i < ax.length; i++) { if (ax[i] instanceof Array) { rx = rx.concat(flattenAndCompact(ax[i])); } else { if (ax[i]) { rx.push(ax[i]); } } } return rx; }; var parseMeridian = function () { if (this.meridian && (this.hour || this.hour === 0)) { if (this.meridian === "a" && this.hour > 11 && Date.Config.strict24hr){ throw "Invalid hour and meridian combination"; } else if (this.meridian === "p" && this.hour < 12 && Date.Config.strict24hr){ throw "Invalid hour and meridian combination"; } else if (this.meridian === "p" && this.hour < 12) { this.hour = this.hour + 12; } else if (this.meridian === "a" && this.hour === 12) { this.hour = 0; } } }; var setDefaults = function () { var now = new Date(); if ((this.hour || this.minute) && (!this.month && !this.year && !this.day)) { this.day = now.getDate(); } if (!this.year) { this.year = now.getFullYear(); } if (!this.month && this.month !== 0) { this.month = now.getMonth(); } if (!this.day) { this.day = 1; } if (!this.hour) { this.hour = 0; } if (!this.minute) { this.minute = 0; } if (!this.second) { this.second = 0; } if (!this.millisecond) { this.millisecond = 0; } }; var finishUtils = { getToday: function () { if (this.now || "hour minute second".indexOf(this.unit) !== -1) { return new Date(); } else { return $D.today(); } }, setDaysFromWeekday: function (today, orient){ var gap; orient = orient || 1; this.unit = "day"; gap = ($D.getDayNumberFromName(this.weekday) - today.getDay()); this.days = gap ? ((gap + (orient * 7)) % 7) : (orient * 7); return this; }, setMonthsFromMonth: function (today, orient) { var gap; orient = orient || 1; this.unit = "month"; gap = (this.month - today.getMonth()); this.months = gap ? ((gap + (orient * 12)) % 12) : (orient * 12); this.month = null; return this; }, setDMYFromWeekday: function () { var d = Date[this.weekday](); this.day = d.getDate(); if (!this.month) { this.month = d.getMonth(); } this.year = d.getFullYear(); return this; }, setUnitValue: function (orient) { if (!this.value && this.operator && this.operator !== null && this[this.unit + "s"] && this[this.unit + "s"] !== null) { this[this.unit + "s"] = this[this.unit + "s"] + ((this.operator === "add") ? 1 : -1) + (this.value||0) * orient; } else if (this[this.unit + "s"] == null || this.operator != null) { if (!this.value) { this.value = 1; } this[this.unit + "s"] = this.value * orient; } }, generateDateFromWeeks: function () { var weekday = (this.weekday !== undefined) ? this.weekday : "today"; var d = Date[weekday]().addWeeks(this.weeks); if (this.now) { d.setTimeToNow(); } return d; } }; $D.Translator = { hour: function (s) { return function () { this.hour = Number(s); }; }, minute: function (s) { return function () { this.minute = Number(s); }; }, second: function (s) { return function () { this.second = Number(s); }; }, /* for ss.s format */ secondAndMillisecond: function (s) { return function () { var mx = s.match(/^([0-5][0-9])\.([0-9]{1,3})/); this.second = Number(mx[1]); this.millisecond = Number(mx[2]); }; }, meridian: function (s) { return function () { this.meridian = s.slice(0, 1).toLowerCase(); }; }, timezone: function (s) { return function () { var n = s.replace(/[^\d\+\-]/g, ""); if (n.length) { this.timezoneOffset = Number(n); } else { this.timezone = s.toLowerCase(); } }; }, day: function (x) { var s = x[0]; return function () { this.day = Number(s.match(/\d+/)[0]); if (this.day < 1) { throw "invalid day"; } }; }, month: function (s) { return function () { this.month = (s.length === 3) ? "jan feb mar apr may jun jul aug sep oct nov dec".indexOf(s)/4 : Number(s) - 1; if (this.month < 0) { throw "invalid month"; } }; }, year: function (s) { return function () { var n = Number(s); this.year = ((s.length > 2) ? n : (n + (((n + 2000) < Date.CultureInfo.twoDigitYearMax) ? 2000 : 1900))); }; }, rday: function (s) { return function () { switch (s) { case "yesterday": this.days = -1; break; case "tomorrow": this.days = 1; break; case "today": this.days = 0; break; case "now": this.days = 0; this.now = true; break; } }; }, finishExact: function (x) { var d; x = (x instanceof Array) ? x : [x]; for (var i = 0 ; i < x.length ; i++) { if (x[i]) { x[i].call(this); } } setDefaults.call(this); parseMeridian.call(this); if (this.day > $D.getDaysInMonth(this.year, this.month)) { throw new RangeError(this.day + " is not a valid value for days."); } d = new Date(this.year, this.month, this.day, this.hour, this.minute, this.second, this.millisecond); if (this.year < 100) { d.setFullYear(this.year); // means years less that 100 are process correctly. JS will parse it otherwise as 1900-1999. } if (this.timezone) { d.set({ timezone: this.timezone }); } else if (this.timezoneOffset) { d.set({ timezoneOffset: this.timezoneOffset }); } return d; }, finish: function (x) { var today, expression, orient, temp; x = (x instanceof Array) ? flattenAndCompact(x) : [ x ]; if (x.length === 0) { return null; } for (var i = 0 ; i < x.length ; i++) { if (typeof x[i] === "function") { x[i].call(this); } } if (this.now && !this.unit && !this.operator) { return new Date(); } else { today = finishUtils.getToday.call(this); } expression = !!(this.days && this.days !== null || this.orient || this.operator); orient = ((this.orient === "past" || this.operator === "subtract") ? -1 : 1); if (this.month && this.unit === "week") { this.value = this.month + 1; delete this.month; delete this.day; } if ((this.month || this.month === 0) && "year day hour minute second".indexOf(this.unit) !== -1) { if (!this.value) { this.value = this.month + 1; } this.month = null; expression = true; } if (!expression && this.weekday && !this.day && !this.days) { finishUtils.setDMYFromWeekday.call(this); } if (expression && this.weekday && this.unit !== "month" && this.unit !== "week") { finishUtils.setDaysFromWeekday.call(this, today, orient); } if (this.weekday && this.unit !== "week" && !this.day && !this.days) { temp = Date[this.weekday](); this.day = temp.getDate(); if (temp.getMonth() !== today.getMonth()) { this.month = temp.getMonth(); } } if (this.month && this.unit === "day" && this.operator) { if (!this.value) { this.value = (this.month + 1); } this.month = null; } if (this.value != null && this.month != null && this.year != null) { this.day = this.value * 1; } if (this.month && !this.day && this.value) { today.set({ day: this.value * 1 }); if (!expression) { this.day = this.value * 1; } } if (!this.month && this.value && this.unit === "month" && !this.now) { this.month = this.value; expression = true; } if (expression && (this.month || this.month === 0) && this.unit !== "year") { finishUtils.setMonthsFromMonth.call(this, today, orient); } if (!this.unit) { this.unit = "day"; } finishUtils.setUnitValue.call(this, orient); parseMeridian.call(this); if ((this.month || this.month === 0) && !this.day) { this.day = 1; } if (!this.orient && !this.operator && this.unit === "week" && this.value && !this.day && !this.month) { return Date.today().setWeek(this.value); } if (this.unit === "week" && this.weeks && !this.day && !this.month) { return finishUtils.generateDateFromWeeks.call(this); } if (expression && this.timezone && this.day && this.days) { this.day = this.days; } if (expression){ today.add(this); } else { today.set(this); } if (this.timezone) { this.timezone = this.timezone.toUpperCase(); var offset = $D.getTimezoneOffset(this.timezone); var timezone; if (today.hasDaylightSavingTime()) { // lets check that we're being sane with timezone setting timezone = $D.getTimezoneAbbreviation(offset, today.isDaylightSavingTime()); if (timezone !== this.timezone) { // bugger, we're in a place where things like EST vs EDT matters. if (today.isDaylightSavingTime()) { today.addHours(-1); } else { today.addHours(1); } } } today.setTimezoneOffset(offset); } return today; } }; }()); (function () { var $D = Date; $D.Grammar = {}; var _ = $D.Parsing.Operators, g = $D.Grammar, t = $D.Translator, _fn; // Allow rolling up into general purpose rules _fn = function () { return _.each(_.any.apply(null, arguments), _.not(g.ctoken2("timeContext"))); }; g.datePartDelimiter = _.rtoken(/^([\s\-\.\,\/\x27]+)/); g.timePartDelimiter = _.stoken(":"); g.whiteSpace = _.rtoken(/^\s*/); g.generalDelimiter = _.rtoken(/^(([\s\,]|at|@|on)+)/); var _C = {}; g.ctoken = function (keys) { var fn = _C[keys]; if (! fn) { var c = Date.CultureInfo.regexPatterns; var kx = keys.split(/\s+/), px = []; for (var i = 0; i < kx.length ; i++) { px.push(_.replace(_.rtoken(c[kx[i]]), kx[i])); } fn = _C[keys] = _.any.apply(null, px); } return fn; }; g.ctoken2 = function (key) { return _.rtoken(Date.CultureInfo.regexPatterns[key]); }; var cacheProcessRtoken = function (key, token, type, eachToken) { if (eachToken) { g[key] = _.cache(_.process(_.each(_.rtoken(token),_.optional(g.ctoken2(eachToken))), type)); } else { g[key] = _.cache(_.process(_.rtoken(token), type)); } }; var cacheProcessCtoken = function (token, type) { return _.cache(_.process(g.ctoken2(token), type)); }; var _F = {}; //function cache var _get = function (f) { _F[f] = (_F[f] || g.format(f)[0]); return _F[f]; }; g.allformats = function (fx) { var rx = []; if (fx instanceof Array) { for (var i = 0; i < fx.length; i++) { rx.push(_get(fx[i])); } } else { rx.push(_get(fx)); } return rx; }; g.formats = function (fx) { if (fx instanceof Array) { var rx = []; for (var i = 0 ; i < fx.length ; i++) { rx.push(_get(fx[i])); } return _.any.apply(null, rx); } else { return _get(fx); } }; var grammarFormats = { timeFormats: function(){ var i, RTokenKeys = [ "h", "hh", "H", "HH", "m", "mm", "s", "ss", "ss.s", "z", "zz" ], RToken = [ /^(0[0-9]|1[0-2]|[1-9])/, /^(0[0-9]|1[0-2])/, /^([0-1][0-9]|2[0-3]|[0-9])/, /^([0-1][0-9]|2[0-3])/, /^([0-5][0-9]|[0-9])/, /^[0-5][0-9]/, /^([0-5][0-9]|[0-9])/, /^[0-5][0-9]/, /^[0-5][0-9]\.[0-9]{1,3}/, /^((\+|\-)\s*\d\d\d\d)|((\+|\-)\d\d\:?\d\d)/, /^((\+|\-)\s*\d\d\d\d)|((\+|\-)\d\d\:?\d\d)/ ], tokens = [ t.hour, t.hour, t.hour, t.hour, t.minute, t.minute, t.second, t.second, t.secondAndMillisecond, t.timezone, t.timezone ]; for (i=0; i < RTokenKeys.length; i++) { cacheProcessRtoken(RTokenKeys[i], RToken[i], tokens[i]); } g.hms = _.cache(_.sequence([g.H, g.m, g.s], g.timePartDelimiter)); g.t = cacheProcessCtoken("shortMeridian", t.meridian); g.tt = cacheProcessCtoken("longMeridian", t.meridian); g.zzz = cacheProcessCtoken("timezone", t.timezone); g.timeSuffix = _.each(_.ignore(g.whiteSpace), _.set([ g.tt, g.zzz ])); g.time = _.each(_.optional(_.ignore(_.stoken("T"))), g.hms, g.timeSuffix); }, dateFormats: function () { // pre-loaded rules for different date part order preferences var _setfn = function () { return _.set(arguments, g.datePartDelimiter); }; var i, RTokenKeys = [ "d", "dd", "M", "MM", "y", "yy", "yyy", "yyyy" ], RToken = [ /^([0-2]\d|3[0-1]|\d)/, /^([0-2]\d|3[0-1])/, /^(1[0-2]|0\d|\d)/, /^(1[0-2]|0\d)/, /^(\d+)/, /^(\d\d)/, /^(\d\d?\d?\d?)/, /^(\d\d\d\d)/ ], tokens = [ t.day, t.day, t.month, t.month, t.year, t.year, t.year, t.year ], eachToken = [ "ordinalSuffix", "ordinalSuffix" ]; for (i=0; i < RTokenKeys.length; i++) { cacheProcessRtoken(RTokenKeys[i], RToken[i], tokens[i], eachToken[i]); } g.MMM = g.MMMM = _.cache(_.process(g.ctoken("jan feb mar apr may jun jul aug sep oct nov dec"), t.month)); g.ddd = g.dddd = _.cache(_.process(g.ctoken("sun mon tue wed thu fri sat"), function (s) { return function () { this.weekday = s; }; } )); g.day = _fn(g.d, g.dd); g.month = _fn(g.M, g.MMM); g.year = _fn(g.yyyy, g.yy); g.mdy = _setfn(g.ddd, g.month, g.day, g.year); g.ymd = _setfn(g.ddd, g.year, g.month, g.day); g.dmy = _setfn(g.ddd, g.day, g.month, g.year); g.date = function (s) { return ((g[Date.CultureInfo.dateElementOrder] || g.mdy).call(this, s)); }; }, relative: function () { // relative date / time expressions g.orientation = _.process(g.ctoken("past future"), function (s) { return function () { this.orient = s; }; } ); g.operator = _.process(g.ctoken("add subtract"), function (s) { return function () { this.operator = s; }; } ); g.rday = _.process(g.ctoken("yesterday tomorrow today now"), t.rday); g.unit = _.process(g.ctoken("second minute hour day week month year"), function (s) { return function () { this.unit = s; }; } ); } }; g.buildGrammarFormats = function () { // these need to be rebuilt every time the language changes. _C = {}; grammarFormats.timeFormats(); grammarFormats.dateFormats(); grammarFormats.relative(); g.value = _.process(_.rtoken(/^([-+]?\d+)?(st|nd|rd|th)?/), function (s) { return function () { this.value = s.replace(/\D/g, ""); }; } ); g.expression = _.set([g.rday, g.operator, g.value, g.unit, g.orientation, g.ddd, g.MMM ]); g.format = _.process(_.many( _.any( // translate format specifiers into grammar rules _.process( _.rtoken(/^(dd?d?d?(?!e)|MM?M?M?|yy?y?y?|hh?|HH?|mm?|ss?|tt?|zz?z?)/), function (fmt) { if (g[fmt]) { return g[fmt]; } else { throw $D.Parsing.Exception(fmt); } } ), // translate separator tokens into token rules _.process(_.rtoken(/^[^dMyhHmstz]+/), // all legal separators function (s) { return _.ignore(_.stoken(s)); } ) ) ), // construct the parser ... function (rules) { return _.process(_.each.apply(null, rules), t.finishExact); } ); // starting rule for general purpose grammar g._start = _.process(_.set([ g.date, g.time, g.expression ], g.generalDelimiter, g.whiteSpace), t.finish); }; g.buildGrammarFormats(); // parsing date format specifiers - ex: "h:m:s tt" // this little guy will generate a custom parser based // on the format string, ex: g.format("h:m:s tt") // check for these formats first g._formats = g.formats([ "\"yyyy-MM-ddTHH:mm:ssZ\"", "yyyy-MM-ddTHH:mm:ss.sz", "yyyy-MM-ddTHH:mm:ssZ", "yyyy-MM-ddTHH:mm:ssz", "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-ddTHH:mmZ", "yyyy-MM-ddTHH:mmz", "yyyy-MM-ddTHH:mm", "ddd, MMM dd, yyyy H:mm:ss tt", "ddd MMM d yyyy HH:mm:ss zzz", "MMddyyyy", "ddMMyyyy", "Mddyyyy", "ddMyyyy", "Mdyyyy", "dMyyyy", "yyyy", "Mdyy", "dMyy", "d" ]); // real starting rule: tries selected formats first, // then general purpose rule g.start = function (s) { try { var r = g._formats.call({}, s); if (r[1].length === 0) { return r; } } catch (e) {} return g._start.call({}, s); }; }()); (function () { var $D = Date; /** * @desc Converts the specified string value into its JavaScript Date equivalent using CultureInfo specific format information. * * Example

	///////////
	// Dates //
	///////////

	// 15-Oct-2004
	var d1 = Date.parse("10/15/2004");

	// 15-Oct-2004
	var d1 = Date.parse("15-Oct-2004");

	// 15-Oct-2004
	var d1 = Date.parse("2004.10.15");

	//Fri Oct 15, 2004
	var d1 = Date.parse("Fri Oct 15, 2004");

	///////////
	// Times //
	///////////

	// Today at 10 PM.
	var d1 = Date.parse("10 PM");

	// Today at 10:30 PM.
	var d1 = Date.parse("10:30 P.M.");

	// Today at 6 AM.
	var d1 = Date.parse("06am");

	/////////////////////
	// Dates and Times //
	/////////////////////

	// 8-July-2004 @ 10:30 PM
	var d1 = Date.parse("July 8th, 2004, 10:30 PM");

	// 1-July-2004 @ 10:30 PM
	var d1 = Date.parse("2004-07-01T22:30:00");

	////////////////////
	// Relative Dates //
	////////////////////

	// Returns today's date. The string "today" is culture specific.
	var d1 = Date.parse("today");

	// Returns yesterday's date. The string "yesterday" is culture specific.
	var d1 = Date.parse("yesterday");

	// Returns the date of the next thursday.
	var d1 = Date.parse("Next thursday");

	// Returns the date of the most previous monday.
	var d1 = Date.parse("last monday");

	// Returns today's day + one year.
	var d1 = Date.parse("next year");

	///////////////
	// Date Math //
	///////////////

	// Today + 2 days
	var d1 = Date.parse("t+2");

	// Today + 2 days
	var d1 = Date.parse("today + 2 days");

	// Today + 3 months
	var d1 = Date.parse("t+3m");

	// Today - 1 year
	var d1 = Date.parse("today - 1 year");

	// Today - 1 year
	var d1 = Date.parse("t-1y"); 


	/////////////////////////////
	// Partial Dates and Times //
	/////////////////////////////

	// July 15th of this year.
	var d1 = Date.parse("July 15");

	// 15th day of current day and year.
	var d1 = Date.parse("15");

	// July 1st of current year at 10pm.
	var d1 = Date.parse("7/1 10pm");
	
* * @param {String} The string value to convert into a Date object [Required] * @return {Date} A Date object or null if the string cannot be converted into a Date. */ var parseUtils = { removeOrds: function (s) { ords = s.match(/\b(\d+)(?:st|nd|rd|th)\b/); // find ordinal matches s = ((ords && ords.length === 2) ? s.replace(ords[0], ords[1]) : s); return s; }, grammarParser: function (s) { var r = null; try { r = $D.Grammar.start.call({}, s.replace(/^\s*(\S*(\s+\S+)*)\s*$/, "$1")); } catch (e) { return null; } return ((r[1].length === 0) ? r[0] : null); }, nativeFallback: function(s) { var t; try { // ok we haven't parsed it, last ditch attempt with the built-in parser. t = Date._parse(s); return (t || t === 0) ? new Date(t) : null; } catch (e) { return null; } } }; function parse (s) { var d; if (!s) { return null; } if (s instanceof Date) { return s.clone(); } if (s.length >= 4 && s.charAt(0) !== "0" && s.charAt(0) !== "+"&& s.charAt(0) !== "-") { // ie: 2004 will pass, 0800 won't. // Start with specific formats d = $D.Parsing.ISO.parse(s) || $D.Parsing.Numeric.parse(s); } if (d instanceof Date && !isNaN(d.getTime())) { return d; } else { // find ordinal dates (1st, 3rd, 8th, etc and remove them as they cause parsing issues) s = $D.Parsing.Normalizer.parse(parseUtils.removeOrds(s)); d = parseUtils.grammarParser(s); if (d !== null) { return d; } else { return parseUtils.nativeFallback(s); } } } if (!$D._parse) { $D._parse = $D.parse; } $D.parse = parse; Date.getParseFunction = function (fx) { var fns = Date.Grammar.allformats(fx); return function (s) { var r = null; for (var i = 0; i < fns.length; i++) { try { r = fns[i].call({}, s); } catch (e) { continue; } if (r[1].length === 0) { return r[0]; } } return null; }; }; /** * Converts the specified string value into its JavaScript Date equivalent using the specified format {String} or formats {Array} and the CultureInfo specific format information. * The format of the string value must match one of the supplied formats exactly. * * Example

	// 15-Oct-2004
	var d1 = Date.parseExact("10/15/2004", "M/d/yyyy");

	// 15-Oct-2004
	var d1 = Date.parse("15-Oct-2004", "M-ddd-yyyy");

	// 15-Oct-2004
	var d1 = Date.parse("2004.10.15", "yyyy.MM.dd");

	// Multiple formats
	var d1 = Date.parseExact("10/15/2004", ["M/d/yyyy", "MMMM d, yyyy"]);
	
* * @param {String} The string value to convert into a Date object [Required]. * @param {Object} The expected format {String} or an array of expected formats {Array} of the date string [Required]. * @return {Date} A Date object or null if the string cannot be converted into a Date. */ $D.parseExact = function (s, fx) { return $D.getParseFunction(fx)(s); }; }()); (function () { var $D = Date, $P = $D.prototype, // $C = $D.CultureInfo, // not used atm p = function (s, l) { if (!l) { l = 2; } return ("000" + s).slice(l * -1); }; /** * Converts a PHP format string to Java/.NET format string. * A PHP format string can be used with ._format or .format. * A Java/.NET format string can be used with .toString(). * The .parseExact function will only accept a Java/.NET format string * * Example * var f1 = "%m/%d/%y" * var f2 = Date.normalizeFormat(f1); // "MM/dd/yy" * * new Date().format(f1); // "04/13/08" * new Date()._format(f1); // "04/13/08" * new Date().toString(f2); // "04/13/08" * * var date = Date.parseExact("04/13/08", f2); // Sun Apr 13 2008 * * @param {String} A PHP format string consisting of one or more format spcifiers. * @return {String} The PHP format converted to a Java/.NET format string. */ var normalizerSubstitutions = { "d" : "dd", "%d": "dd", "D" : "ddd", "%a": "ddd", "j" : "dddd", "l" : "dddd", "%A": "dddd", "S" : "S", "F" : "MMMM", "%B": "MMMM", "m" : "MM", "%m": "MM", "M" : "MMM", "%b": "MMM", "%h": "MMM", "n" : "M", "Y" : "yyyy", "%Y": "yyyy", "y" : "yy", "%y": "yy", "g" : "h", "%I": "h", "G" : "H", "h" : "hh", "H" : "HH", "%H": "HH", "i" : "mm", "%M": "mm", "s" : "ss", "%S": "ss", "%r": "hh:mm tt", "%R": "H:mm", "%T": "H:mm:ss", "%X": "t", "%x": "d", "%e": "d", "%D": "MM/dd/yy", "%n": "\\n", "%t": "\\t", "e" : "z", "T" : "z", "%z": "z", "%Z": "z", "Z" : "ZZ", "N" : "u", "w" : "u", "%w": "u", "W" : "W", "%V": "W" }; var normalizer = { substitutes: function (m) { return normalizerSubstitutions[m]; }, interpreted: function (m, x) { var y; switch (m) { case "%u": return x.getDay() + 1; case "z": return x.getOrdinalNumber(); case "%j": return p(x.getOrdinalNumber(), 3); case "%U": var d1 = x.clone().set({month: 0, day: 1}).addDays(-1).moveToDayOfWeek(0), d2 = x.clone().addDays(1).moveToDayOfWeek(0, -1); return (d2 < d1) ? "00" : p((d2.getOrdinalNumber() - d1.getOrdinalNumber()) / 7 + 1); case "%W": return p(x.getWeek()); case "t": return $D.getDaysInMonth(x.getFullYear(), x.getMonth()); case "o": case "%G": return x.setWeek(x.getISOWeek()).toString("yyyy"); case "%g": return x._format("%G").slice(-2); case "a": case "%p": return t("tt").toLowerCase(); case "A": return t("tt").toUpperCase(); case "u": return p(x.getMilliseconds(), 3); case "I": return (x.isDaylightSavingTime()) ? 1 : 0; case "O": return x.getUTCOffset(); case "P": y = x.getUTCOffset(); return y.substring(0, y.length - 2) + ":" + y.substring(y.length - 2); case "B": var now = new Date(); return Math.floor(((now.getHours() * 3600) + (now.getMinutes() * 60) + now.getSeconds() + (now.getTimezoneOffset() + 60) * 60) / 86.4); case "c": return x.toISOString().replace(/\"/g, ""); case "U": return $D.strtotime("now"); case "%c": return t("d") + " " + t("t"); case "%C": return Math.floor(x.getFullYear() / 100 + 1); } }, shouldOverrideDefaults: function (m) { switch (m) { case "%e": return true; default: return false; } }, parse: function (m, context) { var formatString, c = context || new Date(); formatString = normalizer.substitutes(m); if (formatString) { return formatString; } formatString = normalizer.interpreted(m, c); if (formatString) { return formatString; } else { return m; } } }; $D.normalizeFormat = function (format, context) { return format.replace(/(%|\\)?.|%%/g, function(t){ return normalizer.parse(t, context); }); }; /** * Format a local Unix timestamp according to locale settings * * Example: * Date.strftime("%m/%d/%y", new Date()); // "04/13/08" * Date.strftime("c", "2008-04-13T17:52:03Z"); // "04/13/08" * * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @param {Number|String} The number representing the number of seconds that have elapsed since January 1, 1970 (local time). * @return {String} A string representation of the current Date object. */ $D.strftime = function (format, time) { var d = Date.parse(time); return d._format(format); }; /** * Parse any textual datetime description into a Unix timestamp. * A Unix timestamp is the number of seconds that have elapsed since January 1, 1970 (midnight UTC/GMT). * * Example: * Date.strtotime("04/13/08"); // 1208044800 * Date.strtotime("1970-01-01T00:00:00Z"); // 0 * * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @param {Object} A string or date object. * @return {String} A string representation of the current Date object. */ $D.strtotime = function (time) { var d = $D.parse(time); return Math.round($D.UTC(d.getUTCFullYear(), d.getUTCMonth(), d.getUTCDate(), d.getUTCHours(), d.getUTCMinutes(), d.getUTCSeconds(), d.getUTCMilliseconds()) / 1000); }; /** * Converts the value of the current Date object to its equivalent string representation using a PHP/Unix style of date format specifiers. * Format Specifiers * Format Description Example * ------ --------------------------------------------------------------------------- ----------------------- * %a abbreviated weekday name according to the current localed "Mon" through "Sun" * %A full weekday name according to the current localed "Sunday" through "Saturday" * %b abbreviated month name according to the current localed "Jan" through "Dec" * %B full month name according to the current locale "January" through "December" * %c preferred date and time representation for the current locale "4/13/2008 12:33 PM" * %C century number (the year divided by 100 and truncated to an integer) "00" to "99" * %d day of the month as a decimal number "01" to "31" * %D same as %m/%d/%y "04/13/08" * %e day of the month as a decimal number, a single digit is preceded by a space "1" to "31" * %g like %G, but without the century "08" * %G The 4-digit year corresponding to the ISO week number (see %V). "2008" * This has the same format and value as %Y, except that if the ISO week number * belongs to the previous or next year, that year is used instead. * %h same as %b "Jan" through "Dec" * %H hour as a decimal number using a 24-hour clock. "00" to "23" * %I hour as a decimal number using a 12-hour clock. "01" to "12" * %j day of the year as a decimal number. "001" to "366" * %m month as a decimal number. "01" to "12" * %M minute as a decimal number. "00" to "59" * %n newline character "\n" * %p either "am" or "pm" according to the given time value, or the "am" or "pm" * corresponding strings for the current locale. * %r time in a.m. and p.m. notation "8:44 PM" * %R time in 24 hour notation "20:44" * %S second as a decimal number "00" to "59" * %t tab character "\t" * %T current time, equal to %H:%M:%S "12:49:11" * %u weekday as a decimal number ["1", "7"], with "1" representing Monday "1" to "7" * %U week number of the current year as a decimal number, starting with the "0" to ("52" or "53") * first Sunday as the first day of the first week * %V The ISO 8601:1988 week number of the current year as a decimal number, "00" to ("52" or "53") * range 01 to 53, where week 1 is the first week that has at least 4 days * in the current year, and with Monday as the first day of the week. * (Use %G or %g for the year component that corresponds to the week number * for the specified timestamp.) * %W week number of the current year as a decimal number, starting with the "00" to ("52" or "53") * first Monday as the first day of the first week * %w day of the week as a decimal, Sunday being "0" "0" to "6" * %x preferred date representation for the current locale without the time "4/13/2008" * %X preferred time representation for the current locale without the date "12:53:05" * %y year as a decimal number without a century "00" "99" * %Y year as a decimal number including the century "2008" * %Z time zone or name or abbreviation "UTC", "EST", "PST" * %z same as %Z * %% a literal "%" characters "%" * d Day of the month, 2 digits with leading zeros "01" to "31" * D A textual representation of a day, three letters "Mon" through "Sun" * j Day of the month without leading zeros "1" to "31" * l A full textual representation of the day of the week (lowercase "L") "Sunday" through "Saturday" * N ISO-8601 numeric representation of the day of the week (added in PHP 5.1.0) "1" (for Monday) through "7" (for Sunday) * S English ordinal suffix for the day of the month, 2 characters "st", "nd", "rd" or "th". Works well with j * w Numeric representation of the day of the week "0" (for Sunday) through "6" (for Saturday) * z The day of the year (starting from "0") "0" through "365" * W ISO-8601 week number of year, weeks starting on Monday "00" to ("52" or "53") * F A full textual representation of a month, such as January or March "January" through "December" * m Numeric representation of a month, with leading zeros "01" through "12" * M A short textual representation of a month, three letters "Jan" through "Dec" * n Numeric representation of a month, without leading zeros "1" through "12" * t Number of days in the given month "28" through "31" * L Whether it's a leap year "1" if it is a leap year, "0" otherwise * o ISO-8601 year number. This has the same value as Y, except that if the "2008" * ISO week number (W) belongs to the previous or next year, that year * is used instead. * Y A full numeric representation of a year, 4 digits "2008" * y A two digit representation of a year "08" * a Lowercase Ante meridiem and Post meridiem "am" or "pm" * A Uppercase Ante meridiem and Post meridiem "AM" or "PM" * B Swatch Internet time "000" through "999" * g 12-hour format of an hour without leading zeros "1" through "12" * G 24-hour format of an hour without leading zeros "0" through "23" * h 12-hour format of an hour with leading zeros "01" through "12" * H 24-hour format of an hour with leading zeros "00" through "23" * i Minutes with leading zeros "00" to "59" * s Seconds, with leading zeros "00" through "59" * u Milliseconds "54321" * e Timezone identifier "UTC", "EST", "PST" * I Whether or not the date is in daylight saving time (uppercase i) "1" if Daylight Saving Time, "0" otherwise * O Difference to Greenwich time (GMT) in hours "+0200", "-0600" * P Difference to Greenwich time (GMT) with colon between hours and minutes "+02:00", "-06:00" * T Timezone abbreviation "UTC", "EST", "PST" * Z Timezone offset in seconds. The offset for timezones west of UTC is "-43200" through "50400" * always negative, and for those east of UTC is always positive. * c ISO 8601 date "2004-02-12T15:19:21+00:00" * r RFC 2822 formatted date "Thu, 21 Dec 2000 16:01:07 +0200" * U Seconds since the Unix Epoch (January 1 1970 00:00:00 GMT) "0" * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @return {String} A string representation of the current Date object. */ var formatReplace = function (context) { return function (m) { var formatString, override = false; if (m.charAt(0) === "\\" || m.substring(0, 2) === "%%") { return m.replace("\\", "").replace("%%", "%"); } override = normalizer.shouldOverrideDefaults(m); formatString = $D.normalizeFormat(m, context); if (formatString) { return context.toString(formatString, override); } }; }; $P._format = function (format) { var formatter = formatReplace(this); if (!format) { return this._toString(); } else { return format.replace(/(%|\\)?.|%%/g, formatter); } }; if (!$P.format) { $P.format = $P._format; } }()); (function () { "use strict"; var gFn = function (attr) { return function () { return this[attr]; }; }; var sFn = function (attr) { return function (val) { this[attr] = val; return this; }; }; var attrs = ["years", "months", "days", "hours", "minutes", "seconds", "milliseconds"]; var addSetFuncs = function (context, attrs) { for (var i = 0; i < attrs.length ; i++) { var $a = attrs[i], $b = $a.slice(0, 1).toUpperCase() + $a.slice(1); context.prototype[$a] = 0; context.prototype["get" + $b] = gFn($a); context.prototype["set" + $b] = sFn($a); } }; /** * new TimeSpan(milliseconds); * new TimeSpan(days, hours, minutes, seconds); * new TimeSpan(days, hours, minutes, seconds, milliseconds); */ var TimeSpan = function (days, hours, minutes, seconds, milliseconds) { if (arguments.length === 1 && typeof days === "number") { var orient = (days < 0) ? -1 : +1; var millsLeft = Math.abs(days); this.setDays(Math.floor(millsLeft / 86400000) * orient); millsLeft = millsLeft % 86400000; this.setHours(Math.floor(millsLeft / 3600000) * orient); millsLeft = millsLeft % 3600000; this.setMinutes(Math.floor(millsLeft / 60000) * orient); millsLeft = millsLeft % 60000; this.setSeconds(Math.floor(millsLeft / 1000) * orient); millsLeft = millsLeft % 1000; this.setMilliseconds(millsLeft * orient); } else { this.set(days, hours, minutes, seconds, milliseconds); } this.getTotalMilliseconds = function () { return (this.getDays() * 86400000) + (this.getHours() * 3600000) + (this.getMinutes() * 60000) + (this.getSeconds() * 1000); }; this.compareTo = function (time) { var t1 = new Date(1970, 1, 1, this.getHours(), this.getMinutes(), this.getSeconds()), t2; if (time === null) { t2 = new Date(1970, 1, 1, 0, 0, 0); } else { t2 = new Date(1970, 1, 1, time.getHours(), time.getMinutes(), time.getSeconds()); } return (t1 < t2) ? -1 : (t1 > t2) ? 1 : 0; }; this.equals = function (time) { return (this.compareTo(time) === 0); }; this.add = function (time) { return (time === null) ? this : this.addSeconds(time.getTotalMilliseconds() / 1000); }; this.subtract = function (time) { return (time === null) ? this : this.addSeconds(-time.getTotalMilliseconds() / 1000); }; this.addDays = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 86400000)); }; this.addHours = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 3600000)); }; this.addMinutes = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 60000)); }; this.addSeconds = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 1000)); }; this.addMilliseconds = function (n) { return new TimeSpan(this.getTotalMilliseconds() + n); }; this.get12HourHour = function () { return (this.getHours() > 12) ? this.getHours() - 12 : (this.getHours() === 0) ? 12 : this.getHours(); }; this.getDesignator = function () { return (this.getHours() < 12) ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator; }; this.toString = function (format) { this._toString = function () { if (this.getDays() !== null && this.getDays() > 0) { return this.getDays() + "." + this.getHours() + ":" + this.p(this.getMinutes()) + ":" + this.p(this.getSeconds()); } else { return this.getHours() + ":" + this.p(this.getMinutes()) + ":" + this.p(this.getSeconds()); } }; this.p = function (s) { return (s.toString().length < 2) ? "0" + s : s; }; var me = this; return format ? format.replace(/dd?|HH?|hh?|mm?|ss?|tt?/g, function (format) { switch (format) { case "d": return me.getDays(); case "dd": return me.p(me.getDays()); case "H": return me.getHours(); case "HH": return me.p(me.getHours()); case "h": return me.get12HourHour(); case "hh": return me.p(me.get12HourHour()); case "m": return me.getMinutes(); case "mm": return me.p(me.getMinutes()); case "s": return me.getSeconds(); case "ss": return me.p(me.getSeconds()); case "t": return ((me.getHours() < 12) ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator).substring(0, 1); case "tt": return (me.getHours() < 12) ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator; } } ) : this._toString(); }; return this; }; addSetFuncs(TimeSpan, attrs.slice(2)); TimeSpan.prototype.set = function (days, hours, minutes, seconds, milliseconds){ this.setDays(days || this.getDays()); this.setHours(hours || this.getHours()); this.setMinutes(minutes || this.getMinutes()); this.setSeconds(seconds || this.getSeconds()); this.setMilliseconds(milliseconds || this.getMilliseconds()); }; /** * Gets the time of day for this date instances. * @return {TimeSpan} TimeSpan */ Date.prototype.getTimeOfDay = function () { return new TimeSpan(0, this.getHours(), this.getMinutes(), this.getSeconds(), this.getMilliseconds()); }; Date.TimeSpan = TimeSpan; if (typeof window !== "undefined" ) { // keeping API compatible for v1.x window.TimeSpan = TimeSpan; } }()); (function () { "use strict"; var attrs = ["years", "months", "days", "hours", "minutes", "seconds", "milliseconds"]; var gFn = function (attr) { return function () { return this[attr]; }; }; var sFn = function (attr) { return function (val) { this[attr] = val; return this; }; }; var addSetFuncs = function (context, attrs) { for (var i = 0; i < attrs.length ; i++) { var $a = attrs[i], $b = $a.slice(0, 1).toUpperCase() + $a.slice(1); context.prototype[$a] = 0; context.prototype["get" + $b] = gFn($a); context.prototype["set" + $b] = sFn($a); } }; var setMonthsAndYears = function (orient, d1, d2, context) { function inc() { d1.addMonths(-orient); context.months++; if (context.months === 12) { context.years++; context.months = 0; } } if (orient === +1) { while (d1 > d2) { inc(); } } else { while (d1 < d2) { inc(); } } context.months--; context.months *= orient; context.years *= orient; }; var adjustForDST = function(orient, startDate, endDate) { var hasDSTMismatch = (false === (startDate.isDaylightSavingTime() === endDate.isDaylightSavingTime())); if (hasDSTMismatch && orient === 1) { startDate.addHours(-1); } else if (hasDSTMismatch) { startDate.addHours(1); } }; /** * TimePeriod(startDate, endDate); * TimePeriod(years, months, days, hours, minutes, seconds, milliseconds); */ var TimePeriod = function (years, months, days, hours, minutes, seconds, milliseconds) { if (arguments.length === 7) { this.set(years, months, days, hours, minutes, seconds, milliseconds); } else if (arguments.length === 2 && arguments[0] instanceof Date && arguments[1] instanceof Date) { var startDate = arguments[0].clone(); var endDate = arguments[1].clone(); var orient = (startDate > endDate) ? +1 : -1; this.dates = { start: arguments[0].clone(), end: arguments[1].clone() }; setMonthsAndYears(orient, startDate, endDate, this); adjustForDST(orient, startDate, endDate); // // TODO - adjust for DST var diff = endDate - startDate; if (diff !== 0) { var ts = new TimeSpan(diff); this.set(this.years, this.months, ts.getDays(), ts.getHours(), ts.getMinutes(), ts.getSeconds(), ts.getMilliseconds()); } } return this; }; // create all the set functions. addSetFuncs(TimePeriod, attrs); TimePeriod.prototype.set = function (years, months, days, hours, minutes, seconds, milliseconds){ this.setYears(years || this.getYears()); this.setMonths(months || this.getMonths()); this.setDays(days || this.getDays()); this.setHours(hours || this.getHours()); this.setMinutes(minutes || this.getMinutes()); this.setSeconds(seconds || this.getSeconds()); this.setMilliseconds(milliseconds || this.getMilliseconds()); }; Date.TimePeriod = TimePeriod; if (typeof window !== "undefined") { // keeping API compatible for v1.x window.TimePeriod = TimePeriod; } }()); ================================================ FILE: build/date-de-CH.js ================================================ /** * @overview datejs * @version 1.0.0-rc3 * @author Gregory Wild-Smith * @copyright 2015 Gregory Wild-Smith * @license MIT * @homepage https://github.com/abritinthebay/datejs */ /* * DateJS Culture String File * Country Code: de-CH * Name: German (Switzerland) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["de-CH"] = { "name": "de-CH", "englishName": "German (Switzerland)", "nativeName": "Deutsch (Schweiz)", "Sunday": "Sonntag", "Monday": "Montag", "Tuesday": "Dienstag", "Wednesday": "Mittwoch", "Thursday": "Donnerstag", "Friday": "Freitag", "Saturday": "Samstag", "Sun": "Son", "Mon": "Mon", "Tue": "Die", "Wed": "Mit", "Thu": "Don", "Fri": "Fre", "Sat": "Sam", "Su": "So", "Mo": "Mo", "Tu": "Di", "We": "Mi", "Th": "Do", "Fr": "Fr", "Sa": "Sa", "S_Sun_Initial": "S", "M_Mon_Initial": "M", "T_Tue_Initial": "D", "W_Wed_Initial": "M", "T_Thu_Initial": "D", "F_Fri_Initial": "F", "S_Sat_Initial": "S", "January": "Januar", "February": "Februar", "March": "März", "April": "April", "May": "Mai", "June": "Juni", "July": "Juli", "August": "August", "September": "September", "October": "Oktober", "November": "November", "December": "Dezember", "Jan_Abbr": "Jan", "Feb_Abbr": "Feb", "Mar_Abbr": "Mrz", "Apr_Abbr": "Apr", "May_Abbr": "Mai", "Jun_Abbr": "Jun", "Jul_Abbr": "Jul", "Aug_Abbr": "Aug", "Sep_Abbr": "Sep", "Oct_Abbr": "Okt", "Nov_Abbr": "Nov", "Dec_Abbr": "Dez", "AM": "", "PM": "", "firstDayOfWeek": 1, "twoDigitYearMax": 2029, "mdy": "dmy", "M/d/yyyy": "dd.MM.yyyy", "dddd, MMMM dd, yyyy": "dddd, d. MMMM yyyy", "h:mm tt": "HH:mm", "h:mm:ss tt": "HH:mm:ss", "dddd, MMMM dd, yyyy h:mm:ss tt": "dddd, d. MMMM yyyy HH:mm:ss", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "dd MMMM", "MMMM, yyyy": "MMMM yyyy", "/jan(uary)?/": "jan(uar)?", "/feb(ruary)?/": "feb(ruar)?", "/mar(ch)?/": "märz", "/apr(il)?/": "apr(il)?", "/may/": "mai", "/jun(e)?/": "jun(i)?", "/jul(y)?/": "jul(i)?", "/aug(ust)?/": "aug(ust)?", "/sep(t(ember)?)?/": "sep(t(ember)?)?", "/oct(ober)?/": "okt(ober)?", "/nov(ember)?/": "nov(ember)?", "/dec(ember)?/": "dez(ember)?", "/^su(n(day)?)?/": "^sonntag", "/^mo(n(day)?)?/": "^montag", "/^tu(e(s(day)?)?)?/": "^dienstag", "/^we(d(nesday)?)?/": "^mittwoch", "/^th(u(r(s(day)?)?)?)?/": "^donnerstag", "/^fr(i(day)?)?/": "^freitag", "/^sa(t(urday)?)?/": "^samstag", "/^next/": "^nächste(r|s|n)?", "/^last|past|prev(ious)?/": "^letzte(r|s|n)?|vergangene(r|s|n)?|vorherige(r|s|n)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|(da)?nach(er)?|von|daher|in)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|(be|zu)?vor|früher)", "/^yes(terday)?/": "^gestern", "/^t(od(ay)?)?/": "^heute", "/^tom(orrow)?/": "^morgen", "/^n(ow)?/": "^jetzt|sofort|gleich", "/^ms|milli(second)?s?/": "^ms|milli(sekunde(n)?)?", "/^sec(ond)?s?/": "^sek(unde(n)?)?", "/^mn|min(ute)?s?/": "^mn|min(ute(n)?)?", "/^h(our)?s?/": "^h|st(d|unde(n)?)?", "/^w(eek)?s?/": "^w(oche(n)?)?", "/^m(onth)?s?/": "^m(onat(e)?)?", "/^d(ay)?s?/": "^d|t(ag(en)?)?", "/^y(ear)?s?/": "^y|j(ahr(en)?)?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "de-CH"; /** * @overview datejs * @version 1.0.0-rc3 * @author Gregory Wild-Smith * @copyright 2015 Gregory Wild-Smith * @license MIT * @homepage https://github.com/abritinthebay/datejs */(function () { var $D = Date; var lang = Date.CultureStrings ? Date.CultureStrings.lang : null; var loggedKeys = {}; // for debug purposes. var getText = { getFromKey: function (key, countryCode) { var output; if (Date.CultureStrings && Date.CultureStrings[countryCode] && Date.CultureStrings[countryCode][key]) { output = Date.CultureStrings[countryCode][key]; } else { output = getText.buildFromDefault(key); } if (key.charAt(0) === "/") { // Assume it's a regex output = getText.buildFromRegex(key, countryCode); } return output; }, getFromObjectValues: function (obj, countryCode) { var key, output = {}; for(key in obj) { if (obj.hasOwnProperty(key)) { output[key] = getText.getFromKey(obj[key], countryCode); } } return output; }, getFromObjectKeys: function (obj, countryCode) { var key, output = {}; for(key in obj) { if (obj.hasOwnProperty(key)) { output[getText.getFromKey(key, countryCode)] = obj[key]; } } return output; }, getFromArray: function (arr, countryCode) { var output = []; for (var i=0; i < arr.length; i++){ if (i in arr) { output[i] = getText.getFromKey(arr[i], countryCode); } } return output; }, buildFromDefault: function (key) { var output, length, split, last; switch(key) { case "name": output = "en-US"; break; case "englishName": output = "English (United States)"; break; case "nativeName": output = "English (United States)"; break; case "twoDigitYearMax": output = 2049; break; case "firstDayOfWeek": output = 0; break; default: output = key; split = key.split("_"); length = split.length; if (length > 1 && key.charAt(0) !== "/") { // if the key isn't a regex and it has a split. last = split[(length - 1)].toLowerCase(); if (last === "initial" || last === "abbr") { output = split[0]; } } break; } return output; }, buildFromRegex: function (key, countryCode) { var output; if (Date.CultureStrings && Date.CultureStrings[countryCode] && Date.CultureStrings[countryCode][key]) { output = new RegExp(Date.CultureStrings[countryCode][key], "i"); } else { output = new RegExp(key.replace(new RegExp("/", "g"),""), "i"); } return output; } }; var shallowMerge = function (obj1, obj2) { for (var attrname in obj2) { if (obj2.hasOwnProperty(attrname)) { obj1[attrname] = obj2[attrname]; } } }; var __ = function (key, language) { var countryCode = (language) ? language : lang; loggedKeys[key] = key; if (typeof key === "object") { if (key instanceof Array) { return getText.getFromArray(key, countryCode); } else { return getText.getFromObjectKeys(key, countryCode); } } else { return getText.getFromKey(key, countryCode); } }; var loadI18nScript = function (code) { // paatterned after jQuery's getScript. var url = Date.Config.i18n + code + ".js"; var head = document.getElementsByTagName("head")[0] || document.documentElement; var script = document.createElement("script"); script.src = url; var completed = false; var events = { done: function (){} // placeholder function }; // Attach handlers for all browsers script.onload = script.onreadystatechange = function() { if ( !completed && (!this.readyState || this.readyState === "loaded" || this.readyState === "complete") ) { events.done(); head.removeChild(script); } }; setTimeout(function() { head.insertBefore(script, head.firstChild); }, 0); // allows return to execute first return { done: function (cb) { events.done = function() { if (cb) { setTimeout(cb,0); } }; } }; }; var buildInfo = { buildFromMethodHash: function (obj) { var key; for(key in obj) { if (obj.hasOwnProperty(key)) { obj[key] = buildInfo[obj[key]](); } } return obj; }, timeZoneDST: function () { var DST = { "CHADT": "+1345", "NZDT": "+1300", "AEDT": "+1100", "ACDT": "+1030", "AZST": "+0500", "IRDT": "+0430", "EEST": "+0300", "CEST": "+0200", "BST": "+0100", "PMDT": "-0200", "ADT": "-0300", "NDT": "-0230", "EDT": "-0400", "CDT": "-0500", "MDT": "-0600", "PDT": "-0700", "AKDT": "-0800", "HADT": "-0900" }; return __(DST); }, timeZoneStandard: function () { var standard = { "LINT": "+1400", "TOT": "+1300", "CHAST": "+1245", "NZST": "+1200", "NFT": "+1130", "SBT": "+1100", "AEST": "+1000", "ACST": "+0930", "JST": "+0900", "CWST": "+0845", "CT": "+0800", "ICT": "+0700", "MMT": "+0630", "BST": "+0600", "NPT": "+0545", "IST": "+0530", "PKT": "+0500", "AFT": "+0430", "MSK": "+0400", "IRST": "+0330", "FET": "+0300", "EET": "+0200", "CET": "+0100", "GMT": "+0000", "UTC": "+0000", "CVT": "-0100", "GST": "-0200", "BRT": "-0300", "NST": "-0330", "AST": "-0400", "EST": "-0500", "CST": "-0600", "MST": "-0700", "PST": "-0800", "AKST": "-0900", "MIT": "-0930", "HST": "-1000", "SST": "-1100", "BIT": "-1200" }; return __(standard); }, timeZones: function (data) { var zone; data.timezones = []; for (zone in data.abbreviatedTimeZoneStandard) { if (data.abbreviatedTimeZoneStandard.hasOwnProperty(zone)) { data.timezones.push({ name: zone, offset: data.abbreviatedTimeZoneStandard[zone]}); } } for (zone in data.abbreviatedTimeZoneDST) { if (data.abbreviatedTimeZoneDST.hasOwnProperty(zone)) { data.timezones.push({ name: zone, offset: data.abbreviatedTimeZoneDST[zone], dst: true}); } } return data.timezones; }, days: function () { return __(["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"]); }, dayAbbr: function () { return __(["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"]); }, dayShortNames: function () { return __(["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"]); }, dayFirstLetters: function () { return __(["S_Sun_Initial", "M_Mon_Initial", "T_Tues_Initial", "W_Wed_Initial", "T_Thu_Initial", "F_Fri_Initial", "S_Sat_Initial"]); }, months: function () { return __(["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"]); }, monthAbbr: function () { return __(["Jan_Abbr", "Feb_Abbr", "Mar_Abbr", "Apr_Abbr", "May_Abbr", "Jun_Abbr", "Jul_Abbr", "Aug_Abbr", "Sep_Abbr", "Oct_Abbr", "Nov_Abbr", "Dec_Abbr"]); }, formatPatterns: function () { return getText.getFromObjectValues({ shortDate: "M/d/yyyy", longDate: "dddd, MMMM dd, yyyy", shortTime: "h:mm tt", longTime: "h:mm:ss tt", fullDateTime: "dddd, MMMM dd, yyyy h:mm:ss tt", sortableDateTime: "yyyy-MM-ddTHH:mm:ss", universalSortableDateTime: "yyyy-MM-dd HH:mm:ssZ", rfc1123: "ddd, dd MMM yyyy HH:mm:ss", monthDay: "MMMM dd", yearMonth: "MMMM, yyyy" }, Date.i18n.currentLanguage()); }, regex: function () { return getText.getFromObjectValues({ inTheMorning: "/( in the )(morn(ing)?)\\b/", thisMorning: "/(this )(morn(ing)?)\\b/", amThisMorning: "/(\b\\d(am)? )(this )(morn(ing)?)/", inTheEvening: "/( in the )(even(ing)?)\\b/", thisEvening: "/(this )(even(ing)?)\\b/", pmThisEvening: "/(\b\\d(pm)? )(this )(even(ing)?)/", jan: "/jan(uary)?/", feb: "/feb(ruary)?/", mar: "/mar(ch)?/", apr: "/apr(il)?/", may: "/may/", jun: "/jun(e)?/", jul: "/jul(y)?/", aug: "/aug(ust)?/", sep: "/sep(t(ember)?)?/", oct: "/oct(ober)?/", nov: "/nov(ember)?/", dec: "/dec(ember)?/", sun: "/^su(n(day)?)?/", mon: "/^mo(n(day)?)?/", tue: "/^tu(e(s(day)?)?)?/", wed: "/^we(d(nesday)?)?/", thu: "/^th(u(r(s(day)?)?)?)?/", fri: "/fr(i(day)?)?/", sat: "/^sa(t(urday)?)?/", future: "/^next/", past: "/^last|past|prev(ious)?/", add: "/^(\\+|aft(er)?|from|hence)/", subtract: "/^(\\-|bef(ore)?|ago)/", yesterday: "/^yes(terday)?/", today: "/^t(od(ay)?)?/", tomorrow: "/^tom(orrow)?/", now: "/^n(ow)?/", millisecond: "/^ms|milli(second)?s?/", second: "/^sec(ond)?s?/", minute: "/^mn|min(ute)?s?/", hour: "/^h(our)?s?/", week: "/^w(eek)?s?/", month: "/^m(onth)?s?/", day: "/^d(ay)?s?/", year: "/^y(ear)?s?/", shortMeridian: "/^(a|p)/", longMeridian: "/^(a\\.?m?\\.?|p\\.?m?\\.?)/", timezone: "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/", ordinalSuffix: "/^\\s*(st|nd|rd|th)/", timeContext: "/^\\s*(\\:|a(?!u|p)|p)/" }, Date.i18n.currentLanguage()); } }; var CultureInfo = function () { var info = getText.getFromObjectValues({ name: "name", englishName: "englishName", nativeName: "nativeName", amDesignator: "AM", pmDesignator: "PM", firstDayOfWeek: "firstDayOfWeek", twoDigitYearMax: "twoDigitYearMax", dateElementOrder: "mdy" }, Date.i18n.currentLanguage()); var constructedInfo = buildInfo.buildFromMethodHash({ dayNames: "days", abbreviatedDayNames: "dayAbbr", shortestDayNames: "dayShortNames", firstLetterDayNames: "dayFirstLetters", monthNames: "months", abbreviatedMonthNames: "monthAbbr", formatPatterns: "formatPatterns", regexPatterns: "regex", abbreviatedTimeZoneDST: "timeZoneDST", abbreviatedTimeZoneStandard: "timeZoneStandard" }); shallowMerge(info, constructedInfo); buildInfo.timeZones(info); return info; }; $D.i18n = { __: function (key, lang) { return __(key, lang); }, currentLanguage: function () { return lang || "en-US"; }, setLanguage: function (code, force, cb) { var async = false; if (force || code === "en-US" || (!!Date.CultureStrings && !!Date.CultureStrings[code])) { lang = code; Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings.lang = code; Date.CultureInfo = new CultureInfo(); } else { if (!(!!Date.CultureStrings && !!Date.CultureStrings[code])) { if (typeof exports !== "undefined" && this.exports !== exports) { // we're in a Node enviroment, load it using require try { require("../i18n/" + code + ".js"); lang = code; Date.CultureStrings.lang = code; Date.CultureInfo = new CultureInfo(); } catch (e) { // var str = "The language for '" + code + "' could not be loaded by Node. It likely does not exist."; throw new Error("The DateJS IETF language tag '" + code + "' could not be loaded by Node. It likely does not exist."); } } else if (Date.Config && Date.Config.i18n) { // we know the location of the files, so lets load them async = true; loadI18nScript(code).done(function(){ lang = code; Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings.lang = code; Date.CultureInfo = new CultureInfo(); $D.Parsing.Normalizer.buildReplaceData(); // because this is async if ($D.Grammar) { $D.Grammar.buildGrammarFormats(); // so we can parse those strings... } if (cb) { setTimeout(cb,0); } }); } else { Date.console.error("The DateJS IETF language tag '" + code + "' is not available and has not been loaded."); return false; } } } $D.Parsing.Normalizer.buildReplaceData(); // rebuild normalizer strings if ($D.Grammar) { $D.Grammar.buildGrammarFormats(); // so we can parse those strings... } if (!async && cb) { setTimeout(cb,0); } }, getLoggedKeys: function () { return loggedKeys; }, updateCultureInfo: function () { Date.CultureInfo = new CultureInfo(); } }; $D.i18n.updateCultureInfo(); // run automatically }()); (function () { var $D = Date, $P = $D.prototype, p = function (s, l) { if (!l) { l = 2; } return ("000" + s).slice(l * -1); }; if (typeof window !== "undefined" && typeof window.console !== "undefined" && typeof window.console.log !== "undefined") { $D.console = console; // used only to raise non-critical errors if available } else { // set mock so we don't give errors. $D.console = { log: function(){}, error: function(){} }; } $D.Config = $D.Config || {}; $D.initOverloads = function() { /** * Overload of Date.now. Allows an alternate call for Date.now where it returns the * current Date as an object rather than just milliseconds since the Unix Epoch. * * Also provides an implementation of now() for browsers (IE<9) that don't have it. * * Backwards compatible so with work with either: * Date.now() [returns ms] * or * Date.now(true) [returns Date] */ if (!$D.now) { $D._now = function now() { return new Date().getTime(); }; } else if (!$D._now) { $D._now = $D.now; } $D.now = function (returnObj) { if (returnObj) { return $D.present(); } else { return $D._now(); } }; if ( !$P.toISOString ) { $P.toISOString = function() { return this.getUTCFullYear() + "-" + p(this.getUTCMonth() + 1) + "-" + p(this.getUTCDate()) + "T" + p(this.getUTCHours()) + ":" + p(this.getUTCMinutes()) + ":" + p(this.getUTCSeconds()) + "." + String( (this.getUTCMilliseconds()/1000).toFixed(3)).slice(2, 5) + "Z"; }; } // private if ( $P._toString === undefined ){ $P._toString = $P.toString; } }; $D.initOverloads(); /** * Gets a date that is set to the current date. The time is set to the start of the day (00:00 or 12:00 AM). * @return {Date} The current date. */ $D.today = function () { return new Date().clearTime(); }; /** * Gets a date that is set to the current date and time (same as new Date, but chainable) * @return {Date} The current date. */ $D.present = function () { return new Date(); }; /** * Compares the first date to the second date and returns an number indication of their relative values. * @param {Date} First Date object to compare [Required]. * @param {Date} Second Date object to compare to [Required]. * @return {Number} -1 = date1 is lessthan date2. 0 = values are equal. 1 = date1 is greaterthan date2. */ $D.compare = function (date1, date2) { if (isNaN(date1) || isNaN(date2)) { throw new Error(date1 + " - " + date2); } else if (date1 instanceof Date && date2 instanceof Date) { return (date1 < date2) ? -1 : (date1 > date2) ? 1 : 0; } else { throw new TypeError(date1 + " - " + date2); } }; /** * Compares the first Date object to the second Date object and returns true if they are equal. * @param {Date} First Date object to compare [Required] * @param {Date} Second Date object to compare to [Required] * @return {Boolean} true if dates are equal. false if they are not equal. */ $D.equals = function (date1, date2) { return (date1.compareTo(date2) === 0); }; /** * Gets the language appropriate day name when given the day number(0-6) * eg - 0 == Sunday * @return {String} The day name */ $D.getDayName = function (n) { return Date.CultureInfo.dayNames[n]; }; /** * Gets the day number (0-6) if given a CultureInfo specific string which is a valid dayName, abbreviatedDayName or shortestDayName (two char). * @param {String} The name of the day (eg. "Monday, "Mon", "tuesday", "tue", "We", "we"). * @return {Number} The day number */ $D.getDayNumberFromName = function (name) { var n = Date.CultureInfo.dayNames, m = Date.CultureInfo.abbreviatedDayNames, o = Date.CultureInfo.shortestDayNames, s = name.toLowerCase(); for (var i = 0; i < n.length; i++) { if (n[i].toLowerCase() === s || m[i].toLowerCase() === s || o[i].toLowerCase() === s) { return i; } } return -1; }; /** * Gets the month number (0-11) if given a Culture Info specific string which is a valid monthName or abbreviatedMonthName. * @param {String} The name of the month (eg. "February, "Feb", "october", "oct"). * @return {Number} The day number */ $D.getMonthNumberFromName = function (name) { var n = Date.CultureInfo.monthNames, m = Date.CultureInfo.abbreviatedMonthNames, s = name.toLowerCase(); for (var i = 0; i < n.length; i++) { if (n[i].toLowerCase() === s || m[i].toLowerCase() === s) { return i; } } return -1; }; /** * Gets the language appropriate month name when given the month number(0-11) * eg - 0 == January * @return {String} The month name */ $D.getMonthName = function (n) { return Date.CultureInfo.monthNames[n]; }; /** * Determines if the current date instance is within a LeapYear. * @param {Number} The year. * @return {Boolean} true if date is within a LeapYear, otherwise false. */ $D.isLeapYear = function (year) { return ((year % 4 === 0 && year % 100 !== 0) || year % 400 === 0); }; /** * Gets the number of days in the month, given a year and month value. Automatically corrects for LeapYear. * @param {Number} The year. * @param {Number} The month (0-11). * @return {Number} The number of days in the month. */ $D.getDaysInMonth = function (year, month) { if (!month && $D.validateMonth(year)) { month = year; year = Date.today().getFullYear(); } return [31, ($D.isLeapYear(year) ? 29 : 28), 31, 30, 31, 30, 31, 31, 30, 31, 30, 31][month]; }; $P.getDaysInMonth = function () { return $D.getDaysInMonth(this.getFullYear(), this.getMonth()); }; $D.getTimezoneAbbreviation = function (offset, dst) { var p, n = (dst || false) ? Date.CultureInfo.abbreviatedTimeZoneDST : Date.CultureInfo.abbreviatedTimeZoneStandard; for (p in n) { if (n.hasOwnProperty(p)) { if (n[p] === offset) { return p; } } } return null; }; $D.getTimezoneOffset = function (name, dst) { var i, a =[], z = Date.CultureInfo.timezones; if (!name) { name = (new Date()).getTimezone();} for (i = 0; i < z.length; i++) { if (z[i].name === name.toUpperCase()) { a.push(i); } } if (!z[a[0]]) { return null; } if (a.length === 1 || !dst) { return z[a[0]].offset; } else { for (i=0; i < a.length; i++) { if (z[a[i]].dst) { return z[a[i]].offset; } } } }; $D.getQuarter = function (d) { d = d || new Date(); // If no date supplied, use today var q = [1,2,3,4]; return q[Math.floor(d.getMonth() / 3)]; // ~~~ is a bitwise op. Faster than Math.floor }; $D.getDaysLeftInQuarter = function (d) { d = d || new Date(); var qEnd = new Date(d); qEnd.setMonth(qEnd.getMonth() + 3 - qEnd.getMonth() % 3, 0); return Math.floor((qEnd - d) / 8.64e7); }; // private var validate = function (n, min, max, name) { name = name ? name : "Object"; if (typeof n === "undefined") { return false; } else if (typeof n !== "number") { throw new TypeError(n + " is not a Number."); } else if (n < min || n > max) { // As failing validation is *not* an exceptional circumstance // lets not throw a RangeError Exception here. // It's semantically correct but it's not sensible. return false; } return true; }; /** * Validates the number is within an acceptable range for milliseconds [0-999]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateMillisecond = function (value) { return validate(value, 0, 999, "millisecond"); }; /** * Validates the number is within an acceptable range for seconds [0-59]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateSecond = function (value) { return validate(value, 0, 59, "second"); }; /** * Validates the number is within an acceptable range for minutes [0-59]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateMinute = function (value) { return validate(value, 0, 59, "minute"); }; /** * Validates the number is within an acceptable range for hours [0-23]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateHour = function (value) { return validate(value, 0, 23, "hour"); }; /** * Validates the number is within an acceptable range for the days in a month [0-MaxDaysInMonth]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateDay = function (value, year, month) { if (year === undefined || year === null || month === undefined || month === null) { return false;} return validate(value, 1, $D.getDaysInMonth(year, month), "day"); }; /** * Validates the number is within an acceptable range for months [0-11]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateWeek = function (value) { return validate(value, 0, 53, "week"); }; /** * Validates the number is within an acceptable range for months [0-11]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateMonth = function (value) { return validate(value, 0, 11, "month"); }; /** * Validates the number is within an acceptable range for years. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateYear = function (value) { /** * Per ECMAScript spec the range of times supported by Date objects is * exactly -100,000,000 days to +100,000,000 days measured relative to * midnight at the beginning of 01 January, 1970 UTC. * This gives a range of 8,640,000,000,000,000 milliseconds to either * side of 01 January, 1970 UTC. * * Earliest possible date: Tue, 20 Apr 271,822 B.C. 00:00:00 UTC * Latest possible date: Sat, 13 Sep 275,760 00:00:00 UTC */ return validate(value, -271822, 275760, "year"); }; $D.validateTimezone = function(value) { var timezones = {"ACDT":1,"ACST":1,"ACT":1,"ADT":1,"AEDT":1,"AEST":1,"AFT":1,"AKDT":1,"AKST":1,"AMST":1,"AMT":1,"ART":1,"AST":1,"AWDT":1,"AWST":1,"AZOST":1,"AZT":1,"BDT":1,"BIOT":1,"BIT":1,"BOT":1,"BRT":1,"BST":1,"BTT":1,"CAT":1,"CCT":1,"CDT":1,"CEDT":1,"CEST":1,"CET":1,"CHADT":1,"CHAST":1,"CHOT":1,"ChST":1,"CHUT":1,"CIST":1,"CIT":1,"CKT":1,"CLST":1,"CLT":1,"COST":1,"COT":1,"CST":1,"CT":1,"CVT":1,"CWST":1,"CXT":1,"DAVT":1,"DDUT":1,"DFT":1,"EASST":1,"EAST":1,"EAT":1,"ECT":1,"EDT":1,"EEDT":1,"EEST":1,"EET":1,"EGST":1,"EGT":1,"EIT":1,"EST":1,"FET":1,"FJT":1,"FKST":1,"FKT":1,"FNT":1,"GALT":1,"GAMT":1,"GET":1,"GFT":1,"GILT":1,"GIT":1,"GMT":1,"GST":1,"GYT":1,"HADT":1,"HAEC":1,"HAST":1,"HKT":1,"HMT":1,"HOVT":1,"HST":1,"ICT":1,"IDT":1,"IOT":1,"IRDT":1,"IRKT":1,"IRST":1,"IST":1,"JST":1,"KGT":1,"KOST":1,"KRAT":1,"KST":1,"LHST":1,"LINT":1,"MAGT":1,"MART":1,"MAWT":1,"MDT":1,"MET":1,"MEST":1,"MHT":1,"MIST":1,"MIT":1,"MMT":1,"MSK":1,"MST":1,"MUT":1,"MVT":1,"MYT":1,"NCT":1,"NDT":1,"NFT":1,"NPT":1,"NST":1,"NT":1,"NUT":1,"NZDT":1,"NZST":1,"OMST":1,"ORAT":1,"PDT":1,"PET":1,"PETT":1,"PGT":1,"PHOT":1,"PHT":1,"PKT":1,"PMDT":1,"PMST":1,"PONT":1,"PST":1,"PYST":1,"PYT":1,"RET":1,"ROTT":1,"SAKT":1,"SAMT":1,"SAST":1,"SBT":1,"SCT":1,"SGT":1,"SLST":1,"SRT":1,"SST":1,"SYOT":1,"TAHT":1,"THA":1,"TFT":1,"TJT":1,"TKT":1,"TLT":1,"TMT":1,"TOT":1,"TVT":1,"UCT":1,"ULAT":1,"UTC":1,"UYST":1,"UYT":1,"UZT":1,"VET":1,"VLAT":1,"VOLT":1,"VOST":1,"VUT":1,"WAKT":1,"WAST":1,"WAT":1,"WEDT":1,"WEST":1,"WET":1,"WST":1,"YAKT":1,"YEKT":1,"Z":1}; return (timezones[value] === 1); }; $D.validateTimezoneOffset= function(value) { // timezones go from +14hrs to -12hrs, the +X hours are negative offsets. return (value > -841 && value < 721); }; }()); (function () { var $D = Date, $P = $D.prototype, p = function (s, l) { if (!l) { l = 2; } return ("000" + s).slice(l * -1); }; var validateConfigObject = function (obj) { var result = {}, self = this, prop, testFunc; testFunc = function (prop, func, value) { if (prop === "day") { var month = (obj.month !== undefined) ? obj.month : self.getMonth(); var year = (obj.year !== undefined) ? obj.year : self.getFullYear(); return $D[func](value, year, month); } else { return $D[func](value); } }; for (prop in obj) { if (Object.prototype.hasOwnProperty.call(obj, prop)) { var func = "validate" + prop.charAt(0).toUpperCase() + prop.slice(1); if ($D[func] && obj[prop] !== null && testFunc(prop, func, obj[prop])) { result[prop] = obj[prop]; } } } return result; }; /** * Resets the time of this Date object to 12:00 AM (00:00), which is the start of the day. * @param {Boolean} .clone() this date instance before clearing Time * @return {Date} this */ $P.clearTime = function () { this.setHours(0); this.setMinutes(0); this.setSeconds(0); this.setMilliseconds(0); return this; }; /** * Resets the time of this Date object to the current time ('now'). * @return {Date} this */ $P.setTimeToNow = function () { var n = new Date(); this.setHours(n.getHours()); this.setMinutes(n.getMinutes()); this.setSeconds(n.getSeconds()); this.setMilliseconds(n.getMilliseconds()); return this; }; /** * Returns a new Date object that is an exact date and time copy of the original instance. * @return {Date} A new Date instance */ $P.clone = function () { return new Date(this.getTime()); }; /** * Compares this instance to a Date object and returns an number indication of their relative values. * @param {Date} Date object to compare [Required] * @return {Number} -1 = this is lessthan date. 0 = values are equal. 1 = this is greaterthan date. */ $P.compareTo = function (date) { return Date.compare(this, date); }; /** * Compares this instance to another Date object and returns true if they are equal. * @param {Date} Date object to compare. If no date to compare, new Date() [now] is used. * @return {Boolean} true if dates are equal. false if they are not equal. */ $P.equals = function (date) { return Date.equals(this, (date !== undefined ? date : new Date())); }; /** * Determines if this instance is between a range of two dates or equal to either the start or end dates. * @param {Date} Start of range [Required] * @param {Date} End of range [Required] * @return {Boolean} true is this is between or equal to the start and end dates, else false */ $P.between = function (start, end) { return this.getTime() >= start.getTime() && this.getTime() <= end.getTime(); }; /** * Determines if this date occurs after the date to compare to. * @param {Date} Date object to compare. If no date to compare, new Date() ("now") is used. * @return {Boolean} true if this date instance is greater than the date to compare to (or "now"), otherwise false. */ $P.isAfter = function (date) { return this.compareTo(date || new Date()) === 1; }; /** * Determines if this date occurs before the date to compare to. * @param {Date} Date object to compare. If no date to compare, new Date() ("now") is used. * @return {Boolean} true if this date instance is less than the date to compare to (or "now"). */ $P.isBefore = function (date) { return (this.compareTo(date || new Date()) === -1); }; /** * Determines if the current Date instance occurs today. * @return {Boolean} true if this date instance is 'today', otherwise false. */ /** * Determines if the current Date instance occurs on the same Date as the supplied 'date'. * If no 'date' to compare to is provided, the current Date instance is compared to 'today'. * @param {date} Date object to compare. If no date to compare, the current Date ("now") is used. * @return {Boolean} true if this Date instance occurs on the same Day as the supplied 'date'. */ $P.isToday = $P.isSameDay = function (date) { return this.clone().clearTime().equals((date || new Date()).clone().clearTime()); }; /** * Adds the specified number of milliseconds to this instance. * @param {Number} The number of milliseconds to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addMilliseconds = function (value) { if (!value) { return this; } this.setTime(this.getTime() + value * 1); return this; }; /** * Adds the specified number of seconds to this instance. * @param {Number} The number of seconds to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addSeconds = function (value) { if (!value) { return this; } return this.addMilliseconds(value * 1000); }; /** * Adds the specified number of seconds to this instance. * @param {Number} The number of seconds to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addMinutes = function (value) { if (!value) { return this; } return this.addMilliseconds(value * 60000); // 60*1000 }; /** * Adds the specified number of hours to this instance. * @param {Number} The number of hours to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addHours = function (value) { if (!value) { return this; } return this.addMilliseconds(value * 3600000); // 60*60*1000 }; /** * Adds the specified number of days to this instance. * @param {Number} The number of days to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addDays = function (value) { if (!value) { return this; } this.setDate(this.getDate() + value * 1); return this; }; /** * Adds the specified number of weekdays (ie - not sat or sun) to this instance. * @param {Number} The number of days to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addWeekdays = function (value) { if (!value) { return this; } var day = this.getDay(); var weeks = (Math.ceil(Math.abs(value)/7)); if (day === 0 || day === 6) { if (value > 0) { this.next().monday(); this.addDays(-1); day = this.getDay(); } } if (value < 0) { while (value < 0) { this.addDays(-1); day = this.getDay(); if (day !== 0 && day !== 6) { value++; } } return this; } else if (value > 5 || (6-day) <= value) { value = value + (weeks * 2); } return this.addDays(value); }; /** * Adds the specified number of weeks to this instance. * @param {Number} The number of weeks to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addWeeks = function (value) { if (!value) { return this; } return this.addDays(value * 7); }; /** * Adds the specified number of months to this instance. * @param {Number} The number of months to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addMonths = function (value) { if (!value) { return this; } var n = this.getDate(); this.setDate(1); this.setMonth(this.getMonth() + value * 1); this.setDate(Math.min(n, $D.getDaysInMonth(this.getFullYear(), this.getMonth()))); return this; }; $P.addQuarters = function (value) { if (!value) { return this; } // note this will take you to the same point in the quarter as you are now. // i.e. - if you are 15 days into the quarter you'll be 15 days into the resulting one. // bonus: this allows adding fractional quarters return this.addMonths(value * 3); }; /** * Adds the specified number of years to this instance. * @param {Number} The number of years to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addYears = function (value) { if (!value) { return this; } return this.addMonths(value * 12); }; /** * Adds (or subtracts) to the value of the years, months, weeks, days, hours, minutes, seconds, milliseconds of the date instance using given configuration object. Positive and Negative values allowed. * Example

	Date.today().add( { days: 1, months: 1 } )

	new Date().add( { years: -1 } )
	
* @param {Object} Configuration object containing attributes (months, days, etc.) * @return {Date} this */ $P.add = function (config) { if (typeof config === "number") { this._orient = config; return this; } var x = config; if (x.day) { // If we should be a different date than today (eg: for 'tomorrow -1d', etc). // Should only effect parsing, not direct usage (eg, Finish and FinishExact) if ((x.day - this.getDate()) !== 0) { this.setDate(x.day); } } if (x.milliseconds) { this.addMilliseconds(x.milliseconds); } if (x.seconds) { this.addSeconds(x.seconds); } if (x.minutes) { this.addMinutes(x.minutes); } if (x.hours) { this.addHours(x.hours); } if (x.weeks) { this.addWeeks(x.weeks); } if (x.months) { this.addMonths(x.months); } if (x.years) { this.addYears(x.years); } if (x.days) { this.addDays(x.days); } return this; }; /** * Get the week number. Week one (1) is the week which contains the first Thursday of the year. Monday is considered the first day of the week. * The .getWeek() function does NOT convert the date to UTC. The local datetime is used. * Please use .getISOWeek() to get the week of the UTC converted date. * @return {Number} 1 to 53 */ $P.getWeek = function (utc) { // Create a copy of this date object var self, target = new Date(this.valueOf()); if (utc) { target.addMinutes(target.getTimezoneOffset()); self = target.clone(); } else { self = this; } // ISO week date weeks start on monday // so correct the day number var dayNr = (self.getDay() + 6) % 7; // ISO 8601 states that week 1 is the week // with the first thursday of that year. // Set the target date to the thursday in the target week target.setDate(target.getDate() - dayNr + 3); // Store the millisecond value of the target date var firstThursday = target.valueOf(); // Set the target to the first thursday of the year // First set the target to january first target.setMonth(0, 1); // Not a thursday? Correct the date to the next thursday if (target.getDay() !== 4) { target.setMonth(0, 1 + ((4 - target.getDay()) + 7) % 7); } // The weeknumber is the number of weeks between the // first thursday of the year and the thursday in the target week return 1 + Math.ceil((firstThursday - target) / 604800000); // 604800000 = 7 * 24 * 3600 * 1000 }; /** * Get the ISO 8601 week number. Week one ("01") is the week which contains the first Thursday of the year. Monday is considered the first day of the week. * The .getISOWeek() function does convert the date to it's UTC value. Please use .getWeek() to get the week of the local date. * @return {String} "01" to "53" */ $P.getISOWeek = function () { return p(this.getWeek(true)); }; /** * Moves the date to Monday of the week set. Week one (1) is the week which contains the first Thursday of the year. * @param {Number} A Number (1 to 53) that represents the week of the year. * @return {Date} this */ $P.setWeek = function (n) { if ((n - this.getWeek()) === 0) { if (this.getDay() !== 1) { return this.moveToDayOfWeek(1, (this.getDay() > 1 ? -1 : 1)); } else { return this; } } else { return this.moveToDayOfWeek(1, (this.getDay() > 1 ? -1 : 1)).addWeeks(n - this.getWeek()); } }; $P.setQuarter = function (qtr) { var month = Math.abs(((qtr-1) * 3) + 1); return this.setMonth(month, 1); }; $P.getQuarter = function () { return Date.getQuarter(this); }; $P.getDaysLeftInQuarter = function () { return Date.getDaysLeftInQuarter(this); }; /** * Moves the date to the next n'th occurrence of the dayOfWeek starting from the beginning of the month. The number (-1) is a magic number and will return the last occurrence of the dayOfWeek in the month. * @param {Number} The dayOfWeek to move to * @param {Number} The n'th occurrence to move to. Use (-1) to return the last occurrence in the month * @return {Date} this */ $P.moveToNthOccurrence = function (dayOfWeek, occurrence) { if (dayOfWeek === "Weekday") { if (occurrence > 0) { this.moveToFirstDayOfMonth(); if (this.is().weekday()) { occurrence -= 1; } } else if (occurrence < 0) { this.moveToLastDayOfMonth(); if (this.is().weekday()) { occurrence += 1; } } else { return this; } return this.addWeekdays(occurrence); } var shift = 0; if (occurrence > 0) { shift = occurrence - 1; } else if (occurrence === -1) { this.moveToLastDayOfMonth(); if (this.getDay() !== dayOfWeek) { this.moveToDayOfWeek(dayOfWeek, -1); } return this; } return this.moveToFirstDayOfMonth().addDays(-1).moveToDayOfWeek(dayOfWeek, +1).addWeeks(shift); }; var moveToN = function (getFunc, addFunc, nVal) { return function (value, orient) { var diff = (value - this[getFunc]() + nVal * (orient || +1)) % nVal; return this[addFunc]((diff === 0) ? diff += nVal * (orient || +1) : diff); }; }; /** * Move to the next or last dayOfWeek based on the orient value. * @param {Number} The dayOfWeek to move to * @param {Number} Forward (+1) or Back (-1). Defaults to +1. [Optional] * @return {Date} this */ $P.moveToDayOfWeek = moveToN("getDay", "addDays", 7); /** * Move to the next or last month based on the orient value. * @param {Number} The month to move to. 0 = January, 11 = December * @param {Number} Forward (+1) or Back (-1). Defaults to +1. [Optional] * @return {Date} this */ $P.moveToMonth = moveToN("getMonth", "addMonths", 12); /** * Get the Ordinate of the current day ("th", "st", "rd"). * @return {String} */ $P.getOrdinate = function () { var num = this.getDate(); return ord(num); }; /** * Get the Ordinal day (numeric day number) of the year, adjusted for leap year. * @return {Number} 1 through 365 (366 in leap years) */ $P.getOrdinalNumber = function () { return Math.ceil((this.clone().clearTime() - new Date(this.getFullYear(), 0, 1)) / 86400000) + 1; }; /** * Get the time zone abbreviation of the current date. * @return {String} The abbreviated time zone name (e.g. "EST") */ $P.getTimezone = function () { return $D.getTimezoneAbbreviation(this.getUTCOffset(), this.isDaylightSavingTime()); }; $P.setTimezoneOffset = function (offset) { var here = this.getTimezoneOffset(), there = Number(offset) * -6 / 10; return (there || there === 0) ? this.addMinutes(there - here) : this; }; $P.setTimezone = function (offset) { return this.setTimezoneOffset($D.getTimezoneOffset(offset)); }; /** * Indicates whether Daylight Saving Time is observed in the current time zone. * @return {Boolean} true|false */ $P.hasDaylightSavingTime = function () { return (Date.today().set({month: 0, day: 1}).getTimezoneOffset() !== Date.today().set({month: 6, day: 1}).getTimezoneOffset()); }; /** * Indicates whether this Date instance is within the Daylight Saving Time range for the current time zone. * @return {Boolean} true|false */ $P.isDaylightSavingTime = function () { return Date.today().set({month: 0, day: 1}).getTimezoneOffset() !== this.getTimezoneOffset(); }; /** * Get the offset from UTC of the current date. * @return {String} The 4-character offset string prefixed with + or - (e.g. "-0500") */ $P.getUTCOffset = function (offset) { var n = (offset || this.getTimezoneOffset()) * -10 / 6, r; if (n < 0) { r = (n - 10000).toString(); return r.charAt(0) + r.substr(2); } else { r = (n + 10000).toString(); return "+" + r.substr(1); } }; /** * Returns the number of milliseconds between this date and date. * @param {Date} Defaults to now * @return {Number} The diff in milliseconds */ $P.getElapsed = function (date) { return (date || new Date()) - this; }; /** * Set the value of year, month, day, hour, minute, second, millisecond of date instance using given configuration object. * Example

	Date.today().set( { day: 20, month: 1 } )

	new Date().set( { millisecond: 0 } )
	
* * @param {Object} Configuration object containing attributes (month, day, etc.) * @return {Date} this */ $P.set = function (config) { config = validateConfigObject.call(this, config); var key; for (key in config) { if (Object.prototype.hasOwnProperty.call(config, key)) { var name = key.charAt(0).toUpperCase() + key.slice(1); var addFunc, getFunc; if (key !== "week" && key !== "month" && key !== "timezone" && key !== "timezoneOffset") { name += "s"; } addFunc = "add" + name; getFunc = "get" + name; if (key === "month") { addFunc = addFunc + "s"; } else if (key === "year"){ getFunc = "getFullYear"; } if (key !== "day" && key !== "timezone" && key !== "timezoneOffset" && key !== "week" && key !== "hour") { this[addFunc](config[key] - this[getFunc]()); } else if ( key === "timezone"|| key === "timezoneOffset" || key === "week" || key === "hour") { this["set"+name](config[key]); } } } // day has to go last because you can't validate the day without first knowing the month if (config.day) { this.addDays(config.day - this.getDate()); } return this; }; /** * Moves the date to the first day of the month. * @return {Date} this */ $P.moveToFirstDayOfMonth = function () { return this.set({ day: 1 }); }; /** * Moves the date to the last day of the month. * @return {Date} this */ $P.moveToLastDayOfMonth = function () { return this.set({ day: $D.getDaysInMonth(this.getFullYear(), this.getMonth())}); }; /** * Converts the value of the current Date object to its equivalent string representation. * Format Specifiers * CUSTOM DATE AND TIME FORMAT STRINGS * Format Description Example * ------ --------------------------------------------------------------------------- ----------------------- * s The seconds of the minute between 0-59. "0" to "59" * ss The seconds of the minute with leading zero if required. "00" to "59" * * m The minute of the hour between 0-59. "0" or "59" * mm The minute of the hour with leading zero if required. "00" or "59" * * h The hour of the day between 1-12. "1" to "12" * hh The hour of the day with leading zero if required. "01" to "12" * * H The hour of the day between 0-23. "0" to "23" * HH The hour of the day with leading zero if required. "00" to "23" * * d The day of the month between 1 and 31. "1" to "31" * dd The day of the month with leading zero if required. "01" to "31" * ddd Abbreviated day name. Date.CultureInfo.abbreviatedDayNames. "Mon" to "Sun" * dddd The full day name. Date.CultureInfo.dayNames. "Monday" to "Sunday" * * M The month of the year between 1-12. "1" to "12" * MM The month of the year with leading zero if required. "01" to "12" * MMM Abbreviated month name. Date.CultureInfo.abbreviatedMonthNames. "Jan" to "Dec" * MMMM The full month name. Date.CultureInfo.monthNames. "January" to "December" * * yy The year as a two-digit number. "99" or "08" * yyyy The full four digit year. "1999" or "2008" * * t Displays the first character of the A.M./P.M. designator. "A" or "P" * Date.CultureInfo.amDesignator or Date.CultureInfo.pmDesignator * tt Displays the A.M./P.M. designator. "AM" or "PM" * Date.CultureInfo.amDesignator or Date.CultureInfo.pmDesignator * * S The ordinal suffix ("st, "nd", "rd" or "th") of the current day. "st, "nd", "rd" or "th" * * STANDARD DATE AND TIME FORMAT STRINGS * Format Description Example *------ --------------------------------------------------------------------------- ----------------------- * d The CultureInfo shortDate Format Pattern "M/d/yyyy" * D The CultureInfo longDate Format Pattern "dddd, MMMM dd, yyyy" * F The CultureInfo fullDateTime Format Pattern "dddd, MMMM dd, yyyy h:mm:ss tt" * m The CultureInfo monthDay Format Pattern "MMMM dd" * r The CultureInfo rfc1123 Format Pattern "ddd, dd MMM yyyy HH:mm:ss GMT" * s The CultureInfo sortableDateTime Format Pattern "yyyy-MM-ddTHH:mm:ss" * t The CultureInfo shortTime Format Pattern "h:mm tt" * T The CultureInfo longTime Format Pattern "h:mm:ss tt" * u The CultureInfo universalSortableDateTime Format Pattern "yyyy-MM-dd HH:mm:ssZ" * y The CultureInfo yearMonth Format Pattern "MMMM, yyyy" * * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @return {String} A string representation of the current Date object. */ var ord = function (n) { switch (n * 1) { case 1: case 21: case 31: return "st"; case 2: case 22: return "nd"; case 3: case 23: return "rd"; default: return "th"; } }; var parseStandardFormats = function (format) { var y, c = Date.CultureInfo.formatPatterns; switch (format) { case "d": return this.toString(c.shortDate); case "D": return this.toString(c.longDate); case "F": return this.toString(c.fullDateTime); case "m": return this.toString(c.monthDay); case "r": case "R": y = this.clone().addMinutes(this.getTimezoneOffset()); return y.toString(c.rfc1123) + " GMT"; case "s": return this.toString(c.sortableDateTime); case "t": return this.toString(c.shortTime); case "T": return this.toString(c.longTime); case "u": y = this.clone().addMinutes(this.getTimezoneOffset()); return y.toString(c.universalSortableDateTime); case "y": return this.toString(c.yearMonth); default: return false; } }; var parseFormatStringsClosure = function (context) { return function (m) { if (m.charAt(0) === "\\") { return m.replace("\\", ""); } switch (m) { case "hh": return p(context.getHours() < 13 ? (context.getHours() === 0 ? 12 : context.getHours()) : (context.getHours() - 12)); case "h": return context.getHours() < 13 ? (context.getHours() === 0 ? 12 : context.getHours()) : (context.getHours() - 12); case "HH": return p(context.getHours()); case "H": return context.getHours(); case "mm": return p(context.getMinutes()); case "m": return context.getMinutes(); case "ss": return p(context.getSeconds()); case "s": return context.getSeconds(); case "yyyy": return p(context.getFullYear(), 4); case "yy": return p(context.getFullYear()); case "y": return context.getFullYear(); case "E": case "dddd": return Date.CultureInfo.dayNames[context.getDay()]; case "ddd": return Date.CultureInfo.abbreviatedDayNames[context.getDay()]; case "dd": return p(context.getDate()); case "d": return context.getDate(); case "MMMM": return Date.CultureInfo.monthNames[context.getMonth()]; case "MMM": return Date.CultureInfo.abbreviatedMonthNames[context.getMonth()]; case "MM": return p((context.getMonth() + 1)); case "M": return context.getMonth() + 1; case "t": return context.getHours() < 12 ? Date.CultureInfo.amDesignator.substring(0, 1) : Date.CultureInfo.pmDesignator.substring(0, 1); case "tt": return context.getHours() < 12 ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator; case "S": return ord(context.getDate()); case "W": return context.getWeek(); case "WW": return context.getISOWeek(); case "Q": return "Q" + context.getQuarter(); case "q": return String(context.getQuarter()); case "z": return context.getTimezone(); case "Z": case "X": return Date.getTimezoneOffset(context.getTimezone()); case "ZZ": // Timezone offset in seconds return context.getTimezoneOffset() * -60; case "u": return context.getDay(); case "L": return ($D.isLeapYear(context.getFullYear())) ? 1 : 0; case "B": // Swatch Internet Time (.beats) return "@"+((context.getUTCSeconds() + (context.getUTCMinutes()*60) + ((context.getUTCHours()+1)*3600))/86.4); default: return m; } }; }; $P.toString = function (format, ignoreStandards) { // Standard Date and Time Format Strings. Formats pulled from CultureInfo file and // may vary by culture. if (!ignoreStandards && format && format.length === 1) { output = parseStandardFormats.call(this, format); if (output) { return output; } } var parseFormatStrings = parseFormatStringsClosure(this); return format ? format.replace(/((\\)?(dd?d?d?|MM?M?M?|yy?y?y?|hh?|HH?|mm?|ss?|tt?|S|q|Q|WW?W?W?)(?![^\[]*\]))/g, parseFormatStrings).replace(/\[|\]/g, "") : this._toString(); }; }()); /************************************************************* * SugarPak - Domain Specific Language - Syntactical Sugar * *************************************************************/ (function () { var $D = Date, $P = $D.prototype, $N = Number.prototype; // private $P._orient = +1; // private $P._nth = null; // private $P._is = false; // private $P._same = false; // private $P._isSecond = false; // private $N._dateElement = "days"; /** * Moves the date to the next instance of a date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.today().next().friday();
	Date.today().next().fri();
	Date.today().next().march();
	Date.today().next().mar();
	Date.today().next().week();
	
* * @return {Date} date */ $P.next = function () { this._move = true; this._orient = +1; return this; }; /** * Creates a new Date (Date.today()) and moves the date to the next instance of the date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.next().friday();
	Date.next().fri();
	Date.next().march();
	Date.next().mar();
	Date.next().week();
	
* * @return {Date} date */ $D.next = function () { return $D.today().next(); }; /** * Moves the date to the previous instance of a date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.today().last().friday();
	Date.today().last().fri();
	Date.today().last().march();
	Date.today().last().mar();
	Date.today().last().week();
	
* * @return {Date} date */ $P.last = $P.prev = $P.previous = function () { this._move = true; this._orient = -1; return this; }; /** * Creates a new Date (Date.today()) and moves the date to the previous instance of the date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.last().friday();
	Date.last().fri();
	Date.previous().march();
	Date.prev().mar();
	Date.last().week();
	
* * @return {Date} date */ $D.last = $D.prev = $D.previous = function () { return $D.today().last(); }; /** * Performs a equality check when followed by either a month name, day name or .weekday() function. * Example

	Date.today().is().friday(); // true|false
	Date.today().is().fri();
	Date.today().is().march();
	Date.today().is().mar();
	
* * @return {Boolean} true|false */ $P.is = function () { this._is = true; return this; }; /** * Determines if two date objects occur on/in exactly the same instance of the subsequent date part function. * The function .same() must be followed by a date part function (example: .day(), .month(), .year(), etc). * * An optional Date can be passed in the date part function. If now date is passed as a parameter, 'Now' is used. * * The following example demonstrates how to determine if two dates fall on the exact same day. * * Example

	var d1 = Date.today(); // today at 00:00
	var d2 = new Date();   // exactly now.

	// Do they occur on the same day?
	d1.same().day(d2); // true
	
	// Do they occur on the same hour?
	d1.same().hour(d2); // false, unless d2 hour is '00' (midnight).
	
	// What if it's the same day, but one year apart?
	var nextYear = Date.today().add(1).year();

	d1.same().day(nextYear); // false, because the dates must occur on the exact same day. 
	
* * Scenario: Determine if a given date occurs during some week period 2 months from now. * * Example

	var future = Date.today().add(2).months();
	return someDate.same().week(future); // true|false;
	
* * @return {Boolean} true|false */ $P.same = function () { this._same = true; this._isSecond = false; return this; }; /** * Determines if the current date/time occurs during Today. Must be preceded by the .is() function. * Example

	someDate.is().today();    // true|false
	new Date().is().today();  // true
	Date.today().is().today();// true
	Date.today().add(-1).day().is().today(); // false
	
* * @return {Boolean} true|false */ $P.today = function () { return this.same().day(); }; /** * Determines if the current date is a weekday. This function must be preceded by the .is() function. * Example

	Date.today().is().weekday(); // true|false
	
* * @return {Boolean} true|false */ $P.weekday = function () { if (this._nth) { return df("Weekday").call(this); } if (this._move) { return this.addWeekdays(this._orient); } if (this._is) { this._is = false; return (!this.is().sat() && !this.is().sun()); } return false; }; /** * Determines if the current date is on the weekend. This function must be preceded by the .is() function. * Example

	Date.today().is().weekend(); // true|false
	
* * @return {Boolean} true|false */ $P.weekend = function () { if (this._is) { this._is = false; return (this.is().sat() || this.is().sun()); } return false; }; /** * Sets the Time of the current Date instance. A string "6:15 pm" or config object {hour:18, minute:15} are accepted. * Example

	// Set time to 6:15pm with a String
	Date.today().at("6:15pm");

	// Set time to 6:15pm with a config object
	Date.today().at({hour:18, minute:15});
	
* * @return {Date} date */ $P.at = function (time) { return (typeof time === "string") ? $D.parse(this.toString("d") + " " + time) : this.set(time); }; /** * Creates a new Date() and adds this (Number) to the date based on the preceding date element function (eg. second|minute|hour|day|month|year). * Example

	// Undeclared Numbers must be wrapped with parentheses. Requirment of JavaScript.
	(3).days().fromNow();
	(6).months().fromNow();

	// Declared Number variables do not require parentheses. 
	var n = 6;
	n.months().fromNow();
	
* * @return {Date} A new Date instance */ $N.fromNow = $N.after = function (date) { var c = {}; c[this._dateElement] = this; return ((!date) ? new Date() : date.clone()).add(c); }; /** * Creates a new Date() and subtract this (Number) from the date based on the preceding date element function (eg. second|minute|hour|day|month|year). * Example

	// Undeclared Numbers must be wrapped with parentheses. Requirment of JavaScript.
	(3).days().ago();
	(6).months().ago();

	// Declared Number variables do not require parentheses. 
	var n = 6;
	n.months().ago();
	
* * @return {Date} A new Date instance */ $N.ago = $N.before = function (date) { var c = {}, s = (this._dateElement[this._dateElement.length-1] !== "s") ? this._dateElement + "s" : this._dateElement; c[s] = this * -1; return ((!date) ? new Date() : date.clone()).add(c); }; // Do NOT modify the following string tokens. These tokens are used to build dynamic functions. // All culture-specific strings can be found in the CultureInfo files. var dx = ("sunday monday tuesday wednesday thursday friday saturday").split(/\s/), mx = ("january february march april may june july august september october november december").split(/\s/), px = ("Millisecond Second Minute Hour Day Week Month Year Quarter Weekday").split(/\s/), pxf = ("Milliseconds Seconds Minutes Hours Date Week Month FullYear Quarter").split(/\s/), nth = ("final first second third fourth fifth").split(/\s/), de; /** * Returns an object literal of all the date parts. * Example

	var o = new Date().toObject();
	
	// { year: 2008, month: 4, week: 20, day: 13, hour: 18, minute: 9, second: 32, millisecond: 812 }
	
	// The object properties can be referenced directly from the object.
	
	alert(o.day);  // alerts "13"
	alert(o.year); // alerts "2008"
	
* * @return {Date} An object literal representing the original date object. */ $P.toObject = function () { var o = {}; for (var i = 0; i < px.length; i++) { if (this["get" + pxf[i]]) { o[px[i].toLowerCase()] = this["get" + pxf[i]](); } } return o; }; /** * Returns a date created from an object literal. Ignores the .week property if set in the config. * Example

	var o = new Date().toObject();
	
	return Date.fromObject(o); // will return the same date. 

	var o2 = {month: 1, day: 20, hour: 18}; // birthday party!
	Date.fromObject(o2);
	
* * @return {Date} An object literal representing the original date object. */ $D.fromObject = function(config) { config.week = null; return Date.today().set(config); }; // Create day name functions and abbreviated day name functions (eg. monday(), friday(), fri()). var df = function (n) { return function () { if (this._is) { this._is = false; return this.getDay() === n; } if (this._move) { this._move = null; } if (this._nth !== null) { // If the .second() function was called earlier, remove the _orient // from the date, and then continue. // This is required because 'second' can be used in two different context. // // Example // // Date.today().add(1).second(); // Date.march().second().monday(); // // Things get crazy with the following... // Date.march().add(1).second().second().monday(); // but it works!! // if (this._isSecond) { this.addSeconds(this._orient * -1); } // make sure we reset _isSecond this._isSecond = false; var ntemp = this._nth; this._nth = null; var temp = this.clone().moveToLastDayOfMonth(); this.moveToNthOccurrence(n, ntemp); if (this > temp) { throw new RangeError($D.getDayName(n) + " does not occur " + ntemp + " times in the month of " + $D.getMonthName(temp.getMonth()) + " " + temp.getFullYear() + "."); } return this; } return this.moveToDayOfWeek(n, this._orient); }; }; var sdf = function (n) { return function () { var t = $D.today(), shift = n - t.getDay(); if (n === 0 && Date.CultureInfo.firstDayOfWeek === 1 && t.getDay() !== 0) { shift = shift + 7; } return t.addDays(shift); }; }; // Create month name functions and abbreviated month name functions (eg. january(), march(), mar()). var month_instance_functions = function (n) { return function () { if (this._is) { this._is = false; return this.getMonth() === n; } return this.moveToMonth(n, this._orient); }; }; var month_static_functions = function (n) { return function () { return $D.today().set({ month: n, day: 1 }); }; }; var processTerms = function (names, staticFunc, instanceFunc) { for (var i = 0; i < names.length; i++) { // Create constant static Name variables. $D[names[i].toUpperCase()] = $D[names[i].toUpperCase().substring(0, 3)] = i; // Create Name functions. $D[names[i]] = $D[names[i].substring(0, 3)] = staticFunc(i); // Create Name instance functions. $P[names[i]] = $P[names[i].substring(0, 3)] = instanceFunc(i); } }; processTerms(dx, sdf, df); processTerms(mx, month_static_functions, month_instance_functions); // Create date element functions and plural date element functions used with Date (eg. day(), days(), months()). var ef = function (j) { return function () { // if the .second() function was called earlier, the _orient // has alread been added. Just return this and reset _isSecond. if (this._isSecond) { this._isSecond = false; return this; } if (this._same) { this._same = this._is = false; var o1 = this.toObject(), o2 = (arguments[0] || new Date()).toObject(), v = "", k = j.toLowerCase(); // the substr trick with -1 doesn't work in IE8 or less k = (k[k.length-1] === "s") ? k.substring(0,k.length-1) : k; for (var m = (px.length - 1); m > -1; m--) { v = px[m].toLowerCase(); if (o1[v] !== o2[v]) { return false; } if (k === v) { break; } } return true; } if (j.substring(j.length - 1) !== "s") { j += "s"; } if (this._move) { this._move = null; } return this["add" + j](this._orient); }; }; var nf = function (n) { return function () { this._dateElement = n; return this; }; }; for (var k = 0; k < px.length; k++) { de = px[k].toLowerCase(); if(de !== "weekday") { // Create date element functions and plural date element functions used with Date (eg. day(), days(), months()). $P[de] = $P[de + "s"] = ef(px[k]); // Create date element functions and plural date element functions used with Number (eg. day(), days(), months()). $N[de] = $N[de + "s"] = nf(de + "s"); } } $P._ss = ef("Second"); var nthfn = function (n) { return function (dayOfWeek) { if (this._same) { return this._ss(arguments[0]); } if (dayOfWeek || dayOfWeek === 0) { return this.moveToNthOccurrence(dayOfWeek, n); } this._nth = n; // if the operator is 'second' add the _orient, then deal with it later... if (n === 2 && (dayOfWeek === undefined || dayOfWeek === null)) { this._isSecond = true; return this.addSeconds(this._orient); } return this; }; }; for (var l = 0; l < nth.length; l++) { $P[nth[l]] = (l === 0) ? nthfn(-1) : nthfn(l); } }()); (function () { "use strict"; Date.Parsing = { Exception: function (s) { this.message = "Parse error at '" + s.substring(0, 10) + " ...'"; } }; var $P = Date.Parsing; var dayOffsets = { standard: [0,31,59,90,120,151,181,212,243,273,304,334], leap: [0,31,60,91,121,152,182,213,244,274,305,335] }; $P.isLeapYear = function(year) { return ((year % 4 === 0) && (year % 100 !== 0)) || (year % 400 === 0); }; var utils = { multiReplace : function (str, hash ) { var key; for (key in hash) { if (Object.prototype.hasOwnProperty.call(hash, key)) { var regex; if (typeof hash[key] === "function") { } else { regex = (hash[key] instanceof RegExp) ? hash[key] : new RegExp(hash[key], "g"); } str = str.replace(regex, key); } } return str; }, getDayOfYearFromWeek : function (obj) { var d, jan4, offset; obj.weekDay = (!obj.weekDay && obj.weekDay !== 0) ? 1 : obj.weekDay; d = new Date(obj.year, 0, 4); jan4 = d.getDay() === 0 ? 7 : d.getDay(); // JS is 0 indexed on Sunday. offset = jan4+3; obj.dayOfYear = ((obj.week * 7) + (obj.weekDay === 0 ? 7 : obj.weekDay))-offset; return obj; }, getDayOfYear : function (obj, dayOffset) { if (!obj.dayOfYear) { obj = utils.getDayOfYearFromWeek(obj); } for (var i=0;i <= dayOffset.length;i++) { if (obj.dayOfYear < dayOffset[i] || i === dayOffset.length) { obj.day = obj.day ? obj.day : (obj.dayOfYear - dayOffset[i-1]); break; } else { obj.month = i; } } return obj; }, adjustForTimeZone : function (obj, date) { var offset; if (obj.zone.toUpperCase() === "Z" || (obj.zone_hours === 0 && obj.zone_minutes === 0)) { // it's UTC/GML so work out the current timeszone offset offset = -date.getTimezoneOffset(); } else { offset = (obj.zone_hours*60) + (obj.zone_minutes || 0); if (obj.zone_sign === "+") { offset *= -1; } offset -= date.getTimezoneOffset(); } date.setMinutes(date.getMinutes()+offset); return date; }, setDefaults : function (obj) { obj.year = obj.year || Date.today().getFullYear(); obj.hours = obj.hours || 0; obj.minutes = obj.minutes || 0; obj.seconds = obj.seconds || 0; obj.milliseconds = obj.milliseconds || 0; if (!(!obj.month && (obj.week || obj.dayOfYear))) { // if we have a month, or if we don't but don't have the day calculation data obj.month = obj.month || 0; obj.day = obj.day || 1; } return obj; }, dataNum: function (data, mod, explict, postProcess) { var dataNum = data*1; if (mod) { if (postProcess) { return data ? mod(data)*1 : data; } else { return data ? mod(dataNum) : data; } } else if (!explict){ return data ? dataNum : data; } else { return (data && typeof data !== "undefined") ? dataNum : data; } }, timeDataProcess: function (obj) { var timeObj = {}; for (var x in obj.data) { if (obj.data.hasOwnProperty(x)) { timeObj[x] = obj.ignore[x] ? obj.data[x] : utils.dataNum(obj.data[x], obj.mods[x], obj.explict[x], obj.postProcess[x]); } } if (obj.data.secmins) { obj.data.secmins = obj.data.secmins.replace(",", ".") * 60; if (!timeObj.minutes) { timeObj.minutes = obj.data.secmins; } else if (!timeObj.seconds) { timeObj.seconds = obj.data.secmins; } delete obj.secmins; } return timeObj; }, buildTimeObjectFromData: function (data) { var time = utils.timeDataProcess({ data: { year : data[1], month : data[5], day : data[7], week : data[8], dayOfYear : data[10], hours : data[15], zone_hours : data[23], zone_minutes : data[24], zone : data[21], zone_sign : data[22], weekDay : data[9], minutes: data[16], seconds: data[19], milliseconds: data[20], secmins: data[18] }, mods: { month: function(data) { return data-1; }, weekDay: function (data) { data = Math.abs(data); return (data === 7 ? 0 : data); }, minutes: function (data) { return data.replace(":",""); }, seconds: function (data) { return Math.floor( (data.replace(":","").replace(",","."))*1 ); }, milliseconds: function (data) { return (data.replace(",",".")*1000); } }, postProcess: { minutes: true, seconds: true, milliseconds: true }, explict: { zone_hours: true, zone_minutes: true }, ignore: { zone: true, zone_sign: true, secmins: true } }); return time; }, addToHash: function (hash, keys, data) { keys = keys; data = data; var len = keys.length; for (var i = 0; i < len; i++) { hash[keys[i]] = data[i]; } return hash; }, combineRegex: function (r1, r2) { return new RegExp("(("+r1.source+")\\s("+r2.source+"))"); }, getDateNthString: function(add, last, inc){ if (add) { return Date.today().addDays(inc).toString("d"); } else if (last) { return Date.today().last()[inc]().toString("d"); } }, buildRegexData: function (array) { var arr = []; var len = array.length; for (var i=0; i < len; i++) { if (Object.prototype.toString.call(array[i]) === '[object Array]') { // oldIE compat version of Array.isArray arr.push(this.combineRegex(array[i][0], array[i][1])); } else { arr.push(array[i]); } } return arr; } }; $P.processTimeObject = function (obj) { var date, dayOffset; utils.setDefaults(obj); dayOffset = ($P.isLeapYear(obj.year)) ? dayOffsets.leap : dayOffsets.standard; if (!obj.month && (obj.week || obj.dayOfYear)) { utils.getDayOfYear(obj, dayOffset); } else { obj.dayOfYear = dayOffset[obj.month] + obj.day; } date = new Date(obj.year, obj.month, obj.day, obj.hours, obj.minutes, obj.seconds, obj.milliseconds); if (obj.zone) { utils.adjustForTimeZone(obj, date); // adjust (and calculate) for timezone } return date; }; $P.ISO = { regex : /^([\+-]?\d{4}(?!\d{2}\b))((-?)((0[1-9]|1[0-2])(\3([12]\d|0[1-9]|3[01]))?|W([0-4]\d|5[0-3])(-?[1-7])?|(00[1-9]|0[1-9]\d|[12]\d{2}|3([0-5]\d|6[1-6])))([T\s]((([01]\d|2[0-4])((:?)[0-5]\d)?|24\:?00)([\.,]\d+(?!:))?)?(\17[0-5]\d([\.,]\d+)?)?\s?([zZ]|([\+-])([01]\d|2[0-3]):?([0-5]\d)?)?)?)?$/, parse : function (s) { var time, data = s.match(this.regex); if (!data || !data.length) { return null; } time = utils.buildTimeObjectFromData(data); if (!time.year || (!time.year && (!time.month && !time.day) && (!time.week && !time.dayOfYear)) ) { return null; } return $P.processTimeObject(time); } }; $P.Numeric = { isNumeric: function (e){return!isNaN(parseFloat(e))&&isFinite(e);}, regex: /\b([0-1]?[0-9])([0-3]?[0-9])([0-2]?[0-9]?[0-9][0-9])\b/i, parse: function (s) { var data, i, time = {}, order = Date.CultureInfo.dateElementOrder.split(""); if (!(this.isNumeric(s)) || // if it's non-numeric OR (s[0] === "+" && s[0] === "-")) { // It's an arithmatic string (eg +/-1000) return null; } if (s.length < 5 && s.indexOf(".") < 0 && s.indexOf("/") < 0) { // assume it's just a year. time.year = s; return $P.processTimeObject(time); } data = s.match(this.regex); if (!data || !data.length) { return null; } for (i=0; i < order.length; i++) { switch(order[i]) { case "d": time.day = data[i+1]; break; case "m": time.month = (data[i+1]-1); break; case "y": time.year = data[i+1]; break; } } return $P.processTimeObject(time); } }; $P.Normalizer = { regexData: function () { var $R = Date.CultureInfo.regexPatterns; return utils.buildRegexData([ $R.tomorrow, $R.yesterday, [$R.past, $R.mon], [$R.past, $R.tue], [$R.past, $R.wed], [$R.past, $R.thu], [$R.past, $R.fri], [$R.past, $R.sat], [$R.past, $R.sun] ]); }, basicReplaceHash : function() { var $R = Date.CultureInfo.regexPatterns; return { "January": $R.jan.source, "February": $R.feb, "March": $R.mar, "April": $R.apr, "May": $R.may, "June": $R.jun, "July": $R.jul, "August": $R.aug, "September": $R.sep, "October": $R.oct, "November": $R.nov, "December": $R.dec, "": /\bat\b/gi, " ": /\s{2,}/, "am": $R.inTheMorning, "9am": $R.thisMorning, "pm": $R.inTheEvening, "7pm":$R.thisEvening }; }, keys : function(){ return [ utils.getDateNthString(true, false, 1), // tomorrow utils.getDateNthString(true, false, -1), // yesterday utils.getDateNthString(false, true, "monday"), //last mon utils.getDateNthString(false, true, "tuesday"), //last tues utils.getDateNthString(false, true, "wednesday"), //last wed utils.getDateNthString(false, true, "thursday"), //last thurs utils.getDateNthString(false, true, "friday"), //last fri utils.getDateNthString(false, true, "saturday"), //last sat utils.getDateNthString(false, true, "sunday") //last sun ]; }, buildRegexFunctions: function () { var $R = Date.CultureInfo.regexPatterns; var __ = Date.i18n.__; var tomorrowRE = new RegExp("(\\b\\d\\d?("+__("AM")+"|"+__("PM")+")? )("+$R.tomorrow.source.slice(1)+")", "i"); // adapted tomorrow regex for AM PM relative dates var todayRE = new RegExp($R.today.source + "(?!\\s*([+-]))\\b"); // today, but excludes the math operators (eg "today + 2h") this.replaceFuncs = [ [todayRE, function (full) { return (full.length > 1) ? Date.today().toString("d") : full; }], [tomorrowRE, function(full, m1) { var t = Date.today().addDays(1).toString("d"); return (t + " " + m1); }], [$R.amThisMorning, function(str, am){return am;}], [$R.pmThisEvening, function(str, pm){return pm;}] ]; }, buildReplaceData: function () { this.buildRegexFunctions(); this.replaceHash = utils.addToHash(this.basicReplaceHash(), this.keys(), this.regexData()); }, stringReplaceFuncs: function (s) { for (var i=0; i < this.replaceFuncs.length; i++) { s = s.replace(this.replaceFuncs[i][0], this.replaceFuncs[i][1]); } return s; }, parse: function (s) { s = this.stringReplaceFuncs(s); s = utils.multiReplace(s, this.replaceHash); try { var n = s.split(/([\s\-\.\,\/\x27]+)/); if (n.length === 3 && $P.Numeric.isNumeric(n[0]) && $P.Numeric.isNumeric(n[2]) && (n[2].length >= 4)) { // ok, so we're dealing with x/year. But that's not a full date. // This fixes wonky dateElementOrder parsing when set to dmy order. if (Date.CultureInfo.dateElementOrder[0] === "d") { s = "1/" + n[0] + "/" + n[2]; // set to 1st of month and normalize the seperator } } } catch (e) {} return s; } }; $P.Normalizer.buildReplaceData(); }()); (function () { var $P = Date.Parsing; var _ = $P.Operators = { // // Tokenizers // rtoken: function (r) { // regex token return function (s) { var mx = s.match(r); if (mx) { return ([ mx[0], s.substring(mx[0].length) ]); } else { throw new $P.Exception(s); } }; }, token: function () { // whitespace-eating token return function (s) { return _.rtoken(new RegExp("^\\s*" + s + "\\s*"))(s); }; }, stoken: function (s) { // string token return _.rtoken(new RegExp("^" + s)); }, // Atomic Operators until: function (p) { return function (s) { var qx = [], rx = null; while (s.length) { try { rx = p.call(this, s); } catch (e) { qx.push(rx[0]); s = rx[1]; continue; } break; } return [ qx, s ]; }; }, many: function (p) { return function (s) { var rx = [], r = null; while (s.length) { try { r = p.call(this, s); } catch (e) { return [ rx, s ]; } rx.push(r[0]); s = r[1]; } return [ rx, s ]; }; }, // generator operators -- see below optional: function (p) { return function (s) { var r = null; try { r = p.call(this, s); } catch (e) { return [ null, s ]; } return [ r[0], r[1] ]; }; }, not: function (p) { return function (s) { try { p.call(this, s); } catch (e) { return [null, s]; } throw new $P.Exception(s); }; }, ignore: function (p) { return p ? function (s) { var r = null; r = p.call(this, s); return [null, r[1]]; } : null; }, product: function () { var px = arguments[0], qx = Array.prototype.slice.call(arguments, 1), rx = []; for (var i = 0 ; i < px.length ; i++) { rx.push(_.each(px[i], qx)); } return rx; }, cache: function (rule) { var cache = {}, cache_length = 0, cache_keys = [], CACHE_MAX = Date.Config.CACHE_MAX || 100000, r = null; var cacheCheck = function () { if (cache_length === CACHE_MAX) { // kill several keys, don't want to have to do this all the time... for (var i=0; i < 10; i++) { var key = cache_keys.shift(); if (key) { delete cache[key]; cache_length--; } } } }; return function (s) { cacheCheck(); try { r = cache[s] = (cache[s] || rule.call(this, s)); } catch (e) { r = cache[s] = e; } cache_length++; cache_keys.push(s); if (r instanceof $P.Exception) { throw r; } else { return r; } }; }, // vector operators -- see below any: function () { var px = arguments; return function (s) { var r = null; for (var i = 0; i < px.length; i++) { if (px[i] == null) { continue; } try { r = (px[i].call(this, s)); } catch (e) { r = null; } if (r) { return r; } } throw new $P.Exception(s); }; }, each: function () { var px = arguments; return function (s) { var rx = [], r = null; for (var i = 0; i < px.length ; i++) { if (px[i] == null) { continue; } try { r = (px[i].call(this, s)); } catch (e) { throw new $P.Exception(s); } rx.push(r[0]); s = r[1]; } return [ rx, s]; }; }, all: function () { var px = arguments, _ = _; return _.each(_.optional(px)); }, // delimited operators sequence: function (px, d, c) { d = d || _.rtoken(/^\s*/); c = c || null; if (px.length === 1) { return px[0]; } return function (s) { var r = null, q = null; var rx = []; for (var i = 0; i < px.length ; i++) { try { r = px[i].call(this, s); } catch (e) { break; } rx.push(r[0]); try { q = d.call(this, r[1]); } catch (ex) { q = null; break; } s = q[1]; } if (!r) { throw new $P.Exception(s); } if (q) { throw new $P.Exception(q[1]); } if (c) { try { r = c.call(this, r[1]); } catch (ey) { throw new $P.Exception(r[1]); } } return [ rx, (r?r[1]:s) ]; }; }, // // Composite Operators // between: function (d1, p, d2) { d2 = d2 || d1; var _fn = _.each(_.ignore(d1), p, _.ignore(d2)); return function (s) { var rx = _fn.call(this, s); return [[rx[0][0], r[0][2]], rx[1]]; }; }, list: function (p, d, c) { d = d || _.rtoken(/^\s*/); c = c || null; return (p instanceof Array ? _.each(_.product(p.slice(0, -1), _.ignore(d)), p.slice(-1), _.ignore(c)) : _.each(_.many(_.each(p, _.ignore(d))), px, _.ignore(c))); }, set: function (px, d, c) { d = d || _.rtoken(/^\s*/); c = c || null; return function (s) { // r is the current match, best the current 'best' match // which means it parsed the most amount of input var r = null, p = null, q = null, rx = null, best = [[], s], last = false; // go through the rules in the given set for (var i = 0; i < px.length ; i++) { // last is a flag indicating whether this must be the last element // if there is only 1 element, then it MUST be the last one q = null; p = null; r = null; last = (px.length === 1); // first, we try simply to match the current pattern // if not, try the next pattern try { r = px[i].call(this, s); } catch (e) { continue; } // since we are matching against a set of elements, the first // thing to do is to add r[0] to matched elements rx = [[r[0]], r[1]]; // if we matched and there is still input to parse and // we don't already know this is the last element, // we're going to next check for the delimiter ... // if there's none, or if there's no input left to parse // than this must be the last element after all ... if (r[1].length > 0 && ! last) { try { q = d.call(this, r[1]); } catch (ex) { last = true; } } else { last = true; } // if we parsed the delimiter and now there's no more input, // that means we shouldn't have parsed the delimiter at all // so don't update r and mark this as the last element ... if (!last && q[1].length === 0) { last = true; } // so, if this isn't the last element, we're going to see if // we can get any more matches from the remaining (unmatched) // elements ... if (!last) { // build a list of the remaining rules we can match against, // i.e., all but the one we just matched against var qx = []; for (var j = 0; j < px.length ; j++) { if (i !== j) { qx.push(px[j]); } } // now invoke recursively set with the remaining input // note that we don't include the closing delimiter ... // we'll check for that ourselves at the end p = _.set(qx, d).call(this, q[1]); // if we got a non-empty set as a result ... // (otw rx already contains everything we want to match) if (p[0].length > 0) { // update current result, which is stored in rx ... // basically, pick up the remaining text from p[1] // and concat the result from p[0] so that we don't // get endless nesting ... rx[0] = rx[0].concat(p[0]); rx[1] = p[1]; } } // at this point, rx either contains the last matched element // or the entire matched set that starts with this element. // now we just check to see if this variation is better than // our best so far, in terms of how much of the input is parsed if (rx[1].length < best[1].length) { best = rx; } // if we've parsed all the input, then we're finished if (best[1].length === 0) { break; } } // so now we've either gone through all the patterns trying them // as the initial match; or we found one that parsed the entire // input string ... // if best has no matches, just return empty set ... if (best[0].length === 0) { return best; } // if a closing delimiter is provided, then we have to check it also if (c) { // we try this even if there is no remaining input because the pattern // may well be optional or match empty input ... try { q = c.call(this, best[1]); } catch (ey) { throw new $P.Exception(best[1]); } // it parsed ... be sure to update the best match remaining input best[1] = q[1]; } // if we're here, either there was no closing delimiter or we parsed it // so now we have the best match; just return it! return best; }; }, forward: function (gr, fname) { return function (s) { return gr[fname].call(this, s); }; }, // // Translation Operators // replace: function (rule, repl) { return function (s) { var r = rule.call(this, s); return [repl, r[1]]; }; }, process: function (rule, fn) { return function (s) { var r = rule.call(this, s); return [fn.call(this, r[0]), r[1]]; }; }, min: function (min, rule) { return function (s) { var rx = rule.call(this, s); if (rx[0].length < min) { throw new $P.Exception(s); } return rx; }; } }; // Generator Operators And Vector Operators // Generators are operators that have a signature of F(R) => R, // taking a given rule and returning another rule, such as // ignore, which parses a given rule and throws away the result. // Vector operators are those that have a signature of F(R1,R2,...) => R, // take a list of rules and returning a new rule, such as each. // Generator operators are converted (via the following _generator // function) into functions that can also take a list or array of rules // and return an array of new rules as though the function had been // called on each rule in turn (which is what actually happens). // This allows generators to be used with vector operators more easily. // Example: // each(ignore(foo, bar)) instead of each(ignore(foo), ignore(bar)) // This also turns generators into vector operators, which allows // constructs like: // not(cache(foo, bar)) var _generator = function (op) { function gen() { var args = null, rx = [], px, i; if (arguments.length > 1) { args = Array.prototype.slice.call(arguments); } else if (arguments[0] instanceof Array) { args = arguments[0]; } if (args) { px = args.shift(); if (px.length > 0) { args.unshift(px[i]); rx.push(op.apply(null, args)); args.shift(); return rx; } } else { return op.apply(null, arguments); } } return gen; }; var gx = "optional not ignore cache".split(/\s/); for (var i = 0 ; i < gx.length ; i++) { _[gx[i]] = _generator(_[gx[i]]); } var _vector = function (op) { return function () { if (arguments[0] instanceof Array) { return op.apply(null, arguments[0]); } else { return op.apply(null, arguments); } }; }; var vx = "each any all".split(/\s/); for (var j = 0 ; j < vx.length ; j++) { _[vx[j]] = _vector(_[vx[j]]); } }()); (function () { var $D = Date; var flattenAndCompact = function (ax) { var rx = []; for (var i = 0; i < ax.length; i++) { if (ax[i] instanceof Array) { rx = rx.concat(flattenAndCompact(ax[i])); } else { if (ax[i]) { rx.push(ax[i]); } } } return rx; }; var parseMeridian = function () { if (this.meridian && (this.hour || this.hour === 0)) { if (this.meridian === "a" && this.hour > 11 && Date.Config.strict24hr){ throw "Invalid hour and meridian combination"; } else if (this.meridian === "p" && this.hour < 12 && Date.Config.strict24hr){ throw "Invalid hour and meridian combination"; } else if (this.meridian === "p" && this.hour < 12) { this.hour = this.hour + 12; } else if (this.meridian === "a" && this.hour === 12) { this.hour = 0; } } }; var setDefaults = function () { var now = new Date(); if ((this.hour || this.minute) && (!this.month && !this.year && !this.day)) { this.day = now.getDate(); } if (!this.year) { this.year = now.getFullYear(); } if (!this.month && this.month !== 0) { this.month = now.getMonth(); } if (!this.day) { this.day = 1; } if (!this.hour) { this.hour = 0; } if (!this.minute) { this.minute = 0; } if (!this.second) { this.second = 0; } if (!this.millisecond) { this.millisecond = 0; } }; var finishUtils = { getToday: function () { if (this.now || "hour minute second".indexOf(this.unit) !== -1) { return new Date(); } else { return $D.today(); } }, setDaysFromWeekday: function (today, orient){ var gap; orient = orient || 1; this.unit = "day"; gap = ($D.getDayNumberFromName(this.weekday) - today.getDay()); this.days = gap ? ((gap + (orient * 7)) % 7) : (orient * 7); return this; }, setMonthsFromMonth: function (today, orient) { var gap; orient = orient || 1; this.unit = "month"; gap = (this.month - today.getMonth()); this.months = gap ? ((gap + (orient * 12)) % 12) : (orient * 12); this.month = null; return this; }, setDMYFromWeekday: function () { var d = Date[this.weekday](); this.day = d.getDate(); if (!this.month) { this.month = d.getMonth(); } this.year = d.getFullYear(); return this; }, setUnitValue: function (orient) { if (!this.value && this.operator && this.operator !== null && this[this.unit + "s"] && this[this.unit + "s"] !== null) { this[this.unit + "s"] = this[this.unit + "s"] + ((this.operator === "add") ? 1 : -1) + (this.value||0) * orient; } else if (this[this.unit + "s"] == null || this.operator != null) { if (!this.value) { this.value = 1; } this[this.unit + "s"] = this.value * orient; } }, generateDateFromWeeks: function () { var weekday = (this.weekday !== undefined) ? this.weekday : "today"; var d = Date[weekday]().addWeeks(this.weeks); if (this.now) { d.setTimeToNow(); } return d; } }; $D.Translator = { hour: function (s) { return function () { this.hour = Number(s); }; }, minute: function (s) { return function () { this.minute = Number(s); }; }, second: function (s) { return function () { this.second = Number(s); }; }, /* for ss.s format */ secondAndMillisecond: function (s) { return function () { var mx = s.match(/^([0-5][0-9])\.([0-9]{1,3})/); this.second = Number(mx[1]); this.millisecond = Number(mx[2]); }; }, meridian: function (s) { return function () { this.meridian = s.slice(0, 1).toLowerCase(); }; }, timezone: function (s) { return function () { var n = s.replace(/[^\d\+\-]/g, ""); if (n.length) { this.timezoneOffset = Number(n); } else { this.timezone = s.toLowerCase(); } }; }, day: function (x) { var s = x[0]; return function () { this.day = Number(s.match(/\d+/)[0]); if (this.day < 1) { throw "invalid day"; } }; }, month: function (s) { return function () { this.month = (s.length === 3) ? "jan feb mar apr may jun jul aug sep oct nov dec".indexOf(s)/4 : Number(s) - 1; if (this.month < 0) { throw "invalid month"; } }; }, year: function (s) { return function () { var n = Number(s); this.year = ((s.length > 2) ? n : (n + (((n + 2000) < Date.CultureInfo.twoDigitYearMax) ? 2000 : 1900))); }; }, rday: function (s) { return function () { switch (s) { case "yesterday": this.days = -1; break; case "tomorrow": this.days = 1; break; case "today": this.days = 0; break; case "now": this.days = 0; this.now = true; break; } }; }, finishExact: function (x) { var d; x = (x instanceof Array) ? x : [x]; for (var i = 0 ; i < x.length ; i++) { if (x[i]) { x[i].call(this); } } setDefaults.call(this); parseMeridian.call(this); if (this.day > $D.getDaysInMonth(this.year, this.month)) { throw new RangeError(this.day + " is not a valid value for days."); } d = new Date(this.year, this.month, this.day, this.hour, this.minute, this.second, this.millisecond); if (this.year < 100) { d.setFullYear(this.year); // means years less that 100 are process correctly. JS will parse it otherwise as 1900-1999. } if (this.timezone) { d.set({ timezone: this.timezone }); } else if (this.timezoneOffset) { d.set({ timezoneOffset: this.timezoneOffset }); } return d; }, finish: function (x) { var today, expression, orient, temp; x = (x instanceof Array) ? flattenAndCompact(x) : [ x ]; if (x.length === 0) { return null; } for (var i = 0 ; i < x.length ; i++) { if (typeof x[i] === "function") { x[i].call(this); } } if (this.now && !this.unit && !this.operator) { return new Date(); } else { today = finishUtils.getToday.call(this); } expression = !!(this.days && this.days !== null || this.orient || this.operator); orient = ((this.orient === "past" || this.operator === "subtract") ? -1 : 1); if (this.month && this.unit === "week") { this.value = this.month + 1; delete this.month; delete this.day; } if ((this.month || this.month === 0) && "year day hour minute second".indexOf(this.unit) !== -1) { if (!this.value) { this.value = this.month + 1; } this.month = null; expression = true; } if (!expression && this.weekday && !this.day && !this.days) { finishUtils.setDMYFromWeekday.call(this); } if (expression && this.weekday && this.unit !== "month" && this.unit !== "week") { finishUtils.setDaysFromWeekday.call(this, today, orient); } if (this.weekday && this.unit !== "week" && !this.day && !this.days) { temp = Date[this.weekday](); this.day = temp.getDate(); if (temp.getMonth() !== today.getMonth()) { this.month = temp.getMonth(); } } if (this.month && this.unit === "day" && this.operator) { if (!this.value) { this.value = (this.month + 1); } this.month = null; } if (this.value != null && this.month != null && this.year != null) { this.day = this.value * 1; } if (this.month && !this.day && this.value) { today.set({ day: this.value * 1 }); if (!expression) { this.day = this.value * 1; } } if (!this.month && this.value && this.unit === "month" && !this.now) { this.month = this.value; expression = true; } if (expression && (this.month || this.month === 0) && this.unit !== "year") { finishUtils.setMonthsFromMonth.call(this, today, orient); } if (!this.unit) { this.unit = "day"; } finishUtils.setUnitValue.call(this, orient); parseMeridian.call(this); if ((this.month || this.month === 0) && !this.day) { this.day = 1; } if (!this.orient && !this.operator && this.unit === "week" && this.value && !this.day && !this.month) { return Date.today().setWeek(this.value); } if (this.unit === "week" && this.weeks && !this.day && !this.month) { return finishUtils.generateDateFromWeeks.call(this); } if (expression && this.timezone && this.day && this.days) { this.day = this.days; } if (expression){ today.add(this); } else { today.set(this); } if (this.timezone) { this.timezone = this.timezone.toUpperCase(); var offset = $D.getTimezoneOffset(this.timezone); var timezone; if (today.hasDaylightSavingTime()) { // lets check that we're being sane with timezone setting timezone = $D.getTimezoneAbbreviation(offset, today.isDaylightSavingTime()); if (timezone !== this.timezone) { // bugger, we're in a place where things like EST vs EDT matters. if (today.isDaylightSavingTime()) { today.addHours(-1); } else { today.addHours(1); } } } today.setTimezoneOffset(offset); } return today; } }; }()); (function () { var $D = Date; $D.Grammar = {}; var _ = $D.Parsing.Operators, g = $D.Grammar, t = $D.Translator, _fn; // Allow rolling up into general purpose rules _fn = function () { return _.each(_.any.apply(null, arguments), _.not(g.ctoken2("timeContext"))); }; g.datePartDelimiter = _.rtoken(/^([\s\-\.\,\/\x27]+)/); g.timePartDelimiter = _.stoken(":"); g.whiteSpace = _.rtoken(/^\s*/); g.generalDelimiter = _.rtoken(/^(([\s\,]|at|@|on)+)/); var _C = {}; g.ctoken = function (keys) { var fn = _C[keys]; if (! fn) { var c = Date.CultureInfo.regexPatterns; var kx = keys.split(/\s+/), px = []; for (var i = 0; i < kx.length ; i++) { px.push(_.replace(_.rtoken(c[kx[i]]), kx[i])); } fn = _C[keys] = _.any.apply(null, px); } return fn; }; g.ctoken2 = function (key) { return _.rtoken(Date.CultureInfo.regexPatterns[key]); }; var cacheProcessRtoken = function (key, token, type, eachToken) { if (eachToken) { g[key] = _.cache(_.process(_.each(_.rtoken(token),_.optional(g.ctoken2(eachToken))), type)); } else { g[key] = _.cache(_.process(_.rtoken(token), type)); } }; var cacheProcessCtoken = function (token, type) { return _.cache(_.process(g.ctoken2(token), type)); }; var _F = {}; //function cache var _get = function (f) { _F[f] = (_F[f] || g.format(f)[0]); return _F[f]; }; g.allformats = function (fx) { var rx = []; if (fx instanceof Array) { for (var i = 0; i < fx.length; i++) { rx.push(_get(fx[i])); } } else { rx.push(_get(fx)); } return rx; }; g.formats = function (fx) { if (fx instanceof Array) { var rx = []; for (var i = 0 ; i < fx.length ; i++) { rx.push(_get(fx[i])); } return _.any.apply(null, rx); } else { return _get(fx); } }; var grammarFormats = { timeFormats: function(){ var i, RTokenKeys = [ "h", "hh", "H", "HH", "m", "mm", "s", "ss", "ss.s", "z", "zz" ], RToken = [ /^(0[0-9]|1[0-2]|[1-9])/, /^(0[0-9]|1[0-2])/, /^([0-1][0-9]|2[0-3]|[0-9])/, /^([0-1][0-9]|2[0-3])/, /^([0-5][0-9]|[0-9])/, /^[0-5][0-9]/, /^([0-5][0-9]|[0-9])/, /^[0-5][0-9]/, /^[0-5][0-9]\.[0-9]{1,3}/, /^((\+|\-)\s*\d\d\d\d)|((\+|\-)\d\d\:?\d\d)/, /^((\+|\-)\s*\d\d\d\d)|((\+|\-)\d\d\:?\d\d)/ ], tokens = [ t.hour, t.hour, t.hour, t.hour, t.minute, t.minute, t.second, t.second, t.secondAndMillisecond, t.timezone, t.timezone ]; for (i=0; i < RTokenKeys.length; i++) { cacheProcessRtoken(RTokenKeys[i], RToken[i], tokens[i]); } g.hms = _.cache(_.sequence([g.H, g.m, g.s], g.timePartDelimiter)); g.t = cacheProcessCtoken("shortMeridian", t.meridian); g.tt = cacheProcessCtoken("longMeridian", t.meridian); g.zzz = cacheProcessCtoken("timezone", t.timezone); g.timeSuffix = _.each(_.ignore(g.whiteSpace), _.set([ g.tt, g.zzz ])); g.time = _.each(_.optional(_.ignore(_.stoken("T"))), g.hms, g.timeSuffix); }, dateFormats: function () { // pre-loaded rules for different date part order preferences var _setfn = function () { return _.set(arguments, g.datePartDelimiter); }; var i, RTokenKeys = [ "d", "dd", "M", "MM", "y", "yy", "yyy", "yyyy" ], RToken = [ /^([0-2]\d|3[0-1]|\d)/, /^([0-2]\d|3[0-1])/, /^(1[0-2]|0\d|\d)/, /^(1[0-2]|0\d)/, /^(\d+)/, /^(\d\d)/, /^(\d\d?\d?\d?)/, /^(\d\d\d\d)/ ], tokens = [ t.day, t.day, t.month, t.month, t.year, t.year, t.year, t.year ], eachToken = [ "ordinalSuffix", "ordinalSuffix" ]; for (i=0; i < RTokenKeys.length; i++) { cacheProcessRtoken(RTokenKeys[i], RToken[i], tokens[i], eachToken[i]); } g.MMM = g.MMMM = _.cache(_.process(g.ctoken("jan feb mar apr may jun jul aug sep oct nov dec"), t.month)); g.ddd = g.dddd = _.cache(_.process(g.ctoken("sun mon tue wed thu fri sat"), function (s) { return function () { this.weekday = s; }; } )); g.day = _fn(g.d, g.dd); g.month = _fn(g.M, g.MMM); g.year = _fn(g.yyyy, g.yy); g.mdy = _setfn(g.ddd, g.month, g.day, g.year); g.ymd = _setfn(g.ddd, g.year, g.month, g.day); g.dmy = _setfn(g.ddd, g.day, g.month, g.year); g.date = function (s) { return ((g[Date.CultureInfo.dateElementOrder] || g.mdy).call(this, s)); }; }, relative: function () { // relative date / time expressions g.orientation = _.process(g.ctoken("past future"), function (s) { return function () { this.orient = s; }; } ); g.operator = _.process(g.ctoken("add subtract"), function (s) { return function () { this.operator = s; }; } ); g.rday = _.process(g.ctoken("yesterday tomorrow today now"), t.rday); g.unit = _.process(g.ctoken("second minute hour day week month year"), function (s) { return function () { this.unit = s; }; } ); } }; g.buildGrammarFormats = function () { // these need to be rebuilt every time the language changes. _C = {}; grammarFormats.timeFormats(); grammarFormats.dateFormats(); grammarFormats.relative(); g.value = _.process(_.rtoken(/^([-+]?\d+)?(st|nd|rd|th)?/), function (s) { return function () { this.value = s.replace(/\D/g, ""); }; } ); g.expression = _.set([g.rday, g.operator, g.value, g.unit, g.orientation, g.ddd, g.MMM ]); g.format = _.process(_.many( _.any( // translate format specifiers into grammar rules _.process( _.rtoken(/^(dd?d?d?(?!e)|MM?M?M?|yy?y?y?|hh?|HH?|mm?|ss?|tt?|zz?z?)/), function (fmt) { if (g[fmt]) { return g[fmt]; } else { throw $D.Parsing.Exception(fmt); } } ), // translate separator tokens into token rules _.process(_.rtoken(/^[^dMyhHmstz]+/), // all legal separators function (s) { return _.ignore(_.stoken(s)); } ) ) ), // construct the parser ... function (rules) { return _.process(_.each.apply(null, rules), t.finishExact); } ); // starting rule for general purpose grammar g._start = _.process(_.set([ g.date, g.time, g.expression ], g.generalDelimiter, g.whiteSpace), t.finish); }; g.buildGrammarFormats(); // parsing date format specifiers - ex: "h:m:s tt" // this little guy will generate a custom parser based // on the format string, ex: g.format("h:m:s tt") // check for these formats first g._formats = g.formats([ "\"yyyy-MM-ddTHH:mm:ssZ\"", "yyyy-MM-ddTHH:mm:ss.sz", "yyyy-MM-ddTHH:mm:ssZ", "yyyy-MM-ddTHH:mm:ssz", "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-ddTHH:mmZ", "yyyy-MM-ddTHH:mmz", "yyyy-MM-ddTHH:mm", "ddd, MMM dd, yyyy H:mm:ss tt", "ddd MMM d yyyy HH:mm:ss zzz", "MMddyyyy", "ddMMyyyy", "Mddyyyy", "ddMyyyy", "Mdyyyy", "dMyyyy", "yyyy", "Mdyy", "dMyy", "d" ]); // real starting rule: tries selected formats first, // then general purpose rule g.start = function (s) { try { var r = g._formats.call({}, s); if (r[1].length === 0) { return r; } } catch (e) {} return g._start.call({}, s); }; }()); (function () { var $D = Date; /** * @desc Converts the specified string value into its JavaScript Date equivalent using CultureInfo specific format information. * * Example

	///////////
	// Dates //
	///////////

	// 15-Oct-2004
	var d1 = Date.parse("10/15/2004");

	// 15-Oct-2004
	var d1 = Date.parse("15-Oct-2004");

	// 15-Oct-2004
	var d1 = Date.parse("2004.10.15");

	//Fri Oct 15, 2004
	var d1 = Date.parse("Fri Oct 15, 2004");

	///////////
	// Times //
	///////////

	// Today at 10 PM.
	var d1 = Date.parse("10 PM");

	// Today at 10:30 PM.
	var d1 = Date.parse("10:30 P.M.");

	// Today at 6 AM.
	var d1 = Date.parse("06am");

	/////////////////////
	// Dates and Times //
	/////////////////////

	// 8-July-2004 @ 10:30 PM
	var d1 = Date.parse("July 8th, 2004, 10:30 PM");

	// 1-July-2004 @ 10:30 PM
	var d1 = Date.parse("2004-07-01T22:30:00");

	////////////////////
	// Relative Dates //
	////////////////////

	// Returns today's date. The string "today" is culture specific.
	var d1 = Date.parse("today");

	// Returns yesterday's date. The string "yesterday" is culture specific.
	var d1 = Date.parse("yesterday");

	// Returns the date of the next thursday.
	var d1 = Date.parse("Next thursday");

	// Returns the date of the most previous monday.
	var d1 = Date.parse("last monday");

	// Returns today's day + one year.
	var d1 = Date.parse("next year");

	///////////////
	// Date Math //
	///////////////

	// Today + 2 days
	var d1 = Date.parse("t+2");

	// Today + 2 days
	var d1 = Date.parse("today + 2 days");

	// Today + 3 months
	var d1 = Date.parse("t+3m");

	// Today - 1 year
	var d1 = Date.parse("today - 1 year");

	// Today - 1 year
	var d1 = Date.parse("t-1y"); 


	/////////////////////////////
	// Partial Dates and Times //
	/////////////////////////////

	// July 15th of this year.
	var d1 = Date.parse("July 15");

	// 15th day of current day and year.
	var d1 = Date.parse("15");

	// July 1st of current year at 10pm.
	var d1 = Date.parse("7/1 10pm");
	
* * @param {String} The string value to convert into a Date object [Required] * @return {Date} A Date object or null if the string cannot be converted into a Date. */ var parseUtils = { removeOrds: function (s) { ords = s.match(/\b(\d+)(?:st|nd|rd|th)\b/); // find ordinal matches s = ((ords && ords.length === 2) ? s.replace(ords[0], ords[1]) : s); return s; }, grammarParser: function (s) { var r = null; try { r = $D.Grammar.start.call({}, s.replace(/^\s*(\S*(\s+\S+)*)\s*$/, "$1")); } catch (e) { return null; } return ((r[1].length === 0) ? r[0] : null); }, nativeFallback: function(s) { var t; try { // ok we haven't parsed it, last ditch attempt with the built-in parser. t = Date._parse(s); return (t || t === 0) ? new Date(t) : null; } catch (e) { return null; } } }; function parse (s) { var d; if (!s) { return null; } if (s instanceof Date) { return s.clone(); } if (s.length >= 4 && s.charAt(0) !== "0" && s.charAt(0) !== "+"&& s.charAt(0) !== "-") { // ie: 2004 will pass, 0800 won't. // Start with specific formats d = $D.Parsing.ISO.parse(s) || $D.Parsing.Numeric.parse(s); } if (d instanceof Date && !isNaN(d.getTime())) { return d; } else { // find ordinal dates (1st, 3rd, 8th, etc and remove them as they cause parsing issues) s = $D.Parsing.Normalizer.parse(parseUtils.removeOrds(s)); d = parseUtils.grammarParser(s); if (d !== null) { return d; } else { return parseUtils.nativeFallback(s); } } } if (!$D._parse) { $D._parse = $D.parse; } $D.parse = parse; Date.getParseFunction = function (fx) { var fns = Date.Grammar.allformats(fx); return function (s) { var r = null; for (var i = 0; i < fns.length; i++) { try { r = fns[i].call({}, s); } catch (e) { continue; } if (r[1].length === 0) { return r[0]; } } return null; }; }; /** * Converts the specified string value into its JavaScript Date equivalent using the specified format {String} or formats {Array} and the CultureInfo specific format information. * The format of the string value must match one of the supplied formats exactly. * * Example

	// 15-Oct-2004
	var d1 = Date.parseExact("10/15/2004", "M/d/yyyy");

	// 15-Oct-2004
	var d1 = Date.parse("15-Oct-2004", "M-ddd-yyyy");

	// 15-Oct-2004
	var d1 = Date.parse("2004.10.15", "yyyy.MM.dd");

	// Multiple formats
	var d1 = Date.parseExact("10/15/2004", ["M/d/yyyy", "MMMM d, yyyy"]);
	
* * @param {String} The string value to convert into a Date object [Required]. * @param {Object} The expected format {String} or an array of expected formats {Array} of the date string [Required]. * @return {Date} A Date object or null if the string cannot be converted into a Date. */ $D.parseExact = function (s, fx) { return $D.getParseFunction(fx)(s); }; }()); (function () { var $D = Date, $P = $D.prototype, // $C = $D.CultureInfo, // not used atm p = function (s, l) { if (!l) { l = 2; } return ("000" + s).slice(l * -1); }; /** * Converts a PHP format string to Java/.NET format string. * A PHP format string can be used with ._format or .format. * A Java/.NET format string can be used with .toString(). * The .parseExact function will only accept a Java/.NET format string * * Example * var f1 = "%m/%d/%y" * var f2 = Date.normalizeFormat(f1); // "MM/dd/yy" * * new Date().format(f1); // "04/13/08" * new Date()._format(f1); // "04/13/08" * new Date().toString(f2); // "04/13/08" * * var date = Date.parseExact("04/13/08", f2); // Sun Apr 13 2008 * * @param {String} A PHP format string consisting of one or more format spcifiers. * @return {String} The PHP format converted to a Java/.NET format string. */ var normalizerSubstitutions = { "d" : "dd", "%d": "dd", "D" : "ddd", "%a": "ddd", "j" : "dddd", "l" : "dddd", "%A": "dddd", "S" : "S", "F" : "MMMM", "%B": "MMMM", "m" : "MM", "%m": "MM", "M" : "MMM", "%b": "MMM", "%h": "MMM", "n" : "M", "Y" : "yyyy", "%Y": "yyyy", "y" : "yy", "%y": "yy", "g" : "h", "%I": "h", "G" : "H", "h" : "hh", "H" : "HH", "%H": "HH", "i" : "mm", "%M": "mm", "s" : "ss", "%S": "ss", "%r": "hh:mm tt", "%R": "H:mm", "%T": "H:mm:ss", "%X": "t", "%x": "d", "%e": "d", "%D": "MM/dd/yy", "%n": "\\n", "%t": "\\t", "e" : "z", "T" : "z", "%z": "z", "%Z": "z", "Z" : "ZZ", "N" : "u", "w" : "u", "%w": "u", "W" : "W", "%V": "W" }; var normalizer = { substitutes: function (m) { return normalizerSubstitutions[m]; }, interpreted: function (m, x) { var y; switch (m) { case "%u": return x.getDay() + 1; case "z": return x.getOrdinalNumber(); case "%j": return p(x.getOrdinalNumber(), 3); case "%U": var d1 = x.clone().set({month: 0, day: 1}).addDays(-1).moveToDayOfWeek(0), d2 = x.clone().addDays(1).moveToDayOfWeek(0, -1); return (d2 < d1) ? "00" : p((d2.getOrdinalNumber() - d1.getOrdinalNumber()) / 7 + 1); case "%W": return p(x.getWeek()); case "t": return $D.getDaysInMonth(x.getFullYear(), x.getMonth()); case "o": case "%G": return x.setWeek(x.getISOWeek()).toString("yyyy"); case "%g": return x._format("%G").slice(-2); case "a": case "%p": return t("tt").toLowerCase(); case "A": return t("tt").toUpperCase(); case "u": return p(x.getMilliseconds(), 3); case "I": return (x.isDaylightSavingTime()) ? 1 : 0; case "O": return x.getUTCOffset(); case "P": y = x.getUTCOffset(); return y.substring(0, y.length - 2) + ":" + y.substring(y.length - 2); case "B": var now = new Date(); return Math.floor(((now.getHours() * 3600) + (now.getMinutes() * 60) + now.getSeconds() + (now.getTimezoneOffset() + 60) * 60) / 86.4); case "c": return x.toISOString().replace(/\"/g, ""); case "U": return $D.strtotime("now"); case "%c": return t("d") + " " + t("t"); case "%C": return Math.floor(x.getFullYear() / 100 + 1); } }, shouldOverrideDefaults: function (m) { switch (m) { case "%e": return true; default: return false; } }, parse: function (m, context) { var formatString, c = context || new Date(); formatString = normalizer.substitutes(m); if (formatString) { return formatString; } formatString = normalizer.interpreted(m, c); if (formatString) { return formatString; } else { return m; } } }; $D.normalizeFormat = function (format, context) { return format.replace(/(%|\\)?.|%%/g, function(t){ return normalizer.parse(t, context); }); }; /** * Format a local Unix timestamp according to locale settings * * Example: * Date.strftime("%m/%d/%y", new Date()); // "04/13/08" * Date.strftime("c", "2008-04-13T17:52:03Z"); // "04/13/08" * * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @param {Number|String} The number representing the number of seconds that have elapsed since January 1, 1970 (local time). * @return {String} A string representation of the current Date object. */ $D.strftime = function (format, time) { var d = Date.parse(time); return d._format(format); }; /** * Parse any textual datetime description into a Unix timestamp. * A Unix timestamp is the number of seconds that have elapsed since January 1, 1970 (midnight UTC/GMT). * * Example: * Date.strtotime("04/13/08"); // 1208044800 * Date.strtotime("1970-01-01T00:00:00Z"); // 0 * * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @param {Object} A string or date object. * @return {String} A string representation of the current Date object. */ $D.strtotime = function (time) { var d = $D.parse(time); return Math.round($D.UTC(d.getUTCFullYear(), d.getUTCMonth(), d.getUTCDate(), d.getUTCHours(), d.getUTCMinutes(), d.getUTCSeconds(), d.getUTCMilliseconds()) / 1000); }; /** * Converts the value of the current Date object to its equivalent string representation using a PHP/Unix style of date format specifiers. * Format Specifiers * Format Description Example * ------ --------------------------------------------------------------------------- ----------------------- * %a abbreviated weekday name according to the current localed "Mon" through "Sun" * %A full weekday name according to the current localed "Sunday" through "Saturday" * %b abbreviated month name according to the current localed "Jan" through "Dec" * %B full month name according to the current locale "January" through "December" * %c preferred date and time representation for the current locale "4/13/2008 12:33 PM" * %C century number (the year divided by 100 and truncated to an integer) "00" to "99" * %d day of the month as a decimal number "01" to "31" * %D same as %m/%d/%y "04/13/08" * %e day of the month as a decimal number, a single digit is preceded by a space "1" to "31" * %g like %G, but without the century "08" * %G The 4-digit year corresponding to the ISO week number (see %V). "2008" * This has the same format and value as %Y, except that if the ISO week number * belongs to the previous or next year, that year is used instead. * %h same as %b "Jan" through "Dec" * %H hour as a decimal number using a 24-hour clock. "00" to "23" * %I hour as a decimal number using a 12-hour clock. "01" to "12" * %j day of the year as a decimal number. "001" to "366" * %m month as a decimal number. "01" to "12" * %M minute as a decimal number. "00" to "59" * %n newline character "\n" * %p either "am" or "pm" according to the given time value, or the "am" or "pm" * corresponding strings for the current locale. * %r time in a.m. and p.m. notation "8:44 PM" * %R time in 24 hour notation "20:44" * %S second as a decimal number "00" to "59" * %t tab character "\t" * %T current time, equal to %H:%M:%S "12:49:11" * %u weekday as a decimal number ["1", "7"], with "1" representing Monday "1" to "7" * %U week number of the current year as a decimal number, starting with the "0" to ("52" or "53") * first Sunday as the first day of the first week * %V The ISO 8601:1988 week number of the current year as a decimal number, "00" to ("52" or "53") * range 01 to 53, where week 1 is the first week that has at least 4 days * in the current year, and with Monday as the first day of the week. * (Use %G or %g for the year component that corresponds to the week number * for the specified timestamp.) * %W week number of the current year as a decimal number, starting with the "00" to ("52" or "53") * first Monday as the first day of the first week * %w day of the week as a decimal, Sunday being "0" "0" to "6" * %x preferred date representation for the current locale without the time "4/13/2008" * %X preferred time representation for the current locale without the date "12:53:05" * %y year as a decimal number without a century "00" "99" * %Y year as a decimal number including the century "2008" * %Z time zone or name or abbreviation "UTC", "EST", "PST" * %z same as %Z * %% a literal "%" characters "%" * d Day of the month, 2 digits with leading zeros "01" to "31" * D A textual representation of a day, three letters "Mon" through "Sun" * j Day of the month without leading zeros "1" to "31" * l A full textual representation of the day of the week (lowercase "L") "Sunday" through "Saturday" * N ISO-8601 numeric representation of the day of the week (added in PHP 5.1.0) "1" (for Monday) through "7" (for Sunday) * S English ordinal suffix for the day of the month, 2 characters "st", "nd", "rd" or "th". Works well with j * w Numeric representation of the day of the week "0" (for Sunday) through "6" (for Saturday) * z The day of the year (starting from "0") "0" through "365" * W ISO-8601 week number of year, weeks starting on Monday "00" to ("52" or "53") * F A full textual representation of a month, such as January or March "January" through "December" * m Numeric representation of a month, with leading zeros "01" through "12" * M A short textual representation of a month, three letters "Jan" through "Dec" * n Numeric representation of a month, without leading zeros "1" through "12" * t Number of days in the given month "28" through "31" * L Whether it's a leap year "1" if it is a leap year, "0" otherwise * o ISO-8601 year number. This has the same value as Y, except that if the "2008" * ISO week number (W) belongs to the previous or next year, that year * is used instead. * Y A full numeric representation of a year, 4 digits "2008" * y A two digit representation of a year "08" * a Lowercase Ante meridiem and Post meridiem "am" or "pm" * A Uppercase Ante meridiem and Post meridiem "AM" or "PM" * B Swatch Internet time "000" through "999" * g 12-hour format of an hour without leading zeros "1" through "12" * G 24-hour format of an hour without leading zeros "0" through "23" * h 12-hour format of an hour with leading zeros "01" through "12" * H 24-hour format of an hour with leading zeros "00" through "23" * i Minutes with leading zeros "00" to "59" * s Seconds, with leading zeros "00" through "59" * u Milliseconds "54321" * e Timezone identifier "UTC", "EST", "PST" * I Whether or not the date is in daylight saving time (uppercase i) "1" if Daylight Saving Time, "0" otherwise * O Difference to Greenwich time (GMT) in hours "+0200", "-0600" * P Difference to Greenwich time (GMT) with colon between hours and minutes "+02:00", "-06:00" * T Timezone abbreviation "UTC", "EST", "PST" * Z Timezone offset in seconds. The offset for timezones west of UTC is "-43200" through "50400" * always negative, and for those east of UTC is always positive. * c ISO 8601 date "2004-02-12T15:19:21+00:00" * r RFC 2822 formatted date "Thu, 21 Dec 2000 16:01:07 +0200" * U Seconds since the Unix Epoch (January 1 1970 00:00:00 GMT) "0" * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @return {String} A string representation of the current Date object. */ var formatReplace = function (context) { return function (m) { var formatString, override = false; if (m.charAt(0) === "\\" || m.substring(0, 2) === "%%") { return m.replace("\\", "").replace("%%", "%"); } override = normalizer.shouldOverrideDefaults(m); formatString = $D.normalizeFormat(m, context); if (formatString) { return context.toString(formatString, override); } }; }; $P._format = function (format) { var formatter = formatReplace(this); if (!format) { return this._toString(); } else { return format.replace(/(%|\\)?.|%%/g, formatter); } }; if (!$P.format) { $P.format = $P._format; } }()); (function () { "use strict"; var gFn = function (attr) { return function () { return this[attr]; }; }; var sFn = function (attr) { return function (val) { this[attr] = val; return this; }; }; var attrs = ["years", "months", "days", "hours", "minutes", "seconds", "milliseconds"]; var addSetFuncs = function (context, attrs) { for (var i = 0; i < attrs.length ; i++) { var $a = attrs[i], $b = $a.slice(0, 1).toUpperCase() + $a.slice(1); context.prototype[$a] = 0; context.prototype["get" + $b] = gFn($a); context.prototype["set" + $b] = sFn($a); } }; /** * new TimeSpan(milliseconds); * new TimeSpan(days, hours, minutes, seconds); * new TimeSpan(days, hours, minutes, seconds, milliseconds); */ var TimeSpan = function (days, hours, minutes, seconds, milliseconds) { if (arguments.length === 1 && typeof days === "number") { var orient = (days < 0) ? -1 : +1; var millsLeft = Math.abs(days); this.setDays(Math.floor(millsLeft / 86400000) * orient); millsLeft = millsLeft % 86400000; this.setHours(Math.floor(millsLeft / 3600000) * orient); millsLeft = millsLeft % 3600000; this.setMinutes(Math.floor(millsLeft / 60000) * orient); millsLeft = millsLeft % 60000; this.setSeconds(Math.floor(millsLeft / 1000) * orient); millsLeft = millsLeft % 1000; this.setMilliseconds(millsLeft * orient); } else { this.set(days, hours, minutes, seconds, milliseconds); } this.getTotalMilliseconds = function () { return (this.getDays() * 86400000) + (this.getHours() * 3600000) + (this.getMinutes() * 60000) + (this.getSeconds() * 1000); }; this.compareTo = function (time) { var t1 = new Date(1970, 1, 1, this.getHours(), this.getMinutes(), this.getSeconds()), t2; if (time === null) { t2 = new Date(1970, 1, 1, 0, 0, 0); } else { t2 = new Date(1970, 1, 1, time.getHours(), time.getMinutes(), time.getSeconds()); } return (t1 < t2) ? -1 : (t1 > t2) ? 1 : 0; }; this.equals = function (time) { return (this.compareTo(time) === 0); }; this.add = function (time) { return (time === null) ? this : this.addSeconds(time.getTotalMilliseconds() / 1000); }; this.subtract = function (time) { return (time === null) ? this : this.addSeconds(-time.getTotalMilliseconds() / 1000); }; this.addDays = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 86400000)); }; this.addHours = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 3600000)); }; this.addMinutes = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 60000)); }; this.addSeconds = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 1000)); }; this.addMilliseconds = function (n) { return new TimeSpan(this.getTotalMilliseconds() + n); }; this.get12HourHour = function () { return (this.getHours() > 12) ? this.getHours() - 12 : (this.getHours() === 0) ? 12 : this.getHours(); }; this.getDesignator = function () { return (this.getHours() < 12) ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator; }; this.toString = function (format) { this._toString = function () { if (this.getDays() !== null && this.getDays() > 0) { return this.getDays() + "." + this.getHours() + ":" + this.p(this.getMinutes()) + ":" + this.p(this.getSeconds()); } else { return this.getHours() + ":" + this.p(this.getMinutes()) + ":" + this.p(this.getSeconds()); } }; this.p = function (s) { return (s.toString().length < 2) ? "0" + s : s; }; var me = this; return format ? format.replace(/dd?|HH?|hh?|mm?|ss?|tt?/g, function (format) { switch (format) { case "d": return me.getDays(); case "dd": return me.p(me.getDays()); case "H": return me.getHours(); case "HH": return me.p(me.getHours()); case "h": return me.get12HourHour(); case "hh": return me.p(me.get12HourHour()); case "m": return me.getMinutes(); case "mm": return me.p(me.getMinutes()); case "s": return me.getSeconds(); case "ss": return me.p(me.getSeconds()); case "t": return ((me.getHours() < 12) ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator).substring(0, 1); case "tt": return (me.getHours() < 12) ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator; } } ) : this._toString(); }; return this; }; addSetFuncs(TimeSpan, attrs.slice(2)); TimeSpan.prototype.set = function (days, hours, minutes, seconds, milliseconds){ this.setDays(days || this.getDays()); this.setHours(hours || this.getHours()); this.setMinutes(minutes || this.getMinutes()); this.setSeconds(seconds || this.getSeconds()); this.setMilliseconds(milliseconds || this.getMilliseconds()); }; /** * Gets the time of day for this date instances. * @return {TimeSpan} TimeSpan */ Date.prototype.getTimeOfDay = function () { return new TimeSpan(0, this.getHours(), this.getMinutes(), this.getSeconds(), this.getMilliseconds()); }; Date.TimeSpan = TimeSpan; if (typeof window !== "undefined" ) { // keeping API compatible for v1.x window.TimeSpan = TimeSpan; } }()); (function () { "use strict"; var attrs = ["years", "months", "days", "hours", "minutes", "seconds", "milliseconds"]; var gFn = function (attr) { return function () { return this[attr]; }; }; var sFn = function (attr) { return function (val) { this[attr] = val; return this; }; }; var addSetFuncs = function (context, attrs) { for (var i = 0; i < attrs.length ; i++) { var $a = attrs[i], $b = $a.slice(0, 1).toUpperCase() + $a.slice(1); context.prototype[$a] = 0; context.prototype["get" + $b] = gFn($a); context.prototype["set" + $b] = sFn($a); } }; var setMonthsAndYears = function (orient, d1, d2, context) { function inc() { d1.addMonths(-orient); context.months++; if (context.months === 12) { context.years++; context.months = 0; } } if (orient === +1) { while (d1 > d2) { inc(); } } else { while (d1 < d2) { inc(); } } context.months--; context.months *= orient; context.years *= orient; }; var adjustForDST = function(orient, startDate, endDate) { var hasDSTMismatch = (false === (startDate.isDaylightSavingTime() === endDate.isDaylightSavingTime())); if (hasDSTMismatch && orient === 1) { startDate.addHours(-1); } else if (hasDSTMismatch) { startDate.addHours(1); } }; /** * TimePeriod(startDate, endDate); * TimePeriod(years, months, days, hours, minutes, seconds, milliseconds); */ var TimePeriod = function (years, months, days, hours, minutes, seconds, milliseconds) { if (arguments.length === 7) { this.set(years, months, days, hours, minutes, seconds, milliseconds); } else if (arguments.length === 2 && arguments[0] instanceof Date && arguments[1] instanceof Date) { var startDate = arguments[0].clone(); var endDate = arguments[1].clone(); var orient = (startDate > endDate) ? +1 : -1; this.dates = { start: arguments[0].clone(), end: arguments[1].clone() }; setMonthsAndYears(orient, startDate, endDate, this); adjustForDST(orient, startDate, endDate); // // TODO - adjust for DST var diff = endDate - startDate; if (diff !== 0) { var ts = new TimeSpan(diff); this.set(this.years, this.months, ts.getDays(), ts.getHours(), ts.getMinutes(), ts.getSeconds(), ts.getMilliseconds()); } } return this; }; // create all the set functions. addSetFuncs(TimePeriod, attrs); TimePeriod.prototype.set = function (years, months, days, hours, minutes, seconds, milliseconds){ this.setYears(years || this.getYears()); this.setMonths(months || this.getMonths()); this.setDays(days || this.getDays()); this.setHours(hours || this.getHours()); this.setMinutes(minutes || this.getMinutes()); this.setSeconds(seconds || this.getSeconds()); this.setMilliseconds(milliseconds || this.getMilliseconds()); }; Date.TimePeriod = TimePeriod; if (typeof window !== "undefined") { // keeping API compatible for v1.x window.TimePeriod = TimePeriod; } }()); ================================================ FILE: build/date-de-DE.js ================================================ /** * @overview datejs * @version 1.0.0-rc3 * @author Gregory Wild-Smith * @copyright 2015 Gregory Wild-Smith * @license MIT * @homepage https://github.com/abritinthebay/datejs */ /* * DateJS Culture String File * Country Code: de-DE * Name: German (Germany) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["de-DE"] = { "name": "de-DE", "englishName": "German (Germany)", "nativeName": "Deutsch (Deutschland)", "Sunday": "Sonntag", "Monday": "Montag", "Tuesday": "Dienstag", "Wednesday": "Mittwoch", "Thursday": "Donnerstag", "Friday": "Freitag", "Saturday": "Samstag", "Sun": "Son", "Mon": "Mon", "Tue": "Die", "Wed": "Mit", "Thu": "Don", "Fri": "Fre", "Sat": "Sam", "Su": "So", "Mo": "Mo", "Tu": "Di", "We": "Mi", "Th": "Do", "Fr": "Fr", "Sa": "Sa", "S_Sun_Initial": "S", "M_Mon_Initial": "M", "T_Tue_Initial": "D", "W_Wed_Initial": "M", "T_Thu_Initial": "D", "F_Fri_Initial": "F", "S_Sat_Initial": "S", "January": "Januar", "February": "Februar", "March": "März", "April": "April", "May": "Mai", "June": "Juni", "July": "Juli", "August": "August", "September": "September", "October": "Oktober", "November": "November", "December": "Dezember", "Jan_Abbr": "Jan", "Feb_Abbr": "Feb", "Mar_Abbr": "Mrz", "Apr_Abbr": "Apr", "May_Abbr": "Mai", "Jun_Abbr": "Jun", "Jul_Abbr": "Jul", "Aug_Abbr": "Aug", "Sep_Abbr": "Sep", "Oct_Abbr": "Okt", "Nov_Abbr": "Nov", "Dec_Abbr": "Dez", "AM": "", "PM": "", "firstDayOfWeek": 1, "twoDigitYearMax": 2029, "mdy": "dmy", "M/d/yyyy": "dd.MM.yyyy", "dddd, MMMM dd, yyyy": "dddd, d. MMMM yyyy", "h:mm tt": "HH:mm", "h:mm:ss tt": "HH:mm:ss", "dddd, MMMM dd, yyyy h:mm:ss tt": "dddd, d. MMMM yyyy HH:mm:ss", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "dd MMMM", "MMMM, yyyy": "MMMM yyyy", "/jan(uary)?/": "jan(uar)?", "/feb(ruary)?/": "feb(ruar)?", "/mar(ch)?/": "märz", "/apr(il)?/": "apr(il)?", "/may/": "mai", "/jun(e)?/": "jun(i)?", "/jul(y)?/": "jul(i)?", "/aug(ust)?/": "aug(ust)?", "/sep(t(ember)?)?/": "sep(t(ember)?)?", "/oct(ober)?/": "okt(ober)?", "/nov(ember)?/": "nov(ember)?", "/dec(ember)?/": "dez(ember)?", "/^su(n(day)?)?/": "^sonntag", "/^mo(n(day)?)?/": "^montag", "/^tu(e(s(day)?)?)?/": "^dienstag", "/^we(d(nesday)?)?/": "^mittwoch", "/^th(u(r(s(day)?)?)?)?/": "^donnerstag", "/^fr(i(day)?)?/": "^freitag", "/^sa(t(urday)?)?/": "^samstag", "/^next/": "^nächste(r|s|n)?", "/^last|past|prev(ious)?/": "^letzte(r|s|n)?|vergangene(r|s|n)?|vorherige(r|s|n)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|(da)?nach(er)?|von|daher|in)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|(be|zu)?vor|früher)", "/^yes(terday)?/": "^gestern", "/^t(od(ay)?)?/": "^heute", "/^tom(orrow)?/": "^morgen", "/^n(ow)?/": "^jetzt|sofort|gleich", "/^ms|milli(second)?s?/": "^ms|milli(sekunde(n)?)?", "/^sec(ond)?s?/": "^sek(unde(n)?)?", "/^mn|min(ute)?s?/": "^mn|min(ute(n)?)?", "/^h(our)?s?/": "^h|st(d|unde(n)?)?", "/^w(eek)?s?/": "^w(oche(n)?)?", "/^m(onth)?s?/": "^m(onat(e)?)?", "/^d(ay)?s?/": "^d|t(ag(en)?)?", "/^y(ear)?s?/": "^y|j(ahr(en)?)?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "de-DE"; /** * @overview datejs * @version 1.0.0-rc3 * @author Gregory Wild-Smith * @copyright 2015 Gregory Wild-Smith * @license MIT * @homepage https://github.com/abritinthebay/datejs */(function () { var $D = Date; var lang = Date.CultureStrings ? Date.CultureStrings.lang : null; var loggedKeys = {}; // for debug purposes. var getText = { getFromKey: function (key, countryCode) { var output; if (Date.CultureStrings && Date.CultureStrings[countryCode] && Date.CultureStrings[countryCode][key]) { output = Date.CultureStrings[countryCode][key]; } else { output = getText.buildFromDefault(key); } if (key.charAt(0) === "/") { // Assume it's a regex output = getText.buildFromRegex(key, countryCode); } return output; }, getFromObjectValues: function (obj, countryCode) { var key, output = {}; for(key in obj) { if (obj.hasOwnProperty(key)) { output[key] = getText.getFromKey(obj[key], countryCode); } } return output; }, getFromObjectKeys: function (obj, countryCode) { var key, output = {}; for(key in obj) { if (obj.hasOwnProperty(key)) { output[getText.getFromKey(key, countryCode)] = obj[key]; } } return output; }, getFromArray: function (arr, countryCode) { var output = []; for (var i=0; i < arr.length; i++){ if (i in arr) { output[i] = getText.getFromKey(arr[i], countryCode); } } return output; }, buildFromDefault: function (key) { var output, length, split, last; switch(key) { case "name": output = "en-US"; break; case "englishName": output = "English (United States)"; break; case "nativeName": output = "English (United States)"; break; case "twoDigitYearMax": output = 2049; break; case "firstDayOfWeek": output = 0; break; default: output = key; split = key.split("_"); length = split.length; if (length > 1 && key.charAt(0) !== "/") { // if the key isn't a regex and it has a split. last = split[(length - 1)].toLowerCase(); if (last === "initial" || last === "abbr") { output = split[0]; } } break; } return output; }, buildFromRegex: function (key, countryCode) { var output; if (Date.CultureStrings && Date.CultureStrings[countryCode] && Date.CultureStrings[countryCode][key]) { output = new RegExp(Date.CultureStrings[countryCode][key], "i"); } else { output = new RegExp(key.replace(new RegExp("/", "g"),""), "i"); } return output; } }; var shallowMerge = function (obj1, obj2) { for (var attrname in obj2) { if (obj2.hasOwnProperty(attrname)) { obj1[attrname] = obj2[attrname]; } } }; var __ = function (key, language) { var countryCode = (language) ? language : lang; loggedKeys[key] = key; if (typeof key === "object") { if (key instanceof Array) { return getText.getFromArray(key, countryCode); } else { return getText.getFromObjectKeys(key, countryCode); } } else { return getText.getFromKey(key, countryCode); } }; var loadI18nScript = function (code) { // paatterned after jQuery's getScript. var url = Date.Config.i18n + code + ".js"; var head = document.getElementsByTagName("head")[0] || document.documentElement; var script = document.createElement("script"); script.src = url; var completed = false; var events = { done: function (){} // placeholder function }; // Attach handlers for all browsers script.onload = script.onreadystatechange = function() { if ( !completed && (!this.readyState || this.readyState === "loaded" || this.readyState === "complete") ) { events.done(); head.removeChild(script); } }; setTimeout(function() { head.insertBefore(script, head.firstChild); }, 0); // allows return to execute first return { done: function (cb) { events.done = function() { if (cb) { setTimeout(cb,0); } }; } }; }; var buildInfo = { buildFromMethodHash: function (obj) { var key; for(key in obj) { if (obj.hasOwnProperty(key)) { obj[key] = buildInfo[obj[key]](); } } return obj; }, timeZoneDST: function () { var DST = { "CHADT": "+1345", "NZDT": "+1300", "AEDT": "+1100", "ACDT": "+1030", "AZST": "+0500", "IRDT": "+0430", "EEST": "+0300", "CEST": "+0200", "BST": "+0100", "PMDT": "-0200", "ADT": "-0300", "NDT": "-0230", "EDT": "-0400", "CDT": "-0500", "MDT": "-0600", "PDT": "-0700", "AKDT": "-0800", "HADT": "-0900" }; return __(DST); }, timeZoneStandard: function () { var standard = { "LINT": "+1400", "TOT": "+1300", "CHAST": "+1245", "NZST": "+1200", "NFT": "+1130", "SBT": "+1100", "AEST": "+1000", "ACST": "+0930", "JST": "+0900", "CWST": "+0845", "CT": "+0800", "ICT": "+0700", "MMT": "+0630", "BST": "+0600", "NPT": "+0545", "IST": "+0530", "PKT": "+0500", "AFT": "+0430", "MSK": "+0400", "IRST": "+0330", "FET": "+0300", "EET": "+0200", "CET": "+0100", "GMT": "+0000", "UTC": "+0000", "CVT": "-0100", "GST": "-0200", "BRT": "-0300", "NST": "-0330", "AST": "-0400", "EST": "-0500", "CST": "-0600", "MST": "-0700", "PST": "-0800", "AKST": "-0900", "MIT": "-0930", "HST": "-1000", "SST": "-1100", "BIT": "-1200" }; return __(standard); }, timeZones: function (data) { var zone; data.timezones = []; for (zone in data.abbreviatedTimeZoneStandard) { if (data.abbreviatedTimeZoneStandard.hasOwnProperty(zone)) { data.timezones.push({ name: zone, offset: data.abbreviatedTimeZoneStandard[zone]}); } } for (zone in data.abbreviatedTimeZoneDST) { if (data.abbreviatedTimeZoneDST.hasOwnProperty(zone)) { data.timezones.push({ name: zone, offset: data.abbreviatedTimeZoneDST[zone], dst: true}); } } return data.timezones; }, days: function () { return __(["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"]); }, dayAbbr: function () { return __(["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"]); }, dayShortNames: function () { return __(["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"]); }, dayFirstLetters: function () { return __(["S_Sun_Initial", "M_Mon_Initial", "T_Tues_Initial", "W_Wed_Initial", "T_Thu_Initial", "F_Fri_Initial", "S_Sat_Initial"]); }, months: function () { return __(["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"]); }, monthAbbr: function () { return __(["Jan_Abbr", "Feb_Abbr", "Mar_Abbr", "Apr_Abbr", "May_Abbr", "Jun_Abbr", "Jul_Abbr", "Aug_Abbr", "Sep_Abbr", "Oct_Abbr", "Nov_Abbr", "Dec_Abbr"]); }, formatPatterns: function () { return getText.getFromObjectValues({ shortDate: "M/d/yyyy", longDate: "dddd, MMMM dd, yyyy", shortTime: "h:mm tt", longTime: "h:mm:ss tt", fullDateTime: "dddd, MMMM dd, yyyy h:mm:ss tt", sortableDateTime: "yyyy-MM-ddTHH:mm:ss", universalSortableDateTime: "yyyy-MM-dd HH:mm:ssZ", rfc1123: "ddd, dd MMM yyyy HH:mm:ss", monthDay: "MMMM dd", yearMonth: "MMMM, yyyy" }, Date.i18n.currentLanguage()); }, regex: function () { return getText.getFromObjectValues({ inTheMorning: "/( in the )(morn(ing)?)\\b/", thisMorning: "/(this )(morn(ing)?)\\b/", amThisMorning: "/(\b\\d(am)? )(this )(morn(ing)?)/", inTheEvening: "/( in the )(even(ing)?)\\b/", thisEvening: "/(this )(even(ing)?)\\b/", pmThisEvening: "/(\b\\d(pm)? )(this )(even(ing)?)/", jan: "/jan(uary)?/", feb: "/feb(ruary)?/", mar: "/mar(ch)?/", apr: "/apr(il)?/", may: "/may/", jun: "/jun(e)?/", jul: "/jul(y)?/", aug: "/aug(ust)?/", sep: "/sep(t(ember)?)?/", oct: "/oct(ober)?/", nov: "/nov(ember)?/", dec: "/dec(ember)?/", sun: "/^su(n(day)?)?/", mon: "/^mo(n(day)?)?/", tue: "/^tu(e(s(day)?)?)?/", wed: "/^we(d(nesday)?)?/", thu: "/^th(u(r(s(day)?)?)?)?/", fri: "/fr(i(day)?)?/", sat: "/^sa(t(urday)?)?/", future: "/^next/", past: "/^last|past|prev(ious)?/", add: "/^(\\+|aft(er)?|from|hence)/", subtract: "/^(\\-|bef(ore)?|ago)/", yesterday: "/^yes(terday)?/", today: "/^t(od(ay)?)?/", tomorrow: "/^tom(orrow)?/", now: "/^n(ow)?/", millisecond: "/^ms|milli(second)?s?/", second: "/^sec(ond)?s?/", minute: "/^mn|min(ute)?s?/", hour: "/^h(our)?s?/", week: "/^w(eek)?s?/", month: "/^m(onth)?s?/", day: "/^d(ay)?s?/", year: "/^y(ear)?s?/", shortMeridian: "/^(a|p)/", longMeridian: "/^(a\\.?m?\\.?|p\\.?m?\\.?)/", timezone: "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/", ordinalSuffix: "/^\\s*(st|nd|rd|th)/", timeContext: "/^\\s*(\\:|a(?!u|p)|p)/" }, Date.i18n.currentLanguage()); } }; var CultureInfo = function () { var info = getText.getFromObjectValues({ name: "name", englishName: "englishName", nativeName: "nativeName", amDesignator: "AM", pmDesignator: "PM", firstDayOfWeek: "firstDayOfWeek", twoDigitYearMax: "twoDigitYearMax", dateElementOrder: "mdy" }, Date.i18n.currentLanguage()); var constructedInfo = buildInfo.buildFromMethodHash({ dayNames: "days", abbreviatedDayNames: "dayAbbr", shortestDayNames: "dayShortNames", firstLetterDayNames: "dayFirstLetters", monthNames: "months", abbreviatedMonthNames: "monthAbbr", formatPatterns: "formatPatterns", regexPatterns: "regex", abbreviatedTimeZoneDST: "timeZoneDST", abbreviatedTimeZoneStandard: "timeZoneStandard" }); shallowMerge(info, constructedInfo); buildInfo.timeZones(info); return info; }; $D.i18n = { __: function (key, lang) { return __(key, lang); }, currentLanguage: function () { return lang || "en-US"; }, setLanguage: function (code, force, cb) { var async = false; if (force || code === "en-US" || (!!Date.CultureStrings && !!Date.CultureStrings[code])) { lang = code; Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings.lang = code; Date.CultureInfo = new CultureInfo(); } else { if (!(!!Date.CultureStrings && !!Date.CultureStrings[code])) { if (typeof exports !== "undefined" && this.exports !== exports) { // we're in a Node enviroment, load it using require try { require("../i18n/" + code + ".js"); lang = code; Date.CultureStrings.lang = code; Date.CultureInfo = new CultureInfo(); } catch (e) { // var str = "The language for '" + code + "' could not be loaded by Node. It likely does not exist."; throw new Error("The DateJS IETF language tag '" + code + "' could not be loaded by Node. It likely does not exist."); } } else if (Date.Config && Date.Config.i18n) { // we know the location of the files, so lets load them async = true; loadI18nScript(code).done(function(){ lang = code; Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings.lang = code; Date.CultureInfo = new CultureInfo(); $D.Parsing.Normalizer.buildReplaceData(); // because this is async if ($D.Grammar) { $D.Grammar.buildGrammarFormats(); // so we can parse those strings... } if (cb) { setTimeout(cb,0); } }); } else { Date.console.error("The DateJS IETF language tag '" + code + "' is not available and has not been loaded."); return false; } } } $D.Parsing.Normalizer.buildReplaceData(); // rebuild normalizer strings if ($D.Grammar) { $D.Grammar.buildGrammarFormats(); // so we can parse those strings... } if (!async && cb) { setTimeout(cb,0); } }, getLoggedKeys: function () { return loggedKeys; }, updateCultureInfo: function () { Date.CultureInfo = new CultureInfo(); } }; $D.i18n.updateCultureInfo(); // run automatically }()); (function () { var $D = Date, $P = $D.prototype, p = function (s, l) { if (!l) { l = 2; } return ("000" + s).slice(l * -1); }; if (typeof window !== "undefined" && typeof window.console !== "undefined" && typeof window.console.log !== "undefined") { $D.console = console; // used only to raise non-critical errors if available } else { // set mock so we don't give errors. $D.console = { log: function(){}, error: function(){} }; } $D.Config = $D.Config || {}; $D.initOverloads = function() { /** * Overload of Date.now. Allows an alternate call for Date.now where it returns the * current Date as an object rather than just milliseconds since the Unix Epoch. * * Also provides an implementation of now() for browsers (IE<9) that don't have it. * * Backwards compatible so with work with either: * Date.now() [returns ms] * or * Date.now(true) [returns Date] */ if (!$D.now) { $D._now = function now() { return new Date().getTime(); }; } else if (!$D._now) { $D._now = $D.now; } $D.now = function (returnObj) { if (returnObj) { return $D.present(); } else { return $D._now(); } }; if ( !$P.toISOString ) { $P.toISOString = function() { return this.getUTCFullYear() + "-" + p(this.getUTCMonth() + 1) + "-" + p(this.getUTCDate()) + "T" + p(this.getUTCHours()) + ":" + p(this.getUTCMinutes()) + ":" + p(this.getUTCSeconds()) + "." + String( (this.getUTCMilliseconds()/1000).toFixed(3)).slice(2, 5) + "Z"; }; } // private if ( $P._toString === undefined ){ $P._toString = $P.toString; } }; $D.initOverloads(); /** * Gets a date that is set to the current date. The time is set to the start of the day (00:00 or 12:00 AM). * @return {Date} The current date. */ $D.today = function () { return new Date().clearTime(); }; /** * Gets a date that is set to the current date and time (same as new Date, but chainable) * @return {Date} The current date. */ $D.present = function () { return new Date(); }; /** * Compares the first date to the second date and returns an number indication of their relative values. * @param {Date} First Date object to compare [Required]. * @param {Date} Second Date object to compare to [Required]. * @return {Number} -1 = date1 is lessthan date2. 0 = values are equal. 1 = date1 is greaterthan date2. */ $D.compare = function (date1, date2) { if (isNaN(date1) || isNaN(date2)) { throw new Error(date1 + " - " + date2); } else if (date1 instanceof Date && date2 instanceof Date) { return (date1 < date2) ? -1 : (date1 > date2) ? 1 : 0; } else { throw new TypeError(date1 + " - " + date2); } }; /** * Compares the first Date object to the second Date object and returns true if they are equal. * @param {Date} First Date object to compare [Required] * @param {Date} Second Date object to compare to [Required] * @return {Boolean} true if dates are equal. false if they are not equal. */ $D.equals = function (date1, date2) { return (date1.compareTo(date2) === 0); }; /** * Gets the language appropriate day name when given the day number(0-6) * eg - 0 == Sunday * @return {String} The day name */ $D.getDayName = function (n) { return Date.CultureInfo.dayNames[n]; }; /** * Gets the day number (0-6) if given a CultureInfo specific string which is a valid dayName, abbreviatedDayName or shortestDayName (two char). * @param {String} The name of the day (eg. "Monday, "Mon", "tuesday", "tue", "We", "we"). * @return {Number} The day number */ $D.getDayNumberFromName = function (name) { var n = Date.CultureInfo.dayNames, m = Date.CultureInfo.abbreviatedDayNames, o = Date.CultureInfo.shortestDayNames, s = name.toLowerCase(); for (var i = 0; i < n.length; i++) { if (n[i].toLowerCase() === s || m[i].toLowerCase() === s || o[i].toLowerCase() === s) { return i; } } return -1; }; /** * Gets the month number (0-11) if given a Culture Info specific string which is a valid monthName or abbreviatedMonthName. * @param {String} The name of the month (eg. "February, "Feb", "october", "oct"). * @return {Number} The day number */ $D.getMonthNumberFromName = function (name) { var n = Date.CultureInfo.monthNames, m = Date.CultureInfo.abbreviatedMonthNames, s = name.toLowerCase(); for (var i = 0; i < n.length; i++) { if (n[i].toLowerCase() === s || m[i].toLowerCase() === s) { return i; } } return -1; }; /** * Gets the language appropriate month name when given the month number(0-11) * eg - 0 == January * @return {String} The month name */ $D.getMonthName = function (n) { return Date.CultureInfo.monthNames[n]; }; /** * Determines if the current date instance is within a LeapYear. * @param {Number} The year. * @return {Boolean} true if date is within a LeapYear, otherwise false. */ $D.isLeapYear = function (year) { return ((year % 4 === 0 && year % 100 !== 0) || year % 400 === 0); }; /** * Gets the number of days in the month, given a year and month value. Automatically corrects for LeapYear. * @param {Number} The year. * @param {Number} The month (0-11). * @return {Number} The number of days in the month. */ $D.getDaysInMonth = function (year, month) { if (!month && $D.validateMonth(year)) { month = year; year = Date.today().getFullYear(); } return [31, ($D.isLeapYear(year) ? 29 : 28), 31, 30, 31, 30, 31, 31, 30, 31, 30, 31][month]; }; $P.getDaysInMonth = function () { return $D.getDaysInMonth(this.getFullYear(), this.getMonth()); }; $D.getTimezoneAbbreviation = function (offset, dst) { var p, n = (dst || false) ? Date.CultureInfo.abbreviatedTimeZoneDST : Date.CultureInfo.abbreviatedTimeZoneStandard; for (p in n) { if (n.hasOwnProperty(p)) { if (n[p] === offset) { return p; } } } return null; }; $D.getTimezoneOffset = function (name, dst) { var i, a =[], z = Date.CultureInfo.timezones; if (!name) { name = (new Date()).getTimezone();} for (i = 0; i < z.length; i++) { if (z[i].name === name.toUpperCase()) { a.push(i); } } if (!z[a[0]]) { return null; } if (a.length === 1 || !dst) { return z[a[0]].offset; } else { for (i=0; i < a.length; i++) { if (z[a[i]].dst) { return z[a[i]].offset; } } } }; $D.getQuarter = function (d) { d = d || new Date(); // If no date supplied, use today var q = [1,2,3,4]; return q[Math.floor(d.getMonth() / 3)]; // ~~~ is a bitwise op. Faster than Math.floor }; $D.getDaysLeftInQuarter = function (d) { d = d || new Date(); var qEnd = new Date(d); qEnd.setMonth(qEnd.getMonth() + 3 - qEnd.getMonth() % 3, 0); return Math.floor((qEnd - d) / 8.64e7); }; // private var validate = function (n, min, max, name) { name = name ? name : "Object"; if (typeof n === "undefined") { return false; } else if (typeof n !== "number") { throw new TypeError(n + " is not a Number."); } else if (n < min || n > max) { // As failing validation is *not* an exceptional circumstance // lets not throw a RangeError Exception here. // It's semantically correct but it's not sensible. return false; } return true; }; /** * Validates the number is within an acceptable range for milliseconds [0-999]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateMillisecond = function (value) { return validate(value, 0, 999, "millisecond"); }; /** * Validates the number is within an acceptable range for seconds [0-59]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateSecond = function (value) { return validate(value, 0, 59, "second"); }; /** * Validates the number is within an acceptable range for minutes [0-59]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateMinute = function (value) { return validate(value, 0, 59, "minute"); }; /** * Validates the number is within an acceptable range for hours [0-23]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateHour = function (value) { return validate(value, 0, 23, "hour"); }; /** * Validates the number is within an acceptable range for the days in a month [0-MaxDaysInMonth]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateDay = function (value, year, month) { if (year === undefined || year === null || month === undefined || month === null) { return false;} return validate(value, 1, $D.getDaysInMonth(year, month), "day"); }; /** * Validates the number is within an acceptable range for months [0-11]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateWeek = function (value) { return validate(value, 0, 53, "week"); }; /** * Validates the number is within an acceptable range for months [0-11]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateMonth = function (value) { return validate(value, 0, 11, "month"); }; /** * Validates the number is within an acceptable range for years. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateYear = function (value) { /** * Per ECMAScript spec the range of times supported by Date objects is * exactly -100,000,000 days to +100,000,000 days measured relative to * midnight at the beginning of 01 January, 1970 UTC. * This gives a range of 8,640,000,000,000,000 milliseconds to either * side of 01 January, 1970 UTC. * * Earliest possible date: Tue, 20 Apr 271,822 B.C. 00:00:00 UTC * Latest possible date: Sat, 13 Sep 275,760 00:00:00 UTC */ return validate(value, -271822, 275760, "year"); }; $D.validateTimezone = function(value) { var timezones = {"ACDT":1,"ACST":1,"ACT":1,"ADT":1,"AEDT":1,"AEST":1,"AFT":1,"AKDT":1,"AKST":1,"AMST":1,"AMT":1,"ART":1,"AST":1,"AWDT":1,"AWST":1,"AZOST":1,"AZT":1,"BDT":1,"BIOT":1,"BIT":1,"BOT":1,"BRT":1,"BST":1,"BTT":1,"CAT":1,"CCT":1,"CDT":1,"CEDT":1,"CEST":1,"CET":1,"CHADT":1,"CHAST":1,"CHOT":1,"ChST":1,"CHUT":1,"CIST":1,"CIT":1,"CKT":1,"CLST":1,"CLT":1,"COST":1,"COT":1,"CST":1,"CT":1,"CVT":1,"CWST":1,"CXT":1,"DAVT":1,"DDUT":1,"DFT":1,"EASST":1,"EAST":1,"EAT":1,"ECT":1,"EDT":1,"EEDT":1,"EEST":1,"EET":1,"EGST":1,"EGT":1,"EIT":1,"EST":1,"FET":1,"FJT":1,"FKST":1,"FKT":1,"FNT":1,"GALT":1,"GAMT":1,"GET":1,"GFT":1,"GILT":1,"GIT":1,"GMT":1,"GST":1,"GYT":1,"HADT":1,"HAEC":1,"HAST":1,"HKT":1,"HMT":1,"HOVT":1,"HST":1,"ICT":1,"IDT":1,"IOT":1,"IRDT":1,"IRKT":1,"IRST":1,"IST":1,"JST":1,"KGT":1,"KOST":1,"KRAT":1,"KST":1,"LHST":1,"LINT":1,"MAGT":1,"MART":1,"MAWT":1,"MDT":1,"MET":1,"MEST":1,"MHT":1,"MIST":1,"MIT":1,"MMT":1,"MSK":1,"MST":1,"MUT":1,"MVT":1,"MYT":1,"NCT":1,"NDT":1,"NFT":1,"NPT":1,"NST":1,"NT":1,"NUT":1,"NZDT":1,"NZST":1,"OMST":1,"ORAT":1,"PDT":1,"PET":1,"PETT":1,"PGT":1,"PHOT":1,"PHT":1,"PKT":1,"PMDT":1,"PMST":1,"PONT":1,"PST":1,"PYST":1,"PYT":1,"RET":1,"ROTT":1,"SAKT":1,"SAMT":1,"SAST":1,"SBT":1,"SCT":1,"SGT":1,"SLST":1,"SRT":1,"SST":1,"SYOT":1,"TAHT":1,"THA":1,"TFT":1,"TJT":1,"TKT":1,"TLT":1,"TMT":1,"TOT":1,"TVT":1,"UCT":1,"ULAT":1,"UTC":1,"UYST":1,"UYT":1,"UZT":1,"VET":1,"VLAT":1,"VOLT":1,"VOST":1,"VUT":1,"WAKT":1,"WAST":1,"WAT":1,"WEDT":1,"WEST":1,"WET":1,"WST":1,"YAKT":1,"YEKT":1,"Z":1}; return (timezones[value] === 1); }; $D.validateTimezoneOffset= function(value) { // timezones go from +14hrs to -12hrs, the +X hours are negative offsets. return (value > -841 && value < 721); }; }()); (function () { var $D = Date, $P = $D.prototype, p = function (s, l) { if (!l) { l = 2; } return ("000" + s).slice(l * -1); }; var validateConfigObject = function (obj) { var result = {}, self = this, prop, testFunc; testFunc = function (prop, func, value) { if (prop === "day") { var month = (obj.month !== undefined) ? obj.month : self.getMonth(); var year = (obj.year !== undefined) ? obj.year : self.getFullYear(); return $D[func](value, year, month); } else { return $D[func](value); } }; for (prop in obj) { if (Object.prototype.hasOwnProperty.call(obj, prop)) { var func = "validate" + prop.charAt(0).toUpperCase() + prop.slice(1); if ($D[func] && obj[prop] !== null && testFunc(prop, func, obj[prop])) { result[prop] = obj[prop]; } } } return result; }; /** * Resets the time of this Date object to 12:00 AM (00:00), which is the start of the day. * @param {Boolean} .clone() this date instance before clearing Time * @return {Date} this */ $P.clearTime = function () { this.setHours(0); this.setMinutes(0); this.setSeconds(0); this.setMilliseconds(0); return this; }; /** * Resets the time of this Date object to the current time ('now'). * @return {Date} this */ $P.setTimeToNow = function () { var n = new Date(); this.setHours(n.getHours()); this.setMinutes(n.getMinutes()); this.setSeconds(n.getSeconds()); this.setMilliseconds(n.getMilliseconds()); return this; }; /** * Returns a new Date object that is an exact date and time copy of the original instance. * @return {Date} A new Date instance */ $P.clone = function () { return new Date(this.getTime()); }; /** * Compares this instance to a Date object and returns an number indication of their relative values. * @param {Date} Date object to compare [Required] * @return {Number} -1 = this is lessthan date. 0 = values are equal. 1 = this is greaterthan date. */ $P.compareTo = function (date) { return Date.compare(this, date); }; /** * Compares this instance to another Date object and returns true if they are equal. * @param {Date} Date object to compare. If no date to compare, new Date() [now] is used. * @return {Boolean} true if dates are equal. false if they are not equal. */ $P.equals = function (date) { return Date.equals(this, (date !== undefined ? date : new Date())); }; /** * Determines if this instance is between a range of two dates or equal to either the start or end dates. * @param {Date} Start of range [Required] * @param {Date} End of range [Required] * @return {Boolean} true is this is between or equal to the start and end dates, else false */ $P.between = function (start, end) { return this.getTime() >= start.getTime() && this.getTime() <= end.getTime(); }; /** * Determines if this date occurs after the date to compare to. * @param {Date} Date object to compare. If no date to compare, new Date() ("now") is used. * @return {Boolean} true if this date instance is greater than the date to compare to (or "now"), otherwise false. */ $P.isAfter = function (date) { return this.compareTo(date || new Date()) === 1; }; /** * Determines if this date occurs before the date to compare to. * @param {Date} Date object to compare. If no date to compare, new Date() ("now") is used. * @return {Boolean} true if this date instance is less than the date to compare to (or "now"). */ $P.isBefore = function (date) { return (this.compareTo(date || new Date()) === -1); }; /** * Determines if the current Date instance occurs today. * @return {Boolean} true if this date instance is 'today', otherwise false. */ /** * Determines if the current Date instance occurs on the same Date as the supplied 'date'. * If no 'date' to compare to is provided, the current Date instance is compared to 'today'. * @param {date} Date object to compare. If no date to compare, the current Date ("now") is used. * @return {Boolean} true if this Date instance occurs on the same Day as the supplied 'date'. */ $P.isToday = $P.isSameDay = function (date) { return this.clone().clearTime().equals((date || new Date()).clone().clearTime()); }; /** * Adds the specified number of milliseconds to this instance. * @param {Number} The number of milliseconds to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addMilliseconds = function (value) { if (!value) { return this; } this.setTime(this.getTime() + value * 1); return this; }; /** * Adds the specified number of seconds to this instance. * @param {Number} The number of seconds to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addSeconds = function (value) { if (!value) { return this; } return this.addMilliseconds(value * 1000); }; /** * Adds the specified number of seconds to this instance. * @param {Number} The number of seconds to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addMinutes = function (value) { if (!value) { return this; } return this.addMilliseconds(value * 60000); // 60*1000 }; /** * Adds the specified number of hours to this instance. * @param {Number} The number of hours to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addHours = function (value) { if (!value) { return this; } return this.addMilliseconds(value * 3600000); // 60*60*1000 }; /** * Adds the specified number of days to this instance. * @param {Number} The number of days to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addDays = function (value) { if (!value) { return this; } this.setDate(this.getDate() + value * 1); return this; }; /** * Adds the specified number of weekdays (ie - not sat or sun) to this instance. * @param {Number} The number of days to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addWeekdays = function (value) { if (!value) { return this; } var day = this.getDay(); var weeks = (Math.ceil(Math.abs(value)/7)); if (day === 0 || day === 6) { if (value > 0) { this.next().monday(); this.addDays(-1); day = this.getDay(); } } if (value < 0) { while (value < 0) { this.addDays(-1); day = this.getDay(); if (day !== 0 && day !== 6) { value++; } } return this; } else if (value > 5 || (6-day) <= value) { value = value + (weeks * 2); } return this.addDays(value); }; /** * Adds the specified number of weeks to this instance. * @param {Number} The number of weeks to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addWeeks = function (value) { if (!value) { return this; } return this.addDays(value * 7); }; /** * Adds the specified number of months to this instance. * @param {Number} The number of months to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addMonths = function (value) { if (!value) { return this; } var n = this.getDate(); this.setDate(1); this.setMonth(this.getMonth() + value * 1); this.setDate(Math.min(n, $D.getDaysInMonth(this.getFullYear(), this.getMonth()))); return this; }; $P.addQuarters = function (value) { if (!value) { return this; } // note this will take you to the same point in the quarter as you are now. // i.e. - if you are 15 days into the quarter you'll be 15 days into the resulting one. // bonus: this allows adding fractional quarters return this.addMonths(value * 3); }; /** * Adds the specified number of years to this instance. * @param {Number} The number of years to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addYears = function (value) { if (!value) { return this; } return this.addMonths(value * 12); }; /** * Adds (or subtracts) to the value of the years, months, weeks, days, hours, minutes, seconds, milliseconds of the date instance using given configuration object. Positive and Negative values allowed. * Example

	Date.today().add( { days: 1, months: 1 } )

	new Date().add( { years: -1 } )
	
* @param {Object} Configuration object containing attributes (months, days, etc.) * @return {Date} this */ $P.add = function (config) { if (typeof config === "number") { this._orient = config; return this; } var x = config; if (x.day) { // If we should be a different date than today (eg: for 'tomorrow -1d', etc). // Should only effect parsing, not direct usage (eg, Finish and FinishExact) if ((x.day - this.getDate()) !== 0) { this.setDate(x.day); } } if (x.milliseconds) { this.addMilliseconds(x.milliseconds); } if (x.seconds) { this.addSeconds(x.seconds); } if (x.minutes) { this.addMinutes(x.minutes); } if (x.hours) { this.addHours(x.hours); } if (x.weeks) { this.addWeeks(x.weeks); } if (x.months) { this.addMonths(x.months); } if (x.years) { this.addYears(x.years); } if (x.days) { this.addDays(x.days); } return this; }; /** * Get the week number. Week one (1) is the week which contains the first Thursday of the year. Monday is considered the first day of the week. * The .getWeek() function does NOT convert the date to UTC. The local datetime is used. * Please use .getISOWeek() to get the week of the UTC converted date. * @return {Number} 1 to 53 */ $P.getWeek = function (utc) { // Create a copy of this date object var self, target = new Date(this.valueOf()); if (utc) { target.addMinutes(target.getTimezoneOffset()); self = target.clone(); } else { self = this; } // ISO week date weeks start on monday // so correct the day number var dayNr = (self.getDay() + 6) % 7; // ISO 8601 states that week 1 is the week // with the first thursday of that year. // Set the target date to the thursday in the target week target.setDate(target.getDate() - dayNr + 3); // Store the millisecond value of the target date var firstThursday = target.valueOf(); // Set the target to the first thursday of the year // First set the target to january first target.setMonth(0, 1); // Not a thursday? Correct the date to the next thursday if (target.getDay() !== 4) { target.setMonth(0, 1 + ((4 - target.getDay()) + 7) % 7); } // The weeknumber is the number of weeks between the // first thursday of the year and the thursday in the target week return 1 + Math.ceil((firstThursday - target) / 604800000); // 604800000 = 7 * 24 * 3600 * 1000 }; /** * Get the ISO 8601 week number. Week one ("01") is the week which contains the first Thursday of the year. Monday is considered the first day of the week. * The .getISOWeek() function does convert the date to it's UTC value. Please use .getWeek() to get the week of the local date. * @return {String} "01" to "53" */ $P.getISOWeek = function () { return p(this.getWeek(true)); }; /** * Moves the date to Monday of the week set. Week one (1) is the week which contains the first Thursday of the year. * @param {Number} A Number (1 to 53) that represents the week of the year. * @return {Date} this */ $P.setWeek = function (n) { if ((n - this.getWeek()) === 0) { if (this.getDay() !== 1) { return this.moveToDayOfWeek(1, (this.getDay() > 1 ? -1 : 1)); } else { return this; } } else { return this.moveToDayOfWeek(1, (this.getDay() > 1 ? -1 : 1)).addWeeks(n - this.getWeek()); } }; $P.setQuarter = function (qtr) { var month = Math.abs(((qtr-1) * 3) + 1); return this.setMonth(month, 1); }; $P.getQuarter = function () { return Date.getQuarter(this); }; $P.getDaysLeftInQuarter = function () { return Date.getDaysLeftInQuarter(this); }; /** * Moves the date to the next n'th occurrence of the dayOfWeek starting from the beginning of the month. The number (-1) is a magic number and will return the last occurrence of the dayOfWeek in the month. * @param {Number} The dayOfWeek to move to * @param {Number} The n'th occurrence to move to. Use (-1) to return the last occurrence in the month * @return {Date} this */ $P.moveToNthOccurrence = function (dayOfWeek, occurrence) { if (dayOfWeek === "Weekday") { if (occurrence > 0) { this.moveToFirstDayOfMonth(); if (this.is().weekday()) { occurrence -= 1; } } else if (occurrence < 0) { this.moveToLastDayOfMonth(); if (this.is().weekday()) { occurrence += 1; } } else { return this; } return this.addWeekdays(occurrence); } var shift = 0; if (occurrence > 0) { shift = occurrence - 1; } else if (occurrence === -1) { this.moveToLastDayOfMonth(); if (this.getDay() !== dayOfWeek) { this.moveToDayOfWeek(dayOfWeek, -1); } return this; } return this.moveToFirstDayOfMonth().addDays(-1).moveToDayOfWeek(dayOfWeek, +1).addWeeks(shift); }; var moveToN = function (getFunc, addFunc, nVal) { return function (value, orient) { var diff = (value - this[getFunc]() + nVal * (orient || +1)) % nVal; return this[addFunc]((diff === 0) ? diff += nVal * (orient || +1) : diff); }; }; /** * Move to the next or last dayOfWeek based on the orient value. * @param {Number} The dayOfWeek to move to * @param {Number} Forward (+1) or Back (-1). Defaults to +1. [Optional] * @return {Date} this */ $P.moveToDayOfWeek = moveToN("getDay", "addDays", 7); /** * Move to the next or last month based on the orient value. * @param {Number} The month to move to. 0 = January, 11 = December * @param {Number} Forward (+1) or Back (-1). Defaults to +1. [Optional] * @return {Date} this */ $P.moveToMonth = moveToN("getMonth", "addMonths", 12); /** * Get the Ordinate of the current day ("th", "st", "rd"). * @return {String} */ $P.getOrdinate = function () { var num = this.getDate(); return ord(num); }; /** * Get the Ordinal day (numeric day number) of the year, adjusted for leap year. * @return {Number} 1 through 365 (366 in leap years) */ $P.getOrdinalNumber = function () { return Math.ceil((this.clone().clearTime() - new Date(this.getFullYear(), 0, 1)) / 86400000) + 1; }; /** * Get the time zone abbreviation of the current date. * @return {String} The abbreviated time zone name (e.g. "EST") */ $P.getTimezone = function () { return $D.getTimezoneAbbreviation(this.getUTCOffset(), this.isDaylightSavingTime()); }; $P.setTimezoneOffset = function (offset) { var here = this.getTimezoneOffset(), there = Number(offset) * -6 / 10; return (there || there === 0) ? this.addMinutes(there - here) : this; }; $P.setTimezone = function (offset) { return this.setTimezoneOffset($D.getTimezoneOffset(offset)); }; /** * Indicates whether Daylight Saving Time is observed in the current time zone. * @return {Boolean} true|false */ $P.hasDaylightSavingTime = function () { return (Date.today().set({month: 0, day: 1}).getTimezoneOffset() !== Date.today().set({month: 6, day: 1}).getTimezoneOffset()); }; /** * Indicates whether this Date instance is within the Daylight Saving Time range for the current time zone. * @return {Boolean} true|false */ $P.isDaylightSavingTime = function () { return Date.today().set({month: 0, day: 1}).getTimezoneOffset() !== this.getTimezoneOffset(); }; /** * Get the offset from UTC of the current date. * @return {String} The 4-character offset string prefixed with + or - (e.g. "-0500") */ $P.getUTCOffset = function (offset) { var n = (offset || this.getTimezoneOffset()) * -10 / 6, r; if (n < 0) { r = (n - 10000).toString(); return r.charAt(0) + r.substr(2); } else { r = (n + 10000).toString(); return "+" + r.substr(1); } }; /** * Returns the number of milliseconds between this date and date. * @param {Date} Defaults to now * @return {Number} The diff in milliseconds */ $P.getElapsed = function (date) { return (date || new Date()) - this; }; /** * Set the value of year, month, day, hour, minute, second, millisecond of date instance using given configuration object. * Example

	Date.today().set( { day: 20, month: 1 } )

	new Date().set( { millisecond: 0 } )
	
* * @param {Object} Configuration object containing attributes (month, day, etc.) * @return {Date} this */ $P.set = function (config) { config = validateConfigObject.call(this, config); var key; for (key in config) { if (Object.prototype.hasOwnProperty.call(config, key)) { var name = key.charAt(0).toUpperCase() + key.slice(1); var addFunc, getFunc; if (key !== "week" && key !== "month" && key !== "timezone" && key !== "timezoneOffset") { name += "s"; } addFunc = "add" + name; getFunc = "get" + name; if (key === "month") { addFunc = addFunc + "s"; } else if (key === "year"){ getFunc = "getFullYear"; } if (key !== "day" && key !== "timezone" && key !== "timezoneOffset" && key !== "week" && key !== "hour") { this[addFunc](config[key] - this[getFunc]()); } else if ( key === "timezone"|| key === "timezoneOffset" || key === "week" || key === "hour") { this["set"+name](config[key]); } } } // day has to go last because you can't validate the day without first knowing the month if (config.day) { this.addDays(config.day - this.getDate()); } return this; }; /** * Moves the date to the first day of the month. * @return {Date} this */ $P.moveToFirstDayOfMonth = function () { return this.set({ day: 1 }); }; /** * Moves the date to the last day of the month. * @return {Date} this */ $P.moveToLastDayOfMonth = function () { return this.set({ day: $D.getDaysInMonth(this.getFullYear(), this.getMonth())}); }; /** * Converts the value of the current Date object to its equivalent string representation. * Format Specifiers * CUSTOM DATE AND TIME FORMAT STRINGS * Format Description Example * ------ --------------------------------------------------------------------------- ----------------------- * s The seconds of the minute between 0-59. "0" to "59" * ss The seconds of the minute with leading zero if required. "00" to "59" * * m The minute of the hour between 0-59. "0" or "59" * mm The minute of the hour with leading zero if required. "00" or "59" * * h The hour of the day between 1-12. "1" to "12" * hh The hour of the day with leading zero if required. "01" to "12" * * H The hour of the day between 0-23. "0" to "23" * HH The hour of the day with leading zero if required. "00" to "23" * * d The day of the month between 1 and 31. "1" to "31" * dd The day of the month with leading zero if required. "01" to "31" * ddd Abbreviated day name. Date.CultureInfo.abbreviatedDayNames. "Mon" to "Sun" * dddd The full day name. Date.CultureInfo.dayNames. "Monday" to "Sunday" * * M The month of the year between 1-12. "1" to "12" * MM The month of the year with leading zero if required. "01" to "12" * MMM Abbreviated month name. Date.CultureInfo.abbreviatedMonthNames. "Jan" to "Dec" * MMMM The full month name. Date.CultureInfo.monthNames. "January" to "December" * * yy The year as a two-digit number. "99" or "08" * yyyy The full four digit year. "1999" or "2008" * * t Displays the first character of the A.M./P.M. designator. "A" or "P" * Date.CultureInfo.amDesignator or Date.CultureInfo.pmDesignator * tt Displays the A.M./P.M. designator. "AM" or "PM" * Date.CultureInfo.amDesignator or Date.CultureInfo.pmDesignator * * S The ordinal suffix ("st, "nd", "rd" or "th") of the current day. "st, "nd", "rd" or "th" * * STANDARD DATE AND TIME FORMAT STRINGS * Format Description Example *------ --------------------------------------------------------------------------- ----------------------- * d The CultureInfo shortDate Format Pattern "M/d/yyyy" * D The CultureInfo longDate Format Pattern "dddd, MMMM dd, yyyy" * F The CultureInfo fullDateTime Format Pattern "dddd, MMMM dd, yyyy h:mm:ss tt" * m The CultureInfo monthDay Format Pattern "MMMM dd" * r The CultureInfo rfc1123 Format Pattern "ddd, dd MMM yyyy HH:mm:ss GMT" * s The CultureInfo sortableDateTime Format Pattern "yyyy-MM-ddTHH:mm:ss" * t The CultureInfo shortTime Format Pattern "h:mm tt" * T The CultureInfo longTime Format Pattern "h:mm:ss tt" * u The CultureInfo universalSortableDateTime Format Pattern "yyyy-MM-dd HH:mm:ssZ" * y The CultureInfo yearMonth Format Pattern "MMMM, yyyy" * * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @return {String} A string representation of the current Date object. */ var ord = function (n) { switch (n * 1) { case 1: case 21: case 31: return "st"; case 2: case 22: return "nd"; case 3: case 23: return "rd"; default: return "th"; } }; var parseStandardFormats = function (format) { var y, c = Date.CultureInfo.formatPatterns; switch (format) { case "d": return this.toString(c.shortDate); case "D": return this.toString(c.longDate); case "F": return this.toString(c.fullDateTime); case "m": return this.toString(c.monthDay); case "r": case "R": y = this.clone().addMinutes(this.getTimezoneOffset()); return y.toString(c.rfc1123) + " GMT"; case "s": return this.toString(c.sortableDateTime); case "t": return this.toString(c.shortTime); case "T": return this.toString(c.longTime); case "u": y = this.clone().addMinutes(this.getTimezoneOffset()); return y.toString(c.universalSortableDateTime); case "y": return this.toString(c.yearMonth); default: return false; } }; var parseFormatStringsClosure = function (context) { return function (m) { if (m.charAt(0) === "\\") { return m.replace("\\", ""); } switch (m) { case "hh": return p(context.getHours() < 13 ? (context.getHours() === 0 ? 12 : context.getHours()) : (context.getHours() - 12)); case "h": return context.getHours() < 13 ? (context.getHours() === 0 ? 12 : context.getHours()) : (context.getHours() - 12); case "HH": return p(context.getHours()); case "H": return context.getHours(); case "mm": return p(context.getMinutes()); case "m": return context.getMinutes(); case "ss": return p(context.getSeconds()); case "s": return context.getSeconds(); case "yyyy": return p(context.getFullYear(), 4); case "yy": return p(context.getFullYear()); case "y": return context.getFullYear(); case "E": case "dddd": return Date.CultureInfo.dayNames[context.getDay()]; case "ddd": return Date.CultureInfo.abbreviatedDayNames[context.getDay()]; case "dd": return p(context.getDate()); case "d": return context.getDate(); case "MMMM": return Date.CultureInfo.monthNames[context.getMonth()]; case "MMM": return Date.CultureInfo.abbreviatedMonthNames[context.getMonth()]; case "MM": return p((context.getMonth() + 1)); case "M": return context.getMonth() + 1; case "t": return context.getHours() < 12 ? Date.CultureInfo.amDesignator.substring(0, 1) : Date.CultureInfo.pmDesignator.substring(0, 1); case "tt": return context.getHours() < 12 ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator; case "S": return ord(context.getDate()); case "W": return context.getWeek(); case "WW": return context.getISOWeek(); case "Q": return "Q" + context.getQuarter(); case "q": return String(context.getQuarter()); case "z": return context.getTimezone(); case "Z": case "X": return Date.getTimezoneOffset(context.getTimezone()); case "ZZ": // Timezone offset in seconds return context.getTimezoneOffset() * -60; case "u": return context.getDay(); case "L": return ($D.isLeapYear(context.getFullYear())) ? 1 : 0; case "B": // Swatch Internet Time (.beats) return "@"+((context.getUTCSeconds() + (context.getUTCMinutes()*60) + ((context.getUTCHours()+1)*3600))/86.4); default: return m; } }; }; $P.toString = function (format, ignoreStandards) { // Standard Date and Time Format Strings. Formats pulled from CultureInfo file and // may vary by culture. if (!ignoreStandards && format && format.length === 1) { output = parseStandardFormats.call(this, format); if (output) { return output; } } var parseFormatStrings = parseFormatStringsClosure(this); return format ? format.replace(/((\\)?(dd?d?d?|MM?M?M?|yy?y?y?|hh?|HH?|mm?|ss?|tt?|S|q|Q|WW?W?W?)(?![^\[]*\]))/g, parseFormatStrings).replace(/\[|\]/g, "") : this._toString(); }; }()); /************************************************************* * SugarPak - Domain Specific Language - Syntactical Sugar * *************************************************************/ (function () { var $D = Date, $P = $D.prototype, $N = Number.prototype; // private $P._orient = +1; // private $P._nth = null; // private $P._is = false; // private $P._same = false; // private $P._isSecond = false; // private $N._dateElement = "days"; /** * Moves the date to the next instance of a date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.today().next().friday();
	Date.today().next().fri();
	Date.today().next().march();
	Date.today().next().mar();
	Date.today().next().week();
	
* * @return {Date} date */ $P.next = function () { this._move = true; this._orient = +1; return this; }; /** * Creates a new Date (Date.today()) and moves the date to the next instance of the date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.next().friday();
	Date.next().fri();
	Date.next().march();
	Date.next().mar();
	Date.next().week();
	
* * @return {Date} date */ $D.next = function () { return $D.today().next(); }; /** * Moves the date to the previous instance of a date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.today().last().friday();
	Date.today().last().fri();
	Date.today().last().march();
	Date.today().last().mar();
	Date.today().last().week();
	
* * @return {Date} date */ $P.last = $P.prev = $P.previous = function () { this._move = true; this._orient = -1; return this; }; /** * Creates a new Date (Date.today()) and moves the date to the previous instance of the date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.last().friday();
	Date.last().fri();
	Date.previous().march();
	Date.prev().mar();
	Date.last().week();
	
* * @return {Date} date */ $D.last = $D.prev = $D.previous = function () { return $D.today().last(); }; /** * Performs a equality check when followed by either a month name, day name or .weekday() function. * Example

	Date.today().is().friday(); // true|false
	Date.today().is().fri();
	Date.today().is().march();
	Date.today().is().mar();
	
* * @return {Boolean} true|false */ $P.is = function () { this._is = true; return this; }; /** * Determines if two date objects occur on/in exactly the same instance of the subsequent date part function. * The function .same() must be followed by a date part function (example: .day(), .month(), .year(), etc). * * An optional Date can be passed in the date part function. If now date is passed as a parameter, 'Now' is used. * * The following example demonstrates how to determine if two dates fall on the exact same day. * * Example

	var d1 = Date.today(); // today at 00:00
	var d2 = new Date();   // exactly now.

	// Do they occur on the same day?
	d1.same().day(d2); // true
	
	// Do they occur on the same hour?
	d1.same().hour(d2); // false, unless d2 hour is '00' (midnight).
	
	// What if it's the same day, but one year apart?
	var nextYear = Date.today().add(1).year();

	d1.same().day(nextYear); // false, because the dates must occur on the exact same day. 
	
* * Scenario: Determine if a given date occurs during some week period 2 months from now. * * Example

	var future = Date.today().add(2).months();
	return someDate.same().week(future); // true|false;
	
* * @return {Boolean} true|false */ $P.same = function () { this._same = true; this._isSecond = false; return this; }; /** * Determines if the current date/time occurs during Today. Must be preceded by the .is() function. * Example

	someDate.is().today();    // true|false
	new Date().is().today();  // true
	Date.today().is().today();// true
	Date.today().add(-1).day().is().today(); // false
	
* * @return {Boolean} true|false */ $P.today = function () { return this.same().day(); }; /** * Determines if the current date is a weekday. This function must be preceded by the .is() function. * Example

	Date.today().is().weekday(); // true|false
	
* * @return {Boolean} true|false */ $P.weekday = function () { if (this._nth) { return df("Weekday").call(this); } if (this._move) { return this.addWeekdays(this._orient); } if (this._is) { this._is = false; return (!this.is().sat() && !this.is().sun()); } return false; }; /** * Determines if the current date is on the weekend. This function must be preceded by the .is() function. * Example

	Date.today().is().weekend(); // true|false
	
* * @return {Boolean} true|false */ $P.weekend = function () { if (this._is) { this._is = false; return (this.is().sat() || this.is().sun()); } return false; }; /** * Sets the Time of the current Date instance. A string "6:15 pm" or config object {hour:18, minute:15} are accepted. * Example

	// Set time to 6:15pm with a String
	Date.today().at("6:15pm");

	// Set time to 6:15pm with a config object
	Date.today().at({hour:18, minute:15});
	
* * @return {Date} date */ $P.at = function (time) { return (typeof time === "string") ? $D.parse(this.toString("d") + " " + time) : this.set(time); }; /** * Creates a new Date() and adds this (Number) to the date based on the preceding date element function (eg. second|minute|hour|day|month|year). * Example

	// Undeclared Numbers must be wrapped with parentheses. Requirment of JavaScript.
	(3).days().fromNow();
	(6).months().fromNow();

	// Declared Number variables do not require parentheses. 
	var n = 6;
	n.months().fromNow();
	
* * @return {Date} A new Date instance */ $N.fromNow = $N.after = function (date) { var c = {}; c[this._dateElement] = this; return ((!date) ? new Date() : date.clone()).add(c); }; /** * Creates a new Date() and subtract this (Number) from the date based on the preceding date element function (eg. second|minute|hour|day|month|year). * Example

	// Undeclared Numbers must be wrapped with parentheses. Requirment of JavaScript.
	(3).days().ago();
	(6).months().ago();

	// Declared Number variables do not require parentheses. 
	var n = 6;
	n.months().ago();
	
* * @return {Date} A new Date instance */ $N.ago = $N.before = function (date) { var c = {}, s = (this._dateElement[this._dateElement.length-1] !== "s") ? this._dateElement + "s" : this._dateElement; c[s] = this * -1; return ((!date) ? new Date() : date.clone()).add(c); }; // Do NOT modify the following string tokens. These tokens are used to build dynamic functions. // All culture-specific strings can be found in the CultureInfo files. var dx = ("sunday monday tuesday wednesday thursday friday saturday").split(/\s/), mx = ("january february march april may june july august september october november december").split(/\s/), px = ("Millisecond Second Minute Hour Day Week Month Year Quarter Weekday").split(/\s/), pxf = ("Milliseconds Seconds Minutes Hours Date Week Month FullYear Quarter").split(/\s/), nth = ("final first second third fourth fifth").split(/\s/), de; /** * Returns an object literal of all the date parts. * Example

	var o = new Date().toObject();
	
	// { year: 2008, month: 4, week: 20, day: 13, hour: 18, minute: 9, second: 32, millisecond: 812 }
	
	// The object properties can be referenced directly from the object.
	
	alert(o.day);  // alerts "13"
	alert(o.year); // alerts "2008"
	
* * @return {Date} An object literal representing the original date object. */ $P.toObject = function () { var o = {}; for (var i = 0; i < px.length; i++) { if (this["get" + pxf[i]]) { o[px[i].toLowerCase()] = this["get" + pxf[i]](); } } return o; }; /** * Returns a date created from an object literal. Ignores the .week property if set in the config. * Example

	var o = new Date().toObject();
	
	return Date.fromObject(o); // will return the same date. 

	var o2 = {month: 1, day: 20, hour: 18}; // birthday party!
	Date.fromObject(o2);
	
* * @return {Date} An object literal representing the original date object. */ $D.fromObject = function(config) { config.week = null; return Date.today().set(config); }; // Create day name functions and abbreviated day name functions (eg. monday(), friday(), fri()). var df = function (n) { return function () { if (this._is) { this._is = false; return this.getDay() === n; } if (this._move) { this._move = null; } if (this._nth !== null) { // If the .second() function was called earlier, remove the _orient // from the date, and then continue. // This is required because 'second' can be used in two different context. // // Example // // Date.today().add(1).second(); // Date.march().second().monday(); // // Things get crazy with the following... // Date.march().add(1).second().second().monday(); // but it works!! // if (this._isSecond) { this.addSeconds(this._orient * -1); } // make sure we reset _isSecond this._isSecond = false; var ntemp = this._nth; this._nth = null; var temp = this.clone().moveToLastDayOfMonth(); this.moveToNthOccurrence(n, ntemp); if (this > temp) { throw new RangeError($D.getDayName(n) + " does not occur " + ntemp + " times in the month of " + $D.getMonthName(temp.getMonth()) + " " + temp.getFullYear() + "."); } return this; } return this.moveToDayOfWeek(n, this._orient); }; }; var sdf = function (n) { return function () { var t = $D.today(), shift = n - t.getDay(); if (n === 0 && Date.CultureInfo.firstDayOfWeek === 1 && t.getDay() !== 0) { shift = shift + 7; } return t.addDays(shift); }; }; // Create month name functions and abbreviated month name functions (eg. january(), march(), mar()). var month_instance_functions = function (n) { return function () { if (this._is) { this._is = false; return this.getMonth() === n; } return this.moveToMonth(n, this._orient); }; }; var month_static_functions = function (n) { return function () { return $D.today().set({ month: n, day: 1 }); }; }; var processTerms = function (names, staticFunc, instanceFunc) { for (var i = 0; i < names.length; i++) { // Create constant static Name variables. $D[names[i].toUpperCase()] = $D[names[i].toUpperCase().substring(0, 3)] = i; // Create Name functions. $D[names[i]] = $D[names[i].substring(0, 3)] = staticFunc(i); // Create Name instance functions. $P[names[i]] = $P[names[i].substring(0, 3)] = instanceFunc(i); } }; processTerms(dx, sdf, df); processTerms(mx, month_static_functions, month_instance_functions); // Create date element functions and plural date element functions used with Date (eg. day(), days(), months()). var ef = function (j) { return function () { // if the .second() function was called earlier, the _orient // has alread been added. Just return this and reset _isSecond. if (this._isSecond) { this._isSecond = false; return this; } if (this._same) { this._same = this._is = false; var o1 = this.toObject(), o2 = (arguments[0] || new Date()).toObject(), v = "", k = j.toLowerCase(); // the substr trick with -1 doesn't work in IE8 or less k = (k[k.length-1] === "s") ? k.substring(0,k.length-1) : k; for (var m = (px.length - 1); m > -1; m--) { v = px[m].toLowerCase(); if (o1[v] !== o2[v]) { return false; } if (k === v) { break; } } return true; } if (j.substring(j.length - 1) !== "s") { j += "s"; } if (this._move) { this._move = null; } return this["add" + j](this._orient); }; }; var nf = function (n) { return function () { this._dateElement = n; return this; }; }; for (var k = 0; k < px.length; k++) { de = px[k].toLowerCase(); if(de !== "weekday") { // Create date element functions and plural date element functions used with Date (eg. day(), days(), months()). $P[de] = $P[de + "s"] = ef(px[k]); // Create date element functions and plural date element functions used with Number (eg. day(), days(), months()). $N[de] = $N[de + "s"] = nf(de + "s"); } } $P._ss = ef("Second"); var nthfn = function (n) { return function (dayOfWeek) { if (this._same) { return this._ss(arguments[0]); } if (dayOfWeek || dayOfWeek === 0) { return this.moveToNthOccurrence(dayOfWeek, n); } this._nth = n; // if the operator is 'second' add the _orient, then deal with it later... if (n === 2 && (dayOfWeek === undefined || dayOfWeek === null)) { this._isSecond = true; return this.addSeconds(this._orient); } return this; }; }; for (var l = 0; l < nth.length; l++) { $P[nth[l]] = (l === 0) ? nthfn(-1) : nthfn(l); } }()); (function () { "use strict"; Date.Parsing = { Exception: function (s) { this.message = "Parse error at '" + s.substring(0, 10) + " ...'"; } }; var $P = Date.Parsing; var dayOffsets = { standard: [0,31,59,90,120,151,181,212,243,273,304,334], leap: [0,31,60,91,121,152,182,213,244,274,305,335] }; $P.isLeapYear = function(year) { return ((year % 4 === 0) && (year % 100 !== 0)) || (year % 400 === 0); }; var utils = { multiReplace : function (str, hash ) { var key; for (key in hash) { if (Object.prototype.hasOwnProperty.call(hash, key)) { var regex; if (typeof hash[key] === "function") { } else { regex = (hash[key] instanceof RegExp) ? hash[key] : new RegExp(hash[key], "g"); } str = str.replace(regex, key); } } return str; }, getDayOfYearFromWeek : function (obj) { var d, jan4, offset; obj.weekDay = (!obj.weekDay && obj.weekDay !== 0) ? 1 : obj.weekDay; d = new Date(obj.year, 0, 4); jan4 = d.getDay() === 0 ? 7 : d.getDay(); // JS is 0 indexed on Sunday. offset = jan4+3; obj.dayOfYear = ((obj.week * 7) + (obj.weekDay === 0 ? 7 : obj.weekDay))-offset; return obj; }, getDayOfYear : function (obj, dayOffset) { if (!obj.dayOfYear) { obj = utils.getDayOfYearFromWeek(obj); } for (var i=0;i <= dayOffset.length;i++) { if (obj.dayOfYear < dayOffset[i] || i === dayOffset.length) { obj.day = obj.day ? obj.day : (obj.dayOfYear - dayOffset[i-1]); break; } else { obj.month = i; } } return obj; }, adjustForTimeZone : function (obj, date) { var offset; if (obj.zone.toUpperCase() === "Z" || (obj.zone_hours === 0 && obj.zone_minutes === 0)) { // it's UTC/GML so work out the current timeszone offset offset = -date.getTimezoneOffset(); } else { offset = (obj.zone_hours*60) + (obj.zone_minutes || 0); if (obj.zone_sign === "+") { offset *= -1; } offset -= date.getTimezoneOffset(); } date.setMinutes(date.getMinutes()+offset); return date; }, setDefaults : function (obj) { obj.year = obj.year || Date.today().getFullYear(); obj.hours = obj.hours || 0; obj.minutes = obj.minutes || 0; obj.seconds = obj.seconds || 0; obj.milliseconds = obj.milliseconds || 0; if (!(!obj.month && (obj.week || obj.dayOfYear))) { // if we have a month, or if we don't but don't have the day calculation data obj.month = obj.month || 0; obj.day = obj.day || 1; } return obj; }, dataNum: function (data, mod, explict, postProcess) { var dataNum = data*1; if (mod) { if (postProcess) { return data ? mod(data)*1 : data; } else { return data ? mod(dataNum) : data; } } else if (!explict){ return data ? dataNum : data; } else { return (data && typeof data !== "undefined") ? dataNum : data; } }, timeDataProcess: function (obj) { var timeObj = {}; for (var x in obj.data) { if (obj.data.hasOwnProperty(x)) { timeObj[x] = obj.ignore[x] ? obj.data[x] : utils.dataNum(obj.data[x], obj.mods[x], obj.explict[x], obj.postProcess[x]); } } if (obj.data.secmins) { obj.data.secmins = obj.data.secmins.replace(",", ".") * 60; if (!timeObj.minutes) { timeObj.minutes = obj.data.secmins; } else if (!timeObj.seconds) { timeObj.seconds = obj.data.secmins; } delete obj.secmins; } return timeObj; }, buildTimeObjectFromData: function (data) { var time = utils.timeDataProcess({ data: { year : data[1], month : data[5], day : data[7], week : data[8], dayOfYear : data[10], hours : data[15], zone_hours : data[23], zone_minutes : data[24], zone : data[21], zone_sign : data[22], weekDay : data[9], minutes: data[16], seconds: data[19], milliseconds: data[20], secmins: data[18] }, mods: { month: function(data) { return data-1; }, weekDay: function (data) { data = Math.abs(data); return (data === 7 ? 0 : data); }, minutes: function (data) { return data.replace(":",""); }, seconds: function (data) { return Math.floor( (data.replace(":","").replace(",","."))*1 ); }, milliseconds: function (data) { return (data.replace(",",".")*1000); } }, postProcess: { minutes: true, seconds: true, milliseconds: true }, explict: { zone_hours: true, zone_minutes: true }, ignore: { zone: true, zone_sign: true, secmins: true } }); return time; }, addToHash: function (hash, keys, data) { keys = keys; data = data; var len = keys.length; for (var i = 0; i < len; i++) { hash[keys[i]] = data[i]; } return hash; }, combineRegex: function (r1, r2) { return new RegExp("(("+r1.source+")\\s("+r2.source+"))"); }, getDateNthString: function(add, last, inc){ if (add) { return Date.today().addDays(inc).toString("d"); } else if (last) { return Date.today().last()[inc]().toString("d"); } }, buildRegexData: function (array) { var arr = []; var len = array.length; for (var i=0; i < len; i++) { if (Object.prototype.toString.call(array[i]) === '[object Array]') { // oldIE compat version of Array.isArray arr.push(this.combineRegex(array[i][0], array[i][1])); } else { arr.push(array[i]); } } return arr; } }; $P.processTimeObject = function (obj) { var date, dayOffset; utils.setDefaults(obj); dayOffset = ($P.isLeapYear(obj.year)) ? dayOffsets.leap : dayOffsets.standard; if (!obj.month && (obj.week || obj.dayOfYear)) { utils.getDayOfYear(obj, dayOffset); } else { obj.dayOfYear = dayOffset[obj.month] + obj.day; } date = new Date(obj.year, obj.month, obj.day, obj.hours, obj.minutes, obj.seconds, obj.milliseconds); if (obj.zone) { utils.adjustForTimeZone(obj, date); // adjust (and calculate) for timezone } return date; }; $P.ISO = { regex : /^([\+-]?\d{4}(?!\d{2}\b))((-?)((0[1-9]|1[0-2])(\3([12]\d|0[1-9]|3[01]))?|W([0-4]\d|5[0-3])(-?[1-7])?|(00[1-9]|0[1-9]\d|[12]\d{2}|3([0-5]\d|6[1-6])))([T\s]((([01]\d|2[0-4])((:?)[0-5]\d)?|24\:?00)([\.,]\d+(?!:))?)?(\17[0-5]\d([\.,]\d+)?)?\s?([zZ]|([\+-])([01]\d|2[0-3]):?([0-5]\d)?)?)?)?$/, parse : function (s) { var time, data = s.match(this.regex); if (!data || !data.length) { return null; } time = utils.buildTimeObjectFromData(data); if (!time.year || (!time.year && (!time.month && !time.day) && (!time.week && !time.dayOfYear)) ) { return null; } return $P.processTimeObject(time); } }; $P.Numeric = { isNumeric: function (e){return!isNaN(parseFloat(e))&&isFinite(e);}, regex: /\b([0-1]?[0-9])([0-3]?[0-9])([0-2]?[0-9]?[0-9][0-9])\b/i, parse: function (s) { var data, i, time = {}, order = Date.CultureInfo.dateElementOrder.split(""); if (!(this.isNumeric(s)) || // if it's non-numeric OR (s[0] === "+" && s[0] === "-")) { // It's an arithmatic string (eg +/-1000) return null; } if (s.length < 5 && s.indexOf(".") < 0 && s.indexOf("/") < 0) { // assume it's just a year. time.year = s; return $P.processTimeObject(time); } data = s.match(this.regex); if (!data || !data.length) { return null; } for (i=0; i < order.length; i++) { switch(order[i]) { case "d": time.day = data[i+1]; break; case "m": time.month = (data[i+1]-1); break; case "y": time.year = data[i+1]; break; } } return $P.processTimeObject(time); } }; $P.Normalizer = { regexData: function () { var $R = Date.CultureInfo.regexPatterns; return utils.buildRegexData([ $R.tomorrow, $R.yesterday, [$R.past, $R.mon], [$R.past, $R.tue], [$R.past, $R.wed], [$R.past, $R.thu], [$R.past, $R.fri], [$R.past, $R.sat], [$R.past, $R.sun] ]); }, basicReplaceHash : function() { var $R = Date.CultureInfo.regexPatterns; return { "January": $R.jan.source, "February": $R.feb, "March": $R.mar, "April": $R.apr, "May": $R.may, "June": $R.jun, "July": $R.jul, "August": $R.aug, "September": $R.sep, "October": $R.oct, "November": $R.nov, "December": $R.dec, "": /\bat\b/gi, " ": /\s{2,}/, "am": $R.inTheMorning, "9am": $R.thisMorning, "pm": $R.inTheEvening, "7pm":$R.thisEvening }; }, keys : function(){ return [ utils.getDateNthString(true, false, 1), // tomorrow utils.getDateNthString(true, false, -1), // yesterday utils.getDateNthString(false, true, "monday"), //last mon utils.getDateNthString(false, true, "tuesday"), //last tues utils.getDateNthString(false, true, "wednesday"), //last wed utils.getDateNthString(false, true, "thursday"), //last thurs utils.getDateNthString(false, true, "friday"), //last fri utils.getDateNthString(false, true, "saturday"), //last sat utils.getDateNthString(false, true, "sunday") //last sun ]; }, buildRegexFunctions: function () { var $R = Date.CultureInfo.regexPatterns; var __ = Date.i18n.__; var tomorrowRE = new RegExp("(\\b\\d\\d?("+__("AM")+"|"+__("PM")+")? )("+$R.tomorrow.source.slice(1)+")", "i"); // adapted tomorrow regex for AM PM relative dates var todayRE = new RegExp($R.today.source + "(?!\\s*([+-]))\\b"); // today, but excludes the math operators (eg "today + 2h") this.replaceFuncs = [ [todayRE, function (full) { return (full.length > 1) ? Date.today().toString("d") : full; }], [tomorrowRE, function(full, m1) { var t = Date.today().addDays(1).toString("d"); return (t + " " + m1); }], [$R.amThisMorning, function(str, am){return am;}], [$R.pmThisEvening, function(str, pm){return pm;}] ]; }, buildReplaceData: function () { this.buildRegexFunctions(); this.replaceHash = utils.addToHash(this.basicReplaceHash(), this.keys(), this.regexData()); }, stringReplaceFuncs: function (s) { for (var i=0; i < this.replaceFuncs.length; i++) { s = s.replace(this.replaceFuncs[i][0], this.replaceFuncs[i][1]); } return s; }, parse: function (s) { s = this.stringReplaceFuncs(s); s = utils.multiReplace(s, this.replaceHash); try { var n = s.split(/([\s\-\.\,\/\x27]+)/); if (n.length === 3 && $P.Numeric.isNumeric(n[0]) && $P.Numeric.isNumeric(n[2]) && (n[2].length >= 4)) { // ok, so we're dealing with x/year. But that's not a full date. // This fixes wonky dateElementOrder parsing when set to dmy order. if (Date.CultureInfo.dateElementOrder[0] === "d") { s = "1/" + n[0] + "/" + n[2]; // set to 1st of month and normalize the seperator } } } catch (e) {} return s; } }; $P.Normalizer.buildReplaceData(); }()); (function () { var $P = Date.Parsing; var _ = $P.Operators = { // // Tokenizers // rtoken: function (r) { // regex token return function (s) { var mx = s.match(r); if (mx) { return ([ mx[0], s.substring(mx[0].length) ]); } else { throw new $P.Exception(s); } }; }, token: function () { // whitespace-eating token return function (s) { return _.rtoken(new RegExp("^\\s*" + s + "\\s*"))(s); }; }, stoken: function (s) { // string token return _.rtoken(new RegExp("^" + s)); }, // Atomic Operators until: function (p) { return function (s) { var qx = [], rx = null; while (s.length) { try { rx = p.call(this, s); } catch (e) { qx.push(rx[0]); s = rx[1]; continue; } break; } return [ qx, s ]; }; }, many: function (p) { return function (s) { var rx = [], r = null; while (s.length) { try { r = p.call(this, s); } catch (e) { return [ rx, s ]; } rx.push(r[0]); s = r[1]; } return [ rx, s ]; }; }, // generator operators -- see below optional: function (p) { return function (s) { var r = null; try { r = p.call(this, s); } catch (e) { return [ null, s ]; } return [ r[0], r[1] ]; }; }, not: function (p) { return function (s) { try { p.call(this, s); } catch (e) { return [null, s]; } throw new $P.Exception(s); }; }, ignore: function (p) { return p ? function (s) { var r = null; r = p.call(this, s); return [null, r[1]]; } : null; }, product: function () { var px = arguments[0], qx = Array.prototype.slice.call(arguments, 1), rx = []; for (var i = 0 ; i < px.length ; i++) { rx.push(_.each(px[i], qx)); } return rx; }, cache: function (rule) { var cache = {}, cache_length = 0, cache_keys = [], CACHE_MAX = Date.Config.CACHE_MAX || 100000, r = null; var cacheCheck = function () { if (cache_length === CACHE_MAX) { // kill several keys, don't want to have to do this all the time... for (var i=0; i < 10; i++) { var key = cache_keys.shift(); if (key) { delete cache[key]; cache_length--; } } } }; return function (s) { cacheCheck(); try { r = cache[s] = (cache[s] || rule.call(this, s)); } catch (e) { r = cache[s] = e; } cache_length++; cache_keys.push(s); if (r instanceof $P.Exception) { throw r; } else { return r; } }; }, // vector operators -- see below any: function () { var px = arguments; return function (s) { var r = null; for (var i = 0; i < px.length; i++) { if (px[i] == null) { continue; } try { r = (px[i].call(this, s)); } catch (e) { r = null; } if (r) { return r; } } throw new $P.Exception(s); }; }, each: function () { var px = arguments; return function (s) { var rx = [], r = null; for (var i = 0; i < px.length ; i++) { if (px[i] == null) { continue; } try { r = (px[i].call(this, s)); } catch (e) { throw new $P.Exception(s); } rx.push(r[0]); s = r[1]; } return [ rx, s]; }; }, all: function () { var px = arguments, _ = _; return _.each(_.optional(px)); }, // delimited operators sequence: function (px, d, c) { d = d || _.rtoken(/^\s*/); c = c || null; if (px.length === 1) { return px[0]; } return function (s) { var r = null, q = null; var rx = []; for (var i = 0; i < px.length ; i++) { try { r = px[i].call(this, s); } catch (e) { break; } rx.push(r[0]); try { q = d.call(this, r[1]); } catch (ex) { q = null; break; } s = q[1]; } if (!r) { throw new $P.Exception(s); } if (q) { throw new $P.Exception(q[1]); } if (c) { try { r = c.call(this, r[1]); } catch (ey) { throw new $P.Exception(r[1]); } } return [ rx, (r?r[1]:s) ]; }; }, // // Composite Operators // between: function (d1, p, d2) { d2 = d2 || d1; var _fn = _.each(_.ignore(d1), p, _.ignore(d2)); return function (s) { var rx = _fn.call(this, s); return [[rx[0][0], r[0][2]], rx[1]]; }; }, list: function (p, d, c) { d = d || _.rtoken(/^\s*/); c = c || null; return (p instanceof Array ? _.each(_.product(p.slice(0, -1), _.ignore(d)), p.slice(-1), _.ignore(c)) : _.each(_.many(_.each(p, _.ignore(d))), px, _.ignore(c))); }, set: function (px, d, c) { d = d || _.rtoken(/^\s*/); c = c || null; return function (s) { // r is the current match, best the current 'best' match // which means it parsed the most amount of input var r = null, p = null, q = null, rx = null, best = [[], s], last = false; // go through the rules in the given set for (var i = 0; i < px.length ; i++) { // last is a flag indicating whether this must be the last element // if there is only 1 element, then it MUST be the last one q = null; p = null; r = null; last = (px.length === 1); // first, we try simply to match the current pattern // if not, try the next pattern try { r = px[i].call(this, s); } catch (e) { continue; } // since we are matching against a set of elements, the first // thing to do is to add r[0] to matched elements rx = [[r[0]], r[1]]; // if we matched and there is still input to parse and // we don't already know this is the last element, // we're going to next check for the delimiter ... // if there's none, or if there's no input left to parse // than this must be the last element after all ... if (r[1].length > 0 && ! last) { try { q = d.call(this, r[1]); } catch (ex) { last = true; } } else { last = true; } // if we parsed the delimiter and now there's no more input, // that means we shouldn't have parsed the delimiter at all // so don't update r and mark this as the last element ... if (!last && q[1].length === 0) { last = true; } // so, if this isn't the last element, we're going to see if // we can get any more matches from the remaining (unmatched) // elements ... if (!last) { // build a list of the remaining rules we can match against, // i.e., all but the one we just matched against var qx = []; for (var j = 0; j < px.length ; j++) { if (i !== j) { qx.push(px[j]); } } // now invoke recursively set with the remaining input // note that we don't include the closing delimiter ... // we'll check for that ourselves at the end p = _.set(qx, d).call(this, q[1]); // if we got a non-empty set as a result ... // (otw rx already contains everything we want to match) if (p[0].length > 0) { // update current result, which is stored in rx ... // basically, pick up the remaining text from p[1] // and concat the result from p[0] so that we don't // get endless nesting ... rx[0] = rx[0].concat(p[0]); rx[1] = p[1]; } } // at this point, rx either contains the last matched element // or the entire matched set that starts with this element. // now we just check to see if this variation is better than // our best so far, in terms of how much of the input is parsed if (rx[1].length < best[1].length) { best = rx; } // if we've parsed all the input, then we're finished if (best[1].length === 0) { break; } } // so now we've either gone through all the patterns trying them // as the initial match; or we found one that parsed the entire // input string ... // if best has no matches, just return empty set ... if (best[0].length === 0) { return best; } // if a closing delimiter is provided, then we have to check it also if (c) { // we try this even if there is no remaining input because the pattern // may well be optional or match empty input ... try { q = c.call(this, best[1]); } catch (ey) { throw new $P.Exception(best[1]); } // it parsed ... be sure to update the best match remaining input best[1] = q[1]; } // if we're here, either there was no closing delimiter or we parsed it // so now we have the best match; just return it! return best; }; }, forward: function (gr, fname) { return function (s) { return gr[fname].call(this, s); }; }, // // Translation Operators // replace: function (rule, repl) { return function (s) { var r = rule.call(this, s); return [repl, r[1]]; }; }, process: function (rule, fn) { return function (s) { var r = rule.call(this, s); return [fn.call(this, r[0]), r[1]]; }; }, min: function (min, rule) { return function (s) { var rx = rule.call(this, s); if (rx[0].length < min) { throw new $P.Exception(s); } return rx; }; } }; // Generator Operators And Vector Operators // Generators are operators that have a signature of F(R) => R, // taking a given rule and returning another rule, such as // ignore, which parses a given rule and throws away the result. // Vector operators are those that have a signature of F(R1,R2,...) => R, // take a list of rules and returning a new rule, such as each. // Generator operators are converted (via the following _generator // function) into functions that can also take a list or array of rules // and return an array of new rules as though the function had been // called on each rule in turn (which is what actually happens). // This allows generators to be used with vector operators more easily. // Example: // each(ignore(foo, bar)) instead of each(ignore(foo), ignore(bar)) // This also turns generators into vector operators, which allows // constructs like: // not(cache(foo, bar)) var _generator = function (op) { function gen() { var args = null, rx = [], px, i; if (arguments.length > 1) { args = Array.prototype.slice.call(arguments); } else if (arguments[0] instanceof Array) { args = arguments[0]; } if (args) { px = args.shift(); if (px.length > 0) { args.unshift(px[i]); rx.push(op.apply(null, args)); args.shift(); return rx; } } else { return op.apply(null, arguments); } } return gen; }; var gx = "optional not ignore cache".split(/\s/); for (var i = 0 ; i < gx.length ; i++) { _[gx[i]] = _generator(_[gx[i]]); } var _vector = function (op) { return function () { if (arguments[0] instanceof Array) { return op.apply(null, arguments[0]); } else { return op.apply(null, arguments); } }; }; var vx = "each any all".split(/\s/); for (var j = 0 ; j < vx.length ; j++) { _[vx[j]] = _vector(_[vx[j]]); } }()); (function () { var $D = Date; var flattenAndCompact = function (ax) { var rx = []; for (var i = 0; i < ax.length; i++) { if (ax[i] instanceof Array) { rx = rx.concat(flattenAndCompact(ax[i])); } else { if (ax[i]) { rx.push(ax[i]); } } } return rx; }; var parseMeridian = function () { if (this.meridian && (this.hour || this.hour === 0)) { if (this.meridian === "a" && this.hour > 11 && Date.Config.strict24hr){ throw "Invalid hour and meridian combination"; } else if (this.meridian === "p" && this.hour < 12 && Date.Config.strict24hr){ throw "Invalid hour and meridian combination"; } else if (this.meridian === "p" && this.hour < 12) { this.hour = this.hour + 12; } else if (this.meridian === "a" && this.hour === 12) { this.hour = 0; } } }; var setDefaults = function () { var now = new Date(); if ((this.hour || this.minute) && (!this.month && !this.year && !this.day)) { this.day = now.getDate(); } if (!this.year) { this.year = now.getFullYear(); } if (!this.month && this.month !== 0) { this.month = now.getMonth(); } if (!this.day) { this.day = 1; } if (!this.hour) { this.hour = 0; } if (!this.minute) { this.minute = 0; } if (!this.second) { this.second = 0; } if (!this.millisecond) { this.millisecond = 0; } }; var finishUtils = { getToday: function () { if (this.now || "hour minute second".indexOf(this.unit) !== -1) { return new Date(); } else { return $D.today(); } }, setDaysFromWeekday: function (today, orient){ var gap; orient = orient || 1; this.unit = "day"; gap = ($D.getDayNumberFromName(this.weekday) - today.getDay()); this.days = gap ? ((gap + (orient * 7)) % 7) : (orient * 7); return this; }, setMonthsFromMonth: function (today, orient) { var gap; orient = orient || 1; this.unit = "month"; gap = (this.month - today.getMonth()); this.months = gap ? ((gap + (orient * 12)) % 12) : (orient * 12); this.month = null; return this; }, setDMYFromWeekday: function () { var d = Date[this.weekday](); this.day = d.getDate(); if (!this.month) { this.month = d.getMonth(); } this.year = d.getFullYear(); return this; }, setUnitValue: function (orient) { if (!this.value && this.operator && this.operator !== null && this[this.unit + "s"] && this[this.unit + "s"] !== null) { this[this.unit + "s"] = this[this.unit + "s"] + ((this.operator === "add") ? 1 : -1) + (this.value||0) * orient; } else if (this[this.unit + "s"] == null || this.operator != null) { if (!this.value) { this.value = 1; } this[this.unit + "s"] = this.value * orient; } }, generateDateFromWeeks: function () { var weekday = (this.weekday !== undefined) ? this.weekday : "today"; var d = Date[weekday]().addWeeks(this.weeks); if (this.now) { d.setTimeToNow(); } return d; } }; $D.Translator = { hour: function (s) { return function () { this.hour = Number(s); }; }, minute: function (s) { return function () { this.minute = Number(s); }; }, second: function (s) { return function () { this.second = Number(s); }; }, /* for ss.s format */ secondAndMillisecond: function (s) { return function () { var mx = s.match(/^([0-5][0-9])\.([0-9]{1,3})/); this.second = Number(mx[1]); this.millisecond = Number(mx[2]); }; }, meridian: function (s) { return function () { this.meridian = s.slice(0, 1).toLowerCase(); }; }, timezone: function (s) { return function () { var n = s.replace(/[^\d\+\-]/g, ""); if (n.length) { this.timezoneOffset = Number(n); } else { this.timezone = s.toLowerCase(); } }; }, day: function (x) { var s = x[0]; return function () { this.day = Number(s.match(/\d+/)[0]); if (this.day < 1) { throw "invalid day"; } }; }, month: function (s) { return function () { this.month = (s.length === 3) ? "jan feb mar apr may jun jul aug sep oct nov dec".indexOf(s)/4 : Number(s) - 1; if (this.month < 0) { throw "invalid month"; } }; }, year: function (s) { return function () { var n = Number(s); this.year = ((s.length > 2) ? n : (n + (((n + 2000) < Date.CultureInfo.twoDigitYearMax) ? 2000 : 1900))); }; }, rday: function (s) { return function () { switch (s) { case "yesterday": this.days = -1; break; case "tomorrow": this.days = 1; break; case "today": this.days = 0; break; case "now": this.days = 0; this.now = true; break; } }; }, finishExact: function (x) { var d; x = (x instanceof Array) ? x : [x]; for (var i = 0 ; i < x.length ; i++) { if (x[i]) { x[i].call(this); } } setDefaults.call(this); parseMeridian.call(this); if (this.day > $D.getDaysInMonth(this.year, this.month)) { throw new RangeError(this.day + " is not a valid value for days."); } d = new Date(this.year, this.month, this.day, this.hour, this.minute, this.second, this.millisecond); if (this.year < 100) { d.setFullYear(this.year); // means years less that 100 are process correctly. JS will parse it otherwise as 1900-1999. } if (this.timezone) { d.set({ timezone: this.timezone }); } else if (this.timezoneOffset) { d.set({ timezoneOffset: this.timezoneOffset }); } return d; }, finish: function (x) { var today, expression, orient, temp; x = (x instanceof Array) ? flattenAndCompact(x) : [ x ]; if (x.length === 0) { return null; } for (var i = 0 ; i < x.length ; i++) { if (typeof x[i] === "function") { x[i].call(this); } } if (this.now && !this.unit && !this.operator) { return new Date(); } else { today = finishUtils.getToday.call(this); } expression = !!(this.days && this.days !== null || this.orient || this.operator); orient = ((this.orient === "past" || this.operator === "subtract") ? -1 : 1); if (this.month && this.unit === "week") { this.value = this.month + 1; delete this.month; delete this.day; } if ((this.month || this.month === 0) && "year day hour minute second".indexOf(this.unit) !== -1) { if (!this.value) { this.value = this.month + 1; } this.month = null; expression = true; } if (!expression && this.weekday && !this.day && !this.days) { finishUtils.setDMYFromWeekday.call(this); } if (expression && this.weekday && this.unit !== "month" && this.unit !== "week") { finishUtils.setDaysFromWeekday.call(this, today, orient); } if (this.weekday && this.unit !== "week" && !this.day && !this.days) { temp = Date[this.weekday](); this.day = temp.getDate(); if (temp.getMonth() !== today.getMonth()) { this.month = temp.getMonth(); } } if (this.month && this.unit === "day" && this.operator) { if (!this.value) { this.value = (this.month + 1); } this.month = null; } if (this.value != null && this.month != null && this.year != null) { this.day = this.value * 1; } if (this.month && !this.day && this.value) { today.set({ day: this.value * 1 }); if (!expression) { this.day = this.value * 1; } } if (!this.month && this.value && this.unit === "month" && !this.now) { this.month = this.value; expression = true; } if (expression && (this.month || this.month === 0) && this.unit !== "year") { finishUtils.setMonthsFromMonth.call(this, today, orient); } if (!this.unit) { this.unit = "day"; } finishUtils.setUnitValue.call(this, orient); parseMeridian.call(this); if ((this.month || this.month === 0) && !this.day) { this.day = 1; } if (!this.orient && !this.operator && this.unit === "week" && this.value && !this.day && !this.month) { return Date.today().setWeek(this.value); } if (this.unit === "week" && this.weeks && !this.day && !this.month) { return finishUtils.generateDateFromWeeks.call(this); } if (expression && this.timezone && this.day && this.days) { this.day = this.days; } if (expression){ today.add(this); } else { today.set(this); } if (this.timezone) { this.timezone = this.timezone.toUpperCase(); var offset = $D.getTimezoneOffset(this.timezone); var timezone; if (today.hasDaylightSavingTime()) { // lets check that we're being sane with timezone setting timezone = $D.getTimezoneAbbreviation(offset, today.isDaylightSavingTime()); if (timezone !== this.timezone) { // bugger, we're in a place where things like EST vs EDT matters. if (today.isDaylightSavingTime()) { today.addHours(-1); } else { today.addHours(1); } } } today.setTimezoneOffset(offset); } return today; } }; }()); (function () { var $D = Date; $D.Grammar = {}; var _ = $D.Parsing.Operators, g = $D.Grammar, t = $D.Translator, _fn; // Allow rolling up into general purpose rules _fn = function () { return _.each(_.any.apply(null, arguments), _.not(g.ctoken2("timeContext"))); }; g.datePartDelimiter = _.rtoken(/^([\s\-\.\,\/\x27]+)/); g.timePartDelimiter = _.stoken(":"); g.whiteSpace = _.rtoken(/^\s*/); g.generalDelimiter = _.rtoken(/^(([\s\,]|at|@|on)+)/); var _C = {}; g.ctoken = function (keys) { var fn = _C[keys]; if (! fn) { var c = Date.CultureInfo.regexPatterns; var kx = keys.split(/\s+/), px = []; for (var i = 0; i < kx.length ; i++) { px.push(_.replace(_.rtoken(c[kx[i]]), kx[i])); } fn = _C[keys] = _.any.apply(null, px); } return fn; }; g.ctoken2 = function (key) { return _.rtoken(Date.CultureInfo.regexPatterns[key]); }; var cacheProcessRtoken = function (key, token, type, eachToken) { if (eachToken) { g[key] = _.cache(_.process(_.each(_.rtoken(token),_.optional(g.ctoken2(eachToken))), type)); } else { g[key] = _.cache(_.process(_.rtoken(token), type)); } }; var cacheProcessCtoken = function (token, type) { return _.cache(_.process(g.ctoken2(token), type)); }; var _F = {}; //function cache var _get = function (f) { _F[f] = (_F[f] || g.format(f)[0]); return _F[f]; }; g.allformats = function (fx) { var rx = []; if (fx instanceof Array) { for (var i = 0; i < fx.length; i++) { rx.push(_get(fx[i])); } } else { rx.push(_get(fx)); } return rx; }; g.formats = function (fx) { if (fx instanceof Array) { var rx = []; for (var i = 0 ; i < fx.length ; i++) { rx.push(_get(fx[i])); } return _.any.apply(null, rx); } else { return _get(fx); } }; var grammarFormats = { timeFormats: function(){ var i, RTokenKeys = [ "h", "hh", "H", "HH", "m", "mm", "s", "ss", "ss.s", "z", "zz" ], RToken = [ /^(0[0-9]|1[0-2]|[1-9])/, /^(0[0-9]|1[0-2])/, /^([0-1][0-9]|2[0-3]|[0-9])/, /^([0-1][0-9]|2[0-3])/, /^([0-5][0-9]|[0-9])/, /^[0-5][0-9]/, /^([0-5][0-9]|[0-9])/, /^[0-5][0-9]/, /^[0-5][0-9]\.[0-9]{1,3}/, /^((\+|\-)\s*\d\d\d\d)|((\+|\-)\d\d\:?\d\d)/, /^((\+|\-)\s*\d\d\d\d)|((\+|\-)\d\d\:?\d\d)/ ], tokens = [ t.hour, t.hour, t.hour, t.hour, t.minute, t.minute, t.second, t.second, t.secondAndMillisecond, t.timezone, t.timezone ]; for (i=0; i < RTokenKeys.length; i++) { cacheProcessRtoken(RTokenKeys[i], RToken[i], tokens[i]); } g.hms = _.cache(_.sequence([g.H, g.m, g.s], g.timePartDelimiter)); g.t = cacheProcessCtoken("shortMeridian", t.meridian); g.tt = cacheProcessCtoken("longMeridian", t.meridian); g.zzz = cacheProcessCtoken("timezone", t.timezone); g.timeSuffix = _.each(_.ignore(g.whiteSpace), _.set([ g.tt, g.zzz ])); g.time = _.each(_.optional(_.ignore(_.stoken("T"))), g.hms, g.timeSuffix); }, dateFormats: function () { // pre-loaded rules for different date part order preferences var _setfn = function () { return _.set(arguments, g.datePartDelimiter); }; var i, RTokenKeys = [ "d", "dd", "M", "MM", "y", "yy", "yyy", "yyyy" ], RToken = [ /^([0-2]\d|3[0-1]|\d)/, /^([0-2]\d|3[0-1])/, /^(1[0-2]|0\d|\d)/, /^(1[0-2]|0\d)/, /^(\d+)/, /^(\d\d)/, /^(\d\d?\d?\d?)/, /^(\d\d\d\d)/ ], tokens = [ t.day, t.day, t.month, t.month, t.year, t.year, t.year, t.year ], eachToken = [ "ordinalSuffix", "ordinalSuffix" ]; for (i=0; i < RTokenKeys.length; i++) { cacheProcessRtoken(RTokenKeys[i], RToken[i], tokens[i], eachToken[i]); } g.MMM = g.MMMM = _.cache(_.process(g.ctoken("jan feb mar apr may jun jul aug sep oct nov dec"), t.month)); g.ddd = g.dddd = _.cache(_.process(g.ctoken("sun mon tue wed thu fri sat"), function (s) { return function () { this.weekday = s; }; } )); g.day = _fn(g.d, g.dd); g.month = _fn(g.M, g.MMM); g.year = _fn(g.yyyy, g.yy); g.mdy = _setfn(g.ddd, g.month, g.day, g.year); g.ymd = _setfn(g.ddd, g.year, g.month, g.day); g.dmy = _setfn(g.ddd, g.day, g.month, g.year); g.date = function (s) { return ((g[Date.CultureInfo.dateElementOrder] || g.mdy).call(this, s)); }; }, relative: function () { // relative date / time expressions g.orientation = _.process(g.ctoken("past future"), function (s) { return function () { this.orient = s; }; } ); g.operator = _.process(g.ctoken("add subtract"), function (s) { return function () { this.operator = s; }; } ); g.rday = _.process(g.ctoken("yesterday tomorrow today now"), t.rday); g.unit = _.process(g.ctoken("second minute hour day week month year"), function (s) { return function () { this.unit = s; }; } ); } }; g.buildGrammarFormats = function () { // these need to be rebuilt every time the language changes. _C = {}; grammarFormats.timeFormats(); grammarFormats.dateFormats(); grammarFormats.relative(); g.value = _.process(_.rtoken(/^([-+]?\d+)?(st|nd|rd|th)?/), function (s) { return function () { this.value = s.replace(/\D/g, ""); }; } ); g.expression = _.set([g.rday, g.operator, g.value, g.unit, g.orientation, g.ddd, g.MMM ]); g.format = _.process(_.many( _.any( // translate format specifiers into grammar rules _.process( _.rtoken(/^(dd?d?d?(?!e)|MM?M?M?|yy?y?y?|hh?|HH?|mm?|ss?|tt?|zz?z?)/), function (fmt) { if (g[fmt]) { return g[fmt]; } else { throw $D.Parsing.Exception(fmt); } } ), // translate separator tokens into token rules _.process(_.rtoken(/^[^dMyhHmstz]+/), // all legal separators function (s) { return _.ignore(_.stoken(s)); } ) ) ), // construct the parser ... function (rules) { return _.process(_.each.apply(null, rules), t.finishExact); } ); // starting rule for general purpose grammar g._start = _.process(_.set([ g.date, g.time, g.expression ], g.generalDelimiter, g.whiteSpace), t.finish); }; g.buildGrammarFormats(); // parsing date format specifiers - ex: "h:m:s tt" // this little guy will generate a custom parser based // on the format string, ex: g.format("h:m:s tt") // check for these formats first g._formats = g.formats([ "\"yyyy-MM-ddTHH:mm:ssZ\"", "yyyy-MM-ddTHH:mm:ss.sz", "yyyy-MM-ddTHH:mm:ssZ", "yyyy-MM-ddTHH:mm:ssz", "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-ddTHH:mmZ", "yyyy-MM-ddTHH:mmz", "yyyy-MM-ddTHH:mm", "ddd, MMM dd, yyyy H:mm:ss tt", "ddd MMM d yyyy HH:mm:ss zzz", "MMddyyyy", "ddMMyyyy", "Mddyyyy", "ddMyyyy", "Mdyyyy", "dMyyyy", "yyyy", "Mdyy", "dMyy", "d" ]); // real starting rule: tries selected formats first, // then general purpose rule g.start = function (s) { try { var r = g._formats.call({}, s); if (r[1].length === 0) { return r; } } catch (e) {} return g._start.call({}, s); }; }()); (function () { var $D = Date; /** * @desc Converts the specified string value into its JavaScript Date equivalent using CultureInfo specific format information. * * Example

	///////////
	// Dates //
	///////////

	// 15-Oct-2004
	var d1 = Date.parse("10/15/2004");

	// 15-Oct-2004
	var d1 = Date.parse("15-Oct-2004");

	// 15-Oct-2004
	var d1 = Date.parse("2004.10.15");

	//Fri Oct 15, 2004
	var d1 = Date.parse("Fri Oct 15, 2004");

	///////////
	// Times //
	///////////

	// Today at 10 PM.
	var d1 = Date.parse("10 PM");

	// Today at 10:30 PM.
	var d1 = Date.parse("10:30 P.M.");

	// Today at 6 AM.
	var d1 = Date.parse("06am");

	/////////////////////
	// Dates and Times //
	/////////////////////

	// 8-July-2004 @ 10:30 PM
	var d1 = Date.parse("July 8th, 2004, 10:30 PM");

	// 1-July-2004 @ 10:30 PM
	var d1 = Date.parse("2004-07-01T22:30:00");

	////////////////////
	// Relative Dates //
	////////////////////

	// Returns today's date. The string "today" is culture specific.
	var d1 = Date.parse("today");

	// Returns yesterday's date. The string "yesterday" is culture specific.
	var d1 = Date.parse("yesterday");

	// Returns the date of the next thursday.
	var d1 = Date.parse("Next thursday");

	// Returns the date of the most previous monday.
	var d1 = Date.parse("last monday");

	// Returns today's day + one year.
	var d1 = Date.parse("next year");

	///////////////
	// Date Math //
	///////////////

	// Today + 2 days
	var d1 = Date.parse("t+2");

	// Today + 2 days
	var d1 = Date.parse("today + 2 days");

	// Today + 3 months
	var d1 = Date.parse("t+3m");

	// Today - 1 year
	var d1 = Date.parse("today - 1 year");

	// Today - 1 year
	var d1 = Date.parse("t-1y"); 


	/////////////////////////////
	// Partial Dates and Times //
	/////////////////////////////

	// July 15th of this year.
	var d1 = Date.parse("July 15");

	// 15th day of current day and year.
	var d1 = Date.parse("15");

	// July 1st of current year at 10pm.
	var d1 = Date.parse("7/1 10pm");
	
* * @param {String} The string value to convert into a Date object [Required] * @return {Date} A Date object or null if the string cannot be converted into a Date. */ var parseUtils = { removeOrds: function (s) { ords = s.match(/\b(\d+)(?:st|nd|rd|th)\b/); // find ordinal matches s = ((ords && ords.length === 2) ? s.replace(ords[0], ords[1]) : s); return s; }, grammarParser: function (s) { var r = null; try { r = $D.Grammar.start.call({}, s.replace(/^\s*(\S*(\s+\S+)*)\s*$/, "$1")); } catch (e) { return null; } return ((r[1].length === 0) ? r[0] : null); }, nativeFallback: function(s) { var t; try { // ok we haven't parsed it, last ditch attempt with the built-in parser. t = Date._parse(s); return (t || t === 0) ? new Date(t) : null; } catch (e) { return null; } } }; function parse (s) { var d; if (!s) { return null; } if (s instanceof Date) { return s.clone(); } if (s.length >= 4 && s.charAt(0) !== "0" && s.charAt(0) !== "+"&& s.charAt(0) !== "-") { // ie: 2004 will pass, 0800 won't. // Start with specific formats d = $D.Parsing.ISO.parse(s) || $D.Parsing.Numeric.parse(s); } if (d instanceof Date && !isNaN(d.getTime())) { return d; } else { // find ordinal dates (1st, 3rd, 8th, etc and remove them as they cause parsing issues) s = $D.Parsing.Normalizer.parse(parseUtils.removeOrds(s)); d = parseUtils.grammarParser(s); if (d !== null) { return d; } else { return parseUtils.nativeFallback(s); } } } if (!$D._parse) { $D._parse = $D.parse; } $D.parse = parse; Date.getParseFunction = function (fx) { var fns = Date.Grammar.allformats(fx); return function (s) { var r = null; for (var i = 0; i < fns.length; i++) { try { r = fns[i].call({}, s); } catch (e) { continue; } if (r[1].length === 0) { return r[0]; } } return null; }; }; /** * Converts the specified string value into its JavaScript Date equivalent using the specified format {String} or formats {Array} and the CultureInfo specific format information. * The format of the string value must match one of the supplied formats exactly. * * Example

	// 15-Oct-2004
	var d1 = Date.parseExact("10/15/2004", "M/d/yyyy");

	// 15-Oct-2004
	var d1 = Date.parse("15-Oct-2004", "M-ddd-yyyy");

	// 15-Oct-2004
	var d1 = Date.parse("2004.10.15", "yyyy.MM.dd");

	// Multiple formats
	var d1 = Date.parseExact("10/15/2004", ["M/d/yyyy", "MMMM d, yyyy"]);
	
* * @param {String} The string value to convert into a Date object [Required]. * @param {Object} The expected format {String} or an array of expected formats {Array} of the date string [Required]. * @return {Date} A Date object or null if the string cannot be converted into a Date. */ $D.parseExact = function (s, fx) { return $D.getParseFunction(fx)(s); }; }()); (function () { var $D = Date, $P = $D.prototype, // $C = $D.CultureInfo, // not used atm p = function (s, l) { if (!l) { l = 2; } return ("000" + s).slice(l * -1); }; /** * Converts a PHP format string to Java/.NET format string. * A PHP format string can be used with ._format or .format. * A Java/.NET format string can be used with .toString(). * The .parseExact function will only accept a Java/.NET format string * * Example * var f1 = "%m/%d/%y" * var f2 = Date.normalizeFormat(f1); // "MM/dd/yy" * * new Date().format(f1); // "04/13/08" * new Date()._format(f1); // "04/13/08" * new Date().toString(f2); // "04/13/08" * * var date = Date.parseExact("04/13/08", f2); // Sun Apr 13 2008 * * @param {String} A PHP format string consisting of one or more format spcifiers. * @return {String} The PHP format converted to a Java/.NET format string. */ var normalizerSubstitutions = { "d" : "dd", "%d": "dd", "D" : "ddd", "%a": "ddd", "j" : "dddd", "l" : "dddd", "%A": "dddd", "S" : "S", "F" : "MMMM", "%B": "MMMM", "m" : "MM", "%m": "MM", "M" : "MMM", "%b": "MMM", "%h": "MMM", "n" : "M", "Y" : "yyyy", "%Y": "yyyy", "y" : "yy", "%y": "yy", "g" : "h", "%I": "h", "G" : "H", "h" : "hh", "H" : "HH", "%H": "HH", "i" : "mm", "%M": "mm", "s" : "ss", "%S": "ss", "%r": "hh:mm tt", "%R": "H:mm", "%T": "H:mm:ss", "%X": "t", "%x": "d", "%e": "d", "%D": "MM/dd/yy", "%n": "\\n", "%t": "\\t", "e" : "z", "T" : "z", "%z": "z", "%Z": "z", "Z" : "ZZ", "N" : "u", "w" : "u", "%w": "u", "W" : "W", "%V": "W" }; var normalizer = { substitutes: function (m) { return normalizerSubstitutions[m]; }, interpreted: function (m, x) { var y; switch (m) { case "%u": return x.getDay() + 1; case "z": return x.getOrdinalNumber(); case "%j": return p(x.getOrdinalNumber(), 3); case "%U": var d1 = x.clone().set({month: 0, day: 1}).addDays(-1).moveToDayOfWeek(0), d2 = x.clone().addDays(1).moveToDayOfWeek(0, -1); return (d2 < d1) ? "00" : p((d2.getOrdinalNumber() - d1.getOrdinalNumber()) / 7 + 1); case "%W": return p(x.getWeek()); case "t": return $D.getDaysInMonth(x.getFullYear(), x.getMonth()); case "o": case "%G": return x.setWeek(x.getISOWeek()).toString("yyyy"); case "%g": return x._format("%G").slice(-2); case "a": case "%p": return t("tt").toLowerCase(); case "A": return t("tt").toUpperCase(); case "u": return p(x.getMilliseconds(), 3); case "I": return (x.isDaylightSavingTime()) ? 1 : 0; case "O": return x.getUTCOffset(); case "P": y = x.getUTCOffset(); return y.substring(0, y.length - 2) + ":" + y.substring(y.length - 2); case "B": var now = new Date(); return Math.floor(((now.getHours() * 3600) + (now.getMinutes() * 60) + now.getSeconds() + (now.getTimezoneOffset() + 60) * 60) / 86.4); case "c": return x.toISOString().replace(/\"/g, ""); case "U": return $D.strtotime("now"); case "%c": return t("d") + " " + t("t"); case "%C": return Math.floor(x.getFullYear() / 100 + 1); } }, shouldOverrideDefaults: function (m) { switch (m) { case "%e": return true; default: return false; } }, parse: function (m, context) { var formatString, c = context || new Date(); formatString = normalizer.substitutes(m); if (formatString) { return formatString; } formatString = normalizer.interpreted(m, c); if (formatString) { return formatString; } else { return m; } } }; $D.normalizeFormat = function (format, context) { return format.replace(/(%|\\)?.|%%/g, function(t){ return normalizer.parse(t, context); }); }; /** * Format a local Unix timestamp according to locale settings * * Example: * Date.strftime("%m/%d/%y", new Date()); // "04/13/08" * Date.strftime("c", "2008-04-13T17:52:03Z"); // "04/13/08" * * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @param {Number|String} The number representing the number of seconds that have elapsed since January 1, 1970 (local time). * @return {String} A string representation of the current Date object. */ $D.strftime = function (format, time) { var d = Date.parse(time); return d._format(format); }; /** * Parse any textual datetime description into a Unix timestamp. * A Unix timestamp is the number of seconds that have elapsed since January 1, 1970 (midnight UTC/GMT). * * Example: * Date.strtotime("04/13/08"); // 1208044800 * Date.strtotime("1970-01-01T00:00:00Z"); // 0 * * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @param {Object} A string or date object. * @return {String} A string representation of the current Date object. */ $D.strtotime = function (time) { var d = $D.parse(time); return Math.round($D.UTC(d.getUTCFullYear(), d.getUTCMonth(), d.getUTCDate(), d.getUTCHours(), d.getUTCMinutes(), d.getUTCSeconds(), d.getUTCMilliseconds()) / 1000); }; /** * Converts the value of the current Date object to its equivalent string representation using a PHP/Unix style of date format specifiers. * Format Specifiers * Format Description Example * ------ --------------------------------------------------------------------------- ----------------------- * %a abbreviated weekday name according to the current localed "Mon" through "Sun" * %A full weekday name according to the current localed "Sunday" through "Saturday" * %b abbreviated month name according to the current localed "Jan" through "Dec" * %B full month name according to the current locale "January" through "December" * %c preferred date and time representation for the current locale "4/13/2008 12:33 PM" * %C century number (the year divided by 100 and truncated to an integer) "00" to "99" * %d day of the month as a decimal number "01" to "31" * %D same as %m/%d/%y "04/13/08" * %e day of the month as a decimal number, a single digit is preceded by a space "1" to "31" * %g like %G, but without the century "08" * %G The 4-digit year corresponding to the ISO week number (see %V). "2008" * This has the same format and value as %Y, except that if the ISO week number * belongs to the previous or next year, that year is used instead. * %h same as %b "Jan" through "Dec" * %H hour as a decimal number using a 24-hour clock. "00" to "23" * %I hour as a decimal number using a 12-hour clock. "01" to "12" * %j day of the year as a decimal number. "001" to "366" * %m month as a decimal number. "01" to "12" * %M minute as a decimal number. "00" to "59" * %n newline character "\n" * %p either "am" or "pm" according to the given time value, or the "am" or "pm" * corresponding strings for the current locale. * %r time in a.m. and p.m. notation "8:44 PM" * %R time in 24 hour notation "20:44" * %S second as a decimal number "00" to "59" * %t tab character "\t" * %T current time, equal to %H:%M:%S "12:49:11" * %u weekday as a decimal number ["1", "7"], with "1" representing Monday "1" to "7" * %U week number of the current year as a decimal number, starting with the "0" to ("52" or "53") * first Sunday as the first day of the first week * %V The ISO 8601:1988 week number of the current year as a decimal number, "00" to ("52" or "53") * range 01 to 53, where week 1 is the first week that has at least 4 days * in the current year, and with Monday as the first day of the week. * (Use %G or %g for the year component that corresponds to the week number * for the specified timestamp.) * %W week number of the current year as a decimal number, starting with the "00" to ("52" or "53") * first Monday as the first day of the first week * %w day of the week as a decimal, Sunday being "0" "0" to "6" * %x preferred date representation for the current locale without the time "4/13/2008" * %X preferred time representation for the current locale without the date "12:53:05" * %y year as a decimal number without a century "00" "99" * %Y year as a decimal number including the century "2008" * %Z time zone or name or abbreviation "UTC", "EST", "PST" * %z same as %Z * %% a literal "%" characters "%" * d Day of the month, 2 digits with leading zeros "01" to "31" * D A textual representation of a day, three letters "Mon" through "Sun" * j Day of the month without leading zeros "1" to "31" * l A full textual representation of the day of the week (lowercase "L") "Sunday" through "Saturday" * N ISO-8601 numeric representation of the day of the week (added in PHP 5.1.0) "1" (for Monday) through "7" (for Sunday) * S English ordinal suffix for the day of the month, 2 characters "st", "nd", "rd" or "th". Works well with j * w Numeric representation of the day of the week "0" (for Sunday) through "6" (for Saturday) * z The day of the year (starting from "0") "0" through "365" * W ISO-8601 week number of year, weeks starting on Monday "00" to ("52" or "53") * F A full textual representation of a month, such as January or March "January" through "December" * m Numeric representation of a month, with leading zeros "01" through "12" * M A short textual representation of a month, three letters "Jan" through "Dec" * n Numeric representation of a month, without leading zeros "1" through "12" * t Number of days in the given month "28" through "31" * L Whether it's a leap year "1" if it is a leap year, "0" otherwise * o ISO-8601 year number. This has the same value as Y, except that if the "2008" * ISO week number (W) belongs to the previous or next year, that year * is used instead. * Y A full numeric representation of a year, 4 digits "2008" * y A two digit representation of a year "08" * a Lowercase Ante meridiem and Post meridiem "am" or "pm" * A Uppercase Ante meridiem and Post meridiem "AM" or "PM" * B Swatch Internet time "000" through "999" * g 12-hour format of an hour without leading zeros "1" through "12" * G 24-hour format of an hour without leading zeros "0" through "23" * h 12-hour format of an hour with leading zeros "01" through "12" * H 24-hour format of an hour with leading zeros "00" through "23" * i Minutes with leading zeros "00" to "59" * s Seconds, with leading zeros "00" through "59" * u Milliseconds "54321" * e Timezone identifier "UTC", "EST", "PST" * I Whether or not the date is in daylight saving time (uppercase i) "1" if Daylight Saving Time, "0" otherwise * O Difference to Greenwich time (GMT) in hours "+0200", "-0600" * P Difference to Greenwich time (GMT) with colon between hours and minutes "+02:00", "-06:00" * T Timezone abbreviation "UTC", "EST", "PST" * Z Timezone offset in seconds. The offset for timezones west of UTC is "-43200" through "50400" * always negative, and for those east of UTC is always positive. * c ISO 8601 date "2004-02-12T15:19:21+00:00" * r RFC 2822 formatted date "Thu, 21 Dec 2000 16:01:07 +0200" * U Seconds since the Unix Epoch (January 1 1970 00:00:00 GMT) "0" * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @return {String} A string representation of the current Date object. */ var formatReplace = function (context) { return function (m) { var formatString, override = false; if (m.charAt(0) === "\\" || m.substring(0, 2) === "%%") { return m.replace("\\", "").replace("%%", "%"); } override = normalizer.shouldOverrideDefaults(m); formatString = $D.normalizeFormat(m, context); if (formatString) { return context.toString(formatString, override); } }; }; $P._format = function (format) { var formatter = formatReplace(this); if (!format) { return this._toString(); } else { return format.replace(/(%|\\)?.|%%/g, formatter); } }; if (!$P.format) { $P.format = $P._format; } }()); (function () { "use strict"; var gFn = function (attr) { return function () { return this[attr]; }; }; var sFn = function (attr) { return function (val) { this[attr] = val; return this; }; }; var attrs = ["years", "months", "days", "hours", "minutes", "seconds", "milliseconds"]; var addSetFuncs = function (context, attrs) { for (var i = 0; i < attrs.length ; i++) { var $a = attrs[i], $b = $a.slice(0, 1).toUpperCase() + $a.slice(1); context.prototype[$a] = 0; context.prototype["get" + $b] = gFn($a); context.prototype["set" + $b] = sFn($a); } }; /** * new TimeSpan(milliseconds); * new TimeSpan(days, hours, minutes, seconds); * new TimeSpan(days, hours, minutes, seconds, milliseconds); */ var TimeSpan = function (days, hours, minutes, seconds, milliseconds) { if (arguments.length === 1 && typeof days === "number") { var orient = (days < 0) ? -1 : +1; var millsLeft = Math.abs(days); this.setDays(Math.floor(millsLeft / 86400000) * orient); millsLeft = millsLeft % 86400000; this.setHours(Math.floor(millsLeft / 3600000) * orient); millsLeft = millsLeft % 3600000; this.setMinutes(Math.floor(millsLeft / 60000) * orient); millsLeft = millsLeft % 60000; this.setSeconds(Math.floor(millsLeft / 1000) * orient); millsLeft = millsLeft % 1000; this.setMilliseconds(millsLeft * orient); } else { this.set(days, hours, minutes, seconds, milliseconds); } this.getTotalMilliseconds = function () { return (this.getDays() * 86400000) + (this.getHours() * 3600000) + (this.getMinutes() * 60000) + (this.getSeconds() * 1000); }; this.compareTo = function (time) { var t1 = new Date(1970, 1, 1, this.getHours(), this.getMinutes(), this.getSeconds()), t2; if (time === null) { t2 = new Date(1970, 1, 1, 0, 0, 0); } else { t2 = new Date(1970, 1, 1, time.getHours(), time.getMinutes(), time.getSeconds()); } return (t1 < t2) ? -1 : (t1 > t2) ? 1 : 0; }; this.equals = function (time) { return (this.compareTo(time) === 0); }; this.add = function (time) { return (time === null) ? this : this.addSeconds(time.getTotalMilliseconds() / 1000); }; this.subtract = function (time) { return (time === null) ? this : this.addSeconds(-time.getTotalMilliseconds() / 1000); }; this.addDays = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 86400000)); }; this.addHours = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 3600000)); }; this.addMinutes = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 60000)); }; this.addSeconds = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 1000)); }; this.addMilliseconds = function (n) { return new TimeSpan(this.getTotalMilliseconds() + n); }; this.get12HourHour = function () { return (this.getHours() > 12) ? this.getHours() - 12 : (this.getHours() === 0) ? 12 : this.getHours(); }; this.getDesignator = function () { return (this.getHours() < 12) ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator; }; this.toString = function (format) { this._toString = function () { if (this.getDays() !== null && this.getDays() > 0) { return this.getDays() + "." + this.getHours() + ":" + this.p(this.getMinutes()) + ":" + this.p(this.getSeconds()); } else { return this.getHours() + ":" + this.p(this.getMinutes()) + ":" + this.p(this.getSeconds()); } }; this.p = function (s) { return (s.toString().length < 2) ? "0" + s : s; }; var me = this; return format ? format.replace(/dd?|HH?|hh?|mm?|ss?|tt?/g, function (format) { switch (format) { case "d": return me.getDays(); case "dd": return me.p(me.getDays()); case "H": return me.getHours(); case "HH": return me.p(me.getHours()); case "h": return me.get12HourHour(); case "hh": return me.p(me.get12HourHour()); case "m": return me.getMinutes(); case "mm": return me.p(me.getMinutes()); case "s": return me.getSeconds(); case "ss": return me.p(me.getSeconds()); case "t": return ((me.getHours() < 12) ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator).substring(0, 1); case "tt": return (me.getHours() < 12) ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator; } } ) : this._toString(); }; return this; }; addSetFuncs(TimeSpan, attrs.slice(2)); TimeSpan.prototype.set = function (days, hours, minutes, seconds, milliseconds){ this.setDays(days || this.getDays()); this.setHours(hours || this.getHours()); this.setMinutes(minutes || this.getMinutes()); this.setSeconds(seconds || this.getSeconds()); this.setMilliseconds(milliseconds || this.getMilliseconds()); }; /** * Gets the time of day for this date instances. * @return {TimeSpan} TimeSpan */ Date.prototype.getTimeOfDay = function () { return new TimeSpan(0, this.getHours(), this.getMinutes(), this.getSeconds(), this.getMilliseconds()); }; Date.TimeSpan = TimeSpan; if (typeof window !== "undefined" ) { // keeping API compatible for v1.x window.TimeSpan = TimeSpan; } }()); (function () { "use strict"; var attrs = ["years", "months", "days", "hours", "minutes", "seconds", "milliseconds"]; var gFn = function (attr) { return function () { return this[attr]; }; }; var sFn = function (attr) { return function (val) { this[attr] = val; return this; }; }; var addSetFuncs = function (context, attrs) { for (var i = 0; i < attrs.length ; i++) { var $a = attrs[i], $b = $a.slice(0, 1).toUpperCase() + $a.slice(1); context.prototype[$a] = 0; context.prototype["get" + $b] = gFn($a); context.prototype["set" + $b] = sFn($a); } }; var setMonthsAndYears = function (orient, d1, d2, context) { function inc() { d1.addMonths(-orient); context.months++; if (context.months === 12) { context.years++; context.months = 0; } } if (orient === +1) { while (d1 > d2) { inc(); } } else { while (d1 < d2) { inc(); } } context.months--; context.months *= orient; context.years *= orient; }; var adjustForDST = function(orient, startDate, endDate) { var hasDSTMismatch = (false === (startDate.isDaylightSavingTime() === endDate.isDaylightSavingTime())); if (hasDSTMismatch && orient === 1) { startDate.addHours(-1); } else if (hasDSTMismatch) { startDate.addHours(1); } }; /** * TimePeriod(startDate, endDate); * TimePeriod(years, months, days, hours, minutes, seconds, milliseconds); */ var TimePeriod = function (years, months, days, hours, minutes, seconds, milliseconds) { if (arguments.length === 7) { this.set(years, months, days, hours, minutes, seconds, milliseconds); } else if (arguments.length === 2 && arguments[0] instanceof Date && arguments[1] instanceof Date) { var startDate = arguments[0].clone(); var endDate = arguments[1].clone(); var orient = (startDate > endDate) ? +1 : -1; this.dates = { start: arguments[0].clone(), end: arguments[1].clone() }; setMonthsAndYears(orient, startDate, endDate, this); adjustForDST(orient, startDate, endDate); // // TODO - adjust for DST var diff = endDate - startDate; if (diff !== 0) { var ts = new TimeSpan(diff); this.set(this.years, this.months, ts.getDays(), ts.getHours(), ts.getMinutes(), ts.getSeconds(), ts.getMilliseconds()); } } return this; }; // create all the set functions. addSetFuncs(TimePeriod, attrs); TimePeriod.prototype.set = function (years, months, days, hours, minutes, seconds, milliseconds){ this.setYears(years || this.getYears()); this.setMonths(months || this.getMonths()); this.setDays(days || this.getDays()); this.setHours(hours || this.getHours()); this.setMinutes(minutes || this.getMinutes()); this.setSeconds(seconds || this.getSeconds()); this.setMilliseconds(milliseconds || this.getMilliseconds()); }; Date.TimePeriod = TimePeriod; if (typeof window !== "undefined") { // keeping API compatible for v1.x window.TimePeriod = TimePeriod; } }()); ================================================ FILE: build/date-de-LI.js ================================================ /** * @overview datejs * @version 1.0.0-rc3 * @author Gregory Wild-Smith * @copyright 2015 Gregory Wild-Smith * @license MIT * @homepage https://github.com/abritinthebay/datejs */ /* * DateJS Culture String File * Country Code: de-LI * Name: German (Liechtenstein) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["de-LI"] = { "name": "de-LI", "englishName": "German (Liechtenstein)", "nativeName": "Deutsch (Liechtenstein)", "Sunday": "Sonntag", "Monday": "Montag", "Tuesday": "Dienstag", "Wednesday": "Mittwoch", "Thursday": "Donnerstag", "Friday": "Freitag", "Saturday": "Samstag", "Sun": "Son", "Mon": "Mon", "Tue": "Die", "Wed": "Mit", "Thu": "Don", "Fri": "Fre", "Sat": "Sam", "Su": "So", "Mo": "Mo", "Tu": "Di", "We": "Mi", "Th": "Do", "Fr": "Fr", "Sa": "Sa", "S_Sun_Initial": "S", "M_Mon_Initial": "M", "T_Tue_Initial": "D", "W_Wed_Initial": "M", "T_Thu_Initial": "D", "F_Fri_Initial": "F", "S_Sat_Initial": "S", "January": "Januar", "February": "Februar", "March": "März", "April": "April", "May": "Mai", "June": "Juni", "July": "Juli", "August": "August", "September": "September", "October": "Oktober", "November": "November", "December": "Dezember", "Jan_Abbr": "Jan", "Feb_Abbr": "Feb", "Mar_Abbr": "Mrz", "Apr_Abbr": "Apr", "May_Abbr": "Mai", "Jun_Abbr": "Jun", "Jul_Abbr": "Jul", "Aug_Abbr": "Aug", "Sep_Abbr": "Sep", "Oct_Abbr": "Okt", "Nov_Abbr": "Nov", "Dec_Abbr": "Dez", "AM": "", "PM": "", "firstDayOfWeek": 1, "twoDigitYearMax": 2029, "mdy": "dmy", "M/d/yyyy": "dd.MM.yyyy", "dddd, MMMM dd, yyyy": "dddd, d. MMMM yyyy", "h:mm tt": "HH:mm", "h:mm:ss tt": "HH:mm:ss", "dddd, MMMM dd, yyyy h:mm:ss tt": "dddd, d. MMMM yyyy HH:mm:ss", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "dd MMMM", "MMMM, yyyy": "MMMM yyyy", "/jan(uary)?/": "jan(uar)?", "/feb(ruary)?/": "feb(ruar)?", "/mar(ch)?/": "märz", "/apr(il)?/": "apr(il)?", "/may/": "mai", "/jun(e)?/": "jun(i)?", "/jul(y)?/": "jul(i)?", "/aug(ust)?/": "aug(ust)?", "/sep(t(ember)?)?/": "sep(t(ember)?)?", "/oct(ober)?/": "okt(ober)?", "/nov(ember)?/": "nov(ember)?", "/dec(ember)?/": "dez(ember)?", "/^su(n(day)?)?/": "^sonntag", "/^mo(n(day)?)?/": "^montag", "/^tu(e(s(day)?)?)?/": "^dienstag", "/^we(d(nesday)?)?/": "^mittwoch", "/^th(u(r(s(day)?)?)?)?/": "^donnerstag", "/^fr(i(day)?)?/": "^freitag", "/^sa(t(urday)?)?/": "^samstag", "/^next/": "^nächste(r|s|n)?", "/^last|past|prev(ious)?/": "^letzte(r|s|n)?|vergangene(r|s|n)?|vorherige(r|s|n)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|(da)?nach(er)?|von|daher|in)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|(be|zu)?vor|früher)", "/^yes(terday)?/": "^gestern", "/^t(od(ay)?)?/": "^heute", "/^tom(orrow)?/": "^morgen", "/^n(ow)?/": "^jetzt|sofort|gleich", "/^ms|milli(second)?s?/": "^ms|milli(sekunde(n)?)?", "/^sec(ond)?s?/": "^sek(unde(n)?)?", "/^mn|min(ute)?s?/": "^mn|min(ute(n)?)?", "/^h(our)?s?/": "^h|st(d|unde(n)?)?", "/^w(eek)?s?/": "^w(oche(n)?)?", "/^m(onth)?s?/": "^m(onat(e)?)?", "/^d(ay)?s?/": "^d|t(ag(en)?)?", "/^y(ear)?s?/": "^y|j(ahr(en)?)?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "de-LI"; /** * @overview datejs * @version 1.0.0-rc3 * @author Gregory Wild-Smith * @copyright 2015 Gregory Wild-Smith * @license MIT * @homepage https://github.com/abritinthebay/datejs */(function () { var $D = Date; var lang = Date.CultureStrings ? Date.CultureStrings.lang : null; var loggedKeys = {}; // for debug purposes. var getText = { getFromKey: function (key, countryCode) { var output; if (Date.CultureStrings && Date.CultureStrings[countryCode] && Date.CultureStrings[countryCode][key]) { output = Date.CultureStrings[countryCode][key]; } else { output = getText.buildFromDefault(key); } if (key.charAt(0) === "/") { // Assume it's a regex output = getText.buildFromRegex(key, countryCode); } return output; }, getFromObjectValues: function (obj, countryCode) { var key, output = {}; for(key in obj) { if (obj.hasOwnProperty(key)) { output[key] = getText.getFromKey(obj[key], countryCode); } } return output; }, getFromObjectKeys: function (obj, countryCode) { var key, output = {}; for(key in obj) { if (obj.hasOwnProperty(key)) { output[getText.getFromKey(key, countryCode)] = obj[key]; } } return output; }, getFromArray: function (arr, countryCode) { var output = []; for (var i=0; i < arr.length; i++){ if (i in arr) { output[i] = getText.getFromKey(arr[i], countryCode); } } return output; }, buildFromDefault: function (key) { var output, length, split, last; switch(key) { case "name": output = "en-US"; break; case "englishName": output = "English (United States)"; break; case "nativeName": output = "English (United States)"; break; case "twoDigitYearMax": output = 2049; break; case "firstDayOfWeek": output = 0; break; default: output = key; split = key.split("_"); length = split.length; if (length > 1 && key.charAt(0) !== "/") { // if the key isn't a regex and it has a split. last = split[(length - 1)].toLowerCase(); if (last === "initial" || last === "abbr") { output = split[0]; } } break; } return output; }, buildFromRegex: function (key, countryCode) { var output; if (Date.CultureStrings && Date.CultureStrings[countryCode] && Date.CultureStrings[countryCode][key]) { output = new RegExp(Date.CultureStrings[countryCode][key], "i"); } else { output = new RegExp(key.replace(new RegExp("/", "g"),""), "i"); } return output; } }; var shallowMerge = function (obj1, obj2) { for (var attrname in obj2) { if (obj2.hasOwnProperty(attrname)) { obj1[attrname] = obj2[attrname]; } } }; var __ = function (key, language) { var countryCode = (language) ? language : lang; loggedKeys[key] = key; if (typeof key === "object") { if (key instanceof Array) { return getText.getFromArray(key, countryCode); } else { return getText.getFromObjectKeys(key, countryCode); } } else { return getText.getFromKey(key, countryCode); } }; var loadI18nScript = function (code) { // paatterned after jQuery's getScript. var url = Date.Config.i18n + code + ".js"; var head = document.getElementsByTagName("head")[0] || document.documentElement; var script = document.createElement("script"); script.src = url; var completed = false; var events = { done: function (){} // placeholder function }; // Attach handlers for all browsers script.onload = script.onreadystatechange = function() { if ( !completed && (!this.readyState || this.readyState === "loaded" || this.readyState === "complete") ) { events.done(); head.removeChild(script); } }; setTimeout(function() { head.insertBefore(script, head.firstChild); }, 0); // allows return to execute first return { done: function (cb) { events.done = function() { if (cb) { setTimeout(cb,0); } }; } }; }; var buildInfo = { buildFromMethodHash: function (obj) { var key; for(key in obj) { if (obj.hasOwnProperty(key)) { obj[key] = buildInfo[obj[key]](); } } return obj; }, timeZoneDST: function () { var DST = { "CHADT": "+1345", "NZDT": "+1300", "AEDT": "+1100", "ACDT": "+1030", "AZST": "+0500", "IRDT": "+0430", "EEST": "+0300", "CEST": "+0200", "BST": "+0100", "PMDT": "-0200", "ADT": "-0300", "NDT": "-0230", "EDT": "-0400", "CDT": "-0500", "MDT": "-0600", "PDT": "-0700", "AKDT": "-0800", "HADT": "-0900" }; return __(DST); }, timeZoneStandard: function () { var standard = { "LINT": "+1400", "TOT": "+1300", "CHAST": "+1245", "NZST": "+1200", "NFT": "+1130", "SBT": "+1100", "AEST": "+1000", "ACST": "+0930", "JST": "+0900", "CWST": "+0845", "CT": "+0800", "ICT": "+0700", "MMT": "+0630", "BST": "+0600", "NPT": "+0545", "IST": "+0530", "PKT": "+0500", "AFT": "+0430", "MSK": "+0400", "IRST": "+0330", "FET": "+0300", "EET": "+0200", "CET": "+0100", "GMT": "+0000", "UTC": "+0000", "CVT": "-0100", "GST": "-0200", "BRT": "-0300", "NST": "-0330", "AST": "-0400", "EST": "-0500", "CST": "-0600", "MST": "-0700", "PST": "-0800", "AKST": "-0900", "MIT": "-0930", "HST": "-1000", "SST": "-1100", "BIT": "-1200" }; return __(standard); }, timeZones: function (data) { var zone; data.timezones = []; for (zone in data.abbreviatedTimeZoneStandard) { if (data.abbreviatedTimeZoneStandard.hasOwnProperty(zone)) { data.timezones.push({ name: zone, offset: data.abbreviatedTimeZoneStandard[zone]}); } } for (zone in data.abbreviatedTimeZoneDST) { if (data.abbreviatedTimeZoneDST.hasOwnProperty(zone)) { data.timezones.push({ name: zone, offset: data.abbreviatedTimeZoneDST[zone], dst: true}); } } return data.timezones; }, days: function () { return __(["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"]); }, dayAbbr: function () { return __(["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"]); }, dayShortNames: function () { return __(["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"]); }, dayFirstLetters: function () { return __(["S_Sun_Initial", "M_Mon_Initial", "T_Tues_Initial", "W_Wed_Initial", "T_Thu_Initial", "F_Fri_Initial", "S_Sat_Initial"]); }, months: function () { return __(["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"]); }, monthAbbr: function () { return __(["Jan_Abbr", "Feb_Abbr", "Mar_Abbr", "Apr_Abbr", "May_Abbr", "Jun_Abbr", "Jul_Abbr", "Aug_Abbr", "Sep_Abbr", "Oct_Abbr", "Nov_Abbr", "Dec_Abbr"]); }, formatPatterns: function () { return getText.getFromObjectValues({ shortDate: "M/d/yyyy", longDate: "dddd, MMMM dd, yyyy", shortTime: "h:mm tt", longTime: "h:mm:ss tt", fullDateTime: "dddd, MMMM dd, yyyy h:mm:ss tt", sortableDateTime: "yyyy-MM-ddTHH:mm:ss", universalSortableDateTime: "yyyy-MM-dd HH:mm:ssZ", rfc1123: "ddd, dd MMM yyyy HH:mm:ss", monthDay: "MMMM dd", yearMonth: "MMMM, yyyy" }, Date.i18n.currentLanguage()); }, regex: function () { return getText.getFromObjectValues({ inTheMorning: "/( in the )(morn(ing)?)\\b/", thisMorning: "/(this )(morn(ing)?)\\b/", amThisMorning: "/(\b\\d(am)? )(this )(morn(ing)?)/", inTheEvening: "/( in the )(even(ing)?)\\b/", thisEvening: "/(this )(even(ing)?)\\b/", pmThisEvening: "/(\b\\d(pm)? )(this )(even(ing)?)/", jan: "/jan(uary)?/", feb: "/feb(ruary)?/", mar: "/mar(ch)?/", apr: "/apr(il)?/", may: "/may/", jun: "/jun(e)?/", jul: "/jul(y)?/", aug: "/aug(ust)?/", sep: "/sep(t(ember)?)?/", oct: "/oct(ober)?/", nov: "/nov(ember)?/", dec: "/dec(ember)?/", sun: "/^su(n(day)?)?/", mon: "/^mo(n(day)?)?/", tue: "/^tu(e(s(day)?)?)?/", wed: "/^we(d(nesday)?)?/", thu: "/^th(u(r(s(day)?)?)?)?/", fri: "/fr(i(day)?)?/", sat: "/^sa(t(urday)?)?/", future: "/^next/", past: "/^last|past|prev(ious)?/", add: "/^(\\+|aft(er)?|from|hence)/", subtract: "/^(\\-|bef(ore)?|ago)/", yesterday: "/^yes(terday)?/", today: "/^t(od(ay)?)?/", tomorrow: "/^tom(orrow)?/", now: "/^n(ow)?/", millisecond: "/^ms|milli(second)?s?/", second: "/^sec(ond)?s?/", minute: "/^mn|min(ute)?s?/", hour: "/^h(our)?s?/", week: "/^w(eek)?s?/", month: "/^m(onth)?s?/", day: "/^d(ay)?s?/", year: "/^y(ear)?s?/", shortMeridian: "/^(a|p)/", longMeridian: "/^(a\\.?m?\\.?|p\\.?m?\\.?)/", timezone: "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/", ordinalSuffix: "/^\\s*(st|nd|rd|th)/", timeContext: "/^\\s*(\\:|a(?!u|p)|p)/" }, Date.i18n.currentLanguage()); } }; var CultureInfo = function () { var info = getText.getFromObjectValues({ name: "name", englishName: "englishName", nativeName: "nativeName", amDesignator: "AM", pmDesignator: "PM", firstDayOfWeek: "firstDayOfWeek", twoDigitYearMax: "twoDigitYearMax", dateElementOrder: "mdy" }, Date.i18n.currentLanguage()); var constructedInfo = buildInfo.buildFromMethodHash({ dayNames: "days", abbreviatedDayNames: "dayAbbr", shortestDayNames: "dayShortNames", firstLetterDayNames: "dayFirstLetters", monthNames: "months", abbreviatedMonthNames: "monthAbbr", formatPatterns: "formatPatterns", regexPatterns: "regex", abbreviatedTimeZoneDST: "timeZoneDST", abbreviatedTimeZoneStandard: "timeZoneStandard" }); shallowMerge(info, constructedInfo); buildInfo.timeZones(info); return info; }; $D.i18n = { __: function (key, lang) { return __(key, lang); }, currentLanguage: function () { return lang || "en-US"; }, setLanguage: function (code, force, cb) { var async = false; if (force || code === "en-US" || (!!Date.CultureStrings && !!Date.CultureStrings[code])) { lang = code; Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings.lang = code; Date.CultureInfo = new CultureInfo(); } else { if (!(!!Date.CultureStrings && !!Date.CultureStrings[code])) { if (typeof exports !== "undefined" && this.exports !== exports) { // we're in a Node enviroment, load it using require try { require("../i18n/" + code + ".js"); lang = code; Date.CultureStrings.lang = code; Date.CultureInfo = new CultureInfo(); } catch (e) { // var str = "The language for '" + code + "' could not be loaded by Node. It likely does not exist."; throw new Error("The DateJS IETF language tag '" + code + "' could not be loaded by Node. It likely does not exist."); } } else if (Date.Config && Date.Config.i18n) { // we know the location of the files, so lets load them async = true; loadI18nScript(code).done(function(){ lang = code; Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings.lang = code; Date.CultureInfo = new CultureInfo(); $D.Parsing.Normalizer.buildReplaceData(); // because this is async if ($D.Grammar) { $D.Grammar.buildGrammarFormats(); // so we can parse those strings... } if (cb) { setTimeout(cb,0); } }); } else { Date.console.error("The DateJS IETF language tag '" + code + "' is not available and has not been loaded."); return false; } } } $D.Parsing.Normalizer.buildReplaceData(); // rebuild normalizer strings if ($D.Grammar) { $D.Grammar.buildGrammarFormats(); // so we can parse those strings... } if (!async && cb) { setTimeout(cb,0); } }, getLoggedKeys: function () { return loggedKeys; }, updateCultureInfo: function () { Date.CultureInfo = new CultureInfo(); } }; $D.i18n.updateCultureInfo(); // run automatically }()); (function () { var $D = Date, $P = $D.prototype, p = function (s, l) { if (!l) { l = 2; } return ("000" + s).slice(l * -1); }; if (typeof window !== "undefined" && typeof window.console !== "undefined" && typeof window.console.log !== "undefined") { $D.console = console; // used only to raise non-critical errors if available } else { // set mock so we don't give errors. $D.console = { log: function(){}, error: function(){} }; } $D.Config = $D.Config || {}; $D.initOverloads = function() { /** * Overload of Date.now. Allows an alternate call for Date.now where it returns the * current Date as an object rather than just milliseconds since the Unix Epoch. * * Also provides an implementation of now() for browsers (IE<9) that don't have it. * * Backwards compatible so with work with either: * Date.now() [returns ms] * or * Date.now(true) [returns Date] */ if (!$D.now) { $D._now = function now() { return new Date().getTime(); }; } else if (!$D._now) { $D._now = $D.now; } $D.now = function (returnObj) { if (returnObj) { return $D.present(); } else { return $D._now(); } }; if ( !$P.toISOString ) { $P.toISOString = function() { return this.getUTCFullYear() + "-" + p(this.getUTCMonth() + 1) + "-" + p(this.getUTCDate()) + "T" + p(this.getUTCHours()) + ":" + p(this.getUTCMinutes()) + ":" + p(this.getUTCSeconds()) + "." + String( (this.getUTCMilliseconds()/1000).toFixed(3)).slice(2, 5) + "Z"; }; } // private if ( $P._toString === undefined ){ $P._toString = $P.toString; } }; $D.initOverloads(); /** * Gets a date that is set to the current date. The time is set to the start of the day (00:00 or 12:00 AM). * @return {Date} The current date. */ $D.today = function () { return new Date().clearTime(); }; /** * Gets a date that is set to the current date and time (same as new Date, but chainable) * @return {Date} The current date. */ $D.present = function () { return new Date(); }; /** * Compares the first date to the second date and returns an number indication of their relative values. * @param {Date} First Date object to compare [Required]. * @param {Date} Second Date object to compare to [Required]. * @return {Number} -1 = date1 is lessthan date2. 0 = values are equal. 1 = date1 is greaterthan date2. */ $D.compare = function (date1, date2) { if (isNaN(date1) || isNaN(date2)) { throw new Error(date1 + " - " + date2); } else if (date1 instanceof Date && date2 instanceof Date) { return (date1 < date2) ? -1 : (date1 > date2) ? 1 : 0; } else { throw new TypeError(date1 + " - " + date2); } }; /** * Compares the first Date object to the second Date object and returns true if they are equal. * @param {Date} First Date object to compare [Required] * @param {Date} Second Date object to compare to [Required] * @return {Boolean} true if dates are equal. false if they are not equal. */ $D.equals = function (date1, date2) { return (date1.compareTo(date2) === 0); }; /** * Gets the language appropriate day name when given the day number(0-6) * eg - 0 == Sunday * @return {String} The day name */ $D.getDayName = function (n) { return Date.CultureInfo.dayNames[n]; }; /** * Gets the day number (0-6) if given a CultureInfo specific string which is a valid dayName, abbreviatedDayName or shortestDayName (two char). * @param {String} The name of the day (eg. "Monday, "Mon", "tuesday", "tue", "We", "we"). * @return {Number} The day number */ $D.getDayNumberFromName = function (name) { var n = Date.CultureInfo.dayNames, m = Date.CultureInfo.abbreviatedDayNames, o = Date.CultureInfo.shortestDayNames, s = name.toLowerCase(); for (var i = 0; i < n.length; i++) { if (n[i].toLowerCase() === s || m[i].toLowerCase() === s || o[i].toLowerCase() === s) { return i; } } return -1; }; /** * Gets the month number (0-11) if given a Culture Info specific string which is a valid monthName or abbreviatedMonthName. * @param {String} The name of the month (eg. "February, "Feb", "october", "oct"). * @return {Number} The day number */ $D.getMonthNumberFromName = function (name) { var n = Date.CultureInfo.monthNames, m = Date.CultureInfo.abbreviatedMonthNames, s = name.toLowerCase(); for (var i = 0; i < n.length; i++) { if (n[i].toLowerCase() === s || m[i].toLowerCase() === s) { return i; } } return -1; }; /** * Gets the language appropriate month name when given the month number(0-11) * eg - 0 == January * @return {String} The month name */ $D.getMonthName = function (n) { return Date.CultureInfo.monthNames[n]; }; /** * Determines if the current date instance is within a LeapYear. * @param {Number} The year. * @return {Boolean} true if date is within a LeapYear, otherwise false. */ $D.isLeapYear = function (year) { return ((year % 4 === 0 && year % 100 !== 0) || year % 400 === 0); }; /** * Gets the number of days in the month, given a year and month value. Automatically corrects for LeapYear. * @param {Number} The year. * @param {Number} The month (0-11). * @return {Number} The number of days in the month. */ $D.getDaysInMonth = function (year, month) { if (!month && $D.validateMonth(year)) { month = year; year = Date.today().getFullYear(); } return [31, ($D.isLeapYear(year) ? 29 : 28), 31, 30, 31, 30, 31, 31, 30, 31, 30, 31][month]; }; $P.getDaysInMonth = function () { return $D.getDaysInMonth(this.getFullYear(), this.getMonth()); }; $D.getTimezoneAbbreviation = function (offset, dst) { var p, n = (dst || false) ? Date.CultureInfo.abbreviatedTimeZoneDST : Date.CultureInfo.abbreviatedTimeZoneStandard; for (p in n) { if (n.hasOwnProperty(p)) { if (n[p] === offset) { return p; } } } return null; }; $D.getTimezoneOffset = function (name, dst) { var i, a =[], z = Date.CultureInfo.timezones; if (!name) { name = (new Date()).getTimezone();} for (i = 0; i < z.length; i++) { if (z[i].name === name.toUpperCase()) { a.push(i); } } if (!z[a[0]]) { return null; } if (a.length === 1 || !dst) { return z[a[0]].offset; } else { for (i=0; i < a.length; i++) { if (z[a[i]].dst) { return z[a[i]].offset; } } } }; $D.getQuarter = function (d) { d = d || new Date(); // If no date supplied, use today var q = [1,2,3,4]; return q[Math.floor(d.getMonth() / 3)]; // ~~~ is a bitwise op. Faster than Math.floor }; $D.getDaysLeftInQuarter = function (d) { d = d || new Date(); var qEnd = new Date(d); qEnd.setMonth(qEnd.getMonth() + 3 - qEnd.getMonth() % 3, 0); return Math.floor((qEnd - d) / 8.64e7); }; // private var validate = function (n, min, max, name) { name = name ? name : "Object"; if (typeof n === "undefined") { return false; } else if (typeof n !== "number") { throw new TypeError(n + " is not a Number."); } else if (n < min || n > max) { // As failing validation is *not* an exceptional circumstance // lets not throw a RangeError Exception here. // It's semantically correct but it's not sensible. return false; } return true; }; /** * Validates the number is within an acceptable range for milliseconds [0-999]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateMillisecond = function (value) { return validate(value, 0, 999, "millisecond"); }; /** * Validates the number is within an acceptable range for seconds [0-59]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateSecond = function (value) { return validate(value, 0, 59, "second"); }; /** * Validates the number is within an acceptable range for minutes [0-59]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateMinute = function (value) { return validate(value, 0, 59, "minute"); }; /** * Validates the number is within an acceptable range for hours [0-23]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateHour = function (value) { return validate(value, 0, 23, "hour"); }; /** * Validates the number is within an acceptable range for the days in a month [0-MaxDaysInMonth]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateDay = function (value, year, month) { if (year === undefined || year === null || month === undefined || month === null) { return false;} return validate(value, 1, $D.getDaysInMonth(year, month), "day"); }; /** * Validates the number is within an acceptable range for months [0-11]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateWeek = function (value) { return validate(value, 0, 53, "week"); }; /** * Validates the number is within an acceptable range for months [0-11]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateMonth = function (value) { return validate(value, 0, 11, "month"); }; /** * Validates the number is within an acceptable range for years. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateYear = function (value) { /** * Per ECMAScript spec the range of times supported by Date objects is * exactly -100,000,000 days to +100,000,000 days measured relative to * midnight at the beginning of 01 January, 1970 UTC. * This gives a range of 8,640,000,000,000,000 milliseconds to either * side of 01 January, 1970 UTC. * * Earliest possible date: Tue, 20 Apr 271,822 B.C. 00:00:00 UTC * Latest possible date: Sat, 13 Sep 275,760 00:00:00 UTC */ return validate(value, -271822, 275760, "year"); }; $D.validateTimezone = function(value) { var timezones = {"ACDT":1,"ACST":1,"ACT":1,"ADT":1,"AEDT":1,"AEST":1,"AFT":1,"AKDT":1,"AKST":1,"AMST":1,"AMT":1,"ART":1,"AST":1,"AWDT":1,"AWST":1,"AZOST":1,"AZT":1,"BDT":1,"BIOT":1,"BIT":1,"BOT":1,"BRT":1,"BST":1,"BTT":1,"CAT":1,"CCT":1,"CDT":1,"CEDT":1,"CEST":1,"CET":1,"CHADT":1,"CHAST":1,"CHOT":1,"ChST":1,"CHUT":1,"CIST":1,"CIT":1,"CKT":1,"CLST":1,"CLT":1,"COST":1,"COT":1,"CST":1,"CT":1,"CVT":1,"CWST":1,"CXT":1,"DAVT":1,"DDUT":1,"DFT":1,"EASST":1,"EAST":1,"EAT":1,"ECT":1,"EDT":1,"EEDT":1,"EEST":1,"EET":1,"EGST":1,"EGT":1,"EIT":1,"EST":1,"FET":1,"FJT":1,"FKST":1,"FKT":1,"FNT":1,"GALT":1,"GAMT":1,"GET":1,"GFT":1,"GILT":1,"GIT":1,"GMT":1,"GST":1,"GYT":1,"HADT":1,"HAEC":1,"HAST":1,"HKT":1,"HMT":1,"HOVT":1,"HST":1,"ICT":1,"IDT":1,"IOT":1,"IRDT":1,"IRKT":1,"IRST":1,"IST":1,"JST":1,"KGT":1,"KOST":1,"KRAT":1,"KST":1,"LHST":1,"LINT":1,"MAGT":1,"MART":1,"MAWT":1,"MDT":1,"MET":1,"MEST":1,"MHT":1,"MIST":1,"MIT":1,"MMT":1,"MSK":1,"MST":1,"MUT":1,"MVT":1,"MYT":1,"NCT":1,"NDT":1,"NFT":1,"NPT":1,"NST":1,"NT":1,"NUT":1,"NZDT":1,"NZST":1,"OMST":1,"ORAT":1,"PDT":1,"PET":1,"PETT":1,"PGT":1,"PHOT":1,"PHT":1,"PKT":1,"PMDT":1,"PMST":1,"PONT":1,"PST":1,"PYST":1,"PYT":1,"RET":1,"ROTT":1,"SAKT":1,"SAMT":1,"SAST":1,"SBT":1,"SCT":1,"SGT":1,"SLST":1,"SRT":1,"SST":1,"SYOT":1,"TAHT":1,"THA":1,"TFT":1,"TJT":1,"TKT":1,"TLT":1,"TMT":1,"TOT":1,"TVT":1,"UCT":1,"ULAT":1,"UTC":1,"UYST":1,"UYT":1,"UZT":1,"VET":1,"VLAT":1,"VOLT":1,"VOST":1,"VUT":1,"WAKT":1,"WAST":1,"WAT":1,"WEDT":1,"WEST":1,"WET":1,"WST":1,"YAKT":1,"YEKT":1,"Z":1}; return (timezones[value] === 1); }; $D.validateTimezoneOffset= function(value) { // timezones go from +14hrs to -12hrs, the +X hours are negative offsets. return (value > -841 && value < 721); }; }()); (function () { var $D = Date, $P = $D.prototype, p = function (s, l) { if (!l) { l = 2; } return ("000" + s).slice(l * -1); }; var validateConfigObject = function (obj) { var result = {}, self = this, prop, testFunc; testFunc = function (prop, func, value) { if (prop === "day") { var month = (obj.month !== undefined) ? obj.month : self.getMonth(); var year = (obj.year !== undefined) ? obj.year : self.getFullYear(); return $D[func](value, year, month); } else { return $D[func](value); } }; for (prop in obj) { if (Object.prototype.hasOwnProperty.call(obj, prop)) { var func = "validate" + prop.charAt(0).toUpperCase() + prop.slice(1); if ($D[func] && obj[prop] !== null && testFunc(prop, func, obj[prop])) { result[prop] = obj[prop]; } } } return result; }; /** * Resets the time of this Date object to 12:00 AM (00:00), which is the start of the day. * @param {Boolean} .clone() this date instance before clearing Time * @return {Date} this */ $P.clearTime = function () { this.setHours(0); this.setMinutes(0); this.setSeconds(0); this.setMilliseconds(0); return this; }; /** * Resets the time of this Date object to the current time ('now'). * @return {Date} this */ $P.setTimeToNow = function () { var n = new Date(); this.setHours(n.getHours()); this.setMinutes(n.getMinutes()); this.setSeconds(n.getSeconds()); this.setMilliseconds(n.getMilliseconds()); return this; }; /** * Returns a new Date object that is an exact date and time copy of the original instance. * @return {Date} A new Date instance */ $P.clone = function () { return new Date(this.getTime()); }; /** * Compares this instance to a Date object and returns an number indication of their relative values. * @param {Date} Date object to compare [Required] * @return {Number} -1 = this is lessthan date. 0 = values are equal. 1 = this is greaterthan date. */ $P.compareTo = function (date) { return Date.compare(this, date); }; /** * Compares this instance to another Date object and returns true if they are equal. * @param {Date} Date object to compare. If no date to compare, new Date() [now] is used. * @return {Boolean} true if dates are equal. false if they are not equal. */ $P.equals = function (date) { return Date.equals(this, (date !== undefined ? date : new Date())); }; /** * Determines if this instance is between a range of two dates or equal to either the start or end dates. * @param {Date} Start of range [Required] * @param {Date} End of range [Required] * @return {Boolean} true is this is between or equal to the start and end dates, else false */ $P.between = function (start, end) { return this.getTime() >= start.getTime() && this.getTime() <= end.getTime(); }; /** * Determines if this date occurs after the date to compare to. * @param {Date} Date object to compare. If no date to compare, new Date() ("now") is used. * @return {Boolean} true if this date instance is greater than the date to compare to (or "now"), otherwise false. */ $P.isAfter = function (date) { return this.compareTo(date || new Date()) === 1; }; /** * Determines if this date occurs before the date to compare to. * @param {Date} Date object to compare. If no date to compare, new Date() ("now") is used. * @return {Boolean} true if this date instance is less than the date to compare to (or "now"). */ $P.isBefore = function (date) { return (this.compareTo(date || new Date()) === -1); }; /** * Determines if the current Date instance occurs today. * @return {Boolean} true if this date instance is 'today', otherwise false. */ /** * Determines if the current Date instance occurs on the same Date as the supplied 'date'. * If no 'date' to compare to is provided, the current Date instance is compared to 'today'. * @param {date} Date object to compare. If no date to compare, the current Date ("now") is used. * @return {Boolean} true if this Date instance occurs on the same Day as the supplied 'date'. */ $P.isToday = $P.isSameDay = function (date) { return this.clone().clearTime().equals((date || new Date()).clone().clearTime()); }; /** * Adds the specified number of milliseconds to this instance. * @param {Number} The number of milliseconds to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addMilliseconds = function (value) { if (!value) { return this; } this.setTime(this.getTime() + value * 1); return this; }; /** * Adds the specified number of seconds to this instance. * @param {Number} The number of seconds to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addSeconds = function (value) { if (!value) { return this; } return this.addMilliseconds(value * 1000); }; /** * Adds the specified number of seconds to this instance. * @param {Number} The number of seconds to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addMinutes = function (value) { if (!value) { return this; } return this.addMilliseconds(value * 60000); // 60*1000 }; /** * Adds the specified number of hours to this instance. * @param {Number} The number of hours to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addHours = function (value) { if (!value) { return this; } return this.addMilliseconds(value * 3600000); // 60*60*1000 }; /** * Adds the specified number of days to this instance. * @param {Number} The number of days to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addDays = function (value) { if (!value) { return this; } this.setDate(this.getDate() + value * 1); return this; }; /** * Adds the specified number of weekdays (ie - not sat or sun) to this instance. * @param {Number} The number of days to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addWeekdays = function (value) { if (!value) { return this; } var day = this.getDay(); var weeks = (Math.ceil(Math.abs(value)/7)); if (day === 0 || day === 6) { if (value > 0) { this.next().monday(); this.addDays(-1); day = this.getDay(); } } if (value < 0) { while (value < 0) { this.addDays(-1); day = this.getDay(); if (day !== 0 && day !== 6) { value++; } } return this; } else if (value > 5 || (6-day) <= value) { value = value + (weeks * 2); } return this.addDays(value); }; /** * Adds the specified number of weeks to this instance. * @param {Number} The number of weeks to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addWeeks = function (value) { if (!value) { return this; } return this.addDays(value * 7); }; /** * Adds the specified number of months to this instance. * @param {Number} The number of months to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addMonths = function (value) { if (!value) { return this; } var n = this.getDate(); this.setDate(1); this.setMonth(this.getMonth() + value * 1); this.setDate(Math.min(n, $D.getDaysInMonth(this.getFullYear(), this.getMonth()))); return this; }; $P.addQuarters = function (value) { if (!value) { return this; } // note this will take you to the same point in the quarter as you are now. // i.e. - if you are 15 days into the quarter you'll be 15 days into the resulting one. // bonus: this allows adding fractional quarters return this.addMonths(value * 3); }; /** * Adds the specified number of years to this instance. * @param {Number} The number of years to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addYears = function (value) { if (!value) { return this; } return this.addMonths(value * 12); }; /** * Adds (or subtracts) to the value of the years, months, weeks, days, hours, minutes, seconds, milliseconds of the date instance using given configuration object. Positive and Negative values allowed. * Example

	Date.today().add( { days: 1, months: 1 } )

	new Date().add( { years: -1 } )
	
* @param {Object} Configuration object containing attributes (months, days, etc.) * @return {Date} this */ $P.add = function (config) { if (typeof config === "number") { this._orient = config; return this; } var x = config; if (x.day) { // If we should be a different date than today (eg: for 'tomorrow -1d', etc). // Should only effect parsing, not direct usage (eg, Finish and FinishExact) if ((x.day - this.getDate()) !== 0) { this.setDate(x.day); } } if (x.milliseconds) { this.addMilliseconds(x.milliseconds); } if (x.seconds) { this.addSeconds(x.seconds); } if (x.minutes) { this.addMinutes(x.minutes); } if (x.hours) { this.addHours(x.hours); } if (x.weeks) { this.addWeeks(x.weeks); } if (x.months) { this.addMonths(x.months); } if (x.years) { this.addYears(x.years); } if (x.days) { this.addDays(x.days); } return this; }; /** * Get the week number. Week one (1) is the week which contains the first Thursday of the year. Monday is considered the first day of the week. * The .getWeek() function does NOT convert the date to UTC. The local datetime is used. * Please use .getISOWeek() to get the week of the UTC converted date. * @return {Number} 1 to 53 */ $P.getWeek = function (utc) { // Create a copy of this date object var self, target = new Date(this.valueOf()); if (utc) { target.addMinutes(target.getTimezoneOffset()); self = target.clone(); } else { self = this; } // ISO week date weeks start on monday // so correct the day number var dayNr = (self.getDay() + 6) % 7; // ISO 8601 states that week 1 is the week // with the first thursday of that year. // Set the target date to the thursday in the target week target.setDate(target.getDate() - dayNr + 3); // Store the millisecond value of the target date var firstThursday = target.valueOf(); // Set the target to the first thursday of the year // First set the target to january first target.setMonth(0, 1); // Not a thursday? Correct the date to the next thursday if (target.getDay() !== 4) { target.setMonth(0, 1 + ((4 - target.getDay()) + 7) % 7); } // The weeknumber is the number of weeks between the // first thursday of the year and the thursday in the target week return 1 + Math.ceil((firstThursday - target) / 604800000); // 604800000 = 7 * 24 * 3600 * 1000 }; /** * Get the ISO 8601 week number. Week one ("01") is the week which contains the first Thursday of the year. Monday is considered the first day of the week. * The .getISOWeek() function does convert the date to it's UTC value. Please use .getWeek() to get the week of the local date. * @return {String} "01" to "53" */ $P.getISOWeek = function () { return p(this.getWeek(true)); }; /** * Moves the date to Monday of the week set. Week one (1) is the week which contains the first Thursday of the year. * @param {Number} A Number (1 to 53) that represents the week of the year. * @return {Date} this */ $P.setWeek = function (n) { if ((n - this.getWeek()) === 0) { if (this.getDay() !== 1) { return this.moveToDayOfWeek(1, (this.getDay() > 1 ? -1 : 1)); } else { return this; } } else { return this.moveToDayOfWeek(1, (this.getDay() > 1 ? -1 : 1)).addWeeks(n - this.getWeek()); } }; $P.setQuarter = function (qtr) { var month = Math.abs(((qtr-1) * 3) + 1); return this.setMonth(month, 1); }; $P.getQuarter = function () { return Date.getQuarter(this); }; $P.getDaysLeftInQuarter = function () { return Date.getDaysLeftInQuarter(this); }; /** * Moves the date to the next n'th occurrence of the dayOfWeek starting from the beginning of the month. The number (-1) is a magic number and will return the last occurrence of the dayOfWeek in the month. * @param {Number} The dayOfWeek to move to * @param {Number} The n'th occurrence to move to. Use (-1) to return the last occurrence in the month * @return {Date} this */ $P.moveToNthOccurrence = function (dayOfWeek, occurrence) { if (dayOfWeek === "Weekday") { if (occurrence > 0) { this.moveToFirstDayOfMonth(); if (this.is().weekday()) { occurrence -= 1; } } else if (occurrence < 0) { this.moveToLastDayOfMonth(); if (this.is().weekday()) { occurrence += 1; } } else { return this; } return this.addWeekdays(occurrence); } var shift = 0; if (occurrence > 0) { shift = occurrence - 1; } else if (occurrence === -1) { this.moveToLastDayOfMonth(); if (this.getDay() !== dayOfWeek) { this.moveToDayOfWeek(dayOfWeek, -1); } return this; } return this.moveToFirstDayOfMonth().addDays(-1).moveToDayOfWeek(dayOfWeek, +1).addWeeks(shift); }; var moveToN = function (getFunc, addFunc, nVal) { return function (value, orient) { var diff = (value - this[getFunc]() + nVal * (orient || +1)) % nVal; return this[addFunc]((diff === 0) ? diff += nVal * (orient || +1) : diff); }; }; /** * Move to the next or last dayOfWeek based on the orient value. * @param {Number} The dayOfWeek to move to * @param {Number} Forward (+1) or Back (-1). Defaults to +1. [Optional] * @return {Date} this */ $P.moveToDayOfWeek = moveToN("getDay", "addDays", 7); /** * Move to the next or last month based on the orient value. * @param {Number} The month to move to. 0 = January, 11 = December * @param {Number} Forward (+1) or Back (-1). Defaults to +1. [Optional] * @return {Date} this */ $P.moveToMonth = moveToN("getMonth", "addMonths", 12); /** * Get the Ordinate of the current day ("th", "st", "rd"). * @return {String} */ $P.getOrdinate = function () { var num = this.getDate(); return ord(num); }; /** * Get the Ordinal day (numeric day number) of the year, adjusted for leap year. * @return {Number} 1 through 365 (366 in leap years) */ $P.getOrdinalNumber = function () { return Math.ceil((this.clone().clearTime() - new Date(this.getFullYear(), 0, 1)) / 86400000) + 1; }; /** * Get the time zone abbreviation of the current date. * @return {String} The abbreviated time zone name (e.g. "EST") */ $P.getTimezone = function () { return $D.getTimezoneAbbreviation(this.getUTCOffset(), this.isDaylightSavingTime()); }; $P.setTimezoneOffset = function (offset) { var here = this.getTimezoneOffset(), there = Number(offset) * -6 / 10; return (there || there === 0) ? this.addMinutes(there - here) : this; }; $P.setTimezone = function (offset) { return this.setTimezoneOffset($D.getTimezoneOffset(offset)); }; /** * Indicates whether Daylight Saving Time is observed in the current time zone. * @return {Boolean} true|false */ $P.hasDaylightSavingTime = function () { return (Date.today().set({month: 0, day: 1}).getTimezoneOffset() !== Date.today().set({month: 6, day: 1}).getTimezoneOffset()); }; /** * Indicates whether this Date instance is within the Daylight Saving Time range for the current time zone. * @return {Boolean} true|false */ $P.isDaylightSavingTime = function () { return Date.today().set({month: 0, day: 1}).getTimezoneOffset() !== this.getTimezoneOffset(); }; /** * Get the offset from UTC of the current date. * @return {String} The 4-character offset string prefixed with + or - (e.g. "-0500") */ $P.getUTCOffset = function (offset) { var n = (offset || this.getTimezoneOffset()) * -10 / 6, r; if (n < 0) { r = (n - 10000).toString(); return r.charAt(0) + r.substr(2); } else { r = (n + 10000).toString(); return "+" + r.substr(1); } }; /** * Returns the number of milliseconds between this date and date. * @param {Date} Defaults to now * @return {Number} The diff in milliseconds */ $P.getElapsed = function (date) { return (date || new Date()) - this; }; /** * Set the value of year, month, day, hour, minute, second, millisecond of date instance using given configuration object. * Example

	Date.today().set( { day: 20, month: 1 } )

	new Date().set( { millisecond: 0 } )
	
* * @param {Object} Configuration object containing attributes (month, day, etc.) * @return {Date} this */ $P.set = function (config) { config = validateConfigObject.call(this, config); var key; for (key in config) { if (Object.prototype.hasOwnProperty.call(config, key)) { var name = key.charAt(0).toUpperCase() + key.slice(1); var addFunc, getFunc; if (key !== "week" && key !== "month" && key !== "timezone" && key !== "timezoneOffset") { name += "s"; } addFunc = "add" + name; getFunc = "get" + name; if (key === "month") { addFunc = addFunc + "s"; } else if (key === "year"){ getFunc = "getFullYear"; } if (key !== "day" && key !== "timezone" && key !== "timezoneOffset" && key !== "week" && key !== "hour") { this[addFunc](config[key] - this[getFunc]()); } else if ( key === "timezone"|| key === "timezoneOffset" || key === "week" || key === "hour") { this["set"+name](config[key]); } } } // day has to go last because you can't validate the day without first knowing the month if (config.day) { this.addDays(config.day - this.getDate()); } return this; }; /** * Moves the date to the first day of the month. * @return {Date} this */ $P.moveToFirstDayOfMonth = function () { return this.set({ day: 1 }); }; /** * Moves the date to the last day of the month. * @return {Date} this */ $P.moveToLastDayOfMonth = function () { return this.set({ day: $D.getDaysInMonth(this.getFullYear(), this.getMonth())}); }; /** * Converts the value of the current Date object to its equivalent string representation. * Format Specifiers * CUSTOM DATE AND TIME FORMAT STRINGS * Format Description Example * ------ --------------------------------------------------------------------------- ----------------------- * s The seconds of the minute between 0-59. "0" to "59" * ss The seconds of the minute with leading zero if required. "00" to "59" * * m The minute of the hour between 0-59. "0" or "59" * mm The minute of the hour with leading zero if required. "00" or "59" * * h The hour of the day between 1-12. "1" to "12" * hh The hour of the day with leading zero if required. "01" to "12" * * H The hour of the day between 0-23. "0" to "23" * HH The hour of the day with leading zero if required. "00" to "23" * * d The day of the month between 1 and 31. "1" to "31" * dd The day of the month with leading zero if required. "01" to "31" * ddd Abbreviated day name. Date.CultureInfo.abbreviatedDayNames. "Mon" to "Sun" * dddd The full day name. Date.CultureInfo.dayNames. "Monday" to "Sunday" * * M The month of the year between 1-12. "1" to "12" * MM The month of the year with leading zero if required. "01" to "12" * MMM Abbreviated month name. Date.CultureInfo.abbreviatedMonthNames. "Jan" to "Dec" * MMMM The full month name. Date.CultureInfo.monthNames. "January" to "December" * * yy The year as a two-digit number. "99" or "08" * yyyy The full four digit year. "1999" or "2008" * * t Displays the first character of the A.M./P.M. designator. "A" or "P" * Date.CultureInfo.amDesignator or Date.CultureInfo.pmDesignator * tt Displays the A.M./P.M. designator. "AM" or "PM" * Date.CultureInfo.amDesignator or Date.CultureInfo.pmDesignator * * S The ordinal suffix ("st, "nd", "rd" or "th") of the current day. "st, "nd", "rd" or "th" * * STANDARD DATE AND TIME FORMAT STRINGS * Format Description Example *------ --------------------------------------------------------------------------- ----------------------- * d The CultureInfo shortDate Format Pattern "M/d/yyyy" * D The CultureInfo longDate Format Pattern "dddd, MMMM dd, yyyy" * F The CultureInfo fullDateTime Format Pattern "dddd, MMMM dd, yyyy h:mm:ss tt" * m The CultureInfo monthDay Format Pattern "MMMM dd" * r The CultureInfo rfc1123 Format Pattern "ddd, dd MMM yyyy HH:mm:ss GMT" * s The CultureInfo sortableDateTime Format Pattern "yyyy-MM-ddTHH:mm:ss" * t The CultureInfo shortTime Format Pattern "h:mm tt" * T The CultureInfo longTime Format Pattern "h:mm:ss tt" * u The CultureInfo universalSortableDateTime Format Pattern "yyyy-MM-dd HH:mm:ssZ" * y The CultureInfo yearMonth Format Pattern "MMMM, yyyy" * * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @return {String} A string representation of the current Date object. */ var ord = function (n) { switch (n * 1) { case 1: case 21: case 31: return "st"; case 2: case 22: return "nd"; case 3: case 23: return "rd"; default: return "th"; } }; var parseStandardFormats = function (format) { var y, c = Date.CultureInfo.formatPatterns; switch (format) { case "d": return this.toString(c.shortDate); case "D": return this.toString(c.longDate); case "F": return this.toString(c.fullDateTime); case "m": return this.toString(c.monthDay); case "r": case "R": y = this.clone().addMinutes(this.getTimezoneOffset()); return y.toString(c.rfc1123) + " GMT"; case "s": return this.toString(c.sortableDateTime); case "t": return this.toString(c.shortTime); case "T": return this.toString(c.longTime); case "u": y = this.clone().addMinutes(this.getTimezoneOffset()); return y.toString(c.universalSortableDateTime); case "y": return this.toString(c.yearMonth); default: return false; } }; var parseFormatStringsClosure = function (context) { return function (m) { if (m.charAt(0) === "\\") { return m.replace("\\", ""); } switch (m) { case "hh": return p(context.getHours() < 13 ? (context.getHours() === 0 ? 12 : context.getHours()) : (context.getHours() - 12)); case "h": return context.getHours() < 13 ? (context.getHours() === 0 ? 12 : context.getHours()) : (context.getHours() - 12); case "HH": return p(context.getHours()); case "H": return context.getHours(); case "mm": return p(context.getMinutes()); case "m": return context.getMinutes(); case "ss": return p(context.getSeconds()); case "s": return context.getSeconds(); case "yyyy": return p(context.getFullYear(), 4); case "yy": return p(context.getFullYear()); case "y": return context.getFullYear(); case "E": case "dddd": return Date.CultureInfo.dayNames[context.getDay()]; case "ddd": return Date.CultureInfo.abbreviatedDayNames[context.getDay()]; case "dd": return p(context.getDate()); case "d": return context.getDate(); case "MMMM": return Date.CultureInfo.monthNames[context.getMonth()]; case "MMM": return Date.CultureInfo.abbreviatedMonthNames[context.getMonth()]; case "MM": return p((context.getMonth() + 1)); case "M": return context.getMonth() + 1; case "t": return context.getHours() < 12 ? Date.CultureInfo.amDesignator.substring(0, 1) : Date.CultureInfo.pmDesignator.substring(0, 1); case "tt": return context.getHours() < 12 ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator; case "S": return ord(context.getDate()); case "W": return context.getWeek(); case "WW": return context.getISOWeek(); case "Q": return "Q" + context.getQuarter(); case "q": return String(context.getQuarter()); case "z": return context.getTimezone(); case "Z": case "X": return Date.getTimezoneOffset(context.getTimezone()); case "ZZ": // Timezone offset in seconds return context.getTimezoneOffset() * -60; case "u": return context.getDay(); case "L": return ($D.isLeapYear(context.getFullYear())) ? 1 : 0; case "B": // Swatch Internet Time (.beats) return "@"+((context.getUTCSeconds() + (context.getUTCMinutes()*60) + ((context.getUTCHours()+1)*3600))/86.4); default: return m; } }; }; $P.toString = function (format, ignoreStandards) { // Standard Date and Time Format Strings. Formats pulled from CultureInfo file and // may vary by culture. if (!ignoreStandards && format && format.length === 1) { output = parseStandardFormats.call(this, format); if (output) { return output; } } var parseFormatStrings = parseFormatStringsClosure(this); return format ? format.replace(/((\\)?(dd?d?d?|MM?M?M?|yy?y?y?|hh?|HH?|mm?|ss?|tt?|S|q|Q|WW?W?W?)(?![^\[]*\]))/g, parseFormatStrings).replace(/\[|\]/g, "") : this._toString(); }; }()); /************************************************************* * SugarPak - Domain Specific Language - Syntactical Sugar * *************************************************************/ (function () { var $D = Date, $P = $D.prototype, $N = Number.prototype; // private $P._orient = +1; // private $P._nth = null; // private $P._is = false; // private $P._same = false; // private $P._isSecond = false; // private $N._dateElement = "days"; /** * Moves the date to the next instance of a date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.today().next().friday();
	Date.today().next().fri();
	Date.today().next().march();
	Date.today().next().mar();
	Date.today().next().week();
	
* * @return {Date} date */ $P.next = function () { this._move = true; this._orient = +1; return this; }; /** * Creates a new Date (Date.today()) and moves the date to the next instance of the date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.next().friday();
	Date.next().fri();
	Date.next().march();
	Date.next().mar();
	Date.next().week();
	
* * @return {Date} date */ $D.next = function () { return $D.today().next(); }; /** * Moves the date to the previous instance of a date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.today().last().friday();
	Date.today().last().fri();
	Date.today().last().march();
	Date.today().last().mar();
	Date.today().last().week();
	
* * @return {Date} date */ $P.last = $P.prev = $P.previous = function () { this._move = true; this._orient = -1; return this; }; /** * Creates a new Date (Date.today()) and moves the date to the previous instance of the date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.last().friday();
	Date.last().fri();
	Date.previous().march();
	Date.prev().mar();
	Date.last().week();
	
* * @return {Date} date */ $D.last = $D.prev = $D.previous = function () { return $D.today().last(); }; /** * Performs a equality check when followed by either a month name, day name or .weekday() function. * Example

	Date.today().is().friday(); // true|false
	Date.today().is().fri();
	Date.today().is().march();
	Date.today().is().mar();
	
* * @return {Boolean} true|false */ $P.is = function () { this._is = true; return this; }; /** * Determines if two date objects occur on/in exactly the same instance of the subsequent date part function. * The function .same() must be followed by a date part function (example: .day(), .month(), .year(), etc). * * An optional Date can be passed in the date part function. If now date is passed as a parameter, 'Now' is used. * * The following example demonstrates how to determine if two dates fall on the exact same day. * * Example

	var d1 = Date.today(); // today at 00:00
	var d2 = new Date();   // exactly now.

	// Do they occur on the same day?
	d1.same().day(d2); // true
	
	// Do they occur on the same hour?
	d1.same().hour(d2); // false, unless d2 hour is '00' (midnight).
	
	// What if it's the same day, but one year apart?
	var nextYear = Date.today().add(1).year();

	d1.same().day(nextYear); // false, because the dates must occur on the exact same day. 
	
* * Scenario: Determine if a given date occurs during some week period 2 months from now. * * Example

	var future = Date.today().add(2).months();
	return someDate.same().week(future); // true|false;
	
* * @return {Boolean} true|false */ $P.same = function () { this._same = true; this._isSecond = false; return this; }; /** * Determines if the current date/time occurs during Today. Must be preceded by the .is() function. * Example

	someDate.is().today();    // true|false
	new Date().is().today();  // true
	Date.today().is().today();// true
	Date.today().add(-1).day().is().today(); // false
	
* * @return {Boolean} true|false */ $P.today = function () { return this.same().day(); }; /** * Determines if the current date is a weekday. This function must be preceded by the .is() function. * Example

	Date.today().is().weekday(); // true|false
	
* * @return {Boolean} true|false */ $P.weekday = function () { if (this._nth) { return df("Weekday").call(this); } if (this._move) { return this.addWeekdays(this._orient); } if (this._is) { this._is = false; return (!this.is().sat() && !this.is().sun()); } return false; }; /** * Determines if the current date is on the weekend. This function must be preceded by the .is() function. * Example

	Date.today().is().weekend(); // true|false
	
* * @return {Boolean} true|false */ $P.weekend = function () { if (this._is) { this._is = false; return (this.is().sat() || this.is().sun()); } return false; }; /** * Sets the Time of the current Date instance. A string "6:15 pm" or config object {hour:18, minute:15} are accepted. * Example

	// Set time to 6:15pm with a String
	Date.today().at("6:15pm");

	// Set time to 6:15pm with a config object
	Date.today().at({hour:18, minute:15});
	
* * @return {Date} date */ $P.at = function (time) { return (typeof time === "string") ? $D.parse(this.toString("d") + " " + time) : this.set(time); }; /** * Creates a new Date() and adds this (Number) to the date based on the preceding date element function (eg. second|minute|hour|day|month|year). * Example

	// Undeclared Numbers must be wrapped with parentheses. Requirment of JavaScript.
	(3).days().fromNow();
	(6).months().fromNow();

	// Declared Number variables do not require parentheses. 
	var n = 6;
	n.months().fromNow();
	
* * @return {Date} A new Date instance */ $N.fromNow = $N.after = function (date) { var c = {}; c[this._dateElement] = this; return ((!date) ? new Date() : date.clone()).add(c); }; /** * Creates a new Date() and subtract this (Number) from the date based on the preceding date element function (eg. second|minute|hour|day|month|year). * Example

	// Undeclared Numbers must be wrapped with parentheses. Requirment of JavaScript.
	(3).days().ago();
	(6).months().ago();

	// Declared Number variables do not require parentheses. 
	var n = 6;
	n.months().ago();
	
* * @return {Date} A new Date instance */ $N.ago = $N.before = function (date) { var c = {}, s = (this._dateElement[this._dateElement.length-1] !== "s") ? this._dateElement + "s" : this._dateElement; c[s] = this * -1; return ((!date) ? new Date() : date.clone()).add(c); }; // Do NOT modify the following string tokens. These tokens are used to build dynamic functions. // All culture-specific strings can be found in the CultureInfo files. var dx = ("sunday monday tuesday wednesday thursday friday saturday").split(/\s/), mx = ("january february march april may june july august september october november december").split(/\s/), px = ("Millisecond Second Minute Hour Day Week Month Year Quarter Weekday").split(/\s/), pxf = ("Milliseconds Seconds Minutes Hours Date Week Month FullYear Quarter").split(/\s/), nth = ("final first second third fourth fifth").split(/\s/), de; /** * Returns an object literal of all the date parts. * Example

	var o = new Date().toObject();
	
	// { year: 2008, month: 4, week: 20, day: 13, hour: 18, minute: 9, second: 32, millisecond: 812 }
	
	// The object properties can be referenced directly from the object.
	
	alert(o.day);  // alerts "13"
	alert(o.year); // alerts "2008"
	
* * @return {Date} An object literal representing the original date object. */ $P.toObject = function () { var o = {}; for (var i = 0; i < px.length; i++) { if (this["get" + pxf[i]]) { o[px[i].toLowerCase()] = this["get" + pxf[i]](); } } return o; }; /** * Returns a date created from an object literal. Ignores the .week property if set in the config. * Example

	var o = new Date().toObject();
	
	return Date.fromObject(o); // will return the same date. 

	var o2 = {month: 1, day: 20, hour: 18}; // birthday party!
	Date.fromObject(o2);
	
* * @return {Date} An object literal representing the original date object. */ $D.fromObject = function(config) { config.week = null; return Date.today().set(config); }; // Create day name functions and abbreviated day name functions (eg. monday(), friday(), fri()). var df = function (n) { return function () { if (this._is) { this._is = false; return this.getDay() === n; } if (this._move) { this._move = null; } if (this._nth !== null) { // If the .second() function was called earlier, remove the _orient // from the date, and then continue. // This is required because 'second' can be used in two different context. // // Example // // Date.today().add(1).second(); // Date.march().second().monday(); // // Things get crazy with the following... // Date.march().add(1).second().second().monday(); // but it works!! // if (this._isSecond) { this.addSeconds(this._orient * -1); } // make sure we reset _isSecond this._isSecond = false; var ntemp = this._nth; this._nth = null; var temp = this.clone().moveToLastDayOfMonth(); this.moveToNthOccurrence(n, ntemp); if (this > temp) { throw new RangeError($D.getDayName(n) + " does not occur " + ntemp + " times in the month of " + $D.getMonthName(temp.getMonth()) + " " + temp.getFullYear() + "."); } return this; } return this.moveToDayOfWeek(n, this._orient); }; }; var sdf = function (n) { return function () { var t = $D.today(), shift = n - t.getDay(); if (n === 0 && Date.CultureInfo.firstDayOfWeek === 1 && t.getDay() !== 0) { shift = shift + 7; } return t.addDays(shift); }; }; // Create month name functions and abbreviated month name functions (eg. january(), march(), mar()). var month_instance_functions = function (n) { return function () { if (this._is) { this._is = false; return this.getMonth() === n; } return this.moveToMonth(n, this._orient); }; }; var month_static_functions = function (n) { return function () { return $D.today().set({ month: n, day: 1 }); }; }; var processTerms = function (names, staticFunc, instanceFunc) { for (var i = 0; i < names.length; i++) { // Create constant static Name variables. $D[names[i].toUpperCase()] = $D[names[i].toUpperCase().substring(0, 3)] = i; // Create Name functions. $D[names[i]] = $D[names[i].substring(0, 3)] = staticFunc(i); // Create Name instance functions. $P[names[i]] = $P[names[i].substring(0, 3)] = instanceFunc(i); } }; processTerms(dx, sdf, df); processTerms(mx, month_static_functions, month_instance_functions); // Create date element functions and plural date element functions used with Date (eg. day(), days(), months()). var ef = function (j) { return function () { // if the .second() function was called earlier, the _orient // has alread been added. Just return this and reset _isSecond. if (this._isSecond) { this._isSecond = false; return this; } if (this._same) { this._same = this._is = false; var o1 = this.toObject(), o2 = (arguments[0] || new Date()).toObject(), v = "", k = j.toLowerCase(); // the substr trick with -1 doesn't work in IE8 or less k = (k[k.length-1] === "s") ? k.substring(0,k.length-1) : k; for (var m = (px.length - 1); m > -1; m--) { v = px[m].toLowerCase(); if (o1[v] !== o2[v]) { return false; } if (k === v) { break; } } return true; } if (j.substring(j.length - 1) !== "s") { j += "s"; } if (this._move) { this._move = null; } return this["add" + j](this._orient); }; }; var nf = function (n) { return function () { this._dateElement = n; return this; }; }; for (var k = 0; k < px.length; k++) { de = px[k].toLowerCase(); if(de !== "weekday") { // Create date element functions and plural date element functions used with Date (eg. day(), days(), months()). $P[de] = $P[de + "s"] = ef(px[k]); // Create date element functions and plural date element functions used with Number (eg. day(), days(), months()). $N[de] = $N[de + "s"] = nf(de + "s"); } } $P._ss = ef("Second"); var nthfn = function (n) { return function (dayOfWeek) { if (this._same) { return this._ss(arguments[0]); } if (dayOfWeek || dayOfWeek === 0) { return this.moveToNthOccurrence(dayOfWeek, n); } this._nth = n; // if the operator is 'second' add the _orient, then deal with it later... if (n === 2 && (dayOfWeek === undefined || dayOfWeek === null)) { this._isSecond = true; return this.addSeconds(this._orient); } return this; }; }; for (var l = 0; l < nth.length; l++) { $P[nth[l]] = (l === 0) ? nthfn(-1) : nthfn(l); } }()); (function () { "use strict"; Date.Parsing = { Exception: function (s) { this.message = "Parse error at '" + s.substring(0, 10) + " ...'"; } }; var $P = Date.Parsing; var dayOffsets = { standard: [0,31,59,90,120,151,181,212,243,273,304,334], leap: [0,31,60,91,121,152,182,213,244,274,305,335] }; $P.isLeapYear = function(year) { return ((year % 4 === 0) && (year % 100 !== 0)) || (year % 400 === 0); }; var utils = { multiReplace : function (str, hash ) { var key; for (key in hash) { if (Object.prototype.hasOwnProperty.call(hash, key)) { var regex; if (typeof hash[key] === "function") { } else { regex = (hash[key] instanceof RegExp) ? hash[key] : new RegExp(hash[key], "g"); } str = str.replace(regex, key); } } return str; }, getDayOfYearFromWeek : function (obj) { var d, jan4, offset; obj.weekDay = (!obj.weekDay && obj.weekDay !== 0) ? 1 : obj.weekDay; d = new Date(obj.year, 0, 4); jan4 = d.getDay() === 0 ? 7 : d.getDay(); // JS is 0 indexed on Sunday. offset = jan4+3; obj.dayOfYear = ((obj.week * 7) + (obj.weekDay === 0 ? 7 : obj.weekDay))-offset; return obj; }, getDayOfYear : function (obj, dayOffset) { if (!obj.dayOfYear) { obj = utils.getDayOfYearFromWeek(obj); } for (var i=0;i <= dayOffset.length;i++) { if (obj.dayOfYear < dayOffset[i] || i === dayOffset.length) { obj.day = obj.day ? obj.day : (obj.dayOfYear - dayOffset[i-1]); break; } else { obj.month = i; } } return obj; }, adjustForTimeZone : function (obj, date) { var offset; if (obj.zone.toUpperCase() === "Z" || (obj.zone_hours === 0 && obj.zone_minutes === 0)) { // it's UTC/GML so work out the current timeszone offset offset = -date.getTimezoneOffset(); } else { offset = (obj.zone_hours*60) + (obj.zone_minutes || 0); if (obj.zone_sign === "+") { offset *= -1; } offset -= date.getTimezoneOffset(); } date.setMinutes(date.getMinutes()+offset); return date; }, setDefaults : function (obj) { obj.year = obj.year || Date.today().getFullYear(); obj.hours = obj.hours || 0; obj.minutes = obj.minutes || 0; obj.seconds = obj.seconds || 0; obj.milliseconds = obj.milliseconds || 0; if (!(!obj.month && (obj.week || obj.dayOfYear))) { // if we have a month, or if we don't but don't have the day calculation data obj.month = obj.month || 0; obj.day = obj.day || 1; } return obj; }, dataNum: function (data, mod, explict, postProcess) { var dataNum = data*1; if (mod) { if (postProcess) { return data ? mod(data)*1 : data; } else { return data ? mod(dataNum) : data; } } else if (!explict){ return data ? dataNum : data; } else { return (data && typeof data !== "undefined") ? dataNum : data; } }, timeDataProcess: function (obj) { var timeObj = {}; for (var x in obj.data) { if (obj.data.hasOwnProperty(x)) { timeObj[x] = obj.ignore[x] ? obj.data[x] : utils.dataNum(obj.data[x], obj.mods[x], obj.explict[x], obj.postProcess[x]); } } if (obj.data.secmins) { obj.data.secmins = obj.data.secmins.replace(",", ".") * 60; if (!timeObj.minutes) { timeObj.minutes = obj.data.secmins; } else if (!timeObj.seconds) { timeObj.seconds = obj.data.secmins; } delete obj.secmins; } return timeObj; }, buildTimeObjectFromData: function (data) { var time = utils.timeDataProcess({ data: { year : data[1], month : data[5], day : data[7], week : data[8], dayOfYear : data[10], hours : data[15], zone_hours : data[23], zone_minutes : data[24], zone : data[21], zone_sign : data[22], weekDay : data[9], minutes: data[16], seconds: data[19], milliseconds: data[20], secmins: data[18] }, mods: { month: function(data) { return data-1; }, weekDay: function (data) { data = Math.abs(data); return (data === 7 ? 0 : data); }, minutes: function (data) { return data.replace(":",""); }, seconds: function (data) { return Math.floor( (data.replace(":","").replace(",","."))*1 ); }, milliseconds: function (data) { return (data.replace(",",".")*1000); } }, postProcess: { minutes: true, seconds: true, milliseconds: true }, explict: { zone_hours: true, zone_minutes: true }, ignore: { zone: true, zone_sign: true, secmins: true } }); return time; }, addToHash: function (hash, keys, data) { keys = keys; data = data; var len = keys.length; for (var i = 0; i < len; i++) { hash[keys[i]] = data[i]; } return hash; }, combineRegex: function (r1, r2) { return new RegExp("(("+r1.source+")\\s("+r2.source+"))"); }, getDateNthString: function(add, last, inc){ if (add) { return Date.today().addDays(inc).toString("d"); } else if (last) { return Date.today().last()[inc]().toString("d"); } }, buildRegexData: function (array) { var arr = []; var len = array.length; for (var i=0; i < len; i++) { if (Object.prototype.toString.call(array[i]) === '[object Array]') { // oldIE compat version of Array.isArray arr.push(this.combineRegex(array[i][0], array[i][1])); } else { arr.push(array[i]); } } return arr; } }; $P.processTimeObject = function (obj) { var date, dayOffset; utils.setDefaults(obj); dayOffset = ($P.isLeapYear(obj.year)) ? dayOffsets.leap : dayOffsets.standard; if (!obj.month && (obj.week || obj.dayOfYear)) { utils.getDayOfYear(obj, dayOffset); } else { obj.dayOfYear = dayOffset[obj.month] + obj.day; } date = new Date(obj.year, obj.month, obj.day, obj.hours, obj.minutes, obj.seconds, obj.milliseconds); if (obj.zone) { utils.adjustForTimeZone(obj, date); // adjust (and calculate) for timezone } return date; }; $P.ISO = { regex : /^([\+-]?\d{4}(?!\d{2}\b))((-?)((0[1-9]|1[0-2])(\3([12]\d|0[1-9]|3[01]))?|W([0-4]\d|5[0-3])(-?[1-7])?|(00[1-9]|0[1-9]\d|[12]\d{2}|3([0-5]\d|6[1-6])))([T\s]((([01]\d|2[0-4])((:?)[0-5]\d)?|24\:?00)([\.,]\d+(?!:))?)?(\17[0-5]\d([\.,]\d+)?)?\s?([zZ]|([\+-])([01]\d|2[0-3]):?([0-5]\d)?)?)?)?$/, parse : function (s) { var time, data = s.match(this.regex); if (!data || !data.length) { return null; } time = utils.buildTimeObjectFromData(data); if (!time.year || (!time.year && (!time.month && !time.day) && (!time.week && !time.dayOfYear)) ) { return null; } return $P.processTimeObject(time); } }; $P.Numeric = { isNumeric: function (e){return!isNaN(parseFloat(e))&&isFinite(e);}, regex: /\b([0-1]?[0-9])([0-3]?[0-9])([0-2]?[0-9]?[0-9][0-9])\b/i, parse: function (s) { var data, i, time = {}, order = Date.CultureInfo.dateElementOrder.split(""); if (!(this.isNumeric(s)) || // if it's non-numeric OR (s[0] === "+" && s[0] === "-")) { // It's an arithmatic string (eg +/-1000) return null; } if (s.length < 5 && s.indexOf(".") < 0 && s.indexOf("/") < 0) { // assume it's just a year. time.year = s; return $P.processTimeObject(time); } data = s.match(this.regex); if (!data || !data.length) { return null; } for (i=0; i < order.length; i++) { switch(order[i]) { case "d": time.day = data[i+1]; break; case "m": time.month = (data[i+1]-1); break; case "y": time.year = data[i+1]; break; } } return $P.processTimeObject(time); } }; $P.Normalizer = { regexData: function () { var $R = Date.CultureInfo.regexPatterns; return utils.buildRegexData([ $R.tomorrow, $R.yesterday, [$R.past, $R.mon], [$R.past, $R.tue], [$R.past, $R.wed], [$R.past, $R.thu], [$R.past, $R.fri], [$R.past, $R.sat], [$R.past, $R.sun] ]); }, basicReplaceHash : function() { var $R = Date.CultureInfo.regexPatterns; return { "January": $R.jan.source, "February": $R.feb, "March": $R.mar, "April": $R.apr, "May": $R.may, "June": $R.jun, "July": $R.jul, "August": $R.aug, "September": $R.sep, "October": $R.oct, "November": $R.nov, "December": $R.dec, "": /\bat\b/gi, " ": /\s{2,}/, "am": $R.inTheMorning, "9am": $R.thisMorning, "pm": $R.inTheEvening, "7pm":$R.thisEvening }; }, keys : function(){ return [ utils.getDateNthString(true, false, 1), // tomorrow utils.getDateNthString(true, false, -1), // yesterday utils.getDateNthString(false, true, "monday"), //last mon utils.getDateNthString(false, true, "tuesday"), //last tues utils.getDateNthString(false, true, "wednesday"), //last wed utils.getDateNthString(false, true, "thursday"), //last thurs utils.getDateNthString(false, true, "friday"), //last fri utils.getDateNthString(false, true, "saturday"), //last sat utils.getDateNthString(false, true, "sunday") //last sun ]; }, buildRegexFunctions: function () { var $R = Date.CultureInfo.regexPatterns; var __ = Date.i18n.__; var tomorrowRE = new RegExp("(\\b\\d\\d?("+__("AM")+"|"+__("PM")+")? )("+$R.tomorrow.source.slice(1)+")", "i"); // adapted tomorrow regex for AM PM relative dates var todayRE = new RegExp($R.today.source + "(?!\\s*([+-]))\\b"); // today, but excludes the math operators (eg "today + 2h") this.replaceFuncs = [ [todayRE, function (full) { return (full.length > 1) ? Date.today().toString("d") : full; }], [tomorrowRE, function(full, m1) { var t = Date.today().addDays(1).toString("d"); return (t + " " + m1); }], [$R.amThisMorning, function(str, am){return am;}], [$R.pmThisEvening, function(str, pm){return pm;}] ]; }, buildReplaceData: function () { this.buildRegexFunctions(); this.replaceHash = utils.addToHash(this.basicReplaceHash(), this.keys(), this.regexData()); }, stringReplaceFuncs: function (s) { for (var i=0; i < this.replaceFuncs.length; i++) { s = s.replace(this.replaceFuncs[i][0], this.replaceFuncs[i][1]); } return s; }, parse: function (s) { s = this.stringReplaceFuncs(s); s = utils.multiReplace(s, this.replaceHash); try { var n = s.split(/([\s\-\.\,\/\x27]+)/); if (n.length === 3 && $P.Numeric.isNumeric(n[0]) && $P.Numeric.isNumeric(n[2]) && (n[2].length >= 4)) { // ok, so we're dealing with x/year. But that's not a full date. // This fixes wonky dateElementOrder parsing when set to dmy order. if (Date.CultureInfo.dateElementOrder[0] === "d") { s = "1/" + n[0] + "/" + n[2]; // set to 1st of month and normalize the seperator } } } catch (e) {} return s; } }; $P.Normalizer.buildReplaceData(); }()); (function () { var $P = Date.Parsing; var _ = $P.Operators = { // // Tokenizers // rtoken: function (r) { // regex token return function (s) { var mx = s.match(r); if (mx) { return ([ mx[0], s.substring(mx[0].length) ]); } else { throw new $P.Exception(s); } }; }, token: function () { // whitespace-eating token return function (s) { return _.rtoken(new RegExp("^\\s*" + s + "\\s*"))(s); }; }, stoken: function (s) { // string token return _.rtoken(new RegExp("^" + s)); }, // Atomic Operators until: function (p) { return function (s) { var qx = [], rx = null; while (s.length) { try { rx = p.call(this, s); } catch (e) { qx.push(rx[0]); s = rx[1]; continue; } break; } return [ qx, s ]; }; }, many: function (p) { return function (s) { var rx = [], r = null; while (s.length) { try { r = p.call(this, s); } catch (e) { return [ rx, s ]; } rx.push(r[0]); s = r[1]; } return [ rx, s ]; }; }, // generator operators -- see below optional: function (p) { return function (s) { var r = null; try { r = p.call(this, s); } catch (e) { return [ null, s ]; } return [ r[0], r[1] ]; }; }, not: function (p) { return function (s) { try { p.call(this, s); } catch (e) { return [null, s]; } throw new $P.Exception(s); }; }, ignore: function (p) { return p ? function (s) { var r = null; r = p.call(this, s); return [null, r[1]]; } : null; }, product: function () { var px = arguments[0], qx = Array.prototype.slice.call(arguments, 1), rx = []; for (var i = 0 ; i < px.length ; i++) { rx.push(_.each(px[i], qx)); } return rx; }, cache: function (rule) { var cache = {}, cache_length = 0, cache_keys = [], CACHE_MAX = Date.Config.CACHE_MAX || 100000, r = null; var cacheCheck = function () { if (cache_length === CACHE_MAX) { // kill several keys, don't want to have to do this all the time... for (var i=0; i < 10; i++) { var key = cache_keys.shift(); if (key) { delete cache[key]; cache_length--; } } } }; return function (s) { cacheCheck(); try { r = cache[s] = (cache[s] || rule.call(this, s)); } catch (e) { r = cache[s] = e; } cache_length++; cache_keys.push(s); if (r instanceof $P.Exception) { throw r; } else { return r; } }; }, // vector operators -- see below any: function () { var px = arguments; return function (s) { var r = null; for (var i = 0; i < px.length; i++) { if (px[i] == null) { continue; } try { r = (px[i].call(this, s)); } catch (e) { r = null; } if (r) { return r; } } throw new $P.Exception(s); }; }, each: function () { var px = arguments; return function (s) { var rx = [], r = null; for (var i = 0; i < px.length ; i++) { if (px[i] == null) { continue; } try { r = (px[i].call(this, s)); } catch (e) { throw new $P.Exception(s); } rx.push(r[0]); s = r[1]; } return [ rx, s]; }; }, all: function () { var px = arguments, _ = _; return _.each(_.optional(px)); }, // delimited operators sequence: function (px, d, c) { d = d || _.rtoken(/^\s*/); c = c || null; if (px.length === 1) { return px[0]; } return function (s) { var r = null, q = null; var rx = []; for (var i = 0; i < px.length ; i++) { try { r = px[i].call(this, s); } catch (e) { break; } rx.push(r[0]); try { q = d.call(this, r[1]); } catch (ex) { q = null; break; } s = q[1]; } if (!r) { throw new $P.Exception(s); } if (q) { throw new $P.Exception(q[1]); } if (c) { try { r = c.call(this, r[1]); } catch (ey) { throw new $P.Exception(r[1]); } } return [ rx, (r?r[1]:s) ]; }; }, // // Composite Operators // between: function (d1, p, d2) { d2 = d2 || d1; var _fn = _.each(_.ignore(d1), p, _.ignore(d2)); return function (s) { var rx = _fn.call(this, s); return [[rx[0][0], r[0][2]], rx[1]]; }; }, list: function (p, d, c) { d = d || _.rtoken(/^\s*/); c = c || null; return (p instanceof Array ? _.each(_.product(p.slice(0, -1), _.ignore(d)), p.slice(-1), _.ignore(c)) : _.each(_.many(_.each(p, _.ignore(d))), px, _.ignore(c))); }, set: function (px, d, c) { d = d || _.rtoken(/^\s*/); c = c || null; return function (s) { // r is the current match, best the current 'best' match // which means it parsed the most amount of input var r = null, p = null, q = null, rx = null, best = [[], s], last = false; // go through the rules in the given set for (var i = 0; i < px.length ; i++) { // last is a flag indicating whether this must be the last element // if there is only 1 element, then it MUST be the last one q = null; p = null; r = null; last = (px.length === 1); // first, we try simply to match the current pattern // if not, try the next pattern try { r = px[i].call(this, s); } catch (e) { continue; } // since we are matching against a set of elements, the first // thing to do is to add r[0] to matched elements rx = [[r[0]], r[1]]; // if we matched and there is still input to parse and // we don't already know this is the last element, // we're going to next check for the delimiter ... // if there's none, or if there's no input left to parse // than this must be the last element after all ... if (r[1].length > 0 && ! last) { try { q = d.call(this, r[1]); } catch (ex) { last = true; } } else { last = true; } // if we parsed the delimiter and now there's no more input, // that means we shouldn't have parsed the delimiter at all // so don't update r and mark this as the last element ... if (!last && q[1].length === 0) { last = true; } // so, if this isn't the last element, we're going to see if // we can get any more matches from the remaining (unmatched) // elements ... if (!last) { // build a list of the remaining rules we can match against, // i.e., all but the one we just matched against var qx = []; for (var j = 0; j < px.length ; j++) { if (i !== j) { qx.push(px[j]); } } // now invoke recursively set with the remaining input // note that we don't include the closing delimiter ... // we'll check for that ourselves at the end p = _.set(qx, d).call(this, q[1]); // if we got a non-empty set as a result ... // (otw rx already contains everything we want to match) if (p[0].length > 0) { // update current result, which is stored in rx ... // basically, pick up the remaining text from p[1] // and concat the result from p[0] so that we don't // get endless nesting ... rx[0] = rx[0].concat(p[0]); rx[1] = p[1]; } } // at this point, rx either contains the last matched element // or the entire matched set that starts with this element. // now we just check to see if this variation is better than // our best so far, in terms of how much of the input is parsed if (rx[1].length < best[1].length) { best = rx; } // if we've parsed all the input, then we're finished if (best[1].length === 0) { break; } } // so now we've either gone through all the patterns trying them // as the initial match; or we found one that parsed the entire // input string ... // if best has no matches, just return empty set ... if (best[0].length === 0) { return best; } // if a closing delimiter is provided, then we have to check it also if (c) { // we try this even if there is no remaining input because the pattern // may well be optional or match empty input ... try { q = c.call(this, best[1]); } catch (ey) { throw new $P.Exception(best[1]); } // it parsed ... be sure to update the best match remaining input best[1] = q[1]; } // if we're here, either there was no closing delimiter or we parsed it // so now we have the best match; just return it! return best; }; }, forward: function (gr, fname) { return function (s) { return gr[fname].call(this, s); }; }, // // Translation Operators // replace: function (rule, repl) { return function (s) { var r = rule.call(this, s); return [repl, r[1]]; }; }, process: function (rule, fn) { return function (s) { var r = rule.call(this, s); return [fn.call(this, r[0]), r[1]]; }; }, min: function (min, rule) { return function (s) { var rx = rule.call(this, s); if (rx[0].length < min) { throw new $P.Exception(s); } return rx; }; } }; // Generator Operators And Vector Operators // Generators are operators that have a signature of F(R) => R, // taking a given rule and returning another rule, such as // ignore, which parses a given rule and throws away the result. // Vector operators are those that have a signature of F(R1,R2,...) => R, // take a list of rules and returning a new rule, such as each. // Generator operators are converted (via the following _generator // function) into functions that can also take a list or array of rules // and return an array of new rules as though the function had been // called on each rule in turn (which is what actually happens). // This allows generators to be used with vector operators more easily. // Example: // each(ignore(foo, bar)) instead of each(ignore(foo), ignore(bar)) // This also turns generators into vector operators, which allows // constructs like: // not(cache(foo, bar)) var _generator = function (op) { function gen() { var args = null, rx = [], px, i; if (arguments.length > 1) { args = Array.prototype.slice.call(arguments); } else if (arguments[0] instanceof Array) { args = arguments[0]; } if (args) { px = args.shift(); if (px.length > 0) { args.unshift(px[i]); rx.push(op.apply(null, args)); args.shift(); return rx; } } else { return op.apply(null, arguments); } } return gen; }; var gx = "optional not ignore cache".split(/\s/); for (var i = 0 ; i < gx.length ; i++) { _[gx[i]] = _generator(_[gx[i]]); } var _vector = function (op) { return function () { if (arguments[0] instanceof Array) { return op.apply(null, arguments[0]); } else { return op.apply(null, arguments); } }; }; var vx = "each any all".split(/\s/); for (var j = 0 ; j < vx.length ; j++) { _[vx[j]] = _vector(_[vx[j]]); } }()); (function () { var $D = Date; var flattenAndCompact = function (ax) { var rx = []; for (var i = 0; i < ax.length; i++) { if (ax[i] instanceof Array) { rx = rx.concat(flattenAndCompact(ax[i])); } else { if (ax[i]) { rx.push(ax[i]); } } } return rx; }; var parseMeridian = function () { if (this.meridian && (this.hour || this.hour === 0)) { if (this.meridian === "a" && this.hour > 11 && Date.Config.strict24hr){ throw "Invalid hour and meridian combination"; } else if (this.meridian === "p" && this.hour < 12 && Date.Config.strict24hr){ throw "Invalid hour and meridian combination"; } else if (this.meridian === "p" && this.hour < 12) { this.hour = this.hour + 12; } else if (this.meridian === "a" && this.hour === 12) { this.hour = 0; } } }; var setDefaults = function () { var now = new Date(); if ((this.hour || this.minute) && (!this.month && !this.year && !this.day)) { this.day = now.getDate(); } if (!this.year) { this.year = now.getFullYear(); } if (!this.month && this.month !== 0) { this.month = now.getMonth(); } if (!this.day) { this.day = 1; } if (!this.hour) { this.hour = 0; } if (!this.minute) { this.minute = 0; } if (!this.second) { this.second = 0; } if (!this.millisecond) { this.millisecond = 0; } }; var finishUtils = { getToday: function () { if (this.now || "hour minute second".indexOf(this.unit) !== -1) { return new Date(); } else { return $D.today(); } }, setDaysFromWeekday: function (today, orient){ var gap; orient = orient || 1; this.unit = "day"; gap = ($D.getDayNumberFromName(this.weekday) - today.getDay()); this.days = gap ? ((gap + (orient * 7)) % 7) : (orient * 7); return this; }, setMonthsFromMonth: function (today, orient) { var gap; orient = orient || 1; this.unit = "month"; gap = (this.month - today.getMonth()); this.months = gap ? ((gap + (orient * 12)) % 12) : (orient * 12); this.month = null; return this; }, setDMYFromWeekday: function () { var d = Date[this.weekday](); this.day = d.getDate(); if (!this.month) { this.month = d.getMonth(); } this.year = d.getFullYear(); return this; }, setUnitValue: function (orient) { if (!this.value && this.operator && this.operator !== null && this[this.unit + "s"] && this[this.unit + "s"] !== null) { this[this.unit + "s"] = this[this.unit + "s"] + ((this.operator === "add") ? 1 : -1) + (this.value||0) * orient; } else if (this[this.unit + "s"] == null || this.operator != null) { if (!this.value) { this.value = 1; } this[this.unit + "s"] = this.value * orient; } }, generateDateFromWeeks: function () { var weekday = (this.weekday !== undefined) ? this.weekday : "today"; var d = Date[weekday]().addWeeks(this.weeks); if (this.now) { d.setTimeToNow(); } return d; } }; $D.Translator = { hour: function (s) { return function () { this.hour = Number(s); }; }, minute: function (s) { return function () { this.minute = Number(s); }; }, second: function (s) { return function () { this.second = Number(s); }; }, /* for ss.s format */ secondAndMillisecond: function (s) { return function () { var mx = s.match(/^([0-5][0-9])\.([0-9]{1,3})/); this.second = Number(mx[1]); this.millisecond = Number(mx[2]); }; }, meridian: function (s) { return function () { this.meridian = s.slice(0, 1).toLowerCase(); }; }, timezone: function (s) { return function () { var n = s.replace(/[^\d\+\-]/g, ""); if (n.length) { this.timezoneOffset = Number(n); } else { this.timezone = s.toLowerCase(); } }; }, day: function (x) { var s = x[0]; return function () { this.day = Number(s.match(/\d+/)[0]); if (this.day < 1) { throw "invalid day"; } }; }, month: function (s) { return function () { this.month = (s.length === 3) ? "jan feb mar apr may jun jul aug sep oct nov dec".indexOf(s)/4 : Number(s) - 1; if (this.month < 0) { throw "invalid month"; } }; }, year: function (s) { return function () { var n = Number(s); this.year = ((s.length > 2) ? n : (n + (((n + 2000) < Date.CultureInfo.twoDigitYearMax) ? 2000 : 1900))); }; }, rday: function (s) { return function () { switch (s) { case "yesterday": this.days = -1; break; case "tomorrow": this.days = 1; break; case "today": this.days = 0; break; case "now": this.days = 0; this.now = true; break; } }; }, finishExact: function (x) { var d; x = (x instanceof Array) ? x : [x]; for (var i = 0 ; i < x.length ; i++) { if (x[i]) { x[i].call(this); } } setDefaults.call(this); parseMeridian.call(this); if (this.day > $D.getDaysInMonth(this.year, this.month)) { throw new RangeError(this.day + " is not a valid value for days."); } d = new Date(this.year, this.month, this.day, this.hour, this.minute, this.second, this.millisecond); if (this.year < 100) { d.setFullYear(this.year); // means years less that 100 are process correctly. JS will parse it otherwise as 1900-1999. } if (this.timezone) { d.set({ timezone: this.timezone }); } else if (this.timezoneOffset) { d.set({ timezoneOffset: this.timezoneOffset }); } return d; }, finish: function (x) { var today, expression, orient, temp; x = (x instanceof Array) ? flattenAndCompact(x) : [ x ]; if (x.length === 0) { return null; } for (var i = 0 ; i < x.length ; i++) { if (typeof x[i] === "function") { x[i].call(this); } } if (this.now && !this.unit && !this.operator) { return new Date(); } else { today = finishUtils.getToday.call(this); } expression = !!(this.days && this.days !== null || this.orient || this.operator); orient = ((this.orient === "past" || this.operator === "subtract") ? -1 : 1); if (this.month && this.unit === "week") { this.value = this.month + 1; delete this.month; delete this.day; } if ((this.month || this.month === 0) && "year day hour minute second".indexOf(this.unit) !== -1) { if (!this.value) { this.value = this.month + 1; } this.month = null; expression = true; } if (!expression && this.weekday && !this.day && !this.days) { finishUtils.setDMYFromWeekday.call(this); } if (expression && this.weekday && this.unit !== "month" && this.unit !== "week") { finishUtils.setDaysFromWeekday.call(this, today, orient); } if (this.weekday && this.unit !== "week" && !this.day && !this.days) { temp = Date[this.weekday](); this.day = temp.getDate(); if (temp.getMonth() !== today.getMonth()) { this.month = temp.getMonth(); } } if (this.month && this.unit === "day" && this.operator) { if (!this.value) { this.value = (this.month + 1); } this.month = null; } if (this.value != null && this.month != null && this.year != null) { this.day = this.value * 1; } if (this.month && !this.day && this.value) { today.set({ day: this.value * 1 }); if (!expression) { this.day = this.value * 1; } } if (!this.month && this.value && this.unit === "month" && !this.now) { this.month = this.value; expression = true; } if (expression && (this.month || this.month === 0) && this.unit !== "year") { finishUtils.setMonthsFromMonth.call(this, today, orient); } if (!this.unit) { this.unit = "day"; } finishUtils.setUnitValue.call(this, orient); parseMeridian.call(this); if ((this.month || this.month === 0) && !this.day) { this.day = 1; } if (!this.orient && !this.operator && this.unit === "week" && this.value && !this.day && !this.month) { return Date.today().setWeek(this.value); } if (this.unit === "week" && this.weeks && !this.day && !this.month) { return finishUtils.generateDateFromWeeks.call(this); } if (expression && this.timezone && this.day && this.days) { this.day = this.days; } if (expression){ today.add(this); } else { today.set(this); } if (this.timezone) { this.timezone = this.timezone.toUpperCase(); var offset = $D.getTimezoneOffset(this.timezone); var timezone; if (today.hasDaylightSavingTime()) { // lets check that we're being sane with timezone setting timezone = $D.getTimezoneAbbreviation(offset, today.isDaylightSavingTime()); if (timezone !== this.timezone) { // bugger, we're in a place where things like EST vs EDT matters. if (today.isDaylightSavingTime()) { today.addHours(-1); } else { today.addHours(1); } } } today.setTimezoneOffset(offset); } return today; } }; }()); (function () { var $D = Date; $D.Grammar = {}; var _ = $D.Parsing.Operators, g = $D.Grammar, t = $D.Translator, _fn; // Allow rolling up into general purpose rules _fn = function () { return _.each(_.any.apply(null, arguments), _.not(g.ctoken2("timeContext"))); }; g.datePartDelimiter = _.rtoken(/^([\s\-\.\,\/\x27]+)/); g.timePartDelimiter = _.stoken(":"); g.whiteSpace = _.rtoken(/^\s*/); g.generalDelimiter = _.rtoken(/^(([\s\,]|at|@|on)+)/); var _C = {}; g.ctoken = function (keys) { var fn = _C[keys]; if (! fn) { var c = Date.CultureInfo.regexPatterns; var kx = keys.split(/\s+/), px = []; for (var i = 0; i < kx.length ; i++) { px.push(_.replace(_.rtoken(c[kx[i]]), kx[i])); } fn = _C[keys] = _.any.apply(null, px); } return fn; }; g.ctoken2 = function (key) { return _.rtoken(Date.CultureInfo.regexPatterns[key]); }; var cacheProcessRtoken = function (key, token, type, eachToken) { if (eachToken) { g[key] = _.cache(_.process(_.each(_.rtoken(token),_.optional(g.ctoken2(eachToken))), type)); } else { g[key] = _.cache(_.process(_.rtoken(token), type)); } }; var cacheProcessCtoken = function (token, type) { return _.cache(_.process(g.ctoken2(token), type)); }; var _F = {}; //function cache var _get = function (f) { _F[f] = (_F[f] || g.format(f)[0]); return _F[f]; }; g.allformats = function (fx) { var rx = []; if (fx instanceof Array) { for (var i = 0; i < fx.length; i++) { rx.push(_get(fx[i])); } } else { rx.push(_get(fx)); } return rx; }; g.formats = function (fx) { if (fx instanceof Array) { var rx = []; for (var i = 0 ; i < fx.length ; i++) { rx.push(_get(fx[i])); } return _.any.apply(null, rx); } else { return _get(fx); } }; var grammarFormats = { timeFormats: function(){ var i, RTokenKeys = [ "h", "hh", "H", "HH", "m", "mm", "s", "ss", "ss.s", "z", "zz" ], RToken = [ /^(0[0-9]|1[0-2]|[1-9])/, /^(0[0-9]|1[0-2])/, /^([0-1][0-9]|2[0-3]|[0-9])/, /^([0-1][0-9]|2[0-3])/, /^([0-5][0-9]|[0-9])/, /^[0-5][0-9]/, /^([0-5][0-9]|[0-9])/, /^[0-5][0-9]/, /^[0-5][0-9]\.[0-9]{1,3}/, /^((\+|\-)\s*\d\d\d\d)|((\+|\-)\d\d\:?\d\d)/, /^((\+|\-)\s*\d\d\d\d)|((\+|\-)\d\d\:?\d\d)/ ], tokens = [ t.hour, t.hour, t.hour, t.hour, t.minute, t.minute, t.second, t.second, t.secondAndMillisecond, t.timezone, t.timezone ]; for (i=0; i < RTokenKeys.length; i++) { cacheProcessRtoken(RTokenKeys[i], RToken[i], tokens[i]); } g.hms = _.cache(_.sequence([g.H, g.m, g.s], g.timePartDelimiter)); g.t = cacheProcessCtoken("shortMeridian", t.meridian); g.tt = cacheProcessCtoken("longMeridian", t.meridian); g.zzz = cacheProcessCtoken("timezone", t.timezone); g.timeSuffix = _.each(_.ignore(g.whiteSpace), _.set([ g.tt, g.zzz ])); g.time = _.each(_.optional(_.ignore(_.stoken("T"))), g.hms, g.timeSuffix); }, dateFormats: function () { // pre-loaded rules for different date part order preferences var _setfn = function () { return _.set(arguments, g.datePartDelimiter); }; var i, RTokenKeys = [ "d", "dd", "M", "MM", "y", "yy", "yyy", "yyyy" ], RToken = [ /^([0-2]\d|3[0-1]|\d)/, /^([0-2]\d|3[0-1])/, /^(1[0-2]|0\d|\d)/, /^(1[0-2]|0\d)/, /^(\d+)/, /^(\d\d)/, /^(\d\d?\d?\d?)/, /^(\d\d\d\d)/ ], tokens = [ t.day, t.day, t.month, t.month, t.year, t.year, t.year, t.year ], eachToken = [ "ordinalSuffix", "ordinalSuffix" ]; for (i=0; i < RTokenKeys.length; i++) { cacheProcessRtoken(RTokenKeys[i], RToken[i], tokens[i], eachToken[i]); } g.MMM = g.MMMM = _.cache(_.process(g.ctoken("jan feb mar apr may jun jul aug sep oct nov dec"), t.month)); g.ddd = g.dddd = _.cache(_.process(g.ctoken("sun mon tue wed thu fri sat"), function (s) { return function () { this.weekday = s; }; } )); g.day = _fn(g.d, g.dd); g.month = _fn(g.M, g.MMM); g.year = _fn(g.yyyy, g.yy); g.mdy = _setfn(g.ddd, g.month, g.day, g.year); g.ymd = _setfn(g.ddd, g.year, g.month, g.day); g.dmy = _setfn(g.ddd, g.day, g.month, g.year); g.date = function (s) { return ((g[Date.CultureInfo.dateElementOrder] || g.mdy).call(this, s)); }; }, relative: function () { // relative date / time expressions g.orientation = _.process(g.ctoken("past future"), function (s) { return function () { this.orient = s; }; } ); g.operator = _.process(g.ctoken("add subtract"), function (s) { return function () { this.operator = s; }; } ); g.rday = _.process(g.ctoken("yesterday tomorrow today now"), t.rday); g.unit = _.process(g.ctoken("second minute hour day week month year"), function (s) { return function () { this.unit = s; }; } ); } }; g.buildGrammarFormats = function () { // these need to be rebuilt every time the language changes. _C = {}; grammarFormats.timeFormats(); grammarFormats.dateFormats(); grammarFormats.relative(); g.value = _.process(_.rtoken(/^([-+]?\d+)?(st|nd|rd|th)?/), function (s) { return function () { this.value = s.replace(/\D/g, ""); }; } ); g.expression = _.set([g.rday, g.operator, g.value, g.unit, g.orientation, g.ddd, g.MMM ]); g.format = _.process(_.many( _.any( // translate format specifiers into grammar rules _.process( _.rtoken(/^(dd?d?d?(?!e)|MM?M?M?|yy?y?y?|hh?|HH?|mm?|ss?|tt?|zz?z?)/), function (fmt) { if (g[fmt]) { return g[fmt]; } else { throw $D.Parsing.Exception(fmt); } } ), // translate separator tokens into token rules _.process(_.rtoken(/^[^dMyhHmstz]+/), // all legal separators function (s) { return _.ignore(_.stoken(s)); } ) ) ), // construct the parser ... function (rules) { return _.process(_.each.apply(null, rules), t.finishExact); } ); // starting rule for general purpose grammar g._start = _.process(_.set([ g.date, g.time, g.expression ], g.generalDelimiter, g.whiteSpace), t.finish); }; g.buildGrammarFormats(); // parsing date format specifiers - ex: "h:m:s tt" // this little guy will generate a custom parser based // on the format string, ex: g.format("h:m:s tt") // check for these formats first g._formats = g.formats([ "\"yyyy-MM-ddTHH:mm:ssZ\"", "yyyy-MM-ddTHH:mm:ss.sz", "yyyy-MM-ddTHH:mm:ssZ", "yyyy-MM-ddTHH:mm:ssz", "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-ddTHH:mmZ", "yyyy-MM-ddTHH:mmz", "yyyy-MM-ddTHH:mm", "ddd, MMM dd, yyyy H:mm:ss tt", "ddd MMM d yyyy HH:mm:ss zzz", "MMddyyyy", "ddMMyyyy", "Mddyyyy", "ddMyyyy", "Mdyyyy", "dMyyyy", "yyyy", "Mdyy", "dMyy", "d" ]); // real starting rule: tries selected formats first, // then general purpose rule g.start = function (s) { try { var r = g._formats.call({}, s); if (r[1].length === 0) { return r; } } catch (e) {} return g._start.call({}, s); }; }()); (function () { var $D = Date; /** * @desc Converts the specified string value into its JavaScript Date equivalent using CultureInfo specific format information. * * Example

	///////////
	// Dates //
	///////////

	// 15-Oct-2004
	var d1 = Date.parse("10/15/2004");

	// 15-Oct-2004
	var d1 = Date.parse("15-Oct-2004");

	// 15-Oct-2004
	var d1 = Date.parse("2004.10.15");

	//Fri Oct 15, 2004
	var d1 = Date.parse("Fri Oct 15, 2004");

	///////////
	// Times //
	///////////

	// Today at 10 PM.
	var d1 = Date.parse("10 PM");

	// Today at 10:30 PM.
	var d1 = Date.parse("10:30 P.M.");

	// Today at 6 AM.
	var d1 = Date.parse("06am");

	/////////////////////
	// Dates and Times //
	/////////////////////

	// 8-July-2004 @ 10:30 PM
	var d1 = Date.parse("July 8th, 2004, 10:30 PM");

	// 1-July-2004 @ 10:30 PM
	var d1 = Date.parse("2004-07-01T22:30:00");

	////////////////////
	// Relative Dates //
	////////////////////

	// Returns today's date. The string "today" is culture specific.
	var d1 = Date.parse("today");

	// Returns yesterday's date. The string "yesterday" is culture specific.
	var d1 = Date.parse("yesterday");

	// Returns the date of the next thursday.
	var d1 = Date.parse("Next thursday");

	// Returns the date of the most previous monday.
	var d1 = Date.parse("last monday");

	// Returns today's day + one year.
	var d1 = Date.parse("next year");

	///////////////
	// Date Math //
	///////////////

	// Today + 2 days
	var d1 = Date.parse("t+2");

	// Today + 2 days
	var d1 = Date.parse("today + 2 days");

	// Today + 3 months
	var d1 = Date.parse("t+3m");

	// Today - 1 year
	var d1 = Date.parse("today - 1 year");

	// Today - 1 year
	var d1 = Date.parse("t-1y"); 


	/////////////////////////////
	// Partial Dates and Times //
	/////////////////////////////

	// July 15th of this year.
	var d1 = Date.parse("July 15");

	// 15th day of current day and year.
	var d1 = Date.parse("15");

	// July 1st of current year at 10pm.
	var d1 = Date.parse("7/1 10pm");
	
* * @param {String} The string value to convert into a Date object [Required] * @return {Date} A Date object or null if the string cannot be converted into a Date. */ var parseUtils = { removeOrds: function (s) { ords = s.match(/\b(\d+)(?:st|nd|rd|th)\b/); // find ordinal matches s = ((ords && ords.length === 2) ? s.replace(ords[0], ords[1]) : s); return s; }, grammarParser: function (s) { var r = null; try { r = $D.Grammar.start.call({}, s.replace(/^\s*(\S*(\s+\S+)*)\s*$/, "$1")); } catch (e) { return null; } return ((r[1].length === 0) ? r[0] : null); }, nativeFallback: function(s) { var t; try { // ok we haven't parsed it, last ditch attempt with the built-in parser. t = Date._parse(s); return (t || t === 0) ? new Date(t) : null; } catch (e) { return null; } } }; function parse (s) { var d; if (!s) { return null; } if (s instanceof Date) { return s.clone(); } if (s.length >= 4 && s.charAt(0) !== "0" && s.charAt(0) !== "+"&& s.charAt(0) !== "-") { // ie: 2004 will pass, 0800 won't. // Start with specific formats d = $D.Parsing.ISO.parse(s) || $D.Parsing.Numeric.parse(s); } if (d instanceof Date && !isNaN(d.getTime())) { return d; } else { // find ordinal dates (1st, 3rd, 8th, etc and remove them as they cause parsing issues) s = $D.Parsing.Normalizer.parse(parseUtils.removeOrds(s)); d = parseUtils.grammarParser(s); if (d !== null) { return d; } else { return parseUtils.nativeFallback(s); } } } if (!$D._parse) { $D._parse = $D.parse; } $D.parse = parse; Date.getParseFunction = function (fx) { var fns = Date.Grammar.allformats(fx); return function (s) { var r = null; for (var i = 0; i < fns.length; i++) { try { r = fns[i].call({}, s); } catch (e) { continue; } if (r[1].length === 0) { return r[0]; } } return null; }; }; /** * Converts the specified string value into its JavaScript Date equivalent using the specified format {String} or formats {Array} and the CultureInfo specific format information. * The format of the string value must match one of the supplied formats exactly. * * Example

	// 15-Oct-2004
	var d1 = Date.parseExact("10/15/2004", "M/d/yyyy");

	// 15-Oct-2004
	var d1 = Date.parse("15-Oct-2004", "M-ddd-yyyy");

	// 15-Oct-2004
	var d1 = Date.parse("2004.10.15", "yyyy.MM.dd");

	// Multiple formats
	var d1 = Date.parseExact("10/15/2004", ["M/d/yyyy", "MMMM d, yyyy"]);
	
* * @param {String} The string value to convert into a Date object [Required]. * @param {Object} The expected format {String} or an array of expected formats {Array} of the date string [Required]. * @return {Date} A Date object or null if the string cannot be converted into a Date. */ $D.parseExact = function (s, fx) { return $D.getParseFunction(fx)(s); }; }()); (function () { var $D = Date, $P = $D.prototype, // $C = $D.CultureInfo, // not used atm p = function (s, l) { if (!l) { l = 2; } return ("000" + s).slice(l * -1); }; /** * Converts a PHP format string to Java/.NET format string. * A PHP format string can be used with ._format or .format. * A Java/.NET format string can be used with .toString(). * The .parseExact function will only accept a Java/.NET format string * * Example * var f1 = "%m/%d/%y" * var f2 = Date.normalizeFormat(f1); // "MM/dd/yy" * * new Date().format(f1); // "04/13/08" * new Date()._format(f1); // "04/13/08" * new Date().toString(f2); // "04/13/08" * * var date = Date.parseExact("04/13/08", f2); // Sun Apr 13 2008 * * @param {String} A PHP format string consisting of one or more format spcifiers. * @return {String} The PHP format converted to a Java/.NET format string. */ var normalizerSubstitutions = { "d" : "dd", "%d": "dd", "D" : "ddd", "%a": "ddd", "j" : "dddd", "l" : "dddd", "%A": "dddd", "S" : "S", "F" : "MMMM", "%B": "MMMM", "m" : "MM", "%m": "MM", "M" : "MMM", "%b": "MMM", "%h": "MMM", "n" : "M", "Y" : "yyyy", "%Y": "yyyy", "y" : "yy", "%y": "yy", "g" : "h", "%I": "h", "G" : "H", "h" : "hh", "H" : "HH", "%H": "HH", "i" : "mm", "%M": "mm", "s" : "ss", "%S": "ss", "%r": "hh:mm tt", "%R": "H:mm", "%T": "H:mm:ss", "%X": "t", "%x": "d", "%e": "d", "%D": "MM/dd/yy", "%n": "\\n", "%t": "\\t", "e" : "z", "T" : "z", "%z": "z", "%Z": "z", "Z" : "ZZ", "N" : "u", "w" : "u", "%w": "u", "W" : "W", "%V": "W" }; var normalizer = { substitutes: function (m) { return normalizerSubstitutions[m]; }, interpreted: function (m, x) { var y; switch (m) { case "%u": return x.getDay() + 1; case "z": return x.getOrdinalNumber(); case "%j": return p(x.getOrdinalNumber(), 3); case "%U": var d1 = x.clone().set({month: 0, day: 1}).addDays(-1).moveToDayOfWeek(0), d2 = x.clone().addDays(1).moveToDayOfWeek(0, -1); return (d2 < d1) ? "00" : p((d2.getOrdinalNumber() - d1.getOrdinalNumber()) / 7 + 1); case "%W": return p(x.getWeek()); case "t": return $D.getDaysInMonth(x.getFullYear(), x.getMonth()); case "o": case "%G": return x.setWeek(x.getISOWeek()).toString("yyyy"); case "%g": return x._format("%G").slice(-2); case "a": case "%p": return t("tt").toLowerCase(); case "A": return t("tt").toUpperCase(); case "u": return p(x.getMilliseconds(), 3); case "I": return (x.isDaylightSavingTime()) ? 1 : 0; case "O": return x.getUTCOffset(); case "P": y = x.getUTCOffset(); return y.substring(0, y.length - 2) + ":" + y.substring(y.length - 2); case "B": var now = new Date(); return Math.floor(((now.getHours() * 3600) + (now.getMinutes() * 60) + now.getSeconds() + (now.getTimezoneOffset() + 60) * 60) / 86.4); case "c": return x.toISOString().replace(/\"/g, ""); case "U": return $D.strtotime("now"); case "%c": return t("d") + " " + t("t"); case "%C": return Math.floor(x.getFullYear() / 100 + 1); } }, shouldOverrideDefaults: function (m) { switch (m) { case "%e": return true; default: return false; } }, parse: function (m, context) { var formatString, c = context || new Date(); formatString = normalizer.substitutes(m); if (formatString) { return formatString; } formatString = normalizer.interpreted(m, c); if (formatString) { return formatString; } else { return m; } } }; $D.normalizeFormat = function (format, context) { return format.replace(/(%|\\)?.|%%/g, function(t){ return normalizer.parse(t, context); }); }; /** * Format a local Unix timestamp according to locale settings * * Example: * Date.strftime("%m/%d/%y", new Date()); // "04/13/08" * Date.strftime("c", "2008-04-13T17:52:03Z"); // "04/13/08" * * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @param {Number|String} The number representing the number of seconds that have elapsed since January 1, 1970 (local time). * @return {String} A string representation of the current Date object. */ $D.strftime = function (format, time) { var d = Date.parse(time); return d._format(format); }; /** * Parse any textual datetime description into a Unix timestamp. * A Unix timestamp is the number of seconds that have elapsed since January 1, 1970 (midnight UTC/GMT). * * Example: * Date.strtotime("04/13/08"); // 1208044800 * Date.strtotime("1970-01-01T00:00:00Z"); // 0 * * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @param {Object} A string or date object. * @return {String} A string representation of the current Date object. */ $D.strtotime = function (time) { var d = $D.parse(time); return Math.round($D.UTC(d.getUTCFullYear(), d.getUTCMonth(), d.getUTCDate(), d.getUTCHours(), d.getUTCMinutes(), d.getUTCSeconds(), d.getUTCMilliseconds()) / 1000); }; /** * Converts the value of the current Date object to its equivalent string representation using a PHP/Unix style of date format specifiers. * Format Specifiers * Format Description Example * ------ --------------------------------------------------------------------------- ----------------------- * %a abbreviated weekday name according to the current localed "Mon" through "Sun" * %A full weekday name according to the current localed "Sunday" through "Saturday" * %b abbreviated month name according to the current localed "Jan" through "Dec" * %B full month name according to the current locale "January" through "December" * %c preferred date and time representation for the current locale "4/13/2008 12:33 PM" * %C century number (the year divided by 100 and truncated to an integer) "00" to "99" * %d day of the month as a decimal number "01" to "31" * %D same as %m/%d/%y "04/13/08" * %e day of the month as a decimal number, a single digit is preceded by a space "1" to "31" * %g like %G, but without the century "08" * %G The 4-digit year corresponding to the ISO week number (see %V). "2008" * This has the same format and value as %Y, except that if the ISO week number * belongs to the previous or next year, that year is used instead. * %h same as %b "Jan" through "Dec" * %H hour as a decimal number using a 24-hour clock. "00" to "23" * %I hour as a decimal number using a 12-hour clock. "01" to "12" * %j day of the year as a decimal number. "001" to "366" * %m month as a decimal number. "01" to "12" * %M minute as a decimal number. "00" to "59" * %n newline character "\n" * %p either "am" or "pm" according to the given time value, or the "am" or "pm" * corresponding strings for the current locale. * %r time in a.m. and p.m. notation "8:44 PM" * %R time in 24 hour notation "20:44" * %S second as a decimal number "00" to "59" * %t tab character "\t" * %T current time, equal to %H:%M:%S "12:49:11" * %u weekday as a decimal number ["1", "7"], with "1" representing Monday "1" to "7" * %U week number of the current year as a decimal number, starting with the "0" to ("52" or "53") * first Sunday as the first day of the first week * %V The ISO 8601:1988 week number of the current year as a decimal number, "00" to ("52" or "53") * range 01 to 53, where week 1 is the first week that has at least 4 days * in the current year, and with Monday as the first day of the week. * (Use %G or %g for the year component that corresponds to the week number * for the specified timestamp.) * %W week number of the current year as a decimal number, starting with the "00" to ("52" or "53") * first Monday as the first day of the first week * %w day of the week as a decimal, Sunday being "0" "0" to "6" * %x preferred date representation for the current locale without the time "4/13/2008" * %X preferred time representation for the current locale without the date "12:53:05" * %y year as a decimal number without a century "00" "99" * %Y year as a decimal number including the century "2008" * %Z time zone or name or abbreviation "UTC", "EST", "PST" * %z same as %Z * %% a literal "%" characters "%" * d Day of the month, 2 digits with leading zeros "01" to "31" * D A textual representation of a day, three letters "Mon" through "Sun" * j Day of the month without leading zeros "1" to "31" * l A full textual representation of the day of the week (lowercase "L") "Sunday" through "Saturday" * N ISO-8601 numeric representation of the day of the week (added in PHP 5.1.0) "1" (for Monday) through "7" (for Sunday) * S English ordinal suffix for the day of the month, 2 characters "st", "nd", "rd" or "th". Works well with j * w Numeric representation of the day of the week "0" (for Sunday) through "6" (for Saturday) * z The day of the year (starting from "0") "0" through "365" * W ISO-8601 week number of year, weeks starting on Monday "00" to ("52" or "53") * F A full textual representation of a month, such as January or March "January" through "December" * m Numeric representation of a month, with leading zeros "01" through "12" * M A short textual representation of a month, three letters "Jan" through "Dec" * n Numeric representation of a month, without leading zeros "1" through "12" * t Number of days in the given month "28" through "31" * L Whether it's a leap year "1" if it is a leap year, "0" otherwise * o ISO-8601 year number. This has the same value as Y, except that if the "2008" * ISO week number (W) belongs to the previous or next year, that year * is used instead. * Y A full numeric representation of a year, 4 digits "2008" * y A two digit representation of a year "08" * a Lowercase Ante meridiem and Post meridiem "am" or "pm" * A Uppercase Ante meridiem and Post meridiem "AM" or "PM" * B Swatch Internet time "000" through "999" * g 12-hour format of an hour without leading zeros "1" through "12" * G 24-hour format of an hour without leading zeros "0" through "23" * h 12-hour format of an hour with leading zeros "01" through "12" * H 24-hour format of an hour with leading zeros "00" through "23" * i Minutes with leading zeros "00" to "59" * s Seconds, with leading zeros "00" through "59" * u Milliseconds "54321" * e Timezone identifier "UTC", "EST", "PST" * I Whether or not the date is in daylight saving time (uppercase i) "1" if Daylight Saving Time, "0" otherwise * O Difference to Greenwich time (GMT) in hours "+0200", "-0600" * P Difference to Greenwich time (GMT) with colon between hours and minutes "+02:00", "-06:00" * T Timezone abbreviation "UTC", "EST", "PST" * Z Timezone offset in seconds. The offset for timezones west of UTC is "-43200" through "50400" * always negative, and for those east of UTC is always positive. * c ISO 8601 date "2004-02-12T15:19:21+00:00" * r RFC 2822 formatted date "Thu, 21 Dec 2000 16:01:07 +0200" * U Seconds since the Unix Epoch (January 1 1970 00:00:00 GMT) "0" * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @return {String} A string representation of the current Date object. */ var formatReplace = function (context) { return function (m) { var formatString, override = false; if (m.charAt(0) === "\\" || m.substring(0, 2) === "%%") { return m.replace("\\", "").replace("%%", "%"); } override = normalizer.shouldOverrideDefaults(m); formatString = $D.normalizeFormat(m, context); if (formatString) { return context.toString(formatString, override); } }; }; $P._format = function (format) { var formatter = formatReplace(this); if (!format) { return this._toString(); } else { return format.replace(/(%|\\)?.|%%/g, formatter); } }; if (!$P.format) { $P.format = $P._format; } }()); (function () { "use strict"; var gFn = function (attr) { return function () { return this[attr]; }; }; var sFn = function (attr) { return function (val) { this[attr] = val; return this; }; }; var attrs = ["years", "months", "days", "hours", "minutes", "seconds", "milliseconds"]; var addSetFuncs = function (context, attrs) { for (var i = 0; i < attrs.length ; i++) { var $a = attrs[i], $b = $a.slice(0, 1).toUpperCase() + $a.slice(1); context.prototype[$a] = 0; context.prototype["get" + $b] = gFn($a); context.prototype["set" + $b] = sFn($a); } }; /** * new TimeSpan(milliseconds); * new TimeSpan(days, hours, minutes, seconds); * new TimeSpan(days, hours, minutes, seconds, milliseconds); */ var TimeSpan = function (days, hours, minutes, seconds, milliseconds) { if (arguments.length === 1 && typeof days === "number") { var orient = (days < 0) ? -1 : +1; var millsLeft = Math.abs(days); this.setDays(Math.floor(millsLeft / 86400000) * orient); millsLeft = millsLeft % 86400000; this.setHours(Math.floor(millsLeft / 3600000) * orient); millsLeft = millsLeft % 3600000; this.setMinutes(Math.floor(millsLeft / 60000) * orient); millsLeft = millsLeft % 60000; this.setSeconds(Math.floor(millsLeft / 1000) * orient); millsLeft = millsLeft % 1000; this.setMilliseconds(millsLeft * orient); } else { this.set(days, hours, minutes, seconds, milliseconds); } this.getTotalMilliseconds = function () { return (this.getDays() * 86400000) + (this.getHours() * 3600000) + (this.getMinutes() * 60000) + (this.getSeconds() * 1000); }; this.compareTo = function (time) { var t1 = new Date(1970, 1, 1, this.getHours(), this.getMinutes(), this.getSeconds()), t2; if (time === null) { t2 = new Date(1970, 1, 1, 0, 0, 0); } else { t2 = new Date(1970, 1, 1, time.getHours(), time.getMinutes(), time.getSeconds()); } return (t1 < t2) ? -1 : (t1 > t2) ? 1 : 0; }; this.equals = function (time) { return (this.compareTo(time) === 0); }; this.add = function (time) { return (time === null) ? this : this.addSeconds(time.getTotalMilliseconds() / 1000); }; this.subtract = function (time) { return (time === null) ? this : this.addSeconds(-time.getTotalMilliseconds() / 1000); }; this.addDays = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 86400000)); }; this.addHours = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 3600000)); }; this.addMinutes = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 60000)); }; this.addSeconds = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 1000)); }; this.addMilliseconds = function (n) { return new TimeSpan(this.getTotalMilliseconds() + n); }; this.get12HourHour = function () { return (this.getHours() > 12) ? this.getHours() - 12 : (this.getHours() === 0) ? 12 : this.getHours(); }; this.getDesignator = function () { return (this.getHours() < 12) ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator; }; this.toString = function (format) { this._toString = function () { if (this.getDays() !== null && this.getDays() > 0) { return this.getDays() + "." + this.getHours() + ":" + this.p(this.getMinutes()) + ":" + this.p(this.getSeconds()); } else { return this.getHours() + ":" + this.p(this.getMinutes()) + ":" + this.p(this.getSeconds()); } }; this.p = function (s) { return (s.toString().length < 2) ? "0" + s : s; }; var me = this; return format ? format.replace(/dd?|HH?|hh?|mm?|ss?|tt?/g, function (format) { switch (format) { case "d": return me.getDays(); case "dd": return me.p(me.getDays()); case "H": return me.getHours(); case "HH": return me.p(me.getHours()); case "h": return me.get12HourHour(); case "hh": return me.p(me.get12HourHour()); case "m": return me.getMinutes(); case "mm": return me.p(me.getMinutes()); case "s": return me.getSeconds(); case "ss": return me.p(me.getSeconds()); case "t": return ((me.getHours() < 12) ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator).substring(0, 1); case "tt": return (me.getHours() < 12) ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator; } } ) : this._toString(); }; return this; }; addSetFuncs(TimeSpan, attrs.slice(2)); TimeSpan.prototype.set = function (days, hours, minutes, seconds, milliseconds){ this.setDays(days || this.getDays()); this.setHours(hours || this.getHours()); this.setMinutes(minutes || this.getMinutes()); this.setSeconds(seconds || this.getSeconds()); this.setMilliseconds(milliseconds || this.getMilliseconds()); }; /** * Gets the time of day for this date instances. * @return {TimeSpan} TimeSpan */ Date.prototype.getTimeOfDay = function () { return new TimeSpan(0, this.getHours(), this.getMinutes(), this.getSeconds(), this.getMilliseconds()); }; Date.TimeSpan = TimeSpan; if (typeof window !== "undefined" ) { // keeping API compatible for v1.x window.TimeSpan = TimeSpan; } }()); (function () { "use strict"; var attrs = ["years", "months", "days", "hours", "minutes", "seconds", "milliseconds"]; var gFn = function (attr) { return function () { return this[attr]; }; }; var sFn = function (attr) { return function (val) { this[attr] = val; return this; }; }; var addSetFuncs = function (context, attrs) { for (var i = 0; i < attrs.length ; i++) { var $a = attrs[i], $b = $a.slice(0, 1).toUpperCase() + $a.slice(1); context.prototype[$a] = 0; context.prototype["get" + $b] = gFn($a); context.prototype["set" + $b] = sFn($a); } }; var setMonthsAndYears = function (orient, d1, d2, context) { function inc() { d1.addMonths(-orient); context.months++; if (context.months === 12) { context.years++; context.months = 0; } } if (orient === +1) { while (d1 > d2) { inc(); } } else { while (d1 < d2) { inc(); } } context.months--; context.months *= orient; context.years *= orient; }; var adjustForDST = function(orient, startDate, endDate) { var hasDSTMismatch = (false === (startDate.isDaylightSavingTime() === endDate.isDaylightSavingTime())); if (hasDSTMismatch && orient === 1) { startDate.addHours(-1); } else if (hasDSTMismatch) { startDate.addHours(1); } }; /** * TimePeriod(startDate, endDate); * TimePeriod(years, months, days, hours, minutes, seconds, milliseconds); */ var TimePeriod = function (years, months, days, hours, minutes, seconds, milliseconds) { if (arguments.length === 7) { this.set(years, months, days, hours, minutes, seconds, milliseconds); } else if (arguments.length === 2 && arguments[0] instanceof Date && arguments[1] instanceof Date) { var startDate = arguments[0].clone(); var endDate = arguments[1].clone(); var orient = (startDate > endDate) ? +1 : -1; this.dates = { start: arguments[0].clone(), end: arguments[1].clone() }; setMonthsAndYears(orient, startDate, endDate, this); adjustForDST(orient, startDate, endDate); // // TODO - adjust for DST var diff = endDate - startDate; if (diff !== 0) { var ts = new TimeSpan(diff); this.set(this.years, this.months, ts.getDays(), ts.getHours(), ts.getMinutes(), ts.getSeconds(), ts.getMilliseconds()); } } return this; }; // create all the set functions. addSetFuncs(TimePeriod, attrs); TimePeriod.prototype.set = function (years, months, days, hours, minutes, seconds, milliseconds){ this.setYears(years || this.getYears()); this.setMonths(months || this.getMonths()); this.setDays(days || this.getDays()); this.setHours(hours || this.getHours()); this.setMinutes(minutes || this.getMinutes()); this.setSeconds(seconds || this.getSeconds()); this.setMilliseconds(milliseconds || this.getMilliseconds()); }; Date.TimePeriod = TimePeriod; if (typeof window !== "undefined") { // keeping API compatible for v1.x window.TimePeriod = TimePeriod; } }()); ================================================ FILE: build/date-de-LU.js ================================================ /** * @overview datejs * @version 1.0.0-rc3 * @author Gregory Wild-Smith * @copyright 2015 Gregory Wild-Smith * @license MIT * @homepage https://github.com/abritinthebay/datejs */ /* * DateJS Culture String File * Country Code: de-LU * Name: German (Luxembourg) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["de-LU"] = { "name": "de-LU", "englishName": "German (Luxembourg)", "nativeName": "Deutsch (Luxemburg)", "Sunday": "Sonntag", "Monday": "Montag", "Tuesday": "Dienstag", "Wednesday": "Mittwoch", "Thursday": "Donnerstag", "Friday": "Freitag", "Saturday": "Samstag", "Sun": "Son", "Mon": "Mon", "Tue": "Die", "Wed": "Mit", "Thu": "Don", "Fri": "Fre", "Sat": "Sam", "Su": "So", "Mo": "Mo", "Tu": "Di", "We": "Mi", "Th": "Do", "Fr": "Fr", "Sa": "Sa", "S_Sun_Initial": "S", "M_Mon_Initial": "M", "T_Tue_Initial": "D", "W_Wed_Initial": "M", "T_Thu_Initial": "D", "F_Fri_Initial": "F", "S_Sat_Initial": "S", "January": "Januar", "February": "Februar", "March": "März", "April": "April", "May": "Mai", "June": "Juni", "July": "Juli", "August": "August", "September": "September", "October": "Oktober", "November": "November", "December": "Dezember", "Jan_Abbr": "Jan", "Feb_Abbr": "Feb", "Mar_Abbr": "Mrz", "Apr_Abbr": "Apr", "May_Abbr": "Mai", "Jun_Abbr": "Jun", "Jul_Abbr": "Jul", "Aug_Abbr": "Aug", "Sep_Abbr": "Sep", "Oct_Abbr": "Okt", "Nov_Abbr": "Nov", "Dec_Abbr": "Dez", "AM": "", "PM": "", "firstDayOfWeek": 1, "twoDigitYearMax": 2029, "mdy": "dmy", "M/d/yyyy": "dd.MM.yyyy", "dddd, MMMM dd, yyyy": "dddd, d. MMMM yyyy", "h:mm tt": "HH:mm", "h:mm:ss tt": "HH:mm:ss", "dddd, MMMM dd, yyyy h:mm:ss tt": "dddd, d. MMMM yyyy HH:mm:ss", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "dd MMMM", "MMMM, yyyy": "MMMM yyyy", "/jan(uary)?/": "jan(uar)?", "/feb(ruary)?/": "feb(ruar)?", "/mar(ch)?/": "märz", "/apr(il)?/": "apr(il)?", "/may/": "mai", "/jun(e)?/": "jun(i)?", "/jul(y)?/": "jul(i)?", "/aug(ust)?/": "aug(ust)?", "/sep(t(ember)?)?/": "sep(t(ember)?)?", "/oct(ober)?/": "okt(ober)?", "/nov(ember)?/": "nov(ember)?", "/dec(ember)?/": "dez(ember)?", "/^su(n(day)?)?/": "^sonntag", "/^mo(n(day)?)?/": "^montag", "/^tu(e(s(day)?)?)?/": "^dienstag", "/^we(d(nesday)?)?/": "^mittwoch", "/^th(u(r(s(day)?)?)?)?/": "^donnerstag", "/^fr(i(day)?)?/": "^freitag", "/^sa(t(urday)?)?/": "^samstag", "/^next/": "^nächste(r|s|n)?", "/^last|past|prev(ious)?/": "^letzte(r|s|n)?|vergangene(r|s|n)?|vorherige(r|s|n)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|(da)?nach(er)?|von|daher|in)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|(be|zu)?vor|früher)", "/^yes(terday)?/": "^gestern", "/^t(od(ay)?)?/": "^heute", "/^tom(orrow)?/": "^morgen", "/^n(ow)?/": "^jetzt|sofort|gleich", "/^ms|milli(second)?s?/": "^ms|milli(sekunde(n)?)?", "/^sec(ond)?s?/": "^sek(unde(n)?)?", "/^mn|min(ute)?s?/": "^mn|min(ute(n)?)?", "/^h(our)?s?/": "^h|st(d|unde(n)?)?", "/^w(eek)?s?/": "^w(oche(n)?)?", "/^m(onth)?s?/": "^m(onat(e)?)?", "/^d(ay)?s?/": "^d|t(ag(en)?)?", "/^y(ear)?s?/": "^y|j(ahr(en)?)?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "de-LU"; /** * @overview datejs * @version 1.0.0-rc3 * @author Gregory Wild-Smith * @copyright 2015 Gregory Wild-Smith * @license MIT * @homepage https://github.com/abritinthebay/datejs */(function () { var $D = Date; var lang = Date.CultureStrings ? Date.CultureStrings.lang : null; var loggedKeys = {}; // for debug purposes. var getText = { getFromKey: function (key, countryCode) { var output; if (Date.CultureStrings && Date.CultureStrings[countryCode] && Date.CultureStrings[countryCode][key]) { output = Date.CultureStrings[countryCode][key]; } else { output = getText.buildFromDefault(key); } if (key.charAt(0) === "/") { // Assume it's a regex output = getText.buildFromRegex(key, countryCode); } return output; }, getFromObjectValues: function (obj, countryCode) { var key, output = {}; for(key in obj) { if (obj.hasOwnProperty(key)) { output[key] = getText.getFromKey(obj[key], countryCode); } } return output; }, getFromObjectKeys: function (obj, countryCode) { var key, output = {}; for(key in obj) { if (obj.hasOwnProperty(key)) { output[getText.getFromKey(key, countryCode)] = obj[key]; } } return output; }, getFromArray: function (arr, countryCode) { var output = []; for (var i=0; i < arr.length; i++){ if (i in arr) { output[i] = getText.getFromKey(arr[i], countryCode); } } return output; }, buildFromDefault: function (key) { var output, length, split, last; switch(key) { case "name": output = "en-US"; break; case "englishName": output = "English (United States)"; break; case "nativeName": output = "English (United States)"; break; case "twoDigitYearMax": output = 2049; break; case "firstDayOfWeek": output = 0; break; default: output = key; split = key.split("_"); length = split.length; if (length > 1 && key.charAt(0) !== "/") { // if the key isn't a regex and it has a split. last = split[(length - 1)].toLowerCase(); if (last === "initial" || last === "abbr") { output = split[0]; } } break; } return output; }, buildFromRegex: function (key, countryCode) { var output; if (Date.CultureStrings && Date.CultureStrings[countryCode] && Date.CultureStrings[countryCode][key]) { output = new RegExp(Date.CultureStrings[countryCode][key], "i"); } else { output = new RegExp(key.replace(new RegExp("/", "g"),""), "i"); } return output; } }; var shallowMerge = function (obj1, obj2) { for (var attrname in obj2) { if (obj2.hasOwnProperty(attrname)) { obj1[attrname] = obj2[attrname]; } } }; var __ = function (key, language) { var countryCode = (language) ? language : lang; loggedKeys[key] = key; if (typeof key === "object") { if (key instanceof Array) { return getText.getFromArray(key, countryCode); } else { return getText.getFromObjectKeys(key, countryCode); } } else { return getText.getFromKey(key, countryCode); } }; var loadI18nScript = function (code) { // paatterned after jQuery's getScript. var url = Date.Config.i18n + code + ".js"; var head = document.getElementsByTagName("head")[0] || document.documentElement; var script = document.createElement("script"); script.src = url; var completed = false; var events = { done: function (){} // placeholder function }; // Attach handlers for all browsers script.onload = script.onreadystatechange = function() { if ( !completed && (!this.readyState || this.readyState === "loaded" || this.readyState === "complete") ) { events.done(); head.removeChild(script); } }; setTimeout(function() { head.insertBefore(script, head.firstChild); }, 0); // allows return to execute first return { done: function (cb) { events.done = function() { if (cb) { setTimeout(cb,0); } }; } }; }; var buildInfo = { buildFromMethodHash: function (obj) { var key; for(key in obj) { if (obj.hasOwnProperty(key)) { obj[key] = buildInfo[obj[key]](); } } return obj; }, timeZoneDST: function () { var DST = { "CHADT": "+1345", "NZDT": "+1300", "AEDT": "+1100", "ACDT": "+1030", "AZST": "+0500", "IRDT": "+0430", "EEST": "+0300", "CEST": "+0200", "BST": "+0100", "PMDT": "-0200", "ADT": "-0300", "NDT": "-0230", "EDT": "-0400", "CDT": "-0500", "MDT": "-0600", "PDT": "-0700", "AKDT": "-0800", "HADT": "-0900" }; return __(DST); }, timeZoneStandard: function () { var standard = { "LINT": "+1400", "TOT": "+1300", "CHAST": "+1245", "NZST": "+1200", "NFT": "+1130", "SBT": "+1100", "AEST": "+1000", "ACST": "+0930", "JST": "+0900", "CWST": "+0845", "CT": "+0800", "ICT": "+0700", "MMT": "+0630", "BST": "+0600", "NPT": "+0545", "IST": "+0530", "PKT": "+0500", "AFT": "+0430", "MSK": "+0400", "IRST": "+0330", "FET": "+0300", "EET": "+0200", "CET": "+0100", "GMT": "+0000", "UTC": "+0000", "CVT": "-0100", "GST": "-0200", "BRT": "-0300", "NST": "-0330", "AST": "-0400", "EST": "-0500", "CST": "-0600", "MST": "-0700", "PST": "-0800", "AKST": "-0900", "MIT": "-0930", "HST": "-1000", "SST": "-1100", "BIT": "-1200" }; return __(standard); }, timeZones: function (data) { var zone; data.timezones = []; for (zone in data.abbreviatedTimeZoneStandard) { if (data.abbreviatedTimeZoneStandard.hasOwnProperty(zone)) { data.timezones.push({ name: zone, offset: data.abbreviatedTimeZoneStandard[zone]}); } } for (zone in data.abbreviatedTimeZoneDST) { if (data.abbreviatedTimeZoneDST.hasOwnProperty(zone)) { data.timezones.push({ name: zone, offset: data.abbreviatedTimeZoneDST[zone], dst: true}); } } return data.timezones; }, days: function () { return __(["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"]); }, dayAbbr: function () { return __(["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"]); }, dayShortNames: function () { return __(["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"]); }, dayFirstLetters: function () { return __(["S_Sun_Initial", "M_Mon_Initial", "T_Tues_Initial", "W_Wed_Initial", "T_Thu_Initial", "F_Fri_Initial", "S_Sat_Initial"]); }, months: function () { return __(["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"]); }, monthAbbr: function () { return __(["Jan_Abbr", "Feb_Abbr", "Mar_Abbr", "Apr_Abbr", "May_Abbr", "Jun_Abbr", "Jul_Abbr", "Aug_Abbr", "Sep_Abbr", "Oct_Abbr", "Nov_Abbr", "Dec_Abbr"]); }, formatPatterns: function () { return getText.getFromObjectValues({ shortDate: "M/d/yyyy", longDate: "dddd, MMMM dd, yyyy", shortTime: "h:mm tt", longTime: "h:mm:ss tt", fullDateTime: "dddd, MMMM dd, yyyy h:mm:ss tt", sortableDateTime: "yyyy-MM-ddTHH:mm:ss", universalSortableDateTime: "yyyy-MM-dd HH:mm:ssZ", rfc1123: "ddd, dd MMM yyyy HH:mm:ss", monthDay: "MMMM dd", yearMonth: "MMMM, yyyy" }, Date.i18n.currentLanguage()); }, regex: function () { return getText.getFromObjectValues({ inTheMorning: "/( in the )(morn(ing)?)\\b/", thisMorning: "/(this )(morn(ing)?)\\b/", amThisMorning: "/(\b\\d(am)? )(this )(morn(ing)?)/", inTheEvening: "/( in the )(even(ing)?)\\b/", thisEvening: "/(this )(even(ing)?)\\b/", pmThisEvening: "/(\b\\d(pm)? )(this )(even(ing)?)/", jan: "/jan(uary)?/", feb: "/feb(ruary)?/", mar: "/mar(ch)?/", apr: "/apr(il)?/", may: "/may/", jun: "/jun(e)?/", jul: "/jul(y)?/", aug: "/aug(ust)?/", sep: "/sep(t(ember)?)?/", oct: "/oct(ober)?/", nov: "/nov(ember)?/", dec: "/dec(ember)?/", sun: "/^su(n(day)?)?/", mon: "/^mo(n(day)?)?/", tue: "/^tu(e(s(day)?)?)?/", wed: "/^we(d(nesday)?)?/", thu: "/^th(u(r(s(day)?)?)?)?/", fri: "/fr(i(day)?)?/", sat: "/^sa(t(urday)?)?/", future: "/^next/", past: "/^last|past|prev(ious)?/", add: "/^(\\+|aft(er)?|from|hence)/", subtract: "/^(\\-|bef(ore)?|ago)/", yesterday: "/^yes(terday)?/", today: "/^t(od(ay)?)?/", tomorrow: "/^tom(orrow)?/", now: "/^n(ow)?/", millisecond: "/^ms|milli(second)?s?/", second: "/^sec(ond)?s?/", minute: "/^mn|min(ute)?s?/", hour: "/^h(our)?s?/", week: "/^w(eek)?s?/", month: "/^m(onth)?s?/", day: "/^d(ay)?s?/", year: "/^y(ear)?s?/", shortMeridian: "/^(a|p)/", longMeridian: "/^(a\\.?m?\\.?|p\\.?m?\\.?)/", timezone: "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/", ordinalSuffix: "/^\\s*(st|nd|rd|th)/", timeContext: "/^\\s*(\\:|a(?!u|p)|p)/" }, Date.i18n.currentLanguage()); } }; var CultureInfo = function () { var info = getText.getFromObjectValues({ name: "name", englishName: "englishName", nativeName: "nativeName", amDesignator: "AM", pmDesignator: "PM", firstDayOfWeek: "firstDayOfWeek", twoDigitYearMax: "twoDigitYearMax", dateElementOrder: "mdy" }, Date.i18n.currentLanguage()); var constructedInfo = buildInfo.buildFromMethodHash({ dayNames: "days", abbreviatedDayNames: "dayAbbr", shortestDayNames: "dayShortNames", firstLetterDayNames: "dayFirstLetters", monthNames: "months", abbreviatedMonthNames: "monthAbbr", formatPatterns: "formatPatterns", regexPatterns: "regex", abbreviatedTimeZoneDST: "timeZoneDST", abbreviatedTimeZoneStandard: "timeZoneStandard" }); shallowMerge(info, constructedInfo); buildInfo.timeZones(info); return info; }; $D.i18n = { __: function (key, lang) { return __(key, lang); }, currentLanguage: function () { return lang || "en-US"; }, setLanguage: function (code, force, cb) { var async = false; if (force || code === "en-US" || (!!Date.CultureStrings && !!Date.CultureStrings[code])) { lang = code; Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings.lang = code; Date.CultureInfo = new CultureInfo(); } else { if (!(!!Date.CultureStrings && !!Date.CultureStrings[code])) { if (typeof exports !== "undefined" && this.exports !== exports) { // we're in a Node enviroment, load it using require try { require("../i18n/" + code + ".js"); lang = code; Date.CultureStrings.lang = code; Date.CultureInfo = new CultureInfo(); } catch (e) { // var str = "The language for '" + code + "' could not be loaded by Node. It likely does not exist."; throw new Error("The DateJS IETF language tag '" + code + "' could not be loaded by Node. It likely does not exist."); } } else if (Date.Config && Date.Config.i18n) { // we know the location of the files, so lets load them async = true; loadI18nScript(code).done(function(){ lang = code; Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings.lang = code; Date.CultureInfo = new CultureInfo(); $D.Parsing.Normalizer.buildReplaceData(); // because this is async if ($D.Grammar) { $D.Grammar.buildGrammarFormats(); // so we can parse those strings... } if (cb) { setTimeout(cb,0); } }); } else { Date.console.error("The DateJS IETF language tag '" + code + "' is not available and has not been loaded."); return false; } } } $D.Parsing.Normalizer.buildReplaceData(); // rebuild normalizer strings if ($D.Grammar) { $D.Grammar.buildGrammarFormats(); // so we can parse those strings... } if (!async && cb) { setTimeout(cb,0); } }, getLoggedKeys: function () { return loggedKeys; }, updateCultureInfo: function () { Date.CultureInfo = new CultureInfo(); } }; $D.i18n.updateCultureInfo(); // run automatically }()); (function () { var $D = Date, $P = $D.prototype, p = function (s, l) { if (!l) { l = 2; } return ("000" + s).slice(l * -1); }; if (typeof window !== "undefined" && typeof window.console !== "undefined" && typeof window.console.log !== "undefined") { $D.console = console; // used only to raise non-critical errors if available } else { // set mock so we don't give errors. $D.console = { log: function(){}, error: function(){} }; } $D.Config = $D.Config || {}; $D.initOverloads = function() { /** * Overload of Date.now. Allows an alternate call for Date.now where it returns the * current Date as an object rather than just milliseconds since the Unix Epoch. * * Also provides an implementation of now() for browsers (IE<9) that don't have it. * * Backwards compatible so with work with either: * Date.now() [returns ms] * or * Date.now(true) [returns Date] */ if (!$D.now) { $D._now = function now() { return new Date().getTime(); }; } else if (!$D._now) { $D._now = $D.now; } $D.now = function (returnObj) { if (returnObj) { return $D.present(); } else { return $D._now(); } }; if ( !$P.toISOString ) { $P.toISOString = function() { return this.getUTCFullYear() + "-" + p(this.getUTCMonth() + 1) + "-" + p(this.getUTCDate()) + "T" + p(this.getUTCHours()) + ":" + p(this.getUTCMinutes()) + ":" + p(this.getUTCSeconds()) + "." + String( (this.getUTCMilliseconds()/1000).toFixed(3)).slice(2, 5) + "Z"; }; } // private if ( $P._toString === undefined ){ $P._toString = $P.toString; } }; $D.initOverloads(); /** * Gets a date that is set to the current date. The time is set to the start of the day (00:00 or 12:00 AM). * @return {Date} The current date. */ $D.today = function () { return new Date().clearTime(); }; /** * Gets a date that is set to the current date and time (same as new Date, but chainable) * @return {Date} The current date. */ $D.present = function () { return new Date(); }; /** * Compares the first date to the second date and returns an number indication of their relative values. * @param {Date} First Date object to compare [Required]. * @param {Date} Second Date object to compare to [Required]. * @return {Number} -1 = date1 is lessthan date2. 0 = values are equal. 1 = date1 is greaterthan date2. */ $D.compare = function (date1, date2) { if (isNaN(date1) || isNaN(date2)) { throw new Error(date1 + " - " + date2); } else if (date1 instanceof Date && date2 instanceof Date) { return (date1 < date2) ? -1 : (date1 > date2) ? 1 : 0; } else { throw new TypeError(date1 + " - " + date2); } }; /** * Compares the first Date object to the second Date object and returns true if they are equal. * @param {Date} First Date object to compare [Required] * @param {Date} Second Date object to compare to [Required] * @return {Boolean} true if dates are equal. false if they are not equal. */ $D.equals = function (date1, date2) { return (date1.compareTo(date2) === 0); }; /** * Gets the language appropriate day name when given the day number(0-6) * eg - 0 == Sunday * @return {String} The day name */ $D.getDayName = function (n) { return Date.CultureInfo.dayNames[n]; }; /** * Gets the day number (0-6) if given a CultureInfo specific string which is a valid dayName, abbreviatedDayName or shortestDayName (two char). * @param {String} The name of the day (eg. "Monday, "Mon", "tuesday", "tue", "We", "we"). * @return {Number} The day number */ $D.getDayNumberFromName = function (name) { var n = Date.CultureInfo.dayNames, m = Date.CultureInfo.abbreviatedDayNames, o = Date.CultureInfo.shortestDayNames, s = name.toLowerCase(); for (var i = 0; i < n.length; i++) { if (n[i].toLowerCase() === s || m[i].toLowerCase() === s || o[i].toLowerCase() === s) { return i; } } return -1; }; /** * Gets the month number (0-11) if given a Culture Info specific string which is a valid monthName or abbreviatedMonthName. * @param {String} The name of the month (eg. "February, "Feb", "october", "oct"). * @return {Number} The day number */ $D.getMonthNumberFromName = function (name) { var n = Date.CultureInfo.monthNames, m = Date.CultureInfo.abbreviatedMonthNames, s = name.toLowerCase(); for (var i = 0; i < n.length; i++) { if (n[i].toLowerCase() === s || m[i].toLowerCase() === s) { return i; } } return -1; }; /** * Gets the language appropriate month name when given the month number(0-11) * eg - 0 == January * @return {String} The month name */ $D.getMonthName = function (n) { return Date.CultureInfo.monthNames[n]; }; /** * Determines if the current date instance is within a LeapYear. * @param {Number} The year. * @return {Boolean} true if date is within a LeapYear, otherwise false. */ $D.isLeapYear = function (year) { return ((year % 4 === 0 && year % 100 !== 0) || year % 400 === 0); }; /** * Gets the number of days in the month, given a year and month value. Automatically corrects for LeapYear. * @param {Number} The year. * @param {Number} The month (0-11). * @return {Number} The number of days in the month. */ $D.getDaysInMonth = function (year, month) { if (!month && $D.validateMonth(year)) { month = year; year = Date.today().getFullYear(); } return [31, ($D.isLeapYear(year) ? 29 : 28), 31, 30, 31, 30, 31, 31, 30, 31, 30, 31][month]; }; $P.getDaysInMonth = function () { return $D.getDaysInMonth(this.getFullYear(), this.getMonth()); }; $D.getTimezoneAbbreviation = function (offset, dst) { var p, n = (dst || false) ? Date.CultureInfo.abbreviatedTimeZoneDST : Date.CultureInfo.abbreviatedTimeZoneStandard; for (p in n) { if (n.hasOwnProperty(p)) { if (n[p] === offset) { return p; } } } return null; }; $D.getTimezoneOffset = function (name, dst) { var i, a =[], z = Date.CultureInfo.timezones; if (!name) { name = (new Date()).getTimezone();} for (i = 0; i < z.length; i++) { if (z[i].name === name.toUpperCase()) { a.push(i); } } if (!z[a[0]]) { return null; } if (a.length === 1 || !dst) { return z[a[0]].offset; } else { for (i=0; i < a.length; i++) { if (z[a[i]].dst) { return z[a[i]].offset; } } } }; $D.getQuarter = function (d) { d = d || new Date(); // If no date supplied, use today var q = [1,2,3,4]; return q[Math.floor(d.getMonth() / 3)]; // ~~~ is a bitwise op. Faster than Math.floor }; $D.getDaysLeftInQuarter = function (d) { d = d || new Date(); var qEnd = new Date(d); qEnd.setMonth(qEnd.getMonth() + 3 - qEnd.getMonth() % 3, 0); return Math.floor((qEnd - d) / 8.64e7); }; // private var validate = function (n, min, max, name) { name = name ? name : "Object"; if (typeof n === "undefined") { return false; } else if (typeof n !== "number") { throw new TypeError(n + " is not a Number."); } else if (n < min || n > max) { // As failing validation is *not* an exceptional circumstance // lets not throw a RangeError Exception here. // It's semantically correct but it's not sensible. return false; } return true; }; /** * Validates the number is within an acceptable range for milliseconds [0-999]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateMillisecond = function (value) { return validate(value, 0, 999, "millisecond"); }; /** * Validates the number is within an acceptable range for seconds [0-59]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateSecond = function (value) { return validate(value, 0, 59, "second"); }; /** * Validates the number is within an acceptable range for minutes [0-59]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateMinute = function (value) { return validate(value, 0, 59, "minute"); }; /** * Validates the number is within an acceptable range for hours [0-23]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateHour = function (value) { return validate(value, 0, 23, "hour"); }; /** * Validates the number is within an acceptable range for the days in a month [0-MaxDaysInMonth]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateDay = function (value, year, month) { if (year === undefined || year === null || month === undefined || month === null) { return false;} return validate(value, 1, $D.getDaysInMonth(year, month), "day"); }; /** * Validates the number is within an acceptable range for months [0-11]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateWeek = function (value) { return validate(value, 0, 53, "week"); }; /** * Validates the number is within an acceptable range for months [0-11]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateMonth = function (value) { return validate(value, 0, 11, "month"); }; /** * Validates the number is within an acceptable range for years. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateYear = function (value) { /** * Per ECMAScript spec the range of times supported by Date objects is * exactly -100,000,000 days to +100,000,000 days measured relative to * midnight at the beginning of 01 January, 1970 UTC. * This gives a range of 8,640,000,000,000,000 milliseconds to either * side of 01 January, 1970 UTC. * * Earliest possible date: Tue, 20 Apr 271,822 B.C. 00:00:00 UTC * Latest possible date: Sat, 13 Sep 275,760 00:00:00 UTC */ return validate(value, -271822, 275760, "year"); }; $D.validateTimezone = function(value) { var timezones = {"ACDT":1,"ACST":1,"ACT":1,"ADT":1,"AEDT":1,"AEST":1,"AFT":1,"AKDT":1,"AKST":1,"AMST":1,"AMT":1,"ART":1,"AST":1,"AWDT":1,"AWST":1,"AZOST":1,"AZT":1,"BDT":1,"BIOT":1,"BIT":1,"BOT":1,"BRT":1,"BST":1,"BTT":1,"CAT":1,"CCT":1,"CDT":1,"CEDT":1,"CEST":1,"CET":1,"CHADT":1,"CHAST":1,"CHOT":1,"ChST":1,"CHUT":1,"CIST":1,"CIT":1,"CKT":1,"CLST":1,"CLT":1,"COST":1,"COT":1,"CST":1,"CT":1,"CVT":1,"CWST":1,"CXT":1,"DAVT":1,"DDUT":1,"DFT":1,"EASST":1,"EAST":1,"EAT":1,"ECT":1,"EDT":1,"EEDT":1,"EEST":1,"EET":1,"EGST":1,"EGT":1,"EIT":1,"EST":1,"FET":1,"FJT":1,"FKST":1,"FKT":1,"FNT":1,"GALT":1,"GAMT":1,"GET":1,"GFT":1,"GILT":1,"GIT":1,"GMT":1,"GST":1,"GYT":1,"HADT":1,"HAEC":1,"HAST":1,"HKT":1,"HMT":1,"HOVT":1,"HST":1,"ICT":1,"IDT":1,"IOT":1,"IRDT":1,"IRKT":1,"IRST":1,"IST":1,"JST":1,"KGT":1,"KOST":1,"KRAT":1,"KST":1,"LHST":1,"LINT":1,"MAGT":1,"MART":1,"MAWT":1,"MDT":1,"MET":1,"MEST":1,"MHT":1,"MIST":1,"MIT":1,"MMT":1,"MSK":1,"MST":1,"MUT":1,"MVT":1,"MYT":1,"NCT":1,"NDT":1,"NFT":1,"NPT":1,"NST":1,"NT":1,"NUT":1,"NZDT":1,"NZST":1,"OMST":1,"ORAT":1,"PDT":1,"PET":1,"PETT":1,"PGT":1,"PHOT":1,"PHT":1,"PKT":1,"PMDT":1,"PMST":1,"PONT":1,"PST":1,"PYST":1,"PYT":1,"RET":1,"ROTT":1,"SAKT":1,"SAMT":1,"SAST":1,"SBT":1,"SCT":1,"SGT":1,"SLST":1,"SRT":1,"SST":1,"SYOT":1,"TAHT":1,"THA":1,"TFT":1,"TJT":1,"TKT":1,"TLT":1,"TMT":1,"TOT":1,"TVT":1,"UCT":1,"ULAT":1,"UTC":1,"UYST":1,"UYT":1,"UZT":1,"VET":1,"VLAT":1,"VOLT":1,"VOST":1,"VUT":1,"WAKT":1,"WAST":1,"WAT":1,"WEDT":1,"WEST":1,"WET":1,"WST":1,"YAKT":1,"YEKT":1,"Z":1}; return (timezones[value] === 1); }; $D.validateTimezoneOffset= function(value) { // timezones go from +14hrs to -12hrs, the +X hours are negative offsets. return (value > -841 && value < 721); }; }()); (function () { var $D = Date, $P = $D.prototype, p = function (s, l) { if (!l) { l = 2; } return ("000" + s).slice(l * -1); }; var validateConfigObject = function (obj) { var result = {}, self = this, prop, testFunc; testFunc = function (prop, func, value) { if (prop === "day") { var month = (obj.month !== undefined) ? obj.month : self.getMonth(); var year = (obj.year !== undefined) ? obj.year : self.getFullYear(); return $D[func](value, year, month); } else { return $D[func](value); } }; for (prop in obj) { if (Object.prototype.hasOwnProperty.call(obj, prop)) { var func = "validate" + prop.charAt(0).toUpperCase() + prop.slice(1); if ($D[func] && obj[prop] !== null && testFunc(prop, func, obj[prop])) { result[prop] = obj[prop]; } } } return result; }; /** * Resets the time of this Date object to 12:00 AM (00:00), which is the start of the day. * @param {Boolean} .clone() this date instance before clearing Time * @return {Date} this */ $P.clearTime = function () { this.setHours(0); this.setMinutes(0); this.setSeconds(0); this.setMilliseconds(0); return this; }; /** * Resets the time of this Date object to the current time ('now'). * @return {Date} this */ $P.setTimeToNow = function () { var n = new Date(); this.setHours(n.getHours()); this.setMinutes(n.getMinutes()); this.setSeconds(n.getSeconds()); this.setMilliseconds(n.getMilliseconds()); return this; }; /** * Returns a new Date object that is an exact date and time copy of the original instance. * @return {Date} A new Date instance */ $P.clone = function () { return new Date(this.getTime()); }; /** * Compares this instance to a Date object and returns an number indication of their relative values. * @param {Date} Date object to compare [Required] * @return {Number} -1 = this is lessthan date. 0 = values are equal. 1 = this is greaterthan date. */ $P.compareTo = function (date) { return Date.compare(this, date); }; /** * Compares this instance to another Date object and returns true if they are equal. * @param {Date} Date object to compare. If no date to compare, new Date() [now] is used. * @return {Boolean} true if dates are equal. false if they are not equal. */ $P.equals = function (date) { return Date.equals(this, (date !== undefined ? date : new Date())); }; /** * Determines if this instance is between a range of two dates or equal to either the start or end dates. * @param {Date} Start of range [Required] * @param {Date} End of range [Required] * @return {Boolean} true is this is between or equal to the start and end dates, else false */ $P.between = function (start, end) { return this.getTime() >= start.getTime() && this.getTime() <= end.getTime(); }; /** * Determines if this date occurs after the date to compare to. * @param {Date} Date object to compare. If no date to compare, new Date() ("now") is used. * @return {Boolean} true if this date instance is greater than the date to compare to (or "now"), otherwise false. */ $P.isAfter = function (date) { return this.compareTo(date || new Date()) === 1; }; /** * Determines if this date occurs before the date to compare to. * @param {Date} Date object to compare. If no date to compare, new Date() ("now") is used. * @return {Boolean} true if this date instance is less than the date to compare to (or "now"). */ $P.isBefore = function (date) { return (this.compareTo(date || new Date()) === -1); }; /** * Determines if the current Date instance occurs today. * @return {Boolean} true if this date instance is 'today', otherwise false. */ /** * Determines if the current Date instance occurs on the same Date as the supplied 'date'. * If no 'date' to compare to is provided, the current Date instance is compared to 'today'. * @param {date} Date object to compare. If no date to compare, the current Date ("now") is used. * @return {Boolean} true if this Date instance occurs on the same Day as the supplied 'date'. */ $P.isToday = $P.isSameDay = function (date) { return this.clone().clearTime().equals((date || new Date()).clone().clearTime()); }; /** * Adds the specified number of milliseconds to this instance. * @param {Number} The number of milliseconds to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addMilliseconds = function (value) { if (!value) { return this; } this.setTime(this.getTime() + value * 1); return this; }; /** * Adds the specified number of seconds to this instance. * @param {Number} The number of seconds to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addSeconds = function (value) { if (!value) { return this; } return this.addMilliseconds(value * 1000); }; /** * Adds the specified number of seconds to this instance. * @param {Number} The number of seconds to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addMinutes = function (value) { if (!value) { return this; } return this.addMilliseconds(value * 60000); // 60*1000 }; /** * Adds the specified number of hours to this instance. * @param {Number} The number of hours to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addHours = function (value) { if (!value) { return this; } return this.addMilliseconds(value * 3600000); // 60*60*1000 }; /** * Adds the specified number of days to this instance. * @param {Number} The number of days to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addDays = function (value) { if (!value) { return this; } this.setDate(this.getDate() + value * 1); return this; }; /** * Adds the specified number of weekdays (ie - not sat or sun) to this instance. * @param {Number} The number of days to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addWeekdays = function (value) { if (!value) { return this; } var day = this.getDay(); var weeks = (Math.ceil(Math.abs(value)/7)); if (day === 0 || day === 6) { if (value > 0) { this.next().monday(); this.addDays(-1); day = this.getDay(); } } if (value < 0) { while (value < 0) { this.addDays(-1); day = this.getDay(); if (day !== 0 && day !== 6) { value++; } } return this; } else if (value > 5 || (6-day) <= value) { value = value + (weeks * 2); } return this.addDays(value); }; /** * Adds the specified number of weeks to this instance. * @param {Number} The number of weeks to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addWeeks = function (value) { if (!value) { return this; } return this.addDays(value * 7); }; /** * Adds the specified number of months to this instance. * @param {Number} The number of months to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addMonths = function (value) { if (!value) { return this; } var n = this.getDate(); this.setDate(1); this.setMonth(this.getMonth() + value * 1); this.setDate(Math.min(n, $D.getDaysInMonth(this.getFullYear(), this.getMonth()))); return this; }; $P.addQuarters = function (value) { if (!value) { return this; } // note this will take you to the same point in the quarter as you are now. // i.e. - if you are 15 days into the quarter you'll be 15 days into the resulting one. // bonus: this allows adding fractional quarters return this.addMonths(value * 3); }; /** * Adds the specified number of years to this instance. * @param {Number} The number of years to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addYears = function (value) { if (!value) { return this; } return this.addMonths(value * 12); }; /** * Adds (or subtracts) to the value of the years, months, weeks, days, hours, minutes, seconds, milliseconds of the date instance using given configuration object. Positive and Negative values allowed. * Example

	Date.today().add( { days: 1, months: 1 } )

	new Date().add( { years: -1 } )
	
* @param {Object} Configuration object containing attributes (months, days, etc.) * @return {Date} this */ $P.add = function (config) { if (typeof config === "number") { this._orient = config; return this; } var x = config; if (x.day) { // If we should be a different date than today (eg: for 'tomorrow -1d', etc). // Should only effect parsing, not direct usage (eg, Finish and FinishExact) if ((x.day - this.getDate()) !== 0) { this.setDate(x.day); } } if (x.milliseconds) { this.addMilliseconds(x.milliseconds); } if (x.seconds) { this.addSeconds(x.seconds); } if (x.minutes) { this.addMinutes(x.minutes); } if (x.hours) { this.addHours(x.hours); } if (x.weeks) { this.addWeeks(x.weeks); } if (x.months) { this.addMonths(x.months); } if (x.years) { this.addYears(x.years); } if (x.days) { this.addDays(x.days); } return this; }; /** * Get the week number. Week one (1) is the week which contains the first Thursday of the year. Monday is considered the first day of the week. * The .getWeek() function does NOT convert the date to UTC. The local datetime is used. * Please use .getISOWeek() to get the week of the UTC converted date. * @return {Number} 1 to 53 */ $P.getWeek = function (utc) { // Create a copy of this date object var self, target = new Date(this.valueOf()); if (utc) { target.addMinutes(target.getTimezoneOffset()); self = target.clone(); } else { self = this; } // ISO week date weeks start on monday // so correct the day number var dayNr = (self.getDay() + 6) % 7; // ISO 8601 states that week 1 is the week // with the first thursday of that year. // Set the target date to the thursday in the target week target.setDate(target.getDate() - dayNr + 3); // Store the millisecond value of the target date var firstThursday = target.valueOf(); // Set the target to the first thursday of the year // First set the target to january first target.setMonth(0, 1); // Not a thursday? Correct the date to the next thursday if (target.getDay() !== 4) { target.setMonth(0, 1 + ((4 - target.getDay()) + 7) % 7); } // The weeknumber is the number of weeks between the // first thursday of the year and the thursday in the target week return 1 + Math.ceil((firstThursday - target) / 604800000); // 604800000 = 7 * 24 * 3600 * 1000 }; /** * Get the ISO 8601 week number. Week one ("01") is the week which contains the first Thursday of the year. Monday is considered the first day of the week. * The .getISOWeek() function does convert the date to it's UTC value. Please use .getWeek() to get the week of the local date. * @return {String} "01" to "53" */ $P.getISOWeek = function () { return p(this.getWeek(true)); }; /** * Moves the date to Monday of the week set. Week one (1) is the week which contains the first Thursday of the year. * @param {Number} A Number (1 to 53) that represents the week of the year. * @return {Date} this */ $P.setWeek = function (n) { if ((n - this.getWeek()) === 0) { if (this.getDay() !== 1) { return this.moveToDayOfWeek(1, (this.getDay() > 1 ? -1 : 1)); } else { return this; } } else { return this.moveToDayOfWeek(1, (this.getDay() > 1 ? -1 : 1)).addWeeks(n - this.getWeek()); } }; $P.setQuarter = function (qtr) { var month = Math.abs(((qtr-1) * 3) + 1); return this.setMonth(month, 1); }; $P.getQuarter = function () { return Date.getQuarter(this); }; $P.getDaysLeftInQuarter = function () { return Date.getDaysLeftInQuarter(this); }; /** * Moves the date to the next n'th occurrence of the dayOfWeek starting from the beginning of the month. The number (-1) is a magic number and will return the last occurrence of the dayOfWeek in the month. * @param {Number} The dayOfWeek to move to * @param {Number} The n'th occurrence to move to. Use (-1) to return the last occurrence in the month * @return {Date} this */ $P.moveToNthOccurrence = function (dayOfWeek, occurrence) { if (dayOfWeek === "Weekday") { if (occurrence > 0) { this.moveToFirstDayOfMonth(); if (this.is().weekday()) { occurrence -= 1; } } else if (occurrence < 0) { this.moveToLastDayOfMonth(); if (this.is().weekday()) { occurrence += 1; } } else { return this; } return this.addWeekdays(occurrence); } var shift = 0; if (occurrence > 0) { shift = occurrence - 1; } else if (occurrence === -1) { this.moveToLastDayOfMonth(); if (this.getDay() !== dayOfWeek) { this.moveToDayOfWeek(dayOfWeek, -1); } return this; } return this.moveToFirstDayOfMonth().addDays(-1).moveToDayOfWeek(dayOfWeek, +1).addWeeks(shift); }; var moveToN = function (getFunc, addFunc, nVal) { return function (value, orient) { var diff = (value - this[getFunc]() + nVal * (orient || +1)) % nVal; return this[addFunc]((diff === 0) ? diff += nVal * (orient || +1) : diff); }; }; /** * Move to the next or last dayOfWeek based on the orient value. * @param {Number} The dayOfWeek to move to * @param {Number} Forward (+1) or Back (-1). Defaults to +1. [Optional] * @return {Date} this */ $P.moveToDayOfWeek = moveToN("getDay", "addDays", 7); /** * Move to the next or last month based on the orient value. * @param {Number} The month to move to. 0 = January, 11 = December * @param {Number} Forward (+1) or Back (-1). Defaults to +1. [Optional] * @return {Date} this */ $P.moveToMonth = moveToN("getMonth", "addMonths", 12); /** * Get the Ordinate of the current day ("th", "st", "rd"). * @return {String} */ $P.getOrdinate = function () { var num = this.getDate(); return ord(num); }; /** * Get the Ordinal day (numeric day number) of the year, adjusted for leap year. * @return {Number} 1 through 365 (366 in leap years) */ $P.getOrdinalNumber = function () { return Math.ceil((this.clone().clearTime() - new Date(this.getFullYear(), 0, 1)) / 86400000) + 1; }; /** * Get the time zone abbreviation of the current date. * @return {String} The abbreviated time zone name (e.g. "EST") */ $P.getTimezone = function () { return $D.getTimezoneAbbreviation(this.getUTCOffset(), this.isDaylightSavingTime()); }; $P.setTimezoneOffset = function (offset) { var here = this.getTimezoneOffset(), there = Number(offset) * -6 / 10; return (there || there === 0) ? this.addMinutes(there - here) : this; }; $P.setTimezone = function (offset) { return this.setTimezoneOffset($D.getTimezoneOffset(offset)); }; /** * Indicates whether Daylight Saving Time is observed in the current time zone. * @return {Boolean} true|false */ $P.hasDaylightSavingTime = function () { return (Date.today().set({month: 0, day: 1}).getTimezoneOffset() !== Date.today().set({month: 6, day: 1}).getTimezoneOffset()); }; /** * Indicates whether this Date instance is within the Daylight Saving Time range for the current time zone. * @return {Boolean} true|false */ $P.isDaylightSavingTime = function () { return Date.today().set({month: 0, day: 1}).getTimezoneOffset() !== this.getTimezoneOffset(); }; /** * Get the offset from UTC of the current date. * @return {String} The 4-character offset string prefixed with + or - (e.g. "-0500") */ $P.getUTCOffset = function (offset) { var n = (offset || this.getTimezoneOffset()) * -10 / 6, r; if (n < 0) { r = (n - 10000).toString(); return r.charAt(0) + r.substr(2); } else { r = (n + 10000).toString(); return "+" + r.substr(1); } }; /** * Returns the number of milliseconds between this date and date. * @param {Date} Defaults to now * @return {Number} The diff in milliseconds */ $P.getElapsed = function (date) { return (date || new Date()) - this; }; /** * Set the value of year, month, day, hour, minute, second, millisecond of date instance using given configuration object. * Example

	Date.today().set( { day: 20, month: 1 } )

	new Date().set( { millisecond: 0 } )
	
* * @param {Object} Configuration object containing attributes (month, day, etc.) * @return {Date} this */ $P.set = function (config) { config = validateConfigObject.call(this, config); var key; for (key in config) { if (Object.prototype.hasOwnProperty.call(config, key)) { var name = key.charAt(0).toUpperCase() + key.slice(1); var addFunc, getFunc; if (key !== "week" && key !== "month" && key !== "timezone" && key !== "timezoneOffset") { name += "s"; } addFunc = "add" + name; getFunc = "get" + name; if (key === "month") { addFunc = addFunc + "s"; } else if (key === "year"){ getFunc = "getFullYear"; } if (key !== "day" && key !== "timezone" && key !== "timezoneOffset" && key !== "week" && key !== "hour") { this[addFunc](config[key] - this[getFunc]()); } else if ( key === "timezone"|| key === "timezoneOffset" || key === "week" || key === "hour") { this["set"+name](config[key]); } } } // day has to go last because you can't validate the day without first knowing the month if (config.day) { this.addDays(config.day - this.getDate()); } return this; }; /** * Moves the date to the first day of the month. * @return {Date} this */ $P.moveToFirstDayOfMonth = function () { return this.set({ day: 1 }); }; /** * Moves the date to the last day of the month. * @return {Date} this */ $P.moveToLastDayOfMonth = function () { return this.set({ day: $D.getDaysInMonth(this.getFullYear(), this.getMonth())}); }; /** * Converts the value of the current Date object to its equivalent string representation. * Format Specifiers * CUSTOM DATE AND TIME FORMAT STRINGS * Format Description Example * ------ --------------------------------------------------------------------------- ----------------------- * s The seconds of the minute between 0-59. "0" to "59" * ss The seconds of the minute with leading zero if required. "00" to "59" * * m The minute of the hour between 0-59. "0" or "59" * mm The minute of the hour with leading zero if required. "00" or "59" * * h The hour of the day between 1-12. "1" to "12" * hh The hour of the day with leading zero if required. "01" to "12" * * H The hour of the day between 0-23. "0" to "23" * HH The hour of the day with leading zero if required. "00" to "23" * * d The day of the month between 1 and 31. "1" to "31" * dd The day of the month with leading zero if required. "01" to "31" * ddd Abbreviated day name. Date.CultureInfo.abbreviatedDayNames. "Mon" to "Sun" * dddd The full day name. Date.CultureInfo.dayNames. "Monday" to "Sunday" * * M The month of the year between 1-12. "1" to "12" * MM The month of the year with leading zero if required. "01" to "12" * MMM Abbreviated month name. Date.CultureInfo.abbreviatedMonthNames. "Jan" to "Dec" * MMMM The full month name. Date.CultureInfo.monthNames. "January" to "December" * * yy The year as a two-digit number. "99" or "08" * yyyy The full four digit year. "1999" or "2008" * * t Displays the first character of the A.M./P.M. designator. "A" or "P" * Date.CultureInfo.amDesignator or Date.CultureInfo.pmDesignator * tt Displays the A.M./P.M. designator. "AM" or "PM" * Date.CultureInfo.amDesignator or Date.CultureInfo.pmDesignator * * S The ordinal suffix ("st, "nd", "rd" or "th") of the current day. "st, "nd", "rd" or "th" * * STANDARD DATE AND TIME FORMAT STRINGS * Format Description Example *------ --------------------------------------------------------------------------- ----------------------- * d The CultureInfo shortDate Format Pattern "M/d/yyyy" * D The CultureInfo longDate Format Pattern "dddd, MMMM dd, yyyy" * F The CultureInfo fullDateTime Format Pattern "dddd, MMMM dd, yyyy h:mm:ss tt" * m The CultureInfo monthDay Format Pattern "MMMM dd" * r The CultureInfo rfc1123 Format Pattern "ddd, dd MMM yyyy HH:mm:ss GMT" * s The CultureInfo sortableDateTime Format Pattern "yyyy-MM-ddTHH:mm:ss" * t The CultureInfo shortTime Format Pattern "h:mm tt" * T The CultureInfo longTime Format Pattern "h:mm:ss tt" * u The CultureInfo universalSortableDateTime Format Pattern "yyyy-MM-dd HH:mm:ssZ" * y The CultureInfo yearMonth Format Pattern "MMMM, yyyy" * * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @return {String} A string representation of the current Date object. */ var ord = function (n) { switch (n * 1) { case 1: case 21: case 31: return "st"; case 2: case 22: return "nd"; case 3: case 23: return "rd"; default: return "th"; } }; var parseStandardFormats = function (format) { var y, c = Date.CultureInfo.formatPatterns; switch (format) { case "d": return this.toString(c.shortDate); case "D": return this.toString(c.longDate); case "F": return this.toString(c.fullDateTime); case "m": return this.toString(c.monthDay); case "r": case "R": y = this.clone().addMinutes(this.getTimezoneOffset()); return y.toString(c.rfc1123) + " GMT"; case "s": return this.toString(c.sortableDateTime); case "t": return this.toString(c.shortTime); case "T": return this.toString(c.longTime); case "u": y = this.clone().addMinutes(this.getTimezoneOffset()); return y.toString(c.universalSortableDateTime); case "y": return this.toString(c.yearMonth); default: return false; } }; var parseFormatStringsClosure = function (context) { return function (m) { if (m.charAt(0) === "\\") { return m.replace("\\", ""); } switch (m) { case "hh": return p(context.getHours() < 13 ? (context.getHours() === 0 ? 12 : context.getHours()) : (context.getHours() - 12)); case "h": return context.getHours() < 13 ? (context.getHours() === 0 ? 12 : context.getHours()) : (context.getHours() - 12); case "HH": return p(context.getHours()); case "H": return context.getHours(); case "mm": return p(context.getMinutes()); case "m": return context.getMinutes(); case "ss": return p(context.getSeconds()); case "s": return context.getSeconds(); case "yyyy": return p(context.getFullYear(), 4); case "yy": return p(context.getFullYear()); case "y": return context.getFullYear(); case "E": case "dddd": return Date.CultureInfo.dayNames[context.getDay()]; case "ddd": return Date.CultureInfo.abbreviatedDayNames[context.getDay()]; case "dd": return p(context.getDate()); case "d": return context.getDate(); case "MMMM": return Date.CultureInfo.monthNames[context.getMonth()]; case "MMM": return Date.CultureInfo.abbreviatedMonthNames[context.getMonth()]; case "MM": return p((context.getMonth() + 1)); case "M": return context.getMonth() + 1; case "t": return context.getHours() < 12 ? Date.CultureInfo.amDesignator.substring(0, 1) : Date.CultureInfo.pmDesignator.substring(0, 1); case "tt": return context.getHours() < 12 ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator; case "S": return ord(context.getDate()); case "W": return context.getWeek(); case "WW": return context.getISOWeek(); case "Q": return "Q" + context.getQuarter(); case "q": return String(context.getQuarter()); case "z": return context.getTimezone(); case "Z": case "X": return Date.getTimezoneOffset(context.getTimezone()); case "ZZ": // Timezone offset in seconds return context.getTimezoneOffset() * -60; case "u": return context.getDay(); case "L": return ($D.isLeapYear(context.getFullYear())) ? 1 : 0; case "B": // Swatch Internet Time (.beats) return "@"+((context.getUTCSeconds() + (context.getUTCMinutes()*60) + ((context.getUTCHours()+1)*3600))/86.4); default: return m; } }; }; $P.toString = function (format, ignoreStandards) { // Standard Date and Time Format Strings. Formats pulled from CultureInfo file and // may vary by culture. if (!ignoreStandards && format && format.length === 1) { output = parseStandardFormats.call(this, format); if (output) { return output; } } var parseFormatStrings = parseFormatStringsClosure(this); return format ? format.replace(/((\\)?(dd?d?d?|MM?M?M?|yy?y?y?|hh?|HH?|mm?|ss?|tt?|S|q|Q|WW?W?W?)(?![^\[]*\]))/g, parseFormatStrings).replace(/\[|\]/g, "") : this._toString(); }; }()); /************************************************************* * SugarPak - Domain Specific Language - Syntactical Sugar * *************************************************************/ (function () { var $D = Date, $P = $D.prototype, $N = Number.prototype; // private $P._orient = +1; // private $P._nth = null; // private $P._is = false; // private $P._same = false; // private $P._isSecond = false; // private $N._dateElement = "days"; /** * Moves the date to the next instance of a date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.today().next().friday();
	Date.today().next().fri();
	Date.today().next().march();
	Date.today().next().mar();
	Date.today().next().week();
	
* * @return {Date} date */ $P.next = function () { this._move = true; this._orient = +1; return this; }; /** * Creates a new Date (Date.today()) and moves the date to the next instance of the date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.next().friday();
	Date.next().fri();
	Date.next().march();
	Date.next().mar();
	Date.next().week();
	
* * @return {Date} date */ $D.next = function () { return $D.today().next(); }; /** * Moves the date to the previous instance of a date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.today().last().friday();
	Date.today().last().fri();
	Date.today().last().march();
	Date.today().last().mar();
	Date.today().last().week();
	
* * @return {Date} date */ $P.last = $P.prev = $P.previous = function () { this._move = true; this._orient = -1; return this; }; /** * Creates a new Date (Date.today()) and moves the date to the previous instance of the date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.last().friday();
	Date.last().fri();
	Date.previous().march();
	Date.prev().mar();
	Date.last().week();
	
* * @return {Date} date */ $D.last = $D.prev = $D.previous = function () { return $D.today().last(); }; /** * Performs a equality check when followed by either a month name, day name or .weekday() function. * Example

	Date.today().is().friday(); // true|false
	Date.today().is().fri();
	Date.today().is().march();
	Date.today().is().mar();
	
* * @return {Boolean} true|false */ $P.is = function () { this._is = true; return this; }; /** * Determines if two date objects occur on/in exactly the same instance of the subsequent date part function. * The function .same() must be followed by a date part function (example: .day(), .month(), .year(), etc). * * An optional Date can be passed in the date part function. If now date is passed as a parameter, 'Now' is used. * * The following example demonstrates how to determine if two dates fall on the exact same day. * * Example

	var d1 = Date.today(); // today at 00:00
	var d2 = new Date();   // exactly now.

	// Do they occur on the same day?
	d1.same().day(d2); // true
	
	// Do they occur on the same hour?
	d1.same().hour(d2); // false, unless d2 hour is '00' (midnight).
	
	// What if it's the same day, but one year apart?
	var nextYear = Date.today().add(1).year();

	d1.same().day(nextYear); // false, because the dates must occur on the exact same day. 
	
* * Scenario: Determine if a given date occurs during some week period 2 months from now. * * Example

	var future = Date.today().add(2).months();
	return someDate.same().week(future); // true|false;
	
* * @return {Boolean} true|false */ $P.same = function () { this._same = true; this._isSecond = false; return this; }; /** * Determines if the current date/time occurs during Today. Must be preceded by the .is() function. * Example

	someDate.is().today();    // true|false
	new Date().is().today();  // true
	Date.today().is().today();// true
	Date.today().add(-1).day().is().today(); // false
	
* * @return {Boolean} true|false */ $P.today = function () { return this.same().day(); }; /** * Determines if the current date is a weekday. This function must be preceded by the .is() function. * Example

	Date.today().is().weekday(); // true|false
	
* * @return {Boolean} true|false */ $P.weekday = function () { if (this._nth) { return df("Weekday").call(this); } if (this._move) { return this.addWeekdays(this._orient); } if (this._is) { this._is = false; return (!this.is().sat() && !this.is().sun()); } return false; }; /** * Determines if the current date is on the weekend. This function must be preceded by the .is() function. * Example

	Date.today().is().weekend(); // true|false
	
* * @return {Boolean} true|false */ $P.weekend = function () { if (this._is) { this._is = false; return (this.is().sat() || this.is().sun()); } return false; }; /** * Sets the Time of the current Date instance. A string "6:15 pm" or config object {hour:18, minute:15} are accepted. * Example

	// Set time to 6:15pm with a String
	Date.today().at("6:15pm");

	// Set time to 6:15pm with a config object
	Date.today().at({hour:18, minute:15});
	
* * @return {Date} date */ $P.at = function (time) { return (typeof time === "string") ? $D.parse(this.toString("d") + " " + time) : this.set(time); }; /** * Creates a new Date() and adds this (Number) to the date based on the preceding date element function (eg. second|minute|hour|day|month|year). * Example

	// Undeclared Numbers must be wrapped with parentheses. Requirment of JavaScript.
	(3).days().fromNow();
	(6).months().fromNow();

	// Declared Number variables do not require parentheses. 
	var n = 6;
	n.months().fromNow();
	
* * @return {Date} A new Date instance */ $N.fromNow = $N.after = function (date) { var c = {}; c[this._dateElement] = this; return ((!date) ? new Date() : date.clone()).add(c); }; /** * Creates a new Date() and subtract this (Number) from the date based on the preceding date element function (eg. second|minute|hour|day|month|year). * Example

	// Undeclared Numbers must be wrapped with parentheses. Requirment of JavaScript.
	(3).days().ago();
	(6).months().ago();

	// Declared Number variables do not require parentheses. 
	var n = 6;
	n.months().ago();
	
* * @return {Date} A new Date instance */ $N.ago = $N.before = function (date) { var c = {}, s = (this._dateElement[this._dateElement.length-1] !== "s") ? this._dateElement + "s" : this._dateElement; c[s] = this * -1; return ((!date) ? new Date() : date.clone()).add(c); }; // Do NOT modify the following string tokens. These tokens are used to build dynamic functions. // All culture-specific strings can be found in the CultureInfo files. var dx = ("sunday monday tuesday wednesday thursday friday saturday").split(/\s/), mx = ("january february march april may june july august september october november december").split(/\s/), px = ("Millisecond Second Minute Hour Day Week Month Year Quarter Weekday").split(/\s/), pxf = ("Milliseconds Seconds Minutes Hours Date Week Month FullYear Quarter").split(/\s/), nth = ("final first second third fourth fifth").split(/\s/), de; /** * Returns an object literal of all the date parts. * Example

	var o = new Date().toObject();
	
	// { year: 2008, month: 4, week: 20, day: 13, hour: 18, minute: 9, second: 32, millisecond: 812 }
	
	// The object properties can be referenced directly from the object.
	
	alert(o.day);  // alerts "13"
	alert(o.year); // alerts "2008"
	
* * @return {Date} An object literal representing the original date object. */ $P.toObject = function () { var o = {}; for (var i = 0; i < px.length; i++) { if (this["get" + pxf[i]]) { o[px[i].toLowerCase()] = this["get" + pxf[i]](); } } return o; }; /** * Returns a date created from an object literal. Ignores the .week property if set in the config. * Example

	var o = new Date().toObject();
	
	return Date.fromObject(o); // will return the same date. 

	var o2 = {month: 1, day: 20, hour: 18}; // birthday party!
	Date.fromObject(o2);
	
* * @return {Date} An object literal representing the original date object. */ $D.fromObject = function(config) { config.week = null; return Date.today().set(config); }; // Create day name functions and abbreviated day name functions (eg. monday(), friday(), fri()). var df = function (n) { return function () { if (this._is) { this._is = false; return this.getDay() === n; } if (this._move) { this._move = null; } if (this._nth !== null) { // If the .second() function was called earlier, remove the _orient // from the date, and then continue. // This is required because 'second' can be used in two different context. // // Example // // Date.today().add(1).second(); // Date.march().second().monday(); // // Things get crazy with the following... // Date.march().add(1).second().second().monday(); // but it works!! // if (this._isSecond) { this.addSeconds(this._orient * -1); } // make sure we reset _isSecond this._isSecond = false; var ntemp = this._nth; this._nth = null; var temp = this.clone().moveToLastDayOfMonth(); this.moveToNthOccurrence(n, ntemp); if (this > temp) { throw new RangeError($D.getDayName(n) + " does not occur " + ntemp + " times in the month of " + $D.getMonthName(temp.getMonth()) + " " + temp.getFullYear() + "."); } return this; } return this.moveToDayOfWeek(n, this._orient); }; }; var sdf = function (n) { return function () { var t = $D.today(), shift = n - t.getDay(); if (n === 0 && Date.CultureInfo.firstDayOfWeek === 1 && t.getDay() !== 0) { shift = shift + 7; } return t.addDays(shift); }; }; // Create month name functions and abbreviated month name functions (eg. january(), march(), mar()). var month_instance_functions = function (n) { return function () { if (this._is) { this._is = false; return this.getMonth() === n; } return this.moveToMonth(n, this._orient); }; }; var month_static_functions = function (n) { return function () { return $D.today().set({ month: n, day: 1 }); }; }; var processTerms = function (names, staticFunc, instanceFunc) { for (var i = 0; i < names.length; i++) { // Create constant static Name variables. $D[names[i].toUpperCase()] = $D[names[i].toUpperCase().substring(0, 3)] = i; // Create Name functions. $D[names[i]] = $D[names[i].substring(0, 3)] = staticFunc(i); // Create Name instance functions. $P[names[i]] = $P[names[i].substring(0, 3)] = instanceFunc(i); } }; processTerms(dx, sdf, df); processTerms(mx, month_static_functions, month_instance_functions); // Create date element functions and plural date element functions used with Date (eg. day(), days(), months()). var ef = function (j) { return function () { // if the .second() function was called earlier, the _orient // has alread been added. Just return this and reset _isSecond. if (this._isSecond) { this._isSecond = false; return this; } if (this._same) { this._same = this._is = false; var o1 = this.toObject(), o2 = (arguments[0] || new Date()).toObject(), v = "", k = j.toLowerCase(); // the substr trick with -1 doesn't work in IE8 or less k = (k[k.length-1] === "s") ? k.substring(0,k.length-1) : k; for (var m = (px.length - 1); m > -1; m--) { v = px[m].toLowerCase(); if (o1[v] !== o2[v]) { return false; } if (k === v) { break; } } return true; } if (j.substring(j.length - 1) !== "s") { j += "s"; } if (this._move) { this._move = null; } return this["add" + j](this._orient); }; }; var nf = function (n) { return function () { this._dateElement = n; return this; }; }; for (var k = 0; k < px.length; k++) { de = px[k].toLowerCase(); if(de !== "weekday") { // Create date element functions and plural date element functions used with Date (eg. day(), days(), months()). $P[de] = $P[de + "s"] = ef(px[k]); // Create date element functions and plural date element functions used with Number (eg. day(), days(), months()). $N[de] = $N[de + "s"] = nf(de + "s"); } } $P._ss = ef("Second"); var nthfn = function (n) { return function (dayOfWeek) { if (this._same) { return this._ss(arguments[0]); } if (dayOfWeek || dayOfWeek === 0) { return this.moveToNthOccurrence(dayOfWeek, n); } this._nth = n; // if the operator is 'second' add the _orient, then deal with it later... if (n === 2 && (dayOfWeek === undefined || dayOfWeek === null)) { this._isSecond = true; return this.addSeconds(this._orient); } return this; }; }; for (var l = 0; l < nth.length; l++) { $P[nth[l]] = (l === 0) ? nthfn(-1) : nthfn(l); } }()); (function () { "use strict"; Date.Parsing = { Exception: function (s) { this.message = "Parse error at '" + s.substring(0, 10) + " ...'"; } }; var $P = Date.Parsing; var dayOffsets = { standard: [0,31,59,90,120,151,181,212,243,273,304,334], leap: [0,31,60,91,121,152,182,213,244,274,305,335] }; $P.isLeapYear = function(year) { return ((year % 4 === 0) && (year % 100 !== 0)) || (year % 400 === 0); }; var utils = { multiReplace : function (str, hash ) { var key; for (key in hash) { if (Object.prototype.hasOwnProperty.call(hash, key)) { var regex; if (typeof hash[key] === "function") { } else { regex = (hash[key] instanceof RegExp) ? hash[key] : new RegExp(hash[key], "g"); } str = str.replace(regex, key); } } return str; }, getDayOfYearFromWeek : function (obj) { var d, jan4, offset; obj.weekDay = (!obj.weekDay && obj.weekDay !== 0) ? 1 : obj.weekDay; d = new Date(obj.year, 0, 4); jan4 = d.getDay() === 0 ? 7 : d.getDay(); // JS is 0 indexed on Sunday. offset = jan4+3; obj.dayOfYear = ((obj.week * 7) + (obj.weekDay === 0 ? 7 : obj.weekDay))-offset; return obj; }, getDayOfYear : function (obj, dayOffset) { if (!obj.dayOfYear) { obj = utils.getDayOfYearFromWeek(obj); } for (var i=0;i <= dayOffset.length;i++) { if (obj.dayOfYear < dayOffset[i] || i === dayOffset.length) { obj.day = obj.day ? obj.day : (obj.dayOfYear - dayOffset[i-1]); break; } else { obj.month = i; } } return obj; }, adjustForTimeZone : function (obj, date) { var offset; if (obj.zone.toUpperCase() === "Z" || (obj.zone_hours === 0 && obj.zone_minutes === 0)) { // it's UTC/GML so work out the current timeszone offset offset = -date.getTimezoneOffset(); } else { offset = (obj.zone_hours*60) + (obj.zone_minutes || 0); if (obj.zone_sign === "+") { offset *= -1; } offset -= date.getTimezoneOffset(); } date.setMinutes(date.getMinutes()+offset); return date; }, setDefaults : function (obj) { obj.year = obj.year || Date.today().getFullYear(); obj.hours = obj.hours || 0; obj.minutes = obj.minutes || 0; obj.seconds = obj.seconds || 0; obj.milliseconds = obj.milliseconds || 0; if (!(!obj.month && (obj.week || obj.dayOfYear))) { // if we have a month, or if we don't but don't have the day calculation data obj.month = obj.month || 0; obj.day = obj.day || 1; } return obj; }, dataNum: function (data, mod, explict, postProcess) { var dataNum = data*1; if (mod) { if (postProcess) { return data ? mod(data)*1 : data; } else { return data ? mod(dataNum) : data; } } else if (!explict){ return data ? dataNum : data; } else { return (data && typeof data !== "undefined") ? dataNum : data; } }, timeDataProcess: function (obj) { var timeObj = {}; for (var x in obj.data) { if (obj.data.hasOwnProperty(x)) { timeObj[x] = obj.ignore[x] ? obj.data[x] : utils.dataNum(obj.data[x], obj.mods[x], obj.explict[x], obj.postProcess[x]); } } if (obj.data.secmins) { obj.data.secmins = obj.data.secmins.replace(",", ".") * 60; if (!timeObj.minutes) { timeObj.minutes = obj.data.secmins; } else if (!timeObj.seconds) { timeObj.seconds = obj.data.secmins; } delete obj.secmins; } return timeObj; }, buildTimeObjectFromData: function (data) { var time = utils.timeDataProcess({ data: { year : data[1], month : data[5], day : data[7], week : data[8], dayOfYear : data[10], hours : data[15], zone_hours : data[23], zone_minutes : data[24], zone : data[21], zone_sign : data[22], weekDay : data[9], minutes: data[16], seconds: data[19], milliseconds: data[20], secmins: data[18] }, mods: { month: function(data) { return data-1; }, weekDay: function (data) { data = Math.abs(data); return (data === 7 ? 0 : data); }, minutes: function (data) { return data.replace(":",""); }, seconds: function (data) { return Math.floor( (data.replace(":","").replace(",","."))*1 ); }, milliseconds: function (data) { return (data.replace(",",".")*1000); } }, postProcess: { minutes: true, seconds: true, milliseconds: true }, explict: { zone_hours: true, zone_minutes: true }, ignore: { zone: true, zone_sign: true, secmins: true } }); return time; }, addToHash: function (hash, keys, data) { keys = keys; data = data; var len = keys.length; for (var i = 0; i < len; i++) { hash[keys[i]] = data[i]; } return hash; }, combineRegex: function (r1, r2) { return new RegExp("(("+r1.source+")\\s("+r2.source+"))"); }, getDateNthString: function(add, last, inc){ if (add) { return Date.today().addDays(inc).toString("d"); } else if (last) { return Date.today().last()[inc]().toString("d"); } }, buildRegexData: function (array) { var arr = []; var len = array.length; for (var i=0; i < len; i++) { if (Object.prototype.toString.call(array[i]) === '[object Array]') { // oldIE compat version of Array.isArray arr.push(this.combineRegex(array[i][0], array[i][1])); } else { arr.push(array[i]); } } return arr; } }; $P.processTimeObject = function (obj) { var date, dayOffset; utils.setDefaults(obj); dayOffset = ($P.isLeapYear(obj.year)) ? dayOffsets.leap : dayOffsets.standard; if (!obj.month && (obj.week || obj.dayOfYear)) { utils.getDayOfYear(obj, dayOffset); } else { obj.dayOfYear = dayOffset[obj.month] + obj.day; } date = new Date(obj.year, obj.month, obj.day, obj.hours, obj.minutes, obj.seconds, obj.milliseconds); if (obj.zone) { utils.adjustForTimeZone(obj, date); // adjust (and calculate) for timezone } return date; }; $P.ISO = { regex : /^([\+-]?\d{4}(?!\d{2}\b))((-?)((0[1-9]|1[0-2])(\3([12]\d|0[1-9]|3[01]))?|W([0-4]\d|5[0-3])(-?[1-7])?|(00[1-9]|0[1-9]\d|[12]\d{2}|3([0-5]\d|6[1-6])))([T\s]((([01]\d|2[0-4])((:?)[0-5]\d)?|24\:?00)([\.,]\d+(?!:))?)?(\17[0-5]\d([\.,]\d+)?)?\s?([zZ]|([\+-])([01]\d|2[0-3]):?([0-5]\d)?)?)?)?$/, parse : function (s) { var time, data = s.match(this.regex); if (!data || !data.length) { return null; } time = utils.buildTimeObjectFromData(data); if (!time.year || (!time.year && (!time.month && !time.day) && (!time.week && !time.dayOfYear)) ) { return null; } return $P.processTimeObject(time); } }; $P.Numeric = { isNumeric: function (e){return!isNaN(parseFloat(e))&&isFinite(e);}, regex: /\b([0-1]?[0-9])([0-3]?[0-9])([0-2]?[0-9]?[0-9][0-9])\b/i, parse: function (s) { var data, i, time = {}, order = Date.CultureInfo.dateElementOrder.split(""); if (!(this.isNumeric(s)) || // if it's non-numeric OR (s[0] === "+" && s[0] === "-")) { // It's an arithmatic string (eg +/-1000) return null; } if (s.length < 5 && s.indexOf(".") < 0 && s.indexOf("/") < 0) { // assume it's just a year. time.year = s; return $P.processTimeObject(time); } data = s.match(this.regex); if (!data || !data.length) { return null; } for (i=0; i < order.length; i++) { switch(order[i]) { case "d": time.day = data[i+1]; break; case "m": time.month = (data[i+1]-1); break; case "y": time.year = data[i+1]; break; } } return $P.processTimeObject(time); } }; $P.Normalizer = { regexData: function () { var $R = Date.CultureInfo.regexPatterns; return utils.buildRegexData([ $R.tomorrow, $R.yesterday, [$R.past, $R.mon], [$R.past, $R.tue], [$R.past, $R.wed], [$R.past, $R.thu], [$R.past, $R.fri], [$R.past, $R.sat], [$R.past, $R.sun] ]); }, basicReplaceHash : function() { var $R = Date.CultureInfo.regexPatterns; return { "January": $R.jan.source, "February": $R.feb, "March": $R.mar, "April": $R.apr, "May": $R.may, "June": $R.jun, "July": $R.jul, "August": $R.aug, "September": $R.sep, "October": $R.oct, "November": $R.nov, "December": $R.dec, "": /\bat\b/gi, " ": /\s{2,}/, "am": $R.inTheMorning, "9am": $R.thisMorning, "pm": $R.inTheEvening, "7pm":$R.thisEvening }; }, keys : function(){ return [ utils.getDateNthString(true, false, 1), // tomorrow utils.getDateNthString(true, false, -1), // yesterday utils.getDateNthString(false, true, "monday"), //last mon utils.getDateNthString(false, true, "tuesday"), //last tues utils.getDateNthString(false, true, "wednesday"), //last wed utils.getDateNthString(false, true, "thursday"), //last thurs utils.getDateNthString(false, true, "friday"), //last fri utils.getDateNthString(false, true, "saturday"), //last sat utils.getDateNthString(false, true, "sunday") //last sun ]; }, buildRegexFunctions: function () { var $R = Date.CultureInfo.regexPatterns; var __ = Date.i18n.__; var tomorrowRE = new RegExp("(\\b\\d\\d?("+__("AM")+"|"+__("PM")+")? )("+$R.tomorrow.source.slice(1)+")", "i"); // adapted tomorrow regex for AM PM relative dates var todayRE = new RegExp($R.today.source + "(?!\\s*([+-]))\\b"); // today, but excludes the math operators (eg "today + 2h") this.replaceFuncs = [ [todayRE, function (full) { return (full.length > 1) ? Date.today().toString("d") : full; }], [tomorrowRE, function(full, m1) { var t = Date.today().addDays(1).toString("d"); return (t + " " + m1); }], [$R.amThisMorning, function(str, am){return am;}], [$R.pmThisEvening, function(str, pm){return pm;}] ]; }, buildReplaceData: function () { this.buildRegexFunctions(); this.replaceHash = utils.addToHash(this.basicReplaceHash(), this.keys(), this.regexData()); }, stringReplaceFuncs: function (s) { for (var i=0; i < this.replaceFuncs.length; i++) { s = s.replace(this.replaceFuncs[i][0], this.replaceFuncs[i][1]); } return s; }, parse: function (s) { s = this.stringReplaceFuncs(s); s = utils.multiReplace(s, this.replaceHash); try { var n = s.split(/([\s\-\.\,\/\x27]+)/); if (n.length === 3 && $P.Numeric.isNumeric(n[0]) && $P.Numeric.isNumeric(n[2]) && (n[2].length >= 4)) { // ok, so we're dealing with x/year. But that's not a full date. // This fixes wonky dateElementOrder parsing when set to dmy order. if (Date.CultureInfo.dateElementOrder[0] === "d") { s = "1/" + n[0] + "/" + n[2]; // set to 1st of month and normalize the seperator } } } catch (e) {} return s; } }; $P.Normalizer.buildReplaceData(); }()); (function () { var $P = Date.Parsing; var _ = $P.Operators = { // // Tokenizers // rtoken: function (r) { // regex token return function (s) { var mx = s.match(r); if (mx) { return ([ mx[0], s.substring(mx[0].length) ]); } else { throw new $P.Exception(s); } }; }, token: function () { // whitespace-eating token return function (s) { return _.rtoken(new RegExp("^\\s*" + s + "\\s*"))(s); }; }, stoken: function (s) { // string token return _.rtoken(new RegExp("^" + s)); }, // Atomic Operators until: function (p) { return function (s) { var qx = [], rx = null; while (s.length) { try { rx = p.call(this, s); } catch (e) { qx.push(rx[0]); s = rx[1]; continue; } break; } return [ qx, s ]; }; }, many: function (p) { return function (s) { var rx = [], r = null; while (s.length) { try { r = p.call(this, s); } catch (e) { return [ rx, s ]; } rx.push(r[0]); s = r[1]; } return [ rx, s ]; }; }, // generator operators -- see below optional: function (p) { return function (s) { var r = null; try { r = p.call(this, s); } catch (e) { return [ null, s ]; } return [ r[0], r[1] ]; }; }, not: function (p) { return function (s) { try { p.call(this, s); } catch (e) { return [null, s]; } throw new $P.Exception(s); }; }, ignore: function (p) { return p ? function (s) { var r = null; r = p.call(this, s); return [null, r[1]]; } : null; }, product: function () { var px = arguments[0], qx = Array.prototype.slice.call(arguments, 1), rx = []; for (var i = 0 ; i < px.length ; i++) { rx.push(_.each(px[i], qx)); } return rx; }, cache: function (rule) { var cache = {}, cache_length = 0, cache_keys = [], CACHE_MAX = Date.Config.CACHE_MAX || 100000, r = null; var cacheCheck = function () { if (cache_length === CACHE_MAX) { // kill several keys, don't want to have to do this all the time... for (var i=0; i < 10; i++) { var key = cache_keys.shift(); if (key) { delete cache[key]; cache_length--; } } } }; return function (s) { cacheCheck(); try { r = cache[s] = (cache[s] || rule.call(this, s)); } catch (e) { r = cache[s] = e; } cache_length++; cache_keys.push(s); if (r instanceof $P.Exception) { throw r; } else { return r; } }; }, // vector operators -- see below any: function () { var px = arguments; return function (s) { var r = null; for (var i = 0; i < px.length; i++) { if (px[i] == null) { continue; } try { r = (px[i].call(this, s)); } catch (e) { r = null; } if (r) { return r; } } throw new $P.Exception(s); }; }, each: function () { var px = arguments; return function (s) { var rx = [], r = null; for (var i = 0; i < px.length ; i++) { if (px[i] == null) { continue; } try { r = (px[i].call(this, s)); } catch (e) { throw new $P.Exception(s); } rx.push(r[0]); s = r[1]; } return [ rx, s]; }; }, all: function () { var px = arguments, _ = _; return _.each(_.optional(px)); }, // delimited operators sequence: function (px, d, c) { d = d || _.rtoken(/^\s*/); c = c || null; if (px.length === 1) { return px[0]; } return function (s) { var r = null, q = null; var rx = []; for (var i = 0; i < px.length ; i++) { try { r = px[i].call(this, s); } catch (e) { break; } rx.push(r[0]); try { q = d.call(this, r[1]); } catch (ex) { q = null; break; } s = q[1]; } if (!r) { throw new $P.Exception(s); } if (q) { throw new $P.Exception(q[1]); } if (c) { try { r = c.call(this, r[1]); } catch (ey) { throw new $P.Exception(r[1]); } } return [ rx, (r?r[1]:s) ]; }; }, // // Composite Operators // between: function (d1, p, d2) { d2 = d2 || d1; var _fn = _.each(_.ignore(d1), p, _.ignore(d2)); return function (s) { var rx = _fn.call(this, s); return [[rx[0][0], r[0][2]], rx[1]]; }; }, list: function (p, d, c) { d = d || _.rtoken(/^\s*/); c = c || null; return (p instanceof Array ? _.each(_.product(p.slice(0, -1), _.ignore(d)), p.slice(-1), _.ignore(c)) : _.each(_.many(_.each(p, _.ignore(d))), px, _.ignore(c))); }, set: function (px, d, c) { d = d || _.rtoken(/^\s*/); c = c || null; return function (s) { // r is the current match, best the current 'best' match // which means it parsed the most amount of input var r = null, p = null, q = null, rx = null, best = [[], s], last = false; // go through the rules in the given set for (var i = 0; i < px.length ; i++) { // last is a flag indicating whether this must be the last element // if there is only 1 element, then it MUST be the last one q = null; p = null; r = null; last = (px.length === 1); // first, we try simply to match the current pattern // if not, try the next pattern try { r = px[i].call(this, s); } catch (e) { continue; } // since we are matching against a set of elements, the first // thing to do is to add r[0] to matched elements rx = [[r[0]], r[1]]; // if we matched and there is still input to parse and // we don't already know this is the last element, // we're going to next check for the delimiter ... // if there's none, or if there's no input left to parse // than this must be the last element after all ... if (r[1].length > 0 && ! last) { try { q = d.call(this, r[1]); } catch (ex) { last = true; } } else { last = true; } // if we parsed the delimiter and now there's no more input, // that means we shouldn't have parsed the delimiter at all // so don't update r and mark this as the last element ... if (!last && q[1].length === 0) { last = true; } // so, if this isn't the last element, we're going to see if // we can get any more matches from the remaining (unmatched) // elements ... if (!last) { // build a list of the remaining rules we can match against, // i.e., all but the one we just matched against var qx = []; for (var j = 0; j < px.length ; j++) { if (i !== j) { qx.push(px[j]); } } // now invoke recursively set with the remaining input // note that we don't include the closing delimiter ... // we'll check for that ourselves at the end p = _.set(qx, d).call(this, q[1]); // if we got a non-empty set as a result ... // (otw rx already contains everything we want to match) if (p[0].length > 0) { // update current result, which is stored in rx ... // basically, pick up the remaining text from p[1] // and concat the result from p[0] so that we don't // get endless nesting ... rx[0] = rx[0].concat(p[0]); rx[1] = p[1]; } } // at this point, rx either contains the last matched element // or the entire matched set that starts with this element. // now we just check to see if this variation is better than // our best so far, in terms of how much of the input is parsed if (rx[1].length < best[1].length) { best = rx; } // if we've parsed all the input, then we're finished if (best[1].length === 0) { break; } } // so now we've either gone through all the patterns trying them // as the initial match; or we found one that parsed the entire // input string ... // if best has no matches, just return empty set ... if (best[0].length === 0) { return best; } // if a closing delimiter is provided, then we have to check it also if (c) { // we try this even if there is no remaining input because the pattern // may well be optional or match empty input ... try { q = c.call(this, best[1]); } catch (ey) { throw new $P.Exception(best[1]); } // it parsed ... be sure to update the best match remaining input best[1] = q[1]; } // if we're here, either there was no closing delimiter or we parsed it // so now we have the best match; just return it! return best; }; }, forward: function (gr, fname) { return function (s) { return gr[fname].call(this, s); }; }, // // Translation Operators // replace: function (rule, repl) { return function (s) { var r = rule.call(this, s); return [repl, r[1]]; }; }, process: function (rule, fn) { return function (s) { var r = rule.call(this, s); return [fn.call(this, r[0]), r[1]]; }; }, min: function (min, rule) { return function (s) { var rx = rule.call(this, s); if (rx[0].length < min) { throw new $P.Exception(s); } return rx; }; } }; // Generator Operators And Vector Operators // Generators are operators that have a signature of F(R) => R, // taking a given rule and returning another rule, such as // ignore, which parses a given rule and throws away the result. // Vector operators are those that have a signature of F(R1,R2,...) => R, // take a list of rules and returning a new rule, such as each. // Generator operators are converted (via the following _generator // function) into functions that can also take a list or array of rules // and return an array of new rules as though the function had been // called on each rule in turn (which is what actually happens). // This allows generators to be used with vector operators more easily. // Example: // each(ignore(foo, bar)) instead of each(ignore(foo), ignore(bar)) // This also turns generators into vector operators, which allows // constructs like: // not(cache(foo, bar)) var _generator = function (op) { function gen() { var args = null, rx = [], px, i; if (arguments.length > 1) { args = Array.prototype.slice.call(arguments); } else if (arguments[0] instanceof Array) { args = arguments[0]; } if (args) { px = args.shift(); if (px.length > 0) { args.unshift(px[i]); rx.push(op.apply(null, args)); args.shift(); return rx; } } else { return op.apply(null, arguments); } } return gen; }; var gx = "optional not ignore cache".split(/\s/); for (var i = 0 ; i < gx.length ; i++) { _[gx[i]] = _generator(_[gx[i]]); } var _vector = function (op) { return function () { if (arguments[0] instanceof Array) { return op.apply(null, arguments[0]); } else { return op.apply(null, arguments); } }; }; var vx = "each any all".split(/\s/); for (var j = 0 ; j < vx.length ; j++) { _[vx[j]] = _vector(_[vx[j]]); } }()); (function () { var $D = Date; var flattenAndCompact = function (ax) { var rx = []; for (var i = 0; i < ax.length; i++) { if (ax[i] instanceof Array) { rx = rx.concat(flattenAndCompact(ax[i])); } else { if (ax[i]) { rx.push(ax[i]); } } } return rx; }; var parseMeridian = function () { if (this.meridian && (this.hour || this.hour === 0)) { if (this.meridian === "a" && this.hour > 11 && Date.Config.strict24hr){ throw "Invalid hour and meridian combination"; } else if (this.meridian === "p" && this.hour < 12 && Date.Config.strict24hr){ throw "Invalid hour and meridian combination"; } else if (this.meridian === "p" && this.hour < 12) { this.hour = this.hour + 12; } else if (this.meridian === "a" && this.hour === 12) { this.hour = 0; } } }; var setDefaults = function () { var now = new Date(); if ((this.hour || this.minute) && (!this.month && !this.year && !this.day)) { this.day = now.getDate(); } if (!this.year) { this.year = now.getFullYear(); } if (!this.month && this.month !== 0) { this.month = now.getMonth(); } if (!this.day) { this.day = 1; } if (!this.hour) { this.hour = 0; } if (!this.minute) { this.minute = 0; } if (!this.second) { this.second = 0; } if (!this.millisecond) { this.millisecond = 0; } }; var finishUtils = { getToday: function () { if (this.now || "hour minute second".indexOf(this.unit) !== -1) { return new Date(); } else { return $D.today(); } }, setDaysFromWeekday: function (today, orient){ var gap; orient = orient || 1; this.unit = "day"; gap = ($D.getDayNumberFromName(this.weekday) - today.getDay()); this.days = gap ? ((gap + (orient * 7)) % 7) : (orient * 7); return this; }, setMonthsFromMonth: function (today, orient) { var gap; orient = orient || 1; this.unit = "month"; gap = (this.month - today.getMonth()); this.months = gap ? ((gap + (orient * 12)) % 12) : (orient * 12); this.month = null; return this; }, setDMYFromWeekday: function () { var d = Date[this.weekday](); this.day = d.getDate(); if (!this.month) { this.month = d.getMonth(); } this.year = d.getFullYear(); return this; }, setUnitValue: function (orient) { if (!this.value && this.operator && this.operator !== null && this[this.unit + "s"] && this[this.unit + "s"] !== null) { this[this.unit + "s"] = this[this.unit + "s"] + ((this.operator === "add") ? 1 : -1) + (this.value||0) * orient; } else if (this[this.unit + "s"] == null || this.operator != null) { if (!this.value) { this.value = 1; } this[this.unit + "s"] = this.value * orient; } }, generateDateFromWeeks: function () { var weekday = (this.weekday !== undefined) ? this.weekday : "today"; var d = Date[weekday]().addWeeks(this.weeks); if (this.now) { d.setTimeToNow(); } return d; } }; $D.Translator = { hour: function (s) { return function () { this.hour = Number(s); }; }, minute: function (s) { return function () { this.minute = Number(s); }; }, second: function (s) { return function () { this.second = Number(s); }; }, /* for ss.s format */ secondAndMillisecond: function (s) { return function () { var mx = s.match(/^([0-5][0-9])\.([0-9]{1,3})/); this.second = Number(mx[1]); this.millisecond = Number(mx[2]); }; }, meridian: function (s) { return function () { this.meridian = s.slice(0, 1).toLowerCase(); }; }, timezone: function (s) { return function () { var n = s.replace(/[^\d\+\-]/g, ""); if (n.length) { this.timezoneOffset = Number(n); } else { this.timezone = s.toLowerCase(); } }; }, day: function (x) { var s = x[0]; return function () { this.day = Number(s.match(/\d+/)[0]); if (this.day < 1) { throw "invalid day"; } }; }, month: function (s) { return function () { this.month = (s.length === 3) ? "jan feb mar apr may jun jul aug sep oct nov dec".indexOf(s)/4 : Number(s) - 1; if (this.month < 0) { throw "invalid month"; } }; }, year: function (s) { return function () { var n = Number(s); this.year = ((s.length > 2) ? n : (n + (((n + 2000) < Date.CultureInfo.twoDigitYearMax) ? 2000 : 1900))); }; }, rday: function (s) { return function () { switch (s) { case "yesterday": this.days = -1; break; case "tomorrow": this.days = 1; break; case "today": this.days = 0; break; case "now": this.days = 0; this.now = true; break; } }; }, finishExact: function (x) { var d; x = (x instanceof Array) ? x : [x]; for (var i = 0 ; i < x.length ; i++) { if (x[i]) { x[i].call(this); } } setDefaults.call(this); parseMeridian.call(this); if (this.day > $D.getDaysInMonth(this.year, this.month)) { throw new RangeError(this.day + " is not a valid value for days."); } d = new Date(this.year, this.month, this.day, this.hour, this.minute, this.second, this.millisecond); if (this.year < 100) { d.setFullYear(this.year); // means years less that 100 are process correctly. JS will parse it otherwise as 1900-1999. } if (this.timezone) { d.set({ timezone: this.timezone }); } else if (this.timezoneOffset) { d.set({ timezoneOffset: this.timezoneOffset }); } return d; }, finish: function (x) { var today, expression, orient, temp; x = (x instanceof Array) ? flattenAndCompact(x) : [ x ]; if (x.length === 0) { return null; } for (var i = 0 ; i < x.length ; i++) { if (typeof x[i] === "function") { x[i].call(this); } } if (this.now && !this.unit && !this.operator) { return new Date(); } else { today = finishUtils.getToday.call(this); } expression = !!(this.days && this.days !== null || this.orient || this.operator); orient = ((this.orient === "past" || this.operator === "subtract") ? -1 : 1); if (this.month && this.unit === "week") { this.value = this.month + 1; delete this.month; delete this.day; } if ((this.month || this.month === 0) && "year day hour minute second".indexOf(this.unit) !== -1) { if (!this.value) { this.value = this.month + 1; } this.month = null; expression = true; } if (!expression && this.weekday && !this.day && !this.days) { finishUtils.setDMYFromWeekday.call(this); } if (expression && this.weekday && this.unit !== "month" && this.unit !== "week") { finishUtils.setDaysFromWeekday.call(this, today, orient); } if (this.weekday && this.unit !== "week" && !this.day && !this.days) { temp = Date[this.weekday](); this.day = temp.getDate(); if (temp.getMonth() !== today.getMonth()) { this.month = temp.getMonth(); } } if (this.month && this.unit === "day" && this.operator) { if (!this.value) { this.value = (this.month + 1); } this.month = null; } if (this.value != null && this.month != null && this.year != null) { this.day = this.value * 1; } if (this.month && !this.day && this.value) { today.set({ day: this.value * 1 }); if (!expression) { this.day = this.value * 1; } } if (!this.month && this.value && this.unit === "month" && !this.now) { this.month = this.value; expression = true; } if (expression && (this.month || this.month === 0) && this.unit !== "year") { finishUtils.setMonthsFromMonth.call(this, today, orient); } if (!this.unit) { this.unit = "day"; } finishUtils.setUnitValue.call(this, orient); parseMeridian.call(this); if ((this.month || this.month === 0) && !this.day) { this.day = 1; } if (!this.orient && !this.operator && this.unit === "week" && this.value && !this.day && !this.month) { return Date.today().setWeek(this.value); } if (this.unit === "week" && this.weeks && !this.day && !this.month) { return finishUtils.generateDateFromWeeks.call(this); } if (expression && this.timezone && this.day && this.days) { this.day = this.days; } if (expression){ today.add(this); } else { today.set(this); } if (this.timezone) { this.timezone = this.timezone.toUpperCase(); var offset = $D.getTimezoneOffset(this.timezone); var timezone; if (today.hasDaylightSavingTime()) { // lets check that we're being sane with timezone setting timezone = $D.getTimezoneAbbreviation(offset, today.isDaylightSavingTime()); if (timezone !== this.timezone) { // bugger, we're in a place where things like EST vs EDT matters. if (today.isDaylightSavingTime()) { today.addHours(-1); } else { today.addHours(1); } } } today.setTimezoneOffset(offset); } return today; } }; }()); (function () { var $D = Date; $D.Grammar = {}; var _ = $D.Parsing.Operators, g = $D.Grammar, t = $D.Translator, _fn; // Allow rolling up into general purpose rules _fn = function () { return _.each(_.any.apply(null, arguments), _.not(g.ctoken2("timeContext"))); }; g.datePartDelimiter = _.rtoken(/^([\s\-\.\,\/\x27]+)/); g.timePartDelimiter = _.stoken(":"); g.whiteSpace = _.rtoken(/^\s*/); g.generalDelimiter = _.rtoken(/^(([\s\,]|at|@|on)+)/); var _C = {}; g.ctoken = function (keys) { var fn = _C[keys]; if (! fn) { var c = Date.CultureInfo.regexPatterns; var kx = keys.split(/\s+/), px = []; for (var i = 0; i < kx.length ; i++) { px.push(_.replace(_.rtoken(c[kx[i]]), kx[i])); } fn = _C[keys] = _.any.apply(null, px); } return fn; }; g.ctoken2 = function (key) { return _.rtoken(Date.CultureInfo.regexPatterns[key]); }; var cacheProcessRtoken = function (key, token, type, eachToken) { if (eachToken) { g[key] = _.cache(_.process(_.each(_.rtoken(token),_.optional(g.ctoken2(eachToken))), type)); } else { g[key] = _.cache(_.process(_.rtoken(token), type)); } }; var cacheProcessCtoken = function (token, type) { return _.cache(_.process(g.ctoken2(token), type)); }; var _F = {}; //function cache var _get = function (f) { _F[f] = (_F[f] || g.format(f)[0]); return _F[f]; }; g.allformats = function (fx) { var rx = []; if (fx instanceof Array) { for (var i = 0; i < fx.length; i++) { rx.push(_get(fx[i])); } } else { rx.push(_get(fx)); } return rx; }; g.formats = function (fx) { if (fx instanceof Array) { var rx = []; for (var i = 0 ; i < fx.length ; i++) { rx.push(_get(fx[i])); } return _.any.apply(null, rx); } else { return _get(fx); } }; var grammarFormats = { timeFormats: function(){ var i, RTokenKeys = [ "h", "hh", "H", "HH", "m", "mm", "s", "ss", "ss.s", "z", "zz" ], RToken = [ /^(0[0-9]|1[0-2]|[1-9])/, /^(0[0-9]|1[0-2])/, /^([0-1][0-9]|2[0-3]|[0-9])/, /^([0-1][0-9]|2[0-3])/, /^([0-5][0-9]|[0-9])/, /^[0-5][0-9]/, /^([0-5][0-9]|[0-9])/, /^[0-5][0-9]/, /^[0-5][0-9]\.[0-9]{1,3}/, /^((\+|\-)\s*\d\d\d\d)|((\+|\-)\d\d\:?\d\d)/, /^((\+|\-)\s*\d\d\d\d)|((\+|\-)\d\d\:?\d\d)/ ], tokens = [ t.hour, t.hour, t.hour, t.hour, t.minute, t.minute, t.second, t.second, t.secondAndMillisecond, t.timezone, t.timezone ]; for (i=0; i < RTokenKeys.length; i++) { cacheProcessRtoken(RTokenKeys[i], RToken[i], tokens[i]); } g.hms = _.cache(_.sequence([g.H, g.m, g.s], g.timePartDelimiter)); g.t = cacheProcessCtoken("shortMeridian", t.meridian); g.tt = cacheProcessCtoken("longMeridian", t.meridian); g.zzz = cacheProcessCtoken("timezone", t.timezone); g.timeSuffix = _.each(_.ignore(g.whiteSpace), _.set([ g.tt, g.zzz ])); g.time = _.each(_.optional(_.ignore(_.stoken("T"))), g.hms, g.timeSuffix); }, dateFormats: function () { // pre-loaded rules for different date part order preferences var _setfn = function () { return _.set(arguments, g.datePartDelimiter); }; var i, RTokenKeys = [ "d", "dd", "M", "MM", "y", "yy", "yyy", "yyyy" ], RToken = [ /^([0-2]\d|3[0-1]|\d)/, /^([0-2]\d|3[0-1])/, /^(1[0-2]|0\d|\d)/, /^(1[0-2]|0\d)/, /^(\d+)/, /^(\d\d)/, /^(\d\d?\d?\d?)/, /^(\d\d\d\d)/ ], tokens = [ t.day, t.day, t.month, t.month, t.year, t.year, t.year, t.year ], eachToken = [ "ordinalSuffix", "ordinalSuffix" ]; for (i=0; i < RTokenKeys.length; i++) { cacheProcessRtoken(RTokenKeys[i], RToken[i], tokens[i], eachToken[i]); } g.MMM = g.MMMM = _.cache(_.process(g.ctoken("jan feb mar apr may jun jul aug sep oct nov dec"), t.month)); g.ddd = g.dddd = _.cache(_.process(g.ctoken("sun mon tue wed thu fri sat"), function (s) { return function () { this.weekday = s; }; } )); g.day = _fn(g.d, g.dd); g.month = _fn(g.M, g.MMM); g.year = _fn(g.yyyy, g.yy); g.mdy = _setfn(g.ddd, g.month, g.day, g.year); g.ymd = _setfn(g.ddd, g.year, g.month, g.day); g.dmy = _setfn(g.ddd, g.day, g.month, g.year); g.date = function (s) { return ((g[Date.CultureInfo.dateElementOrder] || g.mdy).call(this, s)); }; }, relative: function () { // relative date / time expressions g.orientation = _.process(g.ctoken("past future"), function (s) { return function () { this.orient = s; }; } ); g.operator = _.process(g.ctoken("add subtract"), function (s) { return function () { this.operator = s; }; } ); g.rday = _.process(g.ctoken("yesterday tomorrow today now"), t.rday); g.unit = _.process(g.ctoken("second minute hour day week month year"), function (s) { return function () { this.unit = s; }; } ); } }; g.buildGrammarFormats = function () { // these need to be rebuilt every time the language changes. _C = {}; grammarFormats.timeFormats(); grammarFormats.dateFormats(); grammarFormats.relative(); g.value = _.process(_.rtoken(/^([-+]?\d+)?(st|nd|rd|th)?/), function (s) { return function () { this.value = s.replace(/\D/g, ""); }; } ); g.expression = _.set([g.rday, g.operator, g.value, g.unit, g.orientation, g.ddd, g.MMM ]); g.format = _.process(_.many( _.any( // translate format specifiers into grammar rules _.process( _.rtoken(/^(dd?d?d?(?!e)|MM?M?M?|yy?y?y?|hh?|HH?|mm?|ss?|tt?|zz?z?)/), function (fmt) { if (g[fmt]) { return g[fmt]; } else { throw $D.Parsing.Exception(fmt); } } ), // translate separator tokens into token rules _.process(_.rtoken(/^[^dMyhHmstz]+/), // all legal separators function (s) { return _.ignore(_.stoken(s)); } ) ) ), // construct the parser ... function (rules) { return _.process(_.each.apply(null, rules), t.finishExact); } ); // starting rule for general purpose grammar g._start = _.process(_.set([ g.date, g.time, g.expression ], g.generalDelimiter, g.whiteSpace), t.finish); }; g.buildGrammarFormats(); // parsing date format specifiers - ex: "h:m:s tt" // this little guy will generate a custom parser based // on the format string, ex: g.format("h:m:s tt") // check for these formats first g._formats = g.formats([ "\"yyyy-MM-ddTHH:mm:ssZ\"", "yyyy-MM-ddTHH:mm:ss.sz", "yyyy-MM-ddTHH:mm:ssZ", "yyyy-MM-ddTHH:mm:ssz", "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-ddTHH:mmZ", "yyyy-MM-ddTHH:mmz", "yyyy-MM-ddTHH:mm", "ddd, MMM dd, yyyy H:mm:ss tt", "ddd MMM d yyyy HH:mm:ss zzz", "MMddyyyy", "ddMMyyyy", "Mddyyyy", "ddMyyyy", "Mdyyyy", "dMyyyy", "yyyy", "Mdyy", "dMyy", "d" ]); // real starting rule: tries selected formats first, // then general purpose rule g.start = function (s) { try { var r = g._formats.call({}, s); if (r[1].length === 0) { return r; } } catch (e) {} return g._start.call({}, s); }; }()); (function () { var $D = Date; /** * @desc Converts the specified string value into its JavaScript Date equivalent using CultureInfo specific format information. * * Example

	///////////
	// Dates //
	///////////

	// 15-Oct-2004
	var d1 = Date.parse("10/15/2004");

	// 15-Oct-2004
	var d1 = Date.parse("15-Oct-2004");

	// 15-Oct-2004
	var d1 = Date.parse("2004.10.15");

	//Fri Oct 15, 2004
	var d1 = Date.parse("Fri Oct 15, 2004");

	///////////
	// Times //
	///////////

	// Today at 10 PM.
	var d1 = Date.parse("10 PM");

	// Today at 10:30 PM.
	var d1 = Date.parse("10:30 P.M.");

	// Today at 6 AM.
	var d1 = Date.parse("06am");

	/////////////////////
	// Dates and Times //
	/////////////////////

	// 8-July-2004 @ 10:30 PM
	var d1 = Date.parse("July 8th, 2004, 10:30 PM");

	// 1-July-2004 @ 10:30 PM
	var d1 = Date.parse("2004-07-01T22:30:00");

	////////////////////
	// Relative Dates //
	////////////////////

	// Returns today's date. The string "today" is culture specific.
	var d1 = Date.parse("today");

	// Returns yesterday's date. The string "yesterday" is culture specific.
	var d1 = Date.parse("yesterday");

	// Returns the date of the next thursday.
	var d1 = Date.parse("Next thursday");

	// Returns the date of the most previous monday.
	var d1 = Date.parse("last monday");

	// Returns today's day + one year.
	var d1 = Date.parse("next year");

	///////////////
	// Date Math //
	///////////////

	// Today + 2 days
	var d1 = Date.parse("t+2");

	// Today + 2 days
	var d1 = Date.parse("today + 2 days");

	// Today + 3 months
	var d1 = Date.parse("t+3m");

	// Today - 1 year
	var d1 = Date.parse("today - 1 year");

	// Today - 1 year
	var d1 = Date.parse("t-1y"); 


	/////////////////////////////
	// Partial Dates and Times //
	/////////////////////////////

	// July 15th of this year.
	var d1 = Date.parse("July 15");

	// 15th day of current day and year.
	var d1 = Date.parse("15");

	// July 1st of current year at 10pm.
	var d1 = Date.parse("7/1 10pm");
	
* * @param {String} The string value to convert into a Date object [Required] * @return {Date} A Date object or null if the string cannot be converted into a Date. */ var parseUtils = { removeOrds: function (s) { ords = s.match(/\b(\d+)(?:st|nd|rd|th)\b/); // find ordinal matches s = ((ords && ords.length === 2) ? s.replace(ords[0], ords[1]) : s); return s; }, grammarParser: function (s) { var r = null; try { r = $D.Grammar.start.call({}, s.replace(/^\s*(\S*(\s+\S+)*)\s*$/, "$1")); } catch (e) { return null; } return ((r[1].length === 0) ? r[0] : null); }, nativeFallback: function(s) { var t; try { // ok we haven't parsed it, last ditch attempt with the built-in parser. t = Date._parse(s); return (t || t === 0) ? new Date(t) : null; } catch (e) { return null; } } }; function parse (s) { var d; if (!s) { return null; } if (s instanceof Date) { return s.clone(); } if (s.length >= 4 && s.charAt(0) !== "0" && s.charAt(0) !== "+"&& s.charAt(0) !== "-") { // ie: 2004 will pass, 0800 won't. // Start with specific formats d = $D.Parsing.ISO.parse(s) || $D.Parsing.Numeric.parse(s); } if (d instanceof Date && !isNaN(d.getTime())) { return d; } else { // find ordinal dates (1st, 3rd, 8th, etc and remove them as they cause parsing issues) s = $D.Parsing.Normalizer.parse(parseUtils.removeOrds(s)); d = parseUtils.grammarParser(s); if (d !== null) { return d; } else { return parseUtils.nativeFallback(s); } } } if (!$D._parse) { $D._parse = $D.parse; } $D.parse = parse; Date.getParseFunction = function (fx) { var fns = Date.Grammar.allformats(fx); return function (s) { var r = null; for (var i = 0; i < fns.length; i++) { try { r = fns[i].call({}, s); } catch (e) { continue; } if (r[1].length === 0) { return r[0]; } } return null; }; }; /** * Converts the specified string value into its JavaScript Date equivalent using the specified format {String} or formats {Array} and the CultureInfo specific format information. * The format of the string value must match one of the supplied formats exactly. * * Example

	// 15-Oct-2004
	var d1 = Date.parseExact("10/15/2004", "M/d/yyyy");

	// 15-Oct-2004
	var d1 = Date.parse("15-Oct-2004", "M-ddd-yyyy");

	// 15-Oct-2004
	var d1 = Date.parse("2004.10.15", "yyyy.MM.dd");

	// Multiple formats
	var d1 = Date.parseExact("10/15/2004", ["M/d/yyyy", "MMMM d, yyyy"]);
	
* * @param {String} The string value to convert into a Date object [Required]. * @param {Object} The expected format {String} or an array of expected formats {Array} of the date string [Required]. * @return {Date} A Date object or null if the string cannot be converted into a Date. */ $D.parseExact = function (s, fx) { return $D.getParseFunction(fx)(s); }; }()); (function () { var $D = Date, $P = $D.prototype, // $C = $D.CultureInfo, // not used atm p = function (s, l) { if (!l) { l = 2; } return ("000" + s).slice(l * -1); }; /** * Converts a PHP format string to Java/.NET format string. * A PHP format string can be used with ._format or .format. * A Java/.NET format string can be used with .toString(). * The .parseExact function will only accept a Java/.NET format string * * Example * var f1 = "%m/%d/%y" * var f2 = Date.normalizeFormat(f1); // "MM/dd/yy" * * new Date().format(f1); // "04/13/08" * new Date()._format(f1); // "04/13/08" * new Date().toString(f2); // "04/13/08" * * var date = Date.parseExact("04/13/08", f2); // Sun Apr 13 2008 * * @param {String} A PHP format string consisting of one or more format spcifiers. * @return {String} The PHP format converted to a Java/.NET format string. */ var normalizerSubstitutions = { "d" : "dd", "%d": "dd", "D" : "ddd", "%a": "ddd", "j" : "dddd", "l" : "dddd", "%A": "dddd", "S" : "S", "F" : "MMMM", "%B": "MMMM", "m" : "MM", "%m": "MM", "M" : "MMM", "%b": "MMM", "%h": "MMM", "n" : "M", "Y" : "yyyy", "%Y": "yyyy", "y" : "yy", "%y": "yy", "g" : "h", "%I": "h", "G" : "H", "h" : "hh", "H" : "HH", "%H": "HH", "i" : "mm", "%M": "mm", "s" : "ss", "%S": "ss", "%r": "hh:mm tt", "%R": "H:mm", "%T": "H:mm:ss", "%X": "t", "%x": "d", "%e": "d", "%D": "MM/dd/yy", "%n": "\\n", "%t": "\\t", "e" : "z", "T" : "z", "%z": "z", "%Z": "z", "Z" : "ZZ", "N" : "u", "w" : "u", "%w": "u", "W" : "W", "%V": "W" }; var normalizer = { substitutes: function (m) { return normalizerSubstitutions[m]; }, interpreted: function (m, x) { var y; switch (m) { case "%u": return x.getDay() + 1; case "z": return x.getOrdinalNumber(); case "%j": return p(x.getOrdinalNumber(), 3); case "%U": var d1 = x.clone().set({month: 0, day: 1}).addDays(-1).moveToDayOfWeek(0), d2 = x.clone().addDays(1).moveToDayOfWeek(0, -1); return (d2 < d1) ? "00" : p((d2.getOrdinalNumber() - d1.getOrdinalNumber()) / 7 + 1); case "%W": return p(x.getWeek()); case "t": return $D.getDaysInMonth(x.getFullYear(), x.getMonth()); case "o": case "%G": return x.setWeek(x.getISOWeek()).toString("yyyy"); case "%g": return x._format("%G").slice(-2); case "a": case "%p": return t("tt").toLowerCase(); case "A": return t("tt").toUpperCase(); case "u": return p(x.getMilliseconds(), 3); case "I": return (x.isDaylightSavingTime()) ? 1 : 0; case "O": return x.getUTCOffset(); case "P": y = x.getUTCOffset(); return y.substring(0, y.length - 2) + ":" + y.substring(y.length - 2); case "B": var now = new Date(); return Math.floor(((now.getHours() * 3600) + (now.getMinutes() * 60) + now.getSeconds() + (now.getTimezoneOffset() + 60) * 60) / 86.4); case "c": return x.toISOString().replace(/\"/g, ""); case "U": return $D.strtotime("now"); case "%c": return t("d") + " " + t("t"); case "%C": return Math.floor(x.getFullYear() / 100 + 1); } }, shouldOverrideDefaults: function (m) { switch (m) { case "%e": return true; default: return false; } }, parse: function (m, context) { var formatString, c = context || new Date(); formatString = normalizer.substitutes(m); if (formatString) { return formatString; } formatString = normalizer.interpreted(m, c); if (formatString) { return formatString; } else { return m; } } }; $D.normalizeFormat = function (format, context) { return format.replace(/(%|\\)?.|%%/g, function(t){ return normalizer.parse(t, context); }); }; /** * Format a local Unix timestamp according to locale settings * * Example: * Date.strftime("%m/%d/%y", new Date()); // "04/13/08" * Date.strftime("c", "2008-04-13T17:52:03Z"); // "04/13/08" * * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @param {Number|String} The number representing the number of seconds that have elapsed since January 1, 1970 (local time). * @return {String} A string representation of the current Date object. */ $D.strftime = function (format, time) { var d = Date.parse(time); return d._format(format); }; /** * Parse any textual datetime description into a Unix timestamp. * A Unix timestamp is the number of seconds that have elapsed since January 1, 1970 (midnight UTC/GMT). * * Example: * Date.strtotime("04/13/08"); // 1208044800 * Date.strtotime("1970-01-01T00:00:00Z"); // 0 * * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @param {Object} A string or date object. * @return {String} A string representation of the current Date object. */ $D.strtotime = function (time) { var d = $D.parse(time); return Math.round($D.UTC(d.getUTCFullYear(), d.getUTCMonth(), d.getUTCDate(), d.getUTCHours(), d.getUTCMinutes(), d.getUTCSeconds(), d.getUTCMilliseconds()) / 1000); }; /** * Converts the value of the current Date object to its equivalent string representation using a PHP/Unix style of date format specifiers. * Format Specifiers * Format Description Example * ------ --------------------------------------------------------------------------- ----------------------- * %a abbreviated weekday name according to the current localed "Mon" through "Sun" * %A full weekday name according to the current localed "Sunday" through "Saturday" * %b abbreviated month name according to the current localed "Jan" through "Dec" * %B full month name according to the current locale "January" through "December" * %c preferred date and time representation for the current locale "4/13/2008 12:33 PM" * %C century number (the year divided by 100 and truncated to an integer) "00" to "99" * %d day of the month as a decimal number "01" to "31" * %D same as %m/%d/%y "04/13/08" * %e day of the month as a decimal number, a single digit is preceded by a space "1" to "31" * %g like %G, but without the century "08" * %G The 4-digit year corresponding to the ISO week number (see %V). "2008" * This has the same format and value as %Y, except that if the ISO week number * belongs to the previous or next year, that year is used instead. * %h same as %b "Jan" through "Dec" * %H hour as a decimal number using a 24-hour clock. "00" to "23" * %I hour as a decimal number using a 12-hour clock. "01" to "12" * %j day of the year as a decimal number. "001" to "366" * %m month as a decimal number. "01" to "12" * %M minute as a decimal number. "00" to "59" * %n newline character "\n" * %p either "am" or "pm" according to the given time value, or the "am" or "pm" * corresponding strings for the current locale. * %r time in a.m. and p.m. notation "8:44 PM" * %R time in 24 hour notation "20:44" * %S second as a decimal number "00" to "59" * %t tab character "\t" * %T current time, equal to %H:%M:%S "12:49:11" * %u weekday as a decimal number ["1", "7"], with "1" representing Monday "1" to "7" * %U week number of the current year as a decimal number, starting with the "0" to ("52" or "53") * first Sunday as the first day of the first week * %V The ISO 8601:1988 week number of the current year as a decimal number, "00" to ("52" or "53") * range 01 to 53, where week 1 is the first week that has at least 4 days * in the current year, and with Monday as the first day of the week. * (Use %G or %g for the year component that corresponds to the week number * for the specified timestamp.) * %W week number of the current year as a decimal number, starting with the "00" to ("52" or "53") * first Monday as the first day of the first week * %w day of the week as a decimal, Sunday being "0" "0" to "6" * %x preferred date representation for the current locale without the time "4/13/2008" * %X preferred time representation for the current locale without the date "12:53:05" * %y year as a decimal number without a century "00" "99" * %Y year as a decimal number including the century "2008" * %Z time zone or name or abbreviation "UTC", "EST", "PST" * %z same as %Z * %% a literal "%" characters "%" * d Day of the month, 2 digits with leading zeros "01" to "31" * D A textual representation of a day, three letters "Mon" through "Sun" * j Day of the month without leading zeros "1" to "31" * l A full textual representation of the day of the week (lowercase "L") "Sunday" through "Saturday" * N ISO-8601 numeric representation of the day of the week (added in PHP 5.1.0) "1" (for Monday) through "7" (for Sunday) * S English ordinal suffix for the day of the month, 2 characters "st", "nd", "rd" or "th". Works well with j * w Numeric representation of the day of the week "0" (for Sunday) through "6" (for Saturday) * z The day of the year (starting from "0") "0" through "365" * W ISO-8601 week number of year, weeks starting on Monday "00" to ("52" or "53") * F A full textual representation of a month, such as January or March "January" through "December" * m Numeric representation of a month, with leading zeros "01" through "12" * M A short textual representation of a month, three letters "Jan" through "Dec" * n Numeric representation of a month, without leading zeros "1" through "12" * t Number of days in the given month "28" through "31" * L Whether it's a leap year "1" if it is a leap year, "0" otherwise * o ISO-8601 year number. This has the same value as Y, except that if the "2008" * ISO week number (W) belongs to the previous or next year, that year * is used instead. * Y A full numeric representation of a year, 4 digits "2008" * y A two digit representation of a year "08" * a Lowercase Ante meridiem and Post meridiem "am" or "pm" * A Uppercase Ante meridiem and Post meridiem "AM" or "PM" * B Swatch Internet time "000" through "999" * g 12-hour format of an hour without leading zeros "1" through "12" * G 24-hour format of an hour without leading zeros "0" through "23" * h 12-hour format of an hour with leading zeros "01" through "12" * H 24-hour format of an hour with leading zeros "00" through "23" * i Minutes with leading zeros "00" to "59" * s Seconds, with leading zeros "00" through "59" * u Milliseconds "54321" * e Timezone identifier "UTC", "EST", "PST" * I Whether or not the date is in daylight saving time (uppercase i) "1" if Daylight Saving Time, "0" otherwise * O Difference to Greenwich time (GMT) in hours "+0200", "-0600" * P Difference to Greenwich time (GMT) with colon between hours and minutes "+02:00", "-06:00" * T Timezone abbreviation "UTC", "EST", "PST" * Z Timezone offset in seconds. The offset for timezones west of UTC is "-43200" through "50400" * always negative, and for those east of UTC is always positive. * c ISO 8601 date "2004-02-12T15:19:21+00:00" * r RFC 2822 formatted date "Thu, 21 Dec 2000 16:01:07 +0200" * U Seconds since the Unix Epoch (January 1 1970 00:00:00 GMT) "0" * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @return {String} A string representation of the current Date object. */ var formatReplace = function (context) { return function (m) { var formatString, override = false; if (m.charAt(0) === "\\" || m.substring(0, 2) === "%%") { return m.replace("\\", "").replace("%%", "%"); } override = normalizer.shouldOverrideDefaults(m); formatString = $D.normalizeFormat(m, context); if (formatString) { return context.toString(formatString, override); } }; }; $P._format = function (format) { var formatter = formatReplace(this); if (!format) { return this._toString(); } else { return format.replace(/(%|\\)?.|%%/g, formatter); } }; if (!$P.format) { $P.format = $P._format; } }()); (function () { "use strict"; var gFn = function (attr) { return function () { return this[attr]; }; }; var sFn = function (attr) { return function (val) { this[attr] = val; return this; }; }; var attrs = ["years", "months", "days", "hours", "minutes", "seconds", "milliseconds"]; var addSetFuncs = function (context, attrs) { for (var i = 0; i < attrs.length ; i++) { var $a = attrs[i], $b = $a.slice(0, 1).toUpperCase() + $a.slice(1); context.prototype[$a] = 0; context.prototype["get" + $b] = gFn($a); context.prototype["set" + $b] = sFn($a); } }; /** * new TimeSpan(milliseconds); * new TimeSpan(days, hours, minutes, seconds); * new TimeSpan(days, hours, minutes, seconds, milliseconds); */ var TimeSpan = function (days, hours, minutes, seconds, milliseconds) { if (arguments.length === 1 && typeof days === "number") { var orient = (days < 0) ? -1 : +1; var millsLeft = Math.abs(days); this.setDays(Math.floor(millsLeft / 86400000) * orient); millsLeft = millsLeft % 86400000; this.setHours(Math.floor(millsLeft / 3600000) * orient); millsLeft = millsLeft % 3600000; this.setMinutes(Math.floor(millsLeft / 60000) * orient); millsLeft = millsLeft % 60000; this.setSeconds(Math.floor(millsLeft / 1000) * orient); millsLeft = millsLeft % 1000; this.setMilliseconds(millsLeft * orient); } else { this.set(days, hours, minutes, seconds, milliseconds); } this.getTotalMilliseconds = function () { return (this.getDays() * 86400000) + (this.getHours() * 3600000) + (this.getMinutes() * 60000) + (this.getSeconds() * 1000); }; this.compareTo = function (time) { var t1 = new Date(1970, 1, 1, this.getHours(), this.getMinutes(), this.getSeconds()), t2; if (time === null) { t2 = new Date(1970, 1, 1, 0, 0, 0); } else { t2 = new Date(1970, 1, 1, time.getHours(), time.getMinutes(), time.getSeconds()); } return (t1 < t2) ? -1 : (t1 > t2) ? 1 : 0; }; this.equals = function (time) { return (this.compareTo(time) === 0); }; this.add = function (time) { return (time === null) ? this : this.addSeconds(time.getTotalMilliseconds() / 1000); }; this.subtract = function (time) { return (time === null) ? this : this.addSeconds(-time.getTotalMilliseconds() / 1000); }; this.addDays = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 86400000)); }; this.addHours = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 3600000)); }; this.addMinutes = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 60000)); }; this.addSeconds = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 1000)); }; this.addMilliseconds = function (n) { return new TimeSpan(this.getTotalMilliseconds() + n); }; this.get12HourHour = function () { return (this.getHours() > 12) ? this.getHours() - 12 : (this.getHours() === 0) ? 12 : this.getHours(); }; this.getDesignator = function () { return (this.getHours() < 12) ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator; }; this.toString = function (format) { this._toString = function () { if (this.getDays() !== null && this.getDays() > 0) { return this.getDays() + "." + this.getHours() + ":" + this.p(this.getMinutes()) + ":" + this.p(this.getSeconds()); } else { return this.getHours() + ":" + this.p(this.getMinutes()) + ":" + this.p(this.getSeconds()); } }; this.p = function (s) { return (s.toString().length < 2) ? "0" + s : s; }; var me = this; return format ? format.replace(/dd?|HH?|hh?|mm?|ss?|tt?/g, function (format) { switch (format) { case "d": return me.getDays(); case "dd": return me.p(me.getDays()); case "H": return me.getHours(); case "HH": return me.p(me.getHours()); case "h": return me.get12HourHour(); case "hh": return me.p(me.get12HourHour()); case "m": return me.getMinutes(); case "mm": return me.p(me.getMinutes()); case "s": return me.getSeconds(); case "ss": return me.p(me.getSeconds()); case "t": return ((me.getHours() < 12) ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator).substring(0, 1); case "tt": return (me.getHours() < 12) ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator; } } ) : this._toString(); }; return this; }; addSetFuncs(TimeSpan, attrs.slice(2)); TimeSpan.prototype.set = function (days, hours, minutes, seconds, milliseconds){ this.setDays(days || this.getDays()); this.setHours(hours || this.getHours()); this.setMinutes(minutes || this.getMinutes()); this.setSeconds(seconds || this.getSeconds()); this.setMilliseconds(milliseconds || this.getMilliseconds()); }; /** * Gets the time of day for this date instances. * @return {TimeSpan} TimeSpan */ Date.prototype.getTimeOfDay = function () { return new TimeSpan(0, this.getHours(), this.getMinutes(), this.getSeconds(), this.getMilliseconds()); }; Date.TimeSpan = TimeSpan; if (typeof window !== "undefined" ) { // keeping API compatible for v1.x window.TimeSpan = TimeSpan; } }()); (function () { "use strict"; var attrs = ["years", "months", "days", "hours", "minutes", "seconds", "milliseconds"]; var gFn = function (attr) { return function () { return this[attr]; }; }; var sFn = function (attr) { return function (val) { this[attr] = val; return this; }; }; var addSetFuncs = function (context, attrs) { for (var i = 0; i < attrs.length ; i++) { var $a = attrs[i], $b = $a.slice(0, 1).toUpperCase() + $a.slice(1); context.prototype[$a] = 0; context.prototype["get" + $b] = gFn($a); context.prototype["set" + $b] = sFn($a); } }; var setMonthsAndYears = function (orient, d1, d2, context) { function inc() { d1.addMonths(-orient); context.months++; if (context.months === 12) { context.years++; context.months = 0; } } if (orient === +1) { while (d1 > d2) { inc(); } } else { while (d1 < d2) { inc(); } } context.months--; context.months *= orient; context.years *= orient; }; var adjustForDST = function(orient, startDate, endDate) { var hasDSTMismatch = (false === (startDate.isDaylightSavingTime() === endDate.isDaylightSavingTime())); if (hasDSTMismatch && orient === 1) { startDate.addHours(-1); } else if (hasDSTMismatch) { startDate.addHours(1); } }; /** * TimePeriod(startDate, endDate); * TimePeriod(years, months, days, hours, minutes, seconds, milliseconds); */ var TimePeriod = function (years, months, days, hours, minutes, seconds, milliseconds) { if (arguments.length === 7) { this.set(years, months, days, hours, minutes, seconds, milliseconds); } else if (arguments.length === 2 && arguments[0] instanceof Date && arguments[1] instanceof Date) { var startDate = arguments[0].clone(); var endDate = arguments[1].clone(); var orient = (startDate > endDate) ? +1 : -1; this.dates = { start: arguments[0].clone(), end: arguments[1].clone() }; setMonthsAndYears(orient, startDate, endDate, this); adjustForDST(orient, startDate, endDate); // // TODO - adjust for DST var diff = endDate - startDate; if (diff !== 0) { var ts = new TimeSpan(diff); this.set(this.years, this.months, ts.getDays(), ts.getHours(), ts.getMinutes(), ts.getSeconds(), ts.getMilliseconds()); } } return this; }; // create all the set functions. addSetFuncs(TimePeriod, attrs); TimePeriod.prototype.set = function (years, months, days, hours, minutes, seconds, milliseconds){ this.setYears(years || this.getYears()); this.setMonths(months || this.getMonths()); this.setDays(days || this.getDays()); this.setHours(hours || this.getHours()); this.setMinutes(minutes || this.getMinutes()); this.setSeconds(seconds || this.getSeconds()); this.setMilliseconds(milliseconds || this.getMilliseconds()); }; Date.TimePeriod = TimePeriod; if (typeof window !== "undefined") { // keeping API compatible for v1.x window.TimePeriod = TimePeriod; } }()); ================================================ FILE: build/date-dv-MV.js ================================================ /** * @overview datejs * @version 1.0.0-rc3 * @author Gregory Wild-Smith * @copyright 2015 Gregory Wild-Smith * @license MIT * @homepage https://github.com/abritinthebay/datejs */ /* * DateJS Culture String File * Country Code: dv-MV * Name: Divehi (Maldives) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["dv-MV"] = { "name": "dv-MV", "englishName": "Divehi (Maldives)", "nativeName": "ދިވެހިބަސް (ދިވެހި ރާއްޖެ)", "Sunday": "الاحد", "Monday": "الاثنين", "Tuesday": "الثلاثاء", "Wednesday": "الاربعاء", "Thursday": "الخميس", "Friday": "الجمعة", "Saturday": "السبت", "Sun": "الاحد", "Mon": "الاثنين", "Tue": "الثلاثاء", "Wed": "الاربعاء", "Thu": "الخميس", "Fri": "الجمعة", "Sat": "السبت", "Su": "ح", "Mo": "ن", "Tu": "ث", "We": "ر", "Th": "خ", "Fr": "ج", "Sa": "س", "S_Sun_Initial": "ح", "M_Mon_Initial": "ن", "T_Tue_Initial": "ث", "W_Wed_Initial": "ر", "T_Thu_Initial": "خ", "F_Fri_Initial": "ج", "S_Sat_Initial": "س", "January": "محرم", "February": "صفر", "March": "ربيع الأول", "April": "ربيع الثاني", "May": "جمادى الأولى", "June": "جمادى الثانية", "July": "رجب", "August": "شعبان", "September": "رمضان", "October": "شوال", "November": "ذو القعدة", "December": "ذو الحجة", "Jan_Abbr": "محرم", "Feb_Abbr": "صفر", "Mar_Abbr": "ربيع الاول", "Apr_Abbr": "ربيع الثاني", "May_Abbr": "جمادى الاولى", "Jun_Abbr": "جمادى الثانية", "Jul_Abbr": "رجب", "Aug_Abbr": "شعبان", "Sep_Abbr": "رمضان", "Oct_Abbr": "شوال", "Nov_Abbr": "ذو القعدة", "Dec_Abbr": "ذو الحجة", "AM": "މކ", "PM": "މފ", "firstDayOfWeek": 0, "twoDigitYearMax": 1451, "mdy": "dmy", "M/d/yyyy": "dd/MM/yy", "dddd, MMMM dd, yyyy": "dd/MMMM/yyyy", "h:mm tt": "HH:mm", "h:mm:ss tt": "HH:mm:ss", "dddd, MMMM dd, yyyy h:mm:ss tt": "dd/MMMM/yyyy HH:mm:ss", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "dd MMMM", "MMMM, yyyy": "MMMM, yyyy", "/jan(uary)?/": "محرم", "/feb(ruary)?/": "صفر", "/mar(ch)?/": "ربيع الأول", "/apr(il)?/": "ربيع الثاني", "/may/": "جمادى الأولى", "/jun(e)?/": "جمادى الثانية", "/jul(y)?/": "رجب", "/aug(ust)?/": "شعبان", "/sep(t(ember)?)?/": "رمضان", "/oct(ober)?/": "شوال", "/nov(ember)?/": "ذو القعدة", "/dec(ember)?/": "ذو الحجة", "/^su(n(day)?)?/": "^الاحد", "/^mo(n(day)?)?/": "^الاثنين", "/^tu(e(s(day)?)?)?/": "^الثلاثاء", "/^we(d(nesday)?)?/": "^الاربعاء", "/^th(u(r(s(day)?)?)?)?/": "^الخميس", "/^fr(i(day)?)?/": "^الجمعة", "/^sa(t(urday)?)?/": "^السبت", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "dv-MV"; /** * @overview datejs * @version 1.0.0-rc3 * @author Gregory Wild-Smith * @copyright 2015 Gregory Wild-Smith * @license MIT * @homepage https://github.com/abritinthebay/datejs */(function () { var $D = Date; var lang = Date.CultureStrings ? Date.CultureStrings.lang : null; var loggedKeys = {}; // for debug purposes. var getText = { getFromKey: function (key, countryCode) { var output; if (Date.CultureStrings && Date.CultureStrings[countryCode] && Date.CultureStrings[countryCode][key]) { output = Date.CultureStrings[countryCode][key]; } else { output = getText.buildFromDefault(key); } if (key.charAt(0) === "/") { // Assume it's a regex output = getText.buildFromRegex(key, countryCode); } return output; }, getFromObjectValues: function (obj, countryCode) { var key, output = {}; for(key in obj) { if (obj.hasOwnProperty(key)) { output[key] = getText.getFromKey(obj[key], countryCode); } } return output; }, getFromObjectKeys: function (obj, countryCode) { var key, output = {}; for(key in obj) { if (obj.hasOwnProperty(key)) { output[getText.getFromKey(key, countryCode)] = obj[key]; } } return output; }, getFromArray: function (arr, countryCode) { var output = []; for (var i=0; i < arr.length; i++){ if (i in arr) { output[i] = getText.getFromKey(arr[i], countryCode); } } return output; }, buildFromDefault: function (key) { var output, length, split, last; switch(key) { case "name": output = "en-US"; break; case "englishName": output = "English (United States)"; break; case "nativeName": output = "English (United States)"; break; case "twoDigitYearMax": output = 2049; break; case "firstDayOfWeek": output = 0; break; default: output = key; split = key.split("_"); length = split.length; if (length > 1 && key.charAt(0) !== "/") { // if the key isn't a regex and it has a split. last = split[(length - 1)].toLowerCase(); if (last === "initial" || last === "abbr") { output = split[0]; } } break; } return output; }, buildFromRegex: function (key, countryCode) { var output; if (Date.CultureStrings && Date.CultureStrings[countryCode] && Date.CultureStrings[countryCode][key]) { output = new RegExp(Date.CultureStrings[countryCode][key], "i"); } else { output = new RegExp(key.replace(new RegExp("/", "g"),""), "i"); } return output; } }; var shallowMerge = function (obj1, obj2) { for (var attrname in obj2) { if (obj2.hasOwnProperty(attrname)) { obj1[attrname] = obj2[attrname]; } } }; var __ = function (key, language) { var countryCode = (language) ? language : lang; loggedKeys[key] = key; if (typeof key === "object") { if (key instanceof Array) { return getText.getFromArray(key, countryCode); } else { return getText.getFromObjectKeys(key, countryCode); } } else { return getText.getFromKey(key, countryCode); } }; var loadI18nScript = function (code) { // paatterned after jQuery's getScript. var url = Date.Config.i18n + code + ".js"; var head = document.getElementsByTagName("head")[0] || document.documentElement; var script = document.createElement("script"); script.src = url; var completed = false; var events = { done: function (){} // placeholder function }; // Attach handlers for all browsers script.onload = script.onreadystatechange = function() { if ( !completed && (!this.readyState || this.readyState === "loaded" || this.readyState === "complete") ) { events.done(); head.removeChild(script); } }; setTimeout(function() { head.insertBefore(script, head.firstChild); }, 0); // allows return to execute first return { done: function (cb) { events.done = function() { if (cb) { setTimeout(cb,0); } }; } }; }; var buildInfo = { buildFromMethodHash: function (obj) { var key; for(key in obj) { if (obj.hasOwnProperty(key)) { obj[key] = buildInfo[obj[key]](); } } return obj; }, timeZoneDST: function () { var DST = { "CHADT": "+1345", "NZDT": "+1300", "AEDT": "+1100", "ACDT": "+1030", "AZST": "+0500", "IRDT": "+0430", "EEST": "+0300", "CEST": "+0200", "BST": "+0100", "PMDT": "-0200", "ADT": "-0300", "NDT": "-0230", "EDT": "-0400", "CDT": "-0500", "MDT": "-0600", "PDT": "-0700", "AKDT": "-0800", "HADT": "-0900" }; return __(DST); }, timeZoneStandard: function () { var standard = { "LINT": "+1400", "TOT": "+1300", "CHAST": "+1245", "NZST": "+1200", "NFT": "+1130", "SBT": "+1100", "AEST": "+1000", "ACST": "+0930", "JST": "+0900", "CWST": "+0845", "CT": "+0800", "ICT": "+0700", "MMT": "+0630", "BST": "+0600", "NPT": "+0545", "IST": "+0530", "PKT": "+0500", "AFT": "+0430", "MSK": "+0400", "IRST": "+0330", "FET": "+0300", "EET": "+0200", "CET": "+0100", "GMT": "+0000", "UTC": "+0000", "CVT": "-0100", "GST": "-0200", "BRT": "-0300", "NST": "-0330", "AST": "-0400", "EST": "-0500", "CST": "-0600", "MST": "-0700", "PST": "-0800", "AKST": "-0900", "MIT": "-0930", "HST": "-1000", "SST": "-1100", "BIT": "-1200" }; return __(standard); }, timeZones: function (data) { var zone; data.timezones = []; for (zone in data.abbreviatedTimeZoneStandard) { if (data.abbreviatedTimeZoneStandard.hasOwnProperty(zone)) { data.timezones.push({ name: zone, offset: data.abbreviatedTimeZoneStandard[zone]}); } } for (zone in data.abbreviatedTimeZoneDST) { if (data.abbreviatedTimeZoneDST.hasOwnProperty(zone)) { data.timezones.push({ name: zone, offset: data.abbreviatedTimeZoneDST[zone], dst: true}); } } return data.timezones; }, days: function () { return __(["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"]); }, dayAbbr: function () { return __(["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"]); }, dayShortNames: function () { return __(["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"]); }, dayFirstLetters: function () { return __(["S_Sun_Initial", "M_Mon_Initial", "T_Tues_Initial", "W_Wed_Initial", "T_Thu_Initial", "F_Fri_Initial", "S_Sat_Initial"]); }, months: function () { return __(["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"]); }, monthAbbr: function () { return __(["Jan_Abbr", "Feb_Abbr", "Mar_Abbr", "Apr_Abbr", "May_Abbr", "Jun_Abbr", "Jul_Abbr", "Aug_Abbr", "Sep_Abbr", "Oct_Abbr", "Nov_Abbr", "Dec_Abbr"]); }, formatPatterns: function () { return getText.getFromObjectValues({ shortDate: "M/d/yyyy", longDate: "dddd, MMMM dd, yyyy", shortTime: "h:mm tt", longTime: "h:mm:ss tt", fullDateTime: "dddd, MMMM dd, yyyy h:mm:ss tt", sortableDateTime: "yyyy-MM-ddTHH:mm:ss", universalSortableDateTime: "yyyy-MM-dd HH:mm:ssZ", rfc1123: "ddd, dd MMM yyyy HH:mm:ss", monthDay: "MMMM dd", yearMonth: "MMMM, yyyy" }, Date.i18n.currentLanguage()); }, regex: function () { return getText.getFromObjectValues({ inTheMorning: "/( in the )(morn(ing)?)\\b/", thisMorning: "/(this )(morn(ing)?)\\b/", amThisMorning: "/(\b\\d(am)? )(this )(morn(ing)?)/", inTheEvening: "/( in the )(even(ing)?)\\b/", thisEvening: "/(this )(even(ing)?)\\b/", pmThisEvening: "/(\b\\d(pm)? )(this )(even(ing)?)/", jan: "/jan(uary)?/", feb: "/feb(ruary)?/", mar: "/mar(ch)?/", apr: "/apr(il)?/", may: "/may/", jun: "/jun(e)?/", jul: "/jul(y)?/", aug: "/aug(ust)?/", sep: "/sep(t(ember)?)?/", oct: "/oct(ober)?/", nov: "/nov(ember)?/", dec: "/dec(ember)?/", sun: "/^su(n(day)?)?/", mon: "/^mo(n(day)?)?/", tue: "/^tu(e(s(day)?)?)?/", wed: "/^we(d(nesday)?)?/", thu: "/^th(u(r(s(day)?)?)?)?/", fri: "/fr(i(day)?)?/", sat: "/^sa(t(urday)?)?/", future: "/^next/", past: "/^last|past|prev(ious)?/", add: "/^(\\+|aft(er)?|from|hence)/", subtract: "/^(\\-|bef(ore)?|ago)/", yesterday: "/^yes(terday)?/", today: "/^t(od(ay)?)?/", tomorrow: "/^tom(orrow)?/", now: "/^n(ow)?/", millisecond: "/^ms|milli(second)?s?/", second: "/^sec(ond)?s?/", minute: "/^mn|min(ute)?s?/", hour: "/^h(our)?s?/", week: "/^w(eek)?s?/", month: "/^m(onth)?s?/", day: "/^d(ay)?s?/", year: "/^y(ear)?s?/", shortMeridian: "/^(a|p)/", longMeridian: "/^(a\\.?m?\\.?|p\\.?m?\\.?)/", timezone: "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/", ordinalSuffix: "/^\\s*(st|nd|rd|th)/", timeContext: "/^\\s*(\\:|a(?!u|p)|p)/" }, Date.i18n.currentLanguage()); } }; var CultureInfo = function () { var info = getText.getFromObjectValues({ name: "name", englishName: "englishName", nativeName: "nativeName", amDesignator: "AM", pmDesignator: "PM", firstDayOfWeek: "firstDayOfWeek", twoDigitYearMax: "twoDigitYearMax", dateElementOrder: "mdy" }, Date.i18n.currentLanguage()); var constructedInfo = buildInfo.buildFromMethodHash({ dayNames: "days", abbreviatedDayNames: "dayAbbr", shortestDayNames: "dayShortNames", firstLetterDayNames: "dayFirstLetters", monthNames: "months", abbreviatedMonthNames: "monthAbbr", formatPatterns: "formatPatterns", regexPatterns: "regex", abbreviatedTimeZoneDST: "timeZoneDST", abbreviatedTimeZoneStandard: "timeZoneStandard" }); shallowMerge(info, constructedInfo); buildInfo.timeZones(info); return info; }; $D.i18n = { __: function (key, lang) { return __(key, lang); }, currentLanguage: function () { return lang || "en-US"; }, setLanguage: function (code, force, cb) { var async = false; if (force || code === "en-US" || (!!Date.CultureStrings && !!Date.CultureStrings[code])) { lang = code; Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings.lang = code; Date.CultureInfo = new CultureInfo(); } else { if (!(!!Date.CultureStrings && !!Date.CultureStrings[code])) { if (typeof exports !== "undefined" && this.exports !== exports) { // we're in a Node enviroment, load it using require try { require("../i18n/" + code + ".js"); lang = code; Date.CultureStrings.lang = code; Date.CultureInfo = new CultureInfo(); } catch (e) { // var str = "The language for '" + code + "' could not be loaded by Node. It likely does not exist."; throw new Error("The DateJS IETF language tag '" + code + "' could not be loaded by Node. It likely does not exist."); } } else if (Date.Config && Date.Config.i18n) { // we know the location of the files, so lets load them async = true; loadI18nScript(code).done(function(){ lang = code; Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings.lang = code; Date.CultureInfo = new CultureInfo(); $D.Parsing.Normalizer.buildReplaceData(); // because this is async if ($D.Grammar) { $D.Grammar.buildGrammarFormats(); // so we can parse those strings... } if (cb) { setTimeout(cb,0); } }); } else { Date.console.error("The DateJS IETF language tag '" + code + "' is not available and has not been loaded."); return false; } } } $D.Parsing.Normalizer.buildReplaceData(); // rebuild normalizer strings if ($D.Grammar) { $D.Grammar.buildGrammarFormats(); // so we can parse those strings... } if (!async && cb) { setTimeout(cb,0); } }, getLoggedKeys: function () { return loggedKeys; }, updateCultureInfo: function () { Date.CultureInfo = new CultureInfo(); } }; $D.i18n.updateCultureInfo(); // run automatically }()); (function () { var $D = Date, $P = $D.prototype, p = function (s, l) { if (!l) { l = 2; } return ("000" + s).slice(l * -1); }; if (typeof window !== "undefined" && typeof window.console !== "undefined" && typeof window.console.log !== "undefined") { $D.console = console; // used only to raise non-critical errors if available } else { // set mock so we don't give errors. $D.console = { log: function(){}, error: function(){} }; } $D.Config = $D.Config || {}; $D.initOverloads = function() { /** * Overload of Date.now. Allows an alternate call for Date.now where it returns the * current Date as an object rather than just milliseconds since the Unix Epoch. * * Also provides an implementation of now() for browsers (IE<9) that don't have it. * * Backwards compatible so with work with either: * Date.now() [returns ms] * or * Date.now(true) [returns Date] */ if (!$D.now) { $D._now = function now() { return new Date().getTime(); }; } else if (!$D._now) { $D._now = $D.now; } $D.now = function (returnObj) { if (returnObj) { return $D.present(); } else { return $D._now(); } }; if ( !$P.toISOString ) { $P.toISOString = function() { return this.getUTCFullYear() + "-" + p(this.getUTCMonth() + 1) + "-" + p(this.getUTCDate()) + "T" + p(this.getUTCHours()) + ":" + p(this.getUTCMinutes()) + ":" + p(this.getUTCSeconds()) + "." + String( (this.getUTCMilliseconds()/1000).toFixed(3)).slice(2, 5) + "Z"; }; } // private if ( $P._toString === undefined ){ $P._toString = $P.toString; } }; $D.initOverloads(); /** * Gets a date that is set to the current date. The time is set to the start of the day (00:00 or 12:00 AM). * @return {Date} The current date. */ $D.today = function () { return new Date().clearTime(); }; /** * Gets a date that is set to the current date and time (same as new Date, but chainable) * @return {Date} The current date. */ $D.present = function () { return new Date(); }; /** * Compares the first date to the second date and returns an number indication of their relative values. * @param {Date} First Date object to compare [Required]. * @param {Date} Second Date object to compare to [Required]. * @return {Number} -1 = date1 is lessthan date2. 0 = values are equal. 1 = date1 is greaterthan date2. */ $D.compare = function (date1, date2) { if (isNaN(date1) || isNaN(date2)) { throw new Error(date1 + " - " + date2); } else if (date1 instanceof Date && date2 instanceof Date) { return (date1 < date2) ? -1 : (date1 > date2) ? 1 : 0; } else { throw new TypeError(date1 + " - " + date2); } }; /** * Compares the first Date object to the second Date object and returns true if they are equal. * @param {Date} First Date object to compare [Required] * @param {Date} Second Date object to compare to [Required] * @return {Boolean} true if dates are equal. false if they are not equal. */ $D.equals = function (date1, date2) { return (date1.compareTo(date2) === 0); }; /** * Gets the language appropriate day name when given the day number(0-6) * eg - 0 == Sunday * @return {String} The day name */ $D.getDayName = function (n) { return Date.CultureInfo.dayNames[n]; }; /** * Gets the day number (0-6) if given a CultureInfo specific string which is a valid dayName, abbreviatedDayName or shortestDayName (two char). * @param {String} The name of the day (eg. "Monday, "Mon", "tuesday", "tue", "We", "we"). * @return {Number} The day number */ $D.getDayNumberFromName = function (name) { var n = Date.CultureInfo.dayNames, m = Date.CultureInfo.abbreviatedDayNames, o = Date.CultureInfo.shortestDayNames, s = name.toLowerCase(); for (var i = 0; i < n.length; i++) { if (n[i].toLowerCase() === s || m[i].toLowerCase() === s || o[i].toLowerCase() === s) { return i; } } return -1; }; /** * Gets the month number (0-11) if given a Culture Info specific string which is a valid monthName or abbreviatedMonthName. * @param {String} The name of the month (eg. "February, "Feb", "october", "oct"). * @return {Number} The day number */ $D.getMonthNumberFromName = function (name) { var n = Date.CultureInfo.monthNames, m = Date.CultureInfo.abbreviatedMonthNames, s = name.toLowerCase(); for (var i = 0; i < n.length; i++) { if (n[i].toLowerCase() === s || m[i].toLowerCase() === s) { return i; } } return -1; }; /** * Gets the language appropriate month name when given the month number(0-11) * eg - 0 == January * @return {String} The month name */ $D.getMonthName = function (n) { return Date.CultureInfo.monthNames[n]; }; /** * Determines if the current date instance is within a LeapYear. * @param {Number} The year. * @return {Boolean} true if date is within a LeapYear, otherwise false. */ $D.isLeapYear = function (year) { return ((year % 4 === 0 && year % 100 !== 0) || year % 400 === 0); }; /** * Gets the number of days in the month, given a year and month value. Automatically corrects for LeapYear. * @param {Number} The year. * @param {Number} The month (0-11). * @return {Number} The number of days in the month. */ $D.getDaysInMonth = function (year, month) { if (!month && $D.validateMonth(year)) { month = year; year = Date.today().getFullYear(); } return [31, ($D.isLeapYear(year) ? 29 : 28), 31, 30, 31, 30, 31, 31, 30, 31, 30, 31][month]; }; $P.getDaysInMonth = function () { return $D.getDaysInMonth(this.getFullYear(), this.getMonth()); }; $D.getTimezoneAbbreviation = function (offset, dst) { var p, n = (dst || false) ? Date.CultureInfo.abbreviatedTimeZoneDST : Date.CultureInfo.abbreviatedTimeZoneStandard; for (p in n) { if (n.hasOwnProperty(p)) { if (n[p] === offset) { return p; } } } return null; }; $D.getTimezoneOffset = function (name, dst) { var i, a =[], z = Date.CultureInfo.timezones; if (!name) { name = (new Date()).getTimezone();} for (i = 0; i < z.length; i++) { if (z[i].name === name.toUpperCase()) { a.push(i); } } if (!z[a[0]]) { return null; } if (a.length === 1 || !dst) { return z[a[0]].offset; } else { for (i=0; i < a.length; i++) { if (z[a[i]].dst) { return z[a[i]].offset; } } } }; $D.getQuarter = function (d) { d = d || new Date(); // If no date supplied, use today var q = [1,2,3,4]; return q[Math.floor(d.getMonth() / 3)]; // ~~~ is a bitwise op. Faster than Math.floor }; $D.getDaysLeftInQuarter = function (d) { d = d || new Date(); var qEnd = new Date(d); qEnd.setMonth(qEnd.getMonth() + 3 - qEnd.getMonth() % 3, 0); return Math.floor((qEnd - d) / 8.64e7); }; // private var validate = function (n, min, max, name) { name = name ? name : "Object"; if (typeof n === "undefined") { return false; } else if (typeof n !== "number") { throw new TypeError(n + " is not a Number."); } else if (n < min || n > max) { // As failing validation is *not* an exceptional circumstance // lets not throw a RangeError Exception here. // It's semantically correct but it's not sensible. return false; } return true; }; /** * Validates the number is within an acceptable range for milliseconds [0-999]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateMillisecond = function (value) { return validate(value, 0, 999, "millisecond"); }; /** * Validates the number is within an acceptable range for seconds [0-59]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateSecond = function (value) { return validate(value, 0, 59, "second"); }; /** * Validates the number is within an acceptable range for minutes [0-59]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateMinute = function (value) { return validate(value, 0, 59, "minute"); }; /** * Validates the number is within an acceptable range for hours [0-23]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateHour = function (value) { return validate(value, 0, 23, "hour"); }; /** * Validates the number is within an acceptable range for the days in a month [0-MaxDaysInMonth]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateDay = function (value, year, month) { if (year === undefined || year === null || month === undefined || month === null) { return false;} return validate(value, 1, $D.getDaysInMonth(year, month), "day"); }; /** * Validates the number is within an acceptable range for months [0-11]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateWeek = function (value) { return validate(value, 0, 53, "week"); }; /** * Validates the number is within an acceptable range for months [0-11]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateMonth = function (value) { return validate(value, 0, 11, "month"); }; /** * Validates the number is within an acceptable range for years. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateYear = function (value) { /** * Per ECMAScript spec the range of times supported by Date objects is * exactly -100,000,000 days to +100,000,000 days measured relative to * midnight at the beginning of 01 January, 1970 UTC. * This gives a range of 8,640,000,000,000,000 milliseconds to either * side of 01 January, 1970 UTC. * * Earliest possible date: Tue, 20 Apr 271,822 B.C. 00:00:00 UTC * Latest possible date: Sat, 13 Sep 275,760 00:00:00 UTC */ return validate(value, -271822, 275760, "year"); }; $D.validateTimezone = function(value) { var timezones = {"ACDT":1,"ACST":1,"ACT":1,"ADT":1,"AEDT":1,"AEST":1,"AFT":1,"AKDT":1,"AKST":1,"AMST":1,"AMT":1,"ART":1,"AST":1,"AWDT":1,"AWST":1,"AZOST":1,"AZT":1,"BDT":1,"BIOT":1,"BIT":1,"BOT":1,"BRT":1,"BST":1,"BTT":1,"CAT":1,"CCT":1,"CDT":1,"CEDT":1,"CEST":1,"CET":1,"CHADT":1,"CHAST":1,"CHOT":1,"ChST":1,"CHUT":1,"CIST":1,"CIT":1,"CKT":1,"CLST":1,"CLT":1,"COST":1,"COT":1,"CST":1,"CT":1,"CVT":1,"CWST":1,"CXT":1,"DAVT":1,"DDUT":1,"DFT":1,"EASST":1,"EAST":1,"EAT":1,"ECT":1,"EDT":1,"EEDT":1,"EEST":1,"EET":1,"EGST":1,"EGT":1,"EIT":1,"EST":1,"FET":1,"FJT":1,"FKST":1,"FKT":1,"FNT":1,"GALT":1,"GAMT":1,"GET":1,"GFT":1,"GILT":1,"GIT":1,"GMT":1,"GST":1,"GYT":1,"HADT":1,"HAEC":1,"HAST":1,"HKT":1,"HMT":1,"HOVT":1,"HST":1,"ICT":1,"IDT":1,"IOT":1,"IRDT":1,"IRKT":1,"IRST":1,"IST":1,"JST":1,"KGT":1,"KOST":1,"KRAT":1,"KST":1,"LHST":1,"LINT":1,"MAGT":1,"MART":1,"MAWT":1,"MDT":1,"MET":1,"MEST":1,"MHT":1,"MIST":1,"MIT":1,"MMT":1,"MSK":1,"MST":1,"MUT":1,"MVT":1,"MYT":1,"NCT":1,"NDT":1,"NFT":1,"NPT":1,"NST":1,"NT":1,"NUT":1,"NZDT":1,"NZST":1,"OMST":1,"ORAT":1,"PDT":1,"PET":1,"PETT":1,"PGT":1,"PHOT":1,"PHT":1,"PKT":1,"PMDT":1,"PMST":1,"PONT":1,"PST":1,"PYST":1,"PYT":1,"RET":1,"ROTT":1,"SAKT":1,"SAMT":1,"SAST":1,"SBT":1,"SCT":1,"SGT":1,"SLST":1,"SRT":1,"SST":1,"SYOT":1,"TAHT":1,"THA":1,"TFT":1,"TJT":1,"TKT":1,"TLT":1,"TMT":1,"TOT":1,"TVT":1,"UCT":1,"ULAT":1,"UTC":1,"UYST":1,"UYT":1,"UZT":1,"VET":1,"VLAT":1,"VOLT":1,"VOST":1,"VUT":1,"WAKT":1,"WAST":1,"WAT":1,"WEDT":1,"WEST":1,"WET":1,"WST":1,"YAKT":1,"YEKT":1,"Z":1}; return (timezones[value] === 1); }; $D.validateTimezoneOffset= function(value) { // timezones go from +14hrs to -12hrs, the +X hours are negative offsets. return (value > -841 && value < 721); }; }()); (function () { var $D = Date, $P = $D.prototype, p = function (s, l) { if (!l) { l = 2; } return ("000" + s).slice(l * -1); }; var validateConfigObject = function (obj) { var result = {}, self = this, prop, testFunc; testFunc = function (prop, func, value) { if (prop === "day") { var month = (obj.month !== undefined) ? obj.month : self.getMonth(); var year = (obj.year !== undefined) ? obj.year : self.getFullYear(); return $D[func](value, year, month); } else { return $D[func](value); } }; for (prop in obj) { if (Object.prototype.hasOwnProperty.call(obj, prop)) { var func = "validate" + prop.charAt(0).toUpperCase() + prop.slice(1); if ($D[func] && obj[prop] !== null && testFunc(prop, func, obj[prop])) { result[prop] = obj[prop]; } } } return result; }; /** * Resets the time of this Date object to 12:00 AM (00:00), which is the start of the day. * @param {Boolean} .clone() this date instance before clearing Time * @return {Date} this */ $P.clearTime = function () { this.setHours(0); this.setMinutes(0); this.setSeconds(0); this.setMilliseconds(0); return this; }; /** * Resets the time of this Date object to the current time ('now'). * @return {Date} this */ $P.setTimeToNow = function () { var n = new Date(); this.setHours(n.getHours()); this.setMinutes(n.getMinutes()); this.setSeconds(n.getSeconds()); this.setMilliseconds(n.getMilliseconds()); return this; }; /** * Returns a new Date object that is an exact date and time copy of the original instance. * @return {Date} A new Date instance */ $P.clone = function () { return new Date(this.getTime()); }; /** * Compares this instance to a Date object and returns an number indication of their relative values. * @param {Date} Date object to compare [Required] * @return {Number} -1 = this is lessthan date. 0 = values are equal. 1 = this is greaterthan date. */ $P.compareTo = function (date) { return Date.compare(this, date); }; /** * Compares this instance to another Date object and returns true if they are equal. * @param {Date} Date object to compare. If no date to compare, new Date() [now] is used. * @return {Boolean} true if dates are equal. false if they are not equal. */ $P.equals = function (date) { return Date.equals(this, (date !== undefined ? date : new Date())); }; /** * Determines if this instance is between a range of two dates or equal to either the start or end dates. * @param {Date} Start of range [Required] * @param {Date} End of range [Required] * @return {Boolean} true is this is between or equal to the start and end dates, else false */ $P.between = function (start, end) { return this.getTime() >= start.getTime() && this.getTime() <= end.getTime(); }; /** * Determines if this date occurs after the date to compare to. * @param {Date} Date object to compare. If no date to compare, new Date() ("now") is used. * @return {Boolean} true if this date instance is greater than the date to compare to (or "now"), otherwise false. */ $P.isAfter = function (date) { return this.compareTo(date || new Date()) === 1; }; /** * Determines if this date occurs before the date to compare to. * @param {Date} Date object to compare. If no date to compare, new Date() ("now") is used. * @return {Boolean} true if this date instance is less than the date to compare to (or "now"). */ $P.isBefore = function (date) { return (this.compareTo(date || new Date()) === -1); }; /** * Determines if the current Date instance occurs today. * @return {Boolean} true if this date instance is 'today', otherwise false. */ /** * Determines if the current Date instance occurs on the same Date as the supplied 'date'. * If no 'date' to compare to is provided, the current Date instance is compared to 'today'. * @param {date} Date object to compare. If no date to compare, the current Date ("now") is used. * @return {Boolean} true if this Date instance occurs on the same Day as the supplied 'date'. */ $P.isToday = $P.isSameDay = function (date) { return this.clone().clearTime().equals((date || new Date()).clone().clearTime()); }; /** * Adds the specified number of milliseconds to this instance. * @param {Number} The number of milliseconds to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addMilliseconds = function (value) { if (!value) { return this; } this.setTime(this.getTime() + value * 1); return this; }; /** * Adds the specified number of seconds to this instance. * @param {Number} The number of seconds to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addSeconds = function (value) { if (!value) { return this; } return this.addMilliseconds(value * 1000); }; /** * Adds the specified number of seconds to this instance. * @param {Number} The number of seconds to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addMinutes = function (value) { if (!value) { return this; } return this.addMilliseconds(value * 60000); // 60*1000 }; /** * Adds the specified number of hours to this instance. * @param {Number} The number of hours to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addHours = function (value) { if (!value) { return this; } return this.addMilliseconds(value * 3600000); // 60*60*1000 }; /** * Adds the specified number of days to this instance. * @param {Number} The number of days to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addDays = function (value) { if (!value) { return this; } this.setDate(this.getDate() + value * 1); return this; }; /** * Adds the specified number of weekdays (ie - not sat or sun) to this instance. * @param {Number} The number of days to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addWeekdays = function (value) { if (!value) { return this; } var day = this.getDay(); var weeks = (Math.ceil(Math.abs(value)/7)); if (day === 0 || day === 6) { if (value > 0) { this.next().monday(); this.addDays(-1); day = this.getDay(); } } if (value < 0) { while (value < 0) { this.addDays(-1); day = this.getDay(); if (day !== 0 && day !== 6) { value++; } } return this; } else if (value > 5 || (6-day) <= value) { value = value + (weeks * 2); } return this.addDays(value); }; /** * Adds the specified number of weeks to this instance. * @param {Number} The number of weeks to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addWeeks = function (value) { if (!value) { return this; } return this.addDays(value * 7); }; /** * Adds the specified number of months to this instance. * @param {Number} The number of months to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addMonths = function (value) { if (!value) { return this; } var n = this.getDate(); this.setDate(1); this.setMonth(this.getMonth() + value * 1); this.setDate(Math.min(n, $D.getDaysInMonth(this.getFullYear(), this.getMonth()))); return this; }; $P.addQuarters = function (value) { if (!value) { return this; } // note this will take you to the same point in the quarter as you are now. // i.e. - if you are 15 days into the quarter you'll be 15 days into the resulting one. // bonus: this allows adding fractional quarters return this.addMonths(value * 3); }; /** * Adds the specified number of years to this instance. * @param {Number} The number of years to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addYears = function (value) { if (!value) { return this; } return this.addMonths(value * 12); }; /** * Adds (or subtracts) to the value of the years, months, weeks, days, hours, minutes, seconds, milliseconds of the date instance using given configuration object. Positive and Negative values allowed. * Example

	Date.today().add( { days: 1, months: 1 } )

	new Date().add( { years: -1 } )
	
* @param {Object} Configuration object containing attributes (months, days, etc.) * @return {Date} this */ $P.add = function (config) { if (typeof config === "number") { this._orient = config; return this; } var x = config; if (x.day) { // If we should be a different date than today (eg: for 'tomorrow -1d', etc). // Should only effect parsing, not direct usage (eg, Finish and FinishExact) if ((x.day - this.getDate()) !== 0) { this.setDate(x.day); } } if (x.milliseconds) { this.addMilliseconds(x.milliseconds); } if (x.seconds) { this.addSeconds(x.seconds); } if (x.minutes) { this.addMinutes(x.minutes); } if (x.hours) { this.addHours(x.hours); } if (x.weeks) { this.addWeeks(x.weeks); } if (x.months) { this.addMonths(x.months); } if (x.years) { this.addYears(x.years); } if (x.days) { this.addDays(x.days); } return this; }; /** * Get the week number. Week one (1) is the week which contains the first Thursday of the year. Monday is considered the first day of the week. * The .getWeek() function does NOT convert the date to UTC. The local datetime is used. * Please use .getISOWeek() to get the week of the UTC converted date. * @return {Number} 1 to 53 */ $P.getWeek = function (utc) { // Create a copy of this date object var self, target = new Date(this.valueOf()); if (utc) { target.addMinutes(target.getTimezoneOffset()); self = target.clone(); } else { self = this; } // ISO week date weeks start on monday // so correct the day number var dayNr = (self.getDay() + 6) % 7; // ISO 8601 states that week 1 is the week // with the first thursday of that year. // Set the target date to the thursday in the target week target.setDate(target.getDate() - dayNr + 3); // Store the millisecond value of the target date var firstThursday = target.valueOf(); // Set the target to the first thursday of the year // First set the target to january first target.setMonth(0, 1); // Not a thursday? Correct the date to the next thursday if (target.getDay() !== 4) { target.setMonth(0, 1 + ((4 - target.getDay()) + 7) % 7); } // The weeknumber is the number of weeks between the // first thursday of the year and the thursday in the target week return 1 + Math.ceil((firstThursday - target) / 604800000); // 604800000 = 7 * 24 * 3600 * 1000 }; /** * Get the ISO 8601 week number. Week one ("01") is the week which contains the first Thursday of the year. Monday is considered the first day of the week. * The .getISOWeek() function does convert the date to it's UTC value. Please use .getWeek() to get the week of the local date. * @return {String} "01" to "53" */ $P.getISOWeek = function () { return p(this.getWeek(true)); }; /** * Moves the date to Monday of the week set. Week one (1) is the week which contains the first Thursday of the year. * @param {Number} A Number (1 to 53) that represents the week of the year. * @return {Date} this */ $P.setWeek = function (n) { if ((n - this.getWeek()) === 0) { if (this.getDay() !== 1) { return this.moveToDayOfWeek(1, (this.getDay() > 1 ? -1 : 1)); } else { return this; } } else { return this.moveToDayOfWeek(1, (this.getDay() > 1 ? -1 : 1)).addWeeks(n - this.getWeek()); } }; $P.setQuarter = function (qtr) { var month = Math.abs(((qtr-1) * 3) + 1); return this.setMonth(month, 1); }; $P.getQuarter = function () { return Date.getQuarter(this); }; $P.getDaysLeftInQuarter = function () { return Date.getDaysLeftInQuarter(this); }; /** * Moves the date to the next n'th occurrence of the dayOfWeek starting from the beginning of the month. The number (-1) is a magic number and will return the last occurrence of the dayOfWeek in the month. * @param {Number} The dayOfWeek to move to * @param {Number} The n'th occurrence to move to. Use (-1) to return the last occurrence in the month * @return {Date} this */ $P.moveToNthOccurrence = function (dayOfWeek, occurrence) { if (dayOfWeek === "Weekday") { if (occurrence > 0) { this.moveToFirstDayOfMonth(); if (this.is().weekday()) { occurrence -= 1; } } else if (occurrence < 0) { this.moveToLastDayOfMonth(); if (this.is().weekday()) { occurrence += 1; } } else { return this; } return this.addWeekdays(occurrence); } var shift = 0; if (occurrence > 0) { shift = occurrence - 1; } else if (occurrence === -1) { this.moveToLastDayOfMonth(); if (this.getDay() !== dayOfWeek) { this.moveToDayOfWeek(dayOfWeek, -1); } return this; } return this.moveToFirstDayOfMonth().addDays(-1).moveToDayOfWeek(dayOfWeek, +1).addWeeks(shift); }; var moveToN = function (getFunc, addFunc, nVal) { return function (value, orient) { var diff = (value - this[getFunc]() + nVal * (orient || +1)) % nVal; return this[addFunc]((diff === 0) ? diff += nVal * (orient || +1) : diff); }; }; /** * Move to the next or last dayOfWeek based on the orient value. * @param {Number} The dayOfWeek to move to * @param {Number} Forward (+1) or Back (-1). Defaults to +1. [Optional] * @return {Date} this */ $P.moveToDayOfWeek = moveToN("getDay", "addDays", 7); /** * Move to the next or last month based on the orient value. * @param {Number} The month to move to. 0 = January, 11 = December * @param {Number} Forward (+1) or Back (-1). Defaults to +1. [Optional] * @return {Date} this */ $P.moveToMonth = moveToN("getMonth", "addMonths", 12); /** * Get the Ordinate of the current day ("th", "st", "rd"). * @return {String} */ $P.getOrdinate = function () { var num = this.getDate(); return ord(num); }; /** * Get the Ordinal day (numeric day number) of the year, adjusted for leap year. * @return {Number} 1 through 365 (366 in leap years) */ $P.getOrdinalNumber = function () { return Math.ceil((this.clone().clearTime() - new Date(this.getFullYear(), 0, 1)) / 86400000) + 1; }; /** * Get the time zone abbreviation of the current date. * @return {String} The abbreviated time zone name (e.g. "EST") */ $P.getTimezone = function () { return $D.getTimezoneAbbreviation(this.getUTCOffset(), this.isDaylightSavingTime()); }; $P.setTimezoneOffset = function (offset) { var here = this.getTimezoneOffset(), there = Number(offset) * -6 / 10; return (there || there === 0) ? this.addMinutes(there - here) : this; }; $P.setTimezone = function (offset) { return this.setTimezoneOffset($D.getTimezoneOffset(offset)); }; /** * Indicates whether Daylight Saving Time is observed in the current time zone. * @return {Boolean} true|false */ $P.hasDaylightSavingTime = function () { return (Date.today().set({month: 0, day: 1}).getTimezoneOffset() !== Date.today().set({month: 6, day: 1}).getTimezoneOffset()); }; /** * Indicates whether this Date instance is within the Daylight Saving Time range for the current time zone. * @return {Boolean} true|false */ $P.isDaylightSavingTime = function () { return Date.today().set({month: 0, day: 1}).getTimezoneOffset() !== this.getTimezoneOffset(); }; /** * Get the offset from UTC of the current date. * @return {String} The 4-character offset string prefixed with + or - (e.g. "-0500") */ $P.getUTCOffset = function (offset) { var n = (offset || this.getTimezoneOffset()) * -10 / 6, r; if (n < 0) { r = (n - 10000).toString(); return r.charAt(0) + r.substr(2); } else { r = (n + 10000).toString(); return "+" + r.substr(1); } }; /** * Returns the number of milliseconds between this date and date. * @param {Date} Defaults to now * @return {Number} The diff in milliseconds */ $P.getElapsed = function (date) { return (date || new Date()) - this; }; /** * Set the value of year, month, day, hour, minute, second, millisecond of date instance using given configuration object. * Example

	Date.today().set( { day: 20, month: 1 } )

	new Date().set( { millisecond: 0 } )
	
* * @param {Object} Configuration object containing attributes (month, day, etc.) * @return {Date} this */ $P.set = function (config) { config = validateConfigObject.call(this, config); var key; for (key in config) { if (Object.prototype.hasOwnProperty.call(config, key)) { var name = key.charAt(0).toUpperCase() + key.slice(1); var addFunc, getFunc; if (key !== "week" && key !== "month" && key !== "timezone" && key !== "timezoneOffset") { name += "s"; } addFunc = "add" + name; getFunc = "get" + name; if (key === "month") { addFunc = addFunc + "s"; } else if (key === "year"){ getFunc = "getFullYear"; } if (key !== "day" && key !== "timezone" && key !== "timezoneOffset" && key !== "week" && key !== "hour") { this[addFunc](config[key] - this[getFunc]()); } else if ( key === "timezone"|| key === "timezoneOffset" || key === "week" || key === "hour") { this["set"+name](config[key]); } } } // day has to go last because you can't validate the day without first knowing the month if (config.day) { this.addDays(config.day - this.getDate()); } return this; }; /** * Moves the date to the first day of the month. * @return {Date} this */ $P.moveToFirstDayOfMonth = function () { return this.set({ day: 1 }); }; /** * Moves the date to the last day of the month. * @return {Date} this */ $P.moveToLastDayOfMonth = function () { return this.set({ day: $D.getDaysInMonth(this.getFullYear(), this.getMonth())}); }; /** * Converts the value of the current Date object to its equivalent string representation. * Format Specifiers * CUSTOM DATE AND TIME FORMAT STRINGS * Format Description Example * ------ --------------------------------------------------------------------------- ----------------------- * s The seconds of the minute between 0-59. "0" to "59" * ss The seconds of the minute with leading zero if required. "00" to "59" * * m The minute of the hour between 0-59. "0" or "59" * mm The minute of the hour with leading zero if required. "00" or "59" * * h The hour of the day between 1-12. "1" to "12" * hh The hour of the day with leading zero if required. "01" to "12" * * H The hour of the day between 0-23. "0" to "23" * HH The hour of the day with leading zero if required. "00" to "23" * * d The day of the month between 1 and 31. "1" to "31" * dd The day of the month with leading zero if required. "01" to "31" * ddd Abbreviated day name. Date.CultureInfo.abbreviatedDayNames. "Mon" to "Sun" * dddd The full day name. Date.CultureInfo.dayNames. "Monday" to "Sunday" * * M The month of the year between 1-12. "1" to "12" * MM The month of the year with leading zero if required. "01" to "12" * MMM Abbreviated month name. Date.CultureInfo.abbreviatedMonthNames. "Jan" to "Dec" * MMMM The full month name. Date.CultureInfo.monthNames. "January" to "December" * * yy The year as a two-digit number. "99" or "08" * yyyy The full four digit year. "1999" or "2008" * * t Displays the first character of the A.M./P.M. designator. "A" or "P" * Date.CultureInfo.amDesignator or Date.CultureInfo.pmDesignator * tt Displays the A.M./P.M. designator. "AM" or "PM" * Date.CultureInfo.amDesignator or Date.CultureInfo.pmDesignator * * S The ordinal suffix ("st, "nd", "rd" or "th") of the current day. "st, "nd", "rd" or "th" * * STANDARD DATE AND TIME FORMAT STRINGS * Format Description Example *------ --------------------------------------------------------------------------- ----------------------- * d The CultureInfo shortDate Format Pattern "M/d/yyyy" * D The CultureInfo longDate Format Pattern "dddd, MMMM dd, yyyy" * F The CultureInfo fullDateTime Format Pattern "dddd, MMMM dd, yyyy h:mm:ss tt" * m The CultureInfo monthDay Format Pattern "MMMM dd" * r The CultureInfo rfc1123 Format Pattern "ddd, dd MMM yyyy HH:mm:ss GMT" * s The CultureInfo sortableDateTime Format Pattern "yyyy-MM-ddTHH:mm:ss" * t The CultureInfo shortTime Format Pattern "h:mm tt" * T The CultureInfo longTime Format Pattern "h:mm:ss tt" * u The CultureInfo universalSortableDateTime Format Pattern "yyyy-MM-dd HH:mm:ssZ" * y The CultureInfo yearMonth Format Pattern "MMMM, yyyy" * * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @return {String} A string representation of the current Date object. */ var ord = function (n) { switch (n * 1) { case 1: case 21: case 31: return "st"; case 2: case 22: return "nd"; case 3: case 23: return "rd"; default: return "th"; } }; var parseStandardFormats = function (format) { var y, c = Date.CultureInfo.formatPatterns; switch (format) { case "d": return this.toString(c.shortDate); case "D": return this.toString(c.longDate); case "F": return this.toString(c.fullDateTime); case "m": return this.toString(c.monthDay); case "r": case "R": y = this.clone().addMinutes(this.getTimezoneOffset()); return y.toString(c.rfc1123) + " GMT"; case "s": return this.toString(c.sortableDateTime); case "t": return this.toString(c.shortTime); case "T": return this.toString(c.longTime); case "u": y = this.clone().addMinutes(this.getTimezoneOffset()); return y.toString(c.universalSortableDateTime); case "y": return this.toString(c.yearMonth); default: return false; } }; var parseFormatStringsClosure = function (context) { return function (m) { if (m.charAt(0) === "\\") { return m.replace("\\", ""); } switch (m) { case "hh": return p(context.getHours() < 13 ? (context.getHours() === 0 ? 12 : context.getHours()) : (context.getHours() - 12)); case "h": return context.getHours() < 13 ? (context.getHours() === 0 ? 12 : context.getHours()) : (context.getHours() - 12); case "HH": return p(context.getHours()); case "H": return context.getHours(); case "mm": return p(context.getMinutes()); case "m": return context.getMinutes(); case "ss": return p(context.getSeconds()); case "s": return context.getSeconds(); case "yyyy": return p(context.getFullYear(), 4); case "yy": return p(context.getFullYear()); case "y": return context.getFullYear(); case "E": case "dddd": return Date.CultureInfo.dayNames[context.getDay()]; case "ddd": return Date.CultureInfo.abbreviatedDayNames[context.getDay()]; case "dd": return p(context.getDate()); case "d": return context.getDate(); case "MMMM": return Date.CultureInfo.monthNames[context.getMonth()]; case "MMM": return Date.CultureInfo.abbreviatedMonthNames[context.getMonth()]; case "MM": return p((context.getMonth() + 1)); case "M": return context.getMonth() + 1; case "t": return context.getHours() < 12 ? Date.CultureInfo.amDesignator.substring(0, 1) : Date.CultureInfo.pmDesignator.substring(0, 1); case "tt": return context.getHours() < 12 ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator; case "S": return ord(context.getDate()); case "W": return context.getWeek(); case "WW": return context.getISOWeek(); case "Q": return "Q" + context.getQuarter(); case "q": return String(context.getQuarter()); case "z": return context.getTimezone(); case "Z": case "X": return Date.getTimezoneOffset(context.getTimezone()); case "ZZ": // Timezone offset in seconds return context.getTimezoneOffset() * -60; case "u": return context.getDay(); case "L": return ($D.isLeapYear(context.getFullYear())) ? 1 : 0; case "B": // Swatch Internet Time (.beats) return "@"+((context.getUTCSeconds() + (context.getUTCMinutes()*60) + ((context.getUTCHours()+1)*3600))/86.4); default: return m; } }; }; $P.toString = function (format, ignoreStandards) { // Standard Date and Time Format Strings. Formats pulled from CultureInfo file and // may vary by culture. if (!ignoreStandards && format && format.length === 1) { output = parseStandardFormats.call(this, format); if (output) { return output; } } var parseFormatStrings = parseFormatStringsClosure(this); return format ? format.replace(/((\\)?(dd?d?d?|MM?M?M?|yy?y?y?|hh?|HH?|mm?|ss?|tt?|S|q|Q|WW?W?W?)(?![^\[]*\]))/g, parseFormatStrings).replace(/\[|\]/g, "") : this._toString(); }; }()); /************************************************************* * SugarPak - Domain Specific Language - Syntactical Sugar * *************************************************************/ (function () { var $D = Date, $P = $D.prototype, $N = Number.prototype; // private $P._orient = +1; // private $P._nth = null; // private $P._is = false; // private $P._same = false; // private $P._isSecond = false; // private $N._dateElement = "days"; /** * Moves the date to the next instance of a date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.today().next().friday();
	Date.today().next().fri();
	Date.today().next().march();
	Date.today().next().mar();
	Date.today().next().week();
	
* * @return {Date} date */ $P.next = function () { this._move = true; this._orient = +1; return this; }; /** * Creates a new Date (Date.today()) and moves the date to the next instance of the date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.next().friday();
	Date.next().fri();
	Date.next().march();
	Date.next().mar();
	Date.next().week();
	
* * @return {Date} date */ $D.next = function () { return $D.today().next(); }; /** * Moves the date to the previous instance of a date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.today().last().friday();
	Date.today().last().fri();
	Date.today().last().march();
	Date.today().last().mar();
	Date.today().last().week();
	
* * @return {Date} date */ $P.last = $P.prev = $P.previous = function () { this._move = true; this._orient = -1; return this; }; /** * Creates a new Date (Date.today()) and moves the date to the previous instance of the date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.last().friday();
	Date.last().fri();
	Date.previous().march();
	Date.prev().mar();
	Date.last().week();
	
* * @return {Date} date */ $D.last = $D.prev = $D.previous = function () { return $D.today().last(); }; /** * Performs a equality check when followed by either a month name, day name or .weekday() function. * Example

	Date.today().is().friday(); // true|false
	Date.today().is().fri();
	Date.today().is().march();
	Date.today().is().mar();
	
* * @return {Boolean} true|false */ $P.is = function () { this._is = true; return this; }; /** * Determines if two date objects occur on/in exactly the same instance of the subsequent date part function. * The function .same() must be followed by a date part function (example: .day(), .month(), .year(), etc). * * An optional Date can be passed in the date part function. If now date is passed as a parameter, 'Now' is used. * * The following example demonstrates how to determine if two dates fall on the exact same day. * * Example

	var d1 = Date.today(); // today at 00:00
	var d2 = new Date();   // exactly now.

	// Do they occur on the same day?
	d1.same().day(d2); // true
	
	// Do they occur on the same hour?
	d1.same().hour(d2); // false, unless d2 hour is '00' (midnight).
	
	// What if it's the same day, but one year apart?
	var nextYear = Date.today().add(1).year();

	d1.same().day(nextYear); // false, because the dates must occur on the exact same day. 
	
* * Scenario: Determine if a given date occurs during some week period 2 months from now. * * Example

	var future = Date.today().add(2).months();
	return someDate.same().week(future); // true|false;
	
* * @return {Boolean} true|false */ $P.same = function () { this._same = true; this._isSecond = false; return this; }; /** * Determines if the current date/time occurs during Today. Must be preceded by the .is() function. * Example

	someDate.is().today();    // true|false
	new Date().is().today();  // true
	Date.today().is().today();// true
	Date.today().add(-1).day().is().today(); // false
	
* * @return {Boolean} true|false */ $P.today = function () { return this.same().day(); }; /** * Determines if the current date is a weekday. This function must be preceded by the .is() function. * Example

	Date.today().is().weekday(); // true|false
	
* * @return {Boolean} true|false */ $P.weekday = function () { if (this._nth) { return df("Weekday").call(this); } if (this._move) { return this.addWeekdays(this._orient); } if (this._is) { this._is = false; return (!this.is().sat() && !this.is().sun()); } return false; }; /** * Determines if the current date is on the weekend. This function must be preceded by the .is() function. * Example

	Date.today().is().weekend(); // true|false
	
* * @return {Boolean} true|false */ $P.weekend = function () { if (this._is) { this._is = false; return (this.is().sat() || this.is().sun()); } return false; }; /** * Sets the Time of the current Date instance. A string "6:15 pm" or config object {hour:18, minute:15} are accepted. * Example

	// Set time to 6:15pm with a String
	Date.today().at("6:15pm");

	// Set time to 6:15pm with a config object
	Date.today().at({hour:18, minute:15});
	
* * @return {Date} date */ $P.at = function (time) { return (typeof time === "string") ? $D.parse(this.toString("d") + " " + time) : this.set(time); }; /** * Creates a new Date() and adds this (Number) to the date based on the preceding date element function (eg. second|minute|hour|day|month|year). * Example

	// Undeclared Numbers must be wrapped with parentheses. Requirment of JavaScript.
	(3).days().fromNow();
	(6).months().fromNow();

	// Declared Number variables do not require parentheses. 
	var n = 6;
	n.months().fromNow();
	
* * @return {Date} A new Date instance */ $N.fromNow = $N.after = function (date) { var c = {}; c[this._dateElement] = this; return ((!date) ? new Date() : date.clone()).add(c); }; /** * Creates a new Date() and subtract this (Number) from the date based on the preceding date element function (eg. second|minute|hour|day|month|year). * Example

	// Undeclared Numbers must be wrapped with parentheses. Requirment of JavaScript.
	(3).days().ago();
	(6).months().ago();

	// Declared Number variables do not require parentheses. 
	var n = 6;
	n.months().ago();
	
* * @return {Date} A new Date instance */ $N.ago = $N.before = function (date) { var c = {}, s = (this._dateElement[this._dateElement.length-1] !== "s") ? this._dateElement + "s" : this._dateElement; c[s] = this * -1; return ((!date) ? new Date() : date.clone()).add(c); }; // Do NOT modify the following string tokens. These tokens are used to build dynamic functions. // All culture-specific strings can be found in the CultureInfo files. var dx = ("sunday monday tuesday wednesday thursday friday saturday").split(/\s/), mx = ("january february march april may june july august september october november december").split(/\s/), px = ("Millisecond Second Minute Hour Day Week Month Year Quarter Weekday").split(/\s/), pxf = ("Milliseconds Seconds Minutes Hours Date Week Month FullYear Quarter").split(/\s/), nth = ("final first second third fourth fifth").split(/\s/), de; /** * Returns an object literal of all the date parts. * Example

	var o = new Date().toObject();
	
	// { year: 2008, month: 4, week: 20, day: 13, hour: 18, minute: 9, second: 32, millisecond: 812 }
	
	// The object properties can be referenced directly from the object.
	
	alert(o.day);  // alerts "13"
	alert(o.year); // alerts "2008"
	
* * @return {Date} An object literal representing the original date object. */ $P.toObject = function () { var o = {}; for (var i = 0; i < px.length; i++) { if (this["get" + pxf[i]]) { o[px[i].toLowerCase()] = this["get" + pxf[i]](); } } return o; }; /** * Returns a date created from an object literal. Ignores the .week property if set in the config. * Example

	var o = new Date().toObject();
	
	return Date.fromObject(o); // will return the same date. 

	var o2 = {month: 1, day: 20, hour: 18}; // birthday party!
	Date.fromObject(o2);
	
* * @return {Date} An object literal representing the original date object. */ $D.fromObject = function(config) { config.week = null; return Date.today().set(config); }; // Create day name functions and abbreviated day name functions (eg. monday(), friday(), fri()). var df = function (n) { return function () { if (this._is) { this._is = false; return this.getDay() === n; } if (this._move) { this._move = null; } if (this._nth !== null) { // If the .second() function was called earlier, remove the _orient // from the date, and then continue. // This is required because 'second' can be used in two different context. // // Example // // Date.today().add(1).second(); // Date.march().second().monday(); // // Things get crazy with the following... // Date.march().add(1).second().second().monday(); // but it works!! // if (this._isSecond) { this.addSeconds(this._orient * -1); } // make sure we reset _isSecond this._isSecond = false; var ntemp = this._nth; this._nth = null; var temp = this.clone().moveToLastDayOfMonth(); this.moveToNthOccurrence(n, ntemp); if (this > temp) { throw new RangeError($D.getDayName(n) + " does not occur " + ntemp + " times in the month of " + $D.getMonthName(temp.getMonth()) + " " + temp.getFullYear() + "."); } return this; } return this.moveToDayOfWeek(n, this._orient); }; }; var sdf = function (n) { return function () { var t = $D.today(), shift = n - t.getDay(); if (n === 0 && Date.CultureInfo.firstDayOfWeek === 1 && t.getDay() !== 0) { shift = shift + 7; } return t.addDays(shift); }; }; // Create month name functions and abbreviated month name functions (eg. january(), march(), mar()). var month_instance_functions = function (n) { return function () { if (this._is) { this._is = false; return this.getMonth() === n; } return this.moveToMonth(n, this._orient); }; }; var month_static_functions = function (n) { return function () { return $D.today().set({ month: n, day: 1 }); }; }; var processTerms = function (names, staticFunc, instanceFunc) { for (var i = 0; i < names.length; i++) { // Create constant static Name variables. $D[names[i].toUpperCase()] = $D[names[i].toUpperCase().substring(0, 3)] = i; // Create Name functions. $D[names[i]] = $D[names[i].substring(0, 3)] = staticFunc(i); // Create Name instance functions. $P[names[i]] = $P[names[i].substring(0, 3)] = instanceFunc(i); } }; processTerms(dx, sdf, df); processTerms(mx, month_static_functions, month_instance_functions); // Create date element functions and plural date element functions used with Date (eg. day(), days(), months()). var ef = function (j) { return function () { // if the .second() function was called earlier, the _orient // has alread been added. Just return this and reset _isSecond. if (this._isSecond) { this._isSecond = false; return this; } if (this._same) { this._same = this._is = false; var o1 = this.toObject(), o2 = (arguments[0] || new Date()).toObject(), v = "", k = j.toLowerCase(); // the substr trick with -1 doesn't work in IE8 or less k = (k[k.length-1] === "s") ? k.substring(0,k.length-1) : k; for (var m = (px.length - 1); m > -1; m--) { v = px[m].toLowerCase(); if (o1[v] !== o2[v]) { return false; } if (k === v) { break; } } return true; } if (j.substring(j.length - 1) !== "s") { j += "s"; } if (this._move) { this._move = null; } return this["add" + j](this._orient); }; }; var nf = function (n) { return function () { this._dateElement = n; return this; }; }; for (var k = 0; k < px.length; k++) { de = px[k].toLowerCase(); if(de !== "weekday") { // Create date element functions and plural date element functions used with Date (eg. day(), days(), months()). $P[de] = $P[de + "s"] = ef(px[k]); // Create date element functions and plural date element functions used with Number (eg. day(), days(), months()). $N[de] = $N[de + "s"] = nf(de + "s"); } } $P._ss = ef("Second"); var nthfn = function (n) { return function (dayOfWeek) { if (this._same) { return this._ss(arguments[0]); } if (dayOfWeek || dayOfWeek === 0) { return this.moveToNthOccurrence(dayOfWeek, n); } this._nth = n; // if the operator is 'second' add the _orient, then deal with it later... if (n === 2 && (dayOfWeek === undefined || dayOfWeek === null)) { this._isSecond = true; return this.addSeconds(this._orient); } return this; }; }; for (var l = 0; l < nth.length; l++) { $P[nth[l]] = (l === 0) ? nthfn(-1) : nthfn(l); } }()); (function () { "use strict"; Date.Parsing = { Exception: function (s) { this.message = "Parse error at '" + s.substring(0, 10) + " ...'"; } }; var $P = Date.Parsing; var dayOffsets = { standard: [0,31,59,90,120,151,181,212,243,273,304,334], leap: [0,31,60,91,121,152,182,213,244,274,305,335] }; $P.isLeapYear = function(year) { return ((year % 4 === 0) && (year % 100 !== 0)) || (year % 400 === 0); }; var utils = { multiReplace : function (str, hash ) { var key; for (key in hash) { if (Object.prototype.hasOwnProperty.call(hash, key)) { var regex; if (typeof hash[key] === "function") { } else { regex = (hash[key] instanceof RegExp) ? hash[key] : new RegExp(hash[key], "g"); } str = str.replace(regex, key); } } return str; }, getDayOfYearFromWeek : function (obj) { var d, jan4, offset; obj.weekDay = (!obj.weekDay && obj.weekDay !== 0) ? 1 : obj.weekDay; d = new Date(obj.year, 0, 4); jan4 = d.getDay() === 0 ? 7 : d.getDay(); // JS is 0 indexed on Sunday. offset = jan4+3; obj.dayOfYear = ((obj.week * 7) + (obj.weekDay === 0 ? 7 : obj.weekDay))-offset; return obj; }, getDayOfYear : function (obj, dayOffset) { if (!obj.dayOfYear) { obj = utils.getDayOfYearFromWeek(obj); } for (var i=0;i <= dayOffset.length;i++) { if (obj.dayOfYear < dayOffset[i] || i === dayOffset.length) { obj.day = obj.day ? obj.day : (obj.dayOfYear - dayOffset[i-1]); break; } else { obj.month = i; } } return obj; }, adjustForTimeZone : function (obj, date) { var offset; if (obj.zone.toUpperCase() === "Z" || (obj.zone_hours === 0 && obj.zone_minutes === 0)) { // it's UTC/GML so work out the current timeszone offset offset = -date.getTimezoneOffset(); } else { offset = (obj.zone_hours*60) + (obj.zone_minutes || 0); if (obj.zone_sign === "+") { offset *= -1; } offset -= date.getTimezoneOffset(); } date.setMinutes(date.getMinutes()+offset); return date; }, setDefaults : function (obj) { obj.year = obj.year || Date.today().getFullYear(); obj.hours = obj.hours || 0; obj.minutes = obj.minutes || 0; obj.seconds = obj.seconds || 0; obj.milliseconds = obj.milliseconds || 0; if (!(!obj.month && (obj.week || obj.dayOfYear))) { // if we have a month, or if we don't but don't have the day calculation data obj.month = obj.month || 0; obj.day = obj.day || 1; } return obj; }, dataNum: function (data, mod, explict, postProcess) { var dataNum = data*1; if (mod) { if (postProcess) { return data ? mod(data)*1 : data; } else { return data ? mod(dataNum) : data; } } else if (!explict){ return data ? dataNum : data; } else { return (data && typeof data !== "undefined") ? dataNum : data; } }, timeDataProcess: function (obj) { var timeObj = {}; for (var x in obj.data) { if (obj.data.hasOwnProperty(x)) { timeObj[x] = obj.ignore[x] ? obj.data[x] : utils.dataNum(obj.data[x], obj.mods[x], obj.explict[x], obj.postProcess[x]); } } if (obj.data.secmins) { obj.data.secmins = obj.data.secmins.replace(",", ".") * 60; if (!timeObj.minutes) { timeObj.minutes = obj.data.secmins; } else if (!timeObj.seconds) { timeObj.seconds = obj.data.secmins; } delete obj.secmins; } return timeObj; }, buildTimeObjectFromData: function (data) { var time = utils.timeDataProcess({ data: { year : data[1], month : data[5], day : data[7], week : data[8], dayOfYear : data[10], hours : data[15], zone_hours : data[23], zone_minutes : data[24], zone : data[21], zone_sign : data[22], weekDay : data[9], minutes: data[16], seconds: data[19], milliseconds: data[20], secmins: data[18] }, mods: { month: function(data) { return data-1; }, weekDay: function (data) { data = Math.abs(data); return (data === 7 ? 0 : data); }, minutes: function (data) { return data.replace(":",""); }, seconds: function (data) { return Math.floor( (data.replace(":","").replace(",","."))*1 ); }, milliseconds: function (data) { return (data.replace(",",".")*1000); } }, postProcess: { minutes: true, seconds: true, milliseconds: true }, explict: { zone_hours: true, zone_minutes: true }, ignore: { zone: true, zone_sign: true, secmins: true } }); return time; }, addToHash: function (hash, keys, data) { keys = keys; data = data; var len = keys.length; for (var i = 0; i < len; i++) { hash[keys[i]] = data[i]; } return hash; }, combineRegex: function (r1, r2) { return new RegExp("(("+r1.source+")\\s("+r2.source+"))"); }, getDateNthString: function(add, last, inc){ if (add) { return Date.today().addDays(inc).toString("d"); } else if (last) { return Date.today().last()[inc]().toString("d"); } }, buildRegexData: function (array) { var arr = []; var len = array.length; for (var i=0; i < len; i++) { if (Object.prototype.toString.call(array[i]) === '[object Array]') { // oldIE compat version of Array.isArray arr.push(this.combineRegex(array[i][0], array[i][1])); } else { arr.push(array[i]); } } return arr; } }; $P.processTimeObject = function (obj) { var date, dayOffset; utils.setDefaults(obj); dayOffset = ($P.isLeapYear(obj.year)) ? dayOffsets.leap : dayOffsets.standard; if (!obj.month && (obj.week || obj.dayOfYear)) { utils.getDayOfYear(obj, dayOffset); } else { obj.dayOfYear = dayOffset[obj.month] + obj.day; } date = new Date(obj.year, obj.month, obj.day, obj.hours, obj.minutes, obj.seconds, obj.milliseconds); if (obj.zone) { utils.adjustForTimeZone(obj, date); // adjust (and calculate) for timezone } return date; }; $P.ISO = { regex : /^([\+-]?\d{4}(?!\d{2}\b))((-?)((0[1-9]|1[0-2])(\3([12]\d|0[1-9]|3[01]))?|W([0-4]\d|5[0-3])(-?[1-7])?|(00[1-9]|0[1-9]\d|[12]\d{2}|3([0-5]\d|6[1-6])))([T\s]((([01]\d|2[0-4])((:?)[0-5]\d)?|24\:?00)([\.,]\d+(?!:))?)?(\17[0-5]\d([\.,]\d+)?)?\s?([zZ]|([\+-])([01]\d|2[0-3]):?([0-5]\d)?)?)?)?$/, parse : function (s) { var time, data = s.match(this.regex); if (!data || !data.length) { return null; } time = utils.buildTimeObjectFromData(data); if (!time.year || (!time.year && (!time.month && !time.day) && (!time.week && !time.dayOfYear)) ) { return null; } return $P.processTimeObject(time); } }; $P.Numeric = { isNumeric: function (e){return!isNaN(parseFloat(e))&&isFinite(e);}, regex: /\b([0-1]?[0-9])([0-3]?[0-9])([0-2]?[0-9]?[0-9][0-9])\b/i, parse: function (s) { var data, i, time = {}, order = Date.CultureInfo.dateElementOrder.split(""); if (!(this.isNumeric(s)) || // if it's non-numeric OR (s[0] === "+" && s[0] === "-")) { // It's an arithmatic string (eg +/-1000) return null; } if (s.length < 5 && s.indexOf(".") < 0 && s.indexOf("/") < 0) { // assume it's just a year. time.year = s; return $P.processTimeObject(time); } data = s.match(this.regex); if (!data || !data.length) { return null; } for (i=0; i < order.length; i++) { switch(order[i]) { case "d": time.day = data[i+1]; break; case "m": time.month = (data[i+1]-1); break; case "y": time.year = data[i+1]; break; } } return $P.processTimeObject(time); } }; $P.Normalizer = { regexData: function () { var $R = Date.CultureInfo.regexPatterns; return utils.buildRegexData([ $R.tomorrow, $R.yesterday, [$R.past, $R.mon], [$R.past, $R.tue], [$R.past, $R.wed], [$R.past, $R.thu], [$R.past, $R.fri], [$R.past, $R.sat], [$R.past, $R.sun] ]); }, basicReplaceHash : function() { var $R = Date.CultureInfo.regexPatterns; return { "January": $R.jan.source, "February": $R.feb, "March": $R.mar, "April": $R.apr, "May": $R.may, "June": $R.jun, "July": $R.jul, "August": $R.aug, "September": $R.sep, "October": $R.oct, "November": $R.nov, "December": $R.dec, "": /\bat\b/gi, " ": /\s{2,}/, "am": $R.inTheMorning, "9am": $R.thisMorning, "pm": $R.inTheEvening, "7pm":$R.thisEvening }; }, keys : function(){ return [ utils.getDateNthString(true, false, 1), // tomorrow utils.getDateNthString(true, false, -1), // yesterday utils.getDateNthString(false, true, "monday"), //last mon utils.getDateNthString(false, true, "tuesday"), //last tues utils.getDateNthString(false, true, "wednesday"), //last wed utils.getDateNthString(false, true, "thursday"), //last thurs utils.getDateNthString(false, true, "friday"), //last fri utils.getDateNthString(false, true, "saturday"), //last sat utils.getDateNthString(false, true, "sunday") //last sun ]; }, buildRegexFunctions: function () { var $R = Date.CultureInfo.regexPatterns; var __ = Date.i18n.__; var tomorrowRE = new RegExp("(\\b\\d\\d?("+__("AM")+"|"+__("PM")+")? )("+$R.tomorrow.source.slice(1)+")", "i"); // adapted tomorrow regex for AM PM relative dates var todayRE = new RegExp($R.today.source + "(?!\\s*([+-]))\\b"); // today, but excludes the math operators (eg "today + 2h") this.replaceFuncs = [ [todayRE, function (full) { return (full.length > 1) ? Date.today().toString("d") : full; }], [tomorrowRE, function(full, m1) { var t = Date.today().addDays(1).toString("d"); return (t + " " + m1); }], [$R.amThisMorning, function(str, am){return am;}], [$R.pmThisEvening, function(str, pm){return pm;}] ]; }, buildReplaceData: function () { this.buildRegexFunctions(); this.replaceHash = utils.addToHash(this.basicReplaceHash(), this.keys(), this.regexData()); }, stringReplaceFuncs: function (s) { for (var i=0; i < this.replaceFuncs.length; i++) { s = s.replace(this.replaceFuncs[i][0], this.replaceFuncs[i][1]); } return s; }, parse: function (s) { s = this.stringReplaceFuncs(s); s = utils.multiReplace(s, this.replaceHash); try { var n = s.split(/([\s\-\.\,\/\x27]+)/); if (n.length === 3 && $P.Numeric.isNumeric(n[0]) && $P.Numeric.isNumeric(n[2]) && (n[2].length >= 4)) { // ok, so we're dealing with x/year. But that's not a full date. // This fixes wonky dateElementOrder parsing when set to dmy order. if (Date.CultureInfo.dateElementOrder[0] === "d") { s = "1/" + n[0] + "/" + n[2]; // set to 1st of month and normalize the seperator } } } catch (e) {} return s; } }; $P.Normalizer.buildReplaceData(); }()); (function () { var $P = Date.Parsing; var _ = $P.Operators = { // // Tokenizers // rtoken: function (r) { // regex token return function (s) { var mx = s.match(r); if (mx) { return ([ mx[0], s.substring(mx[0].length) ]); } else { throw new $P.Exception(s); } }; }, token: function () { // whitespace-eating token return function (s) { return _.rtoken(new RegExp("^\\s*" + s + "\\s*"))(s); }; }, stoken: function (s) { // string token return _.rtoken(new RegExp("^" + s)); }, // Atomic Operators until: function (p) { return function (s) { var qx = [], rx = null; while (s.length) { try { rx = p.call(this, s); } catch (e) { qx.push(rx[0]); s = rx[1]; continue; } break; } return [ qx, s ]; }; }, many: function (p) { return function (s) { var rx = [], r = null; while (s.length) { try { r = p.call(this, s); } catch (e) { return [ rx, s ]; } rx.push(r[0]); s = r[1]; } return [ rx, s ]; }; }, // generator operators -- see below optional: function (p) { return function (s) { var r = null; try { r = p.call(this, s); } catch (e) { return [ null, s ]; } return [ r[0], r[1] ]; }; }, not: function (p) { return function (s) { try { p.call(this, s); } catch (e) { return [null, s]; } throw new $P.Exception(s); }; }, ignore: function (p) { return p ? function (s) { var r = null; r = p.call(this, s); return [null, r[1]]; } : null; }, product: function () { var px = arguments[0], qx = Array.prototype.slice.call(arguments, 1), rx = []; for (var i = 0 ; i < px.length ; i++) { rx.push(_.each(px[i], qx)); } return rx; }, cache: function (rule) { var cache = {}, cache_length = 0, cache_keys = [], CACHE_MAX = Date.Config.CACHE_MAX || 100000, r = null; var cacheCheck = function () { if (cache_length === CACHE_MAX) { // kill several keys, don't want to have to do this all the time... for (var i=0; i < 10; i++) { var key = cache_keys.shift(); if (key) { delete cache[key]; cache_length--; } } } }; return function (s) { cacheCheck(); try { r = cache[s] = (cache[s] || rule.call(this, s)); } catch (e) { r = cache[s] = e; } cache_length++; cache_keys.push(s); if (r instanceof $P.Exception) { throw r; } else { return r; } }; }, // vector operators -- see below any: function () { var px = arguments; return function (s) { var r = null; for (var i = 0; i < px.length; i++) { if (px[i] == null) { continue; } try { r = (px[i].call(this, s)); } catch (e) { r = null; } if (r) { return r; } } throw new $P.Exception(s); }; }, each: function () { var px = arguments; return function (s) { var rx = [], r = null; for (var i = 0; i < px.length ; i++) { if (px[i] == null) { continue; } try { r = (px[i].call(this, s)); } catch (e) { throw new $P.Exception(s); } rx.push(r[0]); s = r[1]; } return [ rx, s]; }; }, all: function () { var px = arguments, _ = _; return _.each(_.optional(px)); }, // delimited operators sequence: function (px, d, c) { d = d || _.rtoken(/^\s*/); c = c || null; if (px.length === 1) { return px[0]; } return function (s) { var r = null, q = null; var rx = []; for (var i = 0; i < px.length ; i++) { try { r = px[i].call(this, s); } catch (e) { break; } rx.push(r[0]); try { q = d.call(this, r[1]); } catch (ex) { q = null; break; } s = q[1]; } if (!r) { throw new $P.Exception(s); } if (q) { throw new $P.Exception(q[1]); } if (c) { try { r = c.call(this, r[1]); } catch (ey) { throw new $P.Exception(r[1]); } } return [ rx, (r?r[1]:s) ]; }; }, // // Composite Operators // between: function (d1, p, d2) { d2 = d2 || d1; var _fn = _.each(_.ignore(d1), p, _.ignore(d2)); return function (s) { var rx = _fn.call(this, s); return [[rx[0][0], r[0][2]], rx[1]]; }; }, list: function (p, d, c) { d = d || _.rtoken(/^\s*/); c = c || null; return (p instanceof Array ? _.each(_.product(p.slice(0, -1), _.ignore(d)), p.slice(-1), _.ignore(c)) : _.each(_.many(_.each(p, _.ignore(d))), px, _.ignore(c))); }, set: function (px, d, c) { d = d || _.rtoken(/^\s*/); c = c || null; return function (s) { // r is the current match, best the current 'best' match // which means it parsed the most amount of input var r = null, p = null, q = null, rx = null, best = [[], s], last = false; // go through the rules in the given set for (var i = 0; i < px.length ; i++) { // last is a flag indicating whether this must be the last element // if there is only 1 element, then it MUST be the last one q = null; p = null; r = null; last = (px.length === 1); // first, we try simply to match the current pattern // if not, try the next pattern try { r = px[i].call(this, s); } catch (e) { continue; } // since we are matching against a set of elements, the first // thing to do is to add r[0] to matched elements rx = [[r[0]], r[1]]; // if we matched and there is still input to parse and // we don't already know this is the last element, // we're going to next check for the delimiter ... // if there's none, or if there's no input left to parse // than this must be the last element after all ... if (r[1].length > 0 && ! last) { try { q = d.call(this, r[1]); } catch (ex) { last = true; } } else { last = true; } // if we parsed the delimiter and now there's no more input, // that means we shouldn't have parsed the delimiter at all // so don't update r and mark this as the last element ... if (!last && q[1].length === 0) { last = true; } // so, if this isn't the last element, we're going to see if // we can get any more matches from the remaining (unmatched) // elements ... if (!last) { // build a list of the remaining rules we can match against, // i.e., all but the one we just matched against var qx = []; for (var j = 0; j < px.length ; j++) { if (i !== j) { qx.push(px[j]); } } // now invoke recursively set with the remaining input // note that we don't include the closing delimiter ... // we'll check for that ourselves at the end p = _.set(qx, d).call(this, q[1]); // if we got a non-empty set as a result ... // (otw rx already contains everything we want to match) if (p[0].length > 0) { // update current result, which is stored in rx ... // basically, pick up the remaining text from p[1] // and concat the result from p[0] so that we don't // get endless nesting ... rx[0] = rx[0].concat(p[0]); rx[1] = p[1]; } } // at this point, rx either contains the last matched element // or the entire matched set that starts with this element. // now we just check to see if this variation is better than // our best so far, in terms of how much of the input is parsed if (rx[1].length < best[1].length) { best = rx; } // if we've parsed all the input, then we're finished if (best[1].length === 0) { break; } } // so now we've either gone through all the patterns trying them // as the initial match; or we found one that parsed the entire // input string ... // if best has no matches, just return empty set ... if (best[0].length === 0) { return best; } // if a closing delimiter is provided, then we have to check it also if (c) { // we try this even if there is no remaining input because the pattern // may well be optional or match empty input ... try { q = c.call(this, best[1]); } catch (ey) { throw new $P.Exception(best[1]); } // it parsed ... be sure to update the best match remaining input best[1] = q[1]; } // if we're here, either there was no closing delimiter or we parsed it // so now we have the best match; just return it! return best; }; }, forward: function (gr, fname) { return function (s) { return gr[fname].call(this, s); }; }, // // Translation Operators // replace: function (rule, repl) { return function (s) { var r = rule.call(this, s); return [repl, r[1]]; }; }, process: function (rule, fn) { return function (s) { var r = rule.call(this, s); return [fn.call(this, r[0]), r[1]]; }; }, min: function (min, rule) { return function (s) { var rx = rule.call(this, s); if (rx[0].length < min) { throw new $P.Exception(s); } return rx; }; } }; // Generator Operators And Vector Operators // Generators are operators that have a signature of F(R) => R, // taking a given rule and returning another rule, such as // ignore, which parses a given rule and throws away the result. // Vector operators are those that have a signature of F(R1,R2,...) => R, // take a list of rules and returning a new rule, such as each. // Generator operators are converted (via the following _generator // function) into functions that can also take a list or array of rules // and return an array of new rules as though the function had been // called on each rule in turn (which is what actually happens). // This allows generators to be used with vector operators more easily. // Example: // each(ignore(foo, bar)) instead of each(ignore(foo), ignore(bar)) // This also turns generators into vector operators, which allows // constructs like: // not(cache(foo, bar)) var _generator = function (op) { function gen() { var args = null, rx = [], px, i; if (arguments.length > 1) { args = Array.prototype.slice.call(arguments); } else if (arguments[0] instanceof Array) { args = arguments[0]; } if (args) { px = args.shift(); if (px.length > 0) { args.unshift(px[i]); rx.push(op.apply(null, args)); args.shift(); return rx; } } else { return op.apply(null, arguments); } } return gen; }; var gx = "optional not ignore cache".split(/\s/); for (var i = 0 ; i < gx.length ; i++) { _[gx[i]] = _generator(_[gx[i]]); } var _vector = function (op) { return function () { if (arguments[0] instanceof Array) { return op.apply(null, arguments[0]); } else { return op.apply(null, arguments); } }; }; var vx = "each any all".split(/\s/); for (var j = 0 ; j < vx.length ; j++) { _[vx[j]] = _vector(_[vx[j]]); } }()); (function () { var $D = Date; var flattenAndCompact = function (ax) { var rx = []; for (var i = 0; i < ax.length; i++) { if (ax[i] instanceof Array) { rx = rx.concat(flattenAndCompact(ax[i])); } else { if (ax[i]) { rx.push(ax[i]); } } } return rx; }; var parseMeridian = function () { if (this.meridian && (this.hour || this.hour === 0)) { if (this.meridian === "a" && this.hour > 11 && Date.Config.strict24hr){ throw "Invalid hour and meridian combination"; } else if (this.meridian === "p" && this.hour < 12 && Date.Config.strict24hr){ throw "Invalid hour and meridian combination"; } else if (this.meridian === "p" && this.hour < 12) { this.hour = this.hour + 12; } else if (this.meridian === "a" && this.hour === 12) { this.hour = 0; } } }; var setDefaults = function () { var now = new Date(); if ((this.hour || this.minute) && (!this.month && !this.year && !this.day)) { this.day = now.getDate(); } if (!this.year) { this.year = now.getFullYear(); } if (!this.month && this.month !== 0) { this.month = now.getMonth(); } if (!this.day) { this.day = 1; } if (!this.hour) { this.hour = 0; } if (!this.minute) { this.minute = 0; } if (!this.second) { this.second = 0; } if (!this.millisecond) { this.millisecond = 0; } }; var finishUtils = { getToday: function () { if (this.now || "hour minute second".indexOf(this.unit) !== -1) { return new Date(); } else { return $D.today(); } }, setDaysFromWeekday: function (today, orient){ var gap; orient = orient || 1; this.unit = "day"; gap = ($D.getDayNumberFromName(this.weekday) - today.getDay()); this.days = gap ? ((gap + (orient * 7)) % 7) : (orient * 7); return this; }, setMonthsFromMonth: function (today, orient) { var gap; orient = orient || 1; this.unit = "month"; gap = (this.month - today.getMonth()); this.months = gap ? ((gap + (orient * 12)) % 12) : (orient * 12); this.month = null; return this; }, setDMYFromWeekday: function () { var d = Date[this.weekday](); this.day = d.getDate(); if (!this.month) { this.month = d.getMonth(); } this.year = d.getFullYear(); return this; }, setUnitValue: function (orient) { if (!this.value && this.operator && this.operator !== null && this[this.unit + "s"] && this[this.unit + "s"] !== null) { this[this.unit + "s"] = this[this.unit + "s"] + ((this.operator === "add") ? 1 : -1) + (this.value||0) * orient; } else if (this[this.unit + "s"] == null || this.operator != null) { if (!this.value) { this.value = 1; } this[this.unit + "s"] = this.value * orient; } }, generateDateFromWeeks: function () { var weekday = (this.weekday !== undefined) ? this.weekday : "today"; var d = Date[weekday]().addWeeks(this.weeks); if (this.now) { d.setTimeToNow(); } return d; } }; $D.Translator = { hour: function (s) { return function () { this.hour = Number(s); }; }, minute: function (s) { return function () { this.minute = Number(s); }; }, second: function (s) { return function () { this.second = Number(s); }; }, /* for ss.s format */ secondAndMillisecond: function (s) { return function () { var mx = s.match(/^([0-5][0-9])\.([0-9]{1,3})/); this.second = Number(mx[1]); this.millisecond = Number(mx[2]); }; }, meridian: function (s) { return function () { this.meridian = s.slice(0, 1).toLowerCase(); }; }, timezone: function (s) { return function () { var n = s.replace(/[^\d\+\-]/g, ""); if (n.length) { this.timezoneOffset = Number(n); } else { this.timezone = s.toLowerCase(); } }; }, day: function (x) { var s = x[0]; return function () { this.day = Number(s.match(/\d+/)[0]); if (this.day < 1) { throw "invalid day"; } }; }, month: function (s) { return function () { this.month = (s.length === 3) ? "jan feb mar apr may jun jul aug sep oct nov dec".indexOf(s)/4 : Number(s) - 1; if (this.month < 0) { throw "invalid month"; } }; }, year: function (s) { return function () { var n = Number(s); this.year = ((s.length > 2) ? n : (n + (((n + 2000) < Date.CultureInfo.twoDigitYearMax) ? 2000 : 1900))); }; }, rday: function (s) { return function () { switch (s) { case "yesterday": this.days = -1; break; case "tomorrow": this.days = 1; break; case "today": this.days = 0; break; case "now": this.days = 0; this.now = true; break; } }; }, finishExact: function (x) { var d; x = (x instanceof Array) ? x : [x]; for (var i = 0 ; i < x.length ; i++) { if (x[i]) { x[i].call(this); } } setDefaults.call(this); parseMeridian.call(this); if (this.day > $D.getDaysInMonth(this.year, this.month)) { throw new RangeError(this.day + " is not a valid value for days."); } d = new Date(this.year, this.month, this.day, this.hour, this.minute, this.second, this.millisecond); if (this.year < 100) { d.setFullYear(this.year); // means years less that 100 are process correctly. JS will parse it otherwise as 1900-1999. } if (this.timezone) { d.set({ timezone: this.timezone }); } else if (this.timezoneOffset) { d.set({ timezoneOffset: this.timezoneOffset }); } return d; }, finish: function (x) { var today, expression, orient, temp; x = (x instanceof Array) ? flattenAndCompact(x) : [ x ]; if (x.length === 0) { return null; } for (var i = 0 ; i < x.length ; i++) { if (typeof x[i] === "function") { x[i].call(this); } } if (this.now && !this.unit && !this.operator) { return new Date(); } else { today = finishUtils.getToday.call(this); } expression = !!(this.days && this.days !== null || this.orient || this.operator); orient = ((this.orient === "past" || this.operator === "subtract") ? -1 : 1); if (this.month && this.unit === "week") { this.value = this.month + 1; delete this.month; delete this.day; } if ((this.month || this.month === 0) && "year day hour minute second".indexOf(this.unit) !== -1) { if (!this.value) { this.value = this.month + 1; } this.month = null; expression = true; } if (!expression && this.weekday && !this.day && !this.days) { finishUtils.setDMYFromWeekday.call(this); } if (expression && this.weekday && this.unit !== "month" && this.unit !== "week") { finishUtils.setDaysFromWeekday.call(this, today, orient); } if (this.weekday && this.unit !== "week" && !this.day && !this.days) { temp = Date[this.weekday](); this.day = temp.getDate(); if (temp.getMonth() !== today.getMonth()) { this.month = temp.getMonth(); } } if (this.month && this.unit === "day" && this.operator) { if (!this.value) { this.value = (this.month + 1); } this.month = null; } if (this.value != null && this.month != null && this.year != null) { this.day = this.value * 1; } if (this.month && !this.day && this.value) { today.set({ day: this.value * 1 }); if (!expression) { this.day = this.value * 1; } } if (!this.month && this.value && this.unit === "month" && !this.now) { this.month = this.value; expression = true; } if (expression && (this.month || this.month === 0) && this.unit !== "year") { finishUtils.setMonthsFromMonth.call(this, today, orient); } if (!this.unit) { this.unit = "day"; } finishUtils.setUnitValue.call(this, orient); parseMeridian.call(this); if ((this.month || this.month === 0) && !this.day) { this.day = 1; } if (!this.orient && !this.operator && this.unit === "week" && this.value && !this.day && !this.month) { return Date.today().setWeek(this.value); } if (this.unit === "week" && this.weeks && !this.day && !this.month) { return finishUtils.generateDateFromWeeks.call(this); } if (expression && this.timezone && this.day && this.days) { this.day = this.days; } if (expression){ today.add(this); } else { today.set(this); } if (this.timezone) { this.timezone = this.timezone.toUpperCase(); var offset = $D.getTimezoneOffset(this.timezone); var timezone; if (today.hasDaylightSavingTime()) { // lets check that we're being sane with timezone setting timezone = $D.getTimezoneAbbreviation(offset, today.isDaylightSavingTime()); if (timezone !== this.timezone) { // bugger, we're in a place where things like EST vs EDT matters. if (today.isDaylightSavingTime()) { today.addHours(-1); } else { today.addHours(1); } } } today.setTimezoneOffset(offset); } return today; } }; }()); (function () { var $D = Date; $D.Grammar = {}; var _ = $D.Parsing.Operators, g = $D.Grammar, t = $D.Translator, _fn; // Allow rolling up into general purpose rules _fn = function () { return _.each(_.any.apply(null, arguments), _.not(g.ctoken2("timeContext"))); }; g.datePartDelimiter = _.rtoken(/^([\s\-\.\,\/\x27]+)/); g.timePartDelimiter = _.stoken(":"); g.whiteSpace = _.rtoken(/^\s*/); g.generalDelimiter = _.rtoken(/^(([\s\,]|at|@|on)+)/); var _C = {}; g.ctoken = function (keys) { var fn = _C[keys]; if (! fn) { var c = Date.CultureInfo.regexPatterns; var kx = keys.split(/\s+/), px = []; for (var i = 0; i < kx.length ; i++) { px.push(_.replace(_.rtoken(c[kx[i]]), kx[i])); } fn = _C[keys] = _.any.apply(null, px); } return fn; }; g.ctoken2 = function (key) { return _.rtoken(Date.CultureInfo.regexPatterns[key]); }; var cacheProcessRtoken = function (key, token, type, eachToken) { if (eachToken) { g[key] = _.cache(_.process(_.each(_.rtoken(token),_.optional(g.ctoken2(eachToken))), type)); } else { g[key] = _.cache(_.process(_.rtoken(token), type)); } }; var cacheProcessCtoken = function (token, type) { return _.cache(_.process(g.ctoken2(token), type)); }; var _F = {}; //function cache var _get = function (f) { _F[f] = (_F[f] || g.format(f)[0]); return _F[f]; }; g.allformats = function (fx) { var rx = []; if (fx instanceof Array) { for (var i = 0; i < fx.length; i++) { rx.push(_get(fx[i])); } } else { rx.push(_get(fx)); } return rx; }; g.formats = function (fx) { if (fx instanceof Array) { var rx = []; for (var i = 0 ; i < fx.length ; i++) { rx.push(_get(fx[i])); } return _.any.apply(null, rx); } else { return _get(fx); } }; var grammarFormats = { timeFormats: function(){ var i, RTokenKeys = [ "h", "hh", "H", "HH", "m", "mm", "s", "ss", "ss.s", "z", "zz" ], RToken = [ /^(0[0-9]|1[0-2]|[1-9])/, /^(0[0-9]|1[0-2])/, /^([0-1][0-9]|2[0-3]|[0-9])/, /^([0-1][0-9]|2[0-3])/, /^([0-5][0-9]|[0-9])/, /^[0-5][0-9]/, /^([0-5][0-9]|[0-9])/, /^[0-5][0-9]/, /^[0-5][0-9]\.[0-9]{1,3}/, /^((\+|\-)\s*\d\d\d\d)|((\+|\-)\d\d\:?\d\d)/, /^((\+|\-)\s*\d\d\d\d)|((\+|\-)\d\d\:?\d\d)/ ], tokens = [ t.hour, t.hour, t.hour, t.hour, t.minute, t.minute, t.second, t.second, t.secondAndMillisecond, t.timezone, t.timezone ]; for (i=0; i < RTokenKeys.length; i++) { cacheProcessRtoken(RTokenKeys[i], RToken[i], tokens[i]); } g.hms = _.cache(_.sequence([g.H, g.m, g.s], g.timePartDelimiter)); g.t = cacheProcessCtoken("shortMeridian", t.meridian); g.tt = cacheProcessCtoken("longMeridian", t.meridian); g.zzz = cacheProcessCtoken("timezone", t.timezone); g.timeSuffix = _.each(_.ignore(g.whiteSpace), _.set([ g.tt, g.zzz ])); g.time = _.each(_.optional(_.ignore(_.stoken("T"))), g.hms, g.timeSuffix); }, dateFormats: function () { // pre-loaded rules for different date part order preferences var _setfn = function () { return _.set(arguments, g.datePartDelimiter); }; var i, RTokenKeys = [ "d", "dd", "M", "MM", "y", "yy", "yyy", "yyyy" ], RToken = [ /^([0-2]\d|3[0-1]|\d)/, /^([0-2]\d|3[0-1])/, /^(1[0-2]|0\d|\d)/, /^(1[0-2]|0\d)/, /^(\d+)/, /^(\d\d)/, /^(\d\d?\d?\d?)/, /^(\d\d\d\d)/ ], tokens = [ t.day, t.day, t.month, t.month, t.year, t.year, t.year, t.year ], eachToken = [ "ordinalSuffix", "ordinalSuffix" ]; for (i=0; i < RTokenKeys.length; i++) { cacheProcessRtoken(RTokenKeys[i], RToken[i], tokens[i], eachToken[i]); } g.MMM = g.MMMM = _.cache(_.process(g.ctoken("jan feb mar apr may jun jul aug sep oct nov dec"), t.month)); g.ddd = g.dddd = _.cache(_.process(g.ctoken("sun mon tue wed thu fri sat"), function (s) { return function () { this.weekday = s; }; } )); g.day = _fn(g.d, g.dd); g.month = _fn(g.M, g.MMM); g.year = _fn(g.yyyy, g.yy); g.mdy = _setfn(g.ddd, g.month, g.day, g.year); g.ymd = _setfn(g.ddd, g.year, g.month, g.day); g.dmy = _setfn(g.ddd, g.day, g.month, g.year); g.date = function (s) { return ((g[Date.CultureInfo.dateElementOrder] || g.mdy).call(this, s)); }; }, relative: function () { // relative date / time expressions g.orientation = _.process(g.ctoken("past future"), function (s) { return function () { this.orient = s; }; } ); g.operator = _.process(g.ctoken("add subtract"), function (s) { return function () { this.operator = s; }; } ); g.rday = _.process(g.ctoken("yesterday tomorrow today now"), t.rday); g.unit = _.process(g.ctoken("second minute hour day week month year"), function (s) { return function () { this.unit = s; }; } ); } }; g.buildGrammarFormats = function () { // these need to be rebuilt every time the language changes. _C = {}; grammarFormats.timeFormats(); grammarFormats.dateFormats(); grammarFormats.relative(); g.value = _.process(_.rtoken(/^([-+]?\d+)?(st|nd|rd|th)?/), function (s) { return function () { this.value = s.replace(/\D/g, ""); }; } ); g.expression = _.set([g.rday, g.operator, g.value, g.unit, g.orientation, g.ddd, g.MMM ]); g.format = _.process(_.many( _.any( // translate format specifiers into grammar rules _.process( _.rtoken(/^(dd?d?d?(?!e)|MM?M?M?|yy?y?y?|hh?|HH?|mm?|ss?|tt?|zz?z?)/), function (fmt) { if (g[fmt]) { return g[fmt]; } else { throw $D.Parsing.Exception(fmt); } } ), // translate separator tokens into token rules _.process(_.rtoken(/^[^dMyhHmstz]+/), // all legal separators function (s) { return _.ignore(_.stoken(s)); } ) ) ), // construct the parser ... function (rules) { return _.process(_.each.apply(null, rules), t.finishExact); } ); // starting rule for general purpose grammar g._start = _.process(_.set([ g.date, g.time, g.expression ], g.generalDelimiter, g.whiteSpace), t.finish); }; g.buildGrammarFormats(); // parsing date format specifiers - ex: "h:m:s tt" // this little guy will generate a custom parser based // on the format string, ex: g.format("h:m:s tt") // check for these formats first g._formats = g.formats([ "\"yyyy-MM-ddTHH:mm:ssZ\"", "yyyy-MM-ddTHH:mm:ss.sz", "yyyy-MM-ddTHH:mm:ssZ", "yyyy-MM-ddTHH:mm:ssz", "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-ddTHH:mmZ", "yyyy-MM-ddTHH:mmz", "yyyy-MM-ddTHH:mm", "ddd, MMM dd, yyyy H:mm:ss tt", "ddd MMM d yyyy HH:mm:ss zzz", "MMddyyyy", "ddMMyyyy", "Mddyyyy", "ddMyyyy", "Mdyyyy", "dMyyyy", "yyyy", "Mdyy", "dMyy", "d" ]); // real starting rule: tries selected formats first, // then general purpose rule g.start = function (s) { try { var r = g._formats.call({}, s); if (r[1].length === 0) { return r; } } catch (e) {} return g._start.call({}, s); }; }()); (function () { var $D = Date; /** * @desc Converts the specified string value into its JavaScript Date equivalent using CultureInfo specific format information. * * Example

	///////////
	// Dates //
	///////////

	// 15-Oct-2004
	var d1 = Date.parse("10/15/2004");

	// 15-Oct-2004
	var d1 = Date.parse("15-Oct-2004");

	// 15-Oct-2004
	var d1 = Date.parse("2004.10.15");

	//Fri Oct 15, 2004
	var d1 = Date.parse("Fri Oct 15, 2004");

	///////////
	// Times //
	///////////

	// Today at 10 PM.
	var d1 = Date.parse("10 PM");

	// Today at 10:30 PM.
	var d1 = Date.parse("10:30 P.M.");

	// Today at 6 AM.
	var d1 = Date.parse("06am");

	/////////////////////
	// Dates and Times //
	/////////////////////

	// 8-July-2004 @ 10:30 PM
	var d1 = Date.parse("July 8th, 2004, 10:30 PM");

	// 1-July-2004 @ 10:30 PM
	var d1 = Date.parse("2004-07-01T22:30:00");

	////////////////////
	// Relative Dates //
	////////////////////

	// Returns today's date. The string "today" is culture specific.
	var d1 = Date.parse("today");

	// Returns yesterday's date. The string "yesterday" is culture specific.
	var d1 = Date.parse("yesterday");

	// Returns the date of the next thursday.
	var d1 = Date.parse("Next thursday");

	// Returns the date of the most previous monday.
	var d1 = Date.parse("last monday");

	// Returns today's day + one year.
	var d1 = Date.parse("next year");

	///////////////
	// Date Math //
	///////////////

	// Today + 2 days
	var d1 = Date.parse("t+2");

	// Today + 2 days
	var d1 = Date.parse("today + 2 days");

	// Today + 3 months
	var d1 = Date.parse("t+3m");

	// Today - 1 year
	var d1 = Date.parse("today - 1 year");

	// Today - 1 year
	var d1 = Date.parse("t-1y"); 


	/////////////////////////////
	// Partial Dates and Times //
	/////////////////////////////

	// July 15th of this year.
	var d1 = Date.parse("July 15");

	// 15th day of current day and year.
	var d1 = Date.parse("15");

	// July 1st of current year at 10pm.
	var d1 = Date.parse("7/1 10pm");
	
* * @param {String} The string value to convert into a Date object [Required] * @return {Date} A Date object or null if the string cannot be converted into a Date. */ var parseUtils = { removeOrds: function (s) { ords = s.match(/\b(\d+)(?:st|nd|rd|th)\b/); // find ordinal matches s = ((ords && ords.length === 2) ? s.replace(ords[0], ords[1]) : s); return s; }, grammarParser: function (s) { var r = null; try { r = $D.Grammar.start.call({}, s.replace(/^\s*(\S*(\s+\S+)*)\s*$/, "$1")); } catch (e) { return null; } return ((r[1].length === 0) ? r[0] : null); }, nativeFallback: function(s) { var t; try { // ok we haven't parsed it, last ditch attempt with the built-in parser. t = Date._parse(s); return (t || t === 0) ? new Date(t) : null; } catch (e) { return null; } } }; function parse (s) { var d; if (!s) { return null; } if (s instanceof Date) { return s.clone(); } if (s.length >= 4 && s.charAt(0) !== "0" && s.charAt(0) !== "+"&& s.charAt(0) !== "-") { // ie: 2004 will pass, 0800 won't. // Start with specific formats d = $D.Parsing.ISO.parse(s) || $D.Parsing.Numeric.parse(s); } if (d instanceof Date && !isNaN(d.getTime())) { return d; } else { // find ordinal dates (1st, 3rd, 8th, etc and remove them as they cause parsing issues) s = $D.Parsing.Normalizer.parse(parseUtils.removeOrds(s)); d = parseUtils.grammarParser(s); if (d !== null) { return d; } else { return parseUtils.nativeFallback(s); } } } if (!$D._parse) { $D._parse = $D.parse; } $D.parse = parse; Date.getParseFunction = function (fx) { var fns = Date.Grammar.allformats(fx); return function (s) { var r = null; for (var i = 0; i < fns.length; i++) { try { r = fns[i].call({}, s); } catch (e) { continue; } if (r[1].length === 0) { return r[0]; } } return null; }; }; /** * Converts the specified string value into its JavaScript Date equivalent using the specified format {String} or formats {Array} and the CultureInfo specific format information. * The format of the string value must match one of the supplied formats exactly. * * Example

	// 15-Oct-2004
	var d1 = Date.parseExact("10/15/2004", "M/d/yyyy");

	// 15-Oct-2004
	var d1 = Date.parse("15-Oct-2004", "M-ddd-yyyy");

	// 15-Oct-2004
	var d1 = Date.parse("2004.10.15", "yyyy.MM.dd");

	// Multiple formats
	var d1 = Date.parseExact("10/15/2004", ["M/d/yyyy", "MMMM d, yyyy"]);
	
* * @param {String} The string value to convert into a Date object [Required]. * @param {Object} The expected format {String} or an array of expected formats {Array} of the date string [Required]. * @return {Date} A Date object or null if the string cannot be converted into a Date. */ $D.parseExact = function (s, fx) { return $D.getParseFunction(fx)(s); }; }()); (function () { var $D = Date, $P = $D.prototype, // $C = $D.CultureInfo, // not used atm p = function (s, l) { if (!l) { l = 2; } return ("000" + s).slice(l * -1); }; /** * Converts a PHP format string to Java/.NET format string. * A PHP format string can be used with ._format or .format. * A Java/.NET format string can be used with .toString(). * The .parseExact function will only accept a Java/.NET format string * * Example * var f1 = "%m/%d/%y" * var f2 = Date.normalizeFormat(f1); // "MM/dd/yy" * * new Date().format(f1); // "04/13/08" * new Date()._format(f1); // "04/13/08" * new Date().toString(f2); // "04/13/08" * * var date = Date.parseExact("04/13/08", f2); // Sun Apr 13 2008 * * @param {String} A PHP format string consisting of one or more format spcifiers. * @return {String} The PHP format converted to a Java/.NET format string. */ var normalizerSubstitutions = { "d" : "dd", "%d": "dd", "D" : "ddd", "%a": "ddd", "j" : "dddd", "l" : "dddd", "%A": "dddd", "S" : "S", "F" : "MMMM", "%B": "MMMM", "m" : "MM", "%m": "MM", "M" : "MMM", "%b": "MMM", "%h": "MMM", "n" : "M", "Y" : "yyyy", "%Y": "yyyy", "y" : "yy", "%y": "yy", "g" : "h", "%I": "h", "G" : "H", "h" : "hh", "H" : "HH", "%H": "HH", "i" : "mm", "%M": "mm", "s" : "ss", "%S": "ss", "%r": "hh:mm tt", "%R": "H:mm", "%T": "H:mm:ss", "%X": "t", "%x": "d", "%e": "d", "%D": "MM/dd/yy", "%n": "\\n", "%t": "\\t", "e" : "z", "T" : "z", "%z": "z", "%Z": "z", "Z" : "ZZ", "N" : "u", "w" : "u", "%w": "u", "W" : "W", "%V": "W" }; var normalizer = { substitutes: function (m) { return normalizerSubstitutions[m]; }, interpreted: function (m, x) { var y; switch (m) { case "%u": return x.getDay() + 1; case "z": return x.getOrdinalNumber(); case "%j": return p(x.getOrdinalNumber(), 3); case "%U": var d1 = x.clone().set({month: 0, day: 1}).addDays(-1).moveToDayOfWeek(0), d2 = x.clone().addDays(1).moveToDayOfWeek(0, -1); return (d2 < d1) ? "00" : p((d2.getOrdinalNumber() - d1.getOrdinalNumber()) / 7 + 1); case "%W": return p(x.getWeek()); case "t": return $D.getDaysInMonth(x.getFullYear(), x.getMonth()); case "o": case "%G": return x.setWeek(x.getISOWeek()).toString("yyyy"); case "%g": return x._format("%G").slice(-2); case "a": case "%p": return t("tt").toLowerCase(); case "A": return t("tt").toUpperCase(); case "u": return p(x.getMilliseconds(), 3); case "I": return (x.isDaylightSavingTime()) ? 1 : 0; case "O": return x.getUTCOffset(); case "P": y = x.getUTCOffset(); return y.substring(0, y.length - 2) + ":" + y.substring(y.length - 2); case "B": var now = new Date(); return Math.floor(((now.getHours() * 3600) + (now.getMinutes() * 60) + now.getSeconds() + (now.getTimezoneOffset() + 60) * 60) / 86.4); case "c": return x.toISOString().replace(/\"/g, ""); case "U": return $D.strtotime("now"); case "%c": return t("d") + " " + t("t"); case "%C": return Math.floor(x.getFullYear() / 100 + 1); } }, shouldOverrideDefaults: function (m) { switch (m) { case "%e": return true; default: return false; } }, parse: function (m, context) { var formatString, c = context || new Date(); formatString = normalizer.substitutes(m); if (formatString) { return formatString; } formatString = normalizer.interpreted(m, c); if (formatString) { return formatString; } else { return m; } } }; $D.normalizeFormat = function (format, context) { return format.replace(/(%|\\)?.|%%/g, function(t){ return normalizer.parse(t, context); }); }; /** * Format a local Unix timestamp according to locale settings * * Example: * Date.strftime("%m/%d/%y", new Date()); // "04/13/08" * Date.strftime("c", "2008-04-13T17:52:03Z"); // "04/13/08" * * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @param {Number|String} The number representing the number of seconds that have elapsed since January 1, 1970 (local time). * @return {String} A string representation of the current Date object. */ $D.strftime = function (format, time) { var d = Date.parse(time); return d._format(format); }; /** * Parse any textual datetime description into a Unix timestamp. * A Unix timestamp is the number of seconds that have elapsed since January 1, 1970 (midnight UTC/GMT). * * Example: * Date.strtotime("04/13/08"); // 1208044800 * Date.strtotime("1970-01-01T00:00:00Z"); // 0 * * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @param {Object} A string or date object. * @return {String} A string representation of the current Date object. */ $D.strtotime = function (time) { var d = $D.parse(time); return Math.round($D.UTC(d.getUTCFullYear(), d.getUTCMonth(), d.getUTCDate(), d.getUTCHours(), d.getUTCMinutes(), d.getUTCSeconds(), d.getUTCMilliseconds()) / 1000); }; /** * Converts the value of the current Date object to its equivalent string representation using a PHP/Unix style of date format specifiers. * Format Specifiers * Format Description Example * ------ --------------------------------------------------------------------------- ----------------------- * %a abbreviated weekday name according to the current localed "Mon" through "Sun" * %A full weekday name according to the current localed "Sunday" through "Saturday" * %b abbreviated month name according to the current localed "Jan" through "Dec" * %B full month name according to the current locale "January" through "December" * %c preferred date and time representation for the current locale "4/13/2008 12:33 PM" * %C century number (the year divided by 100 and truncated to an integer) "00" to "99" * %d day of the month as a decimal number "01" to "31" * %D same as %m/%d/%y "04/13/08" * %e day of the month as a decimal number, a single digit is preceded by a space "1" to "31" * %g like %G, but without the century "08" * %G The 4-digit year corresponding to the ISO week number (see %V). "2008" * This has the same format and value as %Y, except that if the ISO week number * belongs to the previous or next year, that year is used instead. * %h same as %b "Jan" through "Dec" * %H hour as a decimal number using a 24-hour clock. "00" to "23" * %I hour as a decimal number using a 12-hour clock. "01" to "12" * %j day of the year as a decimal number. "001" to "366" * %m month as a decimal number. "01" to "12" * %M minute as a decimal number. "00" to "59" * %n newline character "\n" * %p either "am" or "pm" according to the given time value, or the "am" or "pm" * corresponding strings for the current locale. * %r time in a.m. and p.m. notation "8:44 PM" * %R time in 24 hour notation "20:44" * %S second as a decimal number "00" to "59" * %t tab character "\t" * %T current time, equal to %H:%M:%S "12:49:11" * %u weekday as a decimal number ["1", "7"], with "1" representing Monday "1" to "7" * %U week number of the current year as a decimal number, starting with the "0" to ("52" or "53") * first Sunday as the first day of the first week * %V The ISO 8601:1988 week number of the current year as a decimal number, "00" to ("52" or "53") * range 01 to 53, where week 1 is the first week that has at least 4 days * in the current year, and with Monday as the first day of the week. * (Use %G or %g for the year component that corresponds to the week number * for the specified timestamp.) * %W week number of the current year as a decimal number, starting with the "00" to ("52" or "53") * first Monday as the first day of the first week * %w day of the week as a decimal, Sunday being "0" "0" to "6" * %x preferred date representation for the current locale without the time "4/13/2008" * %X preferred time representation for the current locale without the date "12:53:05" * %y year as a decimal number without a century "00" "99" * %Y year as a decimal number including the century "2008" * %Z time zone or name or abbreviation "UTC", "EST", "PST" * %z same as %Z * %% a literal "%" characters "%" * d Day of the month, 2 digits with leading zeros "01" to "31" * D A textual representation of a day, three letters "Mon" through "Sun" * j Day of the month without leading zeros "1" to "31" * l A full textual representation of the day of the week (lowercase "L") "Sunday" through "Saturday" * N ISO-8601 numeric representation of the day of the week (added in PHP 5.1.0) "1" (for Monday) through "7" (for Sunday) * S English ordinal suffix for the day of the month, 2 characters "st", "nd", "rd" or "th". Works well with j * w Numeric representation of the day of the week "0" (for Sunday) through "6" (for Saturday) * z The day of the year (starting from "0") "0" through "365" * W ISO-8601 week number of year, weeks starting on Monday "00" to ("52" or "53") * F A full textual representation of a month, such as January or March "January" through "December" * m Numeric representation of a month, with leading zeros "01" through "12" * M A short textual representation of a month, three letters "Jan" through "Dec" * n Numeric representation of a month, without leading zeros "1" through "12" * t Number of days in the given month "28" through "31" * L Whether it's a leap year "1" if it is a leap year, "0" otherwise * o ISO-8601 year number. This has the same value as Y, except that if the "2008" * ISO week number (W) belongs to the previous or next year, that year * is used instead. * Y A full numeric representation of a year, 4 digits "2008" * y A two digit representation of a year "08" * a Lowercase Ante meridiem and Post meridiem "am" or "pm" * A Uppercase Ante meridiem and Post meridiem "AM" or "PM" * B Swatch Internet time "000" through "999" * g 12-hour format of an hour without leading zeros "1" through "12" * G 24-hour format of an hour without leading zeros "0" through "23" * h 12-hour format of an hour with leading zeros "01" through "12" * H 24-hour format of an hour with leading zeros "00" through "23" * i Minutes with leading zeros "00" to "59" * s Seconds, with leading zeros "00" through "59" * u Milliseconds "54321" * e Timezone identifier "UTC", "EST", "PST" * I Whether or not the date is in daylight saving time (uppercase i) "1" if Daylight Saving Time, "0" otherwise * O Difference to Greenwich time (GMT) in hours "+0200", "-0600" * P Difference to Greenwich time (GMT) with colon between hours and minutes "+02:00", "-06:00" * T Timezone abbreviation "UTC", "EST", "PST" * Z Timezone offset in seconds. The offset for timezones west of UTC is "-43200" through "50400" * always negative, and for those east of UTC is always positive. * c ISO 8601 date "2004-02-12T15:19:21+00:00" * r RFC 2822 formatted date "Thu, 21 Dec 2000 16:01:07 +0200" * U Seconds since the Unix Epoch (January 1 1970 00:00:00 GMT) "0" * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @return {String} A string representation of the current Date object. */ var formatReplace = function (context) { return function (m) { var formatString, override = false; if (m.charAt(0) === "\\" || m.substring(0, 2) === "%%") { return m.replace("\\", "").replace("%%", "%"); } override = normalizer.shouldOverrideDefaults(m); formatString = $D.normalizeFormat(m, context); if (formatString) { return context.toString(formatString, override); } }; }; $P._format = function (format) { var formatter = formatReplace(this); if (!format) { return this._toString(); } else { return format.replace(/(%|\\)?.|%%/g, formatter); } }; if (!$P.format) { $P.format = $P._format; } }()); (function () { "use strict"; var gFn = function (attr) { return function () { return this[attr]; }; }; var sFn = function (attr) { return function (val) { this[attr] = val; return this; }; }; var attrs = ["years", "months", "days", "hours", "minutes", "seconds", "milliseconds"]; var addSetFuncs = function (context, attrs) { for (var i = 0; i < attrs.length ; i++) { var $a = attrs[i], $b = $a.slice(0, 1).toUpperCase() + $a.slice(1); context.prototype[$a] = 0; context.prototype["get" + $b] = gFn($a); context.prototype["set" + $b] = sFn($a); } }; /** * new TimeSpan(milliseconds); * new TimeSpan(days, hours, minutes, seconds); * new TimeSpan(days, hours, minutes, seconds, milliseconds); */ var TimeSpan = function (days, hours, minutes, seconds, milliseconds) { if (arguments.length === 1 && typeof days === "number") { var orient = (days < 0) ? -1 : +1; var millsLeft = Math.abs(days); this.setDays(Math.floor(millsLeft / 86400000) * orient); millsLeft = millsLeft % 86400000; this.setHours(Math.floor(millsLeft / 3600000) * orient); millsLeft = millsLeft % 3600000; this.setMinutes(Math.floor(millsLeft / 60000) * orient); millsLeft = millsLeft % 60000; this.setSeconds(Math.floor(millsLeft / 1000) * orient); millsLeft = millsLeft % 1000; this.setMilliseconds(millsLeft * orient); } else { this.set(days, hours, minutes, seconds, milliseconds); } this.getTotalMilliseconds = function () { return (this.getDays() * 86400000) + (this.getHours() * 3600000) + (this.getMinutes() * 60000) + (this.getSeconds() * 1000); }; this.compareTo = function (time) { var t1 = new Date(1970, 1, 1, this.getHours(), this.getMinutes(), this.getSeconds()), t2; if (time === null) { t2 = new Date(1970, 1, 1, 0, 0, 0); } else { t2 = new Date(1970, 1, 1, time.getHours(), time.getMinutes(), time.getSeconds()); } return (t1 < t2) ? -1 : (t1 > t2) ? 1 : 0; }; this.equals = function (time) { return (this.compareTo(time) === 0); }; this.add = function (time) { return (time === null) ? this : this.addSeconds(time.getTotalMilliseconds() / 1000); }; this.subtract = function (time) { return (time === null) ? this : this.addSeconds(-time.getTotalMilliseconds() / 1000); }; this.addDays = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 86400000)); }; this.addHours = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 3600000)); }; this.addMinutes = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 60000)); }; this.addSeconds = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 1000)); }; this.addMilliseconds = function (n) { return new TimeSpan(this.getTotalMilliseconds() + n); }; this.get12HourHour = function () { return (this.getHours() > 12) ? this.getHours() - 12 : (this.getHours() === 0) ? 12 : this.getHours(); }; this.getDesignator = function () { return (this.getHours() < 12) ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator; }; this.toString = function (format) { this._toString = function () { if (this.getDays() !== null && this.getDays() > 0) { return this.getDays() + "." + this.getHours() + ":" + this.p(this.getMinutes()) + ":" + this.p(this.getSeconds()); } else { return this.getHours() + ":" + this.p(this.getMinutes()) + ":" + this.p(this.getSeconds()); } }; this.p = function (s) { return (s.toString().length < 2) ? "0" + s : s; }; var me = this; return format ? format.replace(/dd?|HH?|hh?|mm?|ss?|tt?/g, function (format) { switch (format) { case "d": return me.getDays(); case "dd": return me.p(me.getDays()); case "H": return me.getHours(); case "HH": return me.p(me.getHours()); case "h": return me.get12HourHour(); case "hh": return me.p(me.get12HourHour()); case "m": return me.getMinutes(); case "mm": return me.p(me.getMinutes()); case "s": return me.getSeconds(); case "ss": return me.p(me.getSeconds()); case "t": return ((me.getHours() < 12) ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator).substring(0, 1); case "tt": return (me.getHours() < 12) ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator; } } ) : this._toString(); }; return this; }; addSetFuncs(TimeSpan, attrs.slice(2)); TimeSpan.prototype.set = function (days, hours, minutes, seconds, milliseconds){ this.setDays(days || this.getDays()); this.setHours(hours || this.getHours()); this.setMinutes(minutes || this.getMinutes()); this.setSeconds(seconds || this.getSeconds()); this.setMilliseconds(milliseconds || this.getMilliseconds()); }; /** * Gets the time of day for this date instances. * @return {TimeSpan} TimeSpan */ Date.prototype.getTimeOfDay = function () { return new TimeSpan(0, this.getHours(), this.getMinutes(), this.getSeconds(), this.getMilliseconds()); }; Date.TimeSpan = TimeSpan; if (typeof window !== "undefined" ) { // keeping API compatible for v1.x window.TimeSpan = TimeSpan; } }()); (function () { "use strict"; var attrs = ["years", "months", "days", "hours", "minutes", "seconds", "milliseconds"]; var gFn = function (attr) { return function () { return this[attr]; }; }; var sFn = function (attr) { return function (val) { this[attr] = val; return this; }; }; var addSetFuncs = function (context, attrs) { for (var i = 0; i < attrs.length ; i++) { var $a = attrs[i], $b = $a.slice(0, 1).toUpperCase() + $a.slice(1); context.prototype[$a] = 0; context.prototype["get" + $b] = gFn($a); context.prototype["set" + $b] = sFn($a); } }; var setMonthsAndYears = function (orient, d1, d2, context) { function inc() { d1.addMonths(-orient); context.months++; if (context.months === 12) { context.years++; context.months = 0; } } if (orient === +1) { while (d1 > d2) { inc(); } } else { while (d1 < d2) { inc(); } } context.months--; context.months *= orient; context.years *= orient; }; var adjustForDST = function(orient, startDate, endDate) { var hasDSTMismatch = (false === (startDate.isDaylightSavingTime() === endDate.isDaylightSavingTime())); if (hasDSTMismatch && orient === 1) { startDate.addHours(-1); } else if (hasDSTMismatch) { startDate.addHours(1); } }; /** * TimePeriod(startDate, endDate); * TimePeriod(years, months, days, hours, minutes, seconds, milliseconds); */ var TimePeriod = function (years, months, days, hours, minutes, seconds, milliseconds) { if (arguments.length === 7) { this.set(years, months, days, hours, minutes, seconds, milliseconds); } else if (arguments.length === 2 && arguments[0] instanceof Date && arguments[1] instanceof Date) { var startDate = arguments[0].clone(); var endDate = arguments[1].clone(); var orient = (startDate > endDate) ? +1 : -1; this.dates = { start: arguments[0].clone(), end: arguments[1].clone() }; setMonthsAndYears(orient, startDate, endDate, this); adjustForDST(orient, startDate, endDate); // // TODO - adjust for DST var diff = endDate - startDate; if (diff !== 0) { var ts = new TimeSpan(diff); this.set(this.years, this.months, ts.getDays(), ts.getHours(), ts.getMinutes(), ts.getSeconds(), ts.getMilliseconds()); } } return this; }; // create all the set functions. addSetFuncs(TimePeriod, attrs); TimePeriod.prototype.set = function (years, months, days, hours, minutes, seconds, milliseconds){ this.setYears(years || this.getYears()); this.setMonths(months || this.getMonths()); this.setDays(days || this.getDays()); this.setHours(hours || this.getHours()); this.setMinutes(minutes || this.getMinutes()); this.setSeconds(seconds || this.getSeconds()); this.setMilliseconds(milliseconds || this.getMilliseconds()); }; Date.TimePeriod = TimePeriod; if (typeof window !== "undefined") { // keeping API compatible for v1.x window.TimePeriod = TimePeriod; } }()); ================================================ FILE: build/date-el-GR.js ================================================ /** * @overview datejs * @version 1.0.0-rc3 * @author Gregory Wild-Smith * @copyright 2015 Gregory Wild-Smith * @license MIT * @homepage https://github.com/abritinthebay/datejs */ /* * DateJS Culture String File * Country Code: el-GR * Name: Greek (Greece) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["el-GR"] = { "name": "el-GR", "englishName": "Greek (Greece)", "nativeName": "ελληνικά (Ελλάδα)", "Sunday": "Κυριακή", "Monday": "Δευτέρα", "Tuesday": "Τρίτη", "Wednesday": "Τετάρτη", "Thursday": "Πέμπτη", "Friday": "Παρασκευή", "Saturday": "Σάββατο", "Sun": "Κυρ", "Mon": "Δευ", "Tue": "Τρι", "Wed": "Τετ", "Thu": "Πεμ", "Fri": "Παρ", "Sat": "Σαβ", "Su": "Κυ", "Mo": "Δε", "Tu": "Τρ", "We": "Τε", "Th": "Πε", "Fr": "Πα", "Sa": "Σά", "S_Sun_Initial": "Κ", "M_Mon_Initial": "Δ", "T_Tue_Initial": "Τ", "W_Wed_Initial": "Τ", "T_Thu_Initial": "Π", "F_Fri_Initial": "Π", "S_Sat_Initial": "Σ", "January": "Ιανουάριος", "February": "Φεβρουάριος", "March": "Μάρτιος", "April": "Απρίλιος", "May": "Μάιος", "June": "Ιούνιος", "July": "Ιούλιος", "August": "Αύγουστος", "September": "Σεπτέμβριος", "October": "Οκτώβριος", "November": "Νοέμβριος", "December": "Δεκέμβριος", "Jan_Abbr": "Ιαν", "Feb_Abbr": "Φεβ", "Mar_Abbr": "Μαρ", "Apr_Abbr": "Απρ", "May_Abbr": "Μαϊ", "Jun_Abbr": "Ιουν", "Jul_Abbr": "Ιουλ", "Aug_Abbr": "Αυγ", "Sep_Abbr": "Σεπ", "Oct_Abbr": "Οκτ", "Nov_Abbr": "Νοε", "Dec_Abbr": "Δεκ", "AM": "πμ", "PM": "μμ", "firstDayOfWeek": 1, "twoDigitYearMax": 2029, "mdy": "dmy", "M/d/yyyy": "d/M/yyyy", "dddd, MMMM dd, yyyy": "dddd, d MMMM yyyy", "h:mm tt": "h:mm tt", "h:mm:ss tt": "h:mm:ss tt", "dddd, MMMM dd, yyyy h:mm:ss tt": "dddd, d MMMM yyyy h:mm:ss tt", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "dd MMMM", "MMMM, yyyy": "MMMM yyyy", "/jan(uary)?/": "ιαν(ουάριος)?", "/feb(ruary)?/": "φεβ(ρουάριος)?", "/mar(ch)?/": "μάρτιος", "/apr(il)?/": "απρ(ίλιος)?", "/may/": "μάιος", "/jun(e)?/": "ιούνιος", "/jul(y)?/": "ιούλιος", "/aug(ust)?/": "αύγουστος", "/sep(t(ember)?)?/": "σεπ(τέμβριος)?", "/oct(ober)?/": "οκτ(ώβριος)?", "/nov(ember)?/": "νοέμβριος", "/dec(ember)?/": "δεκ(έμβριος)?", "/^su(n(day)?)?/": "^κυ(ρ(ιακή)?)?", "/^mo(n(day)?)?/": "^δε(υ(τέρα)?)?", "/^tu(e(s(day)?)?)?/": "^τρ(ι(τη)?)?", "/^we(d(nesday)?)?/": "^τε(τ(άρτη)?)?", "/^th(u(r(s(day)?)?)?)?/": "^πε(μ(πτη)?)?", "/^fr(i(day)?)?/": "^πα(ρ(ασκευή)?)?", "/^sa(t(urday)?)?/": "^σά(β(βατο)?)?", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "el-GR"; /** * @overview datejs * @version 1.0.0-rc3 * @author Gregory Wild-Smith * @copyright 2015 Gregory Wild-Smith * @license MIT * @homepage https://github.com/abritinthebay/datejs */(function () { var $D = Date; var lang = Date.CultureStrings ? Date.CultureStrings.lang : null; var loggedKeys = {}; // for debug purposes. var getText = { getFromKey: function (key, countryCode) { var output; if (Date.CultureStrings && Date.CultureStrings[countryCode] && Date.CultureStrings[countryCode][key]) { output = Date.CultureStrings[countryCode][key]; } else { output = getText.buildFromDefault(key); } if (key.charAt(0) === "/") { // Assume it's a regex output = getText.buildFromRegex(key, countryCode); } return output; }, getFromObjectValues: function (obj, countryCode) { var key, output = {}; for(key in obj) { if (obj.hasOwnProperty(key)) { output[key] = getText.getFromKey(obj[key], countryCode); } } return output; }, getFromObjectKeys: function (obj, countryCode) { var key, output = {}; for(key in obj) { if (obj.hasOwnProperty(key)) { output[getText.getFromKey(key, countryCode)] = obj[key]; } } return output; }, getFromArray: function (arr, countryCode) { var output = []; for (var i=0; i < arr.length; i++){ if (i in arr) { output[i] = getText.getFromKey(arr[i], countryCode); } } return output; }, buildFromDefault: function (key) { var output, length, split, last; switch(key) { case "name": output = "en-US"; break; case "englishName": output = "English (United States)"; break; case "nativeName": output = "English (United States)"; break; case "twoDigitYearMax": output = 2049; break; case "firstDayOfWeek": output = 0; break; default: output = key; split = key.split("_"); length = split.length; if (length > 1 && key.charAt(0) !== "/") { // if the key isn't a regex and it has a split. last = split[(length - 1)].toLowerCase(); if (last === "initial" || last === "abbr") { output = split[0]; } } break; } return output; }, buildFromRegex: function (key, countryCode) { var output; if (Date.CultureStrings && Date.CultureStrings[countryCode] && Date.CultureStrings[countryCode][key]) { output = new RegExp(Date.CultureStrings[countryCode][key], "i"); } else { output = new RegExp(key.replace(new RegExp("/", "g"),""), "i"); } return output; } }; var shallowMerge = function (obj1, obj2) { for (var attrname in obj2) { if (obj2.hasOwnProperty(attrname)) { obj1[attrname] = obj2[attrname]; } } }; var __ = function (key, language) { var countryCode = (language) ? language : lang; loggedKeys[key] = key; if (typeof key === "object") { if (key instanceof Array) { return getText.getFromArray(key, countryCode); } else { return getText.getFromObjectKeys(key, countryCode); } } else { return getText.getFromKey(key, countryCode); } }; var loadI18nScript = function (code) { // paatterned after jQuery's getScript. var url = Date.Config.i18n + code + ".js"; var head = document.getElementsByTagName("head")[0] || document.documentElement; var script = document.createElement("script"); script.src = url; var completed = false; var events = { done: function (){} // placeholder function }; // Attach handlers for all browsers script.onload = script.onreadystatechange = function() { if ( !completed && (!this.readyState || this.readyState === "loaded" || this.readyState === "complete") ) { events.done(); head.removeChild(script); } }; setTimeout(function() { head.insertBefore(script, head.firstChild); }, 0); // allows return to execute first return { done: function (cb) { events.done = function() { if (cb) { setTimeout(cb,0); } }; } }; }; var buildInfo = { buildFromMethodHash: function (obj) { var key; for(key in obj) { if (obj.hasOwnProperty(key)) { obj[key] = buildInfo[obj[key]](); } } return obj; }, timeZoneDST: function () { var DST = { "CHADT": "+1345", "NZDT": "+1300", "AEDT": "+1100", "ACDT": "+1030", "AZST": "+0500", "IRDT": "+0430", "EEST": "+0300", "CEST": "+0200", "BST": "+0100", "PMDT": "-0200", "ADT": "-0300", "NDT": "-0230", "EDT": "-0400", "CDT": "-0500", "MDT": "-0600", "PDT": "-0700", "AKDT": "-0800", "HADT": "-0900" }; return __(DST); }, timeZoneStandard: function () { var standard = { "LINT": "+1400", "TOT": "+1300", "CHAST": "+1245", "NZST": "+1200", "NFT": "+1130", "SBT": "+1100", "AEST": "+1000", "ACST": "+0930", "JST": "+0900", "CWST": "+0845", "CT": "+0800", "ICT": "+0700", "MMT": "+0630", "BST": "+0600", "NPT": "+0545", "IST": "+0530", "PKT": "+0500", "AFT": "+0430", "MSK": "+0400", "IRST": "+0330", "FET": "+0300", "EET": "+0200", "CET": "+0100", "GMT": "+0000", "UTC": "+0000", "CVT": "-0100", "GST": "-0200", "BRT": "-0300", "NST": "-0330", "AST": "-0400", "EST": "-0500", "CST": "-0600", "MST": "-0700", "PST": "-0800", "AKST": "-0900", "MIT": "-0930", "HST": "-1000", "SST": "-1100", "BIT": "-1200" }; return __(standard); }, timeZones: function (data) { var zone; data.timezones = []; for (zone in data.abbreviatedTimeZoneStandard) { if (data.abbreviatedTimeZoneStandard.hasOwnProperty(zone)) { data.timezones.push({ name: zone, offset: data.abbreviatedTimeZoneStandard[zone]}); } } for (zone in data.abbreviatedTimeZoneDST) { if (data.abbreviatedTimeZoneDST.hasOwnProperty(zone)) { data.timezones.push({ name: zone, offset: data.abbreviatedTimeZoneDST[zone], dst: true}); } } return data.timezones; }, days: function () { return __(["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"]); }, dayAbbr: function () { return __(["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"]); }, dayShortNames: function () { return __(["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"]); }, dayFirstLetters: function () { return __(["S_Sun_Initial", "M_Mon_Initial", "T_Tues_Initial", "W_Wed_Initial", "T_Thu_Initial", "F_Fri_Initial", "S_Sat_Initial"]); }, months: function () { return __(["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"]); }, monthAbbr: function () { return __(["Jan_Abbr", "Feb_Abbr", "Mar_Abbr", "Apr_Abbr", "May_Abbr", "Jun_Abbr", "Jul_Abbr", "Aug_Abbr", "Sep_Abbr", "Oct_Abbr", "Nov_Abbr", "Dec_Abbr"]); }, formatPatterns: function () { return getText.getFromObjectValues({ shortDate: "M/d/yyyy", longDate: "dddd, MMMM dd, yyyy", shortTime: "h:mm tt", longTime: "h:mm:ss tt", fullDateTime: "dddd, MMMM dd, yyyy h:mm:ss tt", sortableDateTime: "yyyy-MM-ddTHH:mm:ss", universalSortableDateTime: "yyyy-MM-dd HH:mm:ssZ", rfc1123: "ddd, dd MMM yyyy HH:mm:ss", monthDay: "MMMM dd", yearMonth: "MMMM, yyyy" }, Date.i18n.currentLanguage()); }, regex: function () { return getText.getFromObjectValues({ inTheMorning: "/( in the )(morn(ing)?)\\b/", thisMorning: "/(this )(morn(ing)?)\\b/", amThisMorning: "/(\b\\d(am)? )(this )(morn(ing)?)/", inTheEvening: "/( in the )(even(ing)?)\\b/", thisEvening: "/(this )(even(ing)?)\\b/", pmThisEvening: "/(\b\\d(pm)? )(this )(even(ing)?)/", jan: "/jan(uary)?/", feb: "/feb(ruary)?/", mar: "/mar(ch)?/", apr: "/apr(il)?/", may: "/may/", jun: "/jun(e)?/", jul: "/jul(y)?/", aug: "/aug(ust)?/", sep: "/sep(t(ember)?)?/", oct: "/oct(ober)?/", nov: "/nov(ember)?/", dec: "/dec(ember)?/", sun: "/^su(n(day)?)?/", mon: "/^mo(n(day)?)?/", tue: "/^tu(e(s(day)?)?)?/", wed: "/^we(d(nesday)?)?/", thu: "/^th(u(r(s(day)?)?)?)?/", fri: "/fr(i(day)?)?/", sat: "/^sa(t(urday)?)?/", future: "/^next/", past: "/^last|past|prev(ious)?/", add: "/^(\\+|aft(er)?|from|hence)/", subtract: "/^(\\-|bef(ore)?|ago)/", yesterday: "/^yes(terday)?/", today: "/^t(od(ay)?)?/", tomorrow: "/^tom(orrow)?/", now: "/^n(ow)?/", millisecond: "/^ms|milli(second)?s?/", second: "/^sec(ond)?s?/", minute: "/^mn|min(ute)?s?/", hour: "/^h(our)?s?/", week: "/^w(eek)?s?/", month: "/^m(onth)?s?/", day: "/^d(ay)?s?/", year: "/^y(ear)?s?/", shortMeridian: "/^(a|p)/", longMeridian: "/^(a\\.?m?\\.?|p\\.?m?\\.?)/", timezone: "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/", ordinalSuffix: "/^\\s*(st|nd|rd|th)/", timeContext: "/^\\s*(\\:|a(?!u|p)|p)/" }, Date.i18n.currentLanguage()); } }; var CultureInfo = function () { var info = getText.getFromObjectValues({ name: "name", englishName: "englishName", nativeName: "nativeName", amDesignator: "AM", pmDesignator: "PM", firstDayOfWeek: "firstDayOfWeek", twoDigitYearMax: "twoDigitYearMax", dateElementOrder: "mdy" }, Date.i18n.currentLanguage()); var constructedInfo = buildInfo.buildFromMethodHash({ dayNames: "days", abbreviatedDayNames: "dayAbbr", shortestDayNames: "dayShortNames", firstLetterDayNames: "dayFirstLetters", monthNames: "months", abbreviatedMonthNames: "monthAbbr", formatPatterns: "formatPatterns", regexPatterns: "regex", abbreviatedTimeZoneDST: "timeZoneDST", abbreviatedTimeZoneStandard: "timeZoneStandard" }); shallowMerge(info, constructedInfo); buildInfo.timeZones(info); return info; }; $D.i18n = { __: function (key, lang) { return __(key, lang); }, currentLanguage: function () { return lang || "en-US"; }, setLanguage: function (code, force, cb) { var async = false; if (force || code === "en-US" || (!!Date.CultureStrings && !!Date.CultureStrings[code])) { lang = code; Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings.lang = code; Date.CultureInfo = new CultureInfo(); } else { if (!(!!Date.CultureStrings && !!Date.CultureStrings[code])) { if (typeof exports !== "undefined" && this.exports !== exports) { // we're in a Node enviroment, load it using require try { require("../i18n/" + code + ".js"); lang = code; Date.CultureStrings.lang = code; Date.CultureInfo = new CultureInfo(); } catch (e) { // var str = "The language for '" + code + "' could not be loaded by Node. It likely does not exist."; throw new Error("The DateJS IETF language tag '" + code + "' could not be loaded by Node. It likely does not exist."); } } else if (Date.Config && Date.Config.i18n) { // we know the location of the files, so lets load them async = true; loadI18nScript(code).done(function(){ lang = code; Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings.lang = code; Date.CultureInfo = new CultureInfo(); $D.Parsing.Normalizer.buildReplaceData(); // because this is async if ($D.Grammar) { $D.Grammar.buildGrammarFormats(); // so we can parse those strings... } if (cb) { setTimeout(cb,0); } }); } else { Date.console.error("The DateJS IETF language tag '" + code + "' is not available and has not been loaded."); return false; } } } $D.Parsing.Normalizer.buildReplaceData(); // rebuild normalizer strings if ($D.Grammar) { $D.Grammar.buildGrammarFormats(); // so we can parse those strings... } if (!async && cb) { setTimeout(cb,0); } }, getLoggedKeys: function () { return loggedKeys; }, updateCultureInfo: function () { Date.CultureInfo = new CultureInfo(); } }; $D.i18n.updateCultureInfo(); // run automatically }()); (function () { var $D = Date, $P = $D.prototype, p = function (s, l) { if (!l) { l = 2; } return ("000" + s).slice(l * -1); }; if (typeof window !== "undefined" && typeof window.console !== "undefined" && typeof window.console.log !== "undefined") { $D.console = console; // used only to raise non-critical errors if available } else { // set mock so we don't give errors. $D.console = { log: function(){}, error: function(){} }; } $D.Config = $D.Config || {}; $D.initOverloads = function() { /** * Overload of Date.now. Allows an alternate call for Date.now where it returns the * current Date as an object rather than just milliseconds since the Unix Epoch. * * Also provides an implementation of now() for browsers (IE<9) that don't have it. * * Backwards compatible so with work with either: * Date.now() [returns ms] * or * Date.now(true) [returns Date] */ if (!$D.now) { $D._now = function now() { return new Date().getTime(); }; } else if (!$D._now) { $D._now = $D.now; } $D.now = function (returnObj) { if (returnObj) { return $D.present(); } else { return $D._now(); } }; if ( !$P.toISOString ) { $P.toISOString = function() { return this.getUTCFullYear() + "-" + p(this.getUTCMonth() + 1) + "-" + p(this.getUTCDate()) + "T" + p(this.getUTCHours()) + ":" + p(this.getUTCMinutes()) + ":" + p(this.getUTCSeconds()) + "." + String( (this.getUTCMilliseconds()/1000).toFixed(3)).slice(2, 5) + "Z"; }; } // private if ( $P._toString === undefined ){ $P._toString = $P.toString; } }; $D.initOverloads(); /** * Gets a date that is set to the current date. The time is set to the start of the day (00:00 or 12:00 AM). * @return {Date} The current date. */ $D.today = function () { return new Date().clearTime(); }; /** * Gets a date that is set to the current date and time (same as new Date, but chainable) * @return {Date} The current date. */ $D.present = function () { return new Date(); }; /** * Compares the first date to the second date and returns an number indication of their relative values. * @param {Date} First Date object to compare [Required]. * @param {Date} Second Date object to compare to [Required]. * @return {Number} -1 = date1 is lessthan date2. 0 = values are equal. 1 = date1 is greaterthan date2. */ $D.compare = function (date1, date2) { if (isNaN(date1) || isNaN(date2)) { throw new Error(date1 + " - " + date2); } else if (date1 instanceof Date && date2 instanceof Date) { return (date1 < date2) ? -1 : (date1 > date2) ? 1 : 0; } else { throw new TypeError(date1 + " - " + date2); } }; /** * Compares the first Date object to the second Date object and returns true if they are equal. * @param {Date} First Date object to compare [Required] * @param {Date} Second Date object to compare to [Required] * @return {Boolean} true if dates are equal. false if they are not equal. */ $D.equals = function (date1, date2) { return (date1.compareTo(date2) === 0); }; /** * Gets the language appropriate day name when given the day number(0-6) * eg - 0 == Sunday * @return {String} The day name */ $D.getDayName = function (n) { return Date.CultureInfo.dayNames[n]; }; /** * Gets the day number (0-6) if given a CultureInfo specific string which is a valid dayName, abbreviatedDayName or shortestDayName (two char). * @param {String} The name of the day (eg. "Monday, "Mon", "tuesday", "tue", "We", "we"). * @return {Number} The day number */ $D.getDayNumberFromName = function (name) { var n = Date.CultureInfo.dayNames, m = Date.CultureInfo.abbreviatedDayNames, o = Date.CultureInfo.shortestDayNames, s = name.toLowerCase(); for (var i = 0; i < n.length; i++) { if (n[i].toLowerCase() === s || m[i].toLowerCase() === s || o[i].toLowerCase() === s) { return i; } } return -1; }; /** * Gets the month number (0-11) if given a Culture Info specific string which is a valid monthName or abbreviatedMonthName. * @param {String} The name of the month (eg. "February, "Feb", "october", "oct"). * @return {Number} The day number */ $D.getMonthNumberFromName = function (name) { var n = Date.CultureInfo.monthNames, m = Date.CultureInfo.abbreviatedMonthNames, s = name.toLowerCase(); for (var i = 0; i < n.length; i++) { if (n[i].toLowerCase() === s || m[i].toLowerCase() === s) { return i; } } return -1; }; /** * Gets the language appropriate month name when given the month number(0-11) * eg - 0 == January * @return {String} The month name */ $D.getMonthName = function (n) { return Date.CultureInfo.monthNames[n]; }; /** * Determines if the current date instance is within a LeapYear. * @param {Number} The year. * @return {Boolean} true if date is within a LeapYear, otherwise false. */ $D.isLeapYear = function (year) { return ((year % 4 === 0 && year % 100 !== 0) || year % 400 === 0); }; /** * Gets the number of days in the month, given a year and month value. Automatically corrects for LeapYear. * @param {Number} The year. * @param {Number} The month (0-11). * @return {Number} The number of days in the month. */ $D.getDaysInMonth = function (year, month) { if (!month && $D.validateMonth(year)) { month = year; year = Date.today().getFullYear(); } return [31, ($D.isLeapYear(year) ? 29 : 28), 31, 30, 31, 30, 31, 31, 30, 31, 30, 31][month]; }; $P.getDaysInMonth = function () { return $D.getDaysInMonth(this.getFullYear(), this.getMonth()); }; $D.getTimezoneAbbreviation = function (offset, dst) { var p, n = (dst || false) ? Date.CultureInfo.abbreviatedTimeZoneDST : Date.CultureInfo.abbreviatedTimeZoneStandard; for (p in n) { if (n.hasOwnProperty(p)) { if (n[p] === offset) { return p; } } } return null; }; $D.getTimezoneOffset = function (name, dst) { var i, a =[], z = Date.CultureInfo.timezones; if (!name) { name = (new Date()).getTimezone();} for (i = 0; i < z.length; i++) { if (z[i].name === name.toUpperCase()) { a.push(i); } } if (!z[a[0]]) { return null; } if (a.length === 1 || !dst) { return z[a[0]].offset; } else { for (i=0; i < a.length; i++) { if (z[a[i]].dst) { return z[a[i]].offset; } } } }; $D.getQuarter = function (d) { d = d || new Date(); // If no date supplied, use today var q = [1,2,3,4]; return q[Math.floor(d.getMonth() / 3)]; // ~~~ is a bitwise op. Faster than Math.floor }; $D.getDaysLeftInQuarter = function (d) { d = d || new Date(); var qEnd = new Date(d); qEnd.setMonth(qEnd.getMonth() + 3 - qEnd.getMonth() % 3, 0); return Math.floor((qEnd - d) / 8.64e7); }; // private var validate = function (n, min, max, name) { name = name ? name : "Object"; if (typeof n === "undefined") { return false; } else if (typeof n !== "number") { throw new TypeError(n + " is not a Number."); } else if (n < min || n > max) { // As failing validation is *not* an exceptional circumstance // lets not throw a RangeError Exception here. // It's semantically correct but it's not sensible. return false; } return true; }; /** * Validates the number is within an acceptable range for milliseconds [0-999]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateMillisecond = function (value) { return validate(value, 0, 999, "millisecond"); }; /** * Validates the number is within an acceptable range for seconds [0-59]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateSecond = function (value) { return validate(value, 0, 59, "second"); }; /** * Validates the number is within an acceptable range for minutes [0-59]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateMinute = function (value) { return validate(value, 0, 59, "minute"); }; /** * Validates the number is within an acceptable range for hours [0-23]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateHour = function (value) { return validate(value, 0, 23, "hour"); }; /** * Validates the number is within an acceptable range for the days in a month [0-MaxDaysInMonth]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateDay = function (value, year, month) { if (year === undefined || year === null || month === undefined || month === null) { return false;} return validate(value, 1, $D.getDaysInMonth(year, month), "day"); }; /** * Validates the number is within an acceptable range for months [0-11]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateWeek = function (value) { return validate(value, 0, 53, "week"); }; /** * Validates the number is within an acceptable range for months [0-11]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateMonth = function (value) { return validate(value, 0, 11, "month"); }; /** * Validates the number is within an acceptable range for years. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateYear = function (value) { /** * Per ECMAScript spec the range of times supported by Date objects is * exactly -100,000,000 days to +100,000,000 days measured relative to * midnight at the beginning of 01 January, 1970 UTC. * This gives a range of 8,640,000,000,000,000 milliseconds to either * side of 01 January, 1970 UTC. * * Earliest possible date: Tue, 20 Apr 271,822 B.C. 00:00:00 UTC * Latest possible date: Sat, 13 Sep 275,760 00:00:00 UTC */ return validate(value, -271822, 275760, "year"); }; $D.validateTimezone = function(value) { var timezones = {"ACDT":1,"ACST":1,"ACT":1,"ADT":1,"AEDT":1,"AEST":1,"AFT":1,"AKDT":1,"AKST":1,"AMST":1,"AMT":1,"ART":1,"AST":1,"AWDT":1,"AWST":1,"AZOST":1,"AZT":1,"BDT":1,"BIOT":1,"BIT":1,"BOT":1,"BRT":1,"BST":1,"BTT":1,"CAT":1,"CCT":1,"CDT":1,"CEDT":1,"CEST":1,"CET":1,"CHADT":1,"CHAST":1,"CHOT":1,"ChST":1,"CHUT":1,"CIST":1,"CIT":1,"CKT":1,"CLST":1,"CLT":1,"COST":1,"COT":1,"CST":1,"CT":1,"CVT":1,"CWST":1,"CXT":1,"DAVT":1,"DDUT":1,"DFT":1,"EASST":1,"EAST":1,"EAT":1,"ECT":1,"EDT":1,"EEDT":1,"EEST":1,"EET":1,"EGST":1,"EGT":1,"EIT":1,"EST":1,"FET":1,"FJT":1,"FKST":1,"FKT":1,"FNT":1,"GALT":1,"GAMT":1,"GET":1,"GFT":1,"GILT":1,"GIT":1,"GMT":1,"GST":1,"GYT":1,"HADT":1,"HAEC":1,"HAST":1,"HKT":1,"HMT":1,"HOVT":1,"HST":1,"ICT":1,"IDT":1,"IOT":1,"IRDT":1,"IRKT":1,"IRST":1,"IST":1,"JST":1,"KGT":1,"KOST":1,"KRAT":1,"KST":1,"LHST":1,"LINT":1,"MAGT":1,"MART":1,"MAWT":1,"MDT":1,"MET":1,"MEST":1,"MHT":1,"MIST":1,"MIT":1,"MMT":1,"MSK":1,"MST":1,"MUT":1,"MVT":1,"MYT":1,"NCT":1,"NDT":1,"NFT":1,"NPT":1,"NST":1,"NT":1,"NUT":1,"NZDT":1,"NZST":1,"OMST":1,"ORAT":1,"PDT":1,"PET":1,"PETT":1,"PGT":1,"PHOT":1,"PHT":1,"PKT":1,"PMDT":1,"PMST":1,"PONT":1,"PST":1,"PYST":1,"PYT":1,"RET":1,"ROTT":1,"SAKT":1,"SAMT":1,"SAST":1,"SBT":1,"SCT":1,"SGT":1,"SLST":1,"SRT":1,"SST":1,"SYOT":1,"TAHT":1,"THA":1,"TFT":1,"TJT":1,"TKT":1,"TLT":1,"TMT":1,"TOT":1,"TVT":1,"UCT":1,"ULAT":1,"UTC":1,"UYST":1,"UYT":1,"UZT":1,"VET":1,"VLAT":1,"VOLT":1,"VOST":1,"VUT":1,"WAKT":1,"WAST":1,"WAT":1,"WEDT":1,"WEST":1,"WET":1,"WST":1,"YAKT":1,"YEKT":1,"Z":1}; return (timezones[value] === 1); }; $D.validateTimezoneOffset= function(value) { // timezones go from +14hrs to -12hrs, the +X hours are negative offsets. return (value > -841 && value < 721); }; }()); (function () { var $D = Date, $P = $D.prototype, p = function (s, l) { if (!l) { l = 2; } return ("000" + s).slice(l * -1); }; var validateConfigObject = function (obj) { var result = {}, self = this, prop, testFunc; testFunc = function (prop, func, value) { if (prop === "day") { var month = (obj.month !== undefined) ? obj.month : self.getMonth(); var year = (obj.year !== undefined) ? obj.year : self.getFullYear(); return $D[func](value, year, month); } else { return $D[func](value); } }; for (prop in obj) { if (Object.prototype.hasOwnProperty.call(obj, prop)) { var func = "validate" + prop.charAt(0).toUpperCase() + prop.slice(1); if ($D[func] && obj[prop] !== null && testFunc(prop, func, obj[prop])) { result[prop] = obj[prop]; } } } return result; }; /** * Resets the time of this Date object to 12:00 AM (00:00), which is the start of the day. * @param {Boolean} .clone() this date instance before clearing Time * @return {Date} this */ $P.clearTime = function () { this.setHours(0); this.setMinutes(0); this.setSeconds(0); this.setMilliseconds(0); return this; }; /** * Resets the time of this Date object to the current time ('now'). * @return {Date} this */ $P.setTimeToNow = function () { var n = new Date(); this.setHours(n.getHours()); this.setMinutes(n.getMinutes()); this.setSeconds(n.getSeconds()); this.setMilliseconds(n.getMilliseconds()); return this; }; /** * Returns a new Date object that is an exact date and time copy of the original instance. * @return {Date} A new Date instance */ $P.clone = function () { return new Date(this.getTime()); }; /** * Compares this instance to a Date object and returns an number indication of their relative values. * @param {Date} Date object to compare [Required] * @return {Number} -1 = this is lessthan date. 0 = values are equal. 1 = this is greaterthan date. */ $P.compareTo = function (date) { return Date.compare(this, date); }; /** * Compares this instance to another Date object and returns true if they are equal. * @param {Date} Date object to compare. If no date to compare, new Date() [now] is used. * @return {Boolean} true if dates are equal. false if they are not equal. */ $P.equals = function (date) { return Date.equals(this, (date !== undefined ? date : new Date())); }; /** * Determines if this instance is between a range of two dates or equal to either the start or end dates. * @param {Date} Start of range [Required] * @param {Date} End of range [Required] * @return {Boolean} true is this is between or equal to the start and end dates, else false */ $P.between = function (start, end) { return this.getTime() >= start.getTime() && this.getTime() <= end.getTime(); }; /** * Determines if this date occurs after the date to compare to. * @param {Date} Date object to compare. If no date to compare, new Date() ("now") is used. * @return {Boolean} true if this date instance is greater than the date to compare to (or "now"), otherwise false. */ $P.isAfter = function (date) { return this.compareTo(date || new Date()) === 1; }; /** * Determines if this date occurs before the date to compare to. * @param {Date} Date object to compare. If no date to compare, new Date() ("now") is used. * @return {Boolean} true if this date instance is less than the date to compare to (or "now"). */ $P.isBefore = function (date) { return (this.compareTo(date || new Date()) === -1); }; /** * Determines if the current Date instance occurs today. * @return {Boolean} true if this date instance is 'today', otherwise false. */ /** * Determines if the current Date instance occurs on the same Date as the supplied 'date'. * If no 'date' to compare to is provided, the current Date instance is compared to 'today'. * @param {date} Date object to compare. If no date to compare, the current Date ("now") is used. * @return {Boolean} true if this Date instance occurs on the same Day as the supplied 'date'. */ $P.isToday = $P.isSameDay = function (date) { return this.clone().clearTime().equals((date || new Date()).clone().clearTime()); }; /** * Adds the specified number of milliseconds to this instance. * @param {Number} The number of milliseconds to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addMilliseconds = function (value) { if (!value) { return this; } this.setTime(this.getTime() + value * 1); return this; }; /** * Adds the specified number of seconds to this instance. * @param {Number} The number of seconds to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addSeconds = function (value) { if (!value) { return this; } return this.addMilliseconds(value * 1000); }; /** * Adds the specified number of seconds to this instance. * @param {Number} The number of seconds to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addMinutes = function (value) { if (!value) { return this; } return this.addMilliseconds(value * 60000); // 60*1000 }; /** * Adds the specified number of hours to this instance. * @param {Number} The number of hours to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addHours = function (value) { if (!value) { return this; } return this.addMilliseconds(value * 3600000); // 60*60*1000 }; /** * Adds the specified number of days to this instance. * @param {Number} The number of days to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addDays = function (value) { if (!value) { return this; } this.setDate(this.getDate() + value * 1); return this; }; /** * Adds the specified number of weekdays (ie - not sat or sun) to this instance. * @param {Number} The number of days to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addWeekdays = function (value) { if (!value) { return this; } var day = this.getDay(); var weeks = (Math.ceil(Math.abs(value)/7)); if (day === 0 || day === 6) { if (value > 0) { this.next().monday(); this.addDays(-1); day = this.getDay(); } } if (value < 0) { while (value < 0) { this.addDays(-1); day = this.getDay(); if (day !== 0 && day !== 6) { value++; } } return this; } else if (value > 5 || (6-day) <= value) { value = value + (weeks * 2); } return this.addDays(value); }; /** * Adds the specified number of weeks to this instance. * @param {Number} The number of weeks to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addWeeks = function (value) { if (!value) { return this; } return this.addDays(value * 7); }; /** * Adds the specified number of months to this instance. * @param {Number} The number of months to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addMonths = function (value) { if (!value) { return this; } var n = this.getDate(); this.setDate(1); this.setMonth(this.getMonth() + value * 1); this.setDate(Math.min(n, $D.getDaysInMonth(this.getFullYear(), this.getMonth()))); return this; }; $P.addQuarters = function (value) { if (!value) { return this; } // note this will take you to the same point in the quarter as you are now. // i.e. - if you are 15 days into the quarter you'll be 15 days into the resulting one. // bonus: this allows adding fractional quarters return this.addMonths(value * 3); }; /** * Adds the specified number of years to this instance. * @param {Number} The number of years to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addYears = function (value) { if (!value) { return this; } return this.addMonths(value * 12); }; /** * Adds (or subtracts) to the value of the years, months, weeks, days, hours, minutes, seconds, milliseconds of the date instance using given configuration object. Positive and Negative values allowed. * Example

	Date.today().add( { days: 1, months: 1 } )

	new Date().add( { years: -1 } )
	
* @param {Object} Configuration object containing attributes (months, days, etc.) * @return {Date} this */ $P.add = function (config) { if (typeof config === "number") { this._orient = config; return this; } var x = config; if (x.day) { // If we should be a different date than today (eg: for 'tomorrow -1d', etc). // Should only effect parsing, not direct usage (eg, Finish and FinishExact) if ((x.day - this.getDate()) !== 0) { this.setDate(x.day); } } if (x.milliseconds) { this.addMilliseconds(x.milliseconds); } if (x.seconds) { this.addSeconds(x.seconds); } if (x.minutes) { this.addMinutes(x.minutes); } if (x.hours) { this.addHours(x.hours); } if (x.weeks) { this.addWeeks(x.weeks); } if (x.months) { this.addMonths(x.months); } if (x.years) { this.addYears(x.years); } if (x.days) { this.addDays(x.days); } return this; }; /** * Get the week number. Week one (1) is the week which contains the first Thursday of the year. Monday is considered the first day of the week. * The .getWeek() function does NOT convert the date to UTC. The local datetime is used. * Please use .getISOWeek() to get the week of the UTC converted date. * @return {Number} 1 to 53 */ $P.getWeek = function (utc) { // Create a copy of this date object var self, target = new Date(this.valueOf()); if (utc) { target.addMinutes(target.getTimezoneOffset()); self = target.clone(); } else { self = this; } // ISO week date weeks start on monday // so correct the day number var dayNr = (self.getDay() + 6) % 7; // ISO 8601 states that week 1 is the week // with the first thursday of that year. // Set the target date to the thursday in the target week target.setDate(target.getDate() - dayNr + 3); // Store the millisecond value of the target date var firstThursday = target.valueOf(); // Set the target to the first thursday of the year // First set the target to january first target.setMonth(0, 1); // Not a thursday? Correct the date to the next thursday if (target.getDay() !== 4) { target.setMonth(0, 1 + ((4 - target.getDay()) + 7) % 7); } // The weeknumber is the number of weeks between the // first thursday of the year and the thursday in the target week return 1 + Math.ceil((firstThursday - target) / 604800000); // 604800000 = 7 * 24 * 3600 * 1000 }; /** * Get the ISO 8601 week number. Week one ("01") is the week which contains the first Thursday of the year. Monday is considered the first day of the week. * The .getISOWeek() function does convert the date to it's UTC value. Please use .getWeek() to get the week of the local date. * @return {String} "01" to "53" */ $P.getISOWeek = function () { return p(this.getWeek(true)); }; /** * Moves the date to Monday of the week set. Week one (1) is the week which contains the first Thursday of the year. * @param {Number} A Number (1 to 53) that represents the week of the year. * @return {Date} this */ $P.setWeek = function (n) { if ((n - this.getWeek()) === 0) { if (this.getDay() !== 1) { return this.moveToDayOfWeek(1, (this.getDay() > 1 ? -1 : 1)); } else { return this; } } else { return this.moveToDayOfWeek(1, (this.getDay() > 1 ? -1 : 1)).addWeeks(n - this.getWeek()); } }; $P.setQuarter = function (qtr) { var month = Math.abs(((qtr-1) * 3) + 1); return this.setMonth(month, 1); }; $P.getQuarter = function () { return Date.getQuarter(this); }; $P.getDaysLeftInQuarter = function () { return Date.getDaysLeftInQuarter(this); }; /** * Moves the date to the next n'th occurrence of the dayOfWeek starting from the beginning of the month. The number (-1) is a magic number and will return the last occurrence of the dayOfWeek in the month. * @param {Number} The dayOfWeek to move to * @param {Number} The n'th occurrence to move to. Use (-1) to return the last occurrence in the month * @return {Date} this */ $P.moveToNthOccurrence = function (dayOfWeek, occurrence) { if (dayOfWeek === "Weekday") { if (occurrence > 0) { this.moveToFirstDayOfMonth(); if (this.is().weekday()) { occurrence -= 1; } } else if (occurrence < 0) { this.moveToLastDayOfMonth(); if (this.is().weekday()) { occurrence += 1; } } else { return this; } return this.addWeekdays(occurrence); } var shift = 0; if (occurrence > 0) { shift = occurrence - 1; } else if (occurrence === -1) { this.moveToLastDayOfMonth(); if (this.getDay() !== dayOfWeek) { this.moveToDayOfWeek(dayOfWeek, -1); } return this; } return this.moveToFirstDayOfMonth().addDays(-1).moveToDayOfWeek(dayOfWeek, +1).addWeeks(shift); }; var moveToN = function (getFunc, addFunc, nVal) { return function (value, orient) { var diff = (value - this[getFunc]() + nVal * (orient || +1)) % nVal; return this[addFunc]((diff === 0) ? diff += nVal * (orient || +1) : diff); }; }; /** * Move to the next or last dayOfWeek based on the orient value. * @param {Number} The dayOfWeek to move to * @param {Number} Forward (+1) or Back (-1). Defaults to +1. [Optional] * @return {Date} this */ $P.moveToDayOfWeek = moveToN("getDay", "addDays", 7); /** * Move to the next or last month based on the orient value. * @param {Number} The month to move to. 0 = January, 11 = December * @param {Number} Forward (+1) or Back (-1). Defaults to +1. [Optional] * @return {Date} this */ $P.moveToMonth = moveToN("getMonth", "addMonths", 12); /** * Get the Ordinate of the current day ("th", "st", "rd"). * @return {String} */ $P.getOrdinate = function () { var num = this.getDate(); return ord(num); }; /** * Get the Ordinal day (numeric day number) of the year, adjusted for leap year. * @return {Number} 1 through 365 (366 in leap years) */ $P.getOrdinalNumber = function () { return Math.ceil((this.clone().clearTime() - new Date(this.getFullYear(), 0, 1)) / 86400000) + 1; }; /** * Get the time zone abbreviation of the current date. * @return {String} The abbreviated time zone name (e.g. "EST") */ $P.getTimezone = function () { return $D.getTimezoneAbbreviation(this.getUTCOffset(), this.isDaylightSavingTime()); }; $P.setTimezoneOffset = function (offset) { var here = this.getTimezoneOffset(), there = Number(offset) * -6 / 10; return (there || there === 0) ? this.addMinutes(there - here) : this; }; $P.setTimezone = function (offset) { return this.setTimezoneOffset($D.getTimezoneOffset(offset)); }; /** * Indicates whether Daylight Saving Time is observed in the current time zone. * @return {Boolean} true|false */ $P.hasDaylightSavingTime = function () { return (Date.today().set({month: 0, day: 1}).getTimezoneOffset() !== Date.today().set({month: 6, day: 1}).getTimezoneOffset()); }; /** * Indicates whether this Date instance is within the Daylight Saving Time range for the current time zone. * @return {Boolean} true|false */ $P.isDaylightSavingTime = function () { return Date.today().set({month: 0, day: 1}).getTimezoneOffset() !== this.getTimezoneOffset(); }; /** * Get the offset from UTC of the current date. * @return {String} The 4-character offset string prefixed with + or - (e.g. "-0500") */ $P.getUTCOffset = function (offset) { var n = (offset || this.getTimezoneOffset()) * -10 / 6, r; if (n < 0) { r = (n - 10000).toString(); return r.charAt(0) + r.substr(2); } else { r = (n + 10000).toString(); return "+" + r.substr(1); } }; /** * Returns the number of milliseconds between this date and date. * @param {Date} Defaults to now * @return {Number} The diff in milliseconds */ $P.getElapsed = function (date) { return (date || new Date()) - this; }; /** * Set the value of year, month, day, hour, minute, second, millisecond of date instance using given configuration object. * Example

	Date.today().set( { day: 20, month: 1 } )

	new Date().set( { millisecond: 0 } )
	
* * @param {Object} Configuration object containing attributes (month, day, etc.) * @return {Date} this */ $P.set = function (config) { config = validateConfigObject.call(this, config); var key; for (key in config) { if (Object.prototype.hasOwnProperty.call(config, key)) { var name = key.charAt(0).toUpperCase() + key.slice(1); var addFunc, getFunc; if (key !== "week" && key !== "month" && key !== "timezone" && key !== "timezoneOffset") { name += "s"; } addFunc = "add" + name; getFunc = "get" + name; if (key === "month") { addFunc = addFunc + "s"; } else if (key === "year"){ getFunc = "getFullYear"; } if (key !== "day" && key !== "timezone" && key !== "timezoneOffset" && key !== "week" && key !== "hour") { this[addFunc](config[key] - this[getFunc]()); } else if ( key === "timezone"|| key === "timezoneOffset" || key === "week" || key === "hour") { this["set"+name](config[key]); } } } // day has to go last because you can't validate the day without first knowing the month if (config.day) { this.addDays(config.day - this.getDate()); } return this; }; /** * Moves the date to the first day of the month. * @return {Date} this */ $P.moveToFirstDayOfMonth = function () { return this.set({ day: 1 }); }; /** * Moves the date to the last day of the month. * @return {Date} this */ $P.moveToLastDayOfMonth = function () { return this.set({ day: $D.getDaysInMonth(this.getFullYear(), this.getMonth())}); }; /** * Converts the value of the current Date object to its equivalent string representation. * Format Specifiers * CUSTOM DATE AND TIME FORMAT STRINGS * Format Description Example * ------ --------------------------------------------------------------------------- ----------------------- * s The seconds of the minute between 0-59. "0" to "59" * ss The seconds of the minute with leading zero if required. "00" to "59" * * m The minute of the hour between 0-59. "0" or "59" * mm The minute of the hour with leading zero if required. "00" or "59" * * h The hour of the day between 1-12. "1" to "12" * hh The hour of the day with leading zero if required. "01" to "12" * * H The hour of the day between 0-23. "0" to "23" * HH The hour of the day with leading zero if required. "00" to "23" * * d The day of the month between 1 and 31. "1" to "31" * dd The day of the month with leading zero if required. "01" to "31" * ddd Abbreviated day name. Date.CultureInfo.abbreviatedDayNames. "Mon" to "Sun" * dddd The full day name. Date.CultureInfo.dayNames. "Monday" to "Sunday" * * M The month of the year between 1-12. "1" to "12" * MM The month of the year with leading zero if required. "01" to "12" * MMM Abbreviated month name. Date.CultureInfo.abbreviatedMonthNames. "Jan" to "Dec" * MMMM The full month name. Date.CultureInfo.monthNames. "January" to "December" * * yy The year as a two-digit number. "99" or "08" * yyyy The full four digit year. "1999" or "2008" * * t Displays the first character of the A.M./P.M. designator. "A" or "P" * Date.CultureInfo.amDesignator or Date.CultureInfo.pmDesignator * tt Displays the A.M./P.M. designator. "AM" or "PM" * Date.CultureInfo.amDesignator or Date.CultureInfo.pmDesignator * * S The ordinal suffix ("st, "nd", "rd" or "th") of the current day. "st, "nd", "rd" or "th" * * STANDARD DATE AND TIME FORMAT STRINGS * Format Description Example *------ --------------------------------------------------------------------------- ----------------------- * d The CultureInfo shortDate Format Pattern "M/d/yyyy" * D The CultureInfo longDate Format Pattern "dddd, MMMM dd, yyyy" * F The CultureInfo fullDateTime Format Pattern "dddd, MMMM dd, yyyy h:mm:ss tt" * m The CultureInfo monthDay Format Pattern "MMMM dd" * r The CultureInfo rfc1123 Format Pattern "ddd, dd MMM yyyy HH:mm:ss GMT" * s The CultureInfo sortableDateTime Format Pattern "yyyy-MM-ddTHH:mm:ss" * t The CultureInfo shortTime Format Pattern "h:mm tt" * T The CultureInfo longTime Format Pattern "h:mm:ss tt" * u The CultureInfo universalSortableDateTime Format Pattern "yyyy-MM-dd HH:mm:ssZ" * y The CultureInfo yearMonth Format Pattern "MMMM, yyyy" * * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @return {String} A string representation of the current Date object. */ var ord = function (n) { switch (n * 1) { case 1: case 21: case 31: return "st"; case 2: case 22: return "nd"; case 3: case 23: return "rd"; default: return "th"; } }; var parseStandardFormats = function (format) { var y, c = Date.CultureInfo.formatPatterns; switch (format) { case "d": return this.toString(c.shortDate); case "D": return this.toString(c.longDate); case "F": return this.toString(c.fullDateTime); case "m": return this.toString(c.monthDay); case "r": case "R": y = this.clone().addMinutes(this.getTimezoneOffset()); return y.toString(c.rfc1123) + " GMT"; case "s": return this.toString(c.sortableDateTime); case "t": return this.toString(c.shortTime); case "T": return this.toString(c.longTime); case "u": y = this.clone().addMinutes(this.getTimezoneOffset()); return y.toString(c.universalSortableDateTime); case "y": return this.toString(c.yearMonth); default: return false; } }; var parseFormatStringsClosure = function (context) { return function (m) { if (m.charAt(0) === "\\") { return m.replace("\\", ""); } switch (m) { case "hh": return p(context.getHours() < 13 ? (context.getHours() === 0 ? 12 : context.getHours()) : (context.getHours() - 12)); case "h": return context.getHours() < 13 ? (context.getHours() === 0 ? 12 : context.getHours()) : (context.getHours() - 12); case "HH": return p(context.getHours()); case "H": return context.getHours(); case "mm": return p(context.getMinutes()); case "m": return context.getMinutes(); case "ss": return p(context.getSeconds()); case "s": return context.getSeconds(); case "yyyy": return p(context.getFullYear(), 4); case "yy": return p(context.getFullYear()); case "y": return context.getFullYear(); case "E": case "dddd": return Date.CultureInfo.dayNames[context.getDay()]; case "ddd": return Date.CultureInfo.abbreviatedDayNames[context.getDay()]; case "dd": return p(context.getDate()); case "d": return context.getDate(); case "MMMM": return Date.CultureInfo.monthNames[context.getMonth()]; case "MMM": return Date.CultureInfo.abbreviatedMonthNames[context.getMonth()]; case "MM": return p((context.getMonth() + 1)); case "M": return context.getMonth() + 1; case "t": return context.getHours() < 12 ? Date.CultureInfo.amDesignator.substring(0, 1) : Date.CultureInfo.pmDesignator.substring(0, 1); case "tt": return context.getHours() < 12 ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator; case "S": return ord(context.getDate()); case "W": return context.getWeek(); case "WW": return context.getISOWeek(); case "Q": return "Q" + context.getQuarter(); case "q": return String(context.getQuarter()); case "z": return context.getTimezone(); case "Z": case "X": return Date.getTimezoneOffset(context.getTimezone()); case "ZZ": // Timezone offset in seconds return context.getTimezoneOffset() * -60; case "u": return context.getDay(); case "L": return ($D.isLeapYear(context.getFullYear())) ? 1 : 0; case "B": // Swatch Internet Time (.beats) return "@"+((context.getUTCSeconds() + (context.getUTCMinutes()*60) + ((context.getUTCHours()+1)*3600))/86.4); default: return m; } }; }; $P.toString = function (format, ignoreStandards) { // Standard Date and Time Format Strings. Formats pulled from CultureInfo file and // may vary by culture. if (!ignoreStandards && format && format.length === 1) { output = parseStandardFormats.call(this, format); if (output) { return output; } } var parseFormatStrings = parseFormatStringsClosure(this); return format ? format.replace(/((\\)?(dd?d?d?|MM?M?M?|yy?y?y?|hh?|HH?|mm?|ss?|tt?|S|q|Q|WW?W?W?)(?![^\[]*\]))/g, parseFormatStrings).replace(/\[|\]/g, "") : this._toString(); }; }()); /************************************************************* * SugarPak - Domain Specific Language - Syntactical Sugar * *************************************************************/ (function () { var $D = Date, $P = $D.prototype, $N = Number.prototype; // private $P._orient = +1; // private $P._nth = null; // private $P._is = false; // private $P._same = false; // private $P._isSecond = false; // private $N._dateElement = "days"; /** * Moves the date to the next instance of a date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.today().next().friday();
	Date.today().next().fri();
	Date.today().next().march();
	Date.today().next().mar();
	Date.today().next().week();
	
* * @return {Date} date */ $P.next = function () { this._move = true; this._orient = +1; return this; }; /** * Creates a new Date (Date.today()) and moves the date to the next instance of the date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.next().friday();
	Date.next().fri();
	Date.next().march();
	Date.next().mar();
	Date.next().week();
	
* * @return {Date} date */ $D.next = function () { return $D.today().next(); }; /** * Moves the date to the previous instance of a date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.today().last().friday();
	Date.today().last().fri();
	Date.today().last().march();
	Date.today().last().mar();
	Date.today().last().week();
	
* * @return {Date} date */ $P.last = $P.prev = $P.previous = function () { this._move = true; this._orient = -1; return this; }; /** * Creates a new Date (Date.today()) and moves the date to the previous instance of the date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.last().friday();
	Date.last().fri();
	Date.previous().march();
	Date.prev().mar();
	Date.last().week();
	
* * @return {Date} date */ $D.last = $D.prev = $D.previous = function () { return $D.today().last(); }; /** * Performs a equality check when followed by either a month name, day name or .weekday() function. * Example

	Date.today().is().friday(); // true|false
	Date.today().is().fri();
	Date.today().is().march();
	Date.today().is().mar();
	
* * @return {Boolean} true|false */ $P.is = function () { this._is = true; return this; }; /** * Determines if two date objects occur on/in exactly the same instance of the subsequent date part function. * The function .same() must be followed by a date part function (example: .day(), .month(), .year(), etc). * * An optional Date can be passed in the date part function. If now date is passed as a parameter, 'Now' is used. * * The following example demonstrates how to determine if two dates fall on the exact same day. * * Example

	var d1 = Date.today(); // today at 00:00
	var d2 = new Date();   // exactly now.

	// Do they occur on the same day?
	d1.same().day(d2); // true
	
	// Do they occur on the same hour?
	d1.same().hour(d2); // false, unless d2 hour is '00' (midnight).
	
	// What if it's the same day, but one year apart?
	var nextYear = Date.today().add(1).year();

	d1.same().day(nextYear); // false, because the dates must occur on the exact same day. 
	
* * Scenario: Determine if a given date occurs during some week period 2 months from now. * * Example

	var future = Date.today().add(2).months();
	return someDate.same().week(future); // true|false;
	
* * @return {Boolean} true|false */ $P.same = function () { this._same = true; this._isSecond = false; return this; }; /** * Determines if the current date/time occurs during Today. Must be preceded by the .is() function. * Example

	someDate.is().today();    // true|false
	new Date().is().today();  // true
	Date.today().is().today();// true
	Date.today().add(-1).day().is().today(); // false
	
* * @return {Boolean} true|false */ $P.today = function () { return this.same().day(); }; /** * Determines if the current date is a weekday. This function must be preceded by the .is() function. * Example

	Date.today().is().weekday(); // true|false
	
* * @return {Boolean} true|false */ $P.weekday = function () { if (this._nth) { return df("Weekday").call(this); } if (this._move) { return this.addWeekdays(this._orient); } if (this._is) { this._is = false; return (!this.is().sat() && !this.is().sun()); } return false; }; /** * Determines if the current date is on the weekend. This function must be preceded by the .is() function. * Example

	Date.today().is().weekend(); // true|false
	
* * @return {Boolean} true|false */ $P.weekend = function () { if (this._is) { this._is = false; return (this.is().sat() || this.is().sun()); } return false; }; /** * Sets the Time of the current Date instance. A string "6:15 pm" or config object {hour:18, minute:15} are accepted. * Example

	// Set time to 6:15pm with a String
	Date.today().at("6:15pm");

	// Set time to 6:15pm with a config object
	Date.today().at({hour:18, minute:15});
	
* * @return {Date} date */ $P.at = function (time) { return (typeof time === "string") ? $D.parse(this.toString("d") + " " + time) : this.set(time); }; /** * Creates a new Date() and adds this (Number) to the date based on the preceding date element function (eg. second|minute|hour|day|month|year). * Example

	// Undeclared Numbers must be wrapped with parentheses. Requirment of JavaScript.
	(3).days().fromNow();
	(6).months().fromNow();

	// Declared Number variables do not require parentheses. 
	var n = 6;
	n.months().fromNow();
	
* * @return {Date} A new Date instance */ $N.fromNow = $N.after = function (date) { var c = {}; c[this._dateElement] = this; return ((!date) ? new Date() : date.clone()).add(c); }; /** * Creates a new Date() and subtract this (Number) from the date based on the preceding date element function (eg. second|minute|hour|day|month|year). * Example

	// Undeclared Numbers must be wrapped with parentheses. Requirment of JavaScript.
	(3).days().ago();
	(6).months().ago();

	// Declared Number variables do not require parentheses. 
	var n = 6;
	n.months().ago();
	
* * @return {Date} A new Date instance */ $N.ago = $N.before = function (date) { var c = {}, s = (this._dateElement[this._dateElement.length-1] !== "s") ? this._dateElement + "s" : this._dateElement; c[s] = this * -1; return ((!date) ? new Date() : date.clone()).add(c); }; // Do NOT modify the following string tokens. These tokens are used to build dynamic functions. // All culture-specific strings can be found in the CultureInfo files. var dx = ("sunday monday tuesday wednesday thursday friday saturday").split(/\s/), mx = ("january february march april may june july august september october november december").split(/\s/), px = ("Millisecond Second Minute Hour Day Week Month Year Quarter Weekday").split(/\s/), pxf = ("Milliseconds Seconds Minutes Hours Date Week Month FullYear Quarter").split(/\s/), nth = ("final first second third fourth fifth").split(/\s/), de; /** * Returns an object literal of all the date parts. * Example

	var o = new Date().toObject();
	
	// { year: 2008, month: 4, week: 20, day: 13, hour: 18, minute: 9, second: 32, millisecond: 812 }
	
	// The object properties can be referenced directly from the object.
	
	alert(o.day);  // alerts "13"
	alert(o.year); // alerts "2008"
	
* * @return {Date} An object literal representing the original date object. */ $P.toObject = function () { var o = {}; for (var i = 0; i < px.length; i++) { if (this["get" + pxf[i]]) { o[px[i].toLowerCase()] = this["get" + pxf[i]](); } } return o; }; /** * Returns a date created from an object literal. Ignores the .week property if set in the config. * Example

	var o = new Date().toObject();
	
	return Date.fromObject(o); // will return the same date. 

	var o2 = {month: 1, day: 20, hour: 18}; // birthday party!
	Date.fromObject(o2);
	
* * @return {Date} An object literal representing the original date object. */ $D.fromObject = function(config) { config.week = null; return Date.today().set(config); }; // Create day name functions and abbreviated day name functions (eg. monday(), friday(), fri()). var df = function (n) { return function () { if (this._is) { this._is = false; return this.getDay() === n; } if (this._move) { this._move = null; } if (this._nth !== null) { // If the .second() function was called earlier, remove the _orient // from the date, and then continue. // This is required because 'second' can be used in two different context. // // Example // // Date.today().add(1).second(); // Date.march().second().monday(); // // Things get crazy with the following... // Date.march().add(1).second().second().monday(); // but it works!! // if (this._isSecond) { this.addSeconds(this._orient * -1); } // make sure we reset _isSecond this._isSecond = false; var ntemp = this._nth; this._nth = null; var temp = this.clone().moveToLastDayOfMonth(); this.moveToNthOccurrence(n, ntemp); if (this > temp) { throw new RangeError($D.getDayName(n) + " does not occur " + ntemp + " times in the month of " + $D.getMonthName(temp.getMonth()) + " " + temp.getFullYear() + "."); } return this; } return this.moveToDayOfWeek(n, this._orient); }; }; var sdf = function (n) { return function () { var t = $D.today(), shift = n - t.getDay(); if (n === 0 && Date.CultureInfo.firstDayOfWeek === 1 && t.getDay() !== 0) { shift = shift + 7; } return t.addDays(shift); }; }; // Create month name functions and abbreviated month name functions (eg. january(), march(), mar()). var month_instance_functions = function (n) { return function () { if (this._is) { this._is = false; return this.getMonth() === n; } return this.moveToMonth(n, this._orient); }; }; var month_static_functions = function (n) { return function () { return $D.today().set({ month: n, day: 1 }); }; }; var processTerms = function (names, staticFunc, instanceFunc) { for (var i = 0; i < names.length; i++) { // Create constant static Name variables. $D[names[i].toUpperCase()] = $D[names[i].toUpperCase().substring(0, 3)] = i; // Create Name functions. $D[names[i]] = $D[names[i].substring(0, 3)] = staticFunc(i); // Create Name instance functions. $P[names[i]] = $P[names[i].substring(0, 3)] = instanceFunc(i); } }; processTerms(dx, sdf, df); processTerms(mx, month_static_functions, month_instance_functions); // Create date element functions and plural date element functions used with Date (eg. day(), days(), months()). var ef = function (j) { return function () { // if the .second() function was called earlier, the _orient // has alread been added. Just return this and reset _isSecond. if (this._isSecond) { this._isSecond = false; return this; } if (this._same) { this._same = this._is = false; var o1 = this.toObject(), o2 = (arguments[0] || new Date()).toObject(), v = "", k = j.toLowerCase(); // the substr trick with -1 doesn't work in IE8 or less k = (k[k.length-1] === "s") ? k.substring(0,k.length-1) : k; for (var m = (px.length - 1); m > -1; m--) { v = px[m].toLowerCase(); if (o1[v] !== o2[v]) { return false; } if (k === v) { break; } } return true; } if (j.substring(j.length - 1) !== "s") { j += "s"; } if (this._move) { this._move = null; } return this["add" + j](this._orient); }; }; var nf = function (n) { return function () { this._dateElement = n; return this; }; }; for (var k = 0; k < px.length; k++) { de = px[k].toLowerCase(); if(de !== "weekday") { // Create date element functions and plural date element functions used with Date (eg. day(), days(), months()). $P[de] = $P[de + "s"] = ef(px[k]); // Create date element functions and plural date element functions used with Number (eg. day(), days(), months()). $N[de] = $N[de + "s"] = nf(de + "s"); } } $P._ss = ef("Second"); var nthfn = function (n) { return function (dayOfWeek) { if (this._same) { return this._ss(arguments[0]); } if (dayOfWeek || dayOfWeek === 0) { return this.moveToNthOccurrence(dayOfWeek, n); } this._nth = n; // if the operator is 'second' add the _orient, then deal with it later... if (n === 2 && (dayOfWeek === undefined || dayOfWeek === null)) { this._isSecond = true; return this.addSeconds(this._orient); } return this; }; }; for (var l = 0; l < nth.length; l++) { $P[nth[l]] = (l === 0) ? nthfn(-1) : nthfn(l); } }()); (function () { "use strict"; Date.Parsing = { Exception: function (s) { this.message = "Parse error at '" + s.substring(0, 10) + " ...'"; } }; var $P = Date.Parsing; var dayOffsets = { standard: [0,31,59,90,120,151,181,212,243,273,304,334], leap: [0,31,60,91,121,152,182,213,244,274,305,335] }; $P.isLeapYear = function(year) { return ((year % 4 === 0) && (year % 100 !== 0)) || (year % 400 === 0); }; var utils = { multiReplace : function (str, hash ) { var key; for (key in hash) { if (Object.prototype.hasOwnProperty.call(hash, key)) { var regex; if (typeof hash[key] === "function") { } else { regex = (hash[key] instanceof RegExp) ? hash[key] : new RegExp(hash[key], "g"); } str = str.replace(regex, key); } } return str; }, getDayOfYearFromWeek : function (obj) { var d, jan4, offset; obj.weekDay = (!obj.weekDay && obj.weekDay !== 0) ? 1 : obj.weekDay; d = new Date(obj.year, 0, 4); jan4 = d.getDay() === 0 ? 7 : d.getDay(); // JS is 0 indexed on Sunday. offset = jan4+3; obj.dayOfYear = ((obj.week * 7) + (obj.weekDay === 0 ? 7 : obj.weekDay))-offset; return obj; }, getDayOfYear : function (obj, dayOffset) { if (!obj.dayOfYear) { obj = utils.getDayOfYearFromWeek(obj); } for (var i=0;i <= dayOffset.length;i++) { if (obj.dayOfYear < dayOffset[i] || i === dayOffset.length) { obj.day = obj.day ? obj.day : (obj.dayOfYear - dayOffset[i-1]); break; } else { obj.month = i; } } return obj; }, adjustForTimeZone : function (obj, date) { var offset; if (obj.zone.toUpperCase() === "Z" || (obj.zone_hours === 0 && obj.zone_minutes === 0)) { // it's UTC/GML so work out the current timeszone offset offset = -date.getTimezoneOffset(); } else { offset = (obj.zone_hours*60) + (obj.zone_minutes || 0); if (obj.zone_sign === "+") { offset *= -1; } offset -= date.getTimezoneOffset(); } date.setMinutes(date.getMinutes()+offset); return date; }, setDefaults : function (obj) { obj.year = obj.year || Date.today().getFullYear(); obj.hours = obj.hours || 0; obj.minutes = obj.minutes || 0; obj.seconds = obj.seconds || 0; obj.milliseconds = obj.milliseconds || 0; if (!(!obj.month && (obj.week || obj.dayOfYear))) { // if we have a month, or if we don't but don't have the day calculation data obj.month = obj.month || 0; obj.day = obj.day || 1; } return obj; }, dataNum: function (data, mod, explict, postProcess) { var dataNum = data*1; if (mod) { if (postProcess) { return data ? mod(data)*1 : data; } else { return data ? mod(dataNum) : data; } } else if (!explict){ return data ? dataNum : data; } else { return (data && typeof data !== "undefined") ? dataNum : data; } }, timeDataProcess: function (obj) { var timeObj = {}; for (var x in obj.data) { if (obj.data.hasOwnProperty(x)) { timeObj[x] = obj.ignore[x] ? obj.data[x] : utils.dataNum(obj.data[x], obj.mods[x], obj.explict[x], obj.postProcess[x]); } } if (obj.data.secmins) { obj.data.secmins = obj.data.secmins.replace(",", ".") * 60; if (!timeObj.minutes) { timeObj.minutes = obj.data.secmins; } else if (!timeObj.seconds) { timeObj.seconds = obj.data.secmins; } delete obj.secmins; } return timeObj; }, buildTimeObjectFromData: function (data) { var time = utils.timeDataProcess({ data: { year : data[1], month : data[5], day : data[7], week : data[8], dayOfYear : data[10], hours : data[15], zone_hours : data[23], zone_minutes : data[24], zone : data[21], zone_sign : data[22], weekDay : data[9], minutes: data[16], seconds: data[19], milliseconds: data[20], secmins: data[18] }, mods: { month: function(data) { return data-1; }, weekDay: function (data) { data = Math.abs(data); return (data === 7 ? 0 : data); }, minutes: function (data) { return data.replace(":",""); }, seconds: function (data) { return Math.floor( (data.replace(":","").replace(",","."))*1 ); }, milliseconds: function (data) { return (data.replace(",",".")*1000); } }, postProcess: { minutes: true, seconds: true, milliseconds: true }, explict: { zone_hours: true, zone_minutes: true }, ignore: { zone: true, zone_sign: true, secmins: true } }); return time; }, addToHash: function (hash, keys, data) { keys = keys; data = data; var len = keys.length; for (var i = 0; i < len; i++) { hash[keys[i]] = data[i]; } return hash; }, combineRegex: function (r1, r2) { return new RegExp("(("+r1.source+")\\s("+r2.source+"))"); }, getDateNthString: function(add, last, inc){ if (add) { return Date.today().addDays(inc).toString("d"); } else if (last) { return Date.today().last()[inc]().toString("d"); } }, buildRegexData: function (array) { var arr = []; var len = array.length; for (var i=0; i < len; i++) { if (Object.prototype.toString.call(array[i]) === '[object Array]') { // oldIE compat version of Array.isArray arr.push(this.combineRegex(array[i][0], array[i][1])); } else { arr.push(array[i]); } } return arr; } }; $P.processTimeObject = function (obj) { var date, dayOffset; utils.setDefaults(obj); dayOffset = ($P.isLeapYear(obj.year)) ? dayOffsets.leap : dayOffsets.standard; if (!obj.month && (obj.week || obj.dayOfYear)) { utils.getDayOfYear(obj, dayOffset); } else { obj.dayOfYear = dayOffset[obj.month] + obj.day; } date = new Date(obj.year, obj.month, obj.day, obj.hours, obj.minutes, obj.seconds, obj.milliseconds); if (obj.zone) { utils.adjustForTimeZone(obj, date); // adjust (and calculate) for timezone } return date; }; $P.ISO = { regex : /^([\+-]?\d{4}(?!\d{2}\b))((-?)((0[1-9]|1[0-2])(\3([12]\d|0[1-9]|3[01]))?|W([0-4]\d|5[0-3])(-?[1-7])?|(00[1-9]|0[1-9]\d|[12]\d{2}|3([0-5]\d|6[1-6])))([T\s]((([01]\d|2[0-4])((:?)[0-5]\d)?|24\:?00)([\.,]\d+(?!:))?)?(\17[0-5]\d([\.,]\d+)?)?\s?([zZ]|([\+-])([01]\d|2[0-3]):?([0-5]\d)?)?)?)?$/, parse : function (s) { var time, data = s.match(this.regex); if (!data || !data.length) { return null; } time = utils.buildTimeObjectFromData(data); if (!time.year || (!time.year && (!time.month && !time.day) && (!time.week && !time.dayOfYear)) ) { return null; } return $P.processTimeObject(time); } }; $P.Numeric = { isNumeric: function (e){return!isNaN(parseFloat(e))&&isFinite(e);}, regex: /\b([0-1]?[0-9])([0-3]?[0-9])([0-2]?[0-9]?[0-9][0-9])\b/i, parse: function (s) { var data, i, time = {}, order = Date.CultureInfo.dateElementOrder.split(""); if (!(this.isNumeric(s)) || // if it's non-numeric OR (s[0] === "+" && s[0] === "-")) { // It's an arithmatic string (eg +/-1000) return null; } if (s.length < 5 && s.indexOf(".") < 0 && s.indexOf("/") < 0) { // assume it's just a year. time.year = s; return $P.processTimeObject(time); } data = s.match(this.regex); if (!data || !data.length) { return null; } for (i=0; i < order.length; i++) { switch(order[i]) { case "d": time.day = data[i+1]; break; case "m": time.month = (data[i+1]-1); break; case "y": time.year = data[i+1]; break; } } return $P.processTimeObject(time); } }; $P.Normalizer = { regexData: function () { var $R = Date.CultureInfo.regexPatterns; return utils.buildRegexData([ $R.tomorrow, $R.yesterday, [$R.past, $R.mon], [$R.past, $R.tue], [$R.past, $R.wed], [$R.past, $R.thu], [$R.past, $R.fri], [$R.past, $R.sat], [$R.past, $R.sun] ]); }, basicReplaceHash : function() { var $R = Date.CultureInfo.regexPatterns; return { "January": $R.jan.source, "February": $R.feb, "March": $R.mar, "April": $R.apr, "May": $R.may, "June": $R.jun, "July": $R.jul, "August": $R.aug, "September": $R.sep, "October": $R.oct, "November": $R.nov, "December": $R.dec, "": /\bat\b/gi, " ": /\s{2,}/, "am": $R.inTheMorning, "9am": $R.thisMorning, "pm": $R.inTheEvening, "7pm":$R.thisEvening }; }, keys : function(){ return [ utils.getDateNthString(true, false, 1), // tomorrow utils.getDateNthString(true, false, -1), // yesterday utils.getDateNthString(false, true, "monday"), //last mon utils.getDateNthString(false, true, "tuesday"), //last tues utils.getDateNthString(false, true, "wednesday"), //last wed utils.getDateNthString(false, true, "thursday"), //last thurs utils.getDateNthString(false, true, "friday"), //last fri utils.getDateNthString(false, true, "saturday"), //last sat utils.getDateNthString(false, true, "sunday") //last sun ]; }, buildRegexFunctions: function () { var $R = Date.CultureInfo.regexPatterns; var __ = Date.i18n.__; var tomorrowRE = new RegExp("(\\b\\d\\d?("+__("AM")+"|"+__("PM")+")? )("+$R.tomorrow.source.slice(1)+")", "i"); // adapted tomorrow regex for AM PM relative dates var todayRE = new RegExp($R.today.source + "(?!\\s*([+-]))\\b"); // today, but excludes the math operators (eg "today + 2h") this.replaceFuncs = [ [todayRE, function (full) { return (full.length > 1) ? Date.today().toString("d") : full; }], [tomorrowRE, function(full, m1) { var t = Date.today().addDays(1).toString("d"); return (t + " " + m1); }], [$R.amThisMorning, function(str, am){return am;}], [$R.pmThisEvening, function(str, pm){return pm;}] ]; }, buildReplaceData: function () { this.buildRegexFunctions(); this.replaceHash = utils.addToHash(this.basicReplaceHash(), this.keys(), this.regexData()); }, stringReplaceFuncs: function (s) { for (var i=0; i < this.replaceFuncs.length; i++) { s = s.replace(this.replaceFuncs[i][0], this.replaceFuncs[i][1]); } return s; }, parse: function (s) { s = this.stringReplaceFuncs(s); s = utils.multiReplace(s, this.replaceHash); try { var n = s.split(/([\s\-\.\,\/\x27]+)/); if (n.length === 3 && $P.Numeric.isNumeric(n[0]) && $P.Numeric.isNumeric(n[2]) && (n[2].length >= 4)) { // ok, so we're dealing with x/year. But that's not a full date. // This fixes wonky dateElementOrder parsing when set to dmy order. if (Date.CultureInfo.dateElementOrder[0] === "d") { s = "1/" + n[0] + "/" + n[2]; // set to 1st of month and normalize the seperator } } } catch (e) {} return s; } }; $P.Normalizer.buildReplaceData(); }()); (function () { var $P = Date.Parsing; var _ = $P.Operators = { // // Tokenizers // rtoken: function (r) { // regex token return function (s) { var mx = s.match(r); if (mx) { return ([ mx[0], s.substring(mx[0].length) ]); } else { throw new $P.Exception(s); } }; }, token: function () { // whitespace-eating token return function (s) { return _.rtoken(new RegExp("^\\s*" + s + "\\s*"))(s); }; }, stoken: function (s) { // string token return _.rtoken(new RegExp("^" + s)); }, // Atomic Operators until: function (p) { return function (s) { var qx = [], rx = null; while (s.length) { try { rx = p.call(this, s); } catch (e) { qx.push(rx[0]); s = rx[1]; continue; } break; } return [ qx, s ]; }; }, many: function (p) { return function (s) { var rx = [], r = null; while (s.length) { try { r = p.call(this, s); } catch (e) { return [ rx, s ]; } rx.push(r[0]); s = r[1]; } return [ rx, s ]; }; }, // generator operators -- see below optional: function (p) { return function (s) { var r = null; try { r = p.call(this, s); } catch (e) { return [ null, s ]; } return [ r[0], r[1] ]; }; }, not: function (p) { return function (s) { try { p.call(this, s); } catch (e) { return [null, s]; } throw new $P.Exception(s); }; }, ignore: function (p) { return p ? function (s) { var r = null; r = p.call(this, s); return [null, r[1]]; } : null; }, product: function () { var px = arguments[0], qx = Array.prototype.slice.call(arguments, 1), rx = []; for (var i = 0 ; i < px.length ; i++) { rx.push(_.each(px[i], qx)); } return rx; }, cache: function (rule) { var cache = {}, cache_length = 0, cache_keys = [], CACHE_MAX = Date.Config.CACHE_MAX || 100000, r = null; var cacheCheck = function () { if (cache_length === CACHE_MAX) { // kill several keys, don't want to have to do this all the time... for (var i=0; i < 10; i++) { var key = cache_keys.shift(); if (key) { delete cache[key]; cache_length--; } } } }; return function (s) { cacheCheck(); try { r = cache[s] = (cache[s] || rule.call(this, s)); } catch (e) { r = cache[s] = e; } cache_length++; cache_keys.push(s); if (r instanceof $P.Exception) { throw r; } else { return r; } }; }, // vector operators -- see below any: function () { var px = arguments; return function (s) { var r = null; for (var i = 0; i < px.length; i++) { if (px[i] == null) { continue; } try { r = (px[i].call(this, s)); } catch (e) { r = null; } if (r) { return r; } } throw new $P.Exception(s); }; }, each: function () { var px = arguments; return function (s) { var rx = [], r = null; for (var i = 0; i < px.length ; i++) { if (px[i] == null) { continue; } try { r = (px[i].call(this, s)); } catch (e) { throw new $P.Exception(s); } rx.push(r[0]); s = r[1]; } return [ rx, s]; }; }, all: function () { var px = arguments, _ = _; return _.each(_.optional(px)); }, // delimited operators sequence: function (px, d, c) { d = d || _.rtoken(/^\s*/); c = c || null; if (px.length === 1) { return px[0]; } return function (s) { var r = null, q = null; var rx = []; for (var i = 0; i < px.length ; i++) { try { r = px[i].call(this, s); } catch (e) { break; } rx.push(r[0]); try { q = d.call(this, r[1]); } catch (ex) { q = null; break; } s = q[1]; } if (!r) { throw new $P.Exception(s); } if (q) { throw new $P.Exception(q[1]); } if (c) { try { r = c.call(this, r[1]); } catch (ey) { throw new $P.Exception(r[1]); } } return [ rx, (r?r[1]:s) ]; }; }, // // Composite Operators // between: function (d1, p, d2) { d2 = d2 || d1; var _fn = _.each(_.ignore(d1), p, _.ignore(d2)); return function (s) { var rx = _fn.call(this, s); return [[rx[0][0], r[0][2]], rx[1]]; }; }, list: function (p, d, c) { d = d || _.rtoken(/^\s*/); c = c || null; return (p instanceof Array ? _.each(_.product(p.slice(0, -1), _.ignore(d)), p.slice(-1), _.ignore(c)) : _.each(_.many(_.each(p, _.ignore(d))), px, _.ignore(c))); }, set: function (px, d, c) { d = d || _.rtoken(/^\s*/); c = c || null; return function (s) { // r is the current match, best the current 'best' match // which means it parsed the most amount of input var r = null, p = null, q = null, rx = null, best = [[], s], last = false; // go through the rules in the given set for (var i = 0; i < px.length ; i++) { // last is a flag indicating whether this must be the last element // if there is only 1 element, then it MUST be the last one q = null; p = null; r = null; last = (px.length === 1); // first, we try simply to match the current pattern // if not, try the next pattern try { r = px[i].call(this, s); } catch (e) { continue; } // since we are matching against a set of elements, the first // thing to do is to add r[0] to matched elements rx = [[r[0]], r[1]]; // if we matched and there is still input to parse and // we don't already know this is the last element, // we're going to next check for the delimiter ... // if there's none, or if there's no input left to parse // than this must be the last element after all ... if (r[1].length > 0 && ! last) { try { q = d.call(this, r[1]); } catch (ex) { last = true; } } else { last = true; } // if we parsed the delimiter and now there's no more input, // that means we shouldn't have parsed the delimiter at all // so don't update r and mark this as the last element ... if (!last && q[1].length === 0) { last = true; } // so, if this isn't the last element, we're going to see if // we can get any more matches from the remaining (unmatched) // elements ... if (!last) { // build a list of the remaining rules we can match against, // i.e., all but the one we just matched against var qx = []; for (var j = 0; j < px.length ; j++) { if (i !== j) { qx.push(px[j]); } } // now invoke recursively set with the remaining input // note that we don't include the closing delimiter ... // we'll check for that ourselves at the end p = _.set(qx, d).call(this, q[1]); // if we got a non-empty set as a result ... // (otw rx already contains everything we want to match) if (p[0].length > 0) { // update current result, which is stored in rx ... // basically, pick up the remaining text from p[1] // and concat the result from p[0] so that we don't // get endless nesting ... rx[0] = rx[0].concat(p[0]); rx[1] = p[1]; } } // at this point, rx either contains the last matched element // or the entire matched set that starts with this element. // now we just check to see if this variation is better than // our best so far, in terms of how much of the input is parsed if (rx[1].length < best[1].length) { best = rx; } // if we've parsed all the input, then we're finished if (best[1].length === 0) { break; } } // so now we've either gone through all the patterns trying them // as the initial match; or we found one that parsed the entire // input string ... // if best has no matches, just return empty set ... if (best[0].length === 0) { return best; } // if a closing delimiter is provided, then we have to check it also if (c) { // we try this even if there is no remaining input because the pattern // may well be optional or match empty input ... try { q = c.call(this, best[1]); } catch (ey) { throw new $P.Exception(best[1]); } // it parsed ... be sure to update the best match remaining input best[1] = q[1]; } // if we're here, either there was no closing delimiter or we parsed it // so now we have the best match; just return it! return best; }; }, forward: function (gr, fname) { return function (s) { return gr[fname].call(this, s); }; }, // // Translation Operators // replace: function (rule, repl) { return function (s) { var r = rule.call(this, s); return [repl, r[1]]; }; }, process: function (rule, fn) { return function (s) { var r = rule.call(this, s); return [fn.call(this, r[0]), r[1]]; }; }, min: function (min, rule) { return function (s) { var rx = rule.call(this, s); if (rx[0].length < min) { throw new $P.Exception(s); } return rx; }; } }; // Generator Operators And Vector Operators // Generators are operators that have a signature of F(R) => R, // taking a given rule and returning another rule, such as // ignore, which parses a given rule and throws away the result. // Vector operators are those that have a signature of F(R1,R2,...) => R, // take a list of rules and returning a new rule, such as each. // Generator operators are converted (via the following _generator // function) into functions that can also take a list or array of rules // and return an array of new rules as though the function had been // called on each rule in turn (which is what actually happens). // This allows generators to be used with vector operators more easily. // Example: // each(ignore(foo, bar)) instead of each(ignore(foo), ignore(bar)) // This also turns generators into vector operators, which allows // constructs like: // not(cache(foo, bar)) var _generator = function (op) { function gen() { var args = null, rx = [], px, i; if (arguments.length > 1) { args = Array.prototype.slice.call(arguments); } else if (arguments[0] instanceof Array) { args = arguments[0]; } if (args) { px = args.shift(); if (px.length > 0) { args.unshift(px[i]); rx.push(op.apply(null, args)); args.shift(); return rx; } } else { return op.apply(null, arguments); } } return gen; }; var gx = "optional not ignore cache".split(/\s/); for (var i = 0 ; i < gx.length ; i++) { _[gx[i]] = _generator(_[gx[i]]); } var _vector = function (op) { return function () { if (arguments[0] instanceof Array) { return op.apply(null, arguments[0]); } else { return op.apply(null, arguments); } }; }; var vx = "each any all".split(/\s/); for (var j = 0 ; j < vx.length ; j++) { _[vx[j]] = _vector(_[vx[j]]); } }()); (function () { var $D = Date; var flattenAndCompact = function (ax) { var rx = []; for (var i = 0; i < ax.length; i++) { if (ax[i] instanceof Array) { rx = rx.concat(flattenAndCompact(ax[i])); } else { if (ax[i]) { rx.push(ax[i]); } } } return rx; }; var parseMeridian = function () { if (this.meridian && (this.hour || this.hour === 0)) { if (this.meridian === "a" && this.hour > 11 && Date.Config.strict24hr){ throw "Invalid hour and meridian combination"; } else if (this.meridian === "p" && this.hour < 12 && Date.Config.strict24hr){ throw "Invalid hour and meridian combination"; } else if (this.meridian === "p" && this.hour < 12) { this.hour = this.hour + 12; } else if (this.meridian === "a" && this.hour === 12) { this.hour = 0; } } }; var setDefaults = function () { var now = new Date(); if ((this.hour || this.minute) && (!this.month && !this.year && !this.day)) { this.day = now.getDate(); } if (!this.year) { this.year = now.getFullYear(); } if (!this.month && this.month !== 0) { this.month = now.getMonth(); } if (!this.day) { this.day = 1; } if (!this.hour) { this.hour = 0; } if (!this.minute) { this.minute = 0; } if (!this.second) { this.second = 0; } if (!this.millisecond) { this.millisecond = 0; } }; var finishUtils = { getToday: function () { if (this.now || "hour minute second".indexOf(this.unit) !== -1) { return new Date(); } else { return $D.today(); } }, setDaysFromWeekday: function (today, orient){ var gap; orient = orient || 1; this.unit = "day"; gap = ($D.getDayNumberFromName(this.weekday) - today.getDay()); this.days = gap ? ((gap + (orient * 7)) % 7) : (orient * 7); return this; }, setMonthsFromMonth: function (today, orient) { var gap; orient = orient || 1; this.unit = "month"; gap = (this.month - today.getMonth()); this.months = gap ? ((gap + (orient * 12)) % 12) : (orient * 12); this.month = null; return this; }, setDMYFromWeekday: function () { var d = Date[this.weekday](); this.day = d.getDate(); if (!this.month) { this.month = d.getMonth(); } this.year = d.getFullYear(); return this; }, setUnitValue: function (orient) { if (!this.value && this.operator && this.operator !== null && this[this.unit + "s"] && this[this.unit + "s"] !== null) { this[this.unit + "s"] = this[this.unit + "s"] + ((this.operator === "add") ? 1 : -1) + (this.value||0) * orient; } else if (this[this.unit + "s"] == null || this.operator != null) { if (!this.value) { this.value = 1; } this[this.unit + "s"] = this.value * orient; } }, generateDateFromWeeks: function () { var weekday = (this.weekday !== undefined) ? this.weekday : "today"; var d = Date[weekday]().addWeeks(this.weeks); if (this.now) { d.setTimeToNow(); } return d; } }; $D.Translator = { hour: function (s) { return function () { this.hour = Number(s); }; }, minute: function (s) { return function () { this.minute = Number(s); }; }, second: function (s) { return function () { this.second = Number(s); }; }, /* for ss.s format */ secondAndMillisecond: function (s) { return function () { var mx = s.match(/^([0-5][0-9])\.([0-9]{1,3})/); this.second = Number(mx[1]); this.millisecond = Number(mx[2]); }; }, meridian: function (s) { return function () { this.meridian = s.slice(0, 1).toLowerCase(); }; }, timezone: function (s) { return function () { var n = s.replace(/[^\d\+\-]/g, ""); if (n.length) { this.timezoneOffset = Number(n); } else { this.timezone = s.toLowerCase(); } }; }, day: function (x) { var s = x[0]; return function () { this.day = Number(s.match(/\d+/)[0]); if (this.day < 1) { throw "invalid day"; } }; }, month: function (s) { return function () { this.month = (s.length === 3) ? "jan feb mar apr may jun jul aug sep oct nov dec".indexOf(s)/4 : Number(s) - 1; if (this.month < 0) { throw "invalid month"; } }; }, year: function (s) { return function () { var n = Number(s); this.year = ((s.length > 2) ? n : (n + (((n + 2000) < Date.CultureInfo.twoDigitYearMax) ? 2000 : 1900))); }; }, rday: function (s) { return function () { switch (s) { case "yesterday": this.days = -1; break; case "tomorrow": this.days = 1; break; case "today": this.days = 0; break; case "now": this.days = 0; this.now = true; break; } }; }, finishExact: function (x) { var d; x = (x instanceof Array) ? x : [x]; for (var i = 0 ; i < x.length ; i++) { if (x[i]) { x[i].call(this); } } setDefaults.call(this); parseMeridian.call(this); if (this.day > $D.getDaysInMonth(this.year, this.month)) { throw new RangeError(this.day + " is not a valid value for days."); } d = new Date(this.year, this.month, this.day, this.hour, this.minute, this.second, this.millisecond); if (this.year < 100) { d.setFullYear(this.year); // means years less that 100 are process correctly. JS will parse it otherwise as 1900-1999. } if (this.timezone) { d.set({ timezone: this.timezone }); } else if (this.timezoneOffset) { d.set({ timezoneOffset: this.timezoneOffset }); } return d; }, finish: function (x) { var today, expression, orient, temp; x = (x instanceof Array) ? flattenAndCompact(x) : [ x ]; if (x.length === 0) { return null; } for (var i = 0 ; i < x.length ; i++) { if (typeof x[i] === "function") { x[i].call(this); } } if (this.now && !this.unit && !this.operator) { return new Date(); } else { today = finishUtils.getToday.call(this); } expression = !!(this.days && this.days !== null || this.orient || this.operator); orient = ((this.orient === "past" || this.operator === "subtract") ? -1 : 1); if (this.month && this.unit === "week") { this.value = this.month + 1; delete this.month; delete this.day; } if ((this.month || this.month === 0) && "year day hour minute second".indexOf(this.unit) !== -1) { if (!this.value) { this.value = this.month + 1; } this.month = null; expression = true; } if (!expression && this.weekday && !this.day && !this.days) { finishUtils.setDMYFromWeekday.call(this); } if (expression && this.weekday && this.unit !== "month" && this.unit !== "week") { finishUtils.setDaysFromWeekday.call(this, today, orient); } if (this.weekday && this.unit !== "week" && !this.day && !this.days) { temp = Date[this.weekday](); this.day = temp.getDate(); if (temp.getMonth() !== today.getMonth()) { this.month = temp.getMonth(); } } if (this.month && this.unit === "day" && this.operator) { if (!this.value) { this.value = (this.month + 1); } this.month = null; } if (this.value != null && this.month != null && this.year != null) { this.day = this.value * 1; } if (this.month && !this.day && this.value) { today.set({ day: this.value * 1 }); if (!expression) { this.day = this.value * 1; } } if (!this.month && this.value && this.unit === "month" && !this.now) { this.month = this.value; expression = true; } if (expression && (this.month || this.month === 0) && this.unit !== "year") { finishUtils.setMonthsFromMonth.call(this, today, orient); } if (!this.unit) { this.unit = "day"; } finishUtils.setUnitValue.call(this, orient); parseMeridian.call(this); if ((this.month || this.month === 0) && !this.day) { this.day = 1; } if (!this.orient && !this.operator && this.unit === "week" && this.value && !this.day && !this.month) { return Date.today().setWeek(this.value); } if (this.unit === "week" && this.weeks && !this.day && !this.month) { return finishUtils.generateDateFromWeeks.call(this); } if (expression && this.timezone && this.day && this.days) { this.day = this.days; } if (expression){ today.add(this); } else { today.set(this); } if (this.timezone) { this.timezone = this.timezone.toUpperCase(); var offset = $D.getTimezoneOffset(this.timezone); var timezone; if (today.hasDaylightSavingTime()) { // lets check that we're being sane with timezone setting timezone = $D.getTimezoneAbbreviation(offset, today.isDaylightSavingTime()); if (timezone !== this.timezone) { // bugger, we're in a place where things like EST vs EDT matters. if (today.isDaylightSavingTime()) { today.addHours(-1); } else { today.addHours(1); } } } today.setTimezoneOffset(offset); } return today; } }; }()); (function () { var $D = Date; $D.Grammar = {}; var _ = $D.Parsing.Operators, g = $D.Grammar, t = $D.Translator, _fn; // Allow rolling up into general purpose rules _fn = function () { return _.each(_.any.apply(null, arguments), _.not(g.ctoken2("timeContext"))); }; g.datePartDelimiter = _.rtoken(/^([\s\-\.\,\/\x27]+)/); g.timePartDelimiter = _.stoken(":"); g.whiteSpace = _.rtoken(/^\s*/); g.generalDelimiter = _.rtoken(/^(([\s\,]|at|@|on)+)/); var _C = {}; g.ctoken = function (keys) { var fn = _C[keys]; if (! fn) { var c = Date.CultureInfo.regexPatterns; var kx = keys.split(/\s+/), px = []; for (var i = 0; i < kx.length ; i++) { px.push(_.replace(_.rtoken(c[kx[i]]), kx[i])); } fn = _C[keys] = _.any.apply(null, px); } return fn; }; g.ctoken2 = function (key) { return _.rtoken(Date.CultureInfo.regexPatterns[key]); }; var cacheProcessRtoken = function (key, token, type, eachToken) { if (eachToken) { g[key] = _.cache(_.process(_.each(_.rtoken(token),_.optional(g.ctoken2(eachToken))), type)); } else { g[key] = _.cache(_.process(_.rtoken(token), type)); } }; var cacheProcessCtoken = function (token, type) { return _.cache(_.process(g.ctoken2(token), type)); }; var _F = {}; //function cache var _get = function (f) { _F[f] = (_F[f] || g.format(f)[0]); return _F[f]; }; g.allformats = function (fx) { var rx = []; if (fx instanceof Array) { for (var i = 0; i < fx.length; i++) { rx.push(_get(fx[i])); } } else { rx.push(_get(fx)); } return rx; }; g.formats = function (fx) { if (fx instanceof Array) { var rx = []; for (var i = 0 ; i < fx.length ; i++) { rx.push(_get(fx[i])); } return _.any.apply(null, rx); } else { return _get(fx); } }; var grammarFormats = { timeFormats: function(){ var i, RTokenKeys = [ "h", "hh", "H", "HH", "m", "mm", "s", "ss", "ss.s", "z", "zz" ], RToken = [ /^(0[0-9]|1[0-2]|[1-9])/, /^(0[0-9]|1[0-2])/, /^([0-1][0-9]|2[0-3]|[0-9])/, /^([0-1][0-9]|2[0-3])/, /^([0-5][0-9]|[0-9])/, /^[0-5][0-9]/, /^([0-5][0-9]|[0-9])/, /^[0-5][0-9]/, /^[0-5][0-9]\.[0-9]{1,3}/, /^((\+|\-)\s*\d\d\d\d)|((\+|\-)\d\d\:?\d\d)/, /^((\+|\-)\s*\d\d\d\d)|((\+|\-)\d\d\:?\d\d)/ ], tokens = [ t.hour, t.hour, t.hour, t.hour, t.minute, t.minute, t.second, t.second, t.secondAndMillisecond, t.timezone, t.timezone ]; for (i=0; i < RTokenKeys.length; i++) { cacheProcessRtoken(RTokenKeys[i], RToken[i], tokens[i]); } g.hms = _.cache(_.sequence([g.H, g.m, g.s], g.timePartDelimiter)); g.t = cacheProcessCtoken("shortMeridian", t.meridian); g.tt = cacheProcessCtoken("longMeridian", t.meridian); g.zzz = cacheProcessCtoken("timezone", t.timezone); g.timeSuffix = _.each(_.ignore(g.whiteSpace), _.set([ g.tt, g.zzz ])); g.time = _.each(_.optional(_.ignore(_.stoken("T"))), g.hms, g.timeSuffix); }, dateFormats: function () { // pre-loaded rules for different date part order preferences var _setfn = function () { return _.set(arguments, g.datePartDelimiter); }; var i, RTokenKeys = [ "d", "dd", "M", "MM", "y", "yy", "yyy", "yyyy" ], RToken = [ /^([0-2]\d|3[0-1]|\d)/, /^([0-2]\d|3[0-1])/, /^(1[0-2]|0\d|\d)/, /^(1[0-2]|0\d)/, /^(\d+)/, /^(\d\d)/, /^(\d\d?\d?\d?)/, /^(\d\d\d\d)/ ], tokens = [ t.day, t.day, t.month, t.month, t.year, t.year, t.year, t.year ], eachToken = [ "ordinalSuffix", "ordinalSuffix" ]; for (i=0; i < RTokenKeys.length; i++) { cacheProcessRtoken(RTokenKeys[i], RToken[i], tokens[i], eachToken[i]); } g.MMM = g.MMMM = _.cache(_.process(g.ctoken("jan feb mar apr may jun jul aug sep oct nov dec"), t.month)); g.ddd = g.dddd = _.cache(_.process(g.ctoken("sun mon tue wed thu fri sat"), function (s) { return function () { this.weekday = s; }; } )); g.day = _fn(g.d, g.dd); g.month = _fn(g.M, g.MMM); g.year = _fn(g.yyyy, g.yy); g.mdy = _setfn(g.ddd, g.month, g.day, g.year); g.ymd = _setfn(g.ddd, g.year, g.month, g.day); g.dmy = _setfn(g.ddd, g.day, g.month, g.year); g.date = function (s) { return ((g[Date.CultureInfo.dateElementOrder] || g.mdy).call(this, s)); }; }, relative: function () { // relative date / time expressions g.orientation = _.process(g.ctoken("past future"), function (s) { return function () { this.orient = s; }; } ); g.operator = _.process(g.ctoken("add subtract"), function (s) { return function () { this.operator = s; }; } ); g.rday = _.process(g.ctoken("yesterday tomorrow today now"), t.rday); g.unit = _.process(g.ctoken("second minute hour day week month year"), function (s) { return function () { this.unit = s; }; } ); } }; g.buildGrammarFormats = function () { // these need to be rebuilt every time the language changes. _C = {}; grammarFormats.timeFormats(); grammarFormats.dateFormats(); grammarFormats.relative(); g.value = _.process(_.rtoken(/^([-+]?\d+)?(st|nd|rd|th)?/), function (s) { return function () { this.value = s.replace(/\D/g, ""); }; } ); g.expression = _.set([g.rday, g.operator, g.value, g.unit, g.orientation, g.ddd, g.MMM ]); g.format = _.process(_.many( _.any( // translate format specifiers into grammar rules _.process( _.rtoken(/^(dd?d?d?(?!e)|MM?M?M?|yy?y?y?|hh?|HH?|mm?|ss?|tt?|zz?z?)/), function (fmt) { if (g[fmt]) { return g[fmt]; } else { throw $D.Parsing.Exception(fmt); } } ), // translate separator tokens into token rules _.process(_.rtoken(/^[^dMyhHmstz]+/), // all legal separators function (s) { return _.ignore(_.stoken(s)); } ) ) ), // construct the parser ... function (rules) { return _.process(_.each.apply(null, rules), t.finishExact); } ); // starting rule for general purpose grammar g._start = _.process(_.set([ g.date, g.time, g.expression ], g.generalDelimiter, g.whiteSpace), t.finish); }; g.buildGrammarFormats(); // parsing date format specifiers - ex: "h:m:s tt" // this little guy will generate a custom parser based // on the format string, ex: g.format("h:m:s tt") // check for these formats first g._formats = g.formats([ "\"yyyy-MM-ddTHH:mm:ssZ\"", "yyyy-MM-ddTHH:mm:ss.sz", "yyyy-MM-ddTHH:mm:ssZ", "yyyy-MM-ddTHH:mm:ssz", "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-ddTHH:mmZ", "yyyy-MM-ddTHH:mmz", "yyyy-MM-ddTHH:mm", "ddd, MMM dd, yyyy H:mm:ss tt", "ddd MMM d yyyy HH:mm:ss zzz", "MMddyyyy", "ddMMyyyy", "Mddyyyy", "ddMyyyy", "Mdyyyy", "dMyyyy", "yyyy", "Mdyy", "dMyy", "d" ]); // real starting rule: tries selected formats first, // then general purpose rule g.start = function (s) { try { var r = g._formats.call({}, s); if (r[1].length === 0) { return r; } } catch (e) {} return g._start.call({}, s); }; }()); (function () { var $D = Date; /** * @desc Converts the specified string value into its JavaScript Date equivalent using CultureInfo specific format information. * * Example

	///////////
	// Dates //
	///////////

	// 15-Oct-2004
	var d1 = Date.parse("10/15/2004");

	// 15-Oct-2004
	var d1 = Date.parse("15-Oct-2004");

	// 15-Oct-2004
	var d1 = Date.parse("2004.10.15");

	//Fri Oct 15, 2004
	var d1 = Date.parse("Fri Oct 15, 2004");

	///////////
	// Times //
	///////////

	// Today at 10 PM.
	var d1 = Date.parse("10 PM");

	// Today at 10:30 PM.
	var d1 = Date.parse("10:30 P.M.");

	// Today at 6 AM.
	var d1 = Date.parse("06am");

	/////////////////////
	// Dates and Times //
	/////////////////////

	// 8-July-2004 @ 10:30 PM
	var d1 = Date.parse("July 8th, 2004, 10:30 PM");

	// 1-July-2004 @ 10:30 PM
	var d1 = Date.parse("2004-07-01T22:30:00");

	////////////////////
	// Relative Dates //
	////////////////////

	// Returns today's date. The string "today" is culture specific.
	var d1 = Date.parse("today");

	// Returns yesterday's date. The string "yesterday" is culture specific.
	var d1 = Date.parse("yesterday");

	// Returns the date of the next thursday.
	var d1 = Date.parse("Next thursday");

	// Returns the date of the most previous monday.
	var d1 = Date.parse("last monday");

	// Returns today's day + one year.
	var d1 = Date.parse("next year");

	///////////////
	// Date Math //
	///////////////

	// Today + 2 days
	var d1 = Date.parse("t+2");

	// Today + 2 days
	var d1 = Date.parse("today + 2 days");

	// Today + 3 months
	var d1 = Date.parse("t+3m");

	// Today - 1 year
	var d1 = Date.parse("today - 1 year");

	// Today - 1 year
	var d1 = Date.parse("t-1y"); 


	/////////////////////////////
	// Partial Dates and Times //
	/////////////////////////////

	// July 15th of this year.
	var d1 = Date.parse("July 15");

	// 15th day of current day and year.
	var d1 = Date.parse("15");

	// July 1st of current year at 10pm.
	var d1 = Date.parse("7/1 10pm");
	
* * @param {String} The string value to convert into a Date object [Required] * @return {Date} A Date object or null if the string cannot be converted into a Date. */ var parseUtils = { removeOrds: function (s) { ords = s.match(/\b(\d+)(?:st|nd|rd|th)\b/); // find ordinal matches s = ((ords && ords.length === 2) ? s.replace(ords[0], ords[1]) : s); return s; }, grammarParser: function (s) { var r = null; try { r = $D.Grammar.start.call({}, s.replace(/^\s*(\S*(\s+\S+)*)\s*$/, "$1")); } catch (e) { return null; } return ((r[1].length === 0) ? r[0] : null); }, nativeFallback: function(s) { var t; try { // ok we haven't parsed it, last ditch attempt with the built-in parser. t = Date._parse(s); return (t || t === 0) ? new Date(t) : null; } catch (e) { return null; } } }; function parse (s) { var d; if (!s) { return null; } if (s instanceof Date) { return s.clone(); } if (s.length >= 4 && s.charAt(0) !== "0" && s.charAt(0) !== "+"&& s.charAt(0) !== "-") { // ie: 2004 will pass, 0800 won't. // Start with specific formats d = $D.Parsing.ISO.parse(s) || $D.Parsing.Numeric.parse(s); } if (d instanceof Date && !isNaN(d.getTime())) { return d; } else { // find ordinal dates (1st, 3rd, 8th, etc and remove them as they cause parsing issues) s = $D.Parsing.Normalizer.parse(parseUtils.removeOrds(s)); d = parseUtils.grammarParser(s); if (d !== null) { return d; } else { return parseUtils.nativeFallback(s); } } } if (!$D._parse) { $D._parse = $D.parse; } $D.parse = parse; Date.getParseFunction = function (fx) { var fns = Date.Grammar.allformats(fx); return function (s) { var r = null; for (var i = 0; i < fns.length; i++) { try { r = fns[i].call({}, s); } catch (e) { continue; } if (r[1].length === 0) { return r[0]; } } return null; }; }; /** * Converts the specified string value into its JavaScript Date equivalent using the specified format {String} or formats {Array} and the CultureInfo specific format information. * The format of the string value must match one of the supplied formats exactly. * * Example

	// 15-Oct-2004
	var d1 = Date.parseExact("10/15/2004", "M/d/yyyy");

	// 15-Oct-2004
	var d1 = Date.parse("15-Oct-2004", "M-ddd-yyyy");

	// 15-Oct-2004
	var d1 = Date.parse("2004.10.15", "yyyy.MM.dd");

	// Multiple formats
	var d1 = Date.parseExact("10/15/2004", ["M/d/yyyy", "MMMM d, yyyy"]);
	
* * @param {String} The string value to convert into a Date object [Required]. * @param {Object} The expected format {String} or an array of expected formats {Array} of the date string [Required]. * @return {Date} A Date object or null if the string cannot be converted into a Date. */ $D.parseExact = function (s, fx) { return $D.getParseFunction(fx)(s); }; }()); (function () { var $D = Date, $P = $D.prototype, // $C = $D.CultureInfo, // not used atm p = function (s, l) { if (!l) { l = 2; } return ("000" + s).slice(l * -1); }; /** * Converts a PHP format string to Java/.NET format string. * A PHP format string can be used with ._format or .format. * A Java/.NET format string can be used with .toString(). * The .parseExact function will only accept a Java/.NET format string * * Example * var f1 = "%m/%d/%y" * var f2 = Date.normalizeFormat(f1); // "MM/dd/yy" * * new Date().format(f1); // "04/13/08" * new Date()._format(f1); // "04/13/08" * new Date().toString(f2); // "04/13/08" * * var date = Date.parseExact("04/13/08", f2); // Sun Apr 13 2008 * * @param {String} A PHP format string consisting of one or more format spcifiers. * @return {String} The PHP format converted to a Java/.NET format string. */ var normalizerSubstitutions = { "d" : "dd", "%d": "dd", "D" : "ddd", "%a": "ddd", "j" : "dddd", "l" : "dddd", "%A": "dddd", "S" : "S", "F" : "MMMM", "%B": "MMMM", "m" : "MM", "%m": "MM", "M" : "MMM", "%b": "MMM", "%h": "MMM", "n" : "M", "Y" : "yyyy", "%Y": "yyyy", "y" : "yy", "%y": "yy", "g" : "h", "%I": "h", "G" : "H", "h" : "hh", "H" : "HH", "%H": "HH", "i" : "mm", "%M": "mm", "s" : "ss", "%S": "ss", "%r": "hh:mm tt", "%R": "H:mm", "%T": "H:mm:ss", "%X": "t", "%x": "d", "%e": "d", "%D": "MM/dd/yy", "%n": "\\n", "%t": "\\t", "e" : "z", "T" : "z", "%z": "z", "%Z": "z", "Z" : "ZZ", "N" : "u", "w" : "u", "%w": "u", "W" : "W", "%V": "W" }; var normalizer = { substitutes: function (m) { return normalizerSubstitutions[m]; }, interpreted: function (m, x) { var y; switch (m) { case "%u": return x.getDay() + 1; case "z": return x.getOrdinalNumber(); case "%j": return p(x.getOrdinalNumber(), 3); case "%U": var d1 = x.clone().set({month: 0, day: 1}).addDays(-1).moveToDayOfWeek(0), d2 = x.clone().addDays(1).moveToDayOfWeek(0, -1); return (d2 < d1) ? "00" : p((d2.getOrdinalNumber() - d1.getOrdinalNumber()) / 7 + 1); case "%W": return p(x.getWeek()); case "t": return $D.getDaysInMonth(x.getFullYear(), x.getMonth()); case "o": case "%G": return x.setWeek(x.getISOWeek()).toString("yyyy"); case "%g": return x._format("%G").slice(-2); case "a": case "%p": return t("tt").toLowerCase(); case "A": return t("tt").toUpperCase(); case "u": return p(x.getMilliseconds(), 3); case "I": return (x.isDaylightSavingTime()) ? 1 : 0; case "O": return x.getUTCOffset(); case "P": y = x.getUTCOffset(); return y.substring(0, y.length - 2) + ":" + y.substring(y.length - 2); case "B": var now = new Date(); return Math.floor(((now.getHours() * 3600) + (now.getMinutes() * 60) + now.getSeconds() + (now.getTimezoneOffset() + 60) * 60) / 86.4); case "c": return x.toISOString().replace(/\"/g, ""); case "U": return $D.strtotime("now"); case "%c": return t("d") + " " + t("t"); case "%C": return Math.floor(x.getFullYear() / 100 + 1); } }, shouldOverrideDefaults: function (m) { switch (m) { case "%e": return true; default: return false; } }, parse: function (m, context) { var formatString, c = context || new Date(); formatString = normalizer.substitutes(m); if (formatString) { return formatString; } formatString = normalizer.interpreted(m, c); if (formatString) { return formatString; } else { return m; } } }; $D.normalizeFormat = function (format, context) { return format.replace(/(%|\\)?.|%%/g, function(t){ return normalizer.parse(t, context); }); }; /** * Format a local Unix timestamp according to locale settings * * Example: * Date.strftime("%m/%d/%y", new Date()); // "04/13/08" * Date.strftime("c", "2008-04-13T17:52:03Z"); // "04/13/08" * * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @param {Number|String} The number representing the number of seconds that have elapsed since January 1, 1970 (local time). * @return {String} A string representation of the current Date object. */ $D.strftime = function (format, time) { var d = Date.parse(time); return d._format(format); }; /** * Parse any textual datetime description into a Unix timestamp. * A Unix timestamp is the number of seconds that have elapsed since January 1, 1970 (midnight UTC/GMT). * * Example: * Date.strtotime("04/13/08"); // 1208044800 * Date.strtotime("1970-01-01T00:00:00Z"); // 0 * * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @param {Object} A string or date object. * @return {String} A string representation of the current Date object. */ $D.strtotime = function (time) { var d = $D.parse(time); return Math.round($D.UTC(d.getUTCFullYear(), d.getUTCMonth(), d.getUTCDate(), d.getUTCHours(), d.getUTCMinutes(), d.getUTCSeconds(), d.getUTCMilliseconds()) / 1000); }; /** * Converts the value of the current Date object to its equivalent string representation using a PHP/Unix style of date format specifiers. * Format Specifiers * Format Description Example * ------ --------------------------------------------------------------------------- ----------------------- * %a abbreviated weekday name according to the current localed "Mon" through "Sun" * %A full weekday name according to the current localed "Sunday" through "Saturday" * %b abbreviated month name according to the current localed "Jan" through "Dec" * %B full month name according to the current locale "January" through "December" * %c preferred date and time representation for the current locale "4/13/2008 12:33 PM" * %C century number (the year divided by 100 and truncated to an integer) "00" to "99" * %d day of the month as a decimal number "01" to "31" * %D same as %m/%d/%y "04/13/08" * %e day of the month as a decimal number, a single digit is preceded by a space "1" to "31" * %g like %G, but without the century "08" * %G The 4-digit year corresponding to the ISO week number (see %V). "2008" * This has the same format and value as %Y, except that if the ISO week number * belongs to the previous or next year, that year is used instead. * %h same as %b "Jan" through "Dec" * %H hour as a decimal number using a 24-hour clock. "00" to "23" * %I hour as a decimal number using a 12-hour clock. "01" to "12" * %j day of the year as a decimal number. "001" to "366" * %m month as a decimal number. "01" to "12" * %M minute as a decimal number. "00" to "59" * %n newline character "\n" * %p either "am" or "pm" according to the given time value, or the "am" or "pm" * corresponding strings for the current locale. * %r time in a.m. and p.m. notation "8:44 PM" * %R time in 24 hour notation "20:44" * %S second as a decimal number "00" to "59" * %t tab character "\t" * %T current time, equal to %H:%M:%S "12:49:11" * %u weekday as a decimal number ["1", "7"], with "1" representing Monday "1" to "7" * %U week number of the current year as a decimal number, starting with the "0" to ("52" or "53") * first Sunday as the first day of the first week * %V The ISO 8601:1988 week number of the current year as a decimal number, "00" to ("52" or "53") * range 01 to 53, where week 1 is the first week that has at least 4 days * in the current year, and with Monday as the first day of the week. * (Use %G or %g for the year component that corresponds to the week number * for the specified timestamp.) * %W week number of the current year as a decimal number, starting with the "00" to ("52" or "53") * first Monday as the first day of the first week * %w day of the week as a decimal, Sunday being "0" "0" to "6" * %x preferred date representation for the current locale without the time "4/13/2008" * %X preferred time representation for the current locale without the date "12:53:05" * %y year as a decimal number without a century "00" "99" * %Y year as a decimal number including the century "2008" * %Z time zone or name or abbreviation "UTC", "EST", "PST" * %z same as %Z * %% a literal "%" characters "%" * d Day of the month, 2 digits with leading zeros "01" to "31" * D A textual representation of a day, three letters "Mon" through "Sun" * j Day of the month without leading zeros "1" to "31" * l A full textual representation of the day of the week (lowercase "L") "Sunday" through "Saturday" * N ISO-8601 numeric representation of the day of the week (added in PHP 5.1.0) "1" (for Monday) through "7" (for Sunday) * S English ordinal suffix for the day of the month, 2 characters "st", "nd", "rd" or "th". Works well with j * w Numeric representation of the day of the week "0" (for Sunday) through "6" (for Saturday) * z The day of the year (starting from "0") "0" through "365" * W ISO-8601 week number of year, weeks starting on Monday "00" to ("52" or "53") * F A full textual representation of a month, such as January or March "January" through "December" * m Numeric representation of a month, with leading zeros "01" through "12" * M A short textual representation of a month, three letters "Jan" through "Dec" * n Numeric representation of a month, without leading zeros "1" through "12" * t Number of days in the given month "28" through "31" * L Whether it's a leap year "1" if it is a leap year, "0" otherwise * o ISO-8601 year number. This has the same value as Y, except that if the "2008" * ISO week number (W) belongs to the previous or next year, that year * is used instead. * Y A full numeric representation of a year, 4 digits "2008" * y A two digit representation of a year "08" * a Lowercase Ante meridiem and Post meridiem "am" or "pm" * A Uppercase Ante meridiem and Post meridiem "AM" or "PM" * B Swatch Internet time "000" through "999" * g 12-hour format of an hour without leading zeros "1" through "12" * G 24-hour format of an hour without leading zeros "0" through "23" * h 12-hour format of an hour with leading zeros "01" through "12" * H 24-hour format of an hour with leading zeros "00" through "23" * i Minutes with leading zeros "00" to "59" * s Seconds, with leading zeros "00" through "59" * u Milliseconds "54321" * e Timezone identifier "UTC", "EST", "PST" * I Whether or not the date is in daylight saving time (uppercase i) "1" if Daylight Saving Time, "0" otherwise * O Difference to Greenwich time (GMT) in hours "+0200", "-0600" * P Difference to Greenwich time (GMT) with colon between hours and minutes "+02:00", "-06:00" * T Timezone abbreviation "UTC", "EST", "PST" * Z Timezone offset in seconds. The offset for timezones west of UTC is "-43200" through "50400" * always negative, and for those east of UTC is always positive. * c ISO 8601 date "2004-02-12T15:19:21+00:00" * r RFC 2822 formatted date "Thu, 21 Dec 2000 16:01:07 +0200" * U Seconds since the Unix Epoch (January 1 1970 00:00:00 GMT) "0" * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @return {String} A string representation of the current Date object. */ var formatReplace = function (context) { return function (m) { var formatString, override = false; if (m.charAt(0) === "\\" || m.substring(0, 2) === "%%") { return m.replace("\\", "").replace("%%", "%"); } override = normalizer.shouldOverrideDefaults(m); formatString = $D.normalizeFormat(m, context); if (formatString) { return context.toString(formatString, override); } }; }; $P._format = function (format) { var formatter = formatReplace(this); if (!format) { return this._toString(); } else { return format.replace(/(%|\\)?.|%%/g, formatter); } }; if (!$P.format) { $P.format = $P._format; } }()); (function () { "use strict"; var gFn = function (attr) { return function () { return this[attr]; }; }; var sFn = function (attr) { return function (val) { this[attr] = val; return this; }; }; var attrs = ["years", "months", "days", "hours", "minutes", "seconds", "milliseconds"]; var addSetFuncs = function (context, attrs) { for (var i = 0; i < attrs.length ; i++) { var $a = attrs[i], $b = $a.slice(0, 1).toUpperCase() + $a.slice(1); context.prototype[$a] = 0; context.prototype["get" + $b] = gFn($a); context.prototype["set" + $b] = sFn($a); } }; /** * new TimeSpan(milliseconds); * new TimeSpan(days, hours, minutes, seconds); * new TimeSpan(days, hours, minutes, seconds, milliseconds); */ var TimeSpan = function (days, hours, minutes, seconds, milliseconds) { if (arguments.length === 1 && typeof days === "number") { var orient = (days < 0) ? -1 : +1; var millsLeft = Math.abs(days); this.setDays(Math.floor(millsLeft / 86400000) * orient); millsLeft = millsLeft % 86400000; this.setHours(Math.floor(millsLeft / 3600000) * orient); millsLeft = millsLeft % 3600000; this.setMinutes(Math.floor(millsLeft / 60000) * orient); millsLeft = millsLeft % 60000; this.setSeconds(Math.floor(millsLeft / 1000) * orient); millsLeft = millsLeft % 1000; this.setMilliseconds(millsLeft * orient); } else { this.set(days, hours, minutes, seconds, milliseconds); } this.getTotalMilliseconds = function () { return (this.getDays() * 86400000) + (this.getHours() * 3600000) + (this.getMinutes() * 60000) + (this.getSeconds() * 1000); }; this.compareTo = function (time) { var t1 = new Date(1970, 1, 1, this.getHours(), this.getMinutes(), this.getSeconds()), t2; if (time === null) { t2 = new Date(1970, 1, 1, 0, 0, 0); } else { t2 = new Date(1970, 1, 1, time.getHours(), time.getMinutes(), time.getSeconds()); } return (t1 < t2) ? -1 : (t1 > t2) ? 1 : 0; }; this.equals = function (time) { return (this.compareTo(time) === 0); }; this.add = function (time) { return (time === null) ? this : this.addSeconds(time.getTotalMilliseconds() / 1000); }; this.subtract = function (time) { return (time === null) ? this : this.addSeconds(-time.getTotalMilliseconds() / 1000); }; this.addDays = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 86400000)); }; this.addHours = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 3600000)); }; this.addMinutes = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 60000)); }; this.addSeconds = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 1000)); }; this.addMilliseconds = function (n) { return new TimeSpan(this.getTotalMilliseconds() + n); }; this.get12HourHour = function () { return (this.getHours() > 12) ? this.getHours() - 12 : (this.getHours() === 0) ? 12 : this.getHours(); }; this.getDesignator = function () { return (this.getHours() < 12) ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator; }; this.toString = function (format) { this._toString = function () { if (this.getDays() !== null && this.getDays() > 0) { return this.getDays() + "." + this.getHours() + ":" + this.p(this.getMinutes()) + ":" + this.p(this.getSeconds()); } else { return this.getHours() + ":" + this.p(this.getMinutes()) + ":" + this.p(this.getSeconds()); } }; this.p = function (s) { return (s.toString().length < 2) ? "0" + s : s; }; var me = this; return format ? format.replace(/dd?|HH?|hh?|mm?|ss?|tt?/g, function (format) { switch (format) { case "d": return me.getDays(); case "dd": return me.p(me.getDays()); case "H": return me.getHours(); case "HH": return me.p(me.getHours()); case "h": return me.get12HourHour(); case "hh": return me.p(me.get12HourHour()); case "m": return me.getMinutes(); case "mm": return me.p(me.getMinutes()); case "s": return me.getSeconds(); case "ss": return me.p(me.getSeconds()); case "t": return ((me.getHours() < 12) ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator).substring(0, 1); case "tt": return (me.getHours() < 12) ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator; } } ) : this._toString(); }; return this; }; addSetFuncs(TimeSpan, attrs.slice(2)); TimeSpan.prototype.set = function (days, hours, minutes, seconds, milliseconds){ this.setDays(days || this.getDays()); this.setHours(hours || this.getHours()); this.setMinutes(minutes || this.getMinutes()); this.setSeconds(seconds || this.getSeconds()); this.setMilliseconds(milliseconds || this.getMilliseconds()); }; /** * Gets the time of day for this date instances. * @return {TimeSpan} TimeSpan */ Date.prototype.getTimeOfDay = function () { return new TimeSpan(0, this.getHours(), this.getMinutes(), this.getSeconds(), this.getMilliseconds()); }; Date.TimeSpan = TimeSpan; if (typeof window !== "undefined" ) { // keeping API compatible for v1.x window.TimeSpan = TimeSpan; } }()); (function () { "use strict"; var attrs = ["years", "months", "days", "hours", "minutes", "seconds", "milliseconds"]; var gFn = function (attr) { return function () { return this[attr]; }; }; var sFn = function (attr) { return function (val) { this[attr] = val; return this; }; }; var addSetFuncs = function (context, attrs) { for (var i = 0; i < attrs.length ; i++) { var $a = attrs[i], $b = $a.slice(0, 1).toUpperCase() + $a.slice(1); context.prototype[$a] = 0; context.prototype["get" + $b] = gFn($a); context.prototype["set" + $b] = sFn($a); } }; var setMonthsAndYears = function (orient, d1, d2, context) { function inc() { d1.addMonths(-orient); context.months++; if (context.months === 12) { context.years++; context.months = 0; } } if (orient === +1) { while (d1 > d2) { inc(); } } else { while (d1 < d2) { inc(); } } context.months--; context.months *= orient; context.years *= orient; }; var adjustForDST = function(orient, startDate, endDate) { var hasDSTMismatch = (false === (startDate.isDaylightSavingTime() === endDate.isDaylightSavingTime())); if (hasDSTMismatch && orient === 1) { startDate.addHours(-1); } else if (hasDSTMismatch) { startDate.addHours(1); } }; /** * TimePeriod(startDate, endDate); * TimePeriod(years, months, days, hours, minutes, seconds, milliseconds); */ var TimePeriod = function (years, months, days, hours, minutes, seconds, milliseconds) { if (arguments.length === 7) { this.set(years, months, days, hours, minutes, seconds, milliseconds); } else if (arguments.length === 2 && arguments[0] instanceof Date && arguments[1] instanceof Date) { var startDate = arguments[0].clone(); var endDate = arguments[1].clone(); var orient = (startDate > endDate) ? +1 : -1; this.dates = { start: arguments[0].clone(), end: arguments[1].clone() }; setMonthsAndYears(orient, startDate, endDate, this); adjustForDST(orient, startDate, endDate); // // TODO - adjust for DST var diff = endDate - startDate; if (diff !== 0) { var ts = new TimeSpan(diff); this.set(this.years, this.months, ts.getDays(), ts.getHours(), ts.getMinutes(), ts.getSeconds(), ts.getMilliseconds()); } } return this; }; // create all the set functions. addSetFuncs(TimePeriod, attrs); TimePeriod.prototype.set = function (years, months, days, hours, minutes, seconds, milliseconds){ this.setYears(years || this.getYears()); this.setMonths(months || this.getMonths()); this.setDays(days || this.getDays()); this.setHours(hours || this.getHours()); this.setMinutes(minutes || this.getMinutes()); this.setSeconds(seconds || this.getSeconds()); this.setMilliseconds(milliseconds || this.getMilliseconds()); }; Date.TimePeriod = TimePeriod; if (typeof window !== "undefined") { // keeping API compatible for v1.x window.TimePeriod = TimePeriod; } }()); ================================================ FILE: build/date-en-029.js ================================================ /** * @overview datejs * @version 1.0.0-rc3 * @author Gregory Wild-Smith * @copyright 2015 Gregory Wild-Smith * @license MIT * @homepage https://github.com/abritinthebay/datejs */ /* * DateJS Culture String File * Country Code: en-029 * Name: English (Caribbean) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["en-029"] = { "name": "en-029", "englishName": "English (Caribbean)", "nativeName": "English (Caribbean)", "Sunday": "Sunday", "Monday": "Monday", "Tuesday": "Tuesday", "Wednesday": "Wednesday", "Thursday": "Thursday", "Friday": "Friday", "Saturday": "Saturday", "Sun": "Sun", "Mon": "Mon", "Tue": "Tue", "Wed": "Wed", "Thu": "Thu", "Fri": "Fri", "Sat": "Sat", "Su": "Su", "Mo": "Mo", "Tu": "Tu", "We": "We", "Th": "Th", "Fr": "Fr", "Sa": "Sa", "S_Sun_Initial": "S", "M_Mon_Initial": "M", "T_Tue_Initial": "T", "W_Wed_Initial": "W", "T_Thu_Initial": "T", "F_Fri_Initial": "F", "S_Sat_Initial": "S", "January": "January", "February": "February", "March": "March", "April": "April", "May": "May", "June": "June", "July": "July", "August": "August", "September": "September", "October": "October", "November": "November", "December": "December", "Jan_Abbr": "Jan", "Feb_Abbr": "Feb", "Mar_Abbr": "Mar", "Apr_Abbr": "Apr", "May_Abbr": "May", "Jun_Abbr": "Jun", "Jul_Abbr": "Jul", "Aug_Abbr": "Aug", "Sep_Abbr": "Sep", "Oct_Abbr": "Oct", "Nov_Abbr": "Nov", "Dec_Abbr": "Dec", "AM": "AM", "PM": "PM", "firstDayOfWeek": 1, "twoDigitYearMax": 2029, "mdy": "mdy", "M/d/yyyy": "MM/dd/yyyy", "dddd, MMMM dd, yyyy": "dddd, MMMM dd, yyyy", "h:mm tt": "h:mm tt", "h:mm:ss tt": "h:mm:ss tt", "dddd, MMMM dd, yyyy h:mm:ss tt": "dddd, MMMM dd, yyyy h:mm:ss tt", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "MMMM dd", "MMMM, yyyy": "MMMM, yyyy", "/jan(uary)?/": "jan(uary)?", "/feb(ruary)?/": "feb(ruary)?", "/mar(ch)?/": "mar(ch)?", "/apr(il)?/": "apr(il)?", "/may/": "may", "/jun(e)?/": "jun(e)?", "/jul(y)?/": "jul(y)?", "/aug(ust)?/": "aug(ust)?", "/sep(t(ember)?)?/": "sep(t(ember)?)?", "/oct(ober)?/": "oct(ober)?", "/nov(ember)?/": "nov(ember)?", "/dec(ember)?/": "dec(ember)?", "/^su(n(day)?)?/": "^su(n(day)?)?", "/^mo(n(day)?)?/": "^mo(n(day)?)?", "/^tu(e(s(day)?)?)?/": "^tu(e(s(day)?)?)?", "/^we(d(nesday)?)?/": "^we(d(nesday)?)?", "/^th(u(r(s(day)?)?)?)?/": "^th(u(r(s(day)?)?)?)?", "/^fr(i(day)?)?/": "^fr(i(day)?)?", "/^sa(t(urday)?)?/": "^sa(t(urday)?)?", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "en-029"; /** * @overview datejs * @version 1.0.0-rc3 * @author Gregory Wild-Smith * @copyright 2015 Gregory Wild-Smith * @license MIT * @homepage https://github.com/abritinthebay/datejs */(function () { var $D = Date; var lang = Date.CultureStrings ? Date.CultureStrings.lang : null; var loggedKeys = {}; // for debug purposes. var getText = { getFromKey: function (key, countryCode) { var output; if (Date.CultureStrings && Date.CultureStrings[countryCode] && Date.CultureStrings[countryCode][key]) { output = Date.CultureStrings[countryCode][key]; } else { output = getText.buildFromDefault(key); } if (key.charAt(0) === "/") { // Assume it's a regex output = getText.buildFromRegex(key, countryCode); } return output; }, getFromObjectValues: function (obj, countryCode) { var key, output = {}; for(key in obj) { if (obj.hasOwnProperty(key)) { output[key] = getText.getFromKey(obj[key], countryCode); } } return output; }, getFromObjectKeys: function (obj, countryCode) { var key, output = {}; for(key in obj) { if (obj.hasOwnProperty(key)) { output[getText.getFromKey(key, countryCode)] = obj[key]; } } return output; }, getFromArray: function (arr, countryCode) { var output = []; for (var i=0; i < arr.length; i++){ if (i in arr) { output[i] = getText.getFromKey(arr[i], countryCode); } } return output; }, buildFromDefault: function (key) { var output, length, split, last; switch(key) { case "name": output = "en-US"; break; case "englishName": output = "English (United States)"; break; case "nativeName": output = "English (United States)"; break; case "twoDigitYearMax": output = 2049; break; case "firstDayOfWeek": output = 0; break; default: output = key; split = key.split("_"); length = split.length; if (length > 1 && key.charAt(0) !== "/") { // if the key isn't a regex and it has a split. last = split[(length - 1)].toLowerCase(); if (last === "initial" || last === "abbr") { output = split[0]; } } break; } return output; }, buildFromRegex: function (key, countryCode) { var output; if (Date.CultureStrings && Date.CultureStrings[countryCode] && Date.CultureStrings[countryCode][key]) { output = new RegExp(Date.CultureStrings[countryCode][key], "i"); } else { output = new RegExp(key.replace(new RegExp("/", "g"),""), "i"); } return output; } }; var shallowMerge = function (obj1, obj2) { for (var attrname in obj2) { if (obj2.hasOwnProperty(attrname)) { obj1[attrname] = obj2[attrname]; } } }; var __ = function (key, language) { var countryCode = (language) ? language : lang; loggedKeys[key] = key; if (typeof key === "object") { if (key instanceof Array) { return getText.getFromArray(key, countryCode); } else { return getText.getFromObjectKeys(key, countryCode); } } else { return getText.getFromKey(key, countryCode); } }; var loadI18nScript = function (code) { // paatterned after jQuery's getScript. var url = Date.Config.i18n + code + ".js"; var head = document.getElementsByTagName("head")[0] || document.documentElement; var script = document.createElement("script"); script.src = url; var completed = false; var events = { done: function (){} // placeholder function }; // Attach handlers for all browsers script.onload = script.onreadystatechange = function() { if ( !completed && (!this.readyState || this.readyState === "loaded" || this.readyState === "complete") ) { events.done(); head.removeChild(script); } }; setTimeout(function() { head.insertBefore(script, head.firstChild); }, 0); // allows return to execute first return { done: function (cb) { events.done = function() { if (cb) { setTimeout(cb,0); } }; } }; }; var buildInfo = { buildFromMethodHash: function (obj) { var key; for(key in obj) { if (obj.hasOwnProperty(key)) { obj[key] = buildInfo[obj[key]](); } } return obj; }, timeZoneDST: function () { var DST = { "CHADT": "+1345", "NZDT": "+1300", "AEDT": "+1100", "ACDT": "+1030", "AZST": "+0500", "IRDT": "+0430", "EEST": "+0300", "CEST": "+0200", "BST": "+0100", "PMDT": "-0200", "ADT": "-0300", "NDT": "-0230", "EDT": "-0400", "CDT": "-0500", "MDT": "-0600", "PDT": "-0700", "AKDT": "-0800", "HADT": "-0900" }; return __(DST); }, timeZoneStandard: function () { var standard = { "LINT": "+1400", "TOT": "+1300", "CHAST": "+1245", "NZST": "+1200", "NFT": "+1130", "SBT": "+1100", "AEST": "+1000", "ACST": "+0930", "JST": "+0900", "CWST": "+0845", "CT": "+0800", "ICT": "+0700", "MMT": "+0630", "BST": "+0600", "NPT": "+0545", "IST": "+0530", "PKT": "+0500", "AFT": "+0430", "MSK": "+0400", "IRST": "+0330", "FET": "+0300", "EET": "+0200", "CET": "+0100", "GMT": "+0000", "UTC": "+0000", "CVT": "-0100", "GST": "-0200", "BRT": "-0300", "NST": "-0330", "AST": "-0400", "EST": "-0500", "CST": "-0600", "MST": "-0700", "PST": "-0800", "AKST": "-0900", "MIT": "-0930", "HST": "-1000", "SST": "-1100", "BIT": "-1200" }; return __(standard); }, timeZones: function (data) { var zone; data.timezones = []; for (zone in data.abbreviatedTimeZoneStandard) { if (data.abbreviatedTimeZoneStandard.hasOwnProperty(zone)) { data.timezones.push({ name: zone, offset: data.abbreviatedTimeZoneStandard[zone]}); } } for (zone in data.abbreviatedTimeZoneDST) { if (data.abbreviatedTimeZoneDST.hasOwnProperty(zone)) { data.timezones.push({ name: zone, offset: data.abbreviatedTimeZoneDST[zone], dst: true}); } } return data.timezones; }, days: function () { return __(["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"]); }, dayAbbr: function () { return __(["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"]); }, dayShortNames: function () { return __(["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"]); }, dayFirstLetters: function () { return __(["S_Sun_Initial", "M_Mon_Initial", "T_Tues_Initial", "W_Wed_Initial", "T_Thu_Initial", "F_Fri_Initial", "S_Sat_Initial"]); }, months: function () { return __(["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"]); }, monthAbbr: function () { return __(["Jan_Abbr", "Feb_Abbr", "Mar_Abbr", "Apr_Abbr", "May_Abbr", "Jun_Abbr", "Jul_Abbr", "Aug_Abbr", "Sep_Abbr", "Oct_Abbr", "Nov_Abbr", "Dec_Abbr"]); }, formatPatterns: function () { return getText.getFromObjectValues({ shortDate: "M/d/yyyy", longDate: "dddd, MMMM dd, yyyy", shortTime: "h:mm tt", longTime: "h:mm:ss tt", fullDateTime: "dddd, MMMM dd, yyyy h:mm:ss tt", sortableDateTime: "yyyy-MM-ddTHH:mm:ss", universalSortableDateTime: "yyyy-MM-dd HH:mm:ssZ", rfc1123: "ddd, dd MMM yyyy HH:mm:ss", monthDay: "MMMM dd", yearMonth: "MMMM, yyyy" }, Date.i18n.currentLanguage()); }, regex: function () { return getText.getFromObjectValues({ inTheMorning: "/( in the )(morn(ing)?)\\b/", thisMorning: "/(this )(morn(ing)?)\\b/", amThisMorning: "/(\b\\d(am)? )(this )(morn(ing)?)/", inTheEvening: "/( in the )(even(ing)?)\\b/", thisEvening: "/(this )(even(ing)?)\\b/", pmThisEvening: "/(\b\\d(pm)? )(this )(even(ing)?)/", jan: "/jan(uary)?/", feb: "/feb(ruary)?/", mar: "/mar(ch)?/", apr: "/apr(il)?/", may: "/may/", jun: "/jun(e)?/", jul: "/jul(y)?/", aug: "/aug(ust)?/", sep: "/sep(t(ember)?)?/", oct: "/oct(ober)?/", nov: "/nov(ember)?/", dec: "/dec(ember)?/", sun: "/^su(n(day)?)?/", mon: "/^mo(n(day)?)?/", tue: "/^tu(e(s(day)?)?)?/", wed: "/^we(d(nesday)?)?/", thu: "/^th(u(r(s(day)?)?)?)?/", fri: "/fr(i(day)?)?/", sat: "/^sa(t(urday)?)?/", future: "/^next/", past: "/^last|past|prev(ious)?/", add: "/^(\\+|aft(er)?|from|hence)/", subtract: "/^(\\-|bef(ore)?|ago)/", yesterday: "/^yes(terday)?/", today: "/^t(od(ay)?)?/", tomorrow: "/^tom(orrow)?/", now: "/^n(ow)?/", millisecond: "/^ms|milli(second)?s?/", second: "/^sec(ond)?s?/", minute: "/^mn|min(ute)?s?/", hour: "/^h(our)?s?/", week: "/^w(eek)?s?/", month: "/^m(onth)?s?/", day: "/^d(ay)?s?/", year: "/^y(ear)?s?/", shortMeridian: "/^(a|p)/", longMeridian: "/^(a\\.?m?\\.?|p\\.?m?\\.?)/", timezone: "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/", ordinalSuffix: "/^\\s*(st|nd|rd|th)/", timeContext: "/^\\s*(\\:|a(?!u|p)|p)/" }, Date.i18n.currentLanguage()); } }; var CultureInfo = function () { var info = getText.getFromObjectValues({ name: "name", englishName: "englishName", nativeName: "nativeName", amDesignator: "AM", pmDesignator: "PM", firstDayOfWeek: "firstDayOfWeek", twoDigitYearMax: "twoDigitYearMax", dateElementOrder: "mdy" }, Date.i18n.currentLanguage()); var constructedInfo = buildInfo.buildFromMethodHash({ dayNames: "days", abbreviatedDayNames: "dayAbbr", shortestDayNames: "dayShortNames", firstLetterDayNames: "dayFirstLetters", monthNames: "months", abbreviatedMonthNames: "monthAbbr", formatPatterns: "formatPatterns", regexPatterns: "regex", abbreviatedTimeZoneDST: "timeZoneDST", abbreviatedTimeZoneStandard: "timeZoneStandard" }); shallowMerge(info, constructedInfo); buildInfo.timeZones(info); return info; }; $D.i18n = { __: function (key, lang) { return __(key, lang); }, currentLanguage: function () { return lang || "en-US"; }, setLanguage: function (code, force, cb) { var async = false; if (force || code === "en-US" || (!!Date.CultureStrings && !!Date.CultureStrings[code])) { lang = code; Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings.lang = code; Date.CultureInfo = new CultureInfo(); } else { if (!(!!Date.CultureStrings && !!Date.CultureStrings[code])) { if (typeof exports !== "undefined" && this.exports !== exports) { // we're in a Node enviroment, load it using require try { require("../i18n/" + code + ".js"); lang = code; Date.CultureStrings.lang = code; Date.CultureInfo = new CultureInfo(); } catch (e) { // var str = "The language for '" + code + "' could not be loaded by Node. It likely does not exist."; throw new Error("The DateJS IETF language tag '" + code + "' could not be loaded by Node. It likely does not exist."); } } else if (Date.Config && Date.Config.i18n) { // we know the location of the files, so lets load them async = true; loadI18nScript(code).done(function(){ lang = code; Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings.lang = code; Date.CultureInfo = new CultureInfo(); $D.Parsing.Normalizer.buildReplaceData(); // because this is async if ($D.Grammar) { $D.Grammar.buildGrammarFormats(); // so we can parse those strings... } if (cb) { setTimeout(cb,0); } }); } else { Date.console.error("The DateJS IETF language tag '" + code + "' is not available and has not been loaded."); return false; } } } $D.Parsing.Normalizer.buildReplaceData(); // rebuild normalizer strings if ($D.Grammar) { $D.Grammar.buildGrammarFormats(); // so we can parse those strings... } if (!async && cb) { setTimeout(cb,0); } }, getLoggedKeys: function () { return loggedKeys; }, updateCultureInfo: function () { Date.CultureInfo = new CultureInfo(); } }; $D.i18n.updateCultureInfo(); // run automatically }()); (function () { var $D = Date, $P = $D.prototype, p = function (s, l) { if (!l) { l = 2; } return ("000" + s).slice(l * -1); }; if (typeof window !== "undefined" && typeof window.console !== "undefined" && typeof window.console.log !== "undefined") { $D.console = console; // used only to raise non-critical errors if available } else { // set mock so we don't give errors. $D.console = { log: function(){}, error: function(){} }; } $D.Config = $D.Config || {}; $D.initOverloads = function() { /** * Overload of Date.now. Allows an alternate call for Date.now where it returns the * current Date as an object rather than just milliseconds since the Unix Epoch. * * Also provides an implementation of now() for browsers (IE<9) that don't have it. * * Backwards compatible so with work with either: * Date.now() [returns ms] * or * Date.now(true) [returns Date] */ if (!$D.now) { $D._now = function now() { return new Date().getTime(); }; } else if (!$D._now) { $D._now = $D.now; } $D.now = function (returnObj) { if (returnObj) { return $D.present(); } else { return $D._now(); } }; if ( !$P.toISOString ) { $P.toISOString = function() { return this.getUTCFullYear() + "-" + p(this.getUTCMonth() + 1) + "-" + p(this.getUTCDate()) + "T" + p(this.getUTCHours()) + ":" + p(this.getUTCMinutes()) + ":" + p(this.getUTCSeconds()) + "." + String( (this.getUTCMilliseconds()/1000).toFixed(3)).slice(2, 5) + "Z"; }; } // private if ( $P._toString === undefined ){ $P._toString = $P.toString; } }; $D.initOverloads(); /** * Gets a date that is set to the current date. The time is set to the start of the day (00:00 or 12:00 AM). * @return {Date} The current date. */ $D.today = function () { return new Date().clearTime(); }; /** * Gets a date that is set to the current date and time (same as new Date, but chainable) * @return {Date} The current date. */ $D.present = function () { return new Date(); }; /** * Compares the first date to the second date and returns an number indication of their relative values. * @param {Date} First Date object to compare [Required]. * @param {Date} Second Date object to compare to [Required]. * @return {Number} -1 = date1 is lessthan date2. 0 = values are equal. 1 = date1 is greaterthan date2. */ $D.compare = function (date1, date2) { if (isNaN(date1) || isNaN(date2)) { throw new Error(date1 + " - " + date2); } else if (date1 instanceof Date && date2 instanceof Date) { return (date1 < date2) ? -1 : (date1 > date2) ? 1 : 0; } else { throw new TypeError(date1 + " - " + date2); } }; /** * Compares the first Date object to the second Date object and returns true if they are equal. * @param {Date} First Date object to compare [Required] * @param {Date} Second Date object to compare to [Required] * @return {Boolean} true if dates are equal. false if they are not equal. */ $D.equals = function (date1, date2) { return (date1.compareTo(date2) === 0); }; /** * Gets the language appropriate day name when given the day number(0-6) * eg - 0 == Sunday * @return {String} The day name */ $D.getDayName = function (n) { return Date.CultureInfo.dayNames[n]; }; /** * Gets the day number (0-6) if given a CultureInfo specific string which is a valid dayName, abbreviatedDayName or shortestDayName (two char). * @param {String} The name of the day (eg. "Monday, "Mon", "tuesday", "tue", "We", "we"). * @return {Number} The day number */ $D.getDayNumberFromName = function (name) { var n = Date.CultureInfo.dayNames, m = Date.CultureInfo.abbreviatedDayNames, o = Date.CultureInfo.shortestDayNames, s = name.toLowerCase(); for (var i = 0; i < n.length; i++) { if (n[i].toLowerCase() === s || m[i].toLowerCase() === s || o[i].toLowerCase() === s) { return i; } } return -1; }; /** * Gets the month number (0-11) if given a Culture Info specific string which is a valid monthName or abbreviatedMonthName. * @param {String} The name of the month (eg. "February, "Feb", "october", "oct"). * @return {Number} The day number */ $D.getMonthNumberFromName = function (name) { var n = Date.CultureInfo.monthNames, m = Date.CultureInfo.abbreviatedMonthNames, s = name.toLowerCase(); for (var i = 0; i < n.length; i++) { if (n[i].toLowerCase() === s || m[i].toLowerCase() === s) { return i; } } return -1; }; /** * Gets the language appropriate month name when given the month number(0-11) * eg - 0 == January * @return {String} The month name */ $D.getMonthName = function (n) { return Date.CultureInfo.monthNames[n]; }; /** * Determines if the current date instance is within a LeapYear. * @param {Number} The year. * @return {Boolean} true if date is within a LeapYear, otherwise false. */ $D.isLeapYear = function (year) { return ((year % 4 === 0 && year % 100 !== 0) || year % 400 === 0); }; /** * Gets the number of days in the month, given a year and month value. Automatically corrects for LeapYear. * @param {Number} The year. * @param {Number} The month (0-11). * @return {Number} The number of days in the month. */ $D.getDaysInMonth = function (year, month) { if (!month && $D.validateMonth(year)) { month = year; year = Date.today().getFullYear(); } return [31, ($D.isLeapYear(year) ? 29 : 28), 31, 30, 31, 30, 31, 31, 30, 31, 30, 31][month]; }; $P.getDaysInMonth = function () { return $D.getDaysInMonth(this.getFullYear(), this.getMonth()); }; $D.getTimezoneAbbreviation = function (offset, dst) { var p, n = (dst || false) ? Date.CultureInfo.abbreviatedTimeZoneDST : Date.CultureInfo.abbreviatedTimeZoneStandard; for (p in n) { if (n.hasOwnProperty(p)) { if (n[p] === offset) { return p; } } } return null; }; $D.getTimezoneOffset = function (name, dst) { var i, a =[], z = Date.CultureInfo.timezones; if (!name) { name = (new Date()).getTimezone();} for (i = 0; i < z.length; i++) { if (z[i].name === name.toUpperCase()) { a.push(i); } } if (!z[a[0]]) { return null; } if (a.length === 1 || !dst) { return z[a[0]].offset; } else { for (i=0; i < a.length; i++) { if (z[a[i]].dst) { return z[a[i]].offset; } } } }; $D.getQuarter = function (d) { d = d || new Date(); // If no date supplied, use today var q = [1,2,3,4]; return q[Math.floor(d.getMonth() / 3)]; // ~~~ is a bitwise op. Faster than Math.floor }; $D.getDaysLeftInQuarter = function (d) { d = d || new Date(); var qEnd = new Date(d); qEnd.setMonth(qEnd.getMonth() + 3 - qEnd.getMonth() % 3, 0); return Math.floor((qEnd - d) / 8.64e7); }; // private var validate = function (n, min, max, name) { name = name ? name : "Object"; if (typeof n === "undefined") { return false; } else if (typeof n !== "number") { throw new TypeError(n + " is not a Number."); } else if (n < min || n > max) { // As failing validation is *not* an exceptional circumstance // lets not throw a RangeError Exception here. // It's semantically correct but it's not sensible. return false; } return true; }; /** * Validates the number is within an acceptable range for milliseconds [0-999]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateMillisecond = function (value) { return validate(value, 0, 999, "millisecond"); }; /** * Validates the number is within an acceptable range for seconds [0-59]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateSecond = function (value) { return validate(value, 0, 59, "second"); }; /** * Validates the number is within an acceptable range for minutes [0-59]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateMinute = function (value) { return validate(value, 0, 59, "minute"); }; /** * Validates the number is within an acceptable range for hours [0-23]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateHour = function (value) { return validate(value, 0, 23, "hour"); }; /** * Validates the number is within an acceptable range for the days in a month [0-MaxDaysInMonth]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateDay = function (value, year, month) { if (year === undefined || year === null || month === undefined || month === null) { return false;} return validate(value, 1, $D.getDaysInMonth(year, month), "day"); }; /** * Validates the number is within an acceptable range for months [0-11]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateWeek = function (value) { return validate(value, 0, 53, "week"); }; /** * Validates the number is within an acceptable range for months [0-11]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateMonth = function (value) { return validate(value, 0, 11, "month"); }; /** * Validates the number is within an acceptable range for years. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateYear = function (value) { /** * Per ECMAScript spec the range of times supported by Date objects is * exactly -100,000,000 days to +100,000,000 days measured relative to * midnight at the beginning of 01 January, 1970 UTC. * This gives a range of 8,640,000,000,000,000 milliseconds to either * side of 01 January, 1970 UTC. * * Earliest possible date: Tue, 20 Apr 271,822 B.C. 00:00:00 UTC * Latest possible date: Sat, 13 Sep 275,760 00:00:00 UTC */ return validate(value, -271822, 275760, "year"); }; $D.validateTimezone = function(value) { var timezones = {"ACDT":1,"ACST":1,"ACT":1,"ADT":1,"AEDT":1,"AEST":1,"AFT":1,"AKDT":1,"AKST":1,"AMST":1,"AMT":1,"ART":1,"AST":1,"AWDT":1,"AWST":1,"AZOST":1,"AZT":1,"BDT":1,"BIOT":1,"BIT":1,"BOT":1,"BRT":1,"BST":1,"BTT":1,"CAT":1,"CCT":1,"CDT":1,"CEDT":1,"CEST":1,"CET":1,"CHADT":1,"CHAST":1,"CHOT":1,"ChST":1,"CHUT":1,"CIST":1,"CIT":1,"CKT":1,"CLST":1,"CLT":1,"COST":1,"COT":1,"CST":1,"CT":1,"CVT":1,"CWST":1,"CXT":1,"DAVT":1,"DDUT":1,"DFT":1,"EASST":1,"EAST":1,"EAT":1,"ECT":1,"EDT":1,"EEDT":1,"EEST":1,"EET":1,"EGST":1,"EGT":1,"EIT":1,"EST":1,"FET":1,"FJT":1,"FKST":1,"FKT":1,"FNT":1,"GALT":1,"GAMT":1,"GET":1,"GFT":1,"GILT":1,"GIT":1,"GMT":1,"GST":1,"GYT":1,"HADT":1,"HAEC":1,"HAST":1,"HKT":1,"HMT":1,"HOVT":1,"HST":1,"ICT":1,"IDT":1,"IOT":1,"IRDT":1,"IRKT":1,"IRST":1,"IST":1,"JST":1,"KGT":1,"KOST":1,"KRAT":1,"KST":1,"LHST":1,"LINT":1,"MAGT":1,"MART":1,"MAWT":1,"MDT":1,"MET":1,"MEST":1,"MHT":1,"MIST":1,"MIT":1,"MMT":1,"MSK":1,"MST":1,"MUT":1,"MVT":1,"MYT":1,"NCT":1,"NDT":1,"NFT":1,"NPT":1,"NST":1,"NT":1,"NUT":1,"NZDT":1,"NZST":1,"OMST":1,"ORAT":1,"PDT":1,"PET":1,"PETT":1,"PGT":1,"PHOT":1,"PHT":1,"PKT":1,"PMDT":1,"PMST":1,"PONT":1,"PST":1,"PYST":1,"PYT":1,"RET":1,"ROTT":1,"SAKT":1,"SAMT":1,"SAST":1,"SBT":1,"SCT":1,"SGT":1,"SLST":1,"SRT":1,"SST":1,"SYOT":1,"TAHT":1,"THA":1,"TFT":1,"TJT":1,"TKT":1,"TLT":1,"TMT":1,"TOT":1,"TVT":1,"UCT":1,"ULAT":1,"UTC":1,"UYST":1,"UYT":1,"UZT":1,"VET":1,"VLAT":1,"VOLT":1,"VOST":1,"VUT":1,"WAKT":1,"WAST":1,"WAT":1,"WEDT":1,"WEST":1,"WET":1,"WST":1,"YAKT":1,"YEKT":1,"Z":1}; return (timezones[value] === 1); }; $D.validateTimezoneOffset= function(value) { // timezones go from +14hrs to -12hrs, the +X hours are negative offsets. return (value > -841 && value < 721); }; }()); (function () { var $D = Date, $P = $D.prototype, p = function (s, l) { if (!l) { l = 2; } return ("000" + s).slice(l * -1); }; var validateConfigObject = function (obj) { var result = {}, self = this, prop, testFunc; testFunc = function (prop, func, value) { if (prop === "day") { var month = (obj.month !== undefined) ? obj.month : self.getMonth(); var year = (obj.year !== undefined) ? obj.year : self.getFullYear(); return $D[func](value, year, month); } else { return $D[func](value); } }; for (prop in obj) { if (Object.prototype.hasOwnProperty.call(obj, prop)) { var func = "validate" + prop.charAt(0).toUpperCase() + prop.slice(1); if ($D[func] && obj[prop] !== null && testFunc(prop, func, obj[prop])) { result[prop] = obj[prop]; } } } return result; }; /** * Resets the time of this Date object to 12:00 AM (00:00), which is the start of the day. * @param {Boolean} .clone() this date instance before clearing Time * @return {Date} this */ $P.clearTime = function () { this.setHours(0); this.setMinutes(0); this.setSeconds(0); this.setMilliseconds(0); return this; }; /** * Resets the time of this Date object to the current time ('now'). * @return {Date} this */ $P.setTimeToNow = function () { var n = new Date(); this.setHours(n.getHours()); this.setMinutes(n.getMinutes()); this.setSeconds(n.getSeconds()); this.setMilliseconds(n.getMilliseconds()); return this; }; /** * Returns a new Date object that is an exact date and time copy of the original instance. * @return {Date} A new Date instance */ $P.clone = function () { return new Date(this.getTime()); }; /** * Compares this instance to a Date object and returns an number indication of their relative values. * @param {Date} Date object to compare [Required] * @return {Number} -1 = this is lessthan date. 0 = values are equal. 1 = this is greaterthan date. */ $P.compareTo = function (date) { return Date.compare(this, date); }; /** * Compares this instance to another Date object and returns true if they are equal. * @param {Date} Date object to compare. If no date to compare, new Date() [now] is used. * @return {Boolean} true if dates are equal. false if they are not equal. */ $P.equals = function (date) { return Date.equals(this, (date !== undefined ? date : new Date())); }; /** * Determines if this instance is between a range of two dates or equal to either the start or end dates. * @param {Date} Start of range [Required] * @param {Date} End of range [Required] * @return {Boolean} true is this is between or equal to the start and end dates, else false */ $P.between = function (start, end) { return this.getTime() >= start.getTime() && this.getTime() <= end.getTime(); }; /** * Determines if this date occurs after the date to compare to. * @param {Date} Date object to compare. If no date to compare, new Date() ("now") is used. * @return {Boolean} true if this date instance is greater than the date to compare to (or "now"), otherwise false. */ $P.isAfter = function (date) { return this.compareTo(date || new Date()) === 1; }; /** * Determines if this date occurs before the date to compare to. * @param {Date} Date object to compare. If no date to compare, new Date() ("now") is used. * @return {Boolean} true if this date instance is less than the date to compare to (or "now"). */ $P.isBefore = function (date) { return (this.compareTo(date || new Date()) === -1); }; /** * Determines if the current Date instance occurs today. * @return {Boolean} true if this date instance is 'today', otherwise false. */ /** * Determines if the current Date instance occurs on the same Date as the supplied 'date'. * If no 'date' to compare to is provided, the current Date instance is compared to 'today'. * @param {date} Date object to compare. If no date to compare, the current Date ("now") is used. * @return {Boolean} true if this Date instance occurs on the same Day as the supplied 'date'. */ $P.isToday = $P.isSameDay = function (date) { return this.clone().clearTime().equals((date || new Date()).clone().clearTime()); }; /** * Adds the specified number of milliseconds to this instance. * @param {Number} The number of milliseconds to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addMilliseconds = function (value) { if (!value) { return this; } this.setTime(this.getTime() + value * 1); return this; }; /** * Adds the specified number of seconds to this instance. * @param {Number} The number of seconds to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addSeconds = function (value) { if (!value) { return this; } return this.addMilliseconds(value * 1000); }; /** * Adds the specified number of seconds to this instance. * @param {Number} The number of seconds to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addMinutes = function (value) { if (!value) { return this; } return this.addMilliseconds(value * 60000); // 60*1000 }; /** * Adds the specified number of hours to this instance. * @param {Number} The number of hours to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addHours = function (value) { if (!value) { return this; } return this.addMilliseconds(value * 3600000); // 60*60*1000 }; /** * Adds the specified number of days to this instance. * @param {Number} The number of days to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addDays = function (value) { if (!value) { return this; } this.setDate(this.getDate() + value * 1); return this; }; /** * Adds the specified number of weekdays (ie - not sat or sun) to this instance. * @param {Number} The number of days to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addWeekdays = function (value) { if (!value) { return this; } var day = this.getDay(); var weeks = (Math.ceil(Math.abs(value)/7)); if (day === 0 || day === 6) { if (value > 0) { this.next().monday(); this.addDays(-1); day = this.getDay(); } } if (value < 0) { while (value < 0) { this.addDays(-1); day = this.getDay(); if (day !== 0 && day !== 6) { value++; } } return this; } else if (value > 5 || (6-day) <= value) { value = value + (weeks * 2); } return this.addDays(value); }; /** * Adds the specified number of weeks to this instance. * @param {Number} The number of weeks to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addWeeks = function (value) { if (!value) { return this; } return this.addDays(value * 7); }; /** * Adds the specified number of months to this instance. * @param {Number} The number of months to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addMonths = function (value) { if (!value) { return this; } var n = this.getDate(); this.setDate(1); this.setMonth(this.getMonth() + value * 1); this.setDate(Math.min(n, $D.getDaysInMonth(this.getFullYear(), this.getMonth()))); return this; }; $P.addQuarters = function (value) { if (!value) { return this; } // note this will take you to the same point in the quarter as you are now. // i.e. - if you are 15 days into the quarter you'll be 15 days into the resulting one. // bonus: this allows adding fractional quarters return this.addMonths(value * 3); }; /** * Adds the specified number of years to this instance. * @param {Number} The number of years to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addYears = function (value) { if (!value) { return this; } return this.addMonths(value * 12); }; /** * Adds (or subtracts) to the value of the years, months, weeks, days, hours, minutes, seconds, milliseconds of the date instance using given configuration object. Positive and Negative values allowed. * Example

	Date.today().add( { days: 1, months: 1 } )

	new Date().add( { years: -1 } )
	
* @param {Object} Configuration object containing attributes (months, days, etc.) * @return {Date} this */ $P.add = function (config) { if (typeof config === "number") { this._orient = config; return this; } var x = config; if (x.day) { // If we should be a different date than today (eg: for 'tomorrow -1d', etc). // Should only effect parsing, not direct usage (eg, Finish and FinishExact) if ((x.day - this.getDate()) !== 0) { this.setDate(x.day); } } if (x.milliseconds) { this.addMilliseconds(x.milliseconds); } if (x.seconds) { this.addSeconds(x.seconds); } if (x.minutes) { this.addMinutes(x.minutes); } if (x.hours) { this.addHours(x.hours); } if (x.weeks) { this.addWeeks(x.weeks); } if (x.months) { this.addMonths(x.months); } if (x.years) { this.addYears(x.years); } if (x.days) { this.addDays(x.days); } return this; }; /** * Get the week number. Week one (1) is the week which contains the first Thursday of the year. Monday is considered the first day of the week. * The .getWeek() function does NOT convert the date to UTC. The local datetime is used. * Please use .getISOWeek() to get the week of the UTC converted date. * @return {Number} 1 to 53 */ $P.getWeek = function (utc) { // Create a copy of this date object var self, target = new Date(this.valueOf()); if (utc) { target.addMinutes(target.getTimezoneOffset()); self = target.clone(); } else { self = this; } // ISO week date weeks start on monday // so correct the day number var dayNr = (self.getDay() + 6) % 7; // ISO 8601 states that week 1 is the week // with the first thursday of that year. // Set the target date to the thursday in the target week target.setDate(target.getDate() - dayNr + 3); // Store the millisecond value of the target date var firstThursday = target.valueOf(); // Set the target to the first thursday of the year // First set the target to january first target.setMonth(0, 1); // Not a thursday? Correct the date to the next thursday if (target.getDay() !== 4) { target.setMonth(0, 1 + ((4 - target.getDay()) + 7) % 7); } // The weeknumber is the number of weeks between the // first thursday of the year and the thursday in the target week return 1 + Math.ceil((firstThursday - target) / 604800000); // 604800000 = 7 * 24 * 3600 * 1000 }; /** * Get the ISO 8601 week number. Week one ("01") is the week which contains the first Thursday of the year. Monday is considered the first day of the week. * The .getISOWeek() function does convert the date to it's UTC value. Please use .getWeek() to get the week of the local date. * @return {String} "01" to "53" */ $P.getISOWeek = function () { return p(this.getWeek(true)); }; /** * Moves the date to Monday of the week set. Week one (1) is the week which contains the first Thursday of the year. * @param {Number} A Number (1 to 53) that represents the week of the year. * @return {Date} this */ $P.setWeek = function (n) { if ((n - this.getWeek()) === 0) { if (this.getDay() !== 1) { return this.moveToDayOfWeek(1, (this.getDay() > 1 ? -1 : 1)); } else { return this; } } else { return this.moveToDayOfWeek(1, (this.getDay() > 1 ? -1 : 1)).addWeeks(n - this.getWeek()); } }; $P.setQuarter = function (qtr) { var month = Math.abs(((qtr-1) * 3) + 1); return this.setMonth(month, 1); }; $P.getQuarter = function () { return Date.getQuarter(this); }; $P.getDaysLeftInQuarter = function () { return Date.getDaysLeftInQuarter(this); }; /** * Moves the date to the next n'th occurrence of the dayOfWeek starting from the beginning of the month. The number (-1) is a magic number and will return the last occurrence of the dayOfWeek in the month. * @param {Number} The dayOfWeek to move to * @param {Number} The n'th occurrence to move to. Use (-1) to return the last occurrence in the month * @return {Date} this */ $P.moveToNthOccurrence = function (dayOfWeek, occurrence) { if (dayOfWeek === "Weekday") { if (occurrence > 0) { this.moveToFirstDayOfMonth(); if (this.is().weekday()) { occurrence -= 1; } } else if (occurrence < 0) { this.moveToLastDayOfMonth(); if (this.is().weekday()) { occurrence += 1; } } else { return this; } return this.addWeekdays(occurrence); } var shift = 0; if (occurrence > 0) { shift = occurrence - 1; } else if (occurrence === -1) { this.moveToLastDayOfMonth(); if (this.getDay() !== dayOfWeek) { this.moveToDayOfWeek(dayOfWeek, -1); } return this; } return this.moveToFirstDayOfMonth().addDays(-1).moveToDayOfWeek(dayOfWeek, +1).addWeeks(shift); }; var moveToN = function (getFunc, addFunc, nVal) { return function (value, orient) { var diff = (value - this[getFunc]() + nVal * (orient || +1)) % nVal; return this[addFunc]((diff === 0) ? diff += nVal * (orient || +1) : diff); }; }; /** * Move to the next or last dayOfWeek based on the orient value. * @param {Number} The dayOfWeek to move to * @param {Number} Forward (+1) or Back (-1). Defaults to +1. [Optional] * @return {Date} this */ $P.moveToDayOfWeek = moveToN("getDay", "addDays", 7); /** * Move to the next or last month based on the orient value. * @param {Number} The month to move to. 0 = January, 11 = December * @param {Number} Forward (+1) or Back (-1). Defaults to +1. [Optional] * @return {Date} this */ $P.moveToMonth = moveToN("getMonth", "addMonths", 12); /** * Get the Ordinate of the current day ("th", "st", "rd"). * @return {String} */ $P.getOrdinate = function () { var num = this.getDate(); return ord(num); }; /** * Get the Ordinal day (numeric day number) of the year, adjusted for leap year. * @return {Number} 1 through 365 (366 in leap years) */ $P.getOrdinalNumber = function () { return Math.ceil((this.clone().clearTime() - new Date(this.getFullYear(), 0, 1)) / 86400000) + 1; }; /** * Get the time zone abbreviation of the current date. * @return {String} The abbreviated time zone name (e.g. "EST") */ $P.getTimezone = function () { return $D.getTimezoneAbbreviation(this.getUTCOffset(), this.isDaylightSavingTime()); }; $P.setTimezoneOffset = function (offset) { var here = this.getTimezoneOffset(), there = Number(offset) * -6 / 10; return (there || there === 0) ? this.addMinutes(there - here) : this; }; $P.setTimezone = function (offset) { return this.setTimezoneOffset($D.getTimezoneOffset(offset)); }; /** * Indicates whether Daylight Saving Time is observed in the current time zone. * @return {Boolean} true|false */ $P.hasDaylightSavingTime = function () { return (Date.today().set({month: 0, day: 1}).getTimezoneOffset() !== Date.today().set({month: 6, day: 1}).getTimezoneOffset()); }; /** * Indicates whether this Date instance is within the Daylight Saving Time range for the current time zone. * @return {Boolean} true|false */ $P.isDaylightSavingTime = function () { return Date.today().set({month: 0, day: 1}).getTimezoneOffset() !== this.getTimezoneOffset(); }; /** * Get the offset from UTC of the current date. * @return {String} The 4-character offset string prefixed with + or - (e.g. "-0500") */ $P.getUTCOffset = function (offset) { var n = (offset || this.getTimezoneOffset()) * -10 / 6, r; if (n < 0) { r = (n - 10000).toString(); return r.charAt(0) + r.substr(2); } else { r = (n + 10000).toString(); return "+" + r.substr(1); } }; /** * Returns the number of milliseconds between this date and date. * @param {Date} Defaults to now * @return {Number} The diff in milliseconds */ $P.getElapsed = function (date) { return (date || new Date()) - this; }; /** * Set the value of year, month, day, hour, minute, second, millisecond of date instance using given configuration object. * Example

	Date.today().set( { day: 20, month: 1 } )

	new Date().set( { millisecond: 0 } )
	
* * @param {Object} Configuration object containing attributes (month, day, etc.) * @return {Date} this */ $P.set = function (config) { config = validateConfigObject.call(this, config); var key; for (key in config) { if (Object.prototype.hasOwnProperty.call(config, key)) { var name = key.charAt(0).toUpperCase() + key.slice(1); var addFunc, getFunc; if (key !== "week" && key !== "month" && key !== "timezone" && key !== "timezoneOffset") { name += "s"; } addFunc = "add" + name; getFunc = "get" + name; if (key === "month") { addFunc = addFunc + "s"; } else if (key === "year"){ getFunc = "getFullYear"; } if (key !== "day" && key !== "timezone" && key !== "timezoneOffset" && key !== "week" && key !== "hour") { this[addFunc](config[key] - this[getFunc]()); } else if ( key === "timezone"|| key === "timezoneOffset" || key === "week" || key === "hour") { this["set"+name](config[key]); } } } // day has to go last because you can't validate the day without first knowing the month if (config.day) { this.addDays(config.day - this.getDate()); } return this; }; /** * Moves the date to the first day of the month. * @return {Date} this */ $P.moveToFirstDayOfMonth = function () { return this.set({ day: 1 }); }; /** * Moves the date to the last day of the month. * @return {Date} this */ $P.moveToLastDayOfMonth = function () { return this.set({ day: $D.getDaysInMonth(this.getFullYear(), this.getMonth())}); }; /** * Converts the value of the current Date object to its equivalent string representation. * Format Specifiers * CUSTOM DATE AND TIME FORMAT STRINGS * Format Description Example * ------ --------------------------------------------------------------------------- ----------------------- * s The seconds of the minute between 0-59. "0" to "59" * ss The seconds of the minute with leading zero if required. "00" to "59" * * m The minute of the hour between 0-59. "0" or "59" * mm The minute of the hour with leading zero if required. "00" or "59" * * h The hour of the day between 1-12. "1" to "12" * hh The hour of the day with leading zero if required. "01" to "12" * * H The hour of the day between 0-23. "0" to "23" * HH The hour of the day with leading zero if required. "00" to "23" * * d The day of the month between 1 and 31. "1" to "31" * dd The day of the month with leading zero if required. "01" to "31" * ddd Abbreviated day name. Date.CultureInfo.abbreviatedDayNames. "Mon" to "Sun" * dddd The full day name. Date.CultureInfo.dayNames. "Monday" to "Sunday" * * M The month of the year between 1-12. "1" to "12" * MM The month of the year with leading zero if required. "01" to "12" * MMM Abbreviated month name. Date.CultureInfo.abbreviatedMonthNames. "Jan" to "Dec" * MMMM The full month name. Date.CultureInfo.monthNames. "January" to "December" * * yy The year as a two-digit number. "99" or "08" * yyyy The full four digit year. "1999" or "2008" * * t Displays the first character of the A.M./P.M. designator. "A" or "P" * Date.CultureInfo.amDesignator or Date.CultureInfo.pmDesignator * tt Displays the A.M./P.M. designator. "AM" or "PM" * Date.CultureInfo.amDesignator or Date.CultureInfo.pmDesignator * * S The ordinal suffix ("st, "nd", "rd" or "th") of the current day. "st, "nd", "rd" or "th" * * STANDARD DATE AND TIME FORMAT STRINGS * Format Description Example *------ --------------------------------------------------------------------------- ----------------------- * d The CultureInfo shortDate Format Pattern "M/d/yyyy" * D The CultureInfo longDate Format Pattern "dddd, MMMM dd, yyyy" * F The CultureInfo fullDateTime Format Pattern "dddd, MMMM dd, yyyy h:mm:ss tt" * m The CultureInfo monthDay Format Pattern "MMMM dd" * r The CultureInfo rfc1123 Format Pattern "ddd, dd MMM yyyy HH:mm:ss GMT" * s The CultureInfo sortableDateTime Format Pattern "yyyy-MM-ddTHH:mm:ss" * t The CultureInfo shortTime Format Pattern "h:mm tt" * T The CultureInfo longTime Format Pattern "h:mm:ss tt" * u The CultureInfo universalSortableDateTime Format Pattern "yyyy-MM-dd HH:mm:ssZ" * y The CultureInfo yearMonth Format Pattern "MMMM, yyyy" * * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @return {String} A string representation of the current Date object. */ var ord = function (n) { switch (n * 1) { case 1: case 21: case 31: return "st"; case 2: case 22: return "nd"; case 3: case 23: return "rd"; default: return "th"; } }; var parseStandardFormats = function (format) { var y, c = Date.CultureInfo.formatPatterns; switch (format) { case "d": return this.toString(c.shortDate); case "D": return this.toString(c.longDate); case "F": return this.toString(c.fullDateTime); case "m": return this.toString(c.monthDay); case "r": case "R": y = this.clone().addMinutes(this.getTimezoneOffset()); return y.toString(c.rfc1123) + " GMT"; case "s": return this.toString(c.sortableDateTime); case "t": return this.toString(c.shortTime); case "T": return this.toString(c.longTime); case "u": y = this.clone().addMinutes(this.getTimezoneOffset()); return y.toString(c.universalSortableDateTime); case "y": return this.toString(c.yearMonth); default: return false; } }; var parseFormatStringsClosure = function (context) { return function (m) { if (m.charAt(0) === "\\") { return m.replace("\\", ""); } switch (m) { case "hh": return p(context.getHours() < 13 ? (context.getHours() === 0 ? 12 : context.getHours()) : (context.getHours() - 12)); case "h": return context.getHours() < 13 ? (context.getHours() === 0 ? 12 : context.getHours()) : (context.getHours() - 12); case "HH": return p(context.getHours()); case "H": return context.getHours(); case "mm": return p(context.getMinutes()); case "m": return context.getMinutes(); case "ss": return p(context.getSeconds()); case "s": return context.getSeconds(); case "yyyy": return p(context.getFullYear(), 4); case "yy": return p(context.getFullYear()); case "y": return context.getFullYear(); case "E": case "dddd": return Date.CultureInfo.dayNames[context.getDay()]; case "ddd": return Date.CultureInfo.abbreviatedDayNames[context.getDay()]; case "dd": return p(context.getDate()); case "d": return context.getDate(); case "MMMM": return Date.CultureInfo.monthNames[context.getMonth()]; case "MMM": return Date.CultureInfo.abbreviatedMonthNames[context.getMonth()]; case "MM": return p((context.getMonth() + 1)); case "M": return context.getMonth() + 1; case "t": return context.getHours() < 12 ? Date.CultureInfo.amDesignator.substring(0, 1) : Date.CultureInfo.pmDesignator.substring(0, 1); case "tt": return context.getHours() < 12 ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator; case "S": return ord(context.getDate()); case "W": return context.getWeek(); case "WW": return context.getISOWeek(); case "Q": return "Q" + context.getQuarter(); case "q": return String(context.getQuarter()); case "z": return context.getTimezone(); case "Z": case "X": return Date.getTimezoneOffset(context.getTimezone()); case "ZZ": // Timezone offset in seconds return context.getTimezoneOffset() * -60; case "u": return context.getDay(); case "L": return ($D.isLeapYear(context.getFullYear())) ? 1 : 0; case "B": // Swatch Internet Time (.beats) return "@"+((context.getUTCSeconds() + (context.getUTCMinutes()*60) + ((context.getUTCHours()+1)*3600))/86.4); default: return m; } }; }; $P.toString = function (format, ignoreStandards) { // Standard Date and Time Format Strings. Formats pulled from CultureInfo file and // may vary by culture. if (!ignoreStandards && format && format.length === 1) { output = parseStandardFormats.call(this, format); if (output) { return output; } } var parseFormatStrings = parseFormatStringsClosure(this); return format ? format.replace(/((\\)?(dd?d?d?|MM?M?M?|yy?y?y?|hh?|HH?|mm?|ss?|tt?|S|q|Q|WW?W?W?)(?![^\[]*\]))/g, parseFormatStrings).replace(/\[|\]/g, "") : this._toString(); }; }()); /************************************************************* * SugarPak - Domain Specific Language - Syntactical Sugar * *************************************************************/ (function () { var $D = Date, $P = $D.prototype, $N = Number.prototype; // private $P._orient = +1; // private $P._nth = null; // private $P._is = false; // private $P._same = false; // private $P._isSecond = false; // private $N._dateElement = "days"; /** * Moves the date to the next instance of a date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.today().next().friday();
	Date.today().next().fri();
	Date.today().next().march();
	Date.today().next().mar();
	Date.today().next().week();
	
* * @return {Date} date */ $P.next = function () { this._move = true; this._orient = +1; return this; }; /** * Creates a new Date (Date.today()) and moves the date to the next instance of the date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.next().friday();
	Date.next().fri();
	Date.next().march();
	Date.next().mar();
	Date.next().week();
	
* * @return {Date} date */ $D.next = function () { return $D.today().next(); }; /** * Moves the date to the previous instance of a date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.today().last().friday();
	Date.today().last().fri();
	Date.today().last().march();
	Date.today().last().mar();
	Date.today().last().week();
	
* * @return {Date} date */ $P.last = $P.prev = $P.previous = function () { this._move = true; this._orient = -1; return this; }; /** * Creates a new Date (Date.today()) and moves the date to the previous instance of the date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.last().friday();
	Date.last().fri();
	Date.previous().march();
	Date.prev().mar();
	Date.last().week();
	
* * @return {Date} date */ $D.last = $D.prev = $D.previous = function () { return $D.today().last(); }; /** * Performs a equality check when followed by either a month name, day name or .weekday() function. * Example

	Date.today().is().friday(); // true|false
	Date.today().is().fri();
	Date.today().is().march();
	Date.today().is().mar();
	
* * @return {Boolean} true|false */ $P.is = function () { this._is = true; return this; }; /** * Determines if two date objects occur on/in exactly the same instance of the subsequent date part function. * The function .same() must be followed by a date part function (example: .day(), .month(), .year(), etc). * * An optional Date can be passed in the date part function. If now date is passed as a parameter, 'Now' is used. * * The following example demonstrates how to determine if two dates fall on the exact same day. * * Example

	var d1 = Date.today(); // today at 00:00
	var d2 = new Date();   // exactly now.

	// Do they occur on the same day?
	d1.same().day(d2); // true
	
	// Do they occur on the same hour?
	d1.same().hour(d2); // false, unless d2 hour is '00' (midnight).
	
	// What if it's the same day, but one year apart?
	var nextYear = Date.today().add(1).year();

	d1.same().day(nextYear); // false, because the dates must occur on the exact same day. 
	
* * Scenario: Determine if a given date occurs during some week period 2 months from now. * * Example

	var future = Date.today().add(2).months();
	return someDate.same().week(future); // true|false;
	
* * @return {Boolean} true|false */ $P.same = function () { this._same = true; this._isSecond = false; return this; }; /** * Determines if the current date/time occurs during Today. Must be preceded by the .is() function. * Example

	someDate.is().today();    // true|false
	new Date().is().today();  // true
	Date.today().is().today();// true
	Date.today().add(-1).day().is().today(); // false
	
* * @return {Boolean} true|false */ $P.today = function () { return this.same().day(); }; /** * Determines if the current date is a weekday. This function must be preceded by the .is() function. * Example

	Date.today().is().weekday(); // true|false
	
* * @return {Boolean} true|false */ $P.weekday = function () { if (this._nth) { return df("Weekday").call(this); } if (this._move) { return this.addWeekdays(this._orient); } if (this._is) { this._is = false; return (!this.is().sat() && !this.is().sun()); } return false; }; /** * Determines if the current date is on the weekend. This function must be preceded by the .is() function. * Example

	Date.today().is().weekend(); // true|false
	
* * @return {Boolean} true|false */ $P.weekend = function () { if (this._is) { this._is = false; return (this.is().sat() || this.is().sun()); } return false; }; /** * Sets the Time of the current Date instance. A string "6:15 pm" or config object {hour:18, minute:15} are accepted. * Example

	// Set time to 6:15pm with a String
	Date.today().at("6:15pm");

	// Set time to 6:15pm with a config object
	Date.today().at({hour:18, minute:15});
	
* * @return {Date} date */ $P.at = function (time) { return (typeof time === "string") ? $D.parse(this.toString("d") + " " + time) : this.set(time); }; /** * Creates a new Date() and adds this (Number) to the date based on the preceding date element function (eg. second|minute|hour|day|month|year). * Example

	// Undeclared Numbers must be wrapped with parentheses. Requirment of JavaScript.
	(3).days().fromNow();
	(6).months().fromNow();

	// Declared Number variables do not require parentheses. 
	var n = 6;
	n.months().fromNow();
	
* * @return {Date} A new Date instance */ $N.fromNow = $N.after = function (date) { var c = {}; c[this._dateElement] = this; return ((!date) ? new Date() : date.clone()).add(c); }; /** * Creates a new Date() and subtract this (Number) from the date based on the preceding date element function (eg. second|minute|hour|day|month|year). * Example

	// Undeclared Numbers must be wrapped with parentheses. Requirment of JavaScript.
	(3).days().ago();
	(6).months().ago();

	// Declared Number variables do not require parentheses. 
	var n = 6;
	n.months().ago();
	
* * @return {Date} A new Date instance */ $N.ago = $N.before = function (date) { var c = {}, s = (this._dateElement[this._dateElement.length-1] !== "s") ? this._dateElement + "s" : this._dateElement; c[s] = this * -1; return ((!date) ? new Date() : date.clone()).add(c); }; // Do NOT modify the following string tokens. These tokens are used to build dynamic functions. // All culture-specific strings can be found in the CultureInfo files. var dx = ("sunday monday tuesday wednesday thursday friday saturday").split(/\s/), mx = ("january february march april may june july august september october november december").split(/\s/), px = ("Millisecond Second Minute Hour Day Week Month Year Quarter Weekday").split(/\s/), pxf = ("Milliseconds Seconds Minutes Hours Date Week Month FullYear Quarter").split(/\s/), nth = ("final first second third fourth fifth").split(/\s/), de; /** * Returns an object literal of all the date parts. * Example

	var o = new Date().toObject();
	
	// { year: 2008, month: 4, week: 20, day: 13, hour: 18, minute: 9, second: 32, millisecond: 812 }
	
	// The object properties can be referenced directly from the object.
	
	alert(o.day);  // alerts "13"
	alert(o.year); // alerts "2008"
	
* * @return {Date} An object literal representing the original date object. */ $P.toObject = function () { var o = {}; for (var i = 0; i < px.length; i++) { if (this["get" + pxf[i]]) { o[px[i].toLowerCase()] = this["get" + pxf[i]](); } } return o; }; /** * Returns a date created from an object literal. Ignores the .week property if set in the config. * Example

	var o = new Date().toObject();
	
	return Date.fromObject(o); // will return the same date. 

	var o2 = {month: 1, day: 20, hour: 18}; // birthday party!
	Date.fromObject(o2);
	
* * @return {Date} An object literal representing the original date object. */ $D.fromObject = function(config) { config.week = null; return Date.today().set(config); }; // Create day name functions and abbreviated day name functions (eg. monday(), friday(), fri()). var df = function (n) { return function () { if (this._is) { this._is = false; return this.getDay() === n; } if (this._move) { this._move = null; } if (this._nth !== null) { // If the .second() function was called earlier, remove the _orient // from the date, and then continue. // This is required because 'second' can be used in two different context. // // Example // // Date.today().add(1).second(); // Date.march().second().monday(); // // Things get crazy with the following... // Date.march().add(1).second().second().monday(); // but it works!! // if (this._isSecond) { this.addSeconds(this._orient * -1); } // make sure we reset _isSecond this._isSecond = false; var ntemp = this._nth; this._nth = null; var temp = this.clone().moveToLastDayOfMonth(); this.moveToNthOccurrence(n, ntemp); if (this > temp) { throw new RangeError($D.getDayName(n) + " does not occur " + ntemp + " times in the month of " + $D.getMonthName(temp.getMonth()) + " " + temp.getFullYear() + "."); } return this; } return this.moveToDayOfWeek(n, this._orient); }; }; var sdf = function (n) { return function () { var t = $D.today(), shift = n - t.getDay(); if (n === 0 && Date.CultureInfo.firstDayOfWeek === 1 && t.getDay() !== 0) { shift = shift + 7; } return t.addDays(shift); }; }; // Create month name functions and abbreviated month name functions (eg. january(), march(), mar()). var month_instance_functions = function (n) { return function () { if (this._is) { this._is = false; return this.getMonth() === n; } return this.moveToMonth(n, this._orient); }; }; var month_static_functions = function (n) { return function () { return $D.today().set({ month: n, day: 1 }); }; }; var processTerms = function (names, staticFunc, instanceFunc) { for (var i = 0; i < names.length; i++) { // Create constant static Name variables. $D[names[i].toUpperCase()] = $D[names[i].toUpperCase().substring(0, 3)] = i; // Create Name functions. $D[names[i]] = $D[names[i].substring(0, 3)] = staticFunc(i); // Create Name instance functions. $P[names[i]] = $P[names[i].substring(0, 3)] = instanceFunc(i); } }; processTerms(dx, sdf, df); processTerms(mx, month_static_functions, month_instance_functions); // Create date element functions and plural date element functions used with Date (eg. day(), days(), months()). var ef = function (j) { return function () { // if the .second() function was called earlier, the _orient // has alread been added. Just return this and reset _isSecond. if (this._isSecond) { this._isSecond = false; return this; } if (this._same) { this._same = this._is = false; var o1 = this.toObject(), o2 = (arguments[0] || new Date()).toObject(), v = "", k = j.toLowerCase(); // the substr trick with -1 doesn't work in IE8 or less k = (k[k.length-1] === "s") ? k.substring(0,k.length-1) : k; for (var m = (px.length - 1); m > -1; m--) { v = px[m].toLowerCase(); if (o1[v] !== o2[v]) { return false; } if (k === v) { break; } } return true; } if (j.substring(j.length - 1) !== "s") { j += "s"; } if (this._move) { this._move = null; } return this["add" + j](this._orient); }; }; var nf = function (n) { return function () { this._dateElement = n; return this; }; }; for (var k = 0; k < px.length; k++) { de = px[k].toLowerCase(); if(de !== "weekday") { // Create date element functions and plural date element functions used with Date (eg. day(), days(), months()). $P[de] = $P[de + "s"] = ef(px[k]); // Create date element functions and plural date element functions used with Number (eg. day(), days(), months()). $N[de] = $N[de + "s"] = nf(de + "s"); } } $P._ss = ef("Second"); var nthfn = function (n) { return function (dayOfWeek) { if (this._same) { return this._ss(arguments[0]); } if (dayOfWeek || dayOfWeek === 0) { return this.moveToNthOccurrence(dayOfWeek, n); } this._nth = n; // if the operator is 'second' add the _orient, then deal with it later... if (n === 2 && (dayOfWeek === undefined || dayOfWeek === null)) { this._isSecond = true; return this.addSeconds(this._orient); } return this; }; }; for (var l = 0; l < nth.length; l++) { $P[nth[l]] = (l === 0) ? nthfn(-1) : nthfn(l); } }()); (function () { "use strict"; Date.Parsing = { Exception: function (s) { this.message = "Parse error at '" + s.substring(0, 10) + " ...'"; } }; var $P = Date.Parsing; var dayOffsets = { standard: [0,31,59,90,120,151,181,212,243,273,304,334], leap: [0,31,60,91,121,152,182,213,244,274,305,335] }; $P.isLeapYear = function(year) { return ((year % 4 === 0) && (year % 100 !== 0)) || (year % 400 === 0); }; var utils = { multiReplace : function (str, hash ) { var key; for (key in hash) { if (Object.prototype.hasOwnProperty.call(hash, key)) { var regex; if (typeof hash[key] === "function") { } else { regex = (hash[key] instanceof RegExp) ? hash[key] : new RegExp(hash[key], "g"); } str = str.replace(regex, key); } } return str; }, getDayOfYearFromWeek : function (obj) { var d, jan4, offset; obj.weekDay = (!obj.weekDay && obj.weekDay !== 0) ? 1 : obj.weekDay; d = new Date(obj.year, 0, 4); jan4 = d.getDay() === 0 ? 7 : d.getDay(); // JS is 0 indexed on Sunday. offset = jan4+3; obj.dayOfYear = ((obj.week * 7) + (obj.weekDay === 0 ? 7 : obj.weekDay))-offset; return obj; }, getDayOfYear : function (obj, dayOffset) { if (!obj.dayOfYear) { obj = utils.getDayOfYearFromWeek(obj); } for (var i=0;i <= dayOffset.length;i++) { if (obj.dayOfYear < dayOffset[i] || i === dayOffset.length) { obj.day = obj.day ? obj.day : (obj.dayOfYear - dayOffset[i-1]); break; } else { obj.month = i; } } return obj; }, adjustForTimeZone : function (obj, date) { var offset; if (obj.zone.toUpperCase() === "Z" || (obj.zone_hours === 0 && obj.zone_minutes === 0)) { // it's UTC/GML so work out the current timeszone offset offset = -date.getTimezoneOffset(); } else { offset = (obj.zone_hours*60) + (obj.zone_minutes || 0); if (obj.zone_sign === "+") { offset *= -1; } offset -= date.getTimezoneOffset(); } date.setMinutes(date.getMinutes()+offset); return date; }, setDefaults : function (obj) { obj.year = obj.year || Date.today().getFullYear(); obj.hours = obj.hours || 0; obj.minutes = obj.minutes || 0; obj.seconds = obj.seconds || 0; obj.milliseconds = obj.milliseconds || 0; if (!(!obj.month && (obj.week || obj.dayOfYear))) { // if we have a month, or if we don't but don't have the day calculation data obj.month = obj.month || 0; obj.day = obj.day || 1; } return obj; }, dataNum: function (data, mod, explict, postProcess) { var dataNum = data*1; if (mod) { if (postProcess) { return data ? mod(data)*1 : data; } else { return data ? mod(dataNum) : data; } } else if (!explict){ return data ? dataNum : data; } else { return (data && typeof data !== "undefined") ? dataNum : data; } }, timeDataProcess: function (obj) { var timeObj = {}; for (var x in obj.data) { if (obj.data.hasOwnProperty(x)) { timeObj[x] = obj.ignore[x] ? obj.data[x] : utils.dataNum(obj.data[x], obj.mods[x], obj.explict[x], obj.postProcess[x]); } } if (obj.data.secmins) { obj.data.secmins = obj.data.secmins.replace(",", ".") * 60; if (!timeObj.minutes) { timeObj.minutes = obj.data.secmins; } else if (!timeObj.seconds) { timeObj.seconds = obj.data.secmins; } delete obj.secmins; } return timeObj; }, buildTimeObjectFromData: function (data) { var time = utils.timeDataProcess({ data: { year : data[1], month : data[5], day : data[7], week : data[8], dayOfYear : data[10], hours : data[15], zone_hours : data[23], zone_minutes : data[24], zone : data[21], zone_sign : data[22], weekDay : data[9], minutes: data[16], seconds: data[19], milliseconds: data[20], secmins: data[18] }, mods: { month: function(data) { return data-1; }, weekDay: function (data) { data = Math.abs(data); return (data === 7 ? 0 : data); }, minutes: function (data) { return data.replace(":",""); }, seconds: function (data) { return Math.floor( (data.replace(":","").replace(",","."))*1 ); }, milliseconds: function (data) { return (data.replace(",",".")*1000); } }, postProcess: { minutes: true, seconds: true, milliseconds: true }, explict: { zone_hours: true, zone_minutes: true }, ignore: { zone: true, zone_sign: true, secmins: true } }); return time; }, addToHash: function (hash, keys, data) { keys = keys; data = data; var len = keys.length; for (var i = 0; i < len; i++) { hash[keys[i]] = data[i]; } return hash; }, combineRegex: function (r1, r2) { return new RegExp("(("+r1.source+")\\s("+r2.source+"))"); }, getDateNthString: function(add, last, inc){ if (add) { return Date.today().addDays(inc).toString("d"); } else if (last) { return Date.today().last()[inc]().toString("d"); } }, buildRegexData: function (array) { var arr = []; var len = array.length; for (var i=0; i < len; i++) { if (Object.prototype.toString.call(array[i]) === '[object Array]') { // oldIE compat version of Array.isArray arr.push(this.combineRegex(array[i][0], array[i][1])); } else { arr.push(array[i]); } } return arr; } }; $P.processTimeObject = function (obj) { var date, dayOffset; utils.setDefaults(obj); dayOffset = ($P.isLeapYear(obj.year)) ? dayOffsets.leap : dayOffsets.standard; if (!obj.month && (obj.week || obj.dayOfYear)) { utils.getDayOfYear(obj, dayOffset); } else { obj.dayOfYear = dayOffset[obj.month] + obj.day; } date = new Date(obj.year, obj.month, obj.day, obj.hours, obj.minutes, obj.seconds, obj.milliseconds); if (obj.zone) { utils.adjustForTimeZone(obj, date); // adjust (and calculate) for timezone } return date; }; $P.ISO = { regex : /^([\+-]?\d{4}(?!\d{2}\b))((-?)((0[1-9]|1[0-2])(\3([12]\d|0[1-9]|3[01]))?|W([0-4]\d|5[0-3])(-?[1-7])?|(00[1-9]|0[1-9]\d|[12]\d{2}|3([0-5]\d|6[1-6])))([T\s]((([01]\d|2[0-4])((:?)[0-5]\d)?|24\:?00)([\.,]\d+(?!:))?)?(\17[0-5]\d([\.,]\d+)?)?\s?([zZ]|([\+-])([01]\d|2[0-3]):?([0-5]\d)?)?)?)?$/, parse : function (s) { var time, data = s.match(this.regex); if (!data || !data.length) { return null; } time = utils.buildTimeObjectFromData(data); if (!time.year || (!time.year && (!time.month && !time.day) && (!time.week && !time.dayOfYear)) ) { return null; } return $P.processTimeObject(time); } }; $P.Numeric = { isNumeric: function (e){return!isNaN(parseFloat(e))&&isFinite(e);}, regex: /\b([0-1]?[0-9])([0-3]?[0-9])([0-2]?[0-9]?[0-9][0-9])\b/i, parse: function (s) { var data, i, time = {}, order = Date.CultureInfo.dateElementOrder.split(""); if (!(this.isNumeric(s)) || // if it's non-numeric OR (s[0] === "+" && s[0] === "-")) { // It's an arithmatic string (eg +/-1000) return null; } if (s.length < 5 && s.indexOf(".") < 0 && s.indexOf("/") < 0) { // assume it's just a year. time.year = s; return $P.processTimeObject(time); } data = s.match(this.regex); if (!data || !data.length) { return null; } for (i=0; i < order.length; i++) { switch(order[i]) { case "d": time.day = data[i+1]; break; case "m": time.month = (data[i+1]-1); break; case "y": time.year = data[i+1]; break; } } return $P.processTimeObject(time); } }; $P.Normalizer = { regexData: function () { var $R = Date.CultureInfo.regexPatterns; return utils.buildRegexData([ $R.tomorrow, $R.yesterday, [$R.past, $R.mon], [$R.past, $R.tue], [$R.past, $R.wed], [$R.past, $R.thu], [$R.past, $R.fri], [$R.past, $R.sat], [$R.past, $R.sun] ]); }, basicReplaceHash : function() { var $R = Date.CultureInfo.regexPatterns; return { "January": $R.jan.source, "February": $R.feb, "March": $R.mar, "April": $R.apr, "May": $R.may, "June": $R.jun, "July": $R.jul, "August": $R.aug, "September": $R.sep, "October": $R.oct, "November": $R.nov, "December": $R.dec, "": /\bat\b/gi, " ": /\s{2,}/, "am": $R.inTheMorning, "9am": $R.thisMorning, "pm": $R.inTheEvening, "7pm":$R.thisEvening }; }, keys : function(){ return [ utils.getDateNthString(true, false, 1), // tomorrow utils.getDateNthString(true, false, -1), // yesterday utils.getDateNthString(false, true, "monday"), //last mon utils.getDateNthString(false, true, "tuesday"), //last tues utils.getDateNthString(false, true, "wednesday"), //last wed utils.getDateNthString(false, true, "thursday"), //last thurs utils.getDateNthString(false, true, "friday"), //last fri utils.getDateNthString(false, true, "saturday"), //last sat utils.getDateNthString(false, true, "sunday") //last sun ]; }, buildRegexFunctions: function () { var $R = Date.CultureInfo.regexPatterns; var __ = Date.i18n.__; var tomorrowRE = new RegExp("(\\b\\d\\d?("+__("AM")+"|"+__("PM")+")? )("+$R.tomorrow.source.slice(1)+")", "i"); // adapted tomorrow regex for AM PM relative dates var todayRE = new RegExp($R.today.source + "(?!\\s*([+-]))\\b"); // today, but excludes the math operators (eg "today + 2h") this.replaceFuncs = [ [todayRE, function (full) { return (full.length > 1) ? Date.today().toString("d") : full; }], [tomorrowRE, function(full, m1) { var t = Date.today().addDays(1).toString("d"); return (t + " " + m1); }], [$R.amThisMorning, function(str, am){return am;}], [$R.pmThisEvening, function(str, pm){return pm;}] ]; }, buildReplaceData: function () { this.buildRegexFunctions(); this.replaceHash = utils.addToHash(this.basicReplaceHash(), this.keys(), this.regexData()); }, stringReplaceFuncs: function (s) { for (var i=0; i < this.replaceFuncs.length; i++) { s = s.replace(this.replaceFuncs[i][0], this.replaceFuncs[i][1]); } return s; }, parse: function (s) { s = this.stringReplaceFuncs(s); s = utils.multiReplace(s, this.replaceHash); try { var n = s.split(/([\s\-\.\,\/\x27]+)/); if (n.length === 3 && $P.Numeric.isNumeric(n[0]) && $P.Numeric.isNumeric(n[2]) && (n[2].length >= 4)) { // ok, so we're dealing with x/year. But that's not a full date. // This fixes wonky dateElementOrder parsing when set to dmy order. if (Date.CultureInfo.dateElementOrder[0] === "d") { s = "1/" + n[0] + "/" + n[2]; // set to 1st of month and normalize the seperator } } } catch (e) {} return s; } }; $P.Normalizer.buildReplaceData(); }()); (function () { var $P = Date.Parsing; var _ = $P.Operators = { // // Tokenizers // rtoken: function (r) { // regex token return function (s) { var mx = s.match(r); if (mx) { return ([ mx[0], s.substring(mx[0].length) ]); } else { throw new $P.Exception(s); } }; }, token: function () { // whitespace-eating token return function (s) { return _.rtoken(new RegExp("^\\s*" + s + "\\s*"))(s); }; }, stoken: function (s) { // string token return _.rtoken(new RegExp("^" + s)); }, // Atomic Operators until: function (p) { return function (s) { var qx = [], rx = null; while (s.length) { try { rx = p.call(this, s); } catch (e) { qx.push(rx[0]); s = rx[1]; continue; } break; } return [ qx, s ]; }; }, many: function (p) { return function (s) { var rx = [], r = null; while (s.length) { try { r = p.call(this, s); } catch (e) { return [ rx, s ]; } rx.push(r[0]); s = r[1]; } return [ rx, s ]; }; }, // generator operators -- see below optional: function (p) { return function (s) { var r = null; try { r = p.call(this, s); } catch (e) { return [ null, s ]; } return [ r[0], r[1] ]; }; }, not: function (p) { return function (s) { try { p.call(this, s); } catch (e) { return [null, s]; } throw new $P.Exception(s); }; }, ignore: function (p) { return p ? function (s) { var r = null; r = p.call(this, s); return [null, r[1]]; } : null; }, product: function () { var px = arguments[0], qx = Array.prototype.slice.call(arguments, 1), rx = []; for (var i = 0 ; i < px.length ; i++) { rx.push(_.each(px[i], qx)); } return rx; }, cache: function (rule) { var cache = {}, cache_length = 0, cache_keys = [], CACHE_MAX = Date.Config.CACHE_MAX || 100000, r = null; var cacheCheck = function () { if (cache_length === CACHE_MAX) { // kill several keys, don't want to have to do this all the time... for (var i=0; i < 10; i++) { var key = cache_keys.shift(); if (key) { delete cache[key]; cache_length--; } } } }; return function (s) { cacheCheck(); try { r = cache[s] = (cache[s] || rule.call(this, s)); } catch (e) { r = cache[s] = e; } cache_length++; cache_keys.push(s); if (r instanceof $P.Exception) { throw r; } else { return r; } }; }, // vector operators -- see below any: function () { var px = arguments; return function (s) { var r = null; for (var i = 0; i < px.length; i++) { if (px[i] == null) { continue; } try { r = (px[i].call(this, s)); } catch (e) { r = null; } if (r) { return r; } } throw new $P.Exception(s); }; }, each: function () { var px = arguments; return function (s) { var rx = [], r = null; for (var i = 0; i < px.length ; i++) { if (px[i] == null) { continue; } try { r = (px[i].call(this, s)); } catch (e) { throw new $P.Exception(s); } rx.push(r[0]); s = r[1]; } return [ rx, s]; }; }, all: function () { var px = arguments, _ = _; return _.each(_.optional(px)); }, // delimited operators sequence: function (px, d, c) { d = d || _.rtoken(/^\s*/); c = c || null; if (px.length === 1) { return px[0]; } return function (s) { var r = null, q = null; var rx = []; for (var i = 0; i < px.length ; i++) { try { r = px[i].call(this, s); } catch (e) { break; } rx.push(r[0]); try { q = d.call(this, r[1]); } catch (ex) { q = null; break; } s = q[1]; } if (!r) { throw new $P.Exception(s); } if (q) { throw new $P.Exception(q[1]); } if (c) { try { r = c.call(this, r[1]); } catch (ey) { throw new $P.Exception(r[1]); } } return [ rx, (r?r[1]:s) ]; }; }, // // Composite Operators // between: function (d1, p, d2) { d2 = d2 || d1; var _fn = _.each(_.ignore(d1), p, _.ignore(d2)); return function (s) { var rx = _fn.call(this, s); return [[rx[0][0], r[0][2]], rx[1]]; }; }, list: function (p, d, c) { d = d || _.rtoken(/^\s*/); c = c || null; return (p instanceof Array ? _.each(_.product(p.slice(0, -1), _.ignore(d)), p.slice(-1), _.ignore(c)) : _.each(_.many(_.each(p, _.ignore(d))), px, _.ignore(c))); }, set: function (px, d, c) { d = d || _.rtoken(/^\s*/); c = c || null; return function (s) { // r is the current match, best the current 'best' match // which means it parsed the most amount of input var r = null, p = null, q = null, rx = null, best = [[], s], last = false; // go through the rules in the given set for (var i = 0; i < px.length ; i++) { // last is a flag indicating whether this must be the last element // if there is only 1 element, then it MUST be the last one q = null; p = null; r = null; last = (px.length === 1); // first, we try simply to match the current pattern // if not, try the next pattern try { r = px[i].call(this, s); } catch (e) { continue; } // since we are matching against a set of elements, the first // thing to do is to add r[0] to matched elements rx = [[r[0]], r[1]]; // if we matched and there is still input to parse and // we don't already know this is the last element, // we're going to next check for the delimiter ... // if there's none, or if there's no input left to parse // than this must be the last element after all ... if (r[1].length > 0 && ! last) { try { q = d.call(this, r[1]); } catch (ex) { last = true; } } else { last = true; } // if we parsed the delimiter and now there's no more input, // that means we shouldn't have parsed the delimiter at all // so don't update r and mark this as the last element ... if (!last && q[1].length === 0) { last = true; } // so, if this isn't the last element, we're going to see if // we can get any more matches from the remaining (unmatched) // elements ... if (!last) { // build a list of the remaining rules we can match against, // i.e., all but the one we just matched against var qx = []; for (var j = 0; j < px.length ; j++) { if (i !== j) { qx.push(px[j]); } } // now invoke recursively set with the remaining input // note that we don't include the closing delimiter ... // we'll check for that ourselves at the end p = _.set(qx, d).call(this, q[1]); // if we got a non-empty set as a result ... // (otw rx already contains everything we want to match) if (p[0].length > 0) { // update current result, which is stored in rx ... // basically, pick up the remaining text from p[1] // and concat the result from p[0] so that we don't // get endless nesting ... rx[0] = rx[0].concat(p[0]); rx[1] = p[1]; } } // at this point, rx either contains the last matched element // or the entire matched set that starts with this element. // now we just check to see if this variation is better than // our best so far, in terms of how much of the input is parsed if (rx[1].length < best[1].length) { best = rx; } // if we've parsed all the input, then we're finished if (best[1].length === 0) { break; } } // so now we've either gone through all the patterns trying them // as the initial match; or we found one that parsed the entire // input string ... // if best has no matches, just return empty set ... if (best[0].length === 0) { return best; } // if a closing delimiter is provided, then we have to check it also if (c) { // we try this even if there is no remaining input because the pattern // may well be optional or match empty input ... try { q = c.call(this, best[1]); } catch (ey) { throw new $P.Exception(best[1]); } // it parsed ... be sure to update the best match remaining input best[1] = q[1]; } // if we're here, either there was no closing delimiter or we parsed it // so now we have the best match; just return it! return best; }; }, forward: function (gr, fname) { return function (s) { return gr[fname].call(this, s); }; }, // // Translation Operators // replace: function (rule, repl) { return function (s) { var r = rule.call(this, s); return [repl, r[1]]; }; }, process: function (rule, fn) { return function (s) { var r = rule.call(this, s); return [fn.call(this, r[0]), r[1]]; }; }, min: function (min, rule) { return function (s) { var rx = rule.call(this, s); if (rx[0].length < min) { throw new $P.Exception(s); } return rx; }; } }; // Generator Operators And Vector Operators // Generators are operators that have a signature of F(R) => R, // taking a given rule and returning another rule, such as // ignore, which parses a given rule and throws away the result. // Vector operators are those that have a signature of F(R1,R2,...) => R, // take a list of rules and returning a new rule, such as each. // Generator operators are converted (via the following _generator // function) into functions that can also take a list or array of rules // and return an array of new rules as though the function had been // called on each rule in turn (which is what actually happens). // This allows generators to be used with vector operators more easily. // Example: // each(ignore(foo, bar)) instead of each(ignore(foo), ignore(bar)) // This also turns generators into vector operators, which allows // constructs like: // not(cache(foo, bar)) var _generator = function (op) { function gen() { var args = null, rx = [], px, i; if (arguments.length > 1) { args = Array.prototype.slice.call(arguments); } else if (arguments[0] instanceof Array) { args = arguments[0]; } if (args) { px = args.shift(); if (px.length > 0) { args.unshift(px[i]); rx.push(op.apply(null, args)); args.shift(); return rx; } } else { return op.apply(null, arguments); } } return gen; }; var gx = "optional not ignore cache".split(/\s/); for (var i = 0 ; i < gx.length ; i++) { _[gx[i]] = _generator(_[gx[i]]); } var _vector = function (op) { return function () { if (arguments[0] instanceof Array) { return op.apply(null, arguments[0]); } else { return op.apply(null, arguments); } }; }; var vx = "each any all".split(/\s/); for (var j = 0 ; j < vx.length ; j++) { _[vx[j]] = _vector(_[vx[j]]); } }()); (function () { var $D = Date; var flattenAndCompact = function (ax) { var rx = []; for (var i = 0; i < ax.length; i++) { if (ax[i] instanceof Array) { rx = rx.concat(flattenAndCompact(ax[i])); } else { if (ax[i]) { rx.push(ax[i]); } } } return rx; }; var parseMeridian = function () { if (this.meridian && (this.hour || this.hour === 0)) { if (this.meridian === "a" && this.hour > 11 && Date.Config.strict24hr){ throw "Invalid hour and meridian combination"; } else if (this.meridian === "p" && this.hour < 12 && Date.Config.strict24hr){ throw "Invalid hour and meridian combination"; } else if (this.meridian === "p" && this.hour < 12) { this.hour = this.hour + 12; } else if (this.meridian === "a" && this.hour === 12) { this.hour = 0; } } }; var setDefaults = function () { var now = new Date(); if ((this.hour || this.minute) && (!this.month && !this.year && !this.day)) { this.day = now.getDate(); } if (!this.year) { this.year = now.getFullYear(); } if (!this.month && this.month !== 0) { this.month = now.getMonth(); } if (!this.day) { this.day = 1; } if (!this.hour) { this.hour = 0; } if (!this.minute) { this.minute = 0; } if (!this.second) { this.second = 0; } if (!this.millisecond) { this.millisecond = 0; } }; var finishUtils = { getToday: function () { if (this.now || "hour minute second".indexOf(this.unit) !== -1) { return new Date(); } else { return $D.today(); } }, setDaysFromWeekday: function (today, orient){ var gap; orient = orient || 1; this.unit = "day"; gap = ($D.getDayNumberFromName(this.weekday) - today.getDay()); this.days = gap ? ((gap + (orient * 7)) % 7) : (orient * 7); return this; }, setMonthsFromMonth: function (today, orient) { var gap; orient = orient || 1; this.unit = "month"; gap = (this.month - today.getMonth()); this.months = gap ? ((gap + (orient * 12)) % 12) : (orient * 12); this.month = null; return this; }, setDMYFromWeekday: function () { var d = Date[this.weekday](); this.day = d.getDate(); if (!this.month) { this.month = d.getMonth(); } this.year = d.getFullYear(); return this; }, setUnitValue: function (orient) { if (!this.value && this.operator && this.operator !== null && this[this.unit + "s"] && this[this.unit + "s"] !== null) { this[this.unit + "s"] = this[this.unit + "s"] + ((this.operator === "add") ? 1 : -1) + (this.value||0) * orient; } else if (this[this.unit + "s"] == null || this.operator != null) { if (!this.value) { this.value = 1; } this[this.unit + "s"] = this.value * orient; } }, generateDateFromWeeks: function () { var weekday = (this.weekday !== undefined) ? this.weekday : "today"; var d = Date[weekday]().addWeeks(this.weeks); if (this.now) { d.setTimeToNow(); } return d; } }; $D.Translator = { hour: function (s) { return function () { this.hour = Number(s); }; }, minute: function (s) { return function () { this.minute = Number(s); }; }, second: function (s) { return function () { this.second = Number(s); }; }, /* for ss.s format */ secondAndMillisecond: function (s) { return function () { var mx = s.match(/^([0-5][0-9])\.([0-9]{1,3})/); this.second = Number(mx[1]); this.millisecond = Number(mx[2]); }; }, meridian: function (s) { return function () { this.meridian = s.slice(0, 1).toLowerCase(); }; }, timezone: function (s) { return function () { var n = s.replace(/[^\d\+\-]/g, ""); if (n.length) { this.timezoneOffset = Number(n); } else { this.timezone = s.toLowerCase(); } }; }, day: function (x) { var s = x[0]; return function () { this.day = Number(s.match(/\d+/)[0]); if (this.day < 1) { throw "invalid day"; } }; }, month: function (s) { return function () { this.month = (s.length === 3) ? "jan feb mar apr may jun jul aug sep oct nov dec".indexOf(s)/4 : Number(s) - 1; if (this.month < 0) { throw "invalid month"; } }; }, year: function (s) { return function () { var n = Number(s); this.year = ((s.length > 2) ? n : (n + (((n + 2000) < Date.CultureInfo.twoDigitYearMax) ? 2000 : 1900))); }; }, rday: function (s) { return function () { switch (s) { case "yesterday": this.days = -1; break; case "tomorrow": this.days = 1; break; case "today": this.days = 0; break; case "now": this.days = 0; this.now = true; break; } }; }, finishExact: function (x) { var d; x = (x instanceof Array) ? x : [x]; for (var i = 0 ; i < x.length ; i++) { if (x[i]) { x[i].call(this); } } setDefaults.call(this); parseMeridian.call(this); if (this.day > $D.getDaysInMonth(this.year, this.month)) { throw new RangeError(this.day + " is not a valid value for days."); } d = new Date(this.year, this.month, this.day, this.hour, this.minute, this.second, this.millisecond); if (this.year < 100) { d.setFullYear(this.year); // means years less that 100 are process correctly. JS will parse it otherwise as 1900-1999. } if (this.timezone) { d.set({ timezone: this.timezone }); } else if (this.timezoneOffset) { d.set({ timezoneOffset: this.timezoneOffset }); } return d; }, finish: function (x) { var today, expression, orient, temp; x = (x instanceof Array) ? flattenAndCompact(x) : [ x ]; if (x.length === 0) { return null; } for (var i = 0 ; i < x.length ; i++) { if (typeof x[i] === "function") { x[i].call(this); } } if (this.now && !this.unit && !this.operator) { return new Date(); } else { today = finishUtils.getToday.call(this); } expression = !!(this.days && this.days !== null || this.orient || this.operator); orient = ((this.orient === "past" || this.operator === "subtract") ? -1 : 1); if (this.month && this.unit === "week") { this.value = this.month + 1; delete this.month; delete this.day; } if ((this.month || this.month === 0) && "year day hour minute second".indexOf(this.unit) !== -1) { if (!this.value) { this.value = this.month + 1; } this.month = null; expression = true; } if (!expression && this.weekday && !this.day && !this.days) { finishUtils.setDMYFromWeekday.call(this); } if (expression && this.weekday && this.unit !== "month" && this.unit !== "week") { finishUtils.setDaysFromWeekday.call(this, today, orient); } if (this.weekday && this.unit !== "week" && !this.day && !this.days) { temp = Date[this.weekday](); this.day = temp.getDate(); if (temp.getMonth() !== today.getMonth()) { this.month = temp.getMonth(); } } if (this.month && this.unit === "day" && this.operator) { if (!this.value) { this.value = (this.month + 1); } this.month = null; } if (this.value != null && this.month != null && this.year != null) { this.day = this.value * 1; } if (this.month && !this.day && this.value) { today.set({ day: this.value * 1 }); if (!expression) { this.day = this.value * 1; } } if (!this.month && this.value && this.unit === "month" && !this.now) { this.month = this.value; expression = true; } if (expression && (this.month || this.month === 0) && this.unit !== "year") { finishUtils.setMonthsFromMonth.call(this, today, orient); } if (!this.unit) { this.unit = "day"; } finishUtils.setUnitValue.call(this, orient); parseMeridian.call(this); if ((this.month || this.month === 0) && !this.day) { this.day = 1; } if (!this.orient && !this.operator && this.unit === "week" && this.value && !this.day && !this.month) { return Date.today().setWeek(this.value); } if (this.unit === "week" && this.weeks && !this.day && !this.month) { return finishUtils.generateDateFromWeeks.call(this); } if (expression && this.timezone && this.day && this.days) { this.day = this.days; } if (expression){ today.add(this); } else { today.set(this); } if (this.timezone) { this.timezone = this.timezone.toUpperCase(); var offset = $D.getTimezoneOffset(this.timezone); var timezone; if (today.hasDaylightSavingTime()) { // lets check that we're being sane with timezone setting timezone = $D.getTimezoneAbbreviation(offset, today.isDaylightSavingTime()); if (timezone !== this.timezone) { // bugger, we're in a place where things like EST vs EDT matters. if (today.isDaylightSavingTime()) { today.addHours(-1); } else { today.addHours(1); } } } today.setTimezoneOffset(offset); } return today; } }; }()); (function () { var $D = Date; $D.Grammar = {}; var _ = $D.Parsing.Operators, g = $D.Grammar, t = $D.Translator, _fn; // Allow rolling up into general purpose rules _fn = function () { return _.each(_.any.apply(null, arguments), _.not(g.ctoken2("timeContext"))); }; g.datePartDelimiter = _.rtoken(/^([\s\-\.\,\/\x27]+)/); g.timePartDelimiter = _.stoken(":"); g.whiteSpace = _.rtoken(/^\s*/); g.generalDelimiter = _.rtoken(/^(([\s\,]|at|@|on)+)/); var _C = {}; g.ctoken = function (keys) { var fn = _C[keys]; if (! fn) { var c = Date.CultureInfo.regexPatterns; var kx = keys.split(/\s+/), px = []; for (var i = 0; i < kx.length ; i++) { px.push(_.replace(_.rtoken(c[kx[i]]), kx[i])); } fn = _C[keys] = _.any.apply(null, px); } return fn; }; g.ctoken2 = function (key) { return _.rtoken(Date.CultureInfo.regexPatterns[key]); }; var cacheProcessRtoken = function (key, token, type, eachToken) { if (eachToken) { g[key] = _.cache(_.process(_.each(_.rtoken(token),_.optional(g.ctoken2(eachToken))), type)); } else { g[key] = _.cache(_.process(_.rtoken(token), type)); } }; var cacheProcessCtoken = function (token, type) { return _.cache(_.process(g.ctoken2(token), type)); }; var _F = {}; //function cache var _get = function (f) { _F[f] = (_F[f] || g.format(f)[0]); return _F[f]; }; g.allformats = function (fx) { var rx = []; if (fx instanceof Array) { for (var i = 0; i < fx.length; i++) { rx.push(_get(fx[i])); } } else { rx.push(_get(fx)); } return rx; }; g.formats = function (fx) { if (fx instanceof Array) { var rx = []; for (var i = 0 ; i < fx.length ; i++) { rx.push(_get(fx[i])); } return _.any.apply(null, rx); } else { return _get(fx); } }; var grammarFormats = { timeFormats: function(){ var i, RTokenKeys = [ "h", "hh", "H", "HH", "m", "mm", "s", "ss", "ss.s", "z", "zz" ], RToken = [ /^(0[0-9]|1[0-2]|[1-9])/, /^(0[0-9]|1[0-2])/, /^([0-1][0-9]|2[0-3]|[0-9])/, /^([0-1][0-9]|2[0-3])/, /^([0-5][0-9]|[0-9])/, /^[0-5][0-9]/, /^([0-5][0-9]|[0-9])/, /^[0-5][0-9]/, /^[0-5][0-9]\.[0-9]{1,3}/, /^((\+|\-)\s*\d\d\d\d)|((\+|\-)\d\d\:?\d\d)/, /^((\+|\-)\s*\d\d\d\d)|((\+|\-)\d\d\:?\d\d)/ ], tokens = [ t.hour, t.hour, t.hour, t.hour, t.minute, t.minute, t.second, t.second, t.secondAndMillisecond, t.timezone, t.timezone ]; for (i=0; i < RTokenKeys.length; i++) { cacheProcessRtoken(RTokenKeys[i], RToken[i], tokens[i]); } g.hms = _.cache(_.sequence([g.H, g.m, g.s], g.timePartDelimiter)); g.t = cacheProcessCtoken("shortMeridian", t.meridian); g.tt = cacheProcessCtoken("longMeridian", t.meridian); g.zzz = cacheProcessCtoken("timezone", t.timezone); g.timeSuffix = _.each(_.ignore(g.whiteSpace), _.set([ g.tt, g.zzz ])); g.time = _.each(_.optional(_.ignore(_.stoken("T"))), g.hms, g.timeSuffix); }, dateFormats: function () { // pre-loaded rules for different date part order preferences var _setfn = function () { return _.set(arguments, g.datePartDelimiter); }; var i, RTokenKeys = [ "d", "dd", "M", "MM", "y", "yy", "yyy", "yyyy" ], RToken = [ /^([0-2]\d|3[0-1]|\d)/, /^([0-2]\d|3[0-1])/, /^(1[0-2]|0\d|\d)/, /^(1[0-2]|0\d)/, /^(\d+)/, /^(\d\d)/, /^(\d\d?\d?\d?)/, /^(\d\d\d\d)/ ], tokens = [ t.day, t.day, t.month, t.month, t.year, t.year, t.year, t.year ], eachToken = [ "ordinalSuffix", "ordinalSuffix" ]; for (i=0; i < RTokenKeys.length; i++) { cacheProcessRtoken(RTokenKeys[i], RToken[i], tokens[i], eachToken[i]); } g.MMM = g.MMMM = _.cache(_.process(g.ctoken("jan feb mar apr may jun jul aug sep oct nov dec"), t.month)); g.ddd = g.dddd = _.cache(_.process(g.ctoken("sun mon tue wed thu fri sat"), function (s) { return function () { this.weekday = s; }; } )); g.day = _fn(g.d, g.dd); g.month = _fn(g.M, g.MMM); g.year = _fn(g.yyyy, g.yy); g.mdy = _setfn(g.ddd, g.month, g.day, g.year); g.ymd = _setfn(g.ddd, g.year, g.month, g.day); g.dmy = _setfn(g.ddd, g.day, g.month, g.year); g.date = function (s) { return ((g[Date.CultureInfo.dateElementOrder] || g.mdy).call(this, s)); }; }, relative: function () { // relative date / time expressions g.orientation = _.process(g.ctoken("past future"), function (s) { return function () { this.orient = s; }; } ); g.operator = _.process(g.ctoken("add subtract"), function (s) { return function () { this.operator = s; }; } ); g.rday = _.process(g.ctoken("yesterday tomorrow today now"), t.rday); g.unit = _.process(g.ctoken("second minute hour day week month year"), function (s) { return function () { this.unit = s; }; } ); } }; g.buildGrammarFormats = function () { // these need to be rebuilt every time the language changes. _C = {}; grammarFormats.timeFormats(); grammarFormats.dateFormats(); grammarFormats.relative(); g.value = _.process(_.rtoken(/^([-+]?\d+)?(st|nd|rd|th)?/), function (s) { return function () { this.value = s.replace(/\D/g, ""); }; } ); g.expression = _.set([g.rday, g.operator, g.value, g.unit, g.orientation, g.ddd, g.MMM ]); g.format = _.process(_.many( _.any( // translate format specifiers into grammar rules _.process( _.rtoken(/^(dd?d?d?(?!e)|MM?M?M?|yy?y?y?|hh?|HH?|mm?|ss?|tt?|zz?z?)/), function (fmt) { if (g[fmt]) { return g[fmt]; } else { throw $D.Parsing.Exception(fmt); } } ), // translate separator tokens into token rules _.process(_.rtoken(/^[^dMyhHmstz]+/), // all legal separators function (s) { return _.ignore(_.stoken(s)); } ) ) ), // construct the parser ... function (rules) { return _.process(_.each.apply(null, rules), t.finishExact); } ); // starting rule for general purpose grammar g._start = _.process(_.set([ g.date, g.time, g.expression ], g.generalDelimiter, g.whiteSpace), t.finish); }; g.buildGrammarFormats(); // parsing date format specifiers - ex: "h:m:s tt" // this little guy will generate a custom parser based // on the format string, ex: g.format("h:m:s tt") // check for these formats first g._formats = g.formats([ "\"yyyy-MM-ddTHH:mm:ssZ\"", "yyyy-MM-ddTHH:mm:ss.sz", "yyyy-MM-ddTHH:mm:ssZ", "yyyy-MM-ddTHH:mm:ssz", "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-ddTHH:mmZ", "yyyy-MM-ddTHH:mmz", "yyyy-MM-ddTHH:mm", "ddd, MMM dd, yyyy H:mm:ss tt", "ddd MMM d yyyy HH:mm:ss zzz", "MMddyyyy", "ddMMyyyy", "Mddyyyy", "ddMyyyy", "Mdyyyy", "dMyyyy", "yyyy", "Mdyy", "dMyy", "d" ]); // real starting rule: tries selected formats first, // then general purpose rule g.start = function (s) { try { var r = g._formats.call({}, s); if (r[1].length === 0) { return r; } } catch (e) {} return g._start.call({}, s); }; }()); (function () { var $D = Date; /** * @desc Converts the specified string value into its JavaScript Date equivalent using CultureInfo specific format information. * * Example

	///////////
	// Dates //
	///////////

	// 15-Oct-2004
	var d1 = Date.parse("10/15/2004");

	// 15-Oct-2004
	var d1 = Date.parse("15-Oct-2004");

	// 15-Oct-2004
	var d1 = Date.parse("2004.10.15");

	//Fri Oct 15, 2004
	var d1 = Date.parse("Fri Oct 15, 2004");

	///////////
	// Times //
	///////////

	// Today at 10 PM.
	var d1 = Date.parse("10 PM");

	// Today at 10:30 PM.
	var d1 = Date.parse("10:30 P.M.");

	// Today at 6 AM.
	var d1 = Date.parse("06am");

	/////////////////////
	// Dates and Times //
	/////////////////////

	// 8-July-2004 @ 10:30 PM
	var d1 = Date.parse("July 8th, 2004, 10:30 PM");

	// 1-July-2004 @ 10:30 PM
	var d1 = Date.parse("2004-07-01T22:30:00");

	////////////////////
	// Relative Dates //
	////////////////////

	// Returns today's date. The string "today" is culture specific.
	var d1 = Date.parse("today");

	// Returns yesterday's date. The string "yesterday" is culture specific.
	var d1 = Date.parse("yesterday");

	// Returns the date of the next thursday.
	var d1 = Date.parse("Next thursday");

	// Returns the date of the most previous monday.
	var d1 = Date.parse("last monday");

	// Returns today's day + one year.
	var d1 = Date.parse("next year");

	///////////////
	// Date Math //
	///////////////

	// Today + 2 days
	var d1 = Date.parse("t+2");

	// Today + 2 days
	var d1 = Date.parse("today + 2 days");

	// Today + 3 months
	var d1 = Date.parse("t+3m");

	// Today - 1 year
	var d1 = Date.parse("today - 1 year");

	// Today - 1 year
	var d1 = Date.parse("t-1y"); 


	/////////////////////////////
	// Partial Dates and Times //
	/////////////////////////////

	// July 15th of this year.
	var d1 = Date.parse("July 15");

	// 15th day of current day and year.
	var d1 = Date.parse("15");

	// July 1st of current year at 10pm.
	var d1 = Date.parse("7/1 10pm");
	
* * @param {String} The string value to convert into a Date object [Required] * @return {Date} A Date object or null if the string cannot be converted into a Date. */ var parseUtils = { removeOrds: function (s) { ords = s.match(/\b(\d+)(?:st|nd|rd|th)\b/); // find ordinal matches s = ((ords && ords.length === 2) ? s.replace(ords[0], ords[1]) : s); return s; }, grammarParser: function (s) { var r = null; try { r = $D.Grammar.start.call({}, s.replace(/^\s*(\S*(\s+\S+)*)\s*$/, "$1")); } catch (e) { return null; } return ((r[1].length === 0) ? r[0] : null); }, nativeFallback: function(s) { var t; try { // ok we haven't parsed it, last ditch attempt with the built-in parser. t = Date._parse(s); return (t || t === 0) ? new Date(t) : null; } catch (e) { return null; } } }; function parse (s) { var d; if (!s) { return null; } if (s instanceof Date) { return s.clone(); } if (s.length >= 4 && s.charAt(0) !== "0" && s.charAt(0) !== "+"&& s.charAt(0) !== "-") { // ie: 2004 will pass, 0800 won't. // Start with specific formats d = $D.Parsing.ISO.parse(s) || $D.Parsing.Numeric.parse(s); } if (d instanceof Date && !isNaN(d.getTime())) { return d; } else { // find ordinal dates (1st, 3rd, 8th, etc and remove them as they cause parsing issues) s = $D.Parsing.Normalizer.parse(parseUtils.removeOrds(s)); d = parseUtils.grammarParser(s); if (d !== null) { return d; } else { return parseUtils.nativeFallback(s); } } } if (!$D._parse) { $D._parse = $D.parse; } $D.parse = parse; Date.getParseFunction = function (fx) { var fns = Date.Grammar.allformats(fx); return function (s) { var r = null; for (var i = 0; i < fns.length; i++) { try { r = fns[i].call({}, s); } catch (e) { continue; } if (r[1].length === 0) { return r[0]; } } return null; }; }; /** * Converts the specified string value into its JavaScript Date equivalent using the specified format {String} or formats {Array} and the CultureInfo specific format information. * The format of the string value must match one of the supplied formats exactly. * * Example

	// 15-Oct-2004
	var d1 = Date.parseExact("10/15/2004", "M/d/yyyy");

	// 15-Oct-2004
	var d1 = Date.parse("15-Oct-2004", "M-ddd-yyyy");

	// 15-Oct-2004
	var d1 = Date.parse("2004.10.15", "yyyy.MM.dd");

	// Multiple formats
	var d1 = Date.parseExact("10/15/2004", ["M/d/yyyy", "MMMM d, yyyy"]);
	
* * @param {String} The string value to convert into a Date object [Required]. * @param {Object} The expected format {String} or an array of expected formats {Array} of the date string [Required]. * @return {Date} A Date object or null if the string cannot be converted into a Date. */ $D.parseExact = function (s, fx) { return $D.getParseFunction(fx)(s); }; }()); (function () { var $D = Date, $P = $D.prototype, // $C = $D.CultureInfo, // not used atm p = function (s, l) { if (!l) { l = 2; } return ("000" + s).slice(l * -1); }; /** * Converts a PHP format string to Java/.NET format string. * A PHP format string can be used with ._format or .format. * A Java/.NET format string can be used with .toString(). * The .parseExact function will only accept a Java/.NET format string * * Example * var f1 = "%m/%d/%y" * var f2 = Date.normalizeFormat(f1); // "MM/dd/yy" * * new Date().format(f1); // "04/13/08" * new Date()._format(f1); // "04/13/08" * new Date().toString(f2); // "04/13/08" * * var date = Date.parseExact("04/13/08", f2); // Sun Apr 13 2008 * * @param {String} A PHP format string consisting of one or more format spcifiers. * @return {String} The PHP format converted to a Java/.NET format string. */ var normalizerSubstitutions = { "d" : "dd", "%d": "dd", "D" : "ddd", "%a": "ddd", "j" : "dddd", "l" : "dddd", "%A": "dddd", "S" : "S", "F" : "MMMM", "%B": "MMMM", "m" : "MM", "%m": "MM", "M" : "MMM", "%b": "MMM", "%h": "MMM", "n" : "M", "Y" : "yyyy", "%Y": "yyyy", "y" : "yy", "%y": "yy", "g" : "h", "%I": "h", "G" : "H", "h" : "hh", "H" : "HH", "%H": "HH", "i" : "mm", "%M": "mm", "s" : "ss", "%S": "ss", "%r": "hh:mm tt", "%R": "H:mm", "%T": "H:mm:ss", "%X": "t", "%x": "d", "%e": "d", "%D": "MM/dd/yy", "%n": "\\n", "%t": "\\t", "e" : "z", "T" : "z", "%z": "z", "%Z": "z", "Z" : "ZZ", "N" : "u", "w" : "u", "%w": "u", "W" : "W", "%V": "W" }; var normalizer = { substitutes: function (m) { return normalizerSubstitutions[m]; }, interpreted: function (m, x) { var y; switch (m) { case "%u": return x.getDay() + 1; case "z": return x.getOrdinalNumber(); case "%j": return p(x.getOrdinalNumber(), 3); case "%U": var d1 = x.clone().set({month: 0, day: 1}).addDays(-1).moveToDayOfWeek(0), d2 = x.clone().addDays(1).moveToDayOfWeek(0, -1); return (d2 < d1) ? "00" : p((d2.getOrdinalNumber() - d1.getOrdinalNumber()) / 7 + 1); case "%W": return p(x.getWeek()); case "t": return $D.getDaysInMonth(x.getFullYear(), x.getMonth()); case "o": case "%G": return x.setWeek(x.getISOWeek()).toString("yyyy"); case "%g": return x._format("%G").slice(-2); case "a": case "%p": return t("tt").toLowerCase(); case "A": return t("tt").toUpperCase(); case "u": return p(x.getMilliseconds(), 3); case "I": return (x.isDaylightSavingTime()) ? 1 : 0; case "O": return x.getUTCOffset(); case "P": y = x.getUTCOffset(); return y.substring(0, y.length - 2) + ":" + y.substring(y.length - 2); case "B": var now = new Date(); return Math.floor(((now.getHours() * 3600) + (now.getMinutes() * 60) + now.getSeconds() + (now.getTimezoneOffset() + 60) * 60) / 86.4); case "c": return x.toISOString().replace(/\"/g, ""); case "U": return $D.strtotime("now"); case "%c": return t("d") + " " + t("t"); case "%C": return Math.floor(x.getFullYear() / 100 + 1); } }, shouldOverrideDefaults: function (m) { switch (m) { case "%e": return true; default: return false; } }, parse: function (m, context) { var formatString, c = context || new Date(); formatString = normalizer.substitutes(m); if (formatString) { return formatString; } formatString = normalizer.interpreted(m, c); if (formatString) { return formatString; } else { return m; } } }; $D.normalizeFormat = function (format, context) { return format.replace(/(%|\\)?.|%%/g, function(t){ return normalizer.parse(t, context); }); }; /** * Format a local Unix timestamp according to locale settings * * Example: * Date.strftime("%m/%d/%y", new Date()); // "04/13/08" * Date.strftime("c", "2008-04-13T17:52:03Z"); // "04/13/08" * * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @param {Number|String} The number representing the number of seconds that have elapsed since January 1, 1970 (local time). * @return {String} A string representation of the current Date object. */ $D.strftime = function (format, time) { var d = Date.parse(time); return d._format(format); }; /** * Parse any textual datetime description into a Unix timestamp. * A Unix timestamp is the number of seconds that have elapsed since January 1, 1970 (midnight UTC/GMT). * * Example: * Date.strtotime("04/13/08"); // 1208044800 * Date.strtotime("1970-01-01T00:00:00Z"); // 0 * * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @param {Object} A string or date object. * @return {String} A string representation of the current Date object. */ $D.strtotime = function (time) { var d = $D.parse(time); return Math.round($D.UTC(d.getUTCFullYear(), d.getUTCMonth(), d.getUTCDate(), d.getUTCHours(), d.getUTCMinutes(), d.getUTCSeconds(), d.getUTCMilliseconds()) / 1000); }; /** * Converts the value of the current Date object to its equivalent string representation using a PHP/Unix style of date format specifiers. * Format Specifiers * Format Description Example * ------ --------------------------------------------------------------------------- ----------------------- * %a abbreviated weekday name according to the current localed "Mon" through "Sun" * %A full weekday name according to the current localed "Sunday" through "Saturday" * %b abbreviated month name according to the current localed "Jan" through "Dec" * %B full month name according to the current locale "January" through "December" * %c preferred date and time representation for the current locale "4/13/2008 12:33 PM" * %C century number (the year divided by 100 and truncated to an integer) "00" to "99" * %d day of the month as a decimal number "01" to "31" * %D same as %m/%d/%y "04/13/08" * %e day of the month as a decimal number, a single digit is preceded by a space "1" to "31" * %g like %G, but without the century "08" * %G The 4-digit year corresponding to the ISO week number (see %V). "2008" * This has the same format and value as %Y, except that if the ISO week number * belongs to the previous or next year, that year is used instead. * %h same as %b "Jan" through "Dec" * %H hour as a decimal number using a 24-hour clock. "00" to "23" * %I hour as a decimal number using a 12-hour clock. "01" to "12" * %j day of the year as a decimal number. "001" to "366" * %m month as a decimal number. "01" to "12" * %M minute as a decimal number. "00" to "59" * %n newline character "\n" * %p either "am" or "pm" according to the given time value, or the "am" or "pm" * corresponding strings for the current locale. * %r time in a.m. and p.m. notation "8:44 PM" * %R time in 24 hour notation "20:44" * %S second as a decimal number "00" to "59" * %t tab character "\t" * %T current time, equal to %H:%M:%S "12:49:11" * %u weekday as a decimal number ["1", "7"], with "1" representing Monday "1" to "7" * %U week number of the current year as a decimal number, starting with the "0" to ("52" or "53") * first Sunday as the first day of the first week * %V The ISO 8601:1988 week number of the current year as a decimal number, "00" to ("52" or "53") * range 01 to 53, where week 1 is the first week that has at least 4 days * in the current year, and with Monday as the first day of the week. * (Use %G or %g for the year component that corresponds to the week number * for the specified timestamp.) * %W week number of the current year as a decimal number, starting with the "00" to ("52" or "53") * first Monday as the first day of the first week * %w day of the week as a decimal, Sunday being "0" "0" to "6" * %x preferred date representation for the current locale without the time "4/13/2008" * %X preferred time representation for the current locale without the date "12:53:05" * %y year as a decimal number without a century "00" "99" * %Y year as a decimal number including the century "2008" * %Z time zone or name or abbreviation "UTC", "EST", "PST" * %z same as %Z * %% a literal "%" characters "%" * d Day of the month, 2 digits with leading zeros "01" to "31" * D A textual representation of a day, three letters "Mon" through "Sun" * j Day of the month without leading zeros "1" to "31" * l A full textual representation of the day of the week (lowercase "L") "Sunday" through "Saturday" * N ISO-8601 numeric representation of the day of the week (added in PHP 5.1.0) "1" (for Monday) through "7" (for Sunday) * S English ordinal suffix for the day of the month, 2 characters "st", "nd", "rd" or "th". Works well with j * w Numeric representation of the day of the week "0" (for Sunday) through "6" (for Saturday) * z The day of the year (starting from "0") "0" through "365" * W ISO-8601 week number of year, weeks starting on Monday "00" to ("52" or "53") * F A full textual representation of a month, such as January or March "January" through "December" * m Numeric representation of a month, with leading zeros "01" through "12" * M A short textual representation of a month, three letters "Jan" through "Dec" * n Numeric representation of a month, without leading zeros "1" through "12" * t Number of days in the given month "28" through "31" * L Whether it's a leap year "1" if it is a leap year, "0" otherwise * o ISO-8601 year number. This has the same value as Y, except that if the "2008" * ISO week number (W) belongs to the previous or next year, that year * is used instead. * Y A full numeric representation of a year, 4 digits "2008" * y A two digit representation of a year "08" * a Lowercase Ante meridiem and Post meridiem "am" or "pm" * A Uppercase Ante meridiem and Post meridiem "AM" or "PM" * B Swatch Internet time "000" through "999" * g 12-hour format of an hour without leading zeros "1" through "12" * G 24-hour format of an hour without leading zeros "0" through "23" * h 12-hour format of an hour with leading zeros "01" through "12" * H 24-hour format of an hour with leading zeros "00" through "23" * i Minutes with leading zeros "00" to "59" * s Seconds, with leading zeros "00" through "59" * u Milliseconds "54321" * e Timezone identifier "UTC", "EST", "PST" * I Whether or not the date is in daylight saving time (uppercase i) "1" if Daylight Saving Time, "0" otherwise * O Difference to Greenwich time (GMT) in hours "+0200", "-0600" * P Difference to Greenwich time (GMT) with colon between hours and minutes "+02:00", "-06:00" * T Timezone abbreviation "UTC", "EST", "PST" * Z Timezone offset in seconds. The offset for timezones west of UTC is "-43200" through "50400" * always negative, and for those east of UTC is always positive. * c ISO 8601 date "2004-02-12T15:19:21+00:00" * r RFC 2822 formatted date "Thu, 21 Dec 2000 16:01:07 +0200" * U Seconds since the Unix Epoch (January 1 1970 00:00:00 GMT) "0" * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @return {String} A string representation of the current Date object. */ var formatReplace = function (context) { return function (m) { var formatString, override = false; if (m.charAt(0) === "\\" || m.substring(0, 2) === "%%") { return m.replace("\\", "").replace("%%", "%"); } override = normalizer.shouldOverrideDefaults(m); formatString = $D.normalizeFormat(m, context); if (formatString) { return context.toString(formatString, override); } }; }; $P._format = function (format) { var formatter = formatReplace(this); if (!format) { return this._toString(); } else { return format.replace(/(%|\\)?.|%%/g, formatter); } }; if (!$P.format) { $P.format = $P._format; } }()); (function () { "use strict"; var gFn = function (attr) { return function () { return this[attr]; }; }; var sFn = function (attr) { return function (val) { this[attr] = val; return this; }; }; var attrs = ["years", "months", "days", "hours", "minutes", "seconds", "milliseconds"]; var addSetFuncs = function (context, attrs) { for (var i = 0; i < attrs.length ; i++) { var $a = attrs[i], $b = $a.slice(0, 1).toUpperCase() + $a.slice(1); context.prototype[$a] = 0; context.prototype["get" + $b] = gFn($a); context.prototype["set" + $b] = sFn($a); } }; /** * new TimeSpan(milliseconds); * new TimeSpan(days, hours, minutes, seconds); * new TimeSpan(days, hours, minutes, seconds, milliseconds); */ var TimeSpan = function (days, hours, minutes, seconds, milliseconds) { if (arguments.length === 1 && typeof days === "number") { var orient = (days < 0) ? -1 : +1; var millsLeft = Math.abs(days); this.setDays(Math.floor(millsLeft / 86400000) * orient); millsLeft = millsLeft % 86400000; this.setHours(Math.floor(millsLeft / 3600000) * orient); millsLeft = millsLeft % 3600000; this.setMinutes(Math.floor(millsLeft / 60000) * orient); millsLeft = millsLeft % 60000; this.setSeconds(Math.floor(millsLeft / 1000) * orient); millsLeft = millsLeft % 1000; this.setMilliseconds(millsLeft * orient); } else { this.set(days, hours, minutes, seconds, milliseconds); } this.getTotalMilliseconds = function () { return (this.getDays() * 86400000) + (this.getHours() * 3600000) + (this.getMinutes() * 60000) + (this.getSeconds() * 1000); }; this.compareTo = function (time) { var t1 = new Date(1970, 1, 1, this.getHours(), this.getMinutes(), this.getSeconds()), t2; if (time === null) { t2 = new Date(1970, 1, 1, 0, 0, 0); } else { t2 = new Date(1970, 1, 1, time.getHours(), time.getMinutes(), time.getSeconds()); } return (t1 < t2) ? -1 : (t1 > t2) ? 1 : 0; }; this.equals = function (time) { return (this.compareTo(time) === 0); }; this.add = function (time) { return (time === null) ? this : this.addSeconds(time.getTotalMilliseconds() / 1000); }; this.subtract = function (time) { return (time === null) ? this : this.addSeconds(-time.getTotalMilliseconds() / 1000); }; this.addDays = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 86400000)); }; this.addHours = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 3600000)); }; this.addMinutes = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 60000)); }; this.addSeconds = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 1000)); }; this.addMilliseconds = function (n) { return new TimeSpan(this.getTotalMilliseconds() + n); }; this.get12HourHour = function () { return (this.getHours() > 12) ? this.getHours() - 12 : (this.getHours() === 0) ? 12 : this.getHours(); }; this.getDesignator = function () { return (this.getHours() < 12) ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator; }; this.toString = function (format) { this._toString = function () { if (this.getDays() !== null && this.getDays() > 0) { return this.getDays() + "." + this.getHours() + ":" + this.p(this.getMinutes()) + ":" + this.p(this.getSeconds()); } else { return this.getHours() + ":" + this.p(this.getMinutes()) + ":" + this.p(this.getSeconds()); } }; this.p = function (s) { return (s.toString().length < 2) ? "0" + s : s; }; var me = this; return format ? format.replace(/dd?|HH?|hh?|mm?|ss?|tt?/g, function (format) { switch (format) { case "d": return me.getDays(); case "dd": return me.p(me.getDays()); case "H": return me.getHours(); case "HH": return me.p(me.getHours()); case "h": return me.get12HourHour(); case "hh": return me.p(me.get12HourHour()); case "m": return me.getMinutes(); case "mm": return me.p(me.getMinutes()); case "s": return me.getSeconds(); case "ss": return me.p(me.getSeconds()); case "t": return ((me.getHours() < 12) ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator).substring(0, 1); case "tt": return (me.getHours() < 12) ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator; } } ) : this._toString(); }; return this; }; addSetFuncs(TimeSpan, attrs.slice(2)); TimeSpan.prototype.set = function (days, hours, minutes, seconds, milliseconds){ this.setDays(days || this.getDays()); this.setHours(hours || this.getHours()); this.setMinutes(minutes || this.getMinutes()); this.setSeconds(seconds || this.getSeconds()); this.setMilliseconds(milliseconds || this.getMilliseconds()); }; /** * Gets the time of day for this date instances. * @return {TimeSpan} TimeSpan */ Date.prototype.getTimeOfDay = function () { return new TimeSpan(0, this.getHours(), this.getMinutes(), this.getSeconds(), this.getMilliseconds()); }; Date.TimeSpan = TimeSpan; if (typeof window !== "undefined" ) { // keeping API compatible for v1.x window.TimeSpan = TimeSpan; } }()); (function () { "use strict"; var attrs = ["years", "months", "days", "hours", "minutes", "seconds", "milliseconds"]; var gFn = function (attr) { return function () { return this[attr]; }; }; var sFn = function (attr) { return function (val) { this[attr] = val; return this; }; }; var addSetFuncs = function (context, attrs) { for (var i = 0; i < attrs.length ; i++) { var $a = attrs[i], $b = $a.slice(0, 1).toUpperCase() + $a.slice(1); context.prototype[$a] = 0; context.prototype["get" + $b] = gFn($a); context.prototype["set" + $b] = sFn($a); } }; var setMonthsAndYears = function (orient, d1, d2, context) { function inc() { d1.addMonths(-orient); context.months++; if (context.months === 12) { context.years++; context.months = 0; } } if (orient === +1) { while (d1 > d2) { inc(); } } else { while (d1 < d2) { inc(); } } context.months--; context.months *= orient; context.years *= orient; }; var adjustForDST = function(orient, startDate, endDate) { var hasDSTMismatch = (false === (startDate.isDaylightSavingTime() === endDate.isDaylightSavingTime())); if (hasDSTMismatch && orient === 1) { startDate.addHours(-1); } else if (hasDSTMismatch) { startDate.addHours(1); } }; /** * TimePeriod(startDate, endDate); * TimePeriod(years, months, days, hours, minutes, seconds, milliseconds); */ var TimePeriod = function (years, months, days, hours, minutes, seconds, milliseconds) { if (arguments.length === 7) { this.set(years, months, days, hours, minutes, seconds, milliseconds); } else if (arguments.length === 2 && arguments[0] instanceof Date && arguments[1] instanceof Date) { var startDate = arguments[0].clone(); var endDate = arguments[1].clone(); var orient = (startDate > endDate) ? +1 : -1; this.dates = { start: arguments[0].clone(), end: arguments[1].clone() }; setMonthsAndYears(orient, startDate, endDate, this); adjustForDST(orient, startDate, endDate); // // TODO - adjust for DST var diff = endDate - startDate; if (diff !== 0) { var ts = new TimeSpan(diff); this.set(this.years, this.months, ts.getDays(), ts.getHours(), ts.getMinutes(), ts.getSeconds(), ts.getMilliseconds()); } } return this; }; // create all the set functions. addSetFuncs(TimePeriod, attrs); TimePeriod.prototype.set = function (years, months, days, hours, minutes, seconds, milliseconds){ this.setYears(years || this.getYears()); this.setMonths(months || this.getMonths()); this.setDays(days || this.getDays()); this.setHours(hours || this.getHours()); this.setMinutes(minutes || this.getMinutes()); this.setSeconds(seconds || this.getSeconds()); this.setMilliseconds(milliseconds || this.getMilliseconds()); }; Date.TimePeriod = TimePeriod; if (typeof window !== "undefined") { // keeping API compatible for v1.x window.TimePeriod = TimePeriod; } }()); ================================================ FILE: build/date-en-AU.js ================================================ /** * @overview datejs * @version 1.0.0-rc3 * @author Gregory Wild-Smith * @copyright 2015 Gregory Wild-Smith * @license MIT * @homepage https://github.com/abritinthebay/datejs */ /* * DateJS Culture String File * Country Code: en-AU * Name: English (Australia) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["en-AU"] = { "name": "en-AU", "englishName": "English (Australia)", "nativeName": "English (Australia)", "Sunday": "Sunday", "Monday": "Monday", "Tuesday": "Tuesday", "Wednesday": "Wednesday", "Thursday": "Thursday", "Friday": "Friday", "Saturday": "Saturday", "Sun": "Sun", "Mon": "Mon", "Tue": "Tue", "Wed": "Wed", "Thu": "Thu", "Fri": "Fri", "Sat": "Sat", "Su": "Su", "Mo": "Mo", "Tu": "Tu", "We": "We", "Th": "Th", "Fr": "Fr", "Sa": "Sa", "S_Sun_Initial": "S", "M_Mon_Initial": "M", "T_Tue_Initial": "T", "W_Wed_Initial": "W", "T_Thu_Initial": "T", "F_Fri_Initial": "F", "S_Sat_Initial": "S", "January": "January", "February": "February", "March": "March", "April": "April", "May": "May", "June": "June", "July": "July", "August": "August", "September": "September", "October": "October", "November": "November", "December": "December", "Jan_Abbr": "Jan", "Feb_Abbr": "Feb", "Mar_Abbr": "Mar", "Apr_Abbr": "Apr", "May_Abbr": "May", "Jun_Abbr": "Jun", "Jul_Abbr": "Jul", "Aug_Abbr": "Aug", "Sep_Abbr": "Sep", "Oct_Abbr": "Oct", "Nov_Abbr": "Nov", "Dec_Abbr": "Dec", "AM": "AM", "PM": "PM", "firstDayOfWeek": 1, "twoDigitYearMax": 2029, "mdy": "dmy", "M/d/yyyy": "d/MM/yyyy", "dddd, MMMM dd, yyyy": "dddd, d MMMM yyyy", "h:mm tt": "h:mm tt", "h:mm:ss tt": "h:mm:ss tt", "dddd, MMMM dd, yyyy h:mm:ss tt": "dddd, d MMMM yyyy h:mm:ss tt", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "dd MMMM", "MMMM, yyyy": "MMMM yyyy", "/jan(uary)?/": "jan(uary)?", "/feb(ruary)?/": "feb(ruary)?", "/mar(ch)?/": "mar(ch)?", "/apr(il)?/": "apr(il)?", "/may/": "may", "/jun(e)?/": "jun(e)?", "/jul(y)?/": "jul(y)?", "/aug(ust)?/": "aug(ust)?", "/sep(t(ember)?)?/": "sep(t(ember)?)?", "/oct(ober)?/": "oct(ober)?", "/nov(ember)?/": "nov(ember)?", "/dec(ember)?/": "dec(ember)?", "/^su(n(day)?)?/": "^su(n(day)?)?", "/^mo(n(day)?)?/": "^mo(n(day)?)?", "/^tu(e(s(day)?)?)?/": "^tu(e(s(day)?)?)?", "/^we(d(nesday)?)?/": "^we(d(nesday)?)?", "/^th(u(r(s(day)?)?)?)?/": "^th(u(r(s(day)?)?)?)?", "/^fr(i(day)?)?/": "^fr(i(day)?)?", "/^sa(t(urday)?)?/": "^sa(t(urday)?)?", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "en-AU"; /** * @overview datejs * @version 1.0.0-rc3 * @author Gregory Wild-Smith * @copyright 2015 Gregory Wild-Smith * @license MIT * @homepage https://github.com/abritinthebay/datejs */(function () { var $D = Date; var lang = Date.CultureStrings ? Date.CultureStrings.lang : null; var loggedKeys = {}; // for debug purposes. var getText = { getFromKey: function (key, countryCode) { var output; if (Date.CultureStrings && Date.CultureStrings[countryCode] && Date.CultureStrings[countryCode][key]) { output = Date.CultureStrings[countryCode][key]; } else { output = getText.buildFromDefault(key); } if (key.charAt(0) === "/") { // Assume it's a regex output = getText.buildFromRegex(key, countryCode); } return output; }, getFromObjectValues: function (obj, countryCode) { var key, output = {}; for(key in obj) { if (obj.hasOwnProperty(key)) { output[key] = getText.getFromKey(obj[key], countryCode); } } return output; }, getFromObjectKeys: function (obj, countryCode) { var key, output = {}; for(key in obj) { if (obj.hasOwnProperty(key)) { output[getText.getFromKey(key, countryCode)] = obj[key]; } } return output; }, getFromArray: function (arr, countryCode) { var output = []; for (var i=0; i < arr.length; i++){ if (i in arr) { output[i] = getText.getFromKey(arr[i], countryCode); } } return output; }, buildFromDefault: function (key) { var output, length, split, last; switch(key) { case "name": output = "en-US"; break; case "englishName": output = "English (United States)"; break; case "nativeName": output = "English (United States)"; break; case "twoDigitYearMax": output = 2049; break; case "firstDayOfWeek": output = 0; break; default: output = key; split = key.split("_"); length = split.length; if (length > 1 && key.charAt(0) !== "/") { // if the key isn't a regex and it has a split. last = split[(length - 1)].toLowerCase(); if (last === "initial" || last === "abbr") { output = split[0]; } } break; } return output; }, buildFromRegex: function (key, countryCode) { var output; if (Date.CultureStrings && Date.CultureStrings[countryCode] && Date.CultureStrings[countryCode][key]) { output = new RegExp(Date.CultureStrings[countryCode][key], "i"); } else { output = new RegExp(key.replace(new RegExp("/", "g"),""), "i"); } return output; } }; var shallowMerge = function (obj1, obj2) { for (var attrname in obj2) { if (obj2.hasOwnProperty(attrname)) { obj1[attrname] = obj2[attrname]; } } }; var __ = function (key, language) { var countryCode = (language) ? language : lang; loggedKeys[key] = key; if (typeof key === "object") { if (key instanceof Array) { return getText.getFromArray(key, countryCode); } else { return getText.getFromObjectKeys(key, countryCode); } } else { return getText.getFromKey(key, countryCode); } }; var loadI18nScript = function (code) { // paatterned after jQuery's getScript. var url = Date.Config.i18n + code + ".js"; var head = document.getElementsByTagName("head")[0] || document.documentElement; var script = document.createElement("script"); script.src = url; var completed = false; var events = { done: function (){} // placeholder function }; // Attach handlers for all browsers script.onload = script.onreadystatechange = function() { if ( !completed && (!this.readyState || this.readyState === "loaded" || this.readyState === "complete") ) { events.done(); head.removeChild(script); } }; setTimeout(function() { head.insertBefore(script, head.firstChild); }, 0); // allows return to execute first return { done: function (cb) { events.done = function() { if (cb) { setTimeout(cb,0); } }; } }; }; var buildInfo = { buildFromMethodHash: function (obj) { var key; for(key in obj) { if (obj.hasOwnProperty(key)) { obj[key] = buildInfo[obj[key]](); } } return obj; }, timeZoneDST: function () { var DST = { "CHADT": "+1345", "NZDT": "+1300", "AEDT": "+1100", "ACDT": "+1030", "AZST": "+0500", "IRDT": "+0430", "EEST": "+0300", "CEST": "+0200", "BST": "+0100", "PMDT": "-0200", "ADT": "-0300", "NDT": "-0230", "EDT": "-0400", "CDT": "-0500", "MDT": "-0600", "PDT": "-0700", "AKDT": "-0800", "HADT": "-0900" }; return __(DST); }, timeZoneStandard: function () { var standard = { "LINT": "+1400", "TOT": "+1300", "CHAST": "+1245", "NZST": "+1200", "NFT": "+1130", "SBT": "+1100", "AEST": "+1000", "ACST": "+0930", "JST": "+0900", "CWST": "+0845", "CT": "+0800", "ICT": "+0700", "MMT": "+0630", "BST": "+0600", "NPT": "+0545", "IST": "+0530", "PKT": "+0500", "AFT": "+0430", "MSK": "+0400", "IRST": "+0330", "FET": "+0300", "EET": "+0200", "CET": "+0100", "GMT": "+0000", "UTC": "+0000", "CVT": "-0100", "GST": "-0200", "BRT": "-0300", "NST": "-0330", "AST": "-0400", "EST": "-0500", "CST": "-0600", "MST": "-0700", "PST": "-0800", "AKST": "-0900", "MIT": "-0930", "HST": "-1000", "SST": "-1100", "BIT": "-1200" }; return __(standard); }, timeZones: function (data) { var zone; data.timezones = []; for (zone in data.abbreviatedTimeZoneStandard) { if (data.abbreviatedTimeZoneStandard.hasOwnProperty(zone)) { data.timezones.push({ name: zone, offset: data.abbreviatedTimeZoneStandard[zone]}); } } for (zone in data.abbreviatedTimeZoneDST) { if (data.abbreviatedTimeZoneDST.hasOwnProperty(zone)) { data.timezones.push({ name: zone, offset: data.abbreviatedTimeZoneDST[zone], dst: true}); } } return data.timezones; }, days: function () { return __(["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"]); }, dayAbbr: function () { return __(["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"]); }, dayShortNames: function () { return __(["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"]); }, dayFirstLetters: function () { return __(["S_Sun_Initial", "M_Mon_Initial", "T_Tues_Initial", "W_Wed_Initial", "T_Thu_Initial", "F_Fri_Initial", "S_Sat_Initial"]); }, months: function () { return __(["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"]); }, monthAbbr: function () { return __(["Jan_Abbr", "Feb_Abbr", "Mar_Abbr", "Apr_Abbr", "May_Abbr", "Jun_Abbr", "Jul_Abbr", "Aug_Abbr", "Sep_Abbr", "Oct_Abbr", "Nov_Abbr", "Dec_Abbr"]); }, formatPatterns: function () { return getText.getFromObjectValues({ shortDate: "M/d/yyyy", longDate: "dddd, MMMM dd, yyyy", shortTime: "h:mm tt", longTime: "h:mm:ss tt", fullDateTime: "dddd, MMMM dd, yyyy h:mm:ss tt", sortableDateTime: "yyyy-MM-ddTHH:mm:ss", universalSortableDateTime: "yyyy-MM-dd HH:mm:ssZ", rfc1123: "ddd, dd MMM yyyy HH:mm:ss", monthDay: "MMMM dd", yearMonth: "MMMM, yyyy" }, Date.i18n.currentLanguage()); }, regex: function () { return getText.getFromObjectValues({ inTheMorning: "/( in the )(morn(ing)?)\\b/", thisMorning: "/(this )(morn(ing)?)\\b/", amThisMorning: "/(\b\\d(am)? )(this )(morn(ing)?)/", inTheEvening: "/( in the )(even(ing)?)\\b/", thisEvening: "/(this )(even(ing)?)\\b/", pmThisEvening: "/(\b\\d(pm)? )(this )(even(ing)?)/", jan: "/jan(uary)?/", feb: "/feb(ruary)?/", mar: "/mar(ch)?/", apr: "/apr(il)?/", may: "/may/", jun: "/jun(e)?/", jul: "/jul(y)?/", aug: "/aug(ust)?/", sep: "/sep(t(ember)?)?/", oct: "/oct(ober)?/", nov: "/nov(ember)?/", dec: "/dec(ember)?/", sun: "/^su(n(day)?)?/", mon: "/^mo(n(day)?)?/", tue: "/^tu(e(s(day)?)?)?/", wed: "/^we(d(nesday)?)?/", thu: "/^th(u(r(s(day)?)?)?)?/", fri: "/fr(i(day)?)?/", sat: "/^sa(t(urday)?)?/", future: "/^next/", past: "/^last|past|prev(ious)?/", add: "/^(\\+|aft(er)?|from|hence)/", subtract: "/^(\\-|bef(ore)?|ago)/", yesterday: "/^yes(terday)?/", today: "/^t(od(ay)?)?/", tomorrow: "/^tom(orrow)?/", now: "/^n(ow)?/", millisecond: "/^ms|milli(second)?s?/", second: "/^sec(ond)?s?/", minute: "/^mn|min(ute)?s?/", hour: "/^h(our)?s?/", week: "/^w(eek)?s?/", month: "/^m(onth)?s?/", day: "/^d(ay)?s?/", year: "/^y(ear)?s?/", shortMeridian: "/^(a|p)/", longMeridian: "/^(a\\.?m?\\.?|p\\.?m?\\.?)/", timezone: "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/", ordinalSuffix: "/^\\s*(st|nd|rd|th)/", timeContext: "/^\\s*(\\:|a(?!u|p)|p)/" }, Date.i18n.currentLanguage()); } }; var CultureInfo = function () { var info = getText.getFromObjectValues({ name: "name", englishName: "englishName", nativeName: "nativeName", amDesignator: "AM", pmDesignator: "PM", firstDayOfWeek: "firstDayOfWeek", twoDigitYearMax: "twoDigitYearMax", dateElementOrder: "mdy" }, Date.i18n.currentLanguage()); var constructedInfo = buildInfo.buildFromMethodHash({ dayNames: "days", abbreviatedDayNames: "dayAbbr", shortestDayNames: "dayShortNames", firstLetterDayNames: "dayFirstLetters", monthNames: "months", abbreviatedMonthNames: "monthAbbr", formatPatterns: "formatPatterns", regexPatterns: "regex", abbreviatedTimeZoneDST: "timeZoneDST", abbreviatedTimeZoneStandard: "timeZoneStandard" }); shallowMerge(info, constructedInfo); buildInfo.timeZones(info); return info; }; $D.i18n = { __: function (key, lang) { return __(key, lang); }, currentLanguage: function () { return lang || "en-US"; }, setLanguage: function (code, force, cb) { var async = false; if (force || code === "en-US" || (!!Date.CultureStrings && !!Date.CultureStrings[code])) { lang = code; Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings.lang = code; Date.CultureInfo = new CultureInfo(); } else { if (!(!!Date.CultureStrings && !!Date.CultureStrings[code])) { if (typeof exports !== "undefined" && this.exports !== exports) { // we're in a Node enviroment, load it using require try { require("../i18n/" + code + ".js"); lang = code; Date.CultureStrings.lang = code; Date.CultureInfo = new CultureInfo(); } catch (e) { // var str = "The language for '" + code + "' could not be loaded by Node. It likely does not exist."; throw new Error("The DateJS IETF language tag '" + code + "' could not be loaded by Node. It likely does not exist."); } } else if (Date.Config && Date.Config.i18n) { // we know the location of the files, so lets load them async = true; loadI18nScript(code).done(function(){ lang = code; Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings.lang = code; Date.CultureInfo = new CultureInfo(); $D.Parsing.Normalizer.buildReplaceData(); // because this is async if ($D.Grammar) { $D.Grammar.buildGrammarFormats(); // so we can parse those strings... } if (cb) { setTimeout(cb,0); } }); } else { Date.console.error("The DateJS IETF language tag '" + code + "' is not available and has not been loaded."); return false; } } } $D.Parsing.Normalizer.buildReplaceData(); // rebuild normalizer strings if ($D.Grammar) { $D.Grammar.buildGrammarFormats(); // so we can parse those strings... } if (!async && cb) { setTimeout(cb,0); } }, getLoggedKeys: function () { return loggedKeys; }, updateCultureInfo: function () { Date.CultureInfo = new CultureInfo(); } }; $D.i18n.updateCultureInfo(); // run automatically }()); (function () { var $D = Date, $P = $D.prototype, p = function (s, l) { if (!l) { l = 2; } return ("000" + s).slice(l * -1); }; if (typeof window !== "undefined" && typeof window.console !== "undefined" && typeof window.console.log !== "undefined") { $D.console = console; // used only to raise non-critical errors if available } else { // set mock so we don't give errors. $D.console = { log: function(){}, error: function(){} }; } $D.Config = $D.Config || {}; $D.initOverloads = function() { /** * Overload of Date.now. Allows an alternate call for Date.now where it returns the * current Date as an object rather than just milliseconds since the Unix Epoch. * * Also provides an implementation of now() for browsers (IE<9) that don't have it. * * Backwards compatible so with work with either: * Date.now() [returns ms] * or * Date.now(true) [returns Date] */ if (!$D.now) { $D._now = function now() { return new Date().getTime(); }; } else if (!$D._now) { $D._now = $D.now; } $D.now = function (returnObj) { if (returnObj) { return $D.present(); } else { return $D._now(); } }; if ( !$P.toISOString ) { $P.toISOString = function() { return this.getUTCFullYear() + "-" + p(this.getUTCMonth() + 1) + "-" + p(this.getUTCDate()) + "T" + p(this.getUTCHours()) + ":" + p(this.getUTCMinutes()) + ":" + p(this.getUTCSeconds()) + "." + String( (this.getUTCMilliseconds()/1000).toFixed(3)).slice(2, 5) + "Z"; }; } // private if ( $P._toString === undefined ){ $P._toString = $P.toString; } }; $D.initOverloads(); /** * Gets a date that is set to the current date. The time is set to the start of the day (00:00 or 12:00 AM). * @return {Date} The current date. */ $D.today = function () { return new Date().clearTime(); }; /** * Gets a date that is set to the current date and time (same as new Date, but chainable) * @return {Date} The current date. */ $D.present = function () { return new Date(); }; /** * Compares the first date to the second date and returns an number indication of their relative values. * @param {Date} First Date object to compare [Required]. * @param {Date} Second Date object to compare to [Required]. * @return {Number} -1 = date1 is lessthan date2. 0 = values are equal. 1 = date1 is greaterthan date2. */ $D.compare = function (date1, date2) { if (isNaN(date1) || isNaN(date2)) { throw new Error(date1 + " - " + date2); } else if (date1 instanceof Date && date2 instanceof Date) { return (date1 < date2) ? -1 : (date1 > date2) ? 1 : 0; } else { throw new TypeError(date1 + " - " + date2); } }; /** * Compares the first Date object to the second Date object and returns true if they are equal. * @param {Date} First Date object to compare [Required] * @param {Date} Second Date object to compare to [Required] * @return {Boolean} true if dates are equal. false if they are not equal. */ $D.equals = function (date1, date2) { return (date1.compareTo(date2) === 0); }; /** * Gets the language appropriate day name when given the day number(0-6) * eg - 0 == Sunday * @return {String} The day name */ $D.getDayName = function (n) { return Date.CultureInfo.dayNames[n]; }; /** * Gets the day number (0-6) if given a CultureInfo specific string which is a valid dayName, abbreviatedDayName or shortestDayName (two char). * @param {String} The name of the day (eg. "Monday, "Mon", "tuesday", "tue", "We", "we"). * @return {Number} The day number */ $D.getDayNumberFromName = function (name) { var n = Date.CultureInfo.dayNames, m = Date.CultureInfo.abbreviatedDayNames, o = Date.CultureInfo.shortestDayNames, s = name.toLowerCase(); for (var i = 0; i < n.length; i++) { if (n[i].toLowerCase() === s || m[i].toLowerCase() === s || o[i].toLowerCase() === s) { return i; } } return -1; }; /** * Gets the month number (0-11) if given a Culture Info specific string which is a valid monthName or abbreviatedMonthName. * @param {String} The name of the month (eg. "February, "Feb", "october", "oct"). * @return {Number} The day number */ $D.getMonthNumberFromName = function (name) { var n = Date.CultureInfo.monthNames, m = Date.CultureInfo.abbreviatedMonthNames, s = name.toLowerCase(); for (var i = 0; i < n.length; i++) { if (n[i].toLowerCase() === s || m[i].toLowerCase() === s) { return i; } } return -1; }; /** * Gets the language appropriate month name when given the month number(0-11) * eg - 0 == January * @return {String} The month name */ $D.getMonthName = function (n) { return Date.CultureInfo.monthNames[n]; }; /** * Determines if the current date instance is within a LeapYear. * @param {Number} The year. * @return {Boolean} true if date is within a LeapYear, otherwise false. */ $D.isLeapYear = function (year) { return ((year % 4 === 0 && year % 100 !== 0) || year % 400 === 0); }; /** * Gets the number of days in the month, given a year and month value. Automatically corrects for LeapYear. * @param {Number} The year. * @param {Number} The month (0-11). * @return {Number} The number of days in the month. */ $D.getDaysInMonth = function (year, month) { if (!month && $D.validateMonth(year)) { month = year; year = Date.today().getFullYear(); } return [31, ($D.isLeapYear(year) ? 29 : 28), 31, 30, 31, 30, 31, 31, 30, 31, 30, 31][month]; }; $P.getDaysInMonth = function () { return $D.getDaysInMonth(this.getFullYear(), this.getMonth()); }; $D.getTimezoneAbbreviation = function (offset, dst) { var p, n = (dst || false) ? Date.CultureInfo.abbreviatedTimeZoneDST : Date.CultureInfo.abbreviatedTimeZoneStandard; for (p in n) { if (n.hasOwnProperty(p)) { if (n[p] === offset) { return p; } } } return null; }; $D.getTimezoneOffset = function (name, dst) { var i, a =[], z = Date.CultureInfo.timezones; if (!name) { name = (new Date()).getTimezone();} for (i = 0; i < z.length; i++) { if (z[i].name === name.toUpperCase()) { a.push(i); } } if (!z[a[0]]) { return null; } if (a.length === 1 || !dst) { return z[a[0]].offset; } else { for (i=0; i < a.length; i++) { if (z[a[i]].dst) { return z[a[i]].offset; } } } }; $D.getQuarter = function (d) { d = d || new Date(); // If no date supplied, use today var q = [1,2,3,4]; return q[Math.floor(d.getMonth() / 3)]; // ~~~ is a bitwise op. Faster than Math.floor }; $D.getDaysLeftInQuarter = function (d) { d = d || new Date(); var qEnd = new Date(d); qEnd.setMonth(qEnd.getMonth() + 3 - qEnd.getMonth() % 3, 0); return Math.floor((qEnd - d) / 8.64e7); }; // private var validate = function (n, min, max, name) { name = name ? name : "Object"; if (typeof n === "undefined") { return false; } else if (typeof n !== "number") { throw new TypeError(n + " is not a Number."); } else if (n < min || n > max) { // As failing validation is *not* an exceptional circumstance // lets not throw a RangeError Exception here. // It's semantically correct but it's not sensible. return false; } return true; }; /** * Validates the number is within an acceptable range for milliseconds [0-999]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateMillisecond = function (value) { return validate(value, 0, 999, "millisecond"); }; /** * Validates the number is within an acceptable range for seconds [0-59]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateSecond = function (value) { return validate(value, 0, 59, "second"); }; /** * Validates the number is within an acceptable range for minutes [0-59]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateMinute = function (value) { return validate(value, 0, 59, "minute"); }; /** * Validates the number is within an acceptable range for hours [0-23]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateHour = function (value) { return validate(value, 0, 23, "hour"); }; /** * Validates the number is within an acceptable range for the days in a month [0-MaxDaysInMonth]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateDay = function (value, year, month) { if (year === undefined || year === null || month === undefined || month === null) { return false;} return validate(value, 1, $D.getDaysInMonth(year, month), "day"); }; /** * Validates the number is within an acceptable range for months [0-11]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateWeek = function (value) { return validate(value, 0, 53, "week"); }; /** * Validates the number is within an acceptable range for months [0-11]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateMonth = function (value) { return validate(value, 0, 11, "month"); }; /** * Validates the number is within an acceptable range for years. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateYear = function (value) { /** * Per ECMAScript spec the range of times supported by Date objects is * exactly -100,000,000 days to +100,000,000 days measured relative to * midnight at the beginning of 01 January, 1970 UTC. * This gives a range of 8,640,000,000,000,000 milliseconds to either * side of 01 January, 1970 UTC. * * Earliest possible date: Tue, 20 Apr 271,822 B.C. 00:00:00 UTC * Latest possible date: Sat, 13 Sep 275,760 00:00:00 UTC */ return validate(value, -271822, 275760, "year"); }; $D.validateTimezone = function(value) { var timezones = {"ACDT":1,"ACST":1,"ACT":1,"ADT":1,"AEDT":1,"AEST":1,"AFT":1,"AKDT":1,"AKST":1,"AMST":1,"AMT":1,"ART":1,"AST":1,"AWDT":1,"AWST":1,"AZOST":1,"AZT":1,"BDT":1,"BIOT":1,"BIT":1,"BOT":1,"BRT":1,"BST":1,"BTT":1,"CAT":1,"CCT":1,"CDT":1,"CEDT":1,"CEST":1,"CET":1,"CHADT":1,"CHAST":1,"CHOT":1,"ChST":1,"CHUT":1,"CIST":1,"CIT":1,"CKT":1,"CLST":1,"CLT":1,"COST":1,"COT":1,"CST":1,"CT":1,"CVT":1,"CWST":1,"CXT":1,"DAVT":1,"DDUT":1,"DFT":1,"EASST":1,"EAST":1,"EAT":1,"ECT":1,"EDT":1,"EEDT":1,"EEST":1,"EET":1,"EGST":1,"EGT":1,"EIT":1,"EST":1,"FET":1,"FJT":1,"FKST":1,"FKT":1,"FNT":1,"GALT":1,"GAMT":1,"GET":1,"GFT":1,"GILT":1,"GIT":1,"GMT":1,"GST":1,"GYT":1,"HADT":1,"HAEC":1,"HAST":1,"HKT":1,"HMT":1,"HOVT":1,"HST":1,"ICT":1,"IDT":1,"IOT":1,"IRDT":1,"IRKT":1,"IRST":1,"IST":1,"JST":1,"KGT":1,"KOST":1,"KRAT":1,"KST":1,"LHST":1,"LINT":1,"MAGT":1,"MART":1,"MAWT":1,"MDT":1,"MET":1,"MEST":1,"MHT":1,"MIST":1,"MIT":1,"MMT":1,"MSK":1,"MST":1,"MUT":1,"MVT":1,"MYT":1,"NCT":1,"NDT":1,"NFT":1,"NPT":1,"NST":1,"NT":1,"NUT":1,"NZDT":1,"NZST":1,"OMST":1,"ORAT":1,"PDT":1,"PET":1,"PETT":1,"PGT":1,"PHOT":1,"PHT":1,"PKT":1,"PMDT":1,"PMST":1,"PONT":1,"PST":1,"PYST":1,"PYT":1,"RET":1,"ROTT":1,"SAKT":1,"SAMT":1,"SAST":1,"SBT":1,"SCT":1,"SGT":1,"SLST":1,"SRT":1,"SST":1,"SYOT":1,"TAHT":1,"THA":1,"TFT":1,"TJT":1,"TKT":1,"TLT":1,"TMT":1,"TOT":1,"TVT":1,"UCT":1,"ULAT":1,"UTC":1,"UYST":1,"UYT":1,"UZT":1,"VET":1,"VLAT":1,"VOLT":1,"VOST":1,"VUT":1,"WAKT":1,"WAST":1,"WAT":1,"WEDT":1,"WEST":1,"WET":1,"WST":1,"YAKT":1,"YEKT":1,"Z":1}; return (timezones[value] === 1); }; $D.validateTimezoneOffset= function(value) { // timezones go from +14hrs to -12hrs, the +X hours are negative offsets. return (value > -841 && value < 721); }; }()); (function () { var $D = Date, $P = $D.prototype, p = function (s, l) { if (!l) { l = 2; } return ("000" + s).slice(l * -1); }; var validateConfigObject = function (obj) { var result = {}, self = this, prop, testFunc; testFunc = function (prop, func, value) { if (prop === "day") { var month = (obj.month !== undefined) ? obj.month : self.getMonth(); var year = (obj.year !== undefined) ? obj.year : self.getFullYear(); return $D[func](value, year, month); } else { return $D[func](value); } }; for (prop in obj) { if (Object.prototype.hasOwnProperty.call(obj, prop)) { var func = "validate" + prop.charAt(0).toUpperCase() + prop.slice(1); if ($D[func] && obj[prop] !== null && testFunc(prop, func, obj[prop])) { result[prop] = obj[prop]; } } } return result; }; /** * Resets the time of this Date object to 12:00 AM (00:00), which is the start of the day. * @param {Boolean} .clone() this date instance before clearing Time * @return {Date} this */ $P.clearTime = function () { this.setHours(0); this.setMinutes(0); this.setSeconds(0); this.setMilliseconds(0); return this; }; /** * Resets the time of this Date object to the current time ('now'). * @return {Date} this */ $P.setTimeToNow = function () { var n = new Date(); this.setHours(n.getHours()); this.setMinutes(n.getMinutes()); this.setSeconds(n.getSeconds()); this.setMilliseconds(n.getMilliseconds()); return this; }; /** * Returns a new Date object that is an exact date and time copy of the original instance. * @return {Date} A new Date instance */ $P.clone = function () { return new Date(this.getTime()); }; /** * Compares this instance to a Date object and returns an number indication of their relative values. * @param {Date} Date object to compare [Required] * @return {Number} -1 = this is lessthan date. 0 = values are equal. 1 = this is greaterthan date. */ $P.compareTo = function (date) { return Date.compare(this, date); }; /** * Compares this instance to another Date object and returns true if they are equal. * @param {Date} Date object to compare. If no date to compare, new Date() [now] is used. * @return {Boolean} true if dates are equal. false if they are not equal. */ $P.equals = function (date) { return Date.equals(this, (date !== undefined ? date : new Date())); }; /** * Determines if this instance is between a range of two dates or equal to either the start or end dates. * @param {Date} Start of range [Required] * @param {Date} End of range [Required] * @return {Boolean} true is this is between or equal to the start and end dates, else false */ $P.between = function (start, end) { return this.getTime() >= start.getTime() && this.getTime() <= end.getTime(); }; /** * Determines if this date occurs after the date to compare to. * @param {Date} Date object to compare. If no date to compare, new Date() ("now") is used. * @return {Boolean} true if this date instance is greater than the date to compare to (or "now"), otherwise false. */ $P.isAfter = function (date) { return this.compareTo(date || new Date()) === 1; }; /** * Determines if this date occurs before the date to compare to. * @param {Date} Date object to compare. If no date to compare, new Date() ("now") is used. * @return {Boolean} true if this date instance is less than the date to compare to (or "now"). */ $P.isBefore = function (date) { return (this.compareTo(date || new Date()) === -1); }; /** * Determines if the current Date instance occurs today. * @return {Boolean} true if this date instance is 'today', otherwise false. */ /** * Determines if the current Date instance occurs on the same Date as the supplied 'date'. * If no 'date' to compare to is provided, the current Date instance is compared to 'today'. * @param {date} Date object to compare. If no date to compare, the current Date ("now") is used. * @return {Boolean} true if this Date instance occurs on the same Day as the supplied 'date'. */ $P.isToday = $P.isSameDay = function (date) { return this.clone().clearTime().equals((date || new Date()).clone().clearTime()); }; /** * Adds the specified number of milliseconds to this instance. * @param {Number} The number of milliseconds to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addMilliseconds = function (value) { if (!value) { return this; } this.setTime(this.getTime() + value * 1); return this; }; /** * Adds the specified number of seconds to this instance. * @param {Number} The number of seconds to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addSeconds = function (value) { if (!value) { return this; } return this.addMilliseconds(value * 1000); }; /** * Adds the specified number of seconds to this instance. * @param {Number} The number of seconds to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addMinutes = function (value) { if (!value) { return this; } return this.addMilliseconds(value * 60000); // 60*1000 }; /** * Adds the specified number of hours to this instance. * @param {Number} The number of hours to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addHours = function (value) { if (!value) { return this; } return this.addMilliseconds(value * 3600000); // 60*60*1000 }; /** * Adds the specified number of days to this instance. * @param {Number} The number of days to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addDays = function (value) { if (!value) { return this; } this.setDate(this.getDate() + value * 1); return this; }; /** * Adds the specified number of weekdays (ie - not sat or sun) to this instance. * @param {Number} The number of days to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addWeekdays = function (value) { if (!value) { return this; } var day = this.getDay(); var weeks = (Math.ceil(Math.abs(value)/7)); if (day === 0 || day === 6) { if (value > 0) { this.next().monday(); this.addDays(-1); day = this.getDay(); } } if (value < 0) { while (value < 0) { this.addDays(-1); day = this.getDay(); if (day !== 0 && day !== 6) { value++; } } return this; } else if (value > 5 || (6-day) <= value) { value = value + (weeks * 2); } return this.addDays(value); }; /** * Adds the specified number of weeks to this instance. * @param {Number} The number of weeks to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addWeeks = function (value) { if (!value) { return this; } return this.addDays(value * 7); }; /** * Adds the specified number of months to this instance. * @param {Number} The number of months to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addMonths = function (value) { if (!value) { return this; } var n = this.getDate(); this.setDate(1); this.setMonth(this.getMonth() + value * 1); this.setDate(Math.min(n, $D.getDaysInMonth(this.getFullYear(), this.getMonth()))); return this; }; $P.addQuarters = function (value) { if (!value) { return this; } // note this will take you to the same point in the quarter as you are now. // i.e. - if you are 15 days into the quarter you'll be 15 days into the resulting one. // bonus: this allows adding fractional quarters return this.addMonths(value * 3); }; /** * Adds the specified number of years to this instance. * @param {Number} The number of years to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addYears = function (value) { if (!value) { return this; } return this.addMonths(value * 12); }; /** * Adds (or subtracts) to the value of the years, months, weeks, days, hours, minutes, seconds, milliseconds of the date instance using given configuration object. Positive and Negative values allowed. * Example

	Date.today().add( { days: 1, months: 1 } )

	new Date().add( { years: -1 } )
	
* @param {Object} Configuration object containing attributes (months, days, etc.) * @return {Date} this */ $P.add = function (config) { if (typeof config === "number") { this._orient = config; return this; } var x = config; if (x.day) { // If we should be a different date than today (eg: for 'tomorrow -1d', etc). // Should only effect parsing, not direct usage (eg, Finish and FinishExact) if ((x.day - this.getDate()) !== 0) { this.setDate(x.day); } } if (x.milliseconds) { this.addMilliseconds(x.milliseconds); } if (x.seconds) { this.addSeconds(x.seconds); } if (x.minutes) { this.addMinutes(x.minutes); } if (x.hours) { this.addHours(x.hours); } if (x.weeks) { this.addWeeks(x.weeks); } if (x.months) { this.addMonths(x.months); } if (x.years) { this.addYears(x.years); } if (x.days) { this.addDays(x.days); } return this; }; /** * Get the week number. Week one (1) is the week which contains the first Thursday of the year. Monday is considered the first day of the week. * The .getWeek() function does NOT convert the date to UTC. The local datetime is used. * Please use .getISOWeek() to get the week of the UTC converted date. * @return {Number} 1 to 53 */ $P.getWeek = function (utc) { // Create a copy of this date object var self, target = new Date(this.valueOf()); if (utc) { target.addMinutes(target.getTimezoneOffset()); self = target.clone(); } else { self = this; } // ISO week date weeks start on monday // so correct the day number var dayNr = (self.getDay() + 6) % 7; // ISO 8601 states that week 1 is the week // with the first thursday of that year. // Set the target date to the thursday in the target week target.setDate(target.getDate() - dayNr + 3); // Store the millisecond value of the target date var firstThursday = target.valueOf(); // Set the target to the first thursday of the year // First set the target to january first target.setMonth(0, 1); // Not a thursday? Correct the date to the next thursday if (target.getDay() !== 4) { target.setMonth(0, 1 + ((4 - target.getDay()) + 7) % 7); } // The weeknumber is the number of weeks between the // first thursday of the year and the thursday in the target week return 1 + Math.ceil((firstThursday - target) / 604800000); // 604800000 = 7 * 24 * 3600 * 1000 }; /** * Get the ISO 8601 week number. Week one ("01") is the week which contains the first Thursday of the year. Monday is considered the first day of the week. * The .getISOWeek() function does convert the date to it's UTC value. Please use .getWeek() to get the week of the local date. * @return {String} "01" to "53" */ $P.getISOWeek = function () { return p(this.getWeek(true)); }; /** * Moves the date to Monday of the week set. Week one (1) is the week which contains the first Thursday of the year. * @param {Number} A Number (1 to 53) that represents the week of the year. * @return {Date} this */ $P.setWeek = function (n) { if ((n - this.getWeek()) === 0) { if (this.getDay() !== 1) { return this.moveToDayOfWeek(1, (this.getDay() > 1 ? -1 : 1)); } else { return this; } } else { return this.moveToDayOfWeek(1, (this.getDay() > 1 ? -1 : 1)).addWeeks(n - this.getWeek()); } }; $P.setQuarter = function (qtr) { var month = Math.abs(((qtr-1) * 3) + 1); return this.setMonth(month, 1); }; $P.getQuarter = function () { return Date.getQuarter(this); }; $P.getDaysLeftInQuarter = function () { return Date.getDaysLeftInQuarter(this); }; /** * Moves the date to the next n'th occurrence of the dayOfWeek starting from the beginning of the month. The number (-1) is a magic number and will return the last occurrence of the dayOfWeek in the month. * @param {Number} The dayOfWeek to move to * @param {Number} The n'th occurrence to move to. Use (-1) to return the last occurrence in the month * @return {Date} this */ $P.moveToNthOccurrence = function (dayOfWeek, occurrence) { if (dayOfWeek === "Weekday") { if (occurrence > 0) { this.moveToFirstDayOfMonth(); if (this.is().weekday()) { occurrence -= 1; } } else if (occurrence < 0) { this.moveToLastDayOfMonth(); if (this.is().weekday()) { occurrence += 1; } } else { return this; } return this.addWeekdays(occurrence); } var shift = 0; if (occurrence > 0) { shift = occurrence - 1; } else if (occurrence === -1) { this.moveToLastDayOfMonth(); if (this.getDay() !== dayOfWeek) { this.moveToDayOfWeek(dayOfWeek, -1); } return this; } return this.moveToFirstDayOfMonth().addDays(-1).moveToDayOfWeek(dayOfWeek, +1).addWeeks(shift); }; var moveToN = function (getFunc, addFunc, nVal) { return function (value, orient) { var diff = (value - this[getFunc]() + nVal * (orient || +1)) % nVal; return this[addFunc]((diff === 0) ? diff += nVal * (orient || +1) : diff); }; }; /** * Move to the next or last dayOfWeek based on the orient value. * @param {Number} The dayOfWeek to move to * @param {Number} Forward (+1) or Back (-1). Defaults to +1. [Optional] * @return {Date} this */ $P.moveToDayOfWeek = moveToN("getDay", "addDays", 7); /** * Move to the next or last month based on the orient value. * @param {Number} The month to move to. 0 = January, 11 = December * @param {Number} Forward (+1) or Back (-1). Defaults to +1. [Optional] * @return {Date} this */ $P.moveToMonth = moveToN("getMonth", "addMonths", 12); /** * Get the Ordinate of the current day ("th", "st", "rd"). * @return {String} */ $P.getOrdinate = function () { var num = this.getDate(); return ord(num); }; /** * Get the Ordinal day (numeric day number) of the year, adjusted for leap year. * @return {Number} 1 through 365 (366 in leap years) */ $P.getOrdinalNumber = function () { return Math.ceil((this.clone().clearTime() - new Date(this.getFullYear(), 0, 1)) / 86400000) + 1; }; /** * Get the time zone abbreviation of the current date. * @return {String} The abbreviated time zone name (e.g. "EST") */ $P.getTimezone = function () { return $D.getTimezoneAbbreviation(this.getUTCOffset(), this.isDaylightSavingTime()); }; $P.setTimezoneOffset = function (offset) { var here = this.getTimezoneOffset(), there = Number(offset) * -6 / 10; return (there || there === 0) ? this.addMinutes(there - here) : this; }; $P.setTimezone = function (offset) { return this.setTimezoneOffset($D.getTimezoneOffset(offset)); }; /** * Indicates whether Daylight Saving Time is observed in the current time zone. * @return {Boolean} true|false */ $P.hasDaylightSavingTime = function () { return (Date.today().set({month: 0, day: 1}).getTimezoneOffset() !== Date.today().set({month: 6, day: 1}).getTimezoneOffset()); }; /** * Indicates whether this Date instance is within the Daylight Saving Time range for the current time zone. * @return {Boolean} true|false */ $P.isDaylightSavingTime = function () { return Date.today().set({month: 0, day: 1}).getTimezoneOffset() !== this.getTimezoneOffset(); }; /** * Get the offset from UTC of the current date. * @return {String} The 4-character offset string prefixed with + or - (e.g. "-0500") */ $P.getUTCOffset = function (offset) { var n = (offset || this.getTimezoneOffset()) * -10 / 6, r; if (n < 0) { r = (n - 10000).toString(); return r.charAt(0) + r.substr(2); } else { r = (n + 10000).toString(); return "+" + r.substr(1); } }; /** * Returns the number of milliseconds between this date and date. * @param {Date} Defaults to now * @return {Number} The diff in milliseconds */ $P.getElapsed = function (date) { return (date || new Date()) - this; }; /** * Set the value of year, month, day, hour, minute, second, millisecond of date instance using given configuration object. * Example

	Date.today().set( { day: 20, month: 1 } )

	new Date().set( { millisecond: 0 } )
	
* * @param {Object} Configuration object containing attributes (month, day, etc.) * @return {Date} this */ $P.set = function (config) { config = validateConfigObject.call(this, config); var key; for (key in config) { if (Object.prototype.hasOwnProperty.call(config, key)) { var name = key.charAt(0).toUpperCase() + key.slice(1); var addFunc, getFunc; if (key !== "week" && key !== "month" && key !== "timezone" && key !== "timezoneOffset") { name += "s"; } addFunc = "add" + name; getFunc = "get" + name; if (key === "month") { addFunc = addFunc + "s"; } else if (key === "year"){ getFunc = "getFullYear"; } if (key !== "day" && key !== "timezone" && key !== "timezoneOffset" && key !== "week" && key !== "hour") { this[addFunc](config[key] - this[getFunc]()); } else if ( key === "timezone"|| key === "timezoneOffset" || key === "week" || key === "hour") { this["set"+name](config[key]); } } } // day has to go last because you can't validate the day without first knowing the month if (config.day) { this.addDays(config.day - this.getDate()); } return this; }; /** * Moves the date to the first day of the month. * @return {Date} this */ $P.moveToFirstDayOfMonth = function () { return this.set({ day: 1 }); }; /** * Moves the date to the last day of the month. * @return {Date} this */ $P.moveToLastDayOfMonth = function () { return this.set({ day: $D.getDaysInMonth(this.getFullYear(), this.getMonth())}); }; /** * Converts the value of the current Date object to its equivalent string representation. * Format Specifiers * CUSTOM DATE AND TIME FORMAT STRINGS * Format Description Example * ------ --------------------------------------------------------------------------- ----------------------- * s The seconds of the minute between 0-59. "0" to "59" * ss The seconds of the minute with leading zero if required. "00" to "59" * * m The minute of the hour between 0-59. "0" or "59" * mm The minute of the hour with leading zero if required. "00" or "59" * * h The hour of the day between 1-12. "1" to "12" * hh The hour of the day with leading zero if required. "01" to "12" * * H The hour of the day between 0-23. "0" to "23" * HH The hour of the day with leading zero if required. "00" to "23" * * d The day of the month between 1 and 31. "1" to "31" * dd The day of the month with leading zero if required. "01" to "31" * ddd Abbreviated day name. Date.CultureInfo.abbreviatedDayNames. "Mon" to "Sun" * dddd The full day name. Date.CultureInfo.dayNames. "Monday" to "Sunday" * * M The month of the year between 1-12. "1" to "12" * MM The month of the year with leading zero if required. "01" to "12" * MMM Abbreviated month name. Date.CultureInfo.abbreviatedMonthNames. "Jan" to "Dec" * MMMM The full month name. Date.CultureInfo.monthNames. "January" to "December" * * yy The year as a two-digit number. "99" or "08" * yyyy The full four digit year. "1999" or "2008" * * t Displays the first character of the A.M./P.M. designator. "A" or "P" * Date.CultureInfo.amDesignator or Date.CultureInfo.pmDesignator * tt Displays the A.M./P.M. designator. "AM" or "PM" * Date.CultureInfo.amDesignator or Date.CultureInfo.pmDesignator * * S The ordinal suffix ("st, "nd", "rd" or "th") of the current day. "st, "nd", "rd" or "th" * * STANDARD DATE AND TIME FORMAT STRINGS * Format Description Example *------ --------------------------------------------------------------------------- ----------------------- * d The CultureInfo shortDate Format Pattern "M/d/yyyy" * D The CultureInfo longDate Format Pattern "dddd, MMMM dd, yyyy" * F The CultureInfo fullDateTime Format Pattern "dddd, MMMM dd, yyyy h:mm:ss tt" * m The CultureInfo monthDay Format Pattern "MMMM dd" * r The CultureInfo rfc1123 Format Pattern "ddd, dd MMM yyyy HH:mm:ss GMT" * s The CultureInfo sortableDateTime Format Pattern "yyyy-MM-ddTHH:mm:ss" * t The CultureInfo shortTime Format Pattern "h:mm tt" * T The CultureInfo longTime Format Pattern "h:mm:ss tt" * u The CultureInfo universalSortableDateTime Format Pattern "yyyy-MM-dd HH:mm:ssZ" * y The CultureInfo yearMonth Format Pattern "MMMM, yyyy" * * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @return {String} A string representation of the current Date object. */ var ord = function (n) { switch (n * 1) { case 1: case 21: case 31: return "st"; case 2: case 22: return "nd"; case 3: case 23: return "rd"; default: return "th"; } }; var parseStandardFormats = function (format) { var y, c = Date.CultureInfo.formatPatterns; switch (format) { case "d": return this.toString(c.shortDate); case "D": return this.toString(c.longDate); case "F": return this.toString(c.fullDateTime); case "m": return this.toString(c.monthDay); case "r": case "R": y = this.clone().addMinutes(this.getTimezoneOffset()); return y.toString(c.rfc1123) + " GMT"; case "s": return this.toString(c.sortableDateTime); case "t": return this.toString(c.shortTime); case "T": return this.toString(c.longTime); case "u": y = this.clone().addMinutes(this.getTimezoneOffset()); return y.toString(c.universalSortableDateTime); case "y": return this.toString(c.yearMonth); default: return false; } }; var parseFormatStringsClosure = function (context) { return function (m) { if (m.charAt(0) === "\\") { return m.replace("\\", ""); } switch (m) { case "hh": return p(context.getHours() < 13 ? (context.getHours() === 0 ? 12 : context.getHours()) : (context.getHours() - 12)); case "h": return context.getHours() < 13 ? (context.getHours() === 0 ? 12 : context.getHours()) : (context.getHours() - 12); case "HH": return p(context.getHours()); case "H": return context.getHours(); case "mm": return p(context.getMinutes()); case "m": return context.getMinutes(); case "ss": return p(context.getSeconds()); case "s": return context.getSeconds(); case "yyyy": return p(context.getFullYear(), 4); case "yy": return p(context.getFullYear()); case "y": return context.getFullYear(); case "E": case "dddd": return Date.CultureInfo.dayNames[context.getDay()]; case "ddd": return Date.CultureInfo.abbreviatedDayNames[context.getDay()]; case "dd": return p(context.getDate()); case "d": return context.getDate(); case "MMMM": return Date.CultureInfo.monthNames[context.getMonth()]; case "MMM": return Date.CultureInfo.abbreviatedMonthNames[context.getMonth()]; case "MM": return p((context.getMonth() + 1)); case "M": return context.getMonth() + 1; case "t": return context.getHours() < 12 ? Date.CultureInfo.amDesignator.substring(0, 1) : Date.CultureInfo.pmDesignator.substring(0, 1); case "tt": return context.getHours() < 12 ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator; case "S": return ord(context.getDate()); case "W": return context.getWeek(); case "WW": return context.getISOWeek(); case "Q": return "Q" + context.getQuarter(); case "q": return String(context.getQuarter()); case "z": return context.getTimezone(); case "Z": case "X": return Date.getTimezoneOffset(context.getTimezone()); case "ZZ": // Timezone offset in seconds return context.getTimezoneOffset() * -60; case "u": return context.getDay(); case "L": return ($D.isLeapYear(context.getFullYear())) ? 1 : 0; case "B": // Swatch Internet Time (.beats) return "@"+((context.getUTCSeconds() + (context.getUTCMinutes()*60) + ((context.getUTCHours()+1)*3600))/86.4); default: return m; } }; }; $P.toString = function (format, ignoreStandards) { // Standard Date and Time Format Strings. Formats pulled from CultureInfo file and // may vary by culture. if (!ignoreStandards && format && format.length === 1) { output = parseStandardFormats.call(this, format); if (output) { return output; } } var parseFormatStrings = parseFormatStringsClosure(this); return format ? format.replace(/((\\)?(dd?d?d?|MM?M?M?|yy?y?y?|hh?|HH?|mm?|ss?|tt?|S|q|Q|WW?W?W?)(?![^\[]*\]))/g, parseFormatStrings).replace(/\[|\]/g, "") : this._toString(); }; }()); /************************************************************* * SugarPak - Domain Specific Language - Syntactical Sugar * *************************************************************/ (function () { var $D = Date, $P = $D.prototype, $N = Number.prototype; // private $P._orient = +1; // private $P._nth = null; // private $P._is = false; // private $P._same = false; // private $P._isSecond = false; // private $N._dateElement = "days"; /** * Moves the date to the next instance of a date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.today().next().friday();
	Date.today().next().fri();
	Date.today().next().march();
	Date.today().next().mar();
	Date.today().next().week();
	
* * @return {Date} date */ $P.next = function () { this._move = true; this._orient = +1; return this; }; /** * Creates a new Date (Date.today()) and moves the date to the next instance of the date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.next().friday();
	Date.next().fri();
	Date.next().march();
	Date.next().mar();
	Date.next().week();
	
* * @return {Date} date */ $D.next = function () { return $D.today().next(); }; /** * Moves the date to the previous instance of a date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.today().last().friday();
	Date.today().last().fri();
	Date.today().last().march();
	Date.today().last().mar();
	Date.today().last().week();
	
* * @return {Date} date */ $P.last = $P.prev = $P.previous = function () { this._move = true; this._orient = -1; return this; }; /** * Creates a new Date (Date.today()) and moves the date to the previous instance of the date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.last().friday();
	Date.last().fri();
	Date.previous().march();
	Date.prev().mar();
	Date.last().week();
	
* * @return {Date} date */ $D.last = $D.prev = $D.previous = function () { return $D.today().last(); }; /** * Performs a equality check when followed by either a month name, day name or .weekday() function. * Example

	Date.today().is().friday(); // true|false
	Date.today().is().fri();
	Date.today().is().march();
	Date.today().is().mar();
	
* * @return {Boolean} true|false */ $P.is = function () { this._is = true; return this; }; /** * Determines if two date objects occur on/in exactly the same instance of the subsequent date part function. * The function .same() must be followed by a date part function (example: .day(), .month(), .year(), etc). * * An optional Date can be passed in the date part function. If now date is passed as a parameter, 'Now' is used. * * The following example demonstrates how to determine if two dates fall on the exact same day. * * Example

	var d1 = Date.today(); // today at 00:00
	var d2 = new Date();   // exactly now.

	// Do they occur on the same day?
	d1.same().day(d2); // true
	
	// Do they occur on the same hour?
	d1.same().hour(d2); // false, unless d2 hour is '00' (midnight).
	
	// What if it's the same day, but one year apart?
	var nextYear = Date.today().add(1).year();

	d1.same().day(nextYear); // false, because the dates must occur on the exact same day. 
	
* * Scenario: Determine if a given date occurs during some week period 2 months from now. * * Example

	var future = Date.today().add(2).months();
	return someDate.same().week(future); // true|false;
	
* * @return {Boolean} true|false */ $P.same = function () { this._same = true; this._isSecond = false; return this; }; /** * Determines if the current date/time occurs during Today. Must be preceded by the .is() function. * Example

	someDate.is().today();    // true|false
	new Date().is().today();  // true
	Date.today().is().today();// true
	Date.today().add(-1).day().is().today(); // false
	
* * @return {Boolean} true|false */ $P.today = function () { return this.same().day(); }; /** * Determines if the current date is a weekday. This function must be preceded by the .is() function. * Example

	Date.today().is().weekday(); // true|false
	
* * @return {Boolean} true|false */ $P.weekday = function () { if (this._nth) { return df("Weekday").call(this); } if (this._move) { return this.addWeekdays(this._orient); } if (this._is) { this._is = false; return (!this.is().sat() && !this.is().sun()); } return false; }; /** * Determines if the current date is on the weekend. This function must be preceded by the .is() function. * Example

	Date.today().is().weekend(); // true|false
	
* * @return {Boolean} true|false */ $P.weekend = function () { if (this._is) { this._is = false; return (this.is().sat() || this.is().sun()); } return false; }; /** * Sets the Time of the current Date instance. A string "6:15 pm" or config object {hour:18, minute:15} are accepted. * Example

	// Set time to 6:15pm with a String
	Date.today().at("6:15pm");

	// Set time to 6:15pm with a config object
	Date.today().at({hour:18, minute:15});
	
* * @return {Date} date */ $P.at = function (time) { return (typeof time === "string") ? $D.parse(this.toString("d") + " " + time) : this.set(time); }; /** * Creates a new Date() and adds this (Number) to the date based on the preceding date element function (eg. second|minute|hour|day|month|year). * Example

	// Undeclared Numbers must be wrapped with parentheses. Requirment of JavaScript.
	(3).days().fromNow();
	(6).months().fromNow();

	// Declared Number variables do not require parentheses. 
	var n = 6;
	n.months().fromNow();
	
* * @return {Date} A new Date instance */ $N.fromNow = $N.after = function (date) { var c = {}; c[this._dateElement] = this; return ((!date) ? new Date() : date.clone()).add(c); }; /** * Creates a new Date() and subtract this (Number) from the date based on the preceding date element function (eg. second|minute|hour|day|month|year). * Example

	// Undeclared Numbers must be wrapped with parentheses. Requirment of JavaScript.
	(3).days().ago();
	(6).months().ago();

	// Declared Number variables do not require parentheses. 
	var n = 6;
	n.months().ago();
	
* * @return {Date} A new Date instance */ $N.ago = $N.before = function (date) { var c = {}, s = (this._dateElement[this._dateElement.length-1] !== "s") ? this._dateElement + "s" : this._dateElement; c[s] = this * -1; return ((!date) ? new Date() : date.clone()).add(c); }; // Do NOT modify the following string tokens. These tokens are used to build dynamic functions. // All culture-specific strings can be found in the CultureInfo files. var dx = ("sunday monday tuesday wednesday thursday friday saturday").split(/\s/), mx = ("january february march april may june july august september october november december").split(/\s/), px = ("Millisecond Second Minute Hour Day Week Month Year Quarter Weekday").split(/\s/), pxf = ("Milliseconds Seconds Minutes Hours Date Week Month FullYear Quarter").split(/\s/), nth = ("final first second third fourth fifth").split(/\s/), de; /** * Returns an object literal of all the date parts. * Example

	var o = new Date().toObject();
	
	// { year: 2008, month: 4, week: 20, day: 13, hour: 18, minute: 9, second: 32, millisecond: 812 }
	
	// The object properties can be referenced directly from the object.
	
	alert(o.day);  // alerts "13"
	alert(o.year); // alerts "2008"
	
* * @return {Date} An object literal representing the original date object. */ $P.toObject = function () { var o = {}; for (var i = 0; i < px.length; i++) { if (this["get" + pxf[i]]) { o[px[i].toLowerCase()] = this["get" + pxf[i]](); } } return o; }; /** * Returns a date created from an object literal. Ignores the .week property if set in the config. * Example

	var o = new Date().toObject();
	
	return Date.fromObject(o); // will return the same date. 

	var o2 = {month: 1, day: 20, hour: 18}; // birthday party!
	Date.fromObject(o2);
	
* * @return {Date} An object literal representing the original date object. */ $D.fromObject = function(config) { config.week = null; return Date.today().set(config); }; // Create day name functions and abbreviated day name functions (eg. monday(), friday(), fri()). var df = function (n) { return function () { if (this._is) { this._is = false; return this.getDay() === n; } if (this._move) { this._move = null; } if (this._nth !== null) { // If the .second() function was called earlier, remove the _orient // from the date, and then continue. // This is required because 'second' can be used in two different context. // // Example // // Date.today().add(1).second(); // Date.march().second().monday(); // // Things get crazy with the following... // Date.march().add(1).second().second().monday(); // but it works!! // if (this._isSecond) { this.addSeconds(this._orient * -1); } // make sure we reset _isSecond this._isSecond = false; var ntemp = this._nth; this._nth = null; var temp = this.clone().moveToLastDayOfMonth(); this.moveToNthOccurrence(n, ntemp); if (this > temp) { throw new RangeError($D.getDayName(n) + " does not occur " + ntemp + " times in the month of " + $D.getMonthName(temp.getMonth()) + " " + temp.getFullYear() + "."); } return this; } return this.moveToDayOfWeek(n, this._orient); }; }; var sdf = function (n) { return function () { var t = $D.today(), shift = n - t.getDay(); if (n === 0 && Date.CultureInfo.firstDayOfWeek === 1 && t.getDay() !== 0) { shift = shift + 7; } return t.addDays(shift); }; }; // Create month name functions and abbreviated month name functions (eg. january(), march(), mar()). var month_instance_functions = function (n) { return function () { if (this._is) { this._is = false; return this.getMonth() === n; } return this.moveToMonth(n, this._orient); }; }; var month_static_functions = function (n) { return function () { return $D.today().set({ month: n, day: 1 }); }; }; var processTerms = function (names, staticFunc, instanceFunc) { for (var i = 0; i < names.length; i++) { // Create constant static Name variables. $D[names[i].toUpperCase()] = $D[names[i].toUpperCase().substring(0, 3)] = i; // Create Name functions. $D[names[i]] = $D[names[i].substring(0, 3)] = staticFunc(i); // Create Name instance functions. $P[names[i]] = $P[names[i].substring(0, 3)] = instanceFunc(i); } }; processTerms(dx, sdf, df); processTerms(mx, month_static_functions, month_instance_functions); // Create date element functions and plural date element functions used with Date (eg. day(), days(), months()). var ef = function (j) { return function () { // if the .second() function was called earlier, the _orient // has alread been added. Just return this and reset _isSecond. if (this._isSecond) { this._isSecond = false; return this; } if (this._same) { this._same = this._is = false; var o1 = this.toObject(), o2 = (arguments[0] || new Date()).toObject(), v = "", k = j.toLowerCase(); // the substr trick with -1 doesn't work in IE8 or less k = (k[k.length-1] === "s") ? k.substring(0,k.length-1) : k; for (var m = (px.length - 1); m > -1; m--) { v = px[m].toLowerCase(); if (o1[v] !== o2[v]) { return false; } if (k === v) { break; } } return true; } if (j.substring(j.length - 1) !== "s") { j += "s"; } if (this._move) { this._move = null; } return this["add" + j](this._orient); }; }; var nf = function (n) { return function () { this._dateElement = n; return this; }; }; for (var k = 0; k < px.length; k++) { de = px[k].toLowerCase(); if(de !== "weekday") { // Create date element functions and plural date element functions used with Date (eg. day(), days(), months()). $P[de] = $P[de + "s"] = ef(px[k]); // Create date element functions and plural date element functions used with Number (eg. day(), days(), months()). $N[de] = $N[de + "s"] = nf(de + "s"); } } $P._ss = ef("Second"); var nthfn = function (n) { return function (dayOfWeek) { if (this._same) { return this._ss(arguments[0]); } if (dayOfWeek || dayOfWeek === 0) { return this.moveToNthOccurrence(dayOfWeek, n); } this._nth = n; // if the operator is 'second' add the _orient, then deal with it later... if (n === 2 && (dayOfWeek === undefined || dayOfWeek === null)) { this._isSecond = true; return this.addSeconds(this._orient); } return this; }; }; for (var l = 0; l < nth.length; l++) { $P[nth[l]] = (l === 0) ? nthfn(-1) : nthfn(l); } }()); (function () { "use strict"; Date.Parsing = { Exception: function (s) { this.message = "Parse error at '" + s.substring(0, 10) + " ...'"; } }; var $P = Date.Parsing; var dayOffsets = { standard: [0,31,59,90,120,151,181,212,243,273,304,334], leap: [0,31,60,91,121,152,182,213,244,274,305,335] }; $P.isLeapYear = function(year) { return ((year % 4 === 0) && (year % 100 !== 0)) || (year % 400 === 0); }; var utils = { multiReplace : function (str, hash ) { var key; for (key in hash) { if (Object.prototype.hasOwnProperty.call(hash, key)) { var regex; if (typeof hash[key] === "function") { } else { regex = (hash[key] instanceof RegExp) ? hash[key] : new RegExp(hash[key], "g"); } str = str.replace(regex, key); } } return str; }, getDayOfYearFromWeek : function (obj) { var d, jan4, offset; obj.weekDay = (!obj.weekDay && obj.weekDay !== 0) ? 1 : obj.weekDay; d = new Date(obj.year, 0, 4); jan4 = d.getDay() === 0 ? 7 : d.getDay(); // JS is 0 indexed on Sunday. offset = jan4+3; obj.dayOfYear = ((obj.week * 7) + (obj.weekDay === 0 ? 7 : obj.weekDay))-offset; return obj; }, getDayOfYear : function (obj, dayOffset) { if (!obj.dayOfYear) { obj = utils.getDayOfYearFromWeek(obj); } for (var i=0;i <= dayOffset.length;i++) { if (obj.dayOfYear < dayOffset[i] || i === dayOffset.length) { obj.day = obj.day ? obj.day : (obj.dayOfYear - dayOffset[i-1]); break; } else { obj.month = i; } } return obj; }, adjustForTimeZone : function (obj, date) { var offset; if (obj.zone.toUpperCase() === "Z" || (obj.zone_hours === 0 && obj.zone_minutes === 0)) { // it's UTC/GML so work out the current timeszone offset offset = -date.getTimezoneOffset(); } else { offset = (obj.zone_hours*60) + (obj.zone_minutes || 0); if (obj.zone_sign === "+") { offset *= -1; } offset -= date.getTimezoneOffset(); } date.setMinutes(date.getMinutes()+offset); return date; }, setDefaults : function (obj) { obj.year = obj.year || Date.today().getFullYear(); obj.hours = obj.hours || 0; obj.minutes = obj.minutes || 0; obj.seconds = obj.seconds || 0; obj.milliseconds = obj.milliseconds || 0; if (!(!obj.month && (obj.week || obj.dayOfYear))) { // if we have a month, or if we don't but don't have the day calculation data obj.month = obj.month || 0; obj.day = obj.day || 1; } return obj; }, dataNum: function (data, mod, explict, postProcess) { var dataNum = data*1; if (mod) { if (postProcess) { return data ? mod(data)*1 : data; } else { return data ? mod(dataNum) : data; } } else if (!explict){ return data ? dataNum : data; } else { return (data && typeof data !== "undefined") ? dataNum : data; } }, timeDataProcess: function (obj) { var timeObj = {}; for (var x in obj.data) { if (obj.data.hasOwnProperty(x)) { timeObj[x] = obj.ignore[x] ? obj.data[x] : utils.dataNum(obj.data[x], obj.mods[x], obj.explict[x], obj.postProcess[x]); } } if (obj.data.secmins) { obj.data.secmins = obj.data.secmins.replace(",", ".") * 60; if (!timeObj.minutes) { timeObj.minutes = obj.data.secmins; } else if (!timeObj.seconds) { timeObj.seconds = obj.data.secmins; } delete obj.secmins; } return timeObj; }, buildTimeObjectFromData: function (data) { var time = utils.timeDataProcess({ data: { year : data[1], month : data[5], day : data[7], week : data[8], dayOfYear : data[10], hours : data[15], zone_hours : data[23], zone_minutes : data[24], zone : data[21], zone_sign : data[22], weekDay : data[9], minutes: data[16], seconds: data[19], milliseconds: data[20], secmins: data[18] }, mods: { month: function(data) { return data-1; }, weekDay: function (data) { data = Math.abs(data); return (data === 7 ? 0 : data); }, minutes: function (data) { return data.replace(":",""); }, seconds: function (data) { return Math.floor( (data.replace(":","").replace(",","."))*1 ); }, milliseconds: function (data) { return (data.replace(",",".")*1000); } }, postProcess: { minutes: true, seconds: true, milliseconds: true }, explict: { zone_hours: true, zone_minutes: true }, ignore: { zone: true, zone_sign: true, secmins: true } }); return time; }, addToHash: function (hash, keys, data) { keys = keys; data = data; var len = keys.length; for (var i = 0; i < len; i++) { hash[keys[i]] = data[i]; } return hash; }, combineRegex: function (r1, r2) { return new RegExp("(("+r1.source+")\\s("+r2.source+"))"); }, getDateNthString: function(add, last, inc){ if (add) { return Date.today().addDays(inc).toString("d"); } else if (last) { return Date.today().last()[inc]().toString("d"); } }, buildRegexData: function (array) { var arr = []; var len = array.length; for (var i=0; i < len; i++) { if (Object.prototype.toString.call(array[i]) === '[object Array]') { // oldIE compat version of Array.isArray arr.push(this.combineRegex(array[i][0], array[i][1])); } else { arr.push(array[i]); } } return arr; } }; $P.processTimeObject = function (obj) { var date, dayOffset; utils.setDefaults(obj); dayOffset = ($P.isLeapYear(obj.year)) ? dayOffsets.leap : dayOffsets.standard; if (!obj.month && (obj.week || obj.dayOfYear)) { utils.getDayOfYear(obj, dayOffset); } else { obj.dayOfYear = dayOffset[obj.month] + obj.day; } date = new Date(obj.year, obj.month, obj.day, obj.hours, obj.minutes, obj.seconds, obj.milliseconds); if (obj.zone) { utils.adjustForTimeZone(obj, date); // adjust (and calculate) for timezone } return date; }; $P.ISO = { regex : /^([\+-]?\d{4}(?!\d{2}\b))((-?)((0[1-9]|1[0-2])(\3([12]\d|0[1-9]|3[01]))?|W([0-4]\d|5[0-3])(-?[1-7])?|(00[1-9]|0[1-9]\d|[12]\d{2}|3([0-5]\d|6[1-6])))([T\s]((([01]\d|2[0-4])((:?)[0-5]\d)?|24\:?00)([\.,]\d+(?!:))?)?(\17[0-5]\d([\.,]\d+)?)?\s?([zZ]|([\+-])([01]\d|2[0-3]):?([0-5]\d)?)?)?)?$/, parse : function (s) { var time, data = s.match(this.regex); if (!data || !data.length) { return null; } time = utils.buildTimeObjectFromData(data); if (!time.year || (!time.year && (!time.month && !time.day) && (!time.week && !time.dayOfYear)) ) { return null; } return $P.processTimeObject(time); } }; $P.Numeric = { isNumeric: function (e){return!isNaN(parseFloat(e))&&isFinite(e);}, regex: /\b([0-1]?[0-9])([0-3]?[0-9])([0-2]?[0-9]?[0-9][0-9])\b/i, parse: function (s) { var data, i, time = {}, order = Date.CultureInfo.dateElementOrder.split(""); if (!(this.isNumeric(s)) || // if it's non-numeric OR (s[0] === "+" && s[0] === "-")) { // It's an arithmatic string (eg +/-1000) return null; } if (s.length < 5 && s.indexOf(".") < 0 && s.indexOf("/") < 0) { // assume it's just a year. time.year = s; return $P.processTimeObject(time); } data = s.match(this.regex); if (!data || !data.length) { return null; } for (i=0; i < order.length; i++) { switch(order[i]) { case "d": time.day = data[i+1]; break; case "m": time.month = (data[i+1]-1); break; case "y": time.year = data[i+1]; break; } } return $P.processTimeObject(time); } }; $P.Normalizer = { regexData: function () { var $R = Date.CultureInfo.regexPatterns; return utils.buildRegexData([ $R.tomorrow, $R.yesterday, [$R.past, $R.mon], [$R.past, $R.tue], [$R.past, $R.wed], [$R.past, $R.thu], [$R.past, $R.fri], [$R.past, $R.sat], [$R.past, $R.sun] ]); }, basicReplaceHash : function() { var $R = Date.CultureInfo.regexPatterns; return { "January": $R.jan.source, "February": $R.feb, "March": $R.mar, "April": $R.apr, "May": $R.may, "June": $R.jun, "July": $R.jul, "August": $R.aug, "September": $R.sep, "October": $R.oct, "November": $R.nov, "December": $R.dec, "": /\bat\b/gi, " ": /\s{2,}/, "am": $R.inTheMorning, "9am": $R.thisMorning, "pm": $R.inTheEvening, "7pm":$R.thisEvening }; }, keys : function(){ return [ utils.getDateNthString(true, false, 1), // tomorrow utils.getDateNthString(true, false, -1), // yesterday utils.getDateNthString(false, true, "monday"), //last mon utils.getDateNthString(false, true, "tuesday"), //last tues utils.getDateNthString(false, true, "wednesday"), //last wed utils.getDateNthString(false, true, "thursday"), //last thurs utils.getDateNthString(false, true, "friday"), //last fri utils.getDateNthString(false, true, "saturday"), //last sat utils.getDateNthString(false, true, "sunday") //last sun ]; }, buildRegexFunctions: function () { var $R = Date.CultureInfo.regexPatterns; var __ = Date.i18n.__; var tomorrowRE = new RegExp("(\\b\\d\\d?("+__("AM")+"|"+__("PM")+")? )("+$R.tomorrow.source.slice(1)+")", "i"); // adapted tomorrow regex for AM PM relative dates var todayRE = new RegExp($R.today.source + "(?!\\s*([+-]))\\b"); // today, but excludes the math operators (eg "today + 2h") this.replaceFuncs = [ [todayRE, function (full) { return (full.length > 1) ? Date.today().toString("d") : full; }], [tomorrowRE, function(full, m1) { var t = Date.today().addDays(1).toString("d"); return (t + " " + m1); }], [$R.amThisMorning, function(str, am){return am;}], [$R.pmThisEvening, function(str, pm){return pm;}] ]; }, buildReplaceData: function () { this.buildRegexFunctions(); this.replaceHash = utils.addToHash(this.basicReplaceHash(), this.keys(), this.regexData()); }, stringReplaceFuncs: function (s) { for (var i=0; i < this.replaceFuncs.length; i++) { s = s.replace(this.replaceFuncs[i][0], this.replaceFuncs[i][1]); } return s; }, parse: function (s) { s = this.stringReplaceFuncs(s); s = utils.multiReplace(s, this.replaceHash); try { var n = s.split(/([\s\-\.\,\/\x27]+)/); if (n.length === 3 && $P.Numeric.isNumeric(n[0]) && $P.Numeric.isNumeric(n[2]) && (n[2].length >= 4)) { // ok, so we're dealing with x/year. But that's not a full date. // This fixes wonky dateElementOrder parsing when set to dmy order. if (Date.CultureInfo.dateElementOrder[0] === "d") { s = "1/" + n[0] + "/" + n[2]; // set to 1st of month and normalize the seperator } } } catch (e) {} return s; } }; $P.Normalizer.buildReplaceData(); }()); (function () { var $P = Date.Parsing; var _ = $P.Operators = { // // Tokenizers // rtoken: function (r) { // regex token return function (s) { var mx = s.match(r); if (mx) { return ([ mx[0], s.substring(mx[0].length) ]); } else { throw new $P.Exception(s); } }; }, token: function () { // whitespace-eating token return function (s) { return _.rtoken(new RegExp("^\\s*" + s + "\\s*"))(s); }; }, stoken: function (s) { // string token return _.rtoken(new RegExp("^" + s)); }, // Atomic Operators until: function (p) { return function (s) { var qx = [], rx = null; while (s.length) { try { rx = p.call(this, s); } catch (e) { qx.push(rx[0]); s = rx[1]; continue; } break; } return [ qx, s ]; }; }, many: function (p) { return function (s) { var rx = [], r = null; while (s.length) { try { r = p.call(this, s); } catch (e) { return [ rx, s ]; } rx.push(r[0]); s = r[1]; } return [ rx, s ]; }; }, // generator operators -- see below optional: function (p) { return function (s) { var r = null; try { r = p.call(this, s); } catch (e) { return [ null, s ]; } return [ r[0], r[1] ]; }; }, not: function (p) { return function (s) { try { p.call(this, s); } catch (e) { return [null, s]; } throw new $P.Exception(s); }; }, ignore: function (p) { return p ? function (s) { var r = null; r = p.call(this, s); return [null, r[1]]; } : null; }, product: function () { var px = arguments[0], qx = Array.prototype.slice.call(arguments, 1), rx = []; for (var i = 0 ; i < px.length ; i++) { rx.push(_.each(px[i], qx)); } return rx; }, cache: function (rule) { var cache = {}, cache_length = 0, cache_keys = [], CACHE_MAX = Date.Config.CACHE_MAX || 100000, r = null; var cacheCheck = function () { if (cache_length === CACHE_MAX) { // kill several keys, don't want to have to do this all the time... for (var i=0; i < 10; i++) { var key = cache_keys.shift(); if (key) { delete cache[key]; cache_length--; } } } }; return function (s) { cacheCheck(); try { r = cache[s] = (cache[s] || rule.call(this, s)); } catch (e) { r = cache[s] = e; } cache_length++; cache_keys.push(s); if (r instanceof $P.Exception) { throw r; } else { return r; } }; }, // vector operators -- see below any: function () { var px = arguments; return function (s) { var r = null; for (var i = 0; i < px.length; i++) { if (px[i] == null) { continue; } try { r = (px[i].call(this, s)); } catch (e) { r = null; } if (r) { return r; } } throw new $P.Exception(s); }; }, each: function () { var px = arguments; return function (s) { var rx = [], r = null; for (var i = 0; i < px.length ; i++) { if (px[i] == null) { continue; } try { r = (px[i].call(this, s)); } catch (e) { throw new $P.Exception(s); } rx.push(r[0]); s = r[1]; } return [ rx, s]; }; }, all: function () { var px = arguments, _ = _; return _.each(_.optional(px)); }, // delimited operators sequence: function (px, d, c) { d = d || _.rtoken(/^\s*/); c = c || null; if (px.length === 1) { return px[0]; } return function (s) { var r = null, q = null; var rx = []; for (var i = 0; i < px.length ; i++) { try { r = px[i].call(this, s); } catch (e) { break; } rx.push(r[0]); try { q = d.call(this, r[1]); } catch (ex) { q = null; break; } s = q[1]; } if (!r) { throw new $P.Exception(s); } if (q) { throw new $P.Exception(q[1]); } if (c) { try { r = c.call(this, r[1]); } catch (ey) { throw new $P.Exception(r[1]); } } return [ rx, (r?r[1]:s) ]; }; }, // // Composite Operators // between: function (d1, p, d2) { d2 = d2 || d1; var _fn = _.each(_.ignore(d1), p, _.ignore(d2)); return function (s) { var rx = _fn.call(this, s); return [[rx[0][0], r[0][2]], rx[1]]; }; }, list: function (p, d, c) { d = d || _.rtoken(/^\s*/); c = c || null; return (p instanceof Array ? _.each(_.product(p.slice(0, -1), _.ignore(d)), p.slice(-1), _.ignore(c)) : _.each(_.many(_.each(p, _.ignore(d))), px, _.ignore(c))); }, set: function (px, d, c) { d = d || _.rtoken(/^\s*/); c = c || null; return function (s) { // r is the current match, best the current 'best' match // which means it parsed the most amount of input var r = null, p = null, q = null, rx = null, best = [[], s], last = false; // go through the rules in the given set for (var i = 0; i < px.length ; i++) { // last is a flag indicating whether this must be the last element // if there is only 1 element, then it MUST be the last one q = null; p = null; r = null; last = (px.length === 1); // first, we try simply to match the current pattern // if not, try the next pattern try { r = px[i].call(this, s); } catch (e) { continue; } // since we are matching against a set of elements, the first // thing to do is to add r[0] to matched elements rx = [[r[0]], r[1]]; // if we matched and there is still input to parse and // we don't already know this is the last element, // we're going to next check for the delimiter ... // if there's none, or if there's no input left to parse // than this must be the last element after all ... if (r[1].length > 0 && ! last) { try { q = d.call(this, r[1]); } catch (ex) { last = true; } } else { last = true; } // if we parsed the delimiter and now there's no more input, // that means we shouldn't have parsed the delimiter at all // so don't update r and mark this as the last element ... if (!last && q[1].length === 0) { last = true; } // so, if this isn't the last element, we're going to see if // we can get any more matches from the remaining (unmatched) // elements ... if (!last) { // build a list of the remaining rules we can match against, // i.e., all but the one we just matched against var qx = []; for (var j = 0; j < px.length ; j++) { if (i !== j) { qx.push(px[j]); } } // now invoke recursively set with the remaining input // note that we don't include the closing delimiter ... // we'll check for that ourselves at the end p = _.set(qx, d).call(this, q[1]); // if we got a non-empty set as a result ... // (otw rx already contains everything we want to match) if (p[0].length > 0) { // update current result, which is stored in rx ... // basically, pick up the remaining text from p[1] // and concat the result from p[0] so that we don't // get endless nesting ... rx[0] = rx[0].concat(p[0]); rx[1] = p[1]; } } // at this point, rx either contains the last matched element // or the entire matched set that starts with this element. // now we just check to see if this variation is better than // our best so far, in terms of how much of the input is parsed if (rx[1].length < best[1].length) { best = rx; } // if we've parsed all the input, then we're finished if (best[1].length === 0) { break; } } // so now we've either gone through all the patterns trying them // as the initial match; or we found one that parsed the entire // input string ... // if best has no matches, just return empty set ... if (best[0].length === 0) { return best; } // if a closing delimiter is provided, then we have to check it also if (c) { // we try this even if there is no remaining input because the pattern // may well be optional or match empty input ... try { q = c.call(this, best[1]); } catch (ey) { throw new $P.Exception(best[1]); } // it parsed ... be sure to update the best match remaining input best[1] = q[1]; } // if we're here, either there was no closing delimiter or we parsed it // so now we have the best match; just return it! return best; }; }, forward: function (gr, fname) { return function (s) { return gr[fname].call(this, s); }; }, // // Translation Operators // replace: function (rule, repl) { return function (s) { var r = rule.call(this, s); return [repl, r[1]]; }; }, process: function (rule, fn) { return function (s) { var r = rule.call(this, s); return [fn.call(this, r[0]), r[1]]; }; }, min: function (min, rule) { return function (s) { var rx = rule.call(this, s); if (rx[0].length < min) { throw new $P.Exception(s); } return rx; }; } }; // Generator Operators And Vector Operators // Generators are operators that have a signature of F(R) => R, // taking a given rule and returning another rule, such as // ignore, which parses a given rule and throws away the result. // Vector operators are those that have a signature of F(R1,R2,...) => R, // take a list of rules and returning a new rule, such as each. // Generator operators are converted (via the following _generator // function) into functions that can also take a list or array of rules // and return an array of new rules as though the function had been // called on each rule in turn (which is what actually happens). // This allows generators to be used with vector operators more easily. // Example: // each(ignore(foo, bar)) instead of each(ignore(foo), ignore(bar)) // This also turns generators into vector operators, which allows // constructs like: // not(cache(foo, bar)) var _generator = function (op) { function gen() { var args = null, rx = [], px, i; if (arguments.length > 1) { args = Array.prototype.slice.call(arguments); } else if (arguments[0] instanceof Array) { args = arguments[0]; } if (args) { px = args.shift(); if (px.length > 0) { args.unshift(px[i]); rx.push(op.apply(null, args)); args.shift(); return rx; } } else { return op.apply(null, arguments); } } return gen; }; var gx = "optional not ignore cache".split(/\s/); for (var i = 0 ; i < gx.length ; i++) { _[gx[i]] = _generator(_[gx[i]]); } var _vector = function (op) { return function () { if (arguments[0] instanceof Array) { return op.apply(null, arguments[0]); } else { return op.apply(null, arguments); } }; }; var vx = "each any all".split(/\s/); for (var j = 0 ; j < vx.length ; j++) { _[vx[j]] = _vector(_[vx[j]]); } }()); (function () { var $D = Date; var flattenAndCompact = function (ax) { var rx = []; for (var i = 0; i < ax.length; i++) { if (ax[i] instanceof Array) { rx = rx.concat(flattenAndCompact(ax[i])); } else { if (ax[i]) { rx.push(ax[i]); } } } return rx; }; var parseMeridian = function () { if (this.meridian && (this.hour || this.hour === 0)) { if (this.meridian === "a" && this.hour > 11 && Date.Config.strict24hr){ throw "Invalid hour and meridian combination"; } else if (this.meridian === "p" && this.hour < 12 && Date.Config.strict24hr){ throw "Invalid hour and meridian combination"; } else if (this.meridian === "p" && this.hour < 12) { this.hour = this.hour + 12; } else if (this.meridian === "a" && this.hour === 12) { this.hour = 0; } } }; var setDefaults = function () { var now = new Date(); if ((this.hour || this.minute) && (!this.month && !this.year && !this.day)) { this.day = now.getDate(); } if (!this.year) { this.year = now.getFullYear(); } if (!this.month && this.month !== 0) { this.month = now.getMonth(); } if (!this.day) { this.day = 1; } if (!this.hour) { this.hour = 0; } if (!this.minute) { this.minute = 0; } if (!this.second) { this.second = 0; } if (!this.millisecond) { this.millisecond = 0; } }; var finishUtils = { getToday: function () { if (this.now || "hour minute second".indexOf(this.unit) !== -1) { return new Date(); } else { return $D.today(); } }, setDaysFromWeekday: function (today, orient){ var gap; orient = orient || 1; this.unit = "day"; gap = ($D.getDayNumberFromName(this.weekday) - today.getDay()); this.days = gap ? ((gap + (orient * 7)) % 7) : (orient * 7); return this; }, setMonthsFromMonth: function (today, orient) { var gap; orient = orient || 1; this.unit = "month"; gap = (this.month - today.getMonth()); this.months = gap ? ((gap + (orient * 12)) % 12) : (orient * 12); this.month = null; return this; }, setDMYFromWeekday: function () { var d = Date[this.weekday](); this.day = d.getDate(); if (!this.month) { this.month = d.getMonth(); } this.year = d.getFullYear(); return this; }, setUnitValue: function (orient) { if (!this.value && this.operator && this.operator !== null && this[this.unit + "s"] && this[this.unit + "s"] !== null) { this[this.unit + "s"] = this[this.unit + "s"] + ((this.operator === "add") ? 1 : -1) + (this.value||0) * orient; } else if (this[this.unit + "s"] == null || this.operator != null) { if (!this.value) { this.value = 1; } this[this.unit + "s"] = this.value * orient; } }, generateDateFromWeeks: function () { var weekday = (this.weekday !== undefined) ? this.weekday : "today"; var d = Date[weekday]().addWeeks(this.weeks); if (this.now) { d.setTimeToNow(); } return d; } }; $D.Translator = { hour: function (s) { return function () { this.hour = Number(s); }; }, minute: function (s) { return function () { this.minute = Number(s); }; }, second: function (s) { return function () { this.second = Number(s); }; }, /* for ss.s format */ secondAndMillisecond: function (s) { return function () { var mx = s.match(/^([0-5][0-9])\.([0-9]{1,3})/); this.second = Number(mx[1]); this.millisecond = Number(mx[2]); }; }, meridian: function (s) { return function () { this.meridian = s.slice(0, 1).toLowerCase(); }; }, timezone: function (s) { return function () { var n = s.replace(/[^\d\+\-]/g, ""); if (n.length) { this.timezoneOffset = Number(n); } else { this.timezone = s.toLowerCase(); } }; }, day: function (x) { var s = x[0]; return function () { this.day = Number(s.match(/\d+/)[0]); if (this.day < 1) { throw "invalid day"; } }; }, month: function (s) { return function () { this.month = (s.length === 3) ? "jan feb mar apr may jun jul aug sep oct nov dec".indexOf(s)/4 : Number(s) - 1; if (this.month < 0) { throw "invalid month"; } }; }, year: function (s) { return function () { var n = Number(s); this.year = ((s.length > 2) ? n : (n + (((n + 2000) < Date.CultureInfo.twoDigitYearMax) ? 2000 : 1900))); }; }, rday: function (s) { return function () { switch (s) { case "yesterday": this.days = -1; break; case "tomorrow": this.days = 1; break; case "today": this.days = 0; break; case "now": this.days = 0; this.now = true; break; } }; }, finishExact: function (x) { var d; x = (x instanceof Array) ? x : [x]; for (var i = 0 ; i < x.length ; i++) { if (x[i]) { x[i].call(this); } } setDefaults.call(this); parseMeridian.call(this); if (this.day > $D.getDaysInMonth(this.year, this.month)) { throw new RangeError(this.day + " is not a valid value for days."); } d = new Date(this.year, this.month, this.day, this.hour, this.minute, this.second, this.millisecond); if (this.year < 100) { d.setFullYear(this.year); // means years less that 100 are process correctly. JS will parse it otherwise as 1900-1999. } if (this.timezone) { d.set({ timezone: this.timezone }); } else if (this.timezoneOffset) { d.set({ timezoneOffset: this.timezoneOffset }); } return d; }, finish: function (x) { var today, expression, orient, temp; x = (x instanceof Array) ? flattenAndCompact(x) : [ x ]; if (x.length === 0) { return null; } for (var i = 0 ; i < x.length ; i++) { if (typeof x[i] === "function") { x[i].call(this); } } if (this.now && !this.unit && !this.operator) { return new Date(); } else { today = finishUtils.getToday.call(this); } expression = !!(this.days && this.days !== null || this.orient || this.operator); orient = ((this.orient === "past" || this.operator === "subtract") ? -1 : 1); if (this.month && this.unit === "week") { this.value = this.month + 1; delete this.month; delete this.day; } if ((this.month || this.month === 0) && "year day hour minute second".indexOf(this.unit) !== -1) { if (!this.value) { this.value = this.month + 1; } this.month = null; expression = true; } if (!expression && this.weekday && !this.day && !this.days) { finishUtils.setDMYFromWeekday.call(this); } if (expression && this.weekday && this.unit !== "month" && this.unit !== "week") { finishUtils.setDaysFromWeekday.call(this, today, orient); } if (this.weekday && this.unit !== "week" && !this.day && !this.days) { temp = Date[this.weekday](); this.day = temp.getDate(); if (temp.getMonth() !== today.getMonth()) { this.month = temp.getMonth(); } } if (this.month && this.unit === "day" && this.operator) { if (!this.value) { this.value = (this.month + 1); } this.month = null; } if (this.value != null && this.month != null && this.year != null) { this.day = this.value * 1; } if (this.month && !this.day && this.value) { today.set({ day: this.value * 1 }); if (!expression) { this.day = this.value * 1; } } if (!this.month && this.value && this.unit === "month" && !this.now) { this.month = this.value; expression = true; } if (expression && (this.month || this.month === 0) && this.unit !== "year") { finishUtils.setMonthsFromMonth.call(this, today, orient); } if (!this.unit) { this.unit = "day"; } finishUtils.setUnitValue.call(this, orient); parseMeridian.call(this); if ((this.month || this.month === 0) && !this.day) { this.day = 1; } if (!this.orient && !this.operator && this.unit === "week" && this.value && !this.day && !this.month) { return Date.today().setWeek(this.value); } if (this.unit === "week" && this.weeks && !this.day && !this.month) { return finishUtils.generateDateFromWeeks.call(this); } if (expression && this.timezone && this.day && this.days) { this.day = this.days; } if (expression){ today.add(this); } else { today.set(this); } if (this.timezone) { this.timezone = this.timezone.toUpperCase(); var offset = $D.getTimezoneOffset(this.timezone); var timezone; if (today.hasDaylightSavingTime()) { // lets check that we're being sane with timezone setting timezone = $D.getTimezoneAbbreviation(offset, today.isDaylightSavingTime()); if (timezone !== this.timezone) { // bugger, we're in a place where things like EST vs EDT matters. if (today.isDaylightSavingTime()) { today.addHours(-1); } else { today.addHours(1); } } } today.setTimezoneOffset(offset); } return today; } }; }()); (function () { var $D = Date; $D.Grammar = {}; var _ = $D.Parsing.Operators, g = $D.Grammar, t = $D.Translator, _fn; // Allow rolling up into general purpose rules _fn = function () { return _.each(_.any.apply(null, arguments), _.not(g.ctoken2("timeContext"))); }; g.datePartDelimiter = _.rtoken(/^([\s\-\.\,\/\x27]+)/); g.timePartDelimiter = _.stoken(":"); g.whiteSpace = _.rtoken(/^\s*/); g.generalDelimiter = _.rtoken(/^(([\s\,]|at|@|on)+)/); var _C = {}; g.ctoken = function (keys) { var fn = _C[keys]; if (! fn) { var c = Date.CultureInfo.regexPatterns; var kx = keys.split(/\s+/), px = []; for (var i = 0; i < kx.length ; i++) { px.push(_.replace(_.rtoken(c[kx[i]]), kx[i])); } fn = _C[keys] = _.any.apply(null, px); } return fn; }; g.ctoken2 = function (key) { return _.rtoken(Date.CultureInfo.regexPatterns[key]); }; var cacheProcessRtoken = function (key, token, type, eachToken) { if (eachToken) { g[key] = _.cache(_.process(_.each(_.rtoken(token),_.optional(g.ctoken2(eachToken))), type)); } else { g[key] = _.cache(_.process(_.rtoken(token), type)); } }; var cacheProcessCtoken = function (token, type) { return _.cache(_.process(g.ctoken2(token), type)); }; var _F = {}; //function cache var _get = function (f) { _F[f] = (_F[f] || g.format(f)[0]); return _F[f]; }; g.allformats = function (fx) { var rx = []; if (fx instanceof Array) { for (var i = 0; i < fx.length; i++) { rx.push(_get(fx[i])); } } else { rx.push(_get(fx)); } return rx; }; g.formats = function (fx) { if (fx instanceof Array) { var rx = []; for (var i = 0 ; i < fx.length ; i++) { rx.push(_get(fx[i])); } return _.any.apply(null, rx); } else { return _get(fx); } }; var grammarFormats = { timeFormats: function(){ var i, RTokenKeys = [ "h", "hh", "H", "HH", "m", "mm", "s", "ss", "ss.s", "z", "zz" ], RToken = [ /^(0[0-9]|1[0-2]|[1-9])/, /^(0[0-9]|1[0-2])/, /^([0-1][0-9]|2[0-3]|[0-9])/, /^([0-1][0-9]|2[0-3])/, /^([0-5][0-9]|[0-9])/, /^[0-5][0-9]/, /^([0-5][0-9]|[0-9])/, /^[0-5][0-9]/, /^[0-5][0-9]\.[0-9]{1,3}/, /^((\+|\-)\s*\d\d\d\d)|((\+|\-)\d\d\:?\d\d)/, /^((\+|\-)\s*\d\d\d\d)|((\+|\-)\d\d\:?\d\d)/ ], tokens = [ t.hour, t.hour, t.hour, t.hour, t.minute, t.minute, t.second, t.second, t.secondAndMillisecond, t.timezone, t.timezone ]; for (i=0; i < RTokenKeys.length; i++) { cacheProcessRtoken(RTokenKeys[i], RToken[i], tokens[i]); } g.hms = _.cache(_.sequence([g.H, g.m, g.s], g.timePartDelimiter)); g.t = cacheProcessCtoken("shortMeridian", t.meridian); g.tt = cacheProcessCtoken("longMeridian", t.meridian); g.zzz = cacheProcessCtoken("timezone", t.timezone); g.timeSuffix = _.each(_.ignore(g.whiteSpace), _.set([ g.tt, g.zzz ])); g.time = _.each(_.optional(_.ignore(_.stoken("T"))), g.hms, g.timeSuffix); }, dateFormats: function () { // pre-loaded rules for different date part order preferences var _setfn = function () { return _.set(arguments, g.datePartDelimiter); }; var i, RTokenKeys = [ "d", "dd", "M", "MM", "y", "yy", "yyy", "yyyy" ], RToken = [ /^([0-2]\d|3[0-1]|\d)/, /^([0-2]\d|3[0-1])/, /^(1[0-2]|0\d|\d)/, /^(1[0-2]|0\d)/, /^(\d+)/, /^(\d\d)/, /^(\d\d?\d?\d?)/, /^(\d\d\d\d)/ ], tokens = [ t.day, t.day, t.month, t.month, t.year, t.year, t.year, t.year ], eachToken = [ "ordinalSuffix", "ordinalSuffix" ]; for (i=0; i < RTokenKeys.length; i++) { cacheProcessRtoken(RTokenKeys[i], RToken[i], tokens[i], eachToken[i]); } g.MMM = g.MMMM = _.cache(_.process(g.ctoken("jan feb mar apr may jun jul aug sep oct nov dec"), t.month)); g.ddd = g.dddd = _.cache(_.process(g.ctoken("sun mon tue wed thu fri sat"), function (s) { return function () { this.weekday = s; }; } )); g.day = _fn(g.d, g.dd); g.month = _fn(g.M, g.MMM); g.year = _fn(g.yyyy, g.yy); g.mdy = _setfn(g.ddd, g.month, g.day, g.year); g.ymd = _setfn(g.ddd, g.year, g.month, g.day); g.dmy = _setfn(g.ddd, g.day, g.month, g.year); g.date = function (s) { return ((g[Date.CultureInfo.dateElementOrder] || g.mdy).call(this, s)); }; }, relative: function () { // relative date / time expressions g.orientation = _.process(g.ctoken("past future"), function (s) { return function () { this.orient = s; }; } ); g.operator = _.process(g.ctoken("add subtract"), function (s) { return function () { this.operator = s; }; } ); g.rday = _.process(g.ctoken("yesterday tomorrow today now"), t.rday); g.unit = _.process(g.ctoken("second minute hour day week month year"), function (s) { return function () { this.unit = s; }; } ); } }; g.buildGrammarFormats = function () { // these need to be rebuilt every time the language changes. _C = {}; grammarFormats.timeFormats(); grammarFormats.dateFormats(); grammarFormats.relative(); g.value = _.process(_.rtoken(/^([-+]?\d+)?(st|nd|rd|th)?/), function (s) { return function () { this.value = s.replace(/\D/g, ""); }; } ); g.expression = _.set([g.rday, g.operator, g.value, g.unit, g.orientation, g.ddd, g.MMM ]); g.format = _.process(_.many( _.any( // translate format specifiers into grammar rules _.process( _.rtoken(/^(dd?d?d?(?!e)|MM?M?M?|yy?y?y?|hh?|HH?|mm?|ss?|tt?|zz?z?)/), function (fmt) { if (g[fmt]) { return g[fmt]; } else { throw $D.Parsing.Exception(fmt); } } ), // translate separator tokens into token rules _.process(_.rtoken(/^[^dMyhHmstz]+/), // all legal separators function (s) { return _.ignore(_.stoken(s)); } ) ) ), // construct the parser ... function (rules) { return _.process(_.each.apply(null, rules), t.finishExact); } ); // starting rule for general purpose grammar g._start = _.process(_.set([ g.date, g.time, g.expression ], g.generalDelimiter, g.whiteSpace), t.finish); }; g.buildGrammarFormats(); // parsing date format specifiers - ex: "h:m:s tt" // this little guy will generate a custom parser based // on the format string, ex: g.format("h:m:s tt") // check for these formats first g._formats = g.formats([ "\"yyyy-MM-ddTHH:mm:ssZ\"", "yyyy-MM-ddTHH:mm:ss.sz", "yyyy-MM-ddTHH:mm:ssZ", "yyyy-MM-ddTHH:mm:ssz", "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-ddTHH:mmZ", "yyyy-MM-ddTHH:mmz", "yyyy-MM-ddTHH:mm", "ddd, MMM dd, yyyy H:mm:ss tt", "ddd MMM d yyyy HH:mm:ss zzz", "MMddyyyy", "ddMMyyyy", "Mddyyyy", "ddMyyyy", "Mdyyyy", "dMyyyy", "yyyy", "Mdyy", "dMyy", "d" ]); // real starting rule: tries selected formats first, // then general purpose rule g.start = function (s) { try { var r = g._formats.call({}, s); if (r[1].length === 0) { return r; } } catch (e) {} return g._start.call({}, s); }; }()); (function () { var $D = Date; /** * @desc Converts the specified string value into its JavaScript Date equivalent using CultureInfo specific format information. * * Example

	///////////
	// Dates //
	///////////

	// 15-Oct-2004
	var d1 = Date.parse("10/15/2004");

	// 15-Oct-2004
	var d1 = Date.parse("15-Oct-2004");

	// 15-Oct-2004
	var d1 = Date.parse("2004.10.15");

	//Fri Oct 15, 2004
	var d1 = Date.parse("Fri Oct 15, 2004");

	///////////
	// Times //
	///////////

	// Today at 10 PM.
	var d1 = Date.parse("10 PM");

	// Today at 10:30 PM.
	var d1 = Date.parse("10:30 P.M.");

	// Today at 6 AM.
	var d1 = Date.parse("06am");

	/////////////////////
	// Dates and Times //
	/////////////////////

	// 8-July-2004 @ 10:30 PM
	var d1 = Date.parse("July 8th, 2004, 10:30 PM");

	// 1-July-2004 @ 10:30 PM
	var d1 = Date.parse("2004-07-01T22:30:00");

	////////////////////
	// Relative Dates //
	////////////////////

	// Returns today's date. The string "today" is culture specific.
	var d1 = Date.parse("today");

	// Returns yesterday's date. The string "yesterday" is culture specific.
	var d1 = Date.parse("yesterday");

	// Returns the date of the next thursday.
	var d1 = Date.parse("Next thursday");

	// Returns the date of the most previous monday.
	var d1 = Date.parse("last monday");

	// Returns today's day + one year.
	var d1 = Date.parse("next year");

	///////////////
	// Date Math //
	///////////////

	// Today + 2 days
	var d1 = Date.parse("t+2");

	// Today + 2 days
	var d1 = Date.parse("today + 2 days");

	// Today + 3 months
	var d1 = Date.parse("t+3m");

	// Today - 1 year
	var d1 = Date.parse("today - 1 year");

	// Today - 1 year
	var d1 = Date.parse("t-1y"); 


	/////////////////////////////
	// Partial Dates and Times //
	/////////////////////////////

	// July 15th of this year.
	var d1 = Date.parse("July 15");

	// 15th day of current day and year.
	var d1 = Date.parse("15");

	// July 1st of current year at 10pm.
	var d1 = Date.parse("7/1 10pm");
	
* * @param {String} The string value to convert into a Date object [Required] * @return {Date} A Date object or null if the string cannot be converted into a Date. */ var parseUtils = { removeOrds: function (s) { ords = s.match(/\b(\d+)(?:st|nd|rd|th)\b/); // find ordinal matches s = ((ords && ords.length === 2) ? s.replace(ords[0], ords[1]) : s); return s; }, grammarParser: function (s) { var r = null; try { r = $D.Grammar.start.call({}, s.replace(/^\s*(\S*(\s+\S+)*)\s*$/, "$1")); } catch (e) { return null; } return ((r[1].length === 0) ? r[0] : null); }, nativeFallback: function(s) { var t; try { // ok we haven't parsed it, last ditch attempt with the built-in parser. t = Date._parse(s); return (t || t === 0) ? new Date(t) : null; } catch (e) { return null; } } }; function parse (s) { var d; if (!s) { return null; } if (s instanceof Date) { return s.clone(); } if (s.length >= 4 && s.charAt(0) !== "0" && s.charAt(0) !== "+"&& s.charAt(0) !== "-") { // ie: 2004 will pass, 0800 won't. // Start with specific formats d = $D.Parsing.ISO.parse(s) || $D.Parsing.Numeric.parse(s); } if (d instanceof Date && !isNaN(d.getTime())) { return d; } else { // find ordinal dates (1st, 3rd, 8th, etc and remove them as they cause parsing issues) s = $D.Parsing.Normalizer.parse(parseUtils.removeOrds(s)); d = parseUtils.grammarParser(s); if (d !== null) { return d; } else { return parseUtils.nativeFallback(s); } } } if (!$D._parse) { $D._parse = $D.parse; } $D.parse = parse; Date.getParseFunction = function (fx) { var fns = Date.Grammar.allformats(fx); return function (s) { var r = null; for (var i = 0; i < fns.length; i++) { try { r = fns[i].call({}, s); } catch (e) { continue; } if (r[1].length === 0) { return r[0]; } } return null; }; }; /** * Converts the specified string value into its JavaScript Date equivalent using the specified format {String} or formats {Array} and the CultureInfo specific format information. * The format of the string value must match one of the supplied formats exactly. * * Example

	// 15-Oct-2004
	var d1 = Date.parseExact("10/15/2004", "M/d/yyyy");

	// 15-Oct-2004
	var d1 = Date.parse("15-Oct-2004", "M-ddd-yyyy");

	// 15-Oct-2004
	var d1 = Date.parse("2004.10.15", "yyyy.MM.dd");

	// Multiple formats
	var d1 = Date.parseExact("10/15/2004", ["M/d/yyyy", "MMMM d, yyyy"]);
	
* * @param {String} The string value to convert into a Date object [Required]. * @param {Object} The expected format {String} or an array of expected formats {Array} of the date string [Required]. * @return {Date} A Date object or null if the string cannot be converted into a Date. */ $D.parseExact = function (s, fx) { return $D.getParseFunction(fx)(s); }; }()); (function () { var $D = Date, $P = $D.prototype, // $C = $D.CultureInfo, // not used atm p = function (s, l) { if (!l) { l = 2; } return ("000" + s).slice(l * -1); }; /** * Converts a PHP format string to Java/.NET format string. * A PHP format string can be used with ._format or .format. * A Java/.NET format string can be used with .toString(). * The .parseExact function will only accept a Java/.NET format string * * Example * var f1 = "%m/%d/%y" * var f2 = Date.normalizeFormat(f1); // "MM/dd/yy" * * new Date().format(f1); // "04/13/08" * new Date()._format(f1); // "04/13/08" * new Date().toString(f2); // "04/13/08" * * var date = Date.parseExact("04/13/08", f2); // Sun Apr 13 2008 * * @param {String} A PHP format string consisting of one or more format spcifiers. * @return {String} The PHP format converted to a Java/.NET format string. */ var normalizerSubstitutions = { "d" : "dd", "%d": "dd", "D" : "ddd", "%a": "ddd", "j" : "dddd", "l" : "dddd", "%A": "dddd", "S" : "S", "F" : "MMMM", "%B": "MMMM", "m" : "MM", "%m": "MM", "M" : "MMM", "%b": "MMM", "%h": "MMM", "n" : "M", "Y" : "yyyy", "%Y": "yyyy", "y" : "yy", "%y": "yy", "g" : "h", "%I": "h", "G" : "H", "h" : "hh", "H" : "HH", "%H": "HH", "i" : "mm", "%M": "mm", "s" : "ss", "%S": "ss", "%r": "hh:mm tt", "%R": "H:mm", "%T": "H:mm:ss", "%X": "t", "%x": "d", "%e": "d", "%D": "MM/dd/yy", "%n": "\\n", "%t": "\\t", "e" : "z", "T" : "z", "%z": "z", "%Z": "z", "Z" : "ZZ", "N" : "u", "w" : "u", "%w": "u", "W" : "W", "%V": "W" }; var normalizer = { substitutes: function (m) { return normalizerSubstitutions[m]; }, interpreted: function (m, x) { var y; switch (m) { case "%u": return x.getDay() + 1; case "z": return x.getOrdinalNumber(); case "%j": return p(x.getOrdinalNumber(), 3); case "%U": var d1 = x.clone().set({month: 0, day: 1}).addDays(-1).moveToDayOfWeek(0), d2 = x.clone().addDays(1).moveToDayOfWeek(0, -1); return (d2 < d1) ? "00" : p((d2.getOrdinalNumber() - d1.getOrdinalNumber()) / 7 + 1); case "%W": return p(x.getWeek()); case "t": return $D.getDaysInMonth(x.getFullYear(), x.getMonth()); case "o": case "%G": return x.setWeek(x.getISOWeek()).toString("yyyy"); case "%g": return x._format("%G").slice(-2); case "a": case "%p": return t("tt").toLowerCase(); case "A": return t("tt").toUpperCase(); case "u": return p(x.getMilliseconds(), 3); case "I": return (x.isDaylightSavingTime()) ? 1 : 0; case "O": return x.getUTCOffset(); case "P": y = x.getUTCOffset(); return y.substring(0, y.length - 2) + ":" + y.substring(y.length - 2); case "B": var now = new Date(); return Math.floor(((now.getHours() * 3600) + (now.getMinutes() * 60) + now.getSeconds() + (now.getTimezoneOffset() + 60) * 60) / 86.4); case "c": return x.toISOString().replace(/\"/g, ""); case "U": return $D.strtotime("now"); case "%c": return t("d") + " " + t("t"); case "%C": return Math.floor(x.getFullYear() / 100 + 1); } }, shouldOverrideDefaults: function (m) { switch (m) { case "%e": return true; default: return false; } }, parse: function (m, context) { var formatString, c = context || new Date(); formatString = normalizer.substitutes(m); if (formatString) { return formatString; } formatString = normalizer.interpreted(m, c); if (formatString) { return formatString; } else { return m; } } }; $D.normalizeFormat = function (format, context) { return format.replace(/(%|\\)?.|%%/g, function(t){ return normalizer.parse(t, context); }); }; /** * Format a local Unix timestamp according to locale settings * * Example: * Date.strftime("%m/%d/%y", new Date()); // "04/13/08" * Date.strftime("c", "2008-04-13T17:52:03Z"); // "04/13/08" * * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @param {Number|String} The number representing the number of seconds that have elapsed since January 1, 1970 (local time). * @return {String} A string representation of the current Date object. */ $D.strftime = function (format, time) { var d = Date.parse(time); return d._format(format); }; /** * Parse any textual datetime description into a Unix timestamp. * A Unix timestamp is the number of seconds that have elapsed since January 1, 1970 (midnight UTC/GMT). * * Example: * Date.strtotime("04/13/08"); // 1208044800 * Date.strtotime("1970-01-01T00:00:00Z"); // 0 * * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @param {Object} A string or date object. * @return {String} A string representation of the current Date object. */ $D.strtotime = function (time) { var d = $D.parse(time); return Math.round($D.UTC(d.getUTCFullYear(), d.getUTCMonth(), d.getUTCDate(), d.getUTCHours(), d.getUTCMinutes(), d.getUTCSeconds(), d.getUTCMilliseconds()) / 1000); }; /** * Converts the value of the current Date object to its equivalent string representation using a PHP/Unix style of date format specifiers. * Format Specifiers * Format Description Example * ------ --------------------------------------------------------------------------- ----------------------- * %a abbreviated weekday name according to the current localed "Mon" through "Sun" * %A full weekday name according to the current localed "Sunday" through "Saturday" * %b abbreviated month name according to the current localed "Jan" through "Dec" * %B full month name according to the current locale "January" through "December" * %c preferred date and time representation for the current locale "4/13/2008 12:33 PM" * %C century number (the year divided by 100 and truncated to an integer) "00" to "99" * %d day of the month as a decimal number "01" to "31" * %D same as %m/%d/%y "04/13/08" * %e day of the month as a decimal number, a single digit is preceded by a space "1" to "31" * %g like %G, but without the century "08" * %G The 4-digit year corresponding to the ISO week number (see %V). "2008" * This has the same format and value as %Y, except that if the ISO week number * belongs to the previous or next year, that year is used instead. * %h same as %b "Jan" through "Dec" * %H hour as a decimal number using a 24-hour clock. "00" to "23" * %I hour as a decimal number using a 12-hour clock. "01" to "12" * %j day of the year as a decimal number. "001" to "366" * %m month as a decimal number. "01" to "12" * %M minute as a decimal number. "00" to "59" * %n newline character "\n" * %p either "am" or "pm" according to the given time value, or the "am" or "pm" * corresponding strings for the current locale. * %r time in a.m. and p.m. notation "8:44 PM" * %R time in 24 hour notation "20:44" * %S second as a decimal number "00" to "59" * %t tab character "\t" * %T current time, equal to %H:%M:%S "12:49:11" * %u weekday as a decimal number ["1", "7"], with "1" representing Monday "1" to "7" * %U week number of the current year as a decimal number, starting with the "0" to ("52" or "53") * first Sunday as the first day of the first week * %V The ISO 8601:1988 week number of the current year as a decimal number, "00" to ("52" or "53") * range 01 to 53, where week 1 is the first week that has at least 4 days * in the current year, and with Monday as the first day of the week. * (Use %G or %g for the year component that corresponds to the week number * for the specified timestamp.) * %W week number of the current year as a decimal number, starting with the "00" to ("52" or "53") * first Monday as the first day of the first week * %w day of the week as a decimal, Sunday being "0" "0" to "6" * %x preferred date representation for the current locale without the time "4/13/2008" * %X preferred time representation for the current locale without the date "12:53:05" * %y year as a decimal number without a century "00" "99" * %Y year as a decimal number including the century "2008" * %Z time zone or name or abbreviation "UTC", "EST", "PST" * %z same as %Z * %% a literal "%" characters "%" * d Day of the month, 2 digits with leading zeros "01" to "31" * D A textual representation of a day, three letters "Mon" through "Sun" * j Day of the month without leading zeros "1" to "31" * l A full textual representation of the day of the week (lowercase "L") "Sunday" through "Saturday" * N ISO-8601 numeric representation of the day of the week (added in PHP 5.1.0) "1" (for Monday) through "7" (for Sunday) * S English ordinal suffix for the day of the month, 2 characters "st", "nd", "rd" or "th". Works well with j * w Numeric representation of the day of the week "0" (for Sunday) through "6" (for Saturday) * z The day of the year (starting from "0") "0" through "365" * W ISO-8601 week number of year, weeks starting on Monday "00" to ("52" or "53") * F A full textual representation of a month, such as January or March "January" through "December" * m Numeric representation of a month, with leading zeros "01" through "12" * M A short textual representation of a month, three letters "Jan" through "Dec" * n Numeric representation of a month, without leading zeros "1" through "12" * t Number of days in the given month "28" through "31" * L Whether it's a leap year "1" if it is a leap year, "0" otherwise * o ISO-8601 year number. This has the same value as Y, except that if the "2008" * ISO week number (W) belongs to the previous or next year, that year * is used instead. * Y A full numeric representation of a year, 4 digits "2008" * y A two digit representation of a year "08" * a Lowercase Ante meridiem and Post meridiem "am" or "pm" * A Uppercase Ante meridiem and Post meridiem "AM" or "PM" * B Swatch Internet time "000" through "999" * g 12-hour format of an hour without leading zeros "1" through "12" * G 24-hour format of an hour without leading zeros "0" through "23" * h 12-hour format of an hour with leading zeros "01" through "12" * H 24-hour format of an hour with leading zeros "00" through "23" * i Minutes with leading zeros "00" to "59" * s Seconds, with leading zeros "00" through "59" * u Milliseconds "54321" * e Timezone identifier "UTC", "EST", "PST" * I Whether or not the date is in daylight saving time (uppercase i) "1" if Daylight Saving Time, "0" otherwise * O Difference to Greenwich time (GMT) in hours "+0200", "-0600" * P Difference to Greenwich time (GMT) with colon between hours and minutes "+02:00", "-06:00" * T Timezone abbreviation "UTC", "EST", "PST" * Z Timezone offset in seconds. The offset for timezones west of UTC is "-43200" through "50400" * always negative, and for those east of UTC is always positive. * c ISO 8601 date "2004-02-12T15:19:21+00:00" * r RFC 2822 formatted date "Thu, 21 Dec 2000 16:01:07 +0200" * U Seconds since the Unix Epoch (January 1 1970 00:00:00 GMT) "0" * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @return {String} A string representation of the current Date object. */ var formatReplace = function (context) { return function (m) { var formatString, override = false; if (m.charAt(0) === "\\" || m.substring(0, 2) === "%%") { return m.replace("\\", "").replace("%%", "%"); } override = normalizer.shouldOverrideDefaults(m); formatString = $D.normalizeFormat(m, context); if (formatString) { return context.toString(formatString, override); } }; }; $P._format = function (format) { var formatter = formatReplace(this); if (!format) { return this._toString(); } else { return format.replace(/(%|\\)?.|%%/g, formatter); } }; if (!$P.format) { $P.format = $P._format; } }()); (function () { "use strict"; var gFn = function (attr) { return function () { return this[attr]; }; }; var sFn = function (attr) { return function (val) { this[attr] = val; return this; }; }; var attrs = ["years", "months", "days", "hours", "minutes", "seconds", "milliseconds"]; var addSetFuncs = function (context, attrs) { for (var i = 0; i < attrs.length ; i++) { var $a = attrs[i], $b = $a.slice(0, 1).toUpperCase() + $a.slice(1); context.prototype[$a] = 0; context.prototype["get" + $b] = gFn($a); context.prototype["set" + $b] = sFn($a); } }; /** * new TimeSpan(milliseconds); * new TimeSpan(days, hours, minutes, seconds); * new TimeSpan(days, hours, minutes, seconds, milliseconds); */ var TimeSpan = function (days, hours, minutes, seconds, milliseconds) { if (arguments.length === 1 && typeof days === "number") { var orient = (days < 0) ? -1 : +1; var millsLeft = Math.abs(days); this.setDays(Math.floor(millsLeft / 86400000) * orient); millsLeft = millsLeft % 86400000; this.setHours(Math.floor(millsLeft / 3600000) * orient); millsLeft = millsLeft % 3600000; this.setMinutes(Math.floor(millsLeft / 60000) * orient); millsLeft = millsLeft % 60000; this.setSeconds(Math.floor(millsLeft / 1000) * orient); millsLeft = millsLeft % 1000; this.setMilliseconds(millsLeft * orient); } else { this.set(days, hours, minutes, seconds, milliseconds); } this.getTotalMilliseconds = function () { return (this.getDays() * 86400000) + (this.getHours() * 3600000) + (this.getMinutes() * 60000) + (this.getSeconds() * 1000); }; this.compareTo = function (time) { var t1 = new Date(1970, 1, 1, this.getHours(), this.getMinutes(), this.getSeconds()), t2; if (time === null) { t2 = new Date(1970, 1, 1, 0, 0, 0); } else { t2 = new Date(1970, 1, 1, time.getHours(), time.getMinutes(), time.getSeconds()); } return (t1 < t2) ? -1 : (t1 > t2) ? 1 : 0; }; this.equals = function (time) { return (this.compareTo(time) === 0); }; this.add = function (time) { return (time === null) ? this : this.addSeconds(time.getTotalMilliseconds() / 1000); }; this.subtract = function (time) { return (time === null) ? this : this.addSeconds(-time.getTotalMilliseconds() / 1000); }; this.addDays = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 86400000)); }; this.addHours = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 3600000)); }; this.addMinutes = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 60000)); }; this.addSeconds = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 1000)); }; this.addMilliseconds = function (n) { return new TimeSpan(this.getTotalMilliseconds() + n); }; this.get12HourHour = function () { return (this.getHours() > 12) ? this.getHours() - 12 : (this.getHours() === 0) ? 12 : this.getHours(); }; this.getDesignator = function () { return (this.getHours() < 12) ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator; }; this.toString = function (format) { this._toString = function () { if (this.getDays() !== null && this.getDays() > 0) { return this.getDays() + "." + this.getHours() + ":" + this.p(this.getMinutes()) + ":" + this.p(this.getSeconds()); } else { return this.getHours() + ":" + this.p(this.getMinutes()) + ":" + this.p(this.getSeconds()); } }; this.p = function (s) { return (s.toString().length < 2) ? "0" + s : s; }; var me = this; return format ? format.replace(/dd?|HH?|hh?|mm?|ss?|tt?/g, function (format) { switch (format) { case "d": return me.getDays(); case "dd": return me.p(me.getDays()); case "H": return me.getHours(); case "HH": return me.p(me.getHours()); case "h": return me.get12HourHour(); case "hh": return me.p(me.get12HourHour()); case "m": return me.getMinutes(); case "mm": return me.p(me.getMinutes()); case "s": return me.getSeconds(); case "ss": return me.p(me.getSeconds()); case "t": return ((me.getHours() < 12) ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator).substring(0, 1); case "tt": return (me.getHours() < 12) ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator; } } ) : this._toString(); }; return this; }; addSetFuncs(TimeSpan, attrs.slice(2)); TimeSpan.prototype.set = function (days, hours, minutes, seconds, milliseconds){ this.setDays(days || this.getDays()); this.setHours(hours || this.getHours()); this.setMinutes(minutes || this.getMinutes()); this.setSeconds(seconds || this.getSeconds()); this.setMilliseconds(milliseconds || this.getMilliseconds()); }; /** * Gets the time of day for this date instances. * @return {TimeSpan} TimeSpan */ Date.prototype.getTimeOfDay = function () { return new TimeSpan(0, this.getHours(), this.getMinutes(), this.getSeconds(), this.getMilliseconds()); }; Date.TimeSpan = TimeSpan; if (typeof window !== "undefined" ) { // keeping API compatible for v1.x window.TimeSpan = TimeSpan; } }()); (function () { "use strict"; var attrs = ["years", "months", "days", "hours", "minutes", "seconds", "milliseconds"]; var gFn = function (attr) { return function () { return this[attr]; }; }; var sFn = function (attr) { return function (val) { this[attr] = val; return this; }; }; var addSetFuncs = function (context, attrs) { for (var i = 0; i < attrs.length ; i++) { var $a = attrs[i], $b = $a.slice(0, 1).toUpperCase() + $a.slice(1); context.prototype[$a] = 0; context.prototype["get" + $b] = gFn($a); context.prototype["set" + $b] = sFn($a); } }; var setMonthsAndYears = function (orient, d1, d2, context) { function inc() { d1.addMonths(-orient); context.months++; if (context.months === 12) { context.years++; context.months = 0; } } if (orient === +1) { while (d1 > d2) { inc(); } } else { while (d1 < d2) { inc(); } } context.months--; context.months *= orient; context.years *= orient; }; var adjustForDST = function(orient, startDate, endDate) { var hasDSTMismatch = (false === (startDate.isDaylightSavingTime() === endDate.isDaylightSavingTime())); if (hasDSTMismatch && orient === 1) { startDate.addHours(-1); } else if (hasDSTMismatch) { startDate.addHours(1); } }; /** * TimePeriod(startDate, endDate); * TimePeriod(years, months, days, hours, minutes, seconds, milliseconds); */ var TimePeriod = function (years, months, days, hours, minutes, seconds, milliseconds) { if (arguments.length === 7) { this.set(years, months, days, hours, minutes, seconds, milliseconds); } else if (arguments.length === 2 && arguments[0] instanceof Date && arguments[1] instanceof Date) { var startDate = arguments[0].clone(); var endDate = arguments[1].clone(); var orient = (startDate > endDate) ? +1 : -1; this.dates = { start: arguments[0].clone(), end: arguments[1].clone() }; setMonthsAndYears(orient, startDate, endDate, this); adjustForDST(orient, startDate, endDate); // // TODO - adjust for DST var diff = endDate - startDate; if (diff !== 0) { var ts = new TimeSpan(diff); this.set(this.years, this.months, ts.getDays(), ts.getHours(), ts.getMinutes(), ts.getSeconds(), ts.getMilliseconds()); } } return this; }; // create all the set functions. addSetFuncs(TimePeriod, attrs); TimePeriod.prototype.set = function (years, months, days, hours, minutes, seconds, milliseconds){ this.setYears(years || this.getYears()); this.setMonths(months || this.getMonths()); this.setDays(days || this.getDays()); this.setHours(hours || this.getHours()); this.setMinutes(minutes || this.getMinutes()); this.setSeconds(seconds || this.getSeconds()); this.setMilliseconds(milliseconds || this.getMilliseconds()); }; Date.TimePeriod = TimePeriod; if (typeof window !== "undefined") { // keeping API compatible for v1.x window.TimePeriod = TimePeriod; } }()); ================================================ FILE: build/date-en-BZ.js ================================================ /** * @overview datejs * @version 1.0.0-rc3 * @author Gregory Wild-Smith * @copyright 2015 Gregory Wild-Smith * @license MIT * @homepage https://github.com/abritinthebay/datejs */ /* * DateJS Culture String File * Country Code: en-BZ * Name: English (Belize) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["en-BZ"] = { "name": "en-BZ", "englishName": "English (Belize)", "nativeName": "English (Belize)", "Sunday": "Sunday", "Monday": "Monday", "Tuesday": "Tuesday", "Wednesday": "Wednesday", "Thursday": "Thursday", "Friday": "Friday", "Saturday": "Saturday", "Sun": "Sun", "Mon": "Mon", "Tue": "Tue", "Wed": "Wed", "Thu": "Thu", "Fri": "Fri", "Sat": "Sat", "Su": "Su", "Mo": "Mo", "Tu": "Tu", "We": "We", "Th": "Th", "Fr": "Fr", "Sa": "Sa", "S_Sun_Initial": "S", "M_Mon_Initial": "M", "T_Tue_Initial": "T", "W_Wed_Initial": "W", "T_Thu_Initial": "T", "F_Fri_Initial": "F", "S_Sat_Initial": "S", "January": "January", "February": "February", "March": "March", "April": "April", "May": "May", "June": "June", "July": "July", "August": "August", "September": "September", "October": "October", "November": "November", "December": "December", "Jan_Abbr": "Jan", "Feb_Abbr": "Feb", "Mar_Abbr": "Mar", "Apr_Abbr": "Apr", "May_Abbr": "May", "Jun_Abbr": "Jun", "Jul_Abbr": "Jul", "Aug_Abbr": "Aug", "Sep_Abbr": "Sep", "Oct_Abbr": "Oct", "Nov_Abbr": "Nov", "Dec_Abbr": "Dec", "AM": "AM", "PM": "PM", "firstDayOfWeek": 0, "twoDigitYearMax": 2029, "mdy": "dmy", "M/d/yyyy": "dd/MM/yyyy", "dddd, MMMM dd, yyyy": "dddd, dd MMMM yyyy", "h:mm tt": "hh:mm tt", "h:mm:ss tt": "hh:mm:ss tt", "dddd, MMMM dd, yyyy h:mm:ss tt": "dddd, dd MMMM yyyy hh:mm:ss tt", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "dd MMMM", "MMMM, yyyy": "MMMM yyyy", "/jan(uary)?/": "jan(uary)?", "/feb(ruary)?/": "feb(ruary)?", "/mar(ch)?/": "mar(ch)?", "/apr(il)?/": "apr(il)?", "/may/": "may", "/jun(e)?/": "jun(e)?", "/jul(y)?/": "jul(y)?", "/aug(ust)?/": "aug(ust)?", "/sep(t(ember)?)?/": "sep(t(ember)?)?", "/oct(ober)?/": "oct(ober)?", "/nov(ember)?/": "nov(ember)?", "/dec(ember)?/": "dec(ember)?", "/^su(n(day)?)?/": "^su(n(day)?)?", "/^mo(n(day)?)?/": "^mo(n(day)?)?", "/^tu(e(s(day)?)?)?/": "^tu(e(s(day)?)?)?", "/^we(d(nesday)?)?/": "^we(d(nesday)?)?", "/^th(u(r(s(day)?)?)?)?/": "^th(u(r(s(day)?)?)?)?", "/^fr(i(day)?)?/": "^fr(i(day)?)?", "/^sa(t(urday)?)?/": "^sa(t(urday)?)?", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "en-BZ"; /** * @overview datejs * @version 1.0.0-rc3 * @author Gregory Wild-Smith * @copyright 2015 Gregory Wild-Smith * @license MIT * @homepage https://github.com/abritinthebay/datejs */(function () { var $D = Date; var lang = Date.CultureStrings ? Date.CultureStrings.lang : null; var loggedKeys = {}; // for debug purposes. var getText = { getFromKey: function (key, countryCode) { var output; if (Date.CultureStrings && Date.CultureStrings[countryCode] && Date.CultureStrings[countryCode][key]) { output = Date.CultureStrings[countryCode][key]; } else { output = getText.buildFromDefault(key); } if (key.charAt(0) === "/") { // Assume it's a regex output = getText.buildFromRegex(key, countryCode); } return output; }, getFromObjectValues: function (obj, countryCode) { var key, output = {}; for(key in obj) { if (obj.hasOwnProperty(key)) { output[key] = getText.getFromKey(obj[key], countryCode); } } return output; }, getFromObjectKeys: function (obj, countryCode) { var key, output = {}; for(key in obj) { if (obj.hasOwnProperty(key)) { output[getText.getFromKey(key, countryCode)] = obj[key]; } } return output; }, getFromArray: function (arr, countryCode) { var output = []; for (var i=0; i < arr.length; i++){ if (i in arr) { output[i] = getText.getFromKey(arr[i], countryCode); } } return output; }, buildFromDefault: function (key) { var output, length, split, last; switch(key) { case "name": output = "en-US"; break; case "englishName": output = "English (United States)"; break; case "nativeName": output = "English (United States)"; break; case "twoDigitYearMax": output = 2049; break; case "firstDayOfWeek": output = 0; break; default: output = key; split = key.split("_"); length = split.length; if (length > 1 && key.charAt(0) !== "/") { // if the key isn't a regex and it has a split. last = split[(length - 1)].toLowerCase(); if (last === "initial" || last === "abbr") { output = split[0]; } } break; } return output; }, buildFromRegex: function (key, countryCode) { var output; if (Date.CultureStrings && Date.CultureStrings[countryCode] && Date.CultureStrings[countryCode][key]) { output = new RegExp(Date.CultureStrings[countryCode][key], "i"); } else { output = new RegExp(key.replace(new RegExp("/", "g"),""), "i"); } return output; } }; var shallowMerge = function (obj1, obj2) { for (var attrname in obj2) { if (obj2.hasOwnProperty(attrname)) { obj1[attrname] = obj2[attrname]; } } }; var __ = function (key, language) { var countryCode = (language) ? language : lang; loggedKeys[key] = key; if (typeof key === "object") { if (key instanceof Array) { return getText.getFromArray(key, countryCode); } else { return getText.getFromObjectKeys(key, countryCode); } } else { return getText.getFromKey(key, countryCode); } }; var loadI18nScript = function (code) { // paatterned after jQuery's getScript. var url = Date.Config.i18n + code + ".js"; var head = document.getElementsByTagName("head")[0] || document.documentElement; var script = document.createElement("script"); script.src = url; var completed = false; var events = { done: function (){} // placeholder function }; // Attach handlers for all browsers script.onload = script.onreadystatechange = function() { if ( !completed && (!this.readyState || this.readyState === "loaded" || this.readyState === "complete") ) { events.done(); head.removeChild(script); } }; setTimeout(function() { head.insertBefore(script, head.firstChild); }, 0); // allows return to execute first return { done: function (cb) { events.done = function() { if (cb) { setTimeout(cb,0); } }; } }; }; var buildInfo = { buildFromMethodHash: function (obj) { var key; for(key in obj) { if (obj.hasOwnProperty(key)) { obj[key] = buildInfo[obj[key]](); } } return obj; }, timeZoneDST: function () { var DST = { "CHADT": "+1345", "NZDT": "+1300", "AEDT": "+1100", "ACDT": "+1030", "AZST": "+0500", "IRDT": "+0430", "EEST": "+0300", "CEST": "+0200", "BST": "+0100", "PMDT": "-0200", "ADT": "-0300", "NDT": "-0230", "EDT": "-0400", "CDT": "-0500", "MDT": "-0600", "PDT": "-0700", "AKDT": "-0800", "HADT": "-0900" }; return __(DST); }, timeZoneStandard: function () { var standard = { "LINT": "+1400", "TOT": "+1300", "CHAST": "+1245", "NZST": "+1200", "NFT": "+1130", "SBT": "+1100", "AEST": "+1000", "ACST": "+0930", "JST": "+0900", "CWST": "+0845", "CT": "+0800", "ICT": "+0700", "MMT": "+0630", "BST": "+0600", "NPT": "+0545", "IST": "+0530", "PKT": "+0500", "AFT": "+0430", "MSK": "+0400", "IRST": "+0330", "FET": "+0300", "EET": "+0200", "CET": "+0100", "GMT": "+0000", "UTC": "+0000", "CVT": "-0100", "GST": "-0200", "BRT": "-0300", "NST": "-0330", "AST": "-0400", "EST": "-0500", "CST": "-0600", "MST": "-0700", "PST": "-0800", "AKST": "-0900", "MIT": "-0930", "HST": "-1000", "SST": "-1100", "BIT": "-1200" }; return __(standard); }, timeZones: function (data) { var zone; data.timezones = []; for (zone in data.abbreviatedTimeZoneStandard) { if (data.abbreviatedTimeZoneStandard.hasOwnProperty(zone)) { data.timezones.push({ name: zone, offset: data.abbreviatedTimeZoneStandard[zone]}); } } for (zone in data.abbreviatedTimeZoneDST) { if (data.abbreviatedTimeZoneDST.hasOwnProperty(zone)) { data.timezones.push({ name: zone, offset: data.abbreviatedTimeZoneDST[zone], dst: true}); } } return data.timezones; }, days: function () { return __(["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"]); }, dayAbbr: function () { return __(["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"]); }, dayShortNames: function () { return __(["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"]); }, dayFirstLetters: function () { return __(["S_Sun_Initial", "M_Mon_Initial", "T_Tues_Initial", "W_Wed_Initial", "T_Thu_Initial", "F_Fri_Initial", "S_Sat_Initial"]); }, months: function () { return __(["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"]); }, monthAbbr: function () { return __(["Jan_Abbr", "Feb_Abbr", "Mar_Abbr", "Apr_Abbr", "May_Abbr", "Jun_Abbr", "Jul_Abbr", "Aug_Abbr", "Sep_Abbr", "Oct_Abbr", "Nov_Abbr", "Dec_Abbr"]); }, formatPatterns: function () { return getText.getFromObjectValues({ shortDate: "M/d/yyyy", longDate: "dddd, MMMM dd, yyyy", shortTime: "h:mm tt", longTime: "h:mm:ss tt", fullDateTime: "dddd, MMMM dd, yyyy h:mm:ss tt", sortableDateTime: "yyyy-MM-ddTHH:mm:ss", universalSortableDateTime: "yyyy-MM-dd HH:mm:ssZ", rfc1123: "ddd, dd MMM yyyy HH:mm:ss", monthDay: "MMMM dd", yearMonth: "MMMM, yyyy" }, Date.i18n.currentLanguage()); }, regex: function () { return getText.getFromObjectValues({ inTheMorning: "/( in the )(morn(ing)?)\\b/", thisMorning: "/(this )(morn(ing)?)\\b/", amThisMorning: "/(\b\\d(am)? )(this )(morn(ing)?)/", inTheEvening: "/( in the )(even(ing)?)\\b/", thisEvening: "/(this )(even(ing)?)\\b/", pmThisEvening: "/(\b\\d(pm)? )(this )(even(ing)?)/", jan: "/jan(uary)?/", feb: "/feb(ruary)?/", mar: "/mar(ch)?/", apr: "/apr(il)?/", may: "/may/", jun: "/jun(e)?/", jul: "/jul(y)?/", aug: "/aug(ust)?/", sep: "/sep(t(ember)?)?/", oct: "/oct(ober)?/", nov: "/nov(ember)?/", dec: "/dec(ember)?/", sun: "/^su(n(day)?)?/", mon: "/^mo(n(day)?)?/", tue: "/^tu(e(s(day)?)?)?/", wed: "/^we(d(nesday)?)?/", thu: "/^th(u(r(s(day)?)?)?)?/", fri: "/fr(i(day)?)?/", sat: "/^sa(t(urday)?)?/", future: "/^next/", past: "/^last|past|prev(ious)?/", add: "/^(\\+|aft(er)?|from|hence)/", subtract: "/^(\\-|bef(ore)?|ago)/", yesterday: "/^yes(terday)?/", today: "/^t(od(ay)?)?/", tomorrow: "/^tom(orrow)?/", now: "/^n(ow)?/", millisecond: "/^ms|milli(second)?s?/", second: "/^sec(ond)?s?/", minute: "/^mn|min(ute)?s?/", hour: "/^h(our)?s?/", week: "/^w(eek)?s?/", month: "/^m(onth)?s?/", day: "/^d(ay)?s?/", year: "/^y(ear)?s?/", shortMeridian: "/^(a|p)/", longMeridian: "/^(a\\.?m?\\.?|p\\.?m?\\.?)/", timezone: "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/", ordinalSuffix: "/^\\s*(st|nd|rd|th)/", timeContext: "/^\\s*(\\:|a(?!u|p)|p)/" }, Date.i18n.currentLanguage()); } }; var CultureInfo = function () { var info = getText.getFromObjectValues({ name: "name", englishName: "englishName", nativeName: "nativeName", amDesignator: "AM", pmDesignator: "PM", firstDayOfWeek: "firstDayOfWeek", twoDigitYearMax: "twoDigitYearMax", dateElementOrder: "mdy" }, Date.i18n.currentLanguage()); var constructedInfo = buildInfo.buildFromMethodHash({ dayNames: "days", abbreviatedDayNames: "dayAbbr", shortestDayNames: "dayShortNames", firstLetterDayNames: "dayFirstLetters", monthNames: "months", abbreviatedMonthNames: "monthAbbr", formatPatterns: "formatPatterns", regexPatterns: "regex", abbreviatedTimeZoneDST: "timeZoneDST", abbreviatedTimeZoneStandard: "timeZoneStandard" }); shallowMerge(info, constructedInfo); buildInfo.timeZones(info); return info; }; $D.i18n = { __: function (key, lang) { return __(key, lang); }, currentLanguage: function () { return lang || "en-US"; }, setLanguage: function (code, force, cb) { var async = false; if (force || code === "en-US" || (!!Date.CultureStrings && !!Date.CultureStrings[code])) { lang = code; Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings.lang = code; Date.CultureInfo = new CultureInfo(); } else { if (!(!!Date.CultureStrings && !!Date.CultureStrings[code])) { if (typeof exports !== "undefined" && this.exports !== exports) { // we're in a Node enviroment, load it using require try { require("../i18n/" + code + ".js"); lang = code; Date.CultureStrings.lang = code; Date.CultureInfo = new CultureInfo(); } catch (e) { // var str = "The language for '" + code + "' could not be loaded by Node. It likely does not exist."; throw new Error("The DateJS IETF language tag '" + code + "' could not be loaded by Node. It likely does not exist."); } } else if (Date.Config && Date.Config.i18n) { // we know the location of the files, so lets load them async = true; loadI18nScript(code).done(function(){ lang = code; Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings.lang = code; Date.CultureInfo = new CultureInfo(); $D.Parsing.Normalizer.buildReplaceData(); // because this is async if ($D.Grammar) { $D.Grammar.buildGrammarFormats(); // so we can parse those strings... } if (cb) { setTimeout(cb,0); } }); } else { Date.console.error("The DateJS IETF language tag '" + code + "' is not available and has not been loaded."); return false; } } } $D.Parsing.Normalizer.buildReplaceData(); // rebuild normalizer strings if ($D.Grammar) { $D.Grammar.buildGrammarFormats(); // so we can parse those strings... } if (!async && cb) { setTimeout(cb,0); } }, getLoggedKeys: function () { return loggedKeys; }, updateCultureInfo: function () { Date.CultureInfo = new CultureInfo(); } }; $D.i18n.updateCultureInfo(); // run automatically }()); (function () { var $D = Date, $P = $D.prototype, p = function (s, l) { if (!l) { l = 2; } return ("000" + s).slice(l * -1); }; if (typeof window !== "undefined" && typeof window.console !== "undefined" && typeof window.console.log !== "undefined") { $D.console = console; // used only to raise non-critical errors if available } else { // set mock so we don't give errors. $D.console = { log: function(){}, error: function(){} }; } $D.Config = $D.Config || {}; $D.initOverloads = function() { /** * Overload of Date.now. Allows an alternate call for Date.now where it returns the * current Date as an object rather than just milliseconds since the Unix Epoch. * * Also provides an implementation of now() for browsers (IE<9) that don't have it. * * Backwards compatible so with work with either: * Date.now() [returns ms] * or * Date.now(true) [returns Date] */ if (!$D.now) { $D._now = function now() { return new Date().getTime(); }; } else if (!$D._now) { $D._now = $D.now; } $D.now = function (returnObj) { if (returnObj) { return $D.present(); } else { return $D._now(); } }; if ( !$P.toISOString ) { $P.toISOString = function() { return this.getUTCFullYear() + "-" + p(this.getUTCMonth() + 1) + "-" + p(this.getUTCDate()) + "T" + p(this.getUTCHours()) + ":" + p(this.getUTCMinutes()) + ":" + p(this.getUTCSeconds()) + "." + String( (this.getUTCMilliseconds()/1000).toFixed(3)).slice(2, 5) + "Z"; }; } // private if ( $P._toString === undefined ){ $P._toString = $P.toString; } }; $D.initOverloads(); /** * Gets a date that is set to the current date. The time is set to the start of the day (00:00 or 12:00 AM). * @return {Date} The current date. */ $D.today = function () { return new Date().clearTime(); }; /** * Gets a date that is set to the current date and time (same as new Date, but chainable) * @return {Date} The current date. */ $D.present = function () { return new Date(); }; /** * Compares the first date to the second date and returns an number indication of their relative values. * @param {Date} First Date object to compare [Required]. * @param {Date} Second Date object to compare to [Required]. * @return {Number} -1 = date1 is lessthan date2. 0 = values are equal. 1 = date1 is greaterthan date2. */ $D.compare = function (date1, date2) { if (isNaN(date1) || isNaN(date2)) { throw new Error(date1 + " - " + date2); } else if (date1 instanceof Date && date2 instanceof Date) { return (date1 < date2) ? -1 : (date1 > date2) ? 1 : 0; } else { throw new TypeError(date1 + " - " + date2); } }; /** * Compares the first Date object to the second Date object and returns true if they are equal. * @param {Date} First Date object to compare [Required] * @param {Date} Second Date object to compare to [Required] * @return {Boolean} true if dates are equal. false if they are not equal. */ $D.equals = function (date1, date2) { return (date1.compareTo(date2) === 0); }; /** * Gets the language appropriate day name when given the day number(0-6) * eg - 0 == Sunday * @return {String} The day name */ $D.getDayName = function (n) { return Date.CultureInfo.dayNames[n]; }; /** * Gets the day number (0-6) if given a CultureInfo specific string which is a valid dayName, abbreviatedDayName or shortestDayName (two char). * @param {String} The name of the day (eg. "Monday, "Mon", "tuesday", "tue", "We", "we"). * @return {Number} The day number */ $D.getDayNumberFromName = function (name) { var n = Date.CultureInfo.dayNames, m = Date.CultureInfo.abbreviatedDayNames, o = Date.CultureInfo.shortestDayNames, s = name.toLowerCase(); for (var i = 0; i < n.length; i++) { if (n[i].toLowerCase() === s || m[i].toLowerCase() === s || o[i].toLowerCase() === s) { return i; } } return -1; }; /** * Gets the month number (0-11) if given a Culture Info specific string which is a valid monthName or abbreviatedMonthName. * @param {String} The name of the month (eg. "February, "Feb", "october", "oct"). * @return {Number} The day number */ $D.getMonthNumberFromName = function (name) { var n = Date.CultureInfo.monthNames, m = Date.CultureInfo.abbreviatedMonthNames, s = name.toLowerCase(); for (var i = 0; i < n.length; i++) { if (n[i].toLowerCase() === s || m[i].toLowerCase() === s) { return i; } } return -1; }; /** * Gets the language appropriate month name when given the month number(0-11) * eg - 0 == January * @return {String} The month name */ $D.getMonthName = function (n) { return Date.CultureInfo.monthNames[n]; }; /** * Determines if the current date instance is within a LeapYear. * @param {Number} The year. * @return {Boolean} true if date is within a LeapYear, otherwise false. */ $D.isLeapYear = function (year) { return ((year % 4 === 0 && year % 100 !== 0) || year % 400 === 0); }; /** * Gets the number of days in the month, given a year and month value. Automatically corrects for LeapYear. * @param {Number} The year. * @param {Number} The month (0-11). * @return {Number} The number of days in the month. */ $D.getDaysInMonth = function (year, month) { if (!month && $D.validateMonth(year)) { month = year; year = Date.today().getFullYear(); } return [31, ($D.isLeapYear(year) ? 29 : 28), 31, 30, 31, 30, 31, 31, 30, 31, 30, 31][month]; }; $P.getDaysInMonth = function () { return $D.getDaysInMonth(this.getFullYear(), this.getMonth()); }; $D.getTimezoneAbbreviation = function (offset, dst) { var p, n = (dst || false) ? Date.CultureInfo.abbreviatedTimeZoneDST : Date.CultureInfo.abbreviatedTimeZoneStandard; for (p in n) { if (n.hasOwnProperty(p)) { if (n[p] === offset) { return p; } } } return null; }; $D.getTimezoneOffset = function (name, dst) { var i, a =[], z = Date.CultureInfo.timezones; if (!name) { name = (new Date()).getTimezone();} for (i = 0; i < z.length; i++) { if (z[i].name === name.toUpperCase()) { a.push(i); } } if (!z[a[0]]) { return null; } if (a.length === 1 || !dst) { return z[a[0]].offset; } else { for (i=0; i < a.length; i++) { if (z[a[i]].dst) { return z[a[i]].offset; } } } }; $D.getQuarter = function (d) { d = d || new Date(); // If no date supplied, use today var q = [1,2,3,4]; return q[Math.floor(d.getMonth() / 3)]; // ~~~ is a bitwise op. Faster than Math.floor }; $D.getDaysLeftInQuarter = function (d) { d = d || new Date(); var qEnd = new Date(d); qEnd.setMonth(qEnd.getMonth() + 3 - qEnd.getMonth() % 3, 0); return Math.floor((qEnd - d) / 8.64e7); }; // private var validate = function (n, min, max, name) { name = name ? name : "Object"; if (typeof n === "undefined") { return false; } else if (typeof n !== "number") { throw new TypeError(n + " is not a Number."); } else if (n < min || n > max) { // As failing validation is *not* an exceptional circumstance // lets not throw a RangeError Exception here. // It's semantically correct but it's not sensible. return false; } return true; }; /** * Validates the number is within an acceptable range for milliseconds [0-999]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateMillisecond = function (value) { return validate(value, 0, 999, "millisecond"); }; /** * Validates the number is within an acceptable range for seconds [0-59]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateSecond = function (value) { return validate(value, 0, 59, "second"); }; /** * Validates the number is within an acceptable range for minutes [0-59]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateMinute = function (value) { return validate(value, 0, 59, "minute"); }; /** * Validates the number is within an acceptable range for hours [0-23]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateHour = function (value) { return validate(value, 0, 23, "hour"); }; /** * Validates the number is within an acceptable range for the days in a month [0-MaxDaysInMonth]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateDay = function (value, year, month) { if (year === undefined || year === null || month === undefined || month === null) { return false;} return validate(value, 1, $D.getDaysInMonth(year, month), "day"); }; /** * Validates the number is within an acceptable range for months [0-11]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateWeek = function (value) { return validate(value, 0, 53, "week"); }; /** * Validates the number is within an acceptable range for months [0-11]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateMonth = function (value) { return validate(value, 0, 11, "month"); }; /** * Validates the number is within an acceptable range for years. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateYear = function (value) { /** * Per ECMAScript spec the range of times supported by Date objects is * exactly -100,000,000 days to +100,000,000 days measured relative to * midnight at the beginning of 01 January, 1970 UTC. * This gives a range of 8,640,000,000,000,000 milliseconds to either * side of 01 January, 1970 UTC. * * Earliest possible date: Tue, 20 Apr 271,822 B.C. 00:00:00 UTC * Latest possible date: Sat, 13 Sep 275,760 00:00:00 UTC */ return validate(value, -271822, 275760, "year"); }; $D.validateTimezone = function(value) { var timezones = {"ACDT":1,"ACST":1,"ACT":1,"ADT":1,"AEDT":1,"AEST":1,"AFT":1,"AKDT":1,"AKST":1,"AMST":1,"AMT":1,"ART":1,"AST":1,"AWDT":1,"AWST":1,"AZOST":1,"AZT":1,"BDT":1,"BIOT":1,"BIT":1,"BOT":1,"BRT":1,"BST":1,"BTT":1,"CAT":1,"CCT":1,"CDT":1,"CEDT":1,"CEST":1,"CET":1,"CHADT":1,"CHAST":1,"CHOT":1,"ChST":1,"CHUT":1,"CIST":1,"CIT":1,"CKT":1,"CLST":1,"CLT":1,"COST":1,"COT":1,"CST":1,"CT":1,"CVT":1,"CWST":1,"CXT":1,"DAVT":1,"DDUT":1,"DFT":1,"EASST":1,"EAST":1,"EAT":1,"ECT":1,"EDT":1,"EEDT":1,"EEST":1,"EET":1,"EGST":1,"EGT":1,"EIT":1,"EST":1,"FET":1,"FJT":1,"FKST":1,"FKT":1,"FNT":1,"GALT":1,"GAMT":1,"GET":1,"GFT":1,"GILT":1,"GIT":1,"GMT":1,"GST":1,"GYT":1,"HADT":1,"HAEC":1,"HAST":1,"HKT":1,"HMT":1,"HOVT":1,"HST":1,"ICT":1,"IDT":1,"IOT":1,"IRDT":1,"IRKT":1,"IRST":1,"IST":1,"JST":1,"KGT":1,"KOST":1,"KRAT":1,"KST":1,"LHST":1,"LINT":1,"MAGT":1,"MART":1,"MAWT":1,"MDT":1,"MET":1,"MEST":1,"MHT":1,"MIST":1,"MIT":1,"MMT":1,"MSK":1,"MST":1,"MUT":1,"MVT":1,"MYT":1,"NCT":1,"NDT":1,"NFT":1,"NPT":1,"NST":1,"NT":1,"NUT":1,"NZDT":1,"NZST":1,"OMST":1,"ORAT":1,"PDT":1,"PET":1,"PETT":1,"PGT":1,"PHOT":1,"PHT":1,"PKT":1,"PMDT":1,"PMST":1,"PONT":1,"PST":1,"PYST":1,"PYT":1,"RET":1,"ROTT":1,"SAKT":1,"SAMT":1,"SAST":1,"SBT":1,"SCT":1,"SGT":1,"SLST":1,"SRT":1,"SST":1,"SYOT":1,"TAHT":1,"THA":1,"TFT":1,"TJT":1,"TKT":1,"TLT":1,"TMT":1,"TOT":1,"TVT":1,"UCT":1,"ULAT":1,"UTC":1,"UYST":1,"UYT":1,"UZT":1,"VET":1,"VLAT":1,"VOLT":1,"VOST":1,"VUT":1,"WAKT":1,"WAST":1,"WAT":1,"WEDT":1,"WEST":1,"WET":1,"WST":1,"YAKT":1,"YEKT":1,"Z":1}; return (timezones[value] === 1); }; $D.validateTimezoneOffset= function(value) { // timezones go from +14hrs to -12hrs, the +X hours are negative offsets. return (value > -841 && value < 721); }; }()); (function () { var $D = Date, $P = $D.prototype, p = function (s, l) { if (!l) { l = 2; } return ("000" + s).slice(l * -1); }; var validateConfigObject = function (obj) { var result = {}, self = this, prop, testFunc; testFunc = function (prop, func, value) { if (prop === "day") { var month = (obj.month !== undefined) ? obj.month : self.getMonth(); var year = (obj.year !== undefined) ? obj.year : self.getFullYear(); return $D[func](value, year, month); } else { return $D[func](value); } }; for (prop in obj) { if (Object.prototype.hasOwnProperty.call(obj, prop)) { var func = "validate" + prop.charAt(0).toUpperCase() + prop.slice(1); if ($D[func] && obj[prop] !== null && testFunc(prop, func, obj[prop])) { result[prop] = obj[prop]; } } } return result; }; /** * Resets the time of this Date object to 12:00 AM (00:00), which is the start of the day. * @param {Boolean} .clone() this date instance before clearing Time * @return {Date} this */ $P.clearTime = function () { this.setHours(0); this.setMinutes(0); this.setSeconds(0); this.setMilliseconds(0); return this; }; /** * Resets the time of this Date object to the current time ('now'). * @return {Date} this */ $P.setTimeToNow = function () { var n = new Date(); this.setHours(n.getHours()); this.setMinutes(n.getMinutes()); this.setSeconds(n.getSeconds()); this.setMilliseconds(n.getMilliseconds()); return this; }; /** * Returns a new Date object that is an exact date and time copy of the original instance. * @return {Date} A new Date instance */ $P.clone = function () { return new Date(this.getTime()); }; /** * Compares this instance to a Date object and returns an number indication of their relative values. * @param {Date} Date object to compare [Required] * @return {Number} -1 = this is lessthan date. 0 = values are equal. 1 = this is greaterthan date. */ $P.compareTo = function (date) { return Date.compare(this, date); }; /** * Compares this instance to another Date object and returns true if they are equal. * @param {Date} Date object to compare. If no date to compare, new Date() [now] is used. * @return {Boolean} true if dates are equal. false if they are not equal. */ $P.equals = function (date) { return Date.equals(this, (date !== undefined ? date : new Date())); }; /** * Determines if this instance is between a range of two dates or equal to either the start or end dates. * @param {Date} Start of range [Required] * @param {Date} End of range [Required] * @return {Boolean} true is this is between or equal to the start and end dates, else false */ $P.between = function (start, end) { return this.getTime() >= start.getTime() && this.getTime() <= end.getTime(); }; /** * Determines if this date occurs after the date to compare to. * @param {Date} Date object to compare. If no date to compare, new Date() ("now") is used. * @return {Boolean} true if this date instance is greater than the date to compare to (or "now"), otherwise false. */ $P.isAfter = function (date) { return this.compareTo(date || new Date()) === 1; }; /** * Determines if this date occurs before the date to compare to. * @param {Date} Date object to compare. If no date to compare, new Date() ("now") is used. * @return {Boolean} true if this date instance is less than the date to compare to (or "now"). */ $P.isBefore = function (date) { return (this.compareTo(date || new Date()) === -1); }; /** * Determines if the current Date instance occurs today. * @return {Boolean} true if this date instance is 'today', otherwise false. */ /** * Determines if the current Date instance occurs on the same Date as the supplied 'date'. * If no 'date' to compare to is provided, the current Date instance is compared to 'today'. * @param {date} Date object to compare. If no date to compare, the current Date ("now") is used. * @return {Boolean} true if this Date instance occurs on the same Day as the supplied 'date'. */ $P.isToday = $P.isSameDay = function (date) { return this.clone().clearTime().equals((date || new Date()).clone().clearTime()); }; /** * Adds the specified number of milliseconds to this instance. * @param {Number} The number of milliseconds to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addMilliseconds = function (value) { if (!value) { return this; } this.setTime(this.getTime() + value * 1); return this; }; /** * Adds the specified number of seconds to this instance. * @param {Number} The number of seconds to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addSeconds = function (value) { if (!value) { return this; } return this.addMilliseconds(value * 1000); }; /** * Adds the specified number of seconds to this instance. * @param {Number} The number of seconds to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addMinutes = function (value) { if (!value) { return this; } return this.addMilliseconds(value * 60000); // 60*1000 }; /** * Adds the specified number of hours to this instance. * @param {Number} The number of hours to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addHours = function (value) { if (!value) { return this; } return this.addMilliseconds(value * 3600000); // 60*60*1000 }; /** * Adds the specified number of days to this instance. * @param {Number} The number of days to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addDays = function (value) { if (!value) { return this; } this.setDate(this.getDate() + value * 1); return this; }; /** * Adds the specified number of weekdays (ie - not sat or sun) to this instance. * @param {Number} The number of days to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addWeekdays = function (value) { if (!value) { return this; } var day = this.getDay(); var weeks = (Math.ceil(Math.abs(value)/7)); if (day === 0 || day === 6) { if (value > 0) { this.next().monday(); this.addDays(-1); day = this.getDay(); } } if (value < 0) { while (value < 0) { this.addDays(-1); day = this.getDay(); if (day !== 0 && day !== 6) { value++; } } return this; } else if (value > 5 || (6-day) <= value) { value = value + (weeks * 2); } return this.addDays(value); }; /** * Adds the specified number of weeks to this instance. * @param {Number} The number of weeks to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addWeeks = function (value) { if (!value) { return this; } return this.addDays(value * 7); }; /** * Adds the specified number of months to this instance. * @param {Number} The number of months to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addMonths = function (value) { if (!value) { return this; } var n = this.getDate(); this.setDate(1); this.setMonth(this.getMonth() + value * 1); this.setDate(Math.min(n, $D.getDaysInMonth(this.getFullYear(), this.getMonth()))); return this; }; $P.addQuarters = function (value) { if (!value) { return this; } // note this will take you to the same point in the quarter as you are now. // i.e. - if you are 15 days into the quarter you'll be 15 days into the resulting one. // bonus: this allows adding fractional quarters return this.addMonths(value * 3); }; /** * Adds the specified number of years to this instance. * @param {Number} The number of years to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addYears = function (value) { if (!value) { return this; } return this.addMonths(value * 12); }; /** * Adds (or subtracts) to the value of the years, months, weeks, days, hours, minutes, seconds, milliseconds of the date instance using given configuration object. Positive and Negative values allowed. * Example

	Date.today().add( { days: 1, months: 1 } )

	new Date().add( { years: -1 } )
	
* @param {Object} Configuration object containing attributes (months, days, etc.) * @return {Date} this */ $P.add = function (config) { if (typeof config === "number") { this._orient = config; return this; } var x = config; if (x.day) { // If we should be a different date than today (eg: for 'tomorrow -1d', etc). // Should only effect parsing, not direct usage (eg, Finish and FinishExact) if ((x.day - this.getDate()) !== 0) { this.setDate(x.day); } } if (x.milliseconds) { this.addMilliseconds(x.milliseconds); } if (x.seconds) { this.addSeconds(x.seconds); } if (x.minutes) { this.addMinutes(x.minutes); } if (x.hours) { this.addHours(x.hours); } if (x.weeks) { this.addWeeks(x.weeks); } if (x.months) { this.addMonths(x.months); } if (x.years) { this.addYears(x.years); } if (x.days) { this.addDays(x.days); } return this; }; /** * Get the week number. Week one (1) is the week which contains the first Thursday of the year. Monday is considered the first day of the week. * The .getWeek() function does NOT convert the date to UTC. The local datetime is used. * Please use .getISOWeek() to get the week of the UTC converted date. * @return {Number} 1 to 53 */ $P.getWeek = function (utc) { // Create a copy of this date object var self, target = new Date(this.valueOf()); if (utc) { target.addMinutes(target.getTimezoneOffset()); self = target.clone(); } else { self = this; } // ISO week date weeks start on monday // so correct the day number var dayNr = (self.getDay() + 6) % 7; // ISO 8601 states that week 1 is the week // with the first thursday of that year. // Set the target date to the thursday in the target week target.setDate(target.getDate() - dayNr + 3); // Store the millisecond value of the target date var firstThursday = target.valueOf(); // Set the target to the first thursday of the year // First set the target to january first target.setMonth(0, 1); // Not a thursday? Correct the date to the next thursday if (target.getDay() !== 4) { target.setMonth(0, 1 + ((4 - target.getDay()) + 7) % 7); } // The weeknumber is the number of weeks between the // first thursday of the year and the thursday in the target week return 1 + Math.ceil((firstThursday - target) / 604800000); // 604800000 = 7 * 24 * 3600 * 1000 }; /** * Get the ISO 8601 week number. Week one ("01") is the week which contains the first Thursday of the year. Monday is considered the first day of the week. * The .getISOWeek() function does convert the date to it's UTC value. Please use .getWeek() to get the week of the local date. * @return {String} "01" to "53" */ $P.getISOWeek = function () { return p(this.getWeek(true)); }; /** * Moves the date to Monday of the week set. Week one (1) is the week which contains the first Thursday of the year. * @param {Number} A Number (1 to 53) that represents the week of the year. * @return {Date} this */ $P.setWeek = function (n) { if ((n - this.getWeek()) === 0) { if (this.getDay() !== 1) { return this.moveToDayOfWeek(1, (this.getDay() > 1 ? -1 : 1)); } else { return this; } } else { return this.moveToDayOfWeek(1, (this.getDay() > 1 ? -1 : 1)).addWeeks(n - this.getWeek()); } }; $P.setQuarter = function (qtr) { var month = Math.abs(((qtr-1) * 3) + 1); return this.setMonth(month, 1); }; $P.getQuarter = function () { return Date.getQuarter(this); }; $P.getDaysLeftInQuarter = function () { return Date.getDaysLeftInQuarter(this); }; /** * Moves the date to the next n'th occurrence of the dayOfWeek starting from the beginning of the month. The number (-1) is a magic number and will return the last occurrence of the dayOfWeek in the month. * @param {Number} The dayOfWeek to move to * @param {Number} The n'th occurrence to move to. Use (-1) to return the last occurrence in the month * @return {Date} this */ $P.moveToNthOccurrence = function (dayOfWeek, occurrence) { if (dayOfWeek === "Weekday") { if (occurrence > 0) { this.moveToFirstDayOfMonth(); if (this.is().weekday()) { occurrence -= 1; } } else if (occurrence < 0) { this.moveToLastDayOfMonth(); if (this.is().weekday()) { occurrence += 1; } } else { return this; } return this.addWeekdays(occurrence); } var shift = 0; if (occurrence > 0) { shift = occurrence - 1; } else if (occurrence === -1) { this.moveToLastDayOfMonth(); if (this.getDay() !== dayOfWeek) { this.moveToDayOfWeek(dayOfWeek, -1); } return this; } return this.moveToFirstDayOfMonth().addDays(-1).moveToDayOfWeek(dayOfWeek, +1).addWeeks(shift); }; var moveToN = function (getFunc, addFunc, nVal) { return function (value, orient) { var diff = (value - this[getFunc]() + nVal * (orient || +1)) % nVal; return this[addFunc]((diff === 0) ? diff += nVal * (orient || +1) : diff); }; }; /** * Move to the next or last dayOfWeek based on the orient value. * @param {Number} The dayOfWeek to move to * @param {Number} Forward (+1) or Back (-1). Defaults to +1. [Optional] * @return {Date} this */ $P.moveToDayOfWeek = moveToN("getDay", "addDays", 7); /** * Move to the next or last month based on the orient value. * @param {Number} The month to move to. 0 = January, 11 = December * @param {Number} Forward (+1) or Back (-1). Defaults to +1. [Optional] * @return {Date} this */ $P.moveToMonth = moveToN("getMonth", "addMonths", 12); /** * Get the Ordinate of the current day ("th", "st", "rd"). * @return {String} */ $P.getOrdinate = function () { var num = this.getDate(); return ord(num); }; /** * Get the Ordinal day (numeric day number) of the year, adjusted for leap year. * @return {Number} 1 through 365 (366 in leap years) */ $P.getOrdinalNumber = function () { return Math.ceil((this.clone().clearTime() - new Date(this.getFullYear(), 0, 1)) / 86400000) + 1; }; /** * Get the time zone abbreviation of the current date. * @return {String} The abbreviated time zone name (e.g. "EST") */ $P.getTimezone = function () { return $D.getTimezoneAbbreviation(this.getUTCOffset(), this.isDaylightSavingTime()); }; $P.setTimezoneOffset = function (offset) { var here = this.getTimezoneOffset(), there = Number(offset) * -6 / 10; return (there || there === 0) ? this.addMinutes(there - here) : this; }; $P.setTimezone = function (offset) { return this.setTimezoneOffset($D.getTimezoneOffset(offset)); }; /** * Indicates whether Daylight Saving Time is observed in the current time zone. * @return {Boolean} true|false */ $P.hasDaylightSavingTime = function () { return (Date.today().set({month: 0, day: 1}).getTimezoneOffset() !== Date.today().set({month: 6, day: 1}).getTimezoneOffset()); }; /** * Indicates whether this Date instance is within the Daylight Saving Time range for the current time zone. * @return {Boolean} true|false */ $P.isDaylightSavingTime = function () { return Date.today().set({month: 0, day: 1}).getTimezoneOffset() !== this.getTimezoneOffset(); }; /** * Get the offset from UTC of the current date. * @return {String} The 4-character offset string prefixed with + or - (e.g. "-0500") */ $P.getUTCOffset = function (offset) { var n = (offset || this.getTimezoneOffset()) * -10 / 6, r; if (n < 0) { r = (n - 10000).toString(); return r.charAt(0) + r.substr(2); } else { r = (n + 10000).toString(); return "+" + r.substr(1); } }; /** * Returns the number of milliseconds between this date and date. * @param {Date} Defaults to now * @return {Number} The diff in milliseconds */ $P.getElapsed = function (date) { return (date || new Date()) - this; }; /** * Set the value of year, month, day, hour, minute, second, millisecond of date instance using given configuration object. * Example

	Date.today().set( { day: 20, month: 1 } )

	new Date().set( { millisecond: 0 } )
	
* * @param {Object} Configuration object containing attributes (month, day, etc.) * @return {Date} this */ $P.set = function (config) { config = validateConfigObject.call(this, config); var key; for (key in config) { if (Object.prototype.hasOwnProperty.call(config, key)) { var name = key.charAt(0).toUpperCase() + key.slice(1); var addFunc, getFunc; if (key !== "week" && key !== "month" && key !== "timezone" && key !== "timezoneOffset") { name += "s"; } addFunc = "add" + name; getFunc = "get" + name; if (key === "month") { addFunc = addFunc + "s"; } else if (key === "year"){ getFunc = "getFullYear"; } if (key !== "day" && key !== "timezone" && key !== "timezoneOffset" && key !== "week" && key !== "hour") { this[addFunc](config[key] - this[getFunc]()); } else if ( key === "timezone"|| key === "timezoneOffset" || key === "week" || key === "hour") { this["set"+name](config[key]); } } } // day has to go last because you can't validate the day without first knowing the month if (config.day) { this.addDays(config.day - this.getDate()); } return this; }; /** * Moves the date to the first day of the month. * @return {Date} this */ $P.moveToFirstDayOfMonth = function () { return this.set({ day: 1 }); }; /** * Moves the date to the last day of the month. * @return {Date} this */ $P.moveToLastDayOfMonth = function () { return this.set({ day: $D.getDaysInMonth(this.getFullYear(), this.getMonth())}); }; /** * Converts the value of the current Date object to its equivalent string representation. * Format Specifiers * CUSTOM DATE AND TIME FORMAT STRINGS * Format Description Example * ------ --------------------------------------------------------------------------- ----------------------- * s The seconds of the minute between 0-59. "0" to "59" * ss The seconds of the minute with leading zero if required. "00" to "59" * * m The minute of the hour between 0-59. "0" or "59" * mm The minute of the hour with leading zero if required. "00" or "59" * * h The hour of the day between 1-12. "1" to "12" * hh The hour of the day with leading zero if required. "01" to "12" * * H The hour of the day between 0-23. "0" to "23" * HH The hour of the day with leading zero if required. "00" to "23" * * d The day of the month between 1 and 31. "1" to "31" * dd The day of the month with leading zero if required. "01" to "31" * ddd Abbreviated day name. Date.CultureInfo.abbreviatedDayNames. "Mon" to "Sun" * dddd The full day name. Date.CultureInfo.dayNames. "Monday" to "Sunday" * * M The month of the year between 1-12. "1" to "12" * MM The month of the year with leading zero if required. "01" to "12" * MMM Abbreviated month name. Date.CultureInfo.abbreviatedMonthNames. "Jan" to "Dec" * MMMM The full month name. Date.CultureInfo.monthNames. "January" to "December" * * yy The year as a two-digit number. "99" or "08" * yyyy The full four digit year. "1999" or "2008" * * t Displays the first character of the A.M./P.M. designator. "A" or "P" * Date.CultureInfo.amDesignator or Date.CultureInfo.pmDesignator * tt Displays the A.M./P.M. designator. "AM" or "PM" * Date.CultureInfo.amDesignator or Date.CultureInfo.pmDesignator * * S The ordinal suffix ("st, "nd", "rd" or "th") of the current day. "st, "nd", "rd" or "th" * * STANDARD DATE AND TIME FORMAT STRINGS * Format Description Example *------ --------------------------------------------------------------------------- ----------------------- * d The CultureInfo shortDate Format Pattern "M/d/yyyy" * D The CultureInfo longDate Format Pattern "dddd, MMMM dd, yyyy" * F The CultureInfo fullDateTime Format Pattern "dddd, MMMM dd, yyyy h:mm:ss tt" * m The CultureInfo monthDay Format Pattern "MMMM dd" * r The CultureInfo rfc1123 Format Pattern "ddd, dd MMM yyyy HH:mm:ss GMT" * s The CultureInfo sortableDateTime Format Pattern "yyyy-MM-ddTHH:mm:ss" * t The CultureInfo shortTime Format Pattern "h:mm tt" * T The CultureInfo longTime Format Pattern "h:mm:ss tt" * u The CultureInfo universalSortableDateTime Format Pattern "yyyy-MM-dd HH:mm:ssZ" * y The CultureInfo yearMonth Format Pattern "MMMM, yyyy" * * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @return {String} A string representation of the current Date object. */ var ord = function (n) { switch (n * 1) { case 1: case 21: case 31: return "st"; case 2: case 22: return "nd"; case 3: case 23: return "rd"; default: return "th"; } }; var parseStandardFormats = function (format) { var y, c = Date.CultureInfo.formatPatterns; switch (format) { case "d": return this.toString(c.shortDate); case "D": return this.toString(c.longDate); case "F": return this.toString(c.fullDateTime); case "m": return this.toString(c.monthDay); case "r": case "R": y = this.clone().addMinutes(this.getTimezoneOffset()); return y.toString(c.rfc1123) + " GMT"; case "s": return this.toString(c.sortableDateTime); case "t": return this.toString(c.shortTime); case "T": return this.toString(c.longTime); case "u": y = this.clone().addMinutes(this.getTimezoneOffset()); return y.toString(c.universalSortableDateTime); case "y": return this.toString(c.yearMonth); default: return false; } }; var parseFormatStringsClosure = function (context) { return function (m) { if (m.charAt(0) === "\\") { return m.replace("\\", ""); } switch (m) { case "hh": return p(context.getHours() < 13 ? (context.getHours() === 0 ? 12 : context.getHours()) : (context.getHours() - 12)); case "h": return context.getHours() < 13 ? (context.getHours() === 0 ? 12 : context.getHours()) : (context.getHours() - 12); case "HH": return p(context.getHours()); case "H": return context.getHours(); case "mm": return p(context.getMinutes()); case "m": return context.getMinutes(); case "ss": return p(context.getSeconds()); case "s": return context.getSeconds(); case "yyyy": return p(context.getFullYear(), 4); case "yy": return p(context.getFullYear()); case "y": return context.getFullYear(); case "E": case "dddd": return Date.CultureInfo.dayNames[context.getDay()]; case "ddd": return Date.CultureInfo.abbreviatedDayNames[context.getDay()]; case "dd": return p(context.getDate()); case "d": return context.getDate(); case "MMMM": return Date.CultureInfo.monthNames[context.getMonth()]; case "MMM": return Date.CultureInfo.abbreviatedMonthNames[context.getMonth()]; case "MM": return p((context.getMonth() + 1)); case "M": return context.getMonth() + 1; case "t": return context.getHours() < 12 ? Date.CultureInfo.amDesignator.substring(0, 1) : Date.CultureInfo.pmDesignator.substring(0, 1); case "tt": return context.getHours() < 12 ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator; case "S": return ord(context.getDate()); case "W": return context.getWeek(); case "WW": return context.getISOWeek(); case "Q": return "Q" + context.getQuarter(); case "q": return String(context.getQuarter()); case "z": return context.getTimezone(); case "Z": case "X": return Date.getTimezoneOffset(context.getTimezone()); case "ZZ": // Timezone offset in seconds return context.getTimezoneOffset() * -60; case "u": return context.getDay(); case "L": return ($D.isLeapYear(context.getFullYear())) ? 1 : 0; case "B": // Swatch Internet Time (.beats) return "@"+((context.getUTCSeconds() + (context.getUTCMinutes()*60) + ((context.getUTCHours()+1)*3600))/86.4); default: return m; } }; }; $P.toString = function (format, ignoreStandards) { // Standard Date and Time Format Strings. Formats pulled from CultureInfo file and // may vary by culture. if (!ignoreStandards && format && format.length === 1) { output = parseStandardFormats.call(this, format); if (output) { return output; } } var parseFormatStrings = parseFormatStringsClosure(this); return format ? format.replace(/((\\)?(dd?d?d?|MM?M?M?|yy?y?y?|hh?|HH?|mm?|ss?|tt?|S|q|Q|WW?W?W?)(?![^\[]*\]))/g, parseFormatStrings).replace(/\[|\]/g, "") : this._toString(); }; }()); /************************************************************* * SugarPak - Domain Specific Language - Syntactical Sugar * *************************************************************/ (function () { var $D = Date, $P = $D.prototype, $N = Number.prototype; // private $P._orient = +1; // private $P._nth = null; // private $P._is = false; // private $P._same = false; // private $P._isSecond = false; // private $N._dateElement = "days"; /** * Moves the date to the next instance of a date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.today().next().friday();
	Date.today().next().fri();
	Date.today().next().march();
	Date.today().next().mar();
	Date.today().next().week();
	
* * @return {Date} date */ $P.next = function () { this._move = true; this._orient = +1; return this; }; /** * Creates a new Date (Date.today()) and moves the date to the next instance of the date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.next().friday();
	Date.next().fri();
	Date.next().march();
	Date.next().mar();
	Date.next().week();
	
* * @return {Date} date */ $D.next = function () { return $D.today().next(); }; /** * Moves the date to the previous instance of a date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.today().last().friday();
	Date.today().last().fri();
	Date.today().last().march();
	Date.today().last().mar();
	Date.today().last().week();
	
* * @return {Date} date */ $P.last = $P.prev = $P.previous = function () { this._move = true; this._orient = -1; return this; }; /** * Creates a new Date (Date.today()) and moves the date to the previous instance of the date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.last().friday();
	Date.last().fri();
	Date.previous().march();
	Date.prev().mar();
	Date.last().week();
	
* * @return {Date} date */ $D.last = $D.prev = $D.previous = function () { return $D.today().last(); }; /** * Performs a equality check when followed by either a month name, day name or .weekday() function. * Example

	Date.today().is().friday(); // true|false
	Date.today().is().fri();
	Date.today().is().march();
	Date.today().is().mar();
	
* * @return {Boolean} true|false */ $P.is = function () { this._is = true; return this; }; /** * Determines if two date objects occur on/in exactly the same instance of the subsequent date part function. * The function .same() must be followed by a date part function (example: .day(), .month(), .year(), etc). * * An optional Date can be passed in the date part function. If now date is passed as a parameter, 'Now' is used. * * The following example demonstrates how to determine if two dates fall on the exact same day. * * Example

	var d1 = Date.today(); // today at 00:00
	var d2 = new Date();   // exactly now.

	// Do they occur on the same day?
	d1.same().day(d2); // true
	
	// Do they occur on the same hour?
	d1.same().hour(d2); // false, unless d2 hour is '00' (midnight).
	
	// What if it's the same day, but one year apart?
	var nextYear = Date.today().add(1).year();

	d1.same().day(nextYear); // false, because the dates must occur on the exact same day. 
	
* * Scenario: Determine if a given date occurs during some week period 2 months from now. * * Example

	var future = Date.today().add(2).months();
	return someDate.same().week(future); // true|false;
	
* * @return {Boolean} true|false */ $P.same = function () { this._same = true; this._isSecond = false; return this; }; /** * Determines if the current date/time occurs during Today. Must be preceded by the .is() function. * Example

	someDate.is().today();    // true|false
	new Date().is().today();  // true
	Date.today().is().today();// true
	Date.today().add(-1).day().is().today(); // false
	
* * @return {Boolean} true|false */ $P.today = function () { return this.same().day(); }; /** * Determines if the current date is a weekday. This function must be preceded by the .is() function. * Example

	Date.today().is().weekday(); // true|false
	
* * @return {Boolean} true|false */ $P.weekday = function () { if (this._nth) { return df("Weekday").call(this); } if (this._move) { return this.addWeekdays(this._orient); } if (this._is) { this._is = false; return (!this.is().sat() && !this.is().sun()); } return false; }; /** * Determines if the current date is on the weekend. This function must be preceded by the .is() function. * Example

	Date.today().is().weekend(); // true|false
	
* * @return {Boolean} true|false */ $P.weekend = function () { if (this._is) { this._is = false; return (this.is().sat() || this.is().sun()); } return false; }; /** * Sets the Time of the current Date instance. A string "6:15 pm" or config object {hour:18, minute:15} are accepted. * Example

	// Set time to 6:15pm with a String
	Date.today().at("6:15pm");

	// Set time to 6:15pm with a config object
	Date.today().at({hour:18, minute:15});
	
* * @return {Date} date */ $P.at = function (time) { return (typeof time === "string") ? $D.parse(this.toString("d") + " " + time) : this.set(time); }; /** * Creates a new Date() and adds this (Number) to the date based on the preceding date element function (eg. second|minute|hour|day|month|year). * Example

	// Undeclared Numbers must be wrapped with parentheses. Requirment of JavaScript.
	(3).days().fromNow();
	(6).months().fromNow();

	// Declared Number variables do not require parentheses. 
	var n = 6;
	n.months().fromNow();
	
* * @return {Date} A new Date instance */ $N.fromNow = $N.after = function (date) { var c = {}; c[this._dateElement] = this; return ((!date) ? new Date() : date.clone()).add(c); }; /** * Creates a new Date() and subtract this (Number) from the date based on the preceding date element function (eg. second|minute|hour|day|month|year). * Example

	// Undeclared Numbers must be wrapped with parentheses. Requirment of JavaScript.
	(3).days().ago();
	(6).months().ago();

	// Declared Number variables do not require parentheses. 
	var n = 6;
	n.months().ago();
	
* * @return {Date} A new Date instance */ $N.ago = $N.before = function (date) { var c = {}, s = (this._dateElement[this._dateElement.length-1] !== "s") ? this._dateElement + "s" : this._dateElement; c[s] = this * -1; return ((!date) ? new Date() : date.clone()).add(c); }; // Do NOT modify the following string tokens. These tokens are used to build dynamic functions. // All culture-specific strings can be found in the CultureInfo files. var dx = ("sunday monday tuesday wednesday thursday friday saturday").split(/\s/), mx = ("january february march april may june july august september october november december").split(/\s/), px = ("Millisecond Second Minute Hour Day Week Month Year Quarter Weekday").split(/\s/), pxf = ("Milliseconds Seconds Minutes Hours Date Week Month FullYear Quarter").split(/\s/), nth = ("final first second third fourth fifth").split(/\s/), de; /** * Returns an object literal of all the date parts. * Example

	var o = new Date().toObject();
	
	// { year: 2008, month: 4, week: 20, day: 13, hour: 18, minute: 9, second: 32, millisecond: 812 }
	
	// The object properties can be referenced directly from the object.
	
	alert(o.day);  // alerts "13"
	alert(o.year); // alerts "2008"
	
* * @return {Date} An object literal representing the original date object. */ $P.toObject = function () { var o = {}; for (var i = 0; i < px.length; i++) { if (this["get" + pxf[i]]) { o[px[i].toLowerCase()] = this["get" + pxf[i]](); } } return o; }; /** * Returns a date created from an object literal. Ignores the .week property if set in the config. * Example

	var o = new Date().toObject();
	
	return Date.fromObject(o); // will return the same date. 

	var o2 = {month: 1, day: 20, hour: 18}; // birthday party!
	Date.fromObject(o2);
	
* * @return {Date} An object literal representing the original date object. */ $D.fromObject = function(config) { config.week = null; return Date.today().set(config); }; // Create day name functions and abbreviated day name functions (eg. monday(), friday(), fri()). var df = function (n) { return function () { if (this._is) { this._is = false; return this.getDay() === n; } if (this._move) { this._move = null; } if (this._nth !== null) { // If the .second() function was called earlier, remove the _orient // from the date, and then continue. // This is required because 'second' can be used in two different context. // // Example // // Date.today().add(1).second(); // Date.march().second().monday(); // // Things get crazy with the following... // Date.march().add(1).second().second().monday(); // but it works!! // if (this._isSecond) { this.addSeconds(this._orient * -1); } // make sure we reset _isSecond this._isSecond = false; var ntemp = this._nth; this._nth = null; var temp = this.clone().moveToLastDayOfMonth(); this.moveToNthOccurrence(n, ntemp); if (this > temp) { throw new RangeError($D.getDayName(n) + " does not occur " + ntemp + " times in the month of " + $D.getMonthName(temp.getMonth()) + " " + temp.getFullYear() + "."); } return this; } return this.moveToDayOfWeek(n, this._orient); }; }; var sdf = function (n) { return function () { var t = $D.today(), shift = n - t.getDay(); if (n === 0 && Date.CultureInfo.firstDayOfWeek === 1 && t.getDay() !== 0) { shift = shift + 7; } return t.addDays(shift); }; }; // Create month name functions and abbreviated month name functions (eg. january(), march(), mar()). var month_instance_functions = function (n) { return function () { if (this._is) { this._is = false; return this.getMonth() === n; } return this.moveToMonth(n, this._orient); }; }; var month_static_functions = function (n) { return function () { return $D.today().set({ month: n, day: 1 }); }; }; var processTerms = function (names, staticFunc, instanceFunc) { for (var i = 0; i < names.length; i++) { // Create constant static Name variables. $D[names[i].toUpperCase()] = $D[names[i].toUpperCase().substring(0, 3)] = i; // Create Name functions. $D[names[i]] = $D[names[i].substring(0, 3)] = staticFunc(i); // Create Name instance functions. $P[names[i]] = $P[names[i].substring(0, 3)] = instanceFunc(i); } }; processTerms(dx, sdf, df); processTerms(mx, month_static_functions, month_instance_functions); // Create date element functions and plural date element functions used with Date (eg. day(), days(), months()). var ef = function (j) { return function () { // if the .second() function was called earlier, the _orient // has alread been added. Just return this and reset _isSecond. if (this._isSecond) { this._isSecond = false; return this; } if (this._same) { this._same = this._is = false; var o1 = this.toObject(), o2 = (arguments[0] || new Date()).toObject(), v = "", k = j.toLowerCase(); // the substr trick with -1 doesn't work in IE8 or less k = (k[k.length-1] === "s") ? k.substring(0,k.length-1) : k; for (var m = (px.length - 1); m > -1; m--) { v = px[m].toLowerCase(); if (o1[v] !== o2[v]) { return false; } if (k === v) { break; } } return true; } if (j.substring(j.length - 1) !== "s") { j += "s"; } if (this._move) { this._move = null; } return this["add" + j](this._orient); }; }; var nf = function (n) { return function () { this._dateElement = n; return this; }; }; for (var k = 0; k < px.length; k++) { de = px[k].toLowerCase(); if(de !== "weekday") { // Create date element functions and plural date element functions used with Date (eg. day(), days(), months()). $P[de] = $P[de + "s"] = ef(px[k]); // Create date element functions and plural date element functions used with Number (eg. day(), days(), months()). $N[de] = $N[de + "s"] = nf(de + "s"); } } $P._ss = ef("Second"); var nthfn = function (n) { return function (dayOfWeek) { if (this._same) { return this._ss(arguments[0]); } if (dayOfWeek || dayOfWeek === 0) { return this.moveToNthOccurrence(dayOfWeek, n); } this._nth = n; // if the operator is 'second' add the _orient, then deal with it later... if (n === 2 && (dayOfWeek === undefined || dayOfWeek === null)) { this._isSecond = true; return this.addSeconds(this._orient); } return this; }; }; for (var l = 0; l < nth.length; l++) { $P[nth[l]] = (l === 0) ? nthfn(-1) : nthfn(l); } }()); (function () { "use strict"; Date.Parsing = { Exception: function (s) { this.message = "Parse error at '" + s.substring(0, 10) + " ...'"; } }; var $P = Date.Parsing; var dayOffsets = { standard: [0,31,59,90,120,151,181,212,243,273,304,334], leap: [0,31,60,91,121,152,182,213,244,274,305,335] }; $P.isLeapYear = function(year) { return ((year % 4 === 0) && (year % 100 !== 0)) || (year % 400 === 0); }; var utils = { multiReplace : function (str, hash ) { var key; for (key in hash) { if (Object.prototype.hasOwnProperty.call(hash, key)) { var regex; if (typeof hash[key] === "function") { } else { regex = (hash[key] instanceof RegExp) ? hash[key] : new RegExp(hash[key], "g"); } str = str.replace(regex, key); } } return str; }, getDayOfYearFromWeek : function (obj) { var d, jan4, offset; obj.weekDay = (!obj.weekDay && obj.weekDay !== 0) ? 1 : obj.weekDay; d = new Date(obj.year, 0, 4); jan4 = d.getDay() === 0 ? 7 : d.getDay(); // JS is 0 indexed on Sunday. offset = jan4+3; obj.dayOfYear = ((obj.week * 7) + (obj.weekDay === 0 ? 7 : obj.weekDay))-offset; return obj; }, getDayOfYear : function (obj, dayOffset) { if (!obj.dayOfYear) { obj = utils.getDayOfYearFromWeek(obj); } for (var i=0;i <= dayOffset.length;i++) { if (obj.dayOfYear < dayOffset[i] || i === dayOffset.length) { obj.day = obj.day ? obj.day : (obj.dayOfYear - dayOffset[i-1]); break; } else { obj.month = i; } } return obj; }, adjustForTimeZone : function (obj, date) { var offset; if (obj.zone.toUpperCase() === "Z" || (obj.zone_hours === 0 && obj.zone_minutes === 0)) { // it's UTC/GML so work out the current timeszone offset offset = -date.getTimezoneOffset(); } else { offset = (obj.zone_hours*60) + (obj.zone_minutes || 0); if (obj.zone_sign === "+") { offset *= -1; } offset -= date.getTimezoneOffset(); } date.setMinutes(date.getMinutes()+offset); return date; }, setDefaults : function (obj) { obj.year = obj.year || Date.today().getFullYear(); obj.hours = obj.hours || 0; obj.minutes = obj.minutes || 0; obj.seconds = obj.seconds || 0; obj.milliseconds = obj.milliseconds || 0; if (!(!obj.month && (obj.week || obj.dayOfYear))) { // if we have a month, or if we don't but don't have the day calculation data obj.month = obj.month || 0; obj.day = obj.day || 1; } return obj; }, dataNum: function (data, mod, explict, postProcess) { var dataNum = data*1; if (mod) { if (postProcess) { return data ? mod(data)*1 : data; } else { return data ? mod(dataNum) : data; } } else if (!explict){ return data ? dataNum : data; } else { return (data && typeof data !== "undefined") ? dataNum : data; } }, timeDataProcess: function (obj) { var timeObj = {}; for (var x in obj.data) { if (obj.data.hasOwnProperty(x)) { timeObj[x] = obj.ignore[x] ? obj.data[x] : utils.dataNum(obj.data[x], obj.mods[x], obj.explict[x], obj.postProcess[x]); } } if (obj.data.secmins) { obj.data.secmins = obj.data.secmins.replace(",", ".") * 60; if (!timeObj.minutes) { timeObj.minutes = obj.data.secmins; } else if (!timeObj.seconds) { timeObj.seconds = obj.data.secmins; } delete obj.secmins; } return timeObj; }, buildTimeObjectFromData: function (data) { var time = utils.timeDataProcess({ data: { year : data[1], month : data[5], day : data[7], week : data[8], dayOfYear : data[10], hours : data[15], zone_hours : data[23], zone_minutes : data[24], zone : data[21], zone_sign : data[22], weekDay : data[9], minutes: data[16], seconds: data[19], milliseconds: data[20], secmins: data[18] }, mods: { month: function(data) { return data-1; }, weekDay: function (data) { data = Math.abs(data); return (data === 7 ? 0 : data); }, minutes: function (data) { return data.replace(":",""); }, seconds: function (data) { return Math.floor( (data.replace(":","").replace(",","."))*1 ); }, milliseconds: function (data) { return (data.replace(",",".")*1000); } }, postProcess: { minutes: true, seconds: true, milliseconds: true }, explict: { zone_hours: true, zone_minutes: true }, ignore: { zone: true, zone_sign: true, secmins: true } }); return time; }, addToHash: function (hash, keys, data) { keys = keys; data = data; var len = keys.length; for (var i = 0; i < len; i++) { hash[keys[i]] = data[i]; } return hash; }, combineRegex: function (r1, r2) { return new RegExp("(("+r1.source+")\\s("+r2.source+"))"); }, getDateNthString: function(add, last, inc){ if (add) { return Date.today().addDays(inc).toString("d"); } else if (last) { return Date.today().last()[inc]().toString("d"); } }, buildRegexData: function (array) { var arr = []; var len = array.length; for (var i=0; i < len; i++) { if (Object.prototype.toString.call(array[i]) === '[object Array]') { // oldIE compat version of Array.isArray arr.push(this.combineRegex(array[i][0], array[i][1])); } else { arr.push(array[i]); } } return arr; } }; $P.processTimeObject = function (obj) { var date, dayOffset; utils.setDefaults(obj); dayOffset = ($P.isLeapYear(obj.year)) ? dayOffsets.leap : dayOffsets.standard; if (!obj.month && (obj.week || obj.dayOfYear)) { utils.getDayOfYear(obj, dayOffset); } else { obj.dayOfYear = dayOffset[obj.month] + obj.day; } date = new Date(obj.year, obj.month, obj.day, obj.hours, obj.minutes, obj.seconds, obj.milliseconds); if (obj.zone) { utils.adjustForTimeZone(obj, date); // adjust (and calculate) for timezone } return date; }; $P.ISO = { regex : /^([\+-]?\d{4}(?!\d{2}\b))((-?)((0[1-9]|1[0-2])(\3([12]\d|0[1-9]|3[01]))?|W([0-4]\d|5[0-3])(-?[1-7])?|(00[1-9]|0[1-9]\d|[12]\d{2}|3([0-5]\d|6[1-6])))([T\s]((([01]\d|2[0-4])((:?)[0-5]\d)?|24\:?00)([\.,]\d+(?!:))?)?(\17[0-5]\d([\.,]\d+)?)?\s?([zZ]|([\+-])([01]\d|2[0-3]):?([0-5]\d)?)?)?)?$/, parse : function (s) { var time, data = s.match(this.regex); if (!data || !data.length) { return null; } time = utils.buildTimeObjectFromData(data); if (!time.year || (!time.year && (!time.month && !time.day) && (!time.week && !time.dayOfYear)) ) { return null; } return $P.processTimeObject(time); } }; $P.Numeric = { isNumeric: function (e){return!isNaN(parseFloat(e))&&isFinite(e);}, regex: /\b([0-1]?[0-9])([0-3]?[0-9])([0-2]?[0-9]?[0-9][0-9])\b/i, parse: function (s) { var data, i, time = {}, order = Date.CultureInfo.dateElementOrder.split(""); if (!(this.isNumeric(s)) || // if it's non-numeric OR (s[0] === "+" && s[0] === "-")) { // It's an arithmatic string (eg +/-1000) return null; } if (s.length < 5 && s.indexOf(".") < 0 && s.indexOf("/") < 0) { // assume it's just a year. time.year = s; return $P.processTimeObject(time); } data = s.match(this.regex); if (!data || !data.length) { return null; } for (i=0; i < order.length; i++) { switch(order[i]) { case "d": time.day = data[i+1]; break; case "m": time.month = (data[i+1]-1); break; case "y": time.year = data[i+1]; break; } } return $P.processTimeObject(time); } }; $P.Normalizer = { regexData: function () { var $R = Date.CultureInfo.regexPatterns; return utils.buildRegexData([ $R.tomorrow, $R.yesterday, [$R.past, $R.mon], [$R.past, $R.tue], [$R.past, $R.wed], [$R.past, $R.thu], [$R.past, $R.fri], [$R.past, $R.sat], [$R.past, $R.sun] ]); }, basicReplaceHash : function() { var $R = Date.CultureInfo.regexPatterns; return { "January": $R.jan.source, "February": $R.feb, "March": $R.mar, "April": $R.apr, "May": $R.may, "June": $R.jun, "July": $R.jul, "August": $R.aug, "September": $R.sep, "October": $R.oct, "November": $R.nov, "December": $R.dec, "": /\bat\b/gi, " ": /\s{2,}/, "am": $R.inTheMorning, "9am": $R.thisMorning, "pm": $R.inTheEvening, "7pm":$R.thisEvening }; }, keys : function(){ return [ utils.getDateNthString(true, false, 1), // tomorrow utils.getDateNthString(true, false, -1), // yesterday utils.getDateNthString(false, true, "monday"), //last mon utils.getDateNthString(false, true, "tuesday"), //last tues utils.getDateNthString(false, true, "wednesday"), //last wed utils.getDateNthString(false, true, "thursday"), //last thurs utils.getDateNthString(false, true, "friday"), //last fri utils.getDateNthString(false, true, "saturday"), //last sat utils.getDateNthString(false, true, "sunday") //last sun ]; }, buildRegexFunctions: function () { var $R = Date.CultureInfo.regexPatterns; var __ = Date.i18n.__; var tomorrowRE = new RegExp("(\\b\\d\\d?("+__("AM")+"|"+__("PM")+")? )("+$R.tomorrow.source.slice(1)+")", "i"); // adapted tomorrow regex for AM PM relative dates var todayRE = new RegExp($R.today.source + "(?!\\s*([+-]))\\b"); // today, but excludes the math operators (eg "today + 2h") this.replaceFuncs = [ [todayRE, function (full) { return (full.length > 1) ? Date.today().toString("d") : full; }], [tomorrowRE, function(full, m1) { var t = Date.today().addDays(1).toString("d"); return (t + " " + m1); }], [$R.amThisMorning, function(str, am){return am;}], [$R.pmThisEvening, function(str, pm){return pm;}] ]; }, buildReplaceData: function () { this.buildRegexFunctions(); this.replaceHash = utils.addToHash(this.basicReplaceHash(), this.keys(), this.regexData()); }, stringReplaceFuncs: function (s) { for (var i=0; i < this.replaceFuncs.length; i++) { s = s.replace(this.replaceFuncs[i][0], this.replaceFuncs[i][1]); } return s; }, parse: function (s) { s = this.stringReplaceFuncs(s); s = utils.multiReplace(s, this.replaceHash); try { var n = s.split(/([\s\-\.\,\/\x27]+)/); if (n.length === 3 && $P.Numeric.isNumeric(n[0]) && $P.Numeric.isNumeric(n[2]) && (n[2].length >= 4)) { // ok, so we're dealing with x/year. But that's not a full date. // This fixes wonky dateElementOrder parsing when set to dmy order. if (Date.CultureInfo.dateElementOrder[0] === "d") { s = "1/" + n[0] + "/" + n[2]; // set to 1st of month and normalize the seperator } } } catch (e) {} return s; } }; $P.Normalizer.buildReplaceData(); }()); (function () { var $P = Date.Parsing; var _ = $P.Operators = { // // Tokenizers // rtoken: function (r) { // regex token return function (s) { var mx = s.match(r); if (mx) { return ([ mx[0], s.substring(mx[0].length) ]); } else { throw new $P.Exception(s); } }; }, token: function () { // whitespace-eating token return function (s) { return _.rtoken(new RegExp("^\\s*" + s + "\\s*"))(s); }; }, stoken: function (s) { // string token return _.rtoken(new RegExp("^" + s)); }, // Atomic Operators until: function (p) { return function (s) { var qx = [], rx = null; while (s.length) { try { rx = p.call(this, s); } catch (e) { qx.push(rx[0]); s = rx[1]; continue; } break; } return [ qx, s ]; }; }, many: function (p) { return function (s) { var rx = [], r = null; while (s.length) { try { r = p.call(this, s); } catch (e) { return [ rx, s ]; } rx.push(r[0]); s = r[1]; } return [ rx, s ]; }; }, // generator operators -- see below optional: function (p) { return function (s) { var r = null; try { r = p.call(this, s); } catch (e) { return [ null, s ]; } return [ r[0], r[1] ]; }; }, not: function (p) { return function (s) { try { p.call(this, s); } catch (e) { return [null, s]; } throw new $P.Exception(s); }; }, ignore: function (p) { return p ? function (s) { var r = null; r = p.call(this, s); return [null, r[1]]; } : null; }, product: function () { var px = arguments[0], qx = Array.prototype.slice.call(arguments, 1), rx = []; for (var i = 0 ; i < px.length ; i++) { rx.push(_.each(px[i], qx)); } return rx; }, cache: function (rule) { var cache = {}, cache_length = 0, cache_keys = [], CACHE_MAX = Date.Config.CACHE_MAX || 100000, r = null; var cacheCheck = function () { if (cache_length === CACHE_MAX) { // kill several keys, don't want to have to do this all the time... for (var i=0; i < 10; i++) { var key = cache_keys.shift(); if (key) { delete cache[key]; cache_length--; } } } }; return function (s) { cacheCheck(); try { r = cache[s] = (cache[s] || rule.call(this, s)); } catch (e) { r = cache[s] = e; } cache_length++; cache_keys.push(s); if (r instanceof $P.Exception) { throw r; } else { return r; } }; }, // vector operators -- see below any: function () { var px = arguments; return function (s) { var r = null; for (var i = 0; i < px.length; i++) { if (px[i] == null) { continue; } try { r = (px[i].call(this, s)); } catch (e) { r = null; } if (r) { return r; } } throw new $P.Exception(s); }; }, each: function () { var px = arguments; return function (s) { var rx = [], r = null; for (var i = 0; i < px.length ; i++) { if (px[i] == null) { continue; } try { r = (px[i].call(this, s)); } catch (e) { throw new $P.Exception(s); } rx.push(r[0]); s = r[1]; } return [ rx, s]; }; }, all: function () { var px = arguments, _ = _; return _.each(_.optional(px)); }, // delimited operators sequence: function (px, d, c) { d = d || _.rtoken(/^\s*/); c = c || null; if (px.length === 1) { return px[0]; } return function (s) { var r = null, q = null; var rx = []; for (var i = 0; i < px.length ; i++) { try { r = px[i].call(this, s); } catch (e) { break; } rx.push(r[0]); try { q = d.call(this, r[1]); } catch (ex) { q = null; break; } s = q[1]; } if (!r) { throw new $P.Exception(s); } if (q) { throw new $P.Exception(q[1]); } if (c) { try { r = c.call(this, r[1]); } catch (ey) { throw new $P.Exception(r[1]); } } return [ rx, (r?r[1]:s) ]; }; }, // // Composite Operators // between: function (d1, p, d2) { d2 = d2 || d1; var _fn = _.each(_.ignore(d1), p, _.ignore(d2)); return function (s) { var rx = _fn.call(this, s); return [[rx[0][0], r[0][2]], rx[1]]; }; }, list: function (p, d, c) { d = d || _.rtoken(/^\s*/); c = c || null; return (p instanceof Array ? _.each(_.product(p.slice(0, -1), _.ignore(d)), p.slice(-1), _.ignore(c)) : _.each(_.many(_.each(p, _.ignore(d))), px, _.ignore(c))); }, set: function (px, d, c) { d = d || _.rtoken(/^\s*/); c = c || null; return function (s) { // r is the current match, best the current 'best' match // which means it parsed the most amount of input var r = null, p = null, q = null, rx = null, best = [[], s], last = false; // go through the rules in the given set for (var i = 0; i < px.length ; i++) { // last is a flag indicating whether this must be the last element // if there is only 1 element, then it MUST be the last one q = null; p = null; r = null; last = (px.length === 1); // first, we try simply to match the current pattern // if not, try the next pattern try { r = px[i].call(this, s); } catch (e) { continue; } // since we are matching against a set of elements, the first // thing to do is to add r[0] to matched elements rx = [[r[0]], r[1]]; // if we matched and there is still input to parse and // we don't already know this is the last element, // we're going to next check for the delimiter ... // if there's none, or if there's no input left to parse // than this must be the last element after all ... if (r[1].length > 0 && ! last) { try { q = d.call(this, r[1]); } catch (ex) { last = true; } } else { last = true; } // if we parsed the delimiter and now there's no more input, // that means we shouldn't have parsed the delimiter at all // so don't update r and mark this as the last element ... if (!last && q[1].length === 0) { last = true; } // so, if this isn't the last element, we're going to see if // we can get any more matches from the remaining (unmatched) // elements ... if (!last) { // build a list of the remaining rules we can match against, // i.e., all but the one we just matched against var qx = []; for (var j = 0; j < px.length ; j++) { if (i !== j) { qx.push(px[j]); } } // now invoke recursively set with the remaining input // note that we don't include the closing delimiter ... // we'll check for that ourselves at the end p = _.set(qx, d).call(this, q[1]); // if we got a non-empty set as a result ... // (otw rx already contains everything we want to match) if (p[0].length > 0) { // update current result, which is stored in rx ... // basically, pick up the remaining text from p[1] // and concat the result from p[0] so that we don't // get endless nesting ... rx[0] = rx[0].concat(p[0]); rx[1] = p[1]; } } // at this point, rx either contains the last matched element // or the entire matched set that starts with this element. // now we just check to see if this variation is better than // our best so far, in terms of how much of the input is parsed if (rx[1].length < best[1].length) { best = rx; } // if we've parsed all the input, then we're finished if (best[1].length === 0) { break; } } // so now we've either gone through all the patterns trying them // as the initial match; or we found one that parsed the entire // input string ... // if best has no matches, just return empty set ... if (best[0].length === 0) { return best; } // if a closing delimiter is provided, then we have to check it also if (c) { // we try this even if there is no remaining input because the pattern // may well be optional or match empty input ... try { q = c.call(this, best[1]); } catch (ey) { throw new $P.Exception(best[1]); } // it parsed ... be sure to update the best match remaining input best[1] = q[1]; } // if we're here, either there was no closing delimiter or we parsed it // so now we have the best match; just return it! return best; }; }, forward: function (gr, fname) { return function (s) { return gr[fname].call(this, s); }; }, // // Translation Operators // replace: function (rule, repl) { return function (s) { var r = rule.call(this, s); return [repl, r[1]]; }; }, process: function (rule, fn) { return function (s) { var r = rule.call(this, s); return [fn.call(this, r[0]), r[1]]; }; }, min: function (min, rule) { return function (s) { var rx = rule.call(this, s); if (rx[0].length < min) { throw new $P.Exception(s); } return rx; }; } }; // Generator Operators And Vector Operators // Generators are operators that have a signature of F(R) => R, // taking a given rule and returning another rule, such as // ignore, which parses a given rule and throws away the result. // Vector operators are those that have a signature of F(R1,R2,...) => R, // take a list of rules and returning a new rule, such as each. // Generator operators are converted (via the following _generator // function) into functions that can also take a list or array of rules // and return an array of new rules as though the function had been // called on each rule in turn (which is what actually happens). // This allows generators to be used with vector operators more easily. // Example: // each(ignore(foo, bar)) instead of each(ignore(foo), ignore(bar)) // This also turns generators into vector operators, which allows // constructs like: // not(cache(foo, bar)) var _generator = function (op) { function gen() { var args = null, rx = [], px, i; if (arguments.length > 1) { args = Array.prototype.slice.call(arguments); } else if (arguments[0] instanceof Array) { args = arguments[0]; } if (args) { px = args.shift(); if (px.length > 0) { args.unshift(px[i]); rx.push(op.apply(null, args)); args.shift(); return rx; } } else { return op.apply(null, arguments); } } return gen; }; var gx = "optional not ignore cache".split(/\s/); for (var i = 0 ; i < gx.length ; i++) { _[gx[i]] = _generator(_[gx[i]]); } var _vector = function (op) { return function () { if (arguments[0] instanceof Array) { return op.apply(null, arguments[0]); } else { return op.apply(null, arguments); } }; }; var vx = "each any all".split(/\s/); for (var j = 0 ; j < vx.length ; j++) { _[vx[j]] = _vector(_[vx[j]]); } }()); (function () { var $D = Date; var flattenAndCompact = function (ax) { var rx = []; for (var i = 0; i < ax.length; i++) { if (ax[i] instanceof Array) { rx = rx.concat(flattenAndCompact(ax[i])); } else { if (ax[i]) { rx.push(ax[i]); } } } return rx; }; var parseMeridian = function () { if (this.meridian && (this.hour || this.hour === 0)) { if (this.meridian === "a" && this.hour > 11 && Date.Config.strict24hr){ throw "Invalid hour and meridian combination"; } else if (this.meridian === "p" && this.hour < 12 && Date.Config.strict24hr){ throw "Invalid hour and meridian combination"; } else if (this.meridian === "p" && this.hour < 12) { this.hour = this.hour + 12; } else if (this.meridian === "a" && this.hour === 12) { this.hour = 0; } } }; var setDefaults = function () { var now = new Date(); if ((this.hour || this.minute) && (!this.month && !this.year && !this.day)) { this.day = now.getDate(); } if (!this.year) { this.year = now.getFullYear(); } if (!this.month && this.month !== 0) { this.month = now.getMonth(); } if (!this.day) { this.day = 1; } if (!this.hour) { this.hour = 0; } if (!this.minute) { this.minute = 0; } if (!this.second) { this.second = 0; } if (!this.millisecond) { this.millisecond = 0; } }; var finishUtils = { getToday: function () { if (this.now || "hour minute second".indexOf(this.unit) !== -1) { return new Date(); } else { return $D.today(); } }, setDaysFromWeekday: function (today, orient){ var gap; orient = orient || 1; this.unit = "day"; gap = ($D.getDayNumberFromName(this.weekday) - today.getDay()); this.days = gap ? ((gap + (orient * 7)) % 7) : (orient * 7); return this; }, setMonthsFromMonth: function (today, orient) { var gap; orient = orient || 1; this.unit = "month"; gap = (this.month - today.getMonth()); this.months = gap ? ((gap + (orient * 12)) % 12) : (orient * 12); this.month = null; return this; }, setDMYFromWeekday: function () { var d = Date[this.weekday](); this.day = d.getDate(); if (!this.month) { this.month = d.getMonth(); } this.year = d.getFullYear(); return this; }, setUnitValue: function (orient) { if (!this.value && this.operator && this.operator !== null && this[this.unit + "s"] && this[this.unit + "s"] !== null) { this[this.unit + "s"] = this[this.unit + "s"] + ((this.operator === "add") ? 1 : -1) + (this.value||0) * orient; } else if (this[this.unit + "s"] == null || this.operator != null) { if (!this.value) { this.value = 1; } this[this.unit + "s"] = this.value * orient; } }, generateDateFromWeeks: function () { var weekday = (this.weekday !== undefined) ? this.weekday : "today"; var d = Date[weekday]().addWeeks(this.weeks); if (this.now) { d.setTimeToNow(); } return d; } }; $D.Translator = { hour: function (s) { return function () { this.hour = Number(s); }; }, minute: function (s) { return function () { this.minute = Number(s); }; }, second: function (s) { return function () { this.second = Number(s); }; }, /* for ss.s format */ secondAndMillisecond: function (s) { return function () { var mx = s.match(/^([0-5][0-9])\.([0-9]{1,3})/); this.second = Number(mx[1]); this.millisecond = Number(mx[2]); }; }, meridian: function (s) { return function () { this.meridian = s.slice(0, 1).toLowerCase(); }; }, timezone: function (s) { return function () { var n = s.replace(/[^\d\+\-]/g, ""); if (n.length) { this.timezoneOffset = Number(n); } else { this.timezone = s.toLowerCase(); } }; }, day: function (x) { var s = x[0]; return function () { this.day = Number(s.match(/\d+/)[0]); if (this.day < 1) { throw "invalid day"; } }; }, month: function (s) { return function () { this.month = (s.length === 3) ? "jan feb mar apr may jun jul aug sep oct nov dec".indexOf(s)/4 : Number(s) - 1; if (this.month < 0) { throw "invalid month"; } }; }, year: function (s) { return function () { var n = Number(s); this.year = ((s.length > 2) ? n : (n + (((n + 2000) < Date.CultureInfo.twoDigitYearMax) ? 2000 : 1900))); }; }, rday: function (s) { return function () { switch (s) { case "yesterday": this.days = -1; break; case "tomorrow": this.days = 1; break; case "today": this.days = 0; break; case "now": this.days = 0; this.now = true; break; } }; }, finishExact: function (x) { var d; x = (x instanceof Array) ? x : [x]; for (var i = 0 ; i < x.length ; i++) { if (x[i]) { x[i].call(this); } } setDefaults.call(this); parseMeridian.call(this); if (this.day > $D.getDaysInMonth(this.year, this.month)) { throw new RangeError(this.day + " is not a valid value for days."); } d = new Date(this.year, this.month, this.day, this.hour, this.minute, this.second, this.millisecond); if (this.year < 100) { d.setFullYear(this.year); // means years less that 100 are process correctly. JS will parse it otherwise as 1900-1999. } if (this.timezone) { d.set({ timezone: this.timezone }); } else if (this.timezoneOffset) { d.set({ timezoneOffset: this.timezoneOffset }); } return d; }, finish: function (x) { var today, expression, orient, temp; x = (x instanceof Array) ? flattenAndCompact(x) : [ x ]; if (x.length === 0) { return null; } for (var i = 0 ; i < x.length ; i++) { if (typeof x[i] === "function") { x[i].call(this); } } if (this.now && !this.unit && !this.operator) { return new Date(); } else { today = finishUtils.getToday.call(this); } expression = !!(this.days && this.days !== null || this.orient || this.operator); orient = ((this.orient === "past" || this.operator === "subtract") ? -1 : 1); if (this.month && this.unit === "week") { this.value = this.month + 1; delete this.month; delete this.day; } if ((this.month || this.month === 0) && "year day hour minute second".indexOf(this.unit) !== -1) { if (!this.value) { this.value = this.month + 1; } this.month = null; expression = true; } if (!expression && this.weekday && !this.day && !this.days) { finishUtils.setDMYFromWeekday.call(this); } if (expression && this.weekday && this.unit !== "month" && this.unit !== "week") { finishUtils.setDaysFromWeekday.call(this, today, orient); } if (this.weekday && this.unit !== "week" && !this.day && !this.days) { temp = Date[this.weekday](); this.day = temp.getDate(); if (temp.getMonth() !== today.getMonth()) { this.month = temp.getMonth(); } } if (this.month && this.unit === "day" && this.operator) { if (!this.value) { this.value = (this.month + 1); } this.month = null; } if (this.value != null && this.month != null && this.year != null) { this.day = this.value * 1; } if (this.month && !this.day && this.value) { today.set({ day: this.value * 1 }); if (!expression) { this.day = this.value * 1; } } if (!this.month && this.value && this.unit === "month" && !this.now) { this.month = this.value; expression = true; } if (expression && (this.month || this.month === 0) && this.unit !== "year") { finishUtils.setMonthsFromMonth.call(this, today, orient); } if (!this.unit) { this.unit = "day"; } finishUtils.setUnitValue.call(this, orient); parseMeridian.call(this); if ((this.month || this.month === 0) && !this.day) { this.day = 1; } if (!this.orient && !this.operator && this.unit === "week" && this.value && !this.day && !this.month) { return Date.today().setWeek(this.value); } if (this.unit === "week" && this.weeks && !this.day && !this.month) { return finishUtils.generateDateFromWeeks.call(this); } if (expression && this.timezone && this.day && this.days) { this.day = this.days; } if (expression){ today.add(this); } else { today.set(this); } if (this.timezone) { this.timezone = this.timezone.toUpperCase(); var offset = $D.getTimezoneOffset(this.timezone); var timezone; if (today.hasDaylightSavingTime()) { // lets check that we're being sane with timezone setting timezone = $D.getTimezoneAbbreviation(offset, today.isDaylightSavingTime()); if (timezone !== this.timezone) { // bugger, we're in a place where things like EST vs EDT matters. if (today.isDaylightSavingTime()) { today.addHours(-1); } else { today.addHours(1); } } } today.setTimezoneOffset(offset); } return today; } }; }()); (function () { var $D = Date; $D.Grammar = {}; var _ = $D.Parsing.Operators, g = $D.Grammar, t = $D.Translator, _fn; // Allow rolling up into general purpose rules _fn = function () { return _.each(_.any.apply(null, arguments), _.not(g.ctoken2("timeContext"))); }; g.datePartDelimiter = _.rtoken(/^([\s\-\.\,\/\x27]+)/); g.timePartDelimiter = _.stoken(":"); g.whiteSpace = _.rtoken(/^\s*/); g.generalDelimiter = _.rtoken(/^(([\s\,]|at|@|on)+)/); var _C = {}; g.ctoken = function (keys) { var fn = _C[keys]; if (! fn) { var c = Date.CultureInfo.regexPatterns; var kx = keys.split(/\s+/), px = []; for (var i = 0; i < kx.length ; i++) { px.push(_.replace(_.rtoken(c[kx[i]]), kx[i])); } fn = _C[keys] = _.any.apply(null, px); } return fn; }; g.ctoken2 = function (key) { return _.rtoken(Date.CultureInfo.regexPatterns[key]); }; var cacheProcessRtoken = function (key, token, type, eachToken) { if (eachToken) { g[key] = _.cache(_.process(_.each(_.rtoken(token),_.optional(g.ctoken2(eachToken))), type)); } else { g[key] = _.cache(_.process(_.rtoken(token), type)); } }; var cacheProcessCtoken = function (token, type) { return _.cache(_.process(g.ctoken2(token), type)); }; var _F = {}; //function cache var _get = function (f) { _F[f] = (_F[f] || g.format(f)[0]); return _F[f]; }; g.allformats = function (fx) { var rx = []; if (fx instanceof Array) { for (var i = 0; i < fx.length; i++) { rx.push(_get(fx[i])); } } else { rx.push(_get(fx)); } return rx; }; g.formats = function (fx) { if (fx instanceof Array) { var rx = []; for (var i = 0 ; i < fx.length ; i++) { rx.push(_get(fx[i])); } return _.any.apply(null, rx); } else { return _get(fx); } }; var grammarFormats = { timeFormats: function(){ var i, RTokenKeys = [ "h", "hh", "H", "HH", "m", "mm", "s", "ss", "ss.s", "z", "zz" ], RToken = [ /^(0[0-9]|1[0-2]|[1-9])/, /^(0[0-9]|1[0-2])/, /^([0-1][0-9]|2[0-3]|[0-9])/, /^([0-1][0-9]|2[0-3])/, /^([0-5][0-9]|[0-9])/, /^[0-5][0-9]/, /^([0-5][0-9]|[0-9])/, /^[0-5][0-9]/, /^[0-5][0-9]\.[0-9]{1,3}/, /^((\+|\-)\s*\d\d\d\d)|((\+|\-)\d\d\:?\d\d)/, /^((\+|\-)\s*\d\d\d\d)|((\+|\-)\d\d\:?\d\d)/ ], tokens = [ t.hour, t.hour, t.hour, t.hour, t.minute, t.minute, t.second, t.second, t.secondAndMillisecond, t.timezone, t.timezone ]; for (i=0; i < RTokenKeys.length; i++) { cacheProcessRtoken(RTokenKeys[i], RToken[i], tokens[i]); } g.hms = _.cache(_.sequence([g.H, g.m, g.s], g.timePartDelimiter)); g.t = cacheProcessCtoken("shortMeridian", t.meridian); g.tt = cacheProcessCtoken("longMeridian", t.meridian); g.zzz = cacheProcessCtoken("timezone", t.timezone); g.timeSuffix = _.each(_.ignore(g.whiteSpace), _.set([ g.tt, g.zzz ])); g.time = _.each(_.optional(_.ignore(_.stoken("T"))), g.hms, g.timeSuffix); }, dateFormats: function () { // pre-loaded rules for different date part order preferences var _setfn = function () { return _.set(arguments, g.datePartDelimiter); }; var i, RTokenKeys = [ "d", "dd", "M", "MM", "y", "yy", "yyy", "yyyy" ], RToken = [ /^([0-2]\d|3[0-1]|\d)/, /^([0-2]\d|3[0-1])/, /^(1[0-2]|0\d|\d)/, /^(1[0-2]|0\d)/, /^(\d+)/, /^(\d\d)/, /^(\d\d?\d?\d?)/, /^(\d\d\d\d)/ ], tokens = [ t.day, t.day, t.month, t.month, t.year, t.year, t.year, t.year ], eachToken = [ "ordinalSuffix", "ordinalSuffix" ]; for (i=0; i < RTokenKeys.length; i++) { cacheProcessRtoken(RTokenKeys[i], RToken[i], tokens[i], eachToken[i]); } g.MMM = g.MMMM = _.cache(_.process(g.ctoken("jan feb mar apr may jun jul aug sep oct nov dec"), t.month)); g.ddd = g.dddd = _.cache(_.process(g.ctoken("sun mon tue wed thu fri sat"), function (s) { return function () { this.weekday = s; }; } )); g.day = _fn(g.d, g.dd); g.month = _fn(g.M, g.MMM); g.year = _fn(g.yyyy, g.yy); g.mdy = _setfn(g.ddd, g.month, g.day, g.year); g.ymd = _setfn(g.ddd, g.year, g.month, g.day); g.dmy = _setfn(g.ddd, g.day, g.month, g.year); g.date = function (s) { return ((g[Date.CultureInfo.dateElementOrder] || g.mdy).call(this, s)); }; }, relative: function () { // relative date / time expressions g.orientation = _.process(g.ctoken("past future"), function (s) { return function () { this.orient = s; }; } ); g.operator = _.process(g.ctoken("add subtract"), function (s) { return function () { this.operator = s; }; } ); g.rday = _.process(g.ctoken("yesterday tomorrow today now"), t.rday); g.unit = _.process(g.ctoken("second minute hour day week month year"), function (s) { return function () { this.unit = s; }; } ); } }; g.buildGrammarFormats = function () { // these need to be rebuilt every time the language changes. _C = {}; grammarFormats.timeFormats(); grammarFormats.dateFormats(); grammarFormats.relative(); g.value = _.process(_.rtoken(/^([-+]?\d+)?(st|nd|rd|th)?/), function (s) { return function () { this.value = s.replace(/\D/g, ""); }; } ); g.expression = _.set([g.rday, g.operator, g.value, g.unit, g.orientation, g.ddd, g.MMM ]); g.format = _.process(_.many( _.any( // translate format specifiers into grammar rules _.process( _.rtoken(/^(dd?d?d?(?!e)|MM?M?M?|yy?y?y?|hh?|HH?|mm?|ss?|tt?|zz?z?)/), function (fmt) { if (g[fmt]) { return g[fmt]; } else { throw $D.Parsing.Exception(fmt); } } ), // translate separator tokens into token rules _.process(_.rtoken(/^[^dMyhHmstz]+/), // all legal separators function (s) { return _.ignore(_.stoken(s)); } ) ) ), // construct the parser ... function (rules) { return _.process(_.each.apply(null, rules), t.finishExact); } ); // starting rule for general purpose grammar g._start = _.process(_.set([ g.date, g.time, g.expression ], g.generalDelimiter, g.whiteSpace), t.finish); }; g.buildGrammarFormats(); // parsing date format specifiers - ex: "h:m:s tt" // this little guy will generate a custom parser based // on the format string, ex: g.format("h:m:s tt") // check for these formats first g._formats = g.formats([ "\"yyyy-MM-ddTHH:mm:ssZ\"", "yyyy-MM-ddTHH:mm:ss.sz", "yyyy-MM-ddTHH:mm:ssZ", "yyyy-MM-ddTHH:mm:ssz", "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-ddTHH:mmZ", "yyyy-MM-ddTHH:mmz", "yyyy-MM-ddTHH:mm", "ddd, MMM dd, yyyy H:mm:ss tt", "ddd MMM d yyyy HH:mm:ss zzz", "MMddyyyy", "ddMMyyyy", "Mddyyyy", "ddMyyyy", "Mdyyyy", "dMyyyy", "yyyy", "Mdyy", "dMyy", "d" ]); // real starting rule: tries selected formats first, // then general purpose rule g.start = function (s) { try { var r = g._formats.call({}, s); if (r[1].length === 0) { return r; } } catch (e) {} return g._start.call({}, s); }; }()); (function () { var $D = Date; /** * @desc Converts the specified string value into its JavaScript Date equivalent using CultureInfo specific format information. * * Example

	///////////
	// Dates //
	///////////

	// 15-Oct-2004
	var d1 = Date.parse("10/15/2004");

	// 15-Oct-2004
	var d1 = Date.parse("15-Oct-2004");

	// 15-Oct-2004
	var d1 = Date.parse("2004.10.15");

	//Fri Oct 15, 2004
	var d1 = Date.parse("Fri Oct 15, 2004");

	///////////
	// Times //
	///////////

	// Today at 10 PM.
	var d1 = Date.parse("10 PM");

	// Today at 10:30 PM.
	var d1 = Date.parse("10:30 P.M.");

	// Today at 6 AM.
	var d1 = Date.parse("06am");

	/////////////////////
	// Dates and Times //
	/////////////////////

	// 8-July-2004 @ 10:30 PM
	var d1 = Date.parse("July 8th, 2004, 10:30 PM");

	// 1-July-2004 @ 10:30 PM
	var d1 = Date.parse("2004-07-01T22:30:00");

	////////////////////
	// Relative Dates //
	////////////////////

	// Returns today's date. The string "today" is culture specific.
	var d1 = Date.parse("today");

	// Returns yesterday's date. The string "yesterday" is culture specific.
	var d1 = Date.parse("yesterday");

	// Returns the date of the next thursday.
	var d1 = Date.parse("Next thursday");

	// Returns the date of the most previous monday.
	var d1 = Date.parse("last monday");

	// Returns today's day + one year.
	var d1 = Date.parse("next year");

	///////////////
	// Date Math //
	///////////////

	// Today + 2 days
	var d1 = Date.parse("t+2");

	// Today + 2 days
	var d1 = Date.parse("today + 2 days");

	// Today + 3 months
	var d1 = Date.parse("t+3m");

	// Today - 1 year
	var d1 = Date.parse("today - 1 year");

	// Today - 1 year
	var d1 = Date.parse("t-1y"); 


	/////////////////////////////
	// Partial Dates and Times //
	/////////////////////////////

	// July 15th of this year.
	var d1 = Date.parse("July 15");

	// 15th day of current day and year.
	var d1 = Date.parse("15");

	// July 1st of current year at 10pm.
	var d1 = Date.parse("7/1 10pm");
	
* * @param {String} The string value to convert into a Date object [Required] * @return {Date} A Date object or null if the string cannot be converted into a Date. */ var parseUtils = { removeOrds: function (s) { ords = s.match(/\b(\d+)(?:st|nd|rd|th)\b/); // find ordinal matches s = ((ords && ords.length === 2) ? s.replace(ords[0], ords[1]) : s); return s; }, grammarParser: function (s) { var r = null; try { r = $D.Grammar.start.call({}, s.replace(/^\s*(\S*(\s+\S+)*)\s*$/, "$1")); } catch (e) { return null; } return ((r[1].length === 0) ? r[0] : null); }, nativeFallback: function(s) { var t; try { // ok we haven't parsed it, last ditch attempt with the built-in parser. t = Date._parse(s); return (t || t === 0) ? new Date(t) : null; } catch (e) { return null; } } }; function parse (s) { var d; if (!s) { return null; } if (s instanceof Date) { return s.clone(); } if (s.length >= 4 && s.charAt(0) !== "0" && s.charAt(0) !== "+"&& s.charAt(0) !== "-") { // ie: 2004 will pass, 0800 won't. // Start with specific formats d = $D.Parsing.ISO.parse(s) || $D.Parsing.Numeric.parse(s); } if (d instanceof Date && !isNaN(d.getTime())) { return d; } else { // find ordinal dates (1st, 3rd, 8th, etc and remove them as they cause parsing issues) s = $D.Parsing.Normalizer.parse(parseUtils.removeOrds(s)); d = parseUtils.grammarParser(s); if (d !== null) { return d; } else { return parseUtils.nativeFallback(s); } } } if (!$D._parse) { $D._parse = $D.parse; } $D.parse = parse; Date.getParseFunction = function (fx) { var fns = Date.Grammar.allformats(fx); return function (s) { var r = null; for (var i = 0; i < fns.length; i++) { try { r = fns[i].call({}, s); } catch (e) { continue; } if (r[1].length === 0) { return r[0]; } } return null; }; }; /** * Converts the specified string value into its JavaScript Date equivalent using the specified format {String} or formats {Array} and the CultureInfo specific format information. * The format of the string value must match one of the supplied formats exactly. * * Example

	// 15-Oct-2004
	var d1 = Date.parseExact("10/15/2004", "M/d/yyyy");

	// 15-Oct-2004
	var d1 = Date.parse("15-Oct-2004", "M-ddd-yyyy");

	// 15-Oct-2004
	var d1 = Date.parse("2004.10.15", "yyyy.MM.dd");

	// Multiple formats
	var d1 = Date.parseExact("10/15/2004", ["M/d/yyyy", "MMMM d, yyyy"]);
	
* * @param {String} The string value to convert into a Date object [Required]. * @param {Object} The expected format {String} or an array of expected formats {Array} of the date string [Required]. * @return {Date} A Date object or null if the string cannot be converted into a Date. */ $D.parseExact = function (s, fx) { return $D.getParseFunction(fx)(s); }; }()); (function () { var $D = Date, $P = $D.prototype, // $C = $D.CultureInfo, // not used atm p = function (s, l) { if (!l) { l = 2; } return ("000" + s).slice(l * -1); }; /** * Converts a PHP format string to Java/.NET format string. * A PHP format string can be used with ._format or .format. * A Java/.NET format string can be used with .toString(). * The .parseExact function will only accept a Java/.NET format string * * Example * var f1 = "%m/%d/%y" * var f2 = Date.normalizeFormat(f1); // "MM/dd/yy" * * new Date().format(f1); // "04/13/08" * new Date()._format(f1); // "04/13/08" * new Date().toString(f2); // "04/13/08" * * var date = Date.parseExact("04/13/08", f2); // Sun Apr 13 2008 * * @param {String} A PHP format string consisting of one or more format spcifiers. * @return {String} The PHP format converted to a Java/.NET format string. */ var normalizerSubstitutions = { "d" : "dd", "%d": "dd", "D" : "ddd", "%a": "ddd", "j" : "dddd", "l" : "dddd", "%A": "dddd", "S" : "S", "F" : "MMMM", "%B": "MMMM", "m" : "MM", "%m": "MM", "M" : "MMM", "%b": "MMM", "%h": "MMM", "n" : "M", "Y" : "yyyy", "%Y": "yyyy", "y" : "yy", "%y": "yy", "g" : "h", "%I": "h", "G" : "H", "h" : "hh", "H" : "HH", "%H": "HH", "i" : "mm", "%M": "mm", "s" : "ss", "%S": "ss", "%r": "hh:mm tt", "%R": "H:mm", "%T": "H:mm:ss", "%X": "t", "%x": "d", "%e": "d", "%D": "MM/dd/yy", "%n": "\\n", "%t": "\\t", "e" : "z", "T" : "z", "%z": "z", "%Z": "z", "Z" : "ZZ", "N" : "u", "w" : "u", "%w": "u", "W" : "W", "%V": "W" }; var normalizer = { substitutes: function (m) { return normalizerSubstitutions[m]; }, interpreted: function (m, x) { var y; switch (m) { case "%u": return x.getDay() + 1; case "z": return x.getOrdinalNumber(); case "%j": return p(x.getOrdinalNumber(), 3); case "%U": var d1 = x.clone().set({month: 0, day: 1}).addDays(-1).moveToDayOfWeek(0), d2 = x.clone().addDays(1).moveToDayOfWeek(0, -1); return (d2 < d1) ? "00" : p((d2.getOrdinalNumber() - d1.getOrdinalNumber()) / 7 + 1); case "%W": return p(x.getWeek()); case "t": return $D.getDaysInMonth(x.getFullYear(), x.getMonth()); case "o": case "%G": return x.setWeek(x.getISOWeek()).toString("yyyy"); case "%g": return x._format("%G").slice(-2); case "a": case "%p": return t("tt").toLowerCase(); case "A": return t("tt").toUpperCase(); case "u": return p(x.getMilliseconds(), 3); case "I": return (x.isDaylightSavingTime()) ? 1 : 0; case "O": return x.getUTCOffset(); case "P": y = x.getUTCOffset(); return y.substring(0, y.length - 2) + ":" + y.substring(y.length - 2); case "B": var now = new Date(); return Math.floor(((now.getHours() * 3600) + (now.getMinutes() * 60) + now.getSeconds() + (now.getTimezoneOffset() + 60) * 60) / 86.4); case "c": return x.toISOString().replace(/\"/g, ""); case "U": return $D.strtotime("now"); case "%c": return t("d") + " " + t("t"); case "%C": return Math.floor(x.getFullYear() / 100 + 1); } }, shouldOverrideDefaults: function (m) { switch (m) { case "%e": return true; default: return false; } }, parse: function (m, context) { var formatString, c = context || new Date(); formatString = normalizer.substitutes(m); if (formatString) { return formatString; } formatString = normalizer.interpreted(m, c); if (formatString) { return formatString; } else { return m; } } }; $D.normalizeFormat = function (format, context) { return format.replace(/(%|\\)?.|%%/g, function(t){ return normalizer.parse(t, context); }); }; /** * Format a local Unix timestamp according to locale settings * * Example: * Date.strftime("%m/%d/%y", new Date()); // "04/13/08" * Date.strftime("c", "2008-04-13T17:52:03Z"); // "04/13/08" * * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @param {Number|String} The number representing the number of seconds that have elapsed since January 1, 1970 (local time). * @return {String} A string representation of the current Date object. */ $D.strftime = function (format, time) { var d = Date.parse(time); return d._format(format); }; /** * Parse any textual datetime description into a Unix timestamp. * A Unix timestamp is the number of seconds that have elapsed since January 1, 1970 (midnight UTC/GMT). * * Example: * Date.strtotime("04/13/08"); // 1208044800 * Date.strtotime("1970-01-01T00:00:00Z"); // 0 * * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @param {Object} A string or date object. * @return {String} A string representation of the current Date object. */ $D.strtotime = function (time) { var d = $D.parse(time); return Math.round($D.UTC(d.getUTCFullYear(), d.getUTCMonth(), d.getUTCDate(), d.getUTCHours(), d.getUTCMinutes(), d.getUTCSeconds(), d.getUTCMilliseconds()) / 1000); }; /** * Converts the value of the current Date object to its equivalent string representation using a PHP/Unix style of date format specifiers. * Format Specifiers * Format Description Example * ------ --------------------------------------------------------------------------- ----------------------- * %a abbreviated weekday name according to the current localed "Mon" through "Sun" * %A full weekday name according to the current localed "Sunday" through "Saturday" * %b abbreviated month name according to the current localed "Jan" through "Dec" * %B full month name according to the current locale "January" through "December" * %c preferred date and time representation for the current locale "4/13/2008 12:33 PM" * %C century number (the year divided by 100 and truncated to an integer) "00" to "99" * %d day of the month as a decimal number "01" to "31" * %D same as %m/%d/%y "04/13/08" * %e day of the month as a decimal number, a single digit is preceded by a space "1" to "31" * %g like %G, but without the century "08" * %G The 4-digit year corresponding to the ISO week number (see %V). "2008" * This has the same format and value as %Y, except that if the ISO week number * belongs to the previous or next year, that year is used instead. * %h same as %b "Jan" through "Dec" * %H hour as a decimal number using a 24-hour clock. "00" to "23" * %I hour as a decimal number using a 12-hour clock. "01" to "12" * %j day of the year as a decimal number. "001" to "366" * %m month as a decimal number. "01" to "12" * %M minute as a decimal number. "00" to "59" * %n newline character "\n" * %p either "am" or "pm" according to the given time value, or the "am" or "pm" * corresponding strings for the current locale. * %r time in a.m. and p.m. notation "8:44 PM" * %R time in 24 hour notation "20:44" * %S second as a decimal number "00" to "59" * %t tab character "\t" * %T current time, equal to %H:%M:%S "12:49:11" * %u weekday as a decimal number ["1", "7"], with "1" representing Monday "1" to "7" * %U week number of the current year as a decimal number, starting with the "0" to ("52" or "53") * first Sunday as the first day of the first week * %V The ISO 8601:1988 week number of the current year as a decimal number, "00" to ("52" or "53") * range 01 to 53, where week 1 is the first week that has at least 4 days * in the current year, and with Monday as the first day of the week. * (Use %G or %g for the year component that corresponds to the week number * for the specified timestamp.) * %W week number of the current year as a decimal number, starting with the "00" to ("52" or "53") * first Monday as the first day of the first week * %w day of the week as a decimal, Sunday being "0" "0" to "6" * %x preferred date representation for the current locale without the time "4/13/2008" * %X preferred time representation for the current locale without the date "12:53:05" * %y year as a decimal number without a century "00" "99" * %Y year as a decimal number including the century "2008" * %Z time zone or name or abbreviation "UTC", "EST", "PST" * %z same as %Z * %% a literal "%" characters "%" * d Day of the month, 2 digits with leading zeros "01" to "31" * D A textual representation of a day, three letters "Mon" through "Sun" * j Day of the month without leading zeros "1" to "31" * l A full textual representation of the day of the week (lowercase "L") "Sunday" through "Saturday" * N ISO-8601 numeric representation of the day of the week (added in PHP 5.1.0) "1" (for Monday) through "7" (for Sunday) * S English ordinal suffix for the day of the month, 2 characters "st", "nd", "rd" or "th". Works well with j * w Numeric representation of the day of the week "0" (for Sunday) through "6" (for Saturday) * z The day of the year (starting from "0") "0" through "365" * W ISO-8601 week number of year, weeks starting on Monday "00" to ("52" or "53") * F A full textual representation of a month, such as January or March "January" through "December" * m Numeric representation of a month, with leading zeros "01" through "12" * M A short textual representation of a month, three letters "Jan" through "Dec" * n Numeric representation of a month, without leading zeros "1" through "12" * t Number of days in the given month "28" through "31" * L Whether it's a leap year "1" if it is a leap year, "0" otherwise * o ISO-8601 year number. This has the same value as Y, except that if the "2008" * ISO week number (W) belongs to the previous or next year, that year * is used instead. * Y A full numeric representation of a year, 4 digits "2008" * y A two digit representation of a year "08" * a Lowercase Ante meridiem and Post meridiem "am" or "pm" * A Uppercase Ante meridiem and Post meridiem "AM" or "PM" * B Swatch Internet time "000" through "999" * g 12-hour format of an hour without leading zeros "1" through "12" * G 24-hour format of an hour without leading zeros "0" through "23" * h 12-hour format of an hour with leading zeros "01" through "12" * H 24-hour format of an hour with leading zeros "00" through "23" * i Minutes with leading zeros "00" to "59" * s Seconds, with leading zeros "00" through "59" * u Milliseconds "54321" * e Timezone identifier "UTC", "EST", "PST" * I Whether or not the date is in daylight saving time (uppercase i) "1" if Daylight Saving Time, "0" otherwise * O Difference to Greenwich time (GMT) in hours "+0200", "-0600" * P Difference to Greenwich time (GMT) with colon between hours and minutes "+02:00", "-06:00" * T Timezone abbreviation "UTC", "EST", "PST" * Z Timezone offset in seconds. The offset for timezones west of UTC is "-43200" through "50400" * always negative, and for those east of UTC is always positive. * c ISO 8601 date "2004-02-12T15:19:21+00:00" * r RFC 2822 formatted date "Thu, 21 Dec 2000 16:01:07 +0200" * U Seconds since the Unix Epoch (January 1 1970 00:00:00 GMT) "0" * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @return {String} A string representation of the current Date object. */ var formatReplace = function (context) { return function (m) { var formatString, override = false; if (m.charAt(0) === "\\" || m.substring(0, 2) === "%%") { return m.replace("\\", "").replace("%%", "%"); } override = normalizer.shouldOverrideDefaults(m); formatString = $D.normalizeFormat(m, context); if (formatString) { return context.toString(formatString, override); } }; }; $P._format = function (format) { var formatter = formatReplace(this); if (!format) { return this._toString(); } else { return format.replace(/(%|\\)?.|%%/g, formatter); } }; if (!$P.format) { $P.format = $P._format; } }()); (function () { "use strict"; var gFn = function (attr) { return function () { return this[attr]; }; }; var sFn = function (attr) { return function (val) { this[attr] = val; return this; }; }; var attrs = ["years", "months", "days", "hours", "minutes", "seconds", "milliseconds"]; var addSetFuncs = function (context, attrs) { for (var i = 0; i < attrs.length ; i++) { var $a = attrs[i], $b = $a.slice(0, 1).toUpperCase() + $a.slice(1); context.prototype[$a] = 0; context.prototype["get" + $b] = gFn($a); context.prototype["set" + $b] = sFn($a); } }; /** * new TimeSpan(milliseconds); * new TimeSpan(days, hours, minutes, seconds); * new TimeSpan(days, hours, minutes, seconds, milliseconds); */ var TimeSpan = function (days, hours, minutes, seconds, milliseconds) { if (arguments.length === 1 && typeof days === "number") { var orient = (days < 0) ? -1 : +1; var millsLeft = Math.abs(days); this.setDays(Math.floor(millsLeft / 86400000) * orient); millsLeft = millsLeft % 86400000; this.setHours(Math.floor(millsLeft / 3600000) * orient); millsLeft = millsLeft % 3600000; this.setMinutes(Math.floor(millsLeft / 60000) * orient); millsLeft = millsLeft % 60000; this.setSeconds(Math.floor(millsLeft / 1000) * orient); millsLeft = millsLeft % 1000; this.setMilliseconds(millsLeft * orient); } else { this.set(days, hours, minutes, seconds, milliseconds); } this.getTotalMilliseconds = function () { return (this.getDays() * 86400000) + (this.getHours() * 3600000) + (this.getMinutes() * 60000) + (this.getSeconds() * 1000); }; this.compareTo = function (time) { var t1 = new Date(1970, 1, 1, this.getHours(), this.getMinutes(), this.getSeconds()), t2; if (time === null) { t2 = new Date(1970, 1, 1, 0, 0, 0); } else { t2 = new Date(1970, 1, 1, time.getHours(), time.getMinutes(), time.getSeconds()); } return (t1 < t2) ? -1 : (t1 > t2) ? 1 : 0; }; this.equals = function (time) { return (this.compareTo(time) === 0); }; this.add = function (time) { return (time === null) ? this : this.addSeconds(time.getTotalMilliseconds() / 1000); }; this.subtract = function (time) { return (time === null) ? this : this.addSeconds(-time.getTotalMilliseconds() / 1000); }; this.addDays = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 86400000)); }; this.addHours = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 3600000)); }; this.addMinutes = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 60000)); }; this.addSeconds = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 1000)); }; this.addMilliseconds = function (n) { return new TimeSpan(this.getTotalMilliseconds() + n); }; this.get12HourHour = function () { return (this.getHours() > 12) ? this.getHours() - 12 : (this.getHours() === 0) ? 12 : this.getHours(); }; this.getDesignator = function () { return (this.getHours() < 12) ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator; }; this.toString = function (format) { this._toString = function () { if (this.getDays() !== null && this.getDays() > 0) { return this.getDays() + "." + this.getHours() + ":" + this.p(this.getMinutes()) + ":" + this.p(this.getSeconds()); } else { return this.getHours() + ":" + this.p(this.getMinutes()) + ":" + this.p(this.getSeconds()); } }; this.p = function (s) { return (s.toString().length < 2) ? "0" + s : s; }; var me = this; return format ? format.replace(/dd?|HH?|hh?|mm?|ss?|tt?/g, function (format) { switch (format) { case "d": return me.getDays(); case "dd": return me.p(me.getDays()); case "H": return me.getHours(); case "HH": return me.p(me.getHours()); case "h": return me.get12HourHour(); case "hh": return me.p(me.get12HourHour()); case "m": return me.getMinutes(); case "mm": return me.p(me.getMinutes()); case "s": return me.getSeconds(); case "ss": return me.p(me.getSeconds()); case "t": return ((me.getHours() < 12) ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator).substring(0, 1); case "tt": return (me.getHours() < 12) ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator; } } ) : this._toString(); }; return this; }; addSetFuncs(TimeSpan, attrs.slice(2)); TimeSpan.prototype.set = function (days, hours, minutes, seconds, milliseconds){ this.setDays(days || this.getDays()); this.setHours(hours || this.getHours()); this.setMinutes(minutes || this.getMinutes()); this.setSeconds(seconds || this.getSeconds()); this.setMilliseconds(milliseconds || this.getMilliseconds()); }; /** * Gets the time of day for this date instances. * @return {TimeSpan} TimeSpan */ Date.prototype.getTimeOfDay = function () { return new TimeSpan(0, this.getHours(), this.getMinutes(), this.getSeconds(), this.getMilliseconds()); }; Date.TimeSpan = TimeSpan; if (typeof window !== "undefined" ) { // keeping API compatible for v1.x window.TimeSpan = TimeSpan; } }()); (function () { "use strict"; var attrs = ["years", "months", "days", "hours", "minutes", "seconds", "milliseconds"]; var gFn = function (attr) { return function () { return this[attr]; }; }; var sFn = function (attr) { return function (val) { this[attr] = val; return this; }; }; var addSetFuncs = function (context, attrs) { for (var i = 0; i < attrs.length ; i++) { var $a = attrs[i], $b = $a.slice(0, 1).toUpperCase() + $a.slice(1); context.prototype[$a] = 0; context.prototype["get" + $b] = gFn($a); context.prototype["set" + $b] = sFn($a); } }; var setMonthsAndYears = function (orient, d1, d2, context) { function inc() { d1.addMonths(-orient); context.months++; if (context.months === 12) { context.years++; context.months = 0; } } if (orient === +1) { while (d1 > d2) { inc(); } } else { while (d1 < d2) { inc(); } } context.months--; context.months *= orient; context.years *= orient; }; var adjustForDST = function(orient, startDate, endDate) { var hasDSTMismatch = (false === (startDate.isDaylightSavingTime() === endDate.isDaylightSavingTime())); if (hasDSTMismatch && orient === 1) { startDate.addHours(-1); } else if (hasDSTMismatch) { startDate.addHours(1); } }; /** * TimePeriod(startDate, endDate); * TimePeriod(years, months, days, hours, minutes, seconds, milliseconds); */ var TimePeriod = function (years, months, days, hours, minutes, seconds, milliseconds) { if (arguments.length === 7) { this.set(years, months, days, hours, minutes, seconds, milliseconds); } else if (arguments.length === 2 && arguments[0] instanceof Date && arguments[1] instanceof Date) { var startDate = arguments[0].clone(); var endDate = arguments[1].clone(); var orient = (startDate > endDate) ? +1 : -1; this.dates = { start: arguments[0].clone(), end: arguments[1].clone() }; setMonthsAndYears(orient, startDate, endDate, this); adjustForDST(orient, startDate, endDate); // // TODO - adjust for DST var diff = endDate - startDate; if (diff !== 0) { var ts = new TimeSpan(diff); this.set(this.years, this.months, ts.getDays(), ts.getHours(), ts.getMinutes(), ts.getSeconds(), ts.getMilliseconds()); } } return this; }; // create all the set functions. addSetFuncs(TimePeriod, attrs); TimePeriod.prototype.set = function (years, months, days, hours, minutes, seconds, milliseconds){ this.setYears(years || this.getYears()); this.setMonths(months || this.getMonths()); this.setDays(days || this.getDays()); this.setHours(hours || this.getHours()); this.setMinutes(minutes || this.getMinutes()); this.setSeconds(seconds || this.getSeconds()); this.setMilliseconds(milliseconds || this.getMilliseconds()); }; Date.TimePeriod = TimePeriod; if (typeof window !== "undefined") { // keeping API compatible for v1.x window.TimePeriod = TimePeriod; } }()); ================================================ FILE: build/date-en-CA.js ================================================ /** * @overview datejs * @version 1.0.0-rc3 * @author Gregory Wild-Smith * @copyright 2015 Gregory Wild-Smith * @license MIT * @homepage https://github.com/abritinthebay/datejs */ /* * DateJS Culture String File * Country Code: en-CA * Name: English (Canada) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["en-CA"] = { "name": "en-CA", "englishName": "English (Canada)", "nativeName": "English (Canada)", "Sunday": "Sunday", "Monday": "Monday", "Tuesday": "Tuesday", "Wednesday": "Wednesday", "Thursday": "Thursday", "Friday": "Friday", "Saturday": "Saturday", "Sun": "Sun", "Mon": "Mon", "Tue": "Tue", "Wed": "Wed", "Thu": "Thu", "Fri": "Fri", "Sat": "Sat", "Su": "Su", "Mo": "Mo", "Tu": "Tu", "We": "We", "Th": "Th", "Fr": "Fr", "Sa": "Sa", "S_Sun_Initial": "S", "M_Mon_Initial": "M", "T_Tue_Initial": "T", "W_Wed_Initial": "W", "T_Thu_Initial": "T", "F_Fri_Initial": "F", "S_Sat_Initial": "S", "January": "January", "February": "February", "March": "March", "April": "April", "May": "May", "June": "June", "July": "July", "August": "August", "September": "September", "October": "October", "November": "November", "December": "December", "Jan_Abbr": "Jan", "Feb_Abbr": "Feb", "Mar_Abbr": "Mar", "Apr_Abbr": "Apr", "May_Abbr": "May", "Jun_Abbr": "Jun", "Jul_Abbr": "Jul", "Aug_Abbr": "Aug", "Sep_Abbr": "Sep", "Oct_Abbr": "Oct", "Nov_Abbr": "Nov", "Dec_Abbr": "Dec", "AM": "AM", "PM": "PM", "firstDayOfWeek": 0, "twoDigitYearMax": 2029, "mdy": "dmy", "M/d/yyyy": "dd/MM/yyyy", "dddd, MMMM dd, yyyy": "MMMM d, yyyy", "h:mm tt": "h:mm tt", "h:mm:ss tt": "h:mm:ss tt", "dddd, MMMM dd, yyyy h:mm:ss tt": "MMMM d, yyyy h:mm:ss tt", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "MMMM dd", "MMMM, yyyy": "MMMM, yyyy", "/jan(uary)?/": "jan(uary)?", "/feb(ruary)?/": "feb(ruary)?", "/mar(ch)?/": "mar(ch)?", "/apr(il)?/": "apr(il)?", "/may/": "may", "/jun(e)?/": "jun(e)?", "/jul(y)?/": "jul(y)?", "/aug(ust)?/": "aug(ust)?", "/sep(t(ember)?)?/": "sep(t(ember)?)?", "/oct(ober)?/": "oct(ober)?", "/nov(ember)?/": "nov(ember)?", "/dec(ember)?/": "dec(ember)?", "/^su(n(day)?)?/": "^su(n(day)?)?", "/^mo(n(day)?)?/": "^mo(n(day)?)?", "/^tu(e(s(day)?)?)?/": "^tu(e(s(day)?)?)?", "/^we(d(nesday)?)?/": "^we(d(nesday)?)?", "/^th(u(r(s(day)?)?)?)?/": "^th(u(r(s(day)?)?)?)?", "/^fr(i(day)?)?/": "^fr(i(day)?)?", "/^sa(t(urday)?)?/": "^sa(t(urday)?)?", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "en-CA"; /** * @overview datejs * @version 1.0.0-rc3 * @author Gregory Wild-Smith * @copyright 2015 Gregory Wild-Smith * @license MIT * @homepage https://github.com/abritinthebay/datejs */(function () { var $D = Date; var lang = Date.CultureStrings ? Date.CultureStrings.lang : null; var loggedKeys = {}; // for debug purposes. var getText = { getFromKey: function (key, countryCode) { var output; if (Date.CultureStrings && Date.CultureStrings[countryCode] && Date.CultureStrings[countryCode][key]) { output = Date.CultureStrings[countryCode][key]; } else { output = getText.buildFromDefault(key); } if (key.charAt(0) === "/") { // Assume it's a regex output = getText.buildFromRegex(key, countryCode); } return output; }, getFromObjectValues: function (obj, countryCode) { var key, output = {}; for(key in obj) { if (obj.hasOwnProperty(key)) { output[key] = getText.getFromKey(obj[key], countryCode); } } return output; }, getFromObjectKeys: function (obj, countryCode) { var key, output = {}; for(key in obj) { if (obj.hasOwnProperty(key)) { output[getText.getFromKey(key, countryCode)] = obj[key]; } } return output; }, getFromArray: function (arr, countryCode) { var output = []; for (var i=0; i < arr.length; i++){ if (i in arr) { output[i] = getText.getFromKey(arr[i], countryCode); } } return output; }, buildFromDefault: function (key) { var output, length, split, last; switch(key) { case "name": output = "en-US"; break; case "englishName": output = "English (United States)"; break; case "nativeName": output = "English (United States)"; break; case "twoDigitYearMax": output = 2049; break; case "firstDayOfWeek": output = 0; break; default: output = key; split = key.split("_"); length = split.length; if (length > 1 && key.charAt(0) !== "/") { // if the key isn't a regex and it has a split. last = split[(length - 1)].toLowerCase(); if (last === "initial" || last === "abbr") { output = split[0]; } } break; } return output; }, buildFromRegex: function (key, countryCode) { var output; if (Date.CultureStrings && Date.CultureStrings[countryCode] && Date.CultureStrings[countryCode][key]) { output = new RegExp(Date.CultureStrings[countryCode][key], "i"); } else { output = new RegExp(key.replace(new RegExp("/", "g"),""), "i"); } return output; } }; var shallowMerge = function (obj1, obj2) { for (var attrname in obj2) { if (obj2.hasOwnProperty(attrname)) { obj1[attrname] = obj2[attrname]; } } }; var __ = function (key, language) { var countryCode = (language) ? language : lang; loggedKeys[key] = key; if (typeof key === "object") { if (key instanceof Array) { return getText.getFromArray(key, countryCode); } else { return getText.getFromObjectKeys(key, countryCode); } } else { return getText.getFromKey(key, countryCode); } }; var loadI18nScript = function (code) { // paatterned after jQuery's getScript. var url = Date.Config.i18n + code + ".js"; var head = document.getElementsByTagName("head")[0] || document.documentElement; var script = document.createElement("script"); script.src = url; var completed = false; var events = { done: function (){} // placeholder function }; // Attach handlers for all browsers script.onload = script.onreadystatechange = function() { if ( !completed && (!this.readyState || this.readyState === "loaded" || this.readyState === "complete") ) { events.done(); head.removeChild(script); } }; setTimeout(function() { head.insertBefore(script, head.firstChild); }, 0); // allows return to execute first return { done: function (cb) { events.done = function() { if (cb) { setTimeout(cb,0); } }; } }; }; var buildInfo = { buildFromMethodHash: function (obj) { var key; for(key in obj) { if (obj.hasOwnProperty(key)) { obj[key] = buildInfo[obj[key]](); } } return obj; }, timeZoneDST: function () { var DST = { "CHADT": "+1345", "NZDT": "+1300", "AEDT": "+1100", "ACDT": "+1030", "AZST": "+0500", "IRDT": "+0430", "EEST": "+0300", "CEST": "+0200", "BST": "+0100", "PMDT": "-0200", "ADT": "-0300", "NDT": "-0230", "EDT": "-0400", "CDT": "-0500", "MDT": "-0600", "PDT": "-0700", "AKDT": "-0800", "HADT": "-0900" }; return __(DST); }, timeZoneStandard: function () { var standard = { "LINT": "+1400", "TOT": "+1300", "CHAST": "+1245", "NZST": "+1200", "NFT": "+1130", "SBT": "+1100", "AEST": "+1000", "ACST": "+0930", "JST": "+0900", "CWST": "+0845", "CT": "+0800", "ICT": "+0700", "MMT": "+0630", "BST": "+0600", "NPT": "+0545", "IST": "+0530", "PKT": "+0500", "AFT": "+0430", "MSK": "+0400", "IRST": "+0330", "FET": "+0300", "EET": "+0200", "CET": "+0100", "GMT": "+0000", "UTC": "+0000", "CVT": "-0100", "GST": "-0200", "BRT": "-0300", "NST": "-0330", "AST": "-0400", "EST": "-0500", "CST": "-0600", "MST": "-0700", "PST": "-0800", "AKST": "-0900", "MIT": "-0930", "HST": "-1000", "SST": "-1100", "BIT": "-1200" }; return __(standard); }, timeZones: function (data) { var zone; data.timezones = []; for (zone in data.abbreviatedTimeZoneStandard) { if (data.abbreviatedTimeZoneStandard.hasOwnProperty(zone)) { data.timezones.push({ name: zone, offset: data.abbreviatedTimeZoneStandard[zone]}); } } for (zone in data.abbreviatedTimeZoneDST) { if (data.abbreviatedTimeZoneDST.hasOwnProperty(zone)) { data.timezones.push({ name: zone, offset: data.abbreviatedTimeZoneDST[zone], dst: true}); } } return data.timezones; }, days: function () { return __(["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"]); }, dayAbbr: function () { return __(["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"]); }, dayShortNames: function () { return __(["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"]); }, dayFirstLetters: function () { return __(["S_Sun_Initial", "M_Mon_Initial", "T_Tues_Initial", "W_Wed_Initial", "T_Thu_Initial", "F_Fri_Initial", "S_Sat_Initial"]); }, months: function () { return __(["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"]); }, monthAbbr: function () { return __(["Jan_Abbr", "Feb_Abbr", "Mar_Abbr", "Apr_Abbr", "May_Abbr", "Jun_Abbr", "Jul_Abbr", "Aug_Abbr", "Sep_Abbr", "Oct_Abbr", "Nov_Abbr", "Dec_Abbr"]); }, formatPatterns: function () { return getText.getFromObjectValues({ shortDate: "M/d/yyyy", longDate: "dddd, MMMM dd, yyyy", shortTime: "h:mm tt", longTime: "h:mm:ss tt", fullDateTime: "dddd, MMMM dd, yyyy h:mm:ss tt", sortableDateTime: "yyyy-MM-ddTHH:mm:ss", universalSortableDateTime: "yyyy-MM-dd HH:mm:ssZ", rfc1123: "ddd, dd MMM yyyy HH:mm:ss", monthDay: "MMMM dd", yearMonth: "MMMM, yyyy" }, Date.i18n.currentLanguage()); }, regex: function () { return getText.getFromObjectValues({ inTheMorning: "/( in the )(morn(ing)?)\\b/", thisMorning: "/(this )(morn(ing)?)\\b/", amThisMorning: "/(\b\\d(am)? )(this )(morn(ing)?)/", inTheEvening: "/( in the )(even(ing)?)\\b/", thisEvening: "/(this )(even(ing)?)\\b/", pmThisEvening: "/(\b\\d(pm)? )(this )(even(ing)?)/", jan: "/jan(uary)?/", feb: "/feb(ruary)?/", mar: "/mar(ch)?/", apr: "/apr(il)?/", may: "/may/", jun: "/jun(e)?/", jul: "/jul(y)?/", aug: "/aug(ust)?/", sep: "/sep(t(ember)?)?/", oct: "/oct(ober)?/", nov: "/nov(ember)?/", dec: "/dec(ember)?/", sun: "/^su(n(day)?)?/", mon: "/^mo(n(day)?)?/", tue: "/^tu(e(s(day)?)?)?/", wed: "/^we(d(nesday)?)?/", thu: "/^th(u(r(s(day)?)?)?)?/", fri: "/fr(i(day)?)?/", sat: "/^sa(t(urday)?)?/", future: "/^next/", past: "/^last|past|prev(ious)?/", add: "/^(\\+|aft(er)?|from|hence)/", subtract: "/^(\\-|bef(ore)?|ago)/", yesterday: "/^yes(terday)?/", today: "/^t(od(ay)?)?/", tomorrow: "/^tom(orrow)?/", now: "/^n(ow)?/", millisecond: "/^ms|milli(second)?s?/", second: "/^sec(ond)?s?/", minute: "/^mn|min(ute)?s?/", hour: "/^h(our)?s?/", week: "/^w(eek)?s?/", month: "/^m(onth)?s?/", day: "/^d(ay)?s?/", year: "/^y(ear)?s?/", shortMeridian: "/^(a|p)/", longMeridian: "/^(a\\.?m?\\.?|p\\.?m?\\.?)/", timezone: "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/", ordinalSuffix: "/^\\s*(st|nd|rd|th)/", timeContext: "/^\\s*(\\:|a(?!u|p)|p)/" }, Date.i18n.currentLanguage()); } }; var CultureInfo = function () { var info = getText.getFromObjectValues({ name: "name", englishName: "englishName", nativeName: "nativeName", amDesignator: "AM", pmDesignator: "PM", firstDayOfWeek: "firstDayOfWeek", twoDigitYearMax: "twoDigitYearMax", dateElementOrder: "mdy" }, Date.i18n.currentLanguage()); var constructedInfo = buildInfo.buildFromMethodHash({ dayNames: "days", abbreviatedDayNames: "dayAbbr", shortestDayNames: "dayShortNames", firstLetterDayNames: "dayFirstLetters", monthNames: "months", abbreviatedMonthNames: "monthAbbr", formatPatterns: "formatPatterns", regexPatterns: "regex", abbreviatedTimeZoneDST: "timeZoneDST", abbreviatedTimeZoneStandard: "timeZoneStandard" }); shallowMerge(info, constructedInfo); buildInfo.timeZones(info); return info; }; $D.i18n = { __: function (key, lang) { return __(key, lang); }, currentLanguage: function () { return lang || "en-US"; }, setLanguage: function (code, force, cb) { var async = false; if (force || code === "en-US" || (!!Date.CultureStrings && !!Date.CultureStrings[code])) { lang = code; Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings.lang = code; Date.CultureInfo = new CultureInfo(); } else { if (!(!!Date.CultureStrings && !!Date.CultureStrings[code])) { if (typeof exports !== "undefined" && this.exports !== exports) { // we're in a Node enviroment, load it using require try { require("../i18n/" + code + ".js"); lang = code; Date.CultureStrings.lang = code; Date.CultureInfo = new CultureInfo(); } catch (e) { // var str = "The language for '" + code + "' could not be loaded by Node. It likely does not exist."; throw new Error("The DateJS IETF language tag '" + code + "' could not be loaded by Node. It likely does not exist."); } } else if (Date.Config && Date.Config.i18n) { // we know the location of the files, so lets load them async = true; loadI18nScript(code).done(function(){ lang = code; Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings.lang = code; Date.CultureInfo = new CultureInfo(); $D.Parsing.Normalizer.buildReplaceData(); // because this is async if ($D.Grammar) { $D.Grammar.buildGrammarFormats(); // so we can parse those strings... } if (cb) { setTimeout(cb,0); } }); } else { Date.console.error("The DateJS IETF language tag '" + code + "' is not available and has not been loaded."); return false; } } } $D.Parsing.Normalizer.buildReplaceData(); // rebuild normalizer strings if ($D.Grammar) { $D.Grammar.buildGrammarFormats(); // so we can parse those strings... } if (!async && cb) { setTimeout(cb,0); } }, getLoggedKeys: function () { return loggedKeys; }, updateCultureInfo: function () { Date.CultureInfo = new CultureInfo(); } }; $D.i18n.updateCultureInfo(); // run automatically }()); (function () { var $D = Date, $P = $D.prototype, p = function (s, l) { if (!l) { l = 2; } return ("000" + s).slice(l * -1); }; if (typeof window !== "undefined" && typeof window.console !== "undefined" && typeof window.console.log !== "undefined") { $D.console = console; // used only to raise non-critical errors if available } else { // set mock so we don't give errors. $D.console = { log: function(){}, error: function(){} }; } $D.Config = $D.Config || {}; $D.initOverloads = function() { /** * Overload of Date.now. Allows an alternate call for Date.now where it returns the * current Date as an object rather than just milliseconds since the Unix Epoch. * * Also provides an implementation of now() for browsers (IE<9) that don't have it. * * Backwards compatible so with work with either: * Date.now() [returns ms] * or * Date.now(true) [returns Date] */ if (!$D.now) { $D._now = function now() { return new Date().getTime(); }; } else if (!$D._now) { $D._now = $D.now; } $D.now = function (returnObj) { if (returnObj) { return $D.present(); } else { return $D._now(); } }; if ( !$P.toISOString ) { $P.toISOString = function() { return this.getUTCFullYear() + "-" + p(this.getUTCMonth() + 1) + "-" + p(this.getUTCDate()) + "T" + p(this.getUTCHours()) + ":" + p(this.getUTCMinutes()) + ":" + p(this.getUTCSeconds()) + "." + String( (this.getUTCMilliseconds()/1000).toFixed(3)).slice(2, 5) + "Z"; }; } // private if ( $P._toString === undefined ){ $P._toString = $P.toString; } }; $D.initOverloads(); /** * Gets a date that is set to the current date. The time is set to the start of the day (00:00 or 12:00 AM). * @return {Date} The current date. */ $D.today = function () { return new Date().clearTime(); }; /** * Gets a date that is set to the current date and time (same as new Date, but chainable) * @return {Date} The current date. */ $D.present = function () { return new Date(); }; /** * Compares the first date to the second date and returns an number indication of their relative values. * @param {Date} First Date object to compare [Required]. * @param {Date} Second Date object to compare to [Required]. * @return {Number} -1 = date1 is lessthan date2. 0 = values are equal. 1 = date1 is greaterthan date2. */ $D.compare = function (date1, date2) { if (isNaN(date1) || isNaN(date2)) { throw new Error(date1 + " - " + date2); } else if (date1 instanceof Date && date2 instanceof Date) { return (date1 < date2) ? -1 : (date1 > date2) ? 1 : 0; } else { throw new TypeError(date1 + " - " + date2); } }; /** * Compares the first Date object to the second Date object and returns true if they are equal. * @param {Date} First Date object to compare [Required] * @param {Date} Second Date object to compare to [Required] * @return {Boolean} true if dates are equal. false if they are not equal. */ $D.equals = function (date1, date2) { return (date1.compareTo(date2) === 0); }; /** * Gets the language appropriate day name when given the day number(0-6) * eg - 0 == Sunday * @return {String} The day name */ $D.getDayName = function (n) { return Date.CultureInfo.dayNames[n]; }; /** * Gets the day number (0-6) if given a CultureInfo specific string which is a valid dayName, abbreviatedDayName or shortestDayName (two char). * @param {String} The name of the day (eg. "Monday, "Mon", "tuesday", "tue", "We", "we"). * @return {Number} The day number */ $D.getDayNumberFromName = function (name) { var n = Date.CultureInfo.dayNames, m = Date.CultureInfo.abbreviatedDayNames, o = Date.CultureInfo.shortestDayNames, s = name.toLowerCase(); for (var i = 0; i < n.length; i++) { if (n[i].toLowerCase() === s || m[i].toLowerCase() === s || o[i].toLowerCase() === s) { return i; } } return -1; }; /** * Gets the month number (0-11) if given a Culture Info specific string which is a valid monthName or abbreviatedMonthName. * @param {String} The name of the month (eg. "February, "Feb", "october", "oct"). * @return {Number} The day number */ $D.getMonthNumberFromName = function (name) { var n = Date.CultureInfo.monthNames, m = Date.CultureInfo.abbreviatedMonthNames, s = name.toLowerCase(); for (var i = 0; i < n.length; i++) { if (n[i].toLowerCase() === s || m[i].toLowerCase() === s) { return i; } } return -1; }; /** * Gets the language appropriate month name when given the month number(0-11) * eg - 0 == January * @return {String} The month name */ $D.getMonthName = function (n) { return Date.CultureInfo.monthNames[n]; }; /** * Determines if the current date instance is within a LeapYear. * @param {Number} The year. * @return {Boolean} true if date is within a LeapYear, otherwise false. */ $D.isLeapYear = function (year) { return ((year % 4 === 0 && year % 100 !== 0) || year % 400 === 0); }; /** * Gets the number of days in the month, given a year and month value. Automatically corrects for LeapYear. * @param {Number} The year. * @param {Number} The month (0-11). * @return {Number} The number of days in the month. */ $D.getDaysInMonth = function (year, month) { if (!month && $D.validateMonth(year)) { month = year; year = Date.today().getFullYear(); } return [31, ($D.isLeapYear(year) ? 29 : 28), 31, 30, 31, 30, 31, 31, 30, 31, 30, 31][month]; }; $P.getDaysInMonth = function () { return $D.getDaysInMonth(this.getFullYear(), this.getMonth()); }; $D.getTimezoneAbbreviation = function (offset, dst) { var p, n = (dst || false) ? Date.CultureInfo.abbreviatedTimeZoneDST : Date.CultureInfo.abbreviatedTimeZoneStandard; for (p in n) { if (n.hasOwnProperty(p)) { if (n[p] === offset) { return p; } } } return null; }; $D.getTimezoneOffset = function (name, dst) { var i, a =[], z = Date.CultureInfo.timezones; if (!name) { name = (new Date()).getTimezone();} for (i = 0; i < z.length; i++) { if (z[i].name === name.toUpperCase()) { a.push(i); } } if (!z[a[0]]) { return null; } if (a.length === 1 || !dst) { return z[a[0]].offset; } else { for (i=0; i < a.length; i++) { if (z[a[i]].dst) { return z[a[i]].offset; } } } }; $D.getQuarter = function (d) { d = d || new Date(); // If no date supplied, use today var q = [1,2,3,4]; return q[Math.floor(d.getMonth() / 3)]; // ~~~ is a bitwise op. Faster than Math.floor }; $D.getDaysLeftInQuarter = function (d) { d = d || new Date(); var qEnd = new Date(d); qEnd.setMonth(qEnd.getMonth() + 3 - qEnd.getMonth() % 3, 0); return Math.floor((qEnd - d) / 8.64e7); }; // private var validate = function (n, min, max, name) { name = name ? name : "Object"; if (typeof n === "undefined") { return false; } else if (typeof n !== "number") { throw new TypeError(n + " is not a Number."); } else if (n < min || n > max) { // As failing validation is *not* an exceptional circumstance // lets not throw a RangeError Exception here. // It's semantically correct but it's not sensible. return false; } return true; }; /** * Validates the number is within an acceptable range for milliseconds [0-999]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateMillisecond = function (value) { return validate(value, 0, 999, "millisecond"); }; /** * Validates the number is within an acceptable range for seconds [0-59]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateSecond = function (value) { return validate(value, 0, 59, "second"); }; /** * Validates the number is within an acceptable range for minutes [0-59]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateMinute = function (value) { return validate(value, 0, 59, "minute"); }; /** * Validates the number is within an acceptable range for hours [0-23]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateHour = function (value) { return validate(value, 0, 23, "hour"); }; /** * Validates the number is within an acceptable range for the days in a month [0-MaxDaysInMonth]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateDay = function (value, year, month) { if (year === undefined || year === null || month === undefined || month === null) { return false;} return validate(value, 1, $D.getDaysInMonth(year, month), "day"); }; /** * Validates the number is within an acceptable range for months [0-11]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateWeek = function (value) { return validate(value, 0, 53, "week"); }; /** * Validates the number is within an acceptable range for months [0-11]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateMonth = function (value) { return validate(value, 0, 11, "month"); }; /** * Validates the number is within an acceptable range for years. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateYear = function (value) { /** * Per ECMAScript spec the range of times supported by Date objects is * exactly -100,000,000 days to +100,000,000 days measured relative to * midnight at the beginning of 01 January, 1970 UTC. * This gives a range of 8,640,000,000,000,000 milliseconds to either * side of 01 January, 1970 UTC. * * Earliest possible date: Tue, 20 Apr 271,822 B.C. 00:00:00 UTC * Latest possible date: Sat, 13 Sep 275,760 00:00:00 UTC */ return validate(value, -271822, 275760, "year"); }; $D.validateTimezone = function(value) { var timezones = {"ACDT":1,"ACST":1,"ACT":1,"ADT":1,"AEDT":1,"AEST":1,"AFT":1,"AKDT":1,"AKST":1,"AMST":1,"AMT":1,"ART":1,"AST":1,"AWDT":1,"AWST":1,"AZOST":1,"AZT":1,"BDT":1,"BIOT":1,"BIT":1,"BOT":1,"BRT":1,"BST":1,"BTT":1,"CAT":1,"CCT":1,"CDT":1,"CEDT":1,"CEST":1,"CET":1,"CHADT":1,"CHAST":1,"CHOT":1,"ChST":1,"CHUT":1,"CIST":1,"CIT":1,"CKT":1,"CLST":1,"CLT":1,"COST":1,"COT":1,"CST":1,"CT":1,"CVT":1,"CWST":1,"CXT":1,"DAVT":1,"DDUT":1,"DFT":1,"EASST":1,"EAST":1,"EAT":1,"ECT":1,"EDT":1,"EEDT":1,"EEST":1,"EET":1,"EGST":1,"EGT":1,"EIT":1,"EST":1,"FET":1,"FJT":1,"FKST":1,"FKT":1,"FNT":1,"GALT":1,"GAMT":1,"GET":1,"GFT":1,"GILT":1,"GIT":1,"GMT":1,"GST":1,"GYT":1,"HADT":1,"HAEC":1,"HAST":1,"HKT":1,"HMT":1,"HOVT":1,"HST":1,"ICT":1,"IDT":1,"IOT":1,"IRDT":1,"IRKT":1,"IRST":1,"IST":1,"JST":1,"KGT":1,"KOST":1,"KRAT":1,"KST":1,"LHST":1,"LINT":1,"MAGT":1,"MART":1,"MAWT":1,"MDT":1,"MET":1,"MEST":1,"MHT":1,"MIST":1,"MIT":1,"MMT":1,"MSK":1,"MST":1,"MUT":1,"MVT":1,"MYT":1,"NCT":1,"NDT":1,"NFT":1,"NPT":1,"NST":1,"NT":1,"NUT":1,"NZDT":1,"NZST":1,"OMST":1,"ORAT":1,"PDT":1,"PET":1,"PETT":1,"PGT":1,"PHOT":1,"PHT":1,"PKT":1,"PMDT":1,"PMST":1,"PONT":1,"PST":1,"PYST":1,"PYT":1,"RET":1,"ROTT":1,"SAKT":1,"SAMT":1,"SAST":1,"SBT":1,"SCT":1,"SGT":1,"SLST":1,"SRT":1,"SST":1,"SYOT":1,"TAHT":1,"THA":1,"TFT":1,"TJT":1,"TKT":1,"TLT":1,"TMT":1,"TOT":1,"TVT":1,"UCT":1,"ULAT":1,"UTC":1,"UYST":1,"UYT":1,"UZT":1,"VET":1,"VLAT":1,"VOLT":1,"VOST":1,"VUT":1,"WAKT":1,"WAST":1,"WAT":1,"WEDT":1,"WEST":1,"WET":1,"WST":1,"YAKT":1,"YEKT":1,"Z":1}; return (timezones[value] === 1); }; $D.validateTimezoneOffset= function(value) { // timezones go from +14hrs to -12hrs, the +X hours are negative offsets. return (value > -841 && value < 721); }; }()); (function () { var $D = Date, $P = $D.prototype, p = function (s, l) { if (!l) { l = 2; } return ("000" + s).slice(l * -1); }; var validateConfigObject = function (obj) { var result = {}, self = this, prop, testFunc; testFunc = function (prop, func, value) { if (prop === "day") { var month = (obj.month !== undefined) ? obj.month : self.getMonth(); var year = (obj.year !== undefined) ? obj.year : self.getFullYear(); return $D[func](value, year, month); } else { return $D[func](value); } }; for (prop in obj) { if (Object.prototype.hasOwnProperty.call(obj, prop)) { var func = "validate" + prop.charAt(0).toUpperCase() + prop.slice(1); if ($D[func] && obj[prop] !== null && testFunc(prop, func, obj[prop])) { result[prop] = obj[prop]; } } } return result; }; /** * Resets the time of this Date object to 12:00 AM (00:00), which is the start of the day. * @param {Boolean} .clone() this date instance before clearing Time * @return {Date} this */ $P.clearTime = function () { this.setHours(0); this.setMinutes(0); this.setSeconds(0); this.setMilliseconds(0); return this; }; /** * Resets the time of this Date object to the current time ('now'). * @return {Date} this */ $P.setTimeToNow = function () { var n = new Date(); this.setHours(n.getHours()); this.setMinutes(n.getMinutes()); this.setSeconds(n.getSeconds()); this.setMilliseconds(n.getMilliseconds()); return this; }; /** * Returns a new Date object that is an exact date and time copy of the original instance. * @return {Date} A new Date instance */ $P.clone = function () { return new Date(this.getTime()); }; /** * Compares this instance to a Date object and returns an number indication of their relative values. * @param {Date} Date object to compare [Required] * @return {Number} -1 = this is lessthan date. 0 = values are equal. 1 = this is greaterthan date. */ $P.compareTo = function (date) { return Date.compare(this, date); }; /** * Compares this instance to another Date object and returns true if they are equal. * @param {Date} Date object to compare. If no date to compare, new Date() [now] is used. * @return {Boolean} true if dates are equal. false if they are not equal. */ $P.equals = function (date) { return Date.equals(this, (date !== undefined ? date : new Date())); }; /** * Determines if this instance is between a range of two dates or equal to either the start or end dates. * @param {Date} Start of range [Required] * @param {Date} End of range [Required] * @return {Boolean} true is this is between or equal to the start and end dates, else false */ $P.between = function (start, end) { return this.getTime() >= start.getTime() && this.getTime() <= end.getTime(); }; /** * Determines if this date occurs after the date to compare to. * @param {Date} Date object to compare. If no date to compare, new Date() ("now") is used. * @return {Boolean} true if this date instance is greater than the date to compare to (or "now"), otherwise false. */ $P.isAfter = function (date) { return this.compareTo(date || new Date()) === 1; }; /** * Determines if this date occurs before the date to compare to. * @param {Date} Date object to compare. If no date to compare, new Date() ("now") is used. * @return {Boolean} true if this date instance is less than the date to compare to (or "now"). */ $P.isBefore = function (date) { return (this.compareTo(date || new Date()) === -1); }; /** * Determines if the current Date instance occurs today. * @return {Boolean} true if this date instance is 'today', otherwise false. */ /** * Determines if the current Date instance occurs on the same Date as the supplied 'date'. * If no 'date' to compare to is provided, the current Date instance is compared to 'today'. * @param {date} Date object to compare. If no date to compare, the current Date ("now") is used. * @return {Boolean} true if this Date instance occurs on the same Day as the supplied 'date'. */ $P.isToday = $P.isSameDay = function (date) { return this.clone().clearTime().equals((date || new Date()).clone().clearTime()); }; /** * Adds the specified number of milliseconds to this instance. * @param {Number} The number of milliseconds to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addMilliseconds = function (value) { if (!value) { return this; } this.setTime(this.getTime() + value * 1); return this; }; /** * Adds the specified number of seconds to this instance. * @param {Number} The number of seconds to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addSeconds = function (value) { if (!value) { return this; } return this.addMilliseconds(value * 1000); }; /** * Adds the specified number of seconds to this instance. * @param {Number} The number of seconds to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addMinutes = function (value) { if (!value) { return this; } return this.addMilliseconds(value * 60000); // 60*1000 }; /** * Adds the specified number of hours to this instance. * @param {Number} The number of hours to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addHours = function (value) { if (!value) { return this; } return this.addMilliseconds(value * 3600000); // 60*60*1000 }; /** * Adds the specified number of days to this instance. * @param {Number} The number of days to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addDays = function (value) { if (!value) { return this; } this.setDate(this.getDate() + value * 1); return this; }; /** * Adds the specified number of weekdays (ie - not sat or sun) to this instance. * @param {Number} The number of days to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addWeekdays = function (value) { if (!value) { return this; } var day = this.getDay(); var weeks = (Math.ceil(Math.abs(value)/7)); if (day === 0 || day === 6) { if (value > 0) { this.next().monday(); this.addDays(-1); day = this.getDay(); } } if (value < 0) { while (value < 0) { this.addDays(-1); day = this.getDay(); if (day !== 0 && day !== 6) { value++; } } return this; } else if (value > 5 || (6-day) <= value) { value = value + (weeks * 2); } return this.addDays(value); }; /** * Adds the specified number of weeks to this instance. * @param {Number} The number of weeks to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addWeeks = function (value) { if (!value) { return this; } return this.addDays(value * 7); }; /** * Adds the specified number of months to this instance. * @param {Number} The number of months to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addMonths = function (value) { if (!value) { return this; } var n = this.getDate(); this.setDate(1); this.setMonth(this.getMonth() + value * 1); this.setDate(Math.min(n, $D.getDaysInMonth(this.getFullYear(), this.getMonth()))); return this; }; $P.addQuarters = function (value) { if (!value) { return this; } // note this will take you to the same point in the quarter as you are now. // i.e. - if you are 15 days into the quarter you'll be 15 days into the resulting one. // bonus: this allows adding fractional quarters return this.addMonths(value * 3); }; /** * Adds the specified number of years to this instance. * @param {Number} The number of years to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addYears = function (value) { if (!value) { return this; } return this.addMonths(value * 12); }; /** * Adds (or subtracts) to the value of the years, months, weeks, days, hours, minutes, seconds, milliseconds of the date instance using given configuration object. Positive and Negative values allowed. * Example

	Date.today().add( { days: 1, months: 1 } )

	new Date().add( { years: -1 } )
	
* @param {Object} Configuration object containing attributes (months, days, etc.) * @return {Date} this */ $P.add = function (config) { if (typeof config === "number") { this._orient = config; return this; } var x = config; if (x.day) { // If we should be a different date than today (eg: for 'tomorrow -1d', etc). // Should only effect parsing, not direct usage (eg, Finish and FinishExact) if ((x.day - this.getDate()) !== 0) { this.setDate(x.day); } } if (x.milliseconds) { this.addMilliseconds(x.milliseconds); } if (x.seconds) { this.addSeconds(x.seconds); } if (x.minutes) { this.addMinutes(x.minutes); } if (x.hours) { this.addHours(x.hours); } if (x.weeks) { this.addWeeks(x.weeks); } if (x.months) { this.addMonths(x.months); } if (x.years) { this.addYears(x.years); } if (x.days) { this.addDays(x.days); } return this; }; /** * Get the week number. Week one (1) is the week which contains the first Thursday of the year. Monday is considered the first day of the week. * The .getWeek() function does NOT convert the date to UTC. The local datetime is used. * Please use .getISOWeek() to get the week of the UTC converted date. * @return {Number} 1 to 53 */ $P.getWeek = function (utc) { // Create a copy of this date object var self, target = new Date(this.valueOf()); if (utc) { target.addMinutes(target.getTimezoneOffset()); self = target.clone(); } else { self = this; } // ISO week date weeks start on monday // so correct the day number var dayNr = (self.getDay() + 6) % 7; // ISO 8601 states that week 1 is the week // with the first thursday of that year. // Set the target date to the thursday in the target week target.setDate(target.getDate() - dayNr + 3); // Store the millisecond value of the target date var firstThursday = target.valueOf(); // Set the target to the first thursday of the year // First set the target to january first target.setMonth(0, 1); // Not a thursday? Correct the date to the next thursday if (target.getDay() !== 4) { target.setMonth(0, 1 + ((4 - target.getDay()) + 7) % 7); } // The weeknumber is the number of weeks between the // first thursday of the year and the thursday in the target week return 1 + Math.ceil((firstThursday - target) / 604800000); // 604800000 = 7 * 24 * 3600 * 1000 }; /** * Get the ISO 8601 week number. Week one ("01") is the week which contains the first Thursday of the year. Monday is considered the first day of the week. * The .getISOWeek() function does convert the date to it's UTC value. Please use .getWeek() to get the week of the local date. * @return {String} "01" to "53" */ $P.getISOWeek = function () { return p(this.getWeek(true)); }; /** * Moves the date to Monday of the week set. Week one (1) is the week which contains the first Thursday of the year. * @param {Number} A Number (1 to 53) that represents the week of the year. * @return {Date} this */ $P.setWeek = function (n) { if ((n - this.getWeek()) === 0) { if (this.getDay() !== 1) { return this.moveToDayOfWeek(1, (this.getDay() > 1 ? -1 : 1)); } else { return this; } } else { return this.moveToDayOfWeek(1, (this.getDay() > 1 ? -1 : 1)).addWeeks(n - this.getWeek()); } }; $P.setQuarter = function (qtr) { var month = Math.abs(((qtr-1) * 3) + 1); return this.setMonth(month, 1); }; $P.getQuarter = function () { return Date.getQuarter(this); }; $P.getDaysLeftInQuarter = function () { return Date.getDaysLeftInQuarter(this); }; /** * Moves the date to the next n'th occurrence of the dayOfWeek starting from the beginning of the month. The number (-1) is a magic number and will return the last occurrence of the dayOfWeek in the month. * @param {Number} The dayOfWeek to move to * @param {Number} The n'th occurrence to move to. Use (-1) to return the last occurrence in the month * @return {Date} this */ $P.moveToNthOccurrence = function (dayOfWeek, occurrence) { if (dayOfWeek === "Weekday") { if (occurrence > 0) { this.moveToFirstDayOfMonth(); if (this.is().weekday()) { occurrence -= 1; } } else if (occurrence < 0) { this.moveToLastDayOfMonth(); if (this.is().weekday()) { occurrence += 1; } } else { return this; } return this.addWeekdays(occurrence); } var shift = 0; if (occurrence > 0) { shift = occurrence - 1; } else if (occurrence === -1) { this.moveToLastDayOfMonth(); if (this.getDay() !== dayOfWeek) { this.moveToDayOfWeek(dayOfWeek, -1); } return this; } return this.moveToFirstDayOfMonth().addDays(-1).moveToDayOfWeek(dayOfWeek, +1).addWeeks(shift); }; var moveToN = function (getFunc, addFunc, nVal) { return function (value, orient) { var diff = (value - this[getFunc]() + nVal * (orient || +1)) % nVal; return this[addFunc]((diff === 0) ? diff += nVal * (orient || +1) : diff); }; }; /** * Move to the next or last dayOfWeek based on the orient value. * @param {Number} The dayOfWeek to move to * @param {Number} Forward (+1) or Back (-1). Defaults to +1. [Optional] * @return {Date} this */ $P.moveToDayOfWeek = moveToN("getDay", "addDays", 7); /** * Move to the next or last month based on the orient value. * @param {Number} The month to move to. 0 = January, 11 = December * @param {Number} Forward (+1) or Back (-1). Defaults to +1. [Optional] * @return {Date} this */ $P.moveToMonth = moveToN("getMonth", "addMonths", 12); /** * Get the Ordinate of the current day ("th", "st", "rd"). * @return {String} */ $P.getOrdinate = function () { var num = this.getDate(); return ord(num); }; /** * Get the Ordinal day (numeric day number) of the year, adjusted for leap year. * @return {Number} 1 through 365 (366 in leap years) */ $P.getOrdinalNumber = function () { return Math.ceil((this.clone().clearTime() - new Date(this.getFullYear(), 0, 1)) / 86400000) + 1; }; /** * Get the time zone abbreviation of the current date. * @return {String} The abbreviated time zone name (e.g. "EST") */ $P.getTimezone = function () { return $D.getTimezoneAbbreviation(this.getUTCOffset(), this.isDaylightSavingTime()); }; $P.setTimezoneOffset = function (offset) { var here = this.getTimezoneOffset(), there = Number(offset) * -6 / 10; return (there || there === 0) ? this.addMinutes(there - here) : this; }; $P.setTimezone = function (offset) { return this.setTimezoneOffset($D.getTimezoneOffset(offset)); }; /** * Indicates whether Daylight Saving Time is observed in the current time zone. * @return {Boolean} true|false */ $P.hasDaylightSavingTime = function () { return (Date.today().set({month: 0, day: 1}).getTimezoneOffset() !== Date.today().set({month: 6, day: 1}).getTimezoneOffset()); }; /** * Indicates whether this Date instance is within the Daylight Saving Time range for the current time zone. * @return {Boolean} true|false */ $P.isDaylightSavingTime = function () { return Date.today().set({month: 0, day: 1}).getTimezoneOffset() !== this.getTimezoneOffset(); }; /** * Get the offset from UTC of the current date. * @return {String} The 4-character offset string prefixed with + or - (e.g. "-0500") */ $P.getUTCOffset = function (offset) { var n = (offset || this.getTimezoneOffset()) * -10 / 6, r; if (n < 0) { r = (n - 10000).toString(); return r.charAt(0) + r.substr(2); } else { r = (n + 10000).toString(); return "+" + r.substr(1); } }; /** * Returns the number of milliseconds between this date and date. * @param {Date} Defaults to now * @return {Number} The diff in milliseconds */ $P.getElapsed = function (date) { return (date || new Date()) - this; }; /** * Set the value of year, month, day, hour, minute, second, millisecond of date instance using given configuration object. * Example

	Date.today().set( { day: 20, month: 1 } )

	new Date().set( { millisecond: 0 } )
	
* * @param {Object} Configuration object containing attributes (month, day, etc.) * @return {Date} this */ $P.set = function (config) { config = validateConfigObject.call(this, config); var key; for (key in config) { if (Object.prototype.hasOwnProperty.call(config, key)) { var name = key.charAt(0).toUpperCase() + key.slice(1); var addFunc, getFunc; if (key !== "week" && key !== "month" && key !== "timezone" && key !== "timezoneOffset") { name += "s"; } addFunc = "add" + name; getFunc = "get" + name; if (key === "month") { addFunc = addFunc + "s"; } else if (key === "year"){ getFunc = "getFullYear"; } if (key !== "day" && key !== "timezone" && key !== "timezoneOffset" && key !== "week" && key !== "hour") { this[addFunc](config[key] - this[getFunc]()); } else if ( key === "timezone"|| key === "timezoneOffset" || key === "week" || key === "hour") { this["set"+name](config[key]); } } } // day has to go last because you can't validate the day without first knowing the month if (config.day) { this.addDays(config.day - this.getDate()); } return this; }; /** * Moves the date to the first day of the month. * @return {Date} this */ $P.moveToFirstDayOfMonth = function () { return this.set({ day: 1 }); }; /** * Moves the date to the last day of the month. * @return {Date} this */ $P.moveToLastDayOfMonth = function () { return this.set({ day: $D.getDaysInMonth(this.getFullYear(), this.getMonth())}); }; /** * Converts the value of the current Date object to its equivalent string representation. * Format Specifiers * CUSTOM DATE AND TIME FORMAT STRINGS * Format Description Example * ------ --------------------------------------------------------------------------- ----------------------- * s The seconds of the minute between 0-59. "0" to "59" * ss The seconds of the minute with leading zero if required. "00" to "59" * * m The minute of the hour between 0-59. "0" or "59" * mm The minute of the hour with leading zero if required. "00" or "59" * * h The hour of the day between 1-12. "1" to "12" * hh The hour of the day with leading zero if required. "01" to "12" * * H The hour of the day between 0-23. "0" to "23" * HH The hour of the day with leading zero if required. "00" to "23" * * d The day of the month between 1 and 31. "1" to "31" * dd The day of the month with leading zero if required. "01" to "31" * ddd Abbreviated day name. Date.CultureInfo.abbreviatedDayNames. "Mon" to "Sun" * dddd The full day name. Date.CultureInfo.dayNames. "Monday" to "Sunday" * * M The month of the year between 1-12. "1" to "12" * MM The month of the year with leading zero if required. "01" to "12" * MMM Abbreviated month name. Date.CultureInfo.abbreviatedMonthNames. "Jan" to "Dec" * MMMM The full month name. Date.CultureInfo.monthNames. "January" to "December" * * yy The year as a two-digit number. "99" or "08" * yyyy The full four digit year. "1999" or "2008" * * t Displays the first character of the A.M./P.M. designator. "A" or "P" * Date.CultureInfo.amDesignator or Date.CultureInfo.pmDesignator * tt Displays the A.M./P.M. designator. "AM" or "PM" * Date.CultureInfo.amDesignator or Date.CultureInfo.pmDesignator * * S The ordinal suffix ("st, "nd", "rd" or "th") of the current day. "st, "nd", "rd" or "th" * * STANDARD DATE AND TIME FORMAT STRINGS * Format Description Example *------ --------------------------------------------------------------------------- ----------------------- * d The CultureInfo shortDate Format Pattern "M/d/yyyy" * D The CultureInfo longDate Format Pattern "dddd, MMMM dd, yyyy" * F The CultureInfo fullDateTime Format Pattern "dddd, MMMM dd, yyyy h:mm:ss tt" * m The CultureInfo monthDay Format Pattern "MMMM dd" * r The CultureInfo rfc1123 Format Pattern "ddd, dd MMM yyyy HH:mm:ss GMT" * s The CultureInfo sortableDateTime Format Pattern "yyyy-MM-ddTHH:mm:ss" * t The CultureInfo shortTime Format Pattern "h:mm tt" * T The CultureInfo longTime Format Pattern "h:mm:ss tt" * u The CultureInfo universalSortableDateTime Format Pattern "yyyy-MM-dd HH:mm:ssZ" * y The CultureInfo yearMonth Format Pattern "MMMM, yyyy" * * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @return {String} A string representation of the current Date object. */ var ord = function (n) { switch (n * 1) { case 1: case 21: case 31: return "st"; case 2: case 22: return "nd"; case 3: case 23: return "rd"; default: return "th"; } }; var parseStandardFormats = function (format) { var y, c = Date.CultureInfo.formatPatterns; switch (format) { case "d": return this.toString(c.shortDate); case "D": return this.toString(c.longDate); case "F": return this.toString(c.fullDateTime); case "m": return this.toString(c.monthDay); case "r": case "R": y = this.clone().addMinutes(this.getTimezoneOffset()); return y.toString(c.rfc1123) + " GMT"; case "s": return this.toString(c.sortableDateTime); case "t": return this.toString(c.shortTime); case "T": return this.toString(c.longTime); case "u": y = this.clone().addMinutes(this.getTimezoneOffset()); return y.toString(c.universalSortableDateTime); case "y": return this.toString(c.yearMonth); default: return false; } }; var parseFormatStringsClosure = function (context) { return function (m) { if (m.charAt(0) === "\\") { return m.replace("\\", ""); } switch (m) { case "hh": return p(context.getHours() < 13 ? (context.getHours() === 0 ? 12 : context.getHours()) : (context.getHours() - 12)); case "h": return context.getHours() < 13 ? (context.getHours() === 0 ? 12 : context.getHours()) : (context.getHours() - 12); case "HH": return p(context.getHours()); case "H": return context.getHours(); case "mm": return p(context.getMinutes()); case "m": return context.getMinutes(); case "ss": return p(context.getSeconds()); case "s": return context.getSeconds(); case "yyyy": return p(context.getFullYear(), 4); case "yy": return p(context.getFullYear()); case "y": return context.getFullYear(); case "E": case "dddd": return Date.CultureInfo.dayNames[context.getDay()]; case "ddd": return Date.CultureInfo.abbreviatedDayNames[context.getDay()]; case "dd": return p(context.getDate()); case "d": return context.getDate(); case "MMMM": return Date.CultureInfo.monthNames[context.getMonth()]; case "MMM": return Date.CultureInfo.abbreviatedMonthNames[context.getMonth()]; case "MM": return p((context.getMonth() + 1)); case "M": return context.getMonth() + 1; case "t": return context.getHours() < 12 ? Date.CultureInfo.amDesignator.substring(0, 1) : Date.CultureInfo.pmDesignator.substring(0, 1); case "tt": return context.getHours() < 12 ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator; case "S": return ord(context.getDate()); case "W": return context.getWeek(); case "WW": return context.getISOWeek(); case "Q": return "Q" + context.getQuarter(); case "q": return String(context.getQuarter()); case "z": return context.getTimezone(); case "Z": case "X": return Date.getTimezoneOffset(context.getTimezone()); case "ZZ": // Timezone offset in seconds return context.getTimezoneOffset() * -60; case "u": return context.getDay(); case "L": return ($D.isLeapYear(context.getFullYear())) ? 1 : 0; case "B": // Swatch Internet Time (.beats) return "@"+((context.getUTCSeconds() + (context.getUTCMinutes()*60) + ((context.getUTCHours()+1)*3600))/86.4); default: return m; } }; }; $P.toString = function (format, ignoreStandards) { // Standard Date and Time Format Strings. Formats pulled from CultureInfo file and // may vary by culture. if (!ignoreStandards && format && format.length === 1) { output = parseStandardFormats.call(this, format); if (output) { return output; } } var parseFormatStrings = parseFormatStringsClosure(this); return format ? format.replace(/((\\)?(dd?d?d?|MM?M?M?|yy?y?y?|hh?|HH?|mm?|ss?|tt?|S|q|Q|WW?W?W?)(?![^\[]*\]))/g, parseFormatStrings).replace(/\[|\]/g, "") : this._toString(); }; }()); /************************************************************* * SugarPak - Domain Specific Language - Syntactical Sugar * *************************************************************/ (function () { var $D = Date, $P = $D.prototype, $N = Number.prototype; // private $P._orient = +1; // private $P._nth = null; // private $P._is = false; // private $P._same = false; // private $P._isSecond = false; // private $N._dateElement = "days"; /** * Moves the date to the next instance of a date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.today().next().friday();
	Date.today().next().fri();
	Date.today().next().march();
	Date.today().next().mar();
	Date.today().next().week();
	
* * @return {Date} date */ $P.next = function () { this._move = true; this._orient = +1; return this; }; /** * Creates a new Date (Date.today()) and moves the date to the next instance of the date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.next().friday();
	Date.next().fri();
	Date.next().march();
	Date.next().mar();
	Date.next().week();
	
* * @return {Date} date */ $D.next = function () { return $D.today().next(); }; /** * Moves the date to the previous instance of a date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.today().last().friday();
	Date.today().last().fri();
	Date.today().last().march();
	Date.today().last().mar();
	Date.today().last().week();
	
* * @return {Date} date */ $P.last = $P.prev = $P.previous = function () { this._move = true; this._orient = -1; return this; }; /** * Creates a new Date (Date.today()) and moves the date to the previous instance of the date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.last().friday();
	Date.last().fri();
	Date.previous().march();
	Date.prev().mar();
	Date.last().week();
	
* * @return {Date} date */ $D.last = $D.prev = $D.previous = function () { return $D.today().last(); }; /** * Performs a equality check when followed by either a month name, day name or .weekday() function. * Example

	Date.today().is().friday(); // true|false
	Date.today().is().fri();
	Date.today().is().march();
	Date.today().is().mar();
	
* * @return {Boolean} true|false */ $P.is = function () { this._is = true; return this; }; /** * Determines if two date objects occur on/in exactly the same instance of the subsequent date part function. * The function .same() must be followed by a date part function (example: .day(), .month(), .year(), etc). * * An optional Date can be passed in the date part function. If now date is passed as a parameter, 'Now' is used. * * The following example demonstrates how to determine if two dates fall on the exact same day. * * Example

	var d1 = Date.today(); // today at 00:00
	var d2 = new Date();   // exactly now.

	// Do they occur on the same day?
	d1.same().day(d2); // true
	
	// Do they occur on the same hour?
	d1.same().hour(d2); // false, unless d2 hour is '00' (midnight).
	
	// What if it's the same day, but one year apart?
	var nextYear = Date.today().add(1).year();

	d1.same().day(nextYear); // false, because the dates must occur on the exact same day. 
	
* * Scenario: Determine if a given date occurs during some week period 2 months from now. * * Example

	var future = Date.today().add(2).months();
	return someDate.same().week(future); // true|false;
	
* * @return {Boolean} true|false */ $P.same = function () { this._same = true; this._isSecond = false; return this; }; /** * Determines if the current date/time occurs during Today. Must be preceded by the .is() function. * Example

	someDate.is().today();    // true|false
	new Date().is().today();  // true
	Date.today().is().today();// true
	Date.today().add(-1).day().is().today(); // false
	
* * @return {Boolean} true|false */ $P.today = function () { return this.same().day(); }; /** * Determines if the current date is a weekday. This function must be preceded by the .is() function. * Example

	Date.today().is().weekday(); // true|false
	
* * @return {Boolean} true|false */ $P.weekday = function () { if (this._nth) { return df("Weekday").call(this); } if (this._move) { return this.addWeekdays(this._orient); } if (this._is) { this._is = false; return (!this.is().sat() && !this.is().sun()); } return false; }; /** * Determines if the current date is on the weekend. This function must be preceded by the .is() function. * Example

	Date.today().is().weekend(); // true|false
	
* * @return {Boolean} true|false */ $P.weekend = function () { if (this._is) { this._is = false; return (this.is().sat() || this.is().sun()); } return false; }; /** * Sets the Time of the current Date instance. A string "6:15 pm" or config object {hour:18, minute:15} are accepted. * Example

	// Set time to 6:15pm with a String
	Date.today().at("6:15pm");

	// Set time to 6:15pm with a config object
	Date.today().at({hour:18, minute:15});
	
* * @return {Date} date */ $P.at = function (time) { return (typeof time === "string") ? $D.parse(this.toString("d") + " " + time) : this.set(time); }; /** * Creates a new Date() and adds this (Number) to the date based on the preceding date element function (eg. second|minute|hour|day|month|year). * Example

	// Undeclared Numbers must be wrapped with parentheses. Requirment of JavaScript.
	(3).days().fromNow();
	(6).months().fromNow();

	// Declared Number variables do not require parentheses. 
	var n = 6;
	n.months().fromNow();
	
* * @return {Date} A new Date instance */ $N.fromNow = $N.after = function (date) { var c = {}; c[this._dateElement] = this; return ((!date) ? new Date() : date.clone()).add(c); }; /** * Creates a new Date() and subtract this (Number) from the date based on the preceding date element function (eg. second|minute|hour|day|month|year). * Example

	// Undeclared Numbers must be wrapped with parentheses. Requirment of JavaScript.
	(3).days().ago();
	(6).months().ago();

	// Declared Number variables do not require parentheses. 
	var n = 6;
	n.months().ago();
	
* * @return {Date} A new Date instance */ $N.ago = $N.before = function (date) { var c = {}, s = (this._dateElement[this._dateElement.length-1] !== "s") ? this._dateElement + "s" : this._dateElement; c[s] = this * -1; return ((!date) ? new Date() : date.clone()).add(c); }; // Do NOT modify the following string tokens. These tokens are used to build dynamic functions. // All culture-specific strings can be found in the CultureInfo files. var dx = ("sunday monday tuesday wednesday thursday friday saturday").split(/\s/), mx = ("january february march april may june july august september october november december").split(/\s/), px = ("Millisecond Second Minute Hour Day Week Month Year Quarter Weekday").split(/\s/), pxf = ("Milliseconds Seconds Minutes Hours Date Week Month FullYear Quarter").split(/\s/), nth = ("final first second third fourth fifth").split(/\s/), de; /** * Returns an object literal of all the date parts. * Example

	var o = new Date().toObject();
	
	// { year: 2008, month: 4, week: 20, day: 13, hour: 18, minute: 9, second: 32, millisecond: 812 }
	
	// The object properties can be referenced directly from the object.
	
	alert(o.day);  // alerts "13"
	alert(o.year); // alerts "2008"
	
* * @return {Date} An object literal representing the original date object. */ $P.toObject = function () { var o = {}; for (var i = 0; i < px.length; i++) { if (this["get" + pxf[i]]) { o[px[i].toLowerCase()] = this["get" + pxf[i]](); } } return o; }; /** * Returns a date created from an object literal. Ignores the .week property if set in the config. * Example

	var o = new Date().toObject();
	
	return Date.fromObject(o); // will return the same date. 

	var o2 = {month: 1, day: 20, hour: 18}; // birthday party!
	Date.fromObject(o2);
	
* * @return {Date} An object literal representing the original date object. */ $D.fromObject = function(config) { config.week = null; return Date.today().set(config); }; // Create day name functions and abbreviated day name functions (eg. monday(), friday(), fri()). var df = function (n) { return function () { if (this._is) { this._is = false; return this.getDay() === n; } if (this._move) { this._move = null; } if (this._nth !== null) { // If the .second() function was called earlier, remove the _orient // from the date, and then continue. // This is required because 'second' can be used in two different context. // // Example // // Date.today().add(1).second(); // Date.march().second().monday(); // // Things get crazy with the following... // Date.march().add(1).second().second().monday(); // but it works!! // if (this._isSecond) { this.addSeconds(this._orient * -1); } // make sure we reset _isSecond this._isSecond = false; var ntemp = this._nth; this._nth = null; var temp = this.clone().moveToLastDayOfMonth(); this.moveToNthOccurrence(n, ntemp); if (this > temp) { throw new RangeError($D.getDayName(n) + " does not occur " + ntemp + " times in the month of " + $D.getMonthName(temp.getMonth()) + " " + temp.getFullYear() + "."); } return this; } return this.moveToDayOfWeek(n, this._orient); }; }; var sdf = function (n) { return function () { var t = $D.today(), shift = n - t.getDay(); if (n === 0 && Date.CultureInfo.firstDayOfWeek === 1 && t.getDay() !== 0) { shift = shift + 7; } return t.addDays(shift); }; }; // Create month name functions and abbreviated month name functions (eg. january(), march(), mar()). var month_instance_functions = function (n) { return function () { if (this._is) { this._is = false; return this.getMonth() === n; } return this.moveToMonth(n, this._orient); }; }; var month_static_functions = function (n) { return function () { return $D.today().set({ month: n, day: 1 }); }; }; var processTerms = function (names, staticFunc, instanceFunc) { for (var i = 0; i < names.length; i++) { // Create constant static Name variables. $D[names[i].toUpperCase()] = $D[names[i].toUpperCase().substring(0, 3)] = i; // Create Name functions. $D[names[i]] = $D[names[i].substring(0, 3)] = staticFunc(i); // Create Name instance functions. $P[names[i]] = $P[names[i].substring(0, 3)] = instanceFunc(i); } }; processTerms(dx, sdf, df); processTerms(mx, month_static_functions, month_instance_functions); // Create date element functions and plural date element functions used with Date (eg. day(), days(), months()). var ef = function (j) { return function () { // if the .second() function was called earlier, the _orient // has alread been added. Just return this and reset _isSecond. if (this._isSecond) { this._isSecond = false; return this; } if (this._same) { this._same = this._is = false; var o1 = this.toObject(), o2 = (arguments[0] || new Date()).toObject(), v = "", k = j.toLowerCase(); // the substr trick with -1 doesn't work in IE8 or less k = (k[k.length-1] === "s") ? k.substring(0,k.length-1) : k; for (var m = (px.length - 1); m > -1; m--) { v = px[m].toLowerCase(); if (o1[v] !== o2[v]) { return false; } if (k === v) { break; } } return true; } if (j.substring(j.length - 1) !== "s") { j += "s"; } if (this._move) { this._move = null; } return this["add" + j](this._orient); }; }; var nf = function (n) { return function () { this._dateElement = n; return this; }; }; for (var k = 0; k < px.length; k++) { de = px[k].toLowerCase(); if(de !== "weekday") { // Create date element functions and plural date element functions used with Date (eg. day(), days(), months()). $P[de] = $P[de + "s"] = ef(px[k]); // Create date element functions and plural date element functions used with Number (eg. day(), days(), months()). $N[de] = $N[de + "s"] = nf(de + "s"); } } $P._ss = ef("Second"); var nthfn = function (n) { return function (dayOfWeek) { if (this._same) { return this._ss(arguments[0]); } if (dayOfWeek || dayOfWeek === 0) { return this.moveToNthOccurrence(dayOfWeek, n); } this._nth = n; // if the operator is 'second' add the _orient, then deal with it later... if (n === 2 && (dayOfWeek === undefined || dayOfWeek === null)) { this._isSecond = true; return this.addSeconds(this._orient); } return this; }; }; for (var l = 0; l < nth.length; l++) { $P[nth[l]] = (l === 0) ? nthfn(-1) : nthfn(l); } }()); (function () { "use strict"; Date.Parsing = { Exception: function (s) { this.message = "Parse error at '" + s.substring(0, 10) + " ...'"; } }; var $P = Date.Parsing; var dayOffsets = { standard: [0,31,59,90,120,151,181,212,243,273,304,334], leap: [0,31,60,91,121,152,182,213,244,274,305,335] }; $P.isLeapYear = function(year) { return ((year % 4 === 0) && (year % 100 !== 0)) || (year % 400 === 0); }; var utils = { multiReplace : function (str, hash ) { var key; for (key in hash) { if (Object.prototype.hasOwnProperty.call(hash, key)) { var regex; if (typeof hash[key] === "function") { } else { regex = (hash[key] instanceof RegExp) ? hash[key] : new RegExp(hash[key], "g"); } str = str.replace(regex, key); } } return str; }, getDayOfYearFromWeek : function (obj) { var d, jan4, offset; obj.weekDay = (!obj.weekDay && obj.weekDay !== 0) ? 1 : obj.weekDay; d = new Date(obj.year, 0, 4); jan4 = d.getDay() === 0 ? 7 : d.getDay(); // JS is 0 indexed on Sunday. offset = jan4+3; obj.dayOfYear = ((obj.week * 7) + (obj.weekDay === 0 ? 7 : obj.weekDay))-offset; return obj; }, getDayOfYear : function (obj, dayOffset) { if (!obj.dayOfYear) { obj = utils.getDayOfYearFromWeek(obj); } for (var i=0;i <= dayOffset.length;i++) { if (obj.dayOfYear < dayOffset[i] || i === dayOffset.length) { obj.day = obj.day ? obj.day : (obj.dayOfYear - dayOffset[i-1]); break; } else { obj.month = i; } } return obj; }, adjustForTimeZone : function (obj, date) { var offset; if (obj.zone.toUpperCase() === "Z" || (obj.zone_hours === 0 && obj.zone_minutes === 0)) { // it's UTC/GML so work out the current timeszone offset offset = -date.getTimezoneOffset(); } else { offset = (obj.zone_hours*60) + (obj.zone_minutes || 0); if (obj.zone_sign === "+") { offset *= -1; } offset -= date.getTimezoneOffset(); } date.setMinutes(date.getMinutes()+offset); return date; }, setDefaults : function (obj) { obj.year = obj.year || Date.today().getFullYear(); obj.hours = obj.hours || 0; obj.minutes = obj.minutes || 0; obj.seconds = obj.seconds || 0; obj.milliseconds = obj.milliseconds || 0; if (!(!obj.month && (obj.week || obj.dayOfYear))) { // if we have a month, or if we don't but don't have the day calculation data obj.month = obj.month || 0; obj.day = obj.day || 1; } return obj; }, dataNum: function (data, mod, explict, postProcess) { var dataNum = data*1; if (mod) { if (postProcess) { return data ? mod(data)*1 : data; } else { return data ? mod(dataNum) : data; } } else if (!explict){ return data ? dataNum : data; } else { return (data && typeof data !== "undefined") ? dataNum : data; } }, timeDataProcess: function (obj) { var timeObj = {}; for (var x in obj.data) { if (obj.data.hasOwnProperty(x)) { timeObj[x] = obj.ignore[x] ? obj.data[x] : utils.dataNum(obj.data[x], obj.mods[x], obj.explict[x], obj.postProcess[x]); } } if (obj.data.secmins) { obj.data.secmins = obj.data.secmins.replace(",", ".") * 60; if (!timeObj.minutes) { timeObj.minutes = obj.data.secmins; } else if (!timeObj.seconds) { timeObj.seconds = obj.data.secmins; } delete obj.secmins; } return timeObj; }, buildTimeObjectFromData: function (data) { var time = utils.timeDataProcess({ data: { year : data[1], month : data[5], day : data[7], week : data[8], dayOfYear : data[10], hours : data[15], zone_hours : data[23], zone_minutes : data[24], zone : data[21], zone_sign : data[22], weekDay : data[9], minutes: data[16], seconds: data[19], milliseconds: data[20], secmins: data[18] }, mods: { month: function(data) { return data-1; }, weekDay: function (data) { data = Math.abs(data); return (data === 7 ? 0 : data); }, minutes: function (data) { return data.replace(":",""); }, seconds: function (data) { return Math.floor( (data.replace(":","").replace(",","."))*1 ); }, milliseconds: function (data) { return (data.replace(",",".")*1000); } }, postProcess: { minutes: true, seconds: true, milliseconds: true }, explict: { zone_hours: true, zone_minutes: true }, ignore: { zone: true, zone_sign: true, secmins: true } }); return time; }, addToHash: function (hash, keys, data) { keys = keys; data = data; var len = keys.length; for (var i = 0; i < len; i++) { hash[keys[i]] = data[i]; } return hash; }, combineRegex: function (r1, r2) { return new RegExp("(("+r1.source+")\\s("+r2.source+"))"); }, getDateNthString: function(add, last, inc){ if (add) { return Date.today().addDays(inc).toString("d"); } else if (last) { return Date.today().last()[inc]().toString("d"); } }, buildRegexData: function (array) { var arr = []; var len = array.length; for (var i=0; i < len; i++) { if (Object.prototype.toString.call(array[i]) === '[object Array]') { // oldIE compat version of Array.isArray arr.push(this.combineRegex(array[i][0], array[i][1])); } else { arr.push(array[i]); } } return arr; } }; $P.processTimeObject = function (obj) { var date, dayOffset; utils.setDefaults(obj); dayOffset = ($P.isLeapYear(obj.year)) ? dayOffsets.leap : dayOffsets.standard; if (!obj.month && (obj.week || obj.dayOfYear)) { utils.getDayOfYear(obj, dayOffset); } else { obj.dayOfYear = dayOffset[obj.month] + obj.day; } date = new Date(obj.year, obj.month, obj.day, obj.hours, obj.minutes, obj.seconds, obj.milliseconds); if (obj.zone) { utils.adjustForTimeZone(obj, date); // adjust (and calculate) for timezone } return date; }; $P.ISO = { regex : /^([\+-]?\d{4}(?!\d{2}\b))((-?)((0[1-9]|1[0-2])(\3([12]\d|0[1-9]|3[01]))?|W([0-4]\d|5[0-3])(-?[1-7])?|(00[1-9]|0[1-9]\d|[12]\d{2}|3([0-5]\d|6[1-6])))([T\s]((([01]\d|2[0-4])((:?)[0-5]\d)?|24\:?00)([\.,]\d+(?!:))?)?(\17[0-5]\d([\.,]\d+)?)?\s?([zZ]|([\+-])([01]\d|2[0-3]):?([0-5]\d)?)?)?)?$/, parse : function (s) { var time, data = s.match(this.regex); if (!data || !data.length) { return null; } time = utils.buildTimeObjectFromData(data); if (!time.year || (!time.year && (!time.month && !time.day) && (!time.week && !time.dayOfYear)) ) { return null; } return $P.processTimeObject(time); } }; $P.Numeric = { isNumeric: function (e){return!isNaN(parseFloat(e))&&isFinite(e);}, regex: /\b([0-1]?[0-9])([0-3]?[0-9])([0-2]?[0-9]?[0-9][0-9])\b/i, parse: function (s) { var data, i, time = {}, order = Date.CultureInfo.dateElementOrder.split(""); if (!(this.isNumeric(s)) || // if it's non-numeric OR (s[0] === "+" && s[0] === "-")) { // It's an arithmatic string (eg +/-1000) return null; } if (s.length < 5 && s.indexOf(".") < 0 && s.indexOf("/") < 0) { // assume it's just a year. time.year = s; return $P.processTimeObject(time); } data = s.match(this.regex); if (!data || !data.length) { return null; } for (i=0; i < order.length; i++) { switch(order[i]) { case "d": time.day = data[i+1]; break; case "m": time.month = (data[i+1]-1); break; case "y": time.year = data[i+1]; break; } } return $P.processTimeObject(time); } }; $P.Normalizer = { regexData: function () { var $R = Date.CultureInfo.regexPatterns; return utils.buildRegexData([ $R.tomorrow, $R.yesterday, [$R.past, $R.mon], [$R.past, $R.tue], [$R.past, $R.wed], [$R.past, $R.thu], [$R.past, $R.fri], [$R.past, $R.sat], [$R.past, $R.sun] ]); }, basicReplaceHash : function() { var $R = Date.CultureInfo.regexPatterns; return { "January": $R.jan.source, "February": $R.feb, "March": $R.mar, "April": $R.apr, "May": $R.may, "June": $R.jun, "July": $R.jul, "August": $R.aug, "September": $R.sep, "October": $R.oct, "November": $R.nov, "December": $R.dec, "": /\bat\b/gi, " ": /\s{2,}/, "am": $R.inTheMorning, "9am": $R.thisMorning, "pm": $R.inTheEvening, "7pm":$R.thisEvening }; }, keys : function(){ return [ utils.getDateNthString(true, false, 1), // tomorrow utils.getDateNthString(true, false, -1), // yesterday utils.getDateNthString(false, true, "monday"), //last mon utils.getDateNthString(false, true, "tuesday"), //last tues utils.getDateNthString(false, true, "wednesday"), //last wed utils.getDateNthString(false, true, "thursday"), //last thurs utils.getDateNthString(false, true, "friday"), //last fri utils.getDateNthString(false, true, "saturday"), //last sat utils.getDateNthString(false, true, "sunday") //last sun ]; }, buildRegexFunctions: function () { var $R = Date.CultureInfo.regexPatterns; var __ = Date.i18n.__; var tomorrowRE = new RegExp("(\\b\\d\\d?("+__("AM")+"|"+__("PM")+")? )("+$R.tomorrow.source.slice(1)+")", "i"); // adapted tomorrow regex for AM PM relative dates var todayRE = new RegExp($R.today.source + "(?!\\s*([+-]))\\b"); // today, but excludes the math operators (eg "today + 2h") this.replaceFuncs = [ [todayRE, function (full) { return (full.length > 1) ? Date.today().toString("d") : full; }], [tomorrowRE, function(full, m1) { var t = Date.today().addDays(1).toString("d"); return (t + " " + m1); }], [$R.amThisMorning, function(str, am){return am;}], [$R.pmThisEvening, function(str, pm){return pm;}] ]; }, buildReplaceData: function () { this.buildRegexFunctions(); this.replaceHash = utils.addToHash(this.basicReplaceHash(), this.keys(), this.regexData()); }, stringReplaceFuncs: function (s) { for (var i=0; i < this.replaceFuncs.length; i++) { s = s.replace(this.replaceFuncs[i][0], this.replaceFuncs[i][1]); } return s; }, parse: function (s) { s = this.stringReplaceFuncs(s); s = utils.multiReplace(s, this.replaceHash); try { var n = s.split(/([\s\-\.\,\/\x27]+)/); if (n.length === 3 && $P.Numeric.isNumeric(n[0]) && $P.Numeric.isNumeric(n[2]) && (n[2].length >= 4)) { // ok, so we're dealing with x/year. But that's not a full date. // This fixes wonky dateElementOrder parsing when set to dmy order. if (Date.CultureInfo.dateElementOrder[0] === "d") { s = "1/" + n[0] + "/" + n[2]; // set to 1st of month and normalize the seperator } } } catch (e) {} return s; } }; $P.Normalizer.buildReplaceData(); }()); (function () { var $P = Date.Parsing; var _ = $P.Operators = { // // Tokenizers // rtoken: function (r) { // regex token return function (s) { var mx = s.match(r); if (mx) { return ([ mx[0], s.substring(mx[0].length) ]); } else { throw new $P.Exception(s); } }; }, token: function () { // whitespace-eating token return function (s) { return _.rtoken(new RegExp("^\\s*" + s + "\\s*"))(s); }; }, stoken: function (s) { // string token return _.rtoken(new RegExp("^" + s)); }, // Atomic Operators until: function (p) { return function (s) { var qx = [], rx = null; while (s.length) { try { rx = p.call(this, s); } catch (e) { qx.push(rx[0]); s = rx[1]; continue; } break; } return [ qx, s ]; }; }, many: function (p) { return function (s) { var rx = [], r = null; while (s.length) { try { r = p.call(this, s); } catch (e) { return [ rx, s ]; } rx.push(r[0]); s = r[1]; } return [ rx, s ]; }; }, // generator operators -- see below optional: function (p) { return function (s) { var r = null; try { r = p.call(this, s); } catch (e) { return [ null, s ]; } return [ r[0], r[1] ]; }; }, not: function (p) { return function (s) { try { p.call(this, s); } catch (e) { return [null, s]; } throw new $P.Exception(s); }; }, ignore: function (p) { return p ? function (s) { var r = null; r = p.call(this, s); return [null, r[1]]; } : null; }, product: function () { var px = arguments[0], qx = Array.prototype.slice.call(arguments, 1), rx = []; for (var i = 0 ; i < px.length ; i++) { rx.push(_.each(px[i], qx)); } return rx; }, cache: function (rule) { var cache = {}, cache_length = 0, cache_keys = [], CACHE_MAX = Date.Config.CACHE_MAX || 100000, r = null; var cacheCheck = function () { if (cache_length === CACHE_MAX) { // kill several keys, don't want to have to do this all the time... for (var i=0; i < 10; i++) { var key = cache_keys.shift(); if (key) { delete cache[key]; cache_length--; } } } }; return function (s) { cacheCheck(); try { r = cache[s] = (cache[s] || rule.call(this, s)); } catch (e) { r = cache[s] = e; } cache_length++; cache_keys.push(s); if (r instanceof $P.Exception) { throw r; } else { return r; } }; }, // vector operators -- see below any: function () { var px = arguments; return function (s) { var r = null; for (var i = 0; i < px.length; i++) { if (px[i] == null) { continue; } try { r = (px[i].call(this, s)); } catch (e) { r = null; } if (r) { return r; } } throw new $P.Exception(s); }; }, each: function () { var px = arguments; return function (s) { var rx = [], r = null; for (var i = 0; i < px.length ; i++) { if (px[i] == null) { continue; } try { r = (px[i].call(this, s)); } catch (e) { throw new $P.Exception(s); } rx.push(r[0]); s = r[1]; } return [ rx, s]; }; }, all: function () { var px = arguments, _ = _; return _.each(_.optional(px)); }, // delimited operators sequence: function (px, d, c) { d = d || _.rtoken(/^\s*/); c = c || null; if (px.length === 1) { return px[0]; } return function (s) { var r = null, q = null; var rx = []; for (var i = 0; i < px.length ; i++) { try { r = px[i].call(this, s); } catch (e) { break; } rx.push(r[0]); try { q = d.call(this, r[1]); } catch (ex) { q = null; break; } s = q[1]; } if (!r) { throw new $P.Exception(s); } if (q) { throw new $P.Exception(q[1]); } if (c) { try { r = c.call(this, r[1]); } catch (ey) { throw new $P.Exception(r[1]); } } return [ rx, (r?r[1]:s) ]; }; }, // // Composite Operators // between: function (d1, p, d2) { d2 = d2 || d1; var _fn = _.each(_.ignore(d1), p, _.ignore(d2)); return function (s) { var rx = _fn.call(this, s); return [[rx[0][0], r[0][2]], rx[1]]; }; }, list: function (p, d, c) { d = d || _.rtoken(/^\s*/); c = c || null; return (p instanceof Array ? _.each(_.product(p.slice(0, -1), _.ignore(d)), p.slice(-1), _.ignore(c)) : _.each(_.many(_.each(p, _.ignore(d))), px, _.ignore(c))); }, set: function (px, d, c) { d = d || _.rtoken(/^\s*/); c = c || null; return function (s) { // r is the current match, best the current 'best' match // which means it parsed the most amount of input var r = null, p = null, q = null, rx = null, best = [[], s], last = false; // go through the rules in the given set for (var i = 0; i < px.length ; i++) { // last is a flag indicating whether this must be the last element // if there is only 1 element, then it MUST be the last one q = null; p = null; r = null; last = (px.length === 1); // first, we try simply to match the current pattern // if not, try the next pattern try { r = px[i].call(this, s); } catch (e) { continue; } // since we are matching against a set of elements, the first // thing to do is to add r[0] to matched elements rx = [[r[0]], r[1]]; // if we matched and there is still input to parse and // we don't already know this is the last element, // we're going to next check for the delimiter ... // if there's none, or if there's no input left to parse // than this must be the last element after all ... if (r[1].length > 0 && ! last) { try { q = d.call(this, r[1]); } catch (ex) { last = true; } } else { last = true; } // if we parsed the delimiter and now there's no more input, // that means we shouldn't have parsed the delimiter at all // so don't update r and mark this as the last element ... if (!last && q[1].length === 0) { last = true; } // so, if this isn't the last element, we're going to see if // we can get any more matches from the remaining (unmatched) // elements ... if (!last) { // build a list of the remaining rules we can match against, // i.e., all but the one we just matched against var qx = []; for (var j = 0; j < px.length ; j++) { if (i !== j) { qx.push(px[j]); } } // now invoke recursively set with the remaining input // note that we don't include the closing delimiter ... // we'll check for that ourselves at the end p = _.set(qx, d).call(this, q[1]); // if we got a non-empty set as a result ... // (otw rx already contains everything we want to match) if (p[0].length > 0) { // update current result, which is stored in rx ... // basically, pick up the remaining text from p[1] // and concat the result from p[0] so that we don't // get endless nesting ... rx[0] = rx[0].concat(p[0]); rx[1] = p[1]; } } // at this point, rx either contains the last matched element // or the entire matched set that starts with this element. // now we just check to see if this variation is better than // our best so far, in terms of how much of the input is parsed if (rx[1].length < best[1].length) { best = rx; } // if we've parsed all the input, then we're finished if (best[1].length === 0) { break; } } // so now we've either gone through all the patterns trying them // as the initial match; or we found one that parsed the entire // input string ... // if best has no matches, just return empty set ... if (best[0].length === 0) { return best; } // if a closing delimiter is provided, then we have to check it also if (c) { // we try this even if there is no remaining input because the pattern // may well be optional or match empty input ... try { q = c.call(this, best[1]); } catch (ey) { throw new $P.Exception(best[1]); } // it parsed ... be sure to update the best match remaining input best[1] = q[1]; } // if we're here, either there was no closing delimiter or we parsed it // so now we have the best match; just return it! return best; }; }, forward: function (gr, fname) { return function (s) { return gr[fname].call(this, s); }; }, // // Translation Operators // replace: function (rule, repl) { return function (s) { var r = rule.call(this, s); return [repl, r[1]]; }; }, process: function (rule, fn) { return function (s) { var r = rule.call(this, s); return [fn.call(this, r[0]), r[1]]; }; }, min: function (min, rule) { return function (s) { var rx = rule.call(this, s); if (rx[0].length < min) { throw new $P.Exception(s); } return rx; }; } }; // Generator Operators And Vector Operators // Generators are operators that have a signature of F(R) => R, // taking a given rule and returning another rule, such as // ignore, which parses a given rule and throws away the result. // Vector operators are those that have a signature of F(R1,R2,...) => R, // take a list of rules and returning a new rule, such as each. // Generator operators are converted (via the following _generator // function) into functions that can also take a list or array of rules // and return an array of new rules as though the function had been // called on each rule in turn (which is what actually happens). // This allows generators to be used with vector operators more easily. // Example: // each(ignore(foo, bar)) instead of each(ignore(foo), ignore(bar)) // This also turns generators into vector operators, which allows // constructs like: // not(cache(foo, bar)) var _generator = function (op) { function gen() { var args = null, rx = [], px, i; if (arguments.length > 1) { args = Array.prototype.slice.call(arguments); } else if (arguments[0] instanceof Array) { args = arguments[0]; } if (args) { px = args.shift(); if (px.length > 0) { args.unshift(px[i]); rx.push(op.apply(null, args)); args.shift(); return rx; } } else { return op.apply(null, arguments); } } return gen; }; var gx = "optional not ignore cache".split(/\s/); for (var i = 0 ; i < gx.length ; i++) { _[gx[i]] = _generator(_[gx[i]]); } var _vector = function (op) { return function () { if (arguments[0] instanceof Array) { return op.apply(null, arguments[0]); } else { return op.apply(null, arguments); } }; }; var vx = "each any all".split(/\s/); for (var j = 0 ; j < vx.length ; j++) { _[vx[j]] = _vector(_[vx[j]]); } }()); (function () { var $D = Date; var flattenAndCompact = function (ax) { var rx = []; for (var i = 0; i < ax.length; i++) { if (ax[i] instanceof Array) { rx = rx.concat(flattenAndCompact(ax[i])); } else { if (ax[i]) { rx.push(ax[i]); } } } return rx; }; var parseMeridian = function () { if (this.meridian && (this.hour || this.hour === 0)) { if (this.meridian === "a" && this.hour > 11 && Date.Config.strict24hr){ throw "Invalid hour and meridian combination"; } else if (this.meridian === "p" && this.hour < 12 && Date.Config.strict24hr){ throw "Invalid hour and meridian combination"; } else if (this.meridian === "p" && this.hour < 12) { this.hour = this.hour + 12; } else if (this.meridian === "a" && this.hour === 12) { this.hour = 0; } } }; var setDefaults = function () { var now = new Date(); if ((this.hour || this.minute) && (!this.month && !this.year && !this.day)) { this.day = now.getDate(); } if (!this.year) { this.year = now.getFullYear(); } if (!this.month && this.month !== 0) { this.month = now.getMonth(); } if (!this.day) { this.day = 1; } if (!this.hour) { this.hour = 0; } if (!this.minute) { this.minute = 0; } if (!this.second) { this.second = 0; } if (!this.millisecond) { this.millisecond = 0; } }; var finishUtils = { getToday: function () { if (this.now || "hour minute second".indexOf(this.unit) !== -1) { return new Date(); } else { return $D.today(); } }, setDaysFromWeekday: function (today, orient){ var gap; orient = orient || 1; this.unit = "day"; gap = ($D.getDayNumberFromName(this.weekday) - today.getDay()); this.days = gap ? ((gap + (orient * 7)) % 7) : (orient * 7); return this; }, setMonthsFromMonth: function (today, orient) { var gap; orient = orient || 1; this.unit = "month"; gap = (this.month - today.getMonth()); this.months = gap ? ((gap + (orient * 12)) % 12) : (orient * 12); this.month = null; return this; }, setDMYFromWeekday: function () { var d = Date[this.weekday](); this.day = d.getDate(); if (!this.month) { this.month = d.getMonth(); } this.year = d.getFullYear(); return this; }, setUnitValue: function (orient) { if (!this.value && this.operator && this.operator !== null && this[this.unit + "s"] && this[this.unit + "s"] !== null) { this[this.unit + "s"] = this[this.unit + "s"] + ((this.operator === "add") ? 1 : -1) + (this.value||0) * orient; } else if (this[this.unit + "s"] == null || this.operator != null) { if (!this.value) { this.value = 1; } this[this.unit + "s"] = this.value * orient; } }, generateDateFromWeeks: function () { var weekday = (this.weekday !== undefined) ? this.weekday : "today"; var d = Date[weekday]().addWeeks(this.weeks); if (this.now) { d.setTimeToNow(); } return d; } }; $D.Translator = { hour: function (s) { return function () { this.hour = Number(s); }; }, minute: function (s) { return function () { this.minute = Number(s); }; }, second: function (s) { return function () { this.second = Number(s); }; }, /* for ss.s format */ secondAndMillisecond: function (s) { return function () { var mx = s.match(/^([0-5][0-9])\.([0-9]{1,3})/); this.second = Number(mx[1]); this.millisecond = Number(mx[2]); }; }, meridian: function (s) { return function () { this.meridian = s.slice(0, 1).toLowerCase(); }; }, timezone: function (s) { return function () { var n = s.replace(/[^\d\+\-]/g, ""); if (n.length) { this.timezoneOffset = Number(n); } else { this.timezone = s.toLowerCase(); } }; }, day: function (x) { var s = x[0]; return function () { this.day = Number(s.match(/\d+/)[0]); if (this.day < 1) { throw "invalid day"; } }; }, month: function (s) { return function () { this.month = (s.length === 3) ? "jan feb mar apr may jun jul aug sep oct nov dec".indexOf(s)/4 : Number(s) - 1; if (this.month < 0) { throw "invalid month"; } }; }, year: function (s) { return function () { var n = Number(s); this.year = ((s.length > 2) ? n : (n + (((n + 2000) < Date.CultureInfo.twoDigitYearMax) ? 2000 : 1900))); }; }, rday: function (s) { return function () { switch (s) { case "yesterday": this.days = -1; break; case "tomorrow": this.days = 1; break; case "today": this.days = 0; break; case "now": this.days = 0; this.now = true; break; } }; }, finishExact: function (x) { var d; x = (x instanceof Array) ? x : [x]; for (var i = 0 ; i < x.length ; i++) { if (x[i]) { x[i].call(this); } } setDefaults.call(this); parseMeridian.call(this); if (this.day > $D.getDaysInMonth(this.year, this.month)) { throw new RangeError(this.day + " is not a valid value for days."); } d = new Date(this.year, this.month, this.day, this.hour, this.minute, this.second, this.millisecond); if (this.year < 100) { d.setFullYear(this.year); // means years less that 100 are process correctly. JS will parse it otherwise as 1900-1999. } if (this.timezone) { d.set({ timezone: this.timezone }); } else if (this.timezoneOffset) { d.set({ timezoneOffset: this.timezoneOffset }); } return d; }, finish: function (x) { var today, expression, orient, temp; x = (x instanceof Array) ? flattenAndCompact(x) : [ x ]; if (x.length === 0) { return null; } for (var i = 0 ; i < x.length ; i++) { if (typeof x[i] === "function") { x[i].call(this); } } if (this.now && !this.unit && !this.operator) { return new Date(); } else { today = finishUtils.getToday.call(this); } expression = !!(this.days && this.days !== null || this.orient || this.operator); orient = ((this.orient === "past" || this.operator === "subtract") ? -1 : 1); if (this.month && this.unit === "week") { this.value = this.month + 1; delete this.month; delete this.day; } if ((this.month || this.month === 0) && "year day hour minute second".indexOf(this.unit) !== -1) { if (!this.value) { this.value = this.month + 1; } this.month = null; expression = true; } if (!expression && this.weekday && !this.day && !this.days) { finishUtils.setDMYFromWeekday.call(this); } if (expression && this.weekday && this.unit !== "month" && this.unit !== "week") { finishUtils.setDaysFromWeekday.call(this, today, orient); } if (this.weekday && this.unit !== "week" && !this.day && !this.days) { temp = Date[this.weekday](); this.day = temp.getDate(); if (temp.getMonth() !== today.getMonth()) { this.month = temp.getMonth(); } } if (this.month && this.unit === "day" && this.operator) { if (!this.value) { this.value = (this.month + 1); } this.month = null; } if (this.value != null && this.month != null && this.year != null) { this.day = this.value * 1; } if (this.month && !this.day && this.value) { today.set({ day: this.value * 1 }); if (!expression) { this.day = this.value * 1; } } if (!this.month && this.value && this.unit === "month" && !this.now) { this.month = this.value; expression = true; } if (expression && (this.month || this.month === 0) && this.unit !== "year") { finishUtils.setMonthsFromMonth.call(this, today, orient); } if (!this.unit) { this.unit = "day"; } finishUtils.setUnitValue.call(this, orient); parseMeridian.call(this); if ((this.month || this.month === 0) && !this.day) { this.day = 1; } if (!this.orient && !this.operator && this.unit === "week" && this.value && !this.day && !this.month) { return Date.today().setWeek(this.value); } if (this.unit === "week" && this.weeks && !this.day && !this.month) { return finishUtils.generateDateFromWeeks.call(this); } if (expression && this.timezone && this.day && this.days) { this.day = this.days; } if (expression){ today.add(this); } else { today.set(this); } if (this.timezone) { this.timezone = this.timezone.toUpperCase(); var offset = $D.getTimezoneOffset(this.timezone); var timezone; if (today.hasDaylightSavingTime()) { // lets check that we're being sane with timezone setting timezone = $D.getTimezoneAbbreviation(offset, today.isDaylightSavingTime()); if (timezone !== this.timezone) { // bugger, we're in a place where things like EST vs EDT matters. if (today.isDaylightSavingTime()) { today.addHours(-1); } else { today.addHours(1); } } } today.setTimezoneOffset(offset); } return today; } }; }()); (function () { var $D = Date; $D.Grammar = {}; var _ = $D.Parsing.Operators, g = $D.Grammar, t = $D.Translator, _fn; // Allow rolling up into general purpose rules _fn = function () { return _.each(_.any.apply(null, arguments), _.not(g.ctoken2("timeContext"))); }; g.datePartDelimiter = _.rtoken(/^([\s\-\.\,\/\x27]+)/); g.timePartDelimiter = _.stoken(":"); g.whiteSpace = _.rtoken(/^\s*/); g.generalDelimiter = _.rtoken(/^(([\s\,]|at|@|on)+)/); var _C = {}; g.ctoken = function (keys) { var fn = _C[keys]; if (! fn) { var c = Date.CultureInfo.regexPatterns; var kx = keys.split(/\s+/), px = []; for (var i = 0; i < kx.length ; i++) { px.push(_.replace(_.rtoken(c[kx[i]]), kx[i])); } fn = _C[keys] = _.any.apply(null, px); } return fn; }; g.ctoken2 = function (key) { return _.rtoken(Date.CultureInfo.regexPatterns[key]); }; var cacheProcessRtoken = function (key, token, type, eachToken) { if (eachToken) { g[key] = _.cache(_.process(_.each(_.rtoken(token),_.optional(g.ctoken2(eachToken))), type)); } else { g[key] = _.cache(_.process(_.rtoken(token), type)); } }; var cacheProcessCtoken = function (token, type) { return _.cache(_.process(g.ctoken2(token), type)); }; var _F = {}; //function cache var _get = function (f) { _F[f] = (_F[f] || g.format(f)[0]); return _F[f]; }; g.allformats = function (fx) { var rx = []; if (fx instanceof Array) { for (var i = 0; i < fx.length; i++) { rx.push(_get(fx[i])); } } else { rx.push(_get(fx)); } return rx; }; g.formats = function (fx) { if (fx instanceof Array) { var rx = []; for (var i = 0 ; i < fx.length ; i++) { rx.push(_get(fx[i])); } return _.any.apply(null, rx); } else { return _get(fx); } }; var grammarFormats = { timeFormats: function(){ var i, RTokenKeys = [ "h", "hh", "H", "HH", "m", "mm", "s", "ss", "ss.s", "z", "zz" ], RToken = [ /^(0[0-9]|1[0-2]|[1-9])/, /^(0[0-9]|1[0-2])/, /^([0-1][0-9]|2[0-3]|[0-9])/, /^([0-1][0-9]|2[0-3])/, /^([0-5][0-9]|[0-9])/, /^[0-5][0-9]/, /^([0-5][0-9]|[0-9])/, /^[0-5][0-9]/, /^[0-5][0-9]\.[0-9]{1,3}/, /^((\+|\-)\s*\d\d\d\d)|((\+|\-)\d\d\:?\d\d)/, /^((\+|\-)\s*\d\d\d\d)|((\+|\-)\d\d\:?\d\d)/ ], tokens = [ t.hour, t.hour, t.hour, t.hour, t.minute, t.minute, t.second, t.second, t.secondAndMillisecond, t.timezone, t.timezone ]; for (i=0; i < RTokenKeys.length; i++) { cacheProcessRtoken(RTokenKeys[i], RToken[i], tokens[i]); } g.hms = _.cache(_.sequence([g.H, g.m, g.s], g.timePartDelimiter)); g.t = cacheProcessCtoken("shortMeridian", t.meridian); g.tt = cacheProcessCtoken("longMeridian", t.meridian); g.zzz = cacheProcessCtoken("timezone", t.timezone); g.timeSuffix = _.each(_.ignore(g.whiteSpace), _.set([ g.tt, g.zzz ])); g.time = _.each(_.optional(_.ignore(_.stoken("T"))), g.hms, g.timeSuffix); }, dateFormats: function () { // pre-loaded rules for different date part order preferences var _setfn = function () { return _.set(arguments, g.datePartDelimiter); }; var i, RTokenKeys = [ "d", "dd", "M", "MM", "y", "yy", "yyy", "yyyy" ], RToken = [ /^([0-2]\d|3[0-1]|\d)/, /^([0-2]\d|3[0-1])/, /^(1[0-2]|0\d|\d)/, /^(1[0-2]|0\d)/, /^(\d+)/, /^(\d\d)/, /^(\d\d?\d?\d?)/, /^(\d\d\d\d)/ ], tokens = [ t.day, t.day, t.month, t.month, t.year, t.year, t.year, t.year ], eachToken = [ "ordinalSuffix", "ordinalSuffix" ]; for (i=0; i < RTokenKeys.length; i++) { cacheProcessRtoken(RTokenKeys[i], RToken[i], tokens[i], eachToken[i]); } g.MMM = g.MMMM = _.cache(_.process(g.ctoken("jan feb mar apr may jun jul aug sep oct nov dec"), t.month)); g.ddd = g.dddd = _.cache(_.process(g.ctoken("sun mon tue wed thu fri sat"), function (s) { return function () { this.weekday = s; }; } )); g.day = _fn(g.d, g.dd); g.month = _fn(g.M, g.MMM); g.year = _fn(g.yyyy, g.yy); g.mdy = _setfn(g.ddd, g.month, g.day, g.year); g.ymd = _setfn(g.ddd, g.year, g.month, g.day); g.dmy = _setfn(g.ddd, g.day, g.month, g.year); g.date = function (s) { return ((g[Date.CultureInfo.dateElementOrder] || g.mdy).call(this, s)); }; }, relative: function () { // relative date / time expressions g.orientation = _.process(g.ctoken("past future"), function (s) { return function () { this.orient = s; }; } ); g.operator = _.process(g.ctoken("add subtract"), function (s) { return function () { this.operator = s; }; } ); g.rday = _.process(g.ctoken("yesterday tomorrow today now"), t.rday); g.unit = _.process(g.ctoken("second minute hour day week month year"), function (s) { return function () { this.unit = s; }; } ); } }; g.buildGrammarFormats = function () { // these need to be rebuilt every time the language changes. _C = {}; grammarFormats.timeFormats(); grammarFormats.dateFormats(); grammarFormats.relative(); g.value = _.process(_.rtoken(/^([-+]?\d+)?(st|nd|rd|th)?/), function (s) { return function () { this.value = s.replace(/\D/g, ""); }; } ); g.expression = _.set([g.rday, g.operator, g.value, g.unit, g.orientation, g.ddd, g.MMM ]); g.format = _.process(_.many( _.any( // translate format specifiers into grammar rules _.process( _.rtoken(/^(dd?d?d?(?!e)|MM?M?M?|yy?y?y?|hh?|HH?|mm?|ss?|tt?|zz?z?)/), function (fmt) { if (g[fmt]) { return g[fmt]; } else { throw $D.Parsing.Exception(fmt); } } ), // translate separator tokens into token rules _.process(_.rtoken(/^[^dMyhHmstz]+/), // all legal separators function (s) { return _.ignore(_.stoken(s)); } ) ) ), // construct the parser ... function (rules) { return _.process(_.each.apply(null, rules), t.finishExact); } ); // starting rule for general purpose grammar g._start = _.process(_.set([ g.date, g.time, g.expression ], g.generalDelimiter, g.whiteSpace), t.finish); }; g.buildGrammarFormats(); // parsing date format specifiers - ex: "h:m:s tt" // this little guy will generate a custom parser based // on the format string, ex: g.format("h:m:s tt") // check for these formats first g._formats = g.formats([ "\"yyyy-MM-ddTHH:mm:ssZ\"", "yyyy-MM-ddTHH:mm:ss.sz", "yyyy-MM-ddTHH:mm:ssZ", "yyyy-MM-ddTHH:mm:ssz", "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-ddTHH:mmZ", "yyyy-MM-ddTHH:mmz", "yyyy-MM-ddTHH:mm", "ddd, MMM dd, yyyy H:mm:ss tt", "ddd MMM d yyyy HH:mm:ss zzz", "MMddyyyy", "ddMMyyyy", "Mddyyyy", "ddMyyyy", "Mdyyyy", "dMyyyy", "yyyy", "Mdyy", "dMyy", "d" ]); // real starting rule: tries selected formats first, // then general purpose rule g.start = function (s) { try { var r = g._formats.call({}, s); if (r[1].length === 0) { return r; } } catch (e) {} return g._start.call({}, s); }; }()); (function () { var $D = Date; /** * @desc Converts the specified string value into its JavaScript Date equivalent using CultureInfo specific format information. * * Example

	///////////
	// Dates //
	///////////

	// 15-Oct-2004
	var d1 = Date.parse("10/15/2004");

	// 15-Oct-2004
	var d1 = Date.parse("15-Oct-2004");

	// 15-Oct-2004
	var d1 = Date.parse("2004.10.15");

	//Fri Oct 15, 2004
	var d1 = Date.parse("Fri Oct 15, 2004");

	///////////
	// Times //
	///////////

	// Today at 10 PM.
	var d1 = Date.parse("10 PM");

	// Today at 10:30 PM.
	var d1 = Date.parse("10:30 P.M.");

	// Today at 6 AM.
	var d1 = Date.parse("06am");

	/////////////////////
	// Dates and Times //
	/////////////////////

	// 8-July-2004 @ 10:30 PM
	var d1 = Date.parse("July 8th, 2004, 10:30 PM");

	// 1-July-2004 @ 10:30 PM
	var d1 = Date.parse("2004-07-01T22:30:00");

	////////////////////
	// Relative Dates //
	////////////////////

	// Returns today's date. The string "today" is culture specific.
	var d1 = Date.parse("today");

	// Returns yesterday's date. The string "yesterday" is culture specific.
	var d1 = Date.parse("yesterday");

	// Returns the date of the next thursday.
	var d1 = Date.parse("Next thursday");

	// Returns the date of the most previous monday.
	var d1 = Date.parse("last monday");

	// Returns today's day + one year.
	var d1 = Date.parse("next year");

	///////////////
	// Date Math //
	///////////////

	// Today + 2 days
	var d1 = Date.parse("t+2");

	// Today + 2 days
	var d1 = Date.parse("today + 2 days");

	// Today + 3 months
	var d1 = Date.parse("t+3m");

	// Today - 1 year
	var d1 = Date.parse("today - 1 year");

	// Today - 1 year
	var d1 = Date.parse("t-1y"); 


	/////////////////////////////
	// Partial Dates and Times //
	/////////////////////////////

	// July 15th of this year.
	var d1 = Date.parse("July 15");

	// 15th day of current day and year.
	var d1 = Date.parse("15");

	// July 1st of current year at 10pm.
	var d1 = Date.parse("7/1 10pm");
	
* * @param {String} The string value to convert into a Date object [Required] * @return {Date} A Date object or null if the string cannot be converted into a Date. */ var parseUtils = { removeOrds: function (s) { ords = s.match(/\b(\d+)(?:st|nd|rd|th)\b/); // find ordinal matches s = ((ords && ords.length === 2) ? s.replace(ords[0], ords[1]) : s); return s; }, grammarParser: function (s) { var r = null; try { r = $D.Grammar.start.call({}, s.replace(/^\s*(\S*(\s+\S+)*)\s*$/, "$1")); } catch (e) { return null; } return ((r[1].length === 0) ? r[0] : null); }, nativeFallback: function(s) { var t; try { // ok we haven't parsed it, last ditch attempt with the built-in parser. t = Date._parse(s); return (t || t === 0) ? new Date(t) : null; } catch (e) { return null; } } }; function parse (s) { var d; if (!s) { return null; } if (s instanceof Date) { return s.clone(); } if (s.length >= 4 && s.charAt(0) !== "0" && s.charAt(0) !== "+"&& s.charAt(0) !== "-") { // ie: 2004 will pass, 0800 won't. // Start with specific formats d = $D.Parsing.ISO.parse(s) || $D.Parsing.Numeric.parse(s); } if (d instanceof Date && !isNaN(d.getTime())) { return d; } else { // find ordinal dates (1st, 3rd, 8th, etc and remove them as they cause parsing issues) s = $D.Parsing.Normalizer.parse(parseUtils.removeOrds(s)); d = parseUtils.grammarParser(s); if (d !== null) { return d; } else { return parseUtils.nativeFallback(s); } } } if (!$D._parse) { $D._parse = $D.parse; } $D.parse = parse; Date.getParseFunction = function (fx) { var fns = Date.Grammar.allformats(fx); return function (s) { var r = null; for (var i = 0; i < fns.length; i++) { try { r = fns[i].call({}, s); } catch (e) { continue; } if (r[1].length === 0) { return r[0]; } } return null; }; }; /** * Converts the specified string value into its JavaScript Date equivalent using the specified format {String} or formats {Array} and the CultureInfo specific format information. * The format of the string value must match one of the supplied formats exactly. * * Example

	// 15-Oct-2004
	var d1 = Date.parseExact("10/15/2004", "M/d/yyyy");

	// 15-Oct-2004
	var d1 = Date.parse("15-Oct-2004", "M-ddd-yyyy");

	// 15-Oct-2004
	var d1 = Date.parse("2004.10.15", "yyyy.MM.dd");

	// Multiple formats
	var d1 = Date.parseExact("10/15/2004", ["M/d/yyyy", "MMMM d, yyyy"]);
	
* * @param {String} The string value to convert into a Date object [Required]. * @param {Object} The expected format {String} or an array of expected formats {Array} of the date string [Required]. * @return {Date} A Date object or null if the string cannot be converted into a Date. */ $D.parseExact = function (s, fx) { return $D.getParseFunction(fx)(s); }; }()); (function () { var $D = Date, $P = $D.prototype, // $C = $D.CultureInfo, // not used atm p = function (s, l) { if (!l) { l = 2; } return ("000" + s).slice(l * -1); }; /** * Converts a PHP format string to Java/.NET format string. * A PHP format string can be used with ._format or .format. * A Java/.NET format string can be used with .toString(). * The .parseExact function will only accept a Java/.NET format string * * Example * var f1 = "%m/%d/%y" * var f2 = Date.normalizeFormat(f1); // "MM/dd/yy" * * new Date().format(f1); // "04/13/08" * new Date()._format(f1); // "04/13/08" * new Date().toString(f2); // "04/13/08" * * var date = Date.parseExact("04/13/08", f2); // Sun Apr 13 2008 * * @param {String} A PHP format string consisting of one or more format spcifiers. * @return {String} The PHP format converted to a Java/.NET format string. */ var normalizerSubstitutions = { "d" : "dd", "%d": "dd", "D" : "ddd", "%a": "ddd", "j" : "dddd", "l" : "dddd", "%A": "dddd", "S" : "S", "F" : "MMMM", "%B": "MMMM", "m" : "MM", "%m": "MM", "M" : "MMM", "%b": "MMM", "%h": "MMM", "n" : "M", "Y" : "yyyy", "%Y": "yyyy", "y" : "yy", "%y": "yy", "g" : "h", "%I": "h", "G" : "H", "h" : "hh", "H" : "HH", "%H": "HH", "i" : "mm", "%M": "mm", "s" : "ss", "%S": "ss", "%r": "hh:mm tt", "%R": "H:mm", "%T": "H:mm:ss", "%X": "t", "%x": "d", "%e": "d", "%D": "MM/dd/yy", "%n": "\\n", "%t": "\\t", "e" : "z", "T" : "z", "%z": "z", "%Z": "z", "Z" : "ZZ", "N" : "u", "w" : "u", "%w": "u", "W" : "W", "%V": "W" }; var normalizer = { substitutes: function (m) { return normalizerSubstitutions[m]; }, interpreted: function (m, x) { var y; switch (m) { case "%u": return x.getDay() + 1; case "z": return x.getOrdinalNumber(); case "%j": return p(x.getOrdinalNumber(), 3); case "%U": var d1 = x.clone().set({month: 0, day: 1}).addDays(-1).moveToDayOfWeek(0), d2 = x.clone().addDays(1).moveToDayOfWeek(0, -1); return (d2 < d1) ? "00" : p((d2.getOrdinalNumber() - d1.getOrdinalNumber()) / 7 + 1); case "%W": return p(x.getWeek()); case "t": return $D.getDaysInMonth(x.getFullYear(), x.getMonth()); case "o": case "%G": return x.setWeek(x.getISOWeek()).toString("yyyy"); case "%g": return x._format("%G").slice(-2); case "a": case "%p": return t("tt").toLowerCase(); case "A": return t("tt").toUpperCase(); case "u": return p(x.getMilliseconds(), 3); case "I": return (x.isDaylightSavingTime()) ? 1 : 0; case "O": return x.getUTCOffset(); case "P": y = x.getUTCOffset(); return y.substring(0, y.length - 2) + ":" + y.substring(y.length - 2); case "B": var now = new Date(); return Math.floor(((now.getHours() * 3600) + (now.getMinutes() * 60) + now.getSeconds() + (now.getTimezoneOffset() + 60) * 60) / 86.4); case "c": return x.toISOString().replace(/\"/g, ""); case "U": return $D.strtotime("now"); case "%c": return t("d") + " " + t("t"); case "%C": return Math.floor(x.getFullYear() / 100 + 1); } }, shouldOverrideDefaults: function (m) { switch (m) { case "%e": return true; default: return false; } }, parse: function (m, context) { var formatString, c = context || new Date(); formatString = normalizer.substitutes(m); if (formatString) { return formatString; } formatString = normalizer.interpreted(m, c); if (formatString) { return formatString; } else { return m; } } }; $D.normalizeFormat = function (format, context) { return format.replace(/(%|\\)?.|%%/g, function(t){ return normalizer.parse(t, context); }); }; /** * Format a local Unix timestamp according to locale settings * * Example: * Date.strftime("%m/%d/%y", new Date()); // "04/13/08" * Date.strftime("c", "2008-04-13T17:52:03Z"); // "04/13/08" * * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @param {Number|String} The number representing the number of seconds that have elapsed since January 1, 1970 (local time). * @return {String} A string representation of the current Date object. */ $D.strftime = function (format, time) { var d = Date.parse(time); return d._format(format); }; /** * Parse any textual datetime description into a Unix timestamp. * A Unix timestamp is the number of seconds that have elapsed since January 1, 1970 (midnight UTC/GMT). * * Example: * Date.strtotime("04/13/08"); // 1208044800 * Date.strtotime("1970-01-01T00:00:00Z"); // 0 * * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @param {Object} A string or date object. * @return {String} A string representation of the current Date object. */ $D.strtotime = function (time) { var d = $D.parse(time); return Math.round($D.UTC(d.getUTCFullYear(), d.getUTCMonth(), d.getUTCDate(), d.getUTCHours(), d.getUTCMinutes(), d.getUTCSeconds(), d.getUTCMilliseconds()) / 1000); }; /** * Converts the value of the current Date object to its equivalent string representation using a PHP/Unix style of date format specifiers. * Format Specifiers * Format Description Example * ------ --------------------------------------------------------------------------- ----------------------- * %a abbreviated weekday name according to the current localed "Mon" through "Sun" * %A full weekday name according to the current localed "Sunday" through "Saturday" * %b abbreviated month name according to the current localed "Jan" through "Dec" * %B full month name according to the current locale "January" through "December" * %c preferred date and time representation for the current locale "4/13/2008 12:33 PM" * %C century number (the year divided by 100 and truncated to an integer) "00" to "99" * %d day of the month as a decimal number "01" to "31" * %D same as %m/%d/%y "04/13/08" * %e day of the month as a decimal number, a single digit is preceded by a space "1" to "31" * %g like %G, but without the century "08" * %G The 4-digit year corresponding to the ISO week number (see %V). "2008" * This has the same format and value as %Y, except that if the ISO week number * belongs to the previous or next year, that year is used instead. * %h same as %b "Jan" through "Dec" * %H hour as a decimal number using a 24-hour clock. "00" to "23" * %I hour as a decimal number using a 12-hour clock. "01" to "12" * %j day of the year as a decimal number. "001" to "366" * %m month as a decimal number. "01" to "12" * %M minute as a decimal number. "00" to "59" * %n newline character "\n" * %p either "am" or "pm" according to the given time value, or the "am" or "pm" * corresponding strings for the current locale. * %r time in a.m. and p.m. notation "8:44 PM" * %R time in 24 hour notation "20:44" * %S second as a decimal number "00" to "59" * %t tab character "\t" * %T current time, equal to %H:%M:%S "12:49:11" * %u weekday as a decimal number ["1", "7"], with "1" representing Monday "1" to "7" * %U week number of the current year as a decimal number, starting with the "0" to ("52" or "53") * first Sunday as the first day of the first week * %V The ISO 8601:1988 week number of the current year as a decimal number, "00" to ("52" or "53") * range 01 to 53, where week 1 is the first week that has at least 4 days * in the current year, and with Monday as the first day of the week. * (Use %G or %g for the year component that corresponds to the week number * for the specified timestamp.) * %W week number of the current year as a decimal number, starting with the "00" to ("52" or "53") * first Monday as the first day of the first week * %w day of the week as a decimal, Sunday being "0" "0" to "6" * %x preferred date representation for the current locale without the time "4/13/2008" * %X preferred time representation for the current locale without the date "12:53:05" * %y year as a decimal number without a century "00" "99" * %Y year as a decimal number including the century "2008" * %Z time zone or name or abbreviation "UTC", "EST", "PST" * %z same as %Z * %% a literal "%" characters "%" * d Day of the month, 2 digits with leading zeros "01" to "31" * D A textual representation of a day, three letters "Mon" through "Sun" * j Day of the month without leading zeros "1" to "31" * l A full textual representation of the day of the week (lowercase "L") "Sunday" through "Saturday" * N ISO-8601 numeric representation of the day of the week (added in PHP 5.1.0) "1" (for Monday) through "7" (for Sunday) * S English ordinal suffix for the day of the month, 2 characters "st", "nd", "rd" or "th". Works well with j * w Numeric representation of the day of the week "0" (for Sunday) through "6" (for Saturday) * z The day of the year (starting from "0") "0" through "365" * W ISO-8601 week number of year, weeks starting on Monday "00" to ("52" or "53") * F A full textual representation of a month, such as January or March "January" through "December" * m Numeric representation of a month, with leading zeros "01" through "12" * M A short textual representation of a month, three letters "Jan" through "Dec" * n Numeric representation of a month, without leading zeros "1" through "12" * t Number of days in the given month "28" through "31" * L Whether it's a leap year "1" if it is a leap year, "0" otherwise * o ISO-8601 year number. This has the same value as Y, except that if the "2008" * ISO week number (W) belongs to the previous or next year, that year * is used instead. * Y A full numeric representation of a year, 4 digits "2008" * y A two digit representation of a year "08" * a Lowercase Ante meridiem and Post meridiem "am" or "pm" * A Uppercase Ante meridiem and Post meridiem "AM" or "PM" * B Swatch Internet time "000" through "999" * g 12-hour format of an hour without leading zeros "1" through "12" * G 24-hour format of an hour without leading zeros "0" through "23" * h 12-hour format of an hour with leading zeros "01" through "12" * H 24-hour format of an hour with leading zeros "00" through "23" * i Minutes with leading zeros "00" to "59" * s Seconds, with leading zeros "00" through "59" * u Milliseconds "54321" * e Timezone identifier "UTC", "EST", "PST" * I Whether or not the date is in daylight saving time (uppercase i) "1" if Daylight Saving Time, "0" otherwise * O Difference to Greenwich time (GMT) in hours "+0200", "-0600" * P Difference to Greenwich time (GMT) with colon between hours and minutes "+02:00", "-06:00" * T Timezone abbreviation "UTC", "EST", "PST" * Z Timezone offset in seconds. The offset for timezones west of UTC is "-43200" through "50400" * always negative, and for those east of UTC is always positive. * c ISO 8601 date "2004-02-12T15:19:21+00:00" * r RFC 2822 formatted date "Thu, 21 Dec 2000 16:01:07 +0200" * U Seconds since the Unix Epoch (January 1 1970 00:00:00 GMT) "0" * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @return {String} A string representation of the current Date object. */ var formatReplace = function (context) { return function (m) { var formatString, override = false; if (m.charAt(0) === "\\" || m.substring(0, 2) === "%%") { return m.replace("\\", "").replace("%%", "%"); } override = normalizer.shouldOverrideDefaults(m); formatString = $D.normalizeFormat(m, context); if (formatString) { return context.toString(formatString, override); } }; }; $P._format = function (format) { var formatter = formatReplace(this); if (!format) { return this._toString(); } else { return format.replace(/(%|\\)?.|%%/g, formatter); } }; if (!$P.format) { $P.format = $P._format; } }()); (function () { "use strict"; var gFn = function (attr) { return function () { return this[attr]; }; }; var sFn = function (attr) { return function (val) { this[attr] = val; return this; }; }; var attrs = ["years", "months", "days", "hours", "minutes", "seconds", "milliseconds"]; var addSetFuncs = function (context, attrs) { for (var i = 0; i < attrs.length ; i++) { var $a = attrs[i], $b = $a.slice(0, 1).toUpperCase() + $a.slice(1); context.prototype[$a] = 0; context.prototype["get" + $b] = gFn($a); context.prototype["set" + $b] = sFn($a); } }; /** * new TimeSpan(milliseconds); * new TimeSpan(days, hours, minutes, seconds); * new TimeSpan(days, hours, minutes, seconds, milliseconds); */ var TimeSpan = function (days, hours, minutes, seconds, milliseconds) { if (arguments.length === 1 && typeof days === "number") { var orient = (days < 0) ? -1 : +1; var millsLeft = Math.abs(days); this.setDays(Math.floor(millsLeft / 86400000) * orient); millsLeft = millsLeft % 86400000; this.setHours(Math.floor(millsLeft / 3600000) * orient); millsLeft = millsLeft % 3600000; this.setMinutes(Math.floor(millsLeft / 60000) * orient); millsLeft = millsLeft % 60000; this.setSeconds(Math.floor(millsLeft / 1000) * orient); millsLeft = millsLeft % 1000; this.setMilliseconds(millsLeft * orient); } else { this.set(days, hours, minutes, seconds, milliseconds); } this.getTotalMilliseconds = function () { return (this.getDays() * 86400000) + (this.getHours() * 3600000) + (this.getMinutes() * 60000) + (this.getSeconds() * 1000); }; this.compareTo = function (time) { var t1 = new Date(1970, 1, 1, this.getHours(), this.getMinutes(), this.getSeconds()), t2; if (time === null) { t2 = new Date(1970, 1, 1, 0, 0, 0); } else { t2 = new Date(1970, 1, 1, time.getHours(), time.getMinutes(), time.getSeconds()); } return (t1 < t2) ? -1 : (t1 > t2) ? 1 : 0; }; this.equals = function (time) { return (this.compareTo(time) === 0); }; this.add = function (time) { return (time === null) ? this : this.addSeconds(time.getTotalMilliseconds() / 1000); }; this.subtract = function (time) { return (time === null) ? this : this.addSeconds(-time.getTotalMilliseconds() / 1000); }; this.addDays = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 86400000)); }; this.addHours = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 3600000)); }; this.addMinutes = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 60000)); }; this.addSeconds = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 1000)); }; this.addMilliseconds = function (n) { return new TimeSpan(this.getTotalMilliseconds() + n); }; this.get12HourHour = function () { return (this.getHours() > 12) ? this.getHours() - 12 : (this.getHours() === 0) ? 12 : this.getHours(); }; this.getDesignator = function () { return (this.getHours() < 12) ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator; }; this.toString = function (format) { this._toString = function () { if (this.getDays() !== null && this.getDays() > 0) { return this.getDays() + "." + this.getHours() + ":" + this.p(this.getMinutes()) + ":" + this.p(this.getSeconds()); } else { return this.getHours() + ":" + this.p(this.getMinutes()) + ":" + this.p(this.getSeconds()); } }; this.p = function (s) { return (s.toString().length < 2) ? "0" + s : s; }; var me = this; return format ? format.replace(/dd?|HH?|hh?|mm?|ss?|tt?/g, function (format) { switch (format) { case "d": return me.getDays(); case "dd": return me.p(me.getDays()); case "H": return me.getHours(); case "HH": return me.p(me.getHours()); case "h": return me.get12HourHour(); case "hh": return me.p(me.get12HourHour()); case "m": return me.getMinutes(); case "mm": return me.p(me.getMinutes()); case "s": return me.getSeconds(); case "ss": return me.p(me.getSeconds()); case "t": return ((me.getHours() < 12) ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator).substring(0, 1); case "tt": return (me.getHours() < 12) ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator; } } ) : this._toString(); }; return this; }; addSetFuncs(TimeSpan, attrs.slice(2)); TimeSpan.prototype.set = function (days, hours, minutes, seconds, milliseconds){ this.setDays(days || this.getDays()); this.setHours(hours || this.getHours()); this.setMinutes(minutes || this.getMinutes()); this.setSeconds(seconds || this.getSeconds()); this.setMilliseconds(milliseconds || this.getMilliseconds()); }; /** * Gets the time of day for this date instances. * @return {TimeSpan} TimeSpan */ Date.prototype.getTimeOfDay = function () { return new TimeSpan(0, this.getHours(), this.getMinutes(), this.getSeconds(), this.getMilliseconds()); }; Date.TimeSpan = TimeSpan; if (typeof window !== "undefined" ) { // keeping API compatible for v1.x window.TimeSpan = TimeSpan; } }()); (function () { "use strict"; var attrs = ["years", "months", "days", "hours", "minutes", "seconds", "milliseconds"]; var gFn = function (attr) { return function () { return this[attr]; }; }; var sFn = function (attr) { return function (val) { this[attr] = val; return this; }; }; var addSetFuncs = function (context, attrs) { for (var i = 0; i < attrs.length ; i++) { var $a = attrs[i], $b = $a.slice(0, 1).toUpperCase() + $a.slice(1); context.prototype[$a] = 0; context.prototype["get" + $b] = gFn($a); context.prototype["set" + $b] = sFn($a); } }; var setMonthsAndYears = function (orient, d1, d2, context) { function inc() { d1.addMonths(-orient); context.months++; if (context.months === 12) { context.years++; context.months = 0; } } if (orient === +1) { while (d1 > d2) { inc(); } } else { while (d1 < d2) { inc(); } } context.months--; context.months *= orient; context.years *= orient; }; var adjustForDST = function(orient, startDate, endDate) { var hasDSTMismatch = (false === (startDate.isDaylightSavingTime() === endDate.isDaylightSavingTime())); if (hasDSTMismatch && orient === 1) { startDate.addHours(-1); } else if (hasDSTMismatch) { startDate.addHours(1); } }; /** * TimePeriod(startDate, endDate); * TimePeriod(years, months, days, hours, minutes, seconds, milliseconds); */ var TimePeriod = function (years, months, days, hours, minutes, seconds, milliseconds) { if (arguments.length === 7) { this.set(years, months, days, hours, minutes, seconds, milliseconds); } else if (arguments.length === 2 && arguments[0] instanceof Date && arguments[1] instanceof Date) { var startDate = arguments[0].clone(); var endDate = arguments[1].clone(); var orient = (startDate > endDate) ? +1 : -1; this.dates = { start: arguments[0].clone(), end: arguments[1].clone() }; setMonthsAndYears(orient, startDate, endDate, this); adjustForDST(orient, startDate, endDate); // // TODO - adjust for DST var diff = endDate - startDate; if (diff !== 0) { var ts = new TimeSpan(diff); this.set(this.years, this.months, ts.getDays(), ts.getHours(), ts.getMinutes(), ts.getSeconds(), ts.getMilliseconds()); } } return this; }; // create all the set functions. addSetFuncs(TimePeriod, attrs); TimePeriod.prototype.set = function (years, months, days, hours, minutes, seconds, milliseconds){ this.setYears(years || this.getYears()); this.setMonths(months || this.getMonths()); this.setDays(days || this.getDays()); this.setHours(hours || this.getHours()); this.setMinutes(minutes || this.getMinutes()); this.setSeconds(seconds || this.getSeconds()); this.setMilliseconds(milliseconds || this.getMilliseconds()); }; Date.TimePeriod = TimePeriod; if (typeof window !== "undefined") { // keeping API compatible for v1.x window.TimePeriod = TimePeriod; } }()); ================================================ FILE: build/date-en-GB.js ================================================ /** * @overview datejs * @version 1.0.0-rc3 * @author Gregory Wild-Smith * @copyright 2015 Gregory Wild-Smith * @license MIT * @homepage https://github.com/abritinthebay/datejs */ /* * DateJS Culture String File * Country Code: en-GB * Name: English (United Kingdom) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["en-GB"] = { "name": "en-GB", "englishName": "English (United Kingdom)", "nativeName": "English (United Kingdom)", "Sunday": "Sunday", "Monday": "Monday", "Tuesday": "Tuesday", "Wednesday": "Wednesday", "Thursday": "Thursday", "Friday": "Friday", "Saturday": "Saturday", "Sun": "Sun", "Mon": "Mon", "Tue": "Tue", "Wed": "Wed", "Thu": "Thu", "Fri": "Fri", "Sat": "Sat", "Su": "Su", "Mo": "Mo", "Tu": "Tu", "We": "We", "Th": "Th", "Fr": "Fr", "Sa": "Sa", "S_Sun_Initial": "S", "M_Mon_Initial": "M", "T_Tue_Initial": "T", "W_Wed_Initial": "W", "T_Thu_Initial": "T", "F_Fri_Initial": "F", "S_Sat_Initial": "S", "January": "January", "February": "February", "March": "March", "April": "April", "May": "May", "June": "June", "July": "July", "August": "August", "September": "September", "October": "October", "November": "November", "December": "December", "Jan_Abbr": "Jan", "Feb_Abbr": "Feb", "Mar_Abbr": "Mar", "Apr_Abbr": "Apr", "May_Abbr": "May", "Jun_Abbr": "Jun", "Jul_Abbr": "Jul", "Aug_Abbr": "Aug", "Sep_Abbr": "Sep", "Oct_Abbr": "Oct", "Nov_Abbr": "Nov", "Dec_Abbr": "Dec", "AM": "AM", "PM": "PM", "firstDayOfWeek": 1, "twoDigitYearMax": 2029, "mdy": "dmy", "M/d/yyyy": "dd/MM/yyyy", "dddd, MMMM dd, yyyy": "dd MMMM yyyy", "h:mm tt": "HH:mm", "h:mm:ss tt": "HH:mm:ss", "dddd, MMMM dd, yyyy h:mm:ss tt": "dd MMMM yyyy HH:mm:ss", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "dd MMMM", "MMMM, yyyy": "MMMM yyyy", "/jan(uary)?/": "jan(uary)?", "/feb(ruary)?/": "feb(ruary)?", "/mar(ch)?/": "mar(ch)?", "/apr(il)?/": "apr(il)?", "/may/": "may", "/jun(e)?/": "jun(e)?", "/jul(y)?/": "jul(y)?", "/aug(ust)?/": "aug(ust)?", "/sep(t(ember)?)?/": "sep(t(ember)?)?", "/oct(ober)?/": "oct(ober)?", "/nov(ember)?/": "nov(ember)?", "/dec(ember)?/": "dec(ember)?", "/^su(n(day)?)?/": "^su(n(day)?)?", "/^mo(n(day)?)?/": "^mo(n(day)?)?", "/^tu(e(s(day)?)?)?/": "^tu(e(s(day)?)?)?", "/^we(d(nesday)?)?/": "^we(d(nesday)?)?", "/^th(u(r(s(day)?)?)?)?/": "^th(u(r(s(day)?)?)?)?", "/^fr(i(day)?)?/": "^fr(i(day)?)?", "/^sa(t(urday)?)?/": "^sa(t(urday)?)?", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "en-GB"; /** * @overview datejs * @version 1.0.0-rc3 * @author Gregory Wild-Smith * @copyright 2015 Gregory Wild-Smith * @license MIT * @homepage https://github.com/abritinthebay/datejs */(function () { var $D = Date; var lang = Date.CultureStrings ? Date.CultureStrings.lang : null; var loggedKeys = {}; // for debug purposes. var getText = { getFromKey: function (key, countryCode) { var output; if (Date.CultureStrings && Date.CultureStrings[countryCode] && Date.CultureStrings[countryCode][key]) { output = Date.CultureStrings[countryCode][key]; } else { output = getText.buildFromDefault(key); } if (key.charAt(0) === "/") { // Assume it's a regex output = getText.buildFromRegex(key, countryCode); } return output; }, getFromObjectValues: function (obj, countryCode) { var key, output = {}; for(key in obj) { if (obj.hasOwnProperty(key)) { output[key] = getText.getFromKey(obj[key], countryCode); } } return output; }, getFromObjectKeys: function (obj, countryCode) { var key, output = {}; for(key in obj) { if (obj.hasOwnProperty(key)) { output[getText.getFromKey(key, countryCode)] = obj[key]; } } return output; }, getFromArray: function (arr, countryCode) { var output = []; for (var i=0; i < arr.length; i++){ if (i in arr) { output[i] = getText.getFromKey(arr[i], countryCode); } } return output; }, buildFromDefault: function (key) { var output, length, split, last; switch(key) { case "name": output = "en-US"; break; case "englishName": output = "English (United States)"; break; case "nativeName": output = "English (United States)"; break; case "twoDigitYearMax": output = 2049; break; case "firstDayOfWeek": output = 0; break; default: output = key; split = key.split("_"); length = split.length; if (length > 1 && key.charAt(0) !== "/") { // if the key isn't a regex and it has a split. last = split[(length - 1)].toLowerCase(); if (last === "initial" || last === "abbr") { output = split[0]; } } break; } return output; }, buildFromRegex: function (key, countryCode) { var output; if (Date.CultureStrings && Date.CultureStrings[countryCode] && Date.CultureStrings[countryCode][key]) { output = new RegExp(Date.CultureStrings[countryCode][key], "i"); } else { output = new RegExp(key.replace(new RegExp("/", "g"),""), "i"); } return output; } }; var shallowMerge = function (obj1, obj2) { for (var attrname in obj2) { if (obj2.hasOwnProperty(attrname)) { obj1[attrname] = obj2[attrname]; } } }; var __ = function (key, language) { var countryCode = (language) ? language : lang; loggedKeys[key] = key; if (typeof key === "object") { if (key instanceof Array) { return getText.getFromArray(key, countryCode); } else { return getText.getFromObjectKeys(key, countryCode); } } else { return getText.getFromKey(key, countryCode); } }; var loadI18nScript = function (code) { // paatterned after jQuery's getScript. var url = Date.Config.i18n + code + ".js"; var head = document.getElementsByTagName("head")[0] || document.documentElement; var script = document.createElement("script"); script.src = url; var completed = false; var events = { done: function (){} // placeholder function }; // Attach handlers for all browsers script.onload = script.onreadystatechange = function() { if ( !completed && (!this.readyState || this.readyState === "loaded" || this.readyState === "complete") ) { events.done(); head.removeChild(script); } }; setTimeout(function() { head.insertBefore(script, head.firstChild); }, 0); // allows return to execute first return { done: function (cb) { events.done = function() { if (cb) { setTimeout(cb,0); } }; } }; }; var buildInfo = { buildFromMethodHash: function (obj) { var key; for(key in obj) { if (obj.hasOwnProperty(key)) { obj[key] = buildInfo[obj[key]](); } } return obj; }, timeZoneDST: function () { var DST = { "CHADT": "+1345", "NZDT": "+1300", "AEDT": "+1100", "ACDT": "+1030", "AZST": "+0500", "IRDT": "+0430", "EEST": "+0300", "CEST": "+0200", "BST": "+0100", "PMDT": "-0200", "ADT": "-0300", "NDT": "-0230", "EDT": "-0400", "CDT": "-0500", "MDT": "-0600", "PDT": "-0700", "AKDT": "-0800", "HADT": "-0900" }; return __(DST); }, timeZoneStandard: function () { var standard = { "LINT": "+1400", "TOT": "+1300", "CHAST": "+1245", "NZST": "+1200", "NFT": "+1130", "SBT": "+1100", "AEST": "+1000", "ACST": "+0930", "JST": "+0900", "CWST": "+0845", "CT": "+0800", "ICT": "+0700", "MMT": "+0630", "BST": "+0600", "NPT": "+0545", "IST": "+0530", "PKT": "+0500", "AFT": "+0430", "MSK": "+0400", "IRST": "+0330", "FET": "+0300", "EET": "+0200", "CET": "+0100", "GMT": "+0000", "UTC": "+0000", "CVT": "-0100", "GST": "-0200", "BRT": "-0300", "NST": "-0330", "AST": "-0400", "EST": "-0500", "CST": "-0600", "MST": "-0700", "PST": "-0800", "AKST": "-0900", "MIT": "-0930", "HST": "-1000", "SST": "-1100", "BIT": "-1200" }; return __(standard); }, timeZones: function (data) { var zone; data.timezones = []; for (zone in data.abbreviatedTimeZoneStandard) { if (data.abbreviatedTimeZoneStandard.hasOwnProperty(zone)) { data.timezones.push({ name: zone, offset: data.abbreviatedTimeZoneStandard[zone]}); } } for (zone in data.abbreviatedTimeZoneDST) { if (data.abbreviatedTimeZoneDST.hasOwnProperty(zone)) { data.timezones.push({ name: zone, offset: data.abbreviatedTimeZoneDST[zone], dst: true}); } } return data.timezones; }, days: function () { return __(["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"]); }, dayAbbr: function () { return __(["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"]); }, dayShortNames: function () { return __(["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"]); }, dayFirstLetters: function () { return __(["S_Sun_Initial", "M_Mon_Initial", "T_Tues_Initial", "W_Wed_Initial", "T_Thu_Initial", "F_Fri_Initial", "S_Sat_Initial"]); }, months: function () { return __(["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"]); }, monthAbbr: function () { return __(["Jan_Abbr", "Feb_Abbr", "Mar_Abbr", "Apr_Abbr", "May_Abbr", "Jun_Abbr", "Jul_Abbr", "Aug_Abbr", "Sep_Abbr", "Oct_Abbr", "Nov_Abbr", "Dec_Abbr"]); }, formatPatterns: function () { return getText.getFromObjectValues({ shortDate: "M/d/yyyy", longDate: "dddd, MMMM dd, yyyy", shortTime: "h:mm tt", longTime: "h:mm:ss tt", fullDateTime: "dddd, MMMM dd, yyyy h:mm:ss tt", sortableDateTime: "yyyy-MM-ddTHH:mm:ss", universalSortableDateTime: "yyyy-MM-dd HH:mm:ssZ", rfc1123: "ddd, dd MMM yyyy HH:mm:ss", monthDay: "MMMM dd", yearMonth: "MMMM, yyyy" }, Date.i18n.currentLanguage()); }, regex: function () { return getText.getFromObjectValues({ inTheMorning: "/( in the )(morn(ing)?)\\b/", thisMorning: "/(this )(morn(ing)?)\\b/", amThisMorning: "/(\b\\d(am)? )(this )(morn(ing)?)/", inTheEvening: "/( in the )(even(ing)?)\\b/", thisEvening: "/(this )(even(ing)?)\\b/", pmThisEvening: "/(\b\\d(pm)? )(this )(even(ing)?)/", jan: "/jan(uary)?/", feb: "/feb(ruary)?/", mar: "/mar(ch)?/", apr: "/apr(il)?/", may: "/may/", jun: "/jun(e)?/", jul: "/jul(y)?/", aug: "/aug(ust)?/", sep: "/sep(t(ember)?)?/", oct: "/oct(ober)?/", nov: "/nov(ember)?/", dec: "/dec(ember)?/", sun: "/^su(n(day)?)?/", mon: "/^mo(n(day)?)?/", tue: "/^tu(e(s(day)?)?)?/", wed: "/^we(d(nesday)?)?/", thu: "/^th(u(r(s(day)?)?)?)?/", fri: "/fr(i(day)?)?/", sat: "/^sa(t(urday)?)?/", future: "/^next/", past: "/^last|past|prev(ious)?/", add: "/^(\\+|aft(er)?|from|hence)/", subtract: "/^(\\-|bef(ore)?|ago)/", yesterday: "/^yes(terday)?/", today: "/^t(od(ay)?)?/", tomorrow: "/^tom(orrow)?/", now: "/^n(ow)?/", millisecond: "/^ms|milli(second)?s?/", second: "/^sec(ond)?s?/", minute: "/^mn|min(ute)?s?/", hour: "/^h(our)?s?/", week: "/^w(eek)?s?/", month: "/^m(onth)?s?/", day: "/^d(ay)?s?/", year: "/^y(ear)?s?/", shortMeridian: "/^(a|p)/", longMeridian: "/^(a\\.?m?\\.?|p\\.?m?\\.?)/", timezone: "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/", ordinalSuffix: "/^\\s*(st|nd|rd|th)/", timeContext: "/^\\s*(\\:|a(?!u|p)|p)/" }, Date.i18n.currentLanguage()); } }; var CultureInfo = function () { var info = getText.getFromObjectValues({ name: "name", englishName: "englishName", nativeName: "nativeName", amDesignator: "AM", pmDesignator: "PM", firstDayOfWeek: "firstDayOfWeek", twoDigitYearMax: "twoDigitYearMax", dateElementOrder: "mdy" }, Date.i18n.currentLanguage()); var constructedInfo = buildInfo.buildFromMethodHash({ dayNames: "days", abbreviatedDayNames: "dayAbbr", shortestDayNames: "dayShortNames", firstLetterDayNames: "dayFirstLetters", monthNames: "months", abbreviatedMonthNames: "monthAbbr", formatPatterns: "formatPatterns", regexPatterns: "regex", abbreviatedTimeZoneDST: "timeZoneDST", abbreviatedTimeZoneStandard: "timeZoneStandard" }); shallowMerge(info, constructedInfo); buildInfo.timeZones(info); return info; }; $D.i18n = { __: function (key, lang) { return __(key, lang); }, currentLanguage: function () { return lang || "en-US"; }, setLanguage: function (code, force, cb) { var async = false; if (force || code === "en-US" || (!!Date.CultureStrings && !!Date.CultureStrings[code])) { lang = code; Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings.lang = code; Date.CultureInfo = new CultureInfo(); } else { if (!(!!Date.CultureStrings && !!Date.CultureStrings[code])) { if (typeof exports !== "undefined" && this.exports !== exports) { // we're in a Node enviroment, load it using require try { require("../i18n/" + code + ".js"); lang = code; Date.CultureStrings.lang = code; Date.CultureInfo = new CultureInfo(); } catch (e) { // var str = "The language for '" + code + "' could not be loaded by Node. It likely does not exist."; throw new Error("The DateJS IETF language tag '" + code + "' could not be loaded by Node. It likely does not exist."); } } else if (Date.Config && Date.Config.i18n) { // we know the location of the files, so lets load them async = true; loadI18nScript(code).done(function(){ lang = code; Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings.lang = code; Date.CultureInfo = new CultureInfo(); $D.Parsing.Normalizer.buildReplaceData(); // because this is async if ($D.Grammar) { $D.Grammar.buildGrammarFormats(); // so we can parse those strings... } if (cb) { setTimeout(cb,0); } }); } else { Date.console.error("The DateJS IETF language tag '" + code + "' is not available and has not been loaded."); return false; } } } $D.Parsing.Normalizer.buildReplaceData(); // rebuild normalizer strings if ($D.Grammar) { $D.Grammar.buildGrammarFormats(); // so we can parse those strings... } if (!async && cb) { setTimeout(cb,0); } }, getLoggedKeys: function () { return loggedKeys; }, updateCultureInfo: function () { Date.CultureInfo = new CultureInfo(); } }; $D.i18n.updateCultureInfo(); // run automatically }()); (function () { var $D = Date, $P = $D.prototype, p = function (s, l) { if (!l) { l = 2; } return ("000" + s).slice(l * -1); }; if (typeof window !== "undefined" && typeof window.console !== "undefined" && typeof window.console.log !== "undefined") { $D.console = console; // used only to raise non-critical errors if available } else { // set mock so we don't give errors. $D.console = { log: function(){}, error: function(){} }; } $D.Config = $D.Config || {}; $D.initOverloads = function() { /** * Overload of Date.now. Allows an alternate call for Date.now where it returns the * current Date as an object rather than just milliseconds since the Unix Epoch. * * Also provides an implementation of now() for browsers (IE<9) that don't have it. * * Backwards compatible so with work with either: * Date.now() [returns ms] * or * Date.now(true) [returns Date] */ if (!$D.now) { $D._now = function now() { return new Date().getTime(); }; } else if (!$D._now) { $D._now = $D.now; } $D.now = function (returnObj) { if (returnObj) { return $D.present(); } else { return $D._now(); } }; if ( !$P.toISOString ) { $P.toISOString = function() { return this.getUTCFullYear() + "-" + p(this.getUTCMonth() + 1) + "-" + p(this.getUTCDate()) + "T" + p(this.getUTCHours()) + ":" + p(this.getUTCMinutes()) + ":" + p(this.getUTCSeconds()) + "." + String( (this.getUTCMilliseconds()/1000).toFixed(3)).slice(2, 5) + "Z"; }; } // private if ( $P._toString === undefined ){ $P._toString = $P.toString; } }; $D.initOverloads(); /** * Gets a date that is set to the current date. The time is set to the start of the day (00:00 or 12:00 AM). * @return {Date} The current date. */ $D.today = function () { return new Date().clearTime(); }; /** * Gets a date that is set to the current date and time (same as new Date, but chainable) * @return {Date} The current date. */ $D.present = function () { return new Date(); }; /** * Compares the first date to the second date and returns an number indication of their relative values. * @param {Date} First Date object to compare [Required]. * @param {Date} Second Date object to compare to [Required]. * @return {Number} -1 = date1 is lessthan date2. 0 = values are equal. 1 = date1 is greaterthan date2. */ $D.compare = function (date1, date2) { if (isNaN(date1) || isNaN(date2)) { throw new Error(date1 + " - " + date2); } else if (date1 instanceof Date && date2 instanceof Date) { return (date1 < date2) ? -1 : (date1 > date2) ? 1 : 0; } else { throw new TypeError(date1 + " - " + date2); } }; /** * Compares the first Date object to the second Date object and returns true if they are equal. * @param {Date} First Date object to compare [Required] * @param {Date} Second Date object to compare to [Required] * @return {Boolean} true if dates are equal. false if they are not equal. */ $D.equals = function (date1, date2) { return (date1.compareTo(date2) === 0); }; /** * Gets the language appropriate day name when given the day number(0-6) * eg - 0 == Sunday * @return {String} The day name */ $D.getDayName = function (n) { return Date.CultureInfo.dayNames[n]; }; /** * Gets the day number (0-6) if given a CultureInfo specific string which is a valid dayName, abbreviatedDayName or shortestDayName (two char). * @param {String} The name of the day (eg. "Monday, "Mon", "tuesday", "tue", "We", "we"). * @return {Number} The day number */ $D.getDayNumberFromName = function (name) { var n = Date.CultureInfo.dayNames, m = Date.CultureInfo.abbreviatedDayNames, o = Date.CultureInfo.shortestDayNames, s = name.toLowerCase(); for (var i = 0; i < n.length; i++) { if (n[i].toLowerCase() === s || m[i].toLowerCase() === s || o[i].toLowerCase() === s) { return i; } } return -1; }; /** * Gets the month number (0-11) if given a Culture Info specific string which is a valid monthName or abbreviatedMonthName. * @param {String} The name of the month (eg. "February, "Feb", "october", "oct"). * @return {Number} The day number */ $D.getMonthNumberFromName = function (name) { var n = Date.CultureInfo.monthNames, m = Date.CultureInfo.abbreviatedMonthNames, s = name.toLowerCase(); for (var i = 0; i < n.length; i++) { if (n[i].toLowerCase() === s || m[i].toLowerCase() === s) { return i; } } return -1; }; /** * Gets the language appropriate month name when given the month number(0-11) * eg - 0 == January * @return {String} The month name */ $D.getMonthName = function (n) { return Date.CultureInfo.monthNames[n]; }; /** * Determines if the current date instance is within a LeapYear. * @param {Number} The year. * @return {Boolean} true if date is within a LeapYear, otherwise false. */ $D.isLeapYear = function (year) { return ((year % 4 === 0 && year % 100 !== 0) || year % 400 === 0); }; /** * Gets the number of days in the month, given a year and month value. Automatically corrects for LeapYear. * @param {Number} The year. * @param {Number} The month (0-11). * @return {Number} The number of days in the month. */ $D.getDaysInMonth = function (year, month) { if (!month && $D.validateMonth(year)) { month = year; year = Date.today().getFullYear(); } return [31, ($D.isLeapYear(year) ? 29 : 28), 31, 30, 31, 30, 31, 31, 30, 31, 30, 31][month]; }; $P.getDaysInMonth = function () { return $D.getDaysInMonth(this.getFullYear(), this.getMonth()); }; $D.getTimezoneAbbreviation = function (offset, dst) { var p, n = (dst || false) ? Date.CultureInfo.abbreviatedTimeZoneDST : Date.CultureInfo.abbreviatedTimeZoneStandard; for (p in n) { if (n.hasOwnProperty(p)) { if (n[p] === offset) { return p; } } } return null; }; $D.getTimezoneOffset = function (name, dst) { var i, a =[], z = Date.CultureInfo.timezones; if (!name) { name = (new Date()).getTimezone();} for (i = 0; i < z.length; i++) { if (z[i].name === name.toUpperCase()) { a.push(i); } } if (!z[a[0]]) { return null; } if (a.length === 1 || !dst) { return z[a[0]].offset; } else { for (i=0; i < a.length; i++) { if (z[a[i]].dst) { return z[a[i]].offset; } } } }; $D.getQuarter = function (d) { d = d || new Date(); // If no date supplied, use today var q = [1,2,3,4]; return q[Math.floor(d.getMonth() / 3)]; // ~~~ is a bitwise op. Faster than Math.floor }; $D.getDaysLeftInQuarter = function (d) { d = d || new Date(); var qEnd = new Date(d); qEnd.setMonth(qEnd.getMonth() + 3 - qEnd.getMonth() % 3, 0); return Math.floor((qEnd - d) / 8.64e7); }; // private var validate = function (n, min, max, name) { name = name ? name : "Object"; if (typeof n === "undefined") { return false; } else if (typeof n !== "number") { throw new TypeError(n + " is not a Number."); } else if (n < min || n > max) { // As failing validation is *not* an exceptional circumstance // lets not throw a RangeError Exception here. // It's semantically correct but it's not sensible. return false; } return true; }; /** * Validates the number is within an acceptable range for milliseconds [0-999]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateMillisecond = function (value) { return validate(value, 0, 999, "millisecond"); }; /** * Validates the number is within an acceptable range for seconds [0-59]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateSecond = function (value) { return validate(value, 0, 59, "second"); }; /** * Validates the number is within an acceptable range for minutes [0-59]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateMinute = function (value) { return validate(value, 0, 59, "minute"); }; /** * Validates the number is within an acceptable range for hours [0-23]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateHour = function (value) { return validate(value, 0, 23, "hour"); }; /** * Validates the number is within an acceptable range for the days in a month [0-MaxDaysInMonth]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateDay = function (value, year, month) { if (year === undefined || year === null || month === undefined || month === null) { return false;} return validate(value, 1, $D.getDaysInMonth(year, month), "day"); }; /** * Validates the number is within an acceptable range for months [0-11]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateWeek = function (value) { return validate(value, 0, 53, "week"); }; /** * Validates the number is within an acceptable range for months [0-11]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateMonth = function (value) { return validate(value, 0, 11, "month"); }; /** * Validates the number is within an acceptable range for years. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateYear = function (value) { /** * Per ECMAScript spec the range of times supported by Date objects is * exactly -100,000,000 days to +100,000,000 days measured relative to * midnight at the beginning of 01 January, 1970 UTC. * This gives a range of 8,640,000,000,000,000 milliseconds to either * side of 01 January, 1970 UTC. * * Earliest possible date: Tue, 20 Apr 271,822 B.C. 00:00:00 UTC * Latest possible date: Sat, 13 Sep 275,760 00:00:00 UTC */ return validate(value, -271822, 275760, "year"); }; $D.validateTimezone = function(value) { var timezones = {"ACDT":1,"ACST":1,"ACT":1,"ADT":1,"AEDT":1,"AEST":1,"AFT":1,"AKDT":1,"AKST":1,"AMST":1,"AMT":1,"ART":1,"AST":1,"AWDT":1,"AWST":1,"AZOST":1,"AZT":1,"BDT":1,"BIOT":1,"BIT":1,"BOT":1,"BRT":1,"BST":1,"BTT":1,"CAT":1,"CCT":1,"CDT":1,"CEDT":1,"CEST":1,"CET":1,"CHADT":1,"CHAST":1,"CHOT":1,"ChST":1,"CHUT":1,"CIST":1,"CIT":1,"CKT":1,"CLST":1,"CLT":1,"COST":1,"COT":1,"CST":1,"CT":1,"CVT":1,"CWST":1,"CXT":1,"DAVT":1,"DDUT":1,"DFT":1,"EASST":1,"EAST":1,"EAT":1,"ECT":1,"EDT":1,"EEDT":1,"EEST":1,"EET":1,"EGST":1,"EGT":1,"EIT":1,"EST":1,"FET":1,"FJT":1,"FKST":1,"FKT":1,"FNT":1,"GALT":1,"GAMT":1,"GET":1,"GFT":1,"GILT":1,"GIT":1,"GMT":1,"GST":1,"GYT":1,"HADT":1,"HAEC":1,"HAST":1,"HKT":1,"HMT":1,"HOVT":1,"HST":1,"ICT":1,"IDT":1,"IOT":1,"IRDT":1,"IRKT":1,"IRST":1,"IST":1,"JST":1,"KGT":1,"KOST":1,"KRAT":1,"KST":1,"LHST":1,"LINT":1,"MAGT":1,"MART":1,"MAWT":1,"MDT":1,"MET":1,"MEST":1,"MHT":1,"MIST":1,"MIT":1,"MMT":1,"MSK":1,"MST":1,"MUT":1,"MVT":1,"MYT":1,"NCT":1,"NDT":1,"NFT":1,"NPT":1,"NST":1,"NT":1,"NUT":1,"NZDT":1,"NZST":1,"OMST":1,"ORAT":1,"PDT":1,"PET":1,"PETT":1,"PGT":1,"PHOT":1,"PHT":1,"PKT":1,"PMDT":1,"PMST":1,"PONT":1,"PST":1,"PYST":1,"PYT":1,"RET":1,"ROTT":1,"SAKT":1,"SAMT":1,"SAST":1,"SBT":1,"SCT":1,"SGT":1,"SLST":1,"SRT":1,"SST":1,"SYOT":1,"TAHT":1,"THA":1,"TFT":1,"TJT":1,"TKT":1,"TLT":1,"TMT":1,"TOT":1,"TVT":1,"UCT":1,"ULAT":1,"UTC":1,"UYST":1,"UYT":1,"UZT":1,"VET":1,"VLAT":1,"VOLT":1,"VOST":1,"VUT":1,"WAKT":1,"WAST":1,"WAT":1,"WEDT":1,"WEST":1,"WET":1,"WST":1,"YAKT":1,"YEKT":1,"Z":1}; return (timezones[value] === 1); }; $D.validateTimezoneOffset= function(value) { // timezones go from +14hrs to -12hrs, the +X hours are negative offsets. return (value > -841 && value < 721); }; }()); (function () { var $D = Date, $P = $D.prototype, p = function (s, l) { if (!l) { l = 2; } return ("000" + s).slice(l * -1); }; var validateConfigObject = function (obj) { var result = {}, self = this, prop, testFunc; testFunc = function (prop, func, value) { if (prop === "day") { var month = (obj.month !== undefined) ? obj.month : self.getMonth(); var year = (obj.year !== undefined) ? obj.year : self.getFullYear(); return $D[func](value, year, month); } else { return $D[func](value); } }; for (prop in obj) { if (Object.prototype.hasOwnProperty.call(obj, prop)) { var func = "validate" + prop.charAt(0).toUpperCase() + prop.slice(1); if ($D[func] && obj[prop] !== null && testFunc(prop, func, obj[prop])) { result[prop] = obj[prop]; } } } return result; }; /** * Resets the time of this Date object to 12:00 AM (00:00), which is the start of the day. * @param {Boolean} .clone() this date instance before clearing Time * @return {Date} this */ $P.clearTime = function () { this.setHours(0); this.setMinutes(0); this.setSeconds(0); this.setMilliseconds(0); return this; }; /** * Resets the time of this Date object to the current time ('now'). * @return {Date} this */ $P.setTimeToNow = function () { var n = new Date(); this.setHours(n.getHours()); this.setMinutes(n.getMinutes()); this.setSeconds(n.getSeconds()); this.setMilliseconds(n.getMilliseconds()); return this; }; /** * Returns a new Date object that is an exact date and time copy of the original instance. * @return {Date} A new Date instance */ $P.clone = function () { return new Date(this.getTime()); }; /** * Compares this instance to a Date object and returns an number indication of their relative values. * @param {Date} Date object to compare [Required] * @return {Number} -1 = this is lessthan date. 0 = values are equal. 1 = this is greaterthan date. */ $P.compareTo = function (date) { return Date.compare(this, date); }; /** * Compares this instance to another Date object and returns true if they are equal. * @param {Date} Date object to compare. If no date to compare, new Date() [now] is used. * @return {Boolean} true if dates are equal. false if they are not equal. */ $P.equals = function (date) { return Date.equals(this, (date !== undefined ? date : new Date())); }; /** * Determines if this instance is between a range of two dates or equal to either the start or end dates. * @param {Date} Start of range [Required] * @param {Date} End of range [Required] * @return {Boolean} true is this is between or equal to the start and end dates, else false */ $P.between = function (start, end) { return this.getTime() >= start.getTime() && this.getTime() <= end.getTime(); }; /** * Determines if this date occurs after the date to compare to. * @param {Date} Date object to compare. If no date to compare, new Date() ("now") is used. * @return {Boolean} true if this date instance is greater than the date to compare to (or "now"), otherwise false. */ $P.isAfter = function (date) { return this.compareTo(date || new Date()) === 1; }; /** * Determines if this date occurs before the date to compare to. * @param {Date} Date object to compare. If no date to compare, new Date() ("now") is used. * @return {Boolean} true if this date instance is less than the date to compare to (or "now"). */ $P.isBefore = function (date) { return (this.compareTo(date || new Date()) === -1); }; /** * Determines if the current Date instance occurs today. * @return {Boolean} true if this date instance is 'today', otherwise false. */ /** * Determines if the current Date instance occurs on the same Date as the supplied 'date'. * If no 'date' to compare to is provided, the current Date instance is compared to 'today'. * @param {date} Date object to compare. If no date to compare, the current Date ("now") is used. * @return {Boolean} true if this Date instance occurs on the same Day as the supplied 'date'. */ $P.isToday = $P.isSameDay = function (date) { return this.clone().clearTime().equals((date || new Date()).clone().clearTime()); }; /** * Adds the specified number of milliseconds to this instance. * @param {Number} The number of milliseconds to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addMilliseconds = function (value) { if (!value) { return this; } this.setTime(this.getTime() + value * 1); return this; }; /** * Adds the specified number of seconds to this instance. * @param {Number} The number of seconds to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addSeconds = function (value) { if (!value) { return this; } return this.addMilliseconds(value * 1000); }; /** * Adds the specified number of seconds to this instance. * @param {Number} The number of seconds to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addMinutes = function (value) { if (!value) { return this; } return this.addMilliseconds(value * 60000); // 60*1000 }; /** * Adds the specified number of hours to this instance. * @param {Number} The number of hours to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addHours = function (value) { if (!value) { return this; } return this.addMilliseconds(value * 3600000); // 60*60*1000 }; /** * Adds the specified number of days to this instance. * @param {Number} The number of days to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addDays = function (value) { if (!value) { return this; } this.setDate(this.getDate() + value * 1); return this; }; /** * Adds the specified number of weekdays (ie - not sat or sun) to this instance. * @param {Number} The number of days to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addWeekdays = function (value) { if (!value) { return this; } var day = this.getDay(); var weeks = (Math.ceil(Math.abs(value)/7)); if (day === 0 || day === 6) { if (value > 0) { this.next().monday(); this.addDays(-1); day = this.getDay(); } } if (value < 0) { while (value < 0) { this.addDays(-1); day = this.getDay(); if (day !== 0 && day !== 6) { value++; } } return this; } else if (value > 5 || (6-day) <= value) { value = value + (weeks * 2); } return this.addDays(value); }; /** * Adds the specified number of weeks to this instance. * @param {Number} The number of weeks to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addWeeks = function (value) { if (!value) { return this; } return this.addDays(value * 7); }; /** * Adds the specified number of months to this instance. * @param {Number} The number of months to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addMonths = function (value) { if (!value) { return this; } var n = this.getDate(); this.setDate(1); this.setMonth(this.getMonth() + value * 1); this.setDate(Math.min(n, $D.getDaysInMonth(this.getFullYear(), this.getMonth()))); return this; }; $P.addQuarters = function (value) { if (!value) { return this; } // note this will take you to the same point in the quarter as you are now. // i.e. - if you are 15 days into the quarter you'll be 15 days into the resulting one. // bonus: this allows adding fractional quarters return this.addMonths(value * 3); }; /** * Adds the specified number of years to this instance. * @param {Number} The number of years to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addYears = function (value) { if (!value) { return this; } return this.addMonths(value * 12); }; /** * Adds (or subtracts) to the value of the years, months, weeks, days, hours, minutes, seconds, milliseconds of the date instance using given configuration object. Positive and Negative values allowed. * Example

	Date.today().add( { days: 1, months: 1 } )

	new Date().add( { years: -1 } )
	
* @param {Object} Configuration object containing attributes (months, days, etc.) * @return {Date} this */ $P.add = function (config) { if (typeof config === "number") { this._orient = config; return this; } var x = config; if (x.day) { // If we should be a different date than today (eg: for 'tomorrow -1d', etc). // Should only effect parsing, not direct usage (eg, Finish and FinishExact) if ((x.day - this.getDate()) !== 0) { this.setDate(x.day); } } if (x.milliseconds) { this.addMilliseconds(x.milliseconds); } if (x.seconds) { this.addSeconds(x.seconds); } if (x.minutes) { this.addMinutes(x.minutes); } if (x.hours) { this.addHours(x.hours); } if (x.weeks) { this.addWeeks(x.weeks); } if (x.months) { this.addMonths(x.months); } if (x.years) { this.addYears(x.years); } if (x.days) { this.addDays(x.days); } return this; }; /** * Get the week number. Week one (1) is the week which contains the first Thursday of the year. Monday is considered the first day of the week. * The .getWeek() function does NOT convert the date to UTC. The local datetime is used. * Please use .getISOWeek() to get the week of the UTC converted date. * @return {Number} 1 to 53 */ $P.getWeek = function (utc) { // Create a copy of this date object var self, target = new Date(this.valueOf()); if (utc) { target.addMinutes(target.getTimezoneOffset()); self = target.clone(); } else { self = this; } // ISO week date weeks start on monday // so correct the day number var dayNr = (self.getDay() + 6) % 7; // ISO 8601 states that week 1 is the week // with the first thursday of that year. // Set the target date to the thursday in the target week target.setDate(target.getDate() - dayNr + 3); // Store the millisecond value of the target date var firstThursday = target.valueOf(); // Set the target to the first thursday of the year // First set the target to january first target.setMonth(0, 1); // Not a thursday? Correct the date to the next thursday if (target.getDay() !== 4) { target.setMonth(0, 1 + ((4 - target.getDay()) + 7) % 7); } // The weeknumber is the number of weeks between the // first thursday of the year and the thursday in the target week return 1 + Math.ceil((firstThursday - target) / 604800000); // 604800000 = 7 * 24 * 3600 * 1000 }; /** * Get the ISO 8601 week number. Week one ("01") is the week which contains the first Thursday of the year. Monday is considered the first day of the week. * The .getISOWeek() function does convert the date to it's UTC value. Please use .getWeek() to get the week of the local date. * @return {String} "01" to "53" */ $P.getISOWeek = function () { return p(this.getWeek(true)); }; /** * Moves the date to Monday of the week set. Week one (1) is the week which contains the first Thursday of the year. * @param {Number} A Number (1 to 53) that represents the week of the year. * @return {Date} this */ $P.setWeek = function (n) { if ((n - this.getWeek()) === 0) { if (this.getDay() !== 1) { return this.moveToDayOfWeek(1, (this.getDay() > 1 ? -1 : 1)); } else { return this; } } else { return this.moveToDayOfWeek(1, (this.getDay() > 1 ? -1 : 1)).addWeeks(n - this.getWeek()); } }; $P.setQuarter = function (qtr) { var month = Math.abs(((qtr-1) * 3) + 1); return this.setMonth(month, 1); }; $P.getQuarter = function () { return Date.getQuarter(this); }; $P.getDaysLeftInQuarter = function () { return Date.getDaysLeftInQuarter(this); }; /** * Moves the date to the next n'th occurrence of the dayOfWeek starting from the beginning of the month. The number (-1) is a magic number and will return the last occurrence of the dayOfWeek in the month. * @param {Number} The dayOfWeek to move to * @param {Number} The n'th occurrence to move to. Use (-1) to return the last occurrence in the month * @return {Date} this */ $P.moveToNthOccurrence = function (dayOfWeek, occurrence) { if (dayOfWeek === "Weekday") { if (occurrence > 0) { this.moveToFirstDayOfMonth(); if (this.is().weekday()) { occurrence -= 1; } } else if (occurrence < 0) { this.moveToLastDayOfMonth(); if (this.is().weekday()) { occurrence += 1; } } else { return this; } return this.addWeekdays(occurrence); } var shift = 0; if (occurrence > 0) { shift = occurrence - 1; } else if (occurrence === -1) { this.moveToLastDayOfMonth(); if (this.getDay() !== dayOfWeek) { this.moveToDayOfWeek(dayOfWeek, -1); } return this; } return this.moveToFirstDayOfMonth().addDays(-1).moveToDayOfWeek(dayOfWeek, +1).addWeeks(shift); }; var moveToN = function (getFunc, addFunc, nVal) { return function (value, orient) { var diff = (value - this[getFunc]() + nVal * (orient || +1)) % nVal; return this[addFunc]((diff === 0) ? diff += nVal * (orient || +1) : diff); }; }; /** * Move to the next or last dayOfWeek based on the orient value. * @param {Number} The dayOfWeek to move to * @param {Number} Forward (+1) or Back (-1). Defaults to +1. [Optional] * @return {Date} this */ $P.moveToDayOfWeek = moveToN("getDay", "addDays", 7); /** * Move to the next or last month based on the orient value. * @param {Number} The month to move to. 0 = January, 11 = December * @param {Number} Forward (+1) or Back (-1). Defaults to +1. [Optional] * @return {Date} this */ $P.moveToMonth = moveToN("getMonth", "addMonths", 12); /** * Get the Ordinate of the current day ("th", "st", "rd"). * @return {String} */ $P.getOrdinate = function () { var num = this.getDate(); return ord(num); }; /** * Get the Ordinal day (numeric day number) of the year, adjusted for leap year. * @return {Number} 1 through 365 (366 in leap years) */ $P.getOrdinalNumber = function () { return Math.ceil((this.clone().clearTime() - new Date(this.getFullYear(), 0, 1)) / 86400000) + 1; }; /** * Get the time zone abbreviation of the current date. * @return {String} The abbreviated time zone name (e.g. "EST") */ $P.getTimezone = function () { return $D.getTimezoneAbbreviation(this.getUTCOffset(), this.isDaylightSavingTime()); }; $P.setTimezoneOffset = function (offset) { var here = this.getTimezoneOffset(), there = Number(offset) * -6 / 10; return (there || there === 0) ? this.addMinutes(there - here) : this; }; $P.setTimezone = function (offset) { return this.setTimezoneOffset($D.getTimezoneOffset(offset)); }; /** * Indicates whether Daylight Saving Time is observed in the current time zone. * @return {Boolean} true|false */ $P.hasDaylightSavingTime = function () { return (Date.today().set({month: 0, day: 1}).getTimezoneOffset() !== Date.today().set({month: 6, day: 1}).getTimezoneOffset()); }; /** * Indicates whether this Date instance is within the Daylight Saving Time range for the current time zone. * @return {Boolean} true|false */ $P.isDaylightSavingTime = function () { return Date.today().set({month: 0, day: 1}).getTimezoneOffset() !== this.getTimezoneOffset(); }; /** * Get the offset from UTC of the current date. * @return {String} The 4-character offset string prefixed with + or - (e.g. "-0500") */ $P.getUTCOffset = function (offset) { var n = (offset || this.getTimezoneOffset()) * -10 / 6, r; if (n < 0) { r = (n - 10000).toString(); return r.charAt(0) + r.substr(2); } else { r = (n + 10000).toString(); return "+" + r.substr(1); } }; /** * Returns the number of milliseconds between this date and date. * @param {Date} Defaults to now * @return {Number} The diff in milliseconds */ $P.getElapsed = function (date) { return (date || new Date()) - this; }; /** * Set the value of year, month, day, hour, minute, second, millisecond of date instance using given configuration object. * Example

	Date.today().set( { day: 20, month: 1 } )

	new Date().set( { millisecond: 0 } )
	
* * @param {Object} Configuration object containing attributes (month, day, etc.) * @return {Date} this */ $P.set = function (config) { config = validateConfigObject.call(this, config); var key; for (key in config) { if (Object.prototype.hasOwnProperty.call(config, key)) { var name = key.charAt(0).toUpperCase() + key.slice(1); var addFunc, getFunc; if (key !== "week" && key !== "month" && key !== "timezone" && key !== "timezoneOffset") { name += "s"; } addFunc = "add" + name; getFunc = "get" + name; if (key === "month") { addFunc = addFunc + "s"; } else if (key === "year"){ getFunc = "getFullYear"; } if (key !== "day" && key !== "timezone" && key !== "timezoneOffset" && key !== "week" && key !== "hour") { this[addFunc](config[key] - this[getFunc]()); } else if ( key === "timezone"|| key === "timezoneOffset" || key === "week" || key === "hour") { this["set"+name](config[key]); } } } // day has to go last because you can't validate the day without first knowing the month if (config.day) { this.addDays(config.day - this.getDate()); } return this; }; /** * Moves the date to the first day of the month. * @return {Date} this */ $P.moveToFirstDayOfMonth = function () { return this.set({ day: 1 }); }; /** * Moves the date to the last day of the month. * @return {Date} this */ $P.moveToLastDayOfMonth = function () { return this.set({ day: $D.getDaysInMonth(this.getFullYear(), this.getMonth())}); }; /** * Converts the value of the current Date object to its equivalent string representation. * Format Specifiers * CUSTOM DATE AND TIME FORMAT STRINGS * Format Description Example * ------ --------------------------------------------------------------------------- ----------------------- * s The seconds of the minute between 0-59. "0" to "59" * ss The seconds of the minute with leading zero if required. "00" to "59" * * m The minute of the hour between 0-59. "0" or "59" * mm The minute of the hour with leading zero if required. "00" or "59" * * h The hour of the day between 1-12. "1" to "12" * hh The hour of the day with leading zero if required. "01" to "12" * * H The hour of the day between 0-23. "0" to "23" * HH The hour of the day with leading zero if required. "00" to "23" * * d The day of the month between 1 and 31. "1" to "31" * dd The day of the month with leading zero if required. "01" to "31" * ddd Abbreviated day name. Date.CultureInfo.abbreviatedDayNames. "Mon" to "Sun" * dddd The full day name. Date.CultureInfo.dayNames. "Monday" to "Sunday" * * M The month of the year between 1-12. "1" to "12" * MM The month of the year with leading zero if required. "01" to "12" * MMM Abbreviated month name. Date.CultureInfo.abbreviatedMonthNames. "Jan" to "Dec" * MMMM The full month name. Date.CultureInfo.monthNames. "January" to "December" * * yy The year as a two-digit number. "99" or "08" * yyyy The full four digit year. "1999" or "2008" * * t Displays the first character of the A.M./P.M. designator. "A" or "P" * Date.CultureInfo.amDesignator or Date.CultureInfo.pmDesignator * tt Displays the A.M./P.M. designator. "AM" or "PM" * Date.CultureInfo.amDesignator or Date.CultureInfo.pmDesignator * * S The ordinal suffix ("st, "nd", "rd" or "th") of the current day. "st, "nd", "rd" or "th" * * STANDARD DATE AND TIME FORMAT STRINGS * Format Description Example *------ --------------------------------------------------------------------------- ----------------------- * d The CultureInfo shortDate Format Pattern "M/d/yyyy" * D The CultureInfo longDate Format Pattern "dddd, MMMM dd, yyyy" * F The CultureInfo fullDateTime Format Pattern "dddd, MMMM dd, yyyy h:mm:ss tt" * m The CultureInfo monthDay Format Pattern "MMMM dd" * r The CultureInfo rfc1123 Format Pattern "ddd, dd MMM yyyy HH:mm:ss GMT" * s The CultureInfo sortableDateTime Format Pattern "yyyy-MM-ddTHH:mm:ss" * t The CultureInfo shortTime Format Pattern "h:mm tt" * T The CultureInfo longTime Format Pattern "h:mm:ss tt" * u The CultureInfo universalSortableDateTime Format Pattern "yyyy-MM-dd HH:mm:ssZ" * y The CultureInfo yearMonth Format Pattern "MMMM, yyyy" * * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @return {String} A string representation of the current Date object. */ var ord = function (n) { switch (n * 1) { case 1: case 21: case 31: return "st"; case 2: case 22: return "nd"; case 3: case 23: return "rd"; default: return "th"; } }; var parseStandardFormats = function (format) { var y, c = Date.CultureInfo.formatPatterns; switch (format) { case "d": return this.toString(c.shortDate); case "D": return this.toString(c.longDate); case "F": return this.toString(c.fullDateTime); case "m": return this.toString(c.monthDay); case "r": case "R": y = this.clone().addMinutes(this.getTimezoneOffset()); return y.toString(c.rfc1123) + " GMT"; case "s": return this.toString(c.sortableDateTime); case "t": return this.toString(c.shortTime); case "T": return this.toString(c.longTime); case "u": y = this.clone().addMinutes(this.getTimezoneOffset()); return y.toString(c.universalSortableDateTime); case "y": return this.toString(c.yearMonth); default: return false; } }; var parseFormatStringsClosure = function (context) { return function (m) { if (m.charAt(0) === "\\") { return m.replace("\\", ""); } switch (m) { case "hh": return p(context.getHours() < 13 ? (context.getHours() === 0 ? 12 : context.getHours()) : (context.getHours() - 12)); case "h": return context.getHours() < 13 ? (context.getHours() === 0 ? 12 : context.getHours()) : (context.getHours() - 12); case "HH": return p(context.getHours()); case "H": return context.getHours(); case "mm": return p(context.getMinutes()); case "m": return context.getMinutes(); case "ss": return p(context.getSeconds()); case "s": return context.getSeconds(); case "yyyy": return p(context.getFullYear(), 4); case "yy": return p(context.getFullYear()); case "y": return context.getFullYear(); case "E": case "dddd": return Date.CultureInfo.dayNames[context.getDay()]; case "ddd": return Date.CultureInfo.abbreviatedDayNames[context.getDay()]; case "dd": return p(context.getDate()); case "d": return context.getDate(); case "MMMM": return Date.CultureInfo.monthNames[context.getMonth()]; case "MMM": return Date.CultureInfo.abbreviatedMonthNames[context.getMonth()]; case "MM": return p((context.getMonth() + 1)); case "M": return context.getMonth() + 1; case "t": return context.getHours() < 12 ? Date.CultureInfo.amDesignator.substring(0, 1) : Date.CultureInfo.pmDesignator.substring(0, 1); case "tt": return context.getHours() < 12 ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator; case "S": return ord(context.getDate()); case "W": return context.getWeek(); case "WW": return context.getISOWeek(); case "Q": return "Q" + context.getQuarter(); case "q": return String(context.getQuarter()); case "z": return context.getTimezone(); case "Z": case "X": return Date.getTimezoneOffset(context.getTimezone()); case "ZZ": // Timezone offset in seconds return context.getTimezoneOffset() * -60; case "u": return context.getDay(); case "L": return ($D.isLeapYear(context.getFullYear())) ? 1 : 0; case "B": // Swatch Internet Time (.beats) return "@"+((context.getUTCSeconds() + (context.getUTCMinutes()*60) + ((context.getUTCHours()+1)*3600))/86.4); default: return m; } }; }; $P.toString = function (format, ignoreStandards) { // Standard Date and Time Format Strings. Formats pulled from CultureInfo file and // may vary by culture. if (!ignoreStandards && format && format.length === 1) { output = parseStandardFormats.call(this, format); if (output) { return output; } } var parseFormatStrings = parseFormatStringsClosure(this); return format ? format.replace(/((\\)?(dd?d?d?|MM?M?M?|yy?y?y?|hh?|HH?|mm?|ss?|tt?|S|q|Q|WW?W?W?)(?![^\[]*\]))/g, parseFormatStrings).replace(/\[|\]/g, "") : this._toString(); }; }()); /************************************************************* * SugarPak - Domain Specific Language - Syntactical Sugar * *************************************************************/ (function () { var $D = Date, $P = $D.prototype, $N = Number.prototype; // private $P._orient = +1; // private $P._nth = null; // private $P._is = false; // private $P._same = false; // private $P._isSecond = false; // private $N._dateElement = "days"; /** * Moves the date to the next instance of a date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.today().next().friday();
	Date.today().next().fri();
	Date.today().next().march();
	Date.today().next().mar();
	Date.today().next().week();
	
* * @return {Date} date */ $P.next = function () { this._move = true; this._orient = +1; return this; }; /** * Creates a new Date (Date.today()) and moves the date to the next instance of the date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.next().friday();
	Date.next().fri();
	Date.next().march();
	Date.next().mar();
	Date.next().week();
	
* * @return {Date} date */ $D.next = function () { return $D.today().next(); }; /** * Moves the date to the previous instance of a date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.today().last().friday();
	Date.today().last().fri();
	Date.today().last().march();
	Date.today().last().mar();
	Date.today().last().week();
	
* * @return {Date} date */ $P.last = $P.prev = $P.previous = function () { this._move = true; this._orient = -1; return this; }; /** * Creates a new Date (Date.today()) and moves the date to the previous instance of the date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.last().friday();
	Date.last().fri();
	Date.previous().march();
	Date.prev().mar();
	Date.last().week();
	
* * @return {Date} date */ $D.last = $D.prev = $D.previous = function () { return $D.today().last(); }; /** * Performs a equality check when followed by either a month name, day name or .weekday() function. * Example

	Date.today().is().friday(); // true|false
	Date.today().is().fri();
	Date.today().is().march();
	Date.today().is().mar();
	
* * @return {Boolean} true|false */ $P.is = function () { this._is = true; return this; }; /** * Determines if two date objects occur on/in exactly the same instance of the subsequent date part function. * The function .same() must be followed by a date part function (example: .day(), .month(), .year(), etc). * * An optional Date can be passed in the date part function. If now date is passed as a parameter, 'Now' is used. * * The following example demonstrates how to determine if two dates fall on the exact same day. * * Example

	var d1 = Date.today(); // today at 00:00
	var d2 = new Date();   // exactly now.

	// Do they occur on the same day?
	d1.same().day(d2); // true
	
	// Do they occur on the same hour?
	d1.same().hour(d2); // false, unless d2 hour is '00' (midnight).
	
	// What if it's the same day, but one year apart?
	var nextYear = Date.today().add(1).year();

	d1.same().day(nextYear); // false, because the dates must occur on the exact same day. 
	
* * Scenario: Determine if a given date occurs during some week period 2 months from now. * * Example

	var future = Date.today().add(2).months();
	return someDate.same().week(future); // true|false;
	
* * @return {Boolean} true|false */ $P.same = function () { this._same = true; this._isSecond = false; return this; }; /** * Determines if the current date/time occurs during Today. Must be preceded by the .is() function. * Example

	someDate.is().today();    // true|false
	new Date().is().today();  // true
	Date.today().is().today();// true
	Date.today().add(-1).day().is().today(); // false
	
* * @return {Boolean} true|false */ $P.today = function () { return this.same().day(); }; /** * Determines if the current date is a weekday. This function must be preceded by the .is() function. * Example

	Date.today().is().weekday(); // true|false
	
* * @return {Boolean} true|false */ $P.weekday = function () { if (this._nth) { return df("Weekday").call(this); } if (this._move) { return this.addWeekdays(this._orient); } if (this._is) { this._is = false; return (!this.is().sat() && !this.is().sun()); } return false; }; /** * Determines if the current date is on the weekend. This function must be preceded by the .is() function. * Example

	Date.today().is().weekend(); // true|false
	
* * @return {Boolean} true|false */ $P.weekend = function () { if (this._is) { this._is = false; return (this.is().sat() || this.is().sun()); } return false; }; /** * Sets the Time of the current Date instance. A string "6:15 pm" or config object {hour:18, minute:15} are accepted. * Example

	// Set time to 6:15pm with a String
	Date.today().at("6:15pm");

	// Set time to 6:15pm with a config object
	Date.today().at({hour:18, minute:15});
	
* * @return {Date} date */ $P.at = function (time) { return (typeof time === "string") ? $D.parse(this.toString("d") + " " + time) : this.set(time); }; /** * Creates a new Date() and adds this (Number) to the date based on the preceding date element function (eg. second|minute|hour|day|month|year). * Example

	// Undeclared Numbers must be wrapped with parentheses. Requirment of JavaScript.
	(3).days().fromNow();
	(6).months().fromNow();

	// Declared Number variables do not require parentheses. 
	var n = 6;
	n.months().fromNow();
	
* * @return {Date} A new Date instance */ $N.fromNow = $N.after = function (date) { var c = {}; c[this._dateElement] = this; return ((!date) ? new Date() : date.clone()).add(c); }; /** * Creates a new Date() and subtract this (Number) from the date based on the preceding date element function (eg. second|minute|hour|day|month|year). * Example

	// Undeclared Numbers must be wrapped with parentheses. Requirment of JavaScript.
	(3).days().ago();
	(6).months().ago();

	// Declared Number variables do not require parentheses. 
	var n = 6;
	n.months().ago();
	
* * @return {Date} A new Date instance */ $N.ago = $N.before = function (date) { var c = {}, s = (this._dateElement[this._dateElement.length-1] !== "s") ? this._dateElement + "s" : this._dateElement; c[s] = this * -1; return ((!date) ? new Date() : date.clone()).add(c); }; // Do NOT modify the following string tokens. These tokens are used to build dynamic functions. // All culture-specific strings can be found in the CultureInfo files. var dx = ("sunday monday tuesday wednesday thursday friday saturday").split(/\s/), mx = ("january february march april may june july august september october november december").split(/\s/), px = ("Millisecond Second Minute Hour Day Week Month Year Quarter Weekday").split(/\s/), pxf = ("Milliseconds Seconds Minutes Hours Date Week Month FullYear Quarter").split(/\s/), nth = ("final first second third fourth fifth").split(/\s/), de; /** * Returns an object literal of all the date parts. * Example

	var o = new Date().toObject();
	
	// { year: 2008, month: 4, week: 20, day: 13, hour: 18, minute: 9, second: 32, millisecond: 812 }
	
	// The object properties can be referenced directly from the object.
	
	alert(o.day);  // alerts "13"
	alert(o.year); // alerts "2008"
	
* * @return {Date} An object literal representing the original date object. */ $P.toObject = function () { var o = {}; for (var i = 0; i < px.length; i++) { if (this["get" + pxf[i]]) { o[px[i].toLowerCase()] = this["get" + pxf[i]](); } } return o; }; /** * Returns a date created from an object literal. Ignores the .week property if set in the config. * Example

	var o = new Date().toObject();
	
	return Date.fromObject(o); // will return the same date. 

	var o2 = {month: 1, day: 20, hour: 18}; // birthday party!
	Date.fromObject(o2);
	
* * @return {Date} An object literal representing the original date object. */ $D.fromObject = function(config) { config.week = null; return Date.today().set(config); }; // Create day name functions and abbreviated day name functions (eg. monday(), friday(), fri()). var df = function (n) { return function () { if (this._is) { this._is = false; return this.getDay() === n; } if (this._move) { this._move = null; } if (this._nth !== null) { // If the .second() function was called earlier, remove the _orient // from the date, and then continue. // This is required because 'second' can be used in two different context. // // Example // // Date.today().add(1).second(); // Date.march().second().monday(); // // Things get crazy with the following... // Date.march().add(1).second().second().monday(); // but it works!! // if (this._isSecond) { this.addSeconds(this._orient * -1); } // make sure we reset _isSecond this._isSecond = false; var ntemp = this._nth; this._nth = null; var temp = this.clone().moveToLastDayOfMonth(); this.moveToNthOccurrence(n, ntemp); if (this > temp) { throw new RangeError($D.getDayName(n) + " does not occur " + ntemp + " times in the month of " + $D.getMonthName(temp.getMonth()) + " " + temp.getFullYear() + "."); } return this; } return this.moveToDayOfWeek(n, this._orient); }; }; var sdf = function (n) { return function () { var t = $D.today(), shift = n - t.getDay(); if (n === 0 && Date.CultureInfo.firstDayOfWeek === 1 && t.getDay() !== 0) { shift = shift + 7; } return t.addDays(shift); }; }; // Create month name functions and abbreviated month name functions (eg. january(), march(), mar()). var month_instance_functions = function (n) { return function () { if (this._is) { this._is = false; return this.getMonth() === n; } return this.moveToMonth(n, this._orient); }; }; var month_static_functions = function (n) { return function () { return $D.today().set({ month: n, day: 1 }); }; }; var processTerms = function (names, staticFunc, instanceFunc) { for (var i = 0; i < names.length; i++) { // Create constant static Name variables. $D[names[i].toUpperCase()] = $D[names[i].toUpperCase().substring(0, 3)] = i; // Create Name functions. $D[names[i]] = $D[names[i].substring(0, 3)] = staticFunc(i); // Create Name instance functions. $P[names[i]] = $P[names[i].substring(0, 3)] = instanceFunc(i); } }; processTerms(dx, sdf, df); processTerms(mx, month_static_functions, month_instance_functions); // Create date element functions and plural date element functions used with Date (eg. day(), days(), months()). var ef = function (j) { return function () { // if the .second() function was called earlier, the _orient // has alread been added. Just return this and reset _isSecond. if (this._isSecond) { this._isSecond = false; return this; } if (this._same) { this._same = this._is = false; var o1 = this.toObject(), o2 = (arguments[0] || new Date()).toObject(), v = "", k = j.toLowerCase(); // the substr trick with -1 doesn't work in IE8 or less k = (k[k.length-1] === "s") ? k.substring(0,k.length-1) : k; for (var m = (px.length - 1); m > -1; m--) { v = px[m].toLowerCase(); if (o1[v] !== o2[v]) { return false; } if (k === v) { break; } } return true; } if (j.substring(j.length - 1) !== "s") { j += "s"; } if (this._move) { this._move = null; } return this["add" + j](this._orient); }; }; var nf = function (n) { return function () { this._dateElement = n; return this; }; }; for (var k = 0; k < px.length; k++) { de = px[k].toLowerCase(); if(de !== "weekday") { // Create date element functions and plural date element functions used with Date (eg. day(), days(), months()). $P[de] = $P[de + "s"] = ef(px[k]); // Create date element functions and plural date element functions used with Number (eg. day(), days(), months()). $N[de] = $N[de + "s"] = nf(de + "s"); } } $P._ss = ef("Second"); var nthfn = function (n) { return function (dayOfWeek) { if (this._same) { return this._ss(arguments[0]); } if (dayOfWeek || dayOfWeek === 0) { return this.moveToNthOccurrence(dayOfWeek, n); } this._nth = n; // if the operator is 'second' add the _orient, then deal with it later... if (n === 2 && (dayOfWeek === undefined || dayOfWeek === null)) { this._isSecond = true; return this.addSeconds(this._orient); } return this; }; }; for (var l = 0; l < nth.length; l++) { $P[nth[l]] = (l === 0) ? nthfn(-1) : nthfn(l); } }()); (function () { "use strict"; Date.Parsing = { Exception: function (s) { this.message = "Parse error at '" + s.substring(0, 10) + " ...'"; } }; var $P = Date.Parsing; var dayOffsets = { standard: [0,31,59,90,120,151,181,212,243,273,304,334], leap: [0,31,60,91,121,152,182,213,244,274,305,335] }; $P.isLeapYear = function(year) { return ((year % 4 === 0) && (year % 100 !== 0)) || (year % 400 === 0); }; var utils = { multiReplace : function (str, hash ) { var key; for (key in hash) { if (Object.prototype.hasOwnProperty.call(hash, key)) { var regex; if (typeof hash[key] === "function") { } else { regex = (hash[key] instanceof RegExp) ? hash[key] : new RegExp(hash[key], "g"); } str = str.replace(regex, key); } } return str; }, getDayOfYearFromWeek : function (obj) { var d, jan4, offset; obj.weekDay = (!obj.weekDay && obj.weekDay !== 0) ? 1 : obj.weekDay; d = new Date(obj.year, 0, 4); jan4 = d.getDay() === 0 ? 7 : d.getDay(); // JS is 0 indexed on Sunday. offset = jan4+3; obj.dayOfYear = ((obj.week * 7) + (obj.weekDay === 0 ? 7 : obj.weekDay))-offset; return obj; }, getDayOfYear : function (obj, dayOffset) { if (!obj.dayOfYear) { obj = utils.getDayOfYearFromWeek(obj); } for (var i=0;i <= dayOffset.length;i++) { if (obj.dayOfYear < dayOffset[i] || i === dayOffset.length) { obj.day = obj.day ? obj.day : (obj.dayOfYear - dayOffset[i-1]); break; } else { obj.month = i; } } return obj; }, adjustForTimeZone : function (obj, date) { var offset; if (obj.zone.toUpperCase() === "Z" || (obj.zone_hours === 0 && obj.zone_minutes === 0)) { // it's UTC/GML so work out the current timeszone offset offset = -date.getTimezoneOffset(); } else { offset = (obj.zone_hours*60) + (obj.zone_minutes || 0); if (obj.zone_sign === "+") { offset *= -1; } offset -= date.getTimezoneOffset(); } date.setMinutes(date.getMinutes()+offset); return date; }, setDefaults : function (obj) { obj.year = obj.year || Date.today().getFullYear(); obj.hours = obj.hours || 0; obj.minutes = obj.minutes || 0; obj.seconds = obj.seconds || 0; obj.milliseconds = obj.milliseconds || 0; if (!(!obj.month && (obj.week || obj.dayOfYear))) { // if we have a month, or if we don't but don't have the day calculation data obj.month = obj.month || 0; obj.day = obj.day || 1; } return obj; }, dataNum: function (data, mod, explict, postProcess) { var dataNum = data*1; if (mod) { if (postProcess) { return data ? mod(data)*1 : data; } else { return data ? mod(dataNum) : data; } } else if (!explict){ return data ? dataNum : data; } else { return (data && typeof data !== "undefined") ? dataNum : data; } }, timeDataProcess: function (obj) { var timeObj = {}; for (var x in obj.data) { if (obj.data.hasOwnProperty(x)) { timeObj[x] = obj.ignore[x] ? obj.data[x] : utils.dataNum(obj.data[x], obj.mods[x], obj.explict[x], obj.postProcess[x]); } } if (obj.data.secmins) { obj.data.secmins = obj.data.secmins.replace(",", ".") * 60; if (!timeObj.minutes) { timeObj.minutes = obj.data.secmins; } else if (!timeObj.seconds) { timeObj.seconds = obj.data.secmins; } delete obj.secmins; } return timeObj; }, buildTimeObjectFromData: function (data) { var time = utils.timeDataProcess({ data: { year : data[1], month : data[5], day : data[7], week : data[8], dayOfYear : data[10], hours : data[15], zone_hours : data[23], zone_minutes : data[24], zone : data[21], zone_sign : data[22], weekDay : data[9], minutes: data[16], seconds: data[19], milliseconds: data[20], secmins: data[18] }, mods: { month: function(data) { return data-1; }, weekDay: function (data) { data = Math.abs(data); return (data === 7 ? 0 : data); }, minutes: function (data) { return data.replace(":",""); }, seconds: function (data) { return Math.floor( (data.replace(":","").replace(",","."))*1 ); }, milliseconds: function (data) { return (data.replace(",",".")*1000); } }, postProcess: { minutes: true, seconds: true, milliseconds: true }, explict: { zone_hours: true, zone_minutes: true }, ignore: { zone: true, zone_sign: true, secmins: true } }); return time; }, addToHash: function (hash, keys, data) { keys = keys; data = data; var len = keys.length; for (var i = 0; i < len; i++) { hash[keys[i]] = data[i]; } return hash; }, combineRegex: function (r1, r2) { return new RegExp("(("+r1.source+")\\s("+r2.source+"))"); }, getDateNthString: function(add, last, inc){ if (add) { return Date.today().addDays(inc).toString("d"); } else if (last) { return Date.today().last()[inc]().toString("d"); } }, buildRegexData: function (array) { var arr = []; var len = array.length; for (var i=0; i < len; i++) { if (Object.prototype.toString.call(array[i]) === '[object Array]') { // oldIE compat version of Array.isArray arr.push(this.combineRegex(array[i][0], array[i][1])); } else { arr.push(array[i]); } } return arr; } }; $P.processTimeObject = function (obj) { var date, dayOffset; utils.setDefaults(obj); dayOffset = ($P.isLeapYear(obj.year)) ? dayOffsets.leap : dayOffsets.standard; if (!obj.month && (obj.week || obj.dayOfYear)) { utils.getDayOfYear(obj, dayOffset); } else { obj.dayOfYear = dayOffset[obj.month] + obj.day; } date = new Date(obj.year, obj.month, obj.day, obj.hours, obj.minutes, obj.seconds, obj.milliseconds); if (obj.zone) { utils.adjustForTimeZone(obj, date); // adjust (and calculate) for timezone } return date; }; $P.ISO = { regex : /^([\+-]?\d{4}(?!\d{2}\b))((-?)((0[1-9]|1[0-2])(\3([12]\d|0[1-9]|3[01]))?|W([0-4]\d|5[0-3])(-?[1-7])?|(00[1-9]|0[1-9]\d|[12]\d{2}|3([0-5]\d|6[1-6])))([T\s]((([01]\d|2[0-4])((:?)[0-5]\d)?|24\:?00)([\.,]\d+(?!:))?)?(\17[0-5]\d([\.,]\d+)?)?\s?([zZ]|([\+-])([01]\d|2[0-3]):?([0-5]\d)?)?)?)?$/, parse : function (s) { var time, data = s.match(this.regex); if (!data || !data.length) { return null; } time = utils.buildTimeObjectFromData(data); if (!time.year || (!time.year && (!time.month && !time.day) && (!time.week && !time.dayOfYear)) ) { return null; } return $P.processTimeObject(time); } }; $P.Numeric = { isNumeric: function (e){return!isNaN(parseFloat(e))&&isFinite(e);}, regex: /\b([0-1]?[0-9])([0-3]?[0-9])([0-2]?[0-9]?[0-9][0-9])\b/i, parse: function (s) { var data, i, time = {}, order = Date.CultureInfo.dateElementOrder.split(""); if (!(this.isNumeric(s)) || // if it's non-numeric OR (s[0] === "+" && s[0] === "-")) { // It's an arithmatic string (eg +/-1000) return null; } if (s.length < 5 && s.indexOf(".") < 0 && s.indexOf("/") < 0) { // assume it's just a year. time.year = s; return $P.processTimeObject(time); } data = s.match(this.regex); if (!data || !data.length) { return null; } for (i=0; i < order.length; i++) { switch(order[i]) { case "d": time.day = data[i+1]; break; case "m": time.month = (data[i+1]-1); break; case "y": time.year = data[i+1]; break; } } return $P.processTimeObject(time); } }; $P.Normalizer = { regexData: function () { var $R = Date.CultureInfo.regexPatterns; return utils.buildRegexData([ $R.tomorrow, $R.yesterday, [$R.past, $R.mon], [$R.past, $R.tue], [$R.past, $R.wed], [$R.past, $R.thu], [$R.past, $R.fri], [$R.past, $R.sat], [$R.past, $R.sun] ]); }, basicReplaceHash : function() { var $R = Date.CultureInfo.regexPatterns; return { "January": $R.jan.source, "February": $R.feb, "March": $R.mar, "April": $R.apr, "May": $R.may, "June": $R.jun, "July": $R.jul, "August": $R.aug, "September": $R.sep, "October": $R.oct, "November": $R.nov, "December": $R.dec, "": /\bat\b/gi, " ": /\s{2,}/, "am": $R.inTheMorning, "9am": $R.thisMorning, "pm": $R.inTheEvening, "7pm":$R.thisEvening }; }, keys : function(){ return [ utils.getDateNthString(true, false, 1), // tomorrow utils.getDateNthString(true, false, -1), // yesterday utils.getDateNthString(false, true, "monday"), //last mon utils.getDateNthString(false, true, "tuesday"), //last tues utils.getDateNthString(false, true, "wednesday"), //last wed utils.getDateNthString(false, true, "thursday"), //last thurs utils.getDateNthString(false, true, "friday"), //last fri utils.getDateNthString(false, true, "saturday"), //last sat utils.getDateNthString(false, true, "sunday") //last sun ]; }, buildRegexFunctions: function () { var $R = Date.CultureInfo.regexPatterns; var __ = Date.i18n.__; var tomorrowRE = new RegExp("(\\b\\d\\d?("+__("AM")+"|"+__("PM")+")? )("+$R.tomorrow.source.slice(1)+")", "i"); // adapted tomorrow regex for AM PM relative dates var todayRE = new RegExp($R.today.source + "(?!\\s*([+-]))\\b"); // today, but excludes the math operators (eg "today + 2h") this.replaceFuncs = [ [todayRE, function (full) { return (full.length > 1) ? Date.today().toString("d") : full; }], [tomorrowRE, function(full, m1) { var t = Date.today().addDays(1).toString("d"); return (t + " " + m1); }], [$R.amThisMorning, function(str, am){return am;}], [$R.pmThisEvening, function(str, pm){return pm;}] ]; }, buildReplaceData: function () { this.buildRegexFunctions(); this.replaceHash = utils.addToHash(this.basicReplaceHash(), this.keys(), this.regexData()); }, stringReplaceFuncs: function (s) { for (var i=0; i < this.replaceFuncs.length; i++) { s = s.replace(this.replaceFuncs[i][0], this.replaceFuncs[i][1]); } return s; }, parse: function (s) { s = this.stringReplaceFuncs(s); s = utils.multiReplace(s, this.replaceHash); try { var n = s.split(/([\s\-\.\,\/\x27]+)/); if (n.length === 3 && $P.Numeric.isNumeric(n[0]) && $P.Numeric.isNumeric(n[2]) && (n[2].length >= 4)) { // ok, so we're dealing with x/year. But that's not a full date. // This fixes wonky dateElementOrder parsing when set to dmy order. if (Date.CultureInfo.dateElementOrder[0] === "d") { s = "1/" + n[0] + "/" + n[2]; // set to 1st of month and normalize the seperator } } } catch (e) {} return s; } }; $P.Normalizer.buildReplaceData(); }()); (function () { var $P = Date.Parsing; var _ = $P.Operators = { // // Tokenizers // rtoken: function (r) { // regex token return function (s) { var mx = s.match(r); if (mx) { return ([ mx[0], s.substring(mx[0].length) ]); } else { throw new $P.Exception(s); } }; }, token: function () { // whitespace-eating token return function (s) { return _.rtoken(new RegExp("^\\s*" + s + "\\s*"))(s); }; }, stoken: function (s) { // string token return _.rtoken(new RegExp("^" + s)); }, // Atomic Operators until: function (p) { return function (s) { var qx = [], rx = null; while (s.length) { try { rx = p.call(this, s); } catch (e) { qx.push(rx[0]); s = rx[1]; continue; } break; } return [ qx, s ]; }; }, many: function (p) { return function (s) { var rx = [], r = null; while (s.length) { try { r = p.call(this, s); } catch (e) { return [ rx, s ]; } rx.push(r[0]); s = r[1]; } return [ rx, s ]; }; }, // generator operators -- see below optional: function (p) { return function (s) { var r = null; try { r = p.call(this, s); } catch (e) { return [ null, s ]; } return [ r[0], r[1] ]; }; }, not: function (p) { return function (s) { try { p.call(this, s); } catch (e) { return [null, s]; } throw new $P.Exception(s); }; }, ignore: function (p) { return p ? function (s) { var r = null; r = p.call(this, s); return [null, r[1]]; } : null; }, product: function () { var px = arguments[0], qx = Array.prototype.slice.call(arguments, 1), rx = []; for (var i = 0 ; i < px.length ; i++) { rx.push(_.each(px[i], qx)); } return rx; }, cache: function (rule) { var cache = {}, cache_length = 0, cache_keys = [], CACHE_MAX = Date.Config.CACHE_MAX || 100000, r = null; var cacheCheck = function () { if (cache_length === CACHE_MAX) { // kill several keys, don't want to have to do this all the time... for (var i=0; i < 10; i++) { var key = cache_keys.shift(); if (key) { delete cache[key]; cache_length--; } } } }; return function (s) { cacheCheck(); try { r = cache[s] = (cache[s] || rule.call(this, s)); } catch (e) { r = cache[s] = e; } cache_length++; cache_keys.push(s); if (r instanceof $P.Exception) { throw r; } else { return r; } }; }, // vector operators -- see below any: function () { var px = arguments; return function (s) { var r = null; for (var i = 0; i < px.length; i++) { if (px[i] == null) { continue; } try { r = (px[i].call(this, s)); } catch (e) { r = null; } if (r) { return r; } } throw new $P.Exception(s); }; }, each: function () { var px = arguments; return function (s) { var rx = [], r = null; for (var i = 0; i < px.length ; i++) { if (px[i] == null) { continue; } try { r = (px[i].call(this, s)); } catch (e) { throw new $P.Exception(s); } rx.push(r[0]); s = r[1]; } return [ rx, s]; }; }, all: function () { var px = arguments, _ = _; return _.each(_.optional(px)); }, // delimited operators sequence: function (px, d, c) { d = d || _.rtoken(/^\s*/); c = c || null; if (px.length === 1) { return px[0]; } return function (s) { var r = null, q = null; var rx = []; for (var i = 0; i < px.length ; i++) { try { r = px[i].call(this, s); } catch (e) { break; } rx.push(r[0]); try { q = d.call(this, r[1]); } catch (ex) { q = null; break; } s = q[1]; } if (!r) { throw new $P.Exception(s); } if (q) { throw new $P.Exception(q[1]); } if (c) { try { r = c.call(this, r[1]); } catch (ey) { throw new $P.Exception(r[1]); } } return [ rx, (r?r[1]:s) ]; }; }, // // Composite Operators // between: function (d1, p, d2) { d2 = d2 || d1; var _fn = _.each(_.ignore(d1), p, _.ignore(d2)); return function (s) { var rx = _fn.call(this, s); return [[rx[0][0], r[0][2]], rx[1]]; }; }, list: function (p, d, c) { d = d || _.rtoken(/^\s*/); c = c || null; return (p instanceof Array ? _.each(_.product(p.slice(0, -1), _.ignore(d)), p.slice(-1), _.ignore(c)) : _.each(_.many(_.each(p, _.ignore(d))), px, _.ignore(c))); }, set: function (px, d, c) { d = d || _.rtoken(/^\s*/); c = c || null; return function (s) { // r is the current match, best the current 'best' match // which means it parsed the most amount of input var r = null, p = null, q = null, rx = null, best = [[], s], last = false; // go through the rules in the given set for (var i = 0; i < px.length ; i++) { // last is a flag indicating whether this must be the last element // if there is only 1 element, then it MUST be the last one q = null; p = null; r = null; last = (px.length === 1); // first, we try simply to match the current pattern // if not, try the next pattern try { r = px[i].call(this, s); } catch (e) { continue; } // since we are matching against a set of elements, the first // thing to do is to add r[0] to matched elements rx = [[r[0]], r[1]]; // if we matched and there is still input to parse and // we don't already know this is the last element, // we're going to next check for the delimiter ... // if there's none, or if there's no input left to parse // than this must be the last element after all ... if (r[1].length > 0 && ! last) { try { q = d.call(this, r[1]); } catch (ex) { last = true; } } else { last = true; } // if we parsed the delimiter and now there's no more input, // that means we shouldn't have parsed the delimiter at all // so don't update r and mark this as the last element ... if (!last && q[1].length === 0) { last = true; } // so, if this isn't the last element, we're going to see if // we can get any more matches from the remaining (unmatched) // elements ... if (!last) { // build a list of the remaining rules we can match against, // i.e., all but the one we just matched against var qx = []; for (var j = 0; j < px.length ; j++) { if (i !== j) { qx.push(px[j]); } } // now invoke recursively set with the remaining input // note that we don't include the closing delimiter ... // we'll check for that ourselves at the end p = _.set(qx, d).call(this, q[1]); // if we got a non-empty set as a result ... // (otw rx already contains everything we want to match) if (p[0].length > 0) { // update current result, which is stored in rx ... // basically, pick up the remaining text from p[1] // and concat the result from p[0] so that we don't // get endless nesting ... rx[0] = rx[0].concat(p[0]); rx[1] = p[1]; } } // at this point, rx either contains the last matched element // or the entire matched set that starts with this element. // now we just check to see if this variation is better than // our best so far, in terms of how much of the input is parsed if (rx[1].length < best[1].length) { best = rx; } // if we've parsed all the input, then we're finished if (best[1].length === 0) { break; } } // so now we've either gone through all the patterns trying them // as the initial match; or we found one that parsed the entire // input string ... // if best has no matches, just return empty set ... if (best[0].length === 0) { return best; } // if a closing delimiter is provided, then we have to check it also if (c) { // we try this even if there is no remaining input because the pattern // may well be optional or match empty input ... try { q = c.call(this, best[1]); } catch (ey) { throw new $P.Exception(best[1]); } // it parsed ... be sure to update the best match remaining input best[1] = q[1]; } // if we're here, either there was no closing delimiter or we parsed it // so now we have the best match; just return it! return best; }; }, forward: function (gr, fname) { return function (s) { return gr[fname].call(this, s); }; }, // // Translation Operators // replace: function (rule, repl) { return function (s) { var r = rule.call(this, s); return [repl, r[1]]; }; }, process: function (rule, fn) { return function (s) { var r = rule.call(this, s); return [fn.call(this, r[0]), r[1]]; }; }, min: function (min, rule) { return function (s) { var rx = rule.call(this, s); if (rx[0].length < min) { throw new $P.Exception(s); } return rx; }; } }; // Generator Operators And Vector Operators // Generators are operators that have a signature of F(R) => R, // taking a given rule and returning another rule, such as // ignore, which parses a given rule and throws away the result. // Vector operators are those that have a signature of F(R1,R2,...) => R, // take a list of rules and returning a new rule, such as each. // Generator operators are converted (via the following _generator // function) into functions that can also take a list or array of rules // and return an array of new rules as though the function had been // called on each rule in turn (which is what actually happens). // This allows generators to be used with vector operators more easily. // Example: // each(ignore(foo, bar)) instead of each(ignore(foo), ignore(bar)) // This also turns generators into vector operators, which allows // constructs like: // not(cache(foo, bar)) var _generator = function (op) { function gen() { var args = null, rx = [], px, i; if (arguments.length > 1) { args = Array.prototype.slice.call(arguments); } else if (arguments[0] instanceof Array) { args = arguments[0]; } if (args) { px = args.shift(); if (px.length > 0) { args.unshift(px[i]); rx.push(op.apply(null, args)); args.shift(); return rx; } } else { return op.apply(null, arguments); } } return gen; }; var gx = "optional not ignore cache".split(/\s/); for (var i = 0 ; i < gx.length ; i++) { _[gx[i]] = _generator(_[gx[i]]); } var _vector = function (op) { return function () { if (arguments[0] instanceof Array) { return op.apply(null, arguments[0]); } else { return op.apply(null, arguments); } }; }; var vx = "each any all".split(/\s/); for (var j = 0 ; j < vx.length ; j++) { _[vx[j]] = _vector(_[vx[j]]); } }()); (function () { var $D = Date; var flattenAndCompact = function (ax) { var rx = []; for (var i = 0; i < ax.length; i++) { if (ax[i] instanceof Array) { rx = rx.concat(flattenAndCompact(ax[i])); } else { if (ax[i]) { rx.push(ax[i]); } } } return rx; }; var parseMeridian = function () { if (this.meridian && (this.hour || this.hour === 0)) { if (this.meridian === "a" && this.hour > 11 && Date.Config.strict24hr){ throw "Invalid hour and meridian combination"; } else if (this.meridian === "p" && this.hour < 12 && Date.Config.strict24hr){ throw "Invalid hour and meridian combination"; } else if (this.meridian === "p" && this.hour < 12) { this.hour = this.hour + 12; } else if (this.meridian === "a" && this.hour === 12) { this.hour = 0; } } }; var setDefaults = function () { var now = new Date(); if ((this.hour || this.minute) && (!this.month && !this.year && !this.day)) { this.day = now.getDate(); } if (!this.year) { this.year = now.getFullYear(); } if (!this.month && this.month !== 0) { this.month = now.getMonth(); } if (!this.day) { this.day = 1; } if (!this.hour) { this.hour = 0; } if (!this.minute) { this.minute = 0; } if (!this.second) { this.second = 0; } if (!this.millisecond) { this.millisecond = 0; } }; var finishUtils = { getToday: function () { if (this.now || "hour minute second".indexOf(this.unit) !== -1) { return new Date(); } else { return $D.today(); } }, setDaysFromWeekday: function (today, orient){ var gap; orient = orient || 1; this.unit = "day"; gap = ($D.getDayNumberFromName(this.weekday) - today.getDay()); this.days = gap ? ((gap + (orient * 7)) % 7) : (orient * 7); return this; }, setMonthsFromMonth: function (today, orient) { var gap; orient = orient || 1; this.unit = "month"; gap = (this.month - today.getMonth()); this.months = gap ? ((gap + (orient * 12)) % 12) : (orient * 12); this.month = null; return this; }, setDMYFromWeekday: function () { var d = Date[this.weekday](); this.day = d.getDate(); if (!this.month) { this.month = d.getMonth(); } this.year = d.getFullYear(); return this; }, setUnitValue: function (orient) { if (!this.value && this.operator && this.operator !== null && this[this.unit + "s"] && this[this.unit + "s"] !== null) { this[this.unit + "s"] = this[this.unit + "s"] + ((this.operator === "add") ? 1 : -1) + (this.value||0) * orient; } else if (this[this.unit + "s"] == null || this.operator != null) { if (!this.value) { this.value = 1; } this[this.unit + "s"] = this.value * orient; } }, generateDateFromWeeks: function () { var weekday = (this.weekday !== undefined) ? this.weekday : "today"; var d = Date[weekday]().addWeeks(this.weeks); if (this.now) { d.setTimeToNow(); } return d; } }; $D.Translator = { hour: function (s) { return function () { this.hour = Number(s); }; }, minute: function (s) { return function () { this.minute = Number(s); }; }, second: function (s) { return function () { this.second = Number(s); }; }, /* for ss.s format */ secondAndMillisecond: function (s) { return function () { var mx = s.match(/^([0-5][0-9])\.([0-9]{1,3})/); this.second = Number(mx[1]); this.millisecond = Number(mx[2]); }; }, meridian: function (s) { return function () { this.meridian = s.slice(0, 1).toLowerCase(); }; }, timezone: function (s) { return function () { var n = s.replace(/[^\d\+\-]/g, ""); if (n.length) { this.timezoneOffset = Number(n); } else { this.timezone = s.toLowerCase(); } }; }, day: function (x) { var s = x[0]; return function () { this.day = Number(s.match(/\d+/)[0]); if (this.day < 1) { throw "invalid day"; } }; }, month: function (s) { return function () { this.month = (s.length === 3) ? "jan feb mar apr may jun jul aug sep oct nov dec".indexOf(s)/4 : Number(s) - 1; if (this.month < 0) { throw "invalid month"; } }; }, year: function (s) { return function () { var n = Number(s); this.year = ((s.length > 2) ? n : (n + (((n + 2000) < Date.CultureInfo.twoDigitYearMax) ? 2000 : 1900))); }; }, rday: function (s) { return function () { switch (s) { case "yesterday": this.days = -1; break; case "tomorrow": this.days = 1; break; case "today": this.days = 0; break; case "now": this.days = 0; this.now = true; break; } }; }, finishExact: function (x) { var d; x = (x instanceof Array) ? x : [x]; for (var i = 0 ; i < x.length ; i++) { if (x[i]) { x[i].call(this); } } setDefaults.call(this); parseMeridian.call(this); if (this.day > $D.getDaysInMonth(this.year, this.month)) { throw new RangeError(this.day + " is not a valid value for days."); } d = new Date(this.year, this.month, this.day, this.hour, this.minute, this.second, this.millisecond); if (this.year < 100) { d.setFullYear(this.year); // means years less that 100 are process correctly. JS will parse it otherwise as 1900-1999. } if (this.timezone) { d.set({ timezone: this.timezone }); } else if (this.timezoneOffset) { d.set({ timezoneOffset: this.timezoneOffset }); } return d; }, finish: function (x) { var today, expression, orient, temp; x = (x instanceof Array) ? flattenAndCompact(x) : [ x ]; if (x.length === 0) { return null; } for (var i = 0 ; i < x.length ; i++) { if (typeof x[i] === "function") { x[i].call(this); } } if (this.now && !this.unit && !this.operator) { return new Date(); } else { today = finishUtils.getToday.call(this); } expression = !!(this.days && this.days !== null || this.orient || this.operator); orient = ((this.orient === "past" || this.operator === "subtract") ? -1 : 1); if (this.month && this.unit === "week") { this.value = this.month + 1; delete this.month; delete this.day; } if ((this.month || this.month === 0) && "year day hour minute second".indexOf(this.unit) !== -1) { if (!this.value) { this.value = this.month + 1; } this.month = null; expression = true; } if (!expression && this.weekday && !this.day && !this.days) { finishUtils.setDMYFromWeekday.call(this); } if (expression && this.weekday && this.unit !== "month" && this.unit !== "week") { finishUtils.setDaysFromWeekday.call(this, today, orient); } if (this.weekday && this.unit !== "week" && !this.day && !this.days) { temp = Date[this.weekday](); this.day = temp.getDate(); if (temp.getMonth() !== today.getMonth()) { this.month = temp.getMonth(); } } if (this.month && this.unit === "day" && this.operator) { if (!this.value) { this.value = (this.month + 1); } this.month = null; } if (this.value != null && this.month != null && this.year != null) { this.day = this.value * 1; } if (this.month && !this.day && this.value) { today.set({ day: this.value * 1 }); if (!expression) { this.day = this.value * 1; } } if (!this.month && this.value && this.unit === "month" && !this.now) { this.month = this.value; expression = true; } if (expression && (this.month || this.month === 0) && this.unit !== "year") { finishUtils.setMonthsFromMonth.call(this, today, orient); } if (!this.unit) { this.unit = "day"; } finishUtils.setUnitValue.call(this, orient); parseMeridian.call(this); if ((this.month || this.month === 0) && !this.day) { this.day = 1; } if (!this.orient && !this.operator && this.unit === "week" && this.value && !this.day && !this.month) { return Date.today().setWeek(this.value); } if (this.unit === "week" && this.weeks && !this.day && !this.month) { return finishUtils.generateDateFromWeeks.call(this); } if (expression && this.timezone && this.day && this.days) { this.day = this.days; } if (expression){ today.add(this); } else { today.set(this); } if (this.timezone) { this.timezone = this.timezone.toUpperCase(); var offset = $D.getTimezoneOffset(this.timezone); var timezone; if (today.hasDaylightSavingTime()) { // lets check that we're being sane with timezone setting timezone = $D.getTimezoneAbbreviation(offset, today.isDaylightSavingTime()); if (timezone !== this.timezone) { // bugger, we're in a place where things like EST vs EDT matters. if (today.isDaylightSavingTime()) { today.addHours(-1); } else { today.addHours(1); } } } today.setTimezoneOffset(offset); } return today; } }; }()); (function () { var $D = Date; $D.Grammar = {}; var _ = $D.Parsing.Operators, g = $D.Grammar, t = $D.Translator, _fn; // Allow rolling up into general purpose rules _fn = function () { return _.each(_.any.apply(null, arguments), _.not(g.ctoken2("timeContext"))); }; g.datePartDelimiter = _.rtoken(/^([\s\-\.\,\/\x27]+)/); g.timePartDelimiter = _.stoken(":"); g.whiteSpace = _.rtoken(/^\s*/); g.generalDelimiter = _.rtoken(/^(([\s\,]|at|@|on)+)/); var _C = {}; g.ctoken = function (keys) { var fn = _C[keys]; if (! fn) { var c = Date.CultureInfo.regexPatterns; var kx = keys.split(/\s+/), px = []; for (var i = 0; i < kx.length ; i++) { px.push(_.replace(_.rtoken(c[kx[i]]), kx[i])); } fn = _C[keys] = _.any.apply(null, px); } return fn; }; g.ctoken2 = function (key) { return _.rtoken(Date.CultureInfo.regexPatterns[key]); }; var cacheProcessRtoken = function (key, token, type, eachToken) { if (eachToken) { g[key] = _.cache(_.process(_.each(_.rtoken(token),_.optional(g.ctoken2(eachToken))), type)); } else { g[key] = _.cache(_.process(_.rtoken(token), type)); } }; var cacheProcessCtoken = function (token, type) { return _.cache(_.process(g.ctoken2(token), type)); }; var _F = {}; //function cache var _get = function (f) { _F[f] = (_F[f] || g.format(f)[0]); return _F[f]; }; g.allformats = function (fx) { var rx = []; if (fx instanceof Array) { for (var i = 0; i < fx.length; i++) { rx.push(_get(fx[i])); } } else { rx.push(_get(fx)); } return rx; }; g.formats = function (fx) { if (fx instanceof Array) { var rx = []; for (var i = 0 ; i < fx.length ; i++) { rx.push(_get(fx[i])); } return _.any.apply(null, rx); } else { return _get(fx); } }; var grammarFormats = { timeFormats: function(){ var i, RTokenKeys = [ "h", "hh", "H", "HH", "m", "mm", "s", "ss", "ss.s", "z", "zz" ], RToken = [ /^(0[0-9]|1[0-2]|[1-9])/, /^(0[0-9]|1[0-2])/, /^([0-1][0-9]|2[0-3]|[0-9])/, /^([0-1][0-9]|2[0-3])/, /^([0-5][0-9]|[0-9])/, /^[0-5][0-9]/, /^([0-5][0-9]|[0-9])/, /^[0-5][0-9]/, /^[0-5][0-9]\.[0-9]{1,3}/, /^((\+|\-)\s*\d\d\d\d)|((\+|\-)\d\d\:?\d\d)/, /^((\+|\-)\s*\d\d\d\d)|((\+|\-)\d\d\:?\d\d)/ ], tokens = [ t.hour, t.hour, t.hour, t.hour, t.minute, t.minute, t.second, t.second, t.secondAndMillisecond, t.timezone, t.timezone ]; for (i=0; i < RTokenKeys.length; i++) { cacheProcessRtoken(RTokenKeys[i], RToken[i], tokens[i]); } g.hms = _.cache(_.sequence([g.H, g.m, g.s], g.timePartDelimiter)); g.t = cacheProcessCtoken("shortMeridian", t.meridian); g.tt = cacheProcessCtoken("longMeridian", t.meridian); g.zzz = cacheProcessCtoken("timezone", t.timezone); g.timeSuffix = _.each(_.ignore(g.whiteSpace), _.set([ g.tt, g.zzz ])); g.time = _.each(_.optional(_.ignore(_.stoken("T"))), g.hms, g.timeSuffix); }, dateFormats: function () { // pre-loaded rules for different date part order preferences var _setfn = function () { return _.set(arguments, g.datePartDelimiter); }; var i, RTokenKeys = [ "d", "dd", "M", "MM", "y", "yy", "yyy", "yyyy" ], RToken = [ /^([0-2]\d|3[0-1]|\d)/, /^([0-2]\d|3[0-1])/, /^(1[0-2]|0\d|\d)/, /^(1[0-2]|0\d)/, /^(\d+)/, /^(\d\d)/, /^(\d\d?\d?\d?)/, /^(\d\d\d\d)/ ], tokens = [ t.day, t.day, t.month, t.month, t.year, t.year, t.year, t.year ], eachToken = [ "ordinalSuffix", "ordinalSuffix" ]; for (i=0; i < RTokenKeys.length; i++) { cacheProcessRtoken(RTokenKeys[i], RToken[i], tokens[i], eachToken[i]); } g.MMM = g.MMMM = _.cache(_.process(g.ctoken("jan feb mar apr may jun jul aug sep oct nov dec"), t.month)); g.ddd = g.dddd = _.cache(_.process(g.ctoken("sun mon tue wed thu fri sat"), function (s) { return function () { this.weekday = s; }; } )); g.day = _fn(g.d, g.dd); g.month = _fn(g.M, g.MMM); g.year = _fn(g.yyyy, g.yy); g.mdy = _setfn(g.ddd, g.month, g.day, g.year); g.ymd = _setfn(g.ddd, g.year, g.month, g.day); g.dmy = _setfn(g.ddd, g.day, g.month, g.year); g.date = function (s) { return ((g[Date.CultureInfo.dateElementOrder] || g.mdy).call(this, s)); }; }, relative: function () { // relative date / time expressions g.orientation = _.process(g.ctoken("past future"), function (s) { return function () { this.orient = s; }; } ); g.operator = _.process(g.ctoken("add subtract"), function (s) { return function () { this.operator = s; }; } ); g.rday = _.process(g.ctoken("yesterday tomorrow today now"), t.rday); g.unit = _.process(g.ctoken("second minute hour day week month year"), function (s) { return function () { this.unit = s; }; } ); } }; g.buildGrammarFormats = function () { // these need to be rebuilt every time the language changes. _C = {}; grammarFormats.timeFormats(); grammarFormats.dateFormats(); grammarFormats.relative(); g.value = _.process(_.rtoken(/^([-+]?\d+)?(st|nd|rd|th)?/), function (s) { return function () { this.value = s.replace(/\D/g, ""); }; } ); g.expression = _.set([g.rday, g.operator, g.value, g.unit, g.orientation, g.ddd, g.MMM ]); g.format = _.process(_.many( _.any( // translate format specifiers into grammar rules _.process( _.rtoken(/^(dd?d?d?(?!e)|MM?M?M?|yy?y?y?|hh?|HH?|mm?|ss?|tt?|zz?z?)/), function (fmt) { if (g[fmt]) { return g[fmt]; } else { throw $D.Parsing.Exception(fmt); } } ), // translate separator tokens into token rules _.process(_.rtoken(/^[^dMyhHmstz]+/), // all legal separators function (s) { return _.ignore(_.stoken(s)); } ) ) ), // construct the parser ... function (rules) { return _.process(_.each.apply(null, rules), t.finishExact); } ); // starting rule for general purpose grammar g._start = _.process(_.set([ g.date, g.time, g.expression ], g.generalDelimiter, g.whiteSpace), t.finish); }; g.buildGrammarFormats(); // parsing date format specifiers - ex: "h:m:s tt" // this little guy will generate a custom parser based // on the format string, ex: g.format("h:m:s tt") // check for these formats first g._formats = g.formats([ "\"yyyy-MM-ddTHH:mm:ssZ\"", "yyyy-MM-ddTHH:mm:ss.sz", "yyyy-MM-ddTHH:mm:ssZ", "yyyy-MM-ddTHH:mm:ssz", "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-ddTHH:mmZ", "yyyy-MM-ddTHH:mmz", "yyyy-MM-ddTHH:mm", "ddd, MMM dd, yyyy H:mm:ss tt", "ddd MMM d yyyy HH:mm:ss zzz", "MMddyyyy", "ddMMyyyy", "Mddyyyy", "ddMyyyy", "Mdyyyy", "dMyyyy", "yyyy", "Mdyy", "dMyy", "d" ]); // real starting rule: tries selected formats first, // then general purpose rule g.start = function (s) { try { var r = g._formats.call({}, s); if (r[1].length === 0) { return r; } } catch (e) {} return g._start.call({}, s); }; }()); (function () { var $D = Date; /** * @desc Converts the specified string value into its JavaScript Date equivalent using CultureInfo specific format information. * * Example

	///////////
	// Dates //
	///////////

	// 15-Oct-2004
	var d1 = Date.parse("10/15/2004");

	// 15-Oct-2004
	var d1 = Date.parse("15-Oct-2004");

	// 15-Oct-2004
	var d1 = Date.parse("2004.10.15");

	//Fri Oct 15, 2004
	var d1 = Date.parse("Fri Oct 15, 2004");

	///////////
	// Times //
	///////////

	// Today at 10 PM.
	var d1 = Date.parse("10 PM");

	// Today at 10:30 PM.
	var d1 = Date.parse("10:30 P.M.");

	// Today at 6 AM.
	var d1 = Date.parse("06am");

	/////////////////////
	// Dates and Times //
	/////////////////////

	// 8-July-2004 @ 10:30 PM
	var d1 = Date.parse("July 8th, 2004, 10:30 PM");

	// 1-July-2004 @ 10:30 PM
	var d1 = Date.parse("2004-07-01T22:30:00");

	////////////////////
	// Relative Dates //
	////////////////////

	// Returns today's date. The string "today" is culture specific.
	var d1 = Date.parse("today");

	// Returns yesterday's date. The string "yesterday" is culture specific.
	var d1 = Date.parse("yesterday");

	// Returns the date of the next thursday.
	var d1 = Date.parse("Next thursday");

	// Returns the date of the most previous monday.
	var d1 = Date.parse("last monday");

	// Returns today's day + one year.
	var d1 = Date.parse("next year");

	///////////////
	// Date Math //
	///////////////

	// Today + 2 days
	var d1 = Date.parse("t+2");

	// Today + 2 days
	var d1 = Date.parse("today + 2 days");

	// Today + 3 months
	var d1 = Date.parse("t+3m");

	// Today - 1 year
	var d1 = Date.parse("today - 1 year");

	// Today - 1 year
	var d1 = Date.parse("t-1y"); 


	/////////////////////////////
	// Partial Dates and Times //
	/////////////////////////////

	// July 15th of this year.
	var d1 = Date.parse("July 15");

	// 15th day of current day and year.
	var d1 = Date.parse("15");

	// July 1st of current year at 10pm.
	var d1 = Date.parse("7/1 10pm");
	
* * @param {String} The string value to convert into a Date object [Required] * @return {Date} A Date object or null if the string cannot be converted into a Date. */ var parseUtils = { removeOrds: function (s) { ords = s.match(/\b(\d+)(?:st|nd|rd|th)\b/); // find ordinal matches s = ((ords && ords.length === 2) ? s.replace(ords[0], ords[1]) : s); return s; }, grammarParser: function (s) { var r = null; try { r = $D.Grammar.start.call({}, s.replace(/^\s*(\S*(\s+\S+)*)\s*$/, "$1")); } catch (e) { return null; } return ((r[1].length === 0) ? r[0] : null); }, nativeFallback: function(s) { var t; try { // ok we haven't parsed it, last ditch attempt with the built-in parser. t = Date._parse(s); return (t || t === 0) ? new Date(t) : null; } catch (e) { return null; } } }; function parse (s) { var d; if (!s) { return null; } if (s instanceof Date) { return s.clone(); } if (s.length >= 4 && s.charAt(0) !== "0" && s.charAt(0) !== "+"&& s.charAt(0) !== "-") { // ie: 2004 will pass, 0800 won't. // Start with specific formats d = $D.Parsing.ISO.parse(s) || $D.Parsing.Numeric.parse(s); } if (d instanceof Date && !isNaN(d.getTime())) { return d; } else { // find ordinal dates (1st, 3rd, 8th, etc and remove them as they cause parsing issues) s = $D.Parsing.Normalizer.parse(parseUtils.removeOrds(s)); d = parseUtils.grammarParser(s); if (d !== null) { return d; } else { return parseUtils.nativeFallback(s); } } } if (!$D._parse) { $D._parse = $D.parse; } $D.parse = parse; Date.getParseFunction = function (fx) { var fns = Date.Grammar.allformats(fx); return function (s) { var r = null; for (var i = 0; i < fns.length; i++) { try { r = fns[i].call({}, s); } catch (e) { continue; } if (r[1].length === 0) { return r[0]; } } return null; }; }; /** * Converts the specified string value into its JavaScript Date equivalent using the specified format {String} or formats {Array} and the CultureInfo specific format information. * The format of the string value must match one of the supplied formats exactly. * * Example

	// 15-Oct-2004
	var d1 = Date.parseExact("10/15/2004", "M/d/yyyy");

	// 15-Oct-2004
	var d1 = Date.parse("15-Oct-2004", "M-ddd-yyyy");

	// 15-Oct-2004
	var d1 = Date.parse("2004.10.15", "yyyy.MM.dd");

	// Multiple formats
	var d1 = Date.parseExact("10/15/2004", ["M/d/yyyy", "MMMM d, yyyy"]);
	
* * @param {String} The string value to convert into a Date object [Required]. * @param {Object} The expected format {String} or an array of expected formats {Array} of the date string [Required]. * @return {Date} A Date object or null if the string cannot be converted into a Date. */ $D.parseExact = function (s, fx) { return $D.getParseFunction(fx)(s); }; }()); (function () { var $D = Date, $P = $D.prototype, // $C = $D.CultureInfo, // not used atm p = function (s, l) { if (!l) { l = 2; } return ("000" + s).slice(l * -1); }; /** * Converts a PHP format string to Java/.NET format string. * A PHP format string can be used with ._format or .format. * A Java/.NET format string can be used with .toString(). * The .parseExact function will only accept a Java/.NET format string * * Example * var f1 = "%m/%d/%y" * var f2 = Date.normalizeFormat(f1); // "MM/dd/yy" * * new Date().format(f1); // "04/13/08" * new Date()._format(f1); // "04/13/08" * new Date().toString(f2); // "04/13/08" * * var date = Date.parseExact("04/13/08", f2); // Sun Apr 13 2008 * * @param {String} A PHP format string consisting of one or more format spcifiers. * @return {String} The PHP format converted to a Java/.NET format string. */ var normalizerSubstitutions = { "d" : "dd", "%d": "dd", "D" : "ddd", "%a": "ddd", "j" : "dddd", "l" : "dddd", "%A": "dddd", "S" : "S", "F" : "MMMM", "%B": "MMMM", "m" : "MM", "%m": "MM", "M" : "MMM", "%b": "MMM", "%h": "MMM", "n" : "M", "Y" : "yyyy", "%Y": "yyyy", "y" : "yy", "%y": "yy", "g" : "h", "%I": "h", "G" : "H", "h" : "hh", "H" : "HH", "%H": "HH", "i" : "mm", "%M": "mm", "s" : "ss", "%S": "ss", "%r": "hh:mm tt", "%R": "H:mm", "%T": "H:mm:ss", "%X": "t", "%x": "d", "%e": "d", "%D": "MM/dd/yy", "%n": "\\n", "%t": "\\t", "e" : "z", "T" : "z", "%z": "z", "%Z": "z", "Z" : "ZZ", "N" : "u", "w" : "u", "%w": "u", "W" : "W", "%V": "W" }; var normalizer = { substitutes: function (m) { return normalizerSubstitutions[m]; }, interpreted: function (m, x) { var y; switch (m) { case "%u": return x.getDay() + 1; case "z": return x.getOrdinalNumber(); case "%j": return p(x.getOrdinalNumber(), 3); case "%U": var d1 = x.clone().set({month: 0, day: 1}).addDays(-1).moveToDayOfWeek(0), d2 = x.clone().addDays(1).moveToDayOfWeek(0, -1); return (d2 < d1) ? "00" : p((d2.getOrdinalNumber() - d1.getOrdinalNumber()) / 7 + 1); case "%W": return p(x.getWeek()); case "t": return $D.getDaysInMonth(x.getFullYear(), x.getMonth()); case "o": case "%G": return x.setWeek(x.getISOWeek()).toString("yyyy"); case "%g": return x._format("%G").slice(-2); case "a": case "%p": return t("tt").toLowerCase(); case "A": return t("tt").toUpperCase(); case "u": return p(x.getMilliseconds(), 3); case "I": return (x.isDaylightSavingTime()) ? 1 : 0; case "O": return x.getUTCOffset(); case "P": y = x.getUTCOffset(); return y.substring(0, y.length - 2) + ":" + y.substring(y.length - 2); case "B": var now = new Date(); return Math.floor(((now.getHours() * 3600) + (now.getMinutes() * 60) + now.getSeconds() + (now.getTimezoneOffset() + 60) * 60) / 86.4); case "c": return x.toISOString().replace(/\"/g, ""); case "U": return $D.strtotime("now"); case "%c": return t("d") + " " + t("t"); case "%C": return Math.floor(x.getFullYear() / 100 + 1); } }, shouldOverrideDefaults: function (m) { switch (m) { case "%e": return true; default: return false; } }, parse: function (m, context) { var formatString, c = context || new Date(); formatString = normalizer.substitutes(m); if (formatString) { return formatString; } formatString = normalizer.interpreted(m, c); if (formatString) { return formatString; } else { return m; } } }; $D.normalizeFormat = function (format, context) { return format.replace(/(%|\\)?.|%%/g, function(t){ return normalizer.parse(t, context); }); }; /** * Format a local Unix timestamp according to locale settings * * Example: * Date.strftime("%m/%d/%y", new Date()); // "04/13/08" * Date.strftime("c", "2008-04-13T17:52:03Z"); // "04/13/08" * * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @param {Number|String} The number representing the number of seconds that have elapsed since January 1, 1970 (local time). * @return {String} A string representation of the current Date object. */ $D.strftime = function (format, time) { var d = Date.parse(time); return d._format(format); }; /** * Parse any textual datetime description into a Unix timestamp. * A Unix timestamp is the number of seconds that have elapsed since January 1, 1970 (midnight UTC/GMT). * * Example: * Date.strtotime("04/13/08"); // 1208044800 * Date.strtotime("1970-01-01T00:00:00Z"); // 0 * * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @param {Object} A string or date object. * @return {String} A string representation of the current Date object. */ $D.strtotime = function (time) { var d = $D.parse(time); return Math.round($D.UTC(d.getUTCFullYear(), d.getUTCMonth(), d.getUTCDate(), d.getUTCHours(), d.getUTCMinutes(), d.getUTCSeconds(), d.getUTCMilliseconds()) / 1000); }; /** * Converts the value of the current Date object to its equivalent string representation using a PHP/Unix style of date format specifiers. * Format Specifiers * Format Description Example * ------ --------------------------------------------------------------------------- ----------------------- * %a abbreviated weekday name according to the current localed "Mon" through "Sun" * %A full weekday name according to the current localed "Sunday" through "Saturday" * %b abbreviated month name according to the current localed "Jan" through "Dec" * %B full month name according to the current locale "January" through "December" * %c preferred date and time representation for the current locale "4/13/2008 12:33 PM" * %C century number (the year divided by 100 and truncated to an integer) "00" to "99" * %d day of the month as a decimal number "01" to "31" * %D same as %m/%d/%y "04/13/08" * %e day of the month as a decimal number, a single digit is preceded by a space "1" to "31" * %g like %G, but without the century "08" * %G The 4-digit year corresponding to the ISO week number (see %V). "2008" * This has the same format and value as %Y, except that if the ISO week number * belongs to the previous or next year, that year is used instead. * %h same as %b "Jan" through "Dec" * %H hour as a decimal number using a 24-hour clock. "00" to "23" * %I hour as a decimal number using a 12-hour clock. "01" to "12" * %j day of the year as a decimal number. "001" to "366" * %m month as a decimal number. "01" to "12" * %M minute as a decimal number. "00" to "59" * %n newline character "\n" * %p either "am" or "pm" according to the given time value, or the "am" or "pm" * corresponding strings for the current locale. * %r time in a.m. and p.m. notation "8:44 PM" * %R time in 24 hour notation "20:44" * %S second as a decimal number "00" to "59" * %t tab character "\t" * %T current time, equal to %H:%M:%S "12:49:11" * %u weekday as a decimal number ["1", "7"], with "1" representing Monday "1" to "7" * %U week number of the current year as a decimal number, starting with the "0" to ("52" or "53") * first Sunday as the first day of the first week * %V The ISO 8601:1988 week number of the current year as a decimal number, "00" to ("52" or "53") * range 01 to 53, where week 1 is the first week that has at least 4 days * in the current year, and with Monday as the first day of the week. * (Use %G or %g for the year component that corresponds to the week number * for the specified timestamp.) * %W week number of the current year as a decimal number, starting with the "00" to ("52" or "53") * first Monday as the first day of the first week * %w day of the week as a decimal, Sunday being "0" "0" to "6" * %x preferred date representation for the current locale without the time "4/13/2008" * %X preferred time representation for the current locale without the date "12:53:05" * %y year as a decimal number without a century "00" "99" * %Y year as a decimal number including the century "2008" * %Z time zone or name or abbreviation "UTC", "EST", "PST" * %z same as %Z * %% a literal "%" characters "%" * d Day of the month, 2 digits with leading zeros "01" to "31" * D A textual representation of a day, three letters "Mon" through "Sun" * j Day of the month without leading zeros "1" to "31" * l A full textual representation of the day of the week (lowercase "L") "Sunday" through "Saturday" * N ISO-8601 numeric representation of the day of the week (added in PHP 5.1.0) "1" (for Monday) through "7" (for Sunday) * S English ordinal suffix for the day of the month, 2 characters "st", "nd", "rd" or "th". Works well with j * w Numeric representation of the day of the week "0" (for Sunday) through "6" (for Saturday) * z The day of the year (starting from "0") "0" through "365" * W ISO-8601 week number of year, weeks starting on Monday "00" to ("52" or "53") * F A full textual representation of a month, such as January or March "January" through "December" * m Numeric representation of a month, with leading zeros "01" through "12" * M A short textual representation of a month, three letters "Jan" through "Dec" * n Numeric representation of a month, without leading zeros "1" through "12" * t Number of days in the given month "28" through "31" * L Whether it's a leap year "1" if it is a leap year, "0" otherwise * o ISO-8601 year number. This has the same value as Y, except that if the "2008" * ISO week number (W) belongs to the previous or next year, that year * is used instead. * Y A full numeric representation of a year, 4 digits "2008" * y A two digit representation of a year "08" * a Lowercase Ante meridiem and Post meridiem "am" or "pm" * A Uppercase Ante meridiem and Post meridiem "AM" or "PM" * B Swatch Internet time "000" through "999" * g 12-hour format of an hour without leading zeros "1" through "12" * G 24-hour format of an hour without leading zeros "0" through "23" * h 12-hour format of an hour with leading zeros "01" through "12" * H 24-hour format of an hour with leading zeros "00" through "23" * i Minutes with leading zeros "00" to "59" * s Seconds, with leading zeros "00" through "59" * u Milliseconds "54321" * e Timezone identifier "UTC", "EST", "PST" * I Whether or not the date is in daylight saving time (uppercase i) "1" if Daylight Saving Time, "0" otherwise * O Difference to Greenwich time (GMT) in hours "+0200", "-0600" * P Difference to Greenwich time (GMT) with colon between hours and minutes "+02:00", "-06:00" * T Timezone abbreviation "UTC", "EST", "PST" * Z Timezone offset in seconds. The offset for timezones west of UTC is "-43200" through "50400" * always negative, and for those east of UTC is always positive. * c ISO 8601 date "2004-02-12T15:19:21+00:00" * r RFC 2822 formatted date "Thu, 21 Dec 2000 16:01:07 +0200" * U Seconds since the Unix Epoch (January 1 1970 00:00:00 GMT) "0" * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @return {String} A string representation of the current Date object. */ var formatReplace = function (context) { return function (m) { var formatString, override = false; if (m.charAt(0) === "\\" || m.substring(0, 2) === "%%") { return m.replace("\\", "").replace("%%", "%"); } override = normalizer.shouldOverrideDefaults(m); formatString = $D.normalizeFormat(m, context); if (formatString) { return context.toString(formatString, override); } }; }; $P._format = function (format) { var formatter = formatReplace(this); if (!format) { return this._toString(); } else { return format.replace(/(%|\\)?.|%%/g, formatter); } }; if (!$P.format) { $P.format = $P._format; } }()); (function () { "use strict"; var gFn = function (attr) { return function () { return this[attr]; }; }; var sFn = function (attr) { return function (val) { this[attr] = val; return this; }; }; var attrs = ["years", "months", "days", "hours", "minutes", "seconds", "milliseconds"]; var addSetFuncs = function (context, attrs) { for (var i = 0; i < attrs.length ; i++) { var $a = attrs[i], $b = $a.slice(0, 1).toUpperCase() + $a.slice(1); context.prototype[$a] = 0; context.prototype["get" + $b] = gFn($a); context.prototype["set" + $b] = sFn($a); } }; /** * new TimeSpan(milliseconds); * new TimeSpan(days, hours, minutes, seconds); * new TimeSpan(days, hours, minutes, seconds, milliseconds); */ var TimeSpan = function (days, hours, minutes, seconds, milliseconds) { if (arguments.length === 1 && typeof days === "number") { var orient = (days < 0) ? -1 : +1; var millsLeft = Math.abs(days); this.setDays(Math.floor(millsLeft / 86400000) * orient); millsLeft = millsLeft % 86400000; this.setHours(Math.floor(millsLeft / 3600000) * orient); millsLeft = millsLeft % 3600000; this.setMinutes(Math.floor(millsLeft / 60000) * orient); millsLeft = millsLeft % 60000; this.setSeconds(Math.floor(millsLeft / 1000) * orient); millsLeft = millsLeft % 1000; this.setMilliseconds(millsLeft * orient); } else { this.set(days, hours, minutes, seconds, milliseconds); } this.getTotalMilliseconds = function () { return (this.getDays() * 86400000) + (this.getHours() * 3600000) + (this.getMinutes() * 60000) + (this.getSeconds() * 1000); }; this.compareTo = function (time) { var t1 = new Date(1970, 1, 1, this.getHours(), this.getMinutes(), this.getSeconds()), t2; if (time === null) { t2 = new Date(1970, 1, 1, 0, 0, 0); } else { t2 = new Date(1970, 1, 1, time.getHours(), time.getMinutes(), time.getSeconds()); } return (t1 < t2) ? -1 : (t1 > t2) ? 1 : 0; }; this.equals = function (time) { return (this.compareTo(time) === 0); }; this.add = function (time) { return (time === null) ? this : this.addSeconds(time.getTotalMilliseconds() / 1000); }; this.subtract = function (time) { return (time === null) ? this : this.addSeconds(-time.getTotalMilliseconds() / 1000); }; this.addDays = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 86400000)); }; this.addHours = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 3600000)); }; this.addMinutes = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 60000)); }; this.addSeconds = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 1000)); }; this.addMilliseconds = function (n) { return new TimeSpan(this.getTotalMilliseconds() + n); }; this.get12HourHour = function () { return (this.getHours() > 12) ? this.getHours() - 12 : (this.getHours() === 0) ? 12 : this.getHours(); }; this.getDesignator = function () { return (this.getHours() < 12) ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator; }; this.toString = function (format) { this._toString = function () { if (this.getDays() !== null && this.getDays() > 0) { return this.getDays() + "." + this.getHours() + ":" + this.p(this.getMinutes()) + ":" + this.p(this.getSeconds()); } else { return this.getHours() + ":" + this.p(this.getMinutes()) + ":" + this.p(this.getSeconds()); } }; this.p = function (s) { return (s.toString().length < 2) ? "0" + s : s; }; var me = this; return format ? format.replace(/dd?|HH?|hh?|mm?|ss?|tt?/g, function (format) { switch (format) { case "d": return me.getDays(); case "dd": return me.p(me.getDays()); case "H": return me.getHours(); case "HH": return me.p(me.getHours()); case "h": return me.get12HourHour(); case "hh": return me.p(me.get12HourHour()); case "m": return me.getMinutes(); case "mm": return me.p(me.getMinutes()); case "s": return me.getSeconds(); case "ss": return me.p(me.getSeconds()); case "t": return ((me.getHours() < 12) ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator).substring(0, 1); case "tt": return (me.getHours() < 12) ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator; } } ) : this._toString(); }; return this; }; addSetFuncs(TimeSpan, attrs.slice(2)); TimeSpan.prototype.set = function (days, hours, minutes, seconds, milliseconds){ this.setDays(days || this.getDays()); this.setHours(hours || this.getHours()); this.setMinutes(minutes || this.getMinutes()); this.setSeconds(seconds || this.getSeconds()); this.setMilliseconds(milliseconds || this.getMilliseconds()); }; /** * Gets the time of day for this date instances. * @return {TimeSpan} TimeSpan */ Date.prototype.getTimeOfDay = function () { return new TimeSpan(0, this.getHours(), this.getMinutes(), this.getSeconds(), this.getMilliseconds()); }; Date.TimeSpan = TimeSpan; if (typeof window !== "undefined" ) { // keeping API compatible for v1.x window.TimeSpan = TimeSpan; } }()); (function () { "use strict"; var attrs = ["years", "months", "days", "hours", "minutes", "seconds", "milliseconds"]; var gFn = function (attr) { return function () { return this[attr]; }; }; var sFn = function (attr) { return function (val) { this[attr] = val; return this; }; }; var addSetFuncs = function (context, attrs) { for (var i = 0; i < attrs.length ; i++) { var $a = attrs[i], $b = $a.slice(0, 1).toUpperCase() + $a.slice(1); context.prototype[$a] = 0; context.prototype["get" + $b] = gFn($a); context.prototype["set" + $b] = sFn($a); } }; var setMonthsAndYears = function (orient, d1, d2, context) { function inc() { d1.addMonths(-orient); context.months++; if (context.months === 12) { context.years++; context.months = 0; } } if (orient === +1) { while (d1 > d2) { inc(); } } else { while (d1 < d2) { inc(); } } context.months--; context.months *= orient; context.years *= orient; }; var adjustForDST = function(orient, startDate, endDate) { var hasDSTMismatch = (false === (startDate.isDaylightSavingTime() === endDate.isDaylightSavingTime())); if (hasDSTMismatch && orient === 1) { startDate.addHours(-1); } else if (hasDSTMismatch) { startDate.addHours(1); } }; /** * TimePeriod(startDate, endDate); * TimePeriod(years, months, days, hours, minutes, seconds, milliseconds); */ var TimePeriod = function (years, months, days, hours, minutes, seconds, milliseconds) { if (arguments.length === 7) { this.set(years, months, days, hours, minutes, seconds, milliseconds); } else if (arguments.length === 2 && arguments[0] instanceof Date && arguments[1] instanceof Date) { var startDate = arguments[0].clone(); var endDate = arguments[1].clone(); var orient = (startDate > endDate) ? +1 : -1; this.dates = { start: arguments[0].clone(), end: arguments[1].clone() }; setMonthsAndYears(orient, startDate, endDate, this); adjustForDST(orient, startDate, endDate); // // TODO - adjust for DST var diff = endDate - startDate; if (diff !== 0) { var ts = new TimeSpan(diff); this.set(this.years, this.months, ts.getDays(), ts.getHours(), ts.getMinutes(), ts.getSeconds(), ts.getMilliseconds()); } } return this; }; // create all the set functions. addSetFuncs(TimePeriod, attrs); TimePeriod.prototype.set = function (years, months, days, hours, minutes, seconds, milliseconds){ this.setYears(years || this.getYears()); this.setMonths(months || this.getMonths()); this.setDays(days || this.getDays()); this.setHours(hours || this.getHours()); this.setMinutes(minutes || this.getMinutes()); this.setSeconds(seconds || this.getSeconds()); this.setMilliseconds(milliseconds || this.getMilliseconds()); }; Date.TimePeriod = TimePeriod; if (typeof window !== "undefined") { // keeping API compatible for v1.x window.TimePeriod = TimePeriod; } }()); ================================================ FILE: build/date-en-IE.js ================================================ /** * @overview datejs * @version 1.0.0-rc3 * @author Gregory Wild-Smith * @copyright 2015 Gregory Wild-Smith * @license MIT * @homepage https://github.com/abritinthebay/datejs */ /* * DateJS Culture String File * Country Code: en-IE * Name: English (Ireland) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["en-IE"] = { "name": "en-IE", "englishName": "English (Ireland)", "nativeName": "English (Eire)", "Sunday": "Sunday", "Monday": "Monday", "Tuesday": "Tuesday", "Wednesday": "Wednesday", "Thursday": "Thursday", "Friday": "Friday", "Saturday": "Saturday", "Sun": "Sun", "Mon": "Mon", "Tue": "Tue", "Wed": "Wed", "Thu": "Thu", "Fri": "Fri", "Sat": "Sat", "Su": "Su", "Mo": "Mo", "Tu": "Tu", "We": "We", "Th": "Th", "Fr": "Fr", "Sa": "Sa", "S_Sun_Initial": "S", "M_Mon_Initial": "M", "T_Tue_Initial": "T", "W_Wed_Initial": "W", "T_Thu_Initial": "T", "F_Fri_Initial": "F", "S_Sat_Initial": "S", "January": "January", "February": "February", "March": "March", "April": "April", "May": "May", "June": "June", "July": "July", "August": "August", "September": "September", "October": "October", "November": "November", "December": "December", "Jan_Abbr": "Jan", "Feb_Abbr": "Feb", "Mar_Abbr": "Mar", "Apr_Abbr": "Apr", "May_Abbr": "May", "Jun_Abbr": "Jun", "Jul_Abbr": "Jul", "Aug_Abbr": "Aug", "Sep_Abbr": "Sep", "Oct_Abbr": "Oct", "Nov_Abbr": "Nov", "Dec_Abbr": "Dec", "AM": "", "PM": "", "firstDayOfWeek": 1, "twoDigitYearMax": 2029, "mdy": "dmy", "M/d/yyyy": "dd/MM/yyyy", "dddd, MMMM dd, yyyy": "dd MMMM yyyy", "h:mm tt": "HH:mm", "h:mm:ss tt": "HH:mm:ss", "dddd, MMMM dd, yyyy h:mm:ss tt": "dd MMMM yyyy HH:mm:ss", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "dd MMMM", "MMMM, yyyy": "MMMM yyyy", "/jan(uary)?/": "jan(uary)?", "/feb(ruary)?/": "feb(ruary)?", "/mar(ch)?/": "mar(ch)?", "/apr(il)?/": "apr(il)?", "/may/": "may", "/jun(e)?/": "jun(e)?", "/jul(y)?/": "jul(y)?", "/aug(ust)?/": "aug(ust)?", "/sep(t(ember)?)?/": "sep(t(ember)?)?", "/oct(ober)?/": "oct(ober)?", "/nov(ember)?/": "nov(ember)?", "/dec(ember)?/": "dec(ember)?", "/^su(n(day)?)?/": "^su(n(day)?)?", "/^mo(n(day)?)?/": "^mo(n(day)?)?", "/^tu(e(s(day)?)?)?/": "^tu(e(s(day)?)?)?", "/^we(d(nesday)?)?/": "^we(d(nesday)?)?", "/^th(u(r(s(day)?)?)?)?/": "^th(u(r(s(day)?)?)?)?", "/^fr(i(day)?)?/": "^fr(i(day)?)?", "/^sa(t(urday)?)?/": "^sa(t(urday)?)?", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "en-IE"; /** * @overview datejs * @version 1.0.0-rc3 * @author Gregory Wild-Smith * @copyright 2015 Gregory Wild-Smith * @license MIT * @homepage https://github.com/abritinthebay/datejs */(function () { var $D = Date; var lang = Date.CultureStrings ? Date.CultureStrings.lang : null; var loggedKeys = {}; // for debug purposes. var getText = { getFromKey: function (key, countryCode) { var output; if (Date.CultureStrings && Date.CultureStrings[countryCode] && Date.CultureStrings[countryCode][key]) { output = Date.CultureStrings[countryCode][key]; } else { output = getText.buildFromDefault(key); } if (key.charAt(0) === "/") { // Assume it's a regex output = getText.buildFromRegex(key, countryCode); } return output; }, getFromObjectValues: function (obj, countryCode) { var key, output = {}; for(key in obj) { if (obj.hasOwnProperty(key)) { output[key] = getText.getFromKey(obj[key], countryCode); } } return output; }, getFromObjectKeys: function (obj, countryCode) { var key, output = {}; for(key in obj) { if (obj.hasOwnProperty(key)) { output[getText.getFromKey(key, countryCode)] = obj[key]; } } return output; }, getFromArray: function (arr, countryCode) { var output = []; for (var i=0; i < arr.length; i++){ if (i in arr) { output[i] = getText.getFromKey(arr[i], countryCode); } } return output; }, buildFromDefault: function (key) { var output, length, split, last; switch(key) { case "name": output = "en-US"; break; case "englishName": output = "English (United States)"; break; case "nativeName": output = "English (United States)"; break; case "twoDigitYearMax": output = 2049; break; case "firstDayOfWeek": output = 0; break; default: output = key; split = key.split("_"); length = split.length; if (length > 1 && key.charAt(0) !== "/") { // if the key isn't a regex and it has a split. last = split[(length - 1)].toLowerCase(); if (last === "initial" || last === "abbr") { output = split[0]; } } break; } return output; }, buildFromRegex: function (key, countryCode) { var output; if (Date.CultureStrings && Date.CultureStrings[countryCode] && Date.CultureStrings[countryCode][key]) { output = new RegExp(Date.CultureStrings[countryCode][key], "i"); } else { output = new RegExp(key.replace(new RegExp("/", "g"),""), "i"); } return output; } }; var shallowMerge = function (obj1, obj2) { for (var attrname in obj2) { if (obj2.hasOwnProperty(attrname)) { obj1[attrname] = obj2[attrname]; } } }; var __ = function (key, language) { var countryCode = (language) ? language : lang; loggedKeys[key] = key; if (typeof key === "object") { if (key instanceof Array) { return getText.getFromArray(key, countryCode); } else { return getText.getFromObjectKeys(key, countryCode); } } else { return getText.getFromKey(key, countryCode); } }; var loadI18nScript = function (code) { // paatterned after jQuery's getScript. var url = Date.Config.i18n + code + ".js"; var head = document.getElementsByTagName("head")[0] || document.documentElement; var script = document.createElement("script"); script.src = url; var completed = false; var events = { done: function (){} // placeholder function }; // Attach handlers for all browsers script.onload = script.onreadystatechange = function() { if ( !completed && (!this.readyState || this.readyState === "loaded" || this.readyState === "complete") ) { events.done(); head.removeChild(script); } }; setTimeout(function() { head.insertBefore(script, head.firstChild); }, 0); // allows return to execute first return { done: function (cb) { events.done = function() { if (cb) { setTimeout(cb,0); } }; } }; }; var buildInfo = { buildFromMethodHash: function (obj) { var key; for(key in obj) { if (obj.hasOwnProperty(key)) { obj[key] = buildInfo[obj[key]](); } } return obj; }, timeZoneDST: function () { var DST = { "CHADT": "+1345", "NZDT": "+1300", "AEDT": "+1100", "ACDT": "+1030", "AZST": "+0500", "IRDT": "+0430", "EEST": "+0300", "CEST": "+0200", "BST": "+0100", "PMDT": "-0200", "ADT": "-0300", "NDT": "-0230", "EDT": "-0400", "CDT": "-0500", "MDT": "-0600", "PDT": "-0700", "AKDT": "-0800", "HADT": "-0900" }; return __(DST); }, timeZoneStandard: function () { var standard = { "LINT": "+1400", "TOT": "+1300", "CHAST": "+1245", "NZST": "+1200", "NFT": "+1130", "SBT": "+1100", "AEST": "+1000", "ACST": "+0930", "JST": "+0900", "CWST": "+0845", "CT": "+0800", "ICT": "+0700", "MMT": "+0630", "BST": "+0600", "NPT": "+0545", "IST": "+0530", "PKT": "+0500", "AFT": "+0430", "MSK": "+0400", "IRST": "+0330", "FET": "+0300", "EET": "+0200", "CET": "+0100", "GMT": "+0000", "UTC": "+0000", "CVT": "-0100", "GST": "-0200", "BRT": "-0300", "NST": "-0330", "AST": "-0400", "EST": "-0500", "CST": "-0600", "MST": "-0700", "PST": "-0800", "AKST": "-0900", "MIT": "-0930", "HST": "-1000", "SST": "-1100", "BIT": "-1200" }; return __(standard); }, timeZones: function (data) { var zone; data.timezones = []; for (zone in data.abbreviatedTimeZoneStandard) { if (data.abbreviatedTimeZoneStandard.hasOwnProperty(zone)) { data.timezones.push({ name: zone, offset: data.abbreviatedTimeZoneStandard[zone]}); } } for (zone in data.abbreviatedTimeZoneDST) { if (data.abbreviatedTimeZoneDST.hasOwnProperty(zone)) { data.timezones.push({ name: zone, offset: data.abbreviatedTimeZoneDST[zone], dst: true}); } } return data.timezones; }, days: function () { return __(["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"]); }, dayAbbr: function () { return __(["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"]); }, dayShortNames: function () { return __(["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"]); }, dayFirstLetters: function () { return __(["S_Sun_Initial", "M_Mon_Initial", "T_Tues_Initial", "W_Wed_Initial", "T_Thu_Initial", "F_Fri_Initial", "S_Sat_Initial"]); }, months: function () { return __(["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"]); }, monthAbbr: function () { return __(["Jan_Abbr", "Feb_Abbr", "Mar_Abbr", "Apr_Abbr", "May_Abbr", "Jun_Abbr", "Jul_Abbr", "Aug_Abbr", "Sep_Abbr", "Oct_Abbr", "Nov_Abbr", "Dec_Abbr"]); }, formatPatterns: function () { return getText.getFromObjectValues({ shortDate: "M/d/yyyy", longDate: "dddd, MMMM dd, yyyy", shortTime: "h:mm tt", longTime: "h:mm:ss tt", fullDateTime: "dddd, MMMM dd, yyyy h:mm:ss tt", sortableDateTime: "yyyy-MM-ddTHH:mm:ss", universalSortableDateTime: "yyyy-MM-dd HH:mm:ssZ", rfc1123: "ddd, dd MMM yyyy HH:mm:ss", monthDay: "MMMM dd", yearMonth: "MMMM, yyyy" }, Date.i18n.currentLanguage()); }, regex: function () { return getText.getFromObjectValues({ inTheMorning: "/( in the )(morn(ing)?)\\b/", thisMorning: "/(this )(morn(ing)?)\\b/", amThisMorning: "/(\b\\d(am)? )(this )(morn(ing)?)/", inTheEvening: "/( in the )(even(ing)?)\\b/", thisEvening: "/(this )(even(ing)?)\\b/", pmThisEvening: "/(\b\\d(pm)? )(this )(even(ing)?)/", jan: "/jan(uary)?/", feb: "/feb(ruary)?/", mar: "/mar(ch)?/", apr: "/apr(il)?/", may: "/may/", jun: "/jun(e)?/", jul: "/jul(y)?/", aug: "/aug(ust)?/", sep: "/sep(t(ember)?)?/", oct: "/oct(ober)?/", nov: "/nov(ember)?/", dec: "/dec(ember)?/", sun: "/^su(n(day)?)?/", mon: "/^mo(n(day)?)?/", tue: "/^tu(e(s(day)?)?)?/", wed: "/^we(d(nesday)?)?/", thu: "/^th(u(r(s(day)?)?)?)?/", fri: "/fr(i(day)?)?/", sat: "/^sa(t(urday)?)?/", future: "/^next/", past: "/^last|past|prev(ious)?/", add: "/^(\\+|aft(er)?|from|hence)/", subtract: "/^(\\-|bef(ore)?|ago)/", yesterday: "/^yes(terday)?/", today: "/^t(od(ay)?)?/", tomorrow: "/^tom(orrow)?/", now: "/^n(ow)?/", millisecond: "/^ms|milli(second)?s?/", second: "/^sec(ond)?s?/", minute: "/^mn|min(ute)?s?/", hour: "/^h(our)?s?/", week: "/^w(eek)?s?/", month: "/^m(onth)?s?/", day: "/^d(ay)?s?/", year: "/^y(ear)?s?/", shortMeridian: "/^(a|p)/", longMeridian: "/^(a\\.?m?\\.?|p\\.?m?\\.?)/", timezone: "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/", ordinalSuffix: "/^\\s*(st|nd|rd|th)/", timeContext: "/^\\s*(\\:|a(?!u|p)|p)/" }, Date.i18n.currentLanguage()); } }; var CultureInfo = function () { var info = getText.getFromObjectValues({ name: "name", englishName: "englishName", nativeName: "nativeName", amDesignator: "AM", pmDesignator: "PM", firstDayOfWeek: "firstDayOfWeek", twoDigitYearMax: "twoDigitYearMax", dateElementOrder: "mdy" }, Date.i18n.currentLanguage()); var constructedInfo = buildInfo.buildFromMethodHash({ dayNames: "days", abbreviatedDayNames: "dayAbbr", shortestDayNames: "dayShortNames", firstLetterDayNames: "dayFirstLetters", monthNames: "months", abbreviatedMonthNames: "monthAbbr", formatPatterns: "formatPatterns", regexPatterns: "regex", abbreviatedTimeZoneDST: "timeZoneDST", abbreviatedTimeZoneStandard: "timeZoneStandard" }); shallowMerge(info, constructedInfo); buildInfo.timeZones(info); return info; }; $D.i18n = { __: function (key, lang) { return __(key, lang); }, currentLanguage: function () { return lang || "en-US"; }, setLanguage: function (code, force, cb) { var async = false; if (force || code === "en-US" || (!!Date.CultureStrings && !!Date.CultureStrings[code])) { lang = code; Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings.lang = code; Date.CultureInfo = new CultureInfo(); } else { if (!(!!Date.CultureStrings && !!Date.CultureStrings[code])) { if (typeof exports !== "undefined" && this.exports !== exports) { // we're in a Node enviroment, load it using require try { require("../i18n/" + code + ".js"); lang = code; Date.CultureStrings.lang = code; Date.CultureInfo = new CultureInfo(); } catch (e) { // var str = "The language for '" + code + "' could not be loaded by Node. It likely does not exist."; throw new Error("The DateJS IETF language tag '" + code + "' could not be loaded by Node. It likely does not exist."); } } else if (Date.Config && Date.Config.i18n) { // we know the location of the files, so lets load them async = true; loadI18nScript(code).done(function(){ lang = code; Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings.lang = code; Date.CultureInfo = new CultureInfo(); $D.Parsing.Normalizer.buildReplaceData(); // because this is async if ($D.Grammar) { $D.Grammar.buildGrammarFormats(); // so we can parse those strings... } if (cb) { setTimeout(cb,0); } }); } else { Date.console.error("The DateJS IETF language tag '" + code + "' is not available and has not been loaded."); return false; } } } $D.Parsing.Normalizer.buildReplaceData(); // rebuild normalizer strings if ($D.Grammar) { $D.Grammar.buildGrammarFormats(); // so we can parse those strings... } if (!async && cb) { setTimeout(cb,0); } }, getLoggedKeys: function () { return loggedKeys; }, updateCultureInfo: function () { Date.CultureInfo = new CultureInfo(); } }; $D.i18n.updateCultureInfo(); // run automatically }()); (function () { var $D = Date, $P = $D.prototype, p = function (s, l) { if (!l) { l = 2; } return ("000" + s).slice(l * -1); }; if (typeof window !== "undefined" && typeof window.console !== "undefined" && typeof window.console.log !== "undefined") { $D.console = console; // used only to raise non-critical errors if available } else { // set mock so we don't give errors. $D.console = { log: function(){}, error: function(){} }; } $D.Config = $D.Config || {}; $D.initOverloads = function() { /** * Overload of Date.now. Allows an alternate call for Date.now where it returns the * current Date as an object rather than just milliseconds since the Unix Epoch. * * Also provides an implementation of now() for browsers (IE<9) that don't have it. * * Backwards compatible so with work with either: * Date.now() [returns ms] * or * Date.now(true) [returns Date] */ if (!$D.now) { $D._now = function now() { return new Date().getTime(); }; } else if (!$D._now) { $D._now = $D.now; } $D.now = function (returnObj) { if (returnObj) { return $D.present(); } else { return $D._now(); } }; if ( !$P.toISOString ) { $P.toISOString = function() { return this.getUTCFullYear() + "-" + p(this.getUTCMonth() + 1) + "-" + p(this.getUTCDate()) + "T" + p(this.getUTCHours()) + ":" + p(this.getUTCMinutes()) + ":" + p(this.getUTCSeconds()) + "." + String( (this.getUTCMilliseconds()/1000).toFixed(3)).slice(2, 5) + "Z"; }; } // private if ( $P._toString === undefined ){ $P._toString = $P.toString; } }; $D.initOverloads(); /** * Gets a date that is set to the current date. The time is set to the start of the day (00:00 or 12:00 AM). * @return {Date} The current date. */ $D.today = function () { return new Date().clearTime(); }; /** * Gets a date that is set to the current date and time (same as new Date, but chainable) * @return {Date} The current date. */ $D.present = function () { return new Date(); }; /** * Compares the first date to the second date and returns an number indication of their relative values. * @param {Date} First Date object to compare [Required]. * @param {Date} Second Date object to compare to [Required]. * @return {Number} -1 = date1 is lessthan date2. 0 = values are equal. 1 = date1 is greaterthan date2. */ $D.compare = function (date1, date2) { if (isNaN(date1) || isNaN(date2)) { throw new Error(date1 + " - " + date2); } else if (date1 instanceof Date && date2 instanceof Date) { return (date1 < date2) ? -1 : (date1 > date2) ? 1 : 0; } else { throw new TypeError(date1 + " - " + date2); } }; /** * Compares the first Date object to the second Date object and returns true if they are equal. * @param {Date} First Date object to compare [Required] * @param {Date} Second Date object to compare to [Required] * @return {Boolean} true if dates are equal. false if they are not equal. */ $D.equals = function (date1, date2) { return (date1.compareTo(date2) === 0); }; /** * Gets the language appropriate day name when given the day number(0-6) * eg - 0 == Sunday * @return {String} The day name */ $D.getDayName = function (n) { return Date.CultureInfo.dayNames[n]; }; /** * Gets the day number (0-6) if given a CultureInfo specific string which is a valid dayName, abbreviatedDayName or shortestDayName (two char). * @param {String} The name of the day (eg. "Monday, "Mon", "tuesday", "tue", "We", "we"). * @return {Number} The day number */ $D.getDayNumberFromName = function (name) { var n = Date.CultureInfo.dayNames, m = Date.CultureInfo.abbreviatedDayNames, o = Date.CultureInfo.shortestDayNames, s = name.toLowerCase(); for (var i = 0; i < n.length; i++) { if (n[i].toLowerCase() === s || m[i].toLowerCase() === s || o[i].toLowerCase() === s) { return i; } } return -1; }; /** * Gets the month number (0-11) if given a Culture Info specific string which is a valid monthName or abbreviatedMonthName. * @param {String} The name of the month (eg. "February, "Feb", "october", "oct"). * @return {Number} The day number */ $D.getMonthNumberFromName = function (name) { var n = Date.CultureInfo.monthNames, m = Date.CultureInfo.abbreviatedMonthNames, s = name.toLowerCase(); for (var i = 0; i < n.length; i++) { if (n[i].toLowerCase() === s || m[i].toLowerCase() === s) { return i; } } return -1; }; /** * Gets the language appropriate month name when given the month number(0-11) * eg - 0 == January * @return {String} The month name */ $D.getMonthName = function (n) { return Date.CultureInfo.monthNames[n]; }; /** * Determines if the current date instance is within a LeapYear. * @param {Number} The year. * @return {Boolean} true if date is within a LeapYear, otherwise false. */ $D.isLeapYear = function (year) { return ((year % 4 === 0 && year % 100 !== 0) || year % 400 === 0); }; /** * Gets the number of days in the month, given a year and month value. Automatically corrects for LeapYear. * @param {Number} The year. * @param {Number} The month (0-11). * @return {Number} The number of days in the month. */ $D.getDaysInMonth = function (year, month) { if (!month && $D.validateMonth(year)) { month = year; year = Date.today().getFullYear(); } return [31, ($D.isLeapYear(year) ? 29 : 28), 31, 30, 31, 30, 31, 31, 30, 31, 30, 31][month]; }; $P.getDaysInMonth = function () { return $D.getDaysInMonth(this.getFullYear(), this.getMonth()); }; $D.getTimezoneAbbreviation = function (offset, dst) { var p, n = (dst || false) ? Date.CultureInfo.abbreviatedTimeZoneDST : Date.CultureInfo.abbreviatedTimeZoneStandard; for (p in n) { if (n.hasOwnProperty(p)) { if (n[p] === offset) { return p; } } } return null; }; $D.getTimezoneOffset = function (name, dst) { var i, a =[], z = Date.CultureInfo.timezones; if (!name) { name = (new Date()).getTimezone();} for (i = 0; i < z.length; i++) { if (z[i].name === name.toUpperCase()) { a.push(i); } } if (!z[a[0]]) { return null; } if (a.length === 1 || !dst) { return z[a[0]].offset; } else { for (i=0; i < a.length; i++) { if (z[a[i]].dst) { return z[a[i]].offset; } } } }; $D.getQuarter = function (d) { d = d || new Date(); // If no date supplied, use today var q = [1,2,3,4]; return q[Math.floor(d.getMonth() / 3)]; // ~~~ is a bitwise op. Faster than Math.floor }; $D.getDaysLeftInQuarter = function (d) { d = d || new Date(); var qEnd = new Date(d); qEnd.setMonth(qEnd.getMonth() + 3 - qEnd.getMonth() % 3, 0); return Math.floor((qEnd - d) / 8.64e7); }; // private var validate = function (n, min, max, name) { name = name ? name : "Object"; if (typeof n === "undefined") { return false; } else if (typeof n !== "number") { throw new TypeError(n + " is not a Number."); } else if (n < min || n > max) { // As failing validation is *not* an exceptional circumstance // lets not throw a RangeError Exception here. // It's semantically correct but it's not sensible. return false; } return true; }; /** * Validates the number is within an acceptable range for milliseconds [0-999]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateMillisecond = function (value) { return validate(value, 0, 999, "millisecond"); }; /** * Validates the number is within an acceptable range for seconds [0-59]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateSecond = function (value) { return validate(value, 0, 59, "second"); }; /** * Validates the number is within an acceptable range for minutes [0-59]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateMinute = function (value) { return validate(value, 0, 59, "minute"); }; /** * Validates the number is within an acceptable range for hours [0-23]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateHour = function (value) { return validate(value, 0, 23, "hour"); }; /** * Validates the number is within an acceptable range for the days in a month [0-MaxDaysInMonth]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateDay = function (value, year, month) { if (year === undefined || year === null || month === undefined || month === null) { return false;} return validate(value, 1, $D.getDaysInMonth(year, month), "day"); }; /** * Validates the number is within an acceptable range for months [0-11]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateWeek = function (value) { return validate(value, 0, 53, "week"); }; /** * Validates the number is within an acceptable range for months [0-11]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateMonth = function (value) { return validate(value, 0, 11, "month"); }; /** * Validates the number is within an acceptable range for years. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateYear = function (value) { /** * Per ECMAScript spec the range of times supported by Date objects is * exactly -100,000,000 days to +100,000,000 days measured relative to * midnight at the beginning of 01 January, 1970 UTC. * This gives a range of 8,640,000,000,000,000 milliseconds to either * side of 01 January, 1970 UTC. * * Earliest possible date: Tue, 20 Apr 271,822 B.C. 00:00:00 UTC * Latest possible date: Sat, 13 Sep 275,760 00:00:00 UTC */ return validate(value, -271822, 275760, "year"); }; $D.validateTimezone = function(value) { var timezones = {"ACDT":1,"ACST":1,"ACT":1,"ADT":1,"AEDT":1,"AEST":1,"AFT":1,"AKDT":1,"AKST":1,"AMST":1,"AMT":1,"ART":1,"AST":1,"AWDT":1,"AWST":1,"AZOST":1,"AZT":1,"BDT":1,"BIOT":1,"BIT":1,"BOT":1,"BRT":1,"BST":1,"BTT":1,"CAT":1,"CCT":1,"CDT":1,"CEDT":1,"CEST":1,"CET":1,"CHADT":1,"CHAST":1,"CHOT":1,"ChST":1,"CHUT":1,"CIST":1,"CIT":1,"CKT":1,"CLST":1,"CLT":1,"COST":1,"COT":1,"CST":1,"CT":1,"CVT":1,"CWST":1,"CXT":1,"DAVT":1,"DDUT":1,"DFT":1,"EASST":1,"EAST":1,"EAT":1,"ECT":1,"EDT":1,"EEDT":1,"EEST":1,"EET":1,"EGST":1,"EGT":1,"EIT":1,"EST":1,"FET":1,"FJT":1,"FKST":1,"FKT":1,"FNT":1,"GALT":1,"GAMT":1,"GET":1,"GFT":1,"GILT":1,"GIT":1,"GMT":1,"GST":1,"GYT":1,"HADT":1,"HAEC":1,"HAST":1,"HKT":1,"HMT":1,"HOVT":1,"HST":1,"ICT":1,"IDT":1,"IOT":1,"IRDT":1,"IRKT":1,"IRST":1,"IST":1,"JST":1,"KGT":1,"KOST":1,"KRAT":1,"KST":1,"LHST":1,"LINT":1,"MAGT":1,"MART":1,"MAWT":1,"MDT":1,"MET":1,"MEST":1,"MHT":1,"MIST":1,"MIT":1,"MMT":1,"MSK":1,"MST":1,"MUT":1,"MVT":1,"MYT":1,"NCT":1,"NDT":1,"NFT":1,"NPT":1,"NST":1,"NT":1,"NUT":1,"NZDT":1,"NZST":1,"OMST":1,"ORAT":1,"PDT":1,"PET":1,"PETT":1,"PGT":1,"PHOT":1,"PHT":1,"PKT":1,"PMDT":1,"PMST":1,"PONT":1,"PST":1,"PYST":1,"PYT":1,"RET":1,"ROTT":1,"SAKT":1,"SAMT":1,"SAST":1,"SBT":1,"SCT":1,"SGT":1,"SLST":1,"SRT":1,"SST":1,"SYOT":1,"TAHT":1,"THA":1,"TFT":1,"TJT":1,"TKT":1,"TLT":1,"TMT":1,"TOT":1,"TVT":1,"UCT":1,"ULAT":1,"UTC":1,"UYST":1,"UYT":1,"UZT":1,"VET":1,"VLAT":1,"VOLT":1,"VOST":1,"VUT":1,"WAKT":1,"WAST":1,"WAT":1,"WEDT":1,"WEST":1,"WET":1,"WST":1,"YAKT":1,"YEKT":1,"Z":1}; return (timezones[value] === 1); }; $D.validateTimezoneOffset= function(value) { // timezones go from +14hrs to -12hrs, the +X hours are negative offsets. return (value > -841 && value < 721); }; }()); (function () { var $D = Date, $P = $D.prototype, p = function (s, l) { if (!l) { l = 2; } return ("000" + s).slice(l * -1); }; var validateConfigObject = function (obj) { var result = {}, self = this, prop, testFunc; testFunc = function (prop, func, value) { if (prop === "day") { var month = (obj.month !== undefined) ? obj.month : self.getMonth(); var year = (obj.year !== undefined) ? obj.year : self.getFullYear(); return $D[func](value, year, month); } else { return $D[func](value); } }; for (prop in obj) { if (Object.prototype.hasOwnProperty.call(obj, prop)) { var func = "validate" + prop.charAt(0).toUpperCase() + prop.slice(1); if ($D[func] && obj[prop] !== null && testFunc(prop, func, obj[prop])) { result[prop] = obj[prop]; } } } return result; }; /** * Resets the time of this Date object to 12:00 AM (00:00), which is the start of the day. * @param {Boolean} .clone() this date instance before clearing Time * @return {Date} this */ $P.clearTime = function () { this.setHours(0); this.setMinutes(0); this.setSeconds(0); this.setMilliseconds(0); return this; }; /** * Resets the time of this Date object to the current time ('now'). * @return {Date} this */ $P.setTimeToNow = function () { var n = new Date(); this.setHours(n.getHours()); this.setMinutes(n.getMinutes()); this.setSeconds(n.getSeconds()); this.setMilliseconds(n.getMilliseconds()); return this; }; /** * Returns a new Date object that is an exact date and time copy of the original instance. * @return {Date} A new Date instance */ $P.clone = function () { return new Date(this.getTime()); }; /** * Compares this instance to a Date object and returns an number indication of their relative values. * @param {Date} Date object to compare [Required] * @return {Number} -1 = this is lessthan date. 0 = values are equal. 1 = this is greaterthan date. */ $P.compareTo = function (date) { return Date.compare(this, date); }; /** * Compares this instance to another Date object and returns true if they are equal. * @param {Date} Date object to compare. If no date to compare, new Date() [now] is used. * @return {Boolean} true if dates are equal. false if they are not equal. */ $P.equals = function (date) { return Date.equals(this, (date !== undefined ? date : new Date())); }; /** * Determines if this instance is between a range of two dates or equal to either the start or end dates. * @param {Date} Start of range [Required] * @param {Date} End of range [Required] * @return {Boolean} true is this is between or equal to the start and end dates, else false */ $P.between = function (start, end) { return this.getTime() >= start.getTime() && this.getTime() <= end.getTime(); }; /** * Determines if this date occurs after the date to compare to. * @param {Date} Date object to compare. If no date to compare, new Date() ("now") is used. * @return {Boolean} true if this date instance is greater than the date to compare to (or "now"), otherwise false. */ $P.isAfter = function (date) { return this.compareTo(date || new Date()) === 1; }; /** * Determines if this date occurs before the date to compare to. * @param {Date} Date object to compare. If no date to compare, new Date() ("now") is used. * @return {Boolean} true if this date instance is less than the date to compare to (or "now"). */ $P.isBefore = function (date) { return (this.compareTo(date || new Date()) === -1); }; /** * Determines if the current Date instance occurs today. * @return {Boolean} true if this date instance is 'today', otherwise false. */ /** * Determines if the current Date instance occurs on the same Date as the supplied 'date'. * If no 'date' to compare to is provided, the current Date instance is compared to 'today'. * @param {date} Date object to compare. If no date to compare, the current Date ("now") is used. * @return {Boolean} true if this Date instance occurs on the same Day as the supplied 'date'. */ $P.isToday = $P.isSameDay = function (date) { return this.clone().clearTime().equals((date || new Date()).clone().clearTime()); }; /** * Adds the specified number of milliseconds to this instance. * @param {Number} The number of milliseconds to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addMilliseconds = function (value) { if (!value) { return this; } this.setTime(this.getTime() + value * 1); return this; }; /** * Adds the specified number of seconds to this instance. * @param {Number} The number of seconds to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addSeconds = function (value) { if (!value) { return this; } return this.addMilliseconds(value * 1000); }; /** * Adds the specified number of seconds to this instance. * @param {Number} The number of seconds to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addMinutes = function (value) { if (!value) { return this; } return this.addMilliseconds(value * 60000); // 60*1000 }; /** * Adds the specified number of hours to this instance. * @param {Number} The number of hours to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addHours = function (value) { if (!value) { return this; } return this.addMilliseconds(value * 3600000); // 60*60*1000 }; /** * Adds the specified number of days to this instance. * @param {Number} The number of days to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addDays = function (value) { if (!value) { return this; } this.setDate(this.getDate() + value * 1); return this; }; /** * Adds the specified number of weekdays (ie - not sat or sun) to this instance. * @param {Number} The number of days to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addWeekdays = function (value) { if (!value) { return this; } var day = this.getDay(); var weeks = (Math.ceil(Math.abs(value)/7)); if (day === 0 || day === 6) { if (value > 0) { this.next().monday(); this.addDays(-1); day = this.getDay(); } } if (value < 0) { while (value < 0) { this.addDays(-1); day = this.getDay(); if (day !== 0 && day !== 6) { value++; } } return this; } else if (value > 5 || (6-day) <= value) { value = value + (weeks * 2); } return this.addDays(value); }; /** * Adds the specified number of weeks to this instance. * @param {Number} The number of weeks to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addWeeks = function (value) { if (!value) { return this; } return this.addDays(value * 7); }; /** * Adds the specified number of months to this instance. * @param {Number} The number of months to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addMonths = function (value) { if (!value) { return this; } var n = this.getDate(); this.setDate(1); this.setMonth(this.getMonth() + value * 1); this.setDate(Math.min(n, $D.getDaysInMonth(this.getFullYear(), this.getMonth()))); return this; }; $P.addQuarters = function (value) { if (!value) { return this; } // note this will take you to the same point in the quarter as you are now. // i.e. - if you are 15 days into the quarter you'll be 15 days into the resulting one. // bonus: this allows adding fractional quarters return this.addMonths(value * 3); }; /** * Adds the specified number of years to this instance. * @param {Number} The number of years to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addYears = function (value) { if (!value) { return this; } return this.addMonths(value * 12); }; /** * Adds (or subtracts) to the value of the years, months, weeks, days, hours, minutes, seconds, milliseconds of the date instance using given configuration object. Positive and Negative values allowed. * Example

	Date.today().add( { days: 1, months: 1 } )

	new Date().add( { years: -1 } )
	
* @param {Object} Configuration object containing attributes (months, days, etc.) * @return {Date} this */ $P.add = function (config) { if (typeof config === "number") { this._orient = config; return this; } var x = config; if (x.day) { // If we should be a different date than today (eg: for 'tomorrow -1d', etc). // Should only effect parsing, not direct usage (eg, Finish and FinishExact) if ((x.day - this.getDate()) !== 0) { this.setDate(x.day); } } if (x.milliseconds) { this.addMilliseconds(x.milliseconds); } if (x.seconds) { this.addSeconds(x.seconds); } if (x.minutes) { this.addMinutes(x.minutes); } if (x.hours) { this.addHours(x.hours); } if (x.weeks) { this.addWeeks(x.weeks); } if (x.months) { this.addMonths(x.months); } if (x.years) { this.addYears(x.years); } if (x.days) { this.addDays(x.days); } return this; }; /** * Get the week number. Week one (1) is the week which contains the first Thursday of the year. Monday is considered the first day of the week. * The .getWeek() function does NOT convert the date to UTC. The local datetime is used. * Please use .getISOWeek() to get the week of the UTC converted date. * @return {Number} 1 to 53 */ $P.getWeek = function (utc) { // Create a copy of this date object var self, target = new Date(this.valueOf()); if (utc) { target.addMinutes(target.getTimezoneOffset()); self = target.clone(); } else { self = this; } // ISO week date weeks start on monday // so correct the day number var dayNr = (self.getDay() + 6) % 7; // ISO 8601 states that week 1 is the week // with the first thursday of that year. // Set the target date to the thursday in the target week target.setDate(target.getDate() - dayNr + 3); // Store the millisecond value of the target date var firstThursday = target.valueOf(); // Set the target to the first thursday of the year // First set the target to january first target.setMonth(0, 1); // Not a thursday? Correct the date to the next thursday if (target.getDay() !== 4) { target.setMonth(0, 1 + ((4 - target.getDay()) + 7) % 7); } // The weeknumber is the number of weeks between the // first thursday of the year and the thursday in the target week return 1 + Math.ceil((firstThursday - target) / 604800000); // 604800000 = 7 * 24 * 3600 * 1000 }; /** * Get the ISO 8601 week number. Week one ("01") is the week which contains the first Thursday of the year. Monday is considered the first day of the week. * The .getISOWeek() function does convert the date to it's UTC value. Please use .getWeek() to get the week of the local date. * @return {String} "01" to "53" */ $P.getISOWeek = function () { return p(this.getWeek(true)); }; /** * Moves the date to Monday of the week set. Week one (1) is the week which contains the first Thursday of the year. * @param {Number} A Number (1 to 53) that represents the week of the year. * @return {Date} this */ $P.setWeek = function (n) { if ((n - this.getWeek()) === 0) { if (this.getDay() !== 1) { return this.moveToDayOfWeek(1, (this.getDay() > 1 ? -1 : 1)); } else { return this; } } else { return this.moveToDayOfWeek(1, (this.getDay() > 1 ? -1 : 1)).addWeeks(n - this.getWeek()); } }; $P.setQuarter = function (qtr) { var month = Math.abs(((qtr-1) * 3) + 1); return this.setMonth(month, 1); }; $P.getQuarter = function () { return Date.getQuarter(this); }; $P.getDaysLeftInQuarter = function () { return Date.getDaysLeftInQuarter(this); }; /** * Moves the date to the next n'th occurrence of the dayOfWeek starting from the beginning of the month. The number (-1) is a magic number and will return the last occurrence of the dayOfWeek in the month. * @param {Number} The dayOfWeek to move to * @param {Number} The n'th occurrence to move to. Use (-1) to return the last occurrence in the month * @return {Date} this */ $P.moveToNthOccurrence = function (dayOfWeek, occurrence) { if (dayOfWeek === "Weekday") { if (occurrence > 0) { this.moveToFirstDayOfMonth(); if (this.is().weekday()) { occurrence -= 1; } } else if (occurrence < 0) { this.moveToLastDayOfMonth(); if (this.is().weekday()) { occurrence += 1; } } else { return this; } return this.addWeekdays(occurrence); } var shift = 0; if (occurrence > 0) { shift = occurrence - 1; } else if (occurrence === -1) { this.moveToLastDayOfMonth(); if (this.getDay() !== dayOfWeek) { this.moveToDayOfWeek(dayOfWeek, -1); } return this; } return this.moveToFirstDayOfMonth().addDays(-1).moveToDayOfWeek(dayOfWeek, +1).addWeeks(shift); }; var moveToN = function (getFunc, addFunc, nVal) { return function (value, orient) { var diff = (value - this[getFunc]() + nVal * (orient || +1)) % nVal; return this[addFunc]((diff === 0) ? diff += nVal * (orient || +1) : diff); }; }; /** * Move to the next or last dayOfWeek based on the orient value. * @param {Number} The dayOfWeek to move to * @param {Number} Forward (+1) or Back (-1). Defaults to +1. [Optional] * @return {Date} this */ $P.moveToDayOfWeek = moveToN("getDay", "addDays", 7); /** * Move to the next or last month based on the orient value. * @param {Number} The month to move to. 0 = January, 11 = December * @param {Number} Forward (+1) or Back (-1). Defaults to +1. [Optional] * @return {Date} this */ $P.moveToMonth = moveToN("getMonth", "addMonths", 12); /** * Get the Ordinate of the current day ("th", "st", "rd"). * @return {String} */ $P.getOrdinate = function () { var num = this.getDate(); return ord(num); }; /** * Get the Ordinal day (numeric day number) of the year, adjusted for leap year. * @return {Number} 1 through 365 (366 in leap years) */ $P.getOrdinalNumber = function () { return Math.ceil((this.clone().clearTime() - new Date(this.getFullYear(), 0, 1)) / 86400000) + 1; }; /** * Get the time zone abbreviation of the current date. * @return {String} The abbreviated time zone name (e.g. "EST") */ $P.getTimezone = function () { return $D.getTimezoneAbbreviation(this.getUTCOffset(), this.isDaylightSavingTime()); }; $P.setTimezoneOffset = function (offset) { var here = this.getTimezoneOffset(), there = Number(offset) * -6 / 10; return (there || there === 0) ? this.addMinutes(there - here) : this; }; $P.setTimezone = function (offset) { return this.setTimezoneOffset($D.getTimezoneOffset(offset)); }; /** * Indicates whether Daylight Saving Time is observed in the current time zone. * @return {Boolean} true|false */ $P.hasDaylightSavingTime = function () { return (Date.today().set({month: 0, day: 1}).getTimezoneOffset() !== Date.today().set({month: 6, day: 1}).getTimezoneOffset()); }; /** * Indicates whether this Date instance is within the Daylight Saving Time range for the current time zone. * @return {Boolean} true|false */ $P.isDaylightSavingTime = function () { return Date.today().set({month: 0, day: 1}).getTimezoneOffset() !== this.getTimezoneOffset(); }; /** * Get the offset from UTC of the current date. * @return {String} The 4-character offset string prefixed with + or - (e.g. "-0500") */ $P.getUTCOffset = function (offset) { var n = (offset || this.getTimezoneOffset()) * -10 / 6, r; if (n < 0) { r = (n - 10000).toString(); return r.charAt(0) + r.substr(2); } else { r = (n + 10000).toString(); return "+" + r.substr(1); } }; /** * Returns the number of milliseconds between this date and date. * @param {Date} Defaults to now * @return {Number} The diff in milliseconds */ $P.getElapsed = function (date) { return (date || new Date()) - this; }; /** * Set the value of year, month, day, hour, minute, second, millisecond of date instance using given configuration object. * Example

	Date.today().set( { day: 20, month: 1 } )

	new Date().set( { millisecond: 0 } )
	
* * @param {Object} Configuration object containing attributes (month, day, etc.) * @return {Date} this */ $P.set = function (config) { config = validateConfigObject.call(this, config); var key; for (key in config) { if (Object.prototype.hasOwnProperty.call(config, key)) { var name = key.charAt(0).toUpperCase() + key.slice(1); var addFunc, getFunc; if (key !== "week" && key !== "month" && key !== "timezone" && key !== "timezoneOffset") { name += "s"; } addFunc = "add" + name; getFunc = "get" + name; if (key === "month") { addFunc = addFunc + "s"; } else if (key === "year"){ getFunc = "getFullYear"; } if (key !== "day" && key !== "timezone" && key !== "timezoneOffset" && key !== "week" && key !== "hour") { this[addFunc](config[key] - this[getFunc]()); } else if ( key === "timezone"|| key === "timezoneOffset" || key === "week" || key === "hour") { this["set"+name](config[key]); } } } // day has to go last because you can't validate the day without first knowing the month if (config.day) { this.addDays(config.day - this.getDate()); } return this; }; /** * Moves the date to the first day of the month. * @return {Date} this */ $P.moveToFirstDayOfMonth = function () { return this.set({ day: 1 }); }; /** * Moves the date to the last day of the month. * @return {Date} this */ $P.moveToLastDayOfMonth = function () { return this.set({ day: $D.getDaysInMonth(this.getFullYear(), this.getMonth())}); }; /** * Converts the value of the current Date object to its equivalent string representation. * Format Specifiers * CUSTOM DATE AND TIME FORMAT STRINGS * Format Description Example * ------ --------------------------------------------------------------------------- ----------------------- * s The seconds of the minute between 0-59. "0" to "59" * ss The seconds of the minute with leading zero if required. "00" to "59" * * m The minute of the hour between 0-59. "0" or "59" * mm The minute of the hour with leading zero if required. "00" or "59" * * h The hour of the day between 1-12. "1" to "12" * hh The hour of the day with leading zero if required. "01" to "12" * * H The hour of the day between 0-23. "0" to "23" * HH The hour of the day with leading zero if required. "00" to "23" * * d The day of the month between 1 and 31. "1" to "31" * dd The day of the month with leading zero if required. "01" to "31" * ddd Abbreviated day name. Date.CultureInfo.abbreviatedDayNames. "Mon" to "Sun" * dddd The full day name. Date.CultureInfo.dayNames. "Monday" to "Sunday" * * M The month of the year between 1-12. "1" to "12" * MM The month of the year with leading zero if required. "01" to "12" * MMM Abbreviated month name. Date.CultureInfo.abbreviatedMonthNames. "Jan" to "Dec" * MMMM The full month name. Date.CultureInfo.monthNames. "January" to "December" * * yy The year as a two-digit number. "99" or "08" * yyyy The full four digit year. "1999" or "2008" * * t Displays the first character of the A.M./P.M. designator. "A" or "P" * Date.CultureInfo.amDesignator or Date.CultureInfo.pmDesignator * tt Displays the A.M./P.M. designator. "AM" or "PM" * Date.CultureInfo.amDesignator or Date.CultureInfo.pmDesignator * * S The ordinal suffix ("st, "nd", "rd" or "th") of the current day. "st, "nd", "rd" or "th" * * STANDARD DATE AND TIME FORMAT STRINGS * Format Description Example *------ --------------------------------------------------------------------------- ----------------------- * d The CultureInfo shortDate Format Pattern "M/d/yyyy" * D The CultureInfo longDate Format Pattern "dddd, MMMM dd, yyyy" * F The CultureInfo fullDateTime Format Pattern "dddd, MMMM dd, yyyy h:mm:ss tt" * m The CultureInfo monthDay Format Pattern "MMMM dd" * r The CultureInfo rfc1123 Format Pattern "ddd, dd MMM yyyy HH:mm:ss GMT" * s The CultureInfo sortableDateTime Format Pattern "yyyy-MM-ddTHH:mm:ss" * t The CultureInfo shortTime Format Pattern "h:mm tt" * T The CultureInfo longTime Format Pattern "h:mm:ss tt" * u The CultureInfo universalSortableDateTime Format Pattern "yyyy-MM-dd HH:mm:ssZ" * y The CultureInfo yearMonth Format Pattern "MMMM, yyyy" * * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @return {String} A string representation of the current Date object. */ var ord = function (n) { switch (n * 1) { case 1: case 21: case 31: return "st"; case 2: case 22: return "nd"; case 3: case 23: return "rd"; default: return "th"; } }; var parseStandardFormats = function (format) { var y, c = Date.CultureInfo.formatPatterns; switch (format) { case "d": return this.toString(c.shortDate); case "D": return this.toString(c.longDate); case "F": return this.toString(c.fullDateTime); case "m": return this.toString(c.monthDay); case "r": case "R": y = this.clone().addMinutes(this.getTimezoneOffset()); return y.toString(c.rfc1123) + " GMT"; case "s": return this.toString(c.sortableDateTime); case "t": return this.toString(c.shortTime); case "T": return this.toString(c.longTime); case "u": y = this.clone().addMinutes(this.getTimezoneOffset()); return y.toString(c.universalSortableDateTime); case "y": return this.toString(c.yearMonth); default: return false; } }; var parseFormatStringsClosure = function (context) { return function (m) { if (m.charAt(0) === "\\") { return m.replace("\\", ""); } switch (m) { case "hh": return p(context.getHours() < 13 ? (context.getHours() === 0 ? 12 : context.getHours()) : (context.getHours() - 12)); case "h": return context.getHours() < 13 ? (context.getHours() === 0 ? 12 : context.getHours()) : (context.getHours() - 12); case "HH": return p(context.getHours()); case "H": return context.getHours(); case "mm": return p(context.getMinutes()); case "m": return context.getMinutes(); case "ss": return p(context.getSeconds()); case "s": return context.getSeconds(); case "yyyy": return p(context.getFullYear(), 4); case "yy": return p(context.getFullYear()); case "y": return context.getFullYear(); case "E": case "dddd": return Date.CultureInfo.dayNames[context.getDay()]; case "ddd": return Date.CultureInfo.abbreviatedDayNames[context.getDay()]; case "dd": return p(context.getDate()); case "d": return context.getDate(); case "MMMM": return Date.CultureInfo.monthNames[context.getMonth()]; case "MMM": return Date.CultureInfo.abbreviatedMonthNames[context.getMonth()]; case "MM": return p((context.getMonth() + 1)); case "M": return context.getMonth() + 1; case "t": return context.getHours() < 12 ? Date.CultureInfo.amDesignator.substring(0, 1) : Date.CultureInfo.pmDesignator.substring(0, 1); case "tt": return context.getHours() < 12 ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator; case "S": return ord(context.getDate()); case "W": return context.getWeek(); case "WW": return context.getISOWeek(); case "Q": return "Q" + context.getQuarter(); case "q": return String(context.getQuarter()); case "z": return context.getTimezone(); case "Z": case "X": return Date.getTimezoneOffset(context.getTimezone()); case "ZZ": // Timezone offset in seconds return context.getTimezoneOffset() * -60; case "u": return context.getDay(); case "L": return ($D.isLeapYear(context.getFullYear())) ? 1 : 0; case "B": // Swatch Internet Time (.beats) return "@"+((context.getUTCSeconds() + (context.getUTCMinutes()*60) + ((context.getUTCHours()+1)*3600))/86.4); default: return m; } }; }; $P.toString = function (format, ignoreStandards) { // Standard Date and Time Format Strings. Formats pulled from CultureInfo file and // may vary by culture. if (!ignoreStandards && format && format.length === 1) { output = parseStandardFormats.call(this, format); if (output) { return output; } } var parseFormatStrings = parseFormatStringsClosure(this); return format ? format.replace(/((\\)?(dd?d?d?|MM?M?M?|yy?y?y?|hh?|HH?|mm?|ss?|tt?|S|q|Q|WW?W?W?)(?![^\[]*\]))/g, parseFormatStrings).replace(/\[|\]/g, "") : this._toString(); }; }()); /************************************************************* * SugarPak - Domain Specific Language - Syntactical Sugar * *************************************************************/ (function () { var $D = Date, $P = $D.prototype, $N = Number.prototype; // private $P._orient = +1; // private $P._nth = null; // private $P._is = false; // private $P._same = false; // private $P._isSecond = false; // private $N._dateElement = "days"; /** * Moves the date to the next instance of a date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.today().next().friday();
	Date.today().next().fri();
	Date.today().next().march();
	Date.today().next().mar();
	Date.today().next().week();
	
* * @return {Date} date */ $P.next = function () { this._move = true; this._orient = +1; return this; }; /** * Creates a new Date (Date.today()) and moves the date to the next instance of the date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.next().friday();
	Date.next().fri();
	Date.next().march();
	Date.next().mar();
	Date.next().week();
	
* * @return {Date} date */ $D.next = function () { return $D.today().next(); }; /** * Moves the date to the previous instance of a date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.today().last().friday();
	Date.today().last().fri();
	Date.today().last().march();
	Date.today().last().mar();
	Date.today().last().week();
	
* * @return {Date} date */ $P.last = $P.prev = $P.previous = function () { this._move = true; this._orient = -1; return this; }; /** * Creates a new Date (Date.today()) and moves the date to the previous instance of the date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.last().friday();
	Date.last().fri();
	Date.previous().march();
	Date.prev().mar();
	Date.last().week();
	
* * @return {Date} date */ $D.last = $D.prev = $D.previous = function () { return $D.today().last(); }; /** * Performs a equality check when followed by either a month name, day name or .weekday() function. * Example

	Date.today().is().friday(); // true|false
	Date.today().is().fri();
	Date.today().is().march();
	Date.today().is().mar();
	
* * @return {Boolean} true|false */ $P.is = function () { this._is = true; return this; }; /** * Determines if two date objects occur on/in exactly the same instance of the subsequent date part function. * The function .same() must be followed by a date part function (example: .day(), .month(), .year(), etc). * * An optional Date can be passed in the date part function. If now date is passed as a parameter, 'Now' is used. * * The following example demonstrates how to determine if two dates fall on the exact same day. * * Example

	var d1 = Date.today(); // today at 00:00
	var d2 = new Date();   // exactly now.

	// Do they occur on the same day?
	d1.same().day(d2); // true
	
	// Do they occur on the same hour?
	d1.same().hour(d2); // false, unless d2 hour is '00' (midnight).
	
	// What if it's the same day, but one year apart?
	var nextYear = Date.today().add(1).year();

	d1.same().day(nextYear); // false, because the dates must occur on the exact same day. 
	
* * Scenario: Determine if a given date occurs during some week period 2 months from now. * * Example

	var future = Date.today().add(2).months();
	return someDate.same().week(future); // true|false;
	
* * @return {Boolean} true|false */ $P.same = function () { this._same = true; this._isSecond = false; return this; }; /** * Determines if the current date/time occurs during Today. Must be preceded by the .is() function. * Example

	someDate.is().today();    // true|false
	new Date().is().today();  // true
	Date.today().is().today();// true
	Date.today().add(-1).day().is().today(); // false
	
* * @return {Boolean} true|false */ $P.today = function () { return this.same().day(); }; /** * Determines if the current date is a weekday. This function must be preceded by the .is() function. * Example

	Date.today().is().weekday(); // true|false
	
* * @return {Boolean} true|false */ $P.weekday = function () { if (this._nth) { return df("Weekday").call(this); } if (this._move) { return this.addWeekdays(this._orient); } if (this._is) { this._is = false; return (!this.is().sat() && !this.is().sun()); } return false; }; /** * Determines if the current date is on the weekend. This function must be preceded by the .is() function. * Example

	Date.today().is().weekend(); // true|false
	
* * @return {Boolean} true|false */ $P.weekend = function () { if (this._is) { this._is = false; return (this.is().sat() || this.is().sun()); } return false; }; /** * Sets the Time of the current Date instance. A string "6:15 pm" or config object {hour:18, minute:15} are accepted. * Example

	// Set time to 6:15pm with a String
	Date.today().at("6:15pm");

	// Set time to 6:15pm with a config object
	Date.today().at({hour:18, minute:15});
	
* * @return {Date} date */ $P.at = function (time) { return (typeof time === "string") ? $D.parse(this.toString("d") + " " + time) : this.set(time); }; /** * Creates a new Date() and adds this (Number) to the date based on the preceding date element function (eg. second|minute|hour|day|month|year). * Example

	// Undeclared Numbers must be wrapped with parentheses. Requirment of JavaScript.
	(3).days().fromNow();
	(6).months().fromNow();

	// Declared Number variables do not require parentheses. 
	var n = 6;
	n.months().fromNow();
	
* * @return {Date} A new Date instance */ $N.fromNow = $N.after = function (date) { var c = {}; c[this._dateElement] = this; return ((!date) ? new Date() : date.clone()).add(c); }; /** * Creates a new Date() and subtract this (Number) from the date based on the preceding date element function (eg. second|minute|hour|day|month|year). * Example

	// Undeclared Numbers must be wrapped with parentheses. Requirment of JavaScript.
	(3).days().ago();
	(6).months().ago();

	// Declared Number variables do not require parentheses. 
	var n = 6;
	n.months().ago();
	
* * @return {Date} A new Date instance */ $N.ago = $N.before = function (date) { var c = {}, s = (this._dateElement[this._dateElement.length-1] !== "s") ? this._dateElement + "s" : this._dateElement; c[s] = this * -1; return ((!date) ? new Date() : date.clone()).add(c); }; // Do NOT modify the following string tokens. These tokens are used to build dynamic functions. // All culture-specific strings can be found in the CultureInfo files. var dx = ("sunday monday tuesday wednesday thursday friday saturday").split(/\s/), mx = ("january february march april may june july august september october november december").split(/\s/), px = ("Millisecond Second Minute Hour Day Week Month Year Quarter Weekday").split(/\s/), pxf = ("Milliseconds Seconds Minutes Hours Date Week Month FullYear Quarter").split(/\s/), nth = ("final first second third fourth fifth").split(/\s/), de; /** * Returns an object literal of all the date parts. * Example

	var o = new Date().toObject();
	
	// { year: 2008, month: 4, week: 20, day: 13, hour: 18, minute: 9, second: 32, millisecond: 812 }
	
	// The object properties can be referenced directly from the object.
	
	alert(o.day);  // alerts "13"
	alert(o.year); // alerts "2008"
	
* * @return {Date} An object literal representing the original date object. */ $P.toObject = function () { var o = {}; for (var i = 0; i < px.length; i++) { if (this["get" + pxf[i]]) { o[px[i].toLowerCase()] = this["get" + pxf[i]](); } } return o; }; /** * Returns a date created from an object literal. Ignores the .week property if set in the config. * Example

	var o = new Date().toObject();
	
	return Date.fromObject(o); // will return the same date. 

	var o2 = {month: 1, day: 20, hour: 18}; // birthday party!
	Date.fromObject(o2);
	
* * @return {Date} An object literal representing the original date object. */ $D.fromObject = function(config) { config.week = null; return Date.today().set(config); }; // Create day name functions and abbreviated day name functions (eg. monday(), friday(), fri()). var df = function (n) { return function () { if (this._is) { this._is = false; return this.getDay() === n; } if (this._move) { this._move = null; } if (this._nth !== null) { // If the .second() function was called earlier, remove the _orient // from the date, and then continue. // This is required because 'second' can be used in two different context. // // Example // // Date.today().add(1).second(); // Date.march().second().monday(); // // Things get crazy with the following... // Date.march().add(1).second().second().monday(); // but it works!! // if (this._isSecond) { this.addSeconds(this._orient * -1); } // make sure we reset _isSecond this._isSecond = false; var ntemp = this._nth; this._nth = null; var temp = this.clone().moveToLastDayOfMonth(); this.moveToNthOccurrence(n, ntemp); if (this > temp) { throw new RangeError($D.getDayName(n) + " does not occur " + ntemp + " times in the month of " + $D.getMonthName(temp.getMonth()) + " " + temp.getFullYear() + "."); } return this; } return this.moveToDayOfWeek(n, this._orient); }; }; var sdf = function (n) { return function () { var t = $D.today(), shift = n - t.getDay(); if (n === 0 && Date.CultureInfo.firstDayOfWeek === 1 && t.getDay() !== 0) { shift = shift + 7; } return t.addDays(shift); }; }; // Create month name functions and abbreviated month name functions (eg. january(), march(), mar()). var month_instance_functions = function (n) { return function () { if (this._is) { this._is = false; return this.getMonth() === n; } return this.moveToMonth(n, this._orient); }; }; var month_static_functions = function (n) { return function () { return $D.today().set({ month: n, day: 1 }); }; }; var processTerms = function (names, staticFunc, instanceFunc) { for (var i = 0; i < names.length; i++) { // Create constant static Name variables. $D[names[i].toUpperCase()] = $D[names[i].toUpperCase().substring(0, 3)] = i; // Create Name functions. $D[names[i]] = $D[names[i].substring(0, 3)] = staticFunc(i); // Create Name instance functions. $P[names[i]] = $P[names[i].substring(0, 3)] = instanceFunc(i); } }; processTerms(dx, sdf, df); processTerms(mx, month_static_functions, month_instance_functions); // Create date element functions and plural date element functions used with Date (eg. day(), days(), months()). var ef = function (j) { return function () { // if the .second() function was called earlier, the _orient // has alread been added. Just return this and reset _isSecond. if (this._isSecond) { this._isSecond = false; return this; } if (this._same) { this._same = this._is = false; var o1 = this.toObject(), o2 = (arguments[0] || new Date()).toObject(), v = "", k = j.toLowerCase(); // the substr trick with -1 doesn't work in IE8 or less k = (k[k.length-1] === "s") ? k.substring(0,k.length-1) : k; for (var m = (px.length - 1); m > -1; m--) { v = px[m].toLowerCase(); if (o1[v] !== o2[v]) { return false; } if (k === v) { break; } } return true; } if (j.substring(j.length - 1) !== "s") { j += "s"; } if (this._move) { this._move = null; } return this["add" + j](this._orient); }; }; var nf = function (n) { return function () { this._dateElement = n; return this; }; }; for (var k = 0; k < px.length; k++) { de = px[k].toLowerCase(); if(de !== "weekday") { // Create date element functions and plural date element functions used with Date (eg. day(), days(), months()). $P[de] = $P[de + "s"] = ef(px[k]); // Create date element functions and plural date element functions used with Number (eg. day(), days(), months()). $N[de] = $N[de + "s"] = nf(de + "s"); } } $P._ss = ef("Second"); var nthfn = function (n) { return function (dayOfWeek) { if (this._same) { return this._ss(arguments[0]); } if (dayOfWeek || dayOfWeek === 0) { return this.moveToNthOccurrence(dayOfWeek, n); } this._nth = n; // if the operator is 'second' add the _orient, then deal with it later... if (n === 2 && (dayOfWeek === undefined || dayOfWeek === null)) { this._isSecond = true; return this.addSeconds(this._orient); } return this; }; }; for (var l = 0; l < nth.length; l++) { $P[nth[l]] = (l === 0) ? nthfn(-1) : nthfn(l); } }()); (function () { "use strict"; Date.Parsing = { Exception: function (s) { this.message = "Parse error at '" + s.substring(0, 10) + " ...'"; } }; var $P = Date.Parsing; var dayOffsets = { standard: [0,31,59,90,120,151,181,212,243,273,304,334], leap: [0,31,60,91,121,152,182,213,244,274,305,335] }; $P.isLeapYear = function(year) { return ((year % 4 === 0) && (year % 100 !== 0)) || (year % 400 === 0); }; var utils = { multiReplace : function (str, hash ) { var key; for (key in hash) { if (Object.prototype.hasOwnProperty.call(hash, key)) { var regex; if (typeof hash[key] === "function") { } else { regex = (hash[key] instanceof RegExp) ? hash[key] : new RegExp(hash[key], "g"); } str = str.replace(regex, key); } } return str; }, getDayOfYearFromWeek : function (obj) { var d, jan4, offset; obj.weekDay = (!obj.weekDay && obj.weekDay !== 0) ? 1 : obj.weekDay; d = new Date(obj.year, 0, 4); jan4 = d.getDay() === 0 ? 7 : d.getDay(); // JS is 0 indexed on Sunday. offset = jan4+3; obj.dayOfYear = ((obj.week * 7) + (obj.weekDay === 0 ? 7 : obj.weekDay))-offset; return obj; }, getDayOfYear : function (obj, dayOffset) { if (!obj.dayOfYear) { obj = utils.getDayOfYearFromWeek(obj); } for (var i=0;i <= dayOffset.length;i++) { if (obj.dayOfYear < dayOffset[i] || i === dayOffset.length) { obj.day = obj.day ? obj.day : (obj.dayOfYear - dayOffset[i-1]); break; } else { obj.month = i; } } return obj; }, adjustForTimeZone : function (obj, date) { var offset; if (obj.zone.toUpperCase() === "Z" || (obj.zone_hours === 0 && obj.zone_minutes === 0)) { // it's UTC/GML so work out the current timeszone offset offset = -date.getTimezoneOffset(); } else { offset = (obj.zone_hours*60) + (obj.zone_minutes || 0); if (obj.zone_sign === "+") { offset *= -1; } offset -= date.getTimezoneOffset(); } date.setMinutes(date.getMinutes()+offset); return date; }, setDefaults : function (obj) { obj.year = obj.year || Date.today().getFullYear(); obj.hours = obj.hours || 0; obj.minutes = obj.minutes || 0; obj.seconds = obj.seconds || 0; obj.milliseconds = obj.milliseconds || 0; if (!(!obj.month && (obj.week || obj.dayOfYear))) { // if we have a month, or if we don't but don't have the day calculation data obj.month = obj.month || 0; obj.day = obj.day || 1; } return obj; }, dataNum: function (data, mod, explict, postProcess) { var dataNum = data*1; if (mod) { if (postProcess) { return data ? mod(data)*1 : data; } else { return data ? mod(dataNum) : data; } } else if (!explict){ return data ? dataNum : data; } else { return (data && typeof data !== "undefined") ? dataNum : data; } }, timeDataProcess: function (obj) { var timeObj = {}; for (var x in obj.data) { if (obj.data.hasOwnProperty(x)) { timeObj[x] = obj.ignore[x] ? obj.data[x] : utils.dataNum(obj.data[x], obj.mods[x], obj.explict[x], obj.postProcess[x]); } } if (obj.data.secmins) { obj.data.secmins = obj.data.secmins.replace(",", ".") * 60; if (!timeObj.minutes) { timeObj.minutes = obj.data.secmins; } else if (!timeObj.seconds) { timeObj.seconds = obj.data.secmins; } delete obj.secmins; } return timeObj; }, buildTimeObjectFromData: function (data) { var time = utils.timeDataProcess({ data: { year : data[1], month : data[5], day : data[7], week : data[8], dayOfYear : data[10], hours : data[15], zone_hours : data[23], zone_minutes : data[24], zone : data[21], zone_sign : data[22], weekDay : data[9], minutes: data[16], seconds: data[19], milliseconds: data[20], secmins: data[18] }, mods: { month: function(data) { return data-1; }, weekDay: function (data) { data = Math.abs(data); return (data === 7 ? 0 : data); }, minutes: function (data) { return data.replace(":",""); }, seconds: function (data) { return Math.floor( (data.replace(":","").replace(",","."))*1 ); }, milliseconds: function (data) { return (data.replace(",",".")*1000); } }, postProcess: { minutes: true, seconds: true, milliseconds: true }, explict: { zone_hours: true, zone_minutes: true }, ignore: { zone: true, zone_sign: true, secmins: true } }); return time; }, addToHash: function (hash, keys, data) { keys = keys; data = data; var len = keys.length; for (var i = 0; i < len; i++) { hash[keys[i]] = data[i]; } return hash; }, combineRegex: function (r1, r2) { return new RegExp("(("+r1.source+")\\s("+r2.source+"))"); }, getDateNthString: function(add, last, inc){ if (add) { return Date.today().addDays(inc).toString("d"); } else if (last) { return Date.today().last()[inc]().toString("d"); } }, buildRegexData: function (array) { var arr = []; var len = array.length; for (var i=0; i < len; i++) { if (Object.prototype.toString.call(array[i]) === '[object Array]') { // oldIE compat version of Array.isArray arr.push(this.combineRegex(array[i][0], array[i][1])); } else { arr.push(array[i]); } } return arr; } }; $P.processTimeObject = function (obj) { var date, dayOffset; utils.setDefaults(obj); dayOffset = ($P.isLeapYear(obj.year)) ? dayOffsets.leap : dayOffsets.standard; if (!obj.month && (obj.week || obj.dayOfYear)) { utils.getDayOfYear(obj, dayOffset); } else { obj.dayOfYear = dayOffset[obj.month] + obj.day; } date = new Date(obj.year, obj.month, obj.day, obj.hours, obj.minutes, obj.seconds, obj.milliseconds); if (obj.zone) { utils.adjustForTimeZone(obj, date); // adjust (and calculate) for timezone } return date; }; $P.ISO = { regex : /^([\+-]?\d{4}(?!\d{2}\b))((-?)((0[1-9]|1[0-2])(\3([12]\d|0[1-9]|3[01]))?|W([0-4]\d|5[0-3])(-?[1-7])?|(00[1-9]|0[1-9]\d|[12]\d{2}|3([0-5]\d|6[1-6])))([T\s]((([01]\d|2[0-4])((:?)[0-5]\d)?|24\:?00)([\.,]\d+(?!:))?)?(\17[0-5]\d([\.,]\d+)?)?\s?([zZ]|([\+-])([01]\d|2[0-3]):?([0-5]\d)?)?)?)?$/, parse : function (s) { var time, data = s.match(this.regex); if (!data || !data.length) { return null; } time = utils.buildTimeObjectFromData(data); if (!time.year || (!time.year && (!time.month && !time.day) && (!time.week && !time.dayOfYear)) ) { return null; } return $P.processTimeObject(time); } }; $P.Numeric = { isNumeric: function (e){return!isNaN(parseFloat(e))&&isFinite(e);}, regex: /\b([0-1]?[0-9])([0-3]?[0-9])([0-2]?[0-9]?[0-9][0-9])\b/i, parse: function (s) { var data, i, time = {}, order = Date.CultureInfo.dateElementOrder.split(""); if (!(this.isNumeric(s)) || // if it's non-numeric OR (s[0] === "+" && s[0] === "-")) { // It's an arithmatic string (eg +/-1000) return null; } if (s.length < 5 && s.indexOf(".") < 0 && s.indexOf("/") < 0) { // assume it's just a year. time.year = s; return $P.processTimeObject(time); } data = s.match(this.regex); if (!data || !data.length) { return null; } for (i=0; i < order.length; i++) { switch(order[i]) { case "d": time.day = data[i+1]; break; case "m": time.month = (data[i+1]-1); break; case "y": time.year = data[i+1]; break; } } return $P.processTimeObject(time); } }; $P.Normalizer = { regexData: function () { var $R = Date.CultureInfo.regexPatterns; return utils.buildRegexData([ $R.tomorrow, $R.yesterday, [$R.past, $R.mon], [$R.past, $R.tue], [$R.past, $R.wed], [$R.past, $R.thu], [$R.past, $R.fri], [$R.past, $R.sat], [$R.past, $R.sun] ]); }, basicReplaceHash : function() { var $R = Date.CultureInfo.regexPatterns; return { "January": $R.jan.source, "February": $R.feb, "March": $R.mar, "April": $R.apr, "May": $R.may, "June": $R.jun, "July": $R.jul, "August": $R.aug, "September": $R.sep, "October": $R.oct, "November": $R.nov, "December": $R.dec, "": /\bat\b/gi, " ": /\s{2,}/, "am": $R.inTheMorning, "9am": $R.thisMorning, "pm": $R.inTheEvening, "7pm":$R.thisEvening }; }, keys : function(){ return [ utils.getDateNthString(true, false, 1), // tomorrow utils.getDateNthString(true, false, -1), // yesterday utils.getDateNthString(false, true, "monday"), //last mon utils.getDateNthString(false, true, "tuesday"), //last tues utils.getDateNthString(false, true, "wednesday"), //last wed utils.getDateNthString(false, true, "thursday"), //last thurs utils.getDateNthString(false, true, "friday"), //last fri utils.getDateNthString(false, true, "saturday"), //last sat utils.getDateNthString(false, true, "sunday") //last sun ]; }, buildRegexFunctions: function () { var $R = Date.CultureInfo.regexPatterns; var __ = Date.i18n.__; var tomorrowRE = new RegExp("(\\b\\d\\d?("+__("AM")+"|"+__("PM")+")? )("+$R.tomorrow.source.slice(1)+")", "i"); // adapted tomorrow regex for AM PM relative dates var todayRE = new RegExp($R.today.source + "(?!\\s*([+-]))\\b"); // today, but excludes the math operators (eg "today + 2h") this.replaceFuncs = [ [todayRE, function (full) { return (full.length > 1) ? Date.today().toString("d") : full; }], [tomorrowRE, function(full, m1) { var t = Date.today().addDays(1).toString("d"); return (t + " " + m1); }], [$R.amThisMorning, function(str, am){return am;}], [$R.pmThisEvening, function(str, pm){return pm;}] ]; }, buildReplaceData: function () { this.buildRegexFunctions(); this.replaceHash = utils.addToHash(this.basicReplaceHash(), this.keys(), this.regexData()); }, stringReplaceFuncs: function (s) { for (var i=0; i < this.replaceFuncs.length; i++) { s = s.replace(this.replaceFuncs[i][0], this.replaceFuncs[i][1]); } return s; }, parse: function (s) { s = this.stringReplaceFuncs(s); s = utils.multiReplace(s, this.replaceHash); try { var n = s.split(/([\s\-\.\,\/\x27]+)/); if (n.length === 3 && $P.Numeric.isNumeric(n[0]) && $P.Numeric.isNumeric(n[2]) && (n[2].length >= 4)) { // ok, so we're dealing with x/year. But that's not a full date. // This fixes wonky dateElementOrder parsing when set to dmy order. if (Date.CultureInfo.dateElementOrder[0] === "d") { s = "1/" + n[0] + "/" + n[2]; // set to 1st of month and normalize the seperator } } } catch (e) {} return s; } }; $P.Normalizer.buildReplaceData(); }()); (function () { var $P = Date.Parsing; var _ = $P.Operators = { // // Tokenizers // rtoken: function (r) { // regex token return function (s) { var mx = s.match(r); if (mx) { return ([ mx[0], s.substring(mx[0].length) ]); } else { throw new $P.Exception(s); } }; }, token: function () { // whitespace-eating token return function (s) { return _.rtoken(new RegExp("^\\s*" + s + "\\s*"))(s); }; }, stoken: function (s) { // string token return _.rtoken(new RegExp("^" + s)); }, // Atomic Operators until: function (p) { return function (s) { var qx = [], rx = null; while (s.length) { try { rx = p.call(this, s); } catch (e) { qx.push(rx[0]); s = rx[1]; continue; } break; } return [ qx, s ]; }; }, many: function (p) { return function (s) { var rx = [], r = null; while (s.length) { try { r = p.call(this, s); } catch (e) { return [ rx, s ]; } rx.push(r[0]); s = r[1]; } return [ rx, s ]; }; }, // generator operators -- see below optional: function (p) { return function (s) { var r = null; try { r = p.call(this, s); } catch (e) { return [ null, s ]; } return [ r[0], r[1] ]; }; }, not: function (p) { return function (s) { try { p.call(this, s); } catch (e) { return [null, s]; } throw new $P.Exception(s); }; }, ignore: function (p) { return p ? function (s) { var r = null; r = p.call(this, s); return [null, r[1]]; } : null; }, product: function () { var px = arguments[0], qx = Array.prototype.slice.call(arguments, 1), rx = []; for (var i = 0 ; i < px.length ; i++) { rx.push(_.each(px[i], qx)); } return rx; }, cache: function (rule) { var cache = {}, cache_length = 0, cache_keys = [], CACHE_MAX = Date.Config.CACHE_MAX || 100000, r = null; var cacheCheck = function () { if (cache_length === CACHE_MAX) { // kill several keys, don't want to have to do this all the time... for (var i=0; i < 10; i++) { var key = cache_keys.shift(); if (key) { delete cache[key]; cache_length--; } } } }; return function (s) { cacheCheck(); try { r = cache[s] = (cache[s] || rule.call(this, s)); } catch (e) { r = cache[s] = e; } cache_length++; cache_keys.push(s); if (r instanceof $P.Exception) { throw r; } else { return r; } }; }, // vector operators -- see below any: function () { var px = arguments; return function (s) { var r = null; for (var i = 0; i < px.length; i++) { if (px[i] == null) { continue; } try { r = (px[i].call(this, s)); } catch (e) { r = null; } if (r) { return r; } } throw new $P.Exception(s); }; }, each: function () { var px = arguments; return function (s) { var rx = [], r = null; for (var i = 0; i < px.length ; i++) { if (px[i] == null) { continue; } try { r = (px[i].call(this, s)); } catch (e) { throw new $P.Exception(s); } rx.push(r[0]); s = r[1]; } return [ rx, s]; }; }, all: function () { var px = arguments, _ = _; return _.each(_.optional(px)); }, // delimited operators sequence: function (px, d, c) { d = d || _.rtoken(/^\s*/); c = c || null; if (px.length === 1) { return px[0]; } return function (s) { var r = null, q = null; var rx = []; for (var i = 0; i < px.length ; i++) { try { r = px[i].call(this, s); } catch (e) { break; } rx.push(r[0]); try { q = d.call(this, r[1]); } catch (ex) { q = null; break; } s = q[1]; } if (!r) { throw new $P.Exception(s); } if (q) { throw new $P.Exception(q[1]); } if (c) { try { r = c.call(this, r[1]); } catch (ey) { throw new $P.Exception(r[1]); } } return [ rx, (r?r[1]:s) ]; }; }, // // Composite Operators // between: function (d1, p, d2) { d2 = d2 || d1; var _fn = _.each(_.ignore(d1), p, _.ignore(d2)); return function (s) { var rx = _fn.call(this, s); return [[rx[0][0], r[0][2]], rx[1]]; }; }, list: function (p, d, c) { d = d || _.rtoken(/^\s*/); c = c || null; return (p instanceof Array ? _.each(_.product(p.slice(0, -1), _.ignore(d)), p.slice(-1), _.ignore(c)) : _.each(_.many(_.each(p, _.ignore(d))), px, _.ignore(c))); }, set: function (px, d, c) { d = d || _.rtoken(/^\s*/); c = c || null; return function (s) { // r is the current match, best the current 'best' match // which means it parsed the most amount of input var r = null, p = null, q = null, rx = null, best = [[], s], last = false; // go through the rules in the given set for (var i = 0; i < px.length ; i++) { // last is a flag indicating whether this must be the last element // if there is only 1 element, then it MUST be the last one q = null; p = null; r = null; last = (px.length === 1); // first, we try simply to match the current pattern // if not, try the next pattern try { r = px[i].call(this, s); } catch (e) { continue; } // since we are matching against a set of elements, the first // thing to do is to add r[0] to matched elements rx = [[r[0]], r[1]]; // if we matched and there is still input to parse and // we don't already know this is the last element, // we're going to next check for the delimiter ... // if there's none, or if there's no input left to parse // than this must be the last element after all ... if (r[1].length > 0 && ! last) { try { q = d.call(this, r[1]); } catch (ex) { last = true; } } else { last = true; } // if we parsed the delimiter and now there's no more input, // that means we shouldn't have parsed the delimiter at all // so don't update r and mark this as the last element ... if (!last && q[1].length === 0) { last = true; } // so, if this isn't the last element, we're going to see if // we can get any more matches from the remaining (unmatched) // elements ... if (!last) { // build a list of the remaining rules we can match against, // i.e., all but the one we just matched against var qx = []; for (var j = 0; j < px.length ; j++) { if (i !== j) { qx.push(px[j]); } } // now invoke recursively set with the remaining input // note that we don't include the closing delimiter ... // we'll check for that ourselves at the end p = _.set(qx, d).call(this, q[1]); // if we got a non-empty set as a result ... // (otw rx already contains everything we want to match) if (p[0].length > 0) { // update current result, which is stored in rx ... // basically, pick up the remaining text from p[1] // and concat the result from p[0] so that we don't // get endless nesting ... rx[0] = rx[0].concat(p[0]); rx[1] = p[1]; } } // at this point, rx either contains the last matched element // or the entire matched set that starts with this element. // now we just check to see if this variation is better than // our best so far, in terms of how much of the input is parsed if (rx[1].length < best[1].length) { best = rx; } // if we've parsed all the input, then we're finished if (best[1].length === 0) { break; } } // so now we've either gone through all the patterns trying them // as the initial match; or we found one that parsed the entire // input string ... // if best has no matches, just return empty set ... if (best[0].length === 0) { return best; } // if a closing delimiter is provided, then we have to check it also if (c) { // we try this even if there is no remaining input because the pattern // may well be optional or match empty input ... try { q = c.call(this, best[1]); } catch (ey) { throw new $P.Exception(best[1]); } // it parsed ... be sure to update the best match remaining input best[1] = q[1]; } // if we're here, either there was no closing delimiter or we parsed it // so now we have the best match; just return it! return best; }; }, forward: function (gr, fname) { return function (s) { return gr[fname].call(this, s); }; }, // // Translation Operators // replace: function (rule, repl) { return function (s) { var r = rule.call(this, s); return [repl, r[1]]; }; }, process: function (rule, fn) { return function (s) { var r = rule.call(this, s); return [fn.call(this, r[0]), r[1]]; }; }, min: function (min, rule) { return function (s) { var rx = rule.call(this, s); if (rx[0].length < min) { throw new $P.Exception(s); } return rx; }; } }; // Generator Operators And Vector Operators // Generators are operators that have a signature of F(R) => R, // taking a given rule and returning another rule, such as // ignore, which parses a given rule and throws away the result. // Vector operators are those that have a signature of F(R1,R2,...) => R, // take a list of rules and returning a new rule, such as each. // Generator operators are converted (via the following _generator // function) into functions that can also take a list or array of rules // and return an array of new rules as though the function had been // called on each rule in turn (which is what actually happens). // This allows generators to be used with vector operators more easily. // Example: // each(ignore(foo, bar)) instead of each(ignore(foo), ignore(bar)) // This also turns generators into vector operators, which allows // constructs like: // not(cache(foo, bar)) var _generator = function (op) { function gen() { var args = null, rx = [], px, i; if (arguments.length > 1) { args = Array.prototype.slice.call(arguments); } else if (arguments[0] instanceof Array) { args = arguments[0]; } if (args) { px = args.shift(); if (px.length > 0) { args.unshift(px[i]); rx.push(op.apply(null, args)); args.shift(); return rx; } } else { return op.apply(null, arguments); } } return gen; }; var gx = "optional not ignore cache".split(/\s/); for (var i = 0 ; i < gx.length ; i++) { _[gx[i]] = _generator(_[gx[i]]); } var _vector = function (op) { return function () { if (arguments[0] instanceof Array) { return op.apply(null, arguments[0]); } else { return op.apply(null, arguments); } }; }; var vx = "each any all".split(/\s/); for (var j = 0 ; j < vx.length ; j++) { _[vx[j]] = _vector(_[vx[j]]); } }()); (function () { var $D = Date; var flattenAndCompact = function (ax) { var rx = []; for (var i = 0; i < ax.length; i++) { if (ax[i] instanceof Array) { rx = rx.concat(flattenAndCompact(ax[i])); } else { if (ax[i]) { rx.push(ax[i]); } } } return rx; }; var parseMeridian = function () { if (this.meridian && (this.hour || this.hour === 0)) { if (this.meridian === "a" && this.hour > 11 && Date.Config.strict24hr){ throw "Invalid hour and meridian combination"; } else if (this.meridian === "p" && this.hour < 12 && Date.Config.strict24hr){ throw "Invalid hour and meridian combination"; } else if (this.meridian === "p" && this.hour < 12) { this.hour = this.hour + 12; } else if (this.meridian === "a" && this.hour === 12) { this.hour = 0; } } }; var setDefaults = function () { var now = new Date(); if ((this.hour || this.minute) && (!this.month && !this.year && !this.day)) { this.day = now.getDate(); } if (!this.year) { this.year = now.getFullYear(); } if (!this.month && this.month !== 0) { this.month = now.getMonth(); } if (!this.day) { this.day = 1; } if (!this.hour) { this.hour = 0; } if (!this.minute) { this.minute = 0; } if (!this.second) { this.second = 0; } if (!this.millisecond) { this.millisecond = 0; } }; var finishUtils = { getToday: function () { if (this.now || "hour minute second".indexOf(this.unit) !== -1) { return new Date(); } else { return $D.today(); } }, setDaysFromWeekday: function (today, orient){ var gap; orient = orient || 1; this.unit = "day"; gap = ($D.getDayNumberFromName(this.weekday) - today.getDay()); this.days = gap ? ((gap + (orient * 7)) % 7) : (orient * 7); return this; }, setMonthsFromMonth: function (today, orient) { var gap; orient = orient || 1; this.unit = "month"; gap = (this.month - today.getMonth()); this.months = gap ? ((gap + (orient * 12)) % 12) : (orient * 12); this.month = null; return this; }, setDMYFromWeekday: function () { var d = Date[this.weekday](); this.day = d.getDate(); if (!this.month) { this.month = d.getMonth(); } this.year = d.getFullYear(); return this; }, setUnitValue: function (orient) { if (!this.value && this.operator && this.operator !== null && this[this.unit + "s"] && this[this.unit + "s"] !== null) { this[this.unit + "s"] = this[this.unit + "s"] + ((this.operator === "add") ? 1 : -1) + (this.value||0) * orient; } else if (this[this.unit + "s"] == null || this.operator != null) { if (!this.value) { this.value = 1; } this[this.unit + "s"] = this.value * orient; } }, generateDateFromWeeks: function () { var weekday = (this.weekday !== undefined) ? this.weekday : "today"; var d = Date[weekday]().addWeeks(this.weeks); if (this.now) { d.setTimeToNow(); } return d; } }; $D.Translator = { hour: function (s) { return function () { this.hour = Number(s); }; }, minute: function (s) { return function () { this.minute = Number(s); }; }, second: function (s) { return function () { this.second = Number(s); }; }, /* for ss.s format */ secondAndMillisecond: function (s) { return function () { var mx = s.match(/^([0-5][0-9])\.([0-9]{1,3})/); this.second = Number(mx[1]); this.millisecond = Number(mx[2]); }; }, meridian: function (s) { return function () { this.meridian = s.slice(0, 1).toLowerCase(); }; }, timezone: function (s) { return function () { var n = s.replace(/[^\d\+\-]/g, ""); if (n.length) { this.timezoneOffset = Number(n); } else { this.timezone = s.toLowerCase(); } }; }, day: function (x) { var s = x[0]; return function () { this.day = Number(s.match(/\d+/)[0]); if (this.day < 1) { throw "invalid day"; } }; }, month: function (s) { return function () { this.month = (s.length === 3) ? "jan feb mar apr may jun jul aug sep oct nov dec".indexOf(s)/4 : Number(s) - 1; if (this.month < 0) { throw "invalid month"; } }; }, year: function (s) { return function () { var n = Number(s); this.year = ((s.length > 2) ? n : (n + (((n + 2000) < Date.CultureInfo.twoDigitYearMax) ? 2000 : 1900))); }; }, rday: function (s) { return function () { switch (s) { case "yesterday": this.days = -1; break; case "tomorrow": this.days = 1; break; case "today": this.days = 0; break; case "now": this.days = 0; this.now = true; break; } }; }, finishExact: function (x) { var d; x = (x instanceof Array) ? x : [x]; for (var i = 0 ; i < x.length ; i++) { if (x[i]) { x[i].call(this); } } setDefaults.call(this); parseMeridian.call(this); if (this.day > $D.getDaysInMonth(this.year, this.month)) { throw new RangeError(this.day + " is not a valid value for days."); } d = new Date(this.year, this.month, this.day, this.hour, this.minute, this.second, this.millisecond); if (this.year < 100) { d.setFullYear(this.year); // means years less that 100 are process correctly. JS will parse it otherwise as 1900-1999. } if (this.timezone) { d.set({ timezone: this.timezone }); } else if (this.timezoneOffset) { d.set({ timezoneOffset: this.timezoneOffset }); } return d; }, finish: function (x) { var today, expression, orient, temp; x = (x instanceof Array) ? flattenAndCompact(x) : [ x ]; if (x.length === 0) { return null; } for (var i = 0 ; i < x.length ; i++) { if (typeof x[i] === "function") { x[i].call(this); } } if (this.now && !this.unit && !this.operator) { return new Date(); } else { today = finishUtils.getToday.call(this); } expression = !!(this.days && this.days !== null || this.orient || this.operator); orient = ((this.orient === "past" || this.operator === "subtract") ? -1 : 1); if (this.month && this.unit === "week") { this.value = this.month + 1; delete this.month; delete this.day; } if ((this.month || this.month === 0) && "year day hour minute second".indexOf(this.unit) !== -1) { if (!this.value) { this.value = this.month + 1; } this.month = null; expression = true; } if (!expression && this.weekday && !this.day && !this.days) { finishUtils.setDMYFromWeekday.call(this); } if (expression && this.weekday && this.unit !== "month" && this.unit !== "week") { finishUtils.setDaysFromWeekday.call(this, today, orient); } if (this.weekday && this.unit !== "week" && !this.day && !this.days) { temp = Date[this.weekday](); this.day = temp.getDate(); if (temp.getMonth() !== today.getMonth()) { this.month = temp.getMonth(); } } if (this.month && this.unit === "day" && this.operator) { if (!this.value) { this.value = (this.month + 1); } this.month = null; } if (this.value != null && this.month != null && this.year != null) { this.day = this.value * 1; } if (this.month && !this.day && this.value) { today.set({ day: this.value * 1 }); if (!expression) { this.day = this.value * 1; } } if (!this.month && this.value && this.unit === "month" && !this.now) { this.month = this.value; expression = true; } if (expression && (this.month || this.month === 0) && this.unit !== "year") { finishUtils.setMonthsFromMonth.call(this, today, orient); } if (!this.unit) { this.unit = "day"; } finishUtils.setUnitValue.call(this, orient); parseMeridian.call(this); if ((this.month || this.month === 0) && !this.day) { this.day = 1; } if (!this.orient && !this.operator && this.unit === "week" && this.value && !this.day && !this.month) { return Date.today().setWeek(this.value); } if (this.unit === "week" && this.weeks && !this.day && !this.month) { return finishUtils.generateDateFromWeeks.call(this); } if (expression && this.timezone && this.day && this.days) { this.day = this.days; } if (expression){ today.add(this); } else { today.set(this); } if (this.timezone) { this.timezone = this.timezone.toUpperCase(); var offset = $D.getTimezoneOffset(this.timezone); var timezone; if (today.hasDaylightSavingTime()) { // lets check that we're being sane with timezone setting timezone = $D.getTimezoneAbbreviation(offset, today.isDaylightSavingTime()); if (timezone !== this.timezone) { // bugger, we're in a place where things like EST vs EDT matters. if (today.isDaylightSavingTime()) { today.addHours(-1); } else { today.addHours(1); } } } today.setTimezoneOffset(offset); } return today; } }; }()); (function () { var $D = Date; $D.Grammar = {}; var _ = $D.Parsing.Operators, g = $D.Grammar, t = $D.Translator, _fn; // Allow rolling up into general purpose rules _fn = function () { return _.each(_.any.apply(null, arguments), _.not(g.ctoken2("timeContext"))); }; g.datePartDelimiter = _.rtoken(/^([\s\-\.\,\/\x27]+)/); g.timePartDelimiter = _.stoken(":"); g.whiteSpace = _.rtoken(/^\s*/); g.generalDelimiter = _.rtoken(/^(([\s\,]|at|@|on)+)/); var _C = {}; g.ctoken = function (keys) { var fn = _C[keys]; if (! fn) { var c = Date.CultureInfo.regexPatterns; var kx = keys.split(/\s+/), px = []; for (var i = 0; i < kx.length ; i++) { px.push(_.replace(_.rtoken(c[kx[i]]), kx[i])); } fn = _C[keys] = _.any.apply(null, px); } return fn; }; g.ctoken2 = function (key) { return _.rtoken(Date.CultureInfo.regexPatterns[key]); }; var cacheProcessRtoken = function (key, token, type, eachToken) { if (eachToken) { g[key] = _.cache(_.process(_.each(_.rtoken(token),_.optional(g.ctoken2(eachToken))), type)); } else { g[key] = _.cache(_.process(_.rtoken(token), type)); } }; var cacheProcessCtoken = function (token, type) { return _.cache(_.process(g.ctoken2(token), type)); }; var _F = {}; //function cache var _get = function (f) { _F[f] = (_F[f] || g.format(f)[0]); return _F[f]; }; g.allformats = function (fx) { var rx = []; if (fx instanceof Array) { for (var i = 0; i < fx.length; i++) { rx.push(_get(fx[i])); } } else { rx.push(_get(fx)); } return rx; }; g.formats = function (fx) { if (fx instanceof Array) { var rx = []; for (var i = 0 ; i < fx.length ; i++) { rx.push(_get(fx[i])); } return _.any.apply(null, rx); } else { return _get(fx); } }; var grammarFormats = { timeFormats: function(){ var i, RTokenKeys = [ "h", "hh", "H", "HH", "m", "mm", "s", "ss", "ss.s", "z", "zz" ], RToken = [ /^(0[0-9]|1[0-2]|[1-9])/, /^(0[0-9]|1[0-2])/, /^([0-1][0-9]|2[0-3]|[0-9])/, /^([0-1][0-9]|2[0-3])/, /^([0-5][0-9]|[0-9])/, /^[0-5][0-9]/, /^([0-5][0-9]|[0-9])/, /^[0-5][0-9]/, /^[0-5][0-9]\.[0-9]{1,3}/, /^((\+|\-)\s*\d\d\d\d)|((\+|\-)\d\d\:?\d\d)/, /^((\+|\-)\s*\d\d\d\d)|((\+|\-)\d\d\:?\d\d)/ ], tokens = [ t.hour, t.hour, t.hour, t.hour, t.minute, t.minute, t.second, t.second, t.secondAndMillisecond, t.timezone, t.timezone ]; for (i=0; i < RTokenKeys.length; i++) { cacheProcessRtoken(RTokenKeys[i], RToken[i], tokens[i]); } g.hms = _.cache(_.sequence([g.H, g.m, g.s], g.timePartDelimiter)); g.t = cacheProcessCtoken("shortMeridian", t.meridian); g.tt = cacheProcessCtoken("longMeridian", t.meridian); g.zzz = cacheProcessCtoken("timezone", t.timezone); g.timeSuffix = _.each(_.ignore(g.whiteSpace), _.set([ g.tt, g.zzz ])); g.time = _.each(_.optional(_.ignore(_.stoken("T"))), g.hms, g.timeSuffix); }, dateFormats: function () { // pre-loaded rules for different date part order preferences var _setfn = function () { return _.set(arguments, g.datePartDelimiter); }; var i, RTokenKeys = [ "d", "dd", "M", "MM", "y", "yy", "yyy", "yyyy" ], RToken = [ /^([0-2]\d|3[0-1]|\d)/, /^([0-2]\d|3[0-1])/, /^(1[0-2]|0\d|\d)/, /^(1[0-2]|0\d)/, /^(\d+)/, /^(\d\d)/, /^(\d\d?\d?\d?)/, /^(\d\d\d\d)/ ], tokens = [ t.day, t.day, t.month, t.month, t.year, t.year, t.year, t.year ], eachToken = [ "ordinalSuffix", "ordinalSuffix" ]; for (i=0; i < RTokenKeys.length; i++) { cacheProcessRtoken(RTokenKeys[i], RToken[i], tokens[i], eachToken[i]); } g.MMM = g.MMMM = _.cache(_.process(g.ctoken("jan feb mar apr may jun jul aug sep oct nov dec"), t.month)); g.ddd = g.dddd = _.cache(_.process(g.ctoken("sun mon tue wed thu fri sat"), function (s) { return function () { this.weekday = s; }; } )); g.day = _fn(g.d, g.dd); g.month = _fn(g.M, g.MMM); g.year = _fn(g.yyyy, g.yy); g.mdy = _setfn(g.ddd, g.month, g.day, g.year); g.ymd = _setfn(g.ddd, g.year, g.month, g.day); g.dmy = _setfn(g.ddd, g.day, g.month, g.year); g.date = function (s) { return ((g[Date.CultureInfo.dateElementOrder] || g.mdy).call(this, s)); }; }, relative: function () { // relative date / time expressions g.orientation = _.process(g.ctoken("past future"), function (s) { return function () { this.orient = s; }; } ); g.operator = _.process(g.ctoken("add subtract"), function (s) { return function () { this.operator = s; }; } ); g.rday = _.process(g.ctoken("yesterday tomorrow today now"), t.rday); g.unit = _.process(g.ctoken("second minute hour day week month year"), function (s) { return function () { this.unit = s; }; } ); } }; g.buildGrammarFormats = function () { // these need to be rebuilt every time the language changes. _C = {}; grammarFormats.timeFormats(); grammarFormats.dateFormats(); grammarFormats.relative(); g.value = _.process(_.rtoken(/^([-+]?\d+)?(st|nd|rd|th)?/), function (s) { return function () { this.value = s.replace(/\D/g, ""); }; } ); g.expression = _.set([g.rday, g.operator, g.value, g.unit, g.orientation, g.ddd, g.MMM ]); g.format = _.process(_.many( _.any( // translate format specifiers into grammar rules _.process( _.rtoken(/^(dd?d?d?(?!e)|MM?M?M?|yy?y?y?|hh?|HH?|mm?|ss?|tt?|zz?z?)/), function (fmt) { if (g[fmt]) { return g[fmt]; } else { throw $D.Parsing.Exception(fmt); } } ), // translate separator tokens into token rules _.process(_.rtoken(/^[^dMyhHmstz]+/), // all legal separators function (s) { return _.ignore(_.stoken(s)); } ) ) ), // construct the parser ... function (rules) { return _.process(_.each.apply(null, rules), t.finishExact); } ); // starting rule for general purpose grammar g._start = _.process(_.set([ g.date, g.time, g.expression ], g.generalDelimiter, g.whiteSpace), t.finish); }; g.buildGrammarFormats(); // parsing date format specifiers - ex: "h:m:s tt" // this little guy will generate a custom parser based // on the format string, ex: g.format("h:m:s tt") // check for these formats first g._formats = g.formats([ "\"yyyy-MM-ddTHH:mm:ssZ\"", "yyyy-MM-ddTHH:mm:ss.sz", "yyyy-MM-ddTHH:mm:ssZ", "yyyy-MM-ddTHH:mm:ssz", "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-ddTHH:mmZ", "yyyy-MM-ddTHH:mmz", "yyyy-MM-ddTHH:mm", "ddd, MMM dd, yyyy H:mm:ss tt", "ddd MMM d yyyy HH:mm:ss zzz", "MMddyyyy", "ddMMyyyy", "Mddyyyy", "ddMyyyy", "Mdyyyy", "dMyyyy", "yyyy", "Mdyy", "dMyy", "d" ]); // real starting rule: tries selected formats first, // then general purpose rule g.start = function (s) { try { var r = g._formats.call({}, s); if (r[1].length === 0) { return r; } } catch (e) {} return g._start.call({}, s); }; }()); (function () { var $D = Date; /** * @desc Converts the specified string value into its JavaScript Date equivalent using CultureInfo specific format information. * * Example

	///////////
	// Dates //
	///////////

	// 15-Oct-2004
	var d1 = Date.parse("10/15/2004");

	// 15-Oct-2004
	var d1 = Date.parse("15-Oct-2004");

	// 15-Oct-2004
	var d1 = Date.parse("2004.10.15");

	//Fri Oct 15, 2004
	var d1 = Date.parse("Fri Oct 15, 2004");

	///////////
	// Times //
	///////////

	// Today at 10 PM.
	var d1 = Date.parse("10 PM");

	// Today at 10:30 PM.
	var d1 = Date.parse("10:30 P.M.");

	// Today at 6 AM.
	var d1 = Date.parse("06am");

	/////////////////////
	// Dates and Times //
	/////////////////////

	// 8-July-2004 @ 10:30 PM
	var d1 = Date.parse("July 8th, 2004, 10:30 PM");

	// 1-July-2004 @ 10:30 PM
	var d1 = Date.parse("2004-07-01T22:30:00");

	////////////////////
	// Relative Dates //
	////////////////////

	// Returns today's date. The string "today" is culture specific.
	var d1 = Date.parse("today");

	// Returns yesterday's date. The string "yesterday" is culture specific.
	var d1 = Date.parse("yesterday");

	// Returns the date of the next thursday.
	var d1 = Date.parse("Next thursday");

	// Returns the date of the most previous monday.
	var d1 = Date.parse("last monday");

	// Returns today's day + one year.
	var d1 = Date.parse("next year");

	///////////////
	// Date Math //
	///////////////

	// Today + 2 days
	var d1 = Date.parse("t+2");

	// Today + 2 days
	var d1 = Date.parse("today + 2 days");

	// Today + 3 months
	var d1 = Date.parse("t+3m");

	// Today - 1 year
	var d1 = Date.parse("today - 1 year");

	// Today - 1 year
	var d1 = Date.parse("t-1y"); 


	/////////////////////////////
	// Partial Dates and Times //
	/////////////////////////////

	// July 15th of this year.
	var d1 = Date.parse("July 15");

	// 15th day of current day and year.
	var d1 = Date.parse("15");

	// July 1st of current year at 10pm.
	var d1 = Date.parse("7/1 10pm");
	
* * @param {String} The string value to convert into a Date object [Required] * @return {Date} A Date object or null if the string cannot be converted into a Date. */ var parseUtils = { removeOrds: function (s) { ords = s.match(/\b(\d+)(?:st|nd|rd|th)\b/); // find ordinal matches s = ((ords && ords.length === 2) ? s.replace(ords[0], ords[1]) : s); return s; }, grammarParser: function (s) { var r = null; try { r = $D.Grammar.start.call({}, s.replace(/^\s*(\S*(\s+\S+)*)\s*$/, "$1")); } catch (e) { return null; } return ((r[1].length === 0) ? r[0] : null); }, nativeFallback: function(s) { var t; try { // ok we haven't parsed it, last ditch attempt with the built-in parser. t = Date._parse(s); return (t || t === 0) ? new Date(t) : null; } catch (e) { return null; } } }; function parse (s) { var d; if (!s) { return null; } if (s instanceof Date) { return s.clone(); } if (s.length >= 4 && s.charAt(0) !== "0" && s.charAt(0) !== "+"&& s.charAt(0) !== "-") { // ie: 2004 will pass, 0800 won't. // Start with specific formats d = $D.Parsing.ISO.parse(s) || $D.Parsing.Numeric.parse(s); } if (d instanceof Date && !isNaN(d.getTime())) { return d; } else { // find ordinal dates (1st, 3rd, 8th, etc and remove them as they cause parsing issues) s = $D.Parsing.Normalizer.parse(parseUtils.removeOrds(s)); d = parseUtils.grammarParser(s); if (d !== null) { return d; } else { return parseUtils.nativeFallback(s); } } } if (!$D._parse) { $D._parse = $D.parse; } $D.parse = parse; Date.getParseFunction = function (fx) { var fns = Date.Grammar.allformats(fx); return function (s) { var r = null; for (var i = 0; i < fns.length; i++) { try { r = fns[i].call({}, s); } catch (e) { continue; } if (r[1].length === 0) { return r[0]; } } return null; }; }; /** * Converts the specified string value into its JavaScript Date equivalent using the specified format {String} or formats {Array} and the CultureInfo specific format information. * The format of the string value must match one of the supplied formats exactly. * * Example

	// 15-Oct-2004
	var d1 = Date.parseExact("10/15/2004", "M/d/yyyy");

	// 15-Oct-2004
	var d1 = Date.parse("15-Oct-2004", "M-ddd-yyyy");

	// 15-Oct-2004
	var d1 = Date.parse("2004.10.15", "yyyy.MM.dd");

	// Multiple formats
	var d1 = Date.parseExact("10/15/2004", ["M/d/yyyy", "MMMM d, yyyy"]);
	
* * @param {String} The string value to convert into a Date object [Required]. * @param {Object} The expected format {String} or an array of expected formats {Array} of the date string [Required]. * @return {Date} A Date object or null if the string cannot be converted into a Date. */ $D.parseExact = function (s, fx) { return $D.getParseFunction(fx)(s); }; }()); (function () { var $D = Date, $P = $D.prototype, // $C = $D.CultureInfo, // not used atm p = function (s, l) { if (!l) { l = 2; } return ("000" + s).slice(l * -1); }; /** * Converts a PHP format string to Java/.NET format string. * A PHP format string can be used with ._format or .format. * A Java/.NET format string can be used with .toString(). * The .parseExact function will only accept a Java/.NET format string * * Example * var f1 = "%m/%d/%y" * var f2 = Date.normalizeFormat(f1); // "MM/dd/yy" * * new Date().format(f1); // "04/13/08" * new Date()._format(f1); // "04/13/08" * new Date().toString(f2); // "04/13/08" * * var date = Date.parseExact("04/13/08", f2); // Sun Apr 13 2008 * * @param {String} A PHP format string consisting of one or more format spcifiers. * @return {String} The PHP format converted to a Java/.NET format string. */ var normalizerSubstitutions = { "d" : "dd", "%d": "dd", "D" : "ddd", "%a": "ddd", "j" : "dddd", "l" : "dddd", "%A": "dddd", "S" : "S", "F" : "MMMM", "%B": "MMMM", "m" : "MM", "%m": "MM", "M" : "MMM", "%b": "MMM", "%h": "MMM", "n" : "M", "Y" : "yyyy", "%Y": "yyyy", "y" : "yy", "%y": "yy", "g" : "h", "%I": "h", "G" : "H", "h" : "hh", "H" : "HH", "%H": "HH", "i" : "mm", "%M": "mm", "s" : "ss", "%S": "ss", "%r": "hh:mm tt", "%R": "H:mm", "%T": "H:mm:ss", "%X": "t", "%x": "d", "%e": "d", "%D": "MM/dd/yy", "%n": "\\n", "%t": "\\t", "e" : "z", "T" : "z", "%z": "z", "%Z": "z", "Z" : "ZZ", "N" : "u", "w" : "u", "%w": "u", "W" : "W", "%V": "W" }; var normalizer = { substitutes: function (m) { return normalizerSubstitutions[m]; }, interpreted: function (m, x) { var y; switch (m) { case "%u": return x.getDay() + 1; case "z": return x.getOrdinalNumber(); case "%j": return p(x.getOrdinalNumber(), 3); case "%U": var d1 = x.clone().set({month: 0, day: 1}).addDays(-1).moveToDayOfWeek(0), d2 = x.clone().addDays(1).moveToDayOfWeek(0, -1); return (d2 < d1) ? "00" : p((d2.getOrdinalNumber() - d1.getOrdinalNumber()) / 7 + 1); case "%W": return p(x.getWeek()); case "t": return $D.getDaysInMonth(x.getFullYear(), x.getMonth()); case "o": case "%G": return x.setWeek(x.getISOWeek()).toString("yyyy"); case "%g": return x._format("%G").slice(-2); case "a": case "%p": return t("tt").toLowerCase(); case "A": return t("tt").toUpperCase(); case "u": return p(x.getMilliseconds(), 3); case "I": return (x.isDaylightSavingTime()) ? 1 : 0; case "O": return x.getUTCOffset(); case "P": y = x.getUTCOffset(); return y.substring(0, y.length - 2) + ":" + y.substring(y.length - 2); case "B": var now = new Date(); return Math.floor(((now.getHours() * 3600) + (now.getMinutes() * 60) + now.getSeconds() + (now.getTimezoneOffset() + 60) * 60) / 86.4); case "c": return x.toISOString().replace(/\"/g, ""); case "U": return $D.strtotime("now"); case "%c": return t("d") + " " + t("t"); case "%C": return Math.floor(x.getFullYear() / 100 + 1); } }, shouldOverrideDefaults: function (m) { switch (m) { case "%e": return true; default: return false; } }, parse: function (m, context) { var formatString, c = context || new Date(); formatString = normalizer.substitutes(m); if (formatString) { return formatString; } formatString = normalizer.interpreted(m, c); if (formatString) { return formatString; } else { return m; } } }; $D.normalizeFormat = function (format, context) { return format.replace(/(%|\\)?.|%%/g, function(t){ return normalizer.parse(t, context); }); }; /** * Format a local Unix timestamp according to locale settings * * Example: * Date.strftime("%m/%d/%y", new Date()); // "04/13/08" * Date.strftime("c", "2008-04-13T17:52:03Z"); // "04/13/08" * * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @param {Number|String} The number representing the number of seconds that have elapsed since January 1, 1970 (local time). * @return {String} A string representation of the current Date object. */ $D.strftime = function (format, time) { var d = Date.parse(time); return d._format(format); }; /** * Parse any textual datetime description into a Unix timestamp. * A Unix timestamp is the number of seconds that have elapsed since January 1, 1970 (midnight UTC/GMT). * * Example: * Date.strtotime("04/13/08"); // 1208044800 * Date.strtotime("1970-01-01T00:00:00Z"); // 0 * * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @param {Object} A string or date object. * @return {String} A string representation of the current Date object. */ $D.strtotime = function (time) { var d = $D.parse(time); return Math.round($D.UTC(d.getUTCFullYear(), d.getUTCMonth(), d.getUTCDate(), d.getUTCHours(), d.getUTCMinutes(), d.getUTCSeconds(), d.getUTCMilliseconds()) / 1000); }; /** * Converts the value of the current Date object to its equivalent string representation using a PHP/Unix style of date format specifiers. * Format Specifiers * Format Description Example * ------ --------------------------------------------------------------------------- ----------------------- * %a abbreviated weekday name according to the current localed "Mon" through "Sun" * %A full weekday name according to the current localed "Sunday" through "Saturday" * %b abbreviated month name according to the current localed "Jan" through "Dec" * %B full month name according to the current locale "January" through "December" * %c preferred date and time representation for the current locale "4/13/2008 12:33 PM" * %C century number (the year divided by 100 and truncated to an integer) "00" to "99" * %d day of the month as a decimal number "01" to "31" * %D same as %m/%d/%y "04/13/08" * %e day of the month as a decimal number, a single digit is preceded by a space "1" to "31" * %g like %G, but without the century "08" * %G The 4-digit year corresponding to the ISO week number (see %V). "2008" * This has the same format and value as %Y, except that if the ISO week number * belongs to the previous or next year, that year is used instead. * %h same as %b "Jan" through "Dec" * %H hour as a decimal number using a 24-hour clock. "00" to "23" * %I hour as a decimal number using a 12-hour clock. "01" to "12" * %j day of the year as a decimal number. "001" to "366" * %m month as a decimal number. "01" to "12" * %M minute as a decimal number. "00" to "59" * %n newline character "\n" * %p either "am" or "pm" according to the given time value, or the "am" or "pm" * corresponding strings for the current locale. * %r time in a.m. and p.m. notation "8:44 PM" * %R time in 24 hour notation "20:44" * %S second as a decimal number "00" to "59" * %t tab character "\t" * %T current time, equal to %H:%M:%S "12:49:11" * %u weekday as a decimal number ["1", "7"], with "1" representing Monday "1" to "7" * %U week number of the current year as a decimal number, starting with the "0" to ("52" or "53") * first Sunday as the first day of the first week * %V The ISO 8601:1988 week number of the current year as a decimal number, "00" to ("52" or "53") * range 01 to 53, where week 1 is the first week that has at least 4 days * in the current year, and with Monday as the first day of the week. * (Use %G or %g for the year component that corresponds to the week number * for the specified timestamp.) * %W week number of the current year as a decimal number, starting with the "00" to ("52" or "53") * first Monday as the first day of the first week * %w day of the week as a decimal, Sunday being "0" "0" to "6" * %x preferred date representation for the current locale without the time "4/13/2008" * %X preferred time representation for the current locale without the date "12:53:05" * %y year as a decimal number without a century "00" "99" * %Y year as a decimal number including the century "2008" * %Z time zone or name or abbreviation "UTC", "EST", "PST" * %z same as %Z * %% a literal "%" characters "%" * d Day of the month, 2 digits with leading zeros "01" to "31" * D A textual representation of a day, three letters "Mon" through "Sun" * j Day of the month without leading zeros "1" to "31" * l A full textual representation of the day of the week (lowercase "L") "Sunday" through "Saturday" * N ISO-8601 numeric representation of the day of the week (added in PHP 5.1.0) "1" (for Monday) through "7" (for Sunday) * S English ordinal suffix for the day of the month, 2 characters "st", "nd", "rd" or "th". Works well with j * w Numeric representation of the day of the week "0" (for Sunday) through "6" (for Saturday) * z The day of the year (starting from "0") "0" through "365" * W ISO-8601 week number of year, weeks starting on Monday "00" to ("52" or "53") * F A full textual representation of a month, such as January or March "January" through "December" * m Numeric representation of a month, with leading zeros "01" through "12" * M A short textual representation of a month, three letters "Jan" through "Dec" * n Numeric representation of a month, without leading zeros "1" through "12" * t Number of days in the given month "28" through "31" * L Whether it's a leap year "1" if it is a leap year, "0" otherwise * o ISO-8601 year number. This has the same value as Y, except that if the "2008" * ISO week number (W) belongs to the previous or next year, that year * is used instead. * Y A full numeric representation of a year, 4 digits "2008" * y A two digit representation of a year "08" * a Lowercase Ante meridiem and Post meridiem "am" or "pm" * A Uppercase Ante meridiem and Post meridiem "AM" or "PM" * B Swatch Internet time "000" through "999" * g 12-hour format of an hour without leading zeros "1" through "12" * G 24-hour format of an hour without leading zeros "0" through "23" * h 12-hour format of an hour with leading zeros "01" through "12" * H 24-hour format of an hour with leading zeros "00" through "23" * i Minutes with leading zeros "00" to "59" * s Seconds, with leading zeros "00" through "59" * u Milliseconds "54321" * e Timezone identifier "UTC", "EST", "PST" * I Whether or not the date is in daylight saving time (uppercase i) "1" if Daylight Saving Time, "0" otherwise * O Difference to Greenwich time (GMT) in hours "+0200", "-0600" * P Difference to Greenwich time (GMT) with colon between hours and minutes "+02:00", "-06:00" * T Timezone abbreviation "UTC", "EST", "PST" * Z Timezone offset in seconds. The offset for timezones west of UTC is "-43200" through "50400" * always negative, and for those east of UTC is always positive. * c ISO 8601 date "2004-02-12T15:19:21+00:00" * r RFC 2822 formatted date "Thu, 21 Dec 2000 16:01:07 +0200" * U Seconds since the Unix Epoch (January 1 1970 00:00:00 GMT) "0" * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @return {String} A string representation of the current Date object. */ var formatReplace = function (context) { return function (m) { var formatString, override = false; if (m.charAt(0) === "\\" || m.substring(0, 2) === "%%") { return m.replace("\\", "").replace("%%", "%"); } override = normalizer.shouldOverrideDefaults(m); formatString = $D.normalizeFormat(m, context); if (formatString) { return context.toString(formatString, override); } }; }; $P._format = function (format) { var formatter = formatReplace(this); if (!format) { return this._toString(); } else { return format.replace(/(%|\\)?.|%%/g, formatter); } }; if (!$P.format) { $P.format = $P._format; } }()); (function () { "use strict"; var gFn = function (attr) { return function () { return this[attr]; }; }; var sFn = function (attr) { return function (val) { this[attr] = val; return this; }; }; var attrs = ["years", "months", "days", "hours", "minutes", "seconds", "milliseconds"]; var addSetFuncs = function (context, attrs) { for (var i = 0; i < attrs.length ; i++) { var $a = attrs[i], $b = $a.slice(0, 1).toUpperCase() + $a.slice(1); context.prototype[$a] = 0; context.prototype["get" + $b] = gFn($a); context.prototype["set" + $b] = sFn($a); } }; /** * new TimeSpan(milliseconds); * new TimeSpan(days, hours, minutes, seconds); * new TimeSpan(days, hours, minutes, seconds, milliseconds); */ var TimeSpan = function (days, hours, minutes, seconds, milliseconds) { if (arguments.length === 1 && typeof days === "number") { var orient = (days < 0) ? -1 : +1; var millsLeft = Math.abs(days); this.setDays(Math.floor(millsLeft / 86400000) * orient); millsLeft = millsLeft % 86400000; this.setHours(Math.floor(millsLeft / 3600000) * orient); millsLeft = millsLeft % 3600000; this.setMinutes(Math.floor(millsLeft / 60000) * orient); millsLeft = millsLeft % 60000; this.setSeconds(Math.floor(millsLeft / 1000) * orient); millsLeft = millsLeft % 1000; this.setMilliseconds(millsLeft * orient); } else { this.set(days, hours, minutes, seconds, milliseconds); } this.getTotalMilliseconds = function () { return (this.getDays() * 86400000) + (this.getHours() * 3600000) + (this.getMinutes() * 60000) + (this.getSeconds() * 1000); }; this.compareTo = function (time) { var t1 = new Date(1970, 1, 1, this.getHours(), this.getMinutes(), this.getSeconds()), t2; if (time === null) { t2 = new Date(1970, 1, 1, 0, 0, 0); } else { t2 = new Date(1970, 1, 1, time.getHours(), time.getMinutes(), time.getSeconds()); } return (t1 < t2) ? -1 : (t1 > t2) ? 1 : 0; }; this.equals = function (time) { return (this.compareTo(time) === 0); }; this.add = function (time) { return (time === null) ? this : this.addSeconds(time.getTotalMilliseconds() / 1000); }; this.subtract = function (time) { return (time === null) ? this : this.addSeconds(-time.getTotalMilliseconds() / 1000); }; this.addDays = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 86400000)); }; this.addHours = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 3600000)); }; this.addMinutes = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 60000)); }; this.addSeconds = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 1000)); }; this.addMilliseconds = function (n) { return new TimeSpan(this.getTotalMilliseconds() + n); }; this.get12HourHour = function () { return (this.getHours() > 12) ? this.getHours() - 12 : (this.getHours() === 0) ? 12 : this.getHours(); }; this.getDesignator = function () { return (this.getHours() < 12) ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator; }; this.toString = function (format) { this._toString = function () { if (this.getDays() !== null && this.getDays() > 0) { return this.getDays() + "." + this.getHours() + ":" + this.p(this.getMinutes()) + ":" + this.p(this.getSeconds()); } else { return this.getHours() + ":" + this.p(this.getMinutes()) + ":" + this.p(this.getSeconds()); } }; this.p = function (s) { return (s.toString().length < 2) ? "0" + s : s; }; var me = this; return format ? format.replace(/dd?|HH?|hh?|mm?|ss?|tt?/g, function (format) { switch (format) { case "d": return me.getDays(); case "dd": return me.p(me.getDays()); case "H": return me.getHours(); case "HH": return me.p(me.getHours()); case "h": return me.get12HourHour(); case "hh": return me.p(me.get12HourHour()); case "m": return me.getMinutes(); case "mm": return me.p(me.getMinutes()); case "s": return me.getSeconds(); case "ss": return me.p(me.getSeconds()); case "t": return ((me.getHours() < 12) ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator).substring(0, 1); case "tt": return (me.getHours() < 12) ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator; } } ) : this._toString(); }; return this; }; addSetFuncs(TimeSpan, attrs.slice(2)); TimeSpan.prototype.set = function (days, hours, minutes, seconds, milliseconds){ this.setDays(days || this.getDays()); this.setHours(hours || this.getHours()); this.setMinutes(minutes || this.getMinutes()); this.setSeconds(seconds || this.getSeconds()); this.setMilliseconds(milliseconds || this.getMilliseconds()); }; /** * Gets the time of day for this date instances. * @return {TimeSpan} TimeSpan */ Date.prototype.getTimeOfDay = function () { return new TimeSpan(0, this.getHours(), this.getMinutes(), this.getSeconds(), this.getMilliseconds()); }; Date.TimeSpan = TimeSpan; if (typeof window !== "undefined" ) { // keeping API compatible for v1.x window.TimeSpan = TimeSpan; } }()); (function () { "use strict"; var attrs = ["years", "months", "days", "hours", "minutes", "seconds", "milliseconds"]; var gFn = function (attr) { return function () { return this[attr]; }; }; var sFn = function (attr) { return function (val) { this[attr] = val; return this; }; }; var addSetFuncs = function (context, attrs) { for (var i = 0; i < attrs.length ; i++) { var $a = attrs[i], $b = $a.slice(0, 1).toUpperCase() + $a.slice(1); context.prototype[$a] = 0; context.prototype["get" + $b] = gFn($a); context.prototype["set" + $b] = sFn($a); } }; var setMonthsAndYears = function (orient, d1, d2, context) { function inc() { d1.addMonths(-orient); context.months++; if (context.months === 12) { context.years++; context.months = 0; } } if (orient === +1) { while (d1 > d2) { inc(); } } else { while (d1 < d2) { inc(); } } context.months--; context.months *= orient; context.years *= orient; }; var adjustForDST = function(orient, startDate, endDate) { var hasDSTMismatch = (false === (startDate.isDaylightSavingTime() === endDate.isDaylightSavingTime())); if (hasDSTMismatch && orient === 1) { startDate.addHours(-1); } else if (hasDSTMismatch) { startDate.addHours(1); } }; /** * TimePeriod(startDate, endDate); * TimePeriod(years, months, days, hours, minutes, seconds, milliseconds); */ var TimePeriod = function (years, months, days, hours, minutes, seconds, milliseconds) { if (arguments.length === 7) { this.set(years, months, days, hours, minutes, seconds, milliseconds); } else if (arguments.length === 2 && arguments[0] instanceof Date && arguments[1] instanceof Date) { var startDate = arguments[0].clone(); var endDate = arguments[1].clone(); var orient = (startDate > endDate) ? +1 : -1; this.dates = { start: arguments[0].clone(), end: arguments[1].clone() }; setMonthsAndYears(orient, startDate, endDate, this); adjustForDST(orient, startDate, endDate); // // TODO - adjust for DST var diff = endDate - startDate; if (diff !== 0) { var ts = new TimeSpan(diff); this.set(this.years, this.months, ts.getDays(), ts.getHours(), ts.getMinutes(), ts.getSeconds(), ts.getMilliseconds()); } } return this; }; // create all the set functions. addSetFuncs(TimePeriod, attrs); TimePeriod.prototype.set = function (years, months, days, hours, minutes, seconds, milliseconds){ this.setYears(years || this.getYears()); this.setMonths(months || this.getMonths()); this.setDays(days || this.getDays()); this.setHours(hours || this.getHours()); this.setMinutes(minutes || this.getMinutes()); this.setSeconds(seconds || this.getSeconds()); this.setMilliseconds(milliseconds || this.getMilliseconds()); }; Date.TimePeriod = TimePeriod; if (typeof window !== "undefined") { // keeping API compatible for v1.x window.TimePeriod = TimePeriod; } }()); ================================================ FILE: build/date-en-JM.js ================================================ /** * @overview datejs * @version 1.0.0-rc3 * @author Gregory Wild-Smith * @copyright 2015 Gregory Wild-Smith * @license MIT * @homepage https://github.com/abritinthebay/datejs */ /* * DateJS Culture String File * Country Code: en-JM * Name: English (Jamaica) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["en-JM"] = { "name": "en-JM", "englishName": "English (Jamaica)", "nativeName": "English (Jamaica)", "Sunday": "Sunday", "Monday": "Monday", "Tuesday": "Tuesday", "Wednesday": "Wednesday", "Thursday": "Thursday", "Friday": "Friday", "Saturday": "Saturday", "Sun": "Sun", "Mon": "Mon", "Tue": "Tue", "Wed": "Wed", "Thu": "Thu", "Fri": "Fri", "Sat": "Sat", "Su": "Su", "Mo": "Mo", "Tu": "Tu", "We": "We", "Th": "Th", "Fr": "Fr", "Sa": "Sa", "S_Sun_Initial": "S", "M_Mon_Initial": "M", "T_Tue_Initial": "T", "W_Wed_Initial": "W", "T_Thu_Initial": "T", "F_Fri_Initial": "F", "S_Sat_Initial": "S", "January": "January", "February": "February", "March": "March", "April": "April", "May": "May", "June": "June", "July": "July", "August": "August", "September": "September", "October": "October", "November": "November", "December": "December", "Jan_Abbr": "Jan", "Feb_Abbr": "Feb", "Mar_Abbr": "Mar", "Apr_Abbr": "Apr", "May_Abbr": "May", "Jun_Abbr": "Jun", "Jul_Abbr": "Jul", "Aug_Abbr": "Aug", "Sep_Abbr": "Sep", "Oct_Abbr": "Oct", "Nov_Abbr": "Nov", "Dec_Abbr": "Dec", "AM": "AM", "PM": "PM", "firstDayOfWeek": 0, "twoDigitYearMax": 2029, "mdy": "dmy", "M/d/yyyy": "dd/MM/yyyy", "dddd, MMMM dd, yyyy": "dddd, MMMM dd, yyyy", "h:mm tt": "hh:mm tt", "h:mm:ss tt": "hh:mm:ss tt", "dddd, MMMM dd, yyyy h:mm:ss tt": "dddd, MMMM dd, yyyy hh:mm:ss tt", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "MMMM dd", "MMMM, yyyy": "MMMM, yyyy", "/jan(uary)?/": "jan(uary)?", "/feb(ruary)?/": "feb(ruary)?", "/mar(ch)?/": "mar(ch)?", "/apr(il)?/": "apr(il)?", "/may/": "may", "/jun(e)?/": "jun(e)?", "/jul(y)?/": "jul(y)?", "/aug(ust)?/": "aug(ust)?", "/sep(t(ember)?)?/": "sep(t(ember)?)?", "/oct(ober)?/": "oct(ober)?", "/nov(ember)?/": "nov(ember)?", "/dec(ember)?/": "dec(ember)?", "/^su(n(day)?)?/": "^su(n(day)?)?", "/^mo(n(day)?)?/": "^mo(n(day)?)?", "/^tu(e(s(day)?)?)?/": "^tu(e(s(day)?)?)?", "/^we(d(nesday)?)?/": "^we(d(nesday)?)?", "/^th(u(r(s(day)?)?)?)?/": "^th(u(r(s(day)?)?)?)?", "/^fr(i(day)?)?/": "^fr(i(day)?)?", "/^sa(t(urday)?)?/": "^sa(t(urday)?)?", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "en-JM"; /** * @overview datejs * @version 1.0.0-rc3 * @author Gregory Wild-Smith * @copyright 2015 Gregory Wild-Smith * @license MIT * @homepage https://github.com/abritinthebay/datejs */(function () { var $D = Date; var lang = Date.CultureStrings ? Date.CultureStrings.lang : null; var loggedKeys = {}; // for debug purposes. var getText = { getFromKey: function (key, countryCode) { var output; if (Date.CultureStrings && Date.CultureStrings[countryCode] && Date.CultureStrings[countryCode][key]) { output = Date.CultureStrings[countryCode][key]; } else { output = getText.buildFromDefault(key); } if (key.charAt(0) === "/") { // Assume it's a regex output = getText.buildFromRegex(key, countryCode); } return output; }, getFromObjectValues: function (obj, countryCode) { var key, output = {}; for(key in obj) { if (obj.hasOwnProperty(key)) { output[key] = getText.getFromKey(obj[key], countryCode); } } return output; }, getFromObjectKeys: function (obj, countryCode) { var key, output = {}; for(key in obj) { if (obj.hasOwnProperty(key)) { output[getText.getFromKey(key, countryCode)] = obj[key]; } } return output; }, getFromArray: function (arr, countryCode) { var output = []; for (var i=0; i < arr.length; i++){ if (i in arr) { output[i] = getText.getFromKey(arr[i], countryCode); } } return output; }, buildFromDefault: function (key) { var output, length, split, last; switch(key) { case "name": output = "en-US"; break; case "englishName": output = "English (United States)"; break; case "nativeName": output = "English (United States)"; break; case "twoDigitYearMax": output = 2049; break; case "firstDayOfWeek": output = 0; break; default: output = key; split = key.split("_"); length = split.length; if (length > 1 && key.charAt(0) !== "/") { // if the key isn't a regex and it has a split. last = split[(length - 1)].toLowerCase(); if (last === "initial" || last === "abbr") { output = split[0]; } } break; } return output; }, buildFromRegex: function (key, countryCode) { var output; if (Date.CultureStrings && Date.CultureStrings[countryCode] && Date.CultureStrings[countryCode][key]) { output = new RegExp(Date.CultureStrings[countryCode][key], "i"); } else { output = new RegExp(key.replace(new RegExp("/", "g"),""), "i"); } return output; } }; var shallowMerge = function (obj1, obj2) { for (var attrname in obj2) { if (obj2.hasOwnProperty(attrname)) { obj1[attrname] = obj2[attrname]; } } }; var __ = function (key, language) { var countryCode = (language) ? language : lang; loggedKeys[key] = key; if (typeof key === "object") { if (key instanceof Array) { return getText.getFromArray(key, countryCode); } else { return getText.getFromObjectKeys(key, countryCode); } } else { return getText.getFromKey(key, countryCode); } }; var loadI18nScript = function (code) { // paatterned after jQuery's getScript. var url = Date.Config.i18n + code + ".js"; var head = document.getElementsByTagName("head")[0] || document.documentElement; var script = document.createElement("script"); script.src = url; var completed = false; var events = { done: function (){} // placeholder function }; // Attach handlers for all browsers script.onload = script.onreadystatechange = function() { if ( !completed && (!this.readyState || this.readyState === "loaded" || this.readyState === "complete") ) { events.done(); head.removeChild(script); } }; setTimeout(function() { head.insertBefore(script, head.firstChild); }, 0); // allows return to execute first return { done: function (cb) { events.done = function() { if (cb) { setTimeout(cb,0); } }; } }; }; var buildInfo = { buildFromMethodHash: function (obj) { var key; for(key in obj) { if (obj.hasOwnProperty(key)) { obj[key] = buildInfo[obj[key]](); } } return obj; }, timeZoneDST: function () { var DST = { "CHADT": "+1345", "NZDT": "+1300", "AEDT": "+1100", "ACDT": "+1030", "AZST": "+0500", "IRDT": "+0430", "EEST": "+0300", "CEST": "+0200", "BST": "+0100", "PMDT": "-0200", "ADT": "-0300", "NDT": "-0230", "EDT": "-0400", "CDT": "-0500", "MDT": "-0600", "PDT": "-0700", "AKDT": "-0800", "HADT": "-0900" }; return __(DST); }, timeZoneStandard: function () { var standard = { "LINT": "+1400", "TOT": "+1300", "CHAST": "+1245", "NZST": "+1200", "NFT": "+1130", "SBT": "+1100", "AEST": "+1000", "ACST": "+0930", "JST": "+0900", "CWST": "+0845", "CT": "+0800", "ICT": "+0700", "MMT": "+0630", "BST": "+0600", "NPT": "+0545", "IST": "+0530", "PKT": "+0500", "AFT": "+0430", "MSK": "+0400", "IRST": "+0330", "FET": "+0300", "EET": "+0200", "CET": "+0100", "GMT": "+0000", "UTC": "+0000", "CVT": "-0100", "GST": "-0200", "BRT": "-0300", "NST": "-0330", "AST": "-0400", "EST": "-0500", "CST": "-0600", "MST": "-0700", "PST": "-0800", "AKST": "-0900", "MIT": "-0930", "HST": "-1000", "SST": "-1100", "BIT": "-1200" }; return __(standard); }, timeZones: function (data) { var zone; data.timezones = []; for (zone in data.abbreviatedTimeZoneStandard) { if (data.abbreviatedTimeZoneStandard.hasOwnProperty(zone)) { data.timezones.push({ name: zone, offset: data.abbreviatedTimeZoneStandard[zone]}); } } for (zone in data.abbreviatedTimeZoneDST) { if (data.abbreviatedTimeZoneDST.hasOwnProperty(zone)) { data.timezones.push({ name: zone, offset: data.abbreviatedTimeZoneDST[zone], dst: true}); } } return data.timezones; }, days: function () { return __(["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"]); }, dayAbbr: function () { return __(["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"]); }, dayShortNames: function () { return __(["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"]); }, dayFirstLetters: function () { return __(["S_Sun_Initial", "M_Mon_Initial", "T_Tues_Initial", "W_Wed_Initial", "T_Thu_Initial", "F_Fri_Initial", "S_Sat_Initial"]); }, months: function () { return __(["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"]); }, monthAbbr: function () { return __(["Jan_Abbr", "Feb_Abbr", "Mar_Abbr", "Apr_Abbr", "May_Abbr", "Jun_Abbr", "Jul_Abbr", "Aug_Abbr", "Sep_Abbr", "Oct_Abbr", "Nov_Abbr", "Dec_Abbr"]); }, formatPatterns: function () { return getText.getFromObjectValues({ shortDate: "M/d/yyyy", longDate: "dddd, MMMM dd, yyyy", shortTime: "h:mm tt", longTime: "h:mm:ss tt", fullDateTime: "dddd, MMMM dd, yyyy h:mm:ss tt", sortableDateTime: "yyyy-MM-ddTHH:mm:ss", universalSortableDateTime: "yyyy-MM-dd HH:mm:ssZ", rfc1123: "ddd, dd MMM yyyy HH:mm:ss", monthDay: "MMMM dd", yearMonth: "MMMM, yyyy" }, Date.i18n.currentLanguage()); }, regex: function () { return getText.getFromObjectValues({ inTheMorning: "/( in the )(morn(ing)?)\\b/", thisMorning: "/(this )(morn(ing)?)\\b/", amThisMorning: "/(\b\\d(am)? )(this )(morn(ing)?)/", inTheEvening: "/( in the )(even(ing)?)\\b/", thisEvening: "/(this )(even(ing)?)\\b/", pmThisEvening: "/(\b\\d(pm)? )(this )(even(ing)?)/", jan: "/jan(uary)?/", feb: "/feb(ruary)?/", mar: "/mar(ch)?/", apr: "/apr(il)?/", may: "/may/", jun: "/jun(e)?/", jul: "/jul(y)?/", aug: "/aug(ust)?/", sep: "/sep(t(ember)?)?/", oct: "/oct(ober)?/", nov: "/nov(ember)?/", dec: "/dec(ember)?/", sun: "/^su(n(day)?)?/", mon: "/^mo(n(day)?)?/", tue: "/^tu(e(s(day)?)?)?/", wed: "/^we(d(nesday)?)?/", thu: "/^th(u(r(s(day)?)?)?)?/", fri: "/fr(i(day)?)?/", sat: "/^sa(t(urday)?)?/", future: "/^next/", past: "/^last|past|prev(ious)?/", add: "/^(\\+|aft(er)?|from|hence)/", subtract: "/^(\\-|bef(ore)?|ago)/", yesterday: "/^yes(terday)?/", today: "/^t(od(ay)?)?/", tomorrow: "/^tom(orrow)?/", now: "/^n(ow)?/", millisecond: "/^ms|milli(second)?s?/", second: "/^sec(ond)?s?/", minute: "/^mn|min(ute)?s?/", hour: "/^h(our)?s?/", week: "/^w(eek)?s?/", month: "/^m(onth)?s?/", day: "/^d(ay)?s?/", year: "/^y(ear)?s?/", shortMeridian: "/^(a|p)/", longMeridian: "/^(a\\.?m?\\.?|p\\.?m?\\.?)/", timezone: "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/", ordinalSuffix: "/^\\s*(st|nd|rd|th)/", timeContext: "/^\\s*(\\:|a(?!u|p)|p)/" }, Date.i18n.currentLanguage()); } }; var CultureInfo = function () { var info = getText.getFromObjectValues({ name: "name", englishName: "englishName", nativeName: "nativeName", amDesignator: "AM", pmDesignator: "PM", firstDayOfWeek: "firstDayOfWeek", twoDigitYearMax: "twoDigitYearMax", dateElementOrder: "mdy" }, Date.i18n.currentLanguage()); var constructedInfo = buildInfo.buildFromMethodHash({ dayNames: "days", abbreviatedDayNames: "dayAbbr", shortestDayNames: "dayShortNames", firstLetterDayNames: "dayFirstLetters", monthNames: "months", abbreviatedMonthNames: "monthAbbr", formatPatterns: "formatPatterns", regexPatterns: "regex", abbreviatedTimeZoneDST: "timeZoneDST", abbreviatedTimeZoneStandard: "timeZoneStandard" }); shallowMerge(info, constructedInfo); buildInfo.timeZones(info); return info; }; $D.i18n = { __: function (key, lang) { return __(key, lang); }, currentLanguage: function () { return lang || "en-US"; }, setLanguage: function (code, force, cb) { var async = false; if (force || code === "en-US" || (!!Date.CultureStrings && !!Date.CultureStrings[code])) { lang = code; Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings.lang = code; Date.CultureInfo = new CultureInfo(); } else { if (!(!!Date.CultureStrings && !!Date.CultureStrings[code])) { if (typeof exports !== "undefined" && this.exports !== exports) { // we're in a Node enviroment, load it using require try { require("../i18n/" + code + ".js"); lang = code; Date.CultureStrings.lang = code; Date.CultureInfo = new CultureInfo(); } catch (e) { // var str = "The language for '" + code + "' could not be loaded by Node. It likely does not exist."; throw new Error("The DateJS IETF language tag '" + code + "' could not be loaded by Node. It likely does not exist."); } } else if (Date.Config && Date.Config.i18n) { // we know the location of the files, so lets load them async = true; loadI18nScript(code).done(function(){ lang = code; Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings.lang = code; Date.CultureInfo = new CultureInfo(); $D.Parsing.Normalizer.buildReplaceData(); // because this is async if ($D.Grammar) { $D.Grammar.buildGrammarFormats(); // so we can parse those strings... } if (cb) { setTimeout(cb,0); } }); } else { Date.console.error("The DateJS IETF language tag '" + code + "' is not available and has not been loaded."); return false; } } } $D.Parsing.Normalizer.buildReplaceData(); // rebuild normalizer strings if ($D.Grammar) { $D.Grammar.buildGrammarFormats(); // so we can parse those strings... } if (!async && cb) { setTimeout(cb,0); } }, getLoggedKeys: function () { return loggedKeys; }, updateCultureInfo: function () { Date.CultureInfo = new CultureInfo(); } }; $D.i18n.updateCultureInfo(); // run automatically }()); (function () { var $D = Date, $P = $D.prototype, p = function (s, l) { if (!l) { l = 2; } return ("000" + s).slice(l * -1); }; if (typeof window !== "undefined" && typeof window.console !== "undefined" && typeof window.console.log !== "undefined") { $D.console = console; // used only to raise non-critical errors if available } else { // set mock so we don't give errors. $D.console = { log: function(){}, error: function(){} }; } $D.Config = $D.Config || {}; $D.initOverloads = function() { /** * Overload of Date.now. Allows an alternate call for Date.now where it returns the * current Date as an object rather than just milliseconds since the Unix Epoch. * * Also provides an implementation of now() for browsers (IE<9) that don't have it. * * Backwards compatible so with work with either: * Date.now() [returns ms] * or * Date.now(true) [returns Date] */ if (!$D.now) { $D._now = function now() { return new Date().getTime(); }; } else if (!$D._now) { $D._now = $D.now; } $D.now = function (returnObj) { if (returnObj) { return $D.present(); } else { return $D._now(); } }; if ( !$P.toISOString ) { $P.toISOString = function() { return this.getUTCFullYear() + "-" + p(this.getUTCMonth() + 1) + "-" + p(this.getUTCDate()) + "T" + p(this.getUTCHours()) + ":" + p(this.getUTCMinutes()) + ":" + p(this.getUTCSeconds()) + "." + String( (this.getUTCMilliseconds()/1000).toFixed(3)).slice(2, 5) + "Z"; }; } // private if ( $P._toString === undefined ){ $P._toString = $P.toString; } }; $D.initOverloads(); /** * Gets a date that is set to the current date. The time is set to the start of the day (00:00 or 12:00 AM). * @return {Date} The current date. */ $D.today = function () { return new Date().clearTime(); }; /** * Gets a date that is set to the current date and time (same as new Date, but chainable) * @return {Date} The current date. */ $D.present = function () { return new Date(); }; /** * Compares the first date to the second date and returns an number indication of their relative values. * @param {Date} First Date object to compare [Required]. * @param {Date} Second Date object to compare to [Required]. * @return {Number} -1 = date1 is lessthan date2. 0 = values are equal. 1 = date1 is greaterthan date2. */ $D.compare = function (date1, date2) { if (isNaN(date1) || isNaN(date2)) { throw new Error(date1 + " - " + date2); } else if (date1 instanceof Date && date2 instanceof Date) { return (date1 < date2) ? -1 : (date1 > date2) ? 1 : 0; } else { throw new TypeError(date1 + " - " + date2); } }; /** * Compares the first Date object to the second Date object and returns true if they are equal. * @param {Date} First Date object to compare [Required] * @param {Date} Second Date object to compare to [Required] * @return {Boolean} true if dates are equal. false if they are not equal. */ $D.equals = function (date1, date2) { return (date1.compareTo(date2) === 0); }; /** * Gets the language appropriate day name when given the day number(0-6) * eg - 0 == Sunday * @return {String} The day name */ $D.getDayName = function (n) { return Date.CultureInfo.dayNames[n]; }; /** * Gets the day number (0-6) if given a CultureInfo specific string which is a valid dayName, abbreviatedDayName or shortestDayName (two char). * @param {String} The name of the day (eg. "Monday, "Mon", "tuesday", "tue", "We", "we"). * @return {Number} The day number */ $D.getDayNumberFromName = function (name) { var n = Date.CultureInfo.dayNames, m = Date.CultureInfo.abbreviatedDayNames, o = Date.CultureInfo.shortestDayNames, s = name.toLowerCase(); for (var i = 0; i < n.length; i++) { if (n[i].toLowerCase() === s || m[i].toLowerCase() === s || o[i].toLowerCase() === s) { return i; } } return -1; }; /** * Gets the month number (0-11) if given a Culture Info specific string which is a valid monthName or abbreviatedMonthName. * @param {String} The name of the month (eg. "February, "Feb", "october", "oct"). * @return {Number} The day number */ $D.getMonthNumberFromName = function (name) { var n = Date.CultureInfo.monthNames, m = Date.CultureInfo.abbreviatedMonthNames, s = name.toLowerCase(); for (var i = 0; i < n.length; i++) { if (n[i].toLowerCase() === s || m[i].toLowerCase() === s) { return i; } } return -1; }; /** * Gets the language appropriate month name when given the month number(0-11) * eg - 0 == January * @return {String} The month name */ $D.getMonthName = function (n) { return Date.CultureInfo.monthNames[n]; }; /** * Determines if the current date instance is within a LeapYear. * @param {Number} The year. * @return {Boolean} true if date is within a LeapYear, otherwise false. */ $D.isLeapYear = function (year) { return ((year % 4 === 0 && year % 100 !== 0) || year % 400 === 0); }; /** * Gets the number of days in the month, given a year and month value. Automatically corrects for LeapYear. * @param {Number} The year. * @param {Number} The month (0-11). * @return {Number} The number of days in the month. */ $D.getDaysInMonth = function (year, month) { if (!month && $D.validateMonth(year)) { month = year; year = Date.today().getFullYear(); } return [31, ($D.isLeapYear(year) ? 29 : 28), 31, 30, 31, 30, 31, 31, 30, 31, 30, 31][month]; }; $P.getDaysInMonth = function () { return $D.getDaysInMonth(this.getFullYear(), this.getMonth()); }; $D.getTimezoneAbbreviation = function (offset, dst) { var p, n = (dst || false) ? Date.CultureInfo.abbreviatedTimeZoneDST : Date.CultureInfo.abbreviatedTimeZoneStandard; for (p in n) { if (n.hasOwnProperty(p)) { if (n[p] === offset) { return p; } } } return null; }; $D.getTimezoneOffset = function (name, dst) { var i, a =[], z = Date.CultureInfo.timezones; if (!name) { name = (new Date()).getTimezone();} for (i = 0; i < z.length; i++) { if (z[i].name === name.toUpperCase()) { a.push(i); } } if (!z[a[0]]) { return null; } if (a.length === 1 || !dst) { return z[a[0]].offset; } else { for (i=0; i < a.length; i++) { if (z[a[i]].dst) { return z[a[i]].offset; } } } }; $D.getQuarter = function (d) { d = d || new Date(); // If no date supplied, use today var q = [1,2,3,4]; return q[Math.floor(d.getMonth() / 3)]; // ~~~ is a bitwise op. Faster than Math.floor }; $D.getDaysLeftInQuarter = function (d) { d = d || new Date(); var qEnd = new Date(d); qEnd.setMonth(qEnd.getMonth() + 3 - qEnd.getMonth() % 3, 0); return Math.floor((qEnd - d) / 8.64e7); }; // private var validate = function (n, min, max, name) { name = name ? name : "Object"; if (typeof n === "undefined") { return false; } else if (typeof n !== "number") { throw new TypeError(n + " is not a Number."); } else if (n < min || n > max) { // As failing validation is *not* an exceptional circumstance // lets not throw a RangeError Exception here. // It's semantically correct but it's not sensible. return false; } return true; }; /** * Validates the number is within an acceptable range for milliseconds [0-999]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateMillisecond = function (value) { return validate(value, 0, 999, "millisecond"); }; /** * Validates the number is within an acceptable range for seconds [0-59]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateSecond = function (value) { return validate(value, 0, 59, "second"); }; /** * Validates the number is within an acceptable range for minutes [0-59]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateMinute = function (value) { return validate(value, 0, 59, "minute"); }; /** * Validates the number is within an acceptable range for hours [0-23]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateHour = function (value) { return validate(value, 0, 23, "hour"); }; /** * Validates the number is within an acceptable range for the days in a month [0-MaxDaysInMonth]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateDay = function (value, year, month) { if (year === undefined || year === null || month === undefined || month === null) { return false;} return validate(value, 1, $D.getDaysInMonth(year, month), "day"); }; /** * Validates the number is within an acceptable range for months [0-11]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateWeek = function (value) { return validate(value, 0, 53, "week"); }; /** * Validates the number is within an acceptable range for months [0-11]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateMonth = function (value) { return validate(value, 0, 11, "month"); }; /** * Validates the number is within an acceptable range for years. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateYear = function (value) { /** * Per ECMAScript spec the range of times supported by Date objects is * exactly -100,000,000 days to +100,000,000 days measured relative to * midnight at the beginning of 01 January, 1970 UTC. * This gives a range of 8,640,000,000,000,000 milliseconds to either * side of 01 January, 1970 UTC. * * Earliest possible date: Tue, 20 Apr 271,822 B.C. 00:00:00 UTC * Latest possible date: Sat, 13 Sep 275,760 00:00:00 UTC */ return validate(value, -271822, 275760, "year"); }; $D.validateTimezone = function(value) { var timezones = {"ACDT":1,"ACST":1,"ACT":1,"ADT":1,"AEDT":1,"AEST":1,"AFT":1,"AKDT":1,"AKST":1,"AMST":1,"AMT":1,"ART":1,"AST":1,"AWDT":1,"AWST":1,"AZOST":1,"AZT":1,"BDT":1,"BIOT":1,"BIT":1,"BOT":1,"BRT":1,"BST":1,"BTT":1,"CAT":1,"CCT":1,"CDT":1,"CEDT":1,"CEST":1,"CET":1,"CHADT":1,"CHAST":1,"CHOT":1,"ChST":1,"CHUT":1,"CIST":1,"CIT":1,"CKT":1,"CLST":1,"CLT":1,"COST":1,"COT":1,"CST":1,"CT":1,"CVT":1,"CWST":1,"CXT":1,"DAVT":1,"DDUT":1,"DFT":1,"EASST":1,"EAST":1,"EAT":1,"ECT":1,"EDT":1,"EEDT":1,"EEST":1,"EET":1,"EGST":1,"EGT":1,"EIT":1,"EST":1,"FET":1,"FJT":1,"FKST":1,"FKT":1,"FNT":1,"GALT":1,"GAMT":1,"GET":1,"GFT":1,"GILT":1,"GIT":1,"GMT":1,"GST":1,"GYT":1,"HADT":1,"HAEC":1,"HAST":1,"HKT":1,"HMT":1,"HOVT":1,"HST":1,"ICT":1,"IDT":1,"IOT":1,"IRDT":1,"IRKT":1,"IRST":1,"IST":1,"JST":1,"KGT":1,"KOST":1,"KRAT":1,"KST":1,"LHST":1,"LINT":1,"MAGT":1,"MART":1,"MAWT":1,"MDT":1,"MET":1,"MEST":1,"MHT":1,"MIST":1,"MIT":1,"MMT":1,"MSK":1,"MST":1,"MUT":1,"MVT":1,"MYT":1,"NCT":1,"NDT":1,"NFT":1,"NPT":1,"NST":1,"NT":1,"NUT":1,"NZDT":1,"NZST":1,"OMST":1,"ORAT":1,"PDT":1,"PET":1,"PETT":1,"PGT":1,"PHOT":1,"PHT":1,"PKT":1,"PMDT":1,"PMST":1,"PONT":1,"PST":1,"PYST":1,"PYT":1,"RET":1,"ROTT":1,"SAKT":1,"SAMT":1,"SAST":1,"SBT":1,"SCT":1,"SGT":1,"SLST":1,"SRT":1,"SST":1,"SYOT":1,"TAHT":1,"THA":1,"TFT":1,"TJT":1,"TKT":1,"TLT":1,"TMT":1,"TOT":1,"TVT":1,"UCT":1,"ULAT":1,"UTC":1,"UYST":1,"UYT":1,"UZT":1,"VET":1,"VLAT":1,"VOLT":1,"VOST":1,"VUT":1,"WAKT":1,"WAST":1,"WAT":1,"WEDT":1,"WEST":1,"WET":1,"WST":1,"YAKT":1,"YEKT":1,"Z":1}; return (timezones[value] === 1); }; $D.validateTimezoneOffset= function(value) { // timezones go from +14hrs to -12hrs, the +X hours are negative offsets. return (value > -841 && value < 721); }; }()); (function () { var $D = Date, $P = $D.prototype, p = function (s, l) { if (!l) { l = 2; } return ("000" + s).slice(l * -1); }; var validateConfigObject = function (obj) { var result = {}, self = this, prop, testFunc; testFunc = function (prop, func, value) { if (prop === "day") { var month = (obj.month !== undefined) ? obj.month : self.getMonth(); var year = (obj.year !== undefined) ? obj.year : self.getFullYear(); return $D[func](value, year, month); } else { return $D[func](value); } }; for (prop in obj) { if (Object.prototype.hasOwnProperty.call(obj, prop)) { var func = "validate" + prop.charAt(0).toUpperCase() + prop.slice(1); if ($D[func] && obj[prop] !== null && testFunc(prop, func, obj[prop])) { result[prop] = obj[prop]; } } } return result; }; /** * Resets the time of this Date object to 12:00 AM (00:00), which is the start of the day. * @param {Boolean} .clone() this date instance before clearing Time * @return {Date} this */ $P.clearTime = function () { this.setHours(0); this.setMinutes(0); this.setSeconds(0); this.setMilliseconds(0); return this; }; /** * Resets the time of this Date object to the current time ('now'). * @return {Date} this */ $P.setTimeToNow = function () { var n = new Date(); this.setHours(n.getHours()); this.setMinutes(n.getMinutes()); this.setSeconds(n.getSeconds()); this.setMilliseconds(n.getMilliseconds()); return this; }; /** * Returns a new Date object that is an exact date and time copy of the original instance. * @return {Date} A new Date instance */ $P.clone = function () { return new Date(this.getTime()); }; /** * Compares this instance to a Date object and returns an number indication of their relative values. * @param {Date} Date object to compare [Required] * @return {Number} -1 = this is lessthan date. 0 = values are equal. 1 = this is greaterthan date. */ $P.compareTo = function (date) { return Date.compare(this, date); }; /** * Compares this instance to another Date object and returns true if they are equal. * @param {Date} Date object to compare. If no date to compare, new Date() [now] is used. * @return {Boolean} true if dates are equal. false if they are not equal. */ $P.equals = function (date) { return Date.equals(this, (date !== undefined ? date : new Date())); }; /** * Determines if this instance is between a range of two dates or equal to either the start or end dates. * @param {Date} Start of range [Required] * @param {Date} End of range [Required] * @return {Boolean} true is this is between or equal to the start and end dates, else false */ $P.between = function (start, end) { return this.getTime() >= start.getTime() && this.getTime() <= end.getTime(); }; /** * Determines if this date occurs after the date to compare to. * @param {Date} Date object to compare. If no date to compare, new Date() ("now") is used. * @return {Boolean} true if this date instance is greater than the date to compare to (or "now"), otherwise false. */ $P.isAfter = function (date) { return this.compareTo(date || new Date()) === 1; }; /** * Determines if this date occurs before the date to compare to. * @param {Date} Date object to compare. If no date to compare, new Date() ("now") is used. * @return {Boolean} true if this date instance is less than the date to compare to (or "now"). */ $P.isBefore = function (date) { return (this.compareTo(date || new Date()) === -1); }; /** * Determines if the current Date instance occurs today. * @return {Boolean} true if this date instance is 'today', otherwise false. */ /** * Determines if the current Date instance occurs on the same Date as the supplied 'date'. * If no 'date' to compare to is provided, the current Date instance is compared to 'today'. * @param {date} Date object to compare. If no date to compare, the current Date ("now") is used. * @return {Boolean} true if this Date instance occurs on the same Day as the supplied 'date'. */ $P.isToday = $P.isSameDay = function (date) { return this.clone().clearTime().equals((date || new Date()).clone().clearTime()); }; /** * Adds the specified number of milliseconds to this instance. * @param {Number} The number of milliseconds to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addMilliseconds = function (value) { if (!value) { return this; } this.setTime(this.getTime() + value * 1); return this; }; /** * Adds the specified number of seconds to this instance. * @param {Number} The number of seconds to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addSeconds = function (value) { if (!value) { return this; } return this.addMilliseconds(value * 1000); }; /** * Adds the specified number of seconds to this instance. * @param {Number} The number of seconds to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addMinutes = function (value) { if (!value) { return this; } return this.addMilliseconds(value * 60000); // 60*1000 }; /** * Adds the specified number of hours to this instance. * @param {Number} The number of hours to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addHours = function (value) { if (!value) { return this; } return this.addMilliseconds(value * 3600000); // 60*60*1000 }; /** * Adds the specified number of days to this instance. * @param {Number} The number of days to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addDays = function (value) { if (!value) { return this; } this.setDate(this.getDate() + value * 1); return this; }; /** * Adds the specified number of weekdays (ie - not sat or sun) to this instance. * @param {Number} The number of days to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addWeekdays = function (value) { if (!value) { return this; } var day = this.getDay(); var weeks = (Math.ceil(Math.abs(value)/7)); if (day === 0 || day === 6) { if (value > 0) { this.next().monday(); this.addDays(-1); day = this.getDay(); } } if (value < 0) { while (value < 0) { this.addDays(-1); day = this.getDay(); if (day !== 0 && day !== 6) { value++; } } return this; } else if (value > 5 || (6-day) <= value) { value = value + (weeks * 2); } return this.addDays(value); }; /** * Adds the specified number of weeks to this instance. * @param {Number} The number of weeks to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addWeeks = function (value) { if (!value) { return this; } return this.addDays(value * 7); }; /** * Adds the specified number of months to this instance. * @param {Number} The number of months to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addMonths = function (value) { if (!value) { return this; } var n = this.getDate(); this.setDate(1); this.setMonth(this.getMonth() + value * 1); this.setDate(Math.min(n, $D.getDaysInMonth(this.getFullYear(), this.getMonth()))); return this; }; $P.addQuarters = function (value) { if (!value) { return this; } // note this will take you to the same point in the quarter as you are now. // i.e. - if you are 15 days into the quarter you'll be 15 days into the resulting one. // bonus: this allows adding fractional quarters return this.addMonths(value * 3); }; /** * Adds the specified number of years to this instance. * @param {Number} The number of years to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addYears = function (value) { if (!value) { return this; } return this.addMonths(value * 12); }; /** * Adds (or subtracts) to the value of the years, months, weeks, days, hours, minutes, seconds, milliseconds of the date instance using given configuration object. Positive and Negative values allowed. * Example

	Date.today().add( { days: 1, months: 1 } )

	new Date().add( { years: -1 } )
	
* @param {Object} Configuration object containing attributes (months, days, etc.) * @return {Date} this */ $P.add = function (config) { if (typeof config === "number") { this._orient = config; return this; } var x = config; if (x.day) { // If we should be a different date than today (eg: for 'tomorrow -1d', etc). // Should only effect parsing, not direct usage (eg, Finish and FinishExact) if ((x.day - this.getDate()) !== 0) { this.setDate(x.day); } } if (x.milliseconds) { this.addMilliseconds(x.milliseconds); } if (x.seconds) { this.addSeconds(x.seconds); } if (x.minutes) { this.addMinutes(x.minutes); } if (x.hours) { this.addHours(x.hours); } if (x.weeks) { this.addWeeks(x.weeks); } if (x.months) { this.addMonths(x.months); } if (x.years) { this.addYears(x.years); } if (x.days) { this.addDays(x.days); } return this; }; /** * Get the week number. Week one (1) is the week which contains the first Thursday of the year. Monday is considered the first day of the week. * The .getWeek() function does NOT convert the date to UTC. The local datetime is used. * Please use .getISOWeek() to get the week of the UTC converted date. * @return {Number} 1 to 53 */ $P.getWeek = function (utc) { // Create a copy of this date object var self, target = new Date(this.valueOf()); if (utc) { target.addMinutes(target.getTimezoneOffset()); self = target.clone(); } else { self = this; } // ISO week date weeks start on monday // so correct the day number var dayNr = (self.getDay() + 6) % 7; // ISO 8601 states that week 1 is the week // with the first thursday of that year. // Set the target date to the thursday in the target week target.setDate(target.getDate() - dayNr + 3); // Store the millisecond value of the target date var firstThursday = target.valueOf(); // Set the target to the first thursday of the year // First set the target to january first target.setMonth(0, 1); // Not a thursday? Correct the date to the next thursday if (target.getDay() !== 4) { target.setMonth(0, 1 + ((4 - target.getDay()) + 7) % 7); } // The weeknumber is the number of weeks between the // first thursday of the year and the thursday in the target week return 1 + Math.ceil((firstThursday - target) / 604800000); // 604800000 = 7 * 24 * 3600 * 1000 }; /** * Get the ISO 8601 week number. Week one ("01") is the week which contains the first Thursday of the year. Monday is considered the first day of the week. * The .getISOWeek() function does convert the date to it's UTC value. Please use .getWeek() to get the week of the local date. * @return {String} "01" to "53" */ $P.getISOWeek = function () { return p(this.getWeek(true)); }; /** * Moves the date to Monday of the week set. Week one (1) is the week which contains the first Thursday of the year. * @param {Number} A Number (1 to 53) that represents the week of the year. * @return {Date} this */ $P.setWeek = function (n) { if ((n - this.getWeek()) === 0) { if (this.getDay() !== 1) { return this.moveToDayOfWeek(1, (this.getDay() > 1 ? -1 : 1)); } else { return this; } } else { return this.moveToDayOfWeek(1, (this.getDay() > 1 ? -1 : 1)).addWeeks(n - this.getWeek()); } }; $P.setQuarter = function (qtr) { var month = Math.abs(((qtr-1) * 3) + 1); return this.setMonth(month, 1); }; $P.getQuarter = function () { return Date.getQuarter(this); }; $P.getDaysLeftInQuarter = function () { return Date.getDaysLeftInQuarter(this); }; /** * Moves the date to the next n'th occurrence of the dayOfWeek starting from the beginning of the month. The number (-1) is a magic number and will return the last occurrence of the dayOfWeek in the month. * @param {Number} The dayOfWeek to move to * @param {Number} The n'th occurrence to move to. Use (-1) to return the last occurrence in the month * @return {Date} this */ $P.moveToNthOccurrence = function (dayOfWeek, occurrence) { if (dayOfWeek === "Weekday") { if (occurrence > 0) { this.moveToFirstDayOfMonth(); if (this.is().weekday()) { occurrence -= 1; } } else if (occurrence < 0) { this.moveToLastDayOfMonth(); if (this.is().weekday()) { occurrence += 1; } } else { return this; } return this.addWeekdays(occurrence); } var shift = 0; if (occurrence > 0) { shift = occurrence - 1; } else if (occurrence === -1) { this.moveToLastDayOfMonth(); if (this.getDay() !== dayOfWeek) { this.moveToDayOfWeek(dayOfWeek, -1); } return this; } return this.moveToFirstDayOfMonth().addDays(-1).moveToDayOfWeek(dayOfWeek, +1).addWeeks(shift); }; var moveToN = function (getFunc, addFunc, nVal) { return function (value, orient) { var diff = (value - this[getFunc]() + nVal * (orient || +1)) % nVal; return this[addFunc]((diff === 0) ? diff += nVal * (orient || +1) : diff); }; }; /** * Move to the next or last dayOfWeek based on the orient value. * @param {Number} The dayOfWeek to move to * @param {Number} Forward (+1) or Back (-1). Defaults to +1. [Optional] * @return {Date} this */ $P.moveToDayOfWeek = moveToN("getDay", "addDays", 7); /** * Move to the next or last month based on the orient value. * @param {Number} The month to move to. 0 = January, 11 = December * @param {Number} Forward (+1) or Back (-1). Defaults to +1. [Optional] * @return {Date} this */ $P.moveToMonth = moveToN("getMonth", "addMonths", 12); /** * Get the Ordinate of the current day ("th", "st", "rd"). * @return {String} */ $P.getOrdinate = function () { var num = this.getDate(); return ord(num); }; /** * Get the Ordinal day (numeric day number) of the year, adjusted for leap year. * @return {Number} 1 through 365 (366 in leap years) */ $P.getOrdinalNumber = function () { return Math.ceil((this.clone().clearTime() - new Date(this.getFullYear(), 0, 1)) / 86400000) + 1; }; /** * Get the time zone abbreviation of the current date. * @return {String} The abbreviated time zone name (e.g. "EST") */ $P.getTimezone = function () { return $D.getTimezoneAbbreviation(this.getUTCOffset(), this.isDaylightSavingTime()); }; $P.setTimezoneOffset = function (offset) { var here = this.getTimezoneOffset(), there = Number(offset) * -6 / 10; return (there || there === 0) ? this.addMinutes(there - here) : this; }; $P.setTimezone = function (offset) { return this.setTimezoneOffset($D.getTimezoneOffset(offset)); }; /** * Indicates whether Daylight Saving Time is observed in the current time zone. * @return {Boolean} true|false */ $P.hasDaylightSavingTime = function () { return (Date.today().set({month: 0, day: 1}).getTimezoneOffset() !== Date.today().set({month: 6, day: 1}).getTimezoneOffset()); }; /** * Indicates whether this Date instance is within the Daylight Saving Time range for the current time zone. * @return {Boolean} true|false */ $P.isDaylightSavingTime = function () { return Date.today().set({month: 0, day: 1}).getTimezoneOffset() !== this.getTimezoneOffset(); }; /** * Get the offset from UTC of the current date. * @return {String} The 4-character offset string prefixed with + or - (e.g. "-0500") */ $P.getUTCOffset = function (offset) { var n = (offset || this.getTimezoneOffset()) * -10 / 6, r; if (n < 0) { r = (n - 10000).toString(); return r.charAt(0) + r.substr(2); } else { r = (n + 10000).toString(); return "+" + r.substr(1); } }; /** * Returns the number of milliseconds between this date and date. * @param {Date} Defaults to now * @return {Number} The diff in milliseconds */ $P.getElapsed = function (date) { return (date || new Date()) - this; }; /** * Set the value of year, month, day, hour, minute, second, millisecond of date instance using given configuration object. * Example

	Date.today().set( { day: 20, month: 1 } )

	new Date().set( { millisecond: 0 } )
	
* * @param {Object} Configuration object containing attributes (month, day, etc.) * @return {Date} this */ $P.set = function (config) { config = validateConfigObject.call(this, config); var key; for (key in config) { if (Object.prototype.hasOwnProperty.call(config, key)) { var name = key.charAt(0).toUpperCase() + key.slice(1); var addFunc, getFunc; if (key !== "week" && key !== "month" && key !== "timezone" && key !== "timezoneOffset") { name += "s"; } addFunc = "add" + name; getFunc = "get" + name; if (key === "month") { addFunc = addFunc + "s"; } else if (key === "year"){ getFunc = "getFullYear"; } if (key !== "day" && key !== "timezone" && key !== "timezoneOffset" && key !== "week" && key !== "hour") { this[addFunc](config[key] - this[getFunc]()); } else if ( key === "timezone"|| key === "timezoneOffset" || key === "week" || key === "hour") { this["set"+name](config[key]); } } } // day has to go last because you can't validate the day without first knowing the month if (config.day) { this.addDays(config.day - this.getDate()); } return this; }; /** * Moves the date to the first day of the month. * @return {Date} this */ $P.moveToFirstDayOfMonth = function () { return this.set({ day: 1 }); }; /** * Moves the date to the last day of the month. * @return {Date} this */ $P.moveToLastDayOfMonth = function () { return this.set({ day: $D.getDaysInMonth(this.getFullYear(), this.getMonth())}); }; /** * Converts the value of the current Date object to its equivalent string representation. * Format Specifiers * CUSTOM DATE AND TIME FORMAT STRINGS * Format Description Example * ------ --------------------------------------------------------------------------- ----------------------- * s The seconds of the minute between 0-59. "0" to "59" * ss The seconds of the minute with leading zero if required. "00" to "59" * * m The minute of the hour between 0-59. "0" or "59" * mm The minute of the hour with leading zero if required. "00" or "59" * * h The hour of the day between 1-12. "1" to "12" * hh The hour of the day with leading zero if required. "01" to "12" * * H The hour of the day between 0-23. "0" to "23" * HH The hour of the day with leading zero if required. "00" to "23" * * d The day of the month between 1 and 31. "1" to "31" * dd The day of the month with leading zero if required. "01" to "31" * ddd Abbreviated day name. Date.CultureInfo.abbreviatedDayNames. "Mon" to "Sun" * dddd The full day name. Date.CultureInfo.dayNames. "Monday" to "Sunday" * * M The month of the year between 1-12. "1" to "12" * MM The month of the year with leading zero if required. "01" to "12" * MMM Abbreviated month name. Date.CultureInfo.abbreviatedMonthNames. "Jan" to "Dec" * MMMM The full month name. Date.CultureInfo.monthNames. "January" to "December" * * yy The year as a two-digit number. "99" or "08" * yyyy The full four digit year. "1999" or "2008" * * t Displays the first character of the A.M./P.M. designator. "A" or "P" * Date.CultureInfo.amDesignator or Date.CultureInfo.pmDesignator * tt Displays the A.M./P.M. designator. "AM" or "PM" * Date.CultureInfo.amDesignator or Date.CultureInfo.pmDesignator * * S The ordinal suffix ("st, "nd", "rd" or "th") of the current day. "st, "nd", "rd" or "th" * * STANDARD DATE AND TIME FORMAT STRINGS * Format Description Example *------ --------------------------------------------------------------------------- ----------------------- * d The CultureInfo shortDate Format Pattern "M/d/yyyy" * D The CultureInfo longDate Format Pattern "dddd, MMMM dd, yyyy" * F The CultureInfo fullDateTime Format Pattern "dddd, MMMM dd, yyyy h:mm:ss tt" * m The CultureInfo monthDay Format Pattern "MMMM dd" * r The CultureInfo rfc1123 Format Pattern "ddd, dd MMM yyyy HH:mm:ss GMT" * s The CultureInfo sortableDateTime Format Pattern "yyyy-MM-ddTHH:mm:ss" * t The CultureInfo shortTime Format Pattern "h:mm tt" * T The CultureInfo longTime Format Pattern "h:mm:ss tt" * u The CultureInfo universalSortableDateTime Format Pattern "yyyy-MM-dd HH:mm:ssZ" * y The CultureInfo yearMonth Format Pattern "MMMM, yyyy" * * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @return {String} A string representation of the current Date object. */ var ord = function (n) { switch (n * 1) { case 1: case 21: case 31: return "st"; case 2: case 22: return "nd"; case 3: case 23: return "rd"; default: return "th"; } }; var parseStandardFormats = function (format) { var y, c = Date.CultureInfo.formatPatterns; switch (format) { case "d": return this.toString(c.shortDate); case "D": return this.toString(c.longDate); case "F": return this.toString(c.fullDateTime); case "m": return this.toString(c.monthDay); case "r": case "R": y = this.clone().addMinutes(this.getTimezoneOffset()); return y.toString(c.rfc1123) + " GMT"; case "s": return this.toString(c.sortableDateTime); case "t": return this.toString(c.shortTime); case "T": return this.toString(c.longTime); case "u": y = this.clone().addMinutes(this.getTimezoneOffset()); return y.toString(c.universalSortableDateTime); case "y": return this.toString(c.yearMonth); default: return false; } }; var parseFormatStringsClosure = function (context) { return function (m) { if (m.charAt(0) === "\\") { return m.replace("\\", ""); } switch (m) { case "hh": return p(context.getHours() < 13 ? (context.getHours() === 0 ? 12 : context.getHours()) : (context.getHours() - 12)); case "h": return context.getHours() < 13 ? (context.getHours() === 0 ? 12 : context.getHours()) : (context.getHours() - 12); case "HH": return p(context.getHours()); case "H": return context.getHours(); case "mm": return p(context.getMinutes()); case "m": return context.getMinutes(); case "ss": return p(context.getSeconds()); case "s": return context.getSeconds(); case "yyyy": return p(context.getFullYear(), 4); case "yy": return p(context.getFullYear()); case "y": return context.getFullYear(); case "E": case "dddd": return Date.CultureInfo.dayNames[context.getDay()]; case "ddd": return Date.CultureInfo.abbreviatedDayNames[context.getDay()]; case "dd": return p(context.getDate()); case "d": return context.getDate(); case "MMMM": return Date.CultureInfo.monthNames[context.getMonth()]; case "MMM": return Date.CultureInfo.abbreviatedMonthNames[context.getMonth()]; case "MM": return p((context.getMonth() + 1)); case "M": return context.getMonth() + 1; case "t": return context.getHours() < 12 ? Date.CultureInfo.amDesignator.substring(0, 1) : Date.CultureInfo.pmDesignator.substring(0, 1); case "tt": return context.getHours() < 12 ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator; case "S": return ord(context.getDate()); case "W": return context.getWeek(); case "WW": return context.getISOWeek(); case "Q": return "Q" + context.getQuarter(); case "q": return String(context.getQuarter()); case "z": return context.getTimezone(); case "Z": case "X": return Date.getTimezoneOffset(context.getTimezone()); case "ZZ": // Timezone offset in seconds return context.getTimezoneOffset() * -60; case "u": return context.getDay(); case "L": return ($D.isLeapYear(context.getFullYear())) ? 1 : 0; case "B": // Swatch Internet Time (.beats) return "@"+((context.getUTCSeconds() + (context.getUTCMinutes()*60) + ((context.getUTCHours()+1)*3600))/86.4); default: return m; } }; }; $P.toString = function (format, ignoreStandards) { // Standard Date and Time Format Strings. Formats pulled from CultureInfo file and // may vary by culture. if (!ignoreStandards && format && format.length === 1) { output = parseStandardFormats.call(this, format); if (output) { return output; } } var parseFormatStrings = parseFormatStringsClosure(this); return format ? format.replace(/((\\)?(dd?d?d?|MM?M?M?|yy?y?y?|hh?|HH?|mm?|ss?|tt?|S|q|Q|WW?W?W?)(?![^\[]*\]))/g, parseFormatStrings).replace(/\[|\]/g, "") : this._toString(); }; }()); /************************************************************* * SugarPak - Domain Specific Language - Syntactical Sugar * *************************************************************/ (function () { var $D = Date, $P = $D.prototype, $N = Number.prototype; // private $P._orient = +1; // private $P._nth = null; // private $P._is = false; // private $P._same = false; // private $P._isSecond = false; // private $N._dateElement = "days"; /** * Moves the date to the next instance of a date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.today().next().friday();
	Date.today().next().fri();
	Date.today().next().march();
	Date.today().next().mar();
	Date.today().next().week();
	
* * @return {Date} date */ $P.next = function () { this._move = true; this._orient = +1; return this; }; /** * Creates a new Date (Date.today()) and moves the date to the next instance of the date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.next().friday();
	Date.next().fri();
	Date.next().march();
	Date.next().mar();
	Date.next().week();
	
* * @return {Date} date */ $D.next = function () { return $D.today().next(); }; /** * Moves the date to the previous instance of a date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.today().last().friday();
	Date.today().last().fri();
	Date.today().last().march();
	Date.today().last().mar();
	Date.today().last().week();
	
* * @return {Date} date */ $P.last = $P.prev = $P.previous = function () { this._move = true; this._orient = -1; return this; }; /** * Creates a new Date (Date.today()) and moves the date to the previous instance of the date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.last().friday();
	Date.last().fri();
	Date.previous().march();
	Date.prev().mar();
	Date.last().week();
	
* * @return {Date} date */ $D.last = $D.prev = $D.previous = function () { return $D.today().last(); }; /** * Performs a equality check when followed by either a month name, day name or .weekday() function. * Example

	Date.today().is().friday(); // true|false
	Date.today().is().fri();
	Date.today().is().march();
	Date.today().is().mar();
	
* * @return {Boolean} true|false */ $P.is = function () { this._is = true; return this; }; /** * Determines if two date objects occur on/in exactly the same instance of the subsequent date part function. * The function .same() must be followed by a date part function (example: .day(), .month(), .year(), etc). * * An optional Date can be passed in the date part function. If now date is passed as a parameter, 'Now' is used. * * The following example demonstrates how to determine if two dates fall on the exact same day. * * Example

	var d1 = Date.today(); // today at 00:00
	var d2 = new Date();   // exactly now.

	// Do they occur on the same day?
	d1.same().day(d2); // true
	
	// Do they occur on the same hour?
	d1.same().hour(d2); // false, unless d2 hour is '00' (midnight).
	
	// What if it's the same day, but one year apart?
	var nextYear = Date.today().add(1).year();

	d1.same().day(nextYear); // false, because the dates must occur on the exact same day. 
	
* * Scenario: Determine if a given date occurs during some week period 2 months from now. * * Example

	var future = Date.today().add(2).months();
	return someDate.same().week(future); // true|false;
	
* * @return {Boolean} true|false */ $P.same = function () { this._same = true; this._isSecond = false; return this; }; /** * Determines if the current date/time occurs during Today. Must be preceded by the .is() function. * Example

	someDate.is().today();    // true|false
	new Date().is().today();  // true
	Date.today().is().today();// true
	Date.today().add(-1).day().is().today(); // false
	
* * @return {Boolean} true|false */ $P.today = function () { return this.same().day(); }; /** * Determines if the current date is a weekday. This function must be preceded by the .is() function. * Example

	Date.today().is().weekday(); // true|false
	
* * @return {Boolean} true|false */ $P.weekday = function () { if (this._nth) { return df("Weekday").call(this); } if (this._move) { return this.addWeekdays(this._orient); } if (this._is) { this._is = false; return (!this.is().sat() && !this.is().sun()); } return false; }; /** * Determines if the current date is on the weekend. This function must be preceded by the .is() function. * Example

	Date.today().is().weekend(); // true|false
	
* * @return {Boolean} true|false */ $P.weekend = function () { if (this._is) { this._is = false; return (this.is().sat() || this.is().sun()); } return false; }; /** * Sets the Time of the current Date instance. A string "6:15 pm" or config object {hour:18, minute:15} are accepted. * Example

	// Set time to 6:15pm with a String
	Date.today().at("6:15pm");

	// Set time to 6:15pm with a config object
	Date.today().at({hour:18, minute:15});
	
* * @return {Date} date */ $P.at = function (time) { return (typeof time === "string") ? $D.parse(this.toString("d") + " " + time) : this.set(time); }; /** * Creates a new Date() and adds this (Number) to the date based on the preceding date element function (eg. second|minute|hour|day|month|year). * Example

	// Undeclared Numbers must be wrapped with parentheses. Requirment of JavaScript.
	(3).days().fromNow();
	(6).months().fromNow();

	// Declared Number variables do not require parentheses. 
	var n = 6;
	n.months().fromNow();
	
* * @return {Date} A new Date instance */ $N.fromNow = $N.after = function (date) { var c = {}; c[this._dateElement] = this; return ((!date) ? new Date() : date.clone()).add(c); }; /** * Creates a new Date() and subtract this (Number) from the date based on the preceding date element function (eg. second|minute|hour|day|month|year). * Example

	// Undeclared Numbers must be wrapped with parentheses. Requirment of JavaScript.
	(3).days().ago();
	(6).months().ago();

	// Declared Number variables do not require parentheses. 
	var n = 6;
	n.months().ago();
	
* * @return {Date} A new Date instance */ $N.ago = $N.before = function (date) { var c = {}, s = (this._dateElement[this._dateElement.length-1] !== "s") ? this._dateElement + "s" : this._dateElement; c[s] = this * -1; return ((!date) ? new Date() : date.clone()).add(c); }; // Do NOT modify the following string tokens. These tokens are used to build dynamic functions. // All culture-specific strings can be found in the CultureInfo files. var dx = ("sunday monday tuesday wednesday thursday friday saturday").split(/\s/), mx = ("january february march april may june july august september october november december").split(/\s/), px = ("Millisecond Second Minute Hour Day Week Month Year Quarter Weekday").split(/\s/), pxf = ("Milliseconds Seconds Minutes Hours Date Week Month FullYear Quarter").split(/\s/), nth = ("final first second third fourth fifth").split(/\s/), de; /** * Returns an object literal of all the date parts. * Example

	var o = new Date().toObject();
	
	// { year: 2008, month: 4, week: 20, day: 13, hour: 18, minute: 9, second: 32, millisecond: 812 }
	
	// The object properties can be referenced directly from the object.
	
	alert(o.day);  // alerts "13"
	alert(o.year); // alerts "2008"
	
* * @return {Date} An object literal representing the original date object. */ $P.toObject = function () { var o = {}; for (var i = 0; i < px.length; i++) { if (this["get" + pxf[i]]) { o[px[i].toLowerCase()] = this["get" + pxf[i]](); } } return o; }; /** * Returns a date created from an object literal. Ignores the .week property if set in the config. * Example

	var o = new Date().toObject();
	
	return Date.fromObject(o); // will return the same date. 

	var o2 = {month: 1, day: 20, hour: 18}; // birthday party!
	Date.fromObject(o2);
	
* * @return {Date} An object literal representing the original date object. */ $D.fromObject = function(config) { config.week = null; return Date.today().set(config); }; // Create day name functions and abbreviated day name functions (eg. monday(), friday(), fri()). var df = function (n) { return function () { if (this._is) { this._is = false; return this.getDay() === n; } if (this._move) { this._move = null; } if (this._nth !== null) { // If the .second() function was called earlier, remove the _orient // from the date, and then continue. // This is required because 'second' can be used in two different context. // // Example // // Date.today().add(1).second(); // Date.march().second().monday(); // // Things get crazy with the following... // Date.march().add(1).second().second().monday(); // but it works!! // if (this._isSecond) { this.addSeconds(this._orient * -1); } // make sure we reset _isSecond this._isSecond = false; var ntemp = this._nth; this._nth = null; var temp = this.clone().moveToLastDayOfMonth(); this.moveToNthOccurrence(n, ntemp); if (this > temp) { throw new RangeError($D.getDayName(n) + " does not occur " + ntemp + " times in the month of " + $D.getMonthName(temp.getMonth()) + " " + temp.getFullYear() + "."); } return this; } return this.moveToDayOfWeek(n, this._orient); }; }; var sdf = function (n) { return function () { var t = $D.today(), shift = n - t.getDay(); if (n === 0 && Date.CultureInfo.firstDayOfWeek === 1 && t.getDay() !== 0) { shift = shift + 7; } return t.addDays(shift); }; }; // Create month name functions and abbreviated month name functions (eg. january(), march(), mar()). var month_instance_functions = function (n) { return function () { if (this._is) { this._is = false; return this.getMonth() === n; } return this.moveToMonth(n, this._orient); }; }; var month_static_functions = function (n) { return function () { return $D.today().set({ month: n, day: 1 }); }; }; var processTerms = function (names, staticFunc, instanceFunc) { for (var i = 0; i < names.length; i++) { // Create constant static Name variables. $D[names[i].toUpperCase()] = $D[names[i].toUpperCase().substring(0, 3)] = i; // Create Name functions. $D[names[i]] = $D[names[i].substring(0, 3)] = staticFunc(i); // Create Name instance functions. $P[names[i]] = $P[names[i].substring(0, 3)] = instanceFunc(i); } }; processTerms(dx, sdf, df); processTerms(mx, month_static_functions, month_instance_functions); // Create date element functions and plural date element functions used with Date (eg. day(), days(), months()). var ef = function (j) { return function () { // if the .second() function was called earlier, the _orient // has alread been added. Just return this and reset _isSecond. if (this._isSecond) { this._isSecond = false; return this; } if (this._same) { this._same = this._is = false; var o1 = this.toObject(), o2 = (arguments[0] || new Date()).toObject(), v = "", k = j.toLowerCase(); // the substr trick with -1 doesn't work in IE8 or less k = (k[k.length-1] === "s") ? k.substring(0,k.length-1) : k; for (var m = (px.length - 1); m > -1; m--) { v = px[m].toLowerCase(); if (o1[v] !== o2[v]) { return false; } if (k === v) { break; } } return true; } if (j.substring(j.length - 1) !== "s") { j += "s"; } if (this._move) { this._move = null; } return this["add" + j](this._orient); }; }; var nf = function (n) { return function () { this._dateElement = n; return this; }; }; for (var k = 0; k < px.length; k++) { de = px[k].toLowerCase(); if(de !== "weekday") { // Create date element functions and plural date element functions used with Date (eg. day(), days(), months()). $P[de] = $P[de + "s"] = ef(px[k]); // Create date element functions and plural date element functions used with Number (eg. day(), days(), months()). $N[de] = $N[de + "s"] = nf(de + "s"); } } $P._ss = ef("Second"); var nthfn = function (n) { return function (dayOfWeek) { if (this._same) { return this._ss(arguments[0]); } if (dayOfWeek || dayOfWeek === 0) { return this.moveToNthOccurrence(dayOfWeek, n); } this._nth = n; // if the operator is 'second' add the _orient, then deal with it later... if (n === 2 && (dayOfWeek === undefined || dayOfWeek === null)) { this._isSecond = true; return this.addSeconds(this._orient); } return this; }; }; for (var l = 0; l < nth.length; l++) { $P[nth[l]] = (l === 0) ? nthfn(-1) : nthfn(l); } }()); (function () { "use strict"; Date.Parsing = { Exception: function (s) { this.message = "Parse error at '" + s.substring(0, 10) + " ...'"; } }; var $P = Date.Parsing; var dayOffsets = { standard: [0,31,59,90,120,151,181,212,243,273,304,334], leap: [0,31,60,91,121,152,182,213,244,274,305,335] }; $P.isLeapYear = function(year) { return ((year % 4 === 0) && (year % 100 !== 0)) || (year % 400 === 0); }; var utils = { multiReplace : function (str, hash ) { var key; for (key in hash) { if (Object.prototype.hasOwnProperty.call(hash, key)) { var regex; if (typeof hash[key] === "function") { } else { regex = (hash[key] instanceof RegExp) ? hash[key] : new RegExp(hash[key], "g"); } str = str.replace(regex, key); } } return str; }, getDayOfYearFromWeek : function (obj) { var d, jan4, offset; obj.weekDay = (!obj.weekDay && obj.weekDay !== 0) ? 1 : obj.weekDay; d = new Date(obj.year, 0, 4); jan4 = d.getDay() === 0 ? 7 : d.getDay(); // JS is 0 indexed on Sunday. offset = jan4+3; obj.dayOfYear = ((obj.week * 7) + (obj.weekDay === 0 ? 7 : obj.weekDay))-offset; return obj; }, getDayOfYear : function (obj, dayOffset) { if (!obj.dayOfYear) { obj = utils.getDayOfYearFromWeek(obj); } for (var i=0;i <= dayOffset.length;i++) { if (obj.dayOfYear < dayOffset[i] || i === dayOffset.length) { obj.day = obj.day ? obj.day : (obj.dayOfYear - dayOffset[i-1]); break; } else { obj.month = i; } } return obj; }, adjustForTimeZone : function (obj, date) { var offset; if (obj.zone.toUpperCase() === "Z" || (obj.zone_hours === 0 && obj.zone_minutes === 0)) { // it's UTC/GML so work out the current timeszone offset offset = -date.getTimezoneOffset(); } else { offset = (obj.zone_hours*60) + (obj.zone_minutes || 0); if (obj.zone_sign === "+") { offset *= -1; } offset -= date.getTimezoneOffset(); } date.setMinutes(date.getMinutes()+offset); return date; }, setDefaults : function (obj) { obj.year = obj.year || Date.today().getFullYear(); obj.hours = obj.hours || 0; obj.minutes = obj.minutes || 0; obj.seconds = obj.seconds || 0; obj.milliseconds = obj.milliseconds || 0; if (!(!obj.month && (obj.week || obj.dayOfYear))) { // if we have a month, or if we don't but don't have the day calculation data obj.month = obj.month || 0; obj.day = obj.day || 1; } return obj; }, dataNum: function (data, mod, explict, postProcess) { var dataNum = data*1; if (mod) { if (postProcess) { return data ? mod(data)*1 : data; } else { return data ? mod(dataNum) : data; } } else if (!explict){ return data ? dataNum : data; } else { return (data && typeof data !== "undefined") ? dataNum : data; } }, timeDataProcess: function (obj) { var timeObj = {}; for (var x in obj.data) { if (obj.data.hasOwnProperty(x)) { timeObj[x] = obj.ignore[x] ? obj.data[x] : utils.dataNum(obj.data[x], obj.mods[x], obj.explict[x], obj.postProcess[x]); } } if (obj.data.secmins) { obj.data.secmins = obj.data.secmins.replace(",", ".") * 60; if (!timeObj.minutes) { timeObj.minutes = obj.data.secmins; } else if (!timeObj.seconds) { timeObj.seconds = obj.data.secmins; } delete obj.secmins; } return timeObj; }, buildTimeObjectFromData: function (data) { var time = utils.timeDataProcess({ data: { year : data[1], month : data[5], day : data[7], week : data[8], dayOfYear : data[10], hours : data[15], zone_hours : data[23], zone_minutes : data[24], zone : data[21], zone_sign : data[22], weekDay : data[9], minutes: data[16], seconds: data[19], milliseconds: data[20], secmins: data[18] }, mods: { month: function(data) { return data-1; }, weekDay: function (data) { data = Math.abs(data); return (data === 7 ? 0 : data); }, minutes: function (data) { return data.replace(":",""); }, seconds: function (data) { return Math.floor( (data.replace(":","").replace(",","."))*1 ); }, milliseconds: function (data) { return (data.replace(",",".")*1000); } }, postProcess: { minutes: true, seconds: true, milliseconds: true }, explict: { zone_hours: true, zone_minutes: true }, ignore: { zone: true, zone_sign: true, secmins: true } }); return time; }, addToHash: function (hash, keys, data) { keys = keys; data = data; var len = keys.length; for (var i = 0; i < len; i++) { hash[keys[i]] = data[i]; } return hash; }, combineRegex: function (r1, r2) { return new RegExp("(("+r1.source+")\\s("+r2.source+"))"); }, getDateNthString: function(add, last, inc){ if (add) { return Date.today().addDays(inc).toString("d"); } else if (last) { return Date.today().last()[inc]().toString("d"); } }, buildRegexData: function (array) { var arr = []; var len = array.length; for (var i=0; i < len; i++) { if (Object.prototype.toString.call(array[i]) === '[object Array]') { // oldIE compat version of Array.isArray arr.push(this.combineRegex(array[i][0], array[i][1])); } else { arr.push(array[i]); } } return arr; } }; $P.processTimeObject = function (obj) { var date, dayOffset; utils.setDefaults(obj); dayOffset = ($P.isLeapYear(obj.year)) ? dayOffsets.leap : dayOffsets.standard; if (!obj.month && (obj.week || obj.dayOfYear)) { utils.getDayOfYear(obj, dayOffset); } else { obj.dayOfYear = dayOffset[obj.month] + obj.day; } date = new Date(obj.year, obj.month, obj.day, obj.hours, obj.minutes, obj.seconds, obj.milliseconds); if (obj.zone) { utils.adjustForTimeZone(obj, date); // adjust (and calculate) for timezone } return date; }; $P.ISO = { regex : /^([\+-]?\d{4}(?!\d{2}\b))((-?)((0[1-9]|1[0-2])(\3([12]\d|0[1-9]|3[01]))?|W([0-4]\d|5[0-3])(-?[1-7])?|(00[1-9]|0[1-9]\d|[12]\d{2}|3([0-5]\d|6[1-6])))([T\s]((([01]\d|2[0-4])((:?)[0-5]\d)?|24\:?00)([\.,]\d+(?!:))?)?(\17[0-5]\d([\.,]\d+)?)?\s?([zZ]|([\+-])([01]\d|2[0-3]):?([0-5]\d)?)?)?)?$/, parse : function (s) { var time, data = s.match(this.regex); if (!data || !data.length) { return null; } time = utils.buildTimeObjectFromData(data); if (!time.year || (!time.year && (!time.month && !time.day) && (!time.week && !time.dayOfYear)) ) { return null; } return $P.processTimeObject(time); } }; $P.Numeric = { isNumeric: function (e){return!isNaN(parseFloat(e))&&isFinite(e);}, regex: /\b([0-1]?[0-9])([0-3]?[0-9])([0-2]?[0-9]?[0-9][0-9])\b/i, parse: function (s) { var data, i, time = {}, order = Date.CultureInfo.dateElementOrder.split(""); if (!(this.isNumeric(s)) || // if it's non-numeric OR (s[0] === "+" && s[0] === "-")) { // It's an arithmatic string (eg +/-1000) return null; } if (s.length < 5 && s.indexOf(".") < 0 && s.indexOf("/") < 0) { // assume it's just a year. time.year = s; return $P.processTimeObject(time); } data = s.match(this.regex); if (!data || !data.length) { return null; } for (i=0; i < order.length; i++) { switch(order[i]) { case "d": time.day = data[i+1]; break; case "m": time.month = (data[i+1]-1); break; case "y": time.year = data[i+1]; break; } } return $P.processTimeObject(time); } }; $P.Normalizer = { regexData: function () { var $R = Date.CultureInfo.regexPatterns; return utils.buildRegexData([ $R.tomorrow, $R.yesterday, [$R.past, $R.mon], [$R.past, $R.tue], [$R.past, $R.wed], [$R.past, $R.thu], [$R.past, $R.fri], [$R.past, $R.sat], [$R.past, $R.sun] ]); }, basicReplaceHash : function() { var $R = Date.CultureInfo.regexPatterns; return { "January": $R.jan.source, "February": $R.feb, "March": $R.mar, "April": $R.apr, "May": $R.may, "June": $R.jun, "July": $R.jul, "August": $R.aug, "September": $R.sep, "October": $R.oct, "November": $R.nov, "December": $R.dec, "": /\bat\b/gi, " ": /\s{2,}/, "am": $R.inTheMorning, "9am": $R.thisMorning, "pm": $R.inTheEvening, "7pm":$R.thisEvening }; }, keys : function(){ return [ utils.getDateNthString(true, false, 1), // tomorrow utils.getDateNthString(true, false, -1), // yesterday utils.getDateNthString(false, true, "monday"), //last mon utils.getDateNthString(false, true, "tuesday"), //last tues utils.getDateNthString(false, true, "wednesday"), //last wed utils.getDateNthString(false, true, "thursday"), //last thurs utils.getDateNthString(false, true, "friday"), //last fri utils.getDateNthString(false, true, "saturday"), //last sat utils.getDateNthString(false, true, "sunday") //last sun ]; }, buildRegexFunctions: function () { var $R = Date.CultureInfo.regexPatterns; var __ = Date.i18n.__; var tomorrowRE = new RegExp("(\\b\\d\\d?("+__("AM")+"|"+__("PM")+")? )("+$R.tomorrow.source.slice(1)+")", "i"); // adapted tomorrow regex for AM PM relative dates var todayRE = new RegExp($R.today.source + "(?!\\s*([+-]))\\b"); // today, but excludes the math operators (eg "today + 2h") this.replaceFuncs = [ [todayRE, function (full) { return (full.length > 1) ? Date.today().toString("d") : full; }], [tomorrowRE, function(full, m1) { var t = Date.today().addDays(1).toString("d"); return (t + " " + m1); }], [$R.amThisMorning, function(str, am){return am;}], [$R.pmThisEvening, function(str, pm){return pm;}] ]; }, buildReplaceData: function () { this.buildRegexFunctions(); this.replaceHash = utils.addToHash(this.basicReplaceHash(), this.keys(), this.regexData()); }, stringReplaceFuncs: function (s) { for (var i=0; i < this.replaceFuncs.length; i++) { s = s.replace(this.replaceFuncs[i][0], this.replaceFuncs[i][1]); } return s; }, parse: function (s) { s = this.stringReplaceFuncs(s); s = utils.multiReplace(s, this.replaceHash); try { var n = s.split(/([\s\-\.\,\/\x27]+)/); if (n.length === 3 && $P.Numeric.isNumeric(n[0]) && $P.Numeric.isNumeric(n[2]) && (n[2].length >= 4)) { // ok, so we're dealing with x/year. But that's not a full date. // This fixes wonky dateElementOrder parsing when set to dmy order. if (Date.CultureInfo.dateElementOrder[0] === "d") { s = "1/" + n[0] + "/" + n[2]; // set to 1st of month and normalize the seperator } } } catch (e) {} return s; } }; $P.Normalizer.buildReplaceData(); }()); (function () { var $P = Date.Parsing; var _ = $P.Operators = { // // Tokenizers // rtoken: function (r) { // regex token return function (s) { var mx = s.match(r); if (mx) { return ([ mx[0], s.substring(mx[0].length) ]); } else { throw new $P.Exception(s); } }; }, token: function () { // whitespace-eating token return function (s) { return _.rtoken(new RegExp("^\\s*" + s + "\\s*"))(s); }; }, stoken: function (s) { // string token return _.rtoken(new RegExp("^" + s)); }, // Atomic Operators until: function (p) { return function (s) { var qx = [], rx = null; while (s.length) { try { rx = p.call(this, s); } catch (e) { qx.push(rx[0]); s = rx[1]; continue; } break; } return [ qx, s ]; }; }, many: function (p) { return function (s) { var rx = [], r = null; while (s.length) { try { r = p.call(this, s); } catch (e) { return [ rx, s ]; } rx.push(r[0]); s = r[1]; } return [ rx, s ]; }; }, // generator operators -- see below optional: function (p) { return function (s) { var r = null; try { r = p.call(this, s); } catch (e) { return [ null, s ]; } return [ r[0], r[1] ]; }; }, not: function (p) { return function (s) { try { p.call(this, s); } catch (e) { return [null, s]; } throw new $P.Exception(s); }; }, ignore: function (p) { return p ? function (s) { var r = null; r = p.call(this, s); return [null, r[1]]; } : null; }, product: function () { var px = arguments[0], qx = Array.prototype.slice.call(arguments, 1), rx = []; for (var i = 0 ; i < px.length ; i++) { rx.push(_.each(px[i], qx)); } return rx; }, cache: function (rule) { var cache = {}, cache_length = 0, cache_keys = [], CACHE_MAX = Date.Config.CACHE_MAX || 100000, r = null; var cacheCheck = function () { if (cache_length === CACHE_MAX) { // kill several keys, don't want to have to do this all the time... for (var i=0; i < 10; i++) { var key = cache_keys.shift(); if (key) { delete cache[key]; cache_length--; } } } }; return function (s) { cacheCheck(); try { r = cache[s] = (cache[s] || rule.call(this, s)); } catch (e) { r = cache[s] = e; } cache_length++; cache_keys.push(s); if (r instanceof $P.Exception) { throw r; } else { return r; } }; }, // vector operators -- see below any: function () { var px = arguments; return function (s) { var r = null; for (var i = 0; i < px.length; i++) { if (px[i] == null) { continue; } try { r = (px[i].call(this, s)); } catch (e) { r = null; } if (r) { return r; } } throw new $P.Exception(s); }; }, each: function () { var px = arguments; return function (s) { var rx = [], r = null; for (var i = 0; i < px.length ; i++) { if (px[i] == null) { continue; } try { r = (px[i].call(this, s)); } catch (e) { throw new $P.Exception(s); } rx.push(r[0]); s = r[1]; } return [ rx, s]; }; }, all: function () { var px = arguments, _ = _; return _.each(_.optional(px)); }, // delimited operators sequence: function (px, d, c) { d = d || _.rtoken(/^\s*/); c = c || null; if (px.length === 1) { return px[0]; } return function (s) { var r = null, q = null; var rx = []; for (var i = 0; i < px.length ; i++) { try { r = px[i].call(this, s); } catch (e) { break; } rx.push(r[0]); try { q = d.call(this, r[1]); } catch (ex) { q = null; break; } s = q[1]; } if (!r) { throw new $P.Exception(s); } if (q) { throw new $P.Exception(q[1]); } if (c) { try { r = c.call(this, r[1]); } catch (ey) { throw new $P.Exception(r[1]); } } return [ rx, (r?r[1]:s) ]; }; }, // // Composite Operators // between: function (d1, p, d2) { d2 = d2 || d1; var _fn = _.each(_.ignore(d1), p, _.ignore(d2)); return function (s) { var rx = _fn.call(this, s); return [[rx[0][0], r[0][2]], rx[1]]; }; }, list: function (p, d, c) { d = d || _.rtoken(/^\s*/); c = c || null; return (p instanceof Array ? _.each(_.product(p.slice(0, -1), _.ignore(d)), p.slice(-1), _.ignore(c)) : _.each(_.many(_.each(p, _.ignore(d))), px, _.ignore(c))); }, set: function (px, d, c) { d = d || _.rtoken(/^\s*/); c = c || null; return function (s) { // r is the current match, best the current 'best' match // which means it parsed the most amount of input var r = null, p = null, q = null, rx = null, best = [[], s], last = false; // go through the rules in the given set for (var i = 0; i < px.length ; i++) { // last is a flag indicating whether this must be the last element // if there is only 1 element, then it MUST be the last one q = null; p = null; r = null; last = (px.length === 1); // first, we try simply to match the current pattern // if not, try the next pattern try { r = px[i].call(this, s); } catch (e) { continue; } // since we are matching against a set of elements, the first // thing to do is to add r[0] to matched elements rx = [[r[0]], r[1]]; // if we matched and there is still input to parse and // we don't already know this is the last element, // we're going to next check for the delimiter ... // if there's none, or if there's no input left to parse // than this must be the last element after all ... if (r[1].length > 0 && ! last) { try { q = d.call(this, r[1]); } catch (ex) { last = true; } } else { last = true; } // if we parsed the delimiter and now there's no more input, // that means we shouldn't have parsed the delimiter at all // so don't update r and mark this as the last element ... if (!last && q[1].length === 0) { last = true; } // so, if this isn't the last element, we're going to see if // we can get any more matches from the remaining (unmatched) // elements ... if (!last) { // build a list of the remaining rules we can match against, // i.e., all but the one we just matched against var qx = []; for (var j = 0; j < px.length ; j++) { if (i !== j) { qx.push(px[j]); } } // now invoke recursively set with the remaining input // note that we don't include the closing delimiter ... // we'll check for that ourselves at the end p = _.set(qx, d).call(this, q[1]); // if we got a non-empty set as a result ... // (otw rx already contains everything we want to match) if (p[0].length > 0) { // update current result, which is stored in rx ... // basically, pick up the remaining text from p[1] // and concat the result from p[0] so that we don't // get endless nesting ... rx[0] = rx[0].concat(p[0]); rx[1] = p[1]; } } // at this point, rx either contains the last matched element // or the entire matched set that starts with this element. // now we just check to see if this variation is better than // our best so far, in terms of how much of the input is parsed if (rx[1].length < best[1].length) { best = rx; } // if we've parsed all the input, then we're finished if (best[1].length === 0) { break; } } // so now we've either gone through all the patterns trying them // as the initial match; or we found one that parsed the entire // input string ... // if best has no matches, just return empty set ... if (best[0].length === 0) { return best; } // if a closing delimiter is provided, then we have to check it also if (c) { // we try this even if there is no remaining input because the pattern // may well be optional or match empty input ... try { q = c.call(this, best[1]); } catch (ey) { throw new $P.Exception(best[1]); } // it parsed ... be sure to update the best match remaining input best[1] = q[1]; } // if we're here, either there was no closing delimiter or we parsed it // so now we have the best match; just return it! return best; }; }, forward: function (gr, fname) { return function (s) { return gr[fname].call(this, s); }; }, // // Translation Operators // replace: function (rule, repl) { return function (s) { var r = rule.call(this, s); return [repl, r[1]]; }; }, process: function (rule, fn) { return function (s) { var r = rule.call(this, s); return [fn.call(this, r[0]), r[1]]; }; }, min: function (min, rule) { return function (s) { var rx = rule.call(this, s); if (rx[0].length < min) { throw new $P.Exception(s); } return rx; }; } }; // Generator Operators And Vector Operators // Generators are operators that have a signature of F(R) => R, // taking a given rule and returning another rule, such as // ignore, which parses a given rule and throws away the result. // Vector operators are those that have a signature of F(R1,R2,...) => R, // take a list of rules and returning a new rule, such as each. // Generator operators are converted (via the following _generator // function) into functions that can also take a list or array of rules // and return an array of new rules as though the function had been // called on each rule in turn (which is what actually happens). // This allows generators to be used with vector operators more easily. // Example: // each(ignore(foo, bar)) instead of each(ignore(foo), ignore(bar)) // This also turns generators into vector operators, which allows // constructs like: // not(cache(foo, bar)) var _generator = function (op) { function gen() { var args = null, rx = [], px, i; if (arguments.length > 1) { args = Array.prototype.slice.call(arguments); } else if (arguments[0] instanceof Array) { args = arguments[0]; } if (args) { px = args.shift(); if (px.length > 0) { args.unshift(px[i]); rx.push(op.apply(null, args)); args.shift(); return rx; } } else { return op.apply(null, arguments); } } return gen; }; var gx = "optional not ignore cache".split(/\s/); for (var i = 0 ; i < gx.length ; i++) { _[gx[i]] = _generator(_[gx[i]]); } var _vector = function (op) { return function () { if (arguments[0] instanceof Array) { return op.apply(null, arguments[0]); } else { return op.apply(null, arguments); } }; }; var vx = "each any all".split(/\s/); for (var j = 0 ; j < vx.length ; j++) { _[vx[j]] = _vector(_[vx[j]]); } }()); (function () { var $D = Date; var flattenAndCompact = function (ax) { var rx = []; for (var i = 0; i < ax.length; i++) { if (ax[i] instanceof Array) { rx = rx.concat(flattenAndCompact(ax[i])); } else { if (ax[i]) { rx.push(ax[i]); } } } return rx; }; var parseMeridian = function () { if (this.meridian && (this.hour || this.hour === 0)) { if (this.meridian === "a" && this.hour > 11 && Date.Config.strict24hr){ throw "Invalid hour and meridian combination"; } else if (this.meridian === "p" && this.hour < 12 && Date.Config.strict24hr){ throw "Invalid hour and meridian combination"; } else if (this.meridian === "p" && this.hour < 12) { this.hour = this.hour + 12; } else if (this.meridian === "a" && this.hour === 12) { this.hour = 0; } } }; var setDefaults = function () { var now = new Date(); if ((this.hour || this.minute) && (!this.month && !this.year && !this.day)) { this.day = now.getDate(); } if (!this.year) { this.year = now.getFullYear(); } if (!this.month && this.month !== 0) { this.month = now.getMonth(); } if (!this.day) { this.day = 1; } if (!this.hour) { this.hour = 0; } if (!this.minute) { this.minute = 0; } if (!this.second) { this.second = 0; } if (!this.millisecond) { this.millisecond = 0; } }; var finishUtils = { getToday: function () { if (this.now || "hour minute second".indexOf(this.unit) !== -1) { return new Date(); } else { return $D.today(); } }, setDaysFromWeekday: function (today, orient){ var gap; orient = orient || 1; this.unit = "day"; gap = ($D.getDayNumberFromName(this.weekday) - today.getDay()); this.days = gap ? ((gap + (orient * 7)) % 7) : (orient * 7); return this; }, setMonthsFromMonth: function (today, orient) { var gap; orient = orient || 1; this.unit = "month"; gap = (this.month - today.getMonth()); this.months = gap ? ((gap + (orient * 12)) % 12) : (orient * 12); this.month = null; return this; }, setDMYFromWeekday: function () { var d = Date[this.weekday](); this.day = d.getDate(); if (!this.month) { this.month = d.getMonth(); } this.year = d.getFullYear(); return this; }, setUnitValue: function (orient) { if (!this.value && this.operator && this.operator !== null && this[this.unit + "s"] && this[this.unit + "s"] !== null) { this[this.unit + "s"] = this[this.unit + "s"] + ((this.operator === "add") ? 1 : -1) + (this.value||0) * orient; } else if (this[this.unit + "s"] == null || this.operator != null) { if (!this.value) { this.value = 1; } this[this.unit + "s"] = this.value * orient; } }, generateDateFromWeeks: function () { var weekday = (this.weekday !== undefined) ? this.weekday : "today"; var d = Date[weekday]().addWeeks(this.weeks); if (this.now) { d.setTimeToNow(); } return d; } }; $D.Translator = { hour: function (s) { return function () { this.hour = Number(s); }; }, minute: function (s) { return function () { this.minute = Number(s); }; }, second: function (s) { return function () { this.second = Number(s); }; }, /* for ss.s format */ secondAndMillisecond: function (s) { return function () { var mx = s.match(/^([0-5][0-9])\.([0-9]{1,3})/); this.second = Number(mx[1]); this.millisecond = Number(mx[2]); }; }, meridian: function (s) { return function () { this.meridian = s.slice(0, 1).toLowerCase(); }; }, timezone: function (s) { return function () { var n = s.replace(/[^\d\+\-]/g, ""); if (n.length) { this.timezoneOffset = Number(n); } else { this.timezone = s.toLowerCase(); } }; }, day: function (x) { var s = x[0]; return function () { this.day = Number(s.match(/\d+/)[0]); if (this.day < 1) { throw "invalid day"; } }; }, month: function (s) { return function () { this.month = (s.length === 3) ? "jan feb mar apr may jun jul aug sep oct nov dec".indexOf(s)/4 : Number(s) - 1; if (this.month < 0) { throw "invalid month"; } }; }, year: function (s) { return function () { var n = Number(s); this.year = ((s.length > 2) ? n : (n + (((n + 2000) < Date.CultureInfo.twoDigitYearMax) ? 2000 : 1900))); }; }, rday: function (s) { return function () { switch (s) { case "yesterday": this.days = -1; break; case "tomorrow": this.days = 1; break; case "today": this.days = 0; break; case "now": this.days = 0; this.now = true; break; } }; }, finishExact: function (x) { var d; x = (x instanceof Array) ? x : [x]; for (var i = 0 ; i < x.length ; i++) { if (x[i]) { x[i].call(this); } } setDefaults.call(this); parseMeridian.call(this); if (this.day > $D.getDaysInMonth(this.year, this.month)) { throw new RangeError(this.day + " is not a valid value for days."); } d = new Date(this.year, this.month, this.day, this.hour, this.minute, this.second, this.millisecond); if (this.year < 100) { d.setFullYear(this.year); // means years less that 100 are process correctly. JS will parse it otherwise as 1900-1999. } if (this.timezone) { d.set({ timezone: this.timezone }); } else if (this.timezoneOffset) { d.set({ timezoneOffset: this.timezoneOffset }); } return d; }, finish: function (x) { var today, expression, orient, temp; x = (x instanceof Array) ? flattenAndCompact(x) : [ x ]; if (x.length === 0) { return null; } for (var i = 0 ; i < x.length ; i++) { if (typeof x[i] === "function") { x[i].call(this); } } if (this.now && !this.unit && !this.operator) { return new Date(); } else { today = finishUtils.getToday.call(this); } expression = !!(this.days && this.days !== null || this.orient || this.operator); orient = ((this.orient === "past" || this.operator === "subtract") ? -1 : 1); if (this.month && this.unit === "week") { this.value = this.month + 1; delete this.month; delete this.day; } if ((this.month || this.month === 0) && "year day hour minute second".indexOf(this.unit) !== -1) { if (!this.value) { this.value = this.month + 1; } this.month = null; expression = true; } if (!expression && this.weekday && !this.day && !this.days) { finishUtils.setDMYFromWeekday.call(this); } if (expression && this.weekday && this.unit !== "month" && this.unit !== "week") { finishUtils.setDaysFromWeekday.call(this, today, orient); } if (this.weekday && this.unit !== "week" && !this.day && !this.days) { temp = Date[this.weekday](); this.day = temp.getDate(); if (temp.getMonth() !== today.getMonth()) { this.month = temp.getMonth(); } } if (this.month && this.unit === "day" && this.operator) { if (!this.value) { this.value = (this.month + 1); } this.month = null; } if (this.value != null && this.month != null && this.year != null) { this.day = this.value * 1; } if (this.month && !this.day && this.value) { today.set({ day: this.value * 1 }); if (!expression) { this.day = this.value * 1; } } if (!this.month && this.value && this.unit === "month" && !this.now) { this.month = this.value; expression = true; } if (expression && (this.month || this.month === 0) && this.unit !== "year") { finishUtils.setMonthsFromMonth.call(this, today, orient); } if (!this.unit) { this.unit = "day"; } finishUtils.setUnitValue.call(this, orient); parseMeridian.call(this); if ((this.month || this.month === 0) && !this.day) { this.day = 1; } if (!this.orient && !this.operator && this.unit === "week" && this.value && !this.day && !this.month) { return Date.today().setWeek(this.value); } if (this.unit === "week" && this.weeks && !this.day && !this.month) { return finishUtils.generateDateFromWeeks.call(this); } if (expression && this.timezone && this.day && this.days) { this.day = this.days; } if (expression){ today.add(this); } else { today.set(this); } if (this.timezone) { this.timezone = this.timezone.toUpperCase(); var offset = $D.getTimezoneOffset(this.timezone); var timezone; if (today.hasDaylightSavingTime()) { // lets check that we're being sane with timezone setting timezone = $D.getTimezoneAbbreviation(offset, today.isDaylightSavingTime()); if (timezone !== this.timezone) { // bugger, we're in a place where things like EST vs EDT matters. if (today.isDaylightSavingTime()) { today.addHours(-1); } else { today.addHours(1); } } } today.setTimezoneOffset(offset); } return today; } }; }()); (function () { var $D = Date; $D.Grammar = {}; var _ = $D.Parsing.Operators, g = $D.Grammar, t = $D.Translator, _fn; // Allow rolling up into general purpose rules _fn = function () { return _.each(_.any.apply(null, arguments), _.not(g.ctoken2("timeContext"))); }; g.datePartDelimiter = _.rtoken(/^([\s\-\.\,\/\x27]+)/); g.timePartDelimiter = _.stoken(":"); g.whiteSpace = _.rtoken(/^\s*/); g.generalDelimiter = _.rtoken(/^(([\s\,]|at|@|on)+)/); var _C = {}; g.ctoken = function (keys) { var fn = _C[keys]; if (! fn) { var c = Date.CultureInfo.regexPatterns; var kx = keys.split(/\s+/), px = []; for (var i = 0; i < kx.length ; i++) { px.push(_.replace(_.rtoken(c[kx[i]]), kx[i])); } fn = _C[keys] = _.any.apply(null, px); } return fn; }; g.ctoken2 = function (key) { return _.rtoken(Date.CultureInfo.regexPatterns[key]); }; var cacheProcessRtoken = function (key, token, type, eachToken) { if (eachToken) { g[key] = _.cache(_.process(_.each(_.rtoken(token),_.optional(g.ctoken2(eachToken))), type)); } else { g[key] = _.cache(_.process(_.rtoken(token), type)); } }; var cacheProcessCtoken = function (token, type) { return _.cache(_.process(g.ctoken2(token), type)); }; var _F = {}; //function cache var _get = function (f) { _F[f] = (_F[f] || g.format(f)[0]); return _F[f]; }; g.allformats = function (fx) { var rx = []; if (fx instanceof Array) { for (var i = 0; i < fx.length; i++) { rx.push(_get(fx[i])); } } else { rx.push(_get(fx)); } return rx; }; g.formats = function (fx) { if (fx instanceof Array) { var rx = []; for (var i = 0 ; i < fx.length ; i++) { rx.push(_get(fx[i])); } return _.any.apply(null, rx); } else { return _get(fx); } }; var grammarFormats = { timeFormats: function(){ var i, RTokenKeys = [ "h", "hh", "H", "HH", "m", "mm", "s", "ss", "ss.s", "z", "zz" ], RToken = [ /^(0[0-9]|1[0-2]|[1-9])/, /^(0[0-9]|1[0-2])/, /^([0-1][0-9]|2[0-3]|[0-9])/, /^([0-1][0-9]|2[0-3])/, /^([0-5][0-9]|[0-9])/, /^[0-5][0-9]/, /^([0-5][0-9]|[0-9])/, /^[0-5][0-9]/, /^[0-5][0-9]\.[0-9]{1,3}/, /^((\+|\-)\s*\d\d\d\d)|((\+|\-)\d\d\:?\d\d)/, /^((\+|\-)\s*\d\d\d\d)|((\+|\-)\d\d\:?\d\d)/ ], tokens = [ t.hour, t.hour, t.hour, t.hour, t.minute, t.minute, t.second, t.second, t.secondAndMillisecond, t.timezone, t.timezone ]; for (i=0; i < RTokenKeys.length; i++) { cacheProcessRtoken(RTokenKeys[i], RToken[i], tokens[i]); } g.hms = _.cache(_.sequence([g.H, g.m, g.s], g.timePartDelimiter)); g.t = cacheProcessCtoken("shortMeridian", t.meridian); g.tt = cacheProcessCtoken("longMeridian", t.meridian); g.zzz = cacheProcessCtoken("timezone", t.timezone); g.timeSuffix = _.each(_.ignore(g.whiteSpace), _.set([ g.tt, g.zzz ])); g.time = _.each(_.optional(_.ignore(_.stoken("T"))), g.hms, g.timeSuffix); }, dateFormats: function () { // pre-loaded rules for different date part order preferences var _setfn = function () { return _.set(arguments, g.datePartDelimiter); }; var i, RTokenKeys = [ "d", "dd", "M", "MM", "y", "yy", "yyy", "yyyy" ], RToken = [ /^([0-2]\d|3[0-1]|\d)/, /^([0-2]\d|3[0-1])/, /^(1[0-2]|0\d|\d)/, /^(1[0-2]|0\d)/, /^(\d+)/, /^(\d\d)/, /^(\d\d?\d?\d?)/, /^(\d\d\d\d)/ ], tokens = [ t.day, t.day, t.month, t.month, t.year, t.year, t.year, t.year ], eachToken = [ "ordinalSuffix", "ordinalSuffix" ]; for (i=0; i < RTokenKeys.length; i++) { cacheProcessRtoken(RTokenKeys[i], RToken[i], tokens[i], eachToken[i]); } g.MMM = g.MMMM = _.cache(_.process(g.ctoken("jan feb mar apr may jun jul aug sep oct nov dec"), t.month)); g.ddd = g.dddd = _.cache(_.process(g.ctoken("sun mon tue wed thu fri sat"), function (s) { return function () { this.weekday = s; }; } )); g.day = _fn(g.d, g.dd); g.month = _fn(g.M, g.MMM); g.year = _fn(g.yyyy, g.yy); g.mdy = _setfn(g.ddd, g.month, g.day, g.year); g.ymd = _setfn(g.ddd, g.year, g.month, g.day); g.dmy = _setfn(g.ddd, g.day, g.month, g.year); g.date = function (s) { return ((g[Date.CultureInfo.dateElementOrder] || g.mdy).call(this, s)); }; }, relative: function () { // relative date / time expressions g.orientation = _.process(g.ctoken("past future"), function (s) { return function () { this.orient = s; }; } ); g.operator = _.process(g.ctoken("add subtract"), function (s) { return function () { this.operator = s; }; } ); g.rday = _.process(g.ctoken("yesterday tomorrow today now"), t.rday); g.unit = _.process(g.ctoken("second minute hour day week month year"), function (s) { return function () { this.unit = s; }; } ); } }; g.buildGrammarFormats = function () { // these need to be rebuilt every time the language changes. _C = {}; grammarFormats.timeFormats(); grammarFormats.dateFormats(); grammarFormats.relative(); g.value = _.process(_.rtoken(/^([-+]?\d+)?(st|nd|rd|th)?/), function (s) { return function () { this.value = s.replace(/\D/g, ""); }; } ); g.expression = _.set([g.rday, g.operator, g.value, g.unit, g.orientation, g.ddd, g.MMM ]); g.format = _.process(_.many( _.any( // translate format specifiers into grammar rules _.process( _.rtoken(/^(dd?d?d?(?!e)|MM?M?M?|yy?y?y?|hh?|HH?|mm?|ss?|tt?|zz?z?)/), function (fmt) { if (g[fmt]) { return g[fmt]; } else { throw $D.Parsing.Exception(fmt); } } ), // translate separator tokens into token rules _.process(_.rtoken(/^[^dMyhHmstz]+/), // all legal separators function (s) { return _.ignore(_.stoken(s)); } ) ) ), // construct the parser ... function (rules) { return _.process(_.each.apply(null, rules), t.finishExact); } ); // starting rule for general purpose grammar g._start = _.process(_.set([ g.date, g.time, g.expression ], g.generalDelimiter, g.whiteSpace), t.finish); }; g.buildGrammarFormats(); // parsing date format specifiers - ex: "h:m:s tt" // this little guy will generate a custom parser based // on the format string, ex: g.format("h:m:s tt") // check for these formats first g._formats = g.formats([ "\"yyyy-MM-ddTHH:mm:ssZ\"", "yyyy-MM-ddTHH:mm:ss.sz", "yyyy-MM-ddTHH:mm:ssZ", "yyyy-MM-ddTHH:mm:ssz", "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-ddTHH:mmZ", "yyyy-MM-ddTHH:mmz", "yyyy-MM-ddTHH:mm", "ddd, MMM dd, yyyy H:mm:ss tt", "ddd MMM d yyyy HH:mm:ss zzz", "MMddyyyy", "ddMMyyyy", "Mddyyyy", "ddMyyyy", "Mdyyyy", "dMyyyy", "yyyy", "Mdyy", "dMyy", "d" ]); // real starting rule: tries selected formats first, // then general purpose rule g.start = function (s) { try { var r = g._formats.call({}, s); if (r[1].length === 0) { return r; } } catch (e) {} return g._start.call({}, s); }; }()); (function () { var $D = Date; /** * @desc Converts the specified string value into its JavaScript Date equivalent using CultureInfo specific format information. * * Example

	///////////
	// Dates //
	///////////

	// 15-Oct-2004
	var d1 = Date.parse("10/15/2004");

	// 15-Oct-2004
	var d1 = Date.parse("15-Oct-2004");

	// 15-Oct-2004
	var d1 = Date.parse("2004.10.15");

	//Fri Oct 15, 2004
	var d1 = Date.parse("Fri Oct 15, 2004");

	///////////
	// Times //
	///////////

	// Today at 10 PM.
	var d1 = Date.parse("10 PM");

	// Today at 10:30 PM.
	var d1 = Date.parse("10:30 P.M.");

	// Today at 6 AM.
	var d1 = Date.parse("06am");

	/////////////////////
	// Dates and Times //
	/////////////////////

	// 8-July-2004 @ 10:30 PM
	var d1 = Date.parse("July 8th, 2004, 10:30 PM");

	// 1-July-2004 @ 10:30 PM
	var d1 = Date.parse("2004-07-01T22:30:00");

	////////////////////
	// Relative Dates //
	////////////////////

	// Returns today's date. The string "today" is culture specific.
	var d1 = Date.parse("today");

	// Returns yesterday's date. The string "yesterday" is culture specific.
	var d1 = Date.parse("yesterday");

	// Returns the date of the next thursday.
	var d1 = Date.parse("Next thursday");

	// Returns the date of the most previous monday.
	var d1 = Date.parse("last monday");

	// Returns today's day + one year.
	var d1 = Date.parse("next year");

	///////////////
	// Date Math //
	///////////////

	// Today + 2 days
	var d1 = Date.parse("t+2");

	// Today + 2 days
	var d1 = Date.parse("today + 2 days");

	// Today + 3 months
	var d1 = Date.parse("t+3m");

	// Today - 1 year
	var d1 = Date.parse("today - 1 year");

	// Today - 1 year
	var d1 = Date.parse("t-1y"); 


	/////////////////////////////
	// Partial Dates and Times //
	/////////////////////////////

	// July 15th of this year.
	var d1 = Date.parse("July 15");

	// 15th day of current day and year.
	var d1 = Date.parse("15");

	// July 1st of current year at 10pm.
	var d1 = Date.parse("7/1 10pm");
	
* * @param {String} The string value to convert into a Date object [Required] * @return {Date} A Date object or null if the string cannot be converted into a Date. */ var parseUtils = { removeOrds: function (s) { ords = s.match(/\b(\d+)(?:st|nd|rd|th)\b/); // find ordinal matches s = ((ords && ords.length === 2) ? s.replace(ords[0], ords[1]) : s); return s; }, grammarParser: function (s) { var r = null; try { r = $D.Grammar.start.call({}, s.replace(/^\s*(\S*(\s+\S+)*)\s*$/, "$1")); } catch (e) { return null; } return ((r[1].length === 0) ? r[0] : null); }, nativeFallback: function(s) { var t; try { // ok we haven't parsed it, last ditch attempt with the built-in parser. t = Date._parse(s); return (t || t === 0) ? new Date(t) : null; } catch (e) { return null; } } }; function parse (s) { var d; if (!s) { return null; } if (s instanceof Date) { return s.clone(); } if (s.length >= 4 && s.charAt(0) !== "0" && s.charAt(0) !== "+"&& s.charAt(0) !== "-") { // ie: 2004 will pass, 0800 won't. // Start with specific formats d = $D.Parsing.ISO.parse(s) || $D.Parsing.Numeric.parse(s); } if (d instanceof Date && !isNaN(d.getTime())) { return d; } else { // find ordinal dates (1st, 3rd, 8th, etc and remove them as they cause parsing issues) s = $D.Parsing.Normalizer.parse(parseUtils.removeOrds(s)); d = parseUtils.grammarParser(s); if (d !== null) { return d; } else { return parseUtils.nativeFallback(s); } } } if (!$D._parse) { $D._parse = $D.parse; } $D.parse = parse; Date.getParseFunction = function (fx) { var fns = Date.Grammar.allformats(fx); return function (s) { var r = null; for (var i = 0; i < fns.length; i++) { try { r = fns[i].call({}, s); } catch (e) { continue; } if (r[1].length === 0) { return r[0]; } } return null; }; }; /** * Converts the specified string value into its JavaScript Date equivalent using the specified format {String} or formats {Array} and the CultureInfo specific format information. * The format of the string value must match one of the supplied formats exactly. * * Example

	// 15-Oct-2004
	var d1 = Date.parseExact("10/15/2004", "M/d/yyyy");

	// 15-Oct-2004
	var d1 = Date.parse("15-Oct-2004", "M-ddd-yyyy");

	// 15-Oct-2004
	var d1 = Date.parse("2004.10.15", "yyyy.MM.dd");

	// Multiple formats
	var d1 = Date.parseExact("10/15/2004", ["M/d/yyyy", "MMMM d, yyyy"]);
	
* * @param {String} The string value to convert into a Date object [Required]. * @param {Object} The expected format {String} or an array of expected formats {Array} of the date string [Required]. * @return {Date} A Date object or null if the string cannot be converted into a Date. */ $D.parseExact = function (s, fx) { return $D.getParseFunction(fx)(s); }; }()); (function () { var $D = Date, $P = $D.prototype, // $C = $D.CultureInfo, // not used atm p = function (s, l) { if (!l) { l = 2; } return ("000" + s).slice(l * -1); }; /** * Converts a PHP format string to Java/.NET format string. * A PHP format string can be used with ._format or .format. * A Java/.NET format string can be used with .toString(). * The .parseExact function will only accept a Java/.NET format string * * Example * var f1 = "%m/%d/%y" * var f2 = Date.normalizeFormat(f1); // "MM/dd/yy" * * new Date().format(f1); // "04/13/08" * new Date()._format(f1); // "04/13/08" * new Date().toString(f2); // "04/13/08" * * var date = Date.parseExact("04/13/08", f2); // Sun Apr 13 2008 * * @param {String} A PHP format string consisting of one or more format spcifiers. * @return {String} The PHP format converted to a Java/.NET format string. */ var normalizerSubstitutions = { "d" : "dd", "%d": "dd", "D" : "ddd", "%a": "ddd", "j" : "dddd", "l" : "dddd", "%A": "dddd", "S" : "S", "F" : "MMMM", "%B": "MMMM", "m" : "MM", "%m": "MM", "M" : "MMM", "%b": "MMM", "%h": "MMM", "n" : "M", "Y" : "yyyy", "%Y": "yyyy", "y" : "yy", "%y": "yy", "g" : "h", "%I": "h", "G" : "H", "h" : "hh", "H" : "HH", "%H": "HH", "i" : "mm", "%M": "mm", "s" : "ss", "%S": "ss", "%r": "hh:mm tt", "%R": "H:mm", "%T": "H:mm:ss", "%X": "t", "%x": "d", "%e": "d", "%D": "MM/dd/yy", "%n": "\\n", "%t": "\\t", "e" : "z", "T" : "z", "%z": "z", "%Z": "z", "Z" : "ZZ", "N" : "u", "w" : "u", "%w": "u", "W" : "W", "%V": "W" }; var normalizer = { substitutes: function (m) { return normalizerSubstitutions[m]; }, interpreted: function (m, x) { var y; switch (m) { case "%u": return x.getDay() + 1; case "z": return x.getOrdinalNumber(); case "%j": return p(x.getOrdinalNumber(), 3); case "%U": var d1 = x.clone().set({month: 0, day: 1}).addDays(-1).moveToDayOfWeek(0), d2 = x.clone().addDays(1).moveToDayOfWeek(0, -1); return (d2 < d1) ? "00" : p((d2.getOrdinalNumber() - d1.getOrdinalNumber()) / 7 + 1); case "%W": return p(x.getWeek()); case "t": return $D.getDaysInMonth(x.getFullYear(), x.getMonth()); case "o": case "%G": return x.setWeek(x.getISOWeek()).toString("yyyy"); case "%g": return x._format("%G").slice(-2); case "a": case "%p": return t("tt").toLowerCase(); case "A": return t("tt").toUpperCase(); case "u": return p(x.getMilliseconds(), 3); case "I": return (x.isDaylightSavingTime()) ? 1 : 0; case "O": return x.getUTCOffset(); case "P": y = x.getUTCOffset(); return y.substring(0, y.length - 2) + ":" + y.substring(y.length - 2); case "B": var now = new Date(); return Math.floor(((now.getHours() * 3600) + (now.getMinutes() * 60) + now.getSeconds() + (now.getTimezoneOffset() + 60) * 60) / 86.4); case "c": return x.toISOString().replace(/\"/g, ""); case "U": return $D.strtotime("now"); case "%c": return t("d") + " " + t("t"); case "%C": return Math.floor(x.getFullYear() / 100 + 1); } }, shouldOverrideDefaults: function (m) { switch (m) { case "%e": return true; default: return false; } }, parse: function (m, context) { var formatString, c = context || new Date(); formatString = normalizer.substitutes(m); if (formatString) { return formatString; } formatString = normalizer.interpreted(m, c); if (formatString) { return formatString; } else { return m; } } }; $D.normalizeFormat = function (format, context) { return format.replace(/(%|\\)?.|%%/g, function(t){ return normalizer.parse(t, context); }); }; /** * Format a local Unix timestamp according to locale settings * * Example: * Date.strftime("%m/%d/%y", new Date()); // "04/13/08" * Date.strftime("c", "2008-04-13T17:52:03Z"); // "04/13/08" * * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @param {Number|String} The number representing the number of seconds that have elapsed since January 1, 1970 (local time). * @return {String} A string representation of the current Date object. */ $D.strftime = function (format, time) { var d = Date.parse(time); return d._format(format); }; /** * Parse any textual datetime description into a Unix timestamp. * A Unix timestamp is the number of seconds that have elapsed since January 1, 1970 (midnight UTC/GMT). * * Example: * Date.strtotime("04/13/08"); // 1208044800 * Date.strtotime("1970-01-01T00:00:00Z"); // 0 * * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @param {Object} A string or date object. * @return {String} A string representation of the current Date object. */ $D.strtotime = function (time) { var d = $D.parse(time); return Math.round($D.UTC(d.getUTCFullYear(), d.getUTCMonth(), d.getUTCDate(), d.getUTCHours(), d.getUTCMinutes(), d.getUTCSeconds(), d.getUTCMilliseconds()) / 1000); }; /** * Converts the value of the current Date object to its equivalent string representation using a PHP/Unix style of date format specifiers. * Format Specifiers * Format Description Example * ------ --------------------------------------------------------------------------- ----------------------- * %a abbreviated weekday name according to the current localed "Mon" through "Sun" * %A full weekday name according to the current localed "Sunday" through "Saturday" * %b abbreviated month name according to the current localed "Jan" through "Dec" * %B full month name according to the current locale "January" through "December" * %c preferred date and time representation for the current locale "4/13/2008 12:33 PM" * %C century number (the year divided by 100 and truncated to an integer) "00" to "99" * %d day of the month as a decimal number "01" to "31" * %D same as %m/%d/%y "04/13/08" * %e day of the month as a decimal number, a single digit is preceded by a space "1" to "31" * %g like %G, but without the century "08" * %G The 4-digit year corresponding to the ISO week number (see %V). "2008" * This has the same format and value as %Y, except that if the ISO week number * belongs to the previous or next year, that year is used instead. * %h same as %b "Jan" through "Dec" * %H hour as a decimal number using a 24-hour clock. "00" to "23" * %I hour as a decimal number using a 12-hour clock. "01" to "12" * %j day of the year as a decimal number. "001" to "366" * %m month as a decimal number. "01" to "12" * %M minute as a decimal number. "00" to "59" * %n newline character "\n" * %p either "am" or "pm" according to the given time value, or the "am" or "pm" * corresponding strings for the current locale. * %r time in a.m. and p.m. notation "8:44 PM" * %R time in 24 hour notation "20:44" * %S second as a decimal number "00" to "59" * %t tab character "\t" * %T current time, equal to %H:%M:%S "12:49:11" * %u weekday as a decimal number ["1", "7"], with "1" representing Monday "1" to "7" * %U week number of the current year as a decimal number, starting with the "0" to ("52" or "53") * first Sunday as the first day of the first week * %V The ISO 8601:1988 week number of the current year as a decimal number, "00" to ("52" or "53") * range 01 to 53, where week 1 is the first week that has at least 4 days * in the current year, and with Monday as the first day of the week. * (Use %G or %g for the year component that corresponds to the week number * for the specified timestamp.) * %W week number of the current year as a decimal number, starting with the "00" to ("52" or "53") * first Monday as the first day of the first week * %w day of the week as a decimal, Sunday being "0" "0" to "6" * %x preferred date representation for the current locale without the time "4/13/2008" * %X preferred time representation for the current locale without the date "12:53:05" * %y year as a decimal number without a century "00" "99" * %Y year as a decimal number including the century "2008" * %Z time zone or name or abbreviation "UTC", "EST", "PST" * %z same as %Z * %% a literal "%" characters "%" * d Day of the month, 2 digits with leading zeros "01" to "31" * D A textual representation of a day, three letters "Mon" through "Sun" * j Day of the month without leading zeros "1" to "31" * l A full textual representation of the day of the week (lowercase "L") "Sunday" through "Saturday" * N ISO-8601 numeric representation of the day of the week (added in PHP 5.1.0) "1" (for Monday) through "7" (for Sunday) * S English ordinal suffix for the day of the month, 2 characters "st", "nd", "rd" or "th". Works well with j * w Numeric representation of the day of the week "0" (for Sunday) through "6" (for Saturday) * z The day of the year (starting from "0") "0" through "365" * W ISO-8601 week number of year, weeks starting on Monday "00" to ("52" or "53") * F A full textual representation of a month, such as January or March "January" through "December" * m Numeric representation of a month, with leading zeros "01" through "12" * M A short textual representation of a month, three letters "Jan" through "Dec" * n Numeric representation of a month, without leading zeros "1" through "12" * t Number of days in the given month "28" through "31" * L Whether it's a leap year "1" if it is a leap year, "0" otherwise * o ISO-8601 year number. This has the same value as Y, except that if the "2008" * ISO week number (W) belongs to the previous or next year, that year * is used instead. * Y A full numeric representation of a year, 4 digits "2008" * y A two digit representation of a year "08" * a Lowercase Ante meridiem and Post meridiem "am" or "pm" * A Uppercase Ante meridiem and Post meridiem "AM" or "PM" * B Swatch Internet time "000" through "999" * g 12-hour format of an hour without leading zeros "1" through "12" * G 24-hour format of an hour without leading zeros "0" through "23" * h 12-hour format of an hour with leading zeros "01" through "12" * H 24-hour format of an hour with leading zeros "00" through "23" * i Minutes with leading zeros "00" to "59" * s Seconds, with leading zeros "00" through "59" * u Milliseconds "54321" * e Timezone identifier "UTC", "EST", "PST" * I Whether or not the date is in daylight saving time (uppercase i) "1" if Daylight Saving Time, "0" otherwise * O Difference to Greenwich time (GMT) in hours "+0200", "-0600" * P Difference to Greenwich time (GMT) with colon between hours and minutes "+02:00", "-06:00" * T Timezone abbreviation "UTC", "EST", "PST" * Z Timezone offset in seconds. The offset for timezones west of UTC is "-43200" through "50400" * always negative, and for those east of UTC is always positive. * c ISO 8601 date "2004-02-12T15:19:21+00:00" * r RFC 2822 formatted date "Thu, 21 Dec 2000 16:01:07 +0200" * U Seconds since the Unix Epoch (January 1 1970 00:00:00 GMT) "0" * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @return {String} A string representation of the current Date object. */ var formatReplace = function (context) { return function (m) { var formatString, override = false; if (m.charAt(0) === "\\" || m.substring(0, 2) === "%%") { return m.replace("\\", "").replace("%%", "%"); } override = normalizer.shouldOverrideDefaults(m); formatString = $D.normalizeFormat(m, context); if (formatString) { return context.toString(formatString, override); } }; }; $P._format = function (format) { var formatter = formatReplace(this); if (!format) { return this._toString(); } else { return format.replace(/(%|\\)?.|%%/g, formatter); } }; if (!$P.format) { $P.format = $P._format; } }()); (function () { "use strict"; var gFn = function (attr) { return function () { return this[attr]; }; }; var sFn = function (attr) { return function (val) { this[attr] = val; return this; }; }; var attrs = ["years", "months", "days", "hours", "minutes", "seconds", "milliseconds"]; var addSetFuncs = function (context, attrs) { for (var i = 0; i < attrs.length ; i++) { var $a = attrs[i], $b = $a.slice(0, 1).toUpperCase() + $a.slice(1); context.prototype[$a] = 0; context.prototype["get" + $b] = gFn($a); context.prototype["set" + $b] = sFn($a); } }; /** * new TimeSpan(milliseconds); * new TimeSpan(days, hours, minutes, seconds); * new TimeSpan(days, hours, minutes, seconds, milliseconds); */ var TimeSpan = function (days, hours, minutes, seconds, milliseconds) { if (arguments.length === 1 && typeof days === "number") { var orient = (days < 0) ? -1 : +1; var millsLeft = Math.abs(days); this.setDays(Math.floor(millsLeft / 86400000) * orient); millsLeft = millsLeft % 86400000; this.setHours(Math.floor(millsLeft / 3600000) * orient); millsLeft = millsLeft % 3600000; this.setMinutes(Math.floor(millsLeft / 60000) * orient); millsLeft = millsLeft % 60000; this.setSeconds(Math.floor(millsLeft / 1000) * orient); millsLeft = millsLeft % 1000; this.setMilliseconds(millsLeft * orient); } else { this.set(days, hours, minutes, seconds, milliseconds); } this.getTotalMilliseconds = function () { return (this.getDays() * 86400000) + (this.getHours() * 3600000) + (this.getMinutes() * 60000) + (this.getSeconds() * 1000); }; this.compareTo = function (time) { var t1 = new Date(1970, 1, 1, this.getHours(), this.getMinutes(), this.getSeconds()), t2; if (time === null) { t2 = new Date(1970, 1, 1, 0, 0, 0); } else { t2 = new Date(1970, 1, 1, time.getHours(), time.getMinutes(), time.getSeconds()); } return (t1 < t2) ? -1 : (t1 > t2) ? 1 : 0; }; this.equals = function (time) { return (this.compareTo(time) === 0); }; this.add = function (time) { return (time === null) ? this : this.addSeconds(time.getTotalMilliseconds() / 1000); }; this.subtract = function (time) { return (time === null) ? this : this.addSeconds(-time.getTotalMilliseconds() / 1000); }; this.addDays = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 86400000)); }; this.addHours = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 3600000)); }; this.addMinutes = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 60000)); }; this.addSeconds = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 1000)); }; this.addMilliseconds = function (n) { return new TimeSpan(this.getTotalMilliseconds() + n); }; this.get12HourHour = function () { return (this.getHours() > 12) ? this.getHours() - 12 : (this.getHours() === 0) ? 12 : this.getHours(); }; this.getDesignator = function () { return (this.getHours() < 12) ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator; }; this.toString = function (format) { this._toString = function () { if (this.getDays() !== null && this.getDays() > 0) { return this.getDays() + "." + this.getHours() + ":" + this.p(this.getMinutes()) + ":" + this.p(this.getSeconds()); } else { return this.getHours() + ":" + this.p(this.getMinutes()) + ":" + this.p(this.getSeconds()); } }; this.p = function (s) { return (s.toString().length < 2) ? "0" + s : s; }; var me = this; return format ? format.replace(/dd?|HH?|hh?|mm?|ss?|tt?/g, function (format) { switch (format) { case "d": return me.getDays(); case "dd": return me.p(me.getDays()); case "H": return me.getHours(); case "HH": return me.p(me.getHours()); case "h": return me.get12HourHour(); case "hh": return me.p(me.get12HourHour()); case "m": return me.getMinutes(); case "mm": return me.p(me.getMinutes()); case "s": return me.getSeconds(); case "ss": return me.p(me.getSeconds()); case "t": return ((me.getHours() < 12) ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator).substring(0, 1); case "tt": return (me.getHours() < 12) ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator; } } ) : this._toString(); }; return this; }; addSetFuncs(TimeSpan, attrs.slice(2)); TimeSpan.prototype.set = function (days, hours, minutes, seconds, milliseconds){ this.setDays(days || this.getDays()); this.setHours(hours || this.getHours()); this.setMinutes(minutes || this.getMinutes()); this.setSeconds(seconds || this.getSeconds()); this.setMilliseconds(milliseconds || this.getMilliseconds()); }; /** * Gets the time of day for this date instances. * @return {TimeSpan} TimeSpan */ Date.prototype.getTimeOfDay = function () { return new TimeSpan(0, this.getHours(), this.getMinutes(), this.getSeconds(), this.getMilliseconds()); }; Date.TimeSpan = TimeSpan; if (typeof window !== "undefined" ) { // keeping API compatible for v1.x window.TimeSpan = TimeSpan; } }()); (function () { "use strict"; var attrs = ["years", "months", "days", "hours", "minutes", "seconds", "milliseconds"]; var gFn = function (attr) { return function () { return this[attr]; }; }; var sFn = function (attr) { return function (val) { this[attr] = val; return this; }; }; var addSetFuncs = function (context, attrs) { for (var i = 0; i < attrs.length ; i++) { var $a = attrs[i], $b = $a.slice(0, 1).toUpperCase() + $a.slice(1); context.prototype[$a] = 0; context.prototype["get" + $b] = gFn($a); context.prototype["set" + $b] = sFn($a); } }; var setMonthsAndYears = function (orient, d1, d2, context) { function inc() { d1.addMonths(-orient); context.months++; if (context.months === 12) { context.years++; context.months = 0; } } if (orient === +1) { while (d1 > d2) { inc(); } } else { while (d1 < d2) { inc(); } } context.months--; context.months *= orient; context.years *= orient; }; var adjustForDST = function(orient, startDate, endDate) { var hasDSTMismatch = (false === (startDate.isDaylightSavingTime() === endDate.isDaylightSavingTime())); if (hasDSTMismatch && orient === 1) { startDate.addHours(-1); } else if (hasDSTMismatch) { startDate.addHours(1); } }; /** * TimePeriod(startDate, endDate); * TimePeriod(years, months, days, hours, minutes, seconds, milliseconds); */ var TimePeriod = function (years, months, days, hours, minutes, seconds, milliseconds) { if (arguments.length === 7) { this.set(years, months, days, hours, minutes, seconds, milliseconds); } else if (arguments.length === 2 && arguments[0] instanceof Date && arguments[1] instanceof Date) { var startDate = arguments[0].clone(); var endDate = arguments[1].clone(); var orient = (startDate > endDate) ? +1 : -1; this.dates = { start: arguments[0].clone(), end: arguments[1].clone() }; setMonthsAndYears(orient, startDate, endDate, this); adjustForDST(orient, startDate, endDate); // // TODO - adjust for DST var diff = endDate - startDate; if (diff !== 0) { var ts = new TimeSpan(diff); this.set(this.years, this.months, ts.getDays(), ts.getHours(), ts.getMinutes(), ts.getSeconds(), ts.getMilliseconds()); } } return this; }; // create all the set functions. addSetFuncs(TimePeriod, attrs); TimePeriod.prototype.set = function (years, months, days, hours, minutes, seconds, milliseconds){ this.setYears(years || this.getYears()); this.setMonths(months || this.getMonths()); this.setDays(days || this.getDays()); this.setHours(hours || this.getHours()); this.setMinutes(minutes || this.getMinutes()); this.setSeconds(seconds || this.getSeconds()); this.setMilliseconds(milliseconds || this.getMilliseconds()); }; Date.TimePeriod = TimePeriod; if (typeof window !== "undefined") { // keeping API compatible for v1.x window.TimePeriod = TimePeriod; } }()); ================================================ FILE: build/date-en-NZ.js ================================================ /** * @overview datejs * @version 1.0.0-rc3 * @author Gregory Wild-Smith * @copyright 2015 Gregory Wild-Smith * @license MIT * @homepage https://github.com/abritinthebay/datejs */ /* * DateJS Culture String File * Country Code: en-NZ * Name: English (New Zealand) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["en-NZ"] = { "name": "en-NZ", "englishName": "English (New Zealand)", "nativeName": "English (New Zealand)", "Sunday": "Sunday", "Monday": "Monday", "Tuesday": "Tuesday", "Wednesday": "Wednesday", "Thursday": "Thursday", "Friday": "Friday", "Saturday": "Saturday", "Sun": "Sun", "Mon": "Mon", "Tue": "Tue", "Wed": "Wed", "Thu": "Thu", "Fri": "Fri", "Sat": "Sat", "Su": "Su", "Mo": "Mo", "Tu": "Tu", "We": "We", "Th": "Th", "Fr": "Fr", "Sa": "Sa", "S_Sun_Initial": "S", "M_Mon_Initial": "M", "T_Tue_Initial": "T", "W_Wed_Initial": "W", "T_Thu_Initial": "T", "F_Fri_Initial": "F", "S_Sat_Initial": "S", "January": "January", "February": "February", "March": "March", "April": "April", "May": "May", "June": "June", "July": "July", "August": "August", "September": "September", "October": "October", "November": "November", "December": "December", "Jan_Abbr": "Jan", "Feb_Abbr": "Feb", "Mar_Abbr": "Mar", "Apr_Abbr": "Apr", "May_Abbr": "May", "Jun_Abbr": "Jun", "Jul_Abbr": "Jul", "Aug_Abbr": "Aug", "Sep_Abbr": "Sep", "Oct_Abbr": "Oct", "Nov_Abbr": "Nov", "Dec_Abbr": "Dec", "AM": "a.m.", "PM": "p.m.", "firstDayOfWeek": 1, "twoDigitYearMax": 2029, "mdy": "dmy", "M/d/yyyy": "d/MM/yyyy", "dddd, MMMM dd, yyyy": "dddd, d MMMM yyyy", "h:mm tt": "h:mm tt", "h:mm:ss tt": "h:mm:ss tt", "dddd, MMMM dd, yyyy h:mm:ss tt": "dddd, d MMMM yyyy h:mm:ss tt", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "dd MMMM", "MMMM, yyyy": "MMMM yyyy", "/jan(uary)?/": "jan(uary)?", "/feb(ruary)?/": "feb(ruary)?", "/mar(ch)?/": "mar(ch)?", "/apr(il)?/": "apr(il)?", "/may/": "may", "/jun(e)?/": "jun(e)?", "/jul(y)?/": "jul(y)?", "/aug(ust)?/": "aug(ust)?", "/sep(t(ember)?)?/": "sep(t(ember)?)?", "/oct(ober)?/": "oct(ober)?", "/nov(ember)?/": "nov(ember)?", "/dec(ember)?/": "dec(ember)?", "/^su(n(day)?)?/": "^su(n(day)?)?", "/^mo(n(day)?)?/": "^mo(n(day)?)?", "/^tu(e(s(day)?)?)?/": "^tu(e(s(day)?)?)?", "/^we(d(nesday)?)?/": "^we(d(nesday)?)?", "/^th(u(r(s(day)?)?)?)?/": "^th(u(r(s(day)?)?)?)?", "/^fr(i(day)?)?/": "^fr(i(day)?)?", "/^sa(t(urday)?)?/": "^sa(t(urday)?)?", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "en-NZ"; /** * @overview datejs * @version 1.0.0-rc3 * @author Gregory Wild-Smith * @copyright 2015 Gregory Wild-Smith * @license MIT * @homepage https://github.com/abritinthebay/datejs */(function () { var $D = Date; var lang = Date.CultureStrings ? Date.CultureStrings.lang : null; var loggedKeys = {}; // for debug purposes. var getText = { getFromKey: function (key, countryCode) { var output; if (Date.CultureStrings && Date.CultureStrings[countryCode] && Date.CultureStrings[countryCode][key]) { output = Date.CultureStrings[countryCode][key]; } else { output = getText.buildFromDefault(key); } if (key.charAt(0) === "/") { // Assume it's a regex output = getText.buildFromRegex(key, countryCode); } return output; }, getFromObjectValues: function (obj, countryCode) { var key, output = {}; for(key in obj) { if (obj.hasOwnProperty(key)) { output[key] = getText.getFromKey(obj[key], countryCode); } } return output; }, getFromObjectKeys: function (obj, countryCode) { var key, output = {}; for(key in obj) { if (obj.hasOwnProperty(key)) { output[getText.getFromKey(key, countryCode)] = obj[key]; } } return output; }, getFromArray: function (arr, countryCode) { var output = []; for (var i=0; i < arr.length; i++){ if (i in arr) { output[i] = getText.getFromKey(arr[i], countryCode); } } return output; }, buildFromDefault: function (key) { var output, length, split, last; switch(key) { case "name": output = "en-US"; break; case "englishName": output = "English (United States)"; break; case "nativeName": output = "English (United States)"; break; case "twoDigitYearMax": output = 2049; break; case "firstDayOfWeek": output = 0; break; default: output = key; split = key.split("_"); length = split.length; if (length > 1 && key.charAt(0) !== "/") { // if the key isn't a regex and it has a split. last = split[(length - 1)].toLowerCase(); if (last === "initial" || last === "abbr") { output = split[0]; } } break; } return output; }, buildFromRegex: function (key, countryCode) { var output; if (Date.CultureStrings && Date.CultureStrings[countryCode] && Date.CultureStrings[countryCode][key]) { output = new RegExp(Date.CultureStrings[countryCode][key], "i"); } else { output = new RegExp(key.replace(new RegExp("/", "g"),""), "i"); } return output; } }; var shallowMerge = function (obj1, obj2) { for (var attrname in obj2) { if (obj2.hasOwnProperty(attrname)) { obj1[attrname] = obj2[attrname]; } } }; var __ = function (key, language) { var countryCode = (language) ? language : lang; loggedKeys[key] = key; if (typeof key === "object") { if (key instanceof Array) { return getText.getFromArray(key, countryCode); } else { return getText.getFromObjectKeys(key, countryCode); } } else { return getText.getFromKey(key, countryCode); } }; var loadI18nScript = function (code) { // paatterned after jQuery's getScript. var url = Date.Config.i18n + code + ".js"; var head = document.getElementsByTagName("head")[0] || document.documentElement; var script = document.createElement("script"); script.src = url; var completed = false; var events = { done: function (){} // placeholder function }; // Attach handlers for all browsers script.onload = script.onreadystatechange = function() { if ( !completed && (!this.readyState || this.readyState === "loaded" || this.readyState === "complete") ) { events.done(); head.removeChild(script); } }; setTimeout(function() { head.insertBefore(script, head.firstChild); }, 0); // allows return to execute first return { done: function (cb) { events.done = function() { if (cb) { setTimeout(cb,0); } }; } }; }; var buildInfo = { buildFromMethodHash: function (obj) { var key; for(key in obj) { if (obj.hasOwnProperty(key)) { obj[key] = buildInfo[obj[key]](); } } return obj; }, timeZoneDST: function () { var DST = { "CHADT": "+1345", "NZDT": "+1300", "AEDT": "+1100", "ACDT": "+1030", "AZST": "+0500", "IRDT": "+0430", "EEST": "+0300", "CEST": "+0200", "BST": "+0100", "PMDT": "-0200", "ADT": "-0300", "NDT": "-0230", "EDT": "-0400", "CDT": "-0500", "MDT": "-0600", "PDT": "-0700", "AKDT": "-0800", "HADT": "-0900" }; return __(DST); }, timeZoneStandard: function () { var standard = { "LINT": "+1400", "TOT": "+1300", "CHAST": "+1245", "NZST": "+1200", "NFT": "+1130", "SBT": "+1100", "AEST": "+1000", "ACST": "+0930", "JST": "+0900", "CWST": "+0845", "CT": "+0800", "ICT": "+0700", "MMT": "+0630", "BST": "+0600", "NPT": "+0545", "IST": "+0530", "PKT": "+0500", "AFT": "+0430", "MSK": "+0400", "IRST": "+0330", "FET": "+0300", "EET": "+0200", "CET": "+0100", "GMT": "+0000", "UTC": "+0000", "CVT": "-0100", "GST": "-0200", "BRT": "-0300", "NST": "-0330", "AST": "-0400", "EST": "-0500", "CST": "-0600", "MST": "-0700", "PST": "-0800", "AKST": "-0900", "MIT": "-0930", "HST": "-1000", "SST": "-1100", "BIT": "-1200" }; return __(standard); }, timeZones: function (data) { var zone; data.timezones = []; for (zone in data.abbreviatedTimeZoneStandard) { if (data.abbreviatedTimeZoneStandard.hasOwnProperty(zone)) { data.timezones.push({ name: zone, offset: data.abbreviatedTimeZoneStandard[zone]}); } } for (zone in data.abbreviatedTimeZoneDST) { if (data.abbreviatedTimeZoneDST.hasOwnProperty(zone)) { data.timezones.push({ name: zone, offset: data.abbreviatedTimeZoneDST[zone], dst: true}); } } return data.timezones; }, days: function () { return __(["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"]); }, dayAbbr: function () { return __(["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"]); }, dayShortNames: function () { return __(["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"]); }, dayFirstLetters: function () { return __(["S_Sun_Initial", "M_Mon_Initial", "T_Tues_Initial", "W_Wed_Initial", "T_Thu_Initial", "F_Fri_Initial", "S_Sat_Initial"]); }, months: function () { return __(["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"]); }, monthAbbr: function () { return __(["Jan_Abbr", "Feb_Abbr", "Mar_Abbr", "Apr_Abbr", "May_Abbr", "Jun_Abbr", "Jul_Abbr", "Aug_Abbr", "Sep_Abbr", "Oct_Abbr", "Nov_Abbr", "Dec_Abbr"]); }, formatPatterns: function () { return getText.getFromObjectValues({ shortDate: "M/d/yyyy", longDate: "dddd, MMMM dd, yyyy", shortTime: "h:mm tt", longTime: "h:mm:ss tt", fullDateTime: "dddd, MMMM dd, yyyy h:mm:ss tt", sortableDateTime: "yyyy-MM-ddTHH:mm:ss", universalSortableDateTime: "yyyy-MM-dd HH:mm:ssZ", rfc1123: "ddd, dd MMM yyyy HH:mm:ss", monthDay: "MMMM dd", yearMonth: "MMMM, yyyy" }, Date.i18n.currentLanguage()); }, regex: function () { return getText.getFromObjectValues({ inTheMorning: "/( in the )(morn(ing)?)\\b/", thisMorning: "/(this )(morn(ing)?)\\b/", amThisMorning: "/(\b\\d(am)? )(this )(morn(ing)?)/", inTheEvening: "/( in the )(even(ing)?)\\b/", thisEvening: "/(this )(even(ing)?)\\b/", pmThisEvening: "/(\b\\d(pm)? )(this )(even(ing)?)/", jan: "/jan(uary)?/", feb: "/feb(ruary)?/", mar: "/mar(ch)?/", apr: "/apr(il)?/", may: "/may/", jun: "/jun(e)?/", jul: "/jul(y)?/", aug: "/aug(ust)?/", sep: "/sep(t(ember)?)?/", oct: "/oct(ober)?/", nov: "/nov(ember)?/", dec: "/dec(ember)?/", sun: "/^su(n(day)?)?/", mon: "/^mo(n(day)?)?/", tue: "/^tu(e(s(day)?)?)?/", wed: "/^we(d(nesday)?)?/", thu: "/^th(u(r(s(day)?)?)?)?/", fri: "/fr(i(day)?)?/", sat: "/^sa(t(urday)?)?/", future: "/^next/", past: "/^last|past|prev(ious)?/", add: "/^(\\+|aft(er)?|from|hence)/", subtract: "/^(\\-|bef(ore)?|ago)/", yesterday: "/^yes(terday)?/", today: "/^t(od(ay)?)?/", tomorrow: "/^tom(orrow)?/", now: "/^n(ow)?/", millisecond: "/^ms|milli(second)?s?/", second: "/^sec(ond)?s?/", minute: "/^mn|min(ute)?s?/", hour: "/^h(our)?s?/", week: "/^w(eek)?s?/", month: "/^m(onth)?s?/", day: "/^d(ay)?s?/", year: "/^y(ear)?s?/", shortMeridian: "/^(a|p)/", longMeridian: "/^(a\\.?m?\\.?|p\\.?m?\\.?)/", timezone: "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/", ordinalSuffix: "/^\\s*(st|nd|rd|th)/", timeContext: "/^\\s*(\\:|a(?!u|p)|p)/" }, Date.i18n.currentLanguage()); } }; var CultureInfo = function () { var info = getText.getFromObjectValues({ name: "name", englishName: "englishName", nativeName: "nativeName", amDesignator: "AM", pmDesignator: "PM", firstDayOfWeek: "firstDayOfWeek", twoDigitYearMax: "twoDigitYearMax", dateElementOrder: "mdy" }, Date.i18n.currentLanguage()); var constructedInfo = buildInfo.buildFromMethodHash({ dayNames: "days", abbreviatedDayNames: "dayAbbr", shortestDayNames: "dayShortNames", firstLetterDayNames: "dayFirstLetters", monthNames: "months", abbreviatedMonthNames: "monthAbbr", formatPatterns: "formatPatterns", regexPatterns: "regex", abbreviatedTimeZoneDST: "timeZoneDST", abbreviatedTimeZoneStandard: "timeZoneStandard" }); shallowMerge(info, constructedInfo); buildInfo.timeZones(info); return info; }; $D.i18n = { __: function (key, lang) { return __(key, lang); }, currentLanguage: function () { return lang || "en-US"; }, setLanguage: function (code, force, cb) { var async = false; if (force || code === "en-US" || (!!Date.CultureStrings && !!Date.CultureStrings[code])) { lang = code; Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings.lang = code; Date.CultureInfo = new CultureInfo(); } else { if (!(!!Date.CultureStrings && !!Date.CultureStrings[code])) { if (typeof exports !== "undefined" && this.exports !== exports) { // we're in a Node enviroment, load it using require try { require("../i18n/" + code + ".js"); lang = code; Date.CultureStrings.lang = code; Date.CultureInfo = new CultureInfo(); } catch (e) { // var str = "The language for '" + code + "' could not be loaded by Node. It likely does not exist."; throw new Error("The DateJS IETF language tag '" + code + "' could not be loaded by Node. It likely does not exist."); } } else if (Date.Config && Date.Config.i18n) { // we know the location of the files, so lets load them async = true; loadI18nScript(code).done(function(){ lang = code; Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings.lang = code; Date.CultureInfo = new CultureInfo(); $D.Parsing.Normalizer.buildReplaceData(); // because this is async if ($D.Grammar) { $D.Grammar.buildGrammarFormats(); // so we can parse those strings... } if (cb) { setTimeout(cb,0); } }); } else { Date.console.error("The DateJS IETF language tag '" + code + "' is not available and has not been loaded."); return false; } } } $D.Parsing.Normalizer.buildReplaceData(); // rebuild normalizer strings if ($D.Grammar) { $D.Grammar.buildGrammarFormats(); // so we can parse those strings... } if (!async && cb) { setTimeout(cb,0); } }, getLoggedKeys: function () { return loggedKeys; }, updateCultureInfo: function () { Date.CultureInfo = new CultureInfo(); } }; $D.i18n.updateCultureInfo(); // run automatically }()); (function () { var $D = Date, $P = $D.prototype, p = function (s, l) { if (!l) { l = 2; } return ("000" + s).slice(l * -1); }; if (typeof window !== "undefined" && typeof window.console !== "undefined" && typeof window.console.log !== "undefined") { $D.console = console; // used only to raise non-critical errors if available } else { // set mock so we don't give errors. $D.console = { log: function(){}, error: function(){} }; } $D.Config = $D.Config || {}; $D.initOverloads = function() { /** * Overload of Date.now. Allows an alternate call for Date.now where it returns the * current Date as an object rather than just milliseconds since the Unix Epoch. * * Also provides an implementation of now() for browsers (IE<9) that don't have it. * * Backwards compatible so with work with either: * Date.now() [returns ms] * or * Date.now(true) [returns Date] */ if (!$D.now) { $D._now = function now() { return new Date().getTime(); }; } else if (!$D._now) { $D._now = $D.now; } $D.now = function (returnObj) { if (returnObj) { return $D.present(); } else { return $D._now(); } }; if ( !$P.toISOString ) { $P.toISOString = function() { return this.getUTCFullYear() + "-" + p(this.getUTCMonth() + 1) + "-" + p(this.getUTCDate()) + "T" + p(this.getUTCHours()) + ":" + p(this.getUTCMinutes()) + ":" + p(this.getUTCSeconds()) + "." + String( (this.getUTCMilliseconds()/1000).toFixed(3)).slice(2, 5) + "Z"; }; } // private if ( $P._toString === undefined ){ $P._toString = $P.toString; } }; $D.initOverloads(); /** * Gets a date that is set to the current date. The time is set to the start of the day (00:00 or 12:00 AM). * @return {Date} The current date. */ $D.today = function () { return new Date().clearTime(); }; /** * Gets a date that is set to the current date and time (same as new Date, but chainable) * @return {Date} The current date. */ $D.present = function () { return new Date(); }; /** * Compares the first date to the second date and returns an number indication of their relative values. * @param {Date} First Date object to compare [Required]. * @param {Date} Second Date object to compare to [Required]. * @return {Number} -1 = date1 is lessthan date2. 0 = values are equal. 1 = date1 is greaterthan date2. */ $D.compare = function (date1, date2) { if (isNaN(date1) || isNaN(date2)) { throw new Error(date1 + " - " + date2); } else if (date1 instanceof Date && date2 instanceof Date) { return (date1 < date2) ? -1 : (date1 > date2) ? 1 : 0; } else { throw new TypeError(date1 + " - " + date2); } }; /** * Compares the first Date object to the second Date object and returns true if they are equal. * @param {Date} First Date object to compare [Required] * @param {Date} Second Date object to compare to [Required] * @return {Boolean} true if dates are equal. false if they are not equal. */ $D.equals = function (date1, date2) { return (date1.compareTo(date2) === 0); }; /** * Gets the language appropriate day name when given the day number(0-6) * eg - 0 == Sunday * @return {String} The day name */ $D.getDayName = function (n) { return Date.CultureInfo.dayNames[n]; }; /** * Gets the day number (0-6) if given a CultureInfo specific string which is a valid dayName, abbreviatedDayName or shortestDayName (two char). * @param {String} The name of the day (eg. "Monday, "Mon", "tuesday", "tue", "We", "we"). * @return {Number} The day number */ $D.getDayNumberFromName = function (name) { var n = Date.CultureInfo.dayNames, m = Date.CultureInfo.abbreviatedDayNames, o = Date.CultureInfo.shortestDayNames, s = name.toLowerCase(); for (var i = 0; i < n.length; i++) { if (n[i].toLowerCase() === s || m[i].toLowerCase() === s || o[i].toLowerCase() === s) { return i; } } return -1; }; /** * Gets the month number (0-11) if given a Culture Info specific string which is a valid monthName or abbreviatedMonthName. * @param {String} The name of the month (eg. "February, "Feb", "october", "oct"). * @return {Number} The day number */ $D.getMonthNumberFromName = function (name) { var n = Date.CultureInfo.monthNames, m = Date.CultureInfo.abbreviatedMonthNames, s = name.toLowerCase(); for (var i = 0; i < n.length; i++) { if (n[i].toLowerCase() === s || m[i].toLowerCase() === s) { return i; } } return -1; }; /** * Gets the language appropriate month name when given the month number(0-11) * eg - 0 == January * @return {String} The month name */ $D.getMonthName = function (n) { return Date.CultureInfo.monthNames[n]; }; /** * Determines if the current date instance is within a LeapYear. * @param {Number} The year. * @return {Boolean} true if date is within a LeapYear, otherwise false. */ $D.isLeapYear = function (year) { return ((year % 4 === 0 && year % 100 !== 0) || year % 400 === 0); }; /** * Gets the number of days in the month, given a year and month value. Automatically corrects for LeapYear. * @param {Number} The year. * @param {Number} The month (0-11). * @return {Number} The number of days in the month. */ $D.getDaysInMonth = function (year, month) { if (!month && $D.validateMonth(year)) { month = year; year = Date.today().getFullYear(); } return [31, ($D.isLeapYear(year) ? 29 : 28), 31, 30, 31, 30, 31, 31, 30, 31, 30, 31][month]; }; $P.getDaysInMonth = function () { return $D.getDaysInMonth(this.getFullYear(), this.getMonth()); }; $D.getTimezoneAbbreviation = function (offset, dst) { var p, n = (dst || false) ? Date.CultureInfo.abbreviatedTimeZoneDST : Date.CultureInfo.abbreviatedTimeZoneStandard; for (p in n) { if (n.hasOwnProperty(p)) { if (n[p] === offset) { return p; } } } return null; }; $D.getTimezoneOffset = function (name, dst) { var i, a =[], z = Date.CultureInfo.timezones; if (!name) { name = (new Date()).getTimezone();} for (i = 0; i < z.length; i++) { if (z[i].name === name.toUpperCase()) { a.push(i); } } if (!z[a[0]]) { return null; } if (a.length === 1 || !dst) { return z[a[0]].offset; } else { for (i=0; i < a.length; i++) { if (z[a[i]].dst) { return z[a[i]].offset; } } } }; $D.getQuarter = function (d) { d = d || new Date(); // If no date supplied, use today var q = [1,2,3,4]; return q[Math.floor(d.getMonth() / 3)]; // ~~~ is a bitwise op. Faster than Math.floor }; $D.getDaysLeftInQuarter = function (d) { d = d || new Date(); var qEnd = new Date(d); qEnd.setMonth(qEnd.getMonth() + 3 - qEnd.getMonth() % 3, 0); return Math.floor((qEnd - d) / 8.64e7); }; // private var validate = function (n, min, max, name) { name = name ? name : "Object"; if (typeof n === "undefined") { return false; } else if (typeof n !== "number") { throw new TypeError(n + " is not a Number."); } else if (n < min || n > max) { // As failing validation is *not* an exceptional circumstance // lets not throw a RangeError Exception here. // It's semantically correct but it's not sensible. return false; } return true; }; /** * Validates the number is within an acceptable range for milliseconds [0-999]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateMillisecond = function (value) { return validate(value, 0, 999, "millisecond"); }; /** * Validates the number is within an acceptable range for seconds [0-59]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateSecond = function (value) { return validate(value, 0, 59, "second"); }; /** * Validates the number is within an acceptable range for minutes [0-59]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateMinute = function (value) { return validate(value, 0, 59, "minute"); }; /** * Validates the number is within an acceptable range for hours [0-23]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateHour = function (value) { return validate(value, 0, 23, "hour"); }; /** * Validates the number is within an acceptable range for the days in a month [0-MaxDaysInMonth]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateDay = function (value, year, month) { if (year === undefined || year === null || month === undefined || month === null) { return false;} return validate(value, 1, $D.getDaysInMonth(year, month), "day"); }; /** * Validates the number is within an acceptable range for months [0-11]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateWeek = function (value) { return validate(value, 0, 53, "week"); }; /** * Validates the number is within an acceptable range for months [0-11]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateMonth = function (value) { return validate(value, 0, 11, "month"); }; /** * Validates the number is within an acceptable range for years. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateYear = function (value) { /** * Per ECMAScript spec the range of times supported by Date objects is * exactly -100,000,000 days to +100,000,000 days measured relative to * midnight at the beginning of 01 January, 1970 UTC. * This gives a range of 8,640,000,000,000,000 milliseconds to either * side of 01 January, 1970 UTC. * * Earliest possible date: Tue, 20 Apr 271,822 B.C. 00:00:00 UTC * Latest possible date: Sat, 13 Sep 275,760 00:00:00 UTC */ return validate(value, -271822, 275760, "year"); }; $D.validateTimezone = function(value) { var timezones = {"ACDT":1,"ACST":1,"ACT":1,"ADT":1,"AEDT":1,"AEST":1,"AFT":1,"AKDT":1,"AKST":1,"AMST":1,"AMT":1,"ART":1,"AST":1,"AWDT":1,"AWST":1,"AZOST":1,"AZT":1,"BDT":1,"BIOT":1,"BIT":1,"BOT":1,"BRT":1,"BST":1,"BTT":1,"CAT":1,"CCT":1,"CDT":1,"CEDT":1,"CEST":1,"CET":1,"CHADT":1,"CHAST":1,"CHOT":1,"ChST":1,"CHUT":1,"CIST":1,"CIT":1,"CKT":1,"CLST":1,"CLT":1,"COST":1,"COT":1,"CST":1,"CT":1,"CVT":1,"CWST":1,"CXT":1,"DAVT":1,"DDUT":1,"DFT":1,"EASST":1,"EAST":1,"EAT":1,"ECT":1,"EDT":1,"EEDT":1,"EEST":1,"EET":1,"EGST":1,"EGT":1,"EIT":1,"EST":1,"FET":1,"FJT":1,"FKST":1,"FKT":1,"FNT":1,"GALT":1,"GAMT":1,"GET":1,"GFT":1,"GILT":1,"GIT":1,"GMT":1,"GST":1,"GYT":1,"HADT":1,"HAEC":1,"HAST":1,"HKT":1,"HMT":1,"HOVT":1,"HST":1,"ICT":1,"IDT":1,"IOT":1,"IRDT":1,"IRKT":1,"IRST":1,"IST":1,"JST":1,"KGT":1,"KOST":1,"KRAT":1,"KST":1,"LHST":1,"LINT":1,"MAGT":1,"MART":1,"MAWT":1,"MDT":1,"MET":1,"MEST":1,"MHT":1,"MIST":1,"MIT":1,"MMT":1,"MSK":1,"MST":1,"MUT":1,"MVT":1,"MYT":1,"NCT":1,"NDT":1,"NFT":1,"NPT":1,"NST":1,"NT":1,"NUT":1,"NZDT":1,"NZST":1,"OMST":1,"ORAT":1,"PDT":1,"PET":1,"PETT":1,"PGT":1,"PHOT":1,"PHT":1,"PKT":1,"PMDT":1,"PMST":1,"PONT":1,"PST":1,"PYST":1,"PYT":1,"RET":1,"ROTT":1,"SAKT":1,"SAMT":1,"SAST":1,"SBT":1,"SCT":1,"SGT":1,"SLST":1,"SRT":1,"SST":1,"SYOT":1,"TAHT":1,"THA":1,"TFT":1,"TJT":1,"TKT":1,"TLT":1,"TMT":1,"TOT":1,"TVT":1,"UCT":1,"ULAT":1,"UTC":1,"UYST":1,"UYT":1,"UZT":1,"VET":1,"VLAT":1,"VOLT":1,"VOST":1,"VUT":1,"WAKT":1,"WAST":1,"WAT":1,"WEDT":1,"WEST":1,"WET":1,"WST":1,"YAKT":1,"YEKT":1,"Z":1}; return (timezones[value] === 1); }; $D.validateTimezoneOffset= function(value) { // timezones go from +14hrs to -12hrs, the +X hours are negative offsets. return (value > -841 && value < 721); }; }()); (function () { var $D = Date, $P = $D.prototype, p = function (s, l) { if (!l) { l = 2; } return ("000" + s).slice(l * -1); }; var validateConfigObject = function (obj) { var result = {}, self = this, prop, testFunc; testFunc = function (prop, func, value) { if (prop === "day") { var month = (obj.month !== undefined) ? obj.month : self.getMonth(); var year = (obj.year !== undefined) ? obj.year : self.getFullYear(); return $D[func](value, year, month); } else { return $D[func](value); } }; for (prop in obj) { if (Object.prototype.hasOwnProperty.call(obj, prop)) { var func = "validate" + prop.charAt(0).toUpperCase() + prop.slice(1); if ($D[func] && obj[prop] !== null && testFunc(prop, func, obj[prop])) { result[prop] = obj[prop]; } } } return result; }; /** * Resets the time of this Date object to 12:00 AM (00:00), which is the start of the day. * @param {Boolean} .clone() this date instance before clearing Time * @return {Date} this */ $P.clearTime = function () { this.setHours(0); this.setMinutes(0); this.setSeconds(0); this.setMilliseconds(0); return this; }; /** * Resets the time of this Date object to the current time ('now'). * @return {Date} this */ $P.setTimeToNow = function () { var n = new Date(); this.setHours(n.getHours()); this.setMinutes(n.getMinutes()); this.setSeconds(n.getSeconds()); this.setMilliseconds(n.getMilliseconds()); return this; }; /** * Returns a new Date object that is an exact date and time copy of the original instance. * @return {Date} A new Date instance */ $P.clone = function () { return new Date(this.getTime()); }; /** * Compares this instance to a Date object and returns an number indication of their relative values. * @param {Date} Date object to compare [Required] * @return {Number} -1 = this is lessthan date. 0 = values are equal. 1 = this is greaterthan date. */ $P.compareTo = function (date) { return Date.compare(this, date); }; /** * Compares this instance to another Date object and returns true if they are equal. * @param {Date} Date object to compare. If no date to compare, new Date() [now] is used. * @return {Boolean} true if dates are equal. false if they are not equal. */ $P.equals = function (date) { return Date.equals(this, (date !== undefined ? date : new Date())); }; /** * Determines if this instance is between a range of two dates or equal to either the start or end dates. * @param {Date} Start of range [Required] * @param {Date} End of range [Required] * @return {Boolean} true is this is between or equal to the start and end dates, else false */ $P.between = function (start, end) { return this.getTime() >= start.getTime() && this.getTime() <= end.getTime(); }; /** * Determines if this date occurs after the date to compare to. * @param {Date} Date object to compare. If no date to compare, new Date() ("now") is used. * @return {Boolean} true if this date instance is greater than the date to compare to (or "now"), otherwise false. */ $P.isAfter = function (date) { return this.compareTo(date || new Date()) === 1; }; /** * Determines if this date occurs before the date to compare to. * @param {Date} Date object to compare. If no date to compare, new Date() ("now") is used. * @return {Boolean} true if this date instance is less than the date to compare to (or "now"). */ $P.isBefore = function (date) { return (this.compareTo(date || new Date()) === -1); }; /** * Determines if the current Date instance occurs today. * @return {Boolean} true if this date instance is 'today', otherwise false. */ /** * Determines if the current Date instance occurs on the same Date as the supplied 'date'. * If no 'date' to compare to is provided, the current Date instance is compared to 'today'. * @param {date} Date object to compare. If no date to compare, the current Date ("now") is used. * @return {Boolean} true if this Date instance occurs on the same Day as the supplied 'date'. */ $P.isToday = $P.isSameDay = function (date) { return this.clone().clearTime().equals((date || new Date()).clone().clearTime()); }; /** * Adds the specified number of milliseconds to this instance. * @param {Number} The number of milliseconds to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addMilliseconds = function (value) { if (!value) { return this; } this.setTime(this.getTime() + value * 1); return this; }; /** * Adds the specified number of seconds to this instance. * @param {Number} The number of seconds to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addSeconds = function (value) { if (!value) { return this; } return this.addMilliseconds(value * 1000); }; /** * Adds the specified number of seconds to this instance. * @param {Number} The number of seconds to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addMinutes = function (value) { if (!value) { return this; } return this.addMilliseconds(value * 60000); // 60*1000 }; /** * Adds the specified number of hours to this instance. * @param {Number} The number of hours to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addHours = function (value) { if (!value) { return this; } return this.addMilliseconds(value * 3600000); // 60*60*1000 }; /** * Adds the specified number of days to this instance. * @param {Number} The number of days to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addDays = function (value) { if (!value) { return this; } this.setDate(this.getDate() + value * 1); return this; }; /** * Adds the specified number of weekdays (ie - not sat or sun) to this instance. * @param {Number} The number of days to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addWeekdays = function (value) { if (!value) { return this; } var day = this.getDay(); var weeks = (Math.ceil(Math.abs(value)/7)); if (day === 0 || day === 6) { if (value > 0) { this.next().monday(); this.addDays(-1); day = this.getDay(); } } if (value < 0) { while (value < 0) { this.addDays(-1); day = this.getDay(); if (day !== 0 && day !== 6) { value++; } } return this; } else if (value > 5 || (6-day) <= value) { value = value + (weeks * 2); } return this.addDays(value); }; /** * Adds the specified number of weeks to this instance. * @param {Number} The number of weeks to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addWeeks = function (value) { if (!value) { return this; } return this.addDays(value * 7); }; /** * Adds the specified number of months to this instance. * @param {Number} The number of months to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addMonths = function (value) { if (!value) { return this; } var n = this.getDate(); this.setDate(1); this.setMonth(this.getMonth() + value * 1); this.setDate(Math.min(n, $D.getDaysInMonth(this.getFullYear(), this.getMonth()))); return this; }; $P.addQuarters = function (value) { if (!value) { return this; } // note this will take you to the same point in the quarter as you are now. // i.e. - if you are 15 days into the quarter you'll be 15 days into the resulting one. // bonus: this allows adding fractional quarters return this.addMonths(value * 3); }; /** * Adds the specified number of years to this instance. * @param {Number} The number of years to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addYears = function (value) { if (!value) { return this; } return this.addMonths(value * 12); }; /** * Adds (or subtracts) to the value of the years, months, weeks, days, hours, minutes, seconds, milliseconds of the date instance using given configuration object. Positive and Negative values allowed. * Example

	Date.today().add( { days: 1, months: 1 } )

	new Date().add( { years: -1 } )
	
* @param {Object} Configuration object containing attributes (months, days, etc.) * @return {Date} this */ $P.add = function (config) { if (typeof config === "number") { this._orient = config; return this; } var x = config; if (x.day) { // If we should be a different date than today (eg: for 'tomorrow -1d', etc). // Should only effect parsing, not direct usage (eg, Finish and FinishExact) if ((x.day - this.getDate()) !== 0) { this.setDate(x.day); } } if (x.milliseconds) { this.addMilliseconds(x.milliseconds); } if (x.seconds) { this.addSeconds(x.seconds); } if (x.minutes) { this.addMinutes(x.minutes); } if (x.hours) { this.addHours(x.hours); } if (x.weeks) { this.addWeeks(x.weeks); } if (x.months) { this.addMonths(x.months); } if (x.years) { this.addYears(x.years); } if (x.days) { this.addDays(x.days); } return this; }; /** * Get the week number. Week one (1) is the week which contains the first Thursday of the year. Monday is considered the first day of the week. * The .getWeek() function does NOT convert the date to UTC. The local datetime is used. * Please use .getISOWeek() to get the week of the UTC converted date. * @return {Number} 1 to 53 */ $P.getWeek = function (utc) { // Create a copy of this date object var self, target = new Date(this.valueOf()); if (utc) { target.addMinutes(target.getTimezoneOffset()); self = target.clone(); } else { self = this; } // ISO week date weeks start on monday // so correct the day number var dayNr = (self.getDay() + 6) % 7; // ISO 8601 states that week 1 is the week // with the first thursday of that year. // Set the target date to the thursday in the target week target.setDate(target.getDate() - dayNr + 3); // Store the millisecond value of the target date var firstThursday = target.valueOf(); // Set the target to the first thursday of the year // First set the target to january first target.setMonth(0, 1); // Not a thursday? Correct the date to the next thursday if (target.getDay() !== 4) { target.setMonth(0, 1 + ((4 - target.getDay()) + 7) % 7); } // The weeknumber is the number of weeks between the // first thursday of the year and the thursday in the target week return 1 + Math.ceil((firstThursday - target) / 604800000); // 604800000 = 7 * 24 * 3600 * 1000 }; /** * Get the ISO 8601 week number. Week one ("01") is the week which contains the first Thursday of the year. Monday is considered the first day of the week. * The .getISOWeek() function does convert the date to it's UTC value. Please use .getWeek() to get the week of the local date. * @return {String} "01" to "53" */ $P.getISOWeek = function () { return p(this.getWeek(true)); }; /** * Moves the date to Monday of the week set. Week one (1) is the week which contains the first Thursday of the year. * @param {Number} A Number (1 to 53) that represents the week of the year. * @return {Date} this */ $P.setWeek = function (n) { if ((n - this.getWeek()) === 0) { if (this.getDay() !== 1) { return this.moveToDayOfWeek(1, (this.getDay() > 1 ? -1 : 1)); } else { return this; } } else { return this.moveToDayOfWeek(1, (this.getDay() > 1 ? -1 : 1)).addWeeks(n - this.getWeek()); } }; $P.setQuarter = function (qtr) { var month = Math.abs(((qtr-1) * 3) + 1); return this.setMonth(month, 1); }; $P.getQuarter = function () { return Date.getQuarter(this); }; $P.getDaysLeftInQuarter = function () { return Date.getDaysLeftInQuarter(this); }; /** * Moves the date to the next n'th occurrence of the dayOfWeek starting from the beginning of the month. The number (-1) is a magic number and will return the last occurrence of the dayOfWeek in the month. * @param {Number} The dayOfWeek to move to * @param {Number} The n'th occurrence to move to. Use (-1) to return the last occurrence in the month * @return {Date} this */ $P.moveToNthOccurrence = function (dayOfWeek, occurrence) { if (dayOfWeek === "Weekday") { if (occurrence > 0) { this.moveToFirstDayOfMonth(); if (this.is().weekday()) { occurrence -= 1; } } else if (occurrence < 0) { this.moveToLastDayOfMonth(); if (this.is().weekday()) { occurrence += 1; } } else { return this; } return this.addWeekdays(occurrence); } var shift = 0; if (occurrence > 0) { shift = occurrence - 1; } else if (occurrence === -1) { this.moveToLastDayOfMonth(); if (this.getDay() !== dayOfWeek) { this.moveToDayOfWeek(dayOfWeek, -1); } return this; } return this.moveToFirstDayOfMonth().addDays(-1).moveToDayOfWeek(dayOfWeek, +1).addWeeks(shift); }; var moveToN = function (getFunc, addFunc, nVal) { return function (value, orient) { var diff = (value - this[getFunc]() + nVal * (orient || +1)) % nVal; return this[addFunc]((diff === 0) ? diff += nVal * (orient || +1) : diff); }; }; /** * Move to the next or last dayOfWeek based on the orient value. * @param {Number} The dayOfWeek to move to * @param {Number} Forward (+1) or Back (-1). Defaults to +1. [Optional] * @return {Date} this */ $P.moveToDayOfWeek = moveToN("getDay", "addDays", 7); /** * Move to the next or last month based on the orient value. * @param {Number} The month to move to. 0 = January, 11 = December * @param {Number} Forward (+1) or Back (-1). Defaults to +1. [Optional] * @return {Date} this */ $P.moveToMonth = moveToN("getMonth", "addMonths", 12); /** * Get the Ordinate of the current day ("th", "st", "rd"). * @return {String} */ $P.getOrdinate = function () { var num = this.getDate(); return ord(num); }; /** * Get the Ordinal day (numeric day number) of the year, adjusted for leap year. * @return {Number} 1 through 365 (366 in leap years) */ $P.getOrdinalNumber = function () { return Math.ceil((this.clone().clearTime() - new Date(this.getFullYear(), 0, 1)) / 86400000) + 1; }; /** * Get the time zone abbreviation of the current date. * @return {String} The abbreviated time zone name (e.g. "EST") */ $P.getTimezone = function () { return $D.getTimezoneAbbreviation(this.getUTCOffset(), this.isDaylightSavingTime()); }; $P.setTimezoneOffset = function (offset) { var here = this.getTimezoneOffset(), there = Number(offset) * -6 / 10; return (there || there === 0) ? this.addMinutes(there - here) : this; }; $P.setTimezone = function (offset) { return this.setTimezoneOffset($D.getTimezoneOffset(offset)); }; /** * Indicates whether Daylight Saving Time is observed in the current time zone. * @return {Boolean} true|false */ $P.hasDaylightSavingTime = function () { return (Date.today().set({month: 0, day: 1}).getTimezoneOffset() !== Date.today().set({month: 6, day: 1}).getTimezoneOffset()); }; /** * Indicates whether this Date instance is within the Daylight Saving Time range for the current time zone. * @return {Boolean} true|false */ $P.isDaylightSavingTime = function () { return Date.today().set({month: 0, day: 1}).getTimezoneOffset() !== this.getTimezoneOffset(); }; /** * Get the offset from UTC of the current date. * @return {String} The 4-character offset string prefixed with + or - (e.g. "-0500") */ $P.getUTCOffset = function (offset) { var n = (offset || this.getTimezoneOffset()) * -10 / 6, r; if (n < 0) { r = (n - 10000).toString(); return r.charAt(0) + r.substr(2); } else { r = (n + 10000).toString(); return "+" + r.substr(1); } }; /** * Returns the number of milliseconds between this date and date. * @param {Date} Defaults to now * @return {Number} The diff in milliseconds */ $P.getElapsed = function (date) { return (date || new Date()) - this; }; /** * Set the value of year, month, day, hour, minute, second, millisecond of date instance using given configuration object. * Example

	Date.today().set( { day: 20, month: 1 } )

	new Date().set( { millisecond: 0 } )
	
* * @param {Object} Configuration object containing attributes (month, day, etc.) * @return {Date} this */ $P.set = function (config) { config = validateConfigObject.call(this, config); var key; for (key in config) { if (Object.prototype.hasOwnProperty.call(config, key)) { var name = key.charAt(0).toUpperCase() + key.slice(1); var addFunc, getFunc; if (key !== "week" && key !== "month" && key !== "timezone" && key !== "timezoneOffset") { name += "s"; } addFunc = "add" + name; getFunc = "get" + name; if (key === "month") { addFunc = addFunc + "s"; } else if (key === "year"){ getFunc = "getFullYear"; } if (key !== "day" && key !== "timezone" && key !== "timezoneOffset" && key !== "week" && key !== "hour") { this[addFunc](config[key] - this[getFunc]()); } else if ( key === "timezone"|| key === "timezoneOffset" || key === "week" || key === "hour") { this["set"+name](config[key]); } } } // day has to go last because you can't validate the day without first knowing the month if (config.day) { this.addDays(config.day - this.getDate()); } return this; }; /** * Moves the date to the first day of the month. * @return {Date} this */ $P.moveToFirstDayOfMonth = function () { return this.set({ day: 1 }); }; /** * Moves the date to the last day of the month. * @return {Date} this */ $P.moveToLastDayOfMonth = function () { return this.set({ day: $D.getDaysInMonth(this.getFullYear(), this.getMonth())}); }; /** * Converts the value of the current Date object to its equivalent string representation. * Format Specifiers * CUSTOM DATE AND TIME FORMAT STRINGS * Format Description Example * ------ --------------------------------------------------------------------------- ----------------------- * s The seconds of the minute between 0-59. "0" to "59" * ss The seconds of the minute with leading zero if required. "00" to "59" * * m The minute of the hour between 0-59. "0" or "59" * mm The minute of the hour with leading zero if required. "00" or "59" * * h The hour of the day between 1-12. "1" to "12" * hh The hour of the day with leading zero if required. "01" to "12" * * H The hour of the day between 0-23. "0" to "23" * HH The hour of the day with leading zero if required. "00" to "23" * * d The day of the month between 1 and 31. "1" to "31" * dd The day of the month with leading zero if required. "01" to "31" * ddd Abbreviated day name. Date.CultureInfo.abbreviatedDayNames. "Mon" to "Sun" * dddd The full day name. Date.CultureInfo.dayNames. "Monday" to "Sunday" * * M The month of the year between 1-12. "1" to "12" * MM The month of the year with leading zero if required. "01" to "12" * MMM Abbreviated month name. Date.CultureInfo.abbreviatedMonthNames. "Jan" to "Dec" * MMMM The full month name. Date.CultureInfo.monthNames. "January" to "December" * * yy The year as a two-digit number. "99" or "08" * yyyy The full four digit year. "1999" or "2008" * * t Displays the first character of the A.M./P.M. designator. "A" or "P" * Date.CultureInfo.amDesignator or Date.CultureInfo.pmDesignator * tt Displays the A.M./P.M. designator. "AM" or "PM" * Date.CultureInfo.amDesignator or Date.CultureInfo.pmDesignator * * S The ordinal suffix ("st, "nd", "rd" or "th") of the current day. "st, "nd", "rd" or "th" * * STANDARD DATE AND TIME FORMAT STRINGS * Format Description Example *------ --------------------------------------------------------------------------- ----------------------- * d The CultureInfo shortDate Format Pattern "M/d/yyyy" * D The CultureInfo longDate Format Pattern "dddd, MMMM dd, yyyy" * F The CultureInfo fullDateTime Format Pattern "dddd, MMMM dd, yyyy h:mm:ss tt" * m The CultureInfo monthDay Format Pattern "MMMM dd" * r The CultureInfo rfc1123 Format Pattern "ddd, dd MMM yyyy HH:mm:ss GMT" * s The CultureInfo sortableDateTime Format Pattern "yyyy-MM-ddTHH:mm:ss" * t The CultureInfo shortTime Format Pattern "h:mm tt" * T The CultureInfo longTime Format Pattern "h:mm:ss tt" * u The CultureInfo universalSortableDateTime Format Pattern "yyyy-MM-dd HH:mm:ssZ" * y The CultureInfo yearMonth Format Pattern "MMMM, yyyy" * * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @return {String} A string representation of the current Date object. */ var ord = function (n) { switch (n * 1) { case 1: case 21: case 31: return "st"; case 2: case 22: return "nd"; case 3: case 23: return "rd"; default: return "th"; } }; var parseStandardFormats = function (format) { var y, c = Date.CultureInfo.formatPatterns; switch (format) { case "d": return this.toString(c.shortDate); case "D": return this.toString(c.longDate); case "F": return this.toString(c.fullDateTime); case "m": return this.toString(c.monthDay); case "r": case "R": y = this.clone().addMinutes(this.getTimezoneOffset()); return y.toString(c.rfc1123) + " GMT"; case "s": return this.toString(c.sortableDateTime); case "t": return this.toString(c.shortTime); case "T": return this.toString(c.longTime); case "u": y = this.clone().addMinutes(this.getTimezoneOffset()); return y.toString(c.universalSortableDateTime); case "y": return this.toString(c.yearMonth); default: return false; } }; var parseFormatStringsClosure = function (context) { return function (m) { if (m.charAt(0) === "\\") { return m.replace("\\", ""); } switch (m) { case "hh": return p(context.getHours() < 13 ? (context.getHours() === 0 ? 12 : context.getHours()) : (context.getHours() - 12)); case "h": return context.getHours() < 13 ? (context.getHours() === 0 ? 12 : context.getHours()) : (context.getHours() - 12); case "HH": return p(context.getHours()); case "H": return context.getHours(); case "mm": return p(context.getMinutes()); case "m": return context.getMinutes(); case "ss": return p(context.getSeconds()); case "s": return context.getSeconds(); case "yyyy": return p(context.getFullYear(), 4); case "yy": return p(context.getFullYear()); case "y": return context.getFullYear(); case "E": case "dddd": return Date.CultureInfo.dayNames[context.getDay()]; case "ddd": return Date.CultureInfo.abbreviatedDayNames[context.getDay()]; case "dd": return p(context.getDate()); case "d": return context.getDate(); case "MMMM": return Date.CultureInfo.monthNames[context.getMonth()]; case "MMM": return Date.CultureInfo.abbreviatedMonthNames[context.getMonth()]; case "MM": return p((context.getMonth() + 1)); case "M": return context.getMonth() + 1; case "t": return context.getHours() < 12 ? Date.CultureInfo.amDesignator.substring(0, 1) : Date.CultureInfo.pmDesignator.substring(0, 1); case "tt": return context.getHours() < 12 ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator; case "S": return ord(context.getDate()); case "W": return context.getWeek(); case "WW": return context.getISOWeek(); case "Q": return "Q" + context.getQuarter(); case "q": return String(context.getQuarter()); case "z": return context.getTimezone(); case "Z": case "X": return Date.getTimezoneOffset(context.getTimezone()); case "ZZ": // Timezone offset in seconds return context.getTimezoneOffset() * -60; case "u": return context.getDay(); case "L": return ($D.isLeapYear(context.getFullYear())) ? 1 : 0; case "B": // Swatch Internet Time (.beats) return "@"+((context.getUTCSeconds() + (context.getUTCMinutes()*60) + ((context.getUTCHours()+1)*3600))/86.4); default: return m; } }; }; $P.toString = function (format, ignoreStandards) { // Standard Date and Time Format Strings. Formats pulled from CultureInfo file and // may vary by culture. if (!ignoreStandards && format && format.length === 1) { output = parseStandardFormats.call(this, format); if (output) { return output; } } var parseFormatStrings = parseFormatStringsClosure(this); return format ? format.replace(/((\\)?(dd?d?d?|MM?M?M?|yy?y?y?|hh?|HH?|mm?|ss?|tt?|S|q|Q|WW?W?W?)(?![^\[]*\]))/g, parseFormatStrings).replace(/\[|\]/g, "") : this._toString(); }; }()); /************************************************************* * SugarPak - Domain Specific Language - Syntactical Sugar * *************************************************************/ (function () { var $D = Date, $P = $D.prototype, $N = Number.prototype; // private $P._orient = +1; // private $P._nth = null; // private $P._is = false; // private $P._same = false; // private $P._isSecond = false; // private $N._dateElement = "days"; /** * Moves the date to the next instance of a date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.today().next().friday();
	Date.today().next().fri();
	Date.today().next().march();
	Date.today().next().mar();
	Date.today().next().week();
	
* * @return {Date} date */ $P.next = function () { this._move = true; this._orient = +1; return this; }; /** * Creates a new Date (Date.today()) and moves the date to the next instance of the date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.next().friday();
	Date.next().fri();
	Date.next().march();
	Date.next().mar();
	Date.next().week();
	
* * @return {Date} date */ $D.next = function () { return $D.today().next(); }; /** * Moves the date to the previous instance of a date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.today().last().friday();
	Date.today().last().fri();
	Date.today().last().march();
	Date.today().last().mar();
	Date.today().last().week();
	
* * @return {Date} date */ $P.last = $P.prev = $P.previous = function () { this._move = true; this._orient = -1; return this; }; /** * Creates a new Date (Date.today()) and moves the date to the previous instance of the date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.last().friday();
	Date.last().fri();
	Date.previous().march();
	Date.prev().mar();
	Date.last().week();
	
* * @return {Date} date */ $D.last = $D.prev = $D.previous = function () { return $D.today().last(); }; /** * Performs a equality check when followed by either a month name, day name or .weekday() function. * Example

	Date.today().is().friday(); // true|false
	Date.today().is().fri();
	Date.today().is().march();
	Date.today().is().mar();
	
* * @return {Boolean} true|false */ $P.is = function () { this._is = true; return this; }; /** * Determines if two date objects occur on/in exactly the same instance of the subsequent date part function. * The function .same() must be followed by a date part function (example: .day(), .month(), .year(), etc). * * An optional Date can be passed in the date part function. If now date is passed as a parameter, 'Now' is used. * * The following example demonstrates how to determine if two dates fall on the exact same day. * * Example

	var d1 = Date.today(); // today at 00:00
	var d2 = new Date();   // exactly now.

	// Do they occur on the same day?
	d1.same().day(d2); // true
	
	// Do they occur on the same hour?
	d1.same().hour(d2); // false, unless d2 hour is '00' (midnight).
	
	// What if it's the same day, but one year apart?
	var nextYear = Date.today().add(1).year();

	d1.same().day(nextYear); // false, because the dates must occur on the exact same day. 
	
* * Scenario: Determine if a given date occurs during some week period 2 months from now. * * Example

	var future = Date.today().add(2).months();
	return someDate.same().week(future); // true|false;
	
* * @return {Boolean} true|false */ $P.same = function () { this._same = true; this._isSecond = false; return this; }; /** * Determines if the current date/time occurs during Today. Must be preceded by the .is() function. * Example

	someDate.is().today();    // true|false
	new Date().is().today();  // true
	Date.today().is().today();// true
	Date.today().add(-1).day().is().today(); // false
	
* * @return {Boolean} true|false */ $P.today = function () { return this.same().day(); }; /** * Determines if the current date is a weekday. This function must be preceded by the .is() function. * Example

	Date.today().is().weekday(); // true|false
	
* * @return {Boolean} true|false */ $P.weekday = function () { if (this._nth) { return df("Weekday").call(this); } if (this._move) { return this.addWeekdays(this._orient); } if (this._is) { this._is = false; return (!this.is().sat() && !this.is().sun()); } return false; }; /** * Determines if the current date is on the weekend. This function must be preceded by the .is() function. * Example

	Date.today().is().weekend(); // true|false
	
* * @return {Boolean} true|false */ $P.weekend = function () { if (this._is) { this._is = false; return (this.is().sat() || this.is().sun()); } return false; }; /** * Sets the Time of the current Date instance. A string "6:15 pm" or config object {hour:18, minute:15} are accepted. * Example

	// Set time to 6:15pm with a String
	Date.today().at("6:15pm");

	// Set time to 6:15pm with a config object
	Date.today().at({hour:18, minute:15});
	
* * @return {Date} date */ $P.at = function (time) { return (typeof time === "string") ? $D.parse(this.toString("d") + " " + time) : this.set(time); }; /** * Creates a new Date() and adds this (Number) to the date based on the preceding date element function (eg. second|minute|hour|day|month|year). * Example

	// Undeclared Numbers must be wrapped with parentheses. Requirment of JavaScript.
	(3).days().fromNow();
	(6).months().fromNow();

	// Declared Number variables do not require parentheses. 
	var n = 6;
	n.months().fromNow();
	
* * @return {Date} A new Date instance */ $N.fromNow = $N.after = function (date) { var c = {}; c[this._dateElement] = this; return ((!date) ? new Date() : date.clone()).add(c); }; /** * Creates a new Date() and subtract this (Number) from the date based on the preceding date element function (eg. second|minute|hour|day|month|year). * Example

	// Undeclared Numbers must be wrapped with parentheses. Requirment of JavaScript.
	(3).days().ago();
	(6).months().ago();

	// Declared Number variables do not require parentheses. 
	var n = 6;
	n.months().ago();
	
* * @return {Date} A new Date instance */ $N.ago = $N.before = function (date) { var c = {}, s = (this._dateElement[this._dateElement.length-1] !== "s") ? this._dateElement + "s" : this._dateElement; c[s] = this * -1; return ((!date) ? new Date() : date.clone()).add(c); }; // Do NOT modify the following string tokens. These tokens are used to build dynamic functions. // All culture-specific strings can be found in the CultureInfo files. var dx = ("sunday monday tuesday wednesday thursday friday saturday").split(/\s/), mx = ("january february march april may june july august september october november december").split(/\s/), px = ("Millisecond Second Minute Hour Day Week Month Year Quarter Weekday").split(/\s/), pxf = ("Milliseconds Seconds Minutes Hours Date Week Month FullYear Quarter").split(/\s/), nth = ("final first second third fourth fifth").split(/\s/), de; /** * Returns an object literal of all the date parts. * Example

	var o = new Date().toObject();
	
	// { year: 2008, month: 4, week: 20, day: 13, hour: 18, minute: 9, second: 32, millisecond: 812 }
	
	// The object properties can be referenced directly from the object.
	
	alert(o.day);  // alerts "13"
	alert(o.year); // alerts "2008"
	
* * @return {Date} An object literal representing the original date object. */ $P.toObject = function () { var o = {}; for (var i = 0; i < px.length; i++) { if (this["get" + pxf[i]]) { o[px[i].toLowerCase()] = this["get" + pxf[i]](); } } return o; }; /** * Returns a date created from an object literal. Ignores the .week property if set in the config. * Example

	var o = new Date().toObject();
	
	return Date.fromObject(o); // will return the same date. 

	var o2 = {month: 1, day: 20, hour: 18}; // birthday party!
	Date.fromObject(o2);
	
* * @return {Date} An object literal representing the original date object. */ $D.fromObject = function(config) { config.week = null; return Date.today().set(config); }; // Create day name functions and abbreviated day name functions (eg. monday(), friday(), fri()). var df = function (n) { return function () { if (this._is) { this._is = false; return this.getDay() === n; } if (this._move) { this._move = null; } if (this._nth !== null) { // If the .second() function was called earlier, remove the _orient // from the date, and then continue. // This is required because 'second' can be used in two different context. // // Example // // Date.today().add(1).second(); // Date.march().second().monday(); // // Things get crazy with the following... // Date.march().add(1).second().second().monday(); // but it works!! // if (this._isSecond) { this.addSeconds(this._orient * -1); } // make sure we reset _isSecond this._isSecond = false; var ntemp = this._nth; this._nth = null; var temp = this.clone().moveToLastDayOfMonth(); this.moveToNthOccurrence(n, ntemp); if (this > temp) { throw new RangeError($D.getDayName(n) + " does not occur " + ntemp + " times in the month of " + $D.getMonthName(temp.getMonth()) + " " + temp.getFullYear() + "."); } return this; } return this.moveToDayOfWeek(n, this._orient); }; }; var sdf = function (n) { return function () { var t = $D.today(), shift = n - t.getDay(); if (n === 0 && Date.CultureInfo.firstDayOfWeek === 1 && t.getDay() !== 0) { shift = shift + 7; } return t.addDays(shift); }; }; // Create month name functions and abbreviated month name functions (eg. january(), march(), mar()). var month_instance_functions = function (n) { return function () { if (this._is) { this._is = false; return this.getMonth() === n; } return this.moveToMonth(n, this._orient); }; }; var month_static_functions = function (n) { return function () { return $D.today().set({ month: n, day: 1 }); }; }; var processTerms = function (names, staticFunc, instanceFunc) { for (var i = 0; i < names.length; i++) { // Create constant static Name variables. $D[names[i].toUpperCase()] = $D[names[i].toUpperCase().substring(0, 3)] = i; // Create Name functions. $D[names[i]] = $D[names[i].substring(0, 3)] = staticFunc(i); // Create Name instance functions. $P[names[i]] = $P[names[i].substring(0, 3)] = instanceFunc(i); } }; processTerms(dx, sdf, df); processTerms(mx, month_static_functions, month_instance_functions); // Create date element functions and plural date element functions used with Date (eg. day(), days(), months()). var ef = function (j) { return function () { // if the .second() function was called earlier, the _orient // has alread been added. Just return this and reset _isSecond. if (this._isSecond) { this._isSecond = false; return this; } if (this._same) { this._same = this._is = false; var o1 = this.toObject(), o2 = (arguments[0] || new Date()).toObject(), v = "", k = j.toLowerCase(); // the substr trick with -1 doesn't work in IE8 or less k = (k[k.length-1] === "s") ? k.substring(0,k.length-1) : k; for (var m = (px.length - 1); m > -1; m--) { v = px[m].toLowerCase(); if (o1[v] !== o2[v]) { return false; } if (k === v) { break; } } return true; } if (j.substring(j.length - 1) !== "s") { j += "s"; } if (this._move) { this._move = null; } return this["add" + j](this._orient); }; }; var nf = function (n) { return function () { this._dateElement = n; return this; }; }; for (var k = 0; k < px.length; k++) { de = px[k].toLowerCase(); if(de !== "weekday") { // Create date element functions and plural date element functions used with Date (eg. day(), days(), months()). $P[de] = $P[de + "s"] = ef(px[k]); // Create date element functions and plural date element functions used with Number (eg. day(), days(), months()). $N[de] = $N[de + "s"] = nf(de + "s"); } } $P._ss = ef("Second"); var nthfn = function (n) { return function (dayOfWeek) { if (this._same) { return this._ss(arguments[0]); } if (dayOfWeek || dayOfWeek === 0) { return this.moveToNthOccurrence(dayOfWeek, n); } this._nth = n; // if the operator is 'second' add the _orient, then deal with it later... if (n === 2 && (dayOfWeek === undefined || dayOfWeek === null)) { this._isSecond = true; return this.addSeconds(this._orient); } return this; }; }; for (var l = 0; l < nth.length; l++) { $P[nth[l]] = (l === 0) ? nthfn(-1) : nthfn(l); } }()); (function () { "use strict"; Date.Parsing = { Exception: function (s) { this.message = "Parse error at '" + s.substring(0, 10) + " ...'"; } }; var $P = Date.Parsing; var dayOffsets = { standard: [0,31,59,90,120,151,181,212,243,273,304,334], leap: [0,31,60,91,121,152,182,213,244,274,305,335] }; $P.isLeapYear = function(year) { return ((year % 4 === 0) && (year % 100 !== 0)) || (year % 400 === 0); }; var utils = { multiReplace : function (str, hash ) { var key; for (key in hash) { if (Object.prototype.hasOwnProperty.call(hash, key)) { var regex; if (typeof hash[key] === "function") { } else { regex = (hash[key] instanceof RegExp) ? hash[key] : new RegExp(hash[key], "g"); } str = str.replace(regex, key); } } return str; }, getDayOfYearFromWeek : function (obj) { var d, jan4, offset; obj.weekDay = (!obj.weekDay && obj.weekDay !== 0) ? 1 : obj.weekDay; d = new Date(obj.year, 0, 4); jan4 = d.getDay() === 0 ? 7 : d.getDay(); // JS is 0 indexed on Sunday. offset = jan4+3; obj.dayOfYear = ((obj.week * 7) + (obj.weekDay === 0 ? 7 : obj.weekDay))-offset; return obj; }, getDayOfYear : function (obj, dayOffset) { if (!obj.dayOfYear) { obj = utils.getDayOfYearFromWeek(obj); } for (var i=0;i <= dayOffset.length;i++) { if (obj.dayOfYear < dayOffset[i] || i === dayOffset.length) { obj.day = obj.day ? obj.day : (obj.dayOfYear - dayOffset[i-1]); break; } else { obj.month = i; } } return obj; }, adjustForTimeZone : function (obj, date) { var offset; if (obj.zone.toUpperCase() === "Z" || (obj.zone_hours === 0 && obj.zone_minutes === 0)) { // it's UTC/GML so work out the current timeszone offset offset = -date.getTimezoneOffset(); } else { offset = (obj.zone_hours*60) + (obj.zone_minutes || 0); if (obj.zone_sign === "+") { offset *= -1; } offset -= date.getTimezoneOffset(); } date.setMinutes(date.getMinutes()+offset); return date; }, setDefaults : function (obj) { obj.year = obj.year || Date.today().getFullYear(); obj.hours = obj.hours || 0; obj.minutes = obj.minutes || 0; obj.seconds = obj.seconds || 0; obj.milliseconds = obj.milliseconds || 0; if (!(!obj.month && (obj.week || obj.dayOfYear))) { // if we have a month, or if we don't but don't have the day calculation data obj.month = obj.month || 0; obj.day = obj.day || 1; } return obj; }, dataNum: function (data, mod, explict, postProcess) { var dataNum = data*1; if (mod) { if (postProcess) { return data ? mod(data)*1 : data; } else { return data ? mod(dataNum) : data; } } else if (!explict){ return data ? dataNum : data; } else { return (data && typeof data !== "undefined") ? dataNum : data; } }, timeDataProcess: function (obj) { var timeObj = {}; for (var x in obj.data) { if (obj.data.hasOwnProperty(x)) { timeObj[x] = obj.ignore[x] ? obj.data[x] : utils.dataNum(obj.data[x], obj.mods[x], obj.explict[x], obj.postProcess[x]); } } if (obj.data.secmins) { obj.data.secmins = obj.data.secmins.replace(",", ".") * 60; if (!timeObj.minutes) { timeObj.minutes = obj.data.secmins; } else if (!timeObj.seconds) { timeObj.seconds = obj.data.secmins; } delete obj.secmins; } return timeObj; }, buildTimeObjectFromData: function (data) { var time = utils.timeDataProcess({ data: { year : data[1], month : data[5], day : data[7], week : data[8], dayOfYear : data[10], hours : data[15], zone_hours : data[23], zone_minutes : data[24], zone : data[21], zone_sign : data[22], weekDay : data[9], minutes: data[16], seconds: data[19], milliseconds: data[20], secmins: data[18] }, mods: { month: function(data) { return data-1; }, weekDay: function (data) { data = Math.abs(data); return (data === 7 ? 0 : data); }, minutes: function (data) { return data.replace(":",""); }, seconds: function (data) { return Math.floor( (data.replace(":","").replace(",","."))*1 ); }, milliseconds: function (data) { return (data.replace(",",".")*1000); } }, postProcess: { minutes: true, seconds: true, milliseconds: true }, explict: { zone_hours: true, zone_minutes: true }, ignore: { zone: true, zone_sign: true, secmins: true } }); return time; }, addToHash: function (hash, keys, data) { keys = keys; data = data; var len = keys.length; for (var i = 0; i < len; i++) { hash[keys[i]] = data[i]; } return hash; }, combineRegex: function (r1, r2) { return new RegExp("(("+r1.source+")\\s("+r2.source+"))"); }, getDateNthString: function(add, last, inc){ if (add) { return Date.today().addDays(inc).toString("d"); } else if (last) { return Date.today().last()[inc]().toString("d"); } }, buildRegexData: function (array) { var arr = []; var len = array.length; for (var i=0; i < len; i++) { if (Object.prototype.toString.call(array[i]) === '[object Array]') { // oldIE compat version of Array.isArray arr.push(this.combineRegex(array[i][0], array[i][1])); } else { arr.push(array[i]); } } return arr; } }; $P.processTimeObject = function (obj) { var date, dayOffset; utils.setDefaults(obj); dayOffset = ($P.isLeapYear(obj.year)) ? dayOffsets.leap : dayOffsets.standard; if (!obj.month && (obj.week || obj.dayOfYear)) { utils.getDayOfYear(obj, dayOffset); } else { obj.dayOfYear = dayOffset[obj.month] + obj.day; } date = new Date(obj.year, obj.month, obj.day, obj.hours, obj.minutes, obj.seconds, obj.milliseconds); if (obj.zone) { utils.adjustForTimeZone(obj, date); // adjust (and calculate) for timezone } return date; }; $P.ISO = { regex : /^([\+-]?\d{4}(?!\d{2}\b))((-?)((0[1-9]|1[0-2])(\3([12]\d|0[1-9]|3[01]))?|W([0-4]\d|5[0-3])(-?[1-7])?|(00[1-9]|0[1-9]\d|[12]\d{2}|3([0-5]\d|6[1-6])))([T\s]((([01]\d|2[0-4])((:?)[0-5]\d)?|24\:?00)([\.,]\d+(?!:))?)?(\17[0-5]\d([\.,]\d+)?)?\s?([zZ]|([\+-])([01]\d|2[0-3]):?([0-5]\d)?)?)?)?$/, parse : function (s) { var time, data = s.match(this.regex); if (!data || !data.length) { return null; } time = utils.buildTimeObjectFromData(data); if (!time.year || (!time.year && (!time.month && !time.day) && (!time.week && !time.dayOfYear)) ) { return null; } return $P.processTimeObject(time); } }; $P.Numeric = { isNumeric: function (e){return!isNaN(parseFloat(e))&&isFinite(e);}, regex: /\b([0-1]?[0-9])([0-3]?[0-9])([0-2]?[0-9]?[0-9][0-9])\b/i, parse: function (s) { var data, i, time = {}, order = Date.CultureInfo.dateElementOrder.split(""); if (!(this.isNumeric(s)) || // if it's non-numeric OR (s[0] === "+" && s[0] === "-")) { // It's an arithmatic string (eg +/-1000) return null; } if (s.length < 5 && s.indexOf(".") < 0 && s.indexOf("/") < 0) { // assume it's just a year. time.year = s; return $P.processTimeObject(time); } data = s.match(this.regex); if (!data || !data.length) { return null; } for (i=0; i < order.length; i++) { switch(order[i]) { case "d": time.day = data[i+1]; break; case "m": time.month = (data[i+1]-1); break; case "y": time.year = data[i+1]; break; } } return $P.processTimeObject(time); } }; $P.Normalizer = { regexData: function () { var $R = Date.CultureInfo.regexPatterns; return utils.buildRegexData([ $R.tomorrow, $R.yesterday, [$R.past, $R.mon], [$R.past, $R.tue], [$R.past, $R.wed], [$R.past, $R.thu], [$R.past, $R.fri], [$R.past, $R.sat], [$R.past, $R.sun] ]); }, basicReplaceHash : function() { var $R = Date.CultureInfo.regexPatterns; return { "January": $R.jan.source, "February": $R.feb, "March": $R.mar, "April": $R.apr, "May": $R.may, "June": $R.jun, "July": $R.jul, "August": $R.aug, "September": $R.sep, "October": $R.oct, "November": $R.nov, "December": $R.dec, "": /\bat\b/gi, " ": /\s{2,}/, "am": $R.inTheMorning, "9am": $R.thisMorning, "pm": $R.inTheEvening, "7pm":$R.thisEvening }; }, keys : function(){ return [ utils.getDateNthString(true, false, 1), // tomorrow utils.getDateNthString(true, false, -1), // yesterday utils.getDateNthString(false, true, "monday"), //last mon utils.getDateNthString(false, true, "tuesday"), //last tues utils.getDateNthString(false, true, "wednesday"), //last wed utils.getDateNthString(false, true, "thursday"), //last thurs utils.getDateNthString(false, true, "friday"), //last fri utils.getDateNthString(false, true, "saturday"), //last sat utils.getDateNthString(false, true, "sunday") //last sun ]; }, buildRegexFunctions: function () { var $R = Date.CultureInfo.regexPatterns; var __ = Date.i18n.__; var tomorrowRE = new RegExp("(\\b\\d\\d?("+__("AM")+"|"+__("PM")+")? )("+$R.tomorrow.source.slice(1)+")", "i"); // adapted tomorrow regex for AM PM relative dates var todayRE = new RegExp($R.today.source + "(?!\\s*([+-]))\\b"); // today, but excludes the math operators (eg "today + 2h") this.replaceFuncs = [ [todayRE, function (full) { return (full.length > 1) ? Date.today().toString("d") : full; }], [tomorrowRE, function(full, m1) { var t = Date.today().addDays(1).toString("d"); return (t + " " + m1); }], [$R.amThisMorning, function(str, am){return am;}], [$R.pmThisEvening, function(str, pm){return pm;}] ]; }, buildReplaceData: function () { this.buildRegexFunctions(); this.replaceHash = utils.addToHash(this.basicReplaceHash(), this.keys(), this.regexData()); }, stringReplaceFuncs: function (s) { for (var i=0; i < this.replaceFuncs.length; i++) { s = s.replace(this.replaceFuncs[i][0], this.replaceFuncs[i][1]); } return s; }, parse: function (s) { s = this.stringReplaceFuncs(s); s = utils.multiReplace(s, this.replaceHash); try { var n = s.split(/([\s\-\.\,\/\x27]+)/); if (n.length === 3 && $P.Numeric.isNumeric(n[0]) && $P.Numeric.isNumeric(n[2]) && (n[2].length >= 4)) { // ok, so we're dealing with x/year. But that's not a full date. // This fixes wonky dateElementOrder parsing when set to dmy order. if (Date.CultureInfo.dateElementOrder[0] === "d") { s = "1/" + n[0] + "/" + n[2]; // set to 1st of month and normalize the seperator } } } catch (e) {} return s; } }; $P.Normalizer.buildReplaceData(); }()); (function () { var $P = Date.Parsing; var _ = $P.Operators = { // // Tokenizers // rtoken: function (r) { // regex token return function (s) { var mx = s.match(r); if (mx) { return ([ mx[0], s.substring(mx[0].length) ]); } else { throw new $P.Exception(s); } }; }, token: function () { // whitespace-eating token return function (s) { return _.rtoken(new RegExp("^\\s*" + s + "\\s*"))(s); }; }, stoken: function (s) { // string token return _.rtoken(new RegExp("^" + s)); }, // Atomic Operators until: function (p) { return function (s) { var qx = [], rx = null; while (s.length) { try { rx = p.call(this, s); } catch (e) { qx.push(rx[0]); s = rx[1]; continue; } break; } return [ qx, s ]; }; }, many: function (p) { return function (s) { var rx = [], r = null; while (s.length) { try { r = p.call(this, s); } catch (e) { return [ rx, s ]; } rx.push(r[0]); s = r[1]; } return [ rx, s ]; }; }, // generator operators -- see below optional: function (p) { return function (s) { var r = null; try { r = p.call(this, s); } catch (e) { return [ null, s ]; } return [ r[0], r[1] ]; }; }, not: function (p) { return function (s) { try { p.call(this, s); } catch (e) { return [null, s]; } throw new $P.Exception(s); }; }, ignore: function (p) { return p ? function (s) { var r = null; r = p.call(this, s); return [null, r[1]]; } : null; }, product: function () { var px = arguments[0], qx = Array.prototype.slice.call(arguments, 1), rx = []; for (var i = 0 ; i < px.length ; i++) { rx.push(_.each(px[i], qx)); } return rx; }, cache: function (rule) { var cache = {}, cache_length = 0, cache_keys = [], CACHE_MAX = Date.Config.CACHE_MAX || 100000, r = null; var cacheCheck = function () { if (cache_length === CACHE_MAX) { // kill several keys, don't want to have to do this all the time... for (var i=0; i < 10; i++) { var key = cache_keys.shift(); if (key) { delete cache[key]; cache_length--; } } } }; return function (s) { cacheCheck(); try { r = cache[s] = (cache[s] || rule.call(this, s)); } catch (e) { r = cache[s] = e; } cache_length++; cache_keys.push(s); if (r instanceof $P.Exception) { throw r; } else { return r; } }; }, // vector operators -- see below any: function () { var px = arguments; return function (s) { var r = null; for (var i = 0; i < px.length; i++) { if (px[i] == null) { continue; } try { r = (px[i].call(this, s)); } catch (e) { r = null; } if (r) { return r; } } throw new $P.Exception(s); }; }, each: function () { var px = arguments; return function (s) { var rx = [], r = null; for (var i = 0; i < px.length ; i++) { if (px[i] == null) { continue; } try { r = (px[i].call(this, s)); } catch (e) { throw new $P.Exception(s); } rx.push(r[0]); s = r[1]; } return [ rx, s]; }; }, all: function () { var px = arguments, _ = _; return _.each(_.optional(px)); }, // delimited operators sequence: function (px, d, c) { d = d || _.rtoken(/^\s*/); c = c || null; if (px.length === 1) { return px[0]; } return function (s) { var r = null, q = null; var rx = []; for (var i = 0; i < px.length ; i++) { try { r = px[i].call(this, s); } catch (e) { break; } rx.push(r[0]); try { q = d.call(this, r[1]); } catch (ex) { q = null; break; } s = q[1]; } if (!r) { throw new $P.Exception(s); } if (q) { throw new $P.Exception(q[1]); } if (c) { try { r = c.call(this, r[1]); } catch (ey) { throw new $P.Exception(r[1]); } } return [ rx, (r?r[1]:s) ]; }; }, // // Composite Operators // between: function (d1, p, d2) { d2 = d2 || d1; var _fn = _.each(_.ignore(d1), p, _.ignore(d2)); return function (s) { var rx = _fn.call(this, s); return [[rx[0][0], r[0][2]], rx[1]]; }; }, list: function (p, d, c) { d = d || _.rtoken(/^\s*/); c = c || null; return (p instanceof Array ? _.each(_.product(p.slice(0, -1), _.ignore(d)), p.slice(-1), _.ignore(c)) : _.each(_.many(_.each(p, _.ignore(d))), px, _.ignore(c))); }, set: function (px, d, c) { d = d || _.rtoken(/^\s*/); c = c || null; return function (s) { // r is the current match, best the current 'best' match // which means it parsed the most amount of input var r = null, p = null, q = null, rx = null, best = [[], s], last = false; // go through the rules in the given set for (var i = 0; i < px.length ; i++) { // last is a flag indicating whether this must be the last element // if there is only 1 element, then it MUST be the last one q = null; p = null; r = null; last = (px.length === 1); // first, we try simply to match the current pattern // if not, try the next pattern try { r = px[i].call(this, s); } catch (e) { continue; } // since we are matching against a set of elements, the first // thing to do is to add r[0] to matched elements rx = [[r[0]], r[1]]; // if we matched and there is still input to parse and // we don't already know this is the last element, // we're going to next check for the delimiter ... // if there's none, or if there's no input left to parse // than this must be the last element after all ... if (r[1].length > 0 && ! last) { try { q = d.call(this, r[1]); } catch (ex) { last = true; } } else { last = true; } // if we parsed the delimiter and now there's no more input, // that means we shouldn't have parsed the delimiter at all // so don't update r and mark this as the last element ... if (!last && q[1].length === 0) { last = true; } // so, if this isn't the last element, we're going to see if // we can get any more matches from the remaining (unmatched) // elements ... if (!last) { // build a list of the remaining rules we can match against, // i.e., all but the one we just matched against var qx = []; for (var j = 0; j < px.length ; j++) { if (i !== j) { qx.push(px[j]); } } // now invoke recursively set with the remaining input // note that we don't include the closing delimiter ... // we'll check for that ourselves at the end p = _.set(qx, d).call(this, q[1]); // if we got a non-empty set as a result ... // (otw rx already contains everything we want to match) if (p[0].length > 0) { // update current result, which is stored in rx ... // basically, pick up the remaining text from p[1] // and concat the result from p[0] so that we don't // get endless nesting ... rx[0] = rx[0].concat(p[0]); rx[1] = p[1]; } } // at this point, rx either contains the last matched element // or the entire matched set that starts with this element. // now we just check to see if this variation is better than // our best so far, in terms of how much of the input is parsed if (rx[1].length < best[1].length) { best = rx; } // if we've parsed all the input, then we're finished if (best[1].length === 0) { break; } } // so now we've either gone through all the patterns trying them // as the initial match; or we found one that parsed the entire // input string ... // if best has no matches, just return empty set ... if (best[0].length === 0) { return best; } // if a closing delimiter is provided, then we have to check it also if (c) { // we try this even if there is no remaining input because the pattern // may well be optional or match empty input ... try { q = c.call(this, best[1]); } catch (ey) { throw new $P.Exception(best[1]); } // it parsed ... be sure to update the best match remaining input best[1] = q[1]; } // if we're here, either there was no closing delimiter or we parsed it // so now we have the best match; just return it! return best; }; }, forward: function (gr, fname) { return function (s) { return gr[fname].call(this, s); }; }, // // Translation Operators // replace: function (rule, repl) { return function (s) { var r = rule.call(this, s); return [repl, r[1]]; }; }, process: function (rule, fn) { return function (s) { var r = rule.call(this, s); return [fn.call(this, r[0]), r[1]]; }; }, min: function (min, rule) { return function (s) { var rx = rule.call(this, s); if (rx[0].length < min) { throw new $P.Exception(s); } return rx; }; } }; // Generator Operators And Vector Operators // Generators are operators that have a signature of F(R) => R, // taking a given rule and returning another rule, such as // ignore, which parses a given rule and throws away the result. // Vector operators are those that have a signature of F(R1,R2,...) => R, // take a list of rules and returning a new rule, such as each. // Generator operators are converted (via the following _generator // function) into functions that can also take a list or array of rules // and return an array of new rules as though the function had been // called on each rule in turn (which is what actually happens). // This allows generators to be used with vector operators more easily. // Example: // each(ignore(foo, bar)) instead of each(ignore(foo), ignore(bar)) // This also turns generators into vector operators, which allows // constructs like: // not(cache(foo, bar)) var _generator = function (op) { function gen() { var args = null, rx = [], px, i; if (arguments.length > 1) { args = Array.prototype.slice.call(arguments); } else if (arguments[0] instanceof Array) { args = arguments[0]; } if (args) { px = args.shift(); if (px.length > 0) { args.unshift(px[i]); rx.push(op.apply(null, args)); args.shift(); return rx; } } else { return op.apply(null, arguments); } } return gen; }; var gx = "optional not ignore cache".split(/\s/); for (var i = 0 ; i < gx.length ; i++) { _[gx[i]] = _generator(_[gx[i]]); } var _vector = function (op) { return function () { if (arguments[0] instanceof Array) { return op.apply(null, arguments[0]); } else { return op.apply(null, arguments); } }; }; var vx = "each any all".split(/\s/); for (var j = 0 ; j < vx.length ; j++) { _[vx[j]] = _vector(_[vx[j]]); } }()); (function () { var $D = Date; var flattenAndCompact = function (ax) { var rx = []; for (var i = 0; i < ax.length; i++) { if (ax[i] instanceof Array) { rx = rx.concat(flattenAndCompact(ax[i])); } else { if (ax[i]) { rx.push(ax[i]); } } } return rx; }; var parseMeridian = function () { if (this.meridian && (this.hour || this.hour === 0)) { if (this.meridian === "a" && this.hour > 11 && Date.Config.strict24hr){ throw "Invalid hour and meridian combination"; } else if (this.meridian === "p" && this.hour < 12 && Date.Config.strict24hr){ throw "Invalid hour and meridian combination"; } else if (this.meridian === "p" && this.hour < 12) { this.hour = this.hour + 12; } else if (this.meridian === "a" && this.hour === 12) { this.hour = 0; } } }; var setDefaults = function () { var now = new Date(); if ((this.hour || this.minute) && (!this.month && !this.year && !this.day)) { this.day = now.getDate(); } if (!this.year) { this.year = now.getFullYear(); } if (!this.month && this.month !== 0) { this.month = now.getMonth(); } if (!this.day) { this.day = 1; } if (!this.hour) { this.hour = 0; } if (!this.minute) { this.minute = 0; } if (!this.second) { this.second = 0; } if (!this.millisecond) { this.millisecond = 0; } }; var finishUtils = { getToday: function () { if (this.now || "hour minute second".indexOf(this.unit) !== -1) { return new Date(); } else { return $D.today(); } }, setDaysFromWeekday: function (today, orient){ var gap; orient = orient || 1; this.unit = "day"; gap = ($D.getDayNumberFromName(this.weekday) - today.getDay()); this.days = gap ? ((gap + (orient * 7)) % 7) : (orient * 7); return this; }, setMonthsFromMonth: function (today, orient) { var gap; orient = orient || 1; this.unit = "month"; gap = (this.month - today.getMonth()); this.months = gap ? ((gap + (orient * 12)) % 12) : (orient * 12); this.month = null; return this; }, setDMYFromWeekday: function () { var d = Date[this.weekday](); this.day = d.getDate(); if (!this.month) { this.month = d.getMonth(); } this.year = d.getFullYear(); return this; }, setUnitValue: function (orient) { if (!this.value && this.operator && this.operator !== null && this[this.unit + "s"] && this[this.unit + "s"] !== null) { this[this.unit + "s"] = this[this.unit + "s"] + ((this.operator === "add") ? 1 : -1) + (this.value||0) * orient; } else if (this[this.unit + "s"] == null || this.operator != null) { if (!this.value) { this.value = 1; } this[this.unit + "s"] = this.value * orient; } }, generateDateFromWeeks: function () { var weekday = (this.weekday !== undefined) ? this.weekday : "today"; var d = Date[weekday]().addWeeks(this.weeks); if (this.now) { d.setTimeToNow(); } return d; } }; $D.Translator = { hour: function (s) { return function () { this.hour = Number(s); }; }, minute: function (s) { return function () { this.minute = Number(s); }; }, second: function (s) { return function () { this.second = Number(s); }; }, /* for ss.s format */ secondAndMillisecond: function (s) { return function () { var mx = s.match(/^([0-5][0-9])\.([0-9]{1,3})/); this.second = Number(mx[1]); this.millisecond = Number(mx[2]); }; }, meridian: function (s) { return function () { this.meridian = s.slice(0, 1).toLowerCase(); }; }, timezone: function (s) { return function () { var n = s.replace(/[^\d\+\-]/g, ""); if (n.length) { this.timezoneOffset = Number(n); } else { this.timezone = s.toLowerCase(); } }; }, day: function (x) { var s = x[0]; return function () { this.day = Number(s.match(/\d+/)[0]); if (this.day < 1) { throw "invalid day"; } }; }, month: function (s) { return function () { this.month = (s.length === 3) ? "jan feb mar apr may jun jul aug sep oct nov dec".indexOf(s)/4 : Number(s) - 1; if (this.month < 0) { throw "invalid month"; } }; }, year: function (s) { return function () { var n = Number(s); this.year = ((s.length > 2) ? n : (n + (((n + 2000) < Date.CultureInfo.twoDigitYearMax) ? 2000 : 1900))); }; }, rday: function (s) { return function () { switch (s) { case "yesterday": this.days = -1; break; case "tomorrow": this.days = 1; break; case "today": this.days = 0; break; case "now": this.days = 0; this.now = true; break; } }; }, finishExact: function (x) { var d; x = (x instanceof Array) ? x : [x]; for (var i = 0 ; i < x.length ; i++) { if (x[i]) { x[i].call(this); } } setDefaults.call(this); parseMeridian.call(this); if (this.day > $D.getDaysInMonth(this.year, this.month)) { throw new RangeError(this.day + " is not a valid value for days."); } d = new Date(this.year, this.month, this.day, this.hour, this.minute, this.second, this.millisecond); if (this.year < 100) { d.setFullYear(this.year); // means years less that 100 are process correctly. JS will parse it otherwise as 1900-1999. } if (this.timezone) { d.set({ timezone: this.timezone }); } else if (this.timezoneOffset) { d.set({ timezoneOffset: this.timezoneOffset }); } return d; }, finish: function (x) { var today, expression, orient, temp; x = (x instanceof Array) ? flattenAndCompact(x) : [ x ]; if (x.length === 0) { return null; } for (var i = 0 ; i < x.length ; i++) { if (typeof x[i] === "function") { x[i].call(this); } } if (this.now && !this.unit && !this.operator) { return new Date(); } else { today = finishUtils.getToday.call(this); } expression = !!(this.days && this.days !== null || this.orient || this.operator); orient = ((this.orient === "past" || this.operator === "subtract") ? -1 : 1); if (this.month && this.unit === "week") { this.value = this.month + 1; delete this.month; delete this.day; } if ((this.month || this.month === 0) && "year day hour minute second".indexOf(this.unit) !== -1) { if (!this.value) { this.value = this.month + 1; } this.month = null; expression = true; } if (!expression && this.weekday && !this.day && !this.days) { finishUtils.setDMYFromWeekday.call(this); } if (expression && this.weekday && this.unit !== "month" && this.unit !== "week") { finishUtils.setDaysFromWeekday.call(this, today, orient); } if (this.weekday && this.unit !== "week" && !this.day && !this.days) { temp = Date[this.weekday](); this.day = temp.getDate(); if (temp.getMonth() !== today.getMonth()) { this.month = temp.getMonth(); } } if (this.month && this.unit === "day" && this.operator) { if (!this.value) { this.value = (this.month + 1); } this.month = null; } if (this.value != null && this.month != null && this.year != null) { this.day = this.value * 1; } if (this.month && !this.day && this.value) { today.set({ day: this.value * 1 }); if (!expression) { this.day = this.value * 1; } } if (!this.month && this.value && this.unit === "month" && !this.now) { this.month = this.value; expression = true; } if (expression && (this.month || this.month === 0) && this.unit !== "year") { finishUtils.setMonthsFromMonth.call(this, today, orient); } if (!this.unit) { this.unit = "day"; } finishUtils.setUnitValue.call(this, orient); parseMeridian.call(this); if ((this.month || this.month === 0) && !this.day) { this.day = 1; } if (!this.orient && !this.operator && this.unit === "week" && this.value && !this.day && !this.month) { return Date.today().setWeek(this.value); } if (this.unit === "week" && this.weeks && !this.day && !this.month) { return finishUtils.generateDateFromWeeks.call(this); } if (expression && this.timezone && this.day && this.days) { this.day = this.days; } if (expression){ today.add(this); } else { today.set(this); } if (this.timezone) { this.timezone = this.timezone.toUpperCase(); var offset = $D.getTimezoneOffset(this.timezone); var timezone; if (today.hasDaylightSavingTime()) { // lets check that we're being sane with timezone setting timezone = $D.getTimezoneAbbreviation(offset, today.isDaylightSavingTime()); if (timezone !== this.timezone) { // bugger, we're in a place where things like EST vs EDT matters. if (today.isDaylightSavingTime()) { today.addHours(-1); } else { today.addHours(1); } } } today.setTimezoneOffset(offset); } return today; } }; }()); (function () { var $D = Date; $D.Grammar = {}; var _ = $D.Parsing.Operators, g = $D.Grammar, t = $D.Translator, _fn; // Allow rolling up into general purpose rules _fn = function () { return _.each(_.any.apply(null, arguments), _.not(g.ctoken2("timeContext"))); }; g.datePartDelimiter = _.rtoken(/^([\s\-\.\,\/\x27]+)/); g.timePartDelimiter = _.stoken(":"); g.whiteSpace = _.rtoken(/^\s*/); g.generalDelimiter = _.rtoken(/^(([\s\,]|at|@|on)+)/); var _C = {}; g.ctoken = function (keys) { var fn = _C[keys]; if (! fn) { var c = Date.CultureInfo.regexPatterns; var kx = keys.split(/\s+/), px = []; for (var i = 0; i < kx.length ; i++) { px.push(_.replace(_.rtoken(c[kx[i]]), kx[i])); } fn = _C[keys] = _.any.apply(null, px); } return fn; }; g.ctoken2 = function (key) { return _.rtoken(Date.CultureInfo.regexPatterns[key]); }; var cacheProcessRtoken = function (key, token, type, eachToken) { if (eachToken) { g[key] = _.cache(_.process(_.each(_.rtoken(token),_.optional(g.ctoken2(eachToken))), type)); } else { g[key] = _.cache(_.process(_.rtoken(token), type)); } }; var cacheProcessCtoken = function (token, type) { return _.cache(_.process(g.ctoken2(token), type)); }; var _F = {}; //function cache var _get = function (f) { _F[f] = (_F[f] || g.format(f)[0]); return _F[f]; }; g.allformats = function (fx) { var rx = []; if (fx instanceof Array) { for (var i = 0; i < fx.length; i++) { rx.push(_get(fx[i])); } } else { rx.push(_get(fx)); } return rx; }; g.formats = function (fx) { if (fx instanceof Array) { var rx = []; for (var i = 0 ; i < fx.length ; i++) { rx.push(_get(fx[i])); } return _.any.apply(null, rx); } else { return _get(fx); } }; var grammarFormats = { timeFormats: function(){ var i, RTokenKeys = [ "h", "hh", "H", "HH", "m", "mm", "s", "ss", "ss.s", "z", "zz" ], RToken = [ /^(0[0-9]|1[0-2]|[1-9])/, /^(0[0-9]|1[0-2])/, /^([0-1][0-9]|2[0-3]|[0-9])/, /^([0-1][0-9]|2[0-3])/, /^([0-5][0-9]|[0-9])/, /^[0-5][0-9]/, /^([0-5][0-9]|[0-9])/, /^[0-5][0-9]/, /^[0-5][0-9]\.[0-9]{1,3}/, /^((\+|\-)\s*\d\d\d\d)|((\+|\-)\d\d\:?\d\d)/, /^((\+|\-)\s*\d\d\d\d)|((\+|\-)\d\d\:?\d\d)/ ], tokens = [ t.hour, t.hour, t.hour, t.hour, t.minute, t.minute, t.second, t.second, t.secondAndMillisecond, t.timezone, t.timezone ]; for (i=0; i < RTokenKeys.length; i++) { cacheProcessRtoken(RTokenKeys[i], RToken[i], tokens[i]); } g.hms = _.cache(_.sequence([g.H, g.m, g.s], g.timePartDelimiter)); g.t = cacheProcessCtoken("shortMeridian", t.meridian); g.tt = cacheProcessCtoken("longMeridian", t.meridian); g.zzz = cacheProcessCtoken("timezone", t.timezone); g.timeSuffix = _.each(_.ignore(g.whiteSpace), _.set([ g.tt, g.zzz ])); g.time = _.each(_.optional(_.ignore(_.stoken("T"))), g.hms, g.timeSuffix); }, dateFormats: function () { // pre-loaded rules for different date part order preferences var _setfn = function () { return _.set(arguments, g.datePartDelimiter); }; var i, RTokenKeys = [ "d", "dd", "M", "MM", "y", "yy", "yyy", "yyyy" ], RToken = [ /^([0-2]\d|3[0-1]|\d)/, /^([0-2]\d|3[0-1])/, /^(1[0-2]|0\d|\d)/, /^(1[0-2]|0\d)/, /^(\d+)/, /^(\d\d)/, /^(\d\d?\d?\d?)/, /^(\d\d\d\d)/ ], tokens = [ t.day, t.day, t.month, t.month, t.year, t.year, t.year, t.year ], eachToken = [ "ordinalSuffix", "ordinalSuffix" ]; for (i=0; i < RTokenKeys.length; i++) { cacheProcessRtoken(RTokenKeys[i], RToken[i], tokens[i], eachToken[i]); } g.MMM = g.MMMM = _.cache(_.process(g.ctoken("jan feb mar apr may jun jul aug sep oct nov dec"), t.month)); g.ddd = g.dddd = _.cache(_.process(g.ctoken("sun mon tue wed thu fri sat"), function (s) { return function () { this.weekday = s; }; } )); g.day = _fn(g.d, g.dd); g.month = _fn(g.M, g.MMM); g.year = _fn(g.yyyy, g.yy); g.mdy = _setfn(g.ddd, g.month, g.day, g.year); g.ymd = _setfn(g.ddd, g.year, g.month, g.day); g.dmy = _setfn(g.ddd, g.day, g.month, g.year); g.date = function (s) { return ((g[Date.CultureInfo.dateElementOrder] || g.mdy).call(this, s)); }; }, relative: function () { // relative date / time expressions g.orientation = _.process(g.ctoken("past future"), function (s) { return function () { this.orient = s; }; } ); g.operator = _.process(g.ctoken("add subtract"), function (s) { return function () { this.operator = s; }; } ); g.rday = _.process(g.ctoken("yesterday tomorrow today now"), t.rday); g.unit = _.process(g.ctoken("second minute hour day week month year"), function (s) { return function () { this.unit = s; }; } ); } }; g.buildGrammarFormats = function () { // these need to be rebuilt every time the language changes. _C = {}; grammarFormats.timeFormats(); grammarFormats.dateFormats(); grammarFormats.relative(); g.value = _.process(_.rtoken(/^([-+]?\d+)?(st|nd|rd|th)?/), function (s) { return function () { this.value = s.replace(/\D/g, ""); }; } ); g.expression = _.set([g.rday, g.operator, g.value, g.unit, g.orientation, g.ddd, g.MMM ]); g.format = _.process(_.many( _.any( // translate format specifiers into grammar rules _.process( _.rtoken(/^(dd?d?d?(?!e)|MM?M?M?|yy?y?y?|hh?|HH?|mm?|ss?|tt?|zz?z?)/), function (fmt) { if (g[fmt]) { return g[fmt]; } else { throw $D.Parsing.Exception(fmt); } } ), // translate separator tokens into token rules _.process(_.rtoken(/^[^dMyhHmstz]+/), // all legal separators function (s) { return _.ignore(_.stoken(s)); } ) ) ), // construct the parser ... function (rules) { return _.process(_.each.apply(null, rules), t.finishExact); } ); // starting rule for general purpose grammar g._start = _.process(_.set([ g.date, g.time, g.expression ], g.generalDelimiter, g.whiteSpace), t.finish); }; g.buildGrammarFormats(); // parsing date format specifiers - ex: "h:m:s tt" // this little guy will generate a custom parser based // on the format string, ex: g.format("h:m:s tt") // check for these formats first g._formats = g.formats([ "\"yyyy-MM-ddTHH:mm:ssZ\"", "yyyy-MM-ddTHH:mm:ss.sz", "yyyy-MM-ddTHH:mm:ssZ", "yyyy-MM-ddTHH:mm:ssz", "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-ddTHH:mmZ", "yyyy-MM-ddTHH:mmz", "yyyy-MM-ddTHH:mm", "ddd, MMM dd, yyyy H:mm:ss tt", "ddd MMM d yyyy HH:mm:ss zzz", "MMddyyyy", "ddMMyyyy", "Mddyyyy", "ddMyyyy", "Mdyyyy", "dMyyyy", "yyyy", "Mdyy", "dMyy", "d" ]); // real starting rule: tries selected formats first, // then general purpose rule g.start = function (s) { try { var r = g._formats.call({}, s); if (r[1].length === 0) { return r; } } catch (e) {} return g._start.call({}, s); }; }()); (function () { var $D = Date; /** * @desc Converts the specified string value into its JavaScript Date equivalent using CultureInfo specific format information. * * Example

	///////////
	// Dates //
	///////////

	// 15-Oct-2004
	var d1 = Date.parse("10/15/2004");

	// 15-Oct-2004
	var d1 = Date.parse("15-Oct-2004");

	// 15-Oct-2004
	var d1 = Date.parse("2004.10.15");

	//Fri Oct 15, 2004
	var d1 = Date.parse("Fri Oct 15, 2004");

	///////////
	// Times //
	///////////

	// Today at 10 PM.
	var d1 = Date.parse("10 PM");

	// Today at 10:30 PM.
	var d1 = Date.parse("10:30 P.M.");

	// Today at 6 AM.
	var d1 = Date.parse("06am");

	/////////////////////
	// Dates and Times //
	/////////////////////

	// 8-July-2004 @ 10:30 PM
	var d1 = Date.parse("July 8th, 2004, 10:30 PM");

	// 1-July-2004 @ 10:30 PM
	var d1 = Date.parse("2004-07-01T22:30:00");

	////////////////////
	// Relative Dates //
	////////////////////

	// Returns today's date. The string "today" is culture specific.
	var d1 = Date.parse("today");

	// Returns yesterday's date. The string "yesterday" is culture specific.
	var d1 = Date.parse("yesterday");

	// Returns the date of the next thursday.
	var d1 = Date.parse("Next thursday");

	// Returns the date of the most previous monday.
	var d1 = Date.parse("last monday");

	// Returns today's day + one year.
	var d1 = Date.parse("next year");

	///////////////
	// Date Math //
	///////////////

	// Today + 2 days
	var d1 = Date.parse("t+2");

	// Today + 2 days
	var d1 = Date.parse("today + 2 days");

	// Today + 3 months
	var d1 = Date.parse("t+3m");

	// Today - 1 year
	var d1 = Date.parse("today - 1 year");

	// Today - 1 year
	var d1 = Date.parse("t-1y"); 


	/////////////////////////////
	// Partial Dates and Times //
	/////////////////////////////

	// July 15th of this year.
	var d1 = Date.parse("July 15");

	// 15th day of current day and year.
	var d1 = Date.parse("15");

	// July 1st of current year at 10pm.
	var d1 = Date.parse("7/1 10pm");
	
* * @param {String} The string value to convert into a Date object [Required] * @return {Date} A Date object or null if the string cannot be converted into a Date. */ var parseUtils = { removeOrds: function (s) { ords = s.match(/\b(\d+)(?:st|nd|rd|th)\b/); // find ordinal matches s = ((ords && ords.length === 2) ? s.replace(ords[0], ords[1]) : s); return s; }, grammarParser: function (s) { var r = null; try { r = $D.Grammar.start.call({}, s.replace(/^\s*(\S*(\s+\S+)*)\s*$/, "$1")); } catch (e) { return null; } return ((r[1].length === 0) ? r[0] : null); }, nativeFallback: function(s) { var t; try { // ok we haven't parsed it, last ditch attempt with the built-in parser. t = Date._parse(s); return (t || t === 0) ? new Date(t) : null; } catch (e) { return null; } } }; function parse (s) { var d; if (!s) { return null; } if (s instanceof Date) { return s.clone(); } if (s.length >= 4 && s.charAt(0) !== "0" && s.charAt(0) !== "+"&& s.charAt(0) !== "-") { // ie: 2004 will pass, 0800 won't. // Start with specific formats d = $D.Parsing.ISO.parse(s) || $D.Parsing.Numeric.parse(s); } if (d instanceof Date && !isNaN(d.getTime())) { return d; } else { // find ordinal dates (1st, 3rd, 8th, etc and remove them as they cause parsing issues) s = $D.Parsing.Normalizer.parse(parseUtils.removeOrds(s)); d = parseUtils.grammarParser(s); if (d !== null) { return d; } else { return parseUtils.nativeFallback(s); } } } if (!$D._parse) { $D._parse = $D.parse; } $D.parse = parse; Date.getParseFunction = function (fx) { var fns = Date.Grammar.allformats(fx); return function (s) { var r = null; for (var i = 0; i < fns.length; i++) { try { r = fns[i].call({}, s); } catch (e) { continue; } if (r[1].length === 0) { return r[0]; } } return null; }; }; /** * Converts the specified string value into its JavaScript Date equivalent using the specified format {String} or formats {Array} and the CultureInfo specific format information. * The format of the string value must match one of the supplied formats exactly. * * Example

	// 15-Oct-2004
	var d1 = Date.parseExact("10/15/2004", "M/d/yyyy");

	// 15-Oct-2004
	var d1 = Date.parse("15-Oct-2004", "M-ddd-yyyy");

	// 15-Oct-2004
	var d1 = Date.parse("2004.10.15", "yyyy.MM.dd");

	// Multiple formats
	var d1 = Date.parseExact("10/15/2004", ["M/d/yyyy", "MMMM d, yyyy"]);
	
* * @param {String} The string value to convert into a Date object [Required]. * @param {Object} The expected format {String} or an array of expected formats {Array} of the date string [Required]. * @return {Date} A Date object or null if the string cannot be converted into a Date. */ $D.parseExact = function (s, fx) { return $D.getParseFunction(fx)(s); }; }()); (function () { var $D = Date, $P = $D.prototype, // $C = $D.CultureInfo, // not used atm p = function (s, l) { if (!l) { l = 2; } return ("000" + s).slice(l * -1); }; /** * Converts a PHP format string to Java/.NET format string. * A PHP format string can be used with ._format or .format. * A Java/.NET format string can be used with .toString(). * The .parseExact function will only accept a Java/.NET format string * * Example * var f1 = "%m/%d/%y" * var f2 = Date.normalizeFormat(f1); // "MM/dd/yy" * * new Date().format(f1); // "04/13/08" * new Date()._format(f1); // "04/13/08" * new Date().toString(f2); // "04/13/08" * * var date = Date.parseExact("04/13/08", f2); // Sun Apr 13 2008 * * @param {String} A PHP format string consisting of one or more format spcifiers. * @return {String} The PHP format converted to a Java/.NET format string. */ var normalizerSubstitutions = { "d" : "dd", "%d": "dd", "D" : "ddd", "%a": "ddd", "j" : "dddd", "l" : "dddd", "%A": "dddd", "S" : "S", "F" : "MMMM", "%B": "MMMM", "m" : "MM", "%m": "MM", "M" : "MMM", "%b": "MMM", "%h": "MMM", "n" : "M", "Y" : "yyyy", "%Y": "yyyy", "y" : "yy", "%y": "yy", "g" : "h", "%I": "h", "G" : "H", "h" : "hh", "H" : "HH", "%H": "HH", "i" : "mm", "%M": "mm", "s" : "ss", "%S": "ss", "%r": "hh:mm tt", "%R": "H:mm", "%T": "H:mm:ss", "%X": "t", "%x": "d", "%e": "d", "%D": "MM/dd/yy", "%n": "\\n", "%t": "\\t", "e" : "z", "T" : "z", "%z": "z", "%Z": "z", "Z" : "ZZ", "N" : "u", "w" : "u", "%w": "u", "W" : "W", "%V": "W" }; var normalizer = { substitutes: function (m) { return normalizerSubstitutions[m]; }, interpreted: function (m, x) { var y; switch (m) { case "%u": return x.getDay() + 1; case "z": return x.getOrdinalNumber(); case "%j": return p(x.getOrdinalNumber(), 3); case "%U": var d1 = x.clone().set({month: 0, day: 1}).addDays(-1).moveToDayOfWeek(0), d2 = x.clone().addDays(1).moveToDayOfWeek(0, -1); return (d2 < d1) ? "00" : p((d2.getOrdinalNumber() - d1.getOrdinalNumber()) / 7 + 1); case "%W": return p(x.getWeek()); case "t": return $D.getDaysInMonth(x.getFullYear(), x.getMonth()); case "o": case "%G": return x.setWeek(x.getISOWeek()).toString("yyyy"); case "%g": return x._format("%G").slice(-2); case "a": case "%p": return t("tt").toLowerCase(); case "A": return t("tt").toUpperCase(); case "u": return p(x.getMilliseconds(), 3); case "I": return (x.isDaylightSavingTime()) ? 1 : 0; case "O": return x.getUTCOffset(); case "P": y = x.getUTCOffset(); return y.substring(0, y.length - 2) + ":" + y.substring(y.length - 2); case "B": var now = new Date(); return Math.floor(((now.getHours() * 3600) + (now.getMinutes() * 60) + now.getSeconds() + (now.getTimezoneOffset() + 60) * 60) / 86.4); case "c": return x.toISOString().replace(/\"/g, ""); case "U": return $D.strtotime("now"); case "%c": return t("d") + " " + t("t"); case "%C": return Math.floor(x.getFullYear() / 100 + 1); } }, shouldOverrideDefaults: function (m) { switch (m) { case "%e": return true; default: return false; } }, parse: function (m, context) { var formatString, c = context || new Date(); formatString = normalizer.substitutes(m); if (formatString) { return formatString; } formatString = normalizer.interpreted(m, c); if (formatString) { return formatString; } else { return m; } } }; $D.normalizeFormat = function (format, context) { return format.replace(/(%|\\)?.|%%/g, function(t){ return normalizer.parse(t, context); }); }; /** * Format a local Unix timestamp according to locale settings * * Example: * Date.strftime("%m/%d/%y", new Date()); // "04/13/08" * Date.strftime("c", "2008-04-13T17:52:03Z"); // "04/13/08" * * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @param {Number|String} The number representing the number of seconds that have elapsed since January 1, 1970 (local time). * @return {String} A string representation of the current Date object. */ $D.strftime = function (format, time) { var d = Date.parse(time); return d._format(format); }; /** * Parse any textual datetime description into a Unix timestamp. * A Unix timestamp is the number of seconds that have elapsed since January 1, 1970 (midnight UTC/GMT). * * Example: * Date.strtotime("04/13/08"); // 1208044800 * Date.strtotime("1970-01-01T00:00:00Z"); // 0 * * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @param {Object} A string or date object. * @return {String} A string representation of the current Date object. */ $D.strtotime = function (time) { var d = $D.parse(time); return Math.round($D.UTC(d.getUTCFullYear(), d.getUTCMonth(), d.getUTCDate(), d.getUTCHours(), d.getUTCMinutes(), d.getUTCSeconds(), d.getUTCMilliseconds()) / 1000); }; /** * Converts the value of the current Date object to its equivalent string representation using a PHP/Unix style of date format specifiers. * Format Specifiers * Format Description Example * ------ --------------------------------------------------------------------------- ----------------------- * %a abbreviated weekday name according to the current localed "Mon" through "Sun" * %A full weekday name according to the current localed "Sunday" through "Saturday" * %b abbreviated month name according to the current localed "Jan" through "Dec" * %B full month name according to the current locale "January" through "December" * %c preferred date and time representation for the current locale "4/13/2008 12:33 PM" * %C century number (the year divided by 100 and truncated to an integer) "00" to "99" * %d day of the month as a decimal number "01" to "31" * %D same as %m/%d/%y "04/13/08" * %e day of the month as a decimal number, a single digit is preceded by a space "1" to "31" * %g like %G, but without the century "08" * %G The 4-digit year corresponding to the ISO week number (see %V). "2008" * This has the same format and value as %Y, except that if the ISO week number * belongs to the previous or next year, that year is used instead. * %h same as %b "Jan" through "Dec" * %H hour as a decimal number using a 24-hour clock. "00" to "23" * %I hour as a decimal number using a 12-hour clock. "01" to "12" * %j day of the year as a decimal number. "001" to "366" * %m month as a decimal number. "01" to "12" * %M minute as a decimal number. "00" to "59" * %n newline character "\n" * %p either "am" or "pm" according to the given time value, or the "am" or "pm" * corresponding strings for the current locale. * %r time in a.m. and p.m. notation "8:44 PM" * %R time in 24 hour notation "20:44" * %S second as a decimal number "00" to "59" * %t tab character "\t" * %T current time, equal to %H:%M:%S "12:49:11" * %u weekday as a decimal number ["1", "7"], with "1" representing Monday "1" to "7" * %U week number of the current year as a decimal number, starting with the "0" to ("52" or "53") * first Sunday as the first day of the first week * %V The ISO 8601:1988 week number of the current year as a decimal number, "00" to ("52" or "53") * range 01 to 53, where week 1 is the first week that has at least 4 days * in the current year, and with Monday as the first day of the week. * (Use %G or %g for the year component that corresponds to the week number * for the specified timestamp.) * %W week number of the current year as a decimal number, starting with the "00" to ("52" or "53") * first Monday as the first day of the first week * %w day of the week as a decimal, Sunday being "0" "0" to "6" * %x preferred date representation for the current locale without the time "4/13/2008" * %X preferred time representation for the current locale without the date "12:53:05" * %y year as a decimal number without a century "00" "99" * %Y year as a decimal number including the century "2008" * %Z time zone or name or abbreviation "UTC", "EST", "PST" * %z same as %Z * %% a literal "%" characters "%" * d Day of the month, 2 digits with leading zeros "01" to "31" * D A textual representation of a day, three letters "Mon" through "Sun" * j Day of the month without leading zeros "1" to "31" * l A full textual representation of the day of the week (lowercase "L") "Sunday" through "Saturday" * N ISO-8601 numeric representation of the day of the week (added in PHP 5.1.0) "1" (for Monday) through "7" (for Sunday) * S English ordinal suffix for the day of the month, 2 characters "st", "nd", "rd" or "th". Works well with j * w Numeric representation of the day of the week "0" (for Sunday) through "6" (for Saturday) * z The day of the year (starting from "0") "0" through "365" * W ISO-8601 week number of year, weeks starting on Monday "00" to ("52" or "53") * F A full textual representation of a month, such as January or March "January" through "December" * m Numeric representation of a month, with leading zeros "01" through "12" * M A short textual representation of a month, three letters "Jan" through "Dec" * n Numeric representation of a month, without leading zeros "1" through "12" * t Number of days in the given month "28" through "31" * L Whether it's a leap year "1" if it is a leap year, "0" otherwise * o ISO-8601 year number. This has the same value as Y, except that if the "2008" * ISO week number (W) belongs to the previous or next year, that year * is used instead. * Y A full numeric representation of a year, 4 digits "2008" * y A two digit representation of a year "08" * a Lowercase Ante meridiem and Post meridiem "am" or "pm" * A Uppercase Ante meridiem and Post meridiem "AM" or "PM" * B Swatch Internet time "000" through "999" * g 12-hour format of an hour without leading zeros "1" through "12" * G 24-hour format of an hour without leading zeros "0" through "23" * h 12-hour format of an hour with leading zeros "01" through "12" * H 24-hour format of an hour with leading zeros "00" through "23" * i Minutes with leading zeros "00" to "59" * s Seconds, with leading zeros "00" through "59" * u Milliseconds "54321" * e Timezone identifier "UTC", "EST", "PST" * I Whether or not the date is in daylight saving time (uppercase i) "1" if Daylight Saving Time, "0" otherwise * O Difference to Greenwich time (GMT) in hours "+0200", "-0600" * P Difference to Greenwich time (GMT) with colon between hours and minutes "+02:00", "-06:00" * T Timezone abbreviation "UTC", "EST", "PST" * Z Timezone offset in seconds. The offset for timezones west of UTC is "-43200" through "50400" * always negative, and for those east of UTC is always positive. * c ISO 8601 date "2004-02-12T15:19:21+00:00" * r RFC 2822 formatted date "Thu, 21 Dec 2000 16:01:07 +0200" * U Seconds since the Unix Epoch (January 1 1970 00:00:00 GMT) "0" * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @return {String} A string representation of the current Date object. */ var formatReplace = function (context) { return function (m) { var formatString, override = false; if (m.charAt(0) === "\\" || m.substring(0, 2) === "%%") { return m.replace("\\", "").replace("%%", "%"); } override = normalizer.shouldOverrideDefaults(m); formatString = $D.normalizeFormat(m, context); if (formatString) { return context.toString(formatString, override); } }; }; $P._format = function (format) { var formatter = formatReplace(this); if (!format) { return this._toString(); } else { return format.replace(/(%|\\)?.|%%/g, formatter); } }; if (!$P.format) { $P.format = $P._format; } }()); (function () { "use strict"; var gFn = function (attr) { return function () { return this[attr]; }; }; var sFn = function (attr) { return function (val) { this[attr] = val; return this; }; }; var attrs = ["years", "months", "days", "hours", "minutes", "seconds", "milliseconds"]; var addSetFuncs = function (context, attrs) { for (var i = 0; i < attrs.length ; i++) { var $a = attrs[i], $b = $a.slice(0, 1).toUpperCase() + $a.slice(1); context.prototype[$a] = 0; context.prototype["get" + $b] = gFn($a); context.prototype["set" + $b] = sFn($a); } }; /** * new TimeSpan(milliseconds); * new TimeSpan(days, hours, minutes, seconds); * new TimeSpan(days, hours, minutes, seconds, milliseconds); */ var TimeSpan = function (days, hours, minutes, seconds, milliseconds) { if (arguments.length === 1 && typeof days === "number") { var orient = (days < 0) ? -1 : +1; var millsLeft = Math.abs(days); this.setDays(Math.floor(millsLeft / 86400000) * orient); millsLeft = millsLeft % 86400000; this.setHours(Math.floor(millsLeft / 3600000) * orient); millsLeft = millsLeft % 3600000; this.setMinutes(Math.floor(millsLeft / 60000) * orient); millsLeft = millsLeft % 60000; this.setSeconds(Math.floor(millsLeft / 1000) * orient); millsLeft = millsLeft % 1000; this.setMilliseconds(millsLeft * orient); } else { this.set(days, hours, minutes, seconds, milliseconds); } this.getTotalMilliseconds = function () { return (this.getDays() * 86400000) + (this.getHours() * 3600000) + (this.getMinutes() * 60000) + (this.getSeconds() * 1000); }; this.compareTo = function (time) { var t1 = new Date(1970, 1, 1, this.getHours(), this.getMinutes(), this.getSeconds()), t2; if (time === null) { t2 = new Date(1970, 1, 1, 0, 0, 0); } else { t2 = new Date(1970, 1, 1, time.getHours(), time.getMinutes(), time.getSeconds()); } return (t1 < t2) ? -1 : (t1 > t2) ? 1 : 0; }; this.equals = function (time) { return (this.compareTo(time) === 0); }; this.add = function (time) { return (time === null) ? this : this.addSeconds(time.getTotalMilliseconds() / 1000); }; this.subtract = function (time) { return (time === null) ? this : this.addSeconds(-time.getTotalMilliseconds() / 1000); }; this.addDays = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 86400000)); }; this.addHours = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 3600000)); }; this.addMinutes = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 60000)); }; this.addSeconds = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 1000)); }; this.addMilliseconds = function (n) { return new TimeSpan(this.getTotalMilliseconds() + n); }; this.get12HourHour = function () { return (this.getHours() > 12) ? this.getHours() - 12 : (this.getHours() === 0) ? 12 : this.getHours(); }; this.getDesignator = function () { return (this.getHours() < 12) ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator; }; this.toString = function (format) { this._toString = function () { if (this.getDays() !== null && this.getDays() > 0) { return this.getDays() + "." + this.getHours() + ":" + this.p(this.getMinutes()) + ":" + this.p(this.getSeconds()); } else { return this.getHours() + ":" + this.p(this.getMinutes()) + ":" + this.p(this.getSeconds()); } }; this.p = function (s) { return (s.toString().length < 2) ? "0" + s : s; }; var me = this; return format ? format.replace(/dd?|HH?|hh?|mm?|ss?|tt?/g, function (format) { switch (format) { case "d": return me.getDays(); case "dd": return me.p(me.getDays()); case "H": return me.getHours(); case "HH": return me.p(me.getHours()); case "h": return me.get12HourHour(); case "hh": return me.p(me.get12HourHour()); case "m": return me.getMinutes(); case "mm": return me.p(me.getMinutes()); case "s": return me.getSeconds(); case "ss": return me.p(me.getSeconds()); case "t": return ((me.getHours() < 12) ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator).substring(0, 1); case "tt": return (me.getHours() < 12) ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator; } } ) : this._toString(); }; return this; }; addSetFuncs(TimeSpan, attrs.slice(2)); TimeSpan.prototype.set = function (days, hours, minutes, seconds, milliseconds){ this.setDays(days || this.getDays()); this.setHours(hours || this.getHours()); this.setMinutes(minutes || this.getMinutes()); this.setSeconds(seconds || this.getSeconds()); this.setMilliseconds(milliseconds || this.getMilliseconds()); }; /** * Gets the time of day for this date instances. * @return {TimeSpan} TimeSpan */ Date.prototype.getTimeOfDay = function () { return new TimeSpan(0, this.getHours(), this.getMinutes(), this.getSeconds(), this.getMilliseconds()); }; Date.TimeSpan = TimeSpan; if (typeof window !== "undefined" ) { // keeping API compatible for v1.x window.TimeSpan = TimeSpan; } }()); (function () { "use strict"; var attrs = ["years", "months", "days", "hours", "minutes", "seconds", "milliseconds"]; var gFn = function (attr) { return function () { return this[attr]; }; }; var sFn = function (attr) { return function (val) { this[attr] = val; return this; }; }; var addSetFuncs = function (context, attrs) { for (var i = 0; i < attrs.length ; i++) { var $a = attrs[i], $b = $a.slice(0, 1).toUpperCase() + $a.slice(1); context.prototype[$a] = 0; context.prototype["get" + $b] = gFn($a); context.prototype["set" + $b] = sFn($a); } }; var setMonthsAndYears = function (orient, d1, d2, context) { function inc() { d1.addMonths(-orient); context.months++; if (context.months === 12) { context.years++; context.months = 0; } } if (orient === +1) { while (d1 > d2) { inc(); } } else { while (d1 < d2) { inc(); } } context.months--; context.months *= orient; context.years *= orient; }; var adjustForDST = function(orient, startDate, endDate) { var hasDSTMismatch = (false === (startDate.isDaylightSavingTime() === endDate.isDaylightSavingTime())); if (hasDSTMismatch && orient === 1) { startDate.addHours(-1); } else if (hasDSTMismatch) { startDate.addHours(1); } }; /** * TimePeriod(startDate, endDate); * TimePeriod(years, months, days, hours, minutes, seconds, milliseconds); */ var TimePeriod = function (years, months, days, hours, minutes, seconds, milliseconds) { if (arguments.length === 7) { this.set(years, months, days, hours, minutes, seconds, milliseconds); } else if (arguments.length === 2 && arguments[0] instanceof Date && arguments[1] instanceof Date) { var startDate = arguments[0].clone(); var endDate = arguments[1].clone(); var orient = (startDate > endDate) ? +1 : -1; this.dates = { start: arguments[0].clone(), end: arguments[1].clone() }; setMonthsAndYears(orient, startDate, endDate, this); adjustForDST(orient, startDate, endDate); // // TODO - adjust for DST var diff = endDate - startDate; if (diff !== 0) { var ts = new TimeSpan(diff); this.set(this.years, this.months, ts.getDays(), ts.getHours(), ts.getMinutes(), ts.getSeconds(), ts.getMilliseconds()); } } return this; }; // create all the set functions. addSetFuncs(TimePeriod, attrs); TimePeriod.prototype.set = function (years, months, days, hours, minutes, seconds, milliseconds){ this.setYears(years || this.getYears()); this.setMonths(months || this.getMonths()); this.setDays(days || this.getDays()); this.setHours(hours || this.getHours()); this.setMinutes(minutes || this.getMinutes()); this.setSeconds(seconds || this.getSeconds()); this.setMilliseconds(milliseconds || this.getMilliseconds()); }; Date.TimePeriod = TimePeriod; if (typeof window !== "undefined") { // keeping API compatible for v1.x window.TimePeriod = TimePeriod; } }()); ================================================ FILE: build/date-en-PH.js ================================================ /** * @overview datejs * @version 1.0.0-rc3 * @author Gregory Wild-Smith * @copyright 2015 Gregory Wild-Smith * @license MIT * @homepage https://github.com/abritinthebay/datejs */ /* * DateJS Culture String File * Country Code: en-PH * Name: English (Republic of the Philippines) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["en-PH"] = { "name": "en-PH", "englishName": "English (Republic of the Philippines)", "nativeName": "English (Philippines)", "Sunday": "Sunday", "Monday": "Monday", "Tuesday": "Tuesday", "Wednesday": "Wednesday", "Thursday": "Thursday", "Friday": "Friday", "Saturday": "Saturday", "Sun": "Sun", "Mon": "Mon", "Tue": "Tue", "Wed": "Wed", "Thu": "Thu", "Fri": "Fri", "Sat": "Sat", "Su": "Su", "Mo": "Mo", "Tu": "Tu", "We": "We", "Th": "Th", "Fr": "Fr", "Sa": "Sa", "S_Sun_Initial": "S", "M_Mon_Initial": "M", "T_Tue_Initial": "T", "W_Wed_Initial": "W", "T_Thu_Initial": "T", "F_Fri_Initial": "F", "S_Sat_Initial": "S", "January": "January", "February": "February", "March": "March", "April": "April", "May": "May", "June": "June", "July": "July", "August": "August", "September": "September", "October": "October", "November": "November", "December": "December", "Jan_Abbr": "Jan", "Feb_Abbr": "Feb", "Mar_Abbr": "Mar", "Apr_Abbr": "Apr", "May_Abbr": "May", "Jun_Abbr": "Jun", "Jul_Abbr": "Jul", "Aug_Abbr": "Aug", "Sep_Abbr": "Sep", "Oct_Abbr": "Oct", "Nov_Abbr": "Nov", "Dec_Abbr": "Dec", "AM": "AM", "PM": "PM", "firstDayOfWeek": 0, "twoDigitYearMax": 2029, "mdy": "mdy", "M/d/yyyy": "M/d/yyyy", "dddd, MMMM dd, yyyy": "dddd, MMMM dd, yyyy", "h:mm tt": "h:mm tt", "h:mm:ss tt": "h:mm:ss tt", "dddd, MMMM dd, yyyy h:mm:ss tt": "dddd, MMMM dd, yyyy h:mm:ss tt", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "MMMM dd", "MMMM, yyyy": "MMMM, yyyy", "/jan(uary)?/": "jan(uary)?", "/feb(ruary)?/": "feb(ruary)?", "/mar(ch)?/": "mar(ch)?", "/apr(il)?/": "apr(il)?", "/may/": "may", "/jun(e)?/": "jun(e)?", "/jul(y)?/": "jul(y)?", "/aug(ust)?/": "aug(ust)?", "/sep(t(ember)?)?/": "sep(t(ember)?)?", "/oct(ober)?/": "oct(ober)?", "/nov(ember)?/": "nov(ember)?", "/dec(ember)?/": "dec(ember)?", "/^su(n(day)?)?/": "^su(n(day)?)?", "/^mo(n(day)?)?/": "^mo(n(day)?)?", "/^tu(e(s(day)?)?)?/": "^tu(e(s(day)?)?)?", "/^we(d(nesday)?)?/": "^we(d(nesday)?)?", "/^th(u(r(s(day)?)?)?)?/": "^th(u(r(s(day)?)?)?)?", "/^fr(i(day)?)?/": "^fr(i(day)?)?", "/^sa(t(urday)?)?/": "^sa(t(urday)?)?", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "en-PH"; /** * @overview datejs * @version 1.0.0-rc3 * @author Gregory Wild-Smith * @copyright 2015 Gregory Wild-Smith * @license MIT * @homepage https://github.com/abritinthebay/datejs */(function () { var $D = Date; var lang = Date.CultureStrings ? Date.CultureStrings.lang : null; var loggedKeys = {}; // for debug purposes. var getText = { getFromKey: function (key, countryCode) { var output; if (Date.CultureStrings && Date.CultureStrings[countryCode] && Date.CultureStrings[countryCode][key]) { output = Date.CultureStrings[countryCode][key]; } else { output = getText.buildFromDefault(key); } if (key.charAt(0) === "/") { // Assume it's a regex output = getText.buildFromRegex(key, countryCode); } return output; }, getFromObjectValues: function (obj, countryCode) { var key, output = {}; for(key in obj) { if (obj.hasOwnProperty(key)) { output[key] = getText.getFromKey(obj[key], countryCode); } } return output; }, getFromObjectKeys: function (obj, countryCode) { var key, output = {}; for(key in obj) { if (obj.hasOwnProperty(key)) { output[getText.getFromKey(key, countryCode)] = obj[key]; } } return output; }, getFromArray: function (arr, countryCode) { var output = []; for (var i=0; i < arr.length; i++){ if (i in arr) { output[i] = getText.getFromKey(arr[i], countryCode); } } return output; }, buildFromDefault: function (key) { var output, length, split, last; switch(key) { case "name": output = "en-US"; break; case "englishName": output = "English (United States)"; break; case "nativeName": output = "English (United States)"; break; case "twoDigitYearMax": output = 2049; break; case "firstDayOfWeek": output = 0; break; default: output = key; split = key.split("_"); length = split.length; if (length > 1 && key.charAt(0) !== "/") { // if the key isn't a regex and it has a split. last = split[(length - 1)].toLowerCase(); if (last === "initial" || last === "abbr") { output = split[0]; } } break; } return output; }, buildFromRegex: function (key, countryCode) { var output; if (Date.CultureStrings && Date.CultureStrings[countryCode] && Date.CultureStrings[countryCode][key]) { output = new RegExp(Date.CultureStrings[countryCode][key], "i"); } else { output = new RegExp(key.replace(new RegExp("/", "g"),""), "i"); } return output; } }; var shallowMerge = function (obj1, obj2) { for (var attrname in obj2) { if (obj2.hasOwnProperty(attrname)) { obj1[attrname] = obj2[attrname]; } } }; var __ = function (key, language) { var countryCode = (language) ? language : lang; loggedKeys[key] = key; if (typeof key === "object") { if (key instanceof Array) { return getText.getFromArray(key, countryCode); } else { return getText.getFromObjectKeys(key, countryCode); } } else { return getText.getFromKey(key, countryCode); } }; var loadI18nScript = function (code) { // paatterned after jQuery's getScript. var url = Date.Config.i18n + code + ".js"; var head = document.getElementsByTagName("head")[0] || document.documentElement; var script = document.createElement("script"); script.src = url; var completed = false; var events = { done: function (){} // placeholder function }; // Attach handlers for all browsers script.onload = script.onreadystatechange = function() { if ( !completed && (!this.readyState || this.readyState === "loaded" || this.readyState === "complete") ) { events.done(); head.removeChild(script); } }; setTimeout(function() { head.insertBefore(script, head.firstChild); }, 0); // allows return to execute first return { done: function (cb) { events.done = function() { if (cb) { setTimeout(cb,0); } }; } }; }; var buildInfo = { buildFromMethodHash: function (obj) { var key; for(key in obj) { if (obj.hasOwnProperty(key)) { obj[key] = buildInfo[obj[key]](); } } return obj; }, timeZoneDST: function () { var DST = { "CHADT": "+1345", "NZDT": "+1300", "AEDT": "+1100", "ACDT": "+1030", "AZST": "+0500", "IRDT": "+0430", "EEST": "+0300", "CEST": "+0200", "BST": "+0100", "PMDT": "-0200", "ADT": "-0300", "NDT": "-0230", "EDT": "-0400", "CDT": "-0500", "MDT": "-0600", "PDT": "-0700", "AKDT": "-0800", "HADT": "-0900" }; return __(DST); }, timeZoneStandard: function () { var standard = { "LINT": "+1400", "TOT": "+1300", "CHAST": "+1245", "NZST": "+1200", "NFT": "+1130", "SBT": "+1100", "AEST": "+1000", "ACST": "+0930", "JST": "+0900", "CWST": "+0845", "CT": "+0800", "ICT": "+0700", "MMT": "+0630", "BST": "+0600", "NPT": "+0545", "IST": "+0530", "PKT": "+0500", "AFT": "+0430", "MSK": "+0400", "IRST": "+0330", "FET": "+0300", "EET": "+0200", "CET": "+0100", "GMT": "+0000", "UTC": "+0000", "CVT": "-0100", "GST": "-0200", "BRT": "-0300", "NST": "-0330", "AST": "-0400", "EST": "-0500", "CST": "-0600", "MST": "-0700", "PST": "-0800", "AKST": "-0900", "MIT": "-0930", "HST": "-1000", "SST": "-1100", "BIT": "-1200" }; return __(standard); }, timeZones: function (data) { var zone; data.timezones = []; for (zone in data.abbreviatedTimeZoneStandard) { if (data.abbreviatedTimeZoneStandard.hasOwnProperty(zone)) { data.timezones.push({ name: zone, offset: data.abbreviatedTimeZoneStandard[zone]}); } } for (zone in data.abbreviatedTimeZoneDST) { if (data.abbreviatedTimeZoneDST.hasOwnProperty(zone)) { data.timezones.push({ name: zone, offset: data.abbreviatedTimeZoneDST[zone], dst: true}); } } return data.timezones; }, days: function () { return __(["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"]); }, dayAbbr: function () { return __(["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"]); }, dayShortNames: function () { return __(["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"]); }, dayFirstLetters: function () { return __(["S_Sun_Initial", "M_Mon_Initial", "T_Tues_Initial", "W_Wed_Initial", "T_Thu_Initial", "F_Fri_Initial", "S_Sat_Initial"]); }, months: function () { return __(["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"]); }, monthAbbr: function () { return __(["Jan_Abbr", "Feb_Abbr", "Mar_Abbr", "Apr_Abbr", "May_Abbr", "Jun_Abbr", "Jul_Abbr", "Aug_Abbr", "Sep_Abbr", "Oct_Abbr", "Nov_Abbr", "Dec_Abbr"]); }, formatPatterns: function () { return getText.getFromObjectValues({ shortDate: "M/d/yyyy", longDate: "dddd, MMMM dd, yyyy", shortTime: "h:mm tt", longTime: "h:mm:ss tt", fullDateTime: "dddd, MMMM dd, yyyy h:mm:ss tt", sortableDateTime: "yyyy-MM-ddTHH:mm:ss", universalSortableDateTime: "yyyy-MM-dd HH:mm:ssZ", rfc1123: "ddd, dd MMM yyyy HH:mm:ss", monthDay: "MMMM dd", yearMonth: "MMMM, yyyy" }, Date.i18n.currentLanguage()); }, regex: function () { return getText.getFromObjectValues({ inTheMorning: "/( in the )(morn(ing)?)\\b/", thisMorning: "/(this )(morn(ing)?)\\b/", amThisMorning: "/(\b\\d(am)? )(this )(morn(ing)?)/", inTheEvening: "/( in the )(even(ing)?)\\b/", thisEvening: "/(this )(even(ing)?)\\b/", pmThisEvening: "/(\b\\d(pm)? )(this )(even(ing)?)/", jan: "/jan(uary)?/", feb: "/feb(ruary)?/", mar: "/mar(ch)?/", apr: "/apr(il)?/", may: "/may/", jun: "/jun(e)?/", jul: "/jul(y)?/", aug: "/aug(ust)?/", sep: "/sep(t(ember)?)?/", oct: "/oct(ober)?/", nov: "/nov(ember)?/", dec: "/dec(ember)?/", sun: "/^su(n(day)?)?/", mon: "/^mo(n(day)?)?/", tue: "/^tu(e(s(day)?)?)?/", wed: "/^we(d(nesday)?)?/", thu: "/^th(u(r(s(day)?)?)?)?/", fri: "/fr(i(day)?)?/", sat: "/^sa(t(urday)?)?/", future: "/^next/", past: "/^last|past|prev(ious)?/", add: "/^(\\+|aft(er)?|from|hence)/", subtract: "/^(\\-|bef(ore)?|ago)/", yesterday: "/^yes(terday)?/", today: "/^t(od(ay)?)?/", tomorrow: "/^tom(orrow)?/", now: "/^n(ow)?/", millisecond: "/^ms|milli(second)?s?/", second: "/^sec(ond)?s?/", minute: "/^mn|min(ute)?s?/", hour: "/^h(our)?s?/", week: "/^w(eek)?s?/", month: "/^m(onth)?s?/", day: "/^d(ay)?s?/", year: "/^y(ear)?s?/", shortMeridian: "/^(a|p)/", longMeridian: "/^(a\\.?m?\\.?|p\\.?m?\\.?)/", timezone: "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/", ordinalSuffix: "/^\\s*(st|nd|rd|th)/", timeContext: "/^\\s*(\\:|a(?!u|p)|p)/" }, Date.i18n.currentLanguage()); } }; var CultureInfo = function () { var info = getText.getFromObjectValues({ name: "name", englishName: "englishName", nativeName: "nativeName", amDesignator: "AM", pmDesignator: "PM", firstDayOfWeek: "firstDayOfWeek", twoDigitYearMax: "twoDigitYearMax", dateElementOrder: "mdy" }, Date.i18n.currentLanguage()); var constructedInfo = buildInfo.buildFromMethodHash({ dayNames: "days", abbreviatedDayNames: "dayAbbr", shortestDayNames: "dayShortNames", firstLetterDayNames: "dayFirstLetters", monthNames: "months", abbreviatedMonthNames: "monthAbbr", formatPatterns: "formatPatterns", regexPatterns: "regex", abbreviatedTimeZoneDST: "timeZoneDST", abbreviatedTimeZoneStandard: "timeZoneStandard" }); shallowMerge(info, constructedInfo); buildInfo.timeZones(info); return info; }; $D.i18n = { __: function (key, lang) { return __(key, lang); }, currentLanguage: function () { return lang || "en-US"; }, setLanguage: function (code, force, cb) { var async = false; if (force || code === "en-US" || (!!Date.CultureStrings && !!Date.CultureStrings[code])) { lang = code; Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings.lang = code; Date.CultureInfo = new CultureInfo(); } else { if (!(!!Date.CultureStrings && !!Date.CultureStrings[code])) { if (typeof exports !== "undefined" && this.exports !== exports) { // we're in a Node enviroment, load it using require try { require("../i18n/" + code + ".js"); lang = code; Date.CultureStrings.lang = code; Date.CultureInfo = new CultureInfo(); } catch (e) { // var str = "The language for '" + code + "' could not be loaded by Node. It likely does not exist."; throw new Error("The DateJS IETF language tag '" + code + "' could not be loaded by Node. It likely does not exist."); } } else if (Date.Config && Date.Config.i18n) { // we know the location of the files, so lets load them async = true; loadI18nScript(code).done(function(){ lang = code; Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings.lang = code; Date.CultureInfo = new CultureInfo(); $D.Parsing.Normalizer.buildReplaceData(); // because this is async if ($D.Grammar) { $D.Grammar.buildGrammarFormats(); // so we can parse those strings... } if (cb) { setTimeout(cb,0); } }); } else { Date.console.error("The DateJS IETF language tag '" + code + "' is not available and has not been loaded."); return false; } } } $D.Parsing.Normalizer.buildReplaceData(); // rebuild normalizer strings if ($D.Grammar) { $D.Grammar.buildGrammarFormats(); // so we can parse those strings... } if (!async && cb) { setTimeout(cb,0); } }, getLoggedKeys: function () { return loggedKeys; }, updateCultureInfo: function () { Date.CultureInfo = new CultureInfo(); } }; $D.i18n.updateCultureInfo(); // run automatically }()); (function () { var $D = Date, $P = $D.prototype, p = function (s, l) { if (!l) { l = 2; } return ("000" + s).slice(l * -1); }; if (typeof window !== "undefined" && typeof window.console !== "undefined" && typeof window.console.log !== "undefined") { $D.console = console; // used only to raise non-critical errors if available } else { // set mock so we don't give errors. $D.console = { log: function(){}, error: function(){} }; } $D.Config = $D.Config || {}; $D.initOverloads = function() { /** * Overload of Date.now. Allows an alternate call for Date.now where it returns the * current Date as an object rather than just milliseconds since the Unix Epoch. * * Also provides an implementation of now() for browsers (IE<9) that don't have it. * * Backwards compatible so with work with either: * Date.now() [returns ms] * or * Date.now(true) [returns Date] */ if (!$D.now) { $D._now = function now() { return new Date().getTime(); }; } else if (!$D._now) { $D._now = $D.now; } $D.now = function (returnObj) { if (returnObj) { return $D.present(); } else { return $D._now(); } }; if ( !$P.toISOString ) { $P.toISOString = function() { return this.getUTCFullYear() + "-" + p(this.getUTCMonth() + 1) + "-" + p(this.getUTCDate()) + "T" + p(this.getUTCHours()) + ":" + p(this.getUTCMinutes()) + ":" + p(this.getUTCSeconds()) + "." + String( (this.getUTCMilliseconds()/1000).toFixed(3)).slice(2, 5) + "Z"; }; } // private if ( $P._toString === undefined ){ $P._toString = $P.toString; } }; $D.initOverloads(); /** * Gets a date that is set to the current date. The time is set to the start of the day (00:00 or 12:00 AM). * @return {Date} The current date. */ $D.today = function () { return new Date().clearTime(); }; /** * Gets a date that is set to the current date and time (same as new Date, but chainable) * @return {Date} The current date. */ $D.present = function () { return new Date(); }; /** * Compares the first date to the second date and returns an number indication of their relative values. * @param {Date} First Date object to compare [Required]. * @param {Date} Second Date object to compare to [Required]. * @return {Number} -1 = date1 is lessthan date2. 0 = values are equal. 1 = date1 is greaterthan date2. */ $D.compare = function (date1, date2) { if (isNaN(date1) || isNaN(date2)) { throw new Error(date1 + " - " + date2); } else if (date1 instanceof Date && date2 instanceof Date) { return (date1 < date2) ? -1 : (date1 > date2) ? 1 : 0; } else { throw new TypeError(date1 + " - " + date2); } }; /** * Compares the first Date object to the second Date object and returns true if they are equal. * @param {Date} First Date object to compare [Required] * @param {Date} Second Date object to compare to [Required] * @return {Boolean} true if dates are equal. false if they are not equal. */ $D.equals = function (date1, date2) { return (date1.compareTo(date2) === 0); }; /** * Gets the language appropriate day name when given the day number(0-6) * eg - 0 == Sunday * @return {String} The day name */ $D.getDayName = function (n) { return Date.CultureInfo.dayNames[n]; }; /** * Gets the day number (0-6) if given a CultureInfo specific string which is a valid dayName, abbreviatedDayName or shortestDayName (two char). * @param {String} The name of the day (eg. "Monday, "Mon", "tuesday", "tue", "We", "we"). * @return {Number} The day number */ $D.getDayNumberFromName = function (name) { var n = Date.CultureInfo.dayNames, m = Date.CultureInfo.abbreviatedDayNames, o = Date.CultureInfo.shortestDayNames, s = name.toLowerCase(); for (var i = 0; i < n.length; i++) { if (n[i].toLowerCase() === s || m[i].toLowerCase() === s || o[i].toLowerCase() === s) { return i; } } return -1; }; /** * Gets the month number (0-11) if given a Culture Info specific string which is a valid monthName or abbreviatedMonthName. * @param {String} The name of the month (eg. "February, "Feb", "october", "oct"). * @return {Number} The day number */ $D.getMonthNumberFromName = function (name) { var n = Date.CultureInfo.monthNames, m = Date.CultureInfo.abbreviatedMonthNames, s = name.toLowerCase(); for (var i = 0; i < n.length; i++) { if (n[i].toLowerCase() === s || m[i].toLowerCase() === s) { return i; } } return -1; }; /** * Gets the language appropriate month name when given the month number(0-11) * eg - 0 == January * @return {String} The month name */ $D.getMonthName = function (n) { return Date.CultureInfo.monthNames[n]; }; /** * Determines if the current date instance is within a LeapYear. * @param {Number} The year. * @return {Boolean} true if date is within a LeapYear, otherwise false. */ $D.isLeapYear = function (year) { return ((year % 4 === 0 && year % 100 !== 0) || year % 400 === 0); }; /** * Gets the number of days in the month, given a year and month value. Automatically corrects for LeapYear. * @param {Number} The year. * @param {Number} The month (0-11). * @return {Number} The number of days in the month. */ $D.getDaysInMonth = function (year, month) { if (!month && $D.validateMonth(year)) { month = year; year = Date.today().getFullYear(); } return [31, ($D.isLeapYear(year) ? 29 : 28), 31, 30, 31, 30, 31, 31, 30, 31, 30, 31][month]; }; $P.getDaysInMonth = function () { return $D.getDaysInMonth(this.getFullYear(), this.getMonth()); }; $D.getTimezoneAbbreviation = function (offset, dst) { var p, n = (dst || false) ? Date.CultureInfo.abbreviatedTimeZoneDST : Date.CultureInfo.abbreviatedTimeZoneStandard; for (p in n) { if (n.hasOwnProperty(p)) { if (n[p] === offset) { return p; } } } return null; }; $D.getTimezoneOffset = function (name, dst) { var i, a =[], z = Date.CultureInfo.timezones; if (!name) { name = (new Date()).getTimezone();} for (i = 0; i < z.length; i++) { if (z[i].name === name.toUpperCase()) { a.push(i); } } if (!z[a[0]]) { return null; } if (a.length === 1 || !dst) { return z[a[0]].offset; } else { for (i=0; i < a.length; i++) { if (z[a[i]].dst) { return z[a[i]].offset; } } } }; $D.getQuarter = function (d) { d = d || new Date(); // If no date supplied, use today var q = [1,2,3,4]; return q[Math.floor(d.getMonth() / 3)]; // ~~~ is a bitwise op. Faster than Math.floor }; $D.getDaysLeftInQuarter = function (d) { d = d || new Date(); var qEnd = new Date(d); qEnd.setMonth(qEnd.getMonth() + 3 - qEnd.getMonth() % 3, 0); return Math.floor((qEnd - d) / 8.64e7); }; // private var validate = function (n, min, max, name) { name = name ? name : "Object"; if (typeof n === "undefined") { return false; } else if (typeof n !== "number") { throw new TypeError(n + " is not a Number."); } else if (n < min || n > max) { // As failing validation is *not* an exceptional circumstance // lets not throw a RangeError Exception here. // It's semantically correct but it's not sensible. return false; } return true; }; /** * Validates the number is within an acceptable range for milliseconds [0-999]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateMillisecond = function (value) { return validate(value, 0, 999, "millisecond"); }; /** * Validates the number is within an acceptable range for seconds [0-59]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateSecond = function (value) { return validate(value, 0, 59, "second"); }; /** * Validates the number is within an acceptable range for minutes [0-59]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateMinute = function (value) { return validate(value, 0, 59, "minute"); }; /** * Validates the number is within an acceptable range for hours [0-23]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateHour = function (value) { return validate(value, 0, 23, "hour"); }; /** * Validates the number is within an acceptable range for the days in a month [0-MaxDaysInMonth]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateDay = function (value, year, month) { if (year === undefined || year === null || month === undefined || month === null) { return false;} return validate(value, 1, $D.getDaysInMonth(year, month), "day"); }; /** * Validates the number is within an acceptable range for months [0-11]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateWeek = function (value) { return validate(value, 0, 53, "week"); }; /** * Validates the number is within an acceptable range for months [0-11]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateMonth = function (value) { return validate(value, 0, 11, "month"); }; /** * Validates the number is within an acceptable range for years. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateYear = function (value) { /** * Per ECMAScript spec the range of times supported by Date objects is * exactly -100,000,000 days to +100,000,000 days measured relative to * midnight at the beginning of 01 January, 1970 UTC. * This gives a range of 8,640,000,000,000,000 milliseconds to either * side of 01 January, 1970 UTC. * * Earliest possible date: Tue, 20 Apr 271,822 B.C. 00:00:00 UTC * Latest possible date: Sat, 13 Sep 275,760 00:00:00 UTC */ return validate(value, -271822, 275760, "year"); }; $D.validateTimezone = function(value) { var timezones = {"ACDT":1,"ACST":1,"ACT":1,"ADT":1,"AEDT":1,"AEST":1,"AFT":1,"AKDT":1,"AKST":1,"AMST":1,"AMT":1,"ART":1,"AST":1,"AWDT":1,"AWST":1,"AZOST":1,"AZT":1,"BDT":1,"BIOT":1,"BIT":1,"BOT":1,"BRT":1,"BST":1,"BTT":1,"CAT":1,"CCT":1,"CDT":1,"CEDT":1,"CEST":1,"CET":1,"CHADT":1,"CHAST":1,"CHOT":1,"ChST":1,"CHUT":1,"CIST":1,"CIT":1,"CKT":1,"CLST":1,"CLT":1,"COST":1,"COT":1,"CST":1,"CT":1,"CVT":1,"CWST":1,"CXT":1,"DAVT":1,"DDUT":1,"DFT":1,"EASST":1,"EAST":1,"EAT":1,"ECT":1,"EDT":1,"EEDT":1,"EEST":1,"EET":1,"EGST":1,"EGT":1,"EIT":1,"EST":1,"FET":1,"FJT":1,"FKST":1,"FKT":1,"FNT":1,"GALT":1,"GAMT":1,"GET":1,"GFT":1,"GILT":1,"GIT":1,"GMT":1,"GST":1,"GYT":1,"HADT":1,"HAEC":1,"HAST":1,"HKT":1,"HMT":1,"HOVT":1,"HST":1,"ICT":1,"IDT":1,"IOT":1,"IRDT":1,"IRKT":1,"IRST":1,"IST":1,"JST":1,"KGT":1,"KOST":1,"KRAT":1,"KST":1,"LHST":1,"LINT":1,"MAGT":1,"MART":1,"MAWT":1,"MDT":1,"MET":1,"MEST":1,"MHT":1,"MIST":1,"MIT":1,"MMT":1,"MSK":1,"MST":1,"MUT":1,"MVT":1,"MYT":1,"NCT":1,"NDT":1,"NFT":1,"NPT":1,"NST":1,"NT":1,"NUT":1,"NZDT":1,"NZST":1,"OMST":1,"ORAT":1,"PDT":1,"PET":1,"PETT":1,"PGT":1,"PHOT":1,"PHT":1,"PKT":1,"PMDT":1,"PMST":1,"PONT":1,"PST":1,"PYST":1,"PYT":1,"RET":1,"ROTT":1,"SAKT":1,"SAMT":1,"SAST":1,"SBT":1,"SCT":1,"SGT":1,"SLST":1,"SRT":1,"SST":1,"SYOT":1,"TAHT":1,"THA":1,"TFT":1,"TJT":1,"TKT":1,"TLT":1,"TMT":1,"TOT":1,"TVT":1,"UCT":1,"ULAT":1,"UTC":1,"UYST":1,"UYT":1,"UZT":1,"VET":1,"VLAT":1,"VOLT":1,"VOST":1,"VUT":1,"WAKT":1,"WAST":1,"WAT":1,"WEDT":1,"WEST":1,"WET":1,"WST":1,"YAKT":1,"YEKT":1,"Z":1}; return (timezones[value] === 1); }; $D.validateTimezoneOffset= function(value) { // timezones go from +14hrs to -12hrs, the +X hours are negative offsets. return (value > -841 && value < 721); }; }()); (function () { var $D = Date, $P = $D.prototype, p = function (s, l) { if (!l) { l = 2; } return ("000" + s).slice(l * -1); }; var validateConfigObject = function (obj) { var result = {}, self = this, prop, testFunc; testFunc = function (prop, func, value) { if (prop === "day") { var month = (obj.month !== undefined) ? obj.month : self.getMonth(); var year = (obj.year !== undefined) ? obj.year : self.getFullYear(); return $D[func](value, year, month); } else { return $D[func](value); } }; for (prop in obj) { if (Object.prototype.hasOwnProperty.call(obj, prop)) { var func = "validate" + prop.charAt(0).toUpperCase() + prop.slice(1); if ($D[func] && obj[prop] !== null && testFunc(prop, func, obj[prop])) { result[prop] = obj[prop]; } } } return result; }; /** * Resets the time of this Date object to 12:00 AM (00:00), which is the start of the day. * @param {Boolean} .clone() this date instance before clearing Time * @return {Date} this */ $P.clearTime = function () { this.setHours(0); this.setMinutes(0); this.setSeconds(0); this.setMilliseconds(0); return this; }; /** * Resets the time of this Date object to the current time ('now'). * @return {Date} this */ $P.setTimeToNow = function () { var n = new Date(); this.setHours(n.getHours()); this.setMinutes(n.getMinutes()); this.setSeconds(n.getSeconds()); this.setMilliseconds(n.getMilliseconds()); return this; }; /** * Returns a new Date object that is an exact date and time copy of the original instance. * @return {Date} A new Date instance */ $P.clone = function () { return new Date(this.getTime()); }; /** * Compares this instance to a Date object and returns an number indication of their relative values. * @param {Date} Date object to compare [Required] * @return {Number} -1 = this is lessthan date. 0 = values are equal. 1 = this is greaterthan date. */ $P.compareTo = function (date) { return Date.compare(this, date); }; /** * Compares this instance to another Date object and returns true if they are equal. * @param {Date} Date object to compare. If no date to compare, new Date() [now] is used. * @return {Boolean} true if dates are equal. false if they are not equal. */ $P.equals = function (date) { return Date.equals(this, (date !== undefined ? date : new Date())); }; /** * Determines if this instance is between a range of two dates or equal to either the start or end dates. * @param {Date} Start of range [Required] * @param {Date} End of range [Required] * @return {Boolean} true is this is between or equal to the start and end dates, else false */ $P.between = function (start, end) { return this.getTime() >= start.getTime() && this.getTime() <= end.getTime(); }; /** * Determines if this date occurs after the date to compare to. * @param {Date} Date object to compare. If no date to compare, new Date() ("now") is used. * @return {Boolean} true if this date instance is greater than the date to compare to (or "now"), otherwise false. */ $P.isAfter = function (date) { return this.compareTo(date || new Date()) === 1; }; /** * Determines if this date occurs before the date to compare to. * @param {Date} Date object to compare. If no date to compare, new Date() ("now") is used. * @return {Boolean} true if this date instance is less than the date to compare to (or "now"). */ $P.isBefore = function (date) { return (this.compareTo(date || new Date()) === -1); }; /** * Determines if the current Date instance occurs today. * @return {Boolean} true if this date instance is 'today', otherwise false. */ /** * Determines if the current Date instance occurs on the same Date as the supplied 'date'. * If no 'date' to compare to is provided, the current Date instance is compared to 'today'. * @param {date} Date object to compare. If no date to compare, the current Date ("now") is used. * @return {Boolean} true if this Date instance occurs on the same Day as the supplied 'date'. */ $P.isToday = $P.isSameDay = function (date) { return this.clone().clearTime().equals((date || new Date()).clone().clearTime()); }; /** * Adds the specified number of milliseconds to this instance. * @param {Number} The number of milliseconds to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addMilliseconds = function (value) { if (!value) { return this; } this.setTime(this.getTime() + value * 1); return this; }; /** * Adds the specified number of seconds to this instance. * @param {Number} The number of seconds to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addSeconds = function (value) { if (!value) { return this; } return this.addMilliseconds(value * 1000); }; /** * Adds the specified number of seconds to this instance. * @param {Number} The number of seconds to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addMinutes = function (value) { if (!value) { return this; } return this.addMilliseconds(value * 60000); // 60*1000 }; /** * Adds the specified number of hours to this instance. * @param {Number} The number of hours to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addHours = function (value) { if (!value) { return this; } return this.addMilliseconds(value * 3600000); // 60*60*1000 }; /** * Adds the specified number of days to this instance. * @param {Number} The number of days to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addDays = function (value) { if (!value) { return this; } this.setDate(this.getDate() + value * 1); return this; }; /** * Adds the specified number of weekdays (ie - not sat or sun) to this instance. * @param {Number} The number of days to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addWeekdays = function (value) { if (!value) { return this; } var day = this.getDay(); var weeks = (Math.ceil(Math.abs(value)/7)); if (day === 0 || day === 6) { if (value > 0) { this.next().monday(); this.addDays(-1); day = this.getDay(); } } if (value < 0) { while (value < 0) { this.addDays(-1); day = this.getDay(); if (day !== 0 && day !== 6) { value++; } } return this; } else if (value > 5 || (6-day) <= value) { value = value + (weeks * 2); } return this.addDays(value); }; /** * Adds the specified number of weeks to this instance. * @param {Number} The number of weeks to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addWeeks = function (value) { if (!value) { return this; } return this.addDays(value * 7); }; /** * Adds the specified number of months to this instance. * @param {Number} The number of months to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addMonths = function (value) { if (!value) { return this; } var n = this.getDate(); this.setDate(1); this.setMonth(this.getMonth() + value * 1); this.setDate(Math.min(n, $D.getDaysInMonth(this.getFullYear(), this.getMonth()))); return this; }; $P.addQuarters = function (value) { if (!value) { return this; } // note this will take you to the same point in the quarter as you are now. // i.e. - if you are 15 days into the quarter you'll be 15 days into the resulting one. // bonus: this allows adding fractional quarters return this.addMonths(value * 3); }; /** * Adds the specified number of years to this instance. * @param {Number} The number of years to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addYears = function (value) { if (!value) { return this; } return this.addMonths(value * 12); }; /** * Adds (or subtracts) to the value of the years, months, weeks, days, hours, minutes, seconds, milliseconds of the date instance using given configuration object. Positive and Negative values allowed. * Example

	Date.today().add( { days: 1, months: 1 } )

	new Date().add( { years: -1 } )
	
* @param {Object} Configuration object containing attributes (months, days, etc.) * @return {Date} this */ $P.add = function (config) { if (typeof config === "number") { this._orient = config; return this; } var x = config; if (x.day) { // If we should be a different date than today (eg: for 'tomorrow -1d', etc). // Should only effect parsing, not direct usage (eg, Finish and FinishExact) if ((x.day - this.getDate()) !== 0) { this.setDate(x.day); } } if (x.milliseconds) { this.addMilliseconds(x.milliseconds); } if (x.seconds) { this.addSeconds(x.seconds); } if (x.minutes) { this.addMinutes(x.minutes); } if (x.hours) { this.addHours(x.hours); } if (x.weeks) { this.addWeeks(x.weeks); } if (x.months) { this.addMonths(x.months); } if (x.years) { this.addYears(x.years); } if (x.days) { this.addDays(x.days); } return this; }; /** * Get the week number. Week one (1) is the week which contains the first Thursday of the year. Monday is considered the first day of the week. * The .getWeek() function does NOT convert the date to UTC. The local datetime is used. * Please use .getISOWeek() to get the week of the UTC converted date. * @return {Number} 1 to 53 */ $P.getWeek = function (utc) { // Create a copy of this date object var self, target = new Date(this.valueOf()); if (utc) { target.addMinutes(target.getTimezoneOffset()); self = target.clone(); } else { self = this; } // ISO week date weeks start on monday // so correct the day number var dayNr = (self.getDay() + 6) % 7; // ISO 8601 states that week 1 is the week // with the first thursday of that year. // Set the target date to the thursday in the target week target.setDate(target.getDate() - dayNr + 3); // Store the millisecond value of the target date var firstThursday = target.valueOf(); // Set the target to the first thursday of the year // First set the target to january first target.setMonth(0, 1); // Not a thursday? Correct the date to the next thursday if (target.getDay() !== 4) { target.setMonth(0, 1 + ((4 - target.getDay()) + 7) % 7); } // The weeknumber is the number of weeks between the // first thursday of the year and the thursday in the target week return 1 + Math.ceil((firstThursday - target) / 604800000); // 604800000 = 7 * 24 * 3600 * 1000 }; /** * Get the ISO 8601 week number. Week one ("01") is the week which contains the first Thursday of the year. Monday is considered the first day of the week. * The .getISOWeek() function does convert the date to it's UTC value. Please use .getWeek() to get the week of the local date. * @return {String} "01" to "53" */ $P.getISOWeek = function () { return p(this.getWeek(true)); }; /** * Moves the date to Monday of the week set. Week one (1) is the week which contains the first Thursday of the year. * @param {Number} A Number (1 to 53) that represents the week of the year. * @return {Date} this */ $P.setWeek = function (n) { if ((n - this.getWeek()) === 0) { if (this.getDay() !== 1) { return this.moveToDayOfWeek(1, (this.getDay() > 1 ? -1 : 1)); } else { return this; } } else { return this.moveToDayOfWeek(1, (this.getDay() > 1 ? -1 : 1)).addWeeks(n - this.getWeek()); } }; $P.setQuarter = function (qtr) { var month = Math.abs(((qtr-1) * 3) + 1); return this.setMonth(month, 1); }; $P.getQuarter = function () { return Date.getQuarter(this); }; $P.getDaysLeftInQuarter = function () { return Date.getDaysLeftInQuarter(this); }; /** * Moves the date to the next n'th occurrence of the dayOfWeek starting from the beginning of the month. The number (-1) is a magic number and will return the last occurrence of the dayOfWeek in the month. * @param {Number} The dayOfWeek to move to * @param {Number} The n'th occurrence to move to. Use (-1) to return the last occurrence in the month * @return {Date} this */ $P.moveToNthOccurrence = function (dayOfWeek, occurrence) { if (dayOfWeek === "Weekday") { if (occurrence > 0) { this.moveToFirstDayOfMonth(); if (this.is().weekday()) { occurrence -= 1; } } else if (occurrence < 0) { this.moveToLastDayOfMonth(); if (this.is().weekday()) { occurrence += 1; } } else { return this; } return this.addWeekdays(occurrence); } var shift = 0; if (occurrence > 0) { shift = occurrence - 1; } else if (occurrence === -1) { this.moveToLastDayOfMonth(); if (this.getDay() !== dayOfWeek) { this.moveToDayOfWeek(dayOfWeek, -1); } return this; } return this.moveToFirstDayOfMonth().addDays(-1).moveToDayOfWeek(dayOfWeek, +1).addWeeks(shift); }; var moveToN = function (getFunc, addFunc, nVal) { return function (value, orient) { var diff = (value - this[getFunc]() + nVal * (orient || +1)) % nVal; return this[addFunc]((diff === 0) ? diff += nVal * (orient || +1) : diff); }; }; /** * Move to the next or last dayOfWeek based on the orient value. * @param {Number} The dayOfWeek to move to * @param {Number} Forward (+1) or Back (-1). Defaults to +1. [Optional] * @return {Date} this */ $P.moveToDayOfWeek = moveToN("getDay", "addDays", 7); /** * Move to the next or last month based on the orient value. * @param {Number} The month to move to. 0 = January, 11 = December * @param {Number} Forward (+1) or Back (-1). Defaults to +1. [Optional] * @return {Date} this */ $P.moveToMonth = moveToN("getMonth", "addMonths", 12); /** * Get the Ordinate of the current day ("th", "st", "rd"). * @return {String} */ $P.getOrdinate = function () { var num = this.getDate(); return ord(num); }; /** * Get the Ordinal day (numeric day number) of the year, adjusted for leap year. * @return {Number} 1 through 365 (366 in leap years) */ $P.getOrdinalNumber = function () { return Math.ceil((this.clone().clearTime() - new Date(this.getFullYear(), 0, 1)) / 86400000) + 1; }; /** * Get the time zone abbreviation of the current date. * @return {String} The abbreviated time zone name (e.g. "EST") */ $P.getTimezone = function () { return $D.getTimezoneAbbreviation(this.getUTCOffset(), this.isDaylightSavingTime()); }; $P.setTimezoneOffset = function (offset) { var here = this.getTimezoneOffset(), there = Number(offset) * -6 / 10; return (there || there === 0) ? this.addMinutes(there - here) : this; }; $P.setTimezone = function (offset) { return this.setTimezoneOffset($D.getTimezoneOffset(offset)); }; /** * Indicates whether Daylight Saving Time is observed in the current time zone. * @return {Boolean} true|false */ $P.hasDaylightSavingTime = function () { return (Date.today().set({month: 0, day: 1}).getTimezoneOffset() !== Date.today().set({month: 6, day: 1}).getTimezoneOffset()); }; /** * Indicates whether this Date instance is within the Daylight Saving Time range for the current time zone. * @return {Boolean} true|false */ $P.isDaylightSavingTime = function () { return Date.today().set({month: 0, day: 1}).getTimezoneOffset() !== this.getTimezoneOffset(); }; /** * Get the offset from UTC of the current date. * @return {String} The 4-character offset string prefixed with + or - (e.g. "-0500") */ $P.getUTCOffset = function (offset) { var n = (offset || this.getTimezoneOffset()) * -10 / 6, r; if (n < 0) { r = (n - 10000).toString(); return r.charAt(0) + r.substr(2); } else { r = (n + 10000).toString(); return "+" + r.substr(1); } }; /** * Returns the number of milliseconds between this date and date. * @param {Date} Defaults to now * @return {Number} The diff in milliseconds */ $P.getElapsed = function (date) { return (date || new Date()) - this; }; /** * Set the value of year, month, day, hour, minute, second, millisecond of date instance using given configuration object. * Example

	Date.today().set( { day: 20, month: 1 } )

	new Date().set( { millisecond: 0 } )
	
* * @param {Object} Configuration object containing attributes (month, day, etc.) * @return {Date} this */ $P.set = function (config) { config = validateConfigObject.call(this, config); var key; for (key in config) { if (Object.prototype.hasOwnProperty.call(config, key)) { var name = key.charAt(0).toUpperCase() + key.slice(1); var addFunc, getFunc; if (key !== "week" && key !== "month" && key !== "timezone" && key !== "timezoneOffset") { name += "s"; } addFunc = "add" + name; getFunc = "get" + name; if (key === "month") { addFunc = addFunc + "s"; } else if (key === "year"){ getFunc = "getFullYear"; } if (key !== "day" && key !== "timezone" && key !== "timezoneOffset" && key !== "week" && key !== "hour") { this[addFunc](config[key] - this[getFunc]()); } else if ( key === "timezone"|| key === "timezoneOffset" || key === "week" || key === "hour") { this["set"+name](config[key]); } } } // day has to go last because you can't validate the day without first knowing the month if (config.day) { this.addDays(config.day - this.getDate()); } return this; }; /** * Moves the date to the first day of the month. * @return {Date} this */ $P.moveToFirstDayOfMonth = function () { return this.set({ day: 1 }); }; /** * Moves the date to the last day of the month. * @return {Date} this */ $P.moveToLastDayOfMonth = function () { return this.set({ day: $D.getDaysInMonth(this.getFullYear(), this.getMonth())}); }; /** * Converts the value of the current Date object to its equivalent string representation. * Format Specifiers * CUSTOM DATE AND TIME FORMAT STRINGS * Format Description Example * ------ --------------------------------------------------------------------------- ----------------------- * s The seconds of the minute between 0-59. "0" to "59" * ss The seconds of the minute with leading zero if required. "00" to "59" * * m The minute of the hour between 0-59. "0" or "59" * mm The minute of the hour with leading zero if required. "00" or "59" * * h The hour of the day between 1-12. "1" to "12" * hh The hour of the day with leading zero if required. "01" to "12" * * H The hour of the day between 0-23. "0" to "23" * HH The hour of the day with leading zero if required. "00" to "23" * * d The day of the month between 1 and 31. "1" to "31" * dd The day of the month with leading zero if required. "01" to "31" * ddd Abbreviated day name. Date.CultureInfo.abbreviatedDayNames. "Mon" to "Sun" * dddd The full day name. Date.CultureInfo.dayNames. "Monday" to "Sunday" * * M The month of the year between 1-12. "1" to "12" * MM The month of the year with leading zero if required. "01" to "12" * MMM Abbreviated month name. Date.CultureInfo.abbreviatedMonthNames. "Jan" to "Dec" * MMMM The full month name. Date.CultureInfo.monthNames. "January" to "December" * * yy The year as a two-digit number. "99" or "08" * yyyy The full four digit year. "1999" or "2008" * * t Displays the first character of the A.M./P.M. designator. "A" or "P" * Date.CultureInfo.amDesignator or Date.CultureInfo.pmDesignator * tt Displays the A.M./P.M. designator. "AM" or "PM" * Date.CultureInfo.amDesignator or Date.CultureInfo.pmDesignator * * S The ordinal suffix ("st, "nd", "rd" or "th") of the current day. "st, "nd", "rd" or "th" * * STANDARD DATE AND TIME FORMAT STRINGS * Format Description Example *------ --------------------------------------------------------------------------- ----------------------- * d The CultureInfo shortDate Format Pattern "M/d/yyyy" * D The CultureInfo longDate Format Pattern "dddd, MMMM dd, yyyy" * F The CultureInfo fullDateTime Format Pattern "dddd, MMMM dd, yyyy h:mm:ss tt" * m The CultureInfo monthDay Format Pattern "MMMM dd" * r The CultureInfo rfc1123 Format Pattern "ddd, dd MMM yyyy HH:mm:ss GMT" * s The CultureInfo sortableDateTime Format Pattern "yyyy-MM-ddTHH:mm:ss" * t The CultureInfo shortTime Format Pattern "h:mm tt" * T The CultureInfo longTime Format Pattern "h:mm:ss tt" * u The CultureInfo universalSortableDateTime Format Pattern "yyyy-MM-dd HH:mm:ssZ" * y The CultureInfo yearMonth Format Pattern "MMMM, yyyy" * * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @return {String} A string representation of the current Date object. */ var ord = function (n) { switch (n * 1) { case 1: case 21: case 31: return "st"; case 2: case 22: return "nd"; case 3: case 23: return "rd"; default: return "th"; } }; var parseStandardFormats = function (format) { var y, c = Date.CultureInfo.formatPatterns; switch (format) { case "d": return this.toString(c.shortDate); case "D": return this.toString(c.longDate); case "F": return this.toString(c.fullDateTime); case "m": return this.toString(c.monthDay); case "r": case "R": y = this.clone().addMinutes(this.getTimezoneOffset()); return y.toString(c.rfc1123) + " GMT"; case "s": return this.toString(c.sortableDateTime); case "t": return this.toString(c.shortTime); case "T": return this.toString(c.longTime); case "u": y = this.clone().addMinutes(this.getTimezoneOffset()); return y.toString(c.universalSortableDateTime); case "y": return this.toString(c.yearMonth); default: return false; } }; var parseFormatStringsClosure = function (context) { return function (m) { if (m.charAt(0) === "\\") { return m.replace("\\", ""); } switch (m) { case "hh": return p(context.getHours() < 13 ? (context.getHours() === 0 ? 12 : context.getHours()) : (context.getHours() - 12)); case "h": return context.getHours() < 13 ? (context.getHours() === 0 ? 12 : context.getHours()) : (context.getHours() - 12); case "HH": return p(context.getHours()); case "H": return context.getHours(); case "mm": return p(context.getMinutes()); case "m": return context.getMinutes(); case "ss": return p(context.getSeconds()); case "s": return context.getSeconds(); case "yyyy": return p(context.getFullYear(), 4); case "yy": return p(context.getFullYear()); case "y": return context.getFullYear(); case "E": case "dddd": return Date.CultureInfo.dayNames[context.getDay()]; case "ddd": return Date.CultureInfo.abbreviatedDayNames[context.getDay()]; case "dd": return p(context.getDate()); case "d": return context.getDate(); case "MMMM": return Date.CultureInfo.monthNames[context.getMonth()]; case "MMM": return Date.CultureInfo.abbreviatedMonthNames[context.getMonth()]; case "MM": return p((context.getMonth() + 1)); case "M": return context.getMonth() + 1; case "t": return context.getHours() < 12 ? Date.CultureInfo.amDesignator.substring(0, 1) : Date.CultureInfo.pmDesignator.substring(0, 1); case "tt": return context.getHours() < 12 ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator; case "S": return ord(context.getDate()); case "W": return context.getWeek(); case "WW": return context.getISOWeek(); case "Q": return "Q" + context.getQuarter(); case "q": return String(context.getQuarter()); case "z": return context.getTimezone(); case "Z": case "X": return Date.getTimezoneOffset(context.getTimezone()); case "ZZ": // Timezone offset in seconds return context.getTimezoneOffset() * -60; case "u": return context.getDay(); case "L": return ($D.isLeapYear(context.getFullYear())) ? 1 : 0; case "B": // Swatch Internet Time (.beats) return "@"+((context.getUTCSeconds() + (context.getUTCMinutes()*60) + ((context.getUTCHours()+1)*3600))/86.4); default: return m; } }; }; $P.toString = function (format, ignoreStandards) { // Standard Date and Time Format Strings. Formats pulled from CultureInfo file and // may vary by culture. if (!ignoreStandards && format && format.length === 1) { output = parseStandardFormats.call(this, format); if (output) { return output; } } var parseFormatStrings = parseFormatStringsClosure(this); return format ? format.replace(/((\\)?(dd?d?d?|MM?M?M?|yy?y?y?|hh?|HH?|mm?|ss?|tt?|S|q|Q|WW?W?W?)(?![^\[]*\]))/g, parseFormatStrings).replace(/\[|\]/g, "") : this._toString(); }; }()); /************************************************************* * SugarPak - Domain Specific Language - Syntactical Sugar * *************************************************************/ (function () { var $D = Date, $P = $D.prototype, $N = Number.prototype; // private $P._orient = +1; // private $P._nth = null; // private $P._is = false; // private $P._same = false; // private $P._isSecond = false; // private $N._dateElement = "days"; /** * Moves the date to the next instance of a date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.today().next().friday();
	Date.today().next().fri();
	Date.today().next().march();
	Date.today().next().mar();
	Date.today().next().week();
	
* * @return {Date} date */ $P.next = function () { this._move = true; this._orient = +1; return this; }; /** * Creates a new Date (Date.today()) and moves the date to the next instance of the date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.next().friday();
	Date.next().fri();
	Date.next().march();
	Date.next().mar();
	Date.next().week();
	
* * @return {Date} date */ $D.next = function () { return $D.today().next(); }; /** * Moves the date to the previous instance of a date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.today().last().friday();
	Date.today().last().fri();
	Date.today().last().march();
	Date.today().last().mar();
	Date.today().last().week();
	
* * @return {Date} date */ $P.last = $P.prev = $P.previous = function () { this._move = true; this._orient = -1; return this; }; /** * Creates a new Date (Date.today()) and moves the date to the previous instance of the date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.last().friday();
	Date.last().fri();
	Date.previous().march();
	Date.prev().mar();
	Date.last().week();
	
* * @return {Date} date */ $D.last = $D.prev = $D.previous = function () { return $D.today().last(); }; /** * Performs a equality check when followed by either a month name, day name or .weekday() function. * Example

	Date.today().is().friday(); // true|false
	Date.today().is().fri();
	Date.today().is().march();
	Date.today().is().mar();
	
* * @return {Boolean} true|false */ $P.is = function () { this._is = true; return this; }; /** * Determines if two date objects occur on/in exactly the same instance of the subsequent date part function. * The function .same() must be followed by a date part function (example: .day(), .month(), .year(), etc). * * An optional Date can be passed in the date part function. If now date is passed as a parameter, 'Now' is used. * * The following example demonstrates how to determine if two dates fall on the exact same day. * * Example

	var d1 = Date.today(); // today at 00:00
	var d2 = new Date();   // exactly now.

	// Do they occur on the same day?
	d1.same().day(d2); // true
	
	// Do they occur on the same hour?
	d1.same().hour(d2); // false, unless d2 hour is '00' (midnight).
	
	// What if it's the same day, but one year apart?
	var nextYear = Date.today().add(1).year();

	d1.same().day(nextYear); // false, because the dates must occur on the exact same day. 
	
* * Scenario: Determine if a given date occurs during some week period 2 months from now. * * Example

	var future = Date.today().add(2).months();
	return someDate.same().week(future); // true|false;
	
* * @return {Boolean} true|false */ $P.same = function () { this._same = true; this._isSecond = false; return this; }; /** * Determines if the current date/time occurs during Today. Must be preceded by the .is() function. * Example

	someDate.is().today();    // true|false
	new Date().is().today();  // true
	Date.today().is().today();// true
	Date.today().add(-1).day().is().today(); // false
	
* * @return {Boolean} true|false */ $P.today = function () { return this.same().day(); }; /** * Determines if the current date is a weekday. This function must be preceded by the .is() function. * Example

	Date.today().is().weekday(); // true|false
	
* * @return {Boolean} true|false */ $P.weekday = function () { if (this._nth) { return df("Weekday").call(this); } if (this._move) { return this.addWeekdays(this._orient); } if (this._is) { this._is = false; return (!this.is().sat() && !this.is().sun()); } return false; }; /** * Determines if the current date is on the weekend. This function must be preceded by the .is() function. * Example

	Date.today().is().weekend(); // true|false
	
* * @return {Boolean} true|false */ $P.weekend = function () { if (this._is) { this._is = false; return (this.is().sat() || this.is().sun()); } return false; }; /** * Sets the Time of the current Date instance. A string "6:15 pm" or config object {hour:18, minute:15} are accepted. * Example

	// Set time to 6:15pm with a String
	Date.today().at("6:15pm");

	// Set time to 6:15pm with a config object
	Date.today().at({hour:18, minute:15});
	
* * @return {Date} date */ $P.at = function (time) { return (typeof time === "string") ? $D.parse(this.toString("d") + " " + time) : this.set(time); }; /** * Creates a new Date() and adds this (Number) to the date based on the preceding date element function (eg. second|minute|hour|day|month|year). * Example

	// Undeclared Numbers must be wrapped with parentheses. Requirment of JavaScript.
	(3).days().fromNow();
	(6).months().fromNow();

	// Declared Number variables do not require parentheses. 
	var n = 6;
	n.months().fromNow();
	
* * @return {Date} A new Date instance */ $N.fromNow = $N.after = function (date) { var c = {}; c[this._dateElement] = this; return ((!date) ? new Date() : date.clone()).add(c); }; /** * Creates a new Date() and subtract this (Number) from the date based on the preceding date element function (eg. second|minute|hour|day|month|year). * Example

	// Undeclared Numbers must be wrapped with parentheses. Requirment of JavaScript.
	(3).days().ago();
	(6).months().ago();

	// Declared Number variables do not require parentheses. 
	var n = 6;
	n.months().ago();
	
* * @return {Date} A new Date instance */ $N.ago = $N.before = function (date) { var c = {}, s = (this._dateElement[this._dateElement.length-1] !== "s") ? this._dateElement + "s" : this._dateElement; c[s] = this * -1; return ((!date) ? new Date() : date.clone()).add(c); }; // Do NOT modify the following string tokens. These tokens are used to build dynamic functions. // All culture-specific strings can be found in the CultureInfo files. var dx = ("sunday monday tuesday wednesday thursday friday saturday").split(/\s/), mx = ("january february march april may june july august september october november december").split(/\s/), px = ("Millisecond Second Minute Hour Day Week Month Year Quarter Weekday").split(/\s/), pxf = ("Milliseconds Seconds Minutes Hours Date Week Month FullYear Quarter").split(/\s/), nth = ("final first second third fourth fifth").split(/\s/), de; /** * Returns an object literal of all the date parts. * Example

	var o = new Date().toObject();
	
	// { year: 2008, month: 4, week: 20, day: 13, hour: 18, minute: 9, second: 32, millisecond: 812 }
	
	// The object properties can be referenced directly from the object.
	
	alert(o.day);  // alerts "13"
	alert(o.year); // alerts "2008"
	
* * @return {Date} An object literal representing the original date object. */ $P.toObject = function () { var o = {}; for (var i = 0; i < px.length; i++) { if (this["get" + pxf[i]]) { o[px[i].toLowerCase()] = this["get" + pxf[i]](); } } return o; }; /** * Returns a date created from an object literal. Ignores the .week property if set in the config. * Example

	var o = new Date().toObject();
	
	return Date.fromObject(o); // will return the same date. 

	var o2 = {month: 1, day: 20, hour: 18}; // birthday party!
	Date.fromObject(o2);
	
* * @return {Date} An object literal representing the original date object. */ $D.fromObject = function(config) { config.week = null; return Date.today().set(config); }; // Create day name functions and abbreviated day name functions (eg. monday(), friday(), fri()). var df = function (n) { return function () { if (this._is) { this._is = false; return this.getDay() === n; } if (this._move) { this._move = null; } if (this._nth !== null) { // If the .second() function was called earlier, remove the _orient // from the date, and then continue. // This is required because 'second' can be used in two different context. // // Example // // Date.today().add(1).second(); // Date.march().second().monday(); // // Things get crazy with the following... // Date.march().add(1).second().second().monday(); // but it works!! // if (this._isSecond) { this.addSeconds(this._orient * -1); } // make sure we reset _isSecond this._isSecond = false; var ntemp = this._nth; this._nth = null; var temp = this.clone().moveToLastDayOfMonth(); this.moveToNthOccurrence(n, ntemp); if (this > temp) { throw new RangeError($D.getDayName(n) + " does not occur " + ntemp + " times in the month of " + $D.getMonthName(temp.getMonth()) + " " + temp.getFullYear() + "."); } return this; } return this.moveToDayOfWeek(n, this._orient); }; }; var sdf = function (n) { return function () { var t = $D.today(), shift = n - t.getDay(); if (n === 0 && Date.CultureInfo.firstDayOfWeek === 1 && t.getDay() !== 0) { shift = shift + 7; } return t.addDays(shift); }; }; // Create month name functions and abbreviated month name functions (eg. january(), march(), mar()). var month_instance_functions = function (n) { return function () { if (this._is) { this._is = false; return this.getMonth() === n; } return this.moveToMonth(n, this._orient); }; }; var month_static_functions = function (n) { return function () { return $D.today().set({ month: n, day: 1 }); }; }; var processTerms = function (names, staticFunc, instanceFunc) { for (var i = 0; i < names.length; i++) { // Create constant static Name variables. $D[names[i].toUpperCase()] = $D[names[i].toUpperCase().substring(0, 3)] = i; // Create Name functions. $D[names[i]] = $D[names[i].substring(0, 3)] = staticFunc(i); // Create Name instance functions. $P[names[i]] = $P[names[i].substring(0, 3)] = instanceFunc(i); } }; processTerms(dx, sdf, df); processTerms(mx, month_static_functions, month_instance_functions); // Create date element functions and plural date element functions used with Date (eg. day(), days(), months()). var ef = function (j) { return function () { // if the .second() function was called earlier, the _orient // has alread been added. Just return this and reset _isSecond. if (this._isSecond) { this._isSecond = false; return this; } if (this._same) { this._same = this._is = false; var o1 = this.toObject(), o2 = (arguments[0] || new Date()).toObject(), v = "", k = j.toLowerCase(); // the substr trick with -1 doesn't work in IE8 or less k = (k[k.length-1] === "s") ? k.substring(0,k.length-1) : k; for (var m = (px.length - 1); m > -1; m--) { v = px[m].toLowerCase(); if (o1[v] !== o2[v]) { return false; } if (k === v) { break; } } return true; } if (j.substring(j.length - 1) !== "s") { j += "s"; } if (this._move) { this._move = null; } return this["add" + j](this._orient); }; }; var nf = function (n) { return function () { this._dateElement = n; return this; }; }; for (var k = 0; k < px.length; k++) { de = px[k].toLowerCase(); if(de !== "weekday") { // Create date element functions and plural date element functions used with Date (eg. day(), days(), months()). $P[de] = $P[de + "s"] = ef(px[k]); // Create date element functions and plural date element functions used with Number (eg. day(), days(), months()). $N[de] = $N[de + "s"] = nf(de + "s"); } } $P._ss = ef("Second"); var nthfn = function (n) { return function (dayOfWeek) { if (this._same) { return this._ss(arguments[0]); } if (dayOfWeek || dayOfWeek === 0) { return this.moveToNthOccurrence(dayOfWeek, n); } this._nth = n; // if the operator is 'second' add the _orient, then deal with it later... if (n === 2 && (dayOfWeek === undefined || dayOfWeek === null)) { this._isSecond = true; return this.addSeconds(this._orient); } return this; }; }; for (var l = 0; l < nth.length; l++) { $P[nth[l]] = (l === 0) ? nthfn(-1) : nthfn(l); } }()); (function () { "use strict"; Date.Parsing = { Exception: function (s) { this.message = "Parse error at '" + s.substring(0, 10) + " ...'"; } }; var $P = Date.Parsing; var dayOffsets = { standard: [0,31,59,90,120,151,181,212,243,273,304,334], leap: [0,31,60,91,121,152,182,213,244,274,305,335] }; $P.isLeapYear = function(year) { return ((year % 4 === 0) && (year % 100 !== 0)) || (year % 400 === 0); }; var utils = { multiReplace : function (str, hash ) { var key; for (key in hash) { if (Object.prototype.hasOwnProperty.call(hash, key)) { var regex; if (typeof hash[key] === "function") { } else { regex = (hash[key] instanceof RegExp) ? hash[key] : new RegExp(hash[key], "g"); } str = str.replace(regex, key); } } return str; }, getDayOfYearFromWeek : function (obj) { var d, jan4, offset; obj.weekDay = (!obj.weekDay && obj.weekDay !== 0) ? 1 : obj.weekDay; d = new Date(obj.year, 0, 4); jan4 = d.getDay() === 0 ? 7 : d.getDay(); // JS is 0 indexed on Sunday. offset = jan4+3; obj.dayOfYear = ((obj.week * 7) + (obj.weekDay === 0 ? 7 : obj.weekDay))-offset; return obj; }, getDayOfYear : function (obj, dayOffset) { if (!obj.dayOfYear) { obj = utils.getDayOfYearFromWeek(obj); } for (var i=0;i <= dayOffset.length;i++) { if (obj.dayOfYear < dayOffset[i] || i === dayOffset.length) { obj.day = obj.day ? obj.day : (obj.dayOfYear - dayOffset[i-1]); break; } else { obj.month = i; } } return obj; }, adjustForTimeZone : function (obj, date) { var offset; if (obj.zone.toUpperCase() === "Z" || (obj.zone_hours === 0 && obj.zone_minutes === 0)) { // it's UTC/GML so work out the current timeszone offset offset = -date.getTimezoneOffset(); } else { offset = (obj.zone_hours*60) + (obj.zone_minutes || 0); if (obj.zone_sign === "+") { offset *= -1; } offset -= date.getTimezoneOffset(); } date.setMinutes(date.getMinutes()+offset); return date; }, setDefaults : function (obj) { obj.year = obj.year || Date.today().getFullYear(); obj.hours = obj.hours || 0; obj.minutes = obj.minutes || 0; obj.seconds = obj.seconds || 0; obj.milliseconds = obj.milliseconds || 0; if (!(!obj.month && (obj.week || obj.dayOfYear))) { // if we have a month, or if we don't but don't have the day calculation data obj.month = obj.month || 0; obj.day = obj.day || 1; } return obj; }, dataNum: function (data, mod, explict, postProcess) { var dataNum = data*1; if (mod) { if (postProcess) { return data ? mod(data)*1 : data; } else { return data ? mod(dataNum) : data; } } else if (!explict){ return data ? dataNum : data; } else { return (data && typeof data !== "undefined") ? dataNum : data; } }, timeDataProcess: function (obj) { var timeObj = {}; for (var x in obj.data) { if (obj.data.hasOwnProperty(x)) { timeObj[x] = obj.ignore[x] ? obj.data[x] : utils.dataNum(obj.data[x], obj.mods[x], obj.explict[x], obj.postProcess[x]); } } if (obj.data.secmins) { obj.data.secmins = obj.data.secmins.replace(",", ".") * 60; if (!timeObj.minutes) { timeObj.minutes = obj.data.secmins; } else if (!timeObj.seconds) { timeObj.seconds = obj.data.secmins; } delete obj.secmins; } return timeObj; }, buildTimeObjectFromData: function (data) { var time = utils.timeDataProcess({ data: { year : data[1], month : data[5], day : data[7], week : data[8], dayOfYear : data[10], hours : data[15], zone_hours : data[23], zone_minutes : data[24], zone : data[21], zone_sign : data[22], weekDay : data[9], minutes: data[16], seconds: data[19], milliseconds: data[20], secmins: data[18] }, mods: { month: function(data) { return data-1; }, weekDay: function (data) { data = Math.abs(data); return (data === 7 ? 0 : data); }, minutes: function (data) { return data.replace(":",""); }, seconds: function (data) { return Math.floor( (data.replace(":","").replace(",","."))*1 ); }, milliseconds: function (data) { return (data.replace(",",".")*1000); } }, postProcess: { minutes: true, seconds: true, milliseconds: true }, explict: { zone_hours: true, zone_minutes: true }, ignore: { zone: true, zone_sign: true, secmins: true } }); return time; }, addToHash: function (hash, keys, data) { keys = keys; data = data; var len = keys.length; for (var i = 0; i < len; i++) { hash[keys[i]] = data[i]; } return hash; }, combineRegex: function (r1, r2) { return new RegExp("(("+r1.source+")\\s("+r2.source+"))"); }, getDateNthString: function(add, last, inc){ if (add) { return Date.today().addDays(inc).toString("d"); } else if (last) { return Date.today().last()[inc]().toString("d"); } }, buildRegexData: function (array) { var arr = []; var len = array.length; for (var i=0; i < len; i++) { if (Object.prototype.toString.call(array[i]) === '[object Array]') { // oldIE compat version of Array.isArray arr.push(this.combineRegex(array[i][0], array[i][1])); } else { arr.push(array[i]); } } return arr; } }; $P.processTimeObject = function (obj) { var date, dayOffset; utils.setDefaults(obj); dayOffset = ($P.isLeapYear(obj.year)) ? dayOffsets.leap : dayOffsets.standard; if (!obj.month && (obj.week || obj.dayOfYear)) { utils.getDayOfYear(obj, dayOffset); } else { obj.dayOfYear = dayOffset[obj.month] + obj.day; } date = new Date(obj.year, obj.month, obj.day, obj.hours, obj.minutes, obj.seconds, obj.milliseconds); if (obj.zone) { utils.adjustForTimeZone(obj, date); // adjust (and calculate) for timezone } return date; }; $P.ISO = { regex : /^([\+-]?\d{4}(?!\d{2}\b))((-?)((0[1-9]|1[0-2])(\3([12]\d|0[1-9]|3[01]))?|W([0-4]\d|5[0-3])(-?[1-7])?|(00[1-9]|0[1-9]\d|[12]\d{2}|3([0-5]\d|6[1-6])))([T\s]((([01]\d|2[0-4])((:?)[0-5]\d)?|24\:?00)([\.,]\d+(?!:))?)?(\17[0-5]\d([\.,]\d+)?)?\s?([zZ]|([\+-])([01]\d|2[0-3]):?([0-5]\d)?)?)?)?$/, parse : function (s) { var time, data = s.match(this.regex); if (!data || !data.length) { return null; } time = utils.buildTimeObjectFromData(data); if (!time.year || (!time.year && (!time.month && !time.day) && (!time.week && !time.dayOfYear)) ) { return null; } return $P.processTimeObject(time); } }; $P.Numeric = { isNumeric: function (e){return!isNaN(parseFloat(e))&&isFinite(e);}, regex: /\b([0-1]?[0-9])([0-3]?[0-9])([0-2]?[0-9]?[0-9][0-9])\b/i, parse: function (s) { var data, i, time = {}, order = Date.CultureInfo.dateElementOrder.split(""); if (!(this.isNumeric(s)) || // if it's non-numeric OR (s[0] === "+" && s[0] === "-")) { // It's an arithmatic string (eg +/-1000) return null; } if (s.length < 5 && s.indexOf(".") < 0 && s.indexOf("/") < 0) { // assume it's just a year. time.year = s; return $P.processTimeObject(time); } data = s.match(this.regex); if (!data || !data.length) { return null; } for (i=0; i < order.length; i++) { switch(order[i]) { case "d": time.day = data[i+1]; break; case "m": time.month = (data[i+1]-1); break; case "y": time.year = data[i+1]; break; } } return $P.processTimeObject(time); } }; $P.Normalizer = { regexData: function () { var $R = Date.CultureInfo.regexPatterns; return utils.buildRegexData([ $R.tomorrow, $R.yesterday, [$R.past, $R.mon], [$R.past, $R.tue], [$R.past, $R.wed], [$R.past, $R.thu], [$R.past, $R.fri], [$R.past, $R.sat], [$R.past, $R.sun] ]); }, basicReplaceHash : function() { var $R = Date.CultureInfo.regexPatterns; return { "January": $R.jan.source, "February": $R.feb, "March": $R.mar, "April": $R.apr, "May": $R.may, "June": $R.jun, "July": $R.jul, "August": $R.aug, "September": $R.sep, "October": $R.oct, "November": $R.nov, "December": $R.dec, "": /\bat\b/gi, " ": /\s{2,}/, "am": $R.inTheMorning, "9am": $R.thisMorning, "pm": $R.inTheEvening, "7pm":$R.thisEvening }; }, keys : function(){ return [ utils.getDateNthString(true, false, 1), // tomorrow utils.getDateNthString(true, false, -1), // yesterday utils.getDateNthString(false, true, "monday"), //last mon utils.getDateNthString(false, true, "tuesday"), //last tues utils.getDateNthString(false, true, "wednesday"), //last wed utils.getDateNthString(false, true, "thursday"), //last thurs utils.getDateNthString(false, true, "friday"), //last fri utils.getDateNthString(false, true, "saturday"), //last sat utils.getDateNthString(false, true, "sunday") //last sun ]; }, buildRegexFunctions: function () { var $R = Date.CultureInfo.regexPatterns; var __ = Date.i18n.__; var tomorrowRE = new RegExp("(\\b\\d\\d?("+__("AM")+"|"+__("PM")+")? )("+$R.tomorrow.source.slice(1)+")", "i"); // adapted tomorrow regex for AM PM relative dates var todayRE = new RegExp($R.today.source + "(?!\\s*([+-]))\\b"); // today, but excludes the math operators (eg "today + 2h") this.replaceFuncs = [ [todayRE, function (full) { return (full.length > 1) ? Date.today().toString("d") : full; }], [tomorrowRE, function(full, m1) { var t = Date.today().addDays(1).toString("d"); return (t + " " + m1); }], [$R.amThisMorning, function(str, am){return am;}], [$R.pmThisEvening, function(str, pm){return pm;}] ]; }, buildReplaceData: function () { this.buildRegexFunctions(); this.replaceHash = utils.addToHash(this.basicReplaceHash(), this.keys(), this.regexData()); }, stringReplaceFuncs: function (s) { for (var i=0; i < this.replaceFuncs.length; i++) { s = s.replace(this.replaceFuncs[i][0], this.replaceFuncs[i][1]); } return s; }, parse: function (s) { s = this.stringReplaceFuncs(s); s = utils.multiReplace(s, this.replaceHash); try { var n = s.split(/([\s\-\.\,\/\x27]+)/); if (n.length === 3 && $P.Numeric.isNumeric(n[0]) && $P.Numeric.isNumeric(n[2]) && (n[2].length >= 4)) { // ok, so we're dealing with x/year. But that's not a full date. // This fixes wonky dateElementOrder parsing when set to dmy order. if (Date.CultureInfo.dateElementOrder[0] === "d") { s = "1/" + n[0] + "/" + n[2]; // set to 1st of month and normalize the seperator } } } catch (e) {} return s; } }; $P.Normalizer.buildReplaceData(); }()); (function () { var $P = Date.Parsing; var _ = $P.Operators = { // // Tokenizers // rtoken: function (r) { // regex token return function (s) { var mx = s.match(r); if (mx) { return ([ mx[0], s.substring(mx[0].length) ]); } else { throw new $P.Exception(s); } }; }, token: function () { // whitespace-eating token return function (s) { return _.rtoken(new RegExp("^\\s*" + s + "\\s*"))(s); }; }, stoken: function (s) { // string token return _.rtoken(new RegExp("^" + s)); }, // Atomic Operators until: function (p) { return function (s) { var qx = [], rx = null; while (s.length) { try { rx = p.call(this, s); } catch (e) { qx.push(rx[0]); s = rx[1]; continue; } break; } return [ qx, s ]; }; }, many: function (p) { return function (s) { var rx = [], r = null; while (s.length) { try { r = p.call(this, s); } catch (e) { return [ rx, s ]; } rx.push(r[0]); s = r[1]; } return [ rx, s ]; }; }, // generator operators -- see below optional: function (p) { return function (s) { var r = null; try { r = p.call(this, s); } catch (e) { return [ null, s ]; } return [ r[0], r[1] ]; }; }, not: function (p) { return function (s) { try { p.call(this, s); } catch (e) { return [null, s]; } throw new $P.Exception(s); }; }, ignore: function (p) { return p ? function (s) { var r = null; r = p.call(this, s); return [null, r[1]]; } : null; }, product: function () { var px = arguments[0], qx = Array.prototype.slice.call(arguments, 1), rx = []; for (var i = 0 ; i < px.length ; i++) { rx.push(_.each(px[i], qx)); } return rx; }, cache: function (rule) { var cache = {}, cache_length = 0, cache_keys = [], CACHE_MAX = Date.Config.CACHE_MAX || 100000, r = null; var cacheCheck = function () { if (cache_length === CACHE_MAX) { // kill several keys, don't want to have to do this all the time... for (var i=0; i < 10; i++) { var key = cache_keys.shift(); if (key) { delete cache[key]; cache_length--; } } } }; return function (s) { cacheCheck(); try { r = cache[s] = (cache[s] || rule.call(this, s)); } catch (e) { r = cache[s] = e; } cache_length++; cache_keys.push(s); if (r instanceof $P.Exception) { throw r; } else { return r; } }; }, // vector operators -- see below any: function () { var px = arguments; return function (s) { var r = null; for (var i = 0; i < px.length; i++) { if (px[i] == null) { continue; } try { r = (px[i].call(this, s)); } catch (e) { r = null; } if (r) { return r; } } throw new $P.Exception(s); }; }, each: function () { var px = arguments; return function (s) { var rx = [], r = null; for (var i = 0; i < px.length ; i++) { if (px[i] == null) { continue; } try { r = (px[i].call(this, s)); } catch (e) { throw new $P.Exception(s); } rx.push(r[0]); s = r[1]; } return [ rx, s]; }; }, all: function () { var px = arguments, _ = _; return _.each(_.optional(px)); }, // delimited operators sequence: function (px, d, c) { d = d || _.rtoken(/^\s*/); c = c || null; if (px.length === 1) { return px[0]; } return function (s) { var r = null, q = null; var rx = []; for (var i = 0; i < px.length ; i++) { try { r = px[i].call(this, s); } catch (e) { break; } rx.push(r[0]); try { q = d.call(this, r[1]); } catch (ex) { q = null; break; } s = q[1]; } if (!r) { throw new $P.Exception(s); } if (q) { throw new $P.Exception(q[1]); } if (c) { try { r = c.call(this, r[1]); } catch (ey) { throw new $P.Exception(r[1]); } } return [ rx, (r?r[1]:s) ]; }; }, // // Composite Operators // between: function (d1, p, d2) { d2 = d2 || d1; var _fn = _.each(_.ignore(d1), p, _.ignore(d2)); return function (s) { var rx = _fn.call(this, s); return [[rx[0][0], r[0][2]], rx[1]]; }; }, list: function (p, d, c) { d = d || _.rtoken(/^\s*/); c = c || null; return (p instanceof Array ? _.each(_.product(p.slice(0, -1), _.ignore(d)), p.slice(-1), _.ignore(c)) : _.each(_.many(_.each(p, _.ignore(d))), px, _.ignore(c))); }, set: function (px, d, c) { d = d || _.rtoken(/^\s*/); c = c || null; return function (s) { // r is the current match, best the current 'best' match // which means it parsed the most amount of input var r = null, p = null, q = null, rx = null, best = [[], s], last = false; // go through the rules in the given set for (var i = 0; i < px.length ; i++) { // last is a flag indicating whether this must be the last element // if there is only 1 element, then it MUST be the last one q = null; p = null; r = null; last = (px.length === 1); // first, we try simply to match the current pattern // if not, try the next pattern try { r = px[i].call(this, s); } catch (e) { continue; } // since we are matching against a set of elements, the first // thing to do is to add r[0] to matched elements rx = [[r[0]], r[1]]; // if we matched and there is still input to parse and // we don't already know this is the last element, // we're going to next check for the delimiter ... // if there's none, or if there's no input left to parse // than this must be the last element after all ... if (r[1].length > 0 && ! last) { try { q = d.call(this, r[1]); } catch (ex) { last = true; } } else { last = true; } // if we parsed the delimiter and now there's no more input, // that means we shouldn't have parsed the delimiter at all // so don't update r and mark this as the last element ... if (!last && q[1].length === 0) { last = true; } // so, if this isn't the last element, we're going to see if // we can get any more matches from the remaining (unmatched) // elements ... if (!last) { // build a list of the remaining rules we can match against, // i.e., all but the one we just matched against var qx = []; for (var j = 0; j < px.length ; j++) { if (i !== j) { qx.push(px[j]); } } // now invoke recursively set with the remaining input // note that we don't include the closing delimiter ... // we'll check for that ourselves at the end p = _.set(qx, d).call(this, q[1]); // if we got a non-empty set as a result ... // (otw rx already contains everything we want to match) if (p[0].length > 0) { // update current result, which is stored in rx ... // basically, pick up the remaining text from p[1] // and concat the result from p[0] so that we don't // get endless nesting ... rx[0] = rx[0].concat(p[0]); rx[1] = p[1]; } } // at this point, rx either contains the last matched element // or the entire matched set that starts with this element. // now we just check to see if this variation is better than // our best so far, in terms of how much of the input is parsed if (rx[1].length < best[1].length) { best = rx; } // if we've parsed all the input, then we're finished if (best[1].length === 0) { break; } } // so now we've either gone through all the patterns trying them // as the initial match; or we found one that parsed the entire // input string ... // if best has no matches, just return empty set ... if (best[0].length === 0) { return best; } // if a closing delimiter is provided, then we have to check it also if (c) { // we try this even if there is no remaining input because the pattern // may well be optional or match empty input ... try { q = c.call(this, best[1]); } catch (ey) { throw new $P.Exception(best[1]); } // it parsed ... be sure to update the best match remaining input best[1] = q[1]; } // if we're here, either there was no closing delimiter or we parsed it // so now we have the best match; just return it! return best; }; }, forward: function (gr, fname) { return function (s) { return gr[fname].call(this, s); }; }, // // Translation Operators // replace: function (rule, repl) { return function (s) { var r = rule.call(this, s); return [repl, r[1]]; }; }, process: function (rule, fn) { return function (s) { var r = rule.call(this, s); return [fn.call(this, r[0]), r[1]]; }; }, min: function (min, rule) { return function (s) { var rx = rule.call(this, s); if (rx[0].length < min) { throw new $P.Exception(s); } return rx; }; } }; // Generator Operators And Vector Operators // Generators are operators that have a signature of F(R) => R, // taking a given rule and returning another rule, such as // ignore, which parses a given rule and throws away the result. // Vector operators are those that have a signature of F(R1,R2,...) => R, // take a list of rules and returning a new rule, such as each. // Generator operators are converted (via the following _generator // function) into functions that can also take a list or array of rules // and return an array of new rules as though the function had been // called on each rule in turn (which is what actually happens). // This allows generators to be used with vector operators more easily. // Example: // each(ignore(foo, bar)) instead of each(ignore(foo), ignore(bar)) // This also turns generators into vector operators, which allows // constructs like: // not(cache(foo, bar)) var _generator = function (op) { function gen() { var args = null, rx = [], px, i; if (arguments.length > 1) { args = Array.prototype.slice.call(arguments); } else if (arguments[0] instanceof Array) { args = arguments[0]; } if (args) { px = args.shift(); if (px.length > 0) { args.unshift(px[i]); rx.push(op.apply(null, args)); args.shift(); return rx; } } else { return op.apply(null, arguments); } } return gen; }; var gx = "optional not ignore cache".split(/\s/); for (var i = 0 ; i < gx.length ; i++) { _[gx[i]] = _generator(_[gx[i]]); } var _vector = function (op) { return function () { if (arguments[0] instanceof Array) { return op.apply(null, arguments[0]); } else { return op.apply(null, arguments); } }; }; var vx = "each any all".split(/\s/); for (var j = 0 ; j < vx.length ; j++) { _[vx[j]] = _vector(_[vx[j]]); } }()); (function () { var $D = Date; var flattenAndCompact = function (ax) { var rx = []; for (var i = 0; i < ax.length; i++) { if (ax[i] instanceof Array) { rx = rx.concat(flattenAndCompact(ax[i])); } else { if (ax[i]) { rx.push(ax[i]); } } } return rx; }; var parseMeridian = function () { if (this.meridian && (this.hour || this.hour === 0)) { if (this.meridian === "a" && this.hour > 11 && Date.Config.strict24hr){ throw "Invalid hour and meridian combination"; } else if (this.meridian === "p" && this.hour < 12 && Date.Config.strict24hr){ throw "Invalid hour and meridian combination"; } else if (this.meridian === "p" && this.hour < 12) { this.hour = this.hour + 12; } else if (this.meridian === "a" && this.hour === 12) { this.hour = 0; } } }; var setDefaults = function () { var now = new Date(); if ((this.hour || this.minute) && (!this.month && !this.year && !this.day)) { this.day = now.getDate(); } if (!this.year) { this.year = now.getFullYear(); } if (!this.month && this.month !== 0) { this.month = now.getMonth(); } if (!this.day) { this.day = 1; } if (!this.hour) { this.hour = 0; } if (!this.minute) { this.minute = 0; } if (!this.second) { this.second = 0; } if (!this.millisecond) { this.millisecond = 0; } }; var finishUtils = { getToday: function () { if (this.now || "hour minute second".indexOf(this.unit) !== -1) { return new Date(); } else { return $D.today(); } }, setDaysFromWeekday: function (today, orient){ var gap; orient = orient || 1; this.unit = "day"; gap = ($D.getDayNumberFromName(this.weekday) - today.getDay()); this.days = gap ? ((gap + (orient * 7)) % 7) : (orient * 7); return this; }, setMonthsFromMonth: function (today, orient) { var gap; orient = orient || 1; this.unit = "month"; gap = (this.month - today.getMonth()); this.months = gap ? ((gap + (orient * 12)) % 12) : (orient * 12); this.month = null; return this; }, setDMYFromWeekday: function () { var d = Date[this.weekday](); this.day = d.getDate(); if (!this.month) { this.month = d.getMonth(); } this.year = d.getFullYear(); return this; }, setUnitValue: function (orient) { if (!this.value && this.operator && this.operator !== null && this[this.unit + "s"] && this[this.unit + "s"] !== null) { this[this.unit + "s"] = this[this.unit + "s"] + ((this.operator === "add") ? 1 : -1) + (this.value||0) * orient; } else if (this[this.unit + "s"] == null || this.operator != null) { if (!this.value) { this.value = 1; } this[this.unit + "s"] = this.value * orient; } }, generateDateFromWeeks: function () { var weekday = (this.weekday !== undefined) ? this.weekday : "today"; var d = Date[weekday]().addWeeks(this.weeks); if (this.now) { d.setTimeToNow(); } return d; } }; $D.Translator = { hour: function (s) { return function () { this.hour = Number(s); }; }, minute: function (s) { return function () { this.minute = Number(s); }; }, second: function (s) { return function () { this.second = Number(s); }; }, /* for ss.s format */ secondAndMillisecond: function (s) { return function () { var mx = s.match(/^([0-5][0-9])\.([0-9]{1,3})/); this.second = Number(mx[1]); this.millisecond = Number(mx[2]); }; }, meridian: function (s) { return function () { this.meridian = s.slice(0, 1).toLowerCase(); }; }, timezone: function (s) { return function () { var n = s.replace(/[^\d\+\-]/g, ""); if (n.length) { this.timezoneOffset = Number(n); } else { this.timezone = s.toLowerCase(); } }; }, day: function (x) { var s = x[0]; return function () { this.day = Number(s.match(/\d+/)[0]); if (this.day < 1) { throw "invalid day"; } }; }, month: function (s) { return function () { this.month = (s.length === 3) ? "jan feb mar apr may jun jul aug sep oct nov dec".indexOf(s)/4 : Number(s) - 1; if (this.month < 0) { throw "invalid month"; } }; }, year: function (s) { return function () { var n = Number(s); this.year = ((s.length > 2) ? n : (n + (((n + 2000) < Date.CultureInfo.twoDigitYearMax) ? 2000 : 1900))); }; }, rday: function (s) { return function () { switch (s) { case "yesterday": this.days = -1; break; case "tomorrow": this.days = 1; break; case "today": this.days = 0; break; case "now": this.days = 0; this.now = true; break; } }; }, finishExact: function (x) { var d; x = (x instanceof Array) ? x : [x]; for (var i = 0 ; i < x.length ; i++) { if (x[i]) { x[i].call(this); } } setDefaults.call(this); parseMeridian.call(this); if (this.day > $D.getDaysInMonth(this.year, this.month)) { throw new RangeError(this.day + " is not a valid value for days."); } d = new Date(this.year, this.month, this.day, this.hour, this.minute, this.second, this.millisecond); if (this.year < 100) { d.setFullYear(this.year); // means years less that 100 are process correctly. JS will parse it otherwise as 1900-1999. } if (this.timezone) { d.set({ timezone: this.timezone }); } else if (this.timezoneOffset) { d.set({ timezoneOffset: this.timezoneOffset }); } return d; }, finish: function (x) { var today, expression, orient, temp; x = (x instanceof Array) ? flattenAndCompact(x) : [ x ]; if (x.length === 0) { return null; } for (var i = 0 ; i < x.length ; i++) { if (typeof x[i] === "function") { x[i].call(this); } } if (this.now && !this.unit && !this.operator) { return new Date(); } else { today = finishUtils.getToday.call(this); } expression = !!(this.days && this.days !== null || this.orient || this.operator); orient = ((this.orient === "past" || this.operator === "subtract") ? -1 : 1); if (this.month && this.unit === "week") { this.value = this.month + 1; delete this.month; delete this.day; } if ((this.month || this.month === 0) && "year day hour minute second".indexOf(this.unit) !== -1) { if (!this.value) { this.value = this.month + 1; } this.month = null; expression = true; } if (!expression && this.weekday && !this.day && !this.days) { finishUtils.setDMYFromWeekday.call(this); } if (expression && this.weekday && this.unit !== "month" && this.unit !== "week") { finishUtils.setDaysFromWeekday.call(this, today, orient); } if (this.weekday && this.unit !== "week" && !this.day && !this.days) { temp = Date[this.weekday](); this.day = temp.getDate(); if (temp.getMonth() !== today.getMonth()) { this.month = temp.getMonth(); } } if (this.month && this.unit === "day" && this.operator) { if (!this.value) { this.value = (this.month + 1); } this.month = null; } if (this.value != null && this.month != null && this.year != null) { this.day = this.value * 1; } if (this.month && !this.day && this.value) { today.set({ day: this.value * 1 }); if (!expression) { this.day = this.value * 1; } } if (!this.month && this.value && this.unit === "month" && !this.now) { this.month = this.value; expression = true; } if (expression && (this.month || this.month === 0) && this.unit !== "year") { finishUtils.setMonthsFromMonth.call(this, today, orient); } if (!this.unit) { this.unit = "day"; } finishUtils.setUnitValue.call(this, orient); parseMeridian.call(this); if ((this.month || this.month === 0) && !this.day) { this.day = 1; } if (!this.orient && !this.operator && this.unit === "week" && this.value && !this.day && !this.month) { return Date.today().setWeek(this.value); } if (this.unit === "week" && this.weeks && !this.day && !this.month) { return finishUtils.generateDateFromWeeks.call(this); } if (expression && this.timezone && this.day && this.days) { this.day = this.days; } if (expression){ today.add(this); } else { today.set(this); } if (this.timezone) { this.timezone = this.timezone.toUpperCase(); var offset = $D.getTimezoneOffset(this.timezone); var timezone; if (today.hasDaylightSavingTime()) { // lets check that we're being sane with timezone setting timezone = $D.getTimezoneAbbreviation(offset, today.isDaylightSavingTime()); if (timezone !== this.timezone) { // bugger, we're in a place where things like EST vs EDT matters. if (today.isDaylightSavingTime()) { today.addHours(-1); } else { today.addHours(1); } } } today.setTimezoneOffset(offset); } return today; } }; }()); (function () { var $D = Date; $D.Grammar = {}; var _ = $D.Parsing.Operators, g = $D.Grammar, t = $D.Translator, _fn; // Allow rolling up into general purpose rules _fn = function () { return _.each(_.any.apply(null, arguments), _.not(g.ctoken2("timeContext"))); }; g.datePartDelimiter = _.rtoken(/^([\s\-\.\,\/\x27]+)/); g.timePartDelimiter = _.stoken(":"); g.whiteSpace = _.rtoken(/^\s*/); g.generalDelimiter = _.rtoken(/^(([\s\,]|at|@|on)+)/); var _C = {}; g.ctoken = function (keys) { var fn = _C[keys]; if (! fn) { var c = Date.CultureInfo.regexPatterns; var kx = keys.split(/\s+/), px = []; for (var i = 0; i < kx.length ; i++) { px.push(_.replace(_.rtoken(c[kx[i]]), kx[i])); } fn = _C[keys] = _.any.apply(null, px); } return fn; }; g.ctoken2 = function (key) { return _.rtoken(Date.CultureInfo.regexPatterns[key]); }; var cacheProcessRtoken = function (key, token, type, eachToken) { if (eachToken) { g[key] = _.cache(_.process(_.each(_.rtoken(token),_.optional(g.ctoken2(eachToken))), type)); } else { g[key] = _.cache(_.process(_.rtoken(token), type)); } }; var cacheProcessCtoken = function (token, type) { return _.cache(_.process(g.ctoken2(token), type)); }; var _F = {}; //function cache var _get = function (f) { _F[f] = (_F[f] || g.format(f)[0]); return _F[f]; }; g.allformats = function (fx) { var rx = []; if (fx instanceof Array) { for (var i = 0; i < fx.length; i++) { rx.push(_get(fx[i])); } } else { rx.push(_get(fx)); } return rx; }; g.formats = function (fx) { if (fx instanceof Array) { var rx = []; for (var i = 0 ; i < fx.length ; i++) { rx.push(_get(fx[i])); } return _.any.apply(null, rx); } else { return _get(fx); } }; var grammarFormats = { timeFormats: function(){ var i, RTokenKeys = [ "h", "hh", "H", "HH", "m", "mm", "s", "ss", "ss.s", "z", "zz" ], RToken = [ /^(0[0-9]|1[0-2]|[1-9])/, /^(0[0-9]|1[0-2])/, /^([0-1][0-9]|2[0-3]|[0-9])/, /^([0-1][0-9]|2[0-3])/, /^([0-5][0-9]|[0-9])/, /^[0-5][0-9]/, /^([0-5][0-9]|[0-9])/, /^[0-5][0-9]/, /^[0-5][0-9]\.[0-9]{1,3}/, /^((\+|\-)\s*\d\d\d\d)|((\+|\-)\d\d\:?\d\d)/, /^((\+|\-)\s*\d\d\d\d)|((\+|\-)\d\d\:?\d\d)/ ], tokens = [ t.hour, t.hour, t.hour, t.hour, t.minute, t.minute, t.second, t.second, t.secondAndMillisecond, t.timezone, t.timezone ]; for (i=0; i < RTokenKeys.length; i++) { cacheProcessRtoken(RTokenKeys[i], RToken[i], tokens[i]); } g.hms = _.cache(_.sequence([g.H, g.m, g.s], g.timePartDelimiter)); g.t = cacheProcessCtoken("shortMeridian", t.meridian); g.tt = cacheProcessCtoken("longMeridian", t.meridian); g.zzz = cacheProcessCtoken("timezone", t.timezone); g.timeSuffix = _.each(_.ignore(g.whiteSpace), _.set([ g.tt, g.zzz ])); g.time = _.each(_.optional(_.ignore(_.stoken("T"))), g.hms, g.timeSuffix); }, dateFormats: function () { // pre-loaded rules for different date part order preferences var _setfn = function () { return _.set(arguments, g.datePartDelimiter); }; var i, RTokenKeys = [ "d", "dd", "M", "MM", "y", "yy", "yyy", "yyyy" ], RToken = [ /^([0-2]\d|3[0-1]|\d)/, /^([0-2]\d|3[0-1])/, /^(1[0-2]|0\d|\d)/, /^(1[0-2]|0\d)/, /^(\d+)/, /^(\d\d)/, /^(\d\d?\d?\d?)/, /^(\d\d\d\d)/ ], tokens = [ t.day, t.day, t.month, t.month, t.year, t.year, t.year, t.year ], eachToken = [ "ordinalSuffix", "ordinalSuffix" ]; for (i=0; i < RTokenKeys.length; i++) { cacheProcessRtoken(RTokenKeys[i], RToken[i], tokens[i], eachToken[i]); } g.MMM = g.MMMM = _.cache(_.process(g.ctoken("jan feb mar apr may jun jul aug sep oct nov dec"), t.month)); g.ddd = g.dddd = _.cache(_.process(g.ctoken("sun mon tue wed thu fri sat"), function (s) { return function () { this.weekday = s; }; } )); g.day = _fn(g.d, g.dd); g.month = _fn(g.M, g.MMM); g.year = _fn(g.yyyy, g.yy); g.mdy = _setfn(g.ddd, g.month, g.day, g.year); g.ymd = _setfn(g.ddd, g.year, g.month, g.day); g.dmy = _setfn(g.ddd, g.day, g.month, g.year); g.date = function (s) { return ((g[Date.CultureInfo.dateElementOrder] || g.mdy).call(this, s)); }; }, relative: function () { // relative date / time expressions g.orientation = _.process(g.ctoken("past future"), function (s) { return function () { this.orient = s; }; } ); g.operator = _.process(g.ctoken("add subtract"), function (s) { return function () { this.operator = s; }; } ); g.rday = _.process(g.ctoken("yesterday tomorrow today now"), t.rday); g.unit = _.process(g.ctoken("second minute hour day week month year"), function (s) { return function () { this.unit = s; }; } ); } }; g.buildGrammarFormats = function () { // these need to be rebuilt every time the language changes. _C = {}; grammarFormats.timeFormats(); grammarFormats.dateFormats(); grammarFormats.relative(); g.value = _.process(_.rtoken(/^([-+]?\d+)?(st|nd|rd|th)?/), function (s) { return function () { this.value = s.replace(/\D/g, ""); }; } ); g.expression = _.set([g.rday, g.operator, g.value, g.unit, g.orientation, g.ddd, g.MMM ]); g.format = _.process(_.many( _.any( // translate format specifiers into grammar rules _.process( _.rtoken(/^(dd?d?d?(?!e)|MM?M?M?|yy?y?y?|hh?|HH?|mm?|ss?|tt?|zz?z?)/), function (fmt) { if (g[fmt]) { return g[fmt]; } else { throw $D.Parsing.Exception(fmt); } } ), // translate separator tokens into token rules _.process(_.rtoken(/^[^dMyhHmstz]+/), // all legal separators function (s) { return _.ignore(_.stoken(s)); } ) ) ), // construct the parser ... function (rules) { return _.process(_.each.apply(null, rules), t.finishExact); } ); // starting rule for general purpose grammar g._start = _.process(_.set([ g.date, g.time, g.expression ], g.generalDelimiter, g.whiteSpace), t.finish); }; g.buildGrammarFormats(); // parsing date format specifiers - ex: "h:m:s tt" // this little guy will generate a custom parser based // on the format string, ex: g.format("h:m:s tt") // check for these formats first g._formats = g.formats([ "\"yyyy-MM-ddTHH:mm:ssZ\"", "yyyy-MM-ddTHH:mm:ss.sz", "yyyy-MM-ddTHH:mm:ssZ", "yyyy-MM-ddTHH:mm:ssz", "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-ddTHH:mmZ", "yyyy-MM-ddTHH:mmz", "yyyy-MM-ddTHH:mm", "ddd, MMM dd, yyyy H:mm:ss tt", "ddd MMM d yyyy HH:mm:ss zzz", "MMddyyyy", "ddMMyyyy", "Mddyyyy", "ddMyyyy", "Mdyyyy", "dMyyyy", "yyyy", "Mdyy", "dMyy", "d" ]); // real starting rule: tries selected formats first, // then general purpose rule g.start = function (s) { try { var r = g._formats.call({}, s); if (r[1].length === 0) { return r; } } catch (e) {} return g._start.call({}, s); }; }()); (function () { var $D = Date; /** * @desc Converts the specified string value into its JavaScript Date equivalent using CultureInfo specific format information. * * Example

	///////////
	// Dates //
	///////////

	// 15-Oct-2004
	var d1 = Date.parse("10/15/2004");

	// 15-Oct-2004
	var d1 = Date.parse("15-Oct-2004");

	// 15-Oct-2004
	var d1 = Date.parse("2004.10.15");

	//Fri Oct 15, 2004
	var d1 = Date.parse("Fri Oct 15, 2004");

	///////////
	// Times //
	///////////

	// Today at 10 PM.
	var d1 = Date.parse("10 PM");

	// Today at 10:30 PM.
	var d1 = Date.parse("10:30 P.M.");

	// Today at 6 AM.
	var d1 = Date.parse("06am");

	/////////////////////
	// Dates and Times //
	/////////////////////

	// 8-July-2004 @ 10:30 PM
	var d1 = Date.parse("July 8th, 2004, 10:30 PM");

	// 1-July-2004 @ 10:30 PM
	var d1 = Date.parse("2004-07-01T22:30:00");

	////////////////////
	// Relative Dates //
	////////////////////

	// Returns today's date. The string "today" is culture specific.
	var d1 = Date.parse("today");

	// Returns yesterday's date. The string "yesterday" is culture specific.
	var d1 = Date.parse("yesterday");

	// Returns the date of the next thursday.
	var d1 = Date.parse("Next thursday");

	// Returns the date of the most previous monday.
	var d1 = Date.parse("last monday");

	// Returns today's day + one year.
	var d1 = Date.parse("next year");

	///////////////
	// Date Math //
	///////////////

	// Today + 2 days
	var d1 = Date.parse("t+2");

	// Today + 2 days
	var d1 = Date.parse("today + 2 days");

	// Today + 3 months
	var d1 = Date.parse("t+3m");

	// Today - 1 year
	var d1 = Date.parse("today - 1 year");

	// Today - 1 year
	var d1 = Date.parse("t-1y"); 


	/////////////////////////////
	// Partial Dates and Times //
	/////////////////////////////

	// July 15th of this year.
	var d1 = Date.parse("July 15");

	// 15th day of current day and year.
	var d1 = Date.parse("15");

	// July 1st of current year at 10pm.
	var d1 = Date.parse("7/1 10pm");
	
* * @param {String} The string value to convert into a Date object [Required] * @return {Date} A Date object or null if the string cannot be converted into a Date. */ var parseUtils = { removeOrds: function (s) { ords = s.match(/\b(\d+)(?:st|nd|rd|th)\b/); // find ordinal matches s = ((ords && ords.length === 2) ? s.replace(ords[0], ords[1]) : s); return s; }, grammarParser: function (s) { var r = null; try { r = $D.Grammar.start.call({}, s.replace(/^\s*(\S*(\s+\S+)*)\s*$/, "$1")); } catch (e) { return null; } return ((r[1].length === 0) ? r[0] : null); }, nativeFallback: function(s) { var t; try { // ok we haven't parsed it, last ditch attempt with the built-in parser. t = Date._parse(s); return (t || t === 0) ? new Date(t) : null; } catch (e) { return null; } } }; function parse (s) { var d; if (!s) { return null; } if (s instanceof Date) { return s.clone(); } if (s.length >= 4 && s.charAt(0) !== "0" && s.charAt(0) !== "+"&& s.charAt(0) !== "-") { // ie: 2004 will pass, 0800 won't. // Start with specific formats d = $D.Parsing.ISO.parse(s) || $D.Parsing.Numeric.parse(s); } if (d instanceof Date && !isNaN(d.getTime())) { return d; } else { // find ordinal dates (1st, 3rd, 8th, etc and remove them as they cause parsing issues) s = $D.Parsing.Normalizer.parse(parseUtils.removeOrds(s)); d = parseUtils.grammarParser(s); if (d !== null) { return d; } else { return parseUtils.nativeFallback(s); } } } if (!$D._parse) { $D._parse = $D.parse; } $D.parse = parse; Date.getParseFunction = function (fx) { var fns = Date.Grammar.allformats(fx); return function (s) { var r = null; for (var i = 0; i < fns.length; i++) { try { r = fns[i].call({}, s); } catch (e) { continue; } if (r[1].length === 0) { return r[0]; } } return null; }; }; /** * Converts the specified string value into its JavaScript Date equivalent using the specified format {String} or formats {Array} and the CultureInfo specific format information. * The format of the string value must match one of the supplied formats exactly. * * Example

	// 15-Oct-2004
	var d1 = Date.parseExact("10/15/2004", "M/d/yyyy");

	// 15-Oct-2004
	var d1 = Date.parse("15-Oct-2004", "M-ddd-yyyy");

	// 15-Oct-2004
	var d1 = Date.parse("2004.10.15", "yyyy.MM.dd");

	// Multiple formats
	var d1 = Date.parseExact("10/15/2004", ["M/d/yyyy", "MMMM d, yyyy"]);
	
* * @param {String} The string value to convert into a Date object [Required]. * @param {Object} The expected format {String} or an array of expected formats {Array} of the date string [Required]. * @return {Date} A Date object or null if the string cannot be converted into a Date. */ $D.parseExact = function (s, fx) { return $D.getParseFunction(fx)(s); }; }()); (function () { var $D = Date, $P = $D.prototype, // $C = $D.CultureInfo, // not used atm p = function (s, l) { if (!l) { l = 2; } return ("000" + s).slice(l * -1); }; /** * Converts a PHP format string to Java/.NET format string. * A PHP format string can be used with ._format or .format. * A Java/.NET format string can be used with .toString(). * The .parseExact function will only accept a Java/.NET format string * * Example * var f1 = "%m/%d/%y" * var f2 = Date.normalizeFormat(f1); // "MM/dd/yy" * * new Date().format(f1); // "04/13/08" * new Date()._format(f1); // "04/13/08" * new Date().toString(f2); // "04/13/08" * * var date = Date.parseExact("04/13/08", f2); // Sun Apr 13 2008 * * @param {String} A PHP format string consisting of one or more format spcifiers. * @return {String} The PHP format converted to a Java/.NET format string. */ var normalizerSubstitutions = { "d" : "dd", "%d": "dd", "D" : "ddd", "%a": "ddd", "j" : "dddd", "l" : "dddd", "%A": "dddd", "S" : "S", "F" : "MMMM", "%B": "MMMM", "m" : "MM", "%m": "MM", "M" : "MMM", "%b": "MMM", "%h": "MMM", "n" : "M", "Y" : "yyyy", "%Y": "yyyy", "y" : "yy", "%y": "yy", "g" : "h", "%I": "h", "G" : "H", "h" : "hh", "H" : "HH", "%H": "HH", "i" : "mm", "%M": "mm", "s" : "ss", "%S": "ss", "%r": "hh:mm tt", "%R": "H:mm", "%T": "H:mm:ss", "%X": "t", "%x": "d", "%e": "d", "%D": "MM/dd/yy", "%n": "\\n", "%t": "\\t", "e" : "z", "T" : "z", "%z": "z", "%Z": "z", "Z" : "ZZ", "N" : "u", "w" : "u", "%w": "u", "W" : "W", "%V": "W" }; var normalizer = { substitutes: function (m) { return normalizerSubstitutions[m]; }, interpreted: function (m, x) { var y; switch (m) { case "%u": return x.getDay() + 1; case "z": return x.getOrdinalNumber(); case "%j": return p(x.getOrdinalNumber(), 3); case "%U": var d1 = x.clone().set({month: 0, day: 1}).addDays(-1).moveToDayOfWeek(0), d2 = x.clone().addDays(1).moveToDayOfWeek(0, -1); return (d2 < d1) ? "00" : p((d2.getOrdinalNumber() - d1.getOrdinalNumber()) / 7 + 1); case "%W": return p(x.getWeek()); case "t": return $D.getDaysInMonth(x.getFullYear(), x.getMonth()); case "o": case "%G": return x.setWeek(x.getISOWeek()).toString("yyyy"); case "%g": return x._format("%G").slice(-2); case "a": case "%p": return t("tt").toLowerCase(); case "A": return t("tt").toUpperCase(); case "u": return p(x.getMilliseconds(), 3); case "I": return (x.isDaylightSavingTime()) ? 1 : 0; case "O": return x.getUTCOffset(); case "P": y = x.getUTCOffset(); return y.substring(0, y.length - 2) + ":" + y.substring(y.length - 2); case "B": var now = new Date(); return Math.floor(((now.getHours() * 3600) + (now.getMinutes() * 60) + now.getSeconds() + (now.getTimezoneOffset() + 60) * 60) / 86.4); case "c": return x.toISOString().replace(/\"/g, ""); case "U": return $D.strtotime("now"); case "%c": return t("d") + " " + t("t"); case "%C": return Math.floor(x.getFullYear() / 100 + 1); } }, shouldOverrideDefaults: function (m) { switch (m) { case "%e": return true; default: return false; } }, parse: function (m, context) { var formatString, c = context || new Date(); formatString = normalizer.substitutes(m); if (formatString) { return formatString; } formatString = normalizer.interpreted(m, c); if (formatString) { return formatString; } else { return m; } } }; $D.normalizeFormat = function (format, context) { return format.replace(/(%|\\)?.|%%/g, function(t){ return normalizer.parse(t, context); }); }; /** * Format a local Unix timestamp according to locale settings * * Example: * Date.strftime("%m/%d/%y", new Date()); // "04/13/08" * Date.strftime("c", "2008-04-13T17:52:03Z"); // "04/13/08" * * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @param {Number|String} The number representing the number of seconds that have elapsed since January 1, 1970 (local time). * @return {String} A string representation of the current Date object. */ $D.strftime = function (format, time) { var d = Date.parse(time); return d._format(format); }; /** * Parse any textual datetime description into a Unix timestamp. * A Unix timestamp is the number of seconds that have elapsed since January 1, 1970 (midnight UTC/GMT). * * Example: * Date.strtotime("04/13/08"); // 1208044800 * Date.strtotime("1970-01-01T00:00:00Z"); // 0 * * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @param {Object} A string or date object. * @return {String} A string representation of the current Date object. */ $D.strtotime = function (time) { var d = $D.parse(time); return Math.round($D.UTC(d.getUTCFullYear(), d.getUTCMonth(), d.getUTCDate(), d.getUTCHours(), d.getUTCMinutes(), d.getUTCSeconds(), d.getUTCMilliseconds()) / 1000); }; /** * Converts the value of the current Date object to its equivalent string representation using a PHP/Unix style of date format specifiers. * Format Specifiers * Format Description Example * ------ --------------------------------------------------------------------------- ----------------------- * %a abbreviated weekday name according to the current localed "Mon" through "Sun" * %A full weekday name according to the current localed "Sunday" through "Saturday" * %b abbreviated month name according to the current localed "Jan" through "Dec" * %B full month name according to the current locale "January" through "December" * %c preferred date and time representation for the current locale "4/13/2008 12:33 PM" * %C century number (the year divided by 100 and truncated to an integer) "00" to "99" * %d day of the month as a decimal number "01" to "31" * %D same as %m/%d/%y "04/13/08" * %e day of the month as a decimal number, a single digit is preceded by a space "1" to "31" * %g like %G, but without the century "08" * %G The 4-digit year corresponding to the ISO week number (see %V). "2008" * This has the same format and value as %Y, except that if the ISO week number * belongs to the previous or next year, that year is used instead. * %h same as %b "Jan" through "Dec" * %H hour as a decimal number using a 24-hour clock. "00" to "23" * %I hour as a decimal number using a 12-hour clock. "01" to "12" * %j day of the year as a decimal number. "001" to "366" * %m month as a decimal number. "01" to "12" * %M minute as a decimal number. "00" to "59" * %n newline character "\n" * %p either "am" or "pm" according to the given time value, or the "am" or "pm" * corresponding strings for the current locale. * %r time in a.m. and p.m. notation "8:44 PM" * %R time in 24 hour notation "20:44" * %S second as a decimal number "00" to "59" * %t tab character "\t" * %T current time, equal to %H:%M:%S "12:49:11" * %u weekday as a decimal number ["1", "7"], with "1" representing Monday "1" to "7" * %U week number of the current year as a decimal number, starting with the "0" to ("52" or "53") * first Sunday as the first day of the first week * %V The ISO 8601:1988 week number of the current year as a decimal number, "00" to ("52" or "53") * range 01 to 53, where week 1 is the first week that has at least 4 days * in the current year, and with Monday as the first day of the week. * (Use %G or %g for the year component that corresponds to the week number * for the specified timestamp.) * %W week number of the current year as a decimal number, starting with the "00" to ("52" or "53") * first Monday as the first day of the first week * %w day of the week as a decimal, Sunday being "0" "0" to "6" * %x preferred date representation for the current locale without the time "4/13/2008" * %X preferred time representation for the current locale without the date "12:53:05" * %y year as a decimal number without a century "00" "99" * %Y year as a decimal number including the century "2008" * %Z time zone or name or abbreviation "UTC", "EST", "PST" * %z same as %Z * %% a literal "%" characters "%" * d Day of the month, 2 digits with leading zeros "01" to "31" * D A textual representation of a day, three letters "Mon" through "Sun" * j Day of the month without leading zeros "1" to "31" * l A full textual representation of the day of the week (lowercase "L") "Sunday" through "Saturday" * N ISO-8601 numeric representation of the day of the week (added in PHP 5.1.0) "1" (for Monday) through "7" (for Sunday) * S English ordinal suffix for the day of the month, 2 characters "st", "nd", "rd" or "th". Works well with j * w Numeric representation of the day of the week "0" (for Sunday) through "6" (for Saturday) * z The day of the year (starting from "0") "0" through "365" * W ISO-8601 week number of year, weeks starting on Monday "00" to ("52" or "53") * F A full textual representation of a month, such as January or March "January" through "December" * m Numeric representation of a month, with leading zeros "01" through "12" * M A short textual representation of a month, three letters "Jan" through "Dec" * n Numeric representation of a month, without leading zeros "1" through "12" * t Number of days in the given month "28" through "31" * L Whether it's a leap year "1" if it is a leap year, "0" otherwise * o ISO-8601 year number. This has the same value as Y, except that if the "2008" * ISO week number (W) belongs to the previous or next year, that year * is used instead. * Y A full numeric representation of a year, 4 digits "2008" * y A two digit representation of a year "08" * a Lowercase Ante meridiem and Post meridiem "am" or "pm" * A Uppercase Ante meridiem and Post meridiem "AM" or "PM" * B Swatch Internet time "000" through "999" * g 12-hour format of an hour without leading zeros "1" through "12" * G 24-hour format of an hour without leading zeros "0" through "23" * h 12-hour format of an hour with leading zeros "01" through "12" * H 24-hour format of an hour with leading zeros "00" through "23" * i Minutes with leading zeros "00" to "59" * s Seconds, with leading zeros "00" through "59" * u Milliseconds "54321" * e Timezone identifier "UTC", "EST", "PST" * I Whether or not the date is in daylight saving time (uppercase i) "1" if Daylight Saving Time, "0" otherwise * O Difference to Greenwich time (GMT) in hours "+0200", "-0600" * P Difference to Greenwich time (GMT) with colon between hours and minutes "+02:00", "-06:00" * T Timezone abbreviation "UTC", "EST", "PST" * Z Timezone offset in seconds. The offset for timezones west of UTC is "-43200" through "50400" * always negative, and for those east of UTC is always positive. * c ISO 8601 date "2004-02-12T15:19:21+00:00" * r RFC 2822 formatted date "Thu, 21 Dec 2000 16:01:07 +0200" * U Seconds since the Unix Epoch (January 1 1970 00:00:00 GMT) "0" * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @return {String} A string representation of the current Date object. */ var formatReplace = function (context) { return function (m) { var formatString, override = false; if (m.charAt(0) === "\\" || m.substring(0, 2) === "%%") { return m.replace("\\", "").replace("%%", "%"); } override = normalizer.shouldOverrideDefaults(m); formatString = $D.normalizeFormat(m, context); if (formatString) { return context.toString(formatString, override); } }; }; $P._format = function (format) { var formatter = formatReplace(this); if (!format) { return this._toString(); } else { return format.replace(/(%|\\)?.|%%/g, formatter); } }; if (!$P.format) { $P.format = $P._format; } }()); (function () { "use strict"; var gFn = function (attr) { return function () { return this[attr]; }; }; var sFn = function (attr) { return function (val) { this[attr] = val; return this; }; }; var attrs = ["years", "months", "days", "hours", "minutes", "seconds", "milliseconds"]; var addSetFuncs = function (context, attrs) { for (var i = 0; i < attrs.length ; i++) { var $a = attrs[i], $b = $a.slice(0, 1).toUpperCase() + $a.slice(1); context.prototype[$a] = 0; context.prototype["get" + $b] = gFn($a); context.prototype["set" + $b] = sFn($a); } }; /** * new TimeSpan(milliseconds); * new TimeSpan(days, hours, minutes, seconds); * new TimeSpan(days, hours, minutes, seconds, milliseconds); */ var TimeSpan = function (days, hours, minutes, seconds, milliseconds) { if (arguments.length === 1 && typeof days === "number") { var orient = (days < 0) ? -1 : +1; var millsLeft = Math.abs(days); this.setDays(Math.floor(millsLeft / 86400000) * orient); millsLeft = millsLeft % 86400000; this.setHours(Math.floor(millsLeft / 3600000) * orient); millsLeft = millsLeft % 3600000; this.setMinutes(Math.floor(millsLeft / 60000) * orient); millsLeft = millsLeft % 60000; this.setSeconds(Math.floor(millsLeft / 1000) * orient); millsLeft = millsLeft % 1000; this.setMilliseconds(millsLeft * orient); } else { this.set(days, hours, minutes, seconds, milliseconds); } this.getTotalMilliseconds = function () { return (this.getDays() * 86400000) + (this.getHours() * 3600000) + (this.getMinutes() * 60000) + (this.getSeconds() * 1000); }; this.compareTo = function (time) { var t1 = new Date(1970, 1, 1, this.getHours(), this.getMinutes(), this.getSeconds()), t2; if (time === null) { t2 = new Date(1970, 1, 1, 0, 0, 0); } else { t2 = new Date(1970, 1, 1, time.getHours(), time.getMinutes(), time.getSeconds()); } return (t1 < t2) ? -1 : (t1 > t2) ? 1 : 0; }; this.equals = function (time) { return (this.compareTo(time) === 0); }; this.add = function (time) { return (time === null) ? this : this.addSeconds(time.getTotalMilliseconds() / 1000); }; this.subtract = function (time) { return (time === null) ? this : this.addSeconds(-time.getTotalMilliseconds() / 1000); }; this.addDays = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 86400000)); }; this.addHours = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 3600000)); }; this.addMinutes = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 60000)); }; this.addSeconds = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 1000)); }; this.addMilliseconds = function (n) { return new TimeSpan(this.getTotalMilliseconds() + n); }; this.get12HourHour = function () { return (this.getHours() > 12) ? this.getHours() - 12 : (this.getHours() === 0) ? 12 : this.getHours(); }; this.getDesignator = function () { return (this.getHours() < 12) ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator; }; this.toString = function (format) { this._toString = function () { if (this.getDays() !== null && this.getDays() > 0) { return this.getDays() + "." + this.getHours() + ":" + this.p(this.getMinutes()) + ":" + this.p(this.getSeconds()); } else { return this.getHours() + ":" + this.p(this.getMinutes()) + ":" + this.p(this.getSeconds()); } }; this.p = function (s) { return (s.toString().length < 2) ? "0" + s : s; }; var me = this; return format ? format.replace(/dd?|HH?|hh?|mm?|ss?|tt?/g, function (format) { switch (format) { case "d": return me.getDays(); case "dd": return me.p(me.getDays()); case "H": return me.getHours(); case "HH": return me.p(me.getHours()); case "h": return me.get12HourHour(); case "hh": return me.p(me.get12HourHour()); case "m": return me.getMinutes(); case "mm": return me.p(me.getMinutes()); case "s": return me.getSeconds(); case "ss": return me.p(me.getSeconds()); case "t": return ((me.getHours() < 12) ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator).substring(0, 1); case "tt": return (me.getHours() < 12) ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator; } } ) : this._toString(); }; return this; }; addSetFuncs(TimeSpan, attrs.slice(2)); TimeSpan.prototype.set = function (days, hours, minutes, seconds, milliseconds){ this.setDays(days || this.getDays()); this.setHours(hours || this.getHours()); this.setMinutes(minutes || this.getMinutes()); this.setSeconds(seconds || this.getSeconds()); this.setMilliseconds(milliseconds || this.getMilliseconds()); }; /** * Gets the time of day for this date instances. * @return {TimeSpan} TimeSpan */ Date.prototype.getTimeOfDay = function () { return new TimeSpan(0, this.getHours(), this.getMinutes(), this.getSeconds(), this.getMilliseconds()); }; Date.TimeSpan = TimeSpan; if (typeof window !== "undefined" ) { // keeping API compatible for v1.x window.TimeSpan = TimeSpan; } }()); (function () { "use strict"; var attrs = ["years", "months", "days", "hours", "minutes", "seconds", "milliseconds"]; var gFn = function (attr) { return function () { return this[attr]; }; }; var sFn = function (attr) { return function (val) { this[attr] = val; return this; }; }; var addSetFuncs = function (context, attrs) { for (var i = 0; i < attrs.length ; i++) { var $a = attrs[i], $b = $a.slice(0, 1).toUpperCase() + $a.slice(1); context.prototype[$a] = 0; context.prototype["get" + $b] = gFn($a); context.prototype["set" + $b] = sFn($a); } }; var setMonthsAndYears = function (orient, d1, d2, context) { function inc() { d1.addMonths(-orient); context.months++; if (context.months === 12) { context.years++; context.months = 0; } } if (orient === +1) { while (d1 > d2) { inc(); } } else { while (d1 < d2) { inc(); } } context.months--; context.months *= orient; context.years *= orient; }; var adjustForDST = function(orient, startDate, endDate) { var hasDSTMismatch = (false === (startDate.isDaylightSavingTime() === endDate.isDaylightSavingTime())); if (hasDSTMismatch && orient === 1) { startDate.addHours(-1); } else if (hasDSTMismatch) { startDate.addHours(1); } }; /** * TimePeriod(startDate, endDate); * TimePeriod(years, months, days, hours, minutes, seconds, milliseconds); */ var TimePeriod = function (years, months, days, hours, minutes, seconds, milliseconds) { if (arguments.length === 7) { this.set(years, months, days, hours, minutes, seconds, milliseconds); } else if (arguments.length === 2 && arguments[0] instanceof Date && arguments[1] instanceof Date) { var startDate = arguments[0].clone(); var endDate = arguments[1].clone(); var orient = (startDate > endDate) ? +1 : -1; this.dates = { start: arguments[0].clone(), end: arguments[1].clone() }; setMonthsAndYears(orient, startDate, endDate, this); adjustForDST(orient, startDate, endDate); // // TODO - adjust for DST var diff = endDate - startDate; if (diff !== 0) { var ts = new TimeSpan(diff); this.set(this.years, this.months, ts.getDays(), ts.getHours(), ts.getMinutes(), ts.getSeconds(), ts.getMilliseconds()); } } return this; }; // create all the set functions. addSetFuncs(TimePeriod, attrs); TimePeriod.prototype.set = function (years, months, days, hours, minutes, seconds, milliseconds){ this.setYears(years || this.getYears()); this.setMonths(months || this.getMonths()); this.setDays(days || this.getDays()); this.setHours(hours || this.getHours()); this.setMinutes(minutes || this.getMinutes()); this.setSeconds(seconds || this.getSeconds()); this.setMilliseconds(milliseconds || this.getMilliseconds()); }; Date.TimePeriod = TimePeriod; if (typeof window !== "undefined") { // keeping API compatible for v1.x window.TimePeriod = TimePeriod; } }()); ================================================ FILE: build/date-en-TT.js ================================================ /** * @overview datejs * @version 1.0.0-rc3 * @author Gregory Wild-Smith * @copyright 2015 Gregory Wild-Smith * @license MIT * @homepage https://github.com/abritinthebay/datejs */ /* * DateJS Culture String File * Country Code: en-TT * Name: English (Trinidad and Tobago) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["en-TT"] = { "name": "en-TT", "englishName": "English (Trinidad and Tobago)", "nativeName": "English (Trinidad y Tobago)", "Sunday": "Sunday", "Monday": "Monday", "Tuesday": "Tuesday", "Wednesday": "Wednesday", "Thursday": "Thursday", "Friday": "Friday", "Saturday": "Saturday", "Sun": "Sun", "Mon": "Mon", "Tue": "Tue", "Wed": "Wed", "Thu": "Thu", "Fri": "Fri", "Sat": "Sat", "Su": "Su", "Mo": "Mo", "Tu": "Tu", "We": "We", "Th": "Th", "Fr": "Fr", "Sa": "Sa", "S_Sun_Initial": "S", "M_Mon_Initial": "M", "T_Tue_Initial": "T", "W_Wed_Initial": "W", "T_Thu_Initial": "T", "F_Fri_Initial": "F", "S_Sat_Initial": "S", "January": "January", "February": "February", "March": "March", "April": "April", "May": "May", "June": "June", "July": "July", "August": "August", "September": "September", "October": "October", "November": "November", "December": "December", "Jan_Abbr": "Jan", "Feb_Abbr": "Feb", "Mar_Abbr": "Mar", "Apr_Abbr": "Apr", "May_Abbr": "May", "Jun_Abbr": "Jun", "Jul_Abbr": "Jul", "Aug_Abbr": "Aug", "Sep_Abbr": "Sep", "Oct_Abbr": "Oct", "Nov_Abbr": "Nov", "Dec_Abbr": "Dec", "AM": "AM", "PM": "PM", "firstDayOfWeek": 0, "twoDigitYearMax": 2029, "mdy": "dmy", "M/d/yyyy": "dd/MM/yyyy", "dddd, MMMM dd, yyyy": "dddd, dd MMMM yyyy", "h:mm tt": "hh:mm tt", "h:mm:ss tt": "hh:mm:ss tt", "dddd, MMMM dd, yyyy h:mm:ss tt": "dddd, dd MMMM yyyy hh:mm:ss tt", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "dd MMMM", "MMMM, yyyy": "MMMM yyyy", "/jan(uary)?/": "jan(uary)?", "/feb(ruary)?/": "feb(ruary)?", "/mar(ch)?/": "mar(ch)?", "/apr(il)?/": "apr(il)?", "/may/": "may", "/jun(e)?/": "jun(e)?", "/jul(y)?/": "jul(y)?", "/aug(ust)?/": "aug(ust)?", "/sep(t(ember)?)?/": "sep(t(ember)?)?", "/oct(ober)?/": "oct(ober)?", "/nov(ember)?/": "nov(ember)?", "/dec(ember)?/": "dec(ember)?", "/^su(n(day)?)?/": "^su(n(day)?)?", "/^mo(n(day)?)?/": "^mo(n(day)?)?", "/^tu(e(s(day)?)?)?/": "^tu(e(s(day)?)?)?", "/^we(d(nesday)?)?/": "^we(d(nesday)?)?", "/^th(u(r(s(day)?)?)?)?/": "^th(u(r(s(day)?)?)?)?", "/^fr(i(day)?)?/": "^fr(i(day)?)?", "/^sa(t(urday)?)?/": "^sa(t(urday)?)?", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "en-TT"; /** * @overview datejs * @version 1.0.0-rc3 * @author Gregory Wild-Smith * @copyright 2015 Gregory Wild-Smith * @license MIT * @homepage https://github.com/abritinthebay/datejs */(function () { var $D = Date; var lang = Date.CultureStrings ? Date.CultureStrings.lang : null; var loggedKeys = {}; // for debug purposes. var getText = { getFromKey: function (key, countryCode) { var output; if (Date.CultureStrings && Date.CultureStrings[countryCode] && Date.CultureStrings[countryCode][key]) { output = Date.CultureStrings[countryCode][key]; } else { output = getText.buildFromDefault(key); } if (key.charAt(0) === "/") { // Assume it's a regex output = getText.buildFromRegex(key, countryCode); } return output; }, getFromObjectValues: function (obj, countryCode) { var key, output = {}; for(key in obj) { if (obj.hasOwnProperty(key)) { output[key] = getText.getFromKey(obj[key], countryCode); } } return output; }, getFromObjectKeys: function (obj, countryCode) { var key, output = {}; for(key in obj) { if (obj.hasOwnProperty(key)) { output[getText.getFromKey(key, countryCode)] = obj[key]; } } return output; }, getFromArray: function (arr, countryCode) { var output = []; for (var i=0; i < arr.length; i++){ if (i in arr) { output[i] = getText.getFromKey(arr[i], countryCode); } } return output; }, buildFromDefault: function (key) { var output, length, split, last; switch(key) { case "name": output = "en-US"; break; case "englishName": output = "English (United States)"; break; case "nativeName": output = "English (United States)"; break; case "twoDigitYearMax": output = 2049; break; case "firstDayOfWeek": output = 0; break; default: output = key; split = key.split("_"); length = split.length; if (length > 1 && key.charAt(0) !== "/") { // if the key isn't a regex and it has a split. last = split[(length - 1)].toLowerCase(); if (last === "initial" || last === "abbr") { output = split[0]; } } break; } return output; }, buildFromRegex: function (key, countryCode) { var output; if (Date.CultureStrings && Date.CultureStrings[countryCode] && Date.CultureStrings[countryCode][key]) { output = new RegExp(Date.CultureStrings[countryCode][key], "i"); } else { output = new RegExp(key.replace(new RegExp("/", "g"),""), "i"); } return output; } }; var shallowMerge = function (obj1, obj2) { for (var attrname in obj2) { if (obj2.hasOwnProperty(attrname)) { obj1[attrname] = obj2[attrname]; } } }; var __ = function (key, language) { var countryCode = (language) ? language : lang; loggedKeys[key] = key; if (typeof key === "object") { if (key instanceof Array) { return getText.getFromArray(key, countryCode); } else { return getText.getFromObjectKeys(key, countryCode); } } else { return getText.getFromKey(key, countryCode); } }; var loadI18nScript = function (code) { // paatterned after jQuery's getScript. var url = Date.Config.i18n + code + ".js"; var head = document.getElementsByTagName("head")[0] || document.documentElement; var script = document.createElement("script"); script.src = url; var completed = false; var events = { done: function (){} // placeholder function }; // Attach handlers for all browsers script.onload = script.onreadystatechange = function() { if ( !completed && (!this.readyState || this.readyState === "loaded" || this.readyState === "complete") ) { events.done(); head.removeChild(script); } }; setTimeout(function() { head.insertBefore(script, head.firstChild); }, 0); // allows return to execute first return { done: function (cb) { events.done = function() { if (cb) { setTimeout(cb,0); } }; } }; }; var buildInfo = { buildFromMethodHash: function (obj) { var key; for(key in obj) { if (obj.hasOwnProperty(key)) { obj[key] = buildInfo[obj[key]](); } } return obj; }, timeZoneDST: function () { var DST = { "CHADT": "+1345", "NZDT": "+1300", "AEDT": "+1100", "ACDT": "+1030", "AZST": "+0500", "IRDT": "+0430", "EEST": "+0300", "CEST": "+0200", "BST": "+0100", "PMDT": "-0200", "ADT": "-0300", "NDT": "-0230", "EDT": "-0400", "CDT": "-0500", "MDT": "-0600", "PDT": "-0700", "AKDT": "-0800", "HADT": "-0900" }; return __(DST); }, timeZoneStandard: function () { var standard = { "LINT": "+1400", "TOT": "+1300", "CHAST": "+1245", "NZST": "+1200", "NFT": "+1130", "SBT": "+1100", "AEST": "+1000", "ACST": "+0930", "JST": "+0900", "CWST": "+0845", "CT": "+0800", "ICT": "+0700", "MMT": "+0630", "BST": "+0600", "NPT": "+0545", "IST": "+0530", "PKT": "+0500", "AFT": "+0430", "MSK": "+0400", "IRST": "+0330", "FET": "+0300", "EET": "+0200", "CET": "+0100", "GMT": "+0000", "UTC": "+0000", "CVT": "-0100", "GST": "-0200", "BRT": "-0300", "NST": "-0330", "AST": "-0400", "EST": "-0500", "CST": "-0600", "MST": "-0700", "PST": "-0800", "AKST": "-0900", "MIT": "-0930", "HST": "-1000", "SST": "-1100", "BIT": "-1200" }; return __(standard); }, timeZones: function (data) { var zone; data.timezones = []; for (zone in data.abbreviatedTimeZoneStandard) { if (data.abbreviatedTimeZoneStandard.hasOwnProperty(zone)) { data.timezones.push({ name: zone, offset: data.abbreviatedTimeZoneStandard[zone]}); } } for (zone in data.abbreviatedTimeZoneDST) { if (data.abbreviatedTimeZoneDST.hasOwnProperty(zone)) { data.timezones.push({ name: zone, offset: data.abbreviatedTimeZoneDST[zone], dst: true}); } } return data.timezones; }, days: function () { return __(["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"]); }, dayAbbr: function () { return __(["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"]); }, dayShortNames: function () { return __(["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"]); }, dayFirstLetters: function () { return __(["S_Sun_Initial", "M_Mon_Initial", "T_Tues_Initial", "W_Wed_Initial", "T_Thu_Initial", "F_Fri_Initial", "S_Sat_Initial"]); }, months: function () { return __(["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"]); }, monthAbbr: function () { return __(["Jan_Abbr", "Feb_Abbr", "Mar_Abbr", "Apr_Abbr", "May_Abbr", "Jun_Abbr", "Jul_Abbr", "Aug_Abbr", "Sep_Abbr", "Oct_Abbr", "Nov_Abbr", "Dec_Abbr"]); }, formatPatterns: function () { return getText.getFromObjectValues({ shortDate: "M/d/yyyy", longDate: "dddd, MMMM dd, yyyy", shortTime: "h:mm tt", longTime: "h:mm:ss tt", fullDateTime: "dddd, MMMM dd, yyyy h:mm:ss tt", sortableDateTime: "yyyy-MM-ddTHH:mm:ss", universalSortableDateTime: "yyyy-MM-dd HH:mm:ssZ", rfc1123: "ddd, dd MMM yyyy HH:mm:ss", monthDay: "MMMM dd", yearMonth: "MMMM, yyyy" }, Date.i18n.currentLanguage()); }, regex: function () { return getText.getFromObjectValues({ inTheMorning: "/( in the )(morn(ing)?)\\b/", thisMorning: "/(this )(morn(ing)?)\\b/", amThisMorning: "/(\b\\d(am)? )(this )(morn(ing)?)/", inTheEvening: "/( in the )(even(ing)?)\\b/", thisEvening: "/(this )(even(ing)?)\\b/", pmThisEvening: "/(\b\\d(pm)? )(this )(even(ing)?)/", jan: "/jan(uary)?/", feb: "/feb(ruary)?/", mar: "/mar(ch)?/", apr: "/apr(il)?/", may: "/may/", jun: "/jun(e)?/", jul: "/jul(y)?/", aug: "/aug(ust)?/", sep: "/sep(t(ember)?)?/", oct: "/oct(ober)?/", nov: "/nov(ember)?/", dec: "/dec(ember)?/", sun: "/^su(n(day)?)?/", mon: "/^mo(n(day)?)?/", tue: "/^tu(e(s(day)?)?)?/", wed: "/^we(d(nesday)?)?/", thu: "/^th(u(r(s(day)?)?)?)?/", fri: "/fr(i(day)?)?/", sat: "/^sa(t(urday)?)?/", future: "/^next/", past: "/^last|past|prev(ious)?/", add: "/^(\\+|aft(er)?|from|hence)/", subtract: "/^(\\-|bef(ore)?|ago)/", yesterday: "/^yes(terday)?/", today: "/^t(od(ay)?)?/", tomorrow: "/^tom(orrow)?/", now: "/^n(ow)?/", millisecond: "/^ms|milli(second)?s?/", second: "/^sec(ond)?s?/", minute: "/^mn|min(ute)?s?/", hour: "/^h(our)?s?/", week: "/^w(eek)?s?/", month: "/^m(onth)?s?/", day: "/^d(ay)?s?/", year: "/^y(ear)?s?/", shortMeridian: "/^(a|p)/", longMeridian: "/^(a\\.?m?\\.?|p\\.?m?\\.?)/", timezone: "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/", ordinalSuffix: "/^\\s*(st|nd|rd|th)/", timeContext: "/^\\s*(\\:|a(?!u|p)|p)/" }, Date.i18n.currentLanguage()); } }; var CultureInfo = function () { var info = getText.getFromObjectValues({ name: "name", englishName: "englishName", nativeName: "nativeName", amDesignator: "AM", pmDesignator: "PM", firstDayOfWeek: "firstDayOfWeek", twoDigitYearMax: "twoDigitYearMax", dateElementOrder: "mdy" }, Date.i18n.currentLanguage()); var constructedInfo = buildInfo.buildFromMethodHash({ dayNames: "days", abbreviatedDayNames: "dayAbbr", shortestDayNames: "dayShortNames", firstLetterDayNames: "dayFirstLetters", monthNames: "months", abbreviatedMonthNames: "monthAbbr", formatPatterns: "formatPatterns", regexPatterns: "regex", abbreviatedTimeZoneDST: "timeZoneDST", abbreviatedTimeZoneStandard: "timeZoneStandard" }); shallowMerge(info, constructedInfo); buildInfo.timeZones(info); return info; }; $D.i18n = { __: function (key, lang) { return __(key, lang); }, currentLanguage: function () { return lang || "en-US"; }, setLanguage: function (code, force, cb) { var async = false; if (force || code === "en-US" || (!!Date.CultureStrings && !!Date.CultureStrings[code])) { lang = code; Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings.lang = code; Date.CultureInfo = new CultureInfo(); } else { if (!(!!Date.CultureStrings && !!Date.CultureStrings[code])) { if (typeof exports !== "undefined" && this.exports !== exports) { // we're in a Node enviroment, load it using require try { require("../i18n/" + code + ".js"); lang = code; Date.CultureStrings.lang = code; Date.CultureInfo = new CultureInfo(); } catch (e) { // var str = "The language for '" + code + "' could not be loaded by Node. It likely does not exist."; throw new Error("The DateJS IETF language tag '" + code + "' could not be loaded by Node. It likely does not exist."); } } else if (Date.Config && Date.Config.i18n) { // we know the location of the files, so lets load them async = true; loadI18nScript(code).done(function(){ lang = code; Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings.lang = code; Date.CultureInfo = new CultureInfo(); $D.Parsing.Normalizer.buildReplaceData(); // because this is async if ($D.Grammar) { $D.Grammar.buildGrammarFormats(); // so we can parse those strings... } if (cb) { setTimeout(cb,0); } }); } else { Date.console.error("The DateJS IETF language tag '" + code + "' is not available and has not been loaded."); return false; } } } $D.Parsing.Normalizer.buildReplaceData(); // rebuild normalizer strings if ($D.Grammar) { $D.Grammar.buildGrammarFormats(); // so we can parse those strings... } if (!async && cb) { setTimeout(cb,0); } }, getLoggedKeys: function () { return loggedKeys; }, updateCultureInfo: function () { Date.CultureInfo = new CultureInfo(); } }; $D.i18n.updateCultureInfo(); // run automatically }()); (function () { var $D = Date, $P = $D.prototype, p = function (s, l) { if (!l) { l = 2; } return ("000" + s).slice(l * -1); }; if (typeof window !== "undefined" && typeof window.console !== "undefined" && typeof window.console.log !== "undefined") { $D.console = console; // used only to raise non-critical errors if available } else { // set mock so we don't give errors. $D.console = { log: function(){}, error: function(){} }; } $D.Config = $D.Config || {}; $D.initOverloads = function() { /** * Overload of Date.now. Allows an alternate call for Date.now where it returns the * current Date as an object rather than just milliseconds since the Unix Epoch. * * Also provides an implementation of now() for browsers (IE<9) that don't have it. * * Backwards compatible so with work with either: * Date.now() [returns ms] * or * Date.now(true) [returns Date] */ if (!$D.now) { $D._now = function now() { return new Date().getTime(); }; } else if (!$D._now) { $D._now = $D.now; } $D.now = function (returnObj) { if (returnObj) { return $D.present(); } else { return $D._now(); } }; if ( !$P.toISOString ) { $P.toISOString = function() { return this.getUTCFullYear() + "-" + p(this.getUTCMonth() + 1) + "-" + p(this.getUTCDate()) + "T" + p(this.getUTCHours()) + ":" + p(this.getUTCMinutes()) + ":" + p(this.getUTCSeconds()) + "." + String( (this.getUTCMilliseconds()/1000).toFixed(3)).slice(2, 5) + "Z"; }; } // private if ( $P._toString === undefined ){ $P._toString = $P.toString; } }; $D.initOverloads(); /** * Gets a date that is set to the current date. The time is set to the start of the day (00:00 or 12:00 AM). * @return {Date} The current date. */ $D.today = function () { return new Date().clearTime(); }; /** * Gets a date that is set to the current date and time (same as new Date, but chainable) * @return {Date} The current date. */ $D.present = function () { return new Date(); }; /** * Compares the first date to the second date and returns an number indication of their relative values. * @param {Date} First Date object to compare [Required]. * @param {Date} Second Date object to compare to [Required]. * @return {Number} -1 = date1 is lessthan date2. 0 = values are equal. 1 = date1 is greaterthan date2. */ $D.compare = function (date1, date2) { if (isNaN(date1) || isNaN(date2)) { throw new Error(date1 + " - " + date2); } else if (date1 instanceof Date && date2 instanceof Date) { return (date1 < date2) ? -1 : (date1 > date2) ? 1 : 0; } else { throw new TypeError(date1 + " - " + date2); } }; /** * Compares the first Date object to the second Date object and returns true if they are equal. * @param {Date} First Date object to compare [Required] * @param {Date} Second Date object to compare to [Required] * @return {Boolean} true if dates are equal. false if they are not equal. */ $D.equals = function (date1, date2) { return (date1.compareTo(date2) === 0); }; /** * Gets the language appropriate day name when given the day number(0-6) * eg - 0 == Sunday * @return {String} The day name */ $D.getDayName = function (n) { return Date.CultureInfo.dayNames[n]; }; /** * Gets the day number (0-6) if given a CultureInfo specific string which is a valid dayName, abbreviatedDayName or shortestDayName (two char). * @param {String} The name of the day (eg. "Monday, "Mon", "tuesday", "tue", "We", "we"). * @return {Number} The day number */ $D.getDayNumberFromName = function (name) { var n = Date.CultureInfo.dayNames, m = Date.CultureInfo.abbreviatedDayNames, o = Date.CultureInfo.shortestDayNames, s = name.toLowerCase(); for (var i = 0; i < n.length; i++) { if (n[i].toLowerCase() === s || m[i].toLowerCase() === s || o[i].toLowerCase() === s) { return i; } } return -1; }; /** * Gets the month number (0-11) if given a Culture Info specific string which is a valid monthName or abbreviatedMonthName. * @param {String} The name of the month (eg. "February, "Feb", "october", "oct"). * @return {Number} The day number */ $D.getMonthNumberFromName = function (name) { var n = Date.CultureInfo.monthNames, m = Date.CultureInfo.abbreviatedMonthNames, s = name.toLowerCase(); for (var i = 0; i < n.length; i++) { if (n[i].toLowerCase() === s || m[i].toLowerCase() === s) { return i; } } return -1; }; /** * Gets the language appropriate month name when given the month number(0-11) * eg - 0 == January * @return {String} The month name */ $D.getMonthName = function (n) { return Date.CultureInfo.monthNames[n]; }; /** * Determines if the current date instance is within a LeapYear. * @param {Number} The year. * @return {Boolean} true if date is within a LeapYear, otherwise false. */ $D.isLeapYear = function (year) { return ((year % 4 === 0 && year % 100 !== 0) || year % 400 === 0); }; /** * Gets the number of days in the month, given a year and month value. Automatically corrects for LeapYear. * @param {Number} The year. * @param {Number} The month (0-11). * @return {Number} The number of days in the month. */ $D.getDaysInMonth = function (year, month) { if (!month && $D.validateMonth(year)) { month = year; year = Date.today().getFullYear(); } return [31, ($D.isLeapYear(year) ? 29 : 28), 31, 30, 31, 30, 31, 31, 30, 31, 30, 31][month]; }; $P.getDaysInMonth = function () { return $D.getDaysInMonth(this.getFullYear(), this.getMonth()); }; $D.getTimezoneAbbreviation = function (offset, dst) { var p, n = (dst || false) ? Date.CultureInfo.abbreviatedTimeZoneDST : Date.CultureInfo.abbreviatedTimeZoneStandard; for (p in n) { if (n.hasOwnProperty(p)) { if (n[p] === offset) { return p; } } } return null; }; $D.getTimezoneOffset = function (name, dst) { var i, a =[], z = Date.CultureInfo.timezones; if (!name) { name = (new Date()).getTimezone();} for (i = 0; i < z.length; i++) { if (z[i].name === name.toUpperCase()) { a.push(i); } } if (!z[a[0]]) { return null; } if (a.length === 1 || !dst) { return z[a[0]].offset; } else { for (i=0; i < a.length; i++) { if (z[a[i]].dst) { return z[a[i]].offset; } } } }; $D.getQuarter = function (d) { d = d || new Date(); // If no date supplied, use today var q = [1,2,3,4]; return q[Math.floor(d.getMonth() / 3)]; // ~~~ is a bitwise op. Faster than Math.floor }; $D.getDaysLeftInQuarter = function (d) { d = d || new Date(); var qEnd = new Date(d); qEnd.setMonth(qEnd.getMonth() + 3 - qEnd.getMonth() % 3, 0); return Math.floor((qEnd - d) / 8.64e7); }; // private var validate = function (n, min, max, name) { name = name ? name : "Object"; if (typeof n === "undefined") { return false; } else if (typeof n !== "number") { throw new TypeError(n + " is not a Number."); } else if (n < min || n > max) { // As failing validation is *not* an exceptional circumstance // lets not throw a RangeError Exception here. // It's semantically correct but it's not sensible. return false; } return true; }; /** * Validates the number is within an acceptable range for milliseconds [0-999]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateMillisecond = function (value) { return validate(value, 0, 999, "millisecond"); }; /** * Validates the number is within an acceptable range for seconds [0-59]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateSecond = function (value) { return validate(value, 0, 59, "second"); }; /** * Validates the number is within an acceptable range for minutes [0-59]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateMinute = function (value) { return validate(value, 0, 59, "minute"); }; /** * Validates the number is within an acceptable range for hours [0-23]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateHour = function (value) { return validate(value, 0, 23, "hour"); }; /** * Validates the number is within an acceptable range for the days in a month [0-MaxDaysInMonth]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateDay = function (value, year, month) { if (year === undefined || year === null || month === undefined || month === null) { return false;} return validate(value, 1, $D.getDaysInMonth(year, month), "day"); }; /** * Validates the number is within an acceptable range for months [0-11]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateWeek = function (value) { return validate(value, 0, 53, "week"); }; /** * Validates the number is within an acceptable range for months [0-11]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateMonth = function (value) { return validate(value, 0, 11, "month"); }; /** * Validates the number is within an acceptable range for years. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateYear = function (value) { /** * Per ECMAScript spec the range of times supported by Date objects is * exactly -100,000,000 days to +100,000,000 days measured relative to * midnight at the beginning of 01 January, 1970 UTC. * This gives a range of 8,640,000,000,000,000 milliseconds to either * side of 01 January, 1970 UTC. * * Earliest possible date: Tue, 20 Apr 271,822 B.C. 00:00:00 UTC * Latest possible date: Sat, 13 Sep 275,760 00:00:00 UTC */ return validate(value, -271822, 275760, "year"); }; $D.validateTimezone = function(value) { var timezones = {"ACDT":1,"ACST":1,"ACT":1,"ADT":1,"AEDT":1,"AEST":1,"AFT":1,"AKDT":1,"AKST":1,"AMST":1,"AMT":1,"ART":1,"AST":1,"AWDT":1,"AWST":1,"AZOST":1,"AZT":1,"BDT":1,"BIOT":1,"BIT":1,"BOT":1,"BRT":1,"BST":1,"BTT":1,"CAT":1,"CCT":1,"CDT":1,"CEDT":1,"CEST":1,"CET":1,"CHADT":1,"CHAST":1,"CHOT":1,"ChST":1,"CHUT":1,"CIST":1,"CIT":1,"CKT":1,"CLST":1,"CLT":1,"COST":1,"COT":1,"CST":1,"CT":1,"CVT":1,"CWST":1,"CXT":1,"DAVT":1,"DDUT":1,"DFT":1,"EASST":1,"EAST":1,"EAT":1,"ECT":1,"EDT":1,"EEDT":1,"EEST":1,"EET":1,"EGST":1,"EGT":1,"EIT":1,"EST":1,"FET":1,"FJT":1,"FKST":1,"FKT":1,"FNT":1,"GALT":1,"GAMT":1,"GET":1,"GFT":1,"GILT":1,"GIT":1,"GMT":1,"GST":1,"GYT":1,"HADT":1,"HAEC":1,"HAST":1,"HKT":1,"HMT":1,"HOVT":1,"HST":1,"ICT":1,"IDT":1,"IOT":1,"IRDT":1,"IRKT":1,"IRST":1,"IST":1,"JST":1,"KGT":1,"KOST":1,"KRAT":1,"KST":1,"LHST":1,"LINT":1,"MAGT":1,"MART":1,"MAWT":1,"MDT":1,"MET":1,"MEST":1,"MHT":1,"MIST":1,"MIT":1,"MMT":1,"MSK":1,"MST":1,"MUT":1,"MVT":1,"MYT":1,"NCT":1,"NDT":1,"NFT":1,"NPT":1,"NST":1,"NT":1,"NUT":1,"NZDT":1,"NZST":1,"OMST":1,"ORAT":1,"PDT":1,"PET":1,"PETT":1,"PGT":1,"PHOT":1,"PHT":1,"PKT":1,"PMDT":1,"PMST":1,"PONT":1,"PST":1,"PYST":1,"PYT":1,"RET":1,"ROTT":1,"SAKT":1,"SAMT":1,"SAST":1,"SBT":1,"SCT":1,"SGT":1,"SLST":1,"SRT":1,"SST":1,"SYOT":1,"TAHT":1,"THA":1,"TFT":1,"TJT":1,"TKT":1,"TLT":1,"TMT":1,"TOT":1,"TVT":1,"UCT":1,"ULAT":1,"UTC":1,"UYST":1,"UYT":1,"UZT":1,"VET":1,"VLAT":1,"VOLT":1,"VOST":1,"VUT":1,"WAKT":1,"WAST":1,"WAT":1,"WEDT":1,"WEST":1,"WET":1,"WST":1,"YAKT":1,"YEKT":1,"Z":1}; return (timezones[value] === 1); }; $D.validateTimezoneOffset= function(value) { // timezones go from +14hrs to -12hrs, the +X hours are negative offsets. return (value > -841 && value < 721); }; }()); (function () { var $D = Date, $P = $D.prototype, p = function (s, l) { if (!l) { l = 2; } return ("000" + s).slice(l * -1); }; var validateConfigObject = function (obj) { var result = {}, self = this, prop, testFunc; testFunc = function (prop, func, value) { if (prop === "day") { var month = (obj.month !== undefined) ? obj.month : self.getMonth(); var year = (obj.year !== undefined) ? obj.year : self.getFullYear(); return $D[func](value, year, month); } else { return $D[func](value); } }; for (prop in obj) { if (Object.prototype.hasOwnProperty.call(obj, prop)) { var func = "validate" + prop.charAt(0).toUpperCase() + prop.slice(1); if ($D[func] && obj[prop] !== null && testFunc(prop, func, obj[prop])) { result[prop] = obj[prop]; } } } return result; }; /** * Resets the time of this Date object to 12:00 AM (00:00), which is the start of the day. * @param {Boolean} .clone() this date instance before clearing Time * @return {Date} this */ $P.clearTime = function () { this.setHours(0); this.setMinutes(0); this.setSeconds(0); this.setMilliseconds(0); return this; }; /** * Resets the time of this Date object to the current time ('now'). * @return {Date} this */ $P.setTimeToNow = function () { var n = new Date(); this.setHours(n.getHours()); this.setMinutes(n.getMinutes()); this.setSeconds(n.getSeconds()); this.setMilliseconds(n.getMilliseconds()); return this; }; /** * Returns a new Date object that is an exact date and time copy of the original instance. * @return {Date} A new Date instance */ $P.clone = function () { return new Date(this.getTime()); }; /** * Compares this instance to a Date object and returns an number indication of their relative values. * @param {Date} Date object to compare [Required] * @return {Number} -1 = this is lessthan date. 0 = values are equal. 1 = this is greaterthan date. */ $P.compareTo = function (date) { return Date.compare(this, date); }; /** * Compares this instance to another Date object and returns true if they are equal. * @param {Date} Date object to compare. If no date to compare, new Date() [now] is used. * @return {Boolean} true if dates are equal. false if they are not equal. */ $P.equals = function (date) { return Date.equals(this, (date !== undefined ? date : new Date())); }; /** * Determines if this instance is between a range of two dates or equal to either the start or end dates. * @param {Date} Start of range [Required] * @param {Date} End of range [Required] * @return {Boolean} true is this is between or equal to the start and end dates, else false */ $P.between = function (start, end) { return this.getTime() >= start.getTime() && this.getTime() <= end.getTime(); }; /** * Determines if this date occurs after the date to compare to. * @param {Date} Date object to compare. If no date to compare, new Date() ("now") is used. * @return {Boolean} true if this date instance is greater than the date to compare to (or "now"), otherwise false. */ $P.isAfter = function (date) { return this.compareTo(date || new Date()) === 1; }; /** * Determines if this date occurs before the date to compare to. * @param {Date} Date object to compare. If no date to compare, new Date() ("now") is used. * @return {Boolean} true if this date instance is less than the date to compare to (or "now"). */ $P.isBefore = function (date) { return (this.compareTo(date || new Date()) === -1); }; /** * Determines if the current Date instance occurs today. * @return {Boolean} true if this date instance is 'today', otherwise false. */ /** * Determines if the current Date instance occurs on the same Date as the supplied 'date'. * If no 'date' to compare to is provided, the current Date instance is compared to 'today'. * @param {date} Date object to compare. If no date to compare, the current Date ("now") is used. * @return {Boolean} true if this Date instance occurs on the same Day as the supplied 'date'. */ $P.isToday = $P.isSameDay = function (date) { return this.clone().clearTime().equals((date || new Date()).clone().clearTime()); }; /** * Adds the specified number of milliseconds to this instance. * @param {Number} The number of milliseconds to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addMilliseconds = function (value) { if (!value) { return this; } this.setTime(this.getTime() + value * 1); return this; }; /** * Adds the specified number of seconds to this instance. * @param {Number} The number of seconds to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addSeconds = function (value) { if (!value) { return this; } return this.addMilliseconds(value * 1000); }; /** * Adds the specified number of seconds to this instance. * @param {Number} The number of seconds to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addMinutes = function (value) { if (!value) { return this; } return this.addMilliseconds(value * 60000); // 60*1000 }; /** * Adds the specified number of hours to this instance. * @param {Number} The number of hours to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addHours = function (value) { if (!value) { return this; } return this.addMilliseconds(value * 3600000); // 60*60*1000 }; /** * Adds the specified number of days to this instance. * @param {Number} The number of days to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addDays = function (value) { if (!value) { return this; } this.setDate(this.getDate() + value * 1); return this; }; /** * Adds the specified number of weekdays (ie - not sat or sun) to this instance. * @param {Number} The number of days to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addWeekdays = function (value) { if (!value) { return this; } var day = this.getDay(); var weeks = (Math.ceil(Math.abs(value)/7)); if (day === 0 || day === 6) { if (value > 0) { this.next().monday(); this.addDays(-1); day = this.getDay(); } } if (value < 0) { while (value < 0) { this.addDays(-1); day = this.getDay(); if (day !== 0 && day !== 6) { value++; } } return this; } else if (value > 5 || (6-day) <= value) { value = value + (weeks * 2); } return this.addDays(value); }; /** * Adds the specified number of weeks to this instance. * @param {Number} The number of weeks to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addWeeks = function (value) { if (!value) { return this; } return this.addDays(value * 7); }; /** * Adds the specified number of months to this instance. * @param {Number} The number of months to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addMonths = function (value) { if (!value) { return this; } var n = this.getDate(); this.setDate(1); this.setMonth(this.getMonth() + value * 1); this.setDate(Math.min(n, $D.getDaysInMonth(this.getFullYear(), this.getMonth()))); return this; }; $P.addQuarters = function (value) { if (!value) { return this; } // note this will take you to the same point in the quarter as you are now. // i.e. - if you are 15 days into the quarter you'll be 15 days into the resulting one. // bonus: this allows adding fractional quarters return this.addMonths(value * 3); }; /** * Adds the specified number of years to this instance. * @param {Number} The number of years to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addYears = function (value) { if (!value) { return this; } return this.addMonths(value * 12); }; /** * Adds (or subtracts) to the value of the years, months, weeks, days, hours, minutes, seconds, milliseconds of the date instance using given configuration object. Positive and Negative values allowed. * Example

	Date.today().add( { days: 1, months: 1 } )

	new Date().add( { years: -1 } )
	
* @param {Object} Configuration object containing attributes (months, days, etc.) * @return {Date} this */ $P.add = function (config) { if (typeof config === "number") { this._orient = config; return this; } var x = config; if (x.day) { // If we should be a different date than today (eg: for 'tomorrow -1d', etc). // Should only effect parsing, not direct usage (eg, Finish and FinishExact) if ((x.day - this.getDate()) !== 0) { this.setDate(x.day); } } if (x.milliseconds) { this.addMilliseconds(x.milliseconds); } if (x.seconds) { this.addSeconds(x.seconds); } if (x.minutes) { this.addMinutes(x.minutes); } if (x.hours) { this.addHours(x.hours); } if (x.weeks) { this.addWeeks(x.weeks); } if (x.months) { this.addMonths(x.months); } if (x.years) { this.addYears(x.years); } if (x.days) { this.addDays(x.days); } return this; }; /** * Get the week number. Week one (1) is the week which contains the first Thursday of the year. Monday is considered the first day of the week. * The .getWeek() function does NOT convert the date to UTC. The local datetime is used. * Please use .getISOWeek() to get the week of the UTC converted date. * @return {Number} 1 to 53 */ $P.getWeek = function (utc) { // Create a copy of this date object var self, target = new Date(this.valueOf()); if (utc) { target.addMinutes(target.getTimezoneOffset()); self = target.clone(); } else { self = this; } // ISO week date weeks start on monday // so correct the day number var dayNr = (self.getDay() + 6) % 7; // ISO 8601 states that week 1 is the week // with the first thursday of that year. // Set the target date to the thursday in the target week target.setDate(target.getDate() - dayNr + 3); // Store the millisecond value of the target date var firstThursday = target.valueOf(); // Set the target to the first thursday of the year // First set the target to january first target.setMonth(0, 1); // Not a thursday? Correct the date to the next thursday if (target.getDay() !== 4) { target.setMonth(0, 1 + ((4 - target.getDay()) + 7) % 7); } // The weeknumber is the number of weeks between the // first thursday of the year and the thursday in the target week return 1 + Math.ceil((firstThursday - target) / 604800000); // 604800000 = 7 * 24 * 3600 * 1000 }; /** * Get the ISO 8601 week number. Week one ("01") is the week which contains the first Thursday of the year. Monday is considered the first day of the week. * The .getISOWeek() function does convert the date to it's UTC value. Please use .getWeek() to get the week of the local date. * @return {String} "01" to "53" */ $P.getISOWeek = function () { return p(this.getWeek(true)); }; /** * Moves the date to Monday of the week set. Week one (1) is the week which contains the first Thursday of the year. * @param {Number} A Number (1 to 53) that represents the week of the year. * @return {Date} this */ $P.setWeek = function (n) { if ((n - this.getWeek()) === 0) { if (this.getDay() !== 1) { return this.moveToDayOfWeek(1, (this.getDay() > 1 ? -1 : 1)); } else { return this; } } else { return this.moveToDayOfWeek(1, (this.getDay() > 1 ? -1 : 1)).addWeeks(n - this.getWeek()); } }; $P.setQuarter = function (qtr) { var month = Math.abs(((qtr-1) * 3) + 1); return this.setMonth(month, 1); }; $P.getQuarter = function () { return Date.getQuarter(this); }; $P.getDaysLeftInQuarter = function () { return Date.getDaysLeftInQuarter(this); }; /** * Moves the date to the next n'th occurrence of the dayOfWeek starting from the beginning of the month. The number (-1) is a magic number and will return the last occurrence of the dayOfWeek in the month. * @param {Number} The dayOfWeek to move to * @param {Number} The n'th occurrence to move to. Use (-1) to return the last occurrence in the month * @return {Date} this */ $P.moveToNthOccurrence = function (dayOfWeek, occurrence) { if (dayOfWeek === "Weekday") { if (occurrence > 0) { this.moveToFirstDayOfMonth(); if (this.is().weekday()) { occurrence -= 1; } } else if (occurrence < 0) { this.moveToLastDayOfMonth(); if (this.is().weekday()) { occurrence += 1; } } else { return this; } return this.addWeekdays(occurrence); } var shift = 0; if (occurrence > 0) { shift = occurrence - 1; } else if (occurrence === -1) { this.moveToLastDayOfMonth(); if (this.getDay() !== dayOfWeek) { this.moveToDayOfWeek(dayOfWeek, -1); } return this; } return this.moveToFirstDayOfMonth().addDays(-1).moveToDayOfWeek(dayOfWeek, +1).addWeeks(shift); }; var moveToN = function (getFunc, addFunc, nVal) { return function (value, orient) { var diff = (value - this[getFunc]() + nVal * (orient || +1)) % nVal; return this[addFunc]((diff === 0) ? diff += nVal * (orient || +1) : diff); }; }; /** * Move to the next or last dayOfWeek based on the orient value. * @param {Number} The dayOfWeek to move to * @param {Number} Forward (+1) or Back (-1). Defaults to +1. [Optional] * @return {Date} this */ $P.moveToDayOfWeek = moveToN("getDay", "addDays", 7); /** * Move to the next or last month based on the orient value. * @param {Number} The month to move to. 0 = January, 11 = December * @param {Number} Forward (+1) or Back (-1). Defaults to +1. [Optional] * @return {Date} this */ $P.moveToMonth = moveToN("getMonth", "addMonths", 12); /** * Get the Ordinate of the current day ("th", "st", "rd"). * @return {String} */ $P.getOrdinate = function () { var num = this.getDate(); return ord(num); }; /** * Get the Ordinal day (numeric day number) of the year, adjusted for leap year. * @return {Number} 1 through 365 (366 in leap years) */ $P.getOrdinalNumber = function () { return Math.ceil((this.clone().clearTime() - new Date(this.getFullYear(), 0, 1)) / 86400000) + 1; }; /** * Get the time zone abbreviation of the current date. * @return {String} The abbreviated time zone name (e.g. "EST") */ $P.getTimezone = function () { return $D.getTimezoneAbbreviation(this.getUTCOffset(), this.isDaylightSavingTime()); }; $P.setTimezoneOffset = function (offset) { var here = this.getTimezoneOffset(), there = Number(offset) * -6 / 10; return (there || there === 0) ? this.addMinutes(there - here) : this; }; $P.setTimezone = function (offset) { return this.setTimezoneOffset($D.getTimezoneOffset(offset)); }; /** * Indicates whether Daylight Saving Time is observed in the current time zone. * @return {Boolean} true|false */ $P.hasDaylightSavingTime = function () { return (Date.today().set({month: 0, day: 1}).getTimezoneOffset() !== Date.today().set({month: 6, day: 1}).getTimezoneOffset()); }; /** * Indicates whether this Date instance is within the Daylight Saving Time range for the current time zone. * @return {Boolean} true|false */ $P.isDaylightSavingTime = function () { return Date.today().set({month: 0, day: 1}).getTimezoneOffset() !== this.getTimezoneOffset(); }; /** * Get the offset from UTC of the current date. * @return {String} The 4-character offset string prefixed with + or - (e.g. "-0500") */ $P.getUTCOffset = function (offset) { var n = (offset || this.getTimezoneOffset()) * -10 / 6, r; if (n < 0) { r = (n - 10000).toString(); return r.charAt(0) + r.substr(2); } else { r = (n + 10000).toString(); return "+" + r.substr(1); } }; /** * Returns the number of milliseconds between this date and date. * @param {Date} Defaults to now * @return {Number} The diff in milliseconds */ $P.getElapsed = function (date) { return (date || new Date()) - this; }; /** * Set the value of year, month, day, hour, minute, second, millisecond of date instance using given configuration object. * Example

	Date.today().set( { day: 20, month: 1 } )

	new Date().set( { millisecond: 0 } )
	
* * @param {Object} Configuration object containing attributes (month, day, etc.) * @return {Date} this */ $P.set = function (config) { config = validateConfigObject.call(this, config); var key; for (key in config) { if (Object.prototype.hasOwnProperty.call(config, key)) { var name = key.charAt(0).toUpperCase() + key.slice(1); var addFunc, getFunc; if (key !== "week" && key !== "month" && key !== "timezone" && key !== "timezoneOffset") { name += "s"; } addFunc = "add" + name; getFunc = "get" + name; if (key === "month") { addFunc = addFunc + "s"; } else if (key === "year"){ getFunc = "getFullYear"; } if (key !== "day" && key !== "timezone" && key !== "timezoneOffset" && key !== "week" && key !== "hour") { this[addFunc](config[key] - this[getFunc]()); } else if ( key === "timezone"|| key === "timezoneOffset" || key === "week" || key === "hour") { this["set"+name](config[key]); } } } // day has to go last because you can't validate the day without first knowing the month if (config.day) { this.addDays(config.day - this.getDate()); } return this; }; /** * Moves the date to the first day of the month. * @return {Date} this */ $P.moveToFirstDayOfMonth = function () { return this.set({ day: 1 }); }; /** * Moves the date to the last day of the month. * @return {Date} this */ $P.moveToLastDayOfMonth = function () { return this.set({ day: $D.getDaysInMonth(this.getFullYear(), this.getMonth())}); }; /** * Converts the value of the current Date object to its equivalent string representation. * Format Specifiers * CUSTOM DATE AND TIME FORMAT STRINGS * Format Description Example * ------ --------------------------------------------------------------------------- ----------------------- * s The seconds of the minute between 0-59. "0" to "59" * ss The seconds of the minute with leading zero if required. "00" to "59" * * m The minute of the hour between 0-59. "0" or "59" * mm The minute of the hour with leading zero if required. "00" or "59" * * h The hour of the day between 1-12. "1" to "12" * hh The hour of the day with leading zero if required. "01" to "12" * * H The hour of the day between 0-23. "0" to "23" * HH The hour of the day with leading zero if required. "00" to "23" * * d The day of the month between 1 and 31. "1" to "31" * dd The day of the month with leading zero if required. "01" to "31" * ddd Abbreviated day name. Date.CultureInfo.abbreviatedDayNames. "Mon" to "Sun" * dddd The full day name. Date.CultureInfo.dayNames. "Monday" to "Sunday" * * M The month of the year between 1-12. "1" to "12" * MM The month of the year with leading zero if required. "01" to "12" * MMM Abbreviated month name. Date.CultureInfo.abbreviatedMonthNames. "Jan" to "Dec" * MMMM The full month name. Date.CultureInfo.monthNames. "January" to "December" * * yy The year as a two-digit number. "99" or "08" * yyyy The full four digit year. "1999" or "2008" * * t Displays the first character of the A.M./P.M. designator. "A" or "P" * Date.CultureInfo.amDesignator or Date.CultureInfo.pmDesignator * tt Displays the A.M./P.M. designator. "AM" or "PM" * Date.CultureInfo.amDesignator or Date.CultureInfo.pmDesignator * * S The ordinal suffix ("st, "nd", "rd" or "th") of the current day. "st, "nd", "rd" or "th" * * STANDARD DATE AND TIME FORMAT STRINGS * Format Description Example *------ --------------------------------------------------------------------------- ----------------------- * d The CultureInfo shortDate Format Pattern "M/d/yyyy" * D The CultureInfo longDate Format Pattern "dddd, MMMM dd, yyyy" * F The CultureInfo fullDateTime Format Pattern "dddd, MMMM dd, yyyy h:mm:ss tt" * m The CultureInfo monthDay Format Pattern "MMMM dd" * r The CultureInfo rfc1123 Format Pattern "ddd, dd MMM yyyy HH:mm:ss GMT" * s The CultureInfo sortableDateTime Format Pattern "yyyy-MM-ddTHH:mm:ss" * t The CultureInfo shortTime Format Pattern "h:mm tt" * T The CultureInfo longTime Format Pattern "h:mm:ss tt" * u The CultureInfo universalSortableDateTime Format Pattern "yyyy-MM-dd HH:mm:ssZ" * y The CultureInfo yearMonth Format Pattern "MMMM, yyyy" * * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @return {String} A string representation of the current Date object. */ var ord = function (n) { switch (n * 1) { case 1: case 21: case 31: return "st"; case 2: case 22: return "nd"; case 3: case 23: return "rd"; default: return "th"; } }; var parseStandardFormats = function (format) { var y, c = Date.CultureInfo.formatPatterns; switch (format) { case "d": return this.toString(c.shortDate); case "D": return this.toString(c.longDate); case "F": return this.toString(c.fullDateTime); case "m": return this.toString(c.monthDay); case "r": case "R": y = this.clone().addMinutes(this.getTimezoneOffset()); return y.toString(c.rfc1123) + " GMT"; case "s": return this.toString(c.sortableDateTime); case "t": return this.toString(c.shortTime); case "T": return this.toString(c.longTime); case "u": y = this.clone().addMinutes(this.getTimezoneOffset()); return y.toString(c.universalSortableDateTime); case "y": return this.toString(c.yearMonth); default: return false; } }; var parseFormatStringsClosure = function (context) { return function (m) { if (m.charAt(0) === "\\") { return m.replace("\\", ""); } switch (m) { case "hh": return p(context.getHours() < 13 ? (context.getHours() === 0 ? 12 : context.getHours()) : (context.getHours() - 12)); case "h": return context.getHours() < 13 ? (context.getHours() === 0 ? 12 : context.getHours()) : (context.getHours() - 12); case "HH": return p(context.getHours()); case "H": return context.getHours(); case "mm": return p(context.getMinutes()); case "m": return context.getMinutes(); case "ss": return p(context.getSeconds()); case "s": return context.getSeconds(); case "yyyy": return p(context.getFullYear(), 4); case "yy": return p(context.getFullYear()); case "y": return context.getFullYear(); case "E": case "dddd": return Date.CultureInfo.dayNames[context.getDay()]; case "ddd": return Date.CultureInfo.abbreviatedDayNames[context.getDay()]; case "dd": return p(context.getDate()); case "d": return context.getDate(); case "MMMM": return Date.CultureInfo.monthNames[context.getMonth()]; case "MMM": return Date.CultureInfo.abbreviatedMonthNames[context.getMonth()]; case "MM": return p((context.getMonth() + 1)); case "M": return context.getMonth() + 1; case "t": return context.getHours() < 12 ? Date.CultureInfo.amDesignator.substring(0, 1) : Date.CultureInfo.pmDesignator.substring(0, 1); case "tt": return context.getHours() < 12 ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator; case "S": return ord(context.getDate()); case "W": return context.getWeek(); case "WW": return context.getISOWeek(); case "Q": return "Q" + context.getQuarter(); case "q": return String(context.getQuarter()); case "z": return context.getTimezone(); case "Z": case "X": return Date.getTimezoneOffset(context.getTimezone()); case "ZZ": // Timezone offset in seconds return context.getTimezoneOffset() * -60; case "u": return context.getDay(); case "L": return ($D.isLeapYear(context.getFullYear())) ? 1 : 0; case "B": // Swatch Internet Time (.beats) return "@"+((context.getUTCSeconds() + (context.getUTCMinutes()*60) + ((context.getUTCHours()+1)*3600))/86.4); default: return m; } }; }; $P.toString = function (format, ignoreStandards) { // Standard Date and Time Format Strings. Formats pulled from CultureInfo file and // may vary by culture. if (!ignoreStandards && format && format.length === 1) { output = parseStandardFormats.call(this, format); if (output) { return output; } } var parseFormatStrings = parseFormatStringsClosure(this); return format ? format.replace(/((\\)?(dd?d?d?|MM?M?M?|yy?y?y?|hh?|HH?|mm?|ss?|tt?|S|q|Q|WW?W?W?)(?![^\[]*\]))/g, parseFormatStrings).replace(/\[|\]/g, "") : this._toString(); }; }()); /************************************************************* * SugarPak - Domain Specific Language - Syntactical Sugar * *************************************************************/ (function () { var $D = Date, $P = $D.prototype, $N = Number.prototype; // private $P._orient = +1; // private $P._nth = null; // private $P._is = false; // private $P._same = false; // private $P._isSecond = false; // private $N._dateElement = "days"; /** * Moves the date to the next instance of a date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.today().next().friday();
	Date.today().next().fri();
	Date.today().next().march();
	Date.today().next().mar();
	Date.today().next().week();
	
* * @return {Date} date */ $P.next = function () { this._move = true; this._orient = +1; return this; }; /** * Creates a new Date (Date.today()) and moves the date to the next instance of the date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.next().friday();
	Date.next().fri();
	Date.next().march();
	Date.next().mar();
	Date.next().week();
	
* * @return {Date} date */ $D.next = function () { return $D.today().next(); }; /** * Moves the date to the previous instance of a date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.today().last().friday();
	Date.today().last().fri();
	Date.today().last().march();
	Date.today().last().mar();
	Date.today().last().week();
	
* * @return {Date} date */ $P.last = $P.prev = $P.previous = function () { this._move = true; this._orient = -1; return this; }; /** * Creates a new Date (Date.today()) and moves the date to the previous instance of the date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.last().friday();
	Date.last().fri();
	Date.previous().march();
	Date.prev().mar();
	Date.last().week();
	
* * @return {Date} date */ $D.last = $D.prev = $D.previous = function () { return $D.today().last(); }; /** * Performs a equality check when followed by either a month name, day name or .weekday() function. * Example

	Date.today().is().friday(); // true|false
	Date.today().is().fri();
	Date.today().is().march();
	Date.today().is().mar();
	
* * @return {Boolean} true|false */ $P.is = function () { this._is = true; return this; }; /** * Determines if two date objects occur on/in exactly the same instance of the subsequent date part function. * The function .same() must be followed by a date part function (example: .day(), .month(), .year(), etc). * * An optional Date can be passed in the date part function. If now date is passed as a parameter, 'Now' is used. * * The following example demonstrates how to determine if two dates fall on the exact same day. * * Example

	var d1 = Date.today(); // today at 00:00
	var d2 = new Date();   // exactly now.

	// Do they occur on the same day?
	d1.same().day(d2); // true
	
	// Do they occur on the same hour?
	d1.same().hour(d2); // false, unless d2 hour is '00' (midnight).
	
	// What if it's the same day, but one year apart?
	var nextYear = Date.today().add(1).year();

	d1.same().day(nextYear); // false, because the dates must occur on the exact same day. 
	
* * Scenario: Determine if a given date occurs during some week period 2 months from now. * * Example

	var future = Date.today().add(2).months();
	return someDate.same().week(future); // true|false;
	
* * @return {Boolean} true|false */ $P.same = function () { this._same = true; this._isSecond = false; return this; }; /** * Determines if the current date/time occurs during Today. Must be preceded by the .is() function. * Example

	someDate.is().today();    // true|false
	new Date().is().today();  // true
	Date.today().is().today();// true
	Date.today().add(-1).day().is().today(); // false
	
* * @return {Boolean} true|false */ $P.today = function () { return this.same().day(); }; /** * Determines if the current date is a weekday. This function must be preceded by the .is() function. * Example

	Date.today().is().weekday(); // true|false
	
* * @return {Boolean} true|false */ $P.weekday = function () { if (this._nth) { return df("Weekday").call(this); } if (this._move) { return this.addWeekdays(this._orient); } if (this._is) { this._is = false; return (!this.is().sat() && !this.is().sun()); } return false; }; /** * Determines if the current date is on the weekend. This function must be preceded by the .is() function. * Example

	Date.today().is().weekend(); // true|false
	
* * @return {Boolean} true|false */ $P.weekend = function () { if (this._is) { this._is = false; return (this.is().sat() || this.is().sun()); } return false; }; /** * Sets the Time of the current Date instance. A string "6:15 pm" or config object {hour:18, minute:15} are accepted. * Example

	// Set time to 6:15pm with a String
	Date.today().at("6:15pm");

	// Set time to 6:15pm with a config object
	Date.today().at({hour:18, minute:15});
	
* * @return {Date} date */ $P.at = function (time) { return (typeof time === "string") ? $D.parse(this.toString("d") + " " + time) : this.set(time); }; /** * Creates a new Date() and adds this (Number) to the date based on the preceding date element function (eg. second|minute|hour|day|month|year). * Example

	// Undeclared Numbers must be wrapped with parentheses. Requirment of JavaScript.
	(3).days().fromNow();
	(6).months().fromNow();

	// Declared Number variables do not require parentheses. 
	var n = 6;
	n.months().fromNow();
	
* * @return {Date} A new Date instance */ $N.fromNow = $N.after = function (date) { var c = {}; c[this._dateElement] = this; return ((!date) ? new Date() : date.clone()).add(c); }; /** * Creates a new Date() and subtract this (Number) from the date based on the preceding date element function (eg. second|minute|hour|day|month|year). * Example

	// Undeclared Numbers must be wrapped with parentheses. Requirment of JavaScript.
	(3).days().ago();
	(6).months().ago();

	// Declared Number variables do not require parentheses. 
	var n = 6;
	n.months().ago();
	
* * @return {Date} A new Date instance */ $N.ago = $N.before = function (date) { var c = {}, s = (this._dateElement[this._dateElement.length-1] !== "s") ? this._dateElement + "s" : this._dateElement; c[s] = this * -1; return ((!date) ? new Date() : date.clone()).add(c); }; // Do NOT modify the following string tokens. These tokens are used to build dynamic functions. // All culture-specific strings can be found in the CultureInfo files. var dx = ("sunday monday tuesday wednesday thursday friday saturday").split(/\s/), mx = ("january february march april may june july august september october november december").split(/\s/), px = ("Millisecond Second Minute Hour Day Week Month Year Quarter Weekday").split(/\s/), pxf = ("Milliseconds Seconds Minutes Hours Date Week Month FullYear Quarter").split(/\s/), nth = ("final first second third fourth fifth").split(/\s/), de; /** * Returns an object literal of all the date parts. * Example

	var o = new Date().toObject();
	
	// { year: 2008, month: 4, week: 20, day: 13, hour: 18, minute: 9, second: 32, millisecond: 812 }
	
	// The object properties can be referenced directly from the object.
	
	alert(o.day);  // alerts "13"
	alert(o.year); // alerts "2008"
	
* * @return {Date} An object literal representing the original date object. */ $P.toObject = function () { var o = {}; for (var i = 0; i < px.length; i++) { if (this["get" + pxf[i]]) { o[px[i].toLowerCase()] = this["get" + pxf[i]](); } } return o; }; /** * Returns a date created from an object literal. Ignores the .week property if set in the config. * Example

	var o = new Date().toObject();
	
	return Date.fromObject(o); // will return the same date. 

	var o2 = {month: 1, day: 20, hour: 18}; // birthday party!
	Date.fromObject(o2);
	
* * @return {Date} An object literal representing the original date object. */ $D.fromObject = function(config) { config.week = null; return Date.today().set(config); }; // Create day name functions and abbreviated day name functions (eg. monday(), friday(), fri()). var df = function (n) { return function () { if (this._is) { this._is = false; return this.getDay() === n; } if (this._move) { this._move = null; } if (this._nth !== null) { // If the .second() function was called earlier, remove the _orient // from the date, and then continue. // This is required because 'second' can be used in two different context. // // Example // // Date.today().add(1).second(); // Date.march().second().monday(); // // Things get crazy with the following... // Date.march().add(1).second().second().monday(); // but it works!! // if (this._isSecond) { this.addSeconds(this._orient * -1); } // make sure we reset _isSecond this._isSecond = false; var ntemp = this._nth; this._nth = null; var temp = this.clone().moveToLastDayOfMonth(); this.moveToNthOccurrence(n, ntemp); if (this > temp) { throw new RangeError($D.getDayName(n) + " does not occur " + ntemp + " times in the month of " + $D.getMonthName(temp.getMonth()) + " " + temp.getFullYear() + "."); } return this; } return this.moveToDayOfWeek(n, this._orient); }; }; var sdf = function (n) { return function () { var t = $D.today(), shift = n - t.getDay(); if (n === 0 && Date.CultureInfo.firstDayOfWeek === 1 && t.getDay() !== 0) { shift = shift + 7; } return t.addDays(shift); }; }; // Create month name functions and abbreviated month name functions (eg. january(), march(), mar()). var month_instance_functions = function (n) { return function () { if (this._is) { this._is = false; return this.getMonth() === n; } return this.moveToMonth(n, this._orient); }; }; var month_static_functions = function (n) { return function () { return $D.today().set({ month: n, day: 1 }); }; }; var processTerms = function (names, staticFunc, instanceFunc) { for (var i = 0; i < names.length; i++) { // Create constant static Name variables. $D[names[i].toUpperCase()] = $D[names[i].toUpperCase().substring(0, 3)] = i; // Create Name functions. $D[names[i]] = $D[names[i].substring(0, 3)] = staticFunc(i); // Create Name instance functions. $P[names[i]] = $P[names[i].substring(0, 3)] = instanceFunc(i); } }; processTerms(dx, sdf, df); processTerms(mx, month_static_functions, month_instance_functions); // Create date element functions and plural date element functions used with Date (eg. day(), days(), months()). var ef = function (j) { return function () { // if the .second() function was called earlier, the _orient // has alread been added. Just return this and reset _isSecond. if (this._isSecond) { this._isSecond = false; return this; } if (this._same) { this._same = this._is = false; var o1 = this.toObject(), o2 = (arguments[0] || new Date()).toObject(), v = "", k = j.toLowerCase(); // the substr trick with -1 doesn't work in IE8 or less k = (k[k.length-1] === "s") ? k.substring(0,k.length-1) : k; for (var m = (px.length - 1); m > -1; m--) { v = px[m].toLowerCase(); if (o1[v] !== o2[v]) { return false; } if (k === v) { break; } } return true; } if (j.substring(j.length - 1) !== "s") { j += "s"; } if (this._move) { this._move = null; } return this["add" + j](this._orient); }; }; var nf = function (n) { return function () { this._dateElement = n; return this; }; }; for (var k = 0; k < px.length; k++) { de = px[k].toLowerCase(); if(de !== "weekday") { // Create date element functions and plural date element functions used with Date (eg. day(), days(), months()). $P[de] = $P[de + "s"] = ef(px[k]); // Create date element functions and plural date element functions used with Number (eg. day(), days(), months()). $N[de] = $N[de + "s"] = nf(de + "s"); } } $P._ss = ef("Second"); var nthfn = function (n) { return function (dayOfWeek) { if (this._same) { return this._ss(arguments[0]); } if (dayOfWeek || dayOfWeek === 0) { return this.moveToNthOccurrence(dayOfWeek, n); } this._nth = n; // if the operator is 'second' add the _orient, then deal with it later... if (n === 2 && (dayOfWeek === undefined || dayOfWeek === null)) { this._isSecond = true; return this.addSeconds(this._orient); } return this; }; }; for (var l = 0; l < nth.length; l++) { $P[nth[l]] = (l === 0) ? nthfn(-1) : nthfn(l); } }()); (function () { "use strict"; Date.Parsing = { Exception: function (s) { this.message = "Parse error at '" + s.substring(0, 10) + " ...'"; } }; var $P = Date.Parsing; var dayOffsets = { standard: [0,31,59,90,120,151,181,212,243,273,304,334], leap: [0,31,60,91,121,152,182,213,244,274,305,335] }; $P.isLeapYear = function(year) { return ((year % 4 === 0) && (year % 100 !== 0)) || (year % 400 === 0); }; var utils = { multiReplace : function (str, hash ) { var key; for (key in hash) { if (Object.prototype.hasOwnProperty.call(hash, key)) { var regex; if (typeof hash[key] === "function") { } else { regex = (hash[key] instanceof RegExp) ? hash[key] : new RegExp(hash[key], "g"); } str = str.replace(regex, key); } } return str; }, getDayOfYearFromWeek : function (obj) { var d, jan4, offset; obj.weekDay = (!obj.weekDay && obj.weekDay !== 0) ? 1 : obj.weekDay; d = new Date(obj.year, 0, 4); jan4 = d.getDay() === 0 ? 7 : d.getDay(); // JS is 0 indexed on Sunday. offset = jan4+3; obj.dayOfYear = ((obj.week * 7) + (obj.weekDay === 0 ? 7 : obj.weekDay))-offset; return obj; }, getDayOfYear : function (obj, dayOffset) { if (!obj.dayOfYear) { obj = utils.getDayOfYearFromWeek(obj); } for (var i=0;i <= dayOffset.length;i++) { if (obj.dayOfYear < dayOffset[i] || i === dayOffset.length) { obj.day = obj.day ? obj.day : (obj.dayOfYear - dayOffset[i-1]); break; } else { obj.month = i; } } return obj; }, adjustForTimeZone : function (obj, date) { var offset; if (obj.zone.toUpperCase() === "Z" || (obj.zone_hours === 0 && obj.zone_minutes === 0)) { // it's UTC/GML so work out the current timeszone offset offset = -date.getTimezoneOffset(); } else { offset = (obj.zone_hours*60) + (obj.zone_minutes || 0); if (obj.zone_sign === "+") { offset *= -1; } offset -= date.getTimezoneOffset(); } date.setMinutes(date.getMinutes()+offset); return date; }, setDefaults : function (obj) { obj.year = obj.year || Date.today().getFullYear(); obj.hours = obj.hours || 0; obj.minutes = obj.minutes || 0; obj.seconds = obj.seconds || 0; obj.milliseconds = obj.milliseconds || 0; if (!(!obj.month && (obj.week || obj.dayOfYear))) { // if we have a month, or if we don't but don't have the day calculation data obj.month = obj.month || 0; obj.day = obj.day || 1; } return obj; }, dataNum: function (data, mod, explict, postProcess) { var dataNum = data*1; if (mod) { if (postProcess) { return data ? mod(data)*1 : data; } else { return data ? mod(dataNum) : data; } } else if (!explict){ return data ? dataNum : data; } else { return (data && typeof data !== "undefined") ? dataNum : data; } }, timeDataProcess: function (obj) { var timeObj = {}; for (var x in obj.data) { if (obj.data.hasOwnProperty(x)) { timeObj[x] = obj.ignore[x] ? obj.data[x] : utils.dataNum(obj.data[x], obj.mods[x], obj.explict[x], obj.postProcess[x]); } } if (obj.data.secmins) { obj.data.secmins = obj.data.secmins.replace(",", ".") * 60; if (!timeObj.minutes) { timeObj.minutes = obj.data.secmins; } else if (!timeObj.seconds) { timeObj.seconds = obj.data.secmins; } delete obj.secmins; } return timeObj; }, buildTimeObjectFromData: function (data) { var time = utils.timeDataProcess({ data: { year : data[1], month : data[5], day : data[7], week : data[8], dayOfYear : data[10], hours : data[15], zone_hours : data[23], zone_minutes : data[24], zone : data[21], zone_sign : data[22], weekDay : data[9], minutes: data[16], seconds: data[19], milliseconds: data[20], secmins: data[18] }, mods: { month: function(data) { return data-1; }, weekDay: function (data) { data = Math.abs(data); return (data === 7 ? 0 : data); }, minutes: function (data) { return data.replace(":",""); }, seconds: function (data) { return Math.floor( (data.replace(":","").replace(",","."))*1 ); }, milliseconds: function (data) { return (data.replace(",",".")*1000); } }, postProcess: { minutes: true, seconds: true, milliseconds: true }, explict: { zone_hours: true, zone_minutes: true }, ignore: { zone: true, zone_sign: true, secmins: true } }); return time; }, addToHash: function (hash, keys, data) { keys = keys; data = data; var len = keys.length; for (var i = 0; i < len; i++) { hash[keys[i]] = data[i]; } return hash; }, combineRegex: function (r1, r2) { return new RegExp("(("+r1.source+")\\s("+r2.source+"))"); }, getDateNthString: function(add, last, inc){ if (add) { return Date.today().addDays(inc).toString("d"); } else if (last) { return Date.today().last()[inc]().toString("d"); } }, buildRegexData: function (array) { var arr = []; var len = array.length; for (var i=0; i < len; i++) { if (Object.prototype.toString.call(array[i]) === '[object Array]') { // oldIE compat version of Array.isArray arr.push(this.combineRegex(array[i][0], array[i][1])); } else { arr.push(array[i]); } } return arr; } }; $P.processTimeObject = function (obj) { var date, dayOffset; utils.setDefaults(obj); dayOffset = ($P.isLeapYear(obj.year)) ? dayOffsets.leap : dayOffsets.standard; if (!obj.month && (obj.week || obj.dayOfYear)) { utils.getDayOfYear(obj, dayOffset); } else { obj.dayOfYear = dayOffset[obj.month] + obj.day; } date = new Date(obj.year, obj.month, obj.day, obj.hours, obj.minutes, obj.seconds, obj.milliseconds); if (obj.zone) { utils.adjustForTimeZone(obj, date); // adjust (and calculate) for timezone } return date; }; $P.ISO = { regex : /^([\+-]?\d{4}(?!\d{2}\b))((-?)((0[1-9]|1[0-2])(\3([12]\d|0[1-9]|3[01]))?|W([0-4]\d|5[0-3])(-?[1-7])?|(00[1-9]|0[1-9]\d|[12]\d{2}|3([0-5]\d|6[1-6])))([T\s]((([01]\d|2[0-4])((:?)[0-5]\d)?|24\:?00)([\.,]\d+(?!:))?)?(\17[0-5]\d([\.,]\d+)?)?\s?([zZ]|([\+-])([01]\d|2[0-3]):?([0-5]\d)?)?)?)?$/, parse : function (s) { var time, data = s.match(this.regex); if (!data || !data.length) { return null; } time = utils.buildTimeObjectFromData(data); if (!time.year || (!time.year && (!time.month && !time.day) && (!time.week && !time.dayOfYear)) ) { return null; } return $P.processTimeObject(time); } }; $P.Numeric = { isNumeric: function (e){return!isNaN(parseFloat(e))&&isFinite(e);}, regex: /\b([0-1]?[0-9])([0-3]?[0-9])([0-2]?[0-9]?[0-9][0-9])\b/i, parse: function (s) { var data, i, time = {}, order = Date.CultureInfo.dateElementOrder.split(""); if (!(this.isNumeric(s)) || // if it's non-numeric OR (s[0] === "+" && s[0] === "-")) { // It's an arithmatic string (eg +/-1000) return null; } if (s.length < 5 && s.indexOf(".") < 0 && s.indexOf("/") < 0) { // assume it's just a year. time.year = s; return $P.processTimeObject(time); } data = s.match(this.regex); if (!data || !data.length) { return null; } for (i=0; i < order.length; i++) { switch(order[i]) { case "d": time.day = data[i+1]; break; case "m": time.month = (data[i+1]-1); break; case "y": time.year = data[i+1]; break; } } return $P.processTimeObject(time); } }; $P.Normalizer = { regexData: function () { var $R = Date.CultureInfo.regexPatterns; return utils.buildRegexData([ $R.tomorrow, $R.yesterday, [$R.past, $R.mon], [$R.past, $R.tue], [$R.past, $R.wed], [$R.past, $R.thu], [$R.past, $R.fri], [$R.past, $R.sat], [$R.past, $R.sun] ]); }, basicReplaceHash : function() { var $R = Date.CultureInfo.regexPatterns; return { "January": $R.jan.source, "February": $R.feb, "March": $R.mar, "April": $R.apr, "May": $R.may, "June": $R.jun, "July": $R.jul, "August": $R.aug, "September": $R.sep, "October": $R.oct, "November": $R.nov, "December": $R.dec, "": /\bat\b/gi, " ": /\s{2,}/, "am": $R.inTheMorning, "9am": $R.thisMorning, "pm": $R.inTheEvening, "7pm":$R.thisEvening }; }, keys : function(){ return [ utils.getDateNthString(true, false, 1), // tomorrow utils.getDateNthString(true, false, -1), // yesterday utils.getDateNthString(false, true, "monday"), //last mon utils.getDateNthString(false, true, "tuesday"), //last tues utils.getDateNthString(false, true, "wednesday"), //last wed utils.getDateNthString(false, true, "thursday"), //last thurs utils.getDateNthString(false, true, "friday"), //last fri utils.getDateNthString(false, true, "saturday"), //last sat utils.getDateNthString(false, true, "sunday") //last sun ]; }, buildRegexFunctions: function () { var $R = Date.CultureInfo.regexPatterns; var __ = Date.i18n.__; var tomorrowRE = new RegExp("(\\b\\d\\d?("+__("AM")+"|"+__("PM")+")? )("+$R.tomorrow.source.slice(1)+")", "i"); // adapted tomorrow regex for AM PM relative dates var todayRE = new RegExp($R.today.source + "(?!\\s*([+-]))\\b"); // today, but excludes the math operators (eg "today + 2h") this.replaceFuncs = [ [todayRE, function (full) { return (full.length > 1) ? Date.today().toString("d") : full; }], [tomorrowRE, function(full, m1) { var t = Date.today().addDays(1).toString("d"); return (t + " " + m1); }], [$R.amThisMorning, function(str, am){return am;}], [$R.pmThisEvening, function(str, pm){return pm;}] ]; }, buildReplaceData: function () { this.buildRegexFunctions(); this.replaceHash = utils.addToHash(this.basicReplaceHash(), this.keys(), this.regexData()); }, stringReplaceFuncs: function (s) { for (var i=0; i < this.replaceFuncs.length; i++) { s = s.replace(this.replaceFuncs[i][0], this.replaceFuncs[i][1]); } return s; }, parse: function (s) { s = this.stringReplaceFuncs(s); s = utils.multiReplace(s, this.replaceHash); try { var n = s.split(/([\s\-\.\,\/\x27]+)/); if (n.length === 3 && $P.Numeric.isNumeric(n[0]) && $P.Numeric.isNumeric(n[2]) && (n[2].length >= 4)) { // ok, so we're dealing with x/year. But that's not a full date. // This fixes wonky dateElementOrder parsing when set to dmy order. if (Date.CultureInfo.dateElementOrder[0] === "d") { s = "1/" + n[0] + "/" + n[2]; // set to 1st of month and normalize the seperator } } } catch (e) {} return s; } }; $P.Normalizer.buildReplaceData(); }()); (function () { var $P = Date.Parsing; var _ = $P.Operators = { // // Tokenizers // rtoken: function (r) { // regex token return function (s) { var mx = s.match(r); if (mx) { return ([ mx[0], s.substring(mx[0].length) ]); } else { throw new $P.Exception(s); } }; }, token: function () { // whitespace-eating token return function (s) { return _.rtoken(new RegExp("^\\s*" + s + "\\s*"))(s); }; }, stoken: function (s) { // string token return _.rtoken(new RegExp("^" + s)); }, // Atomic Operators until: function (p) { return function (s) { var qx = [], rx = null; while (s.length) { try { rx = p.call(this, s); } catch (e) { qx.push(rx[0]); s = rx[1]; continue; } break; } return [ qx, s ]; }; }, many: function (p) { return function (s) { var rx = [], r = null; while (s.length) { try { r = p.call(this, s); } catch (e) { return [ rx, s ]; } rx.push(r[0]); s = r[1]; } return [ rx, s ]; }; }, // generator operators -- see below optional: function (p) { return function (s) { var r = null; try { r = p.call(this, s); } catch (e) { return [ null, s ]; } return [ r[0], r[1] ]; }; }, not: function (p) { return function (s) { try { p.call(this, s); } catch (e) { return [null, s]; } throw new $P.Exception(s); }; }, ignore: function (p) { return p ? function (s) { var r = null; r = p.call(this, s); return [null, r[1]]; } : null; }, product: function () { var px = arguments[0], qx = Array.prototype.slice.call(arguments, 1), rx = []; for (var i = 0 ; i < px.length ; i++) { rx.push(_.each(px[i], qx)); } return rx; }, cache: function (rule) { var cache = {}, cache_length = 0, cache_keys = [], CACHE_MAX = Date.Config.CACHE_MAX || 100000, r = null; var cacheCheck = function () { if (cache_length === CACHE_MAX) { // kill several keys, don't want to have to do this all the time... for (var i=0; i < 10; i++) { var key = cache_keys.shift(); if (key) { delete cache[key]; cache_length--; } } } }; return function (s) { cacheCheck(); try { r = cache[s] = (cache[s] || rule.call(this, s)); } catch (e) { r = cache[s] = e; } cache_length++; cache_keys.push(s); if (r instanceof $P.Exception) { throw r; } else { return r; } }; }, // vector operators -- see below any: function () { var px = arguments; return function (s) { var r = null; for (var i = 0; i < px.length; i++) { if (px[i] == null) { continue; } try { r = (px[i].call(this, s)); } catch (e) { r = null; } if (r) { return r; } } throw new $P.Exception(s); }; }, each: function () { var px = arguments; return function (s) { var rx = [], r = null; for (var i = 0; i < px.length ; i++) { if (px[i] == null) { continue; } try { r = (px[i].call(this, s)); } catch (e) { throw new $P.Exception(s); } rx.push(r[0]); s = r[1]; } return [ rx, s]; }; }, all: function () { var px = arguments, _ = _; return _.each(_.optional(px)); }, // delimited operators sequence: function (px, d, c) { d = d || _.rtoken(/^\s*/); c = c || null; if (px.length === 1) { return px[0]; } return function (s) { var r = null, q = null; var rx = []; for (var i = 0; i < px.length ; i++) { try { r = px[i].call(this, s); } catch (e) { break; } rx.push(r[0]); try { q = d.call(this, r[1]); } catch (ex) { q = null; break; } s = q[1]; } if (!r) { throw new $P.Exception(s); } if (q) { throw new $P.Exception(q[1]); } if (c) { try { r = c.call(this, r[1]); } catch (ey) { throw new $P.Exception(r[1]); } } return [ rx, (r?r[1]:s) ]; }; }, // // Composite Operators // between: function (d1, p, d2) { d2 = d2 || d1; var _fn = _.each(_.ignore(d1), p, _.ignore(d2)); return function (s) { var rx = _fn.call(this, s); return [[rx[0][0], r[0][2]], rx[1]]; }; }, list: function (p, d, c) { d = d || _.rtoken(/^\s*/); c = c || null; return (p instanceof Array ? _.each(_.product(p.slice(0, -1), _.ignore(d)), p.slice(-1), _.ignore(c)) : _.each(_.many(_.each(p, _.ignore(d))), px, _.ignore(c))); }, set: function (px, d, c) { d = d || _.rtoken(/^\s*/); c = c || null; return function (s) { // r is the current match, best the current 'best' match // which means it parsed the most amount of input var r = null, p = null, q = null, rx = null, best = [[], s], last = false; // go through the rules in the given set for (var i = 0; i < px.length ; i++) { // last is a flag indicating whether this must be the last element // if there is only 1 element, then it MUST be the last one q = null; p = null; r = null; last = (px.length === 1); // first, we try simply to match the current pattern // if not, try the next pattern try { r = px[i].call(this, s); } catch (e) { continue; } // since we are matching against a set of elements, the first // thing to do is to add r[0] to matched elements rx = [[r[0]], r[1]]; // if we matched and there is still input to parse and // we don't already know this is the last element, // we're going to next check for the delimiter ... // if there's none, or if there's no input left to parse // than this must be the last element after all ... if (r[1].length > 0 && ! last) { try { q = d.call(this, r[1]); } catch (ex) { last = true; } } else { last = true; } // if we parsed the delimiter and now there's no more input, // that means we shouldn't have parsed the delimiter at all // so don't update r and mark this as the last element ... if (!last && q[1].length === 0) { last = true; } // so, if this isn't the last element, we're going to see if // we can get any more matches from the remaining (unmatched) // elements ... if (!last) { // build a list of the remaining rules we can match against, // i.e., all but the one we just matched against var qx = []; for (var j = 0; j < px.length ; j++) { if (i !== j) { qx.push(px[j]); } } // now invoke recursively set with the remaining input // note that we don't include the closing delimiter ... // we'll check for that ourselves at the end p = _.set(qx, d).call(this, q[1]); // if we got a non-empty set as a result ... // (otw rx already contains everything we want to match) if (p[0].length > 0) { // update current result, which is stored in rx ... // basically, pick up the remaining text from p[1] // and concat the result from p[0] so that we don't // get endless nesting ... rx[0] = rx[0].concat(p[0]); rx[1] = p[1]; } } // at this point, rx either contains the last matched element // or the entire matched set that starts with this element. // now we just check to see if this variation is better than // our best so far, in terms of how much of the input is parsed if (rx[1].length < best[1].length) { best = rx; } // if we've parsed all the input, then we're finished if (best[1].length === 0) { break; } } // so now we've either gone through all the patterns trying them // as the initial match; or we found one that parsed the entire // input string ... // if best has no matches, just return empty set ... if (best[0].length === 0) { return best; } // if a closing delimiter is provided, then we have to check it also if (c) { // we try this even if there is no remaining input because the pattern // may well be optional or match empty input ... try { q = c.call(this, best[1]); } catch (ey) { throw new $P.Exception(best[1]); } // it parsed ... be sure to update the best match remaining input best[1] = q[1]; } // if we're here, either there was no closing delimiter or we parsed it // so now we have the best match; just return it! return best; }; }, forward: function (gr, fname) { return function (s) { return gr[fname].call(this, s); }; }, // // Translation Operators // replace: function (rule, repl) { return function (s) { var r = rule.call(this, s); return [repl, r[1]]; }; }, process: function (rule, fn) { return function (s) { var r = rule.call(this, s); return [fn.call(this, r[0]), r[1]]; }; }, min: function (min, rule) { return function (s) { var rx = rule.call(this, s); if (rx[0].length < min) { throw new $P.Exception(s); } return rx; }; } }; // Generator Operators And Vector Operators // Generators are operators that have a signature of F(R) => R, // taking a given rule and returning another rule, such as // ignore, which parses a given rule and throws away the result. // Vector operators are those that have a signature of F(R1,R2,...) => R, // take a list of rules and returning a new rule, such as each. // Generator operators are converted (via the following _generator // function) into functions that can also take a list or array of rules // and return an array of new rules as though the function had been // called on each rule in turn (which is what actually happens). // This allows generators to be used with vector operators more easily. // Example: // each(ignore(foo, bar)) instead of each(ignore(foo), ignore(bar)) // This also turns generators into vector operators, which allows // constructs like: // not(cache(foo, bar)) var _generator = function (op) { function gen() { var args = null, rx = [], px, i; if (arguments.length > 1) { args = Array.prototype.slice.call(arguments); } else if (arguments[0] instanceof Array) { args = arguments[0]; } if (args) { px = args.shift(); if (px.length > 0) { args.unshift(px[i]); rx.push(op.apply(null, args)); args.shift(); return rx; } } else { return op.apply(null, arguments); } } return gen; }; var gx = "optional not ignore cache".split(/\s/); for (var i = 0 ; i < gx.length ; i++) { _[gx[i]] = _generator(_[gx[i]]); } var _vector = function (op) { return function () { if (arguments[0] instanceof Array) { return op.apply(null, arguments[0]); } else { return op.apply(null, arguments); } }; }; var vx = "each any all".split(/\s/); for (var j = 0 ; j < vx.length ; j++) { _[vx[j]] = _vector(_[vx[j]]); } }()); (function () { var $D = Date; var flattenAndCompact = function (ax) { var rx = []; for (var i = 0; i < ax.length; i++) { if (ax[i] instanceof Array) { rx = rx.concat(flattenAndCompact(ax[i])); } else { if (ax[i]) { rx.push(ax[i]); } } } return rx; }; var parseMeridian = function () { if (this.meridian && (this.hour || this.hour === 0)) { if (this.meridian === "a" && this.hour > 11 && Date.Config.strict24hr){ throw "Invalid hour and meridian combination"; } else if (this.meridian === "p" && this.hour < 12 && Date.Config.strict24hr){ throw "Invalid hour and meridian combination"; } else if (this.meridian === "p" && this.hour < 12) { this.hour = this.hour + 12; } else if (this.meridian === "a" && this.hour === 12) { this.hour = 0; } } }; var setDefaults = function () { var now = new Date(); if ((this.hour || this.minute) && (!this.month && !this.year && !this.day)) { this.day = now.getDate(); } if (!this.year) { this.year = now.getFullYear(); } if (!this.month && this.month !== 0) { this.month = now.getMonth(); } if (!this.day) { this.day = 1; } if (!this.hour) { this.hour = 0; } if (!this.minute) { this.minute = 0; } if (!this.second) { this.second = 0; } if (!this.millisecond) { this.millisecond = 0; } }; var finishUtils = { getToday: function () { if (this.now || "hour minute second".indexOf(this.unit) !== -1) { return new Date(); } else { return $D.today(); } }, setDaysFromWeekday: function (today, orient){ var gap; orient = orient || 1; this.unit = "day"; gap = ($D.getDayNumberFromName(this.weekday) - today.getDay()); this.days = gap ? ((gap + (orient * 7)) % 7) : (orient * 7); return this; }, setMonthsFromMonth: function (today, orient) { var gap; orient = orient || 1; this.unit = "month"; gap = (this.month - today.getMonth()); this.months = gap ? ((gap + (orient * 12)) % 12) : (orient * 12); this.month = null; return this; }, setDMYFromWeekday: function () { var d = Date[this.weekday](); this.day = d.getDate(); if (!this.month) { this.month = d.getMonth(); } this.year = d.getFullYear(); return this; }, setUnitValue: function (orient) { if (!this.value && this.operator && this.operator !== null && this[this.unit + "s"] && this[this.unit + "s"] !== null) { this[this.unit + "s"] = this[this.unit + "s"] + ((this.operator === "add") ? 1 : -1) + (this.value||0) * orient; } else if (this[this.unit + "s"] == null || this.operator != null) { if (!this.value) { this.value = 1; } this[this.unit + "s"] = this.value * orient; } }, generateDateFromWeeks: function () { var weekday = (this.weekday !== undefined) ? this.weekday : "today"; var d = Date[weekday]().addWeeks(this.weeks); if (this.now) { d.setTimeToNow(); } return d; } }; $D.Translator = { hour: function (s) { return function () { this.hour = Number(s); }; }, minute: function (s) { return function () { this.minute = Number(s); }; }, second: function (s) { return function () { this.second = Number(s); }; }, /* for ss.s format */ secondAndMillisecond: function (s) { return function () { var mx = s.match(/^([0-5][0-9])\.([0-9]{1,3})/); this.second = Number(mx[1]); this.millisecond = Number(mx[2]); }; }, meridian: function (s) { return function () { this.meridian = s.slice(0, 1).toLowerCase(); }; }, timezone: function (s) { return function () { var n = s.replace(/[^\d\+\-]/g, ""); if (n.length) { this.timezoneOffset = Number(n); } else { this.timezone = s.toLowerCase(); } }; }, day: function (x) { var s = x[0]; return function () { this.day = Number(s.match(/\d+/)[0]); if (this.day < 1) { throw "invalid day"; } }; }, month: function (s) { return function () { this.month = (s.length === 3) ? "jan feb mar apr may jun jul aug sep oct nov dec".indexOf(s)/4 : Number(s) - 1; if (this.month < 0) { throw "invalid month"; } }; }, year: function (s) { return function () { var n = Number(s); this.year = ((s.length > 2) ? n : (n + (((n + 2000) < Date.CultureInfo.twoDigitYearMax) ? 2000 : 1900))); }; }, rday: function (s) { return function () { switch (s) { case "yesterday": this.days = -1; break; case "tomorrow": this.days = 1; break; case "today": this.days = 0; break; case "now": this.days = 0; this.now = true; break; } }; }, finishExact: function (x) { var d; x = (x instanceof Array) ? x : [x]; for (var i = 0 ; i < x.length ; i++) { if (x[i]) { x[i].call(this); } } setDefaults.call(this); parseMeridian.call(this); if (this.day > $D.getDaysInMonth(this.year, this.month)) { throw new RangeError(this.day + " is not a valid value for days."); } d = new Date(this.year, this.month, this.day, this.hour, this.minute, this.second, this.millisecond); if (this.year < 100) { d.setFullYear(this.year); // means years less that 100 are process correctly. JS will parse it otherwise as 1900-1999. } if (this.timezone) { d.set({ timezone: this.timezone }); } else if (this.timezoneOffset) { d.set({ timezoneOffset: this.timezoneOffset }); } return d; }, finish: function (x) { var today, expression, orient, temp; x = (x instanceof Array) ? flattenAndCompact(x) : [ x ]; if (x.length === 0) { return null; } for (var i = 0 ; i < x.length ; i++) { if (typeof x[i] === "function") { x[i].call(this); } } if (this.now && !this.unit && !this.operator) { return new Date(); } else { today = finishUtils.getToday.call(this); } expression = !!(this.days && this.days !== null || this.orient || this.operator); orient = ((this.orient === "past" || this.operator === "subtract") ? -1 : 1); if (this.month && this.unit === "week") { this.value = this.month + 1; delete this.month; delete this.day; } if ((this.month || this.month === 0) && "year day hour minute second".indexOf(this.unit) !== -1) { if (!this.value) { this.value = this.month + 1; } this.month = null; expression = true; } if (!expression && this.weekday && !this.day && !this.days) { finishUtils.setDMYFromWeekday.call(this); } if (expression && this.weekday && this.unit !== "month" && this.unit !== "week") { finishUtils.setDaysFromWeekday.call(this, today, orient); } if (this.weekday && this.unit !== "week" && !this.day && !this.days) { temp = Date[this.weekday](); this.day = temp.getDate(); if (temp.getMonth() !== today.getMonth()) { this.month = temp.getMonth(); } } if (this.month && this.unit === "day" && this.operator) { if (!this.value) { this.value = (this.month + 1); } this.month = null; } if (this.value != null && this.month != null && this.year != null) { this.day = this.value * 1; } if (this.month && !this.day && this.value) { today.set({ day: this.value * 1 }); if (!expression) { this.day = this.value * 1; } } if (!this.month && this.value && this.unit === "month" && !this.now) { this.month = this.value; expression = true; } if (expression && (this.month || this.month === 0) && this.unit !== "year") { finishUtils.setMonthsFromMonth.call(this, today, orient); } if (!this.unit) { this.unit = "day"; } finishUtils.setUnitValue.call(this, orient); parseMeridian.call(this); if ((this.month || this.month === 0) && !this.day) { this.day = 1; } if (!this.orient && !this.operator && this.unit === "week" && this.value && !this.day && !this.month) { return Date.today().setWeek(this.value); } if (this.unit === "week" && this.weeks && !this.day && !this.month) { return finishUtils.generateDateFromWeeks.call(this); } if (expression && this.timezone && this.day && this.days) { this.day = this.days; } if (expression){ today.add(this); } else { today.set(this); } if (this.timezone) { this.timezone = this.timezone.toUpperCase(); var offset = $D.getTimezoneOffset(this.timezone); var timezone; if (today.hasDaylightSavingTime()) { // lets check that we're being sane with timezone setting timezone = $D.getTimezoneAbbreviation(offset, today.isDaylightSavingTime()); if (timezone !== this.timezone) { // bugger, we're in a place where things like EST vs EDT matters. if (today.isDaylightSavingTime()) { today.addHours(-1); } else { today.addHours(1); } } } today.setTimezoneOffset(offset); } return today; } }; }()); (function () { var $D = Date; $D.Grammar = {}; var _ = $D.Parsing.Operators, g = $D.Grammar, t = $D.Translator, _fn; // Allow rolling up into general purpose rules _fn = function () { return _.each(_.any.apply(null, arguments), _.not(g.ctoken2("timeContext"))); }; g.datePartDelimiter = _.rtoken(/^([\s\-\.\,\/\x27]+)/); g.timePartDelimiter = _.stoken(":"); g.whiteSpace = _.rtoken(/^\s*/); g.generalDelimiter = _.rtoken(/^(([\s\,]|at|@|on)+)/); var _C = {}; g.ctoken = function (keys) { var fn = _C[keys]; if (! fn) { var c = Date.CultureInfo.regexPatterns; var kx = keys.split(/\s+/), px = []; for (var i = 0; i < kx.length ; i++) { px.push(_.replace(_.rtoken(c[kx[i]]), kx[i])); } fn = _C[keys] = _.any.apply(null, px); } return fn; }; g.ctoken2 = function (key) { return _.rtoken(Date.CultureInfo.regexPatterns[key]); }; var cacheProcessRtoken = function (key, token, type, eachToken) { if (eachToken) { g[key] = _.cache(_.process(_.each(_.rtoken(token),_.optional(g.ctoken2(eachToken))), type)); } else { g[key] = _.cache(_.process(_.rtoken(token), type)); } }; var cacheProcessCtoken = function (token, type) { return _.cache(_.process(g.ctoken2(token), type)); }; var _F = {}; //function cache var _get = function (f) { _F[f] = (_F[f] || g.format(f)[0]); return _F[f]; }; g.allformats = function (fx) { var rx = []; if (fx instanceof Array) { for (var i = 0; i < fx.length; i++) { rx.push(_get(fx[i])); } } else { rx.push(_get(fx)); } return rx; }; g.formats = function (fx) { if (fx instanceof Array) { var rx = []; for (var i = 0 ; i < fx.length ; i++) { rx.push(_get(fx[i])); } return _.any.apply(null, rx); } else { return _get(fx); } }; var grammarFormats = { timeFormats: function(){ var i, RTokenKeys = [ "h", "hh", "H", "HH", "m", "mm", "s", "ss", "ss.s", "z", "zz" ], RToken = [ /^(0[0-9]|1[0-2]|[1-9])/, /^(0[0-9]|1[0-2])/, /^([0-1][0-9]|2[0-3]|[0-9])/, /^([0-1][0-9]|2[0-3])/, /^([0-5][0-9]|[0-9])/, /^[0-5][0-9]/, /^([0-5][0-9]|[0-9])/, /^[0-5][0-9]/, /^[0-5][0-9]\.[0-9]{1,3}/, /^((\+|\-)\s*\d\d\d\d)|((\+|\-)\d\d\:?\d\d)/, /^((\+|\-)\s*\d\d\d\d)|((\+|\-)\d\d\:?\d\d)/ ], tokens = [ t.hour, t.hour, t.hour, t.hour, t.minute, t.minute, t.second, t.second, t.secondAndMillisecond, t.timezone, t.timezone ]; for (i=0; i < RTokenKeys.length; i++) { cacheProcessRtoken(RTokenKeys[i], RToken[i], tokens[i]); } g.hms = _.cache(_.sequence([g.H, g.m, g.s], g.timePartDelimiter)); g.t = cacheProcessCtoken("shortMeridian", t.meridian); g.tt = cacheProcessCtoken("longMeridian", t.meridian); g.zzz = cacheProcessCtoken("timezone", t.timezone); g.timeSuffix = _.each(_.ignore(g.whiteSpace), _.set([ g.tt, g.zzz ])); g.time = _.each(_.optional(_.ignore(_.stoken("T"))), g.hms, g.timeSuffix); }, dateFormats: function () { // pre-loaded rules for different date part order preferences var _setfn = function () { return _.set(arguments, g.datePartDelimiter); }; var i, RTokenKeys = [ "d", "dd", "M", "MM", "y", "yy", "yyy", "yyyy" ], RToken = [ /^([0-2]\d|3[0-1]|\d)/, /^([0-2]\d|3[0-1])/, /^(1[0-2]|0\d|\d)/, /^(1[0-2]|0\d)/, /^(\d+)/, /^(\d\d)/, /^(\d\d?\d?\d?)/, /^(\d\d\d\d)/ ], tokens = [ t.day, t.day, t.month, t.month, t.year, t.year, t.year, t.year ], eachToken = [ "ordinalSuffix", "ordinalSuffix" ]; for (i=0; i < RTokenKeys.length; i++) { cacheProcessRtoken(RTokenKeys[i], RToken[i], tokens[i], eachToken[i]); } g.MMM = g.MMMM = _.cache(_.process(g.ctoken("jan feb mar apr may jun jul aug sep oct nov dec"), t.month)); g.ddd = g.dddd = _.cache(_.process(g.ctoken("sun mon tue wed thu fri sat"), function (s) { return function () { this.weekday = s; }; } )); g.day = _fn(g.d, g.dd); g.month = _fn(g.M, g.MMM); g.year = _fn(g.yyyy, g.yy); g.mdy = _setfn(g.ddd, g.month, g.day, g.year); g.ymd = _setfn(g.ddd, g.year, g.month, g.day); g.dmy = _setfn(g.ddd, g.day, g.month, g.year); g.date = function (s) { return ((g[Date.CultureInfo.dateElementOrder] || g.mdy).call(this, s)); }; }, relative: function () { // relative date / time expressions g.orientation = _.process(g.ctoken("past future"), function (s) { return function () { this.orient = s; }; } ); g.operator = _.process(g.ctoken("add subtract"), function (s) { return function () { this.operator = s; }; } ); g.rday = _.process(g.ctoken("yesterday tomorrow today now"), t.rday); g.unit = _.process(g.ctoken("second minute hour day week month year"), function (s) { return function () { this.unit = s; }; } ); } }; g.buildGrammarFormats = function () { // these need to be rebuilt every time the language changes. _C = {}; grammarFormats.timeFormats(); grammarFormats.dateFormats(); grammarFormats.relative(); g.value = _.process(_.rtoken(/^([-+]?\d+)?(st|nd|rd|th)?/), function (s) { return function () { this.value = s.replace(/\D/g, ""); }; } ); g.expression = _.set([g.rday, g.operator, g.value, g.unit, g.orientation, g.ddd, g.MMM ]); g.format = _.process(_.many( _.any( // translate format specifiers into grammar rules _.process( _.rtoken(/^(dd?d?d?(?!e)|MM?M?M?|yy?y?y?|hh?|HH?|mm?|ss?|tt?|zz?z?)/), function (fmt) { if (g[fmt]) { return g[fmt]; } else { throw $D.Parsing.Exception(fmt); } } ), // translate separator tokens into token rules _.process(_.rtoken(/^[^dMyhHmstz]+/), // all legal separators function (s) { return _.ignore(_.stoken(s)); } ) ) ), // construct the parser ... function (rules) { return _.process(_.each.apply(null, rules), t.finishExact); } ); // starting rule for general purpose grammar g._start = _.process(_.set([ g.date, g.time, g.expression ], g.generalDelimiter, g.whiteSpace), t.finish); }; g.buildGrammarFormats(); // parsing date format specifiers - ex: "h:m:s tt" // this little guy will generate a custom parser based // on the format string, ex: g.format("h:m:s tt") // check for these formats first g._formats = g.formats([ "\"yyyy-MM-ddTHH:mm:ssZ\"", "yyyy-MM-ddTHH:mm:ss.sz", "yyyy-MM-ddTHH:mm:ssZ", "yyyy-MM-ddTHH:mm:ssz", "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-ddTHH:mmZ", "yyyy-MM-ddTHH:mmz", "yyyy-MM-ddTHH:mm", "ddd, MMM dd, yyyy H:mm:ss tt", "ddd MMM d yyyy HH:mm:ss zzz", "MMddyyyy", "ddMMyyyy", "Mddyyyy", "ddMyyyy", "Mdyyyy", "dMyyyy", "yyyy", "Mdyy", "dMyy", "d" ]); // real starting rule: tries selected formats first, // then general purpose rule g.start = function (s) { try { var r = g._formats.call({}, s); if (r[1].length === 0) { return r; } } catch (e) {} return g._start.call({}, s); }; }()); (function () { var $D = Date; /** * @desc Converts the specified string value into its JavaScript Date equivalent using CultureInfo specific format information. * * Example

	///////////
	// Dates //
	///////////

	// 15-Oct-2004
	var d1 = Date.parse("10/15/2004");

	// 15-Oct-2004
	var d1 = Date.parse("15-Oct-2004");

	// 15-Oct-2004
	var d1 = Date.parse("2004.10.15");

	//Fri Oct 15, 2004
	var d1 = Date.parse("Fri Oct 15, 2004");

	///////////
	// Times //
	///////////

	// Today at 10 PM.
	var d1 = Date.parse("10 PM");

	// Today at 10:30 PM.
	var d1 = Date.parse("10:30 P.M.");

	// Today at 6 AM.
	var d1 = Date.parse("06am");

	/////////////////////
	// Dates and Times //
	/////////////////////

	// 8-July-2004 @ 10:30 PM
	var d1 = Date.parse("July 8th, 2004, 10:30 PM");

	// 1-July-2004 @ 10:30 PM
	var d1 = Date.parse("2004-07-01T22:30:00");

	////////////////////
	// Relative Dates //
	////////////////////

	// Returns today's date. The string "today" is culture specific.
	var d1 = Date.parse("today");

	// Returns yesterday's date. The string "yesterday" is culture specific.
	var d1 = Date.parse("yesterday");

	// Returns the date of the next thursday.
	var d1 = Date.parse("Next thursday");

	// Returns the date of the most previous monday.
	var d1 = Date.parse("last monday");

	// Returns today's day + one year.
	var d1 = Date.parse("next year");

	///////////////
	// Date Math //
	///////////////

	// Today + 2 days
	var d1 = Date.parse("t+2");

	// Today + 2 days
	var d1 = Date.parse("today + 2 days");

	// Today + 3 months
	var d1 = Date.parse("t+3m");

	// Today - 1 year
	var d1 = Date.parse("today - 1 year");

	// Today - 1 year
	var d1 = Date.parse("t-1y"); 


	/////////////////////////////
	// Partial Dates and Times //
	/////////////////////////////

	// July 15th of this year.
	var d1 = Date.parse("July 15");

	// 15th day of current day and year.
	var d1 = Date.parse("15");

	// July 1st of current year at 10pm.
	var d1 = Date.parse("7/1 10pm");
	
* * @param {String} The string value to convert into a Date object [Required] * @return {Date} A Date object or null if the string cannot be converted into a Date. */ var parseUtils = { removeOrds: function (s) { ords = s.match(/\b(\d+)(?:st|nd|rd|th)\b/); // find ordinal matches s = ((ords && ords.length === 2) ? s.replace(ords[0], ords[1]) : s); return s; }, grammarParser: function (s) { var r = null; try { r = $D.Grammar.start.call({}, s.replace(/^\s*(\S*(\s+\S+)*)\s*$/, "$1")); } catch (e) { return null; } return ((r[1].length === 0) ? r[0] : null); }, nativeFallback: function(s) { var t; try { // ok we haven't parsed it, last ditch attempt with the built-in parser. t = Date._parse(s); return (t || t === 0) ? new Date(t) : null; } catch (e) { return null; } } }; function parse (s) { var d; if (!s) { return null; } if (s instanceof Date) { return s.clone(); } if (s.length >= 4 && s.charAt(0) !== "0" && s.charAt(0) !== "+"&& s.charAt(0) !== "-") { // ie: 2004 will pass, 0800 won't. // Start with specific formats d = $D.Parsing.ISO.parse(s) || $D.Parsing.Numeric.parse(s); } if (d instanceof Date && !isNaN(d.getTime())) { return d; } else { // find ordinal dates (1st, 3rd, 8th, etc and remove them as they cause parsing issues) s = $D.Parsing.Normalizer.parse(parseUtils.removeOrds(s)); d = parseUtils.grammarParser(s); if (d !== null) { return d; } else { return parseUtils.nativeFallback(s); } } } if (!$D._parse) { $D._parse = $D.parse; } $D.parse = parse; Date.getParseFunction = function (fx) { var fns = Date.Grammar.allformats(fx); return function (s) { var r = null; for (var i = 0; i < fns.length; i++) { try { r = fns[i].call({}, s); } catch (e) { continue; } if (r[1].length === 0) { return r[0]; } } return null; }; }; /** * Converts the specified string value into its JavaScript Date equivalent using the specified format {String} or formats {Array} and the CultureInfo specific format information. * The format of the string value must match one of the supplied formats exactly. * * Example

	// 15-Oct-2004
	var d1 = Date.parseExact("10/15/2004", "M/d/yyyy");

	// 15-Oct-2004
	var d1 = Date.parse("15-Oct-2004", "M-ddd-yyyy");

	// 15-Oct-2004
	var d1 = Date.parse("2004.10.15", "yyyy.MM.dd");

	// Multiple formats
	var d1 = Date.parseExact("10/15/2004", ["M/d/yyyy", "MMMM d, yyyy"]);
	
* * @param {String} The string value to convert into a Date object [Required]. * @param {Object} The expected format {String} or an array of expected formats {Array} of the date string [Required]. * @return {Date} A Date object or null if the string cannot be converted into a Date. */ $D.parseExact = function (s, fx) { return $D.getParseFunction(fx)(s); }; }()); (function () { var $D = Date, $P = $D.prototype, // $C = $D.CultureInfo, // not used atm p = function (s, l) { if (!l) { l = 2; } return ("000" + s).slice(l * -1); }; /** * Converts a PHP format string to Java/.NET format string. * A PHP format string can be used with ._format or .format. * A Java/.NET format string can be used with .toString(). * The .parseExact function will only accept a Java/.NET format string * * Example * var f1 = "%m/%d/%y" * var f2 = Date.normalizeFormat(f1); // "MM/dd/yy" * * new Date().format(f1); // "04/13/08" * new Date()._format(f1); // "04/13/08" * new Date().toString(f2); // "04/13/08" * * var date = Date.parseExact("04/13/08", f2); // Sun Apr 13 2008 * * @param {String} A PHP format string consisting of one or more format spcifiers. * @return {String} The PHP format converted to a Java/.NET format string. */ var normalizerSubstitutions = { "d" : "dd", "%d": "dd", "D" : "ddd", "%a": "ddd", "j" : "dddd", "l" : "dddd", "%A": "dddd", "S" : "S", "F" : "MMMM", "%B": "MMMM", "m" : "MM", "%m": "MM", "M" : "MMM", "%b": "MMM", "%h": "MMM", "n" : "M", "Y" : "yyyy", "%Y": "yyyy", "y" : "yy", "%y": "yy", "g" : "h", "%I": "h", "G" : "H", "h" : "hh", "H" : "HH", "%H": "HH", "i" : "mm", "%M": "mm", "s" : "ss", "%S": "ss", "%r": "hh:mm tt", "%R": "H:mm", "%T": "H:mm:ss", "%X": "t", "%x": "d", "%e": "d", "%D": "MM/dd/yy", "%n": "\\n", "%t": "\\t", "e" : "z", "T" : "z", "%z": "z", "%Z": "z", "Z" : "ZZ", "N" : "u", "w" : "u", "%w": "u", "W" : "W", "%V": "W" }; var normalizer = { substitutes: function (m) { return normalizerSubstitutions[m]; }, interpreted: function (m, x) { var y; switch (m) { case "%u": return x.getDay() + 1; case "z": return x.getOrdinalNumber(); case "%j": return p(x.getOrdinalNumber(), 3); case "%U": var d1 = x.clone().set({month: 0, day: 1}).addDays(-1).moveToDayOfWeek(0), d2 = x.clone().addDays(1).moveToDayOfWeek(0, -1); return (d2 < d1) ? "00" : p((d2.getOrdinalNumber() - d1.getOrdinalNumber()) / 7 + 1); case "%W": return p(x.getWeek()); case "t": return $D.getDaysInMonth(x.getFullYear(), x.getMonth()); case "o": case "%G": return x.setWeek(x.getISOWeek()).toString("yyyy"); case "%g": return x._format("%G").slice(-2); case "a": case "%p": return t("tt").toLowerCase(); case "A": return t("tt").toUpperCase(); case "u": return p(x.getMilliseconds(), 3); case "I": return (x.isDaylightSavingTime()) ? 1 : 0; case "O": return x.getUTCOffset(); case "P": y = x.getUTCOffset(); return y.substring(0, y.length - 2) + ":" + y.substring(y.length - 2); case "B": var now = new Date(); return Math.floor(((now.getHours() * 3600) + (now.getMinutes() * 60) + now.getSeconds() + (now.getTimezoneOffset() + 60) * 60) / 86.4); case "c": return x.toISOString().replace(/\"/g, ""); case "U": return $D.strtotime("now"); case "%c": return t("d") + " " + t("t"); case "%C": return Math.floor(x.getFullYear() / 100 + 1); } }, shouldOverrideDefaults: function (m) { switch (m) { case "%e": return true; default: return false; } }, parse: function (m, context) { var formatString, c = context || new Date(); formatString = normalizer.substitutes(m); if (formatString) { return formatString; } formatString = normalizer.interpreted(m, c); if (formatString) { return formatString; } else { return m; } } }; $D.normalizeFormat = function (format, context) { return format.replace(/(%|\\)?.|%%/g, function(t){ return normalizer.parse(t, context); }); }; /** * Format a local Unix timestamp according to locale settings * * Example: * Date.strftime("%m/%d/%y", new Date()); // "04/13/08" * Date.strftime("c", "2008-04-13T17:52:03Z"); // "04/13/08" * * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @param {Number|String} The number representing the number of seconds that have elapsed since January 1, 1970 (local time). * @return {String} A string representation of the current Date object. */ $D.strftime = function (format, time) { var d = Date.parse(time); return d._format(format); }; /** * Parse any textual datetime description into a Unix timestamp. * A Unix timestamp is the number of seconds that have elapsed since January 1, 1970 (midnight UTC/GMT). * * Example: * Date.strtotime("04/13/08"); // 1208044800 * Date.strtotime("1970-01-01T00:00:00Z"); // 0 * * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @param {Object} A string or date object. * @return {String} A string representation of the current Date object. */ $D.strtotime = function (time) { var d = $D.parse(time); return Math.round($D.UTC(d.getUTCFullYear(), d.getUTCMonth(), d.getUTCDate(), d.getUTCHours(), d.getUTCMinutes(), d.getUTCSeconds(), d.getUTCMilliseconds()) / 1000); }; /** * Converts the value of the current Date object to its equivalent string representation using a PHP/Unix style of date format specifiers. * Format Specifiers * Format Description Example * ------ --------------------------------------------------------------------------- ----------------------- * %a abbreviated weekday name according to the current localed "Mon" through "Sun" * %A full weekday name according to the current localed "Sunday" through "Saturday" * %b abbreviated month name according to the current localed "Jan" through "Dec" * %B full month name according to the current locale "January" through "December" * %c preferred date and time representation for the current locale "4/13/2008 12:33 PM" * %C century number (the year divided by 100 and truncated to an integer) "00" to "99" * %d day of the month as a decimal number "01" to "31" * %D same as %m/%d/%y "04/13/08" * %e day of the month as a decimal number, a single digit is preceded by a space "1" to "31" * %g like %G, but without the century "08" * %G The 4-digit year corresponding to the ISO week number (see %V). "2008" * This has the same format and value as %Y, except that if the ISO week number * belongs to the previous or next year, that year is used instead. * %h same as %b "Jan" through "Dec" * %H hour as a decimal number using a 24-hour clock. "00" to "23" * %I hour as a decimal number using a 12-hour clock. "01" to "12" * %j day of the year as a decimal number. "001" to "366" * %m month as a decimal number. "01" to "12" * %M minute as a decimal number. "00" to "59" * %n newline character "\n" * %p either "am" or "pm" according to the given time value, or the "am" or "pm" * corresponding strings for the current locale. * %r time in a.m. and p.m. notation "8:44 PM" * %R time in 24 hour notation "20:44" * %S second as a decimal number "00" to "59" * %t tab character "\t" * %T current time, equal to %H:%M:%S "12:49:11" * %u weekday as a decimal number ["1", "7"], with "1" representing Monday "1" to "7" * %U week number of the current year as a decimal number, starting with the "0" to ("52" or "53") * first Sunday as the first day of the first week * %V The ISO 8601:1988 week number of the current year as a decimal number, "00" to ("52" or "53") * range 01 to 53, where week 1 is the first week that has at least 4 days * in the current year, and with Monday as the first day of the week. * (Use %G or %g for the year component that corresponds to the week number * for the specified timestamp.) * %W week number of the current year as a decimal number, starting with the "00" to ("52" or "53") * first Monday as the first day of the first week * %w day of the week as a decimal, Sunday being "0" "0" to "6" * %x preferred date representation for the current locale without the time "4/13/2008" * %X preferred time representation for the current locale without the date "12:53:05" * %y year as a decimal number without a century "00" "99" * %Y year as a decimal number including the century "2008" * %Z time zone or name or abbreviation "UTC", "EST", "PST" * %z same as %Z * %% a literal "%" characters "%" * d Day of the month, 2 digits with leading zeros "01" to "31" * D A textual representation of a day, three letters "Mon" through "Sun" * j Day of the month without leading zeros "1" to "31" * l A full textual representation of the day of the week (lowercase "L") "Sunday" through "Saturday" * N ISO-8601 numeric representation of the day of the week (added in PHP 5.1.0) "1" (for Monday) through "7" (for Sunday) * S English ordinal suffix for the day of the month, 2 characters "st", "nd", "rd" or "th". Works well with j * w Numeric representation of the day of the week "0" (for Sunday) through "6" (for Saturday) * z The day of the year (starting from "0") "0" through "365" * W ISO-8601 week number of year, weeks starting on Monday "00" to ("52" or "53") * F A full textual representation of a month, such as January or March "January" through "December" * m Numeric representation of a month, with leading zeros "01" through "12" * M A short textual representation of a month, three letters "Jan" through "Dec" * n Numeric representation of a month, without leading zeros "1" through "12" * t Number of days in the given month "28" through "31" * L Whether it's a leap year "1" if it is a leap year, "0" otherwise * o ISO-8601 year number. This has the same value as Y, except that if the "2008" * ISO week number (W) belongs to the previous or next year, that year * is used instead. * Y A full numeric representation of a year, 4 digits "2008" * y A two digit representation of a year "08" * a Lowercase Ante meridiem and Post meridiem "am" or "pm" * A Uppercase Ante meridiem and Post meridiem "AM" or "PM" * B Swatch Internet time "000" through "999" * g 12-hour format of an hour without leading zeros "1" through "12" * G 24-hour format of an hour without leading zeros "0" through "23" * h 12-hour format of an hour with leading zeros "01" through "12" * H 24-hour format of an hour with leading zeros "00" through "23" * i Minutes with leading zeros "00" to "59" * s Seconds, with leading zeros "00" through "59" * u Milliseconds "54321" * e Timezone identifier "UTC", "EST", "PST" * I Whether or not the date is in daylight saving time (uppercase i) "1" if Daylight Saving Time, "0" otherwise * O Difference to Greenwich time (GMT) in hours "+0200", "-0600" * P Difference to Greenwich time (GMT) with colon between hours and minutes "+02:00", "-06:00" * T Timezone abbreviation "UTC", "EST", "PST" * Z Timezone offset in seconds. The offset for timezones west of UTC is "-43200" through "50400" * always negative, and for those east of UTC is always positive. * c ISO 8601 date "2004-02-12T15:19:21+00:00" * r RFC 2822 formatted date "Thu, 21 Dec 2000 16:01:07 +0200" * U Seconds since the Unix Epoch (January 1 1970 00:00:00 GMT) "0" * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @return {String} A string representation of the current Date object. */ var formatReplace = function (context) { return function (m) { var formatString, override = false; if (m.charAt(0) === "\\" || m.substring(0, 2) === "%%") { return m.replace("\\", "").replace("%%", "%"); } override = normalizer.shouldOverrideDefaults(m); formatString = $D.normalizeFormat(m, context); if (formatString) { return context.toString(formatString, override); } }; }; $P._format = function (format) { var formatter = formatReplace(this); if (!format) { return this._toString(); } else { return format.replace(/(%|\\)?.|%%/g, formatter); } }; if (!$P.format) { $P.format = $P._format; } }()); (function () { "use strict"; var gFn = function (attr) { return function () { return this[attr]; }; }; var sFn = function (attr) { return function (val) { this[attr] = val; return this; }; }; var attrs = ["years", "months", "days", "hours", "minutes", "seconds", "milliseconds"]; var addSetFuncs = function (context, attrs) { for (var i = 0; i < attrs.length ; i++) { var $a = attrs[i], $b = $a.slice(0, 1).toUpperCase() + $a.slice(1); context.prototype[$a] = 0; context.prototype["get" + $b] = gFn($a); context.prototype["set" + $b] = sFn($a); } }; /** * new TimeSpan(milliseconds); * new TimeSpan(days, hours, minutes, seconds); * new TimeSpan(days, hours, minutes, seconds, milliseconds); */ var TimeSpan = function (days, hours, minutes, seconds, milliseconds) { if (arguments.length === 1 && typeof days === "number") { var orient = (days < 0) ? -1 : +1; var millsLeft = Math.abs(days); this.setDays(Math.floor(millsLeft / 86400000) * orient); millsLeft = millsLeft % 86400000; this.setHours(Math.floor(millsLeft / 3600000) * orient); millsLeft = millsLeft % 3600000; this.setMinutes(Math.floor(millsLeft / 60000) * orient); millsLeft = millsLeft % 60000; this.setSeconds(Math.floor(millsLeft / 1000) * orient); millsLeft = millsLeft % 1000; this.setMilliseconds(millsLeft * orient); } else { this.set(days, hours, minutes, seconds, milliseconds); } this.getTotalMilliseconds = function () { return (this.getDays() * 86400000) + (this.getHours() * 3600000) + (this.getMinutes() * 60000) + (this.getSeconds() * 1000); }; this.compareTo = function (time) { var t1 = new Date(1970, 1, 1, this.getHours(), this.getMinutes(), this.getSeconds()), t2; if (time === null) { t2 = new Date(1970, 1, 1, 0, 0, 0); } else { t2 = new Date(1970, 1, 1, time.getHours(), time.getMinutes(), time.getSeconds()); } return (t1 < t2) ? -1 : (t1 > t2) ? 1 : 0; }; this.equals = function (time) { return (this.compareTo(time) === 0); }; this.add = function (time) { return (time === null) ? this : this.addSeconds(time.getTotalMilliseconds() / 1000); }; this.subtract = function (time) { return (time === null) ? this : this.addSeconds(-time.getTotalMilliseconds() / 1000); }; this.addDays = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 86400000)); }; this.addHours = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 3600000)); }; this.addMinutes = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 60000)); }; this.addSeconds = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 1000)); }; this.addMilliseconds = function (n) { return new TimeSpan(this.getTotalMilliseconds() + n); }; this.get12HourHour = function () { return (this.getHours() > 12) ? this.getHours() - 12 : (this.getHours() === 0) ? 12 : this.getHours(); }; this.getDesignator = function () { return (this.getHours() < 12) ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator; }; this.toString = function (format) { this._toString = function () { if (this.getDays() !== null && this.getDays() > 0) { return this.getDays() + "." + this.getHours() + ":" + this.p(this.getMinutes()) + ":" + this.p(this.getSeconds()); } else { return this.getHours() + ":" + this.p(this.getMinutes()) + ":" + this.p(this.getSeconds()); } }; this.p = function (s) { return (s.toString().length < 2) ? "0" + s : s; }; var me = this; return format ? format.replace(/dd?|HH?|hh?|mm?|ss?|tt?/g, function (format) { switch (format) { case "d": return me.getDays(); case "dd": return me.p(me.getDays()); case "H": return me.getHours(); case "HH": return me.p(me.getHours()); case "h": return me.get12HourHour(); case "hh": return me.p(me.get12HourHour()); case "m": return me.getMinutes(); case "mm": return me.p(me.getMinutes()); case "s": return me.getSeconds(); case "ss": return me.p(me.getSeconds()); case "t": return ((me.getHours() < 12) ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator).substring(0, 1); case "tt": return (me.getHours() < 12) ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator; } } ) : this._toString(); }; return this; }; addSetFuncs(TimeSpan, attrs.slice(2)); TimeSpan.prototype.set = function (days, hours, minutes, seconds, milliseconds){ this.setDays(days || this.getDays()); this.setHours(hours || this.getHours()); this.setMinutes(minutes || this.getMinutes()); this.setSeconds(seconds || this.getSeconds()); this.setMilliseconds(milliseconds || this.getMilliseconds()); }; /** * Gets the time of day for this date instances. * @return {TimeSpan} TimeSpan */ Date.prototype.getTimeOfDay = function () { return new TimeSpan(0, this.getHours(), this.getMinutes(), this.getSeconds(), this.getMilliseconds()); }; Date.TimeSpan = TimeSpan; if (typeof window !== "undefined" ) { // keeping API compatible for v1.x window.TimeSpan = TimeSpan; } }()); (function () { "use strict"; var attrs = ["years", "months", "days", "hours", "minutes", "seconds", "milliseconds"]; var gFn = function (attr) { return function () { return this[attr]; }; }; var sFn = function (attr) { return function (val) { this[attr] = val; return this; }; }; var addSetFuncs = function (context, attrs) { for (var i = 0; i < attrs.length ; i++) { var $a = attrs[i], $b = $a.slice(0, 1).toUpperCase() + $a.slice(1); context.prototype[$a] = 0; context.prototype["get" + $b] = gFn($a); context.prototype["set" + $b] = sFn($a); } }; var setMonthsAndYears = function (orient, d1, d2, context) { function inc() { d1.addMonths(-orient); context.months++; if (context.months === 12) { context.years++; context.months = 0; } } if (orient === +1) { while (d1 > d2) { inc(); } } else { while (d1 < d2) { inc(); } } context.months--; context.months *= orient; context.years *= orient; }; var adjustForDST = function(orient, startDate, endDate) { var hasDSTMismatch = (false === (startDate.isDaylightSavingTime() === endDate.isDaylightSavingTime())); if (hasDSTMismatch && orient === 1) { startDate.addHours(-1); } else if (hasDSTMismatch) { startDate.addHours(1); } }; /** * TimePeriod(startDate, endDate); * TimePeriod(years, months, days, hours, minutes, seconds, milliseconds); */ var TimePeriod = function (years, months, days, hours, minutes, seconds, milliseconds) { if (arguments.length === 7) { this.set(years, months, days, hours, minutes, seconds, milliseconds); } else if (arguments.length === 2 && arguments[0] instanceof Date && arguments[1] instanceof Date) { var startDate = arguments[0].clone(); var endDate = arguments[1].clone(); var orient = (startDate > endDate) ? +1 : -1; this.dates = { start: arguments[0].clone(), end: arguments[1].clone() }; setMonthsAndYears(orient, startDate, endDate, this); adjustForDST(orient, startDate, endDate); // // TODO - adjust for DST var diff = endDate - startDate; if (diff !== 0) { var ts = new TimeSpan(diff); this.set(this.years, this.months, ts.getDays(), ts.getHours(), ts.getMinutes(), ts.getSeconds(), ts.getMilliseconds()); } } return this; }; // create all the set functions. addSetFuncs(TimePeriod, attrs); TimePeriod.prototype.set = function (years, months, days, hours, minutes, seconds, milliseconds){ this.setYears(years || this.getYears()); this.setMonths(months || this.getMonths()); this.setDays(days || this.getDays()); this.setHours(hours || this.getHours()); this.setMinutes(minutes || this.getMinutes()); this.setSeconds(seconds || this.getSeconds()); this.setMilliseconds(milliseconds || this.getMilliseconds()); }; Date.TimePeriod = TimePeriod; if (typeof window !== "undefined") { // keeping API compatible for v1.x window.TimePeriod = TimePeriod; } }()); ================================================ FILE: build/date-en-US.js ================================================ /** * @overview datejs * @version 1.0.0-beta-2014-03-25 * @author Gregory Wild-Smith * @copyright 2014 Gregory Wild-Smith * @license MIT * @homepage https://github.com/abritinthebay/datejs */ /* * DateJS Culture String File * Country Code: en-US * Name: English (United States) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["en-US"] = { "name": "en-US", "englishName": "English (United States)", "nativeName": "English (United States)", "Sunday": "Sunday", "Monday": "Monday", "Tuesday": "Tuesday", "Wednesday": "Wednesday", "Thursday": "Thursday", "Friday": "Friday", "Saturday": "Saturday", "Sun": "Sun", "Mon": "Mon", "Tue": "Tue", "Wed": "Wed", "Thu": "Thu", "Fri": "Fri", "Sat": "Sat", "Su": "Su", "Mo": "Mo", "Tu": "Tu", "We": "We", "Th": "Th", "Fr": "Fr", "Sa": "Sa", "S_Sun_Initial": "S", "M_Mon_Initial": "M", "T_Tue_Initial": "T", "W_Wed_Initial": "W", "T_Thu_Initial": "T", "F_Fri_Initial": "F", "S_Sat_Initial": "S", "January": "January", "February": "February", "March": "March", "April": "April", "May": "May", "June": "June", "July": "July", "August": "August", "September": "September", "October": "October", "November": "November", "December": "December", "Jan_Abbr": "Jan", "Feb_Abbr": "Feb", "Mar_Abbr": "Mar", "Apr_Abbr": "Apr", "May_Abbr": "May", "Jun_Abbr": "Jun", "Jul_Abbr": "Jul", "Aug_Abbr": "Aug", "Sep_Abbr": "Sep", "Oct_Abbr": "Oct", "Nov_Abbr": "Nov", "Dec_Abbr": "Dec", "AM": "AM", "PM": "PM", "firstDayOfWeek": 0, "twoDigitYearMax": 2049, "mdy": "mdy", "M/d/yyyy": "M/d/yyyy", "dddd, MMMM dd, yyyy": "dddd, MMMM dd, yyyy", "h:mm tt": "h:mm tt", "h:mm:ss tt": "h:mm:ss tt", "dddd, MMMM dd, yyyy h:mm:ss tt": "dddd, MMMM dd, yyyy h:mm:ss tt", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "MMMM dd", "MMMM, yyyy": "MMMM, yyyy", "/jan(uary)?/": "jan(uary)?", "/feb(ruary)?/": "feb(ruary)?", "/mar(ch)?/": "mar(ch)?", "/apr(il)?/": "apr(il)?", "/may/": "may", "/jun(e)?/": "jun(e)?", "/jul(y)?/": "jul(y)?", "/aug(ust)?/": "aug(ust)?", "/sep(t(ember)?)?/": "sep(t(ember)?)?", "/oct(ober)?/": "oct(ober)?", "/nov(ember)?/": "nov(ember)?", "/dec(ember)?/": "dec(ember)?", "/^su(n(day)?)?/": "^su(n(day)?)?", "/^mo(n(day)?)?/": "^mo(n(day)?)?", "/^tu(e(s(day)?)?)?/": "^tu(e(s(day)?)?)?", "/^we(d(nesday)?)?/": "^we(d(nesday)?)?", "/^th(u(r(s(day)?)?)?)?/": "^th(u(r(s(day)?)?)?)?", "/^fr(i(day)?)?/": "^fr(i(day)?)?", "/^sa(t(urday)?)?/": "^sa(t(urday)?)?", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "en-US"; /** * @overview datejs * @version 1.0.0-beta-2014-03-25 * @author Gregory Wild-Smith * @copyright 2014 Gregory Wild-Smith * @license MIT * @homepage https://github.com/abritinthebay/datejs */(function () { var $D = Date; var lang = Date.CultureStrings ? Date.CultureStrings.lang : null; var loggedKeys = {}; // for debug purposes. var __ = function (key, language) { var output, split, length, last; var countryCode = (language) ? language : lang; if (Date.CultureStrings && Date.CultureStrings[countryCode] && Date.CultureStrings[countryCode][key]) { output = Date.CultureStrings[countryCode][key]; } else { switch(key) { case "name": output = "en-US"; break; case "englishName": output = "English (United States)"; break; case "nativeName": output = "English (United States)"; break; case "twoDigitYearMax": output = 2049; break; case "firstDayOfWeek": output = 0; break; default: output = key; split = key.split("_"); length = split.length; if (length > 1 && key.charAt(0) !== "/") { // if the key isn't a regex and it has a split. last = split[(length - 1)].toLowerCase(); if (last === "initial" || last === "abbr") { output = split[0]; } } } } if (key.charAt(0) === "/") { // Assume it's a regex if (Date.CultureStrings && Date.CultureStrings[countryCode] && Date.CultureStrings[countryCode][key]) { output = new RegExp(Date.CultureStrings[countryCode][key], "i"); } else { output = new RegExp(key.replace(new RegExp("/", "g"),""), "i"); } } loggedKeys[key] = key; return output; }; var loadI18nScript = function (code) { // paatterned after jQuery's getScript. var url = Date.Config.i18n + code + '.js'; var head = document.getElementsByTagName("head")[0] || document.documentElement; var script = document.createElement("script"); script.src = url; var completed = false; var events = { done: function (){} // dummy function }; // Attach handlers for all browsers script.onload = script.onreadystatechange = function() { if ( !completed && (!this.readyState || this.readyState === "loaded" || this.readyState === "complete") ) { done = true; events.done(); head.removeChild(script); } }; setTimeout(function() { head.insertBefore(script, head.firstChild); }, 0); // allows return to execute first return { done: function (f) { events.done = function() { if (f) { f(); } }; } }; }; var CultureInfo = function () { var buildTimeZones = function (data) { var zone; for (zone in data.abbreviatedTimeZoneStandard) { if (data.abbreviatedTimeZoneStandard.hasOwnProperty(zone)) { data.timezones.push({ name: zone, offset: data.abbreviatedTimeZoneStandard[zone]}); } } for (zone in data.abbreviatedTimeZoneDST) { if (data.abbreviatedTimeZoneDST.hasOwnProperty(zone)) { data.timezones.push({ name: zone, offset: data.abbreviatedTimeZoneDST[zone], dst: true}); } } return data.timezones; }; var info = { name: __("name"), englishName: __("englishName"), nativeName: __("nativeName"), /* Day Name Strings */ dayNames: [ __("Sunday"), __("Monday"), __("Tuesday"), __("Wednesday"), __("Thursday"), __("Friday"), __("Saturday") ], abbreviatedDayNames: [ __("Sun"), __("Mon"), __("Tue"), __("Wed"), __("Thu"), __("Fri"), __("Sat") ], shortestDayNames: [ __("Su"), __("Mo"), __("Tu"), __("We"), __("Th"), __("Fr"), __("Sa") ], firstLetterDayNames: [ __("S_Sun_Initial"), __("M_Mon_Initial"), __("T_Tues_Initial"), __("W_Wed_Initial"), __("T_Thu_Initial"), __("F_Fri_Initial"), __("S_Sat_Initial") ], /* Month Name Strings */ monthNames: [ __("January"), __("February"), __("March"), __("April"), __("May"), __("June"), __("July"), __("August"), __("September"), __("October"), __("November"), __("December") ], abbreviatedMonthNames: [ __("Jan_Abbr"), __("Feb_Abbr"), __("Mar_Abbr"), __("Apr_Abbr"), __("May_Abbr"), __("Jun_Abbr"), __("Jul_Abbr"), __("Aug_Abbr"), __("Sep_Abbr"), __("Oct_Abbr"), __("Nov_Abbr"), __("Dec_Abbr") ], /* AM/PM Designators */ amDesignator: __("AM"), pmDesignator: __("PM"), firstDayOfWeek: __("firstDayOfWeek"), twoDigitYearMax: __("twoDigitYearMax"), dateElementOrder: __("mdy"), /* Standard date and time format patterns */ formatPatterns: { shortDate: __("M/d/yyyy"), longDate: __("dddd, MMMM dd, yyyy"), shortTime: __("h:mm tt"), longTime: __("h:mm:ss tt"), fullDateTime: __("dddd, MMMM dd, yyyy h:mm:ss tt"), sortableDateTime: __("yyyy-MM-ddTHH:mm:ss"), universalSortableDateTime: __("yyyy-MM-dd HH:mm:ssZ"), rfc1123: __("ddd, dd MMM yyyy HH:mm:ss"), monthDay: __("MMMM dd"), yearMonth: __("MMMM, yyyy") }, regexPatterns: { inTheMorning: __("/( in the )(morn(ing)?)\\b/"), thisMorning: __("/(this )(morn(ing)?)\\b/"), amThisMorning: __("/(\b\\d(am)? )(this )(morn(ing)?)/"), inTheEvening: __("/( in the )(even(ing)?)\\b/"), thisEvening: __("/(this )(even(ing)?)\\b/"), pmThisEvening: __("/(\b\\d(pm)? )(this )(even(ing)?)/"), jan: __("/jan(uary)?/"), feb: __("/feb(ruary)?/"), mar: __("/mar(ch)?/"), apr: __("/apr(il)?/"), may: __("/may/"), jun: __("/jun(e)?/"), jul: __("/jul(y)?/"), aug: __("/aug(ust)?/"), sep: __("/sep(t(ember)?)?/"), oct: __("/oct(ober)?/"), nov: __("/nov(ember)?/"), dec: __("/dec(ember)?/"), sun: __("/^su(n(day)?)?/"), mon: __("/^mo(n(day)?)?/"), tue: __("/^tu(e(s(day)?)?)?/"), wed: __("/^we(d(nesday)?)?/"), thu: __("/^th(u(r(s(day)?)?)?)?/"), fri: __("/fr(i(day)?)?/"), sat: __("/^sa(t(urday)?)?/"), future: __("/^next/"), past: __("/last|past|prev(ious)?/"), add: __("/^(\\+|aft(er)?|from|hence)/"), subtract: __("/^(\\-|bef(ore)?|ago)/"), yesterday: __("/^yes(terday)?/"), today: __("/^t(od(ay)?)?/"), tomorrow: __("/^tom(orrow)?/"), now: __("/^n(ow)?/"), millisecond: __("/^ms|milli(second)?s?/"), second: __("/^sec(ond)?s?/"), minute: __("/^mn|min(ute)?s?/"), hour: __("/^h(our)?s?/"), week: __("/^w(eek)?s?/"), month: __("/^m(onth)?s?/"), day: __("/^d(ay)?s?/"), year: __("/^y(ear)?s?/"), shortMeridian: __("/^(a|p)/"), longMeridian: __("/^(a\\.?m?\\.?|p\\.?m?\\.?)/"), timezone: __("/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/"), ordinalSuffix: __("/^\\s*(st|nd|rd|th)/"), timeContext: __("/^\\s*(\\:|a(?!u|p)|p)/") }, timezones: [], abbreviatedTimeZoneDST: {}, abbreviatedTimeZoneStandard: {} }; info.abbreviatedTimeZoneDST[__("CHADT")] = "+1345"; info.abbreviatedTimeZoneDST[__("NZDT")] = "+1300"; info.abbreviatedTimeZoneDST[__("AEDT")] = "+1100"; info.abbreviatedTimeZoneDST[__("ACDT")] = "+1030"; info.abbreviatedTimeZoneDST[__("AZST")] = "+0500"; info.abbreviatedTimeZoneDST[__("IRDT")] = "+0430"; info.abbreviatedTimeZoneDST[__("EEST")] = "+0300"; info.abbreviatedTimeZoneDST[__("CEST")] = "+0200"; info.abbreviatedTimeZoneDST[__("BST")] = "+0100"; info.abbreviatedTimeZoneDST[__("PMDT")] = "-0200"; info.abbreviatedTimeZoneDST[__("ADT")] = "-0300"; info.abbreviatedTimeZoneDST[__("NDT")] = "-0230"; info.abbreviatedTimeZoneDST[__("EDT")] = "-0400"; info.abbreviatedTimeZoneDST[__("CDT")] = "-0500"; info.abbreviatedTimeZoneDST[__("MDT")] = "-0600"; info.abbreviatedTimeZoneDST[__("PDT")] = "-0700"; info.abbreviatedTimeZoneDST[__("AKDT")] = "-0800"; info.abbreviatedTimeZoneDST[__("HADT")] = "-0900"; info.abbreviatedTimeZoneStandard[__("LINT")] = "+1400"; info.abbreviatedTimeZoneStandard[__("TOT")] = "+1300"; info.abbreviatedTimeZoneStandard[__("CHAST")] = "+1245"; info.abbreviatedTimeZoneStandard[__("NZST")] = "+1200"; info.abbreviatedTimeZoneStandard[__("NFT")] = "+1130"; info.abbreviatedTimeZoneStandard[__("SBT")] = "+1100"; info.abbreviatedTimeZoneStandard[__("AEST")] = "+1000"; info.abbreviatedTimeZoneStandard[__("ACST")] = "+0930"; info.abbreviatedTimeZoneStandard[__("JST")] = "+0900"; info.abbreviatedTimeZoneStandard[__("CWST")] = "+0845"; info.abbreviatedTimeZoneStandard[__("CT")] = "+0800"; info.abbreviatedTimeZoneStandard[__("ICT")] = "+0700"; info.abbreviatedTimeZoneStandard[__("MMT")] = "+0630"; info.abbreviatedTimeZoneStandard[__("BST")] = "+0600"; info.abbreviatedTimeZoneStandard[__("NPT")] = "+0545"; info.abbreviatedTimeZoneStandard[__("IST")] = "+0530"; info.abbreviatedTimeZoneStandard[__("PKT")] = "+0500"; info.abbreviatedTimeZoneStandard[__("AFT")] = "+0430"; info.abbreviatedTimeZoneStandard[__("MSK")] = "+0400"; info.abbreviatedTimeZoneStandard[__("IRST")] = "+0330"; info.abbreviatedTimeZoneStandard[__("FET")] = "+0300"; info.abbreviatedTimeZoneStandard[__("EET")] = "+0200"; info.abbreviatedTimeZoneStandard[__("CET")] = "+0100"; info.abbreviatedTimeZoneStandard[__("GMT")] = "+0000"; info.abbreviatedTimeZoneStandard[__("UTC")] = "+0000"; info.abbreviatedTimeZoneStandard[__("CVT")] = "-0100"; info.abbreviatedTimeZoneStandard[__("GST")] = "-0200"; info.abbreviatedTimeZoneStandard[__("BRT")] = "-0300"; info.abbreviatedTimeZoneStandard[__("NST")] = "-0330"; info.abbreviatedTimeZoneStandard[__("AST")] = "-0400"; info.abbreviatedTimeZoneStandard[__("EST")] = "-0500"; info.abbreviatedTimeZoneStandard[__("CST")] = "-0600"; info.abbreviatedTimeZoneStandard[__("MST")] = "-0700"; info.abbreviatedTimeZoneStandard[__("PST")] = "-0800"; info.abbreviatedTimeZoneStandard[__("AKST")] = "-0900"; info.abbreviatedTimeZoneStandard[__("MIT")] = "-0930"; info.abbreviatedTimeZoneStandard[__("HST")] = "-1000"; info.abbreviatedTimeZoneStandard[__("SST")] = "-1100"; info.abbreviatedTimeZoneStandard[__("BIT")] = "-1200"; buildTimeZones(info); return info; }; $D.i18n = { __: function (key, lang) { return __(key, lang); }, currentLanguage: function () { return lang || "en-US"; }, setLanguage: function (code, force) { if (force || code === "en-US" || (!!Date.CultureStrings && !!Date.CultureStrings[code])) { lang = code; Date.CultureStrings.lang = code; Date.CultureInfo = CultureInfo(); } else { if (!(!!Date.CultureStrings && !!Date.CultureStrings[code])) { if (typeof exports !== 'undefined' && this.exports !== exports) { // we're in a Node enviroment, load it using require try { require("../i18n/" + code + ".js"); lang = code; Date.CultureStrings.lang = code; Date.CultureInfo = CultureInfo(); } catch (e) { // var str = "The language for '" + code + "' could not be loaded by Node. It likely does not exist."; throw new Error("The DateJS IETF language tag '" + code + "' could not be loaded by Node. It likely does not exist."); } } else if (Date.Config && Date.Config.i18n) { // we know the location of the files, so lets load them loadI18nScript(code).done(function(){ lang = code; Date.CultureStrings.lang = code; Date.CultureInfo = CultureInfo(); }); } else { Date.console.error("The DateJS IETF language tag '" + code + "' is not available and has not been loaded."); } } } }, getLoggedKeys: function () { return loggedKeys; }, updateCultureInfo: function () { Date.CultureInfo = CultureInfo(); } }; $D.i18n.updateCultureInfo(); // run automatically }()); (function () { var $D = Date, $P = $D.prototype, p = function (s, l) { if (!l) { l = 2; } return ("000" + s).slice(l * -1); }; if (typeof window !== "undefined" && typeof window.console !== "undefined" && typeof window.console.log !== "undefined") { $D.console = console; // used only to raise non-critical errors if available } else { // set mock so we don't give errors. $D.console = { log: function(){}, error: function(){} }; } $D.Config = {}; $D.initOverloads = function() { /** * Overload of Date.now. Allows an alternate call for Date.now where it returns the * current Date as an object rather than just milliseconds since the Unix Epoch. * * Also provides an implementation of now() for browsers (IE<9) that don't have it. * * Backwards compatible so with work with either: * Date.now() [returns ms] * or * Date.now(true) [returns Date] */ if (!$D.now) { $D._now = function now() { return new Date().getTime(); }; } else if (!$D._now) { $D._now = $D.now; } $D.now = function (returnObj) { if (returnObj) { return $D.present(); } else { return $D._now(); } }; if ( !$P.toISOString ) { $P.toISOString = function() { return this.getUTCFullYear() + "-" + p(this.getUTCMonth() + 1) + "-" + p(this.getUTCDate()) + "T" + p(this.getUTCHours()) + ":" + p(this.getUTCMinutes()) + ":" + p(this.getUTCSeconds()) + "." + String( (this.getUTCMilliseconds()/1000).toFixed(3)).slice(2, 5) + "Z"; }; } // private if ( $P._toString === undefined ){ $P._toString = $P.toString; } }; $D.initOverloads(); /** * Resets the time of this Date object to 12:00 AM (00:00), which is the start of the day. * @param {Boolean} .clone() this date instance before clearing Time * @return {Date} this */ $P.clearTime = function () { this.setHours(0); this.setMinutes(0); this.setSeconds(0); this.setMilliseconds(0); return this; }; /** * Resets the time of this Date object to the current time ('now'). * @return {Date} this */ $P.setTimeToNow = function () { var n = new Date(); this.setHours(n.getHours()); this.setMinutes(n.getMinutes()); this.setSeconds(n.getSeconds()); this.setMilliseconds(n.getMilliseconds()); return this; }; /** * Gets a date that is set to the current date. The time is set to the start of the day (00:00 or 12:00 AM). * @return {Date} The current date. */ $D.today = function () { return new Date().clearTime(); }; /** * Gets a date that is set to the current date and time (same as new Date, but chainable) * @return {Date} The current date. */ $D.present = function () { return new Date(); }; /** * Compares the first date to the second date and returns an number indication of their relative values. * @param {Date} First Date object to compare [Required]. * @param {Date} Second Date object to compare to [Required]. * @return {Number} -1 = date1 is lessthan date2. 0 = values are equal. 1 = date1 is greaterthan date2. */ $D.compare = function (date1, date2) { if (isNaN(date1) || isNaN(date2)) { throw new Error(date1 + " - " + date2); } else if (date1 instanceof Date && date2 instanceof Date) { return (date1 < date2) ? -1 : (date1 > date2) ? 1 : 0; } else { throw new TypeError(date1 + " - " + date2); } }; /** * Compares the first Date object to the second Date object and returns true if they are equal. * @param {Date} First Date object to compare [Required] * @param {Date} Second Date object to compare to [Required] * @return {Boolean} true if dates are equal. false if they are not equal. */ $D.equals = function (date1, date2) { return (date1.compareTo(date2) === 0); }; /** * Gets the language appropriate day name when given the day number(0-6) * eg - 0 == Sunday * @return {String} The day name */ $D.getDayName = function (n) { return Date.CultureInfo.dayNames[n]; }; /** * Gets the day number (0-6) if given a CultureInfo specific string which is a valid dayName, abbreviatedDayName or shortestDayName (two char). * @param {String} The name of the day (eg. "Monday, "Mon", "tuesday", "tue", "We", "we"). * @return {Number} The day number */ $D.getDayNumberFromName = function (name) { var n = Date.CultureInfo.dayNames, m = Date.CultureInfo.abbreviatedDayNames, o = Date.CultureInfo.shortestDayNames, s = name.toLowerCase(); for (var i = 0; i < n.length; i++) { if (n[i].toLowerCase() === s || m[i].toLowerCase() === s || o[i].toLowerCase() === s) { return i; } } return -1; }; /** * Gets the month number (0-11) if given a Culture Info specific string which is a valid monthName or abbreviatedMonthName. * @param {String} The name of the month (eg. "February, "Feb", "october", "oct"). * @return {Number} The day number */ $D.getMonthNumberFromName = function (name) { var n = Date.CultureInfo.monthNames, m = Date.CultureInfo.abbreviatedMonthNames, s = name.toLowerCase(); for (var i = 0; i < n.length; i++) { if (n[i].toLowerCase() === s || m[i].toLowerCase() === s) { return i; } } return -1; }; /** * Gets the language appropriate month name when given the month number(0-11) * eg - 0 == January * @return {String} The month name */ $D.getMonthName = function (n) { return Date.CultureInfo.monthNames[n]; }; /** * Determines if the current date instance is within a LeapYear. * @param {Number} The year. * @return {Boolean} true if date is within a LeapYear, otherwise false. */ $D.isLeapYear = function (year) { return ((year % 4 === 0 && year % 100 !== 0) || year % 400 === 0); }; /** * Gets the number of days in the month, given a year and month value. Automatically corrects for LeapYear. * @param {Number} The year. * @param {Number} The month (0-11). * @return {Number} The number of days in the month. */ $D.getDaysInMonth = function (year, month) { if (!month && $D.validateMonth(year)) { month = year; year = Date.today().getFullYear(); } return [31, ($D.isLeapYear(year) ? 29 : 28), 31, 30, 31, 30, 31, 31, 30, 31, 30, 31][month]; }; $D.getTimezoneAbbreviation = function (offset, dst) { var p, n = (dst || false) ? Date.CultureInfo.abbreviatedTimeZoneDST : Date.CultureInfo.abbreviatedTimeZoneStandard; for (p in n) { if (n.hasOwnProperty(p)) { if (n[p] === offset) { return p; } } } return null; }; $D.getTimezoneOffset = function (name, dst) { var i, a =[], z = Date.CultureInfo.timezones; if (!name) { name = (new Date()).getTimezone()} for (i = 0; i < z.length; i++) { if (z[i].name === name.toUpperCase()) { a.push(i); } } if (!z[a[0]]) { return null; } if (a.length === 1 || !dst) { return z[a[0]].offset; } else { for (i=0; i < a.length; i++) { if (z[a[i]].dst) { return z[a[i]].offset; } } } }; $D.getQuarter = function (d) { d = d || new Date(); // If no date supplied, use today var q = [1,2,3,4]; return q[Math.floor(d.getMonth() / 3)]; // ~~~ is a bitwise op. Faster than Math.floor }; $D.getDaysLeftInQuarter = function (d) { d = d || new Date(); var qEnd = new Date(d); qEnd.setMonth(qEnd.getMonth() + 3 - qEnd.getMonth() % 3, 0); return Math.floor((qEnd - d) / 8.64e7); }; /** * Returns a new Date object that is an exact date and time copy of the original instance. * @return {Date} A new Date instance */ $P.clone = function () { return new Date(this.getTime()); }; /** * Compares this instance to a Date object and returns an number indication of their relative values. * @param {Date} Date object to compare [Required] * @return {Number} -1 = this is lessthan date. 0 = values are equal. 1 = this is greaterthan date. */ $P.compareTo = function (date) { return Date.compare(this, date); }; /** * Compares this instance to another Date object and returns true if they are equal. * @param {Date} Date object to compare. If no date to compare, new Date() [now] is used. * @return {Boolean} true if dates are equal. false if they are not equal. */ $P.equals = function (date) { return Date.equals(this, (date !== undefined ? date : new Date())); }; /** * Determines if this instance is between a range of two dates or equal to either the start or end dates. * @param {Date} Start of range [Required] * @param {Date} End of range [Required] * @return {Boolean} true is this is between or equal to the start and end dates, else false */ $P.between = function (start, end) { return this.getTime() >= start.getTime() && this.getTime() <= end.getTime(); }; /** * Determines if this date occurs after the date to compare to. * @param {Date} Date object to compare. If no date to compare, new Date() ("now") is used. * @return {Boolean} true if this date instance is greater than the date to compare to (or "now"), otherwise false. */ $P.isAfter = function (date) { return this.compareTo(date || new Date()) === 1; }; /** * Determines if this date occurs before the date to compare to. * @param {Date} Date object to compare. If no date to compare, new Date() ("now") is used. * @return {Boolean} true if this date instance is less than the date to compare to (or "now"). */ $P.isBefore = function (date) { return (this.compareTo(date || new Date()) === -1); }; /** * Determines if the current Date instance occurs today. * @return {Boolean} true if this date instance is 'today', otherwise false. */ /** * Determines if the current Date instance occurs on the same Date as the supplied 'date'. * If no 'date' to compare to is provided, the current Date instance is compared to 'today'. * @param {date} Date object to compare. If no date to compare, the current Date ("now") is used. * @return {Boolean} true if this Date instance occurs on the same Day as the supplied 'date'. */ $P.isToday = $P.isSameDay = function (date) { return this.clone().clearTime().equals((date || new Date()).clone().clearTime()); }; /** * Adds the specified number of milliseconds to this instance. * @param {Number} The number of milliseconds to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addMilliseconds = function (value) { if (!value) { return this; } this.setTime(this.getTime() + value * 1); return this; }; /** * Adds the specified number of seconds to this instance. * @param {Number} The number of seconds to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addSeconds = function (value) { if (!value) { return this; } return this.addMilliseconds(value * 1000); }; /** * Adds the specified number of seconds to this instance. * @param {Number} The number of seconds to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addMinutes = function (value) { if (!value) { return this; } return this.addMilliseconds(value * 60000); /* 60*1000 */ }; /** * Adds the specified number of hours to this instance. * @param {Number} The number of hours to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addHours = function (value) { if (!value) { return this; } return this.addMilliseconds(value * 3600000); /* 60*60*1000 */ }; /** * Adds the specified number of days to this instance. * @param {Number} The number of days to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addDays = function (value) { if (!value) { return this; } this.setDate(this.getDate() + value * 1); return this; }; /** * Adds the specified number of weekdays (ie - not sat or sun) to this instance. * @param {Number} The number of days to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addWeekdays = function (value) { if (!value) { return this; } var day = this.getDay(); var weeks = (Math.ceil(Math.abs(value)/7)); if (day === 0 || day === 6) { if (value > 0) { this.next().monday(); this.addDays(-1); } } if (value < 0) { while (value < 0) { this.addDays(-1); day = this.getDay(); if (day !== 0 && day !== 6) { value++; } } return this; } else if (value > 5 || (6-day) <= value) { value = value + (weeks * 2); } return this.addDays(value); }; /** * Adds the specified number of weeks to this instance. * @param {Number} The number of weeks to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addWeeks = function (value) { if (!value) { return this; } return this.addDays(value * 7); }; /** * Adds the specified number of months to this instance. * @param {Number} The number of months to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addMonths = function (value) { if (!value) { return this; } var n = this.getDate(); this.setDate(1); this.setMonth(this.getMonth() + value * 1); this.setDate(Math.min(n, $D.getDaysInMonth(this.getFullYear(), this.getMonth()))); return this; }; $P.addQuarters = function (value) { if (!value) { return this; } // note this will take you to the same point in the quarter as you are now. // i.e. - if you are 15 days into the quarter you'll be 15 days into the resulting one. // bonus: this allows adding fractional quarters return this.addMonths(value * 3); }; /** * Adds the specified number of years to this instance. * @param {Number} The number of years to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addYears = function (value) { if (!value) { return this; } return this.addMonths(value * 12); }; /** * Adds (or subtracts) to the value of the years, months, weeks, days, hours, minutes, seconds, milliseconds of the date instance using given configuration object. Positive and Negative values allowed. * Example

	Date.today().add( { days: 1, months: 1 } )
	 
	new Date().add( { years: -1 } )
	
* @param {Object} Configuration object containing attributes (months, days, etc.) * @return {Date} this */ $P.add = function (config) { if (typeof config === "number") { this._orient = config; return this; } var x = config; if (x.day) { // If we should be a different date than today (eg: for 'tomorrow -1d', etc). // Should only effect parsing, not direct usage (eg, Finish and FinishExact) if ((x.day - this.getDate()) !== 0) { this.setDate(x.day); } } if (x.milliseconds) { this.addMilliseconds(x.milliseconds); } if (x.seconds) { this.addSeconds(x.seconds); } if (x.minutes) { this.addMinutes(x.minutes); } if (x.hours) { this.addHours(x.hours); } if (x.weeks) { this.addWeeks(x.weeks); } if (x.months) { this.addMonths(x.months); } if (x.years) { this.addYears(x.years); } if (x.days) { this.addDays(x.days); } return this; }; /** * Get the week number. Week one (1) is the week which contains the first Thursday of the year. Monday is considered the first day of the week. * The .getWeek() function does NOT convert the date to UTC. The local datetime is used. * Please use .getISOWeek() to get the week of the UTC converted date. * @return {Number} 1 to 53 */ $P.getWeek = function (utc) { // Create a copy of this date object var self, target = new Date(this.valueOf()); if (utc) { target.addMinutes(target.getTimezoneOffset()); self = target.clone(); } else { self = this; } // ISO week date weeks start on monday // so correct the day number var dayNr = (self.getDay() + 6) % 7; // ISO 8601 states that week 1 is the week // with the first thursday of that year. // Set the target date to the thursday in the target week target.setDate(target.getDate() - dayNr + 3); // Store the millisecond value of the target date var firstThursday = target.valueOf(); // Set the target to the first thursday of the year // First set the target to january first target.setMonth(0, 1); // Not a thursday? Correct the date to the next thursday if (target.getDay() !== 4) { target.setMonth(0, 1 + ((4 - target.getDay()) + 7) % 7); } // The weeknumber is the number of weeks between the // first thursday of the year and the thursday in the target week return 1 + Math.ceil((firstThursday - target) / 604800000); // 604800000 = 7 * 24 * 3600 * 1000 }; /** * Get the ISO 8601 week number. Week one ("01") is the week which contains the first Thursday of the year. Monday is considered the first day of the week. * The .getISOWeek() function does convert the date to it's UTC value. Please use .getWeek() to get the week of the local date. * @return {String} "01" to "53" */ $P.getISOWeek = function () { return p(this.getWeek(true)); }; /** * Moves the date to Monday of the week set. Week one (1) is the week which contains the first Thursday of the year. * @param {Number} A Number (1 to 53) that represents the week of the year. * @return {Date} this */ $P.setWeek = function (n) { if ((n - this.getWeek()) === 0) { if (this.getDay() !== 1) { return this.moveToDayOfWeek(1, (this.getDay() > 1 ? -1 : 1)); } else { return this; } } else { return this.moveToDayOfWeek(1, (this.getDay() > 1 ? -1 : 1)).addWeeks(n - this.getWeek()); } }; $P.setQuarter = function (qtr) { var month = Math.abs(((qtr-1) * 3) + 1); return this.setMonth(month, 1); }; $P.getQuarter = function () { return Date.getQuarter(this); }; $P.getDaysLeftInQuarter = function () { return Date.getDaysLeftInQuarter(this); }; // private var validate = function (n, min, max, name) { name = name ? name : "Object"; if (typeof n === "undefined") { return false; } else if (typeof n !== "number") { throw new TypeError(n + " is not a Number."); } else if (n < min || n > max) { // As failing validation is *not* an exceptional circumstance // lets not throw a RangeError Exception here. // It's semantically correct but it's not sensible. return false; } return true; }; /** * Validates the number is within an acceptable range for milliseconds [0-999]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateMillisecond = function (value) { return validate(value, 0, 999, "millisecond"); }; /** * Validates the number is within an acceptable range for seconds [0-59]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateSecond = function (value) { return validate(value, 0, 59, "second"); }; /** * Validates the number is within an acceptable range for minutes [0-59]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateMinute = function (value) { return validate(value, 0, 59, "minute"); }; /** * Validates the number is within an acceptable range for hours [0-23]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateHour = function (value) { return validate(value, 0, 23, "hour"); }; /** * Validates the number is within an acceptable range for the days in a month [0-MaxDaysInMonth]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateDay = function (value, year, month) { return validate(value, 1, $D.getDaysInMonth(year, month), "day"); }; /** * Validates the number is within an acceptable range for months [0-11]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateWeek = function (value) { return validate(value, 0, 53, "week"); }; /** * Validates the number is within an acceptable range for months [0-11]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateMonth = function (value) { return validate(value, 0, 11, "month"); }; /** * Validates the number is within an acceptable range for years. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateYear = function (value) { /** * Per ECMAScript spec the range of times supported by Date objects is * exactly –100,000,000 days to 100,000,000 days measured relative to * midnight at the beginning of 01 January, 1970 UTC. * This gives a range of 8,640,000,000,000,000 milliseconds to either * side of 01 January, 1970 UTC. * * Earliest possible date: Tue, 20 Apr 271,822 B.C. 00:00:00 UTC * Latest possible date: Sat, 13 Sep 275,760 00:00:00 UTC */ return validate(value, -271822, 275760, "year"); }; /** * Set the value of year, month, day, hour, minute, second, millisecond of date instance using given configuration object. * Example

	Date.today().set( { day: 20, month: 1 } )

	new Date().set( { millisecond: 0 } )
	
* * @param {Object} Configuration object containing attributes (month, day, etc.) * @return {Date} this */ $P.set = function (config) { if ($D.validateMillisecond(config.millisecond)) { this.addMilliseconds(config.millisecond - this.getMilliseconds()); } if ($D.validateSecond(config.second)) { this.addSeconds(config.second - this.getSeconds()); } if ($D.validateMinute(config.minute)) { this.addMinutes(config.minute - this.getMinutes()); } if ($D.validateHour(config.hour)) { this.addHours(config.hour - this.getHours()); } if ($D.validateMonth(config.month)) { this.addMonths(config.month - this.getMonth()); } if ($D.validateYear(config.year)) { this.addYears(config.year - this.getFullYear()); } /* day has to go last because you can't validate the day without first knowing the month */ if ($D.validateDay(config.day, this.getFullYear(), this.getMonth())) { this.addDays(config.day - this.getDate()); } if (config.timezone) { this.setTimezone(config.timezone); } if (config.timezoneOffset) { this.setTimezoneOffset(config.timezoneOffset); } if (config.week && $D.validateWeek(config.week)) { this.setWeek(config.week); } return this; }; /** * Moves the date to the first day of the month. * @return {Date} this */ $P.moveToFirstDayOfMonth = function () { return this.set({ day: 1 }); }; /** * Moves the date to the last day of the month. * @return {Date} this */ $P.moveToLastDayOfMonth = function () { return this.set({ day: $D.getDaysInMonth(this.getFullYear(), this.getMonth())}); }; /** * Moves the date to the next n'th occurrence of the dayOfWeek starting from the beginning of the month. The number (-1) is a magic number and will return the last occurrence of the dayOfWeek in the month. * @param {Number} The dayOfWeek to move to * @param {Number} The n'th occurrence to move to. Use (-1) to return the last occurrence in the month * @return {Date} this */ $P.moveToNthOccurrence = function (dayOfWeek, occurrence) { if (dayOfWeek === "Weekday") { if (occurrence > 0) { this.moveToFirstDayOfMonth(); if (this.is().weekday()) { occurrence -= 1; } } else if (occurrence < 0) { this.moveToLastDayOfMonth(); if (this.is().weekday()) { occurrence += 1; } } else { return this; } return this.addWeekdays(occurrence); } var shift = 0; if (occurrence > 0) { shift = occurrence - 1; } else if (occurrence === -1) { this.moveToLastDayOfMonth(); if (this.getDay() !== dayOfWeek) { this.moveToDayOfWeek(dayOfWeek, -1); } return this; } return this.moveToFirstDayOfMonth().addDays(-1).moveToDayOfWeek(dayOfWeek, +1).addWeeks(shift); }; /** * Move to the next or last dayOfWeek based on the orient value. * @param {Number} The dayOfWeek to move to * @param {Number} Forward (+1) or Back (-1). Defaults to +1. [Optional] * @return {Date} this */ $P.moveToDayOfWeek = function (dayOfWeek, orient) { var diff = (dayOfWeek - this.getDay() + 7 * (orient || +1)) % 7; return this.addDays((diff === 0) ? diff += 7 * (orient || +1) : diff); }; /** * Move to the next or last month based on the orient value. * @param {Number} The month to move to. 0 = January, 11 = December * @param {Number} Forward (+1) or Back (-1). Defaults to +1. [Optional] * @return {Date} this */ $P.moveToMonth = function (month, orient) { var diff = (month - this.getMonth() + 12 * (orient || +1)) % 12; return this.addMonths((diff === 0) ? diff += 12 * (orient || +1) : diff); }; /** * Get the Ordinate of the current day ("th", "st", "rd"). * @return {String} */ $P.getOrdinate = function () { var num = this.getDate(); return ord(num); }; /** * Get the Ordinal day (numeric day number) of the year, adjusted for leap year. * @return {Number} 1 through 365 (366 in leap years) */ $P.getOrdinalNumber = function () { return Math.ceil((this.clone().clearTime() - new Date(this.getFullYear(), 0, 1)) / 86400000) + 1; }; /** * Get the time zone abbreviation of the current date. * @return {String} The abbreviated time zone name (e.g. "EST") */ $P.getTimezone = function () { return $D.getTimezoneAbbreviation(this.getUTCOffset(), this.isDaylightSavingTime()); }; $P.setTimezoneOffset = function (offset) { var here = this.getTimezoneOffset(), there = Number(offset) * -6 / 10; return (there || there === 0) ? this.addMinutes(there - here) : this; }; $P.setTimezone = function (offset) { return this.setTimezoneOffset($D.getTimezoneOffset(offset)); }; /** * Indicates whether Daylight Saving Time is observed in the current time zone. * @return {Boolean} true|false */ $P.hasDaylightSavingTime = function () { return (Date.today().set({month: 0, day: 1}).getTimezoneOffset() !== Date.today().set({month: 6, day: 1}).getTimezoneOffset()); }; /** * Indicates whether this Date instance is within the Daylight Saving Time range for the current time zone. * @return {Boolean} true|false */ $P.isDaylightSavingTime = function () { return Date.today().set({month: 0, day: 1}).getTimezoneOffset() !== this.getTimezoneOffset(); }; /** * Get the offset from UTC of the current date. * @return {String} The 4-character offset string prefixed with + or - (e.g. "-0500") */ $P.getUTCOffset = function (offset) { var n = (offset || this.getTimezoneOffset()) * -10 / 6, r; if (n < 0) { r = (n - 10000).toString(); return r.charAt(0) + r.substr(2); } else { r = (n + 10000).toString(); return "+" + r.substr(1); } }; /** * Returns the number of milliseconds between this date and date. * @param {Date} Defaults to now * @return {Number} The diff in milliseconds */ $P.getElapsed = function (date) { return (date || new Date()) - this; }; /** * Converts the value of the current Date object to its equivalent string representation. * Format Specifiers
	CUSTOM DATE AND TIME FORMAT STRINGS
	Format  Description                                                                  Example
	------  ---------------------------------------------------------------------------  -----------------------
	 s      The seconds of the minute between 0-59.                                      "0" to "59"
	 ss     The seconds of the minute with leading zero if required.                     "00" to "59"
	 
	 m      The minute of the hour between 0-59.                                         "0"  or "59"
	 mm     The minute of the hour with leading zero if required.                        "00" or "59"
	 
	 h      The hour of the day between 1-12.                                            "1"  to "12"
	 hh     The hour of the day with leading zero if required.                           "01" to "12"
	 
	 H      The hour of the day between 0-23.                                            "0"  to "23"
	 HH     The hour of the day with leading zero if required.                           "00" to "23"
	 
	 d      The day of the month between 1 and 31.                                       "1"  to "31"
	 dd     The day of the month with leading zero if required.                          "01" to "31"
	 ddd    Abbreviated day name. Date.CultureInfo.abbreviatedDayNames.                                "Mon" to "Sun" 
	 dddd   The full day name. Date.CultureInfo.dayNames.                                              "Monday" to "Sunday"
	 
	 M      The month of the year between 1-12.                                          "1" to "12"
	 MM     The month of the year with leading zero if required.                         "01" to "12"
	 MMM    Abbreviated month name. Date.CultureInfo.abbreviatedMonthNames.                            "Jan" to "Dec"
	 MMMM   The full month name. Date.CultureInfo.monthNames.                                          "January" to "December"

	 yy     The year as a two-digit number.                                              "99" or "08"
	 yyyy   The full four digit year.                                                    "1999" or "2008"
	 
	 t      Displays the first character of the A.M./P.M. designator.                    "A" or "P"
			Date.CultureInfo.amDesignator or Date.CultureInfo.pmDesignator
	 tt     Displays the A.M./P.M. designator.                                           "AM" or "PM"
			Date.CultureInfo.amDesignator or Date.CultureInfo.pmDesignator
	 
	 S      The ordinal suffix ("st, "nd", "rd" or "th") of the current day.            "st, "nd", "rd" or "th"

|| *Format* || *Description* || *Example* ||
|| d      || The CultureInfo shortDate Format Pattern                                     || "M/d/yyyy" ||
|| D      || The CultureInfo longDate Format Pattern                                      || "dddd, MMMM dd, yyyy" ||
|| F      || The CultureInfo fullDateTime Format Pattern                                  || "dddd, MMMM dd, yyyy h:mm:ss tt" ||
|| m      || The CultureInfo monthDay Format Pattern                                      || "MMMM dd" ||
|| r      || The CultureInfo rfc1123 Format Pattern                                       || "ddd, dd MMM yyyy HH:mm:ss GMT" ||
|| s      || The CultureInfo sortableDateTime Format Pattern                              || "yyyy-MM-ddTHH:mm:ss" ||
|| t      || The CultureInfo shortTime Format Pattern                                     || "h:mm tt" ||
|| T      || The CultureInfo longTime Format Pattern                                      || "h:mm:ss tt" ||
|| u      || The CultureInfo universalSortableDateTime Format Pattern                     || "yyyy-MM-dd HH:mm:ssZ" ||
|| y      || The CultureInfo yearMonth Format Pattern                                     || "MMMM, yyyy" ||
	 

	STANDARD DATE AND TIME FORMAT STRINGS
	Format  Description                                                                  Example ("en-US")
	------  ---------------------------------------------------------------------------  -----------------------
	 d      The CultureInfo shortDate Format Pattern                                     "M/d/yyyy"
	 D      The CultureInfo longDate Format Pattern                                      "dddd, MMMM dd, yyyy"
	 F      The CultureInfo fullDateTime Format Pattern                                  "dddd, MMMM dd, yyyy h:mm:ss tt"
	 m      The CultureInfo monthDay Format Pattern                                      "MMMM dd"
	 r      The CultureInfo rfc1123 Format Pattern                                       "ddd, dd MMM yyyy HH:mm:ss GMT"
	 s      The CultureInfo sortableDateTime Format Pattern                              "yyyy-MM-ddTHH:mm:ss"
	 t      The CultureInfo shortTime Format Pattern                                     "h:mm tt"
	 T      The CultureInfo longTime Format Pattern                                      "h:mm:ss tt"
	 u      The CultureInfo universalSortableDateTime Format Pattern                     "yyyy-MM-dd HH:mm:ssZ"
	 y      The CultureInfo yearMonth Format Pattern                                     "MMMM, yyyy"
	
* @param {String} A format string consisting of one or more format spcifiers [Optional]. * @return {String} A string representation of the current Date object. */ var ord = function (n) { switch (n * 1) { case 1: case 21: case 31: return "st"; case 2: case 22: return "nd"; case 3: case 23: return "rd"; default: return "th"; } }; $P.toString = function (format, ignoreStandards) { var x = this; // Standard Date and Time Format Strings. Formats pulled from CultureInfo file and // may vary by culture. if (!ignoreStandards && format && format.length === 1) { var y, c = Date.CultureInfo.formatPatterns; x.t = x.toString; switch (format) { case "d": return x.t(c.shortDate); case "D": return x.t(c.longDate); case "F": return x.t(c.fullDateTime); case "m": return x.t(c.monthDay); case "r": case "R": y = x.clone().addMinutes(x.getTimezoneOffset()); return y.toString(c.rfc1123) + " GMT"; case "s": return x.t(c.sortableDateTime); case "t": return x.t(c.shortTime); case "T": return x.t(c.longTime); case "u": y = x.clone().addMinutes(x.getTimezoneOffset()); return y.toString(c.universalSortableDateTime); case "y": return x.t(c.yearMonth); } } return format ? format.replace(/((\\)?(dd?d?d?|MM?M?M?|yy?y?y?|hh?|HH?|mm?|ss?|tt?|S|q|Q|WW?W?W?)(?![^\[]*\]))/g, function (m) { if (m.charAt(0) === "\\") { return m.replace("\\", ""); } x.h = x.getHours; switch (m) { case "hh": return p(x.h() < 13 ? (x.h() === 0 ? 12 : x.h()) : (x.h() - 12)); case "h": return x.h() < 13 ? (x.h() === 0 ? 12 : x.h()) : (x.h() - 12); case "HH": return p(x.h()); case "H": return x.h(); case "mm": return p(x.getMinutes()); case "m": return x.getMinutes(); case "ss": return p(x.getSeconds()); case "s": return x.getSeconds(); case "yyyy": return p(x.getFullYear(), 4); case "yy": return p(x.getFullYear()); case "dddd": return Date.CultureInfo.dayNames[x.getDay()]; case "ddd": return Date.CultureInfo.abbreviatedDayNames[x.getDay()]; case "dd": return p(x.getDate()); case "d": return x.getDate(); case "MMMM": return Date.CultureInfo.monthNames[x.getMonth()]; case "MMM": return Date.CultureInfo.abbreviatedMonthNames[x.getMonth()]; case "MM": return p((x.getMonth() + 1)); case "M": return x.getMonth() + 1; case "t": return x.h() < 12 ? Date.CultureInfo.amDesignator.substring(0, 1) : Date.CultureInfo.pmDesignator.substring(0, 1); case "tt": return x.h() < 12 ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator; case "S": return ord(x.getDate()); case "W": return x.getWeek(); case "WW": return x.getISOWeek(); case "Q": return "Q" + x.getQuarter(); case "q": return String(x.getQuarter()); default: return m; } }).replace(/\[|\]/g, "") : this._toString(); }; }()); (function () { "use strict"; Date.Parsing = { Exception: function (s) { this.message = "Parse error at '" + s.substring(0, 10) + " ...'"; } }; var $P = Date.Parsing; var dayOffsets = { standard: [0,31,59,90,120,151,181,212,243,273,304,334], leap: [0,31,60,91,121,152,182,213,244,274,305,335] }; $P.isLeapYear = function(year) { return ((year % 4 === 0) && (year % 100 !== 0)) || (year % 400 === 0); }; $P.processTimeObject = function (obj) { var d, jan4, date, offset, dayOffset; d = new Date(); dayOffset = ($P.isLeapYear(obj.year)) ? dayOffsets.leap : dayOffsets.standard; obj.hours = obj.hours ? obj.hours : 0; obj.minutes = obj.minutes ? obj.minutes : 0; obj.seconds = obj.seconds ? obj.seconds : 0; obj.milliseconds = obj.milliseconds ? obj.milliseconds : 0; if (!obj.year) { obj.year = d.getFullYear(); } if (!obj.month && (obj.week || obj.dayOfYear)) { // work out the day of the year... if (!obj.dayOfYear) { obj.weekDay = (!obj.weekDay && obj.weekDay !== 0) ? 1 : obj.weekDay; d = new Date(obj.year, 0, 4); jan4 = d.getDay() === 0 ? 7 : d.getDay(); // JS is 0 indexed on Sunday. offset = jan4+3; obj.dayOfYear = ((obj.week * 7) + (obj.weekDay === 0 ? 7 : obj.weekDay))-offset; } for (var i=0;i <= dayOffset.length;i++) { if (obj.dayOfYear < dayOffset[i] || i === dayOffset.length) { obj.day = obj.day ? obj.day : (obj.dayOfYear - dayOffset[i-1]); break; } else { obj.month = i; } } } else { obj.month = obj.month ? obj.month : 0; obj.day = obj.day ? obj.day : 1; obj.dayOfYear = dayOffset[obj.month] + obj.day; } date = new Date(obj.year, obj.month, obj.day, obj.hours, obj.minutes, obj.seconds, obj.milliseconds); if (obj.zone) { // adjust (and calculate) for timezone here if (obj.zone.toUpperCase() === "Z" || (obj.zone_hours === 0 && obj.zone_minutes === 0)) { // it's UTC/GML so work out the current timeszone offset offset = -date.getTimezoneOffset(); } else { offset = (obj.zone_hours*60) + (obj.zone_minutes ? obj.zone_minutes : 0); if (obj.zone_sign === "+") { offset *= -1; } offset -= date.getTimezoneOffset(); } date.setMinutes(date.getMinutes()+offset); } return date; }; $P.ISO = { regex : /^([\+-]?\d{4}(?!\d{2}\b))((-?)((0[1-9]|1[0-2])(\3([12]\d|0[1-9]|3[01]))?|W([0-4]\d|5[0-3])(-?[1-7])?|(00[1-9]|0[1-9]\d|[12]\d{2}|3([0-5]\d|6[1-6])))([T\s]((([01]\d|2[0-4])((:?)[0-5]\d)?|24\:?00)([\.,]\d+(?!:))?)?(\17[0-5]\d([\.,]\d+)?)?\s?([zZ]|([\+-])([01]\d|2[0-3]):?([0-5]\d)?)?)?)?$/, parse : function (s) { var data = s.match(this.regex); if (!data || !data.length) { return null; } var time = { year : data[1] ? Number(data[1]) : data[1], month : data[5] ? (Number(data[5])-1) : data[5], day : data[7] ? Number(data[7]) : data[7], week : data[8] ? Number(data[8]) : data[8], weekDay : data[9] ? (Math.abs(Number(data[9])) === 7 ? 0 : Math.abs(Number(data[9]))) : data[9], // 1-7, starts on Monday. Convert to JS's 0-6 index. dayOfYear : data[10] ? Number(data[10]) : data[10], hours : data[15] ? Number(data[15]) : data[15], minutes : data[16] ? Number(data[16].replace(":","")) : data[16], seconds : data[19] ? Math.floor(Number(data[19].replace(":","").replace(",","."))) : data[19], milliseconds : data[20] ? (Number(data[20].replace(",","."))*1000) : data[20], zone : data[21], zone_sign : data[22], zone_hours : (data[23] && typeof data[23] !== "undefined") ? Number(data[23]) : data[23], zone_minutes : (data[24] && typeof data[23] !== "undefined") ? Number(data[24]) : data[24] }; if (data[18]) { data[18] = 60 * Number(data[18].replace(",", ".")); if (!time.minutes) { time.minutes = data[18]; } else if (!time.seconds) { time.seconds = data[18]; } } if (!time.year || (!time.year && (!time.month && !time.day) && (!time.week && !time.dayOfYear)) ) { return null; } return $P.processTimeObject(time); } }; $P.Numeric = { isNumeric: function (e){return!isNaN(parseFloat(e))&&isFinite(e)}, regex: /\b([0-1]?[0-9])([0-3]?[0-9])([0-2]?[0-9]?[0-9][0-9])\b/i, parse: function (s) { var data, i, time = {}, order = Date.CultureInfo.dateElementOrder.split(""); if (!(this.isNumeric(s)) || // if it's non-numeric OR (s[0] === "+" && s[0] === "-")) { // It's an arithmatic string (eg +/-1000) return null; } if (s.length < 5) { // assume it's just a year. time.year = s; return $P.processTimeObject(time); } data = s.match(this.regex); if (!data || !data.length) { return null; } for (i=0; i < order.length; i++) { switch(order[i]) { case "d": time.day = data[i+1]; break; case "m": time.month = (data[i+1]-1); break; case "y": time.year = data[i+1]; break; } } return $P.processTimeObject(time); } }; $P.Normalizer = { parse: function (s) { var $C = Date.CultureInfo; var $R = Date.CultureInfo.regexPatterns; var __ = Date.i18n.__; s = s.replace($R.jan.source, "January"); s = s.replace($R.feb, "February"); s = s.replace($R.mar, "March"); s = s.replace($R.apr, "April"); s = s.replace($R.may, "May"); s = s.replace($R.jun, "June"); s = s.replace($R.jul, "July"); s = s.replace($R.aug, "August"); s = s.replace($R.sep, "September"); s = s.replace($R.oct, "October"); s = s.replace($R.nov, "November"); s = s.replace($R.dec, "December"); s = s.replace($R.tomorrow, Date.today().addDays(1).toString("d")); s = s.replace($R.yesterday, Date.today().addDays(-1).toString("d")); // s = s.replace(new RegExp($R.today.source + "\\b", "i"), Date.today().toString("d")); s = s.replace(/\bat\b/gi, ""); // replace "at", eg: "tomorrow at 3pm" s = s.replace(/\s{2,}/, " "); // repliace multiple spaces with one. s = s.replace(new RegExp("(\\b\\d\\d?("+__("AM")+"|"+__("PM")+")? )("+$R.tomorrow.source.slice(1)+")", "i"), function(full, m1, m2, m3, m4) { var t = Date.today().addDays(1).toString("d"); var s = t + " " + m1; return s; }); s = s.replace(new RegExp("(("+$R.past.source+')\\s('+$R.mon.source+'))'), Date.today().last().monday().toString("d")); s = s.replace(new RegExp("(("+$R.past.source+')\\s('+$R.tue.source+'))'), Date.today().last().tuesday().toString("d")); s = s.replace(new RegExp("(("+$R.past.source+')\\s('+$R.wed.source+'))'), Date.today().last().wednesday().toString("d")); s = s.replace(new RegExp("(("+$R.past.source+')\\s('+$R.thu.source+'))'), Date.today().last().thursday().toString("d")); s = s.replace(new RegExp("(("+$R.past.source+')\\s('+$R.fri.source+'))'), Date.today().last().friday().toString("d")); s = s.replace(new RegExp("(("+$R.past.source+')\\s('+$R.sat.source+'))'), Date.today().last().saturday().toString("d")); s = s.replace(new RegExp("(("+$R.past.source+')\\s('+$R.sun.source+'))'), Date.today().last().sunday().toString("d")); // s = s.replace($R.thisMorning, "9am")) s = s.replace($R.amThisMorning, function(str, am){return am;}); s = s.replace($R.inTheMorning, "am"); s = s.replace($R.thisMorning, "9am"); s = s.replace($R.amThisEvening, function(str, pm){return pm;}); s = s.replace($R.inTheEvening, "pm"); s = s.replace($R.thisEvening, "7pm"); try { var n = s.split(/([\s\-\.\,\/\x27]+)/); if (n.length === 3) { if ($P.Numeric.isNumeric(n[0]) && $P.Numeric.isNumeric(n[2])) { if (n[2].length >= 4) { // ok, so we're dealing with x/year. But that's not a full date. // This fixes wonky dateElementOrder parsing when set to dmy order. if (Date.CultureInfo.dateElementOrder[0] === 'd') { s = '1/' + n[0] + '/' + n[2]; // set to 1st of month and normalize the seperator } } } } } catch (e) { // continue... } return s; } }; }()); (function () { var $P = Date.Parsing; var _ = $P.Operators = { // // Tokenizers // rtoken: function (r) { // regex token return function (s) { var mx = s.match(r); if (mx) { return ([ mx[0], s.substring(mx[0].length) ]); } else { throw new $P.Exception(s); } }; }, token: function (s) { // whitespace-eating token return function (s) { return _.rtoken(new RegExp("^\s*" + s + "\s*"))(s); // Removed .strip() // return _.rtoken(new RegExp("^\s*" + s + "\s*"))(s).strip(); }; }, stoken: function (s) { // string token return _.rtoken(new RegExp("^" + s)); }, // // Atomic Operators // until: function (p) { return function (s) { var qx = [], rx = null; while (s.length) { try { rx = p.call(this, s); } catch (e) { qx.push(rx[0]); s = rx[1]; continue; } break; } return [ qx, s ]; }; }, many: function (p) { return function (s) { var rx = [], r = null; while (s.length) { try { r = p.call(this, s); } catch (e) { return [ rx, s ]; } rx.push(r[0]); s = r[1]; } return [ rx, s ]; }; }, // generator operators -- see below optional: function (p) { return function (s) { var r = null; try { r = p.call(this, s); } catch (e) { return [ null, s ]; } return [ r[0], r[1] ]; }; }, not: function (p) { return function (s) { try { p.call(this, s); } catch (e) { return [null, s]; } throw new $P.Exception(s); }; }, ignore: function (p) { return p ? function (s) { var r = null; r = p.call(this, s); return [null, r[1]]; } : null; }, product: function () { var px = arguments[0], qx = Array.prototype.slice.call(arguments, 1), rx = []; for (var i = 0 ; i < px.length ; i++) { rx.push(_.each(px[i], qx)); } return rx; }, cache: function (rule) { var cache = {}, r = null; return function (s) { try { r = cache[s] = (cache[s] || rule.call(this, s)); } catch (e) { r = cache[s] = e; } if (r instanceof $P.Exception) { throw r; } else { return r; } }; }, // vector operators -- see below any: function () { var px = arguments; return function (s) { var r = null; for (var i = 0; i < px.length; i++) { if (px[i] == null) { continue; } try { r = (px[i].call(this, s)); } catch (e) { r = null; } if (r) { return r; } } throw new $P.Exception(s); }; }, each: function () { var px = arguments; return function (s) { var rx = [], r = null; for (var i = 0; i < px.length ; i++) { if (px[i] == null) { continue; } try { r = (px[i].call(this, s)); } catch (e) { throw new $P.Exception(s); } rx.push(r[0]); s = r[1]; } return [ rx, s]; }; }, all: function () { var px = arguments, _ = _; return _.each(_.optional(px)); }, // delimited operators sequence: function (px, d, c) { d = d || _.rtoken(/^\s*/); c = c || null; if (px.length == 1) { return px[0]; } return function (s) { var r = null, q = null; var rx = []; for (var i = 0; i < px.length ; i++) { try { r = px[i].call(this, s); } catch (e) { break; } rx.push(r[0]); try { q = d.call(this, r[1]); } catch (ex) { q = null; break; } s = q[1]; } if (!r) { throw new $P.Exception(s); } if (q) { throw new $P.Exception(q[1]); } if (c) { try { r = c.call(this, r[1]); } catch (ey) { throw new $P.Exception(r[1]); } } return [ rx, (r?r[1]:s) ]; }; }, // // Composite Operators // between: function (d1, p, d2) { d2 = d2 || d1; var _fn = _.each(_.ignore(d1), p, _.ignore(d2)); return function (s) { var rx = _fn.call(this, s); return [[rx[0][0], r[0][2]], rx[1]]; }; }, list: function (p, d, c) { d = d || _.rtoken(/^\s*/); c = c || null; return (p instanceof Array ? _.each(_.product(p.slice(0, -1), _.ignore(d)), p.slice(-1), _.ignore(c)) : _.each(_.many(_.each(p, _.ignore(d))), px, _.ignore(c))); }, set: function (px, d, c) { d = d || _.rtoken(/^\s*/); c = c || null; return function (s) { // r is the current match, best the current 'best' match // which means it parsed the most amount of input var r = null, p = null, q = null, rx = null, best = [[], s], last = false; // go through the rules in the given set for (var i = 0; i < px.length ; i++) { // last is a flag indicating whether this must be the last element // if there is only 1 element, then it MUST be the last one q = null; p = null; r = null; last = (px.length == 1); // first, we try simply to match the current pattern // if not, try the next pattern try { r = px[i].call(this, s); } catch (e) { continue; } // since we are matching against a set of elements, the first // thing to do is to add r[0] to matched elements rx = [[r[0]], r[1]]; // if we matched and there is still input to parse and // we don't already know this is the last element, // we're going to next check for the delimiter ... // if there's none, or if there's no input left to parse // than this must be the last element after all ... if (r[1].length > 0 && ! last) { try { q = d.call(this, r[1]); } catch (ex) { last = true; } } else { last = true; } // if we parsed the delimiter and now there's no more input, // that means we shouldn't have parsed the delimiter at all // so don't update r and mark this as the last element ... if (!last && q[1].length === 0) { last = true; } // so, if this isn't the last element, we're going to see if // we can get any more matches from the remaining (unmatched) // elements ... if (!last) { // build a list of the remaining rules we can match against, // i.e., all but the one we just matched against var qx = []; for (var j = 0; j < px.length ; j++) { if (i != j) { qx.push(px[j]); } } // now invoke recursively set with the remaining input // note that we don't include the closing delimiter ... // we'll check for that ourselves at the end p = _.set(qx, d).call(this, q[1]); // if we got a non-empty set as a result ... // (otw rx already contains everything we want to match) if (p[0].length > 0) { // update current result, which is stored in rx ... // basically, pick up the remaining text from p[1] // and concat the result from p[0] so that we don't // get endless nesting ... rx[0] = rx[0].concat(p[0]); rx[1] = p[1]; } } // at this point, rx either contains the last matched element // or the entire matched set that starts with this element. // now we just check to see if this variation is better than // our best so far, in terms of how much of the input is parsed if (rx[1].length < best[1].length) { best = rx; } // if we've parsed all the input, then we're finished if (best[1].length === 0) { break; } } // so now we've either gone through all the patterns trying them // as the initial match; or we found one that parsed the entire // input string ... // if best has no matches, just return empty set ... if (best[0].length === 0) { return best; } // if a closing delimiter is provided, then we have to check it also if (c) { // we try this even if there is no remaining input because the pattern // may well be optional or match empty input ... try { q = c.call(this, best[1]); } catch (ey) { throw new $P.Exception(best[1]); } // it parsed ... be sure to update the best match remaining input best[1] = q[1]; } // if we're here, either there was no closing delimiter or we parsed it // so now we have the best match; just return it! return best; }; }, forward: function (gr, fname) { return function (s) { return gr[fname].call(this, s); }; }, // // Translation Operators // replace: function (rule, repl) { return function (s) { var r = rule.call(this, s); return [repl, r[1]]; }; }, process: function (rule, fn) { return function (s) { var r = rule.call(this, s); return [fn.call(this, r[0]), r[1]]; }; }, min: function (min, rule) { return function (s) { var rx = rule.call(this, s); if (rx[0].length < min) { throw new $P.Exception(s); } return rx; }; } }; // Generator Operators And Vector Operators // Generators are operators that have a signature of F(R) => R, // taking a given rule and returning another rule, such as // ignore, which parses a given rule and throws away the result. // Vector operators are those that have a signature of F(R1,R2,...) => R, // take a list of rules and returning a new rule, such as each. // Generator operators are converted (via the following _generator // function) into functions that can also take a list or array of rules // and return an array of new rules as though the function had been // called on each rule in turn (which is what actually happens). // This allows generators to be used with vector operators more easily. // Example: // each(ignore(foo, bar)) instead of each(ignore(foo), ignore(bar)) // This also turns generators into vector operators, which allows // constructs like: // not(cache(foo, bar)) var _generator = function (op) { function gen() { var args = null, rx = [], px, i; if (arguments.length > 1) { args = Array.prototype.slice.call(arguments); } else if (arguments[0] instanceof Array) { args = arguments[0]; } if (args) { px = args.shift(); if (px.length > 0) { args.unshift(px[i]); rx.push(op.apply(null, args)); args.shift(); return rx; } } else { return op.apply(null, arguments); } } return gen; }; var gx = "optional not ignore cache".split(/\s/); for (var i = 0 ; i < gx.length ; i++) { _[gx[i]] = _generator(_[gx[i]]); } var _vector = function (op) { return function () { if (arguments[0] instanceof Array) { return op.apply(null, arguments[0]); } else { return op.apply(null, arguments); } }; }; var vx = "each any all".split(/\s/); for (var j = 0 ; j < vx.length ; j++) { _[vx[j]] = _vector(_[vx[j]]); } }()); (function () { var $D = Date; var flattenAndCompact = function (ax) { var rx = []; for (var i = 0; i < ax.length; i++) { if (ax[i] instanceof Array) { rx = rx.concat(flattenAndCompact(ax[i])); } else { if (ax[i]) { rx.push(ax[i]); } } } return rx; }; $D.Grammar = {}; $D.Translator = { hour: function (s) { return function () { this.hour = Number(s); }; }, minute: function (s) { return function () { this.minute = Number(s); }; }, second: function (s) { return function () { this.second = Number(s); }; }, /* for ss.s format */ secondAndMillisecond: function (s) { return function () { var mx = s.match(/^([0-5][0-9])\.([0-9]{1,3})/); this.second = Number(mx[1]); this.millisecond = Number(mx[2]); }; }, meridian: function (s) { return function () { this.meridian = s.slice(0, 1).toLowerCase(); }; }, timezone: function (s) { return function () { var n = s.replace(/[^\d\+\-]/g, ""); if (n.length) { this.timezoneOffset = Number(n); } else { this.timezone = s.toLowerCase(); } }; }, day: function (x) { var s = x[0]; return function () { this.day = Number(s.match(/\d+/)[0]); if (this.day < 1) { throw "invalid day"; } }; }, month: function (s) { return function () { this.month = (s.length === 3) ? "jan feb mar apr may jun jul aug sep oct nov dec".indexOf(s)/4 : Number(s) - 1; if (this.month < 0) { throw "invalid month"; } }; }, year: function (s) { return function () { var n = Number(s); this.year = ((s.length > 2) ? n : (n + (((n + 2000) < Date.CultureInfo.twoDigitYearMax) ? 2000 : 1900))); }; }, rday: function (s) { return function () { switch (s) { case "yesterday": this.days = -1; break; case "tomorrow": this.days = 1; break; case "today": this.days = 0; break; case "now": this.days = 0; this.now = true; break; } }; }, finishExact: function (x) { x = (x instanceof Array) ? x : [ x ]; for (var i = 0 ; i < x.length ; i++) { if (x[i]) { x[i].call(this); } } var now = new Date(); if ((this.hour || this.minute) && (!this.month && !this.year && !this.day)) { this.day = now.getDate(); } if (!this.year) { this.year = now.getFullYear(); } if (!this.month && this.month !== 0) { this.month = now.getMonth(); } if (!this.day) { this.day = 1; } if (!this.hour) { this.hour = 0; } if (!this.minute) { this.minute = 0; } if (!this.second) { this.second = 0; } if (!this.millisecond) { this.millisecond = 0; } if (this.meridian && (this.hour || this.hour === 0)) { if (this.meridian == "a" && this.hour > 11 && Date.Config.strict24hr){ throw "Invalid hour and meridian combination"; } else if (this.meridian == "p" && this.hour < 12 && Date.Config.strict24hr){ throw "Invalid hour and meridian combination"; } else if (this.meridian == "p" && this.hour < 12) { this.hour = this.hour + 12; } else if (this.meridian == "a" && this.hour == 12) { this.hour = 0; } } if (this.day > $D.getDaysInMonth(this.year, this.month)) { throw new RangeError(this.day + " is not a valid value for days."); } var r = new Date(this.year, this.month, this.day, this.hour, this.minute, this.second, this.millisecond); if (this.year < 100) { r.setFullYear(this.year); // means years less that 100 are process correctly. JS will parse it otherwise as 1900-1999. } if (this.timezone) { r.set({ timezone: this.timezone }); } else if (this.timezoneOffset) { r.set({ timezoneOffset: this.timezoneOffset }); } return r; }, finish: function (x) { x = (x instanceof Array) ? flattenAndCompact(x) : [ x ]; if (x.length === 0) { return null; } for (var i = 0 ; i < x.length ; i++) { if (typeof x[i] == "function") { x[i].call(this); } } var today = $D.today(); if (this.now && !this.unit && !this.operator) { return new Date(); } else if (this.now) { today = new Date(); } var expression = !!(this.days && this.days !== null || this.orient || this.operator); var gap, mod, orient; orient = ((this.orient == "past" || this.operator == "subtract") ? -1 : 1); if(!this.now && "hour minute second".indexOf(this.unit) != -1) { today.setTimeToNow(); } if (this.month && this.unit == "week") { this.value = this.month + 1; delete this.month; delete this.day; } if (this.month || this.month === 0) { if ("year day hour minute second".indexOf(this.unit) != -1) { if (!this.value) { this.value = this.month + 1; } this.month = null; expression = true; } } if (!expression && this.weekday && !this.day && !this.days) { var temp = Date[this.weekday](); this.day = temp.getDate(); if (!this.month) { this.month = temp.getMonth(); } this.year = temp.getFullYear(); } if (expression && this.weekday && this.unit != "month" && this.unit != "week") { this.unit = "day"; gap = ($D.getDayNumberFromName(this.weekday) - today.getDay()); mod = 7; this.days = gap ? ((gap + (orient * mod)) % mod) : (orient * mod); } if (this.month && this.unit == "day" && this.operator) { if (!this.value) { this.value = (this.month + 1); } this.month = null; } if (this.value != null && this.month != null && this.year != null) { this.day = this.value * 1; } if (this.month && !this.day && this.value) { today.set({ day: this.value * 1 }); if (!expression) { this.day = this.value * 1; } } if (!this.month && this.value && this.unit == "month" && !this.now) { this.month = this.value; expression = true; } if (expression && (this.month || this.month === 0) && this.unit != "year") { this.unit = "month"; gap = (this.month - today.getMonth()); mod = 12; this.months = gap ? ((gap + (orient * mod)) % mod) : (orient * mod); this.month = null; } if (!this.unit) { this.unit = "day"; } if (!this.value && this.operator && this.operator !== null && this[this.unit + "s"] && this[this.unit + "s"] !== null) { this[this.unit + "s"] = this[this.unit + "s"] + ((this.operator == "add") ? 1 : -1) + (this.value||0) * orient; } else if (this[this.unit + "s"] == null || this.operator != null) { if (!this.value) { this.value = 1; } this[this.unit + "s"] = this.value * orient; } if (this.meridian && (this.hour || this.hour === 0)) { if (this.meridian == "a" && this.hour > 11 && Date.Config.strict24hr){ throw "Invalid hour and meridian combination"; } else if (this.meridian == "p" && this.hour < 12 && Date.Config.strict24hr){ throw "Invalid hour and meridian combination"; } else if (this.meridian == "p" && this.hour < 12) { this.hour = this.hour + 12; } else if (this.meridian == "a" && this.hour == 12) { this.hour = 0; } } if (this.weekday && this.unit !== "week" && !this.day && !this.days) { var temp = Date[this.weekday](); this.day = temp.getDate(); if (temp.getMonth() !== today.getMonth()) { this.month = temp.getMonth(); } } if ((this.month || this.month === 0) && !this.day) { this.day = 1; } if (!this.orient && !this.operator && this.unit == "week" && this.value && !this.day && !this.month) { return Date.today().setWeek(this.value); } if (this.unit == "week" && this.weeks && !this.day && !this.month) { var weekday = (this.weekday) ? this.weekday : "today"; var d = Date[weekday]().addWeeks(this.weeks); if (this.now) { d.setTimeToNow(); } return d; } if (expression && this.timezone && this.day && this.days) { this.day = this.days; } return (expression) ? today.add(this) : today.set(this); } }; var _ = $D.Parsing.Operators, g = $D.Grammar, t = $D.Translator, _fn; g.datePartDelimiter = _.rtoken(/^([\s\-\.\,\/\x27]+)/); g.timePartDelimiter = _.stoken(":"); g.whiteSpace = _.rtoken(/^\s*/); g.generalDelimiter = _.rtoken(/^(([\s\,]|at|@|on)+)/); var _C = {}; g.ctoken = function (keys) { var fn = _C[keys]; if (! fn) { var c = Date.CultureInfo.regexPatterns; var kx = keys.split(/\s+/), px = []; for (var i = 0; i < kx.length ; i++) { px.push(_.replace(_.rtoken(c[kx[i]]), kx[i])); } fn = _C[keys] = _.any.apply(null, px); } return fn; }; g.ctoken2 = function (key) { return _.rtoken(Date.CultureInfo.regexPatterns[key]); }; // hour, minute, second, meridian, timezone g.h = _.cache(_.process(_.rtoken(/^(0[0-9]|1[0-2]|[1-9])/), t.hour)); g.hh = _.cache(_.process(_.rtoken(/^(0[0-9]|1[0-2])/), t.hour)); g.H = _.cache(_.process(_.rtoken(/^([0-1][0-9]|2[0-3]|[0-9])/), t.hour)); g.HH = _.cache(_.process(_.rtoken(/^([0-1][0-9]|2[0-3])/), t.hour)); g.m = _.cache(_.process(_.rtoken(/^([0-5][0-9]|[0-9])/), t.minute)); g.mm = _.cache(_.process(_.rtoken(/^[0-5][0-9]/), t.minute)); g.s = _.cache(_.process(_.rtoken(/^([0-5][0-9]|[0-9])/), t.second)); g.ss = _.cache(_.process(_.rtoken(/^[0-5][0-9]/), t.second)); g["ss.s"] = _.cache(_.process(_.rtoken(/^[0-5][0-9]\.[0-9]{1,3}/), t.secondAndMillisecond)); g.hms = _.cache(_.sequence([g.H, g.m, g.s], g.timePartDelimiter)); // _.min(1, _.set([ g.H, g.m, g.s ], g._t)); g.t = _.cache(_.process(g.ctoken2("shortMeridian"), t.meridian)); g.tt = _.cache(_.process(g.ctoken2("longMeridian"), t.meridian)); g.z = _.cache(_.process(_.rtoken(/^((\+|\-)\s*\d\d\d\d)|((\+|\-)\d\d\:?\d\d)/), t.timezone)); g.zz = _.cache(_.process(_.rtoken(/^((\+|\-)\s*\d\d\d\d)|((\+|\-)\d\d\:?\d\d)/), t.timezone)); g.zzz = _.cache(_.process(g.ctoken2("timezone"), t.timezone)); g.timeSuffix = _.each(_.ignore(g.whiteSpace), _.set([ g.tt, g.zzz ])); g.time = _.each(_.optional(_.ignore(_.stoken("T"))), g.hms, g.timeSuffix); // days, months, years g.d = _.cache(_.process(_.each(_.rtoken(/^([0-2]\d|3[0-1]|\d)/), _.optional(g.ctoken2("ordinalSuffix"))), t.day)); g.dd = _.cache(_.process(_.each(_.rtoken(/^([0-2]\d|3[0-1])/), _.optional(g.ctoken2("ordinalSuffix"))), t.day)); g.ddd = g.dddd = _.cache(_.process(g.ctoken("sun mon tue wed thu fri sat"), function (s) { return function () { this.weekday = s; }; } )); g.M = _.cache(_.process(_.rtoken(/^(1[0-2]|0\d|\d)/), t.month)); g.MM = _.cache(_.process(_.rtoken(/^(1[0-2]|0\d)/), t.month)); g.MMM = g.MMMM = _.cache(_.process(g.ctoken("jan feb mar apr may jun jul aug sep oct nov dec"), t.month)); // g.MMM = g.MMMM = _.cache(_.process(g.ctoken(Date.CultureInfo.abbreviatedMonthNames.join(" ")), t.month)); g.y = _.cache(_.process(_.rtoken(/^(\d\d?)/), t.year)); g.yy = _.cache(_.process(_.rtoken(/^(\d\d)/), t.year)); g.yyy = _.cache(_.process(_.rtoken(/^(\d\d?\d?\d?)/), t.year)); g.yyyy = _.cache(_.process(_.rtoken(/^(\d\d\d\d)/), t.year)); // rolling these up into general purpose rules _fn = function () { return _.each(_.any.apply(null, arguments), _.not(g.ctoken2("timeContext"))); }; g.day = _fn(g.d, g.dd); g.month = _fn(g.M, g.MMM); g.year = _fn(g.yyyy, g.yy); // relative date / time expressions g.orientation = _.process(g.ctoken("past future"), function (s) { return function () { this.orient = s; }; } ); g.operator = _.process(g.ctoken("add subtract"), function (s) { return function () { this.operator = s; }; } ); g.rday = _.process(g.ctoken("yesterday tomorrow today now"), t.rday); g.unit = _.process(g.ctoken("second minute hour day week month year"), function (s) { return function () { this.unit = s; }; } ); g.value = _.process(_.rtoken(/^([-+]?\d+)?(st|nd|rd|th)?/), function (s) { return function () { this.value = s.replace(/\D/g, ""); }; } ); g.expression = _.set([ g.rday, g.operator, g.value, g.unit, g.orientation, g.ddd, g.MMM ]); // pre-loaded rules for different date part order preferences _fn = function () { return _.set(arguments, g.datePartDelimiter); }; g.mdy = _fn(g.ddd, g.month, g.day, g.year); g.ymd = _fn(g.ddd, g.year, g.month, g.day); g.dmy = _fn(g.ddd, g.day, g.month, g.year); g.date = function (s) { return ((g[Date.CultureInfo.dateElementOrder] || g.mdy).call(this, s)); }; // parsing date format specifiers - ex: "h:m:s tt" // this little guy will generate a custom parser based // on the format string, ex: g.format("h:m:s tt") g.format = _.process(_.many( _.any( // translate format specifiers into grammar rules _.process( _.rtoken(/^(dd?d?d?(?!e)|MM?M?M?|yy?y?y?|hh?|HH?|mm?|ss?|tt?|zz?z?)/), function (fmt) { if (g[fmt]) { return g[fmt]; } else { throw $D.Parsing.Exception(fmt); } } ), // translate separator tokens into token rules _.process(_.rtoken(/^[^dMyhHmstz]+/), // all legal separators function (s) { return _.ignore(_.stoken(s)); } ) )), // construct the parser ... function (rules) { return _.process(_.each.apply(null, rules), t.finishExact); } ); var _F = { //"M/d/yyyy": function (s) { // var m = s.match(/^([0-2]\d|3[0-1]|\d)\/(1[0-2]|0\d|\d)\/(\d\d\d\d)/); // if (m!=null) { // var r = [ t.month.call(this,m[1]), t.day.call(this,m[2]), t.year.call(this,m[3]) ]; // r = t.finishExact.call(this,r); // return [ r, "" ]; // } else { // throw new Date.Parsing.Exception(s); // } //} //"M/d/yyyy": function (s) { return [ new Date(Date._parse(s)), ""]; } }; var _get = function (f) { _F[f] = (_F[f] || g.format(f)[0]); return _F[f]; }; g.allformats = function (fx) { var rx = []; if (fx instanceof Array) { for (var i = 0; i < fx.length; i++) { rx.push(_get(fx[i])); } } else { rx.push(_get(fx)); } return rx; }; g.formats = function (fx) { if (fx instanceof Array) { var rx = []; for (var i = 0 ; i < fx.length ; i++) { rx.push(_get(fx[i])); } return _.any.apply(null, rx); } else { return _get(fx); } }; // check for these formats first g._formats = g.formats([ "\"yyyy-MM-ddTHH:mm:ssZ\"", "yyyy-MM-ddTHH:mm:ss.sz", "yyyy-MM-ddTHH:mm:ssZ", "yyyy-MM-ddTHH:mm:ssz", "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-ddTHH:mmZ", "yyyy-MM-ddTHH:mmz", "yyyy-MM-ddTHH:mm", "ddd, MMM dd, yyyy H:mm:ss tt", "ddd MMM d yyyy HH:mm:ss zzz", "MMddyyyy", "ddMMyyyy", "Mddyyyy", "ddMyyyy", "Mdyyyy", "dMyyyy", "yyyy", "Mdyy", "dMyy", "d" ]); // starting rule for general purpose grammar g._start = _.process(_.set([ g.date, g.time, g.expression ], g.generalDelimiter, g.whiteSpace), t.finish); // real starting rule: tries selected formats first, // then general purpose rule g.start = function (s) { try { var r = g._formats.call({}, s); if (r[1].length === 0) { return r; } } catch (e) {} return g._start.call({}, s); }; /** * @desc Converts the specified string value into its JavaScript Date equivalent using CultureInfo specific format information. * * Example

	///////////
	// Dates //
	///////////

	// 15-Oct-2004
	var d1 = Date.parse("10/15/2004");

	// 15-Oct-2004
	var d1 = Date.parse("15-Oct-2004");

	// 15-Oct-2004
	var d1 = Date.parse("2004.10.15");

	//Fri Oct 15, 2004
	var d1 = Date.parse("Fri Oct 15, 2004");

	///////////
	// Times //
	///////////

	// Today at 10 PM.
	var d1 = Date.parse("10 PM");

	// Today at 10:30 PM.
	var d1 = Date.parse("10:30 P.M.");

	// Today at 6 AM.
	var d1 = Date.parse("06am");

	/////////////////////
	// Dates and Times //
	/////////////////////

	// 8-July-2004 @ 10:30 PM
	var d1 = Date.parse("July 8th, 2004, 10:30 PM");

	// 1-July-2004 @ 10:30 PM
	var d1 = Date.parse("2004-07-01T22:30:00");

	////////////////////
	// Relative Dates //
	////////////////////

	// Returns today's date. The string "today" is culture specific.
	var d1 = Date.parse("today");

	// Returns yesterday's date. The string "yesterday" is culture specific.
	var d1 = Date.parse("yesterday");

	// Returns the date of the next thursday.
	var d1 = Date.parse("Next thursday");

	// Returns the date of the most previous monday.
	var d1 = Date.parse("last monday");

	// Returns today's day + one year.
	var d1 = Date.parse("next year");

	///////////////
	// Date Math //
	///////////////

	// Today + 2 days
	var d1 = Date.parse("t+2");

	// Today + 2 days
	var d1 = Date.parse("today + 2 days");

	// Today + 3 months
	var d1 = Date.parse("t+3m");

	// Today - 1 year
	var d1 = Date.parse("today - 1 year");

	// Today - 1 year
	var d1 = Date.parse("t-1y"); 


	/////////////////////////////
	// Partial Dates and Times //
	/////////////////////////////

	// July 15th of this year.
	var d1 = Date.parse("July 15");

	// 15th day of current day and year.
	var d1 = Date.parse("15");

	// July 1st of current year at 10pm.
	var d1 = Date.parse("7/1 10pm");
	
* * @param {String} The string value to convert into a Date object [Required] * @return {Date} A Date object or null if the string cannot be converted into a Date. */ function parse (s) { var ords, d, t, r = null; if (!s) { return null; } if (s instanceof Date) { return s.clone(); } if (s.length >= 4 && s.charAt(0) !== "0" && s.charAt(0) !== "+"&& s.charAt(0) !== "-") { // ie: 2004 will pass, 0800 won't. // Start with specific formats d = $D.Parsing.ISO.parse(s) || $D.Parsing.Numeric.parse(s); } if (d instanceof Date && !isNaN(d.getTime())) { return d; } else { // find ordinal dates (1st, 3rd, 8th, etc and remove them as they cause parsing issues) ords = s.match(/\b(\d+)(?:st|nd|rd|th)\b/); // find ordinal matches s = ((ords && ords.length === 2) ? s.replace(ords[0], ords[1]) : s); s = $D.Parsing.Normalizer.parse(s); try { r = $D.Grammar.start.call({}, s.replace(/^\s*(\S*(\s+\S+)*)\s*$/, "$1")); } catch (e) { return null; } d = ((r[1].length === 0) ? r[0] : null); if (d !== null) { return d; } else { try { // ok we haven't parsed it, last ditch attempt with the built-in parser. t = Date._parse(s); return (t || t === 0) ? new Date(t) : null; } catch (e) { return null; } } } } if (!$D._parse) { $D._parse = $D.parse; } $D.parse = parse; Date.getParseFunction = function (fx) { var fns = Date.Grammar.allformats(fx); return function (s) { var r = null; for (var i = 0; i < fns.length; i++) { try { r = fns[i].call({}, s); } catch (e) { continue; } if (r[1].length === 0) { return r[0]; } } return null; }; }; /** * Converts the specified string value into its JavaScript Date equivalent using the specified format {String} or formats {Array} and the CultureInfo specific format information. * The format of the string value must match one of the supplied formats exactly. * * Example

	// 15-Oct-2004
	var d1 = Date.parseExact("10/15/2004", "M/d/yyyy");

	// 15-Oct-2004
	var d1 = Date.parse("15-Oct-2004", "M-ddd-yyyy");

	// 15-Oct-2004
	var d1 = Date.parse("2004.10.15", "yyyy.MM.dd");

	// Multiple formats
	var d1 = Date.parseExact("10/15/2004", ["M/d/yyyy", "MMMM d, yyyy"]);
	
* * @param {String} The string value to convert into a Date object [Required]. * @param {Object} The expected format {String} or an array of expected formats {Array} of the date string [Required]. * @return {Date} A Date object or null if the string cannot be converted into a Date. */ $D.parseExact = function (s, fx) { return $D.getParseFunction(fx)(s); }; }()); /************************************************************* * SugarPak - Domain Specific Language - Syntactical Sugar * *************************************************************/ (function () { var $D = Date, $P = $D.prototype, $N = Number.prototype; // private $P._orient = +1; // private $P._nth = null; // private $P._is = false; // private $P._same = false; // private $P._isSecond = false; // private $N._dateElement = "days"; /** * Moves the date to the next instance of a date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.today().next().friday();
	Date.today().next().fri();
	Date.today().next().march();
	Date.today().next().mar();
	Date.today().next().week();
	
* * @return {Date} date */ $P.next = function () { this._move = true; this._orient = +1; return this; }; /** * Creates a new Date (Date.today()) and moves the date to the next instance of the date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.next().friday();
	Date.next().fri();
	Date.next().march();
	Date.next().mar();
	Date.next().week();
	
* * @return {Date} date */ $D.next = function () { return $D.today().next(); }; /** * Moves the date to the previous instance of a date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.today().last().friday();
	Date.today().last().fri();
	Date.today().last().march();
	Date.today().last().mar();
	Date.today().last().week();
	
* * @return {Date} date */ $P.last = $P.prev = $P.previous = function () { this._move = true; this._orient = -1; return this; }; /** * Creates a new Date (Date.today()) and moves the date to the previous instance of the date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.last().friday();
	Date.last().fri();
	Date.previous().march();
	Date.prev().mar();
	Date.last().week();
	
* * @return {Date} date */ $D.last = $D.prev = $D.previous = function () { return $D.today().last(); }; /** * Performs a equality check when followed by either a month name, day name or .weekday() function. * Example

	Date.today().is().friday(); // true|false
	Date.today().is().fri();
	Date.today().is().march();
	Date.today().is().mar();
	
* * @return {Boolean} true|false */ $P.is = function () { this._is = true; return this; }; /** * Determines if two date objects occur on/in exactly the same instance of the subsequent date part function. * The function .same() must be followed by a date part function (example: .day(), .month(), .year(), etc). * * An optional Date can be passed in the date part function. If now date is passed as a parameter, 'Now' is used. * * The following example demonstrates how to determine if two dates fall on the exact same day. * * Example

	var d1 = Date.today(); // today at 00:00
	var d2 = new Date();   // exactly now.

	// Do they occur on the same day?
	d1.same().day(d2); // true
	
	 // Do they occur on the same hour?
	d1.same().hour(d2); // false, unless d2 hour is '00' (midnight).
	
	// What if it's the same day, but one year apart?
	var nextYear = Date.today().add(1).year();

	d1.same().day(nextYear); // false, because the dates must occur on the exact same day. 
	
* * Scenario: Determine if a given date occurs during some week period 2 months from now. * * Example

	var future = Date.today().add(2).months();
	return someDate.same().week(future); // true|false;
	
* * @return {Boolean} true|false */ $P.same = function () { this._same = true; this._isSecond = false; return this; }; /** * Determines if the current date/time occurs during Today. Must be preceded by the .is() function. * Example

	someDate.is().today();    // true|false
	new Date().is().today();  // true
	Date.today().is().today();// true
	Date.today().add(-1).day().is().today(); // false
	
* * @return {Boolean} true|false */ $P.today = function () { return this.same().day(); }; /** * Determines if the current date is a weekday. This function must be preceded by the .is() function. * Example

	Date.today().is().weekday(); // true|false
	
* * @return {Boolean} true|false */ $P.weekday = function () { if (this._nth) { return df("Weekday").call(this); } if (this._move) { return this.addWeekdays(this._orient); } if (this._is) { this._is = false; return (!this.is().sat() && !this.is().sun()); } return false; }; /** * Determines if the current date is on the weekend. This function must be preceded by the .is() function. * Example

	Date.today().is().weekend(); // true|false
	
* * @return {Boolean} true|false */ $P.weekend = function () { if (this._is) { this._is = false; return (this.is().sat() || this.is().sun()); } return false; }; /** * Sets the Time of the current Date instance. A string "6:15 pm" or config object {hour:18, minute:15} are accepted. * Example

	// Set time to 6:15pm with a String
	Date.today().at("6:15pm");

	// Set time to 6:15pm with a config object
	Date.today().at({hour:18, minute:15});
	
* * @return {Date} date */ $P.at = function (time) { return (typeof time === "string") ? $D.parse(this.toString("d") + " " + time) : this.set(time); }; /** * Creates a new Date() and adds this (Number) to the date based on the preceding date element function (eg. second|minute|hour|day|month|year). * Example

	// Undeclared Numbers must be wrapped with parentheses. Requirment of JavaScript.
	(3).days().fromNow();
	(6).months().fromNow();

	// Declared Number variables do not require parentheses. 
	var n = 6;
	n.months().fromNow();
	
* * @return {Date} A new Date instance */ $N.fromNow = $N.after = function (date) { var c = {}; c[this._dateElement] = this; return ((!date) ? new Date() : date.clone()).add(c); }; /** * Creates a new Date() and subtract this (Number) from the date based on the preceding date element function (eg. second|minute|hour|day|month|year). * Example

	// Undeclared Numbers must be wrapped with parentheses. Requirment of JavaScript.
	(3).days().ago();
	(6).months().ago();

	// Declared Number variables do not require parentheses. 
	var n = 6;
	n.months().ago();
	
* * @return {Date} A new Date instance */ $N.ago = $N.before = function (date) { var c = {}, s = (this._dateElement[this._dateElement.length-1] !== "s") ? this._dateElement + "s" : this._dateElement; c[s] = this * -1; return ((!date) ? new Date() : date.clone()).add(c); }; // Do NOT modify the following string tokens. These tokens are used to build dynamic functions. // All culture-specific strings can be found in the CultureInfo files. var dx = ("sunday monday tuesday wednesday thursday friday saturday").split(/\s/), mx = ("january february march april may june july august september october november december").split(/\s/), px = ("Millisecond Second Minute Hour Day Week Month Year Quarter Weekday").split(/\s/), pxf = ("Milliseconds Seconds Minutes Hours Date Week Month FullYear Quarter").split(/\s/), nth = ("final first second third fourth fifth").split(/\s/), de; /** * Returns an object literal of all the date parts. * Example

	var o = new Date().toObject();
	
	// { year: 2008, month: 4, week: 20, day: 13, hour: 18, minute: 9, second: 32, millisecond: 812 }
	
	// The object properties can be referenced directly from the object.
	
	alert(o.day);  // alerts "13"
	alert(o.year); // alerts "2008"
	
* * @return {Date} An object literal representing the original date object. */ $P.toObject = function () { var o = {}; for (var i = 0; i < px.length; i++) { if (this["get" + pxf[i]]) { o[px[i].toLowerCase()] = this["get" + pxf[i]](); } } return o; }; /** * Returns a date created from an object literal. Ignores the .week property if set in the config. * Example

	var o = new Date().toObject();
	
	return Date.fromObject(o); // will return the same date. 

	var o2 = {month: 1, day: 20, hour: 18}; // birthday party!
	Date.fromObject(o2);
	
* * @return {Date} An object literal representing the original date object. */ $D.fromObject = function(config) { config.week = null; return Date.today().set(config); }; // Create day name functions and abbreviated day name functions (eg. monday(), friday(), fri()). var df = function (n) { return function () { if (this._is) { this._is = false; return this.getDay() === n; } if (this._move) { this._move = null; } if (this._nth !== null) { // If the .second() function was called earlier, remove the _orient // from the date, and then continue. // This is required because 'second' can be used in two different context. // // Example // // Date.today().add(1).second(); // Date.march().second().monday(); // // Things get crazy with the following... // Date.march().add(1).second().second().monday(); // but it works!! // if (this._isSecond) { this.addSeconds(this._orient * -1); } // make sure we reset _isSecond this._isSecond = false; var ntemp = this._nth; this._nth = null; var temp = this.clone().moveToLastDayOfMonth(); this.moveToNthOccurrence(n, ntemp); if (this > temp) { throw new RangeError($D.getDayName(n) + " does not occur " + ntemp + " times in the month of " + $D.getMonthName(temp.getMonth()) + " " + temp.getFullYear() + "."); } return this; } return this.moveToDayOfWeek(n, this._orient); }; }; var sdf = function (n) { return function () { var t = $D.today(), shift = n - t.getDay(); if (n === 0 && Date.CultureInfo.firstDayOfWeek === 1 && t.getDay() !== 0) { shift = shift + 7; } return t.addDays(shift); }; }; for (var i = 0; i < dx.length; i++) { // Create constant static Day Name variables. Example: Date.MONDAY or Date.MON $D[dx[i].toUpperCase()] = $D[dx[i].toUpperCase().substring(0, 3)] = i; // Create Day Name functions. Example: Date.monday() or Date.mon() $D[dx[i]] = $D[dx[i].substring(0, 3)] = sdf(i); // Create Day Name instance functions. Example: Date.today().next().monday() $P[dx[i]] = $P[dx[i].substring(0, 3)] = df(i); } // Create month name functions and abbreviated month name functions (eg. january(), march(), mar()). var month_instance_functions = function (n) { return function () { if (this._is) { this._is = false; return this.getMonth() === n; } return this.moveToMonth(n, this._orient); }; }; var month_static_functions = function (n) { return function () { return $D.today().set({ month: n, day: 1 }); }; }; for (var j = 0; j < mx.length; j++) { // Create constant static Month Name variables. Example: Date.MARCH or Date.MAR $D[mx[j].toUpperCase()] = $D[mx[j].toUpperCase().substring(0, 3)] = j; // Create Month Name functions. Example: Date.march() or Date.mar() $D[mx[j]] = $D[mx[j].substring(0, 3)] = month_static_functions(j); // Create Month Name instance functions. Example: Date.today().next().march() $P[mx[j]] = $P[mx[j].substring(0, 3)] = month_instance_functions(j); } // Create date element functions and plural date element functions used with Date (eg. day(), days(), months()). var ef = function (j) { return function () { // if the .second() function was called earlier, the _orient // has alread been added. Just return this and reset _isSecond. if (this._isSecond) { this._isSecond = false; return this; } if (this._same) { this._same = this._is = false; var o1 = this.toObject(), o2 = (arguments[0] || new Date()).toObject(), v = "", k = j.toLowerCase(); // the substr trick with -1 doesn't work in IE8 or less k = (k[k.length-1] === "s") ? k.substring(0,k.length-1) : k; for (var m = (px.length - 1); m > -1; m--) { v = px[m].toLowerCase(); if (o1[v] !== o2[v]) { return false; } if (k === v) { break; } } return true; } if (j.substring(j.length - 1) !== "s") { j += "s"; } if (this._move) { this._move = null; } return this["add" + j](this._orient); }; }; var nf = function (n) { return function () { this._dateElement = n; return this; }; }; for (var k = 0; k < px.length; k++) { de = px[k].toLowerCase(); if(de !== "weekday") { // Create date element functions and plural date element functions used with Date (eg. day(), days(), months()). $P[de] = $P[de + "s"] = ef(px[k]); // Create date element functions and plural date element functions used with Number (eg. day(), days(), months()). $N[de] = $N[de + "s"] = nf(de + "s"); } } $P._ss = ef("Second"); var nthfn = function (n) { return function (dayOfWeek) { if (this._same) { return this._ss(arguments[0]); } if (dayOfWeek || dayOfWeek === 0) { return this.moveToNthOccurrence(dayOfWeek, n); } this._nth = n; // if the operator is 'second' add the _orient, then deal with it later... if (n === 2 && (dayOfWeek === undefined || dayOfWeek === null)) { this._isSecond = true; return this.addSeconds(this._orient); } return this; }; }; for (var l = 0; l < nth.length; l++) { $P[nth[l]] = (l === 0) ? nthfn(-1) : nthfn(l); } }()); (function () { var $D = Date, $P = $D.prototype, // $C = $D.CultureInfo, // not used atm $f = [], p = function (s, l) { if (!l) { l = 2; } return ("000" + s).slice(l * -1); }; /** * Converts a PHP format string to Java/.NET format string. * A PHP format string can be used with .$format or .format. * A Java/.NET format string can be used with .toString(). * The .parseExact function will only accept a Java/.NET format string * * Example
	 var f1 = "%m/%d/%y"
	 var f2 = Date.normalizeFormat(f1); // "MM/dd/yy"

	 new Date().format(f1);    // "04/13/08"
	 new Date().$format(f1);   // "04/13/08"
	 new Date().toString(f2);  // "04/13/08"

	 var date = Date.parseExact("04/13/08", f2); // Sun Apr 13 2008
	 
* @param {String} A PHP format string consisting of one or more format spcifiers. * @return {String} The PHP format converted to a Java/.NET format string. */ $D.normalizeFormat = function (format) { // function does nothing atm // $f = []; // var t = new Date().$format(format); // return $f.join(""); return format; }; /** * Format a local Unix timestamp according to locale settings * * Example
	 Date.strftime("%m/%d/%y", new Date());       // "04/13/08"
	 Date.strftime("c", "2008-04-13T17:52:03Z");  // "04/13/08"
	 
* @param {String} A format string consisting of one or more format spcifiers [Optional]. * @param {Number} The number representing the number of seconds that have elapsed since January 1, 1970 (local time). * @return {String} A string representation of the current Date object. */ $D.strftime = function (format, time) { return new Date(time * 1000).$format(format); }; /** * Parse any textual datetime description into a Unix timestamp. * A Unix timestamp is the number of seconds that have elapsed since January 1, 1970 (midnight UTC/GMT). * * Example
	 Date.strtotime("04/13/08");              // 1208044800
	 Date.strtotime("1970-01-01T00:00:00Z");  // 0
	 
* @param {String} A format string consisting of one or more format spcifiers [Optional]. * @param {Object} A string or date object. * @return {String} A string representation of the current Date object. */ $D.strtotime = function (time) { var d = $D.parse(time); d.addMinutes(d.getTimezoneOffset() * -1); return Math.round($D.UTC(d.getUTCFullYear(), d.getUTCMonth(), d.getUTCDate(), d.getUTCHours(), d.getUTCMinutes(), d.getUTCSeconds(), d.getUTCMilliseconds()) / 1000); }; /** * Converts the value of the current Date object to its equivalent string representation using a PHP/Unix style of date format specifiers. * * The following descriptions are from http://www.php.net/strftime and http://www.php.net/manual/en/function.date.php. * Copyright � 2001-2008 The PHP Group * * Format Specifiers
	Format  Description                                                                  Example
	------  ---------------------------------------------------------------------------  -----------------------
	 %a     abbreviated weekday name according to the current localed                    "Mon" through "Sun"
	 %A     full weekday name according to the current locale                            "Sunday" through "Saturday"
	 %b     abbreviated month name according to the current locale                       "Jan" through "Dec"
	 %B     full month name according to the current locale                              "January" through "December"
	 %c     preferred date and time representation for the current locale                "4/13/2008 12:33 PM"
	 %C     century number (the year divided by 100 and truncated to an integer)         "00" to "99"
	 %d     day of the month as a decimal number                                         "01" to "31"
	 %D     same as %m/%d/%y                                                             "04/13/08"
	 %e     day of the month as a decimal number, a single digit is preceded by a space  "1" to "31"
	 %g     like %G, but without the century                                             "08"
	 %G     The 4-digit year corresponding to the ISO week number (see %V).              "2008"
			This has the same format and value as %Y, except that if the ISO week number 
			belongs to the previous or next year, that year is used instead.
	 %h     same as %b                                                                   "Jan" through "Dec"
	 %H     hour as a decimal number using a 24-hour clock                               "00" to "23"
	 %I     hour as a decimal number using a 12-hour clock                               "01" to "12"
	 %j     day of the year as a decimal number                                          "001" to "366"
	 %m     month as a decimal number                                                    "01" to "12"
	 %M     minute as a decimal number                                                   "00" to "59"
	 %n     newline character                                                            "\n"
	 %p     either "am" or "pm" according to the given time value, or the                "am" or "pm"
			corresponding strings for the current locale
	 %r     time in a.m. and p.m. notation                                               "8:44 PM"
	 %R     time in 24 hour notation                                                     "20:44"
	 %S     second as a decimal number                                                   "00" to "59"
	 %t     tab character                                                                "\t"
	 %T     current time, equal to %H:%M:%S                                              "12:49:11"
	 %u     weekday as a decimal number ["1", "7"], with "1" representing Monday         "1" to "7"
	 %U     week number of the current year as a decimal number, starting with the       "0" to ("52" or "53")
			first Sunday as the first day of the first week
	 %V     The ISO 8601:1988 week number of the current year as a decimal number,       "00" to ("52" or "53")
			range 01 to 53, where week 1 is the first week that has at least 4 days 
			in the current year, and with Monday as the first day of the week. 
			(Use %G or %g for the year component that corresponds to the week number 
			for the specified timestamp.)
	 %W     week number of the current year as a decimal number, starting with the       "00" to ("52" or "53")
			first Monday as the first day of the first week
	 %w     day of the week as a decimal, Sunday being "0"                               "0" to "6"
	 %x     preferred date representation for the current locale without the time        "4/13/2008"
	 %X     preferred time representation for the current locale without the date        "12:53:05"
	 %y     year as a decimal number without a century                                   "00" "99"
	 %Y     year as a decimal number including the century                               "2008"
	 %Z     time zone or name or abbreviation                                            "UTC", "EST", "PST"
	 %z     same as %Z 
	 %%     a literal "%" character                                                      "%"
	 d      Day of the month, 2 digits with leading zeros                                "01" to "31"
	 D      A textual representation of a day, three letters                             "Mon" through "Sun"
	 j      Day of the month without leading zeros                                       "1" to "31"
	 l      A full textual representation of the day of the week (lowercase "L")         "Sunday" through "Saturday"
	 N      ISO-8601 numeric representation of the day of the week (added in PHP 5.1.0)  "1" (for Monday) through "7" (for Sunday)
	 S      English ordinal suffix for the day of the month, 2 characters                "st", "nd", "rd" or "th". Works well with j
	 w      Numeric representation of the day of the week                                "0" (for Sunday) through "6" (for Saturday)
	 z      The day of the year (starting from "0")                                      "0" through "365"      
	 W      ISO-8601 week number of year, weeks starting on Monday                       "00" to ("52" or "53")
	 F      A full textual representation of a month, such as January or March           "January" through "December"
	 m      Numeric representation of a month, with leading zeros                        "01" through "12"
	 M      A short textual representation of a month, three letters                     "Jan" through "Dec"
	 n      Numeric representation of a month, without leading zeros                     "1" through "12"
	 t      Number of days in the given month                                            "28" through "31"
	 L      Whether it's a leap year                                                     "1" if it is a leap year, "0" otherwise
	 o      ISO-8601 year number. This has the same value as Y, except that if the       "2008"
			ISO week number (W) belongs to the previous or next year, that year 
			is used instead.
	 Y      A full numeric representation of a year, 4 digits                            "2008"
	 y      A two digit representation of a year                                         "08"
	 a      Lowercase Ante meridiem and Post meridiem                                    "am" or "pm"
	 A      Uppercase Ante meridiem and Post meridiem                                    "AM" or "PM"
	 B      Swatch Internet time                                                         "000" through "999"
	 g      12-hour format of an hour without leading zeros                              "1" through "12"
	 G      24-hour format of an hour without leading zeros                              "0" through "23"
	 h      12-hour format of an hour with leading zeros                                 "01" through "12"
	 H      24-hour format of an hour with leading zeros                                 "00" through "23"
	 i      Minutes with leading zeros                                                   "00" to "59"
	 s      Seconds, with leading zeros                                                  "00" through "59"
	 u      Milliseconds                                                                 "54321"
	 e      Timezone identifier                                                          "UTC", "EST", "PST"
	 I      Whether or not the date is in daylight saving time (uppercase i)             "1" if Daylight Saving Time, "0" otherwise
	 O      Difference to Greenwich time (GMT) in hours                                  "+0200", "-0600"
	 P      Difference to Greenwich time (GMT) with colon between hours and minutes      "+02:00", "-06:00"
	 T      Timezone abbreviation                                                        "UTC", "EST", "PST"
	 Z      Timezone offset in seconds. The offset for timezones west of UTC is          "-43200" through "50400"
			always negative, and for those east of UTC is always positive.
	 c      ISO 8601 date                                                                "2004-02-12T15:19:21+00:00"
	 r      RFC 2822 formatted date                                                      "Thu, 21 Dec 2000 16:01:07 +0200"
	 U      Seconds since the Unix Epoch (January 1 1970 00:00:00 GMT)                   "0"     
	 
* @param {String} A format string consisting of one or more format spcifiers [Optional]. * @return {String} A string representation of the current Date object. */ $P.$format = function (format) { var x = this, y, t = function (v, overrideStandardFormats) { $f.push(v); return x.toString(v, overrideStandardFormats); }; return format ? format.replace(/(%|\\)?.|%%/g, function (m) { if (m.charAt(0) === "\\" || m.substring(0, 2) === "%%") { return m.replace("\\", "").replace("%%", "%"); } switch (m) { case "d": case "%d": return t("dd"); case "D": case "%a": return t("ddd"); case "j": case "%e": return t("d", true); case "l": case "%A": return t("dddd"); case "N": case "%u": return x.getDay() + 1; case "S": return t("S"); case "w": case "%w": return x.getDay(); case "z": return x.getOrdinalNumber(); case "%j": return p(x.getOrdinalNumber(), 3); case "%U": var d1 = x.clone().set({month: 0, day: 1}).addDays(-1).moveToDayOfWeek(0), d2 = x.clone().addDays(1).moveToDayOfWeek(0, -1); return (d2 < d1) ? "00" : p((d2.getOrdinalNumber() - d1.getOrdinalNumber()) / 7 + 1); case "W": case "%V": return x.getISOWeek(); case "%W": return p(x.getWeek()); case "F": case "%B": return t("MMMM"); case "m": case "%m": return t("MM"); case "M": case "%b": case "%h": return t("MMM"); case "n": return t("M"); case "t": return $D.getDaysInMonth(x.getFullYear(), x.getMonth()); case "L": return ($D.isLeapYear(x.getFullYear())) ? 1 : 0; case "o": case "%G": return x.setWeek(x.getISOWeek()).toString("yyyy"); case "%g": return x.$format("%G").slice(-2); case "Y": case "%Y": return t("yyyy"); case "y": case "%y": return t("yy"); case "a": case "%p": return t("tt").toLowerCase(); case "A": return t("tt").toUpperCase(); case "g": case "%I": return t("h"); case "G": return t("H"); case "h": return t("hh"); case "H": case "%H": return t("HH"); case "i": case "%M": return t("mm"); case "s": case "%S": return t("ss"); case "u": return p(x.getMilliseconds(), 3); case "I": return (x.isDaylightSavingTime()) ? 1 : 0; case "O": return x.getUTCOffset(); case "P": y = x.getUTCOffset(); return y.substring(0, y.length - 2) + ":" + y.substring(y.length - 2); case "e": case "T": case "%z": case "%Z": return x.getTimezone(); case "Z": return x.getTimezoneOffset() * -60; case "B": var now = new Date(); return Math.floor(((now.getHours() * 3600) + (now.getMinutes() * 60) + now.getSeconds() + (now.getTimezoneOffset() + 60) * 60) / 86.4); case "c": return x.toISOString().replace(/\"/g, ""); case "U": return $D.strtotime("now"); case "%c": return t("d") + " " + t("t"); case "%C": return Math.floor(x.getFullYear() / 100 + 1); case "%D": return t("MM/dd/yy"); case "%n": return "\\n"; case "%t": return "\\t"; case "%r": return t("hh:mm tt"); case "%R": return t("H:mm"); case "%T": return t("H:mm:ss"); case "%x": return t("d"); case "%X": return t("t"); default: $f.push(m); return m; } }) : this._toString(); }; if (!$P.format) { $P.format = $P.$format; } }()); /* * TimeSpan(milliseconds); * TimeSpan(days, hours, minutes, seconds); * TimeSpan(days, hours, minutes, seconds, milliseconds); */ var TimeSpan = function (days, hours, minutes, seconds, milliseconds) { var attrs = "days hours minutes seconds milliseconds".split(/\s+/); var gFn = function (attr) { return function () { return this[attr]; }; }; var sFn = function (attr) { return function (val) { this[attr] = val; return this; }; }; for (var i = 0; i < attrs.length ; i++) { var $a = attrs[i], $b = $a.slice(0, 1).toUpperCase() + $a.slice(1); TimeSpan.prototype[$a] = 0; TimeSpan.prototype["get" + $b] = gFn($a); TimeSpan.prototype["set" + $b] = sFn($a); } if (arguments.length === 4) { this.setDays(days); this.setHours(hours); this.setMinutes(minutes); this.setSeconds(seconds); } else if (arguments.length === 5) { this.setDays(days); this.setHours(hours); this.setMinutes(minutes); this.setSeconds(seconds); this.setMilliseconds(milliseconds); } else if (arguments.length === 1 && typeof days === "number") { var orient = (days < 0) ? -1 : +1; this.setMilliseconds(Math.abs(days)); this.setDays(Math.floor(this.getMilliseconds() / 86400000) * orient); this.setMilliseconds(this.getMilliseconds() % 86400000); this.setHours(Math.floor(this.getMilliseconds() / 3600000) * orient); this.setMilliseconds(this.getMilliseconds() % 3600000); this.setMinutes(Math.floor(this.getMilliseconds() / 60000) * orient); this.setMilliseconds(this.getMilliseconds() % 60000); this.setSeconds(Math.floor(this.getMilliseconds() / 1000) * orient); this.setMilliseconds(this.getMilliseconds() % 1000); this.setMilliseconds(this.getMilliseconds() * orient); } this.getTotalMilliseconds = function () { return (this.getDays() * 86400000) + (this.getHours() * 3600000) + (this.getMinutes() * 60000) + (this.getSeconds() * 1000); }; this.compareTo = function (time) { var t1 = new Date(1970, 1, 1, this.getHours(), this.getMinutes(), this.getSeconds()), t2; if (time === null) { t2 = new Date(1970, 1, 1, 0, 0, 0); } else { t2 = new Date(1970, 1, 1, time.getHours(), time.getMinutes(), time.getSeconds()); } return (t1 < t2) ? -1 : (t1 > t2) ? 1 : 0; }; this.equals = function (time) { return (this.compareTo(time) === 0); }; this.add = function (time) { return (time === null) ? this : this.addSeconds(time.getTotalMilliseconds() / 1000); }; this.subtract = function (time) { return (time === null) ? this : this.addSeconds(-time.getTotalMilliseconds() / 1000); }; this.addDays = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 86400000)); }; this.addHours = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 3600000)); }; this.addMinutes = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 60000)); }; this.addSeconds = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 1000)); }; this.addMilliseconds = function (n) { return new TimeSpan(this.getTotalMilliseconds() + n); }; this.get12HourHour = function () { return (this.getHours() > 12) ? this.getHours() - 12 : (this.getHours() === 0) ? 12 : this.getHours(); }; this.getDesignator = function () { return (this.getHours() < 12) ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator; }; this.toString = function (format) { this._toString = function () { if (this.getDays() !== null && this.getDays() > 0) { return this.getDays() + "." + this.getHours() + ":" + this.p(this.getMinutes()) + ":" + this.p(this.getSeconds()); } else { return this.getHours() + ":" + this.p(this.getMinutes()) + ":" + this.p(this.getSeconds()); } }; this.p = function (s) { return (s.toString().length < 2) ? "0" + s : s; }; var me = this; return format ? format.replace(/dd?|HH?|hh?|mm?|ss?|tt?/g, function (format) { switch (format) { case "d": return me.getDays(); case "dd": return me.p(me.getDays()); case "H": return me.getHours(); case "HH": return me.p(me.getHours()); case "h": return me.get12HourHour(); case "hh": return me.p(me.get12HourHour()); case "m": return me.getMinutes(); case "mm": return me.p(me.getMinutes()); case "s": return me.getSeconds(); case "ss": return me.p(me.getSeconds()); case "t": return ((me.getHours() < 12) ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator).substring(0, 1); case "tt": return (me.getHours() < 12) ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator; } } ) : this._toString(); }; return this; }; /** * Gets the time of day for this date instances. * @return {TimeSpan} TimeSpan */ Date.prototype.getTimeOfDay = function () { return new TimeSpan(0, this.getHours(), this.getMinutes(), this.getSeconds(), this.getMilliseconds()); }; /* * TimePeriod(startDate, endDate); * TimePeriod(years, months, days, hours, minutes, seconds, milliseconds); */ var TimePeriod = function (years, months, days, hours, minutes, seconds, milliseconds) { var attrs = "years months days hours minutes seconds milliseconds".split(/\s+/); var gFn = function (attr) { return function () { return this[attr]; }; }; var sFn = function (attr) { return function (val) { this[attr] = val; return this; }; }; for (var i = 0; i < attrs.length ; i++) { var $a = attrs[i], $b = $a.slice(0, 1).toUpperCase() + $a.slice(1); TimePeriod.prototype[$a] = 0; TimePeriod.prototype["get" + $b] = gFn($a); TimePeriod.prototype["set" + $b] = sFn($a); } if (arguments.length === 7) { this.years = years; this.months = months; this.setDays(days); this.setHours(hours); this.setMinutes(minutes); this.setSeconds(seconds); this.setMilliseconds(milliseconds); } else if (arguments.length === 2 && arguments[0] instanceof Date && arguments[1] instanceof Date) { // startDate and endDate as arguments var d1 = years.clone(); var d2 = months.clone(); var temp = d1.clone(); var orient = (d1 > d2) ? -1 : +1; this.years = d2.getFullYear() - d1.getFullYear(); temp.addYears(this.years); if (orient === +1) { if (temp > d2) { if (this.years !== 0) { this.years--; } } } else { if (temp < d2) { if (this.years !== 0) { this.years++; } } } d1.addYears(this.years); if (orient === +1) { while (d1 < d2 && d1.clone().addMonths(1) <= d2) { d1.addMonths(1); this.months++; } } else { while (d1 > d2 && d1.clone().addDays(-d1.getDaysInMonth()) > d2) { d1.addMonths(-1); this.months--; } } var diff = d2 - d1; if (diff !== 0) { var ts = new TimeSpan(diff); this.setDays(ts.getDays()); this.setHours(ts.getHours()); this.setMinutes(ts.getMinutes()); this.setSeconds(ts.getSeconds()); this.setMilliseconds(ts.getMilliseconds()); } } return this; }; ================================================ FILE: build/date-en-ZA.js ================================================ /** * @overview datejs * @version 1.0.0-rc3 * @author Gregory Wild-Smith * @copyright 2015 Gregory Wild-Smith * @license MIT * @homepage https://github.com/abritinthebay/datejs */ /* * DateJS Culture String File * Country Code: en-ZA * Name: English (South Africa) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["en-ZA"] = { "name": "en-ZA", "englishName": "English (South Africa)", "nativeName": "English (South Africa)", "Sunday": "Sunday", "Monday": "Monday", "Tuesday": "Tuesday", "Wednesday": "Wednesday", "Thursday": "Thursday", "Friday": "Friday", "Saturday": "Saturday", "Sun": "Sun", "Mon": "Mon", "Tue": "Tue", "Wed": "Wed", "Thu": "Thu", "Fri": "Fri", "Sat": "Sat", "Su": "Su", "Mo": "Mo", "Tu": "Tu", "We": "We", "Th": "Th", "Fr": "Fr", "Sa": "Sa", "S_Sun_Initial": "S", "M_Mon_Initial": "M", "T_Tue_Initial": "T", "W_Wed_Initial": "W", "T_Thu_Initial": "T", "F_Fri_Initial": "F", "S_Sat_Initial": "S", "January": "January", "February": "February", "March": "March", "April": "April", "May": "May", "June": "June", "July": "July", "August": "August", "September": "September", "October": "October", "November": "November", "December": "December", "Jan_Abbr": "Jan", "Feb_Abbr": "Feb", "Mar_Abbr": "Mar", "Apr_Abbr": "Apr", "May_Abbr": "May", "Jun_Abbr": "Jun", "Jul_Abbr": "Jul", "Aug_Abbr": "Aug", "Sep_Abbr": "Sep", "Oct_Abbr": "Oct", "Nov_Abbr": "Nov", "Dec_Abbr": "Dec", "AM": "AM", "PM": "PM", "firstDayOfWeek": 0, "twoDigitYearMax": 2029, "mdy": "ymd", "M/d/yyyy": "yyyy/MM/dd", "dddd, MMMM dd, yyyy": "dd MMMM yyyy", "h:mm tt": "hh:mm tt", "h:mm:ss tt": "hh:mm:ss tt", "dddd, MMMM dd, yyyy h:mm:ss tt": "dd MMMM yyyy hh:mm:ss tt", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "dd MMMM", "MMMM, yyyy": "MMMM yyyy", "/jan(uary)?/": "jan(uary)?", "/feb(ruary)?/": "feb(ruary)?", "/mar(ch)?/": "mar(ch)?", "/apr(il)?/": "apr(il)?", "/may/": "may", "/jun(e)?/": "jun(e)?", "/jul(y)?/": "jul(y)?", "/aug(ust)?/": "aug(ust)?", "/sep(t(ember)?)?/": "sep(t(ember)?)?", "/oct(ober)?/": "oct(ober)?", "/nov(ember)?/": "nov(ember)?", "/dec(ember)?/": "dec(ember)?", "/^su(n(day)?)?/": "^su(n(day)?)?", "/^mo(n(day)?)?/": "^mo(n(day)?)?", "/^tu(e(s(day)?)?)?/": "^tu(e(s(day)?)?)?", "/^we(d(nesday)?)?/": "^we(d(nesday)?)?", "/^th(u(r(s(day)?)?)?)?/": "^th(u(r(s(day)?)?)?)?", "/^fr(i(day)?)?/": "^fr(i(day)?)?", "/^sa(t(urday)?)?/": "^sa(t(urday)?)?", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "en-ZA"; /** * @overview datejs * @version 1.0.0-rc3 * @author Gregory Wild-Smith * @copyright 2015 Gregory Wild-Smith * @license MIT * @homepage https://github.com/abritinthebay/datejs */(function () { var $D = Date; var lang = Date.CultureStrings ? Date.CultureStrings.lang : null; var loggedKeys = {}; // for debug purposes. var getText = { getFromKey: function (key, countryCode) { var output; if (Date.CultureStrings && Date.CultureStrings[countryCode] && Date.CultureStrings[countryCode][key]) { output = Date.CultureStrings[countryCode][key]; } else { output = getText.buildFromDefault(key); } if (key.charAt(0) === "/") { // Assume it's a regex output = getText.buildFromRegex(key, countryCode); } return output; }, getFromObjectValues: function (obj, countryCode) { var key, output = {}; for(key in obj) { if (obj.hasOwnProperty(key)) { output[key] = getText.getFromKey(obj[key], countryCode); } } return output; }, getFromObjectKeys: function (obj, countryCode) { var key, output = {}; for(key in obj) { if (obj.hasOwnProperty(key)) { output[getText.getFromKey(key, countryCode)] = obj[key]; } } return output; }, getFromArray: function (arr, countryCode) { var output = []; for (var i=0; i < arr.length; i++){ if (i in arr) { output[i] = getText.getFromKey(arr[i], countryCode); } } return output; }, buildFromDefault: function (key) { var output, length, split, last; switch(key) { case "name": output = "en-US"; break; case "englishName": output = "English (United States)"; break; case "nativeName": output = "English (United States)"; break; case "twoDigitYearMax": output = 2049; break; case "firstDayOfWeek": output = 0; break; default: output = key; split = key.split("_"); length = split.length; if (length > 1 && key.charAt(0) !== "/") { // if the key isn't a regex and it has a split. last = split[(length - 1)].toLowerCase(); if (last === "initial" || last === "abbr") { output = split[0]; } } break; } return output; }, buildFromRegex: function (key, countryCode) { var output; if (Date.CultureStrings && Date.CultureStrings[countryCode] && Date.CultureStrings[countryCode][key]) { output = new RegExp(Date.CultureStrings[countryCode][key], "i"); } else { output = new RegExp(key.replace(new RegExp("/", "g"),""), "i"); } return output; } }; var shallowMerge = function (obj1, obj2) { for (var attrname in obj2) { if (obj2.hasOwnProperty(attrname)) { obj1[attrname] = obj2[attrname]; } } }; var __ = function (key, language) { var countryCode = (language) ? language : lang; loggedKeys[key] = key; if (typeof key === "object") { if (key instanceof Array) { return getText.getFromArray(key, countryCode); } else { return getText.getFromObjectKeys(key, countryCode); } } else { return getText.getFromKey(key, countryCode); } }; var loadI18nScript = function (code) { // paatterned after jQuery's getScript. var url = Date.Config.i18n + code + ".js"; var head = document.getElementsByTagName("head")[0] || document.documentElement; var script = document.createElement("script"); script.src = url; var completed = false; var events = { done: function (){} // placeholder function }; // Attach handlers for all browsers script.onload = script.onreadystatechange = function() { if ( !completed && (!this.readyState || this.readyState === "loaded" || this.readyState === "complete") ) { events.done(); head.removeChild(script); } }; setTimeout(function() { head.insertBefore(script, head.firstChild); }, 0); // allows return to execute first return { done: function (cb) { events.done = function() { if (cb) { setTimeout(cb,0); } }; } }; }; var buildInfo = { buildFromMethodHash: function (obj) { var key; for(key in obj) { if (obj.hasOwnProperty(key)) { obj[key] = buildInfo[obj[key]](); } } return obj; }, timeZoneDST: function () { var DST = { "CHADT": "+1345", "NZDT": "+1300", "AEDT": "+1100", "ACDT": "+1030", "AZST": "+0500", "IRDT": "+0430", "EEST": "+0300", "CEST": "+0200", "BST": "+0100", "PMDT": "-0200", "ADT": "-0300", "NDT": "-0230", "EDT": "-0400", "CDT": "-0500", "MDT": "-0600", "PDT": "-0700", "AKDT": "-0800", "HADT": "-0900" }; return __(DST); }, timeZoneStandard: function () { var standard = { "LINT": "+1400", "TOT": "+1300", "CHAST": "+1245", "NZST": "+1200", "NFT": "+1130", "SBT": "+1100", "AEST": "+1000", "ACST": "+0930", "JST": "+0900", "CWST": "+0845", "CT": "+0800", "ICT": "+0700", "MMT": "+0630", "BST": "+0600", "NPT": "+0545", "IST": "+0530", "PKT": "+0500", "AFT": "+0430", "MSK": "+0400", "IRST": "+0330", "FET": "+0300", "EET": "+0200", "CET": "+0100", "GMT": "+0000", "UTC": "+0000", "CVT": "-0100", "GST": "-0200", "BRT": "-0300", "NST": "-0330", "AST": "-0400", "EST": "-0500", "CST": "-0600", "MST": "-0700", "PST": "-0800", "AKST": "-0900", "MIT": "-0930", "HST": "-1000", "SST": "-1100", "BIT": "-1200" }; return __(standard); }, timeZones: function (data) { var zone; data.timezones = []; for (zone in data.abbreviatedTimeZoneStandard) { if (data.abbreviatedTimeZoneStandard.hasOwnProperty(zone)) { data.timezones.push({ name: zone, offset: data.abbreviatedTimeZoneStandard[zone]}); } } for (zone in data.abbreviatedTimeZoneDST) { if (data.abbreviatedTimeZoneDST.hasOwnProperty(zone)) { data.timezones.push({ name: zone, offset: data.abbreviatedTimeZoneDST[zone], dst: true}); } } return data.timezones; }, days: function () { return __(["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"]); }, dayAbbr: function () { return __(["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"]); }, dayShortNames: function () { return __(["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"]); }, dayFirstLetters: function () { return __(["S_Sun_Initial", "M_Mon_Initial", "T_Tues_Initial", "W_Wed_Initial", "T_Thu_Initial", "F_Fri_Initial", "S_Sat_Initial"]); }, months: function () { return __(["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"]); }, monthAbbr: function () { return __(["Jan_Abbr", "Feb_Abbr", "Mar_Abbr", "Apr_Abbr", "May_Abbr", "Jun_Abbr", "Jul_Abbr", "Aug_Abbr", "Sep_Abbr", "Oct_Abbr", "Nov_Abbr", "Dec_Abbr"]); }, formatPatterns: function () { return getText.getFromObjectValues({ shortDate: "M/d/yyyy", longDate: "dddd, MMMM dd, yyyy", shortTime: "h:mm tt", longTime: "h:mm:ss tt", fullDateTime: "dddd, MMMM dd, yyyy h:mm:ss tt", sortableDateTime: "yyyy-MM-ddTHH:mm:ss", universalSortableDateTime: "yyyy-MM-dd HH:mm:ssZ", rfc1123: "ddd, dd MMM yyyy HH:mm:ss", monthDay: "MMMM dd", yearMonth: "MMMM, yyyy" }, Date.i18n.currentLanguage()); }, regex: function () { return getText.getFromObjectValues({ inTheMorning: "/( in the )(morn(ing)?)\\b/", thisMorning: "/(this )(morn(ing)?)\\b/", amThisMorning: "/(\b\\d(am)? )(this )(morn(ing)?)/", inTheEvening: "/( in the )(even(ing)?)\\b/", thisEvening: "/(this )(even(ing)?)\\b/", pmThisEvening: "/(\b\\d(pm)? )(this )(even(ing)?)/", jan: "/jan(uary)?/", feb: "/feb(ruary)?/", mar: "/mar(ch)?/", apr: "/apr(il)?/", may: "/may/", jun: "/jun(e)?/", jul: "/jul(y)?/", aug: "/aug(ust)?/", sep: "/sep(t(ember)?)?/", oct: "/oct(ober)?/", nov: "/nov(ember)?/", dec: "/dec(ember)?/", sun: "/^su(n(day)?)?/", mon: "/^mo(n(day)?)?/", tue: "/^tu(e(s(day)?)?)?/", wed: "/^we(d(nesday)?)?/", thu: "/^th(u(r(s(day)?)?)?)?/", fri: "/fr(i(day)?)?/", sat: "/^sa(t(urday)?)?/", future: "/^next/", past: "/^last|past|prev(ious)?/", add: "/^(\\+|aft(er)?|from|hence)/", subtract: "/^(\\-|bef(ore)?|ago)/", yesterday: "/^yes(terday)?/", today: "/^t(od(ay)?)?/", tomorrow: "/^tom(orrow)?/", now: "/^n(ow)?/", millisecond: "/^ms|milli(second)?s?/", second: "/^sec(ond)?s?/", minute: "/^mn|min(ute)?s?/", hour: "/^h(our)?s?/", week: "/^w(eek)?s?/", month: "/^m(onth)?s?/", day: "/^d(ay)?s?/", year: "/^y(ear)?s?/", shortMeridian: "/^(a|p)/", longMeridian: "/^(a\\.?m?\\.?|p\\.?m?\\.?)/", timezone: "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/", ordinalSuffix: "/^\\s*(st|nd|rd|th)/", timeContext: "/^\\s*(\\:|a(?!u|p)|p)/" }, Date.i18n.currentLanguage()); } }; var CultureInfo = function () { var info = getText.getFromObjectValues({ name: "name", englishName: "englishName", nativeName: "nativeName", amDesignator: "AM", pmDesignator: "PM", firstDayOfWeek: "firstDayOfWeek", twoDigitYearMax: "twoDigitYearMax", dateElementOrder: "mdy" }, Date.i18n.currentLanguage()); var constructedInfo = buildInfo.buildFromMethodHash({ dayNames: "days", abbreviatedDayNames: "dayAbbr", shortestDayNames: "dayShortNames", firstLetterDayNames: "dayFirstLetters", monthNames: "months", abbreviatedMonthNames: "monthAbbr", formatPatterns: "formatPatterns", regexPatterns: "regex", abbreviatedTimeZoneDST: "timeZoneDST", abbreviatedTimeZoneStandard: "timeZoneStandard" }); shallowMerge(info, constructedInfo); buildInfo.timeZones(info); return info; }; $D.i18n = { __: function (key, lang) { return __(key, lang); }, currentLanguage: function () { return lang || "en-US"; }, setLanguage: function (code, force, cb) { var async = false; if (force || code === "en-US" || (!!Date.CultureStrings && !!Date.CultureStrings[code])) { lang = code; Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings.lang = code; Date.CultureInfo = new CultureInfo(); } else { if (!(!!Date.CultureStrings && !!Date.CultureStrings[code])) { if (typeof exports !== "undefined" && this.exports !== exports) { // we're in a Node enviroment, load it using require try { require("../i18n/" + code + ".js"); lang = code; Date.CultureStrings.lang = code; Date.CultureInfo = new CultureInfo(); } catch (e) { // var str = "The language for '" + code + "' could not be loaded by Node. It likely does not exist."; throw new Error("The DateJS IETF language tag '" + code + "' could not be loaded by Node. It likely does not exist."); } } else if (Date.Config && Date.Config.i18n) { // we know the location of the files, so lets load them async = true; loadI18nScript(code).done(function(){ lang = code; Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings.lang = code; Date.CultureInfo = new CultureInfo(); $D.Parsing.Normalizer.buildReplaceData(); // because this is async if ($D.Grammar) { $D.Grammar.buildGrammarFormats(); // so we can parse those strings... } if (cb) { setTimeout(cb,0); } }); } else { Date.console.error("The DateJS IETF language tag '" + code + "' is not available and has not been loaded."); return false; } } } $D.Parsing.Normalizer.buildReplaceData(); // rebuild normalizer strings if ($D.Grammar) { $D.Grammar.buildGrammarFormats(); // so we can parse those strings... } if (!async && cb) { setTimeout(cb,0); } }, getLoggedKeys: function () { return loggedKeys; }, updateCultureInfo: function () { Date.CultureInfo = new CultureInfo(); } }; $D.i18n.updateCultureInfo(); // run automatically }()); (function () { var $D = Date, $P = $D.prototype, p = function (s, l) { if (!l) { l = 2; } return ("000" + s).slice(l * -1); }; if (typeof window !== "undefined" && typeof window.console !== "undefined" && typeof window.console.log !== "undefined") { $D.console = console; // used only to raise non-critical errors if available } else { // set mock so we don't give errors. $D.console = { log: function(){}, error: function(){} }; } $D.Config = $D.Config || {}; $D.initOverloads = function() { /** * Overload of Date.now. Allows an alternate call for Date.now where it returns the * current Date as an object rather than just milliseconds since the Unix Epoch. * * Also provides an implementation of now() for browsers (IE<9) that don't have it. * * Backwards compatible so with work with either: * Date.now() [returns ms] * or * Date.now(true) [returns Date] */ if (!$D.now) { $D._now = function now() { return new Date().getTime(); }; } else if (!$D._now) { $D._now = $D.now; } $D.now = function (returnObj) { if (returnObj) { return $D.present(); } else { return $D._now(); } }; if ( !$P.toISOString ) { $P.toISOString = function() { return this.getUTCFullYear() + "-" + p(this.getUTCMonth() + 1) + "-" + p(this.getUTCDate()) + "T" + p(this.getUTCHours()) + ":" + p(this.getUTCMinutes()) + ":" + p(this.getUTCSeconds()) + "." + String( (this.getUTCMilliseconds()/1000).toFixed(3)).slice(2, 5) + "Z"; }; } // private if ( $P._toString === undefined ){ $P._toString = $P.toString; } }; $D.initOverloads(); /** * Gets a date that is set to the current date. The time is set to the start of the day (00:00 or 12:00 AM). * @return {Date} The current date. */ $D.today = function () { return new Date().clearTime(); }; /** * Gets a date that is set to the current date and time (same as new Date, but chainable) * @return {Date} The current date. */ $D.present = function () { return new Date(); }; /** * Compares the first date to the second date and returns an number indication of their relative values. * @param {Date} First Date object to compare [Required]. * @param {Date} Second Date object to compare to [Required]. * @return {Number} -1 = date1 is lessthan date2. 0 = values are equal. 1 = date1 is greaterthan date2. */ $D.compare = function (date1, date2) { if (isNaN(date1) || isNaN(date2)) { throw new Error(date1 + " - " + date2); } else if (date1 instanceof Date && date2 instanceof Date) { return (date1 < date2) ? -1 : (date1 > date2) ? 1 : 0; } else { throw new TypeError(date1 + " - " + date2); } }; /** * Compares the first Date object to the second Date object and returns true if they are equal. * @param {Date} First Date object to compare [Required] * @param {Date} Second Date object to compare to [Required] * @return {Boolean} true if dates are equal. false if they are not equal. */ $D.equals = function (date1, date2) { return (date1.compareTo(date2) === 0); }; /** * Gets the language appropriate day name when given the day number(0-6) * eg - 0 == Sunday * @return {String} The day name */ $D.getDayName = function (n) { return Date.CultureInfo.dayNames[n]; }; /** * Gets the day number (0-6) if given a CultureInfo specific string which is a valid dayName, abbreviatedDayName or shortestDayName (two char). * @param {String} The name of the day (eg. "Monday, "Mon", "tuesday", "tue", "We", "we"). * @return {Number} The day number */ $D.getDayNumberFromName = function (name) { var n = Date.CultureInfo.dayNames, m = Date.CultureInfo.abbreviatedDayNames, o = Date.CultureInfo.shortestDayNames, s = name.toLowerCase(); for (var i = 0; i < n.length; i++) { if (n[i].toLowerCase() === s || m[i].toLowerCase() === s || o[i].toLowerCase() === s) { return i; } } return -1; }; /** * Gets the month number (0-11) if given a Culture Info specific string which is a valid monthName or abbreviatedMonthName. * @param {String} The name of the month (eg. "February, "Feb", "october", "oct"). * @return {Number} The day number */ $D.getMonthNumberFromName = function (name) { var n = Date.CultureInfo.monthNames, m = Date.CultureInfo.abbreviatedMonthNames, s = name.toLowerCase(); for (var i = 0; i < n.length; i++) { if (n[i].toLowerCase() === s || m[i].toLowerCase() === s) { return i; } } return -1; }; /** * Gets the language appropriate month name when given the month number(0-11) * eg - 0 == January * @return {String} The month name */ $D.getMonthName = function (n) { return Date.CultureInfo.monthNames[n]; }; /** * Determines if the current date instance is within a LeapYear. * @param {Number} The year. * @return {Boolean} true if date is within a LeapYear, otherwise false. */ $D.isLeapYear = function (year) { return ((year % 4 === 0 && year % 100 !== 0) || year % 400 === 0); }; /** * Gets the number of days in the month, given a year and month value. Automatically corrects for LeapYear. * @param {Number} The year. * @param {Number} The month (0-11). * @return {Number} The number of days in the month. */ $D.getDaysInMonth = function (year, month) { if (!month && $D.validateMonth(year)) { month = year; year = Date.today().getFullYear(); } return [31, ($D.isLeapYear(year) ? 29 : 28), 31, 30, 31, 30, 31, 31, 30, 31, 30, 31][month]; }; $P.getDaysInMonth = function () { return $D.getDaysInMonth(this.getFullYear(), this.getMonth()); }; $D.getTimezoneAbbreviation = function (offset, dst) { var p, n = (dst || false) ? Date.CultureInfo.abbreviatedTimeZoneDST : Date.CultureInfo.abbreviatedTimeZoneStandard; for (p in n) { if (n.hasOwnProperty(p)) { if (n[p] === offset) { return p; } } } return null; }; $D.getTimezoneOffset = function (name, dst) { var i, a =[], z = Date.CultureInfo.timezones; if (!name) { name = (new Date()).getTimezone();} for (i = 0; i < z.length; i++) { if (z[i].name === name.toUpperCase()) { a.push(i); } } if (!z[a[0]]) { return null; } if (a.length === 1 || !dst) { return z[a[0]].offset; } else { for (i=0; i < a.length; i++) { if (z[a[i]].dst) { return z[a[i]].offset; } } } }; $D.getQuarter = function (d) { d = d || new Date(); // If no date supplied, use today var q = [1,2,3,4]; return q[Math.floor(d.getMonth() / 3)]; // ~~~ is a bitwise op. Faster than Math.floor }; $D.getDaysLeftInQuarter = function (d) { d = d || new Date(); var qEnd = new Date(d); qEnd.setMonth(qEnd.getMonth() + 3 - qEnd.getMonth() % 3, 0); return Math.floor((qEnd - d) / 8.64e7); }; // private var validate = function (n, min, max, name) { name = name ? name : "Object"; if (typeof n === "undefined") { return false; } else if (typeof n !== "number") { throw new TypeError(n + " is not a Number."); } else if (n < min || n > max) { // As failing validation is *not* an exceptional circumstance // lets not throw a RangeError Exception here. // It's semantically correct but it's not sensible. return false; } return true; }; /** * Validates the number is within an acceptable range for milliseconds [0-999]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateMillisecond = function (value) { return validate(value, 0, 999, "millisecond"); }; /** * Validates the number is within an acceptable range for seconds [0-59]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateSecond = function (value) { return validate(value, 0, 59, "second"); }; /** * Validates the number is within an acceptable range for minutes [0-59]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateMinute = function (value) { return validate(value, 0, 59, "minute"); }; /** * Validates the number is within an acceptable range for hours [0-23]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateHour = function (value) { return validate(value, 0, 23, "hour"); }; /** * Validates the number is within an acceptable range for the days in a month [0-MaxDaysInMonth]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateDay = function (value, year, month) { if (year === undefined || year === null || month === undefined || month === null) { return false;} return validate(value, 1, $D.getDaysInMonth(year, month), "day"); }; /** * Validates the number is within an acceptable range for months [0-11]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateWeek = function (value) { return validate(value, 0, 53, "week"); }; /** * Validates the number is within an acceptable range for months [0-11]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateMonth = function (value) { return validate(value, 0, 11, "month"); }; /** * Validates the number is within an acceptable range for years. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateYear = function (value) { /** * Per ECMAScript spec the range of times supported by Date objects is * exactly -100,000,000 days to +100,000,000 days measured relative to * midnight at the beginning of 01 January, 1970 UTC. * This gives a range of 8,640,000,000,000,000 milliseconds to either * side of 01 January, 1970 UTC. * * Earliest possible date: Tue, 20 Apr 271,822 B.C. 00:00:00 UTC * Latest possible date: Sat, 13 Sep 275,760 00:00:00 UTC */ return validate(value, -271822, 275760, "year"); }; $D.validateTimezone = function(value) { var timezones = {"ACDT":1,"ACST":1,"ACT":1,"ADT":1,"AEDT":1,"AEST":1,"AFT":1,"AKDT":1,"AKST":1,"AMST":1,"AMT":1,"ART":1,"AST":1,"AWDT":1,"AWST":1,"AZOST":1,"AZT":1,"BDT":1,"BIOT":1,"BIT":1,"BOT":1,"BRT":1,"BST":1,"BTT":1,"CAT":1,"CCT":1,"CDT":1,"CEDT":1,"CEST":1,"CET":1,"CHADT":1,"CHAST":1,"CHOT":1,"ChST":1,"CHUT":1,"CIST":1,"CIT":1,"CKT":1,"CLST":1,"CLT":1,"COST":1,"COT":1,"CST":1,"CT":1,"CVT":1,"CWST":1,"CXT":1,"DAVT":1,"DDUT":1,"DFT":1,"EASST":1,"EAST":1,"EAT":1,"ECT":1,"EDT":1,"EEDT":1,"EEST":1,"EET":1,"EGST":1,"EGT":1,"EIT":1,"EST":1,"FET":1,"FJT":1,"FKST":1,"FKT":1,"FNT":1,"GALT":1,"GAMT":1,"GET":1,"GFT":1,"GILT":1,"GIT":1,"GMT":1,"GST":1,"GYT":1,"HADT":1,"HAEC":1,"HAST":1,"HKT":1,"HMT":1,"HOVT":1,"HST":1,"ICT":1,"IDT":1,"IOT":1,"IRDT":1,"IRKT":1,"IRST":1,"IST":1,"JST":1,"KGT":1,"KOST":1,"KRAT":1,"KST":1,"LHST":1,"LINT":1,"MAGT":1,"MART":1,"MAWT":1,"MDT":1,"MET":1,"MEST":1,"MHT":1,"MIST":1,"MIT":1,"MMT":1,"MSK":1,"MST":1,"MUT":1,"MVT":1,"MYT":1,"NCT":1,"NDT":1,"NFT":1,"NPT":1,"NST":1,"NT":1,"NUT":1,"NZDT":1,"NZST":1,"OMST":1,"ORAT":1,"PDT":1,"PET":1,"PETT":1,"PGT":1,"PHOT":1,"PHT":1,"PKT":1,"PMDT":1,"PMST":1,"PONT":1,"PST":1,"PYST":1,"PYT":1,"RET":1,"ROTT":1,"SAKT":1,"SAMT":1,"SAST":1,"SBT":1,"SCT":1,"SGT":1,"SLST":1,"SRT":1,"SST":1,"SYOT":1,"TAHT":1,"THA":1,"TFT":1,"TJT":1,"TKT":1,"TLT":1,"TMT":1,"TOT":1,"TVT":1,"UCT":1,"ULAT":1,"UTC":1,"UYST":1,"UYT":1,"UZT":1,"VET":1,"VLAT":1,"VOLT":1,"VOST":1,"VUT":1,"WAKT":1,"WAST":1,"WAT":1,"WEDT":1,"WEST":1,"WET":1,"WST":1,"YAKT":1,"YEKT":1,"Z":1}; return (timezones[value] === 1); }; $D.validateTimezoneOffset= function(value) { // timezones go from +14hrs to -12hrs, the +X hours are negative offsets. return (value > -841 && value < 721); }; }()); (function () { var $D = Date, $P = $D.prototype, p = function (s, l) { if (!l) { l = 2; } return ("000" + s).slice(l * -1); }; var validateConfigObject = function (obj) { var result = {}, self = this, prop, testFunc; testFunc = function (prop, func, value) { if (prop === "day") { var month = (obj.month !== undefined) ? obj.month : self.getMonth(); var year = (obj.year !== undefined) ? obj.year : self.getFullYear(); return $D[func](value, year, month); } else { return $D[func](value); } }; for (prop in obj) { if (Object.prototype.hasOwnProperty.call(obj, prop)) { var func = "validate" + prop.charAt(0).toUpperCase() + prop.slice(1); if ($D[func] && obj[prop] !== null && testFunc(prop, func, obj[prop])) { result[prop] = obj[prop]; } } } return result; }; /** * Resets the time of this Date object to 12:00 AM (00:00), which is the start of the day. * @param {Boolean} .clone() this date instance before clearing Time * @return {Date} this */ $P.clearTime = function () { this.setHours(0); this.setMinutes(0); this.setSeconds(0); this.setMilliseconds(0); return this; }; /** * Resets the time of this Date object to the current time ('now'). * @return {Date} this */ $P.setTimeToNow = function () { var n = new Date(); this.setHours(n.getHours()); this.setMinutes(n.getMinutes()); this.setSeconds(n.getSeconds()); this.setMilliseconds(n.getMilliseconds()); return this; }; /** * Returns a new Date object that is an exact date and time copy of the original instance. * @return {Date} A new Date instance */ $P.clone = function () { return new Date(this.getTime()); }; /** * Compares this instance to a Date object and returns an number indication of their relative values. * @param {Date} Date object to compare [Required] * @return {Number} -1 = this is lessthan date. 0 = values are equal. 1 = this is greaterthan date. */ $P.compareTo = function (date) { return Date.compare(this, date); }; /** * Compares this instance to another Date object and returns true if they are equal. * @param {Date} Date object to compare. If no date to compare, new Date() [now] is used. * @return {Boolean} true if dates are equal. false if they are not equal. */ $P.equals = function (date) { return Date.equals(this, (date !== undefined ? date : new Date())); }; /** * Determines if this instance is between a range of two dates or equal to either the start or end dates. * @param {Date} Start of range [Required] * @param {Date} End of range [Required] * @return {Boolean} true is this is between or equal to the start and end dates, else false */ $P.between = function (start, end) { return this.getTime() >= start.getTime() && this.getTime() <= end.getTime(); }; /** * Determines if this date occurs after the date to compare to. * @param {Date} Date object to compare. If no date to compare, new Date() ("now") is used. * @return {Boolean} true if this date instance is greater than the date to compare to (or "now"), otherwise false. */ $P.isAfter = function (date) { return this.compareTo(date || new Date()) === 1; }; /** * Determines if this date occurs before the date to compare to. * @param {Date} Date object to compare. If no date to compare, new Date() ("now") is used. * @return {Boolean} true if this date instance is less than the date to compare to (or "now"). */ $P.isBefore = function (date) { return (this.compareTo(date || new Date()) === -1); }; /** * Determines if the current Date instance occurs today. * @return {Boolean} true if this date instance is 'today', otherwise false. */ /** * Determines if the current Date instance occurs on the same Date as the supplied 'date'. * If no 'date' to compare to is provided, the current Date instance is compared to 'today'. * @param {date} Date object to compare. If no date to compare, the current Date ("now") is used. * @return {Boolean} true if this Date instance occurs on the same Day as the supplied 'date'. */ $P.isToday = $P.isSameDay = function (date) { return this.clone().clearTime().equals((date || new Date()).clone().clearTime()); }; /** * Adds the specified number of milliseconds to this instance. * @param {Number} The number of milliseconds to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addMilliseconds = function (value) { if (!value) { return this; } this.setTime(this.getTime() + value * 1); return this; }; /** * Adds the specified number of seconds to this instance. * @param {Number} The number of seconds to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addSeconds = function (value) { if (!value) { return this; } return this.addMilliseconds(value * 1000); }; /** * Adds the specified number of seconds to this instance. * @param {Number} The number of seconds to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addMinutes = function (value) { if (!value) { return this; } return this.addMilliseconds(value * 60000); // 60*1000 }; /** * Adds the specified number of hours to this instance. * @param {Number} The number of hours to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addHours = function (value) { if (!value) { return this; } return this.addMilliseconds(value * 3600000); // 60*60*1000 }; /** * Adds the specified number of days to this instance. * @param {Number} The number of days to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addDays = function (value) { if (!value) { return this; } this.setDate(this.getDate() + value * 1); return this; }; /** * Adds the specified number of weekdays (ie - not sat or sun) to this instance. * @param {Number} The number of days to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addWeekdays = function (value) { if (!value) { return this; } var day = this.getDay(); var weeks = (Math.ceil(Math.abs(value)/7)); if (day === 0 || day === 6) { if (value > 0) { this.next().monday(); this.addDays(-1); day = this.getDay(); } } if (value < 0) { while (value < 0) { this.addDays(-1); day = this.getDay(); if (day !== 0 && day !== 6) { value++; } } return this; } else if (value > 5 || (6-day) <= value) { value = value + (weeks * 2); } return this.addDays(value); }; /** * Adds the specified number of weeks to this instance. * @param {Number} The number of weeks to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addWeeks = function (value) { if (!value) { return this; } return this.addDays(value * 7); }; /** * Adds the specified number of months to this instance. * @param {Number} The number of months to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addMonths = function (value) { if (!value) { return this; } var n = this.getDate(); this.setDate(1); this.setMonth(this.getMonth() + value * 1); this.setDate(Math.min(n, $D.getDaysInMonth(this.getFullYear(), this.getMonth()))); return this; }; $P.addQuarters = function (value) { if (!value) { return this; } // note this will take you to the same point in the quarter as you are now. // i.e. - if you are 15 days into the quarter you'll be 15 days into the resulting one. // bonus: this allows adding fractional quarters return this.addMonths(value * 3); }; /** * Adds the specified number of years to this instance. * @param {Number} The number of years to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addYears = function (value) { if (!value) { return this; } return this.addMonths(value * 12); }; /** * Adds (or subtracts) to the value of the years, months, weeks, days, hours, minutes, seconds, milliseconds of the date instance using given configuration object. Positive and Negative values allowed. * Example

	Date.today().add( { days: 1, months: 1 } )

	new Date().add( { years: -1 } )
	
* @param {Object} Configuration object containing attributes (months, days, etc.) * @return {Date} this */ $P.add = function (config) { if (typeof config === "number") { this._orient = config; return this; } var x = config; if (x.day) { // If we should be a different date than today (eg: for 'tomorrow -1d', etc). // Should only effect parsing, not direct usage (eg, Finish and FinishExact) if ((x.day - this.getDate()) !== 0) { this.setDate(x.day); } } if (x.milliseconds) { this.addMilliseconds(x.milliseconds); } if (x.seconds) { this.addSeconds(x.seconds); } if (x.minutes) { this.addMinutes(x.minutes); } if (x.hours) { this.addHours(x.hours); } if (x.weeks) { this.addWeeks(x.weeks); } if (x.months) { this.addMonths(x.months); } if (x.years) { this.addYears(x.years); } if (x.days) { this.addDays(x.days); } return this; }; /** * Get the week number. Week one (1) is the week which contains the first Thursday of the year. Monday is considered the first day of the week. * The .getWeek() function does NOT convert the date to UTC. The local datetime is used. * Please use .getISOWeek() to get the week of the UTC converted date. * @return {Number} 1 to 53 */ $P.getWeek = function (utc) { // Create a copy of this date object var self, target = new Date(this.valueOf()); if (utc) { target.addMinutes(target.getTimezoneOffset()); self = target.clone(); } else { self = this; } // ISO week date weeks start on monday // so correct the day number var dayNr = (self.getDay() + 6) % 7; // ISO 8601 states that week 1 is the week // with the first thursday of that year. // Set the target date to the thursday in the target week target.setDate(target.getDate() - dayNr + 3); // Store the millisecond value of the target date var firstThursday = target.valueOf(); // Set the target to the first thursday of the year // First set the target to january first target.setMonth(0, 1); // Not a thursday? Correct the date to the next thursday if (target.getDay() !== 4) { target.setMonth(0, 1 + ((4 - target.getDay()) + 7) % 7); } // The weeknumber is the number of weeks between the // first thursday of the year and the thursday in the target week return 1 + Math.ceil((firstThursday - target) / 604800000); // 604800000 = 7 * 24 * 3600 * 1000 }; /** * Get the ISO 8601 week number. Week one ("01") is the week which contains the first Thursday of the year. Monday is considered the first day of the week. * The .getISOWeek() function does convert the date to it's UTC value. Please use .getWeek() to get the week of the local date. * @return {String} "01" to "53" */ $P.getISOWeek = function () { return p(this.getWeek(true)); }; /** * Moves the date to Monday of the week set. Week one (1) is the week which contains the first Thursday of the year. * @param {Number} A Number (1 to 53) that represents the week of the year. * @return {Date} this */ $P.setWeek = function (n) { if ((n - this.getWeek()) === 0) { if (this.getDay() !== 1) { return this.moveToDayOfWeek(1, (this.getDay() > 1 ? -1 : 1)); } else { return this; } } else { return this.moveToDayOfWeek(1, (this.getDay() > 1 ? -1 : 1)).addWeeks(n - this.getWeek()); } }; $P.setQuarter = function (qtr) { var month = Math.abs(((qtr-1) * 3) + 1); return this.setMonth(month, 1); }; $P.getQuarter = function () { return Date.getQuarter(this); }; $P.getDaysLeftInQuarter = function () { return Date.getDaysLeftInQuarter(this); }; /** * Moves the date to the next n'th occurrence of the dayOfWeek starting from the beginning of the month. The number (-1) is a magic number and will return the last occurrence of the dayOfWeek in the month. * @param {Number} The dayOfWeek to move to * @param {Number} The n'th occurrence to move to. Use (-1) to return the last occurrence in the month * @return {Date} this */ $P.moveToNthOccurrence = function (dayOfWeek, occurrence) { if (dayOfWeek === "Weekday") { if (occurrence > 0) { this.moveToFirstDayOfMonth(); if (this.is().weekday()) { occurrence -= 1; } } else if (occurrence < 0) { this.moveToLastDayOfMonth(); if (this.is().weekday()) { occurrence += 1; } } else { return this; } return this.addWeekdays(occurrence); } var shift = 0; if (occurrence > 0) { shift = occurrence - 1; } else if (occurrence === -1) { this.moveToLastDayOfMonth(); if (this.getDay() !== dayOfWeek) { this.moveToDayOfWeek(dayOfWeek, -1); } return this; } return this.moveToFirstDayOfMonth().addDays(-1).moveToDayOfWeek(dayOfWeek, +1).addWeeks(shift); }; var moveToN = function (getFunc, addFunc, nVal) { return function (value, orient) { var diff = (value - this[getFunc]() + nVal * (orient || +1)) % nVal; return this[addFunc]((diff === 0) ? diff += nVal * (orient || +1) : diff); }; }; /** * Move to the next or last dayOfWeek based on the orient value. * @param {Number} The dayOfWeek to move to * @param {Number} Forward (+1) or Back (-1). Defaults to +1. [Optional] * @return {Date} this */ $P.moveToDayOfWeek = moveToN("getDay", "addDays", 7); /** * Move to the next or last month based on the orient value. * @param {Number} The month to move to. 0 = January, 11 = December * @param {Number} Forward (+1) or Back (-1). Defaults to +1. [Optional] * @return {Date} this */ $P.moveToMonth = moveToN("getMonth", "addMonths", 12); /** * Get the Ordinate of the current day ("th", "st", "rd"). * @return {String} */ $P.getOrdinate = function () { var num = this.getDate(); return ord(num); }; /** * Get the Ordinal day (numeric day number) of the year, adjusted for leap year. * @return {Number} 1 through 365 (366 in leap years) */ $P.getOrdinalNumber = function () { return Math.ceil((this.clone().clearTime() - new Date(this.getFullYear(), 0, 1)) / 86400000) + 1; }; /** * Get the time zone abbreviation of the current date. * @return {String} The abbreviated time zone name (e.g. "EST") */ $P.getTimezone = function () { return $D.getTimezoneAbbreviation(this.getUTCOffset(), this.isDaylightSavingTime()); }; $P.setTimezoneOffset = function (offset) { var here = this.getTimezoneOffset(), there = Number(offset) * -6 / 10; return (there || there === 0) ? this.addMinutes(there - here) : this; }; $P.setTimezone = function (offset) { return this.setTimezoneOffset($D.getTimezoneOffset(offset)); }; /** * Indicates whether Daylight Saving Time is observed in the current time zone. * @return {Boolean} true|false */ $P.hasDaylightSavingTime = function () { return (Date.today().set({month: 0, day: 1}).getTimezoneOffset() !== Date.today().set({month: 6, day: 1}).getTimezoneOffset()); }; /** * Indicates whether this Date instance is within the Daylight Saving Time range for the current time zone. * @return {Boolean} true|false */ $P.isDaylightSavingTime = function () { return Date.today().set({month: 0, day: 1}).getTimezoneOffset() !== this.getTimezoneOffset(); }; /** * Get the offset from UTC of the current date. * @return {String} The 4-character offset string prefixed with + or - (e.g. "-0500") */ $P.getUTCOffset = function (offset) { var n = (offset || this.getTimezoneOffset()) * -10 / 6, r; if (n < 0) { r = (n - 10000).toString(); return r.charAt(0) + r.substr(2); } else { r = (n + 10000).toString(); return "+" + r.substr(1); } }; /** * Returns the number of milliseconds between this date and date. * @param {Date} Defaults to now * @return {Number} The diff in milliseconds */ $P.getElapsed = function (date) { return (date || new Date()) - this; }; /** * Set the value of year, month, day, hour, minute, second, millisecond of date instance using given configuration object. * Example

	Date.today().set( { day: 20, month: 1 } )

	new Date().set( { millisecond: 0 } )
	
* * @param {Object} Configuration object containing attributes (month, day, etc.) * @return {Date} this */ $P.set = function (config) { config = validateConfigObject.call(this, config); var key; for (key in config) { if (Object.prototype.hasOwnProperty.call(config, key)) { var name = key.charAt(0).toUpperCase() + key.slice(1); var addFunc, getFunc; if (key !== "week" && key !== "month" && key !== "timezone" && key !== "timezoneOffset") { name += "s"; } addFunc = "add" + name; getFunc = "get" + name; if (key === "month") { addFunc = addFunc + "s"; } else if (key === "year"){ getFunc = "getFullYear"; } if (key !== "day" && key !== "timezone" && key !== "timezoneOffset" && key !== "week" && key !== "hour") { this[addFunc](config[key] - this[getFunc]()); } else if ( key === "timezone"|| key === "timezoneOffset" || key === "week" || key === "hour") { this["set"+name](config[key]); } } } // day has to go last because you can't validate the day without first knowing the month if (config.day) { this.addDays(config.day - this.getDate()); } return this; }; /** * Moves the date to the first day of the month. * @return {Date} this */ $P.moveToFirstDayOfMonth = function () { return this.set({ day: 1 }); }; /** * Moves the date to the last day of the month. * @return {Date} this */ $P.moveToLastDayOfMonth = function () { return this.set({ day: $D.getDaysInMonth(this.getFullYear(), this.getMonth())}); }; /** * Converts the value of the current Date object to its equivalent string representation. * Format Specifiers * CUSTOM DATE AND TIME FORMAT STRINGS * Format Description Example * ------ --------------------------------------------------------------------------- ----------------------- * s The seconds of the minute between 0-59. "0" to "59" * ss The seconds of the minute with leading zero if required. "00" to "59" * * m The minute of the hour between 0-59. "0" or "59" * mm The minute of the hour with leading zero if required. "00" or "59" * * h The hour of the day between 1-12. "1" to "12" * hh The hour of the day with leading zero if required. "01" to "12" * * H The hour of the day between 0-23. "0" to "23" * HH The hour of the day with leading zero if required. "00" to "23" * * d The day of the month between 1 and 31. "1" to "31" * dd The day of the month with leading zero if required. "01" to "31" * ddd Abbreviated day name. Date.CultureInfo.abbreviatedDayNames. "Mon" to "Sun" * dddd The full day name. Date.CultureInfo.dayNames. "Monday" to "Sunday" * * M The month of the year between 1-12. "1" to "12" * MM The month of the year with leading zero if required. "01" to "12" * MMM Abbreviated month name. Date.CultureInfo.abbreviatedMonthNames. "Jan" to "Dec" * MMMM The full month name. Date.CultureInfo.monthNames. "January" to "December" * * yy The year as a two-digit number. "99" or "08" * yyyy The full four digit year. "1999" or "2008" * * t Displays the first character of the A.M./P.M. designator. "A" or "P" * Date.CultureInfo.amDesignator or Date.CultureInfo.pmDesignator * tt Displays the A.M./P.M. designator. "AM" or "PM" * Date.CultureInfo.amDesignator or Date.CultureInfo.pmDesignator * * S The ordinal suffix ("st, "nd", "rd" or "th") of the current day. "st, "nd", "rd" or "th" * * STANDARD DATE AND TIME FORMAT STRINGS * Format Description Example *------ --------------------------------------------------------------------------- ----------------------- * d The CultureInfo shortDate Format Pattern "M/d/yyyy" * D The CultureInfo longDate Format Pattern "dddd, MMMM dd, yyyy" * F The CultureInfo fullDateTime Format Pattern "dddd, MMMM dd, yyyy h:mm:ss tt" * m The CultureInfo monthDay Format Pattern "MMMM dd" * r The CultureInfo rfc1123 Format Pattern "ddd, dd MMM yyyy HH:mm:ss GMT" * s The CultureInfo sortableDateTime Format Pattern "yyyy-MM-ddTHH:mm:ss" * t The CultureInfo shortTime Format Pattern "h:mm tt" * T The CultureInfo longTime Format Pattern "h:mm:ss tt" * u The CultureInfo universalSortableDateTime Format Pattern "yyyy-MM-dd HH:mm:ssZ" * y The CultureInfo yearMonth Format Pattern "MMMM, yyyy" * * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @return {String} A string representation of the current Date object. */ var ord = function (n) { switch (n * 1) { case 1: case 21: case 31: return "st"; case 2: case 22: return "nd"; case 3: case 23: return "rd"; default: return "th"; } }; var parseStandardFormats = function (format) { var y, c = Date.CultureInfo.formatPatterns; switch (format) { case "d": return this.toString(c.shortDate); case "D": return this.toString(c.longDate); case "F": return this.toString(c.fullDateTime); case "m": return this.toString(c.monthDay); case "r": case "R": y = this.clone().addMinutes(this.getTimezoneOffset()); return y.toString(c.rfc1123) + " GMT"; case "s": return this.toString(c.sortableDateTime); case "t": return this.toString(c.shortTime); case "T": return this.toString(c.longTime); case "u": y = this.clone().addMinutes(this.getTimezoneOffset()); return y.toString(c.universalSortableDateTime); case "y": return this.toString(c.yearMonth); default: return false; } }; var parseFormatStringsClosure = function (context) { return function (m) { if (m.charAt(0) === "\\") { return m.replace("\\", ""); } switch (m) { case "hh": return p(context.getHours() < 13 ? (context.getHours() === 0 ? 12 : context.getHours()) : (context.getHours() - 12)); case "h": return context.getHours() < 13 ? (context.getHours() === 0 ? 12 : context.getHours()) : (context.getHours() - 12); case "HH": return p(context.getHours()); case "H": return context.getHours(); case "mm": return p(context.getMinutes()); case "m": return context.getMinutes(); case "ss": return p(context.getSeconds()); case "s": return context.getSeconds(); case "yyyy": return p(context.getFullYear(), 4); case "yy": return p(context.getFullYear()); case "y": return context.getFullYear(); case "E": case "dddd": return Date.CultureInfo.dayNames[context.getDay()]; case "ddd": return Date.CultureInfo.abbreviatedDayNames[context.getDay()]; case "dd": return p(context.getDate()); case "d": return context.getDate(); case "MMMM": return Date.CultureInfo.monthNames[context.getMonth()]; case "MMM": return Date.CultureInfo.abbreviatedMonthNames[context.getMonth()]; case "MM": return p((context.getMonth() + 1)); case "M": return context.getMonth() + 1; case "t": return context.getHours() < 12 ? Date.CultureInfo.amDesignator.substring(0, 1) : Date.CultureInfo.pmDesignator.substring(0, 1); case "tt": return context.getHours() < 12 ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator; case "S": return ord(context.getDate()); case "W": return context.getWeek(); case "WW": return context.getISOWeek(); case "Q": return "Q" + context.getQuarter(); case "q": return String(context.getQuarter()); case "z": return context.getTimezone(); case "Z": case "X": return Date.getTimezoneOffset(context.getTimezone()); case "ZZ": // Timezone offset in seconds return context.getTimezoneOffset() * -60; case "u": return context.getDay(); case "L": return ($D.isLeapYear(context.getFullYear())) ? 1 : 0; case "B": // Swatch Internet Time (.beats) return "@"+((context.getUTCSeconds() + (context.getUTCMinutes()*60) + ((context.getUTCHours()+1)*3600))/86.4); default: return m; } }; }; $P.toString = function (format, ignoreStandards) { // Standard Date and Time Format Strings. Formats pulled from CultureInfo file and // may vary by culture. if (!ignoreStandards && format && format.length === 1) { output = parseStandardFormats.call(this, format); if (output) { return output; } } var parseFormatStrings = parseFormatStringsClosure(this); return format ? format.replace(/((\\)?(dd?d?d?|MM?M?M?|yy?y?y?|hh?|HH?|mm?|ss?|tt?|S|q|Q|WW?W?W?)(?![^\[]*\]))/g, parseFormatStrings).replace(/\[|\]/g, "") : this._toString(); }; }()); /************************************************************* * SugarPak - Domain Specific Language - Syntactical Sugar * *************************************************************/ (function () { var $D = Date, $P = $D.prototype, $N = Number.prototype; // private $P._orient = +1; // private $P._nth = null; // private $P._is = false; // private $P._same = false; // private $P._isSecond = false; // private $N._dateElement = "days"; /** * Moves the date to the next instance of a date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.today().next().friday();
	Date.today().next().fri();
	Date.today().next().march();
	Date.today().next().mar();
	Date.today().next().week();
	
* * @return {Date} date */ $P.next = function () { this._move = true; this._orient = +1; return this; }; /** * Creates a new Date (Date.today()) and moves the date to the next instance of the date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.next().friday();
	Date.next().fri();
	Date.next().march();
	Date.next().mar();
	Date.next().week();
	
* * @return {Date} date */ $D.next = function () { return $D.today().next(); }; /** * Moves the date to the previous instance of a date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.today().last().friday();
	Date.today().last().fri();
	Date.today().last().march();
	Date.today().last().mar();
	Date.today().last().week();
	
* * @return {Date} date */ $P.last = $P.prev = $P.previous = function () { this._move = true; this._orient = -1; return this; }; /** * Creates a new Date (Date.today()) and moves the date to the previous instance of the date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.last().friday();
	Date.last().fri();
	Date.previous().march();
	Date.prev().mar();
	Date.last().week();
	
* * @return {Date} date */ $D.last = $D.prev = $D.previous = function () { return $D.today().last(); }; /** * Performs a equality check when followed by either a month name, day name or .weekday() function. * Example

	Date.today().is().friday(); // true|false
	Date.today().is().fri();
	Date.today().is().march();
	Date.today().is().mar();
	
* * @return {Boolean} true|false */ $P.is = function () { this._is = true; return this; }; /** * Determines if two date objects occur on/in exactly the same instance of the subsequent date part function. * The function .same() must be followed by a date part function (example: .day(), .month(), .year(), etc). * * An optional Date can be passed in the date part function. If now date is passed as a parameter, 'Now' is used. * * The following example demonstrates how to determine if two dates fall on the exact same day. * * Example

	var d1 = Date.today(); // today at 00:00
	var d2 = new Date();   // exactly now.

	// Do they occur on the same day?
	d1.same().day(d2); // true
	
	// Do they occur on the same hour?
	d1.same().hour(d2); // false, unless d2 hour is '00' (midnight).
	
	// What if it's the same day, but one year apart?
	var nextYear = Date.today().add(1).year();

	d1.same().day(nextYear); // false, because the dates must occur on the exact same day. 
	
* * Scenario: Determine if a given date occurs during some week period 2 months from now. * * Example

	var future = Date.today().add(2).months();
	return someDate.same().week(future); // true|false;
	
* * @return {Boolean} true|false */ $P.same = function () { this._same = true; this._isSecond = false; return this; }; /** * Determines if the current date/time occurs during Today. Must be preceded by the .is() function. * Example

	someDate.is().today();    // true|false
	new Date().is().today();  // true
	Date.today().is().today();// true
	Date.today().add(-1).day().is().today(); // false
	
* * @return {Boolean} true|false */ $P.today = function () { return this.same().day(); }; /** * Determines if the current date is a weekday. This function must be preceded by the .is() function. * Example

	Date.today().is().weekday(); // true|false
	
* * @return {Boolean} true|false */ $P.weekday = function () { if (this._nth) { return df("Weekday").call(this); } if (this._move) { return this.addWeekdays(this._orient); } if (this._is) { this._is = false; return (!this.is().sat() && !this.is().sun()); } return false; }; /** * Determines if the current date is on the weekend. This function must be preceded by the .is() function. * Example

	Date.today().is().weekend(); // true|false
	
* * @return {Boolean} true|false */ $P.weekend = function () { if (this._is) { this._is = false; return (this.is().sat() || this.is().sun()); } return false; }; /** * Sets the Time of the current Date instance. A string "6:15 pm" or config object {hour:18, minute:15} are accepted. * Example

	// Set time to 6:15pm with a String
	Date.today().at("6:15pm");

	// Set time to 6:15pm with a config object
	Date.today().at({hour:18, minute:15});
	
* * @return {Date} date */ $P.at = function (time) { return (typeof time === "string") ? $D.parse(this.toString("d") + " " + time) : this.set(time); }; /** * Creates a new Date() and adds this (Number) to the date based on the preceding date element function (eg. second|minute|hour|day|month|year). * Example

	// Undeclared Numbers must be wrapped with parentheses. Requirment of JavaScript.
	(3).days().fromNow();
	(6).months().fromNow();

	// Declared Number variables do not require parentheses. 
	var n = 6;
	n.months().fromNow();
	
* * @return {Date} A new Date instance */ $N.fromNow = $N.after = function (date) { var c = {}; c[this._dateElement] = this; return ((!date) ? new Date() : date.clone()).add(c); }; /** * Creates a new Date() and subtract this (Number) from the date based on the preceding date element function (eg. second|minute|hour|day|month|year). * Example

	// Undeclared Numbers must be wrapped with parentheses. Requirment of JavaScript.
	(3).days().ago();
	(6).months().ago();

	// Declared Number variables do not require parentheses. 
	var n = 6;
	n.months().ago();
	
* * @return {Date} A new Date instance */ $N.ago = $N.before = function (date) { var c = {}, s = (this._dateElement[this._dateElement.length-1] !== "s") ? this._dateElement + "s" : this._dateElement; c[s] = this * -1; return ((!date) ? new Date() : date.clone()).add(c); }; // Do NOT modify the following string tokens. These tokens are used to build dynamic functions. // All culture-specific strings can be found in the CultureInfo files. var dx = ("sunday monday tuesday wednesday thursday friday saturday").split(/\s/), mx = ("january february march april may june july august september october november december").split(/\s/), px = ("Millisecond Second Minute Hour Day Week Month Year Quarter Weekday").split(/\s/), pxf = ("Milliseconds Seconds Minutes Hours Date Week Month FullYear Quarter").split(/\s/), nth = ("final first second third fourth fifth").split(/\s/), de; /** * Returns an object literal of all the date parts. * Example

	var o = new Date().toObject();
	
	// { year: 2008, month: 4, week: 20, day: 13, hour: 18, minute: 9, second: 32, millisecond: 812 }
	
	// The object properties can be referenced directly from the object.
	
	alert(o.day);  // alerts "13"
	alert(o.year); // alerts "2008"
	
* * @return {Date} An object literal representing the original date object. */ $P.toObject = function () { var o = {}; for (var i = 0; i < px.length; i++) { if (this["get" + pxf[i]]) { o[px[i].toLowerCase()] = this["get" + pxf[i]](); } } return o; }; /** * Returns a date created from an object literal. Ignores the .week property if set in the config. * Example

	var o = new Date().toObject();
	
	return Date.fromObject(o); // will return the same date. 

	var o2 = {month: 1, day: 20, hour: 18}; // birthday party!
	Date.fromObject(o2);
	
* * @return {Date} An object literal representing the original date object. */ $D.fromObject = function(config) { config.week = null; return Date.today().set(config); }; // Create day name functions and abbreviated day name functions (eg. monday(), friday(), fri()). var df = function (n) { return function () { if (this._is) { this._is = false; return this.getDay() === n; } if (this._move) { this._move = null; } if (this._nth !== null) { // If the .second() function was called earlier, remove the _orient // from the date, and then continue. // This is required because 'second' can be used in two different context. // // Example // // Date.today().add(1).second(); // Date.march().second().monday(); // // Things get crazy with the following... // Date.march().add(1).second().second().monday(); // but it works!! // if (this._isSecond) { this.addSeconds(this._orient * -1); } // make sure we reset _isSecond this._isSecond = false; var ntemp = this._nth; this._nth = null; var temp = this.clone().moveToLastDayOfMonth(); this.moveToNthOccurrence(n, ntemp); if (this > temp) { throw new RangeError($D.getDayName(n) + " does not occur " + ntemp + " times in the month of " + $D.getMonthName(temp.getMonth()) + " " + temp.getFullYear() + "."); } return this; } return this.moveToDayOfWeek(n, this._orient); }; }; var sdf = function (n) { return function () { var t = $D.today(), shift = n - t.getDay(); if (n === 0 && Date.CultureInfo.firstDayOfWeek === 1 && t.getDay() !== 0) { shift = shift + 7; } return t.addDays(shift); }; }; // Create month name functions and abbreviated month name functions (eg. january(), march(), mar()). var month_instance_functions = function (n) { return function () { if (this._is) { this._is = false; return this.getMonth() === n; } return this.moveToMonth(n, this._orient); }; }; var month_static_functions = function (n) { return function () { return $D.today().set({ month: n, day: 1 }); }; }; var processTerms = function (names, staticFunc, instanceFunc) { for (var i = 0; i < names.length; i++) { // Create constant static Name variables. $D[names[i].toUpperCase()] = $D[names[i].toUpperCase().substring(0, 3)] = i; // Create Name functions. $D[names[i]] = $D[names[i].substring(0, 3)] = staticFunc(i); // Create Name instance functions. $P[names[i]] = $P[names[i].substring(0, 3)] = instanceFunc(i); } }; processTerms(dx, sdf, df); processTerms(mx, month_static_functions, month_instance_functions); // Create date element functions and plural date element functions used with Date (eg. day(), days(), months()). var ef = function (j) { return function () { // if the .second() function was called earlier, the _orient // has alread been added. Just return this and reset _isSecond. if (this._isSecond) { this._isSecond = false; return this; } if (this._same) { this._same = this._is = false; var o1 = this.toObject(), o2 = (arguments[0] || new Date()).toObject(), v = "", k = j.toLowerCase(); // the substr trick with -1 doesn't work in IE8 or less k = (k[k.length-1] === "s") ? k.substring(0,k.length-1) : k; for (var m = (px.length - 1); m > -1; m--) { v = px[m].toLowerCase(); if (o1[v] !== o2[v]) { return false; } if (k === v) { break; } } return true; } if (j.substring(j.length - 1) !== "s") { j += "s"; } if (this._move) { this._move = null; } return this["add" + j](this._orient); }; }; var nf = function (n) { return function () { this._dateElement = n; return this; }; }; for (var k = 0; k < px.length; k++) { de = px[k].toLowerCase(); if(de !== "weekday") { // Create date element functions and plural date element functions used with Date (eg. day(), days(), months()). $P[de] = $P[de + "s"] = ef(px[k]); // Create date element functions and plural date element functions used with Number (eg. day(), days(), months()). $N[de] = $N[de + "s"] = nf(de + "s"); } } $P._ss = ef("Second"); var nthfn = function (n) { return function (dayOfWeek) { if (this._same) { return this._ss(arguments[0]); } if (dayOfWeek || dayOfWeek === 0) { return this.moveToNthOccurrence(dayOfWeek, n); } this._nth = n; // if the operator is 'second' add the _orient, then deal with it later... if (n === 2 && (dayOfWeek === undefined || dayOfWeek === null)) { this._isSecond = true; return this.addSeconds(this._orient); } return this; }; }; for (var l = 0; l < nth.length; l++) { $P[nth[l]] = (l === 0) ? nthfn(-1) : nthfn(l); } }()); (function () { "use strict"; Date.Parsing = { Exception: function (s) { this.message = "Parse error at '" + s.substring(0, 10) + " ...'"; } }; var $P = Date.Parsing; var dayOffsets = { standard: [0,31,59,90,120,151,181,212,243,273,304,334], leap: [0,31,60,91,121,152,182,213,244,274,305,335] }; $P.isLeapYear = function(year) { return ((year % 4 === 0) && (year % 100 !== 0)) || (year % 400 === 0); }; var utils = { multiReplace : function (str, hash ) { var key; for (key in hash) { if (Object.prototype.hasOwnProperty.call(hash, key)) { var regex; if (typeof hash[key] === "function") { } else { regex = (hash[key] instanceof RegExp) ? hash[key] : new RegExp(hash[key], "g"); } str = str.replace(regex, key); } } return str; }, getDayOfYearFromWeek : function (obj) { var d, jan4, offset; obj.weekDay = (!obj.weekDay && obj.weekDay !== 0) ? 1 : obj.weekDay; d = new Date(obj.year, 0, 4); jan4 = d.getDay() === 0 ? 7 : d.getDay(); // JS is 0 indexed on Sunday. offset = jan4+3; obj.dayOfYear = ((obj.week * 7) + (obj.weekDay === 0 ? 7 : obj.weekDay))-offset; return obj; }, getDayOfYear : function (obj, dayOffset) { if (!obj.dayOfYear) { obj = utils.getDayOfYearFromWeek(obj); } for (var i=0;i <= dayOffset.length;i++) { if (obj.dayOfYear < dayOffset[i] || i === dayOffset.length) { obj.day = obj.day ? obj.day : (obj.dayOfYear - dayOffset[i-1]); break; } else { obj.month = i; } } return obj; }, adjustForTimeZone : function (obj, date) { var offset; if (obj.zone.toUpperCase() === "Z" || (obj.zone_hours === 0 && obj.zone_minutes === 0)) { // it's UTC/GML so work out the current timeszone offset offset = -date.getTimezoneOffset(); } else { offset = (obj.zone_hours*60) + (obj.zone_minutes || 0); if (obj.zone_sign === "+") { offset *= -1; } offset -= date.getTimezoneOffset(); } date.setMinutes(date.getMinutes()+offset); return date; }, setDefaults : function (obj) { obj.year = obj.year || Date.today().getFullYear(); obj.hours = obj.hours || 0; obj.minutes = obj.minutes || 0; obj.seconds = obj.seconds || 0; obj.milliseconds = obj.milliseconds || 0; if (!(!obj.month && (obj.week || obj.dayOfYear))) { // if we have a month, or if we don't but don't have the day calculation data obj.month = obj.month || 0; obj.day = obj.day || 1; } return obj; }, dataNum: function (data, mod, explict, postProcess) { var dataNum = data*1; if (mod) { if (postProcess) { return data ? mod(data)*1 : data; } else { return data ? mod(dataNum) : data; } } else if (!explict){ return data ? dataNum : data; } else { return (data && typeof data !== "undefined") ? dataNum : data; } }, timeDataProcess: function (obj) { var timeObj = {}; for (var x in obj.data) { if (obj.data.hasOwnProperty(x)) { timeObj[x] = obj.ignore[x] ? obj.data[x] : utils.dataNum(obj.data[x], obj.mods[x], obj.explict[x], obj.postProcess[x]); } } if (obj.data.secmins) { obj.data.secmins = obj.data.secmins.replace(",", ".") * 60; if (!timeObj.minutes) { timeObj.minutes = obj.data.secmins; } else if (!timeObj.seconds) { timeObj.seconds = obj.data.secmins; } delete obj.secmins; } return timeObj; }, buildTimeObjectFromData: function (data) { var time = utils.timeDataProcess({ data: { year : data[1], month : data[5], day : data[7], week : data[8], dayOfYear : data[10], hours : data[15], zone_hours : data[23], zone_minutes : data[24], zone : data[21], zone_sign : data[22], weekDay : data[9], minutes: data[16], seconds: data[19], milliseconds: data[20], secmins: data[18] }, mods: { month: function(data) { return data-1; }, weekDay: function (data) { data = Math.abs(data); return (data === 7 ? 0 : data); }, minutes: function (data) { return data.replace(":",""); }, seconds: function (data) { return Math.floor( (data.replace(":","").replace(",","."))*1 ); }, milliseconds: function (data) { return (data.replace(",",".")*1000); } }, postProcess: { minutes: true, seconds: true, milliseconds: true }, explict: { zone_hours: true, zone_minutes: true }, ignore: { zone: true, zone_sign: true, secmins: true } }); return time; }, addToHash: function (hash, keys, data) { keys = keys; data = data; var len = keys.length; for (var i = 0; i < len; i++) { hash[keys[i]] = data[i]; } return hash; }, combineRegex: function (r1, r2) { return new RegExp("(("+r1.source+")\\s("+r2.source+"))"); }, getDateNthString: function(add, last, inc){ if (add) { return Date.today().addDays(inc).toString("d"); } else if (last) { return Date.today().last()[inc]().toString("d"); } }, buildRegexData: function (array) { var arr = []; var len = array.length; for (var i=0; i < len; i++) { if (Object.prototype.toString.call(array[i]) === '[object Array]') { // oldIE compat version of Array.isArray arr.push(this.combineRegex(array[i][0], array[i][1])); } else { arr.push(array[i]); } } return arr; } }; $P.processTimeObject = function (obj) { var date, dayOffset; utils.setDefaults(obj); dayOffset = ($P.isLeapYear(obj.year)) ? dayOffsets.leap : dayOffsets.standard; if (!obj.month && (obj.week || obj.dayOfYear)) { utils.getDayOfYear(obj, dayOffset); } else { obj.dayOfYear = dayOffset[obj.month] + obj.day; } date = new Date(obj.year, obj.month, obj.day, obj.hours, obj.minutes, obj.seconds, obj.milliseconds); if (obj.zone) { utils.adjustForTimeZone(obj, date); // adjust (and calculate) for timezone } return date; }; $P.ISO = { regex : /^([\+-]?\d{4}(?!\d{2}\b))((-?)((0[1-9]|1[0-2])(\3([12]\d|0[1-9]|3[01]))?|W([0-4]\d|5[0-3])(-?[1-7])?|(00[1-9]|0[1-9]\d|[12]\d{2}|3([0-5]\d|6[1-6])))([T\s]((([01]\d|2[0-4])((:?)[0-5]\d)?|24\:?00)([\.,]\d+(?!:))?)?(\17[0-5]\d([\.,]\d+)?)?\s?([zZ]|([\+-])([01]\d|2[0-3]):?([0-5]\d)?)?)?)?$/, parse : function (s) { var time, data = s.match(this.regex); if (!data || !data.length) { return null; } time = utils.buildTimeObjectFromData(data); if (!time.year || (!time.year && (!time.month && !time.day) && (!time.week && !time.dayOfYear)) ) { return null; } return $P.processTimeObject(time); } }; $P.Numeric = { isNumeric: function (e){return!isNaN(parseFloat(e))&&isFinite(e);}, regex: /\b([0-1]?[0-9])([0-3]?[0-9])([0-2]?[0-9]?[0-9][0-9])\b/i, parse: function (s) { var data, i, time = {}, order = Date.CultureInfo.dateElementOrder.split(""); if (!(this.isNumeric(s)) || // if it's non-numeric OR (s[0] === "+" && s[0] === "-")) { // It's an arithmatic string (eg +/-1000) return null; } if (s.length < 5 && s.indexOf(".") < 0 && s.indexOf("/") < 0) { // assume it's just a year. time.year = s; return $P.processTimeObject(time); } data = s.match(this.regex); if (!data || !data.length) { return null; } for (i=0; i < order.length; i++) { switch(order[i]) { case "d": time.day = data[i+1]; break; case "m": time.month = (data[i+1]-1); break; case "y": time.year = data[i+1]; break; } } return $P.processTimeObject(time); } }; $P.Normalizer = { regexData: function () { var $R = Date.CultureInfo.regexPatterns; return utils.buildRegexData([ $R.tomorrow, $R.yesterday, [$R.past, $R.mon], [$R.past, $R.tue], [$R.past, $R.wed], [$R.past, $R.thu], [$R.past, $R.fri], [$R.past, $R.sat], [$R.past, $R.sun] ]); }, basicReplaceHash : function() { var $R = Date.CultureInfo.regexPatterns; return { "January": $R.jan.source, "February": $R.feb, "March": $R.mar, "April": $R.apr, "May": $R.may, "June": $R.jun, "July": $R.jul, "August": $R.aug, "September": $R.sep, "October": $R.oct, "November": $R.nov, "December": $R.dec, "": /\bat\b/gi, " ": /\s{2,}/, "am": $R.inTheMorning, "9am": $R.thisMorning, "pm": $R.inTheEvening, "7pm":$R.thisEvening }; }, keys : function(){ return [ utils.getDateNthString(true, false, 1), // tomorrow utils.getDateNthString(true, false, -1), // yesterday utils.getDateNthString(false, true, "monday"), //last mon utils.getDateNthString(false, true, "tuesday"), //last tues utils.getDateNthString(false, true, "wednesday"), //last wed utils.getDateNthString(false, true, "thursday"), //last thurs utils.getDateNthString(false, true, "friday"), //last fri utils.getDateNthString(false, true, "saturday"), //last sat utils.getDateNthString(false, true, "sunday") //last sun ]; }, buildRegexFunctions: function () { var $R = Date.CultureInfo.regexPatterns; var __ = Date.i18n.__; var tomorrowRE = new RegExp("(\\b\\d\\d?("+__("AM")+"|"+__("PM")+")? )("+$R.tomorrow.source.slice(1)+")", "i"); // adapted tomorrow regex for AM PM relative dates var todayRE = new RegExp($R.today.source + "(?!\\s*([+-]))\\b"); // today, but excludes the math operators (eg "today + 2h") this.replaceFuncs = [ [todayRE, function (full) { return (full.length > 1) ? Date.today().toString("d") : full; }], [tomorrowRE, function(full, m1) { var t = Date.today().addDays(1).toString("d"); return (t + " " + m1); }], [$R.amThisMorning, function(str, am){return am;}], [$R.pmThisEvening, function(str, pm){return pm;}] ]; }, buildReplaceData: function () { this.buildRegexFunctions(); this.replaceHash = utils.addToHash(this.basicReplaceHash(), this.keys(), this.regexData()); }, stringReplaceFuncs: function (s) { for (var i=0; i < this.replaceFuncs.length; i++) { s = s.replace(this.replaceFuncs[i][0], this.replaceFuncs[i][1]); } return s; }, parse: function (s) { s = this.stringReplaceFuncs(s); s = utils.multiReplace(s, this.replaceHash); try { var n = s.split(/([\s\-\.\,\/\x27]+)/); if (n.length === 3 && $P.Numeric.isNumeric(n[0]) && $P.Numeric.isNumeric(n[2]) && (n[2].length >= 4)) { // ok, so we're dealing with x/year. But that's not a full date. // This fixes wonky dateElementOrder parsing when set to dmy order. if (Date.CultureInfo.dateElementOrder[0] === "d") { s = "1/" + n[0] + "/" + n[2]; // set to 1st of month and normalize the seperator } } } catch (e) {} return s; } }; $P.Normalizer.buildReplaceData(); }()); (function () { var $P = Date.Parsing; var _ = $P.Operators = { // // Tokenizers // rtoken: function (r) { // regex token return function (s) { var mx = s.match(r); if (mx) { return ([ mx[0], s.substring(mx[0].length) ]); } else { throw new $P.Exception(s); } }; }, token: function () { // whitespace-eating token return function (s) { return _.rtoken(new RegExp("^\\s*" + s + "\\s*"))(s); }; }, stoken: function (s) { // string token return _.rtoken(new RegExp("^" + s)); }, // Atomic Operators until: function (p) { return function (s) { var qx = [], rx = null; while (s.length) { try { rx = p.call(this, s); } catch (e) { qx.push(rx[0]); s = rx[1]; continue; } break; } return [ qx, s ]; }; }, many: function (p) { return function (s) { var rx = [], r = null; while (s.length) { try { r = p.call(this, s); } catch (e) { return [ rx, s ]; } rx.push(r[0]); s = r[1]; } return [ rx, s ]; }; }, // generator operators -- see below optional: function (p) { return function (s) { var r = null; try { r = p.call(this, s); } catch (e) { return [ null, s ]; } return [ r[0], r[1] ]; }; }, not: function (p) { return function (s) { try { p.call(this, s); } catch (e) { return [null, s]; } throw new $P.Exception(s); }; }, ignore: function (p) { return p ? function (s) { var r = null; r = p.call(this, s); return [null, r[1]]; } : null; }, product: function () { var px = arguments[0], qx = Array.prototype.slice.call(arguments, 1), rx = []; for (var i = 0 ; i < px.length ; i++) { rx.push(_.each(px[i], qx)); } return rx; }, cache: function (rule) { var cache = {}, cache_length = 0, cache_keys = [], CACHE_MAX = Date.Config.CACHE_MAX || 100000, r = null; var cacheCheck = function () { if (cache_length === CACHE_MAX) { // kill several keys, don't want to have to do this all the time... for (var i=0; i < 10; i++) { var key = cache_keys.shift(); if (key) { delete cache[key]; cache_length--; } } } }; return function (s) { cacheCheck(); try { r = cache[s] = (cache[s] || rule.call(this, s)); } catch (e) { r = cache[s] = e; } cache_length++; cache_keys.push(s); if (r instanceof $P.Exception) { throw r; } else { return r; } }; }, // vector operators -- see below any: function () { var px = arguments; return function (s) { var r = null; for (var i = 0; i < px.length; i++) { if (px[i] == null) { continue; } try { r = (px[i].call(this, s)); } catch (e) { r = null; } if (r) { return r; } } throw new $P.Exception(s); }; }, each: function () { var px = arguments; return function (s) { var rx = [], r = null; for (var i = 0; i < px.length ; i++) { if (px[i] == null) { continue; } try { r = (px[i].call(this, s)); } catch (e) { throw new $P.Exception(s); } rx.push(r[0]); s = r[1]; } return [ rx, s]; }; }, all: function () { var px = arguments, _ = _; return _.each(_.optional(px)); }, // delimited operators sequence: function (px, d, c) { d = d || _.rtoken(/^\s*/); c = c || null; if (px.length === 1) { return px[0]; } return function (s) { var r = null, q = null; var rx = []; for (var i = 0; i < px.length ; i++) { try { r = px[i].call(this, s); } catch (e) { break; } rx.push(r[0]); try { q = d.call(this, r[1]); } catch (ex) { q = null; break; } s = q[1]; } if (!r) { throw new $P.Exception(s); } if (q) { throw new $P.Exception(q[1]); } if (c) { try { r = c.call(this, r[1]); } catch (ey) { throw new $P.Exception(r[1]); } } return [ rx, (r?r[1]:s) ]; }; }, // // Composite Operators // between: function (d1, p, d2) { d2 = d2 || d1; var _fn = _.each(_.ignore(d1), p, _.ignore(d2)); return function (s) { var rx = _fn.call(this, s); return [[rx[0][0], r[0][2]], rx[1]]; }; }, list: function (p, d, c) { d = d || _.rtoken(/^\s*/); c = c || null; return (p instanceof Array ? _.each(_.product(p.slice(0, -1), _.ignore(d)), p.slice(-1), _.ignore(c)) : _.each(_.many(_.each(p, _.ignore(d))), px, _.ignore(c))); }, set: function (px, d, c) { d = d || _.rtoken(/^\s*/); c = c || null; return function (s) { // r is the current match, best the current 'best' match // which means it parsed the most amount of input var r = null, p = null, q = null, rx = null, best = [[], s], last = false; // go through the rules in the given set for (var i = 0; i < px.length ; i++) { // last is a flag indicating whether this must be the last element // if there is only 1 element, then it MUST be the last one q = null; p = null; r = null; last = (px.length === 1); // first, we try simply to match the current pattern // if not, try the next pattern try { r = px[i].call(this, s); } catch (e) { continue; } // since we are matching against a set of elements, the first // thing to do is to add r[0] to matched elements rx = [[r[0]], r[1]]; // if we matched and there is still input to parse and // we don't already know this is the last element, // we're going to next check for the delimiter ... // if there's none, or if there's no input left to parse // than this must be the last element after all ... if (r[1].length > 0 && ! last) { try { q = d.call(this, r[1]); } catch (ex) { last = true; } } else { last = true; } // if we parsed the delimiter and now there's no more input, // that means we shouldn't have parsed the delimiter at all // so don't update r and mark this as the last element ... if (!last && q[1].length === 0) { last = true; } // so, if this isn't the last element, we're going to see if // we can get any more matches from the remaining (unmatched) // elements ... if (!last) { // build a list of the remaining rules we can match against, // i.e., all but the one we just matched against var qx = []; for (var j = 0; j < px.length ; j++) { if (i !== j) { qx.push(px[j]); } } // now invoke recursively set with the remaining input // note that we don't include the closing delimiter ... // we'll check for that ourselves at the end p = _.set(qx, d).call(this, q[1]); // if we got a non-empty set as a result ... // (otw rx already contains everything we want to match) if (p[0].length > 0) { // update current result, which is stored in rx ... // basically, pick up the remaining text from p[1] // and concat the result from p[0] so that we don't // get endless nesting ... rx[0] = rx[0].concat(p[0]); rx[1] = p[1]; } } // at this point, rx either contains the last matched element // or the entire matched set that starts with this element. // now we just check to see if this variation is better than // our best so far, in terms of how much of the input is parsed if (rx[1].length < best[1].length) { best = rx; } // if we've parsed all the input, then we're finished if (best[1].length === 0) { break; } } // so now we've either gone through all the patterns trying them // as the initial match; or we found one that parsed the entire // input string ... // if best has no matches, just return empty set ... if (best[0].length === 0) { return best; } // if a closing delimiter is provided, then we have to check it also if (c) { // we try this even if there is no remaining input because the pattern // may well be optional or match empty input ... try { q = c.call(this, best[1]); } catch (ey) { throw new $P.Exception(best[1]); } // it parsed ... be sure to update the best match remaining input best[1] = q[1]; } // if we're here, either there was no closing delimiter or we parsed it // so now we have the best match; just return it! return best; }; }, forward: function (gr, fname) { return function (s) { return gr[fname].call(this, s); }; }, // // Translation Operators // replace: function (rule, repl) { return function (s) { var r = rule.call(this, s); return [repl, r[1]]; }; }, process: function (rule, fn) { return function (s) { var r = rule.call(this, s); return [fn.call(this, r[0]), r[1]]; }; }, min: function (min, rule) { return function (s) { var rx = rule.call(this, s); if (rx[0].length < min) { throw new $P.Exception(s); } return rx; }; } }; // Generator Operators And Vector Operators // Generators are operators that have a signature of F(R) => R, // taking a given rule and returning another rule, such as // ignore, which parses a given rule and throws away the result. // Vector operators are those that have a signature of F(R1,R2,...) => R, // take a list of rules and returning a new rule, such as each. // Generator operators are converted (via the following _generator // function) into functions that can also take a list or array of rules // and return an array of new rules as though the function had been // called on each rule in turn (which is what actually happens). // This allows generators to be used with vector operators more easily. // Example: // each(ignore(foo, bar)) instead of each(ignore(foo), ignore(bar)) // This also turns generators into vector operators, which allows // constructs like: // not(cache(foo, bar)) var _generator = function (op) { function gen() { var args = null, rx = [], px, i; if (arguments.length > 1) { args = Array.prototype.slice.call(arguments); } else if (arguments[0] instanceof Array) { args = arguments[0]; } if (args) { px = args.shift(); if (px.length > 0) { args.unshift(px[i]); rx.push(op.apply(null, args)); args.shift(); return rx; } } else { return op.apply(null, arguments); } } return gen; }; var gx = "optional not ignore cache".split(/\s/); for (var i = 0 ; i < gx.length ; i++) { _[gx[i]] = _generator(_[gx[i]]); } var _vector = function (op) { return function () { if (arguments[0] instanceof Array) { return op.apply(null, arguments[0]); } else { return op.apply(null, arguments); } }; }; var vx = "each any all".split(/\s/); for (var j = 0 ; j < vx.length ; j++) { _[vx[j]] = _vector(_[vx[j]]); } }()); (function () { var $D = Date; var flattenAndCompact = function (ax) { var rx = []; for (var i = 0; i < ax.length; i++) { if (ax[i] instanceof Array) { rx = rx.concat(flattenAndCompact(ax[i])); } else { if (ax[i]) { rx.push(ax[i]); } } } return rx; }; var parseMeridian = function () { if (this.meridian && (this.hour || this.hour === 0)) { if (this.meridian === "a" && this.hour > 11 && Date.Config.strict24hr){ throw "Invalid hour and meridian combination"; } else if (this.meridian === "p" && this.hour < 12 && Date.Config.strict24hr){ throw "Invalid hour and meridian combination"; } else if (this.meridian === "p" && this.hour < 12) { this.hour = this.hour + 12; } else if (this.meridian === "a" && this.hour === 12) { this.hour = 0; } } }; var setDefaults = function () { var now = new Date(); if ((this.hour || this.minute) && (!this.month && !this.year && !this.day)) { this.day = now.getDate(); } if (!this.year) { this.year = now.getFullYear(); } if (!this.month && this.month !== 0) { this.month = now.getMonth(); } if (!this.day) { this.day = 1; } if (!this.hour) { this.hour = 0; } if (!this.minute) { this.minute = 0; } if (!this.second) { this.second = 0; } if (!this.millisecond) { this.millisecond = 0; } }; var finishUtils = { getToday: function () { if (this.now || "hour minute second".indexOf(this.unit) !== -1) { return new Date(); } else { return $D.today(); } }, setDaysFromWeekday: function (today, orient){ var gap; orient = orient || 1; this.unit = "day"; gap = ($D.getDayNumberFromName(this.weekday) - today.getDay()); this.days = gap ? ((gap + (orient * 7)) % 7) : (orient * 7); return this; }, setMonthsFromMonth: function (today, orient) { var gap; orient = orient || 1; this.unit = "month"; gap = (this.month - today.getMonth()); this.months = gap ? ((gap + (orient * 12)) % 12) : (orient * 12); this.month = null; return this; }, setDMYFromWeekday: function () { var d = Date[this.weekday](); this.day = d.getDate(); if (!this.month) { this.month = d.getMonth(); } this.year = d.getFullYear(); return this; }, setUnitValue: function (orient) { if (!this.value && this.operator && this.operator !== null && this[this.unit + "s"] && this[this.unit + "s"] !== null) { this[this.unit + "s"] = this[this.unit + "s"] + ((this.operator === "add") ? 1 : -1) + (this.value||0) * orient; } else if (this[this.unit + "s"] == null || this.operator != null) { if (!this.value) { this.value = 1; } this[this.unit + "s"] = this.value * orient; } }, generateDateFromWeeks: function () { var weekday = (this.weekday !== undefined) ? this.weekday : "today"; var d = Date[weekday]().addWeeks(this.weeks); if (this.now) { d.setTimeToNow(); } return d; } }; $D.Translator = { hour: function (s) { return function () { this.hour = Number(s); }; }, minute: function (s) { return function () { this.minute = Number(s); }; }, second: function (s) { return function () { this.second = Number(s); }; }, /* for ss.s format */ secondAndMillisecond: function (s) { return function () { var mx = s.match(/^([0-5][0-9])\.([0-9]{1,3})/); this.second = Number(mx[1]); this.millisecond = Number(mx[2]); }; }, meridian: function (s) { return function () { this.meridian = s.slice(0, 1).toLowerCase(); }; }, timezone: function (s) { return function () { var n = s.replace(/[^\d\+\-]/g, ""); if (n.length) { this.timezoneOffset = Number(n); } else { this.timezone = s.toLowerCase(); } }; }, day: function (x) { var s = x[0]; return function () { this.day = Number(s.match(/\d+/)[0]); if (this.day < 1) { throw "invalid day"; } }; }, month: function (s) { return function () { this.month = (s.length === 3) ? "jan feb mar apr may jun jul aug sep oct nov dec".indexOf(s)/4 : Number(s) - 1; if (this.month < 0) { throw "invalid month"; } }; }, year: function (s) { return function () { var n = Number(s); this.year = ((s.length > 2) ? n : (n + (((n + 2000) < Date.CultureInfo.twoDigitYearMax) ? 2000 : 1900))); }; }, rday: function (s) { return function () { switch (s) { case "yesterday": this.days = -1; break; case "tomorrow": this.days = 1; break; case "today": this.days = 0; break; case "now": this.days = 0; this.now = true; break; } }; }, finishExact: function (x) { var d; x = (x instanceof Array) ? x : [x]; for (var i = 0 ; i < x.length ; i++) { if (x[i]) { x[i].call(this); } } setDefaults.call(this); parseMeridian.call(this); if (this.day > $D.getDaysInMonth(this.year, this.month)) { throw new RangeError(this.day + " is not a valid value for days."); } d = new Date(this.year, this.month, this.day, this.hour, this.minute, this.second, this.millisecond); if (this.year < 100) { d.setFullYear(this.year); // means years less that 100 are process correctly. JS will parse it otherwise as 1900-1999. } if (this.timezone) { d.set({ timezone: this.timezone }); } else if (this.timezoneOffset) { d.set({ timezoneOffset: this.timezoneOffset }); } return d; }, finish: function (x) { var today, expression, orient, temp; x = (x instanceof Array) ? flattenAndCompact(x) : [ x ]; if (x.length === 0) { return null; } for (var i = 0 ; i < x.length ; i++) { if (typeof x[i] === "function") { x[i].call(this); } } if (this.now && !this.unit && !this.operator) { return new Date(); } else { today = finishUtils.getToday.call(this); } expression = !!(this.days && this.days !== null || this.orient || this.operator); orient = ((this.orient === "past" || this.operator === "subtract") ? -1 : 1); if (this.month && this.unit === "week") { this.value = this.month + 1; delete this.month; delete this.day; } if ((this.month || this.month === 0) && "year day hour minute second".indexOf(this.unit) !== -1) { if (!this.value) { this.value = this.month + 1; } this.month = null; expression = true; } if (!expression && this.weekday && !this.day && !this.days) { finishUtils.setDMYFromWeekday.call(this); } if (expression && this.weekday && this.unit !== "month" && this.unit !== "week") { finishUtils.setDaysFromWeekday.call(this, today, orient); } if (this.weekday && this.unit !== "week" && !this.day && !this.days) { temp = Date[this.weekday](); this.day = temp.getDate(); if (temp.getMonth() !== today.getMonth()) { this.month = temp.getMonth(); } } if (this.month && this.unit === "day" && this.operator) { if (!this.value) { this.value = (this.month + 1); } this.month = null; } if (this.value != null && this.month != null && this.year != null) { this.day = this.value * 1; } if (this.month && !this.day && this.value) { today.set({ day: this.value * 1 }); if (!expression) { this.day = this.value * 1; } } if (!this.month && this.value && this.unit === "month" && !this.now) { this.month = this.value; expression = true; } if (expression && (this.month || this.month === 0) && this.unit !== "year") { finishUtils.setMonthsFromMonth.call(this, today, orient); } if (!this.unit) { this.unit = "day"; } finishUtils.setUnitValue.call(this, orient); parseMeridian.call(this); if ((this.month || this.month === 0) && !this.day) { this.day = 1; } if (!this.orient && !this.operator && this.unit === "week" && this.value && !this.day && !this.month) { return Date.today().setWeek(this.value); } if (this.unit === "week" && this.weeks && !this.day && !this.month) { return finishUtils.generateDateFromWeeks.call(this); } if (expression && this.timezone && this.day && this.days) { this.day = this.days; } if (expression){ today.add(this); } else { today.set(this); } if (this.timezone) { this.timezone = this.timezone.toUpperCase(); var offset = $D.getTimezoneOffset(this.timezone); var timezone; if (today.hasDaylightSavingTime()) { // lets check that we're being sane with timezone setting timezone = $D.getTimezoneAbbreviation(offset, today.isDaylightSavingTime()); if (timezone !== this.timezone) { // bugger, we're in a place where things like EST vs EDT matters. if (today.isDaylightSavingTime()) { today.addHours(-1); } else { today.addHours(1); } } } today.setTimezoneOffset(offset); } return today; } }; }()); (function () { var $D = Date; $D.Grammar = {}; var _ = $D.Parsing.Operators, g = $D.Grammar, t = $D.Translator, _fn; // Allow rolling up into general purpose rules _fn = function () { return _.each(_.any.apply(null, arguments), _.not(g.ctoken2("timeContext"))); }; g.datePartDelimiter = _.rtoken(/^([\s\-\.\,\/\x27]+)/); g.timePartDelimiter = _.stoken(":"); g.whiteSpace = _.rtoken(/^\s*/); g.generalDelimiter = _.rtoken(/^(([\s\,]|at|@|on)+)/); var _C = {}; g.ctoken = function (keys) { var fn = _C[keys]; if (! fn) { var c = Date.CultureInfo.regexPatterns; var kx = keys.split(/\s+/), px = []; for (var i = 0; i < kx.length ; i++) { px.push(_.replace(_.rtoken(c[kx[i]]), kx[i])); } fn = _C[keys] = _.any.apply(null, px); } return fn; }; g.ctoken2 = function (key) { return _.rtoken(Date.CultureInfo.regexPatterns[key]); }; var cacheProcessRtoken = function (key, token, type, eachToken) { if (eachToken) { g[key] = _.cache(_.process(_.each(_.rtoken(token),_.optional(g.ctoken2(eachToken))), type)); } else { g[key] = _.cache(_.process(_.rtoken(token), type)); } }; var cacheProcessCtoken = function (token, type) { return _.cache(_.process(g.ctoken2(token), type)); }; var _F = {}; //function cache var _get = function (f) { _F[f] = (_F[f] || g.format(f)[0]); return _F[f]; }; g.allformats = function (fx) { var rx = []; if (fx instanceof Array) { for (var i = 0; i < fx.length; i++) { rx.push(_get(fx[i])); } } else { rx.push(_get(fx)); } return rx; }; g.formats = function (fx) { if (fx instanceof Array) { var rx = []; for (var i = 0 ; i < fx.length ; i++) { rx.push(_get(fx[i])); } return _.any.apply(null, rx); } else { return _get(fx); } }; var grammarFormats = { timeFormats: function(){ var i, RTokenKeys = [ "h", "hh", "H", "HH", "m", "mm", "s", "ss", "ss.s", "z", "zz" ], RToken = [ /^(0[0-9]|1[0-2]|[1-9])/, /^(0[0-9]|1[0-2])/, /^([0-1][0-9]|2[0-3]|[0-9])/, /^([0-1][0-9]|2[0-3])/, /^([0-5][0-9]|[0-9])/, /^[0-5][0-9]/, /^([0-5][0-9]|[0-9])/, /^[0-5][0-9]/, /^[0-5][0-9]\.[0-9]{1,3}/, /^((\+|\-)\s*\d\d\d\d)|((\+|\-)\d\d\:?\d\d)/, /^((\+|\-)\s*\d\d\d\d)|((\+|\-)\d\d\:?\d\d)/ ], tokens = [ t.hour, t.hour, t.hour, t.hour, t.minute, t.minute, t.second, t.second, t.secondAndMillisecond, t.timezone, t.timezone ]; for (i=0; i < RTokenKeys.length; i++) { cacheProcessRtoken(RTokenKeys[i], RToken[i], tokens[i]); } g.hms = _.cache(_.sequence([g.H, g.m, g.s], g.timePartDelimiter)); g.t = cacheProcessCtoken("shortMeridian", t.meridian); g.tt = cacheProcessCtoken("longMeridian", t.meridian); g.zzz = cacheProcessCtoken("timezone", t.timezone); g.timeSuffix = _.each(_.ignore(g.whiteSpace), _.set([ g.tt, g.zzz ])); g.time = _.each(_.optional(_.ignore(_.stoken("T"))), g.hms, g.timeSuffix); }, dateFormats: function () { // pre-loaded rules for different date part order preferences var _setfn = function () { return _.set(arguments, g.datePartDelimiter); }; var i, RTokenKeys = [ "d", "dd", "M", "MM", "y", "yy", "yyy", "yyyy" ], RToken = [ /^([0-2]\d|3[0-1]|\d)/, /^([0-2]\d|3[0-1])/, /^(1[0-2]|0\d|\d)/, /^(1[0-2]|0\d)/, /^(\d+)/, /^(\d\d)/, /^(\d\d?\d?\d?)/, /^(\d\d\d\d)/ ], tokens = [ t.day, t.day, t.month, t.month, t.year, t.year, t.year, t.year ], eachToken = [ "ordinalSuffix", "ordinalSuffix" ]; for (i=0; i < RTokenKeys.length; i++) { cacheProcessRtoken(RTokenKeys[i], RToken[i], tokens[i], eachToken[i]); } g.MMM = g.MMMM = _.cache(_.process(g.ctoken("jan feb mar apr may jun jul aug sep oct nov dec"), t.month)); g.ddd = g.dddd = _.cache(_.process(g.ctoken("sun mon tue wed thu fri sat"), function (s) { return function () { this.weekday = s; }; } )); g.day = _fn(g.d, g.dd); g.month = _fn(g.M, g.MMM); g.year = _fn(g.yyyy, g.yy); g.mdy = _setfn(g.ddd, g.month, g.day, g.year); g.ymd = _setfn(g.ddd, g.year, g.month, g.day); g.dmy = _setfn(g.ddd, g.day, g.month, g.year); g.date = function (s) { return ((g[Date.CultureInfo.dateElementOrder] || g.mdy).call(this, s)); }; }, relative: function () { // relative date / time expressions g.orientation = _.process(g.ctoken("past future"), function (s) { return function () { this.orient = s; }; } ); g.operator = _.process(g.ctoken("add subtract"), function (s) { return function () { this.operator = s; }; } ); g.rday = _.process(g.ctoken("yesterday tomorrow today now"), t.rday); g.unit = _.process(g.ctoken("second minute hour day week month year"), function (s) { return function () { this.unit = s; }; } ); } }; g.buildGrammarFormats = function () { // these need to be rebuilt every time the language changes. _C = {}; grammarFormats.timeFormats(); grammarFormats.dateFormats(); grammarFormats.relative(); g.value = _.process(_.rtoken(/^([-+]?\d+)?(st|nd|rd|th)?/), function (s) { return function () { this.value = s.replace(/\D/g, ""); }; } ); g.expression = _.set([g.rday, g.operator, g.value, g.unit, g.orientation, g.ddd, g.MMM ]); g.format = _.process(_.many( _.any( // translate format specifiers into grammar rules _.process( _.rtoken(/^(dd?d?d?(?!e)|MM?M?M?|yy?y?y?|hh?|HH?|mm?|ss?|tt?|zz?z?)/), function (fmt) { if (g[fmt]) { return g[fmt]; } else { throw $D.Parsing.Exception(fmt); } } ), // translate separator tokens into token rules _.process(_.rtoken(/^[^dMyhHmstz]+/), // all legal separators function (s) { return _.ignore(_.stoken(s)); } ) ) ), // construct the parser ... function (rules) { return _.process(_.each.apply(null, rules), t.finishExact); } ); // starting rule for general purpose grammar g._start = _.process(_.set([ g.date, g.time, g.expression ], g.generalDelimiter, g.whiteSpace), t.finish); }; g.buildGrammarFormats(); // parsing date format specifiers - ex: "h:m:s tt" // this little guy will generate a custom parser based // on the format string, ex: g.format("h:m:s tt") // check for these formats first g._formats = g.formats([ "\"yyyy-MM-ddTHH:mm:ssZ\"", "yyyy-MM-ddTHH:mm:ss.sz", "yyyy-MM-ddTHH:mm:ssZ", "yyyy-MM-ddTHH:mm:ssz", "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-ddTHH:mmZ", "yyyy-MM-ddTHH:mmz", "yyyy-MM-ddTHH:mm", "ddd, MMM dd, yyyy H:mm:ss tt", "ddd MMM d yyyy HH:mm:ss zzz", "MMddyyyy", "ddMMyyyy", "Mddyyyy", "ddMyyyy", "Mdyyyy", "dMyyyy", "yyyy", "Mdyy", "dMyy", "d" ]); // real starting rule: tries selected formats first, // then general purpose rule g.start = function (s) { try { var r = g._formats.call({}, s); if (r[1].length === 0) { return r; } } catch (e) {} return g._start.call({}, s); }; }()); (function () { var $D = Date; /** * @desc Converts the specified string value into its JavaScript Date equivalent using CultureInfo specific format information. * * Example

	///////////
	// Dates //
	///////////

	// 15-Oct-2004
	var d1 = Date.parse("10/15/2004");

	// 15-Oct-2004
	var d1 = Date.parse("15-Oct-2004");

	// 15-Oct-2004
	var d1 = Date.parse("2004.10.15");

	//Fri Oct 15, 2004
	var d1 = Date.parse("Fri Oct 15, 2004");

	///////////
	// Times //
	///////////

	// Today at 10 PM.
	var d1 = Date.parse("10 PM");

	// Today at 10:30 PM.
	var d1 = Date.parse("10:30 P.M.");

	// Today at 6 AM.
	var d1 = Date.parse("06am");

	/////////////////////
	// Dates and Times //
	/////////////////////

	// 8-July-2004 @ 10:30 PM
	var d1 = Date.parse("July 8th, 2004, 10:30 PM");

	// 1-July-2004 @ 10:30 PM
	var d1 = Date.parse("2004-07-01T22:30:00");

	////////////////////
	// Relative Dates //
	////////////////////

	// Returns today's date. The string "today" is culture specific.
	var d1 = Date.parse("today");

	// Returns yesterday's date. The string "yesterday" is culture specific.
	var d1 = Date.parse("yesterday");

	// Returns the date of the next thursday.
	var d1 = Date.parse("Next thursday");

	// Returns the date of the most previous monday.
	var d1 = Date.parse("last monday");

	// Returns today's day + one year.
	var d1 = Date.parse("next year");

	///////////////
	// Date Math //
	///////////////

	// Today + 2 days
	var d1 = Date.parse("t+2");

	// Today + 2 days
	var d1 = Date.parse("today + 2 days");

	// Today + 3 months
	var d1 = Date.parse("t+3m");

	// Today - 1 year
	var d1 = Date.parse("today - 1 year");

	// Today - 1 year
	var d1 = Date.parse("t-1y"); 


	/////////////////////////////
	// Partial Dates and Times //
	/////////////////////////////

	// July 15th of this year.
	var d1 = Date.parse("July 15");

	// 15th day of current day and year.
	var d1 = Date.parse("15");

	// July 1st of current year at 10pm.
	var d1 = Date.parse("7/1 10pm");
	
* * @param {String} The string value to convert into a Date object [Required] * @return {Date} A Date object or null if the string cannot be converted into a Date. */ var parseUtils = { removeOrds: function (s) { ords = s.match(/\b(\d+)(?:st|nd|rd|th)\b/); // find ordinal matches s = ((ords && ords.length === 2) ? s.replace(ords[0], ords[1]) : s); return s; }, grammarParser: function (s) { var r = null; try { r = $D.Grammar.start.call({}, s.replace(/^\s*(\S*(\s+\S+)*)\s*$/, "$1")); } catch (e) { return null; } return ((r[1].length === 0) ? r[0] : null); }, nativeFallback: function(s) { var t; try { // ok we haven't parsed it, last ditch attempt with the built-in parser. t = Date._parse(s); return (t || t === 0) ? new Date(t) : null; } catch (e) { return null; } } }; function parse (s) { var d; if (!s) { return null; } if (s instanceof Date) { return s.clone(); } if (s.length >= 4 && s.charAt(0) !== "0" && s.charAt(0) !== "+"&& s.charAt(0) !== "-") { // ie: 2004 will pass, 0800 won't. // Start with specific formats d = $D.Parsing.ISO.parse(s) || $D.Parsing.Numeric.parse(s); } if (d instanceof Date && !isNaN(d.getTime())) { return d; } else { // find ordinal dates (1st, 3rd, 8th, etc and remove them as they cause parsing issues) s = $D.Parsing.Normalizer.parse(parseUtils.removeOrds(s)); d = parseUtils.grammarParser(s); if (d !== null) { return d; } else { return parseUtils.nativeFallback(s); } } } if (!$D._parse) { $D._parse = $D.parse; } $D.parse = parse; Date.getParseFunction = function (fx) { var fns = Date.Grammar.allformats(fx); return function (s) { var r = null; for (var i = 0; i < fns.length; i++) { try { r = fns[i].call({}, s); } catch (e) { continue; } if (r[1].length === 0) { return r[0]; } } return null; }; }; /** * Converts the specified string value into its JavaScript Date equivalent using the specified format {String} or formats {Array} and the CultureInfo specific format information. * The format of the string value must match one of the supplied formats exactly. * * Example

	// 15-Oct-2004
	var d1 = Date.parseExact("10/15/2004", "M/d/yyyy");

	// 15-Oct-2004
	var d1 = Date.parse("15-Oct-2004", "M-ddd-yyyy");

	// 15-Oct-2004
	var d1 = Date.parse("2004.10.15", "yyyy.MM.dd");

	// Multiple formats
	var d1 = Date.parseExact("10/15/2004", ["M/d/yyyy", "MMMM d, yyyy"]);
	
* * @param {String} The string value to convert into a Date object [Required]. * @param {Object} The expected format {String} or an array of expected formats {Array} of the date string [Required]. * @return {Date} A Date object or null if the string cannot be converted into a Date. */ $D.parseExact = function (s, fx) { return $D.getParseFunction(fx)(s); }; }()); (function () { var $D = Date, $P = $D.prototype, // $C = $D.CultureInfo, // not used atm p = function (s, l) { if (!l) { l = 2; } return ("000" + s).slice(l * -1); }; /** * Converts a PHP format string to Java/.NET format string. * A PHP format string can be used with ._format or .format. * A Java/.NET format string can be used with .toString(). * The .parseExact function will only accept a Java/.NET format string * * Example * var f1 = "%m/%d/%y" * var f2 = Date.normalizeFormat(f1); // "MM/dd/yy" * * new Date().format(f1); // "04/13/08" * new Date()._format(f1); // "04/13/08" * new Date().toString(f2); // "04/13/08" * * var date = Date.parseExact("04/13/08", f2); // Sun Apr 13 2008 * * @param {String} A PHP format string consisting of one or more format spcifiers. * @return {String} The PHP format converted to a Java/.NET format string. */ var normalizerSubstitutions = { "d" : "dd", "%d": "dd", "D" : "ddd", "%a": "ddd", "j" : "dddd", "l" : "dddd", "%A": "dddd", "S" : "S", "F" : "MMMM", "%B": "MMMM", "m" : "MM", "%m": "MM", "M" : "MMM", "%b": "MMM", "%h": "MMM", "n" : "M", "Y" : "yyyy", "%Y": "yyyy", "y" : "yy", "%y": "yy", "g" : "h", "%I": "h", "G" : "H", "h" : "hh", "H" : "HH", "%H": "HH", "i" : "mm", "%M": "mm", "s" : "ss", "%S": "ss", "%r": "hh:mm tt", "%R": "H:mm", "%T": "H:mm:ss", "%X": "t", "%x": "d", "%e": "d", "%D": "MM/dd/yy", "%n": "\\n", "%t": "\\t", "e" : "z", "T" : "z", "%z": "z", "%Z": "z", "Z" : "ZZ", "N" : "u", "w" : "u", "%w": "u", "W" : "W", "%V": "W" }; var normalizer = { substitutes: function (m) { return normalizerSubstitutions[m]; }, interpreted: function (m, x) { var y; switch (m) { case "%u": return x.getDay() + 1; case "z": return x.getOrdinalNumber(); case "%j": return p(x.getOrdinalNumber(), 3); case "%U": var d1 = x.clone().set({month: 0, day: 1}).addDays(-1).moveToDayOfWeek(0), d2 = x.clone().addDays(1).moveToDayOfWeek(0, -1); return (d2 < d1) ? "00" : p((d2.getOrdinalNumber() - d1.getOrdinalNumber()) / 7 + 1); case "%W": return p(x.getWeek()); case "t": return $D.getDaysInMonth(x.getFullYear(), x.getMonth()); case "o": case "%G": return x.setWeek(x.getISOWeek()).toString("yyyy"); case "%g": return x._format("%G").slice(-2); case "a": case "%p": return t("tt").toLowerCase(); case "A": return t("tt").toUpperCase(); case "u": return p(x.getMilliseconds(), 3); case "I": return (x.isDaylightSavingTime()) ? 1 : 0; case "O": return x.getUTCOffset(); case "P": y = x.getUTCOffset(); return y.substring(0, y.length - 2) + ":" + y.substring(y.length - 2); case "B": var now = new Date(); return Math.floor(((now.getHours() * 3600) + (now.getMinutes() * 60) + now.getSeconds() + (now.getTimezoneOffset() + 60) * 60) / 86.4); case "c": return x.toISOString().replace(/\"/g, ""); case "U": return $D.strtotime("now"); case "%c": return t("d") + " " + t("t"); case "%C": return Math.floor(x.getFullYear() / 100 + 1); } }, shouldOverrideDefaults: function (m) { switch (m) { case "%e": return true; default: return false; } }, parse: function (m, context) { var formatString, c = context || new Date(); formatString = normalizer.substitutes(m); if (formatString) { return formatString; } formatString = normalizer.interpreted(m, c); if (formatString) { return formatString; } else { return m; } } }; $D.normalizeFormat = function (format, context) { return format.replace(/(%|\\)?.|%%/g, function(t){ return normalizer.parse(t, context); }); }; /** * Format a local Unix timestamp according to locale settings * * Example: * Date.strftime("%m/%d/%y", new Date()); // "04/13/08" * Date.strftime("c", "2008-04-13T17:52:03Z"); // "04/13/08" * * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @param {Number|String} The number representing the number of seconds that have elapsed since January 1, 1970 (local time). * @return {String} A string representation of the current Date object. */ $D.strftime = function (format, time) { var d = Date.parse(time); return d._format(format); }; /** * Parse any textual datetime description into a Unix timestamp. * A Unix timestamp is the number of seconds that have elapsed since January 1, 1970 (midnight UTC/GMT). * * Example: * Date.strtotime("04/13/08"); // 1208044800 * Date.strtotime("1970-01-01T00:00:00Z"); // 0 * * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @param {Object} A string or date object. * @return {String} A string representation of the current Date object. */ $D.strtotime = function (time) { var d = $D.parse(time); return Math.round($D.UTC(d.getUTCFullYear(), d.getUTCMonth(), d.getUTCDate(), d.getUTCHours(), d.getUTCMinutes(), d.getUTCSeconds(), d.getUTCMilliseconds()) / 1000); }; /** * Converts the value of the current Date object to its equivalent string representation using a PHP/Unix style of date format specifiers. * Format Specifiers * Format Description Example * ------ --------------------------------------------------------------------------- ----------------------- * %a abbreviated weekday name according to the current localed "Mon" through "Sun" * %A full weekday name according to the current localed "Sunday" through "Saturday" * %b abbreviated month name according to the current localed "Jan" through "Dec" * %B full month name according to the current locale "January" through "December" * %c preferred date and time representation for the current locale "4/13/2008 12:33 PM" * %C century number (the year divided by 100 and truncated to an integer) "00" to "99" * %d day of the month as a decimal number "01" to "31" * %D same as %m/%d/%y "04/13/08" * %e day of the month as a decimal number, a single digit is preceded by a space "1" to "31" * %g like %G, but without the century "08" * %G The 4-digit year corresponding to the ISO week number (see %V). "2008" * This has the same format and value as %Y, except that if the ISO week number * belongs to the previous or next year, that year is used instead. * %h same as %b "Jan" through "Dec" * %H hour as a decimal number using a 24-hour clock. "00" to "23" * %I hour as a decimal number using a 12-hour clock. "01" to "12" * %j day of the year as a decimal number. "001" to "366" * %m month as a decimal number. "01" to "12" * %M minute as a decimal number. "00" to "59" * %n newline character "\n" * %p either "am" or "pm" according to the given time value, or the "am" or "pm" * corresponding strings for the current locale. * %r time in a.m. and p.m. notation "8:44 PM" * %R time in 24 hour notation "20:44" * %S second as a decimal number "00" to "59" * %t tab character "\t" * %T current time, equal to %H:%M:%S "12:49:11" * %u weekday as a decimal number ["1", "7"], with "1" representing Monday "1" to "7" * %U week number of the current year as a decimal number, starting with the "0" to ("52" or "53") * first Sunday as the first day of the first week * %V The ISO 8601:1988 week number of the current year as a decimal number, "00" to ("52" or "53") * range 01 to 53, where week 1 is the first week that has at least 4 days * in the current year, and with Monday as the first day of the week. * (Use %G or %g for the year component that corresponds to the week number * for the specified timestamp.) * %W week number of the current year as a decimal number, starting with the "00" to ("52" or "53") * first Monday as the first day of the first week * %w day of the week as a decimal, Sunday being "0" "0" to "6" * %x preferred date representation for the current locale without the time "4/13/2008" * %X preferred time representation for the current locale without the date "12:53:05" * %y year as a decimal number without a century "00" "99" * %Y year as a decimal number including the century "2008" * %Z time zone or name or abbreviation "UTC", "EST", "PST" * %z same as %Z * %% a literal "%" characters "%" * d Day of the month, 2 digits with leading zeros "01" to "31" * D A textual representation of a day, three letters "Mon" through "Sun" * j Day of the month without leading zeros "1" to "31" * l A full textual representation of the day of the week (lowercase "L") "Sunday" through "Saturday" * N ISO-8601 numeric representation of the day of the week (added in PHP 5.1.0) "1" (for Monday) through "7" (for Sunday) * S English ordinal suffix for the day of the month, 2 characters "st", "nd", "rd" or "th". Works well with j * w Numeric representation of the day of the week "0" (for Sunday) through "6" (for Saturday) * z The day of the year (starting from "0") "0" through "365" * W ISO-8601 week number of year, weeks starting on Monday "00" to ("52" or "53") * F A full textual representation of a month, such as January or March "January" through "December" * m Numeric representation of a month, with leading zeros "01" through "12" * M A short textual representation of a month, three letters "Jan" through "Dec" * n Numeric representation of a month, without leading zeros "1" through "12" * t Number of days in the given month "28" through "31" * L Whether it's a leap year "1" if it is a leap year, "0" otherwise * o ISO-8601 year number. This has the same value as Y, except that if the "2008" * ISO week number (W) belongs to the previous or next year, that year * is used instead. * Y A full numeric representation of a year, 4 digits "2008" * y A two digit representation of a year "08" * a Lowercase Ante meridiem and Post meridiem "am" or "pm" * A Uppercase Ante meridiem and Post meridiem "AM" or "PM" * B Swatch Internet time "000" through "999" * g 12-hour format of an hour without leading zeros "1" through "12" * G 24-hour format of an hour without leading zeros "0" through "23" * h 12-hour format of an hour with leading zeros "01" through "12" * H 24-hour format of an hour with leading zeros "00" through "23" * i Minutes with leading zeros "00" to "59" * s Seconds, with leading zeros "00" through "59" * u Milliseconds "54321" * e Timezone identifier "UTC", "EST", "PST" * I Whether or not the date is in daylight saving time (uppercase i) "1" if Daylight Saving Time, "0" otherwise * O Difference to Greenwich time (GMT) in hours "+0200", "-0600" * P Difference to Greenwich time (GMT) with colon between hours and minutes "+02:00", "-06:00" * T Timezone abbreviation "UTC", "EST", "PST" * Z Timezone offset in seconds. The offset for timezones west of UTC is "-43200" through "50400" * always negative, and for those east of UTC is always positive. * c ISO 8601 date "2004-02-12T15:19:21+00:00" * r RFC 2822 formatted date "Thu, 21 Dec 2000 16:01:07 +0200" * U Seconds since the Unix Epoch (January 1 1970 00:00:00 GMT) "0" * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @return {String} A string representation of the current Date object. */ var formatReplace = function (context) { return function (m) { var formatString, override = false; if (m.charAt(0) === "\\" || m.substring(0, 2) === "%%") { return m.replace("\\", "").replace("%%", "%"); } override = normalizer.shouldOverrideDefaults(m); formatString = $D.normalizeFormat(m, context); if (formatString) { return context.toString(formatString, override); } }; }; $P._format = function (format) { var formatter = formatReplace(this); if (!format) { return this._toString(); } else { return format.replace(/(%|\\)?.|%%/g, formatter); } }; if (!$P.format) { $P.format = $P._format; } }()); (function () { "use strict"; var gFn = function (attr) { return function () { return this[attr]; }; }; var sFn = function (attr) { return function (val) { this[attr] = val; return this; }; }; var attrs = ["years", "months", "days", "hours", "minutes", "seconds", "milliseconds"]; var addSetFuncs = function (context, attrs) { for (var i = 0; i < attrs.length ; i++) { var $a = attrs[i], $b = $a.slice(0, 1).toUpperCase() + $a.slice(1); context.prototype[$a] = 0; context.prototype["get" + $b] = gFn($a); context.prototype["set" + $b] = sFn($a); } }; /** * new TimeSpan(milliseconds); * new TimeSpan(days, hours, minutes, seconds); * new TimeSpan(days, hours, minutes, seconds, milliseconds); */ var TimeSpan = function (days, hours, minutes, seconds, milliseconds) { if (arguments.length === 1 && typeof days === "number") { var orient = (days < 0) ? -1 : +1; var millsLeft = Math.abs(days); this.setDays(Math.floor(millsLeft / 86400000) * orient); millsLeft = millsLeft % 86400000; this.setHours(Math.floor(millsLeft / 3600000) * orient); millsLeft = millsLeft % 3600000; this.setMinutes(Math.floor(millsLeft / 60000) * orient); millsLeft = millsLeft % 60000; this.setSeconds(Math.floor(millsLeft / 1000) * orient); millsLeft = millsLeft % 1000; this.setMilliseconds(millsLeft * orient); } else { this.set(days, hours, minutes, seconds, milliseconds); } this.getTotalMilliseconds = function () { return (this.getDays() * 86400000) + (this.getHours() * 3600000) + (this.getMinutes() * 60000) + (this.getSeconds() * 1000); }; this.compareTo = function (time) { var t1 = new Date(1970, 1, 1, this.getHours(), this.getMinutes(), this.getSeconds()), t2; if (time === null) { t2 = new Date(1970, 1, 1, 0, 0, 0); } else { t2 = new Date(1970, 1, 1, time.getHours(), time.getMinutes(), time.getSeconds()); } return (t1 < t2) ? -1 : (t1 > t2) ? 1 : 0; }; this.equals = function (time) { return (this.compareTo(time) === 0); }; this.add = function (time) { return (time === null) ? this : this.addSeconds(time.getTotalMilliseconds() / 1000); }; this.subtract = function (time) { return (time === null) ? this : this.addSeconds(-time.getTotalMilliseconds() / 1000); }; this.addDays = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 86400000)); }; this.addHours = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 3600000)); }; this.addMinutes = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 60000)); }; this.addSeconds = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 1000)); }; this.addMilliseconds = function (n) { return new TimeSpan(this.getTotalMilliseconds() + n); }; this.get12HourHour = function () { return (this.getHours() > 12) ? this.getHours() - 12 : (this.getHours() === 0) ? 12 : this.getHours(); }; this.getDesignator = function () { return (this.getHours() < 12) ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator; }; this.toString = function (format) { this._toString = function () { if (this.getDays() !== null && this.getDays() > 0) { return this.getDays() + "." + this.getHours() + ":" + this.p(this.getMinutes()) + ":" + this.p(this.getSeconds()); } else { return this.getHours() + ":" + this.p(this.getMinutes()) + ":" + this.p(this.getSeconds()); } }; this.p = function (s) { return (s.toString().length < 2) ? "0" + s : s; }; var me = this; return format ? format.replace(/dd?|HH?|hh?|mm?|ss?|tt?/g, function (format) { switch (format) { case "d": return me.getDays(); case "dd": return me.p(me.getDays()); case "H": return me.getHours(); case "HH": return me.p(me.getHours()); case "h": return me.get12HourHour(); case "hh": return me.p(me.get12HourHour()); case "m": return me.getMinutes(); case "mm": return me.p(me.getMinutes()); case "s": return me.getSeconds(); case "ss": return me.p(me.getSeconds()); case "t": return ((me.getHours() < 12) ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator).substring(0, 1); case "tt": return (me.getHours() < 12) ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator; } } ) : this._toString(); }; return this; }; addSetFuncs(TimeSpan, attrs.slice(2)); TimeSpan.prototype.set = function (days, hours, minutes, seconds, milliseconds){ this.setDays(days || this.getDays()); this.setHours(hours || this.getHours()); this.setMinutes(minutes || this.getMinutes()); this.setSeconds(seconds || this.getSeconds()); this.setMilliseconds(milliseconds || this.getMilliseconds()); }; /** * Gets the time of day for this date instances. * @return {TimeSpan} TimeSpan */ Date.prototype.getTimeOfDay = function () { return new TimeSpan(0, this.getHours(), this.getMinutes(), this.getSeconds(), this.getMilliseconds()); }; Date.TimeSpan = TimeSpan; if (typeof window !== "undefined" ) { // keeping API compatible for v1.x window.TimeSpan = TimeSpan; } }()); (function () { "use strict"; var attrs = ["years", "months", "days", "hours", "minutes", "seconds", "milliseconds"]; var gFn = function (attr) { return function () { return this[attr]; }; }; var sFn = function (attr) { return function (val) { this[attr] = val; return this; }; }; var addSetFuncs = function (context, attrs) { for (var i = 0; i < attrs.length ; i++) { var $a = attrs[i], $b = $a.slice(0, 1).toUpperCase() + $a.slice(1); context.prototype[$a] = 0; context.prototype["get" + $b] = gFn($a); context.prototype["set" + $b] = sFn($a); } }; var setMonthsAndYears = function (orient, d1, d2, context) { function inc() { d1.addMonths(-orient); context.months++; if (context.months === 12) { context.years++; context.months = 0; } } if (orient === +1) { while (d1 > d2) { inc(); } } else { while (d1 < d2) { inc(); } } context.months--; context.months *= orient; context.years *= orient; }; var adjustForDST = function(orient, startDate, endDate) { var hasDSTMismatch = (false === (startDate.isDaylightSavingTime() === endDate.isDaylightSavingTime())); if (hasDSTMismatch && orient === 1) { startDate.addHours(-1); } else if (hasDSTMismatch) { startDate.addHours(1); } }; /** * TimePeriod(startDate, endDate); * TimePeriod(years, months, days, hours, minutes, seconds, milliseconds); */ var TimePeriod = function (years, months, days, hours, minutes, seconds, milliseconds) { if (arguments.length === 7) { this.set(years, months, days, hours, minutes, seconds, milliseconds); } else if (arguments.length === 2 && arguments[0] instanceof Date && arguments[1] instanceof Date) { var startDate = arguments[0].clone(); var endDate = arguments[1].clone(); var orient = (startDate > endDate) ? +1 : -1; this.dates = { start: arguments[0].clone(), end: arguments[1].clone() }; setMonthsAndYears(orient, startDate, endDate, this); adjustForDST(orient, startDate, endDate); // // TODO - adjust for DST var diff = endDate - startDate; if (diff !== 0) { var ts = new TimeSpan(diff); this.set(this.years, this.months, ts.getDays(), ts.getHours(), ts.getMinutes(), ts.getSeconds(), ts.getMilliseconds()); } } return this; }; // create all the set functions. addSetFuncs(TimePeriod, attrs); TimePeriod.prototype.set = function (years, months, days, hours, minutes, seconds, milliseconds){ this.setYears(years || this.getYears()); this.setMonths(months || this.getMonths()); this.setDays(days || this.getDays()); this.setHours(hours || this.getHours()); this.setMinutes(minutes || this.getMinutes()); this.setSeconds(seconds || this.getSeconds()); this.setMilliseconds(milliseconds || this.getMilliseconds()); }; Date.TimePeriod = TimePeriod; if (typeof window !== "undefined") { // keeping API compatible for v1.x window.TimePeriod = TimePeriod; } }()); ================================================ FILE: build/date-en-ZW.js ================================================ /** * @overview datejs * @version 1.0.0-rc3 * @author Gregory Wild-Smith * @copyright 2015 Gregory Wild-Smith * @license MIT * @homepage https://github.com/abritinthebay/datejs */ /* * DateJS Culture String File * Country Code: en-ZW * Name: English (Zimbabwe) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["en-ZW"] = { "name": "en-ZW", "englishName": "English (Zimbabwe)", "nativeName": "English (Zimbabwe)", "Sunday": "Sunday", "Monday": "Monday", "Tuesday": "Tuesday", "Wednesday": "Wednesday", "Thursday": "Thursday", "Friday": "Friday", "Saturday": "Saturday", "Sun": "Sun", "Mon": "Mon", "Tue": "Tue", "Wed": "Wed", "Thu": "Thu", "Fri": "Fri", "Sat": "Sat", "Su": "Su", "Mo": "Mo", "Tu": "Tu", "We": "We", "Th": "Th", "Fr": "Fr", "Sa": "Sa", "S_Sun_Initial": "S", "M_Mon_Initial": "M", "T_Tue_Initial": "T", "W_Wed_Initial": "W", "T_Thu_Initial": "T", "F_Fri_Initial": "F", "S_Sat_Initial": "S", "January": "January", "February": "February", "March": "March", "April": "April", "May": "May", "June": "June", "July": "July", "August": "August", "September": "September", "October": "October", "November": "November", "December": "December", "Jan_Abbr": "Jan", "Feb_Abbr": "Feb", "Mar_Abbr": "Mar", "Apr_Abbr": "Apr", "May_Abbr": "May", "Jun_Abbr": "Jun", "Jul_Abbr": "Jul", "Aug_Abbr": "Aug", "Sep_Abbr": "Sep", "Oct_Abbr": "Oct", "Nov_Abbr": "Nov", "Dec_Abbr": "Dec", "AM": "AM", "PM": "PM", "firstDayOfWeek": 0, "twoDigitYearMax": 2029, "mdy": "mdy", "M/d/yyyy": "M/d/yyyy", "dddd, MMMM dd, yyyy": "dddd, MMMM dd, yyyy", "h:mm tt": "h:mm tt", "h:mm:ss tt": "h:mm:ss tt", "dddd, MMMM dd, yyyy h:mm:ss tt": "dddd, MMMM dd, yyyy h:mm:ss tt", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "MMMM dd", "MMMM, yyyy": "MMMM, yyyy", "/jan(uary)?/": "jan(uary)?", "/feb(ruary)?/": "feb(ruary)?", "/mar(ch)?/": "mar(ch)?", "/apr(il)?/": "apr(il)?", "/may/": "may", "/jun(e)?/": "jun(e)?", "/jul(y)?/": "jul(y)?", "/aug(ust)?/": "aug(ust)?", "/sep(t(ember)?)?/": "sep(t(ember)?)?", "/oct(ober)?/": "oct(ober)?", "/nov(ember)?/": "nov(ember)?", "/dec(ember)?/": "dec(ember)?", "/^su(n(day)?)?/": "^su(n(day)?)?", "/^mo(n(day)?)?/": "^mo(n(day)?)?", "/^tu(e(s(day)?)?)?/": "^tu(e(s(day)?)?)?", "/^we(d(nesday)?)?/": "^we(d(nesday)?)?", "/^th(u(r(s(day)?)?)?)?/": "^th(u(r(s(day)?)?)?)?", "/^fr(i(day)?)?/": "^fr(i(day)?)?", "/^sa(t(urday)?)?/": "^sa(t(urday)?)?", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "en-ZW"; /** * @overview datejs * @version 1.0.0-rc3 * @author Gregory Wild-Smith * @copyright 2015 Gregory Wild-Smith * @license MIT * @homepage https://github.com/abritinthebay/datejs */(function () { var $D = Date; var lang = Date.CultureStrings ? Date.CultureStrings.lang : null; var loggedKeys = {}; // for debug purposes. var getText = { getFromKey: function (key, countryCode) { var output; if (Date.CultureStrings && Date.CultureStrings[countryCode] && Date.CultureStrings[countryCode][key]) { output = Date.CultureStrings[countryCode][key]; } else { output = getText.buildFromDefault(key); } if (key.charAt(0) === "/") { // Assume it's a regex output = getText.buildFromRegex(key, countryCode); } return output; }, getFromObjectValues: function (obj, countryCode) { var key, output = {}; for(key in obj) { if (obj.hasOwnProperty(key)) { output[key] = getText.getFromKey(obj[key], countryCode); } } return output; }, getFromObjectKeys: function (obj, countryCode) { var key, output = {}; for(key in obj) { if (obj.hasOwnProperty(key)) { output[getText.getFromKey(key, countryCode)] = obj[key]; } } return output; }, getFromArray: function (arr, countryCode) { var output = []; for (var i=0; i < arr.length; i++){ if (i in arr) { output[i] = getText.getFromKey(arr[i], countryCode); } } return output; }, buildFromDefault: function (key) { var output, length, split, last; switch(key) { case "name": output = "en-US"; break; case "englishName": output = "English (United States)"; break; case "nativeName": output = "English (United States)"; break; case "twoDigitYearMax": output = 2049; break; case "firstDayOfWeek": output = 0; break; default: output = key; split = key.split("_"); length = split.length; if (length > 1 && key.charAt(0) !== "/") { // if the key isn't a regex and it has a split. last = split[(length - 1)].toLowerCase(); if (last === "initial" || last === "abbr") { output = split[0]; } } break; } return output; }, buildFromRegex: function (key, countryCode) { var output; if (Date.CultureStrings && Date.CultureStrings[countryCode] && Date.CultureStrings[countryCode][key]) { output = new RegExp(Date.CultureStrings[countryCode][key], "i"); } else { output = new RegExp(key.replace(new RegExp("/", "g"),""), "i"); } return output; } }; var shallowMerge = function (obj1, obj2) { for (var attrname in obj2) { if (obj2.hasOwnProperty(attrname)) { obj1[attrname] = obj2[attrname]; } } }; var __ = function (key, language) { var countryCode = (language) ? language : lang; loggedKeys[key] = key; if (typeof key === "object") { if (key instanceof Array) { return getText.getFromArray(key, countryCode); } else { return getText.getFromObjectKeys(key, countryCode); } } else { return getText.getFromKey(key, countryCode); } }; var loadI18nScript = function (code) { // paatterned after jQuery's getScript. var url = Date.Config.i18n + code + ".js"; var head = document.getElementsByTagName("head")[0] || document.documentElement; var script = document.createElement("script"); script.src = url; var completed = false; var events = { done: function (){} // placeholder function }; // Attach handlers for all browsers script.onload = script.onreadystatechange = function() { if ( !completed && (!this.readyState || this.readyState === "loaded" || this.readyState === "complete") ) { events.done(); head.removeChild(script); } }; setTimeout(function() { head.insertBefore(script, head.firstChild); }, 0); // allows return to execute first return { done: function (cb) { events.done = function() { if (cb) { setTimeout(cb,0); } }; } }; }; var buildInfo = { buildFromMethodHash: function (obj) { var key; for(key in obj) { if (obj.hasOwnProperty(key)) { obj[key] = buildInfo[obj[key]](); } } return obj; }, timeZoneDST: function () { var DST = { "CHADT": "+1345", "NZDT": "+1300", "AEDT": "+1100", "ACDT": "+1030", "AZST": "+0500", "IRDT": "+0430", "EEST": "+0300", "CEST": "+0200", "BST": "+0100", "PMDT": "-0200", "ADT": "-0300", "NDT": "-0230", "EDT": "-0400", "CDT": "-0500", "MDT": "-0600", "PDT": "-0700", "AKDT": "-0800", "HADT": "-0900" }; return __(DST); }, timeZoneStandard: function () { var standard = { "LINT": "+1400", "TOT": "+1300", "CHAST": "+1245", "NZST": "+1200", "NFT": "+1130", "SBT": "+1100", "AEST": "+1000", "ACST": "+0930", "JST": "+0900", "CWST": "+0845", "CT": "+0800", "ICT": "+0700", "MMT": "+0630", "BST": "+0600", "NPT": "+0545", "IST": "+0530", "PKT": "+0500", "AFT": "+0430", "MSK": "+0400", "IRST": "+0330", "FET": "+0300", "EET": "+0200", "CET": "+0100", "GMT": "+0000", "UTC": "+0000", "CVT": "-0100", "GST": "-0200", "BRT": "-0300", "NST": "-0330", "AST": "-0400", "EST": "-0500", "CST": "-0600", "MST": "-0700", "PST": "-0800", "AKST": "-0900", "MIT": "-0930", "HST": "-1000", "SST": "-1100", "BIT": "-1200" }; return __(standard); }, timeZones: function (data) { var zone; data.timezones = []; for (zone in data.abbreviatedTimeZoneStandard) { if (data.abbreviatedTimeZoneStandard.hasOwnProperty(zone)) { data.timezones.push({ name: zone, offset: data.abbreviatedTimeZoneStandard[zone]}); } } for (zone in data.abbreviatedTimeZoneDST) { if (data.abbreviatedTimeZoneDST.hasOwnProperty(zone)) { data.timezones.push({ name: zone, offset: data.abbreviatedTimeZoneDST[zone], dst: true}); } } return data.timezones; }, days: function () { return __(["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"]); }, dayAbbr: function () { return __(["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"]); }, dayShortNames: function () { return __(["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"]); }, dayFirstLetters: function () { return __(["S_Sun_Initial", "M_Mon_Initial", "T_Tues_Initial", "W_Wed_Initial", "T_Thu_Initial", "F_Fri_Initial", "S_Sat_Initial"]); }, months: function () { return __(["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"]); }, monthAbbr: function () { return __(["Jan_Abbr", "Feb_Abbr", "Mar_Abbr", "Apr_Abbr", "May_Abbr", "Jun_Abbr", "Jul_Abbr", "Aug_Abbr", "Sep_Abbr", "Oct_Abbr", "Nov_Abbr", "Dec_Abbr"]); }, formatPatterns: function () { return getText.getFromObjectValues({ shortDate: "M/d/yyyy", longDate: "dddd, MMMM dd, yyyy", shortTime: "h:mm tt", longTime: "h:mm:ss tt", fullDateTime: "dddd, MMMM dd, yyyy h:mm:ss tt", sortableDateTime: "yyyy-MM-ddTHH:mm:ss", universalSortableDateTime: "yyyy-MM-dd HH:mm:ssZ", rfc1123: "ddd, dd MMM yyyy HH:mm:ss", monthDay: "MMMM dd", yearMonth: "MMMM, yyyy" }, Date.i18n.currentLanguage()); }, regex: function () { return getText.getFromObjectValues({ inTheMorning: "/( in the )(morn(ing)?)\\b/", thisMorning: "/(this )(morn(ing)?)\\b/", amThisMorning: "/(\b\\d(am)? )(this )(morn(ing)?)/", inTheEvening: "/( in the )(even(ing)?)\\b/", thisEvening: "/(this )(even(ing)?)\\b/", pmThisEvening: "/(\b\\d(pm)? )(this )(even(ing)?)/", jan: "/jan(uary)?/", feb: "/feb(ruary)?/", mar: "/mar(ch)?/", apr: "/apr(il)?/", may: "/may/", jun: "/jun(e)?/", jul: "/jul(y)?/", aug: "/aug(ust)?/", sep: "/sep(t(ember)?)?/", oct: "/oct(ober)?/", nov: "/nov(ember)?/", dec: "/dec(ember)?/", sun: "/^su(n(day)?)?/", mon: "/^mo(n(day)?)?/", tue: "/^tu(e(s(day)?)?)?/", wed: "/^we(d(nesday)?)?/", thu: "/^th(u(r(s(day)?)?)?)?/", fri: "/fr(i(day)?)?/", sat: "/^sa(t(urday)?)?/", future: "/^next/", past: "/^last|past|prev(ious)?/", add: "/^(\\+|aft(er)?|from|hence)/", subtract: "/^(\\-|bef(ore)?|ago)/", yesterday: "/^yes(terday)?/", today: "/^t(od(ay)?)?/", tomorrow: "/^tom(orrow)?/", now: "/^n(ow)?/", millisecond: "/^ms|milli(second)?s?/", second: "/^sec(ond)?s?/", minute: "/^mn|min(ute)?s?/", hour: "/^h(our)?s?/", week: "/^w(eek)?s?/", month: "/^m(onth)?s?/", day: "/^d(ay)?s?/", year: "/^y(ear)?s?/", shortMeridian: "/^(a|p)/", longMeridian: "/^(a\\.?m?\\.?|p\\.?m?\\.?)/", timezone: "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/", ordinalSuffix: "/^\\s*(st|nd|rd|th)/", timeContext: "/^\\s*(\\:|a(?!u|p)|p)/" }, Date.i18n.currentLanguage()); } }; var CultureInfo = function () { var info = getText.getFromObjectValues({ name: "name", englishName: "englishName", nativeName: "nativeName", amDesignator: "AM", pmDesignator: "PM", firstDayOfWeek: "firstDayOfWeek", twoDigitYearMax: "twoDigitYearMax", dateElementOrder: "mdy" }, Date.i18n.currentLanguage()); var constructedInfo = buildInfo.buildFromMethodHash({ dayNames: "days", abbreviatedDayNames: "dayAbbr", shortestDayNames: "dayShortNames", firstLetterDayNames: "dayFirstLetters", monthNames: "months", abbreviatedMonthNames: "monthAbbr", formatPatterns: "formatPatterns", regexPatterns: "regex", abbreviatedTimeZoneDST: "timeZoneDST", abbreviatedTimeZoneStandard: "timeZoneStandard" }); shallowMerge(info, constructedInfo); buildInfo.timeZones(info); return info; }; $D.i18n = { __: function (key, lang) { return __(key, lang); }, currentLanguage: function () { return lang || "en-US"; }, setLanguage: function (code, force, cb) { var async = false; if (force || code === "en-US" || (!!Date.CultureStrings && !!Date.CultureStrings[code])) { lang = code; Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings.lang = code; Date.CultureInfo = new CultureInfo(); } else { if (!(!!Date.CultureStrings && !!Date.CultureStrings[code])) { if (typeof exports !== "undefined" && this.exports !== exports) { // we're in a Node enviroment, load it using require try { require("../i18n/" + code + ".js"); lang = code; Date.CultureStrings.lang = code; Date.CultureInfo = new CultureInfo(); } catch (e) { // var str = "The language for '" + code + "' could not be loaded by Node. It likely does not exist."; throw new Error("The DateJS IETF language tag '" + code + "' could not be loaded by Node. It likely does not exist."); } } else if (Date.Config && Date.Config.i18n) { // we know the location of the files, so lets load them async = true; loadI18nScript(code).done(function(){ lang = code; Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings.lang = code; Date.CultureInfo = new CultureInfo(); $D.Parsing.Normalizer.buildReplaceData(); // because this is async if ($D.Grammar) { $D.Grammar.buildGrammarFormats(); // so we can parse those strings... } if (cb) { setTimeout(cb,0); } }); } else { Date.console.error("The DateJS IETF language tag '" + code + "' is not available and has not been loaded."); return false; } } } $D.Parsing.Normalizer.buildReplaceData(); // rebuild normalizer strings if ($D.Grammar) { $D.Grammar.buildGrammarFormats(); // so we can parse those strings... } if (!async && cb) { setTimeout(cb,0); } }, getLoggedKeys: function () { return loggedKeys; }, updateCultureInfo: function () { Date.CultureInfo = new CultureInfo(); } }; $D.i18n.updateCultureInfo(); // run automatically }()); (function () { var $D = Date, $P = $D.prototype, p = function (s, l) { if (!l) { l = 2; } return ("000" + s).slice(l * -1); }; if (typeof window !== "undefined" && typeof window.console !== "undefined" && typeof window.console.log !== "undefined") { $D.console = console; // used only to raise non-critical errors if available } else { // set mock so we don't give errors. $D.console = { log: function(){}, error: function(){} }; } $D.Config = $D.Config || {}; $D.initOverloads = function() { /** * Overload of Date.now. Allows an alternate call for Date.now where it returns the * current Date as an object rather than just milliseconds since the Unix Epoch. * * Also provides an implementation of now() for browsers (IE<9) that don't have it. * * Backwards compatible so with work with either: * Date.now() [returns ms] * or * Date.now(true) [returns Date] */ if (!$D.now) { $D._now = function now() { return new Date().getTime(); }; } else if (!$D._now) { $D._now = $D.now; } $D.now = function (returnObj) { if (returnObj) { return $D.present(); } else { return $D._now(); } }; if ( !$P.toISOString ) { $P.toISOString = function() { return this.getUTCFullYear() + "-" + p(this.getUTCMonth() + 1) + "-" + p(this.getUTCDate()) + "T" + p(this.getUTCHours()) + ":" + p(this.getUTCMinutes()) + ":" + p(this.getUTCSeconds()) + "." + String( (this.getUTCMilliseconds()/1000).toFixed(3)).slice(2, 5) + "Z"; }; } // private if ( $P._toString === undefined ){ $P._toString = $P.toString; } }; $D.initOverloads(); /** * Gets a date that is set to the current date. The time is set to the start of the day (00:00 or 12:00 AM). * @return {Date} The current date. */ $D.today = function () { return new Date().clearTime(); }; /** * Gets a date that is set to the current date and time (same as new Date, but chainable) * @return {Date} The current date. */ $D.present = function () { return new Date(); }; /** * Compares the first date to the second date and returns an number indication of their relative values. * @param {Date} First Date object to compare [Required]. * @param {Date} Second Date object to compare to [Required]. * @return {Number} -1 = date1 is lessthan date2. 0 = values are equal. 1 = date1 is greaterthan date2. */ $D.compare = function (date1, date2) { if (isNaN(date1) || isNaN(date2)) { throw new Error(date1 + " - " + date2); } else if (date1 instanceof Date && date2 instanceof Date) { return (date1 < date2) ? -1 : (date1 > date2) ? 1 : 0; } else { throw new TypeError(date1 + " - " + date2); } }; /** * Compares the first Date object to the second Date object and returns true if they are equal. * @param {Date} First Date object to compare [Required] * @param {Date} Second Date object to compare to [Required] * @return {Boolean} true if dates are equal. false if they are not equal. */ $D.equals = function (date1, date2) { return (date1.compareTo(date2) === 0); }; /** * Gets the language appropriate day name when given the day number(0-6) * eg - 0 == Sunday * @return {String} The day name */ $D.getDayName = function (n) { return Date.CultureInfo.dayNames[n]; }; /** * Gets the day number (0-6) if given a CultureInfo specific string which is a valid dayName, abbreviatedDayName or shortestDayName (two char). * @param {String} The name of the day (eg. "Monday, "Mon", "tuesday", "tue", "We", "we"). * @return {Number} The day number */ $D.getDayNumberFromName = function (name) { var n = Date.CultureInfo.dayNames, m = Date.CultureInfo.abbreviatedDayNames, o = Date.CultureInfo.shortestDayNames, s = name.toLowerCase(); for (var i = 0; i < n.length; i++) { if (n[i].toLowerCase() === s || m[i].toLowerCase() === s || o[i].toLowerCase() === s) { return i; } } return -1; }; /** * Gets the month number (0-11) if given a Culture Info specific string which is a valid monthName or abbreviatedMonthName. * @param {String} The name of the month (eg. "February, "Feb", "october", "oct"). * @return {Number} The day number */ $D.getMonthNumberFromName = function (name) { var n = Date.CultureInfo.monthNames, m = Date.CultureInfo.abbreviatedMonthNames, s = name.toLowerCase(); for (var i = 0; i < n.length; i++) { if (n[i].toLowerCase() === s || m[i].toLowerCase() === s) { return i; } } return -1; }; /** * Gets the language appropriate month name when given the month number(0-11) * eg - 0 == January * @return {String} The month name */ $D.getMonthName = function (n) { return Date.CultureInfo.monthNames[n]; }; /** * Determines if the current date instance is within a LeapYear. * @param {Number} The year. * @return {Boolean} true if date is within a LeapYear, otherwise false. */ $D.isLeapYear = function (year) { return ((year % 4 === 0 && year % 100 !== 0) || year % 400 === 0); }; /** * Gets the number of days in the month, given a year and month value. Automatically corrects for LeapYear. * @param {Number} The year. * @param {Number} The month (0-11). * @return {Number} The number of days in the month. */ $D.getDaysInMonth = function (year, month) { if (!month && $D.validateMonth(year)) { month = year; year = Date.today().getFullYear(); } return [31, ($D.isLeapYear(year) ? 29 : 28), 31, 30, 31, 30, 31, 31, 30, 31, 30, 31][month]; }; $P.getDaysInMonth = function () { return $D.getDaysInMonth(this.getFullYear(), this.getMonth()); }; $D.getTimezoneAbbreviation = function (offset, dst) { var p, n = (dst || false) ? Date.CultureInfo.abbreviatedTimeZoneDST : Date.CultureInfo.abbreviatedTimeZoneStandard; for (p in n) { if (n.hasOwnProperty(p)) { if (n[p] === offset) { return p; } } } return null; }; $D.getTimezoneOffset = function (name, dst) { var i, a =[], z = Date.CultureInfo.timezones; if (!name) { name = (new Date()).getTimezone();} for (i = 0; i < z.length; i++) { if (z[i].name === name.toUpperCase()) { a.push(i); } } if (!z[a[0]]) { return null; } if (a.length === 1 || !dst) { return z[a[0]].offset; } else { for (i=0; i < a.length; i++) { if (z[a[i]].dst) { return z[a[i]].offset; } } } }; $D.getQuarter = function (d) { d = d || new Date(); // If no date supplied, use today var q = [1,2,3,4]; return q[Math.floor(d.getMonth() / 3)]; // ~~~ is a bitwise op. Faster than Math.floor }; $D.getDaysLeftInQuarter = function (d) { d = d || new Date(); var qEnd = new Date(d); qEnd.setMonth(qEnd.getMonth() + 3 - qEnd.getMonth() % 3, 0); return Math.floor((qEnd - d) / 8.64e7); }; // private var validate = function (n, min, max, name) { name = name ? name : "Object"; if (typeof n === "undefined") { return false; } else if (typeof n !== "number") { throw new TypeError(n + " is not a Number."); } else if (n < min || n > max) { // As failing validation is *not* an exceptional circumstance // lets not throw a RangeError Exception here. // It's semantically correct but it's not sensible. return false; } return true; }; /** * Validates the number is within an acceptable range for milliseconds [0-999]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateMillisecond = function (value) { return validate(value, 0, 999, "millisecond"); }; /** * Validates the number is within an acceptable range for seconds [0-59]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateSecond = function (value) { return validate(value, 0, 59, "second"); }; /** * Validates the number is within an acceptable range for minutes [0-59]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateMinute = function (value) { return validate(value, 0, 59, "minute"); }; /** * Validates the number is within an acceptable range for hours [0-23]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateHour = function (value) { return validate(value, 0, 23, "hour"); }; /** * Validates the number is within an acceptable range for the days in a month [0-MaxDaysInMonth]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateDay = function (value, year, month) { if (year === undefined || year === null || month === undefined || month === null) { return false;} return validate(value, 1, $D.getDaysInMonth(year, month), "day"); }; /** * Validates the number is within an acceptable range for months [0-11]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateWeek = function (value) { return validate(value, 0, 53, "week"); }; /** * Validates the number is within an acceptable range for months [0-11]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateMonth = function (value) { return validate(value, 0, 11, "month"); }; /** * Validates the number is within an acceptable range for years. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateYear = function (value) { /** * Per ECMAScript spec the range of times supported by Date objects is * exactly -100,000,000 days to +100,000,000 days measured relative to * midnight at the beginning of 01 January, 1970 UTC. * This gives a range of 8,640,000,000,000,000 milliseconds to either * side of 01 January, 1970 UTC. * * Earliest possible date: Tue, 20 Apr 271,822 B.C. 00:00:00 UTC * Latest possible date: Sat, 13 Sep 275,760 00:00:00 UTC */ return validate(value, -271822, 275760, "year"); }; $D.validateTimezone = function(value) { var timezones = {"ACDT":1,"ACST":1,"ACT":1,"ADT":1,"AEDT":1,"AEST":1,"AFT":1,"AKDT":1,"AKST":1,"AMST":1,"AMT":1,"ART":1,"AST":1,"AWDT":1,"AWST":1,"AZOST":1,"AZT":1,"BDT":1,"BIOT":1,"BIT":1,"BOT":1,"BRT":1,"BST":1,"BTT":1,"CAT":1,"CCT":1,"CDT":1,"CEDT":1,"CEST":1,"CET":1,"CHADT":1,"CHAST":1,"CHOT":1,"ChST":1,"CHUT":1,"CIST":1,"CIT":1,"CKT":1,"CLST":1,"CLT":1,"COST":1,"COT":1,"CST":1,"CT":1,"CVT":1,"CWST":1,"CXT":1,"DAVT":1,"DDUT":1,"DFT":1,"EASST":1,"EAST":1,"EAT":1,"ECT":1,"EDT":1,"EEDT":1,"EEST":1,"EET":1,"EGST":1,"EGT":1,"EIT":1,"EST":1,"FET":1,"FJT":1,"FKST":1,"FKT":1,"FNT":1,"GALT":1,"GAMT":1,"GET":1,"GFT":1,"GILT":1,"GIT":1,"GMT":1,"GST":1,"GYT":1,"HADT":1,"HAEC":1,"HAST":1,"HKT":1,"HMT":1,"HOVT":1,"HST":1,"ICT":1,"IDT":1,"IOT":1,"IRDT":1,"IRKT":1,"IRST":1,"IST":1,"JST":1,"KGT":1,"KOST":1,"KRAT":1,"KST":1,"LHST":1,"LINT":1,"MAGT":1,"MART":1,"MAWT":1,"MDT":1,"MET":1,"MEST":1,"MHT":1,"MIST":1,"MIT":1,"MMT":1,"MSK":1,"MST":1,"MUT":1,"MVT":1,"MYT":1,"NCT":1,"NDT":1,"NFT":1,"NPT":1,"NST":1,"NT":1,"NUT":1,"NZDT":1,"NZST":1,"OMST":1,"ORAT":1,"PDT":1,"PET":1,"PETT":1,"PGT":1,"PHOT":1,"PHT":1,"PKT":1,"PMDT":1,"PMST":1,"PONT":1,"PST":1,"PYST":1,"PYT":1,"RET":1,"ROTT":1,"SAKT":1,"SAMT":1,"SAST":1,"SBT":1,"SCT":1,"SGT":1,"SLST":1,"SRT":1,"SST":1,"SYOT":1,"TAHT":1,"THA":1,"TFT":1,"TJT":1,"TKT":1,"TLT":1,"TMT":1,"TOT":1,"TVT":1,"UCT":1,"ULAT":1,"UTC":1,"UYST":1,"UYT":1,"UZT":1,"VET":1,"VLAT":1,"VOLT":1,"VOST":1,"VUT":1,"WAKT":1,"WAST":1,"WAT":1,"WEDT":1,"WEST":1,"WET":1,"WST":1,"YAKT":1,"YEKT":1,"Z":1}; return (timezones[value] === 1); }; $D.validateTimezoneOffset= function(value) { // timezones go from +14hrs to -12hrs, the +X hours are negative offsets. return (value > -841 && value < 721); }; }()); (function () { var $D = Date, $P = $D.prototype, p = function (s, l) { if (!l) { l = 2; } return ("000" + s).slice(l * -1); }; var validateConfigObject = function (obj) { var result = {}, self = this, prop, testFunc; testFunc = function (prop, func, value) { if (prop === "day") { var month = (obj.month !== undefined) ? obj.month : self.getMonth(); var year = (obj.year !== undefined) ? obj.year : self.getFullYear(); return $D[func](value, year, month); } else { return $D[func](value); } }; for (prop in obj) { if (Object.prototype.hasOwnProperty.call(obj, prop)) { var func = "validate" + prop.charAt(0).toUpperCase() + prop.slice(1); if ($D[func] && obj[prop] !== null && testFunc(prop, func, obj[prop])) { result[prop] = obj[prop]; } } } return result; }; /** * Resets the time of this Date object to 12:00 AM (00:00), which is the start of the day. * @param {Boolean} .clone() this date instance before clearing Time * @return {Date} this */ $P.clearTime = function () { this.setHours(0); this.setMinutes(0); this.setSeconds(0); this.setMilliseconds(0); return this; }; /** * Resets the time of this Date object to the current time ('now'). * @return {Date} this */ $P.setTimeToNow = function () { var n = new Date(); this.setHours(n.getHours()); this.setMinutes(n.getMinutes()); this.setSeconds(n.getSeconds()); this.setMilliseconds(n.getMilliseconds()); return this; }; /** * Returns a new Date object that is an exact date and time copy of the original instance. * @return {Date} A new Date instance */ $P.clone = function () { return new Date(this.getTime()); }; /** * Compares this instance to a Date object and returns an number indication of their relative values. * @param {Date} Date object to compare [Required] * @return {Number} -1 = this is lessthan date. 0 = values are equal. 1 = this is greaterthan date. */ $P.compareTo = function (date) { return Date.compare(this, date); }; /** * Compares this instance to another Date object and returns true if they are equal. * @param {Date} Date object to compare. If no date to compare, new Date() [now] is used. * @return {Boolean} true if dates are equal. false if they are not equal. */ $P.equals = function (date) { return Date.equals(this, (date !== undefined ? date : new Date())); }; /** * Determines if this instance is between a range of two dates or equal to either the start or end dates. * @param {Date} Start of range [Required] * @param {Date} End of range [Required] * @return {Boolean} true is this is between or equal to the start and end dates, else false */ $P.between = function (start, end) { return this.getTime() >= start.getTime() && this.getTime() <= end.getTime(); }; /** * Determines if this date occurs after the date to compare to. * @param {Date} Date object to compare. If no date to compare, new Date() ("now") is used. * @return {Boolean} true if this date instance is greater than the date to compare to (or "now"), otherwise false. */ $P.isAfter = function (date) { return this.compareTo(date || new Date()) === 1; }; /** * Determines if this date occurs before the date to compare to. * @param {Date} Date object to compare. If no date to compare, new Date() ("now") is used. * @return {Boolean} true if this date instance is less than the date to compare to (or "now"). */ $P.isBefore = function (date) { return (this.compareTo(date || new Date()) === -1); }; /** * Determines if the current Date instance occurs today. * @return {Boolean} true if this date instance is 'today', otherwise false. */ /** * Determines if the current Date instance occurs on the same Date as the supplied 'date'. * If no 'date' to compare to is provided, the current Date instance is compared to 'today'. * @param {date} Date object to compare. If no date to compare, the current Date ("now") is used. * @return {Boolean} true if this Date instance occurs on the same Day as the supplied 'date'. */ $P.isToday = $P.isSameDay = function (date) { return this.clone().clearTime().equals((date || new Date()).clone().clearTime()); }; /** * Adds the specified number of milliseconds to this instance. * @param {Number} The number of milliseconds to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addMilliseconds = function (value) { if (!value) { return this; } this.setTime(this.getTime() + value * 1); return this; }; /** * Adds the specified number of seconds to this instance. * @param {Number} The number of seconds to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addSeconds = function (value) { if (!value) { return this; } return this.addMilliseconds(value * 1000); }; /** * Adds the specified number of seconds to this instance. * @param {Number} The number of seconds to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addMinutes = function (value) { if (!value) { return this; } return this.addMilliseconds(value * 60000); // 60*1000 }; /** * Adds the specified number of hours to this instance. * @param {Number} The number of hours to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addHours = function (value) { if (!value) { return this; } return this.addMilliseconds(value * 3600000); // 60*60*1000 }; /** * Adds the specified number of days to this instance. * @param {Number} The number of days to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addDays = function (value) { if (!value) { return this; } this.setDate(this.getDate() + value * 1); return this; }; /** * Adds the specified number of weekdays (ie - not sat or sun) to this instance. * @param {Number} The number of days to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addWeekdays = function (value) { if (!value) { return this; } var day = this.getDay(); var weeks = (Math.ceil(Math.abs(value)/7)); if (day === 0 || day === 6) { if (value > 0) { this.next().monday(); this.addDays(-1); day = this.getDay(); } } if (value < 0) { while (value < 0) { this.addDays(-1); day = this.getDay(); if (day !== 0 && day !== 6) { value++; } } return this; } else if (value > 5 || (6-day) <= value) { value = value + (weeks * 2); } return this.addDays(value); }; /** * Adds the specified number of weeks to this instance. * @param {Number} The number of weeks to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addWeeks = function (value) { if (!value) { return this; } return this.addDays(value * 7); }; /** * Adds the specified number of months to this instance. * @param {Number} The number of months to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addMonths = function (value) { if (!value) { return this; } var n = this.getDate(); this.setDate(1); this.setMonth(this.getMonth() + value * 1); this.setDate(Math.min(n, $D.getDaysInMonth(this.getFullYear(), this.getMonth()))); return this; }; $P.addQuarters = function (value) { if (!value) { return this; } // note this will take you to the same point in the quarter as you are now. // i.e. - if you are 15 days into the quarter you'll be 15 days into the resulting one. // bonus: this allows adding fractional quarters return this.addMonths(value * 3); }; /** * Adds the specified number of years to this instance. * @param {Number} The number of years to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addYears = function (value) { if (!value) { return this; } return this.addMonths(value * 12); }; /** * Adds (or subtracts) to the value of the years, months, weeks, days, hours, minutes, seconds, milliseconds of the date instance using given configuration object. Positive and Negative values allowed. * Example

	Date.today().add( { days: 1, months: 1 } )

	new Date().add( { years: -1 } )
	
* @param {Object} Configuration object containing attributes (months, days, etc.) * @return {Date} this */ $P.add = function (config) { if (typeof config === "number") { this._orient = config; return this; } var x = config; if (x.day) { // If we should be a different date than today (eg: for 'tomorrow -1d', etc). // Should only effect parsing, not direct usage (eg, Finish and FinishExact) if ((x.day - this.getDate()) !== 0) { this.setDate(x.day); } } if (x.milliseconds) { this.addMilliseconds(x.milliseconds); } if (x.seconds) { this.addSeconds(x.seconds); } if (x.minutes) { this.addMinutes(x.minutes); } if (x.hours) { this.addHours(x.hours); } if (x.weeks) { this.addWeeks(x.weeks); } if (x.months) { this.addMonths(x.months); } if (x.years) { this.addYears(x.years); } if (x.days) { this.addDays(x.days); } return this; }; /** * Get the week number. Week one (1) is the week which contains the first Thursday of the year. Monday is considered the first day of the week. * The .getWeek() function does NOT convert the date to UTC. The local datetime is used. * Please use .getISOWeek() to get the week of the UTC converted date. * @return {Number} 1 to 53 */ $P.getWeek = function (utc) { // Create a copy of this date object var self, target = new Date(this.valueOf()); if (utc) { target.addMinutes(target.getTimezoneOffset()); self = target.clone(); } else { self = this; } // ISO week date weeks start on monday // so correct the day number var dayNr = (self.getDay() + 6) % 7; // ISO 8601 states that week 1 is the week // with the first thursday of that year. // Set the target date to the thursday in the target week target.setDate(target.getDate() - dayNr + 3); // Store the millisecond value of the target date var firstThursday = target.valueOf(); // Set the target to the first thursday of the year // First set the target to january first target.setMonth(0, 1); // Not a thursday? Correct the date to the next thursday if (target.getDay() !== 4) { target.setMonth(0, 1 + ((4 - target.getDay()) + 7) % 7); } // The weeknumber is the number of weeks between the // first thursday of the year and the thursday in the target week return 1 + Math.ceil((firstThursday - target) / 604800000); // 604800000 = 7 * 24 * 3600 * 1000 }; /** * Get the ISO 8601 week number. Week one ("01") is the week which contains the first Thursday of the year. Monday is considered the first day of the week. * The .getISOWeek() function does convert the date to it's UTC value. Please use .getWeek() to get the week of the local date. * @return {String} "01" to "53" */ $P.getISOWeek = function () { return p(this.getWeek(true)); }; /** * Moves the date to Monday of the week set. Week one (1) is the week which contains the first Thursday of the year. * @param {Number} A Number (1 to 53) that represents the week of the year. * @return {Date} this */ $P.setWeek = function (n) { if ((n - this.getWeek()) === 0) { if (this.getDay() !== 1) { return this.moveToDayOfWeek(1, (this.getDay() > 1 ? -1 : 1)); } else { return this; } } else { return this.moveToDayOfWeek(1, (this.getDay() > 1 ? -1 : 1)).addWeeks(n - this.getWeek()); } }; $P.setQuarter = function (qtr) { var month = Math.abs(((qtr-1) * 3) + 1); return this.setMonth(month, 1); }; $P.getQuarter = function () { return Date.getQuarter(this); }; $P.getDaysLeftInQuarter = function () { return Date.getDaysLeftInQuarter(this); }; /** * Moves the date to the next n'th occurrence of the dayOfWeek starting from the beginning of the month. The number (-1) is a magic number and will return the last occurrence of the dayOfWeek in the month. * @param {Number} The dayOfWeek to move to * @param {Number} The n'th occurrence to move to. Use (-1) to return the last occurrence in the month * @return {Date} this */ $P.moveToNthOccurrence = function (dayOfWeek, occurrence) { if (dayOfWeek === "Weekday") { if (occurrence > 0) { this.moveToFirstDayOfMonth(); if (this.is().weekday()) { occurrence -= 1; } } else if (occurrence < 0) { this.moveToLastDayOfMonth(); if (this.is().weekday()) { occurrence += 1; } } else { return this; } return this.addWeekdays(occurrence); } var shift = 0; if (occurrence > 0) { shift = occurrence - 1; } else if (occurrence === -1) { this.moveToLastDayOfMonth(); if (this.getDay() !== dayOfWeek) { this.moveToDayOfWeek(dayOfWeek, -1); } return this; } return this.moveToFirstDayOfMonth().addDays(-1).moveToDayOfWeek(dayOfWeek, +1).addWeeks(shift); }; var moveToN = function (getFunc, addFunc, nVal) { return function (value, orient) { var diff = (value - this[getFunc]() + nVal * (orient || +1)) % nVal; return this[addFunc]((diff === 0) ? diff += nVal * (orient || +1) : diff); }; }; /** * Move to the next or last dayOfWeek based on the orient value. * @param {Number} The dayOfWeek to move to * @param {Number} Forward (+1) or Back (-1). Defaults to +1. [Optional] * @return {Date} this */ $P.moveToDayOfWeek = moveToN("getDay", "addDays", 7); /** * Move to the next or last month based on the orient value. * @param {Number} The month to move to. 0 = January, 11 = December * @param {Number} Forward (+1) or Back (-1). Defaults to +1. [Optional] * @return {Date} this */ $P.moveToMonth = moveToN("getMonth", "addMonths", 12); /** * Get the Ordinate of the current day ("th", "st", "rd"). * @return {String} */ $P.getOrdinate = function () { var num = this.getDate(); return ord(num); }; /** * Get the Ordinal day (numeric day number) of the year, adjusted for leap year. * @return {Number} 1 through 365 (366 in leap years) */ $P.getOrdinalNumber = function () { return Math.ceil((this.clone().clearTime() - new Date(this.getFullYear(), 0, 1)) / 86400000) + 1; }; /** * Get the time zone abbreviation of the current date. * @return {String} The abbreviated time zone name (e.g. "EST") */ $P.getTimezone = function () { return $D.getTimezoneAbbreviation(this.getUTCOffset(), this.isDaylightSavingTime()); }; $P.setTimezoneOffset = function (offset) { var here = this.getTimezoneOffset(), there = Number(offset) * -6 / 10; return (there || there === 0) ? this.addMinutes(there - here) : this; }; $P.setTimezone = function (offset) { return this.setTimezoneOffset($D.getTimezoneOffset(offset)); }; /** * Indicates whether Daylight Saving Time is observed in the current time zone. * @return {Boolean} true|false */ $P.hasDaylightSavingTime = function () { return (Date.today().set({month: 0, day: 1}).getTimezoneOffset() !== Date.today().set({month: 6, day: 1}).getTimezoneOffset()); }; /** * Indicates whether this Date instance is within the Daylight Saving Time range for the current time zone. * @return {Boolean} true|false */ $P.isDaylightSavingTime = function () { return Date.today().set({month: 0, day: 1}).getTimezoneOffset() !== this.getTimezoneOffset(); }; /** * Get the offset from UTC of the current date. * @return {String} The 4-character offset string prefixed with + or - (e.g. "-0500") */ $P.getUTCOffset = function (offset) { var n = (offset || this.getTimezoneOffset()) * -10 / 6, r; if (n < 0) { r = (n - 10000).toString(); return r.charAt(0) + r.substr(2); } else { r = (n + 10000).toString(); return "+" + r.substr(1); } }; /** * Returns the number of milliseconds between this date and date. * @param {Date} Defaults to now * @return {Number} The diff in milliseconds */ $P.getElapsed = function (date) { return (date || new Date()) - this; }; /** * Set the value of year, month, day, hour, minute, second, millisecond of date instance using given configuration object. * Example

	Date.today().set( { day: 20, month: 1 } )

	new Date().set( { millisecond: 0 } )
	
* * @param {Object} Configuration object containing attributes (month, day, etc.) * @return {Date} this */ $P.set = function (config) { config = validateConfigObject.call(this, config); var key; for (key in config) { if (Object.prototype.hasOwnProperty.call(config, key)) { var name = key.charAt(0).toUpperCase() + key.slice(1); var addFunc, getFunc; if (key !== "week" && key !== "month" && key !== "timezone" && key !== "timezoneOffset") { name += "s"; } addFunc = "add" + name; getFunc = "get" + name; if (key === "month") { addFunc = addFunc + "s"; } else if (key === "year"){ getFunc = "getFullYear"; } if (key !== "day" && key !== "timezone" && key !== "timezoneOffset" && key !== "week" && key !== "hour") { this[addFunc](config[key] - this[getFunc]()); } else if ( key === "timezone"|| key === "timezoneOffset" || key === "week" || key === "hour") { this["set"+name](config[key]); } } } // day has to go last because you can't validate the day without first knowing the month if (config.day) { this.addDays(config.day - this.getDate()); } return this; }; /** * Moves the date to the first day of the month. * @return {Date} this */ $P.moveToFirstDayOfMonth = function () { return this.set({ day: 1 }); }; /** * Moves the date to the last day of the month. * @return {Date} this */ $P.moveToLastDayOfMonth = function () { return this.set({ day: $D.getDaysInMonth(this.getFullYear(), this.getMonth())}); }; /** * Converts the value of the current Date object to its equivalent string representation. * Format Specifiers * CUSTOM DATE AND TIME FORMAT STRINGS * Format Description Example * ------ --------------------------------------------------------------------------- ----------------------- * s The seconds of the minute between 0-59. "0" to "59" * ss The seconds of the minute with leading zero if required. "00" to "59" * * m The minute of the hour between 0-59. "0" or "59" * mm The minute of the hour with leading zero if required. "00" or "59" * * h The hour of the day between 1-12. "1" to "12" * hh The hour of the day with leading zero if required. "01" to "12" * * H The hour of the day between 0-23. "0" to "23" * HH The hour of the day with leading zero if required. "00" to "23" * * d The day of the month between 1 and 31. "1" to "31" * dd The day of the month with leading zero if required. "01" to "31" * ddd Abbreviated day name. Date.CultureInfo.abbreviatedDayNames. "Mon" to "Sun" * dddd The full day name. Date.CultureInfo.dayNames. "Monday" to "Sunday" * * M The month of the year between 1-12. "1" to "12" * MM The month of the year with leading zero if required. "01" to "12" * MMM Abbreviated month name. Date.CultureInfo.abbreviatedMonthNames. "Jan" to "Dec" * MMMM The full month name. Date.CultureInfo.monthNames. "January" to "December" * * yy The year as a two-digit number. "99" or "08" * yyyy The full four digit year. "1999" or "2008" * * t Displays the first character of the A.M./P.M. designator. "A" or "P" * Date.CultureInfo.amDesignator or Date.CultureInfo.pmDesignator * tt Displays the A.M./P.M. designator. "AM" or "PM" * Date.CultureInfo.amDesignator or Date.CultureInfo.pmDesignator * * S The ordinal suffix ("st, "nd", "rd" or "th") of the current day. "st, "nd", "rd" or "th" * * STANDARD DATE AND TIME FORMAT STRINGS * Format Description Example *------ --------------------------------------------------------------------------- ----------------------- * d The CultureInfo shortDate Format Pattern "M/d/yyyy" * D The CultureInfo longDate Format Pattern "dddd, MMMM dd, yyyy" * F The CultureInfo fullDateTime Format Pattern "dddd, MMMM dd, yyyy h:mm:ss tt" * m The CultureInfo monthDay Format Pattern "MMMM dd" * r The CultureInfo rfc1123 Format Pattern "ddd, dd MMM yyyy HH:mm:ss GMT" * s The CultureInfo sortableDateTime Format Pattern "yyyy-MM-ddTHH:mm:ss" * t The CultureInfo shortTime Format Pattern "h:mm tt" * T The CultureInfo longTime Format Pattern "h:mm:ss tt" * u The CultureInfo universalSortableDateTime Format Pattern "yyyy-MM-dd HH:mm:ssZ" * y The CultureInfo yearMonth Format Pattern "MMMM, yyyy" * * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @return {String} A string representation of the current Date object. */ var ord = function (n) { switch (n * 1) { case 1: case 21: case 31: return "st"; case 2: case 22: return "nd"; case 3: case 23: return "rd"; default: return "th"; } }; var parseStandardFormats = function (format) { var y, c = Date.CultureInfo.formatPatterns; switch (format) { case "d": return this.toString(c.shortDate); case "D": return this.toString(c.longDate); case "F": return this.toString(c.fullDateTime); case "m": return this.toString(c.monthDay); case "r": case "R": y = this.clone().addMinutes(this.getTimezoneOffset()); return y.toString(c.rfc1123) + " GMT"; case "s": return this.toString(c.sortableDateTime); case "t": return this.toString(c.shortTime); case "T": return this.toString(c.longTime); case "u": y = this.clone().addMinutes(this.getTimezoneOffset()); return y.toString(c.universalSortableDateTime); case "y": return this.toString(c.yearMonth); default: return false; } }; var parseFormatStringsClosure = function (context) { return function (m) { if (m.charAt(0) === "\\") { return m.replace("\\", ""); } switch (m) { case "hh": return p(context.getHours() < 13 ? (context.getHours() === 0 ? 12 : context.getHours()) : (context.getHours() - 12)); case "h": return context.getHours() < 13 ? (context.getHours() === 0 ? 12 : context.getHours()) : (context.getHours() - 12); case "HH": return p(context.getHours()); case "H": return context.getHours(); case "mm": return p(context.getMinutes()); case "m": return context.getMinutes(); case "ss": return p(context.getSeconds()); case "s": return context.getSeconds(); case "yyyy": return p(context.getFullYear(), 4); case "yy": return p(context.getFullYear()); case "y": return context.getFullYear(); case "E": case "dddd": return Date.CultureInfo.dayNames[context.getDay()]; case "ddd": return Date.CultureInfo.abbreviatedDayNames[context.getDay()]; case "dd": return p(context.getDate()); case "d": return context.getDate(); case "MMMM": return Date.CultureInfo.monthNames[context.getMonth()]; case "MMM": return Date.CultureInfo.abbreviatedMonthNames[context.getMonth()]; case "MM": return p((context.getMonth() + 1)); case "M": return context.getMonth() + 1; case "t": return context.getHours() < 12 ? Date.CultureInfo.amDesignator.substring(0, 1) : Date.CultureInfo.pmDesignator.substring(0, 1); case "tt": return context.getHours() < 12 ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator; case "S": return ord(context.getDate()); case "W": return context.getWeek(); case "WW": return context.getISOWeek(); case "Q": return "Q" + context.getQuarter(); case "q": return String(context.getQuarter()); case "z": return context.getTimezone(); case "Z": case "X": return Date.getTimezoneOffset(context.getTimezone()); case "ZZ": // Timezone offset in seconds return context.getTimezoneOffset() * -60; case "u": return context.getDay(); case "L": return ($D.isLeapYear(context.getFullYear())) ? 1 : 0; case "B": // Swatch Internet Time (.beats) return "@"+((context.getUTCSeconds() + (context.getUTCMinutes()*60) + ((context.getUTCHours()+1)*3600))/86.4); default: return m; } }; }; $P.toString = function (format, ignoreStandards) { // Standard Date and Time Format Strings. Formats pulled from CultureInfo file and // may vary by culture. if (!ignoreStandards && format && format.length === 1) { output = parseStandardFormats.call(this, format); if (output) { return output; } } var parseFormatStrings = parseFormatStringsClosure(this); return format ? format.replace(/((\\)?(dd?d?d?|MM?M?M?|yy?y?y?|hh?|HH?|mm?|ss?|tt?|S|q|Q|WW?W?W?)(?![^\[]*\]))/g, parseFormatStrings).replace(/\[|\]/g, "") : this._toString(); }; }()); /************************************************************* * SugarPak - Domain Specific Language - Syntactical Sugar * *************************************************************/ (function () { var $D = Date, $P = $D.prototype, $N = Number.prototype; // private $P._orient = +1; // private $P._nth = null; // private $P._is = false; // private $P._same = false; // private $P._isSecond = false; // private $N._dateElement = "days"; /** * Moves the date to the next instance of a date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.today().next().friday();
	Date.today().next().fri();
	Date.today().next().march();
	Date.today().next().mar();
	Date.today().next().week();
	
* * @return {Date} date */ $P.next = function () { this._move = true; this._orient = +1; return this; }; /** * Creates a new Date (Date.today()) and moves the date to the next instance of the date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.next().friday();
	Date.next().fri();
	Date.next().march();
	Date.next().mar();
	Date.next().week();
	
* * @return {Date} date */ $D.next = function () { return $D.today().next(); }; /** * Moves the date to the previous instance of a date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.today().last().friday();
	Date.today().last().fri();
	Date.today().last().march();
	Date.today().last().mar();
	Date.today().last().week();
	
* * @return {Date} date */ $P.last = $P.prev = $P.previous = function () { this._move = true; this._orient = -1; return this; }; /** * Creates a new Date (Date.today()) and moves the date to the previous instance of the date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.last().friday();
	Date.last().fri();
	Date.previous().march();
	Date.prev().mar();
	Date.last().week();
	
* * @return {Date} date */ $D.last = $D.prev = $D.previous = function () { return $D.today().last(); }; /** * Performs a equality check when followed by either a month name, day name or .weekday() function. * Example

	Date.today().is().friday(); // true|false
	Date.today().is().fri();
	Date.today().is().march();
	Date.today().is().mar();
	
* * @return {Boolean} true|false */ $P.is = function () { this._is = true; return this; }; /** * Determines if two date objects occur on/in exactly the same instance of the subsequent date part function. * The function .same() must be followed by a date part function (example: .day(), .month(), .year(), etc). * * An optional Date can be passed in the date part function. If now date is passed as a parameter, 'Now' is used. * * The following example demonstrates how to determine if two dates fall on the exact same day. * * Example

	var d1 = Date.today(); // today at 00:00
	var d2 = new Date();   // exactly now.

	// Do they occur on the same day?
	d1.same().day(d2); // true
	
	// Do they occur on the same hour?
	d1.same().hour(d2); // false, unless d2 hour is '00' (midnight).
	
	// What if it's the same day, but one year apart?
	var nextYear = Date.today().add(1).year();

	d1.same().day(nextYear); // false, because the dates must occur on the exact same day. 
	
* * Scenario: Determine if a given date occurs during some week period 2 months from now. * * Example

	var future = Date.today().add(2).months();
	return someDate.same().week(future); // true|false;
	
* * @return {Boolean} true|false */ $P.same = function () { this._same = true; this._isSecond = false; return this; }; /** * Determines if the current date/time occurs during Today. Must be preceded by the .is() function. * Example

	someDate.is().today();    // true|false
	new Date().is().today();  // true
	Date.today().is().today();// true
	Date.today().add(-1).day().is().today(); // false
	
* * @return {Boolean} true|false */ $P.today = function () { return this.same().day(); }; /** * Determines if the current date is a weekday. This function must be preceded by the .is() function. * Example

	Date.today().is().weekday(); // true|false
	
* * @return {Boolean} true|false */ $P.weekday = function () { if (this._nth) { return df("Weekday").call(this); } if (this._move) { return this.addWeekdays(this._orient); } if (this._is) { this._is = false; return (!this.is().sat() && !this.is().sun()); } return false; }; /** * Determines if the current date is on the weekend. This function must be preceded by the .is() function. * Example

	Date.today().is().weekend(); // true|false
	
* * @return {Boolean} true|false */ $P.weekend = function () { if (this._is) { this._is = false; return (this.is().sat() || this.is().sun()); } return false; }; /** * Sets the Time of the current Date instance. A string "6:15 pm" or config object {hour:18, minute:15} are accepted. * Example

	// Set time to 6:15pm with a String
	Date.today().at("6:15pm");

	// Set time to 6:15pm with a config object
	Date.today().at({hour:18, minute:15});
	
* * @return {Date} date */ $P.at = function (time) { return (typeof time === "string") ? $D.parse(this.toString("d") + " " + time) : this.set(time); }; /** * Creates a new Date() and adds this (Number) to the date based on the preceding date element function (eg. second|minute|hour|day|month|year). * Example

	// Undeclared Numbers must be wrapped with parentheses. Requirment of JavaScript.
	(3).days().fromNow();
	(6).months().fromNow();

	// Declared Number variables do not require parentheses. 
	var n = 6;
	n.months().fromNow();
	
* * @return {Date} A new Date instance */ $N.fromNow = $N.after = function (date) { var c = {}; c[this._dateElement] = this; return ((!date) ? new Date() : date.clone()).add(c); }; /** * Creates a new Date() and subtract this (Number) from the date based on the preceding date element function (eg. second|minute|hour|day|month|year). * Example

	// Undeclared Numbers must be wrapped with parentheses. Requirment of JavaScript.
	(3).days().ago();
	(6).months().ago();

	// Declared Number variables do not require parentheses. 
	var n = 6;
	n.months().ago();
	
* * @return {Date} A new Date instance */ $N.ago = $N.before = function (date) { var c = {}, s = (this._dateElement[this._dateElement.length-1] !== "s") ? this._dateElement + "s" : this._dateElement; c[s] = this * -1; return ((!date) ? new Date() : date.clone()).add(c); }; // Do NOT modify the following string tokens. These tokens are used to build dynamic functions. // All culture-specific strings can be found in the CultureInfo files. var dx = ("sunday monday tuesday wednesday thursday friday saturday").split(/\s/), mx = ("january february march april may june july august september october november december").split(/\s/), px = ("Millisecond Second Minute Hour Day Week Month Year Quarter Weekday").split(/\s/), pxf = ("Milliseconds Seconds Minutes Hours Date Week Month FullYear Quarter").split(/\s/), nth = ("final first second third fourth fifth").split(/\s/), de; /** * Returns an object literal of all the date parts. * Example

	var o = new Date().toObject();
	
	// { year: 2008, month: 4, week: 20, day: 13, hour: 18, minute: 9, second: 32, millisecond: 812 }
	
	// The object properties can be referenced directly from the object.
	
	alert(o.day);  // alerts "13"
	alert(o.year); // alerts "2008"
	
* * @return {Date} An object literal representing the original date object. */ $P.toObject = function () { var o = {}; for (var i = 0; i < px.length; i++) { if (this["get" + pxf[i]]) { o[px[i].toLowerCase()] = this["get" + pxf[i]](); } } return o; }; /** * Returns a date created from an object literal. Ignores the .week property if set in the config. * Example

	var o = new Date().toObject();
	
	return Date.fromObject(o); // will return the same date. 

	var o2 = {month: 1, day: 20, hour: 18}; // birthday party!
	Date.fromObject(o2);
	
* * @return {Date} An object literal representing the original date object. */ $D.fromObject = function(config) { config.week = null; return Date.today().set(config); }; // Create day name functions and abbreviated day name functions (eg. monday(), friday(), fri()). var df = function (n) { return function () { if (this._is) { this._is = false; return this.getDay() === n; } if (this._move) { this._move = null; } if (this._nth !== null) { // If the .second() function was called earlier, remove the _orient // from the date, and then continue. // This is required because 'second' can be used in two different context. // // Example // // Date.today().add(1).second(); // Date.march().second().monday(); // // Things get crazy with the following... // Date.march().add(1).second().second().monday(); // but it works!! // if (this._isSecond) { this.addSeconds(this._orient * -1); } // make sure we reset _isSecond this._isSecond = false; var ntemp = this._nth; this._nth = null; var temp = this.clone().moveToLastDayOfMonth(); this.moveToNthOccurrence(n, ntemp); if (this > temp) { throw new RangeError($D.getDayName(n) + " does not occur " + ntemp + " times in the month of " + $D.getMonthName(temp.getMonth()) + " " + temp.getFullYear() + "."); } return this; } return this.moveToDayOfWeek(n, this._orient); }; }; var sdf = function (n) { return function () { var t = $D.today(), shift = n - t.getDay(); if (n === 0 && Date.CultureInfo.firstDayOfWeek === 1 && t.getDay() !== 0) { shift = shift + 7; } return t.addDays(shift); }; }; // Create month name functions and abbreviated month name functions (eg. january(), march(), mar()). var month_instance_functions = function (n) { return function () { if (this._is) { this._is = false; return this.getMonth() === n; } return this.moveToMonth(n, this._orient); }; }; var month_static_functions = function (n) { return function () { return $D.today().set({ month: n, day: 1 }); }; }; var processTerms = function (names, staticFunc, instanceFunc) { for (var i = 0; i < names.length; i++) { // Create constant static Name variables. $D[names[i].toUpperCase()] = $D[names[i].toUpperCase().substring(0, 3)] = i; // Create Name functions. $D[names[i]] = $D[names[i].substring(0, 3)] = staticFunc(i); // Create Name instance functions. $P[names[i]] = $P[names[i].substring(0, 3)] = instanceFunc(i); } }; processTerms(dx, sdf, df); processTerms(mx, month_static_functions, month_instance_functions); // Create date element functions and plural date element functions used with Date (eg. day(), days(), months()). var ef = function (j) { return function () { // if the .second() function was called earlier, the _orient // has alread been added. Just return this and reset _isSecond. if (this._isSecond) { this._isSecond = false; return this; } if (this._same) { this._same = this._is = false; var o1 = this.toObject(), o2 = (arguments[0] || new Date()).toObject(), v = "", k = j.toLowerCase(); // the substr trick with -1 doesn't work in IE8 or less k = (k[k.length-1] === "s") ? k.substring(0,k.length-1) : k; for (var m = (px.length - 1); m > -1; m--) { v = px[m].toLowerCase(); if (o1[v] !== o2[v]) { return false; } if (k === v) { break; } } return true; } if (j.substring(j.length - 1) !== "s") { j += "s"; } if (this._move) { this._move = null; } return this["add" + j](this._orient); }; }; var nf = function (n) { return function () { this._dateElement = n; return this; }; }; for (var k = 0; k < px.length; k++) { de = px[k].toLowerCase(); if(de !== "weekday") { // Create date element functions and plural date element functions used with Date (eg. day(), days(), months()). $P[de] = $P[de + "s"] = ef(px[k]); // Create date element functions and plural date element functions used with Number (eg. day(), days(), months()). $N[de] = $N[de + "s"] = nf(de + "s"); } } $P._ss = ef("Second"); var nthfn = function (n) { return function (dayOfWeek) { if (this._same) { return this._ss(arguments[0]); } if (dayOfWeek || dayOfWeek === 0) { return this.moveToNthOccurrence(dayOfWeek, n); } this._nth = n; // if the operator is 'second' add the _orient, then deal with it later... if (n === 2 && (dayOfWeek === undefined || dayOfWeek === null)) { this._isSecond = true; return this.addSeconds(this._orient); } return this; }; }; for (var l = 0; l < nth.length; l++) { $P[nth[l]] = (l === 0) ? nthfn(-1) : nthfn(l); } }()); (function () { "use strict"; Date.Parsing = { Exception: function (s) { this.message = "Parse error at '" + s.substring(0, 10) + " ...'"; } }; var $P = Date.Parsing; var dayOffsets = { standard: [0,31,59,90,120,151,181,212,243,273,304,334], leap: [0,31,60,91,121,152,182,213,244,274,305,335] }; $P.isLeapYear = function(year) { return ((year % 4 === 0) && (year % 100 !== 0)) || (year % 400 === 0); }; var utils = { multiReplace : function (str, hash ) { var key; for (key in hash) { if (Object.prototype.hasOwnProperty.call(hash, key)) { var regex; if (typeof hash[key] === "function") { } else { regex = (hash[key] instanceof RegExp) ? hash[key] : new RegExp(hash[key], "g"); } str = str.replace(regex, key); } } return str; }, getDayOfYearFromWeek : function (obj) { var d, jan4, offset; obj.weekDay = (!obj.weekDay && obj.weekDay !== 0) ? 1 : obj.weekDay; d = new Date(obj.year, 0, 4); jan4 = d.getDay() === 0 ? 7 : d.getDay(); // JS is 0 indexed on Sunday. offset = jan4+3; obj.dayOfYear = ((obj.week * 7) + (obj.weekDay === 0 ? 7 : obj.weekDay))-offset; return obj; }, getDayOfYear : function (obj, dayOffset) { if (!obj.dayOfYear) { obj = utils.getDayOfYearFromWeek(obj); } for (var i=0;i <= dayOffset.length;i++) { if (obj.dayOfYear < dayOffset[i] || i === dayOffset.length) { obj.day = obj.day ? obj.day : (obj.dayOfYear - dayOffset[i-1]); break; } else { obj.month = i; } } return obj; }, adjustForTimeZone : function (obj, date) { var offset; if (obj.zone.toUpperCase() === "Z" || (obj.zone_hours === 0 && obj.zone_minutes === 0)) { // it's UTC/GML so work out the current timeszone offset offset = -date.getTimezoneOffset(); } else { offset = (obj.zone_hours*60) + (obj.zone_minutes || 0); if (obj.zone_sign === "+") { offset *= -1; } offset -= date.getTimezoneOffset(); } date.setMinutes(date.getMinutes()+offset); return date; }, setDefaults : function (obj) { obj.year = obj.year || Date.today().getFullYear(); obj.hours = obj.hours || 0; obj.minutes = obj.minutes || 0; obj.seconds = obj.seconds || 0; obj.milliseconds = obj.milliseconds || 0; if (!(!obj.month && (obj.week || obj.dayOfYear))) { // if we have a month, or if we don't but don't have the day calculation data obj.month = obj.month || 0; obj.day = obj.day || 1; } return obj; }, dataNum: function (data, mod, explict, postProcess) { var dataNum = data*1; if (mod) { if (postProcess) { return data ? mod(data)*1 : data; } else { return data ? mod(dataNum) : data; } } else if (!explict){ return data ? dataNum : data; } else { return (data && typeof data !== "undefined") ? dataNum : data; } }, timeDataProcess: function (obj) { var timeObj = {}; for (var x in obj.data) { if (obj.data.hasOwnProperty(x)) { timeObj[x] = obj.ignore[x] ? obj.data[x] : utils.dataNum(obj.data[x], obj.mods[x], obj.explict[x], obj.postProcess[x]); } } if (obj.data.secmins) { obj.data.secmins = obj.data.secmins.replace(",", ".") * 60; if (!timeObj.minutes) { timeObj.minutes = obj.data.secmins; } else if (!timeObj.seconds) { timeObj.seconds = obj.data.secmins; } delete obj.secmins; } return timeObj; }, buildTimeObjectFromData: function (data) { var time = utils.timeDataProcess({ data: { year : data[1], month : data[5], day : data[7], week : data[8], dayOfYear : data[10], hours : data[15], zone_hours : data[23], zone_minutes : data[24], zone : data[21], zone_sign : data[22], weekDay : data[9], minutes: data[16], seconds: data[19], milliseconds: data[20], secmins: data[18] }, mods: { month: function(data) { return data-1; }, weekDay: function (data) { data = Math.abs(data); return (data === 7 ? 0 : data); }, minutes: function (data) { return data.replace(":",""); }, seconds: function (data) { return Math.floor( (data.replace(":","").replace(",","."))*1 ); }, milliseconds: function (data) { return (data.replace(",",".")*1000); } }, postProcess: { minutes: true, seconds: true, milliseconds: true }, explict: { zone_hours: true, zone_minutes: true }, ignore: { zone: true, zone_sign: true, secmins: true } }); return time; }, addToHash: function (hash, keys, data) { keys = keys; data = data; var len = keys.length; for (var i = 0; i < len; i++) { hash[keys[i]] = data[i]; } return hash; }, combineRegex: function (r1, r2) { return new RegExp("(("+r1.source+")\\s("+r2.source+"))"); }, getDateNthString: function(add, last, inc){ if (add) { return Date.today().addDays(inc).toString("d"); } else if (last) { return Date.today().last()[inc]().toString("d"); } }, buildRegexData: function (array) { var arr = []; var len = array.length; for (var i=0; i < len; i++) { if (Object.prototype.toString.call(array[i]) === '[object Array]') { // oldIE compat version of Array.isArray arr.push(this.combineRegex(array[i][0], array[i][1])); } else { arr.push(array[i]); } } return arr; } }; $P.processTimeObject = function (obj) { var date, dayOffset; utils.setDefaults(obj); dayOffset = ($P.isLeapYear(obj.year)) ? dayOffsets.leap : dayOffsets.standard; if (!obj.month && (obj.week || obj.dayOfYear)) { utils.getDayOfYear(obj, dayOffset); } else { obj.dayOfYear = dayOffset[obj.month] + obj.day; } date = new Date(obj.year, obj.month, obj.day, obj.hours, obj.minutes, obj.seconds, obj.milliseconds); if (obj.zone) { utils.adjustForTimeZone(obj, date); // adjust (and calculate) for timezone } return date; }; $P.ISO = { regex : /^([\+-]?\d{4}(?!\d{2}\b))((-?)((0[1-9]|1[0-2])(\3([12]\d|0[1-9]|3[01]))?|W([0-4]\d|5[0-3])(-?[1-7])?|(00[1-9]|0[1-9]\d|[12]\d{2}|3([0-5]\d|6[1-6])))([T\s]((([01]\d|2[0-4])((:?)[0-5]\d)?|24\:?00)([\.,]\d+(?!:))?)?(\17[0-5]\d([\.,]\d+)?)?\s?([zZ]|([\+-])([01]\d|2[0-3]):?([0-5]\d)?)?)?)?$/, parse : function (s) { var time, data = s.match(this.regex); if (!data || !data.length) { return null; } time = utils.buildTimeObjectFromData(data); if (!time.year || (!time.year && (!time.month && !time.day) && (!time.week && !time.dayOfYear)) ) { return null; } return $P.processTimeObject(time); } }; $P.Numeric = { isNumeric: function (e){return!isNaN(parseFloat(e))&&isFinite(e);}, regex: /\b([0-1]?[0-9])([0-3]?[0-9])([0-2]?[0-9]?[0-9][0-9])\b/i, parse: function (s) { var data, i, time = {}, order = Date.CultureInfo.dateElementOrder.split(""); if (!(this.isNumeric(s)) || // if it's non-numeric OR (s[0] === "+" && s[0] === "-")) { // It's an arithmatic string (eg +/-1000) return null; } if (s.length < 5 && s.indexOf(".") < 0 && s.indexOf("/") < 0) { // assume it's just a year. time.year = s; return $P.processTimeObject(time); } data = s.match(this.regex); if (!data || !data.length) { return null; } for (i=0; i < order.length; i++) { switch(order[i]) { case "d": time.day = data[i+1]; break; case "m": time.month = (data[i+1]-1); break; case "y": time.year = data[i+1]; break; } } return $P.processTimeObject(time); } }; $P.Normalizer = { regexData: function () { var $R = Date.CultureInfo.regexPatterns; return utils.buildRegexData([ $R.tomorrow, $R.yesterday, [$R.past, $R.mon], [$R.past, $R.tue], [$R.past, $R.wed], [$R.past, $R.thu], [$R.past, $R.fri], [$R.past, $R.sat], [$R.past, $R.sun] ]); }, basicReplaceHash : function() { var $R = Date.CultureInfo.regexPatterns; return { "January": $R.jan.source, "February": $R.feb, "March": $R.mar, "April": $R.apr, "May": $R.may, "June": $R.jun, "July": $R.jul, "August": $R.aug, "September": $R.sep, "October": $R.oct, "November": $R.nov, "December": $R.dec, "": /\bat\b/gi, " ": /\s{2,}/, "am": $R.inTheMorning, "9am": $R.thisMorning, "pm": $R.inTheEvening, "7pm":$R.thisEvening }; }, keys : function(){ return [ utils.getDateNthString(true, false, 1), // tomorrow utils.getDateNthString(true, false, -1), // yesterday utils.getDateNthString(false, true, "monday"), //last mon utils.getDateNthString(false, true, "tuesday"), //last tues utils.getDateNthString(false, true, "wednesday"), //last wed utils.getDateNthString(false, true, "thursday"), //last thurs utils.getDateNthString(false, true, "friday"), //last fri utils.getDateNthString(false, true, "saturday"), //last sat utils.getDateNthString(false, true, "sunday") //last sun ]; }, buildRegexFunctions: function () { var $R = Date.CultureInfo.regexPatterns; var __ = Date.i18n.__; var tomorrowRE = new RegExp("(\\b\\d\\d?("+__("AM")+"|"+__("PM")+")? )("+$R.tomorrow.source.slice(1)+")", "i"); // adapted tomorrow regex for AM PM relative dates var todayRE = new RegExp($R.today.source + "(?!\\s*([+-]))\\b"); // today, but excludes the math operators (eg "today + 2h") this.replaceFuncs = [ [todayRE, function (full) { return (full.length > 1) ? Date.today().toString("d") : full; }], [tomorrowRE, function(full, m1) { var t = Date.today().addDays(1).toString("d"); return (t + " " + m1); }], [$R.amThisMorning, function(str, am){return am;}], [$R.pmThisEvening, function(str, pm){return pm;}] ]; }, buildReplaceData: function () { this.buildRegexFunctions(); this.replaceHash = utils.addToHash(this.basicReplaceHash(), this.keys(), this.regexData()); }, stringReplaceFuncs: function (s) { for (var i=0; i < this.replaceFuncs.length; i++) { s = s.replace(this.replaceFuncs[i][0], this.replaceFuncs[i][1]); } return s; }, parse: function (s) { s = this.stringReplaceFuncs(s); s = utils.multiReplace(s, this.replaceHash); try { var n = s.split(/([\s\-\.\,\/\x27]+)/); if (n.length === 3 && $P.Numeric.isNumeric(n[0]) && $P.Numeric.isNumeric(n[2]) && (n[2].length >= 4)) { // ok, so we're dealing with x/year. But that's not a full date. // This fixes wonky dateElementOrder parsing when set to dmy order. if (Date.CultureInfo.dateElementOrder[0] === "d") { s = "1/" + n[0] + "/" + n[2]; // set to 1st of month and normalize the seperator } } } catch (e) {} return s; } }; $P.Normalizer.buildReplaceData(); }()); (function () { var $P = Date.Parsing; var _ = $P.Operators = { // // Tokenizers // rtoken: function (r) { // regex token return function (s) { var mx = s.match(r); if (mx) { return ([ mx[0], s.substring(mx[0].length) ]); } else { throw new $P.Exception(s); } }; }, token: function () { // whitespace-eating token return function (s) { return _.rtoken(new RegExp("^\\s*" + s + "\\s*"))(s); }; }, stoken: function (s) { // string token return _.rtoken(new RegExp("^" + s)); }, // Atomic Operators until: function (p) { return function (s) { var qx = [], rx = null; while (s.length) { try { rx = p.call(this, s); } catch (e) { qx.push(rx[0]); s = rx[1]; continue; } break; } return [ qx, s ]; }; }, many: function (p) { return function (s) { var rx = [], r = null; while (s.length) { try { r = p.call(this, s); } catch (e) { return [ rx, s ]; } rx.push(r[0]); s = r[1]; } return [ rx, s ]; }; }, // generator operators -- see below optional: function (p) { return function (s) { var r = null; try { r = p.call(this, s); } catch (e) { return [ null, s ]; } return [ r[0], r[1] ]; }; }, not: function (p) { return function (s) { try { p.call(this, s); } catch (e) { return [null, s]; } throw new $P.Exception(s); }; }, ignore: function (p) { return p ? function (s) { var r = null; r = p.call(this, s); return [null, r[1]]; } : null; }, product: function () { var px = arguments[0], qx = Array.prototype.slice.call(arguments, 1), rx = []; for (var i = 0 ; i < px.length ; i++) { rx.push(_.each(px[i], qx)); } return rx; }, cache: function (rule) { var cache = {}, cache_length = 0, cache_keys = [], CACHE_MAX = Date.Config.CACHE_MAX || 100000, r = null; var cacheCheck = function () { if (cache_length === CACHE_MAX) { // kill several keys, don't want to have to do this all the time... for (var i=0; i < 10; i++) { var key = cache_keys.shift(); if (key) { delete cache[key]; cache_length--; } } } }; return function (s) { cacheCheck(); try { r = cache[s] = (cache[s] || rule.call(this, s)); } catch (e) { r = cache[s] = e; } cache_length++; cache_keys.push(s); if (r instanceof $P.Exception) { throw r; } else { return r; } }; }, // vector operators -- see below any: function () { var px = arguments; return function (s) { var r = null; for (var i = 0; i < px.length; i++) { if (px[i] == null) { continue; } try { r = (px[i].call(this, s)); } catch (e) { r = null; } if (r) { return r; } } throw new $P.Exception(s); }; }, each: function () { var px = arguments; return function (s) { var rx = [], r = null; for (var i = 0; i < px.length ; i++) { if (px[i] == null) { continue; } try { r = (px[i].call(this, s)); } catch (e) { throw new $P.Exception(s); } rx.push(r[0]); s = r[1]; } return [ rx, s]; }; }, all: function () { var px = arguments, _ = _; return _.each(_.optional(px)); }, // delimited operators sequence: function (px, d, c) { d = d || _.rtoken(/^\s*/); c = c || null; if (px.length === 1) { return px[0]; } return function (s) { var r = null, q = null; var rx = []; for (var i = 0; i < px.length ; i++) { try { r = px[i].call(this, s); } catch (e) { break; } rx.push(r[0]); try { q = d.call(this, r[1]); } catch (ex) { q = null; break; } s = q[1]; } if (!r) { throw new $P.Exception(s); } if (q) { throw new $P.Exception(q[1]); } if (c) { try { r = c.call(this, r[1]); } catch (ey) { throw new $P.Exception(r[1]); } } return [ rx, (r?r[1]:s) ]; }; }, // // Composite Operators // between: function (d1, p, d2) { d2 = d2 || d1; var _fn = _.each(_.ignore(d1), p, _.ignore(d2)); return function (s) { var rx = _fn.call(this, s); return [[rx[0][0], r[0][2]], rx[1]]; }; }, list: function (p, d, c) { d = d || _.rtoken(/^\s*/); c = c || null; return (p instanceof Array ? _.each(_.product(p.slice(0, -1), _.ignore(d)), p.slice(-1), _.ignore(c)) : _.each(_.many(_.each(p, _.ignore(d))), px, _.ignore(c))); }, set: function (px, d, c) { d = d || _.rtoken(/^\s*/); c = c || null; return function (s) { // r is the current match, best the current 'best' match // which means it parsed the most amount of input var r = null, p = null, q = null, rx = null, best = [[], s], last = false; // go through the rules in the given set for (var i = 0; i < px.length ; i++) { // last is a flag indicating whether this must be the last element // if there is only 1 element, then it MUST be the last one q = null; p = null; r = null; last = (px.length === 1); // first, we try simply to match the current pattern // if not, try the next pattern try { r = px[i].call(this, s); } catch (e) { continue; } // since we are matching against a set of elements, the first // thing to do is to add r[0] to matched elements rx = [[r[0]], r[1]]; // if we matched and there is still input to parse and // we don't already know this is the last element, // we're going to next check for the delimiter ... // if there's none, or if there's no input left to parse // than this must be the last element after all ... if (r[1].length > 0 && ! last) { try { q = d.call(this, r[1]); } catch (ex) { last = true; } } else { last = true; } // if we parsed the delimiter and now there's no more input, // that means we shouldn't have parsed the delimiter at all // so don't update r and mark this as the last element ... if (!last && q[1].length === 0) { last = true; } // so, if this isn't the last element, we're going to see if // we can get any more matches from the remaining (unmatched) // elements ... if (!last) { // build a list of the remaining rules we can match against, // i.e., all but the one we just matched against var qx = []; for (var j = 0; j < px.length ; j++) { if (i !== j) { qx.push(px[j]); } } // now invoke recursively set with the remaining input // note that we don't include the closing delimiter ... // we'll check for that ourselves at the end p = _.set(qx, d).call(this, q[1]); // if we got a non-empty set as a result ... // (otw rx already contains everything we want to match) if (p[0].length > 0) { // update current result, which is stored in rx ... // basically, pick up the remaining text from p[1] // and concat the result from p[0] so that we don't // get endless nesting ... rx[0] = rx[0].concat(p[0]); rx[1] = p[1]; } } // at this point, rx either contains the last matched element // or the entire matched set that starts with this element. // now we just check to see if this variation is better than // our best so far, in terms of how much of the input is parsed if (rx[1].length < best[1].length) { best = rx; } // if we've parsed all the input, then we're finished if (best[1].length === 0) { break; } } // so now we've either gone through all the patterns trying them // as the initial match; or we found one that parsed the entire // input string ... // if best has no matches, just return empty set ... if (best[0].length === 0) { return best; } // if a closing delimiter is provided, then we have to check it also if (c) { // we try this even if there is no remaining input because the pattern // may well be optional or match empty input ... try { q = c.call(this, best[1]); } catch (ey) { throw new $P.Exception(best[1]); } // it parsed ... be sure to update the best match remaining input best[1] = q[1]; } // if we're here, either there was no closing delimiter or we parsed it // so now we have the best match; just return it! return best; }; }, forward: function (gr, fname) { return function (s) { return gr[fname].call(this, s); }; }, // // Translation Operators // replace: function (rule, repl) { return function (s) { var r = rule.call(this, s); return [repl, r[1]]; }; }, process: function (rule, fn) { return function (s) { var r = rule.call(this, s); return [fn.call(this, r[0]), r[1]]; }; }, min: function (min, rule) { return function (s) { var rx = rule.call(this, s); if (rx[0].length < min) { throw new $P.Exception(s); } return rx; }; } }; // Generator Operators And Vector Operators // Generators are operators that have a signature of F(R) => R, // taking a given rule and returning another rule, such as // ignore, which parses a given rule and throws away the result. // Vector operators are those that have a signature of F(R1,R2,...) => R, // take a list of rules and returning a new rule, such as each. // Generator operators are converted (via the following _generator // function) into functions that can also take a list or array of rules // and return an array of new rules as though the function had been // called on each rule in turn (which is what actually happens). // This allows generators to be used with vector operators more easily. // Example: // each(ignore(foo, bar)) instead of each(ignore(foo), ignore(bar)) // This also turns generators into vector operators, which allows // constructs like: // not(cache(foo, bar)) var _generator = function (op) { function gen() { var args = null, rx = [], px, i; if (arguments.length > 1) { args = Array.prototype.slice.call(arguments); } else if (arguments[0] instanceof Array) { args = arguments[0]; } if (args) { px = args.shift(); if (px.length > 0) { args.unshift(px[i]); rx.push(op.apply(null, args)); args.shift(); return rx; } } else { return op.apply(null, arguments); } } return gen; }; var gx = "optional not ignore cache".split(/\s/); for (var i = 0 ; i < gx.length ; i++) { _[gx[i]] = _generator(_[gx[i]]); } var _vector = function (op) { return function () { if (arguments[0] instanceof Array) { return op.apply(null, arguments[0]); } else { return op.apply(null, arguments); } }; }; var vx = "each any all".split(/\s/); for (var j = 0 ; j < vx.length ; j++) { _[vx[j]] = _vector(_[vx[j]]); } }()); (function () { var $D = Date; var flattenAndCompact = function (ax) { var rx = []; for (var i = 0; i < ax.length; i++) { if (ax[i] instanceof Array) { rx = rx.concat(flattenAndCompact(ax[i])); } else { if (ax[i]) { rx.push(ax[i]); } } } return rx; }; var parseMeridian = function () { if (this.meridian && (this.hour || this.hour === 0)) { if (this.meridian === "a" && this.hour > 11 && Date.Config.strict24hr){ throw "Invalid hour and meridian combination"; } else if (this.meridian === "p" && this.hour < 12 && Date.Config.strict24hr){ throw "Invalid hour and meridian combination"; } else if (this.meridian === "p" && this.hour < 12) { this.hour = this.hour + 12; } else if (this.meridian === "a" && this.hour === 12) { this.hour = 0; } } }; var setDefaults = function () { var now = new Date(); if ((this.hour || this.minute) && (!this.month && !this.year && !this.day)) { this.day = now.getDate(); } if (!this.year) { this.year = now.getFullYear(); } if (!this.month && this.month !== 0) { this.month = now.getMonth(); } if (!this.day) { this.day = 1; } if (!this.hour) { this.hour = 0; } if (!this.minute) { this.minute = 0; } if (!this.second) { this.second = 0; } if (!this.millisecond) { this.millisecond = 0; } }; var finishUtils = { getToday: function () { if (this.now || "hour minute second".indexOf(this.unit) !== -1) { return new Date(); } else { return $D.today(); } }, setDaysFromWeekday: function (today, orient){ var gap; orient = orient || 1; this.unit = "day"; gap = ($D.getDayNumberFromName(this.weekday) - today.getDay()); this.days = gap ? ((gap + (orient * 7)) % 7) : (orient * 7); return this; }, setMonthsFromMonth: function (today, orient) { var gap; orient = orient || 1; this.unit = "month"; gap = (this.month - today.getMonth()); this.months = gap ? ((gap + (orient * 12)) % 12) : (orient * 12); this.month = null; return this; }, setDMYFromWeekday: function () { var d = Date[this.weekday](); this.day = d.getDate(); if (!this.month) { this.month = d.getMonth(); } this.year = d.getFullYear(); return this; }, setUnitValue: function (orient) { if (!this.value && this.operator && this.operator !== null && this[this.unit + "s"] && this[this.unit + "s"] !== null) { this[this.unit + "s"] = this[this.unit + "s"] + ((this.operator === "add") ? 1 : -1) + (this.value||0) * orient; } else if (this[this.unit + "s"] == null || this.operator != null) { if (!this.value) { this.value = 1; } this[this.unit + "s"] = this.value * orient; } }, generateDateFromWeeks: function () { var weekday = (this.weekday !== undefined) ? this.weekday : "today"; var d = Date[weekday]().addWeeks(this.weeks); if (this.now) { d.setTimeToNow(); } return d; } }; $D.Translator = { hour: function (s) { return function () { this.hour = Number(s); }; }, minute: function (s) { return function () { this.minute = Number(s); }; }, second: function (s) { return function () { this.second = Number(s); }; }, /* for ss.s format */ secondAndMillisecond: function (s) { return function () { var mx = s.match(/^([0-5][0-9])\.([0-9]{1,3})/); this.second = Number(mx[1]); this.millisecond = Number(mx[2]); }; }, meridian: function (s) { return function () { this.meridian = s.slice(0, 1).toLowerCase(); }; }, timezone: function (s) { return function () { var n = s.replace(/[^\d\+\-]/g, ""); if (n.length) { this.timezoneOffset = Number(n); } else { this.timezone = s.toLowerCase(); } }; }, day: function (x) { var s = x[0]; return function () { this.day = Number(s.match(/\d+/)[0]); if (this.day < 1) { throw "invalid day"; } }; }, month: function (s) { return function () { this.month = (s.length === 3) ? "jan feb mar apr may jun jul aug sep oct nov dec".indexOf(s)/4 : Number(s) - 1; if (this.month < 0) { throw "invalid month"; } }; }, year: function (s) { return function () { var n = Number(s); this.year = ((s.length > 2) ? n : (n + (((n + 2000) < Date.CultureInfo.twoDigitYearMax) ? 2000 : 1900))); }; }, rday: function (s) { return function () { switch (s) { case "yesterday": this.days = -1; break; case "tomorrow": this.days = 1; break; case "today": this.days = 0; break; case "now": this.days = 0; this.now = true; break; } }; }, finishExact: function (x) { var d; x = (x instanceof Array) ? x : [x]; for (var i = 0 ; i < x.length ; i++) { if (x[i]) { x[i].call(this); } } setDefaults.call(this); parseMeridian.call(this); if (this.day > $D.getDaysInMonth(this.year, this.month)) { throw new RangeError(this.day + " is not a valid value for days."); } d = new Date(this.year, this.month, this.day, this.hour, this.minute, this.second, this.millisecond); if (this.year < 100) { d.setFullYear(this.year); // means years less that 100 are process correctly. JS will parse it otherwise as 1900-1999. } if (this.timezone) { d.set({ timezone: this.timezone }); } else if (this.timezoneOffset) { d.set({ timezoneOffset: this.timezoneOffset }); } return d; }, finish: function (x) { var today, expression, orient, temp; x = (x instanceof Array) ? flattenAndCompact(x) : [ x ]; if (x.length === 0) { return null; } for (var i = 0 ; i < x.length ; i++) { if (typeof x[i] === "function") { x[i].call(this); } } if (this.now && !this.unit && !this.operator) { return new Date(); } else { today = finishUtils.getToday.call(this); } expression = !!(this.days && this.days !== null || this.orient || this.operator); orient = ((this.orient === "past" || this.operator === "subtract") ? -1 : 1); if (this.month && this.unit === "week") { this.value = this.month + 1; delete this.month; delete this.day; } if ((this.month || this.month === 0) && "year day hour minute second".indexOf(this.unit) !== -1) { if (!this.value) { this.value = this.month + 1; } this.month = null; expression = true; } if (!expression && this.weekday && !this.day && !this.days) { finishUtils.setDMYFromWeekday.call(this); } if (expression && this.weekday && this.unit !== "month" && this.unit !== "week") { finishUtils.setDaysFromWeekday.call(this, today, orient); } if (this.weekday && this.unit !== "week" && !this.day && !this.days) { temp = Date[this.weekday](); this.day = temp.getDate(); if (temp.getMonth() !== today.getMonth()) { this.month = temp.getMonth(); } } if (this.month && this.unit === "day" && this.operator) { if (!this.value) { this.value = (this.month + 1); } this.month = null; } if (this.value != null && this.month != null && this.year != null) { this.day = this.value * 1; } if (this.month && !this.day && this.value) { today.set({ day: this.value * 1 }); if (!expression) { this.day = this.value * 1; } } if (!this.month && this.value && this.unit === "month" && !this.now) { this.month = this.value; expression = true; } if (expression && (this.month || this.month === 0) && this.unit !== "year") { finishUtils.setMonthsFromMonth.call(this, today, orient); } if (!this.unit) { this.unit = "day"; } finishUtils.setUnitValue.call(this, orient); parseMeridian.call(this); if ((this.month || this.month === 0) && !this.day) { this.day = 1; } if (!this.orient && !this.operator && this.unit === "week" && this.value && !this.day && !this.month) { return Date.today().setWeek(this.value); } if (this.unit === "week" && this.weeks && !this.day && !this.month) { return finishUtils.generateDateFromWeeks.call(this); } if (expression && this.timezone && this.day && this.days) { this.day = this.days; } if (expression){ today.add(this); } else { today.set(this); } if (this.timezone) { this.timezone = this.timezone.toUpperCase(); var offset = $D.getTimezoneOffset(this.timezone); var timezone; if (today.hasDaylightSavingTime()) { // lets check that we're being sane with timezone setting timezone = $D.getTimezoneAbbreviation(offset, today.isDaylightSavingTime()); if (timezone !== this.timezone) { // bugger, we're in a place where things like EST vs EDT matters. if (today.isDaylightSavingTime()) { today.addHours(-1); } else { today.addHours(1); } } } today.setTimezoneOffset(offset); } return today; } }; }()); (function () { var $D = Date; $D.Grammar = {}; var _ = $D.Parsing.Operators, g = $D.Grammar, t = $D.Translator, _fn; // Allow rolling up into general purpose rules _fn = function () { return _.each(_.any.apply(null, arguments), _.not(g.ctoken2("timeContext"))); }; g.datePartDelimiter = _.rtoken(/^([\s\-\.\,\/\x27]+)/); g.timePartDelimiter = _.stoken(":"); g.whiteSpace = _.rtoken(/^\s*/); g.generalDelimiter = _.rtoken(/^(([\s\,]|at|@|on)+)/); var _C = {}; g.ctoken = function (keys) { var fn = _C[keys]; if (! fn) { var c = Date.CultureInfo.regexPatterns; var kx = keys.split(/\s+/), px = []; for (var i = 0; i < kx.length ; i++) { px.push(_.replace(_.rtoken(c[kx[i]]), kx[i])); } fn = _C[keys] = _.any.apply(null, px); } return fn; }; g.ctoken2 = function (key) { return _.rtoken(Date.CultureInfo.regexPatterns[key]); }; var cacheProcessRtoken = function (key, token, type, eachToken) { if (eachToken) { g[key] = _.cache(_.process(_.each(_.rtoken(token),_.optional(g.ctoken2(eachToken))), type)); } else { g[key] = _.cache(_.process(_.rtoken(token), type)); } }; var cacheProcessCtoken = function (token, type) { return _.cache(_.process(g.ctoken2(token), type)); }; var _F = {}; //function cache var _get = function (f) { _F[f] = (_F[f] || g.format(f)[0]); return _F[f]; }; g.allformats = function (fx) { var rx = []; if (fx instanceof Array) { for (var i = 0; i < fx.length; i++) { rx.push(_get(fx[i])); } } else { rx.push(_get(fx)); } return rx; }; g.formats = function (fx) { if (fx instanceof Array) { var rx = []; for (var i = 0 ; i < fx.length ; i++) { rx.push(_get(fx[i])); } return _.any.apply(null, rx); } else { return _get(fx); } }; var grammarFormats = { timeFormats: function(){ var i, RTokenKeys = [ "h", "hh", "H", "HH", "m", "mm", "s", "ss", "ss.s", "z", "zz" ], RToken = [ /^(0[0-9]|1[0-2]|[1-9])/, /^(0[0-9]|1[0-2])/, /^([0-1][0-9]|2[0-3]|[0-9])/, /^([0-1][0-9]|2[0-3])/, /^([0-5][0-9]|[0-9])/, /^[0-5][0-9]/, /^([0-5][0-9]|[0-9])/, /^[0-5][0-9]/, /^[0-5][0-9]\.[0-9]{1,3}/, /^((\+|\-)\s*\d\d\d\d)|((\+|\-)\d\d\:?\d\d)/, /^((\+|\-)\s*\d\d\d\d)|((\+|\-)\d\d\:?\d\d)/ ], tokens = [ t.hour, t.hour, t.hour, t.hour, t.minute, t.minute, t.second, t.second, t.secondAndMillisecond, t.timezone, t.timezone ]; for (i=0; i < RTokenKeys.length; i++) { cacheProcessRtoken(RTokenKeys[i], RToken[i], tokens[i]); } g.hms = _.cache(_.sequence([g.H, g.m, g.s], g.timePartDelimiter)); g.t = cacheProcessCtoken("shortMeridian", t.meridian); g.tt = cacheProcessCtoken("longMeridian", t.meridian); g.zzz = cacheProcessCtoken("timezone", t.timezone); g.timeSuffix = _.each(_.ignore(g.whiteSpace), _.set([ g.tt, g.zzz ])); g.time = _.each(_.optional(_.ignore(_.stoken("T"))), g.hms, g.timeSuffix); }, dateFormats: function () { // pre-loaded rules for different date part order preferences var _setfn = function () { return _.set(arguments, g.datePartDelimiter); }; var i, RTokenKeys = [ "d", "dd", "M", "MM", "y", "yy", "yyy", "yyyy" ], RToken = [ /^([0-2]\d|3[0-1]|\d)/, /^([0-2]\d|3[0-1])/, /^(1[0-2]|0\d|\d)/, /^(1[0-2]|0\d)/, /^(\d+)/, /^(\d\d)/, /^(\d\d?\d?\d?)/, /^(\d\d\d\d)/ ], tokens = [ t.day, t.day, t.month, t.month, t.year, t.year, t.year, t.year ], eachToken = [ "ordinalSuffix", "ordinalSuffix" ]; for (i=0; i < RTokenKeys.length; i++) { cacheProcessRtoken(RTokenKeys[i], RToken[i], tokens[i], eachToken[i]); } g.MMM = g.MMMM = _.cache(_.process(g.ctoken("jan feb mar apr may jun jul aug sep oct nov dec"), t.month)); g.ddd = g.dddd = _.cache(_.process(g.ctoken("sun mon tue wed thu fri sat"), function (s) { return function () { this.weekday = s; }; } )); g.day = _fn(g.d, g.dd); g.month = _fn(g.M, g.MMM); g.year = _fn(g.yyyy, g.yy); g.mdy = _setfn(g.ddd, g.month, g.day, g.year); g.ymd = _setfn(g.ddd, g.year, g.month, g.day); g.dmy = _setfn(g.ddd, g.day, g.month, g.year); g.date = function (s) { return ((g[Date.CultureInfo.dateElementOrder] || g.mdy).call(this, s)); }; }, relative: function () { // relative date / time expressions g.orientation = _.process(g.ctoken("past future"), function (s) { return function () { this.orient = s; }; } ); g.operator = _.process(g.ctoken("add subtract"), function (s) { return function () { this.operator = s; }; } ); g.rday = _.process(g.ctoken("yesterday tomorrow today now"), t.rday); g.unit = _.process(g.ctoken("second minute hour day week month year"), function (s) { return function () { this.unit = s; }; } ); } }; g.buildGrammarFormats = function () { // these need to be rebuilt every time the language changes. _C = {}; grammarFormats.timeFormats(); grammarFormats.dateFormats(); grammarFormats.relative(); g.value = _.process(_.rtoken(/^([-+]?\d+)?(st|nd|rd|th)?/), function (s) { return function () { this.value = s.replace(/\D/g, ""); }; } ); g.expression = _.set([g.rday, g.operator, g.value, g.unit, g.orientation, g.ddd, g.MMM ]); g.format = _.process(_.many( _.any( // translate format specifiers into grammar rules _.process( _.rtoken(/^(dd?d?d?(?!e)|MM?M?M?|yy?y?y?|hh?|HH?|mm?|ss?|tt?|zz?z?)/), function (fmt) { if (g[fmt]) { return g[fmt]; } else { throw $D.Parsing.Exception(fmt); } } ), // translate separator tokens into token rules _.process(_.rtoken(/^[^dMyhHmstz]+/), // all legal separators function (s) { return _.ignore(_.stoken(s)); } ) ) ), // construct the parser ... function (rules) { return _.process(_.each.apply(null, rules), t.finishExact); } ); // starting rule for general purpose grammar g._start = _.process(_.set([ g.date, g.time, g.expression ], g.generalDelimiter, g.whiteSpace), t.finish); }; g.buildGrammarFormats(); // parsing date format specifiers - ex: "h:m:s tt" // this little guy will generate a custom parser based // on the format string, ex: g.format("h:m:s tt") // check for these formats first g._formats = g.formats([ "\"yyyy-MM-ddTHH:mm:ssZ\"", "yyyy-MM-ddTHH:mm:ss.sz", "yyyy-MM-ddTHH:mm:ssZ", "yyyy-MM-ddTHH:mm:ssz", "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-ddTHH:mmZ", "yyyy-MM-ddTHH:mmz", "yyyy-MM-ddTHH:mm", "ddd, MMM dd, yyyy H:mm:ss tt", "ddd MMM d yyyy HH:mm:ss zzz", "MMddyyyy", "ddMMyyyy", "Mddyyyy", "ddMyyyy", "Mdyyyy", "dMyyyy", "yyyy", "Mdyy", "dMyy", "d" ]); // real starting rule: tries selected formats first, // then general purpose rule g.start = function (s) { try { var r = g._formats.call({}, s); if (r[1].length === 0) { return r; } } catch (e) {} return g._start.call({}, s); }; }()); (function () { var $D = Date; /** * @desc Converts the specified string value into its JavaScript Date equivalent using CultureInfo specific format information. * * Example

	///////////
	// Dates //
	///////////

	// 15-Oct-2004
	var d1 = Date.parse("10/15/2004");

	// 15-Oct-2004
	var d1 = Date.parse("15-Oct-2004");

	// 15-Oct-2004
	var d1 = Date.parse("2004.10.15");

	//Fri Oct 15, 2004
	var d1 = Date.parse("Fri Oct 15, 2004");

	///////////
	// Times //
	///////////

	// Today at 10 PM.
	var d1 = Date.parse("10 PM");

	// Today at 10:30 PM.
	var d1 = Date.parse("10:30 P.M.");

	// Today at 6 AM.
	var d1 = Date.parse("06am");

	/////////////////////
	// Dates and Times //
	/////////////////////

	// 8-July-2004 @ 10:30 PM
	var d1 = Date.parse("July 8th, 2004, 10:30 PM");

	// 1-July-2004 @ 10:30 PM
	var d1 = Date.parse("2004-07-01T22:30:00");

	////////////////////
	// Relative Dates //
	////////////////////

	// Returns today's date. The string "today" is culture specific.
	var d1 = Date.parse("today");

	// Returns yesterday's date. The string "yesterday" is culture specific.
	var d1 = Date.parse("yesterday");

	// Returns the date of the next thursday.
	var d1 = Date.parse("Next thursday");

	// Returns the date of the most previous monday.
	var d1 = Date.parse("last monday");

	// Returns today's day + one year.
	var d1 = Date.parse("next year");

	///////////////
	// Date Math //
	///////////////

	// Today + 2 days
	var d1 = Date.parse("t+2");

	// Today + 2 days
	var d1 = Date.parse("today + 2 days");

	// Today + 3 months
	var d1 = Date.parse("t+3m");

	// Today - 1 year
	var d1 = Date.parse("today - 1 year");

	// Today - 1 year
	var d1 = Date.parse("t-1y"); 


	/////////////////////////////
	// Partial Dates and Times //
	/////////////////////////////

	// July 15th of this year.
	var d1 = Date.parse("July 15");

	// 15th day of current day and year.
	var d1 = Date.parse("15");

	// July 1st of current year at 10pm.
	var d1 = Date.parse("7/1 10pm");
	
* * @param {String} The string value to convert into a Date object [Required] * @return {Date} A Date object or null if the string cannot be converted into a Date. */ var parseUtils = { removeOrds: function (s) { ords = s.match(/\b(\d+)(?:st|nd|rd|th)\b/); // find ordinal matches s = ((ords && ords.length === 2) ? s.replace(ords[0], ords[1]) : s); return s; }, grammarParser: function (s) { var r = null; try { r = $D.Grammar.start.call({}, s.replace(/^\s*(\S*(\s+\S+)*)\s*$/, "$1")); } catch (e) { return null; } return ((r[1].length === 0) ? r[0] : null); }, nativeFallback: function(s) { var t; try { // ok we haven't parsed it, last ditch attempt with the built-in parser. t = Date._parse(s); return (t || t === 0) ? new Date(t) : null; } catch (e) { return null; } } }; function parse (s) { var d; if (!s) { return null; } if (s instanceof Date) { return s.clone(); } if (s.length >= 4 && s.charAt(0) !== "0" && s.charAt(0) !== "+"&& s.charAt(0) !== "-") { // ie: 2004 will pass, 0800 won't. // Start with specific formats d = $D.Parsing.ISO.parse(s) || $D.Parsing.Numeric.parse(s); } if (d instanceof Date && !isNaN(d.getTime())) { return d; } else { // find ordinal dates (1st, 3rd, 8th, etc and remove them as they cause parsing issues) s = $D.Parsing.Normalizer.parse(parseUtils.removeOrds(s)); d = parseUtils.grammarParser(s); if (d !== null) { return d; } else { return parseUtils.nativeFallback(s); } } } if (!$D._parse) { $D._parse = $D.parse; } $D.parse = parse; Date.getParseFunction = function (fx) { var fns = Date.Grammar.allformats(fx); return function (s) { var r = null; for (var i = 0; i < fns.length; i++) { try { r = fns[i].call({}, s); } catch (e) { continue; } if (r[1].length === 0) { return r[0]; } } return null; }; }; /** * Converts the specified string value into its JavaScript Date equivalent using the specified format {String} or formats {Array} and the CultureInfo specific format information. * The format of the string value must match one of the supplied formats exactly. * * Example

	// 15-Oct-2004
	var d1 = Date.parseExact("10/15/2004", "M/d/yyyy");

	// 15-Oct-2004
	var d1 = Date.parse("15-Oct-2004", "M-ddd-yyyy");

	// 15-Oct-2004
	var d1 = Date.parse("2004.10.15", "yyyy.MM.dd");

	// Multiple formats
	var d1 = Date.parseExact("10/15/2004", ["M/d/yyyy", "MMMM d, yyyy"]);
	
* * @param {String} The string value to convert into a Date object [Required]. * @param {Object} The expected format {String} or an array of expected formats {Array} of the date string [Required]. * @return {Date} A Date object or null if the string cannot be converted into a Date. */ $D.parseExact = function (s, fx) { return $D.getParseFunction(fx)(s); }; }()); (function () { var $D = Date, $P = $D.prototype, // $C = $D.CultureInfo, // not used atm p = function (s, l) { if (!l) { l = 2; } return ("000" + s).slice(l * -1); }; /** * Converts a PHP format string to Java/.NET format string. * A PHP format string can be used with ._format or .format. * A Java/.NET format string can be used with .toString(). * The .parseExact function will only accept a Java/.NET format string * * Example * var f1 = "%m/%d/%y" * var f2 = Date.normalizeFormat(f1); // "MM/dd/yy" * * new Date().format(f1); // "04/13/08" * new Date()._format(f1); // "04/13/08" * new Date().toString(f2); // "04/13/08" * * var date = Date.parseExact("04/13/08", f2); // Sun Apr 13 2008 * * @param {String} A PHP format string consisting of one or more format spcifiers. * @return {String} The PHP format converted to a Java/.NET format string. */ var normalizerSubstitutions = { "d" : "dd", "%d": "dd", "D" : "ddd", "%a": "ddd", "j" : "dddd", "l" : "dddd", "%A": "dddd", "S" : "S", "F" : "MMMM", "%B": "MMMM", "m" : "MM", "%m": "MM", "M" : "MMM", "%b": "MMM", "%h": "MMM", "n" : "M", "Y" : "yyyy", "%Y": "yyyy", "y" : "yy", "%y": "yy", "g" : "h", "%I": "h", "G" : "H", "h" : "hh", "H" : "HH", "%H": "HH", "i" : "mm", "%M": "mm", "s" : "ss", "%S": "ss", "%r": "hh:mm tt", "%R": "H:mm", "%T": "H:mm:ss", "%X": "t", "%x": "d", "%e": "d", "%D": "MM/dd/yy", "%n": "\\n", "%t": "\\t", "e" : "z", "T" : "z", "%z": "z", "%Z": "z", "Z" : "ZZ", "N" : "u", "w" : "u", "%w": "u", "W" : "W", "%V": "W" }; var normalizer = { substitutes: function (m) { return normalizerSubstitutions[m]; }, interpreted: function (m, x) { var y; switch (m) { case "%u": return x.getDay() + 1; case "z": return x.getOrdinalNumber(); case "%j": return p(x.getOrdinalNumber(), 3); case "%U": var d1 = x.clone().set({month: 0, day: 1}).addDays(-1).moveToDayOfWeek(0), d2 = x.clone().addDays(1).moveToDayOfWeek(0, -1); return (d2 < d1) ? "00" : p((d2.getOrdinalNumber() - d1.getOrdinalNumber()) / 7 + 1); case "%W": return p(x.getWeek()); case "t": return $D.getDaysInMonth(x.getFullYear(), x.getMonth()); case "o": case "%G": return x.setWeek(x.getISOWeek()).toString("yyyy"); case "%g": return x._format("%G").slice(-2); case "a": case "%p": return t("tt").toLowerCase(); case "A": return t("tt").toUpperCase(); case "u": return p(x.getMilliseconds(), 3); case "I": return (x.isDaylightSavingTime()) ? 1 : 0; case "O": return x.getUTCOffset(); case "P": y = x.getUTCOffset(); return y.substring(0, y.length - 2) + ":" + y.substring(y.length - 2); case "B": var now = new Date(); return Math.floor(((now.getHours() * 3600) + (now.getMinutes() * 60) + now.getSeconds() + (now.getTimezoneOffset() + 60) * 60) / 86.4); case "c": return x.toISOString().replace(/\"/g, ""); case "U": return $D.strtotime("now"); case "%c": return t("d") + " " + t("t"); case "%C": return Math.floor(x.getFullYear() / 100 + 1); } }, shouldOverrideDefaults: function (m) { switch (m) { case "%e": return true; default: return false; } }, parse: function (m, context) { var formatString, c = context || new Date(); formatString = normalizer.substitutes(m); if (formatString) { return formatString; } formatString = normalizer.interpreted(m, c); if (formatString) { return formatString; } else { return m; } } }; $D.normalizeFormat = function (format, context) { return format.replace(/(%|\\)?.|%%/g, function(t){ return normalizer.parse(t, context); }); }; /** * Format a local Unix timestamp according to locale settings * * Example: * Date.strftime("%m/%d/%y", new Date()); // "04/13/08" * Date.strftime("c", "2008-04-13T17:52:03Z"); // "04/13/08" * * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @param {Number|String} The number representing the number of seconds that have elapsed since January 1, 1970 (local time). * @return {String} A string representation of the current Date object. */ $D.strftime = function (format, time) { var d = Date.parse(time); return d._format(format); }; /** * Parse any textual datetime description into a Unix timestamp. * A Unix timestamp is the number of seconds that have elapsed since January 1, 1970 (midnight UTC/GMT). * * Example: * Date.strtotime("04/13/08"); // 1208044800 * Date.strtotime("1970-01-01T00:00:00Z"); // 0 * * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @param {Object} A string or date object. * @return {String} A string representation of the current Date object. */ $D.strtotime = function (time) { var d = $D.parse(time); return Math.round($D.UTC(d.getUTCFullYear(), d.getUTCMonth(), d.getUTCDate(), d.getUTCHours(), d.getUTCMinutes(), d.getUTCSeconds(), d.getUTCMilliseconds()) / 1000); }; /** * Converts the value of the current Date object to its equivalent string representation using a PHP/Unix style of date format specifiers. * Format Specifiers * Format Description Example * ------ --------------------------------------------------------------------------- ----------------------- * %a abbreviated weekday name according to the current localed "Mon" through "Sun" * %A full weekday name according to the current localed "Sunday" through "Saturday" * %b abbreviated month name according to the current localed "Jan" through "Dec" * %B full month name according to the current locale "January" through "December" * %c preferred date and time representation for the current locale "4/13/2008 12:33 PM" * %C century number (the year divided by 100 and truncated to an integer) "00" to "99" * %d day of the month as a decimal number "01" to "31" * %D same as %m/%d/%y "04/13/08" * %e day of the month as a decimal number, a single digit is preceded by a space "1" to "31" * %g like %G, but without the century "08" * %G The 4-digit year corresponding to the ISO week number (see %V). "2008" * This has the same format and value as %Y, except that if the ISO week number * belongs to the previous or next year, that year is used instead. * %h same as %b "Jan" through "Dec" * %H hour as a decimal number using a 24-hour clock. "00" to "23" * %I hour as a decimal number using a 12-hour clock. "01" to "12" * %j day of the year as a decimal number. "001" to "366" * %m month as a decimal number. "01" to "12" * %M minute as a decimal number. "00" to "59" * %n newline character "\n" * %p either "am" or "pm" according to the given time value, or the "am" or "pm" * corresponding strings for the current locale. * %r time in a.m. and p.m. notation "8:44 PM" * %R time in 24 hour notation "20:44" * %S second as a decimal number "00" to "59" * %t tab character "\t" * %T current time, equal to %H:%M:%S "12:49:11" * %u weekday as a decimal number ["1", "7"], with "1" representing Monday "1" to "7" * %U week number of the current year as a decimal number, starting with the "0" to ("52" or "53") * first Sunday as the first day of the first week * %V The ISO 8601:1988 week number of the current year as a decimal number, "00" to ("52" or "53") * range 01 to 53, where week 1 is the first week that has at least 4 days * in the current year, and with Monday as the first day of the week. * (Use %G or %g for the year component that corresponds to the week number * for the specified timestamp.) * %W week number of the current year as a decimal number, starting with the "00" to ("52" or "53") * first Monday as the first day of the first week * %w day of the week as a decimal, Sunday being "0" "0" to "6" * %x preferred date representation for the current locale without the time "4/13/2008" * %X preferred time representation for the current locale without the date "12:53:05" * %y year as a decimal number without a century "00" "99" * %Y year as a decimal number including the century "2008" * %Z time zone or name or abbreviation "UTC", "EST", "PST" * %z same as %Z * %% a literal "%" characters "%" * d Day of the month, 2 digits with leading zeros "01" to "31" * D A textual representation of a day, three letters "Mon" through "Sun" * j Day of the month without leading zeros "1" to "31" * l A full textual representation of the day of the week (lowercase "L") "Sunday" through "Saturday" * N ISO-8601 numeric representation of the day of the week (added in PHP 5.1.0) "1" (for Monday) through "7" (for Sunday) * S English ordinal suffix for the day of the month, 2 characters "st", "nd", "rd" or "th". Works well with j * w Numeric representation of the day of the week "0" (for Sunday) through "6" (for Saturday) * z The day of the year (starting from "0") "0" through "365" * W ISO-8601 week number of year, weeks starting on Monday "00" to ("52" or "53") * F A full textual representation of a month, such as January or March "January" through "December" * m Numeric representation of a month, with leading zeros "01" through "12" * M A short textual representation of a month, three letters "Jan" through "Dec" * n Numeric representation of a month, without leading zeros "1" through "12" * t Number of days in the given month "28" through "31" * L Whether it's a leap year "1" if it is a leap year, "0" otherwise * o ISO-8601 year number. This has the same value as Y, except that if the "2008" * ISO week number (W) belongs to the previous or next year, that year * is used instead. * Y A full numeric representation of a year, 4 digits "2008" * y A two digit representation of a year "08" * a Lowercase Ante meridiem and Post meridiem "am" or "pm" * A Uppercase Ante meridiem and Post meridiem "AM" or "PM" * B Swatch Internet time "000" through "999" * g 12-hour format of an hour without leading zeros "1" through "12" * G 24-hour format of an hour without leading zeros "0" through "23" * h 12-hour format of an hour with leading zeros "01" through "12" * H 24-hour format of an hour with leading zeros "00" through "23" * i Minutes with leading zeros "00" to "59" * s Seconds, with leading zeros "00" through "59" * u Milliseconds "54321" * e Timezone identifier "UTC", "EST", "PST" * I Whether or not the date is in daylight saving time (uppercase i) "1" if Daylight Saving Time, "0" otherwise * O Difference to Greenwich time (GMT) in hours "+0200", "-0600" * P Difference to Greenwich time (GMT) with colon between hours and minutes "+02:00", "-06:00" * T Timezone abbreviation "UTC", "EST", "PST" * Z Timezone offset in seconds. The offset for timezones west of UTC is "-43200" through "50400" * always negative, and for those east of UTC is always positive. * c ISO 8601 date "2004-02-12T15:19:21+00:00" * r RFC 2822 formatted date "Thu, 21 Dec 2000 16:01:07 +0200" * U Seconds since the Unix Epoch (January 1 1970 00:00:00 GMT) "0" * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @return {String} A string representation of the current Date object. */ var formatReplace = function (context) { return function (m) { var formatString, override = false; if (m.charAt(0) === "\\" || m.substring(0, 2) === "%%") { return m.replace("\\", "").replace("%%", "%"); } override = normalizer.shouldOverrideDefaults(m); formatString = $D.normalizeFormat(m, context); if (formatString) { return context.toString(formatString, override); } }; }; $P._format = function (format) { var formatter = formatReplace(this); if (!format) { return this._toString(); } else { return format.replace(/(%|\\)?.|%%/g, formatter); } }; if (!$P.format) { $P.format = $P._format; } }()); (function () { "use strict"; var gFn = function (attr) { return function () { return this[attr]; }; }; var sFn = function (attr) { return function (val) { this[attr] = val; return this; }; }; var attrs = ["years", "months", "days", "hours", "minutes", "seconds", "milliseconds"]; var addSetFuncs = function (context, attrs) { for (var i = 0; i < attrs.length ; i++) { var $a = attrs[i], $b = $a.slice(0, 1).toUpperCase() + $a.slice(1); context.prototype[$a] = 0; context.prototype["get" + $b] = gFn($a); context.prototype["set" + $b] = sFn($a); } }; /** * new TimeSpan(milliseconds); * new TimeSpan(days, hours, minutes, seconds); * new TimeSpan(days, hours, minutes, seconds, milliseconds); */ var TimeSpan = function (days, hours, minutes, seconds, milliseconds) { if (arguments.length === 1 && typeof days === "number") { var orient = (days < 0) ? -1 : +1; var millsLeft = Math.abs(days); this.setDays(Math.floor(millsLeft / 86400000) * orient); millsLeft = millsLeft % 86400000; this.setHours(Math.floor(millsLeft / 3600000) * orient); millsLeft = millsLeft % 3600000; this.setMinutes(Math.floor(millsLeft / 60000) * orient); millsLeft = millsLeft % 60000; this.setSeconds(Math.floor(millsLeft / 1000) * orient); millsLeft = millsLeft % 1000; this.setMilliseconds(millsLeft * orient); } else { this.set(days, hours, minutes, seconds, milliseconds); } this.getTotalMilliseconds = function () { return (this.getDays() * 86400000) + (this.getHours() * 3600000) + (this.getMinutes() * 60000) + (this.getSeconds() * 1000); }; this.compareTo = function (time) { var t1 = new Date(1970, 1, 1, this.getHours(), this.getMinutes(), this.getSeconds()), t2; if (time === null) { t2 = new Date(1970, 1, 1, 0, 0, 0); } else { t2 = new Date(1970, 1, 1, time.getHours(), time.getMinutes(), time.getSeconds()); } return (t1 < t2) ? -1 : (t1 > t2) ? 1 : 0; }; this.equals = function (time) { return (this.compareTo(time) === 0); }; this.add = function (time) { return (time === null) ? this : this.addSeconds(time.getTotalMilliseconds() / 1000); }; this.subtract = function (time) { return (time === null) ? this : this.addSeconds(-time.getTotalMilliseconds() / 1000); }; this.addDays = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 86400000)); }; this.addHours = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 3600000)); }; this.addMinutes = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 60000)); }; this.addSeconds = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 1000)); }; this.addMilliseconds = function (n) { return new TimeSpan(this.getTotalMilliseconds() + n); }; this.get12HourHour = function () { return (this.getHours() > 12) ? this.getHours() - 12 : (this.getHours() === 0) ? 12 : this.getHours(); }; this.getDesignator = function () { return (this.getHours() < 12) ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator; }; this.toString = function (format) { this._toString = function () { if (this.getDays() !== null && this.getDays() > 0) { return this.getDays() + "." + this.getHours() + ":" + this.p(this.getMinutes()) + ":" + this.p(this.getSeconds()); } else { return this.getHours() + ":" + this.p(this.getMinutes()) + ":" + this.p(this.getSeconds()); } }; this.p = function (s) { return (s.toString().length < 2) ? "0" + s : s; }; var me = this; return format ? format.replace(/dd?|HH?|hh?|mm?|ss?|tt?/g, function (format) { switch (format) { case "d": return me.getDays(); case "dd": return me.p(me.getDays()); case "H": return me.getHours(); case "HH": return me.p(me.getHours()); case "h": return me.get12HourHour(); case "hh": return me.p(me.get12HourHour()); case "m": return me.getMinutes(); case "mm": return me.p(me.getMinutes()); case "s": return me.getSeconds(); case "ss": return me.p(me.getSeconds()); case "t": return ((me.getHours() < 12) ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator).substring(0, 1); case "tt": return (me.getHours() < 12) ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator; } } ) : this._toString(); }; return this; }; addSetFuncs(TimeSpan, attrs.slice(2)); TimeSpan.prototype.set = function (days, hours, minutes, seconds, milliseconds){ this.setDays(days || this.getDays()); this.setHours(hours || this.getHours()); this.setMinutes(minutes || this.getMinutes()); this.setSeconds(seconds || this.getSeconds()); this.setMilliseconds(milliseconds || this.getMilliseconds()); }; /** * Gets the time of day for this date instances. * @return {TimeSpan} TimeSpan */ Date.prototype.getTimeOfDay = function () { return new TimeSpan(0, this.getHours(), this.getMinutes(), this.getSeconds(), this.getMilliseconds()); }; Date.TimeSpan = TimeSpan; if (typeof window !== "undefined" ) { // keeping API compatible for v1.x window.TimeSpan = TimeSpan; } }()); (function () { "use strict"; var attrs = ["years", "months", "days", "hours", "minutes", "seconds", "milliseconds"]; var gFn = function (attr) { return function () { return this[attr]; }; }; var sFn = function (attr) { return function (val) { this[attr] = val; return this; }; }; var addSetFuncs = function (context, attrs) { for (var i = 0; i < attrs.length ; i++) { var $a = attrs[i], $b = $a.slice(0, 1).toUpperCase() + $a.slice(1); context.prototype[$a] = 0; context.prototype["get" + $b] = gFn($a); context.prototype["set" + $b] = sFn($a); } }; var setMonthsAndYears = function (orient, d1, d2, context) { function inc() { d1.addMonths(-orient); context.months++; if (context.months === 12) { context.years++; context.months = 0; } } if (orient === +1) { while (d1 > d2) { inc(); } } else { while (d1 < d2) { inc(); } } context.months--; context.months *= orient; context.years *= orient; }; var adjustForDST = function(orient, startDate, endDate) { var hasDSTMismatch = (false === (startDate.isDaylightSavingTime() === endDate.isDaylightSavingTime())); if (hasDSTMismatch && orient === 1) { startDate.addHours(-1); } else if (hasDSTMismatch) { startDate.addHours(1); } }; /** * TimePeriod(startDate, endDate); * TimePeriod(years, months, days, hours, minutes, seconds, milliseconds); */ var TimePeriod = function (years, months, days, hours, minutes, seconds, milliseconds) { if (arguments.length === 7) { this.set(years, months, days, hours, minutes, seconds, milliseconds); } else if (arguments.length === 2 && arguments[0] instanceof Date && arguments[1] instanceof Date) { var startDate = arguments[0].clone(); var endDate = arguments[1].clone(); var orient = (startDate > endDate) ? +1 : -1; this.dates = { start: arguments[0].clone(), end: arguments[1].clone() }; setMonthsAndYears(orient, startDate, endDate, this); adjustForDST(orient, startDate, endDate); // // TODO - adjust for DST var diff = endDate - startDate; if (diff !== 0) { var ts = new TimeSpan(diff); this.set(this.years, this.months, ts.getDays(), ts.getHours(), ts.getMinutes(), ts.getSeconds(), ts.getMilliseconds()); } } return this; }; // create all the set functions. addSetFuncs(TimePeriod, attrs); TimePeriod.prototype.set = function (years, months, days, hours, minutes, seconds, milliseconds){ this.setYears(years || this.getYears()); this.setMonths(months || this.getMonths()); this.setDays(days || this.getDays()); this.setHours(hours || this.getHours()); this.setMinutes(minutes || this.getMinutes()); this.setSeconds(seconds || this.getSeconds()); this.setMilliseconds(milliseconds || this.getMilliseconds()); }; Date.TimePeriod = TimePeriod; if (typeof window !== "undefined") { // keeping API compatible for v1.x window.TimePeriod = TimePeriod; } }()); ================================================ FILE: build/date-es-AR.js ================================================ /** * @overview datejs * @version 1.0.0-rc3 * @author Gregory Wild-Smith * @copyright 2015 Gregory Wild-Smith * @license MIT * @homepage https://github.com/abritinthebay/datejs */ /* * DateJS Culture String File * Country Code: es-AR * Name: Spanish (Argentina) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["es-AR"] = { "name": "es-AR", "englishName": "Spanish (Argentina)", "nativeName": "Español (Argentina)", "Sunday": "domingo", "Monday": "lunes", "Tuesday": "martes", "Wednesday": "miércoles", "Thursday": "jueves", "Friday": "viernes", "Saturday": "sábado", "Sun": "dom", "Mon": "lun", "Tue": "mar", "Wed": "mié", "Thu": "jue", "Fri": "vie", "Sat": "sáb", "Su": "do", "Mo": "lu", "Tu": "ma", "We": "mi", "Th": "ju", "Fr": "vi", "Sa": "sá", "S_Sun_Initial": "d", "M_Mon_Initial": "l", "T_Tue_Initial": "m", "W_Wed_Initial": "m", "T_Thu_Initial": "j", "F_Fri_Initial": "v", "S_Sat_Initial": "s", "January": "enero", "February": "febrero", "March": "marzo", "April": "abril", "May": "mayo", "June": "junio", "July": "julio", "August": "agosto", "September": "septiembre", "October": "octubre", "November": "noviembre", "December": "diciembre", "Jan_Abbr": "ene", "Feb_Abbr": "feb", "Mar_Abbr": "mar", "Apr_Abbr": "abr", "May_Abbr": "may", "Jun_Abbr": "jun", "Jul_Abbr": "jul", "Aug_Abbr": "ago", "Sep_Abbr": "sep", "Oct_Abbr": "oct", "Nov_Abbr": "nov", "Dec_Abbr": "dic", "AM": "a.m.", "PM": "p.m.", "firstDayOfWeek": 0, "twoDigitYearMax": 2029, "mdy": "dmy", "M/d/yyyy": "dd/MM/yyyy", "dddd, MMMM dd, yyyy": "dddd, dd' [de] 'MMMM' [de] 'yyyy", "h:mm tt": "hh:mm tt", "h:mm:ss tt": "hh:mm:ss tt", "dddd, MMMM dd, yyyy h:mm:ss tt": "dddd, dd' [de] 'MMMM' [de] 'yyyy hh:mm:ss tt", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "dd MMMM", "MMMM, yyyy": "MMMM' [de] 'yyyy", "/jan(uary)?/": "ene(ro)?", "/feb(ruary)?/": "feb(rero)?", "/mar(ch)?/": "mar(zo)?", "/apr(il)?/": "abr(il)?", "/may/": "may(o)?", "/jun(e)?/": "jun(io)?", "/jul(y)?/": "jul(io)?", "/aug(ust)?/": "ago(sto)?", "/sep(t(ember)?)?/": "sep(tiembre)?", "/oct(ober)?/": "oct(ubre)?", "/nov(ember)?/": "nov(iembre)?", "/dec(ember)?/": "dic(iembre)?", "/^su(n(day)?)?/": "^do(m(ingo)?)?", "/^mo(n(day)?)?/": "^lu(n(es)?)?", "/^tu(e(s(day)?)?)?/": "^ma(r(tes)?)?", "/^we(d(nesday)?)?/": "^mi(é(rcoles)?)?", "/^th(u(r(s(day)?)?)?)?/": "^ju(e(ves)?)?", "/^fr(i(day)?)?/": "^vi(e(rnes)?)?", "/^sa(t(urday)?)?/": "^sá(b(ado)?)?", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "es-AR"; /** * @overview datejs * @version 1.0.0-rc3 * @author Gregory Wild-Smith * @copyright 2015 Gregory Wild-Smith * @license MIT * @homepage https://github.com/abritinthebay/datejs */(function () { var $D = Date; var lang = Date.CultureStrings ? Date.CultureStrings.lang : null; var loggedKeys = {}; // for debug purposes. var getText = { getFromKey: function (key, countryCode) { var output; if (Date.CultureStrings && Date.CultureStrings[countryCode] && Date.CultureStrings[countryCode][key]) { output = Date.CultureStrings[countryCode][key]; } else { output = getText.buildFromDefault(key); } if (key.charAt(0) === "/") { // Assume it's a regex output = getText.buildFromRegex(key, countryCode); } return output; }, getFromObjectValues: function (obj, countryCode) { var key, output = {}; for(key in obj) { if (obj.hasOwnProperty(key)) { output[key] = getText.getFromKey(obj[key], countryCode); } } return output; }, getFromObjectKeys: function (obj, countryCode) { var key, output = {}; for(key in obj) { if (obj.hasOwnProperty(key)) { output[getText.getFromKey(key, countryCode)] = obj[key]; } } return output; }, getFromArray: function (arr, countryCode) { var output = []; for (var i=0; i < arr.length; i++){ if (i in arr) { output[i] = getText.getFromKey(arr[i], countryCode); } } return output; }, buildFromDefault: function (key) { var output, length, split, last; switch(key) { case "name": output = "en-US"; break; case "englishName": output = "English (United States)"; break; case "nativeName": output = "English (United States)"; break; case "twoDigitYearMax": output = 2049; break; case "firstDayOfWeek": output = 0; break; default: output = key; split = key.split("_"); length = split.length; if (length > 1 && key.charAt(0) !== "/") { // if the key isn't a regex and it has a split. last = split[(length - 1)].toLowerCase(); if (last === "initial" || last === "abbr") { output = split[0]; } } break; } return output; }, buildFromRegex: function (key, countryCode) { var output; if (Date.CultureStrings && Date.CultureStrings[countryCode] && Date.CultureStrings[countryCode][key]) { output = new RegExp(Date.CultureStrings[countryCode][key], "i"); } else { output = new RegExp(key.replace(new RegExp("/", "g"),""), "i"); } return output; } }; var shallowMerge = function (obj1, obj2) { for (var attrname in obj2) { if (obj2.hasOwnProperty(attrname)) { obj1[attrname] = obj2[attrname]; } } }; var __ = function (key, language) { var countryCode = (language) ? language : lang; loggedKeys[key] = key; if (typeof key === "object") { if (key instanceof Array) { return getText.getFromArray(key, countryCode); } else { return getText.getFromObjectKeys(key, countryCode); } } else { return getText.getFromKey(key, countryCode); } }; var loadI18nScript = function (code) { // paatterned after jQuery's getScript. var url = Date.Config.i18n + code + ".js"; var head = document.getElementsByTagName("head")[0] || document.documentElement; var script = document.createElement("script"); script.src = url; var completed = false; var events = { done: function (){} // placeholder function }; // Attach handlers for all browsers script.onload = script.onreadystatechange = function() { if ( !completed && (!this.readyState || this.readyState === "loaded" || this.readyState === "complete") ) { events.done(); head.removeChild(script); } }; setTimeout(function() { head.insertBefore(script, head.firstChild); }, 0); // allows return to execute first return { done: function (cb) { events.done = function() { if (cb) { setTimeout(cb,0); } }; } }; }; var buildInfo = { buildFromMethodHash: function (obj) { var key; for(key in obj) { if (obj.hasOwnProperty(key)) { obj[key] = buildInfo[obj[key]](); } } return obj; }, timeZoneDST: function () { var DST = { "CHADT": "+1345", "NZDT": "+1300", "AEDT": "+1100", "ACDT": "+1030", "AZST": "+0500", "IRDT": "+0430", "EEST": "+0300", "CEST": "+0200", "BST": "+0100", "PMDT": "-0200", "ADT": "-0300", "NDT": "-0230", "EDT": "-0400", "CDT": "-0500", "MDT": "-0600", "PDT": "-0700", "AKDT": "-0800", "HADT": "-0900" }; return __(DST); }, timeZoneStandard: function () { var standard = { "LINT": "+1400", "TOT": "+1300", "CHAST": "+1245", "NZST": "+1200", "NFT": "+1130", "SBT": "+1100", "AEST": "+1000", "ACST": "+0930", "JST": "+0900", "CWST": "+0845", "CT": "+0800", "ICT": "+0700", "MMT": "+0630", "BST": "+0600", "NPT": "+0545", "IST": "+0530", "PKT": "+0500", "AFT": "+0430", "MSK": "+0400", "IRST": "+0330", "FET": "+0300", "EET": "+0200", "CET": "+0100", "GMT": "+0000", "UTC": "+0000", "CVT": "-0100", "GST": "-0200", "BRT": "-0300", "NST": "-0330", "AST": "-0400", "EST": "-0500", "CST": "-0600", "MST": "-0700", "PST": "-0800", "AKST": "-0900", "MIT": "-0930", "HST": "-1000", "SST": "-1100", "BIT": "-1200" }; return __(standard); }, timeZones: function (data) { var zone; data.timezones = []; for (zone in data.abbreviatedTimeZoneStandard) { if (data.abbreviatedTimeZoneStandard.hasOwnProperty(zone)) { data.timezones.push({ name: zone, offset: data.abbreviatedTimeZoneStandard[zone]}); } } for (zone in data.abbreviatedTimeZoneDST) { if (data.abbreviatedTimeZoneDST.hasOwnProperty(zone)) { data.timezones.push({ name: zone, offset: data.abbreviatedTimeZoneDST[zone], dst: true}); } } return data.timezones; }, days: function () { return __(["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"]); }, dayAbbr: function () { return __(["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"]); }, dayShortNames: function () { return __(["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"]); }, dayFirstLetters: function () { return __(["S_Sun_Initial", "M_Mon_Initial", "T_Tues_Initial", "W_Wed_Initial", "T_Thu_Initial", "F_Fri_Initial", "S_Sat_Initial"]); }, months: function () { return __(["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"]); }, monthAbbr: function () { return __(["Jan_Abbr", "Feb_Abbr", "Mar_Abbr", "Apr_Abbr", "May_Abbr", "Jun_Abbr", "Jul_Abbr", "Aug_Abbr", "Sep_Abbr", "Oct_Abbr", "Nov_Abbr", "Dec_Abbr"]); }, formatPatterns: function () { return getText.getFromObjectValues({ shortDate: "M/d/yyyy", longDate: "dddd, MMMM dd, yyyy", shortTime: "h:mm tt", longTime: "h:mm:ss tt", fullDateTime: "dddd, MMMM dd, yyyy h:mm:ss tt", sortableDateTime: "yyyy-MM-ddTHH:mm:ss", universalSortableDateTime: "yyyy-MM-dd HH:mm:ssZ", rfc1123: "ddd, dd MMM yyyy HH:mm:ss", monthDay: "MMMM dd", yearMonth: "MMMM, yyyy" }, Date.i18n.currentLanguage()); }, regex: function () { return getText.getFromObjectValues({ inTheMorning: "/( in the )(morn(ing)?)\\b/", thisMorning: "/(this )(morn(ing)?)\\b/", amThisMorning: "/(\b\\d(am)? )(this )(morn(ing)?)/", inTheEvening: "/( in the )(even(ing)?)\\b/", thisEvening: "/(this )(even(ing)?)\\b/", pmThisEvening: "/(\b\\d(pm)? )(this )(even(ing)?)/", jan: "/jan(uary)?/", feb: "/feb(ruary)?/", mar: "/mar(ch)?/", apr: "/apr(il)?/", may: "/may/", jun: "/jun(e)?/", jul: "/jul(y)?/", aug: "/aug(ust)?/", sep: "/sep(t(ember)?)?/", oct: "/oct(ober)?/", nov: "/nov(ember)?/", dec: "/dec(ember)?/", sun: "/^su(n(day)?)?/", mon: "/^mo(n(day)?)?/", tue: "/^tu(e(s(day)?)?)?/", wed: "/^we(d(nesday)?)?/", thu: "/^th(u(r(s(day)?)?)?)?/", fri: "/fr(i(day)?)?/", sat: "/^sa(t(urday)?)?/", future: "/^next/", past: "/^last|past|prev(ious)?/", add: "/^(\\+|aft(er)?|from|hence)/", subtract: "/^(\\-|bef(ore)?|ago)/", yesterday: "/^yes(terday)?/", today: "/^t(od(ay)?)?/", tomorrow: "/^tom(orrow)?/", now: "/^n(ow)?/", millisecond: "/^ms|milli(second)?s?/", second: "/^sec(ond)?s?/", minute: "/^mn|min(ute)?s?/", hour: "/^h(our)?s?/", week: "/^w(eek)?s?/", month: "/^m(onth)?s?/", day: "/^d(ay)?s?/", year: "/^y(ear)?s?/", shortMeridian: "/^(a|p)/", longMeridian: "/^(a\\.?m?\\.?|p\\.?m?\\.?)/", timezone: "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/", ordinalSuffix: "/^\\s*(st|nd|rd|th)/", timeContext: "/^\\s*(\\:|a(?!u|p)|p)/" }, Date.i18n.currentLanguage()); } }; var CultureInfo = function () { var info = getText.getFromObjectValues({ name: "name", englishName: "englishName", nativeName: "nativeName", amDesignator: "AM", pmDesignator: "PM", firstDayOfWeek: "firstDayOfWeek", twoDigitYearMax: "twoDigitYearMax", dateElementOrder: "mdy" }, Date.i18n.currentLanguage()); var constructedInfo = buildInfo.buildFromMethodHash({ dayNames: "days", abbreviatedDayNames: "dayAbbr", shortestDayNames: "dayShortNames", firstLetterDayNames: "dayFirstLetters", monthNames: "months", abbreviatedMonthNames: "monthAbbr", formatPatterns: "formatPatterns", regexPatterns: "regex", abbreviatedTimeZoneDST: "timeZoneDST", abbreviatedTimeZoneStandard: "timeZoneStandard" }); shallowMerge(info, constructedInfo); buildInfo.timeZones(info); return info; }; $D.i18n = { __: function (key, lang) { return __(key, lang); }, currentLanguage: function () { return lang || "en-US"; }, setLanguage: function (code, force, cb) { var async = false; if (force || code === "en-US" || (!!Date.CultureStrings && !!Date.CultureStrings[code])) { lang = code; Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings.lang = code; Date.CultureInfo = new CultureInfo(); } else { if (!(!!Date.CultureStrings && !!Date.CultureStrings[code])) { if (typeof exports !== "undefined" && this.exports !== exports) { // we're in a Node enviroment, load it using require try { require("../i18n/" + code + ".js"); lang = code; Date.CultureStrings.lang = code; Date.CultureInfo = new CultureInfo(); } catch (e) { // var str = "The language for '" + code + "' could not be loaded by Node. It likely does not exist."; throw new Error("The DateJS IETF language tag '" + code + "' could not be loaded by Node. It likely does not exist."); } } else if (Date.Config && Date.Config.i18n) { // we know the location of the files, so lets load them async = true; loadI18nScript(code).done(function(){ lang = code; Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings.lang = code; Date.CultureInfo = new CultureInfo(); $D.Parsing.Normalizer.buildReplaceData(); // because this is async if ($D.Grammar) { $D.Grammar.buildGrammarFormats(); // so we can parse those strings... } if (cb) { setTimeout(cb,0); } }); } else { Date.console.error("The DateJS IETF language tag '" + code + "' is not available and has not been loaded."); return false; } } } $D.Parsing.Normalizer.buildReplaceData(); // rebuild normalizer strings if ($D.Grammar) { $D.Grammar.buildGrammarFormats(); // so we can parse those strings... } if (!async && cb) { setTimeout(cb,0); } }, getLoggedKeys: function () { return loggedKeys; }, updateCultureInfo: function () { Date.CultureInfo = new CultureInfo(); } }; $D.i18n.updateCultureInfo(); // run automatically }()); (function () { var $D = Date, $P = $D.prototype, p = function (s, l) { if (!l) { l = 2; } return ("000" + s).slice(l * -1); }; if (typeof window !== "undefined" && typeof window.console !== "undefined" && typeof window.console.log !== "undefined") { $D.console = console; // used only to raise non-critical errors if available } else { // set mock so we don't give errors. $D.console = { log: function(){}, error: function(){} }; } $D.Config = $D.Config || {}; $D.initOverloads = function() { /** * Overload of Date.now. Allows an alternate call for Date.now where it returns the * current Date as an object rather than just milliseconds since the Unix Epoch. * * Also provides an implementation of now() for browsers (IE<9) that don't have it. * * Backwards compatible so with work with either: * Date.now() [returns ms] * or * Date.now(true) [returns Date] */ if (!$D.now) { $D._now = function now() { return new Date().getTime(); }; } else if (!$D._now) { $D._now = $D.now; } $D.now = function (returnObj) { if (returnObj) { return $D.present(); } else { return $D._now(); } }; if ( !$P.toISOString ) { $P.toISOString = function() { return this.getUTCFullYear() + "-" + p(this.getUTCMonth() + 1) + "-" + p(this.getUTCDate()) + "T" + p(this.getUTCHours()) + ":" + p(this.getUTCMinutes()) + ":" + p(this.getUTCSeconds()) + "." + String( (this.getUTCMilliseconds()/1000).toFixed(3)).slice(2, 5) + "Z"; }; } // private if ( $P._toString === undefined ){ $P._toString = $P.toString; } }; $D.initOverloads(); /** * Gets a date that is set to the current date. The time is set to the start of the day (00:00 or 12:00 AM). * @return {Date} The current date. */ $D.today = function () { return new Date().clearTime(); }; /** * Gets a date that is set to the current date and time (same as new Date, but chainable) * @return {Date} The current date. */ $D.present = function () { return new Date(); }; /** * Compares the first date to the second date and returns an number indication of their relative values. * @param {Date} First Date object to compare [Required]. * @param {Date} Second Date object to compare to [Required]. * @return {Number} -1 = date1 is lessthan date2. 0 = values are equal. 1 = date1 is greaterthan date2. */ $D.compare = function (date1, date2) { if (isNaN(date1) || isNaN(date2)) { throw new Error(date1 + " - " + date2); } else if (date1 instanceof Date && date2 instanceof Date) { return (date1 < date2) ? -1 : (date1 > date2) ? 1 : 0; } else { throw new TypeError(date1 + " - " + date2); } }; /** * Compares the first Date object to the second Date object and returns true if they are equal. * @param {Date} First Date object to compare [Required] * @param {Date} Second Date object to compare to [Required] * @return {Boolean} true if dates are equal. false if they are not equal. */ $D.equals = function (date1, date2) { return (date1.compareTo(date2) === 0); }; /** * Gets the language appropriate day name when given the day number(0-6) * eg - 0 == Sunday * @return {String} The day name */ $D.getDayName = function (n) { return Date.CultureInfo.dayNames[n]; }; /** * Gets the day number (0-6) if given a CultureInfo specific string which is a valid dayName, abbreviatedDayName or shortestDayName (two char). * @param {String} The name of the day (eg. "Monday, "Mon", "tuesday", "tue", "We", "we"). * @return {Number} The day number */ $D.getDayNumberFromName = function (name) { var n = Date.CultureInfo.dayNames, m = Date.CultureInfo.abbreviatedDayNames, o = Date.CultureInfo.shortestDayNames, s = name.toLowerCase(); for (var i = 0; i < n.length; i++) { if (n[i].toLowerCase() === s || m[i].toLowerCase() === s || o[i].toLowerCase() === s) { return i; } } return -1; }; /** * Gets the month number (0-11) if given a Culture Info specific string which is a valid monthName or abbreviatedMonthName. * @param {String} The name of the month (eg. "February, "Feb", "october", "oct"). * @return {Number} The day number */ $D.getMonthNumberFromName = function (name) { var n = Date.CultureInfo.monthNames, m = Date.CultureInfo.abbreviatedMonthNames, s = name.toLowerCase(); for (var i = 0; i < n.length; i++) { if (n[i].toLowerCase() === s || m[i].toLowerCase() === s) { return i; } } return -1; }; /** * Gets the language appropriate month name when given the month number(0-11) * eg - 0 == January * @return {String} The month name */ $D.getMonthName = function (n) { return Date.CultureInfo.monthNames[n]; }; /** * Determines if the current date instance is within a LeapYear. * @param {Number} The year. * @return {Boolean} true if date is within a LeapYear, otherwise false. */ $D.isLeapYear = function (year) { return ((year % 4 === 0 && year % 100 !== 0) || year % 400 === 0); }; /** * Gets the number of days in the month, given a year and month value. Automatically corrects for LeapYear. * @param {Number} The year. * @param {Number} The month (0-11). * @return {Number} The number of days in the month. */ $D.getDaysInMonth = function (year, month) { if (!month && $D.validateMonth(year)) { month = year; year = Date.today().getFullYear(); } return [31, ($D.isLeapYear(year) ? 29 : 28), 31, 30, 31, 30, 31, 31, 30, 31, 30, 31][month]; }; $P.getDaysInMonth = function () { return $D.getDaysInMonth(this.getFullYear(), this.getMonth()); }; $D.getTimezoneAbbreviation = function (offset, dst) { var p, n = (dst || false) ? Date.CultureInfo.abbreviatedTimeZoneDST : Date.CultureInfo.abbreviatedTimeZoneStandard; for (p in n) { if (n.hasOwnProperty(p)) { if (n[p] === offset) { return p; } } } return null; }; $D.getTimezoneOffset = function (name, dst) { var i, a =[], z = Date.CultureInfo.timezones; if (!name) { name = (new Date()).getTimezone();} for (i = 0; i < z.length; i++) { if (z[i].name === name.toUpperCase()) { a.push(i); } } if (!z[a[0]]) { return null; } if (a.length === 1 || !dst) { return z[a[0]].offset; } else { for (i=0; i < a.length; i++) { if (z[a[i]].dst) { return z[a[i]].offset; } } } }; $D.getQuarter = function (d) { d = d || new Date(); // If no date supplied, use today var q = [1,2,3,4]; return q[Math.floor(d.getMonth() / 3)]; // ~~~ is a bitwise op. Faster than Math.floor }; $D.getDaysLeftInQuarter = function (d) { d = d || new Date(); var qEnd = new Date(d); qEnd.setMonth(qEnd.getMonth() + 3 - qEnd.getMonth() % 3, 0); return Math.floor((qEnd - d) / 8.64e7); }; // private var validate = function (n, min, max, name) { name = name ? name : "Object"; if (typeof n === "undefined") { return false; } else if (typeof n !== "number") { throw new TypeError(n + " is not a Number."); } else if (n < min || n > max) { // As failing validation is *not* an exceptional circumstance // lets not throw a RangeError Exception here. // It's semantically correct but it's not sensible. return false; } return true; }; /** * Validates the number is within an acceptable range for milliseconds [0-999]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateMillisecond = function (value) { return validate(value, 0, 999, "millisecond"); }; /** * Validates the number is within an acceptable range for seconds [0-59]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateSecond = function (value) { return validate(value, 0, 59, "second"); }; /** * Validates the number is within an acceptable range for minutes [0-59]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateMinute = function (value) { return validate(value, 0, 59, "minute"); }; /** * Validates the number is within an acceptable range for hours [0-23]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateHour = function (value) { return validate(value, 0, 23, "hour"); }; /** * Validates the number is within an acceptable range for the days in a month [0-MaxDaysInMonth]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateDay = function (value, year, month) { if (year === undefined || year === null || month === undefined || month === null) { return false;} return validate(value, 1, $D.getDaysInMonth(year, month), "day"); }; /** * Validates the number is within an acceptable range for months [0-11]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateWeek = function (value) { return validate(value, 0, 53, "week"); }; /** * Validates the number is within an acceptable range for months [0-11]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateMonth = function (value) { return validate(value, 0, 11, "month"); }; /** * Validates the number is within an acceptable range for years. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateYear = function (value) { /** * Per ECMAScript spec the range of times supported by Date objects is * exactly -100,000,000 days to +100,000,000 days measured relative to * midnight at the beginning of 01 January, 1970 UTC. * This gives a range of 8,640,000,000,000,000 milliseconds to either * side of 01 January, 1970 UTC. * * Earliest possible date: Tue, 20 Apr 271,822 B.C. 00:00:00 UTC * Latest possible date: Sat, 13 Sep 275,760 00:00:00 UTC */ return validate(value, -271822, 275760, "year"); }; $D.validateTimezone = function(value) { var timezones = {"ACDT":1,"ACST":1,"ACT":1,"ADT":1,"AEDT":1,"AEST":1,"AFT":1,"AKDT":1,"AKST":1,"AMST":1,"AMT":1,"ART":1,"AST":1,"AWDT":1,"AWST":1,"AZOST":1,"AZT":1,"BDT":1,"BIOT":1,"BIT":1,"BOT":1,"BRT":1,"BST":1,"BTT":1,"CAT":1,"CCT":1,"CDT":1,"CEDT":1,"CEST":1,"CET":1,"CHADT":1,"CHAST":1,"CHOT":1,"ChST":1,"CHUT":1,"CIST":1,"CIT":1,"CKT":1,"CLST":1,"CLT":1,"COST":1,"COT":1,"CST":1,"CT":1,"CVT":1,"CWST":1,"CXT":1,"DAVT":1,"DDUT":1,"DFT":1,"EASST":1,"EAST":1,"EAT":1,"ECT":1,"EDT":1,"EEDT":1,"EEST":1,"EET":1,"EGST":1,"EGT":1,"EIT":1,"EST":1,"FET":1,"FJT":1,"FKST":1,"FKT":1,"FNT":1,"GALT":1,"GAMT":1,"GET":1,"GFT":1,"GILT":1,"GIT":1,"GMT":1,"GST":1,"GYT":1,"HADT":1,"HAEC":1,"HAST":1,"HKT":1,"HMT":1,"HOVT":1,"HST":1,"ICT":1,"IDT":1,"IOT":1,"IRDT":1,"IRKT":1,"IRST":1,"IST":1,"JST":1,"KGT":1,"KOST":1,"KRAT":1,"KST":1,"LHST":1,"LINT":1,"MAGT":1,"MART":1,"MAWT":1,"MDT":1,"MET":1,"MEST":1,"MHT":1,"MIST":1,"MIT":1,"MMT":1,"MSK":1,"MST":1,"MUT":1,"MVT":1,"MYT":1,"NCT":1,"NDT":1,"NFT":1,"NPT":1,"NST":1,"NT":1,"NUT":1,"NZDT":1,"NZST":1,"OMST":1,"ORAT":1,"PDT":1,"PET":1,"PETT":1,"PGT":1,"PHOT":1,"PHT":1,"PKT":1,"PMDT":1,"PMST":1,"PONT":1,"PST":1,"PYST":1,"PYT":1,"RET":1,"ROTT":1,"SAKT":1,"SAMT":1,"SAST":1,"SBT":1,"SCT":1,"SGT":1,"SLST":1,"SRT":1,"SST":1,"SYOT":1,"TAHT":1,"THA":1,"TFT":1,"TJT":1,"TKT":1,"TLT":1,"TMT":1,"TOT":1,"TVT":1,"UCT":1,"ULAT":1,"UTC":1,"UYST":1,"UYT":1,"UZT":1,"VET":1,"VLAT":1,"VOLT":1,"VOST":1,"VUT":1,"WAKT":1,"WAST":1,"WAT":1,"WEDT":1,"WEST":1,"WET":1,"WST":1,"YAKT":1,"YEKT":1,"Z":1}; return (timezones[value] === 1); }; $D.validateTimezoneOffset= function(value) { // timezones go from +14hrs to -12hrs, the +X hours are negative offsets. return (value > -841 && value < 721); }; }()); (function () { var $D = Date, $P = $D.prototype, p = function (s, l) { if (!l) { l = 2; } return ("000" + s).slice(l * -1); }; var validateConfigObject = function (obj) { var result = {}, self = this, prop, testFunc; testFunc = function (prop, func, value) { if (prop === "day") { var month = (obj.month !== undefined) ? obj.month : self.getMonth(); var year = (obj.year !== undefined) ? obj.year : self.getFullYear(); return $D[func](value, year, month); } else { return $D[func](value); } }; for (prop in obj) { if (Object.prototype.hasOwnProperty.call(obj, prop)) { var func = "validate" + prop.charAt(0).toUpperCase() + prop.slice(1); if ($D[func] && obj[prop] !== null && testFunc(prop, func, obj[prop])) { result[prop] = obj[prop]; } } } return result; }; /** * Resets the time of this Date object to 12:00 AM (00:00), which is the start of the day. * @param {Boolean} .clone() this date instance before clearing Time * @return {Date} this */ $P.clearTime = function () { this.setHours(0); this.setMinutes(0); this.setSeconds(0); this.setMilliseconds(0); return this; }; /** * Resets the time of this Date object to the current time ('now'). * @return {Date} this */ $P.setTimeToNow = function () { var n = new Date(); this.setHours(n.getHours()); this.setMinutes(n.getMinutes()); this.setSeconds(n.getSeconds()); this.setMilliseconds(n.getMilliseconds()); return this; }; /** * Returns a new Date object that is an exact date and time copy of the original instance. * @return {Date} A new Date instance */ $P.clone = function () { return new Date(this.getTime()); }; /** * Compares this instance to a Date object and returns an number indication of their relative values. * @param {Date} Date object to compare [Required] * @return {Number} -1 = this is lessthan date. 0 = values are equal. 1 = this is greaterthan date. */ $P.compareTo = function (date) { return Date.compare(this, date); }; /** * Compares this instance to another Date object and returns true if they are equal. * @param {Date} Date object to compare. If no date to compare, new Date() [now] is used. * @return {Boolean} true if dates are equal. false if they are not equal. */ $P.equals = function (date) { return Date.equals(this, (date !== undefined ? date : new Date())); }; /** * Determines if this instance is between a range of two dates or equal to either the start or end dates. * @param {Date} Start of range [Required] * @param {Date} End of range [Required] * @return {Boolean} true is this is between or equal to the start and end dates, else false */ $P.between = function (start, end) { return this.getTime() >= start.getTime() && this.getTime() <= end.getTime(); }; /** * Determines if this date occurs after the date to compare to. * @param {Date} Date object to compare. If no date to compare, new Date() ("now") is used. * @return {Boolean} true if this date instance is greater than the date to compare to (or "now"), otherwise false. */ $P.isAfter = function (date) { return this.compareTo(date || new Date()) === 1; }; /** * Determines if this date occurs before the date to compare to. * @param {Date} Date object to compare. If no date to compare, new Date() ("now") is used. * @return {Boolean} true if this date instance is less than the date to compare to (or "now"). */ $P.isBefore = function (date) { return (this.compareTo(date || new Date()) === -1); }; /** * Determines if the current Date instance occurs today. * @return {Boolean} true if this date instance is 'today', otherwise false. */ /** * Determines if the current Date instance occurs on the same Date as the supplied 'date'. * If no 'date' to compare to is provided, the current Date instance is compared to 'today'. * @param {date} Date object to compare. If no date to compare, the current Date ("now") is used. * @return {Boolean} true if this Date instance occurs on the same Day as the supplied 'date'. */ $P.isToday = $P.isSameDay = function (date) { return this.clone().clearTime().equals((date || new Date()).clone().clearTime()); }; /** * Adds the specified number of milliseconds to this instance. * @param {Number} The number of milliseconds to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addMilliseconds = function (value) { if (!value) { return this; } this.setTime(this.getTime() + value * 1); return this; }; /** * Adds the specified number of seconds to this instance. * @param {Number} The number of seconds to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addSeconds = function (value) { if (!value) { return this; } return this.addMilliseconds(value * 1000); }; /** * Adds the specified number of seconds to this instance. * @param {Number} The number of seconds to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addMinutes = function (value) { if (!value) { return this; } return this.addMilliseconds(value * 60000); // 60*1000 }; /** * Adds the specified number of hours to this instance. * @param {Number} The number of hours to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addHours = function (value) { if (!value) { return this; } return this.addMilliseconds(value * 3600000); // 60*60*1000 }; /** * Adds the specified number of days to this instance. * @param {Number} The number of days to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addDays = function (value) { if (!value) { return this; } this.setDate(this.getDate() + value * 1); return this; }; /** * Adds the specified number of weekdays (ie - not sat or sun) to this instance. * @param {Number} The number of days to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addWeekdays = function (value) { if (!value) { return this; } var day = this.getDay(); var weeks = (Math.ceil(Math.abs(value)/7)); if (day === 0 || day === 6) { if (value > 0) { this.next().monday(); this.addDays(-1); day = this.getDay(); } } if (value < 0) { while (value < 0) { this.addDays(-1); day = this.getDay(); if (day !== 0 && day !== 6) { value++; } } return this; } else if (value > 5 || (6-day) <= value) { value = value + (weeks * 2); } return this.addDays(value); }; /** * Adds the specified number of weeks to this instance. * @param {Number} The number of weeks to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addWeeks = function (value) { if (!value) { return this; } return this.addDays(value * 7); }; /** * Adds the specified number of months to this instance. * @param {Number} The number of months to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addMonths = function (value) { if (!value) { return this; } var n = this.getDate(); this.setDate(1); this.setMonth(this.getMonth() + value * 1); this.setDate(Math.min(n, $D.getDaysInMonth(this.getFullYear(), this.getMonth()))); return this; }; $P.addQuarters = function (value) { if (!value) { return this; } // note this will take you to the same point in the quarter as you are now. // i.e. - if you are 15 days into the quarter you'll be 15 days into the resulting one. // bonus: this allows adding fractional quarters return this.addMonths(value * 3); }; /** * Adds the specified number of years to this instance. * @param {Number} The number of years to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addYears = function (value) { if (!value) { return this; } return this.addMonths(value * 12); }; /** * Adds (or subtracts) to the value of the years, months, weeks, days, hours, minutes, seconds, milliseconds of the date instance using given configuration object. Positive and Negative values allowed. * Example

	Date.today().add( { days: 1, months: 1 } )

	new Date().add( { years: -1 } )
	
* @param {Object} Configuration object containing attributes (months, days, etc.) * @return {Date} this */ $P.add = function (config) { if (typeof config === "number") { this._orient = config; return this; } var x = config; if (x.day) { // If we should be a different date than today (eg: for 'tomorrow -1d', etc). // Should only effect parsing, not direct usage (eg, Finish and FinishExact) if ((x.day - this.getDate()) !== 0) { this.setDate(x.day); } } if (x.milliseconds) { this.addMilliseconds(x.milliseconds); } if (x.seconds) { this.addSeconds(x.seconds); } if (x.minutes) { this.addMinutes(x.minutes); } if (x.hours) { this.addHours(x.hours); } if (x.weeks) { this.addWeeks(x.weeks); } if (x.months) { this.addMonths(x.months); } if (x.years) { this.addYears(x.years); } if (x.days) { this.addDays(x.days); } return this; }; /** * Get the week number. Week one (1) is the week which contains the first Thursday of the year. Monday is considered the first day of the week. * The .getWeek() function does NOT convert the date to UTC. The local datetime is used. * Please use .getISOWeek() to get the week of the UTC converted date. * @return {Number} 1 to 53 */ $P.getWeek = function (utc) { // Create a copy of this date object var self, target = new Date(this.valueOf()); if (utc) { target.addMinutes(target.getTimezoneOffset()); self = target.clone(); } else { self = this; } // ISO week date weeks start on monday // so correct the day number var dayNr = (self.getDay() + 6) % 7; // ISO 8601 states that week 1 is the week // with the first thursday of that year. // Set the target date to the thursday in the target week target.setDate(target.getDate() - dayNr + 3); // Store the millisecond value of the target date var firstThursday = target.valueOf(); // Set the target to the first thursday of the year // First set the target to january first target.setMonth(0, 1); // Not a thursday? Correct the date to the next thursday if (target.getDay() !== 4) { target.setMonth(0, 1 + ((4 - target.getDay()) + 7) % 7); } // The weeknumber is the number of weeks between the // first thursday of the year and the thursday in the target week return 1 + Math.ceil((firstThursday - target) / 604800000); // 604800000 = 7 * 24 * 3600 * 1000 }; /** * Get the ISO 8601 week number. Week one ("01") is the week which contains the first Thursday of the year. Monday is considered the first day of the week. * The .getISOWeek() function does convert the date to it's UTC value. Please use .getWeek() to get the week of the local date. * @return {String} "01" to "53" */ $P.getISOWeek = function () { return p(this.getWeek(true)); }; /** * Moves the date to Monday of the week set. Week one (1) is the week which contains the first Thursday of the year. * @param {Number} A Number (1 to 53) that represents the week of the year. * @return {Date} this */ $P.setWeek = function (n) { if ((n - this.getWeek()) === 0) { if (this.getDay() !== 1) { return this.moveToDayOfWeek(1, (this.getDay() > 1 ? -1 : 1)); } else { return this; } } else { return this.moveToDayOfWeek(1, (this.getDay() > 1 ? -1 : 1)).addWeeks(n - this.getWeek()); } }; $P.setQuarter = function (qtr) { var month = Math.abs(((qtr-1) * 3) + 1); return this.setMonth(month, 1); }; $P.getQuarter = function () { return Date.getQuarter(this); }; $P.getDaysLeftInQuarter = function () { return Date.getDaysLeftInQuarter(this); }; /** * Moves the date to the next n'th occurrence of the dayOfWeek starting from the beginning of the month. The number (-1) is a magic number and will return the last occurrence of the dayOfWeek in the month. * @param {Number} The dayOfWeek to move to * @param {Number} The n'th occurrence to move to. Use (-1) to return the last occurrence in the month * @return {Date} this */ $P.moveToNthOccurrence = function (dayOfWeek, occurrence) { if (dayOfWeek === "Weekday") { if (occurrence > 0) { this.moveToFirstDayOfMonth(); if (this.is().weekday()) { occurrence -= 1; } } else if (occurrence < 0) { this.moveToLastDayOfMonth(); if (this.is().weekday()) { occurrence += 1; } } else { return this; } return this.addWeekdays(occurrence); } var shift = 0; if (occurrence > 0) { shift = occurrence - 1; } else if (occurrence === -1) { this.moveToLastDayOfMonth(); if (this.getDay() !== dayOfWeek) { this.moveToDayOfWeek(dayOfWeek, -1); } return this; } return this.moveToFirstDayOfMonth().addDays(-1).moveToDayOfWeek(dayOfWeek, +1).addWeeks(shift); }; var moveToN = function (getFunc, addFunc, nVal) { return function (value, orient) { var diff = (value - this[getFunc]() + nVal * (orient || +1)) % nVal; return this[addFunc]((diff === 0) ? diff += nVal * (orient || +1) : diff); }; }; /** * Move to the next or last dayOfWeek based on the orient value. * @param {Number} The dayOfWeek to move to * @param {Number} Forward (+1) or Back (-1). Defaults to +1. [Optional] * @return {Date} this */ $P.moveToDayOfWeek = moveToN("getDay", "addDays", 7); /** * Move to the next or last month based on the orient value. * @param {Number} The month to move to. 0 = January, 11 = December * @param {Number} Forward (+1) or Back (-1). Defaults to +1. [Optional] * @return {Date} this */ $P.moveToMonth = moveToN("getMonth", "addMonths", 12); /** * Get the Ordinate of the current day ("th", "st", "rd"). * @return {String} */ $P.getOrdinate = function () { var num = this.getDate(); return ord(num); }; /** * Get the Ordinal day (numeric day number) of the year, adjusted for leap year. * @return {Number} 1 through 365 (366 in leap years) */ $P.getOrdinalNumber = function () { return Math.ceil((this.clone().clearTime() - new Date(this.getFullYear(), 0, 1)) / 86400000) + 1; }; /** * Get the time zone abbreviation of the current date. * @return {String} The abbreviated time zone name (e.g. "EST") */ $P.getTimezone = function () { return $D.getTimezoneAbbreviation(this.getUTCOffset(), this.isDaylightSavingTime()); }; $P.setTimezoneOffset = function (offset) { var here = this.getTimezoneOffset(), there = Number(offset) * -6 / 10; return (there || there === 0) ? this.addMinutes(there - here) : this; }; $P.setTimezone = function (offset) { return this.setTimezoneOffset($D.getTimezoneOffset(offset)); }; /** * Indicates whether Daylight Saving Time is observed in the current time zone. * @return {Boolean} true|false */ $P.hasDaylightSavingTime = function () { return (Date.today().set({month: 0, day: 1}).getTimezoneOffset() !== Date.today().set({month: 6, day: 1}).getTimezoneOffset()); }; /** * Indicates whether this Date instance is within the Daylight Saving Time range for the current time zone. * @return {Boolean} true|false */ $P.isDaylightSavingTime = function () { return Date.today().set({month: 0, day: 1}).getTimezoneOffset() !== this.getTimezoneOffset(); }; /** * Get the offset from UTC of the current date. * @return {String} The 4-character offset string prefixed with + or - (e.g. "-0500") */ $P.getUTCOffset = function (offset) { var n = (offset || this.getTimezoneOffset()) * -10 / 6, r; if (n < 0) { r = (n - 10000).toString(); return r.charAt(0) + r.substr(2); } else { r = (n + 10000).toString(); return "+" + r.substr(1); } }; /** * Returns the number of milliseconds between this date and date. * @param {Date} Defaults to now * @return {Number} The diff in milliseconds */ $P.getElapsed = function (date) { return (date || new Date()) - this; }; /** * Set the value of year, month, day, hour, minute, second, millisecond of date instance using given configuration object. * Example

	Date.today().set( { day: 20, month: 1 } )

	new Date().set( { millisecond: 0 } )
	
* * @param {Object} Configuration object containing attributes (month, day, etc.) * @return {Date} this */ $P.set = function (config) { config = validateConfigObject.call(this, config); var key; for (key in config) { if (Object.prototype.hasOwnProperty.call(config, key)) { var name = key.charAt(0).toUpperCase() + key.slice(1); var addFunc, getFunc; if (key !== "week" && key !== "month" && key !== "timezone" && key !== "timezoneOffset") { name += "s"; } addFunc = "add" + name; getFunc = "get" + name; if (key === "month") { addFunc = addFunc + "s"; } else if (key === "year"){ getFunc = "getFullYear"; } if (key !== "day" && key !== "timezone" && key !== "timezoneOffset" && key !== "week" && key !== "hour") { this[addFunc](config[key] - this[getFunc]()); } else if ( key === "timezone"|| key === "timezoneOffset" || key === "week" || key === "hour") { this["set"+name](config[key]); } } } // day has to go last because you can't validate the day without first knowing the month if (config.day) { this.addDays(config.day - this.getDate()); } return this; }; /** * Moves the date to the first day of the month. * @return {Date} this */ $P.moveToFirstDayOfMonth = function () { return this.set({ day: 1 }); }; /** * Moves the date to the last day of the month. * @return {Date} this */ $P.moveToLastDayOfMonth = function () { return this.set({ day: $D.getDaysInMonth(this.getFullYear(), this.getMonth())}); }; /** * Converts the value of the current Date object to its equivalent string representation. * Format Specifiers * CUSTOM DATE AND TIME FORMAT STRINGS * Format Description Example * ------ --------------------------------------------------------------------------- ----------------------- * s The seconds of the minute between 0-59. "0" to "59" * ss The seconds of the minute with leading zero if required. "00" to "59" * * m The minute of the hour between 0-59. "0" or "59" * mm The minute of the hour with leading zero if required. "00" or "59" * * h The hour of the day between 1-12. "1" to "12" * hh The hour of the day with leading zero if required. "01" to "12" * * H The hour of the day between 0-23. "0" to "23" * HH The hour of the day with leading zero if required. "00" to "23" * * d The day of the month between 1 and 31. "1" to "31" * dd The day of the month with leading zero if required. "01" to "31" * ddd Abbreviated day name. Date.CultureInfo.abbreviatedDayNames. "Mon" to "Sun" * dddd The full day name. Date.CultureInfo.dayNames. "Monday" to "Sunday" * * M The month of the year between 1-12. "1" to "12" * MM The month of the year with leading zero if required. "01" to "12" * MMM Abbreviated month name. Date.CultureInfo.abbreviatedMonthNames. "Jan" to "Dec" * MMMM The full month name. Date.CultureInfo.monthNames. "January" to "December" * * yy The year as a two-digit number. "99" or "08" * yyyy The full four digit year. "1999" or "2008" * * t Displays the first character of the A.M./P.M. designator. "A" or "P" * Date.CultureInfo.amDesignator or Date.CultureInfo.pmDesignator * tt Displays the A.M./P.M. designator. "AM" or "PM" * Date.CultureInfo.amDesignator or Date.CultureInfo.pmDesignator * * S The ordinal suffix ("st, "nd", "rd" or "th") of the current day. "st, "nd", "rd" or "th" * * STANDARD DATE AND TIME FORMAT STRINGS * Format Description Example *------ --------------------------------------------------------------------------- ----------------------- * d The CultureInfo shortDate Format Pattern "M/d/yyyy" * D The CultureInfo longDate Format Pattern "dddd, MMMM dd, yyyy" * F The CultureInfo fullDateTime Format Pattern "dddd, MMMM dd, yyyy h:mm:ss tt" * m The CultureInfo monthDay Format Pattern "MMMM dd" * r The CultureInfo rfc1123 Format Pattern "ddd, dd MMM yyyy HH:mm:ss GMT" * s The CultureInfo sortableDateTime Format Pattern "yyyy-MM-ddTHH:mm:ss" * t The CultureInfo shortTime Format Pattern "h:mm tt" * T The CultureInfo longTime Format Pattern "h:mm:ss tt" * u The CultureInfo universalSortableDateTime Format Pattern "yyyy-MM-dd HH:mm:ssZ" * y The CultureInfo yearMonth Format Pattern "MMMM, yyyy" * * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @return {String} A string representation of the current Date object. */ var ord = function (n) { switch (n * 1) { case 1: case 21: case 31: return "st"; case 2: case 22: return "nd"; case 3: case 23: return "rd"; default: return "th"; } }; var parseStandardFormats = function (format) { var y, c = Date.CultureInfo.formatPatterns; switch (format) { case "d": return this.toString(c.shortDate); case "D": return this.toString(c.longDate); case "F": return this.toString(c.fullDateTime); case "m": return this.toString(c.monthDay); case "r": case "R": y = this.clone().addMinutes(this.getTimezoneOffset()); return y.toString(c.rfc1123) + " GMT"; case "s": return this.toString(c.sortableDateTime); case "t": return this.toString(c.shortTime); case "T": return this.toString(c.longTime); case "u": y = this.clone().addMinutes(this.getTimezoneOffset()); return y.toString(c.universalSortableDateTime); case "y": return this.toString(c.yearMonth); default: return false; } }; var parseFormatStringsClosure = function (context) { return function (m) { if (m.charAt(0) === "\\") { return m.replace("\\", ""); } switch (m) { case "hh": return p(context.getHours() < 13 ? (context.getHours() === 0 ? 12 : context.getHours()) : (context.getHours() - 12)); case "h": return context.getHours() < 13 ? (context.getHours() === 0 ? 12 : context.getHours()) : (context.getHours() - 12); case "HH": return p(context.getHours()); case "H": return context.getHours(); case "mm": return p(context.getMinutes()); case "m": return context.getMinutes(); case "ss": return p(context.getSeconds()); case "s": return context.getSeconds(); case "yyyy": return p(context.getFullYear(), 4); case "yy": return p(context.getFullYear()); case "y": return context.getFullYear(); case "E": case "dddd": return Date.CultureInfo.dayNames[context.getDay()]; case "ddd": return Date.CultureInfo.abbreviatedDayNames[context.getDay()]; case "dd": return p(context.getDate()); case "d": return context.getDate(); case "MMMM": return Date.CultureInfo.monthNames[context.getMonth()]; case "MMM": return Date.CultureInfo.abbreviatedMonthNames[context.getMonth()]; case "MM": return p((context.getMonth() + 1)); case "M": return context.getMonth() + 1; case "t": return context.getHours() < 12 ? Date.CultureInfo.amDesignator.substring(0, 1) : Date.CultureInfo.pmDesignator.substring(0, 1); case "tt": return context.getHours() < 12 ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator; case "S": return ord(context.getDate()); case "W": return context.getWeek(); case "WW": return context.getISOWeek(); case "Q": return "Q" + context.getQuarter(); case "q": return String(context.getQuarter()); case "z": return context.getTimezone(); case "Z": case "X": return Date.getTimezoneOffset(context.getTimezone()); case "ZZ": // Timezone offset in seconds return context.getTimezoneOffset() * -60; case "u": return context.getDay(); case "L": return ($D.isLeapYear(context.getFullYear())) ? 1 : 0; case "B": // Swatch Internet Time (.beats) return "@"+((context.getUTCSeconds() + (context.getUTCMinutes()*60) + ((context.getUTCHours()+1)*3600))/86.4); default: return m; } }; }; $P.toString = function (format, ignoreStandards) { // Standard Date and Time Format Strings. Formats pulled from CultureInfo file and // may vary by culture. if (!ignoreStandards && format && format.length === 1) { output = parseStandardFormats.call(this, format); if (output) { return output; } } var parseFormatStrings = parseFormatStringsClosure(this); return format ? format.replace(/((\\)?(dd?d?d?|MM?M?M?|yy?y?y?|hh?|HH?|mm?|ss?|tt?|S|q|Q|WW?W?W?)(?![^\[]*\]))/g, parseFormatStrings).replace(/\[|\]/g, "") : this._toString(); }; }()); /************************************************************* * SugarPak - Domain Specific Language - Syntactical Sugar * *************************************************************/ (function () { var $D = Date, $P = $D.prototype, $N = Number.prototype; // private $P._orient = +1; // private $P._nth = null; // private $P._is = false; // private $P._same = false; // private $P._isSecond = false; // private $N._dateElement = "days"; /** * Moves the date to the next instance of a date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.today().next().friday();
	Date.today().next().fri();
	Date.today().next().march();
	Date.today().next().mar();
	Date.today().next().week();
	
* * @return {Date} date */ $P.next = function () { this._move = true; this._orient = +1; return this; }; /** * Creates a new Date (Date.today()) and moves the date to the next instance of the date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.next().friday();
	Date.next().fri();
	Date.next().march();
	Date.next().mar();
	Date.next().week();
	
* * @return {Date} date */ $D.next = function () { return $D.today().next(); }; /** * Moves the date to the previous instance of a date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.today().last().friday();
	Date.today().last().fri();
	Date.today().last().march();
	Date.today().last().mar();
	Date.today().last().week();
	
* * @return {Date} date */ $P.last = $P.prev = $P.previous = function () { this._move = true; this._orient = -1; return this; }; /** * Creates a new Date (Date.today()) and moves the date to the previous instance of the date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.last().friday();
	Date.last().fri();
	Date.previous().march();
	Date.prev().mar();
	Date.last().week();
	
* * @return {Date} date */ $D.last = $D.prev = $D.previous = function () { return $D.today().last(); }; /** * Performs a equality check when followed by either a month name, day name or .weekday() function. * Example

	Date.today().is().friday(); // true|false
	Date.today().is().fri();
	Date.today().is().march();
	Date.today().is().mar();
	
* * @return {Boolean} true|false */ $P.is = function () { this._is = true; return this; }; /** * Determines if two date objects occur on/in exactly the same instance of the subsequent date part function. * The function .same() must be followed by a date part function (example: .day(), .month(), .year(), etc). * * An optional Date can be passed in the date part function. If now date is passed as a parameter, 'Now' is used. * * The following example demonstrates how to determine if two dates fall on the exact same day. * * Example

	var d1 = Date.today(); // today at 00:00
	var d2 = new Date();   // exactly now.

	// Do they occur on the same day?
	d1.same().day(d2); // true
	
	// Do they occur on the same hour?
	d1.same().hour(d2); // false, unless d2 hour is '00' (midnight).
	
	// What if it's the same day, but one year apart?
	var nextYear = Date.today().add(1).year();

	d1.same().day(nextYear); // false, because the dates must occur on the exact same day. 
	
* * Scenario: Determine if a given date occurs during some week period 2 months from now. * * Example

	var future = Date.today().add(2).months();
	return someDate.same().week(future); // true|false;
	
* * @return {Boolean} true|false */ $P.same = function () { this._same = true; this._isSecond = false; return this; }; /** * Determines if the current date/time occurs during Today. Must be preceded by the .is() function. * Example

	someDate.is().today();    // true|false
	new Date().is().today();  // true
	Date.today().is().today();// true
	Date.today().add(-1).day().is().today(); // false
	
* * @return {Boolean} true|false */ $P.today = function () { return this.same().day(); }; /** * Determines if the current date is a weekday. This function must be preceded by the .is() function. * Example

	Date.today().is().weekday(); // true|false
	
* * @return {Boolean} true|false */ $P.weekday = function () { if (this._nth) { return df("Weekday").call(this); } if (this._move) { return this.addWeekdays(this._orient); } if (this._is) { this._is = false; return (!this.is().sat() && !this.is().sun()); } return false; }; /** * Determines if the current date is on the weekend. This function must be preceded by the .is() function. * Example

	Date.today().is().weekend(); // true|false
	
* * @return {Boolean} true|false */ $P.weekend = function () { if (this._is) { this._is = false; return (this.is().sat() || this.is().sun()); } return false; }; /** * Sets the Time of the current Date instance. A string "6:15 pm" or config object {hour:18, minute:15} are accepted. * Example

	// Set time to 6:15pm with a String
	Date.today().at("6:15pm");

	// Set time to 6:15pm with a config object
	Date.today().at({hour:18, minute:15});
	
* * @return {Date} date */ $P.at = function (time) { return (typeof time === "string") ? $D.parse(this.toString("d") + " " + time) : this.set(time); }; /** * Creates a new Date() and adds this (Number) to the date based on the preceding date element function (eg. second|minute|hour|day|month|year). * Example

	// Undeclared Numbers must be wrapped with parentheses. Requirment of JavaScript.
	(3).days().fromNow();
	(6).months().fromNow();

	// Declared Number variables do not require parentheses. 
	var n = 6;
	n.months().fromNow();
	
* * @return {Date} A new Date instance */ $N.fromNow = $N.after = function (date) { var c = {}; c[this._dateElement] = this; return ((!date) ? new Date() : date.clone()).add(c); }; /** * Creates a new Date() and subtract this (Number) from the date based on the preceding date element function (eg. second|minute|hour|day|month|year). * Example

	// Undeclared Numbers must be wrapped with parentheses. Requirment of JavaScript.
	(3).days().ago();
	(6).months().ago();

	// Declared Number variables do not require parentheses. 
	var n = 6;
	n.months().ago();
	
* * @return {Date} A new Date instance */ $N.ago = $N.before = function (date) { var c = {}, s = (this._dateElement[this._dateElement.length-1] !== "s") ? this._dateElement + "s" : this._dateElement; c[s] = this * -1; return ((!date) ? new Date() : date.clone()).add(c); }; // Do NOT modify the following string tokens. These tokens are used to build dynamic functions. // All culture-specific strings can be found in the CultureInfo files. var dx = ("sunday monday tuesday wednesday thursday friday saturday").split(/\s/), mx = ("january february march april may june july august september october november december").split(/\s/), px = ("Millisecond Second Minute Hour Day Week Month Year Quarter Weekday").split(/\s/), pxf = ("Milliseconds Seconds Minutes Hours Date Week Month FullYear Quarter").split(/\s/), nth = ("final first second third fourth fifth").split(/\s/), de; /** * Returns an object literal of all the date parts. * Example

	var o = new Date().toObject();
	
	// { year: 2008, month: 4, week: 20, day: 13, hour: 18, minute: 9, second: 32, millisecond: 812 }
	
	// The object properties can be referenced directly from the object.
	
	alert(o.day);  // alerts "13"
	alert(o.year); // alerts "2008"
	
* * @return {Date} An object literal representing the original date object. */ $P.toObject = function () { var o = {}; for (var i = 0; i < px.length; i++) { if (this["get" + pxf[i]]) { o[px[i].toLowerCase()] = this["get" + pxf[i]](); } } return o; }; /** * Returns a date created from an object literal. Ignores the .week property if set in the config. * Example

	var o = new Date().toObject();
	
	return Date.fromObject(o); // will return the same date. 

	var o2 = {month: 1, day: 20, hour: 18}; // birthday party!
	Date.fromObject(o2);
	
* * @return {Date} An object literal representing the original date object. */ $D.fromObject = function(config) { config.week = null; return Date.today().set(config); }; // Create day name functions and abbreviated day name functions (eg. monday(), friday(), fri()). var df = function (n) { return function () { if (this._is) { this._is = false; return this.getDay() === n; } if (this._move) { this._move = null; } if (this._nth !== null) { // If the .second() function was called earlier, remove the _orient // from the date, and then continue. // This is required because 'second' can be used in two different context. // // Example // // Date.today().add(1).second(); // Date.march().second().monday(); // // Things get crazy with the following... // Date.march().add(1).second().second().monday(); // but it works!! // if (this._isSecond) { this.addSeconds(this._orient * -1); } // make sure we reset _isSecond this._isSecond = false; var ntemp = this._nth; this._nth = null; var temp = this.clone().moveToLastDayOfMonth(); this.moveToNthOccurrence(n, ntemp); if (this > temp) { throw new RangeError($D.getDayName(n) + " does not occur " + ntemp + " times in the month of " + $D.getMonthName(temp.getMonth()) + " " + temp.getFullYear() + "."); } return this; } return this.moveToDayOfWeek(n, this._orient); }; }; var sdf = function (n) { return function () { var t = $D.today(), shift = n - t.getDay(); if (n === 0 && Date.CultureInfo.firstDayOfWeek === 1 && t.getDay() !== 0) { shift = shift + 7; } return t.addDays(shift); }; }; // Create month name functions and abbreviated month name functions (eg. january(), march(), mar()). var month_instance_functions = function (n) { return function () { if (this._is) { this._is = false; return this.getMonth() === n; } return this.moveToMonth(n, this._orient); }; }; var month_static_functions = function (n) { return function () { return $D.today().set({ month: n, day: 1 }); }; }; var processTerms = function (names, staticFunc, instanceFunc) { for (var i = 0; i < names.length; i++) { // Create constant static Name variables. $D[names[i].toUpperCase()] = $D[names[i].toUpperCase().substring(0, 3)] = i; // Create Name functions. $D[names[i]] = $D[names[i].substring(0, 3)] = staticFunc(i); // Create Name instance functions. $P[names[i]] = $P[names[i].substring(0, 3)] = instanceFunc(i); } }; processTerms(dx, sdf, df); processTerms(mx, month_static_functions, month_instance_functions); // Create date element functions and plural date element functions used with Date (eg. day(), days(), months()). var ef = function (j) { return function () { // if the .second() function was called earlier, the _orient // has alread been added. Just return this and reset _isSecond. if (this._isSecond) { this._isSecond = false; return this; } if (this._same) { this._same = this._is = false; var o1 = this.toObject(), o2 = (arguments[0] || new Date()).toObject(), v = "", k = j.toLowerCase(); // the substr trick with -1 doesn't work in IE8 or less k = (k[k.length-1] === "s") ? k.substring(0,k.length-1) : k; for (var m = (px.length - 1); m > -1; m--) { v = px[m].toLowerCase(); if (o1[v] !== o2[v]) { return false; } if (k === v) { break; } } return true; } if (j.substring(j.length - 1) !== "s") { j += "s"; } if (this._move) { this._move = null; } return this["add" + j](this._orient); }; }; var nf = function (n) { return function () { this._dateElement = n; return this; }; }; for (var k = 0; k < px.length; k++) { de = px[k].toLowerCase(); if(de !== "weekday") { // Create date element functions and plural date element functions used with Date (eg. day(), days(), months()). $P[de] = $P[de + "s"] = ef(px[k]); // Create date element functions and plural date element functions used with Number (eg. day(), days(), months()). $N[de] = $N[de + "s"] = nf(de + "s"); } } $P._ss = ef("Second"); var nthfn = function (n) { return function (dayOfWeek) { if (this._same) { return this._ss(arguments[0]); } if (dayOfWeek || dayOfWeek === 0) { return this.moveToNthOccurrence(dayOfWeek, n); } this._nth = n; // if the operator is 'second' add the _orient, then deal with it later... if (n === 2 && (dayOfWeek === undefined || dayOfWeek === null)) { this._isSecond = true; return this.addSeconds(this._orient); } return this; }; }; for (var l = 0; l < nth.length; l++) { $P[nth[l]] = (l === 0) ? nthfn(-1) : nthfn(l); } }()); (function () { "use strict"; Date.Parsing = { Exception: function (s) { this.message = "Parse error at '" + s.substring(0, 10) + " ...'"; } }; var $P = Date.Parsing; var dayOffsets = { standard: [0,31,59,90,120,151,181,212,243,273,304,334], leap: [0,31,60,91,121,152,182,213,244,274,305,335] }; $P.isLeapYear = function(year) { return ((year % 4 === 0) && (year % 100 !== 0)) || (year % 400 === 0); }; var utils = { multiReplace : function (str, hash ) { var key; for (key in hash) { if (Object.prototype.hasOwnProperty.call(hash, key)) { var regex; if (typeof hash[key] === "function") { } else { regex = (hash[key] instanceof RegExp) ? hash[key] : new RegExp(hash[key], "g"); } str = str.replace(regex, key); } } return str; }, getDayOfYearFromWeek : function (obj) { var d, jan4, offset; obj.weekDay = (!obj.weekDay && obj.weekDay !== 0) ? 1 : obj.weekDay; d = new Date(obj.year, 0, 4); jan4 = d.getDay() === 0 ? 7 : d.getDay(); // JS is 0 indexed on Sunday. offset = jan4+3; obj.dayOfYear = ((obj.week * 7) + (obj.weekDay === 0 ? 7 : obj.weekDay))-offset; return obj; }, getDayOfYear : function (obj, dayOffset) { if (!obj.dayOfYear) { obj = utils.getDayOfYearFromWeek(obj); } for (var i=0;i <= dayOffset.length;i++) { if (obj.dayOfYear < dayOffset[i] || i === dayOffset.length) { obj.day = obj.day ? obj.day : (obj.dayOfYear - dayOffset[i-1]); break; } else { obj.month = i; } } return obj; }, adjustForTimeZone : function (obj, date) { var offset; if (obj.zone.toUpperCase() === "Z" || (obj.zone_hours === 0 && obj.zone_minutes === 0)) { // it's UTC/GML so work out the current timeszone offset offset = -date.getTimezoneOffset(); } else { offset = (obj.zone_hours*60) + (obj.zone_minutes || 0); if (obj.zone_sign === "+") { offset *= -1; } offset -= date.getTimezoneOffset(); } date.setMinutes(date.getMinutes()+offset); return date; }, setDefaults : function (obj) { obj.year = obj.year || Date.today().getFullYear(); obj.hours = obj.hours || 0; obj.minutes = obj.minutes || 0; obj.seconds = obj.seconds || 0; obj.milliseconds = obj.milliseconds || 0; if (!(!obj.month && (obj.week || obj.dayOfYear))) { // if we have a month, or if we don't but don't have the day calculation data obj.month = obj.month || 0; obj.day = obj.day || 1; } return obj; }, dataNum: function (data, mod, explict, postProcess) { var dataNum = data*1; if (mod) { if (postProcess) { return data ? mod(data)*1 : data; } else { return data ? mod(dataNum) : data; } } else if (!explict){ return data ? dataNum : data; } else { return (data && typeof data !== "undefined") ? dataNum : data; } }, timeDataProcess: function (obj) { var timeObj = {}; for (var x in obj.data) { if (obj.data.hasOwnProperty(x)) { timeObj[x] = obj.ignore[x] ? obj.data[x] : utils.dataNum(obj.data[x], obj.mods[x], obj.explict[x], obj.postProcess[x]); } } if (obj.data.secmins) { obj.data.secmins = obj.data.secmins.replace(",", ".") * 60; if (!timeObj.minutes) { timeObj.minutes = obj.data.secmins; } else if (!timeObj.seconds) { timeObj.seconds = obj.data.secmins; } delete obj.secmins; } return timeObj; }, buildTimeObjectFromData: function (data) { var time = utils.timeDataProcess({ data: { year : data[1], month : data[5], day : data[7], week : data[8], dayOfYear : data[10], hours : data[15], zone_hours : data[23], zone_minutes : data[24], zone : data[21], zone_sign : data[22], weekDay : data[9], minutes: data[16], seconds: data[19], milliseconds: data[20], secmins: data[18] }, mods: { month: function(data) { return data-1; }, weekDay: function (data) { data = Math.abs(data); return (data === 7 ? 0 : data); }, minutes: function (data) { return data.replace(":",""); }, seconds: function (data) { return Math.floor( (data.replace(":","").replace(",","."))*1 ); }, milliseconds: function (data) { return (data.replace(",",".")*1000); } }, postProcess: { minutes: true, seconds: true, milliseconds: true }, explict: { zone_hours: true, zone_minutes: true }, ignore: { zone: true, zone_sign: true, secmins: true } }); return time; }, addToHash: function (hash, keys, data) { keys = keys; data = data; var len = keys.length; for (var i = 0; i < len; i++) { hash[keys[i]] = data[i]; } return hash; }, combineRegex: function (r1, r2) { return new RegExp("(("+r1.source+")\\s("+r2.source+"))"); }, getDateNthString: function(add, last, inc){ if (add) { return Date.today().addDays(inc).toString("d"); } else if (last) { return Date.today().last()[inc]().toString("d"); } }, buildRegexData: function (array) { var arr = []; var len = array.length; for (var i=0; i < len; i++) { if (Object.prototype.toString.call(array[i]) === '[object Array]') { // oldIE compat version of Array.isArray arr.push(this.combineRegex(array[i][0], array[i][1])); } else { arr.push(array[i]); } } return arr; } }; $P.processTimeObject = function (obj) { var date, dayOffset; utils.setDefaults(obj); dayOffset = ($P.isLeapYear(obj.year)) ? dayOffsets.leap : dayOffsets.standard; if (!obj.month && (obj.week || obj.dayOfYear)) { utils.getDayOfYear(obj, dayOffset); } else { obj.dayOfYear = dayOffset[obj.month] + obj.day; } date = new Date(obj.year, obj.month, obj.day, obj.hours, obj.minutes, obj.seconds, obj.milliseconds); if (obj.zone) { utils.adjustForTimeZone(obj, date); // adjust (and calculate) for timezone } return date; }; $P.ISO = { regex : /^([\+-]?\d{4}(?!\d{2}\b))((-?)((0[1-9]|1[0-2])(\3([12]\d|0[1-9]|3[01]))?|W([0-4]\d|5[0-3])(-?[1-7])?|(00[1-9]|0[1-9]\d|[12]\d{2}|3([0-5]\d|6[1-6])))([T\s]((([01]\d|2[0-4])((:?)[0-5]\d)?|24\:?00)([\.,]\d+(?!:))?)?(\17[0-5]\d([\.,]\d+)?)?\s?([zZ]|([\+-])([01]\d|2[0-3]):?([0-5]\d)?)?)?)?$/, parse : function (s) { var time, data = s.match(this.regex); if (!data || !data.length) { return null; } time = utils.buildTimeObjectFromData(data); if (!time.year || (!time.year && (!time.month && !time.day) && (!time.week && !time.dayOfYear)) ) { return null; } return $P.processTimeObject(time); } }; $P.Numeric = { isNumeric: function (e){return!isNaN(parseFloat(e))&&isFinite(e);}, regex: /\b([0-1]?[0-9])([0-3]?[0-9])([0-2]?[0-9]?[0-9][0-9])\b/i, parse: function (s) { var data, i, time = {}, order = Date.CultureInfo.dateElementOrder.split(""); if (!(this.isNumeric(s)) || // if it's non-numeric OR (s[0] === "+" && s[0] === "-")) { // It's an arithmatic string (eg +/-1000) return null; } if (s.length < 5 && s.indexOf(".") < 0 && s.indexOf("/") < 0) { // assume it's just a year. time.year = s; return $P.processTimeObject(time); } data = s.match(this.regex); if (!data || !data.length) { return null; } for (i=0; i < order.length; i++) { switch(order[i]) { case "d": time.day = data[i+1]; break; case "m": time.month = (data[i+1]-1); break; case "y": time.year = data[i+1]; break; } } return $P.processTimeObject(time); } }; $P.Normalizer = { regexData: function () { var $R = Date.CultureInfo.regexPatterns; return utils.buildRegexData([ $R.tomorrow, $R.yesterday, [$R.past, $R.mon], [$R.past, $R.tue], [$R.past, $R.wed], [$R.past, $R.thu], [$R.past, $R.fri], [$R.past, $R.sat], [$R.past, $R.sun] ]); }, basicReplaceHash : function() { var $R = Date.CultureInfo.regexPatterns; return { "January": $R.jan.source, "February": $R.feb, "March": $R.mar, "April": $R.apr, "May": $R.may, "June": $R.jun, "July": $R.jul, "August": $R.aug, "September": $R.sep, "October": $R.oct, "November": $R.nov, "December": $R.dec, "": /\bat\b/gi, " ": /\s{2,}/, "am": $R.inTheMorning, "9am": $R.thisMorning, "pm": $R.inTheEvening, "7pm":$R.thisEvening }; }, keys : function(){ return [ utils.getDateNthString(true, false, 1), // tomorrow utils.getDateNthString(true, false, -1), // yesterday utils.getDateNthString(false, true, "monday"), //last mon utils.getDateNthString(false, true, "tuesday"), //last tues utils.getDateNthString(false, true, "wednesday"), //last wed utils.getDateNthString(false, true, "thursday"), //last thurs utils.getDateNthString(false, true, "friday"), //last fri utils.getDateNthString(false, true, "saturday"), //last sat utils.getDateNthString(false, true, "sunday") //last sun ]; }, buildRegexFunctions: function () { var $R = Date.CultureInfo.regexPatterns; var __ = Date.i18n.__; var tomorrowRE = new RegExp("(\\b\\d\\d?("+__("AM")+"|"+__("PM")+")? )("+$R.tomorrow.source.slice(1)+")", "i"); // adapted tomorrow regex for AM PM relative dates var todayRE = new RegExp($R.today.source + "(?!\\s*([+-]))\\b"); // today, but excludes the math operators (eg "today + 2h") this.replaceFuncs = [ [todayRE, function (full) { return (full.length > 1) ? Date.today().toString("d") : full; }], [tomorrowRE, function(full, m1) { var t = Date.today().addDays(1).toString("d"); return (t + " " + m1); }], [$R.amThisMorning, function(str, am){return am;}], [$R.pmThisEvening, function(str, pm){return pm;}] ]; }, buildReplaceData: function () { this.buildRegexFunctions(); this.replaceHash = utils.addToHash(this.basicReplaceHash(), this.keys(), this.regexData()); }, stringReplaceFuncs: function (s) { for (var i=0; i < this.replaceFuncs.length; i++) { s = s.replace(this.replaceFuncs[i][0], this.replaceFuncs[i][1]); } return s; }, parse: function (s) { s = this.stringReplaceFuncs(s); s = utils.multiReplace(s, this.replaceHash); try { var n = s.split(/([\s\-\.\,\/\x27]+)/); if (n.length === 3 && $P.Numeric.isNumeric(n[0]) && $P.Numeric.isNumeric(n[2]) && (n[2].length >= 4)) { // ok, so we're dealing with x/year. But that's not a full date. // This fixes wonky dateElementOrder parsing when set to dmy order. if (Date.CultureInfo.dateElementOrder[0] === "d") { s = "1/" + n[0] + "/" + n[2]; // set to 1st of month and normalize the seperator } } } catch (e) {} return s; } }; $P.Normalizer.buildReplaceData(); }()); (function () { var $P = Date.Parsing; var _ = $P.Operators = { // // Tokenizers // rtoken: function (r) { // regex token return function (s) { var mx = s.match(r); if (mx) { return ([ mx[0], s.substring(mx[0].length) ]); } else { throw new $P.Exception(s); } }; }, token: function () { // whitespace-eating token return function (s) { return _.rtoken(new RegExp("^\\s*" + s + "\\s*"))(s); }; }, stoken: function (s) { // string token return _.rtoken(new RegExp("^" + s)); }, // Atomic Operators until: function (p) { return function (s) { var qx = [], rx = null; while (s.length) { try { rx = p.call(this, s); } catch (e) { qx.push(rx[0]); s = rx[1]; continue; } break; } return [ qx, s ]; }; }, many: function (p) { return function (s) { var rx = [], r = null; while (s.length) { try { r = p.call(this, s); } catch (e) { return [ rx, s ]; } rx.push(r[0]); s = r[1]; } return [ rx, s ]; }; }, // generator operators -- see below optional: function (p) { return function (s) { var r = null; try { r = p.call(this, s); } catch (e) { return [ null, s ]; } return [ r[0], r[1] ]; }; }, not: function (p) { return function (s) { try { p.call(this, s); } catch (e) { return [null, s]; } throw new $P.Exception(s); }; }, ignore: function (p) { return p ? function (s) { var r = null; r = p.call(this, s); return [null, r[1]]; } : null; }, product: function () { var px = arguments[0], qx = Array.prototype.slice.call(arguments, 1), rx = []; for (var i = 0 ; i < px.length ; i++) { rx.push(_.each(px[i], qx)); } return rx; }, cache: function (rule) { var cache = {}, cache_length = 0, cache_keys = [], CACHE_MAX = Date.Config.CACHE_MAX || 100000, r = null; var cacheCheck = function () { if (cache_length === CACHE_MAX) { // kill several keys, don't want to have to do this all the time... for (var i=0; i < 10; i++) { var key = cache_keys.shift(); if (key) { delete cache[key]; cache_length--; } } } }; return function (s) { cacheCheck(); try { r = cache[s] = (cache[s] || rule.call(this, s)); } catch (e) { r = cache[s] = e; } cache_length++; cache_keys.push(s); if (r instanceof $P.Exception) { throw r; } else { return r; } }; }, // vector operators -- see below any: function () { var px = arguments; return function (s) { var r = null; for (var i = 0; i < px.length; i++) { if (px[i] == null) { continue; } try { r = (px[i].call(this, s)); } catch (e) { r = null; } if (r) { return r; } } throw new $P.Exception(s); }; }, each: function () { var px = arguments; return function (s) { var rx = [], r = null; for (var i = 0; i < px.length ; i++) { if (px[i] == null) { continue; } try { r = (px[i].call(this, s)); } catch (e) { throw new $P.Exception(s); } rx.push(r[0]); s = r[1]; } return [ rx, s]; }; }, all: function () { var px = arguments, _ = _; return _.each(_.optional(px)); }, // delimited operators sequence: function (px, d, c) { d = d || _.rtoken(/^\s*/); c = c || null; if (px.length === 1) { return px[0]; } return function (s) { var r = null, q = null; var rx = []; for (var i = 0; i < px.length ; i++) { try { r = px[i].call(this, s); } catch (e) { break; } rx.push(r[0]); try { q = d.call(this, r[1]); } catch (ex) { q = null; break; } s = q[1]; } if (!r) { throw new $P.Exception(s); } if (q) { throw new $P.Exception(q[1]); } if (c) { try { r = c.call(this, r[1]); } catch (ey) { throw new $P.Exception(r[1]); } } return [ rx, (r?r[1]:s) ]; }; }, // // Composite Operators // between: function (d1, p, d2) { d2 = d2 || d1; var _fn = _.each(_.ignore(d1), p, _.ignore(d2)); return function (s) { var rx = _fn.call(this, s); return [[rx[0][0], r[0][2]], rx[1]]; }; }, list: function (p, d, c) { d = d || _.rtoken(/^\s*/); c = c || null; return (p instanceof Array ? _.each(_.product(p.slice(0, -1), _.ignore(d)), p.slice(-1), _.ignore(c)) : _.each(_.many(_.each(p, _.ignore(d))), px, _.ignore(c))); }, set: function (px, d, c) { d = d || _.rtoken(/^\s*/); c = c || null; return function (s) { // r is the current match, best the current 'best' match // which means it parsed the most amount of input var r = null, p = null, q = null, rx = null, best = [[], s], last = false; // go through the rules in the given set for (var i = 0; i < px.length ; i++) { // last is a flag indicating whether this must be the last element // if there is only 1 element, then it MUST be the last one q = null; p = null; r = null; last = (px.length === 1); // first, we try simply to match the current pattern // if not, try the next pattern try { r = px[i].call(this, s); } catch (e) { continue; } // since we are matching against a set of elements, the first // thing to do is to add r[0] to matched elements rx = [[r[0]], r[1]]; // if we matched and there is still input to parse and // we don't already know this is the last element, // we're going to next check for the delimiter ... // if there's none, or if there's no input left to parse // than this must be the last element after all ... if (r[1].length > 0 && ! last) { try { q = d.call(this, r[1]); } catch (ex) { last = true; } } else { last = true; } // if we parsed the delimiter and now there's no more input, // that means we shouldn't have parsed the delimiter at all // so don't update r and mark this as the last element ... if (!last && q[1].length === 0) { last = true; } // so, if this isn't the last element, we're going to see if // we can get any more matches from the remaining (unmatched) // elements ... if (!last) { // build a list of the remaining rules we can match against, // i.e., all but the one we just matched against var qx = []; for (var j = 0; j < px.length ; j++) { if (i !== j) { qx.push(px[j]); } } // now invoke recursively set with the remaining input // note that we don't include the closing delimiter ... // we'll check for that ourselves at the end p = _.set(qx, d).call(this, q[1]); // if we got a non-empty set as a result ... // (otw rx already contains everything we want to match) if (p[0].length > 0) { // update current result, which is stored in rx ... // basically, pick up the remaining text from p[1] // and concat the result from p[0] so that we don't // get endless nesting ... rx[0] = rx[0].concat(p[0]); rx[1] = p[1]; } } // at this point, rx either contains the last matched element // or the entire matched set that starts with this element. // now we just check to see if this variation is better than // our best so far, in terms of how much of the input is parsed if (rx[1].length < best[1].length) { best = rx; } // if we've parsed all the input, then we're finished if (best[1].length === 0) { break; } } // so now we've either gone through all the patterns trying them // as the initial match; or we found one that parsed the entire // input string ... // if best has no matches, just return empty set ... if (best[0].length === 0) { return best; } // if a closing delimiter is provided, then we have to check it also if (c) { // we try this even if there is no remaining input because the pattern // may well be optional or match empty input ... try { q = c.call(this, best[1]); } catch (ey) { throw new $P.Exception(best[1]); } // it parsed ... be sure to update the best match remaining input best[1] = q[1]; } // if we're here, either there was no closing delimiter or we parsed it // so now we have the best match; just return it! return best; }; }, forward: function (gr, fname) { return function (s) { return gr[fname].call(this, s); }; }, // // Translation Operators // replace: function (rule, repl) { return function (s) { var r = rule.call(this, s); return [repl, r[1]]; }; }, process: function (rule, fn) { return function (s) { var r = rule.call(this, s); return [fn.call(this, r[0]), r[1]]; }; }, min: function (min, rule) { return function (s) { var rx = rule.call(this, s); if (rx[0].length < min) { throw new $P.Exception(s); } return rx; }; } }; // Generator Operators And Vector Operators // Generators are operators that have a signature of F(R) => R, // taking a given rule and returning another rule, such as // ignore, which parses a given rule and throws away the result. // Vector operators are those that have a signature of F(R1,R2,...) => R, // take a list of rules and returning a new rule, such as each. // Generator operators are converted (via the following _generator // function) into functions that can also take a list or array of rules // and return an array of new rules as though the function had been // called on each rule in turn (which is what actually happens). // This allows generators to be used with vector operators more easily. // Example: // each(ignore(foo, bar)) instead of each(ignore(foo), ignore(bar)) // This also turns generators into vector operators, which allows // constructs like: // not(cache(foo, bar)) var _generator = function (op) { function gen() { var args = null, rx = [], px, i; if (arguments.length > 1) { args = Array.prototype.slice.call(arguments); } else if (arguments[0] instanceof Array) { args = arguments[0]; } if (args) { px = args.shift(); if (px.length > 0) { args.unshift(px[i]); rx.push(op.apply(null, args)); args.shift(); return rx; } } else { return op.apply(null, arguments); } } return gen; }; var gx = "optional not ignore cache".split(/\s/); for (var i = 0 ; i < gx.length ; i++) { _[gx[i]] = _generator(_[gx[i]]); } var _vector = function (op) { return function () { if (arguments[0] instanceof Array) { return op.apply(null, arguments[0]); } else { return op.apply(null, arguments); } }; }; var vx = "each any all".split(/\s/); for (var j = 0 ; j < vx.length ; j++) { _[vx[j]] = _vector(_[vx[j]]); } }()); (function () { var $D = Date; var flattenAndCompact = function (ax) { var rx = []; for (var i = 0; i < ax.length; i++) { if (ax[i] instanceof Array) { rx = rx.concat(flattenAndCompact(ax[i])); } else { if (ax[i]) { rx.push(ax[i]); } } } return rx; }; var parseMeridian = function () { if (this.meridian && (this.hour || this.hour === 0)) { if (this.meridian === "a" && this.hour > 11 && Date.Config.strict24hr){ throw "Invalid hour and meridian combination"; } else if (this.meridian === "p" && this.hour < 12 && Date.Config.strict24hr){ throw "Invalid hour and meridian combination"; } else if (this.meridian === "p" && this.hour < 12) { this.hour = this.hour + 12; } else if (this.meridian === "a" && this.hour === 12) { this.hour = 0; } } }; var setDefaults = function () { var now = new Date(); if ((this.hour || this.minute) && (!this.month && !this.year && !this.day)) { this.day = now.getDate(); } if (!this.year) { this.year = now.getFullYear(); } if (!this.month && this.month !== 0) { this.month = now.getMonth(); } if (!this.day) { this.day = 1; } if (!this.hour) { this.hour = 0; } if (!this.minute) { this.minute = 0; } if (!this.second) { this.second = 0; } if (!this.millisecond) { this.millisecond = 0; } }; var finishUtils = { getToday: function () { if (this.now || "hour minute second".indexOf(this.unit) !== -1) { return new Date(); } else { return $D.today(); } }, setDaysFromWeekday: function (today, orient){ var gap; orient = orient || 1; this.unit = "day"; gap = ($D.getDayNumberFromName(this.weekday) - today.getDay()); this.days = gap ? ((gap + (orient * 7)) % 7) : (orient * 7); return this; }, setMonthsFromMonth: function (today, orient) { var gap; orient = orient || 1; this.unit = "month"; gap = (this.month - today.getMonth()); this.months = gap ? ((gap + (orient * 12)) % 12) : (orient * 12); this.month = null; return this; }, setDMYFromWeekday: function () { var d = Date[this.weekday](); this.day = d.getDate(); if (!this.month) { this.month = d.getMonth(); } this.year = d.getFullYear(); return this; }, setUnitValue: function (orient) { if (!this.value && this.operator && this.operator !== null && this[this.unit + "s"] && this[this.unit + "s"] !== null) { this[this.unit + "s"] = this[this.unit + "s"] + ((this.operator === "add") ? 1 : -1) + (this.value||0) * orient; } else if (this[this.unit + "s"] == null || this.operator != null) { if (!this.value) { this.value = 1; } this[this.unit + "s"] = this.value * orient; } }, generateDateFromWeeks: function () { var weekday = (this.weekday !== undefined) ? this.weekday : "today"; var d = Date[weekday]().addWeeks(this.weeks); if (this.now) { d.setTimeToNow(); } return d; } }; $D.Translator = { hour: function (s) { return function () { this.hour = Number(s); }; }, minute: function (s) { return function () { this.minute = Number(s); }; }, second: function (s) { return function () { this.second = Number(s); }; }, /* for ss.s format */ secondAndMillisecond: function (s) { return function () { var mx = s.match(/^([0-5][0-9])\.([0-9]{1,3})/); this.second = Number(mx[1]); this.millisecond = Number(mx[2]); }; }, meridian: function (s) { return function () { this.meridian = s.slice(0, 1).toLowerCase(); }; }, timezone: function (s) { return function () { var n = s.replace(/[^\d\+\-]/g, ""); if (n.length) { this.timezoneOffset = Number(n); } else { this.timezone = s.toLowerCase(); } }; }, day: function (x) { var s = x[0]; return function () { this.day = Number(s.match(/\d+/)[0]); if (this.day < 1) { throw "invalid day"; } }; }, month: function (s) { return function () { this.month = (s.length === 3) ? "jan feb mar apr may jun jul aug sep oct nov dec".indexOf(s)/4 : Number(s) - 1; if (this.month < 0) { throw "invalid month"; } }; }, year: function (s) { return function () { var n = Number(s); this.year = ((s.length > 2) ? n : (n + (((n + 2000) < Date.CultureInfo.twoDigitYearMax) ? 2000 : 1900))); }; }, rday: function (s) { return function () { switch (s) { case "yesterday": this.days = -1; break; case "tomorrow": this.days = 1; break; case "today": this.days = 0; break; case "now": this.days = 0; this.now = true; break; } }; }, finishExact: function (x) { var d; x = (x instanceof Array) ? x : [x]; for (var i = 0 ; i < x.length ; i++) { if (x[i]) { x[i].call(this); } } setDefaults.call(this); parseMeridian.call(this); if (this.day > $D.getDaysInMonth(this.year, this.month)) { throw new RangeError(this.day + " is not a valid value for days."); } d = new Date(this.year, this.month, this.day, this.hour, this.minute, this.second, this.millisecond); if (this.year < 100) { d.setFullYear(this.year); // means years less that 100 are process correctly. JS will parse it otherwise as 1900-1999. } if (this.timezone) { d.set({ timezone: this.timezone }); } else if (this.timezoneOffset) { d.set({ timezoneOffset: this.timezoneOffset }); } return d; }, finish: function (x) { var today, expression, orient, temp; x = (x instanceof Array) ? flattenAndCompact(x) : [ x ]; if (x.length === 0) { return null; } for (var i = 0 ; i < x.length ; i++) { if (typeof x[i] === "function") { x[i].call(this); } } if (this.now && !this.unit && !this.operator) { return new Date(); } else { today = finishUtils.getToday.call(this); } expression = !!(this.days && this.days !== null || this.orient || this.operator); orient = ((this.orient === "past" || this.operator === "subtract") ? -1 : 1); if (this.month && this.unit === "week") { this.value = this.month + 1; delete this.month; delete this.day; } if ((this.month || this.month === 0) && "year day hour minute second".indexOf(this.unit) !== -1) { if (!this.value) { this.value = this.month + 1; } this.month = null; expression = true; } if (!expression && this.weekday && !this.day && !this.days) { finishUtils.setDMYFromWeekday.call(this); } if (expression && this.weekday && this.unit !== "month" && this.unit !== "week") { finishUtils.setDaysFromWeekday.call(this, today, orient); } if (this.weekday && this.unit !== "week" && !this.day && !this.days) { temp = Date[this.weekday](); this.day = temp.getDate(); if (temp.getMonth() !== today.getMonth()) { this.month = temp.getMonth(); } } if (this.month && this.unit === "day" && this.operator) { if (!this.value) { this.value = (this.month + 1); } this.month = null; } if (this.value != null && this.month != null && this.year != null) { this.day = this.value * 1; } if (this.month && !this.day && this.value) { today.set({ day: this.value * 1 }); if (!expression) { this.day = this.value * 1; } } if (!this.month && this.value && this.unit === "month" && !this.now) { this.month = this.value; expression = true; } if (expression && (this.month || this.month === 0) && this.unit !== "year") { finishUtils.setMonthsFromMonth.call(this, today, orient); } if (!this.unit) { this.unit = "day"; } finishUtils.setUnitValue.call(this, orient); parseMeridian.call(this); if ((this.month || this.month === 0) && !this.day) { this.day = 1; } if (!this.orient && !this.operator && this.unit === "week" && this.value && !this.day && !this.month) { return Date.today().setWeek(this.value); } if (this.unit === "week" && this.weeks && !this.day && !this.month) { return finishUtils.generateDateFromWeeks.call(this); } if (expression && this.timezone && this.day && this.days) { this.day = this.days; } if (expression){ today.add(this); } else { today.set(this); } if (this.timezone) { this.timezone = this.timezone.toUpperCase(); var offset = $D.getTimezoneOffset(this.timezone); var timezone; if (today.hasDaylightSavingTime()) { // lets check that we're being sane with timezone setting timezone = $D.getTimezoneAbbreviation(offset, today.isDaylightSavingTime()); if (timezone !== this.timezone) { // bugger, we're in a place where things like EST vs EDT matters. if (today.isDaylightSavingTime()) { today.addHours(-1); } else { today.addHours(1); } } } today.setTimezoneOffset(offset); } return today; } }; }()); (function () { var $D = Date; $D.Grammar = {}; var _ = $D.Parsing.Operators, g = $D.Grammar, t = $D.Translator, _fn; // Allow rolling up into general purpose rules _fn = function () { return _.each(_.any.apply(null, arguments), _.not(g.ctoken2("timeContext"))); }; g.datePartDelimiter = _.rtoken(/^([\s\-\.\,\/\x27]+)/); g.timePartDelimiter = _.stoken(":"); g.whiteSpace = _.rtoken(/^\s*/); g.generalDelimiter = _.rtoken(/^(([\s\,]|at|@|on)+)/); var _C = {}; g.ctoken = function (keys) { var fn = _C[keys]; if (! fn) { var c = Date.CultureInfo.regexPatterns; var kx = keys.split(/\s+/), px = []; for (var i = 0; i < kx.length ; i++) { px.push(_.replace(_.rtoken(c[kx[i]]), kx[i])); } fn = _C[keys] = _.any.apply(null, px); } return fn; }; g.ctoken2 = function (key) { return _.rtoken(Date.CultureInfo.regexPatterns[key]); }; var cacheProcessRtoken = function (key, token, type, eachToken) { if (eachToken) { g[key] = _.cache(_.process(_.each(_.rtoken(token),_.optional(g.ctoken2(eachToken))), type)); } else { g[key] = _.cache(_.process(_.rtoken(token), type)); } }; var cacheProcessCtoken = function (token, type) { return _.cache(_.process(g.ctoken2(token), type)); }; var _F = {}; //function cache var _get = function (f) { _F[f] = (_F[f] || g.format(f)[0]); return _F[f]; }; g.allformats = function (fx) { var rx = []; if (fx instanceof Array) { for (var i = 0; i < fx.length; i++) { rx.push(_get(fx[i])); } } else { rx.push(_get(fx)); } return rx; }; g.formats = function (fx) { if (fx instanceof Array) { var rx = []; for (var i = 0 ; i < fx.length ; i++) { rx.push(_get(fx[i])); } return _.any.apply(null, rx); } else { return _get(fx); } }; var grammarFormats = { timeFormats: function(){ var i, RTokenKeys = [ "h", "hh", "H", "HH", "m", "mm", "s", "ss", "ss.s", "z", "zz" ], RToken = [ /^(0[0-9]|1[0-2]|[1-9])/, /^(0[0-9]|1[0-2])/, /^([0-1][0-9]|2[0-3]|[0-9])/, /^([0-1][0-9]|2[0-3])/, /^([0-5][0-9]|[0-9])/, /^[0-5][0-9]/, /^([0-5][0-9]|[0-9])/, /^[0-5][0-9]/, /^[0-5][0-9]\.[0-9]{1,3}/, /^((\+|\-)\s*\d\d\d\d)|((\+|\-)\d\d\:?\d\d)/, /^((\+|\-)\s*\d\d\d\d)|((\+|\-)\d\d\:?\d\d)/ ], tokens = [ t.hour, t.hour, t.hour, t.hour, t.minute, t.minute, t.second, t.second, t.secondAndMillisecond, t.timezone, t.timezone ]; for (i=0; i < RTokenKeys.length; i++) { cacheProcessRtoken(RTokenKeys[i], RToken[i], tokens[i]); } g.hms = _.cache(_.sequence([g.H, g.m, g.s], g.timePartDelimiter)); g.t = cacheProcessCtoken("shortMeridian", t.meridian); g.tt = cacheProcessCtoken("longMeridian", t.meridian); g.zzz = cacheProcessCtoken("timezone", t.timezone); g.timeSuffix = _.each(_.ignore(g.whiteSpace), _.set([ g.tt, g.zzz ])); g.time = _.each(_.optional(_.ignore(_.stoken("T"))), g.hms, g.timeSuffix); }, dateFormats: function () { // pre-loaded rules for different date part order preferences var _setfn = function () { return _.set(arguments, g.datePartDelimiter); }; var i, RTokenKeys = [ "d", "dd", "M", "MM", "y", "yy", "yyy", "yyyy" ], RToken = [ /^([0-2]\d|3[0-1]|\d)/, /^([0-2]\d|3[0-1])/, /^(1[0-2]|0\d|\d)/, /^(1[0-2]|0\d)/, /^(\d+)/, /^(\d\d)/, /^(\d\d?\d?\d?)/, /^(\d\d\d\d)/ ], tokens = [ t.day, t.day, t.month, t.month, t.year, t.year, t.year, t.year ], eachToken = [ "ordinalSuffix", "ordinalSuffix" ]; for (i=0; i < RTokenKeys.length; i++) { cacheProcessRtoken(RTokenKeys[i], RToken[i], tokens[i], eachToken[i]); } g.MMM = g.MMMM = _.cache(_.process(g.ctoken("jan feb mar apr may jun jul aug sep oct nov dec"), t.month)); g.ddd = g.dddd = _.cache(_.process(g.ctoken("sun mon tue wed thu fri sat"), function (s) { return function () { this.weekday = s; }; } )); g.day = _fn(g.d, g.dd); g.month = _fn(g.M, g.MMM); g.year = _fn(g.yyyy, g.yy); g.mdy = _setfn(g.ddd, g.month, g.day, g.year); g.ymd = _setfn(g.ddd, g.year, g.month, g.day); g.dmy = _setfn(g.ddd, g.day, g.month, g.year); g.date = function (s) { return ((g[Date.CultureInfo.dateElementOrder] || g.mdy).call(this, s)); }; }, relative: function () { // relative date / time expressions g.orientation = _.process(g.ctoken("past future"), function (s) { return function () { this.orient = s; }; } ); g.operator = _.process(g.ctoken("add subtract"), function (s) { return function () { this.operator = s; }; } ); g.rday = _.process(g.ctoken("yesterday tomorrow today now"), t.rday); g.unit = _.process(g.ctoken("second minute hour day week month year"), function (s) { return function () { this.unit = s; }; } ); } }; g.buildGrammarFormats = function () { // these need to be rebuilt every time the language changes. _C = {}; grammarFormats.timeFormats(); grammarFormats.dateFormats(); grammarFormats.relative(); g.value = _.process(_.rtoken(/^([-+]?\d+)?(st|nd|rd|th)?/), function (s) { return function () { this.value = s.replace(/\D/g, ""); }; } ); g.expression = _.set([g.rday, g.operator, g.value, g.unit, g.orientation, g.ddd, g.MMM ]); g.format = _.process(_.many( _.any( // translate format specifiers into grammar rules _.process( _.rtoken(/^(dd?d?d?(?!e)|MM?M?M?|yy?y?y?|hh?|HH?|mm?|ss?|tt?|zz?z?)/), function (fmt) { if (g[fmt]) { return g[fmt]; } else { throw $D.Parsing.Exception(fmt); } } ), // translate separator tokens into token rules _.process(_.rtoken(/^[^dMyhHmstz]+/), // all legal separators function (s) { return _.ignore(_.stoken(s)); } ) ) ), // construct the parser ... function (rules) { return _.process(_.each.apply(null, rules), t.finishExact); } ); // starting rule for general purpose grammar g._start = _.process(_.set([ g.date, g.time, g.expression ], g.generalDelimiter, g.whiteSpace), t.finish); }; g.buildGrammarFormats(); // parsing date format specifiers - ex: "h:m:s tt" // this little guy will generate a custom parser based // on the format string, ex: g.format("h:m:s tt") // check for these formats first g._formats = g.formats([ "\"yyyy-MM-ddTHH:mm:ssZ\"", "yyyy-MM-ddTHH:mm:ss.sz", "yyyy-MM-ddTHH:mm:ssZ", "yyyy-MM-ddTHH:mm:ssz", "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-ddTHH:mmZ", "yyyy-MM-ddTHH:mmz", "yyyy-MM-ddTHH:mm", "ddd, MMM dd, yyyy H:mm:ss tt", "ddd MMM d yyyy HH:mm:ss zzz", "MMddyyyy", "ddMMyyyy", "Mddyyyy", "ddMyyyy", "Mdyyyy", "dMyyyy", "yyyy", "Mdyy", "dMyy", "d" ]); // real starting rule: tries selected formats first, // then general purpose rule g.start = function (s) { try { var r = g._formats.call({}, s); if (r[1].length === 0) { return r; } } catch (e) {} return g._start.call({}, s); }; }()); (function () { var $D = Date; /** * @desc Converts the specified string value into its JavaScript Date equivalent using CultureInfo specific format information. * * Example

	///////////
	// Dates //
	///////////

	// 15-Oct-2004
	var d1 = Date.parse("10/15/2004");

	// 15-Oct-2004
	var d1 = Date.parse("15-Oct-2004");

	// 15-Oct-2004
	var d1 = Date.parse("2004.10.15");

	//Fri Oct 15, 2004
	var d1 = Date.parse("Fri Oct 15, 2004");

	///////////
	// Times //
	///////////

	// Today at 10 PM.
	var d1 = Date.parse("10 PM");

	// Today at 10:30 PM.
	var d1 = Date.parse("10:30 P.M.");

	// Today at 6 AM.
	var d1 = Date.parse("06am");

	/////////////////////
	// Dates and Times //
	/////////////////////

	// 8-July-2004 @ 10:30 PM
	var d1 = Date.parse("July 8th, 2004, 10:30 PM");

	// 1-July-2004 @ 10:30 PM
	var d1 = Date.parse("2004-07-01T22:30:00");

	////////////////////
	// Relative Dates //
	////////////////////

	// Returns today's date. The string "today" is culture specific.
	var d1 = Date.parse("today");

	// Returns yesterday's date. The string "yesterday" is culture specific.
	var d1 = Date.parse("yesterday");

	// Returns the date of the next thursday.
	var d1 = Date.parse("Next thursday");

	// Returns the date of the most previous monday.
	var d1 = Date.parse("last monday");

	// Returns today's day + one year.
	var d1 = Date.parse("next year");

	///////////////
	// Date Math //
	///////////////

	// Today + 2 days
	var d1 = Date.parse("t+2");

	// Today + 2 days
	var d1 = Date.parse("today + 2 days");

	// Today + 3 months
	var d1 = Date.parse("t+3m");

	// Today - 1 year
	var d1 = Date.parse("today - 1 year");

	// Today - 1 year
	var d1 = Date.parse("t-1y"); 


	/////////////////////////////
	// Partial Dates and Times //
	/////////////////////////////

	// July 15th of this year.
	var d1 = Date.parse("July 15");

	// 15th day of current day and year.
	var d1 = Date.parse("15");

	// July 1st of current year at 10pm.
	var d1 = Date.parse("7/1 10pm");
	
* * @param {String} The string value to convert into a Date object [Required] * @return {Date} A Date object or null if the string cannot be converted into a Date. */ var parseUtils = { removeOrds: function (s) { ords = s.match(/\b(\d+)(?:st|nd|rd|th)\b/); // find ordinal matches s = ((ords && ords.length === 2) ? s.replace(ords[0], ords[1]) : s); return s; }, grammarParser: function (s) { var r = null; try { r = $D.Grammar.start.call({}, s.replace(/^\s*(\S*(\s+\S+)*)\s*$/, "$1")); } catch (e) { return null; } return ((r[1].length === 0) ? r[0] : null); }, nativeFallback: function(s) { var t; try { // ok we haven't parsed it, last ditch attempt with the built-in parser. t = Date._parse(s); return (t || t === 0) ? new Date(t) : null; } catch (e) { return null; } } }; function parse (s) { var d; if (!s) { return null; } if (s instanceof Date) { return s.clone(); } if (s.length >= 4 && s.charAt(0) !== "0" && s.charAt(0) !== "+"&& s.charAt(0) !== "-") { // ie: 2004 will pass, 0800 won't. // Start with specific formats d = $D.Parsing.ISO.parse(s) || $D.Parsing.Numeric.parse(s); } if (d instanceof Date && !isNaN(d.getTime())) { return d; } else { // find ordinal dates (1st, 3rd, 8th, etc and remove them as they cause parsing issues) s = $D.Parsing.Normalizer.parse(parseUtils.removeOrds(s)); d = parseUtils.grammarParser(s); if (d !== null) { return d; } else { return parseUtils.nativeFallback(s); } } } if (!$D._parse) { $D._parse = $D.parse; } $D.parse = parse; Date.getParseFunction = function (fx) { var fns = Date.Grammar.allformats(fx); return function (s) { var r = null; for (var i = 0; i < fns.length; i++) { try { r = fns[i].call({}, s); } catch (e) { continue; } if (r[1].length === 0) { return r[0]; } } return null; }; }; /** * Converts the specified string value into its JavaScript Date equivalent using the specified format {String} or formats {Array} and the CultureInfo specific format information. * The format of the string value must match one of the supplied formats exactly. * * Example

	// 15-Oct-2004
	var d1 = Date.parseExact("10/15/2004", "M/d/yyyy");

	// 15-Oct-2004
	var d1 = Date.parse("15-Oct-2004", "M-ddd-yyyy");

	// 15-Oct-2004
	var d1 = Date.parse("2004.10.15", "yyyy.MM.dd");

	// Multiple formats
	var d1 = Date.parseExact("10/15/2004", ["M/d/yyyy", "MMMM d, yyyy"]);
	
* * @param {String} The string value to convert into a Date object [Required]. * @param {Object} The expected format {String} or an array of expected formats {Array} of the date string [Required]. * @return {Date} A Date object or null if the string cannot be converted into a Date. */ $D.parseExact = function (s, fx) { return $D.getParseFunction(fx)(s); }; }()); (function () { var $D = Date, $P = $D.prototype, // $C = $D.CultureInfo, // not used atm p = function (s, l) { if (!l) { l = 2; } return ("000" + s).slice(l * -1); }; /** * Converts a PHP format string to Java/.NET format string. * A PHP format string can be used with ._format or .format. * A Java/.NET format string can be used with .toString(). * The .parseExact function will only accept a Java/.NET format string * * Example * var f1 = "%m/%d/%y" * var f2 = Date.normalizeFormat(f1); // "MM/dd/yy" * * new Date().format(f1); // "04/13/08" * new Date()._format(f1); // "04/13/08" * new Date().toString(f2); // "04/13/08" * * var date = Date.parseExact("04/13/08", f2); // Sun Apr 13 2008 * * @param {String} A PHP format string consisting of one or more format spcifiers. * @return {String} The PHP format converted to a Java/.NET format string. */ var normalizerSubstitutions = { "d" : "dd", "%d": "dd", "D" : "ddd", "%a": "ddd", "j" : "dddd", "l" : "dddd", "%A": "dddd", "S" : "S", "F" : "MMMM", "%B": "MMMM", "m" : "MM", "%m": "MM", "M" : "MMM", "%b": "MMM", "%h": "MMM", "n" : "M", "Y" : "yyyy", "%Y": "yyyy", "y" : "yy", "%y": "yy", "g" : "h", "%I": "h", "G" : "H", "h" : "hh", "H" : "HH", "%H": "HH", "i" : "mm", "%M": "mm", "s" : "ss", "%S": "ss", "%r": "hh:mm tt", "%R": "H:mm", "%T": "H:mm:ss", "%X": "t", "%x": "d", "%e": "d", "%D": "MM/dd/yy", "%n": "\\n", "%t": "\\t", "e" : "z", "T" : "z", "%z": "z", "%Z": "z", "Z" : "ZZ", "N" : "u", "w" : "u", "%w": "u", "W" : "W", "%V": "W" }; var normalizer = { substitutes: function (m) { return normalizerSubstitutions[m]; }, interpreted: function (m, x) { var y; switch (m) { case "%u": return x.getDay() + 1; case "z": return x.getOrdinalNumber(); case "%j": return p(x.getOrdinalNumber(), 3); case "%U": var d1 = x.clone().set({month: 0, day: 1}).addDays(-1).moveToDayOfWeek(0), d2 = x.clone().addDays(1).moveToDayOfWeek(0, -1); return (d2 < d1) ? "00" : p((d2.getOrdinalNumber() - d1.getOrdinalNumber()) / 7 + 1); case "%W": return p(x.getWeek()); case "t": return $D.getDaysInMonth(x.getFullYear(), x.getMonth()); case "o": case "%G": return x.setWeek(x.getISOWeek()).toString("yyyy"); case "%g": return x._format("%G").slice(-2); case "a": case "%p": return t("tt").toLowerCase(); case "A": return t("tt").toUpperCase(); case "u": return p(x.getMilliseconds(), 3); case "I": return (x.isDaylightSavingTime()) ? 1 : 0; case "O": return x.getUTCOffset(); case "P": y = x.getUTCOffset(); return y.substring(0, y.length - 2) + ":" + y.substring(y.length - 2); case "B": var now = new Date(); return Math.floor(((now.getHours() * 3600) + (now.getMinutes() * 60) + now.getSeconds() + (now.getTimezoneOffset() + 60) * 60) / 86.4); case "c": return x.toISOString().replace(/\"/g, ""); case "U": return $D.strtotime("now"); case "%c": return t("d") + " " + t("t"); case "%C": return Math.floor(x.getFullYear() / 100 + 1); } }, shouldOverrideDefaults: function (m) { switch (m) { case "%e": return true; default: return false; } }, parse: function (m, context) { var formatString, c = context || new Date(); formatString = normalizer.substitutes(m); if (formatString) { return formatString; } formatString = normalizer.interpreted(m, c); if (formatString) { return formatString; } else { return m; } } }; $D.normalizeFormat = function (format, context) { return format.replace(/(%|\\)?.|%%/g, function(t){ return normalizer.parse(t, context); }); }; /** * Format a local Unix timestamp according to locale settings * * Example: * Date.strftime("%m/%d/%y", new Date()); // "04/13/08" * Date.strftime("c", "2008-04-13T17:52:03Z"); // "04/13/08" * * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @param {Number|String} The number representing the number of seconds that have elapsed since January 1, 1970 (local time). * @return {String} A string representation of the current Date object. */ $D.strftime = function (format, time) { var d = Date.parse(time); return d._format(format); }; /** * Parse any textual datetime description into a Unix timestamp. * A Unix timestamp is the number of seconds that have elapsed since January 1, 1970 (midnight UTC/GMT). * * Example: * Date.strtotime("04/13/08"); // 1208044800 * Date.strtotime("1970-01-01T00:00:00Z"); // 0 * * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @param {Object} A string or date object. * @return {String} A string representation of the current Date object. */ $D.strtotime = function (time) { var d = $D.parse(time); return Math.round($D.UTC(d.getUTCFullYear(), d.getUTCMonth(), d.getUTCDate(), d.getUTCHours(), d.getUTCMinutes(), d.getUTCSeconds(), d.getUTCMilliseconds()) / 1000); }; /** * Converts the value of the current Date object to its equivalent string representation using a PHP/Unix style of date format specifiers. * Format Specifiers * Format Description Example * ------ --------------------------------------------------------------------------- ----------------------- * %a abbreviated weekday name according to the current localed "Mon" through "Sun" * %A full weekday name according to the current localed "Sunday" through "Saturday" * %b abbreviated month name according to the current localed "Jan" through "Dec" * %B full month name according to the current locale "January" through "December" * %c preferred date and time representation for the current locale "4/13/2008 12:33 PM" * %C century number (the year divided by 100 and truncated to an integer) "00" to "99" * %d day of the month as a decimal number "01" to "31" * %D same as %m/%d/%y "04/13/08" * %e day of the month as a decimal number, a single digit is preceded by a space "1" to "31" * %g like %G, but without the century "08" * %G The 4-digit year corresponding to the ISO week number (see %V). "2008" * This has the same format and value as %Y, except that if the ISO week number * belongs to the previous or next year, that year is used instead. * %h same as %b "Jan" through "Dec" * %H hour as a decimal number using a 24-hour clock. "00" to "23" * %I hour as a decimal number using a 12-hour clock. "01" to "12" * %j day of the year as a decimal number. "001" to "366" * %m month as a decimal number. "01" to "12" * %M minute as a decimal number. "00" to "59" * %n newline character "\n" * %p either "am" or "pm" according to the given time value, or the "am" or "pm" * corresponding strings for the current locale. * %r time in a.m. and p.m. notation "8:44 PM" * %R time in 24 hour notation "20:44" * %S second as a decimal number "00" to "59" * %t tab character "\t" * %T current time, equal to %H:%M:%S "12:49:11" * %u weekday as a decimal number ["1", "7"], with "1" representing Monday "1" to "7" * %U week number of the current year as a decimal number, starting with the "0" to ("52" or "53") * first Sunday as the first day of the first week * %V The ISO 8601:1988 week number of the current year as a decimal number, "00" to ("52" or "53") * range 01 to 53, where week 1 is the first week that has at least 4 days * in the current year, and with Monday as the first day of the week. * (Use %G or %g for the year component that corresponds to the week number * for the specified timestamp.) * %W week number of the current year as a decimal number, starting with the "00" to ("52" or "53") * first Monday as the first day of the first week * %w day of the week as a decimal, Sunday being "0" "0" to "6" * %x preferred date representation for the current locale without the time "4/13/2008" * %X preferred time representation for the current locale without the date "12:53:05" * %y year as a decimal number without a century "00" "99" * %Y year as a decimal number including the century "2008" * %Z time zone or name or abbreviation "UTC", "EST", "PST" * %z same as %Z * %% a literal "%" characters "%" * d Day of the month, 2 digits with leading zeros "01" to "31" * D A textual representation of a day, three letters "Mon" through "Sun" * j Day of the month without leading zeros "1" to "31" * l A full textual representation of the day of the week (lowercase "L") "Sunday" through "Saturday" * N ISO-8601 numeric representation of the day of the week (added in PHP 5.1.0) "1" (for Monday) through "7" (for Sunday) * S English ordinal suffix for the day of the month, 2 characters "st", "nd", "rd" or "th". Works well with j * w Numeric representation of the day of the week "0" (for Sunday) through "6" (for Saturday) * z The day of the year (starting from "0") "0" through "365" * W ISO-8601 week number of year, weeks starting on Monday "00" to ("52" or "53") * F A full textual representation of a month, such as January or March "January" through "December" * m Numeric representation of a month, with leading zeros "01" through "12" * M A short textual representation of a month, three letters "Jan" through "Dec" * n Numeric representation of a month, without leading zeros "1" through "12" * t Number of days in the given month "28" through "31" * L Whether it's a leap year "1" if it is a leap year, "0" otherwise * o ISO-8601 year number. This has the same value as Y, except that if the "2008" * ISO week number (W) belongs to the previous or next year, that year * is used instead. * Y A full numeric representation of a year, 4 digits "2008" * y A two digit representation of a year "08" * a Lowercase Ante meridiem and Post meridiem "am" or "pm" * A Uppercase Ante meridiem and Post meridiem "AM" or "PM" * B Swatch Internet time "000" through "999" * g 12-hour format of an hour without leading zeros "1" through "12" * G 24-hour format of an hour without leading zeros "0" through "23" * h 12-hour format of an hour with leading zeros "01" through "12" * H 24-hour format of an hour with leading zeros "00" through "23" * i Minutes with leading zeros "00" to "59" * s Seconds, with leading zeros "00" through "59" * u Milliseconds "54321" * e Timezone identifier "UTC", "EST", "PST" * I Whether or not the date is in daylight saving time (uppercase i) "1" if Daylight Saving Time, "0" otherwise * O Difference to Greenwich time (GMT) in hours "+0200", "-0600" * P Difference to Greenwich time (GMT) with colon between hours and minutes "+02:00", "-06:00" * T Timezone abbreviation "UTC", "EST", "PST" * Z Timezone offset in seconds. The offset for timezones west of UTC is "-43200" through "50400" * always negative, and for those east of UTC is always positive. * c ISO 8601 date "2004-02-12T15:19:21+00:00" * r RFC 2822 formatted date "Thu, 21 Dec 2000 16:01:07 +0200" * U Seconds since the Unix Epoch (January 1 1970 00:00:00 GMT) "0" * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @return {String} A string representation of the current Date object. */ var formatReplace = function (context) { return function (m) { var formatString, override = false; if (m.charAt(0) === "\\" || m.substring(0, 2) === "%%") { return m.replace("\\", "").replace("%%", "%"); } override = normalizer.shouldOverrideDefaults(m); formatString = $D.normalizeFormat(m, context); if (formatString) { return context.toString(formatString, override); } }; }; $P._format = function (format) { var formatter = formatReplace(this); if (!format) { return this._toString(); } else { return format.replace(/(%|\\)?.|%%/g, formatter); } }; if (!$P.format) { $P.format = $P._format; } }()); (function () { "use strict"; var gFn = function (attr) { return function () { return this[attr]; }; }; var sFn = function (attr) { return function (val) { this[attr] = val; return this; }; }; var attrs = ["years", "months", "days", "hours", "minutes", "seconds", "milliseconds"]; var addSetFuncs = function (context, attrs) { for (var i = 0; i < attrs.length ; i++) { var $a = attrs[i], $b = $a.slice(0, 1).toUpperCase() + $a.slice(1); context.prototype[$a] = 0; context.prototype["get" + $b] = gFn($a); context.prototype["set" + $b] = sFn($a); } }; /** * new TimeSpan(milliseconds); * new TimeSpan(days, hours, minutes, seconds); * new TimeSpan(days, hours, minutes, seconds, milliseconds); */ var TimeSpan = function (days, hours, minutes, seconds, milliseconds) { if (arguments.length === 1 && typeof days === "number") { var orient = (days < 0) ? -1 : +1; var millsLeft = Math.abs(days); this.setDays(Math.floor(millsLeft / 86400000) * orient); millsLeft = millsLeft % 86400000; this.setHours(Math.floor(millsLeft / 3600000) * orient); millsLeft = millsLeft % 3600000; this.setMinutes(Math.floor(millsLeft / 60000) * orient); millsLeft = millsLeft % 60000; this.setSeconds(Math.floor(millsLeft / 1000) * orient); millsLeft = millsLeft % 1000; this.setMilliseconds(millsLeft * orient); } else { this.set(days, hours, minutes, seconds, milliseconds); } this.getTotalMilliseconds = function () { return (this.getDays() * 86400000) + (this.getHours() * 3600000) + (this.getMinutes() * 60000) + (this.getSeconds() * 1000); }; this.compareTo = function (time) { var t1 = new Date(1970, 1, 1, this.getHours(), this.getMinutes(), this.getSeconds()), t2; if (time === null) { t2 = new Date(1970, 1, 1, 0, 0, 0); } else { t2 = new Date(1970, 1, 1, time.getHours(), time.getMinutes(), time.getSeconds()); } return (t1 < t2) ? -1 : (t1 > t2) ? 1 : 0; }; this.equals = function (time) { return (this.compareTo(time) === 0); }; this.add = function (time) { return (time === null) ? this : this.addSeconds(time.getTotalMilliseconds() / 1000); }; this.subtract = function (time) { return (time === null) ? this : this.addSeconds(-time.getTotalMilliseconds() / 1000); }; this.addDays = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 86400000)); }; this.addHours = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 3600000)); }; this.addMinutes = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 60000)); }; this.addSeconds = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 1000)); }; this.addMilliseconds = function (n) { return new TimeSpan(this.getTotalMilliseconds() + n); }; this.get12HourHour = function () { return (this.getHours() > 12) ? this.getHours() - 12 : (this.getHours() === 0) ? 12 : this.getHours(); }; this.getDesignator = function () { return (this.getHours() < 12) ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator; }; this.toString = function (format) { this._toString = function () { if (this.getDays() !== null && this.getDays() > 0) { return this.getDays() + "." + this.getHours() + ":" + this.p(this.getMinutes()) + ":" + this.p(this.getSeconds()); } else { return this.getHours() + ":" + this.p(this.getMinutes()) + ":" + this.p(this.getSeconds()); } }; this.p = function (s) { return (s.toString().length < 2) ? "0" + s : s; }; var me = this; return format ? format.replace(/dd?|HH?|hh?|mm?|ss?|tt?/g, function (format) { switch (format) { case "d": return me.getDays(); case "dd": return me.p(me.getDays()); case "H": return me.getHours(); case "HH": return me.p(me.getHours()); case "h": return me.get12HourHour(); case "hh": return me.p(me.get12HourHour()); case "m": return me.getMinutes(); case "mm": return me.p(me.getMinutes()); case "s": return me.getSeconds(); case "ss": return me.p(me.getSeconds()); case "t": return ((me.getHours() < 12) ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator).substring(0, 1); case "tt": return (me.getHours() < 12) ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator; } } ) : this._toString(); }; return this; }; addSetFuncs(TimeSpan, attrs.slice(2)); TimeSpan.prototype.set = function (days, hours, minutes, seconds, milliseconds){ this.setDays(days || this.getDays()); this.setHours(hours || this.getHours()); this.setMinutes(minutes || this.getMinutes()); this.setSeconds(seconds || this.getSeconds()); this.setMilliseconds(milliseconds || this.getMilliseconds()); }; /** * Gets the time of day for this date instances. * @return {TimeSpan} TimeSpan */ Date.prototype.getTimeOfDay = function () { return new TimeSpan(0, this.getHours(), this.getMinutes(), this.getSeconds(), this.getMilliseconds()); }; Date.TimeSpan = TimeSpan; if (typeof window !== "undefined" ) { // keeping API compatible for v1.x window.TimeSpan = TimeSpan; } }()); (function () { "use strict"; var attrs = ["years", "months", "days", "hours", "minutes", "seconds", "milliseconds"]; var gFn = function (attr) { return function () { return this[attr]; }; }; var sFn = function (attr) { return function (val) { this[attr] = val; return this; }; }; var addSetFuncs = function (context, attrs) { for (var i = 0; i < attrs.length ; i++) { var $a = attrs[i], $b = $a.slice(0, 1).toUpperCase() + $a.slice(1); context.prototype[$a] = 0; context.prototype["get" + $b] = gFn($a); context.prototype["set" + $b] = sFn($a); } }; var setMonthsAndYears = function (orient, d1, d2, context) { function inc() { d1.addMonths(-orient); context.months++; if (context.months === 12) { context.years++; context.months = 0; } } if (orient === +1) { while (d1 > d2) { inc(); } } else { while (d1 < d2) { inc(); } } context.months--; context.months *= orient; context.years *= orient; }; var adjustForDST = function(orient, startDate, endDate) { var hasDSTMismatch = (false === (startDate.isDaylightSavingTime() === endDate.isDaylightSavingTime())); if (hasDSTMismatch && orient === 1) { startDate.addHours(-1); } else if (hasDSTMismatch) { startDate.addHours(1); } }; /** * TimePeriod(startDate, endDate); * TimePeriod(years, months, days, hours, minutes, seconds, milliseconds); */ var TimePeriod = function (years, months, days, hours, minutes, seconds, milliseconds) { if (arguments.length === 7) { this.set(years, months, days, hours, minutes, seconds, milliseconds); } else if (arguments.length === 2 && arguments[0] instanceof Date && arguments[1] instanceof Date) { var startDate = arguments[0].clone(); var endDate = arguments[1].clone(); var orient = (startDate > endDate) ? +1 : -1; this.dates = { start: arguments[0].clone(), end: arguments[1].clone() }; setMonthsAndYears(orient, startDate, endDate, this); adjustForDST(orient, startDate, endDate); // // TODO - adjust for DST var diff = endDate - startDate; if (diff !== 0) { var ts = new TimeSpan(diff); this.set(this.years, this.months, ts.getDays(), ts.getHours(), ts.getMinutes(), ts.getSeconds(), ts.getMilliseconds()); } } return this; }; // create all the set functions. addSetFuncs(TimePeriod, attrs); TimePeriod.prototype.set = function (years, months, days, hours, minutes, seconds, milliseconds){ this.setYears(years || this.getYears()); this.setMonths(months || this.getMonths()); this.setDays(days || this.getDays()); this.setHours(hours || this.getHours()); this.setMinutes(minutes || this.getMinutes()); this.setSeconds(seconds || this.getSeconds()); this.setMilliseconds(milliseconds || this.getMilliseconds()); }; Date.TimePeriod = TimePeriod; if (typeof window !== "undefined") { // keeping API compatible for v1.x window.TimePeriod = TimePeriod; } }()); ================================================ FILE: build/date-es-BO.js ================================================ /** * @overview datejs * @version 1.0.0-rc3 * @author Gregory Wild-Smith * @copyright 2015 Gregory Wild-Smith * @license MIT * @homepage https://github.com/abritinthebay/datejs */ /* * DateJS Culture String File * Country Code: es-BO * Name: Spanish (Bolivia) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["es-BO"] = { "name": "es-BO", "englishName": "Spanish (Bolivia)", "nativeName": "Español (Bolivia)", "Sunday": "domingo", "Monday": "lunes", "Tuesday": "martes", "Wednesday": "miércoles", "Thursday": "jueves", "Friday": "viernes", "Saturday": "sábado", "Sun": "dom", "Mon": "lun", "Tue": "mar", "Wed": "mié", "Thu": "jue", "Fri": "vie", "Sat": "sáb", "Su": "do", "Mo": "lu", "Tu": "ma", "We": "mi", "Th": "ju", "Fr": "vi", "Sa": "sá", "S_Sun_Initial": "d", "M_Mon_Initial": "l", "T_Tue_Initial": "m", "W_Wed_Initial": "m", "T_Thu_Initial": "j", "F_Fri_Initial": "v", "S_Sat_Initial": "s", "January": "enero", "February": "febrero", "March": "marzo", "April": "abril", "May": "mayo", "June": "junio", "July": "julio", "August": "agosto", "September": "septiembre", "October": "octubre", "November": "noviembre", "December": "diciembre", "Jan_Abbr": "ene", "Feb_Abbr": "feb", "Mar_Abbr": "mar", "Apr_Abbr": "abr", "May_Abbr": "may", "Jun_Abbr": "jun", "Jul_Abbr": "jul", "Aug_Abbr": "ago", "Sep_Abbr": "sep", "Oct_Abbr": "oct", "Nov_Abbr": "nov", "Dec_Abbr": "dic", "AM": "a.m.", "PM": "p.m.", "firstDayOfWeek": 0, "twoDigitYearMax": 2029, "mdy": "dmy", "M/d/yyyy": "dd/MM/yyyy", "dddd, MMMM dd, yyyy": "dddd, dd' [de] 'MMMM' [de] 'yyyy", "h:mm tt": "hh:mm tt", "h:mm:ss tt": "hh:mm:ss tt", "dddd, MMMM dd, yyyy h:mm:ss tt": "dddd, dd' [de] 'MMMM' [de] 'yyyy hh:mm:ss tt", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "dd MMMM", "MMMM, yyyy": "MMMM' [de] 'yyyy", "/jan(uary)?/": "ene(ro)?", "/feb(ruary)?/": "feb(rero)?", "/mar(ch)?/": "mar(zo)?", "/apr(il)?/": "abr(il)?", "/may/": "may(o)?", "/jun(e)?/": "jun(io)?", "/jul(y)?/": "jul(io)?", "/aug(ust)?/": "ago(sto)?", "/sep(t(ember)?)?/": "sep(tiembre)?", "/oct(ober)?/": "oct(ubre)?", "/nov(ember)?/": "nov(iembre)?", "/dec(ember)?/": "dic(iembre)?", "/^su(n(day)?)?/": "^do(m(ingo)?)?", "/^mo(n(day)?)?/": "^lu(n(es)?)?", "/^tu(e(s(day)?)?)?/": "^ma(r(tes)?)?", "/^we(d(nesday)?)?/": "^mi(é(rcoles)?)?", "/^th(u(r(s(day)?)?)?)?/": "^ju(e(ves)?)?", "/^fr(i(day)?)?/": "^vi(e(rnes)?)?", "/^sa(t(urday)?)?/": "^sá(b(ado)?)?", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "es-BO"; /** * @overview datejs * @version 1.0.0-rc3 * @author Gregory Wild-Smith * @copyright 2015 Gregory Wild-Smith * @license MIT * @homepage https://github.com/abritinthebay/datejs */(function () { var $D = Date; var lang = Date.CultureStrings ? Date.CultureStrings.lang : null; var loggedKeys = {}; // for debug purposes. var getText = { getFromKey: function (key, countryCode) { var output; if (Date.CultureStrings && Date.CultureStrings[countryCode] && Date.CultureStrings[countryCode][key]) { output = Date.CultureStrings[countryCode][key]; } else { output = getText.buildFromDefault(key); } if (key.charAt(0) === "/") { // Assume it's a regex output = getText.buildFromRegex(key, countryCode); } return output; }, getFromObjectValues: function (obj, countryCode) { var key, output = {}; for(key in obj) { if (obj.hasOwnProperty(key)) { output[key] = getText.getFromKey(obj[key], countryCode); } } return output; }, getFromObjectKeys: function (obj, countryCode) { var key, output = {}; for(key in obj) { if (obj.hasOwnProperty(key)) { output[getText.getFromKey(key, countryCode)] = obj[key]; } } return output; }, getFromArray: function (arr, countryCode) { var output = []; for (var i=0; i < arr.length; i++){ if (i in arr) { output[i] = getText.getFromKey(arr[i], countryCode); } } return output; }, buildFromDefault: function (key) { var output, length, split, last; switch(key) { case "name": output = "en-US"; break; case "englishName": output = "English (United States)"; break; case "nativeName": output = "English (United States)"; break; case "twoDigitYearMax": output = 2049; break; case "firstDayOfWeek": output = 0; break; default: output = key; split = key.split("_"); length = split.length; if (length > 1 && key.charAt(0) !== "/") { // if the key isn't a regex and it has a split. last = split[(length - 1)].toLowerCase(); if (last === "initial" || last === "abbr") { output = split[0]; } } break; } return output; }, buildFromRegex: function (key, countryCode) { var output; if (Date.CultureStrings && Date.CultureStrings[countryCode] && Date.CultureStrings[countryCode][key]) { output = new RegExp(Date.CultureStrings[countryCode][key], "i"); } else { output = new RegExp(key.replace(new RegExp("/", "g"),""), "i"); } return output; } }; var shallowMerge = function (obj1, obj2) { for (var attrname in obj2) { if (obj2.hasOwnProperty(attrname)) { obj1[attrname] = obj2[attrname]; } } }; var __ = function (key, language) { var countryCode = (language) ? language : lang; loggedKeys[key] = key; if (typeof key === "object") { if (key instanceof Array) { return getText.getFromArray(key, countryCode); } else { return getText.getFromObjectKeys(key, countryCode); } } else { return getText.getFromKey(key, countryCode); } }; var loadI18nScript = function (code) { // paatterned after jQuery's getScript. var url = Date.Config.i18n + code + ".js"; var head = document.getElementsByTagName("head")[0] || document.documentElement; var script = document.createElement("script"); script.src = url; var completed = false; var events = { done: function (){} // placeholder function }; // Attach handlers for all browsers script.onload = script.onreadystatechange = function() { if ( !completed && (!this.readyState || this.readyState === "loaded" || this.readyState === "complete") ) { events.done(); head.removeChild(script); } }; setTimeout(function() { head.insertBefore(script, head.firstChild); }, 0); // allows return to execute first return { done: function (cb) { events.done = function() { if (cb) { setTimeout(cb,0); } }; } }; }; var buildInfo = { buildFromMethodHash: function (obj) { var key; for(key in obj) { if (obj.hasOwnProperty(key)) { obj[key] = buildInfo[obj[key]](); } } return obj; }, timeZoneDST: function () { var DST = { "CHADT": "+1345", "NZDT": "+1300", "AEDT": "+1100", "ACDT": "+1030", "AZST": "+0500", "IRDT": "+0430", "EEST": "+0300", "CEST": "+0200", "BST": "+0100", "PMDT": "-0200", "ADT": "-0300", "NDT": "-0230", "EDT": "-0400", "CDT": "-0500", "MDT": "-0600", "PDT": "-0700", "AKDT": "-0800", "HADT": "-0900" }; return __(DST); }, timeZoneStandard: function () { var standard = { "LINT": "+1400", "TOT": "+1300", "CHAST": "+1245", "NZST": "+1200", "NFT": "+1130", "SBT": "+1100", "AEST": "+1000", "ACST": "+0930", "JST": "+0900", "CWST": "+0845", "CT": "+0800", "ICT": "+0700", "MMT": "+0630", "BST": "+0600", "NPT": "+0545", "IST": "+0530", "PKT": "+0500", "AFT": "+0430", "MSK": "+0400", "IRST": "+0330", "FET": "+0300", "EET": "+0200", "CET": "+0100", "GMT": "+0000", "UTC": "+0000", "CVT": "-0100", "GST": "-0200", "BRT": "-0300", "NST": "-0330", "AST": "-0400", "EST": "-0500", "CST": "-0600", "MST": "-0700", "PST": "-0800", "AKST": "-0900", "MIT": "-0930", "HST": "-1000", "SST": "-1100", "BIT": "-1200" }; return __(standard); }, timeZones: function (data) { var zone; data.timezones = []; for (zone in data.abbreviatedTimeZoneStandard) { if (data.abbreviatedTimeZoneStandard.hasOwnProperty(zone)) { data.timezones.push({ name: zone, offset: data.abbreviatedTimeZoneStandard[zone]}); } } for (zone in data.abbreviatedTimeZoneDST) { if (data.abbreviatedTimeZoneDST.hasOwnProperty(zone)) { data.timezones.push({ name: zone, offset: data.abbreviatedTimeZoneDST[zone], dst: true}); } } return data.timezones; }, days: function () { return __(["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"]); }, dayAbbr: function () { return __(["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"]); }, dayShortNames: function () { return __(["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"]); }, dayFirstLetters: function () { return __(["S_Sun_Initial", "M_Mon_Initial", "T_Tues_Initial", "W_Wed_Initial", "T_Thu_Initial", "F_Fri_Initial", "S_Sat_Initial"]); }, months: function () { return __(["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"]); }, monthAbbr: function () { return __(["Jan_Abbr", "Feb_Abbr", "Mar_Abbr", "Apr_Abbr", "May_Abbr", "Jun_Abbr", "Jul_Abbr", "Aug_Abbr", "Sep_Abbr", "Oct_Abbr", "Nov_Abbr", "Dec_Abbr"]); }, formatPatterns: function () { return getText.getFromObjectValues({ shortDate: "M/d/yyyy", longDate: "dddd, MMMM dd, yyyy", shortTime: "h:mm tt", longTime: "h:mm:ss tt", fullDateTime: "dddd, MMMM dd, yyyy h:mm:ss tt", sortableDateTime: "yyyy-MM-ddTHH:mm:ss", universalSortableDateTime: "yyyy-MM-dd HH:mm:ssZ", rfc1123: "ddd, dd MMM yyyy HH:mm:ss", monthDay: "MMMM dd", yearMonth: "MMMM, yyyy" }, Date.i18n.currentLanguage()); }, regex: function () { return getText.getFromObjectValues({ inTheMorning: "/( in the )(morn(ing)?)\\b/", thisMorning: "/(this )(morn(ing)?)\\b/", amThisMorning: "/(\b\\d(am)? )(this )(morn(ing)?)/", inTheEvening: "/( in the )(even(ing)?)\\b/", thisEvening: "/(this )(even(ing)?)\\b/", pmThisEvening: "/(\b\\d(pm)? )(this )(even(ing)?)/", jan: "/jan(uary)?/", feb: "/feb(ruary)?/", mar: "/mar(ch)?/", apr: "/apr(il)?/", may: "/may/", jun: "/jun(e)?/", jul: "/jul(y)?/", aug: "/aug(ust)?/", sep: "/sep(t(ember)?)?/", oct: "/oct(ober)?/", nov: "/nov(ember)?/", dec: "/dec(ember)?/", sun: "/^su(n(day)?)?/", mon: "/^mo(n(day)?)?/", tue: "/^tu(e(s(day)?)?)?/", wed: "/^we(d(nesday)?)?/", thu: "/^th(u(r(s(day)?)?)?)?/", fri: "/fr(i(day)?)?/", sat: "/^sa(t(urday)?)?/", future: "/^next/", past: "/^last|past|prev(ious)?/", add: "/^(\\+|aft(er)?|from|hence)/", subtract: "/^(\\-|bef(ore)?|ago)/", yesterday: "/^yes(terday)?/", today: "/^t(od(ay)?)?/", tomorrow: "/^tom(orrow)?/", now: "/^n(ow)?/", millisecond: "/^ms|milli(second)?s?/", second: "/^sec(ond)?s?/", minute: "/^mn|min(ute)?s?/", hour: "/^h(our)?s?/", week: "/^w(eek)?s?/", month: "/^m(onth)?s?/", day: "/^d(ay)?s?/", year: "/^y(ear)?s?/", shortMeridian: "/^(a|p)/", longMeridian: "/^(a\\.?m?\\.?|p\\.?m?\\.?)/", timezone: "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/", ordinalSuffix: "/^\\s*(st|nd|rd|th)/", timeContext: "/^\\s*(\\:|a(?!u|p)|p)/" }, Date.i18n.currentLanguage()); } }; var CultureInfo = function () { var info = getText.getFromObjectValues({ name: "name", englishName: "englishName", nativeName: "nativeName", amDesignator: "AM", pmDesignator: "PM", firstDayOfWeek: "firstDayOfWeek", twoDigitYearMax: "twoDigitYearMax", dateElementOrder: "mdy" }, Date.i18n.currentLanguage()); var constructedInfo = buildInfo.buildFromMethodHash({ dayNames: "days", abbreviatedDayNames: "dayAbbr", shortestDayNames: "dayShortNames", firstLetterDayNames: "dayFirstLetters", monthNames: "months", abbreviatedMonthNames: "monthAbbr", formatPatterns: "formatPatterns", regexPatterns: "regex", abbreviatedTimeZoneDST: "timeZoneDST", abbreviatedTimeZoneStandard: "timeZoneStandard" }); shallowMerge(info, constructedInfo); buildInfo.timeZones(info); return info; }; $D.i18n = { __: function (key, lang) { return __(key, lang); }, currentLanguage: function () { return lang || "en-US"; }, setLanguage: function (code, force, cb) { var async = false; if (force || code === "en-US" || (!!Date.CultureStrings && !!Date.CultureStrings[code])) { lang = code; Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings.lang = code; Date.CultureInfo = new CultureInfo(); } else { if (!(!!Date.CultureStrings && !!Date.CultureStrings[code])) { if (typeof exports !== "undefined" && this.exports !== exports) { // we're in a Node enviroment, load it using require try { require("../i18n/" + code + ".js"); lang = code; Date.CultureStrings.lang = code; Date.CultureInfo = new CultureInfo(); } catch (e) { // var str = "The language for '" + code + "' could not be loaded by Node. It likely does not exist."; throw new Error("The DateJS IETF language tag '" + code + "' could not be loaded by Node. It likely does not exist."); } } else if (Date.Config && Date.Config.i18n) { // we know the location of the files, so lets load them async = true; loadI18nScript(code).done(function(){ lang = code; Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings.lang = code; Date.CultureInfo = new CultureInfo(); $D.Parsing.Normalizer.buildReplaceData(); // because this is async if ($D.Grammar) { $D.Grammar.buildGrammarFormats(); // so we can parse those strings... } if (cb) { setTimeout(cb,0); } }); } else { Date.console.error("The DateJS IETF language tag '" + code + "' is not available and has not been loaded."); return false; } } } $D.Parsing.Normalizer.buildReplaceData(); // rebuild normalizer strings if ($D.Grammar) { $D.Grammar.buildGrammarFormats(); // so we can parse those strings... } if (!async && cb) { setTimeout(cb,0); } }, getLoggedKeys: function () { return loggedKeys; }, updateCultureInfo: function () { Date.CultureInfo = new CultureInfo(); } }; $D.i18n.updateCultureInfo(); // run automatically }()); (function () { var $D = Date, $P = $D.prototype, p = function (s, l) { if (!l) { l = 2; } return ("000" + s).slice(l * -1); }; if (typeof window !== "undefined" && typeof window.console !== "undefined" && typeof window.console.log !== "undefined") { $D.console = console; // used only to raise non-critical errors if available } else { // set mock so we don't give errors. $D.console = { log: function(){}, error: function(){} }; } $D.Config = $D.Config || {}; $D.initOverloads = function() { /** * Overload of Date.now. Allows an alternate call for Date.now where it returns the * current Date as an object rather than just milliseconds since the Unix Epoch. * * Also provides an implementation of now() for browsers (IE<9) that don't have it. * * Backwards compatible so with work with either: * Date.now() [returns ms] * or * Date.now(true) [returns Date] */ if (!$D.now) { $D._now = function now() { return new Date().getTime(); }; } else if (!$D._now) { $D._now = $D.now; } $D.now = function (returnObj) { if (returnObj) { return $D.present(); } else { return $D._now(); } }; if ( !$P.toISOString ) { $P.toISOString = function() { return this.getUTCFullYear() + "-" + p(this.getUTCMonth() + 1) + "-" + p(this.getUTCDate()) + "T" + p(this.getUTCHours()) + ":" + p(this.getUTCMinutes()) + ":" + p(this.getUTCSeconds()) + "." + String( (this.getUTCMilliseconds()/1000).toFixed(3)).slice(2, 5) + "Z"; }; } // private if ( $P._toString === undefined ){ $P._toString = $P.toString; } }; $D.initOverloads(); /** * Gets a date that is set to the current date. The time is set to the start of the day (00:00 or 12:00 AM). * @return {Date} The current date. */ $D.today = function () { return new Date().clearTime(); }; /** * Gets a date that is set to the current date and time (same as new Date, but chainable) * @return {Date} The current date. */ $D.present = function () { return new Date(); }; /** * Compares the first date to the second date and returns an number indication of their relative values. * @param {Date} First Date object to compare [Required]. * @param {Date} Second Date object to compare to [Required]. * @return {Number} -1 = date1 is lessthan date2. 0 = values are equal. 1 = date1 is greaterthan date2. */ $D.compare = function (date1, date2) { if (isNaN(date1) || isNaN(date2)) { throw new Error(date1 + " - " + date2); } else if (date1 instanceof Date && date2 instanceof Date) { return (date1 < date2) ? -1 : (date1 > date2) ? 1 : 0; } else { throw new TypeError(date1 + " - " + date2); } }; /** * Compares the first Date object to the second Date object and returns true if they are equal. * @param {Date} First Date object to compare [Required] * @param {Date} Second Date object to compare to [Required] * @return {Boolean} true if dates are equal. false if they are not equal. */ $D.equals = function (date1, date2) { return (date1.compareTo(date2) === 0); }; /** * Gets the language appropriate day name when given the day number(0-6) * eg - 0 == Sunday * @return {String} The day name */ $D.getDayName = function (n) { return Date.CultureInfo.dayNames[n]; }; /** * Gets the day number (0-6) if given a CultureInfo specific string which is a valid dayName, abbreviatedDayName or shortestDayName (two char). * @param {String} The name of the day (eg. "Monday, "Mon", "tuesday", "tue", "We", "we"). * @return {Number} The day number */ $D.getDayNumberFromName = function (name) { var n = Date.CultureInfo.dayNames, m = Date.CultureInfo.abbreviatedDayNames, o = Date.CultureInfo.shortestDayNames, s = name.toLowerCase(); for (var i = 0; i < n.length; i++) { if (n[i].toLowerCase() === s || m[i].toLowerCase() === s || o[i].toLowerCase() === s) { return i; } } return -1; }; /** * Gets the month number (0-11) if given a Culture Info specific string which is a valid monthName or abbreviatedMonthName. * @param {String} The name of the month (eg. "February, "Feb", "october", "oct"). * @return {Number} The day number */ $D.getMonthNumberFromName = function (name) { var n = Date.CultureInfo.monthNames, m = Date.CultureInfo.abbreviatedMonthNames, s = name.toLowerCase(); for (var i = 0; i < n.length; i++) { if (n[i].toLowerCase() === s || m[i].toLowerCase() === s) { return i; } } return -1; }; /** * Gets the language appropriate month name when given the month number(0-11) * eg - 0 == January * @return {String} The month name */ $D.getMonthName = function (n) { return Date.CultureInfo.monthNames[n]; }; /** * Determines if the current date instance is within a LeapYear. * @param {Number} The year. * @return {Boolean} true if date is within a LeapYear, otherwise false. */ $D.isLeapYear = function (year) { return ((year % 4 === 0 && year % 100 !== 0) || year % 400 === 0); }; /** * Gets the number of days in the month, given a year and month value. Automatically corrects for LeapYear. * @param {Number} The year. * @param {Number} The month (0-11). * @return {Number} The number of days in the month. */ $D.getDaysInMonth = function (year, month) { if (!month && $D.validateMonth(year)) { month = year; year = Date.today().getFullYear(); } return [31, ($D.isLeapYear(year) ? 29 : 28), 31, 30, 31, 30, 31, 31, 30, 31, 30, 31][month]; }; $P.getDaysInMonth = function () { return $D.getDaysInMonth(this.getFullYear(), this.getMonth()); }; $D.getTimezoneAbbreviation = function (offset, dst) { var p, n = (dst || false) ? Date.CultureInfo.abbreviatedTimeZoneDST : Date.CultureInfo.abbreviatedTimeZoneStandard; for (p in n) { if (n.hasOwnProperty(p)) { if (n[p] === offset) { return p; } } } return null; }; $D.getTimezoneOffset = function (name, dst) { var i, a =[], z = Date.CultureInfo.timezones; if (!name) { name = (new Date()).getTimezone();} for (i = 0; i < z.length; i++) { if (z[i].name === name.toUpperCase()) { a.push(i); } } if (!z[a[0]]) { return null; } if (a.length === 1 || !dst) { return z[a[0]].offset; } else { for (i=0; i < a.length; i++) { if (z[a[i]].dst) { return z[a[i]].offset; } } } }; $D.getQuarter = function (d) { d = d || new Date(); // If no date supplied, use today var q = [1,2,3,4]; return q[Math.floor(d.getMonth() / 3)]; // ~~~ is a bitwise op. Faster than Math.floor }; $D.getDaysLeftInQuarter = function (d) { d = d || new Date(); var qEnd = new Date(d); qEnd.setMonth(qEnd.getMonth() + 3 - qEnd.getMonth() % 3, 0); return Math.floor((qEnd - d) / 8.64e7); }; // private var validate = function (n, min, max, name) { name = name ? name : "Object"; if (typeof n === "undefined") { return false; } else if (typeof n !== "number") { throw new TypeError(n + " is not a Number."); } else if (n < min || n > max) { // As failing validation is *not* an exceptional circumstance // lets not throw a RangeError Exception here. // It's semantically correct but it's not sensible. return false; } return true; }; /** * Validates the number is within an acceptable range for milliseconds [0-999]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateMillisecond = function (value) { return validate(value, 0, 999, "millisecond"); }; /** * Validates the number is within an acceptable range for seconds [0-59]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateSecond = function (value) { return validate(value, 0, 59, "second"); }; /** * Validates the number is within an acceptable range for minutes [0-59]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateMinute = function (value) { return validate(value, 0, 59, "minute"); }; /** * Validates the number is within an acceptable range for hours [0-23]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateHour = function (value) { return validate(value, 0, 23, "hour"); }; /** * Validates the number is within an acceptable range for the days in a month [0-MaxDaysInMonth]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateDay = function (value, year, month) { if (year === undefined || year === null || month === undefined || month === null) { return false;} return validate(value, 1, $D.getDaysInMonth(year, month), "day"); }; /** * Validates the number is within an acceptable range for months [0-11]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateWeek = function (value) { return validate(value, 0, 53, "week"); }; /** * Validates the number is within an acceptable range for months [0-11]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateMonth = function (value) { return validate(value, 0, 11, "month"); }; /** * Validates the number is within an acceptable range for years. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateYear = function (value) { /** * Per ECMAScript spec the range of times supported by Date objects is * exactly -100,000,000 days to +100,000,000 days measured relative to * midnight at the beginning of 01 January, 1970 UTC. * This gives a range of 8,640,000,000,000,000 milliseconds to either * side of 01 January, 1970 UTC. * * Earliest possible date: Tue, 20 Apr 271,822 B.C. 00:00:00 UTC * Latest possible date: Sat, 13 Sep 275,760 00:00:00 UTC */ return validate(value, -271822, 275760, "year"); }; $D.validateTimezone = function(value) { var timezones = {"ACDT":1,"ACST":1,"ACT":1,"ADT":1,"AEDT":1,"AEST":1,"AFT":1,"AKDT":1,"AKST":1,"AMST":1,"AMT":1,"ART":1,"AST":1,"AWDT":1,"AWST":1,"AZOST":1,"AZT":1,"BDT":1,"BIOT":1,"BIT":1,"BOT":1,"BRT":1,"BST":1,"BTT":1,"CAT":1,"CCT":1,"CDT":1,"CEDT":1,"CEST":1,"CET":1,"CHADT":1,"CHAST":1,"CHOT":1,"ChST":1,"CHUT":1,"CIST":1,"CIT":1,"CKT":1,"CLST":1,"CLT":1,"COST":1,"COT":1,"CST":1,"CT":1,"CVT":1,"CWST":1,"CXT":1,"DAVT":1,"DDUT":1,"DFT":1,"EASST":1,"EAST":1,"EAT":1,"ECT":1,"EDT":1,"EEDT":1,"EEST":1,"EET":1,"EGST":1,"EGT":1,"EIT":1,"EST":1,"FET":1,"FJT":1,"FKST":1,"FKT":1,"FNT":1,"GALT":1,"GAMT":1,"GET":1,"GFT":1,"GILT":1,"GIT":1,"GMT":1,"GST":1,"GYT":1,"HADT":1,"HAEC":1,"HAST":1,"HKT":1,"HMT":1,"HOVT":1,"HST":1,"ICT":1,"IDT":1,"IOT":1,"IRDT":1,"IRKT":1,"IRST":1,"IST":1,"JST":1,"KGT":1,"KOST":1,"KRAT":1,"KST":1,"LHST":1,"LINT":1,"MAGT":1,"MART":1,"MAWT":1,"MDT":1,"MET":1,"MEST":1,"MHT":1,"MIST":1,"MIT":1,"MMT":1,"MSK":1,"MST":1,"MUT":1,"MVT":1,"MYT":1,"NCT":1,"NDT":1,"NFT":1,"NPT":1,"NST":1,"NT":1,"NUT":1,"NZDT":1,"NZST":1,"OMST":1,"ORAT":1,"PDT":1,"PET":1,"PETT":1,"PGT":1,"PHOT":1,"PHT":1,"PKT":1,"PMDT":1,"PMST":1,"PONT":1,"PST":1,"PYST":1,"PYT":1,"RET":1,"ROTT":1,"SAKT":1,"SAMT":1,"SAST":1,"SBT":1,"SCT":1,"SGT":1,"SLST":1,"SRT":1,"SST":1,"SYOT":1,"TAHT":1,"THA":1,"TFT":1,"TJT":1,"TKT":1,"TLT":1,"TMT":1,"TOT":1,"TVT":1,"UCT":1,"ULAT":1,"UTC":1,"UYST":1,"UYT":1,"UZT":1,"VET":1,"VLAT":1,"VOLT":1,"VOST":1,"VUT":1,"WAKT":1,"WAST":1,"WAT":1,"WEDT":1,"WEST":1,"WET":1,"WST":1,"YAKT":1,"YEKT":1,"Z":1}; return (timezones[value] === 1); }; $D.validateTimezoneOffset= function(value) { // timezones go from +14hrs to -12hrs, the +X hours are negative offsets. return (value > -841 && value < 721); }; }()); (function () { var $D = Date, $P = $D.prototype, p = function (s, l) { if (!l) { l = 2; } return ("000" + s).slice(l * -1); }; var validateConfigObject = function (obj) { var result = {}, self = this, prop, testFunc; testFunc = function (prop, func, value) { if (prop === "day") { var month = (obj.month !== undefined) ? obj.month : self.getMonth(); var year = (obj.year !== undefined) ? obj.year : self.getFullYear(); return $D[func](value, year, month); } else { return $D[func](value); } }; for (prop in obj) { if (Object.prototype.hasOwnProperty.call(obj, prop)) { var func = "validate" + prop.charAt(0).toUpperCase() + prop.slice(1); if ($D[func] && obj[prop] !== null && testFunc(prop, func, obj[prop])) { result[prop] = obj[prop]; } } } return result; }; /** * Resets the time of this Date object to 12:00 AM (00:00), which is the start of the day. * @param {Boolean} .clone() this date instance before clearing Time * @return {Date} this */ $P.clearTime = function () { this.setHours(0); this.setMinutes(0); this.setSeconds(0); this.setMilliseconds(0); return this; }; /** * Resets the time of this Date object to the current time ('now'). * @return {Date} this */ $P.setTimeToNow = function () { var n = new Date(); this.setHours(n.getHours()); this.setMinutes(n.getMinutes()); this.setSeconds(n.getSeconds()); this.setMilliseconds(n.getMilliseconds()); return this; }; /** * Returns a new Date object that is an exact date and time copy of the original instance. * @return {Date} A new Date instance */ $P.clone = function () { return new Date(this.getTime()); }; /** * Compares this instance to a Date object and returns an number indication of their relative values. * @param {Date} Date object to compare [Required] * @return {Number} -1 = this is lessthan date. 0 = values are equal. 1 = this is greaterthan date. */ $P.compareTo = function (date) { return Date.compare(this, date); }; /** * Compares this instance to another Date object and returns true if they are equal. * @param {Date} Date object to compare. If no date to compare, new Date() [now] is used. * @return {Boolean} true if dates are equal. false if they are not equal. */ $P.equals = function (date) { return Date.equals(this, (date !== undefined ? date : new Date())); }; /** * Determines if this instance is between a range of two dates or equal to either the start or end dates. * @param {Date} Start of range [Required] * @param {Date} End of range [Required] * @return {Boolean} true is this is between or equal to the start and end dates, else false */ $P.between = function (start, end) { return this.getTime() >= start.getTime() && this.getTime() <= end.getTime(); }; /** * Determines if this date occurs after the date to compare to. * @param {Date} Date object to compare. If no date to compare, new Date() ("now") is used. * @return {Boolean} true if this date instance is greater than the date to compare to (or "now"), otherwise false. */ $P.isAfter = function (date) { return this.compareTo(date || new Date()) === 1; }; /** * Determines if this date occurs before the date to compare to. * @param {Date} Date object to compare. If no date to compare, new Date() ("now") is used. * @return {Boolean} true if this date instance is less than the date to compare to (or "now"). */ $P.isBefore = function (date) { return (this.compareTo(date || new Date()) === -1); }; /** * Determines if the current Date instance occurs today. * @return {Boolean} true if this date instance is 'today', otherwise false. */ /** * Determines if the current Date instance occurs on the same Date as the supplied 'date'. * If no 'date' to compare to is provided, the current Date instance is compared to 'today'. * @param {date} Date object to compare. If no date to compare, the current Date ("now") is used. * @return {Boolean} true if this Date instance occurs on the same Day as the supplied 'date'. */ $P.isToday = $P.isSameDay = function (date) { return this.clone().clearTime().equals((date || new Date()).clone().clearTime()); }; /** * Adds the specified number of milliseconds to this instance. * @param {Number} The number of milliseconds to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addMilliseconds = function (value) { if (!value) { return this; } this.setTime(this.getTime() + value * 1); return this; }; /** * Adds the specified number of seconds to this instance. * @param {Number} The number of seconds to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addSeconds = function (value) { if (!value) { return this; } return this.addMilliseconds(value * 1000); }; /** * Adds the specified number of seconds to this instance. * @param {Number} The number of seconds to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addMinutes = function (value) { if (!value) { return this; } return this.addMilliseconds(value * 60000); // 60*1000 }; /** * Adds the specified number of hours to this instance. * @param {Number} The number of hours to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addHours = function (value) { if (!value) { return this; } return this.addMilliseconds(value * 3600000); // 60*60*1000 }; /** * Adds the specified number of days to this instance. * @param {Number} The number of days to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addDays = function (value) { if (!value) { return this; } this.setDate(this.getDate() + value * 1); return this; }; /** * Adds the specified number of weekdays (ie - not sat or sun) to this instance. * @param {Number} The number of days to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addWeekdays = function (value) { if (!value) { return this; } var day = this.getDay(); var weeks = (Math.ceil(Math.abs(value)/7)); if (day === 0 || day === 6) { if (value > 0) { this.next().monday(); this.addDays(-1); day = this.getDay(); } } if (value < 0) { while (value < 0) { this.addDays(-1); day = this.getDay(); if (day !== 0 && day !== 6) { value++; } } return this; } else if (value > 5 || (6-day) <= value) { value = value + (weeks * 2); } return this.addDays(value); }; /** * Adds the specified number of weeks to this instance. * @param {Number} The number of weeks to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addWeeks = function (value) { if (!value) { return this; } return this.addDays(value * 7); }; /** * Adds the specified number of months to this instance. * @param {Number} The number of months to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addMonths = function (value) { if (!value) { return this; } var n = this.getDate(); this.setDate(1); this.setMonth(this.getMonth() + value * 1); this.setDate(Math.min(n, $D.getDaysInMonth(this.getFullYear(), this.getMonth()))); return this; }; $P.addQuarters = function (value) { if (!value) { return this; } // note this will take you to the same point in the quarter as you are now. // i.e. - if you are 15 days into the quarter you'll be 15 days into the resulting one. // bonus: this allows adding fractional quarters return this.addMonths(value * 3); }; /** * Adds the specified number of years to this instance. * @param {Number} The number of years to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addYears = function (value) { if (!value) { return this; } return this.addMonths(value * 12); }; /** * Adds (or subtracts) to the value of the years, months, weeks, days, hours, minutes, seconds, milliseconds of the date instance using given configuration object. Positive and Negative values allowed. * Example

	Date.today().add( { days: 1, months: 1 } )

	new Date().add( { years: -1 } )
	
* @param {Object} Configuration object containing attributes (months, days, etc.) * @return {Date} this */ $P.add = function (config) { if (typeof config === "number") { this._orient = config; return this; } var x = config; if (x.day) { // If we should be a different date than today (eg: for 'tomorrow -1d', etc). // Should only effect parsing, not direct usage (eg, Finish and FinishExact) if ((x.day - this.getDate()) !== 0) { this.setDate(x.day); } } if (x.milliseconds) { this.addMilliseconds(x.milliseconds); } if (x.seconds) { this.addSeconds(x.seconds); } if (x.minutes) { this.addMinutes(x.minutes); } if (x.hours) { this.addHours(x.hours); } if (x.weeks) { this.addWeeks(x.weeks); } if (x.months) { this.addMonths(x.months); } if (x.years) { this.addYears(x.years); } if (x.days) { this.addDays(x.days); } return this; }; /** * Get the week number. Week one (1) is the week which contains the first Thursday of the year. Monday is considered the first day of the week. * The .getWeek() function does NOT convert the date to UTC. The local datetime is used. * Please use .getISOWeek() to get the week of the UTC converted date. * @return {Number} 1 to 53 */ $P.getWeek = function (utc) { // Create a copy of this date object var self, target = new Date(this.valueOf()); if (utc) { target.addMinutes(target.getTimezoneOffset()); self = target.clone(); } else { self = this; } // ISO week date weeks start on monday // so correct the day number var dayNr = (self.getDay() + 6) % 7; // ISO 8601 states that week 1 is the week // with the first thursday of that year. // Set the target date to the thursday in the target week target.setDate(target.getDate() - dayNr + 3); // Store the millisecond value of the target date var firstThursday = target.valueOf(); // Set the target to the first thursday of the year // First set the target to january first target.setMonth(0, 1); // Not a thursday? Correct the date to the next thursday if (target.getDay() !== 4) { target.setMonth(0, 1 + ((4 - target.getDay()) + 7) % 7); } // The weeknumber is the number of weeks between the // first thursday of the year and the thursday in the target week return 1 + Math.ceil((firstThursday - target) / 604800000); // 604800000 = 7 * 24 * 3600 * 1000 }; /** * Get the ISO 8601 week number. Week one ("01") is the week which contains the first Thursday of the year. Monday is considered the first day of the week. * The .getISOWeek() function does convert the date to it's UTC value. Please use .getWeek() to get the week of the local date. * @return {String} "01" to "53" */ $P.getISOWeek = function () { return p(this.getWeek(true)); }; /** * Moves the date to Monday of the week set. Week one (1) is the week which contains the first Thursday of the year. * @param {Number} A Number (1 to 53) that represents the week of the year. * @return {Date} this */ $P.setWeek = function (n) { if ((n - this.getWeek()) === 0) { if (this.getDay() !== 1) { return this.moveToDayOfWeek(1, (this.getDay() > 1 ? -1 : 1)); } else { return this; } } else { return this.moveToDayOfWeek(1, (this.getDay() > 1 ? -1 : 1)).addWeeks(n - this.getWeek()); } }; $P.setQuarter = function (qtr) { var month = Math.abs(((qtr-1) * 3) + 1); return this.setMonth(month, 1); }; $P.getQuarter = function () { return Date.getQuarter(this); }; $P.getDaysLeftInQuarter = function () { return Date.getDaysLeftInQuarter(this); }; /** * Moves the date to the next n'th occurrence of the dayOfWeek starting from the beginning of the month. The number (-1) is a magic number and will return the last occurrence of the dayOfWeek in the month. * @param {Number} The dayOfWeek to move to * @param {Number} The n'th occurrence to move to. Use (-1) to return the last occurrence in the month * @return {Date} this */ $P.moveToNthOccurrence = function (dayOfWeek, occurrence) { if (dayOfWeek === "Weekday") { if (occurrence > 0) { this.moveToFirstDayOfMonth(); if (this.is().weekday()) { occurrence -= 1; } } else if (occurrence < 0) { this.moveToLastDayOfMonth(); if (this.is().weekday()) { occurrence += 1; } } else { return this; } return this.addWeekdays(occurrence); } var shift = 0; if (occurrence > 0) { shift = occurrence - 1; } else if (occurrence === -1) { this.moveToLastDayOfMonth(); if (this.getDay() !== dayOfWeek) { this.moveToDayOfWeek(dayOfWeek, -1); } return this; } return this.moveToFirstDayOfMonth().addDays(-1).moveToDayOfWeek(dayOfWeek, +1).addWeeks(shift); }; var moveToN = function (getFunc, addFunc, nVal) { return function (value, orient) { var diff = (value - this[getFunc]() + nVal * (orient || +1)) % nVal; return this[addFunc]((diff === 0) ? diff += nVal * (orient || +1) : diff); }; }; /** * Move to the next or last dayOfWeek based on the orient value. * @param {Number} The dayOfWeek to move to * @param {Number} Forward (+1) or Back (-1). Defaults to +1. [Optional] * @return {Date} this */ $P.moveToDayOfWeek = moveToN("getDay", "addDays", 7); /** * Move to the next or last month based on the orient value. * @param {Number} The month to move to. 0 = January, 11 = December * @param {Number} Forward (+1) or Back (-1). Defaults to +1. [Optional] * @return {Date} this */ $P.moveToMonth = moveToN("getMonth", "addMonths", 12); /** * Get the Ordinate of the current day ("th", "st", "rd"). * @return {String} */ $P.getOrdinate = function () { var num = this.getDate(); return ord(num); }; /** * Get the Ordinal day (numeric day number) of the year, adjusted for leap year. * @return {Number} 1 through 365 (366 in leap years) */ $P.getOrdinalNumber = function () { return Math.ceil((this.clone().clearTime() - new Date(this.getFullYear(), 0, 1)) / 86400000) + 1; }; /** * Get the time zone abbreviation of the current date. * @return {String} The abbreviated time zone name (e.g. "EST") */ $P.getTimezone = function () { return $D.getTimezoneAbbreviation(this.getUTCOffset(), this.isDaylightSavingTime()); }; $P.setTimezoneOffset = function (offset) { var here = this.getTimezoneOffset(), there = Number(offset) * -6 / 10; return (there || there === 0) ? this.addMinutes(there - here) : this; }; $P.setTimezone = function (offset) { return this.setTimezoneOffset($D.getTimezoneOffset(offset)); }; /** * Indicates whether Daylight Saving Time is observed in the current time zone. * @return {Boolean} true|false */ $P.hasDaylightSavingTime = function () { return (Date.today().set({month: 0, day: 1}).getTimezoneOffset() !== Date.today().set({month: 6, day: 1}).getTimezoneOffset()); }; /** * Indicates whether this Date instance is within the Daylight Saving Time range for the current time zone. * @return {Boolean} true|false */ $P.isDaylightSavingTime = function () { return Date.today().set({month: 0, day: 1}).getTimezoneOffset() !== this.getTimezoneOffset(); }; /** * Get the offset from UTC of the current date. * @return {String} The 4-character offset string prefixed with + or - (e.g. "-0500") */ $P.getUTCOffset = function (offset) { var n = (offset || this.getTimezoneOffset()) * -10 / 6, r; if (n < 0) { r = (n - 10000).toString(); return r.charAt(0) + r.substr(2); } else { r = (n + 10000).toString(); return "+" + r.substr(1); } }; /** * Returns the number of milliseconds between this date and date. * @param {Date} Defaults to now * @return {Number} The diff in milliseconds */ $P.getElapsed = function (date) { return (date || new Date()) - this; }; /** * Set the value of year, month, day, hour, minute, second, millisecond of date instance using given configuration object. * Example

	Date.today().set( { day: 20, month: 1 } )

	new Date().set( { millisecond: 0 } )
	
* * @param {Object} Configuration object containing attributes (month, day, etc.) * @return {Date} this */ $P.set = function (config) { config = validateConfigObject.call(this, config); var key; for (key in config) { if (Object.prototype.hasOwnProperty.call(config, key)) { var name = key.charAt(0).toUpperCase() + key.slice(1); var addFunc, getFunc; if (key !== "week" && key !== "month" && key !== "timezone" && key !== "timezoneOffset") { name += "s"; } addFunc = "add" + name; getFunc = "get" + name; if (key === "month") { addFunc = addFunc + "s"; } else if (key === "year"){ getFunc = "getFullYear"; } if (key !== "day" && key !== "timezone" && key !== "timezoneOffset" && key !== "week" && key !== "hour") { this[addFunc](config[key] - this[getFunc]()); } else if ( key === "timezone"|| key === "timezoneOffset" || key === "week" || key === "hour") { this["set"+name](config[key]); } } } // day has to go last because you can't validate the day without first knowing the month if (config.day) { this.addDays(config.day - this.getDate()); } return this; }; /** * Moves the date to the first day of the month. * @return {Date} this */ $P.moveToFirstDayOfMonth = function () { return this.set({ day: 1 }); }; /** * Moves the date to the last day of the month. * @return {Date} this */ $P.moveToLastDayOfMonth = function () { return this.set({ day: $D.getDaysInMonth(this.getFullYear(), this.getMonth())}); }; /** * Converts the value of the current Date object to its equivalent string representation. * Format Specifiers * CUSTOM DATE AND TIME FORMAT STRINGS * Format Description Example * ------ --------------------------------------------------------------------------- ----------------------- * s The seconds of the minute between 0-59. "0" to "59" * ss The seconds of the minute with leading zero if required. "00" to "59" * * m The minute of the hour between 0-59. "0" or "59" * mm The minute of the hour with leading zero if required. "00" or "59" * * h The hour of the day between 1-12. "1" to "12" * hh The hour of the day with leading zero if required. "01" to "12" * * H The hour of the day between 0-23. "0" to "23" * HH The hour of the day with leading zero if required. "00" to "23" * * d The day of the month between 1 and 31. "1" to "31" * dd The day of the month with leading zero if required. "01" to "31" * ddd Abbreviated day name. Date.CultureInfo.abbreviatedDayNames. "Mon" to "Sun" * dddd The full day name. Date.CultureInfo.dayNames. "Monday" to "Sunday" * * M The month of the year between 1-12. "1" to "12" * MM The month of the year with leading zero if required. "01" to "12" * MMM Abbreviated month name. Date.CultureInfo.abbreviatedMonthNames. "Jan" to "Dec" * MMMM The full month name. Date.CultureInfo.monthNames. "January" to "December" * * yy The year as a two-digit number. "99" or "08" * yyyy The full four digit year. "1999" or "2008" * * t Displays the first character of the A.M./P.M. designator. "A" or "P" * Date.CultureInfo.amDesignator or Date.CultureInfo.pmDesignator * tt Displays the A.M./P.M. designator. "AM" or "PM" * Date.CultureInfo.amDesignator or Date.CultureInfo.pmDesignator * * S The ordinal suffix ("st, "nd", "rd" or "th") of the current day. "st, "nd", "rd" or "th" * * STANDARD DATE AND TIME FORMAT STRINGS * Format Description Example *------ --------------------------------------------------------------------------- ----------------------- * d The CultureInfo shortDate Format Pattern "M/d/yyyy" * D The CultureInfo longDate Format Pattern "dddd, MMMM dd, yyyy" * F The CultureInfo fullDateTime Format Pattern "dddd, MMMM dd, yyyy h:mm:ss tt" * m The CultureInfo monthDay Format Pattern "MMMM dd" * r The CultureInfo rfc1123 Format Pattern "ddd, dd MMM yyyy HH:mm:ss GMT" * s The CultureInfo sortableDateTime Format Pattern "yyyy-MM-ddTHH:mm:ss" * t The CultureInfo shortTime Format Pattern "h:mm tt" * T The CultureInfo longTime Format Pattern "h:mm:ss tt" * u The CultureInfo universalSortableDateTime Format Pattern "yyyy-MM-dd HH:mm:ssZ" * y The CultureInfo yearMonth Format Pattern "MMMM, yyyy" * * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @return {String} A string representation of the current Date object. */ var ord = function (n) { switch (n * 1) { case 1: case 21: case 31: return "st"; case 2: case 22: return "nd"; case 3: case 23: return "rd"; default: return "th"; } }; var parseStandardFormats = function (format) { var y, c = Date.CultureInfo.formatPatterns; switch (format) { case "d": return this.toString(c.shortDate); case "D": return this.toString(c.longDate); case "F": return this.toString(c.fullDateTime); case "m": return this.toString(c.monthDay); case "r": case "R": y = this.clone().addMinutes(this.getTimezoneOffset()); return y.toString(c.rfc1123) + " GMT"; case "s": return this.toString(c.sortableDateTime); case "t": return this.toString(c.shortTime); case "T": return this.toString(c.longTime); case "u": y = this.clone().addMinutes(this.getTimezoneOffset()); return y.toString(c.universalSortableDateTime); case "y": return this.toString(c.yearMonth); default: return false; } }; var parseFormatStringsClosure = function (context) { return function (m) { if (m.charAt(0) === "\\") { return m.replace("\\", ""); } switch (m) { case "hh": return p(context.getHours() < 13 ? (context.getHours() === 0 ? 12 : context.getHours()) : (context.getHours() - 12)); case "h": return context.getHours() < 13 ? (context.getHours() === 0 ? 12 : context.getHours()) : (context.getHours() - 12); case "HH": return p(context.getHours()); case "H": return context.getHours(); case "mm": return p(context.getMinutes()); case "m": return context.getMinutes(); case "ss": return p(context.getSeconds()); case "s": return context.getSeconds(); case "yyyy": return p(context.getFullYear(), 4); case "yy": return p(context.getFullYear()); case "y": return context.getFullYear(); case "E": case "dddd": return Date.CultureInfo.dayNames[context.getDay()]; case "ddd": return Date.CultureInfo.abbreviatedDayNames[context.getDay()]; case "dd": return p(context.getDate()); case "d": return context.getDate(); case "MMMM": return Date.CultureInfo.monthNames[context.getMonth()]; case "MMM": return Date.CultureInfo.abbreviatedMonthNames[context.getMonth()]; case "MM": return p((context.getMonth() + 1)); case "M": return context.getMonth() + 1; case "t": return context.getHours() < 12 ? Date.CultureInfo.amDesignator.substring(0, 1) : Date.CultureInfo.pmDesignator.substring(0, 1); case "tt": return context.getHours() < 12 ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator; case "S": return ord(context.getDate()); case "W": return context.getWeek(); case "WW": return context.getISOWeek(); case "Q": return "Q" + context.getQuarter(); case "q": return String(context.getQuarter()); case "z": return context.getTimezone(); case "Z": case "X": return Date.getTimezoneOffset(context.getTimezone()); case "ZZ": // Timezone offset in seconds return context.getTimezoneOffset() * -60; case "u": return context.getDay(); case "L": return ($D.isLeapYear(context.getFullYear())) ? 1 : 0; case "B": // Swatch Internet Time (.beats) return "@"+((context.getUTCSeconds() + (context.getUTCMinutes()*60) + ((context.getUTCHours()+1)*3600))/86.4); default: return m; } }; }; $P.toString = function (format, ignoreStandards) { // Standard Date and Time Format Strings. Formats pulled from CultureInfo file and // may vary by culture. if (!ignoreStandards && format && format.length === 1) { output = parseStandardFormats.call(this, format); if (output) { return output; } } var parseFormatStrings = parseFormatStringsClosure(this); return format ? format.replace(/((\\)?(dd?d?d?|MM?M?M?|yy?y?y?|hh?|HH?|mm?|ss?|tt?|S|q|Q|WW?W?W?)(?![^\[]*\]))/g, parseFormatStrings).replace(/\[|\]/g, "") : this._toString(); }; }()); /************************************************************* * SugarPak - Domain Specific Language - Syntactical Sugar * *************************************************************/ (function () { var $D = Date, $P = $D.prototype, $N = Number.prototype; // private $P._orient = +1; // private $P._nth = null; // private $P._is = false; // private $P._same = false; // private $P._isSecond = false; // private $N._dateElement = "days"; /** * Moves the date to the next instance of a date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.today().next().friday();
	Date.today().next().fri();
	Date.today().next().march();
	Date.today().next().mar();
	Date.today().next().week();
	
* * @return {Date} date */ $P.next = function () { this._move = true; this._orient = +1; return this; }; /** * Creates a new Date (Date.today()) and moves the date to the next instance of the date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.next().friday();
	Date.next().fri();
	Date.next().march();
	Date.next().mar();
	Date.next().week();
	
* * @return {Date} date */ $D.next = function () { return $D.today().next(); }; /** * Moves the date to the previous instance of a date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.today().last().friday();
	Date.today().last().fri();
	Date.today().last().march();
	Date.today().last().mar();
	Date.today().last().week();
	
* * @return {Date} date */ $P.last = $P.prev = $P.previous = function () { this._move = true; this._orient = -1; return this; }; /** * Creates a new Date (Date.today()) and moves the date to the previous instance of the date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.last().friday();
	Date.last().fri();
	Date.previous().march();
	Date.prev().mar();
	Date.last().week();
	
* * @return {Date} date */ $D.last = $D.prev = $D.previous = function () { return $D.today().last(); }; /** * Performs a equality check when followed by either a month name, day name or .weekday() function. * Example

	Date.today().is().friday(); // true|false
	Date.today().is().fri();
	Date.today().is().march();
	Date.today().is().mar();
	
* * @return {Boolean} true|false */ $P.is = function () { this._is = true; return this; }; /** * Determines if two date objects occur on/in exactly the same instance of the subsequent date part function. * The function .same() must be followed by a date part function (example: .day(), .month(), .year(), etc). * * An optional Date can be passed in the date part function. If now date is passed as a parameter, 'Now' is used. * * The following example demonstrates how to determine if two dates fall on the exact same day. * * Example

	var d1 = Date.today(); // today at 00:00
	var d2 = new Date();   // exactly now.

	// Do they occur on the same day?
	d1.same().day(d2); // true
	
	// Do they occur on the same hour?
	d1.same().hour(d2); // false, unless d2 hour is '00' (midnight).
	
	// What if it's the same day, but one year apart?
	var nextYear = Date.today().add(1).year();

	d1.same().day(nextYear); // false, because the dates must occur on the exact same day. 
	
* * Scenario: Determine if a given date occurs during some week period 2 months from now. * * Example

	var future = Date.today().add(2).months();
	return someDate.same().week(future); // true|false;
	
* * @return {Boolean} true|false */ $P.same = function () { this._same = true; this._isSecond = false; return this; }; /** * Determines if the current date/time occurs during Today. Must be preceded by the .is() function. * Example

	someDate.is().today();    // true|false
	new Date().is().today();  // true
	Date.today().is().today();// true
	Date.today().add(-1).day().is().today(); // false
	
* * @return {Boolean} true|false */ $P.today = function () { return this.same().day(); }; /** * Determines if the current date is a weekday. This function must be preceded by the .is() function. * Example

	Date.today().is().weekday(); // true|false
	
* * @return {Boolean} true|false */ $P.weekday = function () { if (this._nth) { return df("Weekday").call(this); } if (this._move) { return this.addWeekdays(this._orient); } if (this._is) { this._is = false; return (!this.is().sat() && !this.is().sun()); } return false; }; /** * Determines if the current date is on the weekend. This function must be preceded by the .is() function. * Example

	Date.today().is().weekend(); // true|false
	
* * @return {Boolean} true|false */ $P.weekend = function () { if (this._is) { this._is = false; return (this.is().sat() || this.is().sun()); } return false; }; /** * Sets the Time of the current Date instance. A string "6:15 pm" or config object {hour:18, minute:15} are accepted. * Example

	// Set time to 6:15pm with a String
	Date.today().at("6:15pm");

	// Set time to 6:15pm with a config object
	Date.today().at({hour:18, minute:15});
	
* * @return {Date} date */ $P.at = function (time) { return (typeof time === "string") ? $D.parse(this.toString("d") + " " + time) : this.set(time); }; /** * Creates a new Date() and adds this (Number) to the date based on the preceding date element function (eg. second|minute|hour|day|month|year). * Example

	// Undeclared Numbers must be wrapped with parentheses. Requirment of JavaScript.
	(3).days().fromNow();
	(6).months().fromNow();

	// Declared Number variables do not require parentheses. 
	var n = 6;
	n.months().fromNow();
	
* * @return {Date} A new Date instance */ $N.fromNow = $N.after = function (date) { var c = {}; c[this._dateElement] = this; return ((!date) ? new Date() : date.clone()).add(c); }; /** * Creates a new Date() and subtract this (Number) from the date based on the preceding date element function (eg. second|minute|hour|day|month|year). * Example

	// Undeclared Numbers must be wrapped with parentheses. Requirment of JavaScript.
	(3).days().ago();
	(6).months().ago();

	// Declared Number variables do not require parentheses. 
	var n = 6;
	n.months().ago();
	
* * @return {Date} A new Date instance */ $N.ago = $N.before = function (date) { var c = {}, s = (this._dateElement[this._dateElement.length-1] !== "s") ? this._dateElement + "s" : this._dateElement; c[s] = this * -1; return ((!date) ? new Date() : date.clone()).add(c); }; // Do NOT modify the following string tokens. These tokens are used to build dynamic functions. // All culture-specific strings can be found in the CultureInfo files. var dx = ("sunday monday tuesday wednesday thursday friday saturday").split(/\s/), mx = ("january february march april may june july august september october november december").split(/\s/), px = ("Millisecond Second Minute Hour Day Week Month Year Quarter Weekday").split(/\s/), pxf = ("Milliseconds Seconds Minutes Hours Date Week Month FullYear Quarter").split(/\s/), nth = ("final first second third fourth fifth").split(/\s/), de; /** * Returns an object literal of all the date parts. * Example

	var o = new Date().toObject();
	
	// { year: 2008, month: 4, week: 20, day: 13, hour: 18, minute: 9, second: 32, millisecond: 812 }
	
	// The object properties can be referenced directly from the object.
	
	alert(o.day);  // alerts "13"
	alert(o.year); // alerts "2008"
	
* * @return {Date} An object literal representing the original date object. */ $P.toObject = function () { var o = {}; for (var i = 0; i < px.length; i++) { if (this["get" + pxf[i]]) { o[px[i].toLowerCase()] = this["get" + pxf[i]](); } } return o; }; /** * Returns a date created from an object literal. Ignores the .week property if set in the config. * Example

	var o = new Date().toObject();
	
	return Date.fromObject(o); // will return the same date. 

	var o2 = {month: 1, day: 20, hour: 18}; // birthday party!
	Date.fromObject(o2);
	
* * @return {Date} An object literal representing the original date object. */ $D.fromObject = function(config) { config.week = null; return Date.today().set(config); }; // Create day name functions and abbreviated day name functions (eg. monday(), friday(), fri()). var df = function (n) { return function () { if (this._is) { this._is = false; return this.getDay() === n; } if (this._move) { this._move = null; } if (this._nth !== null) { // If the .second() function was called earlier, remove the _orient // from the date, and then continue. // This is required because 'second' can be used in two different context. // // Example // // Date.today().add(1).second(); // Date.march().second().monday(); // // Things get crazy with the following... // Date.march().add(1).second().second().monday(); // but it works!! // if (this._isSecond) { this.addSeconds(this._orient * -1); } // make sure we reset _isSecond this._isSecond = false; var ntemp = this._nth; this._nth = null; var temp = this.clone().moveToLastDayOfMonth(); this.moveToNthOccurrence(n, ntemp); if (this > temp) { throw new RangeError($D.getDayName(n) + " does not occur " + ntemp + " times in the month of " + $D.getMonthName(temp.getMonth()) + " " + temp.getFullYear() + "."); } return this; } return this.moveToDayOfWeek(n, this._orient); }; }; var sdf = function (n) { return function () { var t = $D.today(), shift = n - t.getDay(); if (n === 0 && Date.CultureInfo.firstDayOfWeek === 1 && t.getDay() !== 0) { shift = shift + 7; } return t.addDays(shift); }; }; // Create month name functions and abbreviated month name functions (eg. january(), march(), mar()). var month_instance_functions = function (n) { return function () { if (this._is) { this._is = false; return this.getMonth() === n; } return this.moveToMonth(n, this._orient); }; }; var month_static_functions = function (n) { return function () { return $D.today().set({ month: n, day: 1 }); }; }; var processTerms = function (names, staticFunc, instanceFunc) { for (var i = 0; i < names.length; i++) { // Create constant static Name variables. $D[names[i].toUpperCase()] = $D[names[i].toUpperCase().substring(0, 3)] = i; // Create Name functions. $D[names[i]] = $D[names[i].substring(0, 3)] = staticFunc(i); // Create Name instance functions. $P[names[i]] = $P[names[i].substring(0, 3)] = instanceFunc(i); } }; processTerms(dx, sdf, df); processTerms(mx, month_static_functions, month_instance_functions); // Create date element functions and plural date element functions used with Date (eg. day(), days(), months()). var ef = function (j) { return function () { // if the .second() function was called earlier, the _orient // has alread been added. Just return this and reset _isSecond. if (this._isSecond) { this._isSecond = false; return this; } if (this._same) { this._same = this._is = false; var o1 = this.toObject(), o2 = (arguments[0] || new Date()).toObject(), v = "", k = j.toLowerCase(); // the substr trick with -1 doesn't work in IE8 or less k = (k[k.length-1] === "s") ? k.substring(0,k.length-1) : k; for (var m = (px.length - 1); m > -1; m--) { v = px[m].toLowerCase(); if (o1[v] !== o2[v]) { return false; } if (k === v) { break; } } return true; } if (j.substring(j.length - 1) !== "s") { j += "s"; } if (this._move) { this._move = null; } return this["add" + j](this._orient); }; }; var nf = function (n) { return function () { this._dateElement = n; return this; }; }; for (var k = 0; k < px.length; k++) { de = px[k].toLowerCase(); if(de !== "weekday") { // Create date element functions and plural date element functions used with Date (eg. day(), days(), months()). $P[de] = $P[de + "s"] = ef(px[k]); // Create date element functions and plural date element functions used with Number (eg. day(), days(), months()). $N[de] = $N[de + "s"] = nf(de + "s"); } } $P._ss = ef("Second"); var nthfn = function (n) { return function (dayOfWeek) { if (this._same) { return this._ss(arguments[0]); } if (dayOfWeek || dayOfWeek === 0) { return this.moveToNthOccurrence(dayOfWeek, n); } this._nth = n; // if the operator is 'second' add the _orient, then deal with it later... if (n === 2 && (dayOfWeek === undefined || dayOfWeek === null)) { this._isSecond = true; return this.addSeconds(this._orient); } return this; }; }; for (var l = 0; l < nth.length; l++) { $P[nth[l]] = (l === 0) ? nthfn(-1) : nthfn(l); } }()); (function () { "use strict"; Date.Parsing = { Exception: function (s) { this.message = "Parse error at '" + s.substring(0, 10) + " ...'"; } }; var $P = Date.Parsing; var dayOffsets = { standard: [0,31,59,90,120,151,181,212,243,273,304,334], leap: [0,31,60,91,121,152,182,213,244,274,305,335] }; $P.isLeapYear = function(year) { return ((year % 4 === 0) && (year % 100 !== 0)) || (year % 400 === 0); }; var utils = { multiReplace : function (str, hash ) { var key; for (key in hash) { if (Object.prototype.hasOwnProperty.call(hash, key)) { var regex; if (typeof hash[key] === "function") { } else { regex = (hash[key] instanceof RegExp) ? hash[key] : new RegExp(hash[key], "g"); } str = str.replace(regex, key); } } return str; }, getDayOfYearFromWeek : function (obj) { var d, jan4, offset; obj.weekDay = (!obj.weekDay && obj.weekDay !== 0) ? 1 : obj.weekDay; d = new Date(obj.year, 0, 4); jan4 = d.getDay() === 0 ? 7 : d.getDay(); // JS is 0 indexed on Sunday. offset = jan4+3; obj.dayOfYear = ((obj.week * 7) + (obj.weekDay === 0 ? 7 : obj.weekDay))-offset; return obj; }, getDayOfYear : function (obj, dayOffset) { if (!obj.dayOfYear) { obj = utils.getDayOfYearFromWeek(obj); } for (var i=0;i <= dayOffset.length;i++) { if (obj.dayOfYear < dayOffset[i] || i === dayOffset.length) { obj.day = obj.day ? obj.day : (obj.dayOfYear - dayOffset[i-1]); break; } else { obj.month = i; } } return obj; }, adjustForTimeZone : function (obj, date) { var offset; if (obj.zone.toUpperCase() === "Z" || (obj.zone_hours === 0 && obj.zone_minutes === 0)) { // it's UTC/GML so work out the current timeszone offset offset = -date.getTimezoneOffset(); } else { offset = (obj.zone_hours*60) + (obj.zone_minutes || 0); if (obj.zone_sign === "+") { offset *= -1; } offset -= date.getTimezoneOffset(); } date.setMinutes(date.getMinutes()+offset); return date; }, setDefaults : function (obj) { obj.year = obj.year || Date.today().getFullYear(); obj.hours = obj.hours || 0; obj.minutes = obj.minutes || 0; obj.seconds = obj.seconds || 0; obj.milliseconds = obj.milliseconds || 0; if (!(!obj.month && (obj.week || obj.dayOfYear))) { // if we have a month, or if we don't but don't have the day calculation data obj.month = obj.month || 0; obj.day = obj.day || 1; } return obj; }, dataNum: function (data, mod, explict, postProcess) { var dataNum = data*1; if (mod) { if (postProcess) { return data ? mod(data)*1 : data; } else { return data ? mod(dataNum) : data; } } else if (!explict){ return data ? dataNum : data; } else { return (data && typeof data !== "undefined") ? dataNum : data; } }, timeDataProcess: function (obj) { var timeObj = {}; for (var x in obj.data) { if (obj.data.hasOwnProperty(x)) { timeObj[x] = obj.ignore[x] ? obj.data[x] : utils.dataNum(obj.data[x], obj.mods[x], obj.explict[x], obj.postProcess[x]); } } if (obj.data.secmins) { obj.data.secmins = obj.data.secmins.replace(",", ".") * 60; if (!timeObj.minutes) { timeObj.minutes = obj.data.secmins; } else if (!timeObj.seconds) { timeObj.seconds = obj.data.secmins; } delete obj.secmins; } return timeObj; }, buildTimeObjectFromData: function (data) { var time = utils.timeDataProcess({ data: { year : data[1], month : data[5], day : data[7], week : data[8], dayOfYear : data[10], hours : data[15], zone_hours : data[23], zone_minutes : data[24], zone : data[21], zone_sign : data[22], weekDay : data[9], minutes: data[16], seconds: data[19], milliseconds: data[20], secmins: data[18] }, mods: { month: function(data) { return data-1; }, weekDay: function (data) { data = Math.abs(data); return (data === 7 ? 0 : data); }, minutes: function (data) { return data.replace(":",""); }, seconds: function (data) { return Math.floor( (data.replace(":","").replace(",","."))*1 ); }, milliseconds: function (data) { return (data.replace(",",".")*1000); } }, postProcess: { minutes: true, seconds: true, milliseconds: true }, explict: { zone_hours: true, zone_minutes: true }, ignore: { zone: true, zone_sign: true, secmins: true } }); return time; }, addToHash: function (hash, keys, data) { keys = keys; data = data; var len = keys.length; for (var i = 0; i < len; i++) { hash[keys[i]] = data[i]; } return hash; }, combineRegex: function (r1, r2) { return new RegExp("(("+r1.source+")\\s("+r2.source+"))"); }, getDateNthString: function(add, last, inc){ if (add) { return Date.today().addDays(inc).toString("d"); } else if (last) { return Date.today().last()[inc]().toString("d"); } }, buildRegexData: function (array) { var arr = []; var len = array.length; for (var i=0; i < len; i++) { if (Object.prototype.toString.call(array[i]) === '[object Array]') { // oldIE compat version of Array.isArray arr.push(this.combineRegex(array[i][0], array[i][1])); } else { arr.push(array[i]); } } return arr; } }; $P.processTimeObject = function (obj) { var date, dayOffset; utils.setDefaults(obj); dayOffset = ($P.isLeapYear(obj.year)) ? dayOffsets.leap : dayOffsets.standard; if (!obj.month && (obj.week || obj.dayOfYear)) { utils.getDayOfYear(obj, dayOffset); } else { obj.dayOfYear = dayOffset[obj.month] + obj.day; } date = new Date(obj.year, obj.month, obj.day, obj.hours, obj.minutes, obj.seconds, obj.milliseconds); if (obj.zone) { utils.adjustForTimeZone(obj, date); // adjust (and calculate) for timezone } return date; }; $P.ISO = { regex : /^([\+-]?\d{4}(?!\d{2}\b))((-?)((0[1-9]|1[0-2])(\3([12]\d|0[1-9]|3[01]))?|W([0-4]\d|5[0-3])(-?[1-7])?|(00[1-9]|0[1-9]\d|[12]\d{2}|3([0-5]\d|6[1-6])))([T\s]((([01]\d|2[0-4])((:?)[0-5]\d)?|24\:?00)([\.,]\d+(?!:))?)?(\17[0-5]\d([\.,]\d+)?)?\s?([zZ]|([\+-])([01]\d|2[0-3]):?([0-5]\d)?)?)?)?$/, parse : function (s) { var time, data = s.match(this.regex); if (!data || !data.length) { return null; } time = utils.buildTimeObjectFromData(data); if (!time.year || (!time.year && (!time.month && !time.day) && (!time.week && !time.dayOfYear)) ) { return null; } return $P.processTimeObject(time); } }; $P.Numeric = { isNumeric: function (e){return!isNaN(parseFloat(e))&&isFinite(e);}, regex: /\b([0-1]?[0-9])([0-3]?[0-9])([0-2]?[0-9]?[0-9][0-9])\b/i, parse: function (s) { var data, i, time = {}, order = Date.CultureInfo.dateElementOrder.split(""); if (!(this.isNumeric(s)) || // if it's non-numeric OR (s[0] === "+" && s[0] === "-")) { // It's an arithmatic string (eg +/-1000) return null; } if (s.length < 5 && s.indexOf(".") < 0 && s.indexOf("/") < 0) { // assume it's just a year. time.year = s; return $P.processTimeObject(time); } data = s.match(this.regex); if (!data || !data.length) { return null; } for (i=0; i < order.length; i++) { switch(order[i]) { case "d": time.day = data[i+1]; break; case "m": time.month = (data[i+1]-1); break; case "y": time.year = data[i+1]; break; } } return $P.processTimeObject(time); } }; $P.Normalizer = { regexData: function () { var $R = Date.CultureInfo.regexPatterns; return utils.buildRegexData([ $R.tomorrow, $R.yesterday, [$R.past, $R.mon], [$R.past, $R.tue], [$R.past, $R.wed], [$R.past, $R.thu], [$R.past, $R.fri], [$R.past, $R.sat], [$R.past, $R.sun] ]); }, basicReplaceHash : function() { var $R = Date.CultureInfo.regexPatterns; return { "January": $R.jan.source, "February": $R.feb, "March": $R.mar, "April": $R.apr, "May": $R.may, "June": $R.jun, "July": $R.jul, "August": $R.aug, "September": $R.sep, "October": $R.oct, "November": $R.nov, "December": $R.dec, "": /\bat\b/gi, " ": /\s{2,}/, "am": $R.inTheMorning, "9am": $R.thisMorning, "pm": $R.inTheEvening, "7pm":$R.thisEvening }; }, keys : function(){ return [ utils.getDateNthString(true, false, 1), // tomorrow utils.getDateNthString(true, false, -1), // yesterday utils.getDateNthString(false, true, "monday"), //last mon utils.getDateNthString(false, true, "tuesday"), //last tues utils.getDateNthString(false, true, "wednesday"), //last wed utils.getDateNthString(false, true, "thursday"), //last thurs utils.getDateNthString(false, true, "friday"), //last fri utils.getDateNthString(false, true, "saturday"), //last sat utils.getDateNthString(false, true, "sunday") //last sun ]; }, buildRegexFunctions: function () { var $R = Date.CultureInfo.regexPatterns; var __ = Date.i18n.__; var tomorrowRE = new RegExp("(\\b\\d\\d?("+__("AM")+"|"+__("PM")+")? )("+$R.tomorrow.source.slice(1)+")", "i"); // adapted tomorrow regex for AM PM relative dates var todayRE = new RegExp($R.today.source + "(?!\\s*([+-]))\\b"); // today, but excludes the math operators (eg "today + 2h") this.replaceFuncs = [ [todayRE, function (full) { return (full.length > 1) ? Date.today().toString("d") : full; }], [tomorrowRE, function(full, m1) { var t = Date.today().addDays(1).toString("d"); return (t + " " + m1); }], [$R.amThisMorning, function(str, am){return am;}], [$R.pmThisEvening, function(str, pm){return pm;}] ]; }, buildReplaceData: function () { this.buildRegexFunctions(); this.replaceHash = utils.addToHash(this.basicReplaceHash(), this.keys(), this.regexData()); }, stringReplaceFuncs: function (s) { for (var i=0; i < this.replaceFuncs.length; i++) { s = s.replace(this.replaceFuncs[i][0], this.replaceFuncs[i][1]); } return s; }, parse: function (s) { s = this.stringReplaceFuncs(s); s = utils.multiReplace(s, this.replaceHash); try { var n = s.split(/([\s\-\.\,\/\x27]+)/); if (n.length === 3 && $P.Numeric.isNumeric(n[0]) && $P.Numeric.isNumeric(n[2]) && (n[2].length >= 4)) { // ok, so we're dealing with x/year. But that's not a full date. // This fixes wonky dateElementOrder parsing when set to dmy order. if (Date.CultureInfo.dateElementOrder[0] === "d") { s = "1/" + n[0] + "/" + n[2]; // set to 1st of month and normalize the seperator } } } catch (e) {} return s; } }; $P.Normalizer.buildReplaceData(); }()); (function () { var $P = Date.Parsing; var _ = $P.Operators = { // // Tokenizers // rtoken: function (r) { // regex token return function (s) { var mx = s.match(r); if (mx) { return ([ mx[0], s.substring(mx[0].length) ]); } else { throw new $P.Exception(s); } }; }, token: function () { // whitespace-eating token return function (s) { return _.rtoken(new RegExp("^\\s*" + s + "\\s*"))(s); }; }, stoken: function (s) { // string token return _.rtoken(new RegExp("^" + s)); }, // Atomic Operators until: function (p) { return function (s) { var qx = [], rx = null; while (s.length) { try { rx = p.call(this, s); } catch (e) { qx.push(rx[0]); s = rx[1]; continue; } break; } return [ qx, s ]; }; }, many: function (p) { return function (s) { var rx = [], r = null; while (s.length) { try { r = p.call(this, s); } catch (e) { return [ rx, s ]; } rx.push(r[0]); s = r[1]; } return [ rx, s ]; }; }, // generator operators -- see below optional: function (p) { return function (s) { var r = null; try { r = p.call(this, s); } catch (e) { return [ null, s ]; } return [ r[0], r[1] ]; }; }, not: function (p) { return function (s) { try { p.call(this, s); } catch (e) { return [null, s]; } throw new $P.Exception(s); }; }, ignore: function (p) { return p ? function (s) { var r = null; r = p.call(this, s); return [null, r[1]]; } : null; }, product: function () { var px = arguments[0], qx = Array.prototype.slice.call(arguments, 1), rx = []; for (var i = 0 ; i < px.length ; i++) { rx.push(_.each(px[i], qx)); } return rx; }, cache: function (rule) { var cache = {}, cache_length = 0, cache_keys = [], CACHE_MAX = Date.Config.CACHE_MAX || 100000, r = null; var cacheCheck = function () { if (cache_length === CACHE_MAX) { // kill several keys, don't want to have to do this all the time... for (var i=0; i < 10; i++) { var key = cache_keys.shift(); if (key) { delete cache[key]; cache_length--; } } } }; return function (s) { cacheCheck(); try { r = cache[s] = (cache[s] || rule.call(this, s)); } catch (e) { r = cache[s] = e; } cache_length++; cache_keys.push(s); if (r instanceof $P.Exception) { throw r; } else { return r; } }; }, // vector operators -- see below any: function () { var px = arguments; return function (s) { var r = null; for (var i = 0; i < px.length; i++) { if (px[i] == null) { continue; } try { r = (px[i].call(this, s)); } catch (e) { r = null; } if (r) { return r; } } throw new $P.Exception(s); }; }, each: function () { var px = arguments; return function (s) { var rx = [], r = null; for (var i = 0; i < px.length ; i++) { if (px[i] == null) { continue; } try { r = (px[i].call(this, s)); } catch (e) { throw new $P.Exception(s); } rx.push(r[0]); s = r[1]; } return [ rx, s]; }; }, all: function () { var px = arguments, _ = _; return _.each(_.optional(px)); }, // delimited operators sequence: function (px, d, c) { d = d || _.rtoken(/^\s*/); c = c || null; if (px.length === 1) { return px[0]; } return function (s) { var r = null, q = null; var rx = []; for (var i = 0; i < px.length ; i++) { try { r = px[i].call(this, s); } catch (e) { break; } rx.push(r[0]); try { q = d.call(this, r[1]); } catch (ex) { q = null; break; } s = q[1]; } if (!r) { throw new $P.Exception(s); } if (q) { throw new $P.Exception(q[1]); } if (c) { try { r = c.call(this, r[1]); } catch (ey) { throw new $P.Exception(r[1]); } } return [ rx, (r?r[1]:s) ]; }; }, // // Composite Operators // between: function (d1, p, d2) { d2 = d2 || d1; var _fn = _.each(_.ignore(d1), p, _.ignore(d2)); return function (s) { var rx = _fn.call(this, s); return [[rx[0][0], r[0][2]], rx[1]]; }; }, list: function (p, d, c) { d = d || _.rtoken(/^\s*/); c = c || null; return (p instanceof Array ? _.each(_.product(p.slice(0, -1), _.ignore(d)), p.slice(-1), _.ignore(c)) : _.each(_.many(_.each(p, _.ignore(d))), px, _.ignore(c))); }, set: function (px, d, c) { d = d || _.rtoken(/^\s*/); c = c || null; return function (s) { // r is the current match, best the current 'best' match // which means it parsed the most amount of input var r = null, p = null, q = null, rx = null, best = [[], s], last = false; // go through the rules in the given set for (var i = 0; i < px.length ; i++) { // last is a flag indicating whether this must be the last element // if there is only 1 element, then it MUST be the last one q = null; p = null; r = null; last = (px.length === 1); // first, we try simply to match the current pattern // if not, try the next pattern try { r = px[i].call(this, s); } catch (e) { continue; } // since we are matching against a set of elements, the first // thing to do is to add r[0] to matched elements rx = [[r[0]], r[1]]; // if we matched and there is still input to parse and // we don't already know this is the last element, // we're going to next check for the delimiter ... // if there's none, or if there's no input left to parse // than this must be the last element after all ... if (r[1].length > 0 && ! last) { try { q = d.call(this, r[1]); } catch (ex) { last = true; } } else { last = true; } // if we parsed the delimiter and now there's no more input, // that means we shouldn't have parsed the delimiter at all // so don't update r and mark this as the last element ... if (!last && q[1].length === 0) { last = true; } // so, if this isn't the last element, we're going to see if // we can get any more matches from the remaining (unmatched) // elements ... if (!last) { // build a list of the remaining rules we can match against, // i.e., all but the one we just matched against var qx = []; for (var j = 0; j < px.length ; j++) { if (i !== j) { qx.push(px[j]); } } // now invoke recursively set with the remaining input // note that we don't include the closing delimiter ... // we'll check for that ourselves at the end p = _.set(qx, d).call(this, q[1]); // if we got a non-empty set as a result ... // (otw rx already contains everything we want to match) if (p[0].length > 0) { // update current result, which is stored in rx ... // basically, pick up the remaining text from p[1] // and concat the result from p[0] so that we don't // get endless nesting ... rx[0] = rx[0].concat(p[0]); rx[1] = p[1]; } } // at this point, rx either contains the last matched element // or the entire matched set that starts with this element. // now we just check to see if this variation is better than // our best so far, in terms of how much of the input is parsed if (rx[1].length < best[1].length) { best = rx; } // if we've parsed all the input, then we're finished if (best[1].length === 0) { break; } } // so now we've either gone through all the patterns trying them // as the initial match; or we found one that parsed the entire // input string ... // if best has no matches, just return empty set ... if (best[0].length === 0) { return best; } // if a closing delimiter is provided, then we have to check it also if (c) { // we try this even if there is no remaining input because the pattern // may well be optional or match empty input ... try { q = c.call(this, best[1]); } catch (ey) { throw new $P.Exception(best[1]); } // it parsed ... be sure to update the best match remaining input best[1] = q[1]; } // if we're here, either there was no closing delimiter or we parsed it // so now we have the best match; just return it! return best; }; }, forward: function (gr, fname) { return function (s) { return gr[fname].call(this, s); }; }, // // Translation Operators // replace: function (rule, repl) { return function (s) { var r = rule.call(this, s); return [repl, r[1]]; }; }, process: function (rule, fn) { return function (s) { var r = rule.call(this, s); return [fn.call(this, r[0]), r[1]]; }; }, min: function (min, rule) { return function (s) { var rx = rule.call(this, s); if (rx[0].length < min) { throw new $P.Exception(s); } return rx; }; } }; // Generator Operators And Vector Operators // Generators are operators that have a signature of F(R) => R, // taking a given rule and returning another rule, such as // ignore, which parses a given rule and throws away the result. // Vector operators are those that have a signature of F(R1,R2,...) => R, // take a list of rules and returning a new rule, such as each. // Generator operators are converted (via the following _generator // function) into functions that can also take a list or array of rules // and return an array of new rules as though the function had been // called on each rule in turn (which is what actually happens). // This allows generators to be used with vector operators more easily. // Example: // each(ignore(foo, bar)) instead of each(ignore(foo), ignore(bar)) // This also turns generators into vector operators, which allows // constructs like: // not(cache(foo, bar)) var _generator = function (op) { function gen() { var args = null, rx = [], px, i; if (arguments.length > 1) { args = Array.prototype.slice.call(arguments); } else if (arguments[0] instanceof Array) { args = arguments[0]; } if (args) { px = args.shift(); if (px.length > 0) { args.unshift(px[i]); rx.push(op.apply(null, args)); args.shift(); return rx; } } else { return op.apply(null, arguments); } } return gen; }; var gx = "optional not ignore cache".split(/\s/); for (var i = 0 ; i < gx.length ; i++) { _[gx[i]] = _generator(_[gx[i]]); } var _vector = function (op) { return function () { if (arguments[0] instanceof Array) { return op.apply(null, arguments[0]); } else { return op.apply(null, arguments); } }; }; var vx = "each any all".split(/\s/); for (var j = 0 ; j < vx.length ; j++) { _[vx[j]] = _vector(_[vx[j]]); } }()); (function () { var $D = Date; var flattenAndCompact = function (ax) { var rx = []; for (var i = 0; i < ax.length; i++) { if (ax[i] instanceof Array) { rx = rx.concat(flattenAndCompact(ax[i])); } else { if (ax[i]) { rx.push(ax[i]); } } } return rx; }; var parseMeridian = function () { if (this.meridian && (this.hour || this.hour === 0)) { if (this.meridian === "a" && this.hour > 11 && Date.Config.strict24hr){ throw "Invalid hour and meridian combination"; } else if (this.meridian === "p" && this.hour < 12 && Date.Config.strict24hr){ throw "Invalid hour and meridian combination"; } else if (this.meridian === "p" && this.hour < 12) { this.hour = this.hour + 12; } else if (this.meridian === "a" && this.hour === 12) { this.hour = 0; } } }; var setDefaults = function () { var now = new Date(); if ((this.hour || this.minute) && (!this.month && !this.year && !this.day)) { this.day = now.getDate(); } if (!this.year) { this.year = now.getFullYear(); } if (!this.month && this.month !== 0) { this.month = now.getMonth(); } if (!this.day) { this.day = 1; } if (!this.hour) { this.hour = 0; } if (!this.minute) { this.minute = 0; } if (!this.second) { this.second = 0; } if (!this.millisecond) { this.millisecond = 0; } }; var finishUtils = { getToday: function () { if (this.now || "hour minute second".indexOf(this.unit) !== -1) { return new Date(); } else { return $D.today(); } }, setDaysFromWeekday: function (today, orient){ var gap; orient = orient || 1; this.unit = "day"; gap = ($D.getDayNumberFromName(this.weekday) - today.getDay()); this.days = gap ? ((gap + (orient * 7)) % 7) : (orient * 7); return this; }, setMonthsFromMonth: function (today, orient) { var gap; orient = orient || 1; this.unit = "month"; gap = (this.month - today.getMonth()); this.months = gap ? ((gap + (orient * 12)) % 12) : (orient * 12); this.month = null; return this; }, setDMYFromWeekday: function () { var d = Date[this.weekday](); this.day = d.getDate(); if (!this.month) { this.month = d.getMonth(); } this.year = d.getFullYear(); return this; }, setUnitValue: function (orient) { if (!this.value && this.operator && this.operator !== null && this[this.unit + "s"] && this[this.unit + "s"] !== null) { this[this.unit + "s"] = this[this.unit + "s"] + ((this.operator === "add") ? 1 : -1) + (this.value||0) * orient; } else if (this[this.unit + "s"] == null || this.operator != null) { if (!this.value) { this.value = 1; } this[this.unit + "s"] = this.value * orient; } }, generateDateFromWeeks: function () { var weekday = (this.weekday !== undefined) ? this.weekday : "today"; var d = Date[weekday]().addWeeks(this.weeks); if (this.now) { d.setTimeToNow(); } return d; } }; $D.Translator = { hour: function (s) { return function () { this.hour = Number(s); }; }, minute: function (s) { return function () { this.minute = Number(s); }; }, second: function (s) { return function () { this.second = Number(s); }; }, /* for ss.s format */ secondAndMillisecond: function (s) { return function () { var mx = s.match(/^([0-5][0-9])\.([0-9]{1,3})/); this.second = Number(mx[1]); this.millisecond = Number(mx[2]); }; }, meridian: function (s) { return function () { this.meridian = s.slice(0, 1).toLowerCase(); }; }, timezone: function (s) { return function () { var n = s.replace(/[^\d\+\-]/g, ""); if (n.length) { this.timezoneOffset = Number(n); } else { this.timezone = s.toLowerCase(); } }; }, day: function (x) { var s = x[0]; return function () { this.day = Number(s.match(/\d+/)[0]); if (this.day < 1) { throw "invalid day"; } }; }, month: function (s) { return function () { this.month = (s.length === 3) ? "jan feb mar apr may jun jul aug sep oct nov dec".indexOf(s)/4 : Number(s) - 1; if (this.month < 0) { throw "invalid month"; } }; }, year: function (s) { return function () { var n = Number(s); this.year = ((s.length > 2) ? n : (n + (((n + 2000) < Date.CultureInfo.twoDigitYearMax) ? 2000 : 1900))); }; }, rday: function (s) { return function () { switch (s) { case "yesterday": this.days = -1; break; case "tomorrow": this.days = 1; break; case "today": this.days = 0; break; case "now": this.days = 0; this.now = true; break; } }; }, finishExact: function (x) { var d; x = (x instanceof Array) ? x : [x]; for (var i = 0 ; i < x.length ; i++) { if (x[i]) { x[i].call(this); } } setDefaults.call(this); parseMeridian.call(this); if (this.day > $D.getDaysInMonth(this.year, this.month)) { throw new RangeError(this.day + " is not a valid value for days."); } d = new Date(this.year, this.month, this.day, this.hour, this.minute, this.second, this.millisecond); if (this.year < 100) { d.setFullYear(this.year); // means years less that 100 are process correctly. JS will parse it otherwise as 1900-1999. } if (this.timezone) { d.set({ timezone: this.timezone }); } else if (this.timezoneOffset) { d.set({ timezoneOffset: this.timezoneOffset }); } return d; }, finish: function (x) { var today, expression, orient, temp; x = (x instanceof Array) ? flattenAndCompact(x) : [ x ]; if (x.length === 0) { return null; } for (var i = 0 ; i < x.length ; i++) { if (typeof x[i] === "function") { x[i].call(this); } } if (this.now && !this.unit && !this.operator) { return new Date(); } else { today = finishUtils.getToday.call(this); } expression = !!(this.days && this.days !== null || this.orient || this.operator); orient = ((this.orient === "past" || this.operator === "subtract") ? -1 : 1); if (this.month && this.unit === "week") { this.value = this.month + 1; delete this.month; delete this.day; } if ((this.month || this.month === 0) && "year day hour minute second".indexOf(this.unit) !== -1) { if (!this.value) { this.value = this.month + 1; } this.month = null; expression = true; } if (!expression && this.weekday && !this.day && !this.days) { finishUtils.setDMYFromWeekday.call(this); } if (expression && this.weekday && this.unit !== "month" && this.unit !== "week") { finishUtils.setDaysFromWeekday.call(this, today, orient); } if (this.weekday && this.unit !== "week" && !this.day && !this.days) { temp = Date[this.weekday](); this.day = temp.getDate(); if (temp.getMonth() !== today.getMonth()) { this.month = temp.getMonth(); } } if (this.month && this.unit === "day" && this.operator) { if (!this.value) { this.value = (this.month + 1); } this.month = null; } if (this.value != null && this.month != null && this.year != null) { this.day = this.value * 1; } if (this.month && !this.day && this.value) { today.set({ day: this.value * 1 }); if (!expression) { this.day = this.value * 1; } } if (!this.month && this.value && this.unit === "month" && !this.now) { this.month = this.value; expression = true; } if (expression && (this.month || this.month === 0) && this.unit !== "year") { finishUtils.setMonthsFromMonth.call(this, today, orient); } if (!this.unit) { this.unit = "day"; } finishUtils.setUnitValue.call(this, orient); parseMeridian.call(this); if ((this.month || this.month === 0) && !this.day) { this.day = 1; } if (!this.orient && !this.operator && this.unit === "week" && this.value && !this.day && !this.month) { return Date.today().setWeek(this.value); } if (this.unit === "week" && this.weeks && !this.day && !this.month) { return finishUtils.generateDateFromWeeks.call(this); } if (expression && this.timezone && this.day && this.days) { this.day = this.days; } if (expression){ today.add(this); } else { today.set(this); } if (this.timezone) { this.timezone = this.timezone.toUpperCase(); var offset = $D.getTimezoneOffset(this.timezone); var timezone; if (today.hasDaylightSavingTime()) { // lets check that we're being sane with timezone setting timezone = $D.getTimezoneAbbreviation(offset, today.isDaylightSavingTime()); if (timezone !== this.timezone) { // bugger, we're in a place where things like EST vs EDT matters. if (today.isDaylightSavingTime()) { today.addHours(-1); } else { today.addHours(1); } } } today.setTimezoneOffset(offset); } return today; } }; }()); (function () { var $D = Date; $D.Grammar = {}; var _ = $D.Parsing.Operators, g = $D.Grammar, t = $D.Translator, _fn; // Allow rolling up into general purpose rules _fn = function () { return _.each(_.any.apply(null, arguments), _.not(g.ctoken2("timeContext"))); }; g.datePartDelimiter = _.rtoken(/^([\s\-\.\,\/\x27]+)/); g.timePartDelimiter = _.stoken(":"); g.whiteSpace = _.rtoken(/^\s*/); g.generalDelimiter = _.rtoken(/^(([\s\,]|at|@|on)+)/); var _C = {}; g.ctoken = function (keys) { var fn = _C[keys]; if (! fn) { var c = Date.CultureInfo.regexPatterns; var kx = keys.split(/\s+/), px = []; for (var i = 0; i < kx.length ; i++) { px.push(_.replace(_.rtoken(c[kx[i]]), kx[i])); } fn = _C[keys] = _.any.apply(null, px); } return fn; }; g.ctoken2 = function (key) { return _.rtoken(Date.CultureInfo.regexPatterns[key]); }; var cacheProcessRtoken = function (key, token, type, eachToken) { if (eachToken) { g[key] = _.cache(_.process(_.each(_.rtoken(token),_.optional(g.ctoken2(eachToken))), type)); } else { g[key] = _.cache(_.process(_.rtoken(token), type)); } }; var cacheProcessCtoken = function (token, type) { return _.cache(_.process(g.ctoken2(token), type)); }; var _F = {}; //function cache var _get = function (f) { _F[f] = (_F[f] || g.format(f)[0]); return _F[f]; }; g.allformats = function (fx) { var rx = []; if (fx instanceof Array) { for (var i = 0; i < fx.length; i++) { rx.push(_get(fx[i])); } } else { rx.push(_get(fx)); } return rx; }; g.formats = function (fx) { if (fx instanceof Array) { var rx = []; for (var i = 0 ; i < fx.length ; i++) { rx.push(_get(fx[i])); } return _.any.apply(null, rx); } else { return _get(fx); } }; var grammarFormats = { timeFormats: function(){ var i, RTokenKeys = [ "h", "hh", "H", "HH", "m", "mm", "s", "ss", "ss.s", "z", "zz" ], RToken = [ /^(0[0-9]|1[0-2]|[1-9])/, /^(0[0-9]|1[0-2])/, /^([0-1][0-9]|2[0-3]|[0-9])/, /^([0-1][0-9]|2[0-3])/, /^([0-5][0-9]|[0-9])/, /^[0-5][0-9]/, /^([0-5][0-9]|[0-9])/, /^[0-5][0-9]/, /^[0-5][0-9]\.[0-9]{1,3}/, /^((\+|\-)\s*\d\d\d\d)|((\+|\-)\d\d\:?\d\d)/, /^((\+|\-)\s*\d\d\d\d)|((\+|\-)\d\d\:?\d\d)/ ], tokens = [ t.hour, t.hour, t.hour, t.hour, t.minute, t.minute, t.second, t.second, t.secondAndMillisecond, t.timezone, t.timezone ]; for (i=0; i < RTokenKeys.length; i++) { cacheProcessRtoken(RTokenKeys[i], RToken[i], tokens[i]); } g.hms = _.cache(_.sequence([g.H, g.m, g.s], g.timePartDelimiter)); g.t = cacheProcessCtoken("shortMeridian", t.meridian); g.tt = cacheProcessCtoken("longMeridian", t.meridian); g.zzz = cacheProcessCtoken("timezone", t.timezone); g.timeSuffix = _.each(_.ignore(g.whiteSpace), _.set([ g.tt, g.zzz ])); g.time = _.each(_.optional(_.ignore(_.stoken("T"))), g.hms, g.timeSuffix); }, dateFormats: function () { // pre-loaded rules for different date part order preferences var _setfn = function () { return _.set(arguments, g.datePartDelimiter); }; var i, RTokenKeys = [ "d", "dd", "M", "MM", "y", "yy", "yyy", "yyyy" ], RToken = [ /^([0-2]\d|3[0-1]|\d)/, /^([0-2]\d|3[0-1])/, /^(1[0-2]|0\d|\d)/, /^(1[0-2]|0\d)/, /^(\d+)/, /^(\d\d)/, /^(\d\d?\d?\d?)/, /^(\d\d\d\d)/ ], tokens = [ t.day, t.day, t.month, t.month, t.year, t.year, t.year, t.year ], eachToken = [ "ordinalSuffix", "ordinalSuffix" ]; for (i=0; i < RTokenKeys.length; i++) { cacheProcessRtoken(RTokenKeys[i], RToken[i], tokens[i], eachToken[i]); } g.MMM = g.MMMM = _.cache(_.process(g.ctoken("jan feb mar apr may jun jul aug sep oct nov dec"), t.month)); g.ddd = g.dddd = _.cache(_.process(g.ctoken("sun mon tue wed thu fri sat"), function (s) { return function () { this.weekday = s; }; } )); g.day = _fn(g.d, g.dd); g.month = _fn(g.M, g.MMM); g.year = _fn(g.yyyy, g.yy); g.mdy = _setfn(g.ddd, g.month, g.day, g.year); g.ymd = _setfn(g.ddd, g.year, g.month, g.day); g.dmy = _setfn(g.ddd, g.day, g.month, g.year); g.date = function (s) { return ((g[Date.CultureInfo.dateElementOrder] || g.mdy).call(this, s)); }; }, relative: function () { // relative date / time expressions g.orientation = _.process(g.ctoken("past future"), function (s) { return function () { this.orient = s; }; } ); g.operator = _.process(g.ctoken("add subtract"), function (s) { return function () { this.operator = s; }; } ); g.rday = _.process(g.ctoken("yesterday tomorrow today now"), t.rday); g.unit = _.process(g.ctoken("second minute hour day week month year"), function (s) { return function () { this.unit = s; }; } ); } }; g.buildGrammarFormats = function () { // these need to be rebuilt every time the language changes. _C = {}; grammarFormats.timeFormats(); grammarFormats.dateFormats(); grammarFormats.relative(); g.value = _.process(_.rtoken(/^([-+]?\d+)?(st|nd|rd|th)?/), function (s) { return function () { this.value = s.replace(/\D/g, ""); }; } ); g.expression = _.set([g.rday, g.operator, g.value, g.unit, g.orientation, g.ddd, g.MMM ]); g.format = _.process(_.many( _.any( // translate format specifiers into grammar rules _.process( _.rtoken(/^(dd?d?d?(?!e)|MM?M?M?|yy?y?y?|hh?|HH?|mm?|ss?|tt?|zz?z?)/), function (fmt) { if (g[fmt]) { return g[fmt]; } else { throw $D.Parsing.Exception(fmt); } } ), // translate separator tokens into token rules _.process(_.rtoken(/^[^dMyhHmstz]+/), // all legal separators function (s) { return _.ignore(_.stoken(s)); } ) ) ), // construct the parser ... function (rules) { return _.process(_.each.apply(null, rules), t.finishExact); } ); // starting rule for general purpose grammar g._start = _.process(_.set([ g.date, g.time, g.expression ], g.generalDelimiter, g.whiteSpace), t.finish); }; g.buildGrammarFormats(); // parsing date format specifiers - ex: "h:m:s tt" // this little guy will generate a custom parser based // on the format string, ex: g.format("h:m:s tt") // check for these formats first g._formats = g.formats([ "\"yyyy-MM-ddTHH:mm:ssZ\"", "yyyy-MM-ddTHH:mm:ss.sz", "yyyy-MM-ddTHH:mm:ssZ", "yyyy-MM-ddTHH:mm:ssz", "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-ddTHH:mmZ", "yyyy-MM-ddTHH:mmz", "yyyy-MM-ddTHH:mm", "ddd, MMM dd, yyyy H:mm:ss tt", "ddd MMM d yyyy HH:mm:ss zzz", "MMddyyyy", "ddMMyyyy", "Mddyyyy", "ddMyyyy", "Mdyyyy", "dMyyyy", "yyyy", "Mdyy", "dMyy", "d" ]); // real starting rule: tries selected formats first, // then general purpose rule g.start = function (s) { try { var r = g._formats.call({}, s); if (r[1].length === 0) { return r; } } catch (e) {} return g._start.call({}, s); }; }()); (function () { var $D = Date; /** * @desc Converts the specified string value into its JavaScript Date equivalent using CultureInfo specific format information. * * Example

	///////////
	// Dates //
	///////////

	// 15-Oct-2004
	var d1 = Date.parse("10/15/2004");

	// 15-Oct-2004
	var d1 = Date.parse("15-Oct-2004");

	// 15-Oct-2004
	var d1 = Date.parse("2004.10.15");

	//Fri Oct 15, 2004
	var d1 = Date.parse("Fri Oct 15, 2004");

	///////////
	// Times //
	///////////

	// Today at 10 PM.
	var d1 = Date.parse("10 PM");

	// Today at 10:30 PM.
	var d1 = Date.parse("10:30 P.M.");

	// Today at 6 AM.
	var d1 = Date.parse("06am");

	/////////////////////
	// Dates and Times //
	/////////////////////

	// 8-July-2004 @ 10:30 PM
	var d1 = Date.parse("July 8th, 2004, 10:30 PM");

	// 1-July-2004 @ 10:30 PM
	var d1 = Date.parse("2004-07-01T22:30:00");

	////////////////////
	// Relative Dates //
	////////////////////

	// Returns today's date. The string "today" is culture specific.
	var d1 = Date.parse("today");

	// Returns yesterday's date. The string "yesterday" is culture specific.
	var d1 = Date.parse("yesterday");

	// Returns the date of the next thursday.
	var d1 = Date.parse("Next thursday");

	// Returns the date of the most previous monday.
	var d1 = Date.parse("last monday");

	// Returns today's day + one year.
	var d1 = Date.parse("next year");

	///////////////
	// Date Math //
	///////////////

	// Today + 2 days
	var d1 = Date.parse("t+2");

	// Today + 2 days
	var d1 = Date.parse("today + 2 days");

	// Today + 3 months
	var d1 = Date.parse("t+3m");

	// Today - 1 year
	var d1 = Date.parse("today - 1 year");

	// Today - 1 year
	var d1 = Date.parse("t-1y"); 


	/////////////////////////////
	// Partial Dates and Times //
	/////////////////////////////

	// July 15th of this year.
	var d1 = Date.parse("July 15");

	// 15th day of current day and year.
	var d1 = Date.parse("15");

	// July 1st of current year at 10pm.
	var d1 = Date.parse("7/1 10pm");
	
* * @param {String} The string value to convert into a Date object [Required] * @return {Date} A Date object or null if the string cannot be converted into a Date. */ var parseUtils = { removeOrds: function (s) { ords = s.match(/\b(\d+)(?:st|nd|rd|th)\b/); // find ordinal matches s = ((ords && ords.length === 2) ? s.replace(ords[0], ords[1]) : s); return s; }, grammarParser: function (s) { var r = null; try { r = $D.Grammar.start.call({}, s.replace(/^\s*(\S*(\s+\S+)*)\s*$/, "$1")); } catch (e) { return null; } return ((r[1].length === 0) ? r[0] : null); }, nativeFallback: function(s) { var t; try { // ok we haven't parsed it, last ditch attempt with the built-in parser. t = Date._parse(s); return (t || t === 0) ? new Date(t) : null; } catch (e) { return null; } } }; function parse (s) { var d; if (!s) { return null; } if (s instanceof Date) { return s.clone(); } if (s.length >= 4 && s.charAt(0) !== "0" && s.charAt(0) !== "+"&& s.charAt(0) !== "-") { // ie: 2004 will pass, 0800 won't. // Start with specific formats d = $D.Parsing.ISO.parse(s) || $D.Parsing.Numeric.parse(s); } if (d instanceof Date && !isNaN(d.getTime())) { return d; } else { // find ordinal dates (1st, 3rd, 8th, etc and remove them as they cause parsing issues) s = $D.Parsing.Normalizer.parse(parseUtils.removeOrds(s)); d = parseUtils.grammarParser(s); if (d !== null) { return d; } else { return parseUtils.nativeFallback(s); } } } if (!$D._parse) { $D._parse = $D.parse; } $D.parse = parse; Date.getParseFunction = function (fx) { var fns = Date.Grammar.allformats(fx); return function (s) { var r = null; for (var i = 0; i < fns.length; i++) { try { r = fns[i].call({}, s); } catch (e) { continue; } if (r[1].length === 0) { return r[0]; } } return null; }; }; /** * Converts the specified string value into its JavaScript Date equivalent using the specified format {String} or formats {Array} and the CultureInfo specific format information. * The format of the string value must match one of the supplied formats exactly. * * Example

	// 15-Oct-2004
	var d1 = Date.parseExact("10/15/2004", "M/d/yyyy");

	// 15-Oct-2004
	var d1 = Date.parse("15-Oct-2004", "M-ddd-yyyy");

	// 15-Oct-2004
	var d1 = Date.parse("2004.10.15", "yyyy.MM.dd");

	// Multiple formats
	var d1 = Date.parseExact("10/15/2004", ["M/d/yyyy", "MMMM d, yyyy"]);
	
* * @param {String} The string value to convert into a Date object [Required]. * @param {Object} The expected format {String} or an array of expected formats {Array} of the date string [Required]. * @return {Date} A Date object or null if the string cannot be converted into a Date. */ $D.parseExact = function (s, fx) { return $D.getParseFunction(fx)(s); }; }()); (function () { var $D = Date, $P = $D.prototype, // $C = $D.CultureInfo, // not used atm p = function (s, l) { if (!l) { l = 2; } return ("000" + s).slice(l * -1); }; /** * Converts a PHP format string to Java/.NET format string. * A PHP format string can be used with ._format or .format. * A Java/.NET format string can be used with .toString(). * The .parseExact function will only accept a Java/.NET format string * * Example * var f1 = "%m/%d/%y" * var f2 = Date.normalizeFormat(f1); // "MM/dd/yy" * * new Date().format(f1); // "04/13/08" * new Date()._format(f1); // "04/13/08" * new Date().toString(f2); // "04/13/08" * * var date = Date.parseExact("04/13/08", f2); // Sun Apr 13 2008 * * @param {String} A PHP format string consisting of one or more format spcifiers. * @return {String} The PHP format converted to a Java/.NET format string. */ var normalizerSubstitutions = { "d" : "dd", "%d": "dd", "D" : "ddd", "%a": "ddd", "j" : "dddd", "l" : "dddd", "%A": "dddd", "S" : "S", "F" : "MMMM", "%B": "MMMM", "m" : "MM", "%m": "MM", "M" : "MMM", "%b": "MMM", "%h": "MMM", "n" : "M", "Y" : "yyyy", "%Y": "yyyy", "y" : "yy", "%y": "yy", "g" : "h", "%I": "h", "G" : "H", "h" : "hh", "H" : "HH", "%H": "HH", "i" : "mm", "%M": "mm", "s" : "ss", "%S": "ss", "%r": "hh:mm tt", "%R": "H:mm", "%T": "H:mm:ss", "%X": "t", "%x": "d", "%e": "d", "%D": "MM/dd/yy", "%n": "\\n", "%t": "\\t", "e" : "z", "T" : "z", "%z": "z", "%Z": "z", "Z" : "ZZ", "N" : "u", "w" : "u", "%w": "u", "W" : "W", "%V": "W" }; var normalizer = { substitutes: function (m) { return normalizerSubstitutions[m]; }, interpreted: function (m, x) { var y; switch (m) { case "%u": return x.getDay() + 1; case "z": return x.getOrdinalNumber(); case "%j": return p(x.getOrdinalNumber(), 3); case "%U": var d1 = x.clone().set({month: 0, day: 1}).addDays(-1).moveToDayOfWeek(0), d2 = x.clone().addDays(1).moveToDayOfWeek(0, -1); return (d2 < d1) ? "00" : p((d2.getOrdinalNumber() - d1.getOrdinalNumber()) / 7 + 1); case "%W": return p(x.getWeek()); case "t": return $D.getDaysInMonth(x.getFullYear(), x.getMonth()); case "o": case "%G": return x.setWeek(x.getISOWeek()).toString("yyyy"); case "%g": return x._format("%G").slice(-2); case "a": case "%p": return t("tt").toLowerCase(); case "A": return t("tt").toUpperCase(); case "u": return p(x.getMilliseconds(), 3); case "I": return (x.isDaylightSavingTime()) ? 1 : 0; case "O": return x.getUTCOffset(); case "P": y = x.getUTCOffset(); return y.substring(0, y.length - 2) + ":" + y.substring(y.length - 2); case "B": var now = new Date(); return Math.floor(((now.getHours() * 3600) + (now.getMinutes() * 60) + now.getSeconds() + (now.getTimezoneOffset() + 60) * 60) / 86.4); case "c": return x.toISOString().replace(/\"/g, ""); case "U": return $D.strtotime("now"); case "%c": return t("d") + " " + t("t"); case "%C": return Math.floor(x.getFullYear() / 100 + 1); } }, shouldOverrideDefaults: function (m) { switch (m) { case "%e": return true; default: return false; } }, parse: function (m, context) { var formatString, c = context || new Date(); formatString = normalizer.substitutes(m); if (formatString) { return formatString; } formatString = normalizer.interpreted(m, c); if (formatString) { return formatString; } else { return m; } } }; $D.normalizeFormat = function (format, context) { return format.replace(/(%|\\)?.|%%/g, function(t){ return normalizer.parse(t, context); }); }; /** * Format a local Unix timestamp according to locale settings * * Example: * Date.strftime("%m/%d/%y", new Date()); // "04/13/08" * Date.strftime("c", "2008-04-13T17:52:03Z"); // "04/13/08" * * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @param {Number|String} The number representing the number of seconds that have elapsed since January 1, 1970 (local time). * @return {String} A string representation of the current Date object. */ $D.strftime = function (format, time) { var d = Date.parse(time); return d._format(format); }; /** * Parse any textual datetime description into a Unix timestamp. * A Unix timestamp is the number of seconds that have elapsed since January 1, 1970 (midnight UTC/GMT). * * Example: * Date.strtotime("04/13/08"); // 1208044800 * Date.strtotime("1970-01-01T00:00:00Z"); // 0 * * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @param {Object} A string or date object. * @return {String} A string representation of the current Date object. */ $D.strtotime = function (time) { var d = $D.parse(time); return Math.round($D.UTC(d.getUTCFullYear(), d.getUTCMonth(), d.getUTCDate(), d.getUTCHours(), d.getUTCMinutes(), d.getUTCSeconds(), d.getUTCMilliseconds()) / 1000); }; /** * Converts the value of the current Date object to its equivalent string representation using a PHP/Unix style of date format specifiers. * Format Specifiers * Format Description Example * ------ --------------------------------------------------------------------------- ----------------------- * %a abbreviated weekday name according to the current localed "Mon" through "Sun" * %A full weekday name according to the current localed "Sunday" through "Saturday" * %b abbreviated month name according to the current localed "Jan" through "Dec" * %B full month name according to the current locale "January" through "December" * %c preferred date and time representation for the current locale "4/13/2008 12:33 PM" * %C century number (the year divided by 100 and truncated to an integer) "00" to "99" * %d day of the month as a decimal number "01" to "31" * %D same as %m/%d/%y "04/13/08" * %e day of the month as a decimal number, a single digit is preceded by a space "1" to "31" * %g like %G, but without the century "08" * %G The 4-digit year corresponding to the ISO week number (see %V). "2008" * This has the same format and value as %Y, except that if the ISO week number * belongs to the previous or next year, that year is used instead. * %h same as %b "Jan" through "Dec" * %H hour as a decimal number using a 24-hour clock. "00" to "23" * %I hour as a decimal number using a 12-hour clock. "01" to "12" * %j day of the year as a decimal number. "001" to "366" * %m month as a decimal number. "01" to "12" * %M minute as a decimal number. "00" to "59" * %n newline character "\n" * %p either "am" or "pm" according to the given time value, or the "am" or "pm" * corresponding strings for the current locale. * %r time in a.m. and p.m. notation "8:44 PM" * %R time in 24 hour notation "20:44" * %S second as a decimal number "00" to "59" * %t tab character "\t" * %T current time, equal to %H:%M:%S "12:49:11" * %u weekday as a decimal number ["1", "7"], with "1" representing Monday "1" to "7" * %U week number of the current year as a decimal number, starting with the "0" to ("52" or "53") * first Sunday as the first day of the first week * %V The ISO 8601:1988 week number of the current year as a decimal number, "00" to ("52" or "53") * range 01 to 53, where week 1 is the first week that has at least 4 days * in the current year, and with Monday as the first day of the week. * (Use %G or %g for the year component that corresponds to the week number * for the specified timestamp.) * %W week number of the current year as a decimal number, starting with the "00" to ("52" or "53") * first Monday as the first day of the first week * %w day of the week as a decimal, Sunday being "0" "0" to "6" * %x preferred date representation for the current locale without the time "4/13/2008" * %X preferred time representation for the current locale without the date "12:53:05" * %y year as a decimal number without a century "00" "99" * %Y year as a decimal number including the century "2008" * %Z time zone or name or abbreviation "UTC", "EST", "PST" * %z same as %Z * %% a literal "%" characters "%" * d Day of the month, 2 digits with leading zeros "01" to "31" * D A textual representation of a day, three letters "Mon" through "Sun" * j Day of the month without leading zeros "1" to "31" * l A full textual representation of the day of the week (lowercase "L") "Sunday" through "Saturday" * N ISO-8601 numeric representation of the day of the week (added in PHP 5.1.0) "1" (for Monday) through "7" (for Sunday) * S English ordinal suffix for the day of the month, 2 characters "st", "nd", "rd" or "th". Works well with j * w Numeric representation of the day of the week "0" (for Sunday) through "6" (for Saturday) * z The day of the year (starting from "0") "0" through "365" * W ISO-8601 week number of year, weeks starting on Monday "00" to ("52" or "53") * F A full textual representation of a month, such as January or March "January" through "December" * m Numeric representation of a month, with leading zeros "01" through "12" * M A short textual representation of a month, three letters "Jan" through "Dec" * n Numeric representation of a month, without leading zeros "1" through "12" * t Number of days in the given month "28" through "31" * L Whether it's a leap year "1" if it is a leap year, "0" otherwise * o ISO-8601 year number. This has the same value as Y, except that if the "2008" * ISO week number (W) belongs to the previous or next year, that year * is used instead. * Y A full numeric representation of a year, 4 digits "2008" * y A two digit representation of a year "08" * a Lowercase Ante meridiem and Post meridiem "am" or "pm" * A Uppercase Ante meridiem and Post meridiem "AM" or "PM" * B Swatch Internet time "000" through "999" * g 12-hour format of an hour without leading zeros "1" through "12" * G 24-hour format of an hour without leading zeros "0" through "23" * h 12-hour format of an hour with leading zeros "01" through "12" * H 24-hour format of an hour with leading zeros "00" through "23" * i Minutes with leading zeros "00" to "59" * s Seconds, with leading zeros "00" through "59" * u Milliseconds "54321" * e Timezone identifier "UTC", "EST", "PST" * I Whether or not the date is in daylight saving time (uppercase i) "1" if Daylight Saving Time, "0" otherwise * O Difference to Greenwich time (GMT) in hours "+0200", "-0600" * P Difference to Greenwich time (GMT) with colon between hours and minutes "+02:00", "-06:00" * T Timezone abbreviation "UTC", "EST", "PST" * Z Timezone offset in seconds. The offset for timezones west of UTC is "-43200" through "50400" * always negative, and for those east of UTC is always positive. * c ISO 8601 date "2004-02-12T15:19:21+00:00" * r RFC 2822 formatted date "Thu, 21 Dec 2000 16:01:07 +0200" * U Seconds since the Unix Epoch (January 1 1970 00:00:00 GMT) "0" * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @return {String} A string representation of the current Date object. */ var formatReplace = function (context) { return function (m) { var formatString, override = false; if (m.charAt(0) === "\\" || m.substring(0, 2) === "%%") { return m.replace("\\", "").replace("%%", "%"); } override = normalizer.shouldOverrideDefaults(m); formatString = $D.normalizeFormat(m, context); if (formatString) { return context.toString(formatString, override); } }; }; $P._format = function (format) { var formatter = formatReplace(this); if (!format) { return this._toString(); } else { return format.replace(/(%|\\)?.|%%/g, formatter); } }; if (!$P.format) { $P.format = $P._format; } }()); (function () { "use strict"; var gFn = function (attr) { return function () { return this[attr]; }; }; var sFn = function (attr) { return function (val) { this[attr] = val; return this; }; }; var attrs = ["years", "months", "days", "hours", "minutes", "seconds", "milliseconds"]; var addSetFuncs = function (context, attrs) { for (var i = 0; i < attrs.length ; i++) { var $a = attrs[i], $b = $a.slice(0, 1).toUpperCase() + $a.slice(1); context.prototype[$a] = 0; context.prototype["get" + $b] = gFn($a); context.prototype["set" + $b] = sFn($a); } }; /** * new TimeSpan(milliseconds); * new TimeSpan(days, hours, minutes, seconds); * new TimeSpan(days, hours, minutes, seconds, milliseconds); */ var TimeSpan = function (days, hours, minutes, seconds, milliseconds) { if (arguments.length === 1 && typeof days === "number") { var orient = (days < 0) ? -1 : +1; var millsLeft = Math.abs(days); this.setDays(Math.floor(millsLeft / 86400000) * orient); millsLeft = millsLeft % 86400000; this.setHours(Math.floor(millsLeft / 3600000) * orient); millsLeft = millsLeft % 3600000; this.setMinutes(Math.floor(millsLeft / 60000) * orient); millsLeft = millsLeft % 60000; this.setSeconds(Math.floor(millsLeft / 1000) * orient); millsLeft = millsLeft % 1000; this.setMilliseconds(millsLeft * orient); } else { this.set(days, hours, minutes, seconds, milliseconds); } this.getTotalMilliseconds = function () { return (this.getDays() * 86400000) + (this.getHours() * 3600000) + (this.getMinutes() * 60000) + (this.getSeconds() * 1000); }; this.compareTo = function (time) { var t1 = new Date(1970, 1, 1, this.getHours(), this.getMinutes(), this.getSeconds()), t2; if (time === null) { t2 = new Date(1970, 1, 1, 0, 0, 0); } else { t2 = new Date(1970, 1, 1, time.getHours(), time.getMinutes(), time.getSeconds()); } return (t1 < t2) ? -1 : (t1 > t2) ? 1 : 0; }; this.equals = function (time) { return (this.compareTo(time) === 0); }; this.add = function (time) { return (time === null) ? this : this.addSeconds(time.getTotalMilliseconds() / 1000); }; this.subtract = function (time) { return (time === null) ? this : this.addSeconds(-time.getTotalMilliseconds() / 1000); }; this.addDays = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 86400000)); }; this.addHours = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 3600000)); }; this.addMinutes = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 60000)); }; this.addSeconds = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 1000)); }; this.addMilliseconds = function (n) { return new TimeSpan(this.getTotalMilliseconds() + n); }; this.get12HourHour = function () { return (this.getHours() > 12) ? this.getHours() - 12 : (this.getHours() === 0) ? 12 : this.getHours(); }; this.getDesignator = function () { return (this.getHours() < 12) ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator; }; this.toString = function (format) { this._toString = function () { if (this.getDays() !== null && this.getDays() > 0) { return this.getDays() + "." + this.getHours() + ":" + this.p(this.getMinutes()) + ":" + this.p(this.getSeconds()); } else { return this.getHours() + ":" + this.p(this.getMinutes()) + ":" + this.p(this.getSeconds()); } }; this.p = function (s) { return (s.toString().length < 2) ? "0" + s : s; }; var me = this; return format ? format.replace(/dd?|HH?|hh?|mm?|ss?|tt?/g, function (format) { switch (format) { case "d": return me.getDays(); case "dd": return me.p(me.getDays()); case "H": return me.getHours(); case "HH": return me.p(me.getHours()); case "h": return me.get12HourHour(); case "hh": return me.p(me.get12HourHour()); case "m": return me.getMinutes(); case "mm": return me.p(me.getMinutes()); case "s": return me.getSeconds(); case "ss": return me.p(me.getSeconds()); case "t": return ((me.getHours() < 12) ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator).substring(0, 1); case "tt": return (me.getHours() < 12) ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator; } } ) : this._toString(); }; return this; }; addSetFuncs(TimeSpan, attrs.slice(2)); TimeSpan.prototype.set = function (days, hours, minutes, seconds, milliseconds){ this.setDays(days || this.getDays()); this.setHours(hours || this.getHours()); this.setMinutes(minutes || this.getMinutes()); this.setSeconds(seconds || this.getSeconds()); this.setMilliseconds(milliseconds || this.getMilliseconds()); }; /** * Gets the time of day for this date instances. * @return {TimeSpan} TimeSpan */ Date.prototype.getTimeOfDay = function () { return new TimeSpan(0, this.getHours(), this.getMinutes(), this.getSeconds(), this.getMilliseconds()); }; Date.TimeSpan = TimeSpan; if (typeof window !== "undefined" ) { // keeping API compatible for v1.x window.TimeSpan = TimeSpan; } }()); (function () { "use strict"; var attrs = ["years", "months", "days", "hours", "minutes", "seconds", "milliseconds"]; var gFn = function (attr) { return function () { return this[attr]; }; }; var sFn = function (attr) { return function (val) { this[attr] = val; return this; }; }; var addSetFuncs = function (context, attrs) { for (var i = 0; i < attrs.length ; i++) { var $a = attrs[i], $b = $a.slice(0, 1).toUpperCase() + $a.slice(1); context.prototype[$a] = 0; context.prototype["get" + $b] = gFn($a); context.prototype["set" + $b] = sFn($a); } }; var setMonthsAndYears = function (orient, d1, d2, context) { function inc() { d1.addMonths(-orient); context.months++; if (context.months === 12) { context.years++; context.months = 0; } } if (orient === +1) { while (d1 > d2) { inc(); } } else { while (d1 < d2) { inc(); } } context.months--; context.months *= orient; context.years *= orient; }; var adjustForDST = function(orient, startDate, endDate) { var hasDSTMismatch = (false === (startDate.isDaylightSavingTime() === endDate.isDaylightSavingTime())); if (hasDSTMismatch && orient === 1) { startDate.addHours(-1); } else if (hasDSTMismatch) { startDate.addHours(1); } }; /** * TimePeriod(startDate, endDate); * TimePeriod(years, months, days, hours, minutes, seconds, milliseconds); */ var TimePeriod = function (years, months, days, hours, minutes, seconds, milliseconds) { if (arguments.length === 7) { this.set(years, months, days, hours, minutes, seconds, milliseconds); } else if (arguments.length === 2 && arguments[0] instanceof Date && arguments[1] instanceof Date) { var startDate = arguments[0].clone(); var endDate = arguments[1].clone(); var orient = (startDate > endDate) ? +1 : -1; this.dates = { start: arguments[0].clone(), end: arguments[1].clone() }; setMonthsAndYears(orient, startDate, endDate, this); adjustForDST(orient, startDate, endDate); // // TODO - adjust for DST var diff = endDate - startDate; if (diff !== 0) { var ts = new TimeSpan(diff); this.set(this.years, this.months, ts.getDays(), ts.getHours(), ts.getMinutes(), ts.getSeconds(), ts.getMilliseconds()); } } return this; }; // create all the set functions. addSetFuncs(TimePeriod, attrs); TimePeriod.prototype.set = function (years, months, days, hours, minutes, seconds, milliseconds){ this.setYears(years || this.getYears()); this.setMonths(months || this.getMonths()); this.setDays(days || this.getDays()); this.setHours(hours || this.getHours()); this.setMinutes(minutes || this.getMinutes()); this.setSeconds(seconds || this.getSeconds()); this.setMilliseconds(milliseconds || this.getMilliseconds()); }; Date.TimePeriod = TimePeriod; if (typeof window !== "undefined") { // keeping API compatible for v1.x window.TimePeriod = TimePeriod; } }()); ================================================ FILE: build/date-es-CL.js ================================================ /** * @overview datejs * @version 1.0.0-rc3 * @author Gregory Wild-Smith * @copyright 2015 Gregory Wild-Smith * @license MIT * @homepage https://github.com/abritinthebay/datejs */ /* * DateJS Culture String File * Country Code: es-CL * Name: Spanish (Chile) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["es-CL"] = { "name": "es-CL", "englishName": "Spanish (Chile)", "nativeName": "Español (Chile)", "Sunday": "domingo", "Monday": "lunes", "Tuesday": "martes", "Wednesday": "miércoles", "Thursday": "jueves", "Friday": "viernes", "Saturday": "sábado", "Sun": "dom", "Mon": "lun", "Tue": "mar", "Wed": "mié", "Thu": "jue", "Fri": "vie", "Sat": "sáb", "Su": "do", "Mo": "lu", "Tu": "ma", "We": "mi", "Th": "ju", "Fr": "vi", "Sa": "sá", "S_Sun_Initial": "d", "M_Mon_Initial": "l", "T_Tue_Initial": "m", "W_Wed_Initial": "m", "T_Thu_Initial": "j", "F_Fri_Initial": "v", "S_Sat_Initial": "s", "January": "enero", "February": "febrero", "March": "marzo", "April": "abril", "May": "mayo", "June": "junio", "July": "julio", "August": "agosto", "September": "septiembre", "October": "octubre", "November": "noviembre", "December": "diciembre", "Jan_Abbr": "ene", "Feb_Abbr": "feb", "Mar_Abbr": "mar", "Apr_Abbr": "abr", "May_Abbr": "may", "Jun_Abbr": "jun", "Jul_Abbr": "jul", "Aug_Abbr": "ago", "Sep_Abbr": "sep", "Oct_Abbr": "oct", "Nov_Abbr": "nov", "Dec_Abbr": "dic", "AM": "", "PM": "", "firstDayOfWeek": 0, "twoDigitYearMax": 2029, "mdy": "dmy", "M/d/yyyy": "dd-MM-yyyy", "dddd, MMMM dd, yyyy": "dddd, dd' [de] 'MMMM' [de] 'yyyy", "h:mm tt": "H:mm", "h:mm:ss tt": "H:mm:ss", "dddd, MMMM dd, yyyy h:mm:ss tt": "dddd, dd' [de] 'MMMM' [de] 'yyyy H:mm:ss", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "dd MMMM", "MMMM, yyyy": "MMMM' [de] 'yyyy", "/jan(uary)?/": "ene(ro)?", "/feb(ruary)?/": "feb(rero)?", "/mar(ch)?/": "mar(zo)?", "/apr(il)?/": "abr(il)?", "/may/": "may(o)?", "/jun(e)?/": "jun(io)?", "/jul(y)?/": "jul(io)?", "/aug(ust)?/": "ago(sto)?", "/sep(t(ember)?)?/": "sep(tiembre)?", "/oct(ober)?/": "oct(ubre)?", "/nov(ember)?/": "nov(iembre)?", "/dec(ember)?/": "dic(iembre)?", "/^su(n(day)?)?/": "^do(m(ingo)?)?", "/^mo(n(day)?)?/": "^lu(n(es)?)?", "/^tu(e(s(day)?)?)?/": "^ma(r(tes)?)?", "/^we(d(nesday)?)?/": "^mi(é(rcoles)?)?", "/^th(u(r(s(day)?)?)?)?/": "^ju(e(ves)?)?", "/^fr(i(day)?)?/": "^vi(e(rnes)?)?", "/^sa(t(urday)?)?/": "^sá(b(ado)?)?", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "es-CL"; /** * @overview datejs * @version 1.0.0-rc3 * @author Gregory Wild-Smith * @copyright 2015 Gregory Wild-Smith * @license MIT * @homepage https://github.com/abritinthebay/datejs */(function () { var $D = Date; var lang = Date.CultureStrings ? Date.CultureStrings.lang : null; var loggedKeys = {}; // for debug purposes. var getText = { getFromKey: function (key, countryCode) { var output; if (Date.CultureStrings && Date.CultureStrings[countryCode] && Date.CultureStrings[countryCode][key]) { output = Date.CultureStrings[countryCode][key]; } else { output = getText.buildFromDefault(key); } if (key.charAt(0) === "/") { // Assume it's a regex output = getText.buildFromRegex(key, countryCode); } return output; }, getFromObjectValues: function (obj, countryCode) { var key, output = {}; for(key in obj) { if (obj.hasOwnProperty(key)) { output[key] = getText.getFromKey(obj[key], countryCode); } } return output; }, getFromObjectKeys: function (obj, countryCode) { var key, output = {}; for(key in obj) { if (obj.hasOwnProperty(key)) { output[getText.getFromKey(key, countryCode)] = obj[key]; } } return output; }, getFromArray: function (arr, countryCode) { var output = []; for (var i=0; i < arr.length; i++){ if (i in arr) { output[i] = getText.getFromKey(arr[i], countryCode); } } return output; }, buildFromDefault: function (key) { var output, length, split, last; switch(key) { case "name": output = "en-US"; break; case "englishName": output = "English (United States)"; break; case "nativeName": output = "English (United States)"; break; case "twoDigitYearMax": output = 2049; break; case "firstDayOfWeek": output = 0; break; default: output = key; split = key.split("_"); length = split.length; if (length > 1 && key.charAt(0) !== "/") { // if the key isn't a regex and it has a split. last = split[(length - 1)].toLowerCase(); if (last === "initial" || last === "abbr") { output = split[0]; } } break; } return output; }, buildFromRegex: function (key, countryCode) { var output; if (Date.CultureStrings && Date.CultureStrings[countryCode] && Date.CultureStrings[countryCode][key]) { output = new RegExp(Date.CultureStrings[countryCode][key], "i"); } else { output = new RegExp(key.replace(new RegExp("/", "g"),""), "i"); } return output; } }; var shallowMerge = function (obj1, obj2) { for (var attrname in obj2) { if (obj2.hasOwnProperty(attrname)) { obj1[attrname] = obj2[attrname]; } } }; var __ = function (key, language) { var countryCode = (language) ? language : lang; loggedKeys[key] = key; if (typeof key === "object") { if (key instanceof Array) { return getText.getFromArray(key, countryCode); } else { return getText.getFromObjectKeys(key, countryCode); } } else { return getText.getFromKey(key, countryCode); } }; var loadI18nScript = function (code) { // paatterned after jQuery's getScript. var url = Date.Config.i18n + code + ".js"; var head = document.getElementsByTagName("head")[0] || document.documentElement; var script = document.createElement("script"); script.src = url; var completed = false; var events = { done: function (){} // placeholder function }; // Attach handlers for all browsers script.onload = script.onreadystatechange = function() { if ( !completed && (!this.readyState || this.readyState === "loaded" || this.readyState === "complete") ) { events.done(); head.removeChild(script); } }; setTimeout(function() { head.insertBefore(script, head.firstChild); }, 0); // allows return to execute first return { done: function (cb) { events.done = function() { if (cb) { setTimeout(cb,0); } }; } }; }; var buildInfo = { buildFromMethodHash: function (obj) { var key; for(key in obj) { if (obj.hasOwnProperty(key)) { obj[key] = buildInfo[obj[key]](); } } return obj; }, timeZoneDST: function () { var DST = { "CHADT": "+1345", "NZDT": "+1300", "AEDT": "+1100", "ACDT": "+1030", "AZST": "+0500", "IRDT": "+0430", "EEST": "+0300", "CEST": "+0200", "BST": "+0100", "PMDT": "-0200", "ADT": "-0300", "NDT": "-0230", "EDT": "-0400", "CDT": "-0500", "MDT": "-0600", "PDT": "-0700", "AKDT": "-0800", "HADT": "-0900" }; return __(DST); }, timeZoneStandard: function () { var standard = { "LINT": "+1400", "TOT": "+1300", "CHAST": "+1245", "NZST": "+1200", "NFT": "+1130", "SBT": "+1100", "AEST": "+1000", "ACST": "+0930", "JST": "+0900", "CWST": "+0845", "CT": "+0800", "ICT": "+0700", "MMT": "+0630", "BST": "+0600", "NPT": "+0545", "IST": "+0530", "PKT": "+0500", "AFT": "+0430", "MSK": "+0400", "IRST": "+0330", "FET": "+0300", "EET": "+0200", "CET": "+0100", "GMT": "+0000", "UTC": "+0000", "CVT": "-0100", "GST": "-0200", "BRT": "-0300", "NST": "-0330", "AST": "-0400", "EST": "-0500", "CST": "-0600", "MST": "-0700", "PST": "-0800", "AKST": "-0900", "MIT": "-0930", "HST": "-1000", "SST": "-1100", "BIT": "-1200" }; return __(standard); }, timeZones: function (data) { var zone; data.timezones = []; for (zone in data.abbreviatedTimeZoneStandard) { if (data.abbreviatedTimeZoneStandard.hasOwnProperty(zone)) { data.timezones.push({ name: zone, offset: data.abbreviatedTimeZoneStandard[zone]}); } } for (zone in data.abbreviatedTimeZoneDST) { if (data.abbreviatedTimeZoneDST.hasOwnProperty(zone)) { data.timezones.push({ name: zone, offset: data.abbreviatedTimeZoneDST[zone], dst: true}); } } return data.timezones; }, days: function () { return __(["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"]); }, dayAbbr: function () { return __(["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"]); }, dayShortNames: function () { return __(["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"]); }, dayFirstLetters: function () { return __(["S_Sun_Initial", "M_Mon_Initial", "T_Tues_Initial", "W_Wed_Initial", "T_Thu_Initial", "F_Fri_Initial", "S_Sat_Initial"]); }, months: function () { return __(["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"]); }, monthAbbr: function () { return __(["Jan_Abbr", "Feb_Abbr", "Mar_Abbr", "Apr_Abbr", "May_Abbr", "Jun_Abbr", "Jul_Abbr", "Aug_Abbr", "Sep_Abbr", "Oct_Abbr", "Nov_Abbr", "Dec_Abbr"]); }, formatPatterns: function () { return getText.getFromObjectValues({ shortDate: "M/d/yyyy", longDate: "dddd, MMMM dd, yyyy", shortTime: "h:mm tt", longTime: "h:mm:ss tt", fullDateTime: "dddd, MMMM dd, yyyy h:mm:ss tt", sortableDateTime: "yyyy-MM-ddTHH:mm:ss", universalSortableDateTime: "yyyy-MM-dd HH:mm:ssZ", rfc1123: "ddd, dd MMM yyyy HH:mm:ss", monthDay: "MMMM dd", yearMonth: "MMMM, yyyy" }, Date.i18n.currentLanguage()); }, regex: function () { return getText.getFromObjectValues({ inTheMorning: "/( in the )(morn(ing)?)\\b/", thisMorning: "/(this )(morn(ing)?)\\b/", amThisMorning: "/(\b\\d(am)? )(this )(morn(ing)?)/", inTheEvening: "/( in the )(even(ing)?)\\b/", thisEvening: "/(this )(even(ing)?)\\b/", pmThisEvening: "/(\b\\d(pm)? )(this )(even(ing)?)/", jan: "/jan(uary)?/", feb: "/feb(ruary)?/", mar: "/mar(ch)?/", apr: "/apr(il)?/", may: "/may/", jun: "/jun(e)?/", jul: "/jul(y)?/", aug: "/aug(ust)?/", sep: "/sep(t(ember)?)?/", oct: "/oct(ober)?/", nov: "/nov(ember)?/", dec: "/dec(ember)?/", sun: "/^su(n(day)?)?/", mon: "/^mo(n(day)?)?/", tue: "/^tu(e(s(day)?)?)?/", wed: "/^we(d(nesday)?)?/", thu: "/^th(u(r(s(day)?)?)?)?/", fri: "/fr(i(day)?)?/", sat: "/^sa(t(urday)?)?/", future: "/^next/", past: "/^last|past|prev(ious)?/", add: "/^(\\+|aft(er)?|from|hence)/", subtract: "/^(\\-|bef(ore)?|ago)/", yesterday: "/^yes(terday)?/", today: "/^t(od(ay)?)?/", tomorrow: "/^tom(orrow)?/", now: "/^n(ow)?/", millisecond: "/^ms|milli(second)?s?/", second: "/^sec(ond)?s?/", minute: "/^mn|min(ute)?s?/", hour: "/^h(our)?s?/", week: "/^w(eek)?s?/", month: "/^m(onth)?s?/", day: "/^d(ay)?s?/", year: "/^y(ear)?s?/", shortMeridian: "/^(a|p)/", longMeridian: "/^(a\\.?m?\\.?|p\\.?m?\\.?)/", timezone: "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/", ordinalSuffix: "/^\\s*(st|nd|rd|th)/", timeContext: "/^\\s*(\\:|a(?!u|p)|p)/" }, Date.i18n.currentLanguage()); } }; var CultureInfo = function () { var info = getText.getFromObjectValues({ name: "name", englishName: "englishName", nativeName: "nativeName", amDesignator: "AM", pmDesignator: "PM", firstDayOfWeek: "firstDayOfWeek", twoDigitYearMax: "twoDigitYearMax", dateElementOrder: "mdy" }, Date.i18n.currentLanguage()); var constructedInfo = buildInfo.buildFromMethodHash({ dayNames: "days", abbreviatedDayNames: "dayAbbr", shortestDayNames: "dayShortNames", firstLetterDayNames: "dayFirstLetters", monthNames: "months", abbreviatedMonthNames: "monthAbbr", formatPatterns: "formatPatterns", regexPatterns: "regex", abbreviatedTimeZoneDST: "timeZoneDST", abbreviatedTimeZoneStandard: "timeZoneStandard" }); shallowMerge(info, constructedInfo); buildInfo.timeZones(info); return info; }; $D.i18n = { __: function (key, lang) { return __(key, lang); }, currentLanguage: function () { return lang || "en-US"; }, setLanguage: function (code, force, cb) { var async = false; if (force || code === "en-US" || (!!Date.CultureStrings && !!Date.CultureStrings[code])) { lang = code; Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings.lang = code; Date.CultureInfo = new CultureInfo(); } else { if (!(!!Date.CultureStrings && !!Date.CultureStrings[code])) { if (typeof exports !== "undefined" && this.exports !== exports) { // we're in a Node enviroment, load it using require try { require("../i18n/" + code + ".js"); lang = code; Date.CultureStrings.lang = code; Date.CultureInfo = new CultureInfo(); } catch (e) { // var str = "The language for '" + code + "' could not be loaded by Node. It likely does not exist."; throw new Error("The DateJS IETF language tag '" + code + "' could not be loaded by Node. It likely does not exist."); } } else if (Date.Config && Date.Config.i18n) { // we know the location of the files, so lets load them async = true; loadI18nScript(code).done(function(){ lang = code; Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings.lang = code; Date.CultureInfo = new CultureInfo(); $D.Parsing.Normalizer.buildReplaceData(); // because this is async if ($D.Grammar) { $D.Grammar.buildGrammarFormats(); // so we can parse those strings... } if (cb) { setTimeout(cb,0); } }); } else { Date.console.error("The DateJS IETF language tag '" + code + "' is not available and has not been loaded."); return false; } } } $D.Parsing.Normalizer.buildReplaceData(); // rebuild normalizer strings if ($D.Grammar) { $D.Grammar.buildGrammarFormats(); // so we can parse those strings... } if (!async && cb) { setTimeout(cb,0); } }, getLoggedKeys: function () { return loggedKeys; }, updateCultureInfo: function () { Date.CultureInfo = new CultureInfo(); } }; $D.i18n.updateCultureInfo(); // run automatically }()); (function () { var $D = Date, $P = $D.prototype, p = function (s, l) { if (!l) { l = 2; } return ("000" + s).slice(l * -1); }; if (typeof window !== "undefined" && typeof window.console !== "undefined" && typeof window.console.log !== "undefined") { $D.console = console; // used only to raise non-critical errors if available } else { // set mock so we don't give errors. $D.console = { log: function(){}, error: function(){} }; } $D.Config = $D.Config || {}; $D.initOverloads = function() { /** * Overload of Date.now. Allows an alternate call for Date.now where it returns the * current Date as an object rather than just milliseconds since the Unix Epoch. * * Also provides an implementation of now() for browsers (IE<9) that don't have it. * * Backwards compatible so with work with either: * Date.now() [returns ms] * or * Date.now(true) [returns Date] */ if (!$D.now) { $D._now = function now() { return new Date().getTime(); }; } else if (!$D._now) { $D._now = $D.now; } $D.now = function (returnObj) { if (returnObj) { return $D.present(); } else { return $D._now(); } }; if ( !$P.toISOString ) { $P.toISOString = function() { return this.getUTCFullYear() + "-" + p(this.getUTCMonth() + 1) + "-" + p(this.getUTCDate()) + "T" + p(this.getUTCHours()) + ":" + p(this.getUTCMinutes()) + ":" + p(this.getUTCSeconds()) + "." + String( (this.getUTCMilliseconds()/1000).toFixed(3)).slice(2, 5) + "Z"; }; } // private if ( $P._toString === undefined ){ $P._toString = $P.toString; } }; $D.initOverloads(); /** * Gets a date that is set to the current date. The time is set to the start of the day (00:00 or 12:00 AM). * @return {Date} The current date. */ $D.today = function () { return new Date().clearTime(); }; /** * Gets a date that is set to the current date and time (same as new Date, but chainable) * @return {Date} The current date. */ $D.present = function () { return new Date(); }; /** * Compares the first date to the second date and returns an number indication of their relative values. * @param {Date} First Date object to compare [Required]. * @param {Date} Second Date object to compare to [Required]. * @return {Number} -1 = date1 is lessthan date2. 0 = values are equal. 1 = date1 is greaterthan date2. */ $D.compare = function (date1, date2) { if (isNaN(date1) || isNaN(date2)) { throw new Error(date1 + " - " + date2); } else if (date1 instanceof Date && date2 instanceof Date) { return (date1 < date2) ? -1 : (date1 > date2) ? 1 : 0; } else { throw new TypeError(date1 + " - " + date2); } }; /** * Compares the first Date object to the second Date object and returns true if they are equal. * @param {Date} First Date object to compare [Required] * @param {Date} Second Date object to compare to [Required] * @return {Boolean} true if dates are equal. false if they are not equal. */ $D.equals = function (date1, date2) { return (date1.compareTo(date2) === 0); }; /** * Gets the language appropriate day name when given the day number(0-6) * eg - 0 == Sunday * @return {String} The day name */ $D.getDayName = function (n) { return Date.CultureInfo.dayNames[n]; }; /** * Gets the day number (0-6) if given a CultureInfo specific string which is a valid dayName, abbreviatedDayName or shortestDayName (two char). * @param {String} The name of the day (eg. "Monday, "Mon", "tuesday", "tue", "We", "we"). * @return {Number} The day number */ $D.getDayNumberFromName = function (name) { var n = Date.CultureInfo.dayNames, m = Date.CultureInfo.abbreviatedDayNames, o = Date.CultureInfo.shortestDayNames, s = name.toLowerCase(); for (var i = 0; i < n.length; i++) { if (n[i].toLowerCase() === s || m[i].toLowerCase() === s || o[i].toLowerCase() === s) { return i; } } return -1; }; /** * Gets the month number (0-11) if given a Culture Info specific string which is a valid monthName or abbreviatedMonthName. * @param {String} The name of the month (eg. "February, "Feb", "october", "oct"). * @return {Number} The day number */ $D.getMonthNumberFromName = function (name) { var n = Date.CultureInfo.monthNames, m = Date.CultureInfo.abbreviatedMonthNames, s = name.toLowerCase(); for (var i = 0; i < n.length; i++) { if (n[i].toLowerCase() === s || m[i].toLowerCase() === s) { return i; } } return -1; }; /** * Gets the language appropriate month name when given the month number(0-11) * eg - 0 == January * @return {String} The month name */ $D.getMonthName = function (n) { return Date.CultureInfo.monthNames[n]; }; /** * Determines if the current date instance is within a LeapYear. * @param {Number} The year. * @return {Boolean} true if date is within a LeapYear, otherwise false. */ $D.isLeapYear = function (year) { return ((year % 4 === 0 && year % 100 !== 0) || year % 400 === 0); }; /** * Gets the number of days in the month, given a year and month value. Automatically corrects for LeapYear. * @param {Number} The year. * @param {Number} The month (0-11). * @return {Number} The number of days in the month. */ $D.getDaysInMonth = function (year, month) { if (!month && $D.validateMonth(year)) { month = year; year = Date.today().getFullYear(); } return [31, ($D.isLeapYear(year) ? 29 : 28), 31, 30, 31, 30, 31, 31, 30, 31, 30, 31][month]; }; $P.getDaysInMonth = function () { return $D.getDaysInMonth(this.getFullYear(), this.getMonth()); }; $D.getTimezoneAbbreviation = function (offset, dst) { var p, n = (dst || false) ? Date.CultureInfo.abbreviatedTimeZoneDST : Date.CultureInfo.abbreviatedTimeZoneStandard; for (p in n) { if (n.hasOwnProperty(p)) { if (n[p] === offset) { return p; } } } return null; }; $D.getTimezoneOffset = function (name, dst) { var i, a =[], z = Date.CultureInfo.timezones; if (!name) { name = (new Date()).getTimezone();} for (i = 0; i < z.length; i++) { if (z[i].name === name.toUpperCase()) { a.push(i); } } if (!z[a[0]]) { return null; } if (a.length === 1 || !dst) { return z[a[0]].offset; } else { for (i=0; i < a.length; i++) { if (z[a[i]].dst) { return z[a[i]].offset; } } } }; $D.getQuarter = function (d) { d = d || new Date(); // If no date supplied, use today var q = [1,2,3,4]; return q[Math.floor(d.getMonth() / 3)]; // ~~~ is a bitwise op. Faster than Math.floor }; $D.getDaysLeftInQuarter = function (d) { d = d || new Date(); var qEnd = new Date(d); qEnd.setMonth(qEnd.getMonth() + 3 - qEnd.getMonth() % 3, 0); return Math.floor((qEnd - d) / 8.64e7); }; // private var validate = function (n, min, max, name) { name = name ? name : "Object"; if (typeof n === "undefined") { return false; } else if (typeof n !== "number") { throw new TypeError(n + " is not a Number."); } else if (n < min || n > max) { // As failing validation is *not* an exceptional circumstance // lets not throw a RangeError Exception here. // It's semantically correct but it's not sensible. return false; } return true; }; /** * Validates the number is within an acceptable range for milliseconds [0-999]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateMillisecond = function (value) { return validate(value, 0, 999, "millisecond"); }; /** * Validates the number is within an acceptable range for seconds [0-59]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateSecond = function (value) { return validate(value, 0, 59, "second"); }; /** * Validates the number is within an acceptable range for minutes [0-59]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateMinute = function (value) { return validate(value, 0, 59, "minute"); }; /** * Validates the number is within an acceptable range for hours [0-23]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateHour = function (value) { return validate(value, 0, 23, "hour"); }; /** * Validates the number is within an acceptable range for the days in a month [0-MaxDaysInMonth]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateDay = function (value, year, month) { if (year === undefined || year === null || month === undefined || month === null) { return false;} return validate(value, 1, $D.getDaysInMonth(year, month), "day"); }; /** * Validates the number is within an acceptable range for months [0-11]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateWeek = function (value) { return validate(value, 0, 53, "week"); }; /** * Validates the number is within an acceptable range for months [0-11]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateMonth = function (value) { return validate(value, 0, 11, "month"); }; /** * Validates the number is within an acceptable range for years. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateYear = function (value) { /** * Per ECMAScript spec the range of times supported by Date objects is * exactly -100,000,000 days to +100,000,000 days measured relative to * midnight at the beginning of 01 January, 1970 UTC. * This gives a range of 8,640,000,000,000,000 milliseconds to either * side of 01 January, 1970 UTC. * * Earliest possible date: Tue, 20 Apr 271,822 B.C. 00:00:00 UTC * Latest possible date: Sat, 13 Sep 275,760 00:00:00 UTC */ return validate(value, -271822, 275760, "year"); }; $D.validateTimezone = function(value) { var timezones = {"ACDT":1,"ACST":1,"ACT":1,"ADT":1,"AEDT":1,"AEST":1,"AFT":1,"AKDT":1,"AKST":1,"AMST":1,"AMT":1,"ART":1,"AST":1,"AWDT":1,"AWST":1,"AZOST":1,"AZT":1,"BDT":1,"BIOT":1,"BIT":1,"BOT":1,"BRT":1,"BST":1,"BTT":1,"CAT":1,"CCT":1,"CDT":1,"CEDT":1,"CEST":1,"CET":1,"CHADT":1,"CHAST":1,"CHOT":1,"ChST":1,"CHUT":1,"CIST":1,"CIT":1,"CKT":1,"CLST":1,"CLT":1,"COST":1,"COT":1,"CST":1,"CT":1,"CVT":1,"CWST":1,"CXT":1,"DAVT":1,"DDUT":1,"DFT":1,"EASST":1,"EAST":1,"EAT":1,"ECT":1,"EDT":1,"EEDT":1,"EEST":1,"EET":1,"EGST":1,"EGT":1,"EIT":1,"EST":1,"FET":1,"FJT":1,"FKST":1,"FKT":1,"FNT":1,"GALT":1,"GAMT":1,"GET":1,"GFT":1,"GILT":1,"GIT":1,"GMT":1,"GST":1,"GYT":1,"HADT":1,"HAEC":1,"HAST":1,"HKT":1,"HMT":1,"HOVT":1,"HST":1,"ICT":1,"IDT":1,"IOT":1,"IRDT":1,"IRKT":1,"IRST":1,"IST":1,"JST":1,"KGT":1,"KOST":1,"KRAT":1,"KST":1,"LHST":1,"LINT":1,"MAGT":1,"MART":1,"MAWT":1,"MDT":1,"MET":1,"MEST":1,"MHT":1,"MIST":1,"MIT":1,"MMT":1,"MSK":1,"MST":1,"MUT":1,"MVT":1,"MYT":1,"NCT":1,"NDT":1,"NFT":1,"NPT":1,"NST":1,"NT":1,"NUT":1,"NZDT":1,"NZST":1,"OMST":1,"ORAT":1,"PDT":1,"PET":1,"PETT":1,"PGT":1,"PHOT":1,"PHT":1,"PKT":1,"PMDT":1,"PMST":1,"PONT":1,"PST":1,"PYST":1,"PYT":1,"RET":1,"ROTT":1,"SAKT":1,"SAMT":1,"SAST":1,"SBT":1,"SCT":1,"SGT":1,"SLST":1,"SRT":1,"SST":1,"SYOT":1,"TAHT":1,"THA":1,"TFT":1,"TJT":1,"TKT":1,"TLT":1,"TMT":1,"TOT":1,"TVT":1,"UCT":1,"ULAT":1,"UTC":1,"UYST":1,"UYT":1,"UZT":1,"VET":1,"VLAT":1,"VOLT":1,"VOST":1,"VUT":1,"WAKT":1,"WAST":1,"WAT":1,"WEDT":1,"WEST":1,"WET":1,"WST":1,"YAKT":1,"YEKT":1,"Z":1}; return (timezones[value] === 1); }; $D.validateTimezoneOffset= function(value) { // timezones go from +14hrs to -12hrs, the +X hours are negative offsets. return (value > -841 && value < 721); }; }()); (function () { var $D = Date, $P = $D.prototype, p = function (s, l) { if (!l) { l = 2; } return ("000" + s).slice(l * -1); }; var validateConfigObject = function (obj) { var result = {}, self = this, prop, testFunc; testFunc = function (prop, func, value) { if (prop === "day") { var month = (obj.month !== undefined) ? obj.month : self.getMonth(); var year = (obj.year !== undefined) ? obj.year : self.getFullYear(); return $D[func](value, year, month); } else { return $D[func](value); } }; for (prop in obj) { if (Object.prototype.hasOwnProperty.call(obj, prop)) { var func = "validate" + prop.charAt(0).toUpperCase() + prop.slice(1); if ($D[func] && obj[prop] !== null && testFunc(prop, func, obj[prop])) { result[prop] = obj[prop]; } } } return result; }; /** * Resets the time of this Date object to 12:00 AM (00:00), which is the start of the day. * @param {Boolean} .clone() this date instance before clearing Time * @return {Date} this */ $P.clearTime = function () { this.setHours(0); this.setMinutes(0); this.setSeconds(0); this.setMilliseconds(0); return this; }; /** * Resets the time of this Date object to the current time ('now'). * @return {Date} this */ $P.setTimeToNow = function () { var n = new Date(); this.setHours(n.getHours()); this.setMinutes(n.getMinutes()); this.setSeconds(n.getSeconds()); this.setMilliseconds(n.getMilliseconds()); return this; }; /** * Returns a new Date object that is an exact date and time copy of the original instance. * @return {Date} A new Date instance */ $P.clone = function () { return new Date(this.getTime()); }; /** * Compares this instance to a Date object and returns an number indication of their relative values. * @param {Date} Date object to compare [Required] * @return {Number} -1 = this is lessthan date. 0 = values are equal. 1 = this is greaterthan date. */ $P.compareTo = function (date) { return Date.compare(this, date); }; /** * Compares this instance to another Date object and returns true if they are equal. * @param {Date} Date object to compare. If no date to compare, new Date() [now] is used. * @return {Boolean} true if dates are equal. false if they are not equal. */ $P.equals = function (date) { return Date.equals(this, (date !== undefined ? date : new Date())); }; /** * Determines if this instance is between a range of two dates or equal to either the start or end dates. * @param {Date} Start of range [Required] * @param {Date} End of range [Required] * @return {Boolean} true is this is between or equal to the start and end dates, else false */ $P.between = function (start, end) { return this.getTime() >= start.getTime() && this.getTime() <= end.getTime(); }; /** * Determines if this date occurs after the date to compare to. * @param {Date} Date object to compare. If no date to compare, new Date() ("now") is used. * @return {Boolean} true if this date instance is greater than the date to compare to (or "now"), otherwise false. */ $P.isAfter = function (date) { return this.compareTo(date || new Date()) === 1; }; /** * Determines if this date occurs before the date to compare to. * @param {Date} Date object to compare. If no date to compare, new Date() ("now") is used. * @return {Boolean} true if this date instance is less than the date to compare to (or "now"). */ $P.isBefore = function (date) { return (this.compareTo(date || new Date()) === -1); }; /** * Determines if the current Date instance occurs today. * @return {Boolean} true if this date instance is 'today', otherwise false. */ /** * Determines if the current Date instance occurs on the same Date as the supplied 'date'. * If no 'date' to compare to is provided, the current Date instance is compared to 'today'. * @param {date} Date object to compare. If no date to compare, the current Date ("now") is used. * @return {Boolean} true if this Date instance occurs on the same Day as the supplied 'date'. */ $P.isToday = $P.isSameDay = function (date) { return this.clone().clearTime().equals((date || new Date()).clone().clearTime()); }; /** * Adds the specified number of milliseconds to this instance. * @param {Number} The number of milliseconds to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addMilliseconds = function (value) { if (!value) { return this; } this.setTime(this.getTime() + value * 1); return this; }; /** * Adds the specified number of seconds to this instance. * @param {Number} The number of seconds to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addSeconds = function (value) { if (!value) { return this; } return this.addMilliseconds(value * 1000); }; /** * Adds the specified number of seconds to this instance. * @param {Number} The number of seconds to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addMinutes = function (value) { if (!value) { return this; } return this.addMilliseconds(value * 60000); // 60*1000 }; /** * Adds the specified number of hours to this instance. * @param {Number} The number of hours to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addHours = function (value) { if (!value) { return this; } return this.addMilliseconds(value * 3600000); // 60*60*1000 }; /** * Adds the specified number of days to this instance. * @param {Number} The number of days to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addDays = function (value) { if (!value) { return this; } this.setDate(this.getDate() + value * 1); return this; }; /** * Adds the specified number of weekdays (ie - not sat or sun) to this instance. * @param {Number} The number of days to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addWeekdays = function (value) { if (!value) { return this; } var day = this.getDay(); var weeks = (Math.ceil(Math.abs(value)/7)); if (day === 0 || day === 6) { if (value > 0) { this.next().monday(); this.addDays(-1); day = this.getDay(); } } if (value < 0) { while (value < 0) { this.addDays(-1); day = this.getDay(); if (day !== 0 && day !== 6) { value++; } } return this; } else if (value > 5 || (6-day) <= value) { value = value + (weeks * 2); } return this.addDays(value); }; /** * Adds the specified number of weeks to this instance. * @param {Number} The number of weeks to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addWeeks = function (value) { if (!value) { return this; } return this.addDays(value * 7); }; /** * Adds the specified number of months to this instance. * @param {Number} The number of months to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addMonths = function (value) { if (!value) { return this; } var n = this.getDate(); this.setDate(1); this.setMonth(this.getMonth() + value * 1); this.setDate(Math.min(n, $D.getDaysInMonth(this.getFullYear(), this.getMonth()))); return this; }; $P.addQuarters = function (value) { if (!value) { return this; } // note this will take you to the same point in the quarter as you are now. // i.e. - if you are 15 days into the quarter you'll be 15 days into the resulting one. // bonus: this allows adding fractional quarters return this.addMonths(value * 3); }; /** * Adds the specified number of years to this instance. * @param {Number} The number of years to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addYears = function (value) { if (!value) { return this; } return this.addMonths(value * 12); }; /** * Adds (or subtracts) to the value of the years, months, weeks, days, hours, minutes, seconds, milliseconds of the date instance using given configuration object. Positive and Negative values allowed. * Example

	Date.today().add( { days: 1, months: 1 } )

	new Date().add( { years: -1 } )
	
* @param {Object} Configuration object containing attributes (months, days, etc.) * @return {Date} this */ $P.add = function (config) { if (typeof config === "number") { this._orient = config; return this; } var x = config; if (x.day) { // If we should be a different date than today (eg: for 'tomorrow -1d', etc). // Should only effect parsing, not direct usage (eg, Finish and FinishExact) if ((x.day - this.getDate()) !== 0) { this.setDate(x.day); } } if (x.milliseconds) { this.addMilliseconds(x.milliseconds); } if (x.seconds) { this.addSeconds(x.seconds); } if (x.minutes) { this.addMinutes(x.minutes); } if (x.hours) { this.addHours(x.hours); } if (x.weeks) { this.addWeeks(x.weeks); } if (x.months) { this.addMonths(x.months); } if (x.years) { this.addYears(x.years); } if (x.days) { this.addDays(x.days); } return this; }; /** * Get the week number. Week one (1) is the week which contains the first Thursday of the year. Monday is considered the first day of the week. * The .getWeek() function does NOT convert the date to UTC. The local datetime is used. * Please use .getISOWeek() to get the week of the UTC converted date. * @return {Number} 1 to 53 */ $P.getWeek = function (utc) { // Create a copy of this date object var self, target = new Date(this.valueOf()); if (utc) { target.addMinutes(target.getTimezoneOffset()); self = target.clone(); } else { self = this; } // ISO week date weeks start on monday // so correct the day number var dayNr = (self.getDay() + 6) % 7; // ISO 8601 states that week 1 is the week // with the first thursday of that year. // Set the target date to the thursday in the target week target.setDate(target.getDate() - dayNr + 3); // Store the millisecond value of the target date var firstThursday = target.valueOf(); // Set the target to the first thursday of the year // First set the target to january first target.setMonth(0, 1); // Not a thursday? Correct the date to the next thursday if (target.getDay() !== 4) { target.setMonth(0, 1 + ((4 - target.getDay()) + 7) % 7); } // The weeknumber is the number of weeks between the // first thursday of the year and the thursday in the target week return 1 + Math.ceil((firstThursday - target) / 604800000); // 604800000 = 7 * 24 * 3600 * 1000 }; /** * Get the ISO 8601 week number. Week one ("01") is the week which contains the first Thursday of the year. Monday is considered the first day of the week. * The .getISOWeek() function does convert the date to it's UTC value. Please use .getWeek() to get the week of the local date. * @return {String} "01" to "53" */ $P.getISOWeek = function () { return p(this.getWeek(true)); }; /** * Moves the date to Monday of the week set. Week one (1) is the week which contains the first Thursday of the year. * @param {Number} A Number (1 to 53) that represents the week of the year. * @return {Date} this */ $P.setWeek = function (n) { if ((n - this.getWeek()) === 0) { if (this.getDay() !== 1) { return this.moveToDayOfWeek(1, (this.getDay() > 1 ? -1 : 1)); } else { return this; } } else { return this.moveToDayOfWeek(1, (this.getDay() > 1 ? -1 : 1)).addWeeks(n - this.getWeek()); } }; $P.setQuarter = function (qtr) { var month = Math.abs(((qtr-1) * 3) + 1); return this.setMonth(month, 1); }; $P.getQuarter = function () { return Date.getQuarter(this); }; $P.getDaysLeftInQuarter = function () { return Date.getDaysLeftInQuarter(this); }; /** * Moves the date to the next n'th occurrence of the dayOfWeek starting from the beginning of the month. The number (-1) is a magic number and will return the last occurrence of the dayOfWeek in the month. * @param {Number} The dayOfWeek to move to * @param {Number} The n'th occurrence to move to. Use (-1) to return the last occurrence in the month * @return {Date} this */ $P.moveToNthOccurrence = function (dayOfWeek, occurrence) { if (dayOfWeek === "Weekday") { if (occurrence > 0) { this.moveToFirstDayOfMonth(); if (this.is().weekday()) { occurrence -= 1; } } else if (occurrence < 0) { this.moveToLastDayOfMonth(); if (this.is().weekday()) { occurrence += 1; } } else { return this; } return this.addWeekdays(occurrence); } var shift = 0; if (occurrence > 0) { shift = occurrence - 1; } else if (occurrence === -1) { this.moveToLastDayOfMonth(); if (this.getDay() !== dayOfWeek) { this.moveToDayOfWeek(dayOfWeek, -1); } return this; } return this.moveToFirstDayOfMonth().addDays(-1).moveToDayOfWeek(dayOfWeek, +1).addWeeks(shift); }; var moveToN = function (getFunc, addFunc, nVal) { return function (value, orient) { var diff = (value - this[getFunc]() + nVal * (orient || +1)) % nVal; return this[addFunc]((diff === 0) ? diff += nVal * (orient || +1) : diff); }; }; /** * Move to the next or last dayOfWeek based on the orient value. * @param {Number} The dayOfWeek to move to * @param {Number} Forward (+1) or Back (-1). Defaults to +1. [Optional] * @return {Date} this */ $P.moveToDayOfWeek = moveToN("getDay", "addDays", 7); /** * Move to the next or last month based on the orient value. * @param {Number} The month to move to. 0 = January, 11 = December * @param {Number} Forward (+1) or Back (-1). Defaults to +1. [Optional] * @return {Date} this */ $P.moveToMonth = moveToN("getMonth", "addMonths", 12); /** * Get the Ordinate of the current day ("th", "st", "rd"). * @return {String} */ $P.getOrdinate = function () { var num = this.getDate(); return ord(num); }; /** * Get the Ordinal day (numeric day number) of the year, adjusted for leap year. * @return {Number} 1 through 365 (366 in leap years) */ $P.getOrdinalNumber = function () { return Math.ceil((this.clone().clearTime() - new Date(this.getFullYear(), 0, 1)) / 86400000) + 1; }; /** * Get the time zone abbreviation of the current date. * @return {String} The abbreviated time zone name (e.g. "EST") */ $P.getTimezone = function () { return $D.getTimezoneAbbreviation(this.getUTCOffset(), this.isDaylightSavingTime()); }; $P.setTimezoneOffset = function (offset) { var here = this.getTimezoneOffset(), there = Number(offset) * -6 / 10; return (there || there === 0) ? this.addMinutes(there - here) : this; }; $P.setTimezone = function (offset) { return this.setTimezoneOffset($D.getTimezoneOffset(offset)); }; /** * Indicates whether Daylight Saving Time is observed in the current time zone. * @return {Boolean} true|false */ $P.hasDaylightSavingTime = function () { return (Date.today().set({month: 0, day: 1}).getTimezoneOffset() !== Date.today().set({month: 6, day: 1}).getTimezoneOffset()); }; /** * Indicates whether this Date instance is within the Daylight Saving Time range for the current time zone. * @return {Boolean} true|false */ $P.isDaylightSavingTime = function () { return Date.today().set({month: 0, day: 1}).getTimezoneOffset() !== this.getTimezoneOffset(); }; /** * Get the offset from UTC of the current date. * @return {String} The 4-character offset string prefixed with + or - (e.g. "-0500") */ $P.getUTCOffset = function (offset) { var n = (offset || this.getTimezoneOffset()) * -10 / 6, r; if (n < 0) { r = (n - 10000).toString(); return r.charAt(0) + r.substr(2); } else { r = (n + 10000).toString(); return "+" + r.substr(1); } }; /** * Returns the number of milliseconds between this date and date. * @param {Date} Defaults to now * @return {Number} The diff in milliseconds */ $P.getElapsed = function (date) { return (date || new Date()) - this; }; /** * Set the value of year, month, day, hour, minute, second, millisecond of date instance using given configuration object. * Example

	Date.today().set( { day: 20, month: 1 } )

	new Date().set( { millisecond: 0 } )
	
* * @param {Object} Configuration object containing attributes (month, day, etc.) * @return {Date} this */ $P.set = function (config) { config = validateConfigObject.call(this, config); var key; for (key in config) { if (Object.prototype.hasOwnProperty.call(config, key)) { var name = key.charAt(0).toUpperCase() + key.slice(1); var addFunc, getFunc; if (key !== "week" && key !== "month" && key !== "timezone" && key !== "timezoneOffset") { name += "s"; } addFunc = "add" + name; getFunc = "get" + name; if (key === "month") { addFunc = addFunc + "s"; } else if (key === "year"){ getFunc = "getFullYear"; } if (key !== "day" && key !== "timezone" && key !== "timezoneOffset" && key !== "week" && key !== "hour") { this[addFunc](config[key] - this[getFunc]()); } else if ( key === "timezone"|| key === "timezoneOffset" || key === "week" || key === "hour") { this["set"+name](config[key]); } } } // day has to go last because you can't validate the day without first knowing the month if (config.day) { this.addDays(config.day - this.getDate()); } return this; }; /** * Moves the date to the first day of the month. * @return {Date} this */ $P.moveToFirstDayOfMonth = function () { return this.set({ day: 1 }); }; /** * Moves the date to the last day of the month. * @return {Date} this */ $P.moveToLastDayOfMonth = function () { return this.set({ day: $D.getDaysInMonth(this.getFullYear(), this.getMonth())}); }; /** * Converts the value of the current Date object to its equivalent string representation. * Format Specifiers * CUSTOM DATE AND TIME FORMAT STRINGS * Format Description Example * ------ --------------------------------------------------------------------------- ----------------------- * s The seconds of the minute between 0-59. "0" to "59" * ss The seconds of the minute with leading zero if required. "00" to "59" * * m The minute of the hour between 0-59. "0" or "59" * mm The minute of the hour with leading zero if required. "00" or "59" * * h The hour of the day between 1-12. "1" to "12" * hh The hour of the day with leading zero if required. "01" to "12" * * H The hour of the day between 0-23. "0" to "23" * HH The hour of the day with leading zero if required. "00" to "23" * * d The day of the month between 1 and 31. "1" to "31" * dd The day of the month with leading zero if required. "01" to "31" * ddd Abbreviated day name. Date.CultureInfo.abbreviatedDayNames. "Mon" to "Sun" * dddd The full day name. Date.CultureInfo.dayNames. "Monday" to "Sunday" * * M The month of the year between 1-12. "1" to "12" * MM The month of the year with leading zero if required. "01" to "12" * MMM Abbreviated month name. Date.CultureInfo.abbreviatedMonthNames. "Jan" to "Dec" * MMMM The full month name. Date.CultureInfo.monthNames. "January" to "December" * * yy The year as a two-digit number. "99" or "08" * yyyy The full four digit year. "1999" or "2008" * * t Displays the first character of the A.M./P.M. designator. "A" or "P" * Date.CultureInfo.amDesignator or Date.CultureInfo.pmDesignator * tt Displays the A.M./P.M. designator. "AM" or "PM" * Date.CultureInfo.amDesignator or Date.CultureInfo.pmDesignator * * S The ordinal suffix ("st, "nd", "rd" or "th") of the current day. "st, "nd", "rd" or "th" * * STANDARD DATE AND TIME FORMAT STRINGS * Format Description Example *------ --------------------------------------------------------------------------- ----------------------- * d The CultureInfo shortDate Format Pattern "M/d/yyyy" * D The CultureInfo longDate Format Pattern "dddd, MMMM dd, yyyy" * F The CultureInfo fullDateTime Format Pattern "dddd, MMMM dd, yyyy h:mm:ss tt" * m The CultureInfo monthDay Format Pattern "MMMM dd" * r The CultureInfo rfc1123 Format Pattern "ddd, dd MMM yyyy HH:mm:ss GMT" * s The CultureInfo sortableDateTime Format Pattern "yyyy-MM-ddTHH:mm:ss" * t The CultureInfo shortTime Format Pattern "h:mm tt" * T The CultureInfo longTime Format Pattern "h:mm:ss tt" * u The CultureInfo universalSortableDateTime Format Pattern "yyyy-MM-dd HH:mm:ssZ" * y The CultureInfo yearMonth Format Pattern "MMMM, yyyy" * * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @return {String} A string representation of the current Date object. */ var ord = function (n) { switch (n * 1) { case 1: case 21: case 31: return "st"; case 2: case 22: return "nd"; case 3: case 23: return "rd"; default: return "th"; } }; var parseStandardFormats = function (format) { var y, c = Date.CultureInfo.formatPatterns; switch (format) { case "d": return this.toString(c.shortDate); case "D": return this.toString(c.longDate); case "F": return this.toString(c.fullDateTime); case "m": return this.toString(c.monthDay); case "r": case "R": y = this.clone().addMinutes(this.getTimezoneOffset()); return y.toString(c.rfc1123) + " GMT"; case "s": return this.toString(c.sortableDateTime); case "t": return this.toString(c.shortTime); case "T": return this.toString(c.longTime); case "u": y = this.clone().addMinutes(this.getTimezoneOffset()); return y.toString(c.universalSortableDateTime); case "y": return this.toString(c.yearMonth); default: return false; } }; var parseFormatStringsClosure = function (context) { return function (m) { if (m.charAt(0) === "\\") { return m.replace("\\", ""); } switch (m) { case "hh": return p(context.getHours() < 13 ? (context.getHours() === 0 ? 12 : context.getHours()) : (context.getHours() - 12)); case "h": return context.getHours() < 13 ? (context.getHours() === 0 ? 12 : context.getHours()) : (context.getHours() - 12); case "HH": return p(context.getHours()); case "H": return context.getHours(); case "mm": return p(context.getMinutes()); case "m": return context.getMinutes(); case "ss": return p(context.getSeconds()); case "s": return context.getSeconds(); case "yyyy": return p(context.getFullYear(), 4); case "yy": return p(context.getFullYear()); case "y": return context.getFullYear(); case "E": case "dddd": return Date.CultureInfo.dayNames[context.getDay()]; case "ddd": return Date.CultureInfo.abbreviatedDayNames[context.getDay()]; case "dd": return p(context.getDate()); case "d": return context.getDate(); case "MMMM": return Date.CultureInfo.monthNames[context.getMonth()]; case "MMM": return Date.CultureInfo.abbreviatedMonthNames[context.getMonth()]; case "MM": return p((context.getMonth() + 1)); case "M": return context.getMonth() + 1; case "t": return context.getHours() < 12 ? Date.CultureInfo.amDesignator.substring(0, 1) : Date.CultureInfo.pmDesignator.substring(0, 1); case "tt": return context.getHours() < 12 ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator; case "S": return ord(context.getDate()); case "W": return context.getWeek(); case "WW": return context.getISOWeek(); case "Q": return "Q" + context.getQuarter(); case "q": return String(context.getQuarter()); case "z": return context.getTimezone(); case "Z": case "X": return Date.getTimezoneOffset(context.getTimezone()); case "ZZ": // Timezone offset in seconds return context.getTimezoneOffset() * -60; case "u": return context.getDay(); case "L": return ($D.isLeapYear(context.getFullYear())) ? 1 : 0; case "B": // Swatch Internet Time (.beats) return "@"+((context.getUTCSeconds() + (context.getUTCMinutes()*60) + ((context.getUTCHours()+1)*3600))/86.4); default: return m; } }; }; $P.toString = function (format, ignoreStandards) { // Standard Date and Time Format Strings. Formats pulled from CultureInfo file and // may vary by culture. if (!ignoreStandards && format && format.length === 1) { output = parseStandardFormats.call(this, format); if (output) { return output; } } var parseFormatStrings = parseFormatStringsClosure(this); return format ? format.replace(/((\\)?(dd?d?d?|MM?M?M?|yy?y?y?|hh?|HH?|mm?|ss?|tt?|S|q|Q|WW?W?W?)(?![^\[]*\]))/g, parseFormatStrings).replace(/\[|\]/g, "") : this._toString(); }; }()); /************************************************************* * SugarPak - Domain Specific Language - Syntactical Sugar * *************************************************************/ (function () { var $D = Date, $P = $D.prototype, $N = Number.prototype; // private $P._orient = +1; // private $P._nth = null; // private $P._is = false; // private $P._same = false; // private $P._isSecond = false; // private $N._dateElement = "days"; /** * Moves the date to the next instance of a date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.today().next().friday();
	Date.today().next().fri();
	Date.today().next().march();
	Date.today().next().mar();
	Date.today().next().week();
	
* * @return {Date} date */ $P.next = function () { this._move = true; this._orient = +1; return this; }; /** * Creates a new Date (Date.today()) and moves the date to the next instance of the date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.next().friday();
	Date.next().fri();
	Date.next().march();
	Date.next().mar();
	Date.next().week();
	
* * @return {Date} date */ $D.next = function () { return $D.today().next(); }; /** * Moves the date to the previous instance of a date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.today().last().friday();
	Date.today().last().fri();
	Date.today().last().march();
	Date.today().last().mar();
	Date.today().last().week();
	
* * @return {Date} date */ $P.last = $P.prev = $P.previous = function () { this._move = true; this._orient = -1; return this; }; /** * Creates a new Date (Date.today()) and moves the date to the previous instance of the date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.last().friday();
	Date.last().fri();
	Date.previous().march();
	Date.prev().mar();
	Date.last().week();
	
* * @return {Date} date */ $D.last = $D.prev = $D.previous = function () { return $D.today().last(); }; /** * Performs a equality check when followed by either a month name, day name or .weekday() function. * Example

	Date.today().is().friday(); // true|false
	Date.today().is().fri();
	Date.today().is().march();
	Date.today().is().mar();
	
* * @return {Boolean} true|false */ $P.is = function () { this._is = true; return this; }; /** * Determines if two date objects occur on/in exactly the same instance of the subsequent date part function. * The function .same() must be followed by a date part function (example: .day(), .month(), .year(), etc). * * An optional Date can be passed in the date part function. If now date is passed as a parameter, 'Now' is used. * * The following example demonstrates how to determine if two dates fall on the exact same day. * * Example

	var d1 = Date.today(); // today at 00:00
	var d2 = new Date();   // exactly now.

	// Do they occur on the same day?
	d1.same().day(d2); // true
	
	// Do they occur on the same hour?
	d1.same().hour(d2); // false, unless d2 hour is '00' (midnight).
	
	// What if it's the same day, but one year apart?
	var nextYear = Date.today().add(1).year();

	d1.same().day(nextYear); // false, because the dates must occur on the exact same day. 
	
* * Scenario: Determine if a given date occurs during some week period 2 months from now. * * Example

	var future = Date.today().add(2).months();
	return someDate.same().week(future); // true|false;
	
* * @return {Boolean} true|false */ $P.same = function () { this._same = true; this._isSecond = false; return this; }; /** * Determines if the current date/time occurs during Today. Must be preceded by the .is() function. * Example

	someDate.is().today();    // true|false
	new Date().is().today();  // true
	Date.today().is().today();// true
	Date.today().add(-1).day().is().today(); // false
	
* * @return {Boolean} true|false */ $P.today = function () { return this.same().day(); }; /** * Determines if the current date is a weekday. This function must be preceded by the .is() function. * Example

	Date.today().is().weekday(); // true|false
	
* * @return {Boolean} true|false */ $P.weekday = function () { if (this._nth) { return df("Weekday").call(this); } if (this._move) { return this.addWeekdays(this._orient); } if (this._is) { this._is = false; return (!this.is().sat() && !this.is().sun()); } return false; }; /** * Determines if the current date is on the weekend. This function must be preceded by the .is() function. * Example

	Date.today().is().weekend(); // true|false
	
* * @return {Boolean} true|false */ $P.weekend = function () { if (this._is) { this._is = false; return (this.is().sat() || this.is().sun()); } return false; }; /** * Sets the Time of the current Date instance. A string "6:15 pm" or config object {hour:18, minute:15} are accepted. * Example

	// Set time to 6:15pm with a String
	Date.today().at("6:15pm");

	// Set time to 6:15pm with a config object
	Date.today().at({hour:18, minute:15});
	
* * @return {Date} date */ $P.at = function (time) { return (typeof time === "string") ? $D.parse(this.toString("d") + " " + time) : this.set(time); }; /** * Creates a new Date() and adds this (Number) to the date based on the preceding date element function (eg. second|minute|hour|day|month|year). * Example

	// Undeclared Numbers must be wrapped with parentheses. Requirment of JavaScript.
	(3).days().fromNow();
	(6).months().fromNow();

	// Declared Number variables do not require parentheses. 
	var n = 6;
	n.months().fromNow();
	
* * @return {Date} A new Date instance */ $N.fromNow = $N.after = function (date) { var c = {}; c[this._dateElement] = this; return ((!date) ? new Date() : date.clone()).add(c); }; /** * Creates a new Date() and subtract this (Number) from the date based on the preceding date element function (eg. second|minute|hour|day|month|year). * Example

	// Undeclared Numbers must be wrapped with parentheses. Requirment of JavaScript.
	(3).days().ago();
	(6).months().ago();

	// Declared Number variables do not require parentheses. 
	var n = 6;
	n.months().ago();
	
* * @return {Date} A new Date instance */ $N.ago = $N.before = function (date) { var c = {}, s = (this._dateElement[this._dateElement.length-1] !== "s") ? this._dateElement + "s" : this._dateElement; c[s] = this * -1; return ((!date) ? new Date() : date.clone()).add(c); }; // Do NOT modify the following string tokens. These tokens are used to build dynamic functions. // All culture-specific strings can be found in the CultureInfo files. var dx = ("sunday monday tuesday wednesday thursday friday saturday").split(/\s/), mx = ("january february march april may june july august september october november december").split(/\s/), px = ("Millisecond Second Minute Hour Day Week Month Year Quarter Weekday").split(/\s/), pxf = ("Milliseconds Seconds Minutes Hours Date Week Month FullYear Quarter").split(/\s/), nth = ("final first second third fourth fifth").split(/\s/), de; /** * Returns an object literal of all the date parts. * Example

	var o = new Date().toObject();
	
	// { year: 2008, month: 4, week: 20, day: 13, hour: 18, minute: 9, second: 32, millisecond: 812 }
	
	// The object properties can be referenced directly from the object.
	
	alert(o.day);  // alerts "13"
	alert(o.year); // alerts "2008"
	
* * @return {Date} An object literal representing the original date object. */ $P.toObject = function () { var o = {}; for (var i = 0; i < px.length; i++) { if (this["get" + pxf[i]]) { o[px[i].toLowerCase()] = this["get" + pxf[i]](); } } return o; }; /** * Returns a date created from an object literal. Ignores the .week property if set in the config. * Example

	var o = new Date().toObject();
	
	return Date.fromObject(o); // will return the same date. 

	var o2 = {month: 1, day: 20, hour: 18}; // birthday party!
	Date.fromObject(o2);
	
* * @return {Date} An object literal representing the original date object. */ $D.fromObject = function(config) { config.week = null; return Date.today().set(config); }; // Create day name functions and abbreviated day name functions (eg. monday(), friday(), fri()). var df = function (n) { return function () { if (this._is) { this._is = false; return this.getDay() === n; } if (this._move) { this._move = null; } if (this._nth !== null) { // If the .second() function was called earlier, remove the _orient // from the date, and then continue. // This is required because 'second' can be used in two different context. // // Example // // Date.today().add(1).second(); // Date.march().second().monday(); // // Things get crazy with the following... // Date.march().add(1).second().second().monday(); // but it works!! // if (this._isSecond) { this.addSeconds(this._orient * -1); } // make sure we reset _isSecond this._isSecond = false; var ntemp = this._nth; this._nth = null; var temp = this.clone().moveToLastDayOfMonth(); this.moveToNthOccurrence(n, ntemp); if (this > temp) { throw new RangeError($D.getDayName(n) + " does not occur " + ntemp + " times in the month of " + $D.getMonthName(temp.getMonth()) + " " + temp.getFullYear() + "."); } return this; } return this.moveToDayOfWeek(n, this._orient); }; }; var sdf = function (n) { return function () { var t = $D.today(), shift = n - t.getDay(); if (n === 0 && Date.CultureInfo.firstDayOfWeek === 1 && t.getDay() !== 0) { shift = shift + 7; } return t.addDays(shift); }; }; // Create month name functions and abbreviated month name functions (eg. january(), march(), mar()). var month_instance_functions = function (n) { return function () { if (this._is) { this._is = false; return this.getMonth() === n; } return this.moveToMonth(n, this._orient); }; }; var month_static_functions = function (n) { return function () { return $D.today().set({ month: n, day: 1 }); }; }; var processTerms = function (names, staticFunc, instanceFunc) { for (var i = 0; i < names.length; i++) { // Create constant static Name variables. $D[names[i].toUpperCase()] = $D[names[i].toUpperCase().substring(0, 3)] = i; // Create Name functions. $D[names[i]] = $D[names[i].substring(0, 3)] = staticFunc(i); // Create Name instance functions. $P[names[i]] = $P[names[i].substring(0, 3)] = instanceFunc(i); } }; processTerms(dx, sdf, df); processTerms(mx, month_static_functions, month_instance_functions); // Create date element functions and plural date element functions used with Date (eg. day(), days(), months()). var ef = function (j) { return function () { // if the .second() function was called earlier, the _orient // has alread been added. Just return this and reset _isSecond. if (this._isSecond) { this._isSecond = false; return this; } if (this._same) { this._same = this._is = false; var o1 = this.toObject(), o2 = (arguments[0] || new Date()).toObject(), v = "", k = j.toLowerCase(); // the substr trick with -1 doesn't work in IE8 or less k = (k[k.length-1] === "s") ? k.substring(0,k.length-1) : k; for (var m = (px.length - 1); m > -1; m--) { v = px[m].toLowerCase(); if (o1[v] !== o2[v]) { return false; } if (k === v) { break; } } return true; } if (j.substring(j.length - 1) !== "s") { j += "s"; } if (this._move) { this._move = null; } return this["add" + j](this._orient); }; }; var nf = function (n) { return function () { this._dateElement = n; return this; }; }; for (var k = 0; k < px.length; k++) { de = px[k].toLowerCase(); if(de !== "weekday") { // Create date element functions and plural date element functions used with Date (eg. day(), days(), months()). $P[de] = $P[de + "s"] = ef(px[k]); // Create date element functions and plural date element functions used with Number (eg. day(), days(), months()). $N[de] = $N[de + "s"] = nf(de + "s"); } } $P._ss = ef("Second"); var nthfn = function (n) { return function (dayOfWeek) { if (this._same) { return this._ss(arguments[0]); } if (dayOfWeek || dayOfWeek === 0) { return this.moveToNthOccurrence(dayOfWeek, n); } this._nth = n; // if the operator is 'second' add the _orient, then deal with it later... if (n === 2 && (dayOfWeek === undefined || dayOfWeek === null)) { this._isSecond = true; return this.addSeconds(this._orient); } return this; }; }; for (var l = 0; l < nth.length; l++) { $P[nth[l]] = (l === 0) ? nthfn(-1) : nthfn(l); } }()); (function () { "use strict"; Date.Parsing = { Exception: function (s) { this.message = "Parse error at '" + s.substring(0, 10) + " ...'"; } }; var $P = Date.Parsing; var dayOffsets = { standard: [0,31,59,90,120,151,181,212,243,273,304,334], leap: [0,31,60,91,121,152,182,213,244,274,305,335] }; $P.isLeapYear = function(year) { return ((year % 4 === 0) && (year % 100 !== 0)) || (year % 400 === 0); }; var utils = { multiReplace : function (str, hash ) { var key; for (key in hash) { if (Object.prototype.hasOwnProperty.call(hash, key)) { var regex; if (typeof hash[key] === "function") { } else { regex = (hash[key] instanceof RegExp) ? hash[key] : new RegExp(hash[key], "g"); } str = str.replace(regex, key); } } return str; }, getDayOfYearFromWeek : function (obj) { var d, jan4, offset; obj.weekDay = (!obj.weekDay && obj.weekDay !== 0) ? 1 : obj.weekDay; d = new Date(obj.year, 0, 4); jan4 = d.getDay() === 0 ? 7 : d.getDay(); // JS is 0 indexed on Sunday. offset = jan4+3; obj.dayOfYear = ((obj.week * 7) + (obj.weekDay === 0 ? 7 : obj.weekDay))-offset; return obj; }, getDayOfYear : function (obj, dayOffset) { if (!obj.dayOfYear) { obj = utils.getDayOfYearFromWeek(obj); } for (var i=0;i <= dayOffset.length;i++) { if (obj.dayOfYear < dayOffset[i] || i === dayOffset.length) { obj.day = obj.day ? obj.day : (obj.dayOfYear - dayOffset[i-1]); break; } else { obj.month = i; } } return obj; }, adjustForTimeZone : function (obj, date) { var offset; if (obj.zone.toUpperCase() === "Z" || (obj.zone_hours === 0 && obj.zone_minutes === 0)) { // it's UTC/GML so work out the current timeszone offset offset = -date.getTimezoneOffset(); } else { offset = (obj.zone_hours*60) + (obj.zone_minutes || 0); if (obj.zone_sign === "+") { offset *= -1; } offset -= date.getTimezoneOffset(); } date.setMinutes(date.getMinutes()+offset); return date; }, setDefaults : function (obj) { obj.year = obj.year || Date.today().getFullYear(); obj.hours = obj.hours || 0; obj.minutes = obj.minutes || 0; obj.seconds = obj.seconds || 0; obj.milliseconds = obj.milliseconds || 0; if (!(!obj.month && (obj.week || obj.dayOfYear))) { // if we have a month, or if we don't but don't have the day calculation data obj.month = obj.month || 0; obj.day = obj.day || 1; } return obj; }, dataNum: function (data, mod, explict, postProcess) { var dataNum = data*1; if (mod) { if (postProcess) { return data ? mod(data)*1 : data; } else { return data ? mod(dataNum) : data; } } else if (!explict){ return data ? dataNum : data; } else { return (data && typeof data !== "undefined") ? dataNum : data; } }, timeDataProcess: function (obj) { var timeObj = {}; for (var x in obj.data) { if (obj.data.hasOwnProperty(x)) { timeObj[x] = obj.ignore[x] ? obj.data[x] : utils.dataNum(obj.data[x], obj.mods[x], obj.explict[x], obj.postProcess[x]); } } if (obj.data.secmins) { obj.data.secmins = obj.data.secmins.replace(",", ".") * 60; if (!timeObj.minutes) { timeObj.minutes = obj.data.secmins; } else if (!timeObj.seconds) { timeObj.seconds = obj.data.secmins; } delete obj.secmins; } return timeObj; }, buildTimeObjectFromData: function (data) { var time = utils.timeDataProcess({ data: { year : data[1], month : data[5], day : data[7], week : data[8], dayOfYear : data[10], hours : data[15], zone_hours : data[23], zone_minutes : data[24], zone : data[21], zone_sign : data[22], weekDay : data[9], minutes: data[16], seconds: data[19], milliseconds: data[20], secmins: data[18] }, mods: { month: function(data) { return data-1; }, weekDay: function (data) { data = Math.abs(data); return (data === 7 ? 0 : data); }, minutes: function (data) { return data.replace(":",""); }, seconds: function (data) { return Math.floor( (data.replace(":","").replace(",","."))*1 ); }, milliseconds: function (data) { return (data.replace(",",".")*1000); } }, postProcess: { minutes: true, seconds: true, milliseconds: true }, explict: { zone_hours: true, zone_minutes: true }, ignore: { zone: true, zone_sign: true, secmins: true } }); return time; }, addToHash: function (hash, keys, data) { keys = keys; data = data; var len = keys.length; for (var i = 0; i < len; i++) { hash[keys[i]] = data[i]; } return hash; }, combineRegex: function (r1, r2) { return new RegExp("(("+r1.source+")\\s("+r2.source+"))"); }, getDateNthString: function(add, last, inc){ if (add) { return Date.today().addDays(inc).toString("d"); } else if (last) { return Date.today().last()[inc]().toString("d"); } }, buildRegexData: function (array) { var arr = []; var len = array.length; for (var i=0; i < len; i++) { if (Object.prototype.toString.call(array[i]) === '[object Array]') { // oldIE compat version of Array.isArray arr.push(this.combineRegex(array[i][0], array[i][1])); } else { arr.push(array[i]); } } return arr; } }; $P.processTimeObject = function (obj) { var date, dayOffset; utils.setDefaults(obj); dayOffset = ($P.isLeapYear(obj.year)) ? dayOffsets.leap : dayOffsets.standard; if (!obj.month && (obj.week || obj.dayOfYear)) { utils.getDayOfYear(obj, dayOffset); } else { obj.dayOfYear = dayOffset[obj.month] + obj.day; } date = new Date(obj.year, obj.month, obj.day, obj.hours, obj.minutes, obj.seconds, obj.milliseconds); if (obj.zone) { utils.adjustForTimeZone(obj, date); // adjust (and calculate) for timezone } return date; }; $P.ISO = { regex : /^([\+-]?\d{4}(?!\d{2}\b))((-?)((0[1-9]|1[0-2])(\3([12]\d|0[1-9]|3[01]))?|W([0-4]\d|5[0-3])(-?[1-7])?|(00[1-9]|0[1-9]\d|[12]\d{2}|3([0-5]\d|6[1-6])))([T\s]((([01]\d|2[0-4])((:?)[0-5]\d)?|24\:?00)([\.,]\d+(?!:))?)?(\17[0-5]\d([\.,]\d+)?)?\s?([zZ]|([\+-])([01]\d|2[0-3]):?([0-5]\d)?)?)?)?$/, parse : function (s) { var time, data = s.match(this.regex); if (!data || !data.length) { return null; } time = utils.buildTimeObjectFromData(data); if (!time.year || (!time.year && (!time.month && !time.day) && (!time.week && !time.dayOfYear)) ) { return null; } return $P.processTimeObject(time); } }; $P.Numeric = { isNumeric: function (e){return!isNaN(parseFloat(e))&&isFinite(e);}, regex: /\b([0-1]?[0-9])([0-3]?[0-9])([0-2]?[0-9]?[0-9][0-9])\b/i, parse: function (s) { var data, i, time = {}, order = Date.CultureInfo.dateElementOrder.split(""); if (!(this.isNumeric(s)) || // if it's non-numeric OR (s[0] === "+" && s[0] === "-")) { // It's an arithmatic string (eg +/-1000) return null; } if (s.length < 5 && s.indexOf(".") < 0 && s.indexOf("/") < 0) { // assume it's just a year. time.year = s; return $P.processTimeObject(time); } data = s.match(this.regex); if (!data || !data.length) { return null; } for (i=0; i < order.length; i++) { switch(order[i]) { case "d": time.day = data[i+1]; break; case "m": time.month = (data[i+1]-1); break; case "y": time.year = data[i+1]; break; } } return $P.processTimeObject(time); } }; $P.Normalizer = { regexData: function () { var $R = Date.CultureInfo.regexPatterns; return utils.buildRegexData([ $R.tomorrow, $R.yesterday, [$R.past, $R.mon], [$R.past, $R.tue], [$R.past, $R.wed], [$R.past, $R.thu], [$R.past, $R.fri], [$R.past, $R.sat], [$R.past, $R.sun] ]); }, basicReplaceHash : function() { var $R = Date.CultureInfo.regexPatterns; return { "January": $R.jan.source, "February": $R.feb, "March": $R.mar, "April": $R.apr, "May": $R.may, "June": $R.jun, "July": $R.jul, "August": $R.aug, "September": $R.sep, "October": $R.oct, "November": $R.nov, "December": $R.dec, "": /\bat\b/gi, " ": /\s{2,}/, "am": $R.inTheMorning, "9am": $R.thisMorning, "pm": $R.inTheEvening, "7pm":$R.thisEvening }; }, keys : function(){ return [ utils.getDateNthString(true, false, 1), // tomorrow utils.getDateNthString(true, false, -1), // yesterday utils.getDateNthString(false, true, "monday"), //last mon utils.getDateNthString(false, true, "tuesday"), //last tues utils.getDateNthString(false, true, "wednesday"), //last wed utils.getDateNthString(false, true, "thursday"), //last thurs utils.getDateNthString(false, true, "friday"), //last fri utils.getDateNthString(false, true, "saturday"), //last sat utils.getDateNthString(false, true, "sunday") //last sun ]; }, buildRegexFunctions: function () { var $R = Date.CultureInfo.regexPatterns; var __ = Date.i18n.__; var tomorrowRE = new RegExp("(\\b\\d\\d?("+__("AM")+"|"+__("PM")+")? )("+$R.tomorrow.source.slice(1)+")", "i"); // adapted tomorrow regex for AM PM relative dates var todayRE = new RegExp($R.today.source + "(?!\\s*([+-]))\\b"); // today, but excludes the math operators (eg "today + 2h") this.replaceFuncs = [ [todayRE, function (full) { return (full.length > 1) ? Date.today().toString("d") : full; }], [tomorrowRE, function(full, m1) { var t = Date.today().addDays(1).toString("d"); return (t + " " + m1); }], [$R.amThisMorning, function(str, am){return am;}], [$R.pmThisEvening, function(str, pm){return pm;}] ]; }, buildReplaceData: function () { this.buildRegexFunctions(); this.replaceHash = utils.addToHash(this.basicReplaceHash(), this.keys(), this.regexData()); }, stringReplaceFuncs: function (s) { for (var i=0; i < this.replaceFuncs.length; i++) { s = s.replace(this.replaceFuncs[i][0], this.replaceFuncs[i][1]); } return s; }, parse: function (s) { s = this.stringReplaceFuncs(s); s = utils.multiReplace(s, this.replaceHash); try { var n = s.split(/([\s\-\.\,\/\x27]+)/); if (n.length === 3 && $P.Numeric.isNumeric(n[0]) && $P.Numeric.isNumeric(n[2]) && (n[2].length >= 4)) { // ok, so we're dealing with x/year. But that's not a full date. // This fixes wonky dateElementOrder parsing when set to dmy order. if (Date.CultureInfo.dateElementOrder[0] === "d") { s = "1/" + n[0] + "/" + n[2]; // set to 1st of month and normalize the seperator } } } catch (e) {} return s; } }; $P.Normalizer.buildReplaceData(); }()); (function () { var $P = Date.Parsing; var _ = $P.Operators = { // // Tokenizers // rtoken: function (r) { // regex token return function (s) { var mx = s.match(r); if (mx) { return ([ mx[0], s.substring(mx[0].length) ]); } else { throw new $P.Exception(s); } }; }, token: function () { // whitespace-eating token return function (s) { return _.rtoken(new RegExp("^\\s*" + s + "\\s*"))(s); }; }, stoken: function (s) { // string token return _.rtoken(new RegExp("^" + s)); }, // Atomic Operators until: function (p) { return function (s) { var qx = [], rx = null; while (s.length) { try { rx = p.call(this, s); } catch (e) { qx.push(rx[0]); s = rx[1]; continue; } break; } return [ qx, s ]; }; }, many: function (p) { return function (s) { var rx = [], r = null; while (s.length) { try { r = p.call(this, s); } catch (e) { return [ rx, s ]; } rx.push(r[0]); s = r[1]; } return [ rx, s ]; }; }, // generator operators -- see below optional: function (p) { return function (s) { var r = null; try { r = p.call(this, s); } catch (e) { return [ null, s ]; } return [ r[0], r[1] ]; }; }, not: function (p) { return function (s) { try { p.call(this, s); } catch (e) { return [null, s]; } throw new $P.Exception(s); }; }, ignore: function (p) { return p ? function (s) { var r = null; r = p.call(this, s); return [null, r[1]]; } : null; }, product: function () { var px = arguments[0], qx = Array.prototype.slice.call(arguments, 1), rx = []; for (var i = 0 ; i < px.length ; i++) { rx.push(_.each(px[i], qx)); } return rx; }, cache: function (rule) { var cache = {}, cache_length = 0, cache_keys = [], CACHE_MAX = Date.Config.CACHE_MAX || 100000, r = null; var cacheCheck = function () { if (cache_length === CACHE_MAX) { // kill several keys, don't want to have to do this all the time... for (var i=0; i < 10; i++) { var key = cache_keys.shift(); if (key) { delete cache[key]; cache_length--; } } } }; return function (s) { cacheCheck(); try { r = cache[s] = (cache[s] || rule.call(this, s)); } catch (e) { r = cache[s] = e; } cache_length++; cache_keys.push(s); if (r instanceof $P.Exception) { throw r; } else { return r; } }; }, // vector operators -- see below any: function () { var px = arguments; return function (s) { var r = null; for (var i = 0; i < px.length; i++) { if (px[i] == null) { continue; } try { r = (px[i].call(this, s)); } catch (e) { r = null; } if (r) { return r; } } throw new $P.Exception(s); }; }, each: function () { var px = arguments; return function (s) { var rx = [], r = null; for (var i = 0; i < px.length ; i++) { if (px[i] == null) { continue; } try { r = (px[i].call(this, s)); } catch (e) { throw new $P.Exception(s); } rx.push(r[0]); s = r[1]; } return [ rx, s]; }; }, all: function () { var px = arguments, _ = _; return _.each(_.optional(px)); }, // delimited operators sequence: function (px, d, c) { d = d || _.rtoken(/^\s*/); c = c || null; if (px.length === 1) { return px[0]; } return function (s) { var r = null, q = null; var rx = []; for (var i = 0; i < px.length ; i++) { try { r = px[i].call(this, s); } catch (e) { break; } rx.push(r[0]); try { q = d.call(this, r[1]); } catch (ex) { q = null; break; } s = q[1]; } if (!r) { throw new $P.Exception(s); } if (q) { throw new $P.Exception(q[1]); } if (c) { try { r = c.call(this, r[1]); } catch (ey) { throw new $P.Exception(r[1]); } } return [ rx, (r?r[1]:s) ]; }; }, // // Composite Operators // between: function (d1, p, d2) { d2 = d2 || d1; var _fn = _.each(_.ignore(d1), p, _.ignore(d2)); return function (s) { var rx = _fn.call(this, s); return [[rx[0][0], r[0][2]], rx[1]]; }; }, list: function (p, d, c) { d = d || _.rtoken(/^\s*/); c = c || null; return (p instanceof Array ? _.each(_.product(p.slice(0, -1), _.ignore(d)), p.slice(-1), _.ignore(c)) : _.each(_.many(_.each(p, _.ignore(d))), px, _.ignore(c))); }, set: function (px, d, c) { d = d || _.rtoken(/^\s*/); c = c || null; return function (s) { // r is the current match, best the current 'best' match // which means it parsed the most amount of input var r = null, p = null, q = null, rx = null, best = [[], s], last = false; // go through the rules in the given set for (var i = 0; i < px.length ; i++) { // last is a flag indicating whether this must be the last element // if there is only 1 element, then it MUST be the last one q = null; p = null; r = null; last = (px.length === 1); // first, we try simply to match the current pattern // if not, try the next pattern try { r = px[i].call(this, s); } catch (e) { continue; } // since we are matching against a set of elements, the first // thing to do is to add r[0] to matched elements rx = [[r[0]], r[1]]; // if we matched and there is still input to parse and // we don't already know this is the last element, // we're going to next check for the delimiter ... // if there's none, or if there's no input left to parse // than this must be the last element after all ... if (r[1].length > 0 && ! last) { try { q = d.call(this, r[1]); } catch (ex) { last = true; } } else { last = true; } // if we parsed the delimiter and now there's no more input, // that means we shouldn't have parsed the delimiter at all // so don't update r and mark this as the last element ... if (!last && q[1].length === 0) { last = true; } // so, if this isn't the last element, we're going to see if // we can get any more matches from the remaining (unmatched) // elements ... if (!last) { // build a list of the remaining rules we can match against, // i.e., all but the one we just matched against var qx = []; for (var j = 0; j < px.length ; j++) { if (i !== j) { qx.push(px[j]); } } // now invoke recursively set with the remaining input // note that we don't include the closing delimiter ... // we'll check for that ourselves at the end p = _.set(qx, d).call(this, q[1]); // if we got a non-empty set as a result ... // (otw rx already contains everything we want to match) if (p[0].length > 0) { // update current result, which is stored in rx ... // basically, pick up the remaining text from p[1] // and concat the result from p[0] so that we don't // get endless nesting ... rx[0] = rx[0].concat(p[0]); rx[1] = p[1]; } } // at this point, rx either contains the last matched element // or the entire matched set that starts with this element. // now we just check to see if this variation is better than // our best so far, in terms of how much of the input is parsed if (rx[1].length < best[1].length) { best = rx; } // if we've parsed all the input, then we're finished if (best[1].length === 0) { break; } } // so now we've either gone through all the patterns trying them // as the initial match; or we found one that parsed the entire // input string ... // if best has no matches, just return empty set ... if (best[0].length === 0) { return best; } // if a closing delimiter is provided, then we have to check it also if (c) { // we try this even if there is no remaining input because the pattern // may well be optional or match empty input ... try { q = c.call(this, best[1]); } catch (ey) { throw new $P.Exception(best[1]); } // it parsed ... be sure to update the best match remaining input best[1] = q[1]; } // if we're here, either there was no closing delimiter or we parsed it // so now we have the best match; just return it! return best; }; }, forward: function (gr, fname) { return function (s) { return gr[fname].call(this, s); }; }, // // Translation Operators // replace: function (rule, repl) { return function (s) { var r = rule.call(this, s); return [repl, r[1]]; }; }, process: function (rule, fn) { return function (s) { var r = rule.call(this, s); return [fn.call(this, r[0]), r[1]]; }; }, min: function (min, rule) { return function (s) { var rx = rule.call(this, s); if (rx[0].length < min) { throw new $P.Exception(s); } return rx; }; } }; // Generator Operators And Vector Operators // Generators are operators that have a signature of F(R) => R, // taking a given rule and returning another rule, such as // ignore, which parses a given rule and throws away the result. // Vector operators are those that have a signature of F(R1,R2,...) => R, // take a list of rules and returning a new rule, such as each. // Generator operators are converted (via the following _generator // function) into functions that can also take a list or array of rules // and return an array of new rules as though the function had been // called on each rule in turn (which is what actually happens). // This allows generators to be used with vector operators more easily. // Example: // each(ignore(foo, bar)) instead of each(ignore(foo), ignore(bar)) // This also turns generators into vector operators, which allows // constructs like: // not(cache(foo, bar)) var _generator = function (op) { function gen() { var args = null, rx = [], px, i; if (arguments.length > 1) { args = Array.prototype.slice.call(arguments); } else if (arguments[0] instanceof Array) { args = arguments[0]; } if (args) { px = args.shift(); if (px.length > 0) { args.unshift(px[i]); rx.push(op.apply(null, args)); args.shift(); return rx; } } else { return op.apply(null, arguments); } } return gen; }; var gx = "optional not ignore cache".split(/\s/); for (var i = 0 ; i < gx.length ; i++) { _[gx[i]] = _generator(_[gx[i]]); } var _vector = function (op) { return function () { if (arguments[0] instanceof Array) { return op.apply(null, arguments[0]); } else { return op.apply(null, arguments); } }; }; var vx = "each any all".split(/\s/); for (var j = 0 ; j < vx.length ; j++) { _[vx[j]] = _vector(_[vx[j]]); } }()); (function () { var $D = Date; var flattenAndCompact = function (ax) { var rx = []; for (var i = 0; i < ax.length; i++) { if (ax[i] instanceof Array) { rx = rx.concat(flattenAndCompact(ax[i])); } else { if (ax[i]) { rx.push(ax[i]); } } } return rx; }; var parseMeridian = function () { if (this.meridian && (this.hour || this.hour === 0)) { if (this.meridian === "a" && this.hour > 11 && Date.Config.strict24hr){ throw "Invalid hour and meridian combination"; } else if (this.meridian === "p" && this.hour < 12 && Date.Config.strict24hr){ throw "Invalid hour and meridian combination"; } else if (this.meridian === "p" && this.hour < 12) { this.hour = this.hour + 12; } else if (this.meridian === "a" && this.hour === 12) { this.hour = 0; } } }; var setDefaults = function () { var now = new Date(); if ((this.hour || this.minute) && (!this.month && !this.year && !this.day)) { this.day = now.getDate(); } if (!this.year) { this.year = now.getFullYear(); } if (!this.month && this.month !== 0) { this.month = now.getMonth(); } if (!this.day) { this.day = 1; } if (!this.hour) { this.hour = 0; } if (!this.minute) { this.minute = 0; } if (!this.second) { this.second = 0; } if (!this.millisecond) { this.millisecond = 0; } }; var finishUtils = { getToday: function () { if (this.now || "hour minute second".indexOf(this.unit) !== -1) { return new Date(); } else { return $D.today(); } }, setDaysFromWeekday: function (today, orient){ var gap; orient = orient || 1; this.unit = "day"; gap = ($D.getDayNumberFromName(this.weekday) - today.getDay()); this.days = gap ? ((gap + (orient * 7)) % 7) : (orient * 7); return this; }, setMonthsFromMonth: function (today, orient) { var gap; orient = orient || 1; this.unit = "month"; gap = (this.month - today.getMonth()); this.months = gap ? ((gap + (orient * 12)) % 12) : (orient * 12); this.month = null; return this; }, setDMYFromWeekday: function () { var d = Date[this.weekday](); this.day = d.getDate(); if (!this.month) { this.month = d.getMonth(); } this.year = d.getFullYear(); return this; }, setUnitValue: function (orient) { if (!this.value && this.operator && this.operator !== null && this[this.unit + "s"] && this[this.unit + "s"] !== null) { this[this.unit + "s"] = this[this.unit + "s"] + ((this.operator === "add") ? 1 : -1) + (this.value||0) * orient; } else if (this[this.unit + "s"] == null || this.operator != null) { if (!this.value) { this.value = 1; } this[this.unit + "s"] = this.value * orient; } }, generateDateFromWeeks: function () { var weekday = (this.weekday !== undefined) ? this.weekday : "today"; var d = Date[weekday]().addWeeks(this.weeks); if (this.now) { d.setTimeToNow(); } return d; } }; $D.Translator = { hour: function (s) { return function () { this.hour = Number(s); }; }, minute: function (s) { return function () { this.minute = Number(s); }; }, second: function (s) { return function () { this.second = Number(s); }; }, /* for ss.s format */ secondAndMillisecond: function (s) { return function () { var mx = s.match(/^([0-5][0-9])\.([0-9]{1,3})/); this.second = Number(mx[1]); this.millisecond = Number(mx[2]); }; }, meridian: function (s) { return function () { this.meridian = s.slice(0, 1).toLowerCase(); }; }, timezone: function (s) { return function () { var n = s.replace(/[^\d\+\-]/g, ""); if (n.length) { this.timezoneOffset = Number(n); } else { this.timezone = s.toLowerCase(); } }; }, day: function (x) { var s = x[0]; return function () { this.day = Number(s.match(/\d+/)[0]); if (this.day < 1) { throw "invalid day"; } }; }, month: function (s) { return function () { this.month = (s.length === 3) ? "jan feb mar apr may jun jul aug sep oct nov dec".indexOf(s)/4 : Number(s) - 1; if (this.month < 0) { throw "invalid month"; } }; }, year: function (s) { return function () { var n = Number(s); this.year = ((s.length > 2) ? n : (n + (((n + 2000) < Date.CultureInfo.twoDigitYearMax) ? 2000 : 1900))); }; }, rday: function (s) { return function () { switch (s) { case "yesterday": this.days = -1; break; case "tomorrow": this.days = 1; break; case "today": this.days = 0; break; case "now": this.days = 0; this.now = true; break; } }; }, finishExact: function (x) { var d; x = (x instanceof Array) ? x : [x]; for (var i = 0 ; i < x.length ; i++) { if (x[i]) { x[i].call(this); } } setDefaults.call(this); parseMeridian.call(this); if (this.day > $D.getDaysInMonth(this.year, this.month)) { throw new RangeError(this.day + " is not a valid value for days."); } d = new Date(this.year, this.month, this.day, this.hour, this.minute, this.second, this.millisecond); if (this.year < 100) { d.setFullYear(this.year); // means years less that 100 are process correctly. JS will parse it otherwise as 1900-1999. } if (this.timezone) { d.set({ timezone: this.timezone }); } else if (this.timezoneOffset) { d.set({ timezoneOffset: this.timezoneOffset }); } return d; }, finish: function (x) { var today, expression, orient, temp; x = (x instanceof Array) ? flattenAndCompact(x) : [ x ]; if (x.length === 0) { return null; } for (var i = 0 ; i < x.length ; i++) { if (typeof x[i] === "function") { x[i].call(this); } } if (this.now && !this.unit && !this.operator) { return new Date(); } else { today = finishUtils.getToday.call(this); } expression = !!(this.days && this.days !== null || this.orient || this.operator); orient = ((this.orient === "past" || this.operator === "subtract") ? -1 : 1); if (this.month && this.unit === "week") { this.value = this.month + 1; delete this.month; delete this.day; } if ((this.month || this.month === 0) && "year day hour minute second".indexOf(this.unit) !== -1) { if (!this.value) { this.value = this.month + 1; } this.month = null; expression = true; } if (!expression && this.weekday && !this.day && !this.days) { finishUtils.setDMYFromWeekday.call(this); } if (expression && this.weekday && this.unit !== "month" && this.unit !== "week") { finishUtils.setDaysFromWeekday.call(this, today, orient); } if (this.weekday && this.unit !== "week" && !this.day && !this.days) { temp = Date[this.weekday](); this.day = temp.getDate(); if (temp.getMonth() !== today.getMonth()) { this.month = temp.getMonth(); } } if (this.month && this.unit === "day" && this.operator) { if (!this.value) { this.value = (this.month + 1); } this.month = null; } if (this.value != null && this.month != null && this.year != null) { this.day = this.value * 1; } if (this.month && !this.day && this.value) { today.set({ day: this.value * 1 }); if (!expression) { this.day = this.value * 1; } } if (!this.month && this.value && this.unit === "month" && !this.now) { this.month = this.value; expression = true; } if (expression && (this.month || this.month === 0) && this.unit !== "year") { finishUtils.setMonthsFromMonth.call(this, today, orient); } if (!this.unit) { this.unit = "day"; } finishUtils.setUnitValue.call(this, orient); parseMeridian.call(this); if ((this.month || this.month === 0) && !this.day) { this.day = 1; } if (!this.orient && !this.operator && this.unit === "week" && this.value && !this.day && !this.month) { return Date.today().setWeek(this.value); } if (this.unit === "week" && this.weeks && !this.day && !this.month) { return finishUtils.generateDateFromWeeks.call(this); } if (expression && this.timezone && this.day && this.days) { this.day = this.days; } if (expression){ today.add(this); } else { today.set(this); } if (this.timezone) { this.timezone = this.timezone.toUpperCase(); var offset = $D.getTimezoneOffset(this.timezone); var timezone; if (today.hasDaylightSavingTime()) { // lets check that we're being sane with timezone setting timezone = $D.getTimezoneAbbreviation(offset, today.isDaylightSavingTime()); if (timezone !== this.timezone) { // bugger, we're in a place where things like EST vs EDT matters. if (today.isDaylightSavingTime()) { today.addHours(-1); } else { today.addHours(1); } } } today.setTimezoneOffset(offset); } return today; } }; }()); (function () { var $D = Date; $D.Grammar = {}; var _ = $D.Parsing.Operators, g = $D.Grammar, t = $D.Translator, _fn; // Allow rolling up into general purpose rules _fn = function () { return _.each(_.any.apply(null, arguments), _.not(g.ctoken2("timeContext"))); }; g.datePartDelimiter = _.rtoken(/^([\s\-\.\,\/\x27]+)/); g.timePartDelimiter = _.stoken(":"); g.whiteSpace = _.rtoken(/^\s*/); g.generalDelimiter = _.rtoken(/^(([\s\,]|at|@|on)+)/); var _C = {}; g.ctoken = function (keys) { var fn = _C[keys]; if (! fn) { var c = Date.CultureInfo.regexPatterns; var kx = keys.split(/\s+/), px = []; for (var i = 0; i < kx.length ; i++) { px.push(_.replace(_.rtoken(c[kx[i]]), kx[i])); } fn = _C[keys] = _.any.apply(null, px); } return fn; }; g.ctoken2 = function (key) { return _.rtoken(Date.CultureInfo.regexPatterns[key]); }; var cacheProcessRtoken = function (key, token, type, eachToken) { if (eachToken) { g[key] = _.cache(_.process(_.each(_.rtoken(token),_.optional(g.ctoken2(eachToken))), type)); } else { g[key] = _.cache(_.process(_.rtoken(token), type)); } }; var cacheProcessCtoken = function (token, type) { return _.cache(_.process(g.ctoken2(token), type)); }; var _F = {}; //function cache var _get = function (f) { _F[f] = (_F[f] || g.format(f)[0]); return _F[f]; }; g.allformats = function (fx) { var rx = []; if (fx instanceof Array) { for (var i = 0; i < fx.length; i++) { rx.push(_get(fx[i])); } } else { rx.push(_get(fx)); } return rx; }; g.formats = function (fx) { if (fx instanceof Array) { var rx = []; for (var i = 0 ; i < fx.length ; i++) { rx.push(_get(fx[i])); } return _.any.apply(null, rx); } else { return _get(fx); } }; var grammarFormats = { timeFormats: function(){ var i, RTokenKeys = [ "h", "hh", "H", "HH", "m", "mm", "s", "ss", "ss.s", "z", "zz" ], RToken = [ /^(0[0-9]|1[0-2]|[1-9])/, /^(0[0-9]|1[0-2])/, /^([0-1][0-9]|2[0-3]|[0-9])/, /^([0-1][0-9]|2[0-3])/, /^([0-5][0-9]|[0-9])/, /^[0-5][0-9]/, /^([0-5][0-9]|[0-9])/, /^[0-5][0-9]/, /^[0-5][0-9]\.[0-9]{1,3}/, /^((\+|\-)\s*\d\d\d\d)|((\+|\-)\d\d\:?\d\d)/, /^((\+|\-)\s*\d\d\d\d)|((\+|\-)\d\d\:?\d\d)/ ], tokens = [ t.hour, t.hour, t.hour, t.hour, t.minute, t.minute, t.second, t.second, t.secondAndMillisecond, t.timezone, t.timezone ]; for (i=0; i < RTokenKeys.length; i++) { cacheProcessRtoken(RTokenKeys[i], RToken[i], tokens[i]); } g.hms = _.cache(_.sequence([g.H, g.m, g.s], g.timePartDelimiter)); g.t = cacheProcessCtoken("shortMeridian", t.meridian); g.tt = cacheProcessCtoken("longMeridian", t.meridian); g.zzz = cacheProcessCtoken("timezone", t.timezone); g.timeSuffix = _.each(_.ignore(g.whiteSpace), _.set([ g.tt, g.zzz ])); g.time = _.each(_.optional(_.ignore(_.stoken("T"))), g.hms, g.timeSuffix); }, dateFormats: function () { // pre-loaded rules for different date part order preferences var _setfn = function () { return _.set(arguments, g.datePartDelimiter); }; var i, RTokenKeys = [ "d", "dd", "M", "MM", "y", "yy", "yyy", "yyyy" ], RToken = [ /^([0-2]\d|3[0-1]|\d)/, /^([0-2]\d|3[0-1])/, /^(1[0-2]|0\d|\d)/, /^(1[0-2]|0\d)/, /^(\d+)/, /^(\d\d)/, /^(\d\d?\d?\d?)/, /^(\d\d\d\d)/ ], tokens = [ t.day, t.day, t.month, t.month, t.year, t.year, t.year, t.year ], eachToken = [ "ordinalSuffix", "ordinalSuffix" ]; for (i=0; i < RTokenKeys.length; i++) { cacheProcessRtoken(RTokenKeys[i], RToken[i], tokens[i], eachToken[i]); } g.MMM = g.MMMM = _.cache(_.process(g.ctoken("jan feb mar apr may jun jul aug sep oct nov dec"), t.month)); g.ddd = g.dddd = _.cache(_.process(g.ctoken("sun mon tue wed thu fri sat"), function (s) { return function () { this.weekday = s; }; } )); g.day = _fn(g.d, g.dd); g.month = _fn(g.M, g.MMM); g.year = _fn(g.yyyy, g.yy); g.mdy = _setfn(g.ddd, g.month, g.day, g.year); g.ymd = _setfn(g.ddd, g.year, g.month, g.day); g.dmy = _setfn(g.ddd, g.day, g.month, g.year); g.date = function (s) { return ((g[Date.CultureInfo.dateElementOrder] || g.mdy).call(this, s)); }; }, relative: function () { // relative date / time expressions g.orientation = _.process(g.ctoken("past future"), function (s) { return function () { this.orient = s; }; } ); g.operator = _.process(g.ctoken("add subtract"), function (s) { return function () { this.operator = s; }; } ); g.rday = _.process(g.ctoken("yesterday tomorrow today now"), t.rday); g.unit = _.process(g.ctoken("second minute hour day week month year"), function (s) { return function () { this.unit = s; }; } ); } }; g.buildGrammarFormats = function () { // these need to be rebuilt every time the language changes. _C = {}; grammarFormats.timeFormats(); grammarFormats.dateFormats(); grammarFormats.relative(); g.value = _.process(_.rtoken(/^([-+]?\d+)?(st|nd|rd|th)?/), function (s) { return function () { this.value = s.replace(/\D/g, ""); }; } ); g.expression = _.set([g.rday, g.operator, g.value, g.unit, g.orientation, g.ddd, g.MMM ]); g.format = _.process(_.many( _.any( // translate format specifiers into grammar rules _.process( _.rtoken(/^(dd?d?d?(?!e)|MM?M?M?|yy?y?y?|hh?|HH?|mm?|ss?|tt?|zz?z?)/), function (fmt) { if (g[fmt]) { return g[fmt]; } else { throw $D.Parsing.Exception(fmt); } } ), // translate separator tokens into token rules _.process(_.rtoken(/^[^dMyhHmstz]+/), // all legal separators function (s) { return _.ignore(_.stoken(s)); } ) ) ), // construct the parser ... function (rules) { return _.process(_.each.apply(null, rules), t.finishExact); } ); // starting rule for general purpose grammar g._start = _.process(_.set([ g.date, g.time, g.expression ], g.generalDelimiter, g.whiteSpace), t.finish); }; g.buildGrammarFormats(); // parsing date format specifiers - ex: "h:m:s tt" // this little guy will generate a custom parser based // on the format string, ex: g.format("h:m:s tt") // check for these formats first g._formats = g.formats([ "\"yyyy-MM-ddTHH:mm:ssZ\"", "yyyy-MM-ddTHH:mm:ss.sz", "yyyy-MM-ddTHH:mm:ssZ", "yyyy-MM-ddTHH:mm:ssz", "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-ddTHH:mmZ", "yyyy-MM-ddTHH:mmz", "yyyy-MM-ddTHH:mm", "ddd, MMM dd, yyyy H:mm:ss tt", "ddd MMM d yyyy HH:mm:ss zzz", "MMddyyyy", "ddMMyyyy", "Mddyyyy", "ddMyyyy", "Mdyyyy", "dMyyyy", "yyyy", "Mdyy", "dMyy", "d" ]); // real starting rule: tries selected formats first, // then general purpose rule g.start = function (s) { try { var r = g._formats.call({}, s); if (r[1].length === 0) { return r; } } catch (e) {} return g._start.call({}, s); }; }()); (function () { var $D = Date; /** * @desc Converts the specified string value into its JavaScript Date equivalent using CultureInfo specific format information. * * Example

	///////////
	// Dates //
	///////////

	// 15-Oct-2004
	var d1 = Date.parse("10/15/2004");

	// 15-Oct-2004
	var d1 = Date.parse("15-Oct-2004");

	// 15-Oct-2004
	var d1 = Date.parse("2004.10.15");

	//Fri Oct 15, 2004
	var d1 = Date.parse("Fri Oct 15, 2004");

	///////////
	// Times //
	///////////

	// Today at 10 PM.
	var d1 = Date.parse("10 PM");

	// Today at 10:30 PM.
	var d1 = Date.parse("10:30 P.M.");

	// Today at 6 AM.
	var d1 = Date.parse("06am");

	/////////////////////
	// Dates and Times //
	/////////////////////

	// 8-July-2004 @ 10:30 PM
	var d1 = Date.parse("July 8th, 2004, 10:30 PM");

	// 1-July-2004 @ 10:30 PM
	var d1 = Date.parse("2004-07-01T22:30:00");

	////////////////////
	// Relative Dates //
	////////////////////

	// Returns today's date. The string "today" is culture specific.
	var d1 = Date.parse("today");

	// Returns yesterday's date. The string "yesterday" is culture specific.
	var d1 = Date.parse("yesterday");

	// Returns the date of the next thursday.
	var d1 = Date.parse("Next thursday");

	// Returns the date of the most previous monday.
	var d1 = Date.parse("last monday");

	// Returns today's day + one year.
	var d1 = Date.parse("next year");

	///////////////
	// Date Math //
	///////////////

	// Today + 2 days
	var d1 = Date.parse("t+2");

	// Today + 2 days
	var d1 = Date.parse("today + 2 days");

	// Today + 3 months
	var d1 = Date.parse("t+3m");

	// Today - 1 year
	var d1 = Date.parse("today - 1 year");

	// Today - 1 year
	var d1 = Date.parse("t-1y"); 


	/////////////////////////////
	// Partial Dates and Times //
	/////////////////////////////

	// July 15th of this year.
	var d1 = Date.parse("July 15");

	// 15th day of current day and year.
	var d1 = Date.parse("15");

	// July 1st of current year at 10pm.
	var d1 = Date.parse("7/1 10pm");
	
* * @param {String} The string value to convert into a Date object [Required] * @return {Date} A Date object or null if the string cannot be converted into a Date. */ var parseUtils = { removeOrds: function (s) { ords = s.match(/\b(\d+)(?:st|nd|rd|th)\b/); // find ordinal matches s = ((ords && ords.length === 2) ? s.replace(ords[0], ords[1]) : s); return s; }, grammarParser: function (s) { var r = null; try { r = $D.Grammar.start.call({}, s.replace(/^\s*(\S*(\s+\S+)*)\s*$/, "$1")); } catch (e) { return null; } return ((r[1].length === 0) ? r[0] : null); }, nativeFallback: function(s) { var t; try { // ok we haven't parsed it, last ditch attempt with the built-in parser. t = Date._parse(s); return (t || t === 0) ? new Date(t) : null; } catch (e) { return null; } } }; function parse (s) { var d; if (!s) { return null; } if (s instanceof Date) { return s.clone(); } if (s.length >= 4 && s.charAt(0) !== "0" && s.charAt(0) !== "+"&& s.charAt(0) !== "-") { // ie: 2004 will pass, 0800 won't. // Start with specific formats d = $D.Parsing.ISO.parse(s) || $D.Parsing.Numeric.parse(s); } if (d instanceof Date && !isNaN(d.getTime())) { return d; } else { // find ordinal dates (1st, 3rd, 8th, etc and remove them as they cause parsing issues) s = $D.Parsing.Normalizer.parse(parseUtils.removeOrds(s)); d = parseUtils.grammarParser(s); if (d !== null) { return d; } else { return parseUtils.nativeFallback(s); } } } if (!$D._parse) { $D._parse = $D.parse; } $D.parse = parse; Date.getParseFunction = function (fx) { var fns = Date.Grammar.allformats(fx); return function (s) { var r = null; for (var i = 0; i < fns.length; i++) { try { r = fns[i].call({}, s); } catch (e) { continue; } if (r[1].length === 0) { return r[0]; } } return null; }; }; /** * Converts the specified string value into its JavaScript Date equivalent using the specified format {String} or formats {Array} and the CultureInfo specific format information. * The format of the string value must match one of the supplied formats exactly. * * Example

	// 15-Oct-2004
	var d1 = Date.parseExact("10/15/2004", "M/d/yyyy");

	// 15-Oct-2004
	var d1 = Date.parse("15-Oct-2004", "M-ddd-yyyy");

	// 15-Oct-2004
	var d1 = Date.parse("2004.10.15", "yyyy.MM.dd");

	// Multiple formats
	var d1 = Date.parseExact("10/15/2004", ["M/d/yyyy", "MMMM d, yyyy"]);
	
* * @param {String} The string value to convert into a Date object [Required]. * @param {Object} The expected format {String} or an array of expected formats {Array} of the date string [Required]. * @return {Date} A Date object or null if the string cannot be converted into a Date. */ $D.parseExact = function (s, fx) { return $D.getParseFunction(fx)(s); }; }()); (function () { var $D = Date, $P = $D.prototype, // $C = $D.CultureInfo, // not used atm p = function (s, l) { if (!l) { l = 2; } return ("000" + s).slice(l * -1); }; /** * Converts a PHP format string to Java/.NET format string. * A PHP format string can be used with ._format or .format. * A Java/.NET format string can be used with .toString(). * The .parseExact function will only accept a Java/.NET format string * * Example * var f1 = "%m/%d/%y" * var f2 = Date.normalizeFormat(f1); // "MM/dd/yy" * * new Date().format(f1); // "04/13/08" * new Date()._format(f1); // "04/13/08" * new Date().toString(f2); // "04/13/08" * * var date = Date.parseExact("04/13/08", f2); // Sun Apr 13 2008 * * @param {String} A PHP format string consisting of one or more format spcifiers. * @return {String} The PHP format converted to a Java/.NET format string. */ var normalizerSubstitutions = { "d" : "dd", "%d": "dd", "D" : "ddd", "%a": "ddd", "j" : "dddd", "l" : "dddd", "%A": "dddd", "S" : "S", "F" : "MMMM", "%B": "MMMM", "m" : "MM", "%m": "MM", "M" : "MMM", "%b": "MMM", "%h": "MMM", "n" : "M", "Y" : "yyyy", "%Y": "yyyy", "y" : "yy", "%y": "yy", "g" : "h", "%I": "h", "G" : "H", "h" : "hh", "H" : "HH", "%H": "HH", "i" : "mm", "%M": "mm", "s" : "ss", "%S": "ss", "%r": "hh:mm tt", "%R": "H:mm", "%T": "H:mm:ss", "%X": "t", "%x": "d", "%e": "d", "%D": "MM/dd/yy", "%n": "\\n", "%t": "\\t", "e" : "z", "T" : "z", "%z": "z", "%Z": "z", "Z" : "ZZ", "N" : "u", "w" : "u", "%w": "u", "W" : "W", "%V": "W" }; var normalizer = { substitutes: function (m) { return normalizerSubstitutions[m]; }, interpreted: function (m, x) { var y; switch (m) { case "%u": return x.getDay() + 1; case "z": return x.getOrdinalNumber(); case "%j": return p(x.getOrdinalNumber(), 3); case "%U": var d1 = x.clone().set({month: 0, day: 1}).addDays(-1).moveToDayOfWeek(0), d2 = x.clone().addDays(1).moveToDayOfWeek(0, -1); return (d2 < d1) ? "00" : p((d2.getOrdinalNumber() - d1.getOrdinalNumber()) / 7 + 1); case "%W": return p(x.getWeek()); case "t": return $D.getDaysInMonth(x.getFullYear(), x.getMonth()); case "o": case "%G": return x.setWeek(x.getISOWeek()).toString("yyyy"); case "%g": return x._format("%G").slice(-2); case "a": case "%p": return t("tt").toLowerCase(); case "A": return t("tt").toUpperCase(); case "u": return p(x.getMilliseconds(), 3); case "I": return (x.isDaylightSavingTime()) ? 1 : 0; case "O": return x.getUTCOffset(); case "P": y = x.getUTCOffset(); return y.substring(0, y.length - 2) + ":" + y.substring(y.length - 2); case "B": var now = new Date(); return Math.floor(((now.getHours() * 3600) + (now.getMinutes() * 60) + now.getSeconds() + (now.getTimezoneOffset() + 60) * 60) / 86.4); case "c": return x.toISOString().replace(/\"/g, ""); case "U": return $D.strtotime("now"); case "%c": return t("d") + " " + t("t"); case "%C": return Math.floor(x.getFullYear() / 100 + 1); } }, shouldOverrideDefaults: function (m) { switch (m) { case "%e": return true; default: return false; } }, parse: function (m, context) { var formatString, c = context || new Date(); formatString = normalizer.substitutes(m); if (formatString) { return formatString; } formatString = normalizer.interpreted(m, c); if (formatString) { return formatString; } else { return m; } } }; $D.normalizeFormat = function (format, context) { return format.replace(/(%|\\)?.|%%/g, function(t){ return normalizer.parse(t, context); }); }; /** * Format a local Unix timestamp according to locale settings * * Example: * Date.strftime("%m/%d/%y", new Date()); // "04/13/08" * Date.strftime("c", "2008-04-13T17:52:03Z"); // "04/13/08" * * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @param {Number|String} The number representing the number of seconds that have elapsed since January 1, 1970 (local time). * @return {String} A string representation of the current Date object. */ $D.strftime = function (format, time) { var d = Date.parse(time); return d._format(format); }; /** * Parse any textual datetime description into a Unix timestamp. * A Unix timestamp is the number of seconds that have elapsed since January 1, 1970 (midnight UTC/GMT). * * Example: * Date.strtotime("04/13/08"); // 1208044800 * Date.strtotime("1970-01-01T00:00:00Z"); // 0 * * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @param {Object} A string or date object. * @return {String} A string representation of the current Date object. */ $D.strtotime = function (time) { var d = $D.parse(time); return Math.round($D.UTC(d.getUTCFullYear(), d.getUTCMonth(), d.getUTCDate(), d.getUTCHours(), d.getUTCMinutes(), d.getUTCSeconds(), d.getUTCMilliseconds()) / 1000); }; /** * Converts the value of the current Date object to its equivalent string representation using a PHP/Unix style of date format specifiers. * Format Specifiers * Format Description Example * ------ --------------------------------------------------------------------------- ----------------------- * %a abbreviated weekday name according to the current localed "Mon" through "Sun" * %A full weekday name according to the current localed "Sunday" through "Saturday" * %b abbreviated month name according to the current localed "Jan" through "Dec" * %B full month name according to the current locale "January" through "December" * %c preferred date and time representation for the current locale "4/13/2008 12:33 PM" * %C century number (the year divided by 100 and truncated to an integer) "00" to "99" * %d day of the month as a decimal number "01" to "31" * %D same as %m/%d/%y "04/13/08" * %e day of the month as a decimal number, a single digit is preceded by a space "1" to "31" * %g like %G, but without the century "08" * %G The 4-digit year corresponding to the ISO week number (see %V). "2008" * This has the same format and value as %Y, except that if the ISO week number * belongs to the previous or next year, that year is used instead. * %h same as %b "Jan" through "Dec" * %H hour as a decimal number using a 24-hour clock. "00" to "23" * %I hour as a decimal number using a 12-hour clock. "01" to "12" * %j day of the year as a decimal number. "001" to "366" * %m month as a decimal number. "01" to "12" * %M minute as a decimal number. "00" to "59" * %n newline character "\n" * %p either "am" or "pm" according to the given time value, or the "am" or "pm" * corresponding strings for the current locale. * %r time in a.m. and p.m. notation "8:44 PM" * %R time in 24 hour notation "20:44" * %S second as a decimal number "00" to "59" * %t tab character "\t" * %T current time, equal to %H:%M:%S "12:49:11" * %u weekday as a decimal number ["1", "7"], with "1" representing Monday "1" to "7" * %U week number of the current year as a decimal number, starting with the "0" to ("52" or "53") * first Sunday as the first day of the first week * %V The ISO 8601:1988 week number of the current year as a decimal number, "00" to ("52" or "53") * range 01 to 53, where week 1 is the first week that has at least 4 days * in the current year, and with Monday as the first day of the week. * (Use %G or %g for the year component that corresponds to the week number * for the specified timestamp.) * %W week number of the current year as a decimal number, starting with the "00" to ("52" or "53") * first Monday as the first day of the first week * %w day of the week as a decimal, Sunday being "0" "0" to "6" * %x preferred date representation for the current locale without the time "4/13/2008" * %X preferred time representation for the current locale without the date "12:53:05" * %y year as a decimal number without a century "00" "99" * %Y year as a decimal number including the century "2008" * %Z time zone or name or abbreviation "UTC", "EST", "PST" * %z same as %Z * %% a literal "%" characters "%" * d Day of the month, 2 digits with leading zeros "01" to "31" * D A textual representation of a day, three letters "Mon" through "Sun" * j Day of the month without leading zeros "1" to "31" * l A full textual representation of the day of the week (lowercase "L") "Sunday" through "Saturday" * N ISO-8601 numeric representation of the day of the week (added in PHP 5.1.0) "1" (for Monday) through "7" (for Sunday) * S English ordinal suffix for the day of the month, 2 characters "st", "nd", "rd" or "th". Works well with j * w Numeric representation of the day of the week "0" (for Sunday) through "6" (for Saturday) * z The day of the year (starting from "0") "0" through "365" * W ISO-8601 week number of year, weeks starting on Monday "00" to ("52" or "53") * F A full textual representation of a month, such as January or March "January" through "December" * m Numeric representation of a month, with leading zeros "01" through "12" * M A short textual representation of a month, three letters "Jan" through "Dec" * n Numeric representation of a month, without leading zeros "1" through "12" * t Number of days in the given month "28" through "31" * L Whether it's a leap year "1" if it is a leap year, "0" otherwise * o ISO-8601 year number. This has the same value as Y, except that if the "2008" * ISO week number (W) belongs to the previous or next year, that year * is used instead. * Y A full numeric representation of a year, 4 digits "2008" * y A two digit representation of a year "08" * a Lowercase Ante meridiem and Post meridiem "am" or "pm" * A Uppercase Ante meridiem and Post meridiem "AM" or "PM" * B Swatch Internet time "000" through "999" * g 12-hour format of an hour without leading zeros "1" through "12" * G 24-hour format of an hour without leading zeros "0" through "23" * h 12-hour format of an hour with leading zeros "01" through "12" * H 24-hour format of an hour with leading zeros "00" through "23" * i Minutes with leading zeros "00" to "59" * s Seconds, with leading zeros "00" through "59" * u Milliseconds "54321" * e Timezone identifier "UTC", "EST", "PST" * I Whether or not the date is in daylight saving time (uppercase i) "1" if Daylight Saving Time, "0" otherwise * O Difference to Greenwich time (GMT) in hours "+0200", "-0600" * P Difference to Greenwich time (GMT) with colon between hours and minutes "+02:00", "-06:00" * T Timezone abbreviation "UTC", "EST", "PST" * Z Timezone offset in seconds. The offset for timezones west of UTC is "-43200" through "50400" * always negative, and for those east of UTC is always positive. * c ISO 8601 date "2004-02-12T15:19:21+00:00" * r RFC 2822 formatted date "Thu, 21 Dec 2000 16:01:07 +0200" * U Seconds since the Unix Epoch (January 1 1970 00:00:00 GMT) "0" * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @return {String} A string representation of the current Date object. */ var formatReplace = function (context) { return function (m) { var formatString, override = false; if (m.charAt(0) === "\\" || m.substring(0, 2) === "%%") { return m.replace("\\", "").replace("%%", "%"); } override = normalizer.shouldOverrideDefaults(m); formatString = $D.normalizeFormat(m, context); if (formatString) { return context.toString(formatString, override); } }; }; $P._format = function (format) { var formatter = formatReplace(this); if (!format) { return this._toString(); } else { return format.replace(/(%|\\)?.|%%/g, formatter); } }; if (!$P.format) { $P.format = $P._format; } }()); (function () { "use strict"; var gFn = function (attr) { return function () { return this[attr]; }; }; var sFn = function (attr) { return function (val) { this[attr] = val; return this; }; }; var attrs = ["years", "months", "days", "hours", "minutes", "seconds", "milliseconds"]; var addSetFuncs = function (context, attrs) { for (var i = 0; i < attrs.length ; i++) { var $a = attrs[i], $b = $a.slice(0, 1).toUpperCase() + $a.slice(1); context.prototype[$a] = 0; context.prototype["get" + $b] = gFn($a); context.prototype["set" + $b] = sFn($a); } }; /** * new TimeSpan(milliseconds); * new TimeSpan(days, hours, minutes, seconds); * new TimeSpan(days, hours, minutes, seconds, milliseconds); */ var TimeSpan = function (days, hours, minutes, seconds, milliseconds) { if (arguments.length === 1 && typeof days === "number") { var orient = (days < 0) ? -1 : +1; var millsLeft = Math.abs(days); this.setDays(Math.floor(millsLeft / 86400000) * orient); millsLeft = millsLeft % 86400000; this.setHours(Math.floor(millsLeft / 3600000) * orient); millsLeft = millsLeft % 3600000; this.setMinutes(Math.floor(millsLeft / 60000) * orient); millsLeft = millsLeft % 60000; this.setSeconds(Math.floor(millsLeft / 1000) * orient); millsLeft = millsLeft % 1000; this.setMilliseconds(millsLeft * orient); } else { this.set(days, hours, minutes, seconds, milliseconds); } this.getTotalMilliseconds = function () { return (this.getDays() * 86400000) + (this.getHours() * 3600000) + (this.getMinutes() * 60000) + (this.getSeconds() * 1000); }; this.compareTo = function (time) { var t1 = new Date(1970, 1, 1, this.getHours(), this.getMinutes(), this.getSeconds()), t2; if (time === null) { t2 = new Date(1970, 1, 1, 0, 0, 0); } else { t2 = new Date(1970, 1, 1, time.getHours(), time.getMinutes(), time.getSeconds()); } return (t1 < t2) ? -1 : (t1 > t2) ? 1 : 0; }; this.equals = function (time) { return (this.compareTo(time) === 0); }; this.add = function (time) { return (time === null) ? this : this.addSeconds(time.getTotalMilliseconds() / 1000); }; this.subtract = function (time) { return (time === null) ? this : this.addSeconds(-time.getTotalMilliseconds() / 1000); }; this.addDays = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 86400000)); }; this.addHours = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 3600000)); }; this.addMinutes = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 60000)); }; this.addSeconds = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 1000)); }; this.addMilliseconds = function (n) { return new TimeSpan(this.getTotalMilliseconds() + n); }; this.get12HourHour = function () { return (this.getHours() > 12) ? this.getHours() - 12 : (this.getHours() === 0) ? 12 : this.getHours(); }; this.getDesignator = function () { return (this.getHours() < 12) ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator; }; this.toString = function (format) { this._toString = function () { if (this.getDays() !== null && this.getDays() > 0) { return this.getDays() + "." + this.getHours() + ":" + this.p(this.getMinutes()) + ":" + this.p(this.getSeconds()); } else { return this.getHours() + ":" + this.p(this.getMinutes()) + ":" + this.p(this.getSeconds()); } }; this.p = function (s) { return (s.toString().length < 2) ? "0" + s : s; }; var me = this; return format ? format.replace(/dd?|HH?|hh?|mm?|ss?|tt?/g, function (format) { switch (format) { case "d": return me.getDays(); case "dd": return me.p(me.getDays()); case "H": return me.getHours(); case "HH": return me.p(me.getHours()); case "h": return me.get12HourHour(); case "hh": return me.p(me.get12HourHour()); case "m": return me.getMinutes(); case "mm": return me.p(me.getMinutes()); case "s": return me.getSeconds(); case "ss": return me.p(me.getSeconds()); case "t": return ((me.getHours() < 12) ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator).substring(0, 1); case "tt": return (me.getHours() < 12) ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator; } } ) : this._toString(); }; return this; }; addSetFuncs(TimeSpan, attrs.slice(2)); TimeSpan.prototype.set = function (days, hours, minutes, seconds, milliseconds){ this.setDays(days || this.getDays()); this.setHours(hours || this.getHours()); this.setMinutes(minutes || this.getMinutes()); this.setSeconds(seconds || this.getSeconds()); this.setMilliseconds(milliseconds || this.getMilliseconds()); }; /** * Gets the time of day for this date instances. * @return {TimeSpan} TimeSpan */ Date.prototype.getTimeOfDay = function () { return new TimeSpan(0, this.getHours(), this.getMinutes(), this.getSeconds(), this.getMilliseconds()); }; Date.TimeSpan = TimeSpan; if (typeof window !== "undefined" ) { // keeping API compatible for v1.x window.TimeSpan = TimeSpan; } }()); (function () { "use strict"; var attrs = ["years", "months", "days", "hours", "minutes", "seconds", "milliseconds"]; var gFn = function (attr) { return function () { return this[attr]; }; }; var sFn = function (attr) { return function (val) { this[attr] = val; return this; }; }; var addSetFuncs = function (context, attrs) { for (var i = 0; i < attrs.length ; i++) { var $a = attrs[i], $b = $a.slice(0, 1).toUpperCase() + $a.slice(1); context.prototype[$a] = 0; context.prototype["get" + $b] = gFn($a); context.prototype["set" + $b] = sFn($a); } }; var setMonthsAndYears = function (orient, d1, d2, context) { function inc() { d1.addMonths(-orient); context.months++; if (context.months === 12) { context.years++; context.months = 0; } } if (orient === +1) { while (d1 > d2) { inc(); } } else { while (d1 < d2) { inc(); } } context.months--; context.months *= orient; context.years *= orient; }; var adjustForDST = function(orient, startDate, endDate) { var hasDSTMismatch = (false === (startDate.isDaylightSavingTime() === endDate.isDaylightSavingTime())); if (hasDSTMismatch && orient === 1) { startDate.addHours(-1); } else if (hasDSTMismatch) { startDate.addHours(1); } }; /** * TimePeriod(startDate, endDate); * TimePeriod(years, months, days, hours, minutes, seconds, milliseconds); */ var TimePeriod = function (years, months, days, hours, minutes, seconds, milliseconds) { if (arguments.length === 7) { this.set(years, months, days, hours, minutes, seconds, milliseconds); } else if (arguments.length === 2 && arguments[0] instanceof Date && arguments[1] instanceof Date) { var startDate = arguments[0].clone(); var endDate = arguments[1].clone(); var orient = (startDate > endDate) ? +1 : -1; this.dates = { start: arguments[0].clone(), end: arguments[1].clone() }; setMonthsAndYears(orient, startDate, endDate, this); adjustForDST(orient, startDate, endDate); // // TODO - adjust for DST var diff = endDate - startDate; if (diff !== 0) { var ts = new TimeSpan(diff); this.set(this.years, this.months, ts.getDays(), ts.getHours(), ts.getMinutes(), ts.getSeconds(), ts.getMilliseconds()); } } return this; }; // create all the set functions. addSetFuncs(TimePeriod, attrs); TimePeriod.prototype.set = function (years, months, days, hours, minutes, seconds, milliseconds){ this.setYears(years || this.getYears()); this.setMonths(months || this.getMonths()); this.setDays(days || this.getDays()); this.setHours(hours || this.getHours()); this.setMinutes(minutes || this.getMinutes()); this.setSeconds(seconds || this.getSeconds()); this.setMilliseconds(milliseconds || this.getMilliseconds()); }; Date.TimePeriod = TimePeriod; if (typeof window !== "undefined") { // keeping API compatible for v1.x window.TimePeriod = TimePeriod; } }()); ================================================ FILE: build/date-es-CO.js ================================================ /** * @overview datejs * @version 1.0.0-rc3 * @author Gregory Wild-Smith * @copyright 2015 Gregory Wild-Smith * @license MIT * @homepage https://github.com/abritinthebay/datejs */ /* * DateJS Culture String File * Country Code: es-CO * Name: Spanish (Colombia) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["es-CO"] = { "name": "es-CO", "englishName": "Spanish (Colombia)", "nativeName": "Español (Colombia)", "Sunday": "domingo", "Monday": "lunes", "Tuesday": "martes", "Wednesday": "miércoles", "Thursday": "jueves", "Friday": "viernes", "Saturday": "sábado", "Sun": "dom", "Mon": "lun", "Tue": "mar", "Wed": "mié", "Thu": "jue", "Fri": "vie", "Sat": "sáb", "Su": "do", "Mo": "lu", "Tu": "ma", "We": "mi", "Th": "ju", "Fr": "vi", "Sa": "sá", "S_Sun_Initial": "d", "M_Mon_Initial": "l", "T_Tue_Initial": "m", "W_Wed_Initial": "m", "T_Thu_Initial": "j", "F_Fri_Initial": "v", "S_Sat_Initial": "s", "January": "enero", "February": "febrero", "March": "marzo", "April": "abril", "May": "mayo", "June": "junio", "July": "julio", "August": "agosto", "September": "septiembre", "October": "octubre", "November": "noviembre", "December": "diciembre", "Jan_Abbr": "ene", "Feb_Abbr": "feb", "Mar_Abbr": "mar", "Apr_Abbr": "abr", "May_Abbr": "may", "Jun_Abbr": "jun", "Jul_Abbr": "jul", "Aug_Abbr": "ago", "Sep_Abbr": "sep", "Oct_Abbr": "oct", "Nov_Abbr": "nov", "Dec_Abbr": "dic", "AM": "a.m.", "PM": "p.m.", "firstDayOfWeek": 0, "twoDigitYearMax": 2029, "mdy": "dmy", "M/d/yyyy": "dd/MM/yyyy", "dddd, MMMM dd, yyyy": "dddd, dd' [de] 'MMMM' [de] 'yyyy", "h:mm tt": "hh:mm tt", "h:mm:ss tt": "hh:mm:ss tt", "dddd, MMMM dd, yyyy h:mm:ss tt": "dddd, dd' [de] 'MMMM' [de] 'yyyy hh:mm:ss tt", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "dd MMMM", "MMMM, yyyy": "MMMM' [de] 'yyyy", "/jan(uary)?/": "ene(ro)?", "/feb(ruary)?/": "feb(rero)?", "/mar(ch)?/": "mar(zo)?", "/apr(il)?/": "abr(il)?", "/may/": "may(o)?", "/jun(e)?/": "jun(io)?", "/jul(y)?/": "jul(io)?", "/aug(ust)?/": "ago(sto)?", "/sep(t(ember)?)?/": "sep(tiembre)?", "/oct(ober)?/": "oct(ubre)?", "/nov(ember)?/": "nov(iembre)?", "/dec(ember)?/": "dic(iembre)?", "/^su(n(day)?)?/": "^do(m(ingo)?)?", "/^mo(n(day)?)?/": "^lu(n(es)?)?", "/^tu(e(s(day)?)?)?/": "^ma(r(tes)?)?", "/^we(d(nesday)?)?/": "^mi(é(rcoles)?)?", "/^th(u(r(s(day)?)?)?)?/": "^ju(e(ves)?)?", "/^fr(i(day)?)?/": "^vi(e(rnes)?)?", "/^sa(t(urday)?)?/": "^sá(b(ado)?)?", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "es-CO"; /** * @overview datejs * @version 1.0.0-rc3 * @author Gregory Wild-Smith * @copyright 2015 Gregory Wild-Smith * @license MIT * @homepage https://github.com/abritinthebay/datejs */(function () { var $D = Date; var lang = Date.CultureStrings ? Date.CultureStrings.lang : null; var loggedKeys = {}; // for debug purposes. var getText = { getFromKey: function (key, countryCode) { var output; if (Date.CultureStrings && Date.CultureStrings[countryCode] && Date.CultureStrings[countryCode][key]) { output = Date.CultureStrings[countryCode][key]; } else { output = getText.buildFromDefault(key); } if (key.charAt(0) === "/") { // Assume it's a regex output = getText.buildFromRegex(key, countryCode); } return output; }, getFromObjectValues: function (obj, countryCode) { var key, output = {}; for(key in obj) { if (obj.hasOwnProperty(key)) { output[key] = getText.getFromKey(obj[key], countryCode); } } return output; }, getFromObjectKeys: function (obj, countryCode) { var key, output = {}; for(key in obj) { if (obj.hasOwnProperty(key)) { output[getText.getFromKey(key, countryCode)] = obj[key]; } } return output; }, getFromArray: function (arr, countryCode) { var output = []; for (var i=0; i < arr.length; i++){ if (i in arr) { output[i] = getText.getFromKey(arr[i], countryCode); } } return output; }, buildFromDefault: function (key) { var output, length, split, last; switch(key) { case "name": output = "en-US"; break; case "englishName": output = "English (United States)"; break; case "nativeName": output = "English (United States)"; break; case "twoDigitYearMax": output = 2049; break; case "firstDayOfWeek": output = 0; break; default: output = key; split = key.split("_"); length = split.length; if (length > 1 && key.charAt(0) !== "/") { // if the key isn't a regex and it has a split. last = split[(length - 1)].toLowerCase(); if (last === "initial" || last === "abbr") { output = split[0]; } } break; } return output; }, buildFromRegex: function (key, countryCode) { var output; if (Date.CultureStrings && Date.CultureStrings[countryCode] && Date.CultureStrings[countryCode][key]) { output = new RegExp(Date.CultureStrings[countryCode][key], "i"); } else { output = new RegExp(key.replace(new RegExp("/", "g"),""), "i"); } return output; } }; var shallowMerge = function (obj1, obj2) { for (var attrname in obj2) { if (obj2.hasOwnProperty(attrname)) { obj1[attrname] = obj2[attrname]; } } }; var __ = function (key, language) { var countryCode = (language) ? language : lang; loggedKeys[key] = key; if (typeof key === "object") { if (key instanceof Array) { return getText.getFromArray(key, countryCode); } else { return getText.getFromObjectKeys(key, countryCode); } } else { return getText.getFromKey(key, countryCode); } }; var loadI18nScript = function (code) { // paatterned after jQuery's getScript. var url = Date.Config.i18n + code + ".js"; var head = document.getElementsByTagName("head")[0] || document.documentElement; var script = document.createElement("script"); script.src = url; var completed = false; var events = { done: function (){} // placeholder function }; // Attach handlers for all browsers script.onload = script.onreadystatechange = function() { if ( !completed && (!this.readyState || this.readyState === "loaded" || this.readyState === "complete") ) { events.done(); head.removeChild(script); } }; setTimeout(function() { head.insertBefore(script, head.firstChild); }, 0); // allows return to execute first return { done: function (cb) { events.done = function() { if (cb) { setTimeout(cb,0); } }; } }; }; var buildInfo = { buildFromMethodHash: function (obj) { var key; for(key in obj) { if (obj.hasOwnProperty(key)) { obj[key] = buildInfo[obj[key]](); } } return obj; }, timeZoneDST: function () { var DST = { "CHADT": "+1345", "NZDT": "+1300", "AEDT": "+1100", "ACDT": "+1030", "AZST": "+0500", "IRDT": "+0430", "EEST": "+0300", "CEST": "+0200", "BST": "+0100", "PMDT": "-0200", "ADT": "-0300", "NDT": "-0230", "EDT": "-0400", "CDT": "-0500", "MDT": "-0600", "PDT": "-0700", "AKDT": "-0800", "HADT": "-0900" }; return __(DST); }, timeZoneStandard: function () { var standard = { "LINT": "+1400", "TOT": "+1300", "CHAST": "+1245", "NZST": "+1200", "NFT": "+1130", "SBT": "+1100", "AEST": "+1000", "ACST": "+0930", "JST": "+0900", "CWST": "+0845", "CT": "+0800", "ICT": "+0700", "MMT": "+0630", "BST": "+0600", "NPT": "+0545", "IST": "+0530", "PKT": "+0500", "AFT": "+0430", "MSK": "+0400", "IRST": "+0330", "FET": "+0300", "EET": "+0200", "CET": "+0100", "GMT": "+0000", "UTC": "+0000", "CVT": "-0100", "GST": "-0200", "BRT": "-0300", "NST": "-0330", "AST": "-0400", "EST": "-0500", "CST": "-0600", "MST": "-0700", "PST": "-0800", "AKST": "-0900", "MIT": "-0930", "HST": "-1000", "SST": "-1100", "BIT": "-1200" }; return __(standard); }, timeZones: function (data) { var zone; data.timezones = []; for (zone in data.abbreviatedTimeZoneStandard) { if (data.abbreviatedTimeZoneStandard.hasOwnProperty(zone)) { data.timezones.push({ name: zone, offset: data.abbreviatedTimeZoneStandard[zone]}); } } for (zone in data.abbreviatedTimeZoneDST) { if (data.abbreviatedTimeZoneDST.hasOwnProperty(zone)) { data.timezones.push({ name: zone, offset: data.abbreviatedTimeZoneDST[zone], dst: true}); } } return data.timezones; }, days: function () { return __(["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"]); }, dayAbbr: function () { return __(["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"]); }, dayShortNames: function () { return __(["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"]); }, dayFirstLetters: function () { return __(["S_Sun_Initial", "M_Mon_Initial", "T_Tues_Initial", "W_Wed_Initial", "T_Thu_Initial", "F_Fri_Initial", "S_Sat_Initial"]); }, months: function () { return __(["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"]); }, monthAbbr: function () { return __(["Jan_Abbr", "Feb_Abbr", "Mar_Abbr", "Apr_Abbr", "May_Abbr", "Jun_Abbr", "Jul_Abbr", "Aug_Abbr", "Sep_Abbr", "Oct_Abbr", "Nov_Abbr", "Dec_Abbr"]); }, formatPatterns: function () { return getText.getFromObjectValues({ shortDate: "M/d/yyyy", longDate: "dddd, MMMM dd, yyyy", shortTime: "h:mm tt", longTime: "h:mm:ss tt", fullDateTime: "dddd, MMMM dd, yyyy h:mm:ss tt", sortableDateTime: "yyyy-MM-ddTHH:mm:ss", universalSortableDateTime: "yyyy-MM-dd HH:mm:ssZ", rfc1123: "ddd, dd MMM yyyy HH:mm:ss", monthDay: "MMMM dd", yearMonth: "MMMM, yyyy" }, Date.i18n.currentLanguage()); }, regex: function () { return getText.getFromObjectValues({ inTheMorning: "/( in the )(morn(ing)?)\\b/", thisMorning: "/(this )(morn(ing)?)\\b/", amThisMorning: "/(\b\\d(am)? )(this )(morn(ing)?)/", inTheEvening: "/( in the )(even(ing)?)\\b/", thisEvening: "/(this )(even(ing)?)\\b/", pmThisEvening: "/(\b\\d(pm)? )(this )(even(ing)?)/", jan: "/jan(uary)?/", feb: "/feb(ruary)?/", mar: "/mar(ch)?/", apr: "/apr(il)?/", may: "/may/", jun: "/jun(e)?/", jul: "/jul(y)?/", aug: "/aug(ust)?/", sep: "/sep(t(ember)?)?/", oct: "/oct(ober)?/", nov: "/nov(ember)?/", dec: "/dec(ember)?/", sun: "/^su(n(day)?)?/", mon: "/^mo(n(day)?)?/", tue: "/^tu(e(s(day)?)?)?/", wed: "/^we(d(nesday)?)?/", thu: "/^th(u(r(s(day)?)?)?)?/", fri: "/fr(i(day)?)?/", sat: "/^sa(t(urday)?)?/", future: "/^next/", past: "/^last|past|prev(ious)?/", add: "/^(\\+|aft(er)?|from|hence)/", subtract: "/^(\\-|bef(ore)?|ago)/", yesterday: "/^yes(terday)?/", today: "/^t(od(ay)?)?/", tomorrow: "/^tom(orrow)?/", now: "/^n(ow)?/", millisecond: "/^ms|milli(second)?s?/", second: "/^sec(ond)?s?/", minute: "/^mn|min(ute)?s?/", hour: "/^h(our)?s?/", week: "/^w(eek)?s?/", month: "/^m(onth)?s?/", day: "/^d(ay)?s?/", year: "/^y(ear)?s?/", shortMeridian: "/^(a|p)/", longMeridian: "/^(a\\.?m?\\.?|p\\.?m?\\.?)/", timezone: "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/", ordinalSuffix: "/^\\s*(st|nd|rd|th)/", timeContext: "/^\\s*(\\:|a(?!u|p)|p)/" }, Date.i18n.currentLanguage()); } }; var CultureInfo = function () { var info = getText.getFromObjectValues({ name: "name", englishName: "englishName", nativeName: "nativeName", amDesignator: "AM", pmDesignator: "PM", firstDayOfWeek: "firstDayOfWeek", twoDigitYearMax: "twoDigitYearMax", dateElementOrder: "mdy" }, Date.i18n.currentLanguage()); var constructedInfo = buildInfo.buildFromMethodHash({ dayNames: "days", abbreviatedDayNames: "dayAbbr", shortestDayNames: "dayShortNames", firstLetterDayNames: "dayFirstLetters", monthNames: "months", abbreviatedMonthNames: "monthAbbr", formatPatterns: "formatPatterns", regexPatterns: "regex", abbreviatedTimeZoneDST: "timeZoneDST", abbreviatedTimeZoneStandard: "timeZoneStandard" }); shallowMerge(info, constructedInfo); buildInfo.timeZones(info); return info; }; $D.i18n = { __: function (key, lang) { return __(key, lang); }, currentLanguage: function () { return lang || "en-US"; }, setLanguage: function (code, force, cb) { var async = false; if (force || code === "en-US" || (!!Date.CultureStrings && !!Date.CultureStrings[code])) { lang = code; Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings.lang = code; Date.CultureInfo = new CultureInfo(); } else { if (!(!!Date.CultureStrings && !!Date.CultureStrings[code])) { if (typeof exports !== "undefined" && this.exports !== exports) { // we're in a Node enviroment, load it using require try { require("../i18n/" + code + ".js"); lang = code; Date.CultureStrings.lang = code; Date.CultureInfo = new CultureInfo(); } catch (e) { // var str = "The language for '" + code + "' could not be loaded by Node. It likely does not exist."; throw new Error("The DateJS IETF language tag '" + code + "' could not be loaded by Node. It likely does not exist."); } } else if (Date.Config && Date.Config.i18n) { // we know the location of the files, so lets load them async = true; loadI18nScript(code).done(function(){ lang = code; Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings.lang = code; Date.CultureInfo = new CultureInfo(); $D.Parsing.Normalizer.buildReplaceData(); // because this is async if ($D.Grammar) { $D.Grammar.buildGrammarFormats(); // so we can parse those strings... } if (cb) { setTimeout(cb,0); } }); } else { Date.console.error("The DateJS IETF language tag '" + code + "' is not available and has not been loaded."); return false; } } } $D.Parsing.Normalizer.buildReplaceData(); // rebuild normalizer strings if ($D.Grammar) { $D.Grammar.buildGrammarFormats(); // so we can parse those strings... } if (!async && cb) { setTimeout(cb,0); } }, getLoggedKeys: function () { return loggedKeys; }, updateCultureInfo: function () { Date.CultureInfo = new CultureInfo(); } }; $D.i18n.updateCultureInfo(); // run automatically }()); (function () { var $D = Date, $P = $D.prototype, p = function (s, l) { if (!l) { l = 2; } return ("000" + s).slice(l * -1); }; if (typeof window !== "undefined" && typeof window.console !== "undefined" && typeof window.console.log !== "undefined") { $D.console = console; // used only to raise non-critical errors if available } else { // set mock so we don't give errors. $D.console = { log: function(){}, error: function(){} }; } $D.Config = $D.Config || {}; $D.initOverloads = function() { /** * Overload of Date.now. Allows an alternate call for Date.now where it returns the * current Date as an object rather than just milliseconds since the Unix Epoch. * * Also provides an implementation of now() for browsers (IE<9) that don't have it. * * Backwards compatible so with work with either: * Date.now() [returns ms] * or * Date.now(true) [returns Date] */ if (!$D.now) { $D._now = function now() { return new Date().getTime(); }; } else if (!$D._now) { $D._now = $D.now; } $D.now = function (returnObj) { if (returnObj) { return $D.present(); } else { return $D._now(); } }; if ( !$P.toISOString ) { $P.toISOString = function() { return this.getUTCFullYear() + "-" + p(this.getUTCMonth() + 1) + "-" + p(this.getUTCDate()) + "T" + p(this.getUTCHours()) + ":" + p(this.getUTCMinutes()) + ":" + p(this.getUTCSeconds()) + "." + String( (this.getUTCMilliseconds()/1000).toFixed(3)).slice(2, 5) + "Z"; }; } // private if ( $P._toString === undefined ){ $P._toString = $P.toString; } }; $D.initOverloads(); /** * Gets a date that is set to the current date. The time is set to the start of the day (00:00 or 12:00 AM). * @return {Date} The current date. */ $D.today = function () { return new Date().clearTime(); }; /** * Gets a date that is set to the current date and time (same as new Date, but chainable) * @return {Date} The current date. */ $D.present = function () { return new Date(); }; /** * Compares the first date to the second date and returns an number indication of their relative values. * @param {Date} First Date object to compare [Required]. * @param {Date} Second Date object to compare to [Required]. * @return {Number} -1 = date1 is lessthan date2. 0 = values are equal. 1 = date1 is greaterthan date2. */ $D.compare = function (date1, date2) { if (isNaN(date1) || isNaN(date2)) { throw new Error(date1 + " - " + date2); } else if (date1 instanceof Date && date2 instanceof Date) { return (date1 < date2) ? -1 : (date1 > date2) ? 1 : 0; } else { throw new TypeError(date1 + " - " + date2); } }; /** * Compares the first Date object to the second Date object and returns true if they are equal. * @param {Date} First Date object to compare [Required] * @param {Date} Second Date object to compare to [Required] * @return {Boolean} true if dates are equal. false if they are not equal. */ $D.equals = function (date1, date2) { return (date1.compareTo(date2) === 0); }; /** * Gets the language appropriate day name when given the day number(0-6) * eg - 0 == Sunday * @return {String} The day name */ $D.getDayName = function (n) { return Date.CultureInfo.dayNames[n]; }; /** * Gets the day number (0-6) if given a CultureInfo specific string which is a valid dayName, abbreviatedDayName or shortestDayName (two char). * @param {String} The name of the day (eg. "Monday, "Mon", "tuesday", "tue", "We", "we"). * @return {Number} The day number */ $D.getDayNumberFromName = function (name) { var n = Date.CultureInfo.dayNames, m = Date.CultureInfo.abbreviatedDayNames, o = Date.CultureInfo.shortestDayNames, s = name.toLowerCase(); for (var i = 0; i < n.length; i++) { if (n[i].toLowerCase() === s || m[i].toLowerCase() === s || o[i].toLowerCase() === s) { return i; } } return -1; }; /** * Gets the month number (0-11) if given a Culture Info specific string which is a valid monthName or abbreviatedMonthName. * @param {String} The name of the month (eg. "February, "Feb", "october", "oct"). * @return {Number} The day number */ $D.getMonthNumberFromName = function (name) { var n = Date.CultureInfo.monthNames, m = Date.CultureInfo.abbreviatedMonthNames, s = name.toLowerCase(); for (var i = 0; i < n.length; i++) { if (n[i].toLowerCase() === s || m[i].toLowerCase() === s) { return i; } } return -1; }; /** * Gets the language appropriate month name when given the month number(0-11) * eg - 0 == January * @return {String} The month name */ $D.getMonthName = function (n) { return Date.CultureInfo.monthNames[n]; }; /** * Determines if the current date instance is within a LeapYear. * @param {Number} The year. * @return {Boolean} true if date is within a LeapYear, otherwise false. */ $D.isLeapYear = function (year) { return ((year % 4 === 0 && year % 100 !== 0) || year % 400 === 0); }; /** * Gets the number of days in the month, given a year and month value. Automatically corrects for LeapYear. * @param {Number} The year. * @param {Number} The month (0-11). * @return {Number} The number of days in the month. */ $D.getDaysInMonth = function (year, month) { if (!month && $D.validateMonth(year)) { month = year; year = Date.today().getFullYear(); } return [31, ($D.isLeapYear(year) ? 29 : 28), 31, 30, 31, 30, 31, 31, 30, 31, 30, 31][month]; }; $P.getDaysInMonth = function () { return $D.getDaysInMonth(this.getFullYear(), this.getMonth()); }; $D.getTimezoneAbbreviation = function (offset, dst) { var p, n = (dst || false) ? Date.CultureInfo.abbreviatedTimeZoneDST : Date.CultureInfo.abbreviatedTimeZoneStandard; for (p in n) { if (n.hasOwnProperty(p)) { if (n[p] === offset) { return p; } } } return null; }; $D.getTimezoneOffset = function (name, dst) { var i, a =[], z = Date.CultureInfo.timezones; if (!name) { name = (new Date()).getTimezone();} for (i = 0; i < z.length; i++) { if (z[i].name === name.toUpperCase()) { a.push(i); } } if (!z[a[0]]) { return null; } if (a.length === 1 || !dst) { return z[a[0]].offset; } else { for (i=0; i < a.length; i++) { if (z[a[i]].dst) { return z[a[i]].offset; } } } }; $D.getQuarter = function (d) { d = d || new Date(); // If no date supplied, use today var q = [1,2,3,4]; return q[Math.floor(d.getMonth() / 3)]; // ~~~ is a bitwise op. Faster than Math.floor }; $D.getDaysLeftInQuarter = function (d) { d = d || new Date(); var qEnd = new Date(d); qEnd.setMonth(qEnd.getMonth() + 3 - qEnd.getMonth() % 3, 0); return Math.floor((qEnd - d) / 8.64e7); }; // private var validate = function (n, min, max, name) { name = name ? name : "Object"; if (typeof n === "undefined") { return false; } else if (typeof n !== "number") { throw new TypeError(n + " is not a Number."); } else if (n < min || n > max) { // As failing validation is *not* an exceptional circumstance // lets not throw a RangeError Exception here. // It's semantically correct but it's not sensible. return false; } return true; }; /** * Validates the number is within an acceptable range for milliseconds [0-999]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateMillisecond = function (value) { return validate(value, 0, 999, "millisecond"); }; /** * Validates the number is within an acceptable range for seconds [0-59]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateSecond = function (value) { return validate(value, 0, 59, "second"); }; /** * Validates the number is within an acceptable range for minutes [0-59]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateMinute = function (value) { return validate(value, 0, 59, "minute"); }; /** * Validates the number is within an acceptable range for hours [0-23]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateHour = function (value) { return validate(value, 0, 23, "hour"); }; /** * Validates the number is within an acceptable range for the days in a month [0-MaxDaysInMonth]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateDay = function (value, year, month) { if (year === undefined || year === null || month === undefined || month === null) { return false;} return validate(value, 1, $D.getDaysInMonth(year, month), "day"); }; /** * Validates the number is within an acceptable range for months [0-11]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateWeek = function (value) { return validate(value, 0, 53, "week"); }; /** * Validates the number is within an acceptable range for months [0-11]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateMonth = function (value) { return validate(value, 0, 11, "month"); }; /** * Validates the number is within an acceptable range for years. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateYear = function (value) { /** * Per ECMAScript spec the range of times supported by Date objects is * exactly -100,000,000 days to +100,000,000 days measured relative to * midnight at the beginning of 01 January, 1970 UTC. * This gives a range of 8,640,000,000,000,000 milliseconds to either * side of 01 January, 1970 UTC. * * Earliest possible date: Tue, 20 Apr 271,822 B.C. 00:00:00 UTC * Latest possible date: Sat, 13 Sep 275,760 00:00:00 UTC */ return validate(value, -271822, 275760, "year"); }; $D.validateTimezone = function(value) { var timezones = {"ACDT":1,"ACST":1,"ACT":1,"ADT":1,"AEDT":1,"AEST":1,"AFT":1,"AKDT":1,"AKST":1,"AMST":1,"AMT":1,"ART":1,"AST":1,"AWDT":1,"AWST":1,"AZOST":1,"AZT":1,"BDT":1,"BIOT":1,"BIT":1,"BOT":1,"BRT":1,"BST":1,"BTT":1,"CAT":1,"CCT":1,"CDT":1,"CEDT":1,"CEST":1,"CET":1,"CHADT":1,"CHAST":1,"CHOT":1,"ChST":1,"CHUT":1,"CIST":1,"CIT":1,"CKT":1,"CLST":1,"CLT":1,"COST":1,"COT":1,"CST":1,"CT":1,"CVT":1,"CWST":1,"CXT":1,"DAVT":1,"DDUT":1,"DFT":1,"EASST":1,"EAST":1,"EAT":1,"ECT":1,"EDT":1,"EEDT":1,"EEST":1,"EET":1,"EGST":1,"EGT":1,"EIT":1,"EST":1,"FET":1,"FJT":1,"FKST":1,"FKT":1,"FNT":1,"GALT":1,"GAMT":1,"GET":1,"GFT":1,"GILT":1,"GIT":1,"GMT":1,"GST":1,"GYT":1,"HADT":1,"HAEC":1,"HAST":1,"HKT":1,"HMT":1,"HOVT":1,"HST":1,"ICT":1,"IDT":1,"IOT":1,"IRDT":1,"IRKT":1,"IRST":1,"IST":1,"JST":1,"KGT":1,"KOST":1,"KRAT":1,"KST":1,"LHST":1,"LINT":1,"MAGT":1,"MART":1,"MAWT":1,"MDT":1,"MET":1,"MEST":1,"MHT":1,"MIST":1,"MIT":1,"MMT":1,"MSK":1,"MST":1,"MUT":1,"MVT":1,"MYT":1,"NCT":1,"NDT":1,"NFT":1,"NPT":1,"NST":1,"NT":1,"NUT":1,"NZDT":1,"NZST":1,"OMST":1,"ORAT":1,"PDT":1,"PET":1,"PETT":1,"PGT":1,"PHOT":1,"PHT":1,"PKT":1,"PMDT":1,"PMST":1,"PONT":1,"PST":1,"PYST":1,"PYT":1,"RET":1,"ROTT":1,"SAKT":1,"SAMT":1,"SAST":1,"SBT":1,"SCT":1,"SGT":1,"SLST":1,"SRT":1,"SST":1,"SYOT":1,"TAHT":1,"THA":1,"TFT":1,"TJT":1,"TKT":1,"TLT":1,"TMT":1,"TOT":1,"TVT":1,"UCT":1,"ULAT":1,"UTC":1,"UYST":1,"UYT":1,"UZT":1,"VET":1,"VLAT":1,"VOLT":1,"VOST":1,"VUT":1,"WAKT":1,"WAST":1,"WAT":1,"WEDT":1,"WEST":1,"WET":1,"WST":1,"YAKT":1,"YEKT":1,"Z":1}; return (timezones[value] === 1); }; $D.validateTimezoneOffset= function(value) { // timezones go from +14hrs to -12hrs, the +X hours are negative offsets. return (value > -841 && value < 721); }; }()); (function () { var $D = Date, $P = $D.prototype, p = function (s, l) { if (!l) { l = 2; } return ("000" + s).slice(l * -1); }; var validateConfigObject = function (obj) { var result = {}, self = this, prop, testFunc; testFunc = function (prop, func, value) { if (prop === "day") { var month = (obj.month !== undefined) ? obj.month : self.getMonth(); var year = (obj.year !== undefined) ? obj.year : self.getFullYear(); return $D[func](value, year, month); } else { return $D[func](value); } }; for (prop in obj) { if (Object.prototype.hasOwnProperty.call(obj, prop)) { var func = "validate" + prop.charAt(0).toUpperCase() + prop.slice(1); if ($D[func] && obj[prop] !== null && testFunc(prop, func, obj[prop])) { result[prop] = obj[prop]; } } } return result; }; /** * Resets the time of this Date object to 12:00 AM (00:00), which is the start of the day. * @param {Boolean} .clone() this date instance before clearing Time * @return {Date} this */ $P.clearTime = function () { this.setHours(0); this.setMinutes(0); this.setSeconds(0); this.setMilliseconds(0); return this; }; /** * Resets the time of this Date object to the current time ('now'). * @return {Date} this */ $P.setTimeToNow = function () { var n = new Date(); this.setHours(n.getHours()); this.setMinutes(n.getMinutes()); this.setSeconds(n.getSeconds()); this.setMilliseconds(n.getMilliseconds()); return this; }; /** * Returns a new Date object that is an exact date and time copy of the original instance. * @return {Date} A new Date instance */ $P.clone = function () { return new Date(this.getTime()); }; /** * Compares this instance to a Date object and returns an number indication of their relative values. * @param {Date} Date object to compare [Required] * @return {Number} -1 = this is lessthan date. 0 = values are equal. 1 = this is greaterthan date. */ $P.compareTo = function (date) { return Date.compare(this, date); }; /** * Compares this instance to another Date object and returns true if they are equal. * @param {Date} Date object to compare. If no date to compare, new Date() [now] is used. * @return {Boolean} true if dates are equal. false if they are not equal. */ $P.equals = function (date) { return Date.equals(this, (date !== undefined ? date : new Date())); }; /** * Determines if this instance is between a range of two dates or equal to either the start or end dates. * @param {Date} Start of range [Required] * @param {Date} End of range [Required] * @return {Boolean} true is this is between or equal to the start and end dates, else false */ $P.between = function (start, end) { return this.getTime() >= start.getTime() && this.getTime() <= end.getTime(); }; /** * Determines if this date occurs after the date to compare to. * @param {Date} Date object to compare. If no date to compare, new Date() ("now") is used. * @return {Boolean} true if this date instance is greater than the date to compare to (or "now"), otherwise false. */ $P.isAfter = function (date) { return this.compareTo(date || new Date()) === 1; }; /** * Determines if this date occurs before the date to compare to. * @param {Date} Date object to compare. If no date to compare, new Date() ("now") is used. * @return {Boolean} true if this date instance is less than the date to compare to (or "now"). */ $P.isBefore = function (date) { return (this.compareTo(date || new Date()) === -1); }; /** * Determines if the current Date instance occurs today. * @return {Boolean} true if this date instance is 'today', otherwise false. */ /** * Determines if the current Date instance occurs on the same Date as the supplied 'date'. * If no 'date' to compare to is provided, the current Date instance is compared to 'today'. * @param {date} Date object to compare. If no date to compare, the current Date ("now") is used. * @return {Boolean} true if this Date instance occurs on the same Day as the supplied 'date'. */ $P.isToday = $P.isSameDay = function (date) { return this.clone().clearTime().equals((date || new Date()).clone().clearTime()); }; /** * Adds the specified number of milliseconds to this instance. * @param {Number} The number of milliseconds to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addMilliseconds = function (value) { if (!value) { return this; } this.setTime(this.getTime() + value * 1); return this; }; /** * Adds the specified number of seconds to this instance. * @param {Number} The number of seconds to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addSeconds = function (value) { if (!value) { return this; } return this.addMilliseconds(value * 1000); }; /** * Adds the specified number of seconds to this instance. * @param {Number} The number of seconds to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addMinutes = function (value) { if (!value) { return this; } return this.addMilliseconds(value * 60000); // 60*1000 }; /** * Adds the specified number of hours to this instance. * @param {Number} The number of hours to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addHours = function (value) { if (!value) { return this; } return this.addMilliseconds(value * 3600000); // 60*60*1000 }; /** * Adds the specified number of days to this instance. * @param {Number} The number of days to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addDays = function (value) { if (!value) { return this; } this.setDate(this.getDate() + value * 1); return this; }; /** * Adds the specified number of weekdays (ie - not sat or sun) to this instance. * @param {Number} The number of days to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addWeekdays = function (value) { if (!value) { return this; } var day = this.getDay(); var weeks = (Math.ceil(Math.abs(value)/7)); if (day === 0 || day === 6) { if (value > 0) { this.next().monday(); this.addDays(-1); day = this.getDay(); } } if (value < 0) { while (value < 0) { this.addDays(-1); day = this.getDay(); if (day !== 0 && day !== 6) { value++; } } return this; } else if (value > 5 || (6-day) <= value) { value = value + (weeks * 2); } return this.addDays(value); }; /** * Adds the specified number of weeks to this instance. * @param {Number} The number of weeks to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addWeeks = function (value) { if (!value) { return this; } return this.addDays(value * 7); }; /** * Adds the specified number of months to this instance. * @param {Number} The number of months to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addMonths = function (value) { if (!value) { return this; } var n = this.getDate(); this.setDate(1); this.setMonth(this.getMonth() + value * 1); this.setDate(Math.min(n, $D.getDaysInMonth(this.getFullYear(), this.getMonth()))); return this; }; $P.addQuarters = function (value) { if (!value) { return this; } // note this will take you to the same point in the quarter as you are now. // i.e. - if you are 15 days into the quarter you'll be 15 days into the resulting one. // bonus: this allows adding fractional quarters return this.addMonths(value * 3); }; /** * Adds the specified number of years to this instance. * @param {Number} The number of years to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addYears = function (value) { if (!value) { return this; } return this.addMonths(value * 12); }; /** * Adds (or subtracts) to the value of the years, months, weeks, days, hours, minutes, seconds, milliseconds of the date instance using given configuration object. Positive and Negative values allowed. * Example

	Date.today().add( { days: 1, months: 1 } )

	new Date().add( { years: -1 } )
	
* @param {Object} Configuration object containing attributes (months, days, etc.) * @return {Date} this */ $P.add = function (config) { if (typeof config === "number") { this._orient = config; return this; } var x = config; if (x.day) { // If we should be a different date than today (eg: for 'tomorrow -1d', etc). // Should only effect parsing, not direct usage (eg, Finish and FinishExact) if ((x.day - this.getDate()) !== 0) { this.setDate(x.day); } } if (x.milliseconds) { this.addMilliseconds(x.milliseconds); } if (x.seconds) { this.addSeconds(x.seconds); } if (x.minutes) { this.addMinutes(x.minutes); } if (x.hours) { this.addHours(x.hours); } if (x.weeks) { this.addWeeks(x.weeks); } if (x.months) { this.addMonths(x.months); } if (x.years) { this.addYears(x.years); } if (x.days) { this.addDays(x.days); } return this; }; /** * Get the week number. Week one (1) is the week which contains the first Thursday of the year. Monday is considered the first day of the week. * The .getWeek() function does NOT convert the date to UTC. The local datetime is used. * Please use .getISOWeek() to get the week of the UTC converted date. * @return {Number} 1 to 53 */ $P.getWeek = function (utc) { // Create a copy of this date object var self, target = new Date(this.valueOf()); if (utc) { target.addMinutes(target.getTimezoneOffset()); self = target.clone(); } else { self = this; } // ISO week date weeks start on monday // so correct the day number var dayNr = (self.getDay() + 6) % 7; // ISO 8601 states that week 1 is the week // with the first thursday of that year. // Set the target date to the thursday in the target week target.setDate(target.getDate() - dayNr + 3); // Store the millisecond value of the target date var firstThursday = target.valueOf(); // Set the target to the first thursday of the year // First set the target to january first target.setMonth(0, 1); // Not a thursday? Correct the date to the next thursday if (target.getDay() !== 4) { target.setMonth(0, 1 + ((4 - target.getDay()) + 7) % 7); } // The weeknumber is the number of weeks between the // first thursday of the year and the thursday in the target week return 1 + Math.ceil((firstThursday - target) / 604800000); // 604800000 = 7 * 24 * 3600 * 1000 }; /** * Get the ISO 8601 week number. Week one ("01") is the week which contains the first Thursday of the year. Monday is considered the first day of the week. * The .getISOWeek() function does convert the date to it's UTC value. Please use .getWeek() to get the week of the local date. * @return {String} "01" to "53" */ $P.getISOWeek = function () { return p(this.getWeek(true)); }; /** * Moves the date to Monday of the week set. Week one (1) is the week which contains the first Thursday of the year. * @param {Number} A Number (1 to 53) that represents the week of the year. * @return {Date} this */ $P.setWeek = function (n) { if ((n - this.getWeek()) === 0) { if (this.getDay() !== 1) { return this.moveToDayOfWeek(1, (this.getDay() > 1 ? -1 : 1)); } else { return this; } } else { return this.moveToDayOfWeek(1, (this.getDay() > 1 ? -1 : 1)).addWeeks(n - this.getWeek()); } }; $P.setQuarter = function (qtr) { var month = Math.abs(((qtr-1) * 3) + 1); return this.setMonth(month, 1); }; $P.getQuarter = function () { return Date.getQuarter(this); }; $P.getDaysLeftInQuarter = function () { return Date.getDaysLeftInQuarter(this); }; /** * Moves the date to the next n'th occurrence of the dayOfWeek starting from the beginning of the month. The number (-1) is a magic number and will return the last occurrence of the dayOfWeek in the month. * @param {Number} The dayOfWeek to move to * @param {Number} The n'th occurrence to move to. Use (-1) to return the last occurrence in the month * @return {Date} this */ $P.moveToNthOccurrence = function (dayOfWeek, occurrence) { if (dayOfWeek === "Weekday") { if (occurrence > 0) { this.moveToFirstDayOfMonth(); if (this.is().weekday()) { occurrence -= 1; } } else if (occurrence < 0) { this.moveToLastDayOfMonth(); if (this.is().weekday()) { occurrence += 1; } } else { return this; } return this.addWeekdays(occurrence); } var shift = 0; if (occurrence > 0) { shift = occurrence - 1; } else if (occurrence === -1) { this.moveToLastDayOfMonth(); if (this.getDay() !== dayOfWeek) { this.moveToDayOfWeek(dayOfWeek, -1); } return this; } return this.moveToFirstDayOfMonth().addDays(-1).moveToDayOfWeek(dayOfWeek, +1).addWeeks(shift); }; var moveToN = function (getFunc, addFunc, nVal) { return function (value, orient) { var diff = (value - this[getFunc]() + nVal * (orient || +1)) % nVal; return this[addFunc]((diff === 0) ? diff += nVal * (orient || +1) : diff); }; }; /** * Move to the next or last dayOfWeek based on the orient value. * @param {Number} The dayOfWeek to move to * @param {Number} Forward (+1) or Back (-1). Defaults to +1. [Optional] * @return {Date} this */ $P.moveToDayOfWeek = moveToN("getDay", "addDays", 7); /** * Move to the next or last month based on the orient value. * @param {Number} The month to move to. 0 = January, 11 = December * @param {Number} Forward (+1) or Back (-1). Defaults to +1. [Optional] * @return {Date} this */ $P.moveToMonth = moveToN("getMonth", "addMonths", 12); /** * Get the Ordinate of the current day ("th", "st", "rd"). * @return {String} */ $P.getOrdinate = function () { var num = this.getDate(); return ord(num); }; /** * Get the Ordinal day (numeric day number) of the year, adjusted for leap year. * @return {Number} 1 through 365 (366 in leap years) */ $P.getOrdinalNumber = function () { return Math.ceil((this.clone().clearTime() - new Date(this.getFullYear(), 0, 1)) / 86400000) + 1; }; /** * Get the time zone abbreviation of the current date. * @return {String} The abbreviated time zone name (e.g. "EST") */ $P.getTimezone = function () { return $D.getTimezoneAbbreviation(this.getUTCOffset(), this.isDaylightSavingTime()); }; $P.setTimezoneOffset = function (offset) { var here = this.getTimezoneOffset(), there = Number(offset) * -6 / 10; return (there || there === 0) ? this.addMinutes(there - here) : this; }; $P.setTimezone = function (offset) { return this.setTimezoneOffset($D.getTimezoneOffset(offset)); }; /** * Indicates whether Daylight Saving Time is observed in the current time zone. * @return {Boolean} true|false */ $P.hasDaylightSavingTime = function () { return (Date.today().set({month: 0, day: 1}).getTimezoneOffset() !== Date.today().set({month: 6, day: 1}).getTimezoneOffset()); }; /** * Indicates whether this Date instance is within the Daylight Saving Time range for the current time zone. * @return {Boolean} true|false */ $P.isDaylightSavingTime = function () { return Date.today().set({month: 0, day: 1}).getTimezoneOffset() !== this.getTimezoneOffset(); }; /** * Get the offset from UTC of the current date. * @return {String} The 4-character offset string prefixed with + or - (e.g. "-0500") */ $P.getUTCOffset = function (offset) { var n = (offset || this.getTimezoneOffset()) * -10 / 6, r; if (n < 0) { r = (n - 10000).toString(); return r.charAt(0) + r.substr(2); } else { r = (n + 10000).toString(); return "+" + r.substr(1); } }; /** * Returns the number of milliseconds between this date and date. * @param {Date} Defaults to now * @return {Number} The diff in milliseconds */ $P.getElapsed = function (date) { return (date || new Date()) - this; }; /** * Set the value of year, month, day, hour, minute, second, millisecond of date instance using given configuration object. * Example

	Date.today().set( { day: 20, month: 1 } )

	new Date().set( { millisecond: 0 } )
	
* * @param {Object} Configuration object containing attributes (month, day, etc.) * @return {Date} this */ $P.set = function (config) { config = validateConfigObject.call(this, config); var key; for (key in config) { if (Object.prototype.hasOwnProperty.call(config, key)) { var name = key.charAt(0).toUpperCase() + key.slice(1); var addFunc, getFunc; if (key !== "week" && key !== "month" && key !== "timezone" && key !== "timezoneOffset") { name += "s"; } addFunc = "add" + name; getFunc = "get" + name; if (key === "month") { addFunc = addFunc + "s"; } else if (key === "year"){ getFunc = "getFullYear"; } if (key !== "day" && key !== "timezone" && key !== "timezoneOffset" && key !== "week" && key !== "hour") { this[addFunc](config[key] - this[getFunc]()); } else if ( key === "timezone"|| key === "timezoneOffset" || key === "week" || key === "hour") { this["set"+name](config[key]); } } } // day has to go last because you can't validate the day without first knowing the month if (config.day) { this.addDays(config.day - this.getDate()); } return this; }; /** * Moves the date to the first day of the month. * @return {Date} this */ $P.moveToFirstDayOfMonth = function () { return this.set({ day: 1 }); }; /** * Moves the date to the last day of the month. * @return {Date} this */ $P.moveToLastDayOfMonth = function () { return this.set({ day: $D.getDaysInMonth(this.getFullYear(), this.getMonth())}); }; /** * Converts the value of the current Date object to its equivalent string representation. * Format Specifiers * CUSTOM DATE AND TIME FORMAT STRINGS * Format Description Example * ------ --------------------------------------------------------------------------- ----------------------- * s The seconds of the minute between 0-59. "0" to "59" * ss The seconds of the minute with leading zero if required. "00" to "59" * * m The minute of the hour between 0-59. "0" or "59" * mm The minute of the hour with leading zero if required. "00" or "59" * * h The hour of the day between 1-12. "1" to "12" * hh The hour of the day with leading zero if required. "01" to "12" * * H The hour of the day between 0-23. "0" to "23" * HH The hour of the day with leading zero if required. "00" to "23" * * d The day of the month between 1 and 31. "1" to "31" * dd The day of the month with leading zero if required. "01" to "31" * ddd Abbreviated day name. Date.CultureInfo.abbreviatedDayNames. "Mon" to "Sun" * dddd The full day name. Date.CultureInfo.dayNames. "Monday" to "Sunday" * * M The month of the year between 1-12. "1" to "12" * MM The month of the year with leading zero if required. "01" to "12" * MMM Abbreviated month name. Date.CultureInfo.abbreviatedMonthNames. "Jan" to "Dec" * MMMM The full month name. Date.CultureInfo.monthNames. "January" to "December" * * yy The year as a two-digit number. "99" or "08" * yyyy The full four digit year. "1999" or "2008" * * t Displays the first character of the A.M./P.M. designator. "A" or "P" * Date.CultureInfo.amDesignator or Date.CultureInfo.pmDesignator * tt Displays the A.M./P.M. designator. "AM" or "PM" * Date.CultureInfo.amDesignator or Date.CultureInfo.pmDesignator * * S The ordinal suffix ("st, "nd", "rd" or "th") of the current day. "st, "nd", "rd" or "th" * * STANDARD DATE AND TIME FORMAT STRINGS * Format Description Example *------ --------------------------------------------------------------------------- ----------------------- * d The CultureInfo shortDate Format Pattern "M/d/yyyy" * D The CultureInfo longDate Format Pattern "dddd, MMMM dd, yyyy" * F The CultureInfo fullDateTime Format Pattern "dddd, MMMM dd, yyyy h:mm:ss tt" * m The CultureInfo monthDay Format Pattern "MMMM dd" * r The CultureInfo rfc1123 Format Pattern "ddd, dd MMM yyyy HH:mm:ss GMT" * s The CultureInfo sortableDateTime Format Pattern "yyyy-MM-ddTHH:mm:ss" * t The CultureInfo shortTime Format Pattern "h:mm tt" * T The CultureInfo longTime Format Pattern "h:mm:ss tt" * u The CultureInfo universalSortableDateTime Format Pattern "yyyy-MM-dd HH:mm:ssZ" * y The CultureInfo yearMonth Format Pattern "MMMM, yyyy" * * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @return {String} A string representation of the current Date object. */ var ord = function (n) { switch (n * 1) { case 1: case 21: case 31: return "st"; case 2: case 22: return "nd"; case 3: case 23: return "rd"; default: return "th"; } }; var parseStandardFormats = function (format) { var y, c = Date.CultureInfo.formatPatterns; switch (format) { case "d": return this.toString(c.shortDate); case "D": return this.toString(c.longDate); case "F": return this.toString(c.fullDateTime); case "m": return this.toString(c.monthDay); case "r": case "R": y = this.clone().addMinutes(this.getTimezoneOffset()); return y.toString(c.rfc1123) + " GMT"; case "s": return this.toString(c.sortableDateTime); case "t": return this.toString(c.shortTime); case "T": return this.toString(c.longTime); case "u": y = this.clone().addMinutes(this.getTimezoneOffset()); return y.toString(c.universalSortableDateTime); case "y": return this.toString(c.yearMonth); default: return false; } }; var parseFormatStringsClosure = function (context) { return function (m) { if (m.charAt(0) === "\\") { return m.replace("\\", ""); } switch (m) { case "hh": return p(context.getHours() < 13 ? (context.getHours() === 0 ? 12 : context.getHours()) : (context.getHours() - 12)); case "h": return context.getHours() < 13 ? (context.getHours() === 0 ? 12 : context.getHours()) : (context.getHours() - 12); case "HH": return p(context.getHours()); case "H": return context.getHours(); case "mm": return p(context.getMinutes()); case "m": return context.getMinutes(); case "ss": return p(context.getSeconds()); case "s": return context.getSeconds(); case "yyyy": return p(context.getFullYear(), 4); case "yy": return p(context.getFullYear()); case "y": return context.getFullYear(); case "E": case "dddd": return Date.CultureInfo.dayNames[context.getDay()]; case "ddd": return Date.CultureInfo.abbreviatedDayNames[context.getDay()]; case "dd": return p(context.getDate()); case "d": return context.getDate(); case "MMMM": return Date.CultureInfo.monthNames[context.getMonth()]; case "MMM": return Date.CultureInfo.abbreviatedMonthNames[context.getMonth()]; case "MM": return p((context.getMonth() + 1)); case "M": return context.getMonth() + 1; case "t": return context.getHours() < 12 ? Date.CultureInfo.amDesignator.substring(0, 1) : Date.CultureInfo.pmDesignator.substring(0, 1); case "tt": return context.getHours() < 12 ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator; case "S": return ord(context.getDate()); case "W": return context.getWeek(); case "WW": return context.getISOWeek(); case "Q": return "Q" + context.getQuarter(); case "q": return String(context.getQuarter()); case "z": return context.getTimezone(); case "Z": case "X": return Date.getTimezoneOffset(context.getTimezone()); case "ZZ": // Timezone offset in seconds return context.getTimezoneOffset() * -60; case "u": return context.getDay(); case "L": return ($D.isLeapYear(context.getFullYear())) ? 1 : 0; case "B": // Swatch Internet Time (.beats) return "@"+((context.getUTCSeconds() + (context.getUTCMinutes()*60) + ((context.getUTCHours()+1)*3600))/86.4); default: return m; } }; }; $P.toString = function (format, ignoreStandards) { // Standard Date and Time Format Strings. Formats pulled from CultureInfo file and // may vary by culture. if (!ignoreStandards && format && format.length === 1) { output = parseStandardFormats.call(this, format); if (output) { return output; } } var parseFormatStrings = parseFormatStringsClosure(this); return format ? format.replace(/((\\)?(dd?d?d?|MM?M?M?|yy?y?y?|hh?|HH?|mm?|ss?|tt?|S|q|Q|WW?W?W?)(?![^\[]*\]))/g, parseFormatStrings).replace(/\[|\]/g, "") : this._toString(); }; }()); /************************************************************* * SugarPak - Domain Specific Language - Syntactical Sugar * *************************************************************/ (function () { var $D = Date, $P = $D.prototype, $N = Number.prototype; // private $P._orient = +1; // private $P._nth = null; // private $P._is = false; // private $P._same = false; // private $P._isSecond = false; // private $N._dateElement = "days"; /** * Moves the date to the next instance of a date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.today().next().friday();
	Date.today().next().fri();
	Date.today().next().march();
	Date.today().next().mar();
	Date.today().next().week();
	
* * @return {Date} date */ $P.next = function () { this._move = true; this._orient = +1; return this; }; /** * Creates a new Date (Date.today()) and moves the date to the next instance of the date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.next().friday();
	Date.next().fri();
	Date.next().march();
	Date.next().mar();
	Date.next().week();
	
* * @return {Date} date */ $D.next = function () { return $D.today().next(); }; /** * Moves the date to the previous instance of a date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.today().last().friday();
	Date.today().last().fri();
	Date.today().last().march();
	Date.today().last().mar();
	Date.today().last().week();
	
* * @return {Date} date */ $P.last = $P.prev = $P.previous = function () { this._move = true; this._orient = -1; return this; }; /** * Creates a new Date (Date.today()) and moves the date to the previous instance of the date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.last().friday();
	Date.last().fri();
	Date.previous().march();
	Date.prev().mar();
	Date.last().week();
	
* * @return {Date} date */ $D.last = $D.prev = $D.previous = function () { return $D.today().last(); }; /** * Performs a equality check when followed by either a month name, day name or .weekday() function. * Example

	Date.today().is().friday(); // true|false
	Date.today().is().fri();
	Date.today().is().march();
	Date.today().is().mar();
	
* * @return {Boolean} true|false */ $P.is = function () { this._is = true; return this; }; /** * Determines if two date objects occur on/in exactly the same instance of the subsequent date part function. * The function .same() must be followed by a date part function (example: .day(), .month(), .year(), etc). * * An optional Date can be passed in the date part function. If now date is passed as a parameter, 'Now' is used. * * The following example demonstrates how to determine if two dates fall on the exact same day. * * Example

	var d1 = Date.today(); // today at 00:00
	var d2 = new Date();   // exactly now.

	// Do they occur on the same day?
	d1.same().day(d2); // true
	
	// Do they occur on the same hour?
	d1.same().hour(d2); // false, unless d2 hour is '00' (midnight).
	
	// What if it's the same day, but one year apart?
	var nextYear = Date.today().add(1).year();

	d1.same().day(nextYear); // false, because the dates must occur on the exact same day. 
	
* * Scenario: Determine if a given date occurs during some week period 2 months from now. * * Example

	var future = Date.today().add(2).months();
	return someDate.same().week(future); // true|false;
	
* * @return {Boolean} true|false */ $P.same = function () { this._same = true; this._isSecond = false; return this; }; /** * Determines if the current date/time occurs during Today. Must be preceded by the .is() function. * Example

	someDate.is().today();    // true|false
	new Date().is().today();  // true
	Date.today().is().today();// true
	Date.today().add(-1).day().is().today(); // false
	
* * @return {Boolean} true|false */ $P.today = function () { return this.same().day(); }; /** * Determines if the current date is a weekday. This function must be preceded by the .is() function. * Example

	Date.today().is().weekday(); // true|false
	
* * @return {Boolean} true|false */ $P.weekday = function () { if (this._nth) { return df("Weekday").call(this); } if (this._move) { return this.addWeekdays(this._orient); } if (this._is) { this._is = false; return (!this.is().sat() && !this.is().sun()); } return false; }; /** * Determines if the current date is on the weekend. This function must be preceded by the .is() function. * Example

	Date.today().is().weekend(); // true|false
	
* * @return {Boolean} true|false */ $P.weekend = function () { if (this._is) { this._is = false; return (this.is().sat() || this.is().sun()); } return false; }; /** * Sets the Time of the current Date instance. A string "6:15 pm" or config object {hour:18, minute:15} are accepted. * Example

	// Set time to 6:15pm with a String
	Date.today().at("6:15pm");

	// Set time to 6:15pm with a config object
	Date.today().at({hour:18, minute:15});
	
* * @return {Date} date */ $P.at = function (time) { return (typeof time === "string") ? $D.parse(this.toString("d") + " " + time) : this.set(time); }; /** * Creates a new Date() and adds this (Number) to the date based on the preceding date element function (eg. second|minute|hour|day|month|year). * Example

	// Undeclared Numbers must be wrapped with parentheses. Requirment of JavaScript.
	(3).days().fromNow();
	(6).months().fromNow();

	// Declared Number variables do not require parentheses. 
	var n = 6;
	n.months().fromNow();
	
* * @return {Date} A new Date instance */ $N.fromNow = $N.after = function (date) { var c = {}; c[this._dateElement] = this; return ((!date) ? new Date() : date.clone()).add(c); }; /** * Creates a new Date() and subtract this (Number) from the date based on the preceding date element function (eg. second|minute|hour|day|month|year). * Example

	// Undeclared Numbers must be wrapped with parentheses. Requirment of JavaScript.
	(3).days().ago();
	(6).months().ago();

	// Declared Number variables do not require parentheses. 
	var n = 6;
	n.months().ago();
	
* * @return {Date} A new Date instance */ $N.ago = $N.before = function (date) { var c = {}, s = (this._dateElement[this._dateElement.length-1] !== "s") ? this._dateElement + "s" : this._dateElement; c[s] = this * -1; return ((!date) ? new Date() : date.clone()).add(c); }; // Do NOT modify the following string tokens. These tokens are used to build dynamic functions. // All culture-specific strings can be found in the CultureInfo files. var dx = ("sunday monday tuesday wednesday thursday friday saturday").split(/\s/), mx = ("january february march april may june july august september october november december").split(/\s/), px = ("Millisecond Second Minute Hour Day Week Month Year Quarter Weekday").split(/\s/), pxf = ("Milliseconds Seconds Minutes Hours Date Week Month FullYear Quarter").split(/\s/), nth = ("final first second third fourth fifth").split(/\s/), de; /** * Returns an object literal of all the date parts. * Example

	var o = new Date().toObject();
	
	// { year: 2008, month: 4, week: 20, day: 13, hour: 18, minute: 9, second: 32, millisecond: 812 }
	
	// The object properties can be referenced directly from the object.
	
	alert(o.day);  // alerts "13"
	alert(o.year); // alerts "2008"
	
* * @return {Date} An object literal representing the original date object. */ $P.toObject = function () { var o = {}; for (var i = 0; i < px.length; i++) { if (this["get" + pxf[i]]) { o[px[i].toLowerCase()] = this["get" + pxf[i]](); } } return o; }; /** * Returns a date created from an object literal. Ignores the .week property if set in the config. * Example

	var o = new Date().toObject();
	
	return Date.fromObject(o); // will return the same date. 

	var o2 = {month: 1, day: 20, hour: 18}; // birthday party!
	Date.fromObject(o2);
	
* * @return {Date} An object literal representing the original date object. */ $D.fromObject = function(config) { config.week = null; return Date.today().set(config); }; // Create day name functions and abbreviated day name functions (eg. monday(), friday(), fri()). var df = function (n) { return function () { if (this._is) { this._is = false; return this.getDay() === n; } if (this._move) { this._move = null; } if (this._nth !== null) { // If the .second() function was called earlier, remove the _orient // from the date, and then continue. // This is required because 'second' can be used in two different context. // // Example // // Date.today().add(1).second(); // Date.march().second().monday(); // // Things get crazy with the following... // Date.march().add(1).second().second().monday(); // but it works!! // if (this._isSecond) { this.addSeconds(this._orient * -1); } // make sure we reset _isSecond this._isSecond = false; var ntemp = this._nth; this._nth = null; var temp = this.clone().moveToLastDayOfMonth(); this.moveToNthOccurrence(n, ntemp); if (this > temp) { throw new RangeError($D.getDayName(n) + " does not occur " + ntemp + " times in the month of " + $D.getMonthName(temp.getMonth()) + " " + temp.getFullYear() + "."); } return this; } return this.moveToDayOfWeek(n, this._orient); }; }; var sdf = function (n) { return function () { var t = $D.today(), shift = n - t.getDay(); if (n === 0 && Date.CultureInfo.firstDayOfWeek === 1 && t.getDay() !== 0) { shift = shift + 7; } return t.addDays(shift); }; }; // Create month name functions and abbreviated month name functions (eg. january(), march(), mar()). var month_instance_functions = function (n) { return function () { if (this._is) { this._is = false; return this.getMonth() === n; } return this.moveToMonth(n, this._orient); }; }; var month_static_functions = function (n) { return function () { return $D.today().set({ month: n, day: 1 }); }; }; var processTerms = function (names, staticFunc, instanceFunc) { for (var i = 0; i < names.length; i++) { // Create constant static Name variables. $D[names[i].toUpperCase()] = $D[names[i].toUpperCase().substring(0, 3)] = i; // Create Name functions. $D[names[i]] = $D[names[i].substring(0, 3)] = staticFunc(i); // Create Name instance functions. $P[names[i]] = $P[names[i].substring(0, 3)] = instanceFunc(i); } }; processTerms(dx, sdf, df); processTerms(mx, month_static_functions, month_instance_functions); // Create date element functions and plural date element functions used with Date (eg. day(), days(), months()). var ef = function (j) { return function () { // if the .second() function was called earlier, the _orient // has alread been added. Just return this and reset _isSecond. if (this._isSecond) { this._isSecond = false; return this; } if (this._same) { this._same = this._is = false; var o1 = this.toObject(), o2 = (arguments[0] || new Date()).toObject(), v = "", k = j.toLowerCase(); // the substr trick with -1 doesn't work in IE8 or less k = (k[k.length-1] === "s") ? k.substring(0,k.length-1) : k; for (var m = (px.length - 1); m > -1; m--) { v = px[m].toLowerCase(); if (o1[v] !== o2[v]) { return false; } if (k === v) { break; } } return true; } if (j.substring(j.length - 1) !== "s") { j += "s"; } if (this._move) { this._move = null; } return this["add" + j](this._orient); }; }; var nf = function (n) { return function () { this._dateElement = n; return this; }; }; for (var k = 0; k < px.length; k++) { de = px[k].toLowerCase(); if(de !== "weekday") { // Create date element functions and plural date element functions used with Date (eg. day(), days(), months()). $P[de] = $P[de + "s"] = ef(px[k]); // Create date element functions and plural date element functions used with Number (eg. day(), days(), months()). $N[de] = $N[de + "s"] = nf(de + "s"); } } $P._ss = ef("Second"); var nthfn = function (n) { return function (dayOfWeek) { if (this._same) { return this._ss(arguments[0]); } if (dayOfWeek || dayOfWeek === 0) { return this.moveToNthOccurrence(dayOfWeek, n); } this._nth = n; // if the operator is 'second' add the _orient, then deal with it later... if (n === 2 && (dayOfWeek === undefined || dayOfWeek === null)) { this._isSecond = true; return this.addSeconds(this._orient); } return this; }; }; for (var l = 0; l < nth.length; l++) { $P[nth[l]] = (l === 0) ? nthfn(-1) : nthfn(l); } }()); (function () { "use strict"; Date.Parsing = { Exception: function (s) { this.message = "Parse error at '" + s.substring(0, 10) + " ...'"; } }; var $P = Date.Parsing; var dayOffsets = { standard: [0,31,59,90,120,151,181,212,243,273,304,334], leap: [0,31,60,91,121,152,182,213,244,274,305,335] }; $P.isLeapYear = function(year) { return ((year % 4 === 0) && (year % 100 !== 0)) || (year % 400 === 0); }; var utils = { multiReplace : function (str, hash ) { var key; for (key in hash) { if (Object.prototype.hasOwnProperty.call(hash, key)) { var regex; if (typeof hash[key] === "function") { } else { regex = (hash[key] instanceof RegExp) ? hash[key] : new RegExp(hash[key], "g"); } str = str.replace(regex, key); } } return str; }, getDayOfYearFromWeek : function (obj) { var d, jan4, offset; obj.weekDay = (!obj.weekDay && obj.weekDay !== 0) ? 1 : obj.weekDay; d = new Date(obj.year, 0, 4); jan4 = d.getDay() === 0 ? 7 : d.getDay(); // JS is 0 indexed on Sunday. offset = jan4+3; obj.dayOfYear = ((obj.week * 7) + (obj.weekDay === 0 ? 7 : obj.weekDay))-offset; return obj; }, getDayOfYear : function (obj, dayOffset) { if (!obj.dayOfYear) { obj = utils.getDayOfYearFromWeek(obj); } for (var i=0;i <= dayOffset.length;i++) { if (obj.dayOfYear < dayOffset[i] || i === dayOffset.length) { obj.day = obj.day ? obj.day : (obj.dayOfYear - dayOffset[i-1]); break; } else { obj.month = i; } } return obj; }, adjustForTimeZone : function (obj, date) { var offset; if (obj.zone.toUpperCase() === "Z" || (obj.zone_hours === 0 && obj.zone_minutes === 0)) { // it's UTC/GML so work out the current timeszone offset offset = -date.getTimezoneOffset(); } else { offset = (obj.zone_hours*60) + (obj.zone_minutes || 0); if (obj.zone_sign === "+") { offset *= -1; } offset -= date.getTimezoneOffset(); } date.setMinutes(date.getMinutes()+offset); return date; }, setDefaults : function (obj) { obj.year = obj.year || Date.today().getFullYear(); obj.hours = obj.hours || 0; obj.minutes = obj.minutes || 0; obj.seconds = obj.seconds || 0; obj.milliseconds = obj.milliseconds || 0; if (!(!obj.month && (obj.week || obj.dayOfYear))) { // if we have a month, or if we don't but don't have the day calculation data obj.month = obj.month || 0; obj.day = obj.day || 1; } return obj; }, dataNum: function (data, mod, explict, postProcess) { var dataNum = data*1; if (mod) { if (postProcess) { return data ? mod(data)*1 : data; } else { return data ? mod(dataNum) : data; } } else if (!explict){ return data ? dataNum : data; } else { return (data && typeof data !== "undefined") ? dataNum : data; } }, timeDataProcess: function (obj) { var timeObj = {}; for (var x in obj.data) { if (obj.data.hasOwnProperty(x)) { timeObj[x] = obj.ignore[x] ? obj.data[x] : utils.dataNum(obj.data[x], obj.mods[x], obj.explict[x], obj.postProcess[x]); } } if (obj.data.secmins) { obj.data.secmins = obj.data.secmins.replace(",", ".") * 60; if (!timeObj.minutes) { timeObj.minutes = obj.data.secmins; } else if (!timeObj.seconds) { timeObj.seconds = obj.data.secmins; } delete obj.secmins; } return timeObj; }, buildTimeObjectFromData: function (data) { var time = utils.timeDataProcess({ data: { year : data[1], month : data[5], day : data[7], week : data[8], dayOfYear : data[10], hours : data[15], zone_hours : data[23], zone_minutes : data[24], zone : data[21], zone_sign : data[22], weekDay : data[9], minutes: data[16], seconds: data[19], milliseconds: data[20], secmins: data[18] }, mods: { month: function(data) { return data-1; }, weekDay: function (data) { data = Math.abs(data); return (data === 7 ? 0 : data); }, minutes: function (data) { return data.replace(":",""); }, seconds: function (data) { return Math.floor( (data.replace(":","").replace(",","."))*1 ); }, milliseconds: function (data) { return (data.replace(",",".")*1000); } }, postProcess: { minutes: true, seconds: true, milliseconds: true }, explict: { zone_hours: true, zone_minutes: true }, ignore: { zone: true, zone_sign: true, secmins: true } }); return time; }, addToHash: function (hash, keys, data) { keys = keys; data = data; var len = keys.length; for (var i = 0; i < len; i++) { hash[keys[i]] = data[i]; } return hash; }, combineRegex: function (r1, r2) { return new RegExp("(("+r1.source+")\\s("+r2.source+"))"); }, getDateNthString: function(add, last, inc){ if (add) { return Date.today().addDays(inc).toString("d"); } else if (last) { return Date.today().last()[inc]().toString("d"); } }, buildRegexData: function (array) { var arr = []; var len = array.length; for (var i=0; i < len; i++) { if (Object.prototype.toString.call(array[i]) === '[object Array]') { // oldIE compat version of Array.isArray arr.push(this.combineRegex(array[i][0], array[i][1])); } else { arr.push(array[i]); } } return arr; } }; $P.processTimeObject = function (obj) { var date, dayOffset; utils.setDefaults(obj); dayOffset = ($P.isLeapYear(obj.year)) ? dayOffsets.leap : dayOffsets.standard; if (!obj.month && (obj.week || obj.dayOfYear)) { utils.getDayOfYear(obj, dayOffset); } else { obj.dayOfYear = dayOffset[obj.month] + obj.day; } date = new Date(obj.year, obj.month, obj.day, obj.hours, obj.minutes, obj.seconds, obj.milliseconds); if (obj.zone) { utils.adjustForTimeZone(obj, date); // adjust (and calculate) for timezone } return date; }; $P.ISO = { regex : /^([\+-]?\d{4}(?!\d{2}\b))((-?)((0[1-9]|1[0-2])(\3([12]\d|0[1-9]|3[01]))?|W([0-4]\d|5[0-3])(-?[1-7])?|(00[1-9]|0[1-9]\d|[12]\d{2}|3([0-5]\d|6[1-6])))([T\s]((([01]\d|2[0-4])((:?)[0-5]\d)?|24\:?00)([\.,]\d+(?!:))?)?(\17[0-5]\d([\.,]\d+)?)?\s?([zZ]|([\+-])([01]\d|2[0-3]):?([0-5]\d)?)?)?)?$/, parse : function (s) { var time, data = s.match(this.regex); if (!data || !data.length) { return null; } time = utils.buildTimeObjectFromData(data); if (!time.year || (!time.year && (!time.month && !time.day) && (!time.week && !time.dayOfYear)) ) { return null; } return $P.processTimeObject(time); } }; $P.Numeric = { isNumeric: function (e){return!isNaN(parseFloat(e))&&isFinite(e);}, regex: /\b([0-1]?[0-9])([0-3]?[0-9])([0-2]?[0-9]?[0-9][0-9])\b/i, parse: function (s) { var data, i, time = {}, order = Date.CultureInfo.dateElementOrder.split(""); if (!(this.isNumeric(s)) || // if it's non-numeric OR (s[0] === "+" && s[0] === "-")) { // It's an arithmatic string (eg +/-1000) return null; } if (s.length < 5 && s.indexOf(".") < 0 && s.indexOf("/") < 0) { // assume it's just a year. time.year = s; return $P.processTimeObject(time); } data = s.match(this.regex); if (!data || !data.length) { return null; } for (i=0; i < order.length; i++) { switch(order[i]) { case "d": time.day = data[i+1]; break; case "m": time.month = (data[i+1]-1); break; case "y": time.year = data[i+1]; break; } } return $P.processTimeObject(time); } }; $P.Normalizer = { regexData: function () { var $R = Date.CultureInfo.regexPatterns; return utils.buildRegexData([ $R.tomorrow, $R.yesterday, [$R.past, $R.mon], [$R.past, $R.tue], [$R.past, $R.wed], [$R.past, $R.thu], [$R.past, $R.fri], [$R.past, $R.sat], [$R.past, $R.sun] ]); }, basicReplaceHash : function() { var $R = Date.CultureInfo.regexPatterns; return { "January": $R.jan.source, "February": $R.feb, "March": $R.mar, "April": $R.apr, "May": $R.may, "June": $R.jun, "July": $R.jul, "August": $R.aug, "September": $R.sep, "October": $R.oct, "November": $R.nov, "December": $R.dec, "": /\bat\b/gi, " ": /\s{2,}/, "am": $R.inTheMorning, "9am": $R.thisMorning, "pm": $R.inTheEvening, "7pm":$R.thisEvening }; }, keys : function(){ return [ utils.getDateNthString(true, false, 1), // tomorrow utils.getDateNthString(true, false, -1), // yesterday utils.getDateNthString(false, true, "monday"), //last mon utils.getDateNthString(false, true, "tuesday"), //last tues utils.getDateNthString(false, true, "wednesday"), //last wed utils.getDateNthString(false, true, "thursday"), //last thurs utils.getDateNthString(false, true, "friday"), //last fri utils.getDateNthString(false, true, "saturday"), //last sat utils.getDateNthString(false, true, "sunday") //last sun ]; }, buildRegexFunctions: function () { var $R = Date.CultureInfo.regexPatterns; var __ = Date.i18n.__; var tomorrowRE = new RegExp("(\\b\\d\\d?("+__("AM")+"|"+__("PM")+")? )("+$R.tomorrow.source.slice(1)+")", "i"); // adapted tomorrow regex for AM PM relative dates var todayRE = new RegExp($R.today.source + "(?!\\s*([+-]))\\b"); // today, but excludes the math operators (eg "today + 2h") this.replaceFuncs = [ [todayRE, function (full) { return (full.length > 1) ? Date.today().toString("d") : full; }], [tomorrowRE, function(full, m1) { var t = Date.today().addDays(1).toString("d"); return (t + " " + m1); }], [$R.amThisMorning, function(str, am){return am;}], [$R.pmThisEvening, function(str, pm){return pm;}] ]; }, buildReplaceData: function () { this.buildRegexFunctions(); this.replaceHash = utils.addToHash(this.basicReplaceHash(), this.keys(), this.regexData()); }, stringReplaceFuncs: function (s) { for (var i=0; i < this.replaceFuncs.length; i++) { s = s.replace(this.replaceFuncs[i][0], this.replaceFuncs[i][1]); } return s; }, parse: function (s) { s = this.stringReplaceFuncs(s); s = utils.multiReplace(s, this.replaceHash); try { var n = s.split(/([\s\-\.\,\/\x27]+)/); if (n.length === 3 && $P.Numeric.isNumeric(n[0]) && $P.Numeric.isNumeric(n[2]) && (n[2].length >= 4)) { // ok, so we're dealing with x/year. But that's not a full date. // This fixes wonky dateElementOrder parsing when set to dmy order. if (Date.CultureInfo.dateElementOrder[0] === "d") { s = "1/" + n[0] + "/" + n[2]; // set to 1st of month and normalize the seperator } } } catch (e) {} return s; } }; $P.Normalizer.buildReplaceData(); }()); (function () { var $P = Date.Parsing; var _ = $P.Operators = { // // Tokenizers // rtoken: function (r) { // regex token return function (s) { var mx = s.match(r); if (mx) { return ([ mx[0], s.substring(mx[0].length) ]); } else { throw new $P.Exception(s); } }; }, token: function () { // whitespace-eating token return function (s) { return _.rtoken(new RegExp("^\\s*" + s + "\\s*"))(s); }; }, stoken: function (s) { // string token return _.rtoken(new RegExp("^" + s)); }, // Atomic Operators until: function (p) { return function (s) { var qx = [], rx = null; while (s.length) { try { rx = p.call(this, s); } catch (e) { qx.push(rx[0]); s = rx[1]; continue; } break; } return [ qx, s ]; }; }, many: function (p) { return function (s) { var rx = [], r = null; while (s.length) { try { r = p.call(this, s); } catch (e) { return [ rx, s ]; } rx.push(r[0]); s = r[1]; } return [ rx, s ]; }; }, // generator operators -- see below optional: function (p) { return function (s) { var r = null; try { r = p.call(this, s); } catch (e) { return [ null, s ]; } return [ r[0], r[1] ]; }; }, not: function (p) { return function (s) { try { p.call(this, s); } catch (e) { return [null, s]; } throw new $P.Exception(s); }; }, ignore: function (p) { return p ? function (s) { var r = null; r = p.call(this, s); return [null, r[1]]; } : null; }, product: function () { var px = arguments[0], qx = Array.prototype.slice.call(arguments, 1), rx = []; for (var i = 0 ; i < px.length ; i++) { rx.push(_.each(px[i], qx)); } return rx; }, cache: function (rule) { var cache = {}, cache_length = 0, cache_keys = [], CACHE_MAX = Date.Config.CACHE_MAX || 100000, r = null; var cacheCheck = function () { if (cache_length === CACHE_MAX) { // kill several keys, don't want to have to do this all the time... for (var i=0; i < 10; i++) { var key = cache_keys.shift(); if (key) { delete cache[key]; cache_length--; } } } }; return function (s) { cacheCheck(); try { r = cache[s] = (cache[s] || rule.call(this, s)); } catch (e) { r = cache[s] = e; } cache_length++; cache_keys.push(s); if (r instanceof $P.Exception) { throw r; } else { return r; } }; }, // vector operators -- see below any: function () { var px = arguments; return function (s) { var r = null; for (var i = 0; i < px.length; i++) { if (px[i] == null) { continue; } try { r = (px[i].call(this, s)); } catch (e) { r = null; } if (r) { return r; } } throw new $P.Exception(s); }; }, each: function () { var px = arguments; return function (s) { var rx = [], r = null; for (var i = 0; i < px.length ; i++) { if (px[i] == null) { continue; } try { r = (px[i].call(this, s)); } catch (e) { throw new $P.Exception(s); } rx.push(r[0]); s = r[1]; } return [ rx, s]; }; }, all: function () { var px = arguments, _ = _; return _.each(_.optional(px)); }, // delimited operators sequence: function (px, d, c) { d = d || _.rtoken(/^\s*/); c = c || null; if (px.length === 1) { return px[0]; } return function (s) { var r = null, q = null; var rx = []; for (var i = 0; i < px.length ; i++) { try { r = px[i].call(this, s); } catch (e) { break; } rx.push(r[0]); try { q = d.call(this, r[1]); } catch (ex) { q = null; break; } s = q[1]; } if (!r) { throw new $P.Exception(s); } if (q) { throw new $P.Exception(q[1]); } if (c) { try { r = c.call(this, r[1]); } catch (ey) { throw new $P.Exception(r[1]); } } return [ rx, (r?r[1]:s) ]; }; }, // // Composite Operators // between: function (d1, p, d2) { d2 = d2 || d1; var _fn = _.each(_.ignore(d1), p, _.ignore(d2)); return function (s) { var rx = _fn.call(this, s); return [[rx[0][0], r[0][2]], rx[1]]; }; }, list: function (p, d, c) { d = d || _.rtoken(/^\s*/); c = c || null; return (p instanceof Array ? _.each(_.product(p.slice(0, -1), _.ignore(d)), p.slice(-1), _.ignore(c)) : _.each(_.many(_.each(p, _.ignore(d))), px, _.ignore(c))); }, set: function (px, d, c) { d = d || _.rtoken(/^\s*/); c = c || null; return function (s) { // r is the current match, best the current 'best' match // which means it parsed the most amount of input var r = null, p = null, q = null, rx = null, best = [[], s], last = false; // go through the rules in the given set for (var i = 0; i < px.length ; i++) { // last is a flag indicating whether this must be the last element // if there is only 1 element, then it MUST be the last one q = null; p = null; r = null; last = (px.length === 1); // first, we try simply to match the current pattern // if not, try the next pattern try { r = px[i].call(this, s); } catch (e) { continue; } // since we are matching against a set of elements, the first // thing to do is to add r[0] to matched elements rx = [[r[0]], r[1]]; // if we matched and there is still input to parse and // we don't already know this is the last element, // we're going to next check for the delimiter ... // if there's none, or if there's no input left to parse // than this must be the last element after all ... if (r[1].length > 0 && ! last) { try { q = d.call(this, r[1]); } catch (ex) { last = true; } } else { last = true; } // if we parsed the delimiter and now there's no more input, // that means we shouldn't have parsed the delimiter at all // so don't update r and mark this as the last element ... if (!last && q[1].length === 0) { last = true; } // so, if this isn't the last element, we're going to see if // we can get any more matches from the remaining (unmatched) // elements ... if (!last) { // build a list of the remaining rules we can match against, // i.e., all but the one we just matched against var qx = []; for (var j = 0; j < px.length ; j++) { if (i !== j) { qx.push(px[j]); } } // now invoke recursively set with the remaining input // note that we don't include the closing delimiter ... // we'll check for that ourselves at the end p = _.set(qx, d).call(this, q[1]); // if we got a non-empty set as a result ... // (otw rx already contains everything we want to match) if (p[0].length > 0) { // update current result, which is stored in rx ... // basically, pick up the remaining text from p[1] // and concat the result from p[0] so that we don't // get endless nesting ... rx[0] = rx[0].concat(p[0]); rx[1] = p[1]; } } // at this point, rx either contains the last matched element // or the entire matched set that starts with this element. // now we just check to see if this variation is better than // our best so far, in terms of how much of the input is parsed if (rx[1].length < best[1].length) { best = rx; } // if we've parsed all the input, then we're finished if (best[1].length === 0) { break; } } // so now we've either gone through all the patterns trying them // as the initial match; or we found one that parsed the entire // input string ... // if best has no matches, just return empty set ... if (best[0].length === 0) { return best; } // if a closing delimiter is provided, then we have to check it also if (c) { // we try this even if there is no remaining input because the pattern // may well be optional or match empty input ... try { q = c.call(this, best[1]); } catch (ey) { throw new $P.Exception(best[1]); } // it parsed ... be sure to update the best match remaining input best[1] = q[1]; } // if we're here, either there was no closing delimiter or we parsed it // so now we have the best match; just return it! return best; }; }, forward: function (gr, fname) { return function (s) { return gr[fname].call(this, s); }; }, // // Translation Operators // replace: function (rule, repl) { return function (s) { var r = rule.call(this, s); return [repl, r[1]]; }; }, process: function (rule, fn) { return function (s) { var r = rule.call(this, s); return [fn.call(this, r[0]), r[1]]; }; }, min: function (min, rule) { return function (s) { var rx = rule.call(this, s); if (rx[0].length < min) { throw new $P.Exception(s); } return rx; }; } }; // Generator Operators And Vector Operators // Generators are operators that have a signature of F(R) => R, // taking a given rule and returning another rule, such as // ignore, which parses a given rule and throws away the result. // Vector operators are those that have a signature of F(R1,R2,...) => R, // take a list of rules and returning a new rule, such as each. // Generator operators are converted (via the following _generator // function) into functions that can also take a list or array of rules // and return an array of new rules as though the function had been // called on each rule in turn (which is what actually happens). // This allows generators to be used with vector operators more easily. // Example: // each(ignore(foo, bar)) instead of each(ignore(foo), ignore(bar)) // This also turns generators into vector operators, which allows // constructs like: // not(cache(foo, bar)) var _generator = function (op) { function gen() { var args = null, rx = [], px, i; if (arguments.length > 1) { args = Array.prototype.slice.call(arguments); } else if (arguments[0] instanceof Array) { args = arguments[0]; } if (args) { px = args.shift(); if (px.length > 0) { args.unshift(px[i]); rx.push(op.apply(null, args)); args.shift(); return rx; } } else { return op.apply(null, arguments); } } return gen; }; var gx = "optional not ignore cache".split(/\s/); for (var i = 0 ; i < gx.length ; i++) { _[gx[i]] = _generator(_[gx[i]]); } var _vector = function (op) { return function () { if (arguments[0] instanceof Array) { return op.apply(null, arguments[0]); } else { return op.apply(null, arguments); } }; }; var vx = "each any all".split(/\s/); for (var j = 0 ; j < vx.length ; j++) { _[vx[j]] = _vector(_[vx[j]]); } }()); (function () { var $D = Date; var flattenAndCompact = function (ax) { var rx = []; for (var i = 0; i < ax.length; i++) { if (ax[i] instanceof Array) { rx = rx.concat(flattenAndCompact(ax[i])); } else { if (ax[i]) { rx.push(ax[i]); } } } return rx; }; var parseMeridian = function () { if (this.meridian && (this.hour || this.hour === 0)) { if (this.meridian === "a" && this.hour > 11 && Date.Config.strict24hr){ throw "Invalid hour and meridian combination"; } else if (this.meridian === "p" && this.hour < 12 && Date.Config.strict24hr){ throw "Invalid hour and meridian combination"; } else if (this.meridian === "p" && this.hour < 12) { this.hour = this.hour + 12; } else if (this.meridian === "a" && this.hour === 12) { this.hour = 0; } } }; var setDefaults = function () { var now = new Date(); if ((this.hour || this.minute) && (!this.month && !this.year && !this.day)) { this.day = now.getDate(); } if (!this.year) { this.year = now.getFullYear(); } if (!this.month && this.month !== 0) { this.month = now.getMonth(); } if (!this.day) { this.day = 1; } if (!this.hour) { this.hour = 0; } if (!this.minute) { this.minute = 0; } if (!this.second) { this.second = 0; } if (!this.millisecond) { this.millisecond = 0; } }; var finishUtils = { getToday: function () { if (this.now || "hour minute second".indexOf(this.unit) !== -1) { return new Date(); } else { return $D.today(); } }, setDaysFromWeekday: function (today, orient){ var gap; orient = orient || 1; this.unit = "day"; gap = ($D.getDayNumberFromName(this.weekday) - today.getDay()); this.days = gap ? ((gap + (orient * 7)) % 7) : (orient * 7); return this; }, setMonthsFromMonth: function (today, orient) { var gap; orient = orient || 1; this.unit = "month"; gap = (this.month - today.getMonth()); this.months = gap ? ((gap + (orient * 12)) % 12) : (orient * 12); this.month = null; return this; }, setDMYFromWeekday: function () { var d = Date[this.weekday](); this.day = d.getDate(); if (!this.month) { this.month = d.getMonth(); } this.year = d.getFullYear(); return this; }, setUnitValue: function (orient) { if (!this.value && this.operator && this.operator !== null && this[this.unit + "s"] && this[this.unit + "s"] !== null) { this[this.unit + "s"] = this[this.unit + "s"] + ((this.operator === "add") ? 1 : -1) + (this.value||0) * orient; } else if (this[this.unit + "s"] == null || this.operator != null) { if (!this.value) { this.value = 1; } this[this.unit + "s"] = this.value * orient; } }, generateDateFromWeeks: function () { var weekday = (this.weekday !== undefined) ? this.weekday : "today"; var d = Date[weekday]().addWeeks(this.weeks); if (this.now) { d.setTimeToNow(); } return d; } }; $D.Translator = { hour: function (s) { return function () { this.hour = Number(s); }; }, minute: function (s) { return function () { this.minute = Number(s); }; }, second: function (s) { return function () { this.second = Number(s); }; }, /* for ss.s format */ secondAndMillisecond: function (s) { return function () { var mx = s.match(/^([0-5][0-9])\.([0-9]{1,3})/); this.second = Number(mx[1]); this.millisecond = Number(mx[2]); }; }, meridian: function (s) { return function () { this.meridian = s.slice(0, 1).toLowerCase(); }; }, timezone: function (s) { return function () { var n = s.replace(/[^\d\+\-]/g, ""); if (n.length) { this.timezoneOffset = Number(n); } else { this.timezone = s.toLowerCase(); } }; }, day: function (x) { var s = x[0]; return function () { this.day = Number(s.match(/\d+/)[0]); if (this.day < 1) { throw "invalid day"; } }; }, month: function (s) { return function () { this.month = (s.length === 3) ? "jan feb mar apr may jun jul aug sep oct nov dec".indexOf(s)/4 : Number(s) - 1; if (this.month < 0) { throw "invalid month"; } }; }, year: function (s) { return function () { var n = Number(s); this.year = ((s.length > 2) ? n : (n + (((n + 2000) < Date.CultureInfo.twoDigitYearMax) ? 2000 : 1900))); }; }, rday: function (s) { return function () { switch (s) { case "yesterday": this.days = -1; break; case "tomorrow": this.days = 1; break; case "today": this.days = 0; break; case "now": this.days = 0; this.now = true; break; } }; }, finishExact: function (x) { var d; x = (x instanceof Array) ? x : [x]; for (var i = 0 ; i < x.length ; i++) { if (x[i]) { x[i].call(this); } } setDefaults.call(this); parseMeridian.call(this); if (this.day > $D.getDaysInMonth(this.year, this.month)) { throw new RangeError(this.day + " is not a valid value for days."); } d = new Date(this.year, this.month, this.day, this.hour, this.minute, this.second, this.millisecond); if (this.year < 100) { d.setFullYear(this.year); // means years less that 100 are process correctly. JS will parse it otherwise as 1900-1999. } if (this.timezone) { d.set({ timezone: this.timezone }); } else if (this.timezoneOffset) { d.set({ timezoneOffset: this.timezoneOffset }); } return d; }, finish: function (x) { var today, expression, orient, temp; x = (x instanceof Array) ? flattenAndCompact(x) : [ x ]; if (x.length === 0) { return null; } for (var i = 0 ; i < x.length ; i++) { if (typeof x[i] === "function") { x[i].call(this); } } if (this.now && !this.unit && !this.operator) { return new Date(); } else { today = finishUtils.getToday.call(this); } expression = !!(this.days && this.days !== null || this.orient || this.operator); orient = ((this.orient === "past" || this.operator === "subtract") ? -1 : 1); if (this.month && this.unit === "week") { this.value = this.month + 1; delete this.month; delete this.day; } if ((this.month || this.month === 0) && "year day hour minute second".indexOf(this.unit) !== -1) { if (!this.value) { this.value = this.month + 1; } this.month = null; expression = true; } if (!expression && this.weekday && !this.day && !this.days) { finishUtils.setDMYFromWeekday.call(this); } if (expression && this.weekday && this.unit !== "month" && this.unit !== "week") { finishUtils.setDaysFromWeekday.call(this, today, orient); } if (this.weekday && this.unit !== "week" && !this.day && !this.days) { temp = Date[this.weekday](); this.day = temp.getDate(); if (temp.getMonth() !== today.getMonth()) { this.month = temp.getMonth(); } } if (this.month && this.unit === "day" && this.operator) { if (!this.value) { this.value = (this.month + 1); } this.month = null; } if (this.value != null && this.month != null && this.year != null) { this.day = this.value * 1; } if (this.month && !this.day && this.value) { today.set({ day: this.value * 1 }); if (!expression) { this.day = this.value * 1; } } if (!this.month && this.value && this.unit === "month" && !this.now) { this.month = this.value; expression = true; } if (expression && (this.month || this.month === 0) && this.unit !== "year") { finishUtils.setMonthsFromMonth.call(this, today, orient); } if (!this.unit) { this.unit = "day"; } finishUtils.setUnitValue.call(this, orient); parseMeridian.call(this); if ((this.month || this.month === 0) && !this.day) { this.day = 1; } if (!this.orient && !this.operator && this.unit === "week" && this.value && !this.day && !this.month) { return Date.today().setWeek(this.value); } if (this.unit === "week" && this.weeks && !this.day && !this.month) { return finishUtils.generateDateFromWeeks.call(this); } if (expression && this.timezone && this.day && this.days) { this.day = this.days; } if (expression){ today.add(this); } else { today.set(this); } if (this.timezone) { this.timezone = this.timezone.toUpperCase(); var offset = $D.getTimezoneOffset(this.timezone); var timezone; if (today.hasDaylightSavingTime()) { // lets check that we're being sane with timezone setting timezone = $D.getTimezoneAbbreviation(offset, today.isDaylightSavingTime()); if (timezone !== this.timezone) { // bugger, we're in a place where things like EST vs EDT matters. if (today.isDaylightSavingTime()) { today.addHours(-1); } else { today.addHours(1); } } } today.setTimezoneOffset(offset); } return today; } }; }()); (function () { var $D = Date; $D.Grammar = {}; var _ = $D.Parsing.Operators, g = $D.Grammar, t = $D.Translator, _fn; // Allow rolling up into general purpose rules _fn = function () { return _.each(_.any.apply(null, arguments), _.not(g.ctoken2("timeContext"))); }; g.datePartDelimiter = _.rtoken(/^([\s\-\.\,\/\x27]+)/); g.timePartDelimiter = _.stoken(":"); g.whiteSpace = _.rtoken(/^\s*/); g.generalDelimiter = _.rtoken(/^(([\s\,]|at|@|on)+)/); var _C = {}; g.ctoken = function (keys) { var fn = _C[keys]; if (! fn) { var c = Date.CultureInfo.regexPatterns; var kx = keys.split(/\s+/), px = []; for (var i = 0; i < kx.length ; i++) { px.push(_.replace(_.rtoken(c[kx[i]]), kx[i])); } fn = _C[keys] = _.any.apply(null, px); } return fn; }; g.ctoken2 = function (key) { return _.rtoken(Date.CultureInfo.regexPatterns[key]); }; var cacheProcessRtoken = function (key, token, type, eachToken) { if (eachToken) { g[key] = _.cache(_.process(_.each(_.rtoken(token),_.optional(g.ctoken2(eachToken))), type)); } else { g[key] = _.cache(_.process(_.rtoken(token), type)); } }; var cacheProcessCtoken = function (token, type) { return _.cache(_.process(g.ctoken2(token), type)); }; var _F = {}; //function cache var _get = function (f) { _F[f] = (_F[f] || g.format(f)[0]); return _F[f]; }; g.allformats = function (fx) { var rx = []; if (fx instanceof Array) { for (var i = 0; i < fx.length; i++) { rx.push(_get(fx[i])); } } else { rx.push(_get(fx)); } return rx; }; g.formats = function (fx) { if (fx instanceof Array) { var rx = []; for (var i = 0 ; i < fx.length ; i++) { rx.push(_get(fx[i])); } return _.any.apply(null, rx); } else { return _get(fx); } }; var grammarFormats = { timeFormats: function(){ var i, RTokenKeys = [ "h", "hh", "H", "HH", "m", "mm", "s", "ss", "ss.s", "z", "zz" ], RToken = [ /^(0[0-9]|1[0-2]|[1-9])/, /^(0[0-9]|1[0-2])/, /^([0-1][0-9]|2[0-3]|[0-9])/, /^([0-1][0-9]|2[0-3])/, /^([0-5][0-9]|[0-9])/, /^[0-5][0-9]/, /^([0-5][0-9]|[0-9])/, /^[0-5][0-9]/, /^[0-5][0-9]\.[0-9]{1,3}/, /^((\+|\-)\s*\d\d\d\d)|((\+|\-)\d\d\:?\d\d)/, /^((\+|\-)\s*\d\d\d\d)|((\+|\-)\d\d\:?\d\d)/ ], tokens = [ t.hour, t.hour, t.hour, t.hour, t.minute, t.minute, t.second, t.second, t.secondAndMillisecond, t.timezone, t.timezone ]; for (i=0; i < RTokenKeys.length; i++) { cacheProcessRtoken(RTokenKeys[i], RToken[i], tokens[i]); } g.hms = _.cache(_.sequence([g.H, g.m, g.s], g.timePartDelimiter)); g.t = cacheProcessCtoken("shortMeridian", t.meridian); g.tt = cacheProcessCtoken("longMeridian", t.meridian); g.zzz = cacheProcessCtoken("timezone", t.timezone); g.timeSuffix = _.each(_.ignore(g.whiteSpace), _.set([ g.tt, g.zzz ])); g.time = _.each(_.optional(_.ignore(_.stoken("T"))), g.hms, g.timeSuffix); }, dateFormats: function () { // pre-loaded rules for different date part order preferences var _setfn = function () { return _.set(arguments, g.datePartDelimiter); }; var i, RTokenKeys = [ "d", "dd", "M", "MM", "y", "yy", "yyy", "yyyy" ], RToken = [ /^([0-2]\d|3[0-1]|\d)/, /^([0-2]\d|3[0-1])/, /^(1[0-2]|0\d|\d)/, /^(1[0-2]|0\d)/, /^(\d+)/, /^(\d\d)/, /^(\d\d?\d?\d?)/, /^(\d\d\d\d)/ ], tokens = [ t.day, t.day, t.month, t.month, t.year, t.year, t.year, t.year ], eachToken = [ "ordinalSuffix", "ordinalSuffix" ]; for (i=0; i < RTokenKeys.length; i++) { cacheProcessRtoken(RTokenKeys[i], RToken[i], tokens[i], eachToken[i]); } g.MMM = g.MMMM = _.cache(_.process(g.ctoken("jan feb mar apr may jun jul aug sep oct nov dec"), t.month)); g.ddd = g.dddd = _.cache(_.process(g.ctoken("sun mon tue wed thu fri sat"), function (s) { return function () { this.weekday = s; }; } )); g.day = _fn(g.d, g.dd); g.month = _fn(g.M, g.MMM); g.year = _fn(g.yyyy, g.yy); g.mdy = _setfn(g.ddd, g.month, g.day, g.year); g.ymd = _setfn(g.ddd, g.year, g.month, g.day); g.dmy = _setfn(g.ddd, g.day, g.month, g.year); g.date = function (s) { return ((g[Date.CultureInfo.dateElementOrder] || g.mdy).call(this, s)); }; }, relative: function () { // relative date / time expressions g.orientation = _.process(g.ctoken("past future"), function (s) { return function () { this.orient = s; }; } ); g.operator = _.process(g.ctoken("add subtract"), function (s) { return function () { this.operator = s; }; } ); g.rday = _.process(g.ctoken("yesterday tomorrow today now"), t.rday); g.unit = _.process(g.ctoken("second minute hour day week month year"), function (s) { return function () { this.unit = s; }; } ); } }; g.buildGrammarFormats = function () { // these need to be rebuilt every time the language changes. _C = {}; grammarFormats.timeFormats(); grammarFormats.dateFormats(); grammarFormats.relative(); g.value = _.process(_.rtoken(/^([-+]?\d+)?(st|nd|rd|th)?/), function (s) { return function () { this.value = s.replace(/\D/g, ""); }; } ); g.expression = _.set([g.rday, g.operator, g.value, g.unit, g.orientation, g.ddd, g.MMM ]); g.format = _.process(_.many( _.any( // translate format specifiers into grammar rules _.process( _.rtoken(/^(dd?d?d?(?!e)|MM?M?M?|yy?y?y?|hh?|HH?|mm?|ss?|tt?|zz?z?)/), function (fmt) { if (g[fmt]) { return g[fmt]; } else { throw $D.Parsing.Exception(fmt); } } ), // translate separator tokens into token rules _.process(_.rtoken(/^[^dMyhHmstz]+/), // all legal separators function (s) { return _.ignore(_.stoken(s)); } ) ) ), // construct the parser ... function (rules) { return _.process(_.each.apply(null, rules), t.finishExact); } ); // starting rule for general purpose grammar g._start = _.process(_.set([ g.date, g.time, g.expression ], g.generalDelimiter, g.whiteSpace), t.finish); }; g.buildGrammarFormats(); // parsing date format specifiers - ex: "h:m:s tt" // this little guy will generate a custom parser based // on the format string, ex: g.format("h:m:s tt") // check for these formats first g._formats = g.formats([ "\"yyyy-MM-ddTHH:mm:ssZ\"", "yyyy-MM-ddTHH:mm:ss.sz", "yyyy-MM-ddTHH:mm:ssZ", "yyyy-MM-ddTHH:mm:ssz", "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-ddTHH:mmZ", "yyyy-MM-ddTHH:mmz", "yyyy-MM-ddTHH:mm", "ddd, MMM dd, yyyy H:mm:ss tt", "ddd MMM d yyyy HH:mm:ss zzz", "MMddyyyy", "ddMMyyyy", "Mddyyyy", "ddMyyyy", "Mdyyyy", "dMyyyy", "yyyy", "Mdyy", "dMyy", "d" ]); // real starting rule: tries selected formats first, // then general purpose rule g.start = function (s) { try { var r = g._formats.call({}, s); if (r[1].length === 0) { return r; } } catch (e) {} return g._start.call({}, s); }; }()); (function () { var $D = Date; /** * @desc Converts the specified string value into its JavaScript Date equivalent using CultureInfo specific format information. * * Example

	///////////
	// Dates //
	///////////

	// 15-Oct-2004
	var d1 = Date.parse("10/15/2004");

	// 15-Oct-2004
	var d1 = Date.parse("15-Oct-2004");

	// 15-Oct-2004
	var d1 = Date.parse("2004.10.15");

	//Fri Oct 15, 2004
	var d1 = Date.parse("Fri Oct 15, 2004");

	///////////
	// Times //
	///////////

	// Today at 10 PM.
	var d1 = Date.parse("10 PM");

	// Today at 10:30 PM.
	var d1 = Date.parse("10:30 P.M.");

	// Today at 6 AM.
	var d1 = Date.parse("06am");

	/////////////////////
	// Dates and Times //
	/////////////////////

	// 8-July-2004 @ 10:30 PM
	var d1 = Date.parse("July 8th, 2004, 10:30 PM");

	// 1-July-2004 @ 10:30 PM
	var d1 = Date.parse("2004-07-01T22:30:00");

	////////////////////
	// Relative Dates //
	////////////////////

	// Returns today's date. The string "today" is culture specific.
	var d1 = Date.parse("today");

	// Returns yesterday's date. The string "yesterday" is culture specific.
	var d1 = Date.parse("yesterday");

	// Returns the date of the next thursday.
	var d1 = Date.parse("Next thursday");

	// Returns the date of the most previous monday.
	var d1 = Date.parse("last monday");

	// Returns today's day + one year.
	var d1 = Date.parse("next year");

	///////////////
	// Date Math //
	///////////////

	// Today + 2 days
	var d1 = Date.parse("t+2");

	// Today + 2 days
	var d1 = Date.parse("today + 2 days");

	// Today + 3 months
	var d1 = Date.parse("t+3m");

	// Today - 1 year
	var d1 = Date.parse("today - 1 year");

	// Today - 1 year
	var d1 = Date.parse("t-1y"); 


	/////////////////////////////
	// Partial Dates and Times //
	/////////////////////////////

	// July 15th of this year.
	var d1 = Date.parse("July 15");

	// 15th day of current day and year.
	var d1 = Date.parse("15");

	// July 1st of current year at 10pm.
	var d1 = Date.parse("7/1 10pm");
	
* * @param {String} The string value to convert into a Date object [Required] * @return {Date} A Date object or null if the string cannot be converted into a Date. */ var parseUtils = { removeOrds: function (s) { ords = s.match(/\b(\d+)(?:st|nd|rd|th)\b/); // find ordinal matches s = ((ords && ords.length === 2) ? s.replace(ords[0], ords[1]) : s); return s; }, grammarParser: function (s) { var r = null; try { r = $D.Grammar.start.call({}, s.replace(/^\s*(\S*(\s+\S+)*)\s*$/, "$1")); } catch (e) { return null; } return ((r[1].length === 0) ? r[0] : null); }, nativeFallback: function(s) { var t; try { // ok we haven't parsed it, last ditch attempt with the built-in parser. t = Date._parse(s); return (t || t === 0) ? new Date(t) : null; } catch (e) { return null; } } }; function parse (s) { var d; if (!s) { return null; } if (s instanceof Date) { return s.clone(); } if (s.length >= 4 && s.charAt(0) !== "0" && s.charAt(0) !== "+"&& s.charAt(0) !== "-") { // ie: 2004 will pass, 0800 won't. // Start with specific formats d = $D.Parsing.ISO.parse(s) || $D.Parsing.Numeric.parse(s); } if (d instanceof Date && !isNaN(d.getTime())) { return d; } else { // find ordinal dates (1st, 3rd, 8th, etc and remove them as they cause parsing issues) s = $D.Parsing.Normalizer.parse(parseUtils.removeOrds(s)); d = parseUtils.grammarParser(s); if (d !== null) { return d; } else { return parseUtils.nativeFallback(s); } } } if (!$D._parse) { $D._parse = $D.parse; } $D.parse = parse; Date.getParseFunction = function (fx) { var fns = Date.Grammar.allformats(fx); return function (s) { var r = null; for (var i = 0; i < fns.length; i++) { try { r = fns[i].call({}, s); } catch (e) { continue; } if (r[1].length === 0) { return r[0]; } } return null; }; }; /** * Converts the specified string value into its JavaScript Date equivalent using the specified format {String} or formats {Array} and the CultureInfo specific format information. * The format of the string value must match one of the supplied formats exactly. * * Example

	// 15-Oct-2004
	var d1 = Date.parseExact("10/15/2004", "M/d/yyyy");

	// 15-Oct-2004
	var d1 = Date.parse("15-Oct-2004", "M-ddd-yyyy");

	// 15-Oct-2004
	var d1 = Date.parse("2004.10.15", "yyyy.MM.dd");

	// Multiple formats
	var d1 = Date.parseExact("10/15/2004", ["M/d/yyyy", "MMMM d, yyyy"]);
	
* * @param {String} The string value to convert into a Date object [Required]. * @param {Object} The expected format {String} or an array of expected formats {Array} of the date string [Required]. * @return {Date} A Date object or null if the string cannot be converted into a Date. */ $D.parseExact = function (s, fx) { return $D.getParseFunction(fx)(s); }; }()); (function () { var $D = Date, $P = $D.prototype, // $C = $D.CultureInfo, // not used atm p = function (s, l) { if (!l) { l = 2; } return ("000" + s).slice(l * -1); }; /** * Converts a PHP format string to Java/.NET format string. * A PHP format string can be used with ._format or .format. * A Java/.NET format string can be used with .toString(). * The .parseExact function will only accept a Java/.NET format string * * Example * var f1 = "%m/%d/%y" * var f2 = Date.normalizeFormat(f1); // "MM/dd/yy" * * new Date().format(f1); // "04/13/08" * new Date()._format(f1); // "04/13/08" * new Date().toString(f2); // "04/13/08" * * var date = Date.parseExact("04/13/08", f2); // Sun Apr 13 2008 * * @param {String} A PHP format string consisting of one or more format spcifiers. * @return {String} The PHP format converted to a Java/.NET format string. */ var normalizerSubstitutions = { "d" : "dd", "%d": "dd", "D" : "ddd", "%a": "ddd", "j" : "dddd", "l" : "dddd", "%A": "dddd", "S" : "S", "F" : "MMMM", "%B": "MMMM", "m" : "MM", "%m": "MM", "M" : "MMM", "%b": "MMM", "%h": "MMM", "n" : "M", "Y" : "yyyy", "%Y": "yyyy", "y" : "yy", "%y": "yy", "g" : "h", "%I": "h", "G" : "H", "h" : "hh", "H" : "HH", "%H": "HH", "i" : "mm", "%M": "mm", "s" : "ss", "%S": "ss", "%r": "hh:mm tt", "%R": "H:mm", "%T": "H:mm:ss", "%X": "t", "%x": "d", "%e": "d", "%D": "MM/dd/yy", "%n": "\\n", "%t": "\\t", "e" : "z", "T" : "z", "%z": "z", "%Z": "z", "Z" : "ZZ", "N" : "u", "w" : "u", "%w": "u", "W" : "W", "%V": "W" }; var normalizer = { substitutes: function (m) { return normalizerSubstitutions[m]; }, interpreted: function (m, x) { var y; switch (m) { case "%u": return x.getDay() + 1; case "z": return x.getOrdinalNumber(); case "%j": return p(x.getOrdinalNumber(), 3); case "%U": var d1 = x.clone().set({month: 0, day: 1}).addDays(-1).moveToDayOfWeek(0), d2 = x.clone().addDays(1).moveToDayOfWeek(0, -1); return (d2 < d1) ? "00" : p((d2.getOrdinalNumber() - d1.getOrdinalNumber()) / 7 + 1); case "%W": return p(x.getWeek()); case "t": return $D.getDaysInMonth(x.getFullYear(), x.getMonth()); case "o": case "%G": return x.setWeek(x.getISOWeek()).toString("yyyy"); case "%g": return x._format("%G").slice(-2); case "a": case "%p": return t("tt").toLowerCase(); case "A": return t("tt").toUpperCase(); case "u": return p(x.getMilliseconds(), 3); case "I": return (x.isDaylightSavingTime()) ? 1 : 0; case "O": return x.getUTCOffset(); case "P": y = x.getUTCOffset(); return y.substring(0, y.length - 2) + ":" + y.substring(y.length - 2); case "B": var now = new Date(); return Math.floor(((now.getHours() * 3600) + (now.getMinutes() * 60) + now.getSeconds() + (now.getTimezoneOffset() + 60) * 60) / 86.4); case "c": return x.toISOString().replace(/\"/g, ""); case "U": return $D.strtotime("now"); case "%c": return t("d") + " " + t("t"); case "%C": return Math.floor(x.getFullYear() / 100 + 1); } }, shouldOverrideDefaults: function (m) { switch (m) { case "%e": return true; default: return false; } }, parse: function (m, context) { var formatString, c = context || new Date(); formatString = normalizer.substitutes(m); if (formatString) { return formatString; } formatString = normalizer.interpreted(m, c); if (formatString) { return formatString; } else { return m; } } }; $D.normalizeFormat = function (format, context) { return format.replace(/(%|\\)?.|%%/g, function(t){ return normalizer.parse(t, context); }); }; /** * Format a local Unix timestamp according to locale settings * * Example: * Date.strftime("%m/%d/%y", new Date()); // "04/13/08" * Date.strftime("c", "2008-04-13T17:52:03Z"); // "04/13/08" * * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @param {Number|String} The number representing the number of seconds that have elapsed since January 1, 1970 (local time). * @return {String} A string representation of the current Date object. */ $D.strftime = function (format, time) { var d = Date.parse(time); return d._format(format); }; /** * Parse any textual datetime description into a Unix timestamp. * A Unix timestamp is the number of seconds that have elapsed since January 1, 1970 (midnight UTC/GMT). * * Example: * Date.strtotime("04/13/08"); // 1208044800 * Date.strtotime("1970-01-01T00:00:00Z"); // 0 * * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @param {Object} A string or date object. * @return {String} A string representation of the current Date object. */ $D.strtotime = function (time) { var d = $D.parse(time); return Math.round($D.UTC(d.getUTCFullYear(), d.getUTCMonth(), d.getUTCDate(), d.getUTCHours(), d.getUTCMinutes(), d.getUTCSeconds(), d.getUTCMilliseconds()) / 1000); }; /** * Converts the value of the current Date object to its equivalent string representation using a PHP/Unix style of date format specifiers. * Format Specifiers * Format Description Example * ------ --------------------------------------------------------------------------- ----------------------- * %a abbreviated weekday name according to the current localed "Mon" through "Sun" * %A full weekday name according to the current localed "Sunday" through "Saturday" * %b abbreviated month name according to the current localed "Jan" through "Dec" * %B full month name according to the current locale "January" through "December" * %c preferred date and time representation for the current locale "4/13/2008 12:33 PM" * %C century number (the year divided by 100 and truncated to an integer) "00" to "99" * %d day of the month as a decimal number "01" to "31" * %D same as %m/%d/%y "04/13/08" * %e day of the month as a decimal number, a single digit is preceded by a space "1" to "31" * %g like %G, but without the century "08" * %G The 4-digit year corresponding to the ISO week number (see %V). "2008" * This has the same format and value as %Y, except that if the ISO week number * belongs to the previous or next year, that year is used instead. * %h same as %b "Jan" through "Dec" * %H hour as a decimal number using a 24-hour clock. "00" to "23" * %I hour as a decimal number using a 12-hour clock. "01" to "12" * %j day of the year as a decimal number. "001" to "366" * %m month as a decimal number. "01" to "12" * %M minute as a decimal number. "00" to "59" * %n newline character "\n" * %p either "am" or "pm" according to the given time value, or the "am" or "pm" * corresponding strings for the current locale. * %r time in a.m. and p.m. notation "8:44 PM" * %R time in 24 hour notation "20:44" * %S second as a decimal number "00" to "59" * %t tab character "\t" * %T current time, equal to %H:%M:%S "12:49:11" * %u weekday as a decimal number ["1", "7"], with "1" representing Monday "1" to "7" * %U week number of the current year as a decimal number, starting with the "0" to ("52" or "53") * first Sunday as the first day of the first week * %V The ISO 8601:1988 week number of the current year as a decimal number, "00" to ("52" or "53") * range 01 to 53, where week 1 is the first week that has at least 4 days * in the current year, and with Monday as the first day of the week. * (Use %G or %g for the year component that corresponds to the week number * for the specified timestamp.) * %W week number of the current year as a decimal number, starting with the "00" to ("52" or "53") * first Monday as the first day of the first week * %w day of the week as a decimal, Sunday being "0" "0" to "6" * %x preferred date representation for the current locale without the time "4/13/2008" * %X preferred time representation for the current locale without the date "12:53:05" * %y year as a decimal number without a century "00" "99" * %Y year as a decimal number including the century "2008" * %Z time zone or name or abbreviation "UTC", "EST", "PST" * %z same as %Z * %% a literal "%" characters "%" * d Day of the month, 2 digits with leading zeros "01" to "31" * D A textual representation of a day, three letters "Mon" through "Sun" * j Day of the month without leading zeros "1" to "31" * l A full textual representation of the day of the week (lowercase "L") "Sunday" through "Saturday" * N ISO-8601 numeric representation of the day of the week (added in PHP 5.1.0) "1" (for Monday) through "7" (for Sunday) * S English ordinal suffix for the day of the month, 2 characters "st", "nd", "rd" or "th". Works well with j * w Numeric representation of the day of the week "0" (for Sunday) through "6" (for Saturday) * z The day of the year (starting from "0") "0" through "365" * W ISO-8601 week number of year, weeks starting on Monday "00" to ("52" or "53") * F A full textual representation of a month, such as January or March "January" through "December" * m Numeric representation of a month, with leading zeros "01" through "12" * M A short textual representation of a month, three letters "Jan" through "Dec" * n Numeric representation of a month, without leading zeros "1" through "12" * t Number of days in the given month "28" through "31" * L Whether it's a leap year "1" if it is a leap year, "0" otherwise * o ISO-8601 year number. This has the same value as Y, except that if the "2008" * ISO week number (W) belongs to the previous or next year, that year * is used instead. * Y A full numeric representation of a year, 4 digits "2008" * y A two digit representation of a year "08" * a Lowercase Ante meridiem and Post meridiem "am" or "pm" * A Uppercase Ante meridiem and Post meridiem "AM" or "PM" * B Swatch Internet time "000" through "999" * g 12-hour format of an hour without leading zeros "1" through "12" * G 24-hour format of an hour without leading zeros "0" through "23" * h 12-hour format of an hour with leading zeros "01" through "12" * H 24-hour format of an hour with leading zeros "00" through "23" * i Minutes with leading zeros "00" to "59" * s Seconds, with leading zeros "00" through "59" * u Milliseconds "54321" * e Timezone identifier "UTC", "EST", "PST" * I Whether or not the date is in daylight saving time (uppercase i) "1" if Daylight Saving Time, "0" otherwise * O Difference to Greenwich time (GMT) in hours "+0200", "-0600" * P Difference to Greenwich time (GMT) with colon between hours and minutes "+02:00", "-06:00" * T Timezone abbreviation "UTC", "EST", "PST" * Z Timezone offset in seconds. The offset for timezones west of UTC is "-43200" through "50400" * always negative, and for those east of UTC is always positive. * c ISO 8601 date "2004-02-12T15:19:21+00:00" * r RFC 2822 formatted date "Thu, 21 Dec 2000 16:01:07 +0200" * U Seconds since the Unix Epoch (January 1 1970 00:00:00 GMT) "0" * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @return {String} A string representation of the current Date object. */ var formatReplace = function (context) { return function (m) { var formatString, override = false; if (m.charAt(0) === "\\" || m.substring(0, 2) === "%%") { return m.replace("\\", "").replace("%%", "%"); } override = normalizer.shouldOverrideDefaults(m); formatString = $D.normalizeFormat(m, context); if (formatString) { return context.toString(formatString, override); } }; }; $P._format = function (format) { var formatter = formatReplace(this); if (!format) { return this._toString(); } else { return format.replace(/(%|\\)?.|%%/g, formatter); } }; if (!$P.format) { $P.format = $P._format; } }()); (function () { "use strict"; var gFn = function (attr) { return function () { return this[attr]; }; }; var sFn = function (attr) { return function (val) { this[attr] = val; return this; }; }; var attrs = ["years", "months", "days", "hours", "minutes", "seconds", "milliseconds"]; var addSetFuncs = function (context, attrs) { for (var i = 0; i < attrs.length ; i++) { var $a = attrs[i], $b = $a.slice(0, 1).toUpperCase() + $a.slice(1); context.prototype[$a] = 0; context.prototype["get" + $b] = gFn($a); context.prototype["set" + $b] = sFn($a); } }; /** * new TimeSpan(milliseconds); * new TimeSpan(days, hours, minutes, seconds); * new TimeSpan(days, hours, minutes, seconds, milliseconds); */ var TimeSpan = function (days, hours, minutes, seconds, milliseconds) { if (arguments.length === 1 && typeof days === "number") { var orient = (days < 0) ? -1 : +1; var millsLeft = Math.abs(days); this.setDays(Math.floor(millsLeft / 86400000) * orient); millsLeft = millsLeft % 86400000; this.setHours(Math.floor(millsLeft / 3600000) * orient); millsLeft = millsLeft % 3600000; this.setMinutes(Math.floor(millsLeft / 60000) * orient); millsLeft = millsLeft % 60000; this.setSeconds(Math.floor(millsLeft / 1000) * orient); millsLeft = millsLeft % 1000; this.setMilliseconds(millsLeft * orient); } else { this.set(days, hours, minutes, seconds, milliseconds); } this.getTotalMilliseconds = function () { return (this.getDays() * 86400000) + (this.getHours() * 3600000) + (this.getMinutes() * 60000) + (this.getSeconds() * 1000); }; this.compareTo = function (time) { var t1 = new Date(1970, 1, 1, this.getHours(), this.getMinutes(), this.getSeconds()), t2; if (time === null) { t2 = new Date(1970, 1, 1, 0, 0, 0); } else { t2 = new Date(1970, 1, 1, time.getHours(), time.getMinutes(), time.getSeconds()); } return (t1 < t2) ? -1 : (t1 > t2) ? 1 : 0; }; this.equals = function (time) { return (this.compareTo(time) === 0); }; this.add = function (time) { return (time === null) ? this : this.addSeconds(time.getTotalMilliseconds() / 1000); }; this.subtract = function (time) { return (time === null) ? this : this.addSeconds(-time.getTotalMilliseconds() / 1000); }; this.addDays = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 86400000)); }; this.addHours = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 3600000)); }; this.addMinutes = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 60000)); }; this.addSeconds = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 1000)); }; this.addMilliseconds = function (n) { return new TimeSpan(this.getTotalMilliseconds() + n); }; this.get12HourHour = function () { return (this.getHours() > 12) ? this.getHours() - 12 : (this.getHours() === 0) ? 12 : this.getHours(); }; this.getDesignator = function () { return (this.getHours() < 12) ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator; }; this.toString = function (format) { this._toString = function () { if (this.getDays() !== null && this.getDays() > 0) { return this.getDays() + "." + this.getHours() + ":" + this.p(this.getMinutes()) + ":" + this.p(this.getSeconds()); } else { return this.getHours() + ":" + this.p(this.getMinutes()) + ":" + this.p(this.getSeconds()); } }; this.p = function (s) { return (s.toString().length < 2) ? "0" + s : s; }; var me = this; return format ? format.replace(/dd?|HH?|hh?|mm?|ss?|tt?/g, function (format) { switch (format) { case "d": return me.getDays(); case "dd": return me.p(me.getDays()); case "H": return me.getHours(); case "HH": return me.p(me.getHours()); case "h": return me.get12HourHour(); case "hh": return me.p(me.get12HourHour()); case "m": return me.getMinutes(); case "mm": return me.p(me.getMinutes()); case "s": return me.getSeconds(); case "ss": return me.p(me.getSeconds()); case "t": return ((me.getHours() < 12) ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator).substring(0, 1); case "tt": return (me.getHours() < 12) ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator; } } ) : this._toString(); }; return this; }; addSetFuncs(TimeSpan, attrs.slice(2)); TimeSpan.prototype.set = function (days, hours, minutes, seconds, milliseconds){ this.setDays(days || this.getDays()); this.setHours(hours || this.getHours()); this.setMinutes(minutes || this.getMinutes()); this.setSeconds(seconds || this.getSeconds()); this.setMilliseconds(milliseconds || this.getMilliseconds()); }; /** * Gets the time of day for this date instances. * @return {TimeSpan} TimeSpan */ Date.prototype.getTimeOfDay = function () { return new TimeSpan(0, this.getHours(), this.getMinutes(), this.getSeconds(), this.getMilliseconds()); }; Date.TimeSpan = TimeSpan; if (typeof window !== "undefined" ) { // keeping API compatible for v1.x window.TimeSpan = TimeSpan; } }()); (function () { "use strict"; var attrs = ["years", "months", "days", "hours", "minutes", "seconds", "milliseconds"]; var gFn = function (attr) { return function () { return this[attr]; }; }; var sFn = function (attr) { return function (val) { this[attr] = val; return this; }; }; var addSetFuncs = function (context, attrs) { for (var i = 0; i < attrs.length ; i++) { var $a = attrs[i], $b = $a.slice(0, 1).toUpperCase() + $a.slice(1); context.prototype[$a] = 0; context.prototype["get" + $b] = gFn($a); context.prototype["set" + $b] = sFn($a); } }; var setMonthsAndYears = function (orient, d1, d2, context) { function inc() { d1.addMonths(-orient); context.months++; if (context.months === 12) { context.years++; context.months = 0; } } if (orient === +1) { while (d1 > d2) { inc(); } } else { while (d1 < d2) { inc(); } } context.months--; context.months *= orient; context.years *= orient; }; var adjustForDST = function(orient, startDate, endDate) { var hasDSTMismatch = (false === (startDate.isDaylightSavingTime() === endDate.isDaylightSavingTime())); if (hasDSTMismatch && orient === 1) { startDate.addHours(-1); } else if (hasDSTMismatch) { startDate.addHours(1); } }; /** * TimePeriod(startDate, endDate); * TimePeriod(years, months, days, hours, minutes, seconds, milliseconds); */ var TimePeriod = function (years, months, days, hours, minutes, seconds, milliseconds) { if (arguments.length === 7) { this.set(years, months, days, hours, minutes, seconds, milliseconds); } else if (arguments.length === 2 && arguments[0] instanceof Date && arguments[1] instanceof Date) { var startDate = arguments[0].clone(); var endDate = arguments[1].clone(); var orient = (startDate > endDate) ? +1 : -1; this.dates = { start: arguments[0].clone(), end: arguments[1].clone() }; setMonthsAndYears(orient, startDate, endDate, this); adjustForDST(orient, startDate, endDate); // // TODO - adjust for DST var diff = endDate - startDate; if (diff !== 0) { var ts = new TimeSpan(diff); this.set(this.years, this.months, ts.getDays(), ts.getHours(), ts.getMinutes(), ts.getSeconds(), ts.getMilliseconds()); } } return this; }; // create all the set functions. addSetFuncs(TimePeriod, attrs); TimePeriod.prototype.set = function (years, months, days, hours, minutes, seconds, milliseconds){ this.setYears(years || this.getYears()); this.setMonths(months || this.getMonths()); this.setDays(days || this.getDays()); this.setHours(hours || this.getHours()); this.setMinutes(minutes || this.getMinutes()); this.setSeconds(seconds || this.getSeconds()); this.setMilliseconds(milliseconds || this.getMilliseconds()); }; Date.TimePeriod = TimePeriod; if (typeof window !== "undefined") { // keeping API compatible for v1.x window.TimePeriod = TimePeriod; } }()); ================================================ FILE: build/date-es-CR.js ================================================ /** * @overview datejs * @version 1.0.0-rc3 * @author Gregory Wild-Smith * @copyright 2015 Gregory Wild-Smith * @license MIT * @homepage https://github.com/abritinthebay/datejs */ /* * DateJS Culture String File * Country Code: es-CR * Name: Spanish (Costa Rica) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["es-CR"] = { "name": "es-CR", "englishName": "Spanish (Costa Rica)", "nativeName": "Español (Costa Rica)", "Sunday": "domingo", "Monday": "lunes", "Tuesday": "martes", "Wednesday": "miércoles", "Thursday": "jueves", "Friday": "viernes", "Saturday": "sábado", "Sun": "dom", "Mon": "lun", "Tue": "mar", "Wed": "mié", "Thu": "jue", "Fri": "vie", "Sat": "sáb", "Su": "do", "Mo": "lu", "Tu": "ma", "We": "mi", "Th": "ju", "Fr": "vi", "Sa": "sá", "S_Sun_Initial": "d", "M_Mon_Initial": "l", "T_Tue_Initial": "m", "W_Wed_Initial": "m", "T_Thu_Initial": "j", "F_Fri_Initial": "v", "S_Sat_Initial": "s", "January": "enero", "February": "febrero", "March": "marzo", "April": "abril", "May": "mayo", "June": "junio", "July": "julio", "August": "agosto", "September": "septiembre", "October": "octubre", "November": "noviembre", "December": "diciembre", "Jan_Abbr": "ene", "Feb_Abbr": "feb", "Mar_Abbr": "mar", "Apr_Abbr": "abr", "May_Abbr": "may", "Jun_Abbr": "jun", "Jul_Abbr": "jul", "Aug_Abbr": "ago", "Sep_Abbr": "sep", "Oct_Abbr": "oct", "Nov_Abbr": "nov", "Dec_Abbr": "dic", "AM": "a.m.", "PM": "p.m.", "firstDayOfWeek": 0, "twoDigitYearMax": 2029, "mdy": "dmy", "M/d/yyyy": "dd/MM/yyyy", "dddd, MMMM dd, yyyy": "dddd, dd' [de] 'MMMM' [de] 'yyyy", "h:mm tt": "hh:mm tt", "h:mm:ss tt": "hh:mm:ss tt", "dddd, MMMM dd, yyyy h:mm:ss tt": "dddd, dd' [de] 'MMMM' [de] 'yyyy hh:mm:ss tt", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "dd MMMM", "MMMM, yyyy": "MMMM' [de] 'yyyy", "/jan(uary)?/": "ene(ro)?", "/feb(ruary)?/": "feb(rero)?", "/mar(ch)?/": "mar(zo)?", "/apr(il)?/": "abr(il)?", "/may/": "may(o)?", "/jun(e)?/": "jun(io)?", "/jul(y)?/": "jul(io)?", "/aug(ust)?/": "ago(sto)?", "/sep(t(ember)?)?/": "sep(tiembre)?", "/oct(ober)?/": "oct(ubre)?", "/nov(ember)?/": "nov(iembre)?", "/dec(ember)?/": "dic(iembre)?", "/^su(n(day)?)?/": "^do(m(ingo)?)?", "/^mo(n(day)?)?/": "^lu(n(es)?)?", "/^tu(e(s(day)?)?)?/": "^ma(r(tes)?)?", "/^we(d(nesday)?)?/": "^mi(é(rcoles)?)?", "/^th(u(r(s(day)?)?)?)?/": "^ju(e(ves)?)?", "/^fr(i(day)?)?/": "^vi(e(rnes)?)?", "/^sa(t(urday)?)?/": "^sá(b(ado)?)?", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "es-CR"; /** * @overview datejs * @version 1.0.0-rc3 * @author Gregory Wild-Smith * @copyright 2015 Gregory Wild-Smith * @license MIT * @homepage https://github.com/abritinthebay/datejs */(function () { var $D = Date; var lang = Date.CultureStrings ? Date.CultureStrings.lang : null; var loggedKeys = {}; // for debug purposes. var getText = { getFromKey: function (key, countryCode) { var output; if (Date.CultureStrings && Date.CultureStrings[countryCode] && Date.CultureStrings[countryCode][key]) { output = Date.CultureStrings[countryCode][key]; } else { output = getText.buildFromDefault(key); } if (key.charAt(0) === "/") { // Assume it's a regex output = getText.buildFromRegex(key, countryCode); } return output; }, getFromObjectValues: function (obj, countryCode) { var key, output = {}; for(key in obj) { if (obj.hasOwnProperty(key)) { output[key] = getText.getFromKey(obj[key], countryCode); } } return output; }, getFromObjectKeys: function (obj, countryCode) { var key, output = {}; for(key in obj) { if (obj.hasOwnProperty(key)) { output[getText.getFromKey(key, countryCode)] = obj[key]; } } return output; }, getFromArray: function (arr, countryCode) { var output = []; for (var i=0; i < arr.length; i++){ if (i in arr) { output[i] = getText.getFromKey(arr[i], countryCode); } } return output; }, buildFromDefault: function (key) { var output, length, split, last; switch(key) { case "name": output = "en-US"; break; case "englishName": output = "English (United States)"; break; case "nativeName": output = "English (United States)"; break; case "twoDigitYearMax": output = 2049; break; case "firstDayOfWeek": output = 0; break; default: output = key; split = key.split("_"); length = split.length; if (length > 1 && key.charAt(0) !== "/") { // if the key isn't a regex and it has a split. last = split[(length - 1)].toLowerCase(); if (last === "initial" || last === "abbr") { output = split[0]; } } break; } return output; }, buildFromRegex: function (key, countryCode) { var output; if (Date.CultureStrings && Date.CultureStrings[countryCode] && Date.CultureStrings[countryCode][key]) { output = new RegExp(Date.CultureStrings[countryCode][key], "i"); } else { output = new RegExp(key.replace(new RegExp("/", "g"),""), "i"); } return output; } }; var shallowMerge = function (obj1, obj2) { for (var attrname in obj2) { if (obj2.hasOwnProperty(attrname)) { obj1[attrname] = obj2[attrname]; } } }; var __ = function (key, language) { var countryCode = (language) ? language : lang; loggedKeys[key] = key; if (typeof key === "object") { if (key instanceof Array) { return getText.getFromArray(key, countryCode); } else { return getText.getFromObjectKeys(key, countryCode); } } else { return getText.getFromKey(key, countryCode); } }; var loadI18nScript = function (code) { // paatterned after jQuery's getScript. var url = Date.Config.i18n + code + ".js"; var head = document.getElementsByTagName("head")[0] || document.documentElement; var script = document.createElement("script"); script.src = url; var completed = false; var events = { done: function (){} // placeholder function }; // Attach handlers for all browsers script.onload = script.onreadystatechange = function() { if ( !completed && (!this.readyState || this.readyState === "loaded" || this.readyState === "complete") ) { events.done(); head.removeChild(script); } }; setTimeout(function() { head.insertBefore(script, head.firstChild); }, 0); // allows return to execute first return { done: function (cb) { events.done = function() { if (cb) { setTimeout(cb,0); } }; } }; }; var buildInfo = { buildFromMethodHash: function (obj) { var key; for(key in obj) { if (obj.hasOwnProperty(key)) { obj[key] = buildInfo[obj[key]](); } } return obj; }, timeZoneDST: function () { var DST = { "CHADT": "+1345", "NZDT": "+1300", "AEDT": "+1100", "ACDT": "+1030", "AZST": "+0500", "IRDT": "+0430", "EEST": "+0300", "CEST": "+0200", "BST": "+0100", "PMDT": "-0200", "ADT": "-0300", "NDT": "-0230", "EDT": "-0400", "CDT": "-0500", "MDT": "-0600", "PDT": "-0700", "AKDT": "-0800", "HADT": "-0900" }; return __(DST); }, timeZoneStandard: function () { var standard = { "LINT": "+1400", "TOT": "+1300", "CHAST": "+1245", "NZST": "+1200", "NFT": "+1130", "SBT": "+1100", "AEST": "+1000", "ACST": "+0930", "JST": "+0900", "CWST": "+0845", "CT": "+0800", "ICT": "+0700", "MMT": "+0630", "BST": "+0600", "NPT": "+0545", "IST": "+0530", "PKT": "+0500", "AFT": "+0430", "MSK": "+0400", "IRST": "+0330", "FET": "+0300", "EET": "+0200", "CET": "+0100", "GMT": "+0000", "UTC": "+0000", "CVT": "-0100", "GST": "-0200", "BRT": "-0300", "NST": "-0330", "AST": "-0400", "EST": "-0500", "CST": "-0600", "MST": "-0700", "PST": "-0800", "AKST": "-0900", "MIT": "-0930", "HST": "-1000", "SST": "-1100", "BIT": "-1200" }; return __(standard); }, timeZones: function (data) { var zone; data.timezones = []; for (zone in data.abbreviatedTimeZoneStandard) { if (data.abbreviatedTimeZoneStandard.hasOwnProperty(zone)) { data.timezones.push({ name: zone, offset: data.abbreviatedTimeZoneStandard[zone]}); } } for (zone in data.abbreviatedTimeZoneDST) { if (data.abbreviatedTimeZoneDST.hasOwnProperty(zone)) { data.timezones.push({ name: zone, offset: data.abbreviatedTimeZoneDST[zone], dst: true}); } } return data.timezones; }, days: function () { return __(["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"]); }, dayAbbr: function () { return __(["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"]); }, dayShortNames: function () { return __(["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"]); }, dayFirstLetters: function () { return __(["S_Sun_Initial", "M_Mon_Initial", "T_Tues_Initial", "W_Wed_Initial", "T_Thu_Initial", "F_Fri_Initial", "S_Sat_Initial"]); }, months: function () { return __(["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"]); }, monthAbbr: function () { return __(["Jan_Abbr", "Feb_Abbr", "Mar_Abbr", "Apr_Abbr", "May_Abbr", "Jun_Abbr", "Jul_Abbr", "Aug_Abbr", "Sep_Abbr", "Oct_Abbr", "Nov_Abbr", "Dec_Abbr"]); }, formatPatterns: function () { return getText.getFromObjectValues({ shortDate: "M/d/yyyy", longDate: "dddd, MMMM dd, yyyy", shortTime: "h:mm tt", longTime: "h:mm:ss tt", fullDateTime: "dddd, MMMM dd, yyyy h:mm:ss tt", sortableDateTime: "yyyy-MM-ddTHH:mm:ss", universalSortableDateTime: "yyyy-MM-dd HH:mm:ssZ", rfc1123: "ddd, dd MMM yyyy HH:mm:ss", monthDay: "MMMM dd", yearMonth: "MMMM, yyyy" }, Date.i18n.currentLanguage()); }, regex: function () { return getText.getFromObjectValues({ inTheMorning: "/( in the )(morn(ing)?)\\b/", thisMorning: "/(this )(morn(ing)?)\\b/", amThisMorning: "/(\b\\d(am)? )(this )(morn(ing)?)/", inTheEvening: "/( in the )(even(ing)?)\\b/", thisEvening: "/(this )(even(ing)?)\\b/", pmThisEvening: "/(\b\\d(pm)? )(this )(even(ing)?)/", jan: "/jan(uary)?/", feb: "/feb(ruary)?/", mar: "/mar(ch)?/", apr: "/apr(il)?/", may: "/may/", jun: "/jun(e)?/", jul: "/jul(y)?/", aug: "/aug(ust)?/", sep: "/sep(t(ember)?)?/", oct: "/oct(ober)?/", nov: "/nov(ember)?/", dec: "/dec(ember)?/", sun: "/^su(n(day)?)?/", mon: "/^mo(n(day)?)?/", tue: "/^tu(e(s(day)?)?)?/", wed: "/^we(d(nesday)?)?/", thu: "/^th(u(r(s(day)?)?)?)?/", fri: "/fr(i(day)?)?/", sat: "/^sa(t(urday)?)?/", future: "/^next/", past: "/^last|past|prev(ious)?/", add: "/^(\\+|aft(er)?|from|hence)/", subtract: "/^(\\-|bef(ore)?|ago)/", yesterday: "/^yes(terday)?/", today: "/^t(od(ay)?)?/", tomorrow: "/^tom(orrow)?/", now: "/^n(ow)?/", millisecond: "/^ms|milli(second)?s?/", second: "/^sec(ond)?s?/", minute: "/^mn|min(ute)?s?/", hour: "/^h(our)?s?/", week: "/^w(eek)?s?/", month: "/^m(onth)?s?/", day: "/^d(ay)?s?/", year: "/^y(ear)?s?/", shortMeridian: "/^(a|p)/", longMeridian: "/^(a\\.?m?\\.?|p\\.?m?\\.?)/", timezone: "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/", ordinalSuffix: "/^\\s*(st|nd|rd|th)/", timeContext: "/^\\s*(\\:|a(?!u|p)|p)/" }, Date.i18n.currentLanguage()); } }; var CultureInfo = function () { var info = getText.getFromObjectValues({ name: "name", englishName: "englishName", nativeName: "nativeName", amDesignator: "AM", pmDesignator: "PM", firstDayOfWeek: "firstDayOfWeek", twoDigitYearMax: "twoDigitYearMax", dateElementOrder: "mdy" }, Date.i18n.currentLanguage()); var constructedInfo = buildInfo.buildFromMethodHash({ dayNames: "days", abbreviatedDayNames: "dayAbbr", shortestDayNames: "dayShortNames", firstLetterDayNames: "dayFirstLetters", monthNames: "months", abbreviatedMonthNames: "monthAbbr", formatPatterns: "formatPatterns", regexPatterns: "regex", abbreviatedTimeZoneDST: "timeZoneDST", abbreviatedTimeZoneStandard: "timeZoneStandard" }); shallowMerge(info, constructedInfo); buildInfo.timeZones(info); return info; }; $D.i18n = { __: function (key, lang) { return __(key, lang); }, currentLanguage: function () { return lang || "en-US"; }, setLanguage: function (code, force, cb) { var async = false; if (force || code === "en-US" || (!!Date.CultureStrings && !!Date.CultureStrings[code])) { lang = code; Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings.lang = code; Date.CultureInfo = new CultureInfo(); } else { if (!(!!Date.CultureStrings && !!Date.CultureStrings[code])) { if (typeof exports !== "undefined" && this.exports !== exports) { // we're in a Node enviroment, load it using require try { require("../i18n/" + code + ".js"); lang = code; Date.CultureStrings.lang = code; Date.CultureInfo = new CultureInfo(); } catch (e) { // var str = "The language for '" + code + "' could not be loaded by Node. It likely does not exist."; throw new Error("The DateJS IETF language tag '" + code + "' could not be loaded by Node. It likely does not exist."); } } else if (Date.Config && Date.Config.i18n) { // we know the location of the files, so lets load them async = true; loadI18nScript(code).done(function(){ lang = code; Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings.lang = code; Date.CultureInfo = new CultureInfo(); $D.Parsing.Normalizer.buildReplaceData(); // because this is async if ($D.Grammar) { $D.Grammar.buildGrammarFormats(); // so we can parse those strings... } if (cb) { setTimeout(cb,0); } }); } else { Date.console.error("The DateJS IETF language tag '" + code + "' is not available and has not been loaded."); return false; } } } $D.Parsing.Normalizer.buildReplaceData(); // rebuild normalizer strings if ($D.Grammar) { $D.Grammar.buildGrammarFormats(); // so we can parse those strings... } if (!async && cb) { setTimeout(cb,0); } }, getLoggedKeys: function () { return loggedKeys; }, updateCultureInfo: function () { Date.CultureInfo = new CultureInfo(); } }; $D.i18n.updateCultureInfo(); // run automatically }()); (function () { var $D = Date, $P = $D.prototype, p = function (s, l) { if (!l) { l = 2; } return ("000" + s).slice(l * -1); }; if (typeof window !== "undefined" && typeof window.console !== "undefined" && typeof window.console.log !== "undefined") { $D.console = console; // used only to raise non-critical errors if available } else { // set mock so we don't give errors. $D.console = { log: function(){}, error: function(){} }; } $D.Config = $D.Config || {}; $D.initOverloads = function() { /** * Overload of Date.now. Allows an alternate call for Date.now where it returns the * current Date as an object rather than just milliseconds since the Unix Epoch. * * Also provides an implementation of now() for browsers (IE<9) that don't have it. * * Backwards compatible so with work with either: * Date.now() [returns ms] * or * Date.now(true) [returns Date] */ if (!$D.now) { $D._now = function now() { return new Date().getTime(); }; } else if (!$D._now) { $D._now = $D.now; } $D.now = function (returnObj) { if (returnObj) { return $D.present(); } else { return $D._now(); } }; if ( !$P.toISOString ) { $P.toISOString = function() { return this.getUTCFullYear() + "-" + p(this.getUTCMonth() + 1) + "-" + p(this.getUTCDate()) + "T" + p(this.getUTCHours()) + ":" + p(this.getUTCMinutes()) + ":" + p(this.getUTCSeconds()) + "." + String( (this.getUTCMilliseconds()/1000).toFixed(3)).slice(2, 5) + "Z"; }; } // private if ( $P._toString === undefined ){ $P._toString = $P.toString; } }; $D.initOverloads(); /** * Gets a date that is set to the current date. The time is set to the start of the day (00:00 or 12:00 AM). * @return {Date} The current date. */ $D.today = function () { return new Date().clearTime(); }; /** * Gets a date that is set to the current date and time (same as new Date, but chainable) * @return {Date} The current date. */ $D.present = function () { return new Date(); }; /** * Compares the first date to the second date and returns an number indication of their relative values. * @param {Date} First Date object to compare [Required]. * @param {Date} Second Date object to compare to [Required]. * @return {Number} -1 = date1 is lessthan date2. 0 = values are equal. 1 = date1 is greaterthan date2. */ $D.compare = function (date1, date2) { if (isNaN(date1) || isNaN(date2)) { throw new Error(date1 + " - " + date2); } else if (date1 instanceof Date && date2 instanceof Date) { return (date1 < date2) ? -1 : (date1 > date2) ? 1 : 0; } else { throw new TypeError(date1 + " - " + date2); } }; /** * Compares the first Date object to the second Date object and returns true if they are equal. * @param {Date} First Date object to compare [Required] * @param {Date} Second Date object to compare to [Required] * @return {Boolean} true if dates are equal. false if they are not equal. */ $D.equals = function (date1, date2) { return (date1.compareTo(date2) === 0); }; /** * Gets the language appropriate day name when given the day number(0-6) * eg - 0 == Sunday * @return {String} The day name */ $D.getDayName = function (n) { return Date.CultureInfo.dayNames[n]; }; /** * Gets the day number (0-6) if given a CultureInfo specific string which is a valid dayName, abbreviatedDayName or shortestDayName (two char). * @param {String} The name of the day (eg. "Monday, "Mon", "tuesday", "tue", "We", "we"). * @return {Number} The day number */ $D.getDayNumberFromName = function (name) { var n = Date.CultureInfo.dayNames, m = Date.CultureInfo.abbreviatedDayNames, o = Date.CultureInfo.shortestDayNames, s = name.toLowerCase(); for (var i = 0; i < n.length; i++) { if (n[i].toLowerCase() === s || m[i].toLowerCase() === s || o[i].toLowerCase() === s) { return i; } } return -1; }; /** * Gets the month number (0-11) if given a Culture Info specific string which is a valid monthName or abbreviatedMonthName. * @param {String} The name of the month (eg. "February, "Feb", "october", "oct"). * @return {Number} The day number */ $D.getMonthNumberFromName = function (name) { var n = Date.CultureInfo.monthNames, m = Date.CultureInfo.abbreviatedMonthNames, s = name.toLowerCase(); for (var i = 0; i < n.length; i++) { if (n[i].toLowerCase() === s || m[i].toLowerCase() === s) { return i; } } return -1; }; /** * Gets the language appropriate month name when given the month number(0-11) * eg - 0 == January * @return {String} The month name */ $D.getMonthName = function (n) { return Date.CultureInfo.monthNames[n]; }; /** * Determines if the current date instance is within a LeapYear. * @param {Number} The year. * @return {Boolean} true if date is within a LeapYear, otherwise false. */ $D.isLeapYear = function (year) { return ((year % 4 === 0 && year % 100 !== 0) || year % 400 === 0); }; /** * Gets the number of days in the month, given a year and month value. Automatically corrects for LeapYear. * @param {Number} The year. * @param {Number} The month (0-11). * @return {Number} The number of days in the month. */ $D.getDaysInMonth = function (year, month) { if (!month && $D.validateMonth(year)) { month = year; year = Date.today().getFullYear(); } return [31, ($D.isLeapYear(year) ? 29 : 28), 31, 30, 31, 30, 31, 31, 30, 31, 30, 31][month]; }; $P.getDaysInMonth = function () { return $D.getDaysInMonth(this.getFullYear(), this.getMonth()); }; $D.getTimezoneAbbreviation = function (offset, dst) { var p, n = (dst || false) ? Date.CultureInfo.abbreviatedTimeZoneDST : Date.CultureInfo.abbreviatedTimeZoneStandard; for (p in n) { if (n.hasOwnProperty(p)) { if (n[p] === offset) { return p; } } } return null; }; $D.getTimezoneOffset = function (name, dst) { var i, a =[], z = Date.CultureInfo.timezones; if (!name) { name = (new Date()).getTimezone();} for (i = 0; i < z.length; i++) { if (z[i].name === name.toUpperCase()) { a.push(i); } } if (!z[a[0]]) { return null; } if (a.length === 1 || !dst) { return z[a[0]].offset; } else { for (i=0; i < a.length; i++) { if (z[a[i]].dst) { return z[a[i]].offset; } } } }; $D.getQuarter = function (d) { d = d || new Date(); // If no date supplied, use today var q = [1,2,3,4]; return q[Math.floor(d.getMonth() / 3)]; // ~~~ is a bitwise op. Faster than Math.floor }; $D.getDaysLeftInQuarter = function (d) { d = d || new Date(); var qEnd = new Date(d); qEnd.setMonth(qEnd.getMonth() + 3 - qEnd.getMonth() % 3, 0); return Math.floor((qEnd - d) / 8.64e7); }; // private var validate = function (n, min, max, name) { name = name ? name : "Object"; if (typeof n === "undefined") { return false; } else if (typeof n !== "number") { throw new TypeError(n + " is not a Number."); } else if (n < min || n > max) { // As failing validation is *not* an exceptional circumstance // lets not throw a RangeError Exception here. // It's semantically correct but it's not sensible. return false; } return true; }; /** * Validates the number is within an acceptable range for milliseconds [0-999]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateMillisecond = function (value) { return validate(value, 0, 999, "millisecond"); }; /** * Validates the number is within an acceptable range for seconds [0-59]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateSecond = function (value) { return validate(value, 0, 59, "second"); }; /** * Validates the number is within an acceptable range for minutes [0-59]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateMinute = function (value) { return validate(value, 0, 59, "minute"); }; /** * Validates the number is within an acceptable range for hours [0-23]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateHour = function (value) { return validate(value, 0, 23, "hour"); }; /** * Validates the number is within an acceptable range for the days in a month [0-MaxDaysInMonth]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateDay = function (value, year, month) { if (year === undefined || year === null || month === undefined || month === null) { return false;} return validate(value, 1, $D.getDaysInMonth(year, month), "day"); }; /** * Validates the number is within an acceptable range for months [0-11]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateWeek = function (value) { return validate(value, 0, 53, "week"); }; /** * Validates the number is within an acceptable range for months [0-11]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateMonth = function (value) { return validate(value, 0, 11, "month"); }; /** * Validates the number is within an acceptable range for years. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateYear = function (value) { /** * Per ECMAScript spec the range of times supported by Date objects is * exactly -100,000,000 days to +100,000,000 days measured relative to * midnight at the beginning of 01 January, 1970 UTC. * This gives a range of 8,640,000,000,000,000 milliseconds to either * side of 01 January, 1970 UTC. * * Earliest possible date: Tue, 20 Apr 271,822 B.C. 00:00:00 UTC * Latest possible date: Sat, 13 Sep 275,760 00:00:00 UTC */ return validate(value, -271822, 275760, "year"); }; $D.validateTimezone = function(value) { var timezones = {"ACDT":1,"ACST":1,"ACT":1,"ADT":1,"AEDT":1,"AEST":1,"AFT":1,"AKDT":1,"AKST":1,"AMST":1,"AMT":1,"ART":1,"AST":1,"AWDT":1,"AWST":1,"AZOST":1,"AZT":1,"BDT":1,"BIOT":1,"BIT":1,"BOT":1,"BRT":1,"BST":1,"BTT":1,"CAT":1,"CCT":1,"CDT":1,"CEDT":1,"CEST":1,"CET":1,"CHADT":1,"CHAST":1,"CHOT":1,"ChST":1,"CHUT":1,"CIST":1,"CIT":1,"CKT":1,"CLST":1,"CLT":1,"COST":1,"COT":1,"CST":1,"CT":1,"CVT":1,"CWST":1,"CXT":1,"DAVT":1,"DDUT":1,"DFT":1,"EASST":1,"EAST":1,"EAT":1,"ECT":1,"EDT":1,"EEDT":1,"EEST":1,"EET":1,"EGST":1,"EGT":1,"EIT":1,"EST":1,"FET":1,"FJT":1,"FKST":1,"FKT":1,"FNT":1,"GALT":1,"GAMT":1,"GET":1,"GFT":1,"GILT":1,"GIT":1,"GMT":1,"GST":1,"GYT":1,"HADT":1,"HAEC":1,"HAST":1,"HKT":1,"HMT":1,"HOVT":1,"HST":1,"ICT":1,"IDT":1,"IOT":1,"IRDT":1,"IRKT":1,"IRST":1,"IST":1,"JST":1,"KGT":1,"KOST":1,"KRAT":1,"KST":1,"LHST":1,"LINT":1,"MAGT":1,"MART":1,"MAWT":1,"MDT":1,"MET":1,"MEST":1,"MHT":1,"MIST":1,"MIT":1,"MMT":1,"MSK":1,"MST":1,"MUT":1,"MVT":1,"MYT":1,"NCT":1,"NDT":1,"NFT":1,"NPT":1,"NST":1,"NT":1,"NUT":1,"NZDT":1,"NZST":1,"OMST":1,"ORAT":1,"PDT":1,"PET":1,"PETT":1,"PGT":1,"PHOT":1,"PHT":1,"PKT":1,"PMDT":1,"PMST":1,"PONT":1,"PST":1,"PYST":1,"PYT":1,"RET":1,"ROTT":1,"SAKT":1,"SAMT":1,"SAST":1,"SBT":1,"SCT":1,"SGT":1,"SLST":1,"SRT":1,"SST":1,"SYOT":1,"TAHT":1,"THA":1,"TFT":1,"TJT":1,"TKT":1,"TLT":1,"TMT":1,"TOT":1,"TVT":1,"UCT":1,"ULAT":1,"UTC":1,"UYST":1,"UYT":1,"UZT":1,"VET":1,"VLAT":1,"VOLT":1,"VOST":1,"VUT":1,"WAKT":1,"WAST":1,"WAT":1,"WEDT":1,"WEST":1,"WET":1,"WST":1,"YAKT":1,"YEKT":1,"Z":1}; return (timezones[value] === 1); }; $D.validateTimezoneOffset= function(value) { // timezones go from +14hrs to -12hrs, the +X hours are negative offsets. return (value > -841 && value < 721); }; }()); (function () { var $D = Date, $P = $D.prototype, p = function (s, l) { if (!l) { l = 2; } return ("000" + s).slice(l * -1); }; var validateConfigObject = function (obj) { var result = {}, self = this, prop, testFunc; testFunc = function (prop, func, value) { if (prop === "day") { var month = (obj.month !== undefined) ? obj.month : self.getMonth(); var year = (obj.year !== undefined) ? obj.year : self.getFullYear(); return $D[func](value, year, month); } else { return $D[func](value); } }; for (prop in obj) { if (Object.prototype.hasOwnProperty.call(obj, prop)) { var func = "validate" + prop.charAt(0).toUpperCase() + prop.slice(1); if ($D[func] && obj[prop] !== null && testFunc(prop, func, obj[prop])) { result[prop] = obj[prop]; } } } return result; }; /** * Resets the time of this Date object to 12:00 AM (00:00), which is the start of the day. * @param {Boolean} .clone() this date instance before clearing Time * @return {Date} this */ $P.clearTime = function () { this.setHours(0); this.setMinutes(0); this.setSeconds(0); this.setMilliseconds(0); return this; }; /** * Resets the time of this Date object to the current time ('now'). * @return {Date} this */ $P.setTimeToNow = function () { var n = new Date(); this.setHours(n.getHours()); this.setMinutes(n.getMinutes()); this.setSeconds(n.getSeconds()); this.setMilliseconds(n.getMilliseconds()); return this; }; /** * Returns a new Date object that is an exact date and time copy of the original instance. * @return {Date} A new Date instance */ $P.clone = function () { return new Date(this.getTime()); }; /** * Compares this instance to a Date object and returns an number indication of their relative values. * @param {Date} Date object to compare [Required] * @return {Number} -1 = this is lessthan date. 0 = values are equal. 1 = this is greaterthan date. */ $P.compareTo = function (date) { return Date.compare(this, date); }; /** * Compares this instance to another Date object and returns true if they are equal. * @param {Date} Date object to compare. If no date to compare, new Date() [now] is used. * @return {Boolean} true if dates are equal. false if they are not equal. */ $P.equals = function (date) { return Date.equals(this, (date !== undefined ? date : new Date())); }; /** * Determines if this instance is between a range of two dates or equal to either the start or end dates. * @param {Date} Start of range [Required] * @param {Date} End of range [Required] * @return {Boolean} true is this is between or equal to the start and end dates, else false */ $P.between = function (start, end) { return this.getTime() >= start.getTime() && this.getTime() <= end.getTime(); }; /** * Determines if this date occurs after the date to compare to. * @param {Date} Date object to compare. If no date to compare, new Date() ("now") is used. * @return {Boolean} true if this date instance is greater than the date to compare to (or "now"), otherwise false. */ $P.isAfter = function (date) { return this.compareTo(date || new Date()) === 1; }; /** * Determines if this date occurs before the date to compare to. * @param {Date} Date object to compare. If no date to compare, new Date() ("now") is used. * @return {Boolean} true if this date instance is less than the date to compare to (or "now"). */ $P.isBefore = function (date) { return (this.compareTo(date || new Date()) === -1); }; /** * Determines if the current Date instance occurs today. * @return {Boolean} true if this date instance is 'today', otherwise false. */ /** * Determines if the current Date instance occurs on the same Date as the supplied 'date'. * If no 'date' to compare to is provided, the current Date instance is compared to 'today'. * @param {date} Date object to compare. If no date to compare, the current Date ("now") is used. * @return {Boolean} true if this Date instance occurs on the same Day as the supplied 'date'. */ $P.isToday = $P.isSameDay = function (date) { return this.clone().clearTime().equals((date || new Date()).clone().clearTime()); }; /** * Adds the specified number of milliseconds to this instance. * @param {Number} The number of milliseconds to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addMilliseconds = function (value) { if (!value) { return this; } this.setTime(this.getTime() + value * 1); return this; }; /** * Adds the specified number of seconds to this instance. * @param {Number} The number of seconds to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addSeconds = function (value) { if (!value) { return this; } return this.addMilliseconds(value * 1000); }; /** * Adds the specified number of seconds to this instance. * @param {Number} The number of seconds to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addMinutes = function (value) { if (!value) { return this; } return this.addMilliseconds(value * 60000); // 60*1000 }; /** * Adds the specified number of hours to this instance. * @param {Number} The number of hours to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addHours = function (value) { if (!value) { return this; } return this.addMilliseconds(value * 3600000); // 60*60*1000 }; /** * Adds the specified number of days to this instance. * @param {Number} The number of days to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addDays = function (value) { if (!value) { return this; } this.setDate(this.getDate() + value * 1); return this; }; /** * Adds the specified number of weekdays (ie - not sat or sun) to this instance. * @param {Number} The number of days to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addWeekdays = function (value) { if (!value) { return this; } var day = this.getDay(); var weeks = (Math.ceil(Math.abs(value)/7)); if (day === 0 || day === 6) { if (value > 0) { this.next().monday(); this.addDays(-1); day = this.getDay(); } } if (value < 0) { while (value < 0) { this.addDays(-1); day = this.getDay(); if (day !== 0 && day !== 6) { value++; } } return this; } else if (value > 5 || (6-day) <= value) { value = value + (weeks * 2); } return this.addDays(value); }; /** * Adds the specified number of weeks to this instance. * @param {Number} The number of weeks to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addWeeks = function (value) { if (!value) { return this; } return this.addDays(value * 7); }; /** * Adds the specified number of months to this instance. * @param {Number} The number of months to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addMonths = function (value) { if (!value) { return this; } var n = this.getDate(); this.setDate(1); this.setMonth(this.getMonth() + value * 1); this.setDate(Math.min(n, $D.getDaysInMonth(this.getFullYear(), this.getMonth()))); return this; }; $P.addQuarters = function (value) { if (!value) { return this; } // note this will take you to the same point in the quarter as you are now. // i.e. - if you are 15 days into the quarter you'll be 15 days into the resulting one. // bonus: this allows adding fractional quarters return this.addMonths(value * 3); }; /** * Adds the specified number of years to this instance. * @param {Number} The number of years to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addYears = function (value) { if (!value) { return this; } return this.addMonths(value * 12); }; /** * Adds (or subtracts) to the value of the years, months, weeks, days, hours, minutes, seconds, milliseconds of the date instance using given configuration object. Positive and Negative values allowed. * Example

	Date.today().add( { days: 1, months: 1 } )

	new Date().add( { years: -1 } )
	
* @param {Object} Configuration object containing attributes (months, days, etc.) * @return {Date} this */ $P.add = function (config) { if (typeof config === "number") { this._orient = config; return this; } var x = config; if (x.day) { // If we should be a different date than today (eg: for 'tomorrow -1d', etc). // Should only effect parsing, not direct usage (eg, Finish and FinishExact) if ((x.day - this.getDate()) !== 0) { this.setDate(x.day); } } if (x.milliseconds) { this.addMilliseconds(x.milliseconds); } if (x.seconds) { this.addSeconds(x.seconds); } if (x.minutes) { this.addMinutes(x.minutes); } if (x.hours) { this.addHours(x.hours); } if (x.weeks) { this.addWeeks(x.weeks); } if (x.months) { this.addMonths(x.months); } if (x.years) { this.addYears(x.years); } if (x.days) { this.addDays(x.days); } return this; }; /** * Get the week number. Week one (1) is the week which contains the first Thursday of the year. Monday is considered the first day of the week. * The .getWeek() function does NOT convert the date to UTC. The local datetime is used. * Please use .getISOWeek() to get the week of the UTC converted date. * @return {Number} 1 to 53 */ $P.getWeek = function (utc) { // Create a copy of this date object var self, target = new Date(this.valueOf()); if (utc) { target.addMinutes(target.getTimezoneOffset()); self = target.clone(); } else { self = this; } // ISO week date weeks start on monday // so correct the day number var dayNr = (self.getDay() + 6) % 7; // ISO 8601 states that week 1 is the week // with the first thursday of that year. // Set the target date to the thursday in the target week target.setDate(target.getDate() - dayNr + 3); // Store the millisecond value of the target date var firstThursday = target.valueOf(); // Set the target to the first thursday of the year // First set the target to january first target.setMonth(0, 1); // Not a thursday? Correct the date to the next thursday if (target.getDay() !== 4) { target.setMonth(0, 1 + ((4 - target.getDay()) + 7) % 7); } // The weeknumber is the number of weeks between the // first thursday of the year and the thursday in the target week return 1 + Math.ceil((firstThursday - target) / 604800000); // 604800000 = 7 * 24 * 3600 * 1000 }; /** * Get the ISO 8601 week number. Week one ("01") is the week which contains the first Thursday of the year. Monday is considered the first day of the week. * The .getISOWeek() function does convert the date to it's UTC value. Please use .getWeek() to get the week of the local date. * @return {String} "01" to "53" */ $P.getISOWeek = function () { return p(this.getWeek(true)); }; /** * Moves the date to Monday of the week set. Week one (1) is the week which contains the first Thursday of the year. * @param {Number} A Number (1 to 53) that represents the week of the year. * @return {Date} this */ $P.setWeek = function (n) { if ((n - this.getWeek()) === 0) { if (this.getDay() !== 1) { return this.moveToDayOfWeek(1, (this.getDay() > 1 ? -1 : 1)); } else { return this; } } else { return this.moveToDayOfWeek(1, (this.getDay() > 1 ? -1 : 1)).addWeeks(n - this.getWeek()); } }; $P.setQuarter = function (qtr) { var month = Math.abs(((qtr-1) * 3) + 1); return this.setMonth(month, 1); }; $P.getQuarter = function () { return Date.getQuarter(this); }; $P.getDaysLeftInQuarter = function () { return Date.getDaysLeftInQuarter(this); }; /** * Moves the date to the next n'th occurrence of the dayOfWeek starting from the beginning of the month. The number (-1) is a magic number and will return the last occurrence of the dayOfWeek in the month. * @param {Number} The dayOfWeek to move to * @param {Number} The n'th occurrence to move to. Use (-1) to return the last occurrence in the month * @return {Date} this */ $P.moveToNthOccurrence = function (dayOfWeek, occurrence) { if (dayOfWeek === "Weekday") { if (occurrence > 0) { this.moveToFirstDayOfMonth(); if (this.is().weekday()) { occurrence -= 1; } } else if (occurrence < 0) { this.moveToLastDayOfMonth(); if (this.is().weekday()) { occurrence += 1; } } else { return this; } return this.addWeekdays(occurrence); } var shift = 0; if (occurrence > 0) { shift = occurrence - 1; } else if (occurrence === -1) { this.moveToLastDayOfMonth(); if (this.getDay() !== dayOfWeek) { this.moveToDayOfWeek(dayOfWeek, -1); } return this; } return this.moveToFirstDayOfMonth().addDays(-1).moveToDayOfWeek(dayOfWeek, +1).addWeeks(shift); }; var moveToN = function (getFunc, addFunc, nVal) { return function (value, orient) { var diff = (value - this[getFunc]() + nVal * (orient || +1)) % nVal; return this[addFunc]((diff === 0) ? diff += nVal * (orient || +1) : diff); }; }; /** * Move to the next or last dayOfWeek based on the orient value. * @param {Number} The dayOfWeek to move to * @param {Number} Forward (+1) or Back (-1). Defaults to +1. [Optional] * @return {Date} this */ $P.moveToDayOfWeek = moveToN("getDay", "addDays", 7); /** * Move to the next or last month based on the orient value. * @param {Number} The month to move to. 0 = January, 11 = December * @param {Number} Forward (+1) or Back (-1). Defaults to +1. [Optional] * @return {Date} this */ $P.moveToMonth = moveToN("getMonth", "addMonths", 12); /** * Get the Ordinate of the current day ("th", "st", "rd"). * @return {String} */ $P.getOrdinate = function () { var num = this.getDate(); return ord(num); }; /** * Get the Ordinal day (numeric day number) of the year, adjusted for leap year. * @return {Number} 1 through 365 (366 in leap years) */ $P.getOrdinalNumber = function () { return Math.ceil((this.clone().clearTime() - new Date(this.getFullYear(), 0, 1)) / 86400000) + 1; }; /** * Get the time zone abbreviation of the current date. * @return {String} The abbreviated time zone name (e.g. "EST") */ $P.getTimezone = function () { return $D.getTimezoneAbbreviation(this.getUTCOffset(), this.isDaylightSavingTime()); }; $P.setTimezoneOffset = function (offset) { var here = this.getTimezoneOffset(), there = Number(offset) * -6 / 10; return (there || there === 0) ? this.addMinutes(there - here) : this; }; $P.setTimezone = function (offset) { return this.setTimezoneOffset($D.getTimezoneOffset(offset)); }; /** * Indicates whether Daylight Saving Time is observed in the current time zone. * @return {Boolean} true|false */ $P.hasDaylightSavingTime = function () { return (Date.today().set({month: 0, day: 1}).getTimezoneOffset() !== Date.today().set({month: 6, day: 1}).getTimezoneOffset()); }; /** * Indicates whether this Date instance is within the Daylight Saving Time range for the current time zone. * @return {Boolean} true|false */ $P.isDaylightSavingTime = function () { return Date.today().set({month: 0, day: 1}).getTimezoneOffset() !== this.getTimezoneOffset(); }; /** * Get the offset from UTC of the current date. * @return {String} The 4-character offset string prefixed with + or - (e.g. "-0500") */ $P.getUTCOffset = function (offset) { var n = (offset || this.getTimezoneOffset()) * -10 / 6, r; if (n < 0) { r = (n - 10000).toString(); return r.charAt(0) + r.substr(2); } else { r = (n + 10000).toString(); return "+" + r.substr(1); } }; /** * Returns the number of milliseconds between this date and date. * @param {Date} Defaults to now * @return {Number} The diff in milliseconds */ $P.getElapsed = function (date) { return (date || new Date()) - this; }; /** * Set the value of year, month, day, hour, minute, second, millisecond of date instance using given configuration object. * Example

	Date.today().set( { day: 20, month: 1 } )

	new Date().set( { millisecond: 0 } )
	
* * @param {Object} Configuration object containing attributes (month, day, etc.) * @return {Date} this */ $P.set = function (config) { config = validateConfigObject.call(this, config); var key; for (key in config) { if (Object.prototype.hasOwnProperty.call(config, key)) { var name = key.charAt(0).toUpperCase() + key.slice(1); var addFunc, getFunc; if (key !== "week" && key !== "month" && key !== "timezone" && key !== "timezoneOffset") { name += "s"; } addFunc = "add" + name; getFunc = "get" + name; if (key === "month") { addFunc = addFunc + "s"; } else if (key === "year"){ getFunc = "getFullYear"; } if (key !== "day" && key !== "timezone" && key !== "timezoneOffset" && key !== "week" && key !== "hour") { this[addFunc](config[key] - this[getFunc]()); } else if ( key === "timezone"|| key === "timezoneOffset" || key === "week" || key === "hour") { this["set"+name](config[key]); } } } // day has to go last because you can't validate the day without first knowing the month if (config.day) { this.addDays(config.day - this.getDate()); } return this; }; /** * Moves the date to the first day of the month. * @return {Date} this */ $P.moveToFirstDayOfMonth = function () { return this.set({ day: 1 }); }; /** * Moves the date to the last day of the month. * @return {Date} this */ $P.moveToLastDayOfMonth = function () { return this.set({ day: $D.getDaysInMonth(this.getFullYear(), this.getMonth())}); }; /** * Converts the value of the current Date object to its equivalent string representation. * Format Specifiers * CUSTOM DATE AND TIME FORMAT STRINGS * Format Description Example * ------ --------------------------------------------------------------------------- ----------------------- * s The seconds of the minute between 0-59. "0" to "59" * ss The seconds of the minute with leading zero if required. "00" to "59" * * m The minute of the hour between 0-59. "0" or "59" * mm The minute of the hour with leading zero if required. "00" or "59" * * h The hour of the day between 1-12. "1" to "12" * hh The hour of the day with leading zero if required. "01" to "12" * * H The hour of the day between 0-23. "0" to "23" * HH The hour of the day with leading zero if required. "00" to "23" * * d The day of the month between 1 and 31. "1" to "31" * dd The day of the month with leading zero if required. "01" to "31" * ddd Abbreviated day name. Date.CultureInfo.abbreviatedDayNames. "Mon" to "Sun" * dddd The full day name. Date.CultureInfo.dayNames. "Monday" to "Sunday" * * M The month of the year between 1-12. "1" to "12" * MM The month of the year with leading zero if required. "01" to "12" * MMM Abbreviated month name. Date.CultureInfo.abbreviatedMonthNames. "Jan" to "Dec" * MMMM The full month name. Date.CultureInfo.monthNames. "January" to "December" * * yy The year as a two-digit number. "99" or "08" * yyyy The full four digit year. "1999" or "2008" * * t Displays the first character of the A.M./P.M. designator. "A" or "P" * Date.CultureInfo.amDesignator or Date.CultureInfo.pmDesignator * tt Displays the A.M./P.M. designator. "AM" or "PM" * Date.CultureInfo.amDesignator or Date.CultureInfo.pmDesignator * * S The ordinal suffix ("st, "nd", "rd" or "th") of the current day. "st, "nd", "rd" or "th" * * STANDARD DATE AND TIME FORMAT STRINGS * Format Description Example *------ --------------------------------------------------------------------------- ----------------------- * d The CultureInfo shortDate Format Pattern "M/d/yyyy" * D The CultureInfo longDate Format Pattern "dddd, MMMM dd, yyyy" * F The CultureInfo fullDateTime Format Pattern "dddd, MMMM dd, yyyy h:mm:ss tt" * m The CultureInfo monthDay Format Pattern "MMMM dd" * r The CultureInfo rfc1123 Format Pattern "ddd, dd MMM yyyy HH:mm:ss GMT" * s The CultureInfo sortableDateTime Format Pattern "yyyy-MM-ddTHH:mm:ss" * t The CultureInfo shortTime Format Pattern "h:mm tt" * T The CultureInfo longTime Format Pattern "h:mm:ss tt" * u The CultureInfo universalSortableDateTime Format Pattern "yyyy-MM-dd HH:mm:ssZ" * y The CultureInfo yearMonth Format Pattern "MMMM, yyyy" * * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @return {String} A string representation of the current Date object. */ var ord = function (n) { switch (n * 1) { case 1: case 21: case 31: return "st"; case 2: case 22: return "nd"; case 3: case 23: return "rd"; default: return "th"; } }; var parseStandardFormats = function (format) { var y, c = Date.CultureInfo.formatPatterns; switch (format) { case "d": return this.toString(c.shortDate); case "D": return this.toString(c.longDate); case "F": return this.toString(c.fullDateTime); case "m": return this.toString(c.monthDay); case "r": case "R": y = this.clone().addMinutes(this.getTimezoneOffset()); return y.toString(c.rfc1123) + " GMT"; case "s": return this.toString(c.sortableDateTime); case "t": return this.toString(c.shortTime); case "T": return this.toString(c.longTime); case "u": y = this.clone().addMinutes(this.getTimezoneOffset()); return y.toString(c.universalSortableDateTime); case "y": return this.toString(c.yearMonth); default: return false; } }; var parseFormatStringsClosure = function (context) { return function (m) { if (m.charAt(0) === "\\") { return m.replace("\\", ""); } switch (m) { case "hh": return p(context.getHours() < 13 ? (context.getHours() === 0 ? 12 : context.getHours()) : (context.getHours() - 12)); case "h": return context.getHours() < 13 ? (context.getHours() === 0 ? 12 : context.getHours()) : (context.getHours() - 12); case "HH": return p(context.getHours()); case "H": return context.getHours(); case "mm": return p(context.getMinutes()); case "m": return context.getMinutes(); case "ss": return p(context.getSeconds()); case "s": return context.getSeconds(); case "yyyy": return p(context.getFullYear(), 4); case "yy": return p(context.getFullYear()); case "y": return context.getFullYear(); case "E": case "dddd": return Date.CultureInfo.dayNames[context.getDay()]; case "ddd": return Date.CultureInfo.abbreviatedDayNames[context.getDay()]; case "dd": return p(context.getDate()); case "d": return context.getDate(); case "MMMM": return Date.CultureInfo.monthNames[context.getMonth()]; case "MMM": return Date.CultureInfo.abbreviatedMonthNames[context.getMonth()]; case "MM": return p((context.getMonth() + 1)); case "M": return context.getMonth() + 1; case "t": return context.getHours() < 12 ? Date.CultureInfo.amDesignator.substring(0, 1) : Date.CultureInfo.pmDesignator.substring(0, 1); case "tt": return context.getHours() < 12 ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator; case "S": return ord(context.getDate()); case "W": return context.getWeek(); case "WW": return context.getISOWeek(); case "Q": return "Q" + context.getQuarter(); case "q": return String(context.getQuarter()); case "z": return context.getTimezone(); case "Z": case "X": return Date.getTimezoneOffset(context.getTimezone()); case "ZZ": // Timezone offset in seconds return context.getTimezoneOffset() * -60; case "u": return context.getDay(); case "L": return ($D.isLeapYear(context.getFullYear())) ? 1 : 0; case "B": // Swatch Internet Time (.beats) return "@"+((context.getUTCSeconds() + (context.getUTCMinutes()*60) + ((context.getUTCHours()+1)*3600))/86.4); default: return m; } }; }; $P.toString = function (format, ignoreStandards) { // Standard Date and Time Format Strings. Formats pulled from CultureInfo file and // may vary by culture. if (!ignoreStandards && format && format.length === 1) { output = parseStandardFormats.call(this, format); if (output) { return output; } } var parseFormatStrings = parseFormatStringsClosure(this); return format ? format.replace(/((\\)?(dd?d?d?|MM?M?M?|yy?y?y?|hh?|HH?|mm?|ss?|tt?|S|q|Q|WW?W?W?)(?![^\[]*\]))/g, parseFormatStrings).replace(/\[|\]/g, "") : this._toString(); }; }()); /************************************************************* * SugarPak - Domain Specific Language - Syntactical Sugar * *************************************************************/ (function () { var $D = Date, $P = $D.prototype, $N = Number.prototype; // private $P._orient = +1; // private $P._nth = null; // private $P._is = false; // private $P._same = false; // private $P._isSecond = false; // private $N._dateElement = "days"; /** * Moves the date to the next instance of a date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.today().next().friday();
	Date.today().next().fri();
	Date.today().next().march();
	Date.today().next().mar();
	Date.today().next().week();
	
* * @return {Date} date */ $P.next = function () { this._move = true; this._orient = +1; return this; }; /** * Creates a new Date (Date.today()) and moves the date to the next instance of the date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.next().friday();
	Date.next().fri();
	Date.next().march();
	Date.next().mar();
	Date.next().week();
	
* * @return {Date} date */ $D.next = function () { return $D.today().next(); }; /** * Moves the date to the previous instance of a date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.today().last().friday();
	Date.today().last().fri();
	Date.today().last().march();
	Date.today().last().mar();
	Date.today().last().week();
	
* * @return {Date} date */ $P.last = $P.prev = $P.previous = function () { this._move = true; this._orient = -1; return this; }; /** * Creates a new Date (Date.today()) and moves the date to the previous instance of the date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.last().friday();
	Date.last().fri();
	Date.previous().march();
	Date.prev().mar();
	Date.last().week();
	
* * @return {Date} date */ $D.last = $D.prev = $D.previous = function () { return $D.today().last(); }; /** * Performs a equality check when followed by either a month name, day name or .weekday() function. * Example

	Date.today().is().friday(); // true|false
	Date.today().is().fri();
	Date.today().is().march();
	Date.today().is().mar();
	
* * @return {Boolean} true|false */ $P.is = function () { this._is = true; return this; }; /** * Determines if two date objects occur on/in exactly the same instance of the subsequent date part function. * The function .same() must be followed by a date part function (example: .day(), .month(), .year(), etc). * * An optional Date can be passed in the date part function. If now date is passed as a parameter, 'Now' is used. * * The following example demonstrates how to determine if two dates fall on the exact same day. * * Example

	var d1 = Date.today(); // today at 00:00
	var d2 = new Date();   // exactly now.

	// Do they occur on the same day?
	d1.same().day(d2); // true
	
	// Do they occur on the same hour?
	d1.same().hour(d2); // false, unless d2 hour is '00' (midnight).
	
	// What if it's the same day, but one year apart?
	var nextYear = Date.today().add(1).year();

	d1.same().day(nextYear); // false, because the dates must occur on the exact same day. 
	
* * Scenario: Determine if a given date occurs during some week period 2 months from now. * * Example

	var future = Date.today().add(2).months();
	return someDate.same().week(future); // true|false;
	
* * @return {Boolean} true|false */ $P.same = function () { this._same = true; this._isSecond = false; return this; }; /** * Determines if the current date/time occurs during Today. Must be preceded by the .is() function. * Example

	someDate.is().today();    // true|false
	new Date().is().today();  // true
	Date.today().is().today();// true
	Date.today().add(-1).day().is().today(); // false
	
* * @return {Boolean} true|false */ $P.today = function () { return this.same().day(); }; /** * Determines if the current date is a weekday. This function must be preceded by the .is() function. * Example

	Date.today().is().weekday(); // true|false
	
* * @return {Boolean} true|false */ $P.weekday = function () { if (this._nth) { return df("Weekday").call(this); } if (this._move) { return this.addWeekdays(this._orient); } if (this._is) { this._is = false; return (!this.is().sat() && !this.is().sun()); } return false; }; /** * Determines if the current date is on the weekend. This function must be preceded by the .is() function. * Example

	Date.today().is().weekend(); // true|false
	
* * @return {Boolean} true|false */ $P.weekend = function () { if (this._is) { this._is = false; return (this.is().sat() || this.is().sun()); } return false; }; /** * Sets the Time of the current Date instance. A string "6:15 pm" or config object {hour:18, minute:15} are accepted. * Example

	// Set time to 6:15pm with a String
	Date.today().at("6:15pm");

	// Set time to 6:15pm with a config object
	Date.today().at({hour:18, minute:15});
	
* * @return {Date} date */ $P.at = function (time) { return (typeof time === "string") ? $D.parse(this.toString("d") + " " + time) : this.set(time); }; /** * Creates a new Date() and adds this (Number) to the date based on the preceding date element function (eg. second|minute|hour|day|month|year). * Example

	// Undeclared Numbers must be wrapped with parentheses. Requirment of JavaScript.
	(3).days().fromNow();
	(6).months().fromNow();

	// Declared Number variables do not require parentheses. 
	var n = 6;
	n.months().fromNow();
	
* * @return {Date} A new Date instance */ $N.fromNow = $N.after = function (date) { var c = {}; c[this._dateElement] = this; return ((!date) ? new Date() : date.clone()).add(c); }; /** * Creates a new Date() and subtract this (Number) from the date based on the preceding date element function (eg. second|minute|hour|day|month|year). * Example

	// Undeclared Numbers must be wrapped with parentheses. Requirment of JavaScript.
	(3).days().ago();
	(6).months().ago();

	// Declared Number variables do not require parentheses. 
	var n = 6;
	n.months().ago();
	
* * @return {Date} A new Date instance */ $N.ago = $N.before = function (date) { var c = {}, s = (this._dateElement[this._dateElement.length-1] !== "s") ? this._dateElement + "s" : this._dateElement; c[s] = this * -1; return ((!date) ? new Date() : date.clone()).add(c); }; // Do NOT modify the following string tokens. These tokens are used to build dynamic functions. // All culture-specific strings can be found in the CultureInfo files. var dx = ("sunday monday tuesday wednesday thursday friday saturday").split(/\s/), mx = ("january february march april may june july august september october november december").split(/\s/), px = ("Millisecond Second Minute Hour Day Week Month Year Quarter Weekday").split(/\s/), pxf = ("Milliseconds Seconds Minutes Hours Date Week Month FullYear Quarter").split(/\s/), nth = ("final first second third fourth fifth").split(/\s/), de; /** * Returns an object literal of all the date parts. * Example

	var o = new Date().toObject();
	
	// { year: 2008, month: 4, week: 20, day: 13, hour: 18, minute: 9, second: 32, millisecond: 812 }
	
	// The object properties can be referenced directly from the object.
	
	alert(o.day);  // alerts "13"
	alert(o.year); // alerts "2008"
	
* * @return {Date} An object literal representing the original date object. */ $P.toObject = function () { var o = {}; for (var i = 0; i < px.length; i++) { if (this["get" + pxf[i]]) { o[px[i].toLowerCase()] = this["get" + pxf[i]](); } } return o; }; /** * Returns a date created from an object literal. Ignores the .week property if set in the config. * Example

	var o = new Date().toObject();
	
	return Date.fromObject(o); // will return the same date. 

	var o2 = {month: 1, day: 20, hour: 18}; // birthday party!
	Date.fromObject(o2);
	
* * @return {Date} An object literal representing the original date object. */ $D.fromObject = function(config) { config.week = null; return Date.today().set(config); }; // Create day name functions and abbreviated day name functions (eg. monday(), friday(), fri()). var df = function (n) { return function () { if (this._is) { this._is = false; return this.getDay() === n; } if (this._move) { this._move = null; } if (this._nth !== null) { // If the .second() function was called earlier, remove the _orient // from the date, and then continue. // This is required because 'second' can be used in two different context. // // Example // // Date.today().add(1).second(); // Date.march().second().monday(); // // Things get crazy with the following... // Date.march().add(1).second().second().monday(); // but it works!! // if (this._isSecond) { this.addSeconds(this._orient * -1); } // make sure we reset _isSecond this._isSecond = false; var ntemp = this._nth; this._nth = null; var temp = this.clone().moveToLastDayOfMonth(); this.moveToNthOccurrence(n, ntemp); if (this > temp) { throw new RangeError($D.getDayName(n) + " does not occur " + ntemp + " times in the month of " + $D.getMonthName(temp.getMonth()) + " " + temp.getFullYear() + "."); } return this; } return this.moveToDayOfWeek(n, this._orient); }; }; var sdf = function (n) { return function () { var t = $D.today(), shift = n - t.getDay(); if (n === 0 && Date.CultureInfo.firstDayOfWeek === 1 && t.getDay() !== 0) { shift = shift + 7; } return t.addDays(shift); }; }; // Create month name functions and abbreviated month name functions (eg. january(), march(), mar()). var month_instance_functions = function (n) { return function () { if (this._is) { this._is = false; return this.getMonth() === n; } return this.moveToMonth(n, this._orient); }; }; var month_static_functions = function (n) { return function () { return $D.today().set({ month: n, day: 1 }); }; }; var processTerms = function (names, staticFunc, instanceFunc) { for (var i = 0; i < names.length; i++) { // Create constant static Name variables. $D[names[i].toUpperCase()] = $D[names[i].toUpperCase().substring(0, 3)] = i; // Create Name functions. $D[names[i]] = $D[names[i].substring(0, 3)] = staticFunc(i); // Create Name instance functions. $P[names[i]] = $P[names[i].substring(0, 3)] = instanceFunc(i); } }; processTerms(dx, sdf, df); processTerms(mx, month_static_functions, month_instance_functions); // Create date element functions and plural date element functions used with Date (eg. day(), days(), months()). var ef = function (j) { return function () { // if the .second() function was called earlier, the _orient // has alread been added. Just return this and reset _isSecond. if (this._isSecond) { this._isSecond = false; return this; } if (this._same) { this._same = this._is = false; var o1 = this.toObject(), o2 = (arguments[0] || new Date()).toObject(), v = "", k = j.toLowerCase(); // the substr trick with -1 doesn't work in IE8 or less k = (k[k.length-1] === "s") ? k.substring(0,k.length-1) : k; for (var m = (px.length - 1); m > -1; m--) { v = px[m].toLowerCase(); if (o1[v] !== o2[v]) { return false; } if (k === v) { break; } } return true; } if (j.substring(j.length - 1) !== "s") { j += "s"; } if (this._move) { this._move = null; } return this["add" + j](this._orient); }; }; var nf = function (n) { return function () { this._dateElement = n; return this; }; }; for (var k = 0; k < px.length; k++) { de = px[k].toLowerCase(); if(de !== "weekday") { // Create date element functions and plural date element functions used with Date (eg. day(), days(), months()). $P[de] = $P[de + "s"] = ef(px[k]); // Create date element functions and plural date element functions used with Number (eg. day(), days(), months()). $N[de] = $N[de + "s"] = nf(de + "s"); } } $P._ss = ef("Second"); var nthfn = function (n) { return function (dayOfWeek) { if (this._same) { return this._ss(arguments[0]); } if (dayOfWeek || dayOfWeek === 0) { return this.moveToNthOccurrence(dayOfWeek, n); } this._nth = n; // if the operator is 'second' add the _orient, then deal with it later... if (n === 2 && (dayOfWeek === undefined || dayOfWeek === null)) { this._isSecond = true; return this.addSeconds(this._orient); } return this; }; }; for (var l = 0; l < nth.length; l++) { $P[nth[l]] = (l === 0) ? nthfn(-1) : nthfn(l); } }()); (function () { "use strict"; Date.Parsing = { Exception: function (s) { this.message = "Parse error at '" + s.substring(0, 10) + " ...'"; } }; var $P = Date.Parsing; var dayOffsets = { standard: [0,31,59,90,120,151,181,212,243,273,304,334], leap: [0,31,60,91,121,152,182,213,244,274,305,335] }; $P.isLeapYear = function(year) { return ((year % 4 === 0) && (year % 100 !== 0)) || (year % 400 === 0); }; var utils = { multiReplace : function (str, hash ) { var key; for (key in hash) { if (Object.prototype.hasOwnProperty.call(hash, key)) { var regex; if (typeof hash[key] === "function") { } else { regex = (hash[key] instanceof RegExp) ? hash[key] : new RegExp(hash[key], "g"); } str = str.replace(regex, key); } } return str; }, getDayOfYearFromWeek : function (obj) { var d, jan4, offset; obj.weekDay = (!obj.weekDay && obj.weekDay !== 0) ? 1 : obj.weekDay; d = new Date(obj.year, 0, 4); jan4 = d.getDay() === 0 ? 7 : d.getDay(); // JS is 0 indexed on Sunday. offset = jan4+3; obj.dayOfYear = ((obj.week * 7) + (obj.weekDay === 0 ? 7 : obj.weekDay))-offset; return obj; }, getDayOfYear : function (obj, dayOffset) { if (!obj.dayOfYear) { obj = utils.getDayOfYearFromWeek(obj); } for (var i=0;i <= dayOffset.length;i++) { if (obj.dayOfYear < dayOffset[i] || i === dayOffset.length) { obj.day = obj.day ? obj.day : (obj.dayOfYear - dayOffset[i-1]); break; } else { obj.month = i; } } return obj; }, adjustForTimeZone : function (obj, date) { var offset; if (obj.zone.toUpperCase() === "Z" || (obj.zone_hours === 0 && obj.zone_minutes === 0)) { // it's UTC/GML so work out the current timeszone offset offset = -date.getTimezoneOffset(); } else { offset = (obj.zone_hours*60) + (obj.zone_minutes || 0); if (obj.zone_sign === "+") { offset *= -1; } offset -= date.getTimezoneOffset(); } date.setMinutes(date.getMinutes()+offset); return date; }, setDefaults : function (obj) { obj.year = obj.year || Date.today().getFullYear(); obj.hours = obj.hours || 0; obj.minutes = obj.minutes || 0; obj.seconds = obj.seconds || 0; obj.milliseconds = obj.milliseconds || 0; if (!(!obj.month && (obj.week || obj.dayOfYear))) { // if we have a month, or if we don't but don't have the day calculation data obj.month = obj.month || 0; obj.day = obj.day || 1; } return obj; }, dataNum: function (data, mod, explict, postProcess) { var dataNum = data*1; if (mod) { if (postProcess) { return data ? mod(data)*1 : data; } else { return data ? mod(dataNum) : data; } } else if (!explict){ return data ? dataNum : data; } else { return (data && typeof data !== "undefined") ? dataNum : data; } }, timeDataProcess: function (obj) { var timeObj = {}; for (var x in obj.data) { if (obj.data.hasOwnProperty(x)) { timeObj[x] = obj.ignore[x] ? obj.data[x] : utils.dataNum(obj.data[x], obj.mods[x], obj.explict[x], obj.postProcess[x]); } } if (obj.data.secmins) { obj.data.secmins = obj.data.secmins.replace(",", ".") * 60; if (!timeObj.minutes) { timeObj.minutes = obj.data.secmins; } else if (!timeObj.seconds) { timeObj.seconds = obj.data.secmins; } delete obj.secmins; } return timeObj; }, buildTimeObjectFromData: function (data) { var time = utils.timeDataProcess({ data: { year : data[1], month : data[5], day : data[7], week : data[8], dayOfYear : data[10], hours : data[15], zone_hours : data[23], zone_minutes : data[24], zone : data[21], zone_sign : data[22], weekDay : data[9], minutes: data[16], seconds: data[19], milliseconds: data[20], secmins: data[18] }, mods: { month: function(data) { return data-1; }, weekDay: function (data) { data = Math.abs(data); return (data === 7 ? 0 : data); }, minutes: function (data) { return data.replace(":",""); }, seconds: function (data) { return Math.floor( (data.replace(":","").replace(",","."))*1 ); }, milliseconds: function (data) { return (data.replace(",",".")*1000); } }, postProcess: { minutes: true, seconds: true, milliseconds: true }, explict: { zone_hours: true, zone_minutes: true }, ignore: { zone: true, zone_sign: true, secmins: true } }); return time; }, addToHash: function (hash, keys, data) { keys = keys; data = data; var len = keys.length; for (var i = 0; i < len; i++) { hash[keys[i]] = data[i]; } return hash; }, combineRegex: function (r1, r2) { return new RegExp("(("+r1.source+")\\s("+r2.source+"))"); }, getDateNthString: function(add, last, inc){ if (add) { return Date.today().addDays(inc).toString("d"); } else if (last) { return Date.today().last()[inc]().toString("d"); } }, buildRegexData: function (array) { var arr = []; var len = array.length; for (var i=0; i < len; i++) { if (Object.prototype.toString.call(array[i]) === '[object Array]') { // oldIE compat version of Array.isArray arr.push(this.combineRegex(array[i][0], array[i][1])); } else { arr.push(array[i]); } } return arr; } }; $P.processTimeObject = function (obj) { var date, dayOffset; utils.setDefaults(obj); dayOffset = ($P.isLeapYear(obj.year)) ? dayOffsets.leap : dayOffsets.standard; if (!obj.month && (obj.week || obj.dayOfYear)) { utils.getDayOfYear(obj, dayOffset); } else { obj.dayOfYear = dayOffset[obj.month] + obj.day; } date = new Date(obj.year, obj.month, obj.day, obj.hours, obj.minutes, obj.seconds, obj.milliseconds); if (obj.zone) { utils.adjustForTimeZone(obj, date); // adjust (and calculate) for timezone } return date; }; $P.ISO = { regex : /^([\+-]?\d{4}(?!\d{2}\b))((-?)((0[1-9]|1[0-2])(\3([12]\d|0[1-9]|3[01]))?|W([0-4]\d|5[0-3])(-?[1-7])?|(00[1-9]|0[1-9]\d|[12]\d{2}|3([0-5]\d|6[1-6])))([T\s]((([01]\d|2[0-4])((:?)[0-5]\d)?|24\:?00)([\.,]\d+(?!:))?)?(\17[0-5]\d([\.,]\d+)?)?\s?([zZ]|([\+-])([01]\d|2[0-3]):?([0-5]\d)?)?)?)?$/, parse : function (s) { var time, data = s.match(this.regex); if (!data || !data.length) { return null; } time = utils.buildTimeObjectFromData(data); if (!time.year || (!time.year && (!time.month && !time.day) && (!time.week && !time.dayOfYear)) ) { return null; } return $P.processTimeObject(time); } }; $P.Numeric = { isNumeric: function (e){return!isNaN(parseFloat(e))&&isFinite(e);}, regex: /\b([0-1]?[0-9])([0-3]?[0-9])([0-2]?[0-9]?[0-9][0-9])\b/i, parse: function (s) { var data, i, time = {}, order = Date.CultureInfo.dateElementOrder.split(""); if (!(this.isNumeric(s)) || // if it's non-numeric OR (s[0] === "+" && s[0] === "-")) { // It's an arithmatic string (eg +/-1000) return null; } if (s.length < 5 && s.indexOf(".") < 0 && s.indexOf("/") < 0) { // assume it's just a year. time.year = s; return $P.processTimeObject(time); } data = s.match(this.regex); if (!data || !data.length) { return null; } for (i=0; i < order.length; i++) { switch(order[i]) { case "d": time.day = data[i+1]; break; case "m": time.month = (data[i+1]-1); break; case "y": time.year = data[i+1]; break; } } return $P.processTimeObject(time); } }; $P.Normalizer = { regexData: function () { var $R = Date.CultureInfo.regexPatterns; return utils.buildRegexData([ $R.tomorrow, $R.yesterday, [$R.past, $R.mon], [$R.past, $R.tue], [$R.past, $R.wed], [$R.past, $R.thu], [$R.past, $R.fri], [$R.past, $R.sat], [$R.past, $R.sun] ]); }, basicReplaceHash : function() { var $R = Date.CultureInfo.regexPatterns; return { "January": $R.jan.source, "February": $R.feb, "March": $R.mar, "April": $R.apr, "May": $R.may, "June": $R.jun, "July": $R.jul, "August": $R.aug, "September": $R.sep, "October": $R.oct, "November": $R.nov, "December": $R.dec, "": /\bat\b/gi, " ": /\s{2,}/, "am": $R.inTheMorning, "9am": $R.thisMorning, "pm": $R.inTheEvening, "7pm":$R.thisEvening }; }, keys : function(){ return [ utils.getDateNthString(true, false, 1), // tomorrow utils.getDateNthString(true, false, -1), // yesterday utils.getDateNthString(false, true, "monday"), //last mon utils.getDateNthString(false, true, "tuesday"), //last tues utils.getDateNthString(false, true, "wednesday"), //last wed utils.getDateNthString(false, true, "thursday"), //last thurs utils.getDateNthString(false, true, "friday"), //last fri utils.getDateNthString(false, true, "saturday"), //last sat utils.getDateNthString(false, true, "sunday") //last sun ]; }, buildRegexFunctions: function () { var $R = Date.CultureInfo.regexPatterns; var __ = Date.i18n.__; var tomorrowRE = new RegExp("(\\b\\d\\d?("+__("AM")+"|"+__("PM")+")? )("+$R.tomorrow.source.slice(1)+")", "i"); // adapted tomorrow regex for AM PM relative dates var todayRE = new RegExp($R.today.source + "(?!\\s*([+-]))\\b"); // today, but excludes the math operators (eg "today + 2h") this.replaceFuncs = [ [todayRE, function (full) { return (full.length > 1) ? Date.today().toString("d") : full; }], [tomorrowRE, function(full, m1) { var t = Date.today().addDays(1).toString("d"); return (t + " " + m1); }], [$R.amThisMorning, function(str, am){return am;}], [$R.pmThisEvening, function(str, pm){return pm;}] ]; }, buildReplaceData: function () { this.buildRegexFunctions(); this.replaceHash = utils.addToHash(this.basicReplaceHash(), this.keys(), this.regexData()); }, stringReplaceFuncs: function (s) { for (var i=0; i < this.replaceFuncs.length; i++) { s = s.replace(this.replaceFuncs[i][0], this.replaceFuncs[i][1]); } return s; }, parse: function (s) { s = this.stringReplaceFuncs(s); s = utils.multiReplace(s, this.replaceHash); try { var n = s.split(/([\s\-\.\,\/\x27]+)/); if (n.length === 3 && $P.Numeric.isNumeric(n[0]) && $P.Numeric.isNumeric(n[2]) && (n[2].length >= 4)) { // ok, so we're dealing with x/year. But that's not a full date. // This fixes wonky dateElementOrder parsing when set to dmy order. if (Date.CultureInfo.dateElementOrder[0] === "d") { s = "1/" + n[0] + "/" + n[2]; // set to 1st of month and normalize the seperator } } } catch (e) {} return s; } }; $P.Normalizer.buildReplaceData(); }()); (function () { var $P = Date.Parsing; var _ = $P.Operators = { // // Tokenizers // rtoken: function (r) { // regex token return function (s) { var mx = s.match(r); if (mx) { return ([ mx[0], s.substring(mx[0].length) ]); } else { throw new $P.Exception(s); } }; }, token: function () { // whitespace-eating token return function (s) { return _.rtoken(new RegExp("^\\s*" + s + "\\s*"))(s); }; }, stoken: function (s) { // string token return _.rtoken(new RegExp("^" + s)); }, // Atomic Operators until: function (p) { return function (s) { var qx = [], rx = null; while (s.length) { try { rx = p.call(this, s); } catch (e) { qx.push(rx[0]); s = rx[1]; continue; } break; } return [ qx, s ]; }; }, many: function (p) { return function (s) { var rx = [], r = null; while (s.length) { try { r = p.call(this, s); } catch (e) { return [ rx, s ]; } rx.push(r[0]); s = r[1]; } return [ rx, s ]; }; }, // generator operators -- see below optional: function (p) { return function (s) { var r = null; try { r = p.call(this, s); } catch (e) { return [ null, s ]; } return [ r[0], r[1] ]; }; }, not: function (p) { return function (s) { try { p.call(this, s); } catch (e) { return [null, s]; } throw new $P.Exception(s); }; }, ignore: function (p) { return p ? function (s) { var r = null; r = p.call(this, s); return [null, r[1]]; } : null; }, product: function () { var px = arguments[0], qx = Array.prototype.slice.call(arguments, 1), rx = []; for (var i = 0 ; i < px.length ; i++) { rx.push(_.each(px[i], qx)); } return rx; }, cache: function (rule) { var cache = {}, cache_length = 0, cache_keys = [], CACHE_MAX = Date.Config.CACHE_MAX || 100000, r = null; var cacheCheck = function () { if (cache_length === CACHE_MAX) { // kill several keys, don't want to have to do this all the time... for (var i=0; i < 10; i++) { var key = cache_keys.shift(); if (key) { delete cache[key]; cache_length--; } } } }; return function (s) { cacheCheck(); try { r = cache[s] = (cache[s] || rule.call(this, s)); } catch (e) { r = cache[s] = e; } cache_length++; cache_keys.push(s); if (r instanceof $P.Exception) { throw r; } else { return r; } }; }, // vector operators -- see below any: function () { var px = arguments; return function (s) { var r = null; for (var i = 0; i < px.length; i++) { if (px[i] == null) { continue; } try { r = (px[i].call(this, s)); } catch (e) { r = null; } if (r) { return r; } } throw new $P.Exception(s); }; }, each: function () { var px = arguments; return function (s) { var rx = [], r = null; for (var i = 0; i < px.length ; i++) { if (px[i] == null) { continue; } try { r = (px[i].call(this, s)); } catch (e) { throw new $P.Exception(s); } rx.push(r[0]); s = r[1]; } return [ rx, s]; }; }, all: function () { var px = arguments, _ = _; return _.each(_.optional(px)); }, // delimited operators sequence: function (px, d, c) { d = d || _.rtoken(/^\s*/); c = c || null; if (px.length === 1) { return px[0]; } return function (s) { var r = null, q = null; var rx = []; for (var i = 0; i < px.length ; i++) { try { r = px[i].call(this, s); } catch (e) { break; } rx.push(r[0]); try { q = d.call(this, r[1]); } catch (ex) { q = null; break; } s = q[1]; } if (!r) { throw new $P.Exception(s); } if (q) { throw new $P.Exception(q[1]); } if (c) { try { r = c.call(this, r[1]); } catch (ey) { throw new $P.Exception(r[1]); } } return [ rx, (r?r[1]:s) ]; }; }, // // Composite Operators // between: function (d1, p, d2) { d2 = d2 || d1; var _fn = _.each(_.ignore(d1), p, _.ignore(d2)); return function (s) { var rx = _fn.call(this, s); return [[rx[0][0], r[0][2]], rx[1]]; }; }, list: function (p, d, c) { d = d || _.rtoken(/^\s*/); c = c || null; return (p instanceof Array ? _.each(_.product(p.slice(0, -1), _.ignore(d)), p.slice(-1), _.ignore(c)) : _.each(_.many(_.each(p, _.ignore(d))), px, _.ignore(c))); }, set: function (px, d, c) { d = d || _.rtoken(/^\s*/); c = c || null; return function (s) { // r is the current match, best the current 'best' match // which means it parsed the most amount of input var r = null, p = null, q = null, rx = null, best = [[], s], last = false; // go through the rules in the given set for (var i = 0; i < px.length ; i++) { // last is a flag indicating whether this must be the last element // if there is only 1 element, then it MUST be the last one q = null; p = null; r = null; last = (px.length === 1); // first, we try simply to match the current pattern // if not, try the next pattern try { r = px[i].call(this, s); } catch (e) { continue; } // since we are matching against a set of elements, the first // thing to do is to add r[0] to matched elements rx = [[r[0]], r[1]]; // if we matched and there is still input to parse and // we don't already know this is the last element, // we're going to next check for the delimiter ... // if there's none, or if there's no input left to parse // than this must be the last element after all ... if (r[1].length > 0 && ! last) { try { q = d.call(this, r[1]); } catch (ex) { last = true; } } else { last = true; } // if we parsed the delimiter and now there's no more input, // that means we shouldn't have parsed the delimiter at all // so don't update r and mark this as the last element ... if (!last && q[1].length === 0) { last = true; } // so, if this isn't the last element, we're going to see if // we can get any more matches from the remaining (unmatched) // elements ... if (!last) { // build a list of the remaining rules we can match against, // i.e., all but the one we just matched against var qx = []; for (var j = 0; j < px.length ; j++) { if (i !== j) { qx.push(px[j]); } } // now invoke recursively set with the remaining input // note that we don't include the closing delimiter ... // we'll check for that ourselves at the end p = _.set(qx, d).call(this, q[1]); // if we got a non-empty set as a result ... // (otw rx already contains everything we want to match) if (p[0].length > 0) { // update current result, which is stored in rx ... // basically, pick up the remaining text from p[1] // and concat the result from p[0] so that we don't // get endless nesting ... rx[0] = rx[0].concat(p[0]); rx[1] = p[1]; } } // at this point, rx either contains the last matched element // or the entire matched set that starts with this element. // now we just check to see if this variation is better than // our best so far, in terms of how much of the input is parsed if (rx[1].length < best[1].length) { best = rx; } // if we've parsed all the input, then we're finished if (best[1].length === 0) { break; } } // so now we've either gone through all the patterns trying them // as the initial match; or we found one that parsed the entire // input string ... // if best has no matches, just return empty set ... if (best[0].length === 0) { return best; } // if a closing delimiter is provided, then we have to check it also if (c) { // we try this even if there is no remaining input because the pattern // may well be optional or match empty input ... try { q = c.call(this, best[1]); } catch (ey) { throw new $P.Exception(best[1]); } // it parsed ... be sure to update the best match remaining input best[1] = q[1]; } // if we're here, either there was no closing delimiter or we parsed it // so now we have the best match; just return it! return best; }; }, forward: function (gr, fname) { return function (s) { return gr[fname].call(this, s); }; }, // // Translation Operators // replace: function (rule, repl) { return function (s) { var r = rule.call(this, s); return [repl, r[1]]; }; }, process: function (rule, fn) { return function (s) { var r = rule.call(this, s); return [fn.call(this, r[0]), r[1]]; }; }, min: function (min, rule) { return function (s) { var rx = rule.call(this, s); if (rx[0].length < min) { throw new $P.Exception(s); } return rx; }; } }; // Generator Operators And Vector Operators // Generators are operators that have a signature of F(R) => R, // taking a given rule and returning another rule, such as // ignore, which parses a given rule and throws away the result. // Vector operators are those that have a signature of F(R1,R2,...) => R, // take a list of rules and returning a new rule, such as each. // Generator operators are converted (via the following _generator // function) into functions that can also take a list or array of rules // and return an array of new rules as though the function had been // called on each rule in turn (which is what actually happens). // This allows generators to be used with vector operators more easily. // Example: // each(ignore(foo, bar)) instead of each(ignore(foo), ignore(bar)) // This also turns generators into vector operators, which allows // constructs like: // not(cache(foo, bar)) var _generator = function (op) { function gen() { var args = null, rx = [], px, i; if (arguments.length > 1) { args = Array.prototype.slice.call(arguments); } else if (arguments[0] instanceof Array) { args = arguments[0]; } if (args) { px = args.shift(); if (px.length > 0) { args.unshift(px[i]); rx.push(op.apply(null, args)); args.shift(); return rx; } } else { return op.apply(null, arguments); } } return gen; }; var gx = "optional not ignore cache".split(/\s/); for (var i = 0 ; i < gx.length ; i++) { _[gx[i]] = _generator(_[gx[i]]); } var _vector = function (op) { return function () { if (arguments[0] instanceof Array) { return op.apply(null, arguments[0]); } else { return op.apply(null, arguments); } }; }; var vx = "each any all".split(/\s/); for (var j = 0 ; j < vx.length ; j++) { _[vx[j]] = _vector(_[vx[j]]); } }()); (function () { var $D = Date; var flattenAndCompact = function (ax) { var rx = []; for (var i = 0; i < ax.length; i++) { if (ax[i] instanceof Array) { rx = rx.concat(flattenAndCompact(ax[i])); } else { if (ax[i]) { rx.push(ax[i]); } } } return rx; }; var parseMeridian = function () { if (this.meridian && (this.hour || this.hour === 0)) { if (this.meridian === "a" && this.hour > 11 && Date.Config.strict24hr){ throw "Invalid hour and meridian combination"; } else if (this.meridian === "p" && this.hour < 12 && Date.Config.strict24hr){ throw "Invalid hour and meridian combination"; } else if (this.meridian === "p" && this.hour < 12) { this.hour = this.hour + 12; } else if (this.meridian === "a" && this.hour === 12) { this.hour = 0; } } }; var setDefaults = function () { var now = new Date(); if ((this.hour || this.minute) && (!this.month && !this.year && !this.day)) { this.day = now.getDate(); } if (!this.year) { this.year = now.getFullYear(); } if (!this.month && this.month !== 0) { this.month = now.getMonth(); } if (!this.day) { this.day = 1; } if (!this.hour) { this.hour = 0; } if (!this.minute) { this.minute = 0; } if (!this.second) { this.second = 0; } if (!this.millisecond) { this.millisecond = 0; } }; var finishUtils = { getToday: function () { if (this.now || "hour minute second".indexOf(this.unit) !== -1) { return new Date(); } else { return $D.today(); } }, setDaysFromWeekday: function (today, orient){ var gap; orient = orient || 1; this.unit = "day"; gap = ($D.getDayNumberFromName(this.weekday) - today.getDay()); this.days = gap ? ((gap + (orient * 7)) % 7) : (orient * 7); return this; }, setMonthsFromMonth: function (today, orient) { var gap; orient = orient || 1; this.unit = "month"; gap = (this.month - today.getMonth()); this.months = gap ? ((gap + (orient * 12)) % 12) : (orient * 12); this.month = null; return this; }, setDMYFromWeekday: function () { var d = Date[this.weekday](); this.day = d.getDate(); if (!this.month) { this.month = d.getMonth(); } this.year = d.getFullYear(); return this; }, setUnitValue: function (orient) { if (!this.value && this.operator && this.operator !== null && this[this.unit + "s"] && this[this.unit + "s"] !== null) { this[this.unit + "s"] = this[this.unit + "s"] + ((this.operator === "add") ? 1 : -1) + (this.value||0) * orient; } else if (this[this.unit + "s"] == null || this.operator != null) { if (!this.value) { this.value = 1; } this[this.unit + "s"] = this.value * orient; } }, generateDateFromWeeks: function () { var weekday = (this.weekday !== undefined) ? this.weekday : "today"; var d = Date[weekday]().addWeeks(this.weeks); if (this.now) { d.setTimeToNow(); } return d; } }; $D.Translator = { hour: function (s) { return function () { this.hour = Number(s); }; }, minute: function (s) { return function () { this.minute = Number(s); }; }, second: function (s) { return function () { this.second = Number(s); }; }, /* for ss.s format */ secondAndMillisecond: function (s) { return function () { var mx = s.match(/^([0-5][0-9])\.([0-9]{1,3})/); this.second = Number(mx[1]); this.millisecond = Number(mx[2]); }; }, meridian: function (s) { return function () { this.meridian = s.slice(0, 1).toLowerCase(); }; }, timezone: function (s) { return function () { var n = s.replace(/[^\d\+\-]/g, ""); if (n.length) { this.timezoneOffset = Number(n); } else { this.timezone = s.toLowerCase(); } }; }, day: function (x) { var s = x[0]; return function () { this.day = Number(s.match(/\d+/)[0]); if (this.day < 1) { throw "invalid day"; } }; }, month: function (s) { return function () { this.month = (s.length === 3) ? "jan feb mar apr may jun jul aug sep oct nov dec".indexOf(s)/4 : Number(s) - 1; if (this.month < 0) { throw "invalid month"; } }; }, year: function (s) { return function () { var n = Number(s); this.year = ((s.length > 2) ? n : (n + (((n + 2000) < Date.CultureInfo.twoDigitYearMax) ? 2000 : 1900))); }; }, rday: function (s) { return function () { switch (s) { case "yesterday": this.days = -1; break; case "tomorrow": this.days = 1; break; case "today": this.days = 0; break; case "now": this.days = 0; this.now = true; break; } }; }, finishExact: function (x) { var d; x = (x instanceof Array) ? x : [x]; for (var i = 0 ; i < x.length ; i++) { if (x[i]) { x[i].call(this); } } setDefaults.call(this); parseMeridian.call(this); if (this.day > $D.getDaysInMonth(this.year, this.month)) { throw new RangeError(this.day + " is not a valid value for days."); } d = new Date(this.year, this.month, this.day, this.hour, this.minute, this.second, this.millisecond); if (this.year < 100) { d.setFullYear(this.year); // means years less that 100 are process correctly. JS will parse it otherwise as 1900-1999. } if (this.timezone) { d.set({ timezone: this.timezone }); } else if (this.timezoneOffset) { d.set({ timezoneOffset: this.timezoneOffset }); } return d; }, finish: function (x) { var today, expression, orient, temp; x = (x instanceof Array) ? flattenAndCompact(x) : [ x ]; if (x.length === 0) { return null; } for (var i = 0 ; i < x.length ; i++) { if (typeof x[i] === "function") { x[i].call(this); } } if (this.now && !this.unit && !this.operator) { return new Date(); } else { today = finishUtils.getToday.call(this); } expression = !!(this.days && this.days !== null || this.orient || this.operator); orient = ((this.orient === "past" || this.operator === "subtract") ? -1 : 1); if (this.month && this.unit === "week") { this.value = this.month + 1; delete this.month; delete this.day; } if ((this.month || this.month === 0) && "year day hour minute second".indexOf(this.unit) !== -1) { if (!this.value) { this.value = this.month + 1; } this.month = null; expression = true; } if (!expression && this.weekday && !this.day && !this.days) { finishUtils.setDMYFromWeekday.call(this); } if (expression && this.weekday && this.unit !== "month" && this.unit !== "week") { finishUtils.setDaysFromWeekday.call(this, today, orient); } if (this.weekday && this.unit !== "week" && !this.day && !this.days) { temp = Date[this.weekday](); this.day = temp.getDate(); if (temp.getMonth() !== today.getMonth()) { this.month = temp.getMonth(); } } if (this.month && this.unit === "day" && this.operator) { if (!this.value) { this.value = (this.month + 1); } this.month = null; } if (this.value != null && this.month != null && this.year != null) { this.day = this.value * 1; } if (this.month && !this.day && this.value) { today.set({ day: this.value * 1 }); if (!expression) { this.day = this.value * 1; } } if (!this.month && this.value && this.unit === "month" && !this.now) { this.month = this.value; expression = true; } if (expression && (this.month || this.month === 0) && this.unit !== "year") { finishUtils.setMonthsFromMonth.call(this, today, orient); } if (!this.unit) { this.unit = "day"; } finishUtils.setUnitValue.call(this, orient); parseMeridian.call(this); if ((this.month || this.month === 0) && !this.day) { this.day = 1; } if (!this.orient && !this.operator && this.unit === "week" && this.value && !this.day && !this.month) { return Date.today().setWeek(this.value); } if (this.unit === "week" && this.weeks && !this.day && !this.month) { return finishUtils.generateDateFromWeeks.call(this); } if (expression && this.timezone && this.day && this.days) { this.day = this.days; } if (expression){ today.add(this); } else { today.set(this); } if (this.timezone) { this.timezone = this.timezone.toUpperCase(); var offset = $D.getTimezoneOffset(this.timezone); var timezone; if (today.hasDaylightSavingTime()) { // lets check that we're being sane with timezone setting timezone = $D.getTimezoneAbbreviation(offset, today.isDaylightSavingTime()); if (timezone !== this.timezone) { // bugger, we're in a place where things like EST vs EDT matters. if (today.isDaylightSavingTime()) { today.addHours(-1); } else { today.addHours(1); } } } today.setTimezoneOffset(offset); } return today; } }; }()); (function () { var $D = Date; $D.Grammar = {}; var _ = $D.Parsing.Operators, g = $D.Grammar, t = $D.Translator, _fn; // Allow rolling up into general purpose rules _fn = function () { return _.each(_.any.apply(null, arguments), _.not(g.ctoken2("timeContext"))); }; g.datePartDelimiter = _.rtoken(/^([\s\-\.\,\/\x27]+)/); g.timePartDelimiter = _.stoken(":"); g.whiteSpace = _.rtoken(/^\s*/); g.generalDelimiter = _.rtoken(/^(([\s\,]|at|@|on)+)/); var _C = {}; g.ctoken = function (keys) { var fn = _C[keys]; if (! fn) { var c = Date.CultureInfo.regexPatterns; var kx = keys.split(/\s+/), px = []; for (var i = 0; i < kx.length ; i++) { px.push(_.replace(_.rtoken(c[kx[i]]), kx[i])); } fn = _C[keys] = _.any.apply(null, px); } return fn; }; g.ctoken2 = function (key) { return _.rtoken(Date.CultureInfo.regexPatterns[key]); }; var cacheProcessRtoken = function (key, token, type, eachToken) { if (eachToken) { g[key] = _.cache(_.process(_.each(_.rtoken(token),_.optional(g.ctoken2(eachToken))), type)); } else { g[key] = _.cache(_.process(_.rtoken(token), type)); } }; var cacheProcessCtoken = function (token, type) { return _.cache(_.process(g.ctoken2(token), type)); }; var _F = {}; //function cache var _get = function (f) { _F[f] = (_F[f] || g.format(f)[0]); return _F[f]; }; g.allformats = function (fx) { var rx = []; if (fx instanceof Array) { for (var i = 0; i < fx.length; i++) { rx.push(_get(fx[i])); } } else { rx.push(_get(fx)); } return rx; }; g.formats = function (fx) { if (fx instanceof Array) { var rx = []; for (var i = 0 ; i < fx.length ; i++) { rx.push(_get(fx[i])); } return _.any.apply(null, rx); } else { return _get(fx); } }; var grammarFormats = { timeFormats: function(){ var i, RTokenKeys = [ "h", "hh", "H", "HH", "m", "mm", "s", "ss", "ss.s", "z", "zz" ], RToken = [ /^(0[0-9]|1[0-2]|[1-9])/, /^(0[0-9]|1[0-2])/, /^([0-1][0-9]|2[0-3]|[0-9])/, /^([0-1][0-9]|2[0-3])/, /^([0-5][0-9]|[0-9])/, /^[0-5][0-9]/, /^([0-5][0-9]|[0-9])/, /^[0-5][0-9]/, /^[0-5][0-9]\.[0-9]{1,3}/, /^((\+|\-)\s*\d\d\d\d)|((\+|\-)\d\d\:?\d\d)/, /^((\+|\-)\s*\d\d\d\d)|((\+|\-)\d\d\:?\d\d)/ ], tokens = [ t.hour, t.hour, t.hour, t.hour, t.minute, t.minute, t.second, t.second, t.secondAndMillisecond, t.timezone, t.timezone ]; for (i=0; i < RTokenKeys.length; i++) { cacheProcessRtoken(RTokenKeys[i], RToken[i], tokens[i]); } g.hms = _.cache(_.sequence([g.H, g.m, g.s], g.timePartDelimiter)); g.t = cacheProcessCtoken("shortMeridian", t.meridian); g.tt = cacheProcessCtoken("longMeridian", t.meridian); g.zzz = cacheProcessCtoken("timezone", t.timezone); g.timeSuffix = _.each(_.ignore(g.whiteSpace), _.set([ g.tt, g.zzz ])); g.time = _.each(_.optional(_.ignore(_.stoken("T"))), g.hms, g.timeSuffix); }, dateFormats: function () { // pre-loaded rules for different date part order preferences var _setfn = function () { return _.set(arguments, g.datePartDelimiter); }; var i, RTokenKeys = [ "d", "dd", "M", "MM", "y", "yy", "yyy", "yyyy" ], RToken = [ /^([0-2]\d|3[0-1]|\d)/, /^([0-2]\d|3[0-1])/, /^(1[0-2]|0\d|\d)/, /^(1[0-2]|0\d)/, /^(\d+)/, /^(\d\d)/, /^(\d\d?\d?\d?)/, /^(\d\d\d\d)/ ], tokens = [ t.day, t.day, t.month, t.month, t.year, t.year, t.year, t.year ], eachToken = [ "ordinalSuffix", "ordinalSuffix" ]; for (i=0; i < RTokenKeys.length; i++) { cacheProcessRtoken(RTokenKeys[i], RToken[i], tokens[i], eachToken[i]); } g.MMM = g.MMMM = _.cache(_.process(g.ctoken("jan feb mar apr may jun jul aug sep oct nov dec"), t.month)); g.ddd = g.dddd = _.cache(_.process(g.ctoken("sun mon tue wed thu fri sat"), function (s) { return function () { this.weekday = s; }; } )); g.day = _fn(g.d, g.dd); g.month = _fn(g.M, g.MMM); g.year = _fn(g.yyyy, g.yy); g.mdy = _setfn(g.ddd, g.month, g.day, g.year); g.ymd = _setfn(g.ddd, g.year, g.month, g.day); g.dmy = _setfn(g.ddd, g.day, g.month, g.year); g.date = function (s) { return ((g[Date.CultureInfo.dateElementOrder] || g.mdy).call(this, s)); }; }, relative: function () { // relative date / time expressions g.orientation = _.process(g.ctoken("past future"), function (s) { return function () { this.orient = s; }; } ); g.operator = _.process(g.ctoken("add subtract"), function (s) { return function () { this.operator = s; }; } ); g.rday = _.process(g.ctoken("yesterday tomorrow today now"), t.rday); g.unit = _.process(g.ctoken("second minute hour day week month year"), function (s) { return function () { this.unit = s; }; } ); } }; g.buildGrammarFormats = function () { // these need to be rebuilt every time the language changes. _C = {}; grammarFormats.timeFormats(); grammarFormats.dateFormats(); grammarFormats.relative(); g.value = _.process(_.rtoken(/^([-+]?\d+)?(st|nd|rd|th)?/), function (s) { return function () { this.value = s.replace(/\D/g, ""); }; } ); g.expression = _.set([g.rday, g.operator, g.value, g.unit, g.orientation, g.ddd, g.MMM ]); g.format = _.process(_.many( _.any( // translate format specifiers into grammar rules _.process( _.rtoken(/^(dd?d?d?(?!e)|MM?M?M?|yy?y?y?|hh?|HH?|mm?|ss?|tt?|zz?z?)/), function (fmt) { if (g[fmt]) { return g[fmt]; } else { throw $D.Parsing.Exception(fmt); } } ), // translate separator tokens into token rules _.process(_.rtoken(/^[^dMyhHmstz]+/), // all legal separators function (s) { return _.ignore(_.stoken(s)); } ) ) ), // construct the parser ... function (rules) { return _.process(_.each.apply(null, rules), t.finishExact); } ); // starting rule for general purpose grammar g._start = _.process(_.set([ g.date, g.time, g.expression ], g.generalDelimiter, g.whiteSpace), t.finish); }; g.buildGrammarFormats(); // parsing date format specifiers - ex: "h:m:s tt" // this little guy will generate a custom parser based // on the format string, ex: g.format("h:m:s tt") // check for these formats first g._formats = g.formats([ "\"yyyy-MM-ddTHH:mm:ssZ\"", "yyyy-MM-ddTHH:mm:ss.sz", "yyyy-MM-ddTHH:mm:ssZ", "yyyy-MM-ddTHH:mm:ssz", "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-ddTHH:mmZ", "yyyy-MM-ddTHH:mmz", "yyyy-MM-ddTHH:mm", "ddd, MMM dd, yyyy H:mm:ss tt", "ddd MMM d yyyy HH:mm:ss zzz", "MMddyyyy", "ddMMyyyy", "Mddyyyy", "ddMyyyy", "Mdyyyy", "dMyyyy", "yyyy", "Mdyy", "dMyy", "d" ]); // real starting rule: tries selected formats first, // then general purpose rule g.start = function (s) { try { var r = g._formats.call({}, s); if (r[1].length === 0) { return r; } } catch (e) {} return g._start.call({}, s); }; }()); (function () { var $D = Date; /** * @desc Converts the specified string value into its JavaScript Date equivalent using CultureInfo specific format information. * * Example

	///////////
	// Dates //
	///////////

	// 15-Oct-2004
	var d1 = Date.parse("10/15/2004");

	// 15-Oct-2004
	var d1 = Date.parse("15-Oct-2004");

	// 15-Oct-2004
	var d1 = Date.parse("2004.10.15");

	//Fri Oct 15, 2004
	var d1 = Date.parse("Fri Oct 15, 2004");

	///////////
	// Times //
	///////////

	// Today at 10 PM.
	var d1 = Date.parse("10 PM");

	// Today at 10:30 PM.
	var d1 = Date.parse("10:30 P.M.");

	// Today at 6 AM.
	var d1 = Date.parse("06am");

	/////////////////////
	// Dates and Times //
	/////////////////////

	// 8-July-2004 @ 10:30 PM
	var d1 = Date.parse("July 8th, 2004, 10:30 PM");

	// 1-July-2004 @ 10:30 PM
	var d1 = Date.parse("2004-07-01T22:30:00");

	////////////////////
	// Relative Dates //
	////////////////////

	// Returns today's date. The string "today" is culture specific.
	var d1 = Date.parse("today");

	// Returns yesterday's date. The string "yesterday" is culture specific.
	var d1 = Date.parse("yesterday");

	// Returns the date of the next thursday.
	var d1 = Date.parse("Next thursday");

	// Returns the date of the most previous monday.
	var d1 = Date.parse("last monday");

	// Returns today's day + one year.
	var d1 = Date.parse("next year");

	///////////////
	// Date Math //
	///////////////

	// Today + 2 days
	var d1 = Date.parse("t+2");

	// Today + 2 days
	var d1 = Date.parse("today + 2 days");

	// Today + 3 months
	var d1 = Date.parse("t+3m");

	// Today - 1 year
	var d1 = Date.parse("today - 1 year");

	// Today - 1 year
	var d1 = Date.parse("t-1y"); 


	/////////////////////////////
	// Partial Dates and Times //
	/////////////////////////////

	// July 15th of this year.
	var d1 = Date.parse("July 15");

	// 15th day of current day and year.
	var d1 = Date.parse("15");

	// July 1st of current year at 10pm.
	var d1 = Date.parse("7/1 10pm");
	
* * @param {String} The string value to convert into a Date object [Required] * @return {Date} A Date object or null if the string cannot be converted into a Date. */ var parseUtils = { removeOrds: function (s) { ords = s.match(/\b(\d+)(?:st|nd|rd|th)\b/); // find ordinal matches s = ((ords && ords.length === 2) ? s.replace(ords[0], ords[1]) : s); return s; }, grammarParser: function (s) { var r = null; try { r = $D.Grammar.start.call({}, s.replace(/^\s*(\S*(\s+\S+)*)\s*$/, "$1")); } catch (e) { return null; } return ((r[1].length === 0) ? r[0] : null); }, nativeFallback: function(s) { var t; try { // ok we haven't parsed it, last ditch attempt with the built-in parser. t = Date._parse(s); return (t || t === 0) ? new Date(t) : null; } catch (e) { return null; } } }; function parse (s) { var d; if (!s) { return null; } if (s instanceof Date) { return s.clone(); } if (s.length >= 4 && s.charAt(0) !== "0" && s.charAt(0) !== "+"&& s.charAt(0) !== "-") { // ie: 2004 will pass, 0800 won't. // Start with specific formats d = $D.Parsing.ISO.parse(s) || $D.Parsing.Numeric.parse(s); } if (d instanceof Date && !isNaN(d.getTime())) { return d; } else { // find ordinal dates (1st, 3rd, 8th, etc and remove them as they cause parsing issues) s = $D.Parsing.Normalizer.parse(parseUtils.removeOrds(s)); d = parseUtils.grammarParser(s); if (d !== null) { return d; } else { return parseUtils.nativeFallback(s); } } } if (!$D._parse) { $D._parse = $D.parse; } $D.parse = parse; Date.getParseFunction = function (fx) { var fns = Date.Grammar.allformats(fx); return function (s) { var r = null; for (var i = 0; i < fns.length; i++) { try { r = fns[i].call({}, s); } catch (e) { continue; } if (r[1].length === 0) { return r[0]; } } return null; }; }; /** * Converts the specified string value into its JavaScript Date equivalent using the specified format {String} or formats {Array} and the CultureInfo specific format information. * The format of the string value must match one of the supplied formats exactly. * * Example

	// 15-Oct-2004
	var d1 = Date.parseExact("10/15/2004", "M/d/yyyy");

	// 15-Oct-2004
	var d1 = Date.parse("15-Oct-2004", "M-ddd-yyyy");

	// 15-Oct-2004
	var d1 = Date.parse("2004.10.15", "yyyy.MM.dd");

	// Multiple formats
	var d1 = Date.parseExact("10/15/2004", ["M/d/yyyy", "MMMM d, yyyy"]);
	
* * @param {String} The string value to convert into a Date object [Required]. * @param {Object} The expected format {String} or an array of expected formats {Array} of the date string [Required]. * @return {Date} A Date object or null if the string cannot be converted into a Date. */ $D.parseExact = function (s, fx) { return $D.getParseFunction(fx)(s); }; }()); (function () { var $D = Date, $P = $D.prototype, // $C = $D.CultureInfo, // not used atm p = function (s, l) { if (!l) { l = 2; } return ("000" + s).slice(l * -1); }; /** * Converts a PHP format string to Java/.NET format string. * A PHP format string can be used with ._format or .format. * A Java/.NET format string can be used with .toString(). * The .parseExact function will only accept a Java/.NET format string * * Example * var f1 = "%m/%d/%y" * var f2 = Date.normalizeFormat(f1); // "MM/dd/yy" * * new Date().format(f1); // "04/13/08" * new Date()._format(f1); // "04/13/08" * new Date().toString(f2); // "04/13/08" * * var date = Date.parseExact("04/13/08", f2); // Sun Apr 13 2008 * * @param {String} A PHP format string consisting of one or more format spcifiers. * @return {String} The PHP format converted to a Java/.NET format string. */ var normalizerSubstitutions = { "d" : "dd", "%d": "dd", "D" : "ddd", "%a": "ddd", "j" : "dddd", "l" : "dddd", "%A": "dddd", "S" : "S", "F" : "MMMM", "%B": "MMMM", "m" : "MM", "%m": "MM", "M" : "MMM", "%b": "MMM", "%h": "MMM", "n" : "M", "Y" : "yyyy", "%Y": "yyyy", "y" : "yy", "%y": "yy", "g" : "h", "%I": "h", "G" : "H", "h" : "hh", "H" : "HH", "%H": "HH", "i" : "mm", "%M": "mm", "s" : "ss", "%S": "ss", "%r": "hh:mm tt", "%R": "H:mm", "%T": "H:mm:ss", "%X": "t", "%x": "d", "%e": "d", "%D": "MM/dd/yy", "%n": "\\n", "%t": "\\t", "e" : "z", "T" : "z", "%z": "z", "%Z": "z", "Z" : "ZZ", "N" : "u", "w" : "u", "%w": "u", "W" : "W", "%V": "W" }; var normalizer = { substitutes: function (m) { return normalizerSubstitutions[m]; }, interpreted: function (m, x) { var y; switch (m) { case "%u": return x.getDay() + 1; case "z": return x.getOrdinalNumber(); case "%j": return p(x.getOrdinalNumber(), 3); case "%U": var d1 = x.clone().set({month: 0, day: 1}).addDays(-1).moveToDayOfWeek(0), d2 = x.clone().addDays(1).moveToDayOfWeek(0, -1); return (d2 < d1) ? "00" : p((d2.getOrdinalNumber() - d1.getOrdinalNumber()) / 7 + 1); case "%W": return p(x.getWeek()); case "t": return $D.getDaysInMonth(x.getFullYear(), x.getMonth()); case "o": case "%G": return x.setWeek(x.getISOWeek()).toString("yyyy"); case "%g": return x._format("%G").slice(-2); case "a": case "%p": return t("tt").toLowerCase(); case "A": return t("tt").toUpperCase(); case "u": return p(x.getMilliseconds(), 3); case "I": return (x.isDaylightSavingTime()) ? 1 : 0; case "O": return x.getUTCOffset(); case "P": y = x.getUTCOffset(); return y.substring(0, y.length - 2) + ":" + y.substring(y.length - 2); case "B": var now = new Date(); return Math.floor(((now.getHours() * 3600) + (now.getMinutes() * 60) + now.getSeconds() + (now.getTimezoneOffset() + 60) * 60) / 86.4); case "c": return x.toISOString().replace(/\"/g, ""); case "U": return $D.strtotime("now"); case "%c": return t("d") + " " + t("t"); case "%C": return Math.floor(x.getFullYear() / 100 + 1); } }, shouldOverrideDefaults: function (m) { switch (m) { case "%e": return true; default: return false; } }, parse: function (m, context) { var formatString, c = context || new Date(); formatString = normalizer.substitutes(m); if (formatString) { return formatString; } formatString = normalizer.interpreted(m, c); if (formatString) { return formatString; } else { return m; } } }; $D.normalizeFormat = function (format, context) { return format.replace(/(%|\\)?.|%%/g, function(t){ return normalizer.parse(t, context); }); }; /** * Format a local Unix timestamp according to locale settings * * Example: * Date.strftime("%m/%d/%y", new Date()); // "04/13/08" * Date.strftime("c", "2008-04-13T17:52:03Z"); // "04/13/08" * * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @param {Number|String} The number representing the number of seconds that have elapsed since January 1, 1970 (local time). * @return {String} A string representation of the current Date object. */ $D.strftime = function (format, time) { var d = Date.parse(time); return d._format(format); }; /** * Parse any textual datetime description into a Unix timestamp. * A Unix timestamp is the number of seconds that have elapsed since January 1, 1970 (midnight UTC/GMT). * * Example: * Date.strtotime("04/13/08"); // 1208044800 * Date.strtotime("1970-01-01T00:00:00Z"); // 0 * * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @param {Object} A string or date object. * @return {String} A string representation of the current Date object. */ $D.strtotime = function (time) { var d = $D.parse(time); return Math.round($D.UTC(d.getUTCFullYear(), d.getUTCMonth(), d.getUTCDate(), d.getUTCHours(), d.getUTCMinutes(), d.getUTCSeconds(), d.getUTCMilliseconds()) / 1000); }; /** * Converts the value of the current Date object to its equivalent string representation using a PHP/Unix style of date format specifiers. * Format Specifiers * Format Description Example * ------ --------------------------------------------------------------------------- ----------------------- * %a abbreviated weekday name according to the current localed "Mon" through "Sun" * %A full weekday name according to the current localed "Sunday" through "Saturday" * %b abbreviated month name according to the current localed "Jan" through "Dec" * %B full month name according to the current locale "January" through "December" * %c preferred date and time representation for the current locale "4/13/2008 12:33 PM" * %C century number (the year divided by 100 and truncated to an integer) "00" to "99" * %d day of the month as a decimal number "01" to "31" * %D same as %m/%d/%y "04/13/08" * %e day of the month as a decimal number, a single digit is preceded by a space "1" to "31" * %g like %G, but without the century "08" * %G The 4-digit year corresponding to the ISO week number (see %V). "2008" * This has the same format and value as %Y, except that if the ISO week number * belongs to the previous or next year, that year is used instead. * %h same as %b "Jan" through "Dec" * %H hour as a decimal number using a 24-hour clock. "00" to "23" * %I hour as a decimal number using a 12-hour clock. "01" to "12" * %j day of the year as a decimal number. "001" to "366" * %m month as a decimal number. "01" to "12" * %M minute as a decimal number. "00" to "59" * %n newline character "\n" * %p either "am" or "pm" according to the given time value, or the "am" or "pm" * corresponding strings for the current locale. * %r time in a.m. and p.m. notation "8:44 PM" * %R time in 24 hour notation "20:44" * %S second as a decimal number "00" to "59" * %t tab character "\t" * %T current time, equal to %H:%M:%S "12:49:11" * %u weekday as a decimal number ["1", "7"], with "1" representing Monday "1" to "7" * %U week number of the current year as a decimal number, starting with the "0" to ("52" or "53") * first Sunday as the first day of the first week * %V The ISO 8601:1988 week number of the current year as a decimal number, "00" to ("52" or "53") * range 01 to 53, where week 1 is the first week that has at least 4 days * in the current year, and with Monday as the first day of the week. * (Use %G or %g for the year component that corresponds to the week number * for the specified timestamp.) * %W week number of the current year as a decimal number, starting with the "00" to ("52" or "53") * first Monday as the first day of the first week * %w day of the week as a decimal, Sunday being "0" "0" to "6" * %x preferred date representation for the current locale without the time "4/13/2008" * %X preferred time representation for the current locale without the date "12:53:05" * %y year as a decimal number without a century "00" "99" * %Y year as a decimal number including the century "2008" * %Z time zone or name or abbreviation "UTC", "EST", "PST" * %z same as %Z * %% a literal "%" characters "%" * d Day of the month, 2 digits with leading zeros "01" to "31" * D A textual representation of a day, three letters "Mon" through "Sun" * j Day of the month without leading zeros "1" to "31" * l A full textual representation of the day of the week (lowercase "L") "Sunday" through "Saturday" * N ISO-8601 numeric representation of the day of the week (added in PHP 5.1.0) "1" (for Monday) through "7" (for Sunday) * S English ordinal suffix for the day of the month, 2 characters "st", "nd", "rd" or "th". Works well with j * w Numeric representation of the day of the week "0" (for Sunday) through "6" (for Saturday) * z The day of the year (starting from "0") "0" through "365" * W ISO-8601 week number of year, weeks starting on Monday "00" to ("52" or "53") * F A full textual representation of a month, such as January or March "January" through "December" * m Numeric representation of a month, with leading zeros "01" through "12" * M A short textual representation of a month, three letters "Jan" through "Dec" * n Numeric representation of a month, without leading zeros "1" through "12" * t Number of days in the given month "28" through "31" * L Whether it's a leap year "1" if it is a leap year, "0" otherwise * o ISO-8601 year number. This has the same value as Y, except that if the "2008" * ISO week number (W) belongs to the previous or next year, that year * is used instead. * Y A full numeric representation of a year, 4 digits "2008" * y A two digit representation of a year "08" * a Lowercase Ante meridiem and Post meridiem "am" or "pm" * A Uppercase Ante meridiem and Post meridiem "AM" or "PM" * B Swatch Internet time "000" through "999" * g 12-hour format of an hour without leading zeros "1" through "12" * G 24-hour format of an hour without leading zeros "0" through "23" * h 12-hour format of an hour with leading zeros "01" through "12" * H 24-hour format of an hour with leading zeros "00" through "23" * i Minutes with leading zeros "00" to "59" * s Seconds, with leading zeros "00" through "59" * u Milliseconds "54321" * e Timezone identifier "UTC", "EST", "PST" * I Whether or not the date is in daylight saving time (uppercase i) "1" if Daylight Saving Time, "0" otherwise * O Difference to Greenwich time (GMT) in hours "+0200", "-0600" * P Difference to Greenwich time (GMT) with colon between hours and minutes "+02:00", "-06:00" * T Timezone abbreviation "UTC", "EST", "PST" * Z Timezone offset in seconds. The offset for timezones west of UTC is "-43200" through "50400" * always negative, and for those east of UTC is always positive. * c ISO 8601 date "2004-02-12T15:19:21+00:00" * r RFC 2822 formatted date "Thu, 21 Dec 2000 16:01:07 +0200" * U Seconds since the Unix Epoch (January 1 1970 00:00:00 GMT) "0" * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @return {String} A string representation of the current Date object. */ var formatReplace = function (context) { return function (m) { var formatString, override = false; if (m.charAt(0) === "\\" || m.substring(0, 2) === "%%") { return m.replace("\\", "").replace("%%", "%"); } override = normalizer.shouldOverrideDefaults(m); formatString = $D.normalizeFormat(m, context); if (formatString) { return context.toString(formatString, override); } }; }; $P._format = function (format) { var formatter = formatReplace(this); if (!format) { return this._toString(); } else { return format.replace(/(%|\\)?.|%%/g, formatter); } }; if (!$P.format) { $P.format = $P._format; } }()); (function () { "use strict"; var gFn = function (attr) { return function () { return this[attr]; }; }; var sFn = function (attr) { return function (val) { this[attr] = val; return this; }; }; var attrs = ["years", "months", "days", "hours", "minutes", "seconds", "milliseconds"]; var addSetFuncs = function (context, attrs) { for (var i = 0; i < attrs.length ; i++) { var $a = attrs[i], $b = $a.slice(0, 1).toUpperCase() + $a.slice(1); context.prototype[$a] = 0; context.prototype["get" + $b] = gFn($a); context.prototype["set" + $b] = sFn($a); } }; /** * new TimeSpan(milliseconds); * new TimeSpan(days, hours, minutes, seconds); * new TimeSpan(days, hours, minutes, seconds, milliseconds); */ var TimeSpan = function (days, hours, minutes, seconds, milliseconds) { if (arguments.length === 1 && typeof days === "number") { var orient = (days < 0) ? -1 : +1; var millsLeft = Math.abs(days); this.setDays(Math.floor(millsLeft / 86400000) * orient); millsLeft = millsLeft % 86400000; this.setHours(Math.floor(millsLeft / 3600000) * orient); millsLeft = millsLeft % 3600000; this.setMinutes(Math.floor(millsLeft / 60000) * orient); millsLeft = millsLeft % 60000; this.setSeconds(Math.floor(millsLeft / 1000) * orient); millsLeft = millsLeft % 1000; this.setMilliseconds(millsLeft * orient); } else { this.set(days, hours, minutes, seconds, milliseconds); } this.getTotalMilliseconds = function () { return (this.getDays() * 86400000) + (this.getHours() * 3600000) + (this.getMinutes() * 60000) + (this.getSeconds() * 1000); }; this.compareTo = function (time) { var t1 = new Date(1970, 1, 1, this.getHours(), this.getMinutes(), this.getSeconds()), t2; if (time === null) { t2 = new Date(1970, 1, 1, 0, 0, 0); } else { t2 = new Date(1970, 1, 1, time.getHours(), time.getMinutes(), time.getSeconds()); } return (t1 < t2) ? -1 : (t1 > t2) ? 1 : 0; }; this.equals = function (time) { return (this.compareTo(time) === 0); }; this.add = function (time) { return (time === null) ? this : this.addSeconds(time.getTotalMilliseconds() / 1000); }; this.subtract = function (time) { return (time === null) ? this : this.addSeconds(-time.getTotalMilliseconds() / 1000); }; this.addDays = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 86400000)); }; this.addHours = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 3600000)); }; this.addMinutes = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 60000)); }; this.addSeconds = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 1000)); }; this.addMilliseconds = function (n) { return new TimeSpan(this.getTotalMilliseconds() + n); }; this.get12HourHour = function () { return (this.getHours() > 12) ? this.getHours() - 12 : (this.getHours() === 0) ? 12 : this.getHours(); }; this.getDesignator = function () { return (this.getHours() < 12) ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator; }; this.toString = function (format) { this._toString = function () { if (this.getDays() !== null && this.getDays() > 0) { return this.getDays() + "." + this.getHours() + ":" + this.p(this.getMinutes()) + ":" + this.p(this.getSeconds()); } else { return this.getHours() + ":" + this.p(this.getMinutes()) + ":" + this.p(this.getSeconds()); } }; this.p = function (s) { return (s.toString().length < 2) ? "0" + s : s; }; var me = this; return format ? format.replace(/dd?|HH?|hh?|mm?|ss?|tt?/g, function (format) { switch (format) { case "d": return me.getDays(); case "dd": return me.p(me.getDays()); case "H": return me.getHours(); case "HH": return me.p(me.getHours()); case "h": return me.get12HourHour(); case "hh": return me.p(me.get12HourHour()); case "m": return me.getMinutes(); case "mm": return me.p(me.getMinutes()); case "s": return me.getSeconds(); case "ss": return me.p(me.getSeconds()); case "t": return ((me.getHours() < 12) ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator).substring(0, 1); case "tt": return (me.getHours() < 12) ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator; } } ) : this._toString(); }; return this; }; addSetFuncs(TimeSpan, attrs.slice(2)); TimeSpan.prototype.set = function (days, hours, minutes, seconds, milliseconds){ this.setDays(days || this.getDays()); this.setHours(hours || this.getHours()); this.setMinutes(minutes || this.getMinutes()); this.setSeconds(seconds || this.getSeconds()); this.setMilliseconds(milliseconds || this.getMilliseconds()); }; /** * Gets the time of day for this date instances. * @return {TimeSpan} TimeSpan */ Date.prototype.getTimeOfDay = function () { return new TimeSpan(0, this.getHours(), this.getMinutes(), this.getSeconds(), this.getMilliseconds()); }; Date.TimeSpan = TimeSpan; if (typeof window !== "undefined" ) { // keeping API compatible for v1.x window.TimeSpan = TimeSpan; } }()); (function () { "use strict"; var attrs = ["years", "months", "days", "hours", "minutes", "seconds", "milliseconds"]; var gFn = function (attr) { return function () { return this[attr]; }; }; var sFn = function (attr) { return function (val) { this[attr] = val; return this; }; }; var addSetFuncs = function (context, attrs) { for (var i = 0; i < attrs.length ; i++) { var $a = attrs[i], $b = $a.slice(0, 1).toUpperCase() + $a.slice(1); context.prototype[$a] = 0; context.prototype["get" + $b] = gFn($a); context.prototype["set" + $b] = sFn($a); } }; var setMonthsAndYears = function (orient, d1, d2, context) { function inc() { d1.addMonths(-orient); context.months++; if (context.months === 12) { context.years++; context.months = 0; } } if (orient === +1) { while (d1 > d2) { inc(); } } else { while (d1 < d2) { inc(); } } context.months--; context.months *= orient; context.years *= orient; }; var adjustForDST = function(orient, startDate, endDate) { var hasDSTMismatch = (false === (startDate.isDaylightSavingTime() === endDate.isDaylightSavingTime())); if (hasDSTMismatch && orient === 1) { startDate.addHours(-1); } else if (hasDSTMismatch) { startDate.addHours(1); } }; /** * TimePeriod(startDate, endDate); * TimePeriod(years, months, days, hours, minutes, seconds, milliseconds); */ var TimePeriod = function (years, months, days, hours, minutes, seconds, milliseconds) { if (arguments.length === 7) { this.set(years, months, days, hours, minutes, seconds, milliseconds); } else if (arguments.length === 2 && arguments[0] instanceof Date && arguments[1] instanceof Date) { var startDate = arguments[0].clone(); var endDate = arguments[1].clone(); var orient = (startDate > endDate) ? +1 : -1; this.dates = { start: arguments[0].clone(), end: arguments[1].clone() }; setMonthsAndYears(orient, startDate, endDate, this); adjustForDST(orient, startDate, endDate); // // TODO - adjust for DST var diff = endDate - startDate; if (diff !== 0) { var ts = new TimeSpan(diff); this.set(this.years, this.months, ts.getDays(), ts.getHours(), ts.getMinutes(), ts.getSeconds(), ts.getMilliseconds()); } } return this; }; // create all the set functions. addSetFuncs(TimePeriod, attrs); TimePeriod.prototype.set = function (years, months, days, hours, minutes, seconds, milliseconds){ this.setYears(years || this.getYears()); this.setMonths(months || this.getMonths()); this.setDays(days || this.getDays()); this.setHours(hours || this.getHours()); this.setMinutes(minutes || this.getMinutes()); this.setSeconds(seconds || this.getSeconds()); this.setMilliseconds(milliseconds || this.getMilliseconds()); }; Date.TimePeriod = TimePeriod; if (typeof window !== "undefined") { // keeping API compatible for v1.x window.TimePeriod = TimePeriod; } }()); ================================================ FILE: build/date-es-DO.js ================================================ /** * @overview datejs * @version 1.0.0-rc3 * @author Gregory Wild-Smith * @copyright 2015 Gregory Wild-Smith * @license MIT * @homepage https://github.com/abritinthebay/datejs */ /* * DateJS Culture String File * Country Code: es-DO * Name: Spanish (Dominican Republic) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["es-DO"] = { "name": "es-DO", "englishName": "Spanish (Dominican Republic)", "nativeName": "Español (República Dominicana)", "Sunday": "domingo", "Monday": "lunes", "Tuesday": "martes", "Wednesday": "miércoles", "Thursday": "jueves", "Friday": "viernes", "Saturday": "sábado", "Sun": "dom", "Mon": "lun", "Tue": "mar", "Wed": "mié", "Thu": "jue", "Fri": "vie", "Sat": "sáb", "Su": "do", "Mo": "lu", "Tu": "ma", "We": "mi", "Th": "ju", "Fr": "vi", "Sa": "sá", "S_Sun_Initial": "d", "M_Mon_Initial": "l", "T_Tue_Initial": "m", "W_Wed_Initial": "m", "T_Thu_Initial": "j", "F_Fri_Initial": "v", "S_Sat_Initial": "s", "January": "enero", "February": "febrero", "March": "marzo", "April": "abril", "May": "mayo", "June": "junio", "July": "julio", "August": "agosto", "September": "septiembre", "October": "octubre", "November": "noviembre", "December": "diciembre", "Jan_Abbr": "ene", "Feb_Abbr": "feb", "Mar_Abbr": "mar", "Apr_Abbr": "abr", "May_Abbr": "may", "Jun_Abbr": "jun", "Jul_Abbr": "jul", "Aug_Abbr": "ago", "Sep_Abbr": "sep", "Oct_Abbr": "oct", "Nov_Abbr": "nov", "Dec_Abbr": "dic", "AM": "a.m.", "PM": "p.m.", "firstDayOfWeek": 0, "twoDigitYearMax": 2029, "mdy": "dmy", "M/d/yyyy": "dd/MM/yyyy", "dddd, MMMM dd, yyyy": "dddd, dd' [de] 'MMMM' [de] 'yyyy", "h:mm tt": "hh:mm tt", "h:mm:ss tt": "hh:mm:ss tt", "dddd, MMMM dd, yyyy h:mm:ss tt": "dddd, dd' [de] 'MMMM' [de] 'yyyy hh:mm:ss tt", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "dd MMMM", "MMMM, yyyy": "MMMM' [de] 'yyyy", "/jan(uary)?/": "ene(ro)?", "/feb(ruary)?/": "feb(rero)?", "/mar(ch)?/": "mar(zo)?", "/apr(il)?/": "abr(il)?", "/may/": "may(o)?", "/jun(e)?/": "jun(io)?", "/jul(y)?/": "jul(io)?", "/aug(ust)?/": "ago(sto)?", "/sep(t(ember)?)?/": "sep(tiembre)?", "/oct(ober)?/": "oct(ubre)?", "/nov(ember)?/": "nov(iembre)?", "/dec(ember)?/": "dic(iembre)?", "/^su(n(day)?)?/": "^do(m(ingo)?)?", "/^mo(n(day)?)?/": "^lu(n(es)?)?", "/^tu(e(s(day)?)?)?/": "^ma(r(tes)?)?", "/^we(d(nesday)?)?/": "^mi(é(rcoles)?)?", "/^th(u(r(s(day)?)?)?)?/": "^ju(e(ves)?)?", "/^fr(i(day)?)?/": "^vi(e(rnes)?)?", "/^sa(t(urday)?)?/": "^sá(b(ado)?)?", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "es-DO"; /** * @overview datejs * @version 1.0.0-rc3 * @author Gregory Wild-Smith * @copyright 2015 Gregory Wild-Smith * @license MIT * @homepage https://github.com/abritinthebay/datejs */(function () { var $D = Date; var lang = Date.CultureStrings ? Date.CultureStrings.lang : null; var loggedKeys = {}; // for debug purposes. var getText = { getFromKey: function (key, countryCode) { var output; if (Date.CultureStrings && Date.CultureStrings[countryCode] && Date.CultureStrings[countryCode][key]) { output = Date.CultureStrings[countryCode][key]; } else { output = getText.buildFromDefault(key); } if (key.charAt(0) === "/") { // Assume it's a regex output = getText.buildFromRegex(key, countryCode); } return output; }, getFromObjectValues: function (obj, countryCode) { var key, output = {}; for(key in obj) { if (obj.hasOwnProperty(key)) { output[key] = getText.getFromKey(obj[key], countryCode); } } return output; }, getFromObjectKeys: function (obj, countryCode) { var key, output = {}; for(key in obj) { if (obj.hasOwnProperty(key)) { output[getText.getFromKey(key, countryCode)] = obj[key]; } } return output; }, getFromArray: function (arr, countryCode) { var output = []; for (var i=0; i < arr.length; i++){ if (i in arr) { output[i] = getText.getFromKey(arr[i], countryCode); } } return output; }, buildFromDefault: function (key) { var output, length, split, last; switch(key) { case "name": output = "en-US"; break; case "englishName": output = "English (United States)"; break; case "nativeName": output = "English (United States)"; break; case "twoDigitYearMax": output = 2049; break; case "firstDayOfWeek": output = 0; break; default: output = key; split = key.split("_"); length = split.length; if (length > 1 && key.charAt(0) !== "/") { // if the key isn't a regex and it has a split. last = split[(length - 1)].toLowerCase(); if (last === "initial" || last === "abbr") { output = split[0]; } } break; } return output; }, buildFromRegex: function (key, countryCode) { var output; if (Date.CultureStrings && Date.CultureStrings[countryCode] && Date.CultureStrings[countryCode][key]) { output = new RegExp(Date.CultureStrings[countryCode][key], "i"); } else { output = new RegExp(key.replace(new RegExp("/", "g"),""), "i"); } return output; } }; var shallowMerge = function (obj1, obj2) { for (var attrname in obj2) { if (obj2.hasOwnProperty(attrname)) { obj1[attrname] = obj2[attrname]; } } }; var __ = function (key, language) { var countryCode = (language) ? language : lang; loggedKeys[key] = key; if (typeof key === "object") { if (key instanceof Array) { return getText.getFromArray(key, countryCode); } else { return getText.getFromObjectKeys(key, countryCode); } } else { return getText.getFromKey(key, countryCode); } }; var loadI18nScript = function (code) { // paatterned after jQuery's getScript. var url = Date.Config.i18n + code + ".js"; var head = document.getElementsByTagName("head")[0] || document.documentElement; var script = document.createElement("script"); script.src = url; var completed = false; var events = { done: function (){} // placeholder function }; // Attach handlers for all browsers script.onload = script.onreadystatechange = function() { if ( !completed && (!this.readyState || this.readyState === "loaded" || this.readyState === "complete") ) { events.done(); head.removeChild(script); } }; setTimeout(function() { head.insertBefore(script, head.firstChild); }, 0); // allows return to execute first return { done: function (cb) { events.done = function() { if (cb) { setTimeout(cb,0); } }; } }; }; var buildInfo = { buildFromMethodHash: function (obj) { var key; for(key in obj) { if (obj.hasOwnProperty(key)) { obj[key] = buildInfo[obj[key]](); } } return obj; }, timeZoneDST: function () { var DST = { "CHADT": "+1345", "NZDT": "+1300", "AEDT": "+1100", "ACDT": "+1030", "AZST": "+0500", "IRDT": "+0430", "EEST": "+0300", "CEST": "+0200", "BST": "+0100", "PMDT": "-0200", "ADT": "-0300", "NDT": "-0230", "EDT": "-0400", "CDT": "-0500", "MDT": "-0600", "PDT": "-0700", "AKDT": "-0800", "HADT": "-0900" }; return __(DST); }, timeZoneStandard: function () { var standard = { "LINT": "+1400", "TOT": "+1300", "CHAST": "+1245", "NZST": "+1200", "NFT": "+1130", "SBT": "+1100", "AEST": "+1000", "ACST": "+0930", "JST": "+0900", "CWST": "+0845", "CT": "+0800", "ICT": "+0700", "MMT": "+0630", "BST": "+0600", "NPT": "+0545", "IST": "+0530", "PKT": "+0500", "AFT": "+0430", "MSK": "+0400", "IRST": "+0330", "FET": "+0300", "EET": "+0200", "CET": "+0100", "GMT": "+0000", "UTC": "+0000", "CVT": "-0100", "GST": "-0200", "BRT": "-0300", "NST": "-0330", "AST": "-0400", "EST": "-0500", "CST": "-0600", "MST": "-0700", "PST": "-0800", "AKST": "-0900", "MIT": "-0930", "HST": "-1000", "SST": "-1100", "BIT": "-1200" }; return __(standard); }, timeZones: function (data) { var zone; data.timezones = []; for (zone in data.abbreviatedTimeZoneStandard) { if (data.abbreviatedTimeZoneStandard.hasOwnProperty(zone)) { data.timezones.push({ name: zone, offset: data.abbreviatedTimeZoneStandard[zone]}); } } for (zone in data.abbreviatedTimeZoneDST) { if (data.abbreviatedTimeZoneDST.hasOwnProperty(zone)) { data.timezones.push({ name: zone, offset: data.abbreviatedTimeZoneDST[zone], dst: true}); } } return data.timezones; }, days: function () { return __(["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"]); }, dayAbbr: function () { return __(["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"]); }, dayShortNames: function () { return __(["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"]); }, dayFirstLetters: function () { return __(["S_Sun_Initial", "M_Mon_Initial", "T_Tues_Initial", "W_Wed_Initial", "T_Thu_Initial", "F_Fri_Initial", "S_Sat_Initial"]); }, months: function () { return __(["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"]); }, monthAbbr: function () { return __(["Jan_Abbr", "Feb_Abbr", "Mar_Abbr", "Apr_Abbr", "May_Abbr", "Jun_Abbr", "Jul_Abbr", "Aug_Abbr", "Sep_Abbr", "Oct_Abbr", "Nov_Abbr", "Dec_Abbr"]); }, formatPatterns: function () { return getText.getFromObjectValues({ shortDate: "M/d/yyyy", longDate: "dddd, MMMM dd, yyyy", shortTime: "h:mm tt", longTime: "h:mm:ss tt", fullDateTime: "dddd, MMMM dd, yyyy h:mm:ss tt", sortableDateTime: "yyyy-MM-ddTHH:mm:ss", universalSortableDateTime: "yyyy-MM-dd HH:mm:ssZ", rfc1123: "ddd, dd MMM yyyy HH:mm:ss", monthDay: "MMMM dd", yearMonth: "MMMM, yyyy" }, Date.i18n.currentLanguage()); }, regex: function () { return getText.getFromObjectValues({ inTheMorning: "/( in the )(morn(ing)?)\\b/", thisMorning: "/(this )(morn(ing)?)\\b/", amThisMorning: "/(\b\\d(am)? )(this )(morn(ing)?)/", inTheEvening: "/( in the )(even(ing)?)\\b/", thisEvening: "/(this )(even(ing)?)\\b/", pmThisEvening: "/(\b\\d(pm)? )(this )(even(ing)?)/", jan: "/jan(uary)?/", feb: "/feb(ruary)?/", mar: "/mar(ch)?/", apr: "/apr(il)?/", may: "/may/", jun: "/jun(e)?/", jul: "/jul(y)?/", aug: "/aug(ust)?/", sep: "/sep(t(ember)?)?/", oct: "/oct(ober)?/", nov: "/nov(ember)?/", dec: "/dec(ember)?/", sun: "/^su(n(day)?)?/", mon: "/^mo(n(day)?)?/", tue: "/^tu(e(s(day)?)?)?/", wed: "/^we(d(nesday)?)?/", thu: "/^th(u(r(s(day)?)?)?)?/", fri: "/fr(i(day)?)?/", sat: "/^sa(t(urday)?)?/", future: "/^next/", past: "/^last|past|prev(ious)?/", add: "/^(\\+|aft(er)?|from|hence)/", subtract: "/^(\\-|bef(ore)?|ago)/", yesterday: "/^yes(terday)?/", today: "/^t(od(ay)?)?/", tomorrow: "/^tom(orrow)?/", now: "/^n(ow)?/", millisecond: "/^ms|milli(second)?s?/", second: "/^sec(ond)?s?/", minute: "/^mn|min(ute)?s?/", hour: "/^h(our)?s?/", week: "/^w(eek)?s?/", month: "/^m(onth)?s?/", day: "/^d(ay)?s?/", year: "/^y(ear)?s?/", shortMeridian: "/^(a|p)/", longMeridian: "/^(a\\.?m?\\.?|p\\.?m?\\.?)/", timezone: "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/", ordinalSuffix: "/^\\s*(st|nd|rd|th)/", timeContext: "/^\\s*(\\:|a(?!u|p)|p)/" }, Date.i18n.currentLanguage()); } }; var CultureInfo = function () { var info = getText.getFromObjectValues({ name: "name", englishName: "englishName", nativeName: "nativeName", amDesignator: "AM", pmDesignator: "PM", firstDayOfWeek: "firstDayOfWeek", twoDigitYearMax: "twoDigitYearMax", dateElementOrder: "mdy" }, Date.i18n.currentLanguage()); var constructedInfo = buildInfo.buildFromMethodHash({ dayNames: "days", abbreviatedDayNames: "dayAbbr", shortestDayNames: "dayShortNames", firstLetterDayNames: "dayFirstLetters", monthNames: "months", abbreviatedMonthNames: "monthAbbr", formatPatterns: "formatPatterns", regexPatterns: "regex", abbreviatedTimeZoneDST: "timeZoneDST", abbreviatedTimeZoneStandard: "timeZoneStandard" }); shallowMerge(info, constructedInfo); buildInfo.timeZones(info); return info; }; $D.i18n = { __: function (key, lang) { return __(key, lang); }, currentLanguage: function () { return lang || "en-US"; }, setLanguage: function (code, force, cb) { var async = false; if (force || code === "en-US" || (!!Date.CultureStrings && !!Date.CultureStrings[code])) { lang = code; Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings.lang = code; Date.CultureInfo = new CultureInfo(); } else { if (!(!!Date.CultureStrings && !!Date.CultureStrings[code])) { if (typeof exports !== "undefined" && this.exports !== exports) { // we're in a Node enviroment, load it using require try { require("../i18n/" + code + ".js"); lang = code; Date.CultureStrings.lang = code; Date.CultureInfo = new CultureInfo(); } catch (e) { // var str = "The language for '" + code + "' could not be loaded by Node. It likely does not exist."; throw new Error("The DateJS IETF language tag '" + code + "' could not be loaded by Node. It likely does not exist."); } } else if (Date.Config && Date.Config.i18n) { // we know the location of the files, so lets load them async = true; loadI18nScript(code).done(function(){ lang = code; Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings.lang = code; Date.CultureInfo = new CultureInfo(); $D.Parsing.Normalizer.buildReplaceData(); // because this is async if ($D.Grammar) { $D.Grammar.buildGrammarFormats(); // so we can parse those strings... } if (cb) { setTimeout(cb,0); } }); } else { Date.console.error("The DateJS IETF language tag '" + code + "' is not available and has not been loaded."); return false; } } } $D.Parsing.Normalizer.buildReplaceData(); // rebuild normalizer strings if ($D.Grammar) { $D.Grammar.buildGrammarFormats(); // so we can parse those strings... } if (!async && cb) { setTimeout(cb,0); } }, getLoggedKeys: function () { return loggedKeys; }, updateCultureInfo: function () { Date.CultureInfo = new CultureInfo(); } }; $D.i18n.updateCultureInfo(); // run automatically }()); (function () { var $D = Date, $P = $D.prototype, p = function (s, l) { if (!l) { l = 2; } return ("000" + s).slice(l * -1); }; if (typeof window !== "undefined" && typeof window.console !== "undefined" && typeof window.console.log !== "undefined") { $D.console = console; // used only to raise non-critical errors if available } else { // set mock so we don't give errors. $D.console = { log: function(){}, error: function(){} }; } $D.Config = $D.Config || {}; $D.initOverloads = function() { /** * Overload of Date.now. Allows an alternate call for Date.now where it returns the * current Date as an object rather than just milliseconds since the Unix Epoch. * * Also provides an implementation of now() for browsers (IE<9) that don't have it. * * Backwards compatible so with work with either: * Date.now() [returns ms] * or * Date.now(true) [returns Date] */ if (!$D.now) { $D._now = function now() { return new Date().getTime(); }; } else if (!$D._now) { $D._now = $D.now; } $D.now = function (returnObj) { if (returnObj) { return $D.present(); } else { return $D._now(); } }; if ( !$P.toISOString ) { $P.toISOString = function() { return this.getUTCFullYear() + "-" + p(this.getUTCMonth() + 1) + "-" + p(this.getUTCDate()) + "T" + p(this.getUTCHours()) + ":" + p(this.getUTCMinutes()) + ":" + p(this.getUTCSeconds()) + "." + String( (this.getUTCMilliseconds()/1000).toFixed(3)).slice(2, 5) + "Z"; }; } // private if ( $P._toString === undefined ){ $P._toString = $P.toString; } }; $D.initOverloads(); /** * Gets a date that is set to the current date. The time is set to the start of the day (00:00 or 12:00 AM). * @return {Date} The current date. */ $D.today = function () { return new Date().clearTime(); }; /** * Gets a date that is set to the current date and time (same as new Date, but chainable) * @return {Date} The current date. */ $D.present = function () { return new Date(); }; /** * Compares the first date to the second date and returns an number indication of their relative values. * @param {Date} First Date object to compare [Required]. * @param {Date} Second Date object to compare to [Required]. * @return {Number} -1 = date1 is lessthan date2. 0 = values are equal. 1 = date1 is greaterthan date2. */ $D.compare = function (date1, date2) { if (isNaN(date1) || isNaN(date2)) { throw new Error(date1 + " - " + date2); } else if (date1 instanceof Date && date2 instanceof Date) { return (date1 < date2) ? -1 : (date1 > date2) ? 1 : 0; } else { throw new TypeError(date1 + " - " + date2); } }; /** * Compares the first Date object to the second Date object and returns true if they are equal. * @param {Date} First Date object to compare [Required] * @param {Date} Second Date object to compare to [Required] * @return {Boolean} true if dates are equal. false if they are not equal. */ $D.equals = function (date1, date2) { return (date1.compareTo(date2) === 0); }; /** * Gets the language appropriate day name when given the day number(0-6) * eg - 0 == Sunday * @return {String} The day name */ $D.getDayName = function (n) { return Date.CultureInfo.dayNames[n]; }; /** * Gets the day number (0-6) if given a CultureInfo specific string which is a valid dayName, abbreviatedDayName or shortestDayName (two char). * @param {String} The name of the day (eg. "Monday, "Mon", "tuesday", "tue", "We", "we"). * @return {Number} The day number */ $D.getDayNumberFromName = function (name) { var n = Date.CultureInfo.dayNames, m = Date.CultureInfo.abbreviatedDayNames, o = Date.CultureInfo.shortestDayNames, s = name.toLowerCase(); for (var i = 0; i < n.length; i++) { if (n[i].toLowerCase() === s || m[i].toLowerCase() === s || o[i].toLowerCase() === s) { return i; } } return -1; }; /** * Gets the month number (0-11) if given a Culture Info specific string which is a valid monthName or abbreviatedMonthName. * @param {String} The name of the month (eg. "February, "Feb", "october", "oct"). * @return {Number} The day number */ $D.getMonthNumberFromName = function (name) { var n = Date.CultureInfo.monthNames, m = Date.CultureInfo.abbreviatedMonthNames, s = name.toLowerCase(); for (var i = 0; i < n.length; i++) { if (n[i].toLowerCase() === s || m[i].toLowerCase() === s) { return i; } } return -1; }; /** * Gets the language appropriate month name when given the month number(0-11) * eg - 0 == January * @return {String} The month name */ $D.getMonthName = function (n) { return Date.CultureInfo.monthNames[n]; }; /** * Determines if the current date instance is within a LeapYear. * @param {Number} The year. * @return {Boolean} true if date is within a LeapYear, otherwise false. */ $D.isLeapYear = function (year) { return ((year % 4 === 0 && year % 100 !== 0) || year % 400 === 0); }; /** * Gets the number of days in the month, given a year and month value. Automatically corrects for LeapYear. * @param {Number} The year. * @param {Number} The month (0-11). * @return {Number} The number of days in the month. */ $D.getDaysInMonth = function (year, month) { if (!month && $D.validateMonth(year)) { month = year; year = Date.today().getFullYear(); } return [31, ($D.isLeapYear(year) ? 29 : 28), 31, 30, 31, 30, 31, 31, 30, 31, 30, 31][month]; }; $P.getDaysInMonth = function () { return $D.getDaysInMonth(this.getFullYear(), this.getMonth()); }; $D.getTimezoneAbbreviation = function (offset, dst) { var p, n = (dst || false) ? Date.CultureInfo.abbreviatedTimeZoneDST : Date.CultureInfo.abbreviatedTimeZoneStandard; for (p in n) { if (n.hasOwnProperty(p)) { if (n[p] === offset) { return p; } } } return null; }; $D.getTimezoneOffset = function (name, dst) { var i, a =[], z = Date.CultureInfo.timezones; if (!name) { name = (new Date()).getTimezone();} for (i = 0; i < z.length; i++) { if (z[i].name === name.toUpperCase()) { a.push(i); } } if (!z[a[0]]) { return null; } if (a.length === 1 || !dst) { return z[a[0]].offset; } else { for (i=0; i < a.length; i++) { if (z[a[i]].dst) { return z[a[i]].offset; } } } }; $D.getQuarter = function (d) { d = d || new Date(); // If no date supplied, use today var q = [1,2,3,4]; return q[Math.floor(d.getMonth() / 3)]; // ~~~ is a bitwise op. Faster than Math.floor }; $D.getDaysLeftInQuarter = function (d) { d = d || new Date(); var qEnd = new Date(d); qEnd.setMonth(qEnd.getMonth() + 3 - qEnd.getMonth() % 3, 0); return Math.floor((qEnd - d) / 8.64e7); }; // private var validate = function (n, min, max, name) { name = name ? name : "Object"; if (typeof n === "undefined") { return false; } else if (typeof n !== "number") { throw new TypeError(n + " is not a Number."); } else if (n < min || n > max) { // As failing validation is *not* an exceptional circumstance // lets not throw a RangeError Exception here. // It's semantically correct but it's not sensible. return false; } return true; }; /** * Validates the number is within an acceptable range for milliseconds [0-999]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateMillisecond = function (value) { return validate(value, 0, 999, "millisecond"); }; /** * Validates the number is within an acceptable range for seconds [0-59]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateSecond = function (value) { return validate(value, 0, 59, "second"); }; /** * Validates the number is within an acceptable range for minutes [0-59]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateMinute = function (value) { return validate(value, 0, 59, "minute"); }; /** * Validates the number is within an acceptable range for hours [0-23]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateHour = function (value) { return validate(value, 0, 23, "hour"); }; /** * Validates the number is within an acceptable range for the days in a month [0-MaxDaysInMonth]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateDay = function (value, year, month) { if (year === undefined || year === null || month === undefined || month === null) { return false;} return validate(value, 1, $D.getDaysInMonth(year, month), "day"); }; /** * Validates the number is within an acceptable range for months [0-11]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateWeek = function (value) { return validate(value, 0, 53, "week"); }; /** * Validates the number is within an acceptable range for months [0-11]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateMonth = function (value) { return validate(value, 0, 11, "month"); }; /** * Validates the number is within an acceptable range for years. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateYear = function (value) { /** * Per ECMAScript spec the range of times supported by Date objects is * exactly -100,000,000 days to +100,000,000 days measured relative to * midnight at the beginning of 01 January, 1970 UTC. * This gives a range of 8,640,000,000,000,000 milliseconds to either * side of 01 January, 1970 UTC. * * Earliest possible date: Tue, 20 Apr 271,822 B.C. 00:00:00 UTC * Latest possible date: Sat, 13 Sep 275,760 00:00:00 UTC */ return validate(value, -271822, 275760, "year"); }; $D.validateTimezone = function(value) { var timezones = {"ACDT":1,"ACST":1,"ACT":1,"ADT":1,"AEDT":1,"AEST":1,"AFT":1,"AKDT":1,"AKST":1,"AMST":1,"AMT":1,"ART":1,"AST":1,"AWDT":1,"AWST":1,"AZOST":1,"AZT":1,"BDT":1,"BIOT":1,"BIT":1,"BOT":1,"BRT":1,"BST":1,"BTT":1,"CAT":1,"CCT":1,"CDT":1,"CEDT":1,"CEST":1,"CET":1,"CHADT":1,"CHAST":1,"CHOT":1,"ChST":1,"CHUT":1,"CIST":1,"CIT":1,"CKT":1,"CLST":1,"CLT":1,"COST":1,"COT":1,"CST":1,"CT":1,"CVT":1,"CWST":1,"CXT":1,"DAVT":1,"DDUT":1,"DFT":1,"EASST":1,"EAST":1,"EAT":1,"ECT":1,"EDT":1,"EEDT":1,"EEST":1,"EET":1,"EGST":1,"EGT":1,"EIT":1,"EST":1,"FET":1,"FJT":1,"FKST":1,"FKT":1,"FNT":1,"GALT":1,"GAMT":1,"GET":1,"GFT":1,"GILT":1,"GIT":1,"GMT":1,"GST":1,"GYT":1,"HADT":1,"HAEC":1,"HAST":1,"HKT":1,"HMT":1,"HOVT":1,"HST":1,"ICT":1,"IDT":1,"IOT":1,"IRDT":1,"IRKT":1,"IRST":1,"IST":1,"JST":1,"KGT":1,"KOST":1,"KRAT":1,"KST":1,"LHST":1,"LINT":1,"MAGT":1,"MART":1,"MAWT":1,"MDT":1,"MET":1,"MEST":1,"MHT":1,"MIST":1,"MIT":1,"MMT":1,"MSK":1,"MST":1,"MUT":1,"MVT":1,"MYT":1,"NCT":1,"NDT":1,"NFT":1,"NPT":1,"NST":1,"NT":1,"NUT":1,"NZDT":1,"NZST":1,"OMST":1,"ORAT":1,"PDT":1,"PET":1,"PETT":1,"PGT":1,"PHOT":1,"PHT":1,"PKT":1,"PMDT":1,"PMST":1,"PONT":1,"PST":1,"PYST":1,"PYT":1,"RET":1,"ROTT":1,"SAKT":1,"SAMT":1,"SAST":1,"SBT":1,"SCT":1,"SGT":1,"SLST":1,"SRT":1,"SST":1,"SYOT":1,"TAHT":1,"THA":1,"TFT":1,"TJT":1,"TKT":1,"TLT":1,"TMT":1,"TOT":1,"TVT":1,"UCT":1,"ULAT":1,"UTC":1,"UYST":1,"UYT":1,"UZT":1,"VET":1,"VLAT":1,"VOLT":1,"VOST":1,"VUT":1,"WAKT":1,"WAST":1,"WAT":1,"WEDT":1,"WEST":1,"WET":1,"WST":1,"YAKT":1,"YEKT":1,"Z":1}; return (timezones[value] === 1); }; $D.validateTimezoneOffset= function(value) { // timezones go from +14hrs to -12hrs, the +X hours are negative offsets. return (value > -841 && value < 721); }; }()); (function () { var $D = Date, $P = $D.prototype, p = function (s, l) { if (!l) { l = 2; } return ("000" + s).slice(l * -1); }; var validateConfigObject = function (obj) { var result = {}, self = this, prop, testFunc; testFunc = function (prop, func, value) { if (prop === "day") { var month = (obj.month !== undefined) ? obj.month : self.getMonth(); var year = (obj.year !== undefined) ? obj.year : self.getFullYear(); return $D[func](value, year, month); } else { return $D[func](value); } }; for (prop in obj) { if (Object.prototype.hasOwnProperty.call(obj, prop)) { var func = "validate" + prop.charAt(0).toUpperCase() + prop.slice(1); if ($D[func] && obj[prop] !== null && testFunc(prop, func, obj[prop])) { result[prop] = obj[prop]; } } } return result; }; /** * Resets the time of this Date object to 12:00 AM (00:00), which is the start of the day. * @param {Boolean} .clone() this date instance before clearing Time * @return {Date} this */ $P.clearTime = function () { this.setHours(0); this.setMinutes(0); this.setSeconds(0); this.setMilliseconds(0); return this; }; /** * Resets the time of this Date object to the current time ('now'). * @return {Date} this */ $P.setTimeToNow = function () { var n = new Date(); this.setHours(n.getHours()); this.setMinutes(n.getMinutes()); this.setSeconds(n.getSeconds()); this.setMilliseconds(n.getMilliseconds()); return this; }; /** * Returns a new Date object that is an exact date and time copy of the original instance. * @return {Date} A new Date instance */ $P.clone = function () { return new Date(this.getTime()); }; /** * Compares this instance to a Date object and returns an number indication of their relative values. * @param {Date} Date object to compare [Required] * @return {Number} -1 = this is lessthan date. 0 = values are equal. 1 = this is greaterthan date. */ $P.compareTo = function (date) { return Date.compare(this, date); }; /** * Compares this instance to another Date object and returns true if they are equal. * @param {Date} Date object to compare. If no date to compare, new Date() [now] is used. * @return {Boolean} true if dates are equal. false if they are not equal. */ $P.equals = function (date) { return Date.equals(this, (date !== undefined ? date : new Date())); }; /** * Determines if this instance is between a range of two dates or equal to either the start or end dates. * @param {Date} Start of range [Required] * @param {Date} End of range [Required] * @return {Boolean} true is this is between or equal to the start and end dates, else false */ $P.between = function (start, end) { return this.getTime() >= start.getTime() && this.getTime() <= end.getTime(); }; /** * Determines if this date occurs after the date to compare to. * @param {Date} Date object to compare. If no date to compare, new Date() ("now") is used. * @return {Boolean} true if this date instance is greater than the date to compare to (or "now"), otherwise false. */ $P.isAfter = function (date) { return this.compareTo(date || new Date()) === 1; }; /** * Determines if this date occurs before the date to compare to. * @param {Date} Date object to compare. If no date to compare, new Date() ("now") is used. * @return {Boolean} true if this date instance is less than the date to compare to (or "now"). */ $P.isBefore = function (date) { return (this.compareTo(date || new Date()) === -1); }; /** * Determines if the current Date instance occurs today. * @return {Boolean} true if this date instance is 'today', otherwise false. */ /** * Determines if the current Date instance occurs on the same Date as the supplied 'date'. * If no 'date' to compare to is provided, the current Date instance is compared to 'today'. * @param {date} Date object to compare. If no date to compare, the current Date ("now") is used. * @return {Boolean} true if this Date instance occurs on the same Day as the supplied 'date'. */ $P.isToday = $P.isSameDay = function (date) { return this.clone().clearTime().equals((date || new Date()).clone().clearTime()); }; /** * Adds the specified number of milliseconds to this instance. * @param {Number} The number of milliseconds to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addMilliseconds = function (value) { if (!value) { return this; } this.setTime(this.getTime() + value * 1); return this; }; /** * Adds the specified number of seconds to this instance. * @param {Number} The number of seconds to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addSeconds = function (value) { if (!value) { return this; } return this.addMilliseconds(value * 1000); }; /** * Adds the specified number of seconds to this instance. * @param {Number} The number of seconds to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addMinutes = function (value) { if (!value) { return this; } return this.addMilliseconds(value * 60000); // 60*1000 }; /** * Adds the specified number of hours to this instance. * @param {Number} The number of hours to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addHours = function (value) { if (!value) { return this; } return this.addMilliseconds(value * 3600000); // 60*60*1000 }; /** * Adds the specified number of days to this instance. * @param {Number} The number of days to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addDays = function (value) { if (!value) { return this; } this.setDate(this.getDate() + value * 1); return this; }; /** * Adds the specified number of weekdays (ie - not sat or sun) to this instance. * @param {Number} The number of days to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addWeekdays = function (value) { if (!value) { return this; } var day = this.getDay(); var weeks = (Math.ceil(Math.abs(value)/7)); if (day === 0 || day === 6) { if (value > 0) { this.next().monday(); this.addDays(-1); day = this.getDay(); } } if (value < 0) { while (value < 0) { this.addDays(-1); day = this.getDay(); if (day !== 0 && day !== 6) { value++; } } return this; } else if (value > 5 || (6-day) <= value) { value = value + (weeks * 2); } return this.addDays(value); }; /** * Adds the specified number of weeks to this instance. * @param {Number} The number of weeks to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addWeeks = function (value) { if (!value) { return this; } return this.addDays(value * 7); }; /** * Adds the specified number of months to this instance. * @param {Number} The number of months to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addMonths = function (value) { if (!value) { return this; } var n = this.getDate(); this.setDate(1); this.setMonth(this.getMonth() + value * 1); this.setDate(Math.min(n, $D.getDaysInMonth(this.getFullYear(), this.getMonth()))); return this; }; $P.addQuarters = function (value) { if (!value) { return this; } // note this will take you to the same point in the quarter as you are now. // i.e. - if you are 15 days into the quarter you'll be 15 days into the resulting one. // bonus: this allows adding fractional quarters return this.addMonths(value * 3); }; /** * Adds the specified number of years to this instance. * @param {Number} The number of years to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addYears = function (value) { if (!value) { return this; } return this.addMonths(value * 12); }; /** * Adds (or subtracts) to the value of the years, months, weeks, days, hours, minutes, seconds, milliseconds of the date instance using given configuration object. Positive and Negative values allowed. * Example

	Date.today().add( { days: 1, months: 1 } )

	new Date().add( { years: -1 } )
	
* @param {Object} Configuration object containing attributes (months, days, etc.) * @return {Date} this */ $P.add = function (config) { if (typeof config === "number") { this._orient = config; return this; } var x = config; if (x.day) { // If we should be a different date than today (eg: for 'tomorrow -1d', etc). // Should only effect parsing, not direct usage (eg, Finish and FinishExact) if ((x.day - this.getDate()) !== 0) { this.setDate(x.day); } } if (x.milliseconds) { this.addMilliseconds(x.milliseconds); } if (x.seconds) { this.addSeconds(x.seconds); } if (x.minutes) { this.addMinutes(x.minutes); } if (x.hours) { this.addHours(x.hours); } if (x.weeks) { this.addWeeks(x.weeks); } if (x.months) { this.addMonths(x.months); } if (x.years) { this.addYears(x.years); } if (x.days) { this.addDays(x.days); } return this; }; /** * Get the week number. Week one (1) is the week which contains the first Thursday of the year. Monday is considered the first day of the week. * The .getWeek() function does NOT convert the date to UTC. The local datetime is used. * Please use .getISOWeek() to get the week of the UTC converted date. * @return {Number} 1 to 53 */ $P.getWeek = function (utc) { // Create a copy of this date object var self, target = new Date(this.valueOf()); if (utc) { target.addMinutes(target.getTimezoneOffset()); self = target.clone(); } else { self = this; } // ISO week date weeks start on monday // so correct the day number var dayNr = (self.getDay() + 6) % 7; // ISO 8601 states that week 1 is the week // with the first thursday of that year. // Set the target date to the thursday in the target week target.setDate(target.getDate() - dayNr + 3); // Store the millisecond value of the target date var firstThursday = target.valueOf(); // Set the target to the first thursday of the year // First set the target to january first target.setMonth(0, 1); // Not a thursday? Correct the date to the next thursday if (target.getDay() !== 4) { target.setMonth(0, 1 + ((4 - target.getDay()) + 7) % 7); } // The weeknumber is the number of weeks between the // first thursday of the year and the thursday in the target week return 1 + Math.ceil((firstThursday - target) / 604800000); // 604800000 = 7 * 24 * 3600 * 1000 }; /** * Get the ISO 8601 week number. Week one ("01") is the week which contains the first Thursday of the year. Monday is considered the first day of the week. * The .getISOWeek() function does convert the date to it's UTC value. Please use .getWeek() to get the week of the local date. * @return {String} "01" to "53" */ $P.getISOWeek = function () { return p(this.getWeek(true)); }; /** * Moves the date to Monday of the week set. Week one (1) is the week which contains the first Thursday of the year. * @param {Number} A Number (1 to 53) that represents the week of the year. * @return {Date} this */ $P.setWeek = function (n) { if ((n - this.getWeek()) === 0) { if (this.getDay() !== 1) { return this.moveToDayOfWeek(1, (this.getDay() > 1 ? -1 : 1)); } else { return this; } } else { return this.moveToDayOfWeek(1, (this.getDay() > 1 ? -1 : 1)).addWeeks(n - this.getWeek()); } }; $P.setQuarter = function (qtr) { var month = Math.abs(((qtr-1) * 3) + 1); return this.setMonth(month, 1); }; $P.getQuarter = function () { return Date.getQuarter(this); }; $P.getDaysLeftInQuarter = function () { return Date.getDaysLeftInQuarter(this); }; /** * Moves the date to the next n'th occurrence of the dayOfWeek starting from the beginning of the month. The number (-1) is a magic number and will return the last occurrence of the dayOfWeek in the month. * @param {Number} The dayOfWeek to move to * @param {Number} The n'th occurrence to move to. Use (-1) to return the last occurrence in the month * @return {Date} this */ $P.moveToNthOccurrence = function (dayOfWeek, occurrence) { if (dayOfWeek === "Weekday") { if (occurrence > 0) { this.moveToFirstDayOfMonth(); if (this.is().weekday()) { occurrence -= 1; } } else if (occurrence < 0) { this.moveToLastDayOfMonth(); if (this.is().weekday()) { occurrence += 1; } } else { return this; } return this.addWeekdays(occurrence); } var shift = 0; if (occurrence > 0) { shift = occurrence - 1; } else if (occurrence === -1) { this.moveToLastDayOfMonth(); if (this.getDay() !== dayOfWeek) { this.moveToDayOfWeek(dayOfWeek, -1); } return this; } return this.moveToFirstDayOfMonth().addDays(-1).moveToDayOfWeek(dayOfWeek, +1).addWeeks(shift); }; var moveToN = function (getFunc, addFunc, nVal) { return function (value, orient) { var diff = (value - this[getFunc]() + nVal * (orient || +1)) % nVal; return this[addFunc]((diff === 0) ? diff += nVal * (orient || +1) : diff); }; }; /** * Move to the next or last dayOfWeek based on the orient value. * @param {Number} The dayOfWeek to move to * @param {Number} Forward (+1) or Back (-1). Defaults to +1. [Optional] * @return {Date} this */ $P.moveToDayOfWeek = moveToN("getDay", "addDays", 7); /** * Move to the next or last month based on the orient value. * @param {Number} The month to move to. 0 = January, 11 = December * @param {Number} Forward (+1) or Back (-1). Defaults to +1. [Optional] * @return {Date} this */ $P.moveToMonth = moveToN("getMonth", "addMonths", 12); /** * Get the Ordinate of the current day ("th", "st", "rd"). * @return {String} */ $P.getOrdinate = function () { var num = this.getDate(); return ord(num); }; /** * Get the Ordinal day (numeric day number) of the year, adjusted for leap year. * @return {Number} 1 through 365 (366 in leap years) */ $P.getOrdinalNumber = function () { return Math.ceil((this.clone().clearTime() - new Date(this.getFullYear(), 0, 1)) / 86400000) + 1; }; /** * Get the time zone abbreviation of the current date. * @return {String} The abbreviated time zone name (e.g. "EST") */ $P.getTimezone = function () { return $D.getTimezoneAbbreviation(this.getUTCOffset(), this.isDaylightSavingTime()); }; $P.setTimezoneOffset = function (offset) { var here = this.getTimezoneOffset(), there = Number(offset) * -6 / 10; return (there || there === 0) ? this.addMinutes(there - here) : this; }; $P.setTimezone = function (offset) { return this.setTimezoneOffset($D.getTimezoneOffset(offset)); }; /** * Indicates whether Daylight Saving Time is observed in the current time zone. * @return {Boolean} true|false */ $P.hasDaylightSavingTime = function () { return (Date.today().set({month: 0, day: 1}).getTimezoneOffset() !== Date.today().set({month: 6, day: 1}).getTimezoneOffset()); }; /** * Indicates whether this Date instance is within the Daylight Saving Time range for the current time zone. * @return {Boolean} true|false */ $P.isDaylightSavingTime = function () { return Date.today().set({month: 0, day: 1}).getTimezoneOffset() !== this.getTimezoneOffset(); }; /** * Get the offset from UTC of the current date. * @return {String} The 4-character offset string prefixed with + or - (e.g. "-0500") */ $P.getUTCOffset = function (offset) { var n = (offset || this.getTimezoneOffset()) * -10 / 6, r; if (n < 0) { r = (n - 10000).toString(); return r.charAt(0) + r.substr(2); } else { r = (n + 10000).toString(); return "+" + r.substr(1); } }; /** * Returns the number of milliseconds between this date and date. * @param {Date} Defaults to now * @return {Number} The diff in milliseconds */ $P.getElapsed = function (date) { return (date || new Date()) - this; }; /** * Set the value of year, month, day, hour, minute, second, millisecond of date instance using given configuration object. * Example

	Date.today().set( { day: 20, month: 1 } )

	new Date().set( { millisecond: 0 } )
	
* * @param {Object} Configuration object containing attributes (month, day, etc.) * @return {Date} this */ $P.set = function (config) { config = validateConfigObject.call(this, config); var key; for (key in config) { if (Object.prototype.hasOwnProperty.call(config, key)) { var name = key.charAt(0).toUpperCase() + key.slice(1); var addFunc, getFunc; if (key !== "week" && key !== "month" && key !== "timezone" && key !== "timezoneOffset") { name += "s"; } addFunc = "add" + name; getFunc = "get" + name; if (key === "month") { addFunc = addFunc + "s"; } else if (key === "year"){ getFunc = "getFullYear"; } if (key !== "day" && key !== "timezone" && key !== "timezoneOffset" && key !== "week" && key !== "hour") { this[addFunc](config[key] - this[getFunc]()); } else if ( key === "timezone"|| key === "timezoneOffset" || key === "week" || key === "hour") { this["set"+name](config[key]); } } } // day has to go last because you can't validate the day without first knowing the month if (config.day) { this.addDays(config.day - this.getDate()); } return this; }; /** * Moves the date to the first day of the month. * @return {Date} this */ $P.moveToFirstDayOfMonth = function () { return this.set({ day: 1 }); }; /** * Moves the date to the last day of the month. * @return {Date} this */ $P.moveToLastDayOfMonth = function () { return this.set({ day: $D.getDaysInMonth(this.getFullYear(), this.getMonth())}); }; /** * Converts the value of the current Date object to its equivalent string representation. * Format Specifiers * CUSTOM DATE AND TIME FORMAT STRINGS * Format Description Example * ------ --------------------------------------------------------------------------- ----------------------- * s The seconds of the minute between 0-59. "0" to "59" * ss The seconds of the minute with leading zero if required. "00" to "59" * * m The minute of the hour between 0-59. "0" or "59" * mm The minute of the hour with leading zero if required. "00" or "59" * * h The hour of the day between 1-12. "1" to "12" * hh The hour of the day with leading zero if required. "01" to "12" * * H The hour of the day between 0-23. "0" to "23" * HH The hour of the day with leading zero if required. "00" to "23" * * d The day of the month between 1 and 31. "1" to "31" * dd The day of the month with leading zero if required. "01" to "31" * ddd Abbreviated day name. Date.CultureInfo.abbreviatedDayNames. "Mon" to "Sun" * dddd The full day name. Date.CultureInfo.dayNames. "Monday" to "Sunday" * * M The month of the year between 1-12. "1" to "12" * MM The month of the year with leading zero if required. "01" to "12" * MMM Abbreviated month name. Date.CultureInfo.abbreviatedMonthNames. "Jan" to "Dec" * MMMM The full month name. Date.CultureInfo.monthNames. "January" to "December" * * yy The year as a two-digit number. "99" or "08" * yyyy The full four digit year. "1999" or "2008" * * t Displays the first character of the A.M./P.M. designator. "A" or "P" * Date.CultureInfo.amDesignator or Date.CultureInfo.pmDesignator * tt Displays the A.M./P.M. designator. "AM" or "PM" * Date.CultureInfo.amDesignator or Date.CultureInfo.pmDesignator * * S The ordinal suffix ("st, "nd", "rd" or "th") of the current day. "st, "nd", "rd" or "th" * * STANDARD DATE AND TIME FORMAT STRINGS * Format Description Example *------ --------------------------------------------------------------------------- ----------------------- * d The CultureInfo shortDate Format Pattern "M/d/yyyy" * D The CultureInfo longDate Format Pattern "dddd, MMMM dd, yyyy" * F The CultureInfo fullDateTime Format Pattern "dddd, MMMM dd, yyyy h:mm:ss tt" * m The CultureInfo monthDay Format Pattern "MMMM dd" * r The CultureInfo rfc1123 Format Pattern "ddd, dd MMM yyyy HH:mm:ss GMT" * s The CultureInfo sortableDateTime Format Pattern "yyyy-MM-ddTHH:mm:ss" * t The CultureInfo shortTime Format Pattern "h:mm tt" * T The CultureInfo longTime Format Pattern "h:mm:ss tt" * u The CultureInfo universalSortableDateTime Format Pattern "yyyy-MM-dd HH:mm:ssZ" * y The CultureInfo yearMonth Format Pattern "MMMM, yyyy" * * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @return {String} A string representation of the current Date object. */ var ord = function (n) { switch (n * 1) { case 1: case 21: case 31: return "st"; case 2: case 22: return "nd"; case 3: case 23: return "rd"; default: return "th"; } }; var parseStandardFormats = function (format) { var y, c = Date.CultureInfo.formatPatterns; switch (format) { case "d": return this.toString(c.shortDate); case "D": return this.toString(c.longDate); case "F": return this.toString(c.fullDateTime); case "m": return this.toString(c.monthDay); case "r": case "R": y = this.clone().addMinutes(this.getTimezoneOffset()); return y.toString(c.rfc1123) + " GMT"; case "s": return this.toString(c.sortableDateTime); case "t": return this.toString(c.shortTime); case "T": return this.toString(c.longTime); case "u": y = this.clone().addMinutes(this.getTimezoneOffset()); return y.toString(c.universalSortableDateTime); case "y": return this.toString(c.yearMonth); default: return false; } }; var parseFormatStringsClosure = function (context) { return function (m) { if (m.charAt(0) === "\\") { return m.replace("\\", ""); } switch (m) { case "hh": return p(context.getHours() < 13 ? (context.getHours() === 0 ? 12 : context.getHours()) : (context.getHours() - 12)); case "h": return context.getHours() < 13 ? (context.getHours() === 0 ? 12 : context.getHours()) : (context.getHours() - 12); case "HH": return p(context.getHours()); case "H": return context.getHours(); case "mm": return p(context.getMinutes()); case "m": return context.getMinutes(); case "ss": return p(context.getSeconds()); case "s": return context.getSeconds(); case "yyyy": return p(context.getFullYear(), 4); case "yy": return p(context.getFullYear()); case "y": return context.getFullYear(); case "E": case "dddd": return Date.CultureInfo.dayNames[context.getDay()]; case "ddd": return Date.CultureInfo.abbreviatedDayNames[context.getDay()]; case "dd": return p(context.getDate()); case "d": return context.getDate(); case "MMMM": return Date.CultureInfo.monthNames[context.getMonth()]; case "MMM": return Date.CultureInfo.abbreviatedMonthNames[context.getMonth()]; case "MM": return p((context.getMonth() + 1)); case "M": return context.getMonth() + 1; case "t": return context.getHours() < 12 ? Date.CultureInfo.amDesignator.substring(0, 1) : Date.CultureInfo.pmDesignator.substring(0, 1); case "tt": return context.getHours() < 12 ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator; case "S": return ord(context.getDate()); case "W": return context.getWeek(); case "WW": return context.getISOWeek(); case "Q": return "Q" + context.getQuarter(); case "q": return String(context.getQuarter()); case "z": return context.getTimezone(); case "Z": case "X": return Date.getTimezoneOffset(context.getTimezone()); case "ZZ": // Timezone offset in seconds return context.getTimezoneOffset() * -60; case "u": return context.getDay(); case "L": return ($D.isLeapYear(context.getFullYear())) ? 1 : 0; case "B": // Swatch Internet Time (.beats) return "@"+((context.getUTCSeconds() + (context.getUTCMinutes()*60) + ((context.getUTCHours()+1)*3600))/86.4); default: return m; } }; }; $P.toString = function (format, ignoreStandards) { // Standard Date and Time Format Strings. Formats pulled from CultureInfo file and // may vary by culture. if (!ignoreStandards && format && format.length === 1) { output = parseStandardFormats.call(this, format); if (output) { return output; } } var parseFormatStrings = parseFormatStringsClosure(this); return format ? format.replace(/((\\)?(dd?d?d?|MM?M?M?|yy?y?y?|hh?|HH?|mm?|ss?|tt?|S|q|Q|WW?W?W?)(?![^\[]*\]))/g, parseFormatStrings).replace(/\[|\]/g, "") : this._toString(); }; }()); /************************************************************* * SugarPak - Domain Specific Language - Syntactical Sugar * *************************************************************/ (function () { var $D = Date, $P = $D.prototype, $N = Number.prototype; // private $P._orient = +1; // private $P._nth = null; // private $P._is = false; // private $P._same = false; // private $P._isSecond = false; // private $N._dateElement = "days"; /** * Moves the date to the next instance of a date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.today().next().friday();
	Date.today().next().fri();
	Date.today().next().march();
	Date.today().next().mar();
	Date.today().next().week();
	
* * @return {Date} date */ $P.next = function () { this._move = true; this._orient = +1; return this; }; /** * Creates a new Date (Date.today()) and moves the date to the next instance of the date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.next().friday();
	Date.next().fri();
	Date.next().march();
	Date.next().mar();
	Date.next().week();
	
* * @return {Date} date */ $D.next = function () { return $D.today().next(); }; /** * Moves the date to the previous instance of a date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.today().last().friday();
	Date.today().last().fri();
	Date.today().last().march();
	Date.today().last().mar();
	Date.today().last().week();
	
* * @return {Date} date */ $P.last = $P.prev = $P.previous = function () { this._move = true; this._orient = -1; return this; }; /** * Creates a new Date (Date.today()) and moves the date to the previous instance of the date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.last().friday();
	Date.last().fri();
	Date.previous().march();
	Date.prev().mar();
	Date.last().week();
	
* * @return {Date} date */ $D.last = $D.prev = $D.previous = function () { return $D.today().last(); }; /** * Performs a equality check when followed by either a month name, day name or .weekday() function. * Example

	Date.today().is().friday(); // true|false
	Date.today().is().fri();
	Date.today().is().march();
	Date.today().is().mar();
	
* * @return {Boolean} true|false */ $P.is = function () { this._is = true; return this; }; /** * Determines if two date objects occur on/in exactly the same instance of the subsequent date part function. * The function .same() must be followed by a date part function (example: .day(), .month(), .year(), etc). * * An optional Date can be passed in the date part function. If now date is passed as a parameter, 'Now' is used. * * The following example demonstrates how to determine if two dates fall on the exact same day. * * Example

	var d1 = Date.today(); // today at 00:00
	var d2 = new Date();   // exactly now.

	// Do they occur on the same day?
	d1.same().day(d2); // true
	
	// Do they occur on the same hour?
	d1.same().hour(d2); // false, unless d2 hour is '00' (midnight).
	
	// What if it's the same day, but one year apart?
	var nextYear = Date.today().add(1).year();

	d1.same().day(nextYear); // false, because the dates must occur on the exact same day. 
	
* * Scenario: Determine if a given date occurs during some week period 2 months from now. * * Example

	var future = Date.today().add(2).months();
	return someDate.same().week(future); // true|false;
	
* * @return {Boolean} true|false */ $P.same = function () { this._same = true; this._isSecond = false; return this; }; /** * Determines if the current date/time occurs during Today. Must be preceded by the .is() function. * Example

	someDate.is().today();    // true|false
	new Date().is().today();  // true
	Date.today().is().today();// true
	Date.today().add(-1).day().is().today(); // false
	
* * @return {Boolean} true|false */ $P.today = function () { return this.same().day(); }; /** * Determines if the current date is a weekday. This function must be preceded by the .is() function. * Example

	Date.today().is().weekday(); // true|false
	
* * @return {Boolean} true|false */ $P.weekday = function () { if (this._nth) { return df("Weekday").call(this); } if (this._move) { return this.addWeekdays(this._orient); } if (this._is) { this._is = false; return (!this.is().sat() && !this.is().sun()); } return false; }; /** * Determines if the current date is on the weekend. This function must be preceded by the .is() function. * Example

	Date.today().is().weekend(); // true|false
	
* * @return {Boolean} true|false */ $P.weekend = function () { if (this._is) { this._is = false; return (this.is().sat() || this.is().sun()); } return false; }; /** * Sets the Time of the current Date instance. A string "6:15 pm" or config object {hour:18, minute:15} are accepted. * Example

	// Set time to 6:15pm with a String
	Date.today().at("6:15pm");

	// Set time to 6:15pm with a config object
	Date.today().at({hour:18, minute:15});
	
* * @return {Date} date */ $P.at = function (time) { return (typeof time === "string") ? $D.parse(this.toString("d") + " " + time) : this.set(time); }; /** * Creates a new Date() and adds this (Number) to the date based on the preceding date element function (eg. second|minute|hour|day|month|year). * Example

	// Undeclared Numbers must be wrapped with parentheses. Requirment of JavaScript.
	(3).days().fromNow();
	(6).months().fromNow();

	// Declared Number variables do not require parentheses. 
	var n = 6;
	n.months().fromNow();
	
* * @return {Date} A new Date instance */ $N.fromNow = $N.after = function (date) { var c = {}; c[this._dateElement] = this; return ((!date) ? new Date() : date.clone()).add(c); }; /** * Creates a new Date() and subtract this (Number) from the date based on the preceding date element function (eg. second|minute|hour|day|month|year). * Example

	// Undeclared Numbers must be wrapped with parentheses. Requirment of JavaScript.
	(3).days().ago();
	(6).months().ago();

	// Declared Number variables do not require parentheses. 
	var n = 6;
	n.months().ago();
	
* * @return {Date} A new Date instance */ $N.ago = $N.before = function (date) { var c = {}, s = (this._dateElement[this._dateElement.length-1] !== "s") ? this._dateElement + "s" : this._dateElement; c[s] = this * -1; return ((!date) ? new Date() : date.clone()).add(c); }; // Do NOT modify the following string tokens. These tokens are used to build dynamic functions. // All culture-specific strings can be found in the CultureInfo files. var dx = ("sunday monday tuesday wednesday thursday friday saturday").split(/\s/), mx = ("january february march april may june july august september october november december").split(/\s/), px = ("Millisecond Second Minute Hour Day Week Month Year Quarter Weekday").split(/\s/), pxf = ("Milliseconds Seconds Minutes Hours Date Week Month FullYear Quarter").split(/\s/), nth = ("final first second third fourth fifth").split(/\s/), de; /** * Returns an object literal of all the date parts. * Example

	var o = new Date().toObject();
	
	// { year: 2008, month: 4, week: 20, day: 13, hour: 18, minute: 9, second: 32, millisecond: 812 }
	
	// The object properties can be referenced directly from the object.
	
	alert(o.day);  // alerts "13"
	alert(o.year); // alerts "2008"
	
* * @return {Date} An object literal representing the original date object. */ $P.toObject = function () { var o = {}; for (var i = 0; i < px.length; i++) { if (this["get" + pxf[i]]) { o[px[i].toLowerCase()] = this["get" + pxf[i]](); } } return o; }; /** * Returns a date created from an object literal. Ignores the .week property if set in the config. * Example

	var o = new Date().toObject();
	
	return Date.fromObject(o); // will return the same date. 

	var o2 = {month: 1, day: 20, hour: 18}; // birthday party!
	Date.fromObject(o2);
	
* * @return {Date} An object literal representing the original date object. */ $D.fromObject = function(config) { config.week = null; return Date.today().set(config); }; // Create day name functions and abbreviated day name functions (eg. monday(), friday(), fri()). var df = function (n) { return function () { if (this._is) { this._is = false; return this.getDay() === n; } if (this._move) { this._move = null; } if (this._nth !== null) { // If the .second() function was called earlier, remove the _orient // from the date, and then continue. // This is required because 'second' can be used in two different context. // // Example // // Date.today().add(1).second(); // Date.march().second().monday(); // // Things get crazy with the following... // Date.march().add(1).second().second().monday(); // but it works!! // if (this._isSecond) { this.addSeconds(this._orient * -1); } // make sure we reset _isSecond this._isSecond = false; var ntemp = this._nth; this._nth = null; var temp = this.clone().moveToLastDayOfMonth(); this.moveToNthOccurrence(n, ntemp); if (this > temp) { throw new RangeError($D.getDayName(n) + " does not occur " + ntemp + " times in the month of " + $D.getMonthName(temp.getMonth()) + " " + temp.getFullYear() + "."); } return this; } return this.moveToDayOfWeek(n, this._orient); }; }; var sdf = function (n) { return function () { var t = $D.today(), shift = n - t.getDay(); if (n === 0 && Date.CultureInfo.firstDayOfWeek === 1 && t.getDay() !== 0) { shift = shift + 7; } return t.addDays(shift); }; }; // Create month name functions and abbreviated month name functions (eg. january(), march(), mar()). var month_instance_functions = function (n) { return function () { if (this._is) { this._is = false; return this.getMonth() === n; } return this.moveToMonth(n, this._orient); }; }; var month_static_functions = function (n) { return function () { return $D.today().set({ month: n, day: 1 }); }; }; var processTerms = function (names, staticFunc, instanceFunc) { for (var i = 0; i < names.length; i++) { // Create constant static Name variables. $D[names[i].toUpperCase()] = $D[names[i].toUpperCase().substring(0, 3)] = i; // Create Name functions. $D[names[i]] = $D[names[i].substring(0, 3)] = staticFunc(i); // Create Name instance functions. $P[names[i]] = $P[names[i].substring(0, 3)] = instanceFunc(i); } }; processTerms(dx, sdf, df); processTerms(mx, month_static_functions, month_instance_functions); // Create date element functions and plural date element functions used with Date (eg. day(), days(), months()). var ef = function (j) { return function () { // if the .second() function was called earlier, the _orient // has alread been added. Just return this and reset _isSecond. if (this._isSecond) { this._isSecond = false; return this; } if (this._same) { this._same = this._is = false; var o1 = this.toObject(), o2 = (arguments[0] || new Date()).toObject(), v = "", k = j.toLowerCase(); // the substr trick with -1 doesn't work in IE8 or less k = (k[k.length-1] === "s") ? k.substring(0,k.length-1) : k; for (var m = (px.length - 1); m > -1; m--) { v = px[m].toLowerCase(); if (o1[v] !== o2[v]) { return false; } if (k === v) { break; } } return true; } if (j.substring(j.length - 1) !== "s") { j += "s"; } if (this._move) { this._move = null; } return this["add" + j](this._orient); }; }; var nf = function (n) { return function () { this._dateElement = n; return this; }; }; for (var k = 0; k < px.length; k++) { de = px[k].toLowerCase(); if(de !== "weekday") { // Create date element functions and plural date element functions used with Date (eg. day(), days(), months()). $P[de] = $P[de + "s"] = ef(px[k]); // Create date element functions and plural date element functions used with Number (eg. day(), days(), months()). $N[de] = $N[de + "s"] = nf(de + "s"); } } $P._ss = ef("Second"); var nthfn = function (n) { return function (dayOfWeek) { if (this._same) { return this._ss(arguments[0]); } if (dayOfWeek || dayOfWeek === 0) { return this.moveToNthOccurrence(dayOfWeek, n); } this._nth = n; // if the operator is 'second' add the _orient, then deal with it later... if (n === 2 && (dayOfWeek === undefined || dayOfWeek === null)) { this._isSecond = true; return this.addSeconds(this._orient); } return this; }; }; for (var l = 0; l < nth.length; l++) { $P[nth[l]] = (l === 0) ? nthfn(-1) : nthfn(l); } }()); (function () { "use strict"; Date.Parsing = { Exception: function (s) { this.message = "Parse error at '" + s.substring(0, 10) + " ...'"; } }; var $P = Date.Parsing; var dayOffsets = { standard: [0,31,59,90,120,151,181,212,243,273,304,334], leap: [0,31,60,91,121,152,182,213,244,274,305,335] }; $P.isLeapYear = function(year) { return ((year % 4 === 0) && (year % 100 !== 0)) || (year % 400 === 0); }; var utils = { multiReplace : function (str, hash ) { var key; for (key in hash) { if (Object.prototype.hasOwnProperty.call(hash, key)) { var regex; if (typeof hash[key] === "function") { } else { regex = (hash[key] instanceof RegExp) ? hash[key] : new RegExp(hash[key], "g"); } str = str.replace(regex, key); } } return str; }, getDayOfYearFromWeek : function (obj) { var d, jan4, offset; obj.weekDay = (!obj.weekDay && obj.weekDay !== 0) ? 1 : obj.weekDay; d = new Date(obj.year, 0, 4); jan4 = d.getDay() === 0 ? 7 : d.getDay(); // JS is 0 indexed on Sunday. offset = jan4+3; obj.dayOfYear = ((obj.week * 7) + (obj.weekDay === 0 ? 7 : obj.weekDay))-offset; return obj; }, getDayOfYear : function (obj, dayOffset) { if (!obj.dayOfYear) { obj = utils.getDayOfYearFromWeek(obj); } for (var i=0;i <= dayOffset.length;i++) { if (obj.dayOfYear < dayOffset[i] || i === dayOffset.length) { obj.day = obj.day ? obj.day : (obj.dayOfYear - dayOffset[i-1]); break; } else { obj.month = i; } } return obj; }, adjustForTimeZone : function (obj, date) { var offset; if (obj.zone.toUpperCase() === "Z" || (obj.zone_hours === 0 && obj.zone_minutes === 0)) { // it's UTC/GML so work out the current timeszone offset offset = -date.getTimezoneOffset(); } else { offset = (obj.zone_hours*60) + (obj.zone_minutes || 0); if (obj.zone_sign === "+") { offset *= -1; } offset -= date.getTimezoneOffset(); } date.setMinutes(date.getMinutes()+offset); return date; }, setDefaults : function (obj) { obj.year = obj.year || Date.today().getFullYear(); obj.hours = obj.hours || 0; obj.minutes = obj.minutes || 0; obj.seconds = obj.seconds || 0; obj.milliseconds = obj.milliseconds || 0; if (!(!obj.month && (obj.week || obj.dayOfYear))) { // if we have a month, or if we don't but don't have the day calculation data obj.month = obj.month || 0; obj.day = obj.day || 1; } return obj; }, dataNum: function (data, mod, explict, postProcess) { var dataNum = data*1; if (mod) { if (postProcess) { return data ? mod(data)*1 : data; } else { return data ? mod(dataNum) : data; } } else if (!explict){ return data ? dataNum : data; } else { return (data && typeof data !== "undefined") ? dataNum : data; } }, timeDataProcess: function (obj) { var timeObj = {}; for (var x in obj.data) { if (obj.data.hasOwnProperty(x)) { timeObj[x] = obj.ignore[x] ? obj.data[x] : utils.dataNum(obj.data[x], obj.mods[x], obj.explict[x], obj.postProcess[x]); } } if (obj.data.secmins) { obj.data.secmins = obj.data.secmins.replace(",", ".") * 60; if (!timeObj.minutes) { timeObj.minutes = obj.data.secmins; } else if (!timeObj.seconds) { timeObj.seconds = obj.data.secmins; } delete obj.secmins; } return timeObj; }, buildTimeObjectFromData: function (data) { var time = utils.timeDataProcess({ data: { year : data[1], month : data[5], day : data[7], week : data[8], dayOfYear : data[10], hours : data[15], zone_hours : data[23], zone_minutes : data[24], zone : data[21], zone_sign : data[22], weekDay : data[9], minutes: data[16], seconds: data[19], milliseconds: data[20], secmins: data[18] }, mods: { month: function(data) { return data-1; }, weekDay: function (data) { data = Math.abs(data); return (data === 7 ? 0 : data); }, minutes: function (data) { return data.replace(":",""); }, seconds: function (data) { return Math.floor( (data.replace(":","").replace(",","."))*1 ); }, milliseconds: function (data) { return (data.replace(",",".")*1000); } }, postProcess: { minutes: true, seconds: true, milliseconds: true }, explict: { zone_hours: true, zone_minutes: true }, ignore: { zone: true, zone_sign: true, secmins: true } }); return time; }, addToHash: function (hash, keys, data) { keys = keys; data = data; var len = keys.length; for (var i = 0; i < len; i++) { hash[keys[i]] = data[i]; } return hash; }, combineRegex: function (r1, r2) { return new RegExp("(("+r1.source+")\\s("+r2.source+"))"); }, getDateNthString: function(add, last, inc){ if (add) { return Date.today().addDays(inc).toString("d"); } else if (last) { return Date.today().last()[inc]().toString("d"); } }, buildRegexData: function (array) { var arr = []; var len = array.length; for (var i=0; i < len; i++) { if (Object.prototype.toString.call(array[i]) === '[object Array]') { // oldIE compat version of Array.isArray arr.push(this.combineRegex(array[i][0], array[i][1])); } else { arr.push(array[i]); } } return arr; } }; $P.processTimeObject = function (obj) { var date, dayOffset; utils.setDefaults(obj); dayOffset = ($P.isLeapYear(obj.year)) ? dayOffsets.leap : dayOffsets.standard; if (!obj.month && (obj.week || obj.dayOfYear)) { utils.getDayOfYear(obj, dayOffset); } else { obj.dayOfYear = dayOffset[obj.month] + obj.day; } date = new Date(obj.year, obj.month, obj.day, obj.hours, obj.minutes, obj.seconds, obj.milliseconds); if (obj.zone) { utils.adjustForTimeZone(obj, date); // adjust (and calculate) for timezone } return date; }; $P.ISO = { regex : /^([\+-]?\d{4}(?!\d{2}\b))((-?)((0[1-9]|1[0-2])(\3([12]\d|0[1-9]|3[01]))?|W([0-4]\d|5[0-3])(-?[1-7])?|(00[1-9]|0[1-9]\d|[12]\d{2}|3([0-5]\d|6[1-6])))([T\s]((([01]\d|2[0-4])((:?)[0-5]\d)?|24\:?00)([\.,]\d+(?!:))?)?(\17[0-5]\d([\.,]\d+)?)?\s?([zZ]|([\+-])([01]\d|2[0-3]):?([0-5]\d)?)?)?)?$/, parse : function (s) { var time, data = s.match(this.regex); if (!data || !data.length) { return null; } time = utils.buildTimeObjectFromData(data); if (!time.year || (!time.year && (!time.month && !time.day) && (!time.week && !time.dayOfYear)) ) { return null; } return $P.processTimeObject(time); } }; $P.Numeric = { isNumeric: function (e){return!isNaN(parseFloat(e))&&isFinite(e);}, regex: /\b([0-1]?[0-9])([0-3]?[0-9])([0-2]?[0-9]?[0-9][0-9])\b/i, parse: function (s) { var data, i, time = {}, order = Date.CultureInfo.dateElementOrder.split(""); if (!(this.isNumeric(s)) || // if it's non-numeric OR (s[0] === "+" && s[0] === "-")) { // It's an arithmatic string (eg +/-1000) return null; } if (s.length < 5 && s.indexOf(".") < 0 && s.indexOf("/") < 0) { // assume it's just a year. time.year = s; return $P.processTimeObject(time); } data = s.match(this.regex); if (!data || !data.length) { return null; } for (i=0; i < order.length; i++) { switch(order[i]) { case "d": time.day = data[i+1]; break; case "m": time.month = (data[i+1]-1); break; case "y": time.year = data[i+1]; break; } } return $P.processTimeObject(time); } }; $P.Normalizer = { regexData: function () { var $R = Date.CultureInfo.regexPatterns; return utils.buildRegexData([ $R.tomorrow, $R.yesterday, [$R.past, $R.mon], [$R.past, $R.tue], [$R.past, $R.wed], [$R.past, $R.thu], [$R.past, $R.fri], [$R.past, $R.sat], [$R.past, $R.sun] ]); }, basicReplaceHash : function() { var $R = Date.CultureInfo.regexPatterns; return { "January": $R.jan.source, "February": $R.feb, "March": $R.mar, "April": $R.apr, "May": $R.may, "June": $R.jun, "July": $R.jul, "August": $R.aug, "September": $R.sep, "October": $R.oct, "November": $R.nov, "December": $R.dec, "": /\bat\b/gi, " ": /\s{2,}/, "am": $R.inTheMorning, "9am": $R.thisMorning, "pm": $R.inTheEvening, "7pm":$R.thisEvening }; }, keys : function(){ return [ utils.getDateNthString(true, false, 1), // tomorrow utils.getDateNthString(true, false, -1), // yesterday utils.getDateNthString(false, true, "monday"), //last mon utils.getDateNthString(false, true, "tuesday"), //last tues utils.getDateNthString(false, true, "wednesday"), //last wed utils.getDateNthString(false, true, "thursday"), //last thurs utils.getDateNthString(false, true, "friday"), //last fri utils.getDateNthString(false, true, "saturday"), //last sat utils.getDateNthString(false, true, "sunday") //last sun ]; }, buildRegexFunctions: function () { var $R = Date.CultureInfo.regexPatterns; var __ = Date.i18n.__; var tomorrowRE = new RegExp("(\\b\\d\\d?("+__("AM")+"|"+__("PM")+")? )("+$R.tomorrow.source.slice(1)+")", "i"); // adapted tomorrow regex for AM PM relative dates var todayRE = new RegExp($R.today.source + "(?!\\s*([+-]))\\b"); // today, but excludes the math operators (eg "today + 2h") this.replaceFuncs = [ [todayRE, function (full) { return (full.length > 1) ? Date.today().toString("d") : full; }], [tomorrowRE, function(full, m1) { var t = Date.today().addDays(1).toString("d"); return (t + " " + m1); }], [$R.amThisMorning, function(str, am){return am;}], [$R.pmThisEvening, function(str, pm){return pm;}] ]; }, buildReplaceData: function () { this.buildRegexFunctions(); this.replaceHash = utils.addToHash(this.basicReplaceHash(), this.keys(), this.regexData()); }, stringReplaceFuncs: function (s) { for (var i=0; i < this.replaceFuncs.length; i++) { s = s.replace(this.replaceFuncs[i][0], this.replaceFuncs[i][1]); } return s; }, parse: function (s) { s = this.stringReplaceFuncs(s); s = utils.multiReplace(s, this.replaceHash); try { var n = s.split(/([\s\-\.\,\/\x27]+)/); if (n.length === 3 && $P.Numeric.isNumeric(n[0]) && $P.Numeric.isNumeric(n[2]) && (n[2].length >= 4)) { // ok, so we're dealing with x/year. But that's not a full date. // This fixes wonky dateElementOrder parsing when set to dmy order. if (Date.CultureInfo.dateElementOrder[0] === "d") { s = "1/" + n[0] + "/" + n[2]; // set to 1st of month and normalize the seperator } } } catch (e) {} return s; } }; $P.Normalizer.buildReplaceData(); }()); (function () { var $P = Date.Parsing; var _ = $P.Operators = { // // Tokenizers // rtoken: function (r) { // regex token return function (s) { var mx = s.match(r); if (mx) { return ([ mx[0], s.substring(mx[0].length) ]); } else { throw new $P.Exception(s); } }; }, token: function () { // whitespace-eating token return function (s) { return _.rtoken(new RegExp("^\\s*" + s + "\\s*"))(s); }; }, stoken: function (s) { // string token return _.rtoken(new RegExp("^" + s)); }, // Atomic Operators until: function (p) { return function (s) { var qx = [], rx = null; while (s.length) { try { rx = p.call(this, s); } catch (e) { qx.push(rx[0]); s = rx[1]; continue; } break; } return [ qx, s ]; }; }, many: function (p) { return function (s) { var rx = [], r = null; while (s.length) { try { r = p.call(this, s); } catch (e) { return [ rx, s ]; } rx.push(r[0]); s = r[1]; } return [ rx, s ]; }; }, // generator operators -- see below optional: function (p) { return function (s) { var r = null; try { r = p.call(this, s); } catch (e) { return [ null, s ]; } return [ r[0], r[1] ]; }; }, not: function (p) { return function (s) { try { p.call(this, s); } catch (e) { return [null, s]; } throw new $P.Exception(s); }; }, ignore: function (p) { return p ? function (s) { var r = null; r = p.call(this, s); return [null, r[1]]; } : null; }, product: function () { var px = arguments[0], qx = Array.prototype.slice.call(arguments, 1), rx = []; for (var i = 0 ; i < px.length ; i++) { rx.push(_.each(px[i], qx)); } return rx; }, cache: function (rule) { var cache = {}, cache_length = 0, cache_keys = [], CACHE_MAX = Date.Config.CACHE_MAX || 100000, r = null; var cacheCheck = function () { if (cache_length === CACHE_MAX) { // kill several keys, don't want to have to do this all the time... for (var i=0; i < 10; i++) { var key = cache_keys.shift(); if (key) { delete cache[key]; cache_length--; } } } }; return function (s) { cacheCheck(); try { r = cache[s] = (cache[s] || rule.call(this, s)); } catch (e) { r = cache[s] = e; } cache_length++; cache_keys.push(s); if (r instanceof $P.Exception) { throw r; } else { return r; } }; }, // vector operators -- see below any: function () { var px = arguments; return function (s) { var r = null; for (var i = 0; i < px.length; i++) { if (px[i] == null) { continue; } try { r = (px[i].call(this, s)); } catch (e) { r = null; } if (r) { return r; } } throw new $P.Exception(s); }; }, each: function () { var px = arguments; return function (s) { var rx = [], r = null; for (var i = 0; i < px.length ; i++) { if (px[i] == null) { continue; } try { r = (px[i].call(this, s)); } catch (e) { throw new $P.Exception(s); } rx.push(r[0]); s = r[1]; } return [ rx, s]; }; }, all: function () { var px = arguments, _ = _; return _.each(_.optional(px)); }, // delimited operators sequence: function (px, d, c) { d = d || _.rtoken(/^\s*/); c = c || null; if (px.length === 1) { return px[0]; } return function (s) { var r = null, q = null; var rx = []; for (var i = 0; i < px.length ; i++) { try { r = px[i].call(this, s); } catch (e) { break; } rx.push(r[0]); try { q = d.call(this, r[1]); } catch (ex) { q = null; break; } s = q[1]; } if (!r) { throw new $P.Exception(s); } if (q) { throw new $P.Exception(q[1]); } if (c) { try { r = c.call(this, r[1]); } catch (ey) { throw new $P.Exception(r[1]); } } return [ rx, (r?r[1]:s) ]; }; }, // // Composite Operators // between: function (d1, p, d2) { d2 = d2 || d1; var _fn = _.each(_.ignore(d1), p, _.ignore(d2)); return function (s) { var rx = _fn.call(this, s); return [[rx[0][0], r[0][2]], rx[1]]; }; }, list: function (p, d, c) { d = d || _.rtoken(/^\s*/); c = c || null; return (p instanceof Array ? _.each(_.product(p.slice(0, -1), _.ignore(d)), p.slice(-1), _.ignore(c)) : _.each(_.many(_.each(p, _.ignore(d))), px, _.ignore(c))); }, set: function (px, d, c) { d = d || _.rtoken(/^\s*/); c = c || null; return function (s) { // r is the current match, best the current 'best' match // which means it parsed the most amount of input var r = null, p = null, q = null, rx = null, best = [[], s], last = false; // go through the rules in the given set for (var i = 0; i < px.length ; i++) { // last is a flag indicating whether this must be the last element // if there is only 1 element, then it MUST be the last one q = null; p = null; r = null; last = (px.length === 1); // first, we try simply to match the current pattern // if not, try the next pattern try { r = px[i].call(this, s); } catch (e) { continue; } // since we are matching against a set of elements, the first // thing to do is to add r[0] to matched elements rx = [[r[0]], r[1]]; // if we matched and there is still input to parse and // we don't already know this is the last element, // we're going to next check for the delimiter ... // if there's none, or if there's no input left to parse // than this must be the last element after all ... if (r[1].length > 0 && ! last) { try { q = d.call(this, r[1]); } catch (ex) { last = true; } } else { last = true; } // if we parsed the delimiter and now there's no more input, // that means we shouldn't have parsed the delimiter at all // so don't update r and mark this as the last element ... if (!last && q[1].length === 0) { last = true; } // so, if this isn't the last element, we're going to see if // we can get any more matches from the remaining (unmatched) // elements ... if (!last) { // build a list of the remaining rules we can match against, // i.e., all but the one we just matched against var qx = []; for (var j = 0; j < px.length ; j++) { if (i !== j) { qx.push(px[j]); } } // now invoke recursively set with the remaining input // note that we don't include the closing delimiter ... // we'll check for that ourselves at the end p = _.set(qx, d).call(this, q[1]); // if we got a non-empty set as a result ... // (otw rx already contains everything we want to match) if (p[0].length > 0) { // update current result, which is stored in rx ... // basically, pick up the remaining text from p[1] // and concat the result from p[0] so that we don't // get endless nesting ... rx[0] = rx[0].concat(p[0]); rx[1] = p[1]; } } // at this point, rx either contains the last matched element // or the entire matched set that starts with this element. // now we just check to see if this variation is better than // our best so far, in terms of how much of the input is parsed if (rx[1].length < best[1].length) { best = rx; } // if we've parsed all the input, then we're finished if (best[1].length === 0) { break; } } // so now we've either gone through all the patterns trying them // as the initial match; or we found one that parsed the entire // input string ... // if best has no matches, just return empty set ... if (best[0].length === 0) { return best; } // if a closing delimiter is provided, then we have to check it also if (c) { // we try this even if there is no remaining input because the pattern // may well be optional or match empty input ... try { q = c.call(this, best[1]); } catch (ey) { throw new $P.Exception(best[1]); } // it parsed ... be sure to update the best match remaining input best[1] = q[1]; } // if we're here, either there was no closing delimiter or we parsed it // so now we have the best match; just return it! return best; }; }, forward: function (gr, fname) { return function (s) { return gr[fname].call(this, s); }; }, // // Translation Operators // replace: function (rule, repl) { return function (s) { var r = rule.call(this, s); return [repl, r[1]]; }; }, process: function (rule, fn) { return function (s) { var r = rule.call(this, s); return [fn.call(this, r[0]), r[1]]; }; }, min: function (min, rule) { return function (s) { var rx = rule.call(this, s); if (rx[0].length < min) { throw new $P.Exception(s); } return rx; }; } }; // Generator Operators And Vector Operators // Generators are operators that have a signature of F(R) => R, // taking a given rule and returning another rule, such as // ignore, which parses a given rule and throws away the result. // Vector operators are those that have a signature of F(R1,R2,...) => R, // take a list of rules and returning a new rule, such as each. // Generator operators are converted (via the following _generator // function) into functions that can also take a list or array of rules // and return an array of new rules as though the function had been // called on each rule in turn (which is what actually happens). // This allows generators to be used with vector operators more easily. // Example: // each(ignore(foo, bar)) instead of each(ignore(foo), ignore(bar)) // This also turns generators into vector operators, which allows // constructs like: // not(cache(foo, bar)) var _generator = function (op) { function gen() { var args = null, rx = [], px, i; if (arguments.length > 1) { args = Array.prototype.slice.call(arguments); } else if (arguments[0] instanceof Array) { args = arguments[0]; } if (args) { px = args.shift(); if (px.length > 0) { args.unshift(px[i]); rx.push(op.apply(null, args)); args.shift(); return rx; } } else { return op.apply(null, arguments); } } return gen; }; var gx = "optional not ignore cache".split(/\s/); for (var i = 0 ; i < gx.length ; i++) { _[gx[i]] = _generator(_[gx[i]]); } var _vector = function (op) { return function () { if (arguments[0] instanceof Array) { return op.apply(null, arguments[0]); } else { return op.apply(null, arguments); } }; }; var vx = "each any all".split(/\s/); for (var j = 0 ; j < vx.length ; j++) { _[vx[j]] = _vector(_[vx[j]]); } }()); (function () { var $D = Date; var flattenAndCompact = function (ax) { var rx = []; for (var i = 0; i < ax.length; i++) { if (ax[i] instanceof Array) { rx = rx.concat(flattenAndCompact(ax[i])); } else { if (ax[i]) { rx.push(ax[i]); } } } return rx; }; var parseMeridian = function () { if (this.meridian && (this.hour || this.hour === 0)) { if (this.meridian === "a" && this.hour > 11 && Date.Config.strict24hr){ throw "Invalid hour and meridian combination"; } else if (this.meridian === "p" && this.hour < 12 && Date.Config.strict24hr){ throw "Invalid hour and meridian combination"; } else if (this.meridian === "p" && this.hour < 12) { this.hour = this.hour + 12; } else if (this.meridian === "a" && this.hour === 12) { this.hour = 0; } } }; var setDefaults = function () { var now = new Date(); if ((this.hour || this.minute) && (!this.month && !this.year && !this.day)) { this.day = now.getDate(); } if (!this.year) { this.year = now.getFullYear(); } if (!this.month && this.month !== 0) { this.month = now.getMonth(); } if (!this.day) { this.day = 1; } if (!this.hour) { this.hour = 0; } if (!this.minute) { this.minute = 0; } if (!this.second) { this.second = 0; } if (!this.millisecond) { this.millisecond = 0; } }; var finishUtils = { getToday: function () { if (this.now || "hour minute second".indexOf(this.unit) !== -1) { return new Date(); } else { return $D.today(); } }, setDaysFromWeekday: function (today, orient){ var gap; orient = orient || 1; this.unit = "day"; gap = ($D.getDayNumberFromName(this.weekday) - today.getDay()); this.days = gap ? ((gap + (orient * 7)) % 7) : (orient * 7); return this; }, setMonthsFromMonth: function (today, orient) { var gap; orient = orient || 1; this.unit = "month"; gap = (this.month - today.getMonth()); this.months = gap ? ((gap + (orient * 12)) % 12) : (orient * 12); this.month = null; return this; }, setDMYFromWeekday: function () { var d = Date[this.weekday](); this.day = d.getDate(); if (!this.month) { this.month = d.getMonth(); } this.year = d.getFullYear(); return this; }, setUnitValue: function (orient) { if (!this.value && this.operator && this.operator !== null && this[this.unit + "s"] && this[this.unit + "s"] !== null) { this[this.unit + "s"] = this[this.unit + "s"] + ((this.operator === "add") ? 1 : -1) + (this.value||0) * orient; } else if (this[this.unit + "s"] == null || this.operator != null) { if (!this.value) { this.value = 1; } this[this.unit + "s"] = this.value * orient; } }, generateDateFromWeeks: function () { var weekday = (this.weekday !== undefined) ? this.weekday : "today"; var d = Date[weekday]().addWeeks(this.weeks); if (this.now) { d.setTimeToNow(); } return d; } }; $D.Translator = { hour: function (s) { return function () { this.hour = Number(s); }; }, minute: function (s) { return function () { this.minute = Number(s); }; }, second: function (s) { return function () { this.second = Number(s); }; }, /* for ss.s format */ secondAndMillisecond: function (s) { return function () { var mx = s.match(/^([0-5][0-9])\.([0-9]{1,3})/); this.second = Number(mx[1]); this.millisecond = Number(mx[2]); }; }, meridian: function (s) { return function () { this.meridian = s.slice(0, 1).toLowerCase(); }; }, timezone: function (s) { return function () { var n = s.replace(/[^\d\+\-]/g, ""); if (n.length) { this.timezoneOffset = Number(n); } else { this.timezone = s.toLowerCase(); } }; }, day: function (x) { var s = x[0]; return function () { this.day = Number(s.match(/\d+/)[0]); if (this.day < 1) { throw "invalid day"; } }; }, month: function (s) { return function () { this.month = (s.length === 3) ? "jan feb mar apr may jun jul aug sep oct nov dec".indexOf(s)/4 : Number(s) - 1; if (this.month < 0) { throw "invalid month"; } }; }, year: function (s) { return function () { var n = Number(s); this.year = ((s.length > 2) ? n : (n + (((n + 2000) < Date.CultureInfo.twoDigitYearMax) ? 2000 : 1900))); }; }, rday: function (s) { return function () { switch (s) { case "yesterday": this.days = -1; break; case "tomorrow": this.days = 1; break; case "today": this.days = 0; break; case "now": this.days = 0; this.now = true; break; } }; }, finishExact: function (x) { var d; x = (x instanceof Array) ? x : [x]; for (var i = 0 ; i < x.length ; i++) { if (x[i]) { x[i].call(this); } } setDefaults.call(this); parseMeridian.call(this); if (this.day > $D.getDaysInMonth(this.year, this.month)) { throw new RangeError(this.day + " is not a valid value for days."); } d = new Date(this.year, this.month, this.day, this.hour, this.minute, this.second, this.millisecond); if (this.year < 100) { d.setFullYear(this.year); // means years less that 100 are process correctly. JS will parse it otherwise as 1900-1999. } if (this.timezone) { d.set({ timezone: this.timezone }); } else if (this.timezoneOffset) { d.set({ timezoneOffset: this.timezoneOffset }); } return d; }, finish: function (x) { var today, expression, orient, temp; x = (x instanceof Array) ? flattenAndCompact(x) : [ x ]; if (x.length === 0) { return null; } for (var i = 0 ; i < x.length ; i++) { if (typeof x[i] === "function") { x[i].call(this); } } if (this.now && !this.unit && !this.operator) { return new Date(); } else { today = finishUtils.getToday.call(this); } expression = !!(this.days && this.days !== null || this.orient || this.operator); orient = ((this.orient === "past" || this.operator === "subtract") ? -1 : 1); if (this.month && this.unit === "week") { this.value = this.month + 1; delete this.month; delete this.day; } if ((this.month || this.month === 0) && "year day hour minute second".indexOf(this.unit) !== -1) { if (!this.value) { this.value = this.month + 1; } this.month = null; expression = true; } if (!expression && this.weekday && !this.day && !this.days) { finishUtils.setDMYFromWeekday.call(this); } if (expression && this.weekday && this.unit !== "month" && this.unit !== "week") { finishUtils.setDaysFromWeekday.call(this, today, orient); } if (this.weekday && this.unit !== "week" && !this.day && !this.days) { temp = Date[this.weekday](); this.day = temp.getDate(); if (temp.getMonth() !== today.getMonth()) { this.month = temp.getMonth(); } } if (this.month && this.unit === "day" && this.operator) { if (!this.value) { this.value = (this.month + 1); } this.month = null; } if (this.value != null && this.month != null && this.year != null) { this.day = this.value * 1; } if (this.month && !this.day && this.value) { today.set({ day: this.value * 1 }); if (!expression) { this.day = this.value * 1; } } if (!this.month && this.value && this.unit === "month" && !this.now) { this.month = this.value; expression = true; } if (expression && (this.month || this.month === 0) && this.unit !== "year") { finishUtils.setMonthsFromMonth.call(this, today, orient); } if (!this.unit) { this.unit = "day"; } finishUtils.setUnitValue.call(this, orient); parseMeridian.call(this); if ((this.month || this.month === 0) && !this.day) { this.day = 1; } if (!this.orient && !this.operator && this.unit === "week" && this.value && !this.day && !this.month) { return Date.today().setWeek(this.value); } if (this.unit === "week" && this.weeks && !this.day && !this.month) { return finishUtils.generateDateFromWeeks.call(this); } if (expression && this.timezone && this.day && this.days) { this.day = this.days; } if (expression){ today.add(this); } else { today.set(this); } if (this.timezone) { this.timezone = this.timezone.toUpperCase(); var offset = $D.getTimezoneOffset(this.timezone); var timezone; if (today.hasDaylightSavingTime()) { // lets check that we're being sane with timezone setting timezone = $D.getTimezoneAbbreviation(offset, today.isDaylightSavingTime()); if (timezone !== this.timezone) { // bugger, we're in a place where things like EST vs EDT matters. if (today.isDaylightSavingTime()) { today.addHours(-1); } else { today.addHours(1); } } } today.setTimezoneOffset(offset); } return today; } }; }()); (function () { var $D = Date; $D.Grammar = {}; var _ = $D.Parsing.Operators, g = $D.Grammar, t = $D.Translator, _fn; // Allow rolling up into general purpose rules _fn = function () { return _.each(_.any.apply(null, arguments), _.not(g.ctoken2("timeContext"))); }; g.datePartDelimiter = _.rtoken(/^([\s\-\.\,\/\x27]+)/); g.timePartDelimiter = _.stoken(":"); g.whiteSpace = _.rtoken(/^\s*/); g.generalDelimiter = _.rtoken(/^(([\s\,]|at|@|on)+)/); var _C = {}; g.ctoken = function (keys) { var fn = _C[keys]; if (! fn) { var c = Date.CultureInfo.regexPatterns; var kx = keys.split(/\s+/), px = []; for (var i = 0; i < kx.length ; i++) { px.push(_.replace(_.rtoken(c[kx[i]]), kx[i])); } fn = _C[keys] = _.any.apply(null, px); } return fn; }; g.ctoken2 = function (key) { return _.rtoken(Date.CultureInfo.regexPatterns[key]); }; var cacheProcessRtoken = function (key, token, type, eachToken) { if (eachToken) { g[key] = _.cache(_.process(_.each(_.rtoken(token),_.optional(g.ctoken2(eachToken))), type)); } else { g[key] = _.cache(_.process(_.rtoken(token), type)); } }; var cacheProcessCtoken = function (token, type) { return _.cache(_.process(g.ctoken2(token), type)); }; var _F = {}; //function cache var _get = function (f) { _F[f] = (_F[f] || g.format(f)[0]); return _F[f]; }; g.allformats = function (fx) { var rx = []; if (fx instanceof Array) { for (var i = 0; i < fx.length; i++) { rx.push(_get(fx[i])); } } else { rx.push(_get(fx)); } return rx; }; g.formats = function (fx) { if (fx instanceof Array) { var rx = []; for (var i = 0 ; i < fx.length ; i++) { rx.push(_get(fx[i])); } return _.any.apply(null, rx); } else { return _get(fx); } }; var grammarFormats = { timeFormats: function(){ var i, RTokenKeys = [ "h", "hh", "H", "HH", "m", "mm", "s", "ss", "ss.s", "z", "zz" ], RToken = [ /^(0[0-9]|1[0-2]|[1-9])/, /^(0[0-9]|1[0-2])/, /^([0-1][0-9]|2[0-3]|[0-9])/, /^([0-1][0-9]|2[0-3])/, /^([0-5][0-9]|[0-9])/, /^[0-5][0-9]/, /^([0-5][0-9]|[0-9])/, /^[0-5][0-9]/, /^[0-5][0-9]\.[0-9]{1,3}/, /^((\+|\-)\s*\d\d\d\d)|((\+|\-)\d\d\:?\d\d)/, /^((\+|\-)\s*\d\d\d\d)|((\+|\-)\d\d\:?\d\d)/ ], tokens = [ t.hour, t.hour, t.hour, t.hour, t.minute, t.minute, t.second, t.second, t.secondAndMillisecond, t.timezone, t.timezone ]; for (i=0; i < RTokenKeys.length; i++) { cacheProcessRtoken(RTokenKeys[i], RToken[i], tokens[i]); } g.hms = _.cache(_.sequence([g.H, g.m, g.s], g.timePartDelimiter)); g.t = cacheProcessCtoken("shortMeridian", t.meridian); g.tt = cacheProcessCtoken("longMeridian", t.meridian); g.zzz = cacheProcessCtoken("timezone", t.timezone); g.timeSuffix = _.each(_.ignore(g.whiteSpace), _.set([ g.tt, g.zzz ])); g.time = _.each(_.optional(_.ignore(_.stoken("T"))), g.hms, g.timeSuffix); }, dateFormats: function () { // pre-loaded rules for different date part order preferences var _setfn = function () { return _.set(arguments, g.datePartDelimiter); }; var i, RTokenKeys = [ "d", "dd", "M", "MM", "y", "yy", "yyy", "yyyy" ], RToken = [ /^([0-2]\d|3[0-1]|\d)/, /^([0-2]\d|3[0-1])/, /^(1[0-2]|0\d|\d)/, /^(1[0-2]|0\d)/, /^(\d+)/, /^(\d\d)/, /^(\d\d?\d?\d?)/, /^(\d\d\d\d)/ ], tokens = [ t.day, t.day, t.month, t.month, t.year, t.year, t.year, t.year ], eachToken = [ "ordinalSuffix", "ordinalSuffix" ]; for (i=0; i < RTokenKeys.length; i++) { cacheProcessRtoken(RTokenKeys[i], RToken[i], tokens[i], eachToken[i]); } g.MMM = g.MMMM = _.cache(_.process(g.ctoken("jan feb mar apr may jun jul aug sep oct nov dec"), t.month)); g.ddd = g.dddd = _.cache(_.process(g.ctoken("sun mon tue wed thu fri sat"), function (s) { return function () { this.weekday = s; }; } )); g.day = _fn(g.d, g.dd); g.month = _fn(g.M, g.MMM); g.year = _fn(g.yyyy, g.yy); g.mdy = _setfn(g.ddd, g.month, g.day, g.year); g.ymd = _setfn(g.ddd, g.year, g.month, g.day); g.dmy = _setfn(g.ddd, g.day, g.month, g.year); g.date = function (s) { return ((g[Date.CultureInfo.dateElementOrder] || g.mdy).call(this, s)); }; }, relative: function () { // relative date / time expressions g.orientation = _.process(g.ctoken("past future"), function (s) { return function () { this.orient = s; }; } ); g.operator = _.process(g.ctoken("add subtract"), function (s) { return function () { this.operator = s; }; } ); g.rday = _.process(g.ctoken("yesterday tomorrow today now"), t.rday); g.unit = _.process(g.ctoken("second minute hour day week month year"), function (s) { return function () { this.unit = s; }; } ); } }; g.buildGrammarFormats = function () { // these need to be rebuilt every time the language changes. _C = {}; grammarFormats.timeFormats(); grammarFormats.dateFormats(); grammarFormats.relative(); g.value = _.process(_.rtoken(/^([-+]?\d+)?(st|nd|rd|th)?/), function (s) { return function () { this.value = s.replace(/\D/g, ""); }; } ); g.expression = _.set([g.rday, g.operator, g.value, g.unit, g.orientation, g.ddd, g.MMM ]); g.format = _.process(_.many( _.any( // translate format specifiers into grammar rules _.process( _.rtoken(/^(dd?d?d?(?!e)|MM?M?M?|yy?y?y?|hh?|HH?|mm?|ss?|tt?|zz?z?)/), function (fmt) { if (g[fmt]) { return g[fmt]; } else { throw $D.Parsing.Exception(fmt); } } ), // translate separator tokens into token rules _.process(_.rtoken(/^[^dMyhHmstz]+/), // all legal separators function (s) { return _.ignore(_.stoken(s)); } ) ) ), // construct the parser ... function (rules) { return _.process(_.each.apply(null, rules), t.finishExact); } ); // starting rule for general purpose grammar g._start = _.process(_.set([ g.date, g.time, g.expression ], g.generalDelimiter, g.whiteSpace), t.finish); }; g.buildGrammarFormats(); // parsing date format specifiers - ex: "h:m:s tt" // this little guy will generate a custom parser based // on the format string, ex: g.format("h:m:s tt") // check for these formats first g._formats = g.formats([ "\"yyyy-MM-ddTHH:mm:ssZ\"", "yyyy-MM-ddTHH:mm:ss.sz", "yyyy-MM-ddTHH:mm:ssZ", "yyyy-MM-ddTHH:mm:ssz", "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-ddTHH:mmZ", "yyyy-MM-ddTHH:mmz", "yyyy-MM-ddTHH:mm", "ddd, MMM dd, yyyy H:mm:ss tt", "ddd MMM d yyyy HH:mm:ss zzz", "MMddyyyy", "ddMMyyyy", "Mddyyyy", "ddMyyyy", "Mdyyyy", "dMyyyy", "yyyy", "Mdyy", "dMyy", "d" ]); // real starting rule: tries selected formats first, // then general purpose rule g.start = function (s) { try { var r = g._formats.call({}, s); if (r[1].length === 0) { return r; } } catch (e) {} return g._start.call({}, s); }; }()); (function () { var $D = Date; /** * @desc Converts the specified string value into its JavaScript Date equivalent using CultureInfo specific format information. * * Example

	///////////
	// Dates //
	///////////

	// 15-Oct-2004
	var d1 = Date.parse("10/15/2004");

	// 15-Oct-2004
	var d1 = Date.parse("15-Oct-2004");

	// 15-Oct-2004
	var d1 = Date.parse("2004.10.15");

	//Fri Oct 15, 2004
	var d1 = Date.parse("Fri Oct 15, 2004");

	///////////
	// Times //
	///////////

	// Today at 10 PM.
	var d1 = Date.parse("10 PM");

	// Today at 10:30 PM.
	var d1 = Date.parse("10:30 P.M.");

	// Today at 6 AM.
	var d1 = Date.parse("06am");

	/////////////////////
	// Dates and Times //
	/////////////////////

	// 8-July-2004 @ 10:30 PM
	var d1 = Date.parse("July 8th, 2004, 10:30 PM");

	// 1-July-2004 @ 10:30 PM
	var d1 = Date.parse("2004-07-01T22:30:00");

	////////////////////
	// Relative Dates //
	////////////////////

	// Returns today's date. The string "today" is culture specific.
	var d1 = Date.parse("today");

	// Returns yesterday's date. The string "yesterday" is culture specific.
	var d1 = Date.parse("yesterday");

	// Returns the date of the next thursday.
	var d1 = Date.parse("Next thursday");

	// Returns the date of the most previous monday.
	var d1 = Date.parse("last monday");

	// Returns today's day + one year.
	var d1 = Date.parse("next year");

	///////////////
	// Date Math //
	///////////////

	// Today + 2 days
	var d1 = Date.parse("t+2");

	// Today + 2 days
	var d1 = Date.parse("today + 2 days");

	// Today + 3 months
	var d1 = Date.parse("t+3m");

	// Today - 1 year
	var d1 = Date.parse("today - 1 year");

	// Today - 1 year
	var d1 = Date.parse("t-1y"); 


	/////////////////////////////
	// Partial Dates and Times //
	/////////////////////////////

	// July 15th of this year.
	var d1 = Date.parse("July 15");

	// 15th day of current day and year.
	var d1 = Date.parse("15");

	// July 1st of current year at 10pm.
	var d1 = Date.parse("7/1 10pm");
	
* * @param {String} The string value to convert into a Date object [Required] * @return {Date} A Date object or null if the string cannot be converted into a Date. */ var parseUtils = { removeOrds: function (s) { ords = s.match(/\b(\d+)(?:st|nd|rd|th)\b/); // find ordinal matches s = ((ords && ords.length === 2) ? s.replace(ords[0], ords[1]) : s); return s; }, grammarParser: function (s) { var r = null; try { r = $D.Grammar.start.call({}, s.replace(/^\s*(\S*(\s+\S+)*)\s*$/, "$1")); } catch (e) { return null; } return ((r[1].length === 0) ? r[0] : null); }, nativeFallback: function(s) { var t; try { // ok we haven't parsed it, last ditch attempt with the built-in parser. t = Date._parse(s); return (t || t === 0) ? new Date(t) : null; } catch (e) { return null; } } }; function parse (s) { var d; if (!s) { return null; } if (s instanceof Date) { return s.clone(); } if (s.length >= 4 && s.charAt(0) !== "0" && s.charAt(0) !== "+"&& s.charAt(0) !== "-") { // ie: 2004 will pass, 0800 won't. // Start with specific formats d = $D.Parsing.ISO.parse(s) || $D.Parsing.Numeric.parse(s); } if (d instanceof Date && !isNaN(d.getTime())) { return d; } else { // find ordinal dates (1st, 3rd, 8th, etc and remove them as they cause parsing issues) s = $D.Parsing.Normalizer.parse(parseUtils.removeOrds(s)); d = parseUtils.grammarParser(s); if (d !== null) { return d; } else { return parseUtils.nativeFallback(s); } } } if (!$D._parse) { $D._parse = $D.parse; } $D.parse = parse; Date.getParseFunction = function (fx) { var fns = Date.Grammar.allformats(fx); return function (s) { var r = null; for (var i = 0; i < fns.length; i++) { try { r = fns[i].call({}, s); } catch (e) { continue; } if (r[1].length === 0) { return r[0]; } } return null; }; }; /** * Converts the specified string value into its JavaScript Date equivalent using the specified format {String} or formats {Array} and the CultureInfo specific format information. * The format of the string value must match one of the supplied formats exactly. * * Example

	// 15-Oct-2004
	var d1 = Date.parseExact("10/15/2004", "M/d/yyyy");

	// 15-Oct-2004
	var d1 = Date.parse("15-Oct-2004", "M-ddd-yyyy");

	// 15-Oct-2004
	var d1 = Date.parse("2004.10.15", "yyyy.MM.dd");

	// Multiple formats
	var d1 = Date.parseExact("10/15/2004", ["M/d/yyyy", "MMMM d, yyyy"]);
	
* * @param {String} The string value to convert into a Date object [Required]. * @param {Object} The expected format {String} or an array of expected formats {Array} of the date string [Required]. * @return {Date} A Date object or null if the string cannot be converted into a Date. */ $D.parseExact = function (s, fx) { return $D.getParseFunction(fx)(s); }; }()); (function () { var $D = Date, $P = $D.prototype, // $C = $D.CultureInfo, // not used atm p = function (s, l) { if (!l) { l = 2; } return ("000" + s).slice(l * -1); }; /** * Converts a PHP format string to Java/.NET format string. * A PHP format string can be used with ._format or .format. * A Java/.NET format string can be used with .toString(). * The .parseExact function will only accept a Java/.NET format string * * Example * var f1 = "%m/%d/%y" * var f2 = Date.normalizeFormat(f1); // "MM/dd/yy" * * new Date().format(f1); // "04/13/08" * new Date()._format(f1); // "04/13/08" * new Date().toString(f2); // "04/13/08" * * var date = Date.parseExact("04/13/08", f2); // Sun Apr 13 2008 * * @param {String} A PHP format string consisting of one or more format spcifiers. * @return {String} The PHP format converted to a Java/.NET format string. */ var normalizerSubstitutions = { "d" : "dd", "%d": "dd", "D" : "ddd", "%a": "ddd", "j" : "dddd", "l" : "dddd", "%A": "dddd", "S" : "S", "F" : "MMMM", "%B": "MMMM", "m" : "MM", "%m": "MM", "M" : "MMM", "%b": "MMM", "%h": "MMM", "n" : "M", "Y" : "yyyy", "%Y": "yyyy", "y" : "yy", "%y": "yy", "g" : "h", "%I": "h", "G" : "H", "h" : "hh", "H" : "HH", "%H": "HH", "i" : "mm", "%M": "mm", "s" : "ss", "%S": "ss", "%r": "hh:mm tt", "%R": "H:mm", "%T": "H:mm:ss", "%X": "t", "%x": "d", "%e": "d", "%D": "MM/dd/yy", "%n": "\\n", "%t": "\\t", "e" : "z", "T" : "z", "%z": "z", "%Z": "z", "Z" : "ZZ", "N" : "u", "w" : "u", "%w": "u", "W" : "W", "%V": "W" }; var normalizer = { substitutes: function (m) { return normalizerSubstitutions[m]; }, interpreted: function (m, x) { var y; switch (m) { case "%u": return x.getDay() + 1; case "z": return x.getOrdinalNumber(); case "%j": return p(x.getOrdinalNumber(), 3); case "%U": var d1 = x.clone().set({month: 0, day: 1}).addDays(-1).moveToDayOfWeek(0), d2 = x.clone().addDays(1).moveToDayOfWeek(0, -1); return (d2 < d1) ? "00" : p((d2.getOrdinalNumber() - d1.getOrdinalNumber()) / 7 + 1); case "%W": return p(x.getWeek()); case "t": return $D.getDaysInMonth(x.getFullYear(), x.getMonth()); case "o": case "%G": return x.setWeek(x.getISOWeek()).toString("yyyy"); case "%g": return x._format("%G").slice(-2); case "a": case "%p": return t("tt").toLowerCase(); case "A": return t("tt").toUpperCase(); case "u": return p(x.getMilliseconds(), 3); case "I": return (x.isDaylightSavingTime()) ? 1 : 0; case "O": return x.getUTCOffset(); case "P": y = x.getUTCOffset(); return y.substring(0, y.length - 2) + ":" + y.substring(y.length - 2); case "B": var now = new Date(); return Math.floor(((now.getHours() * 3600) + (now.getMinutes() * 60) + now.getSeconds() + (now.getTimezoneOffset() + 60) * 60) / 86.4); case "c": return x.toISOString().replace(/\"/g, ""); case "U": return $D.strtotime("now"); case "%c": return t("d") + " " + t("t"); case "%C": return Math.floor(x.getFullYear() / 100 + 1); } }, shouldOverrideDefaults: function (m) { switch (m) { case "%e": return true; default: return false; } }, parse: function (m, context) { var formatString, c = context || new Date(); formatString = normalizer.substitutes(m); if (formatString) { return formatString; } formatString = normalizer.interpreted(m, c); if (formatString) { return formatString; } else { return m; } } }; $D.normalizeFormat = function (format, context) { return format.replace(/(%|\\)?.|%%/g, function(t){ return normalizer.parse(t, context); }); }; /** * Format a local Unix timestamp according to locale settings * * Example: * Date.strftime("%m/%d/%y", new Date()); // "04/13/08" * Date.strftime("c", "2008-04-13T17:52:03Z"); // "04/13/08" * * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @param {Number|String} The number representing the number of seconds that have elapsed since January 1, 1970 (local time). * @return {String} A string representation of the current Date object. */ $D.strftime = function (format, time) { var d = Date.parse(time); return d._format(format); }; /** * Parse any textual datetime description into a Unix timestamp. * A Unix timestamp is the number of seconds that have elapsed since January 1, 1970 (midnight UTC/GMT). * * Example: * Date.strtotime("04/13/08"); // 1208044800 * Date.strtotime("1970-01-01T00:00:00Z"); // 0 * * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @param {Object} A string or date object. * @return {String} A string representation of the current Date object. */ $D.strtotime = function (time) { var d = $D.parse(time); return Math.round($D.UTC(d.getUTCFullYear(), d.getUTCMonth(), d.getUTCDate(), d.getUTCHours(), d.getUTCMinutes(), d.getUTCSeconds(), d.getUTCMilliseconds()) / 1000); }; /** * Converts the value of the current Date object to its equivalent string representation using a PHP/Unix style of date format specifiers. * Format Specifiers * Format Description Example * ------ --------------------------------------------------------------------------- ----------------------- * %a abbreviated weekday name according to the current localed "Mon" through "Sun" * %A full weekday name according to the current localed "Sunday" through "Saturday" * %b abbreviated month name according to the current localed "Jan" through "Dec" * %B full month name according to the current locale "January" through "December" * %c preferred date and time representation for the current locale "4/13/2008 12:33 PM" * %C century number (the year divided by 100 and truncated to an integer) "00" to "99" * %d day of the month as a decimal number "01" to "31" * %D same as %m/%d/%y "04/13/08" * %e day of the month as a decimal number, a single digit is preceded by a space "1" to "31" * %g like %G, but without the century "08" * %G The 4-digit year corresponding to the ISO week number (see %V). "2008" * This has the same format and value as %Y, except that if the ISO week number * belongs to the previous or next year, that year is used instead. * %h same as %b "Jan" through "Dec" * %H hour as a decimal number using a 24-hour clock. "00" to "23" * %I hour as a decimal number using a 12-hour clock. "01" to "12" * %j day of the year as a decimal number. "001" to "366" * %m month as a decimal number. "01" to "12" * %M minute as a decimal number. "00" to "59" * %n newline character "\n" * %p either "am" or "pm" according to the given time value, or the "am" or "pm" * corresponding strings for the current locale. * %r time in a.m. and p.m. notation "8:44 PM" * %R time in 24 hour notation "20:44" * %S second as a decimal number "00" to "59" * %t tab character "\t" * %T current time, equal to %H:%M:%S "12:49:11" * %u weekday as a decimal number ["1", "7"], with "1" representing Monday "1" to "7" * %U week number of the current year as a decimal number, starting with the "0" to ("52" or "53") * first Sunday as the first day of the first week * %V The ISO 8601:1988 week number of the current year as a decimal number, "00" to ("52" or "53") * range 01 to 53, where week 1 is the first week that has at least 4 days * in the current year, and with Monday as the first day of the week. * (Use %G or %g for the year component that corresponds to the week number * for the specified timestamp.) * %W week number of the current year as a decimal number, starting with the "00" to ("52" or "53") * first Monday as the first day of the first week * %w day of the week as a decimal, Sunday being "0" "0" to "6" * %x preferred date representation for the current locale without the time "4/13/2008" * %X preferred time representation for the current locale without the date "12:53:05" * %y year as a decimal number without a century "00" "99" * %Y year as a decimal number including the century "2008" * %Z time zone or name or abbreviation "UTC", "EST", "PST" * %z same as %Z * %% a literal "%" characters "%" * d Day of the month, 2 digits with leading zeros "01" to "31" * D A textual representation of a day, three letters "Mon" through "Sun" * j Day of the month without leading zeros "1" to "31" * l A full textual representation of the day of the week (lowercase "L") "Sunday" through "Saturday" * N ISO-8601 numeric representation of the day of the week (added in PHP 5.1.0) "1" (for Monday) through "7" (for Sunday) * S English ordinal suffix for the day of the month, 2 characters "st", "nd", "rd" or "th". Works well with j * w Numeric representation of the day of the week "0" (for Sunday) through "6" (for Saturday) * z The day of the year (starting from "0") "0" through "365" * W ISO-8601 week number of year, weeks starting on Monday "00" to ("52" or "53") * F A full textual representation of a month, such as January or March "January" through "December" * m Numeric representation of a month, with leading zeros "01" through "12" * M A short textual representation of a month, three letters "Jan" through "Dec" * n Numeric representation of a month, without leading zeros "1" through "12" * t Number of days in the given month "28" through "31" * L Whether it's a leap year "1" if it is a leap year, "0" otherwise * o ISO-8601 year number. This has the same value as Y, except that if the "2008" * ISO week number (W) belongs to the previous or next year, that year * is used instead. * Y A full numeric representation of a year, 4 digits "2008" * y A two digit representation of a year "08" * a Lowercase Ante meridiem and Post meridiem "am" or "pm" * A Uppercase Ante meridiem and Post meridiem "AM" or "PM" * B Swatch Internet time "000" through "999" * g 12-hour format of an hour without leading zeros "1" through "12" * G 24-hour format of an hour without leading zeros "0" through "23" * h 12-hour format of an hour with leading zeros "01" through "12" * H 24-hour format of an hour with leading zeros "00" through "23" * i Minutes with leading zeros "00" to "59" * s Seconds, with leading zeros "00" through "59" * u Milliseconds "54321" * e Timezone identifier "UTC", "EST", "PST" * I Whether or not the date is in daylight saving time (uppercase i) "1" if Daylight Saving Time, "0" otherwise * O Difference to Greenwich time (GMT) in hours "+0200", "-0600" * P Difference to Greenwich time (GMT) with colon between hours and minutes "+02:00", "-06:00" * T Timezone abbreviation "UTC", "EST", "PST" * Z Timezone offset in seconds. The offset for timezones west of UTC is "-43200" through "50400" * always negative, and for those east of UTC is always positive. * c ISO 8601 date "2004-02-12T15:19:21+00:00" * r RFC 2822 formatted date "Thu, 21 Dec 2000 16:01:07 +0200" * U Seconds since the Unix Epoch (January 1 1970 00:00:00 GMT) "0" * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @return {String} A string representation of the current Date object. */ var formatReplace = function (context) { return function (m) { var formatString, override = false; if (m.charAt(0) === "\\" || m.substring(0, 2) === "%%") { return m.replace("\\", "").replace("%%", "%"); } override = normalizer.shouldOverrideDefaults(m); formatString = $D.normalizeFormat(m, context); if (formatString) { return context.toString(formatString, override); } }; }; $P._format = function (format) { var formatter = formatReplace(this); if (!format) { return this._toString(); } else { return format.replace(/(%|\\)?.|%%/g, formatter); } }; if (!$P.format) { $P.format = $P._format; } }()); (function () { "use strict"; var gFn = function (attr) { return function () { return this[attr]; }; }; var sFn = function (attr) { return function (val) { this[attr] = val; return this; }; }; var attrs = ["years", "months", "days", "hours", "minutes", "seconds", "milliseconds"]; var addSetFuncs = function (context, attrs) { for (var i = 0; i < attrs.length ; i++) { var $a = attrs[i], $b = $a.slice(0, 1).toUpperCase() + $a.slice(1); context.prototype[$a] = 0; context.prototype["get" + $b] = gFn($a); context.prototype["set" + $b] = sFn($a); } }; /** * new TimeSpan(milliseconds); * new TimeSpan(days, hours, minutes, seconds); * new TimeSpan(days, hours, minutes, seconds, milliseconds); */ var TimeSpan = function (days, hours, minutes, seconds, milliseconds) { if (arguments.length === 1 && typeof days === "number") { var orient = (days < 0) ? -1 : +1; var millsLeft = Math.abs(days); this.setDays(Math.floor(millsLeft / 86400000) * orient); millsLeft = millsLeft % 86400000; this.setHours(Math.floor(millsLeft / 3600000) * orient); millsLeft = millsLeft % 3600000; this.setMinutes(Math.floor(millsLeft / 60000) * orient); millsLeft = millsLeft % 60000; this.setSeconds(Math.floor(millsLeft / 1000) * orient); millsLeft = millsLeft % 1000; this.setMilliseconds(millsLeft * orient); } else { this.set(days, hours, minutes, seconds, milliseconds); } this.getTotalMilliseconds = function () { return (this.getDays() * 86400000) + (this.getHours() * 3600000) + (this.getMinutes() * 60000) + (this.getSeconds() * 1000); }; this.compareTo = function (time) { var t1 = new Date(1970, 1, 1, this.getHours(), this.getMinutes(), this.getSeconds()), t2; if (time === null) { t2 = new Date(1970, 1, 1, 0, 0, 0); } else { t2 = new Date(1970, 1, 1, time.getHours(), time.getMinutes(), time.getSeconds()); } return (t1 < t2) ? -1 : (t1 > t2) ? 1 : 0; }; this.equals = function (time) { return (this.compareTo(time) === 0); }; this.add = function (time) { return (time === null) ? this : this.addSeconds(time.getTotalMilliseconds() / 1000); }; this.subtract = function (time) { return (time === null) ? this : this.addSeconds(-time.getTotalMilliseconds() / 1000); }; this.addDays = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 86400000)); }; this.addHours = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 3600000)); }; this.addMinutes = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 60000)); }; this.addSeconds = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 1000)); }; this.addMilliseconds = function (n) { return new TimeSpan(this.getTotalMilliseconds() + n); }; this.get12HourHour = function () { return (this.getHours() > 12) ? this.getHours() - 12 : (this.getHours() === 0) ? 12 : this.getHours(); }; this.getDesignator = function () { return (this.getHours() < 12) ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator; }; this.toString = function (format) { this._toString = function () { if (this.getDays() !== null && this.getDays() > 0) { return this.getDays() + "." + this.getHours() + ":" + this.p(this.getMinutes()) + ":" + this.p(this.getSeconds()); } else { return this.getHours() + ":" + this.p(this.getMinutes()) + ":" + this.p(this.getSeconds()); } }; this.p = function (s) { return (s.toString().length < 2) ? "0" + s : s; }; var me = this; return format ? format.replace(/dd?|HH?|hh?|mm?|ss?|tt?/g, function (format) { switch (format) { case "d": return me.getDays(); case "dd": return me.p(me.getDays()); case "H": return me.getHours(); case "HH": return me.p(me.getHours()); case "h": return me.get12HourHour(); case "hh": return me.p(me.get12HourHour()); case "m": return me.getMinutes(); case "mm": return me.p(me.getMinutes()); case "s": return me.getSeconds(); case "ss": return me.p(me.getSeconds()); case "t": return ((me.getHours() < 12) ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator).substring(0, 1); case "tt": return (me.getHours() < 12) ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator; } } ) : this._toString(); }; return this; }; addSetFuncs(TimeSpan, attrs.slice(2)); TimeSpan.prototype.set = function (days, hours, minutes, seconds, milliseconds){ this.setDays(days || this.getDays()); this.setHours(hours || this.getHours()); this.setMinutes(minutes || this.getMinutes()); this.setSeconds(seconds || this.getSeconds()); this.setMilliseconds(milliseconds || this.getMilliseconds()); }; /** * Gets the time of day for this date instances. * @return {TimeSpan} TimeSpan */ Date.prototype.getTimeOfDay = function () { return new TimeSpan(0, this.getHours(), this.getMinutes(), this.getSeconds(), this.getMilliseconds()); }; Date.TimeSpan = TimeSpan; if (typeof window !== "undefined" ) { // keeping API compatible for v1.x window.TimeSpan = TimeSpan; } }()); (function () { "use strict"; var attrs = ["years", "months", "days", "hours", "minutes", "seconds", "milliseconds"]; var gFn = function (attr) { return function () { return this[attr]; }; }; var sFn = function (attr) { return function (val) { this[attr] = val; return this; }; }; var addSetFuncs = function (context, attrs) { for (var i = 0; i < attrs.length ; i++) { var $a = attrs[i], $b = $a.slice(0, 1).toUpperCase() + $a.slice(1); context.prototype[$a] = 0; context.prototype["get" + $b] = gFn($a); context.prototype["set" + $b] = sFn($a); } }; var setMonthsAndYears = function (orient, d1, d2, context) { function inc() { d1.addMonths(-orient); context.months++; if (context.months === 12) { context.years++; context.months = 0; } } if (orient === +1) { while (d1 > d2) { inc(); } } else { while (d1 < d2) { inc(); } } context.months--; context.months *= orient; context.years *= orient; }; var adjustForDST = function(orient, startDate, endDate) { var hasDSTMismatch = (false === (startDate.isDaylightSavingTime() === endDate.isDaylightSavingTime())); if (hasDSTMismatch && orient === 1) { startDate.addHours(-1); } else if (hasDSTMismatch) { startDate.addHours(1); } }; /** * TimePeriod(startDate, endDate); * TimePeriod(years, months, days, hours, minutes, seconds, milliseconds); */ var TimePeriod = function (years, months, days, hours, minutes, seconds, milliseconds) { if (arguments.length === 7) { this.set(years, months, days, hours, minutes, seconds, milliseconds); } else if (arguments.length === 2 && arguments[0] instanceof Date && arguments[1] instanceof Date) { var startDate = arguments[0].clone(); var endDate = arguments[1].clone(); var orient = (startDate > endDate) ? +1 : -1; this.dates = { start: arguments[0].clone(), end: arguments[1].clone() }; setMonthsAndYears(orient, startDate, endDate, this); adjustForDST(orient, startDate, endDate); // // TODO - adjust for DST var diff = endDate - startDate; if (diff !== 0) { var ts = new TimeSpan(diff); this.set(this.years, this.months, ts.getDays(), ts.getHours(), ts.getMinutes(), ts.getSeconds(), ts.getMilliseconds()); } } return this; }; // create all the set functions. addSetFuncs(TimePeriod, attrs); TimePeriod.prototype.set = function (years, months, days, hours, minutes, seconds, milliseconds){ this.setYears(years || this.getYears()); this.setMonths(months || this.getMonths()); this.setDays(days || this.getDays()); this.setHours(hours || this.getHours()); this.setMinutes(minutes || this.getMinutes()); this.setSeconds(seconds || this.getSeconds()); this.setMilliseconds(milliseconds || this.getMilliseconds()); }; Date.TimePeriod = TimePeriod; if (typeof window !== "undefined") { // keeping API compatible for v1.x window.TimePeriod = TimePeriod; } }()); ================================================ FILE: build/date-es-EC.js ================================================ /** * @overview datejs * @version 1.0.0-rc3 * @author Gregory Wild-Smith * @copyright 2015 Gregory Wild-Smith * @license MIT * @homepage https://github.com/abritinthebay/datejs */ /* * DateJS Culture String File * Country Code: es-EC * Name: Spanish (Ecuador) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["es-EC"] = { "name": "es-EC", "englishName": "Spanish (Ecuador)", "nativeName": "Español (Ecuador)", "Sunday": "domingo", "Monday": "lunes", "Tuesday": "martes", "Wednesday": "miércoles", "Thursday": "jueves", "Friday": "viernes", "Saturday": "sábado", "Sun": "dom", "Mon": "lun", "Tue": "mar", "Wed": "mié", "Thu": "jue", "Fri": "vie", "Sat": "sáb", "Su": "do", "Mo": "lu", "Tu": "ma", "We": "mi", "Th": "ju", "Fr": "vi", "Sa": "sá", "S_Sun_Initial": "d", "M_Mon_Initial": "l", "T_Tue_Initial": "m", "W_Wed_Initial": "m", "T_Thu_Initial": "j", "F_Fri_Initial": "v", "S_Sat_Initial": "s", "January": "enero", "February": "febrero", "March": "marzo", "April": "abril", "May": "mayo", "June": "junio", "July": "julio", "August": "agosto", "September": "septiembre", "October": "octubre", "November": "noviembre", "December": "diciembre", "Jan_Abbr": "ene", "Feb_Abbr": "feb", "Mar_Abbr": "mar", "Apr_Abbr": "abr", "May_Abbr": "may", "Jun_Abbr": "jun", "Jul_Abbr": "jul", "Aug_Abbr": "ago", "Sep_Abbr": "sep", "Oct_Abbr": "oct", "Nov_Abbr": "nov", "Dec_Abbr": "dic", "AM": "", "PM": "", "firstDayOfWeek": 0, "twoDigitYearMax": 2029, "mdy": "dmy", "M/d/yyyy": "dd/MM/yyyy", "dddd, MMMM dd, yyyy": "dddd, dd' [de] 'MMMM' [de] 'yyyy", "h:mm tt": "H:mm", "h:mm:ss tt": "H:mm:ss", "dddd, MMMM dd, yyyy h:mm:ss tt": "dddd, dd' [de] 'MMMM' [de] 'yyyy H:mm:ss", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "dd MMMM", "MMMM, yyyy": "MMMM' [de] 'yyyy", "/jan(uary)?/": "ene(ro)?", "/feb(ruary)?/": "feb(rero)?", "/mar(ch)?/": "mar(zo)?", "/apr(il)?/": "abr(il)?", "/may/": "may(o)?", "/jun(e)?/": "jun(io)?", "/jul(y)?/": "jul(io)?", "/aug(ust)?/": "ago(sto)?", "/sep(t(ember)?)?/": "sep(tiembre)?", "/oct(ober)?/": "oct(ubre)?", "/nov(ember)?/": "nov(iembre)?", "/dec(ember)?/": "dic(iembre)?", "/^su(n(day)?)?/": "^do(m(ingo)?)?", "/^mo(n(day)?)?/": "^lu(n(es)?)?", "/^tu(e(s(day)?)?)?/": "^ma(r(tes)?)?", "/^we(d(nesday)?)?/": "^mi(é(rcoles)?)?", "/^th(u(r(s(day)?)?)?)?/": "^ju(e(ves)?)?", "/^fr(i(day)?)?/": "^vi(e(rnes)?)?", "/^sa(t(urday)?)?/": "^sá(b(ado)?)?", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "es-EC"; /** * @overview datejs * @version 1.0.0-rc3 * @author Gregory Wild-Smith * @copyright 2015 Gregory Wild-Smith * @license MIT * @homepage https://github.com/abritinthebay/datejs */(function () { var $D = Date; var lang = Date.CultureStrings ? Date.CultureStrings.lang : null; var loggedKeys = {}; // for debug purposes. var getText = { getFromKey: function (key, countryCode) { var output; if (Date.CultureStrings && Date.CultureStrings[countryCode] && Date.CultureStrings[countryCode][key]) { output = Date.CultureStrings[countryCode][key]; } else { output = getText.buildFromDefault(key); } if (key.charAt(0) === "/") { // Assume it's a regex output = getText.buildFromRegex(key, countryCode); } return output; }, getFromObjectValues: function (obj, countryCode) { var key, output = {}; for(key in obj) { if (obj.hasOwnProperty(key)) { output[key] = getText.getFromKey(obj[key], countryCode); } } return output; }, getFromObjectKeys: function (obj, countryCode) { var key, output = {}; for(key in obj) { if (obj.hasOwnProperty(key)) { output[getText.getFromKey(key, countryCode)] = obj[key]; } } return output; }, getFromArray: function (arr, countryCode) { var output = []; for (var i=0; i < arr.length; i++){ if (i in arr) { output[i] = getText.getFromKey(arr[i], countryCode); } } return output; }, buildFromDefault: function (key) { var output, length, split, last; switch(key) { case "name": output = "en-US"; break; case "englishName": output = "English (United States)"; break; case "nativeName": output = "English (United States)"; break; case "twoDigitYearMax": output = 2049; break; case "firstDayOfWeek": output = 0; break; default: output = key; split = key.split("_"); length = split.length; if (length > 1 && key.charAt(0) !== "/") { // if the key isn't a regex and it has a split. last = split[(length - 1)].toLowerCase(); if (last === "initial" || last === "abbr") { output = split[0]; } } break; } return output; }, buildFromRegex: function (key, countryCode) { var output; if (Date.CultureStrings && Date.CultureStrings[countryCode] && Date.CultureStrings[countryCode][key]) { output = new RegExp(Date.CultureStrings[countryCode][key], "i"); } else { output = new RegExp(key.replace(new RegExp("/", "g"),""), "i"); } return output; } }; var shallowMerge = function (obj1, obj2) { for (var attrname in obj2) { if (obj2.hasOwnProperty(attrname)) { obj1[attrname] = obj2[attrname]; } } }; var __ = function (key, language) { var countryCode = (language) ? language : lang; loggedKeys[key] = key; if (typeof key === "object") { if (key instanceof Array) { return getText.getFromArray(key, countryCode); } else { return getText.getFromObjectKeys(key, countryCode); } } else { return getText.getFromKey(key, countryCode); } }; var loadI18nScript = function (code) { // paatterned after jQuery's getScript. var url = Date.Config.i18n + code + ".js"; var head = document.getElementsByTagName("head")[0] || document.documentElement; var script = document.createElement("script"); script.src = url; var completed = false; var events = { done: function (){} // placeholder function }; // Attach handlers for all browsers script.onload = script.onreadystatechange = function() { if ( !completed && (!this.readyState || this.readyState === "loaded" || this.readyState === "complete") ) { events.done(); head.removeChild(script); } }; setTimeout(function() { head.insertBefore(script, head.firstChild); }, 0); // allows return to execute first return { done: function (cb) { events.done = function() { if (cb) { setTimeout(cb,0); } }; } }; }; var buildInfo = { buildFromMethodHash: function (obj) { var key; for(key in obj) { if (obj.hasOwnProperty(key)) { obj[key] = buildInfo[obj[key]](); } } return obj; }, timeZoneDST: function () { var DST = { "CHADT": "+1345", "NZDT": "+1300", "AEDT": "+1100", "ACDT": "+1030", "AZST": "+0500", "IRDT": "+0430", "EEST": "+0300", "CEST": "+0200", "BST": "+0100", "PMDT": "-0200", "ADT": "-0300", "NDT": "-0230", "EDT": "-0400", "CDT": "-0500", "MDT": "-0600", "PDT": "-0700", "AKDT": "-0800", "HADT": "-0900" }; return __(DST); }, timeZoneStandard: function () { var standard = { "LINT": "+1400", "TOT": "+1300", "CHAST": "+1245", "NZST": "+1200", "NFT": "+1130", "SBT": "+1100", "AEST": "+1000", "ACST": "+0930", "JST": "+0900", "CWST": "+0845", "CT": "+0800", "ICT": "+0700", "MMT": "+0630", "BST": "+0600", "NPT": "+0545", "IST": "+0530", "PKT": "+0500", "AFT": "+0430", "MSK": "+0400", "IRST": "+0330", "FET": "+0300", "EET": "+0200", "CET": "+0100", "GMT": "+0000", "UTC": "+0000", "CVT": "-0100", "GST": "-0200", "BRT": "-0300", "NST": "-0330", "AST": "-0400", "EST": "-0500", "CST": "-0600", "MST": "-0700", "PST": "-0800", "AKST": "-0900", "MIT": "-0930", "HST": "-1000", "SST": "-1100", "BIT": "-1200" }; return __(standard); }, timeZones: function (data) { var zone; data.timezones = []; for (zone in data.abbreviatedTimeZoneStandard) { if (data.abbreviatedTimeZoneStandard.hasOwnProperty(zone)) { data.timezones.push({ name: zone, offset: data.abbreviatedTimeZoneStandard[zone]}); } } for (zone in data.abbreviatedTimeZoneDST) { if (data.abbreviatedTimeZoneDST.hasOwnProperty(zone)) { data.timezones.push({ name: zone, offset: data.abbreviatedTimeZoneDST[zone], dst: true}); } } return data.timezones; }, days: function () { return __(["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"]); }, dayAbbr: function () { return __(["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"]); }, dayShortNames: function () { return __(["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"]); }, dayFirstLetters: function () { return __(["S_Sun_Initial", "M_Mon_Initial", "T_Tues_Initial", "W_Wed_Initial", "T_Thu_Initial", "F_Fri_Initial", "S_Sat_Initial"]); }, months: function () { return __(["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"]); }, monthAbbr: function () { return __(["Jan_Abbr", "Feb_Abbr", "Mar_Abbr", "Apr_Abbr", "May_Abbr", "Jun_Abbr", "Jul_Abbr", "Aug_Abbr", "Sep_Abbr", "Oct_Abbr", "Nov_Abbr", "Dec_Abbr"]); }, formatPatterns: function () { return getText.getFromObjectValues({ shortDate: "M/d/yyyy", longDate: "dddd, MMMM dd, yyyy", shortTime: "h:mm tt", longTime: "h:mm:ss tt", fullDateTime: "dddd, MMMM dd, yyyy h:mm:ss tt", sortableDateTime: "yyyy-MM-ddTHH:mm:ss", universalSortableDateTime: "yyyy-MM-dd HH:mm:ssZ", rfc1123: "ddd, dd MMM yyyy HH:mm:ss", monthDay: "MMMM dd", yearMonth: "MMMM, yyyy" }, Date.i18n.currentLanguage()); }, regex: function () { return getText.getFromObjectValues({ inTheMorning: "/( in the )(morn(ing)?)\\b/", thisMorning: "/(this )(morn(ing)?)\\b/", amThisMorning: "/(\b\\d(am)? )(this )(morn(ing)?)/", inTheEvening: "/( in the )(even(ing)?)\\b/", thisEvening: "/(this )(even(ing)?)\\b/", pmThisEvening: "/(\b\\d(pm)? )(this )(even(ing)?)/", jan: "/jan(uary)?/", feb: "/feb(ruary)?/", mar: "/mar(ch)?/", apr: "/apr(il)?/", may: "/may/", jun: "/jun(e)?/", jul: "/jul(y)?/", aug: "/aug(ust)?/", sep: "/sep(t(ember)?)?/", oct: "/oct(ober)?/", nov: "/nov(ember)?/", dec: "/dec(ember)?/", sun: "/^su(n(day)?)?/", mon: "/^mo(n(day)?)?/", tue: "/^tu(e(s(day)?)?)?/", wed: "/^we(d(nesday)?)?/", thu: "/^th(u(r(s(day)?)?)?)?/", fri: "/fr(i(day)?)?/", sat: "/^sa(t(urday)?)?/", future: "/^next/", past: "/^last|past|prev(ious)?/", add: "/^(\\+|aft(er)?|from|hence)/", subtract: "/^(\\-|bef(ore)?|ago)/", yesterday: "/^yes(terday)?/", today: "/^t(od(ay)?)?/", tomorrow: "/^tom(orrow)?/", now: "/^n(ow)?/", millisecond: "/^ms|milli(second)?s?/", second: "/^sec(ond)?s?/", minute: "/^mn|min(ute)?s?/", hour: "/^h(our)?s?/", week: "/^w(eek)?s?/", month: "/^m(onth)?s?/", day: "/^d(ay)?s?/", year: "/^y(ear)?s?/", shortMeridian: "/^(a|p)/", longMeridian: "/^(a\\.?m?\\.?|p\\.?m?\\.?)/", timezone: "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/", ordinalSuffix: "/^\\s*(st|nd|rd|th)/", timeContext: "/^\\s*(\\:|a(?!u|p)|p)/" }, Date.i18n.currentLanguage()); } }; var CultureInfo = function () { var info = getText.getFromObjectValues({ name: "name", englishName: "englishName", nativeName: "nativeName", amDesignator: "AM", pmDesignator: "PM", firstDayOfWeek: "firstDayOfWeek", twoDigitYearMax: "twoDigitYearMax", dateElementOrder: "mdy" }, Date.i18n.currentLanguage()); var constructedInfo = buildInfo.buildFromMethodHash({ dayNames: "days", abbreviatedDayNames: "dayAbbr", shortestDayNames: "dayShortNames", firstLetterDayNames: "dayFirstLetters", monthNames: "months", abbreviatedMonthNames: "monthAbbr", formatPatterns: "formatPatterns", regexPatterns: "regex", abbreviatedTimeZoneDST: "timeZoneDST", abbreviatedTimeZoneStandard: "timeZoneStandard" }); shallowMerge(info, constructedInfo); buildInfo.timeZones(info); return info; }; $D.i18n = { __: function (key, lang) { return __(key, lang); }, currentLanguage: function () { return lang || "en-US"; }, setLanguage: function (code, force, cb) { var async = false; if (force || code === "en-US" || (!!Date.CultureStrings && !!Date.CultureStrings[code])) { lang = code; Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings.lang = code; Date.CultureInfo = new CultureInfo(); } else { if (!(!!Date.CultureStrings && !!Date.CultureStrings[code])) { if (typeof exports !== "undefined" && this.exports !== exports) { // we're in a Node enviroment, load it using require try { require("../i18n/" + code + ".js"); lang = code; Date.CultureStrings.lang = code; Date.CultureInfo = new CultureInfo(); } catch (e) { // var str = "The language for '" + code + "' could not be loaded by Node. It likely does not exist."; throw new Error("The DateJS IETF language tag '" + code + "' could not be loaded by Node. It likely does not exist."); } } else if (Date.Config && Date.Config.i18n) { // we know the location of the files, so lets load them async = true; loadI18nScript(code).done(function(){ lang = code; Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings.lang = code; Date.CultureInfo = new CultureInfo(); $D.Parsing.Normalizer.buildReplaceData(); // because this is async if ($D.Grammar) { $D.Grammar.buildGrammarFormats(); // so we can parse those strings... } if (cb) { setTimeout(cb,0); } }); } else { Date.console.error("The DateJS IETF language tag '" + code + "' is not available and has not been loaded."); return false; } } } $D.Parsing.Normalizer.buildReplaceData(); // rebuild normalizer strings if ($D.Grammar) { $D.Grammar.buildGrammarFormats(); // so we can parse those strings... } if (!async && cb) { setTimeout(cb,0); } }, getLoggedKeys: function () { return loggedKeys; }, updateCultureInfo: function () { Date.CultureInfo = new CultureInfo(); } }; $D.i18n.updateCultureInfo(); // run automatically }()); (function () { var $D = Date, $P = $D.prototype, p = function (s, l) { if (!l) { l = 2; } return ("000" + s).slice(l * -1); }; if (typeof window !== "undefined" && typeof window.console !== "undefined" && typeof window.console.log !== "undefined") { $D.console = console; // used only to raise non-critical errors if available } else { // set mock so we don't give errors. $D.console = { log: function(){}, error: function(){} }; } $D.Config = $D.Config || {}; $D.initOverloads = function() { /** * Overload of Date.now. Allows an alternate call for Date.now where it returns the * current Date as an object rather than just milliseconds since the Unix Epoch. * * Also provides an implementation of now() for browsers (IE<9) that don't have it. * * Backwards compatible so with work with either: * Date.now() [returns ms] * or * Date.now(true) [returns Date] */ if (!$D.now) { $D._now = function now() { return new Date().getTime(); }; } else if (!$D._now) { $D._now = $D.now; } $D.now = function (returnObj) { if (returnObj) { return $D.present(); } else { return $D._now(); } }; if ( !$P.toISOString ) { $P.toISOString = function() { return this.getUTCFullYear() + "-" + p(this.getUTCMonth() + 1) + "-" + p(this.getUTCDate()) + "T" + p(this.getUTCHours()) + ":" + p(this.getUTCMinutes()) + ":" + p(this.getUTCSeconds()) + "." + String( (this.getUTCMilliseconds()/1000).toFixed(3)).slice(2, 5) + "Z"; }; } // private if ( $P._toString === undefined ){ $P._toString = $P.toString; } }; $D.initOverloads(); /** * Gets a date that is set to the current date. The time is set to the start of the day (00:00 or 12:00 AM). * @return {Date} The current date. */ $D.today = function () { return new Date().clearTime(); }; /** * Gets a date that is set to the current date and time (same as new Date, but chainable) * @return {Date} The current date. */ $D.present = function () { return new Date(); }; /** * Compares the first date to the second date and returns an number indication of their relative values. * @param {Date} First Date object to compare [Required]. * @param {Date} Second Date object to compare to [Required]. * @return {Number} -1 = date1 is lessthan date2. 0 = values are equal. 1 = date1 is greaterthan date2. */ $D.compare = function (date1, date2) { if (isNaN(date1) || isNaN(date2)) { throw new Error(date1 + " - " + date2); } else if (date1 instanceof Date && date2 instanceof Date) { return (date1 < date2) ? -1 : (date1 > date2) ? 1 : 0; } else { throw new TypeError(date1 + " - " + date2); } }; /** * Compares the first Date object to the second Date object and returns true if they are equal. * @param {Date} First Date object to compare [Required] * @param {Date} Second Date object to compare to [Required] * @return {Boolean} true if dates are equal. false if they are not equal. */ $D.equals = function (date1, date2) { return (date1.compareTo(date2) === 0); }; /** * Gets the language appropriate day name when given the day number(0-6) * eg - 0 == Sunday * @return {String} The day name */ $D.getDayName = function (n) { return Date.CultureInfo.dayNames[n]; }; /** * Gets the day number (0-6) if given a CultureInfo specific string which is a valid dayName, abbreviatedDayName or shortestDayName (two char). * @param {String} The name of the day (eg. "Monday, "Mon", "tuesday", "tue", "We", "we"). * @return {Number} The day number */ $D.getDayNumberFromName = function (name) { var n = Date.CultureInfo.dayNames, m = Date.CultureInfo.abbreviatedDayNames, o = Date.CultureInfo.shortestDayNames, s = name.toLowerCase(); for (var i = 0; i < n.length; i++) { if (n[i].toLowerCase() === s || m[i].toLowerCase() === s || o[i].toLowerCase() === s) { return i; } } return -1; }; /** * Gets the month number (0-11) if given a Culture Info specific string which is a valid monthName or abbreviatedMonthName. * @param {String} The name of the month (eg. "February, "Feb", "october", "oct"). * @return {Number} The day number */ $D.getMonthNumberFromName = function (name) { var n = Date.CultureInfo.monthNames, m = Date.CultureInfo.abbreviatedMonthNames, s = name.toLowerCase(); for (var i = 0; i < n.length; i++) { if (n[i].toLowerCase() === s || m[i].toLowerCase() === s) { return i; } } return -1; }; /** * Gets the language appropriate month name when given the month number(0-11) * eg - 0 == January * @return {String} The month name */ $D.getMonthName = function (n) { return Date.CultureInfo.monthNames[n]; }; /** * Determines if the current date instance is within a LeapYear. * @param {Number} The year. * @return {Boolean} true if date is within a LeapYear, otherwise false. */ $D.isLeapYear = function (year) { return ((year % 4 === 0 && year % 100 !== 0) || year % 400 === 0); }; /** * Gets the number of days in the month, given a year and month value. Automatically corrects for LeapYear. * @param {Number} The year. * @param {Number} The month (0-11). * @return {Number} The number of days in the month. */ $D.getDaysInMonth = function (year, month) { if (!month && $D.validateMonth(year)) { month = year; year = Date.today().getFullYear(); } return [31, ($D.isLeapYear(year) ? 29 : 28), 31, 30, 31, 30, 31, 31, 30, 31, 30, 31][month]; }; $P.getDaysInMonth = function () { return $D.getDaysInMonth(this.getFullYear(), this.getMonth()); }; $D.getTimezoneAbbreviation = function (offset, dst) { var p, n = (dst || false) ? Date.CultureInfo.abbreviatedTimeZoneDST : Date.CultureInfo.abbreviatedTimeZoneStandard; for (p in n) { if (n.hasOwnProperty(p)) { if (n[p] === offset) { return p; } } } return null; }; $D.getTimezoneOffset = function (name, dst) { var i, a =[], z = Date.CultureInfo.timezones; if (!name) { name = (new Date()).getTimezone();} for (i = 0; i < z.length; i++) { if (z[i].name === name.toUpperCase()) { a.push(i); } } if (!z[a[0]]) { return null; } if (a.length === 1 || !dst) { return z[a[0]].offset; } else { for (i=0; i < a.length; i++) { if (z[a[i]].dst) { return z[a[i]].offset; } } } }; $D.getQuarter = function (d) { d = d || new Date(); // If no date supplied, use today var q = [1,2,3,4]; return q[Math.floor(d.getMonth() / 3)]; // ~~~ is a bitwise op. Faster than Math.floor }; $D.getDaysLeftInQuarter = function (d) { d = d || new Date(); var qEnd = new Date(d); qEnd.setMonth(qEnd.getMonth() + 3 - qEnd.getMonth() % 3, 0); return Math.floor((qEnd - d) / 8.64e7); }; // private var validate = function (n, min, max, name) { name = name ? name : "Object"; if (typeof n === "undefined") { return false; } else if (typeof n !== "number") { throw new TypeError(n + " is not a Number."); } else if (n < min || n > max) { // As failing validation is *not* an exceptional circumstance // lets not throw a RangeError Exception here. // It's semantically correct but it's not sensible. return false; } return true; }; /** * Validates the number is within an acceptable range for milliseconds [0-999]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateMillisecond = function (value) { return validate(value, 0, 999, "millisecond"); }; /** * Validates the number is within an acceptable range for seconds [0-59]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateSecond = function (value) { return validate(value, 0, 59, "second"); }; /** * Validates the number is within an acceptable range for minutes [0-59]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateMinute = function (value) { return validate(value, 0, 59, "minute"); }; /** * Validates the number is within an acceptable range for hours [0-23]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateHour = function (value) { return validate(value, 0, 23, "hour"); }; /** * Validates the number is within an acceptable range for the days in a month [0-MaxDaysInMonth]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateDay = function (value, year, month) { if (year === undefined || year === null || month === undefined || month === null) { return false;} return validate(value, 1, $D.getDaysInMonth(year, month), "day"); }; /** * Validates the number is within an acceptable range for months [0-11]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateWeek = function (value) { return validate(value, 0, 53, "week"); }; /** * Validates the number is within an acceptable range for months [0-11]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateMonth = function (value) { return validate(value, 0, 11, "month"); }; /** * Validates the number is within an acceptable range for years. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateYear = function (value) { /** * Per ECMAScript spec the range of times supported by Date objects is * exactly -100,000,000 days to +100,000,000 days measured relative to * midnight at the beginning of 01 January, 1970 UTC. * This gives a range of 8,640,000,000,000,000 milliseconds to either * side of 01 January, 1970 UTC. * * Earliest possible date: Tue, 20 Apr 271,822 B.C. 00:00:00 UTC * Latest possible date: Sat, 13 Sep 275,760 00:00:00 UTC */ return validate(value, -271822, 275760, "year"); }; $D.validateTimezone = function(value) { var timezones = {"ACDT":1,"ACST":1,"ACT":1,"ADT":1,"AEDT":1,"AEST":1,"AFT":1,"AKDT":1,"AKST":1,"AMST":1,"AMT":1,"ART":1,"AST":1,"AWDT":1,"AWST":1,"AZOST":1,"AZT":1,"BDT":1,"BIOT":1,"BIT":1,"BOT":1,"BRT":1,"BST":1,"BTT":1,"CAT":1,"CCT":1,"CDT":1,"CEDT":1,"CEST":1,"CET":1,"CHADT":1,"CHAST":1,"CHOT":1,"ChST":1,"CHUT":1,"CIST":1,"CIT":1,"CKT":1,"CLST":1,"CLT":1,"COST":1,"COT":1,"CST":1,"CT":1,"CVT":1,"CWST":1,"CXT":1,"DAVT":1,"DDUT":1,"DFT":1,"EASST":1,"EAST":1,"EAT":1,"ECT":1,"EDT":1,"EEDT":1,"EEST":1,"EET":1,"EGST":1,"EGT":1,"EIT":1,"EST":1,"FET":1,"FJT":1,"FKST":1,"FKT":1,"FNT":1,"GALT":1,"GAMT":1,"GET":1,"GFT":1,"GILT":1,"GIT":1,"GMT":1,"GST":1,"GYT":1,"HADT":1,"HAEC":1,"HAST":1,"HKT":1,"HMT":1,"HOVT":1,"HST":1,"ICT":1,"IDT":1,"IOT":1,"IRDT":1,"IRKT":1,"IRST":1,"IST":1,"JST":1,"KGT":1,"KOST":1,"KRAT":1,"KST":1,"LHST":1,"LINT":1,"MAGT":1,"MART":1,"MAWT":1,"MDT":1,"MET":1,"MEST":1,"MHT":1,"MIST":1,"MIT":1,"MMT":1,"MSK":1,"MST":1,"MUT":1,"MVT":1,"MYT":1,"NCT":1,"NDT":1,"NFT":1,"NPT":1,"NST":1,"NT":1,"NUT":1,"NZDT":1,"NZST":1,"OMST":1,"ORAT":1,"PDT":1,"PET":1,"PETT":1,"PGT":1,"PHOT":1,"PHT":1,"PKT":1,"PMDT":1,"PMST":1,"PONT":1,"PST":1,"PYST":1,"PYT":1,"RET":1,"ROTT":1,"SAKT":1,"SAMT":1,"SAST":1,"SBT":1,"SCT":1,"SGT":1,"SLST":1,"SRT":1,"SST":1,"SYOT":1,"TAHT":1,"THA":1,"TFT":1,"TJT":1,"TKT":1,"TLT":1,"TMT":1,"TOT":1,"TVT":1,"UCT":1,"ULAT":1,"UTC":1,"UYST":1,"UYT":1,"UZT":1,"VET":1,"VLAT":1,"VOLT":1,"VOST":1,"VUT":1,"WAKT":1,"WAST":1,"WAT":1,"WEDT":1,"WEST":1,"WET":1,"WST":1,"YAKT":1,"YEKT":1,"Z":1}; return (timezones[value] === 1); }; $D.validateTimezoneOffset= function(value) { // timezones go from +14hrs to -12hrs, the +X hours are negative offsets. return (value > -841 && value < 721); }; }()); (function () { var $D = Date, $P = $D.prototype, p = function (s, l) { if (!l) { l = 2; } return ("000" + s).slice(l * -1); }; var validateConfigObject = function (obj) { var result = {}, self = this, prop, testFunc; testFunc = function (prop, func, value) { if (prop === "day") { var month = (obj.month !== undefined) ? obj.month : self.getMonth(); var year = (obj.year !== undefined) ? obj.year : self.getFullYear(); return $D[func](value, year, month); } else { return $D[func](value); } }; for (prop in obj) { if (Object.prototype.hasOwnProperty.call(obj, prop)) { var func = "validate" + prop.charAt(0).toUpperCase() + prop.slice(1); if ($D[func] && obj[prop] !== null && testFunc(prop, func, obj[prop])) { result[prop] = obj[prop]; } } } return result; }; /** * Resets the time of this Date object to 12:00 AM (00:00), which is the start of the day. * @param {Boolean} .clone() this date instance before clearing Time * @return {Date} this */ $P.clearTime = function () { this.setHours(0); this.setMinutes(0); this.setSeconds(0); this.setMilliseconds(0); return this; }; /** * Resets the time of this Date object to the current time ('now'). * @return {Date} this */ $P.setTimeToNow = function () { var n = new Date(); this.setHours(n.getHours()); this.setMinutes(n.getMinutes()); this.setSeconds(n.getSeconds()); this.setMilliseconds(n.getMilliseconds()); return this; }; /** * Returns a new Date object that is an exact date and time copy of the original instance. * @return {Date} A new Date instance */ $P.clone = function () { return new Date(this.getTime()); }; /** * Compares this instance to a Date object and returns an number indication of their relative values. * @param {Date} Date object to compare [Required] * @return {Number} -1 = this is lessthan date. 0 = values are equal. 1 = this is greaterthan date. */ $P.compareTo = function (date) { return Date.compare(this, date); }; /** * Compares this instance to another Date object and returns true if they are equal. * @param {Date} Date object to compare. If no date to compare, new Date() [now] is used. * @return {Boolean} true if dates are equal. false if they are not equal. */ $P.equals = function (date) { return Date.equals(this, (date !== undefined ? date : new Date())); }; /** * Determines if this instance is between a range of two dates or equal to either the start or end dates. * @param {Date} Start of range [Required] * @param {Date} End of range [Required] * @return {Boolean} true is this is between or equal to the start and end dates, else false */ $P.between = function (start, end) { return this.getTime() >= start.getTime() && this.getTime() <= end.getTime(); }; /** * Determines if this date occurs after the date to compare to. * @param {Date} Date object to compare. If no date to compare, new Date() ("now") is used. * @return {Boolean} true if this date instance is greater than the date to compare to (or "now"), otherwise false. */ $P.isAfter = function (date) { return this.compareTo(date || new Date()) === 1; }; /** * Determines if this date occurs before the date to compare to. * @param {Date} Date object to compare. If no date to compare, new Date() ("now") is used. * @return {Boolean} true if this date instance is less than the date to compare to (or "now"). */ $P.isBefore = function (date) { return (this.compareTo(date || new Date()) === -1); }; /** * Determines if the current Date instance occurs today. * @return {Boolean} true if this date instance is 'today', otherwise false. */ /** * Determines if the current Date instance occurs on the same Date as the supplied 'date'. * If no 'date' to compare to is provided, the current Date instance is compared to 'today'. * @param {date} Date object to compare. If no date to compare, the current Date ("now") is used. * @return {Boolean} true if this Date instance occurs on the same Day as the supplied 'date'. */ $P.isToday = $P.isSameDay = function (date) { return this.clone().clearTime().equals((date || new Date()).clone().clearTime()); }; /** * Adds the specified number of milliseconds to this instance. * @param {Number} The number of milliseconds to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addMilliseconds = function (value) { if (!value) { return this; } this.setTime(this.getTime() + value * 1); return this; }; /** * Adds the specified number of seconds to this instance. * @param {Number} The number of seconds to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addSeconds = function (value) { if (!value) { return this; } return this.addMilliseconds(value * 1000); }; /** * Adds the specified number of seconds to this instance. * @param {Number} The number of seconds to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addMinutes = function (value) { if (!value) { return this; } return this.addMilliseconds(value * 60000); // 60*1000 }; /** * Adds the specified number of hours to this instance. * @param {Number} The number of hours to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addHours = function (value) { if (!value) { return this; } return this.addMilliseconds(value * 3600000); // 60*60*1000 }; /** * Adds the specified number of days to this instance. * @param {Number} The number of days to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addDays = function (value) { if (!value) { return this; } this.setDate(this.getDate() + value * 1); return this; }; /** * Adds the specified number of weekdays (ie - not sat or sun) to this instance. * @param {Number} The number of days to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addWeekdays = function (value) { if (!value) { return this; } var day = this.getDay(); var weeks = (Math.ceil(Math.abs(value)/7)); if (day === 0 || day === 6) { if (value > 0) { this.next().monday(); this.addDays(-1); day = this.getDay(); } } if (value < 0) { while (value < 0) { this.addDays(-1); day = this.getDay(); if (day !== 0 && day !== 6) { value++; } } return this; } else if (value > 5 || (6-day) <= value) { value = value + (weeks * 2); } return this.addDays(value); }; /** * Adds the specified number of weeks to this instance. * @param {Number} The number of weeks to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addWeeks = function (value) { if (!value) { return this; } return this.addDays(value * 7); }; /** * Adds the specified number of months to this instance. * @param {Number} The number of months to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addMonths = function (value) { if (!value) { return this; } var n = this.getDate(); this.setDate(1); this.setMonth(this.getMonth() + value * 1); this.setDate(Math.min(n, $D.getDaysInMonth(this.getFullYear(), this.getMonth()))); return this; }; $P.addQuarters = function (value) { if (!value) { return this; } // note this will take you to the same point in the quarter as you are now. // i.e. - if you are 15 days into the quarter you'll be 15 days into the resulting one. // bonus: this allows adding fractional quarters return this.addMonths(value * 3); }; /** * Adds the specified number of years to this instance. * @param {Number} The number of years to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addYears = function (value) { if (!value) { return this; } return this.addMonths(value * 12); }; /** * Adds (or subtracts) to the value of the years, months, weeks, days, hours, minutes, seconds, milliseconds of the date instance using given configuration object. Positive and Negative values allowed. * Example

	Date.today().add( { days: 1, months: 1 } )

	new Date().add( { years: -1 } )
	
* @param {Object} Configuration object containing attributes (months, days, etc.) * @return {Date} this */ $P.add = function (config) { if (typeof config === "number") { this._orient = config; return this; } var x = config; if (x.day) { // If we should be a different date than today (eg: for 'tomorrow -1d', etc). // Should only effect parsing, not direct usage (eg, Finish and FinishExact) if ((x.day - this.getDate()) !== 0) { this.setDate(x.day); } } if (x.milliseconds) { this.addMilliseconds(x.milliseconds); } if (x.seconds) { this.addSeconds(x.seconds); } if (x.minutes) { this.addMinutes(x.minutes); } if (x.hours) { this.addHours(x.hours); } if (x.weeks) { this.addWeeks(x.weeks); } if (x.months) { this.addMonths(x.months); } if (x.years) { this.addYears(x.years); } if (x.days) { this.addDays(x.days); } return this; }; /** * Get the week number. Week one (1) is the week which contains the first Thursday of the year. Monday is considered the first day of the week. * The .getWeek() function does NOT convert the date to UTC. The local datetime is used. * Please use .getISOWeek() to get the week of the UTC converted date. * @return {Number} 1 to 53 */ $P.getWeek = function (utc) { // Create a copy of this date object var self, target = new Date(this.valueOf()); if (utc) { target.addMinutes(target.getTimezoneOffset()); self = target.clone(); } else { self = this; } // ISO week date weeks start on monday // so correct the day number var dayNr = (self.getDay() + 6) % 7; // ISO 8601 states that week 1 is the week // with the first thursday of that year. // Set the target date to the thursday in the target week target.setDate(target.getDate() - dayNr + 3); // Store the millisecond value of the target date var firstThursday = target.valueOf(); // Set the target to the first thursday of the year // First set the target to january first target.setMonth(0, 1); // Not a thursday? Correct the date to the next thursday if (target.getDay() !== 4) { target.setMonth(0, 1 + ((4 - target.getDay()) + 7) % 7); } // The weeknumber is the number of weeks between the // first thursday of the year and the thursday in the target week return 1 + Math.ceil((firstThursday - target) / 604800000); // 604800000 = 7 * 24 * 3600 * 1000 }; /** * Get the ISO 8601 week number. Week one ("01") is the week which contains the first Thursday of the year. Monday is considered the first day of the week. * The .getISOWeek() function does convert the date to it's UTC value. Please use .getWeek() to get the week of the local date. * @return {String} "01" to "53" */ $P.getISOWeek = function () { return p(this.getWeek(true)); }; /** * Moves the date to Monday of the week set. Week one (1) is the week which contains the first Thursday of the year. * @param {Number} A Number (1 to 53) that represents the week of the year. * @return {Date} this */ $P.setWeek = function (n) { if ((n - this.getWeek()) === 0) { if (this.getDay() !== 1) { return this.moveToDayOfWeek(1, (this.getDay() > 1 ? -1 : 1)); } else { return this; } } else { return this.moveToDayOfWeek(1, (this.getDay() > 1 ? -1 : 1)).addWeeks(n - this.getWeek()); } }; $P.setQuarter = function (qtr) { var month = Math.abs(((qtr-1) * 3) + 1); return this.setMonth(month, 1); }; $P.getQuarter = function () { return Date.getQuarter(this); }; $P.getDaysLeftInQuarter = function () { return Date.getDaysLeftInQuarter(this); }; /** * Moves the date to the next n'th occurrence of the dayOfWeek starting from the beginning of the month. The number (-1) is a magic number and will return the last occurrence of the dayOfWeek in the month. * @param {Number} The dayOfWeek to move to * @param {Number} The n'th occurrence to move to. Use (-1) to return the last occurrence in the month * @return {Date} this */ $P.moveToNthOccurrence = function (dayOfWeek, occurrence) { if (dayOfWeek === "Weekday") { if (occurrence > 0) { this.moveToFirstDayOfMonth(); if (this.is().weekday()) { occurrence -= 1; } } else if (occurrence < 0) { this.moveToLastDayOfMonth(); if (this.is().weekday()) { occurrence += 1; } } else { return this; } return this.addWeekdays(occurrence); } var shift = 0; if (occurrence > 0) { shift = occurrence - 1; } else if (occurrence === -1) { this.moveToLastDayOfMonth(); if (this.getDay() !== dayOfWeek) { this.moveToDayOfWeek(dayOfWeek, -1); } return this; } return this.moveToFirstDayOfMonth().addDays(-1).moveToDayOfWeek(dayOfWeek, +1).addWeeks(shift); }; var moveToN = function (getFunc, addFunc, nVal) { return function (value, orient) { var diff = (value - this[getFunc]() + nVal * (orient || +1)) % nVal; return this[addFunc]((diff === 0) ? diff += nVal * (orient || +1) : diff); }; }; /** * Move to the next or last dayOfWeek based on the orient value. * @param {Number} The dayOfWeek to move to * @param {Number} Forward (+1) or Back (-1). Defaults to +1. [Optional] * @return {Date} this */ $P.moveToDayOfWeek = moveToN("getDay", "addDays", 7); /** * Move to the next or last month based on the orient value. * @param {Number} The month to move to. 0 = January, 11 = December * @param {Number} Forward (+1) or Back (-1). Defaults to +1. [Optional] * @return {Date} this */ $P.moveToMonth = moveToN("getMonth", "addMonths", 12); /** * Get the Ordinate of the current day ("th", "st", "rd"). * @return {String} */ $P.getOrdinate = function () { var num = this.getDate(); return ord(num); }; /** * Get the Ordinal day (numeric day number) of the year, adjusted for leap year. * @return {Number} 1 through 365 (366 in leap years) */ $P.getOrdinalNumber = function () { return Math.ceil((this.clone().clearTime() - new Date(this.getFullYear(), 0, 1)) / 86400000) + 1; }; /** * Get the time zone abbreviation of the current date. * @return {String} The abbreviated time zone name (e.g. "EST") */ $P.getTimezone = function () { return $D.getTimezoneAbbreviation(this.getUTCOffset(), this.isDaylightSavingTime()); }; $P.setTimezoneOffset = function (offset) { var here = this.getTimezoneOffset(), there = Number(offset) * -6 / 10; return (there || there === 0) ? this.addMinutes(there - here) : this; }; $P.setTimezone = function (offset) { return this.setTimezoneOffset($D.getTimezoneOffset(offset)); }; /** * Indicates whether Daylight Saving Time is observed in the current time zone. * @return {Boolean} true|false */ $P.hasDaylightSavingTime = function () { return (Date.today().set({month: 0, day: 1}).getTimezoneOffset() !== Date.today().set({month: 6, day: 1}).getTimezoneOffset()); }; /** * Indicates whether this Date instance is within the Daylight Saving Time range for the current time zone. * @return {Boolean} true|false */ $P.isDaylightSavingTime = function () { return Date.today().set({month: 0, day: 1}).getTimezoneOffset() !== this.getTimezoneOffset(); }; /** * Get the offset from UTC of the current date. * @return {String} The 4-character offset string prefixed with + or - (e.g. "-0500") */ $P.getUTCOffset = function (offset) { var n = (offset || this.getTimezoneOffset()) * -10 / 6, r; if (n < 0) { r = (n - 10000).toString(); return r.charAt(0) + r.substr(2); } else { r = (n + 10000).toString(); return "+" + r.substr(1); } }; /** * Returns the number of milliseconds between this date and date. * @param {Date} Defaults to now * @return {Number} The diff in milliseconds */ $P.getElapsed = function (date) { return (date || new Date()) - this; }; /** * Set the value of year, month, day, hour, minute, second, millisecond of date instance using given configuration object. * Example

	Date.today().set( { day: 20, month: 1 } )

	new Date().set( { millisecond: 0 } )
	
* * @param {Object} Configuration object containing attributes (month, day, etc.) * @return {Date} this */ $P.set = function (config) { config = validateConfigObject.call(this, config); var key; for (key in config) { if (Object.prototype.hasOwnProperty.call(config, key)) { var name = key.charAt(0).toUpperCase() + key.slice(1); var addFunc, getFunc; if (key !== "week" && key !== "month" && key !== "timezone" && key !== "timezoneOffset") { name += "s"; } addFunc = "add" + name; getFunc = "get" + name; if (key === "month") { addFunc = addFunc + "s"; } else if (key === "year"){ getFunc = "getFullYear"; } if (key !== "day" && key !== "timezone" && key !== "timezoneOffset" && key !== "week" && key !== "hour") { this[addFunc](config[key] - this[getFunc]()); } else if ( key === "timezone"|| key === "timezoneOffset" || key === "week" || key === "hour") { this["set"+name](config[key]); } } } // day has to go last because you can't validate the day without first knowing the month if (config.day) { this.addDays(config.day - this.getDate()); } return this; }; /** * Moves the date to the first day of the month. * @return {Date} this */ $P.moveToFirstDayOfMonth = function () { return this.set({ day: 1 }); }; /** * Moves the date to the last day of the month. * @return {Date} this */ $P.moveToLastDayOfMonth = function () { return this.set({ day: $D.getDaysInMonth(this.getFullYear(), this.getMonth())}); }; /** * Converts the value of the current Date object to its equivalent string representation. * Format Specifiers * CUSTOM DATE AND TIME FORMAT STRINGS * Format Description Example * ------ --------------------------------------------------------------------------- ----------------------- * s The seconds of the minute between 0-59. "0" to "59" * ss The seconds of the minute with leading zero if required. "00" to "59" * * m The minute of the hour between 0-59. "0" or "59" * mm The minute of the hour with leading zero if required. "00" or "59" * * h The hour of the day between 1-12. "1" to "12" * hh The hour of the day with leading zero if required. "01" to "12" * * H The hour of the day between 0-23. "0" to "23" * HH The hour of the day with leading zero if required. "00" to "23" * * d The day of the month between 1 and 31. "1" to "31" * dd The day of the month with leading zero if required. "01" to "31" * ddd Abbreviated day name. Date.CultureInfo.abbreviatedDayNames. "Mon" to "Sun" * dddd The full day name. Date.CultureInfo.dayNames. "Monday" to "Sunday" * * M The month of the year between 1-12. "1" to "12" * MM The month of the year with leading zero if required. "01" to "12" * MMM Abbreviated month name. Date.CultureInfo.abbreviatedMonthNames. "Jan" to "Dec" * MMMM The full month name. Date.CultureInfo.monthNames. "January" to "December" * * yy The year as a two-digit number. "99" or "08" * yyyy The full four digit year. "1999" or "2008" * * t Displays the first character of the A.M./P.M. designator. "A" or "P" * Date.CultureInfo.amDesignator or Date.CultureInfo.pmDesignator * tt Displays the A.M./P.M. designator. "AM" or "PM" * Date.CultureInfo.amDesignator or Date.CultureInfo.pmDesignator * * S The ordinal suffix ("st, "nd", "rd" or "th") of the current day. "st, "nd", "rd" or "th" * * STANDARD DATE AND TIME FORMAT STRINGS * Format Description Example *------ --------------------------------------------------------------------------- ----------------------- * d The CultureInfo shortDate Format Pattern "M/d/yyyy" * D The CultureInfo longDate Format Pattern "dddd, MMMM dd, yyyy" * F The CultureInfo fullDateTime Format Pattern "dddd, MMMM dd, yyyy h:mm:ss tt" * m The CultureInfo monthDay Format Pattern "MMMM dd" * r The CultureInfo rfc1123 Format Pattern "ddd, dd MMM yyyy HH:mm:ss GMT" * s The CultureInfo sortableDateTime Format Pattern "yyyy-MM-ddTHH:mm:ss" * t The CultureInfo shortTime Format Pattern "h:mm tt" * T The CultureInfo longTime Format Pattern "h:mm:ss tt" * u The CultureInfo universalSortableDateTime Format Pattern "yyyy-MM-dd HH:mm:ssZ" * y The CultureInfo yearMonth Format Pattern "MMMM, yyyy" * * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @return {String} A string representation of the current Date object. */ var ord = function (n) { switch (n * 1) { case 1: case 21: case 31: return "st"; case 2: case 22: return "nd"; case 3: case 23: return "rd"; default: return "th"; } }; var parseStandardFormats = function (format) { var y, c = Date.CultureInfo.formatPatterns; switch (format) { case "d": return this.toString(c.shortDate); case "D": return this.toString(c.longDate); case "F": return this.toString(c.fullDateTime); case "m": return this.toString(c.monthDay); case "r": case "R": y = this.clone().addMinutes(this.getTimezoneOffset()); return y.toString(c.rfc1123) + " GMT"; case "s": return this.toString(c.sortableDateTime); case "t": return this.toString(c.shortTime); case "T": return this.toString(c.longTime); case "u": y = this.clone().addMinutes(this.getTimezoneOffset()); return y.toString(c.universalSortableDateTime); case "y": return this.toString(c.yearMonth); default: return false; } }; var parseFormatStringsClosure = function (context) { return function (m) { if (m.charAt(0) === "\\") { return m.replace("\\", ""); } switch (m) { case "hh": return p(context.getHours() < 13 ? (context.getHours() === 0 ? 12 : context.getHours()) : (context.getHours() - 12)); case "h": return context.getHours() < 13 ? (context.getHours() === 0 ? 12 : context.getHours()) : (context.getHours() - 12); case "HH": return p(context.getHours()); case "H": return context.getHours(); case "mm": return p(context.getMinutes()); case "m": return context.getMinutes(); case "ss": return p(context.getSeconds()); case "s": return context.getSeconds(); case "yyyy": return p(context.getFullYear(), 4); case "yy": return p(context.getFullYear()); case "y": return context.getFullYear(); case "E": case "dddd": return Date.CultureInfo.dayNames[context.getDay()]; case "ddd": return Date.CultureInfo.abbreviatedDayNames[context.getDay()]; case "dd": return p(context.getDate()); case "d": return context.getDate(); case "MMMM": return Date.CultureInfo.monthNames[context.getMonth()]; case "MMM": return Date.CultureInfo.abbreviatedMonthNames[context.getMonth()]; case "MM": return p((context.getMonth() + 1)); case "M": return context.getMonth() + 1; case "t": return context.getHours() < 12 ? Date.CultureInfo.amDesignator.substring(0, 1) : Date.CultureInfo.pmDesignator.substring(0, 1); case "tt": return context.getHours() < 12 ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator; case "S": return ord(context.getDate()); case "W": return context.getWeek(); case "WW": return context.getISOWeek(); case "Q": return "Q" + context.getQuarter(); case "q": return String(context.getQuarter()); case "z": return context.getTimezone(); case "Z": case "X": return Date.getTimezoneOffset(context.getTimezone()); case "ZZ": // Timezone offset in seconds return context.getTimezoneOffset() * -60; case "u": return context.getDay(); case "L": return ($D.isLeapYear(context.getFullYear())) ? 1 : 0; case "B": // Swatch Internet Time (.beats) return "@"+((context.getUTCSeconds() + (context.getUTCMinutes()*60) + ((context.getUTCHours()+1)*3600))/86.4); default: return m; } }; }; $P.toString = function (format, ignoreStandards) { // Standard Date and Time Format Strings. Formats pulled from CultureInfo file and // may vary by culture. if (!ignoreStandards && format && format.length === 1) { output = parseStandardFormats.call(this, format); if (output) { return output; } } var parseFormatStrings = parseFormatStringsClosure(this); return format ? format.replace(/((\\)?(dd?d?d?|MM?M?M?|yy?y?y?|hh?|HH?|mm?|ss?|tt?|S|q|Q|WW?W?W?)(?![^\[]*\]))/g, parseFormatStrings).replace(/\[|\]/g, "") : this._toString(); }; }()); /************************************************************* * SugarPak - Domain Specific Language - Syntactical Sugar * *************************************************************/ (function () { var $D = Date, $P = $D.prototype, $N = Number.prototype; // private $P._orient = +1; // private $P._nth = null; // private $P._is = false; // private $P._same = false; // private $P._isSecond = false; // private $N._dateElement = "days"; /** * Moves the date to the next instance of a date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.today().next().friday();
	Date.today().next().fri();
	Date.today().next().march();
	Date.today().next().mar();
	Date.today().next().week();
	
* * @return {Date} date */ $P.next = function () { this._move = true; this._orient = +1; return this; }; /** * Creates a new Date (Date.today()) and moves the date to the next instance of the date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.next().friday();
	Date.next().fri();
	Date.next().march();
	Date.next().mar();
	Date.next().week();
	
* * @return {Date} date */ $D.next = function () { return $D.today().next(); }; /** * Moves the date to the previous instance of a date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.today().last().friday();
	Date.today().last().fri();
	Date.today().last().march();
	Date.today().last().mar();
	Date.today().last().week();
	
* * @return {Date} date */ $P.last = $P.prev = $P.previous = function () { this._move = true; this._orient = -1; return this; }; /** * Creates a new Date (Date.today()) and moves the date to the previous instance of the date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.last().friday();
	Date.last().fri();
	Date.previous().march();
	Date.prev().mar();
	Date.last().week();
	
* * @return {Date} date */ $D.last = $D.prev = $D.previous = function () { return $D.today().last(); }; /** * Performs a equality check when followed by either a month name, day name or .weekday() function. * Example

	Date.today().is().friday(); // true|false
	Date.today().is().fri();
	Date.today().is().march();
	Date.today().is().mar();
	
* * @return {Boolean} true|false */ $P.is = function () { this._is = true; return this; }; /** * Determines if two date objects occur on/in exactly the same instance of the subsequent date part function. * The function .same() must be followed by a date part function (example: .day(), .month(), .year(), etc). * * An optional Date can be passed in the date part function. If now date is passed as a parameter, 'Now' is used. * * The following example demonstrates how to determine if two dates fall on the exact same day. * * Example

	var d1 = Date.today(); // today at 00:00
	var d2 = new Date();   // exactly now.

	// Do they occur on the same day?
	d1.same().day(d2); // true
	
	// Do they occur on the same hour?
	d1.same().hour(d2); // false, unless d2 hour is '00' (midnight).
	
	// What if it's the same day, but one year apart?
	var nextYear = Date.today().add(1).year();

	d1.same().day(nextYear); // false, because the dates must occur on the exact same day. 
	
* * Scenario: Determine if a given date occurs during some week period 2 months from now. * * Example

	var future = Date.today().add(2).months();
	return someDate.same().week(future); // true|false;
	
* * @return {Boolean} true|false */ $P.same = function () { this._same = true; this._isSecond = false; return this; }; /** * Determines if the current date/time occurs during Today. Must be preceded by the .is() function. * Example

	someDate.is().today();    // true|false
	new Date().is().today();  // true
	Date.today().is().today();// true
	Date.today().add(-1).day().is().today(); // false
	
* * @return {Boolean} true|false */ $P.today = function () { return this.same().day(); }; /** * Determines if the current date is a weekday. This function must be preceded by the .is() function. * Example

	Date.today().is().weekday(); // true|false
	
* * @return {Boolean} true|false */ $P.weekday = function () { if (this._nth) { return df("Weekday").call(this); } if (this._move) { return this.addWeekdays(this._orient); } if (this._is) { this._is = false; return (!this.is().sat() && !this.is().sun()); } return false; }; /** * Determines if the current date is on the weekend. This function must be preceded by the .is() function. * Example

	Date.today().is().weekend(); // true|false
	
* * @return {Boolean} true|false */ $P.weekend = function () { if (this._is) { this._is = false; return (this.is().sat() || this.is().sun()); } return false; }; /** * Sets the Time of the current Date instance. A string "6:15 pm" or config object {hour:18, minute:15} are accepted. * Example

	// Set time to 6:15pm with a String
	Date.today().at("6:15pm");

	// Set time to 6:15pm with a config object
	Date.today().at({hour:18, minute:15});
	
* * @return {Date} date */ $P.at = function (time) { return (typeof time === "string") ? $D.parse(this.toString("d") + " " + time) : this.set(time); }; /** * Creates a new Date() and adds this (Number) to the date based on the preceding date element function (eg. second|minute|hour|day|month|year). * Example

	// Undeclared Numbers must be wrapped with parentheses. Requirment of JavaScript.
	(3).days().fromNow();
	(6).months().fromNow();

	// Declared Number variables do not require parentheses. 
	var n = 6;
	n.months().fromNow();
	
* * @return {Date} A new Date instance */ $N.fromNow = $N.after = function (date) { var c = {}; c[this._dateElement] = this; return ((!date) ? new Date() : date.clone()).add(c); }; /** * Creates a new Date() and subtract this (Number) from the date based on the preceding date element function (eg. second|minute|hour|day|month|year). * Example

	// Undeclared Numbers must be wrapped with parentheses. Requirment of JavaScript.
	(3).days().ago();
	(6).months().ago();

	// Declared Number variables do not require parentheses. 
	var n = 6;
	n.months().ago();
	
* * @return {Date} A new Date instance */ $N.ago = $N.before = function (date) { var c = {}, s = (this._dateElement[this._dateElement.length-1] !== "s") ? this._dateElement + "s" : this._dateElement; c[s] = this * -1; return ((!date) ? new Date() : date.clone()).add(c); }; // Do NOT modify the following string tokens. These tokens are used to build dynamic functions. // All culture-specific strings can be found in the CultureInfo files. var dx = ("sunday monday tuesday wednesday thursday friday saturday").split(/\s/), mx = ("january february march april may june july august september october november december").split(/\s/), px = ("Millisecond Second Minute Hour Day Week Month Year Quarter Weekday").split(/\s/), pxf = ("Milliseconds Seconds Minutes Hours Date Week Month FullYear Quarter").split(/\s/), nth = ("final first second third fourth fifth").split(/\s/), de; /** * Returns an object literal of all the date parts. * Example

	var o = new Date().toObject();
	
	// { year: 2008, month: 4, week: 20, day: 13, hour: 18, minute: 9, second: 32, millisecond: 812 }
	
	// The object properties can be referenced directly from the object.
	
	alert(o.day);  // alerts "13"
	alert(o.year); // alerts "2008"
	
* * @return {Date} An object literal representing the original date object. */ $P.toObject = function () { var o = {}; for (var i = 0; i < px.length; i++) { if (this["get" + pxf[i]]) { o[px[i].toLowerCase()] = this["get" + pxf[i]](); } } return o; }; /** * Returns a date created from an object literal. Ignores the .week property if set in the config. * Example

	var o = new Date().toObject();
	
	return Date.fromObject(o); // will return the same date. 

	var o2 = {month: 1, day: 20, hour: 18}; // birthday party!
	Date.fromObject(o2);
	
* * @return {Date} An object literal representing the original date object. */ $D.fromObject = function(config) { config.week = null; return Date.today().set(config); }; // Create day name functions and abbreviated day name functions (eg. monday(), friday(), fri()). var df = function (n) { return function () { if (this._is) { this._is = false; return this.getDay() === n; } if (this._move) { this._move = null; } if (this._nth !== null) { // If the .second() function was called earlier, remove the _orient // from the date, and then continue. // This is required because 'second' can be used in two different context. // // Example // // Date.today().add(1).second(); // Date.march().second().monday(); // // Things get crazy with the following... // Date.march().add(1).second().second().monday(); // but it works!! // if (this._isSecond) { this.addSeconds(this._orient * -1); } // make sure we reset _isSecond this._isSecond = false; var ntemp = this._nth; this._nth = null; var temp = this.clone().moveToLastDayOfMonth(); this.moveToNthOccurrence(n, ntemp); if (this > temp) { throw new RangeError($D.getDayName(n) + " does not occur " + ntemp + " times in the month of " + $D.getMonthName(temp.getMonth()) + " " + temp.getFullYear() + "."); } return this; } return this.moveToDayOfWeek(n, this._orient); }; }; var sdf = function (n) { return function () { var t = $D.today(), shift = n - t.getDay(); if (n === 0 && Date.CultureInfo.firstDayOfWeek === 1 && t.getDay() !== 0) { shift = shift + 7; } return t.addDays(shift); }; }; // Create month name functions and abbreviated month name functions (eg. january(), march(), mar()). var month_instance_functions = function (n) { return function () { if (this._is) { this._is = false; return this.getMonth() === n; } return this.moveToMonth(n, this._orient); }; }; var month_static_functions = function (n) { return function () { return $D.today().set({ month: n, day: 1 }); }; }; var processTerms = function (names, staticFunc, instanceFunc) { for (var i = 0; i < names.length; i++) { // Create constant static Name variables. $D[names[i].toUpperCase()] = $D[names[i].toUpperCase().substring(0, 3)] = i; // Create Name functions. $D[names[i]] = $D[names[i].substring(0, 3)] = staticFunc(i); // Create Name instance functions. $P[names[i]] = $P[names[i].substring(0, 3)] = instanceFunc(i); } }; processTerms(dx, sdf, df); processTerms(mx, month_static_functions, month_instance_functions); // Create date element functions and plural date element functions used with Date (eg. day(), days(), months()). var ef = function (j) { return function () { // if the .second() function was called earlier, the _orient // has alread been added. Just return this and reset _isSecond. if (this._isSecond) { this._isSecond = false; return this; } if (this._same) { this._same = this._is = false; var o1 = this.toObject(), o2 = (arguments[0] || new Date()).toObject(), v = "", k = j.toLowerCase(); // the substr trick with -1 doesn't work in IE8 or less k = (k[k.length-1] === "s") ? k.substring(0,k.length-1) : k; for (var m = (px.length - 1); m > -1; m--) { v = px[m].toLowerCase(); if (o1[v] !== o2[v]) { return false; } if (k === v) { break; } } return true; } if (j.substring(j.length - 1) !== "s") { j += "s"; } if (this._move) { this._move = null; } return this["add" + j](this._orient); }; }; var nf = function (n) { return function () { this._dateElement = n; return this; }; }; for (var k = 0; k < px.length; k++) { de = px[k].toLowerCase(); if(de !== "weekday") { // Create date element functions and plural date element functions used with Date (eg. day(), days(), months()). $P[de] = $P[de + "s"] = ef(px[k]); // Create date element functions and plural date element functions used with Number (eg. day(), days(), months()). $N[de] = $N[de + "s"] = nf(de + "s"); } } $P._ss = ef("Second"); var nthfn = function (n) { return function (dayOfWeek) { if (this._same) { return this._ss(arguments[0]); } if (dayOfWeek || dayOfWeek === 0) { return this.moveToNthOccurrence(dayOfWeek, n); } this._nth = n; // if the operator is 'second' add the _orient, then deal with it later... if (n === 2 && (dayOfWeek === undefined || dayOfWeek === null)) { this._isSecond = true; return this.addSeconds(this._orient); } return this; }; }; for (var l = 0; l < nth.length; l++) { $P[nth[l]] = (l === 0) ? nthfn(-1) : nthfn(l); } }()); (function () { "use strict"; Date.Parsing = { Exception: function (s) { this.message = "Parse error at '" + s.substring(0, 10) + " ...'"; } }; var $P = Date.Parsing; var dayOffsets = { standard: [0,31,59,90,120,151,181,212,243,273,304,334], leap: [0,31,60,91,121,152,182,213,244,274,305,335] }; $P.isLeapYear = function(year) { return ((year % 4 === 0) && (year % 100 !== 0)) || (year % 400 === 0); }; var utils = { multiReplace : function (str, hash ) { var key; for (key in hash) { if (Object.prototype.hasOwnProperty.call(hash, key)) { var regex; if (typeof hash[key] === "function") { } else { regex = (hash[key] instanceof RegExp) ? hash[key] : new RegExp(hash[key], "g"); } str = str.replace(regex, key); } } return str; }, getDayOfYearFromWeek : function (obj) { var d, jan4, offset; obj.weekDay = (!obj.weekDay && obj.weekDay !== 0) ? 1 : obj.weekDay; d = new Date(obj.year, 0, 4); jan4 = d.getDay() === 0 ? 7 : d.getDay(); // JS is 0 indexed on Sunday. offset = jan4+3; obj.dayOfYear = ((obj.week * 7) + (obj.weekDay === 0 ? 7 : obj.weekDay))-offset; return obj; }, getDayOfYear : function (obj, dayOffset) { if (!obj.dayOfYear) { obj = utils.getDayOfYearFromWeek(obj); } for (var i=0;i <= dayOffset.length;i++) { if (obj.dayOfYear < dayOffset[i] || i === dayOffset.length) { obj.day = obj.day ? obj.day : (obj.dayOfYear - dayOffset[i-1]); break; } else { obj.month = i; } } return obj; }, adjustForTimeZone : function (obj, date) { var offset; if (obj.zone.toUpperCase() === "Z" || (obj.zone_hours === 0 && obj.zone_minutes === 0)) { // it's UTC/GML so work out the current timeszone offset offset = -date.getTimezoneOffset(); } else { offset = (obj.zone_hours*60) + (obj.zone_minutes || 0); if (obj.zone_sign === "+") { offset *= -1; } offset -= date.getTimezoneOffset(); } date.setMinutes(date.getMinutes()+offset); return date; }, setDefaults : function (obj) { obj.year = obj.year || Date.today().getFullYear(); obj.hours = obj.hours || 0; obj.minutes = obj.minutes || 0; obj.seconds = obj.seconds || 0; obj.milliseconds = obj.milliseconds || 0; if (!(!obj.month && (obj.week || obj.dayOfYear))) { // if we have a month, or if we don't but don't have the day calculation data obj.month = obj.month || 0; obj.day = obj.day || 1; } return obj; }, dataNum: function (data, mod, explict, postProcess) { var dataNum = data*1; if (mod) { if (postProcess) { return data ? mod(data)*1 : data; } else { return data ? mod(dataNum) : data; } } else if (!explict){ return data ? dataNum : data; } else { return (data && typeof data !== "undefined") ? dataNum : data; } }, timeDataProcess: function (obj) { var timeObj = {}; for (var x in obj.data) { if (obj.data.hasOwnProperty(x)) { timeObj[x] = obj.ignore[x] ? obj.data[x] : utils.dataNum(obj.data[x], obj.mods[x], obj.explict[x], obj.postProcess[x]); } } if (obj.data.secmins) { obj.data.secmins = obj.data.secmins.replace(",", ".") * 60; if (!timeObj.minutes) { timeObj.minutes = obj.data.secmins; } else if (!timeObj.seconds) { timeObj.seconds = obj.data.secmins; } delete obj.secmins; } return timeObj; }, buildTimeObjectFromData: function (data) { var time = utils.timeDataProcess({ data: { year : data[1], month : data[5], day : data[7], week : data[8], dayOfYear : data[10], hours : data[15], zone_hours : data[23], zone_minutes : data[24], zone : data[21], zone_sign : data[22], weekDay : data[9], minutes: data[16], seconds: data[19], milliseconds: data[20], secmins: data[18] }, mods: { month: function(data) { return data-1; }, weekDay: function (data) { data = Math.abs(data); return (data === 7 ? 0 : data); }, minutes: function (data) { return data.replace(":",""); }, seconds: function (data) { return Math.floor( (data.replace(":","").replace(",","."))*1 ); }, milliseconds: function (data) { return (data.replace(",",".")*1000); } }, postProcess: { minutes: true, seconds: true, milliseconds: true }, explict: { zone_hours: true, zone_minutes: true }, ignore: { zone: true, zone_sign: true, secmins: true } }); return time; }, addToHash: function (hash, keys, data) { keys = keys; data = data; var len = keys.length; for (var i = 0; i < len; i++) { hash[keys[i]] = data[i]; } return hash; }, combineRegex: function (r1, r2) { return new RegExp("(("+r1.source+")\\s("+r2.source+"))"); }, getDateNthString: function(add, last, inc){ if (add) { return Date.today().addDays(inc).toString("d"); } else if (last) { return Date.today().last()[inc]().toString("d"); } }, buildRegexData: function (array) { var arr = []; var len = array.length; for (var i=0; i < len; i++) { if (Object.prototype.toString.call(array[i]) === '[object Array]') { // oldIE compat version of Array.isArray arr.push(this.combineRegex(array[i][0], array[i][1])); } else { arr.push(array[i]); } } return arr; } }; $P.processTimeObject = function (obj) { var date, dayOffset; utils.setDefaults(obj); dayOffset = ($P.isLeapYear(obj.year)) ? dayOffsets.leap : dayOffsets.standard; if (!obj.month && (obj.week || obj.dayOfYear)) { utils.getDayOfYear(obj, dayOffset); } else { obj.dayOfYear = dayOffset[obj.month] + obj.day; } date = new Date(obj.year, obj.month, obj.day, obj.hours, obj.minutes, obj.seconds, obj.milliseconds); if (obj.zone) { utils.adjustForTimeZone(obj, date); // adjust (and calculate) for timezone } return date; }; $P.ISO = { regex : /^([\+-]?\d{4}(?!\d{2}\b))((-?)((0[1-9]|1[0-2])(\3([12]\d|0[1-9]|3[01]))?|W([0-4]\d|5[0-3])(-?[1-7])?|(00[1-9]|0[1-9]\d|[12]\d{2}|3([0-5]\d|6[1-6])))([T\s]((([01]\d|2[0-4])((:?)[0-5]\d)?|24\:?00)([\.,]\d+(?!:))?)?(\17[0-5]\d([\.,]\d+)?)?\s?([zZ]|([\+-])([01]\d|2[0-3]):?([0-5]\d)?)?)?)?$/, parse : function (s) { var time, data = s.match(this.regex); if (!data || !data.length) { return null; } time = utils.buildTimeObjectFromData(data); if (!time.year || (!time.year && (!time.month && !time.day) && (!time.week && !time.dayOfYear)) ) { return null; } return $P.processTimeObject(time); } }; $P.Numeric = { isNumeric: function (e){return!isNaN(parseFloat(e))&&isFinite(e);}, regex: /\b([0-1]?[0-9])([0-3]?[0-9])([0-2]?[0-9]?[0-9][0-9])\b/i, parse: function (s) { var data, i, time = {}, order = Date.CultureInfo.dateElementOrder.split(""); if (!(this.isNumeric(s)) || // if it's non-numeric OR (s[0] === "+" && s[0] === "-")) { // It's an arithmatic string (eg +/-1000) return null; } if (s.length < 5 && s.indexOf(".") < 0 && s.indexOf("/") < 0) { // assume it's just a year. time.year = s; return $P.processTimeObject(time); } data = s.match(this.regex); if (!data || !data.length) { return null; } for (i=0; i < order.length; i++) { switch(order[i]) { case "d": time.day = data[i+1]; break; case "m": time.month = (data[i+1]-1); break; case "y": time.year = data[i+1]; break; } } return $P.processTimeObject(time); } }; $P.Normalizer = { regexData: function () { var $R = Date.CultureInfo.regexPatterns; return utils.buildRegexData([ $R.tomorrow, $R.yesterday, [$R.past, $R.mon], [$R.past, $R.tue], [$R.past, $R.wed], [$R.past, $R.thu], [$R.past, $R.fri], [$R.past, $R.sat], [$R.past, $R.sun] ]); }, basicReplaceHash : function() { var $R = Date.CultureInfo.regexPatterns; return { "January": $R.jan.source, "February": $R.feb, "March": $R.mar, "April": $R.apr, "May": $R.may, "June": $R.jun, "July": $R.jul, "August": $R.aug, "September": $R.sep, "October": $R.oct, "November": $R.nov, "December": $R.dec, "": /\bat\b/gi, " ": /\s{2,}/, "am": $R.inTheMorning, "9am": $R.thisMorning, "pm": $R.inTheEvening, "7pm":$R.thisEvening }; }, keys : function(){ return [ utils.getDateNthString(true, false, 1), // tomorrow utils.getDateNthString(true, false, -1), // yesterday utils.getDateNthString(false, true, "monday"), //last mon utils.getDateNthString(false, true, "tuesday"), //last tues utils.getDateNthString(false, true, "wednesday"), //last wed utils.getDateNthString(false, true, "thursday"), //last thurs utils.getDateNthString(false, true, "friday"), //last fri utils.getDateNthString(false, true, "saturday"), //last sat utils.getDateNthString(false, true, "sunday") //last sun ]; }, buildRegexFunctions: function () { var $R = Date.CultureInfo.regexPatterns; var __ = Date.i18n.__; var tomorrowRE = new RegExp("(\\b\\d\\d?("+__("AM")+"|"+__("PM")+")? )("+$R.tomorrow.source.slice(1)+")", "i"); // adapted tomorrow regex for AM PM relative dates var todayRE = new RegExp($R.today.source + "(?!\\s*([+-]))\\b"); // today, but excludes the math operators (eg "today + 2h") this.replaceFuncs = [ [todayRE, function (full) { return (full.length > 1) ? Date.today().toString("d") : full; }], [tomorrowRE, function(full, m1) { var t = Date.today().addDays(1).toString("d"); return (t + " " + m1); }], [$R.amThisMorning, function(str, am){return am;}], [$R.pmThisEvening, function(str, pm){return pm;}] ]; }, buildReplaceData: function () { this.buildRegexFunctions(); this.replaceHash = utils.addToHash(this.basicReplaceHash(), this.keys(), this.regexData()); }, stringReplaceFuncs: function (s) { for (var i=0; i < this.replaceFuncs.length; i++) { s = s.replace(this.replaceFuncs[i][0], this.replaceFuncs[i][1]); } return s; }, parse: function (s) { s = this.stringReplaceFuncs(s); s = utils.multiReplace(s, this.replaceHash); try { var n = s.split(/([\s\-\.\,\/\x27]+)/); if (n.length === 3 && $P.Numeric.isNumeric(n[0]) && $P.Numeric.isNumeric(n[2]) && (n[2].length >= 4)) { // ok, so we're dealing with x/year. But that's not a full date. // This fixes wonky dateElementOrder parsing when set to dmy order. if (Date.CultureInfo.dateElementOrder[0] === "d") { s = "1/" + n[0] + "/" + n[2]; // set to 1st of month and normalize the seperator } } } catch (e) {} return s; } }; $P.Normalizer.buildReplaceData(); }()); (function () { var $P = Date.Parsing; var _ = $P.Operators = { // // Tokenizers // rtoken: function (r) { // regex token return function (s) { var mx = s.match(r); if (mx) { return ([ mx[0], s.substring(mx[0].length) ]); } else { throw new $P.Exception(s); } }; }, token: function () { // whitespace-eating token return function (s) { return _.rtoken(new RegExp("^\\s*" + s + "\\s*"))(s); }; }, stoken: function (s) { // string token return _.rtoken(new RegExp("^" + s)); }, // Atomic Operators until: function (p) { return function (s) { var qx = [], rx = null; while (s.length) { try { rx = p.call(this, s); } catch (e) { qx.push(rx[0]); s = rx[1]; continue; } break; } return [ qx, s ]; }; }, many: function (p) { return function (s) { var rx = [], r = null; while (s.length) { try { r = p.call(this, s); } catch (e) { return [ rx, s ]; } rx.push(r[0]); s = r[1]; } return [ rx, s ]; }; }, // generator operators -- see below optional: function (p) { return function (s) { var r = null; try { r = p.call(this, s); } catch (e) { return [ null, s ]; } return [ r[0], r[1] ]; }; }, not: function (p) { return function (s) { try { p.call(this, s); } catch (e) { return [null, s]; } throw new $P.Exception(s); }; }, ignore: function (p) { return p ? function (s) { var r = null; r = p.call(this, s); return [null, r[1]]; } : null; }, product: function () { var px = arguments[0], qx = Array.prototype.slice.call(arguments, 1), rx = []; for (var i = 0 ; i < px.length ; i++) { rx.push(_.each(px[i], qx)); } return rx; }, cache: function (rule) { var cache = {}, cache_length = 0, cache_keys = [], CACHE_MAX = Date.Config.CACHE_MAX || 100000, r = null; var cacheCheck = function () { if (cache_length === CACHE_MAX) { // kill several keys, don't want to have to do this all the time... for (var i=0; i < 10; i++) { var key = cache_keys.shift(); if (key) { delete cache[key]; cache_length--; } } } }; return function (s) { cacheCheck(); try { r = cache[s] = (cache[s] || rule.call(this, s)); } catch (e) { r = cache[s] = e; } cache_length++; cache_keys.push(s); if (r instanceof $P.Exception) { throw r; } else { return r; } }; }, // vector operators -- see below any: function () { var px = arguments; return function (s) { var r = null; for (var i = 0; i < px.length; i++) { if (px[i] == null) { continue; } try { r = (px[i].call(this, s)); } catch (e) { r = null; } if (r) { return r; } } throw new $P.Exception(s); }; }, each: function () { var px = arguments; return function (s) { var rx = [], r = null; for (var i = 0; i < px.length ; i++) { if (px[i] == null) { continue; } try { r = (px[i].call(this, s)); } catch (e) { throw new $P.Exception(s); } rx.push(r[0]); s = r[1]; } return [ rx, s]; }; }, all: function () { var px = arguments, _ = _; return _.each(_.optional(px)); }, // delimited operators sequence: function (px, d, c) { d = d || _.rtoken(/^\s*/); c = c || null; if (px.length === 1) { return px[0]; } return function (s) { var r = null, q = null; var rx = []; for (var i = 0; i < px.length ; i++) { try { r = px[i].call(this, s); } catch (e) { break; } rx.push(r[0]); try { q = d.call(this, r[1]); } catch (ex) { q = null; break; } s = q[1]; } if (!r) { throw new $P.Exception(s); } if (q) { throw new $P.Exception(q[1]); } if (c) { try { r = c.call(this, r[1]); } catch (ey) { throw new $P.Exception(r[1]); } } return [ rx, (r?r[1]:s) ]; }; }, // // Composite Operators // between: function (d1, p, d2) { d2 = d2 || d1; var _fn = _.each(_.ignore(d1), p, _.ignore(d2)); return function (s) { var rx = _fn.call(this, s); return [[rx[0][0], r[0][2]], rx[1]]; }; }, list: function (p, d, c) { d = d || _.rtoken(/^\s*/); c = c || null; return (p instanceof Array ? _.each(_.product(p.slice(0, -1), _.ignore(d)), p.slice(-1), _.ignore(c)) : _.each(_.many(_.each(p, _.ignore(d))), px, _.ignore(c))); }, set: function (px, d, c) { d = d || _.rtoken(/^\s*/); c = c || null; return function (s) { // r is the current match, best the current 'best' match // which means it parsed the most amount of input var r = null, p = null, q = null, rx = null, best = [[], s], last = false; // go through the rules in the given set for (var i = 0; i < px.length ; i++) { // last is a flag indicating whether this must be the last element // if there is only 1 element, then it MUST be the last one q = null; p = null; r = null; last = (px.length === 1); // first, we try simply to match the current pattern // if not, try the next pattern try { r = px[i].call(this, s); } catch (e) { continue; } // since we are matching against a set of elements, the first // thing to do is to add r[0] to matched elements rx = [[r[0]], r[1]]; // if we matched and there is still input to parse and // we don't already know this is the last element, // we're going to next check for the delimiter ... // if there's none, or if there's no input left to parse // than this must be the last element after all ... if (r[1].length > 0 && ! last) { try { q = d.call(this, r[1]); } catch (ex) { last = true; } } else { last = true; } // if we parsed the delimiter and now there's no more input, // that means we shouldn't have parsed the delimiter at all // so don't update r and mark this as the last element ... if (!last && q[1].length === 0) { last = true; } // so, if this isn't the last element, we're going to see if // we can get any more matches from the remaining (unmatched) // elements ... if (!last) { // build a list of the remaining rules we can match against, // i.e., all but the one we just matched against var qx = []; for (var j = 0; j < px.length ; j++) { if (i !== j) { qx.push(px[j]); } } // now invoke recursively set with the remaining input // note that we don't include the closing delimiter ... // we'll check for that ourselves at the end p = _.set(qx, d).call(this, q[1]); // if we got a non-empty set as a result ... // (otw rx already contains everything we want to match) if (p[0].length > 0) { // update current result, which is stored in rx ... // basically, pick up the remaining text from p[1] // and concat the result from p[0] so that we don't // get endless nesting ... rx[0] = rx[0].concat(p[0]); rx[1] = p[1]; } } // at this point, rx either contains the last matched element // or the entire matched set that starts with this element. // now we just check to see if this variation is better than // our best so far, in terms of how much of the input is parsed if (rx[1].length < best[1].length) { best = rx; } // if we've parsed all the input, then we're finished if (best[1].length === 0) { break; } } // so now we've either gone through all the patterns trying them // as the initial match; or we found one that parsed the entire // input string ... // if best has no matches, just return empty set ... if (best[0].length === 0) { return best; } // if a closing delimiter is provided, then we have to check it also if (c) { // we try this even if there is no remaining input because the pattern // may well be optional or match empty input ... try { q = c.call(this, best[1]); } catch (ey) { throw new $P.Exception(best[1]); } // it parsed ... be sure to update the best match remaining input best[1] = q[1]; } // if we're here, either there was no closing delimiter or we parsed it // so now we have the best match; just return it! return best; }; }, forward: function (gr, fname) { return function (s) { return gr[fname].call(this, s); }; }, // // Translation Operators // replace: function (rule, repl) { return function (s) { var r = rule.call(this, s); return [repl, r[1]]; }; }, process: function (rule, fn) { return function (s) { var r = rule.call(this, s); return [fn.call(this, r[0]), r[1]]; }; }, min: function (min, rule) { return function (s) { var rx = rule.call(this, s); if (rx[0].length < min) { throw new $P.Exception(s); } return rx; }; } }; // Generator Operators And Vector Operators // Generators are operators that have a signature of F(R) => R, // taking a given rule and returning another rule, such as // ignore, which parses a given rule and throws away the result. // Vector operators are those that have a signature of F(R1,R2,...) => R, // take a list of rules and returning a new rule, such as each. // Generator operators are converted (via the following _generator // function) into functions that can also take a list or array of rules // and return an array of new rules as though the function had been // called on each rule in turn (which is what actually happens). // This allows generators to be used with vector operators more easily. // Example: // each(ignore(foo, bar)) instead of each(ignore(foo), ignore(bar)) // This also turns generators into vector operators, which allows // constructs like: // not(cache(foo, bar)) var _generator = function (op) { function gen() { var args = null, rx = [], px, i; if (arguments.length > 1) { args = Array.prototype.slice.call(arguments); } else if (arguments[0] instanceof Array) { args = arguments[0]; } if (args) { px = args.shift(); if (px.length > 0) { args.unshift(px[i]); rx.push(op.apply(null, args)); args.shift(); return rx; } } else { return op.apply(null, arguments); } } return gen; }; var gx = "optional not ignore cache".split(/\s/); for (var i = 0 ; i < gx.length ; i++) { _[gx[i]] = _generator(_[gx[i]]); } var _vector = function (op) { return function () { if (arguments[0] instanceof Array) { return op.apply(null, arguments[0]); } else { return op.apply(null, arguments); } }; }; var vx = "each any all".split(/\s/); for (var j = 0 ; j < vx.length ; j++) { _[vx[j]] = _vector(_[vx[j]]); } }()); (function () { var $D = Date; var flattenAndCompact = function (ax) { var rx = []; for (var i = 0; i < ax.length; i++) { if (ax[i] instanceof Array) { rx = rx.concat(flattenAndCompact(ax[i])); } else { if (ax[i]) { rx.push(ax[i]); } } } return rx; }; var parseMeridian = function () { if (this.meridian && (this.hour || this.hour === 0)) { if (this.meridian === "a" && this.hour > 11 && Date.Config.strict24hr){ throw "Invalid hour and meridian combination"; } else if (this.meridian === "p" && this.hour < 12 && Date.Config.strict24hr){ throw "Invalid hour and meridian combination"; } else if (this.meridian === "p" && this.hour < 12) { this.hour = this.hour + 12; } else if (this.meridian === "a" && this.hour === 12) { this.hour = 0; } } }; var setDefaults = function () { var now = new Date(); if ((this.hour || this.minute) && (!this.month && !this.year && !this.day)) { this.day = now.getDate(); } if (!this.year) { this.year = now.getFullYear(); } if (!this.month && this.month !== 0) { this.month = now.getMonth(); } if (!this.day) { this.day = 1; } if (!this.hour) { this.hour = 0; } if (!this.minute) { this.minute = 0; } if (!this.second) { this.second = 0; } if (!this.millisecond) { this.millisecond = 0; } }; var finishUtils = { getToday: function () { if (this.now || "hour minute second".indexOf(this.unit) !== -1) { return new Date(); } else { return $D.today(); } }, setDaysFromWeekday: function (today, orient){ var gap; orient = orient || 1; this.unit = "day"; gap = ($D.getDayNumberFromName(this.weekday) - today.getDay()); this.days = gap ? ((gap + (orient * 7)) % 7) : (orient * 7); return this; }, setMonthsFromMonth: function (today, orient) { var gap; orient = orient || 1; this.unit = "month"; gap = (this.month - today.getMonth()); this.months = gap ? ((gap + (orient * 12)) % 12) : (orient * 12); this.month = null; return this; }, setDMYFromWeekday: function () { var d = Date[this.weekday](); this.day = d.getDate(); if (!this.month) { this.month = d.getMonth(); } this.year = d.getFullYear(); return this; }, setUnitValue: function (orient) { if (!this.value && this.operator && this.operator !== null && this[this.unit + "s"] && this[this.unit + "s"] !== null) { this[this.unit + "s"] = this[this.unit + "s"] + ((this.operator === "add") ? 1 : -1) + (this.value||0) * orient; } else if (this[this.unit + "s"] == null || this.operator != null) { if (!this.value) { this.value = 1; } this[this.unit + "s"] = this.value * orient; } }, generateDateFromWeeks: function () { var weekday = (this.weekday !== undefined) ? this.weekday : "today"; var d = Date[weekday]().addWeeks(this.weeks); if (this.now) { d.setTimeToNow(); } return d; } }; $D.Translator = { hour: function (s) { return function () { this.hour = Number(s); }; }, minute: function (s) { return function () { this.minute = Number(s); }; }, second: function (s) { return function () { this.second = Number(s); }; }, /* for ss.s format */ secondAndMillisecond: function (s) { return function () { var mx = s.match(/^([0-5][0-9])\.([0-9]{1,3})/); this.second = Number(mx[1]); this.millisecond = Number(mx[2]); }; }, meridian: function (s) { return function () { this.meridian = s.slice(0, 1).toLowerCase(); }; }, timezone: function (s) { return function () { var n = s.replace(/[^\d\+\-]/g, ""); if (n.length) { this.timezoneOffset = Number(n); } else { this.timezone = s.toLowerCase(); } }; }, day: function (x) { var s = x[0]; return function () { this.day = Number(s.match(/\d+/)[0]); if (this.day < 1) { throw "invalid day"; } }; }, month: function (s) { return function () { this.month = (s.length === 3) ? "jan feb mar apr may jun jul aug sep oct nov dec".indexOf(s)/4 : Number(s) - 1; if (this.month < 0) { throw "invalid month"; } }; }, year: function (s) { return function () { var n = Number(s); this.year = ((s.length > 2) ? n : (n + (((n + 2000) < Date.CultureInfo.twoDigitYearMax) ? 2000 : 1900))); }; }, rday: function (s) { return function () { switch (s) { case "yesterday": this.days = -1; break; case "tomorrow": this.days = 1; break; case "today": this.days = 0; break; case "now": this.days = 0; this.now = true; break; } }; }, finishExact: function (x) { var d; x = (x instanceof Array) ? x : [x]; for (var i = 0 ; i < x.length ; i++) { if (x[i]) { x[i].call(this); } } setDefaults.call(this); parseMeridian.call(this); if (this.day > $D.getDaysInMonth(this.year, this.month)) { throw new RangeError(this.day + " is not a valid value for days."); } d = new Date(this.year, this.month, this.day, this.hour, this.minute, this.second, this.millisecond); if (this.year < 100) { d.setFullYear(this.year); // means years less that 100 are process correctly. JS will parse it otherwise as 1900-1999. } if (this.timezone) { d.set({ timezone: this.timezone }); } else if (this.timezoneOffset) { d.set({ timezoneOffset: this.timezoneOffset }); } return d; }, finish: function (x) { var today, expression, orient, temp; x = (x instanceof Array) ? flattenAndCompact(x) : [ x ]; if (x.length === 0) { return null; } for (var i = 0 ; i < x.length ; i++) { if (typeof x[i] === "function") { x[i].call(this); } } if (this.now && !this.unit && !this.operator) { return new Date(); } else { today = finishUtils.getToday.call(this); } expression = !!(this.days && this.days !== null || this.orient || this.operator); orient = ((this.orient === "past" || this.operator === "subtract") ? -1 : 1); if (this.month && this.unit === "week") { this.value = this.month + 1; delete this.month; delete this.day; } if ((this.month || this.month === 0) && "year day hour minute second".indexOf(this.unit) !== -1) { if (!this.value) { this.value = this.month + 1; } this.month = null; expression = true; } if (!expression && this.weekday && !this.day && !this.days) { finishUtils.setDMYFromWeekday.call(this); } if (expression && this.weekday && this.unit !== "month" && this.unit !== "week") { finishUtils.setDaysFromWeekday.call(this, today, orient); } if (this.weekday && this.unit !== "week" && !this.day && !this.days) { temp = Date[this.weekday](); this.day = temp.getDate(); if (temp.getMonth() !== today.getMonth()) { this.month = temp.getMonth(); } } if (this.month && this.unit === "day" && this.operator) { if (!this.value) { this.value = (this.month + 1); } this.month = null; } if (this.value != null && this.month != null && this.year != null) { this.day = this.value * 1; } if (this.month && !this.day && this.value) { today.set({ day: this.value * 1 }); if (!expression) { this.day = this.value * 1; } } if (!this.month && this.value && this.unit === "month" && !this.now) { this.month = this.value; expression = true; } if (expression && (this.month || this.month === 0) && this.unit !== "year") { finishUtils.setMonthsFromMonth.call(this, today, orient); } if (!this.unit) { this.unit = "day"; } finishUtils.setUnitValue.call(this, orient); parseMeridian.call(this); if ((this.month || this.month === 0) && !this.day) { this.day = 1; } if (!this.orient && !this.operator && this.unit === "week" && this.value && !this.day && !this.month) { return Date.today().setWeek(this.value); } if (this.unit === "week" && this.weeks && !this.day && !this.month) { return finishUtils.generateDateFromWeeks.call(this); } if (expression && this.timezone && this.day && this.days) { this.day = this.days; } if (expression){ today.add(this); } else { today.set(this); } if (this.timezone) { this.timezone = this.timezone.toUpperCase(); var offset = $D.getTimezoneOffset(this.timezone); var timezone; if (today.hasDaylightSavingTime()) { // lets check that we're being sane with timezone setting timezone = $D.getTimezoneAbbreviation(offset, today.isDaylightSavingTime()); if (timezone !== this.timezone) { // bugger, we're in a place where things like EST vs EDT matters. if (today.isDaylightSavingTime()) { today.addHours(-1); } else { today.addHours(1); } } } today.setTimezoneOffset(offset); } return today; } }; }()); (function () { var $D = Date; $D.Grammar = {}; var _ = $D.Parsing.Operators, g = $D.Grammar, t = $D.Translator, _fn; // Allow rolling up into general purpose rules _fn = function () { return _.each(_.any.apply(null, arguments), _.not(g.ctoken2("timeContext"))); }; g.datePartDelimiter = _.rtoken(/^([\s\-\.\,\/\x27]+)/); g.timePartDelimiter = _.stoken(":"); g.whiteSpace = _.rtoken(/^\s*/); g.generalDelimiter = _.rtoken(/^(([\s\,]|at|@|on)+)/); var _C = {}; g.ctoken = function (keys) { var fn = _C[keys]; if (! fn) { var c = Date.CultureInfo.regexPatterns; var kx = keys.split(/\s+/), px = []; for (var i = 0; i < kx.length ; i++) { px.push(_.replace(_.rtoken(c[kx[i]]), kx[i])); } fn = _C[keys] = _.any.apply(null, px); } return fn; }; g.ctoken2 = function (key) { return _.rtoken(Date.CultureInfo.regexPatterns[key]); }; var cacheProcessRtoken = function (key, token, type, eachToken) { if (eachToken) { g[key] = _.cache(_.process(_.each(_.rtoken(token),_.optional(g.ctoken2(eachToken))), type)); } else { g[key] = _.cache(_.process(_.rtoken(token), type)); } }; var cacheProcessCtoken = function (token, type) { return _.cache(_.process(g.ctoken2(token), type)); }; var _F = {}; //function cache var _get = function (f) { _F[f] = (_F[f] || g.format(f)[0]); return _F[f]; }; g.allformats = function (fx) { var rx = []; if (fx instanceof Array) { for (var i = 0; i < fx.length; i++) { rx.push(_get(fx[i])); } } else { rx.push(_get(fx)); } return rx; }; g.formats = function (fx) { if (fx instanceof Array) { var rx = []; for (var i = 0 ; i < fx.length ; i++) { rx.push(_get(fx[i])); } return _.any.apply(null, rx); } else { return _get(fx); } }; var grammarFormats = { timeFormats: function(){ var i, RTokenKeys = [ "h", "hh", "H", "HH", "m", "mm", "s", "ss", "ss.s", "z", "zz" ], RToken = [ /^(0[0-9]|1[0-2]|[1-9])/, /^(0[0-9]|1[0-2])/, /^([0-1][0-9]|2[0-3]|[0-9])/, /^([0-1][0-9]|2[0-3])/, /^([0-5][0-9]|[0-9])/, /^[0-5][0-9]/, /^([0-5][0-9]|[0-9])/, /^[0-5][0-9]/, /^[0-5][0-9]\.[0-9]{1,3}/, /^((\+|\-)\s*\d\d\d\d)|((\+|\-)\d\d\:?\d\d)/, /^((\+|\-)\s*\d\d\d\d)|((\+|\-)\d\d\:?\d\d)/ ], tokens = [ t.hour, t.hour, t.hour, t.hour, t.minute, t.minute, t.second, t.second, t.secondAndMillisecond, t.timezone, t.timezone ]; for (i=0; i < RTokenKeys.length; i++) { cacheProcessRtoken(RTokenKeys[i], RToken[i], tokens[i]); } g.hms = _.cache(_.sequence([g.H, g.m, g.s], g.timePartDelimiter)); g.t = cacheProcessCtoken("shortMeridian", t.meridian); g.tt = cacheProcessCtoken("longMeridian", t.meridian); g.zzz = cacheProcessCtoken("timezone", t.timezone); g.timeSuffix = _.each(_.ignore(g.whiteSpace), _.set([ g.tt, g.zzz ])); g.time = _.each(_.optional(_.ignore(_.stoken("T"))), g.hms, g.timeSuffix); }, dateFormats: function () { // pre-loaded rules for different date part order preferences var _setfn = function () { return _.set(arguments, g.datePartDelimiter); }; var i, RTokenKeys = [ "d", "dd", "M", "MM", "y", "yy", "yyy", "yyyy" ], RToken = [ /^([0-2]\d|3[0-1]|\d)/, /^([0-2]\d|3[0-1])/, /^(1[0-2]|0\d|\d)/, /^(1[0-2]|0\d)/, /^(\d+)/, /^(\d\d)/, /^(\d\d?\d?\d?)/, /^(\d\d\d\d)/ ], tokens = [ t.day, t.day, t.month, t.month, t.year, t.year, t.year, t.year ], eachToken = [ "ordinalSuffix", "ordinalSuffix" ]; for (i=0; i < RTokenKeys.length; i++) { cacheProcessRtoken(RTokenKeys[i], RToken[i], tokens[i], eachToken[i]); } g.MMM = g.MMMM = _.cache(_.process(g.ctoken("jan feb mar apr may jun jul aug sep oct nov dec"), t.month)); g.ddd = g.dddd = _.cache(_.process(g.ctoken("sun mon tue wed thu fri sat"), function (s) { return function () { this.weekday = s; }; } )); g.day = _fn(g.d, g.dd); g.month = _fn(g.M, g.MMM); g.year = _fn(g.yyyy, g.yy); g.mdy = _setfn(g.ddd, g.month, g.day, g.year); g.ymd = _setfn(g.ddd, g.year, g.month, g.day); g.dmy = _setfn(g.ddd, g.day, g.month, g.year); g.date = function (s) { return ((g[Date.CultureInfo.dateElementOrder] || g.mdy).call(this, s)); }; }, relative: function () { // relative date / time expressions g.orientation = _.process(g.ctoken("past future"), function (s) { return function () { this.orient = s; }; } ); g.operator = _.process(g.ctoken("add subtract"), function (s) { return function () { this.operator = s; }; } ); g.rday = _.process(g.ctoken("yesterday tomorrow today now"), t.rday); g.unit = _.process(g.ctoken("second minute hour day week month year"), function (s) { return function () { this.unit = s; }; } ); } }; g.buildGrammarFormats = function () { // these need to be rebuilt every time the language changes. _C = {}; grammarFormats.timeFormats(); grammarFormats.dateFormats(); grammarFormats.relative(); g.value = _.process(_.rtoken(/^([-+]?\d+)?(st|nd|rd|th)?/), function (s) { return function () { this.value = s.replace(/\D/g, ""); }; } ); g.expression = _.set([g.rday, g.operator, g.value, g.unit, g.orientation, g.ddd, g.MMM ]); g.format = _.process(_.many( _.any( // translate format specifiers into grammar rules _.process( _.rtoken(/^(dd?d?d?(?!e)|MM?M?M?|yy?y?y?|hh?|HH?|mm?|ss?|tt?|zz?z?)/), function (fmt) { if (g[fmt]) { return g[fmt]; } else { throw $D.Parsing.Exception(fmt); } } ), // translate separator tokens into token rules _.process(_.rtoken(/^[^dMyhHmstz]+/), // all legal separators function (s) { return _.ignore(_.stoken(s)); } ) ) ), // construct the parser ... function (rules) { return _.process(_.each.apply(null, rules), t.finishExact); } ); // starting rule for general purpose grammar g._start = _.process(_.set([ g.date, g.time, g.expression ], g.generalDelimiter, g.whiteSpace), t.finish); }; g.buildGrammarFormats(); // parsing date format specifiers - ex: "h:m:s tt" // this little guy will generate a custom parser based // on the format string, ex: g.format("h:m:s tt") // check for these formats first g._formats = g.formats([ "\"yyyy-MM-ddTHH:mm:ssZ\"", "yyyy-MM-ddTHH:mm:ss.sz", "yyyy-MM-ddTHH:mm:ssZ", "yyyy-MM-ddTHH:mm:ssz", "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-ddTHH:mmZ", "yyyy-MM-ddTHH:mmz", "yyyy-MM-ddTHH:mm", "ddd, MMM dd, yyyy H:mm:ss tt", "ddd MMM d yyyy HH:mm:ss zzz", "MMddyyyy", "ddMMyyyy", "Mddyyyy", "ddMyyyy", "Mdyyyy", "dMyyyy", "yyyy", "Mdyy", "dMyy", "d" ]); // real starting rule: tries selected formats first, // then general purpose rule g.start = function (s) { try { var r = g._formats.call({}, s); if (r[1].length === 0) { return r; } } catch (e) {} return g._start.call({}, s); }; }()); (function () { var $D = Date; /** * @desc Converts the specified string value into its JavaScript Date equivalent using CultureInfo specific format information. * * Example

	///////////
	// Dates //
	///////////

	// 15-Oct-2004
	var d1 = Date.parse("10/15/2004");

	// 15-Oct-2004
	var d1 = Date.parse("15-Oct-2004");

	// 15-Oct-2004
	var d1 = Date.parse("2004.10.15");

	//Fri Oct 15, 2004
	var d1 = Date.parse("Fri Oct 15, 2004");

	///////////
	// Times //
	///////////

	// Today at 10 PM.
	var d1 = Date.parse("10 PM");

	// Today at 10:30 PM.
	var d1 = Date.parse("10:30 P.M.");

	// Today at 6 AM.
	var d1 = Date.parse("06am");

	/////////////////////
	// Dates and Times //
	/////////////////////

	// 8-July-2004 @ 10:30 PM
	var d1 = Date.parse("July 8th, 2004, 10:30 PM");

	// 1-July-2004 @ 10:30 PM
	var d1 = Date.parse("2004-07-01T22:30:00");

	////////////////////
	// Relative Dates //
	////////////////////

	// Returns today's date. The string "today" is culture specific.
	var d1 = Date.parse("today");

	// Returns yesterday's date. The string "yesterday" is culture specific.
	var d1 = Date.parse("yesterday");

	// Returns the date of the next thursday.
	var d1 = Date.parse("Next thursday");

	// Returns the date of the most previous monday.
	var d1 = Date.parse("last monday");

	// Returns today's day + one year.
	var d1 = Date.parse("next year");

	///////////////
	// Date Math //
	///////////////

	// Today + 2 days
	var d1 = Date.parse("t+2");

	// Today + 2 days
	var d1 = Date.parse("today + 2 days");

	// Today + 3 months
	var d1 = Date.parse("t+3m");

	// Today - 1 year
	var d1 = Date.parse("today - 1 year");

	// Today - 1 year
	var d1 = Date.parse("t-1y"); 


	/////////////////////////////
	// Partial Dates and Times //
	/////////////////////////////

	// July 15th of this year.
	var d1 = Date.parse("July 15");

	// 15th day of current day and year.
	var d1 = Date.parse("15");

	// July 1st of current year at 10pm.
	var d1 = Date.parse("7/1 10pm");
	
* * @param {String} The string value to convert into a Date object [Required] * @return {Date} A Date object or null if the string cannot be converted into a Date. */ var parseUtils = { removeOrds: function (s) { ords = s.match(/\b(\d+)(?:st|nd|rd|th)\b/); // find ordinal matches s = ((ords && ords.length === 2) ? s.replace(ords[0], ords[1]) : s); return s; }, grammarParser: function (s) { var r = null; try { r = $D.Grammar.start.call({}, s.replace(/^\s*(\S*(\s+\S+)*)\s*$/, "$1")); } catch (e) { return null; } return ((r[1].length === 0) ? r[0] : null); }, nativeFallback: function(s) { var t; try { // ok we haven't parsed it, last ditch attempt with the built-in parser. t = Date._parse(s); return (t || t === 0) ? new Date(t) : null; } catch (e) { return null; } } }; function parse (s) { var d; if (!s) { return null; } if (s instanceof Date) { return s.clone(); } if (s.length >= 4 && s.charAt(0) !== "0" && s.charAt(0) !== "+"&& s.charAt(0) !== "-") { // ie: 2004 will pass, 0800 won't. // Start with specific formats d = $D.Parsing.ISO.parse(s) || $D.Parsing.Numeric.parse(s); } if (d instanceof Date && !isNaN(d.getTime())) { return d; } else { // find ordinal dates (1st, 3rd, 8th, etc and remove them as they cause parsing issues) s = $D.Parsing.Normalizer.parse(parseUtils.removeOrds(s)); d = parseUtils.grammarParser(s); if (d !== null) { return d; } else { return parseUtils.nativeFallback(s); } } } if (!$D._parse) { $D._parse = $D.parse; } $D.parse = parse; Date.getParseFunction = function (fx) { var fns = Date.Grammar.allformats(fx); return function (s) { var r = null; for (var i = 0; i < fns.length; i++) { try { r = fns[i].call({}, s); } catch (e) { continue; } if (r[1].length === 0) { return r[0]; } } return null; }; }; /** * Converts the specified string value into its JavaScript Date equivalent using the specified format {String} or formats {Array} and the CultureInfo specific format information. * The format of the string value must match one of the supplied formats exactly. * * Example

	// 15-Oct-2004
	var d1 = Date.parseExact("10/15/2004", "M/d/yyyy");

	// 15-Oct-2004
	var d1 = Date.parse("15-Oct-2004", "M-ddd-yyyy");

	// 15-Oct-2004
	var d1 = Date.parse("2004.10.15", "yyyy.MM.dd");

	// Multiple formats
	var d1 = Date.parseExact("10/15/2004", ["M/d/yyyy", "MMMM d, yyyy"]);
	
* * @param {String} The string value to convert into a Date object [Required]. * @param {Object} The expected format {String} or an array of expected formats {Array} of the date string [Required]. * @return {Date} A Date object or null if the string cannot be converted into a Date. */ $D.parseExact = function (s, fx) { return $D.getParseFunction(fx)(s); }; }()); (function () { var $D = Date, $P = $D.prototype, // $C = $D.CultureInfo, // not used atm p = function (s, l) { if (!l) { l = 2; } return ("000" + s).slice(l * -1); }; /** * Converts a PHP format string to Java/.NET format string. * A PHP format string can be used with ._format or .format. * A Java/.NET format string can be used with .toString(). * The .parseExact function will only accept a Java/.NET format string * * Example * var f1 = "%m/%d/%y" * var f2 = Date.normalizeFormat(f1); // "MM/dd/yy" * * new Date().format(f1); // "04/13/08" * new Date()._format(f1); // "04/13/08" * new Date().toString(f2); // "04/13/08" * * var date = Date.parseExact("04/13/08", f2); // Sun Apr 13 2008 * * @param {String} A PHP format string consisting of one or more format spcifiers. * @return {String} The PHP format converted to a Java/.NET format string. */ var normalizerSubstitutions = { "d" : "dd", "%d": "dd", "D" : "ddd", "%a": "ddd", "j" : "dddd", "l" : "dddd", "%A": "dddd", "S" : "S", "F" : "MMMM", "%B": "MMMM", "m" : "MM", "%m": "MM", "M" : "MMM", "%b": "MMM", "%h": "MMM", "n" : "M", "Y" : "yyyy", "%Y": "yyyy", "y" : "yy", "%y": "yy", "g" : "h", "%I": "h", "G" : "H", "h" : "hh", "H" : "HH", "%H": "HH", "i" : "mm", "%M": "mm", "s" : "ss", "%S": "ss", "%r": "hh:mm tt", "%R": "H:mm", "%T": "H:mm:ss", "%X": "t", "%x": "d", "%e": "d", "%D": "MM/dd/yy", "%n": "\\n", "%t": "\\t", "e" : "z", "T" : "z", "%z": "z", "%Z": "z", "Z" : "ZZ", "N" : "u", "w" : "u", "%w": "u", "W" : "W", "%V": "W" }; var normalizer = { substitutes: function (m) { return normalizerSubstitutions[m]; }, interpreted: function (m, x) { var y; switch (m) { case "%u": return x.getDay() + 1; case "z": return x.getOrdinalNumber(); case "%j": return p(x.getOrdinalNumber(), 3); case "%U": var d1 = x.clone().set({month: 0, day: 1}).addDays(-1).moveToDayOfWeek(0), d2 = x.clone().addDays(1).moveToDayOfWeek(0, -1); return (d2 < d1) ? "00" : p((d2.getOrdinalNumber() - d1.getOrdinalNumber()) / 7 + 1); case "%W": return p(x.getWeek()); case "t": return $D.getDaysInMonth(x.getFullYear(), x.getMonth()); case "o": case "%G": return x.setWeek(x.getISOWeek()).toString("yyyy"); case "%g": return x._format("%G").slice(-2); case "a": case "%p": return t("tt").toLowerCase(); case "A": return t("tt").toUpperCase(); case "u": return p(x.getMilliseconds(), 3); case "I": return (x.isDaylightSavingTime()) ? 1 : 0; case "O": return x.getUTCOffset(); case "P": y = x.getUTCOffset(); return y.substring(0, y.length - 2) + ":" + y.substring(y.length - 2); case "B": var now = new Date(); return Math.floor(((now.getHours() * 3600) + (now.getMinutes() * 60) + now.getSeconds() + (now.getTimezoneOffset() + 60) * 60) / 86.4); case "c": return x.toISOString().replace(/\"/g, ""); case "U": return $D.strtotime("now"); case "%c": return t("d") + " " + t("t"); case "%C": return Math.floor(x.getFullYear() / 100 + 1); } }, shouldOverrideDefaults: function (m) { switch (m) { case "%e": return true; default: return false; } }, parse: function (m, context) { var formatString, c = context || new Date(); formatString = normalizer.substitutes(m); if (formatString) { return formatString; } formatString = normalizer.interpreted(m, c); if (formatString) { return formatString; } else { return m; } } }; $D.normalizeFormat = function (format, context) { return format.replace(/(%|\\)?.|%%/g, function(t){ return normalizer.parse(t, context); }); }; /** * Format a local Unix timestamp according to locale settings * * Example: * Date.strftime("%m/%d/%y", new Date()); // "04/13/08" * Date.strftime("c", "2008-04-13T17:52:03Z"); // "04/13/08" * * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @param {Number|String} The number representing the number of seconds that have elapsed since January 1, 1970 (local time). * @return {String} A string representation of the current Date object. */ $D.strftime = function (format, time) { var d = Date.parse(time); return d._format(format); }; /** * Parse any textual datetime description into a Unix timestamp. * A Unix timestamp is the number of seconds that have elapsed since January 1, 1970 (midnight UTC/GMT). * * Example: * Date.strtotime("04/13/08"); // 1208044800 * Date.strtotime("1970-01-01T00:00:00Z"); // 0 * * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @param {Object} A string or date object. * @return {String} A string representation of the current Date object. */ $D.strtotime = function (time) { var d = $D.parse(time); return Math.round($D.UTC(d.getUTCFullYear(), d.getUTCMonth(), d.getUTCDate(), d.getUTCHours(), d.getUTCMinutes(), d.getUTCSeconds(), d.getUTCMilliseconds()) / 1000); }; /** * Converts the value of the current Date object to its equivalent string representation using a PHP/Unix style of date format specifiers. * Format Specifiers * Format Description Example * ------ --------------------------------------------------------------------------- ----------------------- * %a abbreviated weekday name according to the current localed "Mon" through "Sun" * %A full weekday name according to the current localed "Sunday" through "Saturday" * %b abbreviated month name according to the current localed "Jan" through "Dec" * %B full month name according to the current locale "January" through "December" * %c preferred date and time representation for the current locale "4/13/2008 12:33 PM" * %C century number (the year divided by 100 and truncated to an integer) "00" to "99" * %d day of the month as a decimal number "01" to "31" * %D same as %m/%d/%y "04/13/08" * %e day of the month as a decimal number, a single digit is preceded by a space "1" to "31" * %g like %G, but without the century "08" * %G The 4-digit year corresponding to the ISO week number (see %V). "2008" * This has the same format and value as %Y, except that if the ISO week number * belongs to the previous or next year, that year is used instead. * %h same as %b "Jan" through "Dec" * %H hour as a decimal number using a 24-hour clock. "00" to "23" * %I hour as a decimal number using a 12-hour clock. "01" to "12" * %j day of the year as a decimal number. "001" to "366" * %m month as a decimal number. "01" to "12" * %M minute as a decimal number. "00" to "59" * %n newline character "\n" * %p either "am" or "pm" according to the given time value, or the "am" or "pm" * corresponding strings for the current locale. * %r time in a.m. and p.m. notation "8:44 PM" * %R time in 24 hour notation "20:44" * %S second as a decimal number "00" to "59" * %t tab character "\t" * %T current time, equal to %H:%M:%S "12:49:11" * %u weekday as a decimal number ["1", "7"], with "1" representing Monday "1" to "7" * %U week number of the current year as a decimal number, starting with the "0" to ("52" or "53") * first Sunday as the first day of the first week * %V The ISO 8601:1988 week number of the current year as a decimal number, "00" to ("52" or "53") * range 01 to 53, where week 1 is the first week that has at least 4 days * in the current year, and with Monday as the first day of the week. * (Use %G or %g for the year component that corresponds to the week number * for the specified timestamp.) * %W week number of the current year as a decimal number, starting with the "00" to ("52" or "53") * first Monday as the first day of the first week * %w day of the week as a decimal, Sunday being "0" "0" to "6" * %x preferred date representation for the current locale without the time "4/13/2008" * %X preferred time representation for the current locale without the date "12:53:05" * %y year as a decimal number without a century "00" "99" * %Y year as a decimal number including the century "2008" * %Z time zone or name or abbreviation "UTC", "EST", "PST" * %z same as %Z * %% a literal "%" characters "%" * d Day of the month, 2 digits with leading zeros "01" to "31" * D A textual representation of a day, three letters "Mon" through "Sun" * j Day of the month without leading zeros "1" to "31" * l A full textual representation of the day of the week (lowercase "L") "Sunday" through "Saturday" * N ISO-8601 numeric representation of the day of the week (added in PHP 5.1.0) "1" (for Monday) through "7" (for Sunday) * S English ordinal suffix for the day of the month, 2 characters "st", "nd", "rd" or "th". Works well with j * w Numeric representation of the day of the week "0" (for Sunday) through "6" (for Saturday) * z The day of the year (starting from "0") "0" through "365" * W ISO-8601 week number of year, weeks starting on Monday "00" to ("52" or "53") * F A full textual representation of a month, such as January or March "January" through "December" * m Numeric representation of a month, with leading zeros "01" through "12" * M A short textual representation of a month, three letters "Jan" through "Dec" * n Numeric representation of a month, without leading zeros "1" through "12" * t Number of days in the given month "28" through "31" * L Whether it's a leap year "1" if it is a leap year, "0" otherwise * o ISO-8601 year number. This has the same value as Y, except that if the "2008" * ISO week number (W) belongs to the previous or next year, that year * is used instead. * Y A full numeric representation of a year, 4 digits "2008" * y A two digit representation of a year "08" * a Lowercase Ante meridiem and Post meridiem "am" or "pm" * A Uppercase Ante meridiem and Post meridiem "AM" or "PM" * B Swatch Internet time "000" through "999" * g 12-hour format of an hour without leading zeros "1" through "12" * G 24-hour format of an hour without leading zeros "0" through "23" * h 12-hour format of an hour with leading zeros "01" through "12" * H 24-hour format of an hour with leading zeros "00" through "23" * i Minutes with leading zeros "00" to "59" * s Seconds, with leading zeros "00" through "59" * u Milliseconds "54321" * e Timezone identifier "UTC", "EST", "PST" * I Whether or not the date is in daylight saving time (uppercase i) "1" if Daylight Saving Time, "0" otherwise * O Difference to Greenwich time (GMT) in hours "+0200", "-0600" * P Difference to Greenwich time (GMT) with colon between hours and minutes "+02:00", "-06:00" * T Timezone abbreviation "UTC", "EST", "PST" * Z Timezone offset in seconds. The offset for timezones west of UTC is "-43200" through "50400" * always negative, and for those east of UTC is always positive. * c ISO 8601 date "2004-02-12T15:19:21+00:00" * r RFC 2822 formatted date "Thu, 21 Dec 2000 16:01:07 +0200" * U Seconds since the Unix Epoch (January 1 1970 00:00:00 GMT) "0" * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @return {String} A string representation of the current Date object. */ var formatReplace = function (context) { return function (m) { var formatString, override = false; if (m.charAt(0) === "\\" || m.substring(0, 2) === "%%") { return m.replace("\\", "").replace("%%", "%"); } override = normalizer.shouldOverrideDefaults(m); formatString = $D.normalizeFormat(m, context); if (formatString) { return context.toString(formatString, override); } }; }; $P._format = function (format) { var formatter = formatReplace(this); if (!format) { return this._toString(); } else { return format.replace(/(%|\\)?.|%%/g, formatter); } }; if (!$P.format) { $P.format = $P._format; } }()); (function () { "use strict"; var gFn = function (attr) { return function () { return this[attr]; }; }; var sFn = function (attr) { return function (val) { this[attr] = val; return this; }; }; var attrs = ["years", "months", "days", "hours", "minutes", "seconds", "milliseconds"]; var addSetFuncs = function (context, attrs) { for (var i = 0; i < attrs.length ; i++) { var $a = attrs[i], $b = $a.slice(0, 1).toUpperCase() + $a.slice(1); context.prototype[$a] = 0; context.prototype["get" + $b] = gFn($a); context.prototype["set" + $b] = sFn($a); } }; /** * new TimeSpan(milliseconds); * new TimeSpan(days, hours, minutes, seconds); * new TimeSpan(days, hours, minutes, seconds, milliseconds); */ var TimeSpan = function (days, hours, minutes, seconds, milliseconds) { if (arguments.length === 1 && typeof days === "number") { var orient = (days < 0) ? -1 : +1; var millsLeft = Math.abs(days); this.setDays(Math.floor(millsLeft / 86400000) * orient); millsLeft = millsLeft % 86400000; this.setHours(Math.floor(millsLeft / 3600000) * orient); millsLeft = millsLeft % 3600000; this.setMinutes(Math.floor(millsLeft / 60000) * orient); millsLeft = millsLeft % 60000; this.setSeconds(Math.floor(millsLeft / 1000) * orient); millsLeft = millsLeft % 1000; this.setMilliseconds(millsLeft * orient); } else { this.set(days, hours, minutes, seconds, milliseconds); } this.getTotalMilliseconds = function () { return (this.getDays() * 86400000) + (this.getHours() * 3600000) + (this.getMinutes() * 60000) + (this.getSeconds() * 1000); }; this.compareTo = function (time) { var t1 = new Date(1970, 1, 1, this.getHours(), this.getMinutes(), this.getSeconds()), t2; if (time === null) { t2 = new Date(1970, 1, 1, 0, 0, 0); } else { t2 = new Date(1970, 1, 1, time.getHours(), time.getMinutes(), time.getSeconds()); } return (t1 < t2) ? -1 : (t1 > t2) ? 1 : 0; }; this.equals = function (time) { return (this.compareTo(time) === 0); }; this.add = function (time) { return (time === null) ? this : this.addSeconds(time.getTotalMilliseconds() / 1000); }; this.subtract = function (time) { return (time === null) ? this : this.addSeconds(-time.getTotalMilliseconds() / 1000); }; this.addDays = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 86400000)); }; this.addHours = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 3600000)); }; this.addMinutes = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 60000)); }; this.addSeconds = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 1000)); }; this.addMilliseconds = function (n) { return new TimeSpan(this.getTotalMilliseconds() + n); }; this.get12HourHour = function () { return (this.getHours() > 12) ? this.getHours() - 12 : (this.getHours() === 0) ? 12 : this.getHours(); }; this.getDesignator = function () { return (this.getHours() < 12) ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator; }; this.toString = function (format) { this._toString = function () { if (this.getDays() !== null && this.getDays() > 0) { return this.getDays() + "." + this.getHours() + ":" + this.p(this.getMinutes()) + ":" + this.p(this.getSeconds()); } else { return this.getHours() + ":" + this.p(this.getMinutes()) + ":" + this.p(this.getSeconds()); } }; this.p = function (s) { return (s.toString().length < 2) ? "0" + s : s; }; var me = this; return format ? format.replace(/dd?|HH?|hh?|mm?|ss?|tt?/g, function (format) { switch (format) { case "d": return me.getDays(); case "dd": return me.p(me.getDays()); case "H": return me.getHours(); case "HH": return me.p(me.getHours()); case "h": return me.get12HourHour(); case "hh": return me.p(me.get12HourHour()); case "m": return me.getMinutes(); case "mm": return me.p(me.getMinutes()); case "s": return me.getSeconds(); case "ss": return me.p(me.getSeconds()); case "t": return ((me.getHours() < 12) ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator).substring(0, 1); case "tt": return (me.getHours() < 12) ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator; } } ) : this._toString(); }; return this; }; addSetFuncs(TimeSpan, attrs.slice(2)); TimeSpan.prototype.set = function (days, hours, minutes, seconds, milliseconds){ this.setDays(days || this.getDays()); this.setHours(hours || this.getHours()); this.setMinutes(minutes || this.getMinutes()); this.setSeconds(seconds || this.getSeconds()); this.setMilliseconds(milliseconds || this.getMilliseconds()); }; /** * Gets the time of day for this date instances. * @return {TimeSpan} TimeSpan */ Date.prototype.getTimeOfDay = function () { return new TimeSpan(0, this.getHours(), this.getMinutes(), this.getSeconds(), this.getMilliseconds()); }; Date.TimeSpan = TimeSpan; if (typeof window !== "undefined" ) { // keeping API compatible for v1.x window.TimeSpan = TimeSpan; } }()); (function () { "use strict"; var attrs = ["years", "months", "days", "hours", "minutes", "seconds", "milliseconds"]; var gFn = function (attr) { return function () { return this[attr]; }; }; var sFn = function (attr) { return function (val) { this[attr] = val; return this; }; }; var addSetFuncs = function (context, attrs) { for (var i = 0; i < attrs.length ; i++) { var $a = attrs[i], $b = $a.slice(0, 1).toUpperCase() + $a.slice(1); context.prototype[$a] = 0; context.prototype["get" + $b] = gFn($a); context.prototype["set" + $b] = sFn($a); } }; var setMonthsAndYears = function (orient, d1, d2, context) { function inc() { d1.addMonths(-orient); context.months++; if (context.months === 12) { context.years++; context.months = 0; } } if (orient === +1) { while (d1 > d2) { inc(); } } else { while (d1 < d2) { inc(); } } context.months--; context.months *= orient; context.years *= orient; }; var adjustForDST = function(orient, startDate, endDate) { var hasDSTMismatch = (false === (startDate.isDaylightSavingTime() === endDate.isDaylightSavingTime())); if (hasDSTMismatch && orient === 1) { startDate.addHours(-1); } else if (hasDSTMismatch) { startDate.addHours(1); } }; /** * TimePeriod(startDate, endDate); * TimePeriod(years, months, days, hours, minutes, seconds, milliseconds); */ var TimePeriod = function (years, months, days, hours, minutes, seconds, milliseconds) { if (arguments.length === 7) { this.set(years, months, days, hours, minutes, seconds, milliseconds); } else if (arguments.length === 2 && arguments[0] instanceof Date && arguments[1] instanceof Date) { var startDate = arguments[0].clone(); var endDate = arguments[1].clone(); var orient = (startDate > endDate) ? +1 : -1; this.dates = { start: arguments[0].clone(), end: arguments[1].clone() }; setMonthsAndYears(orient, startDate, endDate, this); adjustForDST(orient, startDate, endDate); // // TODO - adjust for DST var diff = endDate - startDate; if (diff !== 0) { var ts = new TimeSpan(diff); this.set(this.years, this.months, ts.getDays(), ts.getHours(), ts.getMinutes(), ts.getSeconds(), ts.getMilliseconds()); } } return this; }; // create all the set functions. addSetFuncs(TimePeriod, attrs); TimePeriod.prototype.set = function (years, months, days, hours, minutes, seconds, milliseconds){ this.setYears(years || this.getYears()); this.setMonths(months || this.getMonths()); this.setDays(days || this.getDays()); this.setHours(hours || this.getHours()); this.setMinutes(minutes || this.getMinutes()); this.setSeconds(seconds || this.getSeconds()); this.setMilliseconds(milliseconds || this.getMilliseconds()); }; Date.TimePeriod = TimePeriod; if (typeof window !== "undefined") { // keeping API compatible for v1.x window.TimePeriod = TimePeriod; } }()); ================================================ FILE: build/date-es-ES.js ================================================ /** * @overview datejs * @version 1.0.0-rc3 * @author Gregory Wild-Smith * @copyright 2015 Gregory Wild-Smith * @license MIT * @homepage https://github.com/abritinthebay/datejs */ /* * DateJS Culture String File * Country Code: es-ES * Name: Spanish (Spain) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["es-ES"] = { "name": "es-ES", "englishName": "Spanish (Spain)", "nativeName": "español (España)", "Sunday": "domingo", "Monday": "lunes", "Tuesday": "martes", "Wednesday": "miércoles", "Thursday": "jueves", "Friday": "viernes", "Saturday": "sábado", "Sun": "dom", "Mon": "lun", "Tue": "mar", "Wed": "mié", "Thu": "jue", "Fri": "vie", "Sat": "sáb", "Su": "do", "Mo": "lu", "Tu": "ma", "We": "mi", "Th": "ju", "Fr": "vi", "Sa": "sá", "S_Sun_Initial": "d", "M_Mon_Initial": "l", "T_Tue_Initial": "m", "W_Wed_Initial": "m", "T_Thu_Initial": "j", "F_Fri_Initial": "v", "S_Sat_Initial": "s", "January": "enero", "February": "febrero", "March": "marzo", "April": "abril", "May": "mayo", "June": "junio", "July": "julio", "August": "agosto", "September": "septiembre", "October": "octubre", "November": "noviembre", "December": "diciembre", "Jan_Abbr": "ene", "Feb_Abbr": "feb", "Mar_Abbr": "mar", "Apr_Abbr": "abr", "May_Abbr": "may", "Jun_Abbr": "jun", "Jul_Abbr": "jul", "Aug_Abbr": "ago", "Sep_Abbr": "sep", "Oct_Abbr": "oct", "Nov_Abbr": "nov", "Dec_Abbr": "dic", "AM": "", "PM": "", "firstDayOfWeek": 1, "twoDigitYearMax": 2029, "mdy": "dmy", "M/d/yyyy": "dd/MM/yyyy", "dddd, MMMM dd, yyyy": "dddd, dd' [de] 'MMMM' [de] 'yyyy", "h:mm tt": "H:mm", "h:mm:ss tt": "H:mm:ss", "dddd, MMMM dd, yyyy h:mm:ss tt": "dddd, dd' [de] 'MMMM' [de] 'yyyy H:mm:ss", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "dd MMMM", "MMMM, yyyy": "MMMM' [de] 'yyyy", "/jan(uary)?/": "ene(ro)?", "/feb(ruary)?/": "feb(rero)?", "/mar(ch)?/": "mar(zo)?", "/apr(il)?/": "abr(il)?", "/may/": "may(o)?", "/jun(e)?/": "jun(io)?", "/jul(y)?/": "jul(io)?", "/aug(ust)?/": "ago(sto)?", "/sep(t(ember)?)?/": "sep(tiembre)?", "/oct(ober)?/": "oct(ubre)?", "/nov(ember)?/": "nov(iembre)?", "/dec(ember)?/": "dic(iembre)?", "/^su(n(day)?)?/": "^do(m(ingo)?)?", "/^mo(n(day)?)?/": "^lu(n(es)?)?", "/^tu(e(s(day)?)?)?/": "^ma(r(tes)?)?", "/^we(d(nesday)?)?/": "^mi(é(rcoles)?)?", "/^th(u(r(s(day)?)?)?)?/": "^ju(e(ves)?)?", "/^fr(i(day)?)?/": "^vi(e(rnes)?)?", "/^sa(t(urday)?)?/": "^sá(b(ado)?)?", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "es-ES"; /** * @overview datejs * @version 1.0.0-rc3 * @author Gregory Wild-Smith * @copyright 2015 Gregory Wild-Smith * @license MIT * @homepage https://github.com/abritinthebay/datejs */(function () { var $D = Date; var lang = Date.CultureStrings ? Date.CultureStrings.lang : null; var loggedKeys = {}; // for debug purposes. var getText = { getFromKey: function (key, countryCode) { var output; if (Date.CultureStrings && Date.CultureStrings[countryCode] && Date.CultureStrings[countryCode][key]) { output = Date.CultureStrings[countryCode][key]; } else { output = getText.buildFromDefault(key); } if (key.charAt(0) === "/") { // Assume it's a regex output = getText.buildFromRegex(key, countryCode); } return output; }, getFromObjectValues: function (obj, countryCode) { var key, output = {}; for(key in obj) { if (obj.hasOwnProperty(key)) { output[key] = getText.getFromKey(obj[key], countryCode); } } return output; }, getFromObjectKeys: function (obj, countryCode) { var key, output = {}; for(key in obj) { if (obj.hasOwnProperty(key)) { output[getText.getFromKey(key, countryCode)] = obj[key]; } } return output; }, getFromArray: function (arr, countryCode) { var output = []; for (var i=0; i < arr.length; i++){ if (i in arr) { output[i] = getText.getFromKey(arr[i], countryCode); } } return output; }, buildFromDefault: function (key) { var output, length, split, last; switch(key) { case "name": output = "en-US"; break; case "englishName": output = "English (United States)"; break; case "nativeName": output = "English (United States)"; break; case "twoDigitYearMax": output = 2049; break; case "firstDayOfWeek": output = 0; break; default: output = key; split = key.split("_"); length = split.length; if (length > 1 && key.charAt(0) !== "/") { // if the key isn't a regex and it has a split. last = split[(length - 1)].toLowerCase(); if (last === "initial" || last === "abbr") { output = split[0]; } } break; } return output; }, buildFromRegex: function (key, countryCode) { var output; if (Date.CultureStrings && Date.CultureStrings[countryCode] && Date.CultureStrings[countryCode][key]) { output = new RegExp(Date.CultureStrings[countryCode][key], "i"); } else { output = new RegExp(key.replace(new RegExp("/", "g"),""), "i"); } return output; } }; var shallowMerge = function (obj1, obj2) { for (var attrname in obj2) { if (obj2.hasOwnProperty(attrname)) { obj1[attrname] = obj2[attrname]; } } }; var __ = function (key, language) { var countryCode = (language) ? language : lang; loggedKeys[key] = key; if (typeof key === "object") { if (key instanceof Array) { return getText.getFromArray(key, countryCode); } else { return getText.getFromObjectKeys(key, countryCode); } } else { return getText.getFromKey(key, countryCode); } }; var loadI18nScript = function (code) { // paatterned after jQuery's getScript. var url = Date.Config.i18n + code + ".js"; var head = document.getElementsByTagName("head")[0] || document.documentElement; var script = document.createElement("script"); script.src = url; var completed = false; var events = { done: function (){} // placeholder function }; // Attach handlers for all browsers script.onload = script.onreadystatechange = function() { if ( !completed && (!this.readyState || this.readyState === "loaded" || this.readyState === "complete") ) { events.done(); head.removeChild(script); } }; setTimeout(function() { head.insertBefore(script, head.firstChild); }, 0); // allows return to execute first return { done: function (cb) { events.done = function() { if (cb) { setTimeout(cb,0); } }; } }; }; var buildInfo = { buildFromMethodHash: function (obj) { var key; for(key in obj) { if (obj.hasOwnProperty(key)) { obj[key] = buildInfo[obj[key]](); } } return obj; }, timeZoneDST: function () { var DST = { "CHADT": "+1345", "NZDT": "+1300", "AEDT": "+1100", "ACDT": "+1030", "AZST": "+0500", "IRDT": "+0430", "EEST": "+0300", "CEST": "+0200", "BST": "+0100", "PMDT": "-0200", "ADT": "-0300", "NDT": "-0230", "EDT": "-0400", "CDT": "-0500", "MDT": "-0600", "PDT": "-0700", "AKDT": "-0800", "HADT": "-0900" }; return __(DST); }, timeZoneStandard: function () { var standard = { "LINT": "+1400", "TOT": "+1300", "CHAST": "+1245", "NZST": "+1200", "NFT": "+1130", "SBT": "+1100", "AEST": "+1000", "ACST": "+0930", "JST": "+0900", "CWST": "+0845", "CT": "+0800", "ICT": "+0700", "MMT": "+0630", "BST": "+0600", "NPT": "+0545", "IST": "+0530", "PKT": "+0500", "AFT": "+0430", "MSK": "+0400", "IRST": "+0330", "FET": "+0300", "EET": "+0200", "CET": "+0100", "GMT": "+0000", "UTC": "+0000", "CVT": "-0100", "GST": "-0200", "BRT": "-0300", "NST": "-0330", "AST": "-0400", "EST": "-0500", "CST": "-0600", "MST": "-0700", "PST": "-0800", "AKST": "-0900", "MIT": "-0930", "HST": "-1000", "SST": "-1100", "BIT": "-1200" }; return __(standard); }, timeZones: function (data) { var zone; data.timezones = []; for (zone in data.abbreviatedTimeZoneStandard) { if (data.abbreviatedTimeZoneStandard.hasOwnProperty(zone)) { data.timezones.push({ name: zone, offset: data.abbreviatedTimeZoneStandard[zone]}); } } for (zone in data.abbreviatedTimeZoneDST) { if (data.abbreviatedTimeZoneDST.hasOwnProperty(zone)) { data.timezones.push({ name: zone, offset: data.abbreviatedTimeZoneDST[zone], dst: true}); } } return data.timezones; }, days: function () { return __(["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"]); }, dayAbbr: function () { return __(["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"]); }, dayShortNames: function () { return __(["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"]); }, dayFirstLetters: function () { return __(["S_Sun_Initial", "M_Mon_Initial", "T_Tues_Initial", "W_Wed_Initial", "T_Thu_Initial", "F_Fri_Initial", "S_Sat_Initial"]); }, months: function () { return __(["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"]); }, monthAbbr: function () { return __(["Jan_Abbr", "Feb_Abbr", "Mar_Abbr", "Apr_Abbr", "May_Abbr", "Jun_Abbr", "Jul_Abbr", "Aug_Abbr", "Sep_Abbr", "Oct_Abbr", "Nov_Abbr", "Dec_Abbr"]); }, formatPatterns: function () { return getText.getFromObjectValues({ shortDate: "M/d/yyyy", longDate: "dddd, MMMM dd, yyyy", shortTime: "h:mm tt", longTime: "h:mm:ss tt", fullDateTime: "dddd, MMMM dd, yyyy h:mm:ss tt", sortableDateTime: "yyyy-MM-ddTHH:mm:ss", universalSortableDateTime: "yyyy-MM-dd HH:mm:ssZ", rfc1123: "ddd, dd MMM yyyy HH:mm:ss", monthDay: "MMMM dd", yearMonth: "MMMM, yyyy" }, Date.i18n.currentLanguage()); }, regex: function () { return getText.getFromObjectValues({ inTheMorning: "/( in the )(morn(ing)?)\\b/", thisMorning: "/(this )(morn(ing)?)\\b/", amThisMorning: "/(\b\\d(am)? )(this )(morn(ing)?)/", inTheEvening: "/( in the )(even(ing)?)\\b/", thisEvening: "/(this )(even(ing)?)\\b/", pmThisEvening: "/(\b\\d(pm)? )(this )(even(ing)?)/", jan: "/jan(uary)?/", feb: "/feb(ruary)?/", mar: "/mar(ch)?/", apr: "/apr(il)?/", may: "/may/", jun: "/jun(e)?/", jul: "/jul(y)?/", aug: "/aug(ust)?/", sep: "/sep(t(ember)?)?/", oct: "/oct(ober)?/", nov: "/nov(ember)?/", dec: "/dec(ember)?/", sun: "/^su(n(day)?)?/", mon: "/^mo(n(day)?)?/", tue: "/^tu(e(s(day)?)?)?/", wed: "/^we(d(nesday)?)?/", thu: "/^th(u(r(s(day)?)?)?)?/", fri: "/fr(i(day)?)?/", sat: "/^sa(t(urday)?)?/", future: "/^next/", past: "/^last|past|prev(ious)?/", add: "/^(\\+|aft(er)?|from|hence)/", subtract: "/^(\\-|bef(ore)?|ago)/", yesterday: "/^yes(terday)?/", today: "/^t(od(ay)?)?/", tomorrow: "/^tom(orrow)?/", now: "/^n(ow)?/", millisecond: "/^ms|milli(second)?s?/", second: "/^sec(ond)?s?/", minute: "/^mn|min(ute)?s?/", hour: "/^h(our)?s?/", week: "/^w(eek)?s?/", month: "/^m(onth)?s?/", day: "/^d(ay)?s?/", year: "/^y(ear)?s?/", shortMeridian: "/^(a|p)/", longMeridian: "/^(a\\.?m?\\.?|p\\.?m?\\.?)/", timezone: "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/", ordinalSuffix: "/^\\s*(st|nd|rd|th)/", timeContext: "/^\\s*(\\:|a(?!u|p)|p)/" }, Date.i18n.currentLanguage()); } }; var CultureInfo = function () { var info = getText.getFromObjectValues({ name: "name", englishName: "englishName", nativeName: "nativeName", amDesignator: "AM", pmDesignator: "PM", firstDayOfWeek: "firstDayOfWeek", twoDigitYearMax: "twoDigitYearMax", dateElementOrder: "mdy" }, Date.i18n.currentLanguage()); var constructedInfo = buildInfo.buildFromMethodHash({ dayNames: "days", abbreviatedDayNames: "dayAbbr", shortestDayNames: "dayShortNames", firstLetterDayNames: "dayFirstLetters", monthNames: "months", abbreviatedMonthNames: "monthAbbr", formatPatterns: "formatPatterns", regexPatterns: "regex", abbreviatedTimeZoneDST: "timeZoneDST", abbreviatedTimeZoneStandard: "timeZoneStandard" }); shallowMerge(info, constructedInfo); buildInfo.timeZones(info); return info; }; $D.i18n = { __: function (key, lang) { return __(key, lang); }, currentLanguage: function () { return lang || "en-US"; }, setLanguage: function (code, force, cb) { var async = false; if (force || code === "en-US" || (!!Date.CultureStrings && !!Date.CultureStrings[code])) { lang = code; Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings.lang = code; Date.CultureInfo = new CultureInfo(); } else { if (!(!!Date.CultureStrings && !!Date.CultureStrings[code])) { if (typeof exports !== "undefined" && this.exports !== exports) { // we're in a Node enviroment, load it using require try { require("../i18n/" + code + ".js"); lang = code; Date.CultureStrings.lang = code; Date.CultureInfo = new CultureInfo(); } catch (e) { // var str = "The language for '" + code + "' could not be loaded by Node. It likely does not exist."; throw new Error("The DateJS IETF language tag '" + code + "' could not be loaded by Node. It likely does not exist."); } } else if (Date.Config && Date.Config.i18n) { // we know the location of the files, so lets load them async = true; loadI18nScript(code).done(function(){ lang = code; Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings.lang = code; Date.CultureInfo = new CultureInfo(); $D.Parsing.Normalizer.buildReplaceData(); // because this is async if ($D.Grammar) { $D.Grammar.buildGrammarFormats(); // so we can parse those strings... } if (cb) { setTimeout(cb,0); } }); } else { Date.console.error("The DateJS IETF language tag '" + code + "' is not available and has not been loaded."); return false; } } } $D.Parsing.Normalizer.buildReplaceData(); // rebuild normalizer strings if ($D.Grammar) { $D.Grammar.buildGrammarFormats(); // so we can parse those strings... } if (!async && cb) { setTimeout(cb,0); } }, getLoggedKeys: function () { return loggedKeys; }, updateCultureInfo: function () { Date.CultureInfo = new CultureInfo(); } }; $D.i18n.updateCultureInfo(); // run automatically }()); (function () { var $D = Date, $P = $D.prototype, p = function (s, l) { if (!l) { l = 2; } return ("000" + s).slice(l * -1); }; if (typeof window !== "undefined" && typeof window.console !== "undefined" && typeof window.console.log !== "undefined") { $D.console = console; // used only to raise non-critical errors if available } else { // set mock so we don't give errors. $D.console = { log: function(){}, error: function(){} }; } $D.Config = $D.Config || {}; $D.initOverloads = function() { /** * Overload of Date.now. Allows an alternate call for Date.now where it returns the * current Date as an object rather than just milliseconds since the Unix Epoch. * * Also provides an implementation of now() for browsers (IE<9) that don't have it. * * Backwards compatible so with work with either: * Date.now() [returns ms] * or * Date.now(true) [returns Date] */ if (!$D.now) { $D._now = function now() { return new Date().getTime(); }; } else if (!$D._now) { $D._now = $D.now; } $D.now = function (returnObj) { if (returnObj) { return $D.present(); } else { return $D._now(); } }; if ( !$P.toISOString ) { $P.toISOString = function() { return this.getUTCFullYear() + "-" + p(this.getUTCMonth() + 1) + "-" + p(this.getUTCDate()) + "T" + p(this.getUTCHours()) + ":" + p(this.getUTCMinutes()) + ":" + p(this.getUTCSeconds()) + "." + String( (this.getUTCMilliseconds()/1000).toFixed(3)).slice(2, 5) + "Z"; }; } // private if ( $P._toString === undefined ){ $P._toString = $P.toString; } }; $D.initOverloads(); /** * Gets a date that is set to the current date. The time is set to the start of the day (00:00 or 12:00 AM). * @return {Date} The current date. */ $D.today = function () { return new Date().clearTime(); }; /** * Gets a date that is set to the current date and time (same as new Date, but chainable) * @return {Date} The current date. */ $D.present = function () { return new Date(); }; /** * Compares the first date to the second date and returns an number indication of their relative values. * @param {Date} First Date object to compare [Required]. * @param {Date} Second Date object to compare to [Required]. * @return {Number} -1 = date1 is lessthan date2. 0 = values are equal. 1 = date1 is greaterthan date2. */ $D.compare = function (date1, date2) { if (isNaN(date1) || isNaN(date2)) { throw new Error(date1 + " - " + date2); } else if (date1 instanceof Date && date2 instanceof Date) { return (date1 < date2) ? -1 : (date1 > date2) ? 1 : 0; } else { throw new TypeError(date1 + " - " + date2); } }; /** * Compares the first Date object to the second Date object and returns true if they are equal. * @param {Date} First Date object to compare [Required] * @param {Date} Second Date object to compare to [Required] * @return {Boolean} true if dates are equal. false if they are not equal. */ $D.equals = function (date1, date2) { return (date1.compareTo(date2) === 0); }; /** * Gets the language appropriate day name when given the day number(0-6) * eg - 0 == Sunday * @return {String} The day name */ $D.getDayName = function (n) { return Date.CultureInfo.dayNames[n]; }; /** * Gets the day number (0-6) if given a CultureInfo specific string which is a valid dayName, abbreviatedDayName or shortestDayName (two char). * @param {String} The name of the day (eg. "Monday, "Mon", "tuesday", "tue", "We", "we"). * @return {Number} The day number */ $D.getDayNumberFromName = function (name) { var n = Date.CultureInfo.dayNames, m = Date.CultureInfo.abbreviatedDayNames, o = Date.CultureInfo.shortestDayNames, s = name.toLowerCase(); for (var i = 0; i < n.length; i++) { if (n[i].toLowerCase() === s || m[i].toLowerCase() === s || o[i].toLowerCase() === s) { return i; } } return -1; }; /** * Gets the month number (0-11) if given a Culture Info specific string which is a valid monthName or abbreviatedMonthName. * @param {String} The name of the month (eg. "February, "Feb", "october", "oct"). * @return {Number} The day number */ $D.getMonthNumberFromName = function (name) { var n = Date.CultureInfo.monthNames, m = Date.CultureInfo.abbreviatedMonthNames, s = name.toLowerCase(); for (var i = 0; i < n.length; i++) { if (n[i].toLowerCase() === s || m[i].toLowerCase() === s) { return i; } } return -1; }; /** * Gets the language appropriate month name when given the month number(0-11) * eg - 0 == January * @return {String} The month name */ $D.getMonthName = function (n) { return Date.CultureInfo.monthNames[n]; }; /** * Determines if the current date instance is within a LeapYear. * @param {Number} The year. * @return {Boolean} true if date is within a LeapYear, otherwise false. */ $D.isLeapYear = function (year) { return ((year % 4 === 0 && year % 100 !== 0) || year % 400 === 0); }; /** * Gets the number of days in the month, given a year and month value. Automatically corrects for LeapYear. * @param {Number} The year. * @param {Number} The month (0-11). * @return {Number} The number of days in the month. */ $D.getDaysInMonth = function (year, month) { if (!month && $D.validateMonth(year)) { month = year; year = Date.today().getFullYear(); } return [31, ($D.isLeapYear(year) ? 29 : 28), 31, 30, 31, 30, 31, 31, 30, 31, 30, 31][month]; }; $P.getDaysInMonth = function () { return $D.getDaysInMonth(this.getFullYear(), this.getMonth()); }; $D.getTimezoneAbbreviation = function (offset, dst) { var p, n = (dst || false) ? Date.CultureInfo.abbreviatedTimeZoneDST : Date.CultureInfo.abbreviatedTimeZoneStandard; for (p in n) { if (n.hasOwnProperty(p)) { if (n[p] === offset) { return p; } } } return null; }; $D.getTimezoneOffset = function (name, dst) { var i, a =[], z = Date.CultureInfo.timezones; if (!name) { name = (new Date()).getTimezone();} for (i = 0; i < z.length; i++) { if (z[i].name === name.toUpperCase()) { a.push(i); } } if (!z[a[0]]) { return null; } if (a.length === 1 || !dst) { return z[a[0]].offset; } else { for (i=0; i < a.length; i++) { if (z[a[i]].dst) { return z[a[i]].offset; } } } }; $D.getQuarter = function (d) { d = d || new Date(); // If no date supplied, use today var q = [1,2,3,4]; return q[Math.floor(d.getMonth() / 3)]; // ~~~ is a bitwise op. Faster than Math.floor }; $D.getDaysLeftInQuarter = function (d) { d = d || new Date(); var qEnd = new Date(d); qEnd.setMonth(qEnd.getMonth() + 3 - qEnd.getMonth() % 3, 0); return Math.floor((qEnd - d) / 8.64e7); }; // private var validate = function (n, min, max, name) { name = name ? name : "Object"; if (typeof n === "undefined") { return false; } else if (typeof n !== "number") { throw new TypeError(n + " is not a Number."); } else if (n < min || n > max) { // As failing validation is *not* an exceptional circumstance // lets not throw a RangeError Exception here. // It's semantically correct but it's not sensible. return false; } return true; }; /** * Validates the number is within an acceptable range for milliseconds [0-999]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateMillisecond = function (value) { return validate(value, 0, 999, "millisecond"); }; /** * Validates the number is within an acceptable range for seconds [0-59]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateSecond = function (value) { return validate(value, 0, 59, "second"); }; /** * Validates the number is within an acceptable range for minutes [0-59]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateMinute = function (value) { return validate(value, 0, 59, "minute"); }; /** * Validates the number is within an acceptable range for hours [0-23]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateHour = function (value) { return validate(value, 0, 23, "hour"); }; /** * Validates the number is within an acceptable range for the days in a month [0-MaxDaysInMonth]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateDay = function (value, year, month) { if (year === undefined || year === null || month === undefined || month === null) { return false;} return validate(value, 1, $D.getDaysInMonth(year, month), "day"); }; /** * Validates the number is within an acceptable range for months [0-11]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateWeek = function (value) { return validate(value, 0, 53, "week"); }; /** * Validates the number is within an acceptable range for months [0-11]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateMonth = function (value) { return validate(value, 0, 11, "month"); }; /** * Validates the number is within an acceptable range for years. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateYear = function (value) { /** * Per ECMAScript spec the range of times supported by Date objects is * exactly -100,000,000 days to +100,000,000 days measured relative to * midnight at the beginning of 01 January, 1970 UTC. * This gives a range of 8,640,000,000,000,000 milliseconds to either * side of 01 January, 1970 UTC. * * Earliest possible date: Tue, 20 Apr 271,822 B.C. 00:00:00 UTC * Latest possible date: Sat, 13 Sep 275,760 00:00:00 UTC */ return validate(value, -271822, 275760, "year"); }; $D.validateTimezone = function(value) { var timezones = {"ACDT":1,"ACST":1,"ACT":1,"ADT":1,"AEDT":1,"AEST":1,"AFT":1,"AKDT":1,"AKST":1,"AMST":1,"AMT":1,"ART":1,"AST":1,"AWDT":1,"AWST":1,"AZOST":1,"AZT":1,"BDT":1,"BIOT":1,"BIT":1,"BOT":1,"BRT":1,"BST":1,"BTT":1,"CAT":1,"CCT":1,"CDT":1,"CEDT":1,"CEST":1,"CET":1,"CHADT":1,"CHAST":1,"CHOT":1,"ChST":1,"CHUT":1,"CIST":1,"CIT":1,"CKT":1,"CLST":1,"CLT":1,"COST":1,"COT":1,"CST":1,"CT":1,"CVT":1,"CWST":1,"CXT":1,"DAVT":1,"DDUT":1,"DFT":1,"EASST":1,"EAST":1,"EAT":1,"ECT":1,"EDT":1,"EEDT":1,"EEST":1,"EET":1,"EGST":1,"EGT":1,"EIT":1,"EST":1,"FET":1,"FJT":1,"FKST":1,"FKT":1,"FNT":1,"GALT":1,"GAMT":1,"GET":1,"GFT":1,"GILT":1,"GIT":1,"GMT":1,"GST":1,"GYT":1,"HADT":1,"HAEC":1,"HAST":1,"HKT":1,"HMT":1,"HOVT":1,"HST":1,"ICT":1,"IDT":1,"IOT":1,"IRDT":1,"IRKT":1,"IRST":1,"IST":1,"JST":1,"KGT":1,"KOST":1,"KRAT":1,"KST":1,"LHST":1,"LINT":1,"MAGT":1,"MART":1,"MAWT":1,"MDT":1,"MET":1,"MEST":1,"MHT":1,"MIST":1,"MIT":1,"MMT":1,"MSK":1,"MST":1,"MUT":1,"MVT":1,"MYT":1,"NCT":1,"NDT":1,"NFT":1,"NPT":1,"NST":1,"NT":1,"NUT":1,"NZDT":1,"NZST":1,"OMST":1,"ORAT":1,"PDT":1,"PET":1,"PETT":1,"PGT":1,"PHOT":1,"PHT":1,"PKT":1,"PMDT":1,"PMST":1,"PONT":1,"PST":1,"PYST":1,"PYT":1,"RET":1,"ROTT":1,"SAKT":1,"SAMT":1,"SAST":1,"SBT":1,"SCT":1,"SGT":1,"SLST":1,"SRT":1,"SST":1,"SYOT":1,"TAHT":1,"THA":1,"TFT":1,"TJT":1,"TKT":1,"TLT":1,"TMT":1,"TOT":1,"TVT":1,"UCT":1,"ULAT":1,"UTC":1,"UYST":1,"UYT":1,"UZT":1,"VET":1,"VLAT":1,"VOLT":1,"VOST":1,"VUT":1,"WAKT":1,"WAST":1,"WAT":1,"WEDT":1,"WEST":1,"WET":1,"WST":1,"YAKT":1,"YEKT":1,"Z":1}; return (timezones[value] === 1); }; $D.validateTimezoneOffset= function(value) { // timezones go from +14hrs to -12hrs, the +X hours are negative offsets. return (value > -841 && value < 721); }; }()); (function () { var $D = Date, $P = $D.prototype, p = function (s, l) { if (!l) { l = 2; } return ("000" + s).slice(l * -1); }; var validateConfigObject = function (obj) { var result = {}, self = this, prop, testFunc; testFunc = function (prop, func, value) { if (prop === "day") { var month = (obj.month !== undefined) ? obj.month : self.getMonth(); var year = (obj.year !== undefined) ? obj.year : self.getFullYear(); return $D[func](value, year, month); } else { return $D[func](value); } }; for (prop in obj) { if (Object.prototype.hasOwnProperty.call(obj, prop)) { var func = "validate" + prop.charAt(0).toUpperCase() + prop.slice(1); if ($D[func] && obj[prop] !== null && testFunc(prop, func, obj[prop])) { result[prop] = obj[prop]; } } } return result; }; /** * Resets the time of this Date object to 12:00 AM (00:00), which is the start of the day. * @param {Boolean} .clone() this date instance before clearing Time * @return {Date} this */ $P.clearTime = function () { this.setHours(0); this.setMinutes(0); this.setSeconds(0); this.setMilliseconds(0); return this; }; /** * Resets the time of this Date object to the current time ('now'). * @return {Date} this */ $P.setTimeToNow = function () { var n = new Date(); this.setHours(n.getHours()); this.setMinutes(n.getMinutes()); this.setSeconds(n.getSeconds()); this.setMilliseconds(n.getMilliseconds()); return this; }; /** * Returns a new Date object that is an exact date and time copy of the original instance. * @return {Date} A new Date instance */ $P.clone = function () { return new Date(this.getTime()); }; /** * Compares this instance to a Date object and returns an number indication of their relative values. * @param {Date} Date object to compare [Required] * @return {Number} -1 = this is lessthan date. 0 = values are equal. 1 = this is greaterthan date. */ $P.compareTo = function (date) { return Date.compare(this, date); }; /** * Compares this instance to another Date object and returns true if they are equal. * @param {Date} Date object to compare. If no date to compare, new Date() [now] is used. * @return {Boolean} true if dates are equal. false if they are not equal. */ $P.equals = function (date) { return Date.equals(this, (date !== undefined ? date : new Date())); }; /** * Determines if this instance is between a range of two dates or equal to either the start or end dates. * @param {Date} Start of range [Required] * @param {Date} End of range [Required] * @return {Boolean} true is this is between or equal to the start and end dates, else false */ $P.between = function (start, end) { return this.getTime() >= start.getTime() && this.getTime() <= end.getTime(); }; /** * Determines if this date occurs after the date to compare to. * @param {Date} Date object to compare. If no date to compare, new Date() ("now") is used. * @return {Boolean} true if this date instance is greater than the date to compare to (or "now"), otherwise false. */ $P.isAfter = function (date) { return this.compareTo(date || new Date()) === 1; }; /** * Determines if this date occurs before the date to compare to. * @param {Date} Date object to compare. If no date to compare, new Date() ("now") is used. * @return {Boolean} true if this date instance is less than the date to compare to (or "now"). */ $P.isBefore = function (date) { return (this.compareTo(date || new Date()) === -1); }; /** * Determines if the current Date instance occurs today. * @return {Boolean} true if this date instance is 'today', otherwise false. */ /** * Determines if the current Date instance occurs on the same Date as the supplied 'date'. * If no 'date' to compare to is provided, the current Date instance is compared to 'today'. * @param {date} Date object to compare. If no date to compare, the current Date ("now") is used. * @return {Boolean} true if this Date instance occurs on the same Day as the supplied 'date'. */ $P.isToday = $P.isSameDay = function (date) { return this.clone().clearTime().equals((date || new Date()).clone().clearTime()); }; /** * Adds the specified number of milliseconds to this instance. * @param {Number} The number of milliseconds to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addMilliseconds = function (value) { if (!value) { return this; } this.setTime(this.getTime() + value * 1); return this; }; /** * Adds the specified number of seconds to this instance. * @param {Number} The number of seconds to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addSeconds = function (value) { if (!value) { return this; } return this.addMilliseconds(value * 1000); }; /** * Adds the specified number of seconds to this instance. * @param {Number} The number of seconds to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addMinutes = function (value) { if (!value) { return this; } return this.addMilliseconds(value * 60000); // 60*1000 }; /** * Adds the specified number of hours to this instance. * @param {Number} The number of hours to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addHours = function (value) { if (!value) { return this; } return this.addMilliseconds(value * 3600000); // 60*60*1000 }; /** * Adds the specified number of days to this instance. * @param {Number} The number of days to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addDays = function (value) { if (!value) { return this; } this.setDate(this.getDate() + value * 1); return this; }; /** * Adds the specified number of weekdays (ie - not sat or sun) to this instance. * @param {Number} The number of days to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addWeekdays = function (value) { if (!value) { return this; } var day = this.getDay(); var weeks = (Math.ceil(Math.abs(value)/7)); if (day === 0 || day === 6) { if (value > 0) { this.next().monday(); this.addDays(-1); day = this.getDay(); } } if (value < 0) { while (value < 0) { this.addDays(-1); day = this.getDay(); if (day !== 0 && day !== 6) { value++; } } return this; } else if (value > 5 || (6-day) <= value) { value = value + (weeks * 2); } return this.addDays(value); }; /** * Adds the specified number of weeks to this instance. * @param {Number} The number of weeks to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addWeeks = function (value) { if (!value) { return this; } return this.addDays(value * 7); }; /** * Adds the specified number of months to this instance. * @param {Number} The number of months to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addMonths = function (value) { if (!value) { return this; } var n = this.getDate(); this.setDate(1); this.setMonth(this.getMonth() + value * 1); this.setDate(Math.min(n, $D.getDaysInMonth(this.getFullYear(), this.getMonth()))); return this; }; $P.addQuarters = function (value) { if (!value) { return this; } // note this will take you to the same point in the quarter as you are now. // i.e. - if you are 15 days into the quarter you'll be 15 days into the resulting one. // bonus: this allows adding fractional quarters return this.addMonths(value * 3); }; /** * Adds the specified number of years to this instance. * @param {Number} The number of years to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addYears = function (value) { if (!value) { return this; } return this.addMonths(value * 12); }; /** * Adds (or subtracts) to the value of the years, months, weeks, days, hours, minutes, seconds, milliseconds of the date instance using given configuration object. Positive and Negative values allowed. * Example

	Date.today().add( { days: 1, months: 1 } )

	new Date().add( { years: -1 } )
	
* @param {Object} Configuration object containing attributes (months, days, etc.) * @return {Date} this */ $P.add = function (config) { if (typeof config === "number") { this._orient = config; return this; } var x = config; if (x.day) { // If we should be a different date than today (eg: for 'tomorrow -1d', etc). // Should only effect parsing, not direct usage (eg, Finish and FinishExact) if ((x.day - this.getDate()) !== 0) { this.setDate(x.day); } } if (x.milliseconds) { this.addMilliseconds(x.milliseconds); } if (x.seconds) { this.addSeconds(x.seconds); } if (x.minutes) { this.addMinutes(x.minutes); } if (x.hours) { this.addHours(x.hours); } if (x.weeks) { this.addWeeks(x.weeks); } if (x.months) { this.addMonths(x.months); } if (x.years) { this.addYears(x.years); } if (x.days) { this.addDays(x.days); } return this; }; /** * Get the week number. Week one (1) is the week which contains the first Thursday of the year. Monday is considered the first day of the week. * The .getWeek() function does NOT convert the date to UTC. The local datetime is used. * Please use .getISOWeek() to get the week of the UTC converted date. * @return {Number} 1 to 53 */ $P.getWeek = function (utc) { // Create a copy of this date object var self, target = new Date(this.valueOf()); if (utc) { target.addMinutes(target.getTimezoneOffset()); self = target.clone(); } else { self = this; } // ISO week date weeks start on monday // so correct the day number var dayNr = (self.getDay() + 6) % 7; // ISO 8601 states that week 1 is the week // with the first thursday of that year. // Set the target date to the thursday in the target week target.setDate(target.getDate() - dayNr + 3); // Store the millisecond value of the target date var firstThursday = target.valueOf(); // Set the target to the first thursday of the year // First set the target to january first target.setMonth(0, 1); // Not a thursday? Correct the date to the next thursday if (target.getDay() !== 4) { target.setMonth(0, 1 + ((4 - target.getDay()) + 7) % 7); } // The weeknumber is the number of weeks between the // first thursday of the year and the thursday in the target week return 1 + Math.ceil((firstThursday - target) / 604800000); // 604800000 = 7 * 24 * 3600 * 1000 }; /** * Get the ISO 8601 week number. Week one ("01") is the week which contains the first Thursday of the year. Monday is considered the first day of the week. * The .getISOWeek() function does convert the date to it's UTC value. Please use .getWeek() to get the week of the local date. * @return {String} "01" to "53" */ $P.getISOWeek = function () { return p(this.getWeek(true)); }; /** * Moves the date to Monday of the week set. Week one (1) is the week which contains the first Thursday of the year. * @param {Number} A Number (1 to 53) that represents the week of the year. * @return {Date} this */ $P.setWeek = function (n) { if ((n - this.getWeek()) === 0) { if (this.getDay() !== 1) { return this.moveToDayOfWeek(1, (this.getDay() > 1 ? -1 : 1)); } else { return this; } } else { return this.moveToDayOfWeek(1, (this.getDay() > 1 ? -1 : 1)).addWeeks(n - this.getWeek()); } }; $P.setQuarter = function (qtr) { var month = Math.abs(((qtr-1) * 3) + 1); return this.setMonth(month, 1); }; $P.getQuarter = function () { return Date.getQuarter(this); }; $P.getDaysLeftInQuarter = function () { return Date.getDaysLeftInQuarter(this); }; /** * Moves the date to the next n'th occurrence of the dayOfWeek starting from the beginning of the month. The number (-1) is a magic number and will return the last occurrence of the dayOfWeek in the month. * @param {Number} The dayOfWeek to move to * @param {Number} The n'th occurrence to move to. Use (-1) to return the last occurrence in the month * @return {Date} this */ $P.moveToNthOccurrence = function (dayOfWeek, occurrence) { if (dayOfWeek === "Weekday") { if (occurrence > 0) { this.moveToFirstDayOfMonth(); if (this.is().weekday()) { occurrence -= 1; } } else if (occurrence < 0) { this.moveToLastDayOfMonth(); if (this.is().weekday()) { occurrence += 1; } } else { return this; } return this.addWeekdays(occurrence); } var shift = 0; if (occurrence > 0) { shift = occurrence - 1; } else if (occurrence === -1) { this.moveToLastDayOfMonth(); if (this.getDay() !== dayOfWeek) { this.moveToDayOfWeek(dayOfWeek, -1); } return this; } return this.moveToFirstDayOfMonth().addDays(-1).moveToDayOfWeek(dayOfWeek, +1).addWeeks(shift); }; var moveToN = function (getFunc, addFunc, nVal) { return function (value, orient) { var diff = (value - this[getFunc]() + nVal * (orient || +1)) % nVal; return this[addFunc]((diff === 0) ? diff += nVal * (orient || +1) : diff); }; }; /** * Move to the next or last dayOfWeek based on the orient value. * @param {Number} The dayOfWeek to move to * @param {Number} Forward (+1) or Back (-1). Defaults to +1. [Optional] * @return {Date} this */ $P.moveToDayOfWeek = moveToN("getDay", "addDays", 7); /** * Move to the next or last month based on the orient value. * @param {Number} The month to move to. 0 = January, 11 = December * @param {Number} Forward (+1) or Back (-1). Defaults to +1. [Optional] * @return {Date} this */ $P.moveToMonth = moveToN("getMonth", "addMonths", 12); /** * Get the Ordinate of the current day ("th", "st", "rd"). * @return {String} */ $P.getOrdinate = function () { var num = this.getDate(); return ord(num); }; /** * Get the Ordinal day (numeric day number) of the year, adjusted for leap year. * @return {Number} 1 through 365 (366 in leap years) */ $P.getOrdinalNumber = function () { return Math.ceil((this.clone().clearTime() - new Date(this.getFullYear(), 0, 1)) / 86400000) + 1; }; /** * Get the time zone abbreviation of the current date. * @return {String} The abbreviated time zone name (e.g. "EST") */ $P.getTimezone = function () { return $D.getTimezoneAbbreviation(this.getUTCOffset(), this.isDaylightSavingTime()); }; $P.setTimezoneOffset = function (offset) { var here = this.getTimezoneOffset(), there = Number(offset) * -6 / 10; return (there || there === 0) ? this.addMinutes(there - here) : this; }; $P.setTimezone = function (offset) { return this.setTimezoneOffset($D.getTimezoneOffset(offset)); }; /** * Indicates whether Daylight Saving Time is observed in the current time zone. * @return {Boolean} true|false */ $P.hasDaylightSavingTime = function () { return (Date.today().set({month: 0, day: 1}).getTimezoneOffset() !== Date.today().set({month: 6, day: 1}).getTimezoneOffset()); }; /** * Indicates whether this Date instance is within the Daylight Saving Time range for the current time zone. * @return {Boolean} true|false */ $P.isDaylightSavingTime = function () { return Date.today().set({month: 0, day: 1}).getTimezoneOffset() !== this.getTimezoneOffset(); }; /** * Get the offset from UTC of the current date. * @return {String} The 4-character offset string prefixed with + or - (e.g. "-0500") */ $P.getUTCOffset = function (offset) { var n = (offset || this.getTimezoneOffset()) * -10 / 6, r; if (n < 0) { r = (n - 10000).toString(); return r.charAt(0) + r.substr(2); } else { r = (n + 10000).toString(); return "+" + r.substr(1); } }; /** * Returns the number of milliseconds between this date and date. * @param {Date} Defaults to now * @return {Number} The diff in milliseconds */ $P.getElapsed = function (date) { return (date || new Date()) - this; }; /** * Set the value of year, month, day, hour, minute, second, millisecond of date instance using given configuration object. * Example

	Date.today().set( { day: 20, month: 1 } )

	new Date().set( { millisecond: 0 } )
	
* * @param {Object} Configuration object containing attributes (month, day, etc.) * @return {Date} this */ $P.set = function (config) { config = validateConfigObject.call(this, config); var key; for (key in config) { if (Object.prototype.hasOwnProperty.call(config, key)) { var name = key.charAt(0).toUpperCase() + key.slice(1); var addFunc, getFunc; if (key !== "week" && key !== "month" && key !== "timezone" && key !== "timezoneOffset") { name += "s"; } addFunc = "add" + name; getFunc = "get" + name; if (key === "month") { addFunc = addFunc + "s"; } else if (key === "year"){ getFunc = "getFullYear"; } if (key !== "day" && key !== "timezone" && key !== "timezoneOffset" && key !== "week" && key !== "hour") { this[addFunc](config[key] - this[getFunc]()); } else if ( key === "timezone"|| key === "timezoneOffset" || key === "week" || key === "hour") { this["set"+name](config[key]); } } } // day has to go last because you can't validate the day without first knowing the month if (config.day) { this.addDays(config.day - this.getDate()); } return this; }; /** * Moves the date to the first day of the month. * @return {Date} this */ $P.moveToFirstDayOfMonth = function () { return this.set({ day: 1 }); }; /** * Moves the date to the last day of the month. * @return {Date} this */ $P.moveToLastDayOfMonth = function () { return this.set({ day: $D.getDaysInMonth(this.getFullYear(), this.getMonth())}); }; /** * Converts the value of the current Date object to its equivalent string representation. * Format Specifiers * CUSTOM DATE AND TIME FORMAT STRINGS * Format Description Example * ------ --------------------------------------------------------------------------- ----------------------- * s The seconds of the minute between 0-59. "0" to "59" * ss The seconds of the minute with leading zero if required. "00" to "59" * * m The minute of the hour between 0-59. "0" or "59" * mm The minute of the hour with leading zero if required. "00" or "59" * * h The hour of the day between 1-12. "1" to "12" * hh The hour of the day with leading zero if required. "01" to "12" * * H The hour of the day between 0-23. "0" to "23" * HH The hour of the day with leading zero if required. "00" to "23" * * d The day of the month between 1 and 31. "1" to "31" * dd The day of the month with leading zero if required. "01" to "31" * ddd Abbreviated day name. Date.CultureInfo.abbreviatedDayNames. "Mon" to "Sun" * dddd The full day name. Date.CultureInfo.dayNames. "Monday" to "Sunday" * * M The month of the year between 1-12. "1" to "12" * MM The month of the year with leading zero if required. "01" to "12" * MMM Abbreviated month name. Date.CultureInfo.abbreviatedMonthNames. "Jan" to "Dec" * MMMM The full month name. Date.CultureInfo.monthNames. "January" to "December" * * yy The year as a two-digit number. "99" or "08" * yyyy The full four digit year. "1999" or "2008" * * t Displays the first character of the A.M./P.M. designator. "A" or "P" * Date.CultureInfo.amDesignator or Date.CultureInfo.pmDesignator * tt Displays the A.M./P.M. designator. "AM" or "PM" * Date.CultureInfo.amDesignator or Date.CultureInfo.pmDesignator * * S The ordinal suffix ("st, "nd", "rd" or "th") of the current day. "st, "nd", "rd" or "th" * * STANDARD DATE AND TIME FORMAT STRINGS * Format Description Example *------ --------------------------------------------------------------------------- ----------------------- * d The CultureInfo shortDate Format Pattern "M/d/yyyy" * D The CultureInfo longDate Format Pattern "dddd, MMMM dd, yyyy" * F The CultureInfo fullDateTime Format Pattern "dddd, MMMM dd, yyyy h:mm:ss tt" * m The CultureInfo monthDay Format Pattern "MMMM dd" * r The CultureInfo rfc1123 Format Pattern "ddd, dd MMM yyyy HH:mm:ss GMT" * s The CultureInfo sortableDateTime Format Pattern "yyyy-MM-ddTHH:mm:ss" * t The CultureInfo shortTime Format Pattern "h:mm tt" * T The CultureInfo longTime Format Pattern "h:mm:ss tt" * u The CultureInfo universalSortableDateTime Format Pattern "yyyy-MM-dd HH:mm:ssZ" * y The CultureInfo yearMonth Format Pattern "MMMM, yyyy" * * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @return {String} A string representation of the current Date object. */ var ord = function (n) { switch (n * 1) { case 1: case 21: case 31: return "st"; case 2: case 22: return "nd"; case 3: case 23: return "rd"; default: return "th"; } }; var parseStandardFormats = function (format) { var y, c = Date.CultureInfo.formatPatterns; switch (format) { case "d": return this.toString(c.shortDate); case "D": return this.toString(c.longDate); case "F": return this.toString(c.fullDateTime); case "m": return this.toString(c.monthDay); case "r": case "R": y = this.clone().addMinutes(this.getTimezoneOffset()); return y.toString(c.rfc1123) + " GMT"; case "s": return this.toString(c.sortableDateTime); case "t": return this.toString(c.shortTime); case "T": return this.toString(c.longTime); case "u": y = this.clone().addMinutes(this.getTimezoneOffset()); return y.toString(c.universalSortableDateTime); case "y": return this.toString(c.yearMonth); default: return false; } }; var parseFormatStringsClosure = function (context) { return function (m) { if (m.charAt(0) === "\\") { return m.replace("\\", ""); } switch (m) { case "hh": return p(context.getHours() < 13 ? (context.getHours() === 0 ? 12 : context.getHours()) : (context.getHours() - 12)); case "h": return context.getHours() < 13 ? (context.getHours() === 0 ? 12 : context.getHours()) : (context.getHours() - 12); case "HH": return p(context.getHours()); case "H": return context.getHours(); case "mm": return p(context.getMinutes()); case "m": return context.getMinutes(); case "ss": return p(context.getSeconds()); case "s": return context.getSeconds(); case "yyyy": return p(context.getFullYear(), 4); case "yy": return p(context.getFullYear()); case "y": return context.getFullYear(); case "E": case "dddd": return Date.CultureInfo.dayNames[context.getDay()]; case "ddd": return Date.CultureInfo.abbreviatedDayNames[context.getDay()]; case "dd": return p(context.getDate()); case "d": return context.getDate(); case "MMMM": return Date.CultureInfo.monthNames[context.getMonth()]; case "MMM": return Date.CultureInfo.abbreviatedMonthNames[context.getMonth()]; case "MM": return p((context.getMonth() + 1)); case "M": return context.getMonth() + 1; case "t": return context.getHours() < 12 ? Date.CultureInfo.amDesignator.substring(0, 1) : Date.CultureInfo.pmDesignator.substring(0, 1); case "tt": return context.getHours() < 12 ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator; case "S": return ord(context.getDate()); case "W": return context.getWeek(); case "WW": return context.getISOWeek(); case "Q": return "Q" + context.getQuarter(); case "q": return String(context.getQuarter()); case "z": return context.getTimezone(); case "Z": case "X": return Date.getTimezoneOffset(context.getTimezone()); case "ZZ": // Timezone offset in seconds return context.getTimezoneOffset() * -60; case "u": return context.getDay(); case "L": return ($D.isLeapYear(context.getFullYear())) ? 1 : 0; case "B": // Swatch Internet Time (.beats) return "@"+((context.getUTCSeconds() + (context.getUTCMinutes()*60) + ((context.getUTCHours()+1)*3600))/86.4); default: return m; } }; }; $P.toString = function (format, ignoreStandards) { // Standard Date and Time Format Strings. Formats pulled from CultureInfo file and // may vary by culture. if (!ignoreStandards && format && format.length === 1) { output = parseStandardFormats.call(this, format); if (output) { return output; } } var parseFormatStrings = parseFormatStringsClosure(this); return format ? format.replace(/((\\)?(dd?d?d?|MM?M?M?|yy?y?y?|hh?|HH?|mm?|ss?|tt?|S|q|Q|WW?W?W?)(?![^\[]*\]))/g, parseFormatStrings).replace(/\[|\]/g, "") : this._toString(); }; }()); /************************************************************* * SugarPak - Domain Specific Language - Syntactical Sugar * *************************************************************/ (function () { var $D = Date, $P = $D.prototype, $N = Number.prototype; // private $P._orient = +1; // private $P._nth = null; // private $P._is = false; // private $P._same = false; // private $P._isSecond = false; // private $N._dateElement = "days"; /** * Moves the date to the next instance of a date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.today().next().friday();
	Date.today().next().fri();
	Date.today().next().march();
	Date.today().next().mar();
	Date.today().next().week();
	
* * @return {Date} date */ $P.next = function () { this._move = true; this._orient = +1; return this; }; /** * Creates a new Date (Date.today()) and moves the date to the next instance of the date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.next().friday();
	Date.next().fri();
	Date.next().march();
	Date.next().mar();
	Date.next().week();
	
* * @return {Date} date */ $D.next = function () { return $D.today().next(); }; /** * Moves the date to the previous instance of a date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.today().last().friday();
	Date.today().last().fri();
	Date.today().last().march();
	Date.today().last().mar();
	Date.today().last().week();
	
* * @return {Date} date */ $P.last = $P.prev = $P.previous = function () { this._move = true; this._orient = -1; return this; }; /** * Creates a new Date (Date.today()) and moves the date to the previous instance of the date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.last().friday();
	Date.last().fri();
	Date.previous().march();
	Date.prev().mar();
	Date.last().week();
	
* * @return {Date} date */ $D.last = $D.prev = $D.previous = function () { return $D.today().last(); }; /** * Performs a equality check when followed by either a month name, day name or .weekday() function. * Example

	Date.today().is().friday(); // true|false
	Date.today().is().fri();
	Date.today().is().march();
	Date.today().is().mar();
	
* * @return {Boolean} true|false */ $P.is = function () { this._is = true; return this; }; /** * Determines if two date objects occur on/in exactly the same instance of the subsequent date part function. * The function .same() must be followed by a date part function (example: .day(), .month(), .year(), etc). * * An optional Date can be passed in the date part function. If now date is passed as a parameter, 'Now' is used. * * The following example demonstrates how to determine if two dates fall on the exact same day. * * Example

	var d1 = Date.today(); // today at 00:00
	var d2 = new Date();   // exactly now.

	// Do they occur on the same day?
	d1.same().day(d2); // true
	
	// Do they occur on the same hour?
	d1.same().hour(d2); // false, unless d2 hour is '00' (midnight).
	
	// What if it's the same day, but one year apart?
	var nextYear = Date.today().add(1).year();

	d1.same().day(nextYear); // false, because the dates must occur on the exact same day. 
	
* * Scenario: Determine if a given date occurs during some week period 2 months from now. * * Example

	var future = Date.today().add(2).months();
	return someDate.same().week(future); // true|false;
	
* * @return {Boolean} true|false */ $P.same = function () { this._same = true; this._isSecond = false; return this; }; /** * Determines if the current date/time occurs during Today. Must be preceded by the .is() function. * Example

	someDate.is().today();    // true|false
	new Date().is().today();  // true
	Date.today().is().today();// true
	Date.today().add(-1).day().is().today(); // false
	
* * @return {Boolean} true|false */ $P.today = function () { return this.same().day(); }; /** * Determines if the current date is a weekday. This function must be preceded by the .is() function. * Example

	Date.today().is().weekday(); // true|false
	
* * @return {Boolean} true|false */ $P.weekday = function () { if (this._nth) { return df("Weekday").call(this); } if (this._move) { return this.addWeekdays(this._orient); } if (this._is) { this._is = false; return (!this.is().sat() && !this.is().sun()); } return false; }; /** * Determines if the current date is on the weekend. This function must be preceded by the .is() function. * Example

	Date.today().is().weekend(); // true|false
	
* * @return {Boolean} true|false */ $P.weekend = function () { if (this._is) { this._is = false; return (this.is().sat() || this.is().sun()); } return false; }; /** * Sets the Time of the current Date instance. A string "6:15 pm" or config object {hour:18, minute:15} are accepted. * Example

	// Set time to 6:15pm with a String
	Date.today().at("6:15pm");

	// Set time to 6:15pm with a config object
	Date.today().at({hour:18, minute:15});
	
* * @return {Date} date */ $P.at = function (time) { return (typeof time === "string") ? $D.parse(this.toString("d") + " " + time) : this.set(time); }; /** * Creates a new Date() and adds this (Number) to the date based on the preceding date element function (eg. second|minute|hour|day|month|year). * Example

	// Undeclared Numbers must be wrapped with parentheses. Requirment of JavaScript.
	(3).days().fromNow();
	(6).months().fromNow();

	// Declared Number variables do not require parentheses. 
	var n = 6;
	n.months().fromNow();
	
* * @return {Date} A new Date instance */ $N.fromNow = $N.after = function (date) { var c = {}; c[this._dateElement] = this; return ((!date) ? new Date() : date.clone()).add(c); }; /** * Creates a new Date() and subtract this (Number) from the date based on the preceding date element function (eg. second|minute|hour|day|month|year). * Example

	// Undeclared Numbers must be wrapped with parentheses. Requirment of JavaScript.
	(3).days().ago();
	(6).months().ago();

	// Declared Number variables do not require parentheses. 
	var n = 6;
	n.months().ago();
	
* * @return {Date} A new Date instance */ $N.ago = $N.before = function (date) { var c = {}, s = (this._dateElement[this._dateElement.length-1] !== "s") ? this._dateElement + "s" : this._dateElement; c[s] = this * -1; return ((!date) ? new Date() : date.clone()).add(c); }; // Do NOT modify the following string tokens. These tokens are used to build dynamic functions. // All culture-specific strings can be found in the CultureInfo files. var dx = ("sunday monday tuesday wednesday thursday friday saturday").split(/\s/), mx = ("january february march april may june july august september october november december").split(/\s/), px = ("Millisecond Second Minute Hour Day Week Month Year Quarter Weekday").split(/\s/), pxf = ("Milliseconds Seconds Minutes Hours Date Week Month FullYear Quarter").split(/\s/), nth = ("final first second third fourth fifth").split(/\s/), de; /** * Returns an object literal of all the date parts. * Example

	var o = new Date().toObject();
	
	// { year: 2008, month: 4, week: 20, day: 13, hour: 18, minute: 9, second: 32, millisecond: 812 }
	
	// The object properties can be referenced directly from the object.
	
	alert(o.day);  // alerts "13"
	alert(o.year); // alerts "2008"
	
* * @return {Date} An object literal representing the original date object. */ $P.toObject = function () { var o = {}; for (var i = 0; i < px.length; i++) { if (this["get" + pxf[i]]) { o[px[i].toLowerCase()] = this["get" + pxf[i]](); } } return o; }; /** * Returns a date created from an object literal. Ignores the .week property if set in the config. * Example

	var o = new Date().toObject();
	
	return Date.fromObject(o); // will return the same date. 

	var o2 = {month: 1, day: 20, hour: 18}; // birthday party!
	Date.fromObject(o2);
	
* * @return {Date} An object literal representing the original date object. */ $D.fromObject = function(config) { config.week = null; return Date.today().set(config); }; // Create day name functions and abbreviated day name functions (eg. monday(), friday(), fri()). var df = function (n) { return function () { if (this._is) { this._is = false; return this.getDay() === n; } if (this._move) { this._move = null; } if (this._nth !== null) { // If the .second() function was called earlier, remove the _orient // from the date, and then continue. // This is required because 'second' can be used in two different context. // // Example // // Date.today().add(1).second(); // Date.march().second().monday(); // // Things get crazy with the following... // Date.march().add(1).second().second().monday(); // but it works!! // if (this._isSecond) { this.addSeconds(this._orient * -1); } // make sure we reset _isSecond this._isSecond = false; var ntemp = this._nth; this._nth = null; var temp = this.clone().moveToLastDayOfMonth(); this.moveToNthOccurrence(n, ntemp); if (this > temp) { throw new RangeError($D.getDayName(n) + " does not occur " + ntemp + " times in the month of " + $D.getMonthName(temp.getMonth()) + " " + temp.getFullYear() + "."); } return this; } return this.moveToDayOfWeek(n, this._orient); }; }; var sdf = function (n) { return function () { var t = $D.today(), shift = n - t.getDay(); if (n === 0 && Date.CultureInfo.firstDayOfWeek === 1 && t.getDay() !== 0) { shift = shift + 7; } return t.addDays(shift); }; }; // Create month name functions and abbreviated month name functions (eg. january(), march(), mar()). var month_instance_functions = function (n) { return function () { if (this._is) { this._is = false; return this.getMonth() === n; } return this.moveToMonth(n, this._orient); }; }; var month_static_functions = function (n) { return function () { return $D.today().set({ month: n, day: 1 }); }; }; var processTerms = function (names, staticFunc, instanceFunc) { for (var i = 0; i < names.length; i++) { // Create constant static Name variables. $D[names[i].toUpperCase()] = $D[names[i].toUpperCase().substring(0, 3)] = i; // Create Name functions. $D[names[i]] = $D[names[i].substring(0, 3)] = staticFunc(i); // Create Name instance functions. $P[names[i]] = $P[names[i].substring(0, 3)] = instanceFunc(i); } }; processTerms(dx, sdf, df); processTerms(mx, month_static_functions, month_instance_functions); // Create date element functions and plural date element functions used with Date (eg. day(), days(), months()). var ef = function (j) { return function () { // if the .second() function was called earlier, the _orient // has alread been added. Just return this and reset _isSecond. if (this._isSecond) { this._isSecond = false; return this; } if (this._same) { this._same = this._is = false; var o1 = this.toObject(), o2 = (arguments[0] || new Date()).toObject(), v = "", k = j.toLowerCase(); // the substr trick with -1 doesn't work in IE8 or less k = (k[k.length-1] === "s") ? k.substring(0,k.length-1) : k; for (var m = (px.length - 1); m > -1; m--) { v = px[m].toLowerCase(); if (o1[v] !== o2[v]) { return false; } if (k === v) { break; } } return true; } if (j.substring(j.length - 1) !== "s") { j += "s"; } if (this._move) { this._move = null; } return this["add" + j](this._orient); }; }; var nf = function (n) { return function () { this._dateElement = n; return this; }; }; for (var k = 0; k < px.length; k++) { de = px[k].toLowerCase(); if(de !== "weekday") { // Create date element functions and plural date element functions used with Date (eg. day(), days(), months()). $P[de] = $P[de + "s"] = ef(px[k]); // Create date element functions and plural date element functions used with Number (eg. day(), days(), months()). $N[de] = $N[de + "s"] = nf(de + "s"); } } $P._ss = ef("Second"); var nthfn = function (n) { return function (dayOfWeek) { if (this._same) { return this._ss(arguments[0]); } if (dayOfWeek || dayOfWeek === 0) { return this.moveToNthOccurrence(dayOfWeek, n); } this._nth = n; // if the operator is 'second' add the _orient, then deal with it later... if (n === 2 && (dayOfWeek === undefined || dayOfWeek === null)) { this._isSecond = true; return this.addSeconds(this._orient); } return this; }; }; for (var l = 0; l < nth.length; l++) { $P[nth[l]] = (l === 0) ? nthfn(-1) : nthfn(l); } }()); (function () { "use strict"; Date.Parsing = { Exception: function (s) { this.message = "Parse error at '" + s.substring(0, 10) + " ...'"; } }; var $P = Date.Parsing; var dayOffsets = { standard: [0,31,59,90,120,151,181,212,243,273,304,334], leap: [0,31,60,91,121,152,182,213,244,274,305,335] }; $P.isLeapYear = function(year) { return ((year % 4 === 0) && (year % 100 !== 0)) || (year % 400 === 0); }; var utils = { multiReplace : function (str, hash ) { var key; for (key in hash) { if (Object.prototype.hasOwnProperty.call(hash, key)) { var regex; if (typeof hash[key] === "function") { } else { regex = (hash[key] instanceof RegExp) ? hash[key] : new RegExp(hash[key], "g"); } str = str.replace(regex, key); } } return str; }, getDayOfYearFromWeek : function (obj) { var d, jan4, offset; obj.weekDay = (!obj.weekDay && obj.weekDay !== 0) ? 1 : obj.weekDay; d = new Date(obj.year, 0, 4); jan4 = d.getDay() === 0 ? 7 : d.getDay(); // JS is 0 indexed on Sunday. offset = jan4+3; obj.dayOfYear = ((obj.week * 7) + (obj.weekDay === 0 ? 7 : obj.weekDay))-offset; return obj; }, getDayOfYear : function (obj, dayOffset) { if (!obj.dayOfYear) { obj = utils.getDayOfYearFromWeek(obj); } for (var i=0;i <= dayOffset.length;i++) { if (obj.dayOfYear < dayOffset[i] || i === dayOffset.length) { obj.day = obj.day ? obj.day : (obj.dayOfYear - dayOffset[i-1]); break; } else { obj.month = i; } } return obj; }, adjustForTimeZone : function (obj, date) { var offset; if (obj.zone.toUpperCase() === "Z" || (obj.zone_hours === 0 && obj.zone_minutes === 0)) { // it's UTC/GML so work out the current timeszone offset offset = -date.getTimezoneOffset(); } else { offset = (obj.zone_hours*60) + (obj.zone_minutes || 0); if (obj.zone_sign === "+") { offset *= -1; } offset -= date.getTimezoneOffset(); } date.setMinutes(date.getMinutes()+offset); return date; }, setDefaults : function (obj) { obj.year = obj.year || Date.today().getFullYear(); obj.hours = obj.hours || 0; obj.minutes = obj.minutes || 0; obj.seconds = obj.seconds || 0; obj.milliseconds = obj.milliseconds || 0; if (!(!obj.month && (obj.week || obj.dayOfYear))) { // if we have a month, or if we don't but don't have the day calculation data obj.month = obj.month || 0; obj.day = obj.day || 1; } return obj; }, dataNum: function (data, mod, explict, postProcess) { var dataNum = data*1; if (mod) { if (postProcess) { return data ? mod(data)*1 : data; } else { return data ? mod(dataNum) : data; } } else if (!explict){ return data ? dataNum : data; } else { return (data && typeof data !== "undefined") ? dataNum : data; } }, timeDataProcess: function (obj) { var timeObj = {}; for (var x in obj.data) { if (obj.data.hasOwnProperty(x)) { timeObj[x] = obj.ignore[x] ? obj.data[x] : utils.dataNum(obj.data[x], obj.mods[x], obj.explict[x], obj.postProcess[x]); } } if (obj.data.secmins) { obj.data.secmins = obj.data.secmins.replace(",", ".") * 60; if (!timeObj.minutes) { timeObj.minutes = obj.data.secmins; } else if (!timeObj.seconds) { timeObj.seconds = obj.data.secmins; } delete obj.secmins; } return timeObj; }, buildTimeObjectFromData: function (data) { var time = utils.timeDataProcess({ data: { year : data[1], month : data[5], day : data[7], week : data[8], dayOfYear : data[10], hours : data[15], zone_hours : data[23], zone_minutes : data[24], zone : data[21], zone_sign : data[22], weekDay : data[9], minutes: data[16], seconds: data[19], milliseconds: data[20], secmins: data[18] }, mods: { month: function(data) { return data-1; }, weekDay: function (data) { data = Math.abs(data); return (data === 7 ? 0 : data); }, minutes: function (data) { return data.replace(":",""); }, seconds: function (data) { return Math.floor( (data.replace(":","").replace(",","."))*1 ); }, milliseconds: function (data) { return (data.replace(",",".")*1000); } }, postProcess: { minutes: true, seconds: true, milliseconds: true }, explict: { zone_hours: true, zone_minutes: true }, ignore: { zone: true, zone_sign: true, secmins: true } }); return time; }, addToHash: function (hash, keys, data) { keys = keys; data = data; var len = keys.length; for (var i = 0; i < len; i++) { hash[keys[i]] = data[i]; } return hash; }, combineRegex: function (r1, r2) { return new RegExp("(("+r1.source+")\\s("+r2.source+"))"); }, getDateNthString: function(add, last, inc){ if (add) { return Date.today().addDays(inc).toString("d"); } else if (last) { return Date.today().last()[inc]().toString("d"); } }, buildRegexData: function (array) { var arr = []; var len = array.length; for (var i=0; i < len; i++) { if (Object.prototype.toString.call(array[i]) === '[object Array]') { // oldIE compat version of Array.isArray arr.push(this.combineRegex(array[i][0], array[i][1])); } else { arr.push(array[i]); } } return arr; } }; $P.processTimeObject = function (obj) { var date, dayOffset; utils.setDefaults(obj); dayOffset = ($P.isLeapYear(obj.year)) ? dayOffsets.leap : dayOffsets.standard; if (!obj.month && (obj.week || obj.dayOfYear)) { utils.getDayOfYear(obj, dayOffset); } else { obj.dayOfYear = dayOffset[obj.month] + obj.day; } date = new Date(obj.year, obj.month, obj.day, obj.hours, obj.minutes, obj.seconds, obj.milliseconds); if (obj.zone) { utils.adjustForTimeZone(obj, date); // adjust (and calculate) for timezone } return date; }; $P.ISO = { regex : /^([\+-]?\d{4}(?!\d{2}\b))((-?)((0[1-9]|1[0-2])(\3([12]\d|0[1-9]|3[01]))?|W([0-4]\d|5[0-3])(-?[1-7])?|(00[1-9]|0[1-9]\d|[12]\d{2}|3([0-5]\d|6[1-6])))([T\s]((([01]\d|2[0-4])((:?)[0-5]\d)?|24\:?00)([\.,]\d+(?!:))?)?(\17[0-5]\d([\.,]\d+)?)?\s?([zZ]|([\+-])([01]\d|2[0-3]):?([0-5]\d)?)?)?)?$/, parse : function (s) { var time, data = s.match(this.regex); if (!data || !data.length) { return null; } time = utils.buildTimeObjectFromData(data); if (!time.year || (!time.year && (!time.month && !time.day) && (!time.week && !time.dayOfYear)) ) { return null; } return $P.processTimeObject(time); } }; $P.Numeric = { isNumeric: function (e){return!isNaN(parseFloat(e))&&isFinite(e);}, regex: /\b([0-1]?[0-9])([0-3]?[0-9])([0-2]?[0-9]?[0-9][0-9])\b/i, parse: function (s) { var data, i, time = {}, order = Date.CultureInfo.dateElementOrder.split(""); if (!(this.isNumeric(s)) || // if it's non-numeric OR (s[0] === "+" && s[0] === "-")) { // It's an arithmatic string (eg +/-1000) return null; } if (s.length < 5 && s.indexOf(".") < 0 && s.indexOf("/") < 0) { // assume it's just a year. time.year = s; return $P.processTimeObject(time); } data = s.match(this.regex); if (!data || !data.length) { return null; } for (i=0; i < order.length; i++) { switch(order[i]) { case "d": time.day = data[i+1]; break; case "m": time.month = (data[i+1]-1); break; case "y": time.year = data[i+1]; break; } } return $P.processTimeObject(time); } }; $P.Normalizer = { regexData: function () { var $R = Date.CultureInfo.regexPatterns; return utils.buildRegexData([ $R.tomorrow, $R.yesterday, [$R.past, $R.mon], [$R.past, $R.tue], [$R.past, $R.wed], [$R.past, $R.thu], [$R.past, $R.fri], [$R.past, $R.sat], [$R.past, $R.sun] ]); }, basicReplaceHash : function() { var $R = Date.CultureInfo.regexPatterns; return { "January": $R.jan.source, "February": $R.feb, "March": $R.mar, "April": $R.apr, "May": $R.may, "June": $R.jun, "July": $R.jul, "August": $R.aug, "September": $R.sep, "October": $R.oct, "November": $R.nov, "December": $R.dec, "": /\bat\b/gi, " ": /\s{2,}/, "am": $R.inTheMorning, "9am": $R.thisMorning, "pm": $R.inTheEvening, "7pm":$R.thisEvening }; }, keys : function(){ return [ utils.getDateNthString(true, false, 1), // tomorrow utils.getDateNthString(true, false, -1), // yesterday utils.getDateNthString(false, true, "monday"), //last mon utils.getDateNthString(false, true, "tuesday"), //last tues utils.getDateNthString(false, true, "wednesday"), //last wed utils.getDateNthString(false, true, "thursday"), //last thurs utils.getDateNthString(false, true, "friday"), //last fri utils.getDateNthString(false, true, "saturday"), //last sat utils.getDateNthString(false, true, "sunday") //last sun ]; }, buildRegexFunctions: function () { var $R = Date.CultureInfo.regexPatterns; var __ = Date.i18n.__; var tomorrowRE = new RegExp("(\\b\\d\\d?("+__("AM")+"|"+__("PM")+")? )("+$R.tomorrow.source.slice(1)+")", "i"); // adapted tomorrow regex for AM PM relative dates var todayRE = new RegExp($R.today.source + "(?!\\s*([+-]))\\b"); // today, but excludes the math operators (eg "today + 2h") this.replaceFuncs = [ [todayRE, function (full) { return (full.length > 1) ? Date.today().toString("d") : full; }], [tomorrowRE, function(full, m1) { var t = Date.today().addDays(1).toString("d"); return (t + " " + m1); }], [$R.amThisMorning, function(str, am){return am;}], [$R.pmThisEvening, function(str, pm){return pm;}] ]; }, buildReplaceData: function () { this.buildRegexFunctions(); this.replaceHash = utils.addToHash(this.basicReplaceHash(), this.keys(), this.regexData()); }, stringReplaceFuncs: function (s) { for (var i=0; i < this.replaceFuncs.length; i++) { s = s.replace(this.replaceFuncs[i][0], this.replaceFuncs[i][1]); } return s; }, parse: function (s) { s = this.stringReplaceFuncs(s); s = utils.multiReplace(s, this.replaceHash); try { var n = s.split(/([\s\-\.\,\/\x27]+)/); if (n.length === 3 && $P.Numeric.isNumeric(n[0]) && $P.Numeric.isNumeric(n[2]) && (n[2].length >= 4)) { // ok, so we're dealing with x/year. But that's not a full date. // This fixes wonky dateElementOrder parsing when set to dmy order. if (Date.CultureInfo.dateElementOrder[0] === "d") { s = "1/" + n[0] + "/" + n[2]; // set to 1st of month and normalize the seperator } } } catch (e) {} return s; } }; $P.Normalizer.buildReplaceData(); }()); (function () { var $P = Date.Parsing; var _ = $P.Operators = { // // Tokenizers // rtoken: function (r) { // regex token return function (s) { var mx = s.match(r); if (mx) { return ([ mx[0], s.substring(mx[0].length) ]); } else { throw new $P.Exception(s); } }; }, token: function () { // whitespace-eating token return function (s) { return _.rtoken(new RegExp("^\\s*" + s + "\\s*"))(s); }; }, stoken: function (s) { // string token return _.rtoken(new RegExp("^" + s)); }, // Atomic Operators until: function (p) { return function (s) { var qx = [], rx = null; while (s.length) { try { rx = p.call(this, s); } catch (e) { qx.push(rx[0]); s = rx[1]; continue; } break; } return [ qx, s ]; }; }, many: function (p) { return function (s) { var rx = [], r = null; while (s.length) { try { r = p.call(this, s); } catch (e) { return [ rx, s ]; } rx.push(r[0]); s = r[1]; } return [ rx, s ]; }; }, // generator operators -- see below optional: function (p) { return function (s) { var r = null; try { r = p.call(this, s); } catch (e) { return [ null, s ]; } return [ r[0], r[1] ]; }; }, not: function (p) { return function (s) { try { p.call(this, s); } catch (e) { return [null, s]; } throw new $P.Exception(s); }; }, ignore: function (p) { return p ? function (s) { var r = null; r = p.call(this, s); return [null, r[1]]; } : null; }, product: function () { var px = arguments[0], qx = Array.prototype.slice.call(arguments, 1), rx = []; for (var i = 0 ; i < px.length ; i++) { rx.push(_.each(px[i], qx)); } return rx; }, cache: function (rule) { var cache = {}, cache_length = 0, cache_keys = [], CACHE_MAX = Date.Config.CACHE_MAX || 100000, r = null; var cacheCheck = function () { if (cache_length === CACHE_MAX) { // kill several keys, don't want to have to do this all the time... for (var i=0; i < 10; i++) { var key = cache_keys.shift(); if (key) { delete cache[key]; cache_length--; } } } }; return function (s) { cacheCheck(); try { r = cache[s] = (cache[s] || rule.call(this, s)); } catch (e) { r = cache[s] = e; } cache_length++; cache_keys.push(s); if (r instanceof $P.Exception) { throw r; } else { return r; } }; }, // vector operators -- see below any: function () { var px = arguments; return function (s) { var r = null; for (var i = 0; i < px.length; i++) { if (px[i] == null) { continue; } try { r = (px[i].call(this, s)); } catch (e) { r = null; } if (r) { return r; } } throw new $P.Exception(s); }; }, each: function () { var px = arguments; return function (s) { var rx = [], r = null; for (var i = 0; i < px.length ; i++) { if (px[i] == null) { continue; } try { r = (px[i].call(this, s)); } catch (e) { throw new $P.Exception(s); } rx.push(r[0]); s = r[1]; } return [ rx, s]; }; }, all: function () { var px = arguments, _ = _; return _.each(_.optional(px)); }, // delimited operators sequence: function (px, d, c) { d = d || _.rtoken(/^\s*/); c = c || null; if (px.length === 1) { return px[0]; } return function (s) { var r = null, q = null; var rx = []; for (var i = 0; i < px.length ; i++) { try { r = px[i].call(this, s); } catch (e) { break; } rx.push(r[0]); try { q = d.call(this, r[1]); } catch (ex) { q = null; break; } s = q[1]; } if (!r) { throw new $P.Exception(s); } if (q) { throw new $P.Exception(q[1]); } if (c) { try { r = c.call(this, r[1]); } catch (ey) { throw new $P.Exception(r[1]); } } return [ rx, (r?r[1]:s) ]; }; }, // // Composite Operators // between: function (d1, p, d2) { d2 = d2 || d1; var _fn = _.each(_.ignore(d1), p, _.ignore(d2)); return function (s) { var rx = _fn.call(this, s); return [[rx[0][0], r[0][2]], rx[1]]; }; }, list: function (p, d, c) { d = d || _.rtoken(/^\s*/); c = c || null; return (p instanceof Array ? _.each(_.product(p.slice(0, -1), _.ignore(d)), p.slice(-1), _.ignore(c)) : _.each(_.many(_.each(p, _.ignore(d))), px, _.ignore(c))); }, set: function (px, d, c) { d = d || _.rtoken(/^\s*/); c = c || null; return function (s) { // r is the current match, best the current 'best' match // which means it parsed the most amount of input var r = null, p = null, q = null, rx = null, best = [[], s], last = false; // go through the rules in the given set for (var i = 0; i < px.length ; i++) { // last is a flag indicating whether this must be the last element // if there is only 1 element, then it MUST be the last one q = null; p = null; r = null; last = (px.length === 1); // first, we try simply to match the current pattern // if not, try the next pattern try { r = px[i].call(this, s); } catch (e) { continue; } // since we are matching against a set of elements, the first // thing to do is to add r[0] to matched elements rx = [[r[0]], r[1]]; // if we matched and there is still input to parse and // we don't already know this is the last element, // we're going to next check for the delimiter ... // if there's none, or if there's no input left to parse // than this must be the last element after all ... if (r[1].length > 0 && ! last) { try { q = d.call(this, r[1]); } catch (ex) { last = true; } } else { last = true; } // if we parsed the delimiter and now there's no more input, // that means we shouldn't have parsed the delimiter at all // so don't update r and mark this as the last element ... if (!last && q[1].length === 0) { last = true; } // so, if this isn't the last element, we're going to see if // we can get any more matches from the remaining (unmatched) // elements ... if (!last) { // build a list of the remaining rules we can match against, // i.e., all but the one we just matched against var qx = []; for (var j = 0; j < px.length ; j++) { if (i !== j) { qx.push(px[j]); } } // now invoke recursively set with the remaining input // note that we don't include the closing delimiter ... // we'll check for that ourselves at the end p = _.set(qx, d).call(this, q[1]); // if we got a non-empty set as a result ... // (otw rx already contains everything we want to match) if (p[0].length > 0) { // update current result, which is stored in rx ... // basically, pick up the remaining text from p[1] // and concat the result from p[0] so that we don't // get endless nesting ... rx[0] = rx[0].concat(p[0]); rx[1] = p[1]; } } // at this point, rx either contains the last matched element // or the entire matched set that starts with this element. // now we just check to see if this variation is better than // our best so far, in terms of how much of the input is parsed if (rx[1].length < best[1].length) { best = rx; } // if we've parsed all the input, then we're finished if (best[1].length === 0) { break; } } // so now we've either gone through all the patterns trying them // as the initial match; or we found one that parsed the entire // input string ... // if best has no matches, just return empty set ... if (best[0].length === 0) { return best; } // if a closing delimiter is provided, then we have to check it also if (c) { // we try this even if there is no remaining input because the pattern // may well be optional or match empty input ... try { q = c.call(this, best[1]); } catch (ey) { throw new $P.Exception(best[1]); } // it parsed ... be sure to update the best match remaining input best[1] = q[1]; } // if we're here, either there was no closing delimiter or we parsed it // so now we have the best match; just return it! return best; }; }, forward: function (gr, fname) { return function (s) { return gr[fname].call(this, s); }; }, // // Translation Operators // replace: function (rule, repl) { return function (s) { var r = rule.call(this, s); return [repl, r[1]]; }; }, process: function (rule, fn) { return function (s) { var r = rule.call(this, s); return [fn.call(this, r[0]), r[1]]; }; }, min: function (min, rule) { return function (s) { var rx = rule.call(this, s); if (rx[0].length < min) { throw new $P.Exception(s); } return rx; }; } }; // Generator Operators And Vector Operators // Generators are operators that have a signature of F(R) => R, // taking a given rule and returning another rule, such as // ignore, which parses a given rule and throws away the result. // Vector operators are those that have a signature of F(R1,R2,...) => R, // take a list of rules and returning a new rule, such as each. // Generator operators are converted (via the following _generator // function) into functions that can also take a list or array of rules // and return an array of new rules as though the function had been // called on each rule in turn (which is what actually happens). // This allows generators to be used with vector operators more easily. // Example: // each(ignore(foo, bar)) instead of each(ignore(foo), ignore(bar)) // This also turns generators into vector operators, which allows // constructs like: // not(cache(foo, bar)) var _generator = function (op) { function gen() { var args = null, rx = [], px, i; if (arguments.length > 1) { args = Array.prototype.slice.call(arguments); } else if (arguments[0] instanceof Array) { args = arguments[0]; } if (args) { px = args.shift(); if (px.length > 0) { args.unshift(px[i]); rx.push(op.apply(null, args)); args.shift(); return rx; } } else { return op.apply(null, arguments); } } return gen; }; var gx = "optional not ignore cache".split(/\s/); for (var i = 0 ; i < gx.length ; i++) { _[gx[i]] = _generator(_[gx[i]]); } var _vector = function (op) { return function () { if (arguments[0] instanceof Array) { return op.apply(null, arguments[0]); } else { return op.apply(null, arguments); } }; }; var vx = "each any all".split(/\s/); for (var j = 0 ; j < vx.length ; j++) { _[vx[j]] = _vector(_[vx[j]]); } }()); (function () { var $D = Date; var flattenAndCompact = function (ax) { var rx = []; for (var i = 0; i < ax.length; i++) { if (ax[i] instanceof Array) { rx = rx.concat(flattenAndCompact(ax[i])); } else { if (ax[i]) { rx.push(ax[i]); } } } return rx; }; var parseMeridian = function () { if (this.meridian && (this.hour || this.hour === 0)) { if (this.meridian === "a" && this.hour > 11 && Date.Config.strict24hr){ throw "Invalid hour and meridian combination"; } else if (this.meridian === "p" && this.hour < 12 && Date.Config.strict24hr){ throw "Invalid hour and meridian combination"; } else if (this.meridian === "p" && this.hour < 12) { this.hour = this.hour + 12; } else if (this.meridian === "a" && this.hour === 12) { this.hour = 0; } } }; var setDefaults = function () { var now = new Date(); if ((this.hour || this.minute) && (!this.month && !this.year && !this.day)) { this.day = now.getDate(); } if (!this.year) { this.year = now.getFullYear(); } if (!this.month && this.month !== 0) { this.month = now.getMonth(); } if (!this.day) { this.day = 1; } if (!this.hour) { this.hour = 0; } if (!this.minute) { this.minute = 0; } if (!this.second) { this.second = 0; } if (!this.millisecond) { this.millisecond = 0; } }; var finishUtils = { getToday: function () { if (this.now || "hour minute second".indexOf(this.unit) !== -1) { return new Date(); } else { return $D.today(); } }, setDaysFromWeekday: function (today, orient){ var gap; orient = orient || 1; this.unit = "day"; gap = ($D.getDayNumberFromName(this.weekday) - today.getDay()); this.days = gap ? ((gap + (orient * 7)) % 7) : (orient * 7); return this; }, setMonthsFromMonth: function (today, orient) { var gap; orient = orient || 1; this.unit = "month"; gap = (this.month - today.getMonth()); this.months = gap ? ((gap + (orient * 12)) % 12) : (orient * 12); this.month = null; return this; }, setDMYFromWeekday: function () { var d = Date[this.weekday](); this.day = d.getDate(); if (!this.month) { this.month = d.getMonth(); } this.year = d.getFullYear(); return this; }, setUnitValue: function (orient) { if (!this.value && this.operator && this.operator !== null && this[this.unit + "s"] && this[this.unit + "s"] !== null) { this[this.unit + "s"] = this[this.unit + "s"] + ((this.operator === "add") ? 1 : -1) + (this.value||0) * orient; } else if (this[this.unit + "s"] == null || this.operator != null) { if (!this.value) { this.value = 1; } this[this.unit + "s"] = this.value * orient; } }, generateDateFromWeeks: function () { var weekday = (this.weekday !== undefined) ? this.weekday : "today"; var d = Date[weekday]().addWeeks(this.weeks); if (this.now) { d.setTimeToNow(); } return d; } }; $D.Translator = { hour: function (s) { return function () { this.hour = Number(s); }; }, minute: function (s) { return function () { this.minute = Number(s); }; }, second: function (s) { return function () { this.second = Number(s); }; }, /* for ss.s format */ secondAndMillisecond: function (s) { return function () { var mx = s.match(/^([0-5][0-9])\.([0-9]{1,3})/); this.second = Number(mx[1]); this.millisecond = Number(mx[2]); }; }, meridian: function (s) { return function () { this.meridian = s.slice(0, 1).toLowerCase(); }; }, timezone: function (s) { return function () { var n = s.replace(/[^\d\+\-]/g, ""); if (n.length) { this.timezoneOffset = Number(n); } else { this.timezone = s.toLowerCase(); } }; }, day: function (x) { var s = x[0]; return function () { this.day = Number(s.match(/\d+/)[0]); if (this.day < 1) { throw "invalid day"; } }; }, month: function (s) { return function () { this.month = (s.length === 3) ? "jan feb mar apr may jun jul aug sep oct nov dec".indexOf(s)/4 : Number(s) - 1; if (this.month < 0) { throw "invalid month"; } }; }, year: function (s) { return function () { var n = Number(s); this.year = ((s.length > 2) ? n : (n + (((n + 2000) < Date.CultureInfo.twoDigitYearMax) ? 2000 : 1900))); }; }, rday: function (s) { return function () { switch (s) { case "yesterday": this.days = -1; break; case "tomorrow": this.days = 1; break; case "today": this.days = 0; break; case "now": this.days = 0; this.now = true; break; } }; }, finishExact: function (x) { var d; x = (x instanceof Array) ? x : [x]; for (var i = 0 ; i < x.length ; i++) { if (x[i]) { x[i].call(this); } } setDefaults.call(this); parseMeridian.call(this); if (this.day > $D.getDaysInMonth(this.year, this.month)) { throw new RangeError(this.day + " is not a valid value for days."); } d = new Date(this.year, this.month, this.day, this.hour, this.minute, this.second, this.millisecond); if (this.year < 100) { d.setFullYear(this.year); // means years less that 100 are process correctly. JS will parse it otherwise as 1900-1999. } if (this.timezone) { d.set({ timezone: this.timezone }); } else if (this.timezoneOffset) { d.set({ timezoneOffset: this.timezoneOffset }); } return d; }, finish: function (x) { var today, expression, orient, temp; x = (x instanceof Array) ? flattenAndCompact(x) : [ x ]; if (x.length === 0) { return null; } for (var i = 0 ; i < x.length ; i++) { if (typeof x[i] === "function") { x[i].call(this); } } if (this.now && !this.unit && !this.operator) { return new Date(); } else { today = finishUtils.getToday.call(this); } expression = !!(this.days && this.days !== null || this.orient || this.operator); orient = ((this.orient === "past" || this.operator === "subtract") ? -1 : 1); if (this.month && this.unit === "week") { this.value = this.month + 1; delete this.month; delete this.day; } if ((this.month || this.month === 0) && "year day hour minute second".indexOf(this.unit) !== -1) { if (!this.value) { this.value = this.month + 1; } this.month = null; expression = true; } if (!expression && this.weekday && !this.day && !this.days) { finishUtils.setDMYFromWeekday.call(this); } if (expression && this.weekday && this.unit !== "month" && this.unit !== "week") { finishUtils.setDaysFromWeekday.call(this, today, orient); } if (this.weekday && this.unit !== "week" && !this.day && !this.days) { temp = Date[this.weekday](); this.day = temp.getDate(); if (temp.getMonth() !== today.getMonth()) { this.month = temp.getMonth(); } } if (this.month && this.unit === "day" && this.operator) { if (!this.value) { this.value = (this.month + 1); } this.month = null; } if (this.value != null && this.month != null && this.year != null) { this.day = this.value * 1; } if (this.month && !this.day && this.value) { today.set({ day: this.value * 1 }); if (!expression) { this.day = this.value * 1; } } if (!this.month && this.value && this.unit === "month" && !this.now) { this.month = this.value; expression = true; } if (expression && (this.month || this.month === 0) && this.unit !== "year") { finishUtils.setMonthsFromMonth.call(this, today, orient); } if (!this.unit) { this.unit = "day"; } finishUtils.setUnitValue.call(this, orient); parseMeridian.call(this); if ((this.month || this.month === 0) && !this.day) { this.day = 1; } if (!this.orient && !this.operator && this.unit === "week" && this.value && !this.day && !this.month) { return Date.today().setWeek(this.value); } if (this.unit === "week" && this.weeks && !this.day && !this.month) { return finishUtils.generateDateFromWeeks.call(this); } if (expression && this.timezone && this.day && this.days) { this.day = this.days; } if (expression){ today.add(this); } else { today.set(this); } if (this.timezone) { this.timezone = this.timezone.toUpperCase(); var offset = $D.getTimezoneOffset(this.timezone); var timezone; if (today.hasDaylightSavingTime()) { // lets check that we're being sane with timezone setting timezone = $D.getTimezoneAbbreviation(offset, today.isDaylightSavingTime()); if (timezone !== this.timezone) { // bugger, we're in a place where things like EST vs EDT matters. if (today.isDaylightSavingTime()) { today.addHours(-1); } else { today.addHours(1); } } } today.setTimezoneOffset(offset); } return today; } }; }()); (function () { var $D = Date; $D.Grammar = {}; var _ = $D.Parsing.Operators, g = $D.Grammar, t = $D.Translator, _fn; // Allow rolling up into general purpose rules _fn = function () { return _.each(_.any.apply(null, arguments), _.not(g.ctoken2("timeContext"))); }; g.datePartDelimiter = _.rtoken(/^([\s\-\.\,\/\x27]+)/); g.timePartDelimiter = _.stoken(":"); g.whiteSpace = _.rtoken(/^\s*/); g.generalDelimiter = _.rtoken(/^(([\s\,]|at|@|on)+)/); var _C = {}; g.ctoken = function (keys) { var fn = _C[keys]; if (! fn) { var c = Date.CultureInfo.regexPatterns; var kx = keys.split(/\s+/), px = []; for (var i = 0; i < kx.length ; i++) { px.push(_.replace(_.rtoken(c[kx[i]]), kx[i])); } fn = _C[keys] = _.any.apply(null, px); } return fn; }; g.ctoken2 = function (key) { return _.rtoken(Date.CultureInfo.regexPatterns[key]); }; var cacheProcessRtoken = function (key, token, type, eachToken) { if (eachToken) { g[key] = _.cache(_.process(_.each(_.rtoken(token),_.optional(g.ctoken2(eachToken))), type)); } else { g[key] = _.cache(_.process(_.rtoken(token), type)); } }; var cacheProcessCtoken = function (token, type) { return _.cache(_.process(g.ctoken2(token), type)); }; var _F = {}; //function cache var _get = function (f) { _F[f] = (_F[f] || g.format(f)[0]); return _F[f]; }; g.allformats = function (fx) { var rx = []; if (fx instanceof Array) { for (var i = 0; i < fx.length; i++) { rx.push(_get(fx[i])); } } else { rx.push(_get(fx)); } return rx; }; g.formats = function (fx) { if (fx instanceof Array) { var rx = []; for (var i = 0 ; i < fx.length ; i++) { rx.push(_get(fx[i])); } return _.any.apply(null, rx); } else { return _get(fx); } }; var grammarFormats = { timeFormats: function(){ var i, RTokenKeys = [ "h", "hh", "H", "HH", "m", "mm", "s", "ss", "ss.s", "z", "zz" ], RToken = [ /^(0[0-9]|1[0-2]|[1-9])/, /^(0[0-9]|1[0-2])/, /^([0-1][0-9]|2[0-3]|[0-9])/, /^([0-1][0-9]|2[0-3])/, /^([0-5][0-9]|[0-9])/, /^[0-5][0-9]/, /^([0-5][0-9]|[0-9])/, /^[0-5][0-9]/, /^[0-5][0-9]\.[0-9]{1,3}/, /^((\+|\-)\s*\d\d\d\d)|((\+|\-)\d\d\:?\d\d)/, /^((\+|\-)\s*\d\d\d\d)|((\+|\-)\d\d\:?\d\d)/ ], tokens = [ t.hour, t.hour, t.hour, t.hour, t.minute, t.minute, t.second, t.second, t.secondAndMillisecond, t.timezone, t.timezone ]; for (i=0; i < RTokenKeys.length; i++) { cacheProcessRtoken(RTokenKeys[i], RToken[i], tokens[i]); } g.hms = _.cache(_.sequence([g.H, g.m, g.s], g.timePartDelimiter)); g.t = cacheProcessCtoken("shortMeridian", t.meridian); g.tt = cacheProcessCtoken("longMeridian", t.meridian); g.zzz = cacheProcessCtoken("timezone", t.timezone); g.timeSuffix = _.each(_.ignore(g.whiteSpace), _.set([ g.tt, g.zzz ])); g.time = _.each(_.optional(_.ignore(_.stoken("T"))), g.hms, g.timeSuffix); }, dateFormats: function () { // pre-loaded rules for different date part order preferences var _setfn = function () { return _.set(arguments, g.datePartDelimiter); }; var i, RTokenKeys = [ "d", "dd", "M", "MM", "y", "yy", "yyy", "yyyy" ], RToken = [ /^([0-2]\d|3[0-1]|\d)/, /^([0-2]\d|3[0-1])/, /^(1[0-2]|0\d|\d)/, /^(1[0-2]|0\d)/, /^(\d+)/, /^(\d\d)/, /^(\d\d?\d?\d?)/, /^(\d\d\d\d)/ ], tokens = [ t.day, t.day, t.month, t.month, t.year, t.year, t.year, t.year ], eachToken = [ "ordinalSuffix", "ordinalSuffix" ]; for (i=0; i < RTokenKeys.length; i++) { cacheProcessRtoken(RTokenKeys[i], RToken[i], tokens[i], eachToken[i]); } g.MMM = g.MMMM = _.cache(_.process(g.ctoken("jan feb mar apr may jun jul aug sep oct nov dec"), t.month)); g.ddd = g.dddd = _.cache(_.process(g.ctoken("sun mon tue wed thu fri sat"), function (s) { return function () { this.weekday = s; }; } )); g.day = _fn(g.d, g.dd); g.month = _fn(g.M, g.MMM); g.year = _fn(g.yyyy, g.yy); g.mdy = _setfn(g.ddd, g.month, g.day, g.year); g.ymd = _setfn(g.ddd, g.year, g.month, g.day); g.dmy = _setfn(g.ddd, g.day, g.month, g.year); g.date = function (s) { return ((g[Date.CultureInfo.dateElementOrder] || g.mdy).call(this, s)); }; }, relative: function () { // relative date / time expressions g.orientation = _.process(g.ctoken("past future"), function (s) { return function () { this.orient = s; }; } ); g.operator = _.process(g.ctoken("add subtract"), function (s) { return function () { this.operator = s; }; } ); g.rday = _.process(g.ctoken("yesterday tomorrow today now"), t.rday); g.unit = _.process(g.ctoken("second minute hour day week month year"), function (s) { return function () { this.unit = s; }; } ); } }; g.buildGrammarFormats = function () { // these need to be rebuilt every time the language changes. _C = {}; grammarFormats.timeFormats(); grammarFormats.dateFormats(); grammarFormats.relative(); g.value = _.process(_.rtoken(/^([-+]?\d+)?(st|nd|rd|th)?/), function (s) { return function () { this.value = s.replace(/\D/g, ""); }; } ); g.expression = _.set([g.rday, g.operator, g.value, g.unit, g.orientation, g.ddd, g.MMM ]); g.format = _.process(_.many( _.any( // translate format specifiers into grammar rules _.process( _.rtoken(/^(dd?d?d?(?!e)|MM?M?M?|yy?y?y?|hh?|HH?|mm?|ss?|tt?|zz?z?)/), function (fmt) { if (g[fmt]) { return g[fmt]; } else { throw $D.Parsing.Exception(fmt); } } ), // translate separator tokens into token rules _.process(_.rtoken(/^[^dMyhHmstz]+/), // all legal separators function (s) { return _.ignore(_.stoken(s)); } ) ) ), // construct the parser ... function (rules) { return _.process(_.each.apply(null, rules), t.finishExact); } ); // starting rule for general purpose grammar g._start = _.process(_.set([ g.date, g.time, g.expression ], g.generalDelimiter, g.whiteSpace), t.finish); }; g.buildGrammarFormats(); // parsing date format specifiers - ex: "h:m:s tt" // this little guy will generate a custom parser based // on the format string, ex: g.format("h:m:s tt") // check for these formats first g._formats = g.formats([ "\"yyyy-MM-ddTHH:mm:ssZ\"", "yyyy-MM-ddTHH:mm:ss.sz", "yyyy-MM-ddTHH:mm:ssZ", "yyyy-MM-ddTHH:mm:ssz", "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-ddTHH:mmZ", "yyyy-MM-ddTHH:mmz", "yyyy-MM-ddTHH:mm", "ddd, MMM dd, yyyy H:mm:ss tt", "ddd MMM d yyyy HH:mm:ss zzz", "MMddyyyy", "ddMMyyyy", "Mddyyyy", "ddMyyyy", "Mdyyyy", "dMyyyy", "yyyy", "Mdyy", "dMyy", "d" ]); // real starting rule: tries selected formats first, // then general purpose rule g.start = function (s) { try { var r = g._formats.call({}, s); if (r[1].length === 0) { return r; } } catch (e) {} return g._start.call({}, s); }; }()); (function () { var $D = Date; /** * @desc Converts the specified string value into its JavaScript Date equivalent using CultureInfo specific format information. * * Example

	///////////
	// Dates //
	///////////

	// 15-Oct-2004
	var d1 = Date.parse("10/15/2004");

	// 15-Oct-2004
	var d1 = Date.parse("15-Oct-2004");

	// 15-Oct-2004
	var d1 = Date.parse("2004.10.15");

	//Fri Oct 15, 2004
	var d1 = Date.parse("Fri Oct 15, 2004");

	///////////
	// Times //
	///////////

	// Today at 10 PM.
	var d1 = Date.parse("10 PM");

	// Today at 10:30 PM.
	var d1 = Date.parse("10:30 P.M.");

	// Today at 6 AM.
	var d1 = Date.parse("06am");

	/////////////////////
	// Dates and Times //
	/////////////////////

	// 8-July-2004 @ 10:30 PM
	var d1 = Date.parse("July 8th, 2004, 10:30 PM");

	// 1-July-2004 @ 10:30 PM
	var d1 = Date.parse("2004-07-01T22:30:00");

	////////////////////
	// Relative Dates //
	////////////////////

	// Returns today's date. The string "today" is culture specific.
	var d1 = Date.parse("today");

	// Returns yesterday's date. The string "yesterday" is culture specific.
	var d1 = Date.parse("yesterday");

	// Returns the date of the next thursday.
	var d1 = Date.parse("Next thursday");

	// Returns the date of the most previous monday.
	var d1 = Date.parse("last monday");

	// Returns today's day + one year.
	var d1 = Date.parse("next year");

	///////////////
	// Date Math //
	///////////////

	// Today + 2 days
	var d1 = Date.parse("t+2");

	// Today + 2 days
	var d1 = Date.parse("today + 2 days");

	// Today + 3 months
	var d1 = Date.parse("t+3m");

	// Today - 1 year
	var d1 = Date.parse("today - 1 year");

	// Today - 1 year
	var d1 = Date.parse("t-1y"); 


	/////////////////////////////
	// Partial Dates and Times //
	/////////////////////////////

	// July 15th of this year.
	var d1 = Date.parse("July 15");

	// 15th day of current day and year.
	var d1 = Date.parse("15");

	// July 1st of current year at 10pm.
	var d1 = Date.parse("7/1 10pm");
	
* * @param {String} The string value to convert into a Date object [Required] * @return {Date} A Date object or null if the string cannot be converted into a Date. */ var parseUtils = { removeOrds: function (s) { ords = s.match(/\b(\d+)(?:st|nd|rd|th)\b/); // find ordinal matches s = ((ords && ords.length === 2) ? s.replace(ords[0], ords[1]) : s); return s; }, grammarParser: function (s) { var r = null; try { r = $D.Grammar.start.call({}, s.replace(/^\s*(\S*(\s+\S+)*)\s*$/, "$1")); } catch (e) { return null; } return ((r[1].length === 0) ? r[0] : null); }, nativeFallback: function(s) { var t; try { // ok we haven't parsed it, last ditch attempt with the built-in parser. t = Date._parse(s); return (t || t === 0) ? new Date(t) : null; } catch (e) { return null; } } }; function parse (s) { var d; if (!s) { return null; } if (s instanceof Date) { return s.clone(); } if (s.length >= 4 && s.charAt(0) !== "0" && s.charAt(0) !== "+"&& s.charAt(0) !== "-") { // ie: 2004 will pass, 0800 won't. // Start with specific formats d = $D.Parsing.ISO.parse(s) || $D.Parsing.Numeric.parse(s); } if (d instanceof Date && !isNaN(d.getTime())) { return d; } else { // find ordinal dates (1st, 3rd, 8th, etc and remove them as they cause parsing issues) s = $D.Parsing.Normalizer.parse(parseUtils.removeOrds(s)); d = parseUtils.grammarParser(s); if (d !== null) { return d; } else { return parseUtils.nativeFallback(s); } } } if (!$D._parse) { $D._parse = $D.parse; } $D.parse = parse; Date.getParseFunction = function (fx) { var fns = Date.Grammar.allformats(fx); return function (s) { var r = null; for (var i = 0; i < fns.length; i++) { try { r = fns[i].call({}, s); } catch (e) { continue; } if (r[1].length === 0) { return r[0]; } } return null; }; }; /** * Converts the specified string value into its JavaScript Date equivalent using the specified format {String} or formats {Array} and the CultureInfo specific format information. * The format of the string value must match one of the supplied formats exactly. * * Example

	// 15-Oct-2004
	var d1 = Date.parseExact("10/15/2004", "M/d/yyyy");

	// 15-Oct-2004
	var d1 = Date.parse("15-Oct-2004", "M-ddd-yyyy");

	// 15-Oct-2004
	var d1 = Date.parse("2004.10.15", "yyyy.MM.dd");

	// Multiple formats
	var d1 = Date.parseExact("10/15/2004", ["M/d/yyyy", "MMMM d, yyyy"]);
	
* * @param {String} The string value to convert into a Date object [Required]. * @param {Object} The expected format {String} or an array of expected formats {Array} of the date string [Required]. * @return {Date} A Date object or null if the string cannot be converted into a Date. */ $D.parseExact = function (s, fx) { return $D.getParseFunction(fx)(s); }; }()); (function () { var $D = Date, $P = $D.prototype, // $C = $D.CultureInfo, // not used atm p = function (s, l) { if (!l) { l = 2; } return ("000" + s).slice(l * -1); }; /** * Converts a PHP format string to Java/.NET format string. * A PHP format string can be used with ._format or .format. * A Java/.NET format string can be used with .toString(). * The .parseExact function will only accept a Java/.NET format string * * Example * var f1 = "%m/%d/%y" * var f2 = Date.normalizeFormat(f1); // "MM/dd/yy" * * new Date().format(f1); // "04/13/08" * new Date()._format(f1); // "04/13/08" * new Date().toString(f2); // "04/13/08" * * var date = Date.parseExact("04/13/08", f2); // Sun Apr 13 2008 * * @param {String} A PHP format string consisting of one or more format spcifiers. * @return {String} The PHP format converted to a Java/.NET format string. */ var normalizerSubstitutions = { "d" : "dd", "%d": "dd", "D" : "ddd", "%a": "ddd", "j" : "dddd", "l" : "dddd", "%A": "dddd", "S" : "S", "F" : "MMMM", "%B": "MMMM", "m" : "MM", "%m": "MM", "M" : "MMM", "%b": "MMM", "%h": "MMM", "n" : "M", "Y" : "yyyy", "%Y": "yyyy", "y" : "yy", "%y": "yy", "g" : "h", "%I": "h", "G" : "H", "h" : "hh", "H" : "HH", "%H": "HH", "i" : "mm", "%M": "mm", "s" : "ss", "%S": "ss", "%r": "hh:mm tt", "%R": "H:mm", "%T": "H:mm:ss", "%X": "t", "%x": "d", "%e": "d", "%D": "MM/dd/yy", "%n": "\\n", "%t": "\\t", "e" : "z", "T" : "z", "%z": "z", "%Z": "z", "Z" : "ZZ", "N" : "u", "w" : "u", "%w": "u", "W" : "W", "%V": "W" }; var normalizer = { substitutes: function (m) { return normalizerSubstitutions[m]; }, interpreted: function (m, x) { var y; switch (m) { case "%u": return x.getDay() + 1; case "z": return x.getOrdinalNumber(); case "%j": return p(x.getOrdinalNumber(), 3); case "%U": var d1 = x.clone().set({month: 0, day: 1}).addDays(-1).moveToDayOfWeek(0), d2 = x.clone().addDays(1).moveToDayOfWeek(0, -1); return (d2 < d1) ? "00" : p((d2.getOrdinalNumber() - d1.getOrdinalNumber()) / 7 + 1); case "%W": return p(x.getWeek()); case "t": return $D.getDaysInMonth(x.getFullYear(), x.getMonth()); case "o": case "%G": return x.setWeek(x.getISOWeek()).toString("yyyy"); case "%g": return x._format("%G").slice(-2); case "a": case "%p": return t("tt").toLowerCase(); case "A": return t("tt").toUpperCase(); case "u": return p(x.getMilliseconds(), 3); case "I": return (x.isDaylightSavingTime()) ? 1 : 0; case "O": return x.getUTCOffset(); case "P": y = x.getUTCOffset(); return y.substring(0, y.length - 2) + ":" + y.substring(y.length - 2); case "B": var now = new Date(); return Math.floor(((now.getHours() * 3600) + (now.getMinutes() * 60) + now.getSeconds() + (now.getTimezoneOffset() + 60) * 60) / 86.4); case "c": return x.toISOString().replace(/\"/g, ""); case "U": return $D.strtotime("now"); case "%c": return t("d") + " " + t("t"); case "%C": return Math.floor(x.getFullYear() / 100 + 1); } }, shouldOverrideDefaults: function (m) { switch (m) { case "%e": return true; default: return false; } }, parse: function (m, context) { var formatString, c = context || new Date(); formatString = normalizer.substitutes(m); if (formatString) { return formatString; } formatString = normalizer.interpreted(m, c); if (formatString) { return formatString; } else { return m; } } }; $D.normalizeFormat = function (format, context) { return format.replace(/(%|\\)?.|%%/g, function(t){ return normalizer.parse(t, context); }); }; /** * Format a local Unix timestamp according to locale settings * * Example: * Date.strftime("%m/%d/%y", new Date()); // "04/13/08" * Date.strftime("c", "2008-04-13T17:52:03Z"); // "04/13/08" * * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @param {Number|String} The number representing the number of seconds that have elapsed since January 1, 1970 (local time). * @return {String} A string representation of the current Date object. */ $D.strftime = function (format, time) { var d = Date.parse(time); return d._format(format); }; /** * Parse any textual datetime description into a Unix timestamp. * A Unix timestamp is the number of seconds that have elapsed since January 1, 1970 (midnight UTC/GMT). * * Example: * Date.strtotime("04/13/08"); // 1208044800 * Date.strtotime("1970-01-01T00:00:00Z"); // 0 * * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @param {Object} A string or date object. * @return {String} A string representation of the current Date object. */ $D.strtotime = function (time) { var d = $D.parse(time); return Math.round($D.UTC(d.getUTCFullYear(), d.getUTCMonth(), d.getUTCDate(), d.getUTCHours(), d.getUTCMinutes(), d.getUTCSeconds(), d.getUTCMilliseconds()) / 1000); }; /** * Converts the value of the current Date object to its equivalent string representation using a PHP/Unix style of date format specifiers. * Format Specifiers * Format Description Example * ------ --------------------------------------------------------------------------- ----------------------- * %a abbreviated weekday name according to the current localed "Mon" through "Sun" * %A full weekday name according to the current localed "Sunday" through "Saturday" * %b abbreviated month name according to the current localed "Jan" through "Dec" * %B full month name according to the current locale "January" through "December" * %c preferred date and time representation for the current locale "4/13/2008 12:33 PM" * %C century number (the year divided by 100 and truncated to an integer) "00" to "99" * %d day of the month as a decimal number "01" to "31" * %D same as %m/%d/%y "04/13/08" * %e day of the month as a decimal number, a single digit is preceded by a space "1" to "31" * %g like %G, but without the century "08" * %G The 4-digit year corresponding to the ISO week number (see %V). "2008" * This has the same format and value as %Y, except that if the ISO week number * belongs to the previous or next year, that year is used instead. * %h same as %b "Jan" through "Dec" * %H hour as a decimal number using a 24-hour clock. "00" to "23" * %I hour as a decimal number using a 12-hour clock. "01" to "12" * %j day of the year as a decimal number. "001" to "366" * %m month as a decimal number. "01" to "12" * %M minute as a decimal number. "00" to "59" * %n newline character "\n" * %p either "am" or "pm" according to the given time value, or the "am" or "pm" * corresponding strings for the current locale. * %r time in a.m. and p.m. notation "8:44 PM" * %R time in 24 hour notation "20:44" * %S second as a decimal number "00" to "59" * %t tab character "\t" * %T current time, equal to %H:%M:%S "12:49:11" * %u weekday as a decimal number ["1", "7"], with "1" representing Monday "1" to "7" * %U week number of the current year as a decimal number, starting with the "0" to ("52" or "53") * first Sunday as the first day of the first week * %V The ISO 8601:1988 week number of the current year as a decimal number, "00" to ("52" or "53") * range 01 to 53, where week 1 is the first week that has at least 4 days * in the current year, and with Monday as the first day of the week. * (Use %G or %g for the year component that corresponds to the week number * for the specified timestamp.) * %W week number of the current year as a decimal number, starting with the "00" to ("52" or "53") * first Monday as the first day of the first week * %w day of the week as a decimal, Sunday being "0" "0" to "6" * %x preferred date representation for the current locale without the time "4/13/2008" * %X preferred time representation for the current locale without the date "12:53:05" * %y year as a decimal number without a century "00" "99" * %Y year as a decimal number including the century "2008" * %Z time zone or name or abbreviation "UTC", "EST", "PST" * %z same as %Z * %% a literal "%" characters "%" * d Day of the month, 2 digits with leading zeros "01" to "31" * D A textual representation of a day, three letters "Mon" through "Sun" * j Day of the month without leading zeros "1" to "31" * l A full textual representation of the day of the week (lowercase "L") "Sunday" through "Saturday" * N ISO-8601 numeric representation of the day of the week (added in PHP 5.1.0) "1" (for Monday) through "7" (for Sunday) * S English ordinal suffix for the day of the month, 2 characters "st", "nd", "rd" or "th". Works well with j * w Numeric representation of the day of the week "0" (for Sunday) through "6" (for Saturday) * z The day of the year (starting from "0") "0" through "365" * W ISO-8601 week number of year, weeks starting on Monday "00" to ("52" or "53") * F A full textual representation of a month, such as January or March "January" through "December" * m Numeric representation of a month, with leading zeros "01" through "12" * M A short textual representation of a month, three letters "Jan" through "Dec" * n Numeric representation of a month, without leading zeros "1" through "12" * t Number of days in the given month "28" through "31" * L Whether it's a leap year "1" if it is a leap year, "0" otherwise * o ISO-8601 year number. This has the same value as Y, except that if the "2008" * ISO week number (W) belongs to the previous or next year, that year * is used instead. * Y A full numeric representation of a year, 4 digits "2008" * y A two digit representation of a year "08" * a Lowercase Ante meridiem and Post meridiem "am" or "pm" * A Uppercase Ante meridiem and Post meridiem "AM" or "PM" * B Swatch Internet time "000" through "999" * g 12-hour format of an hour without leading zeros "1" through "12" * G 24-hour format of an hour without leading zeros "0" through "23" * h 12-hour format of an hour with leading zeros "01" through "12" * H 24-hour format of an hour with leading zeros "00" through "23" * i Minutes with leading zeros "00" to "59" * s Seconds, with leading zeros "00" through "59" * u Milliseconds "54321" * e Timezone identifier "UTC", "EST", "PST" * I Whether or not the date is in daylight saving time (uppercase i) "1" if Daylight Saving Time, "0" otherwise * O Difference to Greenwich time (GMT) in hours "+0200", "-0600" * P Difference to Greenwich time (GMT) with colon between hours and minutes "+02:00", "-06:00" * T Timezone abbreviation "UTC", "EST", "PST" * Z Timezone offset in seconds. The offset for timezones west of UTC is "-43200" through "50400" * always negative, and for those east of UTC is always positive. * c ISO 8601 date "2004-02-12T15:19:21+00:00" * r RFC 2822 formatted date "Thu, 21 Dec 2000 16:01:07 +0200" * U Seconds since the Unix Epoch (January 1 1970 00:00:00 GMT) "0" * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @return {String} A string representation of the current Date object. */ var formatReplace = function (context) { return function (m) { var formatString, override = false; if (m.charAt(0) === "\\" || m.substring(0, 2) === "%%") { return m.replace("\\", "").replace("%%", "%"); } override = normalizer.shouldOverrideDefaults(m); formatString = $D.normalizeFormat(m, context); if (formatString) { return context.toString(formatString, override); } }; }; $P._format = function (format) { var formatter = formatReplace(this); if (!format) { return this._toString(); } else { return format.replace(/(%|\\)?.|%%/g, formatter); } }; if (!$P.format) { $P.format = $P._format; } }()); (function () { "use strict"; var gFn = function (attr) { return function () { return this[attr]; }; }; var sFn = function (attr) { return function (val) { this[attr] = val; return this; }; }; var attrs = ["years", "months", "days", "hours", "minutes", "seconds", "milliseconds"]; var addSetFuncs = function (context, attrs) { for (var i = 0; i < attrs.length ; i++) { var $a = attrs[i], $b = $a.slice(0, 1).toUpperCase() + $a.slice(1); context.prototype[$a] = 0; context.prototype["get" + $b] = gFn($a); context.prototype["set" + $b] = sFn($a); } }; /** * new TimeSpan(milliseconds); * new TimeSpan(days, hours, minutes, seconds); * new TimeSpan(days, hours, minutes, seconds, milliseconds); */ var TimeSpan = function (days, hours, minutes, seconds, milliseconds) { if (arguments.length === 1 && typeof days === "number") { var orient = (days < 0) ? -1 : +1; var millsLeft = Math.abs(days); this.setDays(Math.floor(millsLeft / 86400000) * orient); millsLeft = millsLeft % 86400000; this.setHours(Math.floor(millsLeft / 3600000) * orient); millsLeft = millsLeft % 3600000; this.setMinutes(Math.floor(millsLeft / 60000) * orient); millsLeft = millsLeft % 60000; this.setSeconds(Math.floor(millsLeft / 1000) * orient); millsLeft = millsLeft % 1000; this.setMilliseconds(millsLeft * orient); } else { this.set(days, hours, minutes, seconds, milliseconds); } this.getTotalMilliseconds = function () { return (this.getDays() * 86400000) + (this.getHours() * 3600000) + (this.getMinutes() * 60000) + (this.getSeconds() * 1000); }; this.compareTo = function (time) { var t1 = new Date(1970, 1, 1, this.getHours(), this.getMinutes(), this.getSeconds()), t2; if (time === null) { t2 = new Date(1970, 1, 1, 0, 0, 0); } else { t2 = new Date(1970, 1, 1, time.getHours(), time.getMinutes(), time.getSeconds()); } return (t1 < t2) ? -1 : (t1 > t2) ? 1 : 0; }; this.equals = function (time) { return (this.compareTo(time) === 0); }; this.add = function (time) { return (time === null) ? this : this.addSeconds(time.getTotalMilliseconds() / 1000); }; this.subtract = function (time) { return (time === null) ? this : this.addSeconds(-time.getTotalMilliseconds() / 1000); }; this.addDays = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 86400000)); }; this.addHours = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 3600000)); }; this.addMinutes = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 60000)); }; this.addSeconds = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 1000)); }; this.addMilliseconds = function (n) { return new TimeSpan(this.getTotalMilliseconds() + n); }; this.get12HourHour = function () { return (this.getHours() > 12) ? this.getHours() - 12 : (this.getHours() === 0) ? 12 : this.getHours(); }; this.getDesignator = function () { return (this.getHours() < 12) ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator; }; this.toString = function (format) { this._toString = function () { if (this.getDays() !== null && this.getDays() > 0) { return this.getDays() + "." + this.getHours() + ":" + this.p(this.getMinutes()) + ":" + this.p(this.getSeconds()); } else { return this.getHours() + ":" + this.p(this.getMinutes()) + ":" + this.p(this.getSeconds()); } }; this.p = function (s) { return (s.toString().length < 2) ? "0" + s : s; }; var me = this; return format ? format.replace(/dd?|HH?|hh?|mm?|ss?|tt?/g, function (format) { switch (format) { case "d": return me.getDays(); case "dd": return me.p(me.getDays()); case "H": return me.getHours(); case "HH": return me.p(me.getHours()); case "h": return me.get12HourHour(); case "hh": return me.p(me.get12HourHour()); case "m": return me.getMinutes(); case "mm": return me.p(me.getMinutes()); case "s": return me.getSeconds(); case "ss": return me.p(me.getSeconds()); case "t": return ((me.getHours() < 12) ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator).substring(0, 1); case "tt": return (me.getHours() < 12) ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator; } } ) : this._toString(); }; return this; }; addSetFuncs(TimeSpan, attrs.slice(2)); TimeSpan.prototype.set = function (days, hours, minutes, seconds, milliseconds){ this.setDays(days || this.getDays()); this.setHours(hours || this.getHours()); this.setMinutes(minutes || this.getMinutes()); this.setSeconds(seconds || this.getSeconds()); this.setMilliseconds(milliseconds || this.getMilliseconds()); }; /** * Gets the time of day for this date instances. * @return {TimeSpan} TimeSpan */ Date.prototype.getTimeOfDay = function () { return new TimeSpan(0, this.getHours(), this.getMinutes(), this.getSeconds(), this.getMilliseconds()); }; Date.TimeSpan = TimeSpan; if (typeof window !== "undefined" ) { // keeping API compatible for v1.x window.TimeSpan = TimeSpan; } }()); (function () { "use strict"; var attrs = ["years", "months", "days", "hours", "minutes", "seconds", "milliseconds"]; var gFn = function (attr) { return function () { return this[attr]; }; }; var sFn = function (attr) { return function (val) { this[attr] = val; return this; }; }; var addSetFuncs = function (context, attrs) { for (var i = 0; i < attrs.length ; i++) { var $a = attrs[i], $b = $a.slice(0, 1).toUpperCase() + $a.slice(1); context.prototype[$a] = 0; context.prototype["get" + $b] = gFn($a); context.prototype["set" + $b] = sFn($a); } }; var setMonthsAndYears = function (orient, d1, d2, context) { function inc() { d1.addMonths(-orient); context.months++; if (context.months === 12) { context.years++; context.months = 0; } } if (orient === +1) { while (d1 > d2) { inc(); } } else { while (d1 < d2) { inc(); } } context.months--; context.months *= orient; context.years *= orient; }; var adjustForDST = function(orient, startDate, endDate) { var hasDSTMismatch = (false === (startDate.isDaylightSavingTime() === endDate.isDaylightSavingTime())); if (hasDSTMismatch && orient === 1) { startDate.addHours(-1); } else if (hasDSTMismatch) { startDate.addHours(1); } }; /** * TimePeriod(startDate, endDate); * TimePeriod(years, months, days, hours, minutes, seconds, milliseconds); */ var TimePeriod = function (years, months, days, hours, minutes, seconds, milliseconds) { if (arguments.length === 7) { this.set(years, months, days, hours, minutes, seconds, milliseconds); } else if (arguments.length === 2 && arguments[0] instanceof Date && arguments[1] instanceof Date) { var startDate = arguments[0].clone(); var endDate = arguments[1].clone(); var orient = (startDate > endDate) ? +1 : -1; this.dates = { start: arguments[0].clone(), end: arguments[1].clone() }; setMonthsAndYears(orient, startDate, endDate, this); adjustForDST(orient, startDate, endDate); // // TODO - adjust for DST var diff = endDate - startDate; if (diff !== 0) { var ts = new TimeSpan(diff); this.set(this.years, this.months, ts.getDays(), ts.getHours(), ts.getMinutes(), ts.getSeconds(), ts.getMilliseconds()); } } return this; }; // create all the set functions. addSetFuncs(TimePeriod, attrs); TimePeriod.prototype.set = function (years, months, days, hours, minutes, seconds, milliseconds){ this.setYears(years || this.getYears()); this.setMonths(months || this.getMonths()); this.setDays(days || this.getDays()); this.setHours(hours || this.getHours()); this.setMinutes(minutes || this.getMinutes()); this.setSeconds(seconds || this.getSeconds()); this.setMilliseconds(milliseconds || this.getMilliseconds()); }; Date.TimePeriod = TimePeriod; if (typeof window !== "undefined") { // keeping API compatible for v1.x window.TimePeriod = TimePeriod; } }()); ================================================ FILE: build/date-es-GT.js ================================================ /** * @overview datejs * @version 1.0.0-rc3 * @author Gregory Wild-Smith * @copyright 2015 Gregory Wild-Smith * @license MIT * @homepage https://github.com/abritinthebay/datejs */ /* * DateJS Culture String File * Country Code: es-GT * Name: Spanish (Guatemala) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["es-GT"] = { "name": "es-GT", "englishName": "Spanish (Guatemala)", "nativeName": "Español (Guatemala)", "Sunday": "domingo", "Monday": "lunes", "Tuesday": "martes", "Wednesday": "miércoles", "Thursday": "jueves", "Friday": "viernes", "Saturday": "sábado", "Sun": "dom", "Mon": "lun", "Tue": "mar", "Wed": "mié", "Thu": "jue", "Fri": "vie", "Sat": "sáb", "Su": "do", "Mo": "lu", "Tu": "ma", "We": "mi", "Th": "ju", "Fr": "vi", "Sa": "sá", "S_Sun_Initial": "d", "M_Mon_Initial": "l", "T_Tue_Initial": "m", "W_Wed_Initial": "m", "T_Thu_Initial": "j", "F_Fri_Initial": "v", "S_Sat_Initial": "s", "January": "enero", "February": "febrero", "March": "marzo", "April": "abril", "May": "mayo", "June": "junio", "July": "julio", "August": "agosto", "September": "septiembre", "October": "octubre", "November": "noviembre", "December": "diciembre", "Jan_Abbr": "ene", "Feb_Abbr": "feb", "Mar_Abbr": "mar", "Apr_Abbr": "abr", "May_Abbr": "may", "Jun_Abbr": "jun", "Jul_Abbr": "jul", "Aug_Abbr": "ago", "Sep_Abbr": "sep", "Oct_Abbr": "oct", "Nov_Abbr": "nov", "Dec_Abbr": "dic", "AM": "a.m.", "PM": "p.m.", "firstDayOfWeek": 0, "twoDigitYearMax": 2029, "mdy": "dmy", "M/d/yyyy": "dd/MM/yyyy", "dddd, MMMM dd, yyyy": "dddd, dd' [de] 'MMMM' [de] 'yyyy", "h:mm tt": "hh:mm tt", "h:mm:ss tt": "hh:mm:ss tt", "dddd, MMMM dd, yyyy h:mm:ss tt": "dddd, dd' [de] 'MMMM' [de] 'yyyy hh:mm:ss tt", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "dd MMMM", "MMMM, yyyy": "MMMM' [de] 'yyyy", "/jan(uary)?/": "ene(ro)?", "/feb(ruary)?/": "feb(rero)?", "/mar(ch)?/": "mar(zo)?", "/apr(il)?/": "abr(il)?", "/may/": "may(o)?", "/jun(e)?/": "jun(io)?", "/jul(y)?/": "jul(io)?", "/aug(ust)?/": "ago(sto)?", "/sep(t(ember)?)?/": "sep(tiembre)?", "/oct(ober)?/": "oct(ubre)?", "/nov(ember)?/": "nov(iembre)?", "/dec(ember)?/": "dic(iembre)?", "/^su(n(day)?)?/": "^do(m(ingo)?)?", "/^mo(n(day)?)?/": "^lu(n(es)?)?", "/^tu(e(s(day)?)?)?/": "^ma(r(tes)?)?", "/^we(d(nesday)?)?/": "^mi(é(rcoles)?)?", "/^th(u(r(s(day)?)?)?)?/": "^ju(e(ves)?)?", "/^fr(i(day)?)?/": "^vi(e(rnes)?)?", "/^sa(t(urday)?)?/": "^sá(b(ado)?)?", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "es-GT"; /** * @overview datejs * @version 1.0.0-rc3 * @author Gregory Wild-Smith * @copyright 2015 Gregory Wild-Smith * @license MIT * @homepage https://github.com/abritinthebay/datejs */(function () { var $D = Date; var lang = Date.CultureStrings ? Date.CultureStrings.lang : null; var loggedKeys = {}; // for debug purposes. var getText = { getFromKey: function (key, countryCode) { var output; if (Date.CultureStrings && Date.CultureStrings[countryCode] && Date.CultureStrings[countryCode][key]) { output = Date.CultureStrings[countryCode][key]; } else { output = getText.buildFromDefault(key); } if (key.charAt(0) === "/") { // Assume it's a regex output = getText.buildFromRegex(key, countryCode); } return output; }, getFromObjectValues: function (obj, countryCode) { var key, output = {}; for(key in obj) { if (obj.hasOwnProperty(key)) { output[key] = getText.getFromKey(obj[key], countryCode); } } return output; }, getFromObjectKeys: function (obj, countryCode) { var key, output = {}; for(key in obj) { if (obj.hasOwnProperty(key)) { output[getText.getFromKey(key, countryCode)] = obj[key]; } } return output; }, getFromArray: function (arr, countryCode) { var output = []; for (var i=0; i < arr.length; i++){ if (i in arr) { output[i] = getText.getFromKey(arr[i], countryCode); } } return output; }, buildFromDefault: function (key) { var output, length, split, last; switch(key) { case "name": output = "en-US"; break; case "englishName": output = "English (United States)"; break; case "nativeName": output = "English (United States)"; break; case "twoDigitYearMax": output = 2049; break; case "firstDayOfWeek": output = 0; break; default: output = key; split = key.split("_"); length = split.length; if (length > 1 && key.charAt(0) !== "/") { // if the key isn't a regex and it has a split. last = split[(length - 1)].toLowerCase(); if (last === "initial" || last === "abbr") { output = split[0]; } } break; } return output; }, buildFromRegex: function (key, countryCode) { var output; if (Date.CultureStrings && Date.CultureStrings[countryCode] && Date.CultureStrings[countryCode][key]) { output = new RegExp(Date.CultureStrings[countryCode][key], "i"); } else { output = new RegExp(key.replace(new RegExp("/", "g"),""), "i"); } return output; } }; var shallowMerge = function (obj1, obj2) { for (var attrname in obj2) { if (obj2.hasOwnProperty(attrname)) { obj1[attrname] = obj2[attrname]; } } }; var __ = function (key, language) { var countryCode = (language) ? language : lang; loggedKeys[key] = key; if (typeof key === "object") { if (key instanceof Array) { return getText.getFromArray(key, countryCode); } else { return getText.getFromObjectKeys(key, countryCode); } } else { return getText.getFromKey(key, countryCode); } }; var loadI18nScript = function (code) { // paatterned after jQuery's getScript. var url = Date.Config.i18n + code + ".js"; var head = document.getElementsByTagName("head")[0] || document.documentElement; var script = document.createElement("script"); script.src = url; var completed = false; var events = { done: function (){} // placeholder function }; // Attach handlers for all browsers script.onload = script.onreadystatechange = function() { if ( !completed && (!this.readyState || this.readyState === "loaded" || this.readyState === "complete") ) { events.done(); head.removeChild(script); } }; setTimeout(function() { head.insertBefore(script, head.firstChild); }, 0); // allows return to execute first return { done: function (cb) { events.done = function() { if (cb) { setTimeout(cb,0); } }; } }; }; var buildInfo = { buildFromMethodHash: function (obj) { var key; for(key in obj) { if (obj.hasOwnProperty(key)) { obj[key] = buildInfo[obj[key]](); } } return obj; }, timeZoneDST: function () { var DST = { "CHADT": "+1345", "NZDT": "+1300", "AEDT": "+1100", "ACDT": "+1030", "AZST": "+0500", "IRDT": "+0430", "EEST": "+0300", "CEST": "+0200", "BST": "+0100", "PMDT": "-0200", "ADT": "-0300", "NDT": "-0230", "EDT": "-0400", "CDT": "-0500", "MDT": "-0600", "PDT": "-0700", "AKDT": "-0800", "HADT": "-0900" }; return __(DST); }, timeZoneStandard: function () { var standard = { "LINT": "+1400", "TOT": "+1300", "CHAST": "+1245", "NZST": "+1200", "NFT": "+1130", "SBT": "+1100", "AEST": "+1000", "ACST": "+0930", "JST": "+0900", "CWST": "+0845", "CT": "+0800", "ICT": "+0700", "MMT": "+0630", "BST": "+0600", "NPT": "+0545", "IST": "+0530", "PKT": "+0500", "AFT": "+0430", "MSK": "+0400", "IRST": "+0330", "FET": "+0300", "EET": "+0200", "CET": "+0100", "GMT": "+0000", "UTC": "+0000", "CVT": "-0100", "GST": "-0200", "BRT": "-0300", "NST": "-0330", "AST": "-0400", "EST": "-0500", "CST": "-0600", "MST": "-0700", "PST": "-0800", "AKST": "-0900", "MIT": "-0930", "HST": "-1000", "SST": "-1100", "BIT": "-1200" }; return __(standard); }, timeZones: function (data) { var zone; data.timezones = []; for (zone in data.abbreviatedTimeZoneStandard) { if (data.abbreviatedTimeZoneStandard.hasOwnProperty(zone)) { data.timezones.push({ name: zone, offset: data.abbreviatedTimeZoneStandard[zone]}); } } for (zone in data.abbreviatedTimeZoneDST) { if (data.abbreviatedTimeZoneDST.hasOwnProperty(zone)) { data.timezones.push({ name: zone, offset: data.abbreviatedTimeZoneDST[zone], dst: true}); } } return data.timezones; }, days: function () { return __(["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"]); }, dayAbbr: function () { return __(["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"]); }, dayShortNames: function () { return __(["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"]); }, dayFirstLetters: function () { return __(["S_Sun_Initial", "M_Mon_Initial", "T_Tues_Initial", "W_Wed_Initial", "T_Thu_Initial", "F_Fri_Initial", "S_Sat_Initial"]); }, months: function () { return __(["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"]); }, monthAbbr: function () { return __(["Jan_Abbr", "Feb_Abbr", "Mar_Abbr", "Apr_Abbr", "May_Abbr", "Jun_Abbr", "Jul_Abbr", "Aug_Abbr", "Sep_Abbr", "Oct_Abbr", "Nov_Abbr", "Dec_Abbr"]); }, formatPatterns: function () { return getText.getFromObjectValues({ shortDate: "M/d/yyyy", longDate: "dddd, MMMM dd, yyyy", shortTime: "h:mm tt", longTime: "h:mm:ss tt", fullDateTime: "dddd, MMMM dd, yyyy h:mm:ss tt", sortableDateTime: "yyyy-MM-ddTHH:mm:ss", universalSortableDateTime: "yyyy-MM-dd HH:mm:ssZ", rfc1123: "ddd, dd MMM yyyy HH:mm:ss", monthDay: "MMMM dd", yearMonth: "MMMM, yyyy" }, Date.i18n.currentLanguage()); }, regex: function () { return getText.getFromObjectValues({ inTheMorning: "/( in the )(morn(ing)?)\\b/", thisMorning: "/(this )(morn(ing)?)\\b/", amThisMorning: "/(\b\\d(am)? )(this )(morn(ing)?)/", inTheEvening: "/( in the )(even(ing)?)\\b/", thisEvening: "/(this )(even(ing)?)\\b/", pmThisEvening: "/(\b\\d(pm)? )(this )(even(ing)?)/", jan: "/jan(uary)?/", feb: "/feb(ruary)?/", mar: "/mar(ch)?/", apr: "/apr(il)?/", may: "/may/", jun: "/jun(e)?/", jul: "/jul(y)?/", aug: "/aug(ust)?/", sep: "/sep(t(ember)?)?/", oct: "/oct(ober)?/", nov: "/nov(ember)?/", dec: "/dec(ember)?/", sun: "/^su(n(day)?)?/", mon: "/^mo(n(day)?)?/", tue: "/^tu(e(s(day)?)?)?/", wed: "/^we(d(nesday)?)?/", thu: "/^th(u(r(s(day)?)?)?)?/", fri: "/fr(i(day)?)?/", sat: "/^sa(t(urday)?)?/", future: "/^next/", past: "/^last|past|prev(ious)?/", add: "/^(\\+|aft(er)?|from|hence)/", subtract: "/^(\\-|bef(ore)?|ago)/", yesterday: "/^yes(terday)?/", today: "/^t(od(ay)?)?/", tomorrow: "/^tom(orrow)?/", now: "/^n(ow)?/", millisecond: "/^ms|milli(second)?s?/", second: "/^sec(ond)?s?/", minute: "/^mn|min(ute)?s?/", hour: "/^h(our)?s?/", week: "/^w(eek)?s?/", month: "/^m(onth)?s?/", day: "/^d(ay)?s?/", year: "/^y(ear)?s?/", shortMeridian: "/^(a|p)/", longMeridian: "/^(a\\.?m?\\.?|p\\.?m?\\.?)/", timezone: "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/", ordinalSuffix: "/^\\s*(st|nd|rd|th)/", timeContext: "/^\\s*(\\:|a(?!u|p)|p)/" }, Date.i18n.currentLanguage()); } }; var CultureInfo = function () { var info = getText.getFromObjectValues({ name: "name", englishName: "englishName", nativeName: "nativeName", amDesignator: "AM", pmDesignator: "PM", firstDayOfWeek: "firstDayOfWeek", twoDigitYearMax: "twoDigitYearMax", dateElementOrder: "mdy" }, Date.i18n.currentLanguage()); var constructedInfo = buildInfo.buildFromMethodHash({ dayNames: "days", abbreviatedDayNames: "dayAbbr", shortestDayNames: "dayShortNames", firstLetterDayNames: "dayFirstLetters", monthNames: "months", abbreviatedMonthNames: "monthAbbr", formatPatterns: "formatPatterns", regexPatterns: "regex", abbreviatedTimeZoneDST: "timeZoneDST", abbreviatedTimeZoneStandard: "timeZoneStandard" }); shallowMerge(info, constructedInfo); buildInfo.timeZones(info); return info; }; $D.i18n = { __: function (key, lang) { return __(key, lang); }, currentLanguage: function () { return lang || "en-US"; }, setLanguage: function (code, force, cb) { var async = false; if (force || code === "en-US" || (!!Date.CultureStrings && !!Date.CultureStrings[code])) { lang = code; Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings.lang = code; Date.CultureInfo = new CultureInfo(); } else { if (!(!!Date.CultureStrings && !!Date.CultureStrings[code])) { if (typeof exports !== "undefined" && this.exports !== exports) { // we're in a Node enviroment, load it using require try { require("../i18n/" + code + ".js"); lang = code; Date.CultureStrings.lang = code; Date.CultureInfo = new CultureInfo(); } catch (e) { // var str = "The language for '" + code + "' could not be loaded by Node. It likely does not exist."; throw new Error("The DateJS IETF language tag '" + code + "' could not be loaded by Node. It likely does not exist."); } } else if (Date.Config && Date.Config.i18n) { // we know the location of the files, so lets load them async = true; loadI18nScript(code).done(function(){ lang = code; Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings.lang = code; Date.CultureInfo = new CultureInfo(); $D.Parsing.Normalizer.buildReplaceData(); // because this is async if ($D.Grammar) { $D.Grammar.buildGrammarFormats(); // so we can parse those strings... } if (cb) { setTimeout(cb,0); } }); } else { Date.console.error("The DateJS IETF language tag '" + code + "' is not available and has not been loaded."); return false; } } } $D.Parsing.Normalizer.buildReplaceData(); // rebuild normalizer strings if ($D.Grammar) { $D.Grammar.buildGrammarFormats(); // so we can parse those strings... } if (!async && cb) { setTimeout(cb,0); } }, getLoggedKeys: function () { return loggedKeys; }, updateCultureInfo: function () { Date.CultureInfo = new CultureInfo(); } }; $D.i18n.updateCultureInfo(); // run automatically }()); (function () { var $D = Date, $P = $D.prototype, p = function (s, l) { if (!l) { l = 2; } return ("000" + s).slice(l * -1); }; if (typeof window !== "undefined" && typeof window.console !== "undefined" && typeof window.console.log !== "undefined") { $D.console = console; // used only to raise non-critical errors if available } else { // set mock so we don't give errors. $D.console = { log: function(){}, error: function(){} }; } $D.Config = $D.Config || {}; $D.initOverloads = function() { /** * Overload of Date.now. Allows an alternate call for Date.now where it returns the * current Date as an object rather than just milliseconds since the Unix Epoch. * * Also provides an implementation of now() for browsers (IE<9) that don't have it. * * Backwards compatible so with work with either: * Date.now() [returns ms] * or * Date.now(true) [returns Date] */ if (!$D.now) { $D._now = function now() { return new Date().getTime(); }; } else if (!$D._now) { $D._now = $D.now; } $D.now = function (returnObj) { if (returnObj) { return $D.present(); } else { return $D._now(); } }; if ( !$P.toISOString ) { $P.toISOString = function() { return this.getUTCFullYear() + "-" + p(this.getUTCMonth() + 1) + "-" + p(this.getUTCDate()) + "T" + p(this.getUTCHours()) + ":" + p(this.getUTCMinutes()) + ":" + p(this.getUTCSeconds()) + "." + String( (this.getUTCMilliseconds()/1000).toFixed(3)).slice(2, 5) + "Z"; }; } // private if ( $P._toString === undefined ){ $P._toString = $P.toString; } }; $D.initOverloads(); /** * Gets a date that is set to the current date. The time is set to the start of the day (00:00 or 12:00 AM). * @return {Date} The current date. */ $D.today = function () { return new Date().clearTime(); }; /** * Gets a date that is set to the current date and time (same as new Date, but chainable) * @return {Date} The current date. */ $D.present = function () { return new Date(); }; /** * Compares the first date to the second date and returns an number indication of their relative values. * @param {Date} First Date object to compare [Required]. * @param {Date} Second Date object to compare to [Required]. * @return {Number} -1 = date1 is lessthan date2. 0 = values are equal. 1 = date1 is greaterthan date2. */ $D.compare = function (date1, date2) { if (isNaN(date1) || isNaN(date2)) { throw new Error(date1 + " - " + date2); } else if (date1 instanceof Date && date2 instanceof Date) { return (date1 < date2) ? -1 : (date1 > date2) ? 1 : 0; } else { throw new TypeError(date1 + " - " + date2); } }; /** * Compares the first Date object to the second Date object and returns true if they are equal. * @param {Date} First Date object to compare [Required] * @param {Date} Second Date object to compare to [Required] * @return {Boolean} true if dates are equal. false if they are not equal. */ $D.equals = function (date1, date2) { return (date1.compareTo(date2) === 0); }; /** * Gets the language appropriate day name when given the day number(0-6) * eg - 0 == Sunday * @return {String} The day name */ $D.getDayName = function (n) { return Date.CultureInfo.dayNames[n]; }; /** * Gets the day number (0-6) if given a CultureInfo specific string which is a valid dayName, abbreviatedDayName or shortestDayName (two char). * @param {String} The name of the day (eg. "Monday, "Mon", "tuesday", "tue", "We", "we"). * @return {Number} The day number */ $D.getDayNumberFromName = function (name) { var n = Date.CultureInfo.dayNames, m = Date.CultureInfo.abbreviatedDayNames, o = Date.CultureInfo.shortestDayNames, s = name.toLowerCase(); for (var i = 0; i < n.length; i++) { if (n[i].toLowerCase() === s || m[i].toLowerCase() === s || o[i].toLowerCase() === s) { return i; } } return -1; }; /** * Gets the month number (0-11) if given a Culture Info specific string which is a valid monthName or abbreviatedMonthName. * @param {String} The name of the month (eg. "February, "Feb", "october", "oct"). * @return {Number} The day number */ $D.getMonthNumberFromName = function (name) { var n = Date.CultureInfo.monthNames, m = Date.CultureInfo.abbreviatedMonthNames, s = name.toLowerCase(); for (var i = 0; i < n.length; i++) { if (n[i].toLowerCase() === s || m[i].toLowerCase() === s) { return i; } } return -1; }; /** * Gets the language appropriate month name when given the month number(0-11) * eg - 0 == January * @return {String} The month name */ $D.getMonthName = function (n) { return Date.CultureInfo.monthNames[n]; }; /** * Determines if the current date instance is within a LeapYear. * @param {Number} The year. * @return {Boolean} true if date is within a LeapYear, otherwise false. */ $D.isLeapYear = function (year) { return ((year % 4 === 0 && year % 100 !== 0) || year % 400 === 0); }; /** * Gets the number of days in the month, given a year and month value. Automatically corrects for LeapYear. * @param {Number} The year. * @param {Number} The month (0-11). * @return {Number} The number of days in the month. */ $D.getDaysInMonth = function (year, month) { if (!month && $D.validateMonth(year)) { month = year; year = Date.today().getFullYear(); } return [31, ($D.isLeapYear(year) ? 29 : 28), 31, 30, 31, 30, 31, 31, 30, 31, 30, 31][month]; }; $P.getDaysInMonth = function () { return $D.getDaysInMonth(this.getFullYear(), this.getMonth()); }; $D.getTimezoneAbbreviation = function (offset, dst) { var p, n = (dst || false) ? Date.CultureInfo.abbreviatedTimeZoneDST : Date.CultureInfo.abbreviatedTimeZoneStandard; for (p in n) { if (n.hasOwnProperty(p)) { if (n[p] === offset) { return p; } } } return null; }; $D.getTimezoneOffset = function (name, dst) { var i, a =[], z = Date.CultureInfo.timezones; if (!name) { name = (new Date()).getTimezone();} for (i = 0; i < z.length; i++) { if (z[i].name === name.toUpperCase()) { a.push(i); } } if (!z[a[0]]) { return null; } if (a.length === 1 || !dst) { return z[a[0]].offset; } else { for (i=0; i < a.length; i++) { if (z[a[i]].dst) { return z[a[i]].offset; } } } }; $D.getQuarter = function (d) { d = d || new Date(); // If no date supplied, use today var q = [1,2,3,4]; return q[Math.floor(d.getMonth() / 3)]; // ~~~ is a bitwise op. Faster than Math.floor }; $D.getDaysLeftInQuarter = function (d) { d = d || new Date(); var qEnd = new Date(d); qEnd.setMonth(qEnd.getMonth() + 3 - qEnd.getMonth() % 3, 0); return Math.floor((qEnd - d) / 8.64e7); }; // private var validate = function (n, min, max, name) { name = name ? name : "Object"; if (typeof n === "undefined") { return false; } else if (typeof n !== "number") { throw new TypeError(n + " is not a Number."); } else if (n < min || n > max) { // As failing validation is *not* an exceptional circumstance // lets not throw a RangeError Exception here. // It's semantically correct but it's not sensible. return false; } return true; }; /** * Validates the number is within an acceptable range for milliseconds [0-999]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateMillisecond = function (value) { return validate(value, 0, 999, "millisecond"); }; /** * Validates the number is within an acceptable range for seconds [0-59]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateSecond = function (value) { return validate(value, 0, 59, "second"); }; /** * Validates the number is within an acceptable range for minutes [0-59]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateMinute = function (value) { return validate(value, 0, 59, "minute"); }; /** * Validates the number is within an acceptable range for hours [0-23]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateHour = function (value) { return validate(value, 0, 23, "hour"); }; /** * Validates the number is within an acceptable range for the days in a month [0-MaxDaysInMonth]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateDay = function (value, year, month) { if (year === undefined || year === null || month === undefined || month === null) { return false;} return validate(value, 1, $D.getDaysInMonth(year, month), "day"); }; /** * Validates the number is within an acceptable range for months [0-11]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateWeek = function (value) { return validate(value, 0, 53, "week"); }; /** * Validates the number is within an acceptable range for months [0-11]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateMonth = function (value) { return validate(value, 0, 11, "month"); }; /** * Validates the number is within an acceptable range for years. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateYear = function (value) { /** * Per ECMAScript spec the range of times supported by Date objects is * exactly -100,000,000 days to +100,000,000 days measured relative to * midnight at the beginning of 01 January, 1970 UTC. * This gives a range of 8,640,000,000,000,000 milliseconds to either * side of 01 January, 1970 UTC. * * Earliest possible date: Tue, 20 Apr 271,822 B.C. 00:00:00 UTC * Latest possible date: Sat, 13 Sep 275,760 00:00:00 UTC */ return validate(value, -271822, 275760, "year"); }; $D.validateTimezone = function(value) { var timezones = {"ACDT":1,"ACST":1,"ACT":1,"ADT":1,"AEDT":1,"AEST":1,"AFT":1,"AKDT":1,"AKST":1,"AMST":1,"AMT":1,"ART":1,"AST":1,"AWDT":1,"AWST":1,"AZOST":1,"AZT":1,"BDT":1,"BIOT":1,"BIT":1,"BOT":1,"BRT":1,"BST":1,"BTT":1,"CAT":1,"CCT":1,"CDT":1,"CEDT":1,"CEST":1,"CET":1,"CHADT":1,"CHAST":1,"CHOT":1,"ChST":1,"CHUT":1,"CIST":1,"CIT":1,"CKT":1,"CLST":1,"CLT":1,"COST":1,"COT":1,"CST":1,"CT":1,"CVT":1,"CWST":1,"CXT":1,"DAVT":1,"DDUT":1,"DFT":1,"EASST":1,"EAST":1,"EAT":1,"ECT":1,"EDT":1,"EEDT":1,"EEST":1,"EET":1,"EGST":1,"EGT":1,"EIT":1,"EST":1,"FET":1,"FJT":1,"FKST":1,"FKT":1,"FNT":1,"GALT":1,"GAMT":1,"GET":1,"GFT":1,"GILT":1,"GIT":1,"GMT":1,"GST":1,"GYT":1,"HADT":1,"HAEC":1,"HAST":1,"HKT":1,"HMT":1,"HOVT":1,"HST":1,"ICT":1,"IDT":1,"IOT":1,"IRDT":1,"IRKT":1,"IRST":1,"IST":1,"JST":1,"KGT":1,"KOST":1,"KRAT":1,"KST":1,"LHST":1,"LINT":1,"MAGT":1,"MART":1,"MAWT":1,"MDT":1,"MET":1,"MEST":1,"MHT":1,"MIST":1,"MIT":1,"MMT":1,"MSK":1,"MST":1,"MUT":1,"MVT":1,"MYT":1,"NCT":1,"NDT":1,"NFT":1,"NPT":1,"NST":1,"NT":1,"NUT":1,"NZDT":1,"NZST":1,"OMST":1,"ORAT":1,"PDT":1,"PET":1,"PETT":1,"PGT":1,"PHOT":1,"PHT":1,"PKT":1,"PMDT":1,"PMST":1,"PONT":1,"PST":1,"PYST":1,"PYT":1,"RET":1,"ROTT":1,"SAKT":1,"SAMT":1,"SAST":1,"SBT":1,"SCT":1,"SGT":1,"SLST":1,"SRT":1,"SST":1,"SYOT":1,"TAHT":1,"THA":1,"TFT":1,"TJT":1,"TKT":1,"TLT":1,"TMT":1,"TOT":1,"TVT":1,"UCT":1,"ULAT":1,"UTC":1,"UYST":1,"UYT":1,"UZT":1,"VET":1,"VLAT":1,"VOLT":1,"VOST":1,"VUT":1,"WAKT":1,"WAST":1,"WAT":1,"WEDT":1,"WEST":1,"WET":1,"WST":1,"YAKT":1,"YEKT":1,"Z":1}; return (timezones[value] === 1); }; $D.validateTimezoneOffset= function(value) { // timezones go from +14hrs to -12hrs, the +X hours are negative offsets. return (value > -841 && value < 721); }; }()); (function () { var $D = Date, $P = $D.prototype, p = function (s, l) { if (!l) { l = 2; } return ("000" + s).slice(l * -1); }; var validateConfigObject = function (obj) { var result = {}, self = this, prop, testFunc; testFunc = function (prop, func, value) { if (prop === "day") { var month = (obj.month !== undefined) ? obj.month : self.getMonth(); var year = (obj.year !== undefined) ? obj.year : self.getFullYear(); return $D[func](value, year, month); } else { return $D[func](value); } }; for (prop in obj) { if (Object.prototype.hasOwnProperty.call(obj, prop)) { var func = "validate" + prop.charAt(0).toUpperCase() + prop.slice(1); if ($D[func] && obj[prop] !== null && testFunc(prop, func, obj[prop])) { result[prop] = obj[prop]; } } } return result; }; /** * Resets the time of this Date object to 12:00 AM (00:00), which is the start of the day. * @param {Boolean} .clone() this date instance before clearing Time * @return {Date} this */ $P.clearTime = function () { this.setHours(0); this.setMinutes(0); this.setSeconds(0); this.setMilliseconds(0); return this; }; /** * Resets the time of this Date object to the current time ('now'). * @return {Date} this */ $P.setTimeToNow = function () { var n = new Date(); this.setHours(n.getHours()); this.setMinutes(n.getMinutes()); this.setSeconds(n.getSeconds()); this.setMilliseconds(n.getMilliseconds()); return this; }; /** * Returns a new Date object that is an exact date and time copy of the original instance. * @return {Date} A new Date instance */ $P.clone = function () { return new Date(this.getTime()); }; /** * Compares this instance to a Date object and returns an number indication of their relative values. * @param {Date} Date object to compare [Required] * @return {Number} -1 = this is lessthan date. 0 = values are equal. 1 = this is greaterthan date. */ $P.compareTo = function (date) { return Date.compare(this, date); }; /** * Compares this instance to another Date object and returns true if they are equal. * @param {Date} Date object to compare. If no date to compare, new Date() [now] is used. * @return {Boolean} true if dates are equal. false if they are not equal. */ $P.equals = function (date) { return Date.equals(this, (date !== undefined ? date : new Date())); }; /** * Determines if this instance is between a range of two dates or equal to either the start or end dates. * @param {Date} Start of range [Required] * @param {Date} End of range [Required] * @return {Boolean} true is this is between or equal to the start and end dates, else false */ $P.between = function (start, end) { return this.getTime() >= start.getTime() && this.getTime() <= end.getTime(); }; /** * Determines if this date occurs after the date to compare to. * @param {Date} Date object to compare. If no date to compare, new Date() ("now") is used. * @return {Boolean} true if this date instance is greater than the date to compare to (or "now"), otherwise false. */ $P.isAfter = function (date) { return this.compareTo(date || new Date()) === 1; }; /** * Determines if this date occurs before the date to compare to. * @param {Date} Date object to compare. If no date to compare, new Date() ("now") is used. * @return {Boolean} true if this date instance is less than the date to compare to (or "now"). */ $P.isBefore = function (date) { return (this.compareTo(date || new Date()) === -1); }; /** * Determines if the current Date instance occurs today. * @return {Boolean} true if this date instance is 'today', otherwise false. */ /** * Determines if the current Date instance occurs on the same Date as the supplied 'date'. * If no 'date' to compare to is provided, the current Date instance is compared to 'today'. * @param {date} Date object to compare. If no date to compare, the current Date ("now") is used. * @return {Boolean} true if this Date instance occurs on the same Day as the supplied 'date'. */ $P.isToday = $P.isSameDay = function (date) { return this.clone().clearTime().equals((date || new Date()).clone().clearTime()); }; /** * Adds the specified number of milliseconds to this instance. * @param {Number} The number of milliseconds to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addMilliseconds = function (value) { if (!value) { return this; } this.setTime(this.getTime() + value * 1); return this; }; /** * Adds the specified number of seconds to this instance. * @param {Number} The number of seconds to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addSeconds = function (value) { if (!value) { return this; } return this.addMilliseconds(value * 1000); }; /** * Adds the specified number of seconds to this instance. * @param {Number} The number of seconds to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addMinutes = function (value) { if (!value) { return this; } return this.addMilliseconds(value * 60000); // 60*1000 }; /** * Adds the specified number of hours to this instance. * @param {Number} The number of hours to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addHours = function (value) { if (!value) { return this; } return this.addMilliseconds(value * 3600000); // 60*60*1000 }; /** * Adds the specified number of days to this instance. * @param {Number} The number of days to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addDays = function (value) { if (!value) { return this; } this.setDate(this.getDate() + value * 1); return this; }; /** * Adds the specified number of weekdays (ie - not sat or sun) to this instance. * @param {Number} The number of days to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addWeekdays = function (value) { if (!value) { return this; } var day = this.getDay(); var weeks = (Math.ceil(Math.abs(value)/7)); if (day === 0 || day === 6) { if (value > 0) { this.next().monday(); this.addDays(-1); day = this.getDay(); } } if (value < 0) { while (value < 0) { this.addDays(-1); day = this.getDay(); if (day !== 0 && day !== 6) { value++; } } return this; } else if (value > 5 || (6-day) <= value) { value = value + (weeks * 2); } return this.addDays(value); }; /** * Adds the specified number of weeks to this instance. * @param {Number} The number of weeks to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addWeeks = function (value) { if (!value) { return this; } return this.addDays(value * 7); }; /** * Adds the specified number of months to this instance. * @param {Number} The number of months to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addMonths = function (value) { if (!value) { return this; } var n = this.getDate(); this.setDate(1); this.setMonth(this.getMonth() + value * 1); this.setDate(Math.min(n, $D.getDaysInMonth(this.getFullYear(), this.getMonth()))); return this; }; $P.addQuarters = function (value) { if (!value) { return this; } // note this will take you to the same point in the quarter as you are now. // i.e. - if you are 15 days into the quarter you'll be 15 days into the resulting one. // bonus: this allows adding fractional quarters return this.addMonths(value * 3); }; /** * Adds the specified number of years to this instance. * @param {Number} The number of years to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addYears = function (value) { if (!value) { return this; } return this.addMonths(value * 12); }; /** * Adds (or subtracts) to the value of the years, months, weeks, days, hours, minutes, seconds, milliseconds of the date instance using given configuration object. Positive and Negative values allowed. * Example

	Date.today().add( { days: 1, months: 1 } )

	new Date().add( { years: -1 } )
	
* @param {Object} Configuration object containing attributes (months, days, etc.) * @return {Date} this */ $P.add = function (config) { if (typeof config === "number") { this._orient = config; return this; } var x = config; if (x.day) { // If we should be a different date than today (eg: for 'tomorrow -1d', etc). // Should only effect parsing, not direct usage (eg, Finish and FinishExact) if ((x.day - this.getDate()) !== 0) { this.setDate(x.day); } } if (x.milliseconds) { this.addMilliseconds(x.milliseconds); } if (x.seconds) { this.addSeconds(x.seconds); } if (x.minutes) { this.addMinutes(x.minutes); } if (x.hours) { this.addHours(x.hours); } if (x.weeks) { this.addWeeks(x.weeks); } if (x.months) { this.addMonths(x.months); } if (x.years) { this.addYears(x.years); } if (x.days) { this.addDays(x.days); } return this; }; /** * Get the week number. Week one (1) is the week which contains the first Thursday of the year. Monday is considered the first day of the week. * The .getWeek() function does NOT convert the date to UTC. The local datetime is used. * Please use .getISOWeek() to get the week of the UTC converted date. * @return {Number} 1 to 53 */ $P.getWeek = function (utc) { // Create a copy of this date object var self, target = new Date(this.valueOf()); if (utc) { target.addMinutes(target.getTimezoneOffset()); self = target.clone(); } else { self = this; } // ISO week date weeks start on monday // so correct the day number var dayNr = (self.getDay() + 6) % 7; // ISO 8601 states that week 1 is the week // with the first thursday of that year. // Set the target date to the thursday in the target week target.setDate(target.getDate() - dayNr + 3); // Store the millisecond value of the target date var firstThursday = target.valueOf(); // Set the target to the first thursday of the year // First set the target to january first target.setMonth(0, 1); // Not a thursday? Correct the date to the next thursday if (target.getDay() !== 4) { target.setMonth(0, 1 + ((4 - target.getDay()) + 7) % 7); } // The weeknumber is the number of weeks between the // first thursday of the year and the thursday in the target week return 1 + Math.ceil((firstThursday - target) / 604800000); // 604800000 = 7 * 24 * 3600 * 1000 }; /** * Get the ISO 8601 week number. Week one ("01") is the week which contains the first Thursday of the year. Monday is considered the first day of the week. * The .getISOWeek() function does convert the date to it's UTC value. Please use .getWeek() to get the week of the local date. * @return {String} "01" to "53" */ $P.getISOWeek = function () { return p(this.getWeek(true)); }; /** * Moves the date to Monday of the week set. Week one (1) is the week which contains the first Thursday of the year. * @param {Number} A Number (1 to 53) that represents the week of the year. * @return {Date} this */ $P.setWeek = function (n) { if ((n - this.getWeek()) === 0) { if (this.getDay() !== 1) { return this.moveToDayOfWeek(1, (this.getDay() > 1 ? -1 : 1)); } else { return this; } } else { return this.moveToDayOfWeek(1, (this.getDay() > 1 ? -1 : 1)).addWeeks(n - this.getWeek()); } }; $P.setQuarter = function (qtr) { var month = Math.abs(((qtr-1) * 3) + 1); return this.setMonth(month, 1); }; $P.getQuarter = function () { return Date.getQuarter(this); }; $P.getDaysLeftInQuarter = function () { return Date.getDaysLeftInQuarter(this); }; /** * Moves the date to the next n'th occurrence of the dayOfWeek starting from the beginning of the month. The number (-1) is a magic number and will return the last occurrence of the dayOfWeek in the month. * @param {Number} The dayOfWeek to move to * @param {Number} The n'th occurrence to move to. Use (-1) to return the last occurrence in the month * @return {Date} this */ $P.moveToNthOccurrence = function (dayOfWeek, occurrence) { if (dayOfWeek === "Weekday") { if (occurrence > 0) { this.moveToFirstDayOfMonth(); if (this.is().weekday()) { occurrence -= 1; } } else if (occurrence < 0) { this.moveToLastDayOfMonth(); if (this.is().weekday()) { occurrence += 1; } } else { return this; } return this.addWeekdays(occurrence); } var shift = 0; if (occurrence > 0) { shift = occurrence - 1; } else if (occurrence === -1) { this.moveToLastDayOfMonth(); if (this.getDay() !== dayOfWeek) { this.moveToDayOfWeek(dayOfWeek, -1); } return this; } return this.moveToFirstDayOfMonth().addDays(-1).moveToDayOfWeek(dayOfWeek, +1).addWeeks(shift); }; var moveToN = function (getFunc, addFunc, nVal) { return function (value, orient) { var diff = (value - this[getFunc]() + nVal * (orient || +1)) % nVal; return this[addFunc]((diff === 0) ? diff += nVal * (orient || +1) : diff); }; }; /** * Move to the next or last dayOfWeek based on the orient value. * @param {Number} The dayOfWeek to move to * @param {Number} Forward (+1) or Back (-1). Defaults to +1. [Optional] * @return {Date} this */ $P.moveToDayOfWeek = moveToN("getDay", "addDays", 7); /** * Move to the next or last month based on the orient value. * @param {Number} The month to move to. 0 = January, 11 = December * @param {Number} Forward (+1) or Back (-1). Defaults to +1. [Optional] * @return {Date} this */ $P.moveToMonth = moveToN("getMonth", "addMonths", 12); /** * Get the Ordinate of the current day ("th", "st", "rd"). * @return {String} */ $P.getOrdinate = function () { var num = this.getDate(); return ord(num); }; /** * Get the Ordinal day (numeric day number) of the year, adjusted for leap year. * @return {Number} 1 through 365 (366 in leap years) */ $P.getOrdinalNumber = function () { return Math.ceil((this.clone().clearTime() - new Date(this.getFullYear(), 0, 1)) / 86400000) + 1; }; /** * Get the time zone abbreviation of the current date. * @return {String} The abbreviated time zone name (e.g. "EST") */ $P.getTimezone = function () { return $D.getTimezoneAbbreviation(this.getUTCOffset(), this.isDaylightSavingTime()); }; $P.setTimezoneOffset = function (offset) { var here = this.getTimezoneOffset(), there = Number(offset) * -6 / 10; return (there || there === 0) ? this.addMinutes(there - here) : this; }; $P.setTimezone = function (offset) { return this.setTimezoneOffset($D.getTimezoneOffset(offset)); }; /** * Indicates whether Daylight Saving Time is observed in the current time zone. * @return {Boolean} true|false */ $P.hasDaylightSavingTime = function () { return (Date.today().set({month: 0, day: 1}).getTimezoneOffset() !== Date.today().set({month: 6, day: 1}).getTimezoneOffset()); }; /** * Indicates whether this Date instance is within the Daylight Saving Time range for the current time zone. * @return {Boolean} true|false */ $P.isDaylightSavingTime = function () { return Date.today().set({month: 0, day: 1}).getTimezoneOffset() !== this.getTimezoneOffset(); }; /** * Get the offset from UTC of the current date. * @return {String} The 4-character offset string prefixed with + or - (e.g. "-0500") */ $P.getUTCOffset = function (offset) { var n = (offset || this.getTimezoneOffset()) * -10 / 6, r; if (n < 0) { r = (n - 10000).toString(); return r.charAt(0) + r.substr(2); } else { r = (n + 10000).toString(); return "+" + r.substr(1); } }; /** * Returns the number of milliseconds between this date and date. * @param {Date} Defaults to now * @return {Number} The diff in milliseconds */ $P.getElapsed = function (date) { return (date || new Date()) - this; }; /** * Set the value of year, month, day, hour, minute, second, millisecond of date instance using given configuration object. * Example

	Date.today().set( { day: 20, month: 1 } )

	new Date().set( { millisecond: 0 } )
	
* * @param {Object} Configuration object containing attributes (month, day, etc.) * @return {Date} this */ $P.set = function (config) { config = validateConfigObject.call(this, config); var key; for (key in config) { if (Object.prototype.hasOwnProperty.call(config, key)) { var name = key.charAt(0).toUpperCase() + key.slice(1); var addFunc, getFunc; if (key !== "week" && key !== "month" && key !== "timezone" && key !== "timezoneOffset") { name += "s"; } addFunc = "add" + name; getFunc = "get" + name; if (key === "month") { addFunc = addFunc + "s"; } else if (key === "year"){ getFunc = "getFullYear"; } if (key !== "day" && key !== "timezone" && key !== "timezoneOffset" && key !== "week" && key !== "hour") { this[addFunc](config[key] - this[getFunc]()); } else if ( key === "timezone"|| key === "timezoneOffset" || key === "week" || key === "hour") { this["set"+name](config[key]); } } } // day has to go last because you can't validate the day without first knowing the month if (config.day) { this.addDays(config.day - this.getDate()); } return this; }; /** * Moves the date to the first day of the month. * @return {Date} this */ $P.moveToFirstDayOfMonth = function () { return this.set({ day: 1 }); }; /** * Moves the date to the last day of the month. * @return {Date} this */ $P.moveToLastDayOfMonth = function () { return this.set({ day: $D.getDaysInMonth(this.getFullYear(), this.getMonth())}); }; /** * Converts the value of the current Date object to its equivalent string representation. * Format Specifiers * CUSTOM DATE AND TIME FORMAT STRINGS * Format Description Example * ------ --------------------------------------------------------------------------- ----------------------- * s The seconds of the minute between 0-59. "0" to "59" * ss The seconds of the minute with leading zero if required. "00" to "59" * * m The minute of the hour between 0-59. "0" or "59" * mm The minute of the hour with leading zero if required. "00" or "59" * * h The hour of the day between 1-12. "1" to "12" * hh The hour of the day with leading zero if required. "01" to "12" * * H The hour of the day between 0-23. "0" to "23" * HH The hour of the day with leading zero if required. "00" to "23" * * d The day of the month between 1 and 31. "1" to "31" * dd The day of the month with leading zero if required. "01" to "31" * ddd Abbreviated day name. Date.CultureInfo.abbreviatedDayNames. "Mon" to "Sun" * dddd The full day name. Date.CultureInfo.dayNames. "Monday" to "Sunday" * * M The month of the year between 1-12. "1" to "12" * MM The month of the year with leading zero if required. "01" to "12" * MMM Abbreviated month name. Date.CultureInfo.abbreviatedMonthNames. "Jan" to "Dec" * MMMM The full month name. Date.CultureInfo.monthNames. "January" to "December" * * yy The year as a two-digit number. "99" or "08" * yyyy The full four digit year. "1999" or "2008" * * t Displays the first character of the A.M./P.M. designator. "A" or "P" * Date.CultureInfo.amDesignator or Date.CultureInfo.pmDesignator * tt Displays the A.M./P.M. designator. "AM" or "PM" * Date.CultureInfo.amDesignator or Date.CultureInfo.pmDesignator * * S The ordinal suffix ("st, "nd", "rd" or "th") of the current day. "st, "nd", "rd" or "th" * * STANDARD DATE AND TIME FORMAT STRINGS * Format Description Example *------ --------------------------------------------------------------------------- ----------------------- * d The CultureInfo shortDate Format Pattern "M/d/yyyy" * D The CultureInfo longDate Format Pattern "dddd, MMMM dd, yyyy" * F The CultureInfo fullDateTime Format Pattern "dddd, MMMM dd, yyyy h:mm:ss tt" * m The CultureInfo monthDay Format Pattern "MMMM dd" * r The CultureInfo rfc1123 Format Pattern "ddd, dd MMM yyyy HH:mm:ss GMT" * s The CultureInfo sortableDateTime Format Pattern "yyyy-MM-ddTHH:mm:ss" * t The CultureInfo shortTime Format Pattern "h:mm tt" * T The CultureInfo longTime Format Pattern "h:mm:ss tt" * u The CultureInfo universalSortableDateTime Format Pattern "yyyy-MM-dd HH:mm:ssZ" * y The CultureInfo yearMonth Format Pattern "MMMM, yyyy" * * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @return {String} A string representation of the current Date object. */ var ord = function (n) { switch (n * 1) { case 1: case 21: case 31: return "st"; case 2: case 22: return "nd"; case 3: case 23: return "rd"; default: return "th"; } }; var parseStandardFormats = function (format) { var y, c = Date.CultureInfo.formatPatterns; switch (format) { case "d": return this.toString(c.shortDate); case "D": return this.toString(c.longDate); case "F": return this.toString(c.fullDateTime); case "m": return this.toString(c.monthDay); case "r": case "R": y = this.clone().addMinutes(this.getTimezoneOffset()); return y.toString(c.rfc1123) + " GMT"; case "s": return this.toString(c.sortableDateTime); case "t": return this.toString(c.shortTime); case "T": return this.toString(c.longTime); case "u": y = this.clone().addMinutes(this.getTimezoneOffset()); return y.toString(c.universalSortableDateTime); case "y": return this.toString(c.yearMonth); default: return false; } }; var parseFormatStringsClosure = function (context) { return function (m) { if (m.charAt(0) === "\\") { return m.replace("\\", ""); } switch (m) { case "hh": return p(context.getHours() < 13 ? (context.getHours() === 0 ? 12 : context.getHours()) : (context.getHours() - 12)); case "h": return context.getHours() < 13 ? (context.getHours() === 0 ? 12 : context.getHours()) : (context.getHours() - 12); case "HH": return p(context.getHours()); case "H": return context.getHours(); case "mm": return p(context.getMinutes()); case "m": return context.getMinutes(); case "ss": return p(context.getSeconds()); case "s": return context.getSeconds(); case "yyyy": return p(context.getFullYear(), 4); case "yy": return p(context.getFullYear()); case "y": return context.getFullYear(); case "E": case "dddd": return Date.CultureInfo.dayNames[context.getDay()]; case "ddd": return Date.CultureInfo.abbreviatedDayNames[context.getDay()]; case "dd": return p(context.getDate()); case "d": return context.getDate(); case "MMMM": return Date.CultureInfo.monthNames[context.getMonth()]; case "MMM": return Date.CultureInfo.abbreviatedMonthNames[context.getMonth()]; case "MM": return p((context.getMonth() + 1)); case "M": return context.getMonth() + 1; case "t": return context.getHours() < 12 ? Date.CultureInfo.amDesignator.substring(0, 1) : Date.CultureInfo.pmDesignator.substring(0, 1); case "tt": return context.getHours() < 12 ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator; case "S": return ord(context.getDate()); case "W": return context.getWeek(); case "WW": return context.getISOWeek(); case "Q": return "Q" + context.getQuarter(); case "q": return String(context.getQuarter()); case "z": return context.getTimezone(); case "Z": case "X": return Date.getTimezoneOffset(context.getTimezone()); case "ZZ": // Timezone offset in seconds return context.getTimezoneOffset() * -60; case "u": return context.getDay(); case "L": return ($D.isLeapYear(context.getFullYear())) ? 1 : 0; case "B": // Swatch Internet Time (.beats) return "@"+((context.getUTCSeconds() + (context.getUTCMinutes()*60) + ((context.getUTCHours()+1)*3600))/86.4); default: return m; } }; }; $P.toString = function (format, ignoreStandards) { // Standard Date and Time Format Strings. Formats pulled from CultureInfo file and // may vary by culture. if (!ignoreStandards && format && format.length === 1) { output = parseStandardFormats.call(this, format); if (output) { return output; } } var parseFormatStrings = parseFormatStringsClosure(this); return format ? format.replace(/((\\)?(dd?d?d?|MM?M?M?|yy?y?y?|hh?|HH?|mm?|ss?|tt?|S|q|Q|WW?W?W?)(?![^\[]*\]))/g, parseFormatStrings).replace(/\[|\]/g, "") : this._toString(); }; }()); /************************************************************* * SugarPak - Domain Specific Language - Syntactical Sugar * *************************************************************/ (function () { var $D = Date, $P = $D.prototype, $N = Number.prototype; // private $P._orient = +1; // private $P._nth = null; // private $P._is = false; // private $P._same = false; // private $P._isSecond = false; // private $N._dateElement = "days"; /** * Moves the date to the next instance of a date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.today().next().friday();
	Date.today().next().fri();
	Date.today().next().march();
	Date.today().next().mar();
	Date.today().next().week();
	
* * @return {Date} date */ $P.next = function () { this._move = true; this._orient = +1; return this; }; /** * Creates a new Date (Date.today()) and moves the date to the next instance of the date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.next().friday();
	Date.next().fri();
	Date.next().march();
	Date.next().mar();
	Date.next().week();
	
* * @return {Date} date */ $D.next = function () { return $D.today().next(); }; /** * Moves the date to the previous instance of a date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.today().last().friday();
	Date.today().last().fri();
	Date.today().last().march();
	Date.today().last().mar();
	Date.today().last().week();
	
* * @return {Date} date */ $P.last = $P.prev = $P.previous = function () { this._move = true; this._orient = -1; return this; }; /** * Creates a new Date (Date.today()) and moves the date to the previous instance of the date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.last().friday();
	Date.last().fri();
	Date.previous().march();
	Date.prev().mar();
	Date.last().week();
	
* * @return {Date} date */ $D.last = $D.prev = $D.previous = function () { return $D.today().last(); }; /** * Performs a equality check when followed by either a month name, day name or .weekday() function. * Example

	Date.today().is().friday(); // true|false
	Date.today().is().fri();
	Date.today().is().march();
	Date.today().is().mar();
	
* * @return {Boolean} true|false */ $P.is = function () { this._is = true; return this; }; /** * Determines if two date objects occur on/in exactly the same instance of the subsequent date part function. * The function .same() must be followed by a date part function (example: .day(), .month(), .year(), etc). * * An optional Date can be passed in the date part function. If now date is passed as a parameter, 'Now' is used. * * The following example demonstrates how to determine if two dates fall on the exact same day. * * Example

	var d1 = Date.today(); // today at 00:00
	var d2 = new Date();   // exactly now.

	// Do they occur on the same day?
	d1.same().day(d2); // true
	
	// Do they occur on the same hour?
	d1.same().hour(d2); // false, unless d2 hour is '00' (midnight).
	
	// What if it's the same day, but one year apart?
	var nextYear = Date.today().add(1).year();

	d1.same().day(nextYear); // false, because the dates must occur on the exact same day. 
	
* * Scenario: Determine if a given date occurs during some week period 2 months from now. * * Example

	var future = Date.today().add(2).months();
	return someDate.same().week(future); // true|false;
	
* * @return {Boolean} true|false */ $P.same = function () { this._same = true; this._isSecond = false; return this; }; /** * Determines if the current date/time occurs during Today. Must be preceded by the .is() function. * Example

	someDate.is().today();    // true|false
	new Date().is().today();  // true
	Date.today().is().today();// true
	Date.today().add(-1).day().is().today(); // false
	
* * @return {Boolean} true|false */ $P.today = function () { return this.same().day(); }; /** * Determines if the current date is a weekday. This function must be preceded by the .is() function. * Example

	Date.today().is().weekday(); // true|false
	
* * @return {Boolean} true|false */ $P.weekday = function () { if (this._nth) { return df("Weekday").call(this); } if (this._move) { return this.addWeekdays(this._orient); } if (this._is) { this._is = false; return (!this.is().sat() && !this.is().sun()); } return false; }; /** * Determines if the current date is on the weekend. This function must be preceded by the .is() function. * Example

	Date.today().is().weekend(); // true|false
	
* * @return {Boolean} true|false */ $P.weekend = function () { if (this._is) { this._is = false; return (this.is().sat() || this.is().sun()); } return false; }; /** * Sets the Time of the current Date instance. A string "6:15 pm" or config object {hour:18, minute:15} are accepted. * Example

	// Set time to 6:15pm with a String
	Date.today().at("6:15pm");

	// Set time to 6:15pm with a config object
	Date.today().at({hour:18, minute:15});
	
* * @return {Date} date */ $P.at = function (time) { return (typeof time === "string") ? $D.parse(this.toString("d") + " " + time) : this.set(time); }; /** * Creates a new Date() and adds this (Number) to the date based on the preceding date element function (eg. second|minute|hour|day|month|year). * Example

	// Undeclared Numbers must be wrapped with parentheses. Requirment of JavaScript.
	(3).days().fromNow();
	(6).months().fromNow();

	// Declared Number variables do not require parentheses. 
	var n = 6;
	n.months().fromNow();
	
* * @return {Date} A new Date instance */ $N.fromNow = $N.after = function (date) { var c = {}; c[this._dateElement] = this; return ((!date) ? new Date() : date.clone()).add(c); }; /** * Creates a new Date() and subtract this (Number) from the date based on the preceding date element function (eg. second|minute|hour|day|month|year). * Example

	// Undeclared Numbers must be wrapped with parentheses. Requirment of JavaScript.
	(3).days().ago();
	(6).months().ago();

	// Declared Number variables do not require parentheses. 
	var n = 6;
	n.months().ago();
	
* * @return {Date} A new Date instance */ $N.ago = $N.before = function (date) { var c = {}, s = (this._dateElement[this._dateElement.length-1] !== "s") ? this._dateElement + "s" : this._dateElement; c[s] = this * -1; return ((!date) ? new Date() : date.clone()).add(c); }; // Do NOT modify the following string tokens. These tokens are used to build dynamic functions. // All culture-specific strings can be found in the CultureInfo files. var dx = ("sunday monday tuesday wednesday thursday friday saturday").split(/\s/), mx = ("january february march april may june july august september october november december").split(/\s/), px = ("Millisecond Second Minute Hour Day Week Month Year Quarter Weekday").split(/\s/), pxf = ("Milliseconds Seconds Minutes Hours Date Week Month FullYear Quarter").split(/\s/), nth = ("final first second third fourth fifth").split(/\s/), de; /** * Returns an object literal of all the date parts. * Example

	var o = new Date().toObject();
	
	// { year: 2008, month: 4, week: 20, day: 13, hour: 18, minute: 9, second: 32, millisecond: 812 }
	
	// The object properties can be referenced directly from the object.
	
	alert(o.day);  // alerts "13"
	alert(o.year); // alerts "2008"
	
* * @return {Date} An object literal representing the original date object. */ $P.toObject = function () { var o = {}; for (var i = 0; i < px.length; i++) { if (this["get" + pxf[i]]) { o[px[i].toLowerCase()] = this["get" + pxf[i]](); } } return o; }; /** * Returns a date created from an object literal. Ignores the .week property if set in the config. * Example

	var o = new Date().toObject();
	
	return Date.fromObject(o); // will return the same date. 

	var o2 = {month: 1, day: 20, hour: 18}; // birthday party!
	Date.fromObject(o2);
	
* * @return {Date} An object literal representing the original date object. */ $D.fromObject = function(config) { config.week = null; return Date.today().set(config); }; // Create day name functions and abbreviated day name functions (eg. monday(), friday(), fri()). var df = function (n) { return function () { if (this._is) { this._is = false; return this.getDay() === n; } if (this._move) { this._move = null; } if (this._nth !== null) { // If the .second() function was called earlier, remove the _orient // from the date, and then continue. // This is required because 'second' can be used in two different context. // // Example // // Date.today().add(1).second(); // Date.march().second().monday(); // // Things get crazy with the following... // Date.march().add(1).second().second().monday(); // but it works!! // if (this._isSecond) { this.addSeconds(this._orient * -1); } // make sure we reset _isSecond this._isSecond = false; var ntemp = this._nth; this._nth = null; var temp = this.clone().moveToLastDayOfMonth(); this.moveToNthOccurrence(n, ntemp); if (this > temp) { throw new RangeError($D.getDayName(n) + " does not occur " + ntemp + " times in the month of " + $D.getMonthName(temp.getMonth()) + " " + temp.getFullYear() + "."); } return this; } return this.moveToDayOfWeek(n, this._orient); }; }; var sdf = function (n) { return function () { var t = $D.today(), shift = n - t.getDay(); if (n === 0 && Date.CultureInfo.firstDayOfWeek === 1 && t.getDay() !== 0) { shift = shift + 7; } return t.addDays(shift); }; }; // Create month name functions and abbreviated month name functions (eg. january(), march(), mar()). var month_instance_functions = function (n) { return function () { if (this._is) { this._is = false; return this.getMonth() === n; } return this.moveToMonth(n, this._orient); }; }; var month_static_functions = function (n) { return function () { return $D.today().set({ month: n, day: 1 }); }; }; var processTerms = function (names, staticFunc, instanceFunc) { for (var i = 0; i < names.length; i++) { // Create constant static Name variables. $D[names[i].toUpperCase()] = $D[names[i].toUpperCase().substring(0, 3)] = i; // Create Name functions. $D[names[i]] = $D[names[i].substring(0, 3)] = staticFunc(i); // Create Name instance functions. $P[names[i]] = $P[names[i].substring(0, 3)] = instanceFunc(i); } }; processTerms(dx, sdf, df); processTerms(mx, month_static_functions, month_instance_functions); // Create date element functions and plural date element functions used with Date (eg. day(), days(), months()). var ef = function (j) { return function () { // if the .second() function was called earlier, the _orient // has alread been added. Just return this and reset _isSecond. if (this._isSecond) { this._isSecond = false; return this; } if (this._same) { this._same = this._is = false; var o1 = this.toObject(), o2 = (arguments[0] || new Date()).toObject(), v = "", k = j.toLowerCase(); // the substr trick with -1 doesn't work in IE8 or less k = (k[k.length-1] === "s") ? k.substring(0,k.length-1) : k; for (var m = (px.length - 1); m > -1; m--) { v = px[m].toLowerCase(); if (o1[v] !== o2[v]) { return false; } if (k === v) { break; } } return true; } if (j.substring(j.length - 1) !== "s") { j += "s"; } if (this._move) { this._move = null; } return this["add" + j](this._orient); }; }; var nf = function (n) { return function () { this._dateElement = n; return this; }; }; for (var k = 0; k < px.length; k++) { de = px[k].toLowerCase(); if(de !== "weekday") { // Create date element functions and plural date element functions used with Date (eg. day(), days(), months()). $P[de] = $P[de + "s"] = ef(px[k]); // Create date element functions and plural date element functions used with Number (eg. day(), days(), months()). $N[de] = $N[de + "s"] = nf(de + "s"); } } $P._ss = ef("Second"); var nthfn = function (n) { return function (dayOfWeek) { if (this._same) { return this._ss(arguments[0]); } if (dayOfWeek || dayOfWeek === 0) { return this.moveToNthOccurrence(dayOfWeek, n); } this._nth = n; // if the operator is 'second' add the _orient, then deal with it later... if (n === 2 && (dayOfWeek === undefined || dayOfWeek === null)) { this._isSecond = true; return this.addSeconds(this._orient); } return this; }; }; for (var l = 0; l < nth.length; l++) { $P[nth[l]] = (l === 0) ? nthfn(-1) : nthfn(l); } }()); (function () { "use strict"; Date.Parsing = { Exception: function (s) { this.message = "Parse error at '" + s.substring(0, 10) + " ...'"; } }; var $P = Date.Parsing; var dayOffsets = { standard: [0,31,59,90,120,151,181,212,243,273,304,334], leap: [0,31,60,91,121,152,182,213,244,274,305,335] }; $P.isLeapYear = function(year) { return ((year % 4 === 0) && (year % 100 !== 0)) || (year % 400 === 0); }; var utils = { multiReplace : function (str, hash ) { var key; for (key in hash) { if (Object.prototype.hasOwnProperty.call(hash, key)) { var regex; if (typeof hash[key] === "function") { } else { regex = (hash[key] instanceof RegExp) ? hash[key] : new RegExp(hash[key], "g"); } str = str.replace(regex, key); } } return str; }, getDayOfYearFromWeek : function (obj) { var d, jan4, offset; obj.weekDay = (!obj.weekDay && obj.weekDay !== 0) ? 1 : obj.weekDay; d = new Date(obj.year, 0, 4); jan4 = d.getDay() === 0 ? 7 : d.getDay(); // JS is 0 indexed on Sunday. offset = jan4+3; obj.dayOfYear = ((obj.week * 7) + (obj.weekDay === 0 ? 7 : obj.weekDay))-offset; return obj; }, getDayOfYear : function (obj, dayOffset) { if (!obj.dayOfYear) { obj = utils.getDayOfYearFromWeek(obj); } for (var i=0;i <= dayOffset.length;i++) { if (obj.dayOfYear < dayOffset[i] || i === dayOffset.length) { obj.day = obj.day ? obj.day : (obj.dayOfYear - dayOffset[i-1]); break; } else { obj.month = i; } } return obj; }, adjustForTimeZone : function (obj, date) { var offset; if (obj.zone.toUpperCase() === "Z" || (obj.zone_hours === 0 && obj.zone_minutes === 0)) { // it's UTC/GML so work out the current timeszone offset offset = -date.getTimezoneOffset(); } else { offset = (obj.zone_hours*60) + (obj.zone_minutes || 0); if (obj.zone_sign === "+") { offset *= -1; } offset -= date.getTimezoneOffset(); } date.setMinutes(date.getMinutes()+offset); return date; }, setDefaults : function (obj) { obj.year = obj.year || Date.today().getFullYear(); obj.hours = obj.hours || 0; obj.minutes = obj.minutes || 0; obj.seconds = obj.seconds || 0; obj.milliseconds = obj.milliseconds || 0; if (!(!obj.month && (obj.week || obj.dayOfYear))) { // if we have a month, or if we don't but don't have the day calculation data obj.month = obj.month || 0; obj.day = obj.day || 1; } return obj; }, dataNum: function (data, mod, explict, postProcess) { var dataNum = data*1; if (mod) { if (postProcess) { return data ? mod(data)*1 : data; } else { return data ? mod(dataNum) : data; } } else if (!explict){ return data ? dataNum : data; } else { return (data && typeof data !== "undefined") ? dataNum : data; } }, timeDataProcess: function (obj) { var timeObj = {}; for (var x in obj.data) { if (obj.data.hasOwnProperty(x)) { timeObj[x] = obj.ignore[x] ? obj.data[x] : utils.dataNum(obj.data[x], obj.mods[x], obj.explict[x], obj.postProcess[x]); } } if (obj.data.secmins) { obj.data.secmins = obj.data.secmins.replace(",", ".") * 60; if (!timeObj.minutes) { timeObj.minutes = obj.data.secmins; } else if (!timeObj.seconds) { timeObj.seconds = obj.data.secmins; } delete obj.secmins; } return timeObj; }, buildTimeObjectFromData: function (data) { var time = utils.timeDataProcess({ data: { year : data[1], month : data[5], day : data[7], week : data[8], dayOfYear : data[10], hours : data[15], zone_hours : data[23], zone_minutes : data[24], zone : data[21], zone_sign : data[22], weekDay : data[9], minutes: data[16], seconds: data[19], milliseconds: data[20], secmins: data[18] }, mods: { month: function(data) { return data-1; }, weekDay: function (data) { data = Math.abs(data); return (data === 7 ? 0 : data); }, minutes: function (data) { return data.replace(":",""); }, seconds: function (data) { return Math.floor( (data.replace(":","").replace(",","."))*1 ); }, milliseconds: function (data) { return (data.replace(",",".")*1000); } }, postProcess: { minutes: true, seconds: true, milliseconds: true }, explict: { zone_hours: true, zone_minutes: true }, ignore: { zone: true, zone_sign: true, secmins: true } }); return time; }, addToHash: function (hash, keys, data) { keys = keys; data = data; var len = keys.length; for (var i = 0; i < len; i++) { hash[keys[i]] = data[i]; } return hash; }, combineRegex: function (r1, r2) { return new RegExp("(("+r1.source+")\\s("+r2.source+"))"); }, getDateNthString: function(add, last, inc){ if (add) { return Date.today().addDays(inc).toString("d"); } else if (last) { return Date.today().last()[inc]().toString("d"); } }, buildRegexData: function (array) { var arr = []; var len = array.length; for (var i=0; i < len; i++) { if (Object.prototype.toString.call(array[i]) === '[object Array]') { // oldIE compat version of Array.isArray arr.push(this.combineRegex(array[i][0], array[i][1])); } else { arr.push(array[i]); } } return arr; } }; $P.processTimeObject = function (obj) { var date, dayOffset; utils.setDefaults(obj); dayOffset = ($P.isLeapYear(obj.year)) ? dayOffsets.leap : dayOffsets.standard; if (!obj.month && (obj.week || obj.dayOfYear)) { utils.getDayOfYear(obj, dayOffset); } else { obj.dayOfYear = dayOffset[obj.month] + obj.day; } date = new Date(obj.year, obj.month, obj.day, obj.hours, obj.minutes, obj.seconds, obj.milliseconds); if (obj.zone) { utils.adjustForTimeZone(obj, date); // adjust (and calculate) for timezone } return date; }; $P.ISO = { regex : /^([\+-]?\d{4}(?!\d{2}\b))((-?)((0[1-9]|1[0-2])(\3([12]\d|0[1-9]|3[01]))?|W([0-4]\d|5[0-3])(-?[1-7])?|(00[1-9]|0[1-9]\d|[12]\d{2}|3([0-5]\d|6[1-6])))([T\s]((([01]\d|2[0-4])((:?)[0-5]\d)?|24\:?00)([\.,]\d+(?!:))?)?(\17[0-5]\d([\.,]\d+)?)?\s?([zZ]|([\+-])([01]\d|2[0-3]):?([0-5]\d)?)?)?)?$/, parse : function (s) { var time, data = s.match(this.regex); if (!data || !data.length) { return null; } time = utils.buildTimeObjectFromData(data); if (!time.year || (!time.year && (!time.month && !time.day) && (!time.week && !time.dayOfYear)) ) { return null; } return $P.processTimeObject(time); } }; $P.Numeric = { isNumeric: function (e){return!isNaN(parseFloat(e))&&isFinite(e);}, regex: /\b([0-1]?[0-9])([0-3]?[0-9])([0-2]?[0-9]?[0-9][0-9])\b/i, parse: function (s) { var data, i, time = {}, order = Date.CultureInfo.dateElementOrder.split(""); if (!(this.isNumeric(s)) || // if it's non-numeric OR (s[0] === "+" && s[0] === "-")) { // It's an arithmatic string (eg +/-1000) return null; } if (s.length < 5 && s.indexOf(".") < 0 && s.indexOf("/") < 0) { // assume it's just a year. time.year = s; return $P.processTimeObject(time); } data = s.match(this.regex); if (!data || !data.length) { return null; } for (i=0; i < order.length; i++) { switch(order[i]) { case "d": time.day = data[i+1]; break; case "m": time.month = (data[i+1]-1); break; case "y": time.year = data[i+1]; break; } } return $P.processTimeObject(time); } }; $P.Normalizer = { regexData: function () { var $R = Date.CultureInfo.regexPatterns; return utils.buildRegexData([ $R.tomorrow, $R.yesterday, [$R.past, $R.mon], [$R.past, $R.tue], [$R.past, $R.wed], [$R.past, $R.thu], [$R.past, $R.fri], [$R.past, $R.sat], [$R.past, $R.sun] ]); }, basicReplaceHash : function() { var $R = Date.CultureInfo.regexPatterns; return { "January": $R.jan.source, "February": $R.feb, "March": $R.mar, "April": $R.apr, "May": $R.may, "June": $R.jun, "July": $R.jul, "August": $R.aug, "September": $R.sep, "October": $R.oct, "November": $R.nov, "December": $R.dec, "": /\bat\b/gi, " ": /\s{2,}/, "am": $R.inTheMorning, "9am": $R.thisMorning, "pm": $R.inTheEvening, "7pm":$R.thisEvening }; }, keys : function(){ return [ utils.getDateNthString(true, false, 1), // tomorrow utils.getDateNthString(true, false, -1), // yesterday utils.getDateNthString(false, true, "monday"), //last mon utils.getDateNthString(false, true, "tuesday"), //last tues utils.getDateNthString(false, true, "wednesday"), //last wed utils.getDateNthString(false, true, "thursday"), //last thurs utils.getDateNthString(false, true, "friday"), //last fri utils.getDateNthString(false, true, "saturday"), //last sat utils.getDateNthString(false, true, "sunday") //last sun ]; }, buildRegexFunctions: function () { var $R = Date.CultureInfo.regexPatterns; var __ = Date.i18n.__; var tomorrowRE = new RegExp("(\\b\\d\\d?("+__("AM")+"|"+__("PM")+")? )("+$R.tomorrow.source.slice(1)+")", "i"); // adapted tomorrow regex for AM PM relative dates var todayRE = new RegExp($R.today.source + "(?!\\s*([+-]))\\b"); // today, but excludes the math operators (eg "today + 2h") this.replaceFuncs = [ [todayRE, function (full) { return (full.length > 1) ? Date.today().toString("d") : full; }], [tomorrowRE, function(full, m1) { var t = Date.today().addDays(1).toString("d"); return (t + " " + m1); }], [$R.amThisMorning, function(str, am){return am;}], [$R.pmThisEvening, function(str, pm){return pm;}] ]; }, buildReplaceData: function () { this.buildRegexFunctions(); this.replaceHash = utils.addToHash(this.basicReplaceHash(), this.keys(), this.regexData()); }, stringReplaceFuncs: function (s) { for (var i=0; i < this.replaceFuncs.length; i++) { s = s.replace(this.replaceFuncs[i][0], this.replaceFuncs[i][1]); } return s; }, parse: function (s) { s = this.stringReplaceFuncs(s); s = utils.multiReplace(s, this.replaceHash); try { var n = s.split(/([\s\-\.\,\/\x27]+)/); if (n.length === 3 && $P.Numeric.isNumeric(n[0]) && $P.Numeric.isNumeric(n[2]) && (n[2].length >= 4)) { // ok, so we're dealing with x/year. But that's not a full date. // This fixes wonky dateElementOrder parsing when set to dmy order. if (Date.CultureInfo.dateElementOrder[0] === "d") { s = "1/" + n[0] + "/" + n[2]; // set to 1st of month and normalize the seperator } } } catch (e) {} return s; } }; $P.Normalizer.buildReplaceData(); }()); (function () { var $P = Date.Parsing; var _ = $P.Operators = { // // Tokenizers // rtoken: function (r) { // regex token return function (s) { var mx = s.match(r); if (mx) { return ([ mx[0], s.substring(mx[0].length) ]); } else { throw new $P.Exception(s); } }; }, token: function () { // whitespace-eating token return function (s) { return _.rtoken(new RegExp("^\\s*" + s + "\\s*"))(s); }; }, stoken: function (s) { // string token return _.rtoken(new RegExp("^" + s)); }, // Atomic Operators until: function (p) { return function (s) { var qx = [], rx = null; while (s.length) { try { rx = p.call(this, s); } catch (e) { qx.push(rx[0]); s = rx[1]; continue; } break; } return [ qx, s ]; }; }, many: function (p) { return function (s) { var rx = [], r = null; while (s.length) { try { r = p.call(this, s); } catch (e) { return [ rx, s ]; } rx.push(r[0]); s = r[1]; } return [ rx, s ]; }; }, // generator operators -- see below optional: function (p) { return function (s) { var r = null; try { r = p.call(this, s); } catch (e) { return [ null, s ]; } return [ r[0], r[1] ]; }; }, not: function (p) { return function (s) { try { p.call(this, s); } catch (e) { return [null, s]; } throw new $P.Exception(s); }; }, ignore: function (p) { return p ? function (s) { var r = null; r = p.call(this, s); return [null, r[1]]; } : null; }, product: function () { var px = arguments[0], qx = Array.prototype.slice.call(arguments, 1), rx = []; for (var i = 0 ; i < px.length ; i++) { rx.push(_.each(px[i], qx)); } return rx; }, cache: function (rule) { var cache = {}, cache_length = 0, cache_keys = [], CACHE_MAX = Date.Config.CACHE_MAX || 100000, r = null; var cacheCheck = function () { if (cache_length === CACHE_MAX) { // kill several keys, don't want to have to do this all the time... for (var i=0; i < 10; i++) { var key = cache_keys.shift(); if (key) { delete cache[key]; cache_length--; } } } }; return function (s) { cacheCheck(); try { r = cache[s] = (cache[s] || rule.call(this, s)); } catch (e) { r = cache[s] = e; } cache_length++; cache_keys.push(s); if (r instanceof $P.Exception) { throw r; } else { return r; } }; }, // vector operators -- see below any: function () { var px = arguments; return function (s) { var r = null; for (var i = 0; i < px.length; i++) { if (px[i] == null) { continue; } try { r = (px[i].call(this, s)); } catch (e) { r = null; } if (r) { return r; } } throw new $P.Exception(s); }; }, each: function () { var px = arguments; return function (s) { var rx = [], r = null; for (var i = 0; i < px.length ; i++) { if (px[i] == null) { continue; } try { r = (px[i].call(this, s)); } catch (e) { throw new $P.Exception(s); } rx.push(r[0]); s = r[1]; } return [ rx, s]; }; }, all: function () { var px = arguments, _ = _; return _.each(_.optional(px)); }, // delimited operators sequence: function (px, d, c) { d = d || _.rtoken(/^\s*/); c = c || null; if (px.length === 1) { return px[0]; } return function (s) { var r = null, q = null; var rx = []; for (var i = 0; i < px.length ; i++) { try { r = px[i].call(this, s); } catch (e) { break; } rx.push(r[0]); try { q = d.call(this, r[1]); } catch (ex) { q = null; break; } s = q[1]; } if (!r) { throw new $P.Exception(s); } if (q) { throw new $P.Exception(q[1]); } if (c) { try { r = c.call(this, r[1]); } catch (ey) { throw new $P.Exception(r[1]); } } return [ rx, (r?r[1]:s) ]; }; }, // // Composite Operators // between: function (d1, p, d2) { d2 = d2 || d1; var _fn = _.each(_.ignore(d1), p, _.ignore(d2)); return function (s) { var rx = _fn.call(this, s); return [[rx[0][0], r[0][2]], rx[1]]; }; }, list: function (p, d, c) { d = d || _.rtoken(/^\s*/); c = c || null; return (p instanceof Array ? _.each(_.product(p.slice(0, -1), _.ignore(d)), p.slice(-1), _.ignore(c)) : _.each(_.many(_.each(p, _.ignore(d))), px, _.ignore(c))); }, set: function (px, d, c) { d = d || _.rtoken(/^\s*/); c = c || null; return function (s) { // r is the current match, best the current 'best' match // which means it parsed the most amount of input var r = null, p = null, q = null, rx = null, best = [[], s], last = false; // go through the rules in the given set for (var i = 0; i < px.length ; i++) { // last is a flag indicating whether this must be the last element // if there is only 1 element, then it MUST be the last one q = null; p = null; r = null; last = (px.length === 1); // first, we try simply to match the current pattern // if not, try the next pattern try { r = px[i].call(this, s); } catch (e) { continue; } // since we are matching against a set of elements, the first // thing to do is to add r[0] to matched elements rx = [[r[0]], r[1]]; // if we matched and there is still input to parse and // we don't already know this is the last element, // we're going to next check for the delimiter ... // if there's none, or if there's no input left to parse // than this must be the last element after all ... if (r[1].length > 0 && ! last) { try { q = d.call(this, r[1]); } catch (ex) { last = true; } } else { last = true; } // if we parsed the delimiter and now there's no more input, // that means we shouldn't have parsed the delimiter at all // so don't update r and mark this as the last element ... if (!last && q[1].length === 0) { last = true; } // so, if this isn't the last element, we're going to see if // we can get any more matches from the remaining (unmatched) // elements ... if (!last) { // build a list of the remaining rules we can match against, // i.e., all but the one we just matched against var qx = []; for (var j = 0; j < px.length ; j++) { if (i !== j) { qx.push(px[j]); } } // now invoke recursively set with the remaining input // note that we don't include the closing delimiter ... // we'll check for that ourselves at the end p = _.set(qx, d).call(this, q[1]); // if we got a non-empty set as a result ... // (otw rx already contains everything we want to match) if (p[0].length > 0) { // update current result, which is stored in rx ... // basically, pick up the remaining text from p[1] // and concat the result from p[0] so that we don't // get endless nesting ... rx[0] = rx[0].concat(p[0]); rx[1] = p[1]; } } // at this point, rx either contains the last matched element // or the entire matched set that starts with this element. // now we just check to see if this variation is better than // our best so far, in terms of how much of the input is parsed if (rx[1].length < best[1].length) { best = rx; } // if we've parsed all the input, then we're finished if (best[1].length === 0) { break; } } // so now we've either gone through all the patterns trying them // as the initial match; or we found one that parsed the entire // input string ... // if best has no matches, just return empty set ... if (best[0].length === 0) { return best; } // if a closing delimiter is provided, then we have to check it also if (c) { // we try this even if there is no remaining input because the pattern // may well be optional or match empty input ... try { q = c.call(this, best[1]); } catch (ey) { throw new $P.Exception(best[1]); } // it parsed ... be sure to update the best match remaining input best[1] = q[1]; } // if we're here, either there was no closing delimiter or we parsed it // so now we have the best match; just return it! return best; }; }, forward: function (gr, fname) { return function (s) { return gr[fname].call(this, s); }; }, // // Translation Operators // replace: function (rule, repl) { return function (s) { var r = rule.call(this, s); return [repl, r[1]]; }; }, process: function (rule, fn) { return function (s) { var r = rule.call(this, s); return [fn.call(this, r[0]), r[1]]; }; }, min: function (min, rule) { return function (s) { var rx = rule.call(this, s); if (rx[0].length < min) { throw new $P.Exception(s); } return rx; }; } }; // Generator Operators And Vector Operators // Generators are operators that have a signature of F(R) => R, // taking a given rule and returning another rule, such as // ignore, which parses a given rule and throws away the result. // Vector operators are those that have a signature of F(R1,R2,...) => R, // take a list of rules and returning a new rule, such as each. // Generator operators are converted (via the following _generator // function) into functions that can also take a list or array of rules // and return an array of new rules as though the function had been // called on each rule in turn (which is what actually happens). // This allows generators to be used with vector operators more easily. // Example: // each(ignore(foo, bar)) instead of each(ignore(foo), ignore(bar)) // This also turns generators into vector operators, which allows // constructs like: // not(cache(foo, bar)) var _generator = function (op) { function gen() { var args = null, rx = [], px, i; if (arguments.length > 1) { args = Array.prototype.slice.call(arguments); } else if (arguments[0] instanceof Array) { args = arguments[0]; } if (args) { px = args.shift(); if (px.length > 0) { args.unshift(px[i]); rx.push(op.apply(null, args)); args.shift(); return rx; } } else { return op.apply(null, arguments); } } return gen; }; var gx = "optional not ignore cache".split(/\s/); for (var i = 0 ; i < gx.length ; i++) { _[gx[i]] = _generator(_[gx[i]]); } var _vector = function (op) { return function () { if (arguments[0] instanceof Array) { return op.apply(null, arguments[0]); } else { return op.apply(null, arguments); } }; }; var vx = "each any all".split(/\s/); for (var j = 0 ; j < vx.length ; j++) { _[vx[j]] = _vector(_[vx[j]]); } }()); (function () { var $D = Date; var flattenAndCompact = function (ax) { var rx = []; for (var i = 0; i < ax.length; i++) { if (ax[i] instanceof Array) { rx = rx.concat(flattenAndCompact(ax[i])); } else { if (ax[i]) { rx.push(ax[i]); } } } return rx; }; var parseMeridian = function () { if (this.meridian && (this.hour || this.hour === 0)) { if (this.meridian === "a" && this.hour > 11 && Date.Config.strict24hr){ throw "Invalid hour and meridian combination"; } else if (this.meridian === "p" && this.hour < 12 && Date.Config.strict24hr){ throw "Invalid hour and meridian combination"; } else if (this.meridian === "p" && this.hour < 12) { this.hour = this.hour + 12; } else if (this.meridian === "a" && this.hour === 12) { this.hour = 0; } } }; var setDefaults = function () { var now = new Date(); if ((this.hour || this.minute) && (!this.month && !this.year && !this.day)) { this.day = now.getDate(); } if (!this.year) { this.year = now.getFullYear(); } if (!this.month && this.month !== 0) { this.month = now.getMonth(); } if (!this.day) { this.day = 1; } if (!this.hour) { this.hour = 0; } if (!this.minute) { this.minute = 0; } if (!this.second) { this.second = 0; } if (!this.millisecond) { this.millisecond = 0; } }; var finishUtils = { getToday: function () { if (this.now || "hour minute second".indexOf(this.unit) !== -1) { return new Date(); } else { return $D.today(); } }, setDaysFromWeekday: function (today, orient){ var gap; orient = orient || 1; this.unit = "day"; gap = ($D.getDayNumberFromName(this.weekday) - today.getDay()); this.days = gap ? ((gap + (orient * 7)) % 7) : (orient * 7); return this; }, setMonthsFromMonth: function (today, orient) { var gap; orient = orient || 1; this.unit = "month"; gap = (this.month - today.getMonth()); this.months = gap ? ((gap + (orient * 12)) % 12) : (orient * 12); this.month = null; return this; }, setDMYFromWeekday: function () { var d = Date[this.weekday](); this.day = d.getDate(); if (!this.month) { this.month = d.getMonth(); } this.year = d.getFullYear(); return this; }, setUnitValue: function (orient) { if (!this.value && this.operator && this.operator !== null && this[this.unit + "s"] && this[this.unit + "s"] !== null) { this[this.unit + "s"] = this[this.unit + "s"] + ((this.operator === "add") ? 1 : -1) + (this.value||0) * orient; } else if (this[this.unit + "s"] == null || this.operator != null) { if (!this.value) { this.value = 1; } this[this.unit + "s"] = this.value * orient; } }, generateDateFromWeeks: function () { var weekday = (this.weekday !== undefined) ? this.weekday : "today"; var d = Date[weekday]().addWeeks(this.weeks); if (this.now) { d.setTimeToNow(); } return d; } }; $D.Translator = { hour: function (s) { return function () { this.hour = Number(s); }; }, minute: function (s) { return function () { this.minute = Number(s); }; }, second: function (s) { return function () { this.second = Number(s); }; }, /* for ss.s format */ secondAndMillisecond: function (s) { return function () { var mx = s.match(/^([0-5][0-9])\.([0-9]{1,3})/); this.second = Number(mx[1]); this.millisecond = Number(mx[2]); }; }, meridian: function (s) { return function () { this.meridian = s.slice(0, 1).toLowerCase(); }; }, timezone: function (s) { return function () { var n = s.replace(/[^\d\+\-]/g, ""); if (n.length) { this.timezoneOffset = Number(n); } else { this.timezone = s.toLowerCase(); } }; }, day: function (x) { var s = x[0]; return function () { this.day = Number(s.match(/\d+/)[0]); if (this.day < 1) { throw "invalid day"; } }; }, month: function (s) { return function () { this.month = (s.length === 3) ? "jan feb mar apr may jun jul aug sep oct nov dec".indexOf(s)/4 : Number(s) - 1; if (this.month < 0) { throw "invalid month"; } }; }, year: function (s) { return function () { var n = Number(s); this.year = ((s.length > 2) ? n : (n + (((n + 2000) < Date.CultureInfo.twoDigitYearMax) ? 2000 : 1900))); }; }, rday: function (s) { return function () { switch (s) { case "yesterday": this.days = -1; break; case "tomorrow": this.days = 1; break; case "today": this.days = 0; break; case "now": this.days = 0; this.now = true; break; } }; }, finishExact: function (x) { var d; x = (x instanceof Array) ? x : [x]; for (var i = 0 ; i < x.length ; i++) { if (x[i]) { x[i].call(this); } } setDefaults.call(this); parseMeridian.call(this); if (this.day > $D.getDaysInMonth(this.year, this.month)) { throw new RangeError(this.day + " is not a valid value for days."); } d = new Date(this.year, this.month, this.day, this.hour, this.minute, this.second, this.millisecond); if (this.year < 100) { d.setFullYear(this.year); // means years less that 100 are process correctly. JS will parse it otherwise as 1900-1999. } if (this.timezone) { d.set({ timezone: this.timezone }); } else if (this.timezoneOffset) { d.set({ timezoneOffset: this.timezoneOffset }); } return d; }, finish: function (x) { var today, expression, orient, temp; x = (x instanceof Array) ? flattenAndCompact(x) : [ x ]; if (x.length === 0) { return null; } for (var i = 0 ; i < x.length ; i++) { if (typeof x[i] === "function") { x[i].call(this); } } if (this.now && !this.unit && !this.operator) { return new Date(); } else { today = finishUtils.getToday.call(this); } expression = !!(this.days && this.days !== null || this.orient || this.operator); orient = ((this.orient === "past" || this.operator === "subtract") ? -1 : 1); if (this.month && this.unit === "week") { this.value = this.month + 1; delete this.month; delete this.day; } if ((this.month || this.month === 0) && "year day hour minute second".indexOf(this.unit) !== -1) { if (!this.value) { this.value = this.month + 1; } this.month = null; expression = true; } if (!expression && this.weekday && !this.day && !this.days) { finishUtils.setDMYFromWeekday.call(this); } if (expression && this.weekday && this.unit !== "month" && this.unit !== "week") { finishUtils.setDaysFromWeekday.call(this, today, orient); } if (this.weekday && this.unit !== "week" && !this.day && !this.days) { temp = Date[this.weekday](); this.day = temp.getDate(); if (temp.getMonth() !== today.getMonth()) { this.month = temp.getMonth(); } } if (this.month && this.unit === "day" && this.operator) { if (!this.value) { this.value = (this.month + 1); } this.month = null; } if (this.value != null && this.month != null && this.year != null) { this.day = this.value * 1; } if (this.month && !this.day && this.value) { today.set({ day: this.value * 1 }); if (!expression) { this.day = this.value * 1; } } if (!this.month && this.value && this.unit === "month" && !this.now) { this.month = this.value; expression = true; } if (expression && (this.month || this.month === 0) && this.unit !== "year") { finishUtils.setMonthsFromMonth.call(this, today, orient); } if (!this.unit) { this.unit = "day"; } finishUtils.setUnitValue.call(this, orient); parseMeridian.call(this); if ((this.month || this.month === 0) && !this.day) { this.day = 1; } if (!this.orient && !this.operator && this.unit === "week" && this.value && !this.day && !this.month) { return Date.today().setWeek(this.value); } if (this.unit === "week" && this.weeks && !this.day && !this.month) { return finishUtils.generateDateFromWeeks.call(this); } if (expression && this.timezone && this.day && this.days) { this.day = this.days; } if (expression){ today.add(this); } else { today.set(this); } if (this.timezone) { this.timezone = this.timezone.toUpperCase(); var offset = $D.getTimezoneOffset(this.timezone); var timezone; if (today.hasDaylightSavingTime()) { // lets check that we're being sane with timezone setting timezone = $D.getTimezoneAbbreviation(offset, today.isDaylightSavingTime()); if (timezone !== this.timezone) { // bugger, we're in a place where things like EST vs EDT matters. if (today.isDaylightSavingTime()) { today.addHours(-1); } else { today.addHours(1); } } } today.setTimezoneOffset(offset); } return today; } }; }()); (function () { var $D = Date; $D.Grammar = {}; var _ = $D.Parsing.Operators, g = $D.Grammar, t = $D.Translator, _fn; // Allow rolling up into general purpose rules _fn = function () { return _.each(_.any.apply(null, arguments), _.not(g.ctoken2("timeContext"))); }; g.datePartDelimiter = _.rtoken(/^([\s\-\.\,\/\x27]+)/); g.timePartDelimiter = _.stoken(":"); g.whiteSpace = _.rtoken(/^\s*/); g.generalDelimiter = _.rtoken(/^(([\s\,]|at|@|on)+)/); var _C = {}; g.ctoken = function (keys) { var fn = _C[keys]; if (! fn) { var c = Date.CultureInfo.regexPatterns; var kx = keys.split(/\s+/), px = []; for (var i = 0; i < kx.length ; i++) { px.push(_.replace(_.rtoken(c[kx[i]]), kx[i])); } fn = _C[keys] = _.any.apply(null, px); } return fn; }; g.ctoken2 = function (key) { return _.rtoken(Date.CultureInfo.regexPatterns[key]); }; var cacheProcessRtoken = function (key, token, type, eachToken) { if (eachToken) { g[key] = _.cache(_.process(_.each(_.rtoken(token),_.optional(g.ctoken2(eachToken))), type)); } else { g[key] = _.cache(_.process(_.rtoken(token), type)); } }; var cacheProcessCtoken = function (token, type) { return _.cache(_.process(g.ctoken2(token), type)); }; var _F = {}; //function cache var _get = function (f) { _F[f] = (_F[f] || g.format(f)[0]); return _F[f]; }; g.allformats = function (fx) { var rx = []; if (fx instanceof Array) { for (var i = 0; i < fx.length; i++) { rx.push(_get(fx[i])); } } else { rx.push(_get(fx)); } return rx; }; g.formats = function (fx) { if (fx instanceof Array) { var rx = []; for (var i = 0 ; i < fx.length ; i++) { rx.push(_get(fx[i])); } return _.any.apply(null, rx); } else { return _get(fx); } }; var grammarFormats = { timeFormats: function(){ var i, RTokenKeys = [ "h", "hh", "H", "HH", "m", "mm", "s", "ss", "ss.s", "z", "zz" ], RToken = [ /^(0[0-9]|1[0-2]|[1-9])/, /^(0[0-9]|1[0-2])/, /^([0-1][0-9]|2[0-3]|[0-9])/, /^([0-1][0-9]|2[0-3])/, /^([0-5][0-9]|[0-9])/, /^[0-5][0-9]/, /^([0-5][0-9]|[0-9])/, /^[0-5][0-9]/, /^[0-5][0-9]\.[0-9]{1,3}/, /^((\+|\-)\s*\d\d\d\d)|((\+|\-)\d\d\:?\d\d)/, /^((\+|\-)\s*\d\d\d\d)|((\+|\-)\d\d\:?\d\d)/ ], tokens = [ t.hour, t.hour, t.hour, t.hour, t.minute, t.minute, t.second, t.second, t.secondAndMillisecond, t.timezone, t.timezone ]; for (i=0; i < RTokenKeys.length; i++) { cacheProcessRtoken(RTokenKeys[i], RToken[i], tokens[i]); } g.hms = _.cache(_.sequence([g.H, g.m, g.s], g.timePartDelimiter)); g.t = cacheProcessCtoken("shortMeridian", t.meridian); g.tt = cacheProcessCtoken("longMeridian", t.meridian); g.zzz = cacheProcessCtoken("timezone", t.timezone); g.timeSuffix = _.each(_.ignore(g.whiteSpace), _.set([ g.tt, g.zzz ])); g.time = _.each(_.optional(_.ignore(_.stoken("T"))), g.hms, g.timeSuffix); }, dateFormats: function () { // pre-loaded rules for different date part order preferences var _setfn = function () { return _.set(arguments, g.datePartDelimiter); }; var i, RTokenKeys = [ "d", "dd", "M", "MM", "y", "yy", "yyy", "yyyy" ], RToken = [ /^([0-2]\d|3[0-1]|\d)/, /^([0-2]\d|3[0-1])/, /^(1[0-2]|0\d|\d)/, /^(1[0-2]|0\d)/, /^(\d+)/, /^(\d\d)/, /^(\d\d?\d?\d?)/, /^(\d\d\d\d)/ ], tokens = [ t.day, t.day, t.month, t.month, t.year, t.year, t.year, t.year ], eachToken = [ "ordinalSuffix", "ordinalSuffix" ]; for (i=0; i < RTokenKeys.length; i++) { cacheProcessRtoken(RTokenKeys[i], RToken[i], tokens[i], eachToken[i]); } g.MMM = g.MMMM = _.cache(_.process(g.ctoken("jan feb mar apr may jun jul aug sep oct nov dec"), t.month)); g.ddd = g.dddd = _.cache(_.process(g.ctoken("sun mon tue wed thu fri sat"), function (s) { return function () { this.weekday = s; }; } )); g.day = _fn(g.d, g.dd); g.month = _fn(g.M, g.MMM); g.year = _fn(g.yyyy, g.yy); g.mdy = _setfn(g.ddd, g.month, g.day, g.year); g.ymd = _setfn(g.ddd, g.year, g.month, g.day); g.dmy = _setfn(g.ddd, g.day, g.month, g.year); g.date = function (s) { return ((g[Date.CultureInfo.dateElementOrder] || g.mdy).call(this, s)); }; }, relative: function () { // relative date / time expressions g.orientation = _.process(g.ctoken("past future"), function (s) { return function () { this.orient = s; }; } ); g.operator = _.process(g.ctoken("add subtract"), function (s) { return function () { this.operator = s; }; } ); g.rday = _.process(g.ctoken("yesterday tomorrow today now"), t.rday); g.unit = _.process(g.ctoken("second minute hour day week month year"), function (s) { return function () { this.unit = s; }; } ); } }; g.buildGrammarFormats = function () { // these need to be rebuilt every time the language changes. _C = {}; grammarFormats.timeFormats(); grammarFormats.dateFormats(); grammarFormats.relative(); g.value = _.process(_.rtoken(/^([-+]?\d+)?(st|nd|rd|th)?/), function (s) { return function () { this.value = s.replace(/\D/g, ""); }; } ); g.expression = _.set([g.rday, g.operator, g.value, g.unit, g.orientation, g.ddd, g.MMM ]); g.format = _.process(_.many( _.any( // translate format specifiers into grammar rules _.process( _.rtoken(/^(dd?d?d?(?!e)|MM?M?M?|yy?y?y?|hh?|HH?|mm?|ss?|tt?|zz?z?)/), function (fmt) { if (g[fmt]) { return g[fmt]; } else { throw $D.Parsing.Exception(fmt); } } ), // translate separator tokens into token rules _.process(_.rtoken(/^[^dMyhHmstz]+/), // all legal separators function (s) { return _.ignore(_.stoken(s)); } ) ) ), // construct the parser ... function (rules) { return _.process(_.each.apply(null, rules), t.finishExact); } ); // starting rule for general purpose grammar g._start = _.process(_.set([ g.date, g.time, g.expression ], g.generalDelimiter, g.whiteSpace), t.finish); }; g.buildGrammarFormats(); // parsing date format specifiers - ex: "h:m:s tt" // this little guy will generate a custom parser based // on the format string, ex: g.format("h:m:s tt") // check for these formats first g._formats = g.formats([ "\"yyyy-MM-ddTHH:mm:ssZ\"", "yyyy-MM-ddTHH:mm:ss.sz", "yyyy-MM-ddTHH:mm:ssZ", "yyyy-MM-ddTHH:mm:ssz", "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-ddTHH:mmZ", "yyyy-MM-ddTHH:mmz", "yyyy-MM-ddTHH:mm", "ddd, MMM dd, yyyy H:mm:ss tt", "ddd MMM d yyyy HH:mm:ss zzz", "MMddyyyy", "ddMMyyyy", "Mddyyyy", "ddMyyyy", "Mdyyyy", "dMyyyy", "yyyy", "Mdyy", "dMyy", "d" ]); // real starting rule: tries selected formats first, // then general purpose rule g.start = function (s) { try { var r = g._formats.call({}, s); if (r[1].length === 0) { return r; } } catch (e) {} return g._start.call({}, s); }; }()); (function () { var $D = Date; /** * @desc Converts the specified string value into its JavaScript Date equivalent using CultureInfo specific format information. * * Example

	///////////
	// Dates //
	///////////

	// 15-Oct-2004
	var d1 = Date.parse("10/15/2004");

	// 15-Oct-2004
	var d1 = Date.parse("15-Oct-2004");

	// 15-Oct-2004
	var d1 = Date.parse("2004.10.15");

	//Fri Oct 15, 2004
	var d1 = Date.parse("Fri Oct 15, 2004");

	///////////
	// Times //
	///////////

	// Today at 10 PM.
	var d1 = Date.parse("10 PM");

	// Today at 10:30 PM.
	var d1 = Date.parse("10:30 P.M.");

	// Today at 6 AM.
	var d1 = Date.parse("06am");

	/////////////////////
	// Dates and Times //
	/////////////////////

	// 8-July-2004 @ 10:30 PM
	var d1 = Date.parse("July 8th, 2004, 10:30 PM");

	// 1-July-2004 @ 10:30 PM
	var d1 = Date.parse("2004-07-01T22:30:00");

	////////////////////
	// Relative Dates //
	////////////////////

	// Returns today's date. The string "today" is culture specific.
	var d1 = Date.parse("today");

	// Returns yesterday's date. The string "yesterday" is culture specific.
	var d1 = Date.parse("yesterday");

	// Returns the date of the next thursday.
	var d1 = Date.parse("Next thursday");

	// Returns the date of the most previous monday.
	var d1 = Date.parse("last monday");

	// Returns today's day + one year.
	var d1 = Date.parse("next year");

	///////////////
	// Date Math //
	///////////////

	// Today + 2 days
	var d1 = Date.parse("t+2");

	// Today + 2 days
	var d1 = Date.parse("today + 2 days");

	// Today + 3 months
	var d1 = Date.parse("t+3m");

	// Today - 1 year
	var d1 = Date.parse("today - 1 year");

	// Today - 1 year
	var d1 = Date.parse("t-1y"); 


	/////////////////////////////
	// Partial Dates and Times //
	/////////////////////////////

	// July 15th of this year.
	var d1 = Date.parse("July 15");

	// 15th day of current day and year.
	var d1 = Date.parse("15");

	// July 1st of current year at 10pm.
	var d1 = Date.parse("7/1 10pm");
	
* * @param {String} The string value to convert into a Date object [Required] * @return {Date} A Date object or null if the string cannot be converted into a Date. */ var parseUtils = { removeOrds: function (s) { ords = s.match(/\b(\d+)(?:st|nd|rd|th)\b/); // find ordinal matches s = ((ords && ords.length === 2) ? s.replace(ords[0], ords[1]) : s); return s; }, grammarParser: function (s) { var r = null; try { r = $D.Grammar.start.call({}, s.replace(/^\s*(\S*(\s+\S+)*)\s*$/, "$1")); } catch (e) { return null; } return ((r[1].length === 0) ? r[0] : null); }, nativeFallback: function(s) { var t; try { // ok we haven't parsed it, last ditch attempt with the built-in parser. t = Date._parse(s); return (t || t === 0) ? new Date(t) : null; } catch (e) { return null; } } }; function parse (s) { var d; if (!s) { return null; } if (s instanceof Date) { return s.clone(); } if (s.length >= 4 && s.charAt(0) !== "0" && s.charAt(0) !== "+"&& s.charAt(0) !== "-") { // ie: 2004 will pass, 0800 won't. // Start with specific formats d = $D.Parsing.ISO.parse(s) || $D.Parsing.Numeric.parse(s); } if (d instanceof Date && !isNaN(d.getTime())) { return d; } else { // find ordinal dates (1st, 3rd, 8th, etc and remove them as they cause parsing issues) s = $D.Parsing.Normalizer.parse(parseUtils.removeOrds(s)); d = parseUtils.grammarParser(s); if (d !== null) { return d; } else { return parseUtils.nativeFallback(s); } } } if (!$D._parse) { $D._parse = $D.parse; } $D.parse = parse; Date.getParseFunction = function (fx) { var fns = Date.Grammar.allformats(fx); return function (s) { var r = null; for (var i = 0; i < fns.length; i++) { try { r = fns[i].call({}, s); } catch (e) { continue; } if (r[1].length === 0) { return r[0]; } } return null; }; }; /** * Converts the specified string value into its JavaScript Date equivalent using the specified format {String} or formats {Array} and the CultureInfo specific format information. * The format of the string value must match one of the supplied formats exactly. * * Example

	// 15-Oct-2004
	var d1 = Date.parseExact("10/15/2004", "M/d/yyyy");

	// 15-Oct-2004
	var d1 = Date.parse("15-Oct-2004", "M-ddd-yyyy");

	// 15-Oct-2004
	var d1 = Date.parse("2004.10.15", "yyyy.MM.dd");

	// Multiple formats
	var d1 = Date.parseExact("10/15/2004", ["M/d/yyyy", "MMMM d, yyyy"]);
	
* * @param {String} The string value to convert into a Date object [Required]. * @param {Object} The expected format {String} or an array of expected formats {Array} of the date string [Required]. * @return {Date} A Date object or null if the string cannot be converted into a Date. */ $D.parseExact = function (s, fx) { return $D.getParseFunction(fx)(s); }; }()); (function () { var $D = Date, $P = $D.prototype, // $C = $D.CultureInfo, // not used atm p = function (s, l) { if (!l) { l = 2; } return ("000" + s).slice(l * -1); }; /** * Converts a PHP format string to Java/.NET format string. * A PHP format string can be used with ._format or .format. * A Java/.NET format string can be used with .toString(). * The .parseExact function will only accept a Java/.NET format string * * Example * var f1 = "%m/%d/%y" * var f2 = Date.normalizeFormat(f1); // "MM/dd/yy" * * new Date().format(f1); // "04/13/08" * new Date()._format(f1); // "04/13/08" * new Date().toString(f2); // "04/13/08" * * var date = Date.parseExact("04/13/08", f2); // Sun Apr 13 2008 * * @param {String} A PHP format string consisting of one or more format spcifiers. * @return {String} The PHP format converted to a Java/.NET format string. */ var normalizerSubstitutions = { "d" : "dd", "%d": "dd", "D" : "ddd", "%a": "ddd", "j" : "dddd", "l" : "dddd", "%A": "dddd", "S" : "S", "F" : "MMMM", "%B": "MMMM", "m" : "MM", "%m": "MM", "M" : "MMM", "%b": "MMM", "%h": "MMM", "n" : "M", "Y" : "yyyy", "%Y": "yyyy", "y" : "yy", "%y": "yy", "g" : "h", "%I": "h", "G" : "H", "h" : "hh", "H" : "HH", "%H": "HH", "i" : "mm", "%M": "mm", "s" : "ss", "%S": "ss", "%r": "hh:mm tt", "%R": "H:mm", "%T": "H:mm:ss", "%X": "t", "%x": "d", "%e": "d", "%D": "MM/dd/yy", "%n": "\\n", "%t": "\\t", "e" : "z", "T" : "z", "%z": "z", "%Z": "z", "Z" : "ZZ", "N" : "u", "w" : "u", "%w": "u", "W" : "W", "%V": "W" }; var normalizer = { substitutes: function (m) { return normalizerSubstitutions[m]; }, interpreted: function (m, x) { var y; switch (m) { case "%u": return x.getDay() + 1; case "z": return x.getOrdinalNumber(); case "%j": return p(x.getOrdinalNumber(), 3); case "%U": var d1 = x.clone().set({month: 0, day: 1}).addDays(-1).moveToDayOfWeek(0), d2 = x.clone().addDays(1).moveToDayOfWeek(0, -1); return (d2 < d1) ? "00" : p((d2.getOrdinalNumber() - d1.getOrdinalNumber()) / 7 + 1); case "%W": return p(x.getWeek()); case "t": return $D.getDaysInMonth(x.getFullYear(), x.getMonth()); case "o": case "%G": return x.setWeek(x.getISOWeek()).toString("yyyy"); case "%g": return x._format("%G").slice(-2); case "a": case "%p": return t("tt").toLowerCase(); case "A": return t("tt").toUpperCase(); case "u": return p(x.getMilliseconds(), 3); case "I": return (x.isDaylightSavingTime()) ? 1 : 0; case "O": return x.getUTCOffset(); case "P": y = x.getUTCOffset(); return y.substring(0, y.length - 2) + ":" + y.substring(y.length - 2); case "B": var now = new Date(); return Math.floor(((now.getHours() * 3600) + (now.getMinutes() * 60) + now.getSeconds() + (now.getTimezoneOffset() + 60) * 60) / 86.4); case "c": return x.toISOString().replace(/\"/g, ""); case "U": return $D.strtotime("now"); case "%c": return t("d") + " " + t("t"); case "%C": return Math.floor(x.getFullYear() / 100 + 1); } }, shouldOverrideDefaults: function (m) { switch (m) { case "%e": return true; default: return false; } }, parse: function (m, context) { var formatString, c = context || new Date(); formatString = normalizer.substitutes(m); if (formatString) { return formatString; } formatString = normalizer.interpreted(m, c); if (formatString) { return formatString; } else { return m; } } }; $D.normalizeFormat = function (format, context) { return format.replace(/(%|\\)?.|%%/g, function(t){ return normalizer.parse(t, context); }); }; /** * Format a local Unix timestamp according to locale settings * * Example: * Date.strftime("%m/%d/%y", new Date()); // "04/13/08" * Date.strftime("c", "2008-04-13T17:52:03Z"); // "04/13/08" * * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @param {Number|String} The number representing the number of seconds that have elapsed since January 1, 1970 (local time). * @return {String} A string representation of the current Date object. */ $D.strftime = function (format, time) { var d = Date.parse(time); return d._format(format); }; /** * Parse any textual datetime description into a Unix timestamp. * A Unix timestamp is the number of seconds that have elapsed since January 1, 1970 (midnight UTC/GMT). * * Example: * Date.strtotime("04/13/08"); // 1208044800 * Date.strtotime("1970-01-01T00:00:00Z"); // 0 * * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @param {Object} A string or date object. * @return {String} A string representation of the current Date object. */ $D.strtotime = function (time) { var d = $D.parse(time); return Math.round($D.UTC(d.getUTCFullYear(), d.getUTCMonth(), d.getUTCDate(), d.getUTCHours(), d.getUTCMinutes(), d.getUTCSeconds(), d.getUTCMilliseconds()) / 1000); }; /** * Converts the value of the current Date object to its equivalent string representation using a PHP/Unix style of date format specifiers. * Format Specifiers * Format Description Example * ------ --------------------------------------------------------------------------- ----------------------- * %a abbreviated weekday name according to the current localed "Mon" through "Sun" * %A full weekday name according to the current localed "Sunday" through "Saturday" * %b abbreviated month name according to the current localed "Jan" through "Dec" * %B full month name according to the current locale "January" through "December" * %c preferred date and time representation for the current locale "4/13/2008 12:33 PM" * %C century number (the year divided by 100 and truncated to an integer) "00" to "99" * %d day of the month as a decimal number "01" to "31" * %D same as %m/%d/%y "04/13/08" * %e day of the month as a decimal number, a single digit is preceded by a space "1" to "31" * %g like %G, but without the century "08" * %G The 4-digit year corresponding to the ISO week number (see %V). "2008" * This has the same format and value as %Y, except that if the ISO week number * belongs to the previous or next year, that year is used instead. * %h same as %b "Jan" through "Dec" * %H hour as a decimal number using a 24-hour clock. "00" to "23" * %I hour as a decimal number using a 12-hour clock. "01" to "12" * %j day of the year as a decimal number. "001" to "366" * %m month as a decimal number. "01" to "12" * %M minute as a decimal number. "00" to "59" * %n newline character "\n" * %p either "am" or "pm" according to the given time value, or the "am" or "pm" * corresponding strings for the current locale. * %r time in a.m. and p.m. notation "8:44 PM" * %R time in 24 hour notation "20:44" * %S second as a decimal number "00" to "59" * %t tab character "\t" * %T current time, equal to %H:%M:%S "12:49:11" * %u weekday as a decimal number ["1", "7"], with "1" representing Monday "1" to "7" * %U week number of the current year as a decimal number, starting with the "0" to ("52" or "53") * first Sunday as the first day of the first week * %V The ISO 8601:1988 week number of the current year as a decimal number, "00" to ("52" or "53") * range 01 to 53, where week 1 is the first week that has at least 4 days * in the current year, and with Monday as the first day of the week. * (Use %G or %g for the year component that corresponds to the week number * for the specified timestamp.) * %W week number of the current year as a decimal number, starting with the "00" to ("52" or "53") * first Monday as the first day of the first week * %w day of the week as a decimal, Sunday being "0" "0" to "6" * %x preferred date representation for the current locale without the time "4/13/2008" * %X preferred time representation for the current locale without the date "12:53:05" * %y year as a decimal number without a century "00" "99" * %Y year as a decimal number including the century "2008" * %Z time zone or name or abbreviation "UTC", "EST", "PST" * %z same as %Z * %% a literal "%" characters "%" * d Day of the month, 2 digits with leading zeros "01" to "31" * D A textual representation of a day, three letters "Mon" through "Sun" * j Day of the month without leading zeros "1" to "31" * l A full textual representation of the day of the week (lowercase "L") "Sunday" through "Saturday" * N ISO-8601 numeric representation of the day of the week (added in PHP 5.1.0) "1" (for Monday) through "7" (for Sunday) * S English ordinal suffix for the day of the month, 2 characters "st", "nd", "rd" or "th". Works well with j * w Numeric representation of the day of the week "0" (for Sunday) through "6" (for Saturday) * z The day of the year (starting from "0") "0" through "365" * W ISO-8601 week number of year, weeks starting on Monday "00" to ("52" or "53") * F A full textual representation of a month, such as January or March "January" through "December" * m Numeric representation of a month, with leading zeros "01" through "12" * M A short textual representation of a month, three letters "Jan" through "Dec" * n Numeric representation of a month, without leading zeros "1" through "12" * t Number of days in the given month "28" through "31" * L Whether it's a leap year "1" if it is a leap year, "0" otherwise * o ISO-8601 year number. This has the same value as Y, except that if the "2008" * ISO week number (W) belongs to the previous or next year, that year * is used instead. * Y A full numeric representation of a year, 4 digits "2008" * y A two digit representation of a year "08" * a Lowercase Ante meridiem and Post meridiem "am" or "pm" * A Uppercase Ante meridiem and Post meridiem "AM" or "PM" * B Swatch Internet time "000" through "999" * g 12-hour format of an hour without leading zeros "1" through "12" * G 24-hour format of an hour without leading zeros "0" through "23" * h 12-hour format of an hour with leading zeros "01" through "12" * H 24-hour format of an hour with leading zeros "00" through "23" * i Minutes with leading zeros "00" to "59" * s Seconds, with leading zeros "00" through "59" * u Milliseconds "54321" * e Timezone identifier "UTC", "EST", "PST" * I Whether or not the date is in daylight saving time (uppercase i) "1" if Daylight Saving Time, "0" otherwise * O Difference to Greenwich time (GMT) in hours "+0200", "-0600" * P Difference to Greenwich time (GMT) with colon between hours and minutes "+02:00", "-06:00" * T Timezone abbreviation "UTC", "EST", "PST" * Z Timezone offset in seconds. The offset for timezones west of UTC is "-43200" through "50400" * always negative, and for those east of UTC is always positive. * c ISO 8601 date "2004-02-12T15:19:21+00:00" * r RFC 2822 formatted date "Thu, 21 Dec 2000 16:01:07 +0200" * U Seconds since the Unix Epoch (January 1 1970 00:00:00 GMT) "0" * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @return {String} A string representation of the current Date object. */ var formatReplace = function (context) { return function (m) { var formatString, override = false; if (m.charAt(0) === "\\" || m.substring(0, 2) === "%%") { return m.replace("\\", "").replace("%%", "%"); } override = normalizer.shouldOverrideDefaults(m); formatString = $D.normalizeFormat(m, context); if (formatString) { return context.toString(formatString, override); } }; }; $P._format = function (format) { var formatter = formatReplace(this); if (!format) { return this._toString(); } else { return format.replace(/(%|\\)?.|%%/g, formatter); } }; if (!$P.format) { $P.format = $P._format; } }()); (function () { "use strict"; var gFn = function (attr) { return function () { return this[attr]; }; }; var sFn = function (attr) { return function (val) { this[attr] = val; return this; }; }; var attrs = ["years", "months", "days", "hours", "minutes", "seconds", "milliseconds"]; var addSetFuncs = function (context, attrs) { for (var i = 0; i < attrs.length ; i++) { var $a = attrs[i], $b = $a.slice(0, 1).toUpperCase() + $a.slice(1); context.prototype[$a] = 0; context.prototype["get" + $b] = gFn($a); context.prototype["set" + $b] = sFn($a); } }; /** * new TimeSpan(milliseconds); * new TimeSpan(days, hours, minutes, seconds); * new TimeSpan(days, hours, minutes, seconds, milliseconds); */ var TimeSpan = function (days, hours, minutes, seconds, milliseconds) { if (arguments.length === 1 && typeof days === "number") { var orient = (days < 0) ? -1 : +1; var millsLeft = Math.abs(days); this.setDays(Math.floor(millsLeft / 86400000) * orient); millsLeft = millsLeft % 86400000; this.setHours(Math.floor(millsLeft / 3600000) * orient); millsLeft = millsLeft % 3600000; this.setMinutes(Math.floor(millsLeft / 60000) * orient); millsLeft = millsLeft % 60000; this.setSeconds(Math.floor(millsLeft / 1000) * orient); millsLeft = millsLeft % 1000; this.setMilliseconds(millsLeft * orient); } else { this.set(days, hours, minutes, seconds, milliseconds); } this.getTotalMilliseconds = function () { return (this.getDays() * 86400000) + (this.getHours() * 3600000) + (this.getMinutes() * 60000) + (this.getSeconds() * 1000); }; this.compareTo = function (time) { var t1 = new Date(1970, 1, 1, this.getHours(), this.getMinutes(), this.getSeconds()), t2; if (time === null) { t2 = new Date(1970, 1, 1, 0, 0, 0); } else { t2 = new Date(1970, 1, 1, time.getHours(), time.getMinutes(), time.getSeconds()); } return (t1 < t2) ? -1 : (t1 > t2) ? 1 : 0; }; this.equals = function (time) { return (this.compareTo(time) === 0); }; this.add = function (time) { return (time === null) ? this : this.addSeconds(time.getTotalMilliseconds() / 1000); }; this.subtract = function (time) { return (time === null) ? this : this.addSeconds(-time.getTotalMilliseconds() / 1000); }; this.addDays = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 86400000)); }; this.addHours = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 3600000)); }; this.addMinutes = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 60000)); }; this.addSeconds = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 1000)); }; this.addMilliseconds = function (n) { return new TimeSpan(this.getTotalMilliseconds() + n); }; this.get12HourHour = function () { return (this.getHours() > 12) ? this.getHours() - 12 : (this.getHours() === 0) ? 12 : this.getHours(); }; this.getDesignator = function () { return (this.getHours() < 12) ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator; }; this.toString = function (format) { this._toString = function () { if (this.getDays() !== null && this.getDays() > 0) { return this.getDays() + "." + this.getHours() + ":" + this.p(this.getMinutes()) + ":" + this.p(this.getSeconds()); } else { return this.getHours() + ":" + this.p(this.getMinutes()) + ":" + this.p(this.getSeconds()); } }; this.p = function (s) { return (s.toString().length < 2) ? "0" + s : s; }; var me = this; return format ? format.replace(/dd?|HH?|hh?|mm?|ss?|tt?/g, function (format) { switch (format) { case "d": return me.getDays(); case "dd": return me.p(me.getDays()); case "H": return me.getHours(); case "HH": return me.p(me.getHours()); case "h": return me.get12HourHour(); case "hh": return me.p(me.get12HourHour()); case "m": return me.getMinutes(); case "mm": return me.p(me.getMinutes()); case "s": return me.getSeconds(); case "ss": return me.p(me.getSeconds()); case "t": return ((me.getHours() < 12) ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator).substring(0, 1); case "tt": return (me.getHours() < 12) ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator; } } ) : this._toString(); }; return this; }; addSetFuncs(TimeSpan, attrs.slice(2)); TimeSpan.prototype.set = function (days, hours, minutes, seconds, milliseconds){ this.setDays(days || this.getDays()); this.setHours(hours || this.getHours()); this.setMinutes(minutes || this.getMinutes()); this.setSeconds(seconds || this.getSeconds()); this.setMilliseconds(milliseconds || this.getMilliseconds()); }; /** * Gets the time of day for this date instances. * @return {TimeSpan} TimeSpan */ Date.prototype.getTimeOfDay = function () { return new TimeSpan(0, this.getHours(), this.getMinutes(), this.getSeconds(), this.getMilliseconds()); }; Date.TimeSpan = TimeSpan; if (typeof window !== "undefined" ) { // keeping API compatible for v1.x window.TimeSpan = TimeSpan; } }()); (function () { "use strict"; var attrs = ["years", "months", "days", "hours", "minutes", "seconds", "milliseconds"]; var gFn = function (attr) { return function () { return this[attr]; }; }; var sFn = function (attr) { return function (val) { this[attr] = val; return this; }; }; var addSetFuncs = function (context, attrs) { for (var i = 0; i < attrs.length ; i++) { var $a = attrs[i], $b = $a.slice(0, 1).toUpperCase() + $a.slice(1); context.prototype[$a] = 0; context.prototype["get" + $b] = gFn($a); context.prototype["set" + $b] = sFn($a); } }; var setMonthsAndYears = function (orient, d1, d2, context) { function inc() { d1.addMonths(-orient); context.months++; if (context.months === 12) { context.years++; context.months = 0; } } if (orient === +1) { while (d1 > d2) { inc(); } } else { while (d1 < d2) { inc(); } } context.months--; context.months *= orient; context.years *= orient; }; var adjustForDST = function(orient, startDate, endDate) { var hasDSTMismatch = (false === (startDate.isDaylightSavingTime() === endDate.isDaylightSavingTime())); if (hasDSTMismatch && orient === 1) { startDate.addHours(-1); } else if (hasDSTMismatch) { startDate.addHours(1); } }; /** * TimePeriod(startDate, endDate); * TimePeriod(years, months, days, hours, minutes, seconds, milliseconds); */ var TimePeriod = function (years, months, days, hours, minutes, seconds, milliseconds) { if (arguments.length === 7) { this.set(years, months, days, hours, minutes, seconds, milliseconds); } else if (arguments.length === 2 && arguments[0] instanceof Date && arguments[1] instanceof Date) { var startDate = arguments[0].clone(); var endDate = arguments[1].clone(); var orient = (startDate > endDate) ? +1 : -1; this.dates = { start: arguments[0].clone(), end: arguments[1].clone() }; setMonthsAndYears(orient, startDate, endDate, this); adjustForDST(orient, startDate, endDate); // // TODO - adjust for DST var diff = endDate - startDate; if (diff !== 0) { var ts = new TimeSpan(diff); this.set(this.years, this.months, ts.getDays(), ts.getHours(), ts.getMinutes(), ts.getSeconds(), ts.getMilliseconds()); } } return this; }; // create all the set functions. addSetFuncs(TimePeriod, attrs); TimePeriod.prototype.set = function (years, months, days, hours, minutes, seconds, milliseconds){ this.setYears(years || this.getYears()); this.setMonths(months || this.getMonths()); this.setDays(days || this.getDays()); this.setHours(hours || this.getHours()); this.setMinutes(minutes || this.getMinutes()); this.setSeconds(seconds || this.getSeconds()); this.setMilliseconds(milliseconds || this.getMilliseconds()); }; Date.TimePeriod = TimePeriod; if (typeof window !== "undefined") { // keeping API compatible for v1.x window.TimePeriod = TimePeriod; } }()); ================================================ FILE: build/date-es-HN.js ================================================ /** * @overview datejs * @version 1.0.0-rc3 * @author Gregory Wild-Smith * @copyright 2015 Gregory Wild-Smith * @license MIT * @homepage https://github.com/abritinthebay/datejs */ /* * DateJS Culture String File * Country Code: es-HN * Name: Spanish (Honduras) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["es-HN"] = { "name": "es-HN", "englishName": "Spanish (Honduras)", "nativeName": "Español (Honduras)", "Sunday": "domingo", "Monday": "lunes", "Tuesday": "martes", "Wednesday": "miércoles", "Thursday": "jueves", "Friday": "viernes", "Saturday": "sábado", "Sun": "dom", "Mon": "lun", "Tue": "mar", "Wed": "mié", "Thu": "jue", "Fri": "vie", "Sat": "sáb", "Su": "do", "Mo": "lu", "Tu": "ma", "We": "mi", "Th": "ju", "Fr": "vi", "Sa": "sá", "S_Sun_Initial": "d", "M_Mon_Initial": "l", "T_Tue_Initial": "m", "W_Wed_Initial": "m", "T_Thu_Initial": "j", "F_Fri_Initial": "v", "S_Sat_Initial": "s", "January": "enero", "February": "febrero", "March": "marzo", "April": "abril", "May": "mayo", "June": "junio", "July": "julio", "August": "agosto", "September": "septiembre", "October": "octubre", "November": "noviembre", "December": "diciembre", "Jan_Abbr": "ene", "Feb_Abbr": "feb", "Mar_Abbr": "mar", "Apr_Abbr": "abr", "May_Abbr": "may", "Jun_Abbr": "jun", "Jul_Abbr": "jul", "Aug_Abbr": "ago", "Sep_Abbr": "sep", "Oct_Abbr": "oct", "Nov_Abbr": "nov", "Dec_Abbr": "dic", "AM": "a.m.", "PM": "p.m.", "firstDayOfWeek": 0, "twoDigitYearMax": 2029, "mdy": "dmy", "M/d/yyyy": "dd/MM/yyyy", "dddd, MMMM dd, yyyy": "dddd, dd' [de] 'MMMM' [de] 'yyyy", "h:mm tt": "hh:mm tt", "h:mm:ss tt": "hh:mm:ss tt", "dddd, MMMM dd, yyyy h:mm:ss tt": "dddd, dd' [de] 'MMMM' [de] 'yyyy hh:mm:ss tt", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "dd MMMM", "MMMM, yyyy": "MMMM' [de] 'yyyy", "/jan(uary)?/": "ene(ro)?", "/feb(ruary)?/": "feb(rero)?", "/mar(ch)?/": "mar(zo)?", "/apr(il)?/": "abr(il)?", "/may/": "may(o)?", "/jun(e)?/": "jun(io)?", "/jul(y)?/": "jul(io)?", "/aug(ust)?/": "ago(sto)?", "/sep(t(ember)?)?/": "sep(tiembre)?", "/oct(ober)?/": "oct(ubre)?", "/nov(ember)?/": "nov(iembre)?", "/dec(ember)?/": "dic(iembre)?", "/^su(n(day)?)?/": "^do(m(ingo)?)?", "/^mo(n(day)?)?/": "^lu(n(es)?)?", "/^tu(e(s(day)?)?)?/": "^ma(r(tes)?)?", "/^we(d(nesday)?)?/": "^mi(é(rcoles)?)?", "/^th(u(r(s(day)?)?)?)?/": "^ju(e(ves)?)?", "/^fr(i(day)?)?/": "^vi(e(rnes)?)?", "/^sa(t(urday)?)?/": "^sá(b(ado)?)?", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "es-HN"; /** * @overview datejs * @version 1.0.0-rc3 * @author Gregory Wild-Smith * @copyright 2015 Gregory Wild-Smith * @license MIT * @homepage https://github.com/abritinthebay/datejs */(function () { var $D = Date; var lang = Date.CultureStrings ? Date.CultureStrings.lang : null; var loggedKeys = {}; // for debug purposes. var getText = { getFromKey: function (key, countryCode) { var output; if (Date.CultureStrings && Date.CultureStrings[countryCode] && Date.CultureStrings[countryCode][key]) { output = Date.CultureStrings[countryCode][key]; } else { output = getText.buildFromDefault(key); } if (key.charAt(0) === "/") { // Assume it's a regex output = getText.buildFromRegex(key, countryCode); } return output; }, getFromObjectValues: function (obj, countryCode) { var key, output = {}; for(key in obj) { if (obj.hasOwnProperty(key)) { output[key] = getText.getFromKey(obj[key], countryCode); } } return output; }, getFromObjectKeys: function (obj, countryCode) { var key, output = {}; for(key in obj) { if (obj.hasOwnProperty(key)) { output[getText.getFromKey(key, countryCode)] = obj[key]; } } return output; }, getFromArray: function (arr, countryCode) { var output = []; for (var i=0; i < arr.length; i++){ if (i in arr) { output[i] = getText.getFromKey(arr[i], countryCode); } } return output; }, buildFromDefault: function (key) { var output, length, split, last; switch(key) { case "name": output = "en-US"; break; case "englishName": output = "English (United States)"; break; case "nativeName": output = "English (United States)"; break; case "twoDigitYearMax": output = 2049; break; case "firstDayOfWeek": output = 0; break; default: output = key; split = key.split("_"); length = split.length; if (length > 1 && key.charAt(0) !== "/") { // if the key isn't a regex and it has a split. last = split[(length - 1)].toLowerCase(); if (last === "initial" || last === "abbr") { output = split[0]; } } break; } return output; }, buildFromRegex: function (key, countryCode) { var output; if (Date.CultureStrings && Date.CultureStrings[countryCode] && Date.CultureStrings[countryCode][key]) { output = new RegExp(Date.CultureStrings[countryCode][key], "i"); } else { output = new RegExp(key.replace(new RegExp("/", "g"),""), "i"); } return output; } }; var shallowMerge = function (obj1, obj2) { for (var attrname in obj2) { if (obj2.hasOwnProperty(attrname)) { obj1[attrname] = obj2[attrname]; } } }; var __ = function (key, language) { var countryCode = (language) ? language : lang; loggedKeys[key] = key; if (typeof key === "object") { if (key instanceof Array) { return getText.getFromArray(key, countryCode); } else { return getText.getFromObjectKeys(key, countryCode); } } else { return getText.getFromKey(key, countryCode); } }; var loadI18nScript = function (code) { // paatterned after jQuery's getScript. var url = Date.Config.i18n + code + ".js"; var head = document.getElementsByTagName("head")[0] || document.documentElement; var script = document.createElement("script"); script.src = url; var completed = false; var events = { done: function (){} // placeholder function }; // Attach handlers for all browsers script.onload = script.onreadystatechange = function() { if ( !completed && (!this.readyState || this.readyState === "loaded" || this.readyState === "complete") ) { events.done(); head.removeChild(script); } }; setTimeout(function() { head.insertBefore(script, head.firstChild); }, 0); // allows return to execute first return { done: function (cb) { events.done = function() { if (cb) { setTimeout(cb,0); } }; } }; }; var buildInfo = { buildFromMethodHash: function (obj) { var key; for(key in obj) { if (obj.hasOwnProperty(key)) { obj[key] = buildInfo[obj[key]](); } } return obj; }, timeZoneDST: function () { var DST = { "CHADT": "+1345", "NZDT": "+1300", "AEDT": "+1100", "ACDT": "+1030", "AZST": "+0500", "IRDT": "+0430", "EEST": "+0300", "CEST": "+0200", "BST": "+0100", "PMDT": "-0200", "ADT": "-0300", "NDT": "-0230", "EDT": "-0400", "CDT": "-0500", "MDT": "-0600", "PDT": "-0700", "AKDT": "-0800", "HADT": "-0900" }; return __(DST); }, timeZoneStandard: function () { var standard = { "LINT": "+1400", "TOT": "+1300", "CHAST": "+1245", "NZST": "+1200", "NFT": "+1130", "SBT": "+1100", "AEST": "+1000", "ACST": "+0930", "JST": "+0900", "CWST": "+0845", "CT": "+0800", "ICT": "+0700", "MMT": "+0630", "BST": "+0600", "NPT": "+0545", "IST": "+0530", "PKT": "+0500", "AFT": "+0430", "MSK": "+0400", "IRST": "+0330", "FET": "+0300", "EET": "+0200", "CET": "+0100", "GMT": "+0000", "UTC": "+0000", "CVT": "-0100", "GST": "-0200", "BRT": "-0300", "NST": "-0330", "AST": "-0400", "EST": "-0500", "CST": "-0600", "MST": "-0700", "PST": "-0800", "AKST": "-0900", "MIT": "-0930", "HST": "-1000", "SST": "-1100", "BIT": "-1200" }; return __(standard); }, timeZones: function (data) { var zone; data.timezones = []; for (zone in data.abbreviatedTimeZoneStandard) { if (data.abbreviatedTimeZoneStandard.hasOwnProperty(zone)) { data.timezones.push({ name: zone, offset: data.abbreviatedTimeZoneStandard[zone]}); } } for (zone in data.abbreviatedTimeZoneDST) { if (data.abbreviatedTimeZoneDST.hasOwnProperty(zone)) { data.timezones.push({ name: zone, offset: data.abbreviatedTimeZoneDST[zone], dst: true}); } } return data.timezones; }, days: function () { return __(["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"]); }, dayAbbr: function () { return __(["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"]); }, dayShortNames: function () { return __(["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"]); }, dayFirstLetters: function () { return __(["S_Sun_Initial", "M_Mon_Initial", "T_Tues_Initial", "W_Wed_Initial", "T_Thu_Initial", "F_Fri_Initial", "S_Sat_Initial"]); }, months: function () { return __(["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"]); }, monthAbbr: function () { return __(["Jan_Abbr", "Feb_Abbr", "Mar_Abbr", "Apr_Abbr", "May_Abbr", "Jun_Abbr", "Jul_Abbr", "Aug_Abbr", "Sep_Abbr", "Oct_Abbr", "Nov_Abbr", "Dec_Abbr"]); }, formatPatterns: function () { return getText.getFromObjectValues({ shortDate: "M/d/yyyy", longDate: "dddd, MMMM dd, yyyy", shortTime: "h:mm tt", longTime: "h:mm:ss tt", fullDateTime: "dddd, MMMM dd, yyyy h:mm:ss tt", sortableDateTime: "yyyy-MM-ddTHH:mm:ss", universalSortableDateTime: "yyyy-MM-dd HH:mm:ssZ", rfc1123: "ddd, dd MMM yyyy HH:mm:ss", monthDay: "MMMM dd", yearMonth: "MMMM, yyyy" }, Date.i18n.currentLanguage()); }, regex: function () { return getText.getFromObjectValues({ inTheMorning: "/( in the )(morn(ing)?)\\b/", thisMorning: "/(this )(morn(ing)?)\\b/", amThisMorning: "/(\b\\d(am)? )(this )(morn(ing)?)/", inTheEvening: "/( in the )(even(ing)?)\\b/", thisEvening: "/(this )(even(ing)?)\\b/", pmThisEvening: "/(\b\\d(pm)? )(this )(even(ing)?)/", jan: "/jan(uary)?/", feb: "/feb(ruary)?/", mar: "/mar(ch)?/", apr: "/apr(il)?/", may: "/may/", jun: "/jun(e)?/", jul: "/jul(y)?/", aug: "/aug(ust)?/", sep: "/sep(t(ember)?)?/", oct: "/oct(ober)?/", nov: "/nov(ember)?/", dec: "/dec(ember)?/", sun: "/^su(n(day)?)?/", mon: "/^mo(n(day)?)?/", tue: "/^tu(e(s(day)?)?)?/", wed: "/^we(d(nesday)?)?/", thu: "/^th(u(r(s(day)?)?)?)?/", fri: "/fr(i(day)?)?/", sat: "/^sa(t(urday)?)?/", future: "/^next/", past: "/^last|past|prev(ious)?/", add: "/^(\\+|aft(er)?|from|hence)/", subtract: "/^(\\-|bef(ore)?|ago)/", yesterday: "/^yes(terday)?/", today: "/^t(od(ay)?)?/", tomorrow: "/^tom(orrow)?/", now: "/^n(ow)?/", millisecond: "/^ms|milli(second)?s?/", second: "/^sec(ond)?s?/", minute: "/^mn|min(ute)?s?/", hour: "/^h(our)?s?/", week: "/^w(eek)?s?/", month: "/^m(onth)?s?/", day: "/^d(ay)?s?/", year: "/^y(ear)?s?/", shortMeridian: "/^(a|p)/", longMeridian: "/^(a\\.?m?\\.?|p\\.?m?\\.?)/", timezone: "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/", ordinalSuffix: "/^\\s*(st|nd|rd|th)/", timeContext: "/^\\s*(\\:|a(?!u|p)|p)/" }, Date.i18n.currentLanguage()); } }; var CultureInfo = function () { var info = getText.getFromObjectValues({ name: "name", englishName: "englishName", nativeName: "nativeName", amDesignator: "AM", pmDesignator: "PM", firstDayOfWeek: "firstDayOfWeek", twoDigitYearMax: "twoDigitYearMax", dateElementOrder: "mdy" }, Date.i18n.currentLanguage()); var constructedInfo = buildInfo.buildFromMethodHash({ dayNames: "days", abbreviatedDayNames: "dayAbbr", shortestDayNames: "dayShortNames", firstLetterDayNames: "dayFirstLetters", monthNames: "months", abbreviatedMonthNames: "monthAbbr", formatPatterns: "formatPatterns", regexPatterns: "regex", abbreviatedTimeZoneDST: "timeZoneDST", abbreviatedTimeZoneStandard: "timeZoneStandard" }); shallowMerge(info, constructedInfo); buildInfo.timeZones(info); return info; }; $D.i18n = { __: function (key, lang) { return __(key, lang); }, currentLanguage: function () { return lang || "en-US"; }, setLanguage: function (code, force, cb) { var async = false; if (force || code === "en-US" || (!!Date.CultureStrings && !!Date.CultureStrings[code])) { lang = code; Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings.lang = code; Date.CultureInfo = new CultureInfo(); } else { if (!(!!Date.CultureStrings && !!Date.CultureStrings[code])) { if (typeof exports !== "undefined" && this.exports !== exports) { // we're in a Node enviroment, load it using require try { require("../i18n/" + code + ".js"); lang = code; Date.CultureStrings.lang = code; Date.CultureInfo = new CultureInfo(); } catch (e) { // var str = "The language for '" + code + "' could not be loaded by Node. It likely does not exist."; throw new Error("The DateJS IETF language tag '" + code + "' could not be loaded by Node. It likely does not exist."); } } else if (Date.Config && Date.Config.i18n) { // we know the location of the files, so lets load them async = true; loadI18nScript(code).done(function(){ lang = code; Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings.lang = code; Date.CultureInfo = new CultureInfo(); $D.Parsing.Normalizer.buildReplaceData(); // because this is async if ($D.Grammar) { $D.Grammar.buildGrammarFormats(); // so we can parse those strings... } if (cb) { setTimeout(cb,0); } }); } else { Date.console.error("The DateJS IETF language tag '" + code + "' is not available and has not been loaded."); return false; } } } $D.Parsing.Normalizer.buildReplaceData(); // rebuild normalizer strings if ($D.Grammar) { $D.Grammar.buildGrammarFormats(); // so we can parse those strings... } if (!async && cb) { setTimeout(cb,0); } }, getLoggedKeys: function () { return loggedKeys; }, updateCultureInfo: function () { Date.CultureInfo = new CultureInfo(); } }; $D.i18n.updateCultureInfo(); // run automatically }()); (function () { var $D = Date, $P = $D.prototype, p = function (s, l) { if (!l) { l = 2; } return ("000" + s).slice(l * -1); }; if (typeof window !== "undefined" && typeof window.console !== "undefined" && typeof window.console.log !== "undefined") { $D.console = console; // used only to raise non-critical errors if available } else { // set mock so we don't give errors. $D.console = { log: function(){}, error: function(){} }; } $D.Config = $D.Config || {}; $D.initOverloads = function() { /** * Overload of Date.now. Allows an alternate call for Date.now where it returns the * current Date as an object rather than just milliseconds since the Unix Epoch. * * Also provides an implementation of now() for browsers (IE<9) that don't have it. * * Backwards compatible so with work with either: * Date.now() [returns ms] * or * Date.now(true) [returns Date] */ if (!$D.now) { $D._now = function now() { return new Date().getTime(); }; } else if (!$D._now) { $D._now = $D.now; } $D.now = function (returnObj) { if (returnObj) { return $D.present(); } else { return $D._now(); } }; if ( !$P.toISOString ) { $P.toISOString = function() { return this.getUTCFullYear() + "-" + p(this.getUTCMonth() + 1) + "-" + p(this.getUTCDate()) + "T" + p(this.getUTCHours()) + ":" + p(this.getUTCMinutes()) + ":" + p(this.getUTCSeconds()) + "." + String( (this.getUTCMilliseconds()/1000).toFixed(3)).slice(2, 5) + "Z"; }; } // private if ( $P._toString === undefined ){ $P._toString = $P.toString; } }; $D.initOverloads(); /** * Gets a date that is set to the current date. The time is set to the start of the day (00:00 or 12:00 AM). * @return {Date} The current date. */ $D.today = function () { return new Date().clearTime(); }; /** * Gets a date that is set to the current date and time (same as new Date, but chainable) * @return {Date} The current date. */ $D.present = function () { return new Date(); }; /** * Compares the first date to the second date and returns an number indication of their relative values. * @param {Date} First Date object to compare [Required]. * @param {Date} Second Date object to compare to [Required]. * @return {Number} -1 = date1 is lessthan date2. 0 = values are equal. 1 = date1 is greaterthan date2. */ $D.compare = function (date1, date2) { if (isNaN(date1) || isNaN(date2)) { throw new Error(date1 + " - " + date2); } else if (date1 instanceof Date && date2 instanceof Date) { return (date1 < date2) ? -1 : (date1 > date2) ? 1 : 0; } else { throw new TypeError(date1 + " - " + date2); } }; /** * Compares the first Date object to the second Date object and returns true if they are equal. * @param {Date} First Date object to compare [Required] * @param {Date} Second Date object to compare to [Required] * @return {Boolean} true if dates are equal. false if they are not equal. */ $D.equals = function (date1, date2) { return (date1.compareTo(date2) === 0); }; /** * Gets the language appropriate day name when given the day number(0-6) * eg - 0 == Sunday * @return {String} The day name */ $D.getDayName = function (n) { return Date.CultureInfo.dayNames[n]; }; /** * Gets the day number (0-6) if given a CultureInfo specific string which is a valid dayName, abbreviatedDayName or shortestDayName (two char). * @param {String} The name of the day (eg. "Monday, "Mon", "tuesday", "tue", "We", "we"). * @return {Number} The day number */ $D.getDayNumberFromName = function (name) { var n = Date.CultureInfo.dayNames, m = Date.CultureInfo.abbreviatedDayNames, o = Date.CultureInfo.shortestDayNames, s = name.toLowerCase(); for (var i = 0; i < n.length; i++) { if (n[i].toLowerCase() === s || m[i].toLowerCase() === s || o[i].toLowerCase() === s) { return i; } } return -1; }; /** * Gets the month number (0-11) if given a Culture Info specific string which is a valid monthName or abbreviatedMonthName. * @param {String} The name of the month (eg. "February, "Feb", "october", "oct"). * @return {Number} The day number */ $D.getMonthNumberFromName = function (name) { var n = Date.CultureInfo.monthNames, m = Date.CultureInfo.abbreviatedMonthNames, s = name.toLowerCase(); for (var i = 0; i < n.length; i++) { if (n[i].toLowerCase() === s || m[i].toLowerCase() === s) { return i; } } return -1; }; /** * Gets the language appropriate month name when given the month number(0-11) * eg - 0 == January * @return {String} The month name */ $D.getMonthName = function (n) { return Date.CultureInfo.monthNames[n]; }; /** * Determines if the current date instance is within a LeapYear. * @param {Number} The year. * @return {Boolean} true if date is within a LeapYear, otherwise false. */ $D.isLeapYear = function (year) { return ((year % 4 === 0 && year % 100 !== 0) || year % 400 === 0); }; /** * Gets the number of days in the month, given a year and month value. Automatically corrects for LeapYear. * @param {Number} The year. * @param {Number} The month (0-11). * @return {Number} The number of days in the month. */ $D.getDaysInMonth = function (year, month) { if (!month && $D.validateMonth(year)) { month = year; year = Date.today().getFullYear(); } return [31, ($D.isLeapYear(year) ? 29 : 28), 31, 30, 31, 30, 31, 31, 30, 31, 30, 31][month]; }; $P.getDaysInMonth = function () { return $D.getDaysInMonth(this.getFullYear(), this.getMonth()); }; $D.getTimezoneAbbreviation = function (offset, dst) { var p, n = (dst || false) ? Date.CultureInfo.abbreviatedTimeZoneDST : Date.CultureInfo.abbreviatedTimeZoneStandard; for (p in n) { if (n.hasOwnProperty(p)) { if (n[p] === offset) { return p; } } } return null; }; $D.getTimezoneOffset = function (name, dst) { var i, a =[], z = Date.CultureInfo.timezones; if (!name) { name = (new Date()).getTimezone();} for (i = 0; i < z.length; i++) { if (z[i].name === name.toUpperCase()) { a.push(i); } } if (!z[a[0]]) { return null; } if (a.length === 1 || !dst) { return z[a[0]].offset; } else { for (i=0; i < a.length; i++) { if (z[a[i]].dst) { return z[a[i]].offset; } } } }; $D.getQuarter = function (d) { d = d || new Date(); // If no date supplied, use today var q = [1,2,3,4]; return q[Math.floor(d.getMonth() / 3)]; // ~~~ is a bitwise op. Faster than Math.floor }; $D.getDaysLeftInQuarter = function (d) { d = d || new Date(); var qEnd = new Date(d); qEnd.setMonth(qEnd.getMonth() + 3 - qEnd.getMonth() % 3, 0); return Math.floor((qEnd - d) / 8.64e7); }; // private var validate = function (n, min, max, name) { name = name ? name : "Object"; if (typeof n === "undefined") { return false; } else if (typeof n !== "number") { throw new TypeError(n + " is not a Number."); } else if (n < min || n > max) { // As failing validation is *not* an exceptional circumstance // lets not throw a RangeError Exception here. // It's semantically correct but it's not sensible. return false; } return true; }; /** * Validates the number is within an acceptable range for milliseconds [0-999]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateMillisecond = function (value) { return validate(value, 0, 999, "millisecond"); }; /** * Validates the number is within an acceptable range for seconds [0-59]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateSecond = function (value) { return validate(value, 0, 59, "second"); }; /** * Validates the number is within an acceptable range for minutes [0-59]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateMinute = function (value) { return validate(value, 0, 59, "minute"); }; /** * Validates the number is within an acceptable range for hours [0-23]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateHour = function (value) { return validate(value, 0, 23, "hour"); }; /** * Validates the number is within an acceptable range for the days in a month [0-MaxDaysInMonth]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateDay = function (value, year, month) { if (year === undefined || year === null || month === undefined || month === null) { return false;} return validate(value, 1, $D.getDaysInMonth(year, month), "day"); }; /** * Validates the number is within an acceptable range for months [0-11]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateWeek = function (value) { return validate(value, 0, 53, "week"); }; /** * Validates the number is within an acceptable range for months [0-11]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateMonth = function (value) { return validate(value, 0, 11, "month"); }; /** * Validates the number is within an acceptable range for years. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateYear = function (value) { /** * Per ECMAScript spec the range of times supported by Date objects is * exactly -100,000,000 days to +100,000,000 days measured relative to * midnight at the beginning of 01 January, 1970 UTC. * This gives a range of 8,640,000,000,000,000 milliseconds to either * side of 01 January, 1970 UTC. * * Earliest possible date: Tue, 20 Apr 271,822 B.C. 00:00:00 UTC * Latest possible date: Sat, 13 Sep 275,760 00:00:00 UTC */ return validate(value, -271822, 275760, "year"); }; $D.validateTimezone = function(value) { var timezones = {"ACDT":1,"ACST":1,"ACT":1,"ADT":1,"AEDT":1,"AEST":1,"AFT":1,"AKDT":1,"AKST":1,"AMST":1,"AMT":1,"ART":1,"AST":1,"AWDT":1,"AWST":1,"AZOST":1,"AZT":1,"BDT":1,"BIOT":1,"BIT":1,"BOT":1,"BRT":1,"BST":1,"BTT":1,"CAT":1,"CCT":1,"CDT":1,"CEDT":1,"CEST":1,"CET":1,"CHADT":1,"CHAST":1,"CHOT":1,"ChST":1,"CHUT":1,"CIST":1,"CIT":1,"CKT":1,"CLST":1,"CLT":1,"COST":1,"COT":1,"CST":1,"CT":1,"CVT":1,"CWST":1,"CXT":1,"DAVT":1,"DDUT":1,"DFT":1,"EASST":1,"EAST":1,"EAT":1,"ECT":1,"EDT":1,"EEDT":1,"EEST":1,"EET":1,"EGST":1,"EGT":1,"EIT":1,"EST":1,"FET":1,"FJT":1,"FKST":1,"FKT":1,"FNT":1,"GALT":1,"GAMT":1,"GET":1,"GFT":1,"GILT":1,"GIT":1,"GMT":1,"GST":1,"GYT":1,"HADT":1,"HAEC":1,"HAST":1,"HKT":1,"HMT":1,"HOVT":1,"HST":1,"ICT":1,"IDT":1,"IOT":1,"IRDT":1,"IRKT":1,"IRST":1,"IST":1,"JST":1,"KGT":1,"KOST":1,"KRAT":1,"KST":1,"LHST":1,"LINT":1,"MAGT":1,"MART":1,"MAWT":1,"MDT":1,"MET":1,"MEST":1,"MHT":1,"MIST":1,"MIT":1,"MMT":1,"MSK":1,"MST":1,"MUT":1,"MVT":1,"MYT":1,"NCT":1,"NDT":1,"NFT":1,"NPT":1,"NST":1,"NT":1,"NUT":1,"NZDT":1,"NZST":1,"OMST":1,"ORAT":1,"PDT":1,"PET":1,"PETT":1,"PGT":1,"PHOT":1,"PHT":1,"PKT":1,"PMDT":1,"PMST":1,"PONT":1,"PST":1,"PYST":1,"PYT":1,"RET":1,"ROTT":1,"SAKT":1,"SAMT":1,"SAST":1,"SBT":1,"SCT":1,"SGT":1,"SLST":1,"SRT":1,"SST":1,"SYOT":1,"TAHT":1,"THA":1,"TFT":1,"TJT":1,"TKT":1,"TLT":1,"TMT":1,"TOT":1,"TVT":1,"UCT":1,"ULAT":1,"UTC":1,"UYST":1,"UYT":1,"UZT":1,"VET":1,"VLAT":1,"VOLT":1,"VOST":1,"VUT":1,"WAKT":1,"WAST":1,"WAT":1,"WEDT":1,"WEST":1,"WET":1,"WST":1,"YAKT":1,"YEKT":1,"Z":1}; return (timezones[value] === 1); }; $D.validateTimezoneOffset= function(value) { // timezones go from +14hrs to -12hrs, the +X hours are negative offsets. return (value > -841 && value < 721); }; }()); (function () { var $D = Date, $P = $D.prototype, p = function (s, l) { if (!l) { l = 2; } return ("000" + s).slice(l * -1); }; var validateConfigObject = function (obj) { var result = {}, self = this, prop, testFunc; testFunc = function (prop, func, value) { if (prop === "day") { var month = (obj.month !== undefined) ? obj.month : self.getMonth(); var year = (obj.year !== undefined) ? obj.year : self.getFullYear(); return $D[func](value, year, month); } else { return $D[func](value); } }; for (prop in obj) { if (Object.prototype.hasOwnProperty.call(obj, prop)) { var func = "validate" + prop.charAt(0).toUpperCase() + prop.slice(1); if ($D[func] && obj[prop] !== null && testFunc(prop, func, obj[prop])) { result[prop] = obj[prop]; } } } return result; }; /** * Resets the time of this Date object to 12:00 AM (00:00), which is the start of the day. * @param {Boolean} .clone() this date instance before clearing Time * @return {Date} this */ $P.clearTime = function () { this.setHours(0); this.setMinutes(0); this.setSeconds(0); this.setMilliseconds(0); return this; }; /** * Resets the time of this Date object to the current time ('now'). * @return {Date} this */ $P.setTimeToNow = function () { var n = new Date(); this.setHours(n.getHours()); this.setMinutes(n.getMinutes()); this.setSeconds(n.getSeconds()); this.setMilliseconds(n.getMilliseconds()); return this; }; /** * Returns a new Date object that is an exact date and time copy of the original instance. * @return {Date} A new Date instance */ $P.clone = function () { return new Date(this.getTime()); }; /** * Compares this instance to a Date object and returns an number indication of their relative values. * @param {Date} Date object to compare [Required] * @return {Number} -1 = this is lessthan date. 0 = values are equal. 1 = this is greaterthan date. */ $P.compareTo = function (date) { return Date.compare(this, date); }; /** * Compares this instance to another Date object and returns true if they are equal. * @param {Date} Date object to compare. If no date to compare, new Date() [now] is used. * @return {Boolean} true if dates are equal. false if they are not equal. */ $P.equals = function (date) { return Date.equals(this, (date !== undefined ? date : new Date())); }; /** * Determines if this instance is between a range of two dates or equal to either the start or end dates. * @param {Date} Start of range [Required] * @param {Date} End of range [Required] * @return {Boolean} true is this is between or equal to the start and end dates, else false */ $P.between = function (start, end) { return this.getTime() >= start.getTime() && this.getTime() <= end.getTime(); }; /** * Determines if this date occurs after the date to compare to. * @param {Date} Date object to compare. If no date to compare, new Date() ("now") is used. * @return {Boolean} true if this date instance is greater than the date to compare to (or "now"), otherwise false. */ $P.isAfter = function (date) { return this.compareTo(date || new Date()) === 1; }; /** * Determines if this date occurs before the date to compare to. * @param {Date} Date object to compare. If no date to compare, new Date() ("now") is used. * @return {Boolean} true if this date instance is less than the date to compare to (or "now"). */ $P.isBefore = function (date) { return (this.compareTo(date || new Date()) === -1); }; /** * Determines if the current Date instance occurs today. * @return {Boolean} true if this date instance is 'today', otherwise false. */ /** * Determines if the current Date instance occurs on the same Date as the supplied 'date'. * If no 'date' to compare to is provided, the current Date instance is compared to 'today'. * @param {date} Date object to compare. If no date to compare, the current Date ("now") is used. * @return {Boolean} true if this Date instance occurs on the same Day as the supplied 'date'. */ $P.isToday = $P.isSameDay = function (date) { return this.clone().clearTime().equals((date || new Date()).clone().clearTime()); }; /** * Adds the specified number of milliseconds to this instance. * @param {Number} The number of milliseconds to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addMilliseconds = function (value) { if (!value) { return this; } this.setTime(this.getTime() + value * 1); return this; }; /** * Adds the specified number of seconds to this instance. * @param {Number} The number of seconds to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addSeconds = function (value) { if (!value) { return this; } return this.addMilliseconds(value * 1000); }; /** * Adds the specified number of seconds to this instance. * @param {Number} The number of seconds to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addMinutes = function (value) { if (!value) { return this; } return this.addMilliseconds(value * 60000); // 60*1000 }; /** * Adds the specified number of hours to this instance. * @param {Number} The number of hours to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addHours = function (value) { if (!value) { return this; } return this.addMilliseconds(value * 3600000); // 60*60*1000 }; /** * Adds the specified number of days to this instance. * @param {Number} The number of days to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addDays = function (value) { if (!value) { return this; } this.setDate(this.getDate() + value * 1); return this; }; /** * Adds the specified number of weekdays (ie - not sat or sun) to this instance. * @param {Number} The number of days to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addWeekdays = function (value) { if (!value) { return this; } var day = this.getDay(); var weeks = (Math.ceil(Math.abs(value)/7)); if (day === 0 || day === 6) { if (value > 0) { this.next().monday(); this.addDays(-1); day = this.getDay(); } } if (value < 0) { while (value < 0) { this.addDays(-1); day = this.getDay(); if (day !== 0 && day !== 6) { value++; } } return this; } else if (value > 5 || (6-day) <= value) { value = value + (weeks * 2); } return this.addDays(value); }; /** * Adds the specified number of weeks to this instance. * @param {Number} The number of weeks to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addWeeks = function (value) { if (!value) { return this; } return this.addDays(value * 7); }; /** * Adds the specified number of months to this instance. * @param {Number} The number of months to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addMonths = function (value) { if (!value) { return this; } var n = this.getDate(); this.setDate(1); this.setMonth(this.getMonth() + value * 1); this.setDate(Math.min(n, $D.getDaysInMonth(this.getFullYear(), this.getMonth()))); return this; }; $P.addQuarters = function (value) { if (!value) { return this; } // note this will take you to the same point in the quarter as you are now. // i.e. - if you are 15 days into the quarter you'll be 15 days into the resulting one. // bonus: this allows adding fractional quarters return this.addMonths(value * 3); }; /** * Adds the specified number of years to this instance. * @param {Number} The number of years to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addYears = function (value) { if (!value) { return this; } return this.addMonths(value * 12); }; /** * Adds (or subtracts) to the value of the years, months, weeks, days, hours, minutes, seconds, milliseconds of the date instance using given configuration object. Positive and Negative values allowed. * Example

	Date.today().add( { days: 1, months: 1 } )

	new Date().add( { years: -1 } )
	
* @param {Object} Configuration object containing attributes (months, days, etc.) * @return {Date} this */ $P.add = function (config) { if (typeof config === "number") { this._orient = config; return this; } var x = config; if (x.day) { // If we should be a different date than today (eg: for 'tomorrow -1d', etc). // Should only effect parsing, not direct usage (eg, Finish and FinishExact) if ((x.day - this.getDate()) !== 0) { this.setDate(x.day); } } if (x.milliseconds) { this.addMilliseconds(x.milliseconds); } if (x.seconds) { this.addSeconds(x.seconds); } if (x.minutes) { this.addMinutes(x.minutes); } if (x.hours) { this.addHours(x.hours); } if (x.weeks) { this.addWeeks(x.weeks); } if (x.months) { this.addMonths(x.months); } if (x.years) { this.addYears(x.years); } if (x.days) { this.addDays(x.days); } return this; }; /** * Get the week number. Week one (1) is the week which contains the first Thursday of the year. Monday is considered the first day of the week. * The .getWeek() function does NOT convert the date to UTC. The local datetime is used. * Please use .getISOWeek() to get the week of the UTC converted date. * @return {Number} 1 to 53 */ $P.getWeek = function (utc) { // Create a copy of this date object var self, target = new Date(this.valueOf()); if (utc) { target.addMinutes(target.getTimezoneOffset()); self = target.clone(); } else { self = this; } // ISO week date weeks start on monday // so correct the day number var dayNr = (self.getDay() + 6) % 7; // ISO 8601 states that week 1 is the week // with the first thursday of that year. // Set the target date to the thursday in the target week target.setDate(target.getDate() - dayNr + 3); // Store the millisecond value of the target date var firstThursday = target.valueOf(); // Set the target to the first thursday of the year // First set the target to january first target.setMonth(0, 1); // Not a thursday? Correct the date to the next thursday if (target.getDay() !== 4) { target.setMonth(0, 1 + ((4 - target.getDay()) + 7) % 7); } // The weeknumber is the number of weeks between the // first thursday of the year and the thursday in the target week return 1 + Math.ceil((firstThursday - target) / 604800000); // 604800000 = 7 * 24 * 3600 * 1000 }; /** * Get the ISO 8601 week number. Week one ("01") is the week which contains the first Thursday of the year. Monday is considered the first day of the week. * The .getISOWeek() function does convert the date to it's UTC value. Please use .getWeek() to get the week of the local date. * @return {String} "01" to "53" */ $P.getISOWeek = function () { return p(this.getWeek(true)); }; /** * Moves the date to Monday of the week set. Week one (1) is the week which contains the first Thursday of the year. * @param {Number} A Number (1 to 53) that represents the week of the year. * @return {Date} this */ $P.setWeek = function (n) { if ((n - this.getWeek()) === 0) { if (this.getDay() !== 1) { return this.moveToDayOfWeek(1, (this.getDay() > 1 ? -1 : 1)); } else { return this; } } else { return this.moveToDayOfWeek(1, (this.getDay() > 1 ? -1 : 1)).addWeeks(n - this.getWeek()); } }; $P.setQuarter = function (qtr) { var month = Math.abs(((qtr-1) * 3) + 1); return this.setMonth(month, 1); }; $P.getQuarter = function () { return Date.getQuarter(this); }; $P.getDaysLeftInQuarter = function () { return Date.getDaysLeftInQuarter(this); }; /** * Moves the date to the next n'th occurrence of the dayOfWeek starting from the beginning of the month. The number (-1) is a magic number and will return the last occurrence of the dayOfWeek in the month. * @param {Number} The dayOfWeek to move to * @param {Number} The n'th occurrence to move to. Use (-1) to return the last occurrence in the month * @return {Date} this */ $P.moveToNthOccurrence = function (dayOfWeek, occurrence) { if (dayOfWeek === "Weekday") { if (occurrence > 0) { this.moveToFirstDayOfMonth(); if (this.is().weekday()) { occurrence -= 1; } } else if (occurrence < 0) { this.moveToLastDayOfMonth(); if (this.is().weekday()) { occurrence += 1; } } else { return this; } return this.addWeekdays(occurrence); } var shift = 0; if (occurrence > 0) { shift = occurrence - 1; } else if (occurrence === -1) { this.moveToLastDayOfMonth(); if (this.getDay() !== dayOfWeek) { this.moveToDayOfWeek(dayOfWeek, -1); } return this; } return this.moveToFirstDayOfMonth().addDays(-1).moveToDayOfWeek(dayOfWeek, +1).addWeeks(shift); }; var moveToN = function (getFunc, addFunc, nVal) { return function (value, orient) { var diff = (value - this[getFunc]() + nVal * (orient || +1)) % nVal; return this[addFunc]((diff === 0) ? diff += nVal * (orient || +1) : diff); }; }; /** * Move to the next or last dayOfWeek based on the orient value. * @param {Number} The dayOfWeek to move to * @param {Number} Forward (+1) or Back (-1). Defaults to +1. [Optional] * @return {Date} this */ $P.moveToDayOfWeek = moveToN("getDay", "addDays", 7); /** * Move to the next or last month based on the orient value. * @param {Number} The month to move to. 0 = January, 11 = December * @param {Number} Forward (+1) or Back (-1). Defaults to +1. [Optional] * @return {Date} this */ $P.moveToMonth = moveToN("getMonth", "addMonths", 12); /** * Get the Ordinate of the current day ("th", "st", "rd"). * @return {String} */ $P.getOrdinate = function () { var num = this.getDate(); return ord(num); }; /** * Get the Ordinal day (numeric day number) of the year, adjusted for leap year. * @return {Number} 1 through 365 (366 in leap years) */ $P.getOrdinalNumber = function () { return Math.ceil((this.clone().clearTime() - new Date(this.getFullYear(), 0, 1)) / 86400000) + 1; }; /** * Get the time zone abbreviation of the current date. * @return {String} The abbreviated time zone name (e.g. "EST") */ $P.getTimezone = function () { return $D.getTimezoneAbbreviation(this.getUTCOffset(), this.isDaylightSavingTime()); }; $P.setTimezoneOffset = function (offset) { var here = this.getTimezoneOffset(), there = Number(offset) * -6 / 10; return (there || there === 0) ? this.addMinutes(there - here) : this; }; $P.setTimezone = function (offset) { return this.setTimezoneOffset($D.getTimezoneOffset(offset)); }; /** * Indicates whether Daylight Saving Time is observed in the current time zone. * @return {Boolean} true|false */ $P.hasDaylightSavingTime = function () { return (Date.today().set({month: 0, day: 1}).getTimezoneOffset() !== Date.today().set({month: 6, day: 1}).getTimezoneOffset()); }; /** * Indicates whether this Date instance is within the Daylight Saving Time range for the current time zone. * @return {Boolean} true|false */ $P.isDaylightSavingTime = function () { return Date.today().set({month: 0, day: 1}).getTimezoneOffset() !== this.getTimezoneOffset(); }; /** * Get the offset from UTC of the current date. * @return {String} The 4-character offset string prefixed with + or - (e.g. "-0500") */ $P.getUTCOffset = function (offset) { var n = (offset || this.getTimezoneOffset()) * -10 / 6, r; if (n < 0) { r = (n - 10000).toString(); return r.charAt(0) + r.substr(2); } else { r = (n + 10000).toString(); return "+" + r.substr(1); } }; /** * Returns the number of milliseconds between this date and date. * @param {Date} Defaults to now * @return {Number} The diff in milliseconds */ $P.getElapsed = function (date) { return (date || new Date()) - this; }; /** * Set the value of year, month, day, hour, minute, second, millisecond of date instance using given configuration object. * Example

	Date.today().set( { day: 20, month: 1 } )

	new Date().set( { millisecond: 0 } )
	
* * @param {Object} Configuration object containing attributes (month, day, etc.) * @return {Date} this */ $P.set = function (config) { config = validateConfigObject.call(this, config); var key; for (key in config) { if (Object.prototype.hasOwnProperty.call(config, key)) { var name = key.charAt(0).toUpperCase() + key.slice(1); var addFunc, getFunc; if (key !== "week" && key !== "month" && key !== "timezone" && key !== "timezoneOffset") { name += "s"; } addFunc = "add" + name; getFunc = "get" + name; if (key === "month") { addFunc = addFunc + "s"; } else if (key === "year"){ getFunc = "getFullYear"; } if (key !== "day" && key !== "timezone" && key !== "timezoneOffset" && key !== "week" && key !== "hour") { this[addFunc](config[key] - this[getFunc]()); } else if ( key === "timezone"|| key === "timezoneOffset" || key === "week" || key === "hour") { this["set"+name](config[key]); } } } // day has to go last because you can't validate the day without first knowing the month if (config.day) { this.addDays(config.day - this.getDate()); } return this; }; /** * Moves the date to the first day of the month. * @return {Date} this */ $P.moveToFirstDayOfMonth = function () { return this.set({ day: 1 }); }; /** * Moves the date to the last day of the month. * @return {Date} this */ $P.moveToLastDayOfMonth = function () { return this.set({ day: $D.getDaysInMonth(this.getFullYear(), this.getMonth())}); }; /** * Converts the value of the current Date object to its equivalent string representation. * Format Specifiers * CUSTOM DATE AND TIME FORMAT STRINGS * Format Description Example * ------ --------------------------------------------------------------------------- ----------------------- * s The seconds of the minute between 0-59. "0" to "59" * ss The seconds of the minute with leading zero if required. "00" to "59" * * m The minute of the hour between 0-59. "0" or "59" * mm The minute of the hour with leading zero if required. "00" or "59" * * h The hour of the day between 1-12. "1" to "12" * hh The hour of the day with leading zero if required. "01" to "12" * * H The hour of the day between 0-23. "0" to "23" * HH The hour of the day with leading zero if required. "00" to "23" * * d The day of the month between 1 and 31. "1" to "31" * dd The day of the month with leading zero if required. "01" to "31" * ddd Abbreviated day name. Date.CultureInfo.abbreviatedDayNames. "Mon" to "Sun" * dddd The full day name. Date.CultureInfo.dayNames. "Monday" to "Sunday" * * M The month of the year between 1-12. "1" to "12" * MM The month of the year with leading zero if required. "01" to "12" * MMM Abbreviated month name. Date.CultureInfo.abbreviatedMonthNames. "Jan" to "Dec" * MMMM The full month name. Date.CultureInfo.monthNames. "January" to "December" * * yy The year as a two-digit number. "99" or "08" * yyyy The full four digit year. "1999" or "2008" * * t Displays the first character of the A.M./P.M. designator. "A" or "P" * Date.CultureInfo.amDesignator or Date.CultureInfo.pmDesignator * tt Displays the A.M./P.M. designator. "AM" or "PM" * Date.CultureInfo.amDesignator or Date.CultureInfo.pmDesignator * * S The ordinal suffix ("st, "nd", "rd" or "th") of the current day. "st, "nd", "rd" or "th" * * STANDARD DATE AND TIME FORMAT STRINGS * Format Description Example *------ --------------------------------------------------------------------------- ----------------------- * d The CultureInfo shortDate Format Pattern "M/d/yyyy" * D The CultureInfo longDate Format Pattern "dddd, MMMM dd, yyyy" * F The CultureInfo fullDateTime Format Pattern "dddd, MMMM dd, yyyy h:mm:ss tt" * m The CultureInfo monthDay Format Pattern "MMMM dd" * r The CultureInfo rfc1123 Format Pattern "ddd, dd MMM yyyy HH:mm:ss GMT" * s The CultureInfo sortableDateTime Format Pattern "yyyy-MM-ddTHH:mm:ss" * t The CultureInfo shortTime Format Pattern "h:mm tt" * T The CultureInfo longTime Format Pattern "h:mm:ss tt" * u The CultureInfo universalSortableDateTime Format Pattern "yyyy-MM-dd HH:mm:ssZ" * y The CultureInfo yearMonth Format Pattern "MMMM, yyyy" * * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @return {String} A string representation of the current Date object. */ var ord = function (n) { switch (n * 1) { case 1: case 21: case 31: return "st"; case 2: case 22: return "nd"; case 3: case 23: return "rd"; default: return "th"; } }; var parseStandardFormats = function (format) { var y, c = Date.CultureInfo.formatPatterns; switch (format) { case "d": return this.toString(c.shortDate); case "D": return this.toString(c.longDate); case "F": return this.toString(c.fullDateTime); case "m": return this.toString(c.monthDay); case "r": case "R": y = this.clone().addMinutes(this.getTimezoneOffset()); return y.toString(c.rfc1123) + " GMT"; case "s": return this.toString(c.sortableDateTime); case "t": return this.toString(c.shortTime); case "T": return this.toString(c.longTime); case "u": y = this.clone().addMinutes(this.getTimezoneOffset()); return y.toString(c.universalSortableDateTime); case "y": return this.toString(c.yearMonth); default: return false; } }; var parseFormatStringsClosure = function (context) { return function (m) { if (m.charAt(0) === "\\") { return m.replace("\\", ""); } switch (m) { case "hh": return p(context.getHours() < 13 ? (context.getHours() === 0 ? 12 : context.getHours()) : (context.getHours() - 12)); case "h": return context.getHours() < 13 ? (context.getHours() === 0 ? 12 : context.getHours()) : (context.getHours() - 12); case "HH": return p(context.getHours()); case "H": return context.getHours(); case "mm": return p(context.getMinutes()); case "m": return context.getMinutes(); case "ss": return p(context.getSeconds()); case "s": return context.getSeconds(); case "yyyy": return p(context.getFullYear(), 4); case "yy": return p(context.getFullYear()); case "y": return context.getFullYear(); case "E": case "dddd": return Date.CultureInfo.dayNames[context.getDay()]; case "ddd": return Date.CultureInfo.abbreviatedDayNames[context.getDay()]; case "dd": return p(context.getDate()); case "d": return context.getDate(); case "MMMM": return Date.CultureInfo.monthNames[context.getMonth()]; case "MMM": return Date.CultureInfo.abbreviatedMonthNames[context.getMonth()]; case "MM": return p((context.getMonth() + 1)); case "M": return context.getMonth() + 1; case "t": return context.getHours() < 12 ? Date.CultureInfo.amDesignator.substring(0, 1) : Date.CultureInfo.pmDesignator.substring(0, 1); case "tt": return context.getHours() < 12 ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator; case "S": return ord(context.getDate()); case "W": return context.getWeek(); case "WW": return context.getISOWeek(); case "Q": return "Q" + context.getQuarter(); case "q": return String(context.getQuarter()); case "z": return context.getTimezone(); case "Z": case "X": return Date.getTimezoneOffset(context.getTimezone()); case "ZZ": // Timezone offset in seconds return context.getTimezoneOffset() * -60; case "u": return context.getDay(); case "L": return ($D.isLeapYear(context.getFullYear())) ? 1 : 0; case "B": // Swatch Internet Time (.beats) return "@"+((context.getUTCSeconds() + (context.getUTCMinutes()*60) + ((context.getUTCHours()+1)*3600))/86.4); default: return m; } }; }; $P.toString = function (format, ignoreStandards) { // Standard Date and Time Format Strings. Formats pulled from CultureInfo file and // may vary by culture. if (!ignoreStandards && format && format.length === 1) { output = parseStandardFormats.call(this, format); if (output) { return output; } } var parseFormatStrings = parseFormatStringsClosure(this); return format ? format.replace(/((\\)?(dd?d?d?|MM?M?M?|yy?y?y?|hh?|HH?|mm?|ss?|tt?|S|q|Q|WW?W?W?)(?![^\[]*\]))/g, parseFormatStrings).replace(/\[|\]/g, "") : this._toString(); }; }()); /************************************************************* * SugarPak - Domain Specific Language - Syntactical Sugar * *************************************************************/ (function () { var $D = Date, $P = $D.prototype, $N = Number.prototype; // private $P._orient = +1; // private $P._nth = null; // private $P._is = false; // private $P._same = false; // private $P._isSecond = false; // private $N._dateElement = "days"; /** * Moves the date to the next instance of a date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.today().next().friday();
	Date.today().next().fri();
	Date.today().next().march();
	Date.today().next().mar();
	Date.today().next().week();
	
* * @return {Date} date */ $P.next = function () { this._move = true; this._orient = +1; return this; }; /** * Creates a new Date (Date.today()) and moves the date to the next instance of the date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.next().friday();
	Date.next().fri();
	Date.next().march();
	Date.next().mar();
	Date.next().week();
	
* * @return {Date} date */ $D.next = function () { return $D.today().next(); }; /** * Moves the date to the previous instance of a date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.today().last().friday();
	Date.today().last().fri();
	Date.today().last().march();
	Date.today().last().mar();
	Date.today().last().week();
	
* * @return {Date} date */ $P.last = $P.prev = $P.previous = function () { this._move = true; this._orient = -1; return this; }; /** * Creates a new Date (Date.today()) and moves the date to the previous instance of the date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.last().friday();
	Date.last().fri();
	Date.previous().march();
	Date.prev().mar();
	Date.last().week();
	
* * @return {Date} date */ $D.last = $D.prev = $D.previous = function () { return $D.today().last(); }; /** * Performs a equality check when followed by either a month name, day name or .weekday() function. * Example

	Date.today().is().friday(); // true|false
	Date.today().is().fri();
	Date.today().is().march();
	Date.today().is().mar();
	
* * @return {Boolean} true|false */ $P.is = function () { this._is = true; return this; }; /** * Determines if two date objects occur on/in exactly the same instance of the subsequent date part function. * The function .same() must be followed by a date part function (example: .day(), .month(), .year(), etc). * * An optional Date can be passed in the date part function. If now date is passed as a parameter, 'Now' is used. * * The following example demonstrates how to determine if two dates fall on the exact same day. * * Example

	var d1 = Date.today(); // today at 00:00
	var d2 = new Date();   // exactly now.

	// Do they occur on the same day?
	d1.same().day(d2); // true
	
	// Do they occur on the same hour?
	d1.same().hour(d2); // false, unless d2 hour is '00' (midnight).
	
	// What if it's the same day, but one year apart?
	var nextYear = Date.today().add(1).year();

	d1.same().day(nextYear); // false, because the dates must occur on the exact same day. 
	
* * Scenario: Determine if a given date occurs during some week period 2 months from now. * * Example

	var future = Date.today().add(2).months();
	return someDate.same().week(future); // true|false;
	
* * @return {Boolean} true|false */ $P.same = function () { this._same = true; this._isSecond = false; return this; }; /** * Determines if the current date/time occurs during Today. Must be preceded by the .is() function. * Example

	someDate.is().today();    // true|false
	new Date().is().today();  // true
	Date.today().is().today();// true
	Date.today().add(-1).day().is().today(); // false
	
* * @return {Boolean} true|false */ $P.today = function () { return this.same().day(); }; /** * Determines if the current date is a weekday. This function must be preceded by the .is() function. * Example

	Date.today().is().weekday(); // true|false
	
* * @return {Boolean} true|false */ $P.weekday = function () { if (this._nth) { return df("Weekday").call(this); } if (this._move) { return this.addWeekdays(this._orient); } if (this._is) { this._is = false; return (!this.is().sat() && !this.is().sun()); } return false; }; /** * Determines if the current date is on the weekend. This function must be preceded by the .is() function. * Example

	Date.today().is().weekend(); // true|false
	
* * @return {Boolean} true|false */ $P.weekend = function () { if (this._is) { this._is = false; return (this.is().sat() || this.is().sun()); } return false; }; /** * Sets the Time of the current Date instance. A string "6:15 pm" or config object {hour:18, minute:15} are accepted. * Example

	// Set time to 6:15pm with a String
	Date.today().at("6:15pm");

	// Set time to 6:15pm with a config object
	Date.today().at({hour:18, minute:15});
	
* * @return {Date} date */ $P.at = function (time) { return (typeof time === "string") ? $D.parse(this.toString("d") + " " + time) : this.set(time); }; /** * Creates a new Date() and adds this (Number) to the date based on the preceding date element function (eg. second|minute|hour|day|month|year). * Example

	// Undeclared Numbers must be wrapped with parentheses. Requirment of JavaScript.
	(3).days().fromNow();
	(6).months().fromNow();

	// Declared Number variables do not require parentheses. 
	var n = 6;
	n.months().fromNow();
	
* * @return {Date} A new Date instance */ $N.fromNow = $N.after = function (date) { var c = {}; c[this._dateElement] = this; return ((!date) ? new Date() : date.clone()).add(c); }; /** * Creates a new Date() and subtract this (Number) from the date based on the preceding date element function (eg. second|minute|hour|day|month|year). * Example

	// Undeclared Numbers must be wrapped with parentheses. Requirment of JavaScript.
	(3).days().ago();
	(6).months().ago();

	// Declared Number variables do not require parentheses. 
	var n = 6;
	n.months().ago();
	
* * @return {Date} A new Date instance */ $N.ago = $N.before = function (date) { var c = {}, s = (this._dateElement[this._dateElement.length-1] !== "s") ? this._dateElement + "s" : this._dateElement; c[s] = this * -1; return ((!date) ? new Date() : date.clone()).add(c); }; // Do NOT modify the following string tokens. These tokens are used to build dynamic functions. // All culture-specific strings can be found in the CultureInfo files. var dx = ("sunday monday tuesday wednesday thursday friday saturday").split(/\s/), mx = ("january february march april may june july august september october november december").split(/\s/), px = ("Millisecond Second Minute Hour Day Week Month Year Quarter Weekday").split(/\s/), pxf = ("Milliseconds Seconds Minutes Hours Date Week Month FullYear Quarter").split(/\s/), nth = ("final first second third fourth fifth").split(/\s/), de; /** * Returns an object literal of all the date parts. * Example

	var o = new Date().toObject();
	
	// { year: 2008, month: 4, week: 20, day: 13, hour: 18, minute: 9, second: 32, millisecond: 812 }
	
	// The object properties can be referenced directly from the object.
	
	alert(o.day);  // alerts "13"
	alert(o.year); // alerts "2008"
	
* * @return {Date} An object literal representing the original date object. */ $P.toObject = function () { var o = {}; for (var i = 0; i < px.length; i++) { if (this["get" + pxf[i]]) { o[px[i].toLowerCase()] = this["get" + pxf[i]](); } } return o; }; /** * Returns a date created from an object literal. Ignores the .week property if set in the config. * Example

	var o = new Date().toObject();
	
	return Date.fromObject(o); // will return the same date. 

	var o2 = {month: 1, day: 20, hour: 18}; // birthday party!
	Date.fromObject(o2);
	
* * @return {Date} An object literal representing the original date object. */ $D.fromObject = function(config) { config.week = null; return Date.today().set(config); }; // Create day name functions and abbreviated day name functions (eg. monday(), friday(), fri()). var df = function (n) { return function () { if (this._is) { this._is = false; return this.getDay() === n; } if (this._move) { this._move = null; } if (this._nth !== null) { // If the .second() function was called earlier, remove the _orient // from the date, and then continue. // This is required because 'second' can be used in two different context. // // Example // // Date.today().add(1).second(); // Date.march().second().monday(); // // Things get crazy with the following... // Date.march().add(1).second().second().monday(); // but it works!! // if (this._isSecond) { this.addSeconds(this._orient * -1); } // make sure we reset _isSecond this._isSecond = false; var ntemp = this._nth; this._nth = null; var temp = this.clone().moveToLastDayOfMonth(); this.moveToNthOccurrence(n, ntemp); if (this > temp) { throw new RangeError($D.getDayName(n) + " does not occur " + ntemp + " times in the month of " + $D.getMonthName(temp.getMonth()) + " " + temp.getFullYear() + "."); } return this; } return this.moveToDayOfWeek(n, this._orient); }; }; var sdf = function (n) { return function () { var t = $D.today(), shift = n - t.getDay(); if (n === 0 && Date.CultureInfo.firstDayOfWeek === 1 && t.getDay() !== 0) { shift = shift + 7; } return t.addDays(shift); }; }; // Create month name functions and abbreviated month name functions (eg. january(), march(), mar()). var month_instance_functions = function (n) { return function () { if (this._is) { this._is = false; return this.getMonth() === n; } return this.moveToMonth(n, this._orient); }; }; var month_static_functions = function (n) { return function () { return $D.today().set({ month: n, day: 1 }); }; }; var processTerms = function (names, staticFunc, instanceFunc) { for (var i = 0; i < names.length; i++) { // Create constant static Name variables. $D[names[i].toUpperCase()] = $D[names[i].toUpperCase().substring(0, 3)] = i; // Create Name functions. $D[names[i]] = $D[names[i].substring(0, 3)] = staticFunc(i); // Create Name instance functions. $P[names[i]] = $P[names[i].substring(0, 3)] = instanceFunc(i); } }; processTerms(dx, sdf, df); processTerms(mx, month_static_functions, month_instance_functions); // Create date element functions and plural date element functions used with Date (eg. day(), days(), months()). var ef = function (j) { return function () { // if the .second() function was called earlier, the _orient // has alread been added. Just return this and reset _isSecond. if (this._isSecond) { this._isSecond = false; return this; } if (this._same) { this._same = this._is = false; var o1 = this.toObject(), o2 = (arguments[0] || new Date()).toObject(), v = "", k = j.toLowerCase(); // the substr trick with -1 doesn't work in IE8 or less k = (k[k.length-1] === "s") ? k.substring(0,k.length-1) : k; for (var m = (px.length - 1); m > -1; m--) { v = px[m].toLowerCase(); if (o1[v] !== o2[v]) { return false; } if (k === v) { break; } } return true; } if (j.substring(j.length - 1) !== "s") { j += "s"; } if (this._move) { this._move = null; } return this["add" + j](this._orient); }; }; var nf = function (n) { return function () { this._dateElement = n; return this; }; }; for (var k = 0; k < px.length; k++) { de = px[k].toLowerCase(); if(de !== "weekday") { // Create date element functions and plural date element functions used with Date (eg. day(), days(), months()). $P[de] = $P[de + "s"] = ef(px[k]); // Create date element functions and plural date element functions used with Number (eg. day(), days(), months()). $N[de] = $N[de + "s"] = nf(de + "s"); } } $P._ss = ef("Second"); var nthfn = function (n) { return function (dayOfWeek) { if (this._same) { return this._ss(arguments[0]); } if (dayOfWeek || dayOfWeek === 0) { return this.moveToNthOccurrence(dayOfWeek, n); } this._nth = n; // if the operator is 'second' add the _orient, then deal with it later... if (n === 2 && (dayOfWeek === undefined || dayOfWeek === null)) { this._isSecond = true; return this.addSeconds(this._orient); } return this; }; }; for (var l = 0; l < nth.length; l++) { $P[nth[l]] = (l === 0) ? nthfn(-1) : nthfn(l); } }()); (function () { "use strict"; Date.Parsing = { Exception: function (s) { this.message = "Parse error at '" + s.substring(0, 10) + " ...'"; } }; var $P = Date.Parsing; var dayOffsets = { standard: [0,31,59,90,120,151,181,212,243,273,304,334], leap: [0,31,60,91,121,152,182,213,244,274,305,335] }; $P.isLeapYear = function(year) { return ((year % 4 === 0) && (year % 100 !== 0)) || (year % 400 === 0); }; var utils = { multiReplace : function (str, hash ) { var key; for (key in hash) { if (Object.prototype.hasOwnProperty.call(hash, key)) { var regex; if (typeof hash[key] === "function") { } else { regex = (hash[key] instanceof RegExp) ? hash[key] : new RegExp(hash[key], "g"); } str = str.replace(regex, key); } } return str; }, getDayOfYearFromWeek : function (obj) { var d, jan4, offset; obj.weekDay = (!obj.weekDay && obj.weekDay !== 0) ? 1 : obj.weekDay; d = new Date(obj.year, 0, 4); jan4 = d.getDay() === 0 ? 7 : d.getDay(); // JS is 0 indexed on Sunday. offset = jan4+3; obj.dayOfYear = ((obj.week * 7) + (obj.weekDay === 0 ? 7 : obj.weekDay))-offset; return obj; }, getDayOfYear : function (obj, dayOffset) { if (!obj.dayOfYear) { obj = utils.getDayOfYearFromWeek(obj); } for (var i=0;i <= dayOffset.length;i++) { if (obj.dayOfYear < dayOffset[i] || i === dayOffset.length) { obj.day = obj.day ? obj.day : (obj.dayOfYear - dayOffset[i-1]); break; } else { obj.month = i; } } return obj; }, adjustForTimeZone : function (obj, date) { var offset; if (obj.zone.toUpperCase() === "Z" || (obj.zone_hours === 0 && obj.zone_minutes === 0)) { // it's UTC/GML so work out the current timeszone offset offset = -date.getTimezoneOffset(); } else { offset = (obj.zone_hours*60) + (obj.zone_minutes || 0); if (obj.zone_sign === "+") { offset *= -1; } offset -= date.getTimezoneOffset(); } date.setMinutes(date.getMinutes()+offset); return date; }, setDefaults : function (obj) { obj.year = obj.year || Date.today().getFullYear(); obj.hours = obj.hours || 0; obj.minutes = obj.minutes || 0; obj.seconds = obj.seconds || 0; obj.milliseconds = obj.milliseconds || 0; if (!(!obj.month && (obj.week || obj.dayOfYear))) { // if we have a month, or if we don't but don't have the day calculation data obj.month = obj.month || 0; obj.day = obj.day || 1; } return obj; }, dataNum: function (data, mod, explict, postProcess) { var dataNum = data*1; if (mod) { if (postProcess) { return data ? mod(data)*1 : data; } else { return data ? mod(dataNum) : data; } } else if (!explict){ return data ? dataNum : data; } else { return (data && typeof data !== "undefined") ? dataNum : data; } }, timeDataProcess: function (obj) { var timeObj = {}; for (var x in obj.data) { if (obj.data.hasOwnProperty(x)) { timeObj[x] = obj.ignore[x] ? obj.data[x] : utils.dataNum(obj.data[x], obj.mods[x], obj.explict[x], obj.postProcess[x]); } } if (obj.data.secmins) { obj.data.secmins = obj.data.secmins.replace(",", ".") * 60; if (!timeObj.minutes) { timeObj.minutes = obj.data.secmins; } else if (!timeObj.seconds) { timeObj.seconds = obj.data.secmins; } delete obj.secmins; } return timeObj; }, buildTimeObjectFromData: function (data) { var time = utils.timeDataProcess({ data: { year : data[1], month : data[5], day : data[7], week : data[8], dayOfYear : data[10], hours : data[15], zone_hours : data[23], zone_minutes : data[24], zone : data[21], zone_sign : data[22], weekDay : data[9], minutes: data[16], seconds: data[19], milliseconds: data[20], secmins: data[18] }, mods: { month: function(data) { return data-1; }, weekDay: function (data) { data = Math.abs(data); return (data === 7 ? 0 : data); }, minutes: function (data) { return data.replace(":",""); }, seconds: function (data) { return Math.floor( (data.replace(":","").replace(",","."))*1 ); }, milliseconds: function (data) { return (data.replace(",",".")*1000); } }, postProcess: { minutes: true, seconds: true, milliseconds: true }, explict: { zone_hours: true, zone_minutes: true }, ignore: { zone: true, zone_sign: true, secmins: true } }); return time; }, addToHash: function (hash, keys, data) { keys = keys; data = data; var len = keys.length; for (var i = 0; i < len; i++) { hash[keys[i]] = data[i]; } return hash; }, combineRegex: function (r1, r2) { return new RegExp("(("+r1.source+")\\s("+r2.source+"))"); }, getDateNthString: function(add, last, inc){ if (add) { return Date.today().addDays(inc).toString("d"); } else if (last) { return Date.today().last()[inc]().toString("d"); } }, buildRegexData: function (array) { var arr = []; var len = array.length; for (var i=0; i < len; i++) { if (Object.prototype.toString.call(array[i]) === '[object Array]') { // oldIE compat version of Array.isArray arr.push(this.combineRegex(array[i][0], array[i][1])); } else { arr.push(array[i]); } } return arr; } }; $P.processTimeObject = function (obj) { var date, dayOffset; utils.setDefaults(obj); dayOffset = ($P.isLeapYear(obj.year)) ? dayOffsets.leap : dayOffsets.standard; if (!obj.month && (obj.week || obj.dayOfYear)) { utils.getDayOfYear(obj, dayOffset); } else { obj.dayOfYear = dayOffset[obj.month] + obj.day; } date = new Date(obj.year, obj.month, obj.day, obj.hours, obj.minutes, obj.seconds, obj.milliseconds); if (obj.zone) { utils.adjustForTimeZone(obj, date); // adjust (and calculate) for timezone } return date; }; $P.ISO = { regex : /^([\+-]?\d{4}(?!\d{2}\b))((-?)((0[1-9]|1[0-2])(\3([12]\d|0[1-9]|3[01]))?|W([0-4]\d|5[0-3])(-?[1-7])?|(00[1-9]|0[1-9]\d|[12]\d{2}|3([0-5]\d|6[1-6])))([T\s]((([01]\d|2[0-4])((:?)[0-5]\d)?|24\:?00)([\.,]\d+(?!:))?)?(\17[0-5]\d([\.,]\d+)?)?\s?([zZ]|([\+-])([01]\d|2[0-3]):?([0-5]\d)?)?)?)?$/, parse : function (s) { var time, data = s.match(this.regex); if (!data || !data.length) { return null; } time = utils.buildTimeObjectFromData(data); if (!time.year || (!time.year && (!time.month && !time.day) && (!time.week && !time.dayOfYear)) ) { return null; } return $P.processTimeObject(time); } }; $P.Numeric = { isNumeric: function (e){return!isNaN(parseFloat(e))&&isFinite(e);}, regex: /\b([0-1]?[0-9])([0-3]?[0-9])([0-2]?[0-9]?[0-9][0-9])\b/i, parse: function (s) { var data, i, time = {}, order = Date.CultureInfo.dateElementOrder.split(""); if (!(this.isNumeric(s)) || // if it's non-numeric OR (s[0] === "+" && s[0] === "-")) { // It's an arithmatic string (eg +/-1000) return null; } if (s.length < 5 && s.indexOf(".") < 0 && s.indexOf("/") < 0) { // assume it's just a year. time.year = s; return $P.processTimeObject(time); } data = s.match(this.regex); if (!data || !data.length) { return null; } for (i=0; i < order.length; i++) { switch(order[i]) { case "d": time.day = data[i+1]; break; case "m": time.month = (data[i+1]-1); break; case "y": time.year = data[i+1]; break; } } return $P.processTimeObject(time); } }; $P.Normalizer = { regexData: function () { var $R = Date.CultureInfo.regexPatterns; return utils.buildRegexData([ $R.tomorrow, $R.yesterday, [$R.past, $R.mon], [$R.past, $R.tue], [$R.past, $R.wed], [$R.past, $R.thu], [$R.past, $R.fri], [$R.past, $R.sat], [$R.past, $R.sun] ]); }, basicReplaceHash : function() { var $R = Date.CultureInfo.regexPatterns; return { "January": $R.jan.source, "February": $R.feb, "March": $R.mar, "April": $R.apr, "May": $R.may, "June": $R.jun, "July": $R.jul, "August": $R.aug, "September": $R.sep, "October": $R.oct, "November": $R.nov, "December": $R.dec, "": /\bat\b/gi, " ": /\s{2,}/, "am": $R.inTheMorning, "9am": $R.thisMorning, "pm": $R.inTheEvening, "7pm":$R.thisEvening }; }, keys : function(){ return [ utils.getDateNthString(true, false, 1), // tomorrow utils.getDateNthString(true, false, -1), // yesterday utils.getDateNthString(false, true, "monday"), //last mon utils.getDateNthString(false, true, "tuesday"), //last tues utils.getDateNthString(false, true, "wednesday"), //last wed utils.getDateNthString(false, true, "thursday"), //last thurs utils.getDateNthString(false, true, "friday"), //last fri utils.getDateNthString(false, true, "saturday"), //last sat utils.getDateNthString(false, true, "sunday") //last sun ]; }, buildRegexFunctions: function () { var $R = Date.CultureInfo.regexPatterns; var __ = Date.i18n.__; var tomorrowRE = new RegExp("(\\b\\d\\d?("+__("AM")+"|"+__("PM")+")? )("+$R.tomorrow.source.slice(1)+")", "i"); // adapted tomorrow regex for AM PM relative dates var todayRE = new RegExp($R.today.source + "(?!\\s*([+-]))\\b"); // today, but excludes the math operators (eg "today + 2h") this.replaceFuncs = [ [todayRE, function (full) { return (full.length > 1) ? Date.today().toString("d") : full; }], [tomorrowRE, function(full, m1) { var t = Date.today().addDays(1).toString("d"); return (t + " " + m1); }], [$R.amThisMorning, function(str, am){return am;}], [$R.pmThisEvening, function(str, pm){return pm;}] ]; }, buildReplaceData: function () { this.buildRegexFunctions(); this.replaceHash = utils.addToHash(this.basicReplaceHash(), this.keys(), this.regexData()); }, stringReplaceFuncs: function (s) { for (var i=0; i < this.replaceFuncs.length; i++) { s = s.replace(this.replaceFuncs[i][0], this.replaceFuncs[i][1]); } return s; }, parse: function (s) { s = this.stringReplaceFuncs(s); s = utils.multiReplace(s, this.replaceHash); try { var n = s.split(/([\s\-\.\,\/\x27]+)/); if (n.length === 3 && $P.Numeric.isNumeric(n[0]) && $P.Numeric.isNumeric(n[2]) && (n[2].length >= 4)) { // ok, so we're dealing with x/year. But that's not a full date. // This fixes wonky dateElementOrder parsing when set to dmy order. if (Date.CultureInfo.dateElementOrder[0] === "d") { s = "1/" + n[0] + "/" + n[2]; // set to 1st of month and normalize the seperator } } } catch (e) {} return s; } }; $P.Normalizer.buildReplaceData(); }()); (function () { var $P = Date.Parsing; var _ = $P.Operators = { // // Tokenizers // rtoken: function (r) { // regex token return function (s) { var mx = s.match(r); if (mx) { return ([ mx[0], s.substring(mx[0].length) ]); } else { throw new $P.Exception(s); } }; }, token: function () { // whitespace-eating token return function (s) { return _.rtoken(new RegExp("^\\s*" + s + "\\s*"))(s); }; }, stoken: function (s) { // string token return _.rtoken(new RegExp("^" + s)); }, // Atomic Operators until: function (p) { return function (s) { var qx = [], rx = null; while (s.length) { try { rx = p.call(this, s); } catch (e) { qx.push(rx[0]); s = rx[1]; continue; } break; } return [ qx, s ]; }; }, many: function (p) { return function (s) { var rx = [], r = null; while (s.length) { try { r = p.call(this, s); } catch (e) { return [ rx, s ]; } rx.push(r[0]); s = r[1]; } return [ rx, s ]; }; }, // generator operators -- see below optional: function (p) { return function (s) { var r = null; try { r = p.call(this, s); } catch (e) { return [ null, s ]; } return [ r[0], r[1] ]; }; }, not: function (p) { return function (s) { try { p.call(this, s); } catch (e) { return [null, s]; } throw new $P.Exception(s); }; }, ignore: function (p) { return p ? function (s) { var r = null; r = p.call(this, s); return [null, r[1]]; } : null; }, product: function () { var px = arguments[0], qx = Array.prototype.slice.call(arguments, 1), rx = []; for (var i = 0 ; i < px.length ; i++) { rx.push(_.each(px[i], qx)); } return rx; }, cache: function (rule) { var cache = {}, cache_length = 0, cache_keys = [], CACHE_MAX = Date.Config.CACHE_MAX || 100000, r = null; var cacheCheck = function () { if (cache_length === CACHE_MAX) { // kill several keys, don't want to have to do this all the time... for (var i=0; i < 10; i++) { var key = cache_keys.shift(); if (key) { delete cache[key]; cache_length--; } } } }; return function (s) { cacheCheck(); try { r = cache[s] = (cache[s] || rule.call(this, s)); } catch (e) { r = cache[s] = e; } cache_length++; cache_keys.push(s); if (r instanceof $P.Exception) { throw r; } else { return r; } }; }, // vector operators -- see below any: function () { var px = arguments; return function (s) { var r = null; for (var i = 0; i < px.length; i++) { if (px[i] == null) { continue; } try { r = (px[i].call(this, s)); } catch (e) { r = null; } if (r) { return r; } } throw new $P.Exception(s); }; }, each: function () { var px = arguments; return function (s) { var rx = [], r = null; for (var i = 0; i < px.length ; i++) { if (px[i] == null) { continue; } try { r = (px[i].call(this, s)); } catch (e) { throw new $P.Exception(s); } rx.push(r[0]); s = r[1]; } return [ rx, s]; }; }, all: function () { var px = arguments, _ = _; return _.each(_.optional(px)); }, // delimited operators sequence: function (px, d, c) { d = d || _.rtoken(/^\s*/); c = c || null; if (px.length === 1) { return px[0]; } return function (s) { var r = null, q = null; var rx = []; for (var i = 0; i < px.length ; i++) { try { r = px[i].call(this, s); } catch (e) { break; } rx.push(r[0]); try { q = d.call(this, r[1]); } catch (ex) { q = null; break; } s = q[1]; } if (!r) { throw new $P.Exception(s); } if (q) { throw new $P.Exception(q[1]); } if (c) { try { r = c.call(this, r[1]); } catch (ey) { throw new $P.Exception(r[1]); } } return [ rx, (r?r[1]:s) ]; }; }, // // Composite Operators // between: function (d1, p, d2) { d2 = d2 || d1; var _fn = _.each(_.ignore(d1), p, _.ignore(d2)); return function (s) { var rx = _fn.call(this, s); return [[rx[0][0], r[0][2]], rx[1]]; }; }, list: function (p, d, c) { d = d || _.rtoken(/^\s*/); c = c || null; return (p instanceof Array ? _.each(_.product(p.slice(0, -1), _.ignore(d)), p.slice(-1), _.ignore(c)) : _.each(_.many(_.each(p, _.ignore(d))), px, _.ignore(c))); }, set: function (px, d, c) { d = d || _.rtoken(/^\s*/); c = c || null; return function (s) { // r is the current match, best the current 'best' match // which means it parsed the most amount of input var r = null, p = null, q = null, rx = null, best = [[], s], last = false; // go through the rules in the given set for (var i = 0; i < px.length ; i++) { // last is a flag indicating whether this must be the last element // if there is only 1 element, then it MUST be the last one q = null; p = null; r = null; last = (px.length === 1); // first, we try simply to match the current pattern // if not, try the next pattern try { r = px[i].call(this, s); } catch (e) { continue; } // since we are matching against a set of elements, the first // thing to do is to add r[0] to matched elements rx = [[r[0]], r[1]]; // if we matched and there is still input to parse and // we don't already know this is the last element, // we're going to next check for the delimiter ... // if there's none, or if there's no input left to parse // than this must be the last element after all ... if (r[1].length > 0 && ! last) { try { q = d.call(this, r[1]); } catch (ex) { last = true; } } else { last = true; } // if we parsed the delimiter and now there's no more input, // that means we shouldn't have parsed the delimiter at all // so don't update r and mark this as the last element ... if (!last && q[1].length === 0) { last = true; } // so, if this isn't the last element, we're going to see if // we can get any more matches from the remaining (unmatched) // elements ... if (!last) { // build a list of the remaining rules we can match against, // i.e., all but the one we just matched against var qx = []; for (var j = 0; j < px.length ; j++) { if (i !== j) { qx.push(px[j]); } } // now invoke recursively set with the remaining input // note that we don't include the closing delimiter ... // we'll check for that ourselves at the end p = _.set(qx, d).call(this, q[1]); // if we got a non-empty set as a result ... // (otw rx already contains everything we want to match) if (p[0].length > 0) { // update current result, which is stored in rx ... // basically, pick up the remaining text from p[1] // and concat the result from p[0] so that we don't // get endless nesting ... rx[0] = rx[0].concat(p[0]); rx[1] = p[1]; } } // at this point, rx either contains the last matched element // or the entire matched set that starts with this element. // now we just check to see if this variation is better than // our best so far, in terms of how much of the input is parsed if (rx[1].length < best[1].length) { best = rx; } // if we've parsed all the input, then we're finished if (best[1].length === 0) { break; } } // so now we've either gone through all the patterns trying them // as the initial match; or we found one that parsed the entire // input string ... // if best has no matches, just return empty set ... if (best[0].length === 0) { return best; } // if a closing delimiter is provided, then we have to check it also if (c) { // we try this even if there is no remaining input because the pattern // may well be optional or match empty input ... try { q = c.call(this, best[1]); } catch (ey) { throw new $P.Exception(best[1]); } // it parsed ... be sure to update the best match remaining input best[1] = q[1]; } // if we're here, either there was no closing delimiter or we parsed it // so now we have the best match; just return it! return best; }; }, forward: function (gr, fname) { return function (s) { return gr[fname].call(this, s); }; }, // // Translation Operators // replace: function (rule, repl) { return function (s) { var r = rule.call(this, s); return [repl, r[1]]; }; }, process: function (rule, fn) { return function (s) { var r = rule.call(this, s); return [fn.call(this, r[0]), r[1]]; }; }, min: function (min, rule) { return function (s) { var rx = rule.call(this, s); if (rx[0].length < min) { throw new $P.Exception(s); } return rx; }; } }; // Generator Operators And Vector Operators // Generators are operators that have a signature of F(R) => R, // taking a given rule and returning another rule, such as // ignore, which parses a given rule and throws away the result. // Vector operators are those that have a signature of F(R1,R2,...) => R, // take a list of rules and returning a new rule, such as each. // Generator operators are converted (via the following _generator // function) into functions that can also take a list or array of rules // and return an array of new rules as though the function had been // called on each rule in turn (which is what actually happens). // This allows generators to be used with vector operators more easily. // Example: // each(ignore(foo, bar)) instead of each(ignore(foo), ignore(bar)) // This also turns generators into vector operators, which allows // constructs like: // not(cache(foo, bar)) var _generator = function (op) { function gen() { var args = null, rx = [], px, i; if (arguments.length > 1) { args = Array.prototype.slice.call(arguments); } else if (arguments[0] instanceof Array) { args = arguments[0]; } if (args) { px = args.shift(); if (px.length > 0) { args.unshift(px[i]); rx.push(op.apply(null, args)); args.shift(); return rx; } } else { return op.apply(null, arguments); } } return gen; }; var gx = "optional not ignore cache".split(/\s/); for (var i = 0 ; i < gx.length ; i++) { _[gx[i]] = _generator(_[gx[i]]); } var _vector = function (op) { return function () { if (arguments[0] instanceof Array) { return op.apply(null, arguments[0]); } else { return op.apply(null, arguments); } }; }; var vx = "each any all".split(/\s/); for (var j = 0 ; j < vx.length ; j++) { _[vx[j]] = _vector(_[vx[j]]); } }()); (function () { var $D = Date; var flattenAndCompact = function (ax) { var rx = []; for (var i = 0; i < ax.length; i++) { if (ax[i] instanceof Array) { rx = rx.concat(flattenAndCompact(ax[i])); } else { if (ax[i]) { rx.push(ax[i]); } } } return rx; }; var parseMeridian = function () { if (this.meridian && (this.hour || this.hour === 0)) { if (this.meridian === "a" && this.hour > 11 && Date.Config.strict24hr){ throw "Invalid hour and meridian combination"; } else if (this.meridian === "p" && this.hour < 12 && Date.Config.strict24hr){ throw "Invalid hour and meridian combination"; } else if (this.meridian === "p" && this.hour < 12) { this.hour = this.hour + 12; } else if (this.meridian === "a" && this.hour === 12) { this.hour = 0; } } }; var setDefaults = function () { var now = new Date(); if ((this.hour || this.minute) && (!this.month && !this.year && !this.day)) { this.day = now.getDate(); } if (!this.year) { this.year = now.getFullYear(); } if (!this.month && this.month !== 0) { this.month = now.getMonth(); } if (!this.day) { this.day = 1; } if (!this.hour) { this.hour = 0; } if (!this.minute) { this.minute = 0; } if (!this.second) { this.second = 0; } if (!this.millisecond) { this.millisecond = 0; } }; var finishUtils = { getToday: function () { if (this.now || "hour minute second".indexOf(this.unit) !== -1) { return new Date(); } else { return $D.today(); } }, setDaysFromWeekday: function (today, orient){ var gap; orient = orient || 1; this.unit = "day"; gap = ($D.getDayNumberFromName(this.weekday) - today.getDay()); this.days = gap ? ((gap + (orient * 7)) % 7) : (orient * 7); return this; }, setMonthsFromMonth: function (today, orient) { var gap; orient = orient || 1; this.unit = "month"; gap = (this.month - today.getMonth()); this.months = gap ? ((gap + (orient * 12)) % 12) : (orient * 12); this.month = null; return this; }, setDMYFromWeekday: function () { var d = Date[this.weekday](); this.day = d.getDate(); if (!this.month) { this.month = d.getMonth(); } this.year = d.getFullYear(); return this; }, setUnitValue: function (orient) { if (!this.value && this.operator && this.operator !== null && this[this.unit + "s"] && this[this.unit + "s"] !== null) { this[this.unit + "s"] = this[this.unit + "s"] + ((this.operator === "add") ? 1 : -1) + (this.value||0) * orient; } else if (this[this.unit + "s"] == null || this.operator != null) { if (!this.value) { this.value = 1; } this[this.unit + "s"] = this.value * orient; } }, generateDateFromWeeks: function () { var weekday = (this.weekday !== undefined) ? this.weekday : "today"; var d = Date[weekday]().addWeeks(this.weeks); if (this.now) { d.setTimeToNow(); } return d; } }; $D.Translator = { hour: function (s) { return function () { this.hour = Number(s); }; }, minute: function (s) { return function () { this.minute = Number(s); }; }, second: function (s) { return function () { this.second = Number(s); }; }, /* for ss.s format */ secondAndMillisecond: function (s) { return function () { var mx = s.match(/^([0-5][0-9])\.([0-9]{1,3})/); this.second = Number(mx[1]); this.millisecond = Number(mx[2]); }; }, meridian: function (s) { return function () { this.meridian = s.slice(0, 1).toLowerCase(); }; }, timezone: function (s) { return function () { var n = s.replace(/[^\d\+\-]/g, ""); if (n.length) { this.timezoneOffset = Number(n); } else { this.timezone = s.toLowerCase(); } }; }, day: function (x) { var s = x[0]; return function () { this.day = Number(s.match(/\d+/)[0]); if (this.day < 1) { throw "invalid day"; } }; }, month: function (s) { return function () { this.month = (s.length === 3) ? "jan feb mar apr may jun jul aug sep oct nov dec".indexOf(s)/4 : Number(s) - 1; if (this.month < 0) { throw "invalid month"; } }; }, year: function (s) { return function () { var n = Number(s); this.year = ((s.length > 2) ? n : (n + (((n + 2000) < Date.CultureInfo.twoDigitYearMax) ? 2000 : 1900))); }; }, rday: function (s) { return function () { switch (s) { case "yesterday": this.days = -1; break; case "tomorrow": this.days = 1; break; case "today": this.days = 0; break; case "now": this.days = 0; this.now = true; break; } }; }, finishExact: function (x) { var d; x = (x instanceof Array) ? x : [x]; for (var i = 0 ; i < x.length ; i++) { if (x[i]) { x[i].call(this); } } setDefaults.call(this); parseMeridian.call(this); if (this.day > $D.getDaysInMonth(this.year, this.month)) { throw new RangeError(this.day + " is not a valid value for days."); } d = new Date(this.year, this.month, this.day, this.hour, this.minute, this.second, this.millisecond); if (this.year < 100) { d.setFullYear(this.year); // means years less that 100 are process correctly. JS will parse it otherwise as 1900-1999. } if (this.timezone) { d.set({ timezone: this.timezone }); } else if (this.timezoneOffset) { d.set({ timezoneOffset: this.timezoneOffset }); } return d; }, finish: function (x) { var today, expression, orient, temp; x = (x instanceof Array) ? flattenAndCompact(x) : [ x ]; if (x.length === 0) { return null; } for (var i = 0 ; i < x.length ; i++) { if (typeof x[i] === "function") { x[i].call(this); } } if (this.now && !this.unit && !this.operator) { return new Date(); } else { today = finishUtils.getToday.call(this); } expression = !!(this.days && this.days !== null || this.orient || this.operator); orient = ((this.orient === "past" || this.operator === "subtract") ? -1 : 1); if (this.month && this.unit === "week") { this.value = this.month + 1; delete this.month; delete this.day; } if ((this.month || this.month === 0) && "year day hour minute second".indexOf(this.unit) !== -1) { if (!this.value) { this.value = this.month + 1; } this.month = null; expression = true; } if (!expression && this.weekday && !this.day && !this.days) { finishUtils.setDMYFromWeekday.call(this); } if (expression && this.weekday && this.unit !== "month" && this.unit !== "week") { finishUtils.setDaysFromWeekday.call(this, today, orient); } if (this.weekday && this.unit !== "week" && !this.day && !this.days) { temp = Date[this.weekday](); this.day = temp.getDate(); if (temp.getMonth() !== today.getMonth()) { this.month = temp.getMonth(); } } if (this.month && this.unit === "day" && this.operator) { if (!this.value) { this.value = (this.month + 1); } this.month = null; } if (this.value != null && this.month != null && this.year != null) { this.day = this.value * 1; } if (this.month && !this.day && this.value) { today.set({ day: this.value * 1 }); if (!expression) { this.day = this.value * 1; } } if (!this.month && this.value && this.unit === "month" && !this.now) { this.month = this.value; expression = true; } if (expression && (this.month || this.month === 0) && this.unit !== "year") { finishUtils.setMonthsFromMonth.call(this, today, orient); } if (!this.unit) { this.unit = "day"; } finishUtils.setUnitValue.call(this, orient); parseMeridian.call(this); if ((this.month || this.month === 0) && !this.day) { this.day = 1; } if (!this.orient && !this.operator && this.unit === "week" && this.value && !this.day && !this.month) { return Date.today().setWeek(this.value); } if (this.unit === "week" && this.weeks && !this.day && !this.month) { return finishUtils.generateDateFromWeeks.call(this); } if (expression && this.timezone && this.day && this.days) { this.day = this.days; } if (expression){ today.add(this); } else { today.set(this); } if (this.timezone) { this.timezone = this.timezone.toUpperCase(); var offset = $D.getTimezoneOffset(this.timezone); var timezone; if (today.hasDaylightSavingTime()) { // lets check that we're being sane with timezone setting timezone = $D.getTimezoneAbbreviation(offset, today.isDaylightSavingTime()); if (timezone !== this.timezone) { // bugger, we're in a place where things like EST vs EDT matters. if (today.isDaylightSavingTime()) { today.addHours(-1); } else { today.addHours(1); } } } today.setTimezoneOffset(offset); } return today; } }; }()); (function () { var $D = Date; $D.Grammar = {}; var _ = $D.Parsing.Operators, g = $D.Grammar, t = $D.Translator, _fn; // Allow rolling up into general purpose rules _fn = function () { return _.each(_.any.apply(null, arguments), _.not(g.ctoken2("timeContext"))); }; g.datePartDelimiter = _.rtoken(/^([\s\-\.\,\/\x27]+)/); g.timePartDelimiter = _.stoken(":"); g.whiteSpace = _.rtoken(/^\s*/); g.generalDelimiter = _.rtoken(/^(([\s\,]|at|@|on)+)/); var _C = {}; g.ctoken = function (keys) { var fn = _C[keys]; if (! fn) { var c = Date.CultureInfo.regexPatterns; var kx = keys.split(/\s+/), px = []; for (var i = 0; i < kx.length ; i++) { px.push(_.replace(_.rtoken(c[kx[i]]), kx[i])); } fn = _C[keys] = _.any.apply(null, px); } return fn; }; g.ctoken2 = function (key) { return _.rtoken(Date.CultureInfo.regexPatterns[key]); }; var cacheProcessRtoken = function (key, token, type, eachToken) { if (eachToken) { g[key] = _.cache(_.process(_.each(_.rtoken(token),_.optional(g.ctoken2(eachToken))), type)); } else { g[key] = _.cache(_.process(_.rtoken(token), type)); } }; var cacheProcessCtoken = function (token, type) { return _.cache(_.process(g.ctoken2(token), type)); }; var _F = {}; //function cache var _get = function (f) { _F[f] = (_F[f] || g.format(f)[0]); return _F[f]; }; g.allformats = function (fx) { var rx = []; if (fx instanceof Array) { for (var i = 0; i < fx.length; i++) { rx.push(_get(fx[i])); } } else { rx.push(_get(fx)); } return rx; }; g.formats = function (fx) { if (fx instanceof Array) { var rx = []; for (var i = 0 ; i < fx.length ; i++) { rx.push(_get(fx[i])); } return _.any.apply(null, rx); } else { return _get(fx); } }; var grammarFormats = { timeFormats: function(){ var i, RTokenKeys = [ "h", "hh", "H", "HH", "m", "mm", "s", "ss", "ss.s", "z", "zz" ], RToken = [ /^(0[0-9]|1[0-2]|[1-9])/, /^(0[0-9]|1[0-2])/, /^([0-1][0-9]|2[0-3]|[0-9])/, /^([0-1][0-9]|2[0-3])/, /^([0-5][0-9]|[0-9])/, /^[0-5][0-9]/, /^([0-5][0-9]|[0-9])/, /^[0-5][0-9]/, /^[0-5][0-9]\.[0-9]{1,3}/, /^((\+|\-)\s*\d\d\d\d)|((\+|\-)\d\d\:?\d\d)/, /^((\+|\-)\s*\d\d\d\d)|((\+|\-)\d\d\:?\d\d)/ ], tokens = [ t.hour, t.hour, t.hour, t.hour, t.minute, t.minute, t.second, t.second, t.secondAndMillisecond, t.timezone, t.timezone ]; for (i=0; i < RTokenKeys.length; i++) { cacheProcessRtoken(RTokenKeys[i], RToken[i], tokens[i]); } g.hms = _.cache(_.sequence([g.H, g.m, g.s], g.timePartDelimiter)); g.t = cacheProcessCtoken("shortMeridian", t.meridian); g.tt = cacheProcessCtoken("longMeridian", t.meridian); g.zzz = cacheProcessCtoken("timezone", t.timezone); g.timeSuffix = _.each(_.ignore(g.whiteSpace), _.set([ g.tt, g.zzz ])); g.time = _.each(_.optional(_.ignore(_.stoken("T"))), g.hms, g.timeSuffix); }, dateFormats: function () { // pre-loaded rules for different date part order preferences var _setfn = function () { return _.set(arguments, g.datePartDelimiter); }; var i, RTokenKeys = [ "d", "dd", "M", "MM", "y", "yy", "yyy", "yyyy" ], RToken = [ /^([0-2]\d|3[0-1]|\d)/, /^([0-2]\d|3[0-1])/, /^(1[0-2]|0\d|\d)/, /^(1[0-2]|0\d)/, /^(\d+)/, /^(\d\d)/, /^(\d\d?\d?\d?)/, /^(\d\d\d\d)/ ], tokens = [ t.day, t.day, t.month, t.month, t.year, t.year, t.year, t.year ], eachToken = [ "ordinalSuffix", "ordinalSuffix" ]; for (i=0; i < RTokenKeys.length; i++) { cacheProcessRtoken(RTokenKeys[i], RToken[i], tokens[i], eachToken[i]); } g.MMM = g.MMMM = _.cache(_.process(g.ctoken("jan feb mar apr may jun jul aug sep oct nov dec"), t.month)); g.ddd = g.dddd = _.cache(_.process(g.ctoken("sun mon tue wed thu fri sat"), function (s) { return function () { this.weekday = s; }; } )); g.day = _fn(g.d, g.dd); g.month = _fn(g.M, g.MMM); g.year = _fn(g.yyyy, g.yy); g.mdy = _setfn(g.ddd, g.month, g.day, g.year); g.ymd = _setfn(g.ddd, g.year, g.month, g.day); g.dmy = _setfn(g.ddd, g.day, g.month, g.year); g.date = function (s) { return ((g[Date.CultureInfo.dateElementOrder] || g.mdy).call(this, s)); }; }, relative: function () { // relative date / time expressions g.orientation = _.process(g.ctoken("past future"), function (s) { return function () { this.orient = s; }; } ); g.operator = _.process(g.ctoken("add subtract"), function (s) { return function () { this.operator = s; }; } ); g.rday = _.process(g.ctoken("yesterday tomorrow today now"), t.rday); g.unit = _.process(g.ctoken("second minute hour day week month year"), function (s) { return function () { this.unit = s; }; } ); } }; g.buildGrammarFormats = function () { // these need to be rebuilt every time the language changes. _C = {}; grammarFormats.timeFormats(); grammarFormats.dateFormats(); grammarFormats.relative(); g.value = _.process(_.rtoken(/^([-+]?\d+)?(st|nd|rd|th)?/), function (s) { return function () { this.value = s.replace(/\D/g, ""); }; } ); g.expression = _.set([g.rday, g.operator, g.value, g.unit, g.orientation, g.ddd, g.MMM ]); g.format = _.process(_.many( _.any( // translate format specifiers into grammar rules _.process( _.rtoken(/^(dd?d?d?(?!e)|MM?M?M?|yy?y?y?|hh?|HH?|mm?|ss?|tt?|zz?z?)/), function (fmt) { if (g[fmt]) { return g[fmt]; } else { throw $D.Parsing.Exception(fmt); } } ), // translate separator tokens into token rules _.process(_.rtoken(/^[^dMyhHmstz]+/), // all legal separators function (s) { return _.ignore(_.stoken(s)); } ) ) ), // construct the parser ... function (rules) { return _.process(_.each.apply(null, rules), t.finishExact); } ); // starting rule for general purpose grammar g._start = _.process(_.set([ g.date, g.time, g.expression ], g.generalDelimiter, g.whiteSpace), t.finish); }; g.buildGrammarFormats(); // parsing date format specifiers - ex: "h:m:s tt" // this little guy will generate a custom parser based // on the format string, ex: g.format("h:m:s tt") // check for these formats first g._formats = g.formats([ "\"yyyy-MM-ddTHH:mm:ssZ\"", "yyyy-MM-ddTHH:mm:ss.sz", "yyyy-MM-ddTHH:mm:ssZ", "yyyy-MM-ddTHH:mm:ssz", "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-ddTHH:mmZ", "yyyy-MM-ddTHH:mmz", "yyyy-MM-ddTHH:mm", "ddd, MMM dd, yyyy H:mm:ss tt", "ddd MMM d yyyy HH:mm:ss zzz", "MMddyyyy", "ddMMyyyy", "Mddyyyy", "ddMyyyy", "Mdyyyy", "dMyyyy", "yyyy", "Mdyy", "dMyy", "d" ]); // real starting rule: tries selected formats first, // then general purpose rule g.start = function (s) { try { var r = g._formats.call({}, s); if (r[1].length === 0) { return r; } } catch (e) {} return g._start.call({}, s); }; }()); (function () { var $D = Date; /** * @desc Converts the specified string value into its JavaScript Date equivalent using CultureInfo specific format information. * * Example

	///////////
	// Dates //
	///////////

	// 15-Oct-2004
	var d1 = Date.parse("10/15/2004");

	// 15-Oct-2004
	var d1 = Date.parse("15-Oct-2004");

	// 15-Oct-2004
	var d1 = Date.parse("2004.10.15");

	//Fri Oct 15, 2004
	var d1 = Date.parse("Fri Oct 15, 2004");

	///////////
	// Times //
	///////////

	// Today at 10 PM.
	var d1 = Date.parse("10 PM");

	// Today at 10:30 PM.
	var d1 = Date.parse("10:30 P.M.");

	// Today at 6 AM.
	var d1 = Date.parse("06am");

	/////////////////////
	// Dates and Times //
	/////////////////////

	// 8-July-2004 @ 10:30 PM
	var d1 = Date.parse("July 8th, 2004, 10:30 PM");

	// 1-July-2004 @ 10:30 PM
	var d1 = Date.parse("2004-07-01T22:30:00");

	////////////////////
	// Relative Dates //
	////////////////////

	// Returns today's date. The string "today" is culture specific.
	var d1 = Date.parse("today");

	// Returns yesterday's date. The string "yesterday" is culture specific.
	var d1 = Date.parse("yesterday");

	// Returns the date of the next thursday.
	var d1 = Date.parse("Next thursday");

	// Returns the date of the most previous monday.
	var d1 = Date.parse("last monday");

	// Returns today's day + one year.
	var d1 = Date.parse("next year");

	///////////////
	// Date Math //
	///////////////

	// Today + 2 days
	var d1 = Date.parse("t+2");

	// Today + 2 days
	var d1 = Date.parse("today + 2 days");

	// Today + 3 months
	var d1 = Date.parse("t+3m");

	// Today - 1 year
	var d1 = Date.parse("today - 1 year");

	// Today - 1 year
	var d1 = Date.parse("t-1y"); 


	/////////////////////////////
	// Partial Dates and Times //
	/////////////////////////////

	// July 15th of this year.
	var d1 = Date.parse("July 15");

	// 15th day of current day and year.
	var d1 = Date.parse("15");

	// July 1st of current year at 10pm.
	var d1 = Date.parse("7/1 10pm");
	
* * @param {String} The string value to convert into a Date object [Required] * @return {Date} A Date object or null if the string cannot be converted into a Date. */ var parseUtils = { removeOrds: function (s) { ords = s.match(/\b(\d+)(?:st|nd|rd|th)\b/); // find ordinal matches s = ((ords && ords.length === 2) ? s.replace(ords[0], ords[1]) : s); return s; }, grammarParser: function (s) { var r = null; try { r = $D.Grammar.start.call({}, s.replace(/^\s*(\S*(\s+\S+)*)\s*$/, "$1")); } catch (e) { return null; } return ((r[1].length === 0) ? r[0] : null); }, nativeFallback: function(s) { var t; try { // ok we haven't parsed it, last ditch attempt with the built-in parser. t = Date._parse(s); return (t || t === 0) ? new Date(t) : null; } catch (e) { return null; } } }; function parse (s) { var d; if (!s) { return null; } if (s instanceof Date) { return s.clone(); } if (s.length >= 4 && s.charAt(0) !== "0" && s.charAt(0) !== "+"&& s.charAt(0) !== "-") { // ie: 2004 will pass, 0800 won't. // Start with specific formats d = $D.Parsing.ISO.parse(s) || $D.Parsing.Numeric.parse(s); } if (d instanceof Date && !isNaN(d.getTime())) { return d; } else { // find ordinal dates (1st, 3rd, 8th, etc and remove them as they cause parsing issues) s = $D.Parsing.Normalizer.parse(parseUtils.removeOrds(s)); d = parseUtils.grammarParser(s); if (d !== null) { return d; } else { return parseUtils.nativeFallback(s); } } } if (!$D._parse) { $D._parse = $D.parse; } $D.parse = parse; Date.getParseFunction = function (fx) { var fns = Date.Grammar.allformats(fx); return function (s) { var r = null; for (var i = 0; i < fns.length; i++) { try { r = fns[i].call({}, s); } catch (e) { continue; } if (r[1].length === 0) { return r[0]; } } return null; }; }; /** * Converts the specified string value into its JavaScript Date equivalent using the specified format {String} or formats {Array} and the CultureInfo specific format information. * The format of the string value must match one of the supplied formats exactly. * * Example

	// 15-Oct-2004
	var d1 = Date.parseExact("10/15/2004", "M/d/yyyy");

	// 15-Oct-2004
	var d1 = Date.parse("15-Oct-2004", "M-ddd-yyyy");

	// 15-Oct-2004
	var d1 = Date.parse("2004.10.15", "yyyy.MM.dd");

	// Multiple formats
	var d1 = Date.parseExact("10/15/2004", ["M/d/yyyy", "MMMM d, yyyy"]);
	
* * @param {String} The string value to convert into a Date object [Required]. * @param {Object} The expected format {String} or an array of expected formats {Array} of the date string [Required]. * @return {Date} A Date object or null if the string cannot be converted into a Date. */ $D.parseExact = function (s, fx) { return $D.getParseFunction(fx)(s); }; }()); (function () { var $D = Date, $P = $D.prototype, // $C = $D.CultureInfo, // not used atm p = function (s, l) { if (!l) { l = 2; } return ("000" + s).slice(l * -1); }; /** * Converts a PHP format string to Java/.NET format string. * A PHP format string can be used with ._format or .format. * A Java/.NET format string can be used with .toString(). * The .parseExact function will only accept a Java/.NET format string * * Example * var f1 = "%m/%d/%y" * var f2 = Date.normalizeFormat(f1); // "MM/dd/yy" * * new Date().format(f1); // "04/13/08" * new Date()._format(f1); // "04/13/08" * new Date().toString(f2); // "04/13/08" * * var date = Date.parseExact("04/13/08", f2); // Sun Apr 13 2008 * * @param {String} A PHP format string consisting of one or more format spcifiers. * @return {String} The PHP format converted to a Java/.NET format string. */ var normalizerSubstitutions = { "d" : "dd", "%d": "dd", "D" : "ddd", "%a": "ddd", "j" : "dddd", "l" : "dddd", "%A": "dddd", "S" : "S", "F" : "MMMM", "%B": "MMMM", "m" : "MM", "%m": "MM", "M" : "MMM", "%b": "MMM", "%h": "MMM", "n" : "M", "Y" : "yyyy", "%Y": "yyyy", "y" : "yy", "%y": "yy", "g" : "h", "%I": "h", "G" : "H", "h" : "hh", "H" : "HH", "%H": "HH", "i" : "mm", "%M": "mm", "s" : "ss", "%S": "ss", "%r": "hh:mm tt", "%R": "H:mm", "%T": "H:mm:ss", "%X": "t", "%x": "d", "%e": "d", "%D": "MM/dd/yy", "%n": "\\n", "%t": "\\t", "e" : "z", "T" : "z", "%z": "z", "%Z": "z", "Z" : "ZZ", "N" : "u", "w" : "u", "%w": "u", "W" : "W", "%V": "W" }; var normalizer = { substitutes: function (m) { return normalizerSubstitutions[m]; }, interpreted: function (m, x) { var y; switch (m) { case "%u": return x.getDay() + 1; case "z": return x.getOrdinalNumber(); case "%j": return p(x.getOrdinalNumber(), 3); case "%U": var d1 = x.clone().set({month: 0, day: 1}).addDays(-1).moveToDayOfWeek(0), d2 = x.clone().addDays(1).moveToDayOfWeek(0, -1); return (d2 < d1) ? "00" : p((d2.getOrdinalNumber() - d1.getOrdinalNumber()) / 7 + 1); case "%W": return p(x.getWeek()); case "t": return $D.getDaysInMonth(x.getFullYear(), x.getMonth()); case "o": case "%G": return x.setWeek(x.getISOWeek()).toString("yyyy"); case "%g": return x._format("%G").slice(-2); case "a": case "%p": return t("tt").toLowerCase(); case "A": return t("tt").toUpperCase(); case "u": return p(x.getMilliseconds(), 3); case "I": return (x.isDaylightSavingTime()) ? 1 : 0; case "O": return x.getUTCOffset(); case "P": y = x.getUTCOffset(); return y.substring(0, y.length - 2) + ":" + y.substring(y.length - 2); case "B": var now = new Date(); return Math.floor(((now.getHours() * 3600) + (now.getMinutes() * 60) + now.getSeconds() + (now.getTimezoneOffset() + 60) * 60) / 86.4); case "c": return x.toISOString().replace(/\"/g, ""); case "U": return $D.strtotime("now"); case "%c": return t("d") + " " + t("t"); case "%C": return Math.floor(x.getFullYear() / 100 + 1); } }, shouldOverrideDefaults: function (m) { switch (m) { case "%e": return true; default: return false; } }, parse: function (m, context) { var formatString, c = context || new Date(); formatString = normalizer.substitutes(m); if (formatString) { return formatString; } formatString = normalizer.interpreted(m, c); if (formatString) { return formatString; } else { return m; } } }; $D.normalizeFormat = function (format, context) { return format.replace(/(%|\\)?.|%%/g, function(t){ return normalizer.parse(t, context); }); }; /** * Format a local Unix timestamp according to locale settings * * Example: * Date.strftime("%m/%d/%y", new Date()); // "04/13/08" * Date.strftime("c", "2008-04-13T17:52:03Z"); // "04/13/08" * * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @param {Number|String} The number representing the number of seconds that have elapsed since January 1, 1970 (local time). * @return {String} A string representation of the current Date object. */ $D.strftime = function (format, time) { var d = Date.parse(time); return d._format(format); }; /** * Parse any textual datetime description into a Unix timestamp. * A Unix timestamp is the number of seconds that have elapsed since January 1, 1970 (midnight UTC/GMT). * * Example: * Date.strtotime("04/13/08"); // 1208044800 * Date.strtotime("1970-01-01T00:00:00Z"); // 0 * * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @param {Object} A string or date object. * @return {String} A string representation of the current Date object. */ $D.strtotime = function (time) { var d = $D.parse(time); return Math.round($D.UTC(d.getUTCFullYear(), d.getUTCMonth(), d.getUTCDate(), d.getUTCHours(), d.getUTCMinutes(), d.getUTCSeconds(), d.getUTCMilliseconds()) / 1000); }; /** * Converts the value of the current Date object to its equivalent string representation using a PHP/Unix style of date format specifiers. * Format Specifiers * Format Description Example * ------ --------------------------------------------------------------------------- ----------------------- * %a abbreviated weekday name according to the current localed "Mon" through "Sun" * %A full weekday name according to the current localed "Sunday" through "Saturday" * %b abbreviated month name according to the current localed "Jan" through "Dec" * %B full month name according to the current locale "January" through "December" * %c preferred date and time representation for the current locale "4/13/2008 12:33 PM" * %C century number (the year divided by 100 and truncated to an integer) "00" to "99" * %d day of the month as a decimal number "01" to "31" * %D same as %m/%d/%y "04/13/08" * %e day of the month as a decimal number, a single digit is preceded by a space "1" to "31" * %g like %G, but without the century "08" * %G The 4-digit year corresponding to the ISO week number (see %V). "2008" * This has the same format and value as %Y, except that if the ISO week number * belongs to the previous or next year, that year is used instead. * %h same as %b "Jan" through "Dec" * %H hour as a decimal number using a 24-hour clock. "00" to "23" * %I hour as a decimal number using a 12-hour clock. "01" to "12" * %j day of the year as a decimal number. "001" to "366" * %m month as a decimal number. "01" to "12" * %M minute as a decimal number. "00" to "59" * %n newline character "\n" * %p either "am" or "pm" according to the given time value, or the "am" or "pm" * corresponding strings for the current locale. * %r time in a.m. and p.m. notation "8:44 PM" * %R time in 24 hour notation "20:44" * %S second as a decimal number "00" to "59" * %t tab character "\t" * %T current time, equal to %H:%M:%S "12:49:11" * %u weekday as a decimal number ["1", "7"], with "1" representing Monday "1" to "7" * %U week number of the current year as a decimal number, starting with the "0" to ("52" or "53") * first Sunday as the first day of the first week * %V The ISO 8601:1988 week number of the current year as a decimal number, "00" to ("52" or "53") * range 01 to 53, where week 1 is the first week that has at least 4 days * in the current year, and with Monday as the first day of the week. * (Use %G or %g for the year component that corresponds to the week number * for the specified timestamp.) * %W week number of the current year as a decimal number, starting with the "00" to ("52" or "53") * first Monday as the first day of the first week * %w day of the week as a decimal, Sunday being "0" "0" to "6" * %x preferred date representation for the current locale without the time "4/13/2008" * %X preferred time representation for the current locale without the date "12:53:05" * %y year as a decimal number without a century "00" "99" * %Y year as a decimal number including the century "2008" * %Z time zone or name or abbreviation "UTC", "EST", "PST" * %z same as %Z * %% a literal "%" characters "%" * d Day of the month, 2 digits with leading zeros "01" to "31" * D A textual representation of a day, three letters "Mon" through "Sun" * j Day of the month without leading zeros "1" to "31" * l A full textual representation of the day of the week (lowercase "L") "Sunday" through "Saturday" * N ISO-8601 numeric representation of the day of the week (added in PHP 5.1.0) "1" (for Monday) through "7" (for Sunday) * S English ordinal suffix for the day of the month, 2 characters "st", "nd", "rd" or "th". Works well with j * w Numeric representation of the day of the week "0" (for Sunday) through "6" (for Saturday) * z The day of the year (starting from "0") "0" through "365" * W ISO-8601 week number of year, weeks starting on Monday "00" to ("52" or "53") * F A full textual representation of a month, such as January or March "January" through "December" * m Numeric representation of a month, with leading zeros "01" through "12" * M A short textual representation of a month, three letters "Jan" through "Dec" * n Numeric representation of a month, without leading zeros "1" through "12" * t Number of days in the given month "28" through "31" * L Whether it's a leap year "1" if it is a leap year, "0" otherwise * o ISO-8601 year number. This has the same value as Y, except that if the "2008" * ISO week number (W) belongs to the previous or next year, that year * is used instead. * Y A full numeric representation of a year, 4 digits "2008" * y A two digit representation of a year "08" * a Lowercase Ante meridiem and Post meridiem "am" or "pm" * A Uppercase Ante meridiem and Post meridiem "AM" or "PM" * B Swatch Internet time "000" through "999" * g 12-hour format of an hour without leading zeros "1" through "12" * G 24-hour format of an hour without leading zeros "0" through "23" * h 12-hour format of an hour with leading zeros "01" through "12" * H 24-hour format of an hour with leading zeros "00" through "23" * i Minutes with leading zeros "00" to "59" * s Seconds, with leading zeros "00" through "59" * u Milliseconds "54321" * e Timezone identifier "UTC", "EST", "PST" * I Whether or not the date is in daylight saving time (uppercase i) "1" if Daylight Saving Time, "0" otherwise * O Difference to Greenwich time (GMT) in hours "+0200", "-0600" * P Difference to Greenwich time (GMT) with colon between hours and minutes "+02:00", "-06:00" * T Timezone abbreviation "UTC", "EST", "PST" * Z Timezone offset in seconds. The offset for timezones west of UTC is "-43200" through "50400" * always negative, and for those east of UTC is always positive. * c ISO 8601 date "2004-02-12T15:19:21+00:00" * r RFC 2822 formatted date "Thu, 21 Dec 2000 16:01:07 +0200" * U Seconds since the Unix Epoch (January 1 1970 00:00:00 GMT) "0" * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @return {String} A string representation of the current Date object. */ var formatReplace = function (context) { return function (m) { var formatString, override = false; if (m.charAt(0) === "\\" || m.substring(0, 2) === "%%") { return m.replace("\\", "").replace("%%", "%"); } override = normalizer.shouldOverrideDefaults(m); formatString = $D.normalizeFormat(m, context); if (formatString) { return context.toString(formatString, override); } }; }; $P._format = function (format) { var formatter = formatReplace(this); if (!format) { return this._toString(); } else { return format.replace(/(%|\\)?.|%%/g, formatter); } }; if (!$P.format) { $P.format = $P._format; } }()); (function () { "use strict"; var gFn = function (attr) { return function () { return this[attr]; }; }; var sFn = function (attr) { return function (val) { this[attr] = val; return this; }; }; var attrs = ["years", "months", "days", "hours", "minutes", "seconds", "milliseconds"]; var addSetFuncs = function (context, attrs) { for (var i = 0; i < attrs.length ; i++) { var $a = attrs[i], $b = $a.slice(0, 1).toUpperCase() + $a.slice(1); context.prototype[$a] = 0; context.prototype["get" + $b] = gFn($a); context.prototype["set" + $b] = sFn($a); } }; /** * new TimeSpan(milliseconds); * new TimeSpan(days, hours, minutes, seconds); * new TimeSpan(days, hours, minutes, seconds, milliseconds); */ var TimeSpan = function (days, hours, minutes, seconds, milliseconds) { if (arguments.length === 1 && typeof days === "number") { var orient = (days < 0) ? -1 : +1; var millsLeft = Math.abs(days); this.setDays(Math.floor(millsLeft / 86400000) * orient); millsLeft = millsLeft % 86400000; this.setHours(Math.floor(millsLeft / 3600000) * orient); millsLeft = millsLeft % 3600000; this.setMinutes(Math.floor(millsLeft / 60000) * orient); millsLeft = millsLeft % 60000; this.setSeconds(Math.floor(millsLeft / 1000) * orient); millsLeft = millsLeft % 1000; this.setMilliseconds(millsLeft * orient); } else { this.set(days, hours, minutes, seconds, milliseconds); } this.getTotalMilliseconds = function () { return (this.getDays() * 86400000) + (this.getHours() * 3600000) + (this.getMinutes() * 60000) + (this.getSeconds() * 1000); }; this.compareTo = function (time) { var t1 = new Date(1970, 1, 1, this.getHours(), this.getMinutes(), this.getSeconds()), t2; if (time === null) { t2 = new Date(1970, 1, 1, 0, 0, 0); } else { t2 = new Date(1970, 1, 1, time.getHours(), time.getMinutes(), time.getSeconds()); } return (t1 < t2) ? -1 : (t1 > t2) ? 1 : 0; }; this.equals = function (time) { return (this.compareTo(time) === 0); }; this.add = function (time) { return (time === null) ? this : this.addSeconds(time.getTotalMilliseconds() / 1000); }; this.subtract = function (time) { return (time === null) ? this : this.addSeconds(-time.getTotalMilliseconds() / 1000); }; this.addDays = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 86400000)); }; this.addHours = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 3600000)); }; this.addMinutes = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 60000)); }; this.addSeconds = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 1000)); }; this.addMilliseconds = function (n) { return new TimeSpan(this.getTotalMilliseconds() + n); }; this.get12HourHour = function () { return (this.getHours() > 12) ? this.getHours() - 12 : (this.getHours() === 0) ? 12 : this.getHours(); }; this.getDesignator = function () { return (this.getHours() < 12) ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator; }; this.toString = function (format) { this._toString = function () { if (this.getDays() !== null && this.getDays() > 0) { return this.getDays() + "." + this.getHours() + ":" + this.p(this.getMinutes()) + ":" + this.p(this.getSeconds()); } else { return this.getHours() + ":" + this.p(this.getMinutes()) + ":" + this.p(this.getSeconds()); } }; this.p = function (s) { return (s.toString().length < 2) ? "0" + s : s; }; var me = this; return format ? format.replace(/dd?|HH?|hh?|mm?|ss?|tt?/g, function (format) { switch (format) { case "d": return me.getDays(); case "dd": return me.p(me.getDays()); case "H": return me.getHours(); case "HH": return me.p(me.getHours()); case "h": return me.get12HourHour(); case "hh": return me.p(me.get12HourHour()); case "m": return me.getMinutes(); case "mm": return me.p(me.getMinutes()); case "s": return me.getSeconds(); case "ss": return me.p(me.getSeconds()); case "t": return ((me.getHours() < 12) ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator).substring(0, 1); case "tt": return (me.getHours() < 12) ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator; } } ) : this._toString(); }; return this; }; addSetFuncs(TimeSpan, attrs.slice(2)); TimeSpan.prototype.set = function (days, hours, minutes, seconds, milliseconds){ this.setDays(days || this.getDays()); this.setHours(hours || this.getHours()); this.setMinutes(minutes || this.getMinutes()); this.setSeconds(seconds || this.getSeconds()); this.setMilliseconds(milliseconds || this.getMilliseconds()); }; /** * Gets the time of day for this date instances. * @return {TimeSpan} TimeSpan */ Date.prototype.getTimeOfDay = function () { return new TimeSpan(0, this.getHours(), this.getMinutes(), this.getSeconds(), this.getMilliseconds()); }; Date.TimeSpan = TimeSpan; if (typeof window !== "undefined" ) { // keeping API compatible for v1.x window.TimeSpan = TimeSpan; } }()); (function () { "use strict"; var attrs = ["years", "months", "days", "hours", "minutes", "seconds", "milliseconds"]; var gFn = function (attr) { return function () { return this[attr]; }; }; var sFn = function (attr) { return function (val) { this[attr] = val; return this; }; }; var addSetFuncs = function (context, attrs) { for (var i = 0; i < attrs.length ; i++) { var $a = attrs[i], $b = $a.slice(0, 1).toUpperCase() + $a.slice(1); context.prototype[$a] = 0; context.prototype["get" + $b] = gFn($a); context.prototype["set" + $b] = sFn($a); } }; var setMonthsAndYears = function (orient, d1, d2, context) { function inc() { d1.addMonths(-orient); context.months++; if (context.months === 12) { context.years++; context.months = 0; } } if (orient === +1) { while (d1 > d2) { inc(); } } else { while (d1 < d2) { inc(); } } context.months--; context.months *= orient; context.years *= orient; }; var adjustForDST = function(orient, startDate, endDate) { var hasDSTMismatch = (false === (startDate.isDaylightSavingTime() === endDate.isDaylightSavingTime())); if (hasDSTMismatch && orient === 1) { startDate.addHours(-1); } else if (hasDSTMismatch) { startDate.addHours(1); } }; /** * TimePeriod(startDate, endDate); * TimePeriod(years, months, days, hours, minutes, seconds, milliseconds); */ var TimePeriod = function (years, months, days, hours, minutes, seconds, milliseconds) { if (arguments.length === 7) { this.set(years, months, days, hours, minutes, seconds, milliseconds); } else if (arguments.length === 2 && arguments[0] instanceof Date && arguments[1] instanceof Date) { var startDate = arguments[0].clone(); var endDate = arguments[1].clone(); var orient = (startDate > endDate) ? +1 : -1; this.dates = { start: arguments[0].clone(), end: arguments[1].clone() }; setMonthsAndYears(orient, startDate, endDate, this); adjustForDST(orient, startDate, endDate); // // TODO - adjust for DST var diff = endDate - startDate; if (diff !== 0) { var ts = new TimeSpan(diff); this.set(this.years, this.months, ts.getDays(), ts.getHours(), ts.getMinutes(), ts.getSeconds(), ts.getMilliseconds()); } } return this; }; // create all the set functions. addSetFuncs(TimePeriod, attrs); TimePeriod.prototype.set = function (years, months, days, hours, minutes, seconds, milliseconds){ this.setYears(years || this.getYears()); this.setMonths(months || this.getMonths()); this.setDays(days || this.getDays()); this.setHours(hours || this.getHours()); this.setMinutes(minutes || this.getMinutes()); this.setSeconds(seconds || this.getSeconds()); this.setMilliseconds(milliseconds || this.getMilliseconds()); }; Date.TimePeriod = TimePeriod; if (typeof window !== "undefined") { // keeping API compatible for v1.x window.TimePeriod = TimePeriod; } }()); ================================================ FILE: build/date-es-MX.js ================================================ /** * @overview datejs * @version 1.0.0-rc3 * @author Gregory Wild-Smith * @copyright 2015 Gregory Wild-Smith * @license MIT * @homepage https://github.com/abritinthebay/datejs */ /* * DateJS Culture String File * Country Code: es-MX * Name: Spanish (Mexico) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["es-MX"] = { "name": "es-MX", "englishName": "Spanish (Mexico)", "nativeName": "Español (México)", "Sunday": "domingo", "Monday": "lunes", "Tuesday": "martes", "Wednesday": "miércoles", "Thursday": "jueves", "Friday": "viernes", "Saturday": "sábado", "Sun": "dom", "Mon": "lun", "Tue": "mar", "Wed": "mié", "Thu": "jue", "Fri": "vie", "Sat": "sáb", "Su": "do", "Mo": "lu", "Tu": "ma", "We": "mi", "Th": "ju", "Fr": "vi", "Sa": "sá", "S_Sun_Initial": "d", "M_Mon_Initial": "l", "T_Tue_Initial": "m", "W_Wed_Initial": "m", "T_Thu_Initial": "j", "F_Fri_Initial": "v", "S_Sat_Initial": "s", "January": "enero", "February": "febrero", "March": "marzo", "April": "abril", "May": "mayo", "June": "junio", "July": "julio", "August": "agosto", "September": "septiembre", "October": "octubre", "November": "noviembre", "December": "diciembre", "Jan_Abbr": "ene", "Feb_Abbr": "feb", "Mar_Abbr": "mar", "Apr_Abbr": "abr", "May_Abbr": "may", "Jun_Abbr": "jun", "Jul_Abbr": "jul", "Aug_Abbr": "ago", "Sep_Abbr": "sep", "Oct_Abbr": "oct", "Nov_Abbr": "nov", "Dec_Abbr": "dic", "AM": "a.m.", "PM": "p.m.", "firstDayOfWeek": 0, "twoDigitYearMax": 2029, "mdy": "dmy", "M/d/yyyy": "dd/MM/yyyy", "dddd, MMMM dd, yyyy": "dddd, dd' [de] 'MMMM' [de] 'yyyy", "h:mm tt": "hh:mm tt", "h:mm:ss tt": "hh:mm:ss tt", "dddd, MMMM dd, yyyy h:mm:ss tt": "dddd, dd' [de] 'MMMM' [de] 'yyyy hh:mm:ss tt", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "dd MMMM", "MMMM, yyyy": "MMMM' [de] 'yyyy", "/jan(uary)?/": "ene(ro)?", "/feb(ruary)?/": "feb(rero)?", "/mar(ch)?/": "mar(zo)?", "/apr(il)?/": "abr(il)?", "/may/": "may(o)?", "/jun(e)?/": "jun(io)?", "/jul(y)?/": "jul(io)?", "/aug(ust)?/": "ago(sto)?", "/sep(t(ember)?)?/": "sep(tiembre)?", "/oct(ober)?/": "oct(ubre)?", "/nov(ember)?/": "nov(iembre)?", "/dec(ember)?/": "dic(iembre)?", "/^su(n(day)?)?/": "^do(m(ingo)?)?", "/^mo(n(day)?)?/": "^lu(n(es)?)?", "/^tu(e(s(day)?)?)?/": "^ma(r(tes)?)?", "/^we(d(nesday)?)?/": "^mi(é(rcoles)?)?", "/^th(u(r(s(day)?)?)?)?/": "^ju(e(ves)?)?", "/^fr(i(day)?)?/": "^vi(e(rnes)?)?", "/^sa(t(urday)?)?/": "^sá(b(ado)?)?", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "es-MX"; /** * @overview datejs * @version 1.0.0-rc3 * @author Gregory Wild-Smith * @copyright 2015 Gregory Wild-Smith * @license MIT * @homepage https://github.com/abritinthebay/datejs */(function () { var $D = Date; var lang = Date.CultureStrings ? Date.CultureStrings.lang : null; var loggedKeys = {}; // for debug purposes. var getText = { getFromKey: function (key, countryCode) { var output; if (Date.CultureStrings && Date.CultureStrings[countryCode] && Date.CultureStrings[countryCode][key]) { output = Date.CultureStrings[countryCode][key]; } else { output = getText.buildFromDefault(key); } if (key.charAt(0) === "/") { // Assume it's a regex output = getText.buildFromRegex(key, countryCode); } return output; }, getFromObjectValues: function (obj, countryCode) { var key, output = {}; for(key in obj) { if (obj.hasOwnProperty(key)) { output[key] = getText.getFromKey(obj[key], countryCode); } } return output; }, getFromObjectKeys: function (obj, countryCode) { var key, output = {}; for(key in obj) { if (obj.hasOwnProperty(key)) { output[getText.getFromKey(key, countryCode)] = obj[key]; } } return output; }, getFromArray: function (arr, countryCode) { var output = []; for (var i=0; i < arr.length; i++){ if (i in arr) { output[i] = getText.getFromKey(arr[i], countryCode); } } return output; }, buildFromDefault: function (key) { var output, length, split, last; switch(key) { case "name": output = "en-US"; break; case "englishName": output = "English (United States)"; break; case "nativeName": output = "English (United States)"; break; case "twoDigitYearMax": output = 2049; break; case "firstDayOfWeek": output = 0; break; default: output = key; split = key.split("_"); length = split.length; if (length > 1 && key.charAt(0) !== "/") { // if the key isn't a regex and it has a split. last = split[(length - 1)].toLowerCase(); if (last === "initial" || last === "abbr") { output = split[0]; } } break; } return output; }, buildFromRegex: function (key, countryCode) { var output; if (Date.CultureStrings && Date.CultureStrings[countryCode] && Date.CultureStrings[countryCode][key]) { output = new RegExp(Date.CultureStrings[countryCode][key], "i"); } else { output = new RegExp(key.replace(new RegExp("/", "g"),""), "i"); } return output; } }; var shallowMerge = function (obj1, obj2) { for (var attrname in obj2) { if (obj2.hasOwnProperty(attrname)) { obj1[attrname] = obj2[attrname]; } } }; var __ = function (key, language) { var countryCode = (language) ? language : lang; loggedKeys[key] = key; if (typeof key === "object") { if (key instanceof Array) { return getText.getFromArray(key, countryCode); } else { return getText.getFromObjectKeys(key, countryCode); } } else { return getText.getFromKey(key, countryCode); } }; var loadI18nScript = function (code) { // paatterned after jQuery's getScript. var url = Date.Config.i18n + code + ".js"; var head = document.getElementsByTagName("head")[0] || document.documentElement; var script = document.createElement("script"); script.src = url; var completed = false; var events = { done: function (){} // placeholder function }; // Attach handlers for all browsers script.onload = script.onreadystatechange = function() { if ( !completed && (!this.readyState || this.readyState === "loaded" || this.readyState === "complete") ) { events.done(); head.removeChild(script); } }; setTimeout(function() { head.insertBefore(script, head.firstChild); }, 0); // allows return to execute first return { done: function (cb) { events.done = function() { if (cb) { setTimeout(cb,0); } }; } }; }; var buildInfo = { buildFromMethodHash: function (obj) { var key; for(key in obj) { if (obj.hasOwnProperty(key)) { obj[key] = buildInfo[obj[key]](); } } return obj; }, timeZoneDST: function () { var DST = { "CHADT": "+1345", "NZDT": "+1300", "AEDT": "+1100", "ACDT": "+1030", "AZST": "+0500", "IRDT": "+0430", "EEST": "+0300", "CEST": "+0200", "BST": "+0100", "PMDT": "-0200", "ADT": "-0300", "NDT": "-0230", "EDT": "-0400", "CDT": "-0500", "MDT": "-0600", "PDT": "-0700", "AKDT": "-0800", "HADT": "-0900" }; return __(DST); }, timeZoneStandard: function () { var standard = { "LINT": "+1400", "TOT": "+1300", "CHAST": "+1245", "NZST": "+1200", "NFT": "+1130", "SBT": "+1100", "AEST": "+1000", "ACST": "+0930", "JST": "+0900", "CWST": "+0845", "CT": "+0800", "ICT": "+0700", "MMT": "+0630", "BST": "+0600", "NPT": "+0545", "IST": "+0530", "PKT": "+0500", "AFT": "+0430", "MSK": "+0400", "IRST": "+0330", "FET": "+0300", "EET": "+0200", "CET": "+0100", "GMT": "+0000", "UTC": "+0000", "CVT": "-0100", "GST": "-0200", "BRT": "-0300", "NST": "-0330", "AST": "-0400", "EST": "-0500", "CST": "-0600", "MST": "-0700", "PST": "-0800", "AKST": "-0900", "MIT": "-0930", "HST": "-1000", "SST": "-1100", "BIT": "-1200" }; return __(standard); }, timeZones: function (data) { var zone; data.timezones = []; for (zone in data.abbreviatedTimeZoneStandard) { if (data.abbreviatedTimeZoneStandard.hasOwnProperty(zone)) { data.timezones.push({ name: zone, offset: data.abbreviatedTimeZoneStandard[zone]}); } } for (zone in data.abbreviatedTimeZoneDST) { if (data.abbreviatedTimeZoneDST.hasOwnProperty(zone)) { data.timezones.push({ name: zone, offset: data.abbreviatedTimeZoneDST[zone], dst: true}); } } return data.timezones; }, days: function () { return __(["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"]); }, dayAbbr: function () { return __(["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"]); }, dayShortNames: function () { return __(["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"]); }, dayFirstLetters: function () { return __(["S_Sun_Initial", "M_Mon_Initial", "T_Tues_Initial", "W_Wed_Initial", "T_Thu_Initial", "F_Fri_Initial", "S_Sat_Initial"]); }, months: function () { return __(["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"]); }, monthAbbr: function () { return __(["Jan_Abbr", "Feb_Abbr", "Mar_Abbr", "Apr_Abbr", "May_Abbr", "Jun_Abbr", "Jul_Abbr", "Aug_Abbr", "Sep_Abbr", "Oct_Abbr", "Nov_Abbr", "Dec_Abbr"]); }, formatPatterns: function () { return getText.getFromObjectValues({ shortDate: "M/d/yyyy", longDate: "dddd, MMMM dd, yyyy", shortTime: "h:mm tt", longTime: "h:mm:ss tt", fullDateTime: "dddd, MMMM dd, yyyy h:mm:ss tt", sortableDateTime: "yyyy-MM-ddTHH:mm:ss", universalSortableDateTime: "yyyy-MM-dd HH:mm:ssZ", rfc1123: "ddd, dd MMM yyyy HH:mm:ss", monthDay: "MMMM dd", yearMonth: "MMMM, yyyy" }, Date.i18n.currentLanguage()); }, regex: function () { return getText.getFromObjectValues({ inTheMorning: "/( in the )(morn(ing)?)\\b/", thisMorning: "/(this )(morn(ing)?)\\b/", amThisMorning: "/(\b\\d(am)? )(this )(morn(ing)?)/", inTheEvening: "/( in the )(even(ing)?)\\b/", thisEvening: "/(this )(even(ing)?)\\b/", pmThisEvening: "/(\b\\d(pm)? )(this )(even(ing)?)/", jan: "/jan(uary)?/", feb: "/feb(ruary)?/", mar: "/mar(ch)?/", apr: "/apr(il)?/", may: "/may/", jun: "/jun(e)?/", jul: "/jul(y)?/", aug: "/aug(ust)?/", sep: "/sep(t(ember)?)?/", oct: "/oct(ober)?/", nov: "/nov(ember)?/", dec: "/dec(ember)?/", sun: "/^su(n(day)?)?/", mon: "/^mo(n(day)?)?/", tue: "/^tu(e(s(day)?)?)?/", wed: "/^we(d(nesday)?)?/", thu: "/^th(u(r(s(day)?)?)?)?/", fri: "/fr(i(day)?)?/", sat: "/^sa(t(urday)?)?/", future: "/^next/", past: "/^last|past|prev(ious)?/", add: "/^(\\+|aft(er)?|from|hence)/", subtract: "/^(\\-|bef(ore)?|ago)/", yesterday: "/^yes(terday)?/", today: "/^t(od(ay)?)?/", tomorrow: "/^tom(orrow)?/", now: "/^n(ow)?/", millisecond: "/^ms|milli(second)?s?/", second: "/^sec(ond)?s?/", minute: "/^mn|min(ute)?s?/", hour: "/^h(our)?s?/", week: "/^w(eek)?s?/", month: "/^m(onth)?s?/", day: "/^d(ay)?s?/", year: "/^y(ear)?s?/", shortMeridian: "/^(a|p)/", longMeridian: "/^(a\\.?m?\\.?|p\\.?m?\\.?)/", timezone: "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/", ordinalSuffix: "/^\\s*(st|nd|rd|th)/", timeContext: "/^\\s*(\\:|a(?!u|p)|p)/" }, Date.i18n.currentLanguage()); } }; var CultureInfo = function () { var info = getText.getFromObjectValues({ name: "name", englishName: "englishName", nativeName: "nativeName", amDesignator: "AM", pmDesignator: "PM", firstDayOfWeek: "firstDayOfWeek", twoDigitYearMax: "twoDigitYearMax", dateElementOrder: "mdy" }, Date.i18n.currentLanguage()); var constructedInfo = buildInfo.buildFromMethodHash({ dayNames: "days", abbreviatedDayNames: "dayAbbr", shortestDayNames: "dayShortNames", firstLetterDayNames: "dayFirstLetters", monthNames: "months", abbreviatedMonthNames: "monthAbbr", formatPatterns: "formatPatterns", regexPatterns: "regex", abbreviatedTimeZoneDST: "timeZoneDST", abbreviatedTimeZoneStandard: "timeZoneStandard" }); shallowMerge(info, constructedInfo); buildInfo.timeZones(info); return info; }; $D.i18n = { __: function (key, lang) { return __(key, lang); }, currentLanguage: function () { return lang || "en-US"; }, setLanguage: function (code, force, cb) { var async = false; if (force || code === "en-US" || (!!Date.CultureStrings && !!Date.CultureStrings[code])) { lang = code; Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings.lang = code; Date.CultureInfo = new CultureInfo(); } else { if (!(!!Date.CultureStrings && !!Date.CultureStrings[code])) { if (typeof exports !== "undefined" && this.exports !== exports) { // we're in a Node enviroment, load it using require try { require("../i18n/" + code + ".js"); lang = code; Date.CultureStrings.lang = code; Date.CultureInfo = new CultureInfo(); } catch (e) { // var str = "The language for '" + code + "' could not be loaded by Node. It likely does not exist."; throw new Error("The DateJS IETF language tag '" + code + "' could not be loaded by Node. It likely does not exist."); } } else if (Date.Config && Date.Config.i18n) { // we know the location of the files, so lets load them async = true; loadI18nScript(code).done(function(){ lang = code; Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings.lang = code; Date.CultureInfo = new CultureInfo(); $D.Parsing.Normalizer.buildReplaceData(); // because this is async if ($D.Grammar) { $D.Grammar.buildGrammarFormats(); // so we can parse those strings... } if (cb) { setTimeout(cb,0); } }); } else { Date.console.error("The DateJS IETF language tag '" + code + "' is not available and has not been loaded."); return false; } } } $D.Parsing.Normalizer.buildReplaceData(); // rebuild normalizer strings if ($D.Grammar) { $D.Grammar.buildGrammarFormats(); // so we can parse those strings... } if (!async && cb) { setTimeout(cb,0); } }, getLoggedKeys: function () { return loggedKeys; }, updateCultureInfo: function () { Date.CultureInfo = new CultureInfo(); } }; $D.i18n.updateCultureInfo(); // run automatically }()); (function () { var $D = Date, $P = $D.prototype, p = function (s, l) { if (!l) { l = 2; } return ("000" + s).slice(l * -1); }; if (typeof window !== "undefined" && typeof window.console !== "undefined" && typeof window.console.log !== "undefined") { $D.console = console; // used only to raise non-critical errors if available } else { // set mock so we don't give errors. $D.console = { log: function(){}, error: function(){} }; } $D.Config = $D.Config || {}; $D.initOverloads = function() { /** * Overload of Date.now. Allows an alternate call for Date.now where it returns the * current Date as an object rather than just milliseconds since the Unix Epoch. * * Also provides an implementation of now() for browsers (IE<9) that don't have it. * * Backwards compatible so with work with either: * Date.now() [returns ms] * or * Date.now(true) [returns Date] */ if (!$D.now) { $D._now = function now() { return new Date().getTime(); }; } else if (!$D._now) { $D._now = $D.now; } $D.now = function (returnObj) { if (returnObj) { return $D.present(); } else { return $D._now(); } }; if ( !$P.toISOString ) { $P.toISOString = function() { return this.getUTCFullYear() + "-" + p(this.getUTCMonth() + 1) + "-" + p(this.getUTCDate()) + "T" + p(this.getUTCHours()) + ":" + p(this.getUTCMinutes()) + ":" + p(this.getUTCSeconds()) + "." + String( (this.getUTCMilliseconds()/1000).toFixed(3)).slice(2, 5) + "Z"; }; } // private if ( $P._toString === undefined ){ $P._toString = $P.toString; } }; $D.initOverloads(); /** * Gets a date that is set to the current date. The time is set to the start of the day (00:00 or 12:00 AM). * @return {Date} The current date. */ $D.today = function () { return new Date().clearTime(); }; /** * Gets a date that is set to the current date and time (same as new Date, but chainable) * @return {Date} The current date. */ $D.present = function () { return new Date(); }; /** * Compares the first date to the second date and returns an number indication of their relative values. * @param {Date} First Date object to compare [Required]. * @param {Date} Second Date object to compare to [Required]. * @return {Number} -1 = date1 is lessthan date2. 0 = values are equal. 1 = date1 is greaterthan date2. */ $D.compare = function (date1, date2) { if (isNaN(date1) || isNaN(date2)) { throw new Error(date1 + " - " + date2); } else if (date1 instanceof Date && date2 instanceof Date) { return (date1 < date2) ? -1 : (date1 > date2) ? 1 : 0; } else { throw new TypeError(date1 + " - " + date2); } }; /** * Compares the first Date object to the second Date object and returns true if they are equal. * @param {Date} First Date object to compare [Required] * @param {Date} Second Date object to compare to [Required] * @return {Boolean} true if dates are equal. false if they are not equal. */ $D.equals = function (date1, date2) { return (date1.compareTo(date2) === 0); }; /** * Gets the language appropriate day name when given the day number(0-6) * eg - 0 == Sunday * @return {String} The day name */ $D.getDayName = function (n) { return Date.CultureInfo.dayNames[n]; }; /** * Gets the day number (0-6) if given a CultureInfo specific string which is a valid dayName, abbreviatedDayName or shortestDayName (two char). * @param {String} The name of the day (eg. "Monday, "Mon", "tuesday", "tue", "We", "we"). * @return {Number} The day number */ $D.getDayNumberFromName = function (name) { var n = Date.CultureInfo.dayNames, m = Date.CultureInfo.abbreviatedDayNames, o = Date.CultureInfo.shortestDayNames, s = name.toLowerCase(); for (var i = 0; i < n.length; i++) { if (n[i].toLowerCase() === s || m[i].toLowerCase() === s || o[i].toLowerCase() === s) { return i; } } return -1; }; /** * Gets the month number (0-11) if given a Culture Info specific string which is a valid monthName or abbreviatedMonthName. * @param {String} The name of the month (eg. "February, "Feb", "october", "oct"). * @return {Number} The day number */ $D.getMonthNumberFromName = function (name) { var n = Date.CultureInfo.monthNames, m = Date.CultureInfo.abbreviatedMonthNames, s = name.toLowerCase(); for (var i = 0; i < n.length; i++) { if (n[i].toLowerCase() === s || m[i].toLowerCase() === s) { return i; } } return -1; }; /** * Gets the language appropriate month name when given the month number(0-11) * eg - 0 == January * @return {String} The month name */ $D.getMonthName = function (n) { return Date.CultureInfo.monthNames[n]; }; /** * Determines if the current date instance is within a LeapYear. * @param {Number} The year. * @return {Boolean} true if date is within a LeapYear, otherwise false. */ $D.isLeapYear = function (year) { return ((year % 4 === 0 && year % 100 !== 0) || year % 400 === 0); }; /** * Gets the number of days in the month, given a year and month value. Automatically corrects for LeapYear. * @param {Number} The year. * @param {Number} The month (0-11). * @return {Number} The number of days in the month. */ $D.getDaysInMonth = function (year, month) { if (!month && $D.validateMonth(year)) { month = year; year = Date.today().getFullYear(); } return [31, ($D.isLeapYear(year) ? 29 : 28), 31, 30, 31, 30, 31, 31, 30, 31, 30, 31][month]; }; $P.getDaysInMonth = function () { return $D.getDaysInMonth(this.getFullYear(), this.getMonth()); }; $D.getTimezoneAbbreviation = function (offset, dst) { var p, n = (dst || false) ? Date.CultureInfo.abbreviatedTimeZoneDST : Date.CultureInfo.abbreviatedTimeZoneStandard; for (p in n) { if (n.hasOwnProperty(p)) { if (n[p] === offset) { return p; } } } return null; }; $D.getTimezoneOffset = function (name, dst) { var i, a =[], z = Date.CultureInfo.timezones; if (!name) { name = (new Date()).getTimezone();} for (i = 0; i < z.length; i++) { if (z[i].name === name.toUpperCase()) { a.push(i); } } if (!z[a[0]]) { return null; } if (a.length === 1 || !dst) { return z[a[0]].offset; } else { for (i=0; i < a.length; i++) { if (z[a[i]].dst) { return z[a[i]].offset; } } } }; $D.getQuarter = function (d) { d = d || new Date(); // If no date supplied, use today var q = [1,2,3,4]; return q[Math.floor(d.getMonth() / 3)]; // ~~~ is a bitwise op. Faster than Math.floor }; $D.getDaysLeftInQuarter = function (d) { d = d || new Date(); var qEnd = new Date(d); qEnd.setMonth(qEnd.getMonth() + 3 - qEnd.getMonth() % 3, 0); return Math.floor((qEnd - d) / 8.64e7); }; // private var validate = function (n, min, max, name) { name = name ? name : "Object"; if (typeof n === "undefined") { return false; } else if (typeof n !== "number") { throw new TypeError(n + " is not a Number."); } else if (n < min || n > max) { // As failing validation is *not* an exceptional circumstance // lets not throw a RangeError Exception here. // It's semantically correct but it's not sensible. return false; } return true; }; /** * Validates the number is within an acceptable range for milliseconds [0-999]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateMillisecond = function (value) { return validate(value, 0, 999, "millisecond"); }; /** * Validates the number is within an acceptable range for seconds [0-59]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateSecond = function (value) { return validate(value, 0, 59, "second"); }; /** * Validates the number is within an acceptable range for minutes [0-59]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateMinute = function (value) { return validate(value, 0, 59, "minute"); }; /** * Validates the number is within an acceptable range for hours [0-23]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateHour = function (value) { return validate(value, 0, 23, "hour"); }; /** * Validates the number is within an acceptable range for the days in a month [0-MaxDaysInMonth]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateDay = function (value, year, month) { if (year === undefined || year === null || month === undefined || month === null) { return false;} return validate(value, 1, $D.getDaysInMonth(year, month), "day"); }; /** * Validates the number is within an acceptable range for months [0-11]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateWeek = function (value) { return validate(value, 0, 53, "week"); }; /** * Validates the number is within an acceptable range for months [0-11]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateMonth = function (value) { return validate(value, 0, 11, "month"); }; /** * Validates the number is within an acceptable range for years. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateYear = function (value) { /** * Per ECMAScript spec the range of times supported by Date objects is * exactly -100,000,000 days to +100,000,000 days measured relative to * midnight at the beginning of 01 January, 1970 UTC. * This gives a range of 8,640,000,000,000,000 milliseconds to either * side of 01 January, 1970 UTC. * * Earliest possible date: Tue, 20 Apr 271,822 B.C. 00:00:00 UTC * Latest possible date: Sat, 13 Sep 275,760 00:00:00 UTC */ return validate(value, -271822, 275760, "year"); }; $D.validateTimezone = function(value) { var timezones = {"ACDT":1,"ACST":1,"ACT":1,"ADT":1,"AEDT":1,"AEST":1,"AFT":1,"AKDT":1,"AKST":1,"AMST":1,"AMT":1,"ART":1,"AST":1,"AWDT":1,"AWST":1,"AZOST":1,"AZT":1,"BDT":1,"BIOT":1,"BIT":1,"BOT":1,"BRT":1,"BST":1,"BTT":1,"CAT":1,"CCT":1,"CDT":1,"CEDT":1,"CEST":1,"CET":1,"CHADT":1,"CHAST":1,"CHOT":1,"ChST":1,"CHUT":1,"CIST":1,"CIT":1,"CKT":1,"CLST":1,"CLT":1,"COST":1,"COT":1,"CST":1,"CT":1,"CVT":1,"CWST":1,"CXT":1,"DAVT":1,"DDUT":1,"DFT":1,"EASST":1,"EAST":1,"EAT":1,"ECT":1,"EDT":1,"EEDT":1,"EEST":1,"EET":1,"EGST":1,"EGT":1,"EIT":1,"EST":1,"FET":1,"FJT":1,"FKST":1,"FKT":1,"FNT":1,"GALT":1,"GAMT":1,"GET":1,"GFT":1,"GILT":1,"GIT":1,"GMT":1,"GST":1,"GYT":1,"HADT":1,"HAEC":1,"HAST":1,"HKT":1,"HMT":1,"HOVT":1,"HST":1,"ICT":1,"IDT":1,"IOT":1,"IRDT":1,"IRKT":1,"IRST":1,"IST":1,"JST":1,"KGT":1,"KOST":1,"KRAT":1,"KST":1,"LHST":1,"LINT":1,"MAGT":1,"MART":1,"MAWT":1,"MDT":1,"MET":1,"MEST":1,"MHT":1,"MIST":1,"MIT":1,"MMT":1,"MSK":1,"MST":1,"MUT":1,"MVT":1,"MYT":1,"NCT":1,"NDT":1,"NFT":1,"NPT":1,"NST":1,"NT":1,"NUT":1,"NZDT":1,"NZST":1,"OMST":1,"ORAT":1,"PDT":1,"PET":1,"PETT":1,"PGT":1,"PHOT":1,"PHT":1,"PKT":1,"PMDT":1,"PMST":1,"PONT":1,"PST":1,"PYST":1,"PYT":1,"RET":1,"ROTT":1,"SAKT":1,"SAMT":1,"SAST":1,"SBT":1,"SCT":1,"SGT":1,"SLST":1,"SRT":1,"SST":1,"SYOT":1,"TAHT":1,"THA":1,"TFT":1,"TJT":1,"TKT":1,"TLT":1,"TMT":1,"TOT":1,"TVT":1,"UCT":1,"ULAT":1,"UTC":1,"UYST":1,"UYT":1,"UZT":1,"VET":1,"VLAT":1,"VOLT":1,"VOST":1,"VUT":1,"WAKT":1,"WAST":1,"WAT":1,"WEDT":1,"WEST":1,"WET":1,"WST":1,"YAKT":1,"YEKT":1,"Z":1}; return (timezones[value] === 1); }; $D.validateTimezoneOffset= function(value) { // timezones go from +14hrs to -12hrs, the +X hours are negative offsets. return (value > -841 && value < 721); }; }()); (function () { var $D = Date, $P = $D.prototype, p = function (s, l) { if (!l) { l = 2; } return ("000" + s).slice(l * -1); }; var validateConfigObject = function (obj) { var result = {}, self = this, prop, testFunc; testFunc = function (prop, func, value) { if (prop === "day") { var month = (obj.month !== undefined) ? obj.month : self.getMonth(); var year = (obj.year !== undefined) ? obj.year : self.getFullYear(); return $D[func](value, year, month); } else { return $D[func](value); } }; for (prop in obj) { if (Object.prototype.hasOwnProperty.call(obj, prop)) { var func = "validate" + prop.charAt(0).toUpperCase() + prop.slice(1); if ($D[func] && obj[prop] !== null && testFunc(prop, func, obj[prop])) { result[prop] = obj[prop]; } } } return result; }; /** * Resets the time of this Date object to 12:00 AM (00:00), which is the start of the day. * @param {Boolean} .clone() this date instance before clearing Time * @return {Date} this */ $P.clearTime = function () { this.setHours(0); this.setMinutes(0); this.setSeconds(0); this.setMilliseconds(0); return this; }; /** * Resets the time of this Date object to the current time ('now'). * @return {Date} this */ $P.setTimeToNow = function () { var n = new Date(); this.setHours(n.getHours()); this.setMinutes(n.getMinutes()); this.setSeconds(n.getSeconds()); this.setMilliseconds(n.getMilliseconds()); return this; }; /** * Returns a new Date object that is an exact date and time copy of the original instance. * @return {Date} A new Date instance */ $P.clone = function () { return new Date(this.getTime()); }; /** * Compares this instance to a Date object and returns an number indication of their relative values. * @param {Date} Date object to compare [Required] * @return {Number} -1 = this is lessthan date. 0 = values are equal. 1 = this is greaterthan date. */ $P.compareTo = function (date) { return Date.compare(this, date); }; /** * Compares this instance to another Date object and returns true if they are equal. * @param {Date} Date object to compare. If no date to compare, new Date() [now] is used. * @return {Boolean} true if dates are equal. false if they are not equal. */ $P.equals = function (date) { return Date.equals(this, (date !== undefined ? date : new Date())); }; /** * Determines if this instance is between a range of two dates or equal to either the start or end dates. * @param {Date} Start of range [Required] * @param {Date} End of range [Required] * @return {Boolean} true is this is between or equal to the start and end dates, else false */ $P.between = function (start, end) { return this.getTime() >= start.getTime() && this.getTime() <= end.getTime(); }; /** * Determines if this date occurs after the date to compare to. * @param {Date} Date object to compare. If no date to compare, new Date() ("now") is used. * @return {Boolean} true if this date instance is greater than the date to compare to (or "now"), otherwise false. */ $P.isAfter = function (date) { return this.compareTo(date || new Date()) === 1; }; /** * Determines if this date occurs before the date to compare to. * @param {Date} Date object to compare. If no date to compare, new Date() ("now") is used. * @return {Boolean} true if this date instance is less than the date to compare to (or "now"). */ $P.isBefore = function (date) { return (this.compareTo(date || new Date()) === -1); }; /** * Determines if the current Date instance occurs today. * @return {Boolean} true if this date instance is 'today', otherwise false. */ /** * Determines if the current Date instance occurs on the same Date as the supplied 'date'. * If no 'date' to compare to is provided, the current Date instance is compared to 'today'. * @param {date} Date object to compare. If no date to compare, the current Date ("now") is used. * @return {Boolean} true if this Date instance occurs on the same Day as the supplied 'date'. */ $P.isToday = $P.isSameDay = function (date) { return this.clone().clearTime().equals((date || new Date()).clone().clearTime()); }; /** * Adds the specified number of milliseconds to this instance. * @param {Number} The number of milliseconds to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addMilliseconds = function (value) { if (!value) { return this; } this.setTime(this.getTime() + value * 1); return this; }; /** * Adds the specified number of seconds to this instance. * @param {Number} The number of seconds to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addSeconds = function (value) { if (!value) { return this; } return this.addMilliseconds(value * 1000); }; /** * Adds the specified number of seconds to this instance. * @param {Number} The number of seconds to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addMinutes = function (value) { if (!value) { return this; } return this.addMilliseconds(value * 60000); // 60*1000 }; /** * Adds the specified number of hours to this instance. * @param {Number} The number of hours to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addHours = function (value) { if (!value) { return this; } return this.addMilliseconds(value * 3600000); // 60*60*1000 }; /** * Adds the specified number of days to this instance. * @param {Number} The number of days to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addDays = function (value) { if (!value) { return this; } this.setDate(this.getDate() + value * 1); return this; }; /** * Adds the specified number of weekdays (ie - not sat or sun) to this instance. * @param {Number} The number of days to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addWeekdays = function (value) { if (!value) { return this; } var day = this.getDay(); var weeks = (Math.ceil(Math.abs(value)/7)); if (day === 0 || day === 6) { if (value > 0) { this.next().monday(); this.addDays(-1); day = this.getDay(); } } if (value < 0) { while (value < 0) { this.addDays(-1); day = this.getDay(); if (day !== 0 && day !== 6) { value++; } } return this; } else if (value > 5 || (6-day) <= value) { value = value + (weeks * 2); } return this.addDays(value); }; /** * Adds the specified number of weeks to this instance. * @param {Number} The number of weeks to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addWeeks = function (value) { if (!value) { return this; } return this.addDays(value * 7); }; /** * Adds the specified number of months to this instance. * @param {Number} The number of months to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addMonths = function (value) { if (!value) { return this; } var n = this.getDate(); this.setDate(1); this.setMonth(this.getMonth() + value * 1); this.setDate(Math.min(n, $D.getDaysInMonth(this.getFullYear(), this.getMonth()))); return this; }; $P.addQuarters = function (value) { if (!value) { return this; } // note this will take you to the same point in the quarter as you are now. // i.e. - if you are 15 days into the quarter you'll be 15 days into the resulting one. // bonus: this allows adding fractional quarters return this.addMonths(value * 3); }; /** * Adds the specified number of years to this instance. * @param {Number} The number of years to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addYears = function (value) { if (!value) { return this; } return this.addMonths(value * 12); }; /** * Adds (or subtracts) to the value of the years, months, weeks, days, hours, minutes, seconds, milliseconds of the date instance using given configuration object. Positive and Negative values allowed. * Example

	Date.today().add( { days: 1, months: 1 } )

	new Date().add( { years: -1 } )
	
* @param {Object} Configuration object containing attributes (months, days, etc.) * @return {Date} this */ $P.add = function (config) { if (typeof config === "number") { this._orient = config; return this; } var x = config; if (x.day) { // If we should be a different date than today (eg: for 'tomorrow -1d', etc). // Should only effect parsing, not direct usage (eg, Finish and FinishExact) if ((x.day - this.getDate()) !== 0) { this.setDate(x.day); } } if (x.milliseconds) { this.addMilliseconds(x.milliseconds); } if (x.seconds) { this.addSeconds(x.seconds); } if (x.minutes) { this.addMinutes(x.minutes); } if (x.hours) { this.addHours(x.hours); } if (x.weeks) { this.addWeeks(x.weeks); } if (x.months) { this.addMonths(x.months); } if (x.years) { this.addYears(x.years); } if (x.days) { this.addDays(x.days); } return this; }; /** * Get the week number. Week one (1) is the week which contains the first Thursday of the year. Monday is considered the first day of the week. * The .getWeek() function does NOT convert the date to UTC. The local datetime is used. * Please use .getISOWeek() to get the week of the UTC converted date. * @return {Number} 1 to 53 */ $P.getWeek = function (utc) { // Create a copy of this date object var self, target = new Date(this.valueOf()); if (utc) { target.addMinutes(target.getTimezoneOffset()); self = target.clone(); } else { self = this; } // ISO week date weeks start on monday // so correct the day number var dayNr = (self.getDay() + 6) % 7; // ISO 8601 states that week 1 is the week // with the first thursday of that year. // Set the target date to the thursday in the target week target.setDate(target.getDate() - dayNr + 3); // Store the millisecond value of the target date var firstThursday = target.valueOf(); // Set the target to the first thursday of the year // First set the target to january first target.setMonth(0, 1); // Not a thursday? Correct the date to the next thursday if (target.getDay() !== 4) { target.setMonth(0, 1 + ((4 - target.getDay()) + 7) % 7); } // The weeknumber is the number of weeks between the // first thursday of the year and the thursday in the target week return 1 + Math.ceil((firstThursday - target) / 604800000); // 604800000 = 7 * 24 * 3600 * 1000 }; /** * Get the ISO 8601 week number. Week one ("01") is the week which contains the first Thursday of the year. Monday is considered the first day of the week. * The .getISOWeek() function does convert the date to it's UTC value. Please use .getWeek() to get the week of the local date. * @return {String} "01" to "53" */ $P.getISOWeek = function () { return p(this.getWeek(true)); }; /** * Moves the date to Monday of the week set. Week one (1) is the week which contains the first Thursday of the year. * @param {Number} A Number (1 to 53) that represents the week of the year. * @return {Date} this */ $P.setWeek = function (n) { if ((n - this.getWeek()) === 0) { if (this.getDay() !== 1) { return this.moveToDayOfWeek(1, (this.getDay() > 1 ? -1 : 1)); } else { return this; } } else { return this.moveToDayOfWeek(1, (this.getDay() > 1 ? -1 : 1)).addWeeks(n - this.getWeek()); } }; $P.setQuarter = function (qtr) { var month = Math.abs(((qtr-1) * 3) + 1); return this.setMonth(month, 1); }; $P.getQuarter = function () { return Date.getQuarter(this); }; $P.getDaysLeftInQuarter = function () { return Date.getDaysLeftInQuarter(this); }; /** * Moves the date to the next n'th occurrence of the dayOfWeek starting from the beginning of the month. The number (-1) is a magic number and will return the last occurrence of the dayOfWeek in the month. * @param {Number} The dayOfWeek to move to * @param {Number} The n'th occurrence to move to. Use (-1) to return the last occurrence in the month * @return {Date} this */ $P.moveToNthOccurrence = function (dayOfWeek, occurrence) { if (dayOfWeek === "Weekday") { if (occurrence > 0) { this.moveToFirstDayOfMonth(); if (this.is().weekday()) { occurrence -= 1; } } else if (occurrence < 0) { this.moveToLastDayOfMonth(); if (this.is().weekday()) { occurrence += 1; } } else { return this; } return this.addWeekdays(occurrence); } var shift = 0; if (occurrence > 0) { shift = occurrence - 1; } else if (occurrence === -1) { this.moveToLastDayOfMonth(); if (this.getDay() !== dayOfWeek) { this.moveToDayOfWeek(dayOfWeek, -1); } return this; } return this.moveToFirstDayOfMonth().addDays(-1).moveToDayOfWeek(dayOfWeek, +1).addWeeks(shift); }; var moveToN = function (getFunc, addFunc, nVal) { return function (value, orient) { var diff = (value - this[getFunc]() + nVal * (orient || +1)) % nVal; return this[addFunc]((diff === 0) ? diff += nVal * (orient || +1) : diff); }; }; /** * Move to the next or last dayOfWeek based on the orient value. * @param {Number} The dayOfWeek to move to * @param {Number} Forward (+1) or Back (-1). Defaults to +1. [Optional] * @return {Date} this */ $P.moveToDayOfWeek = moveToN("getDay", "addDays", 7); /** * Move to the next or last month based on the orient value. * @param {Number} The month to move to. 0 = January, 11 = December * @param {Number} Forward (+1) or Back (-1). Defaults to +1. [Optional] * @return {Date} this */ $P.moveToMonth = moveToN("getMonth", "addMonths", 12); /** * Get the Ordinate of the current day ("th", "st", "rd"). * @return {String} */ $P.getOrdinate = function () { var num = this.getDate(); return ord(num); }; /** * Get the Ordinal day (numeric day number) of the year, adjusted for leap year. * @return {Number} 1 through 365 (366 in leap years) */ $P.getOrdinalNumber = function () { return Math.ceil((this.clone().clearTime() - new Date(this.getFullYear(), 0, 1)) / 86400000) + 1; }; /** * Get the time zone abbreviation of the current date. * @return {String} The abbreviated time zone name (e.g. "EST") */ $P.getTimezone = function () { return $D.getTimezoneAbbreviation(this.getUTCOffset(), this.isDaylightSavingTime()); }; $P.setTimezoneOffset = function (offset) { var here = this.getTimezoneOffset(), there = Number(offset) * -6 / 10; return (there || there === 0) ? this.addMinutes(there - here) : this; }; $P.setTimezone = function (offset) { return this.setTimezoneOffset($D.getTimezoneOffset(offset)); }; /** * Indicates whether Daylight Saving Time is observed in the current time zone. * @return {Boolean} true|false */ $P.hasDaylightSavingTime = function () { return (Date.today().set({month: 0, day: 1}).getTimezoneOffset() !== Date.today().set({month: 6, day: 1}).getTimezoneOffset()); }; /** * Indicates whether this Date instance is within the Daylight Saving Time range for the current time zone. * @return {Boolean} true|false */ $P.isDaylightSavingTime = function () { return Date.today().set({month: 0, day: 1}).getTimezoneOffset() !== this.getTimezoneOffset(); }; /** * Get the offset from UTC of the current date. * @return {String} The 4-character offset string prefixed with + or - (e.g. "-0500") */ $P.getUTCOffset = function (offset) { var n = (offset || this.getTimezoneOffset()) * -10 / 6, r; if (n < 0) { r = (n - 10000).toString(); return r.charAt(0) + r.substr(2); } else { r = (n + 10000).toString(); return "+" + r.substr(1); } }; /** * Returns the number of milliseconds between this date and date. * @param {Date} Defaults to now * @return {Number} The diff in milliseconds */ $P.getElapsed = function (date) { return (date || new Date()) - this; }; /** * Set the value of year, month, day, hour, minute, second, millisecond of date instance using given configuration object. * Example

	Date.today().set( { day: 20, month: 1 } )

	new Date().set( { millisecond: 0 } )
	
* * @param {Object} Configuration object containing attributes (month, day, etc.) * @return {Date} this */ $P.set = function (config) { config = validateConfigObject.call(this, config); var key; for (key in config) { if (Object.prototype.hasOwnProperty.call(config, key)) { var name = key.charAt(0).toUpperCase() + key.slice(1); var addFunc, getFunc; if (key !== "week" && key !== "month" && key !== "timezone" && key !== "timezoneOffset") { name += "s"; } addFunc = "add" + name; getFunc = "get" + name; if (key === "month") { addFunc = addFunc + "s"; } else if (key === "year"){ getFunc = "getFullYear"; } if (key !== "day" && key !== "timezone" && key !== "timezoneOffset" && key !== "week" && key !== "hour") { this[addFunc](config[key] - this[getFunc]()); } else if ( key === "timezone"|| key === "timezoneOffset" || key === "week" || key === "hour") { this["set"+name](config[key]); } } } // day has to go last because you can't validate the day without first knowing the month if (config.day) { this.addDays(config.day - this.getDate()); } return this; }; /** * Moves the date to the first day of the month. * @return {Date} this */ $P.moveToFirstDayOfMonth = function () { return this.set({ day: 1 }); }; /** * Moves the date to the last day of the month. * @return {Date} this */ $P.moveToLastDayOfMonth = function () { return this.set({ day: $D.getDaysInMonth(this.getFullYear(), this.getMonth())}); }; /** * Converts the value of the current Date object to its equivalent string representation. * Format Specifiers * CUSTOM DATE AND TIME FORMAT STRINGS * Format Description Example * ------ --------------------------------------------------------------------------- ----------------------- * s The seconds of the minute between 0-59. "0" to "59" * ss The seconds of the minute with leading zero if required. "00" to "59" * * m The minute of the hour between 0-59. "0" or "59" * mm The minute of the hour with leading zero if required. "00" or "59" * * h The hour of the day between 1-12. "1" to "12" * hh The hour of the day with leading zero if required. "01" to "12" * * H The hour of the day between 0-23. "0" to "23" * HH The hour of the day with leading zero if required. "00" to "23" * * d The day of the month between 1 and 31. "1" to "31" * dd The day of the month with leading zero if required. "01" to "31" * ddd Abbreviated day name. Date.CultureInfo.abbreviatedDayNames. "Mon" to "Sun" * dddd The full day name. Date.CultureInfo.dayNames. "Monday" to "Sunday" * * M The month of the year between 1-12. "1" to "12" * MM The month of the year with leading zero if required. "01" to "12" * MMM Abbreviated month name. Date.CultureInfo.abbreviatedMonthNames. "Jan" to "Dec" * MMMM The full month name. Date.CultureInfo.monthNames. "January" to "December" * * yy The year as a two-digit number. "99" or "08" * yyyy The full four digit year. "1999" or "2008" * * t Displays the first character of the A.M./P.M. designator. "A" or "P" * Date.CultureInfo.amDesignator or Date.CultureInfo.pmDesignator * tt Displays the A.M./P.M. designator. "AM" or "PM" * Date.CultureInfo.amDesignator or Date.CultureInfo.pmDesignator * * S The ordinal suffix ("st, "nd", "rd" or "th") of the current day. "st, "nd", "rd" or "th" * * STANDARD DATE AND TIME FORMAT STRINGS * Format Description Example *------ --------------------------------------------------------------------------- ----------------------- * d The CultureInfo shortDate Format Pattern "M/d/yyyy" * D The CultureInfo longDate Format Pattern "dddd, MMMM dd, yyyy" * F The CultureInfo fullDateTime Format Pattern "dddd, MMMM dd, yyyy h:mm:ss tt" * m The CultureInfo monthDay Format Pattern "MMMM dd" * r The CultureInfo rfc1123 Format Pattern "ddd, dd MMM yyyy HH:mm:ss GMT" * s The CultureInfo sortableDateTime Format Pattern "yyyy-MM-ddTHH:mm:ss" * t The CultureInfo shortTime Format Pattern "h:mm tt" * T The CultureInfo longTime Format Pattern "h:mm:ss tt" * u The CultureInfo universalSortableDateTime Format Pattern "yyyy-MM-dd HH:mm:ssZ" * y The CultureInfo yearMonth Format Pattern "MMMM, yyyy" * * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @return {String} A string representation of the current Date object. */ var ord = function (n) { switch (n * 1) { case 1: case 21: case 31: return "st"; case 2: case 22: return "nd"; case 3: case 23: return "rd"; default: return "th"; } }; var parseStandardFormats = function (format) { var y, c = Date.CultureInfo.formatPatterns; switch (format) { case "d": return this.toString(c.shortDate); case "D": return this.toString(c.longDate); case "F": return this.toString(c.fullDateTime); case "m": return this.toString(c.monthDay); case "r": case "R": y = this.clone().addMinutes(this.getTimezoneOffset()); return y.toString(c.rfc1123) + " GMT"; case "s": return this.toString(c.sortableDateTime); case "t": return this.toString(c.shortTime); case "T": return this.toString(c.longTime); case "u": y = this.clone().addMinutes(this.getTimezoneOffset()); return y.toString(c.universalSortableDateTime); case "y": return this.toString(c.yearMonth); default: return false; } }; var parseFormatStringsClosure = function (context) { return function (m) { if (m.charAt(0) === "\\") { return m.replace("\\", ""); } switch (m) { case "hh": return p(context.getHours() < 13 ? (context.getHours() === 0 ? 12 : context.getHours()) : (context.getHours() - 12)); case "h": return context.getHours() < 13 ? (context.getHours() === 0 ? 12 : context.getHours()) : (context.getHours() - 12); case "HH": return p(context.getHours()); case "H": return context.getHours(); case "mm": return p(context.getMinutes()); case "m": return context.getMinutes(); case "ss": return p(context.getSeconds()); case "s": return context.getSeconds(); case "yyyy": return p(context.getFullYear(), 4); case "yy": return p(context.getFullYear()); case "y": return context.getFullYear(); case "E": case "dddd": return Date.CultureInfo.dayNames[context.getDay()]; case "ddd": return Date.CultureInfo.abbreviatedDayNames[context.getDay()]; case "dd": return p(context.getDate()); case "d": return context.getDate(); case "MMMM": return Date.CultureInfo.monthNames[context.getMonth()]; case "MMM": return Date.CultureInfo.abbreviatedMonthNames[context.getMonth()]; case "MM": return p((context.getMonth() + 1)); case "M": return context.getMonth() + 1; case "t": return context.getHours() < 12 ? Date.CultureInfo.amDesignator.substring(0, 1) : Date.CultureInfo.pmDesignator.substring(0, 1); case "tt": return context.getHours() < 12 ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator; case "S": return ord(context.getDate()); case "W": return context.getWeek(); case "WW": return context.getISOWeek(); case "Q": return "Q" + context.getQuarter(); case "q": return String(context.getQuarter()); case "z": return context.getTimezone(); case "Z": case "X": return Date.getTimezoneOffset(context.getTimezone()); case "ZZ": // Timezone offset in seconds return context.getTimezoneOffset() * -60; case "u": return context.getDay(); case "L": return ($D.isLeapYear(context.getFullYear())) ? 1 : 0; case "B": // Swatch Internet Time (.beats) return "@"+((context.getUTCSeconds() + (context.getUTCMinutes()*60) + ((context.getUTCHours()+1)*3600))/86.4); default: return m; } }; }; $P.toString = function (format, ignoreStandards) { // Standard Date and Time Format Strings. Formats pulled from CultureInfo file and // may vary by culture. if (!ignoreStandards && format && format.length === 1) { output = parseStandardFormats.call(this, format); if (output) { return output; } } var parseFormatStrings = parseFormatStringsClosure(this); return format ? format.replace(/((\\)?(dd?d?d?|MM?M?M?|yy?y?y?|hh?|HH?|mm?|ss?|tt?|S|q|Q|WW?W?W?)(?![^\[]*\]))/g, parseFormatStrings).replace(/\[|\]/g, "") : this._toString(); }; }()); /************************************************************* * SugarPak - Domain Specific Language - Syntactical Sugar * *************************************************************/ (function () { var $D = Date, $P = $D.prototype, $N = Number.prototype; // private $P._orient = +1; // private $P._nth = null; // private $P._is = false; // private $P._same = false; // private $P._isSecond = false; // private $N._dateElement = "days"; /** * Moves the date to the next instance of a date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.today().next().friday();
	Date.today().next().fri();
	Date.today().next().march();
	Date.today().next().mar();
	Date.today().next().week();
	
* * @return {Date} date */ $P.next = function () { this._move = true; this._orient = +1; return this; }; /** * Creates a new Date (Date.today()) and moves the date to the next instance of the date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.next().friday();
	Date.next().fri();
	Date.next().march();
	Date.next().mar();
	Date.next().week();
	
* * @return {Date} date */ $D.next = function () { return $D.today().next(); }; /** * Moves the date to the previous instance of a date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.today().last().friday();
	Date.today().last().fri();
	Date.today().last().march();
	Date.today().last().mar();
	Date.today().last().week();
	
* * @return {Date} date */ $P.last = $P.prev = $P.previous = function () { this._move = true; this._orient = -1; return this; }; /** * Creates a new Date (Date.today()) and moves the date to the previous instance of the date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.last().friday();
	Date.last().fri();
	Date.previous().march();
	Date.prev().mar();
	Date.last().week();
	
* * @return {Date} date */ $D.last = $D.prev = $D.previous = function () { return $D.today().last(); }; /** * Performs a equality check when followed by either a month name, day name or .weekday() function. * Example

	Date.today().is().friday(); // true|false
	Date.today().is().fri();
	Date.today().is().march();
	Date.today().is().mar();
	
* * @return {Boolean} true|false */ $P.is = function () { this._is = true; return this; }; /** * Determines if two date objects occur on/in exactly the same instance of the subsequent date part function. * The function .same() must be followed by a date part function (example: .day(), .month(), .year(), etc). * * An optional Date can be passed in the date part function. If now date is passed as a parameter, 'Now' is used. * * The following example demonstrates how to determine if two dates fall on the exact same day. * * Example

	var d1 = Date.today(); // today at 00:00
	var d2 = new Date();   // exactly now.

	// Do they occur on the same day?
	d1.same().day(d2); // true
	
	// Do they occur on the same hour?
	d1.same().hour(d2); // false, unless d2 hour is '00' (midnight).
	
	// What if it's the same day, but one year apart?
	var nextYear = Date.today().add(1).year();

	d1.same().day(nextYear); // false, because the dates must occur on the exact same day. 
	
* * Scenario: Determine if a given date occurs during some week period 2 months from now. * * Example

	var future = Date.today().add(2).months();
	return someDate.same().week(future); // true|false;
	
* * @return {Boolean} true|false */ $P.same = function () { this._same = true; this._isSecond = false; return this; }; /** * Determines if the current date/time occurs during Today. Must be preceded by the .is() function. * Example

	someDate.is().today();    // true|false
	new Date().is().today();  // true
	Date.today().is().today();// true
	Date.today().add(-1).day().is().today(); // false
	
* * @return {Boolean} true|false */ $P.today = function () { return this.same().day(); }; /** * Determines if the current date is a weekday. This function must be preceded by the .is() function. * Example

	Date.today().is().weekday(); // true|false
	
* * @return {Boolean} true|false */ $P.weekday = function () { if (this._nth) { return df("Weekday").call(this); } if (this._move) { return this.addWeekdays(this._orient); } if (this._is) { this._is = false; return (!this.is().sat() && !this.is().sun()); } return false; }; /** * Determines if the current date is on the weekend. This function must be preceded by the .is() function. * Example

	Date.today().is().weekend(); // true|false
	
* * @return {Boolean} true|false */ $P.weekend = function () { if (this._is) { this._is = false; return (this.is().sat() || this.is().sun()); } return false; }; /** * Sets the Time of the current Date instance. A string "6:15 pm" or config object {hour:18, minute:15} are accepted. * Example

	// Set time to 6:15pm with a String
	Date.today().at("6:15pm");

	// Set time to 6:15pm with a config object
	Date.today().at({hour:18, minute:15});
	
* * @return {Date} date */ $P.at = function (time) { return (typeof time === "string") ? $D.parse(this.toString("d") + " " + time) : this.set(time); }; /** * Creates a new Date() and adds this (Number) to the date based on the preceding date element function (eg. second|minute|hour|day|month|year). * Example

	// Undeclared Numbers must be wrapped with parentheses. Requirment of JavaScript.
	(3).days().fromNow();
	(6).months().fromNow();

	// Declared Number variables do not require parentheses. 
	var n = 6;
	n.months().fromNow();
	
* * @return {Date} A new Date instance */ $N.fromNow = $N.after = function (date) { var c = {}; c[this._dateElement] = this; return ((!date) ? new Date() : date.clone()).add(c); }; /** * Creates a new Date() and subtract this (Number) from the date based on the preceding date element function (eg. second|minute|hour|day|month|year). * Example

	// Undeclared Numbers must be wrapped with parentheses. Requirment of JavaScript.
	(3).days().ago();
	(6).months().ago();

	// Declared Number variables do not require parentheses. 
	var n = 6;
	n.months().ago();
	
* * @return {Date} A new Date instance */ $N.ago = $N.before = function (date) { var c = {}, s = (this._dateElement[this._dateElement.length-1] !== "s") ? this._dateElement + "s" : this._dateElement; c[s] = this * -1; return ((!date) ? new Date() : date.clone()).add(c); }; // Do NOT modify the following string tokens. These tokens are used to build dynamic functions. // All culture-specific strings can be found in the CultureInfo files. var dx = ("sunday monday tuesday wednesday thursday friday saturday").split(/\s/), mx = ("january february march april may june july august september october november december").split(/\s/), px = ("Millisecond Second Minute Hour Day Week Month Year Quarter Weekday").split(/\s/), pxf = ("Milliseconds Seconds Minutes Hours Date Week Month FullYear Quarter").split(/\s/), nth = ("final first second third fourth fifth").split(/\s/), de; /** * Returns an object literal of all the date parts. * Example

	var o = new Date().toObject();
	
	// { year: 2008, month: 4, week: 20, day: 13, hour: 18, minute: 9, second: 32, millisecond: 812 }
	
	// The object properties can be referenced directly from the object.
	
	alert(o.day);  // alerts "13"
	alert(o.year); // alerts "2008"
	
* * @return {Date} An object literal representing the original date object. */ $P.toObject = function () { var o = {}; for (var i = 0; i < px.length; i++) { if (this["get" + pxf[i]]) { o[px[i].toLowerCase()] = this["get" + pxf[i]](); } } return o; }; /** * Returns a date created from an object literal. Ignores the .week property if set in the config. * Example

	var o = new Date().toObject();
	
	return Date.fromObject(o); // will return the same date. 

	var o2 = {month: 1, day: 20, hour: 18}; // birthday party!
	Date.fromObject(o2);
	
* * @return {Date} An object literal representing the original date object. */ $D.fromObject = function(config) { config.week = null; return Date.today().set(config); }; // Create day name functions and abbreviated day name functions (eg. monday(), friday(), fri()). var df = function (n) { return function () { if (this._is) { this._is = false; return this.getDay() === n; } if (this._move) { this._move = null; } if (this._nth !== null) { // If the .second() function was called earlier, remove the _orient // from the date, and then continue. // This is required because 'second' can be used in two different context. // // Example // // Date.today().add(1).second(); // Date.march().second().monday(); // // Things get crazy with the following... // Date.march().add(1).second().second().monday(); // but it works!! // if (this._isSecond) { this.addSeconds(this._orient * -1); } // make sure we reset _isSecond this._isSecond = false; var ntemp = this._nth; this._nth = null; var temp = this.clone().moveToLastDayOfMonth(); this.moveToNthOccurrence(n, ntemp); if (this > temp) { throw new RangeError($D.getDayName(n) + " does not occur " + ntemp + " times in the month of " + $D.getMonthName(temp.getMonth()) + " " + temp.getFullYear() + "."); } return this; } return this.moveToDayOfWeek(n, this._orient); }; }; var sdf = function (n) { return function () { var t = $D.today(), shift = n - t.getDay(); if (n === 0 && Date.CultureInfo.firstDayOfWeek === 1 && t.getDay() !== 0) { shift = shift + 7; } return t.addDays(shift); }; }; // Create month name functions and abbreviated month name functions (eg. january(), march(), mar()). var month_instance_functions = function (n) { return function () { if (this._is) { this._is = false; return this.getMonth() === n; } return this.moveToMonth(n, this._orient); }; }; var month_static_functions = function (n) { return function () { return $D.today().set({ month: n, day: 1 }); }; }; var processTerms = function (names, staticFunc, instanceFunc) { for (var i = 0; i < names.length; i++) { // Create constant static Name variables. $D[names[i].toUpperCase()] = $D[names[i].toUpperCase().substring(0, 3)] = i; // Create Name functions. $D[names[i]] = $D[names[i].substring(0, 3)] = staticFunc(i); // Create Name instance functions. $P[names[i]] = $P[names[i].substring(0, 3)] = instanceFunc(i); } }; processTerms(dx, sdf, df); processTerms(mx, month_static_functions, month_instance_functions); // Create date element functions and plural date element functions used with Date (eg. day(), days(), months()). var ef = function (j) { return function () { // if the .second() function was called earlier, the _orient // has alread been added. Just return this and reset _isSecond. if (this._isSecond) { this._isSecond = false; return this; } if (this._same) { this._same = this._is = false; var o1 = this.toObject(), o2 = (arguments[0] || new Date()).toObject(), v = "", k = j.toLowerCase(); // the substr trick with -1 doesn't work in IE8 or less k = (k[k.length-1] === "s") ? k.substring(0,k.length-1) : k; for (var m = (px.length - 1); m > -1; m--) { v = px[m].toLowerCase(); if (o1[v] !== o2[v]) { return false; } if (k === v) { break; } } return true; } if (j.substring(j.length - 1) !== "s") { j += "s"; } if (this._move) { this._move = null; } return this["add" + j](this._orient); }; }; var nf = function (n) { return function () { this._dateElement = n; return this; }; }; for (var k = 0; k < px.length; k++) { de = px[k].toLowerCase(); if(de !== "weekday") { // Create date element functions and plural date element functions used with Date (eg. day(), days(), months()). $P[de] = $P[de + "s"] = ef(px[k]); // Create date element functions and plural date element functions used with Number (eg. day(), days(), months()). $N[de] = $N[de + "s"] = nf(de + "s"); } } $P._ss = ef("Second"); var nthfn = function (n) { return function (dayOfWeek) { if (this._same) { return this._ss(arguments[0]); } if (dayOfWeek || dayOfWeek === 0) { return this.moveToNthOccurrence(dayOfWeek, n); } this._nth = n; // if the operator is 'second' add the _orient, then deal with it later... if (n === 2 && (dayOfWeek === undefined || dayOfWeek === null)) { this._isSecond = true; return this.addSeconds(this._orient); } return this; }; }; for (var l = 0; l < nth.length; l++) { $P[nth[l]] = (l === 0) ? nthfn(-1) : nthfn(l); } }()); (function () { "use strict"; Date.Parsing = { Exception: function (s) { this.message = "Parse error at '" + s.substring(0, 10) + " ...'"; } }; var $P = Date.Parsing; var dayOffsets = { standard: [0,31,59,90,120,151,181,212,243,273,304,334], leap: [0,31,60,91,121,152,182,213,244,274,305,335] }; $P.isLeapYear = function(year) { return ((year % 4 === 0) && (year % 100 !== 0)) || (year % 400 === 0); }; var utils = { multiReplace : function (str, hash ) { var key; for (key in hash) { if (Object.prototype.hasOwnProperty.call(hash, key)) { var regex; if (typeof hash[key] === "function") { } else { regex = (hash[key] instanceof RegExp) ? hash[key] : new RegExp(hash[key], "g"); } str = str.replace(regex, key); } } return str; }, getDayOfYearFromWeek : function (obj) { var d, jan4, offset; obj.weekDay = (!obj.weekDay && obj.weekDay !== 0) ? 1 : obj.weekDay; d = new Date(obj.year, 0, 4); jan4 = d.getDay() === 0 ? 7 : d.getDay(); // JS is 0 indexed on Sunday. offset = jan4+3; obj.dayOfYear = ((obj.week * 7) + (obj.weekDay === 0 ? 7 : obj.weekDay))-offset; return obj; }, getDayOfYear : function (obj, dayOffset) { if (!obj.dayOfYear) { obj = utils.getDayOfYearFromWeek(obj); } for (var i=0;i <= dayOffset.length;i++) { if (obj.dayOfYear < dayOffset[i] || i === dayOffset.length) { obj.day = obj.day ? obj.day : (obj.dayOfYear - dayOffset[i-1]); break; } else { obj.month = i; } } return obj; }, adjustForTimeZone : function (obj, date) { var offset; if (obj.zone.toUpperCase() === "Z" || (obj.zone_hours === 0 && obj.zone_minutes === 0)) { // it's UTC/GML so work out the current timeszone offset offset = -date.getTimezoneOffset(); } else { offset = (obj.zone_hours*60) + (obj.zone_minutes || 0); if (obj.zone_sign === "+") { offset *= -1; } offset -= date.getTimezoneOffset(); } date.setMinutes(date.getMinutes()+offset); return date; }, setDefaults : function (obj) { obj.year = obj.year || Date.today().getFullYear(); obj.hours = obj.hours || 0; obj.minutes = obj.minutes || 0; obj.seconds = obj.seconds || 0; obj.milliseconds = obj.milliseconds || 0; if (!(!obj.month && (obj.week || obj.dayOfYear))) { // if we have a month, or if we don't but don't have the day calculation data obj.month = obj.month || 0; obj.day = obj.day || 1; } return obj; }, dataNum: function (data, mod, explict, postProcess) { var dataNum = data*1; if (mod) { if (postProcess) { return data ? mod(data)*1 : data; } else { return data ? mod(dataNum) : data; } } else if (!explict){ return data ? dataNum : data; } else { return (data && typeof data !== "undefined") ? dataNum : data; } }, timeDataProcess: function (obj) { var timeObj = {}; for (var x in obj.data) { if (obj.data.hasOwnProperty(x)) { timeObj[x] = obj.ignore[x] ? obj.data[x] : utils.dataNum(obj.data[x], obj.mods[x], obj.explict[x], obj.postProcess[x]); } } if (obj.data.secmins) { obj.data.secmins = obj.data.secmins.replace(",", ".") * 60; if (!timeObj.minutes) { timeObj.minutes = obj.data.secmins; } else if (!timeObj.seconds) { timeObj.seconds = obj.data.secmins; } delete obj.secmins; } return timeObj; }, buildTimeObjectFromData: function (data) { var time = utils.timeDataProcess({ data: { year : data[1], month : data[5], day : data[7], week : data[8], dayOfYear : data[10], hours : data[15], zone_hours : data[23], zone_minutes : data[24], zone : data[21], zone_sign : data[22], weekDay : data[9], minutes: data[16], seconds: data[19], milliseconds: data[20], secmins: data[18] }, mods: { month: function(data) { return data-1; }, weekDay: function (data) { data = Math.abs(data); return (data === 7 ? 0 : data); }, minutes: function (data) { return data.replace(":",""); }, seconds: function (data) { return Math.floor( (data.replace(":","").replace(",","."))*1 ); }, milliseconds: function (data) { return (data.replace(",",".")*1000); } }, postProcess: { minutes: true, seconds: true, milliseconds: true }, explict: { zone_hours: true, zone_minutes: true }, ignore: { zone: true, zone_sign: true, secmins: true } }); return time; }, addToHash: function (hash, keys, data) { keys = keys; data = data; var len = keys.length; for (var i = 0; i < len; i++) { hash[keys[i]] = data[i]; } return hash; }, combineRegex: function (r1, r2) { return new RegExp("(("+r1.source+")\\s("+r2.source+"))"); }, getDateNthString: function(add, last, inc){ if (add) { return Date.today().addDays(inc).toString("d"); } else if (last) { return Date.today().last()[inc]().toString("d"); } }, buildRegexData: function (array) { var arr = []; var len = array.length; for (var i=0; i < len; i++) { if (Object.prototype.toString.call(array[i]) === '[object Array]') { // oldIE compat version of Array.isArray arr.push(this.combineRegex(array[i][0], array[i][1])); } else { arr.push(array[i]); } } return arr; } }; $P.processTimeObject = function (obj) { var date, dayOffset; utils.setDefaults(obj); dayOffset = ($P.isLeapYear(obj.year)) ? dayOffsets.leap : dayOffsets.standard; if (!obj.month && (obj.week || obj.dayOfYear)) { utils.getDayOfYear(obj, dayOffset); } else { obj.dayOfYear = dayOffset[obj.month] + obj.day; } date = new Date(obj.year, obj.month, obj.day, obj.hours, obj.minutes, obj.seconds, obj.milliseconds); if (obj.zone) { utils.adjustForTimeZone(obj, date); // adjust (and calculate) for timezone } return date; }; $P.ISO = { regex : /^([\+-]?\d{4}(?!\d{2}\b))((-?)((0[1-9]|1[0-2])(\3([12]\d|0[1-9]|3[01]))?|W([0-4]\d|5[0-3])(-?[1-7])?|(00[1-9]|0[1-9]\d|[12]\d{2}|3([0-5]\d|6[1-6])))([T\s]((([01]\d|2[0-4])((:?)[0-5]\d)?|24\:?00)([\.,]\d+(?!:))?)?(\17[0-5]\d([\.,]\d+)?)?\s?([zZ]|([\+-])([01]\d|2[0-3]):?([0-5]\d)?)?)?)?$/, parse : function (s) { var time, data = s.match(this.regex); if (!data || !data.length) { return null; } time = utils.buildTimeObjectFromData(data); if (!time.year || (!time.year && (!time.month && !time.day) && (!time.week && !time.dayOfYear)) ) { return null; } return $P.processTimeObject(time); } }; $P.Numeric = { isNumeric: function (e){return!isNaN(parseFloat(e))&&isFinite(e);}, regex: /\b([0-1]?[0-9])([0-3]?[0-9])([0-2]?[0-9]?[0-9][0-9])\b/i, parse: function (s) { var data, i, time = {}, order = Date.CultureInfo.dateElementOrder.split(""); if (!(this.isNumeric(s)) || // if it's non-numeric OR (s[0] === "+" && s[0] === "-")) { // It's an arithmatic string (eg +/-1000) return null; } if (s.length < 5 && s.indexOf(".") < 0 && s.indexOf("/") < 0) { // assume it's just a year. time.year = s; return $P.processTimeObject(time); } data = s.match(this.regex); if (!data || !data.length) { return null; } for (i=0; i < order.length; i++) { switch(order[i]) { case "d": time.day = data[i+1]; break; case "m": time.month = (data[i+1]-1); break; case "y": time.year = data[i+1]; break; } } return $P.processTimeObject(time); } }; $P.Normalizer = { regexData: function () { var $R = Date.CultureInfo.regexPatterns; return utils.buildRegexData([ $R.tomorrow, $R.yesterday, [$R.past, $R.mon], [$R.past, $R.tue], [$R.past, $R.wed], [$R.past, $R.thu], [$R.past, $R.fri], [$R.past, $R.sat], [$R.past, $R.sun] ]); }, basicReplaceHash : function() { var $R = Date.CultureInfo.regexPatterns; return { "January": $R.jan.source, "February": $R.feb, "March": $R.mar, "April": $R.apr, "May": $R.may, "June": $R.jun, "July": $R.jul, "August": $R.aug, "September": $R.sep, "October": $R.oct, "November": $R.nov, "December": $R.dec, "": /\bat\b/gi, " ": /\s{2,}/, "am": $R.inTheMorning, "9am": $R.thisMorning, "pm": $R.inTheEvening, "7pm":$R.thisEvening }; }, keys : function(){ return [ utils.getDateNthString(true, false, 1), // tomorrow utils.getDateNthString(true, false, -1), // yesterday utils.getDateNthString(false, true, "monday"), //last mon utils.getDateNthString(false, true, "tuesday"), //last tues utils.getDateNthString(false, true, "wednesday"), //last wed utils.getDateNthString(false, true, "thursday"), //last thurs utils.getDateNthString(false, true, "friday"), //last fri utils.getDateNthString(false, true, "saturday"), //last sat utils.getDateNthString(false, true, "sunday") //last sun ]; }, buildRegexFunctions: function () { var $R = Date.CultureInfo.regexPatterns; var __ = Date.i18n.__; var tomorrowRE = new RegExp("(\\b\\d\\d?("+__("AM")+"|"+__("PM")+")? )("+$R.tomorrow.source.slice(1)+")", "i"); // adapted tomorrow regex for AM PM relative dates var todayRE = new RegExp($R.today.source + "(?!\\s*([+-]))\\b"); // today, but excludes the math operators (eg "today + 2h") this.replaceFuncs = [ [todayRE, function (full) { return (full.length > 1) ? Date.today().toString("d") : full; }], [tomorrowRE, function(full, m1) { var t = Date.today().addDays(1).toString("d"); return (t + " " + m1); }], [$R.amThisMorning, function(str, am){return am;}], [$R.pmThisEvening, function(str, pm){return pm;}] ]; }, buildReplaceData: function () { this.buildRegexFunctions(); this.replaceHash = utils.addToHash(this.basicReplaceHash(), this.keys(), this.regexData()); }, stringReplaceFuncs: function (s) { for (var i=0; i < this.replaceFuncs.length; i++) { s = s.replace(this.replaceFuncs[i][0], this.replaceFuncs[i][1]); } return s; }, parse: function (s) { s = this.stringReplaceFuncs(s); s = utils.multiReplace(s, this.replaceHash); try { var n = s.split(/([\s\-\.\,\/\x27]+)/); if (n.length === 3 && $P.Numeric.isNumeric(n[0]) && $P.Numeric.isNumeric(n[2]) && (n[2].length >= 4)) { // ok, so we're dealing with x/year. But that's not a full date. // This fixes wonky dateElementOrder parsing when set to dmy order. if (Date.CultureInfo.dateElementOrder[0] === "d") { s = "1/" + n[0] + "/" + n[2]; // set to 1st of month and normalize the seperator } } } catch (e) {} return s; } }; $P.Normalizer.buildReplaceData(); }()); (function () { var $P = Date.Parsing; var _ = $P.Operators = { // // Tokenizers // rtoken: function (r) { // regex token return function (s) { var mx = s.match(r); if (mx) { return ([ mx[0], s.substring(mx[0].length) ]); } else { throw new $P.Exception(s); } }; }, token: function () { // whitespace-eating token return function (s) { return _.rtoken(new RegExp("^\\s*" + s + "\\s*"))(s); }; }, stoken: function (s) { // string token return _.rtoken(new RegExp("^" + s)); }, // Atomic Operators until: function (p) { return function (s) { var qx = [], rx = null; while (s.length) { try { rx = p.call(this, s); } catch (e) { qx.push(rx[0]); s = rx[1]; continue; } break; } return [ qx, s ]; }; }, many: function (p) { return function (s) { var rx = [], r = null; while (s.length) { try { r = p.call(this, s); } catch (e) { return [ rx, s ]; } rx.push(r[0]); s = r[1]; } return [ rx, s ]; }; }, // generator operators -- see below optional: function (p) { return function (s) { var r = null; try { r = p.call(this, s); } catch (e) { return [ null, s ]; } return [ r[0], r[1] ]; }; }, not: function (p) { return function (s) { try { p.call(this, s); } catch (e) { return [null, s]; } throw new $P.Exception(s); }; }, ignore: function (p) { return p ? function (s) { var r = null; r = p.call(this, s); return [null, r[1]]; } : null; }, product: function () { var px = arguments[0], qx = Array.prototype.slice.call(arguments, 1), rx = []; for (var i = 0 ; i < px.length ; i++) { rx.push(_.each(px[i], qx)); } return rx; }, cache: function (rule) { var cache = {}, cache_length = 0, cache_keys = [], CACHE_MAX = Date.Config.CACHE_MAX || 100000, r = null; var cacheCheck = function () { if (cache_length === CACHE_MAX) { // kill several keys, don't want to have to do this all the time... for (var i=0; i < 10; i++) { var key = cache_keys.shift(); if (key) { delete cache[key]; cache_length--; } } } }; return function (s) { cacheCheck(); try { r = cache[s] = (cache[s] || rule.call(this, s)); } catch (e) { r = cache[s] = e; } cache_length++; cache_keys.push(s); if (r instanceof $P.Exception) { throw r; } else { return r; } }; }, // vector operators -- see below any: function () { var px = arguments; return function (s) { var r = null; for (var i = 0; i < px.length; i++) { if (px[i] == null) { continue; } try { r = (px[i].call(this, s)); } catch (e) { r = null; } if (r) { return r; } } throw new $P.Exception(s); }; }, each: function () { var px = arguments; return function (s) { var rx = [], r = null; for (var i = 0; i < px.length ; i++) { if (px[i] == null) { continue; } try { r = (px[i].call(this, s)); } catch (e) { throw new $P.Exception(s); } rx.push(r[0]); s = r[1]; } return [ rx, s]; }; }, all: function () { var px = arguments, _ = _; return _.each(_.optional(px)); }, // delimited operators sequence: function (px, d, c) { d = d || _.rtoken(/^\s*/); c = c || null; if (px.length === 1) { return px[0]; } return function (s) { var r = null, q = null; var rx = []; for (var i = 0; i < px.length ; i++) { try { r = px[i].call(this, s); } catch (e) { break; } rx.push(r[0]); try { q = d.call(this, r[1]); } catch (ex) { q = null; break; } s = q[1]; } if (!r) { throw new $P.Exception(s); } if (q) { throw new $P.Exception(q[1]); } if (c) { try { r = c.call(this, r[1]); } catch (ey) { throw new $P.Exception(r[1]); } } return [ rx, (r?r[1]:s) ]; }; }, // // Composite Operators // between: function (d1, p, d2) { d2 = d2 || d1; var _fn = _.each(_.ignore(d1), p, _.ignore(d2)); return function (s) { var rx = _fn.call(this, s); return [[rx[0][0], r[0][2]], rx[1]]; }; }, list: function (p, d, c) { d = d || _.rtoken(/^\s*/); c = c || null; return (p instanceof Array ? _.each(_.product(p.slice(0, -1), _.ignore(d)), p.slice(-1), _.ignore(c)) : _.each(_.many(_.each(p, _.ignore(d))), px, _.ignore(c))); }, set: function (px, d, c) { d = d || _.rtoken(/^\s*/); c = c || null; return function (s) { // r is the current match, best the current 'best' match // which means it parsed the most amount of input var r = null, p = null, q = null, rx = null, best = [[], s], last = false; // go through the rules in the given set for (var i = 0; i < px.length ; i++) { // last is a flag indicating whether this must be the last element // if there is only 1 element, then it MUST be the last one q = null; p = null; r = null; last = (px.length === 1); // first, we try simply to match the current pattern // if not, try the next pattern try { r = px[i].call(this, s); } catch (e) { continue; } // since we are matching against a set of elements, the first // thing to do is to add r[0] to matched elements rx = [[r[0]], r[1]]; // if we matched and there is still input to parse and // we don't already know this is the last element, // we're going to next check for the delimiter ... // if there's none, or if there's no input left to parse // than this must be the last element after all ... if (r[1].length > 0 && ! last) { try { q = d.call(this, r[1]); } catch (ex) { last = true; } } else { last = true; } // if we parsed the delimiter and now there's no more input, // that means we shouldn't have parsed the delimiter at all // so don't update r and mark this as the last element ... if (!last && q[1].length === 0) { last = true; } // so, if this isn't the last element, we're going to see if // we can get any more matches from the remaining (unmatched) // elements ... if (!last) { // build a list of the remaining rules we can match against, // i.e., all but the one we just matched against var qx = []; for (var j = 0; j < px.length ; j++) { if (i !== j) { qx.push(px[j]); } } // now invoke recursively set with the remaining input // note that we don't include the closing delimiter ... // we'll check for that ourselves at the end p = _.set(qx, d).call(this, q[1]); // if we got a non-empty set as a result ... // (otw rx already contains everything we want to match) if (p[0].length > 0) { // update current result, which is stored in rx ... // basically, pick up the remaining text from p[1] // and concat the result from p[0] so that we don't // get endless nesting ... rx[0] = rx[0].concat(p[0]); rx[1] = p[1]; } } // at this point, rx either contains the last matched element // or the entire matched set that starts with this element. // now we just check to see if this variation is better than // our best so far, in terms of how much of the input is parsed if (rx[1].length < best[1].length) { best = rx; } // if we've parsed all the input, then we're finished if (best[1].length === 0) { break; } } // so now we've either gone through all the patterns trying them // as the initial match; or we found one that parsed the entire // input string ... // if best has no matches, just return empty set ... if (best[0].length === 0) { return best; } // if a closing delimiter is provided, then we have to check it also if (c) { // we try this even if there is no remaining input because the pattern // may well be optional or match empty input ... try { q = c.call(this, best[1]); } catch (ey) { throw new $P.Exception(best[1]); } // it parsed ... be sure to update the best match remaining input best[1] = q[1]; } // if we're here, either there was no closing delimiter or we parsed it // so now we have the best match; just return it! return best; }; }, forward: function (gr, fname) { return function (s) { return gr[fname].call(this, s); }; }, // // Translation Operators // replace: function (rule, repl) { return function (s) { var r = rule.call(this, s); return [repl, r[1]]; }; }, process: function (rule, fn) { return function (s) { var r = rule.call(this, s); return [fn.call(this, r[0]), r[1]]; }; }, min: function (min, rule) { return function (s) { var rx = rule.call(this, s); if (rx[0].length < min) { throw new $P.Exception(s); } return rx; }; } }; // Generator Operators And Vector Operators // Generators are operators that have a signature of F(R) => R, // taking a given rule and returning another rule, such as // ignore, which parses a given rule and throws away the result. // Vector operators are those that have a signature of F(R1,R2,...) => R, // take a list of rules and returning a new rule, such as each. // Generator operators are converted (via the following _generator // function) into functions that can also take a list or array of rules // and return an array of new rules as though the function had been // called on each rule in turn (which is what actually happens). // This allows generators to be used with vector operators more easily. // Example: // each(ignore(foo, bar)) instead of each(ignore(foo), ignore(bar)) // This also turns generators into vector operators, which allows // constructs like: // not(cache(foo, bar)) var _generator = function (op) { function gen() { var args = null, rx = [], px, i; if (arguments.length > 1) { args = Array.prototype.slice.call(arguments); } else if (arguments[0] instanceof Array) { args = arguments[0]; } if (args) { px = args.shift(); if (px.length > 0) { args.unshift(px[i]); rx.push(op.apply(null, args)); args.shift(); return rx; } } else { return op.apply(null, arguments); } } return gen; }; var gx = "optional not ignore cache".split(/\s/); for (var i = 0 ; i < gx.length ; i++) { _[gx[i]] = _generator(_[gx[i]]); } var _vector = function (op) { return function () { if (arguments[0] instanceof Array) { return op.apply(null, arguments[0]); } else { return op.apply(null, arguments); } }; }; var vx = "each any all".split(/\s/); for (var j = 0 ; j < vx.length ; j++) { _[vx[j]] = _vector(_[vx[j]]); } }()); (function () { var $D = Date; var flattenAndCompact = function (ax) { var rx = []; for (var i = 0; i < ax.length; i++) { if (ax[i] instanceof Array) { rx = rx.concat(flattenAndCompact(ax[i])); } else { if (ax[i]) { rx.push(ax[i]); } } } return rx; }; var parseMeridian = function () { if (this.meridian && (this.hour || this.hour === 0)) { if (this.meridian === "a" && this.hour > 11 && Date.Config.strict24hr){ throw "Invalid hour and meridian combination"; } else if (this.meridian === "p" && this.hour < 12 && Date.Config.strict24hr){ throw "Invalid hour and meridian combination"; } else if (this.meridian === "p" && this.hour < 12) { this.hour = this.hour + 12; } else if (this.meridian === "a" && this.hour === 12) { this.hour = 0; } } }; var setDefaults = function () { var now = new Date(); if ((this.hour || this.minute) && (!this.month && !this.year && !this.day)) { this.day = now.getDate(); } if (!this.year) { this.year = now.getFullYear(); } if (!this.month && this.month !== 0) { this.month = now.getMonth(); } if (!this.day) { this.day = 1; } if (!this.hour) { this.hour = 0; } if (!this.minute) { this.minute = 0; } if (!this.second) { this.second = 0; } if (!this.millisecond) { this.millisecond = 0; } }; var finishUtils = { getToday: function () { if (this.now || "hour minute second".indexOf(this.unit) !== -1) { return new Date(); } else { return $D.today(); } }, setDaysFromWeekday: function (today, orient){ var gap; orient = orient || 1; this.unit = "day"; gap = ($D.getDayNumberFromName(this.weekday) - today.getDay()); this.days = gap ? ((gap + (orient * 7)) % 7) : (orient * 7); return this; }, setMonthsFromMonth: function (today, orient) { var gap; orient = orient || 1; this.unit = "month"; gap = (this.month - today.getMonth()); this.months = gap ? ((gap + (orient * 12)) % 12) : (orient * 12); this.month = null; return this; }, setDMYFromWeekday: function () { var d = Date[this.weekday](); this.day = d.getDate(); if (!this.month) { this.month = d.getMonth(); } this.year = d.getFullYear(); return this; }, setUnitValue: function (orient) { if (!this.value && this.operator && this.operator !== null && this[this.unit + "s"] && this[this.unit + "s"] !== null) { this[this.unit + "s"] = this[this.unit + "s"] + ((this.operator === "add") ? 1 : -1) + (this.value||0) * orient; } else if (this[this.unit + "s"] == null || this.operator != null) { if (!this.value) { this.value = 1; } this[this.unit + "s"] = this.value * orient; } }, generateDateFromWeeks: function () { var weekday = (this.weekday !== undefined) ? this.weekday : "today"; var d = Date[weekday]().addWeeks(this.weeks); if (this.now) { d.setTimeToNow(); } return d; } }; $D.Translator = { hour: function (s) { return function () { this.hour = Number(s); }; }, minute: function (s) { return function () { this.minute = Number(s); }; }, second: function (s) { return function () { this.second = Number(s); }; }, /* for ss.s format */ secondAndMillisecond: function (s) { return function () { var mx = s.match(/^([0-5][0-9])\.([0-9]{1,3})/); this.second = Number(mx[1]); this.millisecond = Number(mx[2]); }; }, meridian: function (s) { return function () { this.meridian = s.slice(0, 1).toLowerCase(); }; }, timezone: function (s) { return function () { var n = s.replace(/[^\d\+\-]/g, ""); if (n.length) { this.timezoneOffset = Number(n); } else { this.timezone = s.toLowerCase(); } }; }, day: function (x) { var s = x[0]; return function () { this.day = Number(s.match(/\d+/)[0]); if (this.day < 1) { throw "invalid day"; } }; }, month: function (s) { return function () { this.month = (s.length === 3) ? "jan feb mar apr may jun jul aug sep oct nov dec".indexOf(s)/4 : Number(s) - 1; if (this.month < 0) { throw "invalid month"; } }; }, year: function (s) { return function () { var n = Number(s); this.year = ((s.length > 2) ? n : (n + (((n + 2000) < Date.CultureInfo.twoDigitYearMax) ? 2000 : 1900))); }; }, rday: function (s) { return function () { switch (s) { case "yesterday": this.days = -1; break; case "tomorrow": this.days = 1; break; case "today": this.days = 0; break; case "now": this.days = 0; this.now = true; break; } }; }, finishExact: function (x) { var d; x = (x instanceof Array) ? x : [x]; for (var i = 0 ; i < x.length ; i++) { if (x[i]) { x[i].call(this); } } setDefaults.call(this); parseMeridian.call(this); if (this.day > $D.getDaysInMonth(this.year, this.month)) { throw new RangeError(this.day + " is not a valid value for days."); } d = new Date(this.year, this.month, this.day, this.hour, this.minute, this.second, this.millisecond); if (this.year < 100) { d.setFullYear(this.year); // means years less that 100 are process correctly. JS will parse it otherwise as 1900-1999. } if (this.timezone) { d.set({ timezone: this.timezone }); } else if (this.timezoneOffset) { d.set({ timezoneOffset: this.timezoneOffset }); } return d; }, finish: function (x) { var today, expression, orient, temp; x = (x instanceof Array) ? flattenAndCompact(x) : [ x ]; if (x.length === 0) { return null; } for (var i = 0 ; i < x.length ; i++) { if (typeof x[i] === "function") { x[i].call(this); } } if (this.now && !this.unit && !this.operator) { return new Date(); } else { today = finishUtils.getToday.call(this); } expression = !!(this.days && this.days !== null || this.orient || this.operator); orient = ((this.orient === "past" || this.operator === "subtract") ? -1 : 1); if (this.month && this.unit === "week") { this.value = this.month + 1; delete this.month; delete this.day; } if ((this.month || this.month === 0) && "year day hour minute second".indexOf(this.unit) !== -1) { if (!this.value) { this.value = this.month + 1; } this.month = null; expression = true; } if (!expression && this.weekday && !this.day && !this.days) { finishUtils.setDMYFromWeekday.call(this); } if (expression && this.weekday && this.unit !== "month" && this.unit !== "week") { finishUtils.setDaysFromWeekday.call(this, today, orient); } if (this.weekday && this.unit !== "week" && !this.day && !this.days) { temp = Date[this.weekday](); this.day = temp.getDate(); if (temp.getMonth() !== today.getMonth()) { this.month = temp.getMonth(); } } if (this.month && this.unit === "day" && this.operator) { if (!this.value) { this.value = (this.month + 1); } this.month = null; } if (this.value != null && this.month != null && this.year != null) { this.day = this.value * 1; } if (this.month && !this.day && this.value) { today.set({ day: this.value * 1 }); if (!expression) { this.day = this.value * 1; } } if (!this.month && this.value && this.unit === "month" && !this.now) { this.month = this.value; expression = true; } if (expression && (this.month || this.month === 0) && this.unit !== "year") { finishUtils.setMonthsFromMonth.call(this, today, orient); } if (!this.unit) { this.unit = "day"; } finishUtils.setUnitValue.call(this, orient); parseMeridian.call(this); if ((this.month || this.month === 0) && !this.day) { this.day = 1; } if (!this.orient && !this.operator && this.unit === "week" && this.value && !this.day && !this.month) { return Date.today().setWeek(this.value); } if (this.unit === "week" && this.weeks && !this.day && !this.month) { return finishUtils.generateDateFromWeeks.call(this); } if (expression && this.timezone && this.day && this.days) { this.day = this.days; } if (expression){ today.add(this); } else { today.set(this); } if (this.timezone) { this.timezone = this.timezone.toUpperCase(); var offset = $D.getTimezoneOffset(this.timezone); var timezone; if (today.hasDaylightSavingTime()) { // lets check that we're being sane with timezone setting timezone = $D.getTimezoneAbbreviation(offset, today.isDaylightSavingTime()); if (timezone !== this.timezone) { // bugger, we're in a place where things like EST vs EDT matters. if (today.isDaylightSavingTime()) { today.addHours(-1); } else { today.addHours(1); } } } today.setTimezoneOffset(offset); } return today; } }; }()); (function () { var $D = Date; $D.Grammar = {}; var _ = $D.Parsing.Operators, g = $D.Grammar, t = $D.Translator, _fn; // Allow rolling up into general purpose rules _fn = function () { return _.each(_.any.apply(null, arguments), _.not(g.ctoken2("timeContext"))); }; g.datePartDelimiter = _.rtoken(/^([\s\-\.\,\/\x27]+)/); g.timePartDelimiter = _.stoken(":"); g.whiteSpace = _.rtoken(/^\s*/); g.generalDelimiter = _.rtoken(/^(([\s\,]|at|@|on)+)/); var _C = {}; g.ctoken = function (keys) { var fn = _C[keys]; if (! fn) { var c = Date.CultureInfo.regexPatterns; var kx = keys.split(/\s+/), px = []; for (var i = 0; i < kx.length ; i++) { px.push(_.replace(_.rtoken(c[kx[i]]), kx[i])); } fn = _C[keys] = _.any.apply(null, px); } return fn; }; g.ctoken2 = function (key) { return _.rtoken(Date.CultureInfo.regexPatterns[key]); }; var cacheProcessRtoken = function (key, token, type, eachToken) { if (eachToken) { g[key] = _.cache(_.process(_.each(_.rtoken(token),_.optional(g.ctoken2(eachToken))), type)); } else { g[key] = _.cache(_.process(_.rtoken(token), type)); } }; var cacheProcessCtoken = function (token, type) { return _.cache(_.process(g.ctoken2(token), type)); }; var _F = {}; //function cache var _get = function (f) { _F[f] = (_F[f] || g.format(f)[0]); return _F[f]; }; g.allformats = function (fx) { var rx = []; if (fx instanceof Array) { for (var i = 0; i < fx.length; i++) { rx.push(_get(fx[i])); } } else { rx.push(_get(fx)); } return rx; }; g.formats = function (fx) { if (fx instanceof Array) { var rx = []; for (var i = 0 ; i < fx.length ; i++) { rx.push(_get(fx[i])); } return _.any.apply(null, rx); } else { return _get(fx); } }; var grammarFormats = { timeFormats: function(){ var i, RTokenKeys = [ "h", "hh", "H", "HH", "m", "mm", "s", "ss", "ss.s", "z", "zz" ], RToken = [ /^(0[0-9]|1[0-2]|[1-9])/, /^(0[0-9]|1[0-2])/, /^([0-1][0-9]|2[0-3]|[0-9])/, /^([0-1][0-9]|2[0-3])/, /^([0-5][0-9]|[0-9])/, /^[0-5][0-9]/, /^([0-5][0-9]|[0-9])/, /^[0-5][0-9]/, /^[0-5][0-9]\.[0-9]{1,3}/, /^((\+|\-)\s*\d\d\d\d)|((\+|\-)\d\d\:?\d\d)/, /^((\+|\-)\s*\d\d\d\d)|((\+|\-)\d\d\:?\d\d)/ ], tokens = [ t.hour, t.hour, t.hour, t.hour, t.minute, t.minute, t.second, t.second, t.secondAndMillisecond, t.timezone, t.timezone ]; for (i=0; i < RTokenKeys.length; i++) { cacheProcessRtoken(RTokenKeys[i], RToken[i], tokens[i]); } g.hms = _.cache(_.sequence([g.H, g.m, g.s], g.timePartDelimiter)); g.t = cacheProcessCtoken("shortMeridian", t.meridian); g.tt = cacheProcessCtoken("longMeridian", t.meridian); g.zzz = cacheProcessCtoken("timezone", t.timezone); g.timeSuffix = _.each(_.ignore(g.whiteSpace), _.set([ g.tt, g.zzz ])); g.time = _.each(_.optional(_.ignore(_.stoken("T"))), g.hms, g.timeSuffix); }, dateFormats: function () { // pre-loaded rules for different date part order preferences var _setfn = function () { return _.set(arguments, g.datePartDelimiter); }; var i, RTokenKeys = [ "d", "dd", "M", "MM", "y", "yy", "yyy", "yyyy" ], RToken = [ /^([0-2]\d|3[0-1]|\d)/, /^([0-2]\d|3[0-1])/, /^(1[0-2]|0\d|\d)/, /^(1[0-2]|0\d)/, /^(\d+)/, /^(\d\d)/, /^(\d\d?\d?\d?)/, /^(\d\d\d\d)/ ], tokens = [ t.day, t.day, t.month, t.month, t.year, t.year, t.year, t.year ], eachToken = [ "ordinalSuffix", "ordinalSuffix" ]; for (i=0; i < RTokenKeys.length; i++) { cacheProcessRtoken(RTokenKeys[i], RToken[i], tokens[i], eachToken[i]); } g.MMM = g.MMMM = _.cache(_.process(g.ctoken("jan feb mar apr may jun jul aug sep oct nov dec"), t.month)); g.ddd = g.dddd = _.cache(_.process(g.ctoken("sun mon tue wed thu fri sat"), function (s) { return function () { this.weekday = s; }; } )); g.day = _fn(g.d, g.dd); g.month = _fn(g.M, g.MMM); g.year = _fn(g.yyyy, g.yy); g.mdy = _setfn(g.ddd, g.month, g.day, g.year); g.ymd = _setfn(g.ddd, g.year, g.month, g.day); g.dmy = _setfn(g.ddd, g.day, g.month, g.year); g.date = function (s) { return ((g[Date.CultureInfo.dateElementOrder] || g.mdy).call(this, s)); }; }, relative: function () { // relative date / time expressions g.orientation = _.process(g.ctoken("past future"), function (s) { return function () { this.orient = s; }; } ); g.operator = _.process(g.ctoken("add subtract"), function (s) { return function () { this.operator = s; }; } ); g.rday = _.process(g.ctoken("yesterday tomorrow today now"), t.rday); g.unit = _.process(g.ctoken("second minute hour day week month year"), function (s) { return function () { this.unit = s; }; } ); } }; g.buildGrammarFormats = function () { // these need to be rebuilt every time the language changes. _C = {}; grammarFormats.timeFormats(); grammarFormats.dateFormats(); grammarFormats.relative(); g.value = _.process(_.rtoken(/^([-+]?\d+)?(st|nd|rd|th)?/), function (s) { return function () { this.value = s.replace(/\D/g, ""); }; } ); g.expression = _.set([g.rday, g.operator, g.value, g.unit, g.orientation, g.ddd, g.MMM ]); g.format = _.process(_.many( _.any( // translate format specifiers into grammar rules _.process( _.rtoken(/^(dd?d?d?(?!e)|MM?M?M?|yy?y?y?|hh?|HH?|mm?|ss?|tt?|zz?z?)/), function (fmt) { if (g[fmt]) { return g[fmt]; } else { throw $D.Parsing.Exception(fmt); } } ), // translate separator tokens into token rules _.process(_.rtoken(/^[^dMyhHmstz]+/), // all legal separators function (s) { return _.ignore(_.stoken(s)); } ) ) ), // construct the parser ... function (rules) { return _.process(_.each.apply(null, rules), t.finishExact); } ); // starting rule for general purpose grammar g._start = _.process(_.set([ g.date, g.time, g.expression ], g.generalDelimiter, g.whiteSpace), t.finish); }; g.buildGrammarFormats(); // parsing date format specifiers - ex: "h:m:s tt" // this little guy will generate a custom parser based // on the format string, ex: g.format("h:m:s tt") // check for these formats first g._formats = g.formats([ "\"yyyy-MM-ddTHH:mm:ssZ\"", "yyyy-MM-ddTHH:mm:ss.sz", "yyyy-MM-ddTHH:mm:ssZ", "yyyy-MM-ddTHH:mm:ssz", "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-ddTHH:mmZ", "yyyy-MM-ddTHH:mmz", "yyyy-MM-ddTHH:mm", "ddd, MMM dd, yyyy H:mm:ss tt", "ddd MMM d yyyy HH:mm:ss zzz", "MMddyyyy", "ddMMyyyy", "Mddyyyy", "ddMyyyy", "Mdyyyy", "dMyyyy", "yyyy", "Mdyy", "dMyy", "d" ]); // real starting rule: tries selected formats first, // then general purpose rule g.start = function (s) { try { var r = g._formats.call({}, s); if (r[1].length === 0) { return r; } } catch (e) {} return g._start.call({}, s); }; }()); (function () { var $D = Date; /** * @desc Converts the specified string value into its JavaScript Date equivalent using CultureInfo specific format information. * * Example

	///////////
	// Dates //
	///////////

	// 15-Oct-2004
	var d1 = Date.parse("10/15/2004");

	// 15-Oct-2004
	var d1 = Date.parse("15-Oct-2004");

	// 15-Oct-2004
	var d1 = Date.parse("2004.10.15");

	//Fri Oct 15, 2004
	var d1 = Date.parse("Fri Oct 15, 2004");

	///////////
	// Times //
	///////////

	// Today at 10 PM.
	var d1 = Date.parse("10 PM");

	// Today at 10:30 PM.
	var d1 = Date.parse("10:30 P.M.");

	// Today at 6 AM.
	var d1 = Date.parse("06am");

	/////////////////////
	// Dates and Times //
	/////////////////////

	// 8-July-2004 @ 10:30 PM
	var d1 = Date.parse("July 8th, 2004, 10:30 PM");

	// 1-July-2004 @ 10:30 PM
	var d1 = Date.parse("2004-07-01T22:30:00");

	////////////////////
	// Relative Dates //
	////////////////////

	// Returns today's date. The string "today" is culture specific.
	var d1 = Date.parse("today");

	// Returns yesterday's date. The string "yesterday" is culture specific.
	var d1 = Date.parse("yesterday");

	// Returns the date of the next thursday.
	var d1 = Date.parse("Next thursday");

	// Returns the date of the most previous monday.
	var d1 = Date.parse("last monday");

	// Returns today's day + one year.
	var d1 = Date.parse("next year");

	///////////////
	// Date Math //
	///////////////

	// Today + 2 days
	var d1 = Date.parse("t+2");

	// Today + 2 days
	var d1 = Date.parse("today + 2 days");

	// Today + 3 months
	var d1 = Date.parse("t+3m");

	// Today - 1 year
	var d1 = Date.parse("today - 1 year");

	// Today - 1 year
	var d1 = Date.parse("t-1y"); 


	/////////////////////////////
	// Partial Dates and Times //
	/////////////////////////////

	// July 15th of this year.
	var d1 = Date.parse("July 15");

	// 15th day of current day and year.
	var d1 = Date.parse("15");

	// July 1st of current year at 10pm.
	var d1 = Date.parse("7/1 10pm");
	
* * @param {String} The string value to convert into a Date object [Required] * @return {Date} A Date object or null if the string cannot be converted into a Date. */ var parseUtils = { removeOrds: function (s) { ords = s.match(/\b(\d+)(?:st|nd|rd|th)\b/); // find ordinal matches s = ((ords && ords.length === 2) ? s.replace(ords[0], ords[1]) : s); return s; }, grammarParser: function (s) { var r = null; try { r = $D.Grammar.start.call({}, s.replace(/^\s*(\S*(\s+\S+)*)\s*$/, "$1")); } catch (e) { return null; } return ((r[1].length === 0) ? r[0] : null); }, nativeFallback: function(s) { var t; try { // ok we haven't parsed it, last ditch attempt with the built-in parser. t = Date._parse(s); return (t || t === 0) ? new Date(t) : null; } catch (e) { return null; } } }; function parse (s) { var d; if (!s) { return null; } if (s instanceof Date) { return s.clone(); } if (s.length >= 4 && s.charAt(0) !== "0" && s.charAt(0) !== "+"&& s.charAt(0) !== "-") { // ie: 2004 will pass, 0800 won't. // Start with specific formats d = $D.Parsing.ISO.parse(s) || $D.Parsing.Numeric.parse(s); } if (d instanceof Date && !isNaN(d.getTime())) { return d; } else { // find ordinal dates (1st, 3rd, 8th, etc and remove them as they cause parsing issues) s = $D.Parsing.Normalizer.parse(parseUtils.removeOrds(s)); d = parseUtils.grammarParser(s); if (d !== null) { return d; } else { return parseUtils.nativeFallback(s); } } } if (!$D._parse) { $D._parse = $D.parse; } $D.parse = parse; Date.getParseFunction = function (fx) { var fns = Date.Grammar.allformats(fx); return function (s) { var r = null; for (var i = 0; i < fns.length; i++) { try { r = fns[i].call({}, s); } catch (e) { continue; } if (r[1].length === 0) { return r[0]; } } return null; }; }; /** * Converts the specified string value into its JavaScript Date equivalent using the specified format {String} or formats {Array} and the CultureInfo specific format information. * The format of the string value must match one of the supplied formats exactly. * * Example

	// 15-Oct-2004
	var d1 = Date.parseExact("10/15/2004", "M/d/yyyy");

	// 15-Oct-2004
	var d1 = Date.parse("15-Oct-2004", "M-ddd-yyyy");

	// 15-Oct-2004
	var d1 = Date.parse("2004.10.15", "yyyy.MM.dd");

	// Multiple formats
	var d1 = Date.parseExact("10/15/2004", ["M/d/yyyy", "MMMM d, yyyy"]);
	
* * @param {String} The string value to convert into a Date object [Required]. * @param {Object} The expected format {String} or an array of expected formats {Array} of the date string [Required]. * @return {Date} A Date object or null if the string cannot be converted into a Date. */ $D.parseExact = function (s, fx) { return $D.getParseFunction(fx)(s); }; }()); (function () { var $D = Date, $P = $D.prototype, // $C = $D.CultureInfo, // not used atm p = function (s, l) { if (!l) { l = 2; } return ("000" + s).slice(l * -1); }; /** * Converts a PHP format string to Java/.NET format string. * A PHP format string can be used with ._format or .format. * A Java/.NET format string can be used with .toString(). * The .parseExact function will only accept a Java/.NET format string * * Example * var f1 = "%m/%d/%y" * var f2 = Date.normalizeFormat(f1); // "MM/dd/yy" * * new Date().format(f1); // "04/13/08" * new Date()._format(f1); // "04/13/08" * new Date().toString(f2); // "04/13/08" * * var date = Date.parseExact("04/13/08", f2); // Sun Apr 13 2008 * * @param {String} A PHP format string consisting of one or more format spcifiers. * @return {String} The PHP format converted to a Java/.NET format string. */ var normalizerSubstitutions = { "d" : "dd", "%d": "dd", "D" : "ddd", "%a": "ddd", "j" : "dddd", "l" : "dddd", "%A": "dddd", "S" : "S", "F" : "MMMM", "%B": "MMMM", "m" : "MM", "%m": "MM", "M" : "MMM", "%b": "MMM", "%h": "MMM", "n" : "M", "Y" : "yyyy", "%Y": "yyyy", "y" : "yy", "%y": "yy", "g" : "h", "%I": "h", "G" : "H", "h" : "hh", "H" : "HH", "%H": "HH", "i" : "mm", "%M": "mm", "s" : "ss", "%S": "ss", "%r": "hh:mm tt", "%R": "H:mm", "%T": "H:mm:ss", "%X": "t", "%x": "d", "%e": "d", "%D": "MM/dd/yy", "%n": "\\n", "%t": "\\t", "e" : "z", "T" : "z", "%z": "z", "%Z": "z", "Z" : "ZZ", "N" : "u", "w" : "u", "%w": "u", "W" : "W", "%V": "W" }; var normalizer = { substitutes: function (m) { return normalizerSubstitutions[m]; }, interpreted: function (m, x) { var y; switch (m) { case "%u": return x.getDay() + 1; case "z": return x.getOrdinalNumber(); case "%j": return p(x.getOrdinalNumber(), 3); case "%U": var d1 = x.clone().set({month: 0, day: 1}).addDays(-1).moveToDayOfWeek(0), d2 = x.clone().addDays(1).moveToDayOfWeek(0, -1); return (d2 < d1) ? "00" : p((d2.getOrdinalNumber() - d1.getOrdinalNumber()) / 7 + 1); case "%W": return p(x.getWeek()); case "t": return $D.getDaysInMonth(x.getFullYear(), x.getMonth()); case "o": case "%G": return x.setWeek(x.getISOWeek()).toString("yyyy"); case "%g": return x._format("%G").slice(-2); case "a": case "%p": return t("tt").toLowerCase(); case "A": return t("tt").toUpperCase(); case "u": return p(x.getMilliseconds(), 3); case "I": return (x.isDaylightSavingTime()) ? 1 : 0; case "O": return x.getUTCOffset(); case "P": y = x.getUTCOffset(); return y.substring(0, y.length - 2) + ":" + y.substring(y.length - 2); case "B": var now = new Date(); return Math.floor(((now.getHours() * 3600) + (now.getMinutes() * 60) + now.getSeconds() + (now.getTimezoneOffset() + 60) * 60) / 86.4); case "c": return x.toISOString().replace(/\"/g, ""); case "U": return $D.strtotime("now"); case "%c": return t("d") + " " + t("t"); case "%C": return Math.floor(x.getFullYear() / 100 + 1); } }, shouldOverrideDefaults: function (m) { switch (m) { case "%e": return true; default: return false; } }, parse: function (m, context) { var formatString, c = context || new Date(); formatString = normalizer.substitutes(m); if (formatString) { return formatString; } formatString = normalizer.interpreted(m, c); if (formatString) { return formatString; } else { return m; } } }; $D.normalizeFormat = function (format, context) { return format.replace(/(%|\\)?.|%%/g, function(t){ return normalizer.parse(t, context); }); }; /** * Format a local Unix timestamp according to locale settings * * Example: * Date.strftime("%m/%d/%y", new Date()); // "04/13/08" * Date.strftime("c", "2008-04-13T17:52:03Z"); // "04/13/08" * * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @param {Number|String} The number representing the number of seconds that have elapsed since January 1, 1970 (local time). * @return {String} A string representation of the current Date object. */ $D.strftime = function (format, time) { var d = Date.parse(time); return d._format(format); }; /** * Parse any textual datetime description into a Unix timestamp. * A Unix timestamp is the number of seconds that have elapsed since January 1, 1970 (midnight UTC/GMT). * * Example: * Date.strtotime("04/13/08"); // 1208044800 * Date.strtotime("1970-01-01T00:00:00Z"); // 0 * * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @param {Object} A string or date object. * @return {String} A string representation of the current Date object. */ $D.strtotime = function (time) { var d = $D.parse(time); return Math.round($D.UTC(d.getUTCFullYear(), d.getUTCMonth(), d.getUTCDate(), d.getUTCHours(), d.getUTCMinutes(), d.getUTCSeconds(), d.getUTCMilliseconds()) / 1000); }; /** * Converts the value of the current Date object to its equivalent string representation using a PHP/Unix style of date format specifiers. * Format Specifiers * Format Description Example * ------ --------------------------------------------------------------------------- ----------------------- * %a abbreviated weekday name according to the current localed "Mon" through "Sun" * %A full weekday name according to the current localed "Sunday" through "Saturday" * %b abbreviated month name according to the current localed "Jan" through "Dec" * %B full month name according to the current locale "January" through "December" * %c preferred date and time representation for the current locale "4/13/2008 12:33 PM" * %C century number (the year divided by 100 and truncated to an integer) "00" to "99" * %d day of the month as a decimal number "01" to "31" * %D same as %m/%d/%y "04/13/08" * %e day of the month as a decimal number, a single digit is preceded by a space "1" to "31" * %g like %G, but without the century "08" * %G The 4-digit year corresponding to the ISO week number (see %V). "2008" * This has the same format and value as %Y, except that if the ISO week number * belongs to the previous or next year, that year is used instead. * %h same as %b "Jan" through "Dec" * %H hour as a decimal number using a 24-hour clock. "00" to "23" * %I hour as a decimal number using a 12-hour clock. "01" to "12" * %j day of the year as a decimal number. "001" to "366" * %m month as a decimal number. "01" to "12" * %M minute as a decimal number. "00" to "59" * %n newline character "\n" * %p either "am" or "pm" according to the given time value, or the "am" or "pm" * corresponding strings for the current locale. * %r time in a.m. and p.m. notation "8:44 PM" * %R time in 24 hour notation "20:44" * %S second as a decimal number "00" to "59" * %t tab character "\t" * %T current time, equal to %H:%M:%S "12:49:11" * %u weekday as a decimal number ["1", "7"], with "1" representing Monday "1" to "7" * %U week number of the current year as a decimal number, starting with the "0" to ("52" or "53") * first Sunday as the first day of the first week * %V The ISO 8601:1988 week number of the current year as a decimal number, "00" to ("52" or "53") * range 01 to 53, where week 1 is the first week that has at least 4 days * in the current year, and with Monday as the first day of the week. * (Use %G or %g for the year component that corresponds to the week number * for the specified timestamp.) * %W week number of the current year as a decimal number, starting with the "00" to ("52" or "53") * first Monday as the first day of the first week * %w day of the week as a decimal, Sunday being "0" "0" to "6" * %x preferred date representation for the current locale without the time "4/13/2008" * %X preferred time representation for the current locale without the date "12:53:05" * %y year as a decimal number without a century "00" "99" * %Y year as a decimal number including the century "2008" * %Z time zone or name or abbreviation "UTC", "EST", "PST" * %z same as %Z * %% a literal "%" characters "%" * d Day of the month, 2 digits with leading zeros "01" to "31" * D A textual representation of a day, three letters "Mon" through "Sun" * j Day of the month without leading zeros "1" to "31" * l A full textual representation of the day of the week (lowercase "L") "Sunday" through "Saturday" * N ISO-8601 numeric representation of the day of the week (added in PHP 5.1.0) "1" (for Monday) through "7" (for Sunday) * S English ordinal suffix for the day of the month, 2 characters "st", "nd", "rd" or "th". Works well with j * w Numeric representation of the day of the week "0" (for Sunday) through "6" (for Saturday) * z The day of the year (starting from "0") "0" through "365" * W ISO-8601 week number of year, weeks starting on Monday "00" to ("52" or "53") * F A full textual representation of a month, such as January or March "January" through "December" * m Numeric representation of a month, with leading zeros "01" through "12" * M A short textual representation of a month, three letters "Jan" through "Dec" * n Numeric representation of a month, without leading zeros "1" through "12" * t Number of days in the given month "28" through "31" * L Whether it's a leap year "1" if it is a leap year, "0" otherwise * o ISO-8601 year number. This has the same value as Y, except that if the "2008" * ISO week number (W) belongs to the previous or next year, that year * is used instead. * Y A full numeric representation of a year, 4 digits "2008" * y A two digit representation of a year "08" * a Lowercase Ante meridiem and Post meridiem "am" or "pm" * A Uppercase Ante meridiem and Post meridiem "AM" or "PM" * B Swatch Internet time "000" through "999" * g 12-hour format of an hour without leading zeros "1" through "12" * G 24-hour format of an hour without leading zeros "0" through "23" * h 12-hour format of an hour with leading zeros "01" through "12" * H 24-hour format of an hour with leading zeros "00" through "23" * i Minutes with leading zeros "00" to "59" * s Seconds, with leading zeros "00" through "59" * u Milliseconds "54321" * e Timezone identifier "UTC", "EST", "PST" * I Whether or not the date is in daylight saving time (uppercase i) "1" if Daylight Saving Time, "0" otherwise * O Difference to Greenwich time (GMT) in hours "+0200", "-0600" * P Difference to Greenwich time (GMT) with colon between hours and minutes "+02:00", "-06:00" * T Timezone abbreviation "UTC", "EST", "PST" * Z Timezone offset in seconds. The offset for timezones west of UTC is "-43200" through "50400" * always negative, and for those east of UTC is always positive. * c ISO 8601 date "2004-02-12T15:19:21+00:00" * r RFC 2822 formatted date "Thu, 21 Dec 2000 16:01:07 +0200" * U Seconds since the Unix Epoch (January 1 1970 00:00:00 GMT) "0" * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @return {String} A string representation of the current Date object. */ var formatReplace = function (context) { return function (m) { var formatString, override = false; if (m.charAt(0) === "\\" || m.substring(0, 2) === "%%") { return m.replace("\\", "").replace("%%", "%"); } override = normalizer.shouldOverrideDefaults(m); formatString = $D.normalizeFormat(m, context); if (formatString) { return context.toString(formatString, override); } }; }; $P._format = function (format) { var formatter = formatReplace(this); if (!format) { return this._toString(); } else { return format.replace(/(%|\\)?.|%%/g, formatter); } }; if (!$P.format) { $P.format = $P._format; } }()); (function () { "use strict"; var gFn = function (attr) { return function () { return this[attr]; }; }; var sFn = function (attr) { return function (val) { this[attr] = val; return this; }; }; var attrs = ["years", "months", "days", "hours", "minutes", "seconds", "milliseconds"]; var addSetFuncs = function (context, attrs) { for (var i = 0; i < attrs.length ; i++) { var $a = attrs[i], $b = $a.slice(0, 1).toUpperCase() + $a.slice(1); context.prototype[$a] = 0; context.prototype["get" + $b] = gFn($a); context.prototype["set" + $b] = sFn($a); } }; /** * new TimeSpan(milliseconds); * new TimeSpan(days, hours, minutes, seconds); * new TimeSpan(days, hours, minutes, seconds, milliseconds); */ var TimeSpan = function (days, hours, minutes, seconds, milliseconds) { if (arguments.length === 1 && typeof days === "number") { var orient = (days < 0) ? -1 : +1; var millsLeft = Math.abs(days); this.setDays(Math.floor(millsLeft / 86400000) * orient); millsLeft = millsLeft % 86400000; this.setHours(Math.floor(millsLeft / 3600000) * orient); millsLeft = millsLeft % 3600000; this.setMinutes(Math.floor(millsLeft / 60000) * orient); millsLeft = millsLeft % 60000; this.setSeconds(Math.floor(millsLeft / 1000) * orient); millsLeft = millsLeft % 1000; this.setMilliseconds(millsLeft * orient); } else { this.set(days, hours, minutes, seconds, milliseconds); } this.getTotalMilliseconds = function () { return (this.getDays() * 86400000) + (this.getHours() * 3600000) + (this.getMinutes() * 60000) + (this.getSeconds() * 1000); }; this.compareTo = function (time) { var t1 = new Date(1970, 1, 1, this.getHours(), this.getMinutes(), this.getSeconds()), t2; if (time === null) { t2 = new Date(1970, 1, 1, 0, 0, 0); } else { t2 = new Date(1970, 1, 1, time.getHours(), time.getMinutes(), time.getSeconds()); } return (t1 < t2) ? -1 : (t1 > t2) ? 1 : 0; }; this.equals = function (time) { return (this.compareTo(time) === 0); }; this.add = function (time) { return (time === null) ? this : this.addSeconds(time.getTotalMilliseconds() / 1000); }; this.subtract = function (time) { return (time === null) ? this : this.addSeconds(-time.getTotalMilliseconds() / 1000); }; this.addDays = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 86400000)); }; this.addHours = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 3600000)); }; this.addMinutes = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 60000)); }; this.addSeconds = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 1000)); }; this.addMilliseconds = function (n) { return new TimeSpan(this.getTotalMilliseconds() + n); }; this.get12HourHour = function () { return (this.getHours() > 12) ? this.getHours() - 12 : (this.getHours() === 0) ? 12 : this.getHours(); }; this.getDesignator = function () { return (this.getHours() < 12) ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator; }; this.toString = function (format) { this._toString = function () { if (this.getDays() !== null && this.getDays() > 0) { return this.getDays() + "." + this.getHours() + ":" + this.p(this.getMinutes()) + ":" + this.p(this.getSeconds()); } else { return this.getHours() + ":" + this.p(this.getMinutes()) + ":" + this.p(this.getSeconds()); } }; this.p = function (s) { return (s.toString().length < 2) ? "0" + s : s; }; var me = this; return format ? format.replace(/dd?|HH?|hh?|mm?|ss?|tt?/g, function (format) { switch (format) { case "d": return me.getDays(); case "dd": return me.p(me.getDays()); case "H": return me.getHours(); case "HH": return me.p(me.getHours()); case "h": return me.get12HourHour(); case "hh": return me.p(me.get12HourHour()); case "m": return me.getMinutes(); case "mm": return me.p(me.getMinutes()); case "s": return me.getSeconds(); case "ss": return me.p(me.getSeconds()); case "t": return ((me.getHours() < 12) ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator).substring(0, 1); case "tt": return (me.getHours() < 12) ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator; } } ) : this._toString(); }; return this; }; addSetFuncs(TimeSpan, attrs.slice(2)); TimeSpan.prototype.set = function (days, hours, minutes, seconds, milliseconds){ this.setDays(days || this.getDays()); this.setHours(hours || this.getHours()); this.setMinutes(minutes || this.getMinutes()); this.setSeconds(seconds || this.getSeconds()); this.setMilliseconds(milliseconds || this.getMilliseconds()); }; /** * Gets the time of day for this date instances. * @return {TimeSpan} TimeSpan */ Date.prototype.getTimeOfDay = function () { return new TimeSpan(0, this.getHours(), this.getMinutes(), this.getSeconds(), this.getMilliseconds()); }; Date.TimeSpan = TimeSpan; if (typeof window !== "undefined" ) { // keeping API compatible for v1.x window.TimeSpan = TimeSpan; } }()); (function () { "use strict"; var attrs = ["years", "months", "days", "hours", "minutes", "seconds", "milliseconds"]; var gFn = function (attr) { return function () { return this[attr]; }; }; var sFn = function (attr) { return function (val) { this[attr] = val; return this; }; }; var addSetFuncs = function (context, attrs) { for (var i = 0; i < attrs.length ; i++) { var $a = attrs[i], $b = $a.slice(0, 1).toUpperCase() + $a.slice(1); context.prototype[$a] = 0; context.prototype["get" + $b] = gFn($a); context.prototype["set" + $b] = sFn($a); } }; var setMonthsAndYears = function (orient, d1, d2, context) { function inc() { d1.addMonths(-orient); context.months++; if (context.months === 12) { context.years++; context.months = 0; } } if (orient === +1) { while (d1 > d2) { inc(); } } else { while (d1 < d2) { inc(); } } context.months--; context.months *= orient; context.years *= orient; }; var adjustForDST = function(orient, startDate, endDate) { var hasDSTMismatch = (false === (startDate.isDaylightSavingTime() === endDate.isDaylightSavingTime())); if (hasDSTMismatch && orient === 1) { startDate.addHours(-1); } else if (hasDSTMismatch) { startDate.addHours(1); } }; /** * TimePeriod(startDate, endDate); * TimePeriod(years, months, days, hours, minutes, seconds, milliseconds); */ var TimePeriod = function (years, months, days, hours, minutes, seconds, milliseconds) { if (arguments.length === 7) { this.set(years, months, days, hours, minutes, seconds, milliseconds); } else if (arguments.length === 2 && arguments[0] instanceof Date && arguments[1] instanceof Date) { var startDate = arguments[0].clone(); var endDate = arguments[1].clone(); var orient = (startDate > endDate) ? +1 : -1; this.dates = { start: arguments[0].clone(), end: arguments[1].clone() }; setMonthsAndYears(orient, startDate, endDate, this); adjustForDST(orient, startDate, endDate); // // TODO - adjust for DST var diff = endDate - startDate; if (diff !== 0) { var ts = new TimeSpan(diff); this.set(this.years, this.months, ts.getDays(), ts.getHours(), ts.getMinutes(), ts.getSeconds(), ts.getMilliseconds()); } } return this; }; // create all the set functions. addSetFuncs(TimePeriod, attrs); TimePeriod.prototype.set = function (years, months, days, hours, minutes, seconds, milliseconds){ this.setYears(years || this.getYears()); this.setMonths(months || this.getMonths()); this.setDays(days || this.getDays()); this.setHours(hours || this.getHours()); this.setMinutes(minutes || this.getMinutes()); this.setSeconds(seconds || this.getSeconds()); this.setMilliseconds(milliseconds || this.getMilliseconds()); }; Date.TimePeriod = TimePeriod; if (typeof window !== "undefined") { // keeping API compatible for v1.x window.TimePeriod = TimePeriod; } }()); ================================================ FILE: build/date-es-NI.js ================================================ /** * @overview datejs * @version 1.0.0-rc3 * @author Gregory Wild-Smith * @copyright 2015 Gregory Wild-Smith * @license MIT * @homepage https://github.com/abritinthebay/datejs */ /* * DateJS Culture String File * Country Code: es-NI * Name: Spanish (Nicaragua) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["es-NI"] = { "name": "es-NI", "englishName": "Spanish (Nicaragua)", "nativeName": "Español (Nicaragua)", "Sunday": "domingo", "Monday": "lunes", "Tuesday": "martes", "Wednesday": "miércoles", "Thursday": "jueves", "Friday": "viernes", "Saturday": "sábado", "Sun": "dom", "Mon": "lun", "Tue": "mar", "Wed": "mié", "Thu": "jue", "Fri": "vie", "Sat": "sáb", "Su": "do", "Mo": "lu", "Tu": "ma", "We": "mi", "Th": "ju", "Fr": "vi", "Sa": "sá", "S_Sun_Initial": "d", "M_Mon_Initial": "l", "T_Tue_Initial": "m", "W_Wed_Initial": "m", "T_Thu_Initial": "j", "F_Fri_Initial": "v", "S_Sat_Initial": "s", "January": "enero", "February": "febrero", "March": "marzo", "April": "abril", "May": "mayo", "June": "junio", "July": "julio", "August": "agosto", "September": "septiembre", "October": "octubre", "November": "noviembre", "December": "diciembre", "Jan_Abbr": "ene", "Feb_Abbr": "feb", "Mar_Abbr": "mar", "Apr_Abbr": "abr", "May_Abbr": "may", "Jun_Abbr": "jun", "Jul_Abbr": "jul", "Aug_Abbr": "ago", "Sep_Abbr": "sep", "Oct_Abbr": "oct", "Nov_Abbr": "nov", "Dec_Abbr": "dic", "AM": "a.m.", "PM": "p.m.", "firstDayOfWeek": 0, "twoDigitYearMax": 2029, "mdy": "dmy", "M/d/yyyy": "dd/MM/yyyy", "dddd, MMMM dd, yyyy": "dddd, dd' [de] 'MMMM' [de] 'yyyy", "h:mm tt": "hh:mm tt", "h:mm:ss tt": "hh:mm:ss tt", "dddd, MMMM dd, yyyy h:mm:ss tt": "dddd, dd' [de] 'MMMM' [de] 'yyyy hh:mm:ss tt", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "dd MMMM", "MMMM, yyyy": "MMMM' [de] 'yyyy", "/jan(uary)?/": "ene(ro)?", "/feb(ruary)?/": "feb(rero)?", "/mar(ch)?/": "mar(zo)?", "/apr(il)?/": "abr(il)?", "/may/": "may(o)?", "/jun(e)?/": "jun(io)?", "/jul(y)?/": "jul(io)?", "/aug(ust)?/": "ago(sto)?", "/sep(t(ember)?)?/": "sep(tiembre)?", "/oct(ober)?/": "oct(ubre)?", "/nov(ember)?/": "nov(iembre)?", "/dec(ember)?/": "dic(iembre)?", "/^su(n(day)?)?/": "^do(m(ingo)?)?", "/^mo(n(day)?)?/": "^lu(n(es)?)?", "/^tu(e(s(day)?)?)?/": "^ma(r(tes)?)?", "/^we(d(nesday)?)?/": "^mi(é(rcoles)?)?", "/^th(u(r(s(day)?)?)?)?/": "^ju(e(ves)?)?", "/^fr(i(day)?)?/": "^vi(e(rnes)?)?", "/^sa(t(urday)?)?/": "^sá(b(ado)?)?", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "es-NI"; /** * @overview datejs * @version 1.0.0-rc3 * @author Gregory Wild-Smith * @copyright 2015 Gregory Wild-Smith * @license MIT * @homepage https://github.com/abritinthebay/datejs */(function () { var $D = Date; var lang = Date.CultureStrings ? Date.CultureStrings.lang : null; var loggedKeys = {}; // for debug purposes. var getText = { getFromKey: function (key, countryCode) { var output; if (Date.CultureStrings && Date.CultureStrings[countryCode] && Date.CultureStrings[countryCode][key]) { output = Date.CultureStrings[countryCode][key]; } else { output = getText.buildFromDefault(key); } if (key.charAt(0) === "/") { // Assume it's a regex output = getText.buildFromRegex(key, countryCode); } return output; }, getFromObjectValues: function (obj, countryCode) { var key, output = {}; for(key in obj) { if (obj.hasOwnProperty(key)) { output[key] = getText.getFromKey(obj[key], countryCode); } } return output; }, getFromObjectKeys: function (obj, countryCode) { var key, output = {}; for(key in obj) { if (obj.hasOwnProperty(key)) { output[getText.getFromKey(key, countryCode)] = obj[key]; } } return output; }, getFromArray: function (arr, countryCode) { var output = []; for (var i=0; i < arr.length; i++){ if (i in arr) { output[i] = getText.getFromKey(arr[i], countryCode); } } return output; }, buildFromDefault: function (key) { var output, length, split, last; switch(key) { case "name": output = "en-US"; break; case "englishName": output = "English (United States)"; break; case "nativeName": output = "English (United States)"; break; case "twoDigitYearMax": output = 2049; break; case "firstDayOfWeek": output = 0; break; default: output = key; split = key.split("_"); length = split.length; if (length > 1 && key.charAt(0) !== "/") { // if the key isn't a regex and it has a split. last = split[(length - 1)].toLowerCase(); if (last === "initial" || last === "abbr") { output = split[0]; } } break; } return output; }, buildFromRegex: function (key, countryCode) { var output; if (Date.CultureStrings && Date.CultureStrings[countryCode] && Date.CultureStrings[countryCode][key]) { output = new RegExp(Date.CultureStrings[countryCode][key], "i"); } else { output = new RegExp(key.replace(new RegExp("/", "g"),""), "i"); } return output; } }; var shallowMerge = function (obj1, obj2) { for (var attrname in obj2) { if (obj2.hasOwnProperty(attrname)) { obj1[attrname] = obj2[attrname]; } } }; var __ = function (key, language) { var countryCode = (language) ? language : lang; loggedKeys[key] = key; if (typeof key === "object") { if (key instanceof Array) { return getText.getFromArray(key, countryCode); } else { return getText.getFromObjectKeys(key, countryCode); } } else { return getText.getFromKey(key, countryCode); } }; var loadI18nScript = function (code) { // paatterned after jQuery's getScript. var url = Date.Config.i18n + code + ".js"; var head = document.getElementsByTagName("head")[0] || document.documentElement; var script = document.createElement("script"); script.src = url; var completed = false; var events = { done: function (){} // placeholder function }; // Attach handlers for all browsers script.onload = script.onreadystatechange = function() { if ( !completed && (!this.readyState || this.readyState === "loaded" || this.readyState === "complete") ) { events.done(); head.removeChild(script); } }; setTimeout(function() { head.insertBefore(script, head.firstChild); }, 0); // allows return to execute first return { done: function (cb) { events.done = function() { if (cb) { setTimeout(cb,0); } }; } }; }; var buildInfo = { buildFromMethodHash: function (obj) { var key; for(key in obj) { if (obj.hasOwnProperty(key)) { obj[key] = buildInfo[obj[key]](); } } return obj; }, timeZoneDST: function () { var DST = { "CHADT": "+1345", "NZDT": "+1300", "AEDT": "+1100", "ACDT": "+1030", "AZST": "+0500", "IRDT": "+0430", "EEST": "+0300", "CEST": "+0200", "BST": "+0100", "PMDT": "-0200", "ADT": "-0300", "NDT": "-0230", "EDT": "-0400", "CDT": "-0500", "MDT": "-0600", "PDT": "-0700", "AKDT": "-0800", "HADT": "-0900" }; return __(DST); }, timeZoneStandard: function () { var standard = { "LINT": "+1400", "TOT": "+1300", "CHAST": "+1245", "NZST": "+1200", "NFT": "+1130", "SBT": "+1100", "AEST": "+1000", "ACST": "+0930", "JST": "+0900", "CWST": "+0845", "CT": "+0800", "ICT": "+0700", "MMT": "+0630", "BST": "+0600", "NPT": "+0545", "IST": "+0530", "PKT": "+0500", "AFT": "+0430", "MSK": "+0400", "IRST": "+0330", "FET": "+0300", "EET": "+0200", "CET": "+0100", "GMT": "+0000", "UTC": "+0000", "CVT": "-0100", "GST": "-0200", "BRT": "-0300", "NST": "-0330", "AST": "-0400", "EST": "-0500", "CST": "-0600", "MST": "-0700", "PST": "-0800", "AKST": "-0900", "MIT": "-0930", "HST": "-1000", "SST": "-1100", "BIT": "-1200" }; return __(standard); }, timeZones: function (data) { var zone; data.timezones = []; for (zone in data.abbreviatedTimeZoneStandard) { if (data.abbreviatedTimeZoneStandard.hasOwnProperty(zone)) { data.timezones.push({ name: zone, offset: data.abbreviatedTimeZoneStandard[zone]}); } } for (zone in data.abbreviatedTimeZoneDST) { if (data.abbreviatedTimeZoneDST.hasOwnProperty(zone)) { data.timezones.push({ name: zone, offset: data.abbreviatedTimeZoneDST[zone], dst: true}); } } return data.timezones; }, days: function () { return __(["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"]); }, dayAbbr: function () { return __(["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"]); }, dayShortNames: function () { return __(["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"]); }, dayFirstLetters: function () { return __(["S_Sun_Initial", "M_Mon_Initial", "T_Tues_Initial", "W_Wed_Initial", "T_Thu_Initial", "F_Fri_Initial", "S_Sat_Initial"]); }, months: function () { return __(["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"]); }, monthAbbr: function () { return __(["Jan_Abbr", "Feb_Abbr", "Mar_Abbr", "Apr_Abbr", "May_Abbr", "Jun_Abbr", "Jul_Abbr", "Aug_Abbr", "Sep_Abbr", "Oct_Abbr", "Nov_Abbr", "Dec_Abbr"]); }, formatPatterns: function () { return getText.getFromObjectValues({ shortDate: "M/d/yyyy", longDate: "dddd, MMMM dd, yyyy", shortTime: "h:mm tt", longTime: "h:mm:ss tt", fullDateTime: "dddd, MMMM dd, yyyy h:mm:ss tt", sortableDateTime: "yyyy-MM-ddTHH:mm:ss", universalSortableDateTime: "yyyy-MM-dd HH:mm:ssZ", rfc1123: "ddd, dd MMM yyyy HH:mm:ss", monthDay: "MMMM dd", yearMonth: "MMMM, yyyy" }, Date.i18n.currentLanguage()); }, regex: function () { return getText.getFromObjectValues({ inTheMorning: "/( in the )(morn(ing)?)\\b/", thisMorning: "/(this )(morn(ing)?)\\b/", amThisMorning: "/(\b\\d(am)? )(this )(morn(ing)?)/", inTheEvening: "/( in the )(even(ing)?)\\b/", thisEvening: "/(this )(even(ing)?)\\b/", pmThisEvening: "/(\b\\d(pm)? )(this )(even(ing)?)/", jan: "/jan(uary)?/", feb: "/feb(ruary)?/", mar: "/mar(ch)?/", apr: "/apr(il)?/", may: "/may/", jun: "/jun(e)?/", jul: "/jul(y)?/", aug: "/aug(ust)?/", sep: "/sep(t(ember)?)?/", oct: "/oct(ober)?/", nov: "/nov(ember)?/", dec: "/dec(ember)?/", sun: "/^su(n(day)?)?/", mon: "/^mo(n(day)?)?/", tue: "/^tu(e(s(day)?)?)?/", wed: "/^we(d(nesday)?)?/", thu: "/^th(u(r(s(day)?)?)?)?/", fri: "/fr(i(day)?)?/", sat: "/^sa(t(urday)?)?/", future: "/^next/", past: "/^last|past|prev(ious)?/", add: "/^(\\+|aft(er)?|from|hence)/", subtract: "/^(\\-|bef(ore)?|ago)/", yesterday: "/^yes(terday)?/", today: "/^t(od(ay)?)?/", tomorrow: "/^tom(orrow)?/", now: "/^n(ow)?/", millisecond: "/^ms|milli(second)?s?/", second: "/^sec(ond)?s?/", minute: "/^mn|min(ute)?s?/", hour: "/^h(our)?s?/", week: "/^w(eek)?s?/", month: "/^m(onth)?s?/", day: "/^d(ay)?s?/", year: "/^y(ear)?s?/", shortMeridian: "/^(a|p)/", longMeridian: "/^(a\\.?m?\\.?|p\\.?m?\\.?)/", timezone: "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/", ordinalSuffix: "/^\\s*(st|nd|rd|th)/", timeContext: "/^\\s*(\\:|a(?!u|p)|p)/" }, Date.i18n.currentLanguage()); } }; var CultureInfo = function () { var info = getText.getFromObjectValues({ name: "name", englishName: "englishName", nativeName: "nativeName", amDesignator: "AM", pmDesignator: "PM", firstDayOfWeek: "firstDayOfWeek", twoDigitYearMax: "twoDigitYearMax", dateElementOrder: "mdy" }, Date.i18n.currentLanguage()); var constructedInfo = buildInfo.buildFromMethodHash({ dayNames: "days", abbreviatedDayNames: "dayAbbr", shortestDayNames: "dayShortNames", firstLetterDayNames: "dayFirstLetters", monthNames: "months", abbreviatedMonthNames: "monthAbbr", formatPatterns: "formatPatterns", regexPatterns: "regex", abbreviatedTimeZoneDST: "timeZoneDST", abbreviatedTimeZoneStandard: "timeZoneStandard" }); shallowMerge(info, constructedInfo); buildInfo.timeZones(info); return info; }; $D.i18n = { __: function (key, lang) { return __(key, lang); }, currentLanguage: function () { return lang || "en-US"; }, setLanguage: function (code, force, cb) { var async = false; if (force || code === "en-US" || (!!Date.CultureStrings && !!Date.CultureStrings[code])) { lang = code; Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings.lang = code; Date.CultureInfo = new CultureInfo(); } else { if (!(!!Date.CultureStrings && !!Date.CultureStrings[code])) { if (typeof exports !== "undefined" && this.exports !== exports) { // we're in a Node enviroment, load it using require try { require("../i18n/" + code + ".js"); lang = code; Date.CultureStrings.lang = code; Date.CultureInfo = new CultureInfo(); } catch (e) { // var str = "The language for '" + code + "' could not be loaded by Node. It likely does not exist."; throw new Error("The DateJS IETF language tag '" + code + "' could not be loaded by Node. It likely does not exist."); } } else if (Date.Config && Date.Config.i18n) { // we know the location of the files, so lets load them async = true; loadI18nScript(code).done(function(){ lang = code; Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings.lang = code; Date.CultureInfo = new CultureInfo(); $D.Parsing.Normalizer.buildReplaceData(); // because this is async if ($D.Grammar) { $D.Grammar.buildGrammarFormats(); // so we can parse those strings... } if (cb) { setTimeout(cb,0); } }); } else { Date.console.error("The DateJS IETF language tag '" + code + "' is not available and has not been loaded."); return false; } } } $D.Parsing.Normalizer.buildReplaceData(); // rebuild normalizer strings if ($D.Grammar) { $D.Grammar.buildGrammarFormats(); // so we can parse those strings... } if (!async && cb) { setTimeout(cb,0); } }, getLoggedKeys: function () { return loggedKeys; }, updateCultureInfo: function () { Date.CultureInfo = new CultureInfo(); } }; $D.i18n.updateCultureInfo(); // run automatically }()); (function () { var $D = Date, $P = $D.prototype, p = function (s, l) { if (!l) { l = 2; } return ("000" + s).slice(l * -1); }; if (typeof window !== "undefined" && typeof window.console !== "undefined" && typeof window.console.log !== "undefined") { $D.console = console; // used only to raise non-critical errors if available } else { // set mock so we don't give errors. $D.console = { log: function(){}, error: function(){} }; } $D.Config = $D.Config || {}; $D.initOverloads = function() { /** * Overload of Date.now. Allows an alternate call for Date.now where it returns the * current Date as an object rather than just milliseconds since the Unix Epoch. * * Also provides an implementation of now() for browsers (IE<9) that don't have it. * * Backwards compatible so with work with either: * Date.now() [returns ms] * or * Date.now(true) [returns Date] */ if (!$D.now) { $D._now = function now() { return new Date().getTime(); }; } else if (!$D._now) { $D._now = $D.now; } $D.now = function (returnObj) { if (returnObj) { return $D.present(); } else { return $D._now(); } }; if ( !$P.toISOString ) { $P.toISOString = function() { return this.getUTCFullYear() + "-" + p(this.getUTCMonth() + 1) + "-" + p(this.getUTCDate()) + "T" + p(this.getUTCHours()) + ":" + p(this.getUTCMinutes()) + ":" + p(this.getUTCSeconds()) + "." + String( (this.getUTCMilliseconds()/1000).toFixed(3)).slice(2, 5) + "Z"; }; } // private if ( $P._toString === undefined ){ $P._toString = $P.toString; } }; $D.initOverloads(); /** * Gets a date that is set to the current date. The time is set to the start of the day (00:00 or 12:00 AM). * @return {Date} The current date. */ $D.today = function () { return new Date().clearTime(); }; /** * Gets a date that is set to the current date and time (same as new Date, but chainable) * @return {Date} The current date. */ $D.present = function () { return new Date(); }; /** * Compares the first date to the second date and returns an number indication of their relative values. * @param {Date} First Date object to compare [Required]. * @param {Date} Second Date object to compare to [Required]. * @return {Number} -1 = date1 is lessthan date2. 0 = values are equal. 1 = date1 is greaterthan date2. */ $D.compare = function (date1, date2) { if (isNaN(date1) || isNaN(date2)) { throw new Error(date1 + " - " + date2); } else if (date1 instanceof Date && date2 instanceof Date) { return (date1 < date2) ? -1 : (date1 > date2) ? 1 : 0; } else { throw new TypeError(date1 + " - " + date2); } }; /** * Compares the first Date object to the second Date object and returns true if they are equal. * @param {Date} First Date object to compare [Required] * @param {Date} Second Date object to compare to [Required] * @return {Boolean} true if dates are equal. false if they are not equal. */ $D.equals = function (date1, date2) { return (date1.compareTo(date2) === 0); }; /** * Gets the language appropriate day name when given the day number(0-6) * eg - 0 == Sunday * @return {String} The day name */ $D.getDayName = function (n) { return Date.CultureInfo.dayNames[n]; }; /** * Gets the day number (0-6) if given a CultureInfo specific string which is a valid dayName, abbreviatedDayName or shortestDayName (two char). * @param {String} The name of the day (eg. "Monday, "Mon", "tuesday", "tue", "We", "we"). * @return {Number} The day number */ $D.getDayNumberFromName = function (name) { var n = Date.CultureInfo.dayNames, m = Date.CultureInfo.abbreviatedDayNames, o = Date.CultureInfo.shortestDayNames, s = name.toLowerCase(); for (var i = 0; i < n.length; i++) { if (n[i].toLowerCase() === s || m[i].toLowerCase() === s || o[i].toLowerCase() === s) { return i; } } return -1; }; /** * Gets the month number (0-11) if given a Culture Info specific string which is a valid monthName or abbreviatedMonthName. * @param {String} The name of the month (eg. "February, "Feb", "october", "oct"). * @return {Number} The day number */ $D.getMonthNumberFromName = function (name) { var n = Date.CultureInfo.monthNames, m = Date.CultureInfo.abbreviatedMonthNames, s = name.toLowerCase(); for (var i = 0; i < n.length; i++) { if (n[i].toLowerCase() === s || m[i].toLowerCase() === s) { return i; } } return -1; }; /** * Gets the language appropriate month name when given the month number(0-11) * eg - 0 == January * @return {String} The month name */ $D.getMonthName = function (n) { return Date.CultureInfo.monthNames[n]; }; /** * Determines if the current date instance is within a LeapYear. * @param {Number} The year. * @return {Boolean} true if date is within a LeapYear, otherwise false. */ $D.isLeapYear = function (year) { return ((year % 4 === 0 && year % 100 !== 0) || year % 400 === 0); }; /** * Gets the number of days in the month, given a year and month value. Automatically corrects for LeapYear. * @param {Number} The year. * @param {Number} The month (0-11). * @return {Number} The number of days in the month. */ $D.getDaysInMonth = function (year, month) { if (!month && $D.validateMonth(year)) { month = year; year = Date.today().getFullYear(); } return [31, ($D.isLeapYear(year) ? 29 : 28), 31, 30, 31, 30, 31, 31, 30, 31, 30, 31][month]; }; $P.getDaysInMonth = function () { return $D.getDaysInMonth(this.getFullYear(), this.getMonth()); }; $D.getTimezoneAbbreviation = function (offset, dst) { var p, n = (dst || false) ? Date.CultureInfo.abbreviatedTimeZoneDST : Date.CultureInfo.abbreviatedTimeZoneStandard; for (p in n) { if (n.hasOwnProperty(p)) { if (n[p] === offset) { return p; } } } return null; }; $D.getTimezoneOffset = function (name, dst) { var i, a =[], z = Date.CultureInfo.timezones; if (!name) { name = (new Date()).getTimezone();} for (i = 0; i < z.length; i++) { if (z[i].name === name.toUpperCase()) { a.push(i); } } if (!z[a[0]]) { return null; } if (a.length === 1 || !dst) { return z[a[0]].offset; } else { for (i=0; i < a.length; i++) { if (z[a[i]].dst) { return z[a[i]].offset; } } } }; $D.getQuarter = function (d) { d = d || new Date(); // If no date supplied, use today var q = [1,2,3,4]; return q[Math.floor(d.getMonth() / 3)]; // ~~~ is a bitwise op. Faster than Math.floor }; $D.getDaysLeftInQuarter = function (d) { d = d || new Date(); var qEnd = new Date(d); qEnd.setMonth(qEnd.getMonth() + 3 - qEnd.getMonth() % 3, 0); return Math.floor((qEnd - d) / 8.64e7); }; // private var validate = function (n, min, max, name) { name = name ? name : "Object"; if (typeof n === "undefined") { return false; } else if (typeof n !== "number") { throw new TypeError(n + " is not a Number."); } else if (n < min || n > max) { // As failing validation is *not* an exceptional circumstance // lets not throw a RangeError Exception here. // It's semantically correct but it's not sensible. return false; } return true; }; /** * Validates the number is within an acceptable range for milliseconds [0-999]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateMillisecond = function (value) { return validate(value, 0, 999, "millisecond"); }; /** * Validates the number is within an acceptable range for seconds [0-59]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateSecond = function (value) { return validate(value, 0, 59, "second"); }; /** * Validates the number is within an acceptable range for minutes [0-59]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateMinute = function (value) { return validate(value, 0, 59, "minute"); }; /** * Validates the number is within an acceptable range for hours [0-23]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateHour = function (value) { return validate(value, 0, 23, "hour"); }; /** * Validates the number is within an acceptable range for the days in a month [0-MaxDaysInMonth]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateDay = function (value, year, month) { if (year === undefined || year === null || month === undefined || month === null) { return false;} return validate(value, 1, $D.getDaysInMonth(year, month), "day"); }; /** * Validates the number is within an acceptable range for months [0-11]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateWeek = function (value) { return validate(value, 0, 53, "week"); }; /** * Validates the number is within an acceptable range for months [0-11]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateMonth = function (value) { return validate(value, 0, 11, "month"); }; /** * Validates the number is within an acceptable range for years. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateYear = function (value) { /** * Per ECMAScript spec the range of times supported by Date objects is * exactly -100,000,000 days to +100,000,000 days measured relative to * midnight at the beginning of 01 January, 1970 UTC. * This gives a range of 8,640,000,000,000,000 milliseconds to either * side of 01 January, 1970 UTC. * * Earliest possible date: Tue, 20 Apr 271,822 B.C. 00:00:00 UTC * Latest possible date: Sat, 13 Sep 275,760 00:00:00 UTC */ return validate(value, -271822, 275760, "year"); }; $D.validateTimezone = function(value) { var timezones = {"ACDT":1,"ACST":1,"ACT":1,"ADT":1,"AEDT":1,"AEST":1,"AFT":1,"AKDT":1,"AKST":1,"AMST":1,"AMT":1,"ART":1,"AST":1,"AWDT":1,"AWST":1,"AZOST":1,"AZT":1,"BDT":1,"BIOT":1,"BIT":1,"BOT":1,"BRT":1,"BST":1,"BTT":1,"CAT":1,"CCT":1,"CDT":1,"CEDT":1,"CEST":1,"CET":1,"CHADT":1,"CHAST":1,"CHOT":1,"ChST":1,"CHUT":1,"CIST":1,"CIT":1,"CKT":1,"CLST":1,"CLT":1,"COST":1,"COT":1,"CST":1,"CT":1,"CVT":1,"CWST":1,"CXT":1,"DAVT":1,"DDUT":1,"DFT":1,"EASST":1,"EAST":1,"EAT":1,"ECT":1,"EDT":1,"EEDT":1,"EEST":1,"EET":1,"EGST":1,"EGT":1,"EIT":1,"EST":1,"FET":1,"FJT":1,"FKST":1,"FKT":1,"FNT":1,"GALT":1,"GAMT":1,"GET":1,"GFT":1,"GILT":1,"GIT":1,"GMT":1,"GST":1,"GYT":1,"HADT":1,"HAEC":1,"HAST":1,"HKT":1,"HMT":1,"HOVT":1,"HST":1,"ICT":1,"IDT":1,"IOT":1,"IRDT":1,"IRKT":1,"IRST":1,"IST":1,"JST":1,"KGT":1,"KOST":1,"KRAT":1,"KST":1,"LHST":1,"LINT":1,"MAGT":1,"MART":1,"MAWT":1,"MDT":1,"MET":1,"MEST":1,"MHT":1,"MIST":1,"MIT":1,"MMT":1,"MSK":1,"MST":1,"MUT":1,"MVT":1,"MYT":1,"NCT":1,"NDT":1,"NFT":1,"NPT":1,"NST":1,"NT":1,"NUT":1,"NZDT":1,"NZST":1,"OMST":1,"ORAT":1,"PDT":1,"PET":1,"PETT":1,"PGT":1,"PHOT":1,"PHT":1,"PKT":1,"PMDT":1,"PMST":1,"PONT":1,"PST":1,"PYST":1,"PYT":1,"RET":1,"ROTT":1,"SAKT":1,"SAMT":1,"SAST":1,"SBT":1,"SCT":1,"SGT":1,"SLST":1,"SRT":1,"SST":1,"SYOT":1,"TAHT":1,"THA":1,"TFT":1,"TJT":1,"TKT":1,"TLT":1,"TMT":1,"TOT":1,"TVT":1,"UCT":1,"ULAT":1,"UTC":1,"UYST":1,"UYT":1,"UZT":1,"VET":1,"VLAT":1,"VOLT":1,"VOST":1,"VUT":1,"WAKT":1,"WAST":1,"WAT":1,"WEDT":1,"WEST":1,"WET":1,"WST":1,"YAKT":1,"YEKT":1,"Z":1}; return (timezones[value] === 1); }; $D.validateTimezoneOffset= function(value) { // timezones go from +14hrs to -12hrs, the +X hours are negative offsets. return (value > -841 && value < 721); }; }()); (function () { var $D = Date, $P = $D.prototype, p = function (s, l) { if (!l) { l = 2; } return ("000" + s).slice(l * -1); }; var validateConfigObject = function (obj) { var result = {}, self = this, prop, testFunc; testFunc = function (prop, func, value) { if (prop === "day") { var month = (obj.month !== undefined) ? obj.month : self.getMonth(); var year = (obj.year !== undefined) ? obj.year : self.getFullYear(); return $D[func](value, year, month); } else { return $D[func](value); } }; for (prop in obj) { if (Object.prototype.hasOwnProperty.call(obj, prop)) { var func = "validate" + prop.charAt(0).toUpperCase() + prop.slice(1); if ($D[func] && obj[prop] !== null && testFunc(prop, func, obj[prop])) { result[prop] = obj[prop]; } } } return result; }; /** * Resets the time of this Date object to 12:00 AM (00:00), which is the start of the day. * @param {Boolean} .clone() this date instance before clearing Time * @return {Date} this */ $P.clearTime = function () { this.setHours(0); this.setMinutes(0); this.setSeconds(0); this.setMilliseconds(0); return this; }; /** * Resets the time of this Date object to the current time ('now'). * @return {Date} this */ $P.setTimeToNow = function () { var n = new Date(); this.setHours(n.getHours()); this.setMinutes(n.getMinutes()); this.setSeconds(n.getSeconds()); this.setMilliseconds(n.getMilliseconds()); return this; }; /** * Returns a new Date object that is an exact date and time copy of the original instance. * @return {Date} A new Date instance */ $P.clone = function () { return new Date(this.getTime()); }; /** * Compares this instance to a Date object and returns an number indication of their relative values. * @param {Date} Date object to compare [Required] * @return {Number} -1 = this is lessthan date. 0 = values are equal. 1 = this is greaterthan date. */ $P.compareTo = function (date) { return Date.compare(this, date); }; /** * Compares this instance to another Date object and returns true if they are equal. * @param {Date} Date object to compare. If no date to compare, new Date() [now] is used. * @return {Boolean} true if dates are equal. false if they are not equal. */ $P.equals = function (date) { return Date.equals(this, (date !== undefined ? date : new Date())); }; /** * Determines if this instance is between a range of two dates or equal to either the start or end dates. * @param {Date} Start of range [Required] * @param {Date} End of range [Required] * @return {Boolean} true is this is between or equal to the start and end dates, else false */ $P.between = function (start, end) { return this.getTime() >= start.getTime() && this.getTime() <= end.getTime(); }; /** * Determines if this date occurs after the date to compare to. * @param {Date} Date object to compare. If no date to compare, new Date() ("now") is used. * @return {Boolean} true if this date instance is greater than the date to compare to (or "now"), otherwise false. */ $P.isAfter = function (date) { return this.compareTo(date || new Date()) === 1; }; /** * Determines if this date occurs before the date to compare to. * @param {Date} Date object to compare. If no date to compare, new Date() ("now") is used. * @return {Boolean} true if this date instance is less than the date to compare to (or "now"). */ $P.isBefore = function (date) { return (this.compareTo(date || new Date()) === -1); }; /** * Determines if the current Date instance occurs today. * @return {Boolean} true if this date instance is 'today', otherwise false. */ /** * Determines if the current Date instance occurs on the same Date as the supplied 'date'. * If no 'date' to compare to is provided, the current Date instance is compared to 'today'. * @param {date} Date object to compare. If no date to compare, the current Date ("now") is used. * @return {Boolean} true if this Date instance occurs on the same Day as the supplied 'date'. */ $P.isToday = $P.isSameDay = function (date) { return this.clone().clearTime().equals((date || new Date()).clone().clearTime()); }; /** * Adds the specified number of milliseconds to this instance. * @param {Number} The number of milliseconds to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addMilliseconds = function (value) { if (!value) { return this; } this.setTime(this.getTime() + value * 1); return this; }; /** * Adds the specified number of seconds to this instance. * @param {Number} The number of seconds to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addSeconds = function (value) { if (!value) { return this; } return this.addMilliseconds(value * 1000); }; /** * Adds the specified number of seconds to this instance. * @param {Number} The number of seconds to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addMinutes = function (value) { if (!value) { return this; } return this.addMilliseconds(value * 60000); // 60*1000 }; /** * Adds the specified number of hours to this instance. * @param {Number} The number of hours to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addHours = function (value) { if (!value) { return this; } return this.addMilliseconds(value * 3600000); // 60*60*1000 }; /** * Adds the specified number of days to this instance. * @param {Number} The number of days to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addDays = function (value) { if (!value) { return this; } this.setDate(this.getDate() + value * 1); return this; }; /** * Adds the specified number of weekdays (ie - not sat or sun) to this instance. * @param {Number} The number of days to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addWeekdays = function (value) { if (!value) { return this; } var day = this.getDay(); var weeks = (Math.ceil(Math.abs(value)/7)); if (day === 0 || day === 6) { if (value > 0) { this.next().monday(); this.addDays(-1); day = this.getDay(); } } if (value < 0) { while (value < 0) { this.addDays(-1); day = this.getDay(); if (day !== 0 && day !== 6) { value++; } } return this; } else if (value > 5 || (6-day) <= value) { value = value + (weeks * 2); } return this.addDays(value); }; /** * Adds the specified number of weeks to this instance. * @param {Number} The number of weeks to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addWeeks = function (value) { if (!value) { return this; } return this.addDays(value * 7); }; /** * Adds the specified number of months to this instance. * @param {Number} The number of months to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addMonths = function (value) { if (!value) { return this; } var n = this.getDate(); this.setDate(1); this.setMonth(this.getMonth() + value * 1); this.setDate(Math.min(n, $D.getDaysInMonth(this.getFullYear(), this.getMonth()))); return this; }; $P.addQuarters = function (value) { if (!value) { return this; } // note this will take you to the same point in the quarter as you are now. // i.e. - if you are 15 days into the quarter you'll be 15 days into the resulting one. // bonus: this allows adding fractional quarters return this.addMonths(value * 3); }; /** * Adds the specified number of years to this instance. * @param {Number} The number of years to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addYears = function (value) { if (!value) { return this; } return this.addMonths(value * 12); }; /** * Adds (or subtracts) to the value of the years, months, weeks, days, hours, minutes, seconds, milliseconds of the date instance using given configuration object. Positive and Negative values allowed. * Example

	Date.today().add( { days: 1, months: 1 } )

	new Date().add( { years: -1 } )
	
* @param {Object} Configuration object containing attributes (months, days, etc.) * @return {Date} this */ $P.add = function (config) { if (typeof config === "number") { this._orient = config; return this; } var x = config; if (x.day) { // If we should be a different date than today (eg: for 'tomorrow -1d', etc). // Should only effect parsing, not direct usage (eg, Finish and FinishExact) if ((x.day - this.getDate()) !== 0) { this.setDate(x.day); } } if (x.milliseconds) { this.addMilliseconds(x.milliseconds); } if (x.seconds) { this.addSeconds(x.seconds); } if (x.minutes) { this.addMinutes(x.minutes); } if (x.hours) { this.addHours(x.hours); } if (x.weeks) { this.addWeeks(x.weeks); } if (x.months) { this.addMonths(x.months); } if (x.years) { this.addYears(x.years); } if (x.days) { this.addDays(x.days); } return this; }; /** * Get the week number. Week one (1) is the week which contains the first Thursday of the year. Monday is considered the first day of the week. * The .getWeek() function does NOT convert the date to UTC. The local datetime is used. * Please use .getISOWeek() to get the week of the UTC converted date. * @return {Number} 1 to 53 */ $P.getWeek = function (utc) { // Create a copy of this date object var self, target = new Date(this.valueOf()); if (utc) { target.addMinutes(target.getTimezoneOffset()); self = target.clone(); } else { self = this; } // ISO week date weeks start on monday // so correct the day number var dayNr = (self.getDay() + 6) % 7; // ISO 8601 states that week 1 is the week // with the first thursday of that year. // Set the target date to the thursday in the target week target.setDate(target.getDate() - dayNr + 3); // Store the millisecond value of the target date var firstThursday = target.valueOf(); // Set the target to the first thursday of the year // First set the target to january first target.setMonth(0, 1); // Not a thursday? Correct the date to the next thursday if (target.getDay() !== 4) { target.setMonth(0, 1 + ((4 - target.getDay()) + 7) % 7); } // The weeknumber is the number of weeks between the // first thursday of the year and the thursday in the target week return 1 + Math.ceil((firstThursday - target) / 604800000); // 604800000 = 7 * 24 * 3600 * 1000 }; /** * Get the ISO 8601 week number. Week one ("01") is the week which contains the first Thursday of the year. Monday is considered the first day of the week. * The .getISOWeek() function does convert the date to it's UTC value. Please use .getWeek() to get the week of the local date. * @return {String} "01" to "53" */ $P.getISOWeek = function () { return p(this.getWeek(true)); }; /** * Moves the date to Monday of the week set. Week one (1) is the week which contains the first Thursday of the year. * @param {Number} A Number (1 to 53) that represents the week of the year. * @return {Date} this */ $P.setWeek = function (n) { if ((n - this.getWeek()) === 0) { if (this.getDay() !== 1) { return this.moveToDayOfWeek(1, (this.getDay() > 1 ? -1 : 1)); } else { return this; } } else { return this.moveToDayOfWeek(1, (this.getDay() > 1 ? -1 : 1)).addWeeks(n - this.getWeek()); } }; $P.setQuarter = function (qtr) { var month = Math.abs(((qtr-1) * 3) + 1); return this.setMonth(month, 1); }; $P.getQuarter = function () { return Date.getQuarter(this); }; $P.getDaysLeftInQuarter = function () { return Date.getDaysLeftInQuarter(this); }; /** * Moves the date to the next n'th occurrence of the dayOfWeek starting from the beginning of the month. The number (-1) is a magic number and will return the last occurrence of the dayOfWeek in the month. * @param {Number} The dayOfWeek to move to * @param {Number} The n'th occurrence to move to. Use (-1) to return the last occurrence in the month * @return {Date} this */ $P.moveToNthOccurrence = function (dayOfWeek, occurrence) { if (dayOfWeek === "Weekday") { if (occurrence > 0) { this.moveToFirstDayOfMonth(); if (this.is().weekday()) { occurrence -= 1; } } else if (occurrence < 0) { this.moveToLastDayOfMonth(); if (this.is().weekday()) { occurrence += 1; } } else { return this; } return this.addWeekdays(occurrence); } var shift = 0; if (occurrence > 0) { shift = occurrence - 1; } else if (occurrence === -1) { this.moveToLastDayOfMonth(); if (this.getDay() !== dayOfWeek) { this.moveToDayOfWeek(dayOfWeek, -1); } return this; } return this.moveToFirstDayOfMonth().addDays(-1).moveToDayOfWeek(dayOfWeek, +1).addWeeks(shift); }; var moveToN = function (getFunc, addFunc, nVal) { return function (value, orient) { var diff = (value - this[getFunc]() + nVal * (orient || +1)) % nVal; return this[addFunc]((diff === 0) ? diff += nVal * (orient || +1) : diff); }; }; /** * Move to the next or last dayOfWeek based on the orient value. * @param {Number} The dayOfWeek to move to * @param {Number} Forward (+1) or Back (-1). Defaults to +1. [Optional] * @return {Date} this */ $P.moveToDayOfWeek = moveToN("getDay", "addDays", 7); /** * Move to the next or last month based on the orient value. * @param {Number} The month to move to. 0 = January, 11 = December * @param {Number} Forward (+1) or Back (-1). Defaults to +1. [Optional] * @return {Date} this */ $P.moveToMonth = moveToN("getMonth", "addMonths", 12); /** * Get the Ordinate of the current day ("th", "st", "rd"). * @return {String} */ $P.getOrdinate = function () { var num = this.getDate(); return ord(num); }; /** * Get the Ordinal day (numeric day number) of the year, adjusted for leap year. * @return {Number} 1 through 365 (366 in leap years) */ $P.getOrdinalNumber = function () { return Math.ceil((this.clone().clearTime() - new Date(this.getFullYear(), 0, 1)) / 86400000) + 1; }; /** * Get the time zone abbreviation of the current date. * @return {String} The abbreviated time zone name (e.g. "EST") */ $P.getTimezone = function () { return $D.getTimezoneAbbreviation(this.getUTCOffset(), this.isDaylightSavingTime()); }; $P.setTimezoneOffset = function (offset) { var here = this.getTimezoneOffset(), there = Number(offset) * -6 / 10; return (there || there === 0) ? this.addMinutes(there - here) : this; }; $P.setTimezone = function (offset) { return this.setTimezoneOffset($D.getTimezoneOffset(offset)); }; /** * Indicates whether Daylight Saving Time is observed in the current time zone. * @return {Boolean} true|false */ $P.hasDaylightSavingTime = function () { return (Date.today().set({month: 0, day: 1}).getTimezoneOffset() !== Date.today().set({month: 6, day: 1}).getTimezoneOffset()); }; /** * Indicates whether this Date instance is within the Daylight Saving Time range for the current time zone. * @return {Boolean} true|false */ $P.isDaylightSavingTime = function () { return Date.today().set({month: 0, day: 1}).getTimezoneOffset() !== this.getTimezoneOffset(); }; /** * Get the offset from UTC of the current date. * @return {String} The 4-character offset string prefixed with + or - (e.g. "-0500") */ $P.getUTCOffset = function (offset) { var n = (offset || this.getTimezoneOffset()) * -10 / 6, r; if (n < 0) { r = (n - 10000).toString(); return r.charAt(0) + r.substr(2); } else { r = (n + 10000).toString(); return "+" + r.substr(1); } }; /** * Returns the number of milliseconds between this date and date. * @param {Date} Defaults to now * @return {Number} The diff in milliseconds */ $P.getElapsed = function (date) { return (date || new Date()) - this; }; /** * Set the value of year, month, day, hour, minute, second, millisecond of date instance using given configuration object. * Example

	Date.today().set( { day: 20, month: 1 } )

	new Date().set( { millisecond: 0 } )
	
* * @param {Object} Configuration object containing attributes (month, day, etc.) * @return {Date} this */ $P.set = function (config) { config = validateConfigObject.call(this, config); var key; for (key in config) { if (Object.prototype.hasOwnProperty.call(config, key)) { var name = key.charAt(0).toUpperCase() + key.slice(1); var addFunc, getFunc; if (key !== "week" && key !== "month" && key !== "timezone" && key !== "timezoneOffset") { name += "s"; } addFunc = "add" + name; getFunc = "get" + name; if (key === "month") { addFunc = addFunc + "s"; } else if (key === "year"){ getFunc = "getFullYear"; } if (key !== "day" && key !== "timezone" && key !== "timezoneOffset" && key !== "week" && key !== "hour") { this[addFunc](config[key] - this[getFunc]()); } else if ( key === "timezone"|| key === "timezoneOffset" || key === "week" || key === "hour") { this["set"+name](config[key]); } } } // day has to go last because you can't validate the day without first knowing the month if (config.day) { this.addDays(config.day - this.getDate()); } return this; }; /** * Moves the date to the first day of the month. * @return {Date} this */ $P.moveToFirstDayOfMonth = function () { return this.set({ day: 1 }); }; /** * Moves the date to the last day of the month. * @return {Date} this */ $P.moveToLastDayOfMonth = function () { return this.set({ day: $D.getDaysInMonth(this.getFullYear(), this.getMonth())}); }; /** * Converts the value of the current Date object to its equivalent string representation. * Format Specifiers * CUSTOM DATE AND TIME FORMAT STRINGS * Format Description Example * ------ --------------------------------------------------------------------------- ----------------------- * s The seconds of the minute between 0-59. "0" to "59" * ss The seconds of the minute with leading zero if required. "00" to "59" * * m The minute of the hour between 0-59. "0" or "59" * mm The minute of the hour with leading zero if required. "00" or "59" * * h The hour of the day between 1-12. "1" to "12" * hh The hour of the day with leading zero if required. "01" to "12" * * H The hour of the day between 0-23. "0" to "23" * HH The hour of the day with leading zero if required. "00" to "23" * * d The day of the month between 1 and 31. "1" to "31" * dd The day of the month with leading zero if required. "01" to "31" * ddd Abbreviated day name. Date.CultureInfo.abbreviatedDayNames. "Mon" to "Sun" * dddd The full day name. Date.CultureInfo.dayNames. "Monday" to "Sunday" * * M The month of the year between 1-12. "1" to "12" * MM The month of the year with leading zero if required. "01" to "12" * MMM Abbreviated month name. Date.CultureInfo.abbreviatedMonthNames. "Jan" to "Dec" * MMMM The full month name. Date.CultureInfo.monthNames. "January" to "December" * * yy The year as a two-digit number. "99" or "08" * yyyy The full four digit year. "1999" or "2008" * * t Displays the first character of the A.M./P.M. designator. "A" or "P" * Date.CultureInfo.amDesignator or Date.CultureInfo.pmDesignator * tt Displays the A.M./P.M. designator. "AM" or "PM" * Date.CultureInfo.amDesignator or Date.CultureInfo.pmDesignator * * S The ordinal suffix ("st, "nd", "rd" or "th") of the current day. "st, "nd", "rd" or "th" * * STANDARD DATE AND TIME FORMAT STRINGS * Format Description Example *------ --------------------------------------------------------------------------- ----------------------- * d The CultureInfo shortDate Format Pattern "M/d/yyyy" * D The CultureInfo longDate Format Pattern "dddd, MMMM dd, yyyy" * F The CultureInfo fullDateTime Format Pattern "dddd, MMMM dd, yyyy h:mm:ss tt" * m The CultureInfo monthDay Format Pattern "MMMM dd" * r The CultureInfo rfc1123 Format Pattern "ddd, dd MMM yyyy HH:mm:ss GMT" * s The CultureInfo sortableDateTime Format Pattern "yyyy-MM-ddTHH:mm:ss" * t The CultureInfo shortTime Format Pattern "h:mm tt" * T The CultureInfo longTime Format Pattern "h:mm:ss tt" * u The CultureInfo universalSortableDateTime Format Pattern "yyyy-MM-dd HH:mm:ssZ" * y The CultureInfo yearMonth Format Pattern "MMMM, yyyy" * * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @return {String} A string representation of the current Date object. */ var ord = function (n) { switch (n * 1) { case 1: case 21: case 31: return "st"; case 2: case 22: return "nd"; case 3: case 23: return "rd"; default: return "th"; } }; var parseStandardFormats = function (format) { var y, c = Date.CultureInfo.formatPatterns; switch (format) { case "d": return this.toString(c.shortDate); case "D": return this.toString(c.longDate); case "F": return this.toString(c.fullDateTime); case "m": return this.toString(c.monthDay); case "r": case "R": y = this.clone().addMinutes(this.getTimezoneOffset()); return y.toString(c.rfc1123) + " GMT"; case "s": return this.toString(c.sortableDateTime); case "t": return this.toString(c.shortTime); case "T": return this.toString(c.longTime); case "u": y = this.clone().addMinutes(this.getTimezoneOffset()); return y.toString(c.universalSortableDateTime); case "y": return this.toString(c.yearMonth); default: return false; } }; var parseFormatStringsClosure = function (context) { return function (m) { if (m.charAt(0) === "\\") { return m.replace("\\", ""); } switch (m) { case "hh": return p(context.getHours() < 13 ? (context.getHours() === 0 ? 12 : context.getHours()) : (context.getHours() - 12)); case "h": return context.getHours() < 13 ? (context.getHours() === 0 ? 12 : context.getHours()) : (context.getHours() - 12); case "HH": return p(context.getHours()); case "H": return context.getHours(); case "mm": return p(context.getMinutes()); case "m": return context.getMinutes(); case "ss": return p(context.getSeconds()); case "s": return context.getSeconds(); case "yyyy": return p(context.getFullYear(), 4); case "yy": return p(context.getFullYear()); case "y": return context.getFullYear(); case "E": case "dddd": return Date.CultureInfo.dayNames[context.getDay()]; case "ddd": return Date.CultureInfo.abbreviatedDayNames[context.getDay()]; case "dd": return p(context.getDate()); case "d": return context.getDate(); case "MMMM": return Date.CultureInfo.monthNames[context.getMonth()]; case "MMM": return Date.CultureInfo.abbreviatedMonthNames[context.getMonth()]; case "MM": return p((context.getMonth() + 1)); case "M": return context.getMonth() + 1; case "t": return context.getHours() < 12 ? Date.CultureInfo.amDesignator.substring(0, 1) : Date.CultureInfo.pmDesignator.substring(0, 1); case "tt": return context.getHours() < 12 ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator; case "S": return ord(context.getDate()); case "W": return context.getWeek(); case "WW": return context.getISOWeek(); case "Q": return "Q" + context.getQuarter(); case "q": return String(context.getQuarter()); case "z": return context.getTimezone(); case "Z": case "X": return Date.getTimezoneOffset(context.getTimezone()); case "ZZ": // Timezone offset in seconds return context.getTimezoneOffset() * -60; case "u": return context.getDay(); case "L": return ($D.isLeapYear(context.getFullYear())) ? 1 : 0; case "B": // Swatch Internet Time (.beats) return "@"+((context.getUTCSeconds() + (context.getUTCMinutes()*60) + ((context.getUTCHours()+1)*3600))/86.4); default: return m; } }; }; $P.toString = function (format, ignoreStandards) { // Standard Date and Time Format Strings. Formats pulled from CultureInfo file and // may vary by culture. if (!ignoreStandards && format && format.length === 1) { output = parseStandardFormats.call(this, format); if (output) { return output; } } var parseFormatStrings = parseFormatStringsClosure(this); return format ? format.replace(/((\\)?(dd?d?d?|MM?M?M?|yy?y?y?|hh?|HH?|mm?|ss?|tt?|S|q|Q|WW?W?W?)(?![^\[]*\]))/g, parseFormatStrings).replace(/\[|\]/g, "") : this._toString(); }; }()); /************************************************************* * SugarPak - Domain Specific Language - Syntactical Sugar * *************************************************************/ (function () { var $D = Date, $P = $D.prototype, $N = Number.prototype; // private $P._orient = +1; // private $P._nth = null; // private $P._is = false; // private $P._same = false; // private $P._isSecond = false; // private $N._dateElement = "days"; /** * Moves the date to the next instance of a date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.today().next().friday();
	Date.today().next().fri();
	Date.today().next().march();
	Date.today().next().mar();
	Date.today().next().week();
	
* * @return {Date} date */ $P.next = function () { this._move = true; this._orient = +1; return this; }; /** * Creates a new Date (Date.today()) and moves the date to the next instance of the date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.next().friday();
	Date.next().fri();
	Date.next().march();
	Date.next().mar();
	Date.next().week();
	
* * @return {Date} date */ $D.next = function () { return $D.today().next(); }; /** * Moves the date to the previous instance of a date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.today().last().friday();
	Date.today().last().fri();
	Date.today().last().march();
	Date.today().last().mar();
	Date.today().last().week();
	
* * @return {Date} date */ $P.last = $P.prev = $P.previous = function () { this._move = true; this._orient = -1; return this; }; /** * Creates a new Date (Date.today()) and moves the date to the previous instance of the date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.last().friday();
	Date.last().fri();
	Date.previous().march();
	Date.prev().mar();
	Date.last().week();
	
* * @return {Date} date */ $D.last = $D.prev = $D.previous = function () { return $D.today().last(); }; /** * Performs a equality check when followed by either a month name, day name or .weekday() function. * Example

	Date.today().is().friday(); // true|false
	Date.today().is().fri();
	Date.today().is().march();
	Date.today().is().mar();
	
* * @return {Boolean} true|false */ $P.is = function () { this._is = true; return this; }; /** * Determines if two date objects occur on/in exactly the same instance of the subsequent date part function. * The function .same() must be followed by a date part function (example: .day(), .month(), .year(), etc). * * An optional Date can be passed in the date part function. If now date is passed as a parameter, 'Now' is used. * * The following example demonstrates how to determine if two dates fall on the exact same day. * * Example

	var d1 = Date.today(); // today at 00:00
	var d2 = new Date();   // exactly now.

	// Do they occur on the same day?
	d1.same().day(d2); // true
	
	// Do they occur on the same hour?
	d1.same().hour(d2); // false, unless d2 hour is '00' (midnight).
	
	// What if it's the same day, but one year apart?
	var nextYear = Date.today().add(1).year();

	d1.same().day(nextYear); // false, because the dates must occur on the exact same day. 
	
* * Scenario: Determine if a given date occurs during some week period 2 months from now. * * Example

	var future = Date.today().add(2).months();
	return someDate.same().week(future); // true|false;
	
* * @return {Boolean} true|false */ $P.same = function () { this._same = true; this._isSecond = false; return this; }; /** * Determines if the current date/time occurs during Today. Must be preceded by the .is() function. * Example

	someDate.is().today();    // true|false
	new Date().is().today();  // true
	Date.today().is().today();// true
	Date.today().add(-1).day().is().today(); // false
	
* * @return {Boolean} true|false */ $P.today = function () { return this.same().day(); }; /** * Determines if the current date is a weekday. This function must be preceded by the .is() function. * Example

	Date.today().is().weekday(); // true|false
	
* * @return {Boolean} true|false */ $P.weekday = function () { if (this._nth) { return df("Weekday").call(this); } if (this._move) { return this.addWeekdays(this._orient); } if (this._is) { this._is = false; return (!this.is().sat() && !this.is().sun()); } return false; }; /** * Determines if the current date is on the weekend. This function must be preceded by the .is() function. * Example

	Date.today().is().weekend(); // true|false
	
* * @return {Boolean} true|false */ $P.weekend = function () { if (this._is) { this._is = false; return (this.is().sat() || this.is().sun()); } return false; }; /** * Sets the Time of the current Date instance. A string "6:15 pm" or config object {hour:18, minute:15} are accepted. * Example

	// Set time to 6:15pm with a String
	Date.today().at("6:15pm");

	// Set time to 6:15pm with a config object
	Date.today().at({hour:18, minute:15});
	
* * @return {Date} date */ $P.at = function (time) { return (typeof time === "string") ? $D.parse(this.toString("d") + " " + time) : this.set(time); }; /** * Creates a new Date() and adds this (Number) to the date based on the preceding date element function (eg. second|minute|hour|day|month|year). * Example

	// Undeclared Numbers must be wrapped with parentheses. Requirment of JavaScript.
	(3).days().fromNow();
	(6).months().fromNow();

	// Declared Number variables do not require parentheses. 
	var n = 6;
	n.months().fromNow();
	
* * @return {Date} A new Date instance */ $N.fromNow = $N.after = function (date) { var c = {}; c[this._dateElement] = this; return ((!date) ? new Date() : date.clone()).add(c); }; /** * Creates a new Date() and subtract this (Number) from the date based on the preceding date element function (eg. second|minute|hour|day|month|year). * Example

	// Undeclared Numbers must be wrapped with parentheses. Requirment of JavaScript.
	(3).days().ago();
	(6).months().ago();

	// Declared Number variables do not require parentheses. 
	var n = 6;
	n.months().ago();
	
* * @return {Date} A new Date instance */ $N.ago = $N.before = function (date) { var c = {}, s = (this._dateElement[this._dateElement.length-1] !== "s") ? this._dateElement + "s" : this._dateElement; c[s] = this * -1; return ((!date) ? new Date() : date.clone()).add(c); }; // Do NOT modify the following string tokens. These tokens are used to build dynamic functions. // All culture-specific strings can be found in the CultureInfo files. var dx = ("sunday monday tuesday wednesday thursday friday saturday").split(/\s/), mx = ("january february march april may june july august september october november december").split(/\s/), px = ("Millisecond Second Minute Hour Day Week Month Year Quarter Weekday").split(/\s/), pxf = ("Milliseconds Seconds Minutes Hours Date Week Month FullYear Quarter").split(/\s/), nth = ("final first second third fourth fifth").split(/\s/), de; /** * Returns an object literal of all the date parts. * Example

	var o = new Date().toObject();
	
	// { year: 2008, month: 4, week: 20, day: 13, hour: 18, minute: 9, second: 32, millisecond: 812 }
	
	// The object properties can be referenced directly from the object.
	
	alert(o.day);  // alerts "13"
	alert(o.year); // alerts "2008"
	
* * @return {Date} An object literal representing the original date object. */ $P.toObject = function () { var o = {}; for (var i = 0; i < px.length; i++) { if (this["get" + pxf[i]]) { o[px[i].toLowerCase()] = this["get" + pxf[i]](); } } return o; }; /** * Returns a date created from an object literal. Ignores the .week property if set in the config. * Example

	var o = new Date().toObject();
	
	return Date.fromObject(o); // will return the same date. 

	var o2 = {month: 1, day: 20, hour: 18}; // birthday party!
	Date.fromObject(o2);
	
* * @return {Date} An object literal representing the original date object. */ $D.fromObject = function(config) { config.week = null; return Date.today().set(config); }; // Create day name functions and abbreviated day name functions (eg. monday(), friday(), fri()). var df = function (n) { return function () { if (this._is) { this._is = false; return this.getDay() === n; } if (this._move) { this._move = null; } if (this._nth !== null) { // If the .second() function was called earlier, remove the _orient // from the date, and then continue. // This is required because 'second' can be used in two different context. // // Example // // Date.today().add(1).second(); // Date.march().second().monday(); // // Things get crazy with the following... // Date.march().add(1).second().second().monday(); // but it works!! // if (this._isSecond) { this.addSeconds(this._orient * -1); } // make sure we reset _isSecond this._isSecond = false; var ntemp = this._nth; this._nth = null; var temp = this.clone().moveToLastDayOfMonth(); this.moveToNthOccurrence(n, ntemp); if (this > temp) { throw new RangeError($D.getDayName(n) + " does not occur " + ntemp + " times in the month of " + $D.getMonthName(temp.getMonth()) + " " + temp.getFullYear() + "."); } return this; } return this.moveToDayOfWeek(n, this._orient); }; }; var sdf = function (n) { return function () { var t = $D.today(), shift = n - t.getDay(); if (n === 0 && Date.CultureInfo.firstDayOfWeek === 1 && t.getDay() !== 0) { shift = shift + 7; } return t.addDays(shift); }; }; // Create month name functions and abbreviated month name functions (eg. january(), march(), mar()). var month_instance_functions = function (n) { return function () { if (this._is) { this._is = false; return this.getMonth() === n; } return this.moveToMonth(n, this._orient); }; }; var month_static_functions = function (n) { return function () { return $D.today().set({ month: n, day: 1 }); }; }; var processTerms = function (names, staticFunc, instanceFunc) { for (var i = 0; i < names.length; i++) { // Create constant static Name variables. $D[names[i].toUpperCase()] = $D[names[i].toUpperCase().substring(0, 3)] = i; // Create Name functions. $D[names[i]] = $D[names[i].substring(0, 3)] = staticFunc(i); // Create Name instance functions. $P[names[i]] = $P[names[i].substring(0, 3)] = instanceFunc(i); } }; processTerms(dx, sdf, df); processTerms(mx, month_static_functions, month_instance_functions); // Create date element functions and plural date element functions used with Date (eg. day(), days(), months()). var ef = function (j) { return function () { // if the .second() function was called earlier, the _orient // has alread been added. Just return this and reset _isSecond. if (this._isSecond) { this._isSecond = false; return this; } if (this._same) { this._same = this._is = false; var o1 = this.toObject(), o2 = (arguments[0] || new Date()).toObject(), v = "", k = j.toLowerCase(); // the substr trick with -1 doesn't work in IE8 or less k = (k[k.length-1] === "s") ? k.substring(0,k.length-1) : k; for (var m = (px.length - 1); m > -1; m--) { v = px[m].toLowerCase(); if (o1[v] !== o2[v]) { return false; } if (k === v) { break; } } return true; } if (j.substring(j.length - 1) !== "s") { j += "s"; } if (this._move) { this._move = null; } return this["add" + j](this._orient); }; }; var nf = function (n) { return function () { this._dateElement = n; return this; }; }; for (var k = 0; k < px.length; k++) { de = px[k].toLowerCase(); if(de !== "weekday") { // Create date element functions and plural date element functions used with Date (eg. day(), days(), months()). $P[de] = $P[de + "s"] = ef(px[k]); // Create date element functions and plural date element functions used with Number (eg. day(), days(), months()). $N[de] = $N[de + "s"] = nf(de + "s"); } } $P._ss = ef("Second"); var nthfn = function (n) { return function (dayOfWeek) { if (this._same) { return this._ss(arguments[0]); } if (dayOfWeek || dayOfWeek === 0) { return this.moveToNthOccurrence(dayOfWeek, n); } this._nth = n; // if the operator is 'second' add the _orient, then deal with it later... if (n === 2 && (dayOfWeek === undefined || dayOfWeek === null)) { this._isSecond = true; return this.addSeconds(this._orient); } return this; }; }; for (var l = 0; l < nth.length; l++) { $P[nth[l]] = (l === 0) ? nthfn(-1) : nthfn(l); } }()); (function () { "use strict"; Date.Parsing = { Exception: function (s) { this.message = "Parse error at '" + s.substring(0, 10) + " ...'"; } }; var $P = Date.Parsing; var dayOffsets = { standard: [0,31,59,90,120,151,181,212,243,273,304,334], leap: [0,31,60,91,121,152,182,213,244,274,305,335] }; $P.isLeapYear = function(year) { return ((year % 4 === 0) && (year % 100 !== 0)) || (year % 400 === 0); }; var utils = { multiReplace : function (str, hash ) { var key; for (key in hash) { if (Object.prototype.hasOwnProperty.call(hash, key)) { var regex; if (typeof hash[key] === "function") { } else { regex = (hash[key] instanceof RegExp) ? hash[key] : new RegExp(hash[key], "g"); } str = str.replace(regex, key); } } return str; }, getDayOfYearFromWeek : function (obj) { var d, jan4, offset; obj.weekDay = (!obj.weekDay && obj.weekDay !== 0) ? 1 : obj.weekDay; d = new Date(obj.year, 0, 4); jan4 = d.getDay() === 0 ? 7 : d.getDay(); // JS is 0 indexed on Sunday. offset = jan4+3; obj.dayOfYear = ((obj.week * 7) + (obj.weekDay === 0 ? 7 : obj.weekDay))-offset; return obj; }, getDayOfYear : function (obj, dayOffset) { if (!obj.dayOfYear) { obj = utils.getDayOfYearFromWeek(obj); } for (var i=0;i <= dayOffset.length;i++) { if (obj.dayOfYear < dayOffset[i] || i === dayOffset.length) { obj.day = obj.day ? obj.day : (obj.dayOfYear - dayOffset[i-1]); break; } else { obj.month = i; } } return obj; }, adjustForTimeZone : function (obj, date) { var offset; if (obj.zone.toUpperCase() === "Z" || (obj.zone_hours === 0 && obj.zone_minutes === 0)) { // it's UTC/GML so work out the current timeszone offset offset = -date.getTimezoneOffset(); } else { offset = (obj.zone_hours*60) + (obj.zone_minutes || 0); if (obj.zone_sign === "+") { offset *= -1; } offset -= date.getTimezoneOffset(); } date.setMinutes(date.getMinutes()+offset); return date; }, setDefaults : function (obj) { obj.year = obj.year || Date.today().getFullYear(); obj.hours = obj.hours || 0; obj.minutes = obj.minutes || 0; obj.seconds = obj.seconds || 0; obj.milliseconds = obj.milliseconds || 0; if (!(!obj.month && (obj.week || obj.dayOfYear))) { // if we have a month, or if we don't but don't have the day calculation data obj.month = obj.month || 0; obj.day = obj.day || 1; } return obj; }, dataNum: function (data, mod, explict, postProcess) { var dataNum = data*1; if (mod) { if (postProcess) { return data ? mod(data)*1 : data; } else { return data ? mod(dataNum) : data; } } else if (!explict){ return data ? dataNum : data; } else { return (data && typeof data !== "undefined") ? dataNum : data; } }, timeDataProcess: function (obj) { var timeObj = {}; for (var x in obj.data) { if (obj.data.hasOwnProperty(x)) { timeObj[x] = obj.ignore[x] ? obj.data[x] : utils.dataNum(obj.data[x], obj.mods[x], obj.explict[x], obj.postProcess[x]); } } if (obj.data.secmins) { obj.data.secmins = obj.data.secmins.replace(",", ".") * 60; if (!timeObj.minutes) { timeObj.minutes = obj.data.secmins; } else if (!timeObj.seconds) { timeObj.seconds = obj.data.secmins; } delete obj.secmins; } return timeObj; }, buildTimeObjectFromData: function (data) { var time = utils.timeDataProcess({ data: { year : data[1], month : data[5], day : data[7], week : data[8], dayOfYear : data[10], hours : data[15], zone_hours : data[23], zone_minutes : data[24], zone : data[21], zone_sign : data[22], weekDay : data[9], minutes: data[16], seconds: data[19], milliseconds: data[20], secmins: data[18] }, mods: { month: function(data) { return data-1; }, weekDay: function (data) { data = Math.abs(data); return (data === 7 ? 0 : data); }, minutes: function (data) { return data.replace(":",""); }, seconds: function (data) { return Math.floor( (data.replace(":","").replace(",","."))*1 ); }, milliseconds: function (data) { return (data.replace(",",".")*1000); } }, postProcess: { minutes: true, seconds: true, milliseconds: true }, explict: { zone_hours: true, zone_minutes: true }, ignore: { zone: true, zone_sign: true, secmins: true } }); return time; }, addToHash: function (hash, keys, data) { keys = keys; data = data; var len = keys.length; for (var i = 0; i < len; i++) { hash[keys[i]] = data[i]; } return hash; }, combineRegex: function (r1, r2) { return new RegExp("(("+r1.source+")\\s("+r2.source+"))"); }, getDateNthString: function(add, last, inc){ if (add) { return Date.today().addDays(inc).toString("d"); } else if (last) { return Date.today().last()[inc]().toString("d"); } }, buildRegexData: function (array) { var arr = []; var len = array.length; for (var i=0; i < len; i++) { if (Object.prototype.toString.call(array[i]) === '[object Array]') { // oldIE compat version of Array.isArray arr.push(this.combineRegex(array[i][0], array[i][1])); } else { arr.push(array[i]); } } return arr; } }; $P.processTimeObject = function (obj) { var date, dayOffset; utils.setDefaults(obj); dayOffset = ($P.isLeapYear(obj.year)) ? dayOffsets.leap : dayOffsets.standard; if (!obj.month && (obj.week || obj.dayOfYear)) { utils.getDayOfYear(obj, dayOffset); } else { obj.dayOfYear = dayOffset[obj.month] + obj.day; } date = new Date(obj.year, obj.month, obj.day, obj.hours, obj.minutes, obj.seconds, obj.milliseconds); if (obj.zone) { utils.adjustForTimeZone(obj, date); // adjust (and calculate) for timezone } return date; }; $P.ISO = { regex : /^([\+-]?\d{4}(?!\d{2}\b))((-?)((0[1-9]|1[0-2])(\3([12]\d|0[1-9]|3[01]))?|W([0-4]\d|5[0-3])(-?[1-7])?|(00[1-9]|0[1-9]\d|[12]\d{2}|3([0-5]\d|6[1-6])))([T\s]((([01]\d|2[0-4])((:?)[0-5]\d)?|24\:?00)([\.,]\d+(?!:))?)?(\17[0-5]\d([\.,]\d+)?)?\s?([zZ]|([\+-])([01]\d|2[0-3]):?([0-5]\d)?)?)?)?$/, parse : function (s) { var time, data = s.match(this.regex); if (!data || !data.length) { return null; } time = utils.buildTimeObjectFromData(data); if (!time.year || (!time.year && (!time.month && !time.day) && (!time.week && !time.dayOfYear)) ) { return null; } return $P.processTimeObject(time); } }; $P.Numeric = { isNumeric: function (e){return!isNaN(parseFloat(e))&&isFinite(e);}, regex: /\b([0-1]?[0-9])([0-3]?[0-9])([0-2]?[0-9]?[0-9][0-9])\b/i, parse: function (s) { var data, i, time = {}, order = Date.CultureInfo.dateElementOrder.split(""); if (!(this.isNumeric(s)) || // if it's non-numeric OR (s[0] === "+" && s[0] === "-")) { // It's an arithmatic string (eg +/-1000) return null; } if (s.length < 5 && s.indexOf(".") < 0 && s.indexOf("/") < 0) { // assume it's just a year. time.year = s; return $P.processTimeObject(time); } data = s.match(this.regex); if (!data || !data.length) { return null; } for (i=0; i < order.length; i++) { switch(order[i]) { case "d": time.day = data[i+1]; break; case "m": time.month = (data[i+1]-1); break; case "y": time.year = data[i+1]; break; } } return $P.processTimeObject(time); } }; $P.Normalizer = { regexData: function () { var $R = Date.CultureInfo.regexPatterns; return utils.buildRegexData([ $R.tomorrow, $R.yesterday, [$R.past, $R.mon], [$R.past, $R.tue], [$R.past, $R.wed], [$R.past, $R.thu], [$R.past, $R.fri], [$R.past, $R.sat], [$R.past, $R.sun] ]); }, basicReplaceHash : function() { var $R = Date.CultureInfo.regexPatterns; return { "January": $R.jan.source, "February": $R.feb, "March": $R.mar, "April": $R.apr, "May": $R.may, "June": $R.jun, "July": $R.jul, "August": $R.aug, "September": $R.sep, "October": $R.oct, "November": $R.nov, "December": $R.dec, "": /\bat\b/gi, " ": /\s{2,}/, "am": $R.inTheMorning, "9am": $R.thisMorning, "pm": $R.inTheEvening, "7pm":$R.thisEvening }; }, keys : function(){ return [ utils.getDateNthString(true, false, 1), // tomorrow utils.getDateNthString(true, false, -1), // yesterday utils.getDateNthString(false, true, "monday"), //last mon utils.getDateNthString(false, true, "tuesday"), //last tues utils.getDateNthString(false, true, "wednesday"), //last wed utils.getDateNthString(false, true, "thursday"), //last thurs utils.getDateNthString(false, true, "friday"), //last fri utils.getDateNthString(false, true, "saturday"), //last sat utils.getDateNthString(false, true, "sunday") //last sun ]; }, buildRegexFunctions: function () { var $R = Date.CultureInfo.regexPatterns; var __ = Date.i18n.__; var tomorrowRE = new RegExp("(\\b\\d\\d?("+__("AM")+"|"+__("PM")+")? )("+$R.tomorrow.source.slice(1)+")", "i"); // adapted tomorrow regex for AM PM relative dates var todayRE = new RegExp($R.today.source + "(?!\\s*([+-]))\\b"); // today, but excludes the math operators (eg "today + 2h") this.replaceFuncs = [ [todayRE, function (full) { return (full.length > 1) ? Date.today().toString("d") : full; }], [tomorrowRE, function(full, m1) { var t = Date.today().addDays(1).toString("d"); return (t + " " + m1); }], [$R.amThisMorning, function(str, am){return am;}], [$R.pmThisEvening, function(str, pm){return pm;}] ]; }, buildReplaceData: function () { this.buildRegexFunctions(); this.replaceHash = utils.addToHash(this.basicReplaceHash(), this.keys(), this.regexData()); }, stringReplaceFuncs: function (s) { for (var i=0; i < this.replaceFuncs.length; i++) { s = s.replace(this.replaceFuncs[i][0], this.replaceFuncs[i][1]); } return s; }, parse: function (s) { s = this.stringReplaceFuncs(s); s = utils.multiReplace(s, this.replaceHash); try { var n = s.split(/([\s\-\.\,\/\x27]+)/); if (n.length === 3 && $P.Numeric.isNumeric(n[0]) && $P.Numeric.isNumeric(n[2]) && (n[2].length >= 4)) { // ok, so we're dealing with x/year. But that's not a full date. // This fixes wonky dateElementOrder parsing when set to dmy order. if (Date.CultureInfo.dateElementOrder[0] === "d") { s = "1/" + n[0] + "/" + n[2]; // set to 1st of month and normalize the seperator } } } catch (e) {} return s; } }; $P.Normalizer.buildReplaceData(); }()); (function () { var $P = Date.Parsing; var _ = $P.Operators = { // // Tokenizers // rtoken: function (r) { // regex token return function (s) { var mx = s.match(r); if (mx) { return ([ mx[0], s.substring(mx[0].length) ]); } else { throw new $P.Exception(s); } }; }, token: function () { // whitespace-eating token return function (s) { return _.rtoken(new RegExp("^\\s*" + s + "\\s*"))(s); }; }, stoken: function (s) { // string token return _.rtoken(new RegExp("^" + s)); }, // Atomic Operators until: function (p) { return function (s) { var qx = [], rx = null; while (s.length) { try { rx = p.call(this, s); } catch (e) { qx.push(rx[0]); s = rx[1]; continue; } break; } return [ qx, s ]; }; }, many: function (p) { return function (s) { var rx = [], r = null; while (s.length) { try { r = p.call(this, s); } catch (e) { return [ rx, s ]; } rx.push(r[0]); s = r[1]; } return [ rx, s ]; }; }, // generator operators -- see below optional: function (p) { return function (s) { var r = null; try { r = p.call(this, s); } catch (e) { return [ null, s ]; } return [ r[0], r[1] ]; }; }, not: function (p) { return function (s) { try { p.call(this, s); } catch (e) { return [null, s]; } throw new $P.Exception(s); }; }, ignore: function (p) { return p ? function (s) { var r = null; r = p.call(this, s); return [null, r[1]]; } : null; }, product: function () { var px = arguments[0], qx = Array.prototype.slice.call(arguments, 1), rx = []; for (var i = 0 ; i < px.length ; i++) { rx.push(_.each(px[i], qx)); } return rx; }, cache: function (rule) { var cache = {}, cache_length = 0, cache_keys = [], CACHE_MAX = Date.Config.CACHE_MAX || 100000, r = null; var cacheCheck = function () { if (cache_length === CACHE_MAX) { // kill several keys, don't want to have to do this all the time... for (var i=0; i < 10; i++) { var key = cache_keys.shift(); if (key) { delete cache[key]; cache_length--; } } } }; return function (s) { cacheCheck(); try { r = cache[s] = (cache[s] || rule.call(this, s)); } catch (e) { r = cache[s] = e; } cache_length++; cache_keys.push(s); if (r instanceof $P.Exception) { throw r; } else { return r; } }; }, // vector operators -- see below any: function () { var px = arguments; return function (s) { var r = null; for (var i = 0; i < px.length; i++) { if (px[i] == null) { continue; } try { r = (px[i].call(this, s)); } catch (e) { r = null; } if (r) { return r; } } throw new $P.Exception(s); }; }, each: function () { var px = arguments; return function (s) { var rx = [], r = null; for (var i = 0; i < px.length ; i++) { if (px[i] == null) { continue; } try { r = (px[i].call(this, s)); } catch (e) { throw new $P.Exception(s); } rx.push(r[0]); s = r[1]; } return [ rx, s]; }; }, all: function () { var px = arguments, _ = _; return _.each(_.optional(px)); }, // delimited operators sequence: function (px, d, c) { d = d || _.rtoken(/^\s*/); c = c || null; if (px.length === 1) { return px[0]; } return function (s) { var r = null, q = null; var rx = []; for (var i = 0; i < px.length ; i++) { try { r = px[i].call(this, s); } catch (e) { break; } rx.push(r[0]); try { q = d.call(this, r[1]); } catch (ex) { q = null; break; } s = q[1]; } if (!r) { throw new $P.Exception(s); } if (q) { throw new $P.Exception(q[1]); } if (c) { try { r = c.call(this, r[1]); } catch (ey) { throw new $P.Exception(r[1]); } } return [ rx, (r?r[1]:s) ]; }; }, // // Composite Operators // between: function (d1, p, d2) { d2 = d2 || d1; var _fn = _.each(_.ignore(d1), p, _.ignore(d2)); return function (s) { var rx = _fn.call(this, s); return [[rx[0][0], r[0][2]], rx[1]]; }; }, list: function (p, d, c) { d = d || _.rtoken(/^\s*/); c = c || null; return (p instanceof Array ? _.each(_.product(p.slice(0, -1), _.ignore(d)), p.slice(-1), _.ignore(c)) : _.each(_.many(_.each(p, _.ignore(d))), px, _.ignore(c))); }, set: function (px, d, c) { d = d || _.rtoken(/^\s*/); c = c || null; return function (s) { // r is the current match, best the current 'best' match // which means it parsed the most amount of input var r = null, p = null, q = null, rx = null, best = [[], s], last = false; // go through the rules in the given set for (var i = 0; i < px.length ; i++) { // last is a flag indicating whether this must be the last element // if there is only 1 element, then it MUST be the last one q = null; p = null; r = null; last = (px.length === 1); // first, we try simply to match the current pattern // if not, try the next pattern try { r = px[i].call(this, s); } catch (e) { continue; } // since we are matching against a set of elements, the first // thing to do is to add r[0] to matched elements rx = [[r[0]], r[1]]; // if we matched and there is still input to parse and // we don't already know this is the last element, // we're going to next check for the delimiter ... // if there's none, or if there's no input left to parse // than this must be the last element after all ... if (r[1].length > 0 && ! last) { try { q = d.call(this, r[1]); } catch (ex) { last = true; } } else { last = true; } // if we parsed the delimiter and now there's no more input, // that means we shouldn't have parsed the delimiter at all // so don't update r and mark this as the last element ... if (!last && q[1].length === 0) { last = true; } // so, if this isn't the last element, we're going to see if // we can get any more matches from the remaining (unmatched) // elements ... if (!last) { // build a list of the remaining rules we can match against, // i.e., all but the one we just matched against var qx = []; for (var j = 0; j < px.length ; j++) { if (i !== j) { qx.push(px[j]); } } // now invoke recursively set with the remaining input // note that we don't include the closing delimiter ... // we'll check for that ourselves at the end p = _.set(qx, d).call(this, q[1]); // if we got a non-empty set as a result ... // (otw rx already contains everything we want to match) if (p[0].length > 0) { // update current result, which is stored in rx ... // basically, pick up the remaining text from p[1] // and concat the result from p[0] so that we don't // get endless nesting ... rx[0] = rx[0].concat(p[0]); rx[1] = p[1]; } } // at this point, rx either contains the last matched element // or the entire matched set that starts with this element. // now we just check to see if this variation is better than // our best so far, in terms of how much of the input is parsed if (rx[1].length < best[1].length) { best = rx; } // if we've parsed all the input, then we're finished if (best[1].length === 0) { break; } } // so now we've either gone through all the patterns trying them // as the initial match; or we found one that parsed the entire // input string ... // if best has no matches, just return empty set ... if (best[0].length === 0) { return best; } // if a closing delimiter is provided, then we have to check it also if (c) { // we try this even if there is no remaining input because the pattern // may well be optional or match empty input ... try { q = c.call(this, best[1]); } catch (ey) { throw new $P.Exception(best[1]); } // it parsed ... be sure to update the best match remaining input best[1] = q[1]; } // if we're here, either there was no closing delimiter or we parsed it // so now we have the best match; just return it! return best; }; }, forward: function (gr, fname) { return function (s) { return gr[fname].call(this, s); }; }, // // Translation Operators // replace: function (rule, repl) { return function (s) { var r = rule.call(this, s); return [repl, r[1]]; }; }, process: function (rule, fn) { return function (s) { var r = rule.call(this, s); return [fn.call(this, r[0]), r[1]]; }; }, min: function (min, rule) { return function (s) { var rx = rule.call(this, s); if (rx[0].length < min) { throw new $P.Exception(s); } return rx; }; } }; // Generator Operators And Vector Operators // Generators are operators that have a signature of F(R) => R, // taking a given rule and returning another rule, such as // ignore, which parses a given rule and throws away the result. // Vector operators are those that have a signature of F(R1,R2,...) => R, // take a list of rules and returning a new rule, such as each. // Generator operators are converted (via the following _generator // function) into functions that can also take a list or array of rules // and return an array of new rules as though the function had been // called on each rule in turn (which is what actually happens). // This allows generators to be used with vector operators more easily. // Example: // each(ignore(foo, bar)) instead of each(ignore(foo), ignore(bar)) // This also turns generators into vector operators, which allows // constructs like: // not(cache(foo, bar)) var _generator = function (op) { function gen() { var args = null, rx = [], px, i; if (arguments.length > 1) { args = Array.prototype.slice.call(arguments); } else if (arguments[0] instanceof Array) { args = arguments[0]; } if (args) { px = args.shift(); if (px.length > 0) { args.unshift(px[i]); rx.push(op.apply(null, args)); args.shift(); return rx; } } else { return op.apply(null, arguments); } } return gen; }; var gx = "optional not ignore cache".split(/\s/); for (var i = 0 ; i < gx.length ; i++) { _[gx[i]] = _generator(_[gx[i]]); } var _vector = function (op) { return function () { if (arguments[0] instanceof Array) { return op.apply(null, arguments[0]); } else { return op.apply(null, arguments); } }; }; var vx = "each any all".split(/\s/); for (var j = 0 ; j < vx.length ; j++) { _[vx[j]] = _vector(_[vx[j]]); } }()); (function () { var $D = Date; var flattenAndCompact = function (ax) { var rx = []; for (var i = 0; i < ax.length; i++) { if (ax[i] instanceof Array) { rx = rx.concat(flattenAndCompact(ax[i])); } else { if (ax[i]) { rx.push(ax[i]); } } } return rx; }; var parseMeridian = function () { if (this.meridian && (this.hour || this.hour === 0)) { if (this.meridian === "a" && this.hour > 11 && Date.Config.strict24hr){ throw "Invalid hour and meridian combination"; } else if (this.meridian === "p" && this.hour < 12 && Date.Config.strict24hr){ throw "Invalid hour and meridian combination"; } else if (this.meridian === "p" && this.hour < 12) { this.hour = this.hour + 12; } else if (this.meridian === "a" && this.hour === 12) { this.hour = 0; } } }; var setDefaults = function () { var now = new Date(); if ((this.hour || this.minute) && (!this.month && !this.year && !this.day)) { this.day = now.getDate(); } if (!this.year) { this.year = now.getFullYear(); } if (!this.month && this.month !== 0) { this.month = now.getMonth(); } if (!this.day) { this.day = 1; } if (!this.hour) { this.hour = 0; } if (!this.minute) { this.minute = 0; } if (!this.second) { this.second = 0; } if (!this.millisecond) { this.millisecond = 0; } }; var finishUtils = { getToday: function () { if (this.now || "hour minute second".indexOf(this.unit) !== -1) { return new Date(); } else { return $D.today(); } }, setDaysFromWeekday: function (today, orient){ var gap; orient = orient || 1; this.unit = "day"; gap = ($D.getDayNumberFromName(this.weekday) - today.getDay()); this.days = gap ? ((gap + (orient * 7)) % 7) : (orient * 7); return this; }, setMonthsFromMonth: function (today, orient) { var gap; orient = orient || 1; this.unit = "month"; gap = (this.month - today.getMonth()); this.months = gap ? ((gap + (orient * 12)) % 12) : (orient * 12); this.month = null; return this; }, setDMYFromWeekday: function () { var d = Date[this.weekday](); this.day = d.getDate(); if (!this.month) { this.month = d.getMonth(); } this.year = d.getFullYear(); return this; }, setUnitValue: function (orient) { if (!this.value && this.operator && this.operator !== null && this[this.unit + "s"] && this[this.unit + "s"] !== null) { this[this.unit + "s"] = this[this.unit + "s"] + ((this.operator === "add") ? 1 : -1) + (this.value||0) * orient; } else if (this[this.unit + "s"] == null || this.operator != null) { if (!this.value) { this.value = 1; } this[this.unit + "s"] = this.value * orient; } }, generateDateFromWeeks: function () { var weekday = (this.weekday !== undefined) ? this.weekday : "today"; var d = Date[weekday]().addWeeks(this.weeks); if (this.now) { d.setTimeToNow(); } return d; } }; $D.Translator = { hour: function (s) { return function () { this.hour = Number(s); }; }, minute: function (s) { return function () { this.minute = Number(s); }; }, second: function (s) { return function () { this.second = Number(s); }; }, /* for ss.s format */ secondAndMillisecond: function (s) { return function () { var mx = s.match(/^([0-5][0-9])\.([0-9]{1,3})/); this.second = Number(mx[1]); this.millisecond = Number(mx[2]); }; }, meridian: function (s) { return function () { this.meridian = s.slice(0, 1).toLowerCase(); }; }, timezone: function (s) { return function () { var n = s.replace(/[^\d\+\-]/g, ""); if (n.length) { this.timezoneOffset = Number(n); } else { this.timezone = s.toLowerCase(); } }; }, day: function (x) { var s = x[0]; return function () { this.day = Number(s.match(/\d+/)[0]); if (this.day < 1) { throw "invalid day"; } }; }, month: function (s) { return function () { this.month = (s.length === 3) ? "jan feb mar apr may jun jul aug sep oct nov dec".indexOf(s)/4 : Number(s) - 1; if (this.month < 0) { throw "invalid month"; } }; }, year: function (s) { return function () { var n = Number(s); this.year = ((s.length > 2) ? n : (n + (((n + 2000) < Date.CultureInfo.twoDigitYearMax) ? 2000 : 1900))); }; }, rday: function (s) { return function () { switch (s) { case "yesterday": this.days = -1; break; case "tomorrow": this.days = 1; break; case "today": this.days = 0; break; case "now": this.days = 0; this.now = true; break; } }; }, finishExact: function (x) { var d; x = (x instanceof Array) ? x : [x]; for (var i = 0 ; i < x.length ; i++) { if (x[i]) { x[i].call(this); } } setDefaults.call(this); parseMeridian.call(this); if (this.day > $D.getDaysInMonth(this.year, this.month)) { throw new RangeError(this.day + " is not a valid value for days."); } d = new Date(this.year, this.month, this.day, this.hour, this.minute, this.second, this.millisecond); if (this.year < 100) { d.setFullYear(this.year); // means years less that 100 are process correctly. JS will parse it otherwise as 1900-1999. } if (this.timezone) { d.set({ timezone: this.timezone }); } else if (this.timezoneOffset) { d.set({ timezoneOffset: this.timezoneOffset }); } return d; }, finish: function (x) { var today, expression, orient, temp; x = (x instanceof Array) ? flattenAndCompact(x) : [ x ]; if (x.length === 0) { return null; } for (var i = 0 ; i < x.length ; i++) { if (typeof x[i] === "function") { x[i].call(this); } } if (this.now && !this.unit && !this.operator) { return new Date(); } else { today = finishUtils.getToday.call(this); } expression = !!(this.days && this.days !== null || this.orient || this.operator); orient = ((this.orient === "past" || this.operator === "subtract") ? -1 : 1); if (this.month && this.unit === "week") { this.value = this.month + 1; delete this.month; delete this.day; } if ((this.month || this.month === 0) && "year day hour minute second".indexOf(this.unit) !== -1) { if (!this.value) { this.value = this.month + 1; } this.month = null; expression = true; } if (!expression && this.weekday && !this.day && !this.days) { finishUtils.setDMYFromWeekday.call(this); } if (expression && this.weekday && this.unit !== "month" && this.unit !== "week") { finishUtils.setDaysFromWeekday.call(this, today, orient); } if (this.weekday && this.unit !== "week" && !this.day && !this.days) { temp = Date[this.weekday](); this.day = temp.getDate(); if (temp.getMonth() !== today.getMonth()) { this.month = temp.getMonth(); } } if (this.month && this.unit === "day" && this.operator) { if (!this.value) { this.value = (this.month + 1); } this.month = null; } if (this.value != null && this.month != null && this.year != null) { this.day = this.value * 1; } if (this.month && !this.day && this.value) { today.set({ day: this.value * 1 }); if (!expression) { this.day = this.value * 1; } } if (!this.month && this.value && this.unit === "month" && !this.now) { this.month = this.value; expression = true; } if (expression && (this.month || this.month === 0) && this.unit !== "year") { finishUtils.setMonthsFromMonth.call(this, today, orient); } if (!this.unit) { this.unit = "day"; } finishUtils.setUnitValue.call(this, orient); parseMeridian.call(this); if ((this.month || this.month === 0) && !this.day) { this.day = 1; } if (!this.orient && !this.operator && this.unit === "week" && this.value && !this.day && !this.month) { return Date.today().setWeek(this.value); } if (this.unit === "week" && this.weeks && !this.day && !this.month) { return finishUtils.generateDateFromWeeks.call(this); } if (expression && this.timezone && this.day && this.days) { this.day = this.days; } if (expression){ today.add(this); } else { today.set(this); } if (this.timezone) { this.timezone = this.timezone.toUpperCase(); var offset = $D.getTimezoneOffset(this.timezone); var timezone; if (today.hasDaylightSavingTime()) { // lets check that we're being sane with timezone setting timezone = $D.getTimezoneAbbreviation(offset, today.isDaylightSavingTime()); if (timezone !== this.timezone) { // bugger, we're in a place where things like EST vs EDT matters. if (today.isDaylightSavingTime()) { today.addHours(-1); } else { today.addHours(1); } } } today.setTimezoneOffset(offset); } return today; } }; }()); (function () { var $D = Date; $D.Grammar = {}; var _ = $D.Parsing.Operators, g = $D.Grammar, t = $D.Translator, _fn; // Allow rolling up into general purpose rules _fn = function () { return _.each(_.any.apply(null, arguments), _.not(g.ctoken2("timeContext"))); }; g.datePartDelimiter = _.rtoken(/^([\s\-\.\,\/\x27]+)/); g.timePartDelimiter = _.stoken(":"); g.whiteSpace = _.rtoken(/^\s*/); g.generalDelimiter = _.rtoken(/^(([\s\,]|at|@|on)+)/); var _C = {}; g.ctoken = function (keys) { var fn = _C[keys]; if (! fn) { var c = Date.CultureInfo.regexPatterns; var kx = keys.split(/\s+/), px = []; for (var i = 0; i < kx.length ; i++) { px.push(_.replace(_.rtoken(c[kx[i]]), kx[i])); } fn = _C[keys] = _.any.apply(null, px); } return fn; }; g.ctoken2 = function (key) { return _.rtoken(Date.CultureInfo.regexPatterns[key]); }; var cacheProcessRtoken = function (key, token, type, eachToken) { if (eachToken) { g[key] = _.cache(_.process(_.each(_.rtoken(token),_.optional(g.ctoken2(eachToken))), type)); } else { g[key] = _.cache(_.process(_.rtoken(token), type)); } }; var cacheProcessCtoken = function (token, type) { return _.cache(_.process(g.ctoken2(token), type)); }; var _F = {}; //function cache var _get = function (f) { _F[f] = (_F[f] || g.format(f)[0]); return _F[f]; }; g.allformats = function (fx) { var rx = []; if (fx instanceof Array) { for (var i = 0; i < fx.length; i++) { rx.push(_get(fx[i])); } } else { rx.push(_get(fx)); } return rx; }; g.formats = function (fx) { if (fx instanceof Array) { var rx = []; for (var i = 0 ; i < fx.length ; i++) { rx.push(_get(fx[i])); } return _.any.apply(null, rx); } else { return _get(fx); } }; var grammarFormats = { timeFormats: function(){ var i, RTokenKeys = [ "h", "hh", "H", "HH", "m", "mm", "s", "ss", "ss.s", "z", "zz" ], RToken = [ /^(0[0-9]|1[0-2]|[1-9])/, /^(0[0-9]|1[0-2])/, /^([0-1][0-9]|2[0-3]|[0-9])/, /^([0-1][0-9]|2[0-3])/, /^([0-5][0-9]|[0-9])/, /^[0-5][0-9]/, /^([0-5][0-9]|[0-9])/, /^[0-5][0-9]/, /^[0-5][0-9]\.[0-9]{1,3}/, /^((\+|\-)\s*\d\d\d\d)|((\+|\-)\d\d\:?\d\d)/, /^((\+|\-)\s*\d\d\d\d)|((\+|\-)\d\d\:?\d\d)/ ], tokens = [ t.hour, t.hour, t.hour, t.hour, t.minute, t.minute, t.second, t.second, t.secondAndMillisecond, t.timezone, t.timezone ]; for (i=0; i < RTokenKeys.length; i++) { cacheProcessRtoken(RTokenKeys[i], RToken[i], tokens[i]); } g.hms = _.cache(_.sequence([g.H, g.m, g.s], g.timePartDelimiter)); g.t = cacheProcessCtoken("shortMeridian", t.meridian); g.tt = cacheProcessCtoken("longMeridian", t.meridian); g.zzz = cacheProcessCtoken("timezone", t.timezone); g.timeSuffix = _.each(_.ignore(g.whiteSpace), _.set([ g.tt, g.zzz ])); g.time = _.each(_.optional(_.ignore(_.stoken("T"))), g.hms, g.timeSuffix); }, dateFormats: function () { // pre-loaded rules for different date part order preferences var _setfn = function () { return _.set(arguments, g.datePartDelimiter); }; var i, RTokenKeys = [ "d", "dd", "M", "MM", "y", "yy", "yyy", "yyyy" ], RToken = [ /^([0-2]\d|3[0-1]|\d)/, /^([0-2]\d|3[0-1])/, /^(1[0-2]|0\d|\d)/, /^(1[0-2]|0\d)/, /^(\d+)/, /^(\d\d)/, /^(\d\d?\d?\d?)/, /^(\d\d\d\d)/ ], tokens = [ t.day, t.day, t.month, t.month, t.year, t.year, t.year, t.year ], eachToken = [ "ordinalSuffix", "ordinalSuffix" ]; for (i=0; i < RTokenKeys.length; i++) { cacheProcessRtoken(RTokenKeys[i], RToken[i], tokens[i], eachToken[i]); } g.MMM = g.MMMM = _.cache(_.process(g.ctoken("jan feb mar apr may jun jul aug sep oct nov dec"), t.month)); g.ddd = g.dddd = _.cache(_.process(g.ctoken("sun mon tue wed thu fri sat"), function (s) { return function () { this.weekday = s; }; } )); g.day = _fn(g.d, g.dd); g.month = _fn(g.M, g.MMM); g.year = _fn(g.yyyy, g.yy); g.mdy = _setfn(g.ddd, g.month, g.day, g.year); g.ymd = _setfn(g.ddd, g.year, g.month, g.day); g.dmy = _setfn(g.ddd, g.day, g.month, g.year); g.date = function (s) { return ((g[Date.CultureInfo.dateElementOrder] || g.mdy).call(this, s)); }; }, relative: function () { // relative date / time expressions g.orientation = _.process(g.ctoken("past future"), function (s) { return function () { this.orient = s; }; } ); g.operator = _.process(g.ctoken("add subtract"), function (s) { return function () { this.operator = s; }; } ); g.rday = _.process(g.ctoken("yesterday tomorrow today now"), t.rday); g.unit = _.process(g.ctoken("second minute hour day week month year"), function (s) { return function () { this.unit = s; }; } ); } }; g.buildGrammarFormats = function () { // these need to be rebuilt every time the language changes. _C = {}; grammarFormats.timeFormats(); grammarFormats.dateFormats(); grammarFormats.relative(); g.value = _.process(_.rtoken(/^([-+]?\d+)?(st|nd|rd|th)?/), function (s) { return function () { this.value = s.replace(/\D/g, ""); }; } ); g.expression = _.set([g.rday, g.operator, g.value, g.unit, g.orientation, g.ddd, g.MMM ]); g.format = _.process(_.many( _.any( // translate format specifiers into grammar rules _.process( _.rtoken(/^(dd?d?d?(?!e)|MM?M?M?|yy?y?y?|hh?|HH?|mm?|ss?|tt?|zz?z?)/), function (fmt) { if (g[fmt]) { return g[fmt]; } else { throw $D.Parsing.Exception(fmt); } } ), // translate separator tokens into token rules _.process(_.rtoken(/^[^dMyhHmstz]+/), // all legal separators function (s) { return _.ignore(_.stoken(s)); } ) ) ), // construct the parser ... function (rules) { return _.process(_.each.apply(null, rules), t.finishExact); } ); // starting rule for general purpose grammar g._start = _.process(_.set([ g.date, g.time, g.expression ], g.generalDelimiter, g.whiteSpace), t.finish); }; g.buildGrammarFormats(); // parsing date format specifiers - ex: "h:m:s tt" // this little guy will generate a custom parser based // on the format string, ex: g.format("h:m:s tt") // check for these formats first g._formats = g.formats([ "\"yyyy-MM-ddTHH:mm:ssZ\"", "yyyy-MM-ddTHH:mm:ss.sz", "yyyy-MM-ddTHH:mm:ssZ", "yyyy-MM-ddTHH:mm:ssz", "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-ddTHH:mmZ", "yyyy-MM-ddTHH:mmz", "yyyy-MM-ddTHH:mm", "ddd, MMM dd, yyyy H:mm:ss tt", "ddd MMM d yyyy HH:mm:ss zzz", "MMddyyyy", "ddMMyyyy", "Mddyyyy", "ddMyyyy", "Mdyyyy", "dMyyyy", "yyyy", "Mdyy", "dMyy", "d" ]); // real starting rule: tries selected formats first, // then general purpose rule g.start = function (s) { try { var r = g._formats.call({}, s); if (r[1].length === 0) { return r; } } catch (e) {} return g._start.call({}, s); }; }()); (function () { var $D = Date; /** * @desc Converts the specified string value into its JavaScript Date equivalent using CultureInfo specific format information. * * Example

	///////////
	// Dates //
	///////////

	// 15-Oct-2004
	var d1 = Date.parse("10/15/2004");

	// 15-Oct-2004
	var d1 = Date.parse("15-Oct-2004");

	// 15-Oct-2004
	var d1 = Date.parse("2004.10.15");

	//Fri Oct 15, 2004
	var d1 = Date.parse("Fri Oct 15, 2004");

	///////////
	// Times //
	///////////

	// Today at 10 PM.
	var d1 = Date.parse("10 PM");

	// Today at 10:30 PM.
	var d1 = Date.parse("10:30 P.M.");

	// Today at 6 AM.
	var d1 = Date.parse("06am");

	/////////////////////
	// Dates and Times //
	/////////////////////

	// 8-July-2004 @ 10:30 PM
	var d1 = Date.parse("July 8th, 2004, 10:30 PM");

	// 1-July-2004 @ 10:30 PM
	var d1 = Date.parse("2004-07-01T22:30:00");

	////////////////////
	// Relative Dates //
	////////////////////

	// Returns today's date. The string "today" is culture specific.
	var d1 = Date.parse("today");

	// Returns yesterday's date. The string "yesterday" is culture specific.
	var d1 = Date.parse("yesterday");

	// Returns the date of the next thursday.
	var d1 = Date.parse("Next thursday");

	// Returns the date of the most previous monday.
	var d1 = Date.parse("last monday");

	// Returns today's day + one year.
	var d1 = Date.parse("next year");

	///////////////
	// Date Math //
	///////////////

	// Today + 2 days
	var d1 = Date.parse("t+2");

	// Today + 2 days
	var d1 = Date.parse("today + 2 days");

	// Today + 3 months
	var d1 = Date.parse("t+3m");

	// Today - 1 year
	var d1 = Date.parse("today - 1 year");

	// Today - 1 year
	var d1 = Date.parse("t-1y"); 


	/////////////////////////////
	// Partial Dates and Times //
	/////////////////////////////

	// July 15th of this year.
	var d1 = Date.parse("July 15");

	// 15th day of current day and year.
	var d1 = Date.parse("15");

	// July 1st of current year at 10pm.
	var d1 = Date.parse("7/1 10pm");
	
* * @param {String} The string value to convert into a Date object [Required] * @return {Date} A Date object or null if the string cannot be converted into a Date. */ var parseUtils = { removeOrds: function (s) { ords = s.match(/\b(\d+)(?:st|nd|rd|th)\b/); // find ordinal matches s = ((ords && ords.length === 2) ? s.replace(ords[0], ords[1]) : s); return s; }, grammarParser: function (s) { var r = null; try { r = $D.Grammar.start.call({}, s.replace(/^\s*(\S*(\s+\S+)*)\s*$/, "$1")); } catch (e) { return null; } return ((r[1].length === 0) ? r[0] : null); }, nativeFallback: function(s) { var t; try { // ok we haven't parsed it, last ditch attempt with the built-in parser. t = Date._parse(s); return (t || t === 0) ? new Date(t) : null; } catch (e) { return null; } } }; function parse (s) { var d; if (!s) { return null; } if (s instanceof Date) { return s.clone(); } if (s.length >= 4 && s.charAt(0) !== "0" && s.charAt(0) !== "+"&& s.charAt(0) !== "-") { // ie: 2004 will pass, 0800 won't. // Start with specific formats d = $D.Parsing.ISO.parse(s) || $D.Parsing.Numeric.parse(s); } if (d instanceof Date && !isNaN(d.getTime())) { return d; } else { // find ordinal dates (1st, 3rd, 8th, etc and remove them as they cause parsing issues) s = $D.Parsing.Normalizer.parse(parseUtils.removeOrds(s)); d = parseUtils.grammarParser(s); if (d !== null) { return d; } else { return parseUtils.nativeFallback(s); } } } if (!$D._parse) { $D._parse = $D.parse; } $D.parse = parse; Date.getParseFunction = function (fx) { var fns = Date.Grammar.allformats(fx); return function (s) { var r = null; for (var i = 0; i < fns.length; i++) { try { r = fns[i].call({}, s); } catch (e) { continue; } if (r[1].length === 0) { return r[0]; } } return null; }; }; /** * Converts the specified string value into its JavaScript Date equivalent using the specified format {String} or formats {Array} and the CultureInfo specific format information. * The format of the string value must match one of the supplied formats exactly. * * Example

	// 15-Oct-2004
	var d1 = Date.parseExact("10/15/2004", "M/d/yyyy");

	// 15-Oct-2004
	var d1 = Date.parse("15-Oct-2004", "M-ddd-yyyy");

	// 15-Oct-2004
	var d1 = Date.parse("2004.10.15", "yyyy.MM.dd");

	// Multiple formats
	var d1 = Date.parseExact("10/15/2004", ["M/d/yyyy", "MMMM d, yyyy"]);
	
* * @param {String} The string value to convert into a Date object [Required]. * @param {Object} The expected format {String} or an array of expected formats {Array} of the date string [Required]. * @return {Date} A Date object or null if the string cannot be converted into a Date. */ $D.parseExact = function (s, fx) { return $D.getParseFunction(fx)(s); }; }()); (function () { var $D = Date, $P = $D.prototype, // $C = $D.CultureInfo, // not used atm p = function (s, l) { if (!l) { l = 2; } return ("000" + s).slice(l * -1); }; /** * Converts a PHP format string to Java/.NET format string. * A PHP format string can be used with ._format or .format. * A Java/.NET format string can be used with .toString(). * The .parseExact function will only accept a Java/.NET format string * * Example * var f1 = "%m/%d/%y" * var f2 = Date.normalizeFormat(f1); // "MM/dd/yy" * * new Date().format(f1); // "04/13/08" * new Date()._format(f1); // "04/13/08" * new Date().toString(f2); // "04/13/08" * * var date = Date.parseExact("04/13/08", f2); // Sun Apr 13 2008 * * @param {String} A PHP format string consisting of one or more format spcifiers. * @return {String} The PHP format converted to a Java/.NET format string. */ var normalizerSubstitutions = { "d" : "dd", "%d": "dd", "D" : "ddd", "%a": "ddd", "j" : "dddd", "l" : "dddd", "%A": "dddd", "S" : "S", "F" : "MMMM", "%B": "MMMM", "m" : "MM", "%m": "MM", "M" : "MMM", "%b": "MMM", "%h": "MMM", "n" : "M", "Y" : "yyyy", "%Y": "yyyy", "y" : "yy", "%y": "yy", "g" : "h", "%I": "h", "G" : "H", "h" : "hh", "H" : "HH", "%H": "HH", "i" : "mm", "%M": "mm", "s" : "ss", "%S": "ss", "%r": "hh:mm tt", "%R": "H:mm", "%T": "H:mm:ss", "%X": "t", "%x": "d", "%e": "d", "%D": "MM/dd/yy", "%n": "\\n", "%t": "\\t", "e" : "z", "T" : "z", "%z": "z", "%Z": "z", "Z" : "ZZ", "N" : "u", "w" : "u", "%w": "u", "W" : "W", "%V": "W" }; var normalizer = { substitutes: function (m) { return normalizerSubstitutions[m]; }, interpreted: function (m, x) { var y; switch (m) { case "%u": return x.getDay() + 1; case "z": return x.getOrdinalNumber(); case "%j": return p(x.getOrdinalNumber(), 3); case "%U": var d1 = x.clone().set({month: 0, day: 1}).addDays(-1).moveToDayOfWeek(0), d2 = x.clone().addDays(1).moveToDayOfWeek(0, -1); return (d2 < d1) ? "00" : p((d2.getOrdinalNumber() - d1.getOrdinalNumber()) / 7 + 1); case "%W": return p(x.getWeek()); case "t": return $D.getDaysInMonth(x.getFullYear(), x.getMonth()); case "o": case "%G": return x.setWeek(x.getISOWeek()).toString("yyyy"); case "%g": return x._format("%G").slice(-2); case "a": case "%p": return t("tt").toLowerCase(); case "A": return t("tt").toUpperCase(); case "u": return p(x.getMilliseconds(), 3); case "I": return (x.isDaylightSavingTime()) ? 1 : 0; case "O": return x.getUTCOffset(); case "P": y = x.getUTCOffset(); return y.substring(0, y.length - 2) + ":" + y.substring(y.length - 2); case "B": var now = new Date(); return Math.floor(((now.getHours() * 3600) + (now.getMinutes() * 60) + now.getSeconds() + (now.getTimezoneOffset() + 60) * 60) / 86.4); case "c": return x.toISOString().replace(/\"/g, ""); case "U": return $D.strtotime("now"); case "%c": return t("d") + " " + t("t"); case "%C": return Math.floor(x.getFullYear() / 100 + 1); } }, shouldOverrideDefaults: function (m) { switch (m) { case "%e": return true; default: return false; } }, parse: function (m, context) { var formatString, c = context || new Date(); formatString = normalizer.substitutes(m); if (formatString) { return formatString; } formatString = normalizer.interpreted(m, c); if (formatString) { return formatString; } else { return m; } } }; $D.normalizeFormat = function (format, context) { return format.replace(/(%|\\)?.|%%/g, function(t){ return normalizer.parse(t, context); }); }; /** * Format a local Unix timestamp according to locale settings * * Example: * Date.strftime("%m/%d/%y", new Date()); // "04/13/08" * Date.strftime("c", "2008-04-13T17:52:03Z"); // "04/13/08" * * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @param {Number|String} The number representing the number of seconds that have elapsed since January 1, 1970 (local time). * @return {String} A string representation of the current Date object. */ $D.strftime = function (format, time) { var d = Date.parse(time); return d._format(format); }; /** * Parse any textual datetime description into a Unix timestamp. * A Unix timestamp is the number of seconds that have elapsed since January 1, 1970 (midnight UTC/GMT). * * Example: * Date.strtotime("04/13/08"); // 1208044800 * Date.strtotime("1970-01-01T00:00:00Z"); // 0 * * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @param {Object} A string or date object. * @return {String} A string representation of the current Date object. */ $D.strtotime = function (time) { var d = $D.parse(time); return Math.round($D.UTC(d.getUTCFullYear(), d.getUTCMonth(), d.getUTCDate(), d.getUTCHours(), d.getUTCMinutes(), d.getUTCSeconds(), d.getUTCMilliseconds()) / 1000); }; /** * Converts the value of the current Date object to its equivalent string representation using a PHP/Unix style of date format specifiers. * Format Specifiers * Format Description Example * ------ --------------------------------------------------------------------------- ----------------------- * %a abbreviated weekday name according to the current localed "Mon" through "Sun" * %A full weekday name according to the current localed "Sunday" through "Saturday" * %b abbreviated month name according to the current localed "Jan" through "Dec" * %B full month name according to the current locale "January" through "December" * %c preferred date and time representation for the current locale "4/13/2008 12:33 PM" * %C century number (the year divided by 100 and truncated to an integer) "00" to "99" * %d day of the month as a decimal number "01" to "31" * %D same as %m/%d/%y "04/13/08" * %e day of the month as a decimal number, a single digit is preceded by a space "1" to "31" * %g like %G, but without the century "08" * %G The 4-digit year corresponding to the ISO week number (see %V). "2008" * This has the same format and value as %Y, except that if the ISO week number * belongs to the previous or next year, that year is used instead. * %h same as %b "Jan" through "Dec" * %H hour as a decimal number using a 24-hour clock. "00" to "23" * %I hour as a decimal number using a 12-hour clock. "01" to "12" * %j day of the year as a decimal number. "001" to "366" * %m month as a decimal number. "01" to "12" * %M minute as a decimal number. "00" to "59" * %n newline character "\n" * %p either "am" or "pm" according to the given time value, or the "am" or "pm" * corresponding strings for the current locale. * %r time in a.m. and p.m. notation "8:44 PM" * %R time in 24 hour notation "20:44" * %S second as a decimal number "00" to "59" * %t tab character "\t" * %T current time, equal to %H:%M:%S "12:49:11" * %u weekday as a decimal number ["1", "7"], with "1" representing Monday "1" to "7" * %U week number of the current year as a decimal number, starting with the "0" to ("52" or "53") * first Sunday as the first day of the first week * %V The ISO 8601:1988 week number of the current year as a decimal number, "00" to ("52" or "53") * range 01 to 53, where week 1 is the first week that has at least 4 days * in the current year, and with Monday as the first day of the week. * (Use %G or %g for the year component that corresponds to the week number * for the specified timestamp.) * %W week number of the current year as a decimal number, starting with the "00" to ("52" or "53") * first Monday as the first day of the first week * %w day of the week as a decimal, Sunday being "0" "0" to "6" * %x preferred date representation for the current locale without the time "4/13/2008" * %X preferred time representation for the current locale without the date "12:53:05" * %y year as a decimal number without a century "00" "99" * %Y year as a decimal number including the century "2008" * %Z time zone or name or abbreviation "UTC", "EST", "PST" * %z same as %Z * %% a literal "%" characters "%" * d Day of the month, 2 digits with leading zeros "01" to "31" * D A textual representation of a day, three letters "Mon" through "Sun" * j Day of the month without leading zeros "1" to "31" * l A full textual representation of the day of the week (lowercase "L") "Sunday" through "Saturday" * N ISO-8601 numeric representation of the day of the week (added in PHP 5.1.0) "1" (for Monday) through "7" (for Sunday) * S English ordinal suffix for the day of the month, 2 characters "st", "nd", "rd" or "th". Works well with j * w Numeric representation of the day of the week "0" (for Sunday) through "6" (for Saturday) * z The day of the year (starting from "0") "0" through "365" * W ISO-8601 week number of year, weeks starting on Monday "00" to ("52" or "53") * F A full textual representation of a month, such as January or March "January" through "December" * m Numeric representation of a month, with leading zeros "01" through "12" * M A short textual representation of a month, three letters "Jan" through "Dec" * n Numeric representation of a month, without leading zeros "1" through "12" * t Number of days in the given month "28" through "31" * L Whether it's a leap year "1" if it is a leap year, "0" otherwise * o ISO-8601 year number. This has the same value as Y, except that if the "2008" * ISO week number (W) belongs to the previous or next year, that year * is used instead. * Y A full numeric representation of a year, 4 digits "2008" * y A two digit representation of a year "08" * a Lowercase Ante meridiem and Post meridiem "am" or "pm" * A Uppercase Ante meridiem and Post meridiem "AM" or "PM" * B Swatch Internet time "000" through "999" * g 12-hour format of an hour without leading zeros "1" through "12" * G 24-hour format of an hour without leading zeros "0" through "23" * h 12-hour format of an hour with leading zeros "01" through "12" * H 24-hour format of an hour with leading zeros "00" through "23" * i Minutes with leading zeros "00" to "59" * s Seconds, with leading zeros "00" through "59" * u Milliseconds "54321" * e Timezone identifier "UTC", "EST", "PST" * I Whether or not the date is in daylight saving time (uppercase i) "1" if Daylight Saving Time, "0" otherwise * O Difference to Greenwich time (GMT) in hours "+0200", "-0600" * P Difference to Greenwich time (GMT) with colon between hours and minutes "+02:00", "-06:00" * T Timezone abbreviation "UTC", "EST", "PST" * Z Timezone offset in seconds. The offset for timezones west of UTC is "-43200" through "50400" * always negative, and for those east of UTC is always positive. * c ISO 8601 date "2004-02-12T15:19:21+00:00" * r RFC 2822 formatted date "Thu, 21 Dec 2000 16:01:07 +0200" * U Seconds since the Unix Epoch (January 1 1970 00:00:00 GMT) "0" * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @return {String} A string representation of the current Date object. */ var formatReplace = function (context) { return function (m) { var formatString, override = false; if (m.charAt(0) === "\\" || m.substring(0, 2) === "%%") { return m.replace("\\", "").replace("%%", "%"); } override = normalizer.shouldOverrideDefaults(m); formatString = $D.normalizeFormat(m, context); if (formatString) { return context.toString(formatString, override); } }; }; $P._format = function (format) { var formatter = formatReplace(this); if (!format) { return this._toString(); } else { return format.replace(/(%|\\)?.|%%/g, formatter); } }; if (!$P.format) { $P.format = $P._format; } }()); (function () { "use strict"; var gFn = function (attr) { return function () { return this[attr]; }; }; var sFn = function (attr) { return function (val) { this[attr] = val; return this; }; }; var attrs = ["years", "months", "days", "hours", "minutes", "seconds", "milliseconds"]; var addSetFuncs = function (context, attrs) { for (var i = 0; i < attrs.length ; i++) { var $a = attrs[i], $b = $a.slice(0, 1).toUpperCase() + $a.slice(1); context.prototype[$a] = 0; context.prototype["get" + $b] = gFn($a); context.prototype["set" + $b] = sFn($a); } }; /** * new TimeSpan(milliseconds); * new TimeSpan(days, hours, minutes, seconds); * new TimeSpan(days, hours, minutes, seconds, milliseconds); */ var TimeSpan = function (days, hours, minutes, seconds, milliseconds) { if (arguments.length === 1 && typeof days === "number") { var orient = (days < 0) ? -1 : +1; var millsLeft = Math.abs(days); this.setDays(Math.floor(millsLeft / 86400000) * orient); millsLeft = millsLeft % 86400000; this.setHours(Math.floor(millsLeft / 3600000) * orient); millsLeft = millsLeft % 3600000; this.setMinutes(Math.floor(millsLeft / 60000) * orient); millsLeft = millsLeft % 60000; this.setSeconds(Math.floor(millsLeft / 1000) * orient); millsLeft = millsLeft % 1000; this.setMilliseconds(millsLeft * orient); } else { this.set(days, hours, minutes, seconds, milliseconds); } this.getTotalMilliseconds = function () { return (this.getDays() * 86400000) + (this.getHours() * 3600000) + (this.getMinutes() * 60000) + (this.getSeconds() * 1000); }; this.compareTo = function (time) { var t1 = new Date(1970, 1, 1, this.getHours(), this.getMinutes(), this.getSeconds()), t2; if (time === null) { t2 = new Date(1970, 1, 1, 0, 0, 0); } else { t2 = new Date(1970, 1, 1, time.getHours(), time.getMinutes(), time.getSeconds()); } return (t1 < t2) ? -1 : (t1 > t2) ? 1 : 0; }; this.equals = function (time) { return (this.compareTo(time) === 0); }; this.add = function (time) { return (time === null) ? this : this.addSeconds(time.getTotalMilliseconds() / 1000); }; this.subtract = function (time) { return (time === null) ? this : this.addSeconds(-time.getTotalMilliseconds() / 1000); }; this.addDays = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 86400000)); }; this.addHours = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 3600000)); }; this.addMinutes = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 60000)); }; this.addSeconds = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 1000)); }; this.addMilliseconds = function (n) { return new TimeSpan(this.getTotalMilliseconds() + n); }; this.get12HourHour = function () { return (this.getHours() > 12) ? this.getHours() - 12 : (this.getHours() === 0) ? 12 : this.getHours(); }; this.getDesignator = function () { return (this.getHours() < 12) ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator; }; this.toString = function (format) { this._toString = function () { if (this.getDays() !== null && this.getDays() > 0) { return this.getDays() + "." + this.getHours() + ":" + this.p(this.getMinutes()) + ":" + this.p(this.getSeconds()); } else { return this.getHours() + ":" + this.p(this.getMinutes()) + ":" + this.p(this.getSeconds()); } }; this.p = function (s) { return (s.toString().length < 2) ? "0" + s : s; }; var me = this; return format ? format.replace(/dd?|HH?|hh?|mm?|ss?|tt?/g, function (format) { switch (format) { case "d": return me.getDays(); case "dd": return me.p(me.getDays()); case "H": return me.getHours(); case "HH": return me.p(me.getHours()); case "h": return me.get12HourHour(); case "hh": return me.p(me.get12HourHour()); case "m": return me.getMinutes(); case "mm": return me.p(me.getMinutes()); case "s": return me.getSeconds(); case "ss": return me.p(me.getSeconds()); case "t": return ((me.getHours() < 12) ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator).substring(0, 1); case "tt": return (me.getHours() < 12) ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator; } } ) : this._toString(); }; return this; }; addSetFuncs(TimeSpan, attrs.slice(2)); TimeSpan.prototype.set = function (days, hours, minutes, seconds, milliseconds){ this.setDays(days || this.getDays()); this.setHours(hours || this.getHours()); this.setMinutes(minutes || this.getMinutes()); this.setSeconds(seconds || this.getSeconds()); this.setMilliseconds(milliseconds || this.getMilliseconds()); }; /** * Gets the time of day for this date instances. * @return {TimeSpan} TimeSpan */ Date.prototype.getTimeOfDay = function () { return new TimeSpan(0, this.getHours(), this.getMinutes(), this.getSeconds(), this.getMilliseconds()); }; Date.TimeSpan = TimeSpan; if (typeof window !== "undefined" ) { // keeping API compatible for v1.x window.TimeSpan = TimeSpan; } }()); (function () { "use strict"; var attrs = ["years", "months", "days", "hours", "minutes", "seconds", "milliseconds"]; var gFn = function (attr) { return function () { return this[attr]; }; }; var sFn = function (attr) { return function (val) { this[attr] = val; return this; }; }; var addSetFuncs = function (context, attrs) { for (var i = 0; i < attrs.length ; i++) { var $a = attrs[i], $b = $a.slice(0, 1).toUpperCase() + $a.slice(1); context.prototype[$a] = 0; context.prototype["get" + $b] = gFn($a); context.prototype["set" + $b] = sFn($a); } }; var setMonthsAndYears = function (orient, d1, d2, context) { function inc() { d1.addMonths(-orient); context.months++; if (context.months === 12) { context.years++; context.months = 0; } } if (orient === +1) { while (d1 > d2) { inc(); } } else { while (d1 < d2) { inc(); } } context.months--; context.months *= orient; context.years *= orient; }; var adjustForDST = function(orient, startDate, endDate) { var hasDSTMismatch = (false === (startDate.isDaylightSavingTime() === endDate.isDaylightSavingTime())); if (hasDSTMismatch && orient === 1) { startDate.addHours(-1); } else if (hasDSTMismatch) { startDate.addHours(1); } }; /** * TimePeriod(startDate, endDate); * TimePeriod(years, months, days, hours, minutes, seconds, milliseconds); */ var TimePeriod = function (years, months, days, hours, minutes, seconds, milliseconds) { if (arguments.length === 7) { this.set(years, months, days, hours, minutes, seconds, milliseconds); } else if (arguments.length === 2 && arguments[0] instanceof Date && arguments[1] instanceof Date) { var startDate = arguments[0].clone(); var endDate = arguments[1].clone(); var orient = (startDate > endDate) ? +1 : -1; this.dates = { start: arguments[0].clone(), end: arguments[1].clone() }; setMonthsAndYears(orient, startDate, endDate, this); adjustForDST(orient, startDate, endDate); // // TODO - adjust for DST var diff = endDate - startDate; if (diff !== 0) { var ts = new TimeSpan(diff); this.set(this.years, this.months, ts.getDays(), ts.getHours(), ts.getMinutes(), ts.getSeconds(), ts.getMilliseconds()); } } return this; }; // create all the set functions. addSetFuncs(TimePeriod, attrs); TimePeriod.prototype.set = function (years, months, days, hours, minutes, seconds, milliseconds){ this.setYears(years || this.getYears()); this.setMonths(months || this.getMonths()); this.setDays(days || this.getDays()); this.setHours(hours || this.getHours()); this.setMinutes(minutes || this.getMinutes()); this.setSeconds(seconds || this.getSeconds()); this.setMilliseconds(milliseconds || this.getMilliseconds()); }; Date.TimePeriod = TimePeriod; if (typeof window !== "undefined") { // keeping API compatible for v1.x window.TimePeriod = TimePeriod; } }()); ================================================ FILE: build/date-es-PA.js ================================================ /** * @overview datejs * @version 1.0.0-rc3 * @author Gregory Wild-Smith * @copyright 2015 Gregory Wild-Smith * @license MIT * @homepage https://github.com/abritinthebay/datejs */ /* * DateJS Culture String File * Country Code: es-PA * Name: Spanish (Panama) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["es-PA"] = { "name": "es-PA", "englishName": "Spanish (Panama)", "nativeName": "Español (Panamá)", "Sunday": "domingo", "Monday": "lunes", "Tuesday": "martes", "Wednesday": "miércoles", "Thursday": "jueves", "Friday": "viernes", "Saturday": "sábado", "Sun": "dom", "Mon": "lun", "Tue": "mar", "Wed": "mié", "Thu": "jue", "Fri": "vie", "Sat": "sáb", "Su": "do", "Mo": "lu", "Tu": "ma", "We": "mi", "Th": "ju", "Fr": "vi", "Sa": "sá", "S_Sun_Initial": "d", "M_Mon_Initial": "l", "T_Tue_Initial": "m", "W_Wed_Initial": "m", "T_Thu_Initial": "j", "F_Fri_Initial": "v", "S_Sat_Initial": "s", "January": "enero", "February": "febrero", "March": "marzo", "April": "abril", "May": "mayo", "June": "junio", "July": "julio", "August": "agosto", "September": "septiembre", "October": "octubre", "November": "noviembre", "December": "diciembre", "Jan_Abbr": "ene", "Feb_Abbr": "feb", "Mar_Abbr": "mar", "Apr_Abbr": "abr", "May_Abbr": "may", "Jun_Abbr": "jun", "Jul_Abbr": "jul", "Aug_Abbr": "ago", "Sep_Abbr": "sep", "Oct_Abbr": "oct", "Nov_Abbr": "nov", "Dec_Abbr": "dic", "AM": "a.m.", "PM": "p.m.", "firstDayOfWeek": 0, "twoDigitYearMax": 2029, "mdy": "mdy", "M/d/yyyy": "MM/dd/yyyy", "dddd, MMMM dd, yyyy": "dddd, dd' [de] 'MMMM' [de] 'yyyy", "h:mm tt": "hh:mm tt", "h:mm:ss tt": "hh:mm:ss tt", "dddd, MMMM dd, yyyy h:mm:ss tt": "dddd, dd' [de] 'MMMM' [de] 'yyyy hh:mm:ss tt", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "dd MMMM", "MMMM, yyyy": "MMMM' [de] 'yyyy", "/jan(uary)?/": "ene(ro)?", "/feb(ruary)?/": "feb(rero)?", "/mar(ch)?/": "mar(zo)?", "/apr(il)?/": "abr(il)?", "/may/": "may(o)?", "/jun(e)?/": "jun(io)?", "/jul(y)?/": "jul(io)?", "/aug(ust)?/": "ago(sto)?", "/sep(t(ember)?)?/": "sep(tiembre)?", "/oct(ober)?/": "oct(ubre)?", "/nov(ember)?/": "nov(iembre)?", "/dec(ember)?/": "dic(iembre)?", "/^su(n(day)?)?/": "^do(m(ingo)?)?", "/^mo(n(day)?)?/": "^lu(n(es)?)?", "/^tu(e(s(day)?)?)?/": "^ma(r(tes)?)?", "/^we(d(nesday)?)?/": "^mi(é(rcoles)?)?", "/^th(u(r(s(day)?)?)?)?/": "^ju(e(ves)?)?", "/^fr(i(day)?)?/": "^vi(e(rnes)?)?", "/^sa(t(urday)?)?/": "^sá(b(ado)?)?", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "es-PA"; /** * @overview datejs * @version 1.0.0-rc3 * @author Gregory Wild-Smith * @copyright 2015 Gregory Wild-Smith * @license MIT * @homepage https://github.com/abritinthebay/datejs */(function () { var $D = Date; var lang = Date.CultureStrings ? Date.CultureStrings.lang : null; var loggedKeys = {}; // for debug purposes. var getText = { getFromKey: function (key, countryCode) { var output; if (Date.CultureStrings && Date.CultureStrings[countryCode] && Date.CultureStrings[countryCode][key]) { output = Date.CultureStrings[countryCode][key]; } else { output = getText.buildFromDefault(key); } if (key.charAt(0) === "/") { // Assume it's a regex output = getText.buildFromRegex(key, countryCode); } return output; }, getFromObjectValues: function (obj, countryCode) { var key, output = {}; for(key in obj) { if (obj.hasOwnProperty(key)) { output[key] = getText.getFromKey(obj[key], countryCode); } } return output; }, getFromObjectKeys: function (obj, countryCode) { var key, output = {}; for(key in obj) { if (obj.hasOwnProperty(key)) { output[getText.getFromKey(key, countryCode)] = obj[key]; } } return output; }, getFromArray: function (arr, countryCode) { var output = []; for (var i=0; i < arr.length; i++){ if (i in arr) { output[i] = getText.getFromKey(arr[i], countryCode); } } return output; }, buildFromDefault: function (key) { var output, length, split, last; switch(key) { case "name": output = "en-US"; break; case "englishName": output = "English (United States)"; break; case "nativeName": output = "English (United States)"; break; case "twoDigitYearMax": output = 2049; break; case "firstDayOfWeek": output = 0; break; default: output = key; split = key.split("_"); length = split.length; if (length > 1 && key.charAt(0) !== "/") { // if the key isn't a regex and it has a split. last = split[(length - 1)].toLowerCase(); if (last === "initial" || last === "abbr") { output = split[0]; } } break; } return output; }, buildFromRegex: function (key, countryCode) { var output; if (Date.CultureStrings && Date.CultureStrings[countryCode] && Date.CultureStrings[countryCode][key]) { output = new RegExp(Date.CultureStrings[countryCode][key], "i"); } else { output = new RegExp(key.replace(new RegExp("/", "g"),""), "i"); } return output; } }; var shallowMerge = function (obj1, obj2) { for (var attrname in obj2) { if (obj2.hasOwnProperty(attrname)) { obj1[attrname] = obj2[attrname]; } } }; var __ = function (key, language) { var countryCode = (language) ? language : lang; loggedKeys[key] = key; if (typeof key === "object") { if (key instanceof Array) { return getText.getFromArray(key, countryCode); } else { return getText.getFromObjectKeys(key, countryCode); } } else { return getText.getFromKey(key, countryCode); } }; var loadI18nScript = function (code) { // paatterned after jQuery's getScript. var url = Date.Config.i18n + code + ".js"; var head = document.getElementsByTagName("head")[0] || document.documentElement; var script = document.createElement("script"); script.src = url; var completed = false; var events = { done: function (){} // placeholder function }; // Attach handlers for all browsers script.onload = script.onreadystatechange = function() { if ( !completed && (!this.readyState || this.readyState === "loaded" || this.readyState === "complete") ) { events.done(); head.removeChild(script); } }; setTimeout(function() { head.insertBefore(script, head.firstChild); }, 0); // allows return to execute first return { done: function (cb) { events.done = function() { if (cb) { setTimeout(cb,0); } }; } }; }; var buildInfo = { buildFromMethodHash: function (obj) { var key; for(key in obj) { if (obj.hasOwnProperty(key)) { obj[key] = buildInfo[obj[key]](); } } return obj; }, timeZoneDST: function () { var DST = { "CHADT": "+1345", "NZDT": "+1300", "AEDT": "+1100", "ACDT": "+1030", "AZST": "+0500", "IRDT": "+0430", "EEST": "+0300", "CEST": "+0200", "BST": "+0100", "PMDT": "-0200", "ADT": "-0300", "NDT": "-0230", "EDT": "-0400", "CDT": "-0500", "MDT": "-0600", "PDT": "-0700", "AKDT": "-0800", "HADT": "-0900" }; return __(DST); }, timeZoneStandard: function () { var standard = { "LINT": "+1400", "TOT": "+1300", "CHAST": "+1245", "NZST": "+1200", "NFT": "+1130", "SBT": "+1100", "AEST": "+1000", "ACST": "+0930", "JST": "+0900", "CWST": "+0845", "CT": "+0800", "ICT": "+0700", "MMT": "+0630", "BST": "+0600", "NPT": "+0545", "IST": "+0530", "PKT": "+0500", "AFT": "+0430", "MSK": "+0400", "IRST": "+0330", "FET": "+0300", "EET": "+0200", "CET": "+0100", "GMT": "+0000", "UTC": "+0000", "CVT": "-0100", "GST": "-0200", "BRT": "-0300", "NST": "-0330", "AST": "-0400", "EST": "-0500", "CST": "-0600", "MST": "-0700", "PST": "-0800", "AKST": "-0900", "MIT": "-0930", "HST": "-1000", "SST": "-1100", "BIT": "-1200" }; return __(standard); }, timeZones: function (data) { var zone; data.timezones = []; for (zone in data.abbreviatedTimeZoneStandard) { if (data.abbreviatedTimeZoneStandard.hasOwnProperty(zone)) { data.timezones.push({ name: zone, offset: data.abbreviatedTimeZoneStandard[zone]}); } } for (zone in data.abbreviatedTimeZoneDST) { if (data.abbreviatedTimeZoneDST.hasOwnProperty(zone)) { data.timezones.push({ name: zone, offset: data.abbreviatedTimeZoneDST[zone], dst: true}); } } return data.timezones; }, days: function () { return __(["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"]); }, dayAbbr: function () { return __(["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"]); }, dayShortNames: function () { return __(["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"]); }, dayFirstLetters: function () { return __(["S_Sun_Initial", "M_Mon_Initial", "T_Tues_Initial", "W_Wed_Initial", "T_Thu_Initial", "F_Fri_Initial", "S_Sat_Initial"]); }, months: function () { return __(["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"]); }, monthAbbr: function () { return __(["Jan_Abbr", "Feb_Abbr", "Mar_Abbr", "Apr_Abbr", "May_Abbr", "Jun_Abbr", "Jul_Abbr", "Aug_Abbr", "Sep_Abbr", "Oct_Abbr", "Nov_Abbr", "Dec_Abbr"]); }, formatPatterns: function () { return getText.getFromObjectValues({ shortDate: "M/d/yyyy", longDate: "dddd, MMMM dd, yyyy", shortTime: "h:mm tt", longTime: "h:mm:ss tt", fullDateTime: "dddd, MMMM dd, yyyy h:mm:ss tt", sortableDateTime: "yyyy-MM-ddTHH:mm:ss", universalSortableDateTime: "yyyy-MM-dd HH:mm:ssZ", rfc1123: "ddd, dd MMM yyyy HH:mm:ss", monthDay: "MMMM dd", yearMonth: "MMMM, yyyy" }, Date.i18n.currentLanguage()); }, regex: function () { return getText.getFromObjectValues({ inTheMorning: "/( in the )(morn(ing)?)\\b/", thisMorning: "/(this )(morn(ing)?)\\b/", amThisMorning: "/(\b\\d(am)? )(this )(morn(ing)?)/", inTheEvening: "/( in the )(even(ing)?)\\b/", thisEvening: "/(this )(even(ing)?)\\b/", pmThisEvening: "/(\b\\d(pm)? )(this )(even(ing)?)/", jan: "/jan(uary)?/", feb: "/feb(ruary)?/", mar: "/mar(ch)?/", apr: "/apr(il)?/", may: "/may/", jun: "/jun(e)?/", jul: "/jul(y)?/", aug: "/aug(ust)?/", sep: "/sep(t(ember)?)?/", oct: "/oct(ober)?/", nov: "/nov(ember)?/", dec: "/dec(ember)?/", sun: "/^su(n(day)?)?/", mon: "/^mo(n(day)?)?/", tue: "/^tu(e(s(day)?)?)?/", wed: "/^we(d(nesday)?)?/", thu: "/^th(u(r(s(day)?)?)?)?/", fri: "/fr(i(day)?)?/", sat: "/^sa(t(urday)?)?/", future: "/^next/", past: "/^last|past|prev(ious)?/", add: "/^(\\+|aft(er)?|from|hence)/", subtract: "/^(\\-|bef(ore)?|ago)/", yesterday: "/^yes(terday)?/", today: "/^t(od(ay)?)?/", tomorrow: "/^tom(orrow)?/", now: "/^n(ow)?/", millisecond: "/^ms|milli(second)?s?/", second: "/^sec(ond)?s?/", minute: "/^mn|min(ute)?s?/", hour: "/^h(our)?s?/", week: "/^w(eek)?s?/", month: "/^m(onth)?s?/", day: "/^d(ay)?s?/", year: "/^y(ear)?s?/", shortMeridian: "/^(a|p)/", longMeridian: "/^(a\\.?m?\\.?|p\\.?m?\\.?)/", timezone: "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/", ordinalSuffix: "/^\\s*(st|nd|rd|th)/", timeContext: "/^\\s*(\\:|a(?!u|p)|p)/" }, Date.i18n.currentLanguage()); } }; var CultureInfo = function () { var info = getText.getFromObjectValues({ name: "name", englishName: "englishName", nativeName: "nativeName", amDesignator: "AM", pmDesignator: "PM", firstDayOfWeek: "firstDayOfWeek", twoDigitYearMax: "twoDigitYearMax", dateElementOrder: "mdy" }, Date.i18n.currentLanguage()); var constructedInfo = buildInfo.buildFromMethodHash({ dayNames: "days", abbreviatedDayNames: "dayAbbr", shortestDayNames: "dayShortNames", firstLetterDayNames: "dayFirstLetters", monthNames: "months", abbreviatedMonthNames: "monthAbbr", formatPatterns: "formatPatterns", regexPatterns: "regex", abbreviatedTimeZoneDST: "timeZoneDST", abbreviatedTimeZoneStandard: "timeZoneStandard" }); shallowMerge(info, constructedInfo); buildInfo.timeZones(info); return info; }; $D.i18n = { __: function (key, lang) { return __(key, lang); }, currentLanguage: function () { return lang || "en-US"; }, setLanguage: function (code, force, cb) { var async = false; if (force || code === "en-US" || (!!Date.CultureStrings && !!Date.CultureStrings[code])) { lang = code; Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings.lang = code; Date.CultureInfo = new CultureInfo(); } else { if (!(!!Date.CultureStrings && !!Date.CultureStrings[code])) { if (typeof exports !== "undefined" && this.exports !== exports) { // we're in a Node enviroment, load it using require try { require("../i18n/" + code + ".js"); lang = code; Date.CultureStrings.lang = code; Date.CultureInfo = new CultureInfo(); } catch (e) { // var str = "The language for '" + code + "' could not be loaded by Node. It likely does not exist."; throw new Error("The DateJS IETF language tag '" + code + "' could not be loaded by Node. It likely does not exist."); } } else if (Date.Config && Date.Config.i18n) { // we know the location of the files, so lets load them async = true; loadI18nScript(code).done(function(){ lang = code; Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings.lang = code; Date.CultureInfo = new CultureInfo(); $D.Parsing.Normalizer.buildReplaceData(); // because this is async if ($D.Grammar) { $D.Grammar.buildGrammarFormats(); // so we can parse those strings... } if (cb) { setTimeout(cb,0); } }); } else { Date.console.error("The DateJS IETF language tag '" + code + "' is not available and has not been loaded."); return false; } } } $D.Parsing.Normalizer.buildReplaceData(); // rebuild normalizer strings if ($D.Grammar) { $D.Grammar.buildGrammarFormats(); // so we can parse those strings... } if (!async && cb) { setTimeout(cb,0); } }, getLoggedKeys: function () { return loggedKeys; }, updateCultureInfo: function () { Date.CultureInfo = new CultureInfo(); } }; $D.i18n.updateCultureInfo(); // run automatically }()); (function () { var $D = Date, $P = $D.prototype, p = function (s, l) { if (!l) { l = 2; } return ("000" + s).slice(l * -1); }; if (typeof window !== "undefined" && typeof window.console !== "undefined" && typeof window.console.log !== "undefined") { $D.console = console; // used only to raise non-critical errors if available } else { // set mock so we don't give errors. $D.console = { log: function(){}, error: function(){} }; } $D.Config = $D.Config || {}; $D.initOverloads = function() { /** * Overload of Date.now. Allows an alternate call for Date.now where it returns the * current Date as an object rather than just milliseconds since the Unix Epoch. * * Also provides an implementation of now() for browsers (IE<9) that don't have it. * * Backwards compatible so with work with either: * Date.now() [returns ms] * or * Date.now(true) [returns Date] */ if (!$D.now) { $D._now = function now() { return new Date().getTime(); }; } else if (!$D._now) { $D._now = $D.now; } $D.now = function (returnObj) { if (returnObj) { return $D.present(); } else { return $D._now(); } }; if ( !$P.toISOString ) { $P.toISOString = function() { return this.getUTCFullYear() + "-" + p(this.getUTCMonth() + 1) + "-" + p(this.getUTCDate()) + "T" + p(this.getUTCHours()) + ":" + p(this.getUTCMinutes()) + ":" + p(this.getUTCSeconds()) + "." + String( (this.getUTCMilliseconds()/1000).toFixed(3)).slice(2, 5) + "Z"; }; } // private if ( $P._toString === undefined ){ $P._toString = $P.toString; } }; $D.initOverloads(); /** * Gets a date that is set to the current date. The time is set to the start of the day (00:00 or 12:00 AM). * @return {Date} The current date. */ $D.today = function () { return new Date().clearTime(); }; /** * Gets a date that is set to the current date and time (same as new Date, but chainable) * @return {Date} The current date. */ $D.present = function () { return new Date(); }; /** * Compares the first date to the second date and returns an number indication of their relative values. * @param {Date} First Date object to compare [Required]. * @param {Date} Second Date object to compare to [Required]. * @return {Number} -1 = date1 is lessthan date2. 0 = values are equal. 1 = date1 is greaterthan date2. */ $D.compare = function (date1, date2) { if (isNaN(date1) || isNaN(date2)) { throw new Error(date1 + " - " + date2); } else if (date1 instanceof Date && date2 instanceof Date) { return (date1 < date2) ? -1 : (date1 > date2) ? 1 : 0; } else { throw new TypeError(date1 + " - " + date2); } }; /** * Compares the first Date object to the second Date object and returns true if they are equal. * @param {Date} First Date object to compare [Required] * @param {Date} Second Date object to compare to [Required] * @return {Boolean} true if dates are equal. false if they are not equal. */ $D.equals = function (date1, date2) { return (date1.compareTo(date2) === 0); }; /** * Gets the language appropriate day name when given the day number(0-6) * eg - 0 == Sunday * @return {String} The day name */ $D.getDayName = function (n) { return Date.CultureInfo.dayNames[n]; }; /** * Gets the day number (0-6) if given a CultureInfo specific string which is a valid dayName, abbreviatedDayName or shortestDayName (two char). * @param {String} The name of the day (eg. "Monday, "Mon", "tuesday", "tue", "We", "we"). * @return {Number} The day number */ $D.getDayNumberFromName = function (name) { var n = Date.CultureInfo.dayNames, m = Date.CultureInfo.abbreviatedDayNames, o = Date.CultureInfo.shortestDayNames, s = name.toLowerCase(); for (var i = 0; i < n.length; i++) { if (n[i].toLowerCase() === s || m[i].toLowerCase() === s || o[i].toLowerCase() === s) { return i; } } return -1; }; /** * Gets the month number (0-11) if given a Culture Info specific string which is a valid monthName or abbreviatedMonthName. * @param {String} The name of the month (eg. "February, "Feb", "october", "oct"). * @return {Number} The day number */ $D.getMonthNumberFromName = function (name) { var n = Date.CultureInfo.monthNames, m = Date.CultureInfo.abbreviatedMonthNames, s = name.toLowerCase(); for (var i = 0; i < n.length; i++) { if (n[i].toLowerCase() === s || m[i].toLowerCase() === s) { return i; } } return -1; }; /** * Gets the language appropriate month name when given the month number(0-11) * eg - 0 == January * @return {String} The month name */ $D.getMonthName = function (n) { return Date.CultureInfo.monthNames[n]; }; /** * Determines if the current date instance is within a LeapYear. * @param {Number} The year. * @return {Boolean} true if date is within a LeapYear, otherwise false. */ $D.isLeapYear = function (year) { return ((year % 4 === 0 && year % 100 !== 0) || year % 400 === 0); }; /** * Gets the number of days in the month, given a year and month value. Automatically corrects for LeapYear. * @param {Number} The year. * @param {Number} The month (0-11). * @return {Number} The number of days in the month. */ $D.getDaysInMonth = function (year, month) { if (!month && $D.validateMonth(year)) { month = year; year = Date.today().getFullYear(); } return [31, ($D.isLeapYear(year) ? 29 : 28), 31, 30, 31, 30, 31, 31, 30, 31, 30, 31][month]; }; $P.getDaysInMonth = function () { return $D.getDaysInMonth(this.getFullYear(), this.getMonth()); }; $D.getTimezoneAbbreviation = function (offset, dst) { var p, n = (dst || false) ? Date.CultureInfo.abbreviatedTimeZoneDST : Date.CultureInfo.abbreviatedTimeZoneStandard; for (p in n) { if (n.hasOwnProperty(p)) { if (n[p] === offset) { return p; } } } return null; }; $D.getTimezoneOffset = function (name, dst) { var i, a =[], z = Date.CultureInfo.timezones; if (!name) { name = (new Date()).getTimezone();} for (i = 0; i < z.length; i++) { if (z[i].name === name.toUpperCase()) { a.push(i); } } if (!z[a[0]]) { return null; } if (a.length === 1 || !dst) { return z[a[0]].offset; } else { for (i=0; i < a.length; i++) { if (z[a[i]].dst) { return z[a[i]].offset; } } } }; $D.getQuarter = function (d) { d = d || new Date(); // If no date supplied, use today var q = [1,2,3,4]; return q[Math.floor(d.getMonth() / 3)]; // ~~~ is a bitwise op. Faster than Math.floor }; $D.getDaysLeftInQuarter = function (d) { d = d || new Date(); var qEnd = new Date(d); qEnd.setMonth(qEnd.getMonth() + 3 - qEnd.getMonth() % 3, 0); return Math.floor((qEnd - d) / 8.64e7); }; // private var validate = function (n, min, max, name) { name = name ? name : "Object"; if (typeof n === "undefined") { return false; } else if (typeof n !== "number") { throw new TypeError(n + " is not a Number."); } else if (n < min || n > max) { // As failing validation is *not* an exceptional circumstance // lets not throw a RangeError Exception here. // It's semantically correct but it's not sensible. return false; } return true; }; /** * Validates the number is within an acceptable range for milliseconds [0-999]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateMillisecond = function (value) { return validate(value, 0, 999, "millisecond"); }; /** * Validates the number is within an acceptable range for seconds [0-59]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateSecond = function (value) { return validate(value, 0, 59, "second"); }; /** * Validates the number is within an acceptable range for minutes [0-59]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateMinute = function (value) { return validate(value, 0, 59, "minute"); }; /** * Validates the number is within an acceptable range for hours [0-23]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateHour = function (value) { return validate(value, 0, 23, "hour"); }; /** * Validates the number is within an acceptable range for the days in a month [0-MaxDaysInMonth]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateDay = function (value, year, month) { if (year === undefined || year === null || month === undefined || month === null) { return false;} return validate(value, 1, $D.getDaysInMonth(year, month), "day"); }; /** * Validates the number is within an acceptable range for months [0-11]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateWeek = function (value) { return validate(value, 0, 53, "week"); }; /** * Validates the number is within an acceptable range for months [0-11]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateMonth = function (value) { return validate(value, 0, 11, "month"); }; /** * Validates the number is within an acceptable range for years. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateYear = function (value) { /** * Per ECMAScript spec the range of times supported by Date objects is * exactly -100,000,000 days to +100,000,000 days measured relative to * midnight at the beginning of 01 January, 1970 UTC. * This gives a range of 8,640,000,000,000,000 milliseconds to either * side of 01 January, 1970 UTC. * * Earliest possible date: Tue, 20 Apr 271,822 B.C. 00:00:00 UTC * Latest possible date: Sat, 13 Sep 275,760 00:00:00 UTC */ return validate(value, -271822, 275760, "year"); }; $D.validateTimezone = function(value) { var timezones = {"ACDT":1,"ACST":1,"ACT":1,"ADT":1,"AEDT":1,"AEST":1,"AFT":1,"AKDT":1,"AKST":1,"AMST":1,"AMT":1,"ART":1,"AST":1,"AWDT":1,"AWST":1,"AZOST":1,"AZT":1,"BDT":1,"BIOT":1,"BIT":1,"BOT":1,"BRT":1,"BST":1,"BTT":1,"CAT":1,"CCT":1,"CDT":1,"CEDT":1,"CEST":1,"CET":1,"CHADT":1,"CHAST":1,"CHOT":1,"ChST":1,"CHUT":1,"CIST":1,"CIT":1,"CKT":1,"CLST":1,"CLT":1,"COST":1,"COT":1,"CST":1,"CT":1,"CVT":1,"CWST":1,"CXT":1,"DAVT":1,"DDUT":1,"DFT":1,"EASST":1,"EAST":1,"EAT":1,"ECT":1,"EDT":1,"EEDT":1,"EEST":1,"EET":1,"EGST":1,"EGT":1,"EIT":1,"EST":1,"FET":1,"FJT":1,"FKST":1,"FKT":1,"FNT":1,"GALT":1,"GAMT":1,"GET":1,"GFT":1,"GILT":1,"GIT":1,"GMT":1,"GST":1,"GYT":1,"HADT":1,"HAEC":1,"HAST":1,"HKT":1,"HMT":1,"HOVT":1,"HST":1,"ICT":1,"IDT":1,"IOT":1,"IRDT":1,"IRKT":1,"IRST":1,"IST":1,"JST":1,"KGT":1,"KOST":1,"KRAT":1,"KST":1,"LHST":1,"LINT":1,"MAGT":1,"MART":1,"MAWT":1,"MDT":1,"MET":1,"MEST":1,"MHT":1,"MIST":1,"MIT":1,"MMT":1,"MSK":1,"MST":1,"MUT":1,"MVT":1,"MYT":1,"NCT":1,"NDT":1,"NFT":1,"NPT":1,"NST":1,"NT":1,"NUT":1,"NZDT":1,"NZST":1,"OMST":1,"ORAT":1,"PDT":1,"PET":1,"PETT":1,"PGT":1,"PHOT":1,"PHT":1,"PKT":1,"PMDT":1,"PMST":1,"PONT":1,"PST":1,"PYST":1,"PYT":1,"RET":1,"ROTT":1,"SAKT":1,"SAMT":1,"SAST":1,"SBT":1,"SCT":1,"SGT":1,"SLST":1,"SRT":1,"SST":1,"SYOT":1,"TAHT":1,"THA":1,"TFT":1,"TJT":1,"TKT":1,"TLT":1,"TMT":1,"TOT":1,"TVT":1,"UCT":1,"ULAT":1,"UTC":1,"UYST":1,"UYT":1,"UZT":1,"VET":1,"VLAT":1,"VOLT":1,"VOST":1,"VUT":1,"WAKT":1,"WAST":1,"WAT":1,"WEDT":1,"WEST":1,"WET":1,"WST":1,"YAKT":1,"YEKT":1,"Z":1}; return (timezones[value] === 1); }; $D.validateTimezoneOffset= function(value) { // timezones go from +14hrs to -12hrs, the +X hours are negative offsets. return (value > -841 && value < 721); }; }()); (function () { var $D = Date, $P = $D.prototype, p = function (s, l) { if (!l) { l = 2; } return ("000" + s).slice(l * -1); }; var validateConfigObject = function (obj) { var result = {}, self = this, prop, testFunc; testFunc = function (prop, func, value) { if (prop === "day") { var month = (obj.month !== undefined) ? obj.month : self.getMonth(); var year = (obj.year !== undefined) ? obj.year : self.getFullYear(); return $D[func](value, year, month); } else { return $D[func](value); } }; for (prop in obj) { if (Object.prototype.hasOwnProperty.call(obj, prop)) { var func = "validate" + prop.charAt(0).toUpperCase() + prop.slice(1); if ($D[func] && obj[prop] !== null && testFunc(prop, func, obj[prop])) { result[prop] = obj[prop]; } } } return result; }; /** * Resets the time of this Date object to 12:00 AM (00:00), which is the start of the day. * @param {Boolean} .clone() this date instance before clearing Time * @return {Date} this */ $P.clearTime = function () { this.setHours(0); this.setMinutes(0); this.setSeconds(0); this.setMilliseconds(0); return this; }; /** * Resets the time of this Date object to the current time ('now'). * @return {Date} this */ $P.setTimeToNow = function () { var n = new Date(); this.setHours(n.getHours()); this.setMinutes(n.getMinutes()); this.setSeconds(n.getSeconds()); this.setMilliseconds(n.getMilliseconds()); return this; }; /** * Returns a new Date object that is an exact date and time copy of the original instance. * @return {Date} A new Date instance */ $P.clone = function () { return new Date(this.getTime()); }; /** * Compares this instance to a Date object and returns an number indication of their relative values. * @param {Date} Date object to compare [Required] * @return {Number} -1 = this is lessthan date. 0 = values are equal. 1 = this is greaterthan date. */ $P.compareTo = function (date) { return Date.compare(this, date); }; /** * Compares this instance to another Date object and returns true if they are equal. * @param {Date} Date object to compare. If no date to compare, new Date() [now] is used. * @return {Boolean} true if dates are equal. false if they are not equal. */ $P.equals = function (date) { return Date.equals(this, (date !== undefined ? date : new Date())); }; /** * Determines if this instance is between a range of two dates or equal to either the start or end dates. * @param {Date} Start of range [Required] * @param {Date} End of range [Required] * @return {Boolean} true is this is between or equal to the start and end dates, else false */ $P.between = function (start, end) { return this.getTime() >= start.getTime() && this.getTime() <= end.getTime(); }; /** * Determines if this date occurs after the date to compare to. * @param {Date} Date object to compare. If no date to compare, new Date() ("now") is used. * @return {Boolean} true if this date instance is greater than the date to compare to (or "now"), otherwise false. */ $P.isAfter = function (date) { return this.compareTo(date || new Date()) === 1; }; /** * Determines if this date occurs before the date to compare to. * @param {Date} Date object to compare. If no date to compare, new Date() ("now") is used. * @return {Boolean} true if this date instance is less than the date to compare to (or "now"). */ $P.isBefore = function (date) { return (this.compareTo(date || new Date()) === -1); }; /** * Determines if the current Date instance occurs today. * @return {Boolean} true if this date instance is 'today', otherwise false. */ /** * Determines if the current Date instance occurs on the same Date as the supplied 'date'. * If no 'date' to compare to is provided, the current Date instance is compared to 'today'. * @param {date} Date object to compare. If no date to compare, the current Date ("now") is used. * @return {Boolean} true if this Date instance occurs on the same Day as the supplied 'date'. */ $P.isToday = $P.isSameDay = function (date) { return this.clone().clearTime().equals((date || new Date()).clone().clearTime()); }; /** * Adds the specified number of milliseconds to this instance. * @param {Number} The number of milliseconds to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addMilliseconds = function (value) { if (!value) { return this; } this.setTime(this.getTime() + value * 1); return this; }; /** * Adds the specified number of seconds to this instance. * @param {Number} The number of seconds to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addSeconds = function (value) { if (!value) { return this; } return this.addMilliseconds(value * 1000); }; /** * Adds the specified number of seconds to this instance. * @param {Number} The number of seconds to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addMinutes = function (value) { if (!value) { return this; } return this.addMilliseconds(value * 60000); // 60*1000 }; /** * Adds the specified number of hours to this instance. * @param {Number} The number of hours to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addHours = function (value) { if (!value) { return this; } return this.addMilliseconds(value * 3600000); // 60*60*1000 }; /** * Adds the specified number of days to this instance. * @param {Number} The number of days to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addDays = function (value) { if (!value) { return this; } this.setDate(this.getDate() + value * 1); return this; }; /** * Adds the specified number of weekdays (ie - not sat or sun) to this instance. * @param {Number} The number of days to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addWeekdays = function (value) { if (!value) { return this; } var day = this.getDay(); var weeks = (Math.ceil(Math.abs(value)/7)); if (day === 0 || day === 6) { if (value > 0) { this.next().monday(); this.addDays(-1); day = this.getDay(); } } if (value < 0) { while (value < 0) { this.addDays(-1); day = this.getDay(); if (day !== 0 && day !== 6) { value++; } } return this; } else if (value > 5 || (6-day) <= value) { value = value + (weeks * 2); } return this.addDays(value); }; /** * Adds the specified number of weeks to this instance. * @param {Number} The number of weeks to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addWeeks = function (value) { if (!value) { return this; } return this.addDays(value * 7); }; /** * Adds the specified number of months to this instance. * @param {Number} The number of months to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addMonths = function (value) { if (!value) { return this; } var n = this.getDate(); this.setDate(1); this.setMonth(this.getMonth() + value * 1); this.setDate(Math.min(n, $D.getDaysInMonth(this.getFullYear(), this.getMonth()))); return this; }; $P.addQuarters = function (value) { if (!value) { return this; } // note this will take you to the same point in the quarter as you are now. // i.e. - if you are 15 days into the quarter you'll be 15 days into the resulting one. // bonus: this allows adding fractional quarters return this.addMonths(value * 3); }; /** * Adds the specified number of years to this instance. * @param {Number} The number of years to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addYears = function (value) { if (!value) { return this; } return this.addMonths(value * 12); }; /** * Adds (or subtracts) to the value of the years, months, weeks, days, hours, minutes, seconds, milliseconds of the date instance using given configuration object. Positive and Negative values allowed. * Example

	Date.today().add( { days: 1, months: 1 } )

	new Date().add( { years: -1 } )
	
* @param {Object} Configuration object containing attributes (months, days, etc.) * @return {Date} this */ $P.add = function (config) { if (typeof config === "number") { this._orient = config; return this; } var x = config; if (x.day) { // If we should be a different date than today (eg: for 'tomorrow -1d', etc). // Should only effect parsing, not direct usage (eg, Finish and FinishExact) if ((x.day - this.getDate()) !== 0) { this.setDate(x.day); } } if (x.milliseconds) { this.addMilliseconds(x.milliseconds); } if (x.seconds) { this.addSeconds(x.seconds); } if (x.minutes) { this.addMinutes(x.minutes); } if (x.hours) { this.addHours(x.hours); } if (x.weeks) { this.addWeeks(x.weeks); } if (x.months) { this.addMonths(x.months); } if (x.years) { this.addYears(x.years); } if (x.days) { this.addDays(x.days); } return this; }; /** * Get the week number. Week one (1) is the week which contains the first Thursday of the year. Monday is considered the first day of the week. * The .getWeek() function does NOT convert the date to UTC. The local datetime is used. * Please use .getISOWeek() to get the week of the UTC converted date. * @return {Number} 1 to 53 */ $P.getWeek = function (utc) { // Create a copy of this date object var self, target = new Date(this.valueOf()); if (utc) { target.addMinutes(target.getTimezoneOffset()); self = target.clone(); } else { self = this; } // ISO week date weeks start on monday // so correct the day number var dayNr = (self.getDay() + 6) % 7; // ISO 8601 states that week 1 is the week // with the first thursday of that year. // Set the target date to the thursday in the target week target.setDate(target.getDate() - dayNr + 3); // Store the millisecond value of the target date var firstThursday = target.valueOf(); // Set the target to the first thursday of the year // First set the target to january first target.setMonth(0, 1); // Not a thursday? Correct the date to the next thursday if (target.getDay() !== 4) { target.setMonth(0, 1 + ((4 - target.getDay()) + 7) % 7); } // The weeknumber is the number of weeks between the // first thursday of the year and the thursday in the target week return 1 + Math.ceil((firstThursday - target) / 604800000); // 604800000 = 7 * 24 * 3600 * 1000 }; /** * Get the ISO 8601 week number. Week one ("01") is the week which contains the first Thursday of the year. Monday is considered the first day of the week. * The .getISOWeek() function does convert the date to it's UTC value. Please use .getWeek() to get the week of the local date. * @return {String} "01" to "53" */ $P.getISOWeek = function () { return p(this.getWeek(true)); }; /** * Moves the date to Monday of the week set. Week one (1) is the week which contains the first Thursday of the year. * @param {Number} A Number (1 to 53) that represents the week of the year. * @return {Date} this */ $P.setWeek = function (n) { if ((n - this.getWeek()) === 0) { if (this.getDay() !== 1) { return this.moveToDayOfWeek(1, (this.getDay() > 1 ? -1 : 1)); } else { return this; } } else { return this.moveToDayOfWeek(1, (this.getDay() > 1 ? -1 : 1)).addWeeks(n - this.getWeek()); } }; $P.setQuarter = function (qtr) { var month = Math.abs(((qtr-1) * 3) + 1); return this.setMonth(month, 1); }; $P.getQuarter = function () { return Date.getQuarter(this); }; $P.getDaysLeftInQuarter = function () { return Date.getDaysLeftInQuarter(this); }; /** * Moves the date to the next n'th occurrence of the dayOfWeek starting from the beginning of the month. The number (-1) is a magic number and will return the last occurrence of the dayOfWeek in the month. * @param {Number} The dayOfWeek to move to * @param {Number} The n'th occurrence to move to. Use (-1) to return the last occurrence in the month * @return {Date} this */ $P.moveToNthOccurrence = function (dayOfWeek, occurrence) { if (dayOfWeek === "Weekday") { if (occurrence > 0) { this.moveToFirstDayOfMonth(); if (this.is().weekday()) { occurrence -= 1; } } else if (occurrence < 0) { this.moveToLastDayOfMonth(); if (this.is().weekday()) { occurrence += 1; } } else { return this; } return this.addWeekdays(occurrence); } var shift = 0; if (occurrence > 0) { shift = occurrence - 1; } else if (occurrence === -1) { this.moveToLastDayOfMonth(); if (this.getDay() !== dayOfWeek) { this.moveToDayOfWeek(dayOfWeek, -1); } return this; } return this.moveToFirstDayOfMonth().addDays(-1).moveToDayOfWeek(dayOfWeek, +1).addWeeks(shift); }; var moveToN = function (getFunc, addFunc, nVal) { return function (value, orient) { var diff = (value - this[getFunc]() + nVal * (orient || +1)) % nVal; return this[addFunc]((diff === 0) ? diff += nVal * (orient || +1) : diff); }; }; /** * Move to the next or last dayOfWeek based on the orient value. * @param {Number} The dayOfWeek to move to * @param {Number} Forward (+1) or Back (-1). Defaults to +1. [Optional] * @return {Date} this */ $P.moveToDayOfWeek = moveToN("getDay", "addDays", 7); /** * Move to the next or last month based on the orient value. * @param {Number} The month to move to. 0 = January, 11 = December * @param {Number} Forward (+1) or Back (-1). Defaults to +1. [Optional] * @return {Date} this */ $P.moveToMonth = moveToN("getMonth", "addMonths", 12); /** * Get the Ordinate of the current day ("th", "st", "rd"). * @return {String} */ $P.getOrdinate = function () { var num = this.getDate(); return ord(num); }; /** * Get the Ordinal day (numeric day number) of the year, adjusted for leap year. * @return {Number} 1 through 365 (366 in leap years) */ $P.getOrdinalNumber = function () { return Math.ceil((this.clone().clearTime() - new Date(this.getFullYear(), 0, 1)) / 86400000) + 1; }; /** * Get the time zone abbreviation of the current date. * @return {String} The abbreviated time zone name (e.g. "EST") */ $P.getTimezone = function () { return $D.getTimezoneAbbreviation(this.getUTCOffset(), this.isDaylightSavingTime()); }; $P.setTimezoneOffset = function (offset) { var here = this.getTimezoneOffset(), there = Number(offset) * -6 / 10; return (there || there === 0) ? this.addMinutes(there - here) : this; }; $P.setTimezone = function (offset) { return this.setTimezoneOffset($D.getTimezoneOffset(offset)); }; /** * Indicates whether Daylight Saving Time is observed in the current time zone. * @return {Boolean} true|false */ $P.hasDaylightSavingTime = function () { return (Date.today().set({month: 0, day: 1}).getTimezoneOffset() !== Date.today().set({month: 6, day: 1}).getTimezoneOffset()); }; /** * Indicates whether this Date instance is within the Daylight Saving Time range for the current time zone. * @return {Boolean} true|false */ $P.isDaylightSavingTime = function () { return Date.today().set({month: 0, day: 1}).getTimezoneOffset() !== this.getTimezoneOffset(); }; /** * Get the offset from UTC of the current date. * @return {String} The 4-character offset string prefixed with + or - (e.g. "-0500") */ $P.getUTCOffset = function (offset) { var n = (offset || this.getTimezoneOffset()) * -10 / 6, r; if (n < 0) { r = (n - 10000).toString(); return r.charAt(0) + r.substr(2); } else { r = (n + 10000).toString(); return "+" + r.substr(1); } }; /** * Returns the number of milliseconds between this date and date. * @param {Date} Defaults to now * @return {Number} The diff in milliseconds */ $P.getElapsed = function (date) { return (date || new Date()) - this; }; /** * Set the value of year, month, day, hour, minute, second, millisecond of date instance using given configuration object. * Example

	Date.today().set( { day: 20, month: 1 } )

	new Date().set( { millisecond: 0 } )
	
* * @param {Object} Configuration object containing attributes (month, day, etc.) * @return {Date} this */ $P.set = function (config) { config = validateConfigObject.call(this, config); var key; for (key in config) { if (Object.prototype.hasOwnProperty.call(config, key)) { var name = key.charAt(0).toUpperCase() + key.slice(1); var addFunc, getFunc; if (key !== "week" && key !== "month" && key !== "timezone" && key !== "timezoneOffset") { name += "s"; } addFunc = "add" + name; getFunc = "get" + name; if (key === "month") { addFunc = addFunc + "s"; } else if (key === "year"){ getFunc = "getFullYear"; } if (key !== "day" && key !== "timezone" && key !== "timezoneOffset" && key !== "week" && key !== "hour") { this[addFunc](config[key] - this[getFunc]()); } else if ( key === "timezone"|| key === "timezoneOffset" || key === "week" || key === "hour") { this["set"+name](config[key]); } } } // day has to go last because you can't validate the day without first knowing the month if (config.day) { this.addDays(config.day - this.getDate()); } return this; }; /** * Moves the date to the first day of the month. * @return {Date} this */ $P.moveToFirstDayOfMonth = function () { return this.set({ day: 1 }); }; /** * Moves the date to the last day of the month. * @return {Date} this */ $P.moveToLastDayOfMonth = function () { return this.set({ day: $D.getDaysInMonth(this.getFullYear(), this.getMonth())}); }; /** * Converts the value of the current Date object to its equivalent string representation. * Format Specifiers * CUSTOM DATE AND TIME FORMAT STRINGS * Format Description Example * ------ --------------------------------------------------------------------------- ----------------------- * s The seconds of the minute between 0-59. "0" to "59" * ss The seconds of the minute with leading zero if required. "00" to "59" * * m The minute of the hour between 0-59. "0" or "59" * mm The minute of the hour with leading zero if required. "00" or "59" * * h The hour of the day between 1-12. "1" to "12" * hh The hour of the day with leading zero if required. "01" to "12" * * H The hour of the day between 0-23. "0" to "23" * HH The hour of the day with leading zero if required. "00" to "23" * * d The day of the month between 1 and 31. "1" to "31" * dd The day of the month with leading zero if required. "01" to "31" * ddd Abbreviated day name. Date.CultureInfo.abbreviatedDayNames. "Mon" to "Sun" * dddd The full day name. Date.CultureInfo.dayNames. "Monday" to "Sunday" * * M The month of the year between 1-12. "1" to "12" * MM The month of the year with leading zero if required. "01" to "12" * MMM Abbreviated month name. Date.CultureInfo.abbreviatedMonthNames. "Jan" to "Dec" * MMMM The full month name. Date.CultureInfo.monthNames. "January" to "December" * * yy The year as a two-digit number. "99" or "08" * yyyy The full four digit year. "1999" or "2008" * * t Displays the first character of the A.M./P.M. designator. "A" or "P" * Date.CultureInfo.amDesignator or Date.CultureInfo.pmDesignator * tt Displays the A.M./P.M. designator. "AM" or "PM" * Date.CultureInfo.amDesignator or Date.CultureInfo.pmDesignator * * S The ordinal suffix ("st, "nd", "rd" or "th") of the current day. "st, "nd", "rd" or "th" * * STANDARD DATE AND TIME FORMAT STRINGS * Format Description Example *------ --------------------------------------------------------------------------- ----------------------- * d The CultureInfo shortDate Format Pattern "M/d/yyyy" * D The CultureInfo longDate Format Pattern "dddd, MMMM dd, yyyy" * F The CultureInfo fullDateTime Format Pattern "dddd, MMMM dd, yyyy h:mm:ss tt" * m The CultureInfo monthDay Format Pattern "MMMM dd" * r The CultureInfo rfc1123 Format Pattern "ddd, dd MMM yyyy HH:mm:ss GMT" * s The CultureInfo sortableDateTime Format Pattern "yyyy-MM-ddTHH:mm:ss" * t The CultureInfo shortTime Format Pattern "h:mm tt" * T The CultureInfo longTime Format Pattern "h:mm:ss tt" * u The CultureInfo universalSortableDateTime Format Pattern "yyyy-MM-dd HH:mm:ssZ" * y The CultureInfo yearMonth Format Pattern "MMMM, yyyy" * * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @return {String} A string representation of the current Date object. */ var ord = function (n) { switch (n * 1) { case 1: case 21: case 31: return "st"; case 2: case 22: return "nd"; case 3: case 23: return "rd"; default: return "th"; } }; var parseStandardFormats = function (format) { var y, c = Date.CultureInfo.formatPatterns; switch (format) { case "d": return this.toString(c.shortDate); case "D": return this.toString(c.longDate); case "F": return this.toString(c.fullDateTime); case "m": return this.toString(c.monthDay); case "r": case "R": y = this.clone().addMinutes(this.getTimezoneOffset()); return y.toString(c.rfc1123) + " GMT"; case "s": return this.toString(c.sortableDateTime); case "t": return this.toString(c.shortTime); case "T": return this.toString(c.longTime); case "u": y = this.clone().addMinutes(this.getTimezoneOffset()); return y.toString(c.universalSortableDateTime); case "y": return this.toString(c.yearMonth); default: return false; } }; var parseFormatStringsClosure = function (context) { return function (m) { if (m.charAt(0) === "\\") { return m.replace("\\", ""); } switch (m) { case "hh": return p(context.getHours() < 13 ? (context.getHours() === 0 ? 12 : context.getHours()) : (context.getHours() - 12)); case "h": return context.getHours() < 13 ? (context.getHours() === 0 ? 12 : context.getHours()) : (context.getHours() - 12); case "HH": return p(context.getHours()); case "H": return context.getHours(); case "mm": return p(context.getMinutes()); case "m": return context.getMinutes(); case "ss": return p(context.getSeconds()); case "s": return context.getSeconds(); case "yyyy": return p(context.getFullYear(), 4); case "yy": return p(context.getFullYear()); case "y": return context.getFullYear(); case "E": case "dddd": return Date.CultureInfo.dayNames[context.getDay()]; case "ddd": return Date.CultureInfo.abbreviatedDayNames[context.getDay()]; case "dd": return p(context.getDate()); case "d": return context.getDate(); case "MMMM": return Date.CultureInfo.monthNames[context.getMonth()]; case "MMM": return Date.CultureInfo.abbreviatedMonthNames[context.getMonth()]; case "MM": return p((context.getMonth() + 1)); case "M": return context.getMonth() + 1; case "t": return context.getHours() < 12 ? Date.CultureInfo.amDesignator.substring(0, 1) : Date.CultureInfo.pmDesignator.substring(0, 1); case "tt": return context.getHours() < 12 ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator; case "S": return ord(context.getDate()); case "W": return context.getWeek(); case "WW": return context.getISOWeek(); case "Q": return "Q" + context.getQuarter(); case "q": return String(context.getQuarter()); case "z": return context.getTimezone(); case "Z": case "X": return Date.getTimezoneOffset(context.getTimezone()); case "ZZ": // Timezone offset in seconds return context.getTimezoneOffset() * -60; case "u": return context.getDay(); case "L": return ($D.isLeapYear(context.getFullYear())) ? 1 : 0; case "B": // Swatch Internet Time (.beats) return "@"+((context.getUTCSeconds() + (context.getUTCMinutes()*60) + ((context.getUTCHours()+1)*3600))/86.4); default: return m; } }; }; $P.toString = function (format, ignoreStandards) { // Standard Date and Time Format Strings. Formats pulled from CultureInfo file and // may vary by culture. if (!ignoreStandards && format && format.length === 1) { output = parseStandardFormats.call(this, format); if (output) { return output; } } var parseFormatStrings = parseFormatStringsClosure(this); return format ? format.replace(/((\\)?(dd?d?d?|MM?M?M?|yy?y?y?|hh?|HH?|mm?|ss?|tt?|S|q|Q|WW?W?W?)(?![^\[]*\]))/g, parseFormatStrings).replace(/\[|\]/g, "") : this._toString(); }; }()); /************************************************************* * SugarPak - Domain Specific Language - Syntactical Sugar * *************************************************************/ (function () { var $D = Date, $P = $D.prototype, $N = Number.prototype; // private $P._orient = +1; // private $P._nth = null; // private $P._is = false; // private $P._same = false; // private $P._isSecond = false; // private $N._dateElement = "days"; /** * Moves the date to the next instance of a date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.today().next().friday();
	Date.today().next().fri();
	Date.today().next().march();
	Date.today().next().mar();
	Date.today().next().week();
	
* * @return {Date} date */ $P.next = function () { this._move = true; this._orient = +1; return this; }; /** * Creates a new Date (Date.today()) and moves the date to the next instance of the date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.next().friday();
	Date.next().fri();
	Date.next().march();
	Date.next().mar();
	Date.next().week();
	
* * @return {Date} date */ $D.next = function () { return $D.today().next(); }; /** * Moves the date to the previous instance of a date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.today().last().friday();
	Date.today().last().fri();
	Date.today().last().march();
	Date.today().last().mar();
	Date.today().last().week();
	
* * @return {Date} date */ $P.last = $P.prev = $P.previous = function () { this._move = true; this._orient = -1; return this; }; /** * Creates a new Date (Date.today()) and moves the date to the previous instance of the date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.last().friday();
	Date.last().fri();
	Date.previous().march();
	Date.prev().mar();
	Date.last().week();
	
* * @return {Date} date */ $D.last = $D.prev = $D.previous = function () { return $D.today().last(); }; /** * Performs a equality check when followed by either a month name, day name or .weekday() function. * Example

	Date.today().is().friday(); // true|false
	Date.today().is().fri();
	Date.today().is().march();
	Date.today().is().mar();
	
* * @return {Boolean} true|false */ $P.is = function () { this._is = true; return this; }; /** * Determines if two date objects occur on/in exactly the same instance of the subsequent date part function. * The function .same() must be followed by a date part function (example: .day(), .month(), .year(), etc). * * An optional Date can be passed in the date part function. If now date is passed as a parameter, 'Now' is used. * * The following example demonstrates how to determine if two dates fall on the exact same day. * * Example

	var d1 = Date.today(); // today at 00:00
	var d2 = new Date();   // exactly now.

	// Do they occur on the same day?
	d1.same().day(d2); // true
	
	// Do they occur on the same hour?
	d1.same().hour(d2); // false, unless d2 hour is '00' (midnight).
	
	// What if it's the same day, but one year apart?
	var nextYear = Date.today().add(1).year();

	d1.same().day(nextYear); // false, because the dates must occur on the exact same day. 
	
* * Scenario: Determine if a given date occurs during some week period 2 months from now. * * Example

	var future = Date.today().add(2).months();
	return someDate.same().week(future); // true|false;
	
* * @return {Boolean} true|false */ $P.same = function () { this._same = true; this._isSecond = false; return this; }; /** * Determines if the current date/time occurs during Today. Must be preceded by the .is() function. * Example

	someDate.is().today();    // true|false
	new Date().is().today();  // true
	Date.today().is().today();// true
	Date.today().add(-1).day().is().today(); // false
	
* * @return {Boolean} true|false */ $P.today = function () { return this.same().day(); }; /** * Determines if the current date is a weekday. This function must be preceded by the .is() function. * Example

	Date.today().is().weekday(); // true|false
	
* * @return {Boolean} true|false */ $P.weekday = function () { if (this._nth) { return df("Weekday").call(this); } if (this._move) { return this.addWeekdays(this._orient); } if (this._is) { this._is = false; return (!this.is().sat() && !this.is().sun()); } return false; }; /** * Determines if the current date is on the weekend. This function must be preceded by the .is() function. * Example

	Date.today().is().weekend(); // true|false
	
* * @return {Boolean} true|false */ $P.weekend = function () { if (this._is) { this._is = false; return (this.is().sat() || this.is().sun()); } return false; }; /** * Sets the Time of the current Date instance. A string "6:15 pm" or config object {hour:18, minute:15} are accepted. * Example

	// Set time to 6:15pm with a String
	Date.today().at("6:15pm");

	// Set time to 6:15pm with a config object
	Date.today().at({hour:18, minute:15});
	
* * @return {Date} date */ $P.at = function (time) { return (typeof time === "string") ? $D.parse(this.toString("d") + " " + time) : this.set(time); }; /** * Creates a new Date() and adds this (Number) to the date based on the preceding date element function (eg. second|minute|hour|day|month|year). * Example

	// Undeclared Numbers must be wrapped with parentheses. Requirment of JavaScript.
	(3).days().fromNow();
	(6).months().fromNow();

	// Declared Number variables do not require parentheses. 
	var n = 6;
	n.months().fromNow();
	
* * @return {Date} A new Date instance */ $N.fromNow = $N.after = function (date) { var c = {}; c[this._dateElement] = this; return ((!date) ? new Date() : date.clone()).add(c); }; /** * Creates a new Date() and subtract this (Number) from the date based on the preceding date element function (eg. second|minute|hour|day|month|year). * Example

	// Undeclared Numbers must be wrapped with parentheses. Requirment of JavaScript.
	(3).days().ago();
	(6).months().ago();

	// Declared Number variables do not require parentheses. 
	var n = 6;
	n.months().ago();
	
* * @return {Date} A new Date instance */ $N.ago = $N.before = function (date) { var c = {}, s = (this._dateElement[this._dateElement.length-1] !== "s") ? this._dateElement + "s" : this._dateElement; c[s] = this * -1; return ((!date) ? new Date() : date.clone()).add(c); }; // Do NOT modify the following string tokens. These tokens are used to build dynamic functions. // All culture-specific strings can be found in the CultureInfo files. var dx = ("sunday monday tuesday wednesday thursday friday saturday").split(/\s/), mx = ("january february march april may june july august september october november december").split(/\s/), px = ("Millisecond Second Minute Hour Day Week Month Year Quarter Weekday").split(/\s/), pxf = ("Milliseconds Seconds Minutes Hours Date Week Month FullYear Quarter").split(/\s/), nth = ("final first second third fourth fifth").split(/\s/), de; /** * Returns an object literal of all the date parts. * Example

	var o = new Date().toObject();
	
	// { year: 2008, month: 4, week: 20, day: 13, hour: 18, minute: 9, second: 32, millisecond: 812 }
	
	// The object properties can be referenced directly from the object.
	
	alert(o.day);  // alerts "13"
	alert(o.year); // alerts "2008"
	
* * @return {Date} An object literal representing the original date object. */ $P.toObject = function () { var o = {}; for (var i = 0; i < px.length; i++) { if (this["get" + pxf[i]]) { o[px[i].toLowerCase()] = this["get" + pxf[i]](); } } return o; }; /** * Returns a date created from an object literal. Ignores the .week property if set in the config. * Example

	var o = new Date().toObject();
	
	return Date.fromObject(o); // will return the same date. 

	var o2 = {month: 1, day: 20, hour: 18}; // birthday party!
	Date.fromObject(o2);
	
* * @return {Date} An object literal representing the original date object. */ $D.fromObject = function(config) { config.week = null; return Date.today().set(config); }; // Create day name functions and abbreviated day name functions (eg. monday(), friday(), fri()). var df = function (n) { return function () { if (this._is) { this._is = false; return this.getDay() === n; } if (this._move) { this._move = null; } if (this._nth !== null) { // If the .second() function was called earlier, remove the _orient // from the date, and then continue. // This is required because 'second' can be used in two different context. // // Example // // Date.today().add(1).second(); // Date.march().second().monday(); // // Things get crazy with the following... // Date.march().add(1).second().second().monday(); // but it works!! // if (this._isSecond) { this.addSeconds(this._orient * -1); } // make sure we reset _isSecond this._isSecond = false; var ntemp = this._nth; this._nth = null; var temp = this.clone().moveToLastDayOfMonth(); this.moveToNthOccurrence(n, ntemp); if (this > temp) { throw new RangeError($D.getDayName(n) + " does not occur " + ntemp + " times in the month of " + $D.getMonthName(temp.getMonth()) + " " + temp.getFullYear() + "."); } return this; } return this.moveToDayOfWeek(n, this._orient); }; }; var sdf = function (n) { return function () { var t = $D.today(), shift = n - t.getDay(); if (n === 0 && Date.CultureInfo.firstDayOfWeek === 1 && t.getDay() !== 0) { shift = shift + 7; } return t.addDays(shift); }; }; // Create month name functions and abbreviated month name functions (eg. january(), march(), mar()). var month_instance_functions = function (n) { return function () { if (this._is) { this._is = false; return this.getMonth() === n; } return this.moveToMonth(n, this._orient); }; }; var month_static_functions = function (n) { return function () { return $D.today().set({ month: n, day: 1 }); }; }; var processTerms = function (names, staticFunc, instanceFunc) { for (var i = 0; i < names.length; i++) { // Create constant static Name variables. $D[names[i].toUpperCase()] = $D[names[i].toUpperCase().substring(0, 3)] = i; // Create Name functions. $D[names[i]] = $D[names[i].substring(0, 3)] = staticFunc(i); // Create Name instance functions. $P[names[i]] = $P[names[i].substring(0, 3)] = instanceFunc(i); } }; processTerms(dx, sdf, df); processTerms(mx, month_static_functions, month_instance_functions); // Create date element functions and plural date element functions used with Date (eg. day(), days(), months()). var ef = function (j) { return function () { // if the .second() function was called earlier, the _orient // has alread been added. Just return this and reset _isSecond. if (this._isSecond) { this._isSecond = false; return this; } if (this._same) { this._same = this._is = false; var o1 = this.toObject(), o2 = (arguments[0] || new Date()).toObject(), v = "", k = j.toLowerCase(); // the substr trick with -1 doesn't work in IE8 or less k = (k[k.length-1] === "s") ? k.substring(0,k.length-1) : k; for (var m = (px.length - 1); m > -1; m--) { v = px[m].toLowerCase(); if (o1[v] !== o2[v]) { return false; } if (k === v) { break; } } return true; } if (j.substring(j.length - 1) !== "s") { j += "s"; } if (this._move) { this._move = null; } return this["add" + j](this._orient); }; }; var nf = function (n) { return function () { this._dateElement = n; return this; }; }; for (var k = 0; k < px.length; k++) { de = px[k].toLowerCase(); if(de !== "weekday") { // Create date element functions and plural date element functions used with Date (eg. day(), days(), months()). $P[de] = $P[de + "s"] = ef(px[k]); // Create date element functions and plural date element functions used with Number (eg. day(), days(), months()). $N[de] = $N[de + "s"] = nf(de + "s"); } } $P._ss = ef("Second"); var nthfn = function (n) { return function (dayOfWeek) { if (this._same) { return this._ss(arguments[0]); } if (dayOfWeek || dayOfWeek === 0) { return this.moveToNthOccurrence(dayOfWeek, n); } this._nth = n; // if the operator is 'second' add the _orient, then deal with it later... if (n === 2 && (dayOfWeek === undefined || dayOfWeek === null)) { this._isSecond = true; return this.addSeconds(this._orient); } return this; }; }; for (var l = 0; l < nth.length; l++) { $P[nth[l]] = (l === 0) ? nthfn(-1) : nthfn(l); } }()); (function () { "use strict"; Date.Parsing = { Exception: function (s) { this.message = "Parse error at '" + s.substring(0, 10) + " ...'"; } }; var $P = Date.Parsing; var dayOffsets = { standard: [0,31,59,90,120,151,181,212,243,273,304,334], leap: [0,31,60,91,121,152,182,213,244,274,305,335] }; $P.isLeapYear = function(year) { return ((year % 4 === 0) && (year % 100 !== 0)) || (year % 400 === 0); }; var utils = { multiReplace : function (str, hash ) { var key; for (key in hash) { if (Object.prototype.hasOwnProperty.call(hash, key)) { var regex; if (typeof hash[key] === "function") { } else { regex = (hash[key] instanceof RegExp) ? hash[key] : new RegExp(hash[key], "g"); } str = str.replace(regex, key); } } return str; }, getDayOfYearFromWeek : function (obj) { var d, jan4, offset; obj.weekDay = (!obj.weekDay && obj.weekDay !== 0) ? 1 : obj.weekDay; d = new Date(obj.year, 0, 4); jan4 = d.getDay() === 0 ? 7 : d.getDay(); // JS is 0 indexed on Sunday. offset = jan4+3; obj.dayOfYear = ((obj.week * 7) + (obj.weekDay === 0 ? 7 : obj.weekDay))-offset; return obj; }, getDayOfYear : function (obj, dayOffset) { if (!obj.dayOfYear) { obj = utils.getDayOfYearFromWeek(obj); } for (var i=0;i <= dayOffset.length;i++) { if (obj.dayOfYear < dayOffset[i] || i === dayOffset.length) { obj.day = obj.day ? obj.day : (obj.dayOfYear - dayOffset[i-1]); break; } else { obj.month = i; } } return obj; }, adjustForTimeZone : function (obj, date) { var offset; if (obj.zone.toUpperCase() === "Z" || (obj.zone_hours === 0 && obj.zone_minutes === 0)) { // it's UTC/GML so work out the current timeszone offset offset = -date.getTimezoneOffset(); } else { offset = (obj.zone_hours*60) + (obj.zone_minutes || 0); if (obj.zone_sign === "+") { offset *= -1; } offset -= date.getTimezoneOffset(); } date.setMinutes(date.getMinutes()+offset); return date; }, setDefaults : function (obj) { obj.year = obj.year || Date.today().getFullYear(); obj.hours = obj.hours || 0; obj.minutes = obj.minutes || 0; obj.seconds = obj.seconds || 0; obj.milliseconds = obj.milliseconds || 0; if (!(!obj.month && (obj.week || obj.dayOfYear))) { // if we have a month, or if we don't but don't have the day calculation data obj.month = obj.month || 0; obj.day = obj.day || 1; } return obj; }, dataNum: function (data, mod, explict, postProcess) { var dataNum = data*1; if (mod) { if (postProcess) { return data ? mod(data)*1 : data; } else { return data ? mod(dataNum) : data; } } else if (!explict){ return data ? dataNum : data; } else { return (data && typeof data !== "undefined") ? dataNum : data; } }, timeDataProcess: function (obj) { var timeObj = {}; for (var x in obj.data) { if (obj.data.hasOwnProperty(x)) { timeObj[x] = obj.ignore[x] ? obj.data[x] : utils.dataNum(obj.data[x], obj.mods[x], obj.explict[x], obj.postProcess[x]); } } if (obj.data.secmins) { obj.data.secmins = obj.data.secmins.replace(",", ".") * 60; if (!timeObj.minutes) { timeObj.minutes = obj.data.secmins; } else if (!timeObj.seconds) { timeObj.seconds = obj.data.secmins; } delete obj.secmins; } return timeObj; }, buildTimeObjectFromData: function (data) { var time = utils.timeDataProcess({ data: { year : data[1], month : data[5], day : data[7], week : data[8], dayOfYear : data[10], hours : data[15], zone_hours : data[23], zone_minutes : data[24], zone : data[21], zone_sign : data[22], weekDay : data[9], minutes: data[16], seconds: data[19], milliseconds: data[20], secmins: data[18] }, mods: { month: function(data) { return data-1; }, weekDay: function (data) { data = Math.abs(data); return (data === 7 ? 0 : data); }, minutes: function (data) { return data.replace(":",""); }, seconds: function (data) { return Math.floor( (data.replace(":","").replace(",","."))*1 ); }, milliseconds: function (data) { return (data.replace(",",".")*1000); } }, postProcess: { minutes: true, seconds: true, milliseconds: true }, explict: { zone_hours: true, zone_minutes: true }, ignore: { zone: true, zone_sign: true, secmins: true } }); return time; }, addToHash: function (hash, keys, data) { keys = keys; data = data; var len = keys.length; for (var i = 0; i < len; i++) { hash[keys[i]] = data[i]; } return hash; }, combineRegex: function (r1, r2) { return new RegExp("(("+r1.source+")\\s("+r2.source+"))"); }, getDateNthString: function(add, last, inc){ if (add) { return Date.today().addDays(inc).toString("d"); } else if (last) { return Date.today().last()[inc]().toString("d"); } }, buildRegexData: function (array) { var arr = []; var len = array.length; for (var i=0; i < len; i++) { if (Object.prototype.toString.call(array[i]) === '[object Array]') { // oldIE compat version of Array.isArray arr.push(this.combineRegex(array[i][0], array[i][1])); } else { arr.push(array[i]); } } return arr; } }; $P.processTimeObject = function (obj) { var date, dayOffset; utils.setDefaults(obj); dayOffset = ($P.isLeapYear(obj.year)) ? dayOffsets.leap : dayOffsets.standard; if (!obj.month && (obj.week || obj.dayOfYear)) { utils.getDayOfYear(obj, dayOffset); } else { obj.dayOfYear = dayOffset[obj.month] + obj.day; } date = new Date(obj.year, obj.month, obj.day, obj.hours, obj.minutes, obj.seconds, obj.milliseconds); if (obj.zone) { utils.adjustForTimeZone(obj, date); // adjust (and calculate) for timezone } return date; }; $P.ISO = { regex : /^([\+-]?\d{4}(?!\d{2}\b))((-?)((0[1-9]|1[0-2])(\3([12]\d|0[1-9]|3[01]))?|W([0-4]\d|5[0-3])(-?[1-7])?|(00[1-9]|0[1-9]\d|[12]\d{2}|3([0-5]\d|6[1-6])))([T\s]((([01]\d|2[0-4])((:?)[0-5]\d)?|24\:?00)([\.,]\d+(?!:))?)?(\17[0-5]\d([\.,]\d+)?)?\s?([zZ]|([\+-])([01]\d|2[0-3]):?([0-5]\d)?)?)?)?$/, parse : function (s) { var time, data = s.match(this.regex); if (!data || !data.length) { return null; } time = utils.buildTimeObjectFromData(data); if (!time.year || (!time.year && (!time.month && !time.day) && (!time.week && !time.dayOfYear)) ) { return null; } return $P.processTimeObject(time); } }; $P.Numeric = { isNumeric: function (e){return!isNaN(parseFloat(e))&&isFinite(e);}, regex: /\b([0-1]?[0-9])([0-3]?[0-9])([0-2]?[0-9]?[0-9][0-9])\b/i, parse: function (s) { var data, i, time = {}, order = Date.CultureInfo.dateElementOrder.split(""); if (!(this.isNumeric(s)) || // if it's non-numeric OR (s[0] === "+" && s[0] === "-")) { // It's an arithmatic string (eg +/-1000) return null; } if (s.length < 5 && s.indexOf(".") < 0 && s.indexOf("/") < 0) { // assume it's just a year. time.year = s; return $P.processTimeObject(time); } data = s.match(this.regex); if (!data || !data.length) { return null; } for (i=0; i < order.length; i++) { switch(order[i]) { case "d": time.day = data[i+1]; break; case "m": time.month = (data[i+1]-1); break; case "y": time.year = data[i+1]; break; } } return $P.processTimeObject(time); } }; $P.Normalizer = { regexData: function () { var $R = Date.CultureInfo.regexPatterns; return utils.buildRegexData([ $R.tomorrow, $R.yesterday, [$R.past, $R.mon], [$R.past, $R.tue], [$R.past, $R.wed], [$R.past, $R.thu], [$R.past, $R.fri], [$R.past, $R.sat], [$R.past, $R.sun] ]); }, basicReplaceHash : function() { var $R = Date.CultureInfo.regexPatterns; return { "January": $R.jan.source, "February": $R.feb, "March": $R.mar, "April": $R.apr, "May": $R.may, "June": $R.jun, "July": $R.jul, "August": $R.aug, "September": $R.sep, "October": $R.oct, "November": $R.nov, "December": $R.dec, "": /\bat\b/gi, " ": /\s{2,}/, "am": $R.inTheMorning, "9am": $R.thisMorning, "pm": $R.inTheEvening, "7pm":$R.thisEvening }; }, keys : function(){ return [ utils.getDateNthString(true, false, 1), // tomorrow utils.getDateNthString(true, false, -1), // yesterday utils.getDateNthString(false, true, "monday"), //last mon utils.getDateNthString(false, true, "tuesday"), //last tues utils.getDateNthString(false, true, "wednesday"), //last wed utils.getDateNthString(false, true, "thursday"), //last thurs utils.getDateNthString(false, true, "friday"), //last fri utils.getDateNthString(false, true, "saturday"), //last sat utils.getDateNthString(false, true, "sunday") //last sun ]; }, buildRegexFunctions: function () { var $R = Date.CultureInfo.regexPatterns; var __ = Date.i18n.__; var tomorrowRE = new RegExp("(\\b\\d\\d?("+__("AM")+"|"+__("PM")+")? )("+$R.tomorrow.source.slice(1)+")", "i"); // adapted tomorrow regex for AM PM relative dates var todayRE = new RegExp($R.today.source + "(?!\\s*([+-]))\\b"); // today, but excludes the math operators (eg "today + 2h") this.replaceFuncs = [ [todayRE, function (full) { return (full.length > 1) ? Date.today().toString("d") : full; }], [tomorrowRE, function(full, m1) { var t = Date.today().addDays(1).toString("d"); return (t + " " + m1); }], [$R.amThisMorning, function(str, am){return am;}], [$R.pmThisEvening, function(str, pm){return pm;}] ]; }, buildReplaceData: function () { this.buildRegexFunctions(); this.replaceHash = utils.addToHash(this.basicReplaceHash(), this.keys(), this.regexData()); }, stringReplaceFuncs: function (s) { for (var i=0; i < this.replaceFuncs.length; i++) { s = s.replace(this.replaceFuncs[i][0], this.replaceFuncs[i][1]); } return s; }, parse: function (s) { s = this.stringReplaceFuncs(s); s = utils.multiReplace(s, this.replaceHash); try { var n = s.split(/([\s\-\.\,\/\x27]+)/); if (n.length === 3 && $P.Numeric.isNumeric(n[0]) && $P.Numeric.isNumeric(n[2]) && (n[2].length >= 4)) { // ok, so we're dealing with x/year. But that's not a full date. // This fixes wonky dateElementOrder parsing when set to dmy order. if (Date.CultureInfo.dateElementOrder[0] === "d") { s = "1/" + n[0] + "/" + n[2]; // set to 1st of month and normalize the seperator } } } catch (e) {} return s; } }; $P.Normalizer.buildReplaceData(); }()); (function () { var $P = Date.Parsing; var _ = $P.Operators = { // // Tokenizers // rtoken: function (r) { // regex token return function (s) { var mx = s.match(r); if (mx) { return ([ mx[0], s.substring(mx[0].length) ]); } else { throw new $P.Exception(s); } }; }, token: function () { // whitespace-eating token return function (s) { return _.rtoken(new RegExp("^\\s*" + s + "\\s*"))(s); }; }, stoken: function (s) { // string token return _.rtoken(new RegExp("^" + s)); }, // Atomic Operators until: function (p) { return function (s) { var qx = [], rx = null; while (s.length) { try { rx = p.call(this, s); } catch (e) { qx.push(rx[0]); s = rx[1]; continue; } break; } return [ qx, s ]; }; }, many: function (p) { return function (s) { var rx = [], r = null; while (s.length) { try { r = p.call(this, s); } catch (e) { return [ rx, s ]; } rx.push(r[0]); s = r[1]; } return [ rx, s ]; }; }, // generator operators -- see below optional: function (p) { return function (s) { var r = null; try { r = p.call(this, s); } catch (e) { return [ null, s ]; } return [ r[0], r[1] ]; }; }, not: function (p) { return function (s) { try { p.call(this, s); } catch (e) { return [null, s]; } throw new $P.Exception(s); }; }, ignore: function (p) { return p ? function (s) { var r = null; r = p.call(this, s); return [null, r[1]]; } : null; }, product: function () { var px = arguments[0], qx = Array.prototype.slice.call(arguments, 1), rx = []; for (var i = 0 ; i < px.length ; i++) { rx.push(_.each(px[i], qx)); } return rx; }, cache: function (rule) { var cache = {}, cache_length = 0, cache_keys = [], CACHE_MAX = Date.Config.CACHE_MAX || 100000, r = null; var cacheCheck = function () { if (cache_length === CACHE_MAX) { // kill several keys, don't want to have to do this all the time... for (var i=0; i < 10; i++) { var key = cache_keys.shift(); if (key) { delete cache[key]; cache_length--; } } } }; return function (s) { cacheCheck(); try { r = cache[s] = (cache[s] || rule.call(this, s)); } catch (e) { r = cache[s] = e; } cache_length++; cache_keys.push(s); if (r instanceof $P.Exception) { throw r; } else { return r; } }; }, // vector operators -- see below any: function () { var px = arguments; return function (s) { var r = null; for (var i = 0; i < px.length; i++) { if (px[i] == null) { continue; } try { r = (px[i].call(this, s)); } catch (e) { r = null; } if (r) { return r; } } throw new $P.Exception(s); }; }, each: function () { var px = arguments; return function (s) { var rx = [], r = null; for (var i = 0; i < px.length ; i++) { if (px[i] == null) { continue; } try { r = (px[i].call(this, s)); } catch (e) { throw new $P.Exception(s); } rx.push(r[0]); s = r[1]; } return [ rx, s]; }; }, all: function () { var px = arguments, _ = _; return _.each(_.optional(px)); }, // delimited operators sequence: function (px, d, c) { d = d || _.rtoken(/^\s*/); c = c || null; if (px.length === 1) { return px[0]; } return function (s) { var r = null, q = null; var rx = []; for (var i = 0; i < px.length ; i++) { try { r = px[i].call(this, s); } catch (e) { break; } rx.push(r[0]); try { q = d.call(this, r[1]); } catch (ex) { q = null; break; } s = q[1]; } if (!r) { throw new $P.Exception(s); } if (q) { throw new $P.Exception(q[1]); } if (c) { try { r = c.call(this, r[1]); } catch (ey) { throw new $P.Exception(r[1]); } } return [ rx, (r?r[1]:s) ]; }; }, // // Composite Operators // between: function (d1, p, d2) { d2 = d2 || d1; var _fn = _.each(_.ignore(d1), p, _.ignore(d2)); return function (s) { var rx = _fn.call(this, s); return [[rx[0][0], r[0][2]], rx[1]]; }; }, list: function (p, d, c) { d = d || _.rtoken(/^\s*/); c = c || null; return (p instanceof Array ? _.each(_.product(p.slice(0, -1), _.ignore(d)), p.slice(-1), _.ignore(c)) : _.each(_.many(_.each(p, _.ignore(d))), px, _.ignore(c))); }, set: function (px, d, c) { d = d || _.rtoken(/^\s*/); c = c || null; return function (s) { // r is the current match, best the current 'best' match // which means it parsed the most amount of input var r = null, p = null, q = null, rx = null, best = [[], s], last = false; // go through the rules in the given set for (var i = 0; i < px.length ; i++) { // last is a flag indicating whether this must be the last element // if there is only 1 element, then it MUST be the last one q = null; p = null; r = null; last = (px.length === 1); // first, we try simply to match the current pattern // if not, try the next pattern try { r = px[i].call(this, s); } catch (e) { continue; } // since we are matching against a set of elements, the first // thing to do is to add r[0] to matched elements rx = [[r[0]], r[1]]; // if we matched and there is still input to parse and // we don't already know this is the last element, // we're going to next check for the delimiter ... // if there's none, or if there's no input left to parse // than this must be the last element after all ... if (r[1].length > 0 && ! last) { try { q = d.call(this, r[1]); } catch (ex) { last = true; } } else { last = true; } // if we parsed the delimiter and now there's no more input, // that means we shouldn't have parsed the delimiter at all // so don't update r and mark this as the last element ... if (!last && q[1].length === 0) { last = true; } // so, if this isn't the last element, we're going to see if // we can get any more matches from the remaining (unmatched) // elements ... if (!last) { // build a list of the remaining rules we can match against, // i.e., all but the one we just matched against var qx = []; for (var j = 0; j < px.length ; j++) { if (i !== j) { qx.push(px[j]); } } // now invoke recursively set with the remaining input // note that we don't include the closing delimiter ... // we'll check for that ourselves at the end p = _.set(qx, d).call(this, q[1]); // if we got a non-empty set as a result ... // (otw rx already contains everything we want to match) if (p[0].length > 0) { // update current result, which is stored in rx ... // basically, pick up the remaining text from p[1] // and concat the result from p[0] so that we don't // get endless nesting ... rx[0] = rx[0].concat(p[0]); rx[1] = p[1]; } } // at this point, rx either contains the last matched element // or the entire matched set that starts with this element. // now we just check to see if this variation is better than // our best so far, in terms of how much of the input is parsed if (rx[1].length < best[1].length) { best = rx; } // if we've parsed all the input, then we're finished if (best[1].length === 0) { break; } } // so now we've either gone through all the patterns trying them // as the initial match; or we found one that parsed the entire // input string ... // if best has no matches, just return empty set ... if (best[0].length === 0) { return best; } // if a closing delimiter is provided, then we have to check it also if (c) { // we try this even if there is no remaining input because the pattern // may well be optional or match empty input ... try { q = c.call(this, best[1]); } catch (ey) { throw new $P.Exception(best[1]); } // it parsed ... be sure to update the best match remaining input best[1] = q[1]; } // if we're here, either there was no closing delimiter or we parsed it // so now we have the best match; just return it! return best; }; }, forward: function (gr, fname) { return function (s) { return gr[fname].call(this, s); }; }, // // Translation Operators // replace: function (rule, repl) { return function (s) { var r = rule.call(this, s); return [repl, r[1]]; }; }, process: function (rule, fn) { return function (s) { var r = rule.call(this, s); return [fn.call(this, r[0]), r[1]]; }; }, min: function (min, rule) { return function (s) { var rx = rule.call(this, s); if (rx[0].length < min) { throw new $P.Exception(s); } return rx; }; } }; // Generator Operators And Vector Operators // Generators are operators that have a signature of F(R) => R, // taking a given rule and returning another rule, such as // ignore, which parses a given rule and throws away the result. // Vector operators are those that have a signature of F(R1,R2,...) => R, // take a list of rules and returning a new rule, such as each. // Generator operators are converted (via the following _generator // function) into functions that can also take a list or array of rules // and return an array of new rules as though the function had been // called on each rule in turn (which is what actually happens). // This allows generators to be used with vector operators more easily. // Example: // each(ignore(foo, bar)) instead of each(ignore(foo), ignore(bar)) // This also turns generators into vector operators, which allows // constructs like: // not(cache(foo, bar)) var _generator = function (op) { function gen() { var args = null, rx = [], px, i; if (arguments.length > 1) { args = Array.prototype.slice.call(arguments); } else if (arguments[0] instanceof Array) { args = arguments[0]; } if (args) { px = args.shift(); if (px.length > 0) { args.unshift(px[i]); rx.push(op.apply(null, args)); args.shift(); return rx; } } else { return op.apply(null, arguments); } } return gen; }; var gx = "optional not ignore cache".split(/\s/); for (var i = 0 ; i < gx.length ; i++) { _[gx[i]] = _generator(_[gx[i]]); } var _vector = function (op) { return function () { if (arguments[0] instanceof Array) { return op.apply(null, arguments[0]); } else { return op.apply(null, arguments); } }; }; var vx = "each any all".split(/\s/); for (var j = 0 ; j < vx.length ; j++) { _[vx[j]] = _vector(_[vx[j]]); } }()); (function () { var $D = Date; var flattenAndCompact = function (ax) { var rx = []; for (var i = 0; i < ax.length; i++) { if (ax[i] instanceof Array) { rx = rx.concat(flattenAndCompact(ax[i])); } else { if (ax[i]) { rx.push(ax[i]); } } } return rx; }; var parseMeridian = function () { if (this.meridian && (this.hour || this.hour === 0)) { if (this.meridian === "a" && this.hour > 11 && Date.Config.strict24hr){ throw "Invalid hour and meridian combination"; } else if (this.meridian === "p" && this.hour < 12 && Date.Config.strict24hr){ throw "Invalid hour and meridian combination"; } else if (this.meridian === "p" && this.hour < 12) { this.hour = this.hour + 12; } else if (this.meridian === "a" && this.hour === 12) { this.hour = 0; } } }; var setDefaults = function () { var now = new Date(); if ((this.hour || this.minute) && (!this.month && !this.year && !this.day)) { this.day = now.getDate(); } if (!this.year) { this.year = now.getFullYear(); } if (!this.month && this.month !== 0) { this.month = now.getMonth(); } if (!this.day) { this.day = 1; } if (!this.hour) { this.hour = 0; } if (!this.minute) { this.minute = 0; } if (!this.second) { this.second = 0; } if (!this.millisecond) { this.millisecond = 0; } }; var finishUtils = { getToday: function () { if (this.now || "hour minute second".indexOf(this.unit) !== -1) { return new Date(); } else { return $D.today(); } }, setDaysFromWeekday: function (today, orient){ var gap; orient = orient || 1; this.unit = "day"; gap = ($D.getDayNumberFromName(this.weekday) - today.getDay()); this.days = gap ? ((gap + (orient * 7)) % 7) : (orient * 7); return this; }, setMonthsFromMonth: function (today, orient) { var gap; orient = orient || 1; this.unit = "month"; gap = (this.month - today.getMonth()); this.months = gap ? ((gap + (orient * 12)) % 12) : (orient * 12); this.month = null; return this; }, setDMYFromWeekday: function () { var d = Date[this.weekday](); this.day = d.getDate(); if (!this.month) { this.month = d.getMonth(); } this.year = d.getFullYear(); return this; }, setUnitValue: function (orient) { if (!this.value && this.operator && this.operator !== null && this[this.unit + "s"] && this[this.unit + "s"] !== null) { this[this.unit + "s"] = this[this.unit + "s"] + ((this.operator === "add") ? 1 : -1) + (this.value||0) * orient; } else if (this[this.unit + "s"] == null || this.operator != null) { if (!this.value) { this.value = 1; } this[this.unit + "s"] = this.value * orient; } }, generateDateFromWeeks: function () { var weekday = (this.weekday !== undefined) ? this.weekday : "today"; var d = Date[weekday]().addWeeks(this.weeks); if (this.now) { d.setTimeToNow(); } return d; } }; $D.Translator = { hour: function (s) { return function () { this.hour = Number(s); }; }, minute: function (s) { return function () { this.minute = Number(s); }; }, second: function (s) { return function () { this.second = Number(s); }; }, /* for ss.s format */ secondAndMillisecond: function (s) { return function () { var mx = s.match(/^([0-5][0-9])\.([0-9]{1,3})/); this.second = Number(mx[1]); this.millisecond = Number(mx[2]); }; }, meridian: function (s) { return function () { this.meridian = s.slice(0, 1).toLowerCase(); }; }, timezone: function (s) { return function () { var n = s.replace(/[^\d\+\-]/g, ""); if (n.length) { this.timezoneOffset = Number(n); } else { this.timezone = s.toLowerCase(); } }; }, day: function (x) { var s = x[0]; return function () { this.day = Number(s.match(/\d+/)[0]); if (this.day < 1) { throw "invalid day"; } }; }, month: function (s) { return function () { this.month = (s.length === 3) ? "jan feb mar apr may jun jul aug sep oct nov dec".indexOf(s)/4 : Number(s) - 1; if (this.month < 0) { throw "invalid month"; } }; }, year: function (s) { return function () { var n = Number(s); this.year = ((s.length > 2) ? n : (n + (((n + 2000) < Date.CultureInfo.twoDigitYearMax) ? 2000 : 1900))); }; }, rday: function (s) { return function () { switch (s) { case "yesterday": this.days = -1; break; case "tomorrow": this.days = 1; break; case "today": this.days = 0; break; case "now": this.days = 0; this.now = true; break; } }; }, finishExact: function (x) { var d; x = (x instanceof Array) ? x : [x]; for (var i = 0 ; i < x.length ; i++) { if (x[i]) { x[i].call(this); } } setDefaults.call(this); parseMeridian.call(this); if (this.day > $D.getDaysInMonth(this.year, this.month)) { throw new RangeError(this.day + " is not a valid value for days."); } d = new Date(this.year, this.month, this.day, this.hour, this.minute, this.second, this.millisecond); if (this.year < 100) { d.setFullYear(this.year); // means years less that 100 are process correctly. JS will parse it otherwise as 1900-1999. } if (this.timezone) { d.set({ timezone: this.timezone }); } else if (this.timezoneOffset) { d.set({ timezoneOffset: this.timezoneOffset }); } return d; }, finish: function (x) { var today, expression, orient, temp; x = (x instanceof Array) ? flattenAndCompact(x) : [ x ]; if (x.length === 0) { return null; } for (var i = 0 ; i < x.length ; i++) { if (typeof x[i] === "function") { x[i].call(this); } } if (this.now && !this.unit && !this.operator) { return new Date(); } else { today = finishUtils.getToday.call(this); } expression = !!(this.days && this.days !== null || this.orient || this.operator); orient = ((this.orient === "past" || this.operator === "subtract") ? -1 : 1); if (this.month && this.unit === "week") { this.value = this.month + 1; delete this.month; delete this.day; } if ((this.month || this.month === 0) && "year day hour minute second".indexOf(this.unit) !== -1) { if (!this.value) { this.value = this.month + 1; } this.month = null; expression = true; } if (!expression && this.weekday && !this.day && !this.days) { finishUtils.setDMYFromWeekday.call(this); } if (expression && this.weekday && this.unit !== "month" && this.unit !== "week") { finishUtils.setDaysFromWeekday.call(this, today, orient); } if (this.weekday && this.unit !== "week" && !this.day && !this.days) { temp = Date[this.weekday](); this.day = temp.getDate(); if (temp.getMonth() !== today.getMonth()) { this.month = temp.getMonth(); } } if (this.month && this.unit === "day" && this.operator) { if (!this.value) { this.value = (this.month + 1); } this.month = null; } if (this.value != null && this.month != null && this.year != null) { this.day = this.value * 1; } if (this.month && !this.day && this.value) { today.set({ day: this.value * 1 }); if (!expression) { this.day = this.value * 1; } } if (!this.month && this.value && this.unit === "month" && !this.now) { this.month = this.value; expression = true; } if (expression && (this.month || this.month === 0) && this.unit !== "year") { finishUtils.setMonthsFromMonth.call(this, today, orient); } if (!this.unit) { this.unit = "day"; } finishUtils.setUnitValue.call(this, orient); parseMeridian.call(this); if ((this.month || this.month === 0) && !this.day) { this.day = 1; } if (!this.orient && !this.operator && this.unit === "week" && this.value && !this.day && !this.month) { return Date.today().setWeek(this.value); } if (this.unit === "week" && this.weeks && !this.day && !this.month) { return finishUtils.generateDateFromWeeks.call(this); } if (expression && this.timezone && this.day && this.days) { this.day = this.days; } if (expression){ today.add(this); } else { today.set(this); } if (this.timezone) { this.timezone = this.timezone.toUpperCase(); var offset = $D.getTimezoneOffset(this.timezone); var timezone; if (today.hasDaylightSavingTime()) { // lets check that we're being sane with timezone setting timezone = $D.getTimezoneAbbreviation(offset, today.isDaylightSavingTime()); if (timezone !== this.timezone) { // bugger, we're in a place where things like EST vs EDT matters. if (today.isDaylightSavingTime()) { today.addHours(-1); } else { today.addHours(1); } } } today.setTimezoneOffset(offset); } return today; } }; }()); (function () { var $D = Date; $D.Grammar = {}; var _ = $D.Parsing.Operators, g = $D.Grammar, t = $D.Translator, _fn; // Allow rolling up into general purpose rules _fn = function () { return _.each(_.any.apply(null, arguments), _.not(g.ctoken2("timeContext"))); }; g.datePartDelimiter = _.rtoken(/^([\s\-\.\,\/\x27]+)/); g.timePartDelimiter = _.stoken(":"); g.whiteSpace = _.rtoken(/^\s*/); g.generalDelimiter = _.rtoken(/^(([\s\,]|at|@|on)+)/); var _C = {}; g.ctoken = function (keys) { var fn = _C[keys]; if (! fn) { var c = Date.CultureInfo.regexPatterns; var kx = keys.split(/\s+/), px = []; for (var i = 0; i < kx.length ; i++) { px.push(_.replace(_.rtoken(c[kx[i]]), kx[i])); } fn = _C[keys] = _.any.apply(null, px); } return fn; }; g.ctoken2 = function (key) { return _.rtoken(Date.CultureInfo.regexPatterns[key]); }; var cacheProcessRtoken = function (key, token, type, eachToken) { if (eachToken) { g[key] = _.cache(_.process(_.each(_.rtoken(token),_.optional(g.ctoken2(eachToken))), type)); } else { g[key] = _.cache(_.process(_.rtoken(token), type)); } }; var cacheProcessCtoken = function (token, type) { return _.cache(_.process(g.ctoken2(token), type)); }; var _F = {}; //function cache var _get = function (f) { _F[f] = (_F[f] || g.format(f)[0]); return _F[f]; }; g.allformats = function (fx) { var rx = []; if (fx instanceof Array) { for (var i = 0; i < fx.length; i++) { rx.push(_get(fx[i])); } } else { rx.push(_get(fx)); } return rx; }; g.formats = function (fx) { if (fx instanceof Array) { var rx = []; for (var i = 0 ; i < fx.length ; i++) { rx.push(_get(fx[i])); } return _.any.apply(null, rx); } else { return _get(fx); } }; var grammarFormats = { timeFormats: function(){ var i, RTokenKeys = [ "h", "hh", "H", "HH", "m", "mm", "s", "ss", "ss.s", "z", "zz" ], RToken = [ /^(0[0-9]|1[0-2]|[1-9])/, /^(0[0-9]|1[0-2])/, /^([0-1][0-9]|2[0-3]|[0-9])/, /^([0-1][0-9]|2[0-3])/, /^([0-5][0-9]|[0-9])/, /^[0-5][0-9]/, /^([0-5][0-9]|[0-9])/, /^[0-5][0-9]/, /^[0-5][0-9]\.[0-9]{1,3}/, /^((\+|\-)\s*\d\d\d\d)|((\+|\-)\d\d\:?\d\d)/, /^((\+|\-)\s*\d\d\d\d)|((\+|\-)\d\d\:?\d\d)/ ], tokens = [ t.hour, t.hour, t.hour, t.hour, t.minute, t.minute, t.second, t.second, t.secondAndMillisecond, t.timezone, t.timezone ]; for (i=0; i < RTokenKeys.length; i++) { cacheProcessRtoken(RTokenKeys[i], RToken[i], tokens[i]); } g.hms = _.cache(_.sequence([g.H, g.m, g.s], g.timePartDelimiter)); g.t = cacheProcessCtoken("shortMeridian", t.meridian); g.tt = cacheProcessCtoken("longMeridian", t.meridian); g.zzz = cacheProcessCtoken("timezone", t.timezone); g.timeSuffix = _.each(_.ignore(g.whiteSpace), _.set([ g.tt, g.zzz ])); g.time = _.each(_.optional(_.ignore(_.stoken("T"))), g.hms, g.timeSuffix); }, dateFormats: function () { // pre-loaded rules for different date part order preferences var _setfn = function () { return _.set(arguments, g.datePartDelimiter); }; var i, RTokenKeys = [ "d", "dd", "M", "MM", "y", "yy", "yyy", "yyyy" ], RToken = [ /^([0-2]\d|3[0-1]|\d)/, /^([0-2]\d|3[0-1])/, /^(1[0-2]|0\d|\d)/, /^(1[0-2]|0\d)/, /^(\d+)/, /^(\d\d)/, /^(\d\d?\d?\d?)/, /^(\d\d\d\d)/ ], tokens = [ t.day, t.day, t.month, t.month, t.year, t.year, t.year, t.year ], eachToken = [ "ordinalSuffix", "ordinalSuffix" ]; for (i=0; i < RTokenKeys.length; i++) { cacheProcessRtoken(RTokenKeys[i], RToken[i], tokens[i], eachToken[i]); } g.MMM = g.MMMM = _.cache(_.process(g.ctoken("jan feb mar apr may jun jul aug sep oct nov dec"), t.month)); g.ddd = g.dddd = _.cache(_.process(g.ctoken("sun mon tue wed thu fri sat"), function (s) { return function () { this.weekday = s; }; } )); g.day = _fn(g.d, g.dd); g.month = _fn(g.M, g.MMM); g.year = _fn(g.yyyy, g.yy); g.mdy = _setfn(g.ddd, g.month, g.day, g.year); g.ymd = _setfn(g.ddd, g.year, g.month, g.day); g.dmy = _setfn(g.ddd, g.day, g.month, g.year); g.date = function (s) { return ((g[Date.CultureInfo.dateElementOrder] || g.mdy).call(this, s)); }; }, relative: function () { // relative date / time expressions g.orientation = _.process(g.ctoken("past future"), function (s) { return function () { this.orient = s; }; } ); g.operator = _.process(g.ctoken("add subtract"), function (s) { return function () { this.operator = s; }; } ); g.rday = _.process(g.ctoken("yesterday tomorrow today now"), t.rday); g.unit = _.process(g.ctoken("second minute hour day week month year"), function (s) { return function () { this.unit = s; }; } ); } }; g.buildGrammarFormats = function () { // these need to be rebuilt every time the language changes. _C = {}; grammarFormats.timeFormats(); grammarFormats.dateFormats(); grammarFormats.relative(); g.value = _.process(_.rtoken(/^([-+]?\d+)?(st|nd|rd|th)?/), function (s) { return function () { this.value = s.replace(/\D/g, ""); }; } ); g.expression = _.set([g.rday, g.operator, g.value, g.unit, g.orientation, g.ddd, g.MMM ]); g.format = _.process(_.many( _.any( // translate format specifiers into grammar rules _.process( _.rtoken(/^(dd?d?d?(?!e)|MM?M?M?|yy?y?y?|hh?|HH?|mm?|ss?|tt?|zz?z?)/), function (fmt) { if (g[fmt]) { return g[fmt]; } else { throw $D.Parsing.Exception(fmt); } } ), // translate separator tokens into token rules _.process(_.rtoken(/^[^dMyhHmstz]+/), // all legal separators function (s) { return _.ignore(_.stoken(s)); } ) ) ), // construct the parser ... function (rules) { return _.process(_.each.apply(null, rules), t.finishExact); } ); // starting rule for general purpose grammar g._start = _.process(_.set([ g.date, g.time, g.expression ], g.generalDelimiter, g.whiteSpace), t.finish); }; g.buildGrammarFormats(); // parsing date format specifiers - ex: "h:m:s tt" // this little guy will generate a custom parser based // on the format string, ex: g.format("h:m:s tt") // check for these formats first g._formats = g.formats([ "\"yyyy-MM-ddTHH:mm:ssZ\"", "yyyy-MM-ddTHH:mm:ss.sz", "yyyy-MM-ddTHH:mm:ssZ", "yyyy-MM-ddTHH:mm:ssz", "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-ddTHH:mmZ", "yyyy-MM-ddTHH:mmz", "yyyy-MM-ddTHH:mm", "ddd, MMM dd, yyyy H:mm:ss tt", "ddd MMM d yyyy HH:mm:ss zzz", "MMddyyyy", "ddMMyyyy", "Mddyyyy", "ddMyyyy", "Mdyyyy", "dMyyyy", "yyyy", "Mdyy", "dMyy", "d" ]); // real starting rule: tries selected formats first, // then general purpose rule g.start = function (s) { try { var r = g._formats.call({}, s); if (r[1].length === 0) { return r; } } catch (e) {} return g._start.call({}, s); }; }()); (function () { var $D = Date; /** * @desc Converts the specified string value into its JavaScript Date equivalent using CultureInfo specific format information. * * Example

	///////////
	// Dates //
	///////////

	// 15-Oct-2004
	var d1 = Date.parse("10/15/2004");

	// 15-Oct-2004
	var d1 = Date.parse("15-Oct-2004");

	// 15-Oct-2004
	var d1 = Date.parse("2004.10.15");

	//Fri Oct 15, 2004
	var d1 = Date.parse("Fri Oct 15, 2004");

	///////////
	// Times //
	///////////

	// Today at 10 PM.
	var d1 = Date.parse("10 PM");

	// Today at 10:30 PM.
	var d1 = Date.parse("10:30 P.M.");

	// Today at 6 AM.
	var d1 = Date.parse("06am");

	/////////////////////
	// Dates and Times //
	/////////////////////

	// 8-July-2004 @ 10:30 PM
	var d1 = Date.parse("July 8th, 2004, 10:30 PM");

	// 1-July-2004 @ 10:30 PM
	var d1 = Date.parse("2004-07-01T22:30:00");

	////////////////////
	// Relative Dates //
	////////////////////

	// Returns today's date. The string "today" is culture specific.
	var d1 = Date.parse("today");

	// Returns yesterday's date. The string "yesterday" is culture specific.
	var d1 = Date.parse("yesterday");

	// Returns the date of the next thursday.
	var d1 = Date.parse("Next thursday");

	// Returns the date of the most previous monday.
	var d1 = Date.parse("last monday");

	// Returns today's day + one year.
	var d1 = Date.parse("next year");

	///////////////
	// Date Math //
	///////////////

	// Today + 2 days
	var d1 = Date.parse("t+2");

	// Today + 2 days
	var d1 = Date.parse("today + 2 days");

	// Today + 3 months
	var d1 = Date.parse("t+3m");

	// Today - 1 year
	var d1 = Date.parse("today - 1 year");

	// Today - 1 year
	var d1 = Date.parse("t-1y"); 


	/////////////////////////////
	// Partial Dates and Times //
	/////////////////////////////

	// July 15th of this year.
	var d1 = Date.parse("July 15");

	// 15th day of current day and year.
	var d1 = Date.parse("15");

	// July 1st of current year at 10pm.
	var d1 = Date.parse("7/1 10pm");
	
* * @param {String} The string value to convert into a Date object [Required] * @return {Date} A Date object or null if the string cannot be converted into a Date. */ var parseUtils = { removeOrds: function (s) { ords = s.match(/\b(\d+)(?:st|nd|rd|th)\b/); // find ordinal matches s = ((ords && ords.length === 2) ? s.replace(ords[0], ords[1]) : s); return s; }, grammarParser: function (s) { var r = null; try { r = $D.Grammar.start.call({}, s.replace(/^\s*(\S*(\s+\S+)*)\s*$/, "$1")); } catch (e) { return null; } return ((r[1].length === 0) ? r[0] : null); }, nativeFallback: function(s) { var t; try { // ok we haven't parsed it, last ditch attempt with the built-in parser. t = Date._parse(s); return (t || t === 0) ? new Date(t) : null; } catch (e) { return null; } } }; function parse (s) { var d; if (!s) { return null; } if (s instanceof Date) { return s.clone(); } if (s.length >= 4 && s.charAt(0) !== "0" && s.charAt(0) !== "+"&& s.charAt(0) !== "-") { // ie: 2004 will pass, 0800 won't. // Start with specific formats d = $D.Parsing.ISO.parse(s) || $D.Parsing.Numeric.parse(s); } if (d instanceof Date && !isNaN(d.getTime())) { return d; } else { // find ordinal dates (1st, 3rd, 8th, etc and remove them as they cause parsing issues) s = $D.Parsing.Normalizer.parse(parseUtils.removeOrds(s)); d = parseUtils.grammarParser(s); if (d !== null) { return d; } else { return parseUtils.nativeFallback(s); } } } if (!$D._parse) { $D._parse = $D.parse; } $D.parse = parse; Date.getParseFunction = function (fx) { var fns = Date.Grammar.allformats(fx); return function (s) { var r = null; for (var i = 0; i < fns.length; i++) { try { r = fns[i].call({}, s); } catch (e) { continue; } if (r[1].length === 0) { return r[0]; } } return null; }; }; /** * Converts the specified string value into its JavaScript Date equivalent using the specified format {String} or formats {Array} and the CultureInfo specific format information. * The format of the string value must match one of the supplied formats exactly. * * Example

	// 15-Oct-2004
	var d1 = Date.parseExact("10/15/2004", "M/d/yyyy");

	// 15-Oct-2004
	var d1 = Date.parse("15-Oct-2004", "M-ddd-yyyy");

	// 15-Oct-2004
	var d1 = Date.parse("2004.10.15", "yyyy.MM.dd");

	// Multiple formats
	var d1 = Date.parseExact("10/15/2004", ["M/d/yyyy", "MMMM d, yyyy"]);
	
* * @param {String} The string value to convert into a Date object [Required]. * @param {Object} The expected format {String} or an array of expected formats {Array} of the date string [Required]. * @return {Date} A Date object or null if the string cannot be converted into a Date. */ $D.parseExact = function (s, fx) { return $D.getParseFunction(fx)(s); }; }()); (function () { var $D = Date, $P = $D.prototype, // $C = $D.CultureInfo, // not used atm p = function (s, l) { if (!l) { l = 2; } return ("000" + s).slice(l * -1); }; /** * Converts a PHP format string to Java/.NET format string. * A PHP format string can be used with ._format or .format. * A Java/.NET format string can be used with .toString(). * The .parseExact function will only accept a Java/.NET format string * * Example * var f1 = "%m/%d/%y" * var f2 = Date.normalizeFormat(f1); // "MM/dd/yy" * * new Date().format(f1); // "04/13/08" * new Date()._format(f1); // "04/13/08" * new Date().toString(f2); // "04/13/08" * * var date = Date.parseExact("04/13/08", f2); // Sun Apr 13 2008 * * @param {String} A PHP format string consisting of one or more format spcifiers. * @return {String} The PHP format converted to a Java/.NET format string. */ var normalizerSubstitutions = { "d" : "dd", "%d": "dd", "D" : "ddd", "%a": "ddd", "j" : "dddd", "l" : "dddd", "%A": "dddd", "S" : "S", "F" : "MMMM", "%B": "MMMM", "m" : "MM", "%m": "MM", "M" : "MMM", "%b": "MMM", "%h": "MMM", "n" : "M", "Y" : "yyyy", "%Y": "yyyy", "y" : "yy", "%y": "yy", "g" : "h", "%I": "h", "G" : "H", "h" : "hh", "H" : "HH", "%H": "HH", "i" : "mm", "%M": "mm", "s" : "ss", "%S": "ss", "%r": "hh:mm tt", "%R": "H:mm", "%T": "H:mm:ss", "%X": "t", "%x": "d", "%e": "d", "%D": "MM/dd/yy", "%n": "\\n", "%t": "\\t", "e" : "z", "T" : "z", "%z": "z", "%Z": "z", "Z" : "ZZ", "N" : "u", "w" : "u", "%w": "u", "W" : "W", "%V": "W" }; var normalizer = { substitutes: function (m) { return normalizerSubstitutions[m]; }, interpreted: function (m, x) { var y; switch (m) { case "%u": return x.getDay() + 1; case "z": return x.getOrdinalNumber(); case "%j": return p(x.getOrdinalNumber(), 3); case "%U": var d1 = x.clone().set({month: 0, day: 1}).addDays(-1).moveToDayOfWeek(0), d2 = x.clone().addDays(1).moveToDayOfWeek(0, -1); return (d2 < d1) ? "00" : p((d2.getOrdinalNumber() - d1.getOrdinalNumber()) / 7 + 1); case "%W": return p(x.getWeek()); case "t": return $D.getDaysInMonth(x.getFullYear(), x.getMonth()); case "o": case "%G": return x.setWeek(x.getISOWeek()).toString("yyyy"); case "%g": return x._format("%G").slice(-2); case "a": case "%p": return t("tt").toLowerCase(); case "A": return t("tt").toUpperCase(); case "u": return p(x.getMilliseconds(), 3); case "I": return (x.isDaylightSavingTime()) ? 1 : 0; case "O": return x.getUTCOffset(); case "P": y = x.getUTCOffset(); return y.substring(0, y.length - 2) + ":" + y.substring(y.length - 2); case "B": var now = new Date(); return Math.floor(((now.getHours() * 3600) + (now.getMinutes() * 60) + now.getSeconds() + (now.getTimezoneOffset() + 60) * 60) / 86.4); case "c": return x.toISOString().replace(/\"/g, ""); case "U": return $D.strtotime("now"); case "%c": return t("d") + " " + t("t"); case "%C": return Math.floor(x.getFullYear() / 100 + 1); } }, shouldOverrideDefaults: function (m) { switch (m) { case "%e": return true; default: return false; } }, parse: function (m, context) { var formatString, c = context || new Date(); formatString = normalizer.substitutes(m); if (formatString) { return formatString; } formatString = normalizer.interpreted(m, c); if (formatString) { return formatString; } else { return m; } } }; $D.normalizeFormat = function (format, context) { return format.replace(/(%|\\)?.|%%/g, function(t){ return normalizer.parse(t, context); }); }; /** * Format a local Unix timestamp according to locale settings * * Example: * Date.strftime("%m/%d/%y", new Date()); // "04/13/08" * Date.strftime("c", "2008-04-13T17:52:03Z"); // "04/13/08" * * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @param {Number|String} The number representing the number of seconds that have elapsed since January 1, 1970 (local time). * @return {String} A string representation of the current Date object. */ $D.strftime = function (format, time) { var d = Date.parse(time); return d._format(format); }; /** * Parse any textual datetime description into a Unix timestamp. * A Unix timestamp is the number of seconds that have elapsed since January 1, 1970 (midnight UTC/GMT). * * Example: * Date.strtotime("04/13/08"); // 1208044800 * Date.strtotime("1970-01-01T00:00:00Z"); // 0 * * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @param {Object} A string or date object. * @return {String} A string representation of the current Date object. */ $D.strtotime = function (time) { var d = $D.parse(time); return Math.round($D.UTC(d.getUTCFullYear(), d.getUTCMonth(), d.getUTCDate(), d.getUTCHours(), d.getUTCMinutes(), d.getUTCSeconds(), d.getUTCMilliseconds()) / 1000); }; /** * Converts the value of the current Date object to its equivalent string representation using a PHP/Unix style of date format specifiers. * Format Specifiers * Format Description Example * ------ --------------------------------------------------------------------------- ----------------------- * %a abbreviated weekday name according to the current localed "Mon" through "Sun" * %A full weekday name according to the current localed "Sunday" through "Saturday" * %b abbreviated month name according to the current localed "Jan" through "Dec" * %B full month name according to the current locale "January" through "December" * %c preferred date and time representation for the current locale "4/13/2008 12:33 PM" * %C century number (the year divided by 100 and truncated to an integer) "00" to "99" * %d day of the month as a decimal number "01" to "31" * %D same as %m/%d/%y "04/13/08" * %e day of the month as a decimal number, a single digit is preceded by a space "1" to "31" * %g like %G, but without the century "08" * %G The 4-digit year corresponding to the ISO week number (see %V). "2008" * This has the same format and value as %Y, except that if the ISO week number * belongs to the previous or next year, that year is used instead. * %h same as %b "Jan" through "Dec" * %H hour as a decimal number using a 24-hour clock. "00" to "23" * %I hour as a decimal number using a 12-hour clock. "01" to "12" * %j day of the year as a decimal number. "001" to "366" * %m month as a decimal number. "01" to "12" * %M minute as a decimal number. "00" to "59" * %n newline character "\n" * %p either "am" or "pm" according to the given time value, or the "am" or "pm" * corresponding strings for the current locale. * %r time in a.m. and p.m. notation "8:44 PM" * %R time in 24 hour notation "20:44" * %S second as a decimal number "00" to "59" * %t tab character "\t" * %T current time, equal to %H:%M:%S "12:49:11" * %u weekday as a decimal number ["1", "7"], with "1" representing Monday "1" to "7" * %U week number of the current year as a decimal number, starting with the "0" to ("52" or "53") * first Sunday as the first day of the first week * %V The ISO 8601:1988 week number of the current year as a decimal number, "00" to ("52" or "53") * range 01 to 53, where week 1 is the first week that has at least 4 days * in the current year, and with Monday as the first day of the week. * (Use %G or %g for the year component that corresponds to the week number * for the specified timestamp.) * %W week number of the current year as a decimal number, starting with the "00" to ("52" or "53") * first Monday as the first day of the first week * %w day of the week as a decimal, Sunday being "0" "0" to "6" * %x preferred date representation for the current locale without the time "4/13/2008" * %X preferred time representation for the current locale without the date "12:53:05" * %y year as a decimal number without a century "00" "99" * %Y year as a decimal number including the century "2008" * %Z time zone or name or abbreviation "UTC", "EST", "PST" * %z same as %Z * %% a literal "%" characters "%" * d Day of the month, 2 digits with leading zeros "01" to "31" * D A textual representation of a day, three letters "Mon" through "Sun" * j Day of the month without leading zeros "1" to "31" * l A full textual representation of the day of the week (lowercase "L") "Sunday" through "Saturday" * N ISO-8601 numeric representation of the day of the week (added in PHP 5.1.0) "1" (for Monday) through "7" (for Sunday) * S English ordinal suffix for the day of the month, 2 characters "st", "nd", "rd" or "th". Works well with j * w Numeric representation of the day of the week "0" (for Sunday) through "6" (for Saturday) * z The day of the year (starting from "0") "0" through "365" * W ISO-8601 week number of year, weeks starting on Monday "00" to ("52" or "53") * F A full textual representation of a month, such as January or March "January" through "December" * m Numeric representation of a month, with leading zeros "01" through "12" * M A short textual representation of a month, three letters "Jan" through "Dec" * n Numeric representation of a month, without leading zeros "1" through "12" * t Number of days in the given month "28" through "31" * L Whether it's a leap year "1" if it is a leap year, "0" otherwise * o ISO-8601 year number. This has the same value as Y, except that if the "2008" * ISO week number (W) belongs to the previous or next year, that year * is used instead. * Y A full numeric representation of a year, 4 digits "2008" * y A two digit representation of a year "08" * a Lowercase Ante meridiem and Post meridiem "am" or "pm" * A Uppercase Ante meridiem and Post meridiem "AM" or "PM" * B Swatch Internet time "000" through "999" * g 12-hour format of an hour without leading zeros "1" through "12" * G 24-hour format of an hour without leading zeros "0" through "23" * h 12-hour format of an hour with leading zeros "01" through "12" * H 24-hour format of an hour with leading zeros "00" through "23" * i Minutes with leading zeros "00" to "59" * s Seconds, with leading zeros "00" through "59" * u Milliseconds "54321" * e Timezone identifier "UTC", "EST", "PST" * I Whether or not the date is in daylight saving time (uppercase i) "1" if Daylight Saving Time, "0" otherwise * O Difference to Greenwich time (GMT) in hours "+0200", "-0600" * P Difference to Greenwich time (GMT) with colon between hours and minutes "+02:00", "-06:00" * T Timezone abbreviation "UTC", "EST", "PST" * Z Timezone offset in seconds. The offset for timezones west of UTC is "-43200" through "50400" * always negative, and for those east of UTC is always positive. * c ISO 8601 date "2004-02-12T15:19:21+00:00" * r RFC 2822 formatted date "Thu, 21 Dec 2000 16:01:07 +0200" * U Seconds since the Unix Epoch (January 1 1970 00:00:00 GMT) "0" * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @return {String} A string representation of the current Date object. */ var formatReplace = function (context) { return function (m) { var formatString, override = false; if (m.charAt(0) === "\\" || m.substring(0, 2) === "%%") { return m.replace("\\", "").replace("%%", "%"); } override = normalizer.shouldOverrideDefaults(m); formatString = $D.normalizeFormat(m, context); if (formatString) { return context.toString(formatString, override); } }; }; $P._format = function (format) { var formatter = formatReplace(this); if (!format) { return this._toString(); } else { return format.replace(/(%|\\)?.|%%/g, formatter); } }; if (!$P.format) { $P.format = $P._format; } }()); (function () { "use strict"; var gFn = function (attr) { return function () { return this[attr]; }; }; var sFn = function (attr) { return function (val) { this[attr] = val; return this; }; }; var attrs = ["years", "months", "days", "hours", "minutes", "seconds", "milliseconds"]; var addSetFuncs = function (context, attrs) { for (var i = 0; i < attrs.length ; i++) { var $a = attrs[i], $b = $a.slice(0, 1).toUpperCase() + $a.slice(1); context.prototype[$a] = 0; context.prototype["get" + $b] = gFn($a); context.prototype["set" + $b] = sFn($a); } }; /** * new TimeSpan(milliseconds); * new TimeSpan(days, hours, minutes, seconds); * new TimeSpan(days, hours, minutes, seconds, milliseconds); */ var TimeSpan = function (days, hours, minutes, seconds, milliseconds) { if (arguments.length === 1 && typeof days === "number") { var orient = (days < 0) ? -1 : +1; var millsLeft = Math.abs(days); this.setDays(Math.floor(millsLeft / 86400000) * orient); millsLeft = millsLeft % 86400000; this.setHours(Math.floor(millsLeft / 3600000) * orient); millsLeft = millsLeft % 3600000; this.setMinutes(Math.floor(millsLeft / 60000) * orient); millsLeft = millsLeft % 60000; this.setSeconds(Math.floor(millsLeft / 1000) * orient); millsLeft = millsLeft % 1000; this.setMilliseconds(millsLeft * orient); } else { this.set(days, hours, minutes, seconds, milliseconds); } this.getTotalMilliseconds = function () { return (this.getDays() * 86400000) + (this.getHours() * 3600000) + (this.getMinutes() * 60000) + (this.getSeconds() * 1000); }; this.compareTo = function (time) { var t1 = new Date(1970, 1, 1, this.getHours(), this.getMinutes(), this.getSeconds()), t2; if (time === null) { t2 = new Date(1970, 1, 1, 0, 0, 0); } else { t2 = new Date(1970, 1, 1, time.getHours(), time.getMinutes(), time.getSeconds()); } return (t1 < t2) ? -1 : (t1 > t2) ? 1 : 0; }; this.equals = function (time) { return (this.compareTo(time) === 0); }; this.add = function (time) { return (time === null) ? this : this.addSeconds(time.getTotalMilliseconds() / 1000); }; this.subtract = function (time) { return (time === null) ? this : this.addSeconds(-time.getTotalMilliseconds() / 1000); }; this.addDays = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 86400000)); }; this.addHours = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 3600000)); }; this.addMinutes = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 60000)); }; this.addSeconds = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 1000)); }; this.addMilliseconds = function (n) { return new TimeSpan(this.getTotalMilliseconds() + n); }; this.get12HourHour = function () { return (this.getHours() > 12) ? this.getHours() - 12 : (this.getHours() === 0) ? 12 : this.getHours(); }; this.getDesignator = function () { return (this.getHours() < 12) ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator; }; this.toString = function (format) { this._toString = function () { if (this.getDays() !== null && this.getDays() > 0) { return this.getDays() + "." + this.getHours() + ":" + this.p(this.getMinutes()) + ":" + this.p(this.getSeconds()); } else { return this.getHours() + ":" + this.p(this.getMinutes()) + ":" + this.p(this.getSeconds()); } }; this.p = function (s) { return (s.toString().length < 2) ? "0" + s : s; }; var me = this; return format ? format.replace(/dd?|HH?|hh?|mm?|ss?|tt?/g, function (format) { switch (format) { case "d": return me.getDays(); case "dd": return me.p(me.getDays()); case "H": return me.getHours(); case "HH": return me.p(me.getHours()); case "h": return me.get12HourHour(); case "hh": return me.p(me.get12HourHour()); case "m": return me.getMinutes(); case "mm": return me.p(me.getMinutes()); case "s": return me.getSeconds(); case "ss": return me.p(me.getSeconds()); case "t": return ((me.getHours() < 12) ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator).substring(0, 1); case "tt": return (me.getHours() < 12) ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator; } } ) : this._toString(); }; return this; }; addSetFuncs(TimeSpan, attrs.slice(2)); TimeSpan.prototype.set = function (days, hours, minutes, seconds, milliseconds){ this.setDays(days || this.getDays()); this.setHours(hours || this.getHours()); this.setMinutes(minutes || this.getMinutes()); this.setSeconds(seconds || this.getSeconds()); this.setMilliseconds(milliseconds || this.getMilliseconds()); }; /** * Gets the time of day for this date instances. * @return {TimeSpan} TimeSpan */ Date.prototype.getTimeOfDay = function () { return new TimeSpan(0, this.getHours(), this.getMinutes(), this.getSeconds(), this.getMilliseconds()); }; Date.TimeSpan = TimeSpan; if (typeof window !== "undefined" ) { // keeping API compatible for v1.x window.TimeSpan = TimeSpan; } }()); (function () { "use strict"; var attrs = ["years", "months", "days", "hours", "minutes", "seconds", "milliseconds"]; var gFn = function (attr) { return function () { return this[attr]; }; }; var sFn = function (attr) { return function (val) { this[attr] = val; return this; }; }; var addSetFuncs = function (context, attrs) { for (var i = 0; i < attrs.length ; i++) { var $a = attrs[i], $b = $a.slice(0, 1).toUpperCase() + $a.slice(1); context.prototype[$a] = 0; context.prototype["get" + $b] = gFn($a); context.prototype["set" + $b] = sFn($a); } }; var setMonthsAndYears = function (orient, d1, d2, context) { function inc() { d1.addMonths(-orient); context.months++; if (context.months === 12) { context.years++; context.months = 0; } } if (orient === +1) { while (d1 > d2) { inc(); } } else { while (d1 < d2) { inc(); } } context.months--; context.months *= orient; context.years *= orient; }; var adjustForDST = function(orient, startDate, endDate) { var hasDSTMismatch = (false === (startDate.isDaylightSavingTime() === endDate.isDaylightSavingTime())); if (hasDSTMismatch && orient === 1) { startDate.addHours(-1); } else if (hasDSTMismatch) { startDate.addHours(1); } }; /** * TimePeriod(startDate, endDate); * TimePeriod(years, months, days, hours, minutes, seconds, milliseconds); */ var TimePeriod = function (years, months, days, hours, minutes, seconds, milliseconds) { if (arguments.length === 7) { this.set(years, months, days, hours, minutes, seconds, milliseconds); } else if (arguments.length === 2 && arguments[0] instanceof Date && arguments[1] instanceof Date) { var startDate = arguments[0].clone(); var endDate = arguments[1].clone(); var orient = (startDate > endDate) ? +1 : -1; this.dates = { start: arguments[0].clone(), end: arguments[1].clone() }; setMonthsAndYears(orient, startDate, endDate, this); adjustForDST(orient, startDate, endDate); // // TODO - adjust for DST var diff = endDate - startDate; if (diff !== 0) { var ts = new TimeSpan(diff); this.set(this.years, this.months, ts.getDays(), ts.getHours(), ts.getMinutes(), ts.getSeconds(), ts.getMilliseconds()); } } return this; }; // create all the set functions. addSetFuncs(TimePeriod, attrs); TimePeriod.prototype.set = function (years, months, days, hours, minutes, seconds, milliseconds){ this.setYears(years || this.getYears()); this.setMonths(months || this.getMonths()); this.setDays(days || this.getDays()); this.setHours(hours || this.getHours()); this.setMinutes(minutes || this.getMinutes()); this.setSeconds(seconds || this.getSeconds()); this.setMilliseconds(milliseconds || this.getMilliseconds()); }; Date.TimePeriod = TimePeriod; if (typeof window !== "undefined") { // keeping API compatible for v1.x window.TimePeriod = TimePeriod; } }()); ================================================ FILE: build/date-es-PE.js ================================================ /** * @overview datejs * @version 1.0.0-rc3 * @author Gregory Wild-Smith * @copyright 2015 Gregory Wild-Smith * @license MIT * @homepage https://github.com/abritinthebay/datejs */ /* * DateJS Culture String File * Country Code: es-PE * Name: Spanish (Peru) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["es-PE"] = { "name": "es-PE", "englishName": "Spanish (Peru)", "nativeName": "Español (Perú)", "Sunday": "domingo", "Monday": "lunes", "Tuesday": "martes", "Wednesday": "miércoles", "Thursday": "jueves", "Friday": "viernes", "Saturday": "sábado", "Sun": "dom", "Mon": "lun", "Tue": "mar", "Wed": "mié", "Thu": "jue", "Fri": "vie", "Sat": "sáb", "Su": "do", "Mo": "lu", "Tu": "ma", "We": "mi", "Th": "ju", "Fr": "vi", "Sa": "sá", "S_Sun_Initial": "d", "M_Mon_Initial": "l", "T_Tue_Initial": "m", "W_Wed_Initial": "m", "T_Thu_Initial": "j", "F_Fri_Initial": "v", "S_Sat_Initial": "s", "January": "enero", "February": "febrero", "March": "marzo", "April": "abril", "May": "mayo", "June": "junio", "July": "julio", "August": "agosto", "September": "septiembre", "October": "octubre", "November": "noviembre", "December": "diciembre", "Jan_Abbr": "ene", "Feb_Abbr": "feb", "Mar_Abbr": "mar", "Apr_Abbr": "abr", "May_Abbr": "may", "Jun_Abbr": "jun", "Jul_Abbr": "jul", "Aug_Abbr": "ago", "Sep_Abbr": "sep", "Oct_Abbr": "oct", "Nov_Abbr": "nov", "Dec_Abbr": "dic", "AM": "a.m.", "PM": "p.m.", "firstDayOfWeek": 0, "twoDigitYearMax": 2029, "mdy": "dmy", "M/d/yyyy": "dd/MM/yyyy", "dddd, MMMM dd, yyyy": "dddd, dd' [de] 'MMMM' [de] 'yyyy", "h:mm tt": "hh:mm tt", "h:mm:ss tt": "hh:mm:ss tt", "dddd, MMMM dd, yyyy h:mm:ss tt": "dddd, dd' [de] 'MMMM' [de] 'yyyy hh:mm:ss tt", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "dd MMMM", "MMMM, yyyy": "MMMM' [de] 'yyyy", "/jan(uary)?/": "ene(ro)?", "/feb(ruary)?/": "feb(rero)?", "/mar(ch)?/": "mar(zo)?", "/apr(il)?/": "abr(il)?", "/may/": "may(o)?", "/jun(e)?/": "jun(io)?", "/jul(y)?/": "jul(io)?", "/aug(ust)?/": "ago(sto)?", "/sep(t(ember)?)?/": "sep(tiembre)?", "/oct(ober)?/": "oct(ubre)?", "/nov(ember)?/": "nov(iembre)?", "/dec(ember)?/": "dic(iembre)?", "/^su(n(day)?)?/": "^do(m(ingo)?)?", "/^mo(n(day)?)?/": "^lu(n(es)?)?", "/^tu(e(s(day)?)?)?/": "^ma(r(tes)?)?", "/^we(d(nesday)?)?/": "^mi(é(rcoles)?)?", "/^th(u(r(s(day)?)?)?)?/": "^ju(e(ves)?)?", "/^fr(i(day)?)?/": "^vi(e(rnes)?)?", "/^sa(t(urday)?)?/": "^sá(b(ado)?)?", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "es-PE"; /** * @overview datejs * @version 1.0.0-rc3 * @author Gregory Wild-Smith * @copyright 2015 Gregory Wild-Smith * @license MIT * @homepage https://github.com/abritinthebay/datejs */(function () { var $D = Date; var lang = Date.CultureStrings ? Date.CultureStrings.lang : null; var loggedKeys = {}; // for debug purposes. var getText = { getFromKey: function (key, countryCode) { var output; if (Date.CultureStrings && Date.CultureStrings[countryCode] && Date.CultureStrings[countryCode][key]) { output = Date.CultureStrings[countryCode][key]; } else { output = getText.buildFromDefault(key); } if (key.charAt(0) === "/") { // Assume it's a regex output = getText.buildFromRegex(key, countryCode); } return output; }, getFromObjectValues: function (obj, countryCode) { var key, output = {}; for(key in obj) { if (obj.hasOwnProperty(key)) { output[key] = getText.getFromKey(obj[key], countryCode); } } return output; }, getFromObjectKeys: function (obj, countryCode) { var key, output = {}; for(key in obj) { if (obj.hasOwnProperty(key)) { output[getText.getFromKey(key, countryCode)] = obj[key]; } } return output; }, getFromArray: function (arr, countryCode) { var output = []; for (var i=0; i < arr.length; i++){ if (i in arr) { output[i] = getText.getFromKey(arr[i], countryCode); } } return output; }, buildFromDefault: function (key) { var output, length, split, last; switch(key) { case "name": output = "en-US"; break; case "englishName": output = "English (United States)"; break; case "nativeName": output = "English (United States)"; break; case "twoDigitYearMax": output = 2049; break; case "firstDayOfWeek": output = 0; break; default: output = key; split = key.split("_"); length = split.length; if (length > 1 && key.charAt(0) !== "/") { // if the key isn't a regex and it has a split. last = split[(length - 1)].toLowerCase(); if (last === "initial" || last === "abbr") { output = split[0]; } } break; } return output; }, buildFromRegex: function (key, countryCode) { var output; if (Date.CultureStrings && Date.CultureStrings[countryCode] && Date.CultureStrings[countryCode][key]) { output = new RegExp(Date.CultureStrings[countryCode][key], "i"); } else { output = new RegExp(key.replace(new RegExp("/", "g"),""), "i"); } return output; } }; var shallowMerge = function (obj1, obj2) { for (var attrname in obj2) { if (obj2.hasOwnProperty(attrname)) { obj1[attrname] = obj2[attrname]; } } }; var __ = function (key, language) { var countryCode = (language) ? language : lang; loggedKeys[key] = key; if (typeof key === "object") { if (key instanceof Array) { return getText.getFromArray(key, countryCode); } else { return getText.getFromObjectKeys(key, countryCode); } } else { return getText.getFromKey(key, countryCode); } }; var loadI18nScript = function (code) { // paatterned after jQuery's getScript. var url = Date.Config.i18n + code + ".js"; var head = document.getElementsByTagName("head")[0] || document.documentElement; var script = document.createElement("script"); script.src = url; var completed = false; var events = { done: function (){} // placeholder function }; // Attach handlers for all browsers script.onload = script.onreadystatechange = function() { if ( !completed && (!this.readyState || this.readyState === "loaded" || this.readyState === "complete") ) { events.done(); head.removeChild(script); } }; setTimeout(function() { head.insertBefore(script, head.firstChild); }, 0); // allows return to execute first return { done: function (cb) { events.done = function() { if (cb) { setTimeout(cb,0); } }; } }; }; var buildInfo = { buildFromMethodHash: function (obj) { var key; for(key in obj) { if (obj.hasOwnProperty(key)) { obj[key] = buildInfo[obj[key]](); } } return obj; }, timeZoneDST: function () { var DST = { "CHADT": "+1345", "NZDT": "+1300", "AEDT": "+1100", "ACDT": "+1030", "AZST": "+0500", "IRDT": "+0430", "EEST": "+0300", "CEST": "+0200", "BST": "+0100", "PMDT": "-0200", "ADT": "-0300", "NDT": "-0230", "EDT": "-0400", "CDT": "-0500", "MDT": "-0600", "PDT": "-0700", "AKDT": "-0800", "HADT": "-0900" }; return __(DST); }, timeZoneStandard: function () { var standard = { "LINT": "+1400", "TOT": "+1300", "CHAST": "+1245", "NZST": "+1200", "NFT": "+1130", "SBT": "+1100", "AEST": "+1000", "ACST": "+0930", "JST": "+0900", "CWST": "+0845", "CT": "+0800", "ICT": "+0700", "MMT": "+0630", "BST": "+0600", "NPT": "+0545", "IST": "+0530", "PKT": "+0500", "AFT": "+0430", "MSK": "+0400", "IRST": "+0330", "FET": "+0300", "EET": "+0200", "CET": "+0100", "GMT": "+0000", "UTC": "+0000", "CVT": "-0100", "GST": "-0200", "BRT": "-0300", "NST": "-0330", "AST": "-0400", "EST": "-0500", "CST": "-0600", "MST": "-0700", "PST": "-0800", "AKST": "-0900", "MIT": "-0930", "HST": "-1000", "SST": "-1100", "BIT": "-1200" }; return __(standard); }, timeZones: function (data) { var zone; data.timezones = []; for (zone in data.abbreviatedTimeZoneStandard) { if (data.abbreviatedTimeZoneStandard.hasOwnProperty(zone)) { data.timezones.push({ name: zone, offset: data.abbreviatedTimeZoneStandard[zone]}); } } for (zone in data.abbreviatedTimeZoneDST) { if (data.abbreviatedTimeZoneDST.hasOwnProperty(zone)) { data.timezones.push({ name: zone, offset: data.abbreviatedTimeZoneDST[zone], dst: true}); } } return data.timezones; }, days: function () { return __(["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"]); }, dayAbbr: function () { return __(["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"]); }, dayShortNames: function () { return __(["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"]); }, dayFirstLetters: function () { return __(["S_Sun_Initial", "M_Mon_Initial", "T_Tues_Initial", "W_Wed_Initial", "T_Thu_Initial", "F_Fri_Initial", "S_Sat_Initial"]); }, months: function () { return __(["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"]); }, monthAbbr: function () { return __(["Jan_Abbr", "Feb_Abbr", "Mar_Abbr", "Apr_Abbr", "May_Abbr", "Jun_Abbr", "Jul_Abbr", "Aug_Abbr", "Sep_Abbr", "Oct_Abbr", "Nov_Abbr", "Dec_Abbr"]); }, formatPatterns: function () { return getText.getFromObjectValues({ shortDate: "M/d/yyyy", longDate: "dddd, MMMM dd, yyyy", shortTime: "h:mm tt", longTime: "h:mm:ss tt", fullDateTime: "dddd, MMMM dd, yyyy h:mm:ss tt", sortableDateTime: "yyyy-MM-ddTHH:mm:ss", universalSortableDateTime: "yyyy-MM-dd HH:mm:ssZ", rfc1123: "ddd, dd MMM yyyy HH:mm:ss", monthDay: "MMMM dd", yearMonth: "MMMM, yyyy" }, Date.i18n.currentLanguage()); }, regex: function () { return getText.getFromObjectValues({ inTheMorning: "/( in the )(morn(ing)?)\\b/", thisMorning: "/(this )(morn(ing)?)\\b/", amThisMorning: "/(\b\\d(am)? )(this )(morn(ing)?)/", inTheEvening: "/( in the )(even(ing)?)\\b/", thisEvening: "/(this )(even(ing)?)\\b/", pmThisEvening: "/(\b\\d(pm)? )(this )(even(ing)?)/", jan: "/jan(uary)?/", feb: "/feb(ruary)?/", mar: "/mar(ch)?/", apr: "/apr(il)?/", may: "/may/", jun: "/jun(e)?/", jul: "/jul(y)?/", aug: "/aug(ust)?/", sep: "/sep(t(ember)?)?/", oct: "/oct(ober)?/", nov: "/nov(ember)?/", dec: "/dec(ember)?/", sun: "/^su(n(day)?)?/", mon: "/^mo(n(day)?)?/", tue: "/^tu(e(s(day)?)?)?/", wed: "/^we(d(nesday)?)?/", thu: "/^th(u(r(s(day)?)?)?)?/", fri: "/fr(i(day)?)?/", sat: "/^sa(t(urday)?)?/", future: "/^next/", past: "/^last|past|prev(ious)?/", add: "/^(\\+|aft(er)?|from|hence)/", subtract: "/^(\\-|bef(ore)?|ago)/", yesterday: "/^yes(terday)?/", today: "/^t(od(ay)?)?/", tomorrow: "/^tom(orrow)?/", now: "/^n(ow)?/", millisecond: "/^ms|milli(second)?s?/", second: "/^sec(ond)?s?/", minute: "/^mn|min(ute)?s?/", hour: "/^h(our)?s?/", week: "/^w(eek)?s?/", month: "/^m(onth)?s?/", day: "/^d(ay)?s?/", year: "/^y(ear)?s?/", shortMeridian: "/^(a|p)/", longMeridian: "/^(a\\.?m?\\.?|p\\.?m?\\.?)/", timezone: "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/", ordinalSuffix: "/^\\s*(st|nd|rd|th)/", timeContext: "/^\\s*(\\:|a(?!u|p)|p)/" }, Date.i18n.currentLanguage()); } }; var CultureInfo = function () { var info = getText.getFromObjectValues({ name: "name", englishName: "englishName", nativeName: "nativeName", amDesignator: "AM", pmDesignator: "PM", firstDayOfWeek: "firstDayOfWeek", twoDigitYearMax: "twoDigitYearMax", dateElementOrder: "mdy" }, Date.i18n.currentLanguage()); var constructedInfo = buildInfo.buildFromMethodHash({ dayNames: "days", abbreviatedDayNames: "dayAbbr", shortestDayNames: "dayShortNames", firstLetterDayNames: "dayFirstLetters", monthNames: "months", abbreviatedMonthNames: "monthAbbr", formatPatterns: "formatPatterns", regexPatterns: "regex", abbreviatedTimeZoneDST: "timeZoneDST", abbreviatedTimeZoneStandard: "timeZoneStandard" }); shallowMerge(info, constructedInfo); buildInfo.timeZones(info); return info; }; $D.i18n = { __: function (key, lang) { return __(key, lang); }, currentLanguage: function () { return lang || "en-US"; }, setLanguage: function (code, force, cb) { var async = false; if (force || code === "en-US" || (!!Date.CultureStrings && !!Date.CultureStrings[code])) { lang = code; Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings.lang = code; Date.CultureInfo = new CultureInfo(); } else { if (!(!!Date.CultureStrings && !!Date.CultureStrings[code])) { if (typeof exports !== "undefined" && this.exports !== exports) { // we're in a Node enviroment, load it using require try { require("../i18n/" + code + ".js"); lang = code; Date.CultureStrings.lang = code; Date.CultureInfo = new CultureInfo(); } catch (e) { // var str = "The language for '" + code + "' could not be loaded by Node. It likely does not exist."; throw new Error("The DateJS IETF language tag '" + code + "' could not be loaded by Node. It likely does not exist."); } } else if (Date.Config && Date.Config.i18n) { // we know the location of the files, so lets load them async = true; loadI18nScript(code).done(function(){ lang = code; Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings.lang = code; Date.CultureInfo = new CultureInfo(); $D.Parsing.Normalizer.buildReplaceData(); // because this is async if ($D.Grammar) { $D.Grammar.buildGrammarFormats(); // so we can parse those strings... } if (cb) { setTimeout(cb,0); } }); } else { Date.console.error("The DateJS IETF language tag '" + code + "' is not available and has not been loaded."); return false; } } } $D.Parsing.Normalizer.buildReplaceData(); // rebuild normalizer strings if ($D.Grammar) { $D.Grammar.buildGrammarFormats(); // so we can parse those strings... } if (!async && cb) { setTimeout(cb,0); } }, getLoggedKeys: function () { return loggedKeys; }, updateCultureInfo: function () { Date.CultureInfo = new CultureInfo(); } }; $D.i18n.updateCultureInfo(); // run automatically }()); (function () { var $D = Date, $P = $D.prototype, p = function (s, l) { if (!l) { l = 2; } return ("000" + s).slice(l * -1); }; if (typeof window !== "undefined" && typeof window.console !== "undefined" && typeof window.console.log !== "undefined") { $D.console = console; // used only to raise non-critical errors if available } else { // set mock so we don't give errors. $D.console = { log: function(){}, error: function(){} }; } $D.Config = $D.Config || {}; $D.initOverloads = function() { /** * Overload of Date.now. Allows an alternate call for Date.now where it returns the * current Date as an object rather than just milliseconds since the Unix Epoch. * * Also provides an implementation of now() for browsers (IE<9) that don't have it. * * Backwards compatible so with work with either: * Date.now() [returns ms] * or * Date.now(true) [returns Date] */ if (!$D.now) { $D._now = function now() { return new Date().getTime(); }; } else if (!$D._now) { $D._now = $D.now; } $D.now = function (returnObj) { if (returnObj) { return $D.present(); } else { return $D._now(); } }; if ( !$P.toISOString ) { $P.toISOString = function() { return this.getUTCFullYear() + "-" + p(this.getUTCMonth() + 1) + "-" + p(this.getUTCDate()) + "T" + p(this.getUTCHours()) + ":" + p(this.getUTCMinutes()) + ":" + p(this.getUTCSeconds()) + "." + String( (this.getUTCMilliseconds()/1000).toFixed(3)).slice(2, 5) + "Z"; }; } // private if ( $P._toString === undefined ){ $P._toString = $P.toString; } }; $D.initOverloads(); /** * Gets a date that is set to the current date. The time is set to the start of the day (00:00 or 12:00 AM). * @return {Date} The current date. */ $D.today = function () { return new Date().clearTime(); }; /** * Gets a date that is set to the current date and time (same as new Date, but chainable) * @return {Date} The current date. */ $D.present = function () { return new Date(); }; /** * Compares the first date to the second date and returns an number indication of their relative values. * @param {Date} First Date object to compare [Required]. * @param {Date} Second Date object to compare to [Required]. * @return {Number} -1 = date1 is lessthan date2. 0 = values are equal. 1 = date1 is greaterthan date2. */ $D.compare = function (date1, date2) { if (isNaN(date1) || isNaN(date2)) { throw new Error(date1 + " - " + date2); } else if (date1 instanceof Date && date2 instanceof Date) { return (date1 < date2) ? -1 : (date1 > date2) ? 1 : 0; } else { throw new TypeError(date1 + " - " + date2); } }; /** * Compares the first Date object to the second Date object and returns true if they are equal. * @param {Date} First Date object to compare [Required] * @param {Date} Second Date object to compare to [Required] * @return {Boolean} true if dates are equal. false if they are not equal. */ $D.equals = function (date1, date2) { return (date1.compareTo(date2) === 0); }; /** * Gets the language appropriate day name when given the day number(0-6) * eg - 0 == Sunday * @return {String} The day name */ $D.getDayName = function (n) { return Date.CultureInfo.dayNames[n]; }; /** * Gets the day number (0-6) if given a CultureInfo specific string which is a valid dayName, abbreviatedDayName or shortestDayName (two char). * @param {String} The name of the day (eg. "Monday, "Mon", "tuesday", "tue", "We", "we"). * @return {Number} The day number */ $D.getDayNumberFromName = function (name) { var n = Date.CultureInfo.dayNames, m = Date.CultureInfo.abbreviatedDayNames, o = Date.CultureInfo.shortestDayNames, s = name.toLowerCase(); for (var i = 0; i < n.length; i++) { if (n[i].toLowerCase() === s || m[i].toLowerCase() === s || o[i].toLowerCase() === s) { return i; } } return -1; }; /** * Gets the month number (0-11) if given a Culture Info specific string which is a valid monthName or abbreviatedMonthName. * @param {String} The name of the month (eg. "February, "Feb", "october", "oct"). * @return {Number} The day number */ $D.getMonthNumberFromName = function (name) { var n = Date.CultureInfo.monthNames, m = Date.CultureInfo.abbreviatedMonthNames, s = name.toLowerCase(); for (var i = 0; i < n.length; i++) { if (n[i].toLowerCase() === s || m[i].toLowerCase() === s) { return i; } } return -1; }; /** * Gets the language appropriate month name when given the month number(0-11) * eg - 0 == January * @return {String} The month name */ $D.getMonthName = function (n) { return Date.CultureInfo.monthNames[n]; }; /** * Determines if the current date instance is within a LeapYear. * @param {Number} The year. * @return {Boolean} true if date is within a LeapYear, otherwise false. */ $D.isLeapYear = function (year) { return ((year % 4 === 0 && year % 100 !== 0) || year % 400 === 0); }; /** * Gets the number of days in the month, given a year and month value. Automatically corrects for LeapYear. * @param {Number} The year. * @param {Number} The month (0-11). * @return {Number} The number of days in the month. */ $D.getDaysInMonth = function (year, month) { if (!month && $D.validateMonth(year)) { month = year; year = Date.today().getFullYear(); } return [31, ($D.isLeapYear(year) ? 29 : 28), 31, 30, 31, 30, 31, 31, 30, 31, 30, 31][month]; }; $P.getDaysInMonth = function () { return $D.getDaysInMonth(this.getFullYear(), this.getMonth()); }; $D.getTimezoneAbbreviation = function (offset, dst) { var p, n = (dst || false) ? Date.CultureInfo.abbreviatedTimeZoneDST : Date.CultureInfo.abbreviatedTimeZoneStandard; for (p in n) { if (n.hasOwnProperty(p)) { if (n[p] === offset) { return p; } } } return null; }; $D.getTimezoneOffset = function (name, dst) { var i, a =[], z = Date.CultureInfo.timezones; if (!name) { name = (new Date()).getTimezone();} for (i = 0; i < z.length; i++) { if (z[i].name === name.toUpperCase()) { a.push(i); } } if (!z[a[0]]) { return null; } if (a.length === 1 || !dst) { return z[a[0]].offset; } else { for (i=0; i < a.length; i++) { if (z[a[i]].dst) { return z[a[i]].offset; } } } }; $D.getQuarter = function (d) { d = d || new Date(); // If no date supplied, use today var q = [1,2,3,4]; return q[Math.floor(d.getMonth() / 3)]; // ~~~ is a bitwise op. Faster than Math.floor }; $D.getDaysLeftInQuarter = function (d) { d = d || new Date(); var qEnd = new Date(d); qEnd.setMonth(qEnd.getMonth() + 3 - qEnd.getMonth() % 3, 0); return Math.floor((qEnd - d) / 8.64e7); }; // private var validate = function (n, min, max, name) { name = name ? name : "Object"; if (typeof n === "undefined") { return false; } else if (typeof n !== "number") { throw new TypeError(n + " is not a Number."); } else if (n < min || n > max) { // As failing validation is *not* an exceptional circumstance // lets not throw a RangeError Exception here. // It's semantically correct but it's not sensible. return false; } return true; }; /** * Validates the number is within an acceptable range for milliseconds [0-999]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateMillisecond = function (value) { return validate(value, 0, 999, "millisecond"); }; /** * Validates the number is within an acceptable range for seconds [0-59]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateSecond = function (value) { return validate(value, 0, 59, "second"); }; /** * Validates the number is within an acceptable range for minutes [0-59]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateMinute = function (value) { return validate(value, 0, 59, "minute"); }; /** * Validates the number is within an acceptable range for hours [0-23]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateHour = function (value) { return validate(value, 0, 23, "hour"); }; /** * Validates the number is within an acceptable range for the days in a month [0-MaxDaysInMonth]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateDay = function (value, year, month) { if (year === undefined || year === null || month === undefined || month === null) { return false;} return validate(value, 1, $D.getDaysInMonth(year, month), "day"); }; /** * Validates the number is within an acceptable range for months [0-11]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateWeek = function (value) { return validate(value, 0, 53, "week"); }; /** * Validates the number is within an acceptable range for months [0-11]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateMonth = function (value) { return validate(value, 0, 11, "month"); }; /** * Validates the number is within an acceptable range for years. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateYear = function (value) { /** * Per ECMAScript spec the range of times supported by Date objects is * exactly -100,000,000 days to +100,000,000 days measured relative to * midnight at the beginning of 01 January, 1970 UTC. * This gives a range of 8,640,000,000,000,000 milliseconds to either * side of 01 January, 1970 UTC. * * Earliest possible date: Tue, 20 Apr 271,822 B.C. 00:00:00 UTC * Latest possible date: Sat, 13 Sep 275,760 00:00:00 UTC */ return validate(value, -271822, 275760, "year"); }; $D.validateTimezone = function(value) { var timezones = {"ACDT":1,"ACST":1,"ACT":1,"ADT":1,"AEDT":1,"AEST":1,"AFT":1,"AKDT":1,"AKST":1,"AMST":1,"AMT":1,"ART":1,"AST":1,"AWDT":1,"AWST":1,"AZOST":1,"AZT":1,"BDT":1,"BIOT":1,"BIT":1,"BOT":1,"BRT":1,"BST":1,"BTT":1,"CAT":1,"CCT":1,"CDT":1,"CEDT":1,"CEST":1,"CET":1,"CHADT":1,"CHAST":1,"CHOT":1,"ChST":1,"CHUT":1,"CIST":1,"CIT":1,"CKT":1,"CLST":1,"CLT":1,"COST":1,"COT":1,"CST":1,"CT":1,"CVT":1,"CWST":1,"CXT":1,"DAVT":1,"DDUT":1,"DFT":1,"EASST":1,"EAST":1,"EAT":1,"ECT":1,"EDT":1,"EEDT":1,"EEST":1,"EET":1,"EGST":1,"EGT":1,"EIT":1,"EST":1,"FET":1,"FJT":1,"FKST":1,"FKT":1,"FNT":1,"GALT":1,"GAMT":1,"GET":1,"GFT":1,"GILT":1,"GIT":1,"GMT":1,"GST":1,"GYT":1,"HADT":1,"HAEC":1,"HAST":1,"HKT":1,"HMT":1,"HOVT":1,"HST":1,"ICT":1,"IDT":1,"IOT":1,"IRDT":1,"IRKT":1,"IRST":1,"IST":1,"JST":1,"KGT":1,"KOST":1,"KRAT":1,"KST":1,"LHST":1,"LINT":1,"MAGT":1,"MART":1,"MAWT":1,"MDT":1,"MET":1,"MEST":1,"MHT":1,"MIST":1,"MIT":1,"MMT":1,"MSK":1,"MST":1,"MUT":1,"MVT":1,"MYT":1,"NCT":1,"NDT":1,"NFT":1,"NPT":1,"NST":1,"NT":1,"NUT":1,"NZDT":1,"NZST":1,"OMST":1,"ORAT":1,"PDT":1,"PET":1,"PETT":1,"PGT":1,"PHOT":1,"PHT":1,"PKT":1,"PMDT":1,"PMST":1,"PONT":1,"PST":1,"PYST":1,"PYT":1,"RET":1,"ROTT":1,"SAKT":1,"SAMT":1,"SAST":1,"SBT":1,"SCT":1,"SGT":1,"SLST":1,"SRT":1,"SST":1,"SYOT":1,"TAHT":1,"THA":1,"TFT":1,"TJT":1,"TKT":1,"TLT":1,"TMT":1,"TOT":1,"TVT":1,"UCT":1,"ULAT":1,"UTC":1,"UYST":1,"UYT":1,"UZT":1,"VET":1,"VLAT":1,"VOLT":1,"VOST":1,"VUT":1,"WAKT":1,"WAST":1,"WAT":1,"WEDT":1,"WEST":1,"WET":1,"WST":1,"YAKT":1,"YEKT":1,"Z":1}; return (timezones[value] === 1); }; $D.validateTimezoneOffset= function(value) { // timezones go from +14hrs to -12hrs, the +X hours are negative offsets. return (value > -841 && value < 721); }; }()); (function () { var $D = Date, $P = $D.prototype, p = function (s, l) { if (!l) { l = 2; } return ("000" + s).slice(l * -1); }; var validateConfigObject = function (obj) { var result = {}, self = this, prop, testFunc; testFunc = function (prop, func, value) { if (prop === "day") { var month = (obj.month !== undefined) ? obj.month : self.getMonth(); var year = (obj.year !== undefined) ? obj.year : self.getFullYear(); return $D[func](value, year, month); } else { return $D[func](value); } }; for (prop in obj) { if (Object.prototype.hasOwnProperty.call(obj, prop)) { var func = "validate" + prop.charAt(0).toUpperCase() + prop.slice(1); if ($D[func] && obj[prop] !== null && testFunc(prop, func, obj[prop])) { result[prop] = obj[prop]; } } } return result; }; /** * Resets the time of this Date object to 12:00 AM (00:00), which is the start of the day. * @param {Boolean} .clone() this date instance before clearing Time * @return {Date} this */ $P.clearTime = function () { this.setHours(0); this.setMinutes(0); this.setSeconds(0); this.setMilliseconds(0); return this; }; /** * Resets the time of this Date object to the current time ('now'). * @return {Date} this */ $P.setTimeToNow = function () { var n = new Date(); this.setHours(n.getHours()); this.setMinutes(n.getMinutes()); this.setSeconds(n.getSeconds()); this.setMilliseconds(n.getMilliseconds()); return this; }; /** * Returns a new Date object that is an exact date and time copy of the original instance. * @return {Date} A new Date instance */ $P.clone = function () { return new Date(this.getTime()); }; /** * Compares this instance to a Date object and returns an number indication of their relative values. * @param {Date} Date object to compare [Required] * @return {Number} -1 = this is lessthan date. 0 = values are equal. 1 = this is greaterthan date. */ $P.compareTo = function (date) { return Date.compare(this, date); }; /** * Compares this instance to another Date object and returns true if they are equal. * @param {Date} Date object to compare. If no date to compare, new Date() [now] is used. * @return {Boolean} true if dates are equal. false if they are not equal. */ $P.equals = function (date) { return Date.equals(this, (date !== undefined ? date : new Date())); }; /** * Determines if this instance is between a range of two dates or equal to either the start or end dates. * @param {Date} Start of range [Required] * @param {Date} End of range [Required] * @return {Boolean} true is this is between or equal to the start and end dates, else false */ $P.between = function (start, end) { return this.getTime() >= start.getTime() && this.getTime() <= end.getTime(); }; /** * Determines if this date occurs after the date to compare to. * @param {Date} Date object to compare. If no date to compare, new Date() ("now") is used. * @return {Boolean} true if this date instance is greater than the date to compare to (or "now"), otherwise false. */ $P.isAfter = function (date) { return this.compareTo(date || new Date()) === 1; }; /** * Determines if this date occurs before the date to compare to. * @param {Date} Date object to compare. If no date to compare, new Date() ("now") is used. * @return {Boolean} true if this date instance is less than the date to compare to (or "now"). */ $P.isBefore = function (date) { return (this.compareTo(date || new Date()) === -1); }; /** * Determines if the current Date instance occurs today. * @return {Boolean} true if this date instance is 'today', otherwise false. */ /** * Determines if the current Date instance occurs on the same Date as the supplied 'date'. * If no 'date' to compare to is provided, the current Date instance is compared to 'today'. * @param {date} Date object to compare. If no date to compare, the current Date ("now") is used. * @return {Boolean} true if this Date instance occurs on the same Day as the supplied 'date'. */ $P.isToday = $P.isSameDay = function (date) { return this.clone().clearTime().equals((date || new Date()).clone().clearTime()); }; /** * Adds the specified number of milliseconds to this instance. * @param {Number} The number of milliseconds to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addMilliseconds = function (value) { if (!value) { return this; } this.setTime(this.getTime() + value * 1); return this; }; /** * Adds the specified number of seconds to this instance. * @param {Number} The number of seconds to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addSeconds = function (value) { if (!value) { return this; } return this.addMilliseconds(value * 1000); }; /** * Adds the specified number of seconds to this instance. * @param {Number} The number of seconds to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addMinutes = function (value) { if (!value) { return this; } return this.addMilliseconds(value * 60000); // 60*1000 }; /** * Adds the specified number of hours to this instance. * @param {Number} The number of hours to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addHours = function (value) { if (!value) { return this; } return this.addMilliseconds(value * 3600000); // 60*60*1000 }; /** * Adds the specified number of days to this instance. * @param {Number} The number of days to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addDays = function (value) { if (!value) { return this; } this.setDate(this.getDate() + value * 1); return this; }; /** * Adds the specified number of weekdays (ie - not sat or sun) to this instance. * @param {Number} The number of days to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addWeekdays = function (value) { if (!value) { return this; } var day = this.getDay(); var weeks = (Math.ceil(Math.abs(value)/7)); if (day === 0 || day === 6) { if (value > 0) { this.next().monday(); this.addDays(-1); day = this.getDay(); } } if (value < 0) { while (value < 0) { this.addDays(-1); day = this.getDay(); if (day !== 0 && day !== 6) { value++; } } return this; } else if (value > 5 || (6-day) <= value) { value = value + (weeks * 2); } return this.addDays(value); }; /** * Adds the specified number of weeks to this instance. * @param {Number} The number of weeks to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addWeeks = function (value) { if (!value) { return this; } return this.addDays(value * 7); }; /** * Adds the specified number of months to this instance. * @param {Number} The number of months to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addMonths = function (value) { if (!value) { return this; } var n = this.getDate(); this.setDate(1); this.setMonth(this.getMonth() + value * 1); this.setDate(Math.min(n, $D.getDaysInMonth(this.getFullYear(), this.getMonth()))); return this; }; $P.addQuarters = function (value) { if (!value) { return this; } // note this will take you to the same point in the quarter as you are now. // i.e. - if you are 15 days into the quarter you'll be 15 days into the resulting one. // bonus: this allows adding fractional quarters return this.addMonths(value * 3); }; /** * Adds the specified number of years to this instance. * @param {Number} The number of years to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addYears = function (value) { if (!value) { return this; } return this.addMonths(value * 12); }; /** * Adds (or subtracts) to the value of the years, months, weeks, days, hours, minutes, seconds, milliseconds of the date instance using given configuration object. Positive and Negative values allowed. * Example

	Date.today().add( { days: 1, months: 1 } )

	new Date().add( { years: -1 } )
	
* @param {Object} Configuration object containing attributes (months, days, etc.) * @return {Date} this */ $P.add = function (config) { if (typeof config === "number") { this._orient = config; return this; } var x = config; if (x.day) { // If we should be a different date than today (eg: for 'tomorrow -1d', etc). // Should only effect parsing, not direct usage (eg, Finish and FinishExact) if ((x.day - this.getDate()) !== 0) { this.setDate(x.day); } } if (x.milliseconds) { this.addMilliseconds(x.milliseconds); } if (x.seconds) { this.addSeconds(x.seconds); } if (x.minutes) { this.addMinutes(x.minutes); } if (x.hours) { this.addHours(x.hours); } if (x.weeks) { this.addWeeks(x.weeks); } if (x.months) { this.addMonths(x.months); } if (x.years) { this.addYears(x.years); } if (x.days) { this.addDays(x.days); } return this; }; /** * Get the week number. Week one (1) is the week which contains the first Thursday of the year. Monday is considered the first day of the week. * The .getWeek() function does NOT convert the date to UTC. The local datetime is used. * Please use .getISOWeek() to get the week of the UTC converted date. * @return {Number} 1 to 53 */ $P.getWeek = function (utc) { // Create a copy of this date object var self, target = new Date(this.valueOf()); if (utc) { target.addMinutes(target.getTimezoneOffset()); self = target.clone(); } else { self = this; } // ISO week date weeks start on monday // so correct the day number var dayNr = (self.getDay() + 6) % 7; // ISO 8601 states that week 1 is the week // with the first thursday of that year. // Set the target date to the thursday in the target week target.setDate(target.getDate() - dayNr + 3); // Store the millisecond value of the target date var firstThursday = target.valueOf(); // Set the target to the first thursday of the year // First set the target to january first target.setMonth(0, 1); // Not a thursday? Correct the date to the next thursday if (target.getDay() !== 4) { target.setMonth(0, 1 + ((4 - target.getDay()) + 7) % 7); } // The weeknumber is the number of weeks between the // first thursday of the year and the thursday in the target week return 1 + Math.ceil((firstThursday - target) / 604800000); // 604800000 = 7 * 24 * 3600 * 1000 }; /** * Get the ISO 8601 week number. Week one ("01") is the week which contains the first Thursday of the year. Monday is considered the first day of the week. * The .getISOWeek() function does convert the date to it's UTC value. Please use .getWeek() to get the week of the local date. * @return {String} "01" to "53" */ $P.getISOWeek = function () { return p(this.getWeek(true)); }; /** * Moves the date to Monday of the week set. Week one (1) is the week which contains the first Thursday of the year. * @param {Number} A Number (1 to 53) that represents the week of the year. * @return {Date} this */ $P.setWeek = function (n) { if ((n - this.getWeek()) === 0) { if (this.getDay() !== 1) { return this.moveToDayOfWeek(1, (this.getDay() > 1 ? -1 : 1)); } else { return this; } } else { return this.moveToDayOfWeek(1, (this.getDay() > 1 ? -1 : 1)).addWeeks(n - this.getWeek()); } }; $P.setQuarter = function (qtr) { var month = Math.abs(((qtr-1) * 3) + 1); return this.setMonth(month, 1); }; $P.getQuarter = function () { return Date.getQuarter(this); }; $P.getDaysLeftInQuarter = function () { return Date.getDaysLeftInQuarter(this); }; /** * Moves the date to the next n'th occurrence of the dayOfWeek starting from the beginning of the month. The number (-1) is a magic number and will return the last occurrence of the dayOfWeek in the month. * @param {Number} The dayOfWeek to move to * @param {Number} The n'th occurrence to move to. Use (-1) to return the last occurrence in the month * @return {Date} this */ $P.moveToNthOccurrence = function (dayOfWeek, occurrence) { if (dayOfWeek === "Weekday") { if (occurrence > 0) { this.moveToFirstDayOfMonth(); if (this.is().weekday()) { occurrence -= 1; } } else if (occurrence < 0) { this.moveToLastDayOfMonth(); if (this.is().weekday()) { occurrence += 1; } } else { return this; } return this.addWeekdays(occurrence); } var shift = 0; if (occurrence > 0) { shift = occurrence - 1; } else if (occurrence === -1) { this.moveToLastDayOfMonth(); if (this.getDay() !== dayOfWeek) { this.moveToDayOfWeek(dayOfWeek, -1); } return this; } return this.moveToFirstDayOfMonth().addDays(-1).moveToDayOfWeek(dayOfWeek, +1).addWeeks(shift); }; var moveToN = function (getFunc, addFunc, nVal) { return function (value, orient) { var diff = (value - this[getFunc]() + nVal * (orient || +1)) % nVal; return this[addFunc]((diff === 0) ? diff += nVal * (orient || +1) : diff); }; }; /** * Move to the next or last dayOfWeek based on the orient value. * @param {Number} The dayOfWeek to move to * @param {Number} Forward (+1) or Back (-1). Defaults to +1. [Optional] * @return {Date} this */ $P.moveToDayOfWeek = moveToN("getDay", "addDays", 7); /** * Move to the next or last month based on the orient value. * @param {Number} The month to move to. 0 = January, 11 = December * @param {Number} Forward (+1) or Back (-1). Defaults to +1. [Optional] * @return {Date} this */ $P.moveToMonth = moveToN("getMonth", "addMonths", 12); /** * Get the Ordinate of the current day ("th", "st", "rd"). * @return {String} */ $P.getOrdinate = function () { var num = this.getDate(); return ord(num); }; /** * Get the Ordinal day (numeric day number) of the year, adjusted for leap year. * @return {Number} 1 through 365 (366 in leap years) */ $P.getOrdinalNumber = function () { return Math.ceil((this.clone().clearTime() - new Date(this.getFullYear(), 0, 1)) / 86400000) + 1; }; /** * Get the time zone abbreviation of the current date. * @return {String} The abbreviated time zone name (e.g. "EST") */ $P.getTimezone = function () { return $D.getTimezoneAbbreviation(this.getUTCOffset(), this.isDaylightSavingTime()); }; $P.setTimezoneOffset = function (offset) { var here = this.getTimezoneOffset(), there = Number(offset) * -6 / 10; return (there || there === 0) ? this.addMinutes(there - here) : this; }; $P.setTimezone = function (offset) { return this.setTimezoneOffset($D.getTimezoneOffset(offset)); }; /** * Indicates whether Daylight Saving Time is observed in the current time zone. * @return {Boolean} true|false */ $P.hasDaylightSavingTime = function () { return (Date.today().set({month: 0, day: 1}).getTimezoneOffset() !== Date.today().set({month: 6, day: 1}).getTimezoneOffset()); }; /** * Indicates whether this Date instance is within the Daylight Saving Time range for the current time zone. * @return {Boolean} true|false */ $P.isDaylightSavingTime = function () { return Date.today().set({month: 0, day: 1}).getTimezoneOffset() !== this.getTimezoneOffset(); }; /** * Get the offset from UTC of the current date. * @return {String} The 4-character offset string prefixed with + or - (e.g. "-0500") */ $P.getUTCOffset = function (offset) { var n = (offset || this.getTimezoneOffset()) * -10 / 6, r; if (n < 0) { r = (n - 10000).toString(); return r.charAt(0) + r.substr(2); } else { r = (n + 10000).toString(); return "+" + r.substr(1); } }; /** * Returns the number of milliseconds between this date and date. * @param {Date} Defaults to now * @return {Number} The diff in milliseconds */ $P.getElapsed = function (date) { return (date || new Date()) - this; }; /** * Set the value of year, month, day, hour, minute, second, millisecond of date instance using given configuration object. * Example

	Date.today().set( { day: 20, month: 1 } )

	new Date().set( { millisecond: 0 } )
	
* * @param {Object} Configuration object containing attributes (month, day, etc.) * @return {Date} this */ $P.set = function (config) { config = validateConfigObject.call(this, config); var key; for (key in config) { if (Object.prototype.hasOwnProperty.call(config, key)) { var name = key.charAt(0).toUpperCase() + key.slice(1); var addFunc, getFunc; if (key !== "week" && key !== "month" && key !== "timezone" && key !== "timezoneOffset") { name += "s"; } addFunc = "add" + name; getFunc = "get" + name; if (key === "month") { addFunc = addFunc + "s"; } else if (key === "year"){ getFunc = "getFullYear"; } if (key !== "day" && key !== "timezone" && key !== "timezoneOffset" && key !== "week" && key !== "hour") { this[addFunc](config[key] - this[getFunc]()); } else if ( key === "timezone"|| key === "timezoneOffset" || key === "week" || key === "hour") { this["set"+name](config[key]); } } } // day has to go last because you can't validate the day without first knowing the month if (config.day) { this.addDays(config.day - this.getDate()); } return this; }; /** * Moves the date to the first day of the month. * @return {Date} this */ $P.moveToFirstDayOfMonth = function () { return this.set({ day: 1 }); }; /** * Moves the date to the last day of the month. * @return {Date} this */ $P.moveToLastDayOfMonth = function () { return this.set({ day: $D.getDaysInMonth(this.getFullYear(), this.getMonth())}); }; /** * Converts the value of the current Date object to its equivalent string representation. * Format Specifiers * CUSTOM DATE AND TIME FORMAT STRINGS * Format Description Example * ------ --------------------------------------------------------------------------- ----------------------- * s The seconds of the minute between 0-59. "0" to "59" * ss The seconds of the minute with leading zero if required. "00" to "59" * * m The minute of the hour between 0-59. "0" or "59" * mm The minute of the hour with leading zero if required. "00" or "59" * * h The hour of the day between 1-12. "1" to "12" * hh The hour of the day with leading zero if required. "01" to "12" * * H The hour of the day between 0-23. "0" to "23" * HH The hour of the day with leading zero if required. "00" to "23" * * d The day of the month between 1 and 31. "1" to "31" * dd The day of the month with leading zero if required. "01" to "31" * ddd Abbreviated day name. Date.CultureInfo.abbreviatedDayNames. "Mon" to "Sun" * dddd The full day name. Date.CultureInfo.dayNames. "Monday" to "Sunday" * * M The month of the year between 1-12. "1" to "12" * MM The month of the year with leading zero if required. "01" to "12" * MMM Abbreviated month name. Date.CultureInfo.abbreviatedMonthNames. "Jan" to "Dec" * MMMM The full month name. Date.CultureInfo.monthNames. "January" to "December" * * yy The year as a two-digit number. "99" or "08" * yyyy The full four digit year. "1999" or "2008" * * t Displays the first character of the A.M./P.M. designator. "A" or "P" * Date.CultureInfo.amDesignator or Date.CultureInfo.pmDesignator * tt Displays the A.M./P.M. designator. "AM" or "PM" * Date.CultureInfo.amDesignator or Date.CultureInfo.pmDesignator * * S The ordinal suffix ("st, "nd", "rd" or "th") of the current day. "st, "nd", "rd" or "th" * * STANDARD DATE AND TIME FORMAT STRINGS * Format Description Example *------ --------------------------------------------------------------------------- ----------------------- * d The CultureInfo shortDate Format Pattern "M/d/yyyy" * D The CultureInfo longDate Format Pattern "dddd, MMMM dd, yyyy" * F The CultureInfo fullDateTime Format Pattern "dddd, MMMM dd, yyyy h:mm:ss tt" * m The CultureInfo monthDay Format Pattern "MMMM dd" * r The CultureInfo rfc1123 Format Pattern "ddd, dd MMM yyyy HH:mm:ss GMT" * s The CultureInfo sortableDateTime Format Pattern "yyyy-MM-ddTHH:mm:ss" * t The CultureInfo shortTime Format Pattern "h:mm tt" * T The CultureInfo longTime Format Pattern "h:mm:ss tt" * u The CultureInfo universalSortableDateTime Format Pattern "yyyy-MM-dd HH:mm:ssZ" * y The CultureInfo yearMonth Format Pattern "MMMM, yyyy" * * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @return {String} A string representation of the current Date object. */ var ord = function (n) { switch (n * 1) { case 1: case 21: case 31: return "st"; case 2: case 22: return "nd"; case 3: case 23: return "rd"; default: return "th"; } }; var parseStandardFormats = function (format) { var y, c = Date.CultureInfo.formatPatterns; switch (format) { case "d": return this.toString(c.shortDate); case "D": return this.toString(c.longDate); case "F": return this.toString(c.fullDateTime); case "m": return this.toString(c.monthDay); case "r": case "R": y = this.clone().addMinutes(this.getTimezoneOffset()); return y.toString(c.rfc1123) + " GMT"; case "s": return this.toString(c.sortableDateTime); case "t": return this.toString(c.shortTime); case "T": return this.toString(c.longTime); case "u": y = this.clone().addMinutes(this.getTimezoneOffset()); return y.toString(c.universalSortableDateTime); case "y": return this.toString(c.yearMonth); default: return false; } }; var parseFormatStringsClosure = function (context) { return function (m) { if (m.charAt(0) === "\\") { return m.replace("\\", ""); } switch (m) { case "hh": return p(context.getHours() < 13 ? (context.getHours() === 0 ? 12 : context.getHours()) : (context.getHours() - 12)); case "h": return context.getHours() < 13 ? (context.getHours() === 0 ? 12 : context.getHours()) : (context.getHours() - 12); case "HH": return p(context.getHours()); case "H": return context.getHours(); case "mm": return p(context.getMinutes()); case "m": return context.getMinutes(); case "ss": return p(context.getSeconds()); case "s": return context.getSeconds(); case "yyyy": return p(context.getFullYear(), 4); case "yy": return p(context.getFullYear()); case "y": return context.getFullYear(); case "E": case "dddd": return Date.CultureInfo.dayNames[context.getDay()]; case "ddd": return Date.CultureInfo.abbreviatedDayNames[context.getDay()]; case "dd": return p(context.getDate()); case "d": return context.getDate(); case "MMMM": return Date.CultureInfo.monthNames[context.getMonth()]; case "MMM": return Date.CultureInfo.abbreviatedMonthNames[context.getMonth()]; case "MM": return p((context.getMonth() + 1)); case "M": return context.getMonth() + 1; case "t": return context.getHours() < 12 ? Date.CultureInfo.amDesignator.substring(0, 1) : Date.CultureInfo.pmDesignator.substring(0, 1); case "tt": return context.getHours() < 12 ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator; case "S": return ord(context.getDate()); case "W": return context.getWeek(); case "WW": return context.getISOWeek(); case "Q": return "Q" + context.getQuarter(); case "q": return String(context.getQuarter()); case "z": return context.getTimezone(); case "Z": case "X": return Date.getTimezoneOffset(context.getTimezone()); case "ZZ": // Timezone offset in seconds return context.getTimezoneOffset() * -60; case "u": return context.getDay(); case "L": return ($D.isLeapYear(context.getFullYear())) ? 1 : 0; case "B": // Swatch Internet Time (.beats) return "@"+((context.getUTCSeconds() + (context.getUTCMinutes()*60) + ((context.getUTCHours()+1)*3600))/86.4); default: return m; } }; }; $P.toString = function (format, ignoreStandards) { // Standard Date and Time Format Strings. Formats pulled from CultureInfo file and // may vary by culture. if (!ignoreStandards && format && format.length === 1) { output = parseStandardFormats.call(this, format); if (output) { return output; } } var parseFormatStrings = parseFormatStringsClosure(this); return format ? format.replace(/((\\)?(dd?d?d?|MM?M?M?|yy?y?y?|hh?|HH?|mm?|ss?|tt?|S|q|Q|WW?W?W?)(?![^\[]*\]))/g, parseFormatStrings).replace(/\[|\]/g, "") : this._toString(); }; }()); /************************************************************* * SugarPak - Domain Specific Language - Syntactical Sugar * *************************************************************/ (function () { var $D = Date, $P = $D.prototype, $N = Number.prototype; // private $P._orient = +1; // private $P._nth = null; // private $P._is = false; // private $P._same = false; // private $P._isSecond = false; // private $N._dateElement = "days"; /** * Moves the date to the next instance of a date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.today().next().friday();
	Date.today().next().fri();
	Date.today().next().march();
	Date.today().next().mar();
	Date.today().next().week();
	
* * @return {Date} date */ $P.next = function () { this._move = true; this._orient = +1; return this; }; /** * Creates a new Date (Date.today()) and moves the date to the next instance of the date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.next().friday();
	Date.next().fri();
	Date.next().march();
	Date.next().mar();
	Date.next().week();
	
* * @return {Date} date */ $D.next = function () { return $D.today().next(); }; /** * Moves the date to the previous instance of a date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.today().last().friday();
	Date.today().last().fri();
	Date.today().last().march();
	Date.today().last().mar();
	Date.today().last().week();
	
* * @return {Date} date */ $P.last = $P.prev = $P.previous = function () { this._move = true; this._orient = -1; return this; }; /** * Creates a new Date (Date.today()) and moves the date to the previous instance of the date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.last().friday();
	Date.last().fri();
	Date.previous().march();
	Date.prev().mar();
	Date.last().week();
	
* * @return {Date} date */ $D.last = $D.prev = $D.previous = function () { return $D.today().last(); }; /** * Performs a equality check when followed by either a month name, day name or .weekday() function. * Example

	Date.today().is().friday(); // true|false
	Date.today().is().fri();
	Date.today().is().march();
	Date.today().is().mar();
	
* * @return {Boolean} true|false */ $P.is = function () { this._is = true; return this; }; /** * Determines if two date objects occur on/in exactly the same instance of the subsequent date part function. * The function .same() must be followed by a date part function (example: .day(), .month(), .year(), etc). * * An optional Date can be passed in the date part function. If now date is passed as a parameter, 'Now' is used. * * The following example demonstrates how to determine if two dates fall on the exact same day. * * Example

	var d1 = Date.today(); // today at 00:00
	var d2 = new Date();   // exactly now.

	// Do they occur on the same day?
	d1.same().day(d2); // true
	
	// Do they occur on the same hour?
	d1.same().hour(d2); // false, unless d2 hour is '00' (midnight).
	
	// What if it's the same day, but one year apart?
	var nextYear = Date.today().add(1).year();

	d1.same().day(nextYear); // false, because the dates must occur on the exact same day. 
	
* * Scenario: Determine if a given date occurs during some week period 2 months from now. * * Example

	var future = Date.today().add(2).months();
	return someDate.same().week(future); // true|false;
	
* * @return {Boolean} true|false */ $P.same = function () { this._same = true; this._isSecond = false; return this; }; /** * Determines if the current date/time occurs during Today. Must be preceded by the .is() function. * Example

	someDate.is().today();    // true|false
	new Date().is().today();  // true
	Date.today().is().today();// true
	Date.today().add(-1).day().is().today(); // false
	
* * @return {Boolean} true|false */ $P.today = function () { return this.same().day(); }; /** * Determines if the current date is a weekday. This function must be preceded by the .is() function. * Example

	Date.today().is().weekday(); // true|false
	
* * @return {Boolean} true|false */ $P.weekday = function () { if (this._nth) { return df("Weekday").call(this); } if (this._move) { return this.addWeekdays(this._orient); } if (this._is) { this._is = false; return (!this.is().sat() && !this.is().sun()); } return false; }; /** * Determines if the current date is on the weekend. This function must be preceded by the .is() function. * Example

	Date.today().is().weekend(); // true|false
	
* * @return {Boolean} true|false */ $P.weekend = function () { if (this._is) { this._is = false; return (this.is().sat() || this.is().sun()); } return false; }; /** * Sets the Time of the current Date instance. A string "6:15 pm" or config object {hour:18, minute:15} are accepted. * Example

	// Set time to 6:15pm with a String
	Date.today().at("6:15pm");

	// Set time to 6:15pm with a config object
	Date.today().at({hour:18, minute:15});
	
* * @return {Date} date */ $P.at = function (time) { return (typeof time === "string") ? $D.parse(this.toString("d") + " " + time) : this.set(time); }; /** * Creates a new Date() and adds this (Number) to the date based on the preceding date element function (eg. second|minute|hour|day|month|year). * Example

	// Undeclared Numbers must be wrapped with parentheses. Requirment of JavaScript.
	(3).days().fromNow();
	(6).months().fromNow();

	// Declared Number variables do not require parentheses. 
	var n = 6;
	n.months().fromNow();
	
* * @return {Date} A new Date instance */ $N.fromNow = $N.after = function (date) { var c = {}; c[this._dateElement] = this; return ((!date) ? new Date() : date.clone()).add(c); }; /** * Creates a new Date() and subtract this (Number) from the date based on the preceding date element function (eg. second|minute|hour|day|month|year). * Example

	// Undeclared Numbers must be wrapped with parentheses. Requirment of JavaScript.
	(3).days().ago();
	(6).months().ago();

	// Declared Number variables do not require parentheses. 
	var n = 6;
	n.months().ago();
	
* * @return {Date} A new Date instance */ $N.ago = $N.before = function (date) { var c = {}, s = (this._dateElement[this._dateElement.length-1] !== "s") ? this._dateElement + "s" : this._dateElement; c[s] = this * -1; return ((!date) ? new Date() : date.clone()).add(c); }; // Do NOT modify the following string tokens. These tokens are used to build dynamic functions. // All culture-specific strings can be found in the CultureInfo files. var dx = ("sunday monday tuesday wednesday thursday friday saturday").split(/\s/), mx = ("january february march april may june july august september october november december").split(/\s/), px = ("Millisecond Second Minute Hour Day Week Month Year Quarter Weekday").split(/\s/), pxf = ("Milliseconds Seconds Minutes Hours Date Week Month FullYear Quarter").split(/\s/), nth = ("final first second third fourth fifth").split(/\s/), de; /** * Returns an object literal of all the date parts. * Example

	var o = new Date().toObject();
	
	// { year: 2008, month: 4, week: 20, day: 13, hour: 18, minute: 9, second: 32, millisecond: 812 }
	
	// The object properties can be referenced directly from the object.
	
	alert(o.day);  // alerts "13"
	alert(o.year); // alerts "2008"
	
* * @return {Date} An object literal representing the original date object. */ $P.toObject = function () { var o = {}; for (var i = 0; i < px.length; i++) { if (this["get" + pxf[i]]) { o[px[i].toLowerCase()] = this["get" + pxf[i]](); } } return o; }; /** * Returns a date created from an object literal. Ignores the .week property if set in the config. * Example

	var o = new Date().toObject();
	
	return Date.fromObject(o); // will return the same date. 

	var o2 = {month: 1, day: 20, hour: 18}; // birthday party!
	Date.fromObject(o2);
	
* * @return {Date} An object literal representing the original date object. */ $D.fromObject = function(config) { config.week = null; return Date.today().set(config); }; // Create day name functions and abbreviated day name functions (eg. monday(), friday(), fri()). var df = function (n) { return function () { if (this._is) { this._is = false; return this.getDay() === n; } if (this._move) { this._move = null; } if (this._nth !== null) { // If the .second() function was called earlier, remove the _orient // from the date, and then continue. // This is required because 'second' can be used in two different context. // // Example // // Date.today().add(1).second(); // Date.march().second().monday(); // // Things get crazy with the following... // Date.march().add(1).second().second().monday(); // but it works!! // if (this._isSecond) { this.addSeconds(this._orient * -1); } // make sure we reset _isSecond this._isSecond = false; var ntemp = this._nth; this._nth = null; var temp = this.clone().moveToLastDayOfMonth(); this.moveToNthOccurrence(n, ntemp); if (this > temp) { throw new RangeError($D.getDayName(n) + " does not occur " + ntemp + " times in the month of " + $D.getMonthName(temp.getMonth()) + " " + temp.getFullYear() + "."); } return this; } return this.moveToDayOfWeek(n, this._orient); }; }; var sdf = function (n) { return function () { var t = $D.today(), shift = n - t.getDay(); if (n === 0 && Date.CultureInfo.firstDayOfWeek === 1 && t.getDay() !== 0) { shift = shift + 7; } return t.addDays(shift); }; }; // Create month name functions and abbreviated month name functions (eg. january(), march(), mar()). var month_instance_functions = function (n) { return function () { if (this._is) { this._is = false; return this.getMonth() === n; } return this.moveToMonth(n, this._orient); }; }; var month_static_functions = function (n) { return function () { return $D.today().set({ month: n, day: 1 }); }; }; var processTerms = function (names, staticFunc, instanceFunc) { for (var i = 0; i < names.length; i++) { // Create constant static Name variables. $D[names[i].toUpperCase()] = $D[names[i].toUpperCase().substring(0, 3)] = i; // Create Name functions. $D[names[i]] = $D[names[i].substring(0, 3)] = staticFunc(i); // Create Name instance functions. $P[names[i]] = $P[names[i].substring(0, 3)] = instanceFunc(i); } }; processTerms(dx, sdf, df); processTerms(mx, month_static_functions, month_instance_functions); // Create date element functions and plural date element functions used with Date (eg. day(), days(), months()). var ef = function (j) { return function () { // if the .second() function was called earlier, the _orient // has alread been added. Just return this and reset _isSecond. if (this._isSecond) { this._isSecond = false; return this; } if (this._same) { this._same = this._is = false; var o1 = this.toObject(), o2 = (arguments[0] || new Date()).toObject(), v = "", k = j.toLowerCase(); // the substr trick with -1 doesn't work in IE8 or less k = (k[k.length-1] === "s") ? k.substring(0,k.length-1) : k; for (var m = (px.length - 1); m > -1; m--) { v = px[m].toLowerCase(); if (o1[v] !== o2[v]) { return false; } if (k === v) { break; } } return true; } if (j.substring(j.length - 1) !== "s") { j += "s"; } if (this._move) { this._move = null; } return this["add" + j](this._orient); }; }; var nf = function (n) { return function () { this._dateElement = n; return this; }; }; for (var k = 0; k < px.length; k++) { de = px[k].toLowerCase(); if(de !== "weekday") { // Create date element functions and plural date element functions used with Date (eg. day(), days(), months()). $P[de] = $P[de + "s"] = ef(px[k]); // Create date element functions and plural date element functions used with Number (eg. day(), days(), months()). $N[de] = $N[de + "s"] = nf(de + "s"); } } $P._ss = ef("Second"); var nthfn = function (n) { return function (dayOfWeek) { if (this._same) { return this._ss(arguments[0]); } if (dayOfWeek || dayOfWeek === 0) { return this.moveToNthOccurrence(dayOfWeek, n); } this._nth = n; // if the operator is 'second' add the _orient, then deal with it later... if (n === 2 && (dayOfWeek === undefined || dayOfWeek === null)) { this._isSecond = true; return this.addSeconds(this._orient); } return this; }; }; for (var l = 0; l < nth.length; l++) { $P[nth[l]] = (l === 0) ? nthfn(-1) : nthfn(l); } }()); (function () { "use strict"; Date.Parsing = { Exception: function (s) { this.message = "Parse error at '" + s.substring(0, 10) + " ...'"; } }; var $P = Date.Parsing; var dayOffsets = { standard: [0,31,59,90,120,151,181,212,243,273,304,334], leap: [0,31,60,91,121,152,182,213,244,274,305,335] }; $P.isLeapYear = function(year) { return ((year % 4 === 0) && (year % 100 !== 0)) || (year % 400 === 0); }; var utils = { multiReplace : function (str, hash ) { var key; for (key in hash) { if (Object.prototype.hasOwnProperty.call(hash, key)) { var regex; if (typeof hash[key] === "function") { } else { regex = (hash[key] instanceof RegExp) ? hash[key] : new RegExp(hash[key], "g"); } str = str.replace(regex, key); } } return str; }, getDayOfYearFromWeek : function (obj) { var d, jan4, offset; obj.weekDay = (!obj.weekDay && obj.weekDay !== 0) ? 1 : obj.weekDay; d = new Date(obj.year, 0, 4); jan4 = d.getDay() === 0 ? 7 : d.getDay(); // JS is 0 indexed on Sunday. offset = jan4+3; obj.dayOfYear = ((obj.week * 7) + (obj.weekDay === 0 ? 7 : obj.weekDay))-offset; return obj; }, getDayOfYear : function (obj, dayOffset) { if (!obj.dayOfYear) { obj = utils.getDayOfYearFromWeek(obj); } for (var i=0;i <= dayOffset.length;i++) { if (obj.dayOfYear < dayOffset[i] || i === dayOffset.length) { obj.day = obj.day ? obj.day : (obj.dayOfYear - dayOffset[i-1]); break; } else { obj.month = i; } } return obj; }, adjustForTimeZone : function (obj, date) { var offset; if (obj.zone.toUpperCase() === "Z" || (obj.zone_hours === 0 && obj.zone_minutes === 0)) { // it's UTC/GML so work out the current timeszone offset offset = -date.getTimezoneOffset(); } else { offset = (obj.zone_hours*60) + (obj.zone_minutes || 0); if (obj.zone_sign === "+") { offset *= -1; } offset -= date.getTimezoneOffset(); } date.setMinutes(date.getMinutes()+offset); return date; }, setDefaults : function (obj) { obj.year = obj.year || Date.today().getFullYear(); obj.hours = obj.hours || 0; obj.minutes = obj.minutes || 0; obj.seconds = obj.seconds || 0; obj.milliseconds = obj.milliseconds || 0; if (!(!obj.month && (obj.week || obj.dayOfYear))) { // if we have a month, or if we don't but don't have the day calculation data obj.month = obj.month || 0; obj.day = obj.day || 1; } return obj; }, dataNum: function (data, mod, explict, postProcess) { var dataNum = data*1; if (mod) { if (postProcess) { return data ? mod(data)*1 : data; } else { return data ? mod(dataNum) : data; } } else if (!explict){ return data ? dataNum : data; } else { return (data && typeof data !== "undefined") ? dataNum : data; } }, timeDataProcess: function (obj) { var timeObj = {}; for (var x in obj.data) { if (obj.data.hasOwnProperty(x)) { timeObj[x] = obj.ignore[x] ? obj.data[x] : utils.dataNum(obj.data[x], obj.mods[x], obj.explict[x], obj.postProcess[x]); } } if (obj.data.secmins) { obj.data.secmins = obj.data.secmins.replace(",", ".") * 60; if (!timeObj.minutes) { timeObj.minutes = obj.data.secmins; } else if (!timeObj.seconds) { timeObj.seconds = obj.data.secmins; } delete obj.secmins; } return timeObj; }, buildTimeObjectFromData: function (data) { var time = utils.timeDataProcess({ data: { year : data[1], month : data[5], day : data[7], week : data[8], dayOfYear : data[10], hours : data[15], zone_hours : data[23], zone_minutes : data[24], zone : data[21], zone_sign : data[22], weekDay : data[9], minutes: data[16], seconds: data[19], milliseconds: data[20], secmins: data[18] }, mods: { month: function(data) { return data-1; }, weekDay: function (data) { data = Math.abs(data); return (data === 7 ? 0 : data); }, minutes: function (data) { return data.replace(":",""); }, seconds: function (data) { return Math.floor( (data.replace(":","").replace(",","."))*1 ); }, milliseconds: function (data) { return (data.replace(",",".")*1000); } }, postProcess: { minutes: true, seconds: true, milliseconds: true }, explict: { zone_hours: true, zone_minutes: true }, ignore: { zone: true, zone_sign: true, secmins: true } }); return time; }, addToHash: function (hash, keys, data) { keys = keys; data = data; var len = keys.length; for (var i = 0; i < len; i++) { hash[keys[i]] = data[i]; } return hash; }, combineRegex: function (r1, r2) { return new RegExp("(("+r1.source+")\\s("+r2.source+"))"); }, getDateNthString: function(add, last, inc){ if (add) { return Date.today().addDays(inc).toString("d"); } else if (last) { return Date.today().last()[inc]().toString("d"); } }, buildRegexData: function (array) { var arr = []; var len = array.length; for (var i=0; i < len; i++) { if (Object.prototype.toString.call(array[i]) === '[object Array]') { // oldIE compat version of Array.isArray arr.push(this.combineRegex(array[i][0], array[i][1])); } else { arr.push(array[i]); } } return arr; } }; $P.processTimeObject = function (obj) { var date, dayOffset; utils.setDefaults(obj); dayOffset = ($P.isLeapYear(obj.year)) ? dayOffsets.leap : dayOffsets.standard; if (!obj.month && (obj.week || obj.dayOfYear)) { utils.getDayOfYear(obj, dayOffset); } else { obj.dayOfYear = dayOffset[obj.month] + obj.day; } date = new Date(obj.year, obj.month, obj.day, obj.hours, obj.minutes, obj.seconds, obj.milliseconds); if (obj.zone) { utils.adjustForTimeZone(obj, date); // adjust (and calculate) for timezone } return date; }; $P.ISO = { regex : /^([\+-]?\d{4}(?!\d{2}\b))((-?)((0[1-9]|1[0-2])(\3([12]\d|0[1-9]|3[01]))?|W([0-4]\d|5[0-3])(-?[1-7])?|(00[1-9]|0[1-9]\d|[12]\d{2}|3([0-5]\d|6[1-6])))([T\s]((([01]\d|2[0-4])((:?)[0-5]\d)?|24\:?00)([\.,]\d+(?!:))?)?(\17[0-5]\d([\.,]\d+)?)?\s?([zZ]|([\+-])([01]\d|2[0-3]):?([0-5]\d)?)?)?)?$/, parse : function (s) { var time, data = s.match(this.regex); if (!data || !data.length) { return null; } time = utils.buildTimeObjectFromData(data); if (!time.year || (!time.year && (!time.month && !time.day) && (!time.week && !time.dayOfYear)) ) { return null; } return $P.processTimeObject(time); } }; $P.Numeric = { isNumeric: function (e){return!isNaN(parseFloat(e))&&isFinite(e);}, regex: /\b([0-1]?[0-9])([0-3]?[0-9])([0-2]?[0-9]?[0-9][0-9])\b/i, parse: function (s) { var data, i, time = {}, order = Date.CultureInfo.dateElementOrder.split(""); if (!(this.isNumeric(s)) || // if it's non-numeric OR (s[0] === "+" && s[0] === "-")) { // It's an arithmatic string (eg +/-1000) return null; } if (s.length < 5 && s.indexOf(".") < 0 && s.indexOf("/") < 0) { // assume it's just a year. time.year = s; return $P.processTimeObject(time); } data = s.match(this.regex); if (!data || !data.length) { return null; } for (i=0; i < order.length; i++) { switch(order[i]) { case "d": time.day = data[i+1]; break; case "m": time.month = (data[i+1]-1); break; case "y": time.year = data[i+1]; break; } } return $P.processTimeObject(time); } }; $P.Normalizer = { regexData: function () { var $R = Date.CultureInfo.regexPatterns; return utils.buildRegexData([ $R.tomorrow, $R.yesterday, [$R.past, $R.mon], [$R.past, $R.tue], [$R.past, $R.wed], [$R.past, $R.thu], [$R.past, $R.fri], [$R.past, $R.sat], [$R.past, $R.sun] ]); }, basicReplaceHash : function() { var $R = Date.CultureInfo.regexPatterns; return { "January": $R.jan.source, "February": $R.feb, "March": $R.mar, "April": $R.apr, "May": $R.may, "June": $R.jun, "July": $R.jul, "August": $R.aug, "September": $R.sep, "October": $R.oct, "November": $R.nov, "December": $R.dec, "": /\bat\b/gi, " ": /\s{2,}/, "am": $R.inTheMorning, "9am": $R.thisMorning, "pm": $R.inTheEvening, "7pm":$R.thisEvening }; }, keys : function(){ return [ utils.getDateNthString(true, false, 1), // tomorrow utils.getDateNthString(true, false, -1), // yesterday utils.getDateNthString(false, true, "monday"), //last mon utils.getDateNthString(false, true, "tuesday"), //last tues utils.getDateNthString(false, true, "wednesday"), //last wed utils.getDateNthString(false, true, "thursday"), //last thurs utils.getDateNthString(false, true, "friday"), //last fri utils.getDateNthString(false, true, "saturday"), //last sat utils.getDateNthString(false, true, "sunday") //last sun ]; }, buildRegexFunctions: function () { var $R = Date.CultureInfo.regexPatterns; var __ = Date.i18n.__; var tomorrowRE = new RegExp("(\\b\\d\\d?("+__("AM")+"|"+__("PM")+")? )("+$R.tomorrow.source.slice(1)+")", "i"); // adapted tomorrow regex for AM PM relative dates var todayRE = new RegExp($R.today.source + "(?!\\s*([+-]))\\b"); // today, but excludes the math operators (eg "today + 2h") this.replaceFuncs = [ [todayRE, function (full) { return (full.length > 1) ? Date.today().toString("d") : full; }], [tomorrowRE, function(full, m1) { var t = Date.today().addDays(1).toString("d"); return (t + " " + m1); }], [$R.amThisMorning, function(str, am){return am;}], [$R.pmThisEvening, function(str, pm){return pm;}] ]; }, buildReplaceData: function () { this.buildRegexFunctions(); this.replaceHash = utils.addToHash(this.basicReplaceHash(), this.keys(), this.regexData()); }, stringReplaceFuncs: function (s) { for (var i=0; i < this.replaceFuncs.length; i++) { s = s.replace(this.replaceFuncs[i][0], this.replaceFuncs[i][1]); } return s; }, parse: function (s) { s = this.stringReplaceFuncs(s); s = utils.multiReplace(s, this.replaceHash); try { var n = s.split(/([\s\-\.\,\/\x27]+)/); if (n.length === 3 && $P.Numeric.isNumeric(n[0]) && $P.Numeric.isNumeric(n[2]) && (n[2].length >= 4)) { // ok, so we're dealing with x/year. But that's not a full date. // This fixes wonky dateElementOrder parsing when set to dmy order. if (Date.CultureInfo.dateElementOrder[0] === "d") { s = "1/" + n[0] + "/" + n[2]; // set to 1st of month and normalize the seperator } } } catch (e) {} return s; } }; $P.Normalizer.buildReplaceData(); }()); (function () { var $P = Date.Parsing; var _ = $P.Operators = { // // Tokenizers // rtoken: function (r) { // regex token return function (s) { var mx = s.match(r); if (mx) { return ([ mx[0], s.substring(mx[0].length) ]); } else { throw new $P.Exception(s); } }; }, token: function () { // whitespace-eating token return function (s) { return _.rtoken(new RegExp("^\\s*" + s + "\\s*"))(s); }; }, stoken: function (s) { // string token return _.rtoken(new RegExp("^" + s)); }, // Atomic Operators until: function (p) { return function (s) { var qx = [], rx = null; while (s.length) { try { rx = p.call(this, s); } catch (e) { qx.push(rx[0]); s = rx[1]; continue; } break; } return [ qx, s ]; }; }, many: function (p) { return function (s) { var rx = [], r = null; while (s.length) { try { r = p.call(this, s); } catch (e) { return [ rx, s ]; } rx.push(r[0]); s = r[1]; } return [ rx, s ]; }; }, // generator operators -- see below optional: function (p) { return function (s) { var r = null; try { r = p.call(this, s); } catch (e) { return [ null, s ]; } return [ r[0], r[1] ]; }; }, not: function (p) { return function (s) { try { p.call(this, s); } catch (e) { return [null, s]; } throw new $P.Exception(s); }; }, ignore: function (p) { return p ? function (s) { var r = null; r = p.call(this, s); return [null, r[1]]; } : null; }, product: function () { var px = arguments[0], qx = Array.prototype.slice.call(arguments, 1), rx = []; for (var i = 0 ; i < px.length ; i++) { rx.push(_.each(px[i], qx)); } return rx; }, cache: function (rule) { var cache = {}, cache_length = 0, cache_keys = [], CACHE_MAX = Date.Config.CACHE_MAX || 100000, r = null; var cacheCheck = function () { if (cache_length === CACHE_MAX) { // kill several keys, don't want to have to do this all the time... for (var i=0; i < 10; i++) { var key = cache_keys.shift(); if (key) { delete cache[key]; cache_length--; } } } }; return function (s) { cacheCheck(); try { r = cache[s] = (cache[s] || rule.call(this, s)); } catch (e) { r = cache[s] = e; } cache_length++; cache_keys.push(s); if (r instanceof $P.Exception) { throw r; } else { return r; } }; }, // vector operators -- see below any: function () { var px = arguments; return function (s) { var r = null; for (var i = 0; i < px.length; i++) { if (px[i] == null) { continue; } try { r = (px[i].call(this, s)); } catch (e) { r = null; } if (r) { return r; } } throw new $P.Exception(s); }; }, each: function () { var px = arguments; return function (s) { var rx = [], r = null; for (var i = 0; i < px.length ; i++) { if (px[i] == null) { continue; } try { r = (px[i].call(this, s)); } catch (e) { throw new $P.Exception(s); } rx.push(r[0]); s = r[1]; } return [ rx, s]; }; }, all: function () { var px = arguments, _ = _; return _.each(_.optional(px)); }, // delimited operators sequence: function (px, d, c) { d = d || _.rtoken(/^\s*/); c = c || null; if (px.length === 1) { return px[0]; } return function (s) { var r = null, q = null; var rx = []; for (var i = 0; i < px.length ; i++) { try { r = px[i].call(this, s); } catch (e) { break; } rx.push(r[0]); try { q = d.call(this, r[1]); } catch (ex) { q = null; break; } s = q[1]; } if (!r) { throw new $P.Exception(s); } if (q) { throw new $P.Exception(q[1]); } if (c) { try { r = c.call(this, r[1]); } catch (ey) { throw new $P.Exception(r[1]); } } return [ rx, (r?r[1]:s) ]; }; }, // // Composite Operators // between: function (d1, p, d2) { d2 = d2 || d1; var _fn = _.each(_.ignore(d1), p, _.ignore(d2)); return function (s) { var rx = _fn.call(this, s); return [[rx[0][0], r[0][2]], rx[1]]; }; }, list: function (p, d, c) { d = d || _.rtoken(/^\s*/); c = c || null; return (p instanceof Array ? _.each(_.product(p.slice(0, -1), _.ignore(d)), p.slice(-1), _.ignore(c)) : _.each(_.many(_.each(p, _.ignore(d))), px, _.ignore(c))); }, set: function (px, d, c) { d = d || _.rtoken(/^\s*/); c = c || null; return function (s) { // r is the current match, best the current 'best' match // which means it parsed the most amount of input var r = null, p = null, q = null, rx = null, best = [[], s], last = false; // go through the rules in the given set for (var i = 0; i < px.length ; i++) { // last is a flag indicating whether this must be the last element // if there is only 1 element, then it MUST be the last one q = null; p = null; r = null; last = (px.length === 1); // first, we try simply to match the current pattern // if not, try the next pattern try { r = px[i].call(this, s); } catch (e) { continue; } // since we are matching against a set of elements, the first // thing to do is to add r[0] to matched elements rx = [[r[0]], r[1]]; // if we matched and there is still input to parse and // we don't already know this is the last element, // we're going to next check for the delimiter ... // if there's none, or if there's no input left to parse // than this must be the last element after all ... if (r[1].length > 0 && ! last) { try { q = d.call(this, r[1]); } catch (ex) { last = true; } } else { last = true; } // if we parsed the delimiter and now there's no more input, // that means we shouldn't have parsed the delimiter at all // so don't update r and mark this as the last element ... if (!last && q[1].length === 0) { last = true; } // so, if this isn't the last element, we're going to see if // we can get any more matches from the remaining (unmatched) // elements ... if (!last) { // build a list of the remaining rules we can match against, // i.e., all but the one we just matched against var qx = []; for (var j = 0; j < px.length ; j++) { if (i !== j) { qx.push(px[j]); } } // now invoke recursively set with the remaining input // note that we don't include the closing delimiter ... // we'll check for that ourselves at the end p = _.set(qx, d).call(this, q[1]); // if we got a non-empty set as a result ... // (otw rx already contains everything we want to match) if (p[0].length > 0) { // update current result, which is stored in rx ... // basically, pick up the remaining text from p[1] // and concat the result from p[0] so that we don't // get endless nesting ... rx[0] = rx[0].concat(p[0]); rx[1] = p[1]; } } // at this point, rx either contains the last matched element // or the entire matched set that starts with this element. // now we just check to see if this variation is better than // our best so far, in terms of how much of the input is parsed if (rx[1].length < best[1].length) { best = rx; } // if we've parsed all the input, then we're finished if (best[1].length === 0) { break; } } // so now we've either gone through all the patterns trying them // as the initial match; or we found one that parsed the entire // input string ... // if best has no matches, just return empty set ... if (best[0].length === 0) { return best; } // if a closing delimiter is provided, then we have to check it also if (c) { // we try this even if there is no remaining input because the pattern // may well be optional or match empty input ... try { q = c.call(this, best[1]); } catch (ey) { throw new $P.Exception(best[1]); } // it parsed ... be sure to update the best match remaining input best[1] = q[1]; } // if we're here, either there was no closing delimiter or we parsed it // so now we have the best match; just return it! return best; }; }, forward: function (gr, fname) { return function (s) { return gr[fname].call(this, s); }; }, // // Translation Operators // replace: function (rule, repl) { return function (s) { var r = rule.call(this, s); return [repl, r[1]]; }; }, process: function (rule, fn) { return function (s) { var r = rule.call(this, s); return [fn.call(this, r[0]), r[1]]; }; }, min: function (min, rule) { return function (s) { var rx = rule.call(this, s); if (rx[0].length < min) { throw new $P.Exception(s); } return rx; }; } }; // Generator Operators And Vector Operators // Generators are operators that have a signature of F(R) => R, // taking a given rule and returning another rule, such as // ignore, which parses a given rule and throws away the result. // Vector operators are those that have a signature of F(R1,R2,...) => R, // take a list of rules and returning a new rule, such as each. // Generator operators are converted (via the following _generator // function) into functions that can also take a list or array of rules // and return an array of new rules as though the function had been // called on each rule in turn (which is what actually happens). // This allows generators to be used with vector operators more easily. // Example: // each(ignore(foo, bar)) instead of each(ignore(foo), ignore(bar)) // This also turns generators into vector operators, which allows // constructs like: // not(cache(foo, bar)) var _generator = function (op) { function gen() { var args = null, rx = [], px, i; if (arguments.length > 1) { args = Array.prototype.slice.call(arguments); } else if (arguments[0] instanceof Array) { args = arguments[0]; } if (args) { px = args.shift(); if (px.length > 0) { args.unshift(px[i]); rx.push(op.apply(null, args)); args.shift(); return rx; } } else { return op.apply(null, arguments); } } return gen; }; var gx = "optional not ignore cache".split(/\s/); for (var i = 0 ; i < gx.length ; i++) { _[gx[i]] = _generator(_[gx[i]]); } var _vector = function (op) { return function () { if (arguments[0] instanceof Array) { return op.apply(null, arguments[0]); } else { return op.apply(null, arguments); } }; }; var vx = "each any all".split(/\s/); for (var j = 0 ; j < vx.length ; j++) { _[vx[j]] = _vector(_[vx[j]]); } }()); (function () { var $D = Date; var flattenAndCompact = function (ax) { var rx = []; for (var i = 0; i < ax.length; i++) { if (ax[i] instanceof Array) { rx = rx.concat(flattenAndCompact(ax[i])); } else { if (ax[i]) { rx.push(ax[i]); } } } return rx; }; var parseMeridian = function () { if (this.meridian && (this.hour || this.hour === 0)) { if (this.meridian === "a" && this.hour > 11 && Date.Config.strict24hr){ throw "Invalid hour and meridian combination"; } else if (this.meridian === "p" && this.hour < 12 && Date.Config.strict24hr){ throw "Invalid hour and meridian combination"; } else if (this.meridian === "p" && this.hour < 12) { this.hour = this.hour + 12; } else if (this.meridian === "a" && this.hour === 12) { this.hour = 0; } } }; var setDefaults = function () { var now = new Date(); if ((this.hour || this.minute) && (!this.month && !this.year && !this.day)) { this.day = now.getDate(); } if (!this.year) { this.year = now.getFullYear(); } if (!this.month && this.month !== 0) { this.month = now.getMonth(); } if (!this.day) { this.day = 1; } if (!this.hour) { this.hour = 0; } if (!this.minute) { this.minute = 0; } if (!this.second) { this.second = 0; } if (!this.millisecond) { this.millisecond = 0; } }; var finishUtils = { getToday: function () { if (this.now || "hour minute second".indexOf(this.unit) !== -1) { return new Date(); } else { return $D.today(); } }, setDaysFromWeekday: function (today, orient){ var gap; orient = orient || 1; this.unit = "day"; gap = ($D.getDayNumberFromName(this.weekday) - today.getDay()); this.days = gap ? ((gap + (orient * 7)) % 7) : (orient * 7); return this; }, setMonthsFromMonth: function (today, orient) { var gap; orient = orient || 1; this.unit = "month"; gap = (this.month - today.getMonth()); this.months = gap ? ((gap + (orient * 12)) % 12) : (orient * 12); this.month = null; return this; }, setDMYFromWeekday: function () { var d = Date[this.weekday](); this.day = d.getDate(); if (!this.month) { this.month = d.getMonth(); } this.year = d.getFullYear(); return this; }, setUnitValue: function (orient) { if (!this.value && this.operator && this.operator !== null && this[this.unit + "s"] && this[this.unit + "s"] !== null) { this[this.unit + "s"] = this[this.unit + "s"] + ((this.operator === "add") ? 1 : -1) + (this.value||0) * orient; } else if (this[this.unit + "s"] == null || this.operator != null) { if (!this.value) { this.value = 1; } this[this.unit + "s"] = this.value * orient; } }, generateDateFromWeeks: function () { var weekday = (this.weekday !== undefined) ? this.weekday : "today"; var d = Date[weekday]().addWeeks(this.weeks); if (this.now) { d.setTimeToNow(); } return d; } }; $D.Translator = { hour: function (s) { return function () { this.hour = Number(s); }; }, minute: function (s) { return function () { this.minute = Number(s); }; }, second: function (s) { return function () { this.second = Number(s); }; }, /* for ss.s format */ secondAndMillisecond: function (s) { return function () { var mx = s.match(/^([0-5][0-9])\.([0-9]{1,3})/); this.second = Number(mx[1]); this.millisecond = Number(mx[2]); }; }, meridian: function (s) { return function () { this.meridian = s.slice(0, 1).toLowerCase(); }; }, timezone: function (s) { return function () { var n = s.replace(/[^\d\+\-]/g, ""); if (n.length) { this.timezoneOffset = Number(n); } else { this.timezone = s.toLowerCase(); } }; }, day: function (x) { var s = x[0]; return function () { this.day = Number(s.match(/\d+/)[0]); if (this.day < 1) { throw "invalid day"; } }; }, month: function (s) { return function () { this.month = (s.length === 3) ? "jan feb mar apr may jun jul aug sep oct nov dec".indexOf(s)/4 : Number(s) - 1; if (this.month < 0) { throw "invalid month"; } }; }, year: function (s) { return function () { var n = Number(s); this.year = ((s.length > 2) ? n : (n + (((n + 2000) < Date.CultureInfo.twoDigitYearMax) ? 2000 : 1900))); }; }, rday: function (s) { return function () { switch (s) { case "yesterday": this.days = -1; break; case "tomorrow": this.days = 1; break; case "today": this.days = 0; break; case "now": this.days = 0; this.now = true; break; } }; }, finishExact: function (x) { var d; x = (x instanceof Array) ? x : [x]; for (var i = 0 ; i < x.length ; i++) { if (x[i]) { x[i].call(this); } } setDefaults.call(this); parseMeridian.call(this); if (this.day > $D.getDaysInMonth(this.year, this.month)) { throw new RangeError(this.day + " is not a valid value for days."); } d = new Date(this.year, this.month, this.day, this.hour, this.minute, this.second, this.millisecond); if (this.year < 100) { d.setFullYear(this.year); // means years less that 100 are process correctly. JS will parse it otherwise as 1900-1999. } if (this.timezone) { d.set({ timezone: this.timezone }); } else if (this.timezoneOffset) { d.set({ timezoneOffset: this.timezoneOffset }); } return d; }, finish: function (x) { var today, expression, orient, temp; x = (x instanceof Array) ? flattenAndCompact(x) : [ x ]; if (x.length === 0) { return null; } for (var i = 0 ; i < x.length ; i++) { if (typeof x[i] === "function") { x[i].call(this); } } if (this.now && !this.unit && !this.operator) { return new Date(); } else { today = finishUtils.getToday.call(this); } expression = !!(this.days && this.days !== null || this.orient || this.operator); orient = ((this.orient === "past" || this.operator === "subtract") ? -1 : 1); if (this.month && this.unit === "week") { this.value = this.month + 1; delete this.month; delete this.day; } if ((this.month || this.month === 0) && "year day hour minute second".indexOf(this.unit) !== -1) { if (!this.value) { this.value = this.month + 1; } this.month = null; expression = true; } if (!expression && this.weekday && !this.day && !this.days) { finishUtils.setDMYFromWeekday.call(this); } if (expression && this.weekday && this.unit !== "month" && this.unit !== "week") { finishUtils.setDaysFromWeekday.call(this, today, orient); } if (this.weekday && this.unit !== "week" && !this.day && !this.days) { temp = Date[this.weekday](); this.day = temp.getDate(); if (temp.getMonth() !== today.getMonth()) { this.month = temp.getMonth(); } } if (this.month && this.unit === "day" && this.operator) { if (!this.value) { this.value = (this.month + 1); } this.month = null; } if (this.value != null && this.month != null && this.year != null) { this.day = this.value * 1; } if (this.month && !this.day && this.value) { today.set({ day: this.value * 1 }); if (!expression) { this.day = this.value * 1; } } if (!this.month && this.value && this.unit === "month" && !this.now) { this.month = this.value; expression = true; } if (expression && (this.month || this.month === 0) && this.unit !== "year") { finishUtils.setMonthsFromMonth.call(this, today, orient); } if (!this.unit) { this.unit = "day"; } finishUtils.setUnitValue.call(this, orient); parseMeridian.call(this); if ((this.month || this.month === 0) && !this.day) { this.day = 1; } if (!this.orient && !this.operator && this.unit === "week" && this.value && !this.day && !this.month) { return Date.today().setWeek(this.value); } if (this.unit === "week" && this.weeks && !this.day && !this.month) { return finishUtils.generateDateFromWeeks.call(this); } if (expression && this.timezone && this.day && this.days) { this.day = this.days; } if (expression){ today.add(this); } else { today.set(this); } if (this.timezone) { this.timezone = this.timezone.toUpperCase(); var offset = $D.getTimezoneOffset(this.timezone); var timezone; if (today.hasDaylightSavingTime()) { // lets check that we're being sane with timezone setting timezone = $D.getTimezoneAbbreviation(offset, today.isDaylightSavingTime()); if (timezone !== this.timezone) { // bugger, we're in a place where things like EST vs EDT matters. if (today.isDaylightSavingTime()) { today.addHours(-1); } else { today.addHours(1); } } } today.setTimezoneOffset(offset); } return today; } }; }()); (function () { var $D = Date; $D.Grammar = {}; var _ = $D.Parsing.Operators, g = $D.Grammar, t = $D.Translator, _fn; // Allow rolling up into general purpose rules _fn = function () { return _.each(_.any.apply(null, arguments), _.not(g.ctoken2("timeContext"))); }; g.datePartDelimiter = _.rtoken(/^([\s\-\.\,\/\x27]+)/); g.timePartDelimiter = _.stoken(":"); g.whiteSpace = _.rtoken(/^\s*/); g.generalDelimiter = _.rtoken(/^(([\s\,]|at|@|on)+)/); var _C = {}; g.ctoken = function (keys) { var fn = _C[keys]; if (! fn) { var c = Date.CultureInfo.regexPatterns; var kx = keys.split(/\s+/), px = []; for (var i = 0; i < kx.length ; i++) { px.push(_.replace(_.rtoken(c[kx[i]]), kx[i])); } fn = _C[keys] = _.any.apply(null, px); } return fn; }; g.ctoken2 = function (key) { return _.rtoken(Date.CultureInfo.regexPatterns[key]); }; var cacheProcessRtoken = function (key, token, type, eachToken) { if (eachToken) { g[key] = _.cache(_.process(_.each(_.rtoken(token),_.optional(g.ctoken2(eachToken))), type)); } else { g[key] = _.cache(_.process(_.rtoken(token), type)); } }; var cacheProcessCtoken = function (token, type) { return _.cache(_.process(g.ctoken2(token), type)); }; var _F = {}; //function cache var _get = function (f) { _F[f] = (_F[f] || g.format(f)[0]); return _F[f]; }; g.allformats = function (fx) { var rx = []; if (fx instanceof Array) { for (var i = 0; i < fx.length; i++) { rx.push(_get(fx[i])); } } else { rx.push(_get(fx)); } return rx; }; g.formats = function (fx) { if (fx instanceof Array) { var rx = []; for (var i = 0 ; i < fx.length ; i++) { rx.push(_get(fx[i])); } return _.any.apply(null, rx); } else { return _get(fx); } }; var grammarFormats = { timeFormats: function(){ var i, RTokenKeys = [ "h", "hh", "H", "HH", "m", "mm", "s", "ss", "ss.s", "z", "zz" ], RToken = [ /^(0[0-9]|1[0-2]|[1-9])/, /^(0[0-9]|1[0-2])/, /^([0-1][0-9]|2[0-3]|[0-9])/, /^([0-1][0-9]|2[0-3])/, /^([0-5][0-9]|[0-9])/, /^[0-5][0-9]/, /^([0-5][0-9]|[0-9])/, /^[0-5][0-9]/, /^[0-5][0-9]\.[0-9]{1,3}/, /^((\+|\-)\s*\d\d\d\d)|((\+|\-)\d\d\:?\d\d)/, /^((\+|\-)\s*\d\d\d\d)|((\+|\-)\d\d\:?\d\d)/ ], tokens = [ t.hour, t.hour, t.hour, t.hour, t.minute, t.minute, t.second, t.second, t.secondAndMillisecond, t.timezone, t.timezone ]; for (i=0; i < RTokenKeys.length; i++) { cacheProcessRtoken(RTokenKeys[i], RToken[i], tokens[i]); } g.hms = _.cache(_.sequence([g.H, g.m, g.s], g.timePartDelimiter)); g.t = cacheProcessCtoken("shortMeridian", t.meridian); g.tt = cacheProcessCtoken("longMeridian", t.meridian); g.zzz = cacheProcessCtoken("timezone", t.timezone); g.timeSuffix = _.each(_.ignore(g.whiteSpace), _.set([ g.tt, g.zzz ])); g.time = _.each(_.optional(_.ignore(_.stoken("T"))), g.hms, g.timeSuffix); }, dateFormats: function () { // pre-loaded rules for different date part order preferences var _setfn = function () { return _.set(arguments, g.datePartDelimiter); }; var i, RTokenKeys = [ "d", "dd", "M", "MM", "y", "yy", "yyy", "yyyy" ], RToken = [ /^([0-2]\d|3[0-1]|\d)/, /^([0-2]\d|3[0-1])/, /^(1[0-2]|0\d|\d)/, /^(1[0-2]|0\d)/, /^(\d+)/, /^(\d\d)/, /^(\d\d?\d?\d?)/, /^(\d\d\d\d)/ ], tokens = [ t.day, t.day, t.month, t.month, t.year, t.year, t.year, t.year ], eachToken = [ "ordinalSuffix", "ordinalSuffix" ]; for (i=0; i < RTokenKeys.length; i++) { cacheProcessRtoken(RTokenKeys[i], RToken[i], tokens[i], eachToken[i]); } g.MMM = g.MMMM = _.cache(_.process(g.ctoken("jan feb mar apr may jun jul aug sep oct nov dec"), t.month)); g.ddd = g.dddd = _.cache(_.process(g.ctoken("sun mon tue wed thu fri sat"), function (s) { return function () { this.weekday = s; }; } )); g.day = _fn(g.d, g.dd); g.month = _fn(g.M, g.MMM); g.year = _fn(g.yyyy, g.yy); g.mdy = _setfn(g.ddd, g.month, g.day, g.year); g.ymd = _setfn(g.ddd, g.year, g.month, g.day); g.dmy = _setfn(g.ddd, g.day, g.month, g.year); g.date = function (s) { return ((g[Date.CultureInfo.dateElementOrder] || g.mdy).call(this, s)); }; }, relative: function () { // relative date / time expressions g.orientation = _.process(g.ctoken("past future"), function (s) { return function () { this.orient = s; }; } ); g.operator = _.process(g.ctoken("add subtract"), function (s) { return function () { this.operator = s; }; } ); g.rday = _.process(g.ctoken("yesterday tomorrow today now"), t.rday); g.unit = _.process(g.ctoken("second minute hour day week month year"), function (s) { return function () { this.unit = s; }; } ); } }; g.buildGrammarFormats = function () { // these need to be rebuilt every time the language changes. _C = {}; grammarFormats.timeFormats(); grammarFormats.dateFormats(); grammarFormats.relative(); g.value = _.process(_.rtoken(/^([-+]?\d+)?(st|nd|rd|th)?/), function (s) { return function () { this.value = s.replace(/\D/g, ""); }; } ); g.expression = _.set([g.rday, g.operator, g.value, g.unit, g.orientation, g.ddd, g.MMM ]); g.format = _.process(_.many( _.any( // translate format specifiers into grammar rules _.process( _.rtoken(/^(dd?d?d?(?!e)|MM?M?M?|yy?y?y?|hh?|HH?|mm?|ss?|tt?|zz?z?)/), function (fmt) { if (g[fmt]) { return g[fmt]; } else { throw $D.Parsing.Exception(fmt); } } ), // translate separator tokens into token rules _.process(_.rtoken(/^[^dMyhHmstz]+/), // all legal separators function (s) { return _.ignore(_.stoken(s)); } ) ) ), // construct the parser ... function (rules) { return _.process(_.each.apply(null, rules), t.finishExact); } ); // starting rule for general purpose grammar g._start = _.process(_.set([ g.date, g.time, g.expression ], g.generalDelimiter, g.whiteSpace), t.finish); }; g.buildGrammarFormats(); // parsing date format specifiers - ex: "h:m:s tt" // this little guy will generate a custom parser based // on the format string, ex: g.format("h:m:s tt") // check for these formats first g._formats = g.formats([ "\"yyyy-MM-ddTHH:mm:ssZ\"", "yyyy-MM-ddTHH:mm:ss.sz", "yyyy-MM-ddTHH:mm:ssZ", "yyyy-MM-ddTHH:mm:ssz", "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-ddTHH:mmZ", "yyyy-MM-ddTHH:mmz", "yyyy-MM-ddTHH:mm", "ddd, MMM dd, yyyy H:mm:ss tt", "ddd MMM d yyyy HH:mm:ss zzz", "MMddyyyy", "ddMMyyyy", "Mddyyyy", "ddMyyyy", "Mdyyyy", "dMyyyy", "yyyy", "Mdyy", "dMyy", "d" ]); // real starting rule: tries selected formats first, // then general purpose rule g.start = function (s) { try { var r = g._formats.call({}, s); if (r[1].length === 0) { return r; } } catch (e) {} return g._start.call({}, s); }; }()); (function () { var $D = Date; /** * @desc Converts the specified string value into its JavaScript Date equivalent using CultureInfo specific format information. * * Example

	///////////
	// Dates //
	///////////

	// 15-Oct-2004
	var d1 = Date.parse("10/15/2004");

	// 15-Oct-2004
	var d1 = Date.parse("15-Oct-2004");

	// 15-Oct-2004
	var d1 = Date.parse("2004.10.15");

	//Fri Oct 15, 2004
	var d1 = Date.parse("Fri Oct 15, 2004");

	///////////
	// Times //
	///////////

	// Today at 10 PM.
	var d1 = Date.parse("10 PM");

	// Today at 10:30 PM.
	var d1 = Date.parse("10:30 P.M.");

	// Today at 6 AM.
	var d1 = Date.parse("06am");

	/////////////////////
	// Dates and Times //
	/////////////////////

	// 8-July-2004 @ 10:30 PM
	var d1 = Date.parse("July 8th, 2004, 10:30 PM");

	// 1-July-2004 @ 10:30 PM
	var d1 = Date.parse("2004-07-01T22:30:00");

	////////////////////
	// Relative Dates //
	////////////////////

	// Returns today's date. The string "today" is culture specific.
	var d1 = Date.parse("today");

	// Returns yesterday's date. The string "yesterday" is culture specific.
	var d1 = Date.parse("yesterday");

	// Returns the date of the next thursday.
	var d1 = Date.parse("Next thursday");

	// Returns the date of the most previous monday.
	var d1 = Date.parse("last monday");

	// Returns today's day + one year.
	var d1 = Date.parse("next year");

	///////////////
	// Date Math //
	///////////////

	// Today + 2 days
	var d1 = Date.parse("t+2");

	// Today + 2 days
	var d1 = Date.parse("today + 2 days");

	// Today + 3 months
	var d1 = Date.parse("t+3m");

	// Today - 1 year
	var d1 = Date.parse("today - 1 year");

	// Today - 1 year
	var d1 = Date.parse("t-1y"); 


	/////////////////////////////
	// Partial Dates and Times //
	/////////////////////////////

	// July 15th of this year.
	var d1 = Date.parse("July 15");

	// 15th day of current day and year.
	var d1 = Date.parse("15");

	// July 1st of current year at 10pm.
	var d1 = Date.parse("7/1 10pm");
	
* * @param {String} The string value to convert into a Date object [Required] * @return {Date} A Date object or null if the string cannot be converted into a Date. */ var parseUtils = { removeOrds: function (s) { ords = s.match(/\b(\d+)(?:st|nd|rd|th)\b/); // find ordinal matches s = ((ords && ords.length === 2) ? s.replace(ords[0], ords[1]) : s); return s; }, grammarParser: function (s) { var r = null; try { r = $D.Grammar.start.call({}, s.replace(/^\s*(\S*(\s+\S+)*)\s*$/, "$1")); } catch (e) { return null; } return ((r[1].length === 0) ? r[0] : null); }, nativeFallback: function(s) { var t; try { // ok we haven't parsed it, last ditch attempt with the built-in parser. t = Date._parse(s); return (t || t === 0) ? new Date(t) : null; } catch (e) { return null; } } }; function parse (s) { var d; if (!s) { return null; } if (s instanceof Date) { return s.clone(); } if (s.length >= 4 && s.charAt(0) !== "0" && s.charAt(0) !== "+"&& s.charAt(0) !== "-") { // ie: 2004 will pass, 0800 won't. // Start with specific formats d = $D.Parsing.ISO.parse(s) || $D.Parsing.Numeric.parse(s); } if (d instanceof Date && !isNaN(d.getTime())) { return d; } else { // find ordinal dates (1st, 3rd, 8th, etc and remove them as they cause parsing issues) s = $D.Parsing.Normalizer.parse(parseUtils.removeOrds(s)); d = parseUtils.grammarParser(s); if (d !== null) { return d; } else { return parseUtils.nativeFallback(s); } } } if (!$D._parse) { $D._parse = $D.parse; } $D.parse = parse; Date.getParseFunction = function (fx) { var fns = Date.Grammar.allformats(fx); return function (s) { var r = null; for (var i = 0; i < fns.length; i++) { try { r = fns[i].call({}, s); } catch (e) { continue; } if (r[1].length === 0) { return r[0]; } } return null; }; }; /** * Converts the specified string value into its JavaScript Date equivalent using the specified format {String} or formats {Array} and the CultureInfo specific format information. * The format of the string value must match one of the supplied formats exactly. * * Example

	// 15-Oct-2004
	var d1 = Date.parseExact("10/15/2004", "M/d/yyyy");

	// 15-Oct-2004
	var d1 = Date.parse("15-Oct-2004", "M-ddd-yyyy");

	// 15-Oct-2004
	var d1 = Date.parse("2004.10.15", "yyyy.MM.dd");

	// Multiple formats
	var d1 = Date.parseExact("10/15/2004", ["M/d/yyyy", "MMMM d, yyyy"]);
	
* * @param {String} The string value to convert into a Date object [Required]. * @param {Object} The expected format {String} or an array of expected formats {Array} of the date string [Required]. * @return {Date} A Date object or null if the string cannot be converted into a Date. */ $D.parseExact = function (s, fx) { return $D.getParseFunction(fx)(s); }; }()); (function () { var $D = Date, $P = $D.prototype, // $C = $D.CultureInfo, // not used atm p = function (s, l) { if (!l) { l = 2; } return ("000" + s).slice(l * -1); }; /** * Converts a PHP format string to Java/.NET format string. * A PHP format string can be used with ._format or .format. * A Java/.NET format string can be used with .toString(). * The .parseExact function will only accept a Java/.NET format string * * Example * var f1 = "%m/%d/%y" * var f2 = Date.normalizeFormat(f1); // "MM/dd/yy" * * new Date().format(f1); // "04/13/08" * new Date()._format(f1); // "04/13/08" * new Date().toString(f2); // "04/13/08" * * var date = Date.parseExact("04/13/08", f2); // Sun Apr 13 2008 * * @param {String} A PHP format string consisting of one or more format spcifiers. * @return {String} The PHP format converted to a Java/.NET format string. */ var normalizerSubstitutions = { "d" : "dd", "%d": "dd", "D" : "ddd", "%a": "ddd", "j" : "dddd", "l" : "dddd", "%A": "dddd", "S" : "S", "F" : "MMMM", "%B": "MMMM", "m" : "MM", "%m": "MM", "M" : "MMM", "%b": "MMM", "%h": "MMM", "n" : "M", "Y" : "yyyy", "%Y": "yyyy", "y" : "yy", "%y": "yy", "g" : "h", "%I": "h", "G" : "H", "h" : "hh", "H" : "HH", "%H": "HH", "i" : "mm", "%M": "mm", "s" : "ss", "%S": "ss", "%r": "hh:mm tt", "%R": "H:mm", "%T": "H:mm:ss", "%X": "t", "%x": "d", "%e": "d", "%D": "MM/dd/yy", "%n": "\\n", "%t": "\\t", "e" : "z", "T" : "z", "%z": "z", "%Z": "z", "Z" : "ZZ", "N" : "u", "w" : "u", "%w": "u", "W" : "W", "%V": "W" }; var normalizer = { substitutes: function (m) { return normalizerSubstitutions[m]; }, interpreted: function (m, x) { var y; switch (m) { case "%u": return x.getDay() + 1; case "z": return x.getOrdinalNumber(); case "%j": return p(x.getOrdinalNumber(), 3); case "%U": var d1 = x.clone().set({month: 0, day: 1}).addDays(-1).moveToDayOfWeek(0), d2 = x.clone().addDays(1).moveToDayOfWeek(0, -1); return (d2 < d1) ? "00" : p((d2.getOrdinalNumber() - d1.getOrdinalNumber()) / 7 + 1); case "%W": return p(x.getWeek()); case "t": return $D.getDaysInMonth(x.getFullYear(), x.getMonth()); case "o": case "%G": return x.setWeek(x.getISOWeek()).toString("yyyy"); case "%g": return x._format("%G").slice(-2); case "a": case "%p": return t("tt").toLowerCase(); case "A": return t("tt").toUpperCase(); case "u": return p(x.getMilliseconds(), 3); case "I": return (x.isDaylightSavingTime()) ? 1 : 0; case "O": return x.getUTCOffset(); case "P": y = x.getUTCOffset(); return y.substring(0, y.length - 2) + ":" + y.substring(y.length - 2); case "B": var now = new Date(); return Math.floor(((now.getHours() * 3600) + (now.getMinutes() * 60) + now.getSeconds() + (now.getTimezoneOffset() + 60) * 60) / 86.4); case "c": return x.toISOString().replace(/\"/g, ""); case "U": return $D.strtotime("now"); case "%c": return t("d") + " " + t("t"); case "%C": return Math.floor(x.getFullYear() / 100 + 1); } }, shouldOverrideDefaults: function (m) { switch (m) { case "%e": return true; default: return false; } }, parse: function (m, context) { var formatString, c = context || new Date(); formatString = normalizer.substitutes(m); if (formatString) { return formatString; } formatString = normalizer.interpreted(m, c); if (formatString) { return formatString; } else { return m; } } }; $D.normalizeFormat = function (format, context) { return format.replace(/(%|\\)?.|%%/g, function(t){ return normalizer.parse(t, context); }); }; /** * Format a local Unix timestamp according to locale settings * * Example: * Date.strftime("%m/%d/%y", new Date()); // "04/13/08" * Date.strftime("c", "2008-04-13T17:52:03Z"); // "04/13/08" * * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @param {Number|String} The number representing the number of seconds that have elapsed since January 1, 1970 (local time). * @return {String} A string representation of the current Date object. */ $D.strftime = function (format, time) { var d = Date.parse(time); return d._format(format); }; /** * Parse any textual datetime description into a Unix timestamp. * A Unix timestamp is the number of seconds that have elapsed since January 1, 1970 (midnight UTC/GMT). * * Example: * Date.strtotime("04/13/08"); // 1208044800 * Date.strtotime("1970-01-01T00:00:00Z"); // 0 * * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @param {Object} A string or date object. * @return {String} A string representation of the current Date object. */ $D.strtotime = function (time) { var d = $D.parse(time); return Math.round($D.UTC(d.getUTCFullYear(), d.getUTCMonth(), d.getUTCDate(), d.getUTCHours(), d.getUTCMinutes(), d.getUTCSeconds(), d.getUTCMilliseconds()) / 1000); }; /** * Converts the value of the current Date object to its equivalent string representation using a PHP/Unix style of date format specifiers. * Format Specifiers * Format Description Example * ------ --------------------------------------------------------------------------- ----------------------- * %a abbreviated weekday name according to the current localed "Mon" through "Sun" * %A full weekday name according to the current localed "Sunday" through "Saturday" * %b abbreviated month name according to the current localed "Jan" through "Dec" * %B full month name according to the current locale "January" through "December" * %c preferred date and time representation for the current locale "4/13/2008 12:33 PM" * %C century number (the year divided by 100 and truncated to an integer) "00" to "99" * %d day of the month as a decimal number "01" to "31" * %D same as %m/%d/%y "04/13/08" * %e day of the month as a decimal number, a single digit is preceded by a space "1" to "31" * %g like %G, but without the century "08" * %G The 4-digit year corresponding to the ISO week number (see %V). "2008" * This has the same format and value as %Y, except that if the ISO week number * belongs to the previous or next year, that year is used instead. * %h same as %b "Jan" through "Dec" * %H hour as a decimal number using a 24-hour clock. "00" to "23" * %I hour as a decimal number using a 12-hour clock. "01" to "12" * %j day of the year as a decimal number. "001" to "366" * %m month as a decimal number. "01" to "12" * %M minute as a decimal number. "00" to "59" * %n newline character "\n" * %p either "am" or "pm" according to the given time value, or the "am" or "pm" * corresponding strings for the current locale. * %r time in a.m. and p.m. notation "8:44 PM" * %R time in 24 hour notation "20:44" * %S second as a decimal number "00" to "59" * %t tab character "\t" * %T current time, equal to %H:%M:%S "12:49:11" * %u weekday as a decimal number ["1", "7"], with "1" representing Monday "1" to "7" * %U week number of the current year as a decimal number, starting with the "0" to ("52" or "53") * first Sunday as the first day of the first week * %V The ISO 8601:1988 week number of the current year as a decimal number, "00" to ("52" or "53") * range 01 to 53, where week 1 is the first week that has at least 4 days * in the current year, and with Monday as the first day of the week. * (Use %G or %g for the year component that corresponds to the week number * for the specified timestamp.) * %W week number of the current year as a decimal number, starting with the "00" to ("52" or "53") * first Monday as the first day of the first week * %w day of the week as a decimal, Sunday being "0" "0" to "6" * %x preferred date representation for the current locale without the time "4/13/2008" * %X preferred time representation for the current locale without the date "12:53:05" * %y year as a decimal number without a century "00" "99" * %Y year as a decimal number including the century "2008" * %Z time zone or name or abbreviation "UTC", "EST", "PST" * %z same as %Z * %% a literal "%" characters "%" * d Day of the month, 2 digits with leading zeros "01" to "31" * D A textual representation of a day, three letters "Mon" through "Sun" * j Day of the month without leading zeros "1" to "31" * l A full textual representation of the day of the week (lowercase "L") "Sunday" through "Saturday" * N ISO-8601 numeric representation of the day of the week (added in PHP 5.1.0) "1" (for Monday) through "7" (for Sunday) * S English ordinal suffix for the day of the month, 2 characters "st", "nd", "rd" or "th". Works well with j * w Numeric representation of the day of the week "0" (for Sunday) through "6" (for Saturday) * z The day of the year (starting from "0") "0" through "365" * W ISO-8601 week number of year, weeks starting on Monday "00" to ("52" or "53") * F A full textual representation of a month, such as January or March "January" through "December" * m Numeric representation of a month, with leading zeros "01" through "12" * M A short textual representation of a month, three letters "Jan" through "Dec" * n Numeric representation of a month, without leading zeros "1" through "12" * t Number of days in the given month "28" through "31" * L Whether it's a leap year "1" if it is a leap year, "0" otherwise * o ISO-8601 year number. This has the same value as Y, except that if the "2008" * ISO week number (W) belongs to the previous or next year, that year * is used instead. * Y A full numeric representation of a year, 4 digits "2008" * y A two digit representation of a year "08" * a Lowercase Ante meridiem and Post meridiem "am" or "pm" * A Uppercase Ante meridiem and Post meridiem "AM" or "PM" * B Swatch Internet time "000" through "999" * g 12-hour format of an hour without leading zeros "1" through "12" * G 24-hour format of an hour without leading zeros "0" through "23" * h 12-hour format of an hour with leading zeros "01" through "12" * H 24-hour format of an hour with leading zeros "00" through "23" * i Minutes with leading zeros "00" to "59" * s Seconds, with leading zeros "00" through "59" * u Milliseconds "54321" * e Timezone identifier "UTC", "EST", "PST" * I Whether or not the date is in daylight saving time (uppercase i) "1" if Daylight Saving Time, "0" otherwise * O Difference to Greenwich time (GMT) in hours "+0200", "-0600" * P Difference to Greenwich time (GMT) with colon between hours and minutes "+02:00", "-06:00" * T Timezone abbreviation "UTC", "EST", "PST" * Z Timezone offset in seconds. The offset for timezones west of UTC is "-43200" through "50400" * always negative, and for those east of UTC is always positive. * c ISO 8601 date "2004-02-12T15:19:21+00:00" * r RFC 2822 formatted date "Thu, 21 Dec 2000 16:01:07 +0200" * U Seconds since the Unix Epoch (January 1 1970 00:00:00 GMT) "0" * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @return {String} A string representation of the current Date object. */ var formatReplace = function (context) { return function (m) { var formatString, override = false; if (m.charAt(0) === "\\" || m.substring(0, 2) === "%%") { return m.replace("\\", "").replace("%%", "%"); } override = normalizer.shouldOverrideDefaults(m); formatString = $D.normalizeFormat(m, context); if (formatString) { return context.toString(formatString, override); } }; }; $P._format = function (format) { var formatter = formatReplace(this); if (!format) { return this._toString(); } else { return format.replace(/(%|\\)?.|%%/g, formatter); } }; if (!$P.format) { $P.format = $P._format; } }()); (function () { "use strict"; var gFn = function (attr) { return function () { return this[attr]; }; }; var sFn = function (attr) { return function (val) { this[attr] = val; return this; }; }; var attrs = ["years", "months", "days", "hours", "minutes", "seconds", "milliseconds"]; var addSetFuncs = function (context, attrs) { for (var i = 0; i < attrs.length ; i++) { var $a = attrs[i], $b = $a.slice(0, 1).toUpperCase() + $a.slice(1); context.prototype[$a] = 0; context.prototype["get" + $b] = gFn($a); context.prototype["set" + $b] = sFn($a); } }; /** * new TimeSpan(milliseconds); * new TimeSpan(days, hours, minutes, seconds); * new TimeSpan(days, hours, minutes, seconds, milliseconds); */ var TimeSpan = function (days, hours, minutes, seconds, milliseconds) { if (arguments.length === 1 && typeof days === "number") { var orient = (days < 0) ? -1 : +1; var millsLeft = Math.abs(days); this.setDays(Math.floor(millsLeft / 86400000) * orient); millsLeft = millsLeft % 86400000; this.setHours(Math.floor(millsLeft / 3600000) * orient); millsLeft = millsLeft % 3600000; this.setMinutes(Math.floor(millsLeft / 60000) * orient); millsLeft = millsLeft % 60000; this.setSeconds(Math.floor(millsLeft / 1000) * orient); millsLeft = millsLeft % 1000; this.setMilliseconds(millsLeft * orient); } else { this.set(days, hours, minutes, seconds, milliseconds); } this.getTotalMilliseconds = function () { return (this.getDays() * 86400000) + (this.getHours() * 3600000) + (this.getMinutes() * 60000) + (this.getSeconds() * 1000); }; this.compareTo = function (time) { var t1 = new Date(1970, 1, 1, this.getHours(), this.getMinutes(), this.getSeconds()), t2; if (time === null) { t2 = new Date(1970, 1, 1, 0, 0, 0); } else { t2 = new Date(1970, 1, 1, time.getHours(), time.getMinutes(), time.getSeconds()); } return (t1 < t2) ? -1 : (t1 > t2) ? 1 : 0; }; this.equals = function (time) { return (this.compareTo(time) === 0); }; this.add = function (time) { return (time === null) ? this : this.addSeconds(time.getTotalMilliseconds() / 1000); }; this.subtract = function (time) { return (time === null) ? this : this.addSeconds(-time.getTotalMilliseconds() / 1000); }; this.addDays = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 86400000)); }; this.addHours = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 3600000)); }; this.addMinutes = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 60000)); }; this.addSeconds = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 1000)); }; this.addMilliseconds = function (n) { return new TimeSpan(this.getTotalMilliseconds() + n); }; this.get12HourHour = function () { return (this.getHours() > 12) ? this.getHours() - 12 : (this.getHours() === 0) ? 12 : this.getHours(); }; this.getDesignator = function () { return (this.getHours() < 12) ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator; }; this.toString = function (format) { this._toString = function () { if (this.getDays() !== null && this.getDays() > 0) { return this.getDays() + "." + this.getHours() + ":" + this.p(this.getMinutes()) + ":" + this.p(this.getSeconds()); } else { return this.getHours() + ":" + this.p(this.getMinutes()) + ":" + this.p(this.getSeconds()); } }; this.p = function (s) { return (s.toString().length < 2) ? "0" + s : s; }; var me = this; return format ? format.replace(/dd?|HH?|hh?|mm?|ss?|tt?/g, function (format) { switch (format) { case "d": return me.getDays(); case "dd": return me.p(me.getDays()); case "H": return me.getHours(); case "HH": return me.p(me.getHours()); case "h": return me.get12HourHour(); case "hh": return me.p(me.get12HourHour()); case "m": return me.getMinutes(); case "mm": return me.p(me.getMinutes()); case "s": return me.getSeconds(); case "ss": return me.p(me.getSeconds()); case "t": return ((me.getHours() < 12) ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator).substring(0, 1); case "tt": return (me.getHours() < 12) ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator; } } ) : this._toString(); }; return this; }; addSetFuncs(TimeSpan, attrs.slice(2)); TimeSpan.prototype.set = function (days, hours, minutes, seconds, milliseconds){ this.setDays(days || this.getDays()); this.setHours(hours || this.getHours()); this.setMinutes(minutes || this.getMinutes()); this.setSeconds(seconds || this.getSeconds()); this.setMilliseconds(milliseconds || this.getMilliseconds()); }; /** * Gets the time of day for this date instances. * @return {TimeSpan} TimeSpan */ Date.prototype.getTimeOfDay = function () { return new TimeSpan(0, this.getHours(), this.getMinutes(), this.getSeconds(), this.getMilliseconds()); }; Date.TimeSpan = TimeSpan; if (typeof window !== "undefined" ) { // keeping API compatible for v1.x window.TimeSpan = TimeSpan; } }()); (function () { "use strict"; var attrs = ["years", "months", "days", "hours", "minutes", "seconds", "milliseconds"]; var gFn = function (attr) { return function () { return this[attr]; }; }; var sFn = function (attr) { return function (val) { this[attr] = val; return this; }; }; var addSetFuncs = function (context, attrs) { for (var i = 0; i < attrs.length ; i++) { var $a = attrs[i], $b = $a.slice(0, 1).toUpperCase() + $a.slice(1); context.prototype[$a] = 0; context.prototype["get" + $b] = gFn($a); context.prototype["set" + $b] = sFn($a); } }; var setMonthsAndYears = function (orient, d1, d2, context) { function inc() { d1.addMonths(-orient); context.months++; if (context.months === 12) { context.years++; context.months = 0; } } if (orient === +1) { while (d1 > d2) { inc(); } } else { while (d1 < d2) { inc(); } } context.months--; context.months *= orient; context.years *= orient; }; var adjustForDST = function(orient, startDate, endDate) { var hasDSTMismatch = (false === (startDate.isDaylightSavingTime() === endDate.isDaylightSavingTime())); if (hasDSTMismatch && orient === 1) { startDate.addHours(-1); } else if (hasDSTMismatch) { startDate.addHours(1); } }; /** * TimePeriod(startDate, endDate); * TimePeriod(years, months, days, hours, minutes, seconds, milliseconds); */ var TimePeriod = function (years, months, days, hours, minutes, seconds, milliseconds) { if (arguments.length === 7) { this.set(years, months, days, hours, minutes, seconds, milliseconds); } else if (arguments.length === 2 && arguments[0] instanceof Date && arguments[1] instanceof Date) { var startDate = arguments[0].clone(); var endDate = arguments[1].clone(); var orient = (startDate > endDate) ? +1 : -1; this.dates = { start: arguments[0].clone(), end: arguments[1].clone() }; setMonthsAndYears(orient, startDate, endDate, this); adjustForDST(orient, startDate, endDate); // // TODO - adjust for DST var diff = endDate - startDate; if (diff !== 0) { var ts = new TimeSpan(diff); this.set(this.years, this.months, ts.getDays(), ts.getHours(), ts.getMinutes(), ts.getSeconds(), ts.getMilliseconds()); } } return this; }; // create all the set functions. addSetFuncs(TimePeriod, attrs); TimePeriod.prototype.set = function (years, months, days, hours, minutes, seconds, milliseconds){ this.setYears(years || this.getYears()); this.setMonths(months || this.getMonths()); this.setDays(days || this.getDays()); this.setHours(hours || this.getHours()); this.setMinutes(minutes || this.getMinutes()); this.setSeconds(seconds || this.getSeconds()); this.setMilliseconds(milliseconds || this.getMilliseconds()); }; Date.TimePeriod = TimePeriod; if (typeof window !== "undefined") { // keeping API compatible for v1.x window.TimePeriod = TimePeriod; } }()); ================================================ FILE: build/date-es-PR.js ================================================ /** * @overview datejs * @version 1.0.0-rc3 * @author Gregory Wild-Smith * @copyright 2015 Gregory Wild-Smith * @license MIT * @homepage https://github.com/abritinthebay/datejs */ /* * DateJS Culture String File * Country Code: es-PR * Name: Spanish (Puerto Rico) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["es-PR"] = { "name": "es-PR", "englishName": "Spanish (Puerto Rico)", "nativeName": "Español (Puerto Rico)", "Sunday": "domingo", "Monday": "lunes", "Tuesday": "martes", "Wednesday": "miércoles", "Thursday": "jueves", "Friday": "viernes", "Saturday": "sábado", "Sun": "dom", "Mon": "lun", "Tue": "mar", "Wed": "mié", "Thu": "jue", "Fri": "vie", "Sat": "sáb", "Su": "do", "Mo": "lu", "Tu": "ma", "We": "mi", "Th": "ju", "Fr": "vi", "Sa": "sá", "S_Sun_Initial": "d", "M_Mon_Initial": "l", "T_Tue_Initial": "m", "W_Wed_Initial": "m", "T_Thu_Initial": "j", "F_Fri_Initial": "v", "S_Sat_Initial": "s", "January": "enero", "February": "febrero", "March": "marzo", "April": "abril", "May": "mayo", "June": "junio", "July": "julio", "August": "agosto", "September": "septiembre", "October": "octubre", "November": "noviembre", "December": "diciembre", "Jan_Abbr": "ene", "Feb_Abbr": "feb", "Mar_Abbr": "mar", "Apr_Abbr": "abr", "May_Abbr": "may", "Jun_Abbr": "jun", "Jul_Abbr": "jul", "Aug_Abbr": "ago", "Sep_Abbr": "sep", "Oct_Abbr": "oct", "Nov_Abbr": "nov", "Dec_Abbr": "dic", "AM": "a.m.", "PM": "p.m.", "firstDayOfWeek": 0, "twoDigitYearMax": 2029, "mdy": "dmy", "M/d/yyyy": "dd/MM/yyyy", "dddd, MMMM dd, yyyy": "dddd, dd' [de] 'MMMM' [de] 'yyyy", "h:mm tt": "hh:mm tt", "h:mm:ss tt": "hh:mm:ss tt", "dddd, MMMM dd, yyyy h:mm:ss tt": "dddd, dd' [de] 'MMMM' [de] 'yyyy hh:mm:ss tt", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "dd MMMM", "MMMM, yyyy": "MMMM' [de] 'yyyy", "/jan(uary)?/": "ene(ro)?", "/feb(ruary)?/": "feb(rero)?", "/mar(ch)?/": "mar(zo)?", "/apr(il)?/": "abr(il)?", "/may/": "may(o)?", "/jun(e)?/": "jun(io)?", "/jul(y)?/": "jul(io)?", "/aug(ust)?/": "ago(sto)?", "/sep(t(ember)?)?/": "sep(tiembre)?", "/oct(ober)?/": "oct(ubre)?", "/nov(ember)?/": "nov(iembre)?", "/dec(ember)?/": "dic(iembre)?", "/^su(n(day)?)?/": "^do(m(ingo)?)?", "/^mo(n(day)?)?/": "^lu(n(es)?)?", "/^tu(e(s(day)?)?)?/": "^ma(r(tes)?)?", "/^we(d(nesday)?)?/": "^mi(é(rcoles)?)?", "/^th(u(r(s(day)?)?)?)?/": "^ju(e(ves)?)?", "/^fr(i(day)?)?/": "^vi(e(rnes)?)?", "/^sa(t(urday)?)?/": "^sá(b(ado)?)?", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "es-PR"; /** * @overview datejs * @version 1.0.0-rc3 * @author Gregory Wild-Smith * @copyright 2015 Gregory Wild-Smith * @license MIT * @homepage https://github.com/abritinthebay/datejs */(function () { var $D = Date; var lang = Date.CultureStrings ? Date.CultureStrings.lang : null; var loggedKeys = {}; // for debug purposes. var getText = { getFromKey: function (key, countryCode) { var output; if (Date.CultureStrings && Date.CultureStrings[countryCode] && Date.CultureStrings[countryCode][key]) { output = Date.CultureStrings[countryCode][key]; } else { output = getText.buildFromDefault(key); } if (key.charAt(0) === "/") { // Assume it's a regex output = getText.buildFromRegex(key, countryCode); } return output; }, getFromObjectValues: function (obj, countryCode) { var key, output = {}; for(key in obj) { if (obj.hasOwnProperty(key)) { output[key] = getText.getFromKey(obj[key], countryCode); } } return output; }, getFromObjectKeys: function (obj, countryCode) { var key, output = {}; for(key in obj) { if (obj.hasOwnProperty(key)) { output[getText.getFromKey(key, countryCode)] = obj[key]; } } return output; }, getFromArray: function (arr, countryCode) { var output = []; for (var i=0; i < arr.length; i++){ if (i in arr) { output[i] = getText.getFromKey(arr[i], countryCode); } } return output; }, buildFromDefault: function (key) { var output, length, split, last; switch(key) { case "name": output = "en-US"; break; case "englishName": output = "English (United States)"; break; case "nativeName": output = "English (United States)"; break; case "twoDigitYearMax": output = 2049; break; case "firstDayOfWeek": output = 0; break; default: output = key; split = key.split("_"); length = split.length; if (length > 1 && key.charAt(0) !== "/") { // if the key isn't a regex and it has a split. last = split[(length - 1)].toLowerCase(); if (last === "initial" || last === "abbr") { output = split[0]; } } break; } return output; }, buildFromRegex: function (key, countryCode) { var output; if (Date.CultureStrings && Date.CultureStrings[countryCode] && Date.CultureStrings[countryCode][key]) { output = new RegExp(Date.CultureStrings[countryCode][key], "i"); } else { output = new RegExp(key.replace(new RegExp("/", "g"),""), "i"); } return output; } }; var shallowMerge = function (obj1, obj2) { for (var attrname in obj2) { if (obj2.hasOwnProperty(attrname)) { obj1[attrname] = obj2[attrname]; } } }; var __ = function (key, language) { var countryCode = (language) ? language : lang; loggedKeys[key] = key; if (typeof key === "object") { if (key instanceof Array) { return getText.getFromArray(key, countryCode); } else { return getText.getFromObjectKeys(key, countryCode); } } else { return getText.getFromKey(key, countryCode); } }; var loadI18nScript = function (code) { // paatterned after jQuery's getScript. var url = Date.Config.i18n + code + ".js"; var head = document.getElementsByTagName("head")[0] || document.documentElement; var script = document.createElement("script"); script.src = url; var completed = false; var events = { done: function (){} // placeholder function }; // Attach handlers for all browsers script.onload = script.onreadystatechange = function() { if ( !completed && (!this.readyState || this.readyState === "loaded" || this.readyState === "complete") ) { events.done(); head.removeChild(script); } }; setTimeout(function() { head.insertBefore(script, head.firstChild); }, 0); // allows return to execute first return { done: function (cb) { events.done = function() { if (cb) { setTimeout(cb,0); } }; } }; }; var buildInfo = { buildFromMethodHash: function (obj) { var key; for(key in obj) { if (obj.hasOwnProperty(key)) { obj[key] = buildInfo[obj[key]](); } } return obj; }, timeZoneDST: function () { var DST = { "CHADT": "+1345", "NZDT": "+1300", "AEDT": "+1100", "ACDT": "+1030", "AZST": "+0500", "IRDT": "+0430", "EEST": "+0300", "CEST": "+0200", "BST": "+0100", "PMDT": "-0200", "ADT": "-0300", "NDT": "-0230", "EDT": "-0400", "CDT": "-0500", "MDT": "-0600", "PDT": "-0700", "AKDT": "-0800", "HADT": "-0900" }; return __(DST); }, timeZoneStandard: function () { var standard = { "LINT": "+1400", "TOT": "+1300", "CHAST": "+1245", "NZST": "+1200", "NFT": "+1130", "SBT": "+1100", "AEST": "+1000", "ACST": "+0930", "JST": "+0900", "CWST": "+0845", "CT": "+0800", "ICT": "+0700", "MMT": "+0630", "BST": "+0600", "NPT": "+0545", "IST": "+0530", "PKT": "+0500", "AFT": "+0430", "MSK": "+0400", "IRST": "+0330", "FET": "+0300", "EET": "+0200", "CET": "+0100", "GMT": "+0000", "UTC": "+0000", "CVT": "-0100", "GST": "-0200", "BRT": "-0300", "NST": "-0330", "AST": "-0400", "EST": "-0500", "CST": "-0600", "MST": "-0700", "PST": "-0800", "AKST": "-0900", "MIT": "-0930", "HST": "-1000", "SST": "-1100", "BIT": "-1200" }; return __(standard); }, timeZones: function (data) { var zone; data.timezones = []; for (zone in data.abbreviatedTimeZoneStandard) { if (data.abbreviatedTimeZoneStandard.hasOwnProperty(zone)) { data.timezones.push({ name: zone, offset: data.abbreviatedTimeZoneStandard[zone]}); } } for (zone in data.abbreviatedTimeZoneDST) { if (data.abbreviatedTimeZoneDST.hasOwnProperty(zone)) { data.timezones.push({ name: zone, offset: data.abbreviatedTimeZoneDST[zone], dst: true}); } } return data.timezones; }, days: function () { return __(["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"]); }, dayAbbr: function () { return __(["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"]); }, dayShortNames: function () { return __(["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"]); }, dayFirstLetters: function () { return __(["S_Sun_Initial", "M_Mon_Initial", "T_Tues_Initial", "W_Wed_Initial", "T_Thu_Initial", "F_Fri_Initial", "S_Sat_Initial"]); }, months: function () { return __(["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"]); }, monthAbbr: function () { return __(["Jan_Abbr", "Feb_Abbr", "Mar_Abbr", "Apr_Abbr", "May_Abbr", "Jun_Abbr", "Jul_Abbr", "Aug_Abbr", "Sep_Abbr", "Oct_Abbr", "Nov_Abbr", "Dec_Abbr"]); }, formatPatterns: function () { return getText.getFromObjectValues({ shortDate: "M/d/yyyy", longDate: "dddd, MMMM dd, yyyy", shortTime: "h:mm tt", longTime: "h:mm:ss tt", fullDateTime: "dddd, MMMM dd, yyyy h:mm:ss tt", sortableDateTime: "yyyy-MM-ddTHH:mm:ss", universalSortableDateTime: "yyyy-MM-dd HH:mm:ssZ", rfc1123: "ddd, dd MMM yyyy HH:mm:ss", monthDay: "MMMM dd", yearMonth: "MMMM, yyyy" }, Date.i18n.currentLanguage()); }, regex: function () { return getText.getFromObjectValues({ inTheMorning: "/( in the )(morn(ing)?)\\b/", thisMorning: "/(this )(morn(ing)?)\\b/", amThisMorning: "/(\b\\d(am)? )(this )(morn(ing)?)/", inTheEvening: "/( in the )(even(ing)?)\\b/", thisEvening: "/(this )(even(ing)?)\\b/", pmThisEvening: "/(\b\\d(pm)? )(this )(even(ing)?)/", jan: "/jan(uary)?/", feb: "/feb(ruary)?/", mar: "/mar(ch)?/", apr: "/apr(il)?/", may: "/may/", jun: "/jun(e)?/", jul: "/jul(y)?/", aug: "/aug(ust)?/", sep: "/sep(t(ember)?)?/", oct: "/oct(ober)?/", nov: "/nov(ember)?/", dec: "/dec(ember)?/", sun: "/^su(n(day)?)?/", mon: "/^mo(n(day)?)?/", tue: "/^tu(e(s(day)?)?)?/", wed: "/^we(d(nesday)?)?/", thu: "/^th(u(r(s(day)?)?)?)?/", fri: "/fr(i(day)?)?/", sat: "/^sa(t(urday)?)?/", future: "/^next/", past: "/^last|past|prev(ious)?/", add: "/^(\\+|aft(er)?|from|hence)/", subtract: "/^(\\-|bef(ore)?|ago)/", yesterday: "/^yes(terday)?/", today: "/^t(od(ay)?)?/", tomorrow: "/^tom(orrow)?/", now: "/^n(ow)?/", millisecond: "/^ms|milli(second)?s?/", second: "/^sec(ond)?s?/", minute: "/^mn|min(ute)?s?/", hour: "/^h(our)?s?/", week: "/^w(eek)?s?/", month: "/^m(onth)?s?/", day: "/^d(ay)?s?/", year: "/^y(ear)?s?/", shortMeridian: "/^(a|p)/", longMeridian: "/^(a\\.?m?\\.?|p\\.?m?\\.?)/", timezone: "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/", ordinalSuffix: "/^\\s*(st|nd|rd|th)/", timeContext: "/^\\s*(\\:|a(?!u|p)|p)/" }, Date.i18n.currentLanguage()); } }; var CultureInfo = function () { var info = getText.getFromObjectValues({ name: "name", englishName: "englishName", nativeName: "nativeName", amDesignator: "AM", pmDesignator: "PM", firstDayOfWeek: "firstDayOfWeek", twoDigitYearMax: "twoDigitYearMax", dateElementOrder: "mdy" }, Date.i18n.currentLanguage()); var constructedInfo = buildInfo.buildFromMethodHash({ dayNames: "days", abbreviatedDayNames: "dayAbbr", shortestDayNames: "dayShortNames", firstLetterDayNames: "dayFirstLetters", monthNames: "months", abbreviatedMonthNames: "monthAbbr", formatPatterns: "formatPatterns", regexPatterns: "regex", abbreviatedTimeZoneDST: "timeZoneDST", abbreviatedTimeZoneStandard: "timeZoneStandard" }); shallowMerge(info, constructedInfo); buildInfo.timeZones(info); return info; }; $D.i18n = { __: function (key, lang) { return __(key, lang); }, currentLanguage: function () { return lang || "en-US"; }, setLanguage: function (code, force, cb) { var async = false; if (force || code === "en-US" || (!!Date.CultureStrings && !!Date.CultureStrings[code])) { lang = code; Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings.lang = code; Date.CultureInfo = new CultureInfo(); } else { if (!(!!Date.CultureStrings && !!Date.CultureStrings[code])) { if (typeof exports !== "undefined" && this.exports !== exports) { // we're in a Node enviroment, load it using require try { require("../i18n/" + code + ".js"); lang = code; Date.CultureStrings.lang = code; Date.CultureInfo = new CultureInfo(); } catch (e) { // var str = "The language for '" + code + "' could not be loaded by Node. It likely does not exist."; throw new Error("The DateJS IETF language tag '" + code + "' could not be loaded by Node. It likely does not exist."); } } else if (Date.Config && Date.Config.i18n) { // we know the location of the files, so lets load them async = true; loadI18nScript(code).done(function(){ lang = code; Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings.lang = code; Date.CultureInfo = new CultureInfo(); $D.Parsing.Normalizer.buildReplaceData(); // because this is async if ($D.Grammar) { $D.Grammar.buildGrammarFormats(); // so we can parse those strings... } if (cb) { setTimeout(cb,0); } }); } else { Date.console.error("The DateJS IETF language tag '" + code + "' is not available and has not been loaded."); return false; } } } $D.Parsing.Normalizer.buildReplaceData(); // rebuild normalizer strings if ($D.Grammar) { $D.Grammar.buildGrammarFormats(); // so we can parse those strings... } if (!async && cb) { setTimeout(cb,0); } }, getLoggedKeys: function () { return loggedKeys; }, updateCultureInfo: function () { Date.CultureInfo = new CultureInfo(); } }; $D.i18n.updateCultureInfo(); // run automatically }()); (function () { var $D = Date, $P = $D.prototype, p = function (s, l) { if (!l) { l = 2; } return ("000" + s).slice(l * -1); }; if (typeof window !== "undefined" && typeof window.console !== "undefined" && typeof window.console.log !== "undefined") { $D.console = console; // used only to raise non-critical errors if available } else { // set mock so we don't give errors. $D.console = { log: function(){}, error: function(){} }; } $D.Config = $D.Config || {}; $D.initOverloads = function() { /** * Overload of Date.now. Allows an alternate call for Date.now where it returns the * current Date as an object rather than just milliseconds since the Unix Epoch. * * Also provides an implementation of now() for browsers (IE<9) that don't have it. * * Backwards compatible so with work with either: * Date.now() [returns ms] * or * Date.now(true) [returns Date] */ if (!$D.now) { $D._now = function now() { return new Date().getTime(); }; } else if (!$D._now) { $D._now = $D.now; } $D.now = function (returnObj) { if (returnObj) { return $D.present(); } else { return $D._now(); } }; if ( !$P.toISOString ) { $P.toISOString = function() { return this.getUTCFullYear() + "-" + p(this.getUTCMonth() + 1) + "-" + p(this.getUTCDate()) + "T" + p(this.getUTCHours()) + ":" + p(this.getUTCMinutes()) + ":" + p(this.getUTCSeconds()) + "." + String( (this.getUTCMilliseconds()/1000).toFixed(3)).slice(2, 5) + "Z"; }; } // private if ( $P._toString === undefined ){ $P._toString = $P.toString; } }; $D.initOverloads(); /** * Gets a date that is set to the current date. The time is set to the start of the day (00:00 or 12:00 AM). * @return {Date} The current date. */ $D.today = function () { return new Date().clearTime(); }; /** * Gets a date that is set to the current date and time (same as new Date, but chainable) * @return {Date} The current date. */ $D.present = function () { return new Date(); }; /** * Compares the first date to the second date and returns an number indication of their relative values. * @param {Date} First Date object to compare [Required]. * @param {Date} Second Date object to compare to [Required]. * @return {Number} -1 = date1 is lessthan date2. 0 = values are equal. 1 = date1 is greaterthan date2. */ $D.compare = function (date1, date2) { if (isNaN(date1) || isNaN(date2)) { throw new Error(date1 + " - " + date2); } else if (date1 instanceof Date && date2 instanceof Date) { return (date1 < date2) ? -1 : (date1 > date2) ? 1 : 0; } else { throw new TypeError(date1 + " - " + date2); } }; /** * Compares the first Date object to the second Date object and returns true if they are equal. * @param {Date} First Date object to compare [Required] * @param {Date} Second Date object to compare to [Required] * @return {Boolean} true if dates are equal. false if they are not equal. */ $D.equals = function (date1, date2) { return (date1.compareTo(date2) === 0); }; /** * Gets the language appropriate day name when given the day number(0-6) * eg - 0 == Sunday * @return {String} The day name */ $D.getDayName = function (n) { return Date.CultureInfo.dayNames[n]; }; /** * Gets the day number (0-6) if given a CultureInfo specific string which is a valid dayName, abbreviatedDayName or shortestDayName (two char). * @param {String} The name of the day (eg. "Monday, "Mon", "tuesday", "tue", "We", "we"). * @return {Number} The day number */ $D.getDayNumberFromName = function (name) { var n = Date.CultureInfo.dayNames, m = Date.CultureInfo.abbreviatedDayNames, o = Date.CultureInfo.shortestDayNames, s = name.toLowerCase(); for (var i = 0; i < n.length; i++) { if (n[i].toLowerCase() === s || m[i].toLowerCase() === s || o[i].toLowerCase() === s) { return i; } } return -1; }; /** * Gets the month number (0-11) if given a Culture Info specific string which is a valid monthName or abbreviatedMonthName. * @param {String} The name of the month (eg. "February, "Feb", "october", "oct"). * @return {Number} The day number */ $D.getMonthNumberFromName = function (name) { var n = Date.CultureInfo.monthNames, m = Date.CultureInfo.abbreviatedMonthNames, s = name.toLowerCase(); for (var i = 0; i < n.length; i++) { if (n[i].toLowerCase() === s || m[i].toLowerCase() === s) { return i; } } return -1; }; /** * Gets the language appropriate month name when given the month number(0-11) * eg - 0 == January * @return {String} The month name */ $D.getMonthName = function (n) { return Date.CultureInfo.monthNames[n]; }; /** * Determines if the current date instance is within a LeapYear. * @param {Number} The year. * @return {Boolean} true if date is within a LeapYear, otherwise false. */ $D.isLeapYear = function (year) { return ((year % 4 === 0 && year % 100 !== 0) || year % 400 === 0); }; /** * Gets the number of days in the month, given a year and month value. Automatically corrects for LeapYear. * @param {Number} The year. * @param {Number} The month (0-11). * @return {Number} The number of days in the month. */ $D.getDaysInMonth = function (year, month) { if (!month && $D.validateMonth(year)) { month = year; year = Date.today().getFullYear(); } return [31, ($D.isLeapYear(year) ? 29 : 28), 31, 30, 31, 30, 31, 31, 30, 31, 30, 31][month]; }; $P.getDaysInMonth = function () { return $D.getDaysInMonth(this.getFullYear(), this.getMonth()); }; $D.getTimezoneAbbreviation = function (offset, dst) { var p, n = (dst || false) ? Date.CultureInfo.abbreviatedTimeZoneDST : Date.CultureInfo.abbreviatedTimeZoneStandard; for (p in n) { if (n.hasOwnProperty(p)) { if (n[p] === offset) { return p; } } } return null; }; $D.getTimezoneOffset = function (name, dst) { var i, a =[], z = Date.CultureInfo.timezones; if (!name) { name = (new Date()).getTimezone();} for (i = 0; i < z.length; i++) { if (z[i].name === name.toUpperCase()) { a.push(i); } } if (!z[a[0]]) { return null; } if (a.length === 1 || !dst) { return z[a[0]].offset; } else { for (i=0; i < a.length; i++) { if (z[a[i]].dst) { return z[a[i]].offset; } } } }; $D.getQuarter = function (d) { d = d || new Date(); // If no date supplied, use today var q = [1,2,3,4]; return q[Math.floor(d.getMonth() / 3)]; // ~~~ is a bitwise op. Faster than Math.floor }; $D.getDaysLeftInQuarter = function (d) { d = d || new Date(); var qEnd = new Date(d); qEnd.setMonth(qEnd.getMonth() + 3 - qEnd.getMonth() % 3, 0); return Math.floor((qEnd - d) / 8.64e7); }; // private var validate = function (n, min, max, name) { name = name ? name : "Object"; if (typeof n === "undefined") { return false; } else if (typeof n !== "number") { throw new TypeError(n + " is not a Number."); } else if (n < min || n > max) { // As failing validation is *not* an exceptional circumstance // lets not throw a RangeError Exception here. // It's semantically correct but it's not sensible. return false; } return true; }; /** * Validates the number is within an acceptable range for milliseconds [0-999]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateMillisecond = function (value) { return validate(value, 0, 999, "millisecond"); }; /** * Validates the number is within an acceptable range for seconds [0-59]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateSecond = function (value) { return validate(value, 0, 59, "second"); }; /** * Validates the number is within an acceptable range for minutes [0-59]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateMinute = function (value) { return validate(value, 0, 59, "minute"); }; /** * Validates the number is within an acceptable range for hours [0-23]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateHour = function (value) { return validate(value, 0, 23, "hour"); }; /** * Validates the number is within an acceptable range for the days in a month [0-MaxDaysInMonth]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateDay = function (value, year, month) { if (year === undefined || year === null || month === undefined || month === null) { return false;} return validate(value, 1, $D.getDaysInMonth(year, month), "day"); }; /** * Validates the number is within an acceptable range for months [0-11]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateWeek = function (value) { return validate(value, 0, 53, "week"); }; /** * Validates the number is within an acceptable range for months [0-11]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateMonth = function (value) { return validate(value, 0, 11, "month"); }; /** * Validates the number is within an acceptable range for years. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateYear = function (value) { /** * Per ECMAScript spec the range of times supported by Date objects is * exactly -100,000,000 days to +100,000,000 days measured relative to * midnight at the beginning of 01 January, 1970 UTC. * This gives a range of 8,640,000,000,000,000 milliseconds to either * side of 01 January, 1970 UTC. * * Earliest possible date: Tue, 20 Apr 271,822 B.C. 00:00:00 UTC * Latest possible date: Sat, 13 Sep 275,760 00:00:00 UTC */ return validate(value, -271822, 275760, "year"); }; $D.validateTimezone = function(value) { var timezones = {"ACDT":1,"ACST":1,"ACT":1,"ADT":1,"AEDT":1,"AEST":1,"AFT":1,"AKDT":1,"AKST":1,"AMST":1,"AMT":1,"ART":1,"AST":1,"AWDT":1,"AWST":1,"AZOST":1,"AZT":1,"BDT":1,"BIOT":1,"BIT":1,"BOT":1,"BRT":1,"BST":1,"BTT":1,"CAT":1,"CCT":1,"CDT":1,"CEDT":1,"CEST":1,"CET":1,"CHADT":1,"CHAST":1,"CHOT":1,"ChST":1,"CHUT":1,"CIST":1,"CIT":1,"CKT":1,"CLST":1,"CLT":1,"COST":1,"COT":1,"CST":1,"CT":1,"CVT":1,"CWST":1,"CXT":1,"DAVT":1,"DDUT":1,"DFT":1,"EASST":1,"EAST":1,"EAT":1,"ECT":1,"EDT":1,"EEDT":1,"EEST":1,"EET":1,"EGST":1,"EGT":1,"EIT":1,"EST":1,"FET":1,"FJT":1,"FKST":1,"FKT":1,"FNT":1,"GALT":1,"GAMT":1,"GET":1,"GFT":1,"GILT":1,"GIT":1,"GMT":1,"GST":1,"GYT":1,"HADT":1,"HAEC":1,"HAST":1,"HKT":1,"HMT":1,"HOVT":1,"HST":1,"ICT":1,"IDT":1,"IOT":1,"IRDT":1,"IRKT":1,"IRST":1,"IST":1,"JST":1,"KGT":1,"KOST":1,"KRAT":1,"KST":1,"LHST":1,"LINT":1,"MAGT":1,"MART":1,"MAWT":1,"MDT":1,"MET":1,"MEST":1,"MHT":1,"MIST":1,"MIT":1,"MMT":1,"MSK":1,"MST":1,"MUT":1,"MVT":1,"MYT":1,"NCT":1,"NDT":1,"NFT":1,"NPT":1,"NST":1,"NT":1,"NUT":1,"NZDT":1,"NZST":1,"OMST":1,"ORAT":1,"PDT":1,"PET":1,"PETT":1,"PGT":1,"PHOT":1,"PHT":1,"PKT":1,"PMDT":1,"PMST":1,"PONT":1,"PST":1,"PYST":1,"PYT":1,"RET":1,"ROTT":1,"SAKT":1,"SAMT":1,"SAST":1,"SBT":1,"SCT":1,"SGT":1,"SLST":1,"SRT":1,"SST":1,"SYOT":1,"TAHT":1,"THA":1,"TFT":1,"TJT":1,"TKT":1,"TLT":1,"TMT":1,"TOT":1,"TVT":1,"UCT":1,"ULAT":1,"UTC":1,"UYST":1,"UYT":1,"UZT":1,"VET":1,"VLAT":1,"VOLT":1,"VOST":1,"VUT":1,"WAKT":1,"WAST":1,"WAT":1,"WEDT":1,"WEST":1,"WET":1,"WST":1,"YAKT":1,"YEKT":1,"Z":1}; return (timezones[value] === 1); }; $D.validateTimezoneOffset= function(value) { // timezones go from +14hrs to -12hrs, the +X hours are negative offsets. return (value > -841 && value < 721); }; }()); (function () { var $D = Date, $P = $D.prototype, p = function (s, l) { if (!l) { l = 2; } return ("000" + s).slice(l * -1); }; var validateConfigObject = function (obj) { var result = {}, self = this, prop, testFunc; testFunc = function (prop, func, value) { if (prop === "day") { var month = (obj.month !== undefined) ? obj.month : self.getMonth(); var year = (obj.year !== undefined) ? obj.year : self.getFullYear(); return $D[func](value, year, month); } else { return $D[func](value); } }; for (prop in obj) { if (Object.prototype.hasOwnProperty.call(obj, prop)) { var func = "validate" + prop.charAt(0).toUpperCase() + prop.slice(1); if ($D[func] && obj[prop] !== null && testFunc(prop, func, obj[prop])) { result[prop] = obj[prop]; } } } return result; }; /** * Resets the time of this Date object to 12:00 AM (00:00), which is the start of the day. * @param {Boolean} .clone() this date instance before clearing Time * @return {Date} this */ $P.clearTime = function () { this.setHours(0); this.setMinutes(0); this.setSeconds(0); this.setMilliseconds(0); return this; }; /** * Resets the time of this Date object to the current time ('now'). * @return {Date} this */ $P.setTimeToNow = function () { var n = new Date(); this.setHours(n.getHours()); this.setMinutes(n.getMinutes()); this.setSeconds(n.getSeconds()); this.setMilliseconds(n.getMilliseconds()); return this; }; /** * Returns a new Date object that is an exact date and time copy of the original instance. * @return {Date} A new Date instance */ $P.clone = function () { return new Date(this.getTime()); }; /** * Compares this instance to a Date object and returns an number indication of their relative values. * @param {Date} Date object to compare [Required] * @return {Number} -1 = this is lessthan date. 0 = values are equal. 1 = this is greaterthan date. */ $P.compareTo = function (date) { return Date.compare(this, date); }; /** * Compares this instance to another Date object and returns true if they are equal. * @param {Date} Date object to compare. If no date to compare, new Date() [now] is used. * @return {Boolean} true if dates are equal. false if they are not equal. */ $P.equals = function (date) { return Date.equals(this, (date !== undefined ? date : new Date())); }; /** * Determines if this instance is between a range of two dates or equal to either the start or end dates. * @param {Date} Start of range [Required] * @param {Date} End of range [Required] * @return {Boolean} true is this is between or equal to the start and end dates, else false */ $P.between = function (start, end) { return this.getTime() >= start.getTime() && this.getTime() <= end.getTime(); }; /** * Determines if this date occurs after the date to compare to. * @param {Date} Date object to compare. If no date to compare, new Date() ("now") is used. * @return {Boolean} true if this date instance is greater than the date to compare to (or "now"), otherwise false. */ $P.isAfter = function (date) { return this.compareTo(date || new Date()) === 1; }; /** * Determines if this date occurs before the date to compare to. * @param {Date} Date object to compare. If no date to compare, new Date() ("now") is used. * @return {Boolean} true if this date instance is less than the date to compare to (or "now"). */ $P.isBefore = function (date) { return (this.compareTo(date || new Date()) === -1); }; /** * Determines if the current Date instance occurs today. * @return {Boolean} true if this date instance is 'today', otherwise false. */ /** * Determines if the current Date instance occurs on the same Date as the supplied 'date'. * If no 'date' to compare to is provided, the current Date instance is compared to 'today'. * @param {date} Date object to compare. If no date to compare, the current Date ("now") is used. * @return {Boolean} true if this Date instance occurs on the same Day as the supplied 'date'. */ $P.isToday = $P.isSameDay = function (date) { return this.clone().clearTime().equals((date || new Date()).clone().clearTime()); }; /** * Adds the specified number of milliseconds to this instance. * @param {Number} The number of milliseconds to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addMilliseconds = function (value) { if (!value) { return this; } this.setTime(this.getTime() + value * 1); return this; }; /** * Adds the specified number of seconds to this instance. * @param {Number} The number of seconds to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addSeconds = function (value) { if (!value) { return this; } return this.addMilliseconds(value * 1000); }; /** * Adds the specified number of seconds to this instance. * @param {Number} The number of seconds to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addMinutes = function (value) { if (!value) { return this; } return this.addMilliseconds(value * 60000); // 60*1000 }; /** * Adds the specified number of hours to this instance. * @param {Number} The number of hours to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addHours = function (value) { if (!value) { return this; } return this.addMilliseconds(value * 3600000); // 60*60*1000 }; /** * Adds the specified number of days to this instance. * @param {Number} The number of days to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addDays = function (value) { if (!value) { return this; } this.setDate(this.getDate() + value * 1); return this; }; /** * Adds the specified number of weekdays (ie - not sat or sun) to this instance. * @param {Number} The number of days to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addWeekdays = function (value) { if (!value) { return this; } var day = this.getDay(); var weeks = (Math.ceil(Math.abs(value)/7)); if (day === 0 || day === 6) { if (value > 0) { this.next().monday(); this.addDays(-1); day = this.getDay(); } } if (value < 0) { while (value < 0) { this.addDays(-1); day = this.getDay(); if (day !== 0 && day !== 6) { value++; } } return this; } else if (value > 5 || (6-day) <= value) { value = value + (weeks * 2); } return this.addDays(value); }; /** * Adds the specified number of weeks to this instance. * @param {Number} The number of weeks to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addWeeks = function (value) { if (!value) { return this; } return this.addDays(value * 7); }; /** * Adds the specified number of months to this instance. * @param {Number} The number of months to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addMonths = function (value) { if (!value) { return this; } var n = this.getDate(); this.setDate(1); this.setMonth(this.getMonth() + value * 1); this.setDate(Math.min(n, $D.getDaysInMonth(this.getFullYear(), this.getMonth()))); return this; }; $P.addQuarters = function (value) { if (!value) { return this; } // note this will take you to the same point in the quarter as you are now. // i.e. - if you are 15 days into the quarter you'll be 15 days into the resulting one. // bonus: this allows adding fractional quarters return this.addMonths(value * 3); }; /** * Adds the specified number of years to this instance. * @param {Number} The number of years to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addYears = function (value) { if (!value) { return this; } return this.addMonths(value * 12); }; /** * Adds (or subtracts) to the value of the years, months, weeks, days, hours, minutes, seconds, milliseconds of the date instance using given configuration object. Positive and Negative values allowed. * Example

	Date.today().add( { days: 1, months: 1 } )

	new Date().add( { years: -1 } )
	
* @param {Object} Configuration object containing attributes (months, days, etc.) * @return {Date} this */ $P.add = function (config) { if (typeof config === "number") { this._orient = config; return this; } var x = config; if (x.day) { // If we should be a different date than today (eg: for 'tomorrow -1d', etc). // Should only effect parsing, not direct usage (eg, Finish and FinishExact) if ((x.day - this.getDate()) !== 0) { this.setDate(x.day); } } if (x.milliseconds) { this.addMilliseconds(x.milliseconds); } if (x.seconds) { this.addSeconds(x.seconds); } if (x.minutes) { this.addMinutes(x.minutes); } if (x.hours) { this.addHours(x.hours); } if (x.weeks) { this.addWeeks(x.weeks); } if (x.months) { this.addMonths(x.months); } if (x.years) { this.addYears(x.years); } if (x.days) { this.addDays(x.days); } return this; }; /** * Get the week number. Week one (1) is the week which contains the first Thursday of the year. Monday is considered the first day of the week. * The .getWeek() function does NOT convert the date to UTC. The local datetime is used. * Please use .getISOWeek() to get the week of the UTC converted date. * @return {Number} 1 to 53 */ $P.getWeek = function (utc) { // Create a copy of this date object var self, target = new Date(this.valueOf()); if (utc) { target.addMinutes(target.getTimezoneOffset()); self = target.clone(); } else { self = this; } // ISO week date weeks start on monday // so correct the day number var dayNr = (self.getDay() + 6) % 7; // ISO 8601 states that week 1 is the week // with the first thursday of that year. // Set the target date to the thursday in the target week target.setDate(target.getDate() - dayNr + 3); // Store the millisecond value of the target date var firstThursday = target.valueOf(); // Set the target to the first thursday of the year // First set the target to january first target.setMonth(0, 1); // Not a thursday? Correct the date to the next thursday if (target.getDay() !== 4) { target.setMonth(0, 1 + ((4 - target.getDay()) + 7) % 7); } // The weeknumber is the number of weeks between the // first thursday of the year and the thursday in the target week return 1 + Math.ceil((firstThursday - target) / 604800000); // 604800000 = 7 * 24 * 3600 * 1000 }; /** * Get the ISO 8601 week number. Week one ("01") is the week which contains the first Thursday of the year. Monday is considered the first day of the week. * The .getISOWeek() function does convert the date to it's UTC value. Please use .getWeek() to get the week of the local date. * @return {String} "01" to "53" */ $P.getISOWeek = function () { return p(this.getWeek(true)); }; /** * Moves the date to Monday of the week set. Week one (1) is the week which contains the first Thursday of the year. * @param {Number} A Number (1 to 53) that represents the week of the year. * @return {Date} this */ $P.setWeek = function (n) { if ((n - this.getWeek()) === 0) { if (this.getDay() !== 1) { return this.moveToDayOfWeek(1, (this.getDay() > 1 ? -1 : 1)); } else { return this; } } else { return this.moveToDayOfWeek(1, (this.getDay() > 1 ? -1 : 1)).addWeeks(n - this.getWeek()); } }; $P.setQuarter = function (qtr) { var month = Math.abs(((qtr-1) * 3) + 1); return this.setMonth(month, 1); }; $P.getQuarter = function () { return Date.getQuarter(this); }; $P.getDaysLeftInQuarter = function () { return Date.getDaysLeftInQuarter(this); }; /** * Moves the date to the next n'th occurrence of the dayOfWeek starting from the beginning of the month. The number (-1) is a magic number and will return the last occurrence of the dayOfWeek in the month. * @param {Number} The dayOfWeek to move to * @param {Number} The n'th occurrence to move to. Use (-1) to return the last occurrence in the month * @return {Date} this */ $P.moveToNthOccurrence = function (dayOfWeek, occurrence) { if (dayOfWeek === "Weekday") { if (occurrence > 0) { this.moveToFirstDayOfMonth(); if (this.is().weekday()) { occurrence -= 1; } } else if (occurrence < 0) { this.moveToLastDayOfMonth(); if (this.is().weekday()) { occurrence += 1; } } else { return this; } return this.addWeekdays(occurrence); } var shift = 0; if (occurrence > 0) { shift = occurrence - 1; } else if (occurrence === -1) { this.moveToLastDayOfMonth(); if (this.getDay() !== dayOfWeek) { this.moveToDayOfWeek(dayOfWeek, -1); } return this; } return this.moveToFirstDayOfMonth().addDays(-1).moveToDayOfWeek(dayOfWeek, +1).addWeeks(shift); }; var moveToN = function (getFunc, addFunc, nVal) { return function (value, orient) { var diff = (value - this[getFunc]() + nVal * (orient || +1)) % nVal; return this[addFunc]((diff === 0) ? diff += nVal * (orient || +1) : diff); }; }; /** * Move to the next or last dayOfWeek based on the orient value. * @param {Number} The dayOfWeek to move to * @param {Number} Forward (+1) or Back (-1). Defaults to +1. [Optional] * @return {Date} this */ $P.moveToDayOfWeek = moveToN("getDay", "addDays", 7); /** * Move to the next or last month based on the orient value. * @param {Number} The month to move to. 0 = January, 11 = December * @param {Number} Forward (+1) or Back (-1). Defaults to +1. [Optional] * @return {Date} this */ $P.moveToMonth = moveToN("getMonth", "addMonths", 12); /** * Get the Ordinate of the current day ("th", "st", "rd"). * @return {String} */ $P.getOrdinate = function () { var num = this.getDate(); return ord(num); }; /** * Get the Ordinal day (numeric day number) of the year, adjusted for leap year. * @return {Number} 1 through 365 (366 in leap years) */ $P.getOrdinalNumber = function () { return Math.ceil((this.clone().clearTime() - new Date(this.getFullYear(), 0, 1)) / 86400000) + 1; }; /** * Get the time zone abbreviation of the current date. * @return {String} The abbreviated time zone name (e.g. "EST") */ $P.getTimezone = function () { return $D.getTimezoneAbbreviation(this.getUTCOffset(), this.isDaylightSavingTime()); }; $P.setTimezoneOffset = function (offset) { var here = this.getTimezoneOffset(), there = Number(offset) * -6 / 10; return (there || there === 0) ? this.addMinutes(there - here) : this; }; $P.setTimezone = function (offset) { return this.setTimezoneOffset($D.getTimezoneOffset(offset)); }; /** * Indicates whether Daylight Saving Time is observed in the current time zone. * @return {Boolean} true|false */ $P.hasDaylightSavingTime = function () { return (Date.today().set({month: 0, day: 1}).getTimezoneOffset() !== Date.today().set({month: 6, day: 1}).getTimezoneOffset()); }; /** * Indicates whether this Date instance is within the Daylight Saving Time range for the current time zone. * @return {Boolean} true|false */ $P.isDaylightSavingTime = function () { return Date.today().set({month: 0, day: 1}).getTimezoneOffset() !== this.getTimezoneOffset(); }; /** * Get the offset from UTC of the current date. * @return {String} The 4-character offset string prefixed with + or - (e.g. "-0500") */ $P.getUTCOffset = function (offset) { var n = (offset || this.getTimezoneOffset()) * -10 / 6, r; if (n < 0) { r = (n - 10000).toString(); return r.charAt(0) + r.substr(2); } else { r = (n + 10000).toString(); return "+" + r.substr(1); } }; /** * Returns the number of milliseconds between this date and date. * @param {Date} Defaults to now * @return {Number} The diff in milliseconds */ $P.getElapsed = function (date) { return (date || new Date()) - this; }; /** * Set the value of year, month, day, hour, minute, second, millisecond of date instance using given configuration object. * Example

	Date.today().set( { day: 20, month: 1 } )

	new Date().set( { millisecond: 0 } )
	
* * @param {Object} Configuration object containing attributes (month, day, etc.) * @return {Date} this */ $P.set = function (config) { config = validateConfigObject.call(this, config); var key; for (key in config) { if (Object.prototype.hasOwnProperty.call(config, key)) { var name = key.charAt(0).toUpperCase() + key.slice(1); var addFunc, getFunc; if (key !== "week" && key !== "month" && key !== "timezone" && key !== "timezoneOffset") { name += "s"; } addFunc = "add" + name; getFunc = "get" + name; if (key === "month") { addFunc = addFunc + "s"; } else if (key === "year"){ getFunc = "getFullYear"; } if (key !== "day" && key !== "timezone" && key !== "timezoneOffset" && key !== "week" && key !== "hour") { this[addFunc](config[key] - this[getFunc]()); } else if ( key === "timezone"|| key === "timezoneOffset" || key === "week" || key === "hour") { this["set"+name](config[key]); } } } // day has to go last because you can't validate the day without first knowing the month if (config.day) { this.addDays(config.day - this.getDate()); } return this; }; /** * Moves the date to the first day of the month. * @return {Date} this */ $P.moveToFirstDayOfMonth = function () { return this.set({ day: 1 }); }; /** * Moves the date to the last day of the month. * @return {Date} this */ $P.moveToLastDayOfMonth = function () { return this.set({ day: $D.getDaysInMonth(this.getFullYear(), this.getMonth())}); }; /** * Converts the value of the current Date object to its equivalent string representation. * Format Specifiers * CUSTOM DATE AND TIME FORMAT STRINGS * Format Description Example * ------ --------------------------------------------------------------------------- ----------------------- * s The seconds of the minute between 0-59. "0" to "59" * ss The seconds of the minute with leading zero if required. "00" to "59" * * m The minute of the hour between 0-59. "0" or "59" * mm The minute of the hour with leading zero if required. "00" or "59" * * h The hour of the day between 1-12. "1" to "12" * hh The hour of the day with leading zero if required. "01" to "12" * * H The hour of the day between 0-23. "0" to "23" * HH The hour of the day with leading zero if required. "00" to "23" * * d The day of the month between 1 and 31. "1" to "31" * dd The day of the month with leading zero if required. "01" to "31" * ddd Abbreviated day name. Date.CultureInfo.abbreviatedDayNames. "Mon" to "Sun" * dddd The full day name. Date.CultureInfo.dayNames. "Monday" to "Sunday" * * M The month of the year between 1-12. "1" to "12" * MM The month of the year with leading zero if required. "01" to "12" * MMM Abbreviated month name. Date.CultureInfo.abbreviatedMonthNames. "Jan" to "Dec" * MMMM The full month name. Date.CultureInfo.monthNames. "January" to "December" * * yy The year as a two-digit number. "99" or "08" * yyyy The full four digit year. "1999" or "2008" * * t Displays the first character of the A.M./P.M. designator. "A" or "P" * Date.CultureInfo.amDesignator or Date.CultureInfo.pmDesignator * tt Displays the A.M./P.M. designator. "AM" or "PM" * Date.CultureInfo.amDesignator or Date.CultureInfo.pmDesignator * * S The ordinal suffix ("st, "nd", "rd" or "th") of the current day. "st, "nd", "rd" or "th" * * STANDARD DATE AND TIME FORMAT STRINGS * Format Description Example *------ --------------------------------------------------------------------------- ----------------------- * d The CultureInfo shortDate Format Pattern "M/d/yyyy" * D The CultureInfo longDate Format Pattern "dddd, MMMM dd, yyyy" * F The CultureInfo fullDateTime Format Pattern "dddd, MMMM dd, yyyy h:mm:ss tt" * m The CultureInfo monthDay Format Pattern "MMMM dd" * r The CultureInfo rfc1123 Format Pattern "ddd, dd MMM yyyy HH:mm:ss GMT" * s The CultureInfo sortableDateTime Format Pattern "yyyy-MM-ddTHH:mm:ss" * t The CultureInfo shortTime Format Pattern "h:mm tt" * T The CultureInfo longTime Format Pattern "h:mm:ss tt" * u The CultureInfo universalSortableDateTime Format Pattern "yyyy-MM-dd HH:mm:ssZ" * y The CultureInfo yearMonth Format Pattern "MMMM, yyyy" * * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @return {String} A string representation of the current Date object. */ var ord = function (n) { switch (n * 1) { case 1: case 21: case 31: return "st"; case 2: case 22: return "nd"; case 3: case 23: return "rd"; default: return "th"; } }; var parseStandardFormats = function (format) { var y, c = Date.CultureInfo.formatPatterns; switch (format) { case "d": return this.toString(c.shortDate); case "D": return this.toString(c.longDate); case "F": return this.toString(c.fullDateTime); case "m": return this.toString(c.monthDay); case "r": case "R": y = this.clone().addMinutes(this.getTimezoneOffset()); return y.toString(c.rfc1123) + " GMT"; case "s": return this.toString(c.sortableDateTime); case "t": return this.toString(c.shortTime); case "T": return this.toString(c.longTime); case "u": y = this.clone().addMinutes(this.getTimezoneOffset()); return y.toString(c.universalSortableDateTime); case "y": return this.toString(c.yearMonth); default: return false; } }; var parseFormatStringsClosure = function (context) { return function (m) { if (m.charAt(0) === "\\") { return m.replace("\\", ""); } switch (m) { case "hh": return p(context.getHours() < 13 ? (context.getHours() === 0 ? 12 : context.getHours()) : (context.getHours() - 12)); case "h": return context.getHours() < 13 ? (context.getHours() === 0 ? 12 : context.getHours()) : (context.getHours() - 12); case "HH": return p(context.getHours()); case "H": return context.getHours(); case "mm": return p(context.getMinutes()); case "m": return context.getMinutes(); case "ss": return p(context.getSeconds()); case "s": return context.getSeconds(); case "yyyy": return p(context.getFullYear(), 4); case "yy": return p(context.getFullYear()); case "y": return context.getFullYear(); case "E": case "dddd": return Date.CultureInfo.dayNames[context.getDay()]; case "ddd": return Date.CultureInfo.abbreviatedDayNames[context.getDay()]; case "dd": return p(context.getDate()); case "d": return context.getDate(); case "MMMM": return Date.CultureInfo.monthNames[context.getMonth()]; case "MMM": return Date.CultureInfo.abbreviatedMonthNames[context.getMonth()]; case "MM": return p((context.getMonth() + 1)); case "M": return context.getMonth() + 1; case "t": return context.getHours() < 12 ? Date.CultureInfo.amDesignator.substring(0, 1) : Date.CultureInfo.pmDesignator.substring(0, 1); case "tt": return context.getHours() < 12 ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator; case "S": return ord(context.getDate()); case "W": return context.getWeek(); case "WW": return context.getISOWeek(); case "Q": return "Q" + context.getQuarter(); case "q": return String(context.getQuarter()); case "z": return context.getTimezone(); case "Z": case "X": return Date.getTimezoneOffset(context.getTimezone()); case "ZZ": // Timezone offset in seconds return context.getTimezoneOffset() * -60; case "u": return context.getDay(); case "L": return ($D.isLeapYear(context.getFullYear())) ? 1 : 0; case "B": // Swatch Internet Time (.beats) return "@"+((context.getUTCSeconds() + (context.getUTCMinutes()*60) + ((context.getUTCHours()+1)*3600))/86.4); default: return m; } }; }; $P.toString = function (format, ignoreStandards) { // Standard Date and Time Format Strings. Formats pulled from CultureInfo file and // may vary by culture. if (!ignoreStandards && format && format.length === 1) { output = parseStandardFormats.call(this, format); if (output) { return output; } } var parseFormatStrings = parseFormatStringsClosure(this); return format ? format.replace(/((\\)?(dd?d?d?|MM?M?M?|yy?y?y?|hh?|HH?|mm?|ss?|tt?|S|q|Q|WW?W?W?)(?![^\[]*\]))/g, parseFormatStrings).replace(/\[|\]/g, "") : this._toString(); }; }()); /************************************************************* * SugarPak - Domain Specific Language - Syntactical Sugar * *************************************************************/ (function () { var $D = Date, $P = $D.prototype, $N = Number.prototype; // private $P._orient = +1; // private $P._nth = null; // private $P._is = false; // private $P._same = false; // private $P._isSecond = false; // private $N._dateElement = "days"; /** * Moves the date to the next instance of a date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.today().next().friday();
	Date.today().next().fri();
	Date.today().next().march();
	Date.today().next().mar();
	Date.today().next().week();
	
* * @return {Date} date */ $P.next = function () { this._move = true; this._orient = +1; return this; }; /** * Creates a new Date (Date.today()) and moves the date to the next instance of the date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.next().friday();
	Date.next().fri();
	Date.next().march();
	Date.next().mar();
	Date.next().week();
	
* * @return {Date} date */ $D.next = function () { return $D.today().next(); }; /** * Moves the date to the previous instance of a date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.today().last().friday();
	Date.today().last().fri();
	Date.today().last().march();
	Date.today().last().mar();
	Date.today().last().week();
	
* * @return {Date} date */ $P.last = $P.prev = $P.previous = function () { this._move = true; this._orient = -1; return this; }; /** * Creates a new Date (Date.today()) and moves the date to the previous instance of the date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.last().friday();
	Date.last().fri();
	Date.previous().march();
	Date.prev().mar();
	Date.last().week();
	
* * @return {Date} date */ $D.last = $D.prev = $D.previous = function () { return $D.today().last(); }; /** * Performs a equality check when followed by either a month name, day name or .weekday() function. * Example

	Date.today().is().friday(); // true|false
	Date.today().is().fri();
	Date.today().is().march();
	Date.today().is().mar();
	
* * @return {Boolean} true|false */ $P.is = function () { this._is = true; return this; }; /** * Determines if two date objects occur on/in exactly the same instance of the subsequent date part function. * The function .same() must be followed by a date part function (example: .day(), .month(), .year(), etc). * * An optional Date can be passed in the date part function. If now date is passed as a parameter, 'Now' is used. * * The following example demonstrates how to determine if two dates fall on the exact same day. * * Example

	var d1 = Date.today(); // today at 00:00
	var d2 = new Date();   // exactly now.

	// Do they occur on the same day?
	d1.same().day(d2); // true
	
	// Do they occur on the same hour?
	d1.same().hour(d2); // false, unless d2 hour is '00' (midnight).
	
	// What if it's the same day, but one year apart?
	var nextYear = Date.today().add(1).year();

	d1.same().day(nextYear); // false, because the dates must occur on the exact same day. 
	
* * Scenario: Determine if a given date occurs during some week period 2 months from now. * * Example

	var future = Date.today().add(2).months();
	return someDate.same().week(future); // true|false;
	
* * @return {Boolean} true|false */ $P.same = function () { this._same = true; this._isSecond = false; return this; }; /** * Determines if the current date/time occurs during Today. Must be preceded by the .is() function. * Example

	someDate.is().today();    // true|false
	new Date().is().today();  // true
	Date.today().is().today();// true
	Date.today().add(-1).day().is().today(); // false
	
* * @return {Boolean} true|false */ $P.today = function () { return this.same().day(); }; /** * Determines if the current date is a weekday. This function must be preceded by the .is() function. * Example

	Date.today().is().weekday(); // true|false
	
* * @return {Boolean} true|false */ $P.weekday = function () { if (this._nth) { return df("Weekday").call(this); } if (this._move) { return this.addWeekdays(this._orient); } if (this._is) { this._is = false; return (!this.is().sat() && !this.is().sun()); } return false; }; /** * Determines if the current date is on the weekend. This function must be preceded by the .is() function. * Example

	Date.today().is().weekend(); // true|false
	
* * @return {Boolean} true|false */ $P.weekend = function () { if (this._is) { this._is = false; return (this.is().sat() || this.is().sun()); } return false; }; /** * Sets the Time of the current Date instance. A string "6:15 pm" or config object {hour:18, minute:15} are accepted. * Example

	// Set time to 6:15pm with a String
	Date.today().at("6:15pm");

	// Set time to 6:15pm with a config object
	Date.today().at({hour:18, minute:15});
	
* * @return {Date} date */ $P.at = function (time) { return (typeof time === "string") ? $D.parse(this.toString("d") + " " + time) : this.set(time); }; /** * Creates a new Date() and adds this (Number) to the date based on the preceding date element function (eg. second|minute|hour|day|month|year). * Example

	// Undeclared Numbers must be wrapped with parentheses. Requirment of JavaScript.
	(3).days().fromNow();
	(6).months().fromNow();

	// Declared Number variables do not require parentheses. 
	var n = 6;
	n.months().fromNow();
	
* * @return {Date} A new Date instance */ $N.fromNow = $N.after = function (date) { var c = {}; c[this._dateElement] = this; return ((!date) ? new Date() : date.clone()).add(c); }; /** * Creates a new Date() and subtract this (Number) from the date based on the preceding date element function (eg. second|minute|hour|day|month|year). * Example

	// Undeclared Numbers must be wrapped with parentheses. Requirment of JavaScript.
	(3).days().ago();
	(6).months().ago();

	// Declared Number variables do not require parentheses. 
	var n = 6;
	n.months().ago();
	
* * @return {Date} A new Date instance */ $N.ago = $N.before = function (date) { var c = {}, s = (this._dateElement[this._dateElement.length-1] !== "s") ? this._dateElement + "s" : this._dateElement; c[s] = this * -1; return ((!date) ? new Date() : date.clone()).add(c); }; // Do NOT modify the following string tokens. These tokens are used to build dynamic functions. // All culture-specific strings can be found in the CultureInfo files. var dx = ("sunday monday tuesday wednesday thursday friday saturday").split(/\s/), mx = ("january february march april may june july august september october november december").split(/\s/), px = ("Millisecond Second Minute Hour Day Week Month Year Quarter Weekday").split(/\s/), pxf = ("Milliseconds Seconds Minutes Hours Date Week Month FullYear Quarter").split(/\s/), nth = ("final first second third fourth fifth").split(/\s/), de; /** * Returns an object literal of all the date parts. * Example

	var o = new Date().toObject();
	
	// { year: 2008, month: 4, week: 20, day: 13, hour: 18, minute: 9, second: 32, millisecond: 812 }
	
	// The object properties can be referenced directly from the object.
	
	alert(o.day);  // alerts "13"
	alert(o.year); // alerts "2008"
	
* * @return {Date} An object literal representing the original date object. */ $P.toObject = function () { var o = {}; for (var i = 0; i < px.length; i++) { if (this["get" + pxf[i]]) { o[px[i].toLowerCase()] = this["get" + pxf[i]](); } } return o; }; /** * Returns a date created from an object literal. Ignores the .week property if set in the config. * Example

	var o = new Date().toObject();
	
	return Date.fromObject(o); // will return the same date. 

	var o2 = {month: 1, day: 20, hour: 18}; // birthday party!
	Date.fromObject(o2);
	
* * @return {Date} An object literal representing the original date object. */ $D.fromObject = function(config) { config.week = null; return Date.today().set(config); }; // Create day name functions and abbreviated day name functions (eg. monday(), friday(), fri()). var df = function (n) { return function () { if (this._is) { this._is = false; return this.getDay() === n; } if (this._move) { this._move = null; } if (this._nth !== null) { // If the .second() function was called earlier, remove the _orient // from the date, and then continue. // This is required because 'second' can be used in two different context. // // Example // // Date.today().add(1).second(); // Date.march().second().monday(); // // Things get crazy with the following... // Date.march().add(1).second().second().monday(); // but it works!! // if (this._isSecond) { this.addSeconds(this._orient * -1); } // make sure we reset _isSecond this._isSecond = false; var ntemp = this._nth; this._nth = null; var temp = this.clone().moveToLastDayOfMonth(); this.moveToNthOccurrence(n, ntemp); if (this > temp) { throw new RangeError($D.getDayName(n) + " does not occur " + ntemp + " times in the month of " + $D.getMonthName(temp.getMonth()) + " " + temp.getFullYear() + "."); } return this; } return this.moveToDayOfWeek(n, this._orient); }; }; var sdf = function (n) { return function () { var t = $D.today(), shift = n - t.getDay(); if (n === 0 && Date.CultureInfo.firstDayOfWeek === 1 && t.getDay() !== 0) { shift = shift + 7; } return t.addDays(shift); }; }; // Create month name functions and abbreviated month name functions (eg. january(), march(), mar()). var month_instance_functions = function (n) { return function () { if (this._is) { this._is = false; return this.getMonth() === n; } return this.moveToMonth(n, this._orient); }; }; var month_static_functions = function (n) { return function () { return $D.today().set({ month: n, day: 1 }); }; }; var processTerms = function (names, staticFunc, instanceFunc) { for (var i = 0; i < names.length; i++) { // Create constant static Name variables. $D[names[i].toUpperCase()] = $D[names[i].toUpperCase().substring(0, 3)] = i; // Create Name functions. $D[names[i]] = $D[names[i].substring(0, 3)] = staticFunc(i); // Create Name instance functions. $P[names[i]] = $P[names[i].substring(0, 3)] = instanceFunc(i); } }; processTerms(dx, sdf, df); processTerms(mx, month_static_functions, month_instance_functions); // Create date element functions and plural date element functions used with Date (eg. day(), days(), months()). var ef = function (j) { return function () { // if the .second() function was called earlier, the _orient // has alread been added. Just return this and reset _isSecond. if (this._isSecond) { this._isSecond = false; return this; } if (this._same) { this._same = this._is = false; var o1 = this.toObject(), o2 = (arguments[0] || new Date()).toObject(), v = "", k = j.toLowerCase(); // the substr trick with -1 doesn't work in IE8 or less k = (k[k.length-1] === "s") ? k.substring(0,k.length-1) : k; for (var m = (px.length - 1); m > -1; m--) { v = px[m].toLowerCase(); if (o1[v] !== o2[v]) { return false; } if (k === v) { break; } } return true; } if (j.substring(j.length - 1) !== "s") { j += "s"; } if (this._move) { this._move = null; } return this["add" + j](this._orient); }; }; var nf = function (n) { return function () { this._dateElement = n; return this; }; }; for (var k = 0; k < px.length; k++) { de = px[k].toLowerCase(); if(de !== "weekday") { // Create date element functions and plural date element functions used with Date (eg. day(), days(), months()). $P[de] = $P[de + "s"] = ef(px[k]); // Create date element functions and plural date element functions used with Number (eg. day(), days(), months()). $N[de] = $N[de + "s"] = nf(de + "s"); } } $P._ss = ef("Second"); var nthfn = function (n) { return function (dayOfWeek) { if (this._same) { return this._ss(arguments[0]); } if (dayOfWeek || dayOfWeek === 0) { return this.moveToNthOccurrence(dayOfWeek, n); } this._nth = n; // if the operator is 'second' add the _orient, then deal with it later... if (n === 2 && (dayOfWeek === undefined || dayOfWeek === null)) { this._isSecond = true; return this.addSeconds(this._orient); } return this; }; }; for (var l = 0; l < nth.length; l++) { $P[nth[l]] = (l === 0) ? nthfn(-1) : nthfn(l); } }()); (function () { "use strict"; Date.Parsing = { Exception: function (s) { this.message = "Parse error at '" + s.substring(0, 10) + " ...'"; } }; var $P = Date.Parsing; var dayOffsets = { standard: [0,31,59,90,120,151,181,212,243,273,304,334], leap: [0,31,60,91,121,152,182,213,244,274,305,335] }; $P.isLeapYear = function(year) { return ((year % 4 === 0) && (year % 100 !== 0)) || (year % 400 === 0); }; var utils = { multiReplace : function (str, hash ) { var key; for (key in hash) { if (Object.prototype.hasOwnProperty.call(hash, key)) { var regex; if (typeof hash[key] === "function") { } else { regex = (hash[key] instanceof RegExp) ? hash[key] : new RegExp(hash[key], "g"); } str = str.replace(regex, key); } } return str; }, getDayOfYearFromWeek : function (obj) { var d, jan4, offset; obj.weekDay = (!obj.weekDay && obj.weekDay !== 0) ? 1 : obj.weekDay; d = new Date(obj.year, 0, 4); jan4 = d.getDay() === 0 ? 7 : d.getDay(); // JS is 0 indexed on Sunday. offset = jan4+3; obj.dayOfYear = ((obj.week * 7) + (obj.weekDay === 0 ? 7 : obj.weekDay))-offset; return obj; }, getDayOfYear : function (obj, dayOffset) { if (!obj.dayOfYear) { obj = utils.getDayOfYearFromWeek(obj); } for (var i=0;i <= dayOffset.length;i++) { if (obj.dayOfYear < dayOffset[i] || i === dayOffset.length) { obj.day = obj.day ? obj.day : (obj.dayOfYear - dayOffset[i-1]); break; } else { obj.month = i; } } return obj; }, adjustForTimeZone : function (obj, date) { var offset; if (obj.zone.toUpperCase() === "Z" || (obj.zone_hours === 0 && obj.zone_minutes === 0)) { // it's UTC/GML so work out the current timeszone offset offset = -date.getTimezoneOffset(); } else { offset = (obj.zone_hours*60) + (obj.zone_minutes || 0); if (obj.zone_sign === "+") { offset *= -1; } offset -= date.getTimezoneOffset(); } date.setMinutes(date.getMinutes()+offset); return date; }, setDefaults : function (obj) { obj.year = obj.year || Date.today().getFullYear(); obj.hours = obj.hours || 0; obj.minutes = obj.minutes || 0; obj.seconds = obj.seconds || 0; obj.milliseconds = obj.milliseconds || 0; if (!(!obj.month && (obj.week || obj.dayOfYear))) { // if we have a month, or if we don't but don't have the day calculation data obj.month = obj.month || 0; obj.day = obj.day || 1; } return obj; }, dataNum: function (data, mod, explict, postProcess) { var dataNum = data*1; if (mod) { if (postProcess) { return data ? mod(data)*1 : data; } else { return data ? mod(dataNum) : data; } } else if (!explict){ return data ? dataNum : data; } else { return (data && typeof data !== "undefined") ? dataNum : data; } }, timeDataProcess: function (obj) { var timeObj = {}; for (var x in obj.data) { if (obj.data.hasOwnProperty(x)) { timeObj[x] = obj.ignore[x] ? obj.data[x] : utils.dataNum(obj.data[x], obj.mods[x], obj.explict[x], obj.postProcess[x]); } } if (obj.data.secmins) { obj.data.secmins = obj.data.secmins.replace(",", ".") * 60; if (!timeObj.minutes) { timeObj.minutes = obj.data.secmins; } else if (!timeObj.seconds) { timeObj.seconds = obj.data.secmins; } delete obj.secmins; } return timeObj; }, buildTimeObjectFromData: function (data) { var time = utils.timeDataProcess({ data: { year : data[1], month : data[5], day : data[7], week : data[8], dayOfYear : data[10], hours : data[15], zone_hours : data[23], zone_minutes : data[24], zone : data[21], zone_sign : data[22], weekDay : data[9], minutes: data[16], seconds: data[19], milliseconds: data[20], secmins: data[18] }, mods: { month: function(data) { return data-1; }, weekDay: function (data) { data = Math.abs(data); return (data === 7 ? 0 : data); }, minutes: function (data) { return data.replace(":",""); }, seconds: function (data) { return Math.floor( (data.replace(":","").replace(",","."))*1 ); }, milliseconds: function (data) { return (data.replace(",",".")*1000); } }, postProcess: { minutes: true, seconds: true, milliseconds: true }, explict: { zone_hours: true, zone_minutes: true }, ignore: { zone: true, zone_sign: true, secmins: true } }); return time; }, addToHash: function (hash, keys, data) { keys = keys; data = data; var len = keys.length; for (var i = 0; i < len; i++) { hash[keys[i]] = data[i]; } return hash; }, combineRegex: function (r1, r2) { return new RegExp("(("+r1.source+")\\s("+r2.source+"))"); }, getDateNthString: function(add, last, inc){ if (add) { return Date.today().addDays(inc).toString("d"); } else if (last) { return Date.today().last()[inc]().toString("d"); } }, buildRegexData: function (array) { var arr = []; var len = array.length; for (var i=0; i < len; i++) { if (Object.prototype.toString.call(array[i]) === '[object Array]') { // oldIE compat version of Array.isArray arr.push(this.combineRegex(array[i][0], array[i][1])); } else { arr.push(array[i]); } } return arr; } }; $P.processTimeObject = function (obj) { var date, dayOffset; utils.setDefaults(obj); dayOffset = ($P.isLeapYear(obj.year)) ? dayOffsets.leap : dayOffsets.standard; if (!obj.month && (obj.week || obj.dayOfYear)) { utils.getDayOfYear(obj, dayOffset); } else { obj.dayOfYear = dayOffset[obj.month] + obj.day; } date = new Date(obj.year, obj.month, obj.day, obj.hours, obj.minutes, obj.seconds, obj.milliseconds); if (obj.zone) { utils.adjustForTimeZone(obj, date); // adjust (and calculate) for timezone } return date; }; $P.ISO = { regex : /^([\+-]?\d{4}(?!\d{2}\b))((-?)((0[1-9]|1[0-2])(\3([12]\d|0[1-9]|3[01]))?|W([0-4]\d|5[0-3])(-?[1-7])?|(00[1-9]|0[1-9]\d|[12]\d{2}|3([0-5]\d|6[1-6])))([T\s]((([01]\d|2[0-4])((:?)[0-5]\d)?|24\:?00)([\.,]\d+(?!:))?)?(\17[0-5]\d([\.,]\d+)?)?\s?([zZ]|([\+-])([01]\d|2[0-3]):?([0-5]\d)?)?)?)?$/, parse : function (s) { var time, data = s.match(this.regex); if (!data || !data.length) { return null; } time = utils.buildTimeObjectFromData(data); if (!time.year || (!time.year && (!time.month && !time.day) && (!time.week && !time.dayOfYear)) ) { return null; } return $P.processTimeObject(time); } }; $P.Numeric = { isNumeric: function (e){return!isNaN(parseFloat(e))&&isFinite(e);}, regex: /\b([0-1]?[0-9])([0-3]?[0-9])([0-2]?[0-9]?[0-9][0-9])\b/i, parse: function (s) { var data, i, time = {}, order = Date.CultureInfo.dateElementOrder.split(""); if (!(this.isNumeric(s)) || // if it's non-numeric OR (s[0] === "+" && s[0] === "-")) { // It's an arithmatic string (eg +/-1000) return null; } if (s.length < 5 && s.indexOf(".") < 0 && s.indexOf("/") < 0) { // assume it's just a year. time.year = s; return $P.processTimeObject(time); } data = s.match(this.regex); if (!data || !data.length) { return null; } for (i=0; i < order.length; i++) { switch(order[i]) { case "d": time.day = data[i+1]; break; case "m": time.month = (data[i+1]-1); break; case "y": time.year = data[i+1]; break; } } return $P.processTimeObject(time); } }; $P.Normalizer = { regexData: function () { var $R = Date.CultureInfo.regexPatterns; return utils.buildRegexData([ $R.tomorrow, $R.yesterday, [$R.past, $R.mon], [$R.past, $R.tue], [$R.past, $R.wed], [$R.past, $R.thu], [$R.past, $R.fri], [$R.past, $R.sat], [$R.past, $R.sun] ]); }, basicReplaceHash : function() { var $R = Date.CultureInfo.regexPatterns; return { "January": $R.jan.source, "February": $R.feb, "March": $R.mar, "April": $R.apr, "May": $R.may, "June": $R.jun, "July": $R.jul, "August": $R.aug, "September": $R.sep, "October": $R.oct, "November": $R.nov, "December": $R.dec, "": /\bat\b/gi, " ": /\s{2,}/, "am": $R.inTheMorning, "9am": $R.thisMorning, "pm": $R.inTheEvening, "7pm":$R.thisEvening }; }, keys : function(){ return [ utils.getDateNthString(true, false, 1), // tomorrow utils.getDateNthString(true, false, -1), // yesterday utils.getDateNthString(false, true, "monday"), //last mon utils.getDateNthString(false, true, "tuesday"), //last tues utils.getDateNthString(false, true, "wednesday"), //last wed utils.getDateNthString(false, true, "thursday"), //last thurs utils.getDateNthString(false, true, "friday"), //last fri utils.getDateNthString(false, true, "saturday"), //last sat utils.getDateNthString(false, true, "sunday") //last sun ]; }, buildRegexFunctions: function () { var $R = Date.CultureInfo.regexPatterns; var __ = Date.i18n.__; var tomorrowRE = new RegExp("(\\b\\d\\d?("+__("AM")+"|"+__("PM")+")? )("+$R.tomorrow.source.slice(1)+")", "i"); // adapted tomorrow regex for AM PM relative dates var todayRE = new RegExp($R.today.source + "(?!\\s*([+-]))\\b"); // today, but excludes the math operators (eg "today + 2h") this.replaceFuncs = [ [todayRE, function (full) { return (full.length > 1) ? Date.today().toString("d") : full; }], [tomorrowRE, function(full, m1) { var t = Date.today().addDays(1).toString("d"); return (t + " " + m1); }], [$R.amThisMorning, function(str, am){return am;}], [$R.pmThisEvening, function(str, pm){return pm;}] ]; }, buildReplaceData: function () { this.buildRegexFunctions(); this.replaceHash = utils.addToHash(this.basicReplaceHash(), this.keys(), this.regexData()); }, stringReplaceFuncs: function (s) { for (var i=0; i < this.replaceFuncs.length; i++) { s = s.replace(this.replaceFuncs[i][0], this.replaceFuncs[i][1]); } return s; }, parse: function (s) { s = this.stringReplaceFuncs(s); s = utils.multiReplace(s, this.replaceHash); try { var n = s.split(/([\s\-\.\,\/\x27]+)/); if (n.length === 3 && $P.Numeric.isNumeric(n[0]) && $P.Numeric.isNumeric(n[2]) && (n[2].length >= 4)) { // ok, so we're dealing with x/year. But that's not a full date. // This fixes wonky dateElementOrder parsing when set to dmy order. if (Date.CultureInfo.dateElementOrder[0] === "d") { s = "1/" + n[0] + "/" + n[2]; // set to 1st of month and normalize the seperator } } } catch (e) {} return s; } }; $P.Normalizer.buildReplaceData(); }()); (function () { var $P = Date.Parsing; var _ = $P.Operators = { // // Tokenizers // rtoken: function (r) { // regex token return function (s) { var mx = s.match(r); if (mx) { return ([ mx[0], s.substring(mx[0].length) ]); } else { throw new $P.Exception(s); } }; }, token: function () { // whitespace-eating token return function (s) { return _.rtoken(new RegExp("^\\s*" + s + "\\s*"))(s); }; }, stoken: function (s) { // string token return _.rtoken(new RegExp("^" + s)); }, // Atomic Operators until: function (p) { return function (s) { var qx = [], rx = null; while (s.length) { try { rx = p.call(this, s); } catch (e) { qx.push(rx[0]); s = rx[1]; continue; } break; } return [ qx, s ]; }; }, many: function (p) { return function (s) { var rx = [], r = null; while (s.length) { try { r = p.call(this, s); } catch (e) { return [ rx, s ]; } rx.push(r[0]); s = r[1]; } return [ rx, s ]; }; }, // generator operators -- see below optional: function (p) { return function (s) { var r = null; try { r = p.call(this, s); } catch (e) { return [ null, s ]; } return [ r[0], r[1] ]; }; }, not: function (p) { return function (s) { try { p.call(this, s); } catch (e) { return [null, s]; } throw new $P.Exception(s); }; }, ignore: function (p) { return p ? function (s) { var r = null; r = p.call(this, s); return [null, r[1]]; } : null; }, product: function () { var px = arguments[0], qx = Array.prototype.slice.call(arguments, 1), rx = []; for (var i = 0 ; i < px.length ; i++) { rx.push(_.each(px[i], qx)); } return rx; }, cache: function (rule) { var cache = {}, cache_length = 0, cache_keys = [], CACHE_MAX = Date.Config.CACHE_MAX || 100000, r = null; var cacheCheck = function () { if (cache_length === CACHE_MAX) { // kill several keys, don't want to have to do this all the time... for (var i=0; i < 10; i++) { var key = cache_keys.shift(); if (key) { delete cache[key]; cache_length--; } } } }; return function (s) { cacheCheck(); try { r = cache[s] = (cache[s] || rule.call(this, s)); } catch (e) { r = cache[s] = e; } cache_length++; cache_keys.push(s); if (r instanceof $P.Exception) { throw r; } else { return r; } }; }, // vector operators -- see below any: function () { var px = arguments; return function (s) { var r = null; for (var i = 0; i < px.length; i++) { if (px[i] == null) { continue; } try { r = (px[i].call(this, s)); } catch (e) { r = null; } if (r) { return r; } } throw new $P.Exception(s); }; }, each: function () { var px = arguments; return function (s) { var rx = [], r = null; for (var i = 0; i < px.length ; i++) { if (px[i] == null) { continue; } try { r = (px[i].call(this, s)); } catch (e) { throw new $P.Exception(s); } rx.push(r[0]); s = r[1]; } return [ rx, s]; }; }, all: function () { var px = arguments, _ = _; return _.each(_.optional(px)); }, // delimited operators sequence: function (px, d, c) { d = d || _.rtoken(/^\s*/); c = c || null; if (px.length === 1) { return px[0]; } return function (s) { var r = null, q = null; var rx = []; for (var i = 0; i < px.length ; i++) { try { r = px[i].call(this, s); } catch (e) { break; } rx.push(r[0]); try { q = d.call(this, r[1]); } catch (ex) { q = null; break; } s = q[1]; } if (!r) { throw new $P.Exception(s); } if (q) { throw new $P.Exception(q[1]); } if (c) { try { r = c.call(this, r[1]); } catch (ey) { throw new $P.Exception(r[1]); } } return [ rx, (r?r[1]:s) ]; }; }, // // Composite Operators // between: function (d1, p, d2) { d2 = d2 || d1; var _fn = _.each(_.ignore(d1), p, _.ignore(d2)); return function (s) { var rx = _fn.call(this, s); return [[rx[0][0], r[0][2]], rx[1]]; }; }, list: function (p, d, c) { d = d || _.rtoken(/^\s*/); c = c || null; return (p instanceof Array ? _.each(_.product(p.slice(0, -1), _.ignore(d)), p.slice(-1), _.ignore(c)) : _.each(_.many(_.each(p, _.ignore(d))), px, _.ignore(c))); }, set: function (px, d, c) { d = d || _.rtoken(/^\s*/); c = c || null; return function (s) { // r is the current match, best the current 'best' match // which means it parsed the most amount of input var r = null, p = null, q = null, rx = null, best = [[], s], last = false; // go through the rules in the given set for (var i = 0; i < px.length ; i++) { // last is a flag indicating whether this must be the last element // if there is only 1 element, then it MUST be the last one q = null; p = null; r = null; last = (px.length === 1); // first, we try simply to match the current pattern // if not, try the next pattern try { r = px[i].call(this, s); } catch (e) { continue; } // since we are matching against a set of elements, the first // thing to do is to add r[0] to matched elements rx = [[r[0]], r[1]]; // if we matched and there is still input to parse and // we don't already know this is the last element, // we're going to next check for the delimiter ... // if there's none, or if there's no input left to parse // than this must be the last element after all ... if (r[1].length > 0 && ! last) { try { q = d.call(this, r[1]); } catch (ex) { last = true; } } else { last = true; } // if we parsed the delimiter and now there's no more input, // that means we shouldn't have parsed the delimiter at all // so don't update r and mark this as the last element ... if (!last && q[1].length === 0) { last = true; } // so, if this isn't the last element, we're going to see if // we can get any more matches from the remaining (unmatched) // elements ... if (!last) { // build a list of the remaining rules we can match against, // i.e., all but the one we just matched against var qx = []; for (var j = 0; j < px.length ; j++) { if (i !== j) { qx.push(px[j]); } } // now invoke recursively set with the remaining input // note that we don't include the closing delimiter ... // we'll check for that ourselves at the end p = _.set(qx, d).call(this, q[1]); // if we got a non-empty set as a result ... // (otw rx already contains everything we want to match) if (p[0].length > 0) { // update current result, which is stored in rx ... // basically, pick up the remaining text from p[1] // and concat the result from p[0] so that we don't // get endless nesting ... rx[0] = rx[0].concat(p[0]); rx[1] = p[1]; } } // at this point, rx either contains the last matched element // or the entire matched set that starts with this element. // now we just check to see if this variation is better than // our best so far, in terms of how much of the input is parsed if (rx[1].length < best[1].length) { best = rx; } // if we've parsed all the input, then we're finished if (best[1].length === 0) { break; } } // so now we've either gone through all the patterns trying them // as the initial match; or we found one that parsed the entire // input string ... // if best has no matches, just return empty set ... if (best[0].length === 0) { return best; } // if a closing delimiter is provided, then we have to check it also if (c) { // we try this even if there is no remaining input because the pattern // may well be optional or match empty input ... try { q = c.call(this, best[1]); } catch (ey) { throw new $P.Exception(best[1]); } // it parsed ... be sure to update the best match remaining input best[1] = q[1]; } // if we're here, either there was no closing delimiter or we parsed it // so now we have the best match; just return it! return best; }; }, forward: function (gr, fname) { return function (s) { return gr[fname].call(this, s); }; }, // // Translation Operators // replace: function (rule, repl) { return function (s) { var r = rule.call(this, s); return [repl, r[1]]; }; }, process: function (rule, fn) { return function (s) { var r = rule.call(this, s); return [fn.call(this, r[0]), r[1]]; }; }, min: function (min, rule) { return function (s) { var rx = rule.call(this, s); if (rx[0].length < min) { throw new $P.Exception(s); } return rx; }; } }; // Generator Operators And Vector Operators // Generators are operators that have a signature of F(R) => R, // taking a given rule and returning another rule, such as // ignore, which parses a given rule and throws away the result. // Vector operators are those that have a signature of F(R1,R2,...) => R, // take a list of rules and returning a new rule, such as each. // Generator operators are converted (via the following _generator // function) into functions that can also take a list or array of rules // and return an array of new rules as though the function had been // called on each rule in turn (which is what actually happens). // This allows generators to be used with vector operators more easily. // Example: // each(ignore(foo, bar)) instead of each(ignore(foo), ignore(bar)) // This also turns generators into vector operators, which allows // constructs like: // not(cache(foo, bar)) var _generator = function (op) { function gen() { var args = null, rx = [], px, i; if (arguments.length > 1) { args = Array.prototype.slice.call(arguments); } else if (arguments[0] instanceof Array) { args = arguments[0]; } if (args) { px = args.shift(); if (px.length > 0) { args.unshift(px[i]); rx.push(op.apply(null, args)); args.shift(); return rx; } } else { return op.apply(null, arguments); } } return gen; }; var gx = "optional not ignore cache".split(/\s/); for (var i = 0 ; i < gx.length ; i++) { _[gx[i]] = _generator(_[gx[i]]); } var _vector = function (op) { return function () { if (arguments[0] instanceof Array) { return op.apply(null, arguments[0]); } else { return op.apply(null, arguments); } }; }; var vx = "each any all".split(/\s/); for (var j = 0 ; j < vx.length ; j++) { _[vx[j]] = _vector(_[vx[j]]); } }()); (function () { var $D = Date; var flattenAndCompact = function (ax) { var rx = []; for (var i = 0; i < ax.length; i++) { if (ax[i] instanceof Array) { rx = rx.concat(flattenAndCompact(ax[i])); } else { if (ax[i]) { rx.push(ax[i]); } } } return rx; }; var parseMeridian = function () { if (this.meridian && (this.hour || this.hour === 0)) { if (this.meridian === "a" && this.hour > 11 && Date.Config.strict24hr){ throw "Invalid hour and meridian combination"; } else if (this.meridian === "p" && this.hour < 12 && Date.Config.strict24hr){ throw "Invalid hour and meridian combination"; } else if (this.meridian === "p" && this.hour < 12) { this.hour = this.hour + 12; } else if (this.meridian === "a" && this.hour === 12) { this.hour = 0; } } }; var setDefaults = function () { var now = new Date(); if ((this.hour || this.minute) && (!this.month && !this.year && !this.day)) { this.day = now.getDate(); } if (!this.year) { this.year = now.getFullYear(); } if (!this.month && this.month !== 0) { this.month = now.getMonth(); } if (!this.day) { this.day = 1; } if (!this.hour) { this.hour = 0; } if (!this.minute) { this.minute = 0; } if (!this.second) { this.second = 0; } if (!this.millisecond) { this.millisecond = 0; } }; var finishUtils = { getToday: function () { if (this.now || "hour minute second".indexOf(this.unit) !== -1) { return new Date(); } else { return $D.today(); } }, setDaysFromWeekday: function (today, orient){ var gap; orient = orient || 1; this.unit = "day"; gap = ($D.getDayNumberFromName(this.weekday) - today.getDay()); this.days = gap ? ((gap + (orient * 7)) % 7) : (orient * 7); return this; }, setMonthsFromMonth: function (today, orient) { var gap; orient = orient || 1; this.unit = "month"; gap = (this.month - today.getMonth()); this.months = gap ? ((gap + (orient * 12)) % 12) : (orient * 12); this.month = null; return this; }, setDMYFromWeekday: function () { var d = Date[this.weekday](); this.day = d.getDate(); if (!this.month) { this.month = d.getMonth(); } this.year = d.getFullYear(); return this; }, setUnitValue: function (orient) { if (!this.value && this.operator && this.operator !== null && this[this.unit + "s"] && this[this.unit + "s"] !== null) { this[this.unit + "s"] = this[this.unit + "s"] + ((this.operator === "add") ? 1 : -1) + (this.value||0) * orient; } else if (this[this.unit + "s"] == null || this.operator != null) { if (!this.value) { this.value = 1; } this[this.unit + "s"] = this.value * orient; } }, generateDateFromWeeks: function () { var weekday = (this.weekday !== undefined) ? this.weekday : "today"; var d = Date[weekday]().addWeeks(this.weeks); if (this.now) { d.setTimeToNow(); } return d; } }; $D.Translator = { hour: function (s) { return function () { this.hour = Number(s); }; }, minute: function (s) { return function () { this.minute = Number(s); }; }, second: function (s) { return function () { this.second = Number(s); }; }, /* for ss.s format */ secondAndMillisecond: function (s) { return function () { var mx = s.match(/^([0-5][0-9])\.([0-9]{1,3})/); this.second = Number(mx[1]); this.millisecond = Number(mx[2]); }; }, meridian: function (s) { return function () { this.meridian = s.slice(0, 1).toLowerCase(); }; }, timezone: function (s) { return function () { var n = s.replace(/[^\d\+\-]/g, ""); if (n.length) { this.timezoneOffset = Number(n); } else { this.timezone = s.toLowerCase(); } }; }, day: function (x) { var s = x[0]; return function () { this.day = Number(s.match(/\d+/)[0]); if (this.day < 1) { throw "invalid day"; } }; }, month: function (s) { return function () { this.month = (s.length === 3) ? "jan feb mar apr may jun jul aug sep oct nov dec".indexOf(s)/4 : Number(s) - 1; if (this.month < 0) { throw "invalid month"; } }; }, year: function (s) { return function () { var n = Number(s); this.year = ((s.length > 2) ? n : (n + (((n + 2000) < Date.CultureInfo.twoDigitYearMax) ? 2000 : 1900))); }; }, rday: function (s) { return function () { switch (s) { case "yesterday": this.days = -1; break; case "tomorrow": this.days = 1; break; case "today": this.days = 0; break; case "now": this.days = 0; this.now = true; break; } }; }, finishExact: function (x) { var d; x = (x instanceof Array) ? x : [x]; for (var i = 0 ; i < x.length ; i++) { if (x[i]) { x[i].call(this); } } setDefaults.call(this); parseMeridian.call(this); if (this.day > $D.getDaysInMonth(this.year, this.month)) { throw new RangeError(this.day + " is not a valid value for days."); } d = new Date(this.year, this.month, this.day, this.hour, this.minute, this.second, this.millisecond); if (this.year < 100) { d.setFullYear(this.year); // means years less that 100 are process correctly. JS will parse it otherwise as 1900-1999. } if (this.timezone) { d.set({ timezone: this.timezone }); } else if (this.timezoneOffset) { d.set({ timezoneOffset: this.timezoneOffset }); } return d; }, finish: function (x) { var today, expression, orient, temp; x = (x instanceof Array) ? flattenAndCompact(x) : [ x ]; if (x.length === 0) { return null; } for (var i = 0 ; i < x.length ; i++) { if (typeof x[i] === "function") { x[i].call(this); } } if (this.now && !this.unit && !this.operator) { return new Date(); } else { today = finishUtils.getToday.call(this); } expression = !!(this.days && this.days !== null || this.orient || this.operator); orient = ((this.orient === "past" || this.operator === "subtract") ? -1 : 1); if (this.month && this.unit === "week") { this.value = this.month + 1; delete this.month; delete this.day; } if ((this.month || this.month === 0) && "year day hour minute second".indexOf(this.unit) !== -1) { if (!this.value) { this.value = this.month + 1; } this.month = null; expression = true; } if (!expression && this.weekday && !this.day && !this.days) { finishUtils.setDMYFromWeekday.call(this); } if (expression && this.weekday && this.unit !== "month" && this.unit !== "week") { finishUtils.setDaysFromWeekday.call(this, today, orient); } if (this.weekday && this.unit !== "week" && !this.day && !this.days) { temp = Date[this.weekday](); this.day = temp.getDate(); if (temp.getMonth() !== today.getMonth()) { this.month = temp.getMonth(); } } if (this.month && this.unit === "day" && this.operator) { if (!this.value) { this.value = (this.month + 1); } this.month = null; } if (this.value != null && this.month != null && this.year != null) { this.day = this.value * 1; } if (this.month && !this.day && this.value) { today.set({ day: this.value * 1 }); if (!expression) { this.day = this.value * 1; } } if (!this.month && this.value && this.unit === "month" && !this.now) { this.month = this.value; expression = true; } if (expression && (this.month || this.month === 0) && this.unit !== "year") { finishUtils.setMonthsFromMonth.call(this, today, orient); } if (!this.unit) { this.unit = "day"; } finishUtils.setUnitValue.call(this, orient); parseMeridian.call(this); if ((this.month || this.month === 0) && !this.day) { this.day = 1; } if (!this.orient && !this.operator && this.unit === "week" && this.value && !this.day && !this.month) { return Date.today().setWeek(this.value); } if (this.unit === "week" && this.weeks && !this.day && !this.month) { return finishUtils.generateDateFromWeeks.call(this); } if (expression && this.timezone && this.day && this.days) { this.day = this.days; } if (expression){ today.add(this); } else { today.set(this); } if (this.timezone) { this.timezone = this.timezone.toUpperCase(); var offset = $D.getTimezoneOffset(this.timezone); var timezone; if (today.hasDaylightSavingTime()) { // lets check that we're being sane with timezone setting timezone = $D.getTimezoneAbbreviation(offset, today.isDaylightSavingTime()); if (timezone !== this.timezone) { // bugger, we're in a place where things like EST vs EDT matters. if (today.isDaylightSavingTime()) { today.addHours(-1); } else { today.addHours(1); } } } today.setTimezoneOffset(offset); } return today; } }; }()); (function () { var $D = Date; $D.Grammar = {}; var _ = $D.Parsing.Operators, g = $D.Grammar, t = $D.Translator, _fn; // Allow rolling up into general purpose rules _fn = function () { return _.each(_.any.apply(null, arguments), _.not(g.ctoken2("timeContext"))); }; g.datePartDelimiter = _.rtoken(/^([\s\-\.\,\/\x27]+)/); g.timePartDelimiter = _.stoken(":"); g.whiteSpace = _.rtoken(/^\s*/); g.generalDelimiter = _.rtoken(/^(([\s\,]|at|@|on)+)/); var _C = {}; g.ctoken = function (keys) { var fn = _C[keys]; if (! fn) { var c = Date.CultureInfo.regexPatterns; var kx = keys.split(/\s+/), px = []; for (var i = 0; i < kx.length ; i++) { px.push(_.replace(_.rtoken(c[kx[i]]), kx[i])); } fn = _C[keys] = _.any.apply(null, px); } return fn; }; g.ctoken2 = function (key) { return _.rtoken(Date.CultureInfo.regexPatterns[key]); }; var cacheProcessRtoken = function (key, token, type, eachToken) { if (eachToken) { g[key] = _.cache(_.process(_.each(_.rtoken(token),_.optional(g.ctoken2(eachToken))), type)); } else { g[key] = _.cache(_.process(_.rtoken(token), type)); } }; var cacheProcessCtoken = function (token, type) { return _.cache(_.process(g.ctoken2(token), type)); }; var _F = {}; //function cache var _get = function (f) { _F[f] = (_F[f] || g.format(f)[0]); return _F[f]; }; g.allformats = function (fx) { var rx = []; if (fx instanceof Array) { for (var i = 0; i < fx.length; i++) { rx.push(_get(fx[i])); } } else { rx.push(_get(fx)); } return rx; }; g.formats = function (fx) { if (fx instanceof Array) { var rx = []; for (var i = 0 ; i < fx.length ; i++) { rx.push(_get(fx[i])); } return _.any.apply(null, rx); } else { return _get(fx); } }; var grammarFormats = { timeFormats: function(){ var i, RTokenKeys = [ "h", "hh", "H", "HH", "m", "mm", "s", "ss", "ss.s", "z", "zz" ], RToken = [ /^(0[0-9]|1[0-2]|[1-9])/, /^(0[0-9]|1[0-2])/, /^([0-1][0-9]|2[0-3]|[0-9])/, /^([0-1][0-9]|2[0-3])/, /^([0-5][0-9]|[0-9])/, /^[0-5][0-9]/, /^([0-5][0-9]|[0-9])/, /^[0-5][0-9]/, /^[0-5][0-9]\.[0-9]{1,3}/, /^((\+|\-)\s*\d\d\d\d)|((\+|\-)\d\d\:?\d\d)/, /^((\+|\-)\s*\d\d\d\d)|((\+|\-)\d\d\:?\d\d)/ ], tokens = [ t.hour, t.hour, t.hour, t.hour, t.minute, t.minute, t.second, t.second, t.secondAndMillisecond, t.timezone, t.timezone ]; for (i=0; i < RTokenKeys.length; i++) { cacheProcessRtoken(RTokenKeys[i], RToken[i], tokens[i]); } g.hms = _.cache(_.sequence([g.H, g.m, g.s], g.timePartDelimiter)); g.t = cacheProcessCtoken("shortMeridian", t.meridian); g.tt = cacheProcessCtoken("longMeridian", t.meridian); g.zzz = cacheProcessCtoken("timezone", t.timezone); g.timeSuffix = _.each(_.ignore(g.whiteSpace), _.set([ g.tt, g.zzz ])); g.time = _.each(_.optional(_.ignore(_.stoken("T"))), g.hms, g.timeSuffix); }, dateFormats: function () { // pre-loaded rules for different date part order preferences var _setfn = function () { return _.set(arguments, g.datePartDelimiter); }; var i, RTokenKeys = [ "d", "dd", "M", "MM", "y", "yy", "yyy", "yyyy" ], RToken = [ /^([0-2]\d|3[0-1]|\d)/, /^([0-2]\d|3[0-1])/, /^(1[0-2]|0\d|\d)/, /^(1[0-2]|0\d)/, /^(\d+)/, /^(\d\d)/, /^(\d\d?\d?\d?)/, /^(\d\d\d\d)/ ], tokens = [ t.day, t.day, t.month, t.month, t.year, t.year, t.year, t.year ], eachToken = [ "ordinalSuffix", "ordinalSuffix" ]; for (i=0; i < RTokenKeys.length; i++) { cacheProcessRtoken(RTokenKeys[i], RToken[i], tokens[i], eachToken[i]); } g.MMM = g.MMMM = _.cache(_.process(g.ctoken("jan feb mar apr may jun jul aug sep oct nov dec"), t.month)); g.ddd = g.dddd = _.cache(_.process(g.ctoken("sun mon tue wed thu fri sat"), function (s) { return function () { this.weekday = s; }; } )); g.day = _fn(g.d, g.dd); g.month = _fn(g.M, g.MMM); g.year = _fn(g.yyyy, g.yy); g.mdy = _setfn(g.ddd, g.month, g.day, g.year); g.ymd = _setfn(g.ddd, g.year, g.month, g.day); g.dmy = _setfn(g.ddd, g.day, g.month, g.year); g.date = function (s) { return ((g[Date.CultureInfo.dateElementOrder] || g.mdy).call(this, s)); }; }, relative: function () { // relative date / time expressions g.orientation = _.process(g.ctoken("past future"), function (s) { return function () { this.orient = s; }; } ); g.operator = _.process(g.ctoken("add subtract"), function (s) { return function () { this.operator = s; }; } ); g.rday = _.process(g.ctoken("yesterday tomorrow today now"), t.rday); g.unit = _.process(g.ctoken("second minute hour day week month year"), function (s) { return function () { this.unit = s; }; } ); } }; g.buildGrammarFormats = function () { // these need to be rebuilt every time the language changes. _C = {}; grammarFormats.timeFormats(); grammarFormats.dateFormats(); grammarFormats.relative(); g.value = _.process(_.rtoken(/^([-+]?\d+)?(st|nd|rd|th)?/), function (s) { return function () { this.value = s.replace(/\D/g, ""); }; } ); g.expression = _.set([g.rday, g.operator, g.value, g.unit, g.orientation, g.ddd, g.MMM ]); g.format = _.process(_.many( _.any( // translate format specifiers into grammar rules _.process( _.rtoken(/^(dd?d?d?(?!e)|MM?M?M?|yy?y?y?|hh?|HH?|mm?|ss?|tt?|zz?z?)/), function (fmt) { if (g[fmt]) { return g[fmt]; } else { throw $D.Parsing.Exception(fmt); } } ), // translate separator tokens into token rules _.process(_.rtoken(/^[^dMyhHmstz]+/), // all legal separators function (s) { return _.ignore(_.stoken(s)); } ) ) ), // construct the parser ... function (rules) { return _.process(_.each.apply(null, rules), t.finishExact); } ); // starting rule for general purpose grammar g._start = _.process(_.set([ g.date, g.time, g.expression ], g.generalDelimiter, g.whiteSpace), t.finish); }; g.buildGrammarFormats(); // parsing date format specifiers - ex: "h:m:s tt" // this little guy will generate a custom parser based // on the format string, ex: g.format("h:m:s tt") // check for these formats first g._formats = g.formats([ "\"yyyy-MM-ddTHH:mm:ssZ\"", "yyyy-MM-ddTHH:mm:ss.sz", "yyyy-MM-ddTHH:mm:ssZ", "yyyy-MM-ddTHH:mm:ssz", "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-ddTHH:mmZ", "yyyy-MM-ddTHH:mmz", "yyyy-MM-ddTHH:mm", "ddd, MMM dd, yyyy H:mm:ss tt", "ddd MMM d yyyy HH:mm:ss zzz", "MMddyyyy", "ddMMyyyy", "Mddyyyy", "ddMyyyy", "Mdyyyy", "dMyyyy", "yyyy", "Mdyy", "dMyy", "d" ]); // real starting rule: tries selected formats first, // then general purpose rule g.start = function (s) { try { var r = g._formats.call({}, s); if (r[1].length === 0) { return r; } } catch (e) {} return g._start.call({}, s); }; }()); (function () { var $D = Date; /** * @desc Converts the specified string value into its JavaScript Date equivalent using CultureInfo specific format information. * * Example

	///////////
	// Dates //
	///////////

	// 15-Oct-2004
	var d1 = Date.parse("10/15/2004");

	// 15-Oct-2004
	var d1 = Date.parse("15-Oct-2004");

	// 15-Oct-2004
	var d1 = Date.parse("2004.10.15");

	//Fri Oct 15, 2004
	var d1 = Date.parse("Fri Oct 15, 2004");

	///////////
	// Times //
	///////////

	// Today at 10 PM.
	var d1 = Date.parse("10 PM");

	// Today at 10:30 PM.
	var d1 = Date.parse("10:30 P.M.");

	// Today at 6 AM.
	var d1 = Date.parse("06am");

	/////////////////////
	// Dates and Times //
	/////////////////////

	// 8-July-2004 @ 10:30 PM
	var d1 = Date.parse("July 8th, 2004, 10:30 PM");

	// 1-July-2004 @ 10:30 PM
	var d1 = Date.parse("2004-07-01T22:30:00");

	////////////////////
	// Relative Dates //
	////////////////////

	// Returns today's date. The string "today" is culture specific.
	var d1 = Date.parse("today");

	// Returns yesterday's date. The string "yesterday" is culture specific.
	var d1 = Date.parse("yesterday");

	// Returns the date of the next thursday.
	var d1 = Date.parse("Next thursday");

	// Returns the date of the most previous monday.
	var d1 = Date.parse("last monday");

	// Returns today's day + one year.
	var d1 = Date.parse("next year");

	///////////////
	// Date Math //
	///////////////

	// Today + 2 days
	var d1 = Date.parse("t+2");

	// Today + 2 days
	var d1 = Date.parse("today + 2 days");

	// Today + 3 months
	var d1 = Date.parse("t+3m");

	// Today - 1 year
	var d1 = Date.parse("today - 1 year");

	// Today - 1 year
	var d1 = Date.parse("t-1y"); 


	/////////////////////////////
	// Partial Dates and Times //
	/////////////////////////////

	// July 15th of this year.
	var d1 = Date.parse("July 15");

	// 15th day of current day and year.
	var d1 = Date.parse("15");

	// July 1st of current year at 10pm.
	var d1 = Date.parse("7/1 10pm");
	
* * @param {String} The string value to convert into a Date object [Required] * @return {Date} A Date object or null if the string cannot be converted into a Date. */ var parseUtils = { removeOrds: function (s) { ords = s.match(/\b(\d+)(?:st|nd|rd|th)\b/); // find ordinal matches s = ((ords && ords.length === 2) ? s.replace(ords[0], ords[1]) : s); return s; }, grammarParser: function (s) { var r = null; try { r = $D.Grammar.start.call({}, s.replace(/^\s*(\S*(\s+\S+)*)\s*$/, "$1")); } catch (e) { return null; } return ((r[1].length === 0) ? r[0] : null); }, nativeFallback: function(s) { var t; try { // ok we haven't parsed it, last ditch attempt with the built-in parser. t = Date._parse(s); return (t || t === 0) ? new Date(t) : null; } catch (e) { return null; } } }; function parse (s) { var d; if (!s) { return null; } if (s instanceof Date) { return s.clone(); } if (s.length >= 4 && s.charAt(0) !== "0" && s.charAt(0) !== "+"&& s.charAt(0) !== "-") { // ie: 2004 will pass, 0800 won't. // Start with specific formats d = $D.Parsing.ISO.parse(s) || $D.Parsing.Numeric.parse(s); } if (d instanceof Date && !isNaN(d.getTime())) { return d; } else { // find ordinal dates (1st, 3rd, 8th, etc and remove them as they cause parsing issues) s = $D.Parsing.Normalizer.parse(parseUtils.removeOrds(s)); d = parseUtils.grammarParser(s); if (d !== null) { return d; } else { return parseUtils.nativeFallback(s); } } } if (!$D._parse) { $D._parse = $D.parse; } $D.parse = parse; Date.getParseFunction = function (fx) { var fns = Date.Grammar.allformats(fx); return function (s) { var r = null; for (var i = 0; i < fns.length; i++) { try { r = fns[i].call({}, s); } catch (e) { continue; } if (r[1].length === 0) { return r[0]; } } return null; }; }; /** * Converts the specified string value into its JavaScript Date equivalent using the specified format {String} or formats {Array} and the CultureInfo specific format information. * The format of the string value must match one of the supplied formats exactly. * * Example

	// 15-Oct-2004
	var d1 = Date.parseExact("10/15/2004", "M/d/yyyy");

	// 15-Oct-2004
	var d1 = Date.parse("15-Oct-2004", "M-ddd-yyyy");

	// 15-Oct-2004
	var d1 = Date.parse("2004.10.15", "yyyy.MM.dd");

	// Multiple formats
	var d1 = Date.parseExact("10/15/2004", ["M/d/yyyy", "MMMM d, yyyy"]);
	
* * @param {String} The string value to convert into a Date object [Required]. * @param {Object} The expected format {String} or an array of expected formats {Array} of the date string [Required]. * @return {Date} A Date object or null if the string cannot be converted into a Date. */ $D.parseExact = function (s, fx) { return $D.getParseFunction(fx)(s); }; }()); (function () { var $D = Date, $P = $D.prototype, // $C = $D.CultureInfo, // not used atm p = function (s, l) { if (!l) { l = 2; } return ("000" + s).slice(l * -1); }; /** * Converts a PHP format string to Java/.NET format string. * A PHP format string can be used with ._format or .format. * A Java/.NET format string can be used with .toString(). * The .parseExact function will only accept a Java/.NET format string * * Example * var f1 = "%m/%d/%y" * var f2 = Date.normalizeFormat(f1); // "MM/dd/yy" * * new Date().format(f1); // "04/13/08" * new Date()._format(f1); // "04/13/08" * new Date().toString(f2); // "04/13/08" * * var date = Date.parseExact("04/13/08", f2); // Sun Apr 13 2008 * * @param {String} A PHP format string consisting of one or more format spcifiers. * @return {String} The PHP format converted to a Java/.NET format string. */ var normalizerSubstitutions = { "d" : "dd", "%d": "dd", "D" : "ddd", "%a": "ddd", "j" : "dddd", "l" : "dddd", "%A": "dddd", "S" : "S", "F" : "MMMM", "%B": "MMMM", "m" : "MM", "%m": "MM", "M" : "MMM", "%b": "MMM", "%h": "MMM", "n" : "M", "Y" : "yyyy", "%Y": "yyyy", "y" : "yy", "%y": "yy", "g" : "h", "%I": "h", "G" : "H", "h" : "hh", "H" : "HH", "%H": "HH", "i" : "mm", "%M": "mm", "s" : "ss", "%S": "ss", "%r": "hh:mm tt", "%R": "H:mm", "%T": "H:mm:ss", "%X": "t", "%x": "d", "%e": "d", "%D": "MM/dd/yy", "%n": "\\n", "%t": "\\t", "e" : "z", "T" : "z", "%z": "z", "%Z": "z", "Z" : "ZZ", "N" : "u", "w" : "u", "%w": "u", "W" : "W", "%V": "W" }; var normalizer = { substitutes: function (m) { return normalizerSubstitutions[m]; }, interpreted: function (m, x) { var y; switch (m) { case "%u": return x.getDay() + 1; case "z": return x.getOrdinalNumber(); case "%j": return p(x.getOrdinalNumber(), 3); case "%U": var d1 = x.clone().set({month: 0, day: 1}).addDays(-1).moveToDayOfWeek(0), d2 = x.clone().addDays(1).moveToDayOfWeek(0, -1); return (d2 < d1) ? "00" : p((d2.getOrdinalNumber() - d1.getOrdinalNumber()) / 7 + 1); case "%W": return p(x.getWeek()); case "t": return $D.getDaysInMonth(x.getFullYear(), x.getMonth()); case "o": case "%G": return x.setWeek(x.getISOWeek()).toString("yyyy"); case "%g": return x._format("%G").slice(-2); case "a": case "%p": return t("tt").toLowerCase(); case "A": return t("tt").toUpperCase(); case "u": return p(x.getMilliseconds(), 3); case "I": return (x.isDaylightSavingTime()) ? 1 : 0; case "O": return x.getUTCOffset(); case "P": y = x.getUTCOffset(); return y.substring(0, y.length - 2) + ":" + y.substring(y.length - 2); case "B": var now = new Date(); return Math.floor(((now.getHours() * 3600) + (now.getMinutes() * 60) + now.getSeconds() + (now.getTimezoneOffset() + 60) * 60) / 86.4); case "c": return x.toISOString().replace(/\"/g, ""); case "U": return $D.strtotime("now"); case "%c": return t("d") + " " + t("t"); case "%C": return Math.floor(x.getFullYear() / 100 + 1); } }, shouldOverrideDefaults: function (m) { switch (m) { case "%e": return true; default: return false; } }, parse: function (m, context) { var formatString, c = context || new Date(); formatString = normalizer.substitutes(m); if (formatString) { return formatString; } formatString = normalizer.interpreted(m, c); if (formatString) { return formatString; } else { return m; } } }; $D.normalizeFormat = function (format, context) { return format.replace(/(%|\\)?.|%%/g, function(t){ return normalizer.parse(t, context); }); }; /** * Format a local Unix timestamp according to locale settings * * Example: * Date.strftime("%m/%d/%y", new Date()); // "04/13/08" * Date.strftime("c", "2008-04-13T17:52:03Z"); // "04/13/08" * * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @param {Number|String} The number representing the number of seconds that have elapsed since January 1, 1970 (local time). * @return {String} A string representation of the current Date object. */ $D.strftime = function (format, time) { var d = Date.parse(time); return d._format(format); }; /** * Parse any textual datetime description into a Unix timestamp. * A Unix timestamp is the number of seconds that have elapsed since January 1, 1970 (midnight UTC/GMT). * * Example: * Date.strtotime("04/13/08"); // 1208044800 * Date.strtotime("1970-01-01T00:00:00Z"); // 0 * * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @param {Object} A string or date object. * @return {String} A string representation of the current Date object. */ $D.strtotime = function (time) { var d = $D.parse(time); return Math.round($D.UTC(d.getUTCFullYear(), d.getUTCMonth(), d.getUTCDate(), d.getUTCHours(), d.getUTCMinutes(), d.getUTCSeconds(), d.getUTCMilliseconds()) / 1000); }; /** * Converts the value of the current Date object to its equivalent string representation using a PHP/Unix style of date format specifiers. * Format Specifiers * Format Description Example * ------ --------------------------------------------------------------------------- ----------------------- * %a abbreviated weekday name according to the current localed "Mon" through "Sun" * %A full weekday name according to the current localed "Sunday" through "Saturday" * %b abbreviated month name according to the current localed "Jan" through "Dec" * %B full month name according to the current locale "January" through "December" * %c preferred date and time representation for the current locale "4/13/2008 12:33 PM" * %C century number (the year divided by 100 and truncated to an integer) "00" to "99" * %d day of the month as a decimal number "01" to "31" * %D same as %m/%d/%y "04/13/08" * %e day of the month as a decimal number, a single digit is preceded by a space "1" to "31" * %g like %G, but without the century "08" * %G The 4-digit year corresponding to the ISO week number (see %V). "2008" * This has the same format and value as %Y, except that if the ISO week number * belongs to the previous or next year, that year is used instead. * %h same as %b "Jan" through "Dec" * %H hour as a decimal number using a 24-hour clock. "00" to "23" * %I hour as a decimal number using a 12-hour clock. "01" to "12" * %j day of the year as a decimal number. "001" to "366" * %m month as a decimal number. "01" to "12" * %M minute as a decimal number. "00" to "59" * %n newline character "\n" * %p either "am" or "pm" according to the given time value, or the "am" or "pm" * corresponding strings for the current locale. * %r time in a.m. and p.m. notation "8:44 PM" * %R time in 24 hour notation "20:44" * %S second as a decimal number "00" to "59" * %t tab character "\t" * %T current time, equal to %H:%M:%S "12:49:11" * %u weekday as a decimal number ["1", "7"], with "1" representing Monday "1" to "7" * %U week number of the current year as a decimal number, starting with the "0" to ("52" or "53") * first Sunday as the first day of the first week * %V The ISO 8601:1988 week number of the current year as a decimal number, "00" to ("52" or "53") * range 01 to 53, where week 1 is the first week that has at least 4 days * in the current year, and with Monday as the first day of the week. * (Use %G or %g for the year component that corresponds to the week number * for the specified timestamp.) * %W week number of the current year as a decimal number, starting with the "00" to ("52" or "53") * first Monday as the first day of the first week * %w day of the week as a decimal, Sunday being "0" "0" to "6" * %x preferred date representation for the current locale without the time "4/13/2008" * %X preferred time representation for the current locale without the date "12:53:05" * %y year as a decimal number without a century "00" "99" * %Y year as a decimal number including the century "2008" * %Z time zone or name or abbreviation "UTC", "EST", "PST" * %z same as %Z * %% a literal "%" characters "%" * d Day of the month, 2 digits with leading zeros "01" to "31" * D A textual representation of a day, three letters "Mon" through "Sun" * j Day of the month without leading zeros "1" to "31" * l A full textual representation of the day of the week (lowercase "L") "Sunday" through "Saturday" * N ISO-8601 numeric representation of the day of the week (added in PHP 5.1.0) "1" (for Monday) through "7" (for Sunday) * S English ordinal suffix for the day of the month, 2 characters "st", "nd", "rd" or "th". Works well with j * w Numeric representation of the day of the week "0" (for Sunday) through "6" (for Saturday) * z The day of the year (starting from "0") "0" through "365" * W ISO-8601 week number of year, weeks starting on Monday "00" to ("52" or "53") * F A full textual representation of a month, such as January or March "January" through "December" * m Numeric representation of a month, with leading zeros "01" through "12" * M A short textual representation of a month, three letters "Jan" through "Dec" * n Numeric representation of a month, without leading zeros "1" through "12" * t Number of days in the given month "28" through "31" * L Whether it's a leap year "1" if it is a leap year, "0" otherwise * o ISO-8601 year number. This has the same value as Y, except that if the "2008" * ISO week number (W) belongs to the previous or next year, that year * is used instead. * Y A full numeric representation of a year, 4 digits "2008" * y A two digit representation of a year "08" * a Lowercase Ante meridiem and Post meridiem "am" or "pm" * A Uppercase Ante meridiem and Post meridiem "AM" or "PM" * B Swatch Internet time "000" through "999" * g 12-hour format of an hour without leading zeros "1" through "12" * G 24-hour format of an hour without leading zeros "0" through "23" * h 12-hour format of an hour with leading zeros "01" through "12" * H 24-hour format of an hour with leading zeros "00" through "23" * i Minutes with leading zeros "00" to "59" * s Seconds, with leading zeros "00" through "59" * u Milliseconds "54321" * e Timezone identifier "UTC", "EST", "PST" * I Whether or not the date is in daylight saving time (uppercase i) "1" if Daylight Saving Time, "0" otherwise * O Difference to Greenwich time (GMT) in hours "+0200", "-0600" * P Difference to Greenwich time (GMT) with colon between hours and minutes "+02:00", "-06:00" * T Timezone abbreviation "UTC", "EST", "PST" * Z Timezone offset in seconds. The offset for timezones west of UTC is "-43200" through "50400" * always negative, and for those east of UTC is always positive. * c ISO 8601 date "2004-02-12T15:19:21+00:00" * r RFC 2822 formatted date "Thu, 21 Dec 2000 16:01:07 +0200" * U Seconds since the Unix Epoch (January 1 1970 00:00:00 GMT) "0" * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @return {String} A string representation of the current Date object. */ var formatReplace = function (context) { return function (m) { var formatString, override = false; if (m.charAt(0) === "\\" || m.substring(0, 2) === "%%") { return m.replace("\\", "").replace("%%", "%"); } override = normalizer.shouldOverrideDefaults(m); formatString = $D.normalizeFormat(m, context); if (formatString) { return context.toString(formatString, override); } }; }; $P._format = function (format) { var formatter = formatReplace(this); if (!format) { return this._toString(); } else { return format.replace(/(%|\\)?.|%%/g, formatter); } }; if (!$P.format) { $P.format = $P._format; } }()); (function () { "use strict"; var gFn = function (attr) { return function () { return this[attr]; }; }; var sFn = function (attr) { return function (val) { this[attr] = val; return this; }; }; var attrs = ["years", "months", "days", "hours", "minutes", "seconds", "milliseconds"]; var addSetFuncs = function (context, attrs) { for (var i = 0; i < attrs.length ; i++) { var $a = attrs[i], $b = $a.slice(0, 1).toUpperCase() + $a.slice(1); context.prototype[$a] = 0; context.prototype["get" + $b] = gFn($a); context.prototype["set" + $b] = sFn($a); } }; /** * new TimeSpan(milliseconds); * new TimeSpan(days, hours, minutes, seconds); * new TimeSpan(days, hours, minutes, seconds, milliseconds); */ var TimeSpan = function (days, hours, minutes, seconds, milliseconds) { if (arguments.length === 1 && typeof days === "number") { var orient = (days < 0) ? -1 : +1; var millsLeft = Math.abs(days); this.setDays(Math.floor(millsLeft / 86400000) * orient); millsLeft = millsLeft % 86400000; this.setHours(Math.floor(millsLeft / 3600000) * orient); millsLeft = millsLeft % 3600000; this.setMinutes(Math.floor(millsLeft / 60000) * orient); millsLeft = millsLeft % 60000; this.setSeconds(Math.floor(millsLeft / 1000) * orient); millsLeft = millsLeft % 1000; this.setMilliseconds(millsLeft * orient); } else { this.set(days, hours, minutes, seconds, milliseconds); } this.getTotalMilliseconds = function () { return (this.getDays() * 86400000) + (this.getHours() * 3600000) + (this.getMinutes() * 60000) + (this.getSeconds() * 1000); }; this.compareTo = function (time) { var t1 = new Date(1970, 1, 1, this.getHours(), this.getMinutes(), this.getSeconds()), t2; if (time === null) { t2 = new Date(1970, 1, 1, 0, 0, 0); } else { t2 = new Date(1970, 1, 1, time.getHours(), time.getMinutes(), time.getSeconds()); } return (t1 < t2) ? -1 : (t1 > t2) ? 1 : 0; }; this.equals = function (time) { return (this.compareTo(time) === 0); }; this.add = function (time) { return (time === null) ? this : this.addSeconds(time.getTotalMilliseconds() / 1000); }; this.subtract = function (time) { return (time === null) ? this : this.addSeconds(-time.getTotalMilliseconds() / 1000); }; this.addDays = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 86400000)); }; this.addHours = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 3600000)); }; this.addMinutes = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 60000)); }; this.addSeconds = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 1000)); }; this.addMilliseconds = function (n) { return new TimeSpan(this.getTotalMilliseconds() + n); }; this.get12HourHour = function () { return (this.getHours() > 12) ? this.getHours() - 12 : (this.getHours() === 0) ? 12 : this.getHours(); }; this.getDesignator = function () { return (this.getHours() < 12) ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator; }; this.toString = function (format) { this._toString = function () { if (this.getDays() !== null && this.getDays() > 0) { return this.getDays() + "." + this.getHours() + ":" + this.p(this.getMinutes()) + ":" + this.p(this.getSeconds()); } else { return this.getHours() + ":" + this.p(this.getMinutes()) + ":" + this.p(this.getSeconds()); } }; this.p = function (s) { return (s.toString().length < 2) ? "0" + s : s; }; var me = this; return format ? format.replace(/dd?|HH?|hh?|mm?|ss?|tt?/g, function (format) { switch (format) { case "d": return me.getDays(); case "dd": return me.p(me.getDays()); case "H": return me.getHours(); case "HH": return me.p(me.getHours()); case "h": return me.get12HourHour(); case "hh": return me.p(me.get12HourHour()); case "m": return me.getMinutes(); case "mm": return me.p(me.getMinutes()); case "s": return me.getSeconds(); case "ss": return me.p(me.getSeconds()); case "t": return ((me.getHours() < 12) ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator).substring(0, 1); case "tt": return (me.getHours() < 12) ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator; } } ) : this._toString(); }; return this; }; addSetFuncs(TimeSpan, attrs.slice(2)); TimeSpan.prototype.set = function (days, hours, minutes, seconds, milliseconds){ this.setDays(days || this.getDays()); this.setHours(hours || this.getHours()); this.setMinutes(minutes || this.getMinutes()); this.setSeconds(seconds || this.getSeconds()); this.setMilliseconds(milliseconds || this.getMilliseconds()); }; /** * Gets the time of day for this date instances. * @return {TimeSpan} TimeSpan */ Date.prototype.getTimeOfDay = function () { return new TimeSpan(0, this.getHours(), this.getMinutes(), this.getSeconds(), this.getMilliseconds()); }; Date.TimeSpan = TimeSpan; if (typeof window !== "undefined" ) { // keeping API compatible for v1.x window.TimeSpan = TimeSpan; } }()); (function () { "use strict"; var attrs = ["years", "months", "days", "hours", "minutes", "seconds", "milliseconds"]; var gFn = function (attr) { return function () { return this[attr]; }; }; var sFn = function (attr) { return function (val) { this[attr] = val; return this; }; }; var addSetFuncs = function (context, attrs) { for (var i = 0; i < attrs.length ; i++) { var $a = attrs[i], $b = $a.slice(0, 1).toUpperCase() + $a.slice(1); context.prototype[$a] = 0; context.prototype["get" + $b] = gFn($a); context.prototype["set" + $b] = sFn($a); } }; var setMonthsAndYears = function (orient, d1, d2, context) { function inc() { d1.addMonths(-orient); context.months++; if (context.months === 12) { context.years++; context.months = 0; } } if (orient === +1) { while (d1 > d2) { inc(); } } else { while (d1 < d2) { inc(); } } context.months--; context.months *= orient; context.years *= orient; }; var adjustForDST = function(orient, startDate, endDate) { var hasDSTMismatch = (false === (startDate.isDaylightSavingTime() === endDate.isDaylightSavingTime())); if (hasDSTMismatch && orient === 1) { startDate.addHours(-1); } else if (hasDSTMismatch) { startDate.addHours(1); } }; /** * TimePeriod(startDate, endDate); * TimePeriod(years, months, days, hours, minutes, seconds, milliseconds); */ var TimePeriod = function (years, months, days, hours, minutes, seconds, milliseconds) { if (arguments.length === 7) { this.set(years, months, days, hours, minutes, seconds, milliseconds); } else if (arguments.length === 2 && arguments[0] instanceof Date && arguments[1] instanceof Date) { var startDate = arguments[0].clone(); var endDate = arguments[1].clone(); var orient = (startDate > endDate) ? +1 : -1; this.dates = { start: arguments[0].clone(), end: arguments[1].clone() }; setMonthsAndYears(orient, startDate, endDate, this); adjustForDST(orient, startDate, endDate); // // TODO - adjust for DST var diff = endDate - startDate; if (diff !== 0) { var ts = new TimeSpan(diff); this.set(this.years, this.months, ts.getDays(), ts.getHours(), ts.getMinutes(), ts.getSeconds(), ts.getMilliseconds()); } } return this; }; // create all the set functions. addSetFuncs(TimePeriod, attrs); TimePeriod.prototype.set = function (years, months, days, hours, minutes, seconds, milliseconds){ this.setYears(years || this.getYears()); this.setMonths(months || this.getMonths()); this.setDays(days || this.getDays()); this.setHours(hours || this.getHours()); this.setMinutes(minutes || this.getMinutes()); this.setSeconds(seconds || this.getSeconds()); this.setMilliseconds(milliseconds || this.getMilliseconds()); }; Date.TimePeriod = TimePeriod; if (typeof window !== "undefined") { // keeping API compatible for v1.x window.TimePeriod = TimePeriod; } }()); ================================================ FILE: build/date-es-PY.js ================================================ /** * @overview datejs * @version 1.0.0-rc3 * @author Gregory Wild-Smith * @copyright 2015 Gregory Wild-Smith * @license MIT * @homepage https://github.com/abritinthebay/datejs */ /* * DateJS Culture String File * Country Code: es-PY * Name: Spanish (Paraguay) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["es-PY"] = { "name": "es-PY", "englishName": "Spanish (Paraguay)", "nativeName": "Español (Paraguay)", "Sunday": "domingo", "Monday": "lunes", "Tuesday": "martes", "Wednesday": "miércoles", "Thursday": "jueves", "Friday": "viernes", "Saturday": "sábado", "Sun": "dom", "Mon": "lun", "Tue": "mar", "Wed": "mié", "Thu": "jue", "Fri": "vie", "Sat": "sáb", "Su": "do", "Mo": "lu", "Tu": "ma", "We": "mi", "Th": "ju", "Fr": "vi", "Sa": "sá", "S_Sun_Initial": "d", "M_Mon_Initial": "l", "T_Tue_Initial": "m", "W_Wed_Initial": "m", "T_Thu_Initial": "j", "F_Fri_Initial": "v", "S_Sat_Initial": "s", "January": "enero", "February": "febrero", "March": "marzo", "April": "abril", "May": "mayo", "June": "junio", "July": "julio", "August": "agosto", "September": "septiembre", "October": "octubre", "November": "noviembre", "December": "diciembre", "Jan_Abbr": "ene", "Feb_Abbr": "feb", "Mar_Abbr": "mar", "Apr_Abbr": "abr", "May_Abbr": "may", "Jun_Abbr": "jun", "Jul_Abbr": "jul", "Aug_Abbr": "ago", "Sep_Abbr": "sep", "Oct_Abbr": "oct", "Nov_Abbr": "nov", "Dec_Abbr": "dic", "AM": "a.m.", "PM": "p.m.", "firstDayOfWeek": 1, "twoDigitYearMax": 2029, "mdy": "dmy", "M/d/yyyy": "dd/MM/yyyy", "dddd, MMMM dd, yyyy": "dddd, dd' [de] 'MMMM' [de] 'yyyy", "h:mm tt": "hh:mm tt", "h:mm:ss tt": "hh:mm:ss tt", "dddd, MMMM dd, yyyy h:mm:ss tt": "dddd, dd' [de] 'MMMM' [de] 'yyyy hh:mm:ss tt", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "dd MMMM", "MMMM, yyyy": "MMMM' [de] 'yyyy", "/jan(uary)?/": "ene(ro)?", "/feb(ruary)?/": "feb(rero)?", "/mar(ch)?/": "mar(zo)?", "/apr(il)?/": "abr(il)?", "/may/": "may(o)?", "/jun(e)?/": "jun(io)?", "/jul(y)?/": "jul(io)?", "/aug(ust)?/": "ago(sto)?", "/sep(t(ember)?)?/": "sep(tiembre)?", "/oct(ober)?/": "oct(ubre)?", "/nov(ember)?/": "nov(iembre)?", "/dec(ember)?/": "dic(iembre)?", "/^su(n(day)?)?/": "^do(m(ingo)?)?", "/^mo(n(day)?)?/": "^lu(n(es)?)?", "/^tu(e(s(day)?)?)?/": "^ma(r(tes)?)?", "/^we(d(nesday)?)?/": "^mi(é(rcoles)?)?", "/^th(u(r(s(day)?)?)?)?/": "^ju(e(ves)?)?", "/^fr(i(day)?)?/": "^vi(e(rnes)?)?", "/^sa(t(urday)?)?/": "^sá(b(ado)?)?", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "es-PY"; /** * @overview datejs * @version 1.0.0-rc3 * @author Gregory Wild-Smith * @copyright 2015 Gregory Wild-Smith * @license MIT * @homepage https://github.com/abritinthebay/datejs */(function () { var $D = Date; var lang = Date.CultureStrings ? Date.CultureStrings.lang : null; var loggedKeys = {}; // for debug purposes. var getText = { getFromKey: function (key, countryCode) { var output; if (Date.CultureStrings && Date.CultureStrings[countryCode] && Date.CultureStrings[countryCode][key]) { output = Date.CultureStrings[countryCode][key]; } else { output = getText.buildFromDefault(key); } if (key.charAt(0) === "/") { // Assume it's a regex output = getText.buildFromRegex(key, countryCode); } return output; }, getFromObjectValues: function (obj, countryCode) { var key, output = {}; for(key in obj) { if (obj.hasOwnProperty(key)) { output[key] = getText.getFromKey(obj[key], countryCode); } } return output; }, getFromObjectKeys: function (obj, countryCode) { var key, output = {}; for(key in obj) { if (obj.hasOwnProperty(key)) { output[getText.getFromKey(key, countryCode)] = obj[key]; } } return output; }, getFromArray: function (arr, countryCode) { var output = []; for (var i=0; i < arr.length; i++){ if (i in arr) { output[i] = getText.getFromKey(arr[i], countryCode); } } return output; }, buildFromDefault: function (key) { var output, length, split, last; switch(key) { case "name": output = "en-US"; break; case "englishName": output = "English (United States)"; break; case "nativeName": output = "English (United States)"; break; case "twoDigitYearMax": output = 2049; break; case "firstDayOfWeek": output = 0; break; default: output = key; split = key.split("_"); length = split.length; if (length > 1 && key.charAt(0) !== "/") { // if the key isn't a regex and it has a split. last = split[(length - 1)].toLowerCase(); if (last === "initial" || last === "abbr") { output = split[0]; } } break; } return output; }, buildFromRegex: function (key, countryCode) { var output; if (Date.CultureStrings && Date.CultureStrings[countryCode] && Date.CultureStrings[countryCode][key]) { output = new RegExp(Date.CultureStrings[countryCode][key], "i"); } else { output = new RegExp(key.replace(new RegExp("/", "g"),""), "i"); } return output; } }; var shallowMerge = function (obj1, obj2) { for (var attrname in obj2) { if (obj2.hasOwnProperty(attrname)) { obj1[attrname] = obj2[attrname]; } } }; var __ = function (key, language) { var countryCode = (language) ? language : lang; loggedKeys[key] = key; if (typeof key === "object") { if (key instanceof Array) { return getText.getFromArray(key, countryCode); } else { return getText.getFromObjectKeys(key, countryCode); } } else { return getText.getFromKey(key, countryCode); } }; var loadI18nScript = function (code) { // paatterned after jQuery's getScript. var url = Date.Config.i18n + code + ".js"; var head = document.getElementsByTagName("head")[0] || document.documentElement; var script = document.createElement("script"); script.src = url; var completed = false; var events = { done: function (){} // placeholder function }; // Attach handlers for all browsers script.onload = script.onreadystatechange = function() { if ( !completed && (!this.readyState || this.readyState === "loaded" || this.readyState === "complete") ) { events.done(); head.removeChild(script); } }; setTimeout(function() { head.insertBefore(script, head.firstChild); }, 0); // allows return to execute first return { done: function (cb) { events.done = function() { if (cb) { setTimeout(cb,0); } }; } }; }; var buildInfo = { buildFromMethodHash: function (obj) { var key; for(key in obj) { if (obj.hasOwnProperty(key)) { obj[key] = buildInfo[obj[key]](); } } return obj; }, timeZoneDST: function () { var DST = { "CHADT": "+1345", "NZDT": "+1300", "AEDT": "+1100", "ACDT": "+1030", "AZST": "+0500", "IRDT": "+0430", "EEST": "+0300", "CEST": "+0200", "BST": "+0100", "PMDT": "-0200", "ADT": "-0300", "NDT": "-0230", "EDT": "-0400", "CDT": "-0500", "MDT": "-0600", "PDT": "-0700", "AKDT": "-0800", "HADT": "-0900" }; return __(DST); }, timeZoneStandard: function () { var standard = { "LINT": "+1400", "TOT": "+1300", "CHAST": "+1245", "NZST": "+1200", "NFT": "+1130", "SBT": "+1100", "AEST": "+1000", "ACST": "+0930", "JST": "+0900", "CWST": "+0845", "CT": "+0800", "ICT": "+0700", "MMT": "+0630", "BST": "+0600", "NPT": "+0545", "IST": "+0530", "PKT": "+0500", "AFT": "+0430", "MSK": "+0400", "IRST": "+0330", "FET": "+0300", "EET": "+0200", "CET": "+0100", "GMT": "+0000", "UTC": "+0000", "CVT": "-0100", "GST": "-0200", "BRT": "-0300", "NST": "-0330", "AST": "-0400", "EST": "-0500", "CST": "-0600", "MST": "-0700", "PST": "-0800", "AKST": "-0900", "MIT": "-0930", "HST": "-1000", "SST": "-1100", "BIT": "-1200" }; return __(standard); }, timeZones: function (data) { var zone; data.timezones = []; for (zone in data.abbreviatedTimeZoneStandard) { if (data.abbreviatedTimeZoneStandard.hasOwnProperty(zone)) { data.timezones.push({ name: zone, offset: data.abbreviatedTimeZoneStandard[zone]}); } } for (zone in data.abbreviatedTimeZoneDST) { if (data.abbreviatedTimeZoneDST.hasOwnProperty(zone)) { data.timezones.push({ name: zone, offset: data.abbreviatedTimeZoneDST[zone], dst: true}); } } return data.timezones; }, days: function () { return __(["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"]); }, dayAbbr: function () { return __(["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"]); }, dayShortNames: function () { return __(["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"]); }, dayFirstLetters: function () { return __(["S_Sun_Initial", "M_Mon_Initial", "T_Tues_Initial", "W_Wed_Initial", "T_Thu_Initial", "F_Fri_Initial", "S_Sat_Initial"]); }, months: function () { return __(["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"]); }, monthAbbr: function () { return __(["Jan_Abbr", "Feb_Abbr", "Mar_Abbr", "Apr_Abbr", "May_Abbr", "Jun_Abbr", "Jul_Abbr", "Aug_Abbr", "Sep_Abbr", "Oct_Abbr", "Nov_Abbr", "Dec_Abbr"]); }, formatPatterns: function () { return getText.getFromObjectValues({ shortDate: "M/d/yyyy", longDate: "dddd, MMMM dd, yyyy", shortTime: "h:mm tt", longTime: "h:mm:ss tt", fullDateTime: "dddd, MMMM dd, yyyy h:mm:ss tt", sortableDateTime: "yyyy-MM-ddTHH:mm:ss", universalSortableDateTime: "yyyy-MM-dd HH:mm:ssZ", rfc1123: "ddd, dd MMM yyyy HH:mm:ss", monthDay: "MMMM dd", yearMonth: "MMMM, yyyy" }, Date.i18n.currentLanguage()); }, regex: function () { return getText.getFromObjectValues({ inTheMorning: "/( in the )(morn(ing)?)\\b/", thisMorning: "/(this )(morn(ing)?)\\b/", amThisMorning: "/(\b\\d(am)? )(this )(morn(ing)?)/", inTheEvening: "/( in the )(even(ing)?)\\b/", thisEvening: "/(this )(even(ing)?)\\b/", pmThisEvening: "/(\b\\d(pm)? )(this )(even(ing)?)/", jan: "/jan(uary)?/", feb: "/feb(ruary)?/", mar: "/mar(ch)?/", apr: "/apr(il)?/", may: "/may/", jun: "/jun(e)?/", jul: "/jul(y)?/", aug: "/aug(ust)?/", sep: "/sep(t(ember)?)?/", oct: "/oct(ober)?/", nov: "/nov(ember)?/", dec: "/dec(ember)?/", sun: "/^su(n(day)?)?/", mon: "/^mo(n(day)?)?/", tue: "/^tu(e(s(day)?)?)?/", wed: "/^we(d(nesday)?)?/", thu: "/^th(u(r(s(day)?)?)?)?/", fri: "/fr(i(day)?)?/", sat: "/^sa(t(urday)?)?/", future: "/^next/", past: "/^last|past|prev(ious)?/", add: "/^(\\+|aft(er)?|from|hence)/", subtract: "/^(\\-|bef(ore)?|ago)/", yesterday: "/^yes(terday)?/", today: "/^t(od(ay)?)?/", tomorrow: "/^tom(orrow)?/", now: "/^n(ow)?/", millisecond: "/^ms|milli(second)?s?/", second: "/^sec(ond)?s?/", minute: "/^mn|min(ute)?s?/", hour: "/^h(our)?s?/", week: "/^w(eek)?s?/", month: "/^m(onth)?s?/", day: "/^d(ay)?s?/", year: "/^y(ear)?s?/", shortMeridian: "/^(a|p)/", longMeridian: "/^(a\\.?m?\\.?|p\\.?m?\\.?)/", timezone: "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/", ordinalSuffix: "/^\\s*(st|nd|rd|th)/", timeContext: "/^\\s*(\\:|a(?!u|p)|p)/" }, Date.i18n.currentLanguage()); } }; var CultureInfo = function () { var info = getText.getFromObjectValues({ name: "name", englishName: "englishName", nativeName: "nativeName", amDesignator: "AM", pmDesignator: "PM", firstDayOfWeek: "firstDayOfWeek", twoDigitYearMax: "twoDigitYearMax", dateElementOrder: "mdy" }, Date.i18n.currentLanguage()); var constructedInfo = buildInfo.buildFromMethodHash({ dayNames: "days", abbreviatedDayNames: "dayAbbr", shortestDayNames: "dayShortNames", firstLetterDayNames: "dayFirstLetters", monthNames: "months", abbreviatedMonthNames: "monthAbbr", formatPatterns: "formatPatterns", regexPatterns: "regex", abbreviatedTimeZoneDST: "timeZoneDST", abbreviatedTimeZoneStandard: "timeZoneStandard" }); shallowMerge(info, constructedInfo); buildInfo.timeZones(info); return info; }; $D.i18n = { __: function (key, lang) { return __(key, lang); }, currentLanguage: function () { return lang || "en-US"; }, setLanguage: function (code, force, cb) { var async = false; if (force || code === "en-US" || (!!Date.CultureStrings && !!Date.CultureStrings[code])) { lang = code; Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings.lang = code; Date.CultureInfo = new CultureInfo(); } else { if (!(!!Date.CultureStrings && !!Date.CultureStrings[code])) { if (typeof exports !== "undefined" && this.exports !== exports) { // we're in a Node enviroment, load it using require try { require("../i18n/" + code + ".js"); lang = code; Date.CultureStrings.lang = code; Date.CultureInfo = new CultureInfo(); } catch (e) { // var str = "The language for '" + code + "' could not be loaded by Node. It likely does not exist."; throw new Error("The DateJS IETF language tag '" + code + "' could not be loaded by Node. It likely does not exist."); } } else if (Date.Config && Date.Config.i18n) { // we know the location of the files, so lets load them async = true; loadI18nScript(code).done(function(){ lang = code; Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings.lang = code; Date.CultureInfo = new CultureInfo(); $D.Parsing.Normalizer.buildReplaceData(); // because this is async if ($D.Grammar) { $D.Grammar.buildGrammarFormats(); // so we can parse those strings... } if (cb) { setTimeout(cb,0); } }); } else { Date.console.error("The DateJS IETF language tag '" + code + "' is not available and has not been loaded."); return false; } } } $D.Parsing.Normalizer.buildReplaceData(); // rebuild normalizer strings if ($D.Grammar) { $D.Grammar.buildGrammarFormats(); // so we can parse those strings... } if (!async && cb) { setTimeout(cb,0); } }, getLoggedKeys: function () { return loggedKeys; }, updateCultureInfo: function () { Date.CultureInfo = new CultureInfo(); } }; $D.i18n.updateCultureInfo(); // run automatically }()); (function () { var $D = Date, $P = $D.prototype, p = function (s, l) { if (!l) { l = 2; } return ("000" + s).slice(l * -1); }; if (typeof window !== "undefined" && typeof window.console !== "undefined" && typeof window.console.log !== "undefined") { $D.console = console; // used only to raise non-critical errors if available } else { // set mock so we don't give errors. $D.console = { log: function(){}, error: function(){} }; } $D.Config = $D.Config || {}; $D.initOverloads = function() { /** * Overload of Date.now. Allows an alternate call for Date.now where it returns the * current Date as an object rather than just milliseconds since the Unix Epoch. * * Also provides an implementation of now() for browsers (IE<9) that don't have it. * * Backwards compatible so with work with either: * Date.now() [returns ms] * or * Date.now(true) [returns Date] */ if (!$D.now) { $D._now = function now() { return new Date().getTime(); }; } else if (!$D._now) { $D._now = $D.now; } $D.now = function (returnObj) { if (returnObj) { return $D.present(); } else { return $D._now(); } }; if ( !$P.toISOString ) { $P.toISOString = function() { return this.getUTCFullYear() + "-" + p(this.getUTCMonth() + 1) + "-" + p(this.getUTCDate()) + "T" + p(this.getUTCHours()) + ":" + p(this.getUTCMinutes()) + ":" + p(this.getUTCSeconds()) + "." + String( (this.getUTCMilliseconds()/1000).toFixed(3)).slice(2, 5) + "Z"; }; } // private if ( $P._toString === undefined ){ $P._toString = $P.toString; } }; $D.initOverloads(); /** * Gets a date that is set to the current date. The time is set to the start of the day (00:00 or 12:00 AM). * @return {Date} The current date. */ $D.today = function () { return new Date().clearTime(); }; /** * Gets a date that is set to the current date and time (same as new Date, but chainable) * @return {Date} The current date. */ $D.present = function () { return new Date(); }; /** * Compares the first date to the second date and returns an number indication of their relative values. * @param {Date} First Date object to compare [Required]. * @param {Date} Second Date object to compare to [Required]. * @return {Number} -1 = date1 is lessthan date2. 0 = values are equal. 1 = date1 is greaterthan date2. */ $D.compare = function (date1, date2) { if (isNaN(date1) || isNaN(date2)) { throw new Error(date1 + " - " + date2); } else if (date1 instanceof Date && date2 instanceof Date) { return (date1 < date2) ? -1 : (date1 > date2) ? 1 : 0; } else { throw new TypeError(date1 + " - " + date2); } }; /** * Compares the first Date object to the second Date object and returns true if they are equal. * @param {Date} First Date object to compare [Required] * @param {Date} Second Date object to compare to [Required] * @return {Boolean} true if dates are equal. false if they are not equal. */ $D.equals = function (date1, date2) { return (date1.compareTo(date2) === 0); }; /** * Gets the language appropriate day name when given the day number(0-6) * eg - 0 == Sunday * @return {String} The day name */ $D.getDayName = function (n) { return Date.CultureInfo.dayNames[n]; }; /** * Gets the day number (0-6) if given a CultureInfo specific string which is a valid dayName, abbreviatedDayName or shortestDayName (two char). * @param {String} The name of the day (eg. "Monday, "Mon", "tuesday", "tue", "We", "we"). * @return {Number} The day number */ $D.getDayNumberFromName = function (name) { var n = Date.CultureInfo.dayNames, m = Date.CultureInfo.abbreviatedDayNames, o = Date.CultureInfo.shortestDayNames, s = name.toLowerCase(); for (var i = 0; i < n.length; i++) { if (n[i].toLowerCase() === s || m[i].toLowerCase() === s || o[i].toLowerCase() === s) { return i; } } return -1; }; /** * Gets the month number (0-11) if given a Culture Info specific string which is a valid monthName or abbreviatedMonthName. * @param {String} The name of the month (eg. "February, "Feb", "october", "oct"). * @return {Number} The day number */ $D.getMonthNumberFromName = function (name) { var n = Date.CultureInfo.monthNames, m = Date.CultureInfo.abbreviatedMonthNames, s = name.toLowerCase(); for (var i = 0; i < n.length; i++) { if (n[i].toLowerCase() === s || m[i].toLowerCase() === s) { return i; } } return -1; }; /** * Gets the language appropriate month name when given the month number(0-11) * eg - 0 == January * @return {String} The month name */ $D.getMonthName = function (n) { return Date.CultureInfo.monthNames[n]; }; /** * Determines if the current date instance is within a LeapYear. * @param {Number} The year. * @return {Boolean} true if date is within a LeapYear, otherwise false. */ $D.isLeapYear = function (year) { return ((year % 4 === 0 && year % 100 !== 0) || year % 400 === 0); }; /** * Gets the number of days in the month, given a year and month value. Automatically corrects for LeapYear. * @param {Number} The year. * @param {Number} The month (0-11). * @return {Number} The number of days in the month. */ $D.getDaysInMonth = function (year, month) { if (!month && $D.validateMonth(year)) { month = year; year = Date.today().getFullYear(); } return [31, ($D.isLeapYear(year) ? 29 : 28), 31, 30, 31, 30, 31, 31, 30, 31, 30, 31][month]; }; $P.getDaysInMonth = function () { return $D.getDaysInMonth(this.getFullYear(), this.getMonth()); }; $D.getTimezoneAbbreviation = function (offset, dst) { var p, n = (dst || false) ? Date.CultureInfo.abbreviatedTimeZoneDST : Date.CultureInfo.abbreviatedTimeZoneStandard; for (p in n) { if (n.hasOwnProperty(p)) { if (n[p] === offset) { return p; } } } return null; }; $D.getTimezoneOffset = function (name, dst) { var i, a =[], z = Date.CultureInfo.timezones; if (!name) { name = (new Date()).getTimezone();} for (i = 0; i < z.length; i++) { if (z[i].name === name.toUpperCase()) { a.push(i); } } if (!z[a[0]]) { return null; } if (a.length === 1 || !dst) { return z[a[0]].offset; } else { for (i=0; i < a.length; i++) { if (z[a[i]].dst) { return z[a[i]].offset; } } } }; $D.getQuarter = function (d) { d = d || new Date(); // If no date supplied, use today var q = [1,2,3,4]; return q[Math.floor(d.getMonth() / 3)]; // ~~~ is a bitwise op. Faster than Math.floor }; $D.getDaysLeftInQuarter = function (d) { d = d || new Date(); var qEnd = new Date(d); qEnd.setMonth(qEnd.getMonth() + 3 - qEnd.getMonth() % 3, 0); return Math.floor((qEnd - d) / 8.64e7); }; // private var validate = function (n, min, max, name) { name = name ? name : "Object"; if (typeof n === "undefined") { return false; } else if (typeof n !== "number") { throw new TypeError(n + " is not a Number."); } else if (n < min || n > max) { // As failing validation is *not* an exceptional circumstance // lets not throw a RangeError Exception here. // It's semantically correct but it's not sensible. return false; } return true; }; /** * Validates the number is within an acceptable range for milliseconds [0-999]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateMillisecond = function (value) { return validate(value, 0, 999, "millisecond"); }; /** * Validates the number is within an acceptable range for seconds [0-59]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateSecond = function (value) { return validate(value, 0, 59, "second"); }; /** * Validates the number is within an acceptable range for minutes [0-59]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateMinute = function (value) { return validate(value, 0, 59, "minute"); }; /** * Validates the number is within an acceptable range for hours [0-23]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateHour = function (value) { return validate(value, 0, 23, "hour"); }; /** * Validates the number is within an acceptable range for the days in a month [0-MaxDaysInMonth]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateDay = function (value, year, month) { if (year === undefined || year === null || month === undefined || month === null) { return false;} return validate(value, 1, $D.getDaysInMonth(year, month), "day"); }; /** * Validates the number is within an acceptable range for months [0-11]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateWeek = function (value) { return validate(value, 0, 53, "week"); }; /** * Validates the number is within an acceptable range for months [0-11]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateMonth = function (value) { return validate(value, 0, 11, "month"); }; /** * Validates the number is within an acceptable range for years. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateYear = function (value) { /** * Per ECMAScript spec the range of times supported by Date objects is * exactly -100,000,000 days to +100,000,000 days measured relative to * midnight at the beginning of 01 January, 1970 UTC. * This gives a range of 8,640,000,000,000,000 milliseconds to either * side of 01 January, 1970 UTC. * * Earliest possible date: Tue, 20 Apr 271,822 B.C. 00:00:00 UTC * Latest possible date: Sat, 13 Sep 275,760 00:00:00 UTC */ return validate(value, -271822, 275760, "year"); }; $D.validateTimezone = function(value) { var timezones = {"ACDT":1,"ACST":1,"ACT":1,"ADT":1,"AEDT":1,"AEST":1,"AFT":1,"AKDT":1,"AKST":1,"AMST":1,"AMT":1,"ART":1,"AST":1,"AWDT":1,"AWST":1,"AZOST":1,"AZT":1,"BDT":1,"BIOT":1,"BIT":1,"BOT":1,"BRT":1,"BST":1,"BTT":1,"CAT":1,"CCT":1,"CDT":1,"CEDT":1,"CEST":1,"CET":1,"CHADT":1,"CHAST":1,"CHOT":1,"ChST":1,"CHUT":1,"CIST":1,"CIT":1,"CKT":1,"CLST":1,"CLT":1,"COST":1,"COT":1,"CST":1,"CT":1,"CVT":1,"CWST":1,"CXT":1,"DAVT":1,"DDUT":1,"DFT":1,"EASST":1,"EAST":1,"EAT":1,"ECT":1,"EDT":1,"EEDT":1,"EEST":1,"EET":1,"EGST":1,"EGT":1,"EIT":1,"EST":1,"FET":1,"FJT":1,"FKST":1,"FKT":1,"FNT":1,"GALT":1,"GAMT":1,"GET":1,"GFT":1,"GILT":1,"GIT":1,"GMT":1,"GST":1,"GYT":1,"HADT":1,"HAEC":1,"HAST":1,"HKT":1,"HMT":1,"HOVT":1,"HST":1,"ICT":1,"IDT":1,"IOT":1,"IRDT":1,"IRKT":1,"IRST":1,"IST":1,"JST":1,"KGT":1,"KOST":1,"KRAT":1,"KST":1,"LHST":1,"LINT":1,"MAGT":1,"MART":1,"MAWT":1,"MDT":1,"MET":1,"MEST":1,"MHT":1,"MIST":1,"MIT":1,"MMT":1,"MSK":1,"MST":1,"MUT":1,"MVT":1,"MYT":1,"NCT":1,"NDT":1,"NFT":1,"NPT":1,"NST":1,"NT":1,"NUT":1,"NZDT":1,"NZST":1,"OMST":1,"ORAT":1,"PDT":1,"PET":1,"PETT":1,"PGT":1,"PHOT":1,"PHT":1,"PKT":1,"PMDT":1,"PMST":1,"PONT":1,"PST":1,"PYST":1,"PYT":1,"RET":1,"ROTT":1,"SAKT":1,"SAMT":1,"SAST":1,"SBT":1,"SCT":1,"SGT":1,"SLST":1,"SRT":1,"SST":1,"SYOT":1,"TAHT":1,"THA":1,"TFT":1,"TJT":1,"TKT":1,"TLT":1,"TMT":1,"TOT":1,"TVT":1,"UCT":1,"ULAT":1,"UTC":1,"UYST":1,"UYT":1,"UZT":1,"VET":1,"VLAT":1,"VOLT":1,"VOST":1,"VUT":1,"WAKT":1,"WAST":1,"WAT":1,"WEDT":1,"WEST":1,"WET":1,"WST":1,"YAKT":1,"YEKT":1,"Z":1}; return (timezones[value] === 1); }; $D.validateTimezoneOffset= function(value) { // timezones go from +14hrs to -12hrs, the +X hours are negative offsets. return (value > -841 && value < 721); }; }()); (function () { var $D = Date, $P = $D.prototype, p = function (s, l) { if (!l) { l = 2; } return ("000" + s).slice(l * -1); }; var validateConfigObject = function (obj) { var result = {}, self = this, prop, testFunc; testFunc = function (prop, func, value) { if (prop === "day") { var month = (obj.month !== undefined) ? obj.month : self.getMonth(); var year = (obj.year !== undefined) ? obj.year : self.getFullYear(); return $D[func](value, year, month); } else { return $D[func](value); } }; for (prop in obj) { if (Object.prototype.hasOwnProperty.call(obj, prop)) { var func = "validate" + prop.charAt(0).toUpperCase() + prop.slice(1); if ($D[func] && obj[prop] !== null && testFunc(prop, func, obj[prop])) { result[prop] = obj[prop]; } } } return result; }; /** * Resets the time of this Date object to 12:00 AM (00:00), which is the start of the day. * @param {Boolean} .clone() this date instance before clearing Time * @return {Date} this */ $P.clearTime = function () { this.setHours(0); this.setMinutes(0); this.setSeconds(0); this.setMilliseconds(0); return this; }; /** * Resets the time of this Date object to the current time ('now'). * @return {Date} this */ $P.setTimeToNow = function () { var n = new Date(); this.setHours(n.getHours()); this.setMinutes(n.getMinutes()); this.setSeconds(n.getSeconds()); this.setMilliseconds(n.getMilliseconds()); return this; }; /** * Returns a new Date object that is an exact date and time copy of the original instance. * @return {Date} A new Date instance */ $P.clone = function () { return new Date(this.getTime()); }; /** * Compares this instance to a Date object and returns an number indication of their relative values. * @param {Date} Date object to compare [Required] * @return {Number} -1 = this is lessthan date. 0 = values are equal. 1 = this is greaterthan date. */ $P.compareTo = function (date) { return Date.compare(this, date); }; /** * Compares this instance to another Date object and returns true if they are equal. * @param {Date} Date object to compare. If no date to compare, new Date() [now] is used. * @return {Boolean} true if dates are equal. false if they are not equal. */ $P.equals = function (date) { return Date.equals(this, (date !== undefined ? date : new Date())); }; /** * Determines if this instance is between a range of two dates or equal to either the start or end dates. * @param {Date} Start of range [Required] * @param {Date} End of range [Required] * @return {Boolean} true is this is between or equal to the start and end dates, else false */ $P.between = function (start, end) { return this.getTime() >= start.getTime() && this.getTime() <= end.getTime(); }; /** * Determines if this date occurs after the date to compare to. * @param {Date} Date object to compare. If no date to compare, new Date() ("now") is used. * @return {Boolean} true if this date instance is greater than the date to compare to (or "now"), otherwise false. */ $P.isAfter = function (date) { return this.compareTo(date || new Date()) === 1; }; /** * Determines if this date occurs before the date to compare to. * @param {Date} Date object to compare. If no date to compare, new Date() ("now") is used. * @return {Boolean} true if this date instance is less than the date to compare to (or "now"). */ $P.isBefore = function (date) { return (this.compareTo(date || new Date()) === -1); }; /** * Determines if the current Date instance occurs today. * @return {Boolean} true if this date instance is 'today', otherwise false. */ /** * Determines if the current Date instance occurs on the same Date as the supplied 'date'. * If no 'date' to compare to is provided, the current Date instance is compared to 'today'. * @param {date} Date object to compare. If no date to compare, the current Date ("now") is used. * @return {Boolean} true if this Date instance occurs on the same Day as the supplied 'date'. */ $P.isToday = $P.isSameDay = function (date) { return this.clone().clearTime().equals((date || new Date()).clone().clearTime()); }; /** * Adds the specified number of milliseconds to this instance. * @param {Number} The number of milliseconds to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addMilliseconds = function (value) { if (!value) { return this; } this.setTime(this.getTime() + value * 1); return this; }; /** * Adds the specified number of seconds to this instance. * @param {Number} The number of seconds to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addSeconds = function (value) { if (!value) { return this; } return this.addMilliseconds(value * 1000); }; /** * Adds the specified number of seconds to this instance. * @param {Number} The number of seconds to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addMinutes = function (value) { if (!value) { return this; } return this.addMilliseconds(value * 60000); // 60*1000 }; /** * Adds the specified number of hours to this instance. * @param {Number} The number of hours to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addHours = function (value) { if (!value) { return this; } return this.addMilliseconds(value * 3600000); // 60*60*1000 }; /** * Adds the specified number of days to this instance. * @param {Number} The number of days to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addDays = function (value) { if (!value) { return this; } this.setDate(this.getDate() + value * 1); return this; }; /** * Adds the specified number of weekdays (ie - not sat or sun) to this instance. * @param {Number} The number of days to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addWeekdays = function (value) { if (!value) { return this; } var day = this.getDay(); var weeks = (Math.ceil(Math.abs(value)/7)); if (day === 0 || day === 6) { if (value > 0) { this.next().monday(); this.addDays(-1); day = this.getDay(); } } if (value < 0) { while (value < 0) { this.addDays(-1); day = this.getDay(); if (day !== 0 && day !== 6) { value++; } } return this; } else if (value > 5 || (6-day) <= value) { value = value + (weeks * 2); } return this.addDays(value); }; /** * Adds the specified number of weeks to this instance. * @param {Number} The number of weeks to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addWeeks = function (value) { if (!value) { return this; } return this.addDays(value * 7); }; /** * Adds the specified number of months to this instance. * @param {Number} The number of months to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addMonths = function (value) { if (!value) { return this; } var n = this.getDate(); this.setDate(1); this.setMonth(this.getMonth() + value * 1); this.setDate(Math.min(n, $D.getDaysInMonth(this.getFullYear(), this.getMonth()))); return this; }; $P.addQuarters = function (value) { if (!value) { return this; } // note this will take you to the same point in the quarter as you are now. // i.e. - if you are 15 days into the quarter you'll be 15 days into the resulting one. // bonus: this allows adding fractional quarters return this.addMonths(value * 3); }; /** * Adds the specified number of years to this instance. * @param {Number} The number of years to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addYears = function (value) { if (!value) { return this; } return this.addMonths(value * 12); }; /** * Adds (or subtracts) to the value of the years, months, weeks, days, hours, minutes, seconds, milliseconds of the date instance using given configuration object. Positive and Negative values allowed. * Example

	Date.today().add( { days: 1, months: 1 } )

	new Date().add( { years: -1 } )
	
* @param {Object} Configuration object containing attributes (months, days, etc.) * @return {Date} this */ $P.add = function (config) { if (typeof config === "number") { this._orient = config; return this; } var x = config; if (x.day) { // If we should be a different date than today (eg: for 'tomorrow -1d', etc). // Should only effect parsing, not direct usage (eg, Finish and FinishExact) if ((x.day - this.getDate()) !== 0) { this.setDate(x.day); } } if (x.milliseconds) { this.addMilliseconds(x.milliseconds); } if (x.seconds) { this.addSeconds(x.seconds); } if (x.minutes) { this.addMinutes(x.minutes); } if (x.hours) { this.addHours(x.hours); } if (x.weeks) { this.addWeeks(x.weeks); } if (x.months) { this.addMonths(x.months); } if (x.years) { this.addYears(x.years); } if (x.days) { this.addDays(x.days); } return this; }; /** * Get the week number. Week one (1) is the week which contains the first Thursday of the year. Monday is considered the first day of the week. * The .getWeek() function does NOT convert the date to UTC. The local datetime is used. * Please use .getISOWeek() to get the week of the UTC converted date. * @return {Number} 1 to 53 */ $P.getWeek = function (utc) { // Create a copy of this date object var self, target = new Date(this.valueOf()); if (utc) { target.addMinutes(target.getTimezoneOffset()); self = target.clone(); } else { self = this; } // ISO week date weeks start on monday // so correct the day number var dayNr = (self.getDay() + 6) % 7; // ISO 8601 states that week 1 is the week // with the first thursday of that year. // Set the target date to the thursday in the target week target.setDate(target.getDate() - dayNr + 3); // Store the millisecond value of the target date var firstThursday = target.valueOf(); // Set the target to the first thursday of the year // First set the target to january first target.setMonth(0, 1); // Not a thursday? Correct the date to the next thursday if (target.getDay() !== 4) { target.setMonth(0, 1 + ((4 - target.getDay()) + 7) % 7); } // The weeknumber is the number of weeks between the // first thursday of the year and the thursday in the target week return 1 + Math.ceil((firstThursday - target) / 604800000); // 604800000 = 7 * 24 * 3600 * 1000 }; /** * Get the ISO 8601 week number. Week one ("01") is the week which contains the first Thursday of the year. Monday is considered the first day of the week. * The .getISOWeek() function does convert the date to it's UTC value. Please use .getWeek() to get the week of the local date. * @return {String} "01" to "53" */ $P.getISOWeek = function () { return p(this.getWeek(true)); }; /** * Moves the date to Monday of the week set. Week one (1) is the week which contains the first Thursday of the year. * @param {Number} A Number (1 to 53) that represents the week of the year. * @return {Date} this */ $P.setWeek = function (n) { if ((n - this.getWeek()) === 0) { if (this.getDay() !== 1) { return this.moveToDayOfWeek(1, (this.getDay() > 1 ? -1 : 1)); } else { return this; } } else { return this.moveToDayOfWeek(1, (this.getDay() > 1 ? -1 : 1)).addWeeks(n - this.getWeek()); } }; $P.setQuarter = function (qtr) { var month = Math.abs(((qtr-1) * 3) + 1); return this.setMonth(month, 1); }; $P.getQuarter = function () { return Date.getQuarter(this); }; $P.getDaysLeftInQuarter = function () { return Date.getDaysLeftInQuarter(this); }; /** * Moves the date to the next n'th occurrence of the dayOfWeek starting from the beginning of the month. The number (-1) is a magic number and will return the last occurrence of the dayOfWeek in the month. * @param {Number} The dayOfWeek to move to * @param {Number} The n'th occurrence to move to. Use (-1) to return the last occurrence in the month * @return {Date} this */ $P.moveToNthOccurrence = function (dayOfWeek, occurrence) { if (dayOfWeek === "Weekday") { if (occurrence > 0) { this.moveToFirstDayOfMonth(); if (this.is().weekday()) { occurrence -= 1; } } else if (occurrence < 0) { this.moveToLastDayOfMonth(); if (this.is().weekday()) { occurrence += 1; } } else { return this; } return this.addWeekdays(occurrence); } var shift = 0; if (occurrence > 0) { shift = occurrence - 1; } else if (occurrence === -1) { this.moveToLastDayOfMonth(); if (this.getDay() !== dayOfWeek) { this.moveToDayOfWeek(dayOfWeek, -1); } return this; } return this.moveToFirstDayOfMonth().addDays(-1).moveToDayOfWeek(dayOfWeek, +1).addWeeks(shift); }; var moveToN = function (getFunc, addFunc, nVal) { return function (value, orient) { var diff = (value - this[getFunc]() + nVal * (orient || +1)) % nVal; return this[addFunc]((diff === 0) ? diff += nVal * (orient || +1) : diff); }; }; /** * Move to the next or last dayOfWeek based on the orient value. * @param {Number} The dayOfWeek to move to * @param {Number} Forward (+1) or Back (-1). Defaults to +1. [Optional] * @return {Date} this */ $P.moveToDayOfWeek = moveToN("getDay", "addDays", 7); /** * Move to the next or last month based on the orient value. * @param {Number} The month to move to. 0 = January, 11 = December * @param {Number} Forward (+1) or Back (-1). Defaults to +1. [Optional] * @return {Date} this */ $P.moveToMonth = moveToN("getMonth", "addMonths", 12); /** * Get the Ordinate of the current day ("th", "st", "rd"). * @return {String} */ $P.getOrdinate = function () { var num = this.getDate(); return ord(num); }; /** * Get the Ordinal day (numeric day number) of the year, adjusted for leap year. * @return {Number} 1 through 365 (366 in leap years) */ $P.getOrdinalNumber = function () { return Math.ceil((this.clone().clearTime() - new Date(this.getFullYear(), 0, 1)) / 86400000) + 1; }; /** * Get the time zone abbreviation of the current date. * @return {String} The abbreviated time zone name (e.g. "EST") */ $P.getTimezone = function () { return $D.getTimezoneAbbreviation(this.getUTCOffset(), this.isDaylightSavingTime()); }; $P.setTimezoneOffset = function (offset) { var here = this.getTimezoneOffset(), there = Number(offset) * -6 / 10; return (there || there === 0) ? this.addMinutes(there - here) : this; }; $P.setTimezone = function (offset) { return this.setTimezoneOffset($D.getTimezoneOffset(offset)); }; /** * Indicates whether Daylight Saving Time is observed in the current time zone. * @return {Boolean} true|false */ $P.hasDaylightSavingTime = function () { return (Date.today().set({month: 0, day: 1}).getTimezoneOffset() !== Date.today().set({month: 6, day: 1}).getTimezoneOffset()); }; /** * Indicates whether this Date instance is within the Daylight Saving Time range for the current time zone. * @return {Boolean} true|false */ $P.isDaylightSavingTime = function () { return Date.today().set({month: 0, day: 1}).getTimezoneOffset() !== this.getTimezoneOffset(); }; /** * Get the offset from UTC of the current date. * @return {String} The 4-character offset string prefixed with + or - (e.g. "-0500") */ $P.getUTCOffset = function (offset) { var n = (offset || this.getTimezoneOffset()) * -10 / 6, r; if (n < 0) { r = (n - 10000).toString(); return r.charAt(0) + r.substr(2); } else { r = (n + 10000).toString(); return "+" + r.substr(1); } }; /** * Returns the number of milliseconds between this date and date. * @param {Date} Defaults to now * @return {Number} The diff in milliseconds */ $P.getElapsed = function (date) { return (date || new Date()) - this; }; /** * Set the value of year, month, day, hour, minute, second, millisecond of date instance using given configuration object. * Example

	Date.today().set( { day: 20, month: 1 } )

	new Date().set( { millisecond: 0 } )
	
* * @param {Object} Configuration object containing attributes (month, day, etc.) * @return {Date} this */ $P.set = function (config) { config = validateConfigObject.call(this, config); var key; for (key in config) { if (Object.prototype.hasOwnProperty.call(config, key)) { var name = key.charAt(0).toUpperCase() + key.slice(1); var addFunc, getFunc; if (key !== "week" && key !== "month" && key !== "timezone" && key !== "timezoneOffset") { name += "s"; } addFunc = "add" + name; getFunc = "get" + name; if (key === "month") { addFunc = addFunc + "s"; } else if (key === "year"){ getFunc = "getFullYear"; } if (key !== "day" && key !== "timezone" && key !== "timezoneOffset" && key !== "week" && key !== "hour") { this[addFunc](config[key] - this[getFunc]()); } else if ( key === "timezone"|| key === "timezoneOffset" || key === "week" || key === "hour") { this["set"+name](config[key]); } } } // day has to go last because you can't validate the day without first knowing the month if (config.day) { this.addDays(config.day - this.getDate()); } return this; }; /** * Moves the date to the first day of the month. * @return {Date} this */ $P.moveToFirstDayOfMonth = function () { return this.set({ day: 1 }); }; /** * Moves the date to the last day of the month. * @return {Date} this */ $P.moveToLastDayOfMonth = function () { return this.set({ day: $D.getDaysInMonth(this.getFullYear(), this.getMonth())}); }; /** * Converts the value of the current Date object to its equivalent string representation. * Format Specifiers * CUSTOM DATE AND TIME FORMAT STRINGS * Format Description Example * ------ --------------------------------------------------------------------------- ----------------------- * s The seconds of the minute between 0-59. "0" to "59" * ss The seconds of the minute with leading zero if required. "00" to "59" * * m The minute of the hour between 0-59. "0" or "59" * mm The minute of the hour with leading zero if required. "00" or "59" * * h The hour of the day between 1-12. "1" to "12" * hh The hour of the day with leading zero if required. "01" to "12" * * H The hour of the day between 0-23. "0" to "23" * HH The hour of the day with leading zero if required. "00" to "23" * * d The day of the month between 1 and 31. "1" to "31" * dd The day of the month with leading zero if required. "01" to "31" * ddd Abbreviated day name. Date.CultureInfo.abbreviatedDayNames. "Mon" to "Sun" * dddd The full day name. Date.CultureInfo.dayNames. "Monday" to "Sunday" * * M The month of the year between 1-12. "1" to "12" * MM The month of the year with leading zero if required. "01" to "12" * MMM Abbreviated month name. Date.CultureInfo.abbreviatedMonthNames. "Jan" to "Dec" * MMMM The full month name. Date.CultureInfo.monthNames. "January" to "December" * * yy The year as a two-digit number. "99" or "08" * yyyy The full four digit year. "1999" or "2008" * * t Displays the first character of the A.M./P.M. designator. "A" or "P" * Date.CultureInfo.amDesignator or Date.CultureInfo.pmDesignator * tt Displays the A.M./P.M. designator. "AM" or "PM" * Date.CultureInfo.amDesignator or Date.CultureInfo.pmDesignator * * S The ordinal suffix ("st, "nd", "rd" or "th") of the current day. "st, "nd", "rd" or "th" * * STANDARD DATE AND TIME FORMAT STRINGS * Format Description Example *------ --------------------------------------------------------------------------- ----------------------- * d The CultureInfo shortDate Format Pattern "M/d/yyyy" * D The CultureInfo longDate Format Pattern "dddd, MMMM dd, yyyy" * F The CultureInfo fullDateTime Format Pattern "dddd, MMMM dd, yyyy h:mm:ss tt" * m The CultureInfo monthDay Format Pattern "MMMM dd" * r The CultureInfo rfc1123 Format Pattern "ddd, dd MMM yyyy HH:mm:ss GMT" * s The CultureInfo sortableDateTime Format Pattern "yyyy-MM-ddTHH:mm:ss" * t The CultureInfo shortTime Format Pattern "h:mm tt" * T The CultureInfo longTime Format Pattern "h:mm:ss tt" * u The CultureInfo universalSortableDateTime Format Pattern "yyyy-MM-dd HH:mm:ssZ" * y The CultureInfo yearMonth Format Pattern "MMMM, yyyy" * * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @return {String} A string representation of the current Date object. */ var ord = function (n) { switch (n * 1) { case 1: case 21: case 31: return "st"; case 2: case 22: return "nd"; case 3: case 23: return "rd"; default: return "th"; } }; var parseStandardFormats = function (format) { var y, c = Date.CultureInfo.formatPatterns; switch (format) { case "d": return this.toString(c.shortDate); case "D": return this.toString(c.longDate); case "F": return this.toString(c.fullDateTime); case "m": return this.toString(c.monthDay); case "r": case "R": y = this.clone().addMinutes(this.getTimezoneOffset()); return y.toString(c.rfc1123) + " GMT"; case "s": return this.toString(c.sortableDateTime); case "t": return this.toString(c.shortTime); case "T": return this.toString(c.longTime); case "u": y = this.clone().addMinutes(this.getTimezoneOffset()); return y.toString(c.universalSortableDateTime); case "y": return this.toString(c.yearMonth); default: return false; } }; var parseFormatStringsClosure = function (context) { return function (m) { if (m.charAt(0) === "\\") { return m.replace("\\", ""); } switch (m) { case "hh": return p(context.getHours() < 13 ? (context.getHours() === 0 ? 12 : context.getHours()) : (context.getHours() - 12)); case "h": return context.getHours() < 13 ? (context.getHours() === 0 ? 12 : context.getHours()) : (context.getHours() - 12); case "HH": return p(context.getHours()); case "H": return context.getHours(); case "mm": return p(context.getMinutes()); case "m": return context.getMinutes(); case "ss": return p(context.getSeconds()); case "s": return context.getSeconds(); case "yyyy": return p(context.getFullYear(), 4); case "yy": return p(context.getFullYear()); case "y": return context.getFullYear(); case "E": case "dddd": return Date.CultureInfo.dayNames[context.getDay()]; case "ddd": return Date.CultureInfo.abbreviatedDayNames[context.getDay()]; case "dd": return p(context.getDate()); case "d": return context.getDate(); case "MMMM": return Date.CultureInfo.monthNames[context.getMonth()]; case "MMM": return Date.CultureInfo.abbreviatedMonthNames[context.getMonth()]; case "MM": return p((context.getMonth() + 1)); case "M": return context.getMonth() + 1; case "t": return context.getHours() < 12 ? Date.CultureInfo.amDesignator.substring(0, 1) : Date.CultureInfo.pmDesignator.substring(0, 1); case "tt": return context.getHours() < 12 ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator; case "S": return ord(context.getDate()); case "W": return context.getWeek(); case "WW": return context.getISOWeek(); case "Q": return "Q" + context.getQuarter(); case "q": return String(context.getQuarter()); case "z": return context.getTimezone(); case "Z": case "X": return Date.getTimezoneOffset(context.getTimezone()); case "ZZ": // Timezone offset in seconds return context.getTimezoneOffset() * -60; case "u": return context.getDay(); case "L": return ($D.isLeapYear(context.getFullYear())) ? 1 : 0; case "B": // Swatch Internet Time (.beats) return "@"+((context.getUTCSeconds() + (context.getUTCMinutes()*60) + ((context.getUTCHours()+1)*3600))/86.4); default: return m; } }; }; $P.toString = function (format, ignoreStandards) { // Standard Date and Time Format Strings. Formats pulled from CultureInfo file and // may vary by culture. if (!ignoreStandards && format && format.length === 1) { output = parseStandardFormats.call(this, format); if (output) { return output; } } var parseFormatStrings = parseFormatStringsClosure(this); return format ? format.replace(/((\\)?(dd?d?d?|MM?M?M?|yy?y?y?|hh?|HH?|mm?|ss?|tt?|S|q|Q|WW?W?W?)(?![^\[]*\]))/g, parseFormatStrings).replace(/\[|\]/g, "") : this._toString(); }; }()); /************************************************************* * SugarPak - Domain Specific Language - Syntactical Sugar * *************************************************************/ (function () { var $D = Date, $P = $D.prototype, $N = Number.prototype; // private $P._orient = +1; // private $P._nth = null; // private $P._is = false; // private $P._same = false; // private $P._isSecond = false; // private $N._dateElement = "days"; /** * Moves the date to the next instance of a date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.today().next().friday();
	Date.today().next().fri();
	Date.today().next().march();
	Date.today().next().mar();
	Date.today().next().week();
	
* * @return {Date} date */ $P.next = function () { this._move = true; this._orient = +1; return this; }; /** * Creates a new Date (Date.today()) and moves the date to the next instance of the date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.next().friday();
	Date.next().fri();
	Date.next().march();
	Date.next().mar();
	Date.next().week();
	
* * @return {Date} date */ $D.next = function () { return $D.today().next(); }; /** * Moves the date to the previous instance of a date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.today().last().friday();
	Date.today().last().fri();
	Date.today().last().march();
	Date.today().last().mar();
	Date.today().last().week();
	
* * @return {Date} date */ $P.last = $P.prev = $P.previous = function () { this._move = true; this._orient = -1; return this; }; /** * Creates a new Date (Date.today()) and moves the date to the previous instance of the date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.last().friday();
	Date.last().fri();
	Date.previous().march();
	Date.prev().mar();
	Date.last().week();
	
* * @return {Date} date */ $D.last = $D.prev = $D.previous = function () { return $D.today().last(); }; /** * Performs a equality check when followed by either a month name, day name or .weekday() function. * Example

	Date.today().is().friday(); // true|false
	Date.today().is().fri();
	Date.today().is().march();
	Date.today().is().mar();
	
* * @return {Boolean} true|false */ $P.is = function () { this._is = true; return this; }; /** * Determines if two date objects occur on/in exactly the same instance of the subsequent date part function. * The function .same() must be followed by a date part function (example: .day(), .month(), .year(), etc). * * An optional Date can be passed in the date part function. If now date is passed as a parameter, 'Now' is used. * * The following example demonstrates how to determine if two dates fall on the exact same day. * * Example

	var d1 = Date.today(); // today at 00:00
	var d2 = new Date();   // exactly now.

	// Do they occur on the same day?
	d1.same().day(d2); // true
	
	// Do they occur on the same hour?
	d1.same().hour(d2); // false, unless d2 hour is '00' (midnight).
	
	// What if it's the same day, but one year apart?
	var nextYear = Date.today().add(1).year();

	d1.same().day(nextYear); // false, because the dates must occur on the exact same day. 
	
* * Scenario: Determine if a given date occurs during some week period 2 months from now. * * Example

	var future = Date.today().add(2).months();
	return someDate.same().week(future); // true|false;
	
* * @return {Boolean} true|false */ $P.same = function () { this._same = true; this._isSecond = false; return this; }; /** * Determines if the current date/time occurs during Today. Must be preceded by the .is() function. * Example

	someDate.is().today();    // true|false
	new Date().is().today();  // true
	Date.today().is().today();// true
	Date.today().add(-1).day().is().today(); // false
	
* * @return {Boolean} true|false */ $P.today = function () { return this.same().day(); }; /** * Determines if the current date is a weekday. This function must be preceded by the .is() function. * Example

	Date.today().is().weekday(); // true|false
	
* * @return {Boolean} true|false */ $P.weekday = function () { if (this._nth) { return df("Weekday").call(this); } if (this._move) { return this.addWeekdays(this._orient); } if (this._is) { this._is = false; return (!this.is().sat() && !this.is().sun()); } return false; }; /** * Determines if the current date is on the weekend. This function must be preceded by the .is() function. * Example

	Date.today().is().weekend(); // true|false
	
* * @return {Boolean} true|false */ $P.weekend = function () { if (this._is) { this._is = false; return (this.is().sat() || this.is().sun()); } return false; }; /** * Sets the Time of the current Date instance. A string "6:15 pm" or config object {hour:18, minute:15} are accepted. * Example

	// Set time to 6:15pm with a String
	Date.today().at("6:15pm");

	// Set time to 6:15pm with a config object
	Date.today().at({hour:18, minute:15});
	
* * @return {Date} date */ $P.at = function (time) { return (typeof time === "string") ? $D.parse(this.toString("d") + " " + time) : this.set(time); }; /** * Creates a new Date() and adds this (Number) to the date based on the preceding date element function (eg. second|minute|hour|day|month|year). * Example

	// Undeclared Numbers must be wrapped with parentheses. Requirment of JavaScript.
	(3).days().fromNow();
	(6).months().fromNow();

	// Declared Number variables do not require parentheses. 
	var n = 6;
	n.months().fromNow();
	
* * @return {Date} A new Date instance */ $N.fromNow = $N.after = function (date) { var c = {}; c[this._dateElement] = this; return ((!date) ? new Date() : date.clone()).add(c); }; /** * Creates a new Date() and subtract this (Number) from the date based on the preceding date element function (eg. second|minute|hour|day|month|year). * Example

	// Undeclared Numbers must be wrapped with parentheses. Requirment of JavaScript.
	(3).days().ago();
	(6).months().ago();

	// Declared Number variables do not require parentheses. 
	var n = 6;
	n.months().ago();
	
* * @return {Date} A new Date instance */ $N.ago = $N.before = function (date) { var c = {}, s = (this._dateElement[this._dateElement.length-1] !== "s") ? this._dateElement + "s" : this._dateElement; c[s] = this * -1; return ((!date) ? new Date() : date.clone()).add(c); }; // Do NOT modify the following string tokens. These tokens are used to build dynamic functions. // All culture-specific strings can be found in the CultureInfo files. var dx = ("sunday monday tuesday wednesday thursday friday saturday").split(/\s/), mx = ("january february march april may june july august september october november december").split(/\s/), px = ("Millisecond Second Minute Hour Day Week Month Year Quarter Weekday").split(/\s/), pxf = ("Milliseconds Seconds Minutes Hours Date Week Month FullYear Quarter").split(/\s/), nth = ("final first second third fourth fifth").split(/\s/), de; /** * Returns an object literal of all the date parts. * Example

	var o = new Date().toObject();
	
	// { year: 2008, month: 4, week: 20, day: 13, hour: 18, minute: 9, second: 32, millisecond: 812 }
	
	// The object properties can be referenced directly from the object.
	
	alert(o.day);  // alerts "13"
	alert(o.year); // alerts "2008"
	
* * @return {Date} An object literal representing the original date object. */ $P.toObject = function () { var o = {}; for (var i = 0; i < px.length; i++) { if (this["get" + pxf[i]]) { o[px[i].toLowerCase()] = this["get" + pxf[i]](); } } return o; }; /** * Returns a date created from an object literal. Ignores the .week property if set in the config. * Example

	var o = new Date().toObject();
	
	return Date.fromObject(o); // will return the same date. 

	var o2 = {month: 1, day: 20, hour: 18}; // birthday party!
	Date.fromObject(o2);
	
* * @return {Date} An object literal representing the original date object. */ $D.fromObject = function(config) { config.week = null; return Date.today().set(config); }; // Create day name functions and abbreviated day name functions (eg. monday(), friday(), fri()). var df = function (n) { return function () { if (this._is) { this._is = false; return this.getDay() === n; } if (this._move) { this._move = null; } if (this._nth !== null) { // If the .second() function was called earlier, remove the _orient // from the date, and then continue. // This is required because 'second' can be used in two different context. // // Example // // Date.today().add(1).second(); // Date.march().second().monday(); // // Things get crazy with the following... // Date.march().add(1).second().second().monday(); // but it works!! // if (this._isSecond) { this.addSeconds(this._orient * -1); } // make sure we reset _isSecond this._isSecond = false; var ntemp = this._nth; this._nth = null; var temp = this.clone().moveToLastDayOfMonth(); this.moveToNthOccurrence(n, ntemp); if (this > temp) { throw new RangeError($D.getDayName(n) + " does not occur " + ntemp + " times in the month of " + $D.getMonthName(temp.getMonth()) + " " + temp.getFullYear() + "."); } return this; } return this.moveToDayOfWeek(n, this._orient); }; }; var sdf = function (n) { return function () { var t = $D.today(), shift = n - t.getDay(); if (n === 0 && Date.CultureInfo.firstDayOfWeek === 1 && t.getDay() !== 0) { shift = shift + 7; } return t.addDays(shift); }; }; // Create month name functions and abbreviated month name functions (eg. january(), march(), mar()). var month_instance_functions = function (n) { return function () { if (this._is) { this._is = false; return this.getMonth() === n; } return this.moveToMonth(n, this._orient); }; }; var month_static_functions = function (n) { return function () { return $D.today().set({ month: n, day: 1 }); }; }; var processTerms = function (names, staticFunc, instanceFunc) { for (var i = 0; i < names.length; i++) { // Create constant static Name variables. $D[names[i].toUpperCase()] = $D[names[i].toUpperCase().substring(0, 3)] = i; // Create Name functions. $D[names[i]] = $D[names[i].substring(0, 3)] = staticFunc(i); // Create Name instance functions. $P[names[i]] = $P[names[i].substring(0, 3)] = instanceFunc(i); } }; processTerms(dx, sdf, df); processTerms(mx, month_static_functions, month_instance_functions); // Create date element functions and plural date element functions used with Date (eg. day(), days(), months()). var ef = function (j) { return function () { // if the .second() function was called earlier, the _orient // has alread been added. Just return this and reset _isSecond. if (this._isSecond) { this._isSecond = false; return this; } if (this._same) { this._same = this._is = false; var o1 = this.toObject(), o2 = (arguments[0] || new Date()).toObject(), v = "", k = j.toLowerCase(); // the substr trick with -1 doesn't work in IE8 or less k = (k[k.length-1] === "s") ? k.substring(0,k.length-1) : k; for (var m = (px.length - 1); m > -1; m--) { v = px[m].toLowerCase(); if (o1[v] !== o2[v]) { return false; } if (k === v) { break; } } return true; } if (j.substring(j.length - 1) !== "s") { j += "s"; } if (this._move) { this._move = null; } return this["add" + j](this._orient); }; }; var nf = function (n) { return function () { this._dateElement = n; return this; }; }; for (var k = 0; k < px.length; k++) { de = px[k].toLowerCase(); if(de !== "weekday") { // Create date element functions and plural date element functions used with Date (eg. day(), days(), months()). $P[de] = $P[de + "s"] = ef(px[k]); // Create date element functions and plural date element functions used with Number (eg. day(), days(), months()). $N[de] = $N[de + "s"] = nf(de + "s"); } } $P._ss = ef("Second"); var nthfn = function (n) { return function (dayOfWeek) { if (this._same) { return this._ss(arguments[0]); } if (dayOfWeek || dayOfWeek === 0) { return this.moveToNthOccurrence(dayOfWeek, n); } this._nth = n; // if the operator is 'second' add the _orient, then deal with it later... if (n === 2 && (dayOfWeek === undefined || dayOfWeek === null)) { this._isSecond = true; return this.addSeconds(this._orient); } return this; }; }; for (var l = 0; l < nth.length; l++) { $P[nth[l]] = (l === 0) ? nthfn(-1) : nthfn(l); } }()); (function () { "use strict"; Date.Parsing = { Exception: function (s) { this.message = "Parse error at '" + s.substring(0, 10) + " ...'"; } }; var $P = Date.Parsing; var dayOffsets = { standard: [0,31,59,90,120,151,181,212,243,273,304,334], leap: [0,31,60,91,121,152,182,213,244,274,305,335] }; $P.isLeapYear = function(year) { return ((year % 4 === 0) && (year % 100 !== 0)) || (year % 400 === 0); }; var utils = { multiReplace : function (str, hash ) { var key; for (key in hash) { if (Object.prototype.hasOwnProperty.call(hash, key)) { var regex; if (typeof hash[key] === "function") { } else { regex = (hash[key] instanceof RegExp) ? hash[key] : new RegExp(hash[key], "g"); } str = str.replace(regex, key); } } return str; }, getDayOfYearFromWeek : function (obj) { var d, jan4, offset; obj.weekDay = (!obj.weekDay && obj.weekDay !== 0) ? 1 : obj.weekDay; d = new Date(obj.year, 0, 4); jan4 = d.getDay() === 0 ? 7 : d.getDay(); // JS is 0 indexed on Sunday. offset = jan4+3; obj.dayOfYear = ((obj.week * 7) + (obj.weekDay === 0 ? 7 : obj.weekDay))-offset; return obj; }, getDayOfYear : function (obj, dayOffset) { if (!obj.dayOfYear) { obj = utils.getDayOfYearFromWeek(obj); } for (var i=0;i <= dayOffset.length;i++) { if (obj.dayOfYear < dayOffset[i] || i === dayOffset.length) { obj.day = obj.day ? obj.day : (obj.dayOfYear - dayOffset[i-1]); break; } else { obj.month = i; } } return obj; }, adjustForTimeZone : function (obj, date) { var offset; if (obj.zone.toUpperCase() === "Z" || (obj.zone_hours === 0 && obj.zone_minutes === 0)) { // it's UTC/GML so work out the current timeszone offset offset = -date.getTimezoneOffset(); } else { offset = (obj.zone_hours*60) + (obj.zone_minutes || 0); if (obj.zone_sign === "+") { offset *= -1; } offset -= date.getTimezoneOffset(); } date.setMinutes(date.getMinutes()+offset); return date; }, setDefaults : function (obj) { obj.year = obj.year || Date.today().getFullYear(); obj.hours = obj.hours || 0; obj.minutes = obj.minutes || 0; obj.seconds = obj.seconds || 0; obj.milliseconds = obj.milliseconds || 0; if (!(!obj.month && (obj.week || obj.dayOfYear))) { // if we have a month, or if we don't but don't have the day calculation data obj.month = obj.month || 0; obj.day = obj.day || 1; } return obj; }, dataNum: function (data, mod, explict, postProcess) { var dataNum = data*1; if (mod) { if (postProcess) { return data ? mod(data)*1 : data; } else { return data ? mod(dataNum) : data; } } else if (!explict){ return data ? dataNum : data; } else { return (data && typeof data !== "undefined") ? dataNum : data; } }, timeDataProcess: function (obj) { var timeObj = {}; for (var x in obj.data) { if (obj.data.hasOwnProperty(x)) { timeObj[x] = obj.ignore[x] ? obj.data[x] : utils.dataNum(obj.data[x], obj.mods[x], obj.explict[x], obj.postProcess[x]); } } if (obj.data.secmins) { obj.data.secmins = obj.data.secmins.replace(",", ".") * 60; if (!timeObj.minutes) { timeObj.minutes = obj.data.secmins; } else if (!timeObj.seconds) { timeObj.seconds = obj.data.secmins; } delete obj.secmins; } return timeObj; }, buildTimeObjectFromData: function (data) { var time = utils.timeDataProcess({ data: { year : data[1], month : data[5], day : data[7], week : data[8], dayOfYear : data[10], hours : data[15], zone_hours : data[23], zone_minutes : data[24], zone : data[21], zone_sign : data[22], weekDay : data[9], minutes: data[16], seconds: data[19], milliseconds: data[20], secmins: data[18] }, mods: { month: function(data) { return data-1; }, weekDay: function (data) { data = Math.abs(data); return (data === 7 ? 0 : data); }, minutes: function (data) { return data.replace(":",""); }, seconds: function (data) { return Math.floor( (data.replace(":","").replace(",","."))*1 ); }, milliseconds: function (data) { return (data.replace(",",".")*1000); } }, postProcess: { minutes: true, seconds: true, milliseconds: true }, explict: { zone_hours: true, zone_minutes: true }, ignore: { zone: true, zone_sign: true, secmins: true } }); return time; }, addToHash: function (hash, keys, data) { keys = keys; data = data; var len = keys.length; for (var i = 0; i < len; i++) { hash[keys[i]] = data[i]; } return hash; }, combineRegex: function (r1, r2) { return new RegExp("(("+r1.source+")\\s("+r2.source+"))"); }, getDateNthString: function(add, last, inc){ if (add) { return Date.today().addDays(inc).toString("d"); } else if (last) { return Date.today().last()[inc]().toString("d"); } }, buildRegexData: function (array) { var arr = []; var len = array.length; for (var i=0; i < len; i++) { if (Object.prototype.toString.call(array[i]) === '[object Array]') { // oldIE compat version of Array.isArray arr.push(this.combineRegex(array[i][0], array[i][1])); } else { arr.push(array[i]); } } return arr; } }; $P.processTimeObject = function (obj) { var date, dayOffset; utils.setDefaults(obj); dayOffset = ($P.isLeapYear(obj.year)) ? dayOffsets.leap : dayOffsets.standard; if (!obj.month && (obj.week || obj.dayOfYear)) { utils.getDayOfYear(obj, dayOffset); } else { obj.dayOfYear = dayOffset[obj.month] + obj.day; } date = new Date(obj.year, obj.month, obj.day, obj.hours, obj.minutes, obj.seconds, obj.milliseconds); if (obj.zone) { utils.adjustForTimeZone(obj, date); // adjust (and calculate) for timezone } return date; }; $P.ISO = { regex : /^([\+-]?\d{4}(?!\d{2}\b))((-?)((0[1-9]|1[0-2])(\3([12]\d|0[1-9]|3[01]))?|W([0-4]\d|5[0-3])(-?[1-7])?|(00[1-9]|0[1-9]\d|[12]\d{2}|3([0-5]\d|6[1-6])))([T\s]((([01]\d|2[0-4])((:?)[0-5]\d)?|24\:?00)([\.,]\d+(?!:))?)?(\17[0-5]\d([\.,]\d+)?)?\s?([zZ]|([\+-])([01]\d|2[0-3]):?([0-5]\d)?)?)?)?$/, parse : function (s) { var time, data = s.match(this.regex); if (!data || !data.length) { return null; } time = utils.buildTimeObjectFromData(data); if (!time.year || (!time.year && (!time.month && !time.day) && (!time.week && !time.dayOfYear)) ) { return null; } return $P.processTimeObject(time); } }; $P.Numeric = { isNumeric: function (e){return!isNaN(parseFloat(e))&&isFinite(e);}, regex: /\b([0-1]?[0-9])([0-3]?[0-9])([0-2]?[0-9]?[0-9][0-9])\b/i, parse: function (s) { var data, i, time = {}, order = Date.CultureInfo.dateElementOrder.split(""); if (!(this.isNumeric(s)) || // if it's non-numeric OR (s[0] === "+" && s[0] === "-")) { // It's an arithmatic string (eg +/-1000) return null; } if (s.length < 5 && s.indexOf(".") < 0 && s.indexOf("/") < 0) { // assume it's just a year. time.year = s; return $P.processTimeObject(time); } data = s.match(this.regex); if (!data || !data.length) { return null; } for (i=0; i < order.length; i++) { switch(order[i]) { case "d": time.day = data[i+1]; break; case "m": time.month = (data[i+1]-1); break; case "y": time.year = data[i+1]; break; } } return $P.processTimeObject(time); } }; $P.Normalizer = { regexData: function () { var $R = Date.CultureInfo.regexPatterns; return utils.buildRegexData([ $R.tomorrow, $R.yesterday, [$R.past, $R.mon], [$R.past, $R.tue], [$R.past, $R.wed], [$R.past, $R.thu], [$R.past, $R.fri], [$R.past, $R.sat], [$R.past, $R.sun] ]); }, basicReplaceHash : function() { var $R = Date.CultureInfo.regexPatterns; return { "January": $R.jan.source, "February": $R.feb, "March": $R.mar, "April": $R.apr, "May": $R.may, "June": $R.jun, "July": $R.jul, "August": $R.aug, "September": $R.sep, "October": $R.oct, "November": $R.nov, "December": $R.dec, "": /\bat\b/gi, " ": /\s{2,}/, "am": $R.inTheMorning, "9am": $R.thisMorning, "pm": $R.inTheEvening, "7pm":$R.thisEvening }; }, keys : function(){ return [ utils.getDateNthString(true, false, 1), // tomorrow utils.getDateNthString(true, false, -1), // yesterday utils.getDateNthString(false, true, "monday"), //last mon utils.getDateNthString(false, true, "tuesday"), //last tues utils.getDateNthString(false, true, "wednesday"), //last wed utils.getDateNthString(false, true, "thursday"), //last thurs utils.getDateNthString(false, true, "friday"), //last fri utils.getDateNthString(false, true, "saturday"), //last sat utils.getDateNthString(false, true, "sunday") //last sun ]; }, buildRegexFunctions: function () { var $R = Date.CultureInfo.regexPatterns; var __ = Date.i18n.__; var tomorrowRE = new RegExp("(\\b\\d\\d?("+__("AM")+"|"+__("PM")+")? )("+$R.tomorrow.source.slice(1)+")", "i"); // adapted tomorrow regex for AM PM relative dates var todayRE = new RegExp($R.today.source + "(?!\\s*([+-]))\\b"); // today, but excludes the math operators (eg "today + 2h") this.replaceFuncs = [ [todayRE, function (full) { return (full.length > 1) ? Date.today().toString("d") : full; }], [tomorrowRE, function(full, m1) { var t = Date.today().addDays(1).toString("d"); return (t + " " + m1); }], [$R.amThisMorning, function(str, am){return am;}], [$R.pmThisEvening, function(str, pm){return pm;}] ]; }, buildReplaceData: function () { this.buildRegexFunctions(); this.replaceHash = utils.addToHash(this.basicReplaceHash(), this.keys(), this.regexData()); }, stringReplaceFuncs: function (s) { for (var i=0; i < this.replaceFuncs.length; i++) { s = s.replace(this.replaceFuncs[i][0], this.replaceFuncs[i][1]); } return s; }, parse: function (s) { s = this.stringReplaceFuncs(s); s = utils.multiReplace(s, this.replaceHash); try { var n = s.split(/([\s\-\.\,\/\x27]+)/); if (n.length === 3 && $P.Numeric.isNumeric(n[0]) && $P.Numeric.isNumeric(n[2]) && (n[2].length >= 4)) { // ok, so we're dealing with x/year. But that's not a full date. // This fixes wonky dateElementOrder parsing when set to dmy order. if (Date.CultureInfo.dateElementOrder[0] === "d") { s = "1/" + n[0] + "/" + n[2]; // set to 1st of month and normalize the seperator } } } catch (e) {} return s; } }; $P.Normalizer.buildReplaceData(); }()); (function () { var $P = Date.Parsing; var _ = $P.Operators = { // // Tokenizers // rtoken: function (r) { // regex token return function (s) { var mx = s.match(r); if (mx) { return ([ mx[0], s.substring(mx[0].length) ]); } else { throw new $P.Exception(s); } }; }, token: function () { // whitespace-eating token return function (s) { return _.rtoken(new RegExp("^\\s*" + s + "\\s*"))(s); }; }, stoken: function (s) { // string token return _.rtoken(new RegExp("^" + s)); }, // Atomic Operators until: function (p) { return function (s) { var qx = [], rx = null; while (s.length) { try { rx = p.call(this, s); } catch (e) { qx.push(rx[0]); s = rx[1]; continue; } break; } return [ qx, s ]; }; }, many: function (p) { return function (s) { var rx = [], r = null; while (s.length) { try { r = p.call(this, s); } catch (e) { return [ rx, s ]; } rx.push(r[0]); s = r[1]; } return [ rx, s ]; }; }, // generator operators -- see below optional: function (p) { return function (s) { var r = null; try { r = p.call(this, s); } catch (e) { return [ null, s ]; } return [ r[0], r[1] ]; }; }, not: function (p) { return function (s) { try { p.call(this, s); } catch (e) { return [null, s]; } throw new $P.Exception(s); }; }, ignore: function (p) { return p ? function (s) { var r = null; r = p.call(this, s); return [null, r[1]]; } : null; }, product: function () { var px = arguments[0], qx = Array.prototype.slice.call(arguments, 1), rx = []; for (var i = 0 ; i < px.length ; i++) { rx.push(_.each(px[i], qx)); } return rx; }, cache: function (rule) { var cache = {}, cache_length = 0, cache_keys = [], CACHE_MAX = Date.Config.CACHE_MAX || 100000, r = null; var cacheCheck = function () { if (cache_length === CACHE_MAX) { // kill several keys, don't want to have to do this all the time... for (var i=0; i < 10; i++) { var key = cache_keys.shift(); if (key) { delete cache[key]; cache_length--; } } } }; return function (s) { cacheCheck(); try { r = cache[s] = (cache[s] || rule.call(this, s)); } catch (e) { r = cache[s] = e; } cache_length++; cache_keys.push(s); if (r instanceof $P.Exception) { throw r; } else { return r; } }; }, // vector operators -- see below any: function () { var px = arguments; return function (s) { var r = null; for (var i = 0; i < px.length; i++) { if (px[i] == null) { continue; } try { r = (px[i].call(this, s)); } catch (e) { r = null; } if (r) { return r; } } throw new $P.Exception(s); }; }, each: function () { var px = arguments; return function (s) { var rx = [], r = null; for (var i = 0; i < px.length ; i++) { if (px[i] == null) { continue; } try { r = (px[i].call(this, s)); } catch (e) { throw new $P.Exception(s); } rx.push(r[0]); s = r[1]; } return [ rx, s]; }; }, all: function () { var px = arguments, _ = _; return _.each(_.optional(px)); }, // delimited operators sequence: function (px, d, c) { d = d || _.rtoken(/^\s*/); c = c || null; if (px.length === 1) { return px[0]; } return function (s) { var r = null, q = null; var rx = []; for (var i = 0; i < px.length ; i++) { try { r = px[i].call(this, s); } catch (e) { break; } rx.push(r[0]); try { q = d.call(this, r[1]); } catch (ex) { q = null; break; } s = q[1]; } if (!r) { throw new $P.Exception(s); } if (q) { throw new $P.Exception(q[1]); } if (c) { try { r = c.call(this, r[1]); } catch (ey) { throw new $P.Exception(r[1]); } } return [ rx, (r?r[1]:s) ]; }; }, // // Composite Operators // between: function (d1, p, d2) { d2 = d2 || d1; var _fn = _.each(_.ignore(d1), p, _.ignore(d2)); return function (s) { var rx = _fn.call(this, s); return [[rx[0][0], r[0][2]], rx[1]]; }; }, list: function (p, d, c) { d = d || _.rtoken(/^\s*/); c = c || null; return (p instanceof Array ? _.each(_.product(p.slice(0, -1), _.ignore(d)), p.slice(-1), _.ignore(c)) : _.each(_.many(_.each(p, _.ignore(d))), px, _.ignore(c))); }, set: function (px, d, c) { d = d || _.rtoken(/^\s*/); c = c || null; return function (s) { // r is the current match, best the current 'best' match // which means it parsed the most amount of input var r = null, p = null, q = null, rx = null, best = [[], s], last = false; // go through the rules in the given set for (var i = 0; i < px.length ; i++) { // last is a flag indicating whether this must be the last element // if there is only 1 element, then it MUST be the last one q = null; p = null; r = null; last = (px.length === 1); // first, we try simply to match the current pattern // if not, try the next pattern try { r = px[i].call(this, s); } catch (e) { continue; } // since we are matching against a set of elements, the first // thing to do is to add r[0] to matched elements rx = [[r[0]], r[1]]; // if we matched and there is still input to parse and // we don't already know this is the last element, // we're going to next check for the delimiter ... // if there's none, or if there's no input left to parse // than this must be the last element after all ... if (r[1].length > 0 && ! last) { try { q = d.call(this, r[1]); } catch (ex) { last = true; } } else { last = true; } // if we parsed the delimiter and now there's no more input, // that means we shouldn't have parsed the delimiter at all // so don't update r and mark this as the last element ... if (!last && q[1].length === 0) { last = true; } // so, if this isn't the last element, we're going to see if // we can get any more matches from the remaining (unmatched) // elements ... if (!last) { // build a list of the remaining rules we can match against, // i.e., all but the one we just matched against var qx = []; for (var j = 0; j < px.length ; j++) { if (i !== j) { qx.push(px[j]); } } // now invoke recursively set with the remaining input // note that we don't include the closing delimiter ... // we'll check for that ourselves at the end p = _.set(qx, d).call(this, q[1]); // if we got a non-empty set as a result ... // (otw rx already contains everything we want to match) if (p[0].length > 0) { // update current result, which is stored in rx ... // basically, pick up the remaining text from p[1] // and concat the result from p[0] so that we don't // get endless nesting ... rx[0] = rx[0].concat(p[0]); rx[1] = p[1]; } } // at this point, rx either contains the last matched element // or the entire matched set that starts with this element. // now we just check to see if this variation is better than // our best so far, in terms of how much of the input is parsed if (rx[1].length < best[1].length) { best = rx; } // if we've parsed all the input, then we're finished if (best[1].length === 0) { break; } } // so now we've either gone through all the patterns trying them // as the initial match; or we found one that parsed the entire // input string ... // if best has no matches, just return empty set ... if (best[0].length === 0) { return best; } // if a closing delimiter is provided, then we have to check it also if (c) { // we try this even if there is no remaining input because the pattern // may well be optional or match empty input ... try { q = c.call(this, best[1]); } catch (ey) { throw new $P.Exception(best[1]); } // it parsed ... be sure to update the best match remaining input best[1] = q[1]; } // if we're here, either there was no closing delimiter or we parsed it // so now we have the best match; just return it! return best; }; }, forward: function (gr, fname) { return function (s) { return gr[fname].call(this, s); }; }, // // Translation Operators // replace: function (rule, repl) { return function (s) { var r = rule.call(this, s); return [repl, r[1]]; }; }, process: function (rule, fn) { return function (s) { var r = rule.call(this, s); return [fn.call(this, r[0]), r[1]]; }; }, min: function (min, rule) { return function (s) { var rx = rule.call(this, s); if (rx[0].length < min) { throw new $P.Exception(s); } return rx; }; } }; // Generator Operators And Vector Operators // Generators are operators that have a signature of F(R) => R, // taking a given rule and returning another rule, such as // ignore, which parses a given rule and throws away the result. // Vector operators are those that have a signature of F(R1,R2,...) => R, // take a list of rules and returning a new rule, such as each. // Generator operators are converted (via the following _generator // function) into functions that can also take a list or array of rules // and return an array of new rules as though the function had been // called on each rule in turn (which is what actually happens). // This allows generators to be used with vector operators more easily. // Example: // each(ignore(foo, bar)) instead of each(ignore(foo), ignore(bar)) // This also turns generators into vector operators, which allows // constructs like: // not(cache(foo, bar)) var _generator = function (op) { function gen() { var args = null, rx = [], px, i; if (arguments.length > 1) { args = Array.prototype.slice.call(arguments); } else if (arguments[0] instanceof Array) { args = arguments[0]; } if (args) { px = args.shift(); if (px.length > 0) { args.unshift(px[i]); rx.push(op.apply(null, args)); args.shift(); return rx; } } else { return op.apply(null, arguments); } } return gen; }; var gx = "optional not ignore cache".split(/\s/); for (var i = 0 ; i < gx.length ; i++) { _[gx[i]] = _generator(_[gx[i]]); } var _vector = function (op) { return function () { if (arguments[0] instanceof Array) { return op.apply(null, arguments[0]); } else { return op.apply(null, arguments); } }; }; var vx = "each any all".split(/\s/); for (var j = 0 ; j < vx.length ; j++) { _[vx[j]] = _vector(_[vx[j]]); } }()); (function () { var $D = Date; var flattenAndCompact = function (ax) { var rx = []; for (var i = 0; i < ax.length; i++) { if (ax[i] instanceof Array) { rx = rx.concat(flattenAndCompact(ax[i])); } else { if (ax[i]) { rx.push(ax[i]); } } } return rx; }; var parseMeridian = function () { if (this.meridian && (this.hour || this.hour === 0)) { if (this.meridian === "a" && this.hour > 11 && Date.Config.strict24hr){ throw "Invalid hour and meridian combination"; } else if (this.meridian === "p" && this.hour < 12 && Date.Config.strict24hr){ throw "Invalid hour and meridian combination"; } else if (this.meridian === "p" && this.hour < 12) { this.hour = this.hour + 12; } else if (this.meridian === "a" && this.hour === 12) { this.hour = 0; } } }; var setDefaults = function () { var now = new Date(); if ((this.hour || this.minute) && (!this.month && !this.year && !this.day)) { this.day = now.getDate(); } if (!this.year) { this.year = now.getFullYear(); } if (!this.month && this.month !== 0) { this.month = now.getMonth(); } if (!this.day) { this.day = 1; } if (!this.hour) { this.hour = 0; } if (!this.minute) { this.minute = 0; } if (!this.second) { this.second = 0; } if (!this.millisecond) { this.millisecond = 0; } }; var finishUtils = { getToday: function () { if (this.now || "hour minute second".indexOf(this.unit) !== -1) { return new Date(); } else { return $D.today(); } }, setDaysFromWeekday: function (today, orient){ var gap; orient = orient || 1; this.unit = "day"; gap = ($D.getDayNumberFromName(this.weekday) - today.getDay()); this.days = gap ? ((gap + (orient * 7)) % 7) : (orient * 7); return this; }, setMonthsFromMonth: function (today, orient) { var gap; orient = orient || 1; this.unit = "month"; gap = (this.month - today.getMonth()); this.months = gap ? ((gap + (orient * 12)) % 12) : (orient * 12); this.month = null; return this; }, setDMYFromWeekday: function () { var d = Date[this.weekday](); this.day = d.getDate(); if (!this.month) { this.month = d.getMonth(); } this.year = d.getFullYear(); return this; }, setUnitValue: function (orient) { if (!this.value && this.operator && this.operator !== null && this[this.unit + "s"] && this[this.unit + "s"] !== null) { this[this.unit + "s"] = this[this.unit + "s"] + ((this.operator === "add") ? 1 : -1) + (this.value||0) * orient; } else if (this[this.unit + "s"] == null || this.operator != null) { if (!this.value) { this.value = 1; } this[this.unit + "s"] = this.value * orient; } }, generateDateFromWeeks: function () { var weekday = (this.weekday !== undefined) ? this.weekday : "today"; var d = Date[weekday]().addWeeks(this.weeks); if (this.now) { d.setTimeToNow(); } return d; } }; $D.Translator = { hour: function (s) { return function () { this.hour = Number(s); }; }, minute: function (s) { return function () { this.minute = Number(s); }; }, second: function (s) { return function () { this.second = Number(s); }; }, /* for ss.s format */ secondAndMillisecond: function (s) { return function () { var mx = s.match(/^([0-5][0-9])\.([0-9]{1,3})/); this.second = Number(mx[1]); this.millisecond = Number(mx[2]); }; }, meridian: function (s) { return function () { this.meridian = s.slice(0, 1).toLowerCase(); }; }, timezone: function (s) { return function () { var n = s.replace(/[^\d\+\-]/g, ""); if (n.length) { this.timezoneOffset = Number(n); } else { this.timezone = s.toLowerCase(); } }; }, day: function (x) { var s = x[0]; return function () { this.day = Number(s.match(/\d+/)[0]); if (this.day < 1) { throw "invalid day"; } }; }, month: function (s) { return function () { this.month = (s.length === 3) ? "jan feb mar apr may jun jul aug sep oct nov dec".indexOf(s)/4 : Number(s) - 1; if (this.month < 0) { throw "invalid month"; } }; }, year: function (s) { return function () { var n = Number(s); this.year = ((s.length > 2) ? n : (n + (((n + 2000) < Date.CultureInfo.twoDigitYearMax) ? 2000 : 1900))); }; }, rday: function (s) { return function () { switch (s) { case "yesterday": this.days = -1; break; case "tomorrow": this.days = 1; break; case "today": this.days = 0; break; case "now": this.days = 0; this.now = true; break; } }; }, finishExact: function (x) { var d; x = (x instanceof Array) ? x : [x]; for (var i = 0 ; i < x.length ; i++) { if (x[i]) { x[i].call(this); } } setDefaults.call(this); parseMeridian.call(this); if (this.day > $D.getDaysInMonth(this.year, this.month)) { throw new RangeError(this.day + " is not a valid value for days."); } d = new Date(this.year, this.month, this.day, this.hour, this.minute, this.second, this.millisecond); if (this.year < 100) { d.setFullYear(this.year); // means years less that 100 are process correctly. JS will parse it otherwise as 1900-1999. } if (this.timezone) { d.set({ timezone: this.timezone }); } else if (this.timezoneOffset) { d.set({ timezoneOffset: this.timezoneOffset }); } return d; }, finish: function (x) { var today, expression, orient, temp; x = (x instanceof Array) ? flattenAndCompact(x) : [ x ]; if (x.length === 0) { return null; } for (var i = 0 ; i < x.length ; i++) { if (typeof x[i] === "function") { x[i].call(this); } } if (this.now && !this.unit && !this.operator) { return new Date(); } else { today = finishUtils.getToday.call(this); } expression = !!(this.days && this.days !== null || this.orient || this.operator); orient = ((this.orient === "past" || this.operator === "subtract") ? -1 : 1); if (this.month && this.unit === "week") { this.value = this.month + 1; delete this.month; delete this.day; } if ((this.month || this.month === 0) && "year day hour minute second".indexOf(this.unit) !== -1) { if (!this.value) { this.value = this.month + 1; } this.month = null; expression = true; } if (!expression && this.weekday && !this.day && !this.days) { finishUtils.setDMYFromWeekday.call(this); } if (expression && this.weekday && this.unit !== "month" && this.unit !== "week") { finishUtils.setDaysFromWeekday.call(this, today, orient); } if (this.weekday && this.unit !== "week" && !this.day && !this.days) { temp = Date[this.weekday](); this.day = temp.getDate(); if (temp.getMonth() !== today.getMonth()) { this.month = temp.getMonth(); } } if (this.month && this.unit === "day" && this.operator) { if (!this.value) { this.value = (this.month + 1); } this.month = null; } if (this.value != null && this.month != null && this.year != null) { this.day = this.value * 1; } if (this.month && !this.day && this.value) { today.set({ day: this.value * 1 }); if (!expression) { this.day = this.value * 1; } } if (!this.month && this.value && this.unit === "month" && !this.now) { this.month = this.value; expression = true; } if (expression && (this.month || this.month === 0) && this.unit !== "year") { finishUtils.setMonthsFromMonth.call(this, today, orient); } if (!this.unit) { this.unit = "day"; } finishUtils.setUnitValue.call(this, orient); parseMeridian.call(this); if ((this.month || this.month === 0) && !this.day) { this.day = 1; } if (!this.orient && !this.operator && this.unit === "week" && this.value && !this.day && !this.month) { return Date.today().setWeek(this.value); } if (this.unit === "week" && this.weeks && !this.day && !this.month) { return finishUtils.generateDateFromWeeks.call(this); } if (expression && this.timezone && this.day && this.days) { this.day = this.days; } if (expression){ today.add(this); } else { today.set(this); } if (this.timezone) { this.timezone = this.timezone.toUpperCase(); var offset = $D.getTimezoneOffset(this.timezone); var timezone; if (today.hasDaylightSavingTime()) { // lets check that we're being sane with timezone setting timezone = $D.getTimezoneAbbreviation(offset, today.isDaylightSavingTime()); if (timezone !== this.timezone) { // bugger, we're in a place where things like EST vs EDT matters. if (today.isDaylightSavingTime()) { today.addHours(-1); } else { today.addHours(1); } } } today.setTimezoneOffset(offset); } return today; } }; }()); (function () { var $D = Date; $D.Grammar = {}; var _ = $D.Parsing.Operators, g = $D.Grammar, t = $D.Translator, _fn; // Allow rolling up into general purpose rules _fn = function () { return _.each(_.any.apply(null, arguments), _.not(g.ctoken2("timeContext"))); }; g.datePartDelimiter = _.rtoken(/^([\s\-\.\,\/\x27]+)/); g.timePartDelimiter = _.stoken(":"); g.whiteSpace = _.rtoken(/^\s*/); g.generalDelimiter = _.rtoken(/^(([\s\,]|at|@|on)+)/); var _C = {}; g.ctoken = function (keys) { var fn = _C[keys]; if (! fn) { var c = Date.CultureInfo.regexPatterns; var kx = keys.split(/\s+/), px = []; for (var i = 0; i < kx.length ; i++) { px.push(_.replace(_.rtoken(c[kx[i]]), kx[i])); } fn = _C[keys] = _.any.apply(null, px); } return fn; }; g.ctoken2 = function (key) { return _.rtoken(Date.CultureInfo.regexPatterns[key]); }; var cacheProcessRtoken = function (key, token, type, eachToken) { if (eachToken) { g[key] = _.cache(_.process(_.each(_.rtoken(token),_.optional(g.ctoken2(eachToken))), type)); } else { g[key] = _.cache(_.process(_.rtoken(token), type)); } }; var cacheProcessCtoken = function (token, type) { return _.cache(_.process(g.ctoken2(token), type)); }; var _F = {}; //function cache var _get = function (f) { _F[f] = (_F[f] || g.format(f)[0]); return _F[f]; }; g.allformats = function (fx) { var rx = []; if (fx instanceof Array) { for (var i = 0; i < fx.length; i++) { rx.push(_get(fx[i])); } } else { rx.push(_get(fx)); } return rx; }; g.formats = function (fx) { if (fx instanceof Array) { var rx = []; for (var i = 0 ; i < fx.length ; i++) { rx.push(_get(fx[i])); } return _.any.apply(null, rx); } else { return _get(fx); } }; var grammarFormats = { timeFormats: function(){ var i, RTokenKeys = [ "h", "hh", "H", "HH", "m", "mm", "s", "ss", "ss.s", "z", "zz" ], RToken = [ /^(0[0-9]|1[0-2]|[1-9])/, /^(0[0-9]|1[0-2])/, /^([0-1][0-9]|2[0-3]|[0-9])/, /^([0-1][0-9]|2[0-3])/, /^([0-5][0-9]|[0-9])/, /^[0-5][0-9]/, /^([0-5][0-9]|[0-9])/, /^[0-5][0-9]/, /^[0-5][0-9]\.[0-9]{1,3}/, /^((\+|\-)\s*\d\d\d\d)|((\+|\-)\d\d\:?\d\d)/, /^((\+|\-)\s*\d\d\d\d)|((\+|\-)\d\d\:?\d\d)/ ], tokens = [ t.hour, t.hour, t.hour, t.hour, t.minute, t.minute, t.second, t.second, t.secondAndMillisecond, t.timezone, t.timezone ]; for (i=0; i < RTokenKeys.length; i++) { cacheProcessRtoken(RTokenKeys[i], RToken[i], tokens[i]); } g.hms = _.cache(_.sequence([g.H, g.m, g.s], g.timePartDelimiter)); g.t = cacheProcessCtoken("shortMeridian", t.meridian); g.tt = cacheProcessCtoken("longMeridian", t.meridian); g.zzz = cacheProcessCtoken("timezone", t.timezone); g.timeSuffix = _.each(_.ignore(g.whiteSpace), _.set([ g.tt, g.zzz ])); g.time = _.each(_.optional(_.ignore(_.stoken("T"))), g.hms, g.timeSuffix); }, dateFormats: function () { // pre-loaded rules for different date part order preferences var _setfn = function () { return _.set(arguments, g.datePartDelimiter); }; var i, RTokenKeys = [ "d", "dd", "M", "MM", "y", "yy", "yyy", "yyyy" ], RToken = [ /^([0-2]\d|3[0-1]|\d)/, /^([0-2]\d|3[0-1])/, /^(1[0-2]|0\d|\d)/, /^(1[0-2]|0\d)/, /^(\d+)/, /^(\d\d)/, /^(\d\d?\d?\d?)/, /^(\d\d\d\d)/ ], tokens = [ t.day, t.day, t.month, t.month, t.year, t.year, t.year, t.year ], eachToken = [ "ordinalSuffix", "ordinalSuffix" ]; for (i=0; i < RTokenKeys.length; i++) { cacheProcessRtoken(RTokenKeys[i], RToken[i], tokens[i], eachToken[i]); } g.MMM = g.MMMM = _.cache(_.process(g.ctoken("jan feb mar apr may jun jul aug sep oct nov dec"), t.month)); g.ddd = g.dddd = _.cache(_.process(g.ctoken("sun mon tue wed thu fri sat"), function (s) { return function () { this.weekday = s; }; } )); g.day = _fn(g.d, g.dd); g.month = _fn(g.M, g.MMM); g.year = _fn(g.yyyy, g.yy); g.mdy = _setfn(g.ddd, g.month, g.day, g.year); g.ymd = _setfn(g.ddd, g.year, g.month, g.day); g.dmy = _setfn(g.ddd, g.day, g.month, g.year); g.date = function (s) { return ((g[Date.CultureInfo.dateElementOrder] || g.mdy).call(this, s)); }; }, relative: function () { // relative date / time expressions g.orientation = _.process(g.ctoken("past future"), function (s) { return function () { this.orient = s; }; } ); g.operator = _.process(g.ctoken("add subtract"), function (s) { return function () { this.operator = s; }; } ); g.rday = _.process(g.ctoken("yesterday tomorrow today now"), t.rday); g.unit = _.process(g.ctoken("second minute hour day week month year"), function (s) { return function () { this.unit = s; }; } ); } }; g.buildGrammarFormats = function () { // these need to be rebuilt every time the language changes. _C = {}; grammarFormats.timeFormats(); grammarFormats.dateFormats(); grammarFormats.relative(); g.value = _.process(_.rtoken(/^([-+]?\d+)?(st|nd|rd|th)?/), function (s) { return function () { this.value = s.replace(/\D/g, ""); }; } ); g.expression = _.set([g.rday, g.operator, g.value, g.unit, g.orientation, g.ddd, g.MMM ]); g.format = _.process(_.many( _.any( // translate format specifiers into grammar rules _.process( _.rtoken(/^(dd?d?d?(?!e)|MM?M?M?|yy?y?y?|hh?|HH?|mm?|ss?|tt?|zz?z?)/), function (fmt) { if (g[fmt]) { return g[fmt]; } else { throw $D.Parsing.Exception(fmt); } } ), // translate separator tokens into token rules _.process(_.rtoken(/^[^dMyhHmstz]+/), // all legal separators function (s) { return _.ignore(_.stoken(s)); } ) ) ), // construct the parser ... function (rules) { return _.process(_.each.apply(null, rules), t.finishExact); } ); // starting rule for general purpose grammar g._start = _.process(_.set([ g.date, g.time, g.expression ], g.generalDelimiter, g.whiteSpace), t.finish); }; g.buildGrammarFormats(); // parsing date format specifiers - ex: "h:m:s tt" // this little guy will generate a custom parser based // on the format string, ex: g.format("h:m:s tt") // check for these formats first g._formats = g.formats([ "\"yyyy-MM-ddTHH:mm:ssZ\"", "yyyy-MM-ddTHH:mm:ss.sz", "yyyy-MM-ddTHH:mm:ssZ", "yyyy-MM-ddTHH:mm:ssz", "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-ddTHH:mmZ", "yyyy-MM-ddTHH:mmz", "yyyy-MM-ddTHH:mm", "ddd, MMM dd, yyyy H:mm:ss tt", "ddd MMM d yyyy HH:mm:ss zzz", "MMddyyyy", "ddMMyyyy", "Mddyyyy", "ddMyyyy", "Mdyyyy", "dMyyyy", "yyyy", "Mdyy", "dMyy", "d" ]); // real starting rule: tries selected formats first, // then general purpose rule g.start = function (s) { try { var r = g._formats.call({}, s); if (r[1].length === 0) { return r; } } catch (e) {} return g._start.call({}, s); }; }()); (function () { var $D = Date; /** * @desc Converts the specified string value into its JavaScript Date equivalent using CultureInfo specific format information. * * Example

	///////////
	// Dates //
	///////////

	// 15-Oct-2004
	var d1 = Date.parse("10/15/2004");

	// 15-Oct-2004
	var d1 = Date.parse("15-Oct-2004");

	// 15-Oct-2004
	var d1 = Date.parse("2004.10.15");

	//Fri Oct 15, 2004
	var d1 = Date.parse("Fri Oct 15, 2004");

	///////////
	// Times //
	///////////

	// Today at 10 PM.
	var d1 = Date.parse("10 PM");

	// Today at 10:30 PM.
	var d1 = Date.parse("10:30 P.M.");

	// Today at 6 AM.
	var d1 = Date.parse("06am");

	/////////////////////
	// Dates and Times //
	/////////////////////

	// 8-July-2004 @ 10:30 PM
	var d1 = Date.parse("July 8th, 2004, 10:30 PM");

	// 1-July-2004 @ 10:30 PM
	var d1 = Date.parse("2004-07-01T22:30:00");

	////////////////////
	// Relative Dates //
	////////////////////

	// Returns today's date. The string "today" is culture specific.
	var d1 = Date.parse("today");

	// Returns yesterday's date. The string "yesterday" is culture specific.
	var d1 = Date.parse("yesterday");

	// Returns the date of the next thursday.
	var d1 = Date.parse("Next thursday");

	// Returns the date of the most previous monday.
	var d1 = Date.parse("last monday");

	// Returns today's day + one year.
	var d1 = Date.parse("next year");

	///////////////
	// Date Math //
	///////////////

	// Today + 2 days
	var d1 = Date.parse("t+2");

	// Today + 2 days
	var d1 = Date.parse("today + 2 days");

	// Today + 3 months
	var d1 = Date.parse("t+3m");

	// Today - 1 year
	var d1 = Date.parse("today - 1 year");

	// Today - 1 year
	var d1 = Date.parse("t-1y"); 


	/////////////////////////////
	// Partial Dates and Times //
	/////////////////////////////

	// July 15th of this year.
	var d1 = Date.parse("July 15");

	// 15th day of current day and year.
	var d1 = Date.parse("15");

	// July 1st of current year at 10pm.
	var d1 = Date.parse("7/1 10pm");
	
* * @param {String} The string value to convert into a Date object [Required] * @return {Date} A Date object or null if the string cannot be converted into a Date. */ var parseUtils = { removeOrds: function (s) { ords = s.match(/\b(\d+)(?:st|nd|rd|th)\b/); // find ordinal matches s = ((ords && ords.length === 2) ? s.replace(ords[0], ords[1]) : s); return s; }, grammarParser: function (s) { var r = null; try { r = $D.Grammar.start.call({}, s.replace(/^\s*(\S*(\s+\S+)*)\s*$/, "$1")); } catch (e) { return null; } return ((r[1].length === 0) ? r[0] : null); }, nativeFallback: function(s) { var t; try { // ok we haven't parsed it, last ditch attempt with the built-in parser. t = Date._parse(s); return (t || t === 0) ? new Date(t) : null; } catch (e) { return null; } } }; function parse (s) { var d; if (!s) { return null; } if (s instanceof Date) { return s.clone(); } if (s.length >= 4 && s.charAt(0) !== "0" && s.charAt(0) !== "+"&& s.charAt(0) !== "-") { // ie: 2004 will pass, 0800 won't. // Start with specific formats d = $D.Parsing.ISO.parse(s) || $D.Parsing.Numeric.parse(s); } if (d instanceof Date && !isNaN(d.getTime())) { return d; } else { // find ordinal dates (1st, 3rd, 8th, etc and remove them as they cause parsing issues) s = $D.Parsing.Normalizer.parse(parseUtils.removeOrds(s)); d = parseUtils.grammarParser(s); if (d !== null) { return d; } else { return parseUtils.nativeFallback(s); } } } if (!$D._parse) { $D._parse = $D.parse; } $D.parse = parse; Date.getParseFunction = function (fx) { var fns = Date.Grammar.allformats(fx); return function (s) { var r = null; for (var i = 0; i < fns.length; i++) { try { r = fns[i].call({}, s); } catch (e) { continue; } if (r[1].length === 0) { return r[0]; } } return null; }; }; /** * Converts the specified string value into its JavaScript Date equivalent using the specified format {String} or formats {Array} and the CultureInfo specific format information. * The format of the string value must match one of the supplied formats exactly. * * Example

	// 15-Oct-2004
	var d1 = Date.parseExact("10/15/2004", "M/d/yyyy");

	// 15-Oct-2004
	var d1 = Date.parse("15-Oct-2004", "M-ddd-yyyy");

	// 15-Oct-2004
	var d1 = Date.parse("2004.10.15", "yyyy.MM.dd");

	// Multiple formats
	var d1 = Date.parseExact("10/15/2004", ["M/d/yyyy", "MMMM d, yyyy"]);
	
* * @param {String} The string value to convert into a Date object [Required]. * @param {Object} The expected format {String} or an array of expected formats {Array} of the date string [Required]. * @return {Date} A Date object or null if the string cannot be converted into a Date. */ $D.parseExact = function (s, fx) { return $D.getParseFunction(fx)(s); }; }()); (function () { var $D = Date, $P = $D.prototype, // $C = $D.CultureInfo, // not used atm p = function (s, l) { if (!l) { l = 2; } return ("000" + s).slice(l * -1); }; /** * Converts a PHP format string to Java/.NET format string. * A PHP format string can be used with ._format or .format. * A Java/.NET format string can be used with .toString(). * The .parseExact function will only accept a Java/.NET format string * * Example * var f1 = "%m/%d/%y" * var f2 = Date.normalizeFormat(f1); // "MM/dd/yy" * * new Date().format(f1); // "04/13/08" * new Date()._format(f1); // "04/13/08" * new Date().toString(f2); // "04/13/08" * * var date = Date.parseExact("04/13/08", f2); // Sun Apr 13 2008 * * @param {String} A PHP format string consisting of one or more format spcifiers. * @return {String} The PHP format converted to a Java/.NET format string. */ var normalizerSubstitutions = { "d" : "dd", "%d": "dd", "D" : "ddd", "%a": "ddd", "j" : "dddd", "l" : "dddd", "%A": "dddd", "S" : "S", "F" : "MMMM", "%B": "MMMM", "m" : "MM", "%m": "MM", "M" : "MMM", "%b": "MMM", "%h": "MMM", "n" : "M", "Y" : "yyyy", "%Y": "yyyy", "y" : "yy", "%y": "yy", "g" : "h", "%I": "h", "G" : "H", "h" : "hh", "H" : "HH", "%H": "HH", "i" : "mm", "%M": "mm", "s" : "ss", "%S": "ss", "%r": "hh:mm tt", "%R": "H:mm", "%T": "H:mm:ss", "%X": "t", "%x": "d", "%e": "d", "%D": "MM/dd/yy", "%n": "\\n", "%t": "\\t", "e" : "z", "T" : "z", "%z": "z", "%Z": "z", "Z" : "ZZ", "N" : "u", "w" : "u", "%w": "u", "W" : "W", "%V": "W" }; var normalizer = { substitutes: function (m) { return normalizerSubstitutions[m]; }, interpreted: function (m, x) { var y; switch (m) { case "%u": return x.getDay() + 1; case "z": return x.getOrdinalNumber(); case "%j": return p(x.getOrdinalNumber(), 3); case "%U": var d1 = x.clone().set({month: 0, day: 1}).addDays(-1).moveToDayOfWeek(0), d2 = x.clone().addDays(1).moveToDayOfWeek(0, -1); return (d2 < d1) ? "00" : p((d2.getOrdinalNumber() - d1.getOrdinalNumber()) / 7 + 1); case "%W": return p(x.getWeek()); case "t": return $D.getDaysInMonth(x.getFullYear(), x.getMonth()); case "o": case "%G": return x.setWeek(x.getISOWeek()).toString("yyyy"); case "%g": return x._format("%G").slice(-2); case "a": case "%p": return t("tt").toLowerCase(); case "A": return t("tt").toUpperCase(); case "u": return p(x.getMilliseconds(), 3); case "I": return (x.isDaylightSavingTime()) ? 1 : 0; case "O": return x.getUTCOffset(); case "P": y = x.getUTCOffset(); return y.substring(0, y.length - 2) + ":" + y.substring(y.length - 2); case "B": var now = new Date(); return Math.floor(((now.getHours() * 3600) + (now.getMinutes() * 60) + now.getSeconds() + (now.getTimezoneOffset() + 60) * 60) / 86.4); case "c": return x.toISOString().replace(/\"/g, ""); case "U": return $D.strtotime("now"); case "%c": return t("d") + " " + t("t"); case "%C": return Math.floor(x.getFullYear() / 100 + 1); } }, shouldOverrideDefaults: function (m) { switch (m) { case "%e": return true; default: return false; } }, parse: function (m, context) { var formatString, c = context || new Date(); formatString = normalizer.substitutes(m); if (formatString) { return formatString; } formatString = normalizer.interpreted(m, c); if (formatString) { return formatString; } else { return m; } } }; $D.normalizeFormat = function (format, context) { return format.replace(/(%|\\)?.|%%/g, function(t){ return normalizer.parse(t, context); }); }; /** * Format a local Unix timestamp according to locale settings * * Example: * Date.strftime("%m/%d/%y", new Date()); // "04/13/08" * Date.strftime("c", "2008-04-13T17:52:03Z"); // "04/13/08" * * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @param {Number|String} The number representing the number of seconds that have elapsed since January 1, 1970 (local time). * @return {String} A string representation of the current Date object. */ $D.strftime = function (format, time) { var d = Date.parse(time); return d._format(format); }; /** * Parse any textual datetime description into a Unix timestamp. * A Unix timestamp is the number of seconds that have elapsed since January 1, 1970 (midnight UTC/GMT). * * Example: * Date.strtotime("04/13/08"); // 1208044800 * Date.strtotime("1970-01-01T00:00:00Z"); // 0 * * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @param {Object} A string or date object. * @return {String} A string representation of the current Date object. */ $D.strtotime = function (time) { var d = $D.parse(time); return Math.round($D.UTC(d.getUTCFullYear(), d.getUTCMonth(), d.getUTCDate(), d.getUTCHours(), d.getUTCMinutes(), d.getUTCSeconds(), d.getUTCMilliseconds()) / 1000); }; /** * Converts the value of the current Date object to its equivalent string representation using a PHP/Unix style of date format specifiers. * Format Specifiers * Format Description Example * ------ --------------------------------------------------------------------------- ----------------------- * %a abbreviated weekday name according to the current localed "Mon" through "Sun" * %A full weekday name according to the current localed "Sunday" through "Saturday" * %b abbreviated month name according to the current localed "Jan" through "Dec" * %B full month name according to the current locale "January" through "December" * %c preferred date and time representation for the current locale "4/13/2008 12:33 PM" * %C century number (the year divided by 100 and truncated to an integer) "00" to "99" * %d day of the month as a decimal number "01" to "31" * %D same as %m/%d/%y "04/13/08" * %e day of the month as a decimal number, a single digit is preceded by a space "1" to "31" * %g like %G, but without the century "08" * %G The 4-digit year corresponding to the ISO week number (see %V). "2008" * This has the same format and value as %Y, except that if the ISO week number * belongs to the previous or next year, that year is used instead. * %h same as %b "Jan" through "Dec" * %H hour as a decimal number using a 24-hour clock. "00" to "23" * %I hour as a decimal number using a 12-hour clock. "01" to "12" * %j day of the year as a decimal number. "001" to "366" * %m month as a decimal number. "01" to "12" * %M minute as a decimal number. "00" to "59" * %n newline character "\n" * %p either "am" or "pm" according to the given time value, or the "am" or "pm" * corresponding strings for the current locale. * %r time in a.m. and p.m. notation "8:44 PM" * %R time in 24 hour notation "20:44" * %S second as a decimal number "00" to "59" * %t tab character "\t" * %T current time, equal to %H:%M:%S "12:49:11" * %u weekday as a decimal number ["1", "7"], with "1" representing Monday "1" to "7" * %U week number of the current year as a decimal number, starting with the "0" to ("52" or "53") * first Sunday as the first day of the first week * %V The ISO 8601:1988 week number of the current year as a decimal number, "00" to ("52" or "53") * range 01 to 53, where week 1 is the first week that has at least 4 days * in the current year, and with Monday as the first day of the week. * (Use %G or %g for the year component that corresponds to the week number * for the specified timestamp.) * %W week number of the current year as a decimal number, starting with the "00" to ("52" or "53") * first Monday as the first day of the first week * %w day of the week as a decimal, Sunday being "0" "0" to "6" * %x preferred date representation for the current locale without the time "4/13/2008" * %X preferred time representation for the current locale without the date "12:53:05" * %y year as a decimal number without a century "00" "99" * %Y year as a decimal number including the century "2008" * %Z time zone or name or abbreviation "UTC", "EST", "PST" * %z same as %Z * %% a literal "%" characters "%" * d Day of the month, 2 digits with leading zeros "01" to "31" * D A textual representation of a day, three letters "Mon" through "Sun" * j Day of the month without leading zeros "1" to "31" * l A full textual representation of the day of the week (lowercase "L") "Sunday" through "Saturday" * N ISO-8601 numeric representation of the day of the week (added in PHP 5.1.0) "1" (for Monday) through "7" (for Sunday) * S English ordinal suffix for the day of the month, 2 characters "st", "nd", "rd" or "th". Works well with j * w Numeric representation of the day of the week "0" (for Sunday) through "6" (for Saturday) * z The day of the year (starting from "0") "0" through "365" * W ISO-8601 week number of year, weeks starting on Monday "00" to ("52" or "53") * F A full textual representation of a month, such as January or March "January" through "December" * m Numeric representation of a month, with leading zeros "01" through "12" * M A short textual representation of a month, three letters "Jan" through "Dec" * n Numeric representation of a month, without leading zeros "1" through "12" * t Number of days in the given month "28" through "31" * L Whether it's a leap year "1" if it is a leap year, "0" otherwise * o ISO-8601 year number. This has the same value as Y, except that if the "2008" * ISO week number (W) belongs to the previous or next year, that year * is used instead. * Y A full numeric representation of a year, 4 digits "2008" * y A two digit representation of a year "08" * a Lowercase Ante meridiem and Post meridiem "am" or "pm" * A Uppercase Ante meridiem and Post meridiem "AM" or "PM" * B Swatch Internet time "000" through "999" * g 12-hour format of an hour without leading zeros "1" through "12" * G 24-hour format of an hour without leading zeros "0" through "23" * h 12-hour format of an hour with leading zeros "01" through "12" * H 24-hour format of an hour with leading zeros "00" through "23" * i Minutes with leading zeros "00" to "59" * s Seconds, with leading zeros "00" through "59" * u Milliseconds "54321" * e Timezone identifier "UTC", "EST", "PST" * I Whether or not the date is in daylight saving time (uppercase i) "1" if Daylight Saving Time, "0" otherwise * O Difference to Greenwich time (GMT) in hours "+0200", "-0600" * P Difference to Greenwich time (GMT) with colon between hours and minutes "+02:00", "-06:00" * T Timezone abbreviation "UTC", "EST", "PST" * Z Timezone offset in seconds. The offset for timezones west of UTC is "-43200" through "50400" * always negative, and for those east of UTC is always positive. * c ISO 8601 date "2004-02-12T15:19:21+00:00" * r RFC 2822 formatted date "Thu, 21 Dec 2000 16:01:07 +0200" * U Seconds since the Unix Epoch (January 1 1970 00:00:00 GMT) "0" * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @return {String} A string representation of the current Date object. */ var formatReplace = function (context) { return function (m) { var formatString, override = false; if (m.charAt(0) === "\\" || m.substring(0, 2) === "%%") { return m.replace("\\", "").replace("%%", "%"); } override = normalizer.shouldOverrideDefaults(m); formatString = $D.normalizeFormat(m, context); if (formatString) { return context.toString(formatString, override); } }; }; $P._format = function (format) { var formatter = formatReplace(this); if (!format) { return this._toString(); } else { return format.replace(/(%|\\)?.|%%/g, formatter); } }; if (!$P.format) { $P.format = $P._format; } }()); (function () { "use strict"; var gFn = function (attr) { return function () { return this[attr]; }; }; var sFn = function (attr) { return function (val) { this[attr] = val; return this; }; }; var attrs = ["years", "months", "days", "hours", "minutes", "seconds", "milliseconds"]; var addSetFuncs = function (context, attrs) { for (var i = 0; i < attrs.length ; i++) { var $a = attrs[i], $b = $a.slice(0, 1).toUpperCase() + $a.slice(1); context.prototype[$a] = 0; context.prototype["get" + $b] = gFn($a); context.prototype["set" + $b] = sFn($a); } }; /** * new TimeSpan(milliseconds); * new TimeSpan(days, hours, minutes, seconds); * new TimeSpan(days, hours, minutes, seconds, milliseconds); */ var TimeSpan = function (days, hours, minutes, seconds, milliseconds) { if (arguments.length === 1 && typeof days === "number") { var orient = (days < 0) ? -1 : +1; var millsLeft = Math.abs(days); this.setDays(Math.floor(millsLeft / 86400000) * orient); millsLeft = millsLeft % 86400000; this.setHours(Math.floor(millsLeft / 3600000) * orient); millsLeft = millsLeft % 3600000; this.setMinutes(Math.floor(millsLeft / 60000) * orient); millsLeft = millsLeft % 60000; this.setSeconds(Math.floor(millsLeft / 1000) * orient); millsLeft = millsLeft % 1000; this.setMilliseconds(millsLeft * orient); } else { this.set(days, hours, minutes, seconds, milliseconds); } this.getTotalMilliseconds = function () { return (this.getDays() * 86400000) + (this.getHours() * 3600000) + (this.getMinutes() * 60000) + (this.getSeconds() * 1000); }; this.compareTo = function (time) { var t1 = new Date(1970, 1, 1, this.getHours(), this.getMinutes(), this.getSeconds()), t2; if (time === null) { t2 = new Date(1970, 1, 1, 0, 0, 0); } else { t2 = new Date(1970, 1, 1, time.getHours(), time.getMinutes(), time.getSeconds()); } return (t1 < t2) ? -1 : (t1 > t2) ? 1 : 0; }; this.equals = function (time) { return (this.compareTo(time) === 0); }; this.add = function (time) { return (time === null) ? this : this.addSeconds(time.getTotalMilliseconds() / 1000); }; this.subtract = function (time) { return (time === null) ? this : this.addSeconds(-time.getTotalMilliseconds() / 1000); }; this.addDays = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 86400000)); }; this.addHours = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 3600000)); }; this.addMinutes = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 60000)); }; this.addSeconds = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 1000)); }; this.addMilliseconds = function (n) { return new TimeSpan(this.getTotalMilliseconds() + n); }; this.get12HourHour = function () { return (this.getHours() > 12) ? this.getHours() - 12 : (this.getHours() === 0) ? 12 : this.getHours(); }; this.getDesignator = function () { return (this.getHours() < 12) ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator; }; this.toString = function (format) { this._toString = function () { if (this.getDays() !== null && this.getDays() > 0) { return this.getDays() + "." + this.getHours() + ":" + this.p(this.getMinutes()) + ":" + this.p(this.getSeconds()); } else { return this.getHours() + ":" + this.p(this.getMinutes()) + ":" + this.p(this.getSeconds()); } }; this.p = function (s) { return (s.toString().length < 2) ? "0" + s : s; }; var me = this; return format ? format.replace(/dd?|HH?|hh?|mm?|ss?|tt?/g, function (format) { switch (format) { case "d": return me.getDays(); case "dd": return me.p(me.getDays()); case "H": return me.getHours(); case "HH": return me.p(me.getHours()); case "h": return me.get12HourHour(); case "hh": return me.p(me.get12HourHour()); case "m": return me.getMinutes(); case "mm": return me.p(me.getMinutes()); case "s": return me.getSeconds(); case "ss": return me.p(me.getSeconds()); case "t": return ((me.getHours() < 12) ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator).substring(0, 1); case "tt": return (me.getHours() < 12) ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator; } } ) : this._toString(); }; return this; }; addSetFuncs(TimeSpan, attrs.slice(2)); TimeSpan.prototype.set = function (days, hours, minutes, seconds, milliseconds){ this.setDays(days || this.getDays()); this.setHours(hours || this.getHours()); this.setMinutes(minutes || this.getMinutes()); this.setSeconds(seconds || this.getSeconds()); this.setMilliseconds(milliseconds || this.getMilliseconds()); }; /** * Gets the time of day for this date instances. * @return {TimeSpan} TimeSpan */ Date.prototype.getTimeOfDay = function () { return new TimeSpan(0, this.getHours(), this.getMinutes(), this.getSeconds(), this.getMilliseconds()); }; Date.TimeSpan = TimeSpan; if (typeof window !== "undefined" ) { // keeping API compatible for v1.x window.TimeSpan = TimeSpan; } }()); (function () { "use strict"; var attrs = ["years", "months", "days", "hours", "minutes", "seconds", "milliseconds"]; var gFn = function (attr) { return function () { return this[attr]; }; }; var sFn = function (attr) { return function (val) { this[attr] = val; return this; }; }; var addSetFuncs = function (context, attrs) { for (var i = 0; i < attrs.length ; i++) { var $a = attrs[i], $b = $a.slice(0, 1).toUpperCase() + $a.slice(1); context.prototype[$a] = 0; context.prototype["get" + $b] = gFn($a); context.prototype["set" + $b] = sFn($a); } }; var setMonthsAndYears = function (orient, d1, d2, context) { function inc() { d1.addMonths(-orient); context.months++; if (context.months === 12) { context.years++; context.months = 0; } } if (orient === +1) { while (d1 > d2) { inc(); } } else { while (d1 < d2) { inc(); } } context.months--; context.months *= orient; context.years *= orient; }; var adjustForDST = function(orient, startDate, endDate) { var hasDSTMismatch = (false === (startDate.isDaylightSavingTime() === endDate.isDaylightSavingTime())); if (hasDSTMismatch && orient === 1) { startDate.addHours(-1); } else if (hasDSTMismatch) { startDate.addHours(1); } }; /** * TimePeriod(startDate, endDate); * TimePeriod(years, months, days, hours, minutes, seconds, milliseconds); */ var TimePeriod = function (years, months, days, hours, minutes, seconds, milliseconds) { if (arguments.length === 7) { this.set(years, months, days, hours, minutes, seconds, milliseconds); } else if (arguments.length === 2 && arguments[0] instanceof Date && arguments[1] instanceof Date) { var startDate = arguments[0].clone(); var endDate = arguments[1].clone(); var orient = (startDate > endDate) ? +1 : -1; this.dates = { start: arguments[0].clone(), end: arguments[1].clone() }; setMonthsAndYears(orient, startDate, endDate, this); adjustForDST(orient, startDate, endDate); // // TODO - adjust for DST var diff = endDate - startDate; if (diff !== 0) { var ts = new TimeSpan(diff); this.set(this.years, this.months, ts.getDays(), ts.getHours(), ts.getMinutes(), ts.getSeconds(), ts.getMilliseconds()); } } return this; }; // create all the set functions. addSetFuncs(TimePeriod, attrs); TimePeriod.prototype.set = function (years, months, days, hours, minutes, seconds, milliseconds){ this.setYears(years || this.getYears()); this.setMonths(months || this.getMonths()); this.setDays(days || this.getDays()); this.setHours(hours || this.getHours()); this.setMinutes(minutes || this.getMinutes()); this.setSeconds(seconds || this.getSeconds()); this.setMilliseconds(milliseconds || this.getMilliseconds()); }; Date.TimePeriod = TimePeriod; if (typeof window !== "undefined") { // keeping API compatible for v1.x window.TimePeriod = TimePeriod; } }()); ================================================ FILE: build/date-es-SV.js ================================================ /** * @overview datejs * @version 1.0.0-rc3 * @author Gregory Wild-Smith * @copyright 2015 Gregory Wild-Smith * @license MIT * @homepage https://github.com/abritinthebay/datejs */ /* * DateJS Culture String File * Country Code: es-SV * Name: Spanish (El Salvador) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["es-SV"] = { "name": "es-SV", "englishName": "Spanish (El Salvador)", "nativeName": "Español (El Salvador)", "Sunday": "domingo", "Monday": "lunes", "Tuesday": "martes", "Wednesday": "miércoles", "Thursday": "jueves", "Friday": "viernes", "Saturday": "sábado", "Sun": "dom", "Mon": "lun", "Tue": "mar", "Wed": "mié", "Thu": "jue", "Fri": "vie", "Sat": "sáb", "Su": "do", "Mo": "lu", "Tu": "ma", "We": "mi", "Th": "ju", "Fr": "vi", "Sa": "sá", "S_Sun_Initial": "d", "M_Mon_Initial": "l", "T_Tue_Initial": "m", "W_Wed_Initial": "m", "T_Thu_Initial": "j", "F_Fri_Initial": "v", "S_Sat_Initial": "s", "January": "enero", "February": "febrero", "March": "marzo", "April": "abril", "May": "mayo", "June": "junio", "July": "julio", "August": "agosto", "September": "septiembre", "October": "octubre", "November": "noviembre", "December": "diciembre", "Jan_Abbr": "ene", "Feb_Abbr": "feb", "Mar_Abbr": "mar", "Apr_Abbr": "abr", "May_Abbr": "may", "Jun_Abbr": "jun", "Jul_Abbr": "jul", "Aug_Abbr": "ago", "Sep_Abbr": "sep", "Oct_Abbr": "oct", "Nov_Abbr": "nov", "Dec_Abbr": "dic", "AM": "a.m.", "PM": "p.m.", "firstDayOfWeek": 0, "twoDigitYearMax": 2029, "mdy": "dmy", "M/d/yyyy": "dd/MM/yyyy", "dddd, MMMM dd, yyyy": "dddd, dd' [de] 'MMMM' [de] 'yyyy", "h:mm tt": "hh:mm tt", "h:mm:ss tt": "hh:mm:ss tt", "dddd, MMMM dd, yyyy h:mm:ss tt": "dddd, dd' [de] 'MMMM' [de] 'yyyy hh:mm:ss tt", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "dd MMMM", "MMMM, yyyy": "MMMM' [de] 'yyyy", "/jan(uary)?/": "ene(ro)?", "/feb(ruary)?/": "feb(rero)?", "/mar(ch)?/": "mar(zo)?", "/apr(il)?/": "abr(il)?", "/may/": "may(o)?", "/jun(e)?/": "jun(io)?", "/jul(y)?/": "jul(io)?", "/aug(ust)?/": "ago(sto)?", "/sep(t(ember)?)?/": "sep(tiembre)?", "/oct(ober)?/": "oct(ubre)?", "/nov(ember)?/": "nov(iembre)?", "/dec(ember)?/": "dic(iembre)?", "/^su(n(day)?)?/": "^do(m(ingo)?)?", "/^mo(n(day)?)?/": "^lu(n(es)?)?", "/^tu(e(s(day)?)?)?/": "^ma(r(tes)?)?", "/^we(d(nesday)?)?/": "^mi(é(rcoles)?)?", "/^th(u(r(s(day)?)?)?)?/": "^ju(e(ves)?)?", "/^fr(i(day)?)?/": "^vi(e(rnes)?)?", "/^sa(t(urday)?)?/": "^sá(b(ado)?)?", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "es-SV"; /** * @overview datejs * @version 1.0.0-rc3 * @author Gregory Wild-Smith * @copyright 2015 Gregory Wild-Smith * @license MIT * @homepage https://github.com/abritinthebay/datejs */(function () { var $D = Date; var lang = Date.CultureStrings ? Date.CultureStrings.lang : null; var loggedKeys = {}; // for debug purposes. var getText = { getFromKey: function (key, countryCode) { var output; if (Date.CultureStrings && Date.CultureStrings[countryCode] && Date.CultureStrings[countryCode][key]) { output = Date.CultureStrings[countryCode][key]; } else { output = getText.buildFromDefault(key); } if (key.charAt(0) === "/") { // Assume it's a regex output = getText.buildFromRegex(key, countryCode); } return output; }, getFromObjectValues: function (obj, countryCode) { var key, output = {}; for(key in obj) { if (obj.hasOwnProperty(key)) { output[key] = getText.getFromKey(obj[key], countryCode); } } return output; }, getFromObjectKeys: function (obj, countryCode) { var key, output = {}; for(key in obj) { if (obj.hasOwnProperty(key)) { output[getText.getFromKey(key, countryCode)] = obj[key]; } } return output; }, getFromArray: function (arr, countryCode) { var output = []; for (var i=0; i < arr.length; i++){ if (i in arr) { output[i] = getText.getFromKey(arr[i], countryCode); } } return output; }, buildFromDefault: function (key) { var output, length, split, last; switch(key) { case "name": output = "en-US"; break; case "englishName": output = "English (United States)"; break; case "nativeName": output = "English (United States)"; break; case "twoDigitYearMax": output = 2049; break; case "firstDayOfWeek": output = 0; break; default: output = key; split = key.split("_"); length = split.length; if (length > 1 && key.charAt(0) !== "/") { // if the key isn't a regex and it has a split. last = split[(length - 1)].toLowerCase(); if (last === "initial" || last === "abbr") { output = split[0]; } } break; } return output; }, buildFromRegex: function (key, countryCode) { var output; if (Date.CultureStrings && Date.CultureStrings[countryCode] && Date.CultureStrings[countryCode][key]) { output = new RegExp(Date.CultureStrings[countryCode][key], "i"); } else { output = new RegExp(key.replace(new RegExp("/", "g"),""), "i"); } return output; } }; var shallowMerge = function (obj1, obj2) { for (var attrname in obj2) { if (obj2.hasOwnProperty(attrname)) { obj1[attrname] = obj2[attrname]; } } }; var __ = function (key, language) { var countryCode = (language) ? language : lang; loggedKeys[key] = key; if (typeof key === "object") { if (key instanceof Array) { return getText.getFromArray(key, countryCode); } else { return getText.getFromObjectKeys(key, countryCode); } } else { return getText.getFromKey(key, countryCode); } }; var loadI18nScript = function (code) { // paatterned after jQuery's getScript. var url = Date.Config.i18n + code + ".js"; var head = document.getElementsByTagName("head")[0] || document.documentElement; var script = document.createElement("script"); script.src = url; var completed = false; var events = { done: function (){} // placeholder function }; // Attach handlers for all browsers script.onload = script.onreadystatechange = function() { if ( !completed && (!this.readyState || this.readyState === "loaded" || this.readyState === "complete") ) { events.done(); head.removeChild(script); } }; setTimeout(function() { head.insertBefore(script, head.firstChild); }, 0); // allows return to execute first return { done: function (cb) { events.done = function() { if (cb) { setTimeout(cb,0); } }; } }; }; var buildInfo = { buildFromMethodHash: function (obj) { var key; for(key in obj) { if (obj.hasOwnProperty(key)) { obj[key] = buildInfo[obj[key]](); } } return obj; }, timeZoneDST: function () { var DST = { "CHADT": "+1345", "NZDT": "+1300", "AEDT": "+1100", "ACDT": "+1030", "AZST": "+0500", "IRDT": "+0430", "EEST": "+0300", "CEST": "+0200", "BST": "+0100", "PMDT": "-0200", "ADT": "-0300", "NDT": "-0230", "EDT": "-0400", "CDT": "-0500", "MDT": "-0600", "PDT": "-0700", "AKDT": "-0800", "HADT": "-0900" }; return __(DST); }, timeZoneStandard: function () { var standard = { "LINT": "+1400", "TOT": "+1300", "CHAST": "+1245", "NZST": "+1200", "NFT": "+1130", "SBT": "+1100", "AEST": "+1000", "ACST": "+0930", "JST": "+0900", "CWST": "+0845", "CT": "+0800", "ICT": "+0700", "MMT": "+0630", "BST": "+0600", "NPT": "+0545", "IST": "+0530", "PKT": "+0500", "AFT": "+0430", "MSK": "+0400", "IRST": "+0330", "FET": "+0300", "EET": "+0200", "CET": "+0100", "GMT": "+0000", "UTC": "+0000", "CVT": "-0100", "GST": "-0200", "BRT": "-0300", "NST": "-0330", "AST": "-0400", "EST": "-0500", "CST": "-0600", "MST": "-0700", "PST": "-0800", "AKST": "-0900", "MIT": "-0930", "HST": "-1000", "SST": "-1100", "BIT": "-1200" }; return __(standard); }, timeZones: function (data) { var zone; data.timezones = []; for (zone in data.abbreviatedTimeZoneStandard) { if (data.abbreviatedTimeZoneStandard.hasOwnProperty(zone)) { data.timezones.push({ name: zone, offset: data.abbreviatedTimeZoneStandard[zone]}); } } for (zone in data.abbreviatedTimeZoneDST) { if (data.abbreviatedTimeZoneDST.hasOwnProperty(zone)) { data.timezones.push({ name: zone, offset: data.abbreviatedTimeZoneDST[zone], dst: true}); } } return data.timezones; }, days: function () { return __(["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"]); }, dayAbbr: function () { return __(["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"]); }, dayShortNames: function () { return __(["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"]); }, dayFirstLetters: function () { return __(["S_Sun_Initial", "M_Mon_Initial", "T_Tues_Initial", "W_Wed_Initial", "T_Thu_Initial", "F_Fri_Initial", "S_Sat_Initial"]); }, months: function () { return __(["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"]); }, monthAbbr: function () { return __(["Jan_Abbr", "Feb_Abbr", "Mar_Abbr", "Apr_Abbr", "May_Abbr", "Jun_Abbr", "Jul_Abbr", "Aug_Abbr", "Sep_Abbr", "Oct_Abbr", "Nov_Abbr", "Dec_Abbr"]); }, formatPatterns: function () { return getText.getFromObjectValues({ shortDate: "M/d/yyyy", longDate: "dddd, MMMM dd, yyyy", shortTime: "h:mm tt", longTime: "h:mm:ss tt", fullDateTime: "dddd, MMMM dd, yyyy h:mm:ss tt", sortableDateTime: "yyyy-MM-ddTHH:mm:ss", universalSortableDateTime: "yyyy-MM-dd HH:mm:ssZ", rfc1123: "ddd, dd MMM yyyy HH:mm:ss", monthDay: "MMMM dd", yearMonth: "MMMM, yyyy" }, Date.i18n.currentLanguage()); }, regex: function () { return getText.getFromObjectValues({ inTheMorning: "/( in the )(morn(ing)?)\\b/", thisMorning: "/(this )(morn(ing)?)\\b/", amThisMorning: "/(\b\\d(am)? )(this )(morn(ing)?)/", inTheEvening: "/( in the )(even(ing)?)\\b/", thisEvening: "/(this )(even(ing)?)\\b/", pmThisEvening: "/(\b\\d(pm)? )(this )(even(ing)?)/", jan: "/jan(uary)?/", feb: "/feb(ruary)?/", mar: "/mar(ch)?/", apr: "/apr(il)?/", may: "/may/", jun: "/jun(e)?/", jul: "/jul(y)?/", aug: "/aug(ust)?/", sep: "/sep(t(ember)?)?/", oct: "/oct(ober)?/", nov: "/nov(ember)?/", dec: "/dec(ember)?/", sun: "/^su(n(day)?)?/", mon: "/^mo(n(day)?)?/", tue: "/^tu(e(s(day)?)?)?/", wed: "/^we(d(nesday)?)?/", thu: "/^th(u(r(s(day)?)?)?)?/", fri: "/fr(i(day)?)?/", sat: "/^sa(t(urday)?)?/", future: "/^next/", past: "/^last|past|prev(ious)?/", add: "/^(\\+|aft(er)?|from|hence)/", subtract: "/^(\\-|bef(ore)?|ago)/", yesterday: "/^yes(terday)?/", today: "/^t(od(ay)?)?/", tomorrow: "/^tom(orrow)?/", now: "/^n(ow)?/", millisecond: "/^ms|milli(second)?s?/", second: "/^sec(ond)?s?/", minute: "/^mn|min(ute)?s?/", hour: "/^h(our)?s?/", week: "/^w(eek)?s?/", month: "/^m(onth)?s?/", day: "/^d(ay)?s?/", year: "/^y(ear)?s?/", shortMeridian: "/^(a|p)/", longMeridian: "/^(a\\.?m?\\.?|p\\.?m?\\.?)/", timezone: "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/", ordinalSuffix: "/^\\s*(st|nd|rd|th)/", timeContext: "/^\\s*(\\:|a(?!u|p)|p)/" }, Date.i18n.currentLanguage()); } }; var CultureInfo = function () { var info = getText.getFromObjectValues({ name: "name", englishName: "englishName", nativeName: "nativeName", amDesignator: "AM", pmDesignator: "PM", firstDayOfWeek: "firstDayOfWeek", twoDigitYearMax: "twoDigitYearMax", dateElementOrder: "mdy" }, Date.i18n.currentLanguage()); var constructedInfo = buildInfo.buildFromMethodHash({ dayNames: "days", abbreviatedDayNames: "dayAbbr", shortestDayNames: "dayShortNames", firstLetterDayNames: "dayFirstLetters", monthNames: "months", abbreviatedMonthNames: "monthAbbr", formatPatterns: "formatPatterns", regexPatterns: "regex", abbreviatedTimeZoneDST: "timeZoneDST", abbreviatedTimeZoneStandard: "timeZoneStandard" }); shallowMerge(info, constructedInfo); buildInfo.timeZones(info); return info; }; $D.i18n = { __: function (key, lang) { return __(key, lang); }, currentLanguage: function () { return lang || "en-US"; }, setLanguage: function (code, force, cb) { var async = false; if (force || code === "en-US" || (!!Date.CultureStrings && !!Date.CultureStrings[code])) { lang = code; Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings.lang = code; Date.CultureInfo = new CultureInfo(); } else { if (!(!!Date.CultureStrings && !!Date.CultureStrings[code])) { if (typeof exports !== "undefined" && this.exports !== exports) { // we're in a Node enviroment, load it using require try { require("../i18n/" + code + ".js"); lang = code; Date.CultureStrings.lang = code; Date.CultureInfo = new CultureInfo(); } catch (e) { // var str = "The language for '" + code + "' could not be loaded by Node. It likely does not exist."; throw new Error("The DateJS IETF language tag '" + code + "' could not be loaded by Node. It likely does not exist."); } } else if (Date.Config && Date.Config.i18n) { // we know the location of the files, so lets load them async = true; loadI18nScript(code).done(function(){ lang = code; Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings.lang = code; Date.CultureInfo = new CultureInfo(); $D.Parsing.Normalizer.buildReplaceData(); // because this is async if ($D.Grammar) { $D.Grammar.buildGrammarFormats(); // so we can parse those strings... } if (cb) { setTimeout(cb,0); } }); } else { Date.console.error("The DateJS IETF language tag '" + code + "' is not available and has not been loaded."); return false; } } } $D.Parsing.Normalizer.buildReplaceData(); // rebuild normalizer strings if ($D.Grammar) { $D.Grammar.buildGrammarFormats(); // so we can parse those strings... } if (!async && cb) { setTimeout(cb,0); } }, getLoggedKeys: function () { return loggedKeys; }, updateCultureInfo: function () { Date.CultureInfo = new CultureInfo(); } }; $D.i18n.updateCultureInfo(); // run automatically }()); (function () { var $D = Date, $P = $D.prototype, p = function (s, l) { if (!l) { l = 2; } return ("000" + s).slice(l * -1); }; if (typeof window !== "undefined" && typeof window.console !== "undefined" && typeof window.console.log !== "undefined") { $D.console = console; // used only to raise non-critical errors if available } else { // set mock so we don't give errors. $D.console = { log: function(){}, error: function(){} }; } $D.Config = $D.Config || {}; $D.initOverloads = function() { /** * Overload of Date.now. Allows an alternate call for Date.now where it returns the * current Date as an object rather than just milliseconds since the Unix Epoch. * * Also provides an implementation of now() for browsers (IE<9) that don't have it. * * Backwards compatible so with work with either: * Date.now() [returns ms] * or * Date.now(true) [returns Date] */ if (!$D.now) { $D._now = function now() { return new Date().getTime(); }; } else if (!$D._now) { $D._now = $D.now; } $D.now = function (returnObj) { if (returnObj) { return $D.present(); } else { return $D._now(); } }; if ( !$P.toISOString ) { $P.toISOString = function() { return this.getUTCFullYear() + "-" + p(this.getUTCMonth() + 1) + "-" + p(this.getUTCDate()) + "T" + p(this.getUTCHours()) + ":" + p(this.getUTCMinutes()) + ":" + p(this.getUTCSeconds()) + "." + String( (this.getUTCMilliseconds()/1000).toFixed(3)).slice(2, 5) + "Z"; }; } // private if ( $P._toString === undefined ){ $P._toString = $P.toString; } }; $D.initOverloads(); /** * Gets a date that is set to the current date. The time is set to the start of the day (00:00 or 12:00 AM). * @return {Date} The current date. */ $D.today = function () { return new Date().clearTime(); }; /** * Gets a date that is set to the current date and time (same as new Date, but chainable) * @return {Date} The current date. */ $D.present = function () { return new Date(); }; /** * Compares the first date to the second date and returns an number indication of their relative values. * @param {Date} First Date object to compare [Required]. * @param {Date} Second Date object to compare to [Required]. * @return {Number} -1 = date1 is lessthan date2. 0 = values are equal. 1 = date1 is greaterthan date2. */ $D.compare = function (date1, date2) { if (isNaN(date1) || isNaN(date2)) { throw new Error(date1 + " - " + date2); } else if (date1 instanceof Date && date2 instanceof Date) { return (date1 < date2) ? -1 : (date1 > date2) ? 1 : 0; } else { throw new TypeError(date1 + " - " + date2); } }; /** * Compares the first Date object to the second Date object and returns true if they are equal. * @param {Date} First Date object to compare [Required] * @param {Date} Second Date object to compare to [Required] * @return {Boolean} true if dates are equal. false if they are not equal. */ $D.equals = function (date1, date2) { return (date1.compareTo(date2) === 0); }; /** * Gets the language appropriate day name when given the day number(0-6) * eg - 0 == Sunday * @return {String} The day name */ $D.getDayName = function (n) { return Date.CultureInfo.dayNames[n]; }; /** * Gets the day number (0-6) if given a CultureInfo specific string which is a valid dayName, abbreviatedDayName or shortestDayName (two char). * @param {String} The name of the day (eg. "Monday, "Mon", "tuesday", "tue", "We", "we"). * @return {Number} The day number */ $D.getDayNumberFromName = function (name) { var n = Date.CultureInfo.dayNames, m = Date.CultureInfo.abbreviatedDayNames, o = Date.CultureInfo.shortestDayNames, s = name.toLowerCase(); for (var i = 0; i < n.length; i++) { if (n[i].toLowerCase() === s || m[i].toLowerCase() === s || o[i].toLowerCase() === s) { return i; } } return -1; }; /** * Gets the month number (0-11) if given a Culture Info specific string which is a valid monthName or abbreviatedMonthName. * @param {String} The name of the month (eg. "February, "Feb", "october", "oct"). * @return {Number} The day number */ $D.getMonthNumberFromName = function (name) { var n = Date.CultureInfo.monthNames, m = Date.CultureInfo.abbreviatedMonthNames, s = name.toLowerCase(); for (var i = 0; i < n.length; i++) { if (n[i].toLowerCase() === s || m[i].toLowerCase() === s) { return i; } } return -1; }; /** * Gets the language appropriate month name when given the month number(0-11) * eg - 0 == January * @return {String} The month name */ $D.getMonthName = function (n) { return Date.CultureInfo.monthNames[n]; }; /** * Determines if the current date instance is within a LeapYear. * @param {Number} The year. * @return {Boolean} true if date is within a LeapYear, otherwise false. */ $D.isLeapYear = function (year) { return ((year % 4 === 0 && year % 100 !== 0) || year % 400 === 0); }; /** * Gets the number of days in the month, given a year and month value. Automatically corrects for LeapYear. * @param {Number} The year. * @param {Number} The month (0-11). * @return {Number} The number of days in the month. */ $D.getDaysInMonth = function (year, month) { if (!month && $D.validateMonth(year)) { month = year; year = Date.today().getFullYear(); } return [31, ($D.isLeapYear(year) ? 29 : 28), 31, 30, 31, 30, 31, 31, 30, 31, 30, 31][month]; }; $P.getDaysInMonth = function () { return $D.getDaysInMonth(this.getFullYear(), this.getMonth()); }; $D.getTimezoneAbbreviation = function (offset, dst) { var p, n = (dst || false) ? Date.CultureInfo.abbreviatedTimeZoneDST : Date.CultureInfo.abbreviatedTimeZoneStandard; for (p in n) { if (n.hasOwnProperty(p)) { if (n[p] === offset) { return p; } } } return null; }; $D.getTimezoneOffset = function (name, dst) { var i, a =[], z = Date.CultureInfo.timezones; if (!name) { name = (new Date()).getTimezone();} for (i = 0; i < z.length; i++) { if (z[i].name === name.toUpperCase()) { a.push(i); } } if (!z[a[0]]) { return null; } if (a.length === 1 || !dst) { return z[a[0]].offset; } else { for (i=0; i < a.length; i++) { if (z[a[i]].dst) { return z[a[i]].offset; } } } }; $D.getQuarter = function (d) { d = d || new Date(); // If no date supplied, use today var q = [1,2,3,4]; return q[Math.floor(d.getMonth() / 3)]; // ~~~ is a bitwise op. Faster than Math.floor }; $D.getDaysLeftInQuarter = function (d) { d = d || new Date(); var qEnd = new Date(d); qEnd.setMonth(qEnd.getMonth() + 3 - qEnd.getMonth() % 3, 0); return Math.floor((qEnd - d) / 8.64e7); }; // private var validate = function (n, min, max, name) { name = name ? name : "Object"; if (typeof n === "undefined") { return false; } else if (typeof n !== "number") { throw new TypeError(n + " is not a Number."); } else if (n < min || n > max) { // As failing validation is *not* an exceptional circumstance // lets not throw a RangeError Exception here. // It's semantically correct but it's not sensible. return false; } return true; }; /** * Validates the number is within an acceptable range for milliseconds [0-999]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateMillisecond = function (value) { return validate(value, 0, 999, "millisecond"); }; /** * Validates the number is within an acceptable range for seconds [0-59]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateSecond = function (value) { return validate(value, 0, 59, "second"); }; /** * Validates the number is within an acceptable range for minutes [0-59]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateMinute = function (value) { return validate(value, 0, 59, "minute"); }; /** * Validates the number is within an acceptable range for hours [0-23]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateHour = function (value) { return validate(value, 0, 23, "hour"); }; /** * Validates the number is within an acceptable range for the days in a month [0-MaxDaysInMonth]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateDay = function (value, year, month) { if (year === undefined || year === null || month === undefined || month === null) { return false;} return validate(value, 1, $D.getDaysInMonth(year, month), "day"); }; /** * Validates the number is within an acceptable range for months [0-11]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateWeek = function (value) { return validate(value, 0, 53, "week"); }; /** * Validates the number is within an acceptable range for months [0-11]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateMonth = function (value) { return validate(value, 0, 11, "month"); }; /** * Validates the number is within an acceptable range for years. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateYear = function (value) { /** * Per ECMAScript spec the range of times supported by Date objects is * exactly -100,000,000 days to +100,000,000 days measured relative to * midnight at the beginning of 01 January, 1970 UTC. * This gives a range of 8,640,000,000,000,000 milliseconds to either * side of 01 January, 1970 UTC. * * Earliest possible date: Tue, 20 Apr 271,822 B.C. 00:00:00 UTC * Latest possible date: Sat, 13 Sep 275,760 00:00:00 UTC */ return validate(value, -271822, 275760, "year"); }; $D.validateTimezone = function(value) { var timezones = {"ACDT":1,"ACST":1,"ACT":1,"ADT":1,"AEDT":1,"AEST":1,"AFT":1,"AKDT":1,"AKST":1,"AMST":1,"AMT":1,"ART":1,"AST":1,"AWDT":1,"AWST":1,"AZOST":1,"AZT":1,"BDT":1,"BIOT":1,"BIT":1,"BOT":1,"BRT":1,"BST":1,"BTT":1,"CAT":1,"CCT":1,"CDT":1,"CEDT":1,"CEST":1,"CET":1,"CHADT":1,"CHAST":1,"CHOT":1,"ChST":1,"CHUT":1,"CIST":1,"CIT":1,"CKT":1,"CLST":1,"CLT":1,"COST":1,"COT":1,"CST":1,"CT":1,"CVT":1,"CWST":1,"CXT":1,"DAVT":1,"DDUT":1,"DFT":1,"EASST":1,"EAST":1,"EAT":1,"ECT":1,"EDT":1,"EEDT":1,"EEST":1,"EET":1,"EGST":1,"EGT":1,"EIT":1,"EST":1,"FET":1,"FJT":1,"FKST":1,"FKT":1,"FNT":1,"GALT":1,"GAMT":1,"GET":1,"GFT":1,"GILT":1,"GIT":1,"GMT":1,"GST":1,"GYT":1,"HADT":1,"HAEC":1,"HAST":1,"HKT":1,"HMT":1,"HOVT":1,"HST":1,"ICT":1,"IDT":1,"IOT":1,"IRDT":1,"IRKT":1,"IRST":1,"IST":1,"JST":1,"KGT":1,"KOST":1,"KRAT":1,"KST":1,"LHST":1,"LINT":1,"MAGT":1,"MART":1,"MAWT":1,"MDT":1,"MET":1,"MEST":1,"MHT":1,"MIST":1,"MIT":1,"MMT":1,"MSK":1,"MST":1,"MUT":1,"MVT":1,"MYT":1,"NCT":1,"NDT":1,"NFT":1,"NPT":1,"NST":1,"NT":1,"NUT":1,"NZDT":1,"NZST":1,"OMST":1,"ORAT":1,"PDT":1,"PET":1,"PETT":1,"PGT":1,"PHOT":1,"PHT":1,"PKT":1,"PMDT":1,"PMST":1,"PONT":1,"PST":1,"PYST":1,"PYT":1,"RET":1,"ROTT":1,"SAKT":1,"SAMT":1,"SAST":1,"SBT":1,"SCT":1,"SGT":1,"SLST":1,"SRT":1,"SST":1,"SYOT":1,"TAHT":1,"THA":1,"TFT":1,"TJT":1,"TKT":1,"TLT":1,"TMT":1,"TOT":1,"TVT":1,"UCT":1,"ULAT":1,"UTC":1,"UYST":1,"UYT":1,"UZT":1,"VET":1,"VLAT":1,"VOLT":1,"VOST":1,"VUT":1,"WAKT":1,"WAST":1,"WAT":1,"WEDT":1,"WEST":1,"WET":1,"WST":1,"YAKT":1,"YEKT":1,"Z":1}; return (timezones[value] === 1); }; $D.validateTimezoneOffset= function(value) { // timezones go from +14hrs to -12hrs, the +X hours are negative offsets. return (value > -841 && value < 721); }; }()); (function () { var $D = Date, $P = $D.prototype, p = function (s, l) { if (!l) { l = 2; } return ("000" + s).slice(l * -1); }; var validateConfigObject = function (obj) { var result = {}, self = this, prop, testFunc; testFunc = function (prop, func, value) { if (prop === "day") { var month = (obj.month !== undefined) ? obj.month : self.getMonth(); var year = (obj.year !== undefined) ? obj.year : self.getFullYear(); return $D[func](value, year, month); } else { return $D[func](value); } }; for (prop in obj) { if (Object.prototype.hasOwnProperty.call(obj, prop)) { var func = "validate" + prop.charAt(0).toUpperCase() + prop.slice(1); if ($D[func] && obj[prop] !== null && testFunc(prop, func, obj[prop])) { result[prop] = obj[prop]; } } } return result; }; /** * Resets the time of this Date object to 12:00 AM (00:00), which is the start of the day. * @param {Boolean} .clone() this date instance before clearing Time * @return {Date} this */ $P.clearTime = function () { this.setHours(0); this.setMinutes(0); this.setSeconds(0); this.setMilliseconds(0); return this; }; /** * Resets the time of this Date object to the current time ('now'). * @return {Date} this */ $P.setTimeToNow = function () { var n = new Date(); this.setHours(n.getHours()); this.setMinutes(n.getMinutes()); this.setSeconds(n.getSeconds()); this.setMilliseconds(n.getMilliseconds()); return this; }; /** * Returns a new Date object that is an exact date and time copy of the original instance. * @return {Date} A new Date instance */ $P.clone = function () { return new Date(this.getTime()); }; /** * Compares this instance to a Date object and returns an number indication of their relative values. * @param {Date} Date object to compare [Required] * @return {Number} -1 = this is lessthan date. 0 = values are equal. 1 = this is greaterthan date. */ $P.compareTo = function (date) { return Date.compare(this, date); }; /** * Compares this instance to another Date object and returns true if they are equal. * @param {Date} Date object to compare. If no date to compare, new Date() [now] is used. * @return {Boolean} true if dates are equal. false if they are not equal. */ $P.equals = function (date) { return Date.equals(this, (date !== undefined ? date : new Date())); }; /** * Determines if this instance is between a range of two dates or equal to either the start or end dates. * @param {Date} Start of range [Required] * @param {Date} End of range [Required] * @return {Boolean} true is this is between or equal to the start and end dates, else false */ $P.between = function (start, end) { return this.getTime() >= start.getTime() && this.getTime() <= end.getTime(); }; /** * Determines if this date occurs after the date to compare to. * @param {Date} Date object to compare. If no date to compare, new Date() ("now") is used. * @return {Boolean} true if this date instance is greater than the date to compare to (or "now"), otherwise false. */ $P.isAfter = function (date) { return this.compareTo(date || new Date()) === 1; }; /** * Determines if this date occurs before the date to compare to. * @param {Date} Date object to compare. If no date to compare, new Date() ("now") is used. * @return {Boolean} true if this date instance is less than the date to compare to (or "now"). */ $P.isBefore = function (date) { return (this.compareTo(date || new Date()) === -1); }; /** * Determines if the current Date instance occurs today. * @return {Boolean} true if this date instance is 'today', otherwise false. */ /** * Determines if the current Date instance occurs on the same Date as the supplied 'date'. * If no 'date' to compare to is provided, the current Date instance is compared to 'today'. * @param {date} Date object to compare. If no date to compare, the current Date ("now") is used. * @return {Boolean} true if this Date instance occurs on the same Day as the supplied 'date'. */ $P.isToday = $P.isSameDay = function (date) { return this.clone().clearTime().equals((date || new Date()).clone().clearTime()); }; /** * Adds the specified number of milliseconds to this instance. * @param {Number} The number of milliseconds to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addMilliseconds = function (value) { if (!value) { return this; } this.setTime(this.getTime() + value * 1); return this; }; /** * Adds the specified number of seconds to this instance. * @param {Number} The number of seconds to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addSeconds = function (value) { if (!value) { return this; } return this.addMilliseconds(value * 1000); }; /** * Adds the specified number of seconds to this instance. * @param {Number} The number of seconds to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addMinutes = function (value) { if (!value) { return this; } return this.addMilliseconds(value * 60000); // 60*1000 }; /** * Adds the specified number of hours to this instance. * @param {Number} The number of hours to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addHours = function (value) { if (!value) { return this; } return this.addMilliseconds(value * 3600000); // 60*60*1000 }; /** * Adds the specified number of days to this instance. * @param {Number} The number of days to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addDays = function (value) { if (!value) { return this; } this.setDate(this.getDate() + value * 1); return this; }; /** * Adds the specified number of weekdays (ie - not sat or sun) to this instance. * @param {Number} The number of days to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addWeekdays = function (value) { if (!value) { return this; } var day = this.getDay(); var weeks = (Math.ceil(Math.abs(value)/7)); if (day === 0 || day === 6) { if (value > 0) { this.next().monday(); this.addDays(-1); day = this.getDay(); } } if (value < 0) { while (value < 0) { this.addDays(-1); day = this.getDay(); if (day !== 0 && day !== 6) { value++; } } return this; } else if (value > 5 || (6-day) <= value) { value = value + (weeks * 2); } return this.addDays(value); }; /** * Adds the specified number of weeks to this instance. * @param {Number} The number of weeks to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addWeeks = function (value) { if (!value) { return this; } return this.addDays(value * 7); }; /** * Adds the specified number of months to this instance. * @param {Number} The number of months to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addMonths = function (value) { if (!value) { return this; } var n = this.getDate(); this.setDate(1); this.setMonth(this.getMonth() + value * 1); this.setDate(Math.min(n, $D.getDaysInMonth(this.getFullYear(), this.getMonth()))); return this; }; $P.addQuarters = function (value) { if (!value) { return this; } // note this will take you to the same point in the quarter as you are now. // i.e. - if you are 15 days into the quarter you'll be 15 days into the resulting one. // bonus: this allows adding fractional quarters return this.addMonths(value * 3); }; /** * Adds the specified number of years to this instance. * @param {Number} The number of years to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addYears = function (value) { if (!value) { return this; } return this.addMonths(value * 12); }; /** * Adds (or subtracts) to the value of the years, months, weeks, days, hours, minutes, seconds, milliseconds of the date instance using given configuration object. Positive and Negative values allowed. * Example

	Date.today().add( { days: 1, months: 1 } )

	new Date().add( { years: -1 } )
	
* @param {Object} Configuration object containing attributes (months, days, etc.) * @return {Date} this */ $P.add = function (config) { if (typeof config === "number") { this._orient = config; return this; } var x = config; if (x.day) { // If we should be a different date than today (eg: for 'tomorrow -1d', etc). // Should only effect parsing, not direct usage (eg, Finish and FinishExact) if ((x.day - this.getDate()) !== 0) { this.setDate(x.day); } } if (x.milliseconds) { this.addMilliseconds(x.milliseconds); } if (x.seconds) { this.addSeconds(x.seconds); } if (x.minutes) { this.addMinutes(x.minutes); } if (x.hours) { this.addHours(x.hours); } if (x.weeks) { this.addWeeks(x.weeks); } if (x.months) { this.addMonths(x.months); } if (x.years) { this.addYears(x.years); } if (x.days) { this.addDays(x.days); } return this; }; /** * Get the week number. Week one (1) is the week which contains the first Thursday of the year. Monday is considered the first day of the week. * The .getWeek() function does NOT convert the date to UTC. The local datetime is used. * Please use .getISOWeek() to get the week of the UTC converted date. * @return {Number} 1 to 53 */ $P.getWeek = function (utc) { // Create a copy of this date object var self, target = new Date(this.valueOf()); if (utc) { target.addMinutes(target.getTimezoneOffset()); self = target.clone(); } else { self = this; } // ISO week date weeks start on monday // so correct the day number var dayNr = (self.getDay() + 6) % 7; // ISO 8601 states that week 1 is the week // with the first thursday of that year. // Set the target date to the thursday in the target week target.setDate(target.getDate() - dayNr + 3); // Store the millisecond value of the target date var firstThursday = target.valueOf(); // Set the target to the first thursday of the year // First set the target to january first target.setMonth(0, 1); // Not a thursday? Correct the date to the next thursday if (target.getDay() !== 4) { target.setMonth(0, 1 + ((4 - target.getDay()) + 7) % 7); } // The weeknumber is the number of weeks between the // first thursday of the year and the thursday in the target week return 1 + Math.ceil((firstThursday - target) / 604800000); // 604800000 = 7 * 24 * 3600 * 1000 }; /** * Get the ISO 8601 week number. Week one ("01") is the week which contains the first Thursday of the year. Monday is considered the first day of the week. * The .getISOWeek() function does convert the date to it's UTC value. Please use .getWeek() to get the week of the local date. * @return {String} "01" to "53" */ $P.getISOWeek = function () { return p(this.getWeek(true)); }; /** * Moves the date to Monday of the week set. Week one (1) is the week which contains the first Thursday of the year. * @param {Number} A Number (1 to 53) that represents the week of the year. * @return {Date} this */ $P.setWeek = function (n) { if ((n - this.getWeek()) === 0) { if (this.getDay() !== 1) { return this.moveToDayOfWeek(1, (this.getDay() > 1 ? -1 : 1)); } else { return this; } } else { return this.moveToDayOfWeek(1, (this.getDay() > 1 ? -1 : 1)).addWeeks(n - this.getWeek()); } }; $P.setQuarter = function (qtr) { var month = Math.abs(((qtr-1) * 3) + 1); return this.setMonth(month, 1); }; $P.getQuarter = function () { return Date.getQuarter(this); }; $P.getDaysLeftInQuarter = function () { return Date.getDaysLeftInQuarter(this); }; /** * Moves the date to the next n'th occurrence of the dayOfWeek starting from the beginning of the month. The number (-1) is a magic number and will return the last occurrence of the dayOfWeek in the month. * @param {Number} The dayOfWeek to move to * @param {Number} The n'th occurrence to move to. Use (-1) to return the last occurrence in the month * @return {Date} this */ $P.moveToNthOccurrence = function (dayOfWeek, occurrence) { if (dayOfWeek === "Weekday") { if (occurrence > 0) { this.moveToFirstDayOfMonth(); if (this.is().weekday()) { occurrence -= 1; } } else if (occurrence < 0) { this.moveToLastDayOfMonth(); if (this.is().weekday()) { occurrence += 1; } } else { return this; } return this.addWeekdays(occurrence); } var shift = 0; if (occurrence > 0) { shift = occurrence - 1; } else if (occurrence === -1) { this.moveToLastDayOfMonth(); if (this.getDay() !== dayOfWeek) { this.moveToDayOfWeek(dayOfWeek, -1); } return this; } return this.moveToFirstDayOfMonth().addDays(-1).moveToDayOfWeek(dayOfWeek, +1).addWeeks(shift); }; var moveToN = function (getFunc, addFunc, nVal) { return function (value, orient) { var diff = (value - this[getFunc]() + nVal * (orient || +1)) % nVal; return this[addFunc]((diff === 0) ? diff += nVal * (orient || +1) : diff); }; }; /** * Move to the next or last dayOfWeek based on the orient value. * @param {Number} The dayOfWeek to move to * @param {Number} Forward (+1) or Back (-1). Defaults to +1. [Optional] * @return {Date} this */ $P.moveToDayOfWeek = moveToN("getDay", "addDays", 7); /** * Move to the next or last month based on the orient value. * @param {Number} The month to move to. 0 = January, 11 = December * @param {Number} Forward (+1) or Back (-1). Defaults to +1. [Optional] * @return {Date} this */ $P.moveToMonth = moveToN("getMonth", "addMonths", 12); /** * Get the Ordinate of the current day ("th", "st", "rd"). * @return {String} */ $P.getOrdinate = function () { var num = this.getDate(); return ord(num); }; /** * Get the Ordinal day (numeric day number) of the year, adjusted for leap year. * @return {Number} 1 through 365 (366 in leap years) */ $P.getOrdinalNumber = function () { return Math.ceil((this.clone().clearTime() - new Date(this.getFullYear(), 0, 1)) / 86400000) + 1; }; /** * Get the time zone abbreviation of the current date. * @return {String} The abbreviated time zone name (e.g. "EST") */ $P.getTimezone = function () { return $D.getTimezoneAbbreviation(this.getUTCOffset(), this.isDaylightSavingTime()); }; $P.setTimezoneOffset = function (offset) { var here = this.getTimezoneOffset(), there = Number(offset) * -6 / 10; return (there || there === 0) ? this.addMinutes(there - here) : this; }; $P.setTimezone = function (offset) { return this.setTimezoneOffset($D.getTimezoneOffset(offset)); }; /** * Indicates whether Daylight Saving Time is observed in the current time zone. * @return {Boolean} true|false */ $P.hasDaylightSavingTime = function () { return (Date.today().set({month: 0, day: 1}).getTimezoneOffset() !== Date.today().set({month: 6, day: 1}).getTimezoneOffset()); }; /** * Indicates whether this Date instance is within the Daylight Saving Time range for the current time zone. * @return {Boolean} true|false */ $P.isDaylightSavingTime = function () { return Date.today().set({month: 0, day: 1}).getTimezoneOffset() !== this.getTimezoneOffset(); }; /** * Get the offset from UTC of the current date. * @return {String} The 4-character offset string prefixed with + or - (e.g. "-0500") */ $P.getUTCOffset = function (offset) { var n = (offset || this.getTimezoneOffset()) * -10 / 6, r; if (n < 0) { r = (n - 10000).toString(); return r.charAt(0) + r.substr(2); } else { r = (n + 10000).toString(); return "+" + r.substr(1); } }; /** * Returns the number of milliseconds between this date and date. * @param {Date} Defaults to now * @return {Number} The diff in milliseconds */ $P.getElapsed = function (date) { return (date || new Date()) - this; }; /** * Set the value of year, month, day, hour, minute, second, millisecond of date instance using given configuration object. * Example

	Date.today().set( { day: 20, month: 1 } )

	new Date().set( { millisecond: 0 } )
	
* * @param {Object} Configuration object containing attributes (month, day, etc.) * @return {Date} this */ $P.set = function (config) { config = validateConfigObject.call(this, config); var key; for (key in config) { if (Object.prototype.hasOwnProperty.call(config, key)) { var name = key.charAt(0).toUpperCase() + key.slice(1); var addFunc, getFunc; if (key !== "week" && key !== "month" && key !== "timezone" && key !== "timezoneOffset") { name += "s"; } addFunc = "add" + name; getFunc = "get" + name; if (key === "month") { addFunc = addFunc + "s"; } else if (key === "year"){ getFunc = "getFullYear"; } if (key !== "day" && key !== "timezone" && key !== "timezoneOffset" && key !== "week" && key !== "hour") { this[addFunc](config[key] - this[getFunc]()); } else if ( key === "timezone"|| key === "timezoneOffset" || key === "week" || key === "hour") { this["set"+name](config[key]); } } } // day has to go last because you can't validate the day without first knowing the month if (config.day) { this.addDays(config.day - this.getDate()); } return this; }; /** * Moves the date to the first day of the month. * @return {Date} this */ $P.moveToFirstDayOfMonth = function () { return this.set({ day: 1 }); }; /** * Moves the date to the last day of the month. * @return {Date} this */ $P.moveToLastDayOfMonth = function () { return this.set({ day: $D.getDaysInMonth(this.getFullYear(), this.getMonth())}); }; /** * Converts the value of the current Date object to its equivalent string representation. * Format Specifiers * CUSTOM DATE AND TIME FORMAT STRINGS * Format Description Example * ------ --------------------------------------------------------------------------- ----------------------- * s The seconds of the minute between 0-59. "0" to "59" * ss The seconds of the minute with leading zero if required. "00" to "59" * * m The minute of the hour between 0-59. "0" or "59" * mm The minute of the hour with leading zero if required. "00" or "59" * * h The hour of the day between 1-12. "1" to "12" * hh The hour of the day with leading zero if required. "01" to "12" * * H The hour of the day between 0-23. "0" to "23" * HH The hour of the day with leading zero if required. "00" to "23" * * d The day of the month between 1 and 31. "1" to "31" * dd The day of the month with leading zero if required. "01" to "31" * ddd Abbreviated day name. Date.CultureInfo.abbreviatedDayNames. "Mon" to "Sun" * dddd The full day name. Date.CultureInfo.dayNames. "Monday" to "Sunday" * * M The month of the year between 1-12. "1" to "12" * MM The month of the year with leading zero if required. "01" to "12" * MMM Abbreviated month name. Date.CultureInfo.abbreviatedMonthNames. "Jan" to "Dec" * MMMM The full month name. Date.CultureInfo.monthNames. "January" to "December" * * yy The year as a two-digit number. "99" or "08" * yyyy The full four digit year. "1999" or "2008" * * t Displays the first character of the A.M./P.M. designator. "A" or "P" * Date.CultureInfo.amDesignator or Date.CultureInfo.pmDesignator * tt Displays the A.M./P.M. designator. "AM" or "PM" * Date.CultureInfo.amDesignator or Date.CultureInfo.pmDesignator * * S The ordinal suffix ("st, "nd", "rd" or "th") of the current day. "st, "nd", "rd" or "th" * * STANDARD DATE AND TIME FORMAT STRINGS * Format Description Example *------ --------------------------------------------------------------------------- ----------------------- * d The CultureInfo shortDate Format Pattern "M/d/yyyy" * D The CultureInfo longDate Format Pattern "dddd, MMMM dd, yyyy" * F The CultureInfo fullDateTime Format Pattern "dddd, MMMM dd, yyyy h:mm:ss tt" * m The CultureInfo monthDay Format Pattern "MMMM dd" * r The CultureInfo rfc1123 Format Pattern "ddd, dd MMM yyyy HH:mm:ss GMT" * s The CultureInfo sortableDateTime Format Pattern "yyyy-MM-ddTHH:mm:ss" * t The CultureInfo shortTime Format Pattern "h:mm tt" * T The CultureInfo longTime Format Pattern "h:mm:ss tt" * u The CultureInfo universalSortableDateTime Format Pattern "yyyy-MM-dd HH:mm:ssZ" * y The CultureInfo yearMonth Format Pattern "MMMM, yyyy" * * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @return {String} A string representation of the current Date object. */ var ord = function (n) { switch (n * 1) { case 1: case 21: case 31: return "st"; case 2: case 22: return "nd"; case 3: case 23: return "rd"; default: return "th"; } }; var parseStandardFormats = function (format) { var y, c = Date.CultureInfo.formatPatterns; switch (format) { case "d": return this.toString(c.shortDate); case "D": return this.toString(c.longDate); case "F": return this.toString(c.fullDateTime); case "m": return this.toString(c.monthDay); case "r": case "R": y = this.clone().addMinutes(this.getTimezoneOffset()); return y.toString(c.rfc1123) + " GMT"; case "s": return this.toString(c.sortableDateTime); case "t": return this.toString(c.shortTime); case "T": return this.toString(c.longTime); case "u": y = this.clone().addMinutes(this.getTimezoneOffset()); return y.toString(c.universalSortableDateTime); case "y": return this.toString(c.yearMonth); default: return false; } }; var parseFormatStringsClosure = function (context) { return function (m) { if (m.charAt(0) === "\\") { return m.replace("\\", ""); } switch (m) { case "hh": return p(context.getHours() < 13 ? (context.getHours() === 0 ? 12 : context.getHours()) : (context.getHours() - 12)); case "h": return context.getHours() < 13 ? (context.getHours() === 0 ? 12 : context.getHours()) : (context.getHours() - 12); case "HH": return p(context.getHours()); case "H": return context.getHours(); case "mm": return p(context.getMinutes()); case "m": return context.getMinutes(); case "ss": return p(context.getSeconds()); case "s": return context.getSeconds(); case "yyyy": return p(context.getFullYear(), 4); case "yy": return p(context.getFullYear()); case "y": return context.getFullYear(); case "E": case "dddd": return Date.CultureInfo.dayNames[context.getDay()]; case "ddd": return Date.CultureInfo.abbreviatedDayNames[context.getDay()]; case "dd": return p(context.getDate()); case "d": return context.getDate(); case "MMMM": return Date.CultureInfo.monthNames[context.getMonth()]; case "MMM": return Date.CultureInfo.abbreviatedMonthNames[context.getMonth()]; case "MM": return p((context.getMonth() + 1)); case "M": return context.getMonth() + 1; case "t": return context.getHours() < 12 ? Date.CultureInfo.amDesignator.substring(0, 1) : Date.CultureInfo.pmDesignator.substring(0, 1); case "tt": return context.getHours() < 12 ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator; case "S": return ord(context.getDate()); case "W": return context.getWeek(); case "WW": return context.getISOWeek(); case "Q": return "Q" + context.getQuarter(); case "q": return String(context.getQuarter()); case "z": return context.getTimezone(); case "Z": case "X": return Date.getTimezoneOffset(context.getTimezone()); case "ZZ": // Timezone offset in seconds return context.getTimezoneOffset() * -60; case "u": return context.getDay(); case "L": return ($D.isLeapYear(context.getFullYear())) ? 1 : 0; case "B": // Swatch Internet Time (.beats) return "@"+((context.getUTCSeconds() + (context.getUTCMinutes()*60) + ((context.getUTCHours()+1)*3600))/86.4); default: return m; } }; }; $P.toString = function (format, ignoreStandards) { // Standard Date and Time Format Strings. Formats pulled from CultureInfo file and // may vary by culture. if (!ignoreStandards && format && format.length === 1) { output = parseStandardFormats.call(this, format); if (output) { return output; } } var parseFormatStrings = parseFormatStringsClosure(this); return format ? format.replace(/((\\)?(dd?d?d?|MM?M?M?|yy?y?y?|hh?|HH?|mm?|ss?|tt?|S|q|Q|WW?W?W?)(?![^\[]*\]))/g, parseFormatStrings).replace(/\[|\]/g, "") : this._toString(); }; }()); /************************************************************* * SugarPak - Domain Specific Language - Syntactical Sugar * *************************************************************/ (function () { var $D = Date, $P = $D.prototype, $N = Number.prototype; // private $P._orient = +1; // private $P._nth = null; // private $P._is = false; // private $P._same = false; // private $P._isSecond = false; // private $N._dateElement = "days"; /** * Moves the date to the next instance of a date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.today().next().friday();
	Date.today().next().fri();
	Date.today().next().march();
	Date.today().next().mar();
	Date.today().next().week();
	
* * @return {Date} date */ $P.next = function () { this._move = true; this._orient = +1; return this; }; /** * Creates a new Date (Date.today()) and moves the date to the next instance of the date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.next().friday();
	Date.next().fri();
	Date.next().march();
	Date.next().mar();
	Date.next().week();
	
* * @return {Date} date */ $D.next = function () { return $D.today().next(); }; /** * Moves the date to the previous instance of a date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.today().last().friday();
	Date.today().last().fri();
	Date.today().last().march();
	Date.today().last().mar();
	Date.today().last().week();
	
* * @return {Date} date */ $P.last = $P.prev = $P.previous = function () { this._move = true; this._orient = -1; return this; }; /** * Creates a new Date (Date.today()) and moves the date to the previous instance of the date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.last().friday();
	Date.last().fri();
	Date.previous().march();
	Date.prev().mar();
	Date.last().week();
	
* * @return {Date} date */ $D.last = $D.prev = $D.previous = function () { return $D.today().last(); }; /** * Performs a equality check when followed by either a month name, day name or .weekday() function. * Example

	Date.today().is().friday(); // true|false
	Date.today().is().fri();
	Date.today().is().march();
	Date.today().is().mar();
	
* * @return {Boolean} true|false */ $P.is = function () { this._is = true; return this; }; /** * Determines if two date objects occur on/in exactly the same instance of the subsequent date part function. * The function .same() must be followed by a date part function (example: .day(), .month(), .year(), etc). * * An optional Date can be passed in the date part function. If now date is passed as a parameter, 'Now' is used. * * The following example demonstrates how to determine if two dates fall on the exact same day. * * Example

	var d1 = Date.today(); // today at 00:00
	var d2 = new Date();   // exactly now.

	// Do they occur on the same day?
	d1.same().day(d2); // true
	
	// Do they occur on the same hour?
	d1.same().hour(d2); // false, unless d2 hour is '00' (midnight).
	
	// What if it's the same day, but one year apart?
	var nextYear = Date.today().add(1).year();

	d1.same().day(nextYear); // false, because the dates must occur on the exact same day. 
	
* * Scenario: Determine if a given date occurs during some week period 2 months from now. * * Example

	var future = Date.today().add(2).months();
	return someDate.same().week(future); // true|false;
	
* * @return {Boolean} true|false */ $P.same = function () { this._same = true; this._isSecond = false; return this; }; /** * Determines if the current date/time occurs during Today. Must be preceded by the .is() function. * Example

	someDate.is().today();    // true|false
	new Date().is().today();  // true
	Date.today().is().today();// true
	Date.today().add(-1).day().is().today(); // false
	
* * @return {Boolean} true|false */ $P.today = function () { return this.same().day(); }; /** * Determines if the current date is a weekday. This function must be preceded by the .is() function. * Example

	Date.today().is().weekday(); // true|false
	
* * @return {Boolean} true|false */ $P.weekday = function () { if (this._nth) { return df("Weekday").call(this); } if (this._move) { return this.addWeekdays(this._orient); } if (this._is) { this._is = false; return (!this.is().sat() && !this.is().sun()); } return false; }; /** * Determines if the current date is on the weekend. This function must be preceded by the .is() function. * Example

	Date.today().is().weekend(); // true|false
	
* * @return {Boolean} true|false */ $P.weekend = function () { if (this._is) { this._is = false; return (this.is().sat() || this.is().sun()); } return false; }; /** * Sets the Time of the current Date instance. A string "6:15 pm" or config object {hour:18, minute:15} are accepted. * Example

	// Set time to 6:15pm with a String
	Date.today().at("6:15pm");

	// Set time to 6:15pm with a config object
	Date.today().at({hour:18, minute:15});
	
* * @return {Date} date */ $P.at = function (time) { return (typeof time === "string") ? $D.parse(this.toString("d") + " " + time) : this.set(time); }; /** * Creates a new Date() and adds this (Number) to the date based on the preceding date element function (eg. second|minute|hour|day|month|year). * Example

	// Undeclared Numbers must be wrapped with parentheses. Requirment of JavaScript.
	(3).days().fromNow();
	(6).months().fromNow();

	// Declared Number variables do not require parentheses. 
	var n = 6;
	n.months().fromNow();
	
* * @return {Date} A new Date instance */ $N.fromNow = $N.after = function (date) { var c = {}; c[this._dateElement] = this; return ((!date) ? new Date() : date.clone()).add(c); }; /** * Creates a new Date() and subtract this (Number) from the date based on the preceding date element function (eg. second|minute|hour|day|month|year). * Example

	// Undeclared Numbers must be wrapped with parentheses. Requirment of JavaScript.
	(3).days().ago();
	(6).months().ago();

	// Declared Number variables do not require parentheses. 
	var n = 6;
	n.months().ago();
	
* * @return {Date} A new Date instance */ $N.ago = $N.before = function (date) { var c = {}, s = (this._dateElement[this._dateElement.length-1] !== "s") ? this._dateElement + "s" : this._dateElement; c[s] = this * -1; return ((!date) ? new Date() : date.clone()).add(c); }; // Do NOT modify the following string tokens. These tokens are used to build dynamic functions. // All culture-specific strings can be found in the CultureInfo files. var dx = ("sunday monday tuesday wednesday thursday friday saturday").split(/\s/), mx = ("january february march april may june july august september october november december").split(/\s/), px = ("Millisecond Second Minute Hour Day Week Month Year Quarter Weekday").split(/\s/), pxf = ("Milliseconds Seconds Minutes Hours Date Week Month FullYear Quarter").split(/\s/), nth = ("final first second third fourth fifth").split(/\s/), de; /** * Returns an object literal of all the date parts. * Example

	var o = new Date().toObject();
	
	// { year: 2008, month: 4, week: 20, day: 13, hour: 18, minute: 9, second: 32, millisecond: 812 }
	
	// The object properties can be referenced directly from the object.
	
	alert(o.day);  // alerts "13"
	alert(o.year); // alerts "2008"
	
* * @return {Date} An object literal representing the original date object. */ $P.toObject = function () { var o = {}; for (var i = 0; i < px.length; i++) { if (this["get" + pxf[i]]) { o[px[i].toLowerCase()] = this["get" + pxf[i]](); } } return o; }; /** * Returns a date created from an object literal. Ignores the .week property if set in the config. * Example

	var o = new Date().toObject();
	
	return Date.fromObject(o); // will return the same date. 

	var o2 = {month: 1, day: 20, hour: 18}; // birthday party!
	Date.fromObject(o2);
	
* * @return {Date} An object literal representing the original date object. */ $D.fromObject = function(config) { config.week = null; return Date.today().set(config); }; // Create day name functions and abbreviated day name functions (eg. monday(), friday(), fri()). var df = function (n) { return function () { if (this._is) { this._is = false; return this.getDay() === n; } if (this._move) { this._move = null; } if (this._nth !== null) { // If the .second() function was called earlier, remove the _orient // from the date, and then continue. // This is required because 'second' can be used in two different context. // // Example // // Date.today().add(1).second(); // Date.march().second().monday(); // // Things get crazy with the following... // Date.march().add(1).second().second().monday(); // but it works!! // if (this._isSecond) { this.addSeconds(this._orient * -1); } // make sure we reset _isSecond this._isSecond = false; var ntemp = this._nth; this._nth = null; var temp = this.clone().moveToLastDayOfMonth(); this.moveToNthOccurrence(n, ntemp); if (this > temp) { throw new RangeError($D.getDayName(n) + " does not occur " + ntemp + " times in the month of " + $D.getMonthName(temp.getMonth()) + " " + temp.getFullYear() + "."); } return this; } return this.moveToDayOfWeek(n, this._orient); }; }; var sdf = function (n) { return function () { var t = $D.today(), shift = n - t.getDay(); if (n === 0 && Date.CultureInfo.firstDayOfWeek === 1 && t.getDay() !== 0) { shift = shift + 7; } return t.addDays(shift); }; }; // Create month name functions and abbreviated month name functions (eg. january(), march(), mar()). var month_instance_functions = function (n) { return function () { if (this._is) { this._is = false; return this.getMonth() === n; } return this.moveToMonth(n, this._orient); }; }; var month_static_functions = function (n) { return function () { return $D.today().set({ month: n, day: 1 }); }; }; var processTerms = function (names, staticFunc, instanceFunc) { for (var i = 0; i < names.length; i++) { // Create constant static Name variables. $D[names[i].toUpperCase()] = $D[names[i].toUpperCase().substring(0, 3)] = i; // Create Name functions. $D[names[i]] = $D[names[i].substring(0, 3)] = staticFunc(i); // Create Name instance functions. $P[names[i]] = $P[names[i].substring(0, 3)] = instanceFunc(i); } }; processTerms(dx, sdf, df); processTerms(mx, month_static_functions, month_instance_functions); // Create date element functions and plural date element functions used with Date (eg. day(), days(), months()). var ef = function (j) { return function () { // if the .second() function was called earlier, the _orient // has alread been added. Just return this and reset _isSecond. if (this._isSecond) { this._isSecond = false; return this; } if (this._same) { this._same = this._is = false; var o1 = this.toObject(), o2 = (arguments[0] || new Date()).toObject(), v = "", k = j.toLowerCase(); // the substr trick with -1 doesn't work in IE8 or less k = (k[k.length-1] === "s") ? k.substring(0,k.length-1) : k; for (var m = (px.length - 1); m > -1; m--) { v = px[m].toLowerCase(); if (o1[v] !== o2[v]) { return false; } if (k === v) { break; } } return true; } if (j.substring(j.length - 1) !== "s") { j += "s"; } if (this._move) { this._move = null; } return this["add" + j](this._orient); }; }; var nf = function (n) { return function () { this._dateElement = n; return this; }; }; for (var k = 0; k < px.length; k++) { de = px[k].toLowerCase(); if(de !== "weekday") { // Create date element functions and plural date element functions used with Date (eg. day(), days(), months()). $P[de] = $P[de + "s"] = ef(px[k]); // Create date element functions and plural date element functions used with Number (eg. day(), days(), months()). $N[de] = $N[de + "s"] = nf(de + "s"); } } $P._ss = ef("Second"); var nthfn = function (n) { return function (dayOfWeek) { if (this._same) { return this._ss(arguments[0]); } if (dayOfWeek || dayOfWeek === 0) { return this.moveToNthOccurrence(dayOfWeek, n); } this._nth = n; // if the operator is 'second' add the _orient, then deal with it later... if (n === 2 && (dayOfWeek === undefined || dayOfWeek === null)) { this._isSecond = true; return this.addSeconds(this._orient); } return this; }; }; for (var l = 0; l < nth.length; l++) { $P[nth[l]] = (l === 0) ? nthfn(-1) : nthfn(l); } }()); (function () { "use strict"; Date.Parsing = { Exception: function (s) { this.message = "Parse error at '" + s.substring(0, 10) + " ...'"; } }; var $P = Date.Parsing; var dayOffsets = { standard: [0,31,59,90,120,151,181,212,243,273,304,334], leap: [0,31,60,91,121,152,182,213,244,274,305,335] }; $P.isLeapYear = function(year) { return ((year % 4 === 0) && (year % 100 !== 0)) || (year % 400 === 0); }; var utils = { multiReplace : function (str, hash ) { var key; for (key in hash) { if (Object.prototype.hasOwnProperty.call(hash, key)) { var regex; if (typeof hash[key] === "function") { } else { regex = (hash[key] instanceof RegExp) ? hash[key] : new RegExp(hash[key], "g"); } str = str.replace(regex, key); } } return str; }, getDayOfYearFromWeek : function (obj) { var d, jan4, offset; obj.weekDay = (!obj.weekDay && obj.weekDay !== 0) ? 1 : obj.weekDay; d = new Date(obj.year, 0, 4); jan4 = d.getDay() === 0 ? 7 : d.getDay(); // JS is 0 indexed on Sunday. offset = jan4+3; obj.dayOfYear = ((obj.week * 7) + (obj.weekDay === 0 ? 7 : obj.weekDay))-offset; return obj; }, getDayOfYear : function (obj, dayOffset) { if (!obj.dayOfYear) { obj = utils.getDayOfYearFromWeek(obj); } for (var i=0;i <= dayOffset.length;i++) { if (obj.dayOfYear < dayOffset[i] || i === dayOffset.length) { obj.day = obj.day ? obj.day : (obj.dayOfYear - dayOffset[i-1]); break; } else { obj.month = i; } } return obj; }, adjustForTimeZone : function (obj, date) { var offset; if (obj.zone.toUpperCase() === "Z" || (obj.zone_hours === 0 && obj.zone_minutes === 0)) { // it's UTC/GML so work out the current timeszone offset offset = -date.getTimezoneOffset(); } else { offset = (obj.zone_hours*60) + (obj.zone_minutes || 0); if (obj.zone_sign === "+") { offset *= -1; } offset -= date.getTimezoneOffset(); } date.setMinutes(date.getMinutes()+offset); return date; }, setDefaults : function (obj) { obj.year = obj.year || Date.today().getFullYear(); obj.hours = obj.hours || 0; obj.minutes = obj.minutes || 0; obj.seconds = obj.seconds || 0; obj.milliseconds = obj.milliseconds || 0; if (!(!obj.month && (obj.week || obj.dayOfYear))) { // if we have a month, or if we don't but don't have the day calculation data obj.month = obj.month || 0; obj.day = obj.day || 1; } return obj; }, dataNum: function (data, mod, explict, postProcess) { var dataNum = data*1; if (mod) { if (postProcess) { return data ? mod(data)*1 : data; } else { return data ? mod(dataNum) : data; } } else if (!explict){ return data ? dataNum : data; } else { return (data && typeof data !== "undefined") ? dataNum : data; } }, timeDataProcess: function (obj) { var timeObj = {}; for (var x in obj.data) { if (obj.data.hasOwnProperty(x)) { timeObj[x] = obj.ignore[x] ? obj.data[x] : utils.dataNum(obj.data[x], obj.mods[x], obj.explict[x], obj.postProcess[x]); } } if (obj.data.secmins) { obj.data.secmins = obj.data.secmins.replace(",", ".") * 60; if (!timeObj.minutes) { timeObj.minutes = obj.data.secmins; } else if (!timeObj.seconds) { timeObj.seconds = obj.data.secmins; } delete obj.secmins; } return timeObj; }, buildTimeObjectFromData: function (data) { var time = utils.timeDataProcess({ data: { year : data[1], month : data[5], day : data[7], week : data[8], dayOfYear : data[10], hours : data[15], zone_hours : data[23], zone_minutes : data[24], zone : data[21], zone_sign : data[22], weekDay : data[9], minutes: data[16], seconds: data[19], milliseconds: data[20], secmins: data[18] }, mods: { month: function(data) { return data-1; }, weekDay: function (data) { data = Math.abs(data); return (data === 7 ? 0 : data); }, minutes: function (data) { return data.replace(":",""); }, seconds: function (data) { return Math.floor( (data.replace(":","").replace(",","."))*1 ); }, milliseconds: function (data) { return (data.replace(",",".")*1000); } }, postProcess: { minutes: true, seconds: true, milliseconds: true }, explict: { zone_hours: true, zone_minutes: true }, ignore: { zone: true, zone_sign: true, secmins: true } }); return time; }, addToHash: function (hash, keys, data) { keys = keys; data = data; var len = keys.length; for (var i = 0; i < len; i++) { hash[keys[i]] = data[i]; } return hash; }, combineRegex: function (r1, r2) { return new RegExp("(("+r1.source+")\\s("+r2.source+"))"); }, getDateNthString: function(add, last, inc){ if (add) { return Date.today().addDays(inc).toString("d"); } else if (last) { return Date.today().last()[inc]().toString("d"); } }, buildRegexData: function (array) { var arr = []; var len = array.length; for (var i=0; i < len; i++) { if (Object.prototype.toString.call(array[i]) === '[object Array]') { // oldIE compat version of Array.isArray arr.push(this.combineRegex(array[i][0], array[i][1])); } else { arr.push(array[i]); } } return arr; } }; $P.processTimeObject = function (obj) { var date, dayOffset; utils.setDefaults(obj); dayOffset = ($P.isLeapYear(obj.year)) ? dayOffsets.leap : dayOffsets.standard; if (!obj.month && (obj.week || obj.dayOfYear)) { utils.getDayOfYear(obj, dayOffset); } else { obj.dayOfYear = dayOffset[obj.month] + obj.day; } date = new Date(obj.year, obj.month, obj.day, obj.hours, obj.minutes, obj.seconds, obj.milliseconds); if (obj.zone) { utils.adjustForTimeZone(obj, date); // adjust (and calculate) for timezone } return date; }; $P.ISO = { regex : /^([\+-]?\d{4}(?!\d{2}\b))((-?)((0[1-9]|1[0-2])(\3([12]\d|0[1-9]|3[01]))?|W([0-4]\d|5[0-3])(-?[1-7])?|(00[1-9]|0[1-9]\d|[12]\d{2}|3([0-5]\d|6[1-6])))([T\s]((([01]\d|2[0-4])((:?)[0-5]\d)?|24\:?00)([\.,]\d+(?!:))?)?(\17[0-5]\d([\.,]\d+)?)?\s?([zZ]|([\+-])([01]\d|2[0-3]):?([0-5]\d)?)?)?)?$/, parse : function (s) { var time, data = s.match(this.regex); if (!data || !data.length) { return null; } time = utils.buildTimeObjectFromData(data); if (!time.year || (!time.year && (!time.month && !time.day) && (!time.week && !time.dayOfYear)) ) { return null; } return $P.processTimeObject(time); } }; $P.Numeric = { isNumeric: function (e){return!isNaN(parseFloat(e))&&isFinite(e);}, regex: /\b([0-1]?[0-9])([0-3]?[0-9])([0-2]?[0-9]?[0-9][0-9])\b/i, parse: function (s) { var data, i, time = {}, order = Date.CultureInfo.dateElementOrder.split(""); if (!(this.isNumeric(s)) || // if it's non-numeric OR (s[0] === "+" && s[0] === "-")) { // It's an arithmatic string (eg +/-1000) return null; } if (s.length < 5 && s.indexOf(".") < 0 && s.indexOf("/") < 0) { // assume it's just a year. time.year = s; return $P.processTimeObject(time); } data = s.match(this.regex); if (!data || !data.length) { return null; } for (i=0; i < order.length; i++) { switch(order[i]) { case "d": time.day = data[i+1]; break; case "m": time.month = (data[i+1]-1); break; case "y": time.year = data[i+1]; break; } } return $P.processTimeObject(time); } }; $P.Normalizer = { regexData: function () { var $R = Date.CultureInfo.regexPatterns; return utils.buildRegexData([ $R.tomorrow, $R.yesterday, [$R.past, $R.mon], [$R.past, $R.tue], [$R.past, $R.wed], [$R.past, $R.thu], [$R.past, $R.fri], [$R.past, $R.sat], [$R.past, $R.sun] ]); }, basicReplaceHash : function() { var $R = Date.CultureInfo.regexPatterns; return { "January": $R.jan.source, "February": $R.feb, "March": $R.mar, "April": $R.apr, "May": $R.may, "June": $R.jun, "July": $R.jul, "August": $R.aug, "September": $R.sep, "October": $R.oct, "November": $R.nov, "December": $R.dec, "": /\bat\b/gi, " ": /\s{2,}/, "am": $R.inTheMorning, "9am": $R.thisMorning, "pm": $R.inTheEvening, "7pm":$R.thisEvening }; }, keys : function(){ return [ utils.getDateNthString(true, false, 1), // tomorrow utils.getDateNthString(true, false, -1), // yesterday utils.getDateNthString(false, true, "monday"), //last mon utils.getDateNthString(false, true, "tuesday"), //last tues utils.getDateNthString(false, true, "wednesday"), //last wed utils.getDateNthString(false, true, "thursday"), //last thurs utils.getDateNthString(false, true, "friday"), //last fri utils.getDateNthString(false, true, "saturday"), //last sat utils.getDateNthString(false, true, "sunday") //last sun ]; }, buildRegexFunctions: function () { var $R = Date.CultureInfo.regexPatterns; var __ = Date.i18n.__; var tomorrowRE = new RegExp("(\\b\\d\\d?("+__("AM")+"|"+__("PM")+")? )("+$R.tomorrow.source.slice(1)+")", "i"); // adapted tomorrow regex for AM PM relative dates var todayRE = new RegExp($R.today.source + "(?!\\s*([+-]))\\b"); // today, but excludes the math operators (eg "today + 2h") this.replaceFuncs = [ [todayRE, function (full) { return (full.length > 1) ? Date.today().toString("d") : full; }], [tomorrowRE, function(full, m1) { var t = Date.today().addDays(1).toString("d"); return (t + " " + m1); }], [$R.amThisMorning, function(str, am){return am;}], [$R.pmThisEvening, function(str, pm){return pm;}] ]; }, buildReplaceData: function () { this.buildRegexFunctions(); this.replaceHash = utils.addToHash(this.basicReplaceHash(), this.keys(), this.regexData()); }, stringReplaceFuncs: function (s) { for (var i=0; i < this.replaceFuncs.length; i++) { s = s.replace(this.replaceFuncs[i][0], this.replaceFuncs[i][1]); } return s; }, parse: function (s) { s = this.stringReplaceFuncs(s); s = utils.multiReplace(s, this.replaceHash); try { var n = s.split(/([\s\-\.\,\/\x27]+)/); if (n.length === 3 && $P.Numeric.isNumeric(n[0]) && $P.Numeric.isNumeric(n[2]) && (n[2].length >= 4)) { // ok, so we're dealing with x/year. But that's not a full date. // This fixes wonky dateElementOrder parsing when set to dmy order. if (Date.CultureInfo.dateElementOrder[0] === "d") { s = "1/" + n[0] + "/" + n[2]; // set to 1st of month and normalize the seperator } } } catch (e) {} return s; } }; $P.Normalizer.buildReplaceData(); }()); (function () { var $P = Date.Parsing; var _ = $P.Operators = { // // Tokenizers // rtoken: function (r) { // regex token return function (s) { var mx = s.match(r); if (mx) { return ([ mx[0], s.substring(mx[0].length) ]); } else { throw new $P.Exception(s); } }; }, token: function () { // whitespace-eating token return function (s) { return _.rtoken(new RegExp("^\\s*" + s + "\\s*"))(s); }; }, stoken: function (s) { // string token return _.rtoken(new RegExp("^" + s)); }, // Atomic Operators until: function (p) { return function (s) { var qx = [], rx = null; while (s.length) { try { rx = p.call(this, s); } catch (e) { qx.push(rx[0]); s = rx[1]; continue; } break; } return [ qx, s ]; }; }, many: function (p) { return function (s) { var rx = [], r = null; while (s.length) { try { r = p.call(this, s); } catch (e) { return [ rx, s ]; } rx.push(r[0]); s = r[1]; } return [ rx, s ]; }; }, // generator operators -- see below optional: function (p) { return function (s) { var r = null; try { r = p.call(this, s); } catch (e) { return [ null, s ]; } return [ r[0], r[1] ]; }; }, not: function (p) { return function (s) { try { p.call(this, s); } catch (e) { return [null, s]; } throw new $P.Exception(s); }; }, ignore: function (p) { return p ? function (s) { var r = null; r = p.call(this, s); return [null, r[1]]; } : null; }, product: function () { var px = arguments[0], qx = Array.prototype.slice.call(arguments, 1), rx = []; for (var i = 0 ; i < px.length ; i++) { rx.push(_.each(px[i], qx)); } return rx; }, cache: function (rule) { var cache = {}, cache_length = 0, cache_keys = [], CACHE_MAX = Date.Config.CACHE_MAX || 100000, r = null; var cacheCheck = function () { if (cache_length === CACHE_MAX) { // kill several keys, don't want to have to do this all the time... for (var i=0; i < 10; i++) { var key = cache_keys.shift(); if (key) { delete cache[key]; cache_length--; } } } }; return function (s) { cacheCheck(); try { r = cache[s] = (cache[s] || rule.call(this, s)); } catch (e) { r = cache[s] = e; } cache_length++; cache_keys.push(s); if (r instanceof $P.Exception) { throw r; } else { return r; } }; }, // vector operators -- see below any: function () { var px = arguments; return function (s) { var r = null; for (var i = 0; i < px.length; i++) { if (px[i] == null) { continue; } try { r = (px[i].call(this, s)); } catch (e) { r = null; } if (r) { return r; } } throw new $P.Exception(s); }; }, each: function () { var px = arguments; return function (s) { var rx = [], r = null; for (var i = 0; i < px.length ; i++) { if (px[i] == null) { continue; } try { r = (px[i].call(this, s)); } catch (e) { throw new $P.Exception(s); } rx.push(r[0]); s = r[1]; } return [ rx, s]; }; }, all: function () { var px = arguments, _ = _; return _.each(_.optional(px)); }, // delimited operators sequence: function (px, d, c) { d = d || _.rtoken(/^\s*/); c = c || null; if (px.length === 1) { return px[0]; } return function (s) { var r = null, q = null; var rx = []; for (var i = 0; i < px.length ; i++) { try { r = px[i].call(this, s); } catch (e) { break; } rx.push(r[0]); try { q = d.call(this, r[1]); } catch (ex) { q = null; break; } s = q[1]; } if (!r) { throw new $P.Exception(s); } if (q) { throw new $P.Exception(q[1]); } if (c) { try { r = c.call(this, r[1]); } catch (ey) { throw new $P.Exception(r[1]); } } return [ rx, (r?r[1]:s) ]; }; }, // // Composite Operators // between: function (d1, p, d2) { d2 = d2 || d1; var _fn = _.each(_.ignore(d1), p, _.ignore(d2)); return function (s) { var rx = _fn.call(this, s); return [[rx[0][0], r[0][2]], rx[1]]; }; }, list: function (p, d, c) { d = d || _.rtoken(/^\s*/); c = c || null; return (p instanceof Array ? _.each(_.product(p.slice(0, -1), _.ignore(d)), p.slice(-1), _.ignore(c)) : _.each(_.many(_.each(p, _.ignore(d))), px, _.ignore(c))); }, set: function (px, d, c) { d = d || _.rtoken(/^\s*/); c = c || null; return function (s) { // r is the current match, best the current 'best' match // which means it parsed the most amount of input var r = null, p = null, q = null, rx = null, best = [[], s], last = false; // go through the rules in the given set for (var i = 0; i < px.length ; i++) { // last is a flag indicating whether this must be the last element // if there is only 1 element, then it MUST be the last one q = null; p = null; r = null; last = (px.length === 1); // first, we try simply to match the current pattern // if not, try the next pattern try { r = px[i].call(this, s); } catch (e) { continue; } // since we are matching against a set of elements, the first // thing to do is to add r[0] to matched elements rx = [[r[0]], r[1]]; // if we matched and there is still input to parse and // we don't already know this is the last element, // we're going to next check for the delimiter ... // if there's none, or if there's no input left to parse // than this must be the last element after all ... if (r[1].length > 0 && ! last) { try { q = d.call(this, r[1]); } catch (ex) { last = true; } } else { last = true; } // if we parsed the delimiter and now there's no more input, // that means we shouldn't have parsed the delimiter at all // so don't update r and mark this as the last element ... if (!last && q[1].length === 0) { last = true; } // so, if this isn't the last element, we're going to see if // we can get any more matches from the remaining (unmatched) // elements ... if (!last) { // build a list of the remaining rules we can match against, // i.e., all but the one we just matched against var qx = []; for (var j = 0; j < px.length ; j++) { if (i !== j) { qx.push(px[j]); } } // now invoke recursively set with the remaining input // note that we don't include the closing delimiter ... // we'll check for that ourselves at the end p = _.set(qx, d).call(this, q[1]); // if we got a non-empty set as a result ... // (otw rx already contains everything we want to match) if (p[0].length > 0) { // update current result, which is stored in rx ... // basically, pick up the remaining text from p[1] // and concat the result from p[0] so that we don't // get endless nesting ... rx[0] = rx[0].concat(p[0]); rx[1] = p[1]; } } // at this point, rx either contains the last matched element // or the entire matched set that starts with this element. // now we just check to see if this variation is better than // our best so far, in terms of how much of the input is parsed if (rx[1].length < best[1].length) { best = rx; } // if we've parsed all the input, then we're finished if (best[1].length === 0) { break; } } // so now we've either gone through all the patterns trying them // as the initial match; or we found one that parsed the entire // input string ... // if best has no matches, just return empty set ... if (best[0].length === 0) { return best; } // if a closing delimiter is provided, then we have to check it also if (c) { // we try this even if there is no remaining input because the pattern // may well be optional or match empty input ... try { q = c.call(this, best[1]); } catch (ey) { throw new $P.Exception(best[1]); } // it parsed ... be sure to update the best match remaining input best[1] = q[1]; } // if we're here, either there was no closing delimiter or we parsed it // so now we have the best match; just return it! return best; }; }, forward: function (gr, fname) { return function (s) { return gr[fname].call(this, s); }; }, // // Translation Operators // replace: function (rule, repl) { return function (s) { var r = rule.call(this, s); return [repl, r[1]]; }; }, process: function (rule, fn) { return function (s) { var r = rule.call(this, s); return [fn.call(this, r[0]), r[1]]; }; }, min: function (min, rule) { return function (s) { var rx = rule.call(this, s); if (rx[0].length < min) { throw new $P.Exception(s); } return rx; }; } }; // Generator Operators And Vector Operators // Generators are operators that have a signature of F(R) => R, // taking a given rule and returning another rule, such as // ignore, which parses a given rule and throws away the result. // Vector operators are those that have a signature of F(R1,R2,...) => R, // take a list of rules and returning a new rule, such as each. // Generator operators are converted (via the following _generator // function) into functions that can also take a list or array of rules // and return an array of new rules as though the function had been // called on each rule in turn (which is what actually happens). // This allows generators to be used with vector operators more easily. // Example: // each(ignore(foo, bar)) instead of each(ignore(foo), ignore(bar)) // This also turns generators into vector operators, which allows // constructs like: // not(cache(foo, bar)) var _generator = function (op) { function gen() { var args = null, rx = [], px, i; if (arguments.length > 1) { args = Array.prototype.slice.call(arguments); } else if (arguments[0] instanceof Array) { args = arguments[0]; } if (args) { px = args.shift(); if (px.length > 0) { args.unshift(px[i]); rx.push(op.apply(null, args)); args.shift(); return rx; } } else { return op.apply(null, arguments); } } return gen; }; var gx = "optional not ignore cache".split(/\s/); for (var i = 0 ; i < gx.length ; i++) { _[gx[i]] = _generator(_[gx[i]]); } var _vector = function (op) { return function () { if (arguments[0] instanceof Array) { return op.apply(null, arguments[0]); } else { return op.apply(null, arguments); } }; }; var vx = "each any all".split(/\s/); for (var j = 0 ; j < vx.length ; j++) { _[vx[j]] = _vector(_[vx[j]]); } }()); (function () { var $D = Date; var flattenAndCompact = function (ax) { var rx = []; for (var i = 0; i < ax.length; i++) { if (ax[i] instanceof Array) { rx = rx.concat(flattenAndCompact(ax[i])); } else { if (ax[i]) { rx.push(ax[i]); } } } return rx; }; var parseMeridian = function () { if (this.meridian && (this.hour || this.hour === 0)) { if (this.meridian === "a" && this.hour > 11 && Date.Config.strict24hr){ throw "Invalid hour and meridian combination"; } else if (this.meridian === "p" && this.hour < 12 && Date.Config.strict24hr){ throw "Invalid hour and meridian combination"; } else if (this.meridian === "p" && this.hour < 12) { this.hour = this.hour + 12; } else if (this.meridian === "a" && this.hour === 12) { this.hour = 0; } } }; var setDefaults = function () { var now = new Date(); if ((this.hour || this.minute) && (!this.month && !this.year && !this.day)) { this.day = now.getDate(); } if (!this.year) { this.year = now.getFullYear(); } if (!this.month && this.month !== 0) { this.month = now.getMonth(); } if (!this.day) { this.day = 1; } if (!this.hour) { this.hour = 0; } if (!this.minute) { this.minute = 0; } if (!this.second) { this.second = 0; } if (!this.millisecond) { this.millisecond = 0; } }; var finishUtils = { getToday: function () { if (this.now || "hour minute second".indexOf(this.unit) !== -1) { return new Date(); } else { return $D.today(); } }, setDaysFromWeekday: function (today, orient){ var gap; orient = orient || 1; this.unit = "day"; gap = ($D.getDayNumberFromName(this.weekday) - today.getDay()); this.days = gap ? ((gap + (orient * 7)) % 7) : (orient * 7); return this; }, setMonthsFromMonth: function (today, orient) { var gap; orient = orient || 1; this.unit = "month"; gap = (this.month - today.getMonth()); this.months = gap ? ((gap + (orient * 12)) % 12) : (orient * 12); this.month = null; return this; }, setDMYFromWeekday: function () { var d = Date[this.weekday](); this.day = d.getDate(); if (!this.month) { this.month = d.getMonth(); } this.year = d.getFullYear(); return this; }, setUnitValue: function (orient) { if (!this.value && this.operator && this.operator !== null && this[this.unit + "s"] && this[this.unit + "s"] !== null) { this[this.unit + "s"] = this[this.unit + "s"] + ((this.operator === "add") ? 1 : -1) + (this.value||0) * orient; } else if (this[this.unit + "s"] == null || this.operator != null) { if (!this.value) { this.value = 1; } this[this.unit + "s"] = this.value * orient; } }, generateDateFromWeeks: function () { var weekday = (this.weekday !== undefined) ? this.weekday : "today"; var d = Date[weekday]().addWeeks(this.weeks); if (this.now) { d.setTimeToNow(); } return d; } }; $D.Translator = { hour: function (s) { return function () { this.hour = Number(s); }; }, minute: function (s) { return function () { this.minute = Number(s); }; }, second: function (s) { return function () { this.second = Number(s); }; }, /* for ss.s format */ secondAndMillisecond: function (s) { return function () { var mx = s.match(/^([0-5][0-9])\.([0-9]{1,3})/); this.second = Number(mx[1]); this.millisecond = Number(mx[2]); }; }, meridian: function (s) { return function () { this.meridian = s.slice(0, 1).toLowerCase(); }; }, timezone: function (s) { return function () { var n = s.replace(/[^\d\+\-]/g, ""); if (n.length) { this.timezoneOffset = Number(n); } else { this.timezone = s.toLowerCase(); } }; }, day: function (x) { var s = x[0]; return function () { this.day = Number(s.match(/\d+/)[0]); if (this.day < 1) { throw "invalid day"; } }; }, month: function (s) { return function () { this.month = (s.length === 3) ? "jan feb mar apr may jun jul aug sep oct nov dec".indexOf(s)/4 : Number(s) - 1; if (this.month < 0) { throw "invalid month"; } }; }, year: function (s) { return function () { var n = Number(s); this.year = ((s.length > 2) ? n : (n + (((n + 2000) < Date.CultureInfo.twoDigitYearMax) ? 2000 : 1900))); }; }, rday: function (s) { return function () { switch (s) { case "yesterday": this.days = -1; break; case "tomorrow": this.days = 1; break; case "today": this.days = 0; break; case "now": this.days = 0; this.now = true; break; } }; }, finishExact: function (x) { var d; x = (x instanceof Array) ? x : [x]; for (var i = 0 ; i < x.length ; i++) { if (x[i]) { x[i].call(this); } } setDefaults.call(this); parseMeridian.call(this); if (this.day > $D.getDaysInMonth(this.year, this.month)) { throw new RangeError(this.day + " is not a valid value for days."); } d = new Date(this.year, this.month, this.day, this.hour, this.minute, this.second, this.millisecond); if (this.year < 100) { d.setFullYear(this.year); // means years less that 100 are process correctly. JS will parse it otherwise as 1900-1999. } if (this.timezone) { d.set({ timezone: this.timezone }); } else if (this.timezoneOffset) { d.set({ timezoneOffset: this.timezoneOffset }); } return d; }, finish: function (x) { var today, expression, orient, temp; x = (x instanceof Array) ? flattenAndCompact(x) : [ x ]; if (x.length === 0) { return null; } for (var i = 0 ; i < x.length ; i++) { if (typeof x[i] === "function") { x[i].call(this); } } if (this.now && !this.unit && !this.operator) { return new Date(); } else { today = finishUtils.getToday.call(this); } expression = !!(this.days && this.days !== null || this.orient || this.operator); orient = ((this.orient === "past" || this.operator === "subtract") ? -1 : 1); if (this.month && this.unit === "week") { this.value = this.month + 1; delete this.month; delete this.day; } if ((this.month || this.month === 0) && "year day hour minute second".indexOf(this.unit) !== -1) { if (!this.value) { this.value = this.month + 1; } this.month = null; expression = true; } if (!expression && this.weekday && !this.day && !this.days) { finishUtils.setDMYFromWeekday.call(this); } if (expression && this.weekday && this.unit !== "month" && this.unit !== "week") { finishUtils.setDaysFromWeekday.call(this, today, orient); } if (this.weekday && this.unit !== "week" && !this.day && !this.days) { temp = Date[this.weekday](); this.day = temp.getDate(); if (temp.getMonth() !== today.getMonth()) { this.month = temp.getMonth(); } } if (this.month && this.unit === "day" && this.operator) { if (!this.value) { this.value = (this.month + 1); } this.month = null; } if (this.value != null && this.month != null && this.year != null) { this.day = this.value * 1; } if (this.month && !this.day && this.value) { today.set({ day: this.value * 1 }); if (!expression) { this.day = this.value * 1; } } if (!this.month && this.value && this.unit === "month" && !this.now) { this.month = this.value; expression = true; } if (expression && (this.month || this.month === 0) && this.unit !== "year") { finishUtils.setMonthsFromMonth.call(this, today, orient); } if (!this.unit) { this.unit = "day"; } finishUtils.setUnitValue.call(this, orient); parseMeridian.call(this); if ((this.month || this.month === 0) && !this.day) { this.day = 1; } if (!this.orient && !this.operator && this.unit === "week" && this.value && !this.day && !this.month) { return Date.today().setWeek(this.value); } if (this.unit === "week" && this.weeks && !this.day && !this.month) { return finishUtils.generateDateFromWeeks.call(this); } if (expression && this.timezone && this.day && this.days) { this.day = this.days; } if (expression){ today.add(this); } else { today.set(this); } if (this.timezone) { this.timezone = this.timezone.toUpperCase(); var offset = $D.getTimezoneOffset(this.timezone); var timezone; if (today.hasDaylightSavingTime()) { // lets check that we're being sane with timezone setting timezone = $D.getTimezoneAbbreviation(offset, today.isDaylightSavingTime()); if (timezone !== this.timezone) { // bugger, we're in a place where things like EST vs EDT matters. if (today.isDaylightSavingTime()) { today.addHours(-1); } else { today.addHours(1); } } } today.setTimezoneOffset(offset); } return today; } }; }()); (function () { var $D = Date; $D.Grammar = {}; var _ = $D.Parsing.Operators, g = $D.Grammar, t = $D.Translator, _fn; // Allow rolling up into general purpose rules _fn = function () { return _.each(_.any.apply(null, arguments), _.not(g.ctoken2("timeContext"))); }; g.datePartDelimiter = _.rtoken(/^([\s\-\.\,\/\x27]+)/); g.timePartDelimiter = _.stoken(":"); g.whiteSpace = _.rtoken(/^\s*/); g.generalDelimiter = _.rtoken(/^(([\s\,]|at|@|on)+)/); var _C = {}; g.ctoken = function (keys) { var fn = _C[keys]; if (! fn) { var c = Date.CultureInfo.regexPatterns; var kx = keys.split(/\s+/), px = []; for (var i = 0; i < kx.length ; i++) { px.push(_.replace(_.rtoken(c[kx[i]]), kx[i])); } fn = _C[keys] = _.any.apply(null, px); } return fn; }; g.ctoken2 = function (key) { return _.rtoken(Date.CultureInfo.regexPatterns[key]); }; var cacheProcessRtoken = function (key, token, type, eachToken) { if (eachToken) { g[key] = _.cache(_.process(_.each(_.rtoken(token),_.optional(g.ctoken2(eachToken))), type)); } else { g[key] = _.cache(_.process(_.rtoken(token), type)); } }; var cacheProcessCtoken = function (token, type) { return _.cache(_.process(g.ctoken2(token), type)); }; var _F = {}; //function cache var _get = function (f) { _F[f] = (_F[f] || g.format(f)[0]); return _F[f]; }; g.allformats = function (fx) { var rx = []; if (fx instanceof Array) { for (var i = 0; i < fx.length; i++) { rx.push(_get(fx[i])); } } else { rx.push(_get(fx)); } return rx; }; g.formats = function (fx) { if (fx instanceof Array) { var rx = []; for (var i = 0 ; i < fx.length ; i++) { rx.push(_get(fx[i])); } return _.any.apply(null, rx); } else { return _get(fx); } }; var grammarFormats = { timeFormats: function(){ var i, RTokenKeys = [ "h", "hh", "H", "HH", "m", "mm", "s", "ss", "ss.s", "z", "zz" ], RToken = [ /^(0[0-9]|1[0-2]|[1-9])/, /^(0[0-9]|1[0-2])/, /^([0-1][0-9]|2[0-3]|[0-9])/, /^([0-1][0-9]|2[0-3])/, /^([0-5][0-9]|[0-9])/, /^[0-5][0-9]/, /^([0-5][0-9]|[0-9])/, /^[0-5][0-9]/, /^[0-5][0-9]\.[0-9]{1,3}/, /^((\+|\-)\s*\d\d\d\d)|((\+|\-)\d\d\:?\d\d)/, /^((\+|\-)\s*\d\d\d\d)|((\+|\-)\d\d\:?\d\d)/ ], tokens = [ t.hour, t.hour, t.hour, t.hour, t.minute, t.minute, t.second, t.second, t.secondAndMillisecond, t.timezone, t.timezone ]; for (i=0; i < RTokenKeys.length; i++) { cacheProcessRtoken(RTokenKeys[i], RToken[i], tokens[i]); } g.hms = _.cache(_.sequence([g.H, g.m, g.s], g.timePartDelimiter)); g.t = cacheProcessCtoken("shortMeridian", t.meridian); g.tt = cacheProcessCtoken("longMeridian", t.meridian); g.zzz = cacheProcessCtoken("timezone", t.timezone); g.timeSuffix = _.each(_.ignore(g.whiteSpace), _.set([ g.tt, g.zzz ])); g.time = _.each(_.optional(_.ignore(_.stoken("T"))), g.hms, g.timeSuffix); }, dateFormats: function () { // pre-loaded rules for different date part order preferences var _setfn = function () { return _.set(arguments, g.datePartDelimiter); }; var i, RTokenKeys = [ "d", "dd", "M", "MM", "y", "yy", "yyy", "yyyy" ], RToken = [ /^([0-2]\d|3[0-1]|\d)/, /^([0-2]\d|3[0-1])/, /^(1[0-2]|0\d|\d)/, /^(1[0-2]|0\d)/, /^(\d+)/, /^(\d\d)/, /^(\d\d?\d?\d?)/, /^(\d\d\d\d)/ ], tokens = [ t.day, t.day, t.month, t.month, t.year, t.year, t.year, t.year ], eachToken = [ "ordinalSuffix", "ordinalSuffix" ]; for (i=0; i < RTokenKeys.length; i++) { cacheProcessRtoken(RTokenKeys[i], RToken[i], tokens[i], eachToken[i]); } g.MMM = g.MMMM = _.cache(_.process(g.ctoken("jan feb mar apr may jun jul aug sep oct nov dec"), t.month)); g.ddd = g.dddd = _.cache(_.process(g.ctoken("sun mon tue wed thu fri sat"), function (s) { return function () { this.weekday = s; }; } )); g.day = _fn(g.d, g.dd); g.month = _fn(g.M, g.MMM); g.year = _fn(g.yyyy, g.yy); g.mdy = _setfn(g.ddd, g.month, g.day, g.year); g.ymd = _setfn(g.ddd, g.year, g.month, g.day); g.dmy = _setfn(g.ddd, g.day, g.month, g.year); g.date = function (s) { return ((g[Date.CultureInfo.dateElementOrder] || g.mdy).call(this, s)); }; }, relative: function () { // relative date / time expressions g.orientation = _.process(g.ctoken("past future"), function (s) { return function () { this.orient = s; }; } ); g.operator = _.process(g.ctoken("add subtract"), function (s) { return function () { this.operator = s; }; } ); g.rday = _.process(g.ctoken("yesterday tomorrow today now"), t.rday); g.unit = _.process(g.ctoken("second minute hour day week month year"), function (s) { return function () { this.unit = s; }; } ); } }; g.buildGrammarFormats = function () { // these need to be rebuilt every time the language changes. _C = {}; grammarFormats.timeFormats(); grammarFormats.dateFormats(); grammarFormats.relative(); g.value = _.process(_.rtoken(/^([-+]?\d+)?(st|nd|rd|th)?/), function (s) { return function () { this.value = s.replace(/\D/g, ""); }; } ); g.expression = _.set([g.rday, g.operator, g.value, g.unit, g.orientation, g.ddd, g.MMM ]); g.format = _.process(_.many( _.any( // translate format specifiers into grammar rules _.process( _.rtoken(/^(dd?d?d?(?!e)|MM?M?M?|yy?y?y?|hh?|HH?|mm?|ss?|tt?|zz?z?)/), function (fmt) { if (g[fmt]) { return g[fmt]; } else { throw $D.Parsing.Exception(fmt); } } ), // translate separator tokens into token rules _.process(_.rtoken(/^[^dMyhHmstz]+/), // all legal separators function (s) { return _.ignore(_.stoken(s)); } ) ) ), // construct the parser ... function (rules) { return _.process(_.each.apply(null, rules), t.finishExact); } ); // starting rule for general purpose grammar g._start = _.process(_.set([ g.date, g.time, g.expression ], g.generalDelimiter, g.whiteSpace), t.finish); }; g.buildGrammarFormats(); // parsing date format specifiers - ex: "h:m:s tt" // this little guy will generate a custom parser based // on the format string, ex: g.format("h:m:s tt") // check for these formats first g._formats = g.formats([ "\"yyyy-MM-ddTHH:mm:ssZ\"", "yyyy-MM-ddTHH:mm:ss.sz", "yyyy-MM-ddTHH:mm:ssZ", "yyyy-MM-ddTHH:mm:ssz", "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-ddTHH:mmZ", "yyyy-MM-ddTHH:mmz", "yyyy-MM-ddTHH:mm", "ddd, MMM dd, yyyy H:mm:ss tt", "ddd MMM d yyyy HH:mm:ss zzz", "MMddyyyy", "ddMMyyyy", "Mddyyyy", "ddMyyyy", "Mdyyyy", "dMyyyy", "yyyy", "Mdyy", "dMyy", "d" ]); // real starting rule: tries selected formats first, // then general purpose rule g.start = function (s) { try { var r = g._formats.call({}, s); if (r[1].length === 0) { return r; } } catch (e) {} return g._start.call({}, s); }; }()); (function () { var $D = Date; /** * @desc Converts the specified string value into its JavaScript Date equivalent using CultureInfo specific format information. * * Example

	///////////
	// Dates //
	///////////

	// 15-Oct-2004
	var d1 = Date.parse("10/15/2004");

	// 15-Oct-2004
	var d1 = Date.parse("15-Oct-2004");

	// 15-Oct-2004
	var d1 = Date.parse("2004.10.15");

	//Fri Oct 15, 2004
	var d1 = Date.parse("Fri Oct 15, 2004");

	///////////
	// Times //
	///////////

	// Today at 10 PM.
	var d1 = Date.parse("10 PM");

	// Today at 10:30 PM.
	var d1 = Date.parse("10:30 P.M.");

	// Today at 6 AM.
	var d1 = Date.parse("06am");

	/////////////////////
	// Dates and Times //
	/////////////////////

	// 8-July-2004 @ 10:30 PM
	var d1 = Date.parse("July 8th, 2004, 10:30 PM");

	// 1-July-2004 @ 10:30 PM
	var d1 = Date.parse("2004-07-01T22:30:00");

	////////////////////
	// Relative Dates //
	////////////////////

	// Returns today's date. The string "today" is culture specific.
	var d1 = Date.parse("today");

	// Returns yesterday's date. The string "yesterday" is culture specific.
	var d1 = Date.parse("yesterday");

	// Returns the date of the next thursday.
	var d1 = Date.parse("Next thursday");

	// Returns the date of the most previous monday.
	var d1 = Date.parse("last monday");

	// Returns today's day + one year.
	var d1 = Date.parse("next year");

	///////////////
	// Date Math //
	///////////////

	// Today + 2 days
	var d1 = Date.parse("t+2");

	// Today + 2 days
	var d1 = Date.parse("today + 2 days");

	// Today + 3 months
	var d1 = Date.parse("t+3m");

	// Today - 1 year
	var d1 = Date.parse("today - 1 year");

	// Today - 1 year
	var d1 = Date.parse("t-1y"); 


	/////////////////////////////
	// Partial Dates and Times //
	/////////////////////////////

	// July 15th of this year.
	var d1 = Date.parse("July 15");

	// 15th day of current day and year.
	var d1 = Date.parse("15");

	// July 1st of current year at 10pm.
	var d1 = Date.parse("7/1 10pm");
	
* * @param {String} The string value to convert into a Date object [Required] * @return {Date} A Date object or null if the string cannot be converted into a Date. */ var parseUtils = { removeOrds: function (s) { ords = s.match(/\b(\d+)(?:st|nd|rd|th)\b/); // find ordinal matches s = ((ords && ords.length === 2) ? s.replace(ords[0], ords[1]) : s); return s; }, grammarParser: function (s) { var r = null; try { r = $D.Grammar.start.call({}, s.replace(/^\s*(\S*(\s+\S+)*)\s*$/, "$1")); } catch (e) { return null; } return ((r[1].length === 0) ? r[0] : null); }, nativeFallback: function(s) { var t; try { // ok we haven't parsed it, last ditch attempt with the built-in parser. t = Date._parse(s); return (t || t === 0) ? new Date(t) : null; } catch (e) { return null; } } }; function parse (s) { var d; if (!s) { return null; } if (s instanceof Date) { return s.clone(); } if (s.length >= 4 && s.charAt(0) !== "0" && s.charAt(0) !== "+"&& s.charAt(0) !== "-") { // ie: 2004 will pass, 0800 won't. // Start with specific formats d = $D.Parsing.ISO.parse(s) || $D.Parsing.Numeric.parse(s); } if (d instanceof Date && !isNaN(d.getTime())) { return d; } else { // find ordinal dates (1st, 3rd, 8th, etc and remove them as they cause parsing issues) s = $D.Parsing.Normalizer.parse(parseUtils.removeOrds(s)); d = parseUtils.grammarParser(s); if (d !== null) { return d; } else { return parseUtils.nativeFallback(s); } } } if (!$D._parse) { $D._parse = $D.parse; } $D.parse = parse; Date.getParseFunction = function (fx) { var fns = Date.Grammar.allformats(fx); return function (s) { var r = null; for (var i = 0; i < fns.length; i++) { try { r = fns[i].call({}, s); } catch (e) { continue; } if (r[1].length === 0) { return r[0]; } } return null; }; }; /** * Converts the specified string value into its JavaScript Date equivalent using the specified format {String} or formats {Array} and the CultureInfo specific format information. * The format of the string value must match one of the supplied formats exactly. * * Example

	// 15-Oct-2004
	var d1 = Date.parseExact("10/15/2004", "M/d/yyyy");

	// 15-Oct-2004
	var d1 = Date.parse("15-Oct-2004", "M-ddd-yyyy");

	// 15-Oct-2004
	var d1 = Date.parse("2004.10.15", "yyyy.MM.dd");

	// Multiple formats
	var d1 = Date.parseExact("10/15/2004", ["M/d/yyyy", "MMMM d, yyyy"]);
	
* * @param {String} The string value to convert into a Date object [Required]. * @param {Object} The expected format {String} or an array of expected formats {Array} of the date string [Required]. * @return {Date} A Date object or null if the string cannot be converted into a Date. */ $D.parseExact = function (s, fx) { return $D.getParseFunction(fx)(s); }; }()); (function () { var $D = Date, $P = $D.prototype, // $C = $D.CultureInfo, // not used atm p = function (s, l) { if (!l) { l = 2; } return ("000" + s).slice(l * -1); }; /** * Converts a PHP format string to Java/.NET format string. * A PHP format string can be used with ._format or .format. * A Java/.NET format string can be used with .toString(). * The .parseExact function will only accept a Java/.NET format string * * Example * var f1 = "%m/%d/%y" * var f2 = Date.normalizeFormat(f1); // "MM/dd/yy" * * new Date().format(f1); // "04/13/08" * new Date()._format(f1); // "04/13/08" * new Date().toString(f2); // "04/13/08" * * var date = Date.parseExact("04/13/08", f2); // Sun Apr 13 2008 * * @param {String} A PHP format string consisting of one or more format spcifiers. * @return {String} The PHP format converted to a Java/.NET format string. */ var normalizerSubstitutions = { "d" : "dd", "%d": "dd", "D" : "ddd", "%a": "ddd", "j" : "dddd", "l" : "dddd", "%A": "dddd", "S" : "S", "F" : "MMMM", "%B": "MMMM", "m" : "MM", "%m": "MM", "M" : "MMM", "%b": "MMM", "%h": "MMM", "n" : "M", "Y" : "yyyy", "%Y": "yyyy", "y" : "yy", "%y": "yy", "g" : "h", "%I": "h", "G" : "H", "h" : "hh", "H" : "HH", "%H": "HH", "i" : "mm", "%M": "mm", "s" : "ss", "%S": "ss", "%r": "hh:mm tt", "%R": "H:mm", "%T": "H:mm:ss", "%X": "t", "%x": "d", "%e": "d", "%D": "MM/dd/yy", "%n": "\\n", "%t": "\\t", "e" : "z", "T" : "z", "%z": "z", "%Z": "z", "Z" : "ZZ", "N" : "u", "w" : "u", "%w": "u", "W" : "W", "%V": "W" }; var normalizer = { substitutes: function (m) { return normalizerSubstitutions[m]; }, interpreted: function (m, x) { var y; switch (m) { case "%u": return x.getDay() + 1; case "z": return x.getOrdinalNumber(); case "%j": return p(x.getOrdinalNumber(), 3); case "%U": var d1 = x.clone().set({month: 0, day: 1}).addDays(-1).moveToDayOfWeek(0), d2 = x.clone().addDays(1).moveToDayOfWeek(0, -1); return (d2 < d1) ? "00" : p((d2.getOrdinalNumber() - d1.getOrdinalNumber()) / 7 + 1); case "%W": return p(x.getWeek()); case "t": return $D.getDaysInMonth(x.getFullYear(), x.getMonth()); case "o": case "%G": return x.setWeek(x.getISOWeek()).toString("yyyy"); case "%g": return x._format("%G").slice(-2); case "a": case "%p": return t("tt").toLowerCase(); case "A": return t("tt").toUpperCase(); case "u": return p(x.getMilliseconds(), 3); case "I": return (x.isDaylightSavingTime()) ? 1 : 0; case "O": return x.getUTCOffset(); case "P": y = x.getUTCOffset(); return y.substring(0, y.length - 2) + ":" + y.substring(y.length - 2); case "B": var now = new Date(); return Math.floor(((now.getHours() * 3600) + (now.getMinutes() * 60) + now.getSeconds() + (now.getTimezoneOffset() + 60) * 60) / 86.4); case "c": return x.toISOString().replace(/\"/g, ""); case "U": return $D.strtotime("now"); case "%c": return t("d") + " " + t("t"); case "%C": return Math.floor(x.getFullYear() / 100 + 1); } }, shouldOverrideDefaults: function (m) { switch (m) { case "%e": return true; default: return false; } }, parse: function (m, context) { var formatString, c = context || new Date(); formatString = normalizer.substitutes(m); if (formatString) { return formatString; } formatString = normalizer.interpreted(m, c); if (formatString) { return formatString; } else { return m; } } }; $D.normalizeFormat = function (format, context) { return format.replace(/(%|\\)?.|%%/g, function(t){ return normalizer.parse(t, context); }); }; /** * Format a local Unix timestamp according to locale settings * * Example: * Date.strftime("%m/%d/%y", new Date()); // "04/13/08" * Date.strftime("c", "2008-04-13T17:52:03Z"); // "04/13/08" * * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @param {Number|String} The number representing the number of seconds that have elapsed since January 1, 1970 (local time). * @return {String} A string representation of the current Date object. */ $D.strftime = function (format, time) { var d = Date.parse(time); return d._format(format); }; /** * Parse any textual datetime description into a Unix timestamp. * A Unix timestamp is the number of seconds that have elapsed since January 1, 1970 (midnight UTC/GMT). * * Example: * Date.strtotime("04/13/08"); // 1208044800 * Date.strtotime("1970-01-01T00:00:00Z"); // 0 * * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @param {Object} A string or date object. * @return {String} A string representation of the current Date object. */ $D.strtotime = function (time) { var d = $D.parse(time); return Math.round($D.UTC(d.getUTCFullYear(), d.getUTCMonth(), d.getUTCDate(), d.getUTCHours(), d.getUTCMinutes(), d.getUTCSeconds(), d.getUTCMilliseconds()) / 1000); }; /** * Converts the value of the current Date object to its equivalent string representation using a PHP/Unix style of date format specifiers. * Format Specifiers * Format Description Example * ------ --------------------------------------------------------------------------- ----------------------- * %a abbreviated weekday name according to the current localed "Mon" through "Sun" * %A full weekday name according to the current localed "Sunday" through "Saturday" * %b abbreviated month name according to the current localed "Jan" through "Dec" * %B full month name according to the current locale "January" through "December" * %c preferred date and time representation for the current locale "4/13/2008 12:33 PM" * %C century number (the year divided by 100 and truncated to an integer) "00" to "99" * %d day of the month as a decimal number "01" to "31" * %D same as %m/%d/%y "04/13/08" * %e day of the month as a decimal number, a single digit is preceded by a space "1" to "31" * %g like %G, but without the century "08" * %G The 4-digit year corresponding to the ISO week number (see %V). "2008" * This has the same format and value as %Y, except that if the ISO week number * belongs to the previous or next year, that year is used instead. * %h same as %b "Jan" through "Dec" * %H hour as a decimal number using a 24-hour clock. "00" to "23" * %I hour as a decimal number using a 12-hour clock. "01" to "12" * %j day of the year as a decimal number. "001" to "366" * %m month as a decimal number. "01" to "12" * %M minute as a decimal number. "00" to "59" * %n newline character "\n" * %p either "am" or "pm" according to the given time value, or the "am" or "pm" * corresponding strings for the current locale. * %r time in a.m. and p.m. notation "8:44 PM" * %R time in 24 hour notation "20:44" * %S second as a decimal number "00" to "59" * %t tab character "\t" * %T current time, equal to %H:%M:%S "12:49:11" * %u weekday as a decimal number ["1", "7"], with "1" representing Monday "1" to "7" * %U week number of the current year as a decimal number, starting with the "0" to ("52" or "53") * first Sunday as the first day of the first week * %V The ISO 8601:1988 week number of the current year as a decimal number, "00" to ("52" or "53") * range 01 to 53, where week 1 is the first week that has at least 4 days * in the current year, and with Monday as the first day of the week. * (Use %G or %g for the year component that corresponds to the week number * for the specified timestamp.) * %W week number of the current year as a decimal number, starting with the "00" to ("52" or "53") * first Monday as the first day of the first week * %w day of the week as a decimal, Sunday being "0" "0" to "6" * %x preferred date representation for the current locale without the time "4/13/2008" * %X preferred time representation for the current locale without the date "12:53:05" * %y year as a decimal number without a century "00" "99" * %Y year as a decimal number including the century "2008" * %Z time zone or name or abbreviation "UTC", "EST", "PST" * %z same as %Z * %% a literal "%" characters "%" * d Day of the month, 2 digits with leading zeros "01" to "31" * D A textual representation of a day, three letters "Mon" through "Sun" * j Day of the month without leading zeros "1" to "31" * l A full textual representation of the day of the week (lowercase "L") "Sunday" through "Saturday" * N ISO-8601 numeric representation of the day of the week (added in PHP 5.1.0) "1" (for Monday) through "7" (for Sunday) * S English ordinal suffix for the day of the month, 2 characters "st", "nd", "rd" or "th". Works well with j * w Numeric representation of the day of the week "0" (for Sunday) through "6" (for Saturday) * z The day of the year (starting from "0") "0" through "365" * W ISO-8601 week number of year, weeks starting on Monday "00" to ("52" or "53") * F A full textual representation of a month, such as January or March "January" through "December" * m Numeric representation of a month, with leading zeros "01" through "12" * M A short textual representation of a month, three letters "Jan" through "Dec" * n Numeric representation of a month, without leading zeros "1" through "12" * t Number of days in the given month "28" through "31" * L Whether it's a leap year "1" if it is a leap year, "0" otherwise * o ISO-8601 year number. This has the same value as Y, except that if the "2008" * ISO week number (W) belongs to the previous or next year, that year * is used instead. * Y A full numeric representation of a year, 4 digits "2008" * y A two digit representation of a year "08" * a Lowercase Ante meridiem and Post meridiem "am" or "pm" * A Uppercase Ante meridiem and Post meridiem "AM" or "PM" * B Swatch Internet time "000" through "999" * g 12-hour format of an hour without leading zeros "1" through "12" * G 24-hour format of an hour without leading zeros "0" through "23" * h 12-hour format of an hour with leading zeros "01" through "12" * H 24-hour format of an hour with leading zeros "00" through "23" * i Minutes with leading zeros "00" to "59" * s Seconds, with leading zeros "00" through "59" * u Milliseconds "54321" * e Timezone identifier "UTC", "EST", "PST" * I Whether or not the date is in daylight saving time (uppercase i) "1" if Daylight Saving Time, "0" otherwise * O Difference to Greenwich time (GMT) in hours "+0200", "-0600" * P Difference to Greenwich time (GMT) with colon between hours and minutes "+02:00", "-06:00" * T Timezone abbreviation "UTC", "EST", "PST" * Z Timezone offset in seconds. The offset for timezones west of UTC is "-43200" through "50400" * always negative, and for those east of UTC is always positive. * c ISO 8601 date "2004-02-12T15:19:21+00:00" * r RFC 2822 formatted date "Thu, 21 Dec 2000 16:01:07 +0200" * U Seconds since the Unix Epoch (January 1 1970 00:00:00 GMT) "0" * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @return {String} A string representation of the current Date object. */ var formatReplace = function (context) { return function (m) { var formatString, override = false; if (m.charAt(0) === "\\" || m.substring(0, 2) === "%%") { return m.replace("\\", "").replace("%%", "%"); } override = normalizer.shouldOverrideDefaults(m); formatString = $D.normalizeFormat(m, context); if (formatString) { return context.toString(formatString, override); } }; }; $P._format = function (format) { var formatter = formatReplace(this); if (!format) { return this._toString(); } else { return format.replace(/(%|\\)?.|%%/g, formatter); } }; if (!$P.format) { $P.format = $P._format; } }()); (function () { "use strict"; var gFn = function (attr) { return function () { return this[attr]; }; }; var sFn = function (attr) { return function (val) { this[attr] = val; return this; }; }; var attrs = ["years", "months", "days", "hours", "minutes", "seconds", "milliseconds"]; var addSetFuncs = function (context, attrs) { for (var i = 0; i < attrs.length ; i++) { var $a = attrs[i], $b = $a.slice(0, 1).toUpperCase() + $a.slice(1); context.prototype[$a] = 0; context.prototype["get" + $b] = gFn($a); context.prototype["set" + $b] = sFn($a); } }; /** * new TimeSpan(milliseconds); * new TimeSpan(days, hours, minutes, seconds); * new TimeSpan(days, hours, minutes, seconds, milliseconds); */ var TimeSpan = function (days, hours, minutes, seconds, milliseconds) { if (arguments.length === 1 && typeof days === "number") { var orient = (days < 0) ? -1 : +1; var millsLeft = Math.abs(days); this.setDays(Math.floor(millsLeft / 86400000) * orient); millsLeft = millsLeft % 86400000; this.setHours(Math.floor(millsLeft / 3600000) * orient); millsLeft = millsLeft % 3600000; this.setMinutes(Math.floor(millsLeft / 60000) * orient); millsLeft = millsLeft % 60000; this.setSeconds(Math.floor(millsLeft / 1000) * orient); millsLeft = millsLeft % 1000; this.setMilliseconds(millsLeft * orient); } else { this.set(days, hours, minutes, seconds, milliseconds); } this.getTotalMilliseconds = function () { return (this.getDays() * 86400000) + (this.getHours() * 3600000) + (this.getMinutes() * 60000) + (this.getSeconds() * 1000); }; this.compareTo = function (time) { var t1 = new Date(1970, 1, 1, this.getHours(), this.getMinutes(), this.getSeconds()), t2; if (time === null) { t2 = new Date(1970, 1, 1, 0, 0, 0); } else { t2 = new Date(1970, 1, 1, time.getHours(), time.getMinutes(), time.getSeconds()); } return (t1 < t2) ? -1 : (t1 > t2) ? 1 : 0; }; this.equals = function (time) { return (this.compareTo(time) === 0); }; this.add = function (time) { return (time === null) ? this : this.addSeconds(time.getTotalMilliseconds() / 1000); }; this.subtract = function (time) { return (time === null) ? this : this.addSeconds(-time.getTotalMilliseconds() / 1000); }; this.addDays = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 86400000)); }; this.addHours = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 3600000)); }; this.addMinutes = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 60000)); }; this.addSeconds = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 1000)); }; this.addMilliseconds = function (n) { return new TimeSpan(this.getTotalMilliseconds() + n); }; this.get12HourHour = function () { return (this.getHours() > 12) ? this.getHours() - 12 : (this.getHours() === 0) ? 12 : this.getHours(); }; this.getDesignator = function () { return (this.getHours() < 12) ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator; }; this.toString = function (format) { this._toString = function () { if (this.getDays() !== null && this.getDays() > 0) { return this.getDays() + "." + this.getHours() + ":" + this.p(this.getMinutes()) + ":" + this.p(this.getSeconds()); } else { return this.getHours() + ":" + this.p(this.getMinutes()) + ":" + this.p(this.getSeconds()); } }; this.p = function (s) { return (s.toString().length < 2) ? "0" + s : s; }; var me = this; return format ? format.replace(/dd?|HH?|hh?|mm?|ss?|tt?/g, function (format) { switch (format) { case "d": return me.getDays(); case "dd": return me.p(me.getDays()); case "H": return me.getHours(); case "HH": return me.p(me.getHours()); case "h": return me.get12HourHour(); case "hh": return me.p(me.get12HourHour()); case "m": return me.getMinutes(); case "mm": return me.p(me.getMinutes()); case "s": return me.getSeconds(); case "ss": return me.p(me.getSeconds()); case "t": return ((me.getHours() < 12) ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator).substring(0, 1); case "tt": return (me.getHours() < 12) ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator; } } ) : this._toString(); }; return this; }; addSetFuncs(TimeSpan, attrs.slice(2)); TimeSpan.prototype.set = function (days, hours, minutes, seconds, milliseconds){ this.setDays(days || this.getDays()); this.setHours(hours || this.getHours()); this.setMinutes(minutes || this.getMinutes()); this.setSeconds(seconds || this.getSeconds()); this.setMilliseconds(milliseconds || this.getMilliseconds()); }; /** * Gets the time of day for this date instances. * @return {TimeSpan} TimeSpan */ Date.prototype.getTimeOfDay = function () { return new TimeSpan(0, this.getHours(), this.getMinutes(), this.getSeconds(), this.getMilliseconds()); }; Date.TimeSpan = TimeSpan; if (typeof window !== "undefined" ) { // keeping API compatible for v1.x window.TimeSpan = TimeSpan; } }()); (function () { "use strict"; var attrs = ["years", "months", "days", "hours", "minutes", "seconds", "milliseconds"]; var gFn = function (attr) { return function () { return this[attr]; }; }; var sFn = function (attr) { return function (val) { this[attr] = val; return this; }; }; var addSetFuncs = function (context, attrs) { for (var i = 0; i < attrs.length ; i++) { var $a = attrs[i], $b = $a.slice(0, 1).toUpperCase() + $a.slice(1); context.prototype[$a] = 0; context.prototype["get" + $b] = gFn($a); context.prototype["set" + $b] = sFn($a); } }; var setMonthsAndYears = function (orient, d1, d2, context) { function inc() { d1.addMonths(-orient); context.months++; if (context.months === 12) { context.years++; context.months = 0; } } if (orient === +1) { while (d1 > d2) { inc(); } } else { while (d1 < d2) { inc(); } } context.months--; context.months *= orient; context.years *= orient; }; var adjustForDST = function(orient, startDate, endDate) { var hasDSTMismatch = (false === (startDate.isDaylightSavingTime() === endDate.isDaylightSavingTime())); if (hasDSTMismatch && orient === 1) { startDate.addHours(-1); } else if (hasDSTMismatch) { startDate.addHours(1); } }; /** * TimePeriod(startDate, endDate); * TimePeriod(years, months, days, hours, minutes, seconds, milliseconds); */ var TimePeriod = function (years, months, days, hours, minutes, seconds, milliseconds) { if (arguments.length === 7) { this.set(years, months, days, hours, minutes, seconds, milliseconds); } else if (arguments.length === 2 && arguments[0] instanceof Date && arguments[1] instanceof Date) { var startDate = arguments[0].clone(); var endDate = arguments[1].clone(); var orient = (startDate > endDate) ? +1 : -1; this.dates = { start: arguments[0].clone(), end: arguments[1].clone() }; setMonthsAndYears(orient, startDate, endDate, this); adjustForDST(orient, startDate, endDate); // // TODO - adjust for DST var diff = endDate - startDate; if (diff !== 0) { var ts = new TimeSpan(diff); this.set(this.years, this.months, ts.getDays(), ts.getHours(), ts.getMinutes(), ts.getSeconds(), ts.getMilliseconds()); } } return this; }; // create all the set functions. addSetFuncs(TimePeriod, attrs); TimePeriod.prototype.set = function (years, months, days, hours, minutes, seconds, milliseconds){ this.setYears(years || this.getYears()); this.setMonths(months || this.getMonths()); this.setDays(days || this.getDays()); this.setHours(hours || this.getHours()); this.setMinutes(minutes || this.getMinutes()); this.setSeconds(seconds || this.getSeconds()); this.setMilliseconds(milliseconds || this.getMilliseconds()); }; Date.TimePeriod = TimePeriod; if (typeof window !== "undefined") { // keeping API compatible for v1.x window.TimePeriod = TimePeriod; } }()); ================================================ FILE: build/date-es-UY.js ================================================ /** * @overview datejs * @version 1.0.0-rc3 * @author Gregory Wild-Smith * @copyright 2015 Gregory Wild-Smith * @license MIT * @homepage https://github.com/abritinthebay/datejs */ /* * DateJS Culture String File * Country Code: es-UY * Name: Spanish (Uruguay) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["es-UY"] = { "name": "es-UY", "englishName": "Spanish (Uruguay)", "nativeName": "Español (Uruguay)", "Sunday": "domingo", "Monday": "lunes", "Tuesday": "martes", "Wednesday": "miércoles", "Thursday": "jueves", "Friday": "viernes", "Saturday": "sábado", "Sun": "dom", "Mon": "lun", "Tue": "mar", "Wed": "mié", "Thu": "jue", "Fri": "vie", "Sat": "sáb", "Su": "do", "Mo": "lu", "Tu": "ma", "We": "mi", "Th": "ju", "Fr": "vi", "Sa": "sá", "S_Sun_Initial": "d", "M_Mon_Initial": "l", "T_Tue_Initial": "m", "W_Wed_Initial": "m", "T_Thu_Initial": "j", "F_Fri_Initial": "v", "S_Sat_Initial": "s", "January": "enero", "February": "febrero", "March": "marzo", "April": "abril", "May": "mayo", "June": "junio", "July": "julio", "August": "agosto", "September": "septiembre", "October": "octubre", "November": "noviembre", "December": "diciembre", "Jan_Abbr": "ene", "Feb_Abbr": "feb", "Mar_Abbr": "mar", "Apr_Abbr": "abr", "May_Abbr": "may", "Jun_Abbr": "jun", "Jul_Abbr": "jul", "Aug_Abbr": "ago", "Sep_Abbr": "sep", "Oct_Abbr": "oct", "Nov_Abbr": "nov", "Dec_Abbr": "dic", "AM": "a.m.", "PM": "p.m.", "firstDayOfWeek": 1, "twoDigitYearMax": 2029, "mdy": "dmy", "M/d/yyyy": "dd/MM/yyyy", "dddd, MMMM dd, yyyy": "dddd, dd' [de] 'MMMM' [de] 'yyyy", "h:mm tt": "hh:mm tt", "h:mm:ss tt": "hh:mm:ss tt", "dddd, MMMM dd, yyyy h:mm:ss tt": "dddd, dd' [de] 'MMMM' [de] 'yyyy hh:mm:ss tt", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "dd MMMM", "MMMM, yyyy": "MMMM' [de] 'yyyy", "/jan(uary)?/": "ene(ro)?", "/feb(ruary)?/": "feb(rero)?", "/mar(ch)?/": "mar(zo)?", "/apr(il)?/": "abr(il)?", "/may/": "may(o)?", "/jun(e)?/": "jun(io)?", "/jul(y)?/": "jul(io)?", "/aug(ust)?/": "ago(sto)?", "/sep(t(ember)?)?/": "sep(tiembre)?", "/oct(ober)?/": "oct(ubre)?", "/nov(ember)?/": "nov(iembre)?", "/dec(ember)?/": "dic(iembre)?", "/^su(n(day)?)?/": "^do(m(ingo)?)?", "/^mo(n(day)?)?/": "^lu(n(es)?)?", "/^tu(e(s(day)?)?)?/": "^ma(r(tes)?)?", "/^we(d(nesday)?)?/": "^mi(é(rcoles)?)?", "/^th(u(r(s(day)?)?)?)?/": "^ju(e(ves)?)?", "/^fr(i(day)?)?/": "^vi(e(rnes)?)?", "/^sa(t(urday)?)?/": "^sá(b(ado)?)?", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "es-UY"; /** * @overview datejs * @version 1.0.0-rc3 * @author Gregory Wild-Smith * @copyright 2015 Gregory Wild-Smith * @license MIT * @homepage https://github.com/abritinthebay/datejs */(function () { var $D = Date; var lang = Date.CultureStrings ? Date.CultureStrings.lang : null; var loggedKeys = {}; // for debug purposes. var getText = { getFromKey: function (key, countryCode) { var output; if (Date.CultureStrings && Date.CultureStrings[countryCode] && Date.CultureStrings[countryCode][key]) { output = Date.CultureStrings[countryCode][key]; } else { output = getText.buildFromDefault(key); } if (key.charAt(0) === "/") { // Assume it's a regex output = getText.buildFromRegex(key, countryCode); } return output; }, getFromObjectValues: function (obj, countryCode) { var key, output = {}; for(key in obj) { if (obj.hasOwnProperty(key)) { output[key] = getText.getFromKey(obj[key], countryCode); } } return output; }, getFromObjectKeys: function (obj, countryCode) { var key, output = {}; for(key in obj) { if (obj.hasOwnProperty(key)) { output[getText.getFromKey(key, countryCode)] = obj[key]; } } return output; }, getFromArray: function (arr, countryCode) { var output = []; for (var i=0; i < arr.length; i++){ if (i in arr) { output[i] = getText.getFromKey(arr[i], countryCode); } } return output; }, buildFromDefault: function (key) { var output, length, split, last; switch(key) { case "name": output = "en-US"; break; case "englishName": output = "English (United States)"; break; case "nativeName": output = "English (United States)"; break; case "twoDigitYearMax": output = 2049; break; case "firstDayOfWeek": output = 0; break; default: output = key; split = key.split("_"); length = split.length; if (length > 1 && key.charAt(0) !== "/") { // if the key isn't a regex and it has a split. last = split[(length - 1)].toLowerCase(); if (last === "initial" || last === "abbr") { output = split[0]; } } break; } return output; }, buildFromRegex: function (key, countryCode) { var output; if (Date.CultureStrings && Date.CultureStrings[countryCode] && Date.CultureStrings[countryCode][key]) { output = new RegExp(Date.CultureStrings[countryCode][key], "i"); } else { output = new RegExp(key.replace(new RegExp("/", "g"),""), "i"); } return output; } }; var shallowMerge = function (obj1, obj2) { for (var attrname in obj2) { if (obj2.hasOwnProperty(attrname)) { obj1[attrname] = obj2[attrname]; } } }; var __ = function (key, language) { var countryCode = (language) ? language : lang; loggedKeys[key] = key; if (typeof key === "object") { if (key instanceof Array) { return getText.getFromArray(key, countryCode); } else { return getText.getFromObjectKeys(key, countryCode); } } else { return getText.getFromKey(key, countryCode); } }; var loadI18nScript = function (code) { // paatterned after jQuery's getScript. var url = Date.Config.i18n + code + ".js"; var head = document.getElementsByTagName("head")[0] || document.documentElement; var script = document.createElement("script"); script.src = url; var completed = false; var events = { done: function (){} // placeholder function }; // Attach handlers for all browsers script.onload = script.onreadystatechange = function() { if ( !completed && (!this.readyState || this.readyState === "loaded" || this.readyState === "complete") ) { events.done(); head.removeChild(script); } }; setTimeout(function() { head.insertBefore(script, head.firstChild); }, 0); // allows return to execute first return { done: function (cb) { events.done = function() { if (cb) { setTimeout(cb,0); } }; } }; }; var buildInfo = { buildFromMethodHash: function (obj) { var key; for(key in obj) { if (obj.hasOwnProperty(key)) { obj[key] = buildInfo[obj[key]](); } } return obj; }, timeZoneDST: function () { var DST = { "CHADT": "+1345", "NZDT": "+1300", "AEDT": "+1100", "ACDT": "+1030", "AZST": "+0500", "IRDT": "+0430", "EEST": "+0300", "CEST": "+0200", "BST": "+0100", "PMDT": "-0200", "ADT": "-0300", "NDT": "-0230", "EDT": "-0400", "CDT": "-0500", "MDT": "-0600", "PDT": "-0700", "AKDT": "-0800", "HADT": "-0900" }; return __(DST); }, timeZoneStandard: function () { var standard = { "LINT": "+1400", "TOT": "+1300", "CHAST": "+1245", "NZST": "+1200", "NFT": "+1130", "SBT": "+1100", "AEST": "+1000", "ACST": "+0930", "JST": "+0900", "CWST": "+0845", "CT": "+0800", "ICT": "+0700", "MMT": "+0630", "BST": "+0600", "NPT": "+0545", "IST": "+0530", "PKT": "+0500", "AFT": "+0430", "MSK": "+0400", "IRST": "+0330", "FET": "+0300", "EET": "+0200", "CET": "+0100", "GMT": "+0000", "UTC": "+0000", "CVT": "-0100", "GST": "-0200", "BRT": "-0300", "NST": "-0330", "AST": "-0400", "EST": "-0500", "CST": "-0600", "MST": "-0700", "PST": "-0800", "AKST": "-0900", "MIT": "-0930", "HST": "-1000", "SST": "-1100", "BIT": "-1200" }; return __(standard); }, timeZones: function (data) { var zone; data.timezones = []; for (zone in data.abbreviatedTimeZoneStandard) { if (data.abbreviatedTimeZoneStandard.hasOwnProperty(zone)) { data.timezones.push({ name: zone, offset: data.abbreviatedTimeZoneStandard[zone]}); } } for (zone in data.abbreviatedTimeZoneDST) { if (data.abbreviatedTimeZoneDST.hasOwnProperty(zone)) { data.timezones.push({ name: zone, offset: data.abbreviatedTimeZoneDST[zone], dst: true}); } } return data.timezones; }, days: function () { return __(["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"]); }, dayAbbr: function () { return __(["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"]); }, dayShortNames: function () { return __(["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"]); }, dayFirstLetters: function () { return __(["S_Sun_Initial", "M_Mon_Initial", "T_Tues_Initial", "W_Wed_Initial", "T_Thu_Initial", "F_Fri_Initial", "S_Sat_Initial"]); }, months: function () { return __(["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"]); }, monthAbbr: function () { return __(["Jan_Abbr", "Feb_Abbr", "Mar_Abbr", "Apr_Abbr", "May_Abbr", "Jun_Abbr", "Jul_Abbr", "Aug_Abbr", "Sep_Abbr", "Oct_Abbr", "Nov_Abbr", "Dec_Abbr"]); }, formatPatterns: function () { return getText.getFromObjectValues({ shortDate: "M/d/yyyy", longDate: "dddd, MMMM dd, yyyy", shortTime: "h:mm tt", longTime: "h:mm:ss tt", fullDateTime: "dddd, MMMM dd, yyyy h:mm:ss tt", sortableDateTime: "yyyy-MM-ddTHH:mm:ss", universalSortableDateTime: "yyyy-MM-dd HH:mm:ssZ", rfc1123: "ddd, dd MMM yyyy HH:mm:ss", monthDay: "MMMM dd", yearMonth: "MMMM, yyyy" }, Date.i18n.currentLanguage()); }, regex: function () { return getText.getFromObjectValues({ inTheMorning: "/( in the )(morn(ing)?)\\b/", thisMorning: "/(this )(morn(ing)?)\\b/", amThisMorning: "/(\b\\d(am)? )(this )(morn(ing)?)/", inTheEvening: "/( in the )(even(ing)?)\\b/", thisEvening: "/(this )(even(ing)?)\\b/", pmThisEvening: "/(\b\\d(pm)? )(this )(even(ing)?)/", jan: "/jan(uary)?/", feb: "/feb(ruary)?/", mar: "/mar(ch)?/", apr: "/apr(il)?/", may: "/may/", jun: "/jun(e)?/", jul: "/jul(y)?/", aug: "/aug(ust)?/", sep: "/sep(t(ember)?)?/", oct: "/oct(ober)?/", nov: "/nov(ember)?/", dec: "/dec(ember)?/", sun: "/^su(n(day)?)?/", mon: "/^mo(n(day)?)?/", tue: "/^tu(e(s(day)?)?)?/", wed: "/^we(d(nesday)?)?/", thu: "/^th(u(r(s(day)?)?)?)?/", fri: "/fr(i(day)?)?/", sat: "/^sa(t(urday)?)?/", future: "/^next/", past: "/^last|past|prev(ious)?/", add: "/^(\\+|aft(er)?|from|hence)/", subtract: "/^(\\-|bef(ore)?|ago)/", yesterday: "/^yes(terday)?/", today: "/^t(od(ay)?)?/", tomorrow: "/^tom(orrow)?/", now: "/^n(ow)?/", millisecond: "/^ms|milli(second)?s?/", second: "/^sec(ond)?s?/", minute: "/^mn|min(ute)?s?/", hour: "/^h(our)?s?/", week: "/^w(eek)?s?/", month: "/^m(onth)?s?/", day: "/^d(ay)?s?/", year: "/^y(ear)?s?/", shortMeridian: "/^(a|p)/", longMeridian: "/^(a\\.?m?\\.?|p\\.?m?\\.?)/", timezone: "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/", ordinalSuffix: "/^\\s*(st|nd|rd|th)/", timeContext: "/^\\s*(\\:|a(?!u|p)|p)/" }, Date.i18n.currentLanguage()); } }; var CultureInfo = function () { var info = getText.getFromObjectValues({ name: "name", englishName: "englishName", nativeName: "nativeName", amDesignator: "AM", pmDesignator: "PM", firstDayOfWeek: "firstDayOfWeek", twoDigitYearMax: "twoDigitYearMax", dateElementOrder: "mdy" }, Date.i18n.currentLanguage()); var constructedInfo = buildInfo.buildFromMethodHash({ dayNames: "days", abbreviatedDayNames: "dayAbbr", shortestDayNames: "dayShortNames", firstLetterDayNames: "dayFirstLetters", monthNames: "months", abbreviatedMonthNames: "monthAbbr", formatPatterns: "formatPatterns", regexPatterns: "regex", abbreviatedTimeZoneDST: "timeZoneDST", abbreviatedTimeZoneStandard: "timeZoneStandard" }); shallowMerge(info, constructedInfo); buildInfo.timeZones(info); return info; }; $D.i18n = { __: function (key, lang) { return __(key, lang); }, currentLanguage: function () { return lang || "en-US"; }, setLanguage: function (code, force, cb) { var async = false; if (force || code === "en-US" || (!!Date.CultureStrings && !!Date.CultureStrings[code])) { lang = code; Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings.lang = code; Date.CultureInfo = new CultureInfo(); } else { if (!(!!Date.CultureStrings && !!Date.CultureStrings[code])) { if (typeof exports !== "undefined" && this.exports !== exports) { // we're in a Node enviroment, load it using require try { require("../i18n/" + code + ".js"); lang = code; Date.CultureStrings.lang = code; Date.CultureInfo = new CultureInfo(); } catch (e) { // var str = "The language for '" + code + "' could not be loaded by Node. It likely does not exist."; throw new Error("The DateJS IETF language tag '" + code + "' could not be loaded by Node. It likely does not exist."); } } else if (Date.Config && Date.Config.i18n) { // we know the location of the files, so lets load them async = true; loadI18nScript(code).done(function(){ lang = code; Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings.lang = code; Date.CultureInfo = new CultureInfo(); $D.Parsing.Normalizer.buildReplaceData(); // because this is async if ($D.Grammar) { $D.Grammar.buildGrammarFormats(); // so we can parse those strings... } if (cb) { setTimeout(cb,0); } }); } else { Date.console.error("The DateJS IETF language tag '" + code + "' is not available and has not been loaded."); return false; } } } $D.Parsing.Normalizer.buildReplaceData(); // rebuild normalizer strings if ($D.Grammar) { $D.Grammar.buildGrammarFormats(); // so we can parse those strings... } if (!async && cb) { setTimeout(cb,0); } }, getLoggedKeys: function () { return loggedKeys; }, updateCultureInfo: function () { Date.CultureInfo = new CultureInfo(); } }; $D.i18n.updateCultureInfo(); // run automatically }()); (function () { var $D = Date, $P = $D.prototype, p = function (s, l) { if (!l) { l = 2; } return ("000" + s).slice(l * -1); }; if (typeof window !== "undefined" && typeof window.console !== "undefined" && typeof window.console.log !== "undefined") { $D.console = console; // used only to raise non-critical errors if available } else { // set mock so we don't give errors. $D.console = { log: function(){}, error: function(){} }; } $D.Config = $D.Config || {}; $D.initOverloads = function() { /** * Overload of Date.now. Allows an alternate call for Date.now where it returns the * current Date as an object rather than just milliseconds since the Unix Epoch. * * Also provides an implementation of now() for browsers (IE<9) that don't have it. * * Backwards compatible so with work with either: * Date.now() [returns ms] * or * Date.now(true) [returns Date] */ if (!$D.now) { $D._now = function now() { return new Date().getTime(); }; } else if (!$D._now) { $D._now = $D.now; } $D.now = function (returnObj) { if (returnObj) { return $D.present(); } else { return $D._now(); } }; if ( !$P.toISOString ) { $P.toISOString = function() { return this.getUTCFullYear() + "-" + p(this.getUTCMonth() + 1) + "-" + p(this.getUTCDate()) + "T" + p(this.getUTCHours()) + ":" + p(this.getUTCMinutes()) + ":" + p(this.getUTCSeconds()) + "." + String( (this.getUTCMilliseconds()/1000).toFixed(3)).slice(2, 5) + "Z"; }; } // private if ( $P._toString === undefined ){ $P._toString = $P.toString; } }; $D.initOverloads(); /** * Gets a date that is set to the current date. The time is set to the start of the day (00:00 or 12:00 AM). * @return {Date} The current date. */ $D.today = function () { return new Date().clearTime(); }; /** * Gets a date that is set to the current date and time (same as new Date, but chainable) * @return {Date} The current date. */ $D.present = function () { return new Date(); }; /** * Compares the first date to the second date and returns an number indication of their relative values. * @param {Date} First Date object to compare [Required]. * @param {Date} Second Date object to compare to [Required]. * @return {Number} -1 = date1 is lessthan date2. 0 = values are equal. 1 = date1 is greaterthan date2. */ $D.compare = function (date1, date2) { if (isNaN(date1) || isNaN(date2)) { throw new Error(date1 + " - " + date2); } else if (date1 instanceof Date && date2 instanceof Date) { return (date1 < date2) ? -1 : (date1 > date2) ? 1 : 0; } else { throw new TypeError(date1 + " - " + date2); } }; /** * Compares the first Date object to the second Date object and returns true if they are equal. * @param {Date} First Date object to compare [Required] * @param {Date} Second Date object to compare to [Required] * @return {Boolean} true if dates are equal. false if they are not equal. */ $D.equals = function (date1, date2) { return (date1.compareTo(date2) === 0); }; /** * Gets the language appropriate day name when given the day number(0-6) * eg - 0 == Sunday * @return {String} The day name */ $D.getDayName = function (n) { return Date.CultureInfo.dayNames[n]; }; /** * Gets the day number (0-6) if given a CultureInfo specific string which is a valid dayName, abbreviatedDayName or shortestDayName (two char). * @param {String} The name of the day (eg. "Monday, "Mon", "tuesday", "tue", "We", "we"). * @return {Number} The day number */ $D.getDayNumberFromName = function (name) { var n = Date.CultureInfo.dayNames, m = Date.CultureInfo.abbreviatedDayNames, o = Date.CultureInfo.shortestDayNames, s = name.toLowerCase(); for (var i = 0; i < n.length; i++) { if (n[i].toLowerCase() === s || m[i].toLowerCase() === s || o[i].toLowerCase() === s) { return i; } } return -1; }; /** * Gets the month number (0-11) if given a Culture Info specific string which is a valid monthName or abbreviatedMonthName. * @param {String} The name of the month (eg. "February, "Feb", "october", "oct"). * @return {Number} The day number */ $D.getMonthNumberFromName = function (name) { var n = Date.CultureInfo.monthNames, m = Date.CultureInfo.abbreviatedMonthNames, s = name.toLowerCase(); for (var i = 0; i < n.length; i++) { if (n[i].toLowerCase() === s || m[i].toLowerCase() === s) { return i; } } return -1; }; /** * Gets the language appropriate month name when given the month number(0-11) * eg - 0 == January * @return {String} The month name */ $D.getMonthName = function (n) { return Date.CultureInfo.monthNames[n]; }; /** * Determines if the current date instance is within a LeapYear. * @param {Number} The year. * @return {Boolean} true if date is within a LeapYear, otherwise false. */ $D.isLeapYear = function (year) { return ((year % 4 === 0 && year % 100 !== 0) || year % 400 === 0); }; /** * Gets the number of days in the month, given a year and month value. Automatically corrects for LeapYear. * @param {Number} The year. * @param {Number} The month (0-11). * @return {Number} The number of days in the month. */ $D.getDaysInMonth = function (year, month) { if (!month && $D.validateMonth(year)) { month = year; year = Date.today().getFullYear(); } return [31, ($D.isLeapYear(year) ? 29 : 28), 31, 30, 31, 30, 31, 31, 30, 31, 30, 31][month]; }; $P.getDaysInMonth = function () { return $D.getDaysInMonth(this.getFullYear(), this.getMonth()); }; $D.getTimezoneAbbreviation = function (offset, dst) { var p, n = (dst || false) ? Date.CultureInfo.abbreviatedTimeZoneDST : Date.CultureInfo.abbreviatedTimeZoneStandard; for (p in n) { if (n.hasOwnProperty(p)) { if (n[p] === offset) { return p; } } } return null; }; $D.getTimezoneOffset = function (name, dst) { var i, a =[], z = Date.CultureInfo.timezones; if (!name) { name = (new Date()).getTimezone();} for (i = 0; i < z.length; i++) { if (z[i].name === name.toUpperCase()) { a.push(i); } } if (!z[a[0]]) { return null; } if (a.length === 1 || !dst) { return z[a[0]].offset; } else { for (i=0; i < a.length; i++) { if (z[a[i]].dst) { return z[a[i]].offset; } } } }; $D.getQuarter = function (d) { d = d || new Date(); // If no date supplied, use today var q = [1,2,3,4]; return q[Math.floor(d.getMonth() / 3)]; // ~~~ is a bitwise op. Faster than Math.floor }; $D.getDaysLeftInQuarter = function (d) { d = d || new Date(); var qEnd = new Date(d); qEnd.setMonth(qEnd.getMonth() + 3 - qEnd.getMonth() % 3, 0); return Math.floor((qEnd - d) / 8.64e7); }; // private var validate = function (n, min, max, name) { name = name ? name : "Object"; if (typeof n === "undefined") { return false; } else if (typeof n !== "number") { throw new TypeError(n + " is not a Number."); } else if (n < min || n > max) { // As failing validation is *not* an exceptional circumstance // lets not throw a RangeError Exception here. // It's semantically correct but it's not sensible. return false; } return true; }; /** * Validates the number is within an acceptable range for milliseconds [0-999]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateMillisecond = function (value) { return validate(value, 0, 999, "millisecond"); }; /** * Validates the number is within an acceptable range for seconds [0-59]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateSecond = function (value) { return validate(value, 0, 59, "second"); }; /** * Validates the number is within an acceptable range for minutes [0-59]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateMinute = function (value) { return validate(value, 0, 59, "minute"); }; /** * Validates the number is within an acceptable range for hours [0-23]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateHour = function (value) { return validate(value, 0, 23, "hour"); }; /** * Validates the number is within an acceptable range for the days in a month [0-MaxDaysInMonth]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateDay = function (value, year, month) { if (year === undefined || year === null || month === undefined || month === null) { return false;} return validate(value, 1, $D.getDaysInMonth(year, month), "day"); }; /** * Validates the number is within an acceptable range for months [0-11]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateWeek = function (value) { return validate(value, 0, 53, "week"); }; /** * Validates the number is within an acceptable range for months [0-11]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateMonth = function (value) { return validate(value, 0, 11, "month"); }; /** * Validates the number is within an acceptable range for years. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateYear = function (value) { /** * Per ECMAScript spec the range of times supported by Date objects is * exactly -100,000,000 days to +100,000,000 days measured relative to * midnight at the beginning of 01 January, 1970 UTC. * This gives a range of 8,640,000,000,000,000 milliseconds to either * side of 01 January, 1970 UTC. * * Earliest possible date: Tue, 20 Apr 271,822 B.C. 00:00:00 UTC * Latest possible date: Sat, 13 Sep 275,760 00:00:00 UTC */ return validate(value, -271822, 275760, "year"); }; $D.validateTimezone = function(value) { var timezones = {"ACDT":1,"ACST":1,"ACT":1,"ADT":1,"AEDT":1,"AEST":1,"AFT":1,"AKDT":1,"AKST":1,"AMST":1,"AMT":1,"ART":1,"AST":1,"AWDT":1,"AWST":1,"AZOST":1,"AZT":1,"BDT":1,"BIOT":1,"BIT":1,"BOT":1,"BRT":1,"BST":1,"BTT":1,"CAT":1,"CCT":1,"CDT":1,"CEDT":1,"CEST":1,"CET":1,"CHADT":1,"CHAST":1,"CHOT":1,"ChST":1,"CHUT":1,"CIST":1,"CIT":1,"CKT":1,"CLST":1,"CLT":1,"COST":1,"COT":1,"CST":1,"CT":1,"CVT":1,"CWST":1,"CXT":1,"DAVT":1,"DDUT":1,"DFT":1,"EASST":1,"EAST":1,"EAT":1,"ECT":1,"EDT":1,"EEDT":1,"EEST":1,"EET":1,"EGST":1,"EGT":1,"EIT":1,"EST":1,"FET":1,"FJT":1,"FKST":1,"FKT":1,"FNT":1,"GALT":1,"GAMT":1,"GET":1,"GFT":1,"GILT":1,"GIT":1,"GMT":1,"GST":1,"GYT":1,"HADT":1,"HAEC":1,"HAST":1,"HKT":1,"HMT":1,"HOVT":1,"HST":1,"ICT":1,"IDT":1,"IOT":1,"IRDT":1,"IRKT":1,"IRST":1,"IST":1,"JST":1,"KGT":1,"KOST":1,"KRAT":1,"KST":1,"LHST":1,"LINT":1,"MAGT":1,"MART":1,"MAWT":1,"MDT":1,"MET":1,"MEST":1,"MHT":1,"MIST":1,"MIT":1,"MMT":1,"MSK":1,"MST":1,"MUT":1,"MVT":1,"MYT":1,"NCT":1,"NDT":1,"NFT":1,"NPT":1,"NST":1,"NT":1,"NUT":1,"NZDT":1,"NZST":1,"OMST":1,"ORAT":1,"PDT":1,"PET":1,"PETT":1,"PGT":1,"PHOT":1,"PHT":1,"PKT":1,"PMDT":1,"PMST":1,"PONT":1,"PST":1,"PYST":1,"PYT":1,"RET":1,"ROTT":1,"SAKT":1,"SAMT":1,"SAST":1,"SBT":1,"SCT":1,"SGT":1,"SLST":1,"SRT":1,"SST":1,"SYOT":1,"TAHT":1,"THA":1,"TFT":1,"TJT":1,"TKT":1,"TLT":1,"TMT":1,"TOT":1,"TVT":1,"UCT":1,"ULAT":1,"UTC":1,"UYST":1,"UYT":1,"UZT":1,"VET":1,"VLAT":1,"VOLT":1,"VOST":1,"VUT":1,"WAKT":1,"WAST":1,"WAT":1,"WEDT":1,"WEST":1,"WET":1,"WST":1,"YAKT":1,"YEKT":1,"Z":1}; return (timezones[value] === 1); }; $D.validateTimezoneOffset= function(value) { // timezones go from +14hrs to -12hrs, the +X hours are negative offsets. return (value > -841 && value < 721); }; }()); (function () { var $D = Date, $P = $D.prototype, p = function (s, l) { if (!l) { l = 2; } return ("000" + s).slice(l * -1); }; var validateConfigObject = function (obj) { var result = {}, self = this, prop, testFunc; testFunc = function (prop, func, value) { if (prop === "day") { var month = (obj.month !== undefined) ? obj.month : self.getMonth(); var year = (obj.year !== undefined) ? obj.year : self.getFullYear(); return $D[func](value, year, month); } else { return $D[func](value); } }; for (prop in obj) { if (Object.prototype.hasOwnProperty.call(obj, prop)) { var func = "validate" + prop.charAt(0).toUpperCase() + prop.slice(1); if ($D[func] && obj[prop] !== null && testFunc(prop, func, obj[prop])) { result[prop] = obj[prop]; } } } return result; }; /** * Resets the time of this Date object to 12:00 AM (00:00), which is the start of the day. * @param {Boolean} .clone() this date instance before clearing Time * @return {Date} this */ $P.clearTime = function () { this.setHours(0); this.setMinutes(0); this.setSeconds(0); this.setMilliseconds(0); return this; }; /** * Resets the time of this Date object to the current time ('now'). * @return {Date} this */ $P.setTimeToNow = function () { var n = new Date(); this.setHours(n.getHours()); this.setMinutes(n.getMinutes()); this.setSeconds(n.getSeconds()); this.setMilliseconds(n.getMilliseconds()); return this; }; /** * Returns a new Date object that is an exact date and time copy of the original instance. * @return {Date} A new Date instance */ $P.clone = function () { return new Date(this.getTime()); }; /** * Compares this instance to a Date object and returns an number indication of their relative values. * @param {Date} Date object to compare [Required] * @return {Number} -1 = this is lessthan date. 0 = values are equal. 1 = this is greaterthan date. */ $P.compareTo = function (date) { return Date.compare(this, date); }; /** * Compares this instance to another Date object and returns true if they are equal. * @param {Date} Date object to compare. If no date to compare, new Date() [now] is used. * @return {Boolean} true if dates are equal. false if they are not equal. */ $P.equals = function (date) { return Date.equals(this, (date !== undefined ? date : new Date())); }; /** * Determines if this instance is between a range of two dates or equal to either the start or end dates. * @param {Date} Start of range [Required] * @param {Date} End of range [Required] * @return {Boolean} true is this is between or equal to the start and end dates, else false */ $P.between = function (start, end) { return this.getTime() >= start.getTime() && this.getTime() <= end.getTime(); }; /** * Determines if this date occurs after the date to compare to. * @param {Date} Date object to compare. If no date to compare, new Date() ("now") is used. * @return {Boolean} true if this date instance is greater than the date to compare to (or "now"), otherwise false. */ $P.isAfter = function (date) { return this.compareTo(date || new Date()) === 1; }; /** * Determines if this date occurs before the date to compare to. * @param {Date} Date object to compare. If no date to compare, new Date() ("now") is used. * @return {Boolean} true if this date instance is less than the date to compare to (or "now"). */ $P.isBefore = function (date) { return (this.compareTo(date || new Date()) === -1); }; /** * Determines if the current Date instance occurs today. * @return {Boolean} true if this date instance is 'today', otherwise false. */ /** * Determines if the current Date instance occurs on the same Date as the supplied 'date'. * If no 'date' to compare to is provided, the current Date instance is compared to 'today'. * @param {date} Date object to compare. If no date to compare, the current Date ("now") is used. * @return {Boolean} true if this Date instance occurs on the same Day as the supplied 'date'. */ $P.isToday = $P.isSameDay = function (date) { return this.clone().clearTime().equals((date || new Date()).clone().clearTime()); }; /** * Adds the specified number of milliseconds to this instance. * @param {Number} The number of milliseconds to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addMilliseconds = function (value) { if (!value) { return this; } this.setTime(this.getTime() + value * 1); return this; }; /** * Adds the specified number of seconds to this instance. * @param {Number} The number of seconds to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addSeconds = function (value) { if (!value) { return this; } return this.addMilliseconds(value * 1000); }; /** * Adds the specified number of seconds to this instance. * @param {Number} The number of seconds to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addMinutes = function (value) { if (!value) { return this; } return this.addMilliseconds(value * 60000); // 60*1000 }; /** * Adds the specified number of hours to this instance. * @param {Number} The number of hours to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addHours = function (value) { if (!value) { return this; } return this.addMilliseconds(value * 3600000); // 60*60*1000 }; /** * Adds the specified number of days to this instance. * @param {Number} The number of days to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addDays = function (value) { if (!value) { return this; } this.setDate(this.getDate() + value * 1); return this; }; /** * Adds the specified number of weekdays (ie - not sat or sun) to this instance. * @param {Number} The number of days to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addWeekdays = function (value) { if (!value) { return this; } var day = this.getDay(); var weeks = (Math.ceil(Math.abs(value)/7)); if (day === 0 || day === 6) { if (value > 0) { this.next().monday(); this.addDays(-1); day = this.getDay(); } } if (value < 0) { while (value < 0) { this.addDays(-1); day = this.getDay(); if (day !== 0 && day !== 6) { value++; } } return this; } else if (value > 5 || (6-day) <= value) { value = value + (weeks * 2); } return this.addDays(value); }; /** * Adds the specified number of weeks to this instance. * @param {Number} The number of weeks to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addWeeks = function (value) { if (!value) { return this; } return this.addDays(value * 7); }; /** * Adds the specified number of months to this instance. * @param {Number} The number of months to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addMonths = function (value) { if (!value) { return this; } var n = this.getDate(); this.setDate(1); this.setMonth(this.getMonth() + value * 1); this.setDate(Math.min(n, $D.getDaysInMonth(this.getFullYear(), this.getMonth()))); return this; }; $P.addQuarters = function (value) { if (!value) { return this; } // note this will take you to the same point in the quarter as you are now. // i.e. - if you are 15 days into the quarter you'll be 15 days into the resulting one. // bonus: this allows adding fractional quarters return this.addMonths(value * 3); }; /** * Adds the specified number of years to this instance. * @param {Number} The number of years to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addYears = function (value) { if (!value) { return this; } return this.addMonths(value * 12); }; /** * Adds (or subtracts) to the value of the years, months, weeks, days, hours, minutes, seconds, milliseconds of the date instance using given configuration object. Positive and Negative values allowed. * Example

	Date.today().add( { days: 1, months: 1 } )

	new Date().add( { years: -1 } )
	
* @param {Object} Configuration object containing attributes (months, days, etc.) * @return {Date} this */ $P.add = function (config) { if (typeof config === "number") { this._orient = config; return this; } var x = config; if (x.day) { // If we should be a different date than today (eg: for 'tomorrow -1d', etc). // Should only effect parsing, not direct usage (eg, Finish and FinishExact) if ((x.day - this.getDate()) !== 0) { this.setDate(x.day); } } if (x.milliseconds) { this.addMilliseconds(x.milliseconds); } if (x.seconds) { this.addSeconds(x.seconds); } if (x.minutes) { this.addMinutes(x.minutes); } if (x.hours) { this.addHours(x.hours); } if (x.weeks) { this.addWeeks(x.weeks); } if (x.months) { this.addMonths(x.months); } if (x.years) { this.addYears(x.years); } if (x.days) { this.addDays(x.days); } return this; }; /** * Get the week number. Week one (1) is the week which contains the first Thursday of the year. Monday is considered the first day of the week. * The .getWeek() function does NOT convert the date to UTC. The local datetime is used. * Please use .getISOWeek() to get the week of the UTC converted date. * @return {Number} 1 to 53 */ $P.getWeek = function (utc) { // Create a copy of this date object var self, target = new Date(this.valueOf()); if (utc) { target.addMinutes(target.getTimezoneOffset()); self = target.clone(); } else { self = this; } // ISO week date weeks start on monday // so correct the day number var dayNr = (self.getDay() + 6) % 7; // ISO 8601 states that week 1 is the week // with the first thursday of that year. // Set the target date to the thursday in the target week target.setDate(target.getDate() - dayNr + 3); // Store the millisecond value of the target date var firstThursday = target.valueOf(); // Set the target to the first thursday of the year // First set the target to january first target.setMonth(0, 1); // Not a thursday? Correct the date to the next thursday if (target.getDay() !== 4) { target.setMonth(0, 1 + ((4 - target.getDay()) + 7) % 7); } // The weeknumber is the number of weeks between the // first thursday of the year and the thursday in the target week return 1 + Math.ceil((firstThursday - target) / 604800000); // 604800000 = 7 * 24 * 3600 * 1000 }; /** * Get the ISO 8601 week number. Week one ("01") is the week which contains the first Thursday of the year. Monday is considered the first day of the week. * The .getISOWeek() function does convert the date to it's UTC value. Please use .getWeek() to get the week of the local date. * @return {String} "01" to "53" */ $P.getISOWeek = function () { return p(this.getWeek(true)); }; /** * Moves the date to Monday of the week set. Week one (1) is the week which contains the first Thursday of the year. * @param {Number} A Number (1 to 53) that represents the week of the year. * @return {Date} this */ $P.setWeek = function (n) { if ((n - this.getWeek()) === 0) { if (this.getDay() !== 1) { return this.moveToDayOfWeek(1, (this.getDay() > 1 ? -1 : 1)); } else { return this; } } else { return this.moveToDayOfWeek(1, (this.getDay() > 1 ? -1 : 1)).addWeeks(n - this.getWeek()); } }; $P.setQuarter = function (qtr) { var month = Math.abs(((qtr-1) * 3) + 1); return this.setMonth(month, 1); }; $P.getQuarter = function () { return Date.getQuarter(this); }; $P.getDaysLeftInQuarter = function () { return Date.getDaysLeftInQuarter(this); }; /** * Moves the date to the next n'th occurrence of the dayOfWeek starting from the beginning of the month. The number (-1) is a magic number and will return the last occurrence of the dayOfWeek in the month. * @param {Number} The dayOfWeek to move to * @param {Number} The n'th occurrence to move to. Use (-1) to return the last occurrence in the month * @return {Date} this */ $P.moveToNthOccurrence = function (dayOfWeek, occurrence) { if (dayOfWeek === "Weekday") { if (occurrence > 0) { this.moveToFirstDayOfMonth(); if (this.is().weekday()) { occurrence -= 1; } } else if (occurrence < 0) { this.moveToLastDayOfMonth(); if (this.is().weekday()) { occurrence += 1; } } else { return this; } return this.addWeekdays(occurrence); } var shift = 0; if (occurrence > 0) { shift = occurrence - 1; } else if (occurrence === -1) { this.moveToLastDayOfMonth(); if (this.getDay() !== dayOfWeek) { this.moveToDayOfWeek(dayOfWeek, -1); } return this; } return this.moveToFirstDayOfMonth().addDays(-1).moveToDayOfWeek(dayOfWeek, +1).addWeeks(shift); }; var moveToN = function (getFunc, addFunc, nVal) { return function (value, orient) { var diff = (value - this[getFunc]() + nVal * (orient || +1)) % nVal; return this[addFunc]((diff === 0) ? diff += nVal * (orient || +1) : diff); }; }; /** * Move to the next or last dayOfWeek based on the orient value. * @param {Number} The dayOfWeek to move to * @param {Number} Forward (+1) or Back (-1). Defaults to +1. [Optional] * @return {Date} this */ $P.moveToDayOfWeek = moveToN("getDay", "addDays", 7); /** * Move to the next or last month based on the orient value. * @param {Number} The month to move to. 0 = January, 11 = December * @param {Number} Forward (+1) or Back (-1). Defaults to +1. [Optional] * @return {Date} this */ $P.moveToMonth = moveToN("getMonth", "addMonths", 12); /** * Get the Ordinate of the current day ("th", "st", "rd"). * @return {String} */ $P.getOrdinate = function () { var num = this.getDate(); return ord(num); }; /** * Get the Ordinal day (numeric day number) of the year, adjusted for leap year. * @return {Number} 1 through 365 (366 in leap years) */ $P.getOrdinalNumber = function () { return Math.ceil((this.clone().clearTime() - new Date(this.getFullYear(), 0, 1)) / 86400000) + 1; }; /** * Get the time zone abbreviation of the current date. * @return {String} The abbreviated time zone name (e.g. "EST") */ $P.getTimezone = function () { return $D.getTimezoneAbbreviation(this.getUTCOffset(), this.isDaylightSavingTime()); }; $P.setTimezoneOffset = function (offset) { var here = this.getTimezoneOffset(), there = Number(offset) * -6 / 10; return (there || there === 0) ? this.addMinutes(there - here) : this; }; $P.setTimezone = function (offset) { return this.setTimezoneOffset($D.getTimezoneOffset(offset)); }; /** * Indicates whether Daylight Saving Time is observed in the current time zone. * @return {Boolean} true|false */ $P.hasDaylightSavingTime = function () { return (Date.today().set({month: 0, day: 1}).getTimezoneOffset() !== Date.today().set({month: 6, day: 1}).getTimezoneOffset()); }; /** * Indicates whether this Date instance is within the Daylight Saving Time range for the current time zone. * @return {Boolean} true|false */ $P.isDaylightSavingTime = function () { return Date.today().set({month: 0, day: 1}).getTimezoneOffset() !== this.getTimezoneOffset(); }; /** * Get the offset from UTC of the current date. * @return {String} The 4-character offset string prefixed with + or - (e.g. "-0500") */ $P.getUTCOffset = function (offset) { var n = (offset || this.getTimezoneOffset()) * -10 / 6, r; if (n < 0) { r = (n - 10000).toString(); return r.charAt(0) + r.substr(2); } else { r = (n + 10000).toString(); return "+" + r.substr(1); } }; /** * Returns the number of milliseconds between this date and date. * @param {Date} Defaults to now * @return {Number} The diff in milliseconds */ $P.getElapsed = function (date) { return (date || new Date()) - this; }; /** * Set the value of year, month, day, hour, minute, second, millisecond of date instance using given configuration object. * Example

	Date.today().set( { day: 20, month: 1 } )

	new Date().set( { millisecond: 0 } )
	
* * @param {Object} Configuration object containing attributes (month, day, etc.) * @return {Date} this */ $P.set = function (config) { config = validateConfigObject.call(this, config); var key; for (key in config) { if (Object.prototype.hasOwnProperty.call(config, key)) { var name = key.charAt(0).toUpperCase() + key.slice(1); var addFunc, getFunc; if (key !== "week" && key !== "month" && key !== "timezone" && key !== "timezoneOffset") { name += "s"; } addFunc = "add" + name; getFunc = "get" + name; if (key === "month") { addFunc = addFunc + "s"; } else if (key === "year"){ getFunc = "getFullYear"; } if (key !== "day" && key !== "timezone" && key !== "timezoneOffset" && key !== "week" && key !== "hour") { this[addFunc](config[key] - this[getFunc]()); } else if ( key === "timezone"|| key === "timezoneOffset" || key === "week" || key === "hour") { this["set"+name](config[key]); } } } // day has to go last because you can't validate the day without first knowing the month if (config.day) { this.addDays(config.day - this.getDate()); } return this; }; /** * Moves the date to the first day of the month. * @return {Date} this */ $P.moveToFirstDayOfMonth = function () { return this.set({ day: 1 }); }; /** * Moves the date to the last day of the month. * @return {Date} this */ $P.moveToLastDayOfMonth = function () { return this.set({ day: $D.getDaysInMonth(this.getFullYear(), this.getMonth())}); }; /** * Converts the value of the current Date object to its equivalent string representation. * Format Specifiers * CUSTOM DATE AND TIME FORMAT STRINGS * Format Description Example * ------ --------------------------------------------------------------------------- ----------------------- * s The seconds of the minute between 0-59. "0" to "59" * ss The seconds of the minute with leading zero if required. "00" to "59" * * m The minute of the hour between 0-59. "0" or "59" * mm The minute of the hour with leading zero if required. "00" or "59" * * h The hour of the day between 1-12. "1" to "12" * hh The hour of the day with leading zero if required. "01" to "12" * * H The hour of the day between 0-23. "0" to "23" * HH The hour of the day with leading zero if required. "00" to "23" * * d The day of the month between 1 and 31. "1" to "31" * dd The day of the month with leading zero if required. "01" to "31" * ddd Abbreviated day name. Date.CultureInfo.abbreviatedDayNames. "Mon" to "Sun" * dddd The full day name. Date.CultureInfo.dayNames. "Monday" to "Sunday" * * M The month of the year between 1-12. "1" to "12" * MM The month of the year with leading zero if required. "01" to "12" * MMM Abbreviated month name. Date.CultureInfo.abbreviatedMonthNames. "Jan" to "Dec" * MMMM The full month name. Date.CultureInfo.monthNames. "January" to "December" * * yy The year as a two-digit number. "99" or "08" * yyyy The full four digit year. "1999" or "2008" * * t Displays the first character of the A.M./P.M. designator. "A" or "P" * Date.CultureInfo.amDesignator or Date.CultureInfo.pmDesignator * tt Displays the A.M./P.M. designator. "AM" or "PM" * Date.CultureInfo.amDesignator or Date.CultureInfo.pmDesignator * * S The ordinal suffix ("st, "nd", "rd" or "th") of the current day. "st, "nd", "rd" or "th" * * STANDARD DATE AND TIME FORMAT STRINGS * Format Description Example *------ --------------------------------------------------------------------------- ----------------------- * d The CultureInfo shortDate Format Pattern "M/d/yyyy" * D The CultureInfo longDate Format Pattern "dddd, MMMM dd, yyyy" * F The CultureInfo fullDateTime Format Pattern "dddd, MMMM dd, yyyy h:mm:ss tt" * m The CultureInfo monthDay Format Pattern "MMMM dd" * r The CultureInfo rfc1123 Format Pattern "ddd, dd MMM yyyy HH:mm:ss GMT" * s The CultureInfo sortableDateTime Format Pattern "yyyy-MM-ddTHH:mm:ss" * t The CultureInfo shortTime Format Pattern "h:mm tt" * T The CultureInfo longTime Format Pattern "h:mm:ss tt" * u The CultureInfo universalSortableDateTime Format Pattern "yyyy-MM-dd HH:mm:ssZ" * y The CultureInfo yearMonth Format Pattern "MMMM, yyyy" * * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @return {String} A string representation of the current Date object. */ var ord = function (n) { switch (n * 1) { case 1: case 21: case 31: return "st"; case 2: case 22: return "nd"; case 3: case 23: return "rd"; default: return "th"; } }; var parseStandardFormats = function (format) { var y, c = Date.CultureInfo.formatPatterns; switch (format) { case "d": return this.toString(c.shortDate); case "D": return this.toString(c.longDate); case "F": return this.toString(c.fullDateTime); case "m": return this.toString(c.monthDay); case "r": case "R": y = this.clone().addMinutes(this.getTimezoneOffset()); return y.toString(c.rfc1123) + " GMT"; case "s": return this.toString(c.sortableDateTime); case "t": return this.toString(c.shortTime); case "T": return this.toString(c.longTime); case "u": y = this.clone().addMinutes(this.getTimezoneOffset()); return y.toString(c.universalSortableDateTime); case "y": return this.toString(c.yearMonth); default: return false; } }; var parseFormatStringsClosure = function (context) { return function (m) { if (m.charAt(0) === "\\") { return m.replace("\\", ""); } switch (m) { case "hh": return p(context.getHours() < 13 ? (context.getHours() === 0 ? 12 : context.getHours()) : (context.getHours() - 12)); case "h": return context.getHours() < 13 ? (context.getHours() === 0 ? 12 : context.getHours()) : (context.getHours() - 12); case "HH": return p(context.getHours()); case "H": return context.getHours(); case "mm": return p(context.getMinutes()); case "m": return context.getMinutes(); case "ss": return p(context.getSeconds()); case "s": return context.getSeconds(); case "yyyy": return p(context.getFullYear(), 4); case "yy": return p(context.getFullYear()); case "y": return context.getFullYear(); case "E": case "dddd": return Date.CultureInfo.dayNames[context.getDay()]; case "ddd": return Date.CultureInfo.abbreviatedDayNames[context.getDay()]; case "dd": return p(context.getDate()); case "d": return context.getDate(); case "MMMM": return Date.CultureInfo.monthNames[context.getMonth()]; case "MMM": return Date.CultureInfo.abbreviatedMonthNames[context.getMonth()]; case "MM": return p((context.getMonth() + 1)); case "M": return context.getMonth() + 1; case "t": return context.getHours() < 12 ? Date.CultureInfo.amDesignator.substring(0, 1) : Date.CultureInfo.pmDesignator.substring(0, 1); case "tt": return context.getHours() < 12 ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator; case "S": return ord(context.getDate()); case "W": return context.getWeek(); case "WW": return context.getISOWeek(); case "Q": return "Q" + context.getQuarter(); case "q": return String(context.getQuarter()); case "z": return context.getTimezone(); case "Z": case "X": return Date.getTimezoneOffset(context.getTimezone()); case "ZZ": // Timezone offset in seconds return context.getTimezoneOffset() * -60; case "u": return context.getDay(); case "L": return ($D.isLeapYear(context.getFullYear())) ? 1 : 0; case "B": // Swatch Internet Time (.beats) return "@"+((context.getUTCSeconds() + (context.getUTCMinutes()*60) + ((context.getUTCHours()+1)*3600))/86.4); default: return m; } }; }; $P.toString = function (format, ignoreStandards) { // Standard Date and Time Format Strings. Formats pulled from CultureInfo file and // may vary by culture. if (!ignoreStandards && format && format.length === 1) { output = parseStandardFormats.call(this, format); if (output) { return output; } } var parseFormatStrings = parseFormatStringsClosure(this); return format ? format.replace(/((\\)?(dd?d?d?|MM?M?M?|yy?y?y?|hh?|HH?|mm?|ss?|tt?|S|q|Q|WW?W?W?)(?![^\[]*\]))/g, parseFormatStrings).replace(/\[|\]/g, "") : this._toString(); }; }()); /************************************************************* * SugarPak - Domain Specific Language - Syntactical Sugar * *************************************************************/ (function () { var $D = Date, $P = $D.prototype, $N = Number.prototype; // private $P._orient = +1; // private $P._nth = null; // private $P._is = false; // private $P._same = false; // private $P._isSecond = false; // private $N._dateElement = "days"; /** * Moves the date to the next instance of a date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.today().next().friday();
	Date.today().next().fri();
	Date.today().next().march();
	Date.today().next().mar();
	Date.today().next().week();
	
* * @return {Date} date */ $P.next = function () { this._move = true; this._orient = +1; return this; }; /** * Creates a new Date (Date.today()) and moves the date to the next instance of the date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.next().friday();
	Date.next().fri();
	Date.next().march();
	Date.next().mar();
	Date.next().week();
	
* * @return {Date} date */ $D.next = function () { return $D.today().next(); }; /** * Moves the date to the previous instance of a date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.today().last().friday();
	Date.today().last().fri();
	Date.today().last().march();
	Date.today().last().mar();
	Date.today().last().week();
	
* * @return {Date} date */ $P.last = $P.prev = $P.previous = function () { this._move = true; this._orient = -1; return this; }; /** * Creates a new Date (Date.today()) and moves the date to the previous instance of the date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.last().friday();
	Date.last().fri();
	Date.previous().march();
	Date.prev().mar();
	Date.last().week();
	
* * @return {Date} date */ $D.last = $D.prev = $D.previous = function () { return $D.today().last(); }; /** * Performs a equality check when followed by either a month name, day name or .weekday() function. * Example

	Date.today().is().friday(); // true|false
	Date.today().is().fri();
	Date.today().is().march();
	Date.today().is().mar();
	
* * @return {Boolean} true|false */ $P.is = function () { this._is = true; return this; }; /** * Determines if two date objects occur on/in exactly the same instance of the subsequent date part function. * The function .same() must be followed by a date part function (example: .day(), .month(), .year(), etc). * * An optional Date can be passed in the date part function. If now date is passed as a parameter, 'Now' is used. * * The following example demonstrates how to determine if two dates fall on the exact same day. * * Example

	var d1 = Date.today(); // today at 00:00
	var d2 = new Date();   // exactly now.

	// Do they occur on the same day?
	d1.same().day(d2); // true
	
	// Do they occur on the same hour?
	d1.same().hour(d2); // false, unless d2 hour is '00' (midnight).
	
	// What if it's the same day, but one year apart?
	var nextYear = Date.today().add(1).year();

	d1.same().day(nextYear); // false, because the dates must occur on the exact same day. 
	
* * Scenario: Determine if a given date occurs during some week period 2 months from now. * * Example

	var future = Date.today().add(2).months();
	return someDate.same().week(future); // true|false;
	
* * @return {Boolean} true|false */ $P.same = function () { this._same = true; this._isSecond = false; return this; }; /** * Determines if the current date/time occurs during Today. Must be preceded by the .is() function. * Example

	someDate.is().today();    // true|false
	new Date().is().today();  // true
	Date.today().is().today();// true
	Date.today().add(-1).day().is().today(); // false
	
* * @return {Boolean} true|false */ $P.today = function () { return this.same().day(); }; /** * Determines if the current date is a weekday. This function must be preceded by the .is() function. * Example

	Date.today().is().weekday(); // true|false
	
* * @return {Boolean} true|false */ $P.weekday = function () { if (this._nth) { return df("Weekday").call(this); } if (this._move) { return this.addWeekdays(this._orient); } if (this._is) { this._is = false; return (!this.is().sat() && !this.is().sun()); } return false; }; /** * Determines if the current date is on the weekend. This function must be preceded by the .is() function. * Example

	Date.today().is().weekend(); // true|false
	
* * @return {Boolean} true|false */ $P.weekend = function () { if (this._is) { this._is = false; return (this.is().sat() || this.is().sun()); } return false; }; /** * Sets the Time of the current Date instance. A string "6:15 pm" or config object {hour:18, minute:15} are accepted. * Example

	// Set time to 6:15pm with a String
	Date.today().at("6:15pm");

	// Set time to 6:15pm with a config object
	Date.today().at({hour:18, minute:15});
	
* * @return {Date} date */ $P.at = function (time) { return (typeof time === "string") ? $D.parse(this.toString("d") + " " + time) : this.set(time); }; /** * Creates a new Date() and adds this (Number) to the date based on the preceding date element function (eg. second|minute|hour|day|month|year). * Example

	// Undeclared Numbers must be wrapped with parentheses. Requirment of JavaScript.
	(3).days().fromNow();
	(6).months().fromNow();

	// Declared Number variables do not require parentheses. 
	var n = 6;
	n.months().fromNow();
	
* * @return {Date} A new Date instance */ $N.fromNow = $N.after = function (date) { var c = {}; c[this._dateElement] = this; return ((!date) ? new Date() : date.clone()).add(c); }; /** * Creates a new Date() and subtract this (Number) from the date based on the preceding date element function (eg. second|minute|hour|day|month|year). * Example

	// Undeclared Numbers must be wrapped with parentheses. Requirment of JavaScript.
	(3).days().ago();
	(6).months().ago();

	// Declared Number variables do not require parentheses. 
	var n = 6;
	n.months().ago();
	
* * @return {Date} A new Date instance */ $N.ago = $N.before = function (date) { var c = {}, s = (this._dateElement[this._dateElement.length-1] !== "s") ? this._dateElement + "s" : this._dateElement; c[s] = this * -1; return ((!date) ? new Date() : date.clone()).add(c); }; // Do NOT modify the following string tokens. These tokens are used to build dynamic functions. // All culture-specific strings can be found in the CultureInfo files. var dx = ("sunday monday tuesday wednesday thursday friday saturday").split(/\s/), mx = ("january february march april may june july august september october november december").split(/\s/), px = ("Millisecond Second Minute Hour Day Week Month Year Quarter Weekday").split(/\s/), pxf = ("Milliseconds Seconds Minutes Hours Date Week Month FullYear Quarter").split(/\s/), nth = ("final first second third fourth fifth").split(/\s/), de; /** * Returns an object literal of all the date parts. * Example

	var o = new Date().toObject();
	
	// { year: 2008, month: 4, week: 20, day: 13, hour: 18, minute: 9, second: 32, millisecond: 812 }
	
	// The object properties can be referenced directly from the object.
	
	alert(o.day);  // alerts "13"
	alert(o.year); // alerts "2008"
	
* * @return {Date} An object literal representing the original date object. */ $P.toObject = function () { var o = {}; for (var i = 0; i < px.length; i++) { if (this["get" + pxf[i]]) { o[px[i].toLowerCase()] = this["get" + pxf[i]](); } } return o; }; /** * Returns a date created from an object literal. Ignores the .week property if set in the config. * Example

	var o = new Date().toObject();
	
	return Date.fromObject(o); // will return the same date. 

	var o2 = {month: 1, day: 20, hour: 18}; // birthday party!
	Date.fromObject(o2);
	
* * @return {Date} An object literal representing the original date object. */ $D.fromObject = function(config) { config.week = null; return Date.today().set(config); }; // Create day name functions and abbreviated day name functions (eg. monday(), friday(), fri()). var df = function (n) { return function () { if (this._is) { this._is = false; return this.getDay() === n; } if (this._move) { this._move = null; } if (this._nth !== null) { // If the .second() function was called earlier, remove the _orient // from the date, and then continue. // This is required because 'second' can be used in two different context. // // Example // // Date.today().add(1).second(); // Date.march().second().monday(); // // Things get crazy with the following... // Date.march().add(1).second().second().monday(); // but it works!! // if (this._isSecond) { this.addSeconds(this._orient * -1); } // make sure we reset _isSecond this._isSecond = false; var ntemp = this._nth; this._nth = null; var temp = this.clone().moveToLastDayOfMonth(); this.moveToNthOccurrence(n, ntemp); if (this > temp) { throw new RangeError($D.getDayName(n) + " does not occur " + ntemp + " times in the month of " + $D.getMonthName(temp.getMonth()) + " " + temp.getFullYear() + "."); } return this; } return this.moveToDayOfWeek(n, this._orient); }; }; var sdf = function (n) { return function () { var t = $D.today(), shift = n - t.getDay(); if (n === 0 && Date.CultureInfo.firstDayOfWeek === 1 && t.getDay() !== 0) { shift = shift + 7; } return t.addDays(shift); }; }; // Create month name functions and abbreviated month name functions (eg. january(), march(), mar()). var month_instance_functions = function (n) { return function () { if (this._is) { this._is = false; return this.getMonth() === n; } return this.moveToMonth(n, this._orient); }; }; var month_static_functions = function (n) { return function () { return $D.today().set({ month: n, day: 1 }); }; }; var processTerms = function (names, staticFunc, instanceFunc) { for (var i = 0; i < names.length; i++) { // Create constant static Name variables. $D[names[i].toUpperCase()] = $D[names[i].toUpperCase().substring(0, 3)] = i; // Create Name functions. $D[names[i]] = $D[names[i].substring(0, 3)] = staticFunc(i); // Create Name instance functions. $P[names[i]] = $P[names[i].substring(0, 3)] = instanceFunc(i); } }; processTerms(dx, sdf, df); processTerms(mx, month_static_functions, month_instance_functions); // Create date element functions and plural date element functions used with Date (eg. day(), days(), months()). var ef = function (j) { return function () { // if the .second() function was called earlier, the _orient // has alread been added. Just return this and reset _isSecond. if (this._isSecond) { this._isSecond = false; return this; } if (this._same) { this._same = this._is = false; var o1 = this.toObject(), o2 = (arguments[0] || new Date()).toObject(), v = "", k = j.toLowerCase(); // the substr trick with -1 doesn't work in IE8 or less k = (k[k.length-1] === "s") ? k.substring(0,k.length-1) : k; for (var m = (px.length - 1); m > -1; m--) { v = px[m].toLowerCase(); if (o1[v] !== o2[v]) { return false; } if (k === v) { break; } } return true; } if (j.substring(j.length - 1) !== "s") { j += "s"; } if (this._move) { this._move = null; } return this["add" + j](this._orient); }; }; var nf = function (n) { return function () { this._dateElement = n; return this; }; }; for (var k = 0; k < px.length; k++) { de = px[k].toLowerCase(); if(de !== "weekday") { // Create date element functions and plural date element functions used with Date (eg. day(), days(), months()). $P[de] = $P[de + "s"] = ef(px[k]); // Create date element functions and plural date element functions used with Number (eg. day(), days(), months()). $N[de] = $N[de + "s"] = nf(de + "s"); } } $P._ss = ef("Second"); var nthfn = function (n) { return function (dayOfWeek) { if (this._same) { return this._ss(arguments[0]); } if (dayOfWeek || dayOfWeek === 0) { return this.moveToNthOccurrence(dayOfWeek, n); } this._nth = n; // if the operator is 'second' add the _orient, then deal with it later... if (n === 2 && (dayOfWeek === undefined || dayOfWeek === null)) { this._isSecond = true; return this.addSeconds(this._orient); } return this; }; }; for (var l = 0; l < nth.length; l++) { $P[nth[l]] = (l === 0) ? nthfn(-1) : nthfn(l); } }()); (function () { "use strict"; Date.Parsing = { Exception: function (s) { this.message = "Parse error at '" + s.substring(0, 10) + " ...'"; } }; var $P = Date.Parsing; var dayOffsets = { standard: [0,31,59,90,120,151,181,212,243,273,304,334], leap: [0,31,60,91,121,152,182,213,244,274,305,335] }; $P.isLeapYear = function(year) { return ((year % 4 === 0) && (year % 100 !== 0)) || (year % 400 === 0); }; var utils = { multiReplace : function (str, hash ) { var key; for (key in hash) { if (Object.prototype.hasOwnProperty.call(hash, key)) { var regex; if (typeof hash[key] === "function") { } else { regex = (hash[key] instanceof RegExp) ? hash[key] : new RegExp(hash[key], "g"); } str = str.replace(regex, key); } } return str; }, getDayOfYearFromWeek : function (obj) { var d, jan4, offset; obj.weekDay = (!obj.weekDay && obj.weekDay !== 0) ? 1 : obj.weekDay; d = new Date(obj.year, 0, 4); jan4 = d.getDay() === 0 ? 7 : d.getDay(); // JS is 0 indexed on Sunday. offset = jan4+3; obj.dayOfYear = ((obj.week * 7) + (obj.weekDay === 0 ? 7 : obj.weekDay))-offset; return obj; }, getDayOfYear : function (obj, dayOffset) { if (!obj.dayOfYear) { obj = utils.getDayOfYearFromWeek(obj); } for (var i=0;i <= dayOffset.length;i++) { if (obj.dayOfYear < dayOffset[i] || i === dayOffset.length) { obj.day = obj.day ? obj.day : (obj.dayOfYear - dayOffset[i-1]); break; } else { obj.month = i; } } return obj; }, adjustForTimeZone : function (obj, date) { var offset; if (obj.zone.toUpperCase() === "Z" || (obj.zone_hours === 0 && obj.zone_minutes === 0)) { // it's UTC/GML so work out the current timeszone offset offset = -date.getTimezoneOffset(); } else { offset = (obj.zone_hours*60) + (obj.zone_minutes || 0); if (obj.zone_sign === "+") { offset *= -1; } offset -= date.getTimezoneOffset(); } date.setMinutes(date.getMinutes()+offset); return date; }, setDefaults : function (obj) { obj.year = obj.year || Date.today().getFullYear(); obj.hours = obj.hours || 0; obj.minutes = obj.minutes || 0; obj.seconds = obj.seconds || 0; obj.milliseconds = obj.milliseconds || 0; if (!(!obj.month && (obj.week || obj.dayOfYear))) { // if we have a month, or if we don't but don't have the day calculation data obj.month = obj.month || 0; obj.day = obj.day || 1; } return obj; }, dataNum: function (data, mod, explict, postProcess) { var dataNum = data*1; if (mod) { if (postProcess) { return data ? mod(data)*1 : data; } else { return data ? mod(dataNum) : data; } } else if (!explict){ return data ? dataNum : data; } else { return (data && typeof data !== "undefined") ? dataNum : data; } }, timeDataProcess: function (obj) { var timeObj = {}; for (var x in obj.data) { if (obj.data.hasOwnProperty(x)) { timeObj[x] = obj.ignore[x] ? obj.data[x] : utils.dataNum(obj.data[x], obj.mods[x], obj.explict[x], obj.postProcess[x]); } } if (obj.data.secmins) { obj.data.secmins = obj.data.secmins.replace(",", ".") * 60; if (!timeObj.minutes) { timeObj.minutes = obj.data.secmins; } else if (!timeObj.seconds) { timeObj.seconds = obj.data.secmins; } delete obj.secmins; } return timeObj; }, buildTimeObjectFromData: function (data) { var time = utils.timeDataProcess({ data: { year : data[1], month : data[5], day : data[7], week : data[8], dayOfYear : data[10], hours : data[15], zone_hours : data[23], zone_minutes : data[24], zone : data[21], zone_sign : data[22], weekDay : data[9], minutes: data[16], seconds: data[19], milliseconds: data[20], secmins: data[18] }, mods: { month: function(data) { return data-1; }, weekDay: function (data) { data = Math.abs(data); return (data === 7 ? 0 : data); }, minutes: function (data) { return data.replace(":",""); }, seconds: function (data) { return Math.floor( (data.replace(":","").replace(",","."))*1 ); }, milliseconds: function (data) { return (data.replace(",",".")*1000); } }, postProcess: { minutes: true, seconds: true, milliseconds: true }, explict: { zone_hours: true, zone_minutes: true }, ignore: { zone: true, zone_sign: true, secmins: true } }); return time; }, addToHash: function (hash, keys, data) { keys = keys; data = data; var len = keys.length; for (var i = 0; i < len; i++) { hash[keys[i]] = data[i]; } return hash; }, combineRegex: function (r1, r2) { return new RegExp("(("+r1.source+")\\s("+r2.source+"))"); }, getDateNthString: function(add, last, inc){ if (add) { return Date.today().addDays(inc).toString("d"); } else if (last) { return Date.today().last()[inc]().toString("d"); } }, buildRegexData: function (array) { var arr = []; var len = array.length; for (var i=0; i < len; i++) { if (Object.prototype.toString.call(array[i]) === '[object Array]') { // oldIE compat version of Array.isArray arr.push(this.combineRegex(array[i][0], array[i][1])); } else { arr.push(array[i]); } } return arr; } }; $P.processTimeObject = function (obj) { var date, dayOffset; utils.setDefaults(obj); dayOffset = ($P.isLeapYear(obj.year)) ? dayOffsets.leap : dayOffsets.standard; if (!obj.month && (obj.week || obj.dayOfYear)) { utils.getDayOfYear(obj, dayOffset); } else { obj.dayOfYear = dayOffset[obj.month] + obj.day; } date = new Date(obj.year, obj.month, obj.day, obj.hours, obj.minutes, obj.seconds, obj.milliseconds); if (obj.zone) { utils.adjustForTimeZone(obj, date); // adjust (and calculate) for timezone } return date; }; $P.ISO = { regex : /^([\+-]?\d{4}(?!\d{2}\b))((-?)((0[1-9]|1[0-2])(\3([12]\d|0[1-9]|3[01]))?|W([0-4]\d|5[0-3])(-?[1-7])?|(00[1-9]|0[1-9]\d|[12]\d{2}|3([0-5]\d|6[1-6])))([T\s]((([01]\d|2[0-4])((:?)[0-5]\d)?|24\:?00)([\.,]\d+(?!:))?)?(\17[0-5]\d([\.,]\d+)?)?\s?([zZ]|([\+-])([01]\d|2[0-3]):?([0-5]\d)?)?)?)?$/, parse : function (s) { var time, data = s.match(this.regex); if (!data || !data.length) { return null; } time = utils.buildTimeObjectFromData(data); if (!time.year || (!time.year && (!time.month && !time.day) && (!time.week && !time.dayOfYear)) ) { return null; } return $P.processTimeObject(time); } }; $P.Numeric = { isNumeric: function (e){return!isNaN(parseFloat(e))&&isFinite(e);}, regex: /\b([0-1]?[0-9])([0-3]?[0-9])([0-2]?[0-9]?[0-9][0-9])\b/i, parse: function (s) { var data, i, time = {}, order = Date.CultureInfo.dateElementOrder.split(""); if (!(this.isNumeric(s)) || // if it's non-numeric OR (s[0] === "+" && s[0] === "-")) { // It's an arithmatic string (eg +/-1000) return null; } if (s.length < 5 && s.indexOf(".") < 0 && s.indexOf("/") < 0) { // assume it's just a year. time.year = s; return $P.processTimeObject(time); } data = s.match(this.regex); if (!data || !data.length) { return null; } for (i=0; i < order.length; i++) { switch(order[i]) { case "d": time.day = data[i+1]; break; case "m": time.month = (data[i+1]-1); break; case "y": time.year = data[i+1]; break; } } return $P.processTimeObject(time); } }; $P.Normalizer = { regexData: function () { var $R = Date.CultureInfo.regexPatterns; return utils.buildRegexData([ $R.tomorrow, $R.yesterday, [$R.past, $R.mon], [$R.past, $R.tue], [$R.past, $R.wed], [$R.past, $R.thu], [$R.past, $R.fri], [$R.past, $R.sat], [$R.past, $R.sun] ]); }, basicReplaceHash : function() { var $R = Date.CultureInfo.regexPatterns; return { "January": $R.jan.source, "February": $R.feb, "March": $R.mar, "April": $R.apr, "May": $R.may, "June": $R.jun, "July": $R.jul, "August": $R.aug, "September": $R.sep, "October": $R.oct, "November": $R.nov, "December": $R.dec, "": /\bat\b/gi, " ": /\s{2,}/, "am": $R.inTheMorning, "9am": $R.thisMorning, "pm": $R.inTheEvening, "7pm":$R.thisEvening }; }, keys : function(){ return [ utils.getDateNthString(true, false, 1), // tomorrow utils.getDateNthString(true, false, -1), // yesterday utils.getDateNthString(false, true, "monday"), //last mon utils.getDateNthString(false, true, "tuesday"), //last tues utils.getDateNthString(false, true, "wednesday"), //last wed utils.getDateNthString(false, true, "thursday"), //last thurs utils.getDateNthString(false, true, "friday"), //last fri utils.getDateNthString(false, true, "saturday"), //last sat utils.getDateNthString(false, true, "sunday") //last sun ]; }, buildRegexFunctions: function () { var $R = Date.CultureInfo.regexPatterns; var __ = Date.i18n.__; var tomorrowRE = new RegExp("(\\b\\d\\d?("+__("AM")+"|"+__("PM")+")? )("+$R.tomorrow.source.slice(1)+")", "i"); // adapted tomorrow regex for AM PM relative dates var todayRE = new RegExp($R.today.source + "(?!\\s*([+-]))\\b"); // today, but excludes the math operators (eg "today + 2h") this.replaceFuncs = [ [todayRE, function (full) { return (full.length > 1) ? Date.today().toString("d") : full; }], [tomorrowRE, function(full, m1) { var t = Date.today().addDays(1).toString("d"); return (t + " " + m1); }], [$R.amThisMorning, function(str, am){return am;}], [$R.pmThisEvening, function(str, pm){return pm;}] ]; }, buildReplaceData: function () { this.buildRegexFunctions(); this.replaceHash = utils.addToHash(this.basicReplaceHash(), this.keys(), this.regexData()); }, stringReplaceFuncs: function (s) { for (var i=0; i < this.replaceFuncs.length; i++) { s = s.replace(this.replaceFuncs[i][0], this.replaceFuncs[i][1]); } return s; }, parse: function (s) { s = this.stringReplaceFuncs(s); s = utils.multiReplace(s, this.replaceHash); try { var n = s.split(/([\s\-\.\,\/\x27]+)/); if (n.length === 3 && $P.Numeric.isNumeric(n[0]) && $P.Numeric.isNumeric(n[2]) && (n[2].length >= 4)) { // ok, so we're dealing with x/year. But that's not a full date. // This fixes wonky dateElementOrder parsing when set to dmy order. if (Date.CultureInfo.dateElementOrder[0] === "d") { s = "1/" + n[0] + "/" + n[2]; // set to 1st of month and normalize the seperator } } } catch (e) {} return s; } }; $P.Normalizer.buildReplaceData(); }()); (function () { var $P = Date.Parsing; var _ = $P.Operators = { // // Tokenizers // rtoken: function (r) { // regex token return function (s) { var mx = s.match(r); if (mx) { return ([ mx[0], s.substring(mx[0].length) ]); } else { throw new $P.Exception(s); } }; }, token: function () { // whitespace-eating token return function (s) { return _.rtoken(new RegExp("^\\s*" + s + "\\s*"))(s); }; }, stoken: function (s) { // string token return _.rtoken(new RegExp("^" + s)); }, // Atomic Operators until: function (p) { return function (s) { var qx = [], rx = null; while (s.length) { try { rx = p.call(this, s); } catch (e) { qx.push(rx[0]); s = rx[1]; continue; } break; } return [ qx, s ]; }; }, many: function (p) { return function (s) { var rx = [], r = null; while (s.length) { try { r = p.call(this, s); } catch (e) { return [ rx, s ]; } rx.push(r[0]); s = r[1]; } return [ rx, s ]; }; }, // generator operators -- see below optional: function (p) { return function (s) { var r = null; try { r = p.call(this, s); } catch (e) { return [ null, s ]; } return [ r[0], r[1] ]; }; }, not: function (p) { return function (s) { try { p.call(this, s); } catch (e) { return [null, s]; } throw new $P.Exception(s); }; }, ignore: function (p) { return p ? function (s) { var r = null; r = p.call(this, s); return [null, r[1]]; } : null; }, product: function () { var px = arguments[0], qx = Array.prototype.slice.call(arguments, 1), rx = []; for (var i = 0 ; i < px.length ; i++) { rx.push(_.each(px[i], qx)); } return rx; }, cache: function (rule) { var cache = {}, cache_length = 0, cache_keys = [], CACHE_MAX = Date.Config.CACHE_MAX || 100000, r = null; var cacheCheck = function () { if (cache_length === CACHE_MAX) { // kill several keys, don't want to have to do this all the time... for (var i=0; i < 10; i++) { var key = cache_keys.shift(); if (key) { delete cache[key]; cache_length--; } } } }; return function (s) { cacheCheck(); try { r = cache[s] = (cache[s] || rule.call(this, s)); } catch (e) { r = cache[s] = e; } cache_length++; cache_keys.push(s); if (r instanceof $P.Exception) { throw r; } else { return r; } }; }, // vector operators -- see below any: function () { var px = arguments; return function (s) { var r = null; for (var i = 0; i < px.length; i++) { if (px[i] == null) { continue; } try { r = (px[i].call(this, s)); } catch (e) { r = null; } if (r) { return r; } } throw new $P.Exception(s); }; }, each: function () { var px = arguments; return function (s) { var rx = [], r = null; for (var i = 0; i < px.length ; i++) { if (px[i] == null) { continue; } try { r = (px[i].call(this, s)); } catch (e) { throw new $P.Exception(s); } rx.push(r[0]); s = r[1]; } return [ rx, s]; }; }, all: function () { var px = arguments, _ = _; return _.each(_.optional(px)); }, // delimited operators sequence: function (px, d, c) { d = d || _.rtoken(/^\s*/); c = c || null; if (px.length === 1) { return px[0]; } return function (s) { var r = null, q = null; var rx = []; for (var i = 0; i < px.length ; i++) { try { r = px[i].call(this, s); } catch (e) { break; } rx.push(r[0]); try { q = d.call(this, r[1]); } catch (ex) { q = null; break; } s = q[1]; } if (!r) { throw new $P.Exception(s); } if (q) { throw new $P.Exception(q[1]); } if (c) { try { r = c.call(this, r[1]); } catch (ey) { throw new $P.Exception(r[1]); } } return [ rx, (r?r[1]:s) ]; }; }, // // Composite Operators // between: function (d1, p, d2) { d2 = d2 || d1; var _fn = _.each(_.ignore(d1), p, _.ignore(d2)); return function (s) { var rx = _fn.call(this, s); return [[rx[0][0], r[0][2]], rx[1]]; }; }, list: function (p, d, c) { d = d || _.rtoken(/^\s*/); c = c || null; return (p instanceof Array ? _.each(_.product(p.slice(0, -1), _.ignore(d)), p.slice(-1), _.ignore(c)) : _.each(_.many(_.each(p, _.ignore(d))), px, _.ignore(c))); }, set: function (px, d, c) { d = d || _.rtoken(/^\s*/); c = c || null; return function (s) { // r is the current match, best the current 'best' match // which means it parsed the most amount of input var r = null, p = null, q = null, rx = null, best = [[], s], last = false; // go through the rules in the given set for (var i = 0; i < px.length ; i++) { // last is a flag indicating whether this must be the last element // if there is only 1 element, then it MUST be the last one q = null; p = null; r = null; last = (px.length === 1); // first, we try simply to match the current pattern // if not, try the next pattern try { r = px[i].call(this, s); } catch (e) { continue; } // since we are matching against a set of elements, the first // thing to do is to add r[0] to matched elements rx = [[r[0]], r[1]]; // if we matched and there is still input to parse and // we don't already know this is the last element, // we're going to next check for the delimiter ... // if there's none, or if there's no input left to parse // than this must be the last element after all ... if (r[1].length > 0 && ! last) { try { q = d.call(this, r[1]); } catch (ex) { last = true; } } else { last = true; } // if we parsed the delimiter and now there's no more input, // that means we shouldn't have parsed the delimiter at all // so don't update r and mark this as the last element ... if (!last && q[1].length === 0) { last = true; } // so, if this isn't the last element, we're going to see if // we can get any more matches from the remaining (unmatched) // elements ... if (!last) { // build a list of the remaining rules we can match against, // i.e., all but the one we just matched against var qx = []; for (var j = 0; j < px.length ; j++) { if (i !== j) { qx.push(px[j]); } } // now invoke recursively set with the remaining input // note that we don't include the closing delimiter ... // we'll check for that ourselves at the end p = _.set(qx, d).call(this, q[1]); // if we got a non-empty set as a result ... // (otw rx already contains everything we want to match) if (p[0].length > 0) { // update current result, which is stored in rx ... // basically, pick up the remaining text from p[1] // and concat the result from p[0] so that we don't // get endless nesting ... rx[0] = rx[0].concat(p[0]); rx[1] = p[1]; } } // at this point, rx either contains the last matched element // or the entire matched set that starts with this element. // now we just check to see if this variation is better than // our best so far, in terms of how much of the input is parsed if (rx[1].length < best[1].length) { best = rx; } // if we've parsed all the input, then we're finished if (best[1].length === 0) { break; } } // so now we've either gone through all the patterns trying them // as the initial match; or we found one that parsed the entire // input string ... // if best has no matches, just return empty set ... if (best[0].length === 0) { return best; } // if a closing delimiter is provided, then we have to check it also if (c) { // we try this even if there is no remaining input because the pattern // may well be optional or match empty input ... try { q = c.call(this, best[1]); } catch (ey) { throw new $P.Exception(best[1]); } // it parsed ... be sure to update the best match remaining input best[1] = q[1]; } // if we're here, either there was no closing delimiter or we parsed it // so now we have the best match; just return it! return best; }; }, forward: function (gr, fname) { return function (s) { return gr[fname].call(this, s); }; }, // // Translation Operators // replace: function (rule, repl) { return function (s) { var r = rule.call(this, s); return [repl, r[1]]; }; }, process: function (rule, fn) { return function (s) { var r = rule.call(this, s); return [fn.call(this, r[0]), r[1]]; }; }, min: function (min, rule) { return function (s) { var rx = rule.call(this, s); if (rx[0].length < min) { throw new $P.Exception(s); } return rx; }; } }; // Generator Operators And Vector Operators // Generators are operators that have a signature of F(R) => R, // taking a given rule and returning another rule, such as // ignore, which parses a given rule and throws away the result. // Vector operators are those that have a signature of F(R1,R2,...) => R, // take a list of rules and returning a new rule, such as each. // Generator operators are converted (via the following _generator // function) into functions that can also take a list or array of rules // and return an array of new rules as though the function had been // called on each rule in turn (which is what actually happens). // This allows generators to be used with vector operators more easily. // Example: // each(ignore(foo, bar)) instead of each(ignore(foo), ignore(bar)) // This also turns generators into vector operators, which allows // constructs like: // not(cache(foo, bar)) var _generator = function (op) { function gen() { var args = null, rx = [], px, i; if (arguments.length > 1) { args = Array.prototype.slice.call(arguments); } else if (arguments[0] instanceof Array) { args = arguments[0]; } if (args) { px = args.shift(); if (px.length > 0) { args.unshift(px[i]); rx.push(op.apply(null, args)); args.shift(); return rx; } } else { return op.apply(null, arguments); } } return gen; }; var gx = "optional not ignore cache".split(/\s/); for (var i = 0 ; i < gx.length ; i++) { _[gx[i]] = _generator(_[gx[i]]); } var _vector = function (op) { return function () { if (arguments[0] instanceof Array) { return op.apply(null, arguments[0]); } else { return op.apply(null, arguments); } }; }; var vx = "each any all".split(/\s/); for (var j = 0 ; j < vx.length ; j++) { _[vx[j]] = _vector(_[vx[j]]); } }()); (function () { var $D = Date; var flattenAndCompact = function (ax) { var rx = []; for (var i = 0; i < ax.length; i++) { if (ax[i] instanceof Array) { rx = rx.concat(flattenAndCompact(ax[i])); } else { if (ax[i]) { rx.push(ax[i]); } } } return rx; }; var parseMeridian = function () { if (this.meridian && (this.hour || this.hour === 0)) { if (this.meridian === "a" && this.hour > 11 && Date.Config.strict24hr){ throw "Invalid hour and meridian combination"; } else if (this.meridian === "p" && this.hour < 12 && Date.Config.strict24hr){ throw "Invalid hour and meridian combination"; } else if (this.meridian === "p" && this.hour < 12) { this.hour = this.hour + 12; } else if (this.meridian === "a" && this.hour === 12) { this.hour = 0; } } }; var setDefaults = function () { var now = new Date(); if ((this.hour || this.minute) && (!this.month && !this.year && !this.day)) { this.day = now.getDate(); } if (!this.year) { this.year = now.getFullYear(); } if (!this.month && this.month !== 0) { this.month = now.getMonth(); } if (!this.day) { this.day = 1; } if (!this.hour) { this.hour = 0; } if (!this.minute) { this.minute = 0; } if (!this.second) { this.second = 0; } if (!this.millisecond) { this.millisecond = 0; } }; var finishUtils = { getToday: function () { if (this.now || "hour minute second".indexOf(this.unit) !== -1) { return new Date(); } else { return $D.today(); } }, setDaysFromWeekday: function (today, orient){ var gap; orient = orient || 1; this.unit = "day"; gap = ($D.getDayNumberFromName(this.weekday) - today.getDay()); this.days = gap ? ((gap + (orient * 7)) % 7) : (orient * 7); return this; }, setMonthsFromMonth: function (today, orient) { var gap; orient = orient || 1; this.unit = "month"; gap = (this.month - today.getMonth()); this.months = gap ? ((gap + (orient * 12)) % 12) : (orient * 12); this.month = null; return this; }, setDMYFromWeekday: function () { var d = Date[this.weekday](); this.day = d.getDate(); if (!this.month) { this.month = d.getMonth(); } this.year = d.getFullYear(); return this; }, setUnitValue: function (orient) { if (!this.value && this.operator && this.operator !== null && this[this.unit + "s"] && this[this.unit + "s"] !== null) { this[this.unit + "s"] = this[this.unit + "s"] + ((this.operator === "add") ? 1 : -1) + (this.value||0) * orient; } else if (this[this.unit + "s"] == null || this.operator != null) { if (!this.value) { this.value = 1; } this[this.unit + "s"] = this.value * orient; } }, generateDateFromWeeks: function () { var weekday = (this.weekday !== undefined) ? this.weekday : "today"; var d = Date[weekday]().addWeeks(this.weeks); if (this.now) { d.setTimeToNow(); } return d; } }; $D.Translator = { hour: function (s) { return function () { this.hour = Number(s); }; }, minute: function (s) { return function () { this.minute = Number(s); }; }, second: function (s) { return function () { this.second = Number(s); }; }, /* for ss.s format */ secondAndMillisecond: function (s) { return function () { var mx = s.match(/^([0-5][0-9])\.([0-9]{1,3})/); this.second = Number(mx[1]); this.millisecond = Number(mx[2]); }; }, meridian: function (s) { return function () { this.meridian = s.slice(0, 1).toLowerCase(); }; }, timezone: function (s) { return function () { var n = s.replace(/[^\d\+\-]/g, ""); if (n.length) { this.timezoneOffset = Number(n); } else { this.timezone = s.toLowerCase(); } }; }, day: function (x) { var s = x[0]; return function () { this.day = Number(s.match(/\d+/)[0]); if (this.day < 1) { throw "invalid day"; } }; }, month: function (s) { return function () { this.month = (s.length === 3) ? "jan feb mar apr may jun jul aug sep oct nov dec".indexOf(s)/4 : Number(s) - 1; if (this.month < 0) { throw "invalid month"; } }; }, year: function (s) { return function () { var n = Number(s); this.year = ((s.length > 2) ? n : (n + (((n + 2000) < Date.CultureInfo.twoDigitYearMax) ? 2000 : 1900))); }; }, rday: function (s) { return function () { switch (s) { case "yesterday": this.days = -1; break; case "tomorrow": this.days = 1; break; case "today": this.days = 0; break; case "now": this.days = 0; this.now = true; break; } }; }, finishExact: function (x) { var d; x = (x instanceof Array) ? x : [x]; for (var i = 0 ; i < x.length ; i++) { if (x[i]) { x[i].call(this); } } setDefaults.call(this); parseMeridian.call(this); if (this.day > $D.getDaysInMonth(this.year, this.month)) { throw new RangeError(this.day + " is not a valid value for days."); } d = new Date(this.year, this.month, this.day, this.hour, this.minute, this.second, this.millisecond); if (this.year < 100) { d.setFullYear(this.year); // means years less that 100 are process correctly. JS will parse it otherwise as 1900-1999. } if (this.timezone) { d.set({ timezone: this.timezone }); } else if (this.timezoneOffset) { d.set({ timezoneOffset: this.timezoneOffset }); } return d; }, finish: function (x) { var today, expression, orient, temp; x = (x instanceof Array) ? flattenAndCompact(x) : [ x ]; if (x.length === 0) { return null; } for (var i = 0 ; i < x.length ; i++) { if (typeof x[i] === "function") { x[i].call(this); } } if (this.now && !this.unit && !this.operator) { return new Date(); } else { today = finishUtils.getToday.call(this); } expression = !!(this.days && this.days !== null || this.orient || this.operator); orient = ((this.orient === "past" || this.operator === "subtract") ? -1 : 1); if (this.month && this.unit === "week") { this.value = this.month + 1; delete this.month; delete this.day; } if ((this.month || this.month === 0) && "year day hour minute second".indexOf(this.unit) !== -1) { if (!this.value) { this.value = this.month + 1; } this.month = null; expression = true; } if (!expression && this.weekday && !this.day && !this.days) { finishUtils.setDMYFromWeekday.call(this); } if (expression && this.weekday && this.unit !== "month" && this.unit !== "week") { finishUtils.setDaysFromWeekday.call(this, today, orient); } if (this.weekday && this.unit !== "week" && !this.day && !this.days) { temp = Date[this.weekday](); this.day = temp.getDate(); if (temp.getMonth() !== today.getMonth()) { this.month = temp.getMonth(); } } if (this.month && this.unit === "day" && this.operator) { if (!this.value) { this.value = (this.month + 1); } this.month = null; } if (this.value != null && this.month != null && this.year != null) { this.day = this.value * 1; } if (this.month && !this.day && this.value) { today.set({ day: this.value * 1 }); if (!expression) { this.day = this.value * 1; } } if (!this.month && this.value && this.unit === "month" && !this.now) { this.month = this.value; expression = true; } if (expression && (this.month || this.month === 0) && this.unit !== "year") { finishUtils.setMonthsFromMonth.call(this, today, orient); } if (!this.unit) { this.unit = "day"; } finishUtils.setUnitValue.call(this, orient); parseMeridian.call(this); if ((this.month || this.month === 0) && !this.day) { this.day = 1; } if (!this.orient && !this.operator && this.unit === "week" && this.value && !this.day && !this.month) { return Date.today().setWeek(this.value); } if (this.unit === "week" && this.weeks && !this.day && !this.month) { return finishUtils.generateDateFromWeeks.call(this); } if (expression && this.timezone && this.day && this.days) { this.day = this.days; } if (expression){ today.add(this); } else { today.set(this); } if (this.timezone) { this.timezone = this.timezone.toUpperCase(); var offset = $D.getTimezoneOffset(this.timezone); var timezone; if (today.hasDaylightSavingTime()) { // lets check that we're being sane with timezone setting timezone = $D.getTimezoneAbbreviation(offset, today.isDaylightSavingTime()); if (timezone !== this.timezone) { // bugger, we're in a place where things like EST vs EDT matters. if (today.isDaylightSavingTime()) { today.addHours(-1); } else { today.addHours(1); } } } today.setTimezoneOffset(offset); } return today; } }; }()); (function () { var $D = Date; $D.Grammar = {}; var _ = $D.Parsing.Operators, g = $D.Grammar, t = $D.Translator, _fn; // Allow rolling up into general purpose rules _fn = function () { return _.each(_.any.apply(null, arguments), _.not(g.ctoken2("timeContext"))); }; g.datePartDelimiter = _.rtoken(/^([\s\-\.\,\/\x27]+)/); g.timePartDelimiter = _.stoken(":"); g.whiteSpace = _.rtoken(/^\s*/); g.generalDelimiter = _.rtoken(/^(([\s\,]|at|@|on)+)/); var _C = {}; g.ctoken = function (keys) { var fn = _C[keys]; if (! fn) { var c = Date.CultureInfo.regexPatterns; var kx = keys.split(/\s+/), px = []; for (var i = 0; i < kx.length ; i++) { px.push(_.replace(_.rtoken(c[kx[i]]), kx[i])); } fn = _C[keys] = _.any.apply(null, px); } return fn; }; g.ctoken2 = function (key) { return _.rtoken(Date.CultureInfo.regexPatterns[key]); }; var cacheProcessRtoken = function (key, token, type, eachToken) { if (eachToken) { g[key] = _.cache(_.process(_.each(_.rtoken(token),_.optional(g.ctoken2(eachToken))), type)); } else { g[key] = _.cache(_.process(_.rtoken(token), type)); } }; var cacheProcessCtoken = function (token, type) { return _.cache(_.process(g.ctoken2(token), type)); }; var _F = {}; //function cache var _get = function (f) { _F[f] = (_F[f] || g.format(f)[0]); return _F[f]; }; g.allformats = function (fx) { var rx = []; if (fx instanceof Array) { for (var i = 0; i < fx.length; i++) { rx.push(_get(fx[i])); } } else { rx.push(_get(fx)); } return rx; }; g.formats = function (fx) { if (fx instanceof Array) { var rx = []; for (var i = 0 ; i < fx.length ; i++) { rx.push(_get(fx[i])); } return _.any.apply(null, rx); } else { return _get(fx); } }; var grammarFormats = { timeFormats: function(){ var i, RTokenKeys = [ "h", "hh", "H", "HH", "m", "mm", "s", "ss", "ss.s", "z", "zz" ], RToken = [ /^(0[0-9]|1[0-2]|[1-9])/, /^(0[0-9]|1[0-2])/, /^([0-1][0-9]|2[0-3]|[0-9])/, /^([0-1][0-9]|2[0-3])/, /^([0-5][0-9]|[0-9])/, /^[0-5][0-9]/, /^([0-5][0-9]|[0-9])/, /^[0-5][0-9]/, /^[0-5][0-9]\.[0-9]{1,3}/, /^((\+|\-)\s*\d\d\d\d)|((\+|\-)\d\d\:?\d\d)/, /^((\+|\-)\s*\d\d\d\d)|((\+|\-)\d\d\:?\d\d)/ ], tokens = [ t.hour, t.hour, t.hour, t.hour, t.minute, t.minute, t.second, t.second, t.secondAndMillisecond, t.timezone, t.timezone ]; for (i=0; i < RTokenKeys.length; i++) { cacheProcessRtoken(RTokenKeys[i], RToken[i], tokens[i]); } g.hms = _.cache(_.sequence([g.H, g.m, g.s], g.timePartDelimiter)); g.t = cacheProcessCtoken("shortMeridian", t.meridian); g.tt = cacheProcessCtoken("longMeridian", t.meridian); g.zzz = cacheProcessCtoken("timezone", t.timezone); g.timeSuffix = _.each(_.ignore(g.whiteSpace), _.set([ g.tt, g.zzz ])); g.time = _.each(_.optional(_.ignore(_.stoken("T"))), g.hms, g.timeSuffix); }, dateFormats: function () { // pre-loaded rules for different date part order preferences var _setfn = function () { return _.set(arguments, g.datePartDelimiter); }; var i, RTokenKeys = [ "d", "dd", "M", "MM", "y", "yy", "yyy", "yyyy" ], RToken = [ /^([0-2]\d|3[0-1]|\d)/, /^([0-2]\d|3[0-1])/, /^(1[0-2]|0\d|\d)/, /^(1[0-2]|0\d)/, /^(\d+)/, /^(\d\d)/, /^(\d\d?\d?\d?)/, /^(\d\d\d\d)/ ], tokens = [ t.day, t.day, t.month, t.month, t.year, t.year, t.year, t.year ], eachToken = [ "ordinalSuffix", "ordinalSuffix" ]; for (i=0; i < RTokenKeys.length; i++) { cacheProcessRtoken(RTokenKeys[i], RToken[i], tokens[i], eachToken[i]); } g.MMM = g.MMMM = _.cache(_.process(g.ctoken("jan feb mar apr may jun jul aug sep oct nov dec"), t.month)); g.ddd = g.dddd = _.cache(_.process(g.ctoken("sun mon tue wed thu fri sat"), function (s) { return function () { this.weekday = s; }; } )); g.day = _fn(g.d, g.dd); g.month = _fn(g.M, g.MMM); g.year = _fn(g.yyyy, g.yy); g.mdy = _setfn(g.ddd, g.month, g.day, g.year); g.ymd = _setfn(g.ddd, g.year, g.month, g.day); g.dmy = _setfn(g.ddd, g.day, g.month, g.year); g.date = function (s) { return ((g[Date.CultureInfo.dateElementOrder] || g.mdy).call(this, s)); }; }, relative: function () { // relative date / time expressions g.orientation = _.process(g.ctoken("past future"), function (s) { return function () { this.orient = s; }; } ); g.operator = _.process(g.ctoken("add subtract"), function (s) { return function () { this.operator = s; }; } ); g.rday = _.process(g.ctoken("yesterday tomorrow today now"), t.rday); g.unit = _.process(g.ctoken("second minute hour day week month year"), function (s) { return function () { this.unit = s; }; } ); } }; g.buildGrammarFormats = function () { // these need to be rebuilt every time the language changes. _C = {}; grammarFormats.timeFormats(); grammarFormats.dateFormats(); grammarFormats.relative(); g.value = _.process(_.rtoken(/^([-+]?\d+)?(st|nd|rd|th)?/), function (s) { return function () { this.value = s.replace(/\D/g, ""); }; } ); g.expression = _.set([g.rday, g.operator, g.value, g.unit, g.orientation, g.ddd, g.MMM ]); g.format = _.process(_.many( _.any( // translate format specifiers into grammar rules _.process( _.rtoken(/^(dd?d?d?(?!e)|MM?M?M?|yy?y?y?|hh?|HH?|mm?|ss?|tt?|zz?z?)/), function (fmt) { if (g[fmt]) { return g[fmt]; } else { throw $D.Parsing.Exception(fmt); } } ), // translate separator tokens into token rules _.process(_.rtoken(/^[^dMyhHmstz]+/), // all legal separators function (s) { return _.ignore(_.stoken(s)); } ) ) ), // construct the parser ... function (rules) { return _.process(_.each.apply(null, rules), t.finishExact); } ); // starting rule for general purpose grammar g._start = _.process(_.set([ g.date, g.time, g.expression ], g.generalDelimiter, g.whiteSpace), t.finish); }; g.buildGrammarFormats(); // parsing date format specifiers - ex: "h:m:s tt" // this little guy will generate a custom parser based // on the format string, ex: g.format("h:m:s tt") // check for these formats first g._formats = g.formats([ "\"yyyy-MM-ddTHH:mm:ssZ\"", "yyyy-MM-ddTHH:mm:ss.sz", "yyyy-MM-ddTHH:mm:ssZ", "yyyy-MM-ddTHH:mm:ssz", "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-ddTHH:mmZ", "yyyy-MM-ddTHH:mmz", "yyyy-MM-ddTHH:mm", "ddd, MMM dd, yyyy H:mm:ss tt", "ddd MMM d yyyy HH:mm:ss zzz", "MMddyyyy", "ddMMyyyy", "Mddyyyy", "ddMyyyy", "Mdyyyy", "dMyyyy", "yyyy", "Mdyy", "dMyy", "d" ]); // real starting rule: tries selected formats first, // then general purpose rule g.start = function (s) { try { var r = g._formats.call({}, s); if (r[1].length === 0) { return r; } } catch (e) {} return g._start.call({}, s); }; }()); (function () { var $D = Date; /** * @desc Converts the specified string value into its JavaScript Date equivalent using CultureInfo specific format information. * * Example

	///////////
	// Dates //
	///////////

	// 15-Oct-2004
	var d1 = Date.parse("10/15/2004");

	// 15-Oct-2004
	var d1 = Date.parse("15-Oct-2004");

	// 15-Oct-2004
	var d1 = Date.parse("2004.10.15");

	//Fri Oct 15, 2004
	var d1 = Date.parse("Fri Oct 15, 2004");

	///////////
	// Times //
	///////////

	// Today at 10 PM.
	var d1 = Date.parse("10 PM");

	// Today at 10:30 PM.
	var d1 = Date.parse("10:30 P.M.");

	// Today at 6 AM.
	var d1 = Date.parse("06am");

	/////////////////////
	// Dates and Times //
	/////////////////////

	// 8-July-2004 @ 10:30 PM
	var d1 = Date.parse("July 8th, 2004, 10:30 PM");

	// 1-July-2004 @ 10:30 PM
	var d1 = Date.parse("2004-07-01T22:30:00");

	////////////////////
	// Relative Dates //
	////////////////////

	// Returns today's date. The string "today" is culture specific.
	var d1 = Date.parse("today");

	// Returns yesterday's date. The string "yesterday" is culture specific.
	var d1 = Date.parse("yesterday");

	// Returns the date of the next thursday.
	var d1 = Date.parse("Next thursday");

	// Returns the date of the most previous monday.
	var d1 = Date.parse("last monday");

	// Returns today's day + one year.
	var d1 = Date.parse("next year");

	///////////////
	// Date Math //
	///////////////

	// Today + 2 days
	var d1 = Date.parse("t+2");

	// Today + 2 days
	var d1 = Date.parse("today + 2 days");

	// Today + 3 months
	var d1 = Date.parse("t+3m");

	// Today - 1 year
	var d1 = Date.parse("today - 1 year");

	// Today - 1 year
	var d1 = Date.parse("t-1y"); 


	/////////////////////////////
	// Partial Dates and Times //
	/////////////////////////////

	// July 15th of this year.
	var d1 = Date.parse("July 15");

	// 15th day of current day and year.
	var d1 = Date.parse("15");

	// July 1st of current year at 10pm.
	var d1 = Date.parse("7/1 10pm");
	
* * @param {String} The string value to convert into a Date object [Required] * @return {Date} A Date object or null if the string cannot be converted into a Date. */ var parseUtils = { removeOrds: function (s) { ords = s.match(/\b(\d+)(?:st|nd|rd|th)\b/); // find ordinal matches s = ((ords && ords.length === 2) ? s.replace(ords[0], ords[1]) : s); return s; }, grammarParser: function (s) { var r = null; try { r = $D.Grammar.start.call({}, s.replace(/^\s*(\S*(\s+\S+)*)\s*$/, "$1")); } catch (e) { return null; } return ((r[1].length === 0) ? r[0] : null); }, nativeFallback: function(s) { var t; try { // ok we haven't parsed it, last ditch attempt with the built-in parser. t = Date._parse(s); return (t || t === 0) ? new Date(t) : null; } catch (e) { return null; } } }; function parse (s) { var d; if (!s) { return null; } if (s instanceof Date) { return s.clone(); } if (s.length >= 4 && s.charAt(0) !== "0" && s.charAt(0) !== "+"&& s.charAt(0) !== "-") { // ie: 2004 will pass, 0800 won't. // Start with specific formats d = $D.Parsing.ISO.parse(s) || $D.Parsing.Numeric.parse(s); } if (d instanceof Date && !isNaN(d.getTime())) { return d; } else { // find ordinal dates (1st, 3rd, 8th, etc and remove them as they cause parsing issues) s = $D.Parsing.Normalizer.parse(parseUtils.removeOrds(s)); d = parseUtils.grammarParser(s); if (d !== null) { return d; } else { return parseUtils.nativeFallback(s); } } } if (!$D._parse) { $D._parse = $D.parse; } $D.parse = parse; Date.getParseFunction = function (fx) { var fns = Date.Grammar.allformats(fx); return function (s) { var r = null; for (var i = 0; i < fns.length; i++) { try { r = fns[i].call({}, s); } catch (e) { continue; } if (r[1].length === 0) { return r[0]; } } return null; }; }; /** * Converts the specified string value into its JavaScript Date equivalent using the specified format {String} or formats {Array} and the CultureInfo specific format information. * The format of the string value must match one of the supplied formats exactly. * * Example

	// 15-Oct-2004
	var d1 = Date.parseExact("10/15/2004", "M/d/yyyy");

	// 15-Oct-2004
	var d1 = Date.parse("15-Oct-2004", "M-ddd-yyyy");

	// 15-Oct-2004
	var d1 = Date.parse("2004.10.15", "yyyy.MM.dd");

	// Multiple formats
	var d1 = Date.parseExact("10/15/2004", ["M/d/yyyy", "MMMM d, yyyy"]);
	
* * @param {String} The string value to convert into a Date object [Required]. * @param {Object} The expected format {String} or an array of expected formats {Array} of the date string [Required]. * @return {Date} A Date object or null if the string cannot be converted into a Date. */ $D.parseExact = function (s, fx) { return $D.getParseFunction(fx)(s); }; }()); (function () { var $D = Date, $P = $D.prototype, // $C = $D.CultureInfo, // not used atm p = function (s, l) { if (!l) { l = 2; } return ("000" + s).slice(l * -1); }; /** * Converts a PHP format string to Java/.NET format string. * A PHP format string can be used with ._format or .format. * A Java/.NET format string can be used with .toString(). * The .parseExact function will only accept a Java/.NET format string * * Example * var f1 = "%m/%d/%y" * var f2 = Date.normalizeFormat(f1); // "MM/dd/yy" * * new Date().format(f1); // "04/13/08" * new Date()._format(f1); // "04/13/08" * new Date().toString(f2); // "04/13/08" * * var date = Date.parseExact("04/13/08", f2); // Sun Apr 13 2008 * * @param {String} A PHP format string consisting of one or more format spcifiers. * @return {String} The PHP format converted to a Java/.NET format string. */ var normalizerSubstitutions = { "d" : "dd", "%d": "dd", "D" : "ddd", "%a": "ddd", "j" : "dddd", "l" : "dddd", "%A": "dddd", "S" : "S", "F" : "MMMM", "%B": "MMMM", "m" : "MM", "%m": "MM", "M" : "MMM", "%b": "MMM", "%h": "MMM", "n" : "M", "Y" : "yyyy", "%Y": "yyyy", "y" : "yy", "%y": "yy", "g" : "h", "%I": "h", "G" : "H", "h" : "hh", "H" : "HH", "%H": "HH", "i" : "mm", "%M": "mm", "s" : "ss", "%S": "ss", "%r": "hh:mm tt", "%R": "H:mm", "%T": "H:mm:ss", "%X": "t", "%x": "d", "%e": "d", "%D": "MM/dd/yy", "%n": "\\n", "%t": "\\t", "e" : "z", "T" : "z", "%z": "z", "%Z": "z", "Z" : "ZZ", "N" : "u", "w" : "u", "%w": "u", "W" : "W", "%V": "W" }; var normalizer = { substitutes: function (m) { return normalizerSubstitutions[m]; }, interpreted: function (m, x) { var y; switch (m) { case "%u": return x.getDay() + 1; case "z": return x.getOrdinalNumber(); case "%j": return p(x.getOrdinalNumber(), 3); case "%U": var d1 = x.clone().set({month: 0, day: 1}).addDays(-1).moveToDayOfWeek(0), d2 = x.clone().addDays(1).moveToDayOfWeek(0, -1); return (d2 < d1) ? "00" : p((d2.getOrdinalNumber() - d1.getOrdinalNumber()) / 7 + 1); case "%W": return p(x.getWeek()); case "t": return $D.getDaysInMonth(x.getFullYear(), x.getMonth()); case "o": case "%G": return x.setWeek(x.getISOWeek()).toString("yyyy"); case "%g": return x._format("%G").slice(-2); case "a": case "%p": return t("tt").toLowerCase(); case "A": return t("tt").toUpperCase(); case "u": return p(x.getMilliseconds(), 3); case "I": return (x.isDaylightSavingTime()) ? 1 : 0; case "O": return x.getUTCOffset(); case "P": y = x.getUTCOffset(); return y.substring(0, y.length - 2) + ":" + y.substring(y.length - 2); case "B": var now = new Date(); return Math.floor(((now.getHours() * 3600) + (now.getMinutes() * 60) + now.getSeconds() + (now.getTimezoneOffset() + 60) * 60) / 86.4); case "c": return x.toISOString().replace(/\"/g, ""); case "U": return $D.strtotime("now"); case "%c": return t("d") + " " + t("t"); case "%C": return Math.floor(x.getFullYear() / 100 + 1); } }, shouldOverrideDefaults: function (m) { switch (m) { case "%e": return true; default: return false; } }, parse: function (m, context) { var formatString, c = context || new Date(); formatString = normalizer.substitutes(m); if (formatString) { return formatString; } formatString = normalizer.interpreted(m, c); if (formatString) { return formatString; } else { return m; } } }; $D.normalizeFormat = function (format, context) { return format.replace(/(%|\\)?.|%%/g, function(t){ return normalizer.parse(t, context); }); }; /** * Format a local Unix timestamp according to locale settings * * Example: * Date.strftime("%m/%d/%y", new Date()); // "04/13/08" * Date.strftime("c", "2008-04-13T17:52:03Z"); // "04/13/08" * * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @param {Number|String} The number representing the number of seconds that have elapsed since January 1, 1970 (local time). * @return {String} A string representation of the current Date object. */ $D.strftime = function (format, time) { var d = Date.parse(time); return d._format(format); }; /** * Parse any textual datetime description into a Unix timestamp. * A Unix timestamp is the number of seconds that have elapsed since January 1, 1970 (midnight UTC/GMT). * * Example: * Date.strtotime("04/13/08"); // 1208044800 * Date.strtotime("1970-01-01T00:00:00Z"); // 0 * * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @param {Object} A string or date object. * @return {String} A string representation of the current Date object. */ $D.strtotime = function (time) { var d = $D.parse(time); return Math.round($D.UTC(d.getUTCFullYear(), d.getUTCMonth(), d.getUTCDate(), d.getUTCHours(), d.getUTCMinutes(), d.getUTCSeconds(), d.getUTCMilliseconds()) / 1000); }; /** * Converts the value of the current Date object to its equivalent string representation using a PHP/Unix style of date format specifiers. * Format Specifiers * Format Description Example * ------ --------------------------------------------------------------------------- ----------------------- * %a abbreviated weekday name according to the current localed "Mon" through "Sun" * %A full weekday name according to the current localed "Sunday" through "Saturday" * %b abbreviated month name according to the current localed "Jan" through "Dec" * %B full month name according to the current locale "January" through "December" * %c preferred date and time representation for the current locale "4/13/2008 12:33 PM" * %C century number (the year divided by 100 and truncated to an integer) "00" to "99" * %d day of the month as a decimal number "01" to "31" * %D same as %m/%d/%y "04/13/08" * %e day of the month as a decimal number, a single digit is preceded by a space "1" to "31" * %g like %G, but without the century "08" * %G The 4-digit year corresponding to the ISO week number (see %V). "2008" * This has the same format and value as %Y, except that if the ISO week number * belongs to the previous or next year, that year is used instead. * %h same as %b "Jan" through "Dec" * %H hour as a decimal number using a 24-hour clock. "00" to "23" * %I hour as a decimal number using a 12-hour clock. "01" to "12" * %j day of the year as a decimal number. "001" to "366" * %m month as a decimal number. "01" to "12" * %M minute as a decimal number. "00" to "59" * %n newline character "\n" * %p either "am" or "pm" according to the given time value, or the "am" or "pm" * corresponding strings for the current locale. * %r time in a.m. and p.m. notation "8:44 PM" * %R time in 24 hour notation "20:44" * %S second as a decimal number "00" to "59" * %t tab character "\t" * %T current time, equal to %H:%M:%S "12:49:11" * %u weekday as a decimal number ["1", "7"], with "1" representing Monday "1" to "7" * %U week number of the current year as a decimal number, starting with the "0" to ("52" or "53") * first Sunday as the first day of the first week * %V The ISO 8601:1988 week number of the current year as a decimal number, "00" to ("52" or "53") * range 01 to 53, where week 1 is the first week that has at least 4 days * in the current year, and with Monday as the first day of the week. * (Use %G or %g for the year component that corresponds to the week number * for the specified timestamp.) * %W week number of the current year as a decimal number, starting with the "00" to ("52" or "53") * first Monday as the first day of the first week * %w day of the week as a decimal, Sunday being "0" "0" to "6" * %x preferred date representation for the current locale without the time "4/13/2008" * %X preferred time representation for the current locale without the date "12:53:05" * %y year as a decimal number without a century "00" "99" * %Y year as a decimal number including the century "2008" * %Z time zone or name or abbreviation "UTC", "EST", "PST" * %z same as %Z * %% a literal "%" characters "%" * d Day of the month, 2 digits with leading zeros "01" to "31" * D A textual representation of a day, three letters "Mon" through "Sun" * j Day of the month without leading zeros "1" to "31" * l A full textual representation of the day of the week (lowercase "L") "Sunday" through "Saturday" * N ISO-8601 numeric representation of the day of the week (added in PHP 5.1.0) "1" (for Monday) through "7" (for Sunday) * S English ordinal suffix for the day of the month, 2 characters "st", "nd", "rd" or "th". Works well with j * w Numeric representation of the day of the week "0" (for Sunday) through "6" (for Saturday) * z The day of the year (starting from "0") "0" through "365" * W ISO-8601 week number of year, weeks starting on Monday "00" to ("52" or "53") * F A full textual representation of a month, such as January or March "January" through "December" * m Numeric representation of a month, with leading zeros "01" through "12" * M A short textual representation of a month, three letters "Jan" through "Dec" * n Numeric representation of a month, without leading zeros "1" through "12" * t Number of days in the given month "28" through "31" * L Whether it's a leap year "1" if it is a leap year, "0" otherwise * o ISO-8601 year number. This has the same value as Y, except that if the "2008" * ISO week number (W) belongs to the previous or next year, that year * is used instead. * Y A full numeric representation of a year, 4 digits "2008" * y A two digit representation of a year "08" * a Lowercase Ante meridiem and Post meridiem "am" or "pm" * A Uppercase Ante meridiem and Post meridiem "AM" or "PM" * B Swatch Internet time "000" through "999" * g 12-hour format of an hour without leading zeros "1" through "12" * G 24-hour format of an hour without leading zeros "0" through "23" * h 12-hour format of an hour with leading zeros "01" through "12" * H 24-hour format of an hour with leading zeros "00" through "23" * i Minutes with leading zeros "00" to "59" * s Seconds, with leading zeros "00" through "59" * u Milliseconds "54321" * e Timezone identifier "UTC", "EST", "PST" * I Whether or not the date is in daylight saving time (uppercase i) "1" if Daylight Saving Time, "0" otherwise * O Difference to Greenwich time (GMT) in hours "+0200", "-0600" * P Difference to Greenwich time (GMT) with colon between hours and minutes "+02:00", "-06:00" * T Timezone abbreviation "UTC", "EST", "PST" * Z Timezone offset in seconds. The offset for timezones west of UTC is "-43200" through "50400" * always negative, and for those east of UTC is always positive. * c ISO 8601 date "2004-02-12T15:19:21+00:00" * r RFC 2822 formatted date "Thu, 21 Dec 2000 16:01:07 +0200" * U Seconds since the Unix Epoch (January 1 1970 00:00:00 GMT) "0" * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @return {String} A string representation of the current Date object. */ var formatReplace = function (context) { return function (m) { var formatString, override = false; if (m.charAt(0) === "\\" || m.substring(0, 2) === "%%") { return m.replace("\\", "").replace("%%", "%"); } override = normalizer.shouldOverrideDefaults(m); formatString = $D.normalizeFormat(m, context); if (formatString) { return context.toString(formatString, override); } }; }; $P._format = function (format) { var formatter = formatReplace(this); if (!format) { return this._toString(); } else { return format.replace(/(%|\\)?.|%%/g, formatter); } }; if (!$P.format) { $P.format = $P._format; } }()); (function () { "use strict"; var gFn = function (attr) { return function () { return this[attr]; }; }; var sFn = function (attr) { return function (val) { this[attr] = val; return this; }; }; var attrs = ["years", "months", "days", "hours", "minutes", "seconds", "milliseconds"]; var addSetFuncs = function (context, attrs) { for (var i = 0; i < attrs.length ; i++) { var $a = attrs[i], $b = $a.slice(0, 1).toUpperCase() + $a.slice(1); context.prototype[$a] = 0; context.prototype["get" + $b] = gFn($a); context.prototype["set" + $b] = sFn($a); } }; /** * new TimeSpan(milliseconds); * new TimeSpan(days, hours, minutes, seconds); * new TimeSpan(days, hours, minutes, seconds, milliseconds); */ var TimeSpan = function (days, hours, minutes, seconds, milliseconds) { if (arguments.length === 1 && typeof days === "number") { var orient = (days < 0) ? -1 : +1; var millsLeft = Math.abs(days); this.setDays(Math.floor(millsLeft / 86400000) * orient); millsLeft = millsLeft % 86400000; this.setHours(Math.floor(millsLeft / 3600000) * orient); millsLeft = millsLeft % 3600000; this.setMinutes(Math.floor(millsLeft / 60000) * orient); millsLeft = millsLeft % 60000; this.setSeconds(Math.floor(millsLeft / 1000) * orient); millsLeft = millsLeft % 1000; this.setMilliseconds(millsLeft * orient); } else { this.set(days, hours, minutes, seconds, milliseconds); } this.getTotalMilliseconds = function () { return (this.getDays() * 86400000) + (this.getHours() * 3600000) + (this.getMinutes() * 60000) + (this.getSeconds() * 1000); }; this.compareTo = function (time) { var t1 = new Date(1970, 1, 1, this.getHours(), this.getMinutes(), this.getSeconds()), t2; if (time === null) { t2 = new Date(1970, 1, 1, 0, 0, 0); } else { t2 = new Date(1970, 1, 1, time.getHours(), time.getMinutes(), time.getSeconds()); } return (t1 < t2) ? -1 : (t1 > t2) ? 1 : 0; }; this.equals = function (time) { return (this.compareTo(time) === 0); }; this.add = function (time) { return (time === null) ? this : this.addSeconds(time.getTotalMilliseconds() / 1000); }; this.subtract = function (time) { return (time === null) ? this : this.addSeconds(-time.getTotalMilliseconds() / 1000); }; this.addDays = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 86400000)); }; this.addHours = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 3600000)); }; this.addMinutes = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 60000)); }; this.addSeconds = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 1000)); }; this.addMilliseconds = function (n) { return new TimeSpan(this.getTotalMilliseconds() + n); }; this.get12HourHour = function () { return (this.getHours() > 12) ? this.getHours() - 12 : (this.getHours() === 0) ? 12 : this.getHours(); }; this.getDesignator = function () { return (this.getHours() < 12) ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator; }; this.toString = function (format) { this._toString = function () { if (this.getDays() !== null && this.getDays() > 0) { return this.getDays() + "." + this.getHours() + ":" + this.p(this.getMinutes()) + ":" + this.p(this.getSeconds()); } else { return this.getHours() + ":" + this.p(this.getMinutes()) + ":" + this.p(this.getSeconds()); } }; this.p = function (s) { return (s.toString().length < 2) ? "0" + s : s; }; var me = this; return format ? format.replace(/dd?|HH?|hh?|mm?|ss?|tt?/g, function (format) { switch (format) { case "d": return me.getDays(); case "dd": return me.p(me.getDays()); case "H": return me.getHours(); case "HH": return me.p(me.getHours()); case "h": return me.get12HourHour(); case "hh": return me.p(me.get12HourHour()); case "m": return me.getMinutes(); case "mm": return me.p(me.getMinutes()); case "s": return me.getSeconds(); case "ss": return me.p(me.getSeconds()); case "t": return ((me.getHours() < 12) ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator).substring(0, 1); case "tt": return (me.getHours() < 12) ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator; } } ) : this._toString(); }; return this; }; addSetFuncs(TimeSpan, attrs.slice(2)); TimeSpan.prototype.set = function (days, hours, minutes, seconds, milliseconds){ this.setDays(days || this.getDays()); this.setHours(hours || this.getHours()); this.setMinutes(minutes || this.getMinutes()); this.setSeconds(seconds || this.getSeconds()); this.setMilliseconds(milliseconds || this.getMilliseconds()); }; /** * Gets the time of day for this date instances. * @return {TimeSpan} TimeSpan */ Date.prototype.getTimeOfDay = function () { return new TimeSpan(0, this.getHours(), this.getMinutes(), this.getSeconds(), this.getMilliseconds()); }; Date.TimeSpan = TimeSpan; if (typeof window !== "undefined" ) { // keeping API compatible for v1.x window.TimeSpan = TimeSpan; } }()); (function () { "use strict"; var attrs = ["years", "months", "days", "hours", "minutes", "seconds", "milliseconds"]; var gFn = function (attr) { return function () { return this[attr]; }; }; var sFn = function (attr) { return function (val) { this[attr] = val; return this; }; }; var addSetFuncs = function (context, attrs) { for (var i = 0; i < attrs.length ; i++) { var $a = attrs[i], $b = $a.slice(0, 1).toUpperCase() + $a.slice(1); context.prototype[$a] = 0; context.prototype["get" + $b] = gFn($a); context.prototype["set" + $b] = sFn($a); } }; var setMonthsAndYears = function (orient, d1, d2, context) { function inc() { d1.addMonths(-orient); context.months++; if (context.months === 12) { context.years++; context.months = 0; } } if (orient === +1) { while (d1 > d2) { inc(); } } else { while (d1 < d2) { inc(); } } context.months--; context.months *= orient; context.years *= orient; }; var adjustForDST = function(orient, startDate, endDate) { var hasDSTMismatch = (false === (startDate.isDaylightSavingTime() === endDate.isDaylightSavingTime())); if (hasDSTMismatch && orient === 1) { startDate.addHours(-1); } else if (hasDSTMismatch) { startDate.addHours(1); } }; /** * TimePeriod(startDate, endDate); * TimePeriod(years, months, days, hours, minutes, seconds, milliseconds); */ var TimePeriod = function (years, months, days, hours, minutes, seconds, milliseconds) { if (arguments.length === 7) { this.set(years, months, days, hours, minutes, seconds, milliseconds); } else if (arguments.length === 2 && arguments[0] instanceof Date && arguments[1] instanceof Date) { var startDate = arguments[0].clone(); var endDate = arguments[1].clone(); var orient = (startDate > endDate) ? +1 : -1; this.dates = { start: arguments[0].clone(), end: arguments[1].clone() }; setMonthsAndYears(orient, startDate, endDate, this); adjustForDST(orient, startDate, endDate); // // TODO - adjust for DST var diff = endDate - startDate; if (diff !== 0) { var ts = new TimeSpan(diff); this.set(this.years, this.months, ts.getDays(), ts.getHours(), ts.getMinutes(), ts.getSeconds(), ts.getMilliseconds()); } } return this; }; // create all the set functions. addSetFuncs(TimePeriod, attrs); TimePeriod.prototype.set = function (years, months, days, hours, minutes, seconds, milliseconds){ this.setYears(years || this.getYears()); this.setMonths(months || this.getMonths()); this.setDays(days || this.getDays()); this.setHours(hours || this.getHours()); this.setMinutes(minutes || this.getMinutes()); this.setSeconds(seconds || this.getSeconds()); this.setMilliseconds(milliseconds || this.getMilliseconds()); }; Date.TimePeriod = TimePeriod; if (typeof window !== "undefined") { // keeping API compatible for v1.x window.TimePeriod = TimePeriod; } }()); ================================================ FILE: build/date-es-VE.js ================================================ /** * @overview datejs * @version 1.0.0-rc3 * @author Gregory Wild-Smith * @copyright 2015 Gregory Wild-Smith * @license MIT * @homepage https://github.com/abritinthebay/datejs */ /* * DateJS Culture String File * Country Code: es-VE * Name: Spanish (Venezuela) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["es-VE"] = { "name": "es-VE", "englishName": "Spanish (Venezuela)", "nativeName": "Español (Republica Bolivariana de Venezuela)", "Sunday": "domingo", "Monday": "lunes", "Tuesday": "martes", "Wednesday": "miércoles", "Thursday": "jueves", "Friday": "viernes", "Saturday": "sábado", "Sun": "dom", "Mon": "lun", "Tue": "mar", "Wed": "mié", "Thu": "jue", "Fri": "vie", "Sat": "sáb", "Su": "do", "Mo": "lu", "Tu": "ma", "We": "mi", "Th": "ju", "Fr": "vi", "Sa": "sá", "S_Sun_Initial": "d", "M_Mon_Initial": "l", "T_Tue_Initial": "m", "W_Wed_Initial": "m", "T_Thu_Initial": "j", "F_Fri_Initial": "v", "S_Sat_Initial": "s", "January": "enero", "February": "febrero", "March": "marzo", "April": "abril", "May": "mayo", "June": "junio", "July": "julio", "August": "agosto", "September": "septiembre", "October": "octubre", "November": "noviembre", "December": "diciembre", "Jan_Abbr": "ene", "Feb_Abbr": "feb", "Mar_Abbr": "mar", "Apr_Abbr": "abr", "May_Abbr": "may", "Jun_Abbr": "jun", "Jul_Abbr": "jul", "Aug_Abbr": "ago", "Sep_Abbr": "sep", "Oct_Abbr": "oct", "Nov_Abbr": "nov", "Dec_Abbr": "dic", "AM": "a.m.", "PM": "p.m.", "firstDayOfWeek": 0, "twoDigitYearMax": 2029, "mdy": "dmy", "M/d/yyyy": "dd/MM/yyyy", "dddd, MMMM dd, yyyy": "dddd, dd' [de] 'MMMM' [de] 'yyyy", "h:mm tt": "hh:mm tt", "h:mm:ss tt": "hh:mm:ss tt", "dddd, MMMM dd, yyyy h:mm:ss tt": "dddd, dd' [de] 'MMMM' [de] 'yyyy hh:mm:ss tt", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "dd MMMM", "MMMM, yyyy": "MMMM' [de] 'yyyy", "/jan(uary)?/": "ene(ro)?", "/feb(ruary)?/": "feb(rero)?", "/mar(ch)?/": "mar(zo)?", "/apr(il)?/": "abr(il)?", "/may/": "may(o)?", "/jun(e)?/": "jun(io)?", "/jul(y)?/": "jul(io)?", "/aug(ust)?/": "ago(sto)?", "/sep(t(ember)?)?/": "sep(tiembre)?", "/oct(ober)?/": "oct(ubre)?", "/nov(ember)?/": "nov(iembre)?", "/dec(ember)?/": "dic(iembre)?", "/^su(n(day)?)?/": "^do(m(ingo)?)?", "/^mo(n(day)?)?/": "^lu(n(es)?)?", "/^tu(e(s(day)?)?)?/": "^ma(r(tes)?)?", "/^we(d(nesday)?)?/": "^mi(é(rcoles)?)?", "/^th(u(r(s(day)?)?)?)?/": "^ju(e(ves)?)?", "/^fr(i(day)?)?/": "^vi(e(rnes)?)?", "/^sa(t(urday)?)?/": "^sá(b(ado)?)?", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "es-VE"; /** * @overview datejs * @version 1.0.0-rc3 * @author Gregory Wild-Smith * @copyright 2015 Gregory Wild-Smith * @license MIT * @homepage https://github.com/abritinthebay/datejs */(function () { var $D = Date; var lang = Date.CultureStrings ? Date.CultureStrings.lang : null; var loggedKeys = {}; // for debug purposes. var getText = { getFromKey: function (key, countryCode) { var output; if (Date.CultureStrings && Date.CultureStrings[countryCode] && Date.CultureStrings[countryCode][key]) { output = Date.CultureStrings[countryCode][key]; } else { output = getText.buildFromDefault(key); } if (key.charAt(0) === "/") { // Assume it's a regex output = getText.buildFromRegex(key, countryCode); } return output; }, getFromObjectValues: function (obj, countryCode) { var key, output = {}; for(key in obj) { if (obj.hasOwnProperty(key)) { output[key] = getText.getFromKey(obj[key], countryCode); } } return output; }, getFromObjectKeys: function (obj, countryCode) { var key, output = {}; for(key in obj) { if (obj.hasOwnProperty(key)) { output[getText.getFromKey(key, countryCode)] = obj[key]; } } return output; }, getFromArray: function (arr, countryCode) { var output = []; for (var i=0; i < arr.length; i++){ if (i in arr) { output[i] = getText.getFromKey(arr[i], countryCode); } } return output; }, buildFromDefault: function (key) { var output, length, split, last; switch(key) { case "name": output = "en-US"; break; case "englishName": output = "English (United States)"; break; case "nativeName": output = "English (United States)"; break; case "twoDigitYearMax": output = 2049; break; case "firstDayOfWeek": output = 0; break; default: output = key; split = key.split("_"); length = split.length; if (length > 1 && key.charAt(0) !== "/") { // if the key isn't a regex and it has a split. last = split[(length - 1)].toLowerCase(); if (last === "initial" || last === "abbr") { output = split[0]; } } break; } return output; }, buildFromRegex: function (key, countryCode) { var output; if (Date.CultureStrings && Date.CultureStrings[countryCode] && Date.CultureStrings[countryCode][key]) { output = new RegExp(Date.CultureStrings[countryCode][key], "i"); } else { output = new RegExp(key.replace(new RegExp("/", "g"),""), "i"); } return output; } }; var shallowMerge = function (obj1, obj2) { for (var attrname in obj2) { if (obj2.hasOwnProperty(attrname)) { obj1[attrname] = obj2[attrname]; } } }; var __ = function (key, language) { var countryCode = (language) ? language : lang; loggedKeys[key] = key; if (typeof key === "object") { if (key instanceof Array) { return getText.getFromArray(key, countryCode); } else { return getText.getFromObjectKeys(key, countryCode); } } else { return getText.getFromKey(key, countryCode); } }; var loadI18nScript = function (code) { // paatterned after jQuery's getScript. var url = Date.Config.i18n + code + ".js"; var head = document.getElementsByTagName("head")[0] || document.documentElement; var script = document.createElement("script"); script.src = url; var completed = false; var events = { done: function (){} // placeholder function }; // Attach handlers for all browsers script.onload = script.onreadystatechange = function() { if ( !completed && (!this.readyState || this.readyState === "loaded" || this.readyState === "complete") ) { events.done(); head.removeChild(script); } }; setTimeout(function() { head.insertBefore(script, head.firstChild); }, 0); // allows return to execute first return { done: function (cb) { events.done = function() { if (cb) { setTimeout(cb,0); } }; } }; }; var buildInfo = { buildFromMethodHash: function (obj) { var key; for(key in obj) { if (obj.hasOwnProperty(key)) { obj[key] = buildInfo[obj[key]](); } } return obj; }, timeZoneDST: function () { var DST = { "CHADT": "+1345", "NZDT": "+1300", "AEDT": "+1100", "ACDT": "+1030", "AZST": "+0500", "IRDT": "+0430", "EEST": "+0300", "CEST": "+0200", "BST": "+0100", "PMDT": "-0200", "ADT": "-0300", "NDT": "-0230", "EDT": "-0400", "CDT": "-0500", "MDT": "-0600", "PDT": "-0700", "AKDT": "-0800", "HADT": "-0900" }; return __(DST); }, timeZoneStandard: function () { var standard = { "LINT": "+1400", "TOT": "+1300", "CHAST": "+1245", "NZST": "+1200", "NFT": "+1130", "SBT": "+1100", "AEST": "+1000", "ACST": "+0930", "JST": "+0900", "CWST": "+0845", "CT": "+0800", "ICT": "+0700", "MMT": "+0630", "BST": "+0600", "NPT": "+0545", "IST": "+0530", "PKT": "+0500", "AFT": "+0430", "MSK": "+0400", "IRST": "+0330", "FET": "+0300", "EET": "+0200", "CET": "+0100", "GMT": "+0000", "UTC": "+0000", "CVT": "-0100", "GST": "-0200", "BRT": "-0300", "NST": "-0330", "AST": "-0400", "EST": "-0500", "CST": "-0600", "MST": "-0700", "PST": "-0800", "AKST": "-0900", "MIT": "-0930", "HST": "-1000", "SST": "-1100", "BIT": "-1200" }; return __(standard); }, timeZones: function (data) { var zone; data.timezones = []; for (zone in data.abbreviatedTimeZoneStandard) { if (data.abbreviatedTimeZoneStandard.hasOwnProperty(zone)) { data.timezones.push({ name: zone, offset: data.abbreviatedTimeZoneStandard[zone]}); } } for (zone in data.abbreviatedTimeZoneDST) { if (data.abbreviatedTimeZoneDST.hasOwnProperty(zone)) { data.timezones.push({ name: zone, offset: data.abbreviatedTimeZoneDST[zone], dst: true}); } } return data.timezones; }, days: function () { return __(["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"]); }, dayAbbr: function () { return __(["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"]); }, dayShortNames: function () { return __(["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"]); }, dayFirstLetters: function () { return __(["S_Sun_Initial", "M_Mon_Initial", "T_Tues_Initial", "W_Wed_Initial", "T_Thu_Initial", "F_Fri_Initial", "S_Sat_Initial"]); }, months: function () { return __(["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"]); }, monthAbbr: function () { return __(["Jan_Abbr", "Feb_Abbr", "Mar_Abbr", "Apr_Abbr", "May_Abbr", "Jun_Abbr", "Jul_Abbr", "Aug_Abbr", "Sep_Abbr", "Oct_Abbr", "Nov_Abbr", "Dec_Abbr"]); }, formatPatterns: function () { return getText.getFromObjectValues({ shortDate: "M/d/yyyy", longDate: "dddd, MMMM dd, yyyy", shortTime: "h:mm tt", longTime: "h:mm:ss tt", fullDateTime: "dddd, MMMM dd, yyyy h:mm:ss tt", sortableDateTime: "yyyy-MM-ddTHH:mm:ss", universalSortableDateTime: "yyyy-MM-dd HH:mm:ssZ", rfc1123: "ddd, dd MMM yyyy HH:mm:ss", monthDay: "MMMM dd", yearMonth: "MMMM, yyyy" }, Date.i18n.currentLanguage()); }, regex: function () { return getText.getFromObjectValues({ inTheMorning: "/( in the )(morn(ing)?)\\b/", thisMorning: "/(this )(morn(ing)?)\\b/", amThisMorning: "/(\b\\d(am)? )(this )(morn(ing)?)/", inTheEvening: "/( in the )(even(ing)?)\\b/", thisEvening: "/(this )(even(ing)?)\\b/", pmThisEvening: "/(\b\\d(pm)? )(this )(even(ing)?)/", jan: "/jan(uary)?/", feb: "/feb(ruary)?/", mar: "/mar(ch)?/", apr: "/apr(il)?/", may: "/may/", jun: "/jun(e)?/", jul: "/jul(y)?/", aug: "/aug(ust)?/", sep: "/sep(t(ember)?)?/", oct: "/oct(ober)?/", nov: "/nov(ember)?/", dec: "/dec(ember)?/", sun: "/^su(n(day)?)?/", mon: "/^mo(n(day)?)?/", tue: "/^tu(e(s(day)?)?)?/", wed: "/^we(d(nesday)?)?/", thu: "/^th(u(r(s(day)?)?)?)?/", fri: "/fr(i(day)?)?/", sat: "/^sa(t(urday)?)?/", future: "/^next/", past: "/^last|past|prev(ious)?/", add: "/^(\\+|aft(er)?|from|hence)/", subtract: "/^(\\-|bef(ore)?|ago)/", yesterday: "/^yes(terday)?/", today: "/^t(od(ay)?)?/", tomorrow: "/^tom(orrow)?/", now: "/^n(ow)?/", millisecond: "/^ms|milli(second)?s?/", second: "/^sec(ond)?s?/", minute: "/^mn|min(ute)?s?/", hour: "/^h(our)?s?/", week: "/^w(eek)?s?/", month: "/^m(onth)?s?/", day: "/^d(ay)?s?/", year: "/^y(ear)?s?/", shortMeridian: "/^(a|p)/", longMeridian: "/^(a\\.?m?\\.?|p\\.?m?\\.?)/", timezone: "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/", ordinalSuffix: "/^\\s*(st|nd|rd|th)/", timeContext: "/^\\s*(\\:|a(?!u|p)|p)/" }, Date.i18n.currentLanguage()); } }; var CultureInfo = function () { var info = getText.getFromObjectValues({ name: "name", englishName: "englishName", nativeName: "nativeName", amDesignator: "AM", pmDesignator: "PM", firstDayOfWeek: "firstDayOfWeek", twoDigitYearMax: "twoDigitYearMax", dateElementOrder: "mdy" }, Date.i18n.currentLanguage()); var constructedInfo = buildInfo.buildFromMethodHash({ dayNames: "days", abbreviatedDayNames: "dayAbbr", shortestDayNames: "dayShortNames", firstLetterDayNames: "dayFirstLetters", monthNames: "months", abbreviatedMonthNames: "monthAbbr", formatPatterns: "formatPatterns", regexPatterns: "regex", abbreviatedTimeZoneDST: "timeZoneDST", abbreviatedTimeZoneStandard: "timeZoneStandard" }); shallowMerge(info, constructedInfo); buildInfo.timeZones(info); return info; }; $D.i18n = { __: function (key, lang) { return __(key, lang); }, currentLanguage: function () { return lang || "en-US"; }, setLanguage: function (code, force, cb) { var async = false; if (force || code === "en-US" || (!!Date.CultureStrings && !!Date.CultureStrings[code])) { lang = code; Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings.lang = code; Date.CultureInfo = new CultureInfo(); } else { if (!(!!Date.CultureStrings && !!Date.CultureStrings[code])) { if (typeof exports !== "undefined" && this.exports !== exports) { // we're in a Node enviroment, load it using require try { require("../i18n/" + code + ".js"); lang = code; Date.CultureStrings.lang = code; Date.CultureInfo = new CultureInfo(); } catch (e) { // var str = "The language for '" + code + "' could not be loaded by Node. It likely does not exist."; throw new Error("The DateJS IETF language tag '" + code + "' could not be loaded by Node. It likely does not exist."); } } else if (Date.Config && Date.Config.i18n) { // we know the location of the files, so lets load them async = true; loadI18nScript(code).done(function(){ lang = code; Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings.lang = code; Date.CultureInfo = new CultureInfo(); $D.Parsing.Normalizer.buildReplaceData(); // because this is async if ($D.Grammar) { $D.Grammar.buildGrammarFormats(); // so we can parse those strings... } if (cb) { setTimeout(cb,0); } }); } else { Date.console.error("The DateJS IETF language tag '" + code + "' is not available and has not been loaded."); return false; } } } $D.Parsing.Normalizer.buildReplaceData(); // rebuild normalizer strings if ($D.Grammar) { $D.Grammar.buildGrammarFormats(); // so we can parse those strings... } if (!async && cb) { setTimeout(cb,0); } }, getLoggedKeys: function () { return loggedKeys; }, updateCultureInfo: function () { Date.CultureInfo = new CultureInfo(); } }; $D.i18n.updateCultureInfo(); // run automatically }()); (function () { var $D = Date, $P = $D.prototype, p = function (s, l) { if (!l) { l = 2; } return ("000" + s).slice(l * -1); }; if (typeof window !== "undefined" && typeof window.console !== "undefined" && typeof window.console.log !== "undefined") { $D.console = console; // used only to raise non-critical errors if available } else { // set mock so we don't give errors. $D.console = { log: function(){}, error: function(){} }; } $D.Config = $D.Config || {}; $D.initOverloads = function() { /** * Overload of Date.now. Allows an alternate call for Date.now where it returns the * current Date as an object rather than just milliseconds since the Unix Epoch. * * Also provides an implementation of now() for browsers (IE<9) that don't have it. * * Backwards compatible so with work with either: * Date.now() [returns ms] * or * Date.now(true) [returns Date] */ if (!$D.now) { $D._now = function now() { return new Date().getTime(); }; } else if (!$D._now) { $D._now = $D.now; } $D.now = function (returnObj) { if (returnObj) { return $D.present(); } else { return $D._now(); } }; if ( !$P.toISOString ) { $P.toISOString = function() { return this.getUTCFullYear() + "-" + p(this.getUTCMonth() + 1) + "-" + p(this.getUTCDate()) + "T" + p(this.getUTCHours()) + ":" + p(this.getUTCMinutes()) + ":" + p(this.getUTCSeconds()) + "." + String( (this.getUTCMilliseconds()/1000).toFixed(3)).slice(2, 5) + "Z"; }; } // private if ( $P._toString === undefined ){ $P._toString = $P.toString; } }; $D.initOverloads(); /** * Gets a date that is set to the current date. The time is set to the start of the day (00:00 or 12:00 AM). * @return {Date} The current date. */ $D.today = function () { return new Date().clearTime(); }; /** * Gets a date that is set to the current date and time (same as new Date, but chainable) * @return {Date} The current date. */ $D.present = function () { return new Date(); }; /** * Compares the first date to the second date and returns an number indication of their relative values. * @param {Date} First Date object to compare [Required]. * @param {Date} Second Date object to compare to [Required]. * @return {Number} -1 = date1 is lessthan date2. 0 = values are equal. 1 = date1 is greaterthan date2. */ $D.compare = function (date1, date2) { if (isNaN(date1) || isNaN(date2)) { throw new Error(date1 + " - " + date2); } else if (date1 instanceof Date && date2 instanceof Date) { return (date1 < date2) ? -1 : (date1 > date2) ? 1 : 0; } else { throw new TypeError(date1 + " - " + date2); } }; /** * Compares the first Date object to the second Date object and returns true if they are equal. * @param {Date} First Date object to compare [Required] * @param {Date} Second Date object to compare to [Required] * @return {Boolean} true if dates are equal. false if they are not equal. */ $D.equals = function (date1, date2) { return (date1.compareTo(date2) === 0); }; /** * Gets the language appropriate day name when given the day number(0-6) * eg - 0 == Sunday * @return {String} The day name */ $D.getDayName = function (n) { return Date.CultureInfo.dayNames[n]; }; /** * Gets the day number (0-6) if given a CultureInfo specific string which is a valid dayName, abbreviatedDayName or shortestDayName (two char). * @param {String} The name of the day (eg. "Monday, "Mon", "tuesday", "tue", "We", "we"). * @return {Number} The day number */ $D.getDayNumberFromName = function (name) { var n = Date.CultureInfo.dayNames, m = Date.CultureInfo.abbreviatedDayNames, o = Date.CultureInfo.shortestDayNames, s = name.toLowerCase(); for (var i = 0; i < n.length; i++) { if (n[i].toLowerCase() === s || m[i].toLowerCase() === s || o[i].toLowerCase() === s) { return i; } } return -1; }; /** * Gets the month number (0-11) if given a Culture Info specific string which is a valid monthName or abbreviatedMonthName. * @param {String} The name of the month (eg. "February, "Feb", "october", "oct"). * @return {Number} The day number */ $D.getMonthNumberFromName = function (name) { var n = Date.CultureInfo.monthNames, m = Date.CultureInfo.abbreviatedMonthNames, s = name.toLowerCase(); for (var i = 0; i < n.length; i++) { if (n[i].toLowerCase() === s || m[i].toLowerCase() === s) { return i; } } return -1; }; /** * Gets the language appropriate month name when given the month number(0-11) * eg - 0 == January * @return {String} The month name */ $D.getMonthName = function (n) { return Date.CultureInfo.monthNames[n]; }; /** * Determines if the current date instance is within a LeapYear. * @param {Number} The year. * @return {Boolean} true if date is within a LeapYear, otherwise false. */ $D.isLeapYear = function (year) { return ((year % 4 === 0 && year % 100 !== 0) || year % 400 === 0); }; /** * Gets the number of days in the month, given a year and month value. Automatically corrects for LeapYear. * @param {Number} The year. * @param {Number} The month (0-11). * @return {Number} The number of days in the month. */ $D.getDaysInMonth = function (year, month) { if (!month && $D.validateMonth(year)) { month = year; year = Date.today().getFullYear(); } return [31, ($D.isLeapYear(year) ? 29 : 28), 31, 30, 31, 30, 31, 31, 30, 31, 30, 31][month]; }; $P.getDaysInMonth = function () { return $D.getDaysInMonth(this.getFullYear(), this.getMonth()); }; $D.getTimezoneAbbreviation = function (offset, dst) { var p, n = (dst || false) ? Date.CultureInfo.abbreviatedTimeZoneDST : Date.CultureInfo.abbreviatedTimeZoneStandard; for (p in n) { if (n.hasOwnProperty(p)) { if (n[p] === offset) { return p; } } } return null; }; $D.getTimezoneOffset = function (name, dst) { var i, a =[], z = Date.CultureInfo.timezones; if (!name) { name = (new Date()).getTimezone();} for (i = 0; i < z.length; i++) { if (z[i].name === name.toUpperCase()) { a.push(i); } } if (!z[a[0]]) { return null; } if (a.length === 1 || !dst) { return z[a[0]].offset; } else { for (i=0; i < a.length; i++) { if (z[a[i]].dst) { return z[a[i]].offset; } } } }; $D.getQuarter = function (d) { d = d || new Date(); // If no date supplied, use today var q = [1,2,3,4]; return q[Math.floor(d.getMonth() / 3)]; // ~~~ is a bitwise op. Faster than Math.floor }; $D.getDaysLeftInQuarter = function (d) { d = d || new Date(); var qEnd = new Date(d); qEnd.setMonth(qEnd.getMonth() + 3 - qEnd.getMonth() % 3, 0); return Math.floor((qEnd - d) / 8.64e7); }; // private var validate = function (n, min, max, name) { name = name ? name : "Object"; if (typeof n === "undefined") { return false; } else if (typeof n !== "number") { throw new TypeError(n + " is not a Number."); } else if (n < min || n > max) { // As failing validation is *not* an exceptional circumstance // lets not throw a RangeError Exception here. // It's semantically correct but it's not sensible. return false; } return true; }; /** * Validates the number is within an acceptable range for milliseconds [0-999]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateMillisecond = function (value) { return validate(value, 0, 999, "millisecond"); }; /** * Validates the number is within an acceptable range for seconds [0-59]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateSecond = function (value) { return validate(value, 0, 59, "second"); }; /** * Validates the number is within an acceptable range for minutes [0-59]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateMinute = function (value) { return validate(value, 0, 59, "minute"); }; /** * Validates the number is within an acceptable range for hours [0-23]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateHour = function (value) { return validate(value, 0, 23, "hour"); }; /** * Validates the number is within an acceptable range for the days in a month [0-MaxDaysInMonth]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateDay = function (value, year, month) { if (year === undefined || year === null || month === undefined || month === null) { return false;} return validate(value, 1, $D.getDaysInMonth(year, month), "day"); }; /** * Validates the number is within an acceptable range for months [0-11]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateWeek = function (value) { return validate(value, 0, 53, "week"); }; /** * Validates the number is within an acceptable range for months [0-11]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateMonth = function (value) { return validate(value, 0, 11, "month"); }; /** * Validates the number is within an acceptable range for years. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateYear = function (value) { /** * Per ECMAScript spec the range of times supported by Date objects is * exactly -100,000,000 days to +100,000,000 days measured relative to * midnight at the beginning of 01 January, 1970 UTC. * This gives a range of 8,640,000,000,000,000 milliseconds to either * side of 01 January, 1970 UTC. * * Earliest possible date: Tue, 20 Apr 271,822 B.C. 00:00:00 UTC * Latest possible date: Sat, 13 Sep 275,760 00:00:00 UTC */ return validate(value, -271822, 275760, "year"); }; $D.validateTimezone = function(value) { var timezones = {"ACDT":1,"ACST":1,"ACT":1,"ADT":1,"AEDT":1,"AEST":1,"AFT":1,"AKDT":1,"AKST":1,"AMST":1,"AMT":1,"ART":1,"AST":1,"AWDT":1,"AWST":1,"AZOST":1,"AZT":1,"BDT":1,"BIOT":1,"BIT":1,"BOT":1,"BRT":1,"BST":1,"BTT":1,"CAT":1,"CCT":1,"CDT":1,"CEDT":1,"CEST":1,"CET":1,"CHADT":1,"CHAST":1,"CHOT":1,"ChST":1,"CHUT":1,"CIST":1,"CIT":1,"CKT":1,"CLST":1,"CLT":1,"COST":1,"COT":1,"CST":1,"CT":1,"CVT":1,"CWST":1,"CXT":1,"DAVT":1,"DDUT":1,"DFT":1,"EASST":1,"EAST":1,"EAT":1,"ECT":1,"EDT":1,"EEDT":1,"EEST":1,"EET":1,"EGST":1,"EGT":1,"EIT":1,"EST":1,"FET":1,"FJT":1,"FKST":1,"FKT":1,"FNT":1,"GALT":1,"GAMT":1,"GET":1,"GFT":1,"GILT":1,"GIT":1,"GMT":1,"GST":1,"GYT":1,"HADT":1,"HAEC":1,"HAST":1,"HKT":1,"HMT":1,"HOVT":1,"HST":1,"ICT":1,"IDT":1,"IOT":1,"IRDT":1,"IRKT":1,"IRST":1,"IST":1,"JST":1,"KGT":1,"KOST":1,"KRAT":1,"KST":1,"LHST":1,"LINT":1,"MAGT":1,"MART":1,"MAWT":1,"MDT":1,"MET":1,"MEST":1,"MHT":1,"MIST":1,"MIT":1,"MMT":1,"MSK":1,"MST":1,"MUT":1,"MVT":1,"MYT":1,"NCT":1,"NDT":1,"NFT":1,"NPT":1,"NST":1,"NT":1,"NUT":1,"NZDT":1,"NZST":1,"OMST":1,"ORAT":1,"PDT":1,"PET":1,"PETT":1,"PGT":1,"PHOT":1,"PHT":1,"PKT":1,"PMDT":1,"PMST":1,"PONT":1,"PST":1,"PYST":1,"PYT":1,"RET":1,"ROTT":1,"SAKT":1,"SAMT":1,"SAST":1,"SBT":1,"SCT":1,"SGT":1,"SLST":1,"SRT":1,"SST":1,"SYOT":1,"TAHT":1,"THA":1,"TFT":1,"TJT":1,"TKT":1,"TLT":1,"TMT":1,"TOT":1,"TVT":1,"UCT":1,"ULAT":1,"UTC":1,"UYST":1,"UYT":1,"UZT":1,"VET":1,"VLAT":1,"VOLT":1,"VOST":1,"VUT":1,"WAKT":1,"WAST":1,"WAT":1,"WEDT":1,"WEST":1,"WET":1,"WST":1,"YAKT":1,"YEKT":1,"Z":1}; return (timezones[value] === 1); }; $D.validateTimezoneOffset= function(value) { // timezones go from +14hrs to -12hrs, the +X hours are negative offsets. return (value > -841 && value < 721); }; }()); (function () { var $D = Date, $P = $D.prototype, p = function (s, l) { if (!l) { l = 2; } return ("000" + s).slice(l * -1); }; var validateConfigObject = function (obj) { var result = {}, self = this, prop, testFunc; testFunc = function (prop, func, value) { if (prop === "day") { var month = (obj.month !== undefined) ? obj.month : self.getMonth(); var year = (obj.year !== undefined) ? obj.year : self.getFullYear(); return $D[func](value, year, month); } else { return $D[func](value); } }; for (prop in obj) { if (Object.prototype.hasOwnProperty.call(obj, prop)) { var func = "validate" + prop.charAt(0).toUpperCase() + prop.slice(1); if ($D[func] && obj[prop] !== null && testFunc(prop, func, obj[prop])) { result[prop] = obj[prop]; } } } return result; }; /** * Resets the time of this Date object to 12:00 AM (00:00), which is the start of the day. * @param {Boolean} .clone() this date instance before clearing Time * @return {Date} this */ $P.clearTime = function () { this.setHours(0); this.setMinutes(0); this.setSeconds(0); this.setMilliseconds(0); return this; }; /** * Resets the time of this Date object to the current time ('now'). * @return {Date} this */ $P.setTimeToNow = function () { var n = new Date(); this.setHours(n.getHours()); this.setMinutes(n.getMinutes()); this.setSeconds(n.getSeconds()); this.setMilliseconds(n.getMilliseconds()); return this; }; /** * Returns a new Date object that is an exact date and time copy of the original instance. * @return {Date} A new Date instance */ $P.clone = function () { return new Date(this.getTime()); }; /** * Compares this instance to a Date object and returns an number indication of their relative values. * @param {Date} Date object to compare [Required] * @return {Number} -1 = this is lessthan date. 0 = values are equal. 1 = this is greaterthan date. */ $P.compareTo = function (date) { return Date.compare(this, date); }; /** * Compares this instance to another Date object and returns true if they are equal. * @param {Date} Date object to compare. If no date to compare, new Date() [now] is used. * @return {Boolean} true if dates are equal. false if they are not equal. */ $P.equals = function (date) { return Date.equals(this, (date !== undefined ? date : new Date())); }; /** * Determines if this instance is between a range of two dates or equal to either the start or end dates. * @param {Date} Start of range [Required] * @param {Date} End of range [Required] * @return {Boolean} true is this is between or equal to the start and end dates, else false */ $P.between = function (start, end) { return this.getTime() >= start.getTime() && this.getTime() <= end.getTime(); }; /** * Determines if this date occurs after the date to compare to. * @param {Date} Date object to compare. If no date to compare, new Date() ("now") is used. * @return {Boolean} true if this date instance is greater than the date to compare to (or "now"), otherwise false. */ $P.isAfter = function (date) { return this.compareTo(date || new Date()) === 1; }; /** * Determines if this date occurs before the date to compare to. * @param {Date} Date object to compare. If no date to compare, new Date() ("now") is used. * @return {Boolean} true if this date instance is less than the date to compare to (or "now"). */ $P.isBefore = function (date) { return (this.compareTo(date || new Date()) === -1); }; /** * Determines if the current Date instance occurs today. * @return {Boolean} true if this date instance is 'today', otherwise false. */ /** * Determines if the current Date instance occurs on the same Date as the supplied 'date'. * If no 'date' to compare to is provided, the current Date instance is compared to 'today'. * @param {date} Date object to compare. If no date to compare, the current Date ("now") is used. * @return {Boolean} true if this Date instance occurs on the same Day as the supplied 'date'. */ $P.isToday = $P.isSameDay = function (date) { return this.clone().clearTime().equals((date || new Date()).clone().clearTime()); }; /** * Adds the specified number of milliseconds to this instance. * @param {Number} The number of milliseconds to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addMilliseconds = function (value) { if (!value) { return this; } this.setTime(this.getTime() + value * 1); return this; }; /** * Adds the specified number of seconds to this instance. * @param {Number} The number of seconds to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addSeconds = function (value) { if (!value) { return this; } return this.addMilliseconds(value * 1000); }; /** * Adds the specified number of seconds to this instance. * @param {Number} The number of seconds to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addMinutes = function (value) { if (!value) { return this; } return this.addMilliseconds(value * 60000); // 60*1000 }; /** * Adds the specified number of hours to this instance. * @param {Number} The number of hours to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addHours = function (value) { if (!value) { return this; } return this.addMilliseconds(value * 3600000); // 60*60*1000 }; /** * Adds the specified number of days to this instance. * @param {Number} The number of days to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addDays = function (value) { if (!value) { return this; } this.setDate(this.getDate() + value * 1); return this; }; /** * Adds the specified number of weekdays (ie - not sat or sun) to this instance. * @param {Number} The number of days to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addWeekdays = function (value) { if (!value) { return this; } var day = this.getDay(); var weeks = (Math.ceil(Math.abs(value)/7)); if (day === 0 || day === 6) { if (value > 0) { this.next().monday(); this.addDays(-1); day = this.getDay(); } } if (value < 0) { while (value < 0) { this.addDays(-1); day = this.getDay(); if (day !== 0 && day !== 6) { value++; } } return this; } else if (value > 5 || (6-day) <= value) { value = value + (weeks * 2); } return this.addDays(value); }; /** * Adds the specified number of weeks to this instance. * @param {Number} The number of weeks to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addWeeks = function (value) { if (!value) { return this; } return this.addDays(value * 7); }; /** * Adds the specified number of months to this instance. * @param {Number} The number of months to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addMonths = function (value) { if (!value) { return this; } var n = this.getDate(); this.setDate(1); this.setMonth(this.getMonth() + value * 1); this.setDate(Math.min(n, $D.getDaysInMonth(this.getFullYear(), this.getMonth()))); return this; }; $P.addQuarters = function (value) { if (!value) { return this; } // note this will take you to the same point in the quarter as you are now. // i.e. - if you are 15 days into the quarter you'll be 15 days into the resulting one. // bonus: this allows adding fractional quarters return this.addMonths(value * 3); }; /** * Adds the specified number of years to this instance. * @param {Number} The number of years to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addYears = function (value) { if (!value) { return this; } return this.addMonths(value * 12); }; /** * Adds (or subtracts) to the value of the years, months, weeks, days, hours, minutes, seconds, milliseconds of the date instance using given configuration object. Positive and Negative values allowed. * Example

	Date.today().add( { days: 1, months: 1 } )

	new Date().add( { years: -1 } )
	
* @param {Object} Configuration object containing attributes (months, days, etc.) * @return {Date} this */ $P.add = function (config) { if (typeof config === "number") { this._orient = config; return this; } var x = config; if (x.day) { // If we should be a different date than today (eg: for 'tomorrow -1d', etc). // Should only effect parsing, not direct usage (eg, Finish and FinishExact) if ((x.day - this.getDate()) !== 0) { this.setDate(x.day); } } if (x.milliseconds) { this.addMilliseconds(x.milliseconds); } if (x.seconds) { this.addSeconds(x.seconds); } if (x.minutes) { this.addMinutes(x.minutes); } if (x.hours) { this.addHours(x.hours); } if (x.weeks) { this.addWeeks(x.weeks); } if (x.months) { this.addMonths(x.months); } if (x.years) { this.addYears(x.years); } if (x.days) { this.addDays(x.days); } return this; }; /** * Get the week number. Week one (1) is the week which contains the first Thursday of the year. Monday is considered the first day of the week. * The .getWeek() function does NOT convert the date to UTC. The local datetime is used. * Please use .getISOWeek() to get the week of the UTC converted date. * @return {Number} 1 to 53 */ $P.getWeek = function (utc) { // Create a copy of this date object var self, target = new Date(this.valueOf()); if (utc) { target.addMinutes(target.getTimezoneOffset()); self = target.clone(); } else { self = this; } // ISO week date weeks start on monday // so correct the day number var dayNr = (self.getDay() + 6) % 7; // ISO 8601 states that week 1 is the week // with the first thursday of that year. // Set the target date to the thursday in the target week target.setDate(target.getDate() - dayNr + 3); // Store the millisecond value of the target date var firstThursday = target.valueOf(); // Set the target to the first thursday of the year // First set the target to january first target.setMonth(0, 1); // Not a thursday? Correct the date to the next thursday if (target.getDay() !== 4) { target.setMonth(0, 1 + ((4 - target.getDay()) + 7) % 7); } // The weeknumber is the number of weeks between the // first thursday of the year and the thursday in the target week return 1 + Math.ceil((firstThursday - target) / 604800000); // 604800000 = 7 * 24 * 3600 * 1000 }; /** * Get the ISO 8601 week number. Week one ("01") is the week which contains the first Thursday of the year. Monday is considered the first day of the week. * The .getISOWeek() function does convert the date to it's UTC value. Please use .getWeek() to get the week of the local date. * @return {String} "01" to "53" */ $P.getISOWeek = function () { return p(this.getWeek(true)); }; /** * Moves the date to Monday of the week set. Week one (1) is the week which contains the first Thursday of the year. * @param {Number} A Number (1 to 53) that represents the week of the year. * @return {Date} this */ $P.setWeek = function (n) { if ((n - this.getWeek()) === 0) { if (this.getDay() !== 1) { return this.moveToDayOfWeek(1, (this.getDay() > 1 ? -1 : 1)); } else { return this; } } else { return this.moveToDayOfWeek(1, (this.getDay() > 1 ? -1 : 1)).addWeeks(n - this.getWeek()); } }; $P.setQuarter = function (qtr) { var month = Math.abs(((qtr-1) * 3) + 1); return this.setMonth(month, 1); }; $P.getQuarter = function () { return Date.getQuarter(this); }; $P.getDaysLeftInQuarter = function () { return Date.getDaysLeftInQuarter(this); }; /** * Moves the date to the next n'th occurrence of the dayOfWeek starting from the beginning of the month. The number (-1) is a magic number and will return the last occurrence of the dayOfWeek in the month. * @param {Number} The dayOfWeek to move to * @param {Number} The n'th occurrence to move to. Use (-1) to return the last occurrence in the month * @return {Date} this */ $P.moveToNthOccurrence = function (dayOfWeek, occurrence) { if (dayOfWeek === "Weekday") { if (occurrence > 0) { this.moveToFirstDayOfMonth(); if (this.is().weekday()) { occurrence -= 1; } } else if (occurrence < 0) { this.moveToLastDayOfMonth(); if (this.is().weekday()) { occurrence += 1; } } else { return this; } return this.addWeekdays(occurrence); } var shift = 0; if (occurrence > 0) { shift = occurrence - 1; } else if (occurrence === -1) { this.moveToLastDayOfMonth(); if (this.getDay() !== dayOfWeek) { this.moveToDayOfWeek(dayOfWeek, -1); } return this; } return this.moveToFirstDayOfMonth().addDays(-1).moveToDayOfWeek(dayOfWeek, +1).addWeeks(shift); }; var moveToN = function (getFunc, addFunc, nVal) { return function (value, orient) { var diff = (value - this[getFunc]() + nVal * (orient || +1)) % nVal; return this[addFunc]((diff === 0) ? diff += nVal * (orient || +1) : diff); }; }; /** * Move to the next or last dayOfWeek based on the orient value. * @param {Number} The dayOfWeek to move to * @param {Number} Forward (+1) or Back (-1). Defaults to +1. [Optional] * @return {Date} this */ $P.moveToDayOfWeek = moveToN("getDay", "addDays", 7); /** * Move to the next or last month based on the orient value. * @param {Number} The month to move to. 0 = January, 11 = December * @param {Number} Forward (+1) or Back (-1). Defaults to +1. [Optional] * @return {Date} this */ $P.moveToMonth = moveToN("getMonth", "addMonths", 12); /** * Get the Ordinate of the current day ("th", "st", "rd"). * @return {String} */ $P.getOrdinate = function () { var num = this.getDate(); return ord(num); }; /** * Get the Ordinal day (numeric day number) of the year, adjusted for leap year. * @return {Number} 1 through 365 (366 in leap years) */ $P.getOrdinalNumber = function () { return Math.ceil((this.clone().clearTime() - new Date(this.getFullYear(), 0, 1)) / 86400000) + 1; }; /** * Get the time zone abbreviation of the current date. * @return {String} The abbreviated time zone name (e.g. "EST") */ $P.getTimezone = function () { return $D.getTimezoneAbbreviation(this.getUTCOffset(), this.isDaylightSavingTime()); }; $P.setTimezoneOffset = function (offset) { var here = this.getTimezoneOffset(), there = Number(offset) * -6 / 10; return (there || there === 0) ? this.addMinutes(there - here) : this; }; $P.setTimezone = function (offset) { return this.setTimezoneOffset($D.getTimezoneOffset(offset)); }; /** * Indicates whether Daylight Saving Time is observed in the current time zone. * @return {Boolean} true|false */ $P.hasDaylightSavingTime = function () { return (Date.today().set({month: 0, day: 1}).getTimezoneOffset() !== Date.today().set({month: 6, day: 1}).getTimezoneOffset()); }; /** * Indicates whether this Date instance is within the Daylight Saving Time range for the current time zone. * @return {Boolean} true|false */ $P.isDaylightSavingTime = function () { return Date.today().set({month: 0, day: 1}).getTimezoneOffset() !== this.getTimezoneOffset(); }; /** * Get the offset from UTC of the current date. * @return {String} The 4-character offset string prefixed with + or - (e.g. "-0500") */ $P.getUTCOffset = function (offset) { var n = (offset || this.getTimezoneOffset()) * -10 / 6, r; if (n < 0) { r = (n - 10000).toString(); return r.charAt(0) + r.substr(2); } else { r = (n + 10000).toString(); return "+" + r.substr(1); } }; /** * Returns the number of milliseconds between this date and date. * @param {Date} Defaults to now * @return {Number} The diff in milliseconds */ $P.getElapsed = function (date) { return (date || new Date()) - this; }; /** * Set the value of year, month, day, hour, minute, second, millisecond of date instance using given configuration object. * Example

	Date.today().set( { day: 20, month: 1 } )

	new Date().set( { millisecond: 0 } )
	
* * @param {Object} Configuration object containing attributes (month, day, etc.) * @return {Date} this */ $P.set = function (config) { config = validateConfigObject.call(this, config); var key; for (key in config) { if (Object.prototype.hasOwnProperty.call(config, key)) { var name = key.charAt(0).toUpperCase() + key.slice(1); var addFunc, getFunc; if (key !== "week" && key !== "month" && key !== "timezone" && key !== "timezoneOffset") { name += "s"; } addFunc = "add" + name; getFunc = "get" + name; if (key === "month") { addFunc = addFunc + "s"; } else if (key === "year"){ getFunc = "getFullYear"; } if (key !== "day" && key !== "timezone" && key !== "timezoneOffset" && key !== "week" && key !== "hour") { this[addFunc](config[key] - this[getFunc]()); } else if ( key === "timezone"|| key === "timezoneOffset" || key === "week" || key === "hour") { this["set"+name](config[key]); } } } // day has to go last because you can't validate the day without first knowing the month if (config.day) { this.addDays(config.day - this.getDate()); } return this; }; /** * Moves the date to the first day of the month. * @return {Date} this */ $P.moveToFirstDayOfMonth = function () { return this.set({ day: 1 }); }; /** * Moves the date to the last day of the month. * @return {Date} this */ $P.moveToLastDayOfMonth = function () { return this.set({ day: $D.getDaysInMonth(this.getFullYear(), this.getMonth())}); }; /** * Converts the value of the current Date object to its equivalent string representation. * Format Specifiers * CUSTOM DATE AND TIME FORMAT STRINGS * Format Description Example * ------ --------------------------------------------------------------------------- ----------------------- * s The seconds of the minute between 0-59. "0" to "59" * ss The seconds of the minute with leading zero if required. "00" to "59" * * m The minute of the hour between 0-59. "0" or "59" * mm The minute of the hour with leading zero if required. "00" or "59" * * h The hour of the day between 1-12. "1" to "12" * hh The hour of the day with leading zero if required. "01" to "12" * * H The hour of the day between 0-23. "0" to "23" * HH The hour of the day with leading zero if required. "00" to "23" * * d The day of the month between 1 and 31. "1" to "31" * dd The day of the month with leading zero if required. "01" to "31" * ddd Abbreviated day name. Date.CultureInfo.abbreviatedDayNames. "Mon" to "Sun" * dddd The full day name. Date.CultureInfo.dayNames. "Monday" to "Sunday" * * M The month of the year between 1-12. "1" to "12" * MM The month of the year with leading zero if required. "01" to "12" * MMM Abbreviated month name. Date.CultureInfo.abbreviatedMonthNames. "Jan" to "Dec" * MMMM The full month name. Date.CultureInfo.monthNames. "January" to "December" * * yy The year as a two-digit number. "99" or "08" * yyyy The full four digit year. "1999" or "2008" * * t Displays the first character of the A.M./P.M. designator. "A" or "P" * Date.CultureInfo.amDesignator or Date.CultureInfo.pmDesignator * tt Displays the A.M./P.M. designator. "AM" or "PM" * Date.CultureInfo.amDesignator or Date.CultureInfo.pmDesignator * * S The ordinal suffix ("st, "nd", "rd" or "th") of the current day. "st, "nd", "rd" or "th" * * STANDARD DATE AND TIME FORMAT STRINGS * Format Description Example *------ --------------------------------------------------------------------------- ----------------------- * d The CultureInfo shortDate Format Pattern "M/d/yyyy" * D The CultureInfo longDate Format Pattern "dddd, MMMM dd, yyyy" * F The CultureInfo fullDateTime Format Pattern "dddd, MMMM dd, yyyy h:mm:ss tt" * m The CultureInfo monthDay Format Pattern "MMMM dd" * r The CultureInfo rfc1123 Format Pattern "ddd, dd MMM yyyy HH:mm:ss GMT" * s The CultureInfo sortableDateTime Format Pattern "yyyy-MM-ddTHH:mm:ss" * t The CultureInfo shortTime Format Pattern "h:mm tt" * T The CultureInfo longTime Format Pattern "h:mm:ss tt" * u The CultureInfo universalSortableDateTime Format Pattern "yyyy-MM-dd HH:mm:ssZ" * y The CultureInfo yearMonth Format Pattern "MMMM, yyyy" * * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @return {String} A string representation of the current Date object. */ var ord = function (n) { switch (n * 1) { case 1: case 21: case 31: return "st"; case 2: case 22: return "nd"; case 3: case 23: return "rd"; default: return "th"; } }; var parseStandardFormats = function (format) { var y, c = Date.CultureInfo.formatPatterns; switch (format) { case "d": return this.toString(c.shortDate); case "D": return this.toString(c.longDate); case "F": return this.toString(c.fullDateTime); case "m": return this.toString(c.monthDay); case "r": case "R": y = this.clone().addMinutes(this.getTimezoneOffset()); return y.toString(c.rfc1123) + " GMT"; case "s": return this.toString(c.sortableDateTime); case "t": return this.toString(c.shortTime); case "T": return this.toString(c.longTime); case "u": y = this.clone().addMinutes(this.getTimezoneOffset()); return y.toString(c.universalSortableDateTime); case "y": return this.toString(c.yearMonth); default: return false; } }; var parseFormatStringsClosure = function (context) { return function (m) { if (m.charAt(0) === "\\") { return m.replace("\\", ""); } switch (m) { case "hh": return p(context.getHours() < 13 ? (context.getHours() === 0 ? 12 : context.getHours()) : (context.getHours() - 12)); case "h": return context.getHours() < 13 ? (context.getHours() === 0 ? 12 : context.getHours()) : (context.getHours() - 12); case "HH": return p(context.getHours()); case "H": return context.getHours(); case "mm": return p(context.getMinutes()); case "m": return context.getMinutes(); case "ss": return p(context.getSeconds()); case "s": return context.getSeconds(); case "yyyy": return p(context.getFullYear(), 4); case "yy": return p(context.getFullYear()); case "y": return context.getFullYear(); case "E": case "dddd": return Date.CultureInfo.dayNames[context.getDay()]; case "ddd": return Date.CultureInfo.abbreviatedDayNames[context.getDay()]; case "dd": return p(context.getDate()); case "d": return context.getDate(); case "MMMM": return Date.CultureInfo.monthNames[context.getMonth()]; case "MMM": return Date.CultureInfo.abbreviatedMonthNames[context.getMonth()]; case "MM": return p((context.getMonth() + 1)); case "M": return context.getMonth() + 1; case "t": return context.getHours() < 12 ? Date.CultureInfo.amDesignator.substring(0, 1) : Date.CultureInfo.pmDesignator.substring(0, 1); case "tt": return context.getHours() < 12 ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator; case "S": return ord(context.getDate()); case "W": return context.getWeek(); case "WW": return context.getISOWeek(); case "Q": return "Q" + context.getQuarter(); case "q": return String(context.getQuarter()); case "z": return context.getTimezone(); case "Z": case "X": return Date.getTimezoneOffset(context.getTimezone()); case "ZZ": // Timezone offset in seconds return context.getTimezoneOffset() * -60; case "u": return context.getDay(); case "L": return ($D.isLeapYear(context.getFullYear())) ? 1 : 0; case "B": // Swatch Internet Time (.beats) return "@"+((context.getUTCSeconds() + (context.getUTCMinutes()*60) + ((context.getUTCHours()+1)*3600))/86.4); default: return m; } }; }; $P.toString = function (format, ignoreStandards) { // Standard Date and Time Format Strings. Formats pulled from CultureInfo file and // may vary by culture. if (!ignoreStandards && format && format.length === 1) { output = parseStandardFormats.call(this, format); if (output) { return output; } } var parseFormatStrings = parseFormatStringsClosure(this); return format ? format.replace(/((\\)?(dd?d?d?|MM?M?M?|yy?y?y?|hh?|HH?|mm?|ss?|tt?|S|q|Q|WW?W?W?)(?![^\[]*\]))/g, parseFormatStrings).replace(/\[|\]/g, "") : this._toString(); }; }()); /************************************************************* * SugarPak - Domain Specific Language - Syntactical Sugar * *************************************************************/ (function () { var $D = Date, $P = $D.prototype, $N = Number.prototype; // private $P._orient = +1; // private $P._nth = null; // private $P._is = false; // private $P._same = false; // private $P._isSecond = false; // private $N._dateElement = "days"; /** * Moves the date to the next instance of a date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.today().next().friday();
	Date.today().next().fri();
	Date.today().next().march();
	Date.today().next().mar();
	Date.today().next().week();
	
* * @return {Date} date */ $P.next = function () { this._move = true; this._orient = +1; return this; }; /** * Creates a new Date (Date.today()) and moves the date to the next instance of the date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.next().friday();
	Date.next().fri();
	Date.next().march();
	Date.next().mar();
	Date.next().week();
	
* * @return {Date} date */ $D.next = function () { return $D.today().next(); }; /** * Moves the date to the previous instance of a date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.today().last().friday();
	Date.today().last().fri();
	Date.today().last().march();
	Date.today().last().mar();
	Date.today().last().week();
	
* * @return {Date} date */ $P.last = $P.prev = $P.previous = function () { this._move = true; this._orient = -1; return this; }; /** * Creates a new Date (Date.today()) and moves the date to the previous instance of the date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.last().friday();
	Date.last().fri();
	Date.previous().march();
	Date.prev().mar();
	Date.last().week();
	
* * @return {Date} date */ $D.last = $D.prev = $D.previous = function () { return $D.today().last(); }; /** * Performs a equality check when followed by either a month name, day name or .weekday() function. * Example

	Date.today().is().friday(); // true|false
	Date.today().is().fri();
	Date.today().is().march();
	Date.today().is().mar();
	
* * @return {Boolean} true|false */ $P.is = function () { this._is = true; return this; }; /** * Determines if two date objects occur on/in exactly the same instance of the subsequent date part function. * The function .same() must be followed by a date part function (example: .day(), .month(), .year(), etc). * * An optional Date can be passed in the date part function. If now date is passed as a parameter, 'Now' is used. * * The following example demonstrates how to determine if two dates fall on the exact same day. * * Example

	var d1 = Date.today(); // today at 00:00
	var d2 = new Date();   // exactly now.

	// Do they occur on the same day?
	d1.same().day(d2); // true
	
	// Do they occur on the same hour?
	d1.same().hour(d2); // false, unless d2 hour is '00' (midnight).
	
	// What if it's the same day, but one year apart?
	var nextYear = Date.today().add(1).year();

	d1.same().day(nextYear); // false, because the dates must occur on the exact same day. 
	
* * Scenario: Determine if a given date occurs during some week period 2 months from now. * * Example

	var future = Date.today().add(2).months();
	return someDate.same().week(future); // true|false;
	
* * @return {Boolean} true|false */ $P.same = function () { this._same = true; this._isSecond = false; return this; }; /** * Determines if the current date/time occurs during Today. Must be preceded by the .is() function. * Example

	someDate.is().today();    // true|false
	new Date().is().today();  // true
	Date.today().is().today();// true
	Date.today().add(-1).day().is().today(); // false
	
* * @return {Boolean} true|false */ $P.today = function () { return this.same().day(); }; /** * Determines if the current date is a weekday. This function must be preceded by the .is() function. * Example

	Date.today().is().weekday(); // true|false
	
* * @return {Boolean} true|false */ $P.weekday = function () { if (this._nth) { return df("Weekday").call(this); } if (this._move) { return this.addWeekdays(this._orient); } if (this._is) { this._is = false; return (!this.is().sat() && !this.is().sun()); } return false; }; /** * Determines if the current date is on the weekend. This function must be preceded by the .is() function. * Example

	Date.today().is().weekend(); // true|false
	
* * @return {Boolean} true|false */ $P.weekend = function () { if (this._is) { this._is = false; return (this.is().sat() || this.is().sun()); } return false; }; /** * Sets the Time of the current Date instance. A string "6:15 pm" or config object {hour:18, minute:15} are accepted. * Example

	// Set time to 6:15pm with a String
	Date.today().at("6:15pm");

	// Set time to 6:15pm with a config object
	Date.today().at({hour:18, minute:15});
	
* * @return {Date} date */ $P.at = function (time) { return (typeof time === "string") ? $D.parse(this.toString("d") + " " + time) : this.set(time); }; /** * Creates a new Date() and adds this (Number) to the date based on the preceding date element function (eg. second|minute|hour|day|month|year). * Example

	// Undeclared Numbers must be wrapped with parentheses. Requirment of JavaScript.
	(3).days().fromNow();
	(6).months().fromNow();

	// Declared Number variables do not require parentheses. 
	var n = 6;
	n.months().fromNow();
	
* * @return {Date} A new Date instance */ $N.fromNow = $N.after = function (date) { var c = {}; c[this._dateElement] = this; return ((!date) ? new Date() : date.clone()).add(c); }; /** * Creates a new Date() and subtract this (Number) from the date based on the preceding date element function (eg. second|minute|hour|day|month|year). * Example

	// Undeclared Numbers must be wrapped with parentheses. Requirment of JavaScript.
	(3).days().ago();
	(6).months().ago();

	// Declared Number variables do not require parentheses. 
	var n = 6;
	n.months().ago();
	
* * @return {Date} A new Date instance */ $N.ago = $N.before = function (date) { var c = {}, s = (this._dateElement[this._dateElement.length-1] !== "s") ? this._dateElement + "s" : this._dateElement; c[s] = this * -1; return ((!date) ? new Date() : date.clone()).add(c); }; // Do NOT modify the following string tokens. These tokens are used to build dynamic functions. // All culture-specific strings can be found in the CultureInfo files. var dx = ("sunday monday tuesday wednesday thursday friday saturday").split(/\s/), mx = ("january february march april may june july august september october november december").split(/\s/), px = ("Millisecond Second Minute Hour Day Week Month Year Quarter Weekday").split(/\s/), pxf = ("Milliseconds Seconds Minutes Hours Date Week Month FullYear Quarter").split(/\s/), nth = ("final first second third fourth fifth").split(/\s/), de; /** * Returns an object literal of all the date parts. * Example

	var o = new Date().toObject();
	
	// { year: 2008, month: 4, week: 20, day: 13, hour: 18, minute: 9, second: 32, millisecond: 812 }
	
	// The object properties can be referenced directly from the object.
	
	alert(o.day);  // alerts "13"
	alert(o.year); // alerts "2008"
	
* * @return {Date} An object literal representing the original date object. */ $P.toObject = function () { var o = {}; for (var i = 0; i < px.length; i++) { if (this["get" + pxf[i]]) { o[px[i].toLowerCase()] = this["get" + pxf[i]](); } } return o; }; /** * Returns a date created from an object literal. Ignores the .week property if set in the config. * Example

	var o = new Date().toObject();
	
	return Date.fromObject(o); // will return the same date. 

	var o2 = {month: 1, day: 20, hour: 18}; // birthday party!
	Date.fromObject(o2);
	
* * @return {Date} An object literal representing the original date object. */ $D.fromObject = function(config) { config.week = null; return Date.today().set(config); }; // Create day name functions and abbreviated day name functions (eg. monday(), friday(), fri()). var df = function (n) { return function () { if (this._is) { this._is = false; return this.getDay() === n; } if (this._move) { this._move = null; } if (this._nth !== null) { // If the .second() function was called earlier, remove the _orient // from the date, and then continue. // This is required because 'second' can be used in two different context. // // Example // // Date.today().add(1).second(); // Date.march().second().monday(); // // Things get crazy with the following... // Date.march().add(1).second().second().monday(); // but it works!! // if (this._isSecond) { this.addSeconds(this._orient * -1); } // make sure we reset _isSecond this._isSecond = false; var ntemp = this._nth; this._nth = null; var temp = this.clone().moveToLastDayOfMonth(); this.moveToNthOccurrence(n, ntemp); if (this > temp) { throw new RangeError($D.getDayName(n) + " does not occur " + ntemp + " times in the month of " + $D.getMonthName(temp.getMonth()) + " " + temp.getFullYear() + "."); } return this; } return this.moveToDayOfWeek(n, this._orient); }; }; var sdf = function (n) { return function () { var t = $D.today(), shift = n - t.getDay(); if (n === 0 && Date.CultureInfo.firstDayOfWeek === 1 && t.getDay() !== 0) { shift = shift + 7; } return t.addDays(shift); }; }; // Create month name functions and abbreviated month name functions (eg. january(), march(), mar()). var month_instance_functions = function (n) { return function () { if (this._is) { this._is = false; return this.getMonth() === n; } return this.moveToMonth(n, this._orient); }; }; var month_static_functions = function (n) { return function () { return $D.today().set({ month: n, day: 1 }); }; }; var processTerms = function (names, staticFunc, instanceFunc) { for (var i = 0; i < names.length; i++) { // Create constant static Name variables. $D[names[i].toUpperCase()] = $D[names[i].toUpperCase().substring(0, 3)] = i; // Create Name functions. $D[names[i]] = $D[names[i].substring(0, 3)] = staticFunc(i); // Create Name instance functions. $P[names[i]] = $P[names[i].substring(0, 3)] = instanceFunc(i); } }; processTerms(dx, sdf, df); processTerms(mx, month_static_functions, month_instance_functions); // Create date element functions and plural date element functions used with Date (eg. day(), days(), months()). var ef = function (j) { return function () { // if the .second() function was called earlier, the _orient // has alread been added. Just return this and reset _isSecond. if (this._isSecond) { this._isSecond = false; return this; } if (this._same) { this._same = this._is = false; var o1 = this.toObject(), o2 = (arguments[0] || new Date()).toObject(), v = "", k = j.toLowerCase(); // the substr trick with -1 doesn't work in IE8 or less k = (k[k.length-1] === "s") ? k.substring(0,k.length-1) : k; for (var m = (px.length - 1); m > -1; m--) { v = px[m].toLowerCase(); if (o1[v] !== o2[v]) { return false; } if (k === v) { break; } } return true; } if (j.substring(j.length - 1) !== "s") { j += "s"; } if (this._move) { this._move = null; } return this["add" + j](this._orient); }; }; var nf = function (n) { return function () { this._dateElement = n; return this; }; }; for (var k = 0; k < px.length; k++) { de = px[k].toLowerCase(); if(de !== "weekday") { // Create date element functions and plural date element functions used with Date (eg. day(), days(), months()). $P[de] = $P[de + "s"] = ef(px[k]); // Create date element functions and plural date element functions used with Number (eg. day(), days(), months()). $N[de] = $N[de + "s"] = nf(de + "s"); } } $P._ss = ef("Second"); var nthfn = function (n) { return function (dayOfWeek) { if (this._same) { return this._ss(arguments[0]); } if (dayOfWeek || dayOfWeek === 0) { return this.moveToNthOccurrence(dayOfWeek, n); } this._nth = n; // if the operator is 'second' add the _orient, then deal with it later... if (n === 2 && (dayOfWeek === undefined || dayOfWeek === null)) { this._isSecond = true; return this.addSeconds(this._orient); } return this; }; }; for (var l = 0; l < nth.length; l++) { $P[nth[l]] = (l === 0) ? nthfn(-1) : nthfn(l); } }()); (function () { "use strict"; Date.Parsing = { Exception: function (s) { this.message = "Parse error at '" + s.substring(0, 10) + " ...'"; } }; var $P = Date.Parsing; var dayOffsets = { standard: [0,31,59,90,120,151,181,212,243,273,304,334], leap: [0,31,60,91,121,152,182,213,244,274,305,335] }; $P.isLeapYear = function(year) { return ((year % 4 === 0) && (year % 100 !== 0)) || (year % 400 === 0); }; var utils = { multiReplace : function (str, hash ) { var key; for (key in hash) { if (Object.prototype.hasOwnProperty.call(hash, key)) { var regex; if (typeof hash[key] === "function") { } else { regex = (hash[key] instanceof RegExp) ? hash[key] : new RegExp(hash[key], "g"); } str = str.replace(regex, key); } } return str; }, getDayOfYearFromWeek : function (obj) { var d, jan4, offset; obj.weekDay = (!obj.weekDay && obj.weekDay !== 0) ? 1 : obj.weekDay; d = new Date(obj.year, 0, 4); jan4 = d.getDay() === 0 ? 7 : d.getDay(); // JS is 0 indexed on Sunday. offset = jan4+3; obj.dayOfYear = ((obj.week * 7) + (obj.weekDay === 0 ? 7 : obj.weekDay))-offset; return obj; }, getDayOfYear : function (obj, dayOffset) { if (!obj.dayOfYear) { obj = utils.getDayOfYearFromWeek(obj); } for (var i=0;i <= dayOffset.length;i++) { if (obj.dayOfYear < dayOffset[i] || i === dayOffset.length) { obj.day = obj.day ? obj.day : (obj.dayOfYear - dayOffset[i-1]); break; } else { obj.month = i; } } return obj; }, adjustForTimeZone : function (obj, date) { var offset; if (obj.zone.toUpperCase() === "Z" || (obj.zone_hours === 0 && obj.zone_minutes === 0)) { // it's UTC/GML so work out the current timeszone offset offset = -date.getTimezoneOffset(); } else { offset = (obj.zone_hours*60) + (obj.zone_minutes || 0); if (obj.zone_sign === "+") { offset *= -1; } offset -= date.getTimezoneOffset(); } date.setMinutes(date.getMinutes()+offset); return date; }, setDefaults : function (obj) { obj.year = obj.year || Date.today().getFullYear(); obj.hours = obj.hours || 0; obj.minutes = obj.minutes || 0; obj.seconds = obj.seconds || 0; obj.milliseconds = obj.milliseconds || 0; if (!(!obj.month && (obj.week || obj.dayOfYear))) { // if we have a month, or if we don't but don't have the day calculation data obj.month = obj.month || 0; obj.day = obj.day || 1; } return obj; }, dataNum: function (data, mod, explict, postProcess) { var dataNum = data*1; if (mod) { if (postProcess) { return data ? mod(data)*1 : data; } else { return data ? mod(dataNum) : data; } } else if (!explict){ return data ? dataNum : data; } else { return (data && typeof data !== "undefined") ? dataNum : data; } }, timeDataProcess: function (obj) { var timeObj = {}; for (var x in obj.data) { if (obj.data.hasOwnProperty(x)) { timeObj[x] = obj.ignore[x] ? obj.data[x] : utils.dataNum(obj.data[x], obj.mods[x], obj.explict[x], obj.postProcess[x]); } } if (obj.data.secmins) { obj.data.secmins = obj.data.secmins.replace(",", ".") * 60; if (!timeObj.minutes) { timeObj.minutes = obj.data.secmins; } else if (!timeObj.seconds) { timeObj.seconds = obj.data.secmins; } delete obj.secmins; } return timeObj; }, buildTimeObjectFromData: function (data) { var time = utils.timeDataProcess({ data: { year : data[1], month : data[5], day : data[7], week : data[8], dayOfYear : data[10], hours : data[15], zone_hours : data[23], zone_minutes : data[24], zone : data[21], zone_sign : data[22], weekDay : data[9], minutes: data[16], seconds: data[19], milliseconds: data[20], secmins: data[18] }, mods: { month: function(data) { return data-1; }, weekDay: function (data) { data = Math.abs(data); return (data === 7 ? 0 : data); }, minutes: function (data) { return data.replace(":",""); }, seconds: function (data) { return Math.floor( (data.replace(":","").replace(",","."))*1 ); }, milliseconds: function (data) { return (data.replace(",",".")*1000); } }, postProcess: { minutes: true, seconds: true, milliseconds: true }, explict: { zone_hours: true, zone_minutes: true }, ignore: { zone: true, zone_sign: true, secmins: true } }); return time; }, addToHash: function (hash, keys, data) { keys = keys; data = data; var len = keys.length; for (var i = 0; i < len; i++) { hash[keys[i]] = data[i]; } return hash; }, combineRegex: function (r1, r2) { return new RegExp("(("+r1.source+")\\s("+r2.source+"))"); }, getDateNthString: function(add, last, inc){ if (add) { return Date.today().addDays(inc).toString("d"); } else if (last) { return Date.today().last()[inc]().toString("d"); } }, buildRegexData: function (array) { var arr = []; var len = array.length; for (var i=0; i < len; i++) { if (Object.prototype.toString.call(array[i]) === '[object Array]') { // oldIE compat version of Array.isArray arr.push(this.combineRegex(array[i][0], array[i][1])); } else { arr.push(array[i]); } } return arr; } }; $P.processTimeObject = function (obj) { var date, dayOffset; utils.setDefaults(obj); dayOffset = ($P.isLeapYear(obj.year)) ? dayOffsets.leap : dayOffsets.standard; if (!obj.month && (obj.week || obj.dayOfYear)) { utils.getDayOfYear(obj, dayOffset); } else { obj.dayOfYear = dayOffset[obj.month] + obj.day; } date = new Date(obj.year, obj.month, obj.day, obj.hours, obj.minutes, obj.seconds, obj.milliseconds); if (obj.zone) { utils.adjustForTimeZone(obj, date); // adjust (and calculate) for timezone } return date; }; $P.ISO = { regex : /^([\+-]?\d{4}(?!\d{2}\b))((-?)((0[1-9]|1[0-2])(\3([12]\d|0[1-9]|3[01]))?|W([0-4]\d|5[0-3])(-?[1-7])?|(00[1-9]|0[1-9]\d|[12]\d{2}|3([0-5]\d|6[1-6])))([T\s]((([01]\d|2[0-4])((:?)[0-5]\d)?|24\:?00)([\.,]\d+(?!:))?)?(\17[0-5]\d([\.,]\d+)?)?\s?([zZ]|([\+-])([01]\d|2[0-3]):?([0-5]\d)?)?)?)?$/, parse : function (s) { var time, data = s.match(this.regex); if (!data || !data.length) { return null; } time = utils.buildTimeObjectFromData(data); if (!time.year || (!time.year && (!time.month && !time.day) && (!time.week && !time.dayOfYear)) ) { return null; } return $P.processTimeObject(time); } }; $P.Numeric = { isNumeric: function (e){return!isNaN(parseFloat(e))&&isFinite(e);}, regex: /\b([0-1]?[0-9])([0-3]?[0-9])([0-2]?[0-9]?[0-9][0-9])\b/i, parse: function (s) { var data, i, time = {}, order = Date.CultureInfo.dateElementOrder.split(""); if (!(this.isNumeric(s)) || // if it's non-numeric OR (s[0] === "+" && s[0] === "-")) { // It's an arithmatic string (eg +/-1000) return null; } if (s.length < 5 && s.indexOf(".") < 0 && s.indexOf("/") < 0) { // assume it's just a year. time.year = s; return $P.processTimeObject(time); } data = s.match(this.regex); if (!data || !data.length) { return null; } for (i=0; i < order.length; i++) { switch(order[i]) { case "d": time.day = data[i+1]; break; case "m": time.month = (data[i+1]-1); break; case "y": time.year = data[i+1]; break; } } return $P.processTimeObject(time); } }; $P.Normalizer = { regexData: function () { var $R = Date.CultureInfo.regexPatterns; return utils.buildRegexData([ $R.tomorrow, $R.yesterday, [$R.past, $R.mon], [$R.past, $R.tue], [$R.past, $R.wed], [$R.past, $R.thu], [$R.past, $R.fri], [$R.past, $R.sat], [$R.past, $R.sun] ]); }, basicReplaceHash : function() { var $R = Date.CultureInfo.regexPatterns; return { "January": $R.jan.source, "February": $R.feb, "March": $R.mar, "April": $R.apr, "May": $R.may, "June": $R.jun, "July": $R.jul, "August": $R.aug, "September": $R.sep, "October": $R.oct, "November": $R.nov, "December": $R.dec, "": /\bat\b/gi, " ": /\s{2,}/, "am": $R.inTheMorning, "9am": $R.thisMorning, "pm": $R.inTheEvening, "7pm":$R.thisEvening }; }, keys : function(){ return [ utils.getDateNthString(true, false, 1), // tomorrow utils.getDateNthString(true, false, -1), // yesterday utils.getDateNthString(false, true, "monday"), //last mon utils.getDateNthString(false, true, "tuesday"), //last tues utils.getDateNthString(false, true, "wednesday"), //last wed utils.getDateNthString(false, true, "thursday"), //last thurs utils.getDateNthString(false, true, "friday"), //last fri utils.getDateNthString(false, true, "saturday"), //last sat utils.getDateNthString(false, true, "sunday") //last sun ]; }, buildRegexFunctions: function () { var $R = Date.CultureInfo.regexPatterns; var __ = Date.i18n.__; var tomorrowRE = new RegExp("(\\b\\d\\d?("+__("AM")+"|"+__("PM")+")? )("+$R.tomorrow.source.slice(1)+")", "i"); // adapted tomorrow regex for AM PM relative dates var todayRE = new RegExp($R.today.source + "(?!\\s*([+-]))\\b"); // today, but excludes the math operators (eg "today + 2h") this.replaceFuncs = [ [todayRE, function (full) { return (full.length > 1) ? Date.today().toString("d") : full; }], [tomorrowRE, function(full, m1) { var t = Date.today().addDays(1).toString("d"); return (t + " " + m1); }], [$R.amThisMorning, function(str, am){return am;}], [$R.pmThisEvening, function(str, pm){return pm;}] ]; }, buildReplaceData: function () { this.buildRegexFunctions(); this.replaceHash = utils.addToHash(this.basicReplaceHash(), this.keys(), this.regexData()); }, stringReplaceFuncs: function (s) { for (var i=0; i < this.replaceFuncs.length; i++) { s = s.replace(this.replaceFuncs[i][0], this.replaceFuncs[i][1]); } return s; }, parse: function (s) { s = this.stringReplaceFuncs(s); s = utils.multiReplace(s, this.replaceHash); try { var n = s.split(/([\s\-\.\,\/\x27]+)/); if (n.length === 3 && $P.Numeric.isNumeric(n[0]) && $P.Numeric.isNumeric(n[2]) && (n[2].length >= 4)) { // ok, so we're dealing with x/year. But that's not a full date. // This fixes wonky dateElementOrder parsing when set to dmy order. if (Date.CultureInfo.dateElementOrder[0] === "d") { s = "1/" + n[0] + "/" + n[2]; // set to 1st of month and normalize the seperator } } } catch (e) {} return s; } }; $P.Normalizer.buildReplaceData(); }()); (function () { var $P = Date.Parsing; var _ = $P.Operators = { // // Tokenizers // rtoken: function (r) { // regex token return function (s) { var mx = s.match(r); if (mx) { return ([ mx[0], s.substring(mx[0].length) ]); } else { throw new $P.Exception(s); } }; }, token: function () { // whitespace-eating token return function (s) { return _.rtoken(new RegExp("^\\s*" + s + "\\s*"))(s); }; }, stoken: function (s) { // string token return _.rtoken(new RegExp("^" + s)); }, // Atomic Operators until: function (p) { return function (s) { var qx = [], rx = null; while (s.length) { try { rx = p.call(this, s); } catch (e) { qx.push(rx[0]); s = rx[1]; continue; } break; } return [ qx, s ]; }; }, many: function (p) { return function (s) { var rx = [], r = null; while (s.length) { try { r = p.call(this, s); } catch (e) { return [ rx, s ]; } rx.push(r[0]); s = r[1]; } return [ rx, s ]; }; }, // generator operators -- see below optional: function (p) { return function (s) { var r = null; try { r = p.call(this, s); } catch (e) { return [ null, s ]; } return [ r[0], r[1] ]; }; }, not: function (p) { return function (s) { try { p.call(this, s); } catch (e) { return [null, s]; } throw new $P.Exception(s); }; }, ignore: function (p) { return p ? function (s) { var r = null; r = p.call(this, s); return [null, r[1]]; } : null; }, product: function () { var px = arguments[0], qx = Array.prototype.slice.call(arguments, 1), rx = []; for (var i = 0 ; i < px.length ; i++) { rx.push(_.each(px[i], qx)); } return rx; }, cache: function (rule) { var cache = {}, cache_length = 0, cache_keys = [], CACHE_MAX = Date.Config.CACHE_MAX || 100000, r = null; var cacheCheck = function () { if (cache_length === CACHE_MAX) { // kill several keys, don't want to have to do this all the time... for (var i=0; i < 10; i++) { var key = cache_keys.shift(); if (key) { delete cache[key]; cache_length--; } } } }; return function (s) { cacheCheck(); try { r = cache[s] = (cache[s] || rule.call(this, s)); } catch (e) { r = cache[s] = e; } cache_length++; cache_keys.push(s); if (r instanceof $P.Exception) { throw r; } else { return r; } }; }, // vector operators -- see below any: function () { var px = arguments; return function (s) { var r = null; for (var i = 0; i < px.length; i++) { if (px[i] == null) { continue; } try { r = (px[i].call(this, s)); } catch (e) { r = null; } if (r) { return r; } } throw new $P.Exception(s); }; }, each: function () { var px = arguments; return function (s) { var rx = [], r = null; for (var i = 0; i < px.length ; i++) { if (px[i] == null) { continue; } try { r = (px[i].call(this, s)); } catch (e) { throw new $P.Exception(s); } rx.push(r[0]); s = r[1]; } return [ rx, s]; }; }, all: function () { var px = arguments, _ = _; return _.each(_.optional(px)); }, // delimited operators sequence: function (px, d, c) { d = d || _.rtoken(/^\s*/); c = c || null; if (px.length === 1) { return px[0]; } return function (s) { var r = null, q = null; var rx = []; for (var i = 0; i < px.length ; i++) { try { r = px[i].call(this, s); } catch (e) { break; } rx.push(r[0]); try { q = d.call(this, r[1]); } catch (ex) { q = null; break; } s = q[1]; } if (!r) { throw new $P.Exception(s); } if (q) { throw new $P.Exception(q[1]); } if (c) { try { r = c.call(this, r[1]); } catch (ey) { throw new $P.Exception(r[1]); } } return [ rx, (r?r[1]:s) ]; }; }, // // Composite Operators // between: function (d1, p, d2) { d2 = d2 || d1; var _fn = _.each(_.ignore(d1), p, _.ignore(d2)); return function (s) { var rx = _fn.call(this, s); return [[rx[0][0], r[0][2]], rx[1]]; }; }, list: function (p, d, c) { d = d || _.rtoken(/^\s*/); c = c || null; return (p instanceof Array ? _.each(_.product(p.slice(0, -1), _.ignore(d)), p.slice(-1), _.ignore(c)) : _.each(_.many(_.each(p, _.ignore(d))), px, _.ignore(c))); }, set: function (px, d, c) { d = d || _.rtoken(/^\s*/); c = c || null; return function (s) { // r is the current match, best the current 'best' match // which means it parsed the most amount of input var r = null, p = null, q = null, rx = null, best = [[], s], last = false; // go through the rules in the given set for (var i = 0; i < px.length ; i++) { // last is a flag indicating whether this must be the last element // if there is only 1 element, then it MUST be the last one q = null; p = null; r = null; last = (px.length === 1); // first, we try simply to match the current pattern // if not, try the next pattern try { r = px[i].call(this, s); } catch (e) { continue; } // since we are matching against a set of elements, the first // thing to do is to add r[0] to matched elements rx = [[r[0]], r[1]]; // if we matched and there is still input to parse and // we don't already know this is the last element, // we're going to next check for the delimiter ... // if there's none, or if there's no input left to parse // than this must be the last element after all ... if (r[1].length > 0 && ! last) { try { q = d.call(this, r[1]); } catch (ex) { last = true; } } else { last = true; } // if we parsed the delimiter and now there's no more input, // that means we shouldn't have parsed the delimiter at all // so don't update r and mark this as the last element ... if (!last && q[1].length === 0) { last = true; } // so, if this isn't the last element, we're going to see if // we can get any more matches from the remaining (unmatched) // elements ... if (!last) { // build a list of the remaining rules we can match against, // i.e., all but the one we just matched against var qx = []; for (var j = 0; j < px.length ; j++) { if (i !== j) { qx.push(px[j]); } } // now invoke recursively set with the remaining input // note that we don't include the closing delimiter ... // we'll check for that ourselves at the end p = _.set(qx, d).call(this, q[1]); // if we got a non-empty set as a result ... // (otw rx already contains everything we want to match) if (p[0].length > 0) { // update current result, which is stored in rx ... // basically, pick up the remaining text from p[1] // and concat the result from p[0] so that we don't // get endless nesting ... rx[0] = rx[0].concat(p[0]); rx[1] = p[1]; } } // at this point, rx either contains the last matched element // or the entire matched set that starts with this element. // now we just check to see if this variation is better than // our best so far, in terms of how much of the input is parsed if (rx[1].length < best[1].length) { best = rx; } // if we've parsed all the input, then we're finished if (best[1].length === 0) { break; } } // so now we've either gone through all the patterns trying them // as the initial match; or we found one that parsed the entire // input string ... // if best has no matches, just return empty set ... if (best[0].length === 0) { return best; } // if a closing delimiter is provided, then we have to check it also if (c) { // we try this even if there is no remaining input because the pattern // may well be optional or match empty input ... try { q = c.call(this, best[1]); } catch (ey) { throw new $P.Exception(best[1]); } // it parsed ... be sure to update the best match remaining input best[1] = q[1]; } // if we're here, either there was no closing delimiter or we parsed it // so now we have the best match; just return it! return best; }; }, forward: function (gr, fname) { return function (s) { return gr[fname].call(this, s); }; }, // // Translation Operators // replace: function (rule, repl) { return function (s) { var r = rule.call(this, s); return [repl, r[1]]; }; }, process: function (rule, fn) { return function (s) { var r = rule.call(this, s); return [fn.call(this, r[0]), r[1]]; }; }, min: function (min, rule) { return function (s) { var rx = rule.call(this, s); if (rx[0].length < min) { throw new $P.Exception(s); } return rx; }; } }; // Generator Operators And Vector Operators // Generators are operators that have a signature of F(R) => R, // taking a given rule and returning another rule, such as // ignore, which parses a given rule and throws away the result. // Vector operators are those that have a signature of F(R1,R2,...) => R, // take a list of rules and returning a new rule, such as each. // Generator operators are converted (via the following _generator // function) into functions that can also take a list or array of rules // and return an array of new rules as though the function had been // called on each rule in turn (which is what actually happens). // This allows generators to be used with vector operators more easily. // Example: // each(ignore(foo, bar)) instead of each(ignore(foo), ignore(bar)) // This also turns generators into vector operators, which allows // constructs like: // not(cache(foo, bar)) var _generator = function (op) { function gen() { var args = null, rx = [], px, i; if (arguments.length > 1) { args = Array.prototype.slice.call(arguments); } else if (arguments[0] instanceof Array) { args = arguments[0]; } if (args) { px = args.shift(); if (px.length > 0) { args.unshift(px[i]); rx.push(op.apply(null, args)); args.shift(); return rx; } } else { return op.apply(null, arguments); } } return gen; }; var gx = "optional not ignore cache".split(/\s/); for (var i = 0 ; i < gx.length ; i++) { _[gx[i]] = _generator(_[gx[i]]); } var _vector = function (op) { return function () { if (arguments[0] instanceof Array) { return op.apply(null, arguments[0]); } else { return op.apply(null, arguments); } }; }; var vx = "each any all".split(/\s/); for (var j = 0 ; j < vx.length ; j++) { _[vx[j]] = _vector(_[vx[j]]); } }()); (function () { var $D = Date; var flattenAndCompact = function (ax) { var rx = []; for (var i = 0; i < ax.length; i++) { if (ax[i] instanceof Array) { rx = rx.concat(flattenAndCompact(ax[i])); } else { if (ax[i]) { rx.push(ax[i]); } } } return rx; }; var parseMeridian = function () { if (this.meridian && (this.hour || this.hour === 0)) { if (this.meridian === "a" && this.hour > 11 && Date.Config.strict24hr){ throw "Invalid hour and meridian combination"; } else if (this.meridian === "p" && this.hour < 12 && Date.Config.strict24hr){ throw "Invalid hour and meridian combination"; } else if (this.meridian === "p" && this.hour < 12) { this.hour = this.hour + 12; } else if (this.meridian === "a" && this.hour === 12) { this.hour = 0; } } }; var setDefaults = function () { var now = new Date(); if ((this.hour || this.minute) && (!this.month && !this.year && !this.day)) { this.day = now.getDate(); } if (!this.year) { this.year = now.getFullYear(); } if (!this.month && this.month !== 0) { this.month = now.getMonth(); } if (!this.day) { this.day = 1; } if (!this.hour) { this.hour = 0; } if (!this.minute) { this.minute = 0; } if (!this.second) { this.second = 0; } if (!this.millisecond) { this.millisecond = 0; } }; var finishUtils = { getToday: function () { if (this.now || "hour minute second".indexOf(this.unit) !== -1) { return new Date(); } else { return $D.today(); } }, setDaysFromWeekday: function (today, orient){ var gap; orient = orient || 1; this.unit = "day"; gap = ($D.getDayNumberFromName(this.weekday) - today.getDay()); this.days = gap ? ((gap + (orient * 7)) % 7) : (orient * 7); return this; }, setMonthsFromMonth: function (today, orient) { var gap; orient = orient || 1; this.unit = "month"; gap = (this.month - today.getMonth()); this.months = gap ? ((gap + (orient * 12)) % 12) : (orient * 12); this.month = null; return this; }, setDMYFromWeekday: function () { var d = Date[this.weekday](); this.day = d.getDate(); if (!this.month) { this.month = d.getMonth(); } this.year = d.getFullYear(); return this; }, setUnitValue: function (orient) { if (!this.value && this.operator && this.operator !== null && this[this.unit + "s"] && this[this.unit + "s"] !== null) { this[this.unit + "s"] = this[this.unit + "s"] + ((this.operator === "add") ? 1 : -1) + (this.value||0) * orient; } else if (this[this.unit + "s"] == null || this.operator != null) { if (!this.value) { this.value = 1; } this[this.unit + "s"] = this.value * orient; } }, generateDateFromWeeks: function () { var weekday = (this.weekday !== undefined) ? this.weekday : "today"; var d = Date[weekday]().addWeeks(this.weeks); if (this.now) { d.setTimeToNow(); } return d; } }; $D.Translator = { hour: function (s) { return function () { this.hour = Number(s); }; }, minute: function (s) { return function () { this.minute = Number(s); }; }, second: function (s) { return function () { this.second = Number(s); }; }, /* for ss.s format */ secondAndMillisecond: function (s) { return function () { var mx = s.match(/^([0-5][0-9])\.([0-9]{1,3})/); this.second = Number(mx[1]); this.millisecond = Number(mx[2]); }; }, meridian: function (s) { return function () { this.meridian = s.slice(0, 1).toLowerCase(); }; }, timezone: function (s) { return function () { var n = s.replace(/[^\d\+\-]/g, ""); if (n.length) { this.timezoneOffset = Number(n); } else { this.timezone = s.toLowerCase(); } }; }, day: function (x) { var s = x[0]; return function () { this.day = Number(s.match(/\d+/)[0]); if (this.day < 1) { throw "invalid day"; } }; }, month: function (s) { return function () { this.month = (s.length === 3) ? "jan feb mar apr may jun jul aug sep oct nov dec".indexOf(s)/4 : Number(s) - 1; if (this.month < 0) { throw "invalid month"; } }; }, year: function (s) { return function () { var n = Number(s); this.year = ((s.length > 2) ? n : (n + (((n + 2000) < Date.CultureInfo.twoDigitYearMax) ? 2000 : 1900))); }; }, rday: function (s) { return function () { switch (s) { case "yesterday": this.days = -1; break; case "tomorrow": this.days = 1; break; case "today": this.days = 0; break; case "now": this.days = 0; this.now = true; break; } }; }, finishExact: function (x) { var d; x = (x instanceof Array) ? x : [x]; for (var i = 0 ; i < x.length ; i++) { if (x[i]) { x[i].call(this); } } setDefaults.call(this); parseMeridian.call(this); if (this.day > $D.getDaysInMonth(this.year, this.month)) { throw new RangeError(this.day + " is not a valid value for days."); } d = new Date(this.year, this.month, this.day, this.hour, this.minute, this.second, this.millisecond); if (this.year < 100) { d.setFullYear(this.year); // means years less that 100 are process correctly. JS will parse it otherwise as 1900-1999. } if (this.timezone) { d.set({ timezone: this.timezone }); } else if (this.timezoneOffset) { d.set({ timezoneOffset: this.timezoneOffset }); } return d; }, finish: function (x) { var today, expression, orient, temp; x = (x instanceof Array) ? flattenAndCompact(x) : [ x ]; if (x.length === 0) { return null; } for (var i = 0 ; i < x.length ; i++) { if (typeof x[i] === "function") { x[i].call(this); } } if (this.now && !this.unit && !this.operator) { return new Date(); } else { today = finishUtils.getToday.call(this); } expression = !!(this.days && this.days !== null || this.orient || this.operator); orient = ((this.orient === "past" || this.operator === "subtract") ? -1 : 1); if (this.month && this.unit === "week") { this.value = this.month + 1; delete this.month; delete this.day; } if ((this.month || this.month === 0) && "year day hour minute second".indexOf(this.unit) !== -1) { if (!this.value) { this.value = this.month + 1; } this.month = null; expression = true; } if (!expression && this.weekday && !this.day && !this.days) { finishUtils.setDMYFromWeekday.call(this); } if (expression && this.weekday && this.unit !== "month" && this.unit !== "week") { finishUtils.setDaysFromWeekday.call(this, today, orient); } if (this.weekday && this.unit !== "week" && !this.day && !this.days) { temp = Date[this.weekday](); this.day = temp.getDate(); if (temp.getMonth() !== today.getMonth()) { this.month = temp.getMonth(); } } if (this.month && this.unit === "day" && this.operator) { if (!this.value) { this.value = (this.month + 1); } this.month = null; } if (this.value != null && this.month != null && this.year != null) { this.day = this.value * 1; } if (this.month && !this.day && this.value) { today.set({ day: this.value * 1 }); if (!expression) { this.day = this.value * 1; } } if (!this.month && this.value && this.unit === "month" && !this.now) { this.month = this.value; expression = true; } if (expression && (this.month || this.month === 0) && this.unit !== "year") { finishUtils.setMonthsFromMonth.call(this, today, orient); } if (!this.unit) { this.unit = "day"; } finishUtils.setUnitValue.call(this, orient); parseMeridian.call(this); if ((this.month || this.month === 0) && !this.day) { this.day = 1; } if (!this.orient && !this.operator && this.unit === "week" && this.value && !this.day && !this.month) { return Date.today().setWeek(this.value); } if (this.unit === "week" && this.weeks && !this.day && !this.month) { return finishUtils.generateDateFromWeeks.call(this); } if (expression && this.timezone && this.day && this.days) { this.day = this.days; } if (expression){ today.add(this); } else { today.set(this); } if (this.timezone) { this.timezone = this.timezone.toUpperCase(); var offset = $D.getTimezoneOffset(this.timezone); var timezone; if (today.hasDaylightSavingTime()) { // lets check that we're being sane with timezone setting timezone = $D.getTimezoneAbbreviation(offset, today.isDaylightSavingTime()); if (timezone !== this.timezone) { // bugger, we're in a place where things like EST vs EDT matters. if (today.isDaylightSavingTime()) { today.addHours(-1); } else { today.addHours(1); } } } today.setTimezoneOffset(offset); } return today; } }; }()); (function () { var $D = Date; $D.Grammar = {}; var _ = $D.Parsing.Operators, g = $D.Grammar, t = $D.Translator, _fn; // Allow rolling up into general purpose rules _fn = function () { return _.each(_.any.apply(null, arguments), _.not(g.ctoken2("timeContext"))); }; g.datePartDelimiter = _.rtoken(/^([\s\-\.\,\/\x27]+)/); g.timePartDelimiter = _.stoken(":"); g.whiteSpace = _.rtoken(/^\s*/); g.generalDelimiter = _.rtoken(/^(([\s\,]|at|@|on)+)/); var _C = {}; g.ctoken = function (keys) { var fn = _C[keys]; if (! fn) { var c = Date.CultureInfo.regexPatterns; var kx = keys.split(/\s+/), px = []; for (var i = 0; i < kx.length ; i++) { px.push(_.replace(_.rtoken(c[kx[i]]), kx[i])); } fn = _C[keys] = _.any.apply(null, px); } return fn; }; g.ctoken2 = function (key) { return _.rtoken(Date.CultureInfo.regexPatterns[key]); }; var cacheProcessRtoken = function (key, token, type, eachToken) { if (eachToken) { g[key] = _.cache(_.process(_.each(_.rtoken(token),_.optional(g.ctoken2(eachToken))), type)); } else { g[key] = _.cache(_.process(_.rtoken(token), type)); } }; var cacheProcessCtoken = function (token, type) { return _.cache(_.process(g.ctoken2(token), type)); }; var _F = {}; //function cache var _get = function (f) { _F[f] = (_F[f] || g.format(f)[0]); return _F[f]; }; g.allformats = function (fx) { var rx = []; if (fx instanceof Array) { for (var i = 0; i < fx.length; i++) { rx.push(_get(fx[i])); } } else { rx.push(_get(fx)); } return rx; }; g.formats = function (fx) { if (fx instanceof Array) { var rx = []; for (var i = 0 ; i < fx.length ; i++) { rx.push(_get(fx[i])); } return _.any.apply(null, rx); } else { return _get(fx); } }; var grammarFormats = { timeFormats: function(){ var i, RTokenKeys = [ "h", "hh", "H", "HH", "m", "mm", "s", "ss", "ss.s", "z", "zz" ], RToken = [ /^(0[0-9]|1[0-2]|[1-9])/, /^(0[0-9]|1[0-2])/, /^([0-1][0-9]|2[0-3]|[0-9])/, /^([0-1][0-9]|2[0-3])/, /^([0-5][0-9]|[0-9])/, /^[0-5][0-9]/, /^([0-5][0-9]|[0-9])/, /^[0-5][0-9]/, /^[0-5][0-9]\.[0-9]{1,3}/, /^((\+|\-)\s*\d\d\d\d)|((\+|\-)\d\d\:?\d\d)/, /^((\+|\-)\s*\d\d\d\d)|((\+|\-)\d\d\:?\d\d)/ ], tokens = [ t.hour, t.hour, t.hour, t.hour, t.minute, t.minute, t.second, t.second, t.secondAndMillisecond, t.timezone, t.timezone ]; for (i=0; i < RTokenKeys.length; i++) { cacheProcessRtoken(RTokenKeys[i], RToken[i], tokens[i]); } g.hms = _.cache(_.sequence([g.H, g.m, g.s], g.timePartDelimiter)); g.t = cacheProcessCtoken("shortMeridian", t.meridian); g.tt = cacheProcessCtoken("longMeridian", t.meridian); g.zzz = cacheProcessCtoken("timezone", t.timezone); g.timeSuffix = _.each(_.ignore(g.whiteSpace), _.set([ g.tt, g.zzz ])); g.time = _.each(_.optional(_.ignore(_.stoken("T"))), g.hms, g.timeSuffix); }, dateFormats: function () { // pre-loaded rules for different date part order preferences var _setfn = function () { return _.set(arguments, g.datePartDelimiter); }; var i, RTokenKeys = [ "d", "dd", "M", "MM", "y", "yy", "yyy", "yyyy" ], RToken = [ /^([0-2]\d|3[0-1]|\d)/, /^([0-2]\d|3[0-1])/, /^(1[0-2]|0\d|\d)/, /^(1[0-2]|0\d)/, /^(\d+)/, /^(\d\d)/, /^(\d\d?\d?\d?)/, /^(\d\d\d\d)/ ], tokens = [ t.day, t.day, t.month, t.month, t.year, t.year, t.year, t.year ], eachToken = [ "ordinalSuffix", "ordinalSuffix" ]; for (i=0; i < RTokenKeys.length; i++) { cacheProcessRtoken(RTokenKeys[i], RToken[i], tokens[i], eachToken[i]); } g.MMM = g.MMMM = _.cache(_.process(g.ctoken("jan feb mar apr may jun jul aug sep oct nov dec"), t.month)); g.ddd = g.dddd = _.cache(_.process(g.ctoken("sun mon tue wed thu fri sat"), function (s) { return function () { this.weekday = s; }; } )); g.day = _fn(g.d, g.dd); g.month = _fn(g.M, g.MMM); g.year = _fn(g.yyyy, g.yy); g.mdy = _setfn(g.ddd, g.month, g.day, g.year); g.ymd = _setfn(g.ddd, g.year, g.month, g.day); g.dmy = _setfn(g.ddd, g.day, g.month, g.year); g.date = function (s) { return ((g[Date.CultureInfo.dateElementOrder] || g.mdy).call(this, s)); }; }, relative: function () { // relative date / time expressions g.orientation = _.process(g.ctoken("past future"), function (s) { return function () { this.orient = s; }; } ); g.operator = _.process(g.ctoken("add subtract"), function (s) { return function () { this.operator = s; }; } ); g.rday = _.process(g.ctoken("yesterday tomorrow today now"), t.rday); g.unit = _.process(g.ctoken("second minute hour day week month year"), function (s) { return function () { this.unit = s; }; } ); } }; g.buildGrammarFormats = function () { // these need to be rebuilt every time the language changes. _C = {}; grammarFormats.timeFormats(); grammarFormats.dateFormats(); grammarFormats.relative(); g.value = _.process(_.rtoken(/^([-+]?\d+)?(st|nd|rd|th)?/), function (s) { return function () { this.value = s.replace(/\D/g, ""); }; } ); g.expression = _.set([g.rday, g.operator, g.value, g.unit, g.orientation, g.ddd, g.MMM ]); g.format = _.process(_.many( _.any( // translate format specifiers into grammar rules _.process( _.rtoken(/^(dd?d?d?(?!e)|MM?M?M?|yy?y?y?|hh?|HH?|mm?|ss?|tt?|zz?z?)/), function (fmt) { if (g[fmt]) { return g[fmt]; } else { throw $D.Parsing.Exception(fmt); } } ), // translate separator tokens into token rules _.process(_.rtoken(/^[^dMyhHmstz]+/), // all legal separators function (s) { return _.ignore(_.stoken(s)); } ) ) ), // construct the parser ... function (rules) { return _.process(_.each.apply(null, rules), t.finishExact); } ); // starting rule for general purpose grammar g._start = _.process(_.set([ g.date, g.time, g.expression ], g.generalDelimiter, g.whiteSpace), t.finish); }; g.buildGrammarFormats(); // parsing date format specifiers - ex: "h:m:s tt" // this little guy will generate a custom parser based // on the format string, ex: g.format("h:m:s tt") // check for these formats first g._formats = g.formats([ "\"yyyy-MM-ddTHH:mm:ssZ\"", "yyyy-MM-ddTHH:mm:ss.sz", "yyyy-MM-ddTHH:mm:ssZ", "yyyy-MM-ddTHH:mm:ssz", "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-ddTHH:mmZ", "yyyy-MM-ddTHH:mmz", "yyyy-MM-ddTHH:mm", "ddd, MMM dd, yyyy H:mm:ss tt", "ddd MMM d yyyy HH:mm:ss zzz", "MMddyyyy", "ddMMyyyy", "Mddyyyy", "ddMyyyy", "Mdyyyy", "dMyyyy", "yyyy", "Mdyy", "dMyy", "d" ]); // real starting rule: tries selected formats first, // then general purpose rule g.start = function (s) { try { var r = g._formats.call({}, s); if (r[1].length === 0) { return r; } } catch (e) {} return g._start.call({}, s); }; }()); (function () { var $D = Date; /** * @desc Converts the specified string value into its JavaScript Date equivalent using CultureInfo specific format information. * * Example

	///////////
	// Dates //
	///////////

	// 15-Oct-2004
	var d1 = Date.parse("10/15/2004");

	// 15-Oct-2004
	var d1 = Date.parse("15-Oct-2004");

	// 15-Oct-2004
	var d1 = Date.parse("2004.10.15");

	//Fri Oct 15, 2004
	var d1 = Date.parse("Fri Oct 15, 2004");

	///////////
	// Times //
	///////////

	// Today at 10 PM.
	var d1 = Date.parse("10 PM");

	// Today at 10:30 PM.
	var d1 = Date.parse("10:30 P.M.");

	// Today at 6 AM.
	var d1 = Date.parse("06am");

	/////////////////////
	// Dates and Times //
	/////////////////////

	// 8-July-2004 @ 10:30 PM
	var d1 = Date.parse("July 8th, 2004, 10:30 PM");

	// 1-July-2004 @ 10:30 PM
	var d1 = Date.parse("2004-07-01T22:30:00");

	////////////////////
	// Relative Dates //
	////////////////////

	// Returns today's date. The string "today" is culture specific.
	var d1 = Date.parse("today");

	// Returns yesterday's date. The string "yesterday" is culture specific.
	var d1 = Date.parse("yesterday");

	// Returns the date of the next thursday.
	var d1 = Date.parse("Next thursday");

	// Returns the date of the most previous monday.
	var d1 = Date.parse("last monday");

	// Returns today's day + one year.
	var d1 = Date.parse("next year");

	///////////////
	// Date Math //
	///////////////

	// Today + 2 days
	var d1 = Date.parse("t+2");

	// Today + 2 days
	var d1 = Date.parse("today + 2 days");

	// Today + 3 months
	var d1 = Date.parse("t+3m");

	// Today - 1 year
	var d1 = Date.parse("today - 1 year");

	// Today - 1 year
	var d1 = Date.parse("t-1y"); 


	/////////////////////////////
	// Partial Dates and Times //
	/////////////////////////////

	// July 15th of this year.
	var d1 = Date.parse("July 15");

	// 15th day of current day and year.
	var d1 = Date.parse("15");

	// July 1st of current year at 10pm.
	var d1 = Date.parse("7/1 10pm");
	
* * @param {String} The string value to convert into a Date object [Required] * @return {Date} A Date object or null if the string cannot be converted into a Date. */ var parseUtils = { removeOrds: function (s) { ords = s.match(/\b(\d+)(?:st|nd|rd|th)\b/); // find ordinal matches s = ((ords && ords.length === 2) ? s.replace(ords[0], ords[1]) : s); return s; }, grammarParser: function (s) { var r = null; try { r = $D.Grammar.start.call({}, s.replace(/^\s*(\S*(\s+\S+)*)\s*$/, "$1")); } catch (e) { return null; } return ((r[1].length === 0) ? r[0] : null); }, nativeFallback: function(s) { var t; try { // ok we haven't parsed it, last ditch attempt with the built-in parser. t = Date._parse(s); return (t || t === 0) ? new Date(t) : null; } catch (e) { return null; } } }; function parse (s) { var d; if (!s) { return null; } if (s instanceof Date) { return s.clone(); } if (s.length >= 4 && s.charAt(0) !== "0" && s.charAt(0) !== "+"&& s.charAt(0) !== "-") { // ie: 2004 will pass, 0800 won't. // Start with specific formats d = $D.Parsing.ISO.parse(s) || $D.Parsing.Numeric.parse(s); } if (d instanceof Date && !isNaN(d.getTime())) { return d; } else { // find ordinal dates (1st, 3rd, 8th, etc and remove them as they cause parsing issues) s = $D.Parsing.Normalizer.parse(parseUtils.removeOrds(s)); d = parseUtils.grammarParser(s); if (d !== null) { return d; } else { return parseUtils.nativeFallback(s); } } } if (!$D._parse) { $D._parse = $D.parse; } $D.parse = parse; Date.getParseFunction = function (fx) { var fns = Date.Grammar.allformats(fx); return function (s) { var r = null; for (var i = 0; i < fns.length; i++) { try { r = fns[i].call({}, s); } catch (e) { continue; } if (r[1].length === 0) { return r[0]; } } return null; }; }; /** * Converts the specified string value into its JavaScript Date equivalent using the specified format {String} or formats {Array} and the CultureInfo specific format information. * The format of the string value must match one of the supplied formats exactly. * * Example

	// 15-Oct-2004
	var d1 = Date.parseExact("10/15/2004", "M/d/yyyy");

	// 15-Oct-2004
	var d1 = Date.parse("15-Oct-2004", "M-ddd-yyyy");

	// 15-Oct-2004
	var d1 = Date.parse("2004.10.15", "yyyy.MM.dd");

	// Multiple formats
	var d1 = Date.parseExact("10/15/2004", ["M/d/yyyy", "MMMM d, yyyy"]);
	
* * @param {String} The string value to convert into a Date object [Required]. * @param {Object} The expected format {String} or an array of expected formats {Array} of the date string [Required]. * @return {Date} A Date object or null if the string cannot be converted into a Date. */ $D.parseExact = function (s, fx) { return $D.getParseFunction(fx)(s); }; }()); (function () { var $D = Date, $P = $D.prototype, // $C = $D.CultureInfo, // not used atm p = function (s, l) { if (!l) { l = 2; } return ("000" + s).slice(l * -1); }; /** * Converts a PHP format string to Java/.NET format string. * A PHP format string can be used with ._format or .format. * A Java/.NET format string can be used with .toString(). * The .parseExact function will only accept a Java/.NET format string * * Example * var f1 = "%m/%d/%y" * var f2 = Date.normalizeFormat(f1); // "MM/dd/yy" * * new Date().format(f1); // "04/13/08" * new Date()._format(f1); // "04/13/08" * new Date().toString(f2); // "04/13/08" * * var date = Date.parseExact("04/13/08", f2); // Sun Apr 13 2008 * * @param {String} A PHP format string consisting of one or more format spcifiers. * @return {String} The PHP format converted to a Java/.NET format string. */ var normalizerSubstitutions = { "d" : "dd", "%d": "dd", "D" : "ddd", "%a": "ddd", "j" : "dddd", "l" : "dddd", "%A": "dddd", "S" : "S", "F" : "MMMM", "%B": "MMMM", "m" : "MM", "%m": "MM", "M" : "MMM", "%b": "MMM", "%h": "MMM", "n" : "M", "Y" : "yyyy", "%Y": "yyyy", "y" : "yy", "%y": "yy", "g" : "h", "%I": "h", "G" : "H", "h" : "hh", "H" : "HH", "%H": "HH", "i" : "mm", "%M": "mm", "s" : "ss", "%S": "ss", "%r": "hh:mm tt", "%R": "H:mm", "%T": "H:mm:ss", "%X": "t", "%x": "d", "%e": "d", "%D": "MM/dd/yy", "%n": "\\n", "%t": "\\t", "e" : "z", "T" : "z", "%z": "z", "%Z": "z", "Z" : "ZZ", "N" : "u", "w" : "u", "%w": "u", "W" : "W", "%V": "W" }; var normalizer = { substitutes: function (m) { return normalizerSubstitutions[m]; }, interpreted: function (m, x) { var y; switch (m) { case "%u": return x.getDay() + 1; case "z": return x.getOrdinalNumber(); case "%j": return p(x.getOrdinalNumber(), 3); case "%U": var d1 = x.clone().set({month: 0, day: 1}).addDays(-1).moveToDayOfWeek(0), d2 = x.clone().addDays(1).moveToDayOfWeek(0, -1); return (d2 < d1) ? "00" : p((d2.getOrdinalNumber() - d1.getOrdinalNumber()) / 7 + 1); case "%W": return p(x.getWeek()); case "t": return $D.getDaysInMonth(x.getFullYear(), x.getMonth()); case "o": case "%G": return x.setWeek(x.getISOWeek()).toString("yyyy"); case "%g": return x._format("%G").slice(-2); case "a": case "%p": return t("tt").toLowerCase(); case "A": return t("tt").toUpperCase(); case "u": return p(x.getMilliseconds(), 3); case "I": return (x.isDaylightSavingTime()) ? 1 : 0; case "O": return x.getUTCOffset(); case "P": y = x.getUTCOffset(); return y.substring(0, y.length - 2) + ":" + y.substring(y.length - 2); case "B": var now = new Date(); return Math.floor(((now.getHours() * 3600) + (now.getMinutes() * 60) + now.getSeconds() + (now.getTimezoneOffset() + 60) * 60) / 86.4); case "c": return x.toISOString().replace(/\"/g, ""); case "U": return $D.strtotime("now"); case "%c": return t("d") + " " + t("t"); case "%C": return Math.floor(x.getFullYear() / 100 + 1); } }, shouldOverrideDefaults: function (m) { switch (m) { case "%e": return true; default: return false; } }, parse: function (m, context) { var formatString, c = context || new Date(); formatString = normalizer.substitutes(m); if (formatString) { return formatString; } formatString = normalizer.interpreted(m, c); if (formatString) { return formatString; } else { return m; } } }; $D.normalizeFormat = function (format, context) { return format.replace(/(%|\\)?.|%%/g, function(t){ return normalizer.parse(t, context); }); }; /** * Format a local Unix timestamp according to locale settings * * Example: * Date.strftime("%m/%d/%y", new Date()); // "04/13/08" * Date.strftime("c", "2008-04-13T17:52:03Z"); // "04/13/08" * * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @param {Number|String} The number representing the number of seconds that have elapsed since January 1, 1970 (local time). * @return {String} A string representation of the current Date object. */ $D.strftime = function (format, time) { var d = Date.parse(time); return d._format(format); }; /** * Parse any textual datetime description into a Unix timestamp. * A Unix timestamp is the number of seconds that have elapsed since January 1, 1970 (midnight UTC/GMT). * * Example: * Date.strtotime("04/13/08"); // 1208044800 * Date.strtotime("1970-01-01T00:00:00Z"); // 0 * * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @param {Object} A string or date object. * @return {String} A string representation of the current Date object. */ $D.strtotime = function (time) { var d = $D.parse(time); return Math.round($D.UTC(d.getUTCFullYear(), d.getUTCMonth(), d.getUTCDate(), d.getUTCHours(), d.getUTCMinutes(), d.getUTCSeconds(), d.getUTCMilliseconds()) / 1000); }; /** * Converts the value of the current Date object to its equivalent string representation using a PHP/Unix style of date format specifiers. * Format Specifiers * Format Description Example * ------ --------------------------------------------------------------------------- ----------------------- * %a abbreviated weekday name according to the current localed "Mon" through "Sun" * %A full weekday name according to the current localed "Sunday" through "Saturday" * %b abbreviated month name according to the current localed "Jan" through "Dec" * %B full month name according to the current locale "January" through "December" * %c preferred date and time representation for the current locale "4/13/2008 12:33 PM" * %C century number (the year divided by 100 and truncated to an integer) "00" to "99" * %d day of the month as a decimal number "01" to "31" * %D same as %m/%d/%y "04/13/08" * %e day of the month as a decimal number, a single digit is preceded by a space "1" to "31" * %g like %G, but without the century "08" * %G The 4-digit year corresponding to the ISO week number (see %V). "2008" * This has the same format and value as %Y, except that if the ISO week number * belongs to the previous or next year, that year is used instead. * %h same as %b "Jan" through "Dec" * %H hour as a decimal number using a 24-hour clock. "00" to "23" * %I hour as a decimal number using a 12-hour clock. "01" to "12" * %j day of the year as a decimal number. "001" to "366" * %m month as a decimal number. "01" to "12" * %M minute as a decimal number. "00" to "59" * %n newline character "\n" * %p either "am" or "pm" according to the given time value, or the "am" or "pm" * corresponding strings for the current locale. * %r time in a.m. and p.m. notation "8:44 PM" * %R time in 24 hour notation "20:44" * %S second as a decimal number "00" to "59" * %t tab character "\t" * %T current time, equal to %H:%M:%S "12:49:11" * %u weekday as a decimal number ["1", "7"], with "1" representing Monday "1" to "7" * %U week number of the current year as a decimal number, starting with the "0" to ("52" or "53") * first Sunday as the first day of the first week * %V The ISO 8601:1988 week number of the current year as a decimal number, "00" to ("52" or "53") * range 01 to 53, where week 1 is the first week that has at least 4 days * in the current year, and with Monday as the first day of the week. * (Use %G or %g for the year component that corresponds to the week number * for the specified timestamp.) * %W week number of the current year as a decimal number, starting with the "00" to ("52" or "53") * first Monday as the first day of the first week * %w day of the week as a decimal, Sunday being "0" "0" to "6" * %x preferred date representation for the current locale without the time "4/13/2008" * %X preferred time representation for the current locale without the date "12:53:05" * %y year as a decimal number without a century "00" "99" * %Y year as a decimal number including the century "2008" * %Z time zone or name or abbreviation "UTC", "EST", "PST" * %z same as %Z * %% a literal "%" characters "%" * d Day of the month, 2 digits with leading zeros "01" to "31" * D A textual representation of a day, three letters "Mon" through "Sun" * j Day of the month without leading zeros "1" to "31" * l A full textual representation of the day of the week (lowercase "L") "Sunday" through "Saturday" * N ISO-8601 numeric representation of the day of the week (added in PHP 5.1.0) "1" (for Monday) through "7" (for Sunday) * S English ordinal suffix for the day of the month, 2 characters "st", "nd", "rd" or "th". Works well with j * w Numeric representation of the day of the week "0" (for Sunday) through "6" (for Saturday) * z The day of the year (starting from "0") "0" through "365" * W ISO-8601 week number of year, weeks starting on Monday "00" to ("52" or "53") * F A full textual representation of a month, such as January or March "January" through "December" * m Numeric representation of a month, with leading zeros "01" through "12" * M A short textual representation of a month, three letters "Jan" through "Dec" * n Numeric representation of a month, without leading zeros "1" through "12" * t Number of days in the given month "28" through "31" * L Whether it's a leap year "1" if it is a leap year, "0" otherwise * o ISO-8601 year number. This has the same value as Y, except that if the "2008" * ISO week number (W) belongs to the previous or next year, that year * is used instead. * Y A full numeric representation of a year, 4 digits "2008" * y A two digit representation of a year "08" * a Lowercase Ante meridiem and Post meridiem "am" or "pm" * A Uppercase Ante meridiem and Post meridiem "AM" or "PM" * B Swatch Internet time "000" through "999" * g 12-hour format of an hour without leading zeros "1" through "12" * G 24-hour format of an hour without leading zeros "0" through "23" * h 12-hour format of an hour with leading zeros "01" through "12" * H 24-hour format of an hour with leading zeros "00" through "23" * i Minutes with leading zeros "00" to "59" * s Seconds, with leading zeros "00" through "59" * u Milliseconds "54321" * e Timezone identifier "UTC", "EST", "PST" * I Whether or not the date is in daylight saving time (uppercase i) "1" if Daylight Saving Time, "0" otherwise * O Difference to Greenwich time (GMT) in hours "+0200", "-0600" * P Difference to Greenwich time (GMT) with colon between hours and minutes "+02:00", "-06:00" * T Timezone abbreviation "UTC", "EST", "PST" * Z Timezone offset in seconds. The offset for timezones west of UTC is "-43200" through "50400" * always negative, and for those east of UTC is always positive. * c ISO 8601 date "2004-02-12T15:19:21+00:00" * r RFC 2822 formatted date "Thu, 21 Dec 2000 16:01:07 +0200" * U Seconds since the Unix Epoch (January 1 1970 00:00:00 GMT) "0" * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @return {String} A string representation of the current Date object. */ var formatReplace = function (context) { return function (m) { var formatString, override = false; if (m.charAt(0) === "\\" || m.substring(0, 2) === "%%") { return m.replace("\\", "").replace("%%", "%"); } override = normalizer.shouldOverrideDefaults(m); formatString = $D.normalizeFormat(m, context); if (formatString) { return context.toString(formatString, override); } }; }; $P._format = function (format) { var formatter = formatReplace(this); if (!format) { return this._toString(); } else { return format.replace(/(%|\\)?.|%%/g, formatter); } }; if (!$P.format) { $P.format = $P._format; } }()); (function () { "use strict"; var gFn = function (attr) { return function () { return this[attr]; }; }; var sFn = function (attr) { return function (val) { this[attr] = val; return this; }; }; var attrs = ["years", "months", "days", "hours", "minutes", "seconds", "milliseconds"]; var addSetFuncs = function (context, attrs) { for (var i = 0; i < attrs.length ; i++) { var $a = attrs[i], $b = $a.slice(0, 1).toUpperCase() + $a.slice(1); context.prototype[$a] = 0; context.prototype["get" + $b] = gFn($a); context.prototype["set" + $b] = sFn($a); } }; /** * new TimeSpan(milliseconds); * new TimeSpan(days, hours, minutes, seconds); * new TimeSpan(days, hours, minutes, seconds, milliseconds); */ var TimeSpan = function (days, hours, minutes, seconds, milliseconds) { if (arguments.length === 1 && typeof days === "number") { var orient = (days < 0) ? -1 : +1; var millsLeft = Math.abs(days); this.setDays(Math.floor(millsLeft / 86400000) * orient); millsLeft = millsLeft % 86400000; this.setHours(Math.floor(millsLeft / 3600000) * orient); millsLeft = millsLeft % 3600000; this.setMinutes(Math.floor(millsLeft / 60000) * orient); millsLeft = millsLeft % 60000; this.setSeconds(Math.floor(millsLeft / 1000) * orient); millsLeft = millsLeft % 1000; this.setMilliseconds(millsLeft * orient); } else { this.set(days, hours, minutes, seconds, milliseconds); } this.getTotalMilliseconds = function () { return (this.getDays() * 86400000) + (this.getHours() * 3600000) + (this.getMinutes() * 60000) + (this.getSeconds() * 1000); }; this.compareTo = function (time) { var t1 = new Date(1970, 1, 1, this.getHours(), this.getMinutes(), this.getSeconds()), t2; if (time === null) { t2 = new Date(1970, 1, 1, 0, 0, 0); } else { t2 = new Date(1970, 1, 1, time.getHours(), time.getMinutes(), time.getSeconds()); } return (t1 < t2) ? -1 : (t1 > t2) ? 1 : 0; }; this.equals = function (time) { return (this.compareTo(time) === 0); }; this.add = function (time) { return (time === null) ? this : this.addSeconds(time.getTotalMilliseconds() / 1000); }; this.subtract = function (time) { return (time === null) ? this : this.addSeconds(-time.getTotalMilliseconds() / 1000); }; this.addDays = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 86400000)); }; this.addHours = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 3600000)); }; this.addMinutes = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 60000)); }; this.addSeconds = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 1000)); }; this.addMilliseconds = function (n) { return new TimeSpan(this.getTotalMilliseconds() + n); }; this.get12HourHour = function () { return (this.getHours() > 12) ? this.getHours() - 12 : (this.getHours() === 0) ? 12 : this.getHours(); }; this.getDesignator = function () { return (this.getHours() < 12) ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator; }; this.toString = function (format) { this._toString = function () { if (this.getDays() !== null && this.getDays() > 0) { return this.getDays() + "." + this.getHours() + ":" + this.p(this.getMinutes()) + ":" + this.p(this.getSeconds()); } else { return this.getHours() + ":" + this.p(this.getMinutes()) + ":" + this.p(this.getSeconds()); } }; this.p = function (s) { return (s.toString().length < 2) ? "0" + s : s; }; var me = this; return format ? format.replace(/dd?|HH?|hh?|mm?|ss?|tt?/g, function (format) { switch (format) { case "d": return me.getDays(); case "dd": return me.p(me.getDays()); case "H": return me.getHours(); case "HH": return me.p(me.getHours()); case "h": return me.get12HourHour(); case "hh": return me.p(me.get12HourHour()); case "m": return me.getMinutes(); case "mm": return me.p(me.getMinutes()); case "s": return me.getSeconds(); case "ss": return me.p(me.getSeconds()); case "t": return ((me.getHours() < 12) ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator).substring(0, 1); case "tt": return (me.getHours() < 12) ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator; } } ) : this._toString(); }; return this; }; addSetFuncs(TimeSpan, attrs.slice(2)); TimeSpan.prototype.set = function (days, hours, minutes, seconds, milliseconds){ this.setDays(days || this.getDays()); this.setHours(hours || this.getHours()); this.setMinutes(minutes || this.getMinutes()); this.setSeconds(seconds || this.getSeconds()); this.setMilliseconds(milliseconds || this.getMilliseconds()); }; /** * Gets the time of day for this date instances. * @return {TimeSpan} TimeSpan */ Date.prototype.getTimeOfDay = function () { return new TimeSpan(0, this.getHours(), this.getMinutes(), this.getSeconds(), this.getMilliseconds()); }; Date.TimeSpan = TimeSpan; if (typeof window !== "undefined" ) { // keeping API compatible for v1.x window.TimeSpan = TimeSpan; } }()); (function () { "use strict"; var attrs = ["years", "months", "days", "hours", "minutes", "seconds", "milliseconds"]; var gFn = function (attr) { return function () { return this[attr]; }; }; var sFn = function (attr) { return function (val) { this[attr] = val; return this; }; }; var addSetFuncs = function (context, attrs) { for (var i = 0; i < attrs.length ; i++) { var $a = attrs[i], $b = $a.slice(0, 1).toUpperCase() + $a.slice(1); context.prototype[$a] = 0; context.prototype["get" + $b] = gFn($a); context.prototype["set" + $b] = sFn($a); } }; var setMonthsAndYears = function (orient, d1, d2, context) { function inc() { d1.addMonths(-orient); context.months++; if (context.months === 12) { context.years++; context.months = 0; } } if (orient === +1) { while (d1 > d2) { inc(); } } else { while (d1 < d2) { inc(); } } context.months--; context.months *= orient; context.years *= orient; }; var adjustForDST = function(orient, startDate, endDate) { var hasDSTMismatch = (false === (startDate.isDaylightSavingTime() === endDate.isDaylightSavingTime())); if (hasDSTMismatch && orient === 1) { startDate.addHours(-1); } else if (hasDSTMismatch) { startDate.addHours(1); } }; /** * TimePeriod(startDate, endDate); * TimePeriod(years, months, days, hours, minutes, seconds, milliseconds); */ var TimePeriod = function (years, months, days, hours, minutes, seconds, milliseconds) { if (arguments.length === 7) { this.set(years, months, days, hours, minutes, seconds, milliseconds); } else if (arguments.length === 2 && arguments[0] instanceof Date && arguments[1] instanceof Date) { var startDate = arguments[0].clone(); var endDate = arguments[1].clone(); var orient = (startDate > endDate) ? +1 : -1; this.dates = { start: arguments[0].clone(), end: arguments[1].clone() }; setMonthsAndYears(orient, startDate, endDate, this); adjustForDST(orient, startDate, endDate); // // TODO - adjust for DST var diff = endDate - startDate; if (diff !== 0) { var ts = new TimeSpan(diff); this.set(this.years, this.months, ts.getDays(), ts.getHours(), ts.getMinutes(), ts.getSeconds(), ts.getMilliseconds()); } } return this; }; // create all the set functions. addSetFuncs(TimePeriod, attrs); TimePeriod.prototype.set = function (years, months, days, hours, minutes, seconds, milliseconds){ this.setYears(years || this.getYears()); this.setMonths(months || this.getMonths()); this.setDays(days || this.getDays()); this.setHours(hours || this.getHours()); this.setMinutes(minutes || this.getMinutes()); this.setSeconds(seconds || this.getSeconds()); this.setMilliseconds(milliseconds || this.getMilliseconds()); }; Date.TimePeriod = TimePeriod; if (typeof window !== "undefined") { // keeping API compatible for v1.x window.TimePeriod = TimePeriod; } }()); ================================================ FILE: build/date-et-EE.js ================================================ /** * @overview datejs * @version 1.0.0-rc3 * @author Gregory Wild-Smith * @copyright 2015 Gregory Wild-Smith * @license MIT * @homepage https://github.com/abritinthebay/datejs */ /* * DateJS Culture String File * Country Code: et-EE * Name: Estonian (Estonia) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["et-EE"] = { "name": "et-EE", "englishName": "Estonian (Estonia)", "nativeName": "eesti (Eesti)", "Sunday": "pühapäev", "Monday": "esmaspäev", "Tuesday": "teisipäev", "Wednesday": "kolmapäev", "Thursday": "neljapäev", "Friday": "reede", "Saturday": "laupäev", "Sun": "P", "Mon": "E", "Tue": "T", "Wed": "K", "Thu": "N", "Fri": "R", "Sat": "L", "Su": "P", "Mo": "E", "Tu": "T", "We": "K", "Th": "N", "Fr": "R", "Sa": "L", "S_Sun_Initial": "P", "M_Mon_Initial": "E", "T_Tue_Initial": "T", "W_Wed_Initial": "K", "T_Thu_Initial": "N", "F_Fri_Initial": "R", "S_Sat_Initial": "L", "January": "jaanuar", "February": "veebruar", "March": "märts", "April": "aprill", "May": "mai", "June": "juuni", "July": "juuli", "August": "august", "September": "september", "October": "oktoober", "November": "november", "December": "detsember", "Jan_Abbr": "jaan", "Feb_Abbr": "veebr", "Mar_Abbr": "märts", "Apr_Abbr": "apr", "May_Abbr": "mai", "Jun_Abbr": "juuni", "Jul_Abbr": "juuli", "Aug_Abbr": "aug", "Sep_Abbr": "sept", "Oct_Abbr": "okt", "Nov_Abbr": "nov", "Dec_Abbr": "dets", "AM": "EL", "PM": "PL", "firstDayOfWeek": 1, "twoDigitYearMax": 2029, "mdy": "dmy", "M/d/yyyy": "d.MM.yyyy", "dddd, MMMM dd, yyyy": "d. MMMM yyyy'. a.'", "h:mm tt": "H:mm", "h:mm:ss tt": "H:mm:ss", "dddd, MMMM dd, yyyy h:mm:ss tt": "d. MMMM yyyy'. a.' H:mm:ss", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "d. MMMM", "MMMM, yyyy": "MMMM yyyy'. a.'", "/jan(uary)?/": "jaan(uar)?", "/feb(ruary)?/": "veebr(uar)?", "/mar(ch)?/": "märts", "/apr(il)?/": "apr(ill)?", "/may/": "mai", "/jun(e)?/": "juuni", "/jul(y)?/": "juuli", "/aug(ust)?/": "aug(ust)?", "/sep(t(ember)?)?/": "sep(t(ember)?)?", "/oct(ober)?/": "okt(oober)?", "/nov(ember)?/": "nov(ember)?", "/dec(ember)?/": "dets(ember)?", "/^su(n(day)?)?/": "^pühapäev", "/^mo(n(day)?)?/": "^esmaspäev", "/^tu(e(s(day)?)?)?/": "^teisipäev", "/^we(d(nesday)?)?/": "^kolmapäev", "/^th(u(r(s(day)?)?)?)?/": "^neljapäev", "/^fr(i(day)?)?/": "^reede", "/^sa(t(urday)?)?/": "^laupäev", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "et-EE"; /** * @overview datejs * @version 1.0.0-rc3 * @author Gregory Wild-Smith * @copyright 2015 Gregory Wild-Smith * @license MIT * @homepage https://github.com/abritinthebay/datejs */(function () { var $D = Date; var lang = Date.CultureStrings ? Date.CultureStrings.lang : null; var loggedKeys = {}; // for debug purposes. var getText = { getFromKey: function (key, countryCode) { var output; if (Date.CultureStrings && Date.CultureStrings[countryCode] && Date.CultureStrings[countryCode][key]) { output = Date.CultureStrings[countryCode][key]; } else { output = getText.buildFromDefault(key); } if (key.charAt(0) === "/") { // Assume it's a regex output = getText.buildFromRegex(key, countryCode); } return output; }, getFromObjectValues: function (obj, countryCode) { var key, output = {}; for(key in obj) { if (obj.hasOwnProperty(key)) { output[key] = getText.getFromKey(obj[key], countryCode); } } return output; }, getFromObjectKeys: function (obj, countryCode) { var key, output = {}; for(key in obj) { if (obj.hasOwnProperty(key)) { output[getText.getFromKey(key, countryCode)] = obj[key]; } } return output; }, getFromArray: function (arr, countryCode) { var output = []; for (var i=0; i < arr.length; i++){ if (i in arr) { output[i] = getText.getFromKey(arr[i], countryCode); } } return output; }, buildFromDefault: function (key) { var output, length, split, last; switch(key) { case "name": output = "en-US"; break; case "englishName": output = "English (United States)"; break; case "nativeName": output = "English (United States)"; break; case "twoDigitYearMax": output = 2049; break; case "firstDayOfWeek": output = 0; break; default: output = key; split = key.split("_"); length = split.length; if (length > 1 && key.charAt(0) !== "/") { // if the key isn't a regex and it has a split. last = split[(length - 1)].toLowerCase(); if (last === "initial" || last === "abbr") { output = split[0]; } } break; } return output; }, buildFromRegex: function (key, countryCode) { var output; if (Date.CultureStrings && Date.CultureStrings[countryCode] && Date.CultureStrings[countryCode][key]) { output = new RegExp(Date.CultureStrings[countryCode][key], "i"); } else { output = new RegExp(key.replace(new RegExp("/", "g"),""), "i"); } return output; } }; var shallowMerge = function (obj1, obj2) { for (var attrname in obj2) { if (obj2.hasOwnProperty(attrname)) { obj1[attrname] = obj2[attrname]; } } }; var __ = function (key, language) { var countryCode = (language) ? language : lang; loggedKeys[key] = key; if (typeof key === "object") { if (key instanceof Array) { return getText.getFromArray(key, countryCode); } else { return getText.getFromObjectKeys(key, countryCode); } } else { return getText.getFromKey(key, countryCode); } }; var loadI18nScript = function (code) { // paatterned after jQuery's getScript. var url = Date.Config.i18n + code + ".js"; var head = document.getElementsByTagName("head")[0] || document.documentElement; var script = document.createElement("script"); script.src = url; var completed = false; var events = { done: function (){} // placeholder function }; // Attach handlers for all browsers script.onload = script.onreadystatechange = function() { if ( !completed && (!this.readyState || this.readyState === "loaded" || this.readyState === "complete") ) { events.done(); head.removeChild(script); } }; setTimeout(function() { head.insertBefore(script, head.firstChild); }, 0); // allows return to execute first return { done: function (cb) { events.done = function() { if (cb) { setTimeout(cb,0); } }; } }; }; var buildInfo = { buildFromMethodHash: function (obj) { var key; for(key in obj) { if (obj.hasOwnProperty(key)) { obj[key] = buildInfo[obj[key]](); } } return obj; }, timeZoneDST: function () { var DST = { "CHADT": "+1345", "NZDT": "+1300", "AEDT": "+1100", "ACDT": "+1030", "AZST": "+0500", "IRDT": "+0430", "EEST": "+0300", "CEST": "+0200", "BST": "+0100", "PMDT": "-0200", "ADT": "-0300", "NDT": "-0230", "EDT": "-0400", "CDT": "-0500", "MDT": "-0600", "PDT": "-0700", "AKDT": "-0800", "HADT": "-0900" }; return __(DST); }, timeZoneStandard: function () { var standard = { "LINT": "+1400", "TOT": "+1300", "CHAST": "+1245", "NZST": "+1200", "NFT": "+1130", "SBT": "+1100", "AEST": "+1000", "ACST": "+0930", "JST": "+0900", "CWST": "+0845", "CT": "+0800", "ICT": "+0700", "MMT": "+0630", "BST": "+0600", "NPT": "+0545", "IST": "+0530", "PKT": "+0500", "AFT": "+0430", "MSK": "+0400", "IRST": "+0330", "FET": "+0300", "EET": "+0200", "CET": "+0100", "GMT": "+0000", "UTC": "+0000", "CVT": "-0100", "GST": "-0200", "BRT": "-0300", "NST": "-0330", "AST": "-0400", "EST": "-0500", "CST": "-0600", "MST": "-0700", "PST": "-0800", "AKST": "-0900", "MIT": "-0930", "HST": "-1000", "SST": "-1100", "BIT": "-1200" }; return __(standard); }, timeZones: function (data) { var zone; data.timezones = []; for (zone in data.abbreviatedTimeZoneStandard) { if (data.abbreviatedTimeZoneStandard.hasOwnProperty(zone)) { data.timezones.push({ name: zone, offset: data.abbreviatedTimeZoneStandard[zone]}); } } for (zone in data.abbreviatedTimeZoneDST) { if (data.abbreviatedTimeZoneDST.hasOwnProperty(zone)) { data.timezones.push({ name: zone, offset: data.abbreviatedTimeZoneDST[zone], dst: true}); } } return data.timezones; }, days: function () { return __(["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"]); }, dayAbbr: function () { return __(["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"]); }, dayShortNames: function () { return __(["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"]); }, dayFirstLetters: function () { return __(["S_Sun_Initial", "M_Mon_Initial", "T_Tues_Initial", "W_Wed_Initial", "T_Thu_Initial", "F_Fri_Initial", "S_Sat_Initial"]); }, months: function () { return __(["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"]); }, monthAbbr: function () { return __(["Jan_Abbr", "Feb_Abbr", "Mar_Abbr", "Apr_Abbr", "May_Abbr", "Jun_Abbr", "Jul_Abbr", "Aug_Abbr", "Sep_Abbr", "Oct_Abbr", "Nov_Abbr", "Dec_Abbr"]); }, formatPatterns: function () { return getText.getFromObjectValues({ shortDate: "M/d/yyyy", longDate: "dddd, MMMM dd, yyyy", shortTime: "h:mm tt", longTime: "h:mm:ss tt", fullDateTime: "dddd, MMMM dd, yyyy h:mm:ss tt", sortableDateTime: "yyyy-MM-ddTHH:mm:ss", universalSortableDateTime: "yyyy-MM-dd HH:mm:ssZ", rfc1123: "ddd, dd MMM yyyy HH:mm:ss", monthDay: "MMMM dd", yearMonth: "MMMM, yyyy" }, Date.i18n.currentLanguage()); }, regex: function () { return getText.getFromObjectValues({ inTheMorning: "/( in the )(morn(ing)?)\\b/", thisMorning: "/(this )(morn(ing)?)\\b/", amThisMorning: "/(\b\\d(am)? )(this )(morn(ing)?)/", inTheEvening: "/( in the )(even(ing)?)\\b/", thisEvening: "/(this )(even(ing)?)\\b/", pmThisEvening: "/(\b\\d(pm)? )(this )(even(ing)?)/", jan: "/jan(uary)?/", feb: "/feb(ruary)?/", mar: "/mar(ch)?/", apr: "/apr(il)?/", may: "/may/", jun: "/jun(e)?/", jul: "/jul(y)?/", aug: "/aug(ust)?/", sep: "/sep(t(ember)?)?/", oct: "/oct(ober)?/", nov: "/nov(ember)?/", dec: "/dec(ember)?/", sun: "/^su(n(day)?)?/", mon: "/^mo(n(day)?)?/", tue: "/^tu(e(s(day)?)?)?/", wed: "/^we(d(nesday)?)?/", thu: "/^th(u(r(s(day)?)?)?)?/", fri: "/fr(i(day)?)?/", sat: "/^sa(t(urday)?)?/", future: "/^next/", past: "/^last|past|prev(ious)?/", add: "/^(\\+|aft(er)?|from|hence)/", subtract: "/^(\\-|bef(ore)?|ago)/", yesterday: "/^yes(terday)?/", today: "/^t(od(ay)?)?/", tomorrow: "/^tom(orrow)?/", now: "/^n(ow)?/", millisecond: "/^ms|milli(second)?s?/", second: "/^sec(ond)?s?/", minute: "/^mn|min(ute)?s?/", hour: "/^h(our)?s?/", week: "/^w(eek)?s?/", month: "/^m(onth)?s?/", day: "/^d(ay)?s?/", year: "/^y(ear)?s?/", shortMeridian: "/^(a|p)/", longMeridian: "/^(a\\.?m?\\.?|p\\.?m?\\.?)/", timezone: "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/", ordinalSuffix: "/^\\s*(st|nd|rd|th)/", timeContext: "/^\\s*(\\:|a(?!u|p)|p)/" }, Date.i18n.currentLanguage()); } }; var CultureInfo = function () { var info = getText.getFromObjectValues({ name: "name", englishName: "englishName", nativeName: "nativeName", amDesignator: "AM", pmDesignator: "PM", firstDayOfWeek: "firstDayOfWeek", twoDigitYearMax: "twoDigitYearMax", dateElementOrder: "mdy" }, Date.i18n.currentLanguage()); var constructedInfo = buildInfo.buildFromMethodHash({ dayNames: "days", abbreviatedDayNames: "dayAbbr", shortestDayNames: "dayShortNames", firstLetterDayNames: "dayFirstLetters", monthNames: "months", abbreviatedMonthNames: "monthAbbr", formatPatterns: "formatPatterns", regexPatterns: "regex", abbreviatedTimeZoneDST: "timeZoneDST", abbreviatedTimeZoneStandard: "timeZoneStandard" }); shallowMerge(info, constructedInfo); buildInfo.timeZones(info); return info; }; $D.i18n = { __: function (key, lang) { return __(key, lang); }, currentLanguage: function () { return lang || "en-US"; }, setLanguage: function (code, force, cb) { var async = false; if (force || code === "en-US" || (!!Date.CultureStrings && !!Date.CultureStrings[code])) { lang = code; Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings.lang = code; Date.CultureInfo = new CultureInfo(); } else { if (!(!!Date.CultureStrings && !!Date.CultureStrings[code])) { if (typeof exports !== "undefined" && this.exports !== exports) { // we're in a Node enviroment, load it using require try { require("../i18n/" + code + ".js"); lang = code; Date.CultureStrings.lang = code; Date.CultureInfo = new CultureInfo(); } catch (e) { // var str = "The language for '" + code + "' could not be loaded by Node. It likely does not exist."; throw new Error("The DateJS IETF language tag '" + code + "' could not be loaded by Node. It likely does not exist."); } } else if (Date.Config && Date.Config.i18n) { // we know the location of the files, so lets load them async = true; loadI18nScript(code).done(function(){ lang = code; Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings.lang = code; Date.CultureInfo = new CultureInfo(); $D.Parsing.Normalizer.buildReplaceData(); // because this is async if ($D.Grammar) { $D.Grammar.buildGrammarFormats(); // so we can parse those strings... } if (cb) { setTimeout(cb,0); } }); } else { Date.console.error("The DateJS IETF language tag '" + code + "' is not available and has not been loaded."); return false; } } } $D.Parsing.Normalizer.buildReplaceData(); // rebuild normalizer strings if ($D.Grammar) { $D.Grammar.buildGrammarFormats(); // so we can parse those strings... } if (!async && cb) { setTimeout(cb,0); } }, getLoggedKeys: function () { return loggedKeys; }, updateCultureInfo: function () { Date.CultureInfo = new CultureInfo(); } }; $D.i18n.updateCultureInfo(); // run automatically }()); (function () { var $D = Date, $P = $D.prototype, p = function (s, l) { if (!l) { l = 2; } return ("000" + s).slice(l * -1); }; if (typeof window !== "undefined" && typeof window.console !== "undefined" && typeof window.console.log !== "undefined") { $D.console = console; // used only to raise non-critical errors if available } else { // set mock so we don't give errors. $D.console = { log: function(){}, error: function(){} }; } $D.Config = $D.Config || {}; $D.initOverloads = function() { /** * Overload of Date.now. Allows an alternate call for Date.now where it returns the * current Date as an object rather than just milliseconds since the Unix Epoch. * * Also provides an implementation of now() for browsers (IE<9) that don't have it. * * Backwards compatible so with work with either: * Date.now() [returns ms] * or * Date.now(true) [returns Date] */ if (!$D.now) { $D._now = function now() { return new Date().getTime(); }; } else if (!$D._now) { $D._now = $D.now; } $D.now = function (returnObj) { if (returnObj) { return $D.present(); } else { return $D._now(); } }; if ( !$P.toISOString ) { $P.toISOString = function() { return this.getUTCFullYear() + "-" + p(this.getUTCMonth() + 1) + "-" + p(this.getUTCDate()) + "T" + p(this.getUTCHours()) + ":" + p(this.getUTCMinutes()) + ":" + p(this.getUTCSeconds()) + "." + String( (this.getUTCMilliseconds()/1000).toFixed(3)).slice(2, 5) + "Z"; }; } // private if ( $P._toString === undefined ){ $P._toString = $P.toString; } }; $D.initOverloads(); /** * Gets a date that is set to the current date. The time is set to the start of the day (00:00 or 12:00 AM). * @return {Date} The current date. */ $D.today = function () { return new Date().clearTime(); }; /** * Gets a date that is set to the current date and time (same as new Date, but chainable) * @return {Date} The current date. */ $D.present = function () { return new Date(); }; /** * Compares the first date to the second date and returns an number indication of their relative values. * @param {Date} First Date object to compare [Required]. * @param {Date} Second Date object to compare to [Required]. * @return {Number} -1 = date1 is lessthan date2. 0 = values are equal. 1 = date1 is greaterthan date2. */ $D.compare = function (date1, date2) { if (isNaN(date1) || isNaN(date2)) { throw new Error(date1 + " - " + date2); } else if (date1 instanceof Date && date2 instanceof Date) { return (date1 < date2) ? -1 : (date1 > date2) ? 1 : 0; } else { throw new TypeError(date1 + " - " + date2); } }; /** * Compares the first Date object to the second Date object and returns true if they are equal. * @param {Date} First Date object to compare [Required] * @param {Date} Second Date object to compare to [Required] * @return {Boolean} true if dates are equal. false if they are not equal. */ $D.equals = function (date1, date2) { return (date1.compareTo(date2) === 0); }; /** * Gets the language appropriate day name when given the day number(0-6) * eg - 0 == Sunday * @return {String} The day name */ $D.getDayName = function (n) { return Date.CultureInfo.dayNames[n]; }; /** * Gets the day number (0-6) if given a CultureInfo specific string which is a valid dayName, abbreviatedDayName or shortestDayName (two char). * @param {String} The name of the day (eg. "Monday, "Mon", "tuesday", "tue", "We", "we"). * @return {Number} The day number */ $D.getDayNumberFromName = function (name) { var n = Date.CultureInfo.dayNames, m = Date.CultureInfo.abbreviatedDayNames, o = Date.CultureInfo.shortestDayNames, s = name.toLowerCase(); for (var i = 0; i < n.length; i++) { if (n[i].toLowerCase() === s || m[i].toLowerCase() === s || o[i].toLowerCase() === s) { return i; } } return -1; }; /** * Gets the month number (0-11) if given a Culture Info specific string which is a valid monthName or abbreviatedMonthName. * @param {String} The name of the month (eg. "February, "Feb", "october", "oct"). * @return {Number} The day number */ $D.getMonthNumberFromName = function (name) { var n = Date.CultureInfo.monthNames, m = Date.CultureInfo.abbreviatedMonthNames, s = name.toLowerCase(); for (var i = 0; i < n.length; i++) { if (n[i].toLowerCase() === s || m[i].toLowerCase() === s) { return i; } } return -1; }; /** * Gets the language appropriate month name when given the month number(0-11) * eg - 0 == January * @return {String} The month name */ $D.getMonthName = function (n) { return Date.CultureInfo.monthNames[n]; }; /** * Determines if the current date instance is within a LeapYear. * @param {Number} The year. * @return {Boolean} true if date is within a LeapYear, otherwise false. */ $D.isLeapYear = function (year) { return ((year % 4 === 0 && year % 100 !== 0) || year % 400 === 0); }; /** * Gets the number of days in the month, given a year and month value. Automatically corrects for LeapYear. * @param {Number} The year. * @param {Number} The month (0-11). * @return {Number} The number of days in the month. */ $D.getDaysInMonth = function (year, month) { if (!month && $D.validateMonth(year)) { month = year; year = Date.today().getFullYear(); } return [31, ($D.isLeapYear(year) ? 29 : 28), 31, 30, 31, 30, 31, 31, 30, 31, 30, 31][month]; }; $P.getDaysInMonth = function () { return $D.getDaysInMonth(this.getFullYear(), this.getMonth()); }; $D.getTimezoneAbbreviation = function (offset, dst) { var p, n = (dst || false) ? Date.CultureInfo.abbreviatedTimeZoneDST : Date.CultureInfo.abbreviatedTimeZoneStandard; for (p in n) { if (n.hasOwnProperty(p)) { if (n[p] === offset) { return p; } } } return null; }; $D.getTimezoneOffset = function (name, dst) { var i, a =[], z = Date.CultureInfo.timezones; if (!name) { name = (new Date()).getTimezone();} for (i = 0; i < z.length; i++) { if (z[i].name === name.toUpperCase()) { a.push(i); } } if (!z[a[0]]) { return null; } if (a.length === 1 || !dst) { return z[a[0]].offset; } else { for (i=0; i < a.length; i++) { if (z[a[i]].dst) { return z[a[i]].offset; } } } }; $D.getQuarter = function (d) { d = d || new Date(); // If no date supplied, use today var q = [1,2,3,4]; return q[Math.floor(d.getMonth() / 3)]; // ~~~ is a bitwise op. Faster than Math.floor }; $D.getDaysLeftInQuarter = function (d) { d = d || new Date(); var qEnd = new Date(d); qEnd.setMonth(qEnd.getMonth() + 3 - qEnd.getMonth() % 3, 0); return Math.floor((qEnd - d) / 8.64e7); }; // private var validate = function (n, min, max, name) { name = name ? name : "Object"; if (typeof n === "undefined") { return false; } else if (typeof n !== "number") { throw new TypeError(n + " is not a Number."); } else if (n < min || n > max) { // As failing validation is *not* an exceptional circumstance // lets not throw a RangeError Exception here. // It's semantically correct but it's not sensible. return false; } return true; }; /** * Validates the number is within an acceptable range for milliseconds [0-999]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateMillisecond = function (value) { return validate(value, 0, 999, "millisecond"); }; /** * Validates the number is within an acceptable range for seconds [0-59]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateSecond = function (value) { return validate(value, 0, 59, "second"); }; /** * Validates the number is within an acceptable range for minutes [0-59]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateMinute = function (value) { return validate(value, 0, 59, "minute"); }; /** * Validates the number is within an acceptable range for hours [0-23]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateHour = function (value) { return validate(value, 0, 23, "hour"); }; /** * Validates the number is within an acceptable range for the days in a month [0-MaxDaysInMonth]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateDay = function (value, year, month) { if (year === undefined || year === null || month === undefined || month === null) { return false;} return validate(value, 1, $D.getDaysInMonth(year, month), "day"); }; /** * Validates the number is within an acceptable range for months [0-11]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateWeek = function (value) { return validate(value, 0, 53, "week"); }; /** * Validates the number is within an acceptable range for months [0-11]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateMonth = function (value) { return validate(value, 0, 11, "month"); }; /** * Validates the number is within an acceptable range for years. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateYear = function (value) { /** * Per ECMAScript spec the range of times supported by Date objects is * exactly -100,000,000 days to +100,000,000 days measured relative to * midnight at the beginning of 01 January, 1970 UTC. * This gives a range of 8,640,000,000,000,000 milliseconds to either * side of 01 January, 1970 UTC. * * Earliest possible date: Tue, 20 Apr 271,822 B.C. 00:00:00 UTC * Latest possible date: Sat, 13 Sep 275,760 00:00:00 UTC */ return validate(value, -271822, 275760, "year"); }; $D.validateTimezone = function(value) { var timezones = {"ACDT":1,"ACST":1,"ACT":1,"ADT":1,"AEDT":1,"AEST":1,"AFT":1,"AKDT":1,"AKST":1,"AMST":1,"AMT":1,"ART":1,"AST":1,"AWDT":1,"AWST":1,"AZOST":1,"AZT":1,"BDT":1,"BIOT":1,"BIT":1,"BOT":1,"BRT":1,"BST":1,"BTT":1,"CAT":1,"CCT":1,"CDT":1,"CEDT":1,"CEST":1,"CET":1,"CHADT":1,"CHAST":1,"CHOT":1,"ChST":1,"CHUT":1,"CIST":1,"CIT":1,"CKT":1,"CLST":1,"CLT":1,"COST":1,"COT":1,"CST":1,"CT":1,"CVT":1,"CWST":1,"CXT":1,"DAVT":1,"DDUT":1,"DFT":1,"EASST":1,"EAST":1,"EAT":1,"ECT":1,"EDT":1,"EEDT":1,"EEST":1,"EET":1,"EGST":1,"EGT":1,"EIT":1,"EST":1,"FET":1,"FJT":1,"FKST":1,"FKT":1,"FNT":1,"GALT":1,"GAMT":1,"GET":1,"GFT":1,"GILT":1,"GIT":1,"GMT":1,"GST":1,"GYT":1,"HADT":1,"HAEC":1,"HAST":1,"HKT":1,"HMT":1,"HOVT":1,"HST":1,"ICT":1,"IDT":1,"IOT":1,"IRDT":1,"IRKT":1,"IRST":1,"IST":1,"JST":1,"KGT":1,"KOST":1,"KRAT":1,"KST":1,"LHST":1,"LINT":1,"MAGT":1,"MART":1,"MAWT":1,"MDT":1,"MET":1,"MEST":1,"MHT":1,"MIST":1,"MIT":1,"MMT":1,"MSK":1,"MST":1,"MUT":1,"MVT":1,"MYT":1,"NCT":1,"NDT":1,"NFT":1,"NPT":1,"NST":1,"NT":1,"NUT":1,"NZDT":1,"NZST":1,"OMST":1,"ORAT":1,"PDT":1,"PET":1,"PETT":1,"PGT":1,"PHOT":1,"PHT":1,"PKT":1,"PMDT":1,"PMST":1,"PONT":1,"PST":1,"PYST":1,"PYT":1,"RET":1,"ROTT":1,"SAKT":1,"SAMT":1,"SAST":1,"SBT":1,"SCT":1,"SGT":1,"SLST":1,"SRT":1,"SST":1,"SYOT":1,"TAHT":1,"THA":1,"TFT":1,"TJT":1,"TKT":1,"TLT":1,"TMT":1,"TOT":1,"TVT":1,"UCT":1,"ULAT":1,"UTC":1,"UYST":1,"UYT":1,"UZT":1,"VET":1,"VLAT":1,"VOLT":1,"VOST":1,"VUT":1,"WAKT":1,"WAST":1,"WAT":1,"WEDT":1,"WEST":1,"WET":1,"WST":1,"YAKT":1,"YEKT":1,"Z":1}; return (timezones[value] === 1); }; $D.validateTimezoneOffset= function(value) { // timezones go from +14hrs to -12hrs, the +X hours are negative offsets. return (value > -841 && value < 721); }; }()); (function () { var $D = Date, $P = $D.prototype, p = function (s, l) { if (!l) { l = 2; } return ("000" + s).slice(l * -1); }; var validateConfigObject = function (obj) { var result = {}, self = this, prop, testFunc; testFunc = function (prop, func, value) { if (prop === "day") { var month = (obj.month !== undefined) ? obj.month : self.getMonth(); var year = (obj.year !== undefined) ? obj.year : self.getFullYear(); return $D[func](value, year, month); } else { return $D[func](value); } }; for (prop in obj) { if (Object.prototype.hasOwnProperty.call(obj, prop)) { var func = "validate" + prop.charAt(0).toUpperCase() + prop.slice(1); if ($D[func] && obj[prop] !== null && testFunc(prop, func, obj[prop])) { result[prop] = obj[prop]; } } } return result; }; /** * Resets the time of this Date object to 12:00 AM (00:00), which is the start of the day. * @param {Boolean} .clone() this date instance before clearing Time * @return {Date} this */ $P.clearTime = function () { this.setHours(0); this.setMinutes(0); this.setSeconds(0); this.setMilliseconds(0); return this; }; /** * Resets the time of this Date object to the current time ('now'). * @return {Date} this */ $P.setTimeToNow = function () { var n = new Date(); this.setHours(n.getHours()); this.setMinutes(n.getMinutes()); this.setSeconds(n.getSeconds()); this.setMilliseconds(n.getMilliseconds()); return this; }; /** * Returns a new Date object that is an exact date and time copy of the original instance. * @return {Date} A new Date instance */ $P.clone = function () { return new Date(this.getTime()); }; /** * Compares this instance to a Date object and returns an number indication of their relative values. * @param {Date} Date object to compare [Required] * @return {Number} -1 = this is lessthan date. 0 = values are equal. 1 = this is greaterthan date. */ $P.compareTo = function (date) { return Date.compare(this, date); }; /** * Compares this instance to another Date object and returns true if they are equal. * @param {Date} Date object to compare. If no date to compare, new Date() [now] is used. * @return {Boolean} true if dates are equal. false if they are not equal. */ $P.equals = function (date) { return Date.equals(this, (date !== undefined ? date : new Date())); }; /** * Determines if this instance is between a range of two dates or equal to either the start or end dates. * @param {Date} Start of range [Required] * @param {Date} End of range [Required] * @return {Boolean} true is this is between or equal to the start and end dates, else false */ $P.between = function (start, end) { return this.getTime() >= start.getTime() && this.getTime() <= end.getTime(); }; /** * Determines if this date occurs after the date to compare to. * @param {Date} Date object to compare. If no date to compare, new Date() ("now") is used. * @return {Boolean} true if this date instance is greater than the date to compare to (or "now"), otherwise false. */ $P.isAfter = function (date) { return this.compareTo(date || new Date()) === 1; }; /** * Determines if this date occurs before the date to compare to. * @param {Date} Date object to compare. If no date to compare, new Date() ("now") is used. * @return {Boolean} true if this date instance is less than the date to compare to (or "now"). */ $P.isBefore = function (date) { return (this.compareTo(date || new Date()) === -1); }; /** * Determines if the current Date instance occurs today. * @return {Boolean} true if this date instance is 'today', otherwise false. */ /** * Determines if the current Date instance occurs on the same Date as the supplied 'date'. * If no 'date' to compare to is provided, the current Date instance is compared to 'today'. * @param {date} Date object to compare. If no date to compare, the current Date ("now") is used. * @return {Boolean} true if this Date instance occurs on the same Day as the supplied 'date'. */ $P.isToday = $P.isSameDay = function (date) { return this.clone().clearTime().equals((date || new Date()).clone().clearTime()); }; /** * Adds the specified number of milliseconds to this instance. * @param {Number} The number of milliseconds to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addMilliseconds = function (value) { if (!value) { return this; } this.setTime(this.getTime() + value * 1); return this; }; /** * Adds the specified number of seconds to this instance. * @param {Number} The number of seconds to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addSeconds = function (value) { if (!value) { return this; } return this.addMilliseconds(value * 1000); }; /** * Adds the specified number of seconds to this instance. * @param {Number} The number of seconds to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addMinutes = function (value) { if (!value) { return this; } return this.addMilliseconds(value * 60000); // 60*1000 }; /** * Adds the specified number of hours to this instance. * @param {Number} The number of hours to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addHours = function (value) { if (!value) { return this; } return this.addMilliseconds(value * 3600000); // 60*60*1000 }; /** * Adds the specified number of days to this instance. * @param {Number} The number of days to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addDays = function (value) { if (!value) { return this; } this.setDate(this.getDate() + value * 1); return this; }; /** * Adds the specified number of weekdays (ie - not sat or sun) to this instance. * @param {Number} The number of days to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addWeekdays = function (value) { if (!value) { return this; } var day = this.getDay(); var weeks = (Math.ceil(Math.abs(value)/7)); if (day === 0 || day === 6) { if (value > 0) { this.next().monday(); this.addDays(-1); day = this.getDay(); } } if (value < 0) { while (value < 0) { this.addDays(-1); day = this.getDay(); if (day !== 0 && day !== 6) { value++; } } return this; } else if (value > 5 || (6-day) <= value) { value = value + (weeks * 2); } return this.addDays(value); }; /** * Adds the specified number of weeks to this instance. * @param {Number} The number of weeks to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addWeeks = function (value) { if (!value) { return this; } return this.addDays(value * 7); }; /** * Adds the specified number of months to this instance. * @param {Number} The number of months to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addMonths = function (value) { if (!value) { return this; } var n = this.getDate(); this.setDate(1); this.setMonth(this.getMonth() + value * 1); this.setDate(Math.min(n, $D.getDaysInMonth(this.getFullYear(), this.getMonth()))); return this; }; $P.addQuarters = function (value) { if (!value) { return this; } // note this will take you to the same point in the quarter as you are now. // i.e. - if you are 15 days into the quarter you'll be 15 days into the resulting one. // bonus: this allows adding fractional quarters return this.addMonths(value * 3); }; /** * Adds the specified number of years to this instance. * @param {Number} The number of years to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addYears = function (value) { if (!value) { return this; } return this.addMonths(value * 12); }; /** * Adds (or subtracts) to the value of the years, months, weeks, days, hours, minutes, seconds, milliseconds of the date instance using given configuration object. Positive and Negative values allowed. * Example

	Date.today().add( { days: 1, months: 1 } )

	new Date().add( { years: -1 } )
	
* @param {Object} Configuration object containing attributes (months, days, etc.) * @return {Date} this */ $P.add = function (config) { if (typeof config === "number") { this._orient = config; return this; } var x = config; if (x.day) { // If we should be a different date than today (eg: for 'tomorrow -1d', etc). // Should only effect parsing, not direct usage (eg, Finish and FinishExact) if ((x.day - this.getDate()) !== 0) { this.setDate(x.day); } } if (x.milliseconds) { this.addMilliseconds(x.milliseconds); } if (x.seconds) { this.addSeconds(x.seconds); } if (x.minutes) { this.addMinutes(x.minutes); } if (x.hours) { this.addHours(x.hours); } if (x.weeks) { this.addWeeks(x.weeks); } if (x.months) { this.addMonths(x.months); } if (x.years) { this.addYears(x.years); } if (x.days) { this.addDays(x.days); } return this; }; /** * Get the week number. Week one (1) is the week which contains the first Thursday of the year. Monday is considered the first day of the week. * The .getWeek() function does NOT convert the date to UTC. The local datetime is used. * Please use .getISOWeek() to get the week of the UTC converted date. * @return {Number} 1 to 53 */ $P.getWeek = function (utc) { // Create a copy of this date object var self, target = new Date(this.valueOf()); if (utc) { target.addMinutes(target.getTimezoneOffset()); self = target.clone(); } else { self = this; } // ISO week date weeks start on monday // so correct the day number var dayNr = (self.getDay() + 6) % 7; // ISO 8601 states that week 1 is the week // with the first thursday of that year. // Set the target date to the thursday in the target week target.setDate(target.getDate() - dayNr + 3); // Store the millisecond value of the target date var firstThursday = target.valueOf(); // Set the target to the first thursday of the year // First set the target to january first target.setMonth(0, 1); // Not a thursday? Correct the date to the next thursday if (target.getDay() !== 4) { target.setMonth(0, 1 + ((4 - target.getDay()) + 7) % 7); } // The weeknumber is the number of weeks between the // first thursday of the year and the thursday in the target week return 1 + Math.ceil((firstThursday - target) / 604800000); // 604800000 = 7 * 24 * 3600 * 1000 }; /** * Get the ISO 8601 week number. Week one ("01") is the week which contains the first Thursday of the year. Monday is considered the first day of the week. * The .getISOWeek() function does convert the date to it's UTC value. Please use .getWeek() to get the week of the local date. * @return {String} "01" to "53" */ $P.getISOWeek = function () { return p(this.getWeek(true)); }; /** * Moves the date to Monday of the week set. Week one (1) is the week which contains the first Thursday of the year. * @param {Number} A Number (1 to 53) that represents the week of the year. * @return {Date} this */ $P.setWeek = function (n) { if ((n - this.getWeek()) === 0) { if (this.getDay() !== 1) { return this.moveToDayOfWeek(1, (this.getDay() > 1 ? -1 : 1)); } else { return this; } } else { return this.moveToDayOfWeek(1, (this.getDay() > 1 ? -1 : 1)).addWeeks(n - this.getWeek()); } }; $P.setQuarter = function (qtr) { var month = Math.abs(((qtr-1) * 3) + 1); return this.setMonth(month, 1); }; $P.getQuarter = function () { return Date.getQuarter(this); }; $P.getDaysLeftInQuarter = function () { return Date.getDaysLeftInQuarter(this); }; /** * Moves the date to the next n'th occurrence of the dayOfWeek starting from the beginning of the month. The number (-1) is a magic number and will return the last occurrence of the dayOfWeek in the month. * @param {Number} The dayOfWeek to move to * @param {Number} The n'th occurrence to move to. Use (-1) to return the last occurrence in the month * @return {Date} this */ $P.moveToNthOccurrence = function (dayOfWeek, occurrence) { if (dayOfWeek === "Weekday") { if (occurrence > 0) { this.moveToFirstDayOfMonth(); if (this.is().weekday()) { occurrence -= 1; } } else if (occurrence < 0) { this.moveToLastDayOfMonth(); if (this.is().weekday()) { occurrence += 1; } } else { return this; } return this.addWeekdays(occurrence); } var shift = 0; if (occurrence > 0) { shift = occurrence - 1; } else if (occurrence === -1) { this.moveToLastDayOfMonth(); if (this.getDay() !== dayOfWeek) { this.moveToDayOfWeek(dayOfWeek, -1); } return this; } return this.moveToFirstDayOfMonth().addDays(-1).moveToDayOfWeek(dayOfWeek, +1).addWeeks(shift); }; var moveToN = function (getFunc, addFunc, nVal) { return function (value, orient) { var diff = (value - this[getFunc]() + nVal * (orient || +1)) % nVal; return this[addFunc]((diff === 0) ? diff += nVal * (orient || +1) : diff); }; }; /** * Move to the next or last dayOfWeek based on the orient value. * @param {Number} The dayOfWeek to move to * @param {Number} Forward (+1) or Back (-1). Defaults to +1. [Optional] * @return {Date} this */ $P.moveToDayOfWeek = moveToN("getDay", "addDays", 7); /** * Move to the next or last month based on the orient value. * @param {Number} The month to move to. 0 = January, 11 = December * @param {Number} Forward (+1) or Back (-1). Defaults to +1. [Optional] * @return {Date} this */ $P.moveToMonth = moveToN("getMonth", "addMonths", 12); /** * Get the Ordinate of the current day ("th", "st", "rd"). * @return {String} */ $P.getOrdinate = function () { var num = this.getDate(); return ord(num); }; /** * Get the Ordinal day (numeric day number) of the year, adjusted for leap year. * @return {Number} 1 through 365 (366 in leap years) */ $P.getOrdinalNumber = function () { return Math.ceil((this.clone().clearTime() - new Date(this.getFullYear(), 0, 1)) / 86400000) + 1; }; /** * Get the time zone abbreviation of the current date. * @return {String} The abbreviated time zone name (e.g. "EST") */ $P.getTimezone = function () { return $D.getTimezoneAbbreviation(this.getUTCOffset(), this.isDaylightSavingTime()); }; $P.setTimezoneOffset = function (offset) { var here = this.getTimezoneOffset(), there = Number(offset) * -6 / 10; return (there || there === 0) ? this.addMinutes(there - here) : this; }; $P.setTimezone = function (offset) { return this.setTimezoneOffset($D.getTimezoneOffset(offset)); }; /** * Indicates whether Daylight Saving Time is observed in the current time zone. * @return {Boolean} true|false */ $P.hasDaylightSavingTime = function () { return (Date.today().set({month: 0, day: 1}).getTimezoneOffset() !== Date.today().set({month: 6, day: 1}).getTimezoneOffset()); }; /** * Indicates whether this Date instance is within the Daylight Saving Time range for the current time zone. * @return {Boolean} true|false */ $P.isDaylightSavingTime = function () { return Date.today().set({month: 0, day: 1}).getTimezoneOffset() !== this.getTimezoneOffset(); }; /** * Get the offset from UTC of the current date. * @return {String} The 4-character offset string prefixed with + or - (e.g. "-0500") */ $P.getUTCOffset = function (offset) { var n = (offset || this.getTimezoneOffset()) * -10 / 6, r; if (n < 0) { r = (n - 10000).toString(); return r.charAt(0) + r.substr(2); } else { r = (n + 10000).toString(); return "+" + r.substr(1); } }; /** * Returns the number of milliseconds between this date and date. * @param {Date} Defaults to now * @return {Number} The diff in milliseconds */ $P.getElapsed = function (date) { return (date || new Date()) - this; }; /** * Set the value of year, month, day, hour, minute, second, millisecond of date instance using given configuration object. * Example

	Date.today().set( { day: 20, month: 1 } )

	new Date().set( { millisecond: 0 } )
	
* * @param {Object} Configuration object containing attributes (month, day, etc.) * @return {Date} this */ $P.set = function (config) { config = validateConfigObject.call(this, config); var key; for (key in config) { if (Object.prototype.hasOwnProperty.call(config, key)) { var name = key.charAt(0).toUpperCase() + key.slice(1); var addFunc, getFunc; if (key !== "week" && key !== "month" && key !== "timezone" && key !== "timezoneOffset") { name += "s"; } addFunc = "add" + name; getFunc = "get" + name; if (key === "month") { addFunc = addFunc + "s"; } else if (key === "year"){ getFunc = "getFullYear"; } if (key !== "day" && key !== "timezone" && key !== "timezoneOffset" && key !== "week" && key !== "hour") { this[addFunc](config[key] - this[getFunc]()); } else if ( key === "timezone"|| key === "timezoneOffset" || key === "week" || key === "hour") { this["set"+name](config[key]); } } } // day has to go last because you can't validate the day without first knowing the month if (config.day) { this.addDays(config.day - this.getDate()); } return this; }; /** * Moves the date to the first day of the month. * @return {Date} this */ $P.moveToFirstDayOfMonth = function () { return this.set({ day: 1 }); }; /** * Moves the date to the last day of the month. * @return {Date} this */ $P.moveToLastDayOfMonth = function () { return this.set({ day: $D.getDaysInMonth(this.getFullYear(), this.getMonth())}); }; /** * Converts the value of the current Date object to its equivalent string representation. * Format Specifiers * CUSTOM DATE AND TIME FORMAT STRINGS * Format Description Example * ------ --------------------------------------------------------------------------- ----------------------- * s The seconds of the minute between 0-59. "0" to "59" * ss The seconds of the minute with leading zero if required. "00" to "59" * * m The minute of the hour between 0-59. "0" or "59" * mm The minute of the hour with leading zero if required. "00" or "59" * * h The hour of the day between 1-12. "1" to "12" * hh The hour of the day with leading zero if required. "01" to "12" * * H The hour of the day between 0-23. "0" to "23" * HH The hour of the day with leading zero if required. "00" to "23" * * d The day of the month between 1 and 31. "1" to "31" * dd The day of the month with leading zero if required. "01" to "31" * ddd Abbreviated day name. Date.CultureInfo.abbreviatedDayNames. "Mon" to "Sun" * dddd The full day name. Date.CultureInfo.dayNames. "Monday" to "Sunday" * * M The month of the year between 1-12. "1" to "12" * MM The month of the year with leading zero if required. "01" to "12" * MMM Abbreviated month name. Date.CultureInfo.abbreviatedMonthNames. "Jan" to "Dec" * MMMM The full month name. Date.CultureInfo.monthNames. "January" to "December" * * yy The year as a two-digit number. "99" or "08" * yyyy The full four digit year. "1999" or "2008" * * t Displays the first character of the A.M./P.M. designator. "A" or "P" * Date.CultureInfo.amDesignator or Date.CultureInfo.pmDesignator * tt Displays the A.M./P.M. designator. "AM" or "PM" * Date.CultureInfo.amDesignator or Date.CultureInfo.pmDesignator * * S The ordinal suffix ("st, "nd", "rd" or "th") of the current day. "st, "nd", "rd" or "th" * * STANDARD DATE AND TIME FORMAT STRINGS * Format Description Example *------ --------------------------------------------------------------------------- ----------------------- * d The CultureInfo shortDate Format Pattern "M/d/yyyy" * D The CultureInfo longDate Format Pattern "dddd, MMMM dd, yyyy" * F The CultureInfo fullDateTime Format Pattern "dddd, MMMM dd, yyyy h:mm:ss tt" * m The CultureInfo monthDay Format Pattern "MMMM dd" * r The CultureInfo rfc1123 Format Pattern "ddd, dd MMM yyyy HH:mm:ss GMT" * s The CultureInfo sortableDateTime Format Pattern "yyyy-MM-ddTHH:mm:ss" * t The CultureInfo shortTime Format Pattern "h:mm tt" * T The CultureInfo longTime Format Pattern "h:mm:ss tt" * u The CultureInfo universalSortableDateTime Format Pattern "yyyy-MM-dd HH:mm:ssZ" * y The CultureInfo yearMonth Format Pattern "MMMM, yyyy" * * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @return {String} A string representation of the current Date object. */ var ord = function (n) { switch (n * 1) { case 1: case 21: case 31: return "st"; case 2: case 22: return "nd"; case 3: case 23: return "rd"; default: return "th"; } }; var parseStandardFormats = function (format) { var y, c = Date.CultureInfo.formatPatterns; switch (format) { case "d": return this.toString(c.shortDate); case "D": return this.toString(c.longDate); case "F": return this.toString(c.fullDateTime); case "m": return this.toString(c.monthDay); case "r": case "R": y = this.clone().addMinutes(this.getTimezoneOffset()); return y.toString(c.rfc1123) + " GMT"; case "s": return this.toString(c.sortableDateTime); case "t": return this.toString(c.shortTime); case "T": return this.toString(c.longTime); case "u": y = this.clone().addMinutes(this.getTimezoneOffset()); return y.toString(c.universalSortableDateTime); case "y": return this.toString(c.yearMonth); default: return false; } }; var parseFormatStringsClosure = function (context) { return function (m) { if (m.charAt(0) === "\\") { return m.replace("\\", ""); } switch (m) { case "hh": return p(context.getHours() < 13 ? (context.getHours() === 0 ? 12 : context.getHours()) : (context.getHours() - 12)); case "h": return context.getHours() < 13 ? (context.getHours() === 0 ? 12 : context.getHours()) : (context.getHours() - 12); case "HH": return p(context.getHours()); case "H": return context.getHours(); case "mm": return p(context.getMinutes()); case "m": return context.getMinutes(); case "ss": return p(context.getSeconds()); case "s": return context.getSeconds(); case "yyyy": return p(context.getFullYear(), 4); case "yy": return p(context.getFullYear()); case "y": return context.getFullYear(); case "E": case "dddd": return Date.CultureInfo.dayNames[context.getDay()]; case "ddd": return Date.CultureInfo.abbreviatedDayNames[context.getDay()]; case "dd": return p(context.getDate()); case "d": return context.getDate(); case "MMMM": return Date.CultureInfo.monthNames[context.getMonth()]; case "MMM": return Date.CultureInfo.abbreviatedMonthNames[context.getMonth()]; case "MM": return p((context.getMonth() + 1)); case "M": return context.getMonth() + 1; case "t": return context.getHours() < 12 ? Date.CultureInfo.amDesignator.substring(0, 1) : Date.CultureInfo.pmDesignator.substring(0, 1); case "tt": return context.getHours() < 12 ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator; case "S": return ord(context.getDate()); case "W": return context.getWeek(); case "WW": return context.getISOWeek(); case "Q": return "Q" + context.getQuarter(); case "q": return String(context.getQuarter()); case "z": return context.getTimezone(); case "Z": case "X": return Date.getTimezoneOffset(context.getTimezone()); case "ZZ": // Timezone offset in seconds return context.getTimezoneOffset() * -60; case "u": return context.getDay(); case "L": return ($D.isLeapYear(context.getFullYear())) ? 1 : 0; case "B": // Swatch Internet Time (.beats) return "@"+((context.getUTCSeconds() + (context.getUTCMinutes()*60) + ((context.getUTCHours()+1)*3600))/86.4); default: return m; } }; }; $P.toString = function (format, ignoreStandards) { // Standard Date and Time Format Strings. Formats pulled from CultureInfo file and // may vary by culture. if (!ignoreStandards && format && format.length === 1) { output = parseStandardFormats.call(this, format); if (output) { return output; } } var parseFormatStrings = parseFormatStringsClosure(this); return format ? format.replace(/((\\)?(dd?d?d?|MM?M?M?|yy?y?y?|hh?|HH?|mm?|ss?|tt?|S|q|Q|WW?W?W?)(?![^\[]*\]))/g, parseFormatStrings).replace(/\[|\]/g, "") : this._toString(); }; }()); /************************************************************* * SugarPak - Domain Specific Language - Syntactical Sugar * *************************************************************/ (function () { var $D = Date, $P = $D.prototype, $N = Number.prototype; // private $P._orient = +1; // private $P._nth = null; // private $P._is = false; // private $P._same = false; // private $P._isSecond = false; // private $N._dateElement = "days"; /** * Moves the date to the next instance of a date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.today().next().friday();
	Date.today().next().fri();
	Date.today().next().march();
	Date.today().next().mar();
	Date.today().next().week();
	
* * @return {Date} date */ $P.next = function () { this._move = true; this._orient = +1; return this; }; /** * Creates a new Date (Date.today()) and moves the date to the next instance of the date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.next().friday();
	Date.next().fri();
	Date.next().march();
	Date.next().mar();
	Date.next().week();
	
* * @return {Date} date */ $D.next = function () { return $D.today().next(); }; /** * Moves the date to the previous instance of a date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.today().last().friday();
	Date.today().last().fri();
	Date.today().last().march();
	Date.today().last().mar();
	Date.today().last().week();
	
* * @return {Date} date */ $P.last = $P.prev = $P.previous = function () { this._move = true; this._orient = -1; return this; }; /** * Creates a new Date (Date.today()) and moves the date to the previous instance of the date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.last().friday();
	Date.last().fri();
	Date.previous().march();
	Date.prev().mar();
	Date.last().week();
	
* * @return {Date} date */ $D.last = $D.prev = $D.previous = function () { return $D.today().last(); }; /** * Performs a equality check when followed by either a month name, day name or .weekday() function. * Example

	Date.today().is().friday(); // true|false
	Date.today().is().fri();
	Date.today().is().march();
	Date.today().is().mar();
	
* * @return {Boolean} true|false */ $P.is = function () { this._is = true; return this; }; /** * Determines if two date objects occur on/in exactly the same instance of the subsequent date part function. * The function .same() must be followed by a date part function (example: .day(), .month(), .year(), etc). * * An optional Date can be passed in the date part function. If now date is passed as a parameter, 'Now' is used. * * The following example demonstrates how to determine if two dates fall on the exact same day. * * Example

	var d1 = Date.today(); // today at 00:00
	var d2 = new Date();   // exactly now.

	// Do they occur on the same day?
	d1.same().day(d2); // true
	
	// Do they occur on the same hour?
	d1.same().hour(d2); // false, unless d2 hour is '00' (midnight).
	
	// What if it's the same day, but one year apart?
	var nextYear = Date.today().add(1).year();

	d1.same().day(nextYear); // false, because the dates must occur on the exact same day. 
	
* * Scenario: Determine if a given date occurs during some week period 2 months from now. * * Example

	var future = Date.today().add(2).months();
	return someDate.same().week(future); // true|false;
	
* * @return {Boolean} true|false */ $P.same = function () { this._same = true; this._isSecond = false; return this; }; /** * Determines if the current date/time occurs during Today. Must be preceded by the .is() function. * Example

	someDate.is().today();    // true|false
	new Date().is().today();  // true
	Date.today().is().today();// true
	Date.today().add(-1).day().is().today(); // false
	
* * @return {Boolean} true|false */ $P.today = function () { return this.same().day(); }; /** * Determines if the current date is a weekday. This function must be preceded by the .is() function. * Example

	Date.today().is().weekday(); // true|false
	
* * @return {Boolean} true|false */ $P.weekday = function () { if (this._nth) { return df("Weekday").call(this); } if (this._move) { return this.addWeekdays(this._orient); } if (this._is) { this._is = false; return (!this.is().sat() && !this.is().sun()); } return false; }; /** * Determines if the current date is on the weekend. This function must be preceded by the .is() function. * Example

	Date.today().is().weekend(); // true|false
	
* * @return {Boolean} true|false */ $P.weekend = function () { if (this._is) { this._is = false; return (this.is().sat() || this.is().sun()); } return false; }; /** * Sets the Time of the current Date instance. A string "6:15 pm" or config object {hour:18, minute:15} are accepted. * Example

	// Set time to 6:15pm with a String
	Date.today().at("6:15pm");

	// Set time to 6:15pm with a config object
	Date.today().at({hour:18, minute:15});
	
* * @return {Date} date */ $P.at = function (time) { return (typeof time === "string") ? $D.parse(this.toString("d") + " " + time) : this.set(time); }; /** * Creates a new Date() and adds this (Number) to the date based on the preceding date element function (eg. second|minute|hour|day|month|year). * Example

	// Undeclared Numbers must be wrapped with parentheses. Requirment of JavaScript.
	(3).days().fromNow();
	(6).months().fromNow();

	// Declared Number variables do not require parentheses. 
	var n = 6;
	n.months().fromNow();
	
* * @return {Date} A new Date instance */ $N.fromNow = $N.after = function (date) { var c = {}; c[this._dateElement] = this; return ((!date) ? new Date() : date.clone()).add(c); }; /** * Creates a new Date() and subtract this (Number) from the date based on the preceding date element function (eg. second|minute|hour|day|month|year). * Example

	// Undeclared Numbers must be wrapped with parentheses. Requirment of JavaScript.
	(3).days().ago();
	(6).months().ago();

	// Declared Number variables do not require parentheses. 
	var n = 6;
	n.months().ago();
	
* * @return {Date} A new Date instance */ $N.ago = $N.before = function (date) { var c = {}, s = (this._dateElement[this._dateElement.length-1] !== "s") ? this._dateElement + "s" : this._dateElement; c[s] = this * -1; return ((!date) ? new Date() : date.clone()).add(c); }; // Do NOT modify the following string tokens. These tokens are used to build dynamic functions. // All culture-specific strings can be found in the CultureInfo files. var dx = ("sunday monday tuesday wednesday thursday friday saturday").split(/\s/), mx = ("january february march april may june july august september october november december").split(/\s/), px = ("Millisecond Second Minute Hour Day Week Month Year Quarter Weekday").split(/\s/), pxf = ("Milliseconds Seconds Minutes Hours Date Week Month FullYear Quarter").split(/\s/), nth = ("final first second third fourth fifth").split(/\s/), de; /** * Returns an object literal of all the date parts. * Example

	var o = new Date().toObject();
	
	// { year: 2008, month: 4, week: 20, day: 13, hour: 18, minute: 9, second: 32, millisecond: 812 }
	
	// The object properties can be referenced directly from the object.
	
	alert(o.day);  // alerts "13"
	alert(o.year); // alerts "2008"
	
* * @return {Date} An object literal representing the original date object. */ $P.toObject = function () { var o = {}; for (var i = 0; i < px.length; i++) { if (this["get" + pxf[i]]) { o[px[i].toLowerCase()] = this["get" + pxf[i]](); } } return o; }; /** * Returns a date created from an object literal. Ignores the .week property if set in the config. * Example

	var o = new Date().toObject();
	
	return Date.fromObject(o); // will return the same date. 

	var o2 = {month: 1, day: 20, hour: 18}; // birthday party!
	Date.fromObject(o2);
	
* * @return {Date} An object literal representing the original date object. */ $D.fromObject = function(config) { config.week = null; return Date.today().set(config); }; // Create day name functions and abbreviated day name functions (eg. monday(), friday(), fri()). var df = function (n) { return function () { if (this._is) { this._is = false; return this.getDay() === n; } if (this._move) { this._move = null; } if (this._nth !== null) { // If the .second() function was called earlier, remove the _orient // from the date, and then continue. // This is required because 'second' can be used in two different context. // // Example // // Date.today().add(1).second(); // Date.march().second().monday(); // // Things get crazy with the following... // Date.march().add(1).second().second().monday(); // but it works!! // if (this._isSecond) { this.addSeconds(this._orient * -1); } // make sure we reset _isSecond this._isSecond = false; var ntemp = this._nth; this._nth = null; var temp = this.clone().moveToLastDayOfMonth(); this.moveToNthOccurrence(n, ntemp); if (this > temp) { throw new RangeError($D.getDayName(n) + " does not occur " + ntemp + " times in the month of " + $D.getMonthName(temp.getMonth()) + " " + temp.getFullYear() + "."); } return this; } return this.moveToDayOfWeek(n, this._orient); }; }; var sdf = function (n) { return function () { var t = $D.today(), shift = n - t.getDay(); if (n === 0 && Date.CultureInfo.firstDayOfWeek === 1 && t.getDay() !== 0) { shift = shift + 7; } return t.addDays(shift); }; }; // Create month name functions and abbreviated month name functions (eg. january(), march(), mar()). var month_instance_functions = function (n) { return function () { if (this._is) { this._is = false; return this.getMonth() === n; } return this.moveToMonth(n, this._orient); }; }; var month_static_functions = function (n) { return function () { return $D.today().set({ month: n, day: 1 }); }; }; var processTerms = function (names, staticFunc, instanceFunc) { for (var i = 0; i < names.length; i++) { // Create constant static Name variables. $D[names[i].toUpperCase()] = $D[names[i].toUpperCase().substring(0, 3)] = i; // Create Name functions. $D[names[i]] = $D[names[i].substring(0, 3)] = staticFunc(i); // Create Name instance functions. $P[names[i]] = $P[names[i].substring(0, 3)] = instanceFunc(i); } }; processTerms(dx, sdf, df); processTerms(mx, month_static_functions, month_instance_functions); // Create date element functions and plural date element functions used with Date (eg. day(), days(), months()). var ef = function (j) { return function () { // if the .second() function was called earlier, the _orient // has alread been added. Just return this and reset _isSecond. if (this._isSecond) { this._isSecond = false; return this; } if (this._same) { this._same = this._is = false; var o1 = this.toObject(), o2 = (arguments[0] || new Date()).toObject(), v = "", k = j.toLowerCase(); // the substr trick with -1 doesn't work in IE8 or less k = (k[k.length-1] === "s") ? k.substring(0,k.length-1) : k; for (var m = (px.length - 1); m > -1; m--) { v = px[m].toLowerCase(); if (o1[v] !== o2[v]) { return false; } if (k === v) { break; } } return true; } if (j.substring(j.length - 1) !== "s") { j += "s"; } if (this._move) { this._move = null; } return this["add" + j](this._orient); }; }; var nf = function (n) { return function () { this._dateElement = n; return this; }; }; for (var k = 0; k < px.length; k++) { de = px[k].toLowerCase(); if(de !== "weekday") { // Create date element functions and plural date element functions used with Date (eg. day(), days(), months()). $P[de] = $P[de + "s"] = ef(px[k]); // Create date element functions and plural date element functions used with Number (eg. day(), days(), months()). $N[de] = $N[de + "s"] = nf(de + "s"); } } $P._ss = ef("Second"); var nthfn = function (n) { return function (dayOfWeek) { if (this._same) { return this._ss(arguments[0]); } if (dayOfWeek || dayOfWeek === 0) { return this.moveToNthOccurrence(dayOfWeek, n); } this._nth = n; // if the operator is 'second' add the _orient, then deal with it later... if (n === 2 && (dayOfWeek === undefined || dayOfWeek === null)) { this._isSecond = true; return this.addSeconds(this._orient); } return this; }; }; for (var l = 0; l < nth.length; l++) { $P[nth[l]] = (l === 0) ? nthfn(-1) : nthfn(l); } }()); (function () { "use strict"; Date.Parsing = { Exception: function (s) { this.message = "Parse error at '" + s.substring(0, 10) + " ...'"; } }; var $P = Date.Parsing; var dayOffsets = { standard: [0,31,59,90,120,151,181,212,243,273,304,334], leap: [0,31,60,91,121,152,182,213,244,274,305,335] }; $P.isLeapYear = function(year) { return ((year % 4 === 0) && (year % 100 !== 0)) || (year % 400 === 0); }; var utils = { multiReplace : function (str, hash ) { var key; for (key in hash) { if (Object.prototype.hasOwnProperty.call(hash, key)) { var regex; if (typeof hash[key] === "function") { } else { regex = (hash[key] instanceof RegExp) ? hash[key] : new RegExp(hash[key], "g"); } str = str.replace(regex, key); } } return str; }, getDayOfYearFromWeek : function (obj) { var d, jan4, offset; obj.weekDay = (!obj.weekDay && obj.weekDay !== 0) ? 1 : obj.weekDay; d = new Date(obj.year, 0, 4); jan4 = d.getDay() === 0 ? 7 : d.getDay(); // JS is 0 indexed on Sunday. offset = jan4+3; obj.dayOfYear = ((obj.week * 7) + (obj.weekDay === 0 ? 7 : obj.weekDay))-offset; return obj; }, getDayOfYear : function (obj, dayOffset) { if (!obj.dayOfYear) { obj = utils.getDayOfYearFromWeek(obj); } for (var i=0;i <= dayOffset.length;i++) { if (obj.dayOfYear < dayOffset[i] || i === dayOffset.length) { obj.day = obj.day ? obj.day : (obj.dayOfYear - dayOffset[i-1]); break; } else { obj.month = i; } } return obj; }, adjustForTimeZone : function (obj, date) { var offset; if (obj.zone.toUpperCase() === "Z" || (obj.zone_hours === 0 && obj.zone_minutes === 0)) { // it's UTC/GML so work out the current timeszone offset offset = -date.getTimezoneOffset(); } else { offset = (obj.zone_hours*60) + (obj.zone_minutes || 0); if (obj.zone_sign === "+") { offset *= -1; } offset -= date.getTimezoneOffset(); } date.setMinutes(date.getMinutes()+offset); return date; }, setDefaults : function (obj) { obj.year = obj.year || Date.today().getFullYear(); obj.hours = obj.hours || 0; obj.minutes = obj.minutes || 0; obj.seconds = obj.seconds || 0; obj.milliseconds = obj.milliseconds || 0; if (!(!obj.month && (obj.week || obj.dayOfYear))) { // if we have a month, or if we don't but don't have the day calculation data obj.month = obj.month || 0; obj.day = obj.day || 1; } return obj; }, dataNum: function (data, mod, explict, postProcess) { var dataNum = data*1; if (mod) { if (postProcess) { return data ? mod(data)*1 : data; } else { return data ? mod(dataNum) : data; } } else if (!explict){ return data ? dataNum : data; } else { return (data && typeof data !== "undefined") ? dataNum : data; } }, timeDataProcess: function (obj) { var timeObj = {}; for (var x in obj.data) { if (obj.data.hasOwnProperty(x)) { timeObj[x] = obj.ignore[x] ? obj.data[x] : utils.dataNum(obj.data[x], obj.mods[x], obj.explict[x], obj.postProcess[x]); } } if (obj.data.secmins) { obj.data.secmins = obj.data.secmins.replace(",", ".") * 60; if (!timeObj.minutes) { timeObj.minutes = obj.data.secmins; } else if (!timeObj.seconds) { timeObj.seconds = obj.data.secmins; } delete obj.secmins; } return timeObj; }, buildTimeObjectFromData: function (data) { var time = utils.timeDataProcess({ data: { year : data[1], month : data[5], day : data[7], week : data[8], dayOfYear : data[10], hours : data[15], zone_hours : data[23], zone_minutes : data[24], zone : data[21], zone_sign : data[22], weekDay : data[9], minutes: data[16], seconds: data[19], milliseconds: data[20], secmins: data[18] }, mods: { month: function(data) { return data-1; }, weekDay: function (data) { data = Math.abs(data); return (data === 7 ? 0 : data); }, minutes: function (data) { return data.replace(":",""); }, seconds: function (data) { return Math.floor( (data.replace(":","").replace(",","."))*1 ); }, milliseconds: function (data) { return (data.replace(",",".")*1000); } }, postProcess: { minutes: true, seconds: true, milliseconds: true }, explict: { zone_hours: true, zone_minutes: true }, ignore: { zone: true, zone_sign: true, secmins: true } }); return time; }, addToHash: function (hash, keys, data) { keys = keys; data = data; var len = keys.length; for (var i = 0; i < len; i++) { hash[keys[i]] = data[i]; } return hash; }, combineRegex: function (r1, r2) { return new RegExp("(("+r1.source+")\\s("+r2.source+"))"); }, getDateNthString: function(add, last, inc){ if (add) { return Date.today().addDays(inc).toString("d"); } else if (last) { return Date.today().last()[inc]().toString("d"); } }, buildRegexData: function (array) { var arr = []; var len = array.length; for (var i=0; i < len; i++) { if (Object.prototype.toString.call(array[i]) === '[object Array]') { // oldIE compat version of Array.isArray arr.push(this.combineRegex(array[i][0], array[i][1])); } else { arr.push(array[i]); } } return arr; } }; $P.processTimeObject = function (obj) { var date, dayOffset; utils.setDefaults(obj); dayOffset = ($P.isLeapYear(obj.year)) ? dayOffsets.leap : dayOffsets.standard; if (!obj.month && (obj.week || obj.dayOfYear)) { utils.getDayOfYear(obj, dayOffset); } else { obj.dayOfYear = dayOffset[obj.month] + obj.day; } date = new Date(obj.year, obj.month, obj.day, obj.hours, obj.minutes, obj.seconds, obj.milliseconds); if (obj.zone) { utils.adjustForTimeZone(obj, date); // adjust (and calculate) for timezone } return date; }; $P.ISO = { regex : /^([\+-]?\d{4}(?!\d{2}\b))((-?)((0[1-9]|1[0-2])(\3([12]\d|0[1-9]|3[01]))?|W([0-4]\d|5[0-3])(-?[1-7])?|(00[1-9]|0[1-9]\d|[12]\d{2}|3([0-5]\d|6[1-6])))([T\s]((([01]\d|2[0-4])((:?)[0-5]\d)?|24\:?00)([\.,]\d+(?!:))?)?(\17[0-5]\d([\.,]\d+)?)?\s?([zZ]|([\+-])([01]\d|2[0-3]):?([0-5]\d)?)?)?)?$/, parse : function (s) { var time, data = s.match(this.regex); if (!data || !data.length) { return null; } time = utils.buildTimeObjectFromData(data); if (!time.year || (!time.year && (!time.month && !time.day) && (!time.week && !time.dayOfYear)) ) { return null; } return $P.processTimeObject(time); } }; $P.Numeric = { isNumeric: function (e){return!isNaN(parseFloat(e))&&isFinite(e);}, regex: /\b([0-1]?[0-9])([0-3]?[0-9])([0-2]?[0-9]?[0-9][0-9])\b/i, parse: function (s) { var data, i, time = {}, order = Date.CultureInfo.dateElementOrder.split(""); if (!(this.isNumeric(s)) || // if it's non-numeric OR (s[0] === "+" && s[0] === "-")) { // It's an arithmatic string (eg +/-1000) return null; } if (s.length < 5 && s.indexOf(".") < 0 && s.indexOf("/") < 0) { // assume it's just a year. time.year = s; return $P.processTimeObject(time); } data = s.match(this.regex); if (!data || !data.length) { return null; } for (i=0; i < order.length; i++) { switch(order[i]) { case "d": time.day = data[i+1]; break; case "m": time.month = (data[i+1]-1); break; case "y": time.year = data[i+1]; break; } } return $P.processTimeObject(time); } }; $P.Normalizer = { regexData: function () { var $R = Date.CultureInfo.regexPatterns; return utils.buildRegexData([ $R.tomorrow, $R.yesterday, [$R.past, $R.mon], [$R.past, $R.tue], [$R.past, $R.wed], [$R.past, $R.thu], [$R.past, $R.fri], [$R.past, $R.sat], [$R.past, $R.sun] ]); }, basicReplaceHash : function() { var $R = Date.CultureInfo.regexPatterns; return { "January": $R.jan.source, "February": $R.feb, "March": $R.mar, "April": $R.apr, "May": $R.may, "June": $R.jun, "July": $R.jul, "August": $R.aug, "September": $R.sep, "October": $R.oct, "November": $R.nov, "December": $R.dec, "": /\bat\b/gi, " ": /\s{2,}/, "am": $R.inTheMorning, "9am": $R.thisMorning, "pm": $R.inTheEvening, "7pm":$R.thisEvening }; }, keys : function(){ return [ utils.getDateNthString(true, false, 1), // tomorrow utils.getDateNthString(true, false, -1), // yesterday utils.getDateNthString(false, true, "monday"), //last mon utils.getDateNthString(false, true, "tuesday"), //last tues utils.getDateNthString(false, true, "wednesday"), //last wed utils.getDateNthString(false, true, "thursday"), //last thurs utils.getDateNthString(false, true, "friday"), //last fri utils.getDateNthString(false, true, "saturday"), //last sat utils.getDateNthString(false, true, "sunday") //last sun ]; }, buildRegexFunctions: function () { var $R = Date.CultureInfo.regexPatterns; var __ = Date.i18n.__; var tomorrowRE = new RegExp("(\\b\\d\\d?("+__("AM")+"|"+__("PM")+")? )("+$R.tomorrow.source.slice(1)+")", "i"); // adapted tomorrow regex for AM PM relative dates var todayRE = new RegExp($R.today.source + "(?!\\s*([+-]))\\b"); // today, but excludes the math operators (eg "today + 2h") this.replaceFuncs = [ [todayRE, function (full) { return (full.length > 1) ? Date.today().toString("d") : full; }], [tomorrowRE, function(full, m1) { var t = Date.today().addDays(1).toString("d"); return (t + " " + m1); }], [$R.amThisMorning, function(str, am){return am;}], [$R.pmThisEvening, function(str, pm){return pm;}] ]; }, buildReplaceData: function () { this.buildRegexFunctions(); this.replaceHash = utils.addToHash(this.basicReplaceHash(), this.keys(), this.regexData()); }, stringReplaceFuncs: function (s) { for (var i=0; i < this.replaceFuncs.length; i++) { s = s.replace(this.replaceFuncs[i][0], this.replaceFuncs[i][1]); } return s; }, parse: function (s) { s = this.stringReplaceFuncs(s); s = utils.multiReplace(s, this.replaceHash); try { var n = s.split(/([\s\-\.\,\/\x27]+)/); if (n.length === 3 && $P.Numeric.isNumeric(n[0]) && $P.Numeric.isNumeric(n[2]) && (n[2].length >= 4)) { // ok, so we're dealing with x/year. But that's not a full date. // This fixes wonky dateElementOrder parsing when set to dmy order. if (Date.CultureInfo.dateElementOrder[0] === "d") { s = "1/" + n[0] + "/" + n[2]; // set to 1st of month and normalize the seperator } } } catch (e) {} return s; } }; $P.Normalizer.buildReplaceData(); }()); (function () { var $P = Date.Parsing; var _ = $P.Operators = { // // Tokenizers // rtoken: function (r) { // regex token return function (s) { var mx = s.match(r); if (mx) { return ([ mx[0], s.substring(mx[0].length) ]); } else { throw new $P.Exception(s); } }; }, token: function () { // whitespace-eating token return function (s) { return _.rtoken(new RegExp("^\\s*" + s + "\\s*"))(s); }; }, stoken: function (s) { // string token return _.rtoken(new RegExp("^" + s)); }, // Atomic Operators until: function (p) { return function (s) { var qx = [], rx = null; while (s.length) { try { rx = p.call(this, s); } catch (e) { qx.push(rx[0]); s = rx[1]; continue; } break; } return [ qx, s ]; }; }, many: function (p) { return function (s) { var rx = [], r = null; while (s.length) { try { r = p.call(this, s); } catch (e) { return [ rx, s ]; } rx.push(r[0]); s = r[1]; } return [ rx, s ]; }; }, // generator operators -- see below optional: function (p) { return function (s) { var r = null; try { r = p.call(this, s); } catch (e) { return [ null, s ]; } return [ r[0], r[1] ]; }; }, not: function (p) { return function (s) { try { p.call(this, s); } catch (e) { return [null, s]; } throw new $P.Exception(s); }; }, ignore: function (p) { return p ? function (s) { var r = null; r = p.call(this, s); return [null, r[1]]; } : null; }, product: function () { var px = arguments[0], qx = Array.prototype.slice.call(arguments, 1), rx = []; for (var i = 0 ; i < px.length ; i++) { rx.push(_.each(px[i], qx)); } return rx; }, cache: function (rule) { var cache = {}, cache_length = 0, cache_keys = [], CACHE_MAX = Date.Config.CACHE_MAX || 100000, r = null; var cacheCheck = function () { if (cache_length === CACHE_MAX) { // kill several keys, don't want to have to do this all the time... for (var i=0; i < 10; i++) { var key = cache_keys.shift(); if (key) { delete cache[key]; cache_length--; } } } }; return function (s) { cacheCheck(); try { r = cache[s] = (cache[s] || rule.call(this, s)); } catch (e) { r = cache[s] = e; } cache_length++; cache_keys.push(s); if (r instanceof $P.Exception) { throw r; } else { return r; } }; }, // vector operators -- see below any: function () { var px = arguments; return function (s) { var r = null; for (var i = 0; i < px.length; i++) { if (px[i] == null) { continue; } try { r = (px[i].call(this, s)); } catch (e) { r = null; } if (r) { return r; } } throw new $P.Exception(s); }; }, each: function () { var px = arguments; return function (s) { var rx = [], r = null; for (var i = 0; i < px.length ; i++) { if (px[i] == null) { continue; } try { r = (px[i].call(this, s)); } catch (e) { throw new $P.Exception(s); } rx.push(r[0]); s = r[1]; } return [ rx, s]; }; }, all: function () { var px = arguments, _ = _; return _.each(_.optional(px)); }, // delimited operators sequence: function (px, d, c) { d = d || _.rtoken(/^\s*/); c = c || null; if (px.length === 1) { return px[0]; } return function (s) { var r = null, q = null; var rx = []; for (var i = 0; i < px.length ; i++) { try { r = px[i].call(this, s); } catch (e) { break; } rx.push(r[0]); try { q = d.call(this, r[1]); } catch (ex) { q = null; break; } s = q[1]; } if (!r) { throw new $P.Exception(s); } if (q) { throw new $P.Exception(q[1]); } if (c) { try { r = c.call(this, r[1]); } catch (ey) { throw new $P.Exception(r[1]); } } return [ rx, (r?r[1]:s) ]; }; }, // // Composite Operators // between: function (d1, p, d2) { d2 = d2 || d1; var _fn = _.each(_.ignore(d1), p, _.ignore(d2)); return function (s) { var rx = _fn.call(this, s); return [[rx[0][0], r[0][2]], rx[1]]; }; }, list: function (p, d, c) { d = d || _.rtoken(/^\s*/); c = c || null; return (p instanceof Array ? _.each(_.product(p.slice(0, -1), _.ignore(d)), p.slice(-1), _.ignore(c)) : _.each(_.many(_.each(p, _.ignore(d))), px, _.ignore(c))); }, set: function (px, d, c) { d = d || _.rtoken(/^\s*/); c = c || null; return function (s) { // r is the current match, best the current 'best' match // which means it parsed the most amount of input var r = null, p = null, q = null, rx = null, best = [[], s], last = false; // go through the rules in the given set for (var i = 0; i < px.length ; i++) { // last is a flag indicating whether this must be the last element // if there is only 1 element, then it MUST be the last one q = null; p = null; r = null; last = (px.length === 1); // first, we try simply to match the current pattern // if not, try the next pattern try { r = px[i].call(this, s); } catch (e) { continue; } // since we are matching against a set of elements, the first // thing to do is to add r[0] to matched elements rx = [[r[0]], r[1]]; // if we matched and there is still input to parse and // we don't already know this is the last element, // we're going to next check for the delimiter ... // if there's none, or if there's no input left to parse // than this must be the last element after all ... if (r[1].length > 0 && ! last) { try { q = d.call(this, r[1]); } catch (ex) { last = true; } } else { last = true; } // if we parsed the delimiter and now there's no more input, // that means we shouldn't have parsed the delimiter at all // so don't update r and mark this as the last element ... if (!last && q[1].length === 0) { last = true; } // so, if this isn't the last element, we're going to see if // we can get any more matches from the remaining (unmatched) // elements ... if (!last) { // build a list of the remaining rules we can match against, // i.e., all but the one we just matched against var qx = []; for (var j = 0; j < px.length ; j++) { if (i !== j) { qx.push(px[j]); } } // now invoke recursively set with the remaining input // note that we don't include the closing delimiter ... // we'll check for that ourselves at the end p = _.set(qx, d).call(this, q[1]); // if we got a non-empty set as a result ... // (otw rx already contains everything we want to match) if (p[0].length > 0) { // update current result, which is stored in rx ... // basically, pick up the remaining text from p[1] // and concat the result from p[0] so that we don't // get endless nesting ... rx[0] = rx[0].concat(p[0]); rx[1] = p[1]; } } // at this point, rx either contains the last matched element // or the entire matched set that starts with this element. // now we just check to see if this variation is better than // our best so far, in terms of how much of the input is parsed if (rx[1].length < best[1].length) { best = rx; } // if we've parsed all the input, then we're finished if (best[1].length === 0) { break; } } // so now we've either gone through all the patterns trying them // as the initial match; or we found one that parsed the entire // input string ... // if best has no matches, just return empty set ... if (best[0].length === 0) { return best; } // if a closing delimiter is provided, then we have to check it also if (c) { // we try this even if there is no remaining input because the pattern // may well be optional or match empty input ... try { q = c.call(this, best[1]); } catch (ey) { throw new $P.Exception(best[1]); } // it parsed ... be sure to update the best match remaining input best[1] = q[1]; } // if we're here, either there was no closing delimiter or we parsed it // so now we have the best match; just return it! return best; }; }, forward: function (gr, fname) { return function (s) { return gr[fname].call(this, s); }; }, // // Translation Operators // replace: function (rule, repl) { return function (s) { var r = rule.call(this, s); return [repl, r[1]]; }; }, process: function (rule, fn) { return function (s) { var r = rule.call(this, s); return [fn.call(this, r[0]), r[1]]; }; }, min: function (min, rule) { return function (s) { var rx = rule.call(this, s); if (rx[0].length < min) { throw new $P.Exception(s); } return rx; }; } }; // Generator Operators And Vector Operators // Generators are operators that have a signature of F(R) => R, // taking a given rule and returning another rule, such as // ignore, which parses a given rule and throws away the result. // Vector operators are those that have a signature of F(R1,R2,...) => R, // take a list of rules and returning a new rule, such as each. // Generator operators are converted (via the following _generator // function) into functions that can also take a list or array of rules // and return an array of new rules as though the function had been // called on each rule in turn (which is what actually happens). // This allows generators to be used with vector operators more easily. // Example: // each(ignore(foo, bar)) instead of each(ignore(foo), ignore(bar)) // This also turns generators into vector operators, which allows // constructs like: // not(cache(foo, bar)) var _generator = function (op) { function gen() { var args = null, rx = [], px, i; if (arguments.length > 1) { args = Array.prototype.slice.call(arguments); } else if (arguments[0] instanceof Array) { args = arguments[0]; } if (args) { px = args.shift(); if (px.length > 0) { args.unshift(px[i]); rx.push(op.apply(null, args)); args.shift(); return rx; } } else { return op.apply(null, arguments); } } return gen; }; var gx = "optional not ignore cache".split(/\s/); for (var i = 0 ; i < gx.length ; i++) { _[gx[i]] = _generator(_[gx[i]]); } var _vector = function (op) { return function () { if (arguments[0] instanceof Array) { return op.apply(null, arguments[0]); } else { return op.apply(null, arguments); } }; }; var vx = "each any all".split(/\s/); for (var j = 0 ; j < vx.length ; j++) { _[vx[j]] = _vector(_[vx[j]]); } }()); (function () { var $D = Date; var flattenAndCompact = function (ax) { var rx = []; for (var i = 0; i < ax.length; i++) { if (ax[i] instanceof Array) { rx = rx.concat(flattenAndCompact(ax[i])); } else { if (ax[i]) { rx.push(ax[i]); } } } return rx; }; var parseMeridian = function () { if (this.meridian && (this.hour || this.hour === 0)) { if (this.meridian === "a" && this.hour > 11 && Date.Config.strict24hr){ throw "Invalid hour and meridian combination"; } else if (this.meridian === "p" && this.hour < 12 && Date.Config.strict24hr){ throw "Invalid hour and meridian combination"; } else if (this.meridian === "p" && this.hour < 12) { this.hour = this.hour + 12; } else if (this.meridian === "a" && this.hour === 12) { this.hour = 0; } } }; var setDefaults = function () { var now = new Date(); if ((this.hour || this.minute) && (!this.month && !this.year && !this.day)) { this.day = now.getDate(); } if (!this.year) { this.year = now.getFullYear(); } if (!this.month && this.month !== 0) { this.month = now.getMonth(); } if (!this.day) { this.day = 1; } if (!this.hour) { this.hour = 0; } if (!this.minute) { this.minute = 0; } if (!this.second) { this.second = 0; } if (!this.millisecond) { this.millisecond = 0; } }; var finishUtils = { getToday: function () { if (this.now || "hour minute second".indexOf(this.unit) !== -1) { return new Date(); } else { return $D.today(); } }, setDaysFromWeekday: function (today, orient){ var gap; orient = orient || 1; this.unit = "day"; gap = ($D.getDayNumberFromName(this.weekday) - today.getDay()); this.days = gap ? ((gap + (orient * 7)) % 7) : (orient * 7); return this; }, setMonthsFromMonth: function (today, orient) { var gap; orient = orient || 1; this.unit = "month"; gap = (this.month - today.getMonth()); this.months = gap ? ((gap + (orient * 12)) % 12) : (orient * 12); this.month = null; return this; }, setDMYFromWeekday: function () { var d = Date[this.weekday](); this.day = d.getDate(); if (!this.month) { this.month = d.getMonth(); } this.year = d.getFullYear(); return this; }, setUnitValue: function (orient) { if (!this.value && this.operator && this.operator !== null && this[this.unit + "s"] && this[this.unit + "s"] !== null) { this[this.unit + "s"] = this[this.unit + "s"] + ((this.operator === "add") ? 1 : -1) + (this.value||0) * orient; } else if (this[this.unit + "s"] == null || this.operator != null) { if (!this.value) { this.value = 1; } this[this.unit + "s"] = this.value * orient; } }, generateDateFromWeeks: function () { var weekday = (this.weekday !== undefined) ? this.weekday : "today"; var d = Date[weekday]().addWeeks(this.weeks); if (this.now) { d.setTimeToNow(); } return d; } }; $D.Translator = { hour: function (s) { return function () { this.hour = Number(s); }; }, minute: function (s) { return function () { this.minute = Number(s); }; }, second: function (s) { return function () { this.second = Number(s); }; }, /* for ss.s format */ secondAndMillisecond: function (s) { return function () { var mx = s.match(/^([0-5][0-9])\.([0-9]{1,3})/); this.second = Number(mx[1]); this.millisecond = Number(mx[2]); }; }, meridian: function (s) { return function () { this.meridian = s.slice(0, 1).toLowerCase(); }; }, timezone: function (s) { return function () { var n = s.replace(/[^\d\+\-]/g, ""); if (n.length) { this.timezoneOffset = Number(n); } else { this.timezone = s.toLowerCase(); } }; }, day: function (x) { var s = x[0]; return function () { this.day = Number(s.match(/\d+/)[0]); if (this.day < 1) { throw "invalid day"; } }; }, month: function (s) { return function () { this.month = (s.length === 3) ? "jan feb mar apr may jun jul aug sep oct nov dec".indexOf(s)/4 : Number(s) - 1; if (this.month < 0) { throw "invalid month"; } }; }, year: function (s) { return function () { var n = Number(s); this.year = ((s.length > 2) ? n : (n + (((n + 2000) < Date.CultureInfo.twoDigitYearMax) ? 2000 : 1900))); }; }, rday: function (s) { return function () { switch (s) { case "yesterday": this.days = -1; break; case "tomorrow": this.days = 1; break; case "today": this.days = 0; break; case "now": this.days = 0; this.now = true; break; } }; }, finishExact: function (x) { var d; x = (x instanceof Array) ? x : [x]; for (var i = 0 ; i < x.length ; i++) { if (x[i]) { x[i].call(this); } } setDefaults.call(this); parseMeridian.call(this); if (this.day > $D.getDaysInMonth(this.year, this.month)) { throw new RangeError(this.day + " is not a valid value for days."); } d = new Date(this.year, this.month, this.day, this.hour, this.minute, this.second, this.millisecond); if (this.year < 100) { d.setFullYear(this.year); // means years less that 100 are process correctly. JS will parse it otherwise as 1900-1999. } if (this.timezone) { d.set({ timezone: this.timezone }); } else if (this.timezoneOffset) { d.set({ timezoneOffset: this.timezoneOffset }); } return d; }, finish: function (x) { var today, expression, orient, temp; x = (x instanceof Array) ? flattenAndCompact(x) : [ x ]; if (x.length === 0) { return null; } for (var i = 0 ; i < x.length ; i++) { if (typeof x[i] === "function") { x[i].call(this); } } if (this.now && !this.unit && !this.operator) { return new Date(); } else { today = finishUtils.getToday.call(this); } expression = !!(this.days && this.days !== null || this.orient || this.operator); orient = ((this.orient === "past" || this.operator === "subtract") ? -1 : 1); if (this.month && this.unit === "week") { this.value = this.month + 1; delete this.month; delete this.day; } if ((this.month || this.month === 0) && "year day hour minute second".indexOf(this.unit) !== -1) { if (!this.value) { this.value = this.month + 1; } this.month = null; expression = true; } if (!expression && this.weekday && !this.day && !this.days) { finishUtils.setDMYFromWeekday.call(this); } if (expression && this.weekday && this.unit !== "month" && this.unit !== "week") { finishUtils.setDaysFromWeekday.call(this, today, orient); } if (this.weekday && this.unit !== "week" && !this.day && !this.days) { temp = Date[this.weekday](); this.day = temp.getDate(); if (temp.getMonth() !== today.getMonth()) { this.month = temp.getMonth(); } } if (this.month && this.unit === "day" && this.operator) { if (!this.value) { this.value = (this.month + 1); } this.month = null; } if (this.value != null && this.month != null && this.year != null) { this.day = this.value * 1; } if (this.month && !this.day && this.value) { today.set({ day: this.value * 1 }); if (!expression) { this.day = this.value * 1; } } if (!this.month && this.value && this.unit === "month" && !this.now) { this.month = this.value; expression = true; } if (expression && (this.month || this.month === 0) && this.unit !== "year") { finishUtils.setMonthsFromMonth.call(this, today, orient); } if (!this.unit) { this.unit = "day"; } finishUtils.setUnitValue.call(this, orient); parseMeridian.call(this); if ((this.month || this.month === 0) && !this.day) { this.day = 1; } if (!this.orient && !this.operator && this.unit === "week" && this.value && !this.day && !this.month) { return Date.today().setWeek(this.value); } if (this.unit === "week" && this.weeks && !this.day && !this.month) { return finishUtils.generateDateFromWeeks.call(this); } if (expression && this.timezone && this.day && this.days) { this.day = this.days; } if (expression){ today.add(this); } else { today.set(this); } if (this.timezone) { this.timezone = this.timezone.toUpperCase(); var offset = $D.getTimezoneOffset(this.timezone); var timezone; if (today.hasDaylightSavingTime()) { // lets check that we're being sane with timezone setting timezone = $D.getTimezoneAbbreviation(offset, today.isDaylightSavingTime()); if (timezone !== this.timezone) { // bugger, we're in a place where things like EST vs EDT matters. if (today.isDaylightSavingTime()) { today.addHours(-1); } else { today.addHours(1); } } } today.setTimezoneOffset(offset); } return today; } }; }()); (function () { var $D = Date; $D.Grammar = {}; var _ = $D.Parsing.Operators, g = $D.Grammar, t = $D.Translator, _fn; // Allow rolling up into general purpose rules _fn = function () { return _.each(_.any.apply(null, arguments), _.not(g.ctoken2("timeContext"))); }; g.datePartDelimiter = _.rtoken(/^([\s\-\.\,\/\x27]+)/); g.timePartDelimiter = _.stoken(":"); g.whiteSpace = _.rtoken(/^\s*/); g.generalDelimiter = _.rtoken(/^(([\s\,]|at|@|on)+)/); var _C = {}; g.ctoken = function (keys) { var fn = _C[keys]; if (! fn) { var c = Date.CultureInfo.regexPatterns; var kx = keys.split(/\s+/), px = []; for (var i = 0; i < kx.length ; i++) { px.push(_.replace(_.rtoken(c[kx[i]]), kx[i])); } fn = _C[keys] = _.any.apply(null, px); } return fn; }; g.ctoken2 = function (key) { return _.rtoken(Date.CultureInfo.regexPatterns[key]); }; var cacheProcessRtoken = function (key, token, type, eachToken) { if (eachToken) { g[key] = _.cache(_.process(_.each(_.rtoken(token),_.optional(g.ctoken2(eachToken))), type)); } else { g[key] = _.cache(_.process(_.rtoken(token), type)); } }; var cacheProcessCtoken = function (token, type) { return _.cache(_.process(g.ctoken2(token), type)); }; var _F = {}; //function cache var _get = function (f) { _F[f] = (_F[f] || g.format(f)[0]); return _F[f]; }; g.allformats = function (fx) { var rx = []; if (fx instanceof Array) { for (var i = 0; i < fx.length; i++) { rx.push(_get(fx[i])); } } else { rx.push(_get(fx)); } return rx; }; g.formats = function (fx) { if (fx instanceof Array) { var rx = []; for (var i = 0 ; i < fx.length ; i++) { rx.push(_get(fx[i])); } return _.any.apply(null, rx); } else { return _get(fx); } }; var grammarFormats = { timeFormats: function(){ var i, RTokenKeys = [ "h", "hh", "H", "HH", "m", "mm", "s", "ss", "ss.s", "z", "zz" ], RToken = [ /^(0[0-9]|1[0-2]|[1-9])/, /^(0[0-9]|1[0-2])/, /^([0-1][0-9]|2[0-3]|[0-9])/, /^([0-1][0-9]|2[0-3])/, /^([0-5][0-9]|[0-9])/, /^[0-5][0-9]/, /^([0-5][0-9]|[0-9])/, /^[0-5][0-9]/, /^[0-5][0-9]\.[0-9]{1,3}/, /^((\+|\-)\s*\d\d\d\d)|((\+|\-)\d\d\:?\d\d)/, /^((\+|\-)\s*\d\d\d\d)|((\+|\-)\d\d\:?\d\d)/ ], tokens = [ t.hour, t.hour, t.hour, t.hour, t.minute, t.minute, t.second, t.second, t.secondAndMillisecond, t.timezone, t.timezone ]; for (i=0; i < RTokenKeys.length; i++) { cacheProcessRtoken(RTokenKeys[i], RToken[i], tokens[i]); } g.hms = _.cache(_.sequence([g.H, g.m, g.s], g.timePartDelimiter)); g.t = cacheProcessCtoken("shortMeridian", t.meridian); g.tt = cacheProcessCtoken("longMeridian", t.meridian); g.zzz = cacheProcessCtoken("timezone", t.timezone); g.timeSuffix = _.each(_.ignore(g.whiteSpace), _.set([ g.tt, g.zzz ])); g.time = _.each(_.optional(_.ignore(_.stoken("T"))), g.hms, g.timeSuffix); }, dateFormats: function () { // pre-loaded rules for different date part order preferences var _setfn = function () { return _.set(arguments, g.datePartDelimiter); }; var i, RTokenKeys = [ "d", "dd", "M", "MM", "y", "yy", "yyy", "yyyy" ], RToken = [ /^([0-2]\d|3[0-1]|\d)/, /^([0-2]\d|3[0-1])/, /^(1[0-2]|0\d|\d)/, /^(1[0-2]|0\d)/, /^(\d+)/, /^(\d\d)/, /^(\d\d?\d?\d?)/, /^(\d\d\d\d)/ ], tokens = [ t.day, t.day, t.month, t.month, t.year, t.year, t.year, t.year ], eachToken = [ "ordinalSuffix", "ordinalSuffix" ]; for (i=0; i < RTokenKeys.length; i++) { cacheProcessRtoken(RTokenKeys[i], RToken[i], tokens[i], eachToken[i]); } g.MMM = g.MMMM = _.cache(_.process(g.ctoken("jan feb mar apr may jun jul aug sep oct nov dec"), t.month)); g.ddd = g.dddd = _.cache(_.process(g.ctoken("sun mon tue wed thu fri sat"), function (s) { return function () { this.weekday = s; }; } )); g.day = _fn(g.d, g.dd); g.month = _fn(g.M, g.MMM); g.year = _fn(g.yyyy, g.yy); g.mdy = _setfn(g.ddd, g.month, g.day, g.year); g.ymd = _setfn(g.ddd, g.year, g.month, g.day); g.dmy = _setfn(g.ddd, g.day, g.month, g.year); g.date = function (s) { return ((g[Date.CultureInfo.dateElementOrder] || g.mdy).call(this, s)); }; }, relative: function () { // relative date / time expressions g.orientation = _.process(g.ctoken("past future"), function (s) { return function () { this.orient = s; }; } ); g.operator = _.process(g.ctoken("add subtract"), function (s) { return function () { this.operator = s; }; } ); g.rday = _.process(g.ctoken("yesterday tomorrow today now"), t.rday); g.unit = _.process(g.ctoken("second minute hour day week month year"), function (s) { return function () { this.unit = s; }; } ); } }; g.buildGrammarFormats = function () { // these need to be rebuilt every time the language changes. _C = {}; grammarFormats.timeFormats(); grammarFormats.dateFormats(); grammarFormats.relative(); g.value = _.process(_.rtoken(/^([-+]?\d+)?(st|nd|rd|th)?/), function (s) { return function () { this.value = s.replace(/\D/g, ""); }; } ); g.expression = _.set([g.rday, g.operator, g.value, g.unit, g.orientation, g.ddd, g.MMM ]); g.format = _.process(_.many( _.any( // translate format specifiers into grammar rules _.process( _.rtoken(/^(dd?d?d?(?!e)|MM?M?M?|yy?y?y?|hh?|HH?|mm?|ss?|tt?|zz?z?)/), function (fmt) { if (g[fmt]) { return g[fmt]; } else { throw $D.Parsing.Exception(fmt); } } ), // translate separator tokens into token rules _.process(_.rtoken(/^[^dMyhHmstz]+/), // all legal separators function (s) { return _.ignore(_.stoken(s)); } ) ) ), // construct the parser ... function (rules) { return _.process(_.each.apply(null, rules), t.finishExact); } ); // starting rule for general purpose grammar g._start = _.process(_.set([ g.date, g.time, g.expression ], g.generalDelimiter, g.whiteSpace), t.finish); }; g.buildGrammarFormats(); // parsing date format specifiers - ex: "h:m:s tt" // this little guy will generate a custom parser based // on the format string, ex: g.format("h:m:s tt") // check for these formats first g._formats = g.formats([ "\"yyyy-MM-ddTHH:mm:ssZ\"", "yyyy-MM-ddTHH:mm:ss.sz", "yyyy-MM-ddTHH:mm:ssZ", "yyyy-MM-ddTHH:mm:ssz", "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-ddTHH:mmZ", "yyyy-MM-ddTHH:mmz", "yyyy-MM-ddTHH:mm", "ddd, MMM dd, yyyy H:mm:ss tt", "ddd MMM d yyyy HH:mm:ss zzz", "MMddyyyy", "ddMMyyyy", "Mddyyyy", "ddMyyyy", "Mdyyyy", "dMyyyy", "yyyy", "Mdyy", "dMyy", "d" ]); // real starting rule: tries selected formats first, // then general purpose rule g.start = function (s) { try { var r = g._formats.call({}, s); if (r[1].length === 0) { return r; } } catch (e) {} return g._start.call({}, s); }; }()); (function () { var $D = Date; /** * @desc Converts the specified string value into its JavaScript Date equivalent using CultureInfo specific format information. * * Example

	///////////
	// Dates //
	///////////

	// 15-Oct-2004
	var d1 = Date.parse("10/15/2004");

	// 15-Oct-2004
	var d1 = Date.parse("15-Oct-2004");

	// 15-Oct-2004
	var d1 = Date.parse("2004.10.15");

	//Fri Oct 15, 2004
	var d1 = Date.parse("Fri Oct 15, 2004");

	///////////
	// Times //
	///////////

	// Today at 10 PM.
	var d1 = Date.parse("10 PM");

	// Today at 10:30 PM.
	var d1 = Date.parse("10:30 P.M.");

	// Today at 6 AM.
	var d1 = Date.parse("06am");

	/////////////////////
	// Dates and Times //
	/////////////////////

	// 8-July-2004 @ 10:30 PM
	var d1 = Date.parse("July 8th, 2004, 10:30 PM");

	// 1-July-2004 @ 10:30 PM
	var d1 = Date.parse("2004-07-01T22:30:00");

	////////////////////
	// Relative Dates //
	////////////////////

	// Returns today's date. The string "today" is culture specific.
	var d1 = Date.parse("today");

	// Returns yesterday's date. The string "yesterday" is culture specific.
	var d1 = Date.parse("yesterday");

	// Returns the date of the next thursday.
	var d1 = Date.parse("Next thursday");

	// Returns the date of the most previous monday.
	var d1 = Date.parse("last monday");

	// Returns today's day + one year.
	var d1 = Date.parse("next year");

	///////////////
	// Date Math //
	///////////////

	// Today + 2 days
	var d1 = Date.parse("t+2");

	// Today + 2 days
	var d1 = Date.parse("today + 2 days");

	// Today + 3 months
	var d1 = Date.parse("t+3m");

	// Today - 1 year
	var d1 = Date.parse("today - 1 year");

	// Today - 1 year
	var d1 = Date.parse("t-1y"); 


	/////////////////////////////
	// Partial Dates and Times //
	/////////////////////////////

	// July 15th of this year.
	var d1 = Date.parse("July 15");

	// 15th day of current day and year.
	var d1 = Date.parse("15");

	// July 1st of current year at 10pm.
	var d1 = Date.parse("7/1 10pm");
	
* * @param {String} The string value to convert into a Date object [Required] * @return {Date} A Date object or null if the string cannot be converted into a Date. */ var parseUtils = { removeOrds: function (s) { ords = s.match(/\b(\d+)(?:st|nd|rd|th)\b/); // find ordinal matches s = ((ords && ords.length === 2) ? s.replace(ords[0], ords[1]) : s); return s; }, grammarParser: function (s) { var r = null; try { r = $D.Grammar.start.call({}, s.replace(/^\s*(\S*(\s+\S+)*)\s*$/, "$1")); } catch (e) { return null; } return ((r[1].length === 0) ? r[0] : null); }, nativeFallback: function(s) { var t; try { // ok we haven't parsed it, last ditch attempt with the built-in parser. t = Date._parse(s); return (t || t === 0) ? new Date(t) : null; } catch (e) { return null; } } }; function parse (s) { var d; if (!s) { return null; } if (s instanceof Date) { return s.clone(); } if (s.length >= 4 && s.charAt(0) !== "0" && s.charAt(0) !== "+"&& s.charAt(0) !== "-") { // ie: 2004 will pass, 0800 won't. // Start with specific formats d = $D.Parsing.ISO.parse(s) || $D.Parsing.Numeric.parse(s); } if (d instanceof Date && !isNaN(d.getTime())) { return d; } else { // find ordinal dates (1st, 3rd, 8th, etc and remove them as they cause parsing issues) s = $D.Parsing.Normalizer.parse(parseUtils.removeOrds(s)); d = parseUtils.grammarParser(s); if (d !== null) { return d; } else { return parseUtils.nativeFallback(s); } } } if (!$D._parse) { $D._parse = $D.parse; } $D.parse = parse; Date.getParseFunction = function (fx) { var fns = Date.Grammar.allformats(fx); return function (s) { var r = null; for (var i = 0; i < fns.length; i++) { try { r = fns[i].call({}, s); } catch (e) { continue; } if (r[1].length === 0) { return r[0]; } } return null; }; }; /** * Converts the specified string value into its JavaScript Date equivalent using the specified format {String} or formats {Array} and the CultureInfo specific format information. * The format of the string value must match one of the supplied formats exactly. * * Example

	// 15-Oct-2004
	var d1 = Date.parseExact("10/15/2004", "M/d/yyyy");

	// 15-Oct-2004
	var d1 = Date.parse("15-Oct-2004", "M-ddd-yyyy");

	// 15-Oct-2004
	var d1 = Date.parse("2004.10.15", "yyyy.MM.dd");

	// Multiple formats
	var d1 = Date.parseExact("10/15/2004", ["M/d/yyyy", "MMMM d, yyyy"]);
	
* * @param {String} The string value to convert into a Date object [Required]. * @param {Object} The expected format {String} or an array of expected formats {Array} of the date string [Required]. * @return {Date} A Date object or null if the string cannot be converted into a Date. */ $D.parseExact = function (s, fx) { return $D.getParseFunction(fx)(s); }; }()); (function () { var $D = Date, $P = $D.prototype, // $C = $D.CultureInfo, // not used atm p = function (s, l) { if (!l) { l = 2; } return ("000" + s).slice(l * -1); }; /** * Converts a PHP format string to Java/.NET format string. * A PHP format string can be used with ._format or .format. * A Java/.NET format string can be used with .toString(). * The .parseExact function will only accept a Java/.NET format string * * Example * var f1 = "%m/%d/%y" * var f2 = Date.normalizeFormat(f1); // "MM/dd/yy" * * new Date().format(f1); // "04/13/08" * new Date()._format(f1); // "04/13/08" * new Date().toString(f2); // "04/13/08" * * var date = Date.parseExact("04/13/08", f2); // Sun Apr 13 2008 * * @param {String} A PHP format string consisting of one or more format spcifiers. * @return {String} The PHP format converted to a Java/.NET format string. */ var normalizerSubstitutions = { "d" : "dd", "%d": "dd", "D" : "ddd", "%a": "ddd", "j" : "dddd", "l" : "dddd", "%A": "dddd", "S" : "S", "F" : "MMMM", "%B": "MMMM", "m" : "MM", "%m": "MM", "M" : "MMM", "%b": "MMM", "%h": "MMM", "n" : "M", "Y" : "yyyy", "%Y": "yyyy", "y" : "yy", "%y": "yy", "g" : "h", "%I": "h", "G" : "H", "h" : "hh", "H" : "HH", "%H": "HH", "i" : "mm", "%M": "mm", "s" : "ss", "%S": "ss", "%r": "hh:mm tt", "%R": "H:mm", "%T": "H:mm:ss", "%X": "t", "%x": "d", "%e": "d", "%D": "MM/dd/yy", "%n": "\\n", "%t": "\\t", "e" : "z", "T" : "z", "%z": "z", "%Z": "z", "Z" : "ZZ", "N" : "u", "w" : "u", "%w": "u", "W" : "W", "%V": "W" }; var normalizer = { substitutes: function (m) { return normalizerSubstitutions[m]; }, interpreted: function (m, x) { var y; switch (m) { case "%u": return x.getDay() + 1; case "z": return x.getOrdinalNumber(); case "%j": return p(x.getOrdinalNumber(), 3); case "%U": var d1 = x.clone().set({month: 0, day: 1}).addDays(-1).moveToDayOfWeek(0), d2 = x.clone().addDays(1).moveToDayOfWeek(0, -1); return (d2 < d1) ? "00" : p((d2.getOrdinalNumber() - d1.getOrdinalNumber()) / 7 + 1); case "%W": return p(x.getWeek()); case "t": return $D.getDaysInMonth(x.getFullYear(), x.getMonth()); case "o": case "%G": return x.setWeek(x.getISOWeek()).toString("yyyy"); case "%g": return x._format("%G").slice(-2); case "a": case "%p": return t("tt").toLowerCase(); case "A": return t("tt").toUpperCase(); case "u": return p(x.getMilliseconds(), 3); case "I": return (x.isDaylightSavingTime()) ? 1 : 0; case "O": return x.getUTCOffset(); case "P": y = x.getUTCOffset(); return y.substring(0, y.length - 2) + ":" + y.substring(y.length - 2); case "B": var now = new Date(); return Math.floor(((now.getHours() * 3600) + (now.getMinutes() * 60) + now.getSeconds() + (now.getTimezoneOffset() + 60) * 60) / 86.4); case "c": return x.toISOString().replace(/\"/g, ""); case "U": return $D.strtotime("now"); case "%c": return t("d") + " " + t("t"); case "%C": return Math.floor(x.getFullYear() / 100 + 1); } }, shouldOverrideDefaults: function (m) { switch (m) { case "%e": return true; default: return false; } }, parse: function (m, context) { var formatString, c = context || new Date(); formatString = normalizer.substitutes(m); if (formatString) { return formatString; } formatString = normalizer.interpreted(m, c); if (formatString) { return formatString; } else { return m; } } }; $D.normalizeFormat = function (format, context) { return format.replace(/(%|\\)?.|%%/g, function(t){ return normalizer.parse(t, context); }); }; /** * Format a local Unix timestamp according to locale settings * * Example: * Date.strftime("%m/%d/%y", new Date()); // "04/13/08" * Date.strftime("c", "2008-04-13T17:52:03Z"); // "04/13/08" * * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @param {Number|String} The number representing the number of seconds that have elapsed since January 1, 1970 (local time). * @return {String} A string representation of the current Date object. */ $D.strftime = function (format, time) { var d = Date.parse(time); return d._format(format); }; /** * Parse any textual datetime description into a Unix timestamp. * A Unix timestamp is the number of seconds that have elapsed since January 1, 1970 (midnight UTC/GMT). * * Example: * Date.strtotime("04/13/08"); // 1208044800 * Date.strtotime("1970-01-01T00:00:00Z"); // 0 * * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @param {Object} A string or date object. * @return {String} A string representation of the current Date object. */ $D.strtotime = function (time) { var d = $D.parse(time); return Math.round($D.UTC(d.getUTCFullYear(), d.getUTCMonth(), d.getUTCDate(), d.getUTCHours(), d.getUTCMinutes(), d.getUTCSeconds(), d.getUTCMilliseconds()) / 1000); }; /** * Converts the value of the current Date object to its equivalent string representation using a PHP/Unix style of date format specifiers. * Format Specifiers * Format Description Example * ------ --------------------------------------------------------------------------- ----------------------- * %a abbreviated weekday name according to the current localed "Mon" through "Sun" * %A full weekday name according to the current localed "Sunday" through "Saturday" * %b abbreviated month name according to the current localed "Jan" through "Dec" * %B full month name according to the current locale "January" through "December" * %c preferred date and time representation for the current locale "4/13/2008 12:33 PM" * %C century number (the year divided by 100 and truncated to an integer) "00" to "99" * %d day of the month as a decimal number "01" to "31" * %D same as %m/%d/%y "04/13/08" * %e day of the month as a decimal number, a single digit is preceded by a space "1" to "31" * %g like %G, but without the century "08" * %G The 4-digit year corresponding to the ISO week number (see %V). "2008" * This has the same format and value as %Y, except that if the ISO week number * belongs to the previous or next year, that year is used instead. * %h same as %b "Jan" through "Dec" * %H hour as a decimal number using a 24-hour clock. "00" to "23" * %I hour as a decimal number using a 12-hour clock. "01" to "12" * %j day of the year as a decimal number. "001" to "366" * %m month as a decimal number. "01" to "12" * %M minute as a decimal number. "00" to "59" * %n newline character "\n" * %p either "am" or "pm" according to the given time value, or the "am" or "pm" * corresponding strings for the current locale. * %r time in a.m. and p.m. notation "8:44 PM" * %R time in 24 hour notation "20:44" * %S second as a decimal number "00" to "59" * %t tab character "\t" * %T current time, equal to %H:%M:%S "12:49:11" * %u weekday as a decimal number ["1", "7"], with "1" representing Monday "1" to "7" * %U week number of the current year as a decimal number, starting with the "0" to ("52" or "53") * first Sunday as the first day of the first week * %V The ISO 8601:1988 week number of the current year as a decimal number, "00" to ("52" or "53") * range 01 to 53, where week 1 is the first week that has at least 4 days * in the current year, and with Monday as the first day of the week. * (Use %G or %g for the year component that corresponds to the week number * for the specified timestamp.) * %W week number of the current year as a decimal number, starting with the "00" to ("52" or "53") * first Monday as the first day of the first week * %w day of the week as a decimal, Sunday being "0" "0" to "6" * %x preferred date representation for the current locale without the time "4/13/2008" * %X preferred time representation for the current locale without the date "12:53:05" * %y year as a decimal number without a century "00" "99" * %Y year as a decimal number including the century "2008" * %Z time zone or name or abbreviation "UTC", "EST", "PST" * %z same as %Z * %% a literal "%" characters "%" * d Day of the month, 2 digits with leading zeros "01" to "31" * D A textual representation of a day, three letters "Mon" through "Sun" * j Day of the month without leading zeros "1" to "31" * l A full textual representation of the day of the week (lowercase "L") "Sunday" through "Saturday" * N ISO-8601 numeric representation of the day of the week (added in PHP 5.1.0) "1" (for Monday) through "7" (for Sunday) * S English ordinal suffix for the day of the month, 2 characters "st", "nd", "rd" or "th". Works well with j * w Numeric representation of the day of the week "0" (for Sunday) through "6" (for Saturday) * z The day of the year (starting from "0") "0" through "365" * W ISO-8601 week number of year, weeks starting on Monday "00" to ("52" or "53") * F A full textual representation of a month, such as January or March "January" through "December" * m Numeric representation of a month, with leading zeros "01" through "12" * M A short textual representation of a month, three letters "Jan" through "Dec" * n Numeric representation of a month, without leading zeros "1" through "12" * t Number of days in the given month "28" through "31" * L Whether it's a leap year "1" if it is a leap year, "0" otherwise * o ISO-8601 year number. This has the same value as Y, except that if the "2008" * ISO week number (W) belongs to the previous or next year, that year * is used instead. * Y A full numeric representation of a year, 4 digits "2008" * y A two digit representation of a year "08" * a Lowercase Ante meridiem and Post meridiem "am" or "pm" * A Uppercase Ante meridiem and Post meridiem "AM" or "PM" * B Swatch Internet time "000" through "999" * g 12-hour format of an hour without leading zeros "1" through "12" * G 24-hour format of an hour without leading zeros "0" through "23" * h 12-hour format of an hour with leading zeros "01" through "12" * H 24-hour format of an hour with leading zeros "00" through "23" * i Minutes with leading zeros "00" to "59" * s Seconds, with leading zeros "00" through "59" * u Milliseconds "54321" * e Timezone identifier "UTC", "EST", "PST" * I Whether or not the date is in daylight saving time (uppercase i) "1" if Daylight Saving Time, "0" otherwise * O Difference to Greenwich time (GMT) in hours "+0200", "-0600" * P Difference to Greenwich time (GMT) with colon between hours and minutes "+02:00", "-06:00" * T Timezone abbreviation "UTC", "EST", "PST" * Z Timezone offset in seconds. The offset for timezones west of UTC is "-43200" through "50400" * always negative, and for those east of UTC is always positive. * c ISO 8601 date "2004-02-12T15:19:21+00:00" * r RFC 2822 formatted date "Thu, 21 Dec 2000 16:01:07 +0200" * U Seconds since the Unix Epoch (January 1 1970 00:00:00 GMT) "0" * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @return {String} A string representation of the current Date object. */ var formatReplace = function (context) { return function (m) { var formatString, override = false; if (m.charAt(0) === "\\" || m.substring(0, 2) === "%%") { return m.replace("\\", "").replace("%%", "%"); } override = normalizer.shouldOverrideDefaults(m); formatString = $D.normalizeFormat(m, context); if (formatString) { return context.toString(formatString, override); } }; }; $P._format = function (format) { var formatter = formatReplace(this); if (!format) { return this._toString(); } else { return format.replace(/(%|\\)?.|%%/g, formatter); } }; if (!$P.format) { $P.format = $P._format; } }()); (function () { "use strict"; var gFn = function (attr) { return function () { return this[attr]; }; }; var sFn = function (attr) { return function (val) { this[attr] = val; return this; }; }; var attrs = ["years", "months", "days", "hours", "minutes", "seconds", "milliseconds"]; var addSetFuncs = function (context, attrs) { for (var i = 0; i < attrs.length ; i++) { var $a = attrs[i], $b = $a.slice(0, 1).toUpperCase() + $a.slice(1); context.prototype[$a] = 0; context.prototype["get" + $b] = gFn($a); context.prototype["set" + $b] = sFn($a); } }; /** * new TimeSpan(milliseconds); * new TimeSpan(days, hours, minutes, seconds); * new TimeSpan(days, hours, minutes, seconds, milliseconds); */ var TimeSpan = function (days, hours, minutes, seconds, milliseconds) { if (arguments.length === 1 && typeof days === "number") { var orient = (days < 0) ? -1 : +1; var millsLeft = Math.abs(days); this.setDays(Math.floor(millsLeft / 86400000) * orient); millsLeft = millsLeft % 86400000; this.setHours(Math.floor(millsLeft / 3600000) * orient); millsLeft = millsLeft % 3600000; this.setMinutes(Math.floor(millsLeft / 60000) * orient); millsLeft = millsLeft % 60000; this.setSeconds(Math.floor(millsLeft / 1000) * orient); millsLeft = millsLeft % 1000; this.setMilliseconds(millsLeft * orient); } else { this.set(days, hours, minutes, seconds, milliseconds); } this.getTotalMilliseconds = function () { return (this.getDays() * 86400000) + (this.getHours() * 3600000) + (this.getMinutes() * 60000) + (this.getSeconds() * 1000); }; this.compareTo = function (time) { var t1 = new Date(1970, 1, 1, this.getHours(), this.getMinutes(), this.getSeconds()), t2; if (time === null) { t2 = new Date(1970, 1, 1, 0, 0, 0); } else { t2 = new Date(1970, 1, 1, time.getHours(), time.getMinutes(), time.getSeconds()); } return (t1 < t2) ? -1 : (t1 > t2) ? 1 : 0; }; this.equals = function (time) { return (this.compareTo(time) === 0); }; this.add = function (time) { return (time === null) ? this : this.addSeconds(time.getTotalMilliseconds() / 1000); }; this.subtract = function (time) { return (time === null) ? this : this.addSeconds(-time.getTotalMilliseconds() / 1000); }; this.addDays = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 86400000)); }; this.addHours = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 3600000)); }; this.addMinutes = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 60000)); }; this.addSeconds = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 1000)); }; this.addMilliseconds = function (n) { return new TimeSpan(this.getTotalMilliseconds() + n); }; this.get12HourHour = function () { return (this.getHours() > 12) ? this.getHours() - 12 : (this.getHours() === 0) ? 12 : this.getHours(); }; this.getDesignator = function () { return (this.getHours() < 12) ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator; }; this.toString = function (format) { this._toString = function () { if (this.getDays() !== null && this.getDays() > 0) { return this.getDays() + "." + this.getHours() + ":" + this.p(this.getMinutes()) + ":" + this.p(this.getSeconds()); } else { return this.getHours() + ":" + this.p(this.getMinutes()) + ":" + this.p(this.getSeconds()); } }; this.p = function (s) { return (s.toString().length < 2) ? "0" + s : s; }; var me = this; return format ? format.replace(/dd?|HH?|hh?|mm?|ss?|tt?/g, function (format) { switch (format) { case "d": return me.getDays(); case "dd": return me.p(me.getDays()); case "H": return me.getHours(); case "HH": return me.p(me.getHours()); case "h": return me.get12HourHour(); case "hh": return me.p(me.get12HourHour()); case "m": return me.getMinutes(); case "mm": return me.p(me.getMinutes()); case "s": return me.getSeconds(); case "ss": return me.p(me.getSeconds()); case "t": return ((me.getHours() < 12) ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator).substring(0, 1); case "tt": return (me.getHours() < 12) ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator; } } ) : this._toString(); }; return this; }; addSetFuncs(TimeSpan, attrs.slice(2)); TimeSpan.prototype.set = function (days, hours, minutes, seconds, milliseconds){ this.setDays(days || this.getDays()); this.setHours(hours || this.getHours()); this.setMinutes(minutes || this.getMinutes()); this.setSeconds(seconds || this.getSeconds()); this.setMilliseconds(milliseconds || this.getMilliseconds()); }; /** * Gets the time of day for this date instances. * @return {TimeSpan} TimeSpan */ Date.prototype.getTimeOfDay = function () { return new TimeSpan(0, this.getHours(), this.getMinutes(), this.getSeconds(), this.getMilliseconds()); }; Date.TimeSpan = TimeSpan; if (typeof window !== "undefined" ) { // keeping API compatible for v1.x window.TimeSpan = TimeSpan; } }()); (function () { "use strict"; var attrs = ["years", "months", "days", "hours", "minutes", "seconds", "milliseconds"]; var gFn = function (attr) { return function () { return this[attr]; }; }; var sFn = function (attr) { return function (val) { this[attr] = val; return this; }; }; var addSetFuncs = function (context, attrs) { for (var i = 0; i < attrs.length ; i++) { var $a = attrs[i], $b = $a.slice(0, 1).toUpperCase() + $a.slice(1); context.prototype[$a] = 0; context.prototype["get" + $b] = gFn($a); context.prototype["set" + $b] = sFn($a); } }; var setMonthsAndYears = function (orient, d1, d2, context) { function inc() { d1.addMonths(-orient); context.months++; if (context.months === 12) { context.years++; context.months = 0; } } if (orient === +1) { while (d1 > d2) { inc(); } } else { while (d1 < d2) { inc(); } } context.months--; context.months *= orient; context.years *= orient; }; var adjustForDST = function(orient, startDate, endDate) { var hasDSTMismatch = (false === (startDate.isDaylightSavingTime() === endDate.isDaylightSavingTime())); if (hasDSTMismatch && orient === 1) { startDate.addHours(-1); } else if (hasDSTMismatch) { startDate.addHours(1); } }; /** * TimePeriod(startDate, endDate); * TimePeriod(years, months, days, hours, minutes, seconds, milliseconds); */ var TimePeriod = function (years, months, days, hours, minutes, seconds, milliseconds) { if (arguments.length === 7) { this.set(years, months, days, hours, minutes, seconds, milliseconds); } else if (arguments.length === 2 && arguments[0] instanceof Date && arguments[1] instanceof Date) { var startDate = arguments[0].clone(); var endDate = arguments[1].clone(); var orient = (startDate > endDate) ? +1 : -1; this.dates = { start: arguments[0].clone(), end: arguments[1].clone() }; setMonthsAndYears(orient, startDate, endDate, this); adjustForDST(orient, startDate, endDate); // // TODO - adjust for DST var diff = endDate - startDate; if (diff !== 0) { var ts = new TimeSpan(diff); this.set(this.years, this.months, ts.getDays(), ts.getHours(), ts.getMinutes(), ts.getSeconds(), ts.getMilliseconds()); } } return this; }; // create all the set functions. addSetFuncs(TimePeriod, attrs); TimePeriod.prototype.set = function (years, months, days, hours, minutes, seconds, milliseconds){ this.setYears(years || this.getYears()); this.setMonths(months || this.getMonths()); this.setDays(days || this.getDays()); this.setHours(hours || this.getHours()); this.setMinutes(minutes || this.getMinutes()); this.setSeconds(seconds || this.getSeconds()); this.setMilliseconds(milliseconds || this.getMilliseconds()); }; Date.TimePeriod = TimePeriod; if (typeof window !== "undefined") { // keeping API compatible for v1.x window.TimePeriod = TimePeriod; } }()); ================================================ FILE: build/date-eu-ES.js ================================================ /** * @overview datejs * @version 1.0.0-rc3 * @author Gregory Wild-Smith * @copyright 2015 Gregory Wild-Smith * @license MIT * @homepage https://github.com/abritinthebay/datejs */ /* * DateJS Culture String File * Country Code: eu-ES * Name: Basque (Basque) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["eu-ES"] = { "name": "eu-ES", "englishName": "Basque (Basque)", "nativeName": "euskara (euskara)", "Sunday": "igandea", "Monday": "astelehena", "Tuesday": "asteartea", "Wednesday": "asteazkena", "Thursday": "osteguna", "Friday": "ostirala", "Saturday": "larunbata", "Sun": "ig.", "Mon": "al.", "Tue": "as.", "Wed": "az.", "Thu": "og.", "Fri": "or.", "Sat": "lr.", "Su": "ig", "Mo": "al", "Tu": "as", "We": "az", "Th": "og", "Fr": "or", "Sa": "lr", "S_Sun_Initial": "i", "M_Mon_Initial": "a", "T_Tue_Initial": "a", "W_Wed_Initial": "a", "T_Thu_Initial": "o", "F_Fri_Initial": "o", "S_Sat_Initial": "l", "January": "urtarrila", "February": "otsaila", "March": "martxoa", "April": "apirila", "May": "maiatza", "June": "ekaina", "July": "uztaila", "August": "abuztua", "September": "iraila", "October": "urria", "November": "azaroa", "December": "abendua", "Jan_Abbr": "urt.", "Feb_Abbr": "ots.", "Mar_Abbr": "mar.", "Apr_Abbr": "api.", "May_Abbr": "mai.", "Jun_Abbr": "eka.", "Jul_Abbr": "uzt.", "Aug_Abbr": "abu.", "Sep_Abbr": "ira.", "Oct_Abbr": "urr.", "Nov_Abbr": "aza.", "Dec_Abbr": "abe.", "AM": "", "PM": "", "firstDayOfWeek": 1, "twoDigitYearMax": 2029, "mdy": "ymd", "M/d/yyyy": "yyyy/MM/dd", "dddd, MMMM dd, yyyy": "dddd, yyyy.'eko' MMMM'k 'd", "h:mm tt": "HH:mm", "h:mm:ss tt": "HH:mm:ss", "dddd, MMMM dd, yyyy h:mm:ss tt": "dddd, yyyy.'eko' MMMM'k 'd HH:mm:ss", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "MMMM dd", "MMMM, yyyy": "yyyy.'eko' MMMM", "/jan(uary)?/": "urt(.(arrila)?)?", "/feb(ruary)?/": "ots(.(aila)?)?", "/mar(ch)?/": "mar(.(txoa)?)?", "/apr(il)?/": "api(.(rila)?)?", "/may/": "mai(.(atza)?)?", "/jun(e)?/": "eka(.(ina)?)?", "/jul(y)?/": "uzt(.(aila)?)?", "/aug(ust)?/": "abu(.(ztua)?)?", "/sep(t(ember)?)?/": "ira(.(ila)?)?", "/oct(ober)?/": "urr(.(ia)?)?", "/nov(ember)?/": "aza(.(roa)?)?", "/dec(ember)?/": "abe(.(ndua)?)?", "/^su(n(day)?)?/": "^ig((.(andea)?)?)?", "/^mo(n(day)?)?/": "^al((.(telehena)?)?)?", "/^tu(e(s(day)?)?)?/": "^as((.(teartea)?)?)?", "/^we(d(nesday)?)?/": "^az((.(teazkena)?)?)?", "/^th(u(r(s(day)?)?)?)?/": "^og((.(teguna)?)?)?", "/^fr(i(day)?)?/": "^or((.(tirala)?)?)?", "/^sa(t(urday)?)?/": "^lr((.(runbata)?)?)?", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "eu-ES"; /** * @overview datejs * @version 1.0.0-rc3 * @author Gregory Wild-Smith * @copyright 2015 Gregory Wild-Smith * @license MIT * @homepage https://github.com/abritinthebay/datejs */(function () { var $D = Date; var lang = Date.CultureStrings ? Date.CultureStrings.lang : null; var loggedKeys = {}; // for debug purposes. var getText = { getFromKey: function (key, countryCode) { var output; if (Date.CultureStrings && Date.CultureStrings[countryCode] && Date.CultureStrings[countryCode][key]) { output = Date.CultureStrings[countryCode][key]; } else { output = getText.buildFromDefault(key); } if (key.charAt(0) === "/") { // Assume it's a regex output = getText.buildFromRegex(key, countryCode); } return output; }, getFromObjectValues: function (obj, countryCode) { var key, output = {}; for(key in obj) { if (obj.hasOwnProperty(key)) { output[key] = getText.getFromKey(obj[key], countryCode); } } return output; }, getFromObjectKeys: function (obj, countryCode) { var key, output = {}; for(key in obj) { if (obj.hasOwnProperty(key)) { output[getText.getFromKey(key, countryCode)] = obj[key]; } } return output; }, getFromArray: function (arr, countryCode) { var output = []; for (var i=0; i < arr.length; i++){ if (i in arr) { output[i] = getText.getFromKey(arr[i], countryCode); } } return output; }, buildFromDefault: function (key) { var output, length, split, last; switch(key) { case "name": output = "en-US"; break; case "englishName": output = "English (United States)"; break; case "nativeName": output = "English (United States)"; break; case "twoDigitYearMax": output = 2049; break; case "firstDayOfWeek": output = 0; break; default: output = key; split = key.split("_"); length = split.length; if (length > 1 && key.charAt(0) !== "/") { // if the key isn't a regex and it has a split. last = split[(length - 1)].toLowerCase(); if (last === "initial" || last === "abbr") { output = split[0]; } } break; } return output; }, buildFromRegex: function (key, countryCode) { var output; if (Date.CultureStrings && Date.CultureStrings[countryCode] && Date.CultureStrings[countryCode][key]) { output = new RegExp(Date.CultureStrings[countryCode][key], "i"); } else { output = new RegExp(key.replace(new RegExp("/", "g"),""), "i"); } return output; } }; var shallowMerge = function (obj1, obj2) { for (var attrname in obj2) { if (obj2.hasOwnProperty(attrname)) { obj1[attrname] = obj2[attrname]; } } }; var __ = function (key, language) { var countryCode = (language) ? language : lang; loggedKeys[key] = key; if (typeof key === "object") { if (key instanceof Array) { return getText.getFromArray(key, countryCode); } else { return getText.getFromObjectKeys(key, countryCode); } } else { return getText.getFromKey(key, countryCode); } }; var loadI18nScript = function (code) { // paatterned after jQuery's getScript. var url = Date.Config.i18n + code + ".js"; var head = document.getElementsByTagName("head")[0] || document.documentElement; var script = document.createElement("script"); script.src = url; var completed = false; var events = { done: function (){} // placeholder function }; // Attach handlers for all browsers script.onload = script.onreadystatechange = function() { if ( !completed && (!this.readyState || this.readyState === "loaded" || this.readyState === "complete") ) { events.done(); head.removeChild(script); } }; setTimeout(function() { head.insertBefore(script, head.firstChild); }, 0); // allows return to execute first return { done: function (cb) { events.done = function() { if (cb) { setTimeout(cb,0); } }; } }; }; var buildInfo = { buildFromMethodHash: function (obj) { var key; for(key in obj) { if (obj.hasOwnProperty(key)) { obj[key] = buildInfo[obj[key]](); } } return obj; }, timeZoneDST: function () { var DST = { "CHADT": "+1345", "NZDT": "+1300", "AEDT": "+1100", "ACDT": "+1030", "AZST": "+0500", "IRDT": "+0430", "EEST": "+0300", "CEST": "+0200", "BST": "+0100", "PMDT": "-0200", "ADT": "-0300", "NDT": "-0230", "EDT": "-0400", "CDT": "-0500", "MDT": "-0600", "PDT": "-0700", "AKDT": "-0800", "HADT": "-0900" }; return __(DST); }, timeZoneStandard: function () { var standard = { "LINT": "+1400", "TOT": "+1300", "CHAST": "+1245", "NZST": "+1200", "NFT": "+1130", "SBT": "+1100", "AEST": "+1000", "ACST": "+0930", "JST": "+0900", "CWST": "+0845", "CT": "+0800", "ICT": "+0700", "MMT": "+0630", "BST": "+0600", "NPT": "+0545", "IST": "+0530", "PKT": "+0500", "AFT": "+0430", "MSK": "+0400", "IRST": "+0330", "FET": "+0300", "EET": "+0200", "CET": "+0100", "GMT": "+0000", "UTC": "+0000", "CVT": "-0100", "GST": "-0200", "BRT": "-0300", "NST": "-0330", "AST": "-0400", "EST": "-0500", "CST": "-0600", "MST": "-0700", "PST": "-0800", "AKST": "-0900", "MIT": "-0930", "HST": "-1000", "SST": "-1100", "BIT": "-1200" }; return __(standard); }, timeZones: function (data) { var zone; data.timezones = []; for (zone in data.abbreviatedTimeZoneStandard) { if (data.abbreviatedTimeZoneStandard.hasOwnProperty(zone)) { data.timezones.push({ name: zone, offset: data.abbreviatedTimeZoneStandard[zone]}); } } for (zone in data.abbreviatedTimeZoneDST) { if (data.abbreviatedTimeZoneDST.hasOwnProperty(zone)) { data.timezones.push({ name: zone, offset: data.abbreviatedTimeZoneDST[zone], dst: true}); } } return data.timezones; }, days: function () { return __(["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"]); }, dayAbbr: function () { return __(["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"]); }, dayShortNames: function () { return __(["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"]); }, dayFirstLetters: function () { return __(["S_Sun_Initial", "M_Mon_Initial", "T_Tues_Initial", "W_Wed_Initial", "T_Thu_Initial", "F_Fri_Initial", "S_Sat_Initial"]); }, months: function () { return __(["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"]); }, monthAbbr: function () { return __(["Jan_Abbr", "Feb_Abbr", "Mar_Abbr", "Apr_Abbr", "May_Abbr", "Jun_Abbr", "Jul_Abbr", "Aug_Abbr", "Sep_Abbr", "Oct_Abbr", "Nov_Abbr", "Dec_Abbr"]); }, formatPatterns: function () { return getText.getFromObjectValues({ shortDate: "M/d/yyyy", longDate: "dddd, MMMM dd, yyyy", shortTime: "h:mm tt", longTime: "h:mm:ss tt", fullDateTime: "dddd, MMMM dd, yyyy h:mm:ss tt", sortableDateTime: "yyyy-MM-ddTHH:mm:ss", universalSortableDateTime: "yyyy-MM-dd HH:mm:ssZ", rfc1123: "ddd, dd MMM yyyy HH:mm:ss", monthDay: "MMMM dd", yearMonth: "MMMM, yyyy" }, Date.i18n.currentLanguage()); }, regex: function () { return getText.getFromObjectValues({ inTheMorning: "/( in the )(morn(ing)?)\\b/", thisMorning: "/(this )(morn(ing)?)\\b/", amThisMorning: "/(\b\\d(am)? )(this )(morn(ing)?)/", inTheEvening: "/( in the )(even(ing)?)\\b/", thisEvening: "/(this )(even(ing)?)\\b/", pmThisEvening: "/(\b\\d(pm)? )(this )(even(ing)?)/", jan: "/jan(uary)?/", feb: "/feb(ruary)?/", mar: "/mar(ch)?/", apr: "/apr(il)?/", may: "/may/", jun: "/jun(e)?/", jul: "/jul(y)?/", aug: "/aug(ust)?/", sep: "/sep(t(ember)?)?/", oct: "/oct(ober)?/", nov: "/nov(ember)?/", dec: "/dec(ember)?/", sun: "/^su(n(day)?)?/", mon: "/^mo(n(day)?)?/", tue: "/^tu(e(s(day)?)?)?/", wed: "/^we(d(nesday)?)?/", thu: "/^th(u(r(s(day)?)?)?)?/", fri: "/fr(i(day)?)?/", sat: "/^sa(t(urday)?)?/", future: "/^next/", past: "/^last|past|prev(ious)?/", add: "/^(\\+|aft(er)?|from|hence)/", subtract: "/^(\\-|bef(ore)?|ago)/", yesterday: "/^yes(terday)?/", today: "/^t(od(ay)?)?/", tomorrow: "/^tom(orrow)?/", now: "/^n(ow)?/", millisecond: "/^ms|milli(second)?s?/", second: "/^sec(ond)?s?/", minute: "/^mn|min(ute)?s?/", hour: "/^h(our)?s?/", week: "/^w(eek)?s?/", month: "/^m(onth)?s?/", day: "/^d(ay)?s?/", year: "/^y(ear)?s?/", shortMeridian: "/^(a|p)/", longMeridian: "/^(a\\.?m?\\.?|p\\.?m?\\.?)/", timezone: "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/", ordinalSuffix: "/^\\s*(st|nd|rd|th)/", timeContext: "/^\\s*(\\:|a(?!u|p)|p)/" }, Date.i18n.currentLanguage()); } }; var CultureInfo = function () { var info = getText.getFromObjectValues({ name: "name", englishName: "englishName", nativeName: "nativeName", amDesignator: "AM", pmDesignator: "PM", firstDayOfWeek: "firstDayOfWeek", twoDigitYearMax: "twoDigitYearMax", dateElementOrder: "mdy" }, Date.i18n.currentLanguage()); var constructedInfo = buildInfo.buildFromMethodHash({ dayNames: "days", abbreviatedDayNames: "dayAbbr", shortestDayNames: "dayShortNames", firstLetterDayNames: "dayFirstLetters", monthNames: "months", abbreviatedMonthNames: "monthAbbr", formatPatterns: "formatPatterns", regexPatterns: "regex", abbreviatedTimeZoneDST: "timeZoneDST", abbreviatedTimeZoneStandard: "timeZoneStandard" }); shallowMerge(info, constructedInfo); buildInfo.timeZones(info); return info; }; $D.i18n = { __: function (key, lang) { return __(key, lang); }, currentLanguage: function () { return lang || "en-US"; }, setLanguage: function (code, force, cb) { var async = false; if (force || code === "en-US" || (!!Date.CultureStrings && !!Date.CultureStrings[code])) { lang = code; Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings.lang = code; Date.CultureInfo = new CultureInfo(); } else { if (!(!!Date.CultureStrings && !!Date.CultureStrings[code])) { if (typeof exports !== "undefined" && this.exports !== exports) { // we're in a Node enviroment, load it using require try { require("../i18n/" + code + ".js"); lang = code; Date.CultureStrings.lang = code; Date.CultureInfo = new CultureInfo(); } catch (e) { // var str = "The language for '" + code + "' could not be loaded by Node. It likely does not exist."; throw new Error("The DateJS IETF language tag '" + code + "' could not be loaded by Node. It likely does not exist."); } } else if (Date.Config && Date.Config.i18n) { // we know the location of the files, so lets load them async = true; loadI18nScript(code).done(function(){ lang = code; Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings.lang = code; Date.CultureInfo = new CultureInfo(); $D.Parsing.Normalizer.buildReplaceData(); // because this is async if ($D.Grammar) { $D.Grammar.buildGrammarFormats(); // so we can parse those strings... } if (cb) { setTimeout(cb,0); } }); } else { Date.console.error("The DateJS IETF language tag '" + code + "' is not available and has not been loaded."); return false; } } } $D.Parsing.Normalizer.buildReplaceData(); // rebuild normalizer strings if ($D.Grammar) { $D.Grammar.buildGrammarFormats(); // so we can parse those strings... } if (!async && cb) { setTimeout(cb,0); } }, getLoggedKeys: function () { return loggedKeys; }, updateCultureInfo: function () { Date.CultureInfo = new CultureInfo(); } }; $D.i18n.updateCultureInfo(); // run automatically }()); (function () { var $D = Date, $P = $D.prototype, p = function (s, l) { if (!l) { l = 2; } return ("000" + s).slice(l * -1); }; if (typeof window !== "undefined" && typeof window.console !== "undefined" && typeof window.console.log !== "undefined") { $D.console = console; // used only to raise non-critical errors if available } else { // set mock so we don't give errors. $D.console = { log: function(){}, error: function(){} }; } $D.Config = $D.Config || {}; $D.initOverloads = function() { /** * Overload of Date.now. Allows an alternate call for Date.now where it returns the * current Date as an object rather than just milliseconds since the Unix Epoch. * * Also provides an implementation of now() for browsers (IE<9) that don't have it. * * Backwards compatible so with work with either: * Date.now() [returns ms] * or * Date.now(true) [returns Date] */ if (!$D.now) { $D._now = function now() { return new Date().getTime(); }; } else if (!$D._now) { $D._now = $D.now; } $D.now = function (returnObj) { if (returnObj) { return $D.present(); } else { return $D._now(); } }; if ( !$P.toISOString ) { $P.toISOString = function() { return this.getUTCFullYear() + "-" + p(this.getUTCMonth() + 1) + "-" + p(this.getUTCDate()) + "T" + p(this.getUTCHours()) + ":" + p(this.getUTCMinutes()) + ":" + p(this.getUTCSeconds()) + "." + String( (this.getUTCMilliseconds()/1000).toFixed(3)).slice(2, 5) + "Z"; }; } // private if ( $P._toString === undefined ){ $P._toString = $P.toString; } }; $D.initOverloads(); /** * Gets a date that is set to the current date. The time is set to the start of the day (00:00 or 12:00 AM). * @return {Date} The current date. */ $D.today = function () { return new Date().clearTime(); }; /** * Gets a date that is set to the current date and time (same as new Date, but chainable) * @return {Date} The current date. */ $D.present = function () { return new Date(); }; /** * Compares the first date to the second date and returns an number indication of their relative values. * @param {Date} First Date object to compare [Required]. * @param {Date} Second Date object to compare to [Required]. * @return {Number} -1 = date1 is lessthan date2. 0 = values are equal. 1 = date1 is greaterthan date2. */ $D.compare = function (date1, date2) { if (isNaN(date1) || isNaN(date2)) { throw new Error(date1 + " - " + date2); } else if (date1 instanceof Date && date2 instanceof Date) { return (date1 < date2) ? -1 : (date1 > date2) ? 1 : 0; } else { throw new TypeError(date1 + " - " + date2); } }; /** * Compares the first Date object to the second Date object and returns true if they are equal. * @param {Date} First Date object to compare [Required] * @param {Date} Second Date object to compare to [Required] * @return {Boolean} true if dates are equal. false if they are not equal. */ $D.equals = function (date1, date2) { return (date1.compareTo(date2) === 0); }; /** * Gets the language appropriate day name when given the day number(0-6) * eg - 0 == Sunday * @return {String} The day name */ $D.getDayName = function (n) { return Date.CultureInfo.dayNames[n]; }; /** * Gets the day number (0-6) if given a CultureInfo specific string which is a valid dayName, abbreviatedDayName or shortestDayName (two char). * @param {String} The name of the day (eg. "Monday, "Mon", "tuesday", "tue", "We", "we"). * @return {Number} The day number */ $D.getDayNumberFromName = function (name) { var n = Date.CultureInfo.dayNames, m = Date.CultureInfo.abbreviatedDayNames, o = Date.CultureInfo.shortestDayNames, s = name.toLowerCase(); for (var i = 0; i < n.length; i++) { if (n[i].toLowerCase() === s || m[i].toLowerCase() === s || o[i].toLowerCase() === s) { return i; } } return -1; }; /** * Gets the month number (0-11) if given a Culture Info specific string which is a valid monthName or abbreviatedMonthName. * @param {String} The name of the month (eg. "February, "Feb", "october", "oct"). * @return {Number} The day number */ $D.getMonthNumberFromName = function (name) { var n = Date.CultureInfo.monthNames, m = Date.CultureInfo.abbreviatedMonthNames, s = name.toLowerCase(); for (var i = 0; i < n.length; i++) { if (n[i].toLowerCase() === s || m[i].toLowerCase() === s) { return i; } } return -1; }; /** * Gets the language appropriate month name when given the month number(0-11) * eg - 0 == January * @return {String} The month name */ $D.getMonthName = function (n) { return Date.CultureInfo.monthNames[n]; }; /** * Determines if the current date instance is within a LeapYear. * @param {Number} The year. * @return {Boolean} true if date is within a LeapYear, otherwise false. */ $D.isLeapYear = function (year) { return ((year % 4 === 0 && year % 100 !== 0) || year % 400 === 0); }; /** * Gets the number of days in the month, given a year and month value. Automatically corrects for LeapYear. * @param {Number} The year. * @param {Number} The month (0-11). * @return {Number} The number of days in the month. */ $D.getDaysInMonth = function (year, month) { if (!month && $D.validateMonth(year)) { month = year; year = Date.today().getFullYear(); } return [31, ($D.isLeapYear(year) ? 29 : 28), 31, 30, 31, 30, 31, 31, 30, 31, 30, 31][month]; }; $P.getDaysInMonth = function () { return $D.getDaysInMonth(this.getFullYear(), this.getMonth()); }; $D.getTimezoneAbbreviation = function (offset, dst) { var p, n = (dst || false) ? Date.CultureInfo.abbreviatedTimeZoneDST : Date.CultureInfo.abbreviatedTimeZoneStandard; for (p in n) { if (n.hasOwnProperty(p)) { if (n[p] === offset) { return p; } } } return null; }; $D.getTimezoneOffset = function (name, dst) { var i, a =[], z = Date.CultureInfo.timezones; if (!name) { name = (new Date()).getTimezone();} for (i = 0; i < z.length; i++) { if (z[i].name === name.toUpperCase()) { a.push(i); } } if (!z[a[0]]) { return null; } if (a.length === 1 || !dst) { return z[a[0]].offset; } else { for (i=0; i < a.length; i++) { if (z[a[i]].dst) { return z[a[i]].offset; } } } }; $D.getQuarter = function (d) { d = d || new Date(); // If no date supplied, use today var q = [1,2,3,4]; return q[Math.floor(d.getMonth() / 3)]; // ~~~ is a bitwise op. Faster than Math.floor }; $D.getDaysLeftInQuarter = function (d) { d = d || new Date(); var qEnd = new Date(d); qEnd.setMonth(qEnd.getMonth() + 3 - qEnd.getMonth() % 3, 0); return Math.floor((qEnd - d) / 8.64e7); }; // private var validate = function (n, min, max, name) { name = name ? name : "Object"; if (typeof n === "undefined") { return false; } else if (typeof n !== "number") { throw new TypeError(n + " is not a Number."); } else if (n < min || n > max) { // As failing validation is *not* an exceptional circumstance // lets not throw a RangeError Exception here. // It's semantically correct but it's not sensible. return false; } return true; }; /** * Validates the number is within an acceptable range for milliseconds [0-999]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateMillisecond = function (value) { return validate(value, 0, 999, "millisecond"); }; /** * Validates the number is within an acceptable range for seconds [0-59]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateSecond = function (value) { return validate(value, 0, 59, "second"); }; /** * Validates the number is within an acceptable range for minutes [0-59]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateMinute = function (value) { return validate(value, 0, 59, "minute"); }; /** * Validates the number is within an acceptable range for hours [0-23]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateHour = function (value) { return validate(value, 0, 23, "hour"); }; /** * Validates the number is within an acceptable range for the days in a month [0-MaxDaysInMonth]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateDay = function (value, year, month) { if (year === undefined || year === null || month === undefined || month === null) { return false;} return validate(value, 1, $D.getDaysInMonth(year, month), "day"); }; /** * Validates the number is within an acceptable range for months [0-11]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateWeek = function (value) { return validate(value, 0, 53, "week"); }; /** * Validates the number is within an acceptable range for months [0-11]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateMonth = function (value) { return validate(value, 0, 11, "month"); }; /** * Validates the number is within an acceptable range for years. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateYear = function (value) { /** * Per ECMAScript spec the range of times supported by Date objects is * exactly -100,000,000 days to +100,000,000 days measured relative to * midnight at the beginning of 01 January, 1970 UTC. * This gives a range of 8,640,000,000,000,000 milliseconds to either * side of 01 January, 1970 UTC. * * Earliest possible date: Tue, 20 Apr 271,822 B.C. 00:00:00 UTC * Latest possible date: Sat, 13 Sep 275,760 00:00:00 UTC */ return validate(value, -271822, 275760, "year"); }; $D.validateTimezone = function(value) { var timezones = {"ACDT":1,"ACST":1,"ACT":1,"ADT":1,"AEDT":1,"AEST":1,"AFT":1,"AKDT":1,"AKST":1,"AMST":1,"AMT":1,"ART":1,"AST":1,"AWDT":1,"AWST":1,"AZOST":1,"AZT":1,"BDT":1,"BIOT":1,"BIT":1,"BOT":1,"BRT":1,"BST":1,"BTT":1,"CAT":1,"CCT":1,"CDT":1,"CEDT":1,"CEST":1,"CET":1,"CHADT":1,"CHAST":1,"CHOT":1,"ChST":1,"CHUT":1,"CIST":1,"CIT":1,"CKT":1,"CLST":1,"CLT":1,"COST":1,"COT":1,"CST":1,"CT":1,"CVT":1,"CWST":1,"CXT":1,"DAVT":1,"DDUT":1,"DFT":1,"EASST":1,"EAST":1,"EAT":1,"ECT":1,"EDT":1,"EEDT":1,"EEST":1,"EET":1,"EGST":1,"EGT":1,"EIT":1,"EST":1,"FET":1,"FJT":1,"FKST":1,"FKT":1,"FNT":1,"GALT":1,"GAMT":1,"GET":1,"GFT":1,"GILT":1,"GIT":1,"GMT":1,"GST":1,"GYT":1,"HADT":1,"HAEC":1,"HAST":1,"HKT":1,"HMT":1,"HOVT":1,"HST":1,"ICT":1,"IDT":1,"IOT":1,"IRDT":1,"IRKT":1,"IRST":1,"IST":1,"JST":1,"KGT":1,"KOST":1,"KRAT":1,"KST":1,"LHST":1,"LINT":1,"MAGT":1,"MART":1,"MAWT":1,"MDT":1,"MET":1,"MEST":1,"MHT":1,"MIST":1,"MIT":1,"MMT":1,"MSK":1,"MST":1,"MUT":1,"MVT":1,"MYT":1,"NCT":1,"NDT":1,"NFT":1,"NPT":1,"NST":1,"NT":1,"NUT":1,"NZDT":1,"NZST":1,"OMST":1,"ORAT":1,"PDT":1,"PET":1,"PETT":1,"PGT":1,"PHOT":1,"PHT":1,"PKT":1,"PMDT":1,"PMST":1,"PONT":1,"PST":1,"PYST":1,"PYT":1,"RET":1,"ROTT":1,"SAKT":1,"SAMT":1,"SAST":1,"SBT":1,"SCT":1,"SGT":1,"SLST":1,"SRT":1,"SST":1,"SYOT":1,"TAHT":1,"THA":1,"TFT":1,"TJT":1,"TKT":1,"TLT":1,"TMT":1,"TOT":1,"TVT":1,"UCT":1,"ULAT":1,"UTC":1,"UYST":1,"UYT":1,"UZT":1,"VET":1,"VLAT":1,"VOLT":1,"VOST":1,"VUT":1,"WAKT":1,"WAST":1,"WAT":1,"WEDT":1,"WEST":1,"WET":1,"WST":1,"YAKT":1,"YEKT":1,"Z":1}; return (timezones[value] === 1); }; $D.validateTimezoneOffset= function(value) { // timezones go from +14hrs to -12hrs, the +X hours are negative offsets. return (value > -841 && value < 721); }; }()); (function () { var $D = Date, $P = $D.prototype, p = function (s, l) { if (!l) { l = 2; } return ("000" + s).slice(l * -1); }; var validateConfigObject = function (obj) { var result = {}, self = this, prop, testFunc; testFunc = function (prop, func, value) { if (prop === "day") { var month = (obj.month !== undefined) ? obj.month : self.getMonth(); var year = (obj.year !== undefined) ? obj.year : self.getFullYear(); return $D[func](value, year, month); } else { return $D[func](value); } }; for (prop in obj) { if (Object.prototype.hasOwnProperty.call(obj, prop)) { var func = "validate" + prop.charAt(0).toUpperCase() + prop.slice(1); if ($D[func] && obj[prop] !== null && testFunc(prop, func, obj[prop])) { result[prop] = obj[prop]; } } } return result; }; /** * Resets the time of this Date object to 12:00 AM (00:00), which is the start of the day. * @param {Boolean} .clone() this date instance before clearing Time * @return {Date} this */ $P.clearTime = function () { this.setHours(0); this.setMinutes(0); this.setSeconds(0); this.setMilliseconds(0); return this; }; /** * Resets the time of this Date object to the current time ('now'). * @return {Date} this */ $P.setTimeToNow = function () { var n = new Date(); this.setHours(n.getHours()); this.setMinutes(n.getMinutes()); this.setSeconds(n.getSeconds()); this.setMilliseconds(n.getMilliseconds()); return this; }; /** * Returns a new Date object that is an exact date and time copy of the original instance. * @return {Date} A new Date instance */ $P.clone = function () { return new Date(this.getTime()); }; /** * Compares this instance to a Date object and returns an number indication of their relative values. * @param {Date} Date object to compare [Required] * @return {Number} -1 = this is lessthan date. 0 = values are equal. 1 = this is greaterthan date. */ $P.compareTo = function (date) { return Date.compare(this, date); }; /** * Compares this instance to another Date object and returns true if they are equal. * @param {Date} Date object to compare. If no date to compare, new Date() [now] is used. * @return {Boolean} true if dates are equal. false if they are not equal. */ $P.equals = function (date) { return Date.equals(this, (date !== undefined ? date : new Date())); }; /** * Determines if this instance is between a range of two dates or equal to either the start or end dates. * @param {Date} Start of range [Required] * @param {Date} End of range [Required] * @return {Boolean} true is this is between or equal to the start and end dates, else false */ $P.between = function (start, end) { return this.getTime() >= start.getTime() && this.getTime() <= end.getTime(); }; /** * Determines if this date occurs after the date to compare to. * @param {Date} Date object to compare. If no date to compare, new Date() ("now") is used. * @return {Boolean} true if this date instance is greater than the date to compare to (or "now"), otherwise false. */ $P.isAfter = function (date) { return this.compareTo(date || new Date()) === 1; }; /** * Determines if this date occurs before the date to compare to. * @param {Date} Date object to compare. If no date to compare, new Date() ("now") is used. * @return {Boolean} true if this date instance is less than the date to compare to (or "now"). */ $P.isBefore = function (date) { return (this.compareTo(date || new Date()) === -1); }; /** * Determines if the current Date instance occurs today. * @return {Boolean} true if this date instance is 'today', otherwise false. */ /** * Determines if the current Date instance occurs on the same Date as the supplied 'date'. * If no 'date' to compare to is provided, the current Date instance is compared to 'today'. * @param {date} Date object to compare. If no date to compare, the current Date ("now") is used. * @return {Boolean} true if this Date instance occurs on the same Day as the supplied 'date'. */ $P.isToday = $P.isSameDay = function (date) { return this.clone().clearTime().equals((date || new Date()).clone().clearTime()); }; /** * Adds the specified number of milliseconds to this instance. * @param {Number} The number of milliseconds to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addMilliseconds = function (value) { if (!value) { return this; } this.setTime(this.getTime() + value * 1); return this; }; /** * Adds the specified number of seconds to this instance. * @param {Number} The number of seconds to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addSeconds = function (value) { if (!value) { return this; } return this.addMilliseconds(value * 1000); }; /** * Adds the specified number of seconds to this instance. * @param {Number} The number of seconds to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addMinutes = function (value) { if (!value) { return this; } return this.addMilliseconds(value * 60000); // 60*1000 }; /** * Adds the specified number of hours to this instance. * @param {Number} The number of hours to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addHours = function (value) { if (!value) { return this; } return this.addMilliseconds(value * 3600000); // 60*60*1000 }; /** * Adds the specified number of days to this instance. * @param {Number} The number of days to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addDays = function (value) { if (!value) { return this; } this.setDate(this.getDate() + value * 1); return this; }; /** * Adds the specified number of weekdays (ie - not sat or sun) to this instance. * @param {Number} The number of days to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addWeekdays = function (value) { if (!value) { return this; } var day = this.getDay(); var weeks = (Math.ceil(Math.abs(value)/7)); if (day === 0 || day === 6) { if (value > 0) { this.next().monday(); this.addDays(-1); day = this.getDay(); } } if (value < 0) { while (value < 0) { this.addDays(-1); day = this.getDay(); if (day !== 0 && day !== 6) { value++; } } return this; } else if (value > 5 || (6-day) <= value) { value = value + (weeks * 2); } return this.addDays(value); }; /** * Adds the specified number of weeks to this instance. * @param {Number} The number of weeks to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addWeeks = function (value) { if (!value) { return this; } return this.addDays(value * 7); }; /** * Adds the specified number of months to this instance. * @param {Number} The number of months to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addMonths = function (value) { if (!value) { return this; } var n = this.getDate(); this.setDate(1); this.setMonth(this.getMonth() + value * 1); this.setDate(Math.min(n, $D.getDaysInMonth(this.getFullYear(), this.getMonth()))); return this; }; $P.addQuarters = function (value) { if (!value) { return this; } // note this will take you to the same point in the quarter as you are now. // i.e. - if you are 15 days into the quarter you'll be 15 days into the resulting one. // bonus: this allows adding fractional quarters return this.addMonths(value * 3); }; /** * Adds the specified number of years to this instance. * @param {Number} The number of years to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addYears = function (value) { if (!value) { return this; } return this.addMonths(value * 12); }; /** * Adds (or subtracts) to the value of the years, months, weeks, days, hours, minutes, seconds, milliseconds of the date instance using given configuration object. Positive and Negative values allowed. * Example

	Date.today().add( { days: 1, months: 1 } )

	new Date().add( { years: -1 } )
	
* @param {Object} Configuration object containing attributes (months, days, etc.) * @return {Date} this */ $P.add = function (config) { if (typeof config === "number") { this._orient = config; return this; } var x = config; if (x.day) { // If we should be a different date than today (eg: for 'tomorrow -1d', etc). // Should only effect parsing, not direct usage (eg, Finish and FinishExact) if ((x.day - this.getDate()) !== 0) { this.setDate(x.day); } } if (x.milliseconds) { this.addMilliseconds(x.milliseconds); } if (x.seconds) { this.addSeconds(x.seconds); } if (x.minutes) { this.addMinutes(x.minutes); } if (x.hours) { this.addHours(x.hours); } if (x.weeks) { this.addWeeks(x.weeks); } if (x.months) { this.addMonths(x.months); } if (x.years) { this.addYears(x.years); } if (x.days) { this.addDays(x.days); } return this; }; /** * Get the week number. Week one (1) is the week which contains the first Thursday of the year. Monday is considered the first day of the week. * The .getWeek() function does NOT convert the date to UTC. The local datetime is used. * Please use .getISOWeek() to get the week of the UTC converted date. * @return {Number} 1 to 53 */ $P.getWeek = function (utc) { // Create a copy of this date object var self, target = new Date(this.valueOf()); if (utc) { target.addMinutes(target.getTimezoneOffset()); self = target.clone(); } else { self = this; } // ISO week date weeks start on monday // so correct the day number var dayNr = (self.getDay() + 6) % 7; // ISO 8601 states that week 1 is the week // with the first thursday of that year. // Set the target date to the thursday in the target week target.setDate(target.getDate() - dayNr + 3); // Store the millisecond value of the target date var firstThursday = target.valueOf(); // Set the target to the first thursday of the year // First set the target to january first target.setMonth(0, 1); // Not a thursday? Correct the date to the next thursday if (target.getDay() !== 4) { target.setMonth(0, 1 + ((4 - target.getDay()) + 7) % 7); } // The weeknumber is the number of weeks between the // first thursday of the year and the thursday in the target week return 1 + Math.ceil((firstThursday - target) / 604800000); // 604800000 = 7 * 24 * 3600 * 1000 }; /** * Get the ISO 8601 week number. Week one ("01") is the week which contains the first Thursday of the year. Monday is considered the first day of the week. * The .getISOWeek() function does convert the date to it's UTC value. Please use .getWeek() to get the week of the local date. * @return {String} "01" to "53" */ $P.getISOWeek = function () { return p(this.getWeek(true)); }; /** * Moves the date to Monday of the week set. Week one (1) is the week which contains the first Thursday of the year. * @param {Number} A Number (1 to 53) that represents the week of the year. * @return {Date} this */ $P.setWeek = function (n) { if ((n - this.getWeek()) === 0) { if (this.getDay() !== 1) { return this.moveToDayOfWeek(1, (this.getDay() > 1 ? -1 : 1)); } else { return this; } } else { return this.moveToDayOfWeek(1, (this.getDay() > 1 ? -1 : 1)).addWeeks(n - this.getWeek()); } }; $P.setQuarter = function (qtr) { var month = Math.abs(((qtr-1) * 3) + 1); return this.setMonth(month, 1); }; $P.getQuarter = function () { return Date.getQuarter(this); }; $P.getDaysLeftInQuarter = function () { return Date.getDaysLeftInQuarter(this); }; /** * Moves the date to the next n'th occurrence of the dayOfWeek starting from the beginning of the month. The number (-1) is a magic number and will return the last occurrence of the dayOfWeek in the month. * @param {Number} The dayOfWeek to move to * @param {Number} The n'th occurrence to move to. Use (-1) to return the last occurrence in the month * @return {Date} this */ $P.moveToNthOccurrence = function (dayOfWeek, occurrence) { if (dayOfWeek === "Weekday") { if (occurrence > 0) { this.moveToFirstDayOfMonth(); if (this.is().weekday()) { occurrence -= 1; } } else if (occurrence < 0) { this.moveToLastDayOfMonth(); if (this.is().weekday()) { occurrence += 1; } } else { return this; } return this.addWeekdays(occurrence); } var shift = 0; if (occurrence > 0) { shift = occurrence - 1; } else if (occurrence === -1) { this.moveToLastDayOfMonth(); if (this.getDay() !== dayOfWeek) { this.moveToDayOfWeek(dayOfWeek, -1); } return this; } return this.moveToFirstDayOfMonth().addDays(-1).moveToDayOfWeek(dayOfWeek, +1).addWeeks(shift); }; var moveToN = function (getFunc, addFunc, nVal) { return function (value, orient) { var diff = (value - this[getFunc]() + nVal * (orient || +1)) % nVal; return this[addFunc]((diff === 0) ? diff += nVal * (orient || +1) : diff); }; }; /** * Move to the next or last dayOfWeek based on the orient value. * @param {Number} The dayOfWeek to move to * @param {Number} Forward (+1) or Back (-1). Defaults to +1. [Optional] * @return {Date} this */ $P.moveToDayOfWeek = moveToN("getDay", "addDays", 7); /** * Move to the next or last month based on the orient value. * @param {Number} The month to move to. 0 = January, 11 = December * @param {Number} Forward (+1) or Back (-1). Defaults to +1. [Optional] * @return {Date} this */ $P.moveToMonth = moveToN("getMonth", "addMonths", 12); /** * Get the Ordinate of the current day ("th", "st", "rd"). * @return {String} */ $P.getOrdinate = function () { var num = this.getDate(); return ord(num); }; /** * Get the Ordinal day (numeric day number) of the year, adjusted for leap year. * @return {Number} 1 through 365 (366 in leap years) */ $P.getOrdinalNumber = function () { return Math.ceil((this.clone().clearTime() - new Date(this.getFullYear(), 0, 1)) / 86400000) + 1; }; /** * Get the time zone abbreviation of the current date. * @return {String} The abbreviated time zone name (e.g. "EST") */ $P.getTimezone = function () { return $D.getTimezoneAbbreviation(this.getUTCOffset(), this.isDaylightSavingTime()); }; $P.setTimezoneOffset = function (offset) { var here = this.getTimezoneOffset(), there = Number(offset) * -6 / 10; return (there || there === 0) ? this.addMinutes(there - here) : this; }; $P.setTimezone = function (offset) { return this.setTimezoneOffset($D.getTimezoneOffset(offset)); }; /** * Indicates whether Daylight Saving Time is observed in the current time zone. * @return {Boolean} true|false */ $P.hasDaylightSavingTime = function () { return (Date.today().set({month: 0, day: 1}).getTimezoneOffset() !== Date.today().set({month: 6, day: 1}).getTimezoneOffset()); }; /** * Indicates whether this Date instance is within the Daylight Saving Time range for the current time zone. * @return {Boolean} true|false */ $P.isDaylightSavingTime = function () { return Date.today().set({month: 0, day: 1}).getTimezoneOffset() !== this.getTimezoneOffset(); }; /** * Get the offset from UTC of the current date. * @return {String} The 4-character offset string prefixed with + or - (e.g. "-0500") */ $P.getUTCOffset = function (offset) { var n = (offset || this.getTimezoneOffset()) * -10 / 6, r; if (n < 0) { r = (n - 10000).toString(); return r.charAt(0) + r.substr(2); } else { r = (n + 10000).toString(); return "+" + r.substr(1); } }; /** * Returns the number of milliseconds between this date and date. * @param {Date} Defaults to now * @return {Number} The diff in milliseconds */ $P.getElapsed = function (date) { return (date || new Date()) - this; }; /** * Set the value of year, month, day, hour, minute, second, millisecond of date instance using given configuration object. * Example

	Date.today().set( { day: 20, month: 1 } )

	new Date().set( { millisecond: 0 } )
	
* * @param {Object} Configuration object containing attributes (month, day, etc.) * @return {Date} this */ $P.set = function (config) { config = validateConfigObject.call(this, config); var key; for (key in config) { if (Object.prototype.hasOwnProperty.call(config, key)) { var name = key.charAt(0).toUpperCase() + key.slice(1); var addFunc, getFunc; if (key !== "week" && key !== "month" && key !== "timezone" && key !== "timezoneOffset") { name += "s"; } addFunc = "add" + name; getFunc = "get" + name; if (key === "month") { addFunc = addFunc + "s"; } else if (key === "year"){ getFunc = "getFullYear"; } if (key !== "day" && key !== "timezone" && key !== "timezoneOffset" && key !== "week" && key !== "hour") { this[addFunc](config[key] - this[getFunc]()); } else if ( key === "timezone"|| key === "timezoneOffset" || key === "week" || key === "hour") { this["set"+name](config[key]); } } } // day has to go last because you can't validate the day without first knowing the month if (config.day) { this.addDays(config.day - this.getDate()); } return this; }; /** * Moves the date to the first day of the month. * @return {Date} this */ $P.moveToFirstDayOfMonth = function () { return this.set({ day: 1 }); }; /** * Moves the date to the last day of the month. * @return {Date} this */ $P.moveToLastDayOfMonth = function () { return this.set({ day: $D.getDaysInMonth(this.getFullYear(), this.getMonth())}); }; /** * Converts the value of the current Date object to its equivalent string representation. * Format Specifiers * CUSTOM DATE AND TIME FORMAT STRINGS * Format Description Example * ------ --------------------------------------------------------------------------- ----------------------- * s The seconds of the minute between 0-59. "0" to "59" * ss The seconds of the minute with leading zero if required. "00" to "59" * * m The minute of the hour between 0-59. "0" or "59" * mm The minute of the hour with leading zero if required. "00" or "59" * * h The hour of the day between 1-12. "1" to "12" * hh The hour of the day with leading zero if required. "01" to "12" * * H The hour of the day between 0-23. "0" to "23" * HH The hour of the day with leading zero if required. "00" to "23" * * d The day of the month between 1 and 31. "1" to "31" * dd The day of the month with leading zero if required. "01" to "31" * ddd Abbreviated day name. Date.CultureInfo.abbreviatedDayNames. "Mon" to "Sun" * dddd The full day name. Date.CultureInfo.dayNames. "Monday" to "Sunday" * * M The month of the year between 1-12. "1" to "12" * MM The month of the year with leading zero if required. "01" to "12" * MMM Abbreviated month name. Date.CultureInfo.abbreviatedMonthNames. "Jan" to "Dec" * MMMM The full month name. Date.CultureInfo.monthNames. "January" to "December" * * yy The year as a two-digit number. "99" or "08" * yyyy The full four digit year. "1999" or "2008" * * t Displays the first character of the A.M./P.M. designator. "A" or "P" * Date.CultureInfo.amDesignator or Date.CultureInfo.pmDesignator * tt Displays the A.M./P.M. designator. "AM" or "PM" * Date.CultureInfo.amDesignator or Date.CultureInfo.pmDesignator * * S The ordinal suffix ("st, "nd", "rd" or "th") of the current day. "st, "nd", "rd" or "th" * * STANDARD DATE AND TIME FORMAT STRINGS * Format Description Example *------ --------------------------------------------------------------------------- ----------------------- * d The CultureInfo shortDate Format Pattern "M/d/yyyy" * D The CultureInfo longDate Format Pattern "dddd, MMMM dd, yyyy" * F The CultureInfo fullDateTime Format Pattern "dddd, MMMM dd, yyyy h:mm:ss tt" * m The CultureInfo monthDay Format Pattern "MMMM dd" * r The CultureInfo rfc1123 Format Pattern "ddd, dd MMM yyyy HH:mm:ss GMT" * s The CultureInfo sortableDateTime Format Pattern "yyyy-MM-ddTHH:mm:ss" * t The CultureInfo shortTime Format Pattern "h:mm tt" * T The CultureInfo longTime Format Pattern "h:mm:ss tt" * u The CultureInfo universalSortableDateTime Format Pattern "yyyy-MM-dd HH:mm:ssZ" * y The CultureInfo yearMonth Format Pattern "MMMM, yyyy" * * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @return {String} A string representation of the current Date object. */ var ord = function (n) { switch (n * 1) { case 1: case 21: case 31: return "st"; case 2: case 22: return "nd"; case 3: case 23: return "rd"; default: return "th"; } }; var parseStandardFormats = function (format) { var y, c = Date.CultureInfo.formatPatterns; switch (format) { case "d": return this.toString(c.shortDate); case "D": return this.toString(c.longDate); case "F": return this.toString(c.fullDateTime); case "m": return this.toString(c.monthDay); case "r": case "R": y = this.clone().addMinutes(this.getTimezoneOffset()); return y.toString(c.rfc1123) + " GMT"; case "s": return this.toString(c.sortableDateTime); case "t": return this.toString(c.shortTime); case "T": return this.toString(c.longTime); case "u": y = this.clone().addMinutes(this.getTimezoneOffset()); return y.toString(c.universalSortableDateTime); case "y": return this.toString(c.yearMonth); default: return false; } }; var parseFormatStringsClosure = function (context) { return function (m) { if (m.charAt(0) === "\\") { return m.replace("\\", ""); } switch (m) { case "hh": return p(context.getHours() < 13 ? (context.getHours() === 0 ? 12 : context.getHours()) : (context.getHours() - 12)); case "h": return context.getHours() < 13 ? (context.getHours() === 0 ? 12 : context.getHours()) : (context.getHours() - 12); case "HH": return p(context.getHours()); case "H": return context.getHours(); case "mm": return p(context.getMinutes()); case "m": return context.getMinutes(); case "ss": return p(context.getSeconds()); case "s": return context.getSeconds(); case "yyyy": return p(context.getFullYear(), 4); case "yy": return p(context.getFullYear()); case "y": return context.getFullYear(); case "E": case "dddd": return Date.CultureInfo.dayNames[context.getDay()]; case "ddd": return Date.CultureInfo.abbreviatedDayNames[context.getDay()]; case "dd": return p(context.getDate()); case "d": return context.getDate(); case "MMMM": return Date.CultureInfo.monthNames[context.getMonth()]; case "MMM": return Date.CultureInfo.abbreviatedMonthNames[context.getMonth()]; case "MM": return p((context.getMonth() + 1)); case "M": return context.getMonth() + 1; case "t": return context.getHours() < 12 ? Date.CultureInfo.amDesignator.substring(0, 1) : Date.CultureInfo.pmDesignator.substring(0, 1); case "tt": return context.getHours() < 12 ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator; case "S": return ord(context.getDate()); case "W": return context.getWeek(); case "WW": return context.getISOWeek(); case "Q": return "Q" + context.getQuarter(); case "q": return String(context.getQuarter()); case "z": return context.getTimezone(); case "Z": case "X": return Date.getTimezoneOffset(context.getTimezone()); case "ZZ": // Timezone offset in seconds return context.getTimezoneOffset() * -60; case "u": return context.getDay(); case "L": return ($D.isLeapYear(context.getFullYear())) ? 1 : 0; case "B": // Swatch Internet Time (.beats) return "@"+((context.getUTCSeconds() + (context.getUTCMinutes()*60) + ((context.getUTCHours()+1)*3600))/86.4); default: return m; } }; }; $P.toString = function (format, ignoreStandards) { // Standard Date and Time Format Strings. Formats pulled from CultureInfo file and // may vary by culture. if (!ignoreStandards && format && format.length === 1) { output = parseStandardFormats.call(this, format); if (output) { return output; } } var parseFormatStrings = parseFormatStringsClosure(this); return format ? format.replace(/((\\)?(dd?d?d?|MM?M?M?|yy?y?y?|hh?|HH?|mm?|ss?|tt?|S|q|Q|WW?W?W?)(?![^\[]*\]))/g, parseFormatStrings).replace(/\[|\]/g, "") : this._toString(); }; }()); /************************************************************* * SugarPak - Domain Specific Language - Syntactical Sugar * *************************************************************/ (function () { var $D = Date, $P = $D.prototype, $N = Number.prototype; // private $P._orient = +1; // private $P._nth = null; // private $P._is = false; // private $P._same = false; // private $P._isSecond = false; // private $N._dateElement = "days"; /** * Moves the date to the next instance of a date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.today().next().friday();
	Date.today().next().fri();
	Date.today().next().march();
	Date.today().next().mar();
	Date.today().next().week();
	
* * @return {Date} date */ $P.next = function () { this._move = true; this._orient = +1; return this; }; /** * Creates a new Date (Date.today()) and moves the date to the next instance of the date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.next().friday();
	Date.next().fri();
	Date.next().march();
	Date.next().mar();
	Date.next().week();
	
* * @return {Date} date */ $D.next = function () { return $D.today().next(); }; /** * Moves the date to the previous instance of a date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.today().last().friday();
	Date.today().last().fri();
	Date.today().last().march();
	Date.today().last().mar();
	Date.today().last().week();
	
* * @return {Date} date */ $P.last = $P.prev = $P.previous = function () { this._move = true; this._orient = -1; return this; }; /** * Creates a new Date (Date.today()) and moves the date to the previous instance of the date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.last().friday();
	Date.last().fri();
	Date.previous().march();
	Date.prev().mar();
	Date.last().week();
	
* * @return {Date} date */ $D.last = $D.prev = $D.previous = function () { return $D.today().last(); }; /** * Performs a equality check when followed by either a month name, day name or .weekday() function. * Example

	Date.today().is().friday(); // true|false
	Date.today().is().fri();
	Date.today().is().march();
	Date.today().is().mar();
	
* * @return {Boolean} true|false */ $P.is = function () { this._is = true; return this; }; /** * Determines if two date objects occur on/in exactly the same instance of the subsequent date part function. * The function .same() must be followed by a date part function (example: .day(), .month(), .year(), etc). * * An optional Date can be passed in the date part function. If now date is passed as a parameter, 'Now' is used. * * The following example demonstrates how to determine if two dates fall on the exact same day. * * Example

	var d1 = Date.today(); // today at 00:00
	var d2 = new Date();   // exactly now.

	// Do they occur on the same day?
	d1.same().day(d2); // true
	
	// Do they occur on the same hour?
	d1.same().hour(d2); // false, unless d2 hour is '00' (midnight).
	
	// What if it's the same day, but one year apart?
	var nextYear = Date.today().add(1).year();

	d1.same().day(nextYear); // false, because the dates must occur on the exact same day. 
	
* * Scenario: Determine if a given date occurs during some week period 2 months from now. * * Example

	var future = Date.today().add(2).months();
	return someDate.same().week(future); // true|false;
	
* * @return {Boolean} true|false */ $P.same = function () { this._same = true; this._isSecond = false; return this; }; /** * Determines if the current date/time occurs during Today. Must be preceded by the .is() function. * Example

	someDate.is().today();    // true|false
	new Date().is().today();  // true
	Date.today().is().today();// true
	Date.today().add(-1).day().is().today(); // false
	
* * @return {Boolean} true|false */ $P.today = function () { return this.same().day(); }; /** * Determines if the current date is a weekday. This function must be preceded by the .is() function. * Example

	Date.today().is().weekday(); // true|false
	
* * @return {Boolean} true|false */ $P.weekday = function () { if (this._nth) { return df("Weekday").call(this); } if (this._move) { return this.addWeekdays(this._orient); } if (this._is) { this._is = false; return (!this.is().sat() && !this.is().sun()); } return false; }; /** * Determines if the current date is on the weekend. This function must be preceded by the .is() function. * Example

	Date.today().is().weekend(); // true|false
	
* * @return {Boolean} true|false */ $P.weekend = function () { if (this._is) { this._is = false; return (this.is().sat() || this.is().sun()); } return false; }; /** * Sets the Time of the current Date instance. A string "6:15 pm" or config object {hour:18, minute:15} are accepted. * Example

	// Set time to 6:15pm with a String
	Date.today().at("6:15pm");

	// Set time to 6:15pm with a config object
	Date.today().at({hour:18, minute:15});
	
* * @return {Date} date */ $P.at = function (time) { return (typeof time === "string") ? $D.parse(this.toString("d") + " " + time) : this.set(time); }; /** * Creates a new Date() and adds this (Number) to the date based on the preceding date element function (eg. second|minute|hour|day|month|year). * Example

	// Undeclared Numbers must be wrapped with parentheses. Requirment of JavaScript.
	(3).days().fromNow();
	(6).months().fromNow();

	// Declared Number variables do not require parentheses. 
	var n = 6;
	n.months().fromNow();
	
* * @return {Date} A new Date instance */ $N.fromNow = $N.after = function (date) { var c = {}; c[this._dateElement] = this; return ((!date) ? new Date() : date.clone()).add(c); }; /** * Creates a new Date() and subtract this (Number) from the date based on the preceding date element function (eg. second|minute|hour|day|month|year). * Example

	// Undeclared Numbers must be wrapped with parentheses. Requirment of JavaScript.
	(3).days().ago();
	(6).months().ago();

	// Declared Number variables do not require parentheses. 
	var n = 6;
	n.months().ago();
	
* * @return {Date} A new Date instance */ $N.ago = $N.before = function (date) { var c = {}, s = (this._dateElement[this._dateElement.length-1] !== "s") ? this._dateElement + "s" : this._dateElement; c[s] = this * -1; return ((!date) ? new Date() : date.clone()).add(c); }; // Do NOT modify the following string tokens. These tokens are used to build dynamic functions. // All culture-specific strings can be found in the CultureInfo files. var dx = ("sunday monday tuesday wednesday thursday friday saturday").split(/\s/), mx = ("january february march april may june july august september october november december").split(/\s/), px = ("Millisecond Second Minute Hour Day Week Month Year Quarter Weekday").split(/\s/), pxf = ("Milliseconds Seconds Minutes Hours Date Week Month FullYear Quarter").split(/\s/), nth = ("final first second third fourth fifth").split(/\s/), de; /** * Returns an object literal of all the date parts. * Example

	var o = new Date().toObject();
	
	// { year: 2008, month: 4, week: 20, day: 13, hour: 18, minute: 9, second: 32, millisecond: 812 }
	
	// The object properties can be referenced directly from the object.
	
	alert(o.day);  // alerts "13"
	alert(o.year); // alerts "2008"
	
* * @return {Date} An object literal representing the original date object. */ $P.toObject = function () { var o = {}; for (var i = 0; i < px.length; i++) { if (this["get" + pxf[i]]) { o[px[i].toLowerCase()] = this["get" + pxf[i]](); } } return o; }; /** * Returns a date created from an object literal. Ignores the .week property if set in the config. * Example

	var o = new Date().toObject();
	
	return Date.fromObject(o); // will return the same date. 

	var o2 = {month: 1, day: 20, hour: 18}; // birthday party!
	Date.fromObject(o2);
	
* * @return {Date} An object literal representing the original date object. */ $D.fromObject = function(config) { config.week = null; return Date.today().set(config); }; // Create day name functions and abbreviated day name functions (eg. monday(), friday(), fri()). var df = function (n) { return function () { if (this._is) { this._is = false; return this.getDay() === n; } if (this._move) { this._move = null; } if (this._nth !== null) { // If the .second() function was called earlier, remove the _orient // from the date, and then continue. // This is required because 'second' can be used in two different context. // // Example // // Date.today().add(1).second(); // Date.march().second().monday(); // // Things get crazy with the following... // Date.march().add(1).second().second().monday(); // but it works!! // if (this._isSecond) { this.addSeconds(this._orient * -1); } // make sure we reset _isSecond this._isSecond = false; var ntemp = this._nth; this._nth = null; var temp = this.clone().moveToLastDayOfMonth(); this.moveToNthOccurrence(n, ntemp); if (this > temp) { throw new RangeError($D.getDayName(n) + " does not occur " + ntemp + " times in the month of " + $D.getMonthName(temp.getMonth()) + " " + temp.getFullYear() + "."); } return this; } return this.moveToDayOfWeek(n, this._orient); }; }; var sdf = function (n) { return function () { var t = $D.today(), shift = n - t.getDay(); if (n === 0 && Date.CultureInfo.firstDayOfWeek === 1 && t.getDay() !== 0) { shift = shift + 7; } return t.addDays(shift); }; }; // Create month name functions and abbreviated month name functions (eg. january(), march(), mar()). var month_instance_functions = function (n) { return function () { if (this._is) { this._is = false; return this.getMonth() === n; } return this.moveToMonth(n, this._orient); }; }; var month_static_functions = function (n) { return function () { return $D.today().set({ month: n, day: 1 }); }; }; var processTerms = function (names, staticFunc, instanceFunc) { for (var i = 0; i < names.length; i++) { // Create constant static Name variables. $D[names[i].toUpperCase()] = $D[names[i].toUpperCase().substring(0, 3)] = i; // Create Name functions. $D[names[i]] = $D[names[i].substring(0, 3)] = staticFunc(i); // Create Name instance functions. $P[names[i]] = $P[names[i].substring(0, 3)] = instanceFunc(i); } }; processTerms(dx, sdf, df); processTerms(mx, month_static_functions, month_instance_functions); // Create date element functions and plural date element functions used with Date (eg. day(), days(), months()). var ef = function (j) { return function () { // if the .second() function was called earlier, the _orient // has alread been added. Just return this and reset _isSecond. if (this._isSecond) { this._isSecond = false; return this; } if (this._same) { this._same = this._is = false; var o1 = this.toObject(), o2 = (arguments[0] || new Date()).toObject(), v = "", k = j.toLowerCase(); // the substr trick with -1 doesn't work in IE8 or less k = (k[k.length-1] === "s") ? k.substring(0,k.length-1) : k; for (var m = (px.length - 1); m > -1; m--) { v = px[m].toLowerCase(); if (o1[v] !== o2[v]) { return false; } if (k === v) { break; } } return true; } if (j.substring(j.length - 1) !== "s") { j += "s"; } if (this._move) { this._move = null; } return this["add" + j](this._orient); }; }; var nf = function (n) { return function () { this._dateElement = n; return this; }; }; for (var k = 0; k < px.length; k++) { de = px[k].toLowerCase(); if(de !== "weekday") { // Create date element functions and plural date element functions used with Date (eg. day(), days(), months()). $P[de] = $P[de + "s"] = ef(px[k]); // Create date element functions and plural date element functions used with Number (eg. day(), days(), months()). $N[de] = $N[de + "s"] = nf(de + "s"); } } $P._ss = ef("Second"); var nthfn = function (n) { return function (dayOfWeek) { if (this._same) { return this._ss(arguments[0]); } if (dayOfWeek || dayOfWeek === 0) { return this.moveToNthOccurrence(dayOfWeek, n); } this._nth = n; // if the operator is 'second' add the _orient, then deal with it later... if (n === 2 && (dayOfWeek === undefined || dayOfWeek === null)) { this._isSecond = true; return this.addSeconds(this._orient); } return this; }; }; for (var l = 0; l < nth.length; l++) { $P[nth[l]] = (l === 0) ? nthfn(-1) : nthfn(l); } }()); (function () { "use strict"; Date.Parsing = { Exception: function (s) { this.message = "Parse error at '" + s.substring(0, 10) + " ...'"; } }; var $P = Date.Parsing; var dayOffsets = { standard: [0,31,59,90,120,151,181,212,243,273,304,334], leap: [0,31,60,91,121,152,182,213,244,274,305,335] }; $P.isLeapYear = function(year) { return ((year % 4 === 0) && (year % 100 !== 0)) || (year % 400 === 0); }; var utils = { multiReplace : function (str, hash ) { var key; for (key in hash) { if (Object.prototype.hasOwnProperty.call(hash, key)) { var regex; if (typeof hash[key] === "function") { } else { regex = (hash[key] instanceof RegExp) ? hash[key] : new RegExp(hash[key], "g"); } str = str.replace(regex, key); } } return str; }, getDayOfYearFromWeek : function (obj) { var d, jan4, offset; obj.weekDay = (!obj.weekDay && obj.weekDay !== 0) ? 1 : obj.weekDay; d = new Date(obj.year, 0, 4); jan4 = d.getDay() === 0 ? 7 : d.getDay(); // JS is 0 indexed on Sunday. offset = jan4+3; obj.dayOfYear = ((obj.week * 7) + (obj.weekDay === 0 ? 7 : obj.weekDay))-offset; return obj; }, getDayOfYear : function (obj, dayOffset) { if (!obj.dayOfYear) { obj = utils.getDayOfYearFromWeek(obj); } for (var i=0;i <= dayOffset.length;i++) { if (obj.dayOfYear < dayOffset[i] || i === dayOffset.length) { obj.day = obj.day ? obj.day : (obj.dayOfYear - dayOffset[i-1]); break; } else { obj.month = i; } } return obj; }, adjustForTimeZone : function (obj, date) { var offset; if (obj.zone.toUpperCase() === "Z" || (obj.zone_hours === 0 && obj.zone_minutes === 0)) { // it's UTC/GML so work out the current timeszone offset offset = -date.getTimezoneOffset(); } else { offset = (obj.zone_hours*60) + (obj.zone_minutes || 0); if (obj.zone_sign === "+") { offset *= -1; } offset -= date.getTimezoneOffset(); } date.setMinutes(date.getMinutes()+offset); return date; }, setDefaults : function (obj) { obj.year = obj.year || Date.today().getFullYear(); obj.hours = obj.hours || 0; obj.minutes = obj.minutes || 0; obj.seconds = obj.seconds || 0; obj.milliseconds = obj.milliseconds || 0; if (!(!obj.month && (obj.week || obj.dayOfYear))) { // if we have a month, or if we don't but don't have the day calculation data obj.month = obj.month || 0; obj.day = obj.day || 1; } return obj; }, dataNum: function (data, mod, explict, postProcess) { var dataNum = data*1; if (mod) { if (postProcess) { return data ? mod(data)*1 : data; } else { return data ? mod(dataNum) : data; } } else if (!explict){ return data ? dataNum : data; } else { return (data && typeof data !== "undefined") ? dataNum : data; } }, timeDataProcess: function (obj) { var timeObj = {}; for (var x in obj.data) { if (obj.data.hasOwnProperty(x)) { timeObj[x] = obj.ignore[x] ? obj.data[x] : utils.dataNum(obj.data[x], obj.mods[x], obj.explict[x], obj.postProcess[x]); } } if (obj.data.secmins) { obj.data.secmins = obj.data.secmins.replace(",", ".") * 60; if (!timeObj.minutes) { timeObj.minutes = obj.data.secmins; } else if (!timeObj.seconds) { timeObj.seconds = obj.data.secmins; } delete obj.secmins; } return timeObj; }, buildTimeObjectFromData: function (data) { var time = utils.timeDataProcess({ data: { year : data[1], month : data[5], day : data[7], week : data[8], dayOfYear : data[10], hours : data[15], zone_hours : data[23], zone_minutes : data[24], zone : data[21], zone_sign : data[22], weekDay : data[9], minutes: data[16], seconds: data[19], milliseconds: data[20], secmins: data[18] }, mods: { month: function(data) { return data-1; }, weekDay: function (data) { data = Math.abs(data); return (data === 7 ? 0 : data); }, minutes: function (data) { return data.replace(":",""); }, seconds: function (data) { return Math.floor( (data.replace(":","").replace(",","."))*1 ); }, milliseconds: function (data) { return (data.replace(",",".")*1000); } }, postProcess: { minutes: true, seconds: true, milliseconds: true }, explict: { zone_hours: true, zone_minutes: true }, ignore: { zone: true, zone_sign: true, secmins: true } }); return time; }, addToHash: function (hash, keys, data) { keys = keys; data = data; var len = keys.length; for (var i = 0; i < len; i++) { hash[keys[i]] = data[i]; } return hash; }, combineRegex: function (r1, r2) { return new RegExp("(("+r1.source+")\\s("+r2.source+"))"); }, getDateNthString: function(add, last, inc){ if (add) { return Date.today().addDays(inc).toString("d"); } else if (last) { return Date.today().last()[inc]().toString("d"); } }, buildRegexData: function (array) { var arr = []; var len = array.length; for (var i=0; i < len; i++) { if (Object.prototype.toString.call(array[i]) === '[object Array]') { // oldIE compat version of Array.isArray arr.push(this.combineRegex(array[i][0], array[i][1])); } else { arr.push(array[i]); } } return arr; } }; $P.processTimeObject = function (obj) { var date, dayOffset; utils.setDefaults(obj); dayOffset = ($P.isLeapYear(obj.year)) ? dayOffsets.leap : dayOffsets.standard; if (!obj.month && (obj.week || obj.dayOfYear)) { utils.getDayOfYear(obj, dayOffset); } else { obj.dayOfYear = dayOffset[obj.month] + obj.day; } date = new Date(obj.year, obj.month, obj.day, obj.hours, obj.minutes, obj.seconds, obj.milliseconds); if (obj.zone) { utils.adjustForTimeZone(obj, date); // adjust (and calculate) for timezone } return date; }; $P.ISO = { regex : /^([\+-]?\d{4}(?!\d{2}\b))((-?)((0[1-9]|1[0-2])(\3([12]\d|0[1-9]|3[01]))?|W([0-4]\d|5[0-3])(-?[1-7])?|(00[1-9]|0[1-9]\d|[12]\d{2}|3([0-5]\d|6[1-6])))([T\s]((([01]\d|2[0-4])((:?)[0-5]\d)?|24\:?00)([\.,]\d+(?!:))?)?(\17[0-5]\d([\.,]\d+)?)?\s?([zZ]|([\+-])([01]\d|2[0-3]):?([0-5]\d)?)?)?)?$/, parse : function (s) { var time, data = s.match(this.regex); if (!data || !data.length) { return null; } time = utils.buildTimeObjectFromData(data); if (!time.year || (!time.year && (!time.month && !time.day) && (!time.week && !time.dayOfYear)) ) { return null; } return $P.processTimeObject(time); } }; $P.Numeric = { isNumeric: function (e){return!isNaN(parseFloat(e))&&isFinite(e);}, regex: /\b([0-1]?[0-9])([0-3]?[0-9])([0-2]?[0-9]?[0-9][0-9])\b/i, parse: function (s) { var data, i, time = {}, order = Date.CultureInfo.dateElementOrder.split(""); if (!(this.isNumeric(s)) || // if it's non-numeric OR (s[0] === "+" && s[0] === "-")) { // It's an arithmatic string (eg +/-1000) return null; } if (s.length < 5 && s.indexOf(".") < 0 && s.indexOf("/") < 0) { // assume it's just a year. time.year = s; return $P.processTimeObject(time); } data = s.match(this.regex); if (!data || !data.length) { return null; } for (i=0; i < order.length; i++) { switch(order[i]) { case "d": time.day = data[i+1]; break; case "m": time.month = (data[i+1]-1); break; case "y": time.year = data[i+1]; break; } } return $P.processTimeObject(time); } }; $P.Normalizer = { regexData: function () { var $R = Date.CultureInfo.regexPatterns; return utils.buildRegexData([ $R.tomorrow, $R.yesterday, [$R.past, $R.mon], [$R.past, $R.tue], [$R.past, $R.wed], [$R.past, $R.thu], [$R.past, $R.fri], [$R.past, $R.sat], [$R.past, $R.sun] ]); }, basicReplaceHash : function() { var $R = Date.CultureInfo.regexPatterns; return { "January": $R.jan.source, "February": $R.feb, "March": $R.mar, "April": $R.apr, "May": $R.may, "June": $R.jun, "July": $R.jul, "August": $R.aug, "September": $R.sep, "October": $R.oct, "November": $R.nov, "December": $R.dec, "": /\bat\b/gi, " ": /\s{2,}/, "am": $R.inTheMorning, "9am": $R.thisMorning, "pm": $R.inTheEvening, "7pm":$R.thisEvening }; }, keys : function(){ return [ utils.getDateNthString(true, false, 1), // tomorrow utils.getDateNthString(true, false, -1), // yesterday utils.getDateNthString(false, true, "monday"), //last mon utils.getDateNthString(false, true, "tuesday"), //last tues utils.getDateNthString(false, true, "wednesday"), //last wed utils.getDateNthString(false, true, "thursday"), //last thurs utils.getDateNthString(false, true, "friday"), //last fri utils.getDateNthString(false, true, "saturday"), //last sat utils.getDateNthString(false, true, "sunday") //last sun ]; }, buildRegexFunctions: function () { var $R = Date.CultureInfo.regexPatterns; var __ = Date.i18n.__; var tomorrowRE = new RegExp("(\\b\\d\\d?("+__("AM")+"|"+__("PM")+")? )("+$R.tomorrow.source.slice(1)+")", "i"); // adapted tomorrow regex for AM PM relative dates var todayRE = new RegExp($R.today.source + "(?!\\s*([+-]))\\b"); // today, but excludes the math operators (eg "today + 2h") this.replaceFuncs = [ [todayRE, function (full) { return (full.length > 1) ? Date.today().toString("d") : full; }], [tomorrowRE, function(full, m1) { var t = Date.today().addDays(1).toString("d"); return (t + " " + m1); }], [$R.amThisMorning, function(str, am){return am;}], [$R.pmThisEvening, function(str, pm){return pm;}] ]; }, buildReplaceData: function () { this.buildRegexFunctions(); this.replaceHash = utils.addToHash(this.basicReplaceHash(), this.keys(), this.regexData()); }, stringReplaceFuncs: function (s) { for (var i=0; i < this.replaceFuncs.length; i++) { s = s.replace(this.replaceFuncs[i][0], this.replaceFuncs[i][1]); } return s; }, parse: function (s) { s = this.stringReplaceFuncs(s); s = utils.multiReplace(s, this.replaceHash); try { var n = s.split(/([\s\-\.\,\/\x27]+)/); if (n.length === 3 && $P.Numeric.isNumeric(n[0]) && $P.Numeric.isNumeric(n[2]) && (n[2].length >= 4)) { // ok, so we're dealing with x/year. But that's not a full date. // This fixes wonky dateElementOrder parsing when set to dmy order. if (Date.CultureInfo.dateElementOrder[0] === "d") { s = "1/" + n[0] + "/" + n[2]; // set to 1st of month and normalize the seperator } } } catch (e) {} return s; } }; $P.Normalizer.buildReplaceData(); }()); (function () { var $P = Date.Parsing; var _ = $P.Operators = { // // Tokenizers // rtoken: function (r) { // regex token return function (s) { var mx = s.match(r); if (mx) { return ([ mx[0], s.substring(mx[0].length) ]); } else { throw new $P.Exception(s); } }; }, token: function () { // whitespace-eating token return function (s) { return _.rtoken(new RegExp("^\\s*" + s + "\\s*"))(s); }; }, stoken: function (s) { // string token return _.rtoken(new RegExp("^" + s)); }, // Atomic Operators until: function (p) { return function (s) { var qx = [], rx = null; while (s.length) { try { rx = p.call(this, s); } catch (e) { qx.push(rx[0]); s = rx[1]; continue; } break; } return [ qx, s ]; }; }, many: function (p) { return function (s) { var rx = [], r = null; while (s.length) { try { r = p.call(this, s); } catch (e) { return [ rx, s ]; } rx.push(r[0]); s = r[1]; } return [ rx, s ]; }; }, // generator operators -- see below optional: function (p) { return function (s) { var r = null; try { r = p.call(this, s); } catch (e) { return [ null, s ]; } return [ r[0], r[1] ]; }; }, not: function (p) { return function (s) { try { p.call(this, s); } catch (e) { return [null, s]; } throw new $P.Exception(s); }; }, ignore: function (p) { return p ? function (s) { var r = null; r = p.call(this, s); return [null, r[1]]; } : null; }, product: function () { var px = arguments[0], qx = Array.prototype.slice.call(arguments, 1), rx = []; for (var i = 0 ; i < px.length ; i++) { rx.push(_.each(px[i], qx)); } return rx; }, cache: function (rule) { var cache = {}, cache_length = 0, cache_keys = [], CACHE_MAX = Date.Config.CACHE_MAX || 100000, r = null; var cacheCheck = function () { if (cache_length === CACHE_MAX) { // kill several keys, don't want to have to do this all the time... for (var i=0; i < 10; i++) { var key = cache_keys.shift(); if (key) { delete cache[key]; cache_length--; } } } }; return function (s) { cacheCheck(); try { r = cache[s] = (cache[s] || rule.call(this, s)); } catch (e) { r = cache[s] = e; } cache_length++; cache_keys.push(s); if (r instanceof $P.Exception) { throw r; } else { return r; } }; }, // vector operators -- see below any: function () { var px = arguments; return function (s) { var r = null; for (var i = 0; i < px.length; i++) { if (px[i] == null) { continue; } try { r = (px[i].call(this, s)); } catch (e) { r = null; } if (r) { return r; } } throw new $P.Exception(s); }; }, each: function () { var px = arguments; return function (s) { var rx = [], r = null; for (var i = 0; i < px.length ; i++) { if (px[i] == null) { continue; } try { r = (px[i].call(this, s)); } catch (e) { throw new $P.Exception(s); } rx.push(r[0]); s = r[1]; } return [ rx, s]; }; }, all: function () { var px = arguments, _ = _; return _.each(_.optional(px)); }, // delimited operators sequence: function (px, d, c) { d = d || _.rtoken(/^\s*/); c = c || null; if (px.length === 1) { return px[0]; } return function (s) { var r = null, q = null; var rx = []; for (var i = 0; i < px.length ; i++) { try { r = px[i].call(this, s); } catch (e) { break; } rx.push(r[0]); try { q = d.call(this, r[1]); } catch (ex) { q = null; break; } s = q[1]; } if (!r) { throw new $P.Exception(s); } if (q) { throw new $P.Exception(q[1]); } if (c) { try { r = c.call(this, r[1]); } catch (ey) { throw new $P.Exception(r[1]); } } return [ rx, (r?r[1]:s) ]; }; }, // // Composite Operators // between: function (d1, p, d2) { d2 = d2 || d1; var _fn = _.each(_.ignore(d1), p, _.ignore(d2)); return function (s) { var rx = _fn.call(this, s); return [[rx[0][0], r[0][2]], rx[1]]; }; }, list: function (p, d, c) { d = d || _.rtoken(/^\s*/); c = c || null; return (p instanceof Array ? _.each(_.product(p.slice(0, -1), _.ignore(d)), p.slice(-1), _.ignore(c)) : _.each(_.many(_.each(p, _.ignore(d))), px, _.ignore(c))); }, set: function (px, d, c) { d = d || _.rtoken(/^\s*/); c = c || null; return function (s) { // r is the current match, best the current 'best' match // which means it parsed the most amount of input var r = null, p = null, q = null, rx = null, best = [[], s], last = false; // go through the rules in the given set for (var i = 0; i < px.length ; i++) { // last is a flag indicating whether this must be the last element // if there is only 1 element, then it MUST be the last one q = null; p = null; r = null; last = (px.length === 1); // first, we try simply to match the current pattern // if not, try the next pattern try { r = px[i].call(this, s); } catch (e) { continue; } // since we are matching against a set of elements, the first // thing to do is to add r[0] to matched elements rx = [[r[0]], r[1]]; // if we matched and there is still input to parse and // we don't already know this is the last element, // we're going to next check for the delimiter ... // if there's none, or if there's no input left to parse // than this must be the last element after all ... if (r[1].length > 0 && ! last) { try { q = d.call(this, r[1]); } catch (ex) { last = true; } } else { last = true; } // if we parsed the delimiter and now there's no more input, // that means we shouldn't have parsed the delimiter at all // so don't update r and mark this as the last element ... if (!last && q[1].length === 0) { last = true; } // so, if this isn't the last element, we're going to see if // we can get any more matches from the remaining (unmatched) // elements ... if (!last) { // build a list of the remaining rules we can match against, // i.e., all but the one we just matched against var qx = []; for (var j = 0; j < px.length ; j++) { if (i !== j) { qx.push(px[j]); } } // now invoke recursively set with the remaining input // note that we don't include the closing delimiter ... // we'll check for that ourselves at the end p = _.set(qx, d).call(this, q[1]); // if we got a non-empty set as a result ... // (otw rx already contains everything we want to match) if (p[0].length > 0) { // update current result, which is stored in rx ... // basically, pick up the remaining text from p[1] // and concat the result from p[0] so that we don't // get endless nesting ... rx[0] = rx[0].concat(p[0]); rx[1] = p[1]; } } // at this point, rx either contains the last matched element // or the entire matched set that starts with this element. // now we just check to see if this variation is better than // our best so far, in terms of how much of the input is parsed if (rx[1].length < best[1].length) { best = rx; } // if we've parsed all the input, then we're finished if (best[1].length === 0) { break; } } // so now we've either gone through all the patterns trying them // as the initial match; or we found one that parsed the entire // input string ... // if best has no matches, just return empty set ... if (best[0].length === 0) { return best; } // if a closing delimiter is provided, then we have to check it also if (c) { // we try this even if there is no remaining input because the pattern // may well be optional or match empty input ... try { q = c.call(this, best[1]); } catch (ey) { throw new $P.Exception(best[1]); } // it parsed ... be sure to update the best match remaining input best[1] = q[1]; } // if we're here, either there was no closing delimiter or we parsed it // so now we have the best match; just return it! return best; }; }, forward: function (gr, fname) { return function (s) { return gr[fname].call(this, s); }; }, // // Translation Operators // replace: function (rule, repl) { return function (s) { var r = rule.call(this, s); return [repl, r[1]]; }; }, process: function (rule, fn) { return function (s) { var r = rule.call(this, s); return [fn.call(this, r[0]), r[1]]; }; }, min: function (min, rule) { return function (s) { var rx = rule.call(this, s); if (rx[0].length < min) { throw new $P.Exception(s); } return rx; }; } }; // Generator Operators And Vector Operators // Generators are operators that have a signature of F(R) => R, // taking a given rule and returning another rule, such as // ignore, which parses a given rule and throws away the result. // Vector operators are those that have a signature of F(R1,R2,...) => R, // take a list of rules and returning a new rule, such as each. // Generator operators are converted (via the following _generator // function) into functions that can also take a list or array of rules // and return an array of new rules as though the function had been // called on each rule in turn (which is what actually happens). // This allows generators to be used with vector operators more easily. // Example: // each(ignore(foo, bar)) instead of each(ignore(foo), ignore(bar)) // This also turns generators into vector operators, which allows // constructs like: // not(cache(foo, bar)) var _generator = function (op) { function gen() { var args = null, rx = [], px, i; if (arguments.length > 1) { args = Array.prototype.slice.call(arguments); } else if (arguments[0] instanceof Array) { args = arguments[0]; } if (args) { px = args.shift(); if (px.length > 0) { args.unshift(px[i]); rx.push(op.apply(null, args)); args.shift(); return rx; } } else { return op.apply(null, arguments); } } return gen; }; var gx = "optional not ignore cache".split(/\s/); for (var i = 0 ; i < gx.length ; i++) { _[gx[i]] = _generator(_[gx[i]]); } var _vector = function (op) { return function () { if (arguments[0] instanceof Array) { return op.apply(null, arguments[0]); } else { return op.apply(null, arguments); } }; }; var vx = "each any all".split(/\s/); for (var j = 0 ; j < vx.length ; j++) { _[vx[j]] = _vector(_[vx[j]]); } }()); (function () { var $D = Date; var flattenAndCompact = function (ax) { var rx = []; for (var i = 0; i < ax.length; i++) { if (ax[i] instanceof Array) { rx = rx.concat(flattenAndCompact(ax[i])); } else { if (ax[i]) { rx.push(ax[i]); } } } return rx; }; var parseMeridian = function () { if (this.meridian && (this.hour || this.hour === 0)) { if (this.meridian === "a" && this.hour > 11 && Date.Config.strict24hr){ throw "Invalid hour and meridian combination"; } else if (this.meridian === "p" && this.hour < 12 && Date.Config.strict24hr){ throw "Invalid hour and meridian combination"; } else if (this.meridian === "p" && this.hour < 12) { this.hour = this.hour + 12; } else if (this.meridian === "a" && this.hour === 12) { this.hour = 0; } } }; var setDefaults = function () { var now = new Date(); if ((this.hour || this.minute) && (!this.month && !this.year && !this.day)) { this.day = now.getDate(); } if (!this.year) { this.year = now.getFullYear(); } if (!this.month && this.month !== 0) { this.month = now.getMonth(); } if (!this.day) { this.day = 1; } if (!this.hour) { this.hour = 0; } if (!this.minute) { this.minute = 0; } if (!this.second) { this.second = 0; } if (!this.millisecond) { this.millisecond = 0; } }; var finishUtils = { getToday: function () { if (this.now || "hour minute second".indexOf(this.unit) !== -1) { return new Date(); } else { return $D.today(); } }, setDaysFromWeekday: function (today, orient){ var gap; orient = orient || 1; this.unit = "day"; gap = ($D.getDayNumberFromName(this.weekday) - today.getDay()); this.days = gap ? ((gap + (orient * 7)) % 7) : (orient * 7); return this; }, setMonthsFromMonth: function (today, orient) { var gap; orient = orient || 1; this.unit = "month"; gap = (this.month - today.getMonth()); this.months = gap ? ((gap + (orient * 12)) % 12) : (orient * 12); this.month = null; return this; }, setDMYFromWeekday: function () { var d = Date[this.weekday](); this.day = d.getDate(); if (!this.month) { this.month = d.getMonth(); } this.year = d.getFullYear(); return this; }, setUnitValue: function (orient) { if (!this.value && this.operator && this.operator !== null && this[this.unit + "s"] && this[this.unit + "s"] !== null) { this[this.unit + "s"] = this[this.unit + "s"] + ((this.operator === "add") ? 1 : -1) + (this.value||0) * orient; } else if (this[this.unit + "s"] == null || this.operator != null) { if (!this.value) { this.value = 1; } this[this.unit + "s"] = this.value * orient; } }, generateDateFromWeeks: function () { var weekday = (this.weekday !== undefined) ? this.weekday : "today"; var d = Date[weekday]().addWeeks(this.weeks); if (this.now) { d.setTimeToNow(); } return d; } }; $D.Translator = { hour: function (s) { return function () { this.hour = Number(s); }; }, minute: function (s) { return function () { this.minute = Number(s); }; }, second: function (s) { return function () { this.second = Number(s); }; }, /* for ss.s format */ secondAndMillisecond: function (s) { return function () { var mx = s.match(/^([0-5][0-9])\.([0-9]{1,3})/); this.second = Number(mx[1]); this.millisecond = Number(mx[2]); }; }, meridian: function (s) { return function () { this.meridian = s.slice(0, 1).toLowerCase(); }; }, timezone: function (s) { return function () { var n = s.replace(/[^\d\+\-]/g, ""); if (n.length) { this.timezoneOffset = Number(n); } else { this.timezone = s.toLowerCase(); } }; }, day: function (x) { var s = x[0]; return function () { this.day = Number(s.match(/\d+/)[0]); if (this.day < 1) { throw "invalid day"; } }; }, month: function (s) { return function () { this.month = (s.length === 3) ? "jan feb mar apr may jun jul aug sep oct nov dec".indexOf(s)/4 : Number(s) - 1; if (this.month < 0) { throw "invalid month"; } }; }, year: function (s) { return function () { var n = Number(s); this.year = ((s.length > 2) ? n : (n + (((n + 2000) < Date.CultureInfo.twoDigitYearMax) ? 2000 : 1900))); }; }, rday: function (s) { return function () { switch (s) { case "yesterday": this.days = -1; break; case "tomorrow": this.days = 1; break; case "today": this.days = 0; break; case "now": this.days = 0; this.now = true; break; } }; }, finishExact: function (x) { var d; x = (x instanceof Array) ? x : [x]; for (var i = 0 ; i < x.length ; i++) { if (x[i]) { x[i].call(this); } } setDefaults.call(this); parseMeridian.call(this); if (this.day > $D.getDaysInMonth(this.year, this.month)) { throw new RangeError(this.day + " is not a valid value for days."); } d = new Date(this.year, this.month, this.day, this.hour, this.minute, this.second, this.millisecond); if (this.year < 100) { d.setFullYear(this.year); // means years less that 100 are process correctly. JS will parse it otherwise as 1900-1999. } if (this.timezone) { d.set({ timezone: this.timezone }); } else if (this.timezoneOffset) { d.set({ timezoneOffset: this.timezoneOffset }); } return d; }, finish: function (x) { var today, expression, orient, temp; x = (x instanceof Array) ? flattenAndCompact(x) : [ x ]; if (x.length === 0) { return null; } for (var i = 0 ; i < x.length ; i++) { if (typeof x[i] === "function") { x[i].call(this); } } if (this.now && !this.unit && !this.operator) { return new Date(); } else { today = finishUtils.getToday.call(this); } expression = !!(this.days && this.days !== null || this.orient || this.operator); orient = ((this.orient === "past" || this.operator === "subtract") ? -1 : 1); if (this.month && this.unit === "week") { this.value = this.month + 1; delete this.month; delete this.day; } if ((this.month || this.month === 0) && "year day hour minute second".indexOf(this.unit) !== -1) { if (!this.value) { this.value = this.month + 1; } this.month = null; expression = true; } if (!expression && this.weekday && !this.day && !this.days) { finishUtils.setDMYFromWeekday.call(this); } if (expression && this.weekday && this.unit !== "month" && this.unit !== "week") { finishUtils.setDaysFromWeekday.call(this, today, orient); } if (this.weekday && this.unit !== "week" && !this.day && !this.days) { temp = Date[this.weekday](); this.day = temp.getDate(); if (temp.getMonth() !== today.getMonth()) { this.month = temp.getMonth(); } } if (this.month && this.unit === "day" && this.operator) { if (!this.value) { this.value = (this.month + 1); } this.month = null; } if (this.value != null && this.month != null && this.year != null) { this.day = this.value * 1; } if (this.month && !this.day && this.value) { today.set({ day: this.value * 1 }); if (!expression) { this.day = this.value * 1; } } if (!this.month && this.value && this.unit === "month" && !this.now) { this.month = this.value; expression = true; } if (expression && (this.month || this.month === 0) && this.unit !== "year") { finishUtils.setMonthsFromMonth.call(this, today, orient); } if (!this.unit) { this.unit = "day"; } finishUtils.setUnitValue.call(this, orient); parseMeridian.call(this); if ((this.month || this.month === 0) && !this.day) { this.day = 1; } if (!this.orient && !this.operator && this.unit === "week" && this.value && !this.day && !this.month) { return Date.today().setWeek(this.value); } if (this.unit === "week" && this.weeks && !this.day && !this.month) { return finishUtils.generateDateFromWeeks.call(this); } if (expression && this.timezone && this.day && this.days) { this.day = this.days; } if (expression){ today.add(this); } else { today.set(this); } if (this.timezone) { this.timezone = this.timezone.toUpperCase(); var offset = $D.getTimezoneOffset(this.timezone); var timezone; if (today.hasDaylightSavingTime()) { // lets check that we're being sane with timezone setting timezone = $D.getTimezoneAbbreviation(offset, today.isDaylightSavingTime()); if (timezone !== this.timezone) { // bugger, we're in a place where things like EST vs EDT matters. if (today.isDaylightSavingTime()) { today.addHours(-1); } else { today.addHours(1); } } } today.setTimezoneOffset(offset); } return today; } }; }()); (function () { var $D = Date; $D.Grammar = {}; var _ = $D.Parsing.Operators, g = $D.Grammar, t = $D.Translator, _fn; // Allow rolling up into general purpose rules _fn = function () { return _.each(_.any.apply(null, arguments), _.not(g.ctoken2("timeContext"))); }; g.datePartDelimiter = _.rtoken(/^([\s\-\.\,\/\x27]+)/); g.timePartDelimiter = _.stoken(":"); g.whiteSpace = _.rtoken(/^\s*/); g.generalDelimiter = _.rtoken(/^(([\s\,]|at|@|on)+)/); var _C = {}; g.ctoken = function (keys) { var fn = _C[keys]; if (! fn) { var c = Date.CultureInfo.regexPatterns; var kx = keys.split(/\s+/), px = []; for (var i = 0; i < kx.length ; i++) { px.push(_.replace(_.rtoken(c[kx[i]]), kx[i])); } fn = _C[keys] = _.any.apply(null, px); } return fn; }; g.ctoken2 = function (key) { return _.rtoken(Date.CultureInfo.regexPatterns[key]); }; var cacheProcessRtoken = function (key, token, type, eachToken) { if (eachToken) { g[key] = _.cache(_.process(_.each(_.rtoken(token),_.optional(g.ctoken2(eachToken))), type)); } else { g[key] = _.cache(_.process(_.rtoken(token), type)); } }; var cacheProcessCtoken = function (token, type) { return _.cache(_.process(g.ctoken2(token), type)); }; var _F = {}; //function cache var _get = function (f) { _F[f] = (_F[f] || g.format(f)[0]); return _F[f]; }; g.allformats = function (fx) { var rx = []; if (fx instanceof Array) { for (var i = 0; i < fx.length; i++) { rx.push(_get(fx[i])); } } else { rx.push(_get(fx)); } return rx; }; g.formats = function (fx) { if (fx instanceof Array) { var rx = []; for (var i = 0 ; i < fx.length ; i++) { rx.push(_get(fx[i])); } return _.any.apply(null, rx); } else { return _get(fx); } }; var grammarFormats = { timeFormats: function(){ var i, RTokenKeys = [ "h", "hh", "H", "HH", "m", "mm", "s", "ss", "ss.s", "z", "zz" ], RToken = [ /^(0[0-9]|1[0-2]|[1-9])/, /^(0[0-9]|1[0-2])/, /^([0-1][0-9]|2[0-3]|[0-9])/, /^([0-1][0-9]|2[0-3])/, /^([0-5][0-9]|[0-9])/, /^[0-5][0-9]/, /^([0-5][0-9]|[0-9])/, /^[0-5][0-9]/, /^[0-5][0-9]\.[0-9]{1,3}/, /^((\+|\-)\s*\d\d\d\d)|((\+|\-)\d\d\:?\d\d)/, /^((\+|\-)\s*\d\d\d\d)|((\+|\-)\d\d\:?\d\d)/ ], tokens = [ t.hour, t.hour, t.hour, t.hour, t.minute, t.minute, t.second, t.second, t.secondAndMillisecond, t.timezone, t.timezone ]; for (i=0; i < RTokenKeys.length; i++) { cacheProcessRtoken(RTokenKeys[i], RToken[i], tokens[i]); } g.hms = _.cache(_.sequence([g.H, g.m, g.s], g.timePartDelimiter)); g.t = cacheProcessCtoken("shortMeridian", t.meridian); g.tt = cacheProcessCtoken("longMeridian", t.meridian); g.zzz = cacheProcessCtoken("timezone", t.timezone); g.timeSuffix = _.each(_.ignore(g.whiteSpace), _.set([ g.tt, g.zzz ])); g.time = _.each(_.optional(_.ignore(_.stoken("T"))), g.hms, g.timeSuffix); }, dateFormats: function () { // pre-loaded rules for different date part order preferences var _setfn = function () { return _.set(arguments, g.datePartDelimiter); }; var i, RTokenKeys = [ "d", "dd", "M", "MM", "y", "yy", "yyy", "yyyy" ], RToken = [ /^([0-2]\d|3[0-1]|\d)/, /^([0-2]\d|3[0-1])/, /^(1[0-2]|0\d|\d)/, /^(1[0-2]|0\d)/, /^(\d+)/, /^(\d\d)/, /^(\d\d?\d?\d?)/, /^(\d\d\d\d)/ ], tokens = [ t.day, t.day, t.month, t.month, t.year, t.year, t.year, t.year ], eachToken = [ "ordinalSuffix", "ordinalSuffix" ]; for (i=0; i < RTokenKeys.length; i++) { cacheProcessRtoken(RTokenKeys[i], RToken[i], tokens[i], eachToken[i]); } g.MMM = g.MMMM = _.cache(_.process(g.ctoken("jan feb mar apr may jun jul aug sep oct nov dec"), t.month)); g.ddd = g.dddd = _.cache(_.process(g.ctoken("sun mon tue wed thu fri sat"), function (s) { return function () { this.weekday = s; }; } )); g.day = _fn(g.d, g.dd); g.month = _fn(g.M, g.MMM); g.year = _fn(g.yyyy, g.yy); g.mdy = _setfn(g.ddd, g.month, g.day, g.year); g.ymd = _setfn(g.ddd, g.year, g.month, g.day); g.dmy = _setfn(g.ddd, g.day, g.month, g.year); g.date = function (s) { return ((g[Date.CultureInfo.dateElementOrder] || g.mdy).call(this, s)); }; }, relative: function () { // relative date / time expressions g.orientation = _.process(g.ctoken("past future"), function (s) { return function () { this.orient = s; }; } ); g.operator = _.process(g.ctoken("add subtract"), function (s) { return function () { this.operator = s; }; } ); g.rday = _.process(g.ctoken("yesterday tomorrow today now"), t.rday); g.unit = _.process(g.ctoken("second minute hour day week month year"), function (s) { return function () { this.unit = s; }; } ); } }; g.buildGrammarFormats = function () { // these need to be rebuilt every time the language changes. _C = {}; grammarFormats.timeFormats(); grammarFormats.dateFormats(); grammarFormats.relative(); g.value = _.process(_.rtoken(/^([-+]?\d+)?(st|nd|rd|th)?/), function (s) { return function () { this.value = s.replace(/\D/g, ""); }; } ); g.expression = _.set([g.rday, g.operator, g.value, g.unit, g.orientation, g.ddd, g.MMM ]); g.format = _.process(_.many( _.any( // translate format specifiers into grammar rules _.process( _.rtoken(/^(dd?d?d?(?!e)|MM?M?M?|yy?y?y?|hh?|HH?|mm?|ss?|tt?|zz?z?)/), function (fmt) { if (g[fmt]) { return g[fmt]; } else { throw $D.Parsing.Exception(fmt); } } ), // translate separator tokens into token rules _.process(_.rtoken(/^[^dMyhHmstz]+/), // all legal separators function (s) { return _.ignore(_.stoken(s)); } ) ) ), // construct the parser ... function (rules) { return _.process(_.each.apply(null, rules), t.finishExact); } ); // starting rule for general purpose grammar g._start = _.process(_.set([ g.date, g.time, g.expression ], g.generalDelimiter, g.whiteSpace), t.finish); }; g.buildGrammarFormats(); // parsing date format specifiers - ex: "h:m:s tt" // this little guy will generate a custom parser based // on the format string, ex: g.format("h:m:s tt") // check for these formats first g._formats = g.formats([ "\"yyyy-MM-ddTHH:mm:ssZ\"", "yyyy-MM-ddTHH:mm:ss.sz", "yyyy-MM-ddTHH:mm:ssZ", "yyyy-MM-ddTHH:mm:ssz", "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-ddTHH:mmZ", "yyyy-MM-ddTHH:mmz", "yyyy-MM-ddTHH:mm", "ddd, MMM dd, yyyy H:mm:ss tt", "ddd MMM d yyyy HH:mm:ss zzz", "MMddyyyy", "ddMMyyyy", "Mddyyyy", "ddMyyyy", "Mdyyyy", "dMyyyy", "yyyy", "Mdyy", "dMyy", "d" ]); // real starting rule: tries selected formats first, // then general purpose rule g.start = function (s) { try { var r = g._formats.call({}, s); if (r[1].length === 0) { return r; } } catch (e) {} return g._start.call({}, s); }; }()); (function () { var $D = Date; /** * @desc Converts the specified string value into its JavaScript Date equivalent using CultureInfo specific format information. * * Example

	///////////
	// Dates //
	///////////

	// 15-Oct-2004
	var d1 = Date.parse("10/15/2004");

	// 15-Oct-2004
	var d1 = Date.parse("15-Oct-2004");

	// 15-Oct-2004
	var d1 = Date.parse("2004.10.15");

	//Fri Oct 15, 2004
	var d1 = Date.parse("Fri Oct 15, 2004");

	///////////
	// Times //
	///////////

	// Today at 10 PM.
	var d1 = Date.parse("10 PM");

	// Today at 10:30 PM.
	var d1 = Date.parse("10:30 P.M.");

	// Today at 6 AM.
	var d1 = Date.parse("06am");

	/////////////////////
	// Dates and Times //
	/////////////////////

	// 8-July-2004 @ 10:30 PM
	var d1 = Date.parse("July 8th, 2004, 10:30 PM");

	// 1-July-2004 @ 10:30 PM
	var d1 = Date.parse("2004-07-01T22:30:00");

	////////////////////
	// Relative Dates //
	////////////////////

	// Returns today's date. The string "today" is culture specific.
	var d1 = Date.parse("today");

	// Returns yesterday's date. The string "yesterday" is culture specific.
	var d1 = Date.parse("yesterday");

	// Returns the date of the next thursday.
	var d1 = Date.parse("Next thursday");

	// Returns the date of the most previous monday.
	var d1 = Date.parse("last monday");

	// Returns today's day + one year.
	var d1 = Date.parse("next year");

	///////////////
	// Date Math //
	///////////////

	// Today + 2 days
	var d1 = Date.parse("t+2");

	// Today + 2 days
	var d1 = Date.parse("today + 2 days");

	// Today + 3 months
	var d1 = Date.parse("t+3m");

	// Today - 1 year
	var d1 = Date.parse("today - 1 year");

	// Today - 1 year
	var d1 = Date.parse("t-1y"); 


	/////////////////////////////
	// Partial Dates and Times //
	/////////////////////////////

	// July 15th of this year.
	var d1 = Date.parse("July 15");

	// 15th day of current day and year.
	var d1 = Date.parse("15");

	// July 1st of current year at 10pm.
	var d1 = Date.parse("7/1 10pm");
	
* * @param {String} The string value to convert into a Date object [Required] * @return {Date} A Date object or null if the string cannot be converted into a Date. */ var parseUtils = { removeOrds: function (s) { ords = s.match(/\b(\d+)(?:st|nd|rd|th)\b/); // find ordinal matches s = ((ords && ords.length === 2) ? s.replace(ords[0], ords[1]) : s); return s; }, grammarParser: function (s) { var r = null; try { r = $D.Grammar.start.call({}, s.replace(/^\s*(\S*(\s+\S+)*)\s*$/, "$1")); } catch (e) { return null; } return ((r[1].length === 0) ? r[0] : null); }, nativeFallback: function(s) { var t; try { // ok we haven't parsed it, last ditch attempt with the built-in parser. t = Date._parse(s); return (t || t === 0) ? new Date(t) : null; } catch (e) { return null; } } }; function parse (s) { var d; if (!s) { return null; } if (s instanceof Date) { return s.clone(); } if (s.length >= 4 && s.charAt(0) !== "0" && s.charAt(0) !== "+"&& s.charAt(0) !== "-") { // ie: 2004 will pass, 0800 won't. // Start with specific formats d = $D.Parsing.ISO.parse(s) || $D.Parsing.Numeric.parse(s); } if (d instanceof Date && !isNaN(d.getTime())) { return d; } else { // find ordinal dates (1st, 3rd, 8th, etc and remove them as they cause parsing issues) s = $D.Parsing.Normalizer.parse(parseUtils.removeOrds(s)); d = parseUtils.grammarParser(s); if (d !== null) { return d; } else { return parseUtils.nativeFallback(s); } } } if (!$D._parse) { $D._parse = $D.parse; } $D.parse = parse; Date.getParseFunction = function (fx) { var fns = Date.Grammar.allformats(fx); return function (s) { var r = null; for (var i = 0; i < fns.length; i++) { try { r = fns[i].call({}, s); } catch (e) { continue; } if (r[1].length === 0) { return r[0]; } } return null; }; }; /** * Converts the specified string value into its JavaScript Date equivalent using the specified format {String} or formats {Array} and the CultureInfo specific format information. * The format of the string value must match one of the supplied formats exactly. * * Example

	// 15-Oct-2004
	var d1 = Date.parseExact("10/15/2004", "M/d/yyyy");

	// 15-Oct-2004
	var d1 = Date.parse("15-Oct-2004", "M-ddd-yyyy");

	// 15-Oct-2004
	var d1 = Date.parse("2004.10.15", "yyyy.MM.dd");

	// Multiple formats
	var d1 = Date.parseExact("10/15/2004", ["M/d/yyyy", "MMMM d, yyyy"]);
	
* * @param {String} The string value to convert into a Date object [Required]. * @param {Object} The expected format {String} or an array of expected formats {Array} of the date string [Required]. * @return {Date} A Date object or null if the string cannot be converted into a Date. */ $D.parseExact = function (s, fx) { return $D.getParseFunction(fx)(s); }; }()); (function () { var $D = Date, $P = $D.prototype, // $C = $D.CultureInfo, // not used atm p = function (s, l) { if (!l) { l = 2; } return ("000" + s).slice(l * -1); }; /** * Converts a PHP format string to Java/.NET format string. * A PHP format string can be used with ._format or .format. * A Java/.NET format string can be used with .toString(). * The .parseExact function will only accept a Java/.NET format string * * Example * var f1 = "%m/%d/%y" * var f2 = Date.normalizeFormat(f1); // "MM/dd/yy" * * new Date().format(f1); // "04/13/08" * new Date()._format(f1); // "04/13/08" * new Date().toString(f2); // "04/13/08" * * var date = Date.parseExact("04/13/08", f2); // Sun Apr 13 2008 * * @param {String} A PHP format string consisting of one or more format spcifiers. * @return {String} The PHP format converted to a Java/.NET format string. */ var normalizerSubstitutions = { "d" : "dd", "%d": "dd", "D" : "ddd", "%a": "ddd", "j" : "dddd", "l" : "dddd", "%A": "dddd", "S" : "S", "F" : "MMMM", "%B": "MMMM", "m" : "MM", "%m": "MM", "M" : "MMM", "%b": "MMM", "%h": "MMM", "n" : "M", "Y" : "yyyy", "%Y": "yyyy", "y" : "yy", "%y": "yy", "g" : "h", "%I": "h", "G" : "H", "h" : "hh", "H" : "HH", "%H": "HH", "i" : "mm", "%M": "mm", "s" : "ss", "%S": "ss", "%r": "hh:mm tt", "%R": "H:mm", "%T": "H:mm:ss", "%X": "t", "%x": "d", "%e": "d", "%D": "MM/dd/yy", "%n": "\\n", "%t": "\\t", "e" : "z", "T" : "z", "%z": "z", "%Z": "z", "Z" : "ZZ", "N" : "u", "w" : "u", "%w": "u", "W" : "W", "%V": "W" }; var normalizer = { substitutes: function (m) { return normalizerSubstitutions[m]; }, interpreted: function (m, x) { var y; switch (m) { case "%u": return x.getDay() + 1; case "z": return x.getOrdinalNumber(); case "%j": return p(x.getOrdinalNumber(), 3); case "%U": var d1 = x.clone().set({month: 0, day: 1}).addDays(-1).moveToDayOfWeek(0), d2 = x.clone().addDays(1).moveToDayOfWeek(0, -1); return (d2 < d1) ? "00" : p((d2.getOrdinalNumber() - d1.getOrdinalNumber()) / 7 + 1); case "%W": return p(x.getWeek()); case "t": return $D.getDaysInMonth(x.getFullYear(), x.getMonth()); case "o": case "%G": return x.setWeek(x.getISOWeek()).toString("yyyy"); case "%g": return x._format("%G").slice(-2); case "a": case "%p": return t("tt").toLowerCase(); case "A": return t("tt").toUpperCase(); case "u": return p(x.getMilliseconds(), 3); case "I": return (x.isDaylightSavingTime()) ? 1 : 0; case "O": return x.getUTCOffset(); case "P": y = x.getUTCOffset(); return y.substring(0, y.length - 2) + ":" + y.substring(y.length - 2); case "B": var now = new Date(); return Math.floor(((now.getHours() * 3600) + (now.getMinutes() * 60) + now.getSeconds() + (now.getTimezoneOffset() + 60) * 60) / 86.4); case "c": return x.toISOString().replace(/\"/g, ""); case "U": return $D.strtotime("now"); case "%c": return t("d") + " " + t("t"); case "%C": return Math.floor(x.getFullYear() / 100 + 1); } }, shouldOverrideDefaults: function (m) { switch (m) { case "%e": return true; default: return false; } }, parse: function (m, context) { var formatString, c = context || new Date(); formatString = normalizer.substitutes(m); if (formatString) { return formatString; } formatString = normalizer.interpreted(m, c); if (formatString) { return formatString; } else { return m; } } }; $D.normalizeFormat = function (format, context) { return format.replace(/(%|\\)?.|%%/g, function(t){ return normalizer.parse(t, context); }); }; /** * Format a local Unix timestamp according to locale settings * * Example: * Date.strftime("%m/%d/%y", new Date()); // "04/13/08" * Date.strftime("c", "2008-04-13T17:52:03Z"); // "04/13/08" * * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @param {Number|String} The number representing the number of seconds that have elapsed since January 1, 1970 (local time). * @return {String} A string representation of the current Date object. */ $D.strftime = function (format, time) { var d = Date.parse(time); return d._format(format); }; /** * Parse any textual datetime description into a Unix timestamp. * A Unix timestamp is the number of seconds that have elapsed since January 1, 1970 (midnight UTC/GMT). * * Example: * Date.strtotime("04/13/08"); // 1208044800 * Date.strtotime("1970-01-01T00:00:00Z"); // 0 * * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @param {Object} A string or date object. * @return {String} A string representation of the current Date object. */ $D.strtotime = function (time) { var d = $D.parse(time); return Math.round($D.UTC(d.getUTCFullYear(), d.getUTCMonth(), d.getUTCDate(), d.getUTCHours(), d.getUTCMinutes(), d.getUTCSeconds(), d.getUTCMilliseconds()) / 1000); }; /** * Converts the value of the current Date object to its equivalent string representation using a PHP/Unix style of date format specifiers. * Format Specifiers * Format Description Example * ------ --------------------------------------------------------------------------- ----------------------- * %a abbreviated weekday name according to the current localed "Mon" through "Sun" * %A full weekday name according to the current localed "Sunday" through "Saturday" * %b abbreviated month name according to the current localed "Jan" through "Dec" * %B full month name according to the current locale "January" through "December" * %c preferred date and time representation for the current locale "4/13/2008 12:33 PM" * %C century number (the year divided by 100 and truncated to an integer) "00" to "99" * %d day of the month as a decimal number "01" to "31" * %D same as %m/%d/%y "04/13/08" * %e day of the month as a decimal number, a single digit is preceded by a space "1" to "31" * %g like %G, but without the century "08" * %G The 4-digit year corresponding to the ISO week number (see %V). "2008" * This has the same format and value as %Y, except that if the ISO week number * belongs to the previous or next year, that year is used instead. * %h same as %b "Jan" through "Dec" * %H hour as a decimal number using a 24-hour clock. "00" to "23" * %I hour as a decimal number using a 12-hour clock. "01" to "12" * %j day of the year as a decimal number. "001" to "366" * %m month as a decimal number. "01" to "12" * %M minute as a decimal number. "00" to "59" * %n newline character "\n" * %p either "am" or "pm" according to the given time value, or the "am" or "pm" * corresponding strings for the current locale. * %r time in a.m. and p.m. notation "8:44 PM" * %R time in 24 hour notation "20:44" * %S second as a decimal number "00" to "59" * %t tab character "\t" * %T current time, equal to %H:%M:%S "12:49:11" * %u weekday as a decimal number ["1", "7"], with "1" representing Monday "1" to "7" * %U week number of the current year as a decimal number, starting with the "0" to ("52" or "53") * first Sunday as the first day of the first week * %V The ISO 8601:1988 week number of the current year as a decimal number, "00" to ("52" or "53") * range 01 to 53, where week 1 is the first week that has at least 4 days * in the current year, and with Monday as the first day of the week. * (Use %G or %g for the year component that corresponds to the week number * for the specified timestamp.) * %W week number of the current year as a decimal number, starting with the "00" to ("52" or "53") * first Monday as the first day of the first week * %w day of the week as a decimal, Sunday being "0" "0" to "6" * %x preferred date representation for the current locale without the time "4/13/2008" * %X preferred time representation for the current locale without the date "12:53:05" * %y year as a decimal number without a century "00" "99" * %Y year as a decimal number including the century "2008" * %Z time zone or name or abbreviation "UTC", "EST", "PST" * %z same as %Z * %% a literal "%" characters "%" * d Day of the month, 2 digits with leading zeros "01" to "31" * D A textual representation of a day, three letters "Mon" through "Sun" * j Day of the month without leading zeros "1" to "31" * l A full textual representation of the day of the week (lowercase "L") "Sunday" through "Saturday" * N ISO-8601 numeric representation of the day of the week (added in PHP 5.1.0) "1" (for Monday) through "7" (for Sunday) * S English ordinal suffix for the day of the month, 2 characters "st", "nd", "rd" or "th". Works well with j * w Numeric representation of the day of the week "0" (for Sunday) through "6" (for Saturday) * z The day of the year (starting from "0") "0" through "365" * W ISO-8601 week number of year, weeks starting on Monday "00" to ("52" or "53") * F A full textual representation of a month, such as January or March "January" through "December" * m Numeric representation of a month, with leading zeros "01" through "12" * M A short textual representation of a month, three letters "Jan" through "Dec" * n Numeric representation of a month, without leading zeros "1" through "12" * t Number of days in the given month "28" through "31" * L Whether it's a leap year "1" if it is a leap year, "0" otherwise * o ISO-8601 year number. This has the same value as Y, except that if the "2008" * ISO week number (W) belongs to the previous or next year, that year * is used instead. * Y A full numeric representation of a year, 4 digits "2008" * y A two digit representation of a year "08" * a Lowercase Ante meridiem and Post meridiem "am" or "pm" * A Uppercase Ante meridiem and Post meridiem "AM" or "PM" * B Swatch Internet time "000" through "999" * g 12-hour format of an hour without leading zeros "1" through "12" * G 24-hour format of an hour without leading zeros "0" through "23" * h 12-hour format of an hour with leading zeros "01" through "12" * H 24-hour format of an hour with leading zeros "00" through "23" * i Minutes with leading zeros "00" to "59" * s Seconds, with leading zeros "00" through "59" * u Milliseconds "54321" * e Timezone identifier "UTC", "EST", "PST" * I Whether or not the date is in daylight saving time (uppercase i) "1" if Daylight Saving Time, "0" otherwise * O Difference to Greenwich time (GMT) in hours "+0200", "-0600" * P Difference to Greenwich time (GMT) with colon between hours and minutes "+02:00", "-06:00" * T Timezone abbreviation "UTC", "EST", "PST" * Z Timezone offset in seconds. The offset for timezones west of UTC is "-43200" through "50400" * always negative, and for those east of UTC is always positive. * c ISO 8601 date "2004-02-12T15:19:21+00:00" * r RFC 2822 formatted date "Thu, 21 Dec 2000 16:01:07 +0200" * U Seconds since the Unix Epoch (January 1 1970 00:00:00 GMT) "0" * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @return {String} A string representation of the current Date object. */ var formatReplace = function (context) { return function (m) { var formatString, override = false; if (m.charAt(0) === "\\" || m.substring(0, 2) === "%%") { return m.replace("\\", "").replace("%%", "%"); } override = normalizer.shouldOverrideDefaults(m); formatString = $D.normalizeFormat(m, context); if (formatString) { return context.toString(formatString, override); } }; }; $P._format = function (format) { var formatter = formatReplace(this); if (!format) { return this._toString(); } else { return format.replace(/(%|\\)?.|%%/g, formatter); } }; if (!$P.format) { $P.format = $P._format; } }()); (function () { "use strict"; var gFn = function (attr) { return function () { return this[attr]; }; }; var sFn = function (attr) { return function (val) { this[attr] = val; return this; }; }; var attrs = ["years", "months", "days", "hours", "minutes", "seconds", "milliseconds"]; var addSetFuncs = function (context, attrs) { for (var i = 0; i < attrs.length ; i++) { var $a = attrs[i], $b = $a.slice(0, 1).toUpperCase() + $a.slice(1); context.prototype[$a] = 0; context.prototype["get" + $b] = gFn($a); context.prototype["set" + $b] = sFn($a); } }; /** * new TimeSpan(milliseconds); * new TimeSpan(days, hours, minutes, seconds); * new TimeSpan(days, hours, minutes, seconds, milliseconds); */ var TimeSpan = function (days, hours, minutes, seconds, milliseconds) { if (arguments.length === 1 && typeof days === "number") { var orient = (days < 0) ? -1 : +1; var millsLeft = Math.abs(days); this.setDays(Math.floor(millsLeft / 86400000) * orient); millsLeft = millsLeft % 86400000; this.setHours(Math.floor(millsLeft / 3600000) * orient); millsLeft = millsLeft % 3600000; this.setMinutes(Math.floor(millsLeft / 60000) * orient); millsLeft = millsLeft % 60000; this.setSeconds(Math.floor(millsLeft / 1000) * orient); millsLeft = millsLeft % 1000; this.setMilliseconds(millsLeft * orient); } else { this.set(days, hours, minutes, seconds, milliseconds); } this.getTotalMilliseconds = function () { return (this.getDays() * 86400000) + (this.getHours() * 3600000) + (this.getMinutes() * 60000) + (this.getSeconds() * 1000); }; this.compareTo = function (time) { var t1 = new Date(1970, 1, 1, this.getHours(), this.getMinutes(), this.getSeconds()), t2; if (time === null) { t2 = new Date(1970, 1, 1, 0, 0, 0); } else { t2 = new Date(1970, 1, 1, time.getHours(), time.getMinutes(), time.getSeconds()); } return (t1 < t2) ? -1 : (t1 > t2) ? 1 : 0; }; this.equals = function (time) { return (this.compareTo(time) === 0); }; this.add = function (time) { return (time === null) ? this : this.addSeconds(time.getTotalMilliseconds() / 1000); }; this.subtract = function (time) { return (time === null) ? this : this.addSeconds(-time.getTotalMilliseconds() / 1000); }; this.addDays = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 86400000)); }; this.addHours = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 3600000)); }; this.addMinutes = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 60000)); }; this.addSeconds = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 1000)); }; this.addMilliseconds = function (n) { return new TimeSpan(this.getTotalMilliseconds() + n); }; this.get12HourHour = function () { return (this.getHours() > 12) ? this.getHours() - 12 : (this.getHours() === 0) ? 12 : this.getHours(); }; this.getDesignator = function () { return (this.getHours() < 12) ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator; }; this.toString = function (format) { this._toString = function () { if (this.getDays() !== null && this.getDays() > 0) { return this.getDays() + "." + this.getHours() + ":" + this.p(this.getMinutes()) + ":" + this.p(this.getSeconds()); } else { return this.getHours() + ":" + this.p(this.getMinutes()) + ":" + this.p(this.getSeconds()); } }; this.p = function (s) { return (s.toString().length < 2) ? "0" + s : s; }; var me = this; return format ? format.replace(/dd?|HH?|hh?|mm?|ss?|tt?/g, function (format) { switch (format) { case "d": return me.getDays(); case "dd": return me.p(me.getDays()); case "H": return me.getHours(); case "HH": return me.p(me.getHours()); case "h": return me.get12HourHour(); case "hh": return me.p(me.get12HourHour()); case "m": return me.getMinutes(); case "mm": return me.p(me.getMinutes()); case "s": return me.getSeconds(); case "ss": return me.p(me.getSeconds()); case "t": return ((me.getHours() < 12) ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator).substring(0, 1); case "tt": return (me.getHours() < 12) ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator; } } ) : this._toString(); }; return this; }; addSetFuncs(TimeSpan, attrs.slice(2)); TimeSpan.prototype.set = function (days, hours, minutes, seconds, milliseconds){ this.setDays(days || this.getDays()); this.setHours(hours || this.getHours()); this.setMinutes(minutes || this.getMinutes()); this.setSeconds(seconds || this.getSeconds()); this.setMilliseconds(milliseconds || this.getMilliseconds()); }; /** * Gets the time of day for this date instances. * @return {TimeSpan} TimeSpan */ Date.prototype.getTimeOfDay = function () { return new TimeSpan(0, this.getHours(), this.getMinutes(), this.getSeconds(), this.getMilliseconds()); }; Date.TimeSpan = TimeSpan; if (typeof window !== "undefined" ) { // keeping API compatible for v1.x window.TimeSpan = TimeSpan; } }()); (function () { "use strict"; var attrs = ["years", "months", "days", "hours", "minutes", "seconds", "milliseconds"]; var gFn = function (attr) { return function () { return this[attr]; }; }; var sFn = function (attr) { return function (val) { this[attr] = val; return this; }; }; var addSetFuncs = function (context, attrs) { for (var i = 0; i < attrs.length ; i++) { var $a = attrs[i], $b = $a.slice(0, 1).toUpperCase() + $a.slice(1); context.prototype[$a] = 0; context.prototype["get" + $b] = gFn($a); context.prototype["set" + $b] = sFn($a); } }; var setMonthsAndYears = function (orient, d1, d2, context) { function inc() { d1.addMonths(-orient); context.months++; if (context.months === 12) { context.years++; context.months = 0; } } if (orient === +1) { while (d1 > d2) { inc(); } } else { while (d1 < d2) { inc(); } } context.months--; context.months *= orient; context.years *= orient; }; var adjustForDST = function(orient, startDate, endDate) { var hasDSTMismatch = (false === (startDate.isDaylightSavingTime() === endDate.isDaylightSavingTime())); if (hasDSTMismatch && orient === 1) { startDate.addHours(-1); } else if (hasDSTMismatch) { startDate.addHours(1); } }; /** * TimePeriod(startDate, endDate); * TimePeriod(years, months, days, hours, minutes, seconds, milliseconds); */ var TimePeriod = function (years, months, days, hours, minutes, seconds, milliseconds) { if (arguments.length === 7) { this.set(years, months, days, hours, minutes, seconds, milliseconds); } else if (arguments.length === 2 && arguments[0] instanceof Date && arguments[1] instanceof Date) { var startDate = arguments[0].clone(); var endDate = arguments[1].clone(); var orient = (startDate > endDate) ? +1 : -1; this.dates = { start: arguments[0].clone(), end: arguments[1].clone() }; setMonthsAndYears(orient, startDate, endDate, this); adjustForDST(orient, startDate, endDate); // // TODO - adjust for DST var diff = endDate - startDate; if (diff !== 0) { var ts = new TimeSpan(diff); this.set(this.years, this.months, ts.getDays(), ts.getHours(), ts.getMinutes(), ts.getSeconds(), ts.getMilliseconds()); } } return this; }; // create all the set functions. addSetFuncs(TimePeriod, attrs); TimePeriod.prototype.set = function (years, months, days, hours, minutes, seconds, milliseconds){ this.setYears(years || this.getYears()); this.setMonths(months || this.getMonths()); this.setDays(days || this.getDays()); this.setHours(hours || this.getHours()); this.setMinutes(minutes || this.getMinutes()); this.setSeconds(seconds || this.getSeconds()); this.setMilliseconds(milliseconds || this.getMilliseconds()); }; Date.TimePeriod = TimePeriod; if (typeof window !== "undefined") { // keeping API compatible for v1.x window.TimePeriod = TimePeriod; } }()); ================================================ FILE: build/date-fa-IR.js ================================================ /** * @overview datejs * @version 1.0.0-rc3 * @author Gregory Wild-Smith * @copyright 2015 Gregory Wild-Smith * @license MIT * @homepage https://github.com/abritinthebay/datejs */ /* * DateJS Culture String File * Country Code: fa-IR * Name: Persian (Iran) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["fa-IR"] = { "name": "fa-IR", "englishName": "Persian (Iran)", "nativeName": "فارسى (ايران)", "Sunday": "Sunday", "Monday": "Monday", "Tuesday": "Tuesday", "Wednesday": "Wednesday", "Thursday": "Thursday", "Friday": "Friday", "Saturday": "Saturday", "Sun": "Sun", "Mon": "Mon", "Tue": "Tue", "Wed": "Wed", "Thu": "Thu", "Fri": "Fri", "Sat": "Sat", "Su": "Su", "Mo": "Mo", "Tu": "Tu", "We": "We", "Th": "Th", "Fr": "Fr", "Sa": "Sa", "S_Sun_Initial": "S", "M_Mon_Initial": "M", "T_Tue_Initial": "T", "W_Wed_Initial": "W", "T_Thu_Initial": "T", "F_Fri_Initial": "F", "S_Sat_Initial": "S", "January": "January", "February": "February", "March": "March", "April": "April", "May": "May", "June": "June", "July": "July", "August": "August", "September": "September", "October": "October", "November": "November", "December": "December", "Jan_Abbr": "Jan", "Feb_Abbr": "Feb", "Mar_Abbr": "Mar", "Apr_Abbr": "Apr", "May_Abbr": "May", "Jun_Abbr": "Jun", "Jul_Abbr": "Jul", "Aug_Abbr": "Aug", "Sep_Abbr": "Sep", "Oct_Abbr": "Oct", "Nov_Abbr": "Nov", "Dec_Abbr": "Dec", "AM": "ق.ظ", "PM": "ب.ظ", "firstDayOfWeek": 0, "twoDigitYearMax": 2029, "mdy": "mdy", "M/d/yyyy": "M/d/yyyy", "dddd, MMMM dd, yyyy": "dddd, MMMM dd, yyyy", "h:mm tt": "hh:mm tt", "h:mm:ss tt": "hh:mm:ss tt", "dddd, MMMM dd, yyyy h:mm:ss tt": "dddd, MMMM dd, yyyy hh:mm:ss tt", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "MMMM dd", "MMMM, yyyy": "MMMM, yyyy", "/jan(uary)?/": "jan(uary)?", "/feb(ruary)?/": "feb(ruary)?", "/mar(ch)?/": "mar(ch)?", "/apr(il)?/": "apr(il)?", "/may/": "may", "/jun(e)?/": "jun(e)?", "/jul(y)?/": "jul(y)?", "/aug(ust)?/": "aug(ust)?", "/sep(t(ember)?)?/": "sep(t(ember)?)?", "/oct(ober)?/": "oct(ober)?", "/nov(ember)?/": "nov(ember)?", "/dec(ember)?/": "dec(ember)?", "/^su(n(day)?)?/": "^su(n(day)?)?", "/^mo(n(day)?)?/": "^mo(n(day)?)?", "/^tu(e(s(day)?)?)?/": "^tu(e(s(day)?)?)?", "/^we(d(nesday)?)?/": "^we(d(nesday)?)?", "/^th(u(r(s(day)?)?)?)?/": "^th(u(r(s(day)?)?)?)?", "/^fr(i(day)?)?/": "^fr(i(day)?)?", "/^sa(t(urday)?)?/": "^sa(t(urday)?)?", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "fa-IR"; /** * @overview datejs * @version 1.0.0-rc3 * @author Gregory Wild-Smith * @copyright 2015 Gregory Wild-Smith * @license MIT * @homepage https://github.com/abritinthebay/datejs */(function () { var $D = Date; var lang = Date.CultureStrings ? Date.CultureStrings.lang : null; var loggedKeys = {}; // for debug purposes. var getText = { getFromKey: function (key, countryCode) { var output; if (Date.CultureStrings && Date.CultureStrings[countryCode] && Date.CultureStrings[countryCode][key]) { output = Date.CultureStrings[countryCode][key]; } else { output = getText.buildFromDefault(key); } if (key.charAt(0) === "/") { // Assume it's a regex output = getText.buildFromRegex(key, countryCode); } return output; }, getFromObjectValues: function (obj, countryCode) { var key, output = {}; for(key in obj) { if (obj.hasOwnProperty(key)) { output[key] = getText.getFromKey(obj[key], countryCode); } } return output; }, getFromObjectKeys: function (obj, countryCode) { var key, output = {}; for(key in obj) { if (obj.hasOwnProperty(key)) { output[getText.getFromKey(key, countryCode)] = obj[key]; } } return output; }, getFromArray: function (arr, countryCode) { var output = []; for (var i=0; i < arr.length; i++){ if (i in arr) { output[i] = getText.getFromKey(arr[i], countryCode); } } return output; }, buildFromDefault: function (key) { var output, length, split, last; switch(key) { case "name": output = "en-US"; break; case "englishName": output = "English (United States)"; break; case "nativeName": output = "English (United States)"; break; case "twoDigitYearMax": output = 2049; break; case "firstDayOfWeek": output = 0; break; default: output = key; split = key.split("_"); length = split.length; if (length > 1 && key.charAt(0) !== "/") { // if the key isn't a regex and it has a split. last = split[(length - 1)].toLowerCase(); if (last === "initial" || last === "abbr") { output = split[0]; } } break; } return output; }, buildFromRegex: function (key, countryCode) { var output; if (Date.CultureStrings && Date.CultureStrings[countryCode] && Date.CultureStrings[countryCode][key]) { output = new RegExp(Date.CultureStrings[countryCode][key], "i"); } else { output = new RegExp(key.replace(new RegExp("/", "g"),""), "i"); } return output; } }; var shallowMerge = function (obj1, obj2) { for (var attrname in obj2) { if (obj2.hasOwnProperty(attrname)) { obj1[attrname] = obj2[attrname]; } } }; var __ = function (key, language) { var countryCode = (language) ? language : lang; loggedKeys[key] = key; if (typeof key === "object") { if (key instanceof Array) { return getText.getFromArray(key, countryCode); } else { return getText.getFromObjectKeys(key, countryCode); } } else { return getText.getFromKey(key, countryCode); } }; var loadI18nScript = function (code) { // paatterned after jQuery's getScript. var url = Date.Config.i18n + code + ".js"; var head = document.getElementsByTagName("head")[0] || document.documentElement; var script = document.createElement("script"); script.src = url; var completed = false; var events = { done: function (){} // placeholder function }; // Attach handlers for all browsers script.onload = script.onreadystatechange = function() { if ( !completed && (!this.readyState || this.readyState === "loaded" || this.readyState === "complete") ) { events.done(); head.removeChild(script); } }; setTimeout(function() { head.insertBefore(script, head.firstChild); }, 0); // allows return to execute first return { done: function (cb) { events.done = function() { if (cb) { setTimeout(cb,0); } }; } }; }; var buildInfo = { buildFromMethodHash: function (obj) { var key; for(key in obj) { if (obj.hasOwnProperty(key)) { obj[key] = buildInfo[obj[key]](); } } return obj; }, timeZoneDST: function () { var DST = { "CHADT": "+1345", "NZDT": "+1300", "AEDT": "+1100", "ACDT": "+1030", "AZST": "+0500", "IRDT": "+0430", "EEST": "+0300", "CEST": "+0200", "BST": "+0100", "PMDT": "-0200", "ADT": "-0300", "NDT": "-0230", "EDT": "-0400", "CDT": "-0500", "MDT": "-0600", "PDT": "-0700", "AKDT": "-0800", "HADT": "-0900" }; return __(DST); }, timeZoneStandard: function () { var standard = { "LINT": "+1400", "TOT": "+1300", "CHAST": "+1245", "NZST": "+1200", "NFT": "+1130", "SBT": "+1100", "AEST": "+1000", "ACST": "+0930", "JST": "+0900", "CWST": "+0845", "CT": "+0800", "ICT": "+0700", "MMT": "+0630", "BST": "+0600", "NPT": "+0545", "IST": "+0530", "PKT": "+0500", "AFT": "+0430", "MSK": "+0400", "IRST": "+0330", "FET": "+0300", "EET": "+0200", "CET": "+0100", "GMT": "+0000", "UTC": "+0000", "CVT": "-0100", "GST": "-0200", "BRT": "-0300", "NST": "-0330", "AST": "-0400", "EST": "-0500", "CST": "-0600", "MST": "-0700", "PST": "-0800", "AKST": "-0900", "MIT": "-0930", "HST": "-1000", "SST": "-1100", "BIT": "-1200" }; return __(standard); }, timeZones: function (data) { var zone; data.timezones = []; for (zone in data.abbreviatedTimeZoneStandard) { if (data.abbreviatedTimeZoneStandard.hasOwnProperty(zone)) { data.timezones.push({ name: zone, offset: data.abbreviatedTimeZoneStandard[zone]}); } } for (zone in data.abbreviatedTimeZoneDST) { if (data.abbreviatedTimeZoneDST.hasOwnProperty(zone)) { data.timezones.push({ name: zone, offset: data.abbreviatedTimeZoneDST[zone], dst: true}); } } return data.timezones; }, days: function () { return __(["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"]); }, dayAbbr: function () { return __(["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"]); }, dayShortNames: function () { return __(["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"]); }, dayFirstLetters: function () { return __(["S_Sun_Initial", "M_Mon_Initial", "T_Tues_Initial", "W_Wed_Initial", "T_Thu_Initial", "F_Fri_Initial", "S_Sat_Initial"]); }, months: function () { return __(["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"]); }, monthAbbr: function () { return __(["Jan_Abbr", "Feb_Abbr", "Mar_Abbr", "Apr_Abbr", "May_Abbr", "Jun_Abbr", "Jul_Abbr", "Aug_Abbr", "Sep_Abbr", "Oct_Abbr", "Nov_Abbr", "Dec_Abbr"]); }, formatPatterns: function () { return getText.getFromObjectValues({ shortDate: "M/d/yyyy", longDate: "dddd, MMMM dd, yyyy", shortTime: "h:mm tt", longTime: "h:mm:ss tt", fullDateTime: "dddd, MMMM dd, yyyy h:mm:ss tt", sortableDateTime: "yyyy-MM-ddTHH:mm:ss", universalSortableDateTime: "yyyy-MM-dd HH:mm:ssZ", rfc1123: "ddd, dd MMM yyyy HH:mm:ss", monthDay: "MMMM dd", yearMonth: "MMMM, yyyy" }, Date.i18n.currentLanguage()); }, regex: function () { return getText.getFromObjectValues({ inTheMorning: "/( in the )(morn(ing)?)\\b/", thisMorning: "/(this )(morn(ing)?)\\b/", amThisMorning: "/(\b\\d(am)? )(this )(morn(ing)?)/", inTheEvening: "/( in the )(even(ing)?)\\b/", thisEvening: "/(this )(even(ing)?)\\b/", pmThisEvening: "/(\b\\d(pm)? )(this )(even(ing)?)/", jan: "/jan(uary)?/", feb: "/feb(ruary)?/", mar: "/mar(ch)?/", apr: "/apr(il)?/", may: "/may/", jun: "/jun(e)?/", jul: "/jul(y)?/", aug: "/aug(ust)?/", sep: "/sep(t(ember)?)?/", oct: "/oct(ober)?/", nov: "/nov(ember)?/", dec: "/dec(ember)?/", sun: "/^su(n(day)?)?/", mon: "/^mo(n(day)?)?/", tue: "/^tu(e(s(day)?)?)?/", wed: "/^we(d(nesday)?)?/", thu: "/^th(u(r(s(day)?)?)?)?/", fri: "/fr(i(day)?)?/", sat: "/^sa(t(urday)?)?/", future: "/^next/", past: "/^last|past|prev(ious)?/", add: "/^(\\+|aft(er)?|from|hence)/", subtract: "/^(\\-|bef(ore)?|ago)/", yesterday: "/^yes(terday)?/", today: "/^t(od(ay)?)?/", tomorrow: "/^tom(orrow)?/", now: "/^n(ow)?/", millisecond: "/^ms|milli(second)?s?/", second: "/^sec(ond)?s?/", minute: "/^mn|min(ute)?s?/", hour: "/^h(our)?s?/", week: "/^w(eek)?s?/", month: "/^m(onth)?s?/", day: "/^d(ay)?s?/", year: "/^y(ear)?s?/", shortMeridian: "/^(a|p)/", longMeridian: "/^(a\\.?m?\\.?|p\\.?m?\\.?)/", timezone: "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/", ordinalSuffix: "/^\\s*(st|nd|rd|th)/", timeContext: "/^\\s*(\\:|a(?!u|p)|p)/" }, Date.i18n.currentLanguage()); } }; var CultureInfo = function () { var info = getText.getFromObjectValues({ name: "name", englishName: "englishName", nativeName: "nativeName", amDesignator: "AM", pmDesignator: "PM", firstDayOfWeek: "firstDayOfWeek", twoDigitYearMax: "twoDigitYearMax", dateElementOrder: "mdy" }, Date.i18n.currentLanguage()); var constructedInfo = buildInfo.buildFromMethodHash({ dayNames: "days", abbreviatedDayNames: "dayAbbr", shortestDayNames: "dayShortNames", firstLetterDayNames: "dayFirstLetters", monthNames: "months", abbreviatedMonthNames: "monthAbbr", formatPatterns: "formatPatterns", regexPatterns: "regex", abbreviatedTimeZoneDST: "timeZoneDST", abbreviatedTimeZoneStandard: "timeZoneStandard" }); shallowMerge(info, constructedInfo); buildInfo.timeZones(info); return info; }; $D.i18n = { __: function (key, lang) { return __(key, lang); }, currentLanguage: function () { return lang || "en-US"; }, setLanguage: function (code, force, cb) { var async = false; if (force || code === "en-US" || (!!Date.CultureStrings && !!Date.CultureStrings[code])) { lang = code; Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings.lang = code; Date.CultureInfo = new CultureInfo(); } else { if (!(!!Date.CultureStrings && !!Date.CultureStrings[code])) { if (typeof exports !== "undefined" && this.exports !== exports) { // we're in a Node enviroment, load it using require try { require("../i18n/" + code + ".js"); lang = code; Date.CultureStrings.lang = code; Date.CultureInfo = new CultureInfo(); } catch (e) { // var str = "The language for '" + code + "' could not be loaded by Node. It likely does not exist."; throw new Error("The DateJS IETF language tag '" + code + "' could not be loaded by Node. It likely does not exist."); } } else if (Date.Config && Date.Config.i18n) { // we know the location of the files, so lets load them async = true; loadI18nScript(code).done(function(){ lang = code; Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings.lang = code; Date.CultureInfo = new CultureInfo(); $D.Parsing.Normalizer.buildReplaceData(); // because this is async if ($D.Grammar) { $D.Grammar.buildGrammarFormats(); // so we can parse those strings... } if (cb) { setTimeout(cb,0); } }); } else { Date.console.error("The DateJS IETF language tag '" + code + "' is not available and has not been loaded."); return false; } } } $D.Parsing.Normalizer.buildReplaceData(); // rebuild normalizer strings if ($D.Grammar) { $D.Grammar.buildGrammarFormats(); // so we can parse those strings... } if (!async && cb) { setTimeout(cb,0); } }, getLoggedKeys: function () { return loggedKeys; }, updateCultureInfo: function () { Date.CultureInfo = new CultureInfo(); } }; $D.i18n.updateCultureInfo(); // run automatically }()); (function () { var $D = Date, $P = $D.prototype, p = function (s, l) { if (!l) { l = 2; } return ("000" + s).slice(l * -1); }; if (typeof window !== "undefined" && typeof window.console !== "undefined" && typeof window.console.log !== "undefined") { $D.console = console; // used only to raise non-critical errors if available } else { // set mock so we don't give errors. $D.console = { log: function(){}, error: function(){} }; } $D.Config = $D.Config || {}; $D.initOverloads = function() { /** * Overload of Date.now. Allows an alternate call for Date.now where it returns the * current Date as an object rather than just milliseconds since the Unix Epoch. * * Also provides an implementation of now() for browsers (IE<9) that don't have it. * * Backwards compatible so with work with either: * Date.now() [returns ms] * or * Date.now(true) [returns Date] */ if (!$D.now) { $D._now = function now() { return new Date().getTime(); }; } else if (!$D._now) { $D._now = $D.now; } $D.now = function (returnObj) { if (returnObj) { return $D.present(); } else { return $D._now(); } }; if ( !$P.toISOString ) { $P.toISOString = function() { return this.getUTCFullYear() + "-" + p(this.getUTCMonth() + 1) + "-" + p(this.getUTCDate()) + "T" + p(this.getUTCHours()) + ":" + p(this.getUTCMinutes()) + ":" + p(this.getUTCSeconds()) + "." + String( (this.getUTCMilliseconds()/1000).toFixed(3)).slice(2, 5) + "Z"; }; } // private if ( $P._toString === undefined ){ $P._toString = $P.toString; } }; $D.initOverloads(); /** * Gets a date that is set to the current date. The time is set to the start of the day (00:00 or 12:00 AM). * @return {Date} The current date. */ $D.today = function () { return new Date().clearTime(); }; /** * Gets a date that is set to the current date and time (same as new Date, but chainable) * @return {Date} The current date. */ $D.present = function () { return new Date(); }; /** * Compares the first date to the second date and returns an number indication of their relative values. * @param {Date} First Date object to compare [Required]. * @param {Date} Second Date object to compare to [Required]. * @return {Number} -1 = date1 is lessthan date2. 0 = values are equal. 1 = date1 is greaterthan date2. */ $D.compare = function (date1, date2) { if (isNaN(date1) || isNaN(date2)) { throw new Error(date1 + " - " + date2); } else if (date1 instanceof Date && date2 instanceof Date) { return (date1 < date2) ? -1 : (date1 > date2) ? 1 : 0; } else { throw new TypeError(date1 + " - " + date2); } }; /** * Compares the first Date object to the second Date object and returns true if they are equal. * @param {Date} First Date object to compare [Required] * @param {Date} Second Date object to compare to [Required] * @return {Boolean} true if dates are equal. false if they are not equal. */ $D.equals = function (date1, date2) { return (date1.compareTo(date2) === 0); }; /** * Gets the language appropriate day name when given the day number(0-6) * eg - 0 == Sunday * @return {String} The day name */ $D.getDayName = function (n) { return Date.CultureInfo.dayNames[n]; }; /** * Gets the day number (0-6) if given a CultureInfo specific string which is a valid dayName, abbreviatedDayName or shortestDayName (two char). * @param {String} The name of the day (eg. "Monday, "Mon", "tuesday", "tue", "We", "we"). * @return {Number} The day number */ $D.getDayNumberFromName = function (name) { var n = Date.CultureInfo.dayNames, m = Date.CultureInfo.abbreviatedDayNames, o = Date.CultureInfo.shortestDayNames, s = name.toLowerCase(); for (var i = 0; i < n.length; i++) { if (n[i].toLowerCase() === s || m[i].toLowerCase() === s || o[i].toLowerCase() === s) { return i; } } return -1; }; /** * Gets the month number (0-11) if given a Culture Info specific string which is a valid monthName or abbreviatedMonthName. * @param {String} The name of the month (eg. "February, "Feb", "october", "oct"). * @return {Number} The day number */ $D.getMonthNumberFromName = function (name) { var n = Date.CultureInfo.monthNames, m = Date.CultureInfo.abbreviatedMonthNames, s = name.toLowerCase(); for (var i = 0; i < n.length; i++) { if (n[i].toLowerCase() === s || m[i].toLowerCase() === s) { return i; } } return -1; }; /** * Gets the language appropriate month name when given the month number(0-11) * eg - 0 == January * @return {String} The month name */ $D.getMonthName = function (n) { return Date.CultureInfo.monthNames[n]; }; /** * Determines if the current date instance is within a LeapYear. * @param {Number} The year. * @return {Boolean} true if date is within a LeapYear, otherwise false. */ $D.isLeapYear = function (year) { return ((year % 4 === 0 && year % 100 !== 0) || year % 400 === 0); }; /** * Gets the number of days in the month, given a year and month value. Automatically corrects for LeapYear. * @param {Number} The year. * @param {Number} The month (0-11). * @return {Number} The number of days in the month. */ $D.getDaysInMonth = function (year, month) { if (!month && $D.validateMonth(year)) { month = year; year = Date.today().getFullYear(); } return [31, ($D.isLeapYear(year) ? 29 : 28), 31, 30, 31, 30, 31, 31, 30, 31, 30, 31][month]; }; $P.getDaysInMonth = function () { return $D.getDaysInMonth(this.getFullYear(), this.getMonth()); }; $D.getTimezoneAbbreviation = function (offset, dst) { var p, n = (dst || false) ? Date.CultureInfo.abbreviatedTimeZoneDST : Date.CultureInfo.abbreviatedTimeZoneStandard; for (p in n) { if (n.hasOwnProperty(p)) { if (n[p] === offset) { return p; } } } return null; }; $D.getTimezoneOffset = function (name, dst) { var i, a =[], z = Date.CultureInfo.timezones; if (!name) { name = (new Date()).getTimezone();} for (i = 0; i < z.length; i++) { if (z[i].name === name.toUpperCase()) { a.push(i); } } if (!z[a[0]]) { return null; } if (a.length === 1 || !dst) { return z[a[0]].offset; } else { for (i=0; i < a.length; i++) { if (z[a[i]].dst) { return z[a[i]].offset; } } } }; $D.getQuarter = function (d) { d = d || new Date(); // If no date supplied, use today var q = [1,2,3,4]; return q[Math.floor(d.getMonth() / 3)]; // ~~~ is a bitwise op. Faster than Math.floor }; $D.getDaysLeftInQuarter = function (d) { d = d || new Date(); var qEnd = new Date(d); qEnd.setMonth(qEnd.getMonth() + 3 - qEnd.getMonth() % 3, 0); return Math.floor((qEnd - d) / 8.64e7); }; // private var validate = function (n, min, max, name) { name = name ? name : "Object"; if (typeof n === "undefined") { return false; } else if (typeof n !== "number") { throw new TypeError(n + " is not a Number."); } else if (n < min || n > max) { // As failing validation is *not* an exceptional circumstance // lets not throw a RangeError Exception here. // It's semantically correct but it's not sensible. return false; } return true; }; /** * Validates the number is within an acceptable range for milliseconds [0-999]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateMillisecond = function (value) { return validate(value, 0, 999, "millisecond"); }; /** * Validates the number is within an acceptable range for seconds [0-59]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateSecond = function (value) { return validate(value, 0, 59, "second"); }; /** * Validates the number is within an acceptable range for minutes [0-59]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateMinute = function (value) { return validate(value, 0, 59, "minute"); }; /** * Validates the number is within an acceptable range for hours [0-23]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateHour = function (value) { return validate(value, 0, 23, "hour"); }; /** * Validates the number is within an acceptable range for the days in a month [0-MaxDaysInMonth]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateDay = function (value, year, month) { if (year === undefined || year === null || month === undefined || month === null) { return false;} return validate(value, 1, $D.getDaysInMonth(year, month), "day"); }; /** * Validates the number is within an acceptable range for months [0-11]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateWeek = function (value) { return validate(value, 0, 53, "week"); }; /** * Validates the number is within an acceptable range for months [0-11]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateMonth = function (value) { return validate(value, 0, 11, "month"); }; /** * Validates the number is within an acceptable range for years. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateYear = function (value) { /** * Per ECMAScript spec the range of times supported by Date objects is * exactly -100,000,000 days to +100,000,000 days measured relative to * midnight at the beginning of 01 January, 1970 UTC. * This gives a range of 8,640,000,000,000,000 milliseconds to either * side of 01 January, 1970 UTC. * * Earliest possible date: Tue, 20 Apr 271,822 B.C. 00:00:00 UTC * Latest possible date: Sat, 13 Sep 275,760 00:00:00 UTC */ return validate(value, -271822, 275760, "year"); }; $D.validateTimezone = function(value) { var timezones = {"ACDT":1,"ACST":1,"ACT":1,"ADT":1,"AEDT":1,"AEST":1,"AFT":1,"AKDT":1,"AKST":1,"AMST":1,"AMT":1,"ART":1,"AST":1,"AWDT":1,"AWST":1,"AZOST":1,"AZT":1,"BDT":1,"BIOT":1,"BIT":1,"BOT":1,"BRT":1,"BST":1,"BTT":1,"CAT":1,"CCT":1,"CDT":1,"CEDT":1,"CEST":1,"CET":1,"CHADT":1,"CHAST":1,"CHOT":1,"ChST":1,"CHUT":1,"CIST":1,"CIT":1,"CKT":1,"CLST":1,"CLT":1,"COST":1,"COT":1,"CST":1,"CT":1,"CVT":1,"CWST":1,"CXT":1,"DAVT":1,"DDUT":1,"DFT":1,"EASST":1,"EAST":1,"EAT":1,"ECT":1,"EDT":1,"EEDT":1,"EEST":1,"EET":1,"EGST":1,"EGT":1,"EIT":1,"EST":1,"FET":1,"FJT":1,"FKST":1,"FKT":1,"FNT":1,"GALT":1,"GAMT":1,"GET":1,"GFT":1,"GILT":1,"GIT":1,"GMT":1,"GST":1,"GYT":1,"HADT":1,"HAEC":1,"HAST":1,"HKT":1,"HMT":1,"HOVT":1,"HST":1,"ICT":1,"IDT":1,"IOT":1,"IRDT":1,"IRKT":1,"IRST":1,"IST":1,"JST":1,"KGT":1,"KOST":1,"KRAT":1,"KST":1,"LHST":1,"LINT":1,"MAGT":1,"MART":1,"MAWT":1,"MDT":1,"MET":1,"MEST":1,"MHT":1,"MIST":1,"MIT":1,"MMT":1,"MSK":1,"MST":1,"MUT":1,"MVT":1,"MYT":1,"NCT":1,"NDT":1,"NFT":1,"NPT":1,"NST":1,"NT":1,"NUT":1,"NZDT":1,"NZST":1,"OMST":1,"ORAT":1,"PDT":1,"PET":1,"PETT":1,"PGT":1,"PHOT":1,"PHT":1,"PKT":1,"PMDT":1,"PMST":1,"PONT":1,"PST":1,"PYST":1,"PYT":1,"RET":1,"ROTT":1,"SAKT":1,"SAMT":1,"SAST":1,"SBT":1,"SCT":1,"SGT":1,"SLST":1,"SRT":1,"SST":1,"SYOT":1,"TAHT":1,"THA":1,"TFT":1,"TJT":1,"TKT":1,"TLT":1,"TMT":1,"TOT":1,"TVT":1,"UCT":1,"ULAT":1,"UTC":1,"UYST":1,"UYT":1,"UZT":1,"VET":1,"VLAT":1,"VOLT":1,"VOST":1,"VUT":1,"WAKT":1,"WAST":1,"WAT":1,"WEDT":1,"WEST":1,"WET":1,"WST":1,"YAKT":1,"YEKT":1,"Z":1}; return (timezones[value] === 1); }; $D.validateTimezoneOffset= function(value) { // timezones go from +14hrs to -12hrs, the +X hours are negative offsets. return (value > -841 && value < 721); }; }()); (function () { var $D = Date, $P = $D.prototype, p = function (s, l) { if (!l) { l = 2; } return ("000" + s).slice(l * -1); }; var validateConfigObject = function (obj) { var result = {}, self = this, prop, testFunc; testFunc = function (prop, func, value) { if (prop === "day") { var month = (obj.month !== undefined) ? obj.month : self.getMonth(); var year = (obj.year !== undefined) ? obj.year : self.getFullYear(); return $D[func](value, year, month); } else { return $D[func](value); } }; for (prop in obj) { if (Object.prototype.hasOwnProperty.call(obj, prop)) { var func = "validate" + prop.charAt(0).toUpperCase() + prop.slice(1); if ($D[func] && obj[prop] !== null && testFunc(prop, func, obj[prop])) { result[prop] = obj[prop]; } } } return result; }; /** * Resets the time of this Date object to 12:00 AM (00:00), which is the start of the day. * @param {Boolean} .clone() this date instance before clearing Time * @return {Date} this */ $P.clearTime = function () { this.setHours(0); this.setMinutes(0); this.setSeconds(0); this.setMilliseconds(0); return this; }; /** * Resets the time of this Date object to the current time ('now'). * @return {Date} this */ $P.setTimeToNow = function () { var n = new Date(); this.setHours(n.getHours()); this.setMinutes(n.getMinutes()); this.setSeconds(n.getSeconds()); this.setMilliseconds(n.getMilliseconds()); return this; }; /** * Returns a new Date object that is an exact date and time copy of the original instance. * @return {Date} A new Date instance */ $P.clone = function () { return new Date(this.getTime()); }; /** * Compares this instance to a Date object and returns an number indication of their relative values. * @param {Date} Date object to compare [Required] * @return {Number} -1 = this is lessthan date. 0 = values are equal. 1 = this is greaterthan date. */ $P.compareTo = function (date) { return Date.compare(this, date); }; /** * Compares this instance to another Date object and returns true if they are equal. * @param {Date} Date object to compare. If no date to compare, new Date() [now] is used. * @return {Boolean} true if dates are equal. false if they are not equal. */ $P.equals = function (date) { return Date.equals(this, (date !== undefined ? date : new Date())); }; /** * Determines if this instance is between a range of two dates or equal to either the start or end dates. * @param {Date} Start of range [Required] * @param {Date} End of range [Required] * @return {Boolean} true is this is between or equal to the start and end dates, else false */ $P.between = function (start, end) { return this.getTime() >= start.getTime() && this.getTime() <= end.getTime(); }; /** * Determines if this date occurs after the date to compare to. * @param {Date} Date object to compare. If no date to compare, new Date() ("now") is used. * @return {Boolean} true if this date instance is greater than the date to compare to (or "now"), otherwise false. */ $P.isAfter = function (date) { return this.compareTo(date || new Date()) === 1; }; /** * Determines if this date occurs before the date to compare to. * @param {Date} Date object to compare. If no date to compare, new Date() ("now") is used. * @return {Boolean} true if this date instance is less than the date to compare to (or "now"). */ $P.isBefore = function (date) { return (this.compareTo(date || new Date()) === -1); }; /** * Determines if the current Date instance occurs today. * @return {Boolean} true if this date instance is 'today', otherwise false. */ /** * Determines if the current Date instance occurs on the same Date as the supplied 'date'. * If no 'date' to compare to is provided, the current Date instance is compared to 'today'. * @param {date} Date object to compare. If no date to compare, the current Date ("now") is used. * @return {Boolean} true if this Date instance occurs on the same Day as the supplied 'date'. */ $P.isToday = $P.isSameDay = function (date) { return this.clone().clearTime().equals((date || new Date()).clone().clearTime()); }; /** * Adds the specified number of milliseconds to this instance. * @param {Number} The number of milliseconds to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addMilliseconds = function (value) { if (!value) { return this; } this.setTime(this.getTime() + value * 1); return this; }; /** * Adds the specified number of seconds to this instance. * @param {Number} The number of seconds to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addSeconds = function (value) { if (!value) { return this; } return this.addMilliseconds(value * 1000); }; /** * Adds the specified number of seconds to this instance. * @param {Number} The number of seconds to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addMinutes = function (value) { if (!value) { return this; } return this.addMilliseconds(value * 60000); // 60*1000 }; /** * Adds the specified number of hours to this instance. * @param {Number} The number of hours to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addHours = function (value) { if (!value) { return this; } return this.addMilliseconds(value * 3600000); // 60*60*1000 }; /** * Adds the specified number of days to this instance. * @param {Number} The number of days to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addDays = function (value) { if (!value) { return this; } this.setDate(this.getDate() + value * 1); return this; }; /** * Adds the specified number of weekdays (ie - not sat or sun) to this instance. * @param {Number} The number of days to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addWeekdays = function (value) { if (!value) { return this; } var day = this.getDay(); var weeks = (Math.ceil(Math.abs(value)/7)); if (day === 0 || day === 6) { if (value > 0) { this.next().monday(); this.addDays(-1); day = this.getDay(); } } if (value < 0) { while (value < 0) { this.addDays(-1); day = this.getDay(); if (day !== 0 && day !== 6) { value++; } } return this; } else if (value > 5 || (6-day) <= value) { value = value + (weeks * 2); } return this.addDays(value); }; /** * Adds the specified number of weeks to this instance. * @param {Number} The number of weeks to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addWeeks = function (value) { if (!value) { return this; } return this.addDays(value * 7); }; /** * Adds the specified number of months to this instance. * @param {Number} The number of months to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addMonths = function (value) { if (!value) { return this; } var n = this.getDate(); this.setDate(1); this.setMonth(this.getMonth() + value * 1); this.setDate(Math.min(n, $D.getDaysInMonth(this.getFullYear(), this.getMonth()))); return this; }; $P.addQuarters = function (value) { if (!value) { return this; } // note this will take you to the same point in the quarter as you are now. // i.e. - if you are 15 days into the quarter you'll be 15 days into the resulting one. // bonus: this allows adding fractional quarters return this.addMonths(value * 3); }; /** * Adds the specified number of years to this instance. * @param {Number} The number of years to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addYears = function (value) { if (!value) { return this; } return this.addMonths(value * 12); }; /** * Adds (or subtracts) to the value of the years, months, weeks, days, hours, minutes, seconds, milliseconds of the date instance using given configuration object. Positive and Negative values allowed. * Example

	Date.today().add( { days: 1, months: 1 } )

	new Date().add( { years: -1 } )
	
* @param {Object} Configuration object containing attributes (months, days, etc.) * @return {Date} this */ $P.add = function (config) { if (typeof config === "number") { this._orient = config; return this; } var x = config; if (x.day) { // If we should be a different date than today (eg: for 'tomorrow -1d', etc). // Should only effect parsing, not direct usage (eg, Finish and FinishExact) if ((x.day - this.getDate()) !== 0) { this.setDate(x.day); } } if (x.milliseconds) { this.addMilliseconds(x.milliseconds); } if (x.seconds) { this.addSeconds(x.seconds); } if (x.minutes) { this.addMinutes(x.minutes); } if (x.hours) { this.addHours(x.hours); } if (x.weeks) { this.addWeeks(x.weeks); } if (x.months) { this.addMonths(x.months); } if (x.years) { this.addYears(x.years); } if (x.days) { this.addDays(x.days); } return this; }; /** * Get the week number. Week one (1) is the week which contains the first Thursday of the year. Monday is considered the first day of the week. * The .getWeek() function does NOT convert the date to UTC. The local datetime is used. * Please use .getISOWeek() to get the week of the UTC converted date. * @return {Number} 1 to 53 */ $P.getWeek = function (utc) { // Create a copy of this date object var self, target = new Date(this.valueOf()); if (utc) { target.addMinutes(target.getTimezoneOffset()); self = target.clone(); } else { self = this; } // ISO week date weeks start on monday // so correct the day number var dayNr = (self.getDay() + 6) % 7; // ISO 8601 states that week 1 is the week // with the first thursday of that year. // Set the target date to the thursday in the target week target.setDate(target.getDate() - dayNr + 3); // Store the millisecond value of the target date var firstThursday = target.valueOf(); // Set the target to the first thursday of the year // First set the target to january first target.setMonth(0, 1); // Not a thursday? Correct the date to the next thursday if (target.getDay() !== 4) { target.setMonth(0, 1 + ((4 - target.getDay()) + 7) % 7); } // The weeknumber is the number of weeks between the // first thursday of the year and the thursday in the target week return 1 + Math.ceil((firstThursday - target) / 604800000); // 604800000 = 7 * 24 * 3600 * 1000 }; /** * Get the ISO 8601 week number. Week one ("01") is the week which contains the first Thursday of the year. Monday is considered the first day of the week. * The .getISOWeek() function does convert the date to it's UTC value. Please use .getWeek() to get the week of the local date. * @return {String} "01" to "53" */ $P.getISOWeek = function () { return p(this.getWeek(true)); }; /** * Moves the date to Monday of the week set. Week one (1) is the week which contains the first Thursday of the year. * @param {Number} A Number (1 to 53) that represents the week of the year. * @return {Date} this */ $P.setWeek = function (n) { if ((n - this.getWeek()) === 0) { if (this.getDay() !== 1) { return this.moveToDayOfWeek(1, (this.getDay() > 1 ? -1 : 1)); } else { return this; } } else { return this.moveToDayOfWeek(1, (this.getDay() > 1 ? -1 : 1)).addWeeks(n - this.getWeek()); } }; $P.setQuarter = function (qtr) { var month = Math.abs(((qtr-1) * 3) + 1); return this.setMonth(month, 1); }; $P.getQuarter = function () { return Date.getQuarter(this); }; $P.getDaysLeftInQuarter = function () { return Date.getDaysLeftInQuarter(this); }; /** * Moves the date to the next n'th occurrence of the dayOfWeek starting from the beginning of the month. The number (-1) is a magic number and will return the last occurrence of the dayOfWeek in the month. * @param {Number} The dayOfWeek to move to * @param {Number} The n'th occurrence to move to. Use (-1) to return the last occurrence in the month * @return {Date} this */ $P.moveToNthOccurrence = function (dayOfWeek, occurrence) { if (dayOfWeek === "Weekday") { if (occurrence > 0) { this.moveToFirstDayOfMonth(); if (this.is().weekday()) { occurrence -= 1; } } else if (occurrence < 0) { this.moveToLastDayOfMonth(); if (this.is().weekday()) { occurrence += 1; } } else { return this; } return this.addWeekdays(occurrence); } var shift = 0; if (occurrence > 0) { shift = occurrence - 1; } else if (occurrence === -1) { this.moveToLastDayOfMonth(); if (this.getDay() !== dayOfWeek) { this.moveToDayOfWeek(dayOfWeek, -1); } return this; } return this.moveToFirstDayOfMonth().addDays(-1).moveToDayOfWeek(dayOfWeek, +1).addWeeks(shift); }; var moveToN = function (getFunc, addFunc, nVal) { return function (value, orient) { var diff = (value - this[getFunc]() + nVal * (orient || +1)) % nVal; return this[addFunc]((diff === 0) ? diff += nVal * (orient || +1) : diff); }; }; /** * Move to the next or last dayOfWeek based on the orient value. * @param {Number} The dayOfWeek to move to * @param {Number} Forward (+1) or Back (-1). Defaults to +1. [Optional] * @return {Date} this */ $P.moveToDayOfWeek = moveToN("getDay", "addDays", 7); /** * Move to the next or last month based on the orient value. * @param {Number} The month to move to. 0 = January, 11 = December * @param {Number} Forward (+1) or Back (-1). Defaults to +1. [Optional] * @return {Date} this */ $P.moveToMonth = moveToN("getMonth", "addMonths", 12); /** * Get the Ordinate of the current day ("th", "st", "rd"). * @return {String} */ $P.getOrdinate = function () { var num = this.getDate(); return ord(num); }; /** * Get the Ordinal day (numeric day number) of the year, adjusted for leap year. * @return {Number} 1 through 365 (366 in leap years) */ $P.getOrdinalNumber = function () { return Math.ceil((this.clone().clearTime() - new Date(this.getFullYear(), 0, 1)) / 86400000) + 1; }; /** * Get the time zone abbreviation of the current date. * @return {String} The abbreviated time zone name (e.g. "EST") */ $P.getTimezone = function () { return $D.getTimezoneAbbreviation(this.getUTCOffset(), this.isDaylightSavingTime()); }; $P.setTimezoneOffset = function (offset) { var here = this.getTimezoneOffset(), there = Number(offset) * -6 / 10; return (there || there === 0) ? this.addMinutes(there - here) : this; }; $P.setTimezone = function (offset) { return this.setTimezoneOffset($D.getTimezoneOffset(offset)); }; /** * Indicates whether Daylight Saving Time is observed in the current time zone. * @return {Boolean} true|false */ $P.hasDaylightSavingTime = function () { return (Date.today().set({month: 0, day: 1}).getTimezoneOffset() !== Date.today().set({month: 6, day: 1}).getTimezoneOffset()); }; /** * Indicates whether this Date instance is within the Daylight Saving Time range for the current time zone. * @return {Boolean} true|false */ $P.isDaylightSavingTime = function () { return Date.today().set({month: 0, day: 1}).getTimezoneOffset() !== this.getTimezoneOffset(); }; /** * Get the offset from UTC of the current date. * @return {String} The 4-character offset string prefixed with + or - (e.g. "-0500") */ $P.getUTCOffset = function (offset) { var n = (offset || this.getTimezoneOffset()) * -10 / 6, r; if (n < 0) { r = (n - 10000).toString(); return r.charAt(0) + r.substr(2); } else { r = (n + 10000).toString(); return "+" + r.substr(1); } }; /** * Returns the number of milliseconds between this date and date. * @param {Date} Defaults to now * @return {Number} The diff in milliseconds */ $P.getElapsed = function (date) { return (date || new Date()) - this; }; /** * Set the value of year, month, day, hour, minute, second, millisecond of date instance using given configuration object. * Example

	Date.today().set( { day: 20, month: 1 } )

	new Date().set( { millisecond: 0 } )
	
* * @param {Object} Configuration object containing attributes (month, day, etc.) * @return {Date} this */ $P.set = function (config) { config = validateConfigObject.call(this, config); var key; for (key in config) { if (Object.prototype.hasOwnProperty.call(config, key)) { var name = key.charAt(0).toUpperCase() + key.slice(1); var addFunc, getFunc; if (key !== "week" && key !== "month" && key !== "timezone" && key !== "timezoneOffset") { name += "s"; } addFunc = "add" + name; getFunc = "get" + name; if (key === "month") { addFunc = addFunc + "s"; } else if (key === "year"){ getFunc = "getFullYear"; } if (key !== "day" && key !== "timezone" && key !== "timezoneOffset" && key !== "week" && key !== "hour") { this[addFunc](config[key] - this[getFunc]()); } else if ( key === "timezone"|| key === "timezoneOffset" || key === "week" || key === "hour") { this["set"+name](config[key]); } } } // day has to go last because you can't validate the day without first knowing the month if (config.day) { this.addDays(config.day - this.getDate()); } return this; }; /** * Moves the date to the first day of the month. * @return {Date} this */ $P.moveToFirstDayOfMonth = function () { return this.set({ day: 1 }); }; /** * Moves the date to the last day of the month. * @return {Date} this */ $P.moveToLastDayOfMonth = function () { return this.set({ day: $D.getDaysInMonth(this.getFullYear(), this.getMonth())}); }; /** * Converts the value of the current Date object to its equivalent string representation. * Format Specifiers * CUSTOM DATE AND TIME FORMAT STRINGS * Format Description Example * ------ --------------------------------------------------------------------------- ----------------------- * s The seconds of the minute between 0-59. "0" to "59" * ss The seconds of the minute with leading zero if required. "00" to "59" * * m The minute of the hour between 0-59. "0" or "59" * mm The minute of the hour with leading zero if required. "00" or "59" * * h The hour of the day between 1-12. "1" to "12" * hh The hour of the day with leading zero if required. "01" to "12" * * H The hour of the day between 0-23. "0" to "23" * HH The hour of the day with leading zero if required. "00" to "23" * * d The day of the month between 1 and 31. "1" to "31" * dd The day of the month with leading zero if required. "01" to "31" * ddd Abbreviated day name. Date.CultureInfo.abbreviatedDayNames. "Mon" to "Sun" * dddd The full day name. Date.CultureInfo.dayNames. "Monday" to "Sunday" * * M The month of the year between 1-12. "1" to "12" * MM The month of the year with leading zero if required. "01" to "12" * MMM Abbreviated month name. Date.CultureInfo.abbreviatedMonthNames. "Jan" to "Dec" * MMMM The full month name. Date.CultureInfo.monthNames. "January" to "December" * * yy The year as a two-digit number. "99" or "08" * yyyy The full four digit year. "1999" or "2008" * * t Displays the first character of the A.M./P.M. designator. "A" or "P" * Date.CultureInfo.amDesignator or Date.CultureInfo.pmDesignator * tt Displays the A.M./P.M. designator. "AM" or "PM" * Date.CultureInfo.amDesignator or Date.CultureInfo.pmDesignator * * S The ordinal suffix ("st, "nd", "rd" or "th") of the current day. "st, "nd", "rd" or "th" * * STANDARD DATE AND TIME FORMAT STRINGS * Format Description Example *------ --------------------------------------------------------------------------- ----------------------- * d The CultureInfo shortDate Format Pattern "M/d/yyyy" * D The CultureInfo longDate Format Pattern "dddd, MMMM dd, yyyy" * F The CultureInfo fullDateTime Format Pattern "dddd, MMMM dd, yyyy h:mm:ss tt" * m The CultureInfo monthDay Format Pattern "MMMM dd" * r The CultureInfo rfc1123 Format Pattern "ddd, dd MMM yyyy HH:mm:ss GMT" * s The CultureInfo sortableDateTime Format Pattern "yyyy-MM-ddTHH:mm:ss" * t The CultureInfo shortTime Format Pattern "h:mm tt" * T The CultureInfo longTime Format Pattern "h:mm:ss tt" * u The CultureInfo universalSortableDateTime Format Pattern "yyyy-MM-dd HH:mm:ssZ" * y The CultureInfo yearMonth Format Pattern "MMMM, yyyy" * * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @return {String} A string representation of the current Date object. */ var ord = function (n) { switch (n * 1) { case 1: case 21: case 31: return "st"; case 2: case 22: return "nd"; case 3: case 23: return "rd"; default: return "th"; } }; var parseStandardFormats = function (format) { var y, c = Date.CultureInfo.formatPatterns; switch (format) { case "d": return this.toString(c.shortDate); case "D": return this.toString(c.longDate); case "F": return this.toString(c.fullDateTime); case "m": return this.toString(c.monthDay); case "r": case "R": y = this.clone().addMinutes(this.getTimezoneOffset()); return y.toString(c.rfc1123) + " GMT"; case "s": return this.toString(c.sortableDateTime); case "t": return this.toString(c.shortTime); case "T": return this.toString(c.longTime); case "u": y = this.clone().addMinutes(this.getTimezoneOffset()); return y.toString(c.universalSortableDateTime); case "y": return this.toString(c.yearMonth); default: return false; } }; var parseFormatStringsClosure = function (context) { return function (m) { if (m.charAt(0) === "\\") { return m.replace("\\", ""); } switch (m) { case "hh": return p(context.getHours() < 13 ? (context.getHours() === 0 ? 12 : context.getHours()) : (context.getHours() - 12)); case "h": return context.getHours() < 13 ? (context.getHours() === 0 ? 12 : context.getHours()) : (context.getHours() - 12); case "HH": return p(context.getHours()); case "H": return context.getHours(); case "mm": return p(context.getMinutes()); case "m": return context.getMinutes(); case "ss": return p(context.getSeconds()); case "s": return context.getSeconds(); case "yyyy": return p(context.getFullYear(), 4); case "yy": return p(context.getFullYear()); case "y": return context.getFullYear(); case "E": case "dddd": return Date.CultureInfo.dayNames[context.getDay()]; case "ddd": return Date.CultureInfo.abbreviatedDayNames[context.getDay()]; case "dd": return p(context.getDate()); case "d": return context.getDate(); case "MMMM": return Date.CultureInfo.monthNames[context.getMonth()]; case "MMM": return Date.CultureInfo.abbreviatedMonthNames[context.getMonth()]; case "MM": return p((context.getMonth() + 1)); case "M": return context.getMonth() + 1; case "t": return context.getHours() < 12 ? Date.CultureInfo.amDesignator.substring(0, 1) : Date.CultureInfo.pmDesignator.substring(0, 1); case "tt": return context.getHours() < 12 ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator; case "S": return ord(context.getDate()); case "W": return context.getWeek(); case "WW": return context.getISOWeek(); case "Q": return "Q" + context.getQuarter(); case "q": return String(context.getQuarter()); case "z": return context.getTimezone(); case "Z": case "X": return Date.getTimezoneOffset(context.getTimezone()); case "ZZ": // Timezone offset in seconds return context.getTimezoneOffset() * -60; case "u": return context.getDay(); case "L": return ($D.isLeapYear(context.getFullYear())) ? 1 : 0; case "B": // Swatch Internet Time (.beats) return "@"+((context.getUTCSeconds() + (context.getUTCMinutes()*60) + ((context.getUTCHours()+1)*3600))/86.4); default: return m; } }; }; $P.toString = function (format, ignoreStandards) { // Standard Date and Time Format Strings. Formats pulled from CultureInfo file and // may vary by culture. if (!ignoreStandards && format && format.length === 1) { output = parseStandardFormats.call(this, format); if (output) { return output; } } var parseFormatStrings = parseFormatStringsClosure(this); return format ? format.replace(/((\\)?(dd?d?d?|MM?M?M?|yy?y?y?|hh?|HH?|mm?|ss?|tt?|S|q|Q|WW?W?W?)(?![^\[]*\]))/g, parseFormatStrings).replace(/\[|\]/g, "") : this._toString(); }; }()); /************************************************************* * SugarPak - Domain Specific Language - Syntactical Sugar * *************************************************************/ (function () { var $D = Date, $P = $D.prototype, $N = Number.prototype; // private $P._orient = +1; // private $P._nth = null; // private $P._is = false; // private $P._same = false; // private $P._isSecond = false; // private $N._dateElement = "days"; /** * Moves the date to the next instance of a date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.today().next().friday();
	Date.today().next().fri();
	Date.today().next().march();
	Date.today().next().mar();
	Date.today().next().week();
	
* * @return {Date} date */ $P.next = function () { this._move = true; this._orient = +1; return this; }; /** * Creates a new Date (Date.today()) and moves the date to the next instance of the date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.next().friday();
	Date.next().fri();
	Date.next().march();
	Date.next().mar();
	Date.next().week();
	
* * @return {Date} date */ $D.next = function () { return $D.today().next(); }; /** * Moves the date to the previous instance of a date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.today().last().friday();
	Date.today().last().fri();
	Date.today().last().march();
	Date.today().last().mar();
	Date.today().last().week();
	
* * @return {Date} date */ $P.last = $P.prev = $P.previous = function () { this._move = true; this._orient = -1; return this; }; /** * Creates a new Date (Date.today()) and moves the date to the previous instance of the date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.last().friday();
	Date.last().fri();
	Date.previous().march();
	Date.prev().mar();
	Date.last().week();
	
* * @return {Date} date */ $D.last = $D.prev = $D.previous = function () { return $D.today().last(); }; /** * Performs a equality check when followed by either a month name, day name or .weekday() function. * Example

	Date.today().is().friday(); // true|false
	Date.today().is().fri();
	Date.today().is().march();
	Date.today().is().mar();
	
* * @return {Boolean} true|false */ $P.is = function () { this._is = true; return this; }; /** * Determines if two date objects occur on/in exactly the same instance of the subsequent date part function. * The function .same() must be followed by a date part function (example: .day(), .month(), .year(), etc). * * An optional Date can be passed in the date part function. If now date is passed as a parameter, 'Now' is used. * * The following example demonstrates how to determine if two dates fall on the exact same day. * * Example

	var d1 = Date.today(); // today at 00:00
	var d2 = new Date();   // exactly now.

	// Do they occur on the same day?
	d1.same().day(d2); // true
	
	// Do they occur on the same hour?
	d1.same().hour(d2); // false, unless d2 hour is '00' (midnight).
	
	// What if it's the same day, but one year apart?
	var nextYear = Date.today().add(1).year();

	d1.same().day(nextYear); // false, because the dates must occur on the exact same day. 
	
* * Scenario: Determine if a given date occurs during some week period 2 months from now. * * Example

	var future = Date.today().add(2).months();
	return someDate.same().week(future); // true|false;
	
* * @return {Boolean} true|false */ $P.same = function () { this._same = true; this._isSecond = false; return this; }; /** * Determines if the current date/time occurs during Today. Must be preceded by the .is() function. * Example

	someDate.is().today();    // true|false
	new Date().is().today();  // true
	Date.today().is().today();// true
	Date.today().add(-1).day().is().today(); // false
	
* * @return {Boolean} true|false */ $P.today = function () { return this.same().day(); }; /** * Determines if the current date is a weekday. This function must be preceded by the .is() function. * Example

	Date.today().is().weekday(); // true|false
	
* * @return {Boolean} true|false */ $P.weekday = function () { if (this._nth) { return df("Weekday").call(this); } if (this._move) { return this.addWeekdays(this._orient); } if (this._is) { this._is = false; return (!this.is().sat() && !this.is().sun()); } return false; }; /** * Determines if the current date is on the weekend. This function must be preceded by the .is() function. * Example

	Date.today().is().weekend(); // true|false
	
* * @return {Boolean} true|false */ $P.weekend = function () { if (this._is) { this._is = false; return (this.is().sat() || this.is().sun()); } return false; }; /** * Sets the Time of the current Date instance. A string "6:15 pm" or config object {hour:18, minute:15} are accepted. * Example

	// Set time to 6:15pm with a String
	Date.today().at("6:15pm");

	// Set time to 6:15pm with a config object
	Date.today().at({hour:18, minute:15});
	
* * @return {Date} date */ $P.at = function (time) { return (typeof time === "string") ? $D.parse(this.toString("d") + " " + time) : this.set(time); }; /** * Creates a new Date() and adds this (Number) to the date based on the preceding date element function (eg. second|minute|hour|day|month|year). * Example

	// Undeclared Numbers must be wrapped with parentheses. Requirment of JavaScript.
	(3).days().fromNow();
	(6).months().fromNow();

	// Declared Number variables do not require parentheses. 
	var n = 6;
	n.months().fromNow();
	
* * @return {Date} A new Date instance */ $N.fromNow = $N.after = function (date) { var c = {}; c[this._dateElement] = this; return ((!date) ? new Date() : date.clone()).add(c); }; /** * Creates a new Date() and subtract this (Number) from the date based on the preceding date element function (eg. second|minute|hour|day|month|year). * Example

	// Undeclared Numbers must be wrapped with parentheses. Requirment of JavaScript.
	(3).days().ago();
	(6).months().ago();

	// Declared Number variables do not require parentheses. 
	var n = 6;
	n.months().ago();
	
* * @return {Date} A new Date instance */ $N.ago = $N.before = function (date) { var c = {}, s = (this._dateElement[this._dateElement.length-1] !== "s") ? this._dateElement + "s" : this._dateElement; c[s] = this * -1; return ((!date) ? new Date() : date.clone()).add(c); }; // Do NOT modify the following string tokens. These tokens are used to build dynamic functions. // All culture-specific strings can be found in the CultureInfo files. var dx = ("sunday monday tuesday wednesday thursday friday saturday").split(/\s/), mx = ("january february march april may june july august september october november december").split(/\s/), px = ("Millisecond Second Minute Hour Day Week Month Year Quarter Weekday").split(/\s/), pxf = ("Milliseconds Seconds Minutes Hours Date Week Month FullYear Quarter").split(/\s/), nth = ("final first second third fourth fifth").split(/\s/), de; /** * Returns an object literal of all the date parts. * Example

	var o = new Date().toObject();
	
	// { year: 2008, month: 4, week: 20, day: 13, hour: 18, minute: 9, second: 32, millisecond: 812 }
	
	// The object properties can be referenced directly from the object.
	
	alert(o.day);  // alerts "13"
	alert(o.year); // alerts "2008"
	
* * @return {Date} An object literal representing the original date object. */ $P.toObject = function () { var o = {}; for (var i = 0; i < px.length; i++) { if (this["get" + pxf[i]]) { o[px[i].toLowerCase()] = this["get" + pxf[i]](); } } return o; }; /** * Returns a date created from an object literal. Ignores the .week property if set in the config. * Example

	var o = new Date().toObject();
	
	return Date.fromObject(o); // will return the same date. 

	var o2 = {month: 1, day: 20, hour: 18}; // birthday party!
	Date.fromObject(o2);
	
* * @return {Date} An object literal representing the original date object. */ $D.fromObject = function(config) { config.week = null; return Date.today().set(config); }; // Create day name functions and abbreviated day name functions (eg. monday(), friday(), fri()). var df = function (n) { return function () { if (this._is) { this._is = false; return this.getDay() === n; } if (this._move) { this._move = null; } if (this._nth !== null) { // If the .second() function was called earlier, remove the _orient // from the date, and then continue. // This is required because 'second' can be used in two different context. // // Example // // Date.today().add(1).second(); // Date.march().second().monday(); // // Things get crazy with the following... // Date.march().add(1).second().second().monday(); // but it works!! // if (this._isSecond) { this.addSeconds(this._orient * -1); } // make sure we reset _isSecond this._isSecond = false; var ntemp = this._nth; this._nth = null; var temp = this.clone().moveToLastDayOfMonth(); this.moveToNthOccurrence(n, ntemp); if (this > temp) { throw new RangeError($D.getDayName(n) + " does not occur " + ntemp + " times in the month of " + $D.getMonthName(temp.getMonth()) + " " + temp.getFullYear() + "."); } return this; } return this.moveToDayOfWeek(n, this._orient); }; }; var sdf = function (n) { return function () { var t = $D.today(), shift = n - t.getDay(); if (n === 0 && Date.CultureInfo.firstDayOfWeek === 1 && t.getDay() !== 0) { shift = shift + 7; } return t.addDays(shift); }; }; // Create month name functions and abbreviated month name functions (eg. january(), march(), mar()). var month_instance_functions = function (n) { return function () { if (this._is) { this._is = false; return this.getMonth() === n; } return this.moveToMonth(n, this._orient); }; }; var month_static_functions = function (n) { return function () { return $D.today().set({ month: n, day: 1 }); }; }; var processTerms = function (names, staticFunc, instanceFunc) { for (var i = 0; i < names.length; i++) { // Create constant static Name variables. $D[names[i].toUpperCase()] = $D[names[i].toUpperCase().substring(0, 3)] = i; // Create Name functions. $D[names[i]] = $D[names[i].substring(0, 3)] = staticFunc(i); // Create Name instance functions. $P[names[i]] = $P[names[i].substring(0, 3)] = instanceFunc(i); } }; processTerms(dx, sdf, df); processTerms(mx, month_static_functions, month_instance_functions); // Create date element functions and plural date element functions used with Date (eg. day(), days(), months()). var ef = function (j) { return function () { // if the .second() function was called earlier, the _orient // has alread been added. Just return this and reset _isSecond. if (this._isSecond) { this._isSecond = false; return this; } if (this._same) { this._same = this._is = false; var o1 = this.toObject(), o2 = (arguments[0] || new Date()).toObject(), v = "", k = j.toLowerCase(); // the substr trick with -1 doesn't work in IE8 or less k = (k[k.length-1] === "s") ? k.substring(0,k.length-1) : k; for (var m = (px.length - 1); m > -1; m--) { v = px[m].toLowerCase(); if (o1[v] !== o2[v]) { return false; } if (k === v) { break; } } return true; } if (j.substring(j.length - 1) !== "s") { j += "s"; } if (this._move) { this._move = null; } return this["add" + j](this._orient); }; }; var nf = function (n) { return function () { this._dateElement = n; return this; }; }; for (var k = 0; k < px.length; k++) { de = px[k].toLowerCase(); if(de !== "weekday") { // Create date element functions and plural date element functions used with Date (eg. day(), days(), months()). $P[de] = $P[de + "s"] = ef(px[k]); // Create date element functions and plural date element functions used with Number (eg. day(), days(), months()). $N[de] = $N[de + "s"] = nf(de + "s"); } } $P._ss = ef("Second"); var nthfn = function (n) { return function (dayOfWeek) { if (this._same) { return this._ss(arguments[0]); } if (dayOfWeek || dayOfWeek === 0) { return this.moveToNthOccurrence(dayOfWeek, n); } this._nth = n; // if the operator is 'second' add the _orient, then deal with it later... if (n === 2 && (dayOfWeek === undefined || dayOfWeek === null)) { this._isSecond = true; return this.addSeconds(this._orient); } return this; }; }; for (var l = 0; l < nth.length; l++) { $P[nth[l]] = (l === 0) ? nthfn(-1) : nthfn(l); } }()); (function () { "use strict"; Date.Parsing = { Exception: function (s) { this.message = "Parse error at '" + s.substring(0, 10) + " ...'"; } }; var $P = Date.Parsing; var dayOffsets = { standard: [0,31,59,90,120,151,181,212,243,273,304,334], leap: [0,31,60,91,121,152,182,213,244,274,305,335] }; $P.isLeapYear = function(year) { return ((year % 4 === 0) && (year % 100 !== 0)) || (year % 400 === 0); }; var utils = { multiReplace : function (str, hash ) { var key; for (key in hash) { if (Object.prototype.hasOwnProperty.call(hash, key)) { var regex; if (typeof hash[key] === "function") { } else { regex = (hash[key] instanceof RegExp) ? hash[key] : new RegExp(hash[key], "g"); } str = str.replace(regex, key); } } return str; }, getDayOfYearFromWeek : function (obj) { var d, jan4, offset; obj.weekDay = (!obj.weekDay && obj.weekDay !== 0) ? 1 : obj.weekDay; d = new Date(obj.year, 0, 4); jan4 = d.getDay() === 0 ? 7 : d.getDay(); // JS is 0 indexed on Sunday. offset = jan4+3; obj.dayOfYear = ((obj.week * 7) + (obj.weekDay === 0 ? 7 : obj.weekDay))-offset; return obj; }, getDayOfYear : function (obj, dayOffset) { if (!obj.dayOfYear) { obj = utils.getDayOfYearFromWeek(obj); } for (var i=0;i <= dayOffset.length;i++) { if (obj.dayOfYear < dayOffset[i] || i === dayOffset.length) { obj.day = obj.day ? obj.day : (obj.dayOfYear - dayOffset[i-1]); break; } else { obj.month = i; } } return obj; }, adjustForTimeZone : function (obj, date) { var offset; if (obj.zone.toUpperCase() === "Z" || (obj.zone_hours === 0 && obj.zone_minutes === 0)) { // it's UTC/GML so work out the current timeszone offset offset = -date.getTimezoneOffset(); } else { offset = (obj.zone_hours*60) + (obj.zone_minutes || 0); if (obj.zone_sign === "+") { offset *= -1; } offset -= date.getTimezoneOffset(); } date.setMinutes(date.getMinutes()+offset); return date; }, setDefaults : function (obj) { obj.year = obj.year || Date.today().getFullYear(); obj.hours = obj.hours || 0; obj.minutes = obj.minutes || 0; obj.seconds = obj.seconds || 0; obj.milliseconds = obj.milliseconds || 0; if (!(!obj.month && (obj.week || obj.dayOfYear))) { // if we have a month, or if we don't but don't have the day calculation data obj.month = obj.month || 0; obj.day = obj.day || 1; } return obj; }, dataNum: function (data, mod, explict, postProcess) { var dataNum = data*1; if (mod) { if (postProcess) { return data ? mod(data)*1 : data; } else { return data ? mod(dataNum) : data; } } else if (!explict){ return data ? dataNum : data; } else { return (data && typeof data !== "undefined") ? dataNum : data; } }, timeDataProcess: function (obj) { var timeObj = {}; for (var x in obj.data) { if (obj.data.hasOwnProperty(x)) { timeObj[x] = obj.ignore[x] ? obj.data[x] : utils.dataNum(obj.data[x], obj.mods[x], obj.explict[x], obj.postProcess[x]); } } if (obj.data.secmins) { obj.data.secmins = obj.data.secmins.replace(",", ".") * 60; if (!timeObj.minutes) { timeObj.minutes = obj.data.secmins; } else if (!timeObj.seconds) { timeObj.seconds = obj.data.secmins; } delete obj.secmins; } return timeObj; }, buildTimeObjectFromData: function (data) { var time = utils.timeDataProcess({ data: { year : data[1], month : data[5], day : data[7], week : data[8], dayOfYear : data[10], hours : data[15], zone_hours : data[23], zone_minutes : data[24], zone : data[21], zone_sign : data[22], weekDay : data[9], minutes: data[16], seconds: data[19], milliseconds: data[20], secmins: data[18] }, mods: { month: function(data) { return data-1; }, weekDay: function (data) { data = Math.abs(data); return (data === 7 ? 0 : data); }, minutes: function (data) { return data.replace(":",""); }, seconds: function (data) { return Math.floor( (data.replace(":","").replace(",","."))*1 ); }, milliseconds: function (data) { return (data.replace(",",".")*1000); } }, postProcess: { minutes: true, seconds: true, milliseconds: true }, explict: { zone_hours: true, zone_minutes: true }, ignore: { zone: true, zone_sign: true, secmins: true } }); return time; }, addToHash: function (hash, keys, data) { keys = keys; data = data; var len = keys.length; for (var i = 0; i < len; i++) { hash[keys[i]] = data[i]; } return hash; }, combineRegex: function (r1, r2) { return new RegExp("(("+r1.source+")\\s("+r2.source+"))"); }, getDateNthString: function(add, last, inc){ if (add) { return Date.today().addDays(inc).toString("d"); } else if (last) { return Date.today().last()[inc]().toString("d"); } }, buildRegexData: function (array) { var arr = []; var len = array.length; for (var i=0; i < len; i++) { if (Object.prototype.toString.call(array[i]) === '[object Array]') { // oldIE compat version of Array.isArray arr.push(this.combineRegex(array[i][0], array[i][1])); } else { arr.push(array[i]); } } return arr; } }; $P.processTimeObject = function (obj) { var date, dayOffset; utils.setDefaults(obj); dayOffset = ($P.isLeapYear(obj.year)) ? dayOffsets.leap : dayOffsets.standard; if (!obj.month && (obj.week || obj.dayOfYear)) { utils.getDayOfYear(obj, dayOffset); } else { obj.dayOfYear = dayOffset[obj.month] + obj.day; } date = new Date(obj.year, obj.month, obj.day, obj.hours, obj.minutes, obj.seconds, obj.milliseconds); if (obj.zone) { utils.adjustForTimeZone(obj, date); // adjust (and calculate) for timezone } return date; }; $P.ISO = { regex : /^([\+-]?\d{4}(?!\d{2}\b))((-?)((0[1-9]|1[0-2])(\3([12]\d|0[1-9]|3[01]))?|W([0-4]\d|5[0-3])(-?[1-7])?|(00[1-9]|0[1-9]\d|[12]\d{2}|3([0-5]\d|6[1-6])))([T\s]((([01]\d|2[0-4])((:?)[0-5]\d)?|24\:?00)([\.,]\d+(?!:))?)?(\17[0-5]\d([\.,]\d+)?)?\s?([zZ]|([\+-])([01]\d|2[0-3]):?([0-5]\d)?)?)?)?$/, parse : function (s) { var time, data = s.match(this.regex); if (!data || !data.length) { return null; } time = utils.buildTimeObjectFromData(data); if (!time.year || (!time.year && (!time.month && !time.day) && (!time.week && !time.dayOfYear)) ) { return null; } return $P.processTimeObject(time); } }; $P.Numeric = { isNumeric: function (e){return!isNaN(parseFloat(e))&&isFinite(e);}, regex: /\b([0-1]?[0-9])([0-3]?[0-9])([0-2]?[0-9]?[0-9][0-9])\b/i, parse: function (s) { var data, i, time = {}, order = Date.CultureInfo.dateElementOrder.split(""); if (!(this.isNumeric(s)) || // if it's non-numeric OR (s[0] === "+" && s[0] === "-")) { // It's an arithmatic string (eg +/-1000) return null; } if (s.length < 5 && s.indexOf(".") < 0 && s.indexOf("/") < 0) { // assume it's just a year. time.year = s; return $P.processTimeObject(time); } data = s.match(this.regex); if (!data || !data.length) { return null; } for (i=0; i < order.length; i++) { switch(order[i]) { case "d": time.day = data[i+1]; break; case "m": time.month = (data[i+1]-1); break; case "y": time.year = data[i+1]; break; } } return $P.processTimeObject(time); } }; $P.Normalizer = { regexData: function () { var $R = Date.CultureInfo.regexPatterns; return utils.buildRegexData([ $R.tomorrow, $R.yesterday, [$R.past, $R.mon], [$R.past, $R.tue], [$R.past, $R.wed], [$R.past, $R.thu], [$R.past, $R.fri], [$R.past, $R.sat], [$R.past, $R.sun] ]); }, basicReplaceHash : function() { var $R = Date.CultureInfo.regexPatterns; return { "January": $R.jan.source, "February": $R.feb, "March": $R.mar, "April": $R.apr, "May": $R.may, "June": $R.jun, "July": $R.jul, "August": $R.aug, "September": $R.sep, "October": $R.oct, "November": $R.nov, "December": $R.dec, "": /\bat\b/gi, " ": /\s{2,}/, "am": $R.inTheMorning, "9am": $R.thisMorning, "pm": $R.inTheEvening, "7pm":$R.thisEvening }; }, keys : function(){ return [ utils.getDateNthString(true, false, 1), // tomorrow utils.getDateNthString(true, false, -1), // yesterday utils.getDateNthString(false, true, "monday"), //last mon utils.getDateNthString(false, true, "tuesday"), //last tues utils.getDateNthString(false, true, "wednesday"), //last wed utils.getDateNthString(false, true, "thursday"), //last thurs utils.getDateNthString(false, true, "friday"), //last fri utils.getDateNthString(false, true, "saturday"), //last sat utils.getDateNthString(false, true, "sunday") //last sun ]; }, buildRegexFunctions: function () { var $R = Date.CultureInfo.regexPatterns; var __ = Date.i18n.__; var tomorrowRE = new RegExp("(\\b\\d\\d?("+__("AM")+"|"+__("PM")+")? )("+$R.tomorrow.source.slice(1)+")", "i"); // adapted tomorrow regex for AM PM relative dates var todayRE = new RegExp($R.today.source + "(?!\\s*([+-]))\\b"); // today, but excludes the math operators (eg "today + 2h") this.replaceFuncs = [ [todayRE, function (full) { return (full.length > 1) ? Date.today().toString("d") : full; }], [tomorrowRE, function(full, m1) { var t = Date.today().addDays(1).toString("d"); return (t + " " + m1); }], [$R.amThisMorning, function(str, am){return am;}], [$R.pmThisEvening, function(str, pm){return pm;}] ]; }, buildReplaceData: function () { this.buildRegexFunctions(); this.replaceHash = utils.addToHash(this.basicReplaceHash(), this.keys(), this.regexData()); }, stringReplaceFuncs: function (s) { for (var i=0; i < this.replaceFuncs.length; i++) { s = s.replace(this.replaceFuncs[i][0], this.replaceFuncs[i][1]); } return s; }, parse: function (s) { s = this.stringReplaceFuncs(s); s = utils.multiReplace(s, this.replaceHash); try { var n = s.split(/([\s\-\.\,\/\x27]+)/); if (n.length === 3 && $P.Numeric.isNumeric(n[0]) && $P.Numeric.isNumeric(n[2]) && (n[2].length >= 4)) { // ok, so we're dealing with x/year. But that's not a full date. // This fixes wonky dateElementOrder parsing when set to dmy order. if (Date.CultureInfo.dateElementOrder[0] === "d") { s = "1/" + n[0] + "/" + n[2]; // set to 1st of month and normalize the seperator } } } catch (e) {} return s; } }; $P.Normalizer.buildReplaceData(); }()); (function () { var $P = Date.Parsing; var _ = $P.Operators = { // // Tokenizers // rtoken: function (r) { // regex token return function (s) { var mx = s.match(r); if (mx) { return ([ mx[0], s.substring(mx[0].length) ]); } else { throw new $P.Exception(s); } }; }, token: function () { // whitespace-eating token return function (s) { return _.rtoken(new RegExp("^\\s*" + s + "\\s*"))(s); }; }, stoken: function (s) { // string token return _.rtoken(new RegExp("^" + s)); }, // Atomic Operators until: function (p) { return function (s) { var qx = [], rx = null; while (s.length) { try { rx = p.call(this, s); } catch (e) { qx.push(rx[0]); s = rx[1]; continue; } break; } return [ qx, s ]; }; }, many: function (p) { return function (s) { var rx = [], r = null; while (s.length) { try { r = p.call(this, s); } catch (e) { return [ rx, s ]; } rx.push(r[0]); s = r[1]; } return [ rx, s ]; }; }, // generator operators -- see below optional: function (p) { return function (s) { var r = null; try { r = p.call(this, s); } catch (e) { return [ null, s ]; } return [ r[0], r[1] ]; }; }, not: function (p) { return function (s) { try { p.call(this, s); } catch (e) { return [null, s]; } throw new $P.Exception(s); }; }, ignore: function (p) { return p ? function (s) { var r = null; r = p.call(this, s); return [null, r[1]]; } : null; }, product: function () { var px = arguments[0], qx = Array.prototype.slice.call(arguments, 1), rx = []; for (var i = 0 ; i < px.length ; i++) { rx.push(_.each(px[i], qx)); } return rx; }, cache: function (rule) { var cache = {}, cache_length = 0, cache_keys = [], CACHE_MAX = Date.Config.CACHE_MAX || 100000, r = null; var cacheCheck = function () { if (cache_length === CACHE_MAX) { // kill several keys, don't want to have to do this all the time... for (var i=0; i < 10; i++) { var key = cache_keys.shift(); if (key) { delete cache[key]; cache_length--; } } } }; return function (s) { cacheCheck(); try { r = cache[s] = (cache[s] || rule.call(this, s)); } catch (e) { r = cache[s] = e; } cache_length++; cache_keys.push(s); if (r instanceof $P.Exception) { throw r; } else { return r; } }; }, // vector operators -- see below any: function () { var px = arguments; return function (s) { var r = null; for (var i = 0; i < px.length; i++) { if (px[i] == null) { continue; } try { r = (px[i].call(this, s)); } catch (e) { r = null; } if (r) { return r; } } throw new $P.Exception(s); }; }, each: function () { var px = arguments; return function (s) { var rx = [], r = null; for (var i = 0; i < px.length ; i++) { if (px[i] == null) { continue; } try { r = (px[i].call(this, s)); } catch (e) { throw new $P.Exception(s); } rx.push(r[0]); s = r[1]; } return [ rx, s]; }; }, all: function () { var px = arguments, _ = _; return _.each(_.optional(px)); }, // delimited operators sequence: function (px, d, c) { d = d || _.rtoken(/^\s*/); c = c || null; if (px.length === 1) { return px[0]; } return function (s) { var r = null, q = null; var rx = []; for (var i = 0; i < px.length ; i++) { try { r = px[i].call(this, s); } catch (e) { break; } rx.push(r[0]); try { q = d.call(this, r[1]); } catch (ex) { q = null; break; } s = q[1]; } if (!r) { throw new $P.Exception(s); } if (q) { throw new $P.Exception(q[1]); } if (c) { try { r = c.call(this, r[1]); } catch (ey) { throw new $P.Exception(r[1]); } } return [ rx, (r?r[1]:s) ]; }; }, // // Composite Operators // between: function (d1, p, d2) { d2 = d2 || d1; var _fn = _.each(_.ignore(d1), p, _.ignore(d2)); return function (s) { var rx = _fn.call(this, s); return [[rx[0][0], r[0][2]], rx[1]]; }; }, list: function (p, d, c) { d = d || _.rtoken(/^\s*/); c = c || null; return (p instanceof Array ? _.each(_.product(p.slice(0, -1), _.ignore(d)), p.slice(-1), _.ignore(c)) : _.each(_.many(_.each(p, _.ignore(d))), px, _.ignore(c))); }, set: function (px, d, c) { d = d || _.rtoken(/^\s*/); c = c || null; return function (s) { // r is the current match, best the current 'best' match // which means it parsed the most amount of input var r = null, p = null, q = null, rx = null, best = [[], s], last = false; // go through the rules in the given set for (var i = 0; i < px.length ; i++) { // last is a flag indicating whether this must be the last element // if there is only 1 element, then it MUST be the last one q = null; p = null; r = null; last = (px.length === 1); // first, we try simply to match the current pattern // if not, try the next pattern try { r = px[i].call(this, s); } catch (e) { continue; } // since we are matching against a set of elements, the first // thing to do is to add r[0] to matched elements rx = [[r[0]], r[1]]; // if we matched and there is still input to parse and // we don't already know this is the last element, // we're going to next check for the delimiter ... // if there's none, or if there's no input left to parse // than this must be the last element after all ... if (r[1].length > 0 && ! last) { try { q = d.call(this, r[1]); } catch (ex) { last = true; } } else { last = true; } // if we parsed the delimiter and now there's no more input, // that means we shouldn't have parsed the delimiter at all // so don't update r and mark this as the last element ... if (!last && q[1].length === 0) { last = true; } // so, if this isn't the last element, we're going to see if // we can get any more matches from the remaining (unmatched) // elements ... if (!last) { // build a list of the remaining rules we can match against, // i.e., all but the one we just matched against var qx = []; for (var j = 0; j < px.length ; j++) { if (i !== j) { qx.push(px[j]); } } // now invoke recursively set with the remaining input // note that we don't include the closing delimiter ... // we'll check for that ourselves at the end p = _.set(qx, d).call(this, q[1]); // if we got a non-empty set as a result ... // (otw rx already contains everything we want to match) if (p[0].length > 0) { // update current result, which is stored in rx ... // basically, pick up the remaining text from p[1] // and concat the result from p[0] so that we don't // get endless nesting ... rx[0] = rx[0].concat(p[0]); rx[1] = p[1]; } } // at this point, rx either contains the last matched element // or the entire matched set that starts with this element. // now we just check to see if this variation is better than // our best so far, in terms of how much of the input is parsed if (rx[1].length < best[1].length) { best = rx; } // if we've parsed all the input, then we're finished if (best[1].length === 0) { break; } } // so now we've either gone through all the patterns trying them // as the initial match; or we found one that parsed the entire // input string ... // if best has no matches, just return empty set ... if (best[0].length === 0) { return best; } // if a closing delimiter is provided, then we have to check it also if (c) { // we try this even if there is no remaining input because the pattern // may well be optional or match empty input ... try { q = c.call(this, best[1]); } catch (ey) { throw new $P.Exception(best[1]); } // it parsed ... be sure to update the best match remaining input best[1] = q[1]; } // if we're here, either there was no closing delimiter or we parsed it // so now we have the best match; just return it! return best; }; }, forward: function (gr, fname) { return function (s) { return gr[fname].call(this, s); }; }, // // Translation Operators // replace: function (rule, repl) { return function (s) { var r = rule.call(this, s); return [repl, r[1]]; }; }, process: function (rule, fn) { return function (s) { var r = rule.call(this, s); return [fn.call(this, r[0]), r[1]]; }; }, min: function (min, rule) { return function (s) { var rx = rule.call(this, s); if (rx[0].length < min) { throw new $P.Exception(s); } return rx; }; } }; // Generator Operators And Vector Operators // Generators are operators that have a signature of F(R) => R, // taking a given rule and returning another rule, such as // ignore, which parses a given rule and throws away the result. // Vector operators are those that have a signature of F(R1,R2,...) => R, // take a list of rules and returning a new rule, such as each. // Generator operators are converted (via the following _generator // function) into functions that can also take a list or array of rules // and return an array of new rules as though the function had been // called on each rule in turn (which is what actually happens). // This allows generators to be used with vector operators more easily. // Example: // each(ignore(foo, bar)) instead of each(ignore(foo), ignore(bar)) // This also turns generators into vector operators, which allows // constructs like: // not(cache(foo, bar)) var _generator = function (op) { function gen() { var args = null, rx = [], px, i; if (arguments.length > 1) { args = Array.prototype.slice.call(arguments); } else if (arguments[0] instanceof Array) { args = arguments[0]; } if (args) { px = args.shift(); if (px.length > 0) { args.unshift(px[i]); rx.push(op.apply(null, args)); args.shift(); return rx; } } else { return op.apply(null, arguments); } } return gen; }; var gx = "optional not ignore cache".split(/\s/); for (var i = 0 ; i < gx.length ; i++) { _[gx[i]] = _generator(_[gx[i]]); } var _vector = function (op) { return function () { if (arguments[0] instanceof Array) { return op.apply(null, arguments[0]); } else { return op.apply(null, arguments); } }; }; var vx = "each any all".split(/\s/); for (var j = 0 ; j < vx.length ; j++) { _[vx[j]] = _vector(_[vx[j]]); } }()); (function () { var $D = Date; var flattenAndCompact = function (ax) { var rx = []; for (var i = 0; i < ax.length; i++) { if (ax[i] instanceof Array) { rx = rx.concat(flattenAndCompact(ax[i])); } else { if (ax[i]) { rx.push(ax[i]); } } } return rx; }; var parseMeridian = function () { if (this.meridian && (this.hour || this.hour === 0)) { if (this.meridian === "a" && this.hour > 11 && Date.Config.strict24hr){ throw "Invalid hour and meridian combination"; } else if (this.meridian === "p" && this.hour < 12 && Date.Config.strict24hr){ throw "Invalid hour and meridian combination"; } else if (this.meridian === "p" && this.hour < 12) { this.hour = this.hour + 12; } else if (this.meridian === "a" && this.hour === 12) { this.hour = 0; } } }; var setDefaults = function () { var now = new Date(); if ((this.hour || this.minute) && (!this.month && !this.year && !this.day)) { this.day = now.getDate(); } if (!this.year) { this.year = now.getFullYear(); } if (!this.month && this.month !== 0) { this.month = now.getMonth(); } if (!this.day) { this.day = 1; } if (!this.hour) { this.hour = 0; } if (!this.minute) { this.minute = 0; } if (!this.second) { this.second = 0; } if (!this.millisecond) { this.millisecond = 0; } }; var finishUtils = { getToday: function () { if (this.now || "hour minute second".indexOf(this.unit) !== -1) { return new Date(); } else { return $D.today(); } }, setDaysFromWeekday: function (today, orient){ var gap; orient = orient || 1; this.unit = "day"; gap = ($D.getDayNumberFromName(this.weekday) - today.getDay()); this.days = gap ? ((gap + (orient * 7)) % 7) : (orient * 7); return this; }, setMonthsFromMonth: function (today, orient) { var gap; orient = orient || 1; this.unit = "month"; gap = (this.month - today.getMonth()); this.months = gap ? ((gap + (orient * 12)) % 12) : (orient * 12); this.month = null; return this; }, setDMYFromWeekday: function () { var d = Date[this.weekday](); this.day = d.getDate(); if (!this.month) { this.month = d.getMonth(); } this.year = d.getFullYear(); return this; }, setUnitValue: function (orient) { if (!this.value && this.operator && this.operator !== null && this[this.unit + "s"] && this[this.unit + "s"] !== null) { this[this.unit + "s"] = this[this.unit + "s"] + ((this.operator === "add") ? 1 : -1) + (this.value||0) * orient; } else if (this[this.unit + "s"] == null || this.operator != null) { if (!this.value) { this.value = 1; } this[this.unit + "s"] = this.value * orient; } }, generateDateFromWeeks: function () { var weekday = (this.weekday !== undefined) ? this.weekday : "today"; var d = Date[weekday]().addWeeks(this.weeks); if (this.now) { d.setTimeToNow(); } return d; } }; $D.Translator = { hour: function (s) { return function () { this.hour = Number(s); }; }, minute: function (s) { return function () { this.minute = Number(s); }; }, second: function (s) { return function () { this.second = Number(s); }; }, /* for ss.s format */ secondAndMillisecond: function (s) { return function () { var mx = s.match(/^([0-5][0-9])\.([0-9]{1,3})/); this.second = Number(mx[1]); this.millisecond = Number(mx[2]); }; }, meridian: function (s) { return function () { this.meridian = s.slice(0, 1).toLowerCase(); }; }, timezone: function (s) { return function () { var n = s.replace(/[^\d\+\-]/g, ""); if (n.length) { this.timezoneOffset = Number(n); } else { this.timezone = s.toLowerCase(); } }; }, day: function (x) { var s = x[0]; return function () { this.day = Number(s.match(/\d+/)[0]); if (this.day < 1) { throw "invalid day"; } }; }, month: function (s) { return function () { this.month = (s.length === 3) ? "jan feb mar apr may jun jul aug sep oct nov dec".indexOf(s)/4 : Number(s) - 1; if (this.month < 0) { throw "invalid month"; } }; }, year: function (s) { return function () { var n = Number(s); this.year = ((s.length > 2) ? n : (n + (((n + 2000) < Date.CultureInfo.twoDigitYearMax) ? 2000 : 1900))); }; }, rday: function (s) { return function () { switch (s) { case "yesterday": this.days = -1; break; case "tomorrow": this.days = 1; break; case "today": this.days = 0; break; case "now": this.days = 0; this.now = true; break; } }; }, finishExact: function (x) { var d; x = (x instanceof Array) ? x : [x]; for (var i = 0 ; i < x.length ; i++) { if (x[i]) { x[i].call(this); } } setDefaults.call(this); parseMeridian.call(this); if (this.day > $D.getDaysInMonth(this.year, this.month)) { throw new RangeError(this.day + " is not a valid value for days."); } d = new Date(this.year, this.month, this.day, this.hour, this.minute, this.second, this.millisecond); if (this.year < 100) { d.setFullYear(this.year); // means years less that 100 are process correctly. JS will parse it otherwise as 1900-1999. } if (this.timezone) { d.set({ timezone: this.timezone }); } else if (this.timezoneOffset) { d.set({ timezoneOffset: this.timezoneOffset }); } return d; }, finish: function (x) { var today, expression, orient, temp; x = (x instanceof Array) ? flattenAndCompact(x) : [ x ]; if (x.length === 0) { return null; } for (var i = 0 ; i < x.length ; i++) { if (typeof x[i] === "function") { x[i].call(this); } } if (this.now && !this.unit && !this.operator) { return new Date(); } else { today = finishUtils.getToday.call(this); } expression = !!(this.days && this.days !== null || this.orient || this.operator); orient = ((this.orient === "past" || this.operator === "subtract") ? -1 : 1); if (this.month && this.unit === "week") { this.value = this.month + 1; delete this.month; delete this.day; } if ((this.month || this.month === 0) && "year day hour minute second".indexOf(this.unit) !== -1) { if (!this.value) { this.value = this.month + 1; } this.month = null; expression = true; } if (!expression && this.weekday && !this.day && !this.days) { finishUtils.setDMYFromWeekday.call(this); } if (expression && this.weekday && this.unit !== "month" && this.unit !== "week") { finishUtils.setDaysFromWeekday.call(this, today, orient); } if (this.weekday && this.unit !== "week" && !this.day && !this.days) { temp = Date[this.weekday](); this.day = temp.getDate(); if (temp.getMonth() !== today.getMonth()) { this.month = temp.getMonth(); } } if (this.month && this.unit === "day" && this.operator) { if (!this.value) { this.value = (this.month + 1); } this.month = null; } if (this.value != null && this.month != null && this.year != null) { this.day = this.value * 1; } if (this.month && !this.day && this.value) { today.set({ day: this.value * 1 }); if (!expression) { this.day = this.value * 1; } } if (!this.month && this.value && this.unit === "month" && !this.now) { this.month = this.value; expression = true; } if (expression && (this.month || this.month === 0) && this.unit !== "year") { finishUtils.setMonthsFromMonth.call(this, today, orient); } if (!this.unit) { this.unit = "day"; } finishUtils.setUnitValue.call(this, orient); parseMeridian.call(this); if ((this.month || this.month === 0) && !this.day) { this.day = 1; } if (!this.orient && !this.operator && this.unit === "week" && this.value && !this.day && !this.month) { return Date.today().setWeek(this.value); } if (this.unit === "week" && this.weeks && !this.day && !this.month) { return finishUtils.generateDateFromWeeks.call(this); } if (expression && this.timezone && this.day && this.days) { this.day = this.days; } if (expression){ today.add(this); } else { today.set(this); } if (this.timezone) { this.timezone = this.timezone.toUpperCase(); var offset = $D.getTimezoneOffset(this.timezone); var timezone; if (today.hasDaylightSavingTime()) { // lets check that we're being sane with timezone setting timezone = $D.getTimezoneAbbreviation(offset, today.isDaylightSavingTime()); if (timezone !== this.timezone) { // bugger, we're in a place where things like EST vs EDT matters. if (today.isDaylightSavingTime()) { today.addHours(-1); } else { today.addHours(1); } } } today.setTimezoneOffset(offset); } return today; } }; }()); (function () { var $D = Date; $D.Grammar = {}; var _ = $D.Parsing.Operators, g = $D.Grammar, t = $D.Translator, _fn; // Allow rolling up into general purpose rules _fn = function () { return _.each(_.any.apply(null, arguments), _.not(g.ctoken2("timeContext"))); }; g.datePartDelimiter = _.rtoken(/^([\s\-\.\,\/\x27]+)/); g.timePartDelimiter = _.stoken(":"); g.whiteSpace = _.rtoken(/^\s*/); g.generalDelimiter = _.rtoken(/^(([\s\,]|at|@|on)+)/); var _C = {}; g.ctoken = function (keys) { var fn = _C[keys]; if (! fn) { var c = Date.CultureInfo.regexPatterns; var kx = keys.split(/\s+/), px = []; for (var i = 0; i < kx.length ; i++) { px.push(_.replace(_.rtoken(c[kx[i]]), kx[i])); } fn = _C[keys] = _.any.apply(null, px); } return fn; }; g.ctoken2 = function (key) { return _.rtoken(Date.CultureInfo.regexPatterns[key]); }; var cacheProcessRtoken = function (key, token, type, eachToken) { if (eachToken) { g[key] = _.cache(_.process(_.each(_.rtoken(token),_.optional(g.ctoken2(eachToken))), type)); } else { g[key] = _.cache(_.process(_.rtoken(token), type)); } }; var cacheProcessCtoken = function (token, type) { return _.cache(_.process(g.ctoken2(token), type)); }; var _F = {}; //function cache var _get = function (f) { _F[f] = (_F[f] || g.format(f)[0]); return _F[f]; }; g.allformats = function (fx) { var rx = []; if (fx instanceof Array) { for (var i = 0; i < fx.length; i++) { rx.push(_get(fx[i])); } } else { rx.push(_get(fx)); } return rx; }; g.formats = function (fx) { if (fx instanceof Array) { var rx = []; for (var i = 0 ; i < fx.length ; i++) { rx.push(_get(fx[i])); } return _.any.apply(null, rx); } else { return _get(fx); } }; var grammarFormats = { timeFormats: function(){ var i, RTokenKeys = [ "h", "hh", "H", "HH", "m", "mm", "s", "ss", "ss.s", "z", "zz" ], RToken = [ /^(0[0-9]|1[0-2]|[1-9])/, /^(0[0-9]|1[0-2])/, /^([0-1][0-9]|2[0-3]|[0-9])/, /^([0-1][0-9]|2[0-3])/, /^([0-5][0-9]|[0-9])/, /^[0-5][0-9]/, /^([0-5][0-9]|[0-9])/, /^[0-5][0-9]/, /^[0-5][0-9]\.[0-9]{1,3}/, /^((\+|\-)\s*\d\d\d\d)|((\+|\-)\d\d\:?\d\d)/, /^((\+|\-)\s*\d\d\d\d)|((\+|\-)\d\d\:?\d\d)/ ], tokens = [ t.hour, t.hour, t.hour, t.hour, t.minute, t.minute, t.second, t.second, t.secondAndMillisecond, t.timezone, t.timezone ]; for (i=0; i < RTokenKeys.length; i++) { cacheProcessRtoken(RTokenKeys[i], RToken[i], tokens[i]); } g.hms = _.cache(_.sequence([g.H, g.m, g.s], g.timePartDelimiter)); g.t = cacheProcessCtoken("shortMeridian", t.meridian); g.tt = cacheProcessCtoken("longMeridian", t.meridian); g.zzz = cacheProcessCtoken("timezone", t.timezone); g.timeSuffix = _.each(_.ignore(g.whiteSpace), _.set([ g.tt, g.zzz ])); g.time = _.each(_.optional(_.ignore(_.stoken("T"))), g.hms, g.timeSuffix); }, dateFormats: function () { // pre-loaded rules for different date part order preferences var _setfn = function () { return _.set(arguments, g.datePartDelimiter); }; var i, RTokenKeys = [ "d", "dd", "M", "MM", "y", "yy", "yyy", "yyyy" ], RToken = [ /^([0-2]\d|3[0-1]|\d)/, /^([0-2]\d|3[0-1])/, /^(1[0-2]|0\d|\d)/, /^(1[0-2]|0\d)/, /^(\d+)/, /^(\d\d)/, /^(\d\d?\d?\d?)/, /^(\d\d\d\d)/ ], tokens = [ t.day, t.day, t.month, t.month, t.year, t.year, t.year, t.year ], eachToken = [ "ordinalSuffix", "ordinalSuffix" ]; for (i=0; i < RTokenKeys.length; i++) { cacheProcessRtoken(RTokenKeys[i], RToken[i], tokens[i], eachToken[i]); } g.MMM = g.MMMM = _.cache(_.process(g.ctoken("jan feb mar apr may jun jul aug sep oct nov dec"), t.month)); g.ddd = g.dddd = _.cache(_.process(g.ctoken("sun mon tue wed thu fri sat"), function (s) { return function () { this.weekday = s; }; } )); g.day = _fn(g.d, g.dd); g.month = _fn(g.M, g.MMM); g.year = _fn(g.yyyy, g.yy); g.mdy = _setfn(g.ddd, g.month, g.day, g.year); g.ymd = _setfn(g.ddd, g.year, g.month, g.day); g.dmy = _setfn(g.ddd, g.day, g.month, g.year); g.date = function (s) { return ((g[Date.CultureInfo.dateElementOrder] || g.mdy).call(this, s)); }; }, relative: function () { // relative date / time expressions g.orientation = _.process(g.ctoken("past future"), function (s) { return function () { this.orient = s; }; } ); g.operator = _.process(g.ctoken("add subtract"), function (s) { return function () { this.operator = s; }; } ); g.rday = _.process(g.ctoken("yesterday tomorrow today now"), t.rday); g.unit = _.process(g.ctoken("second minute hour day week month year"), function (s) { return function () { this.unit = s; }; } ); } }; g.buildGrammarFormats = function () { // these need to be rebuilt every time the language changes. _C = {}; grammarFormats.timeFormats(); grammarFormats.dateFormats(); grammarFormats.relative(); g.value = _.process(_.rtoken(/^([-+]?\d+)?(st|nd|rd|th)?/), function (s) { return function () { this.value = s.replace(/\D/g, ""); }; } ); g.expression = _.set([g.rday, g.operator, g.value, g.unit, g.orientation, g.ddd, g.MMM ]); g.format = _.process(_.many( _.any( // translate format specifiers into grammar rules _.process( _.rtoken(/^(dd?d?d?(?!e)|MM?M?M?|yy?y?y?|hh?|HH?|mm?|ss?|tt?|zz?z?)/), function (fmt) { if (g[fmt]) { return g[fmt]; } else { throw $D.Parsing.Exception(fmt); } } ), // translate separator tokens into token rules _.process(_.rtoken(/^[^dMyhHmstz]+/), // all legal separators function (s) { return _.ignore(_.stoken(s)); } ) ) ), // construct the parser ... function (rules) { return _.process(_.each.apply(null, rules), t.finishExact); } ); // starting rule for general purpose grammar g._start = _.process(_.set([ g.date, g.time, g.expression ], g.generalDelimiter, g.whiteSpace), t.finish); }; g.buildGrammarFormats(); // parsing date format specifiers - ex: "h:m:s tt" // this little guy will generate a custom parser based // on the format string, ex: g.format("h:m:s tt") // check for these formats first g._formats = g.formats([ "\"yyyy-MM-ddTHH:mm:ssZ\"", "yyyy-MM-ddTHH:mm:ss.sz", "yyyy-MM-ddTHH:mm:ssZ", "yyyy-MM-ddTHH:mm:ssz", "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-ddTHH:mmZ", "yyyy-MM-ddTHH:mmz", "yyyy-MM-ddTHH:mm", "ddd, MMM dd, yyyy H:mm:ss tt", "ddd MMM d yyyy HH:mm:ss zzz", "MMddyyyy", "ddMMyyyy", "Mddyyyy", "ddMyyyy", "Mdyyyy", "dMyyyy", "yyyy", "Mdyy", "dMyy", "d" ]); // real starting rule: tries selected formats first, // then general purpose rule g.start = function (s) { try { var r = g._formats.call({}, s); if (r[1].length === 0) { return r; } } catch (e) {} return g._start.call({}, s); }; }()); (function () { var $D = Date; /** * @desc Converts the specified string value into its JavaScript Date equivalent using CultureInfo specific format information. * * Example

	///////////
	// Dates //
	///////////

	// 15-Oct-2004
	var d1 = Date.parse("10/15/2004");

	// 15-Oct-2004
	var d1 = Date.parse("15-Oct-2004");

	// 15-Oct-2004
	var d1 = Date.parse("2004.10.15");

	//Fri Oct 15, 2004
	var d1 = Date.parse("Fri Oct 15, 2004");

	///////////
	// Times //
	///////////

	// Today at 10 PM.
	var d1 = Date.parse("10 PM");

	// Today at 10:30 PM.
	var d1 = Date.parse("10:30 P.M.");

	// Today at 6 AM.
	var d1 = Date.parse("06am");

	/////////////////////
	// Dates and Times //
	/////////////////////

	// 8-July-2004 @ 10:30 PM
	var d1 = Date.parse("July 8th, 2004, 10:30 PM");

	// 1-July-2004 @ 10:30 PM
	var d1 = Date.parse("2004-07-01T22:30:00");

	////////////////////
	// Relative Dates //
	////////////////////

	// Returns today's date. The string "today" is culture specific.
	var d1 = Date.parse("today");

	// Returns yesterday's date. The string "yesterday" is culture specific.
	var d1 = Date.parse("yesterday");

	// Returns the date of the next thursday.
	var d1 = Date.parse("Next thursday");

	// Returns the date of the most previous monday.
	var d1 = Date.parse("last monday");

	// Returns today's day + one year.
	var d1 = Date.parse("next year");

	///////////////
	// Date Math //
	///////////////

	// Today + 2 days
	var d1 = Date.parse("t+2");

	// Today + 2 days
	var d1 = Date.parse("today + 2 days");

	// Today + 3 months
	var d1 = Date.parse("t+3m");

	// Today - 1 year
	var d1 = Date.parse("today - 1 year");

	// Today - 1 year
	var d1 = Date.parse("t-1y"); 


	/////////////////////////////
	// Partial Dates and Times //
	/////////////////////////////

	// July 15th of this year.
	var d1 = Date.parse("July 15");

	// 15th day of current day and year.
	var d1 = Date.parse("15");

	// July 1st of current year at 10pm.
	var d1 = Date.parse("7/1 10pm");
	
* * @param {String} The string value to convert into a Date object [Required] * @return {Date} A Date object or null if the string cannot be converted into a Date. */ var parseUtils = { removeOrds: function (s) { ords = s.match(/\b(\d+)(?:st|nd|rd|th)\b/); // find ordinal matches s = ((ords && ords.length === 2) ? s.replace(ords[0], ords[1]) : s); return s; }, grammarParser: function (s) { var r = null; try { r = $D.Grammar.start.call({}, s.replace(/^\s*(\S*(\s+\S+)*)\s*$/, "$1")); } catch (e) { return null; } return ((r[1].length === 0) ? r[0] : null); }, nativeFallback: function(s) { var t; try { // ok we haven't parsed it, last ditch attempt with the built-in parser. t = Date._parse(s); return (t || t === 0) ? new Date(t) : null; } catch (e) { return null; } } }; function parse (s) { var d; if (!s) { return null; } if (s instanceof Date) { return s.clone(); } if (s.length >= 4 && s.charAt(0) !== "0" && s.charAt(0) !== "+"&& s.charAt(0) !== "-") { // ie: 2004 will pass, 0800 won't. // Start with specific formats d = $D.Parsing.ISO.parse(s) || $D.Parsing.Numeric.parse(s); } if (d instanceof Date && !isNaN(d.getTime())) { return d; } else { // find ordinal dates (1st, 3rd, 8th, etc and remove them as they cause parsing issues) s = $D.Parsing.Normalizer.parse(parseUtils.removeOrds(s)); d = parseUtils.grammarParser(s); if (d !== null) { return d; } else { return parseUtils.nativeFallback(s); } } } if (!$D._parse) { $D._parse = $D.parse; } $D.parse = parse; Date.getParseFunction = function (fx) { var fns = Date.Grammar.allformats(fx); return function (s) { var r = null; for (var i = 0; i < fns.length; i++) { try { r = fns[i].call({}, s); } catch (e) { continue; } if (r[1].length === 0) { return r[0]; } } return null; }; }; /** * Converts the specified string value into its JavaScript Date equivalent using the specified format {String} or formats {Array} and the CultureInfo specific format information. * The format of the string value must match one of the supplied formats exactly. * * Example

	// 15-Oct-2004
	var d1 = Date.parseExact("10/15/2004", "M/d/yyyy");

	// 15-Oct-2004
	var d1 = Date.parse("15-Oct-2004", "M-ddd-yyyy");

	// 15-Oct-2004
	var d1 = Date.parse("2004.10.15", "yyyy.MM.dd");

	// Multiple formats
	var d1 = Date.parseExact("10/15/2004", ["M/d/yyyy", "MMMM d, yyyy"]);
	
* * @param {String} The string value to convert into a Date object [Required]. * @param {Object} The expected format {String} or an array of expected formats {Array} of the date string [Required]. * @return {Date} A Date object or null if the string cannot be converted into a Date. */ $D.parseExact = function (s, fx) { return $D.getParseFunction(fx)(s); }; }()); (function () { var $D = Date, $P = $D.prototype, // $C = $D.CultureInfo, // not used atm p = function (s, l) { if (!l) { l = 2; } return ("000" + s).slice(l * -1); }; /** * Converts a PHP format string to Java/.NET format string. * A PHP format string can be used with ._format or .format. * A Java/.NET format string can be used with .toString(). * The .parseExact function will only accept a Java/.NET format string * * Example * var f1 = "%m/%d/%y" * var f2 = Date.normalizeFormat(f1); // "MM/dd/yy" * * new Date().format(f1); // "04/13/08" * new Date()._format(f1); // "04/13/08" * new Date().toString(f2); // "04/13/08" * * var date = Date.parseExact("04/13/08", f2); // Sun Apr 13 2008 * * @param {String} A PHP format string consisting of one or more format spcifiers. * @return {String} The PHP format converted to a Java/.NET format string. */ var normalizerSubstitutions = { "d" : "dd", "%d": "dd", "D" : "ddd", "%a": "ddd", "j" : "dddd", "l" : "dddd", "%A": "dddd", "S" : "S", "F" : "MMMM", "%B": "MMMM", "m" : "MM", "%m": "MM", "M" : "MMM", "%b": "MMM", "%h": "MMM", "n" : "M", "Y" : "yyyy", "%Y": "yyyy", "y" : "yy", "%y": "yy", "g" : "h", "%I": "h", "G" : "H", "h" : "hh", "H" : "HH", "%H": "HH", "i" : "mm", "%M": "mm", "s" : "ss", "%S": "ss", "%r": "hh:mm tt", "%R": "H:mm", "%T": "H:mm:ss", "%X": "t", "%x": "d", "%e": "d", "%D": "MM/dd/yy", "%n": "\\n", "%t": "\\t", "e" : "z", "T" : "z", "%z": "z", "%Z": "z", "Z" : "ZZ", "N" : "u", "w" : "u", "%w": "u", "W" : "W", "%V": "W" }; var normalizer = { substitutes: function (m) { return normalizerSubstitutions[m]; }, interpreted: function (m, x) { var y; switch (m) { case "%u": return x.getDay() + 1; case "z": return x.getOrdinalNumber(); case "%j": return p(x.getOrdinalNumber(), 3); case "%U": var d1 = x.clone().set({month: 0, day: 1}).addDays(-1).moveToDayOfWeek(0), d2 = x.clone().addDays(1).moveToDayOfWeek(0, -1); return (d2 < d1) ? "00" : p((d2.getOrdinalNumber() - d1.getOrdinalNumber()) / 7 + 1); case "%W": return p(x.getWeek()); case "t": return $D.getDaysInMonth(x.getFullYear(), x.getMonth()); case "o": case "%G": return x.setWeek(x.getISOWeek()).toString("yyyy"); case "%g": return x._format("%G").slice(-2); case "a": case "%p": return t("tt").toLowerCase(); case "A": return t("tt").toUpperCase(); case "u": return p(x.getMilliseconds(), 3); case "I": return (x.isDaylightSavingTime()) ? 1 : 0; case "O": return x.getUTCOffset(); case "P": y = x.getUTCOffset(); return y.substring(0, y.length - 2) + ":" + y.substring(y.length - 2); case "B": var now = new Date(); return Math.floor(((now.getHours() * 3600) + (now.getMinutes() * 60) + now.getSeconds() + (now.getTimezoneOffset() + 60) * 60) / 86.4); case "c": return x.toISOString().replace(/\"/g, ""); case "U": return $D.strtotime("now"); case "%c": return t("d") + " " + t("t"); case "%C": return Math.floor(x.getFullYear() / 100 + 1); } }, shouldOverrideDefaults: function (m) { switch (m) { case "%e": return true; default: return false; } }, parse: function (m, context) { var formatString, c = context || new Date(); formatString = normalizer.substitutes(m); if (formatString) { return formatString; } formatString = normalizer.interpreted(m, c); if (formatString) { return formatString; } else { return m; } } }; $D.normalizeFormat = function (format, context) { return format.replace(/(%|\\)?.|%%/g, function(t){ return normalizer.parse(t, context); }); }; /** * Format a local Unix timestamp according to locale settings * * Example: * Date.strftime("%m/%d/%y", new Date()); // "04/13/08" * Date.strftime("c", "2008-04-13T17:52:03Z"); // "04/13/08" * * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @param {Number|String} The number representing the number of seconds that have elapsed since January 1, 1970 (local time). * @return {String} A string representation of the current Date object. */ $D.strftime = function (format, time) { var d = Date.parse(time); return d._format(format); }; /** * Parse any textual datetime description into a Unix timestamp. * A Unix timestamp is the number of seconds that have elapsed since January 1, 1970 (midnight UTC/GMT). * * Example: * Date.strtotime("04/13/08"); // 1208044800 * Date.strtotime("1970-01-01T00:00:00Z"); // 0 * * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @param {Object} A string or date object. * @return {String} A string representation of the current Date object. */ $D.strtotime = function (time) { var d = $D.parse(time); return Math.round($D.UTC(d.getUTCFullYear(), d.getUTCMonth(), d.getUTCDate(), d.getUTCHours(), d.getUTCMinutes(), d.getUTCSeconds(), d.getUTCMilliseconds()) / 1000); }; /** * Converts the value of the current Date object to its equivalent string representation using a PHP/Unix style of date format specifiers. * Format Specifiers * Format Description Example * ------ --------------------------------------------------------------------------- ----------------------- * %a abbreviated weekday name according to the current localed "Mon" through "Sun" * %A full weekday name according to the current localed "Sunday" through "Saturday" * %b abbreviated month name according to the current localed "Jan" through "Dec" * %B full month name according to the current locale "January" through "December" * %c preferred date and time representation for the current locale "4/13/2008 12:33 PM" * %C century number (the year divided by 100 and truncated to an integer) "00" to "99" * %d day of the month as a decimal number "01" to "31" * %D same as %m/%d/%y "04/13/08" * %e day of the month as a decimal number, a single digit is preceded by a space "1" to "31" * %g like %G, but without the century "08" * %G The 4-digit year corresponding to the ISO week number (see %V). "2008" * This has the same format and value as %Y, except that if the ISO week number * belongs to the previous or next year, that year is used instead. * %h same as %b "Jan" through "Dec" * %H hour as a decimal number using a 24-hour clock. "00" to "23" * %I hour as a decimal number using a 12-hour clock. "01" to "12" * %j day of the year as a decimal number. "001" to "366" * %m month as a decimal number. "01" to "12" * %M minute as a decimal number. "00" to "59" * %n newline character "\n" * %p either "am" or "pm" according to the given time value, or the "am" or "pm" * corresponding strings for the current locale. * %r time in a.m. and p.m. notation "8:44 PM" * %R time in 24 hour notation "20:44" * %S second as a decimal number "00" to "59" * %t tab character "\t" * %T current time, equal to %H:%M:%S "12:49:11" * %u weekday as a decimal number ["1", "7"], with "1" representing Monday "1" to "7" * %U week number of the current year as a decimal number, starting with the "0" to ("52" or "53") * first Sunday as the first day of the first week * %V The ISO 8601:1988 week number of the current year as a decimal number, "00" to ("52" or "53") * range 01 to 53, where week 1 is the first week that has at least 4 days * in the current year, and with Monday as the first day of the week. * (Use %G or %g for the year component that corresponds to the week number * for the specified timestamp.) * %W week number of the current year as a decimal number, starting with the "00" to ("52" or "53") * first Monday as the first day of the first week * %w day of the week as a decimal, Sunday being "0" "0" to "6" * %x preferred date representation for the current locale without the time "4/13/2008" * %X preferred time representation for the current locale without the date "12:53:05" * %y year as a decimal number without a century "00" "99" * %Y year as a decimal number including the century "2008" * %Z time zone or name or abbreviation "UTC", "EST", "PST" * %z same as %Z * %% a literal "%" characters "%" * d Day of the month, 2 digits with leading zeros "01" to "31" * D A textual representation of a day, three letters "Mon" through "Sun" * j Day of the month without leading zeros "1" to "31" * l A full textual representation of the day of the week (lowercase "L") "Sunday" through "Saturday" * N ISO-8601 numeric representation of the day of the week (added in PHP 5.1.0) "1" (for Monday) through "7" (for Sunday) * S English ordinal suffix for the day of the month, 2 characters "st", "nd", "rd" or "th". Works well with j * w Numeric representation of the day of the week "0" (for Sunday) through "6" (for Saturday) * z The day of the year (starting from "0") "0" through "365" * W ISO-8601 week number of year, weeks starting on Monday "00" to ("52" or "53") * F A full textual representation of a month, such as January or March "January" through "December" * m Numeric representation of a month, with leading zeros "01" through "12" * M A short textual representation of a month, three letters "Jan" through "Dec" * n Numeric representation of a month, without leading zeros "1" through "12" * t Number of days in the given month "28" through "31" * L Whether it's a leap year "1" if it is a leap year, "0" otherwise * o ISO-8601 year number. This has the same value as Y, except that if the "2008" * ISO week number (W) belongs to the previous or next year, that year * is used instead. * Y A full numeric representation of a year, 4 digits "2008" * y A two digit representation of a year "08" * a Lowercase Ante meridiem and Post meridiem "am" or "pm" * A Uppercase Ante meridiem and Post meridiem "AM" or "PM" * B Swatch Internet time "000" through "999" * g 12-hour format of an hour without leading zeros "1" through "12" * G 24-hour format of an hour without leading zeros "0" through "23" * h 12-hour format of an hour with leading zeros "01" through "12" * H 24-hour format of an hour with leading zeros "00" through "23" * i Minutes with leading zeros "00" to "59" * s Seconds, with leading zeros "00" through "59" * u Milliseconds "54321" * e Timezone identifier "UTC", "EST", "PST" * I Whether or not the date is in daylight saving time (uppercase i) "1" if Daylight Saving Time, "0" otherwise * O Difference to Greenwich time (GMT) in hours "+0200", "-0600" * P Difference to Greenwich time (GMT) with colon between hours and minutes "+02:00", "-06:00" * T Timezone abbreviation "UTC", "EST", "PST" * Z Timezone offset in seconds. The offset for timezones west of UTC is "-43200" through "50400" * always negative, and for those east of UTC is always positive. * c ISO 8601 date "2004-02-12T15:19:21+00:00" * r RFC 2822 formatted date "Thu, 21 Dec 2000 16:01:07 +0200" * U Seconds since the Unix Epoch (January 1 1970 00:00:00 GMT) "0" * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @return {String} A string representation of the current Date object. */ var formatReplace = function (context) { return function (m) { var formatString, override = false; if (m.charAt(0) === "\\" || m.substring(0, 2) === "%%") { return m.replace("\\", "").replace("%%", "%"); } override = normalizer.shouldOverrideDefaults(m); formatString = $D.normalizeFormat(m, context); if (formatString) { return context.toString(formatString, override); } }; }; $P._format = function (format) { var formatter = formatReplace(this); if (!format) { return this._toString(); } else { return format.replace(/(%|\\)?.|%%/g, formatter); } }; if (!$P.format) { $P.format = $P._format; } }()); (function () { "use strict"; var gFn = function (attr) { return function () { return this[attr]; }; }; var sFn = function (attr) { return function (val) { this[attr] = val; return this; }; }; var attrs = ["years", "months", "days", "hours", "minutes", "seconds", "milliseconds"]; var addSetFuncs = function (context, attrs) { for (var i = 0; i < attrs.length ; i++) { var $a = attrs[i], $b = $a.slice(0, 1).toUpperCase() + $a.slice(1); context.prototype[$a] = 0; context.prototype["get" + $b] = gFn($a); context.prototype["set" + $b] = sFn($a); } }; /** * new TimeSpan(milliseconds); * new TimeSpan(days, hours, minutes, seconds); * new TimeSpan(days, hours, minutes, seconds, milliseconds); */ var TimeSpan = function (days, hours, minutes, seconds, milliseconds) { if (arguments.length === 1 && typeof days === "number") { var orient = (days < 0) ? -1 : +1; var millsLeft = Math.abs(days); this.setDays(Math.floor(millsLeft / 86400000) * orient); millsLeft = millsLeft % 86400000; this.setHours(Math.floor(millsLeft / 3600000) * orient); millsLeft = millsLeft % 3600000; this.setMinutes(Math.floor(millsLeft / 60000) * orient); millsLeft = millsLeft % 60000; this.setSeconds(Math.floor(millsLeft / 1000) * orient); millsLeft = millsLeft % 1000; this.setMilliseconds(millsLeft * orient); } else { this.set(days, hours, minutes, seconds, milliseconds); } this.getTotalMilliseconds = function () { return (this.getDays() * 86400000) + (this.getHours() * 3600000) + (this.getMinutes() * 60000) + (this.getSeconds() * 1000); }; this.compareTo = function (time) { var t1 = new Date(1970, 1, 1, this.getHours(), this.getMinutes(), this.getSeconds()), t2; if (time === null) { t2 = new Date(1970, 1, 1, 0, 0, 0); } else { t2 = new Date(1970, 1, 1, time.getHours(), time.getMinutes(), time.getSeconds()); } return (t1 < t2) ? -1 : (t1 > t2) ? 1 : 0; }; this.equals = function (time) { return (this.compareTo(time) === 0); }; this.add = function (time) { return (time === null) ? this : this.addSeconds(time.getTotalMilliseconds() / 1000); }; this.subtract = function (time) { return (time === null) ? this : this.addSeconds(-time.getTotalMilliseconds() / 1000); }; this.addDays = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 86400000)); }; this.addHours = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 3600000)); }; this.addMinutes = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 60000)); }; this.addSeconds = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 1000)); }; this.addMilliseconds = function (n) { return new TimeSpan(this.getTotalMilliseconds() + n); }; this.get12HourHour = function () { return (this.getHours() > 12) ? this.getHours() - 12 : (this.getHours() === 0) ? 12 : this.getHours(); }; this.getDesignator = function () { return (this.getHours() < 12) ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator; }; this.toString = function (format) { this._toString = function () { if (this.getDays() !== null && this.getDays() > 0) { return this.getDays() + "." + this.getHours() + ":" + this.p(this.getMinutes()) + ":" + this.p(this.getSeconds()); } else { return this.getHours() + ":" + this.p(this.getMinutes()) + ":" + this.p(this.getSeconds()); } }; this.p = function (s) { return (s.toString().length < 2) ? "0" + s : s; }; var me = this; return format ? format.replace(/dd?|HH?|hh?|mm?|ss?|tt?/g, function (format) { switch (format) { case "d": return me.getDays(); case "dd": return me.p(me.getDays()); case "H": return me.getHours(); case "HH": return me.p(me.getHours()); case "h": return me.get12HourHour(); case "hh": return me.p(me.get12HourHour()); case "m": return me.getMinutes(); case "mm": return me.p(me.getMinutes()); case "s": return me.getSeconds(); case "ss": return me.p(me.getSeconds()); case "t": return ((me.getHours() < 12) ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator).substring(0, 1); case "tt": return (me.getHours() < 12) ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator; } } ) : this._toString(); }; return this; }; addSetFuncs(TimeSpan, attrs.slice(2)); TimeSpan.prototype.set = function (days, hours, minutes, seconds, milliseconds){ this.setDays(days || this.getDays()); this.setHours(hours || this.getHours()); this.setMinutes(minutes || this.getMinutes()); this.setSeconds(seconds || this.getSeconds()); this.setMilliseconds(milliseconds || this.getMilliseconds()); }; /** * Gets the time of day for this date instances. * @return {TimeSpan} TimeSpan */ Date.prototype.getTimeOfDay = function () { return new TimeSpan(0, this.getHours(), this.getMinutes(), this.getSeconds(), this.getMilliseconds()); }; Date.TimeSpan = TimeSpan; if (typeof window !== "undefined" ) { // keeping API compatible for v1.x window.TimeSpan = TimeSpan; } }()); (function () { "use strict"; var attrs = ["years", "months", "days", "hours", "minutes", "seconds", "milliseconds"]; var gFn = function (attr) { return function () { return this[attr]; }; }; var sFn = function (attr) { return function (val) { this[attr] = val; return this; }; }; var addSetFuncs = function (context, attrs) { for (var i = 0; i < attrs.length ; i++) { var $a = attrs[i], $b = $a.slice(0, 1).toUpperCase() + $a.slice(1); context.prototype[$a] = 0; context.prototype["get" + $b] = gFn($a); context.prototype["set" + $b] = sFn($a); } }; var setMonthsAndYears = function (orient, d1, d2, context) { function inc() { d1.addMonths(-orient); context.months++; if (context.months === 12) { context.years++; context.months = 0; } } if (orient === +1) { while (d1 > d2) { inc(); } } else { while (d1 < d2) { inc(); } } context.months--; context.months *= orient; context.years *= orient; }; var adjustForDST = function(orient, startDate, endDate) { var hasDSTMismatch = (false === (startDate.isDaylightSavingTime() === endDate.isDaylightSavingTime())); if (hasDSTMismatch && orient === 1) { startDate.addHours(-1); } else if (hasDSTMismatch) { startDate.addHours(1); } }; /** * TimePeriod(startDate, endDate); * TimePeriod(years, months, days, hours, minutes, seconds, milliseconds); */ var TimePeriod = function (years, months, days, hours, minutes, seconds, milliseconds) { if (arguments.length === 7) { this.set(years, months, days, hours, minutes, seconds, milliseconds); } else if (arguments.length === 2 && arguments[0] instanceof Date && arguments[1] instanceof Date) { var startDate = arguments[0].clone(); var endDate = arguments[1].clone(); var orient = (startDate > endDate) ? +1 : -1; this.dates = { start: arguments[0].clone(), end: arguments[1].clone() }; setMonthsAndYears(orient, startDate, endDate, this); adjustForDST(orient, startDate, endDate); // // TODO - adjust for DST var diff = endDate - startDate; if (diff !== 0) { var ts = new TimeSpan(diff); this.set(this.years, this.months, ts.getDays(), ts.getHours(), ts.getMinutes(), ts.getSeconds(), ts.getMilliseconds()); } } return this; }; // create all the set functions. addSetFuncs(TimePeriod, attrs); TimePeriod.prototype.set = function (years, months, days, hours, minutes, seconds, milliseconds){ this.setYears(years || this.getYears()); this.setMonths(months || this.getMonths()); this.setDays(days || this.getDays()); this.setHours(hours || this.getHours()); this.setMinutes(minutes || this.getMinutes()); this.setSeconds(seconds || this.getSeconds()); this.setMilliseconds(milliseconds || this.getMilliseconds()); }; Date.TimePeriod = TimePeriod; if (typeof window !== "undefined") { // keeping API compatible for v1.x window.TimePeriod = TimePeriod; } }()); ================================================ FILE: build/date-fi-FI.js ================================================ /** * @overview datejs * @version 1.0.0-rc3 * @author Gregory Wild-Smith * @copyright 2015 Gregory Wild-Smith * @license MIT * @homepage https://github.com/abritinthebay/datejs */ /* * DateJS Culture String File * Country Code: fi-FI * Name: Finnish (Finland) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["fi-FI"] = { "name": "fi-FI", "englishName": "Finnish (Finland)", "nativeName": "suomi (Suomi)", "Sunday": "sunnuntai", "Monday": "maanantai", "Tuesday": "tiistai", "Wednesday": "keskiviikko", "Thursday": "torstai", "Friday": "perjantai", "Saturday": "lauantai", "Sun": "su", "Mon": "ma", "Tue": "ti", "Wed": "ke", "Thu": "to", "Fri": "pe", "Sat": "la", "Su": "su", "Mo": "ma", "Tu": "ti", "We": "ke", "Th": "to", "Fr": "pe", "Sa": "la", "S_Sun_Initial": "s", "M_Mon_Initial": "m", "T_Tue_Initial": "t", "W_Wed_Initial": "k", "T_Thu_Initial": "t", "F_Fri_Initial": "p", "S_Sat_Initial": "l", "January": "tammikuu", "February": "helmikuu", "March": "maaliskuu", "April": "huhtikuu", "May": "toukokuu", "June": "kesäkuu", "July": "heinäkuu", "August": "elokuu", "September": "syyskuu", "October": "lokakuu", "November": "marraskuu", "December": "joulukuu", "Jan_Abbr": "tammi", "Feb_Abbr": "helmi", "Mar_Abbr": "maalis", "Apr_Abbr": "huhti", "May_Abbr": "touko", "Jun_Abbr": "kesä", "Jul_Abbr": "heinä", "Aug_Abbr": "elo", "Sep_Abbr": "syys", "Oct_Abbr": "loka", "Nov_Abbr": "marras", "Dec_Abbr": "joulu", "AM": "", "PM": "", "firstDayOfWeek": 1, "twoDigitYearMax": 2029, "mdy": "dmy", "M/d/yyyy": "d.M.yyyy", "dddd, MMMM dd, yyyy": "d. MMMM'ta 'yyyy", "h:mm tt": "H:mm", "h:mm:ss tt": "H:mm:ss", "dddd, MMMM dd, yyyy h:mm:ss tt": "d. MMMM'ta 'yyyy H:mm:ss", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "d. MMMM'ta'", "MMMM, yyyy": "MMMM yyyy", "/jan(uary)?/": "tammi(kuu)?", "/feb(ruary)?/": "helmi(kuu)?", "/mar(ch)?/": "maalis(kuu)?", "/apr(il)?/": "huhti(kuu)?", "/may/": "touko(kuu)?", "/jun(e)?/": "kesä(kuu)?", "/jul(y)?/": "heinä(kuu)?", "/aug(ust)?/": "elo(kuu)?", "/sep(t(ember)?)?/": "syys(kuu)?", "/oct(ober)?/": "loka(kuu)?", "/nov(ember)?/": "marras(kuu)?", "/dec(ember)?/": "joulu(kuu)?", "/^su(n(day)?)?/": "^sunnuntai", "/^mo(n(day)?)?/": "^maanantai", "/^tu(e(s(day)?)?)?/": "^tiistai", "/^we(d(nesday)?)?/": "^keskiviikko", "/^th(u(r(s(day)?)?)?)?/": "^torstai", "/^fr(i(day)?)?/": "^perjantai", "/^sa(t(urday)?)?/": "^lauantai", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "fi-FI"; /** * @overview datejs * @version 1.0.0-rc3 * @author Gregory Wild-Smith * @copyright 2015 Gregory Wild-Smith * @license MIT * @homepage https://github.com/abritinthebay/datejs */(function () { var $D = Date; var lang = Date.CultureStrings ? Date.CultureStrings.lang : null; var loggedKeys = {}; // for debug purposes. var getText = { getFromKey: function (key, countryCode) { var output; if (Date.CultureStrings && Date.CultureStrings[countryCode] && Date.CultureStrings[countryCode][key]) { output = Date.CultureStrings[countryCode][key]; } else { output = getText.buildFromDefault(key); } if (key.charAt(0) === "/") { // Assume it's a regex output = getText.buildFromRegex(key, countryCode); } return output; }, getFromObjectValues: function (obj, countryCode) { var key, output = {}; for(key in obj) { if (obj.hasOwnProperty(key)) { output[key] = getText.getFromKey(obj[key], countryCode); } } return output; }, getFromObjectKeys: function (obj, countryCode) { var key, output = {}; for(key in obj) { if (obj.hasOwnProperty(key)) { output[getText.getFromKey(key, countryCode)] = obj[key]; } } return output; }, getFromArray: function (arr, countryCode) { var output = []; for (var i=0; i < arr.length; i++){ if (i in arr) { output[i] = getText.getFromKey(arr[i], countryCode); } } return output; }, buildFromDefault: function (key) { var output, length, split, last; switch(key) { case "name": output = "en-US"; break; case "englishName": output = "English (United States)"; break; case "nativeName": output = "English (United States)"; break; case "twoDigitYearMax": output = 2049; break; case "firstDayOfWeek": output = 0; break; default: output = key; split = key.split("_"); length = split.length; if (length > 1 && key.charAt(0) !== "/") { // if the key isn't a regex and it has a split. last = split[(length - 1)].toLowerCase(); if (last === "initial" || last === "abbr") { output = split[0]; } } break; } return output; }, buildFromRegex: function (key, countryCode) { var output; if (Date.CultureStrings && Date.CultureStrings[countryCode] && Date.CultureStrings[countryCode][key]) { output = new RegExp(Date.CultureStrings[countryCode][key], "i"); } else { output = new RegExp(key.replace(new RegExp("/", "g"),""), "i"); } return output; } }; var shallowMerge = function (obj1, obj2) { for (var attrname in obj2) { if (obj2.hasOwnProperty(attrname)) { obj1[attrname] = obj2[attrname]; } } }; var __ = function (key, language) { var countryCode = (language) ? language : lang; loggedKeys[key] = key; if (typeof key === "object") { if (key instanceof Array) { return getText.getFromArray(key, countryCode); } else { return getText.getFromObjectKeys(key, countryCode); } } else { return getText.getFromKey(key, countryCode); } }; var loadI18nScript = function (code) { // paatterned after jQuery's getScript. var url = Date.Config.i18n + code + ".js"; var head = document.getElementsByTagName("head")[0] || document.documentElement; var script = document.createElement("script"); script.src = url; var completed = false; var events = { done: function (){} // placeholder function }; // Attach handlers for all browsers script.onload = script.onreadystatechange = function() { if ( !completed && (!this.readyState || this.readyState === "loaded" || this.readyState === "complete") ) { events.done(); head.removeChild(script); } }; setTimeout(function() { head.insertBefore(script, head.firstChild); }, 0); // allows return to execute first return { done: function (cb) { events.done = function() { if (cb) { setTimeout(cb,0); } }; } }; }; var buildInfo = { buildFromMethodHash: function (obj) { var key; for(key in obj) { if (obj.hasOwnProperty(key)) { obj[key] = buildInfo[obj[key]](); } } return obj; }, timeZoneDST: function () { var DST = { "CHADT": "+1345", "NZDT": "+1300", "AEDT": "+1100", "ACDT": "+1030", "AZST": "+0500", "IRDT": "+0430", "EEST": "+0300", "CEST": "+0200", "BST": "+0100", "PMDT": "-0200", "ADT": "-0300", "NDT": "-0230", "EDT": "-0400", "CDT": "-0500", "MDT": "-0600", "PDT": "-0700", "AKDT": "-0800", "HADT": "-0900" }; return __(DST); }, timeZoneStandard: function () { var standard = { "LINT": "+1400", "TOT": "+1300", "CHAST": "+1245", "NZST": "+1200", "NFT": "+1130", "SBT": "+1100", "AEST": "+1000", "ACST": "+0930", "JST": "+0900", "CWST": "+0845", "CT": "+0800", "ICT": "+0700", "MMT": "+0630", "BST": "+0600", "NPT": "+0545", "IST": "+0530", "PKT": "+0500", "AFT": "+0430", "MSK": "+0400", "IRST": "+0330", "FET": "+0300", "EET": "+0200", "CET": "+0100", "GMT": "+0000", "UTC": "+0000", "CVT": "-0100", "GST": "-0200", "BRT": "-0300", "NST": "-0330", "AST": "-0400", "EST": "-0500", "CST": "-0600", "MST": "-0700", "PST": "-0800", "AKST": "-0900", "MIT": "-0930", "HST": "-1000", "SST": "-1100", "BIT": "-1200" }; return __(standard); }, timeZones: function (data) { var zone; data.timezones = []; for (zone in data.abbreviatedTimeZoneStandard) { if (data.abbreviatedTimeZoneStandard.hasOwnProperty(zone)) { data.timezones.push({ name: zone, offset: data.abbreviatedTimeZoneStandard[zone]}); } } for (zone in data.abbreviatedTimeZoneDST) { if (data.abbreviatedTimeZoneDST.hasOwnProperty(zone)) { data.timezones.push({ name: zone, offset: data.abbreviatedTimeZoneDST[zone], dst: true}); } } return data.timezones; }, days: function () { return __(["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"]); }, dayAbbr: function () { return __(["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"]); }, dayShortNames: function () { return __(["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"]); }, dayFirstLetters: function () { return __(["S_Sun_Initial", "M_Mon_Initial", "T_Tues_Initial", "W_Wed_Initial", "T_Thu_Initial", "F_Fri_Initial", "S_Sat_Initial"]); }, months: function () { return __(["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"]); }, monthAbbr: function () { return __(["Jan_Abbr", "Feb_Abbr", "Mar_Abbr", "Apr_Abbr", "May_Abbr", "Jun_Abbr", "Jul_Abbr", "Aug_Abbr", "Sep_Abbr", "Oct_Abbr", "Nov_Abbr", "Dec_Abbr"]); }, formatPatterns: function () { return getText.getFromObjectValues({ shortDate: "M/d/yyyy", longDate: "dddd, MMMM dd, yyyy", shortTime: "h:mm tt", longTime: "h:mm:ss tt", fullDateTime: "dddd, MMMM dd, yyyy h:mm:ss tt", sortableDateTime: "yyyy-MM-ddTHH:mm:ss", universalSortableDateTime: "yyyy-MM-dd HH:mm:ssZ", rfc1123: "ddd, dd MMM yyyy HH:mm:ss", monthDay: "MMMM dd", yearMonth: "MMMM, yyyy" }, Date.i18n.currentLanguage()); }, regex: function () { return getText.getFromObjectValues({ inTheMorning: "/( in the )(morn(ing)?)\\b/", thisMorning: "/(this )(morn(ing)?)\\b/", amThisMorning: "/(\b\\d(am)? )(this )(morn(ing)?)/", inTheEvening: "/( in the )(even(ing)?)\\b/", thisEvening: "/(this )(even(ing)?)\\b/", pmThisEvening: "/(\b\\d(pm)? )(this )(even(ing)?)/", jan: "/jan(uary)?/", feb: "/feb(ruary)?/", mar: "/mar(ch)?/", apr: "/apr(il)?/", may: "/may/", jun: "/jun(e)?/", jul: "/jul(y)?/", aug: "/aug(ust)?/", sep: "/sep(t(ember)?)?/", oct: "/oct(ober)?/", nov: "/nov(ember)?/", dec: "/dec(ember)?/", sun: "/^su(n(day)?)?/", mon: "/^mo(n(day)?)?/", tue: "/^tu(e(s(day)?)?)?/", wed: "/^we(d(nesday)?)?/", thu: "/^th(u(r(s(day)?)?)?)?/", fri: "/fr(i(day)?)?/", sat: "/^sa(t(urday)?)?/", future: "/^next/", past: "/^last|past|prev(ious)?/", add: "/^(\\+|aft(er)?|from|hence)/", subtract: "/^(\\-|bef(ore)?|ago)/", yesterday: "/^yes(terday)?/", today: "/^t(od(ay)?)?/", tomorrow: "/^tom(orrow)?/", now: "/^n(ow)?/", millisecond: "/^ms|milli(second)?s?/", second: "/^sec(ond)?s?/", minute: "/^mn|min(ute)?s?/", hour: "/^h(our)?s?/", week: "/^w(eek)?s?/", month: "/^m(onth)?s?/", day: "/^d(ay)?s?/", year: "/^y(ear)?s?/", shortMeridian: "/^(a|p)/", longMeridian: "/^(a\\.?m?\\.?|p\\.?m?\\.?)/", timezone: "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/", ordinalSuffix: "/^\\s*(st|nd|rd|th)/", timeContext: "/^\\s*(\\:|a(?!u|p)|p)/" }, Date.i18n.currentLanguage()); } }; var CultureInfo = function () { var info = getText.getFromObjectValues({ name: "name", englishName: "englishName", nativeName: "nativeName", amDesignator: "AM", pmDesignator: "PM", firstDayOfWeek: "firstDayOfWeek", twoDigitYearMax: "twoDigitYearMax", dateElementOrder: "mdy" }, Date.i18n.currentLanguage()); var constructedInfo = buildInfo.buildFromMethodHash({ dayNames: "days", abbreviatedDayNames: "dayAbbr", shortestDayNames: "dayShortNames", firstLetterDayNames: "dayFirstLetters", monthNames: "months", abbreviatedMonthNames: "monthAbbr", formatPatterns: "formatPatterns", regexPatterns: "regex", abbreviatedTimeZoneDST: "timeZoneDST", abbreviatedTimeZoneStandard: "timeZoneStandard" }); shallowMerge(info, constructedInfo); buildInfo.timeZones(info); return info; }; $D.i18n = { __: function (key, lang) { return __(key, lang); }, currentLanguage: function () { return lang || "en-US"; }, setLanguage: function (code, force, cb) { var async = false; if (force || code === "en-US" || (!!Date.CultureStrings && !!Date.CultureStrings[code])) { lang = code; Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings.lang = code; Date.CultureInfo = new CultureInfo(); } else { if (!(!!Date.CultureStrings && !!Date.CultureStrings[code])) { if (typeof exports !== "undefined" && this.exports !== exports) { // we're in a Node enviroment, load it using require try { require("../i18n/" + code + ".js"); lang = code; Date.CultureStrings.lang = code; Date.CultureInfo = new CultureInfo(); } catch (e) { // var str = "The language for '" + code + "' could not be loaded by Node. It likely does not exist."; throw new Error("The DateJS IETF language tag '" + code + "' could not be loaded by Node. It likely does not exist."); } } else if (Date.Config && Date.Config.i18n) { // we know the location of the files, so lets load them async = true; loadI18nScript(code).done(function(){ lang = code; Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings.lang = code; Date.CultureInfo = new CultureInfo(); $D.Parsing.Normalizer.buildReplaceData(); // because this is async if ($D.Grammar) { $D.Grammar.buildGrammarFormats(); // so we can parse those strings... } if (cb) { setTimeout(cb,0); } }); } else { Date.console.error("The DateJS IETF language tag '" + code + "' is not available and has not been loaded."); return false; } } } $D.Parsing.Normalizer.buildReplaceData(); // rebuild normalizer strings if ($D.Grammar) { $D.Grammar.buildGrammarFormats(); // so we can parse those strings... } if (!async && cb) { setTimeout(cb,0); } }, getLoggedKeys: function () { return loggedKeys; }, updateCultureInfo: function () { Date.CultureInfo = new CultureInfo(); } }; $D.i18n.updateCultureInfo(); // run automatically }()); (function () { var $D = Date, $P = $D.prototype, p = function (s, l) { if (!l) { l = 2; } return ("000" + s).slice(l * -1); }; if (typeof window !== "undefined" && typeof window.console !== "undefined" && typeof window.console.log !== "undefined") { $D.console = console; // used only to raise non-critical errors if available } else { // set mock so we don't give errors. $D.console = { log: function(){}, error: function(){} }; } $D.Config = $D.Config || {}; $D.initOverloads = function() { /** * Overload of Date.now. Allows an alternate call for Date.now where it returns the * current Date as an object rather than just milliseconds since the Unix Epoch. * * Also provides an implementation of now() for browsers (IE<9) that don't have it. * * Backwards compatible so with work with either: * Date.now() [returns ms] * or * Date.now(true) [returns Date] */ if (!$D.now) { $D._now = function now() { return new Date().getTime(); }; } else if (!$D._now) { $D._now = $D.now; } $D.now = function (returnObj) { if (returnObj) { return $D.present(); } else { return $D._now(); } }; if ( !$P.toISOString ) { $P.toISOString = function() { return this.getUTCFullYear() + "-" + p(this.getUTCMonth() + 1) + "-" + p(this.getUTCDate()) + "T" + p(this.getUTCHours()) + ":" + p(this.getUTCMinutes()) + ":" + p(this.getUTCSeconds()) + "." + String( (this.getUTCMilliseconds()/1000).toFixed(3)).slice(2, 5) + "Z"; }; } // private if ( $P._toString === undefined ){ $P._toString = $P.toString; } }; $D.initOverloads(); /** * Gets a date that is set to the current date. The time is set to the start of the day (00:00 or 12:00 AM). * @return {Date} The current date. */ $D.today = function () { return new Date().clearTime(); }; /** * Gets a date that is set to the current date and time (same as new Date, but chainable) * @return {Date} The current date. */ $D.present = function () { return new Date(); }; /** * Compares the first date to the second date and returns an number indication of their relative values. * @param {Date} First Date object to compare [Required]. * @param {Date} Second Date object to compare to [Required]. * @return {Number} -1 = date1 is lessthan date2. 0 = values are equal. 1 = date1 is greaterthan date2. */ $D.compare = function (date1, date2) { if (isNaN(date1) || isNaN(date2)) { throw new Error(date1 + " - " + date2); } else if (date1 instanceof Date && date2 instanceof Date) { return (date1 < date2) ? -1 : (date1 > date2) ? 1 : 0; } else { throw new TypeError(date1 + " - " + date2); } }; /** * Compares the first Date object to the second Date object and returns true if they are equal. * @param {Date} First Date object to compare [Required] * @param {Date} Second Date object to compare to [Required] * @return {Boolean} true if dates are equal. false if they are not equal. */ $D.equals = function (date1, date2) { return (date1.compareTo(date2) === 0); }; /** * Gets the language appropriate day name when given the day number(0-6) * eg - 0 == Sunday * @return {String} The day name */ $D.getDayName = function (n) { return Date.CultureInfo.dayNames[n]; }; /** * Gets the day number (0-6) if given a CultureInfo specific string which is a valid dayName, abbreviatedDayName or shortestDayName (two char). * @param {String} The name of the day (eg. "Monday, "Mon", "tuesday", "tue", "We", "we"). * @return {Number} The day number */ $D.getDayNumberFromName = function (name) { var n = Date.CultureInfo.dayNames, m = Date.CultureInfo.abbreviatedDayNames, o = Date.CultureInfo.shortestDayNames, s = name.toLowerCase(); for (var i = 0; i < n.length; i++) { if (n[i].toLowerCase() === s || m[i].toLowerCase() === s || o[i].toLowerCase() === s) { return i; } } return -1; }; /** * Gets the month number (0-11) if given a Culture Info specific string which is a valid monthName or abbreviatedMonthName. * @param {String} The name of the month (eg. "February, "Feb", "october", "oct"). * @return {Number} The day number */ $D.getMonthNumberFromName = function (name) { var n = Date.CultureInfo.monthNames, m = Date.CultureInfo.abbreviatedMonthNames, s = name.toLowerCase(); for (var i = 0; i < n.length; i++) { if (n[i].toLowerCase() === s || m[i].toLowerCase() === s) { return i; } } return -1; }; /** * Gets the language appropriate month name when given the month number(0-11) * eg - 0 == January * @return {String} The month name */ $D.getMonthName = function (n) { return Date.CultureInfo.monthNames[n]; }; /** * Determines if the current date instance is within a LeapYear. * @param {Number} The year. * @return {Boolean} true if date is within a LeapYear, otherwise false. */ $D.isLeapYear = function (year) { return ((year % 4 === 0 && year % 100 !== 0) || year % 400 === 0); }; /** * Gets the number of days in the month, given a year and month value. Automatically corrects for LeapYear. * @param {Number} The year. * @param {Number} The month (0-11). * @return {Number} The number of days in the month. */ $D.getDaysInMonth = function (year, month) { if (!month && $D.validateMonth(year)) { month = year; year = Date.today().getFullYear(); } return [31, ($D.isLeapYear(year) ? 29 : 28), 31, 30, 31, 30, 31, 31, 30, 31, 30, 31][month]; }; $P.getDaysInMonth = function () { return $D.getDaysInMonth(this.getFullYear(), this.getMonth()); }; $D.getTimezoneAbbreviation = function (offset, dst) { var p, n = (dst || false) ? Date.CultureInfo.abbreviatedTimeZoneDST : Date.CultureInfo.abbreviatedTimeZoneStandard; for (p in n) { if (n.hasOwnProperty(p)) { if (n[p] === offset) { return p; } } } return null; }; $D.getTimezoneOffset = function (name, dst) { var i, a =[], z = Date.CultureInfo.timezones; if (!name) { name = (new Date()).getTimezone();} for (i = 0; i < z.length; i++) { if (z[i].name === name.toUpperCase()) { a.push(i); } } if (!z[a[0]]) { return null; } if (a.length === 1 || !dst) { return z[a[0]].offset; } else { for (i=0; i < a.length; i++) { if (z[a[i]].dst) { return z[a[i]].offset; } } } }; $D.getQuarter = function (d) { d = d || new Date(); // If no date supplied, use today var q = [1,2,3,4]; return q[Math.floor(d.getMonth() / 3)]; // ~~~ is a bitwise op. Faster than Math.floor }; $D.getDaysLeftInQuarter = function (d) { d = d || new Date(); var qEnd = new Date(d); qEnd.setMonth(qEnd.getMonth() + 3 - qEnd.getMonth() % 3, 0); return Math.floor((qEnd - d) / 8.64e7); }; // private var validate = function (n, min, max, name) { name = name ? name : "Object"; if (typeof n === "undefined") { return false; } else if (typeof n !== "number") { throw new TypeError(n + " is not a Number."); } else if (n < min || n > max) { // As failing validation is *not* an exceptional circumstance // lets not throw a RangeError Exception here. // It's semantically correct but it's not sensible. return false; } return true; }; /** * Validates the number is within an acceptable range for milliseconds [0-999]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateMillisecond = function (value) { return validate(value, 0, 999, "millisecond"); }; /** * Validates the number is within an acceptable range for seconds [0-59]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateSecond = function (value) { return validate(value, 0, 59, "second"); }; /** * Validates the number is within an acceptable range for minutes [0-59]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateMinute = function (value) { return validate(value, 0, 59, "minute"); }; /** * Validates the number is within an acceptable range for hours [0-23]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateHour = function (value) { return validate(value, 0, 23, "hour"); }; /** * Validates the number is within an acceptable range for the days in a month [0-MaxDaysInMonth]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateDay = function (value, year, month) { if (year === undefined || year === null || month === undefined || month === null) { return false;} return validate(value, 1, $D.getDaysInMonth(year, month), "day"); }; /** * Validates the number is within an acceptable range for months [0-11]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateWeek = function (value) { return validate(value, 0, 53, "week"); }; /** * Validates the number is within an acceptable range for months [0-11]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateMonth = function (value) { return validate(value, 0, 11, "month"); }; /** * Validates the number is within an acceptable range for years. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateYear = function (value) { /** * Per ECMAScript spec the range of times supported by Date objects is * exactly -100,000,000 days to +100,000,000 days measured relative to * midnight at the beginning of 01 January, 1970 UTC. * This gives a range of 8,640,000,000,000,000 milliseconds to either * side of 01 January, 1970 UTC. * * Earliest possible date: Tue, 20 Apr 271,822 B.C. 00:00:00 UTC * Latest possible date: Sat, 13 Sep 275,760 00:00:00 UTC */ return validate(value, -271822, 275760, "year"); }; $D.validateTimezone = function(value) { var timezones = {"ACDT":1,"ACST":1,"ACT":1,"ADT":1,"AEDT":1,"AEST":1,"AFT":1,"AKDT":1,"AKST":1,"AMST":1,"AMT":1,"ART":1,"AST":1,"AWDT":1,"AWST":1,"AZOST":1,"AZT":1,"BDT":1,"BIOT":1,"BIT":1,"BOT":1,"BRT":1,"BST":1,"BTT":1,"CAT":1,"CCT":1,"CDT":1,"CEDT":1,"CEST":1,"CET":1,"CHADT":1,"CHAST":1,"CHOT":1,"ChST":1,"CHUT":1,"CIST":1,"CIT":1,"CKT":1,"CLST":1,"CLT":1,"COST":1,"COT":1,"CST":1,"CT":1,"CVT":1,"CWST":1,"CXT":1,"DAVT":1,"DDUT":1,"DFT":1,"EASST":1,"EAST":1,"EAT":1,"ECT":1,"EDT":1,"EEDT":1,"EEST":1,"EET":1,"EGST":1,"EGT":1,"EIT":1,"EST":1,"FET":1,"FJT":1,"FKST":1,"FKT":1,"FNT":1,"GALT":1,"GAMT":1,"GET":1,"GFT":1,"GILT":1,"GIT":1,"GMT":1,"GST":1,"GYT":1,"HADT":1,"HAEC":1,"HAST":1,"HKT":1,"HMT":1,"HOVT":1,"HST":1,"ICT":1,"IDT":1,"IOT":1,"IRDT":1,"IRKT":1,"IRST":1,"IST":1,"JST":1,"KGT":1,"KOST":1,"KRAT":1,"KST":1,"LHST":1,"LINT":1,"MAGT":1,"MART":1,"MAWT":1,"MDT":1,"MET":1,"MEST":1,"MHT":1,"MIST":1,"MIT":1,"MMT":1,"MSK":1,"MST":1,"MUT":1,"MVT":1,"MYT":1,"NCT":1,"NDT":1,"NFT":1,"NPT":1,"NST":1,"NT":1,"NUT":1,"NZDT":1,"NZST":1,"OMST":1,"ORAT":1,"PDT":1,"PET":1,"PETT":1,"PGT":1,"PHOT":1,"PHT":1,"PKT":1,"PMDT":1,"PMST":1,"PONT":1,"PST":1,"PYST":1,"PYT":1,"RET":1,"ROTT":1,"SAKT":1,"SAMT":1,"SAST":1,"SBT":1,"SCT":1,"SGT":1,"SLST":1,"SRT":1,"SST":1,"SYOT":1,"TAHT":1,"THA":1,"TFT":1,"TJT":1,"TKT":1,"TLT":1,"TMT":1,"TOT":1,"TVT":1,"UCT":1,"ULAT":1,"UTC":1,"UYST":1,"UYT":1,"UZT":1,"VET":1,"VLAT":1,"VOLT":1,"VOST":1,"VUT":1,"WAKT":1,"WAST":1,"WAT":1,"WEDT":1,"WEST":1,"WET":1,"WST":1,"YAKT":1,"YEKT":1,"Z":1}; return (timezones[value] === 1); }; $D.validateTimezoneOffset= function(value) { // timezones go from +14hrs to -12hrs, the +X hours are negative offsets. return (value > -841 && value < 721); }; }()); (function () { var $D = Date, $P = $D.prototype, p = function (s, l) { if (!l) { l = 2; } return ("000" + s).slice(l * -1); }; var validateConfigObject = function (obj) { var result = {}, self = this, prop, testFunc; testFunc = function (prop, func, value) { if (prop === "day") { var month = (obj.month !== undefined) ? obj.month : self.getMonth(); var year = (obj.year !== undefined) ? obj.year : self.getFullYear(); return $D[func](value, year, month); } else { return $D[func](value); } }; for (prop in obj) { if (Object.prototype.hasOwnProperty.call(obj, prop)) { var func = "validate" + prop.charAt(0).toUpperCase() + prop.slice(1); if ($D[func] && obj[prop] !== null && testFunc(prop, func, obj[prop])) { result[prop] = obj[prop]; } } } return result; }; /** * Resets the time of this Date object to 12:00 AM (00:00), which is the start of the day. * @param {Boolean} .clone() this date instance before clearing Time * @return {Date} this */ $P.clearTime = function () { this.setHours(0); this.setMinutes(0); this.setSeconds(0); this.setMilliseconds(0); return this; }; /** * Resets the time of this Date object to the current time ('now'). * @return {Date} this */ $P.setTimeToNow = function () { var n = new Date(); this.setHours(n.getHours()); this.setMinutes(n.getMinutes()); this.setSeconds(n.getSeconds()); this.setMilliseconds(n.getMilliseconds()); return this; }; /** * Returns a new Date object that is an exact date and time copy of the original instance. * @return {Date} A new Date instance */ $P.clone = function () { return new Date(this.getTime()); }; /** * Compares this instance to a Date object and returns an number indication of their relative values. * @param {Date} Date object to compare [Required] * @return {Number} -1 = this is lessthan date. 0 = values are equal. 1 = this is greaterthan date. */ $P.compareTo = function (date) { return Date.compare(this, date); }; /** * Compares this instance to another Date object and returns true if they are equal. * @param {Date} Date object to compare. If no date to compare, new Date() [now] is used. * @return {Boolean} true if dates are equal. false if they are not equal. */ $P.equals = function (date) { return Date.equals(this, (date !== undefined ? date : new Date())); }; /** * Determines if this instance is between a range of two dates or equal to either the start or end dates. * @param {Date} Start of range [Required] * @param {Date} End of range [Required] * @return {Boolean} true is this is between or equal to the start and end dates, else false */ $P.between = function (start, end) { return this.getTime() >= start.getTime() && this.getTime() <= end.getTime(); }; /** * Determines if this date occurs after the date to compare to. * @param {Date} Date object to compare. If no date to compare, new Date() ("now") is used. * @return {Boolean} true if this date instance is greater than the date to compare to (or "now"), otherwise false. */ $P.isAfter = function (date) { return this.compareTo(date || new Date()) === 1; }; /** * Determines if this date occurs before the date to compare to. * @param {Date} Date object to compare. If no date to compare, new Date() ("now") is used. * @return {Boolean} true if this date instance is less than the date to compare to (or "now"). */ $P.isBefore = function (date) { return (this.compareTo(date || new Date()) === -1); }; /** * Determines if the current Date instance occurs today. * @return {Boolean} true if this date instance is 'today', otherwise false. */ /** * Determines if the current Date instance occurs on the same Date as the supplied 'date'. * If no 'date' to compare to is provided, the current Date instance is compared to 'today'. * @param {date} Date object to compare. If no date to compare, the current Date ("now") is used. * @return {Boolean} true if this Date instance occurs on the same Day as the supplied 'date'. */ $P.isToday = $P.isSameDay = function (date) { return this.clone().clearTime().equals((date || new Date()).clone().clearTime()); }; /** * Adds the specified number of milliseconds to this instance. * @param {Number} The number of milliseconds to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addMilliseconds = function (value) { if (!value) { return this; } this.setTime(this.getTime() + value * 1); return this; }; /** * Adds the specified number of seconds to this instance. * @param {Number} The number of seconds to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addSeconds = function (value) { if (!value) { return this; } return this.addMilliseconds(value * 1000); }; /** * Adds the specified number of seconds to this instance. * @param {Number} The number of seconds to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addMinutes = function (value) { if (!value) { return this; } return this.addMilliseconds(value * 60000); // 60*1000 }; /** * Adds the specified number of hours to this instance. * @param {Number} The number of hours to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addHours = function (value) { if (!value) { return this; } return this.addMilliseconds(value * 3600000); // 60*60*1000 }; /** * Adds the specified number of days to this instance. * @param {Number} The number of days to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addDays = function (value) { if (!value) { return this; } this.setDate(this.getDate() + value * 1); return this; }; /** * Adds the specified number of weekdays (ie - not sat or sun) to this instance. * @param {Number} The number of days to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addWeekdays = function (value) { if (!value) { return this; } var day = this.getDay(); var weeks = (Math.ceil(Math.abs(value)/7)); if (day === 0 || day === 6) { if (value > 0) { this.next().monday(); this.addDays(-1); day = this.getDay(); } } if (value < 0) { while (value < 0) { this.addDays(-1); day = this.getDay(); if (day !== 0 && day !== 6) { value++; } } return this; } else if (value > 5 || (6-day) <= value) { value = value + (weeks * 2); } return this.addDays(value); }; /** * Adds the specified number of weeks to this instance. * @param {Number} The number of weeks to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addWeeks = function (value) { if (!value) { return this; } return this.addDays(value * 7); }; /** * Adds the specified number of months to this instance. * @param {Number} The number of months to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addMonths = function (value) { if (!value) { return this; } var n = this.getDate(); this.setDate(1); this.setMonth(this.getMonth() + value * 1); this.setDate(Math.min(n, $D.getDaysInMonth(this.getFullYear(), this.getMonth()))); return this; }; $P.addQuarters = function (value) { if (!value) { return this; } // note this will take you to the same point in the quarter as you are now. // i.e. - if you are 15 days into the quarter you'll be 15 days into the resulting one. // bonus: this allows adding fractional quarters return this.addMonths(value * 3); }; /** * Adds the specified number of years to this instance. * @param {Number} The number of years to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addYears = function (value) { if (!value) { return this; } return this.addMonths(value * 12); }; /** * Adds (or subtracts) to the value of the years, months, weeks, days, hours, minutes, seconds, milliseconds of the date instance using given configuration object. Positive and Negative values allowed. * Example

	Date.today().add( { days: 1, months: 1 } )

	new Date().add( { years: -1 } )
	
* @param {Object} Configuration object containing attributes (months, days, etc.) * @return {Date} this */ $P.add = function (config) { if (typeof config === "number") { this._orient = config; return this; } var x = config; if (x.day) { // If we should be a different date than today (eg: for 'tomorrow -1d', etc). // Should only effect parsing, not direct usage (eg, Finish and FinishExact) if ((x.day - this.getDate()) !== 0) { this.setDate(x.day); } } if (x.milliseconds) { this.addMilliseconds(x.milliseconds); } if (x.seconds) { this.addSeconds(x.seconds); } if (x.minutes) { this.addMinutes(x.minutes); } if (x.hours) { this.addHours(x.hours); } if (x.weeks) { this.addWeeks(x.weeks); } if (x.months) { this.addMonths(x.months); } if (x.years) { this.addYears(x.years); } if (x.days) { this.addDays(x.days); } return this; }; /** * Get the week number. Week one (1) is the week which contains the first Thursday of the year. Monday is considered the first day of the week. * The .getWeek() function does NOT convert the date to UTC. The local datetime is used. * Please use .getISOWeek() to get the week of the UTC converted date. * @return {Number} 1 to 53 */ $P.getWeek = function (utc) { // Create a copy of this date object var self, target = new Date(this.valueOf()); if (utc) { target.addMinutes(target.getTimezoneOffset()); self = target.clone(); } else { self = this; } // ISO week date weeks start on monday // so correct the day number var dayNr = (self.getDay() + 6) % 7; // ISO 8601 states that week 1 is the week // with the first thursday of that year. // Set the target date to the thursday in the target week target.setDate(target.getDate() - dayNr + 3); // Store the millisecond value of the target date var firstThursday = target.valueOf(); // Set the target to the first thursday of the year // First set the target to january first target.setMonth(0, 1); // Not a thursday? Correct the date to the next thursday if (target.getDay() !== 4) { target.setMonth(0, 1 + ((4 - target.getDay()) + 7) % 7); } // The weeknumber is the number of weeks between the // first thursday of the year and the thursday in the target week return 1 + Math.ceil((firstThursday - target) / 604800000); // 604800000 = 7 * 24 * 3600 * 1000 }; /** * Get the ISO 8601 week number. Week one ("01") is the week which contains the first Thursday of the year. Monday is considered the first day of the week. * The .getISOWeek() function does convert the date to it's UTC value. Please use .getWeek() to get the week of the local date. * @return {String} "01" to "53" */ $P.getISOWeek = function () { return p(this.getWeek(true)); }; /** * Moves the date to Monday of the week set. Week one (1) is the week which contains the first Thursday of the year. * @param {Number} A Number (1 to 53) that represents the week of the year. * @return {Date} this */ $P.setWeek = function (n) { if ((n - this.getWeek()) === 0) { if (this.getDay() !== 1) { return this.moveToDayOfWeek(1, (this.getDay() > 1 ? -1 : 1)); } else { return this; } } else { return this.moveToDayOfWeek(1, (this.getDay() > 1 ? -1 : 1)).addWeeks(n - this.getWeek()); } }; $P.setQuarter = function (qtr) { var month = Math.abs(((qtr-1) * 3) + 1); return this.setMonth(month, 1); }; $P.getQuarter = function () { return Date.getQuarter(this); }; $P.getDaysLeftInQuarter = function () { return Date.getDaysLeftInQuarter(this); }; /** * Moves the date to the next n'th occurrence of the dayOfWeek starting from the beginning of the month. The number (-1) is a magic number and will return the last occurrence of the dayOfWeek in the month. * @param {Number} The dayOfWeek to move to * @param {Number} The n'th occurrence to move to. Use (-1) to return the last occurrence in the month * @return {Date} this */ $P.moveToNthOccurrence = function (dayOfWeek, occurrence) { if (dayOfWeek === "Weekday") { if (occurrence > 0) { this.moveToFirstDayOfMonth(); if (this.is().weekday()) { occurrence -= 1; } } else if (occurrence < 0) { this.moveToLastDayOfMonth(); if (this.is().weekday()) { occurrence += 1; } } else { return this; } return this.addWeekdays(occurrence); } var shift = 0; if (occurrence > 0) { shift = occurrence - 1; } else if (occurrence === -1) { this.moveToLastDayOfMonth(); if (this.getDay() !== dayOfWeek) { this.moveToDayOfWeek(dayOfWeek, -1); } return this; } return this.moveToFirstDayOfMonth().addDays(-1).moveToDayOfWeek(dayOfWeek, +1).addWeeks(shift); }; var moveToN = function (getFunc, addFunc, nVal) { return function (value, orient) { var diff = (value - this[getFunc]() + nVal * (orient || +1)) % nVal; return this[addFunc]((diff === 0) ? diff += nVal * (orient || +1) : diff); }; }; /** * Move to the next or last dayOfWeek based on the orient value. * @param {Number} The dayOfWeek to move to * @param {Number} Forward (+1) or Back (-1). Defaults to +1. [Optional] * @return {Date} this */ $P.moveToDayOfWeek = moveToN("getDay", "addDays", 7); /** * Move to the next or last month based on the orient value. * @param {Number} The month to move to. 0 = January, 11 = December * @param {Number} Forward (+1) or Back (-1). Defaults to +1. [Optional] * @return {Date} this */ $P.moveToMonth = moveToN("getMonth", "addMonths", 12); /** * Get the Ordinate of the current day ("th", "st", "rd"). * @return {String} */ $P.getOrdinate = function () { var num = this.getDate(); return ord(num); }; /** * Get the Ordinal day (numeric day number) of the year, adjusted for leap year. * @return {Number} 1 through 365 (366 in leap years) */ $P.getOrdinalNumber = function () { return Math.ceil((this.clone().clearTime() - new Date(this.getFullYear(), 0, 1)) / 86400000) + 1; }; /** * Get the time zone abbreviation of the current date. * @return {String} The abbreviated time zone name (e.g. "EST") */ $P.getTimezone = function () { return $D.getTimezoneAbbreviation(this.getUTCOffset(), this.isDaylightSavingTime()); }; $P.setTimezoneOffset = function (offset) { var here = this.getTimezoneOffset(), there = Number(offset) * -6 / 10; return (there || there === 0) ? this.addMinutes(there - here) : this; }; $P.setTimezone = function (offset) { return this.setTimezoneOffset($D.getTimezoneOffset(offset)); }; /** * Indicates whether Daylight Saving Time is observed in the current time zone. * @return {Boolean} true|false */ $P.hasDaylightSavingTime = function () { return (Date.today().set({month: 0, day: 1}).getTimezoneOffset() !== Date.today().set({month: 6, day: 1}).getTimezoneOffset()); }; /** * Indicates whether this Date instance is within the Daylight Saving Time range for the current time zone. * @return {Boolean} true|false */ $P.isDaylightSavingTime = function () { return Date.today().set({month: 0, day: 1}).getTimezoneOffset() !== this.getTimezoneOffset(); }; /** * Get the offset from UTC of the current date. * @return {String} The 4-character offset string prefixed with + or - (e.g. "-0500") */ $P.getUTCOffset = function (offset) { var n = (offset || this.getTimezoneOffset()) * -10 / 6, r; if (n < 0) { r = (n - 10000).toString(); return r.charAt(0) + r.substr(2); } else { r = (n + 10000).toString(); return "+" + r.substr(1); } }; /** * Returns the number of milliseconds between this date and date. * @param {Date} Defaults to now * @return {Number} The diff in milliseconds */ $P.getElapsed = function (date) { return (date || new Date()) - this; }; /** * Set the value of year, month, day, hour, minute, second, millisecond of date instance using given configuration object. * Example

	Date.today().set( { day: 20, month: 1 } )

	new Date().set( { millisecond: 0 } )
	
* * @param {Object} Configuration object containing attributes (month, day, etc.) * @return {Date} this */ $P.set = function (config) { config = validateConfigObject.call(this, config); var key; for (key in config) { if (Object.prototype.hasOwnProperty.call(config, key)) { var name = key.charAt(0).toUpperCase() + key.slice(1); var addFunc, getFunc; if (key !== "week" && key !== "month" && key !== "timezone" && key !== "timezoneOffset") { name += "s"; } addFunc = "add" + name; getFunc = "get" + name; if (key === "month") { addFunc = addFunc + "s"; } else if (key === "year"){ getFunc = "getFullYear"; } if (key !== "day" && key !== "timezone" && key !== "timezoneOffset" && key !== "week" && key !== "hour") { this[addFunc](config[key] - this[getFunc]()); } else if ( key === "timezone"|| key === "timezoneOffset" || key === "week" || key === "hour") { this["set"+name](config[key]); } } } // day has to go last because you can't validate the day without first knowing the month if (config.day) { this.addDays(config.day - this.getDate()); } return this; }; /** * Moves the date to the first day of the month. * @return {Date} this */ $P.moveToFirstDayOfMonth = function () { return this.set({ day: 1 }); }; /** * Moves the date to the last day of the month. * @return {Date} this */ $P.moveToLastDayOfMonth = function () { return this.set({ day: $D.getDaysInMonth(this.getFullYear(), this.getMonth())}); }; /** * Converts the value of the current Date object to its equivalent string representation. * Format Specifiers * CUSTOM DATE AND TIME FORMAT STRINGS * Format Description Example * ------ --------------------------------------------------------------------------- ----------------------- * s The seconds of the minute between 0-59. "0" to "59" * ss The seconds of the minute with leading zero if required. "00" to "59" * * m The minute of the hour between 0-59. "0" or "59" * mm The minute of the hour with leading zero if required. "00" or "59" * * h The hour of the day between 1-12. "1" to "12" * hh The hour of the day with leading zero if required. "01" to "12" * * H The hour of the day between 0-23. "0" to "23" * HH The hour of the day with leading zero if required. "00" to "23" * * d The day of the month between 1 and 31. "1" to "31" * dd The day of the month with leading zero if required. "01" to "31" * ddd Abbreviated day name. Date.CultureInfo.abbreviatedDayNames. "Mon" to "Sun" * dddd The full day name. Date.CultureInfo.dayNames. "Monday" to "Sunday" * * M The month of the year between 1-12. "1" to "12" * MM The month of the year with leading zero if required. "01" to "12" * MMM Abbreviated month name. Date.CultureInfo.abbreviatedMonthNames. "Jan" to "Dec" * MMMM The full month name. Date.CultureInfo.monthNames. "January" to "December" * * yy The year as a two-digit number. "99" or "08" * yyyy The full four digit year. "1999" or "2008" * * t Displays the first character of the A.M./P.M. designator. "A" or "P" * Date.CultureInfo.amDesignator or Date.CultureInfo.pmDesignator * tt Displays the A.M./P.M. designator. "AM" or "PM" * Date.CultureInfo.amDesignator or Date.CultureInfo.pmDesignator * * S The ordinal suffix ("st, "nd", "rd" or "th") of the current day. "st, "nd", "rd" or "th" * * STANDARD DATE AND TIME FORMAT STRINGS * Format Description Example *------ --------------------------------------------------------------------------- ----------------------- * d The CultureInfo shortDate Format Pattern "M/d/yyyy" * D The CultureInfo longDate Format Pattern "dddd, MMMM dd, yyyy" * F The CultureInfo fullDateTime Format Pattern "dddd, MMMM dd, yyyy h:mm:ss tt" * m The CultureInfo monthDay Format Pattern "MMMM dd" * r The CultureInfo rfc1123 Format Pattern "ddd, dd MMM yyyy HH:mm:ss GMT" * s The CultureInfo sortableDateTime Format Pattern "yyyy-MM-ddTHH:mm:ss" * t The CultureInfo shortTime Format Pattern "h:mm tt" * T The CultureInfo longTime Format Pattern "h:mm:ss tt" * u The CultureInfo universalSortableDateTime Format Pattern "yyyy-MM-dd HH:mm:ssZ" * y The CultureInfo yearMonth Format Pattern "MMMM, yyyy" * * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @return {String} A string representation of the current Date object. */ var ord = function (n) { switch (n * 1) { case 1: case 21: case 31: return "st"; case 2: case 22: return "nd"; case 3: case 23: return "rd"; default: return "th"; } }; var parseStandardFormats = function (format) { var y, c = Date.CultureInfo.formatPatterns; switch (format) { case "d": return this.toString(c.shortDate); case "D": return this.toString(c.longDate); case "F": return this.toString(c.fullDateTime); case "m": return this.toString(c.monthDay); case "r": case "R": y = this.clone().addMinutes(this.getTimezoneOffset()); return y.toString(c.rfc1123) + " GMT"; case "s": return this.toString(c.sortableDateTime); case "t": return this.toString(c.shortTime); case "T": return this.toString(c.longTime); case "u": y = this.clone().addMinutes(this.getTimezoneOffset()); return y.toString(c.universalSortableDateTime); case "y": return this.toString(c.yearMonth); default: return false; } }; var parseFormatStringsClosure = function (context) { return function (m) { if (m.charAt(0) === "\\") { return m.replace("\\", ""); } switch (m) { case "hh": return p(context.getHours() < 13 ? (context.getHours() === 0 ? 12 : context.getHours()) : (context.getHours() - 12)); case "h": return context.getHours() < 13 ? (context.getHours() === 0 ? 12 : context.getHours()) : (context.getHours() - 12); case "HH": return p(context.getHours()); case "H": return context.getHours(); case "mm": return p(context.getMinutes()); case "m": return context.getMinutes(); case "ss": return p(context.getSeconds()); case "s": return context.getSeconds(); case "yyyy": return p(context.getFullYear(), 4); case "yy": return p(context.getFullYear()); case "y": return context.getFullYear(); case "E": case "dddd": return Date.CultureInfo.dayNames[context.getDay()]; case "ddd": return Date.CultureInfo.abbreviatedDayNames[context.getDay()]; case "dd": return p(context.getDate()); case "d": return context.getDate(); case "MMMM": return Date.CultureInfo.monthNames[context.getMonth()]; case "MMM": return Date.CultureInfo.abbreviatedMonthNames[context.getMonth()]; case "MM": return p((context.getMonth() + 1)); case "M": return context.getMonth() + 1; case "t": return context.getHours() < 12 ? Date.CultureInfo.amDesignator.substring(0, 1) : Date.CultureInfo.pmDesignator.substring(0, 1); case "tt": return context.getHours() < 12 ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator; case "S": return ord(context.getDate()); case "W": return context.getWeek(); case "WW": return context.getISOWeek(); case "Q": return "Q" + context.getQuarter(); case "q": return String(context.getQuarter()); case "z": return context.getTimezone(); case "Z": case "X": return Date.getTimezoneOffset(context.getTimezone()); case "ZZ": // Timezone offset in seconds return context.getTimezoneOffset() * -60; case "u": return context.getDay(); case "L": return ($D.isLeapYear(context.getFullYear())) ? 1 : 0; case "B": // Swatch Internet Time (.beats) return "@"+((context.getUTCSeconds() + (context.getUTCMinutes()*60) + ((context.getUTCHours()+1)*3600))/86.4); default: return m; } }; }; $P.toString = function (format, ignoreStandards) { // Standard Date and Time Format Strings. Formats pulled from CultureInfo file and // may vary by culture. if (!ignoreStandards && format && format.length === 1) { output = parseStandardFormats.call(this, format); if (output) { return output; } } var parseFormatStrings = parseFormatStringsClosure(this); return format ? format.replace(/((\\)?(dd?d?d?|MM?M?M?|yy?y?y?|hh?|HH?|mm?|ss?|tt?|S|q|Q|WW?W?W?)(?![^\[]*\]))/g, parseFormatStrings).replace(/\[|\]/g, "") : this._toString(); }; }()); /************************************************************* * SugarPak - Domain Specific Language - Syntactical Sugar * *************************************************************/ (function () { var $D = Date, $P = $D.prototype, $N = Number.prototype; // private $P._orient = +1; // private $P._nth = null; // private $P._is = false; // private $P._same = false; // private $P._isSecond = false; // private $N._dateElement = "days"; /** * Moves the date to the next instance of a date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.today().next().friday();
	Date.today().next().fri();
	Date.today().next().march();
	Date.today().next().mar();
	Date.today().next().week();
	
* * @return {Date} date */ $P.next = function () { this._move = true; this._orient = +1; return this; }; /** * Creates a new Date (Date.today()) and moves the date to the next instance of the date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.next().friday();
	Date.next().fri();
	Date.next().march();
	Date.next().mar();
	Date.next().week();
	
* * @return {Date} date */ $D.next = function () { return $D.today().next(); }; /** * Moves the date to the previous instance of a date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.today().last().friday();
	Date.today().last().fri();
	Date.today().last().march();
	Date.today().last().mar();
	Date.today().last().week();
	
* * @return {Date} date */ $P.last = $P.prev = $P.previous = function () { this._move = true; this._orient = -1; return this; }; /** * Creates a new Date (Date.today()) and moves the date to the previous instance of the date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.last().friday();
	Date.last().fri();
	Date.previous().march();
	Date.prev().mar();
	Date.last().week();
	
* * @return {Date} date */ $D.last = $D.prev = $D.previous = function () { return $D.today().last(); }; /** * Performs a equality check when followed by either a month name, day name or .weekday() function. * Example

	Date.today().is().friday(); // true|false
	Date.today().is().fri();
	Date.today().is().march();
	Date.today().is().mar();
	
* * @return {Boolean} true|false */ $P.is = function () { this._is = true; return this; }; /** * Determines if two date objects occur on/in exactly the same instance of the subsequent date part function. * The function .same() must be followed by a date part function (example: .day(), .month(), .year(), etc). * * An optional Date can be passed in the date part function. If now date is passed as a parameter, 'Now' is used. * * The following example demonstrates how to determine if two dates fall on the exact same day. * * Example

	var d1 = Date.today(); // today at 00:00
	var d2 = new Date();   // exactly now.

	// Do they occur on the same day?
	d1.same().day(d2); // true
	
	// Do they occur on the same hour?
	d1.same().hour(d2); // false, unless d2 hour is '00' (midnight).
	
	// What if it's the same day, but one year apart?
	var nextYear = Date.today().add(1).year();

	d1.same().day(nextYear); // false, because the dates must occur on the exact same day. 
	
* * Scenario: Determine if a given date occurs during some week period 2 months from now. * * Example

	var future = Date.today().add(2).months();
	return someDate.same().week(future); // true|false;
	
* * @return {Boolean} true|false */ $P.same = function () { this._same = true; this._isSecond = false; return this; }; /** * Determines if the current date/time occurs during Today. Must be preceded by the .is() function. * Example

	someDate.is().today();    // true|false
	new Date().is().today();  // true
	Date.today().is().today();// true
	Date.today().add(-1).day().is().today(); // false
	
* * @return {Boolean} true|false */ $P.today = function () { return this.same().day(); }; /** * Determines if the current date is a weekday. This function must be preceded by the .is() function. * Example

	Date.today().is().weekday(); // true|false
	
* * @return {Boolean} true|false */ $P.weekday = function () { if (this._nth) { return df("Weekday").call(this); } if (this._move) { return this.addWeekdays(this._orient); } if (this._is) { this._is = false; return (!this.is().sat() && !this.is().sun()); } return false; }; /** * Determines if the current date is on the weekend. This function must be preceded by the .is() function. * Example

	Date.today().is().weekend(); // true|false
	
* * @return {Boolean} true|false */ $P.weekend = function () { if (this._is) { this._is = false; return (this.is().sat() || this.is().sun()); } return false; }; /** * Sets the Time of the current Date instance. A string "6:15 pm" or config object {hour:18, minute:15} are accepted. * Example

	// Set time to 6:15pm with a String
	Date.today().at("6:15pm");

	// Set time to 6:15pm with a config object
	Date.today().at({hour:18, minute:15});
	
* * @return {Date} date */ $P.at = function (time) { return (typeof time === "string") ? $D.parse(this.toString("d") + " " + time) : this.set(time); }; /** * Creates a new Date() and adds this (Number) to the date based on the preceding date element function (eg. second|minute|hour|day|month|year). * Example

	// Undeclared Numbers must be wrapped with parentheses. Requirment of JavaScript.
	(3).days().fromNow();
	(6).months().fromNow();

	// Declared Number variables do not require parentheses. 
	var n = 6;
	n.months().fromNow();
	
* * @return {Date} A new Date instance */ $N.fromNow = $N.after = function (date) { var c = {}; c[this._dateElement] = this; return ((!date) ? new Date() : date.clone()).add(c); }; /** * Creates a new Date() and subtract this (Number) from the date based on the preceding date element function (eg. second|minute|hour|day|month|year). * Example

	// Undeclared Numbers must be wrapped with parentheses. Requirment of JavaScript.
	(3).days().ago();
	(6).months().ago();

	// Declared Number variables do not require parentheses. 
	var n = 6;
	n.months().ago();
	
* * @return {Date} A new Date instance */ $N.ago = $N.before = function (date) { var c = {}, s = (this._dateElement[this._dateElement.length-1] !== "s") ? this._dateElement + "s" : this._dateElement; c[s] = this * -1; return ((!date) ? new Date() : date.clone()).add(c); }; // Do NOT modify the following string tokens. These tokens are used to build dynamic functions. // All culture-specific strings can be found in the CultureInfo files. var dx = ("sunday monday tuesday wednesday thursday friday saturday").split(/\s/), mx = ("january february march april may june july august september october november december").split(/\s/), px = ("Millisecond Second Minute Hour Day Week Month Year Quarter Weekday").split(/\s/), pxf = ("Milliseconds Seconds Minutes Hours Date Week Month FullYear Quarter").split(/\s/), nth = ("final first second third fourth fifth").split(/\s/), de; /** * Returns an object literal of all the date parts. * Example

	var o = new Date().toObject();
	
	// { year: 2008, month: 4, week: 20, day: 13, hour: 18, minute: 9, second: 32, millisecond: 812 }
	
	// The object properties can be referenced directly from the object.
	
	alert(o.day);  // alerts "13"
	alert(o.year); // alerts "2008"
	
* * @return {Date} An object literal representing the original date object. */ $P.toObject = function () { var o = {}; for (var i = 0; i < px.length; i++) { if (this["get" + pxf[i]]) { o[px[i].toLowerCase()] = this["get" + pxf[i]](); } } return o; }; /** * Returns a date created from an object literal. Ignores the .week property if set in the config. * Example

	var o = new Date().toObject();
	
	return Date.fromObject(o); // will return the same date. 

	var o2 = {month: 1, day: 20, hour: 18}; // birthday party!
	Date.fromObject(o2);
	
* * @return {Date} An object literal representing the original date object. */ $D.fromObject = function(config) { config.week = null; return Date.today().set(config); }; // Create day name functions and abbreviated day name functions (eg. monday(), friday(), fri()). var df = function (n) { return function () { if (this._is) { this._is = false; return this.getDay() === n; } if (this._move) { this._move = null; } if (this._nth !== null) { // If the .second() function was called earlier, remove the _orient // from the date, and then continue. // This is required because 'second' can be used in two different context. // // Example // // Date.today().add(1).second(); // Date.march().second().monday(); // // Things get crazy with the following... // Date.march().add(1).second().second().monday(); // but it works!! // if (this._isSecond) { this.addSeconds(this._orient * -1); } // make sure we reset _isSecond this._isSecond = false; var ntemp = this._nth; this._nth = null; var temp = this.clone().moveToLastDayOfMonth(); this.moveToNthOccurrence(n, ntemp); if (this > temp) { throw new RangeError($D.getDayName(n) + " does not occur " + ntemp + " times in the month of " + $D.getMonthName(temp.getMonth()) + " " + temp.getFullYear() + "."); } return this; } return this.moveToDayOfWeek(n, this._orient); }; }; var sdf = function (n) { return function () { var t = $D.today(), shift = n - t.getDay(); if (n === 0 && Date.CultureInfo.firstDayOfWeek === 1 && t.getDay() !== 0) { shift = shift + 7; } return t.addDays(shift); }; }; // Create month name functions and abbreviated month name functions (eg. january(), march(), mar()). var month_instance_functions = function (n) { return function () { if (this._is) { this._is = false; return this.getMonth() === n; } return this.moveToMonth(n, this._orient); }; }; var month_static_functions = function (n) { return function () { return $D.today().set({ month: n, day: 1 }); }; }; var processTerms = function (names, staticFunc, instanceFunc) { for (var i = 0; i < names.length; i++) { // Create constant static Name variables. $D[names[i].toUpperCase()] = $D[names[i].toUpperCase().substring(0, 3)] = i; // Create Name functions. $D[names[i]] = $D[names[i].substring(0, 3)] = staticFunc(i); // Create Name instance functions. $P[names[i]] = $P[names[i].substring(0, 3)] = instanceFunc(i); } }; processTerms(dx, sdf, df); processTerms(mx, month_static_functions, month_instance_functions); // Create date element functions and plural date element functions used with Date (eg. day(), days(), months()). var ef = function (j) { return function () { // if the .second() function was called earlier, the _orient // has alread been added. Just return this and reset _isSecond. if (this._isSecond) { this._isSecond = false; return this; } if (this._same) { this._same = this._is = false; var o1 = this.toObject(), o2 = (arguments[0] || new Date()).toObject(), v = "", k = j.toLowerCase(); // the substr trick with -1 doesn't work in IE8 or less k = (k[k.length-1] === "s") ? k.substring(0,k.length-1) : k; for (var m = (px.length - 1); m > -1; m--) { v = px[m].toLowerCase(); if (o1[v] !== o2[v]) { return false; } if (k === v) { break; } } return true; } if (j.substring(j.length - 1) !== "s") { j += "s"; } if (this._move) { this._move = null; } return this["add" + j](this._orient); }; }; var nf = function (n) { return function () { this._dateElement = n; return this; }; }; for (var k = 0; k < px.length; k++) { de = px[k].toLowerCase(); if(de !== "weekday") { // Create date element functions and plural date element functions used with Date (eg. day(), days(), months()). $P[de] = $P[de + "s"] = ef(px[k]); // Create date element functions and plural date element functions used with Number (eg. day(), days(), months()). $N[de] = $N[de + "s"] = nf(de + "s"); } } $P._ss = ef("Second"); var nthfn = function (n) { return function (dayOfWeek) { if (this._same) { return this._ss(arguments[0]); } if (dayOfWeek || dayOfWeek === 0) { return this.moveToNthOccurrence(dayOfWeek, n); } this._nth = n; // if the operator is 'second' add the _orient, then deal with it later... if (n === 2 && (dayOfWeek === undefined || dayOfWeek === null)) { this._isSecond = true; return this.addSeconds(this._orient); } return this; }; }; for (var l = 0; l < nth.length; l++) { $P[nth[l]] = (l === 0) ? nthfn(-1) : nthfn(l); } }()); (function () { "use strict"; Date.Parsing = { Exception: function (s) { this.message = "Parse error at '" + s.substring(0, 10) + " ...'"; } }; var $P = Date.Parsing; var dayOffsets = { standard: [0,31,59,90,120,151,181,212,243,273,304,334], leap: [0,31,60,91,121,152,182,213,244,274,305,335] }; $P.isLeapYear = function(year) { return ((year % 4 === 0) && (year % 100 !== 0)) || (year % 400 === 0); }; var utils = { multiReplace : function (str, hash ) { var key; for (key in hash) { if (Object.prototype.hasOwnProperty.call(hash, key)) { var regex; if (typeof hash[key] === "function") { } else { regex = (hash[key] instanceof RegExp) ? hash[key] : new RegExp(hash[key], "g"); } str = str.replace(regex, key); } } return str; }, getDayOfYearFromWeek : function (obj) { var d, jan4, offset; obj.weekDay = (!obj.weekDay && obj.weekDay !== 0) ? 1 : obj.weekDay; d = new Date(obj.year, 0, 4); jan4 = d.getDay() === 0 ? 7 : d.getDay(); // JS is 0 indexed on Sunday. offset = jan4+3; obj.dayOfYear = ((obj.week * 7) + (obj.weekDay === 0 ? 7 : obj.weekDay))-offset; return obj; }, getDayOfYear : function (obj, dayOffset) { if (!obj.dayOfYear) { obj = utils.getDayOfYearFromWeek(obj); } for (var i=0;i <= dayOffset.length;i++) { if (obj.dayOfYear < dayOffset[i] || i === dayOffset.length) { obj.day = obj.day ? obj.day : (obj.dayOfYear - dayOffset[i-1]); break; } else { obj.month = i; } } return obj; }, adjustForTimeZone : function (obj, date) { var offset; if (obj.zone.toUpperCase() === "Z" || (obj.zone_hours === 0 && obj.zone_minutes === 0)) { // it's UTC/GML so work out the current timeszone offset offset = -date.getTimezoneOffset(); } else { offset = (obj.zone_hours*60) + (obj.zone_minutes || 0); if (obj.zone_sign === "+") { offset *= -1; } offset -= date.getTimezoneOffset(); } date.setMinutes(date.getMinutes()+offset); return date; }, setDefaults : function (obj) { obj.year = obj.year || Date.today().getFullYear(); obj.hours = obj.hours || 0; obj.minutes = obj.minutes || 0; obj.seconds = obj.seconds || 0; obj.milliseconds = obj.milliseconds || 0; if (!(!obj.month && (obj.week || obj.dayOfYear))) { // if we have a month, or if we don't but don't have the day calculation data obj.month = obj.month || 0; obj.day = obj.day || 1; } return obj; }, dataNum: function (data, mod, explict, postProcess) { var dataNum = data*1; if (mod) { if (postProcess) { return data ? mod(data)*1 : data; } else { return data ? mod(dataNum) : data; } } else if (!explict){ return data ? dataNum : data; } else { return (data && typeof data !== "undefined") ? dataNum : data; } }, timeDataProcess: function (obj) { var timeObj = {}; for (var x in obj.data) { if (obj.data.hasOwnProperty(x)) { timeObj[x] = obj.ignore[x] ? obj.data[x] : utils.dataNum(obj.data[x], obj.mods[x], obj.explict[x], obj.postProcess[x]); } } if (obj.data.secmins) { obj.data.secmins = obj.data.secmins.replace(",", ".") * 60; if (!timeObj.minutes) { timeObj.minutes = obj.data.secmins; } else if (!timeObj.seconds) { timeObj.seconds = obj.data.secmins; } delete obj.secmins; } return timeObj; }, buildTimeObjectFromData: function (data) { var time = utils.timeDataProcess({ data: { year : data[1], month : data[5], day : data[7], week : data[8], dayOfYear : data[10], hours : data[15], zone_hours : data[23], zone_minutes : data[24], zone : data[21], zone_sign : data[22], weekDay : data[9], minutes: data[16], seconds: data[19], milliseconds: data[20], secmins: data[18] }, mods: { month: function(data) { return data-1; }, weekDay: function (data) { data = Math.abs(data); return (data === 7 ? 0 : data); }, minutes: function (data) { return data.replace(":",""); }, seconds: function (data) { return Math.floor( (data.replace(":","").replace(",","."))*1 ); }, milliseconds: function (data) { return (data.replace(",",".")*1000); } }, postProcess: { minutes: true, seconds: true, milliseconds: true }, explict: { zone_hours: true, zone_minutes: true }, ignore: { zone: true, zone_sign: true, secmins: true } }); return time; }, addToHash: function (hash, keys, data) { keys = keys; data = data; var len = keys.length; for (var i = 0; i < len; i++) { hash[keys[i]] = data[i]; } return hash; }, combineRegex: function (r1, r2) { return new RegExp("(("+r1.source+")\\s("+r2.source+"))"); }, getDateNthString: function(add, last, inc){ if (add) { return Date.today().addDays(inc).toString("d"); } else if (last) { return Date.today().last()[inc]().toString("d"); } }, buildRegexData: function (array) { var arr = []; var len = array.length; for (var i=0; i < len; i++) { if (Object.prototype.toString.call(array[i]) === '[object Array]') { // oldIE compat version of Array.isArray arr.push(this.combineRegex(array[i][0], array[i][1])); } else { arr.push(array[i]); } } return arr; } }; $P.processTimeObject = function (obj) { var date, dayOffset; utils.setDefaults(obj); dayOffset = ($P.isLeapYear(obj.year)) ? dayOffsets.leap : dayOffsets.standard; if (!obj.month && (obj.week || obj.dayOfYear)) { utils.getDayOfYear(obj, dayOffset); } else { obj.dayOfYear = dayOffset[obj.month] + obj.day; } date = new Date(obj.year, obj.month, obj.day, obj.hours, obj.minutes, obj.seconds, obj.milliseconds); if (obj.zone) { utils.adjustForTimeZone(obj, date); // adjust (and calculate) for timezone } return date; }; $P.ISO = { regex : /^([\+-]?\d{4}(?!\d{2}\b))((-?)((0[1-9]|1[0-2])(\3([12]\d|0[1-9]|3[01]))?|W([0-4]\d|5[0-3])(-?[1-7])?|(00[1-9]|0[1-9]\d|[12]\d{2}|3([0-5]\d|6[1-6])))([T\s]((([01]\d|2[0-4])((:?)[0-5]\d)?|24\:?00)([\.,]\d+(?!:))?)?(\17[0-5]\d([\.,]\d+)?)?\s?([zZ]|([\+-])([01]\d|2[0-3]):?([0-5]\d)?)?)?)?$/, parse : function (s) { var time, data = s.match(this.regex); if (!data || !data.length) { return null; } time = utils.buildTimeObjectFromData(data); if (!time.year || (!time.year && (!time.month && !time.day) && (!time.week && !time.dayOfYear)) ) { return null; } return $P.processTimeObject(time); } }; $P.Numeric = { isNumeric: function (e){return!isNaN(parseFloat(e))&&isFinite(e);}, regex: /\b([0-1]?[0-9])([0-3]?[0-9])([0-2]?[0-9]?[0-9][0-9])\b/i, parse: function (s) { var data, i, time = {}, order = Date.CultureInfo.dateElementOrder.split(""); if (!(this.isNumeric(s)) || // if it's non-numeric OR (s[0] === "+" && s[0] === "-")) { // It's an arithmatic string (eg +/-1000) return null; } if (s.length < 5 && s.indexOf(".") < 0 && s.indexOf("/") < 0) { // assume it's just a year. time.year = s; return $P.processTimeObject(time); } data = s.match(this.regex); if (!data || !data.length) { return null; } for (i=0; i < order.length; i++) { switch(order[i]) { case "d": time.day = data[i+1]; break; case "m": time.month = (data[i+1]-1); break; case "y": time.year = data[i+1]; break; } } return $P.processTimeObject(time); } }; $P.Normalizer = { regexData: function () { var $R = Date.CultureInfo.regexPatterns; return utils.buildRegexData([ $R.tomorrow, $R.yesterday, [$R.past, $R.mon], [$R.past, $R.tue], [$R.past, $R.wed], [$R.past, $R.thu], [$R.past, $R.fri], [$R.past, $R.sat], [$R.past, $R.sun] ]); }, basicReplaceHash : function() { var $R = Date.CultureInfo.regexPatterns; return { "January": $R.jan.source, "February": $R.feb, "March": $R.mar, "April": $R.apr, "May": $R.may, "June": $R.jun, "July": $R.jul, "August": $R.aug, "September": $R.sep, "October": $R.oct, "November": $R.nov, "December": $R.dec, "": /\bat\b/gi, " ": /\s{2,}/, "am": $R.inTheMorning, "9am": $R.thisMorning, "pm": $R.inTheEvening, "7pm":$R.thisEvening }; }, keys : function(){ return [ utils.getDateNthString(true, false, 1), // tomorrow utils.getDateNthString(true, false, -1), // yesterday utils.getDateNthString(false, true, "monday"), //last mon utils.getDateNthString(false, true, "tuesday"), //last tues utils.getDateNthString(false, true, "wednesday"), //last wed utils.getDateNthString(false, true, "thursday"), //last thurs utils.getDateNthString(false, true, "friday"), //last fri utils.getDateNthString(false, true, "saturday"), //last sat utils.getDateNthString(false, true, "sunday") //last sun ]; }, buildRegexFunctions: function () { var $R = Date.CultureInfo.regexPatterns; var __ = Date.i18n.__; var tomorrowRE = new RegExp("(\\b\\d\\d?("+__("AM")+"|"+__("PM")+")? )("+$R.tomorrow.source.slice(1)+")", "i"); // adapted tomorrow regex for AM PM relative dates var todayRE = new RegExp($R.today.source + "(?!\\s*([+-]))\\b"); // today, but excludes the math operators (eg "today + 2h") this.replaceFuncs = [ [todayRE, function (full) { return (full.length > 1) ? Date.today().toString("d") : full; }], [tomorrowRE, function(full, m1) { var t = Date.today().addDays(1).toString("d"); return (t + " " + m1); }], [$R.amThisMorning, function(str, am){return am;}], [$R.pmThisEvening, function(str, pm){return pm;}] ]; }, buildReplaceData: function () { this.buildRegexFunctions(); this.replaceHash = utils.addToHash(this.basicReplaceHash(), this.keys(), this.regexData()); }, stringReplaceFuncs: function (s) { for (var i=0; i < this.replaceFuncs.length; i++) { s = s.replace(this.replaceFuncs[i][0], this.replaceFuncs[i][1]); } return s; }, parse: function (s) { s = this.stringReplaceFuncs(s); s = utils.multiReplace(s, this.replaceHash); try { var n = s.split(/([\s\-\.\,\/\x27]+)/); if (n.length === 3 && $P.Numeric.isNumeric(n[0]) && $P.Numeric.isNumeric(n[2]) && (n[2].length >= 4)) { // ok, so we're dealing with x/year. But that's not a full date. // This fixes wonky dateElementOrder parsing when set to dmy order. if (Date.CultureInfo.dateElementOrder[0] === "d") { s = "1/" + n[0] + "/" + n[2]; // set to 1st of month and normalize the seperator } } } catch (e) {} return s; } }; $P.Normalizer.buildReplaceData(); }()); (function () { var $P = Date.Parsing; var _ = $P.Operators = { // // Tokenizers // rtoken: function (r) { // regex token return function (s) { var mx = s.match(r); if (mx) { return ([ mx[0], s.substring(mx[0].length) ]); } else { throw new $P.Exception(s); } }; }, token: function () { // whitespace-eating token return function (s) { return _.rtoken(new RegExp("^\\s*" + s + "\\s*"))(s); }; }, stoken: function (s) { // string token return _.rtoken(new RegExp("^" + s)); }, // Atomic Operators until: function (p) { return function (s) { var qx = [], rx = null; while (s.length) { try { rx = p.call(this, s); } catch (e) { qx.push(rx[0]); s = rx[1]; continue; } break; } return [ qx, s ]; }; }, many: function (p) { return function (s) { var rx = [], r = null; while (s.length) { try { r = p.call(this, s); } catch (e) { return [ rx, s ]; } rx.push(r[0]); s = r[1]; } return [ rx, s ]; }; }, // generator operators -- see below optional: function (p) { return function (s) { var r = null; try { r = p.call(this, s); } catch (e) { return [ null, s ]; } return [ r[0], r[1] ]; }; }, not: function (p) { return function (s) { try { p.call(this, s); } catch (e) { return [null, s]; } throw new $P.Exception(s); }; }, ignore: function (p) { return p ? function (s) { var r = null; r = p.call(this, s); return [null, r[1]]; } : null; }, product: function () { var px = arguments[0], qx = Array.prototype.slice.call(arguments, 1), rx = []; for (var i = 0 ; i < px.length ; i++) { rx.push(_.each(px[i], qx)); } return rx; }, cache: function (rule) { var cache = {}, cache_length = 0, cache_keys = [], CACHE_MAX = Date.Config.CACHE_MAX || 100000, r = null; var cacheCheck = function () { if (cache_length === CACHE_MAX) { // kill several keys, don't want to have to do this all the time... for (var i=0; i < 10; i++) { var key = cache_keys.shift(); if (key) { delete cache[key]; cache_length--; } } } }; return function (s) { cacheCheck(); try { r = cache[s] = (cache[s] || rule.call(this, s)); } catch (e) { r = cache[s] = e; } cache_length++; cache_keys.push(s); if (r instanceof $P.Exception) { throw r; } else { return r; } }; }, // vector operators -- see below any: function () { var px = arguments; return function (s) { var r = null; for (var i = 0; i < px.length; i++) { if (px[i] == null) { continue; } try { r = (px[i].call(this, s)); } catch (e) { r = null; } if (r) { return r; } } throw new $P.Exception(s); }; }, each: function () { var px = arguments; return function (s) { var rx = [], r = null; for (var i = 0; i < px.length ; i++) { if (px[i] == null) { continue; } try { r = (px[i].call(this, s)); } catch (e) { throw new $P.Exception(s); } rx.push(r[0]); s = r[1]; } return [ rx, s]; }; }, all: function () { var px = arguments, _ = _; return _.each(_.optional(px)); }, // delimited operators sequence: function (px, d, c) { d = d || _.rtoken(/^\s*/); c = c || null; if (px.length === 1) { return px[0]; } return function (s) { var r = null, q = null; var rx = []; for (var i = 0; i < px.length ; i++) { try { r = px[i].call(this, s); } catch (e) { break; } rx.push(r[0]); try { q = d.call(this, r[1]); } catch (ex) { q = null; break; } s = q[1]; } if (!r) { throw new $P.Exception(s); } if (q) { throw new $P.Exception(q[1]); } if (c) { try { r = c.call(this, r[1]); } catch (ey) { throw new $P.Exception(r[1]); } } return [ rx, (r?r[1]:s) ]; }; }, // // Composite Operators // between: function (d1, p, d2) { d2 = d2 || d1; var _fn = _.each(_.ignore(d1), p, _.ignore(d2)); return function (s) { var rx = _fn.call(this, s); return [[rx[0][0], r[0][2]], rx[1]]; }; }, list: function (p, d, c) { d = d || _.rtoken(/^\s*/); c = c || null; return (p instanceof Array ? _.each(_.product(p.slice(0, -1), _.ignore(d)), p.slice(-1), _.ignore(c)) : _.each(_.many(_.each(p, _.ignore(d))), px, _.ignore(c))); }, set: function (px, d, c) { d = d || _.rtoken(/^\s*/); c = c || null; return function (s) { // r is the current match, best the current 'best' match // which means it parsed the most amount of input var r = null, p = null, q = null, rx = null, best = [[], s], last = false; // go through the rules in the given set for (var i = 0; i < px.length ; i++) { // last is a flag indicating whether this must be the last element // if there is only 1 element, then it MUST be the last one q = null; p = null; r = null; last = (px.length === 1); // first, we try simply to match the current pattern // if not, try the next pattern try { r = px[i].call(this, s); } catch (e) { continue; } // since we are matching against a set of elements, the first // thing to do is to add r[0] to matched elements rx = [[r[0]], r[1]]; // if we matched and there is still input to parse and // we don't already know this is the last element, // we're going to next check for the delimiter ... // if there's none, or if there's no input left to parse // than this must be the last element after all ... if (r[1].length > 0 && ! last) { try { q = d.call(this, r[1]); } catch (ex) { last = true; } } else { last = true; } // if we parsed the delimiter and now there's no more input, // that means we shouldn't have parsed the delimiter at all // so don't update r and mark this as the last element ... if (!last && q[1].length === 0) { last = true; } // so, if this isn't the last element, we're going to see if // we can get any more matches from the remaining (unmatched) // elements ... if (!last) { // build a list of the remaining rules we can match against, // i.e., all but the one we just matched against var qx = []; for (var j = 0; j < px.length ; j++) { if (i !== j) { qx.push(px[j]); } } // now invoke recursively set with the remaining input // note that we don't include the closing delimiter ... // we'll check for that ourselves at the end p = _.set(qx, d).call(this, q[1]); // if we got a non-empty set as a result ... // (otw rx already contains everything we want to match) if (p[0].length > 0) { // update current result, which is stored in rx ... // basically, pick up the remaining text from p[1] // and concat the result from p[0] so that we don't // get endless nesting ... rx[0] = rx[0].concat(p[0]); rx[1] = p[1]; } } // at this point, rx either contains the last matched element // or the entire matched set that starts with this element. // now we just check to see if this variation is better than // our best so far, in terms of how much of the input is parsed if (rx[1].length < best[1].length) { best = rx; } // if we've parsed all the input, then we're finished if (best[1].length === 0) { break; } } // so now we've either gone through all the patterns trying them // as the initial match; or we found one that parsed the entire // input string ... // if best has no matches, just return empty set ... if (best[0].length === 0) { return best; } // if a closing delimiter is provided, then we have to check it also if (c) { // we try this even if there is no remaining input because the pattern // may well be optional or match empty input ... try { q = c.call(this, best[1]); } catch (ey) { throw new $P.Exception(best[1]); } // it parsed ... be sure to update the best match remaining input best[1] = q[1]; } // if we're here, either there was no closing delimiter or we parsed it // so now we have the best match; just return it! return best; }; }, forward: function (gr, fname) { return function (s) { return gr[fname].call(this, s); }; }, // // Translation Operators // replace: function (rule, repl) { return function (s) { var r = rule.call(this, s); return [repl, r[1]]; }; }, process: function (rule, fn) { return function (s) { var r = rule.call(this, s); return [fn.call(this, r[0]), r[1]]; }; }, min: function (min, rule) { return function (s) { var rx = rule.call(this, s); if (rx[0].length < min) { throw new $P.Exception(s); } return rx; }; } }; // Generator Operators And Vector Operators // Generators are operators that have a signature of F(R) => R, // taking a given rule and returning another rule, such as // ignore, which parses a given rule and throws away the result. // Vector operators are those that have a signature of F(R1,R2,...) => R, // take a list of rules and returning a new rule, such as each. // Generator operators are converted (via the following _generator // function) into functions that can also take a list or array of rules // and return an array of new rules as though the function had been // called on each rule in turn (which is what actually happens). // This allows generators to be used with vector operators more easily. // Example: // each(ignore(foo, bar)) instead of each(ignore(foo), ignore(bar)) // This also turns generators into vector operators, which allows // constructs like: // not(cache(foo, bar)) var _generator = function (op) { function gen() { var args = null, rx = [], px, i; if (arguments.length > 1) { args = Array.prototype.slice.call(arguments); } else if (arguments[0] instanceof Array) { args = arguments[0]; } if (args) { px = args.shift(); if (px.length > 0) { args.unshift(px[i]); rx.push(op.apply(null, args)); args.shift(); return rx; } } else { return op.apply(null, arguments); } } return gen; }; var gx = "optional not ignore cache".split(/\s/); for (var i = 0 ; i < gx.length ; i++) { _[gx[i]] = _generator(_[gx[i]]); } var _vector = function (op) { return function () { if (arguments[0] instanceof Array) { return op.apply(null, arguments[0]); } else { return op.apply(null, arguments); } }; }; var vx = "each any all".split(/\s/); for (var j = 0 ; j < vx.length ; j++) { _[vx[j]] = _vector(_[vx[j]]); } }()); (function () { var $D = Date; var flattenAndCompact = function (ax) { var rx = []; for (var i = 0; i < ax.length; i++) { if (ax[i] instanceof Array) { rx = rx.concat(flattenAndCompact(ax[i])); } else { if (ax[i]) { rx.push(ax[i]); } } } return rx; }; var parseMeridian = function () { if (this.meridian && (this.hour || this.hour === 0)) { if (this.meridian === "a" && this.hour > 11 && Date.Config.strict24hr){ throw "Invalid hour and meridian combination"; } else if (this.meridian === "p" && this.hour < 12 && Date.Config.strict24hr){ throw "Invalid hour and meridian combination"; } else if (this.meridian === "p" && this.hour < 12) { this.hour = this.hour + 12; } else if (this.meridian === "a" && this.hour === 12) { this.hour = 0; } } }; var setDefaults = function () { var now = new Date(); if ((this.hour || this.minute) && (!this.month && !this.year && !this.day)) { this.day = now.getDate(); } if (!this.year) { this.year = now.getFullYear(); } if (!this.month && this.month !== 0) { this.month = now.getMonth(); } if (!this.day) { this.day = 1; } if (!this.hour) { this.hour = 0; } if (!this.minute) { this.minute = 0; } if (!this.second) { this.second = 0; } if (!this.millisecond) { this.millisecond = 0; } }; var finishUtils = { getToday: function () { if (this.now || "hour minute second".indexOf(this.unit) !== -1) { return new Date(); } else { return $D.today(); } }, setDaysFromWeekday: function (today, orient){ var gap; orient = orient || 1; this.unit = "day"; gap = ($D.getDayNumberFromName(this.weekday) - today.getDay()); this.days = gap ? ((gap + (orient * 7)) % 7) : (orient * 7); return this; }, setMonthsFromMonth: function (today, orient) { var gap; orient = orient || 1; this.unit = "month"; gap = (this.month - today.getMonth()); this.months = gap ? ((gap + (orient * 12)) % 12) : (orient * 12); this.month = null; return this; }, setDMYFromWeekday: function () { var d = Date[this.weekday](); this.day = d.getDate(); if (!this.month) { this.month = d.getMonth(); } this.year = d.getFullYear(); return this; }, setUnitValue: function (orient) { if (!this.value && this.operator && this.operator !== null && this[this.unit + "s"] && this[this.unit + "s"] !== null) { this[this.unit + "s"] = this[this.unit + "s"] + ((this.operator === "add") ? 1 : -1) + (this.value||0) * orient; } else if (this[this.unit + "s"] == null || this.operator != null) { if (!this.value) { this.value = 1; } this[this.unit + "s"] = this.value * orient; } }, generateDateFromWeeks: function () { var weekday = (this.weekday !== undefined) ? this.weekday : "today"; var d = Date[weekday]().addWeeks(this.weeks); if (this.now) { d.setTimeToNow(); } return d; } }; $D.Translator = { hour: function (s) { return function () { this.hour = Number(s); }; }, minute: function (s) { return function () { this.minute = Number(s); }; }, second: function (s) { return function () { this.second = Number(s); }; }, /* for ss.s format */ secondAndMillisecond: function (s) { return function () { var mx = s.match(/^([0-5][0-9])\.([0-9]{1,3})/); this.second = Number(mx[1]); this.millisecond = Number(mx[2]); }; }, meridian: function (s) { return function () { this.meridian = s.slice(0, 1).toLowerCase(); }; }, timezone: function (s) { return function () { var n = s.replace(/[^\d\+\-]/g, ""); if (n.length) { this.timezoneOffset = Number(n); } else { this.timezone = s.toLowerCase(); } }; }, day: function (x) { var s = x[0]; return function () { this.day = Number(s.match(/\d+/)[0]); if (this.day < 1) { throw "invalid day"; } }; }, month: function (s) { return function () { this.month = (s.length === 3) ? "jan feb mar apr may jun jul aug sep oct nov dec".indexOf(s)/4 : Number(s) - 1; if (this.month < 0) { throw "invalid month"; } }; }, year: function (s) { return function () { var n = Number(s); this.year = ((s.length > 2) ? n : (n + (((n + 2000) < Date.CultureInfo.twoDigitYearMax) ? 2000 : 1900))); }; }, rday: function (s) { return function () { switch (s) { case "yesterday": this.days = -1; break; case "tomorrow": this.days = 1; break; case "today": this.days = 0; break; case "now": this.days = 0; this.now = true; break; } }; }, finishExact: function (x) { var d; x = (x instanceof Array) ? x : [x]; for (var i = 0 ; i < x.length ; i++) { if (x[i]) { x[i].call(this); } } setDefaults.call(this); parseMeridian.call(this); if (this.day > $D.getDaysInMonth(this.year, this.month)) { throw new RangeError(this.day + " is not a valid value for days."); } d = new Date(this.year, this.month, this.day, this.hour, this.minute, this.second, this.millisecond); if (this.year < 100) { d.setFullYear(this.year); // means years less that 100 are process correctly. JS will parse it otherwise as 1900-1999. } if (this.timezone) { d.set({ timezone: this.timezone }); } else if (this.timezoneOffset) { d.set({ timezoneOffset: this.timezoneOffset }); } return d; }, finish: function (x) { var today, expression, orient, temp; x = (x instanceof Array) ? flattenAndCompact(x) : [ x ]; if (x.length === 0) { return null; } for (var i = 0 ; i < x.length ; i++) { if (typeof x[i] === "function") { x[i].call(this); } } if (this.now && !this.unit && !this.operator) { return new Date(); } else { today = finishUtils.getToday.call(this); } expression = !!(this.days && this.days !== null || this.orient || this.operator); orient = ((this.orient === "past" || this.operator === "subtract") ? -1 : 1); if (this.month && this.unit === "week") { this.value = this.month + 1; delete this.month; delete this.day; } if ((this.month || this.month === 0) && "year day hour minute second".indexOf(this.unit) !== -1) { if (!this.value) { this.value = this.month + 1; } this.month = null; expression = true; } if (!expression && this.weekday && !this.day && !this.days) { finishUtils.setDMYFromWeekday.call(this); } if (expression && this.weekday && this.unit !== "month" && this.unit !== "week") { finishUtils.setDaysFromWeekday.call(this, today, orient); } if (this.weekday && this.unit !== "week" && !this.day && !this.days) { temp = Date[this.weekday](); this.day = temp.getDate(); if (temp.getMonth() !== today.getMonth()) { this.month = temp.getMonth(); } } if (this.month && this.unit === "day" && this.operator) { if (!this.value) { this.value = (this.month + 1); } this.month = null; } if (this.value != null && this.month != null && this.year != null) { this.day = this.value * 1; } if (this.month && !this.day && this.value) { today.set({ day: this.value * 1 }); if (!expression) { this.day = this.value * 1; } } if (!this.month && this.value && this.unit === "month" && !this.now) { this.month = this.value; expression = true; } if (expression && (this.month || this.month === 0) && this.unit !== "year") { finishUtils.setMonthsFromMonth.call(this, today, orient); } if (!this.unit) { this.unit = "day"; } finishUtils.setUnitValue.call(this, orient); parseMeridian.call(this); if ((this.month || this.month === 0) && !this.day) { this.day = 1; } if (!this.orient && !this.operator && this.unit === "week" && this.value && !this.day && !this.month) { return Date.today().setWeek(this.value); } if (this.unit === "week" && this.weeks && !this.day && !this.month) { return finishUtils.generateDateFromWeeks.call(this); } if (expression && this.timezone && this.day && this.days) { this.day = this.days; } if (expression){ today.add(this); } else { today.set(this); } if (this.timezone) { this.timezone = this.timezone.toUpperCase(); var offset = $D.getTimezoneOffset(this.timezone); var timezone; if (today.hasDaylightSavingTime()) { // lets check that we're being sane with timezone setting timezone = $D.getTimezoneAbbreviation(offset, today.isDaylightSavingTime()); if (timezone !== this.timezone) { // bugger, we're in a place where things like EST vs EDT matters. if (today.isDaylightSavingTime()) { today.addHours(-1); } else { today.addHours(1); } } } today.setTimezoneOffset(offset); } return today; } }; }()); (function () { var $D = Date; $D.Grammar = {}; var _ = $D.Parsing.Operators, g = $D.Grammar, t = $D.Translator, _fn; // Allow rolling up into general purpose rules _fn = function () { return _.each(_.any.apply(null, arguments), _.not(g.ctoken2("timeContext"))); }; g.datePartDelimiter = _.rtoken(/^([\s\-\.\,\/\x27]+)/); g.timePartDelimiter = _.stoken(":"); g.whiteSpace = _.rtoken(/^\s*/); g.generalDelimiter = _.rtoken(/^(([\s\,]|at|@|on)+)/); var _C = {}; g.ctoken = function (keys) { var fn = _C[keys]; if (! fn) { var c = Date.CultureInfo.regexPatterns; var kx = keys.split(/\s+/), px = []; for (var i = 0; i < kx.length ; i++) { px.push(_.replace(_.rtoken(c[kx[i]]), kx[i])); } fn = _C[keys] = _.any.apply(null, px); } return fn; }; g.ctoken2 = function (key) { return _.rtoken(Date.CultureInfo.regexPatterns[key]); }; var cacheProcessRtoken = function (key, token, type, eachToken) { if (eachToken) { g[key] = _.cache(_.process(_.each(_.rtoken(token),_.optional(g.ctoken2(eachToken))), type)); } else { g[key] = _.cache(_.process(_.rtoken(token), type)); } }; var cacheProcessCtoken = function (token, type) { return _.cache(_.process(g.ctoken2(token), type)); }; var _F = {}; //function cache var _get = function (f) { _F[f] = (_F[f] || g.format(f)[0]); return _F[f]; }; g.allformats = function (fx) { var rx = []; if (fx instanceof Array) { for (var i = 0; i < fx.length; i++) { rx.push(_get(fx[i])); } } else { rx.push(_get(fx)); } return rx; }; g.formats = function (fx) { if (fx instanceof Array) { var rx = []; for (var i = 0 ; i < fx.length ; i++) { rx.push(_get(fx[i])); } return _.any.apply(null, rx); } else { return _get(fx); } }; var grammarFormats = { timeFormats: function(){ var i, RTokenKeys = [ "h", "hh", "H", "HH", "m", "mm", "s", "ss", "ss.s", "z", "zz" ], RToken = [ /^(0[0-9]|1[0-2]|[1-9])/, /^(0[0-9]|1[0-2])/, /^([0-1][0-9]|2[0-3]|[0-9])/, /^([0-1][0-9]|2[0-3])/, /^([0-5][0-9]|[0-9])/, /^[0-5][0-9]/, /^([0-5][0-9]|[0-9])/, /^[0-5][0-9]/, /^[0-5][0-9]\.[0-9]{1,3}/, /^((\+|\-)\s*\d\d\d\d)|((\+|\-)\d\d\:?\d\d)/, /^((\+|\-)\s*\d\d\d\d)|((\+|\-)\d\d\:?\d\d)/ ], tokens = [ t.hour, t.hour, t.hour, t.hour, t.minute, t.minute, t.second, t.second, t.secondAndMillisecond, t.timezone, t.timezone ]; for (i=0; i < RTokenKeys.length; i++) { cacheProcessRtoken(RTokenKeys[i], RToken[i], tokens[i]); } g.hms = _.cache(_.sequence([g.H, g.m, g.s], g.timePartDelimiter)); g.t = cacheProcessCtoken("shortMeridian", t.meridian); g.tt = cacheProcessCtoken("longMeridian", t.meridian); g.zzz = cacheProcessCtoken("timezone", t.timezone); g.timeSuffix = _.each(_.ignore(g.whiteSpace), _.set([ g.tt, g.zzz ])); g.time = _.each(_.optional(_.ignore(_.stoken("T"))), g.hms, g.timeSuffix); }, dateFormats: function () { // pre-loaded rules for different date part order preferences var _setfn = function () { return _.set(arguments, g.datePartDelimiter); }; var i, RTokenKeys = [ "d", "dd", "M", "MM", "y", "yy", "yyy", "yyyy" ], RToken = [ /^([0-2]\d|3[0-1]|\d)/, /^([0-2]\d|3[0-1])/, /^(1[0-2]|0\d|\d)/, /^(1[0-2]|0\d)/, /^(\d+)/, /^(\d\d)/, /^(\d\d?\d?\d?)/, /^(\d\d\d\d)/ ], tokens = [ t.day, t.day, t.month, t.month, t.year, t.year, t.year, t.year ], eachToken = [ "ordinalSuffix", "ordinalSuffix" ]; for (i=0; i < RTokenKeys.length; i++) { cacheProcessRtoken(RTokenKeys[i], RToken[i], tokens[i], eachToken[i]); } g.MMM = g.MMMM = _.cache(_.process(g.ctoken("jan feb mar apr may jun jul aug sep oct nov dec"), t.month)); g.ddd = g.dddd = _.cache(_.process(g.ctoken("sun mon tue wed thu fri sat"), function (s) { return function () { this.weekday = s; }; } )); g.day = _fn(g.d, g.dd); g.month = _fn(g.M, g.MMM); g.year = _fn(g.yyyy, g.yy); g.mdy = _setfn(g.ddd, g.month, g.day, g.year); g.ymd = _setfn(g.ddd, g.year, g.month, g.day); g.dmy = _setfn(g.ddd, g.day, g.month, g.year); g.date = function (s) { return ((g[Date.CultureInfo.dateElementOrder] || g.mdy).call(this, s)); }; }, relative: function () { // relative date / time expressions g.orientation = _.process(g.ctoken("past future"), function (s) { return function () { this.orient = s; }; } ); g.operator = _.process(g.ctoken("add subtract"), function (s) { return function () { this.operator = s; }; } ); g.rday = _.process(g.ctoken("yesterday tomorrow today now"), t.rday); g.unit = _.process(g.ctoken("second minute hour day week month year"), function (s) { return function () { this.unit = s; }; } ); } }; g.buildGrammarFormats = function () { // these need to be rebuilt every time the language changes. _C = {}; grammarFormats.timeFormats(); grammarFormats.dateFormats(); grammarFormats.relative(); g.value = _.process(_.rtoken(/^([-+]?\d+)?(st|nd|rd|th)?/), function (s) { return function () { this.value = s.replace(/\D/g, ""); }; } ); g.expression = _.set([g.rday, g.operator, g.value, g.unit, g.orientation, g.ddd, g.MMM ]); g.format = _.process(_.many( _.any( // translate format specifiers into grammar rules _.process( _.rtoken(/^(dd?d?d?(?!e)|MM?M?M?|yy?y?y?|hh?|HH?|mm?|ss?|tt?|zz?z?)/), function (fmt) { if (g[fmt]) { return g[fmt]; } else { throw $D.Parsing.Exception(fmt); } } ), // translate separator tokens into token rules _.process(_.rtoken(/^[^dMyhHmstz]+/), // all legal separators function (s) { return _.ignore(_.stoken(s)); } ) ) ), // construct the parser ... function (rules) { return _.process(_.each.apply(null, rules), t.finishExact); } ); // starting rule for general purpose grammar g._start = _.process(_.set([ g.date, g.time, g.expression ], g.generalDelimiter, g.whiteSpace), t.finish); }; g.buildGrammarFormats(); // parsing date format specifiers - ex: "h:m:s tt" // this little guy will generate a custom parser based // on the format string, ex: g.format("h:m:s tt") // check for these formats first g._formats = g.formats([ "\"yyyy-MM-ddTHH:mm:ssZ\"", "yyyy-MM-ddTHH:mm:ss.sz", "yyyy-MM-ddTHH:mm:ssZ", "yyyy-MM-ddTHH:mm:ssz", "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-ddTHH:mmZ", "yyyy-MM-ddTHH:mmz", "yyyy-MM-ddTHH:mm", "ddd, MMM dd, yyyy H:mm:ss tt", "ddd MMM d yyyy HH:mm:ss zzz", "MMddyyyy", "ddMMyyyy", "Mddyyyy", "ddMyyyy", "Mdyyyy", "dMyyyy", "yyyy", "Mdyy", "dMyy", "d" ]); // real starting rule: tries selected formats first, // then general purpose rule g.start = function (s) { try { var r = g._formats.call({}, s); if (r[1].length === 0) { return r; } } catch (e) {} return g._start.call({}, s); }; }()); (function () { var $D = Date; /** * @desc Converts the specified string value into its JavaScript Date equivalent using CultureInfo specific format information. * * Example

	///////////
	// Dates //
	///////////

	// 15-Oct-2004
	var d1 = Date.parse("10/15/2004");

	// 15-Oct-2004
	var d1 = Date.parse("15-Oct-2004");

	// 15-Oct-2004
	var d1 = Date.parse("2004.10.15");

	//Fri Oct 15, 2004
	var d1 = Date.parse("Fri Oct 15, 2004");

	///////////
	// Times //
	///////////

	// Today at 10 PM.
	var d1 = Date.parse("10 PM");

	// Today at 10:30 PM.
	var d1 = Date.parse("10:30 P.M.");

	// Today at 6 AM.
	var d1 = Date.parse("06am");

	/////////////////////
	// Dates and Times //
	/////////////////////

	// 8-July-2004 @ 10:30 PM
	var d1 = Date.parse("July 8th, 2004, 10:30 PM");

	// 1-July-2004 @ 10:30 PM
	var d1 = Date.parse("2004-07-01T22:30:00");

	////////////////////
	// Relative Dates //
	////////////////////

	// Returns today's date. The string "today" is culture specific.
	var d1 = Date.parse("today");

	// Returns yesterday's date. The string "yesterday" is culture specific.
	var d1 = Date.parse("yesterday");

	// Returns the date of the next thursday.
	var d1 = Date.parse("Next thursday");

	// Returns the date of the most previous monday.
	var d1 = Date.parse("last monday");

	// Returns today's day + one year.
	var d1 = Date.parse("next year");

	///////////////
	// Date Math //
	///////////////

	// Today + 2 days
	var d1 = Date.parse("t+2");

	// Today + 2 days
	var d1 = Date.parse("today + 2 days");

	// Today + 3 months
	var d1 = Date.parse("t+3m");

	// Today - 1 year
	var d1 = Date.parse("today - 1 year");

	// Today - 1 year
	var d1 = Date.parse("t-1y"); 


	/////////////////////////////
	// Partial Dates and Times //
	/////////////////////////////

	// July 15th of this year.
	var d1 = Date.parse("July 15");

	// 15th day of current day and year.
	var d1 = Date.parse("15");

	// July 1st of current year at 10pm.
	var d1 = Date.parse("7/1 10pm");
	
* * @param {String} The string value to convert into a Date object [Required] * @return {Date} A Date object or null if the string cannot be converted into a Date. */ var parseUtils = { removeOrds: function (s) { ords = s.match(/\b(\d+)(?:st|nd|rd|th)\b/); // find ordinal matches s = ((ords && ords.length === 2) ? s.replace(ords[0], ords[1]) : s); return s; }, grammarParser: function (s) { var r = null; try { r = $D.Grammar.start.call({}, s.replace(/^\s*(\S*(\s+\S+)*)\s*$/, "$1")); } catch (e) { return null; } return ((r[1].length === 0) ? r[0] : null); }, nativeFallback: function(s) { var t; try { // ok we haven't parsed it, last ditch attempt with the built-in parser. t = Date._parse(s); return (t || t === 0) ? new Date(t) : null; } catch (e) { return null; } } }; function parse (s) { var d; if (!s) { return null; } if (s instanceof Date) { return s.clone(); } if (s.length >= 4 && s.charAt(0) !== "0" && s.charAt(0) !== "+"&& s.charAt(0) !== "-") { // ie: 2004 will pass, 0800 won't. // Start with specific formats d = $D.Parsing.ISO.parse(s) || $D.Parsing.Numeric.parse(s); } if (d instanceof Date && !isNaN(d.getTime())) { return d; } else { // find ordinal dates (1st, 3rd, 8th, etc and remove them as they cause parsing issues) s = $D.Parsing.Normalizer.parse(parseUtils.removeOrds(s)); d = parseUtils.grammarParser(s); if (d !== null) { return d; } else { return parseUtils.nativeFallback(s); } } } if (!$D._parse) { $D._parse = $D.parse; } $D.parse = parse; Date.getParseFunction = function (fx) { var fns = Date.Grammar.allformats(fx); return function (s) { var r = null; for (var i = 0; i < fns.length; i++) { try { r = fns[i].call({}, s); } catch (e) { continue; } if (r[1].length === 0) { return r[0]; } } return null; }; }; /** * Converts the specified string value into its JavaScript Date equivalent using the specified format {String} or formats {Array} and the CultureInfo specific format information. * The format of the string value must match one of the supplied formats exactly. * * Example

	// 15-Oct-2004
	var d1 = Date.parseExact("10/15/2004", "M/d/yyyy");

	// 15-Oct-2004
	var d1 = Date.parse("15-Oct-2004", "M-ddd-yyyy");

	// 15-Oct-2004
	var d1 = Date.parse("2004.10.15", "yyyy.MM.dd");

	// Multiple formats
	var d1 = Date.parseExact("10/15/2004", ["M/d/yyyy", "MMMM d, yyyy"]);
	
* * @param {String} The string value to convert into a Date object [Required]. * @param {Object} The expected format {String} or an array of expected formats {Array} of the date string [Required]. * @return {Date} A Date object or null if the string cannot be converted into a Date. */ $D.parseExact = function (s, fx) { return $D.getParseFunction(fx)(s); }; }()); (function () { var $D = Date, $P = $D.prototype, // $C = $D.CultureInfo, // not used atm p = function (s, l) { if (!l) { l = 2; } return ("000" + s).slice(l * -1); }; /** * Converts a PHP format string to Java/.NET format string. * A PHP format string can be used with ._format or .format. * A Java/.NET format string can be used with .toString(). * The .parseExact function will only accept a Java/.NET format string * * Example * var f1 = "%m/%d/%y" * var f2 = Date.normalizeFormat(f1); // "MM/dd/yy" * * new Date().format(f1); // "04/13/08" * new Date()._format(f1); // "04/13/08" * new Date().toString(f2); // "04/13/08" * * var date = Date.parseExact("04/13/08", f2); // Sun Apr 13 2008 * * @param {String} A PHP format string consisting of one or more format spcifiers. * @return {String} The PHP format converted to a Java/.NET format string. */ var normalizerSubstitutions = { "d" : "dd", "%d": "dd", "D" : "ddd", "%a": "ddd", "j" : "dddd", "l" : "dddd", "%A": "dddd", "S" : "S", "F" : "MMMM", "%B": "MMMM", "m" : "MM", "%m": "MM", "M" : "MMM", "%b": "MMM", "%h": "MMM", "n" : "M", "Y" : "yyyy", "%Y": "yyyy", "y" : "yy", "%y": "yy", "g" : "h", "%I": "h", "G" : "H", "h" : "hh", "H" : "HH", "%H": "HH", "i" : "mm", "%M": "mm", "s" : "ss", "%S": "ss", "%r": "hh:mm tt", "%R": "H:mm", "%T": "H:mm:ss", "%X": "t", "%x": "d", "%e": "d", "%D": "MM/dd/yy", "%n": "\\n", "%t": "\\t", "e" : "z", "T" : "z", "%z": "z", "%Z": "z", "Z" : "ZZ", "N" : "u", "w" : "u", "%w": "u", "W" : "W", "%V": "W" }; var normalizer = { substitutes: function (m) { return normalizerSubstitutions[m]; }, interpreted: function (m, x) { var y; switch (m) { case "%u": return x.getDay() + 1; case "z": return x.getOrdinalNumber(); case "%j": return p(x.getOrdinalNumber(), 3); case "%U": var d1 = x.clone().set({month: 0, day: 1}).addDays(-1).moveToDayOfWeek(0), d2 = x.clone().addDays(1).moveToDayOfWeek(0, -1); return (d2 < d1) ? "00" : p((d2.getOrdinalNumber() - d1.getOrdinalNumber()) / 7 + 1); case "%W": return p(x.getWeek()); case "t": return $D.getDaysInMonth(x.getFullYear(), x.getMonth()); case "o": case "%G": return x.setWeek(x.getISOWeek()).toString("yyyy"); case "%g": return x._format("%G").slice(-2); case "a": case "%p": return t("tt").toLowerCase(); case "A": return t("tt").toUpperCase(); case "u": return p(x.getMilliseconds(), 3); case "I": return (x.isDaylightSavingTime()) ? 1 : 0; case "O": return x.getUTCOffset(); case "P": y = x.getUTCOffset(); return y.substring(0, y.length - 2) + ":" + y.substring(y.length - 2); case "B": var now = new Date(); return Math.floor(((now.getHours() * 3600) + (now.getMinutes() * 60) + now.getSeconds() + (now.getTimezoneOffset() + 60) * 60) / 86.4); case "c": return x.toISOString().replace(/\"/g, ""); case "U": return $D.strtotime("now"); case "%c": return t("d") + " " + t("t"); case "%C": return Math.floor(x.getFullYear() / 100 + 1); } }, shouldOverrideDefaults: function (m) { switch (m) { case "%e": return true; default: return false; } }, parse: function (m, context) { var formatString, c = context || new Date(); formatString = normalizer.substitutes(m); if (formatString) { return formatString; } formatString = normalizer.interpreted(m, c); if (formatString) { return formatString; } else { return m; } } }; $D.normalizeFormat = function (format, context) { return format.replace(/(%|\\)?.|%%/g, function(t){ return normalizer.parse(t, context); }); }; /** * Format a local Unix timestamp according to locale settings * * Example: * Date.strftime("%m/%d/%y", new Date()); // "04/13/08" * Date.strftime("c", "2008-04-13T17:52:03Z"); // "04/13/08" * * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @param {Number|String} The number representing the number of seconds that have elapsed since January 1, 1970 (local time). * @return {String} A string representation of the current Date object. */ $D.strftime = function (format, time) { var d = Date.parse(time); return d._format(format); }; /** * Parse any textual datetime description into a Unix timestamp. * A Unix timestamp is the number of seconds that have elapsed since January 1, 1970 (midnight UTC/GMT). * * Example: * Date.strtotime("04/13/08"); // 1208044800 * Date.strtotime("1970-01-01T00:00:00Z"); // 0 * * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @param {Object} A string or date object. * @return {String} A string representation of the current Date object. */ $D.strtotime = function (time) { var d = $D.parse(time); return Math.round($D.UTC(d.getUTCFullYear(), d.getUTCMonth(), d.getUTCDate(), d.getUTCHours(), d.getUTCMinutes(), d.getUTCSeconds(), d.getUTCMilliseconds()) / 1000); }; /** * Converts the value of the current Date object to its equivalent string representation using a PHP/Unix style of date format specifiers. * Format Specifiers * Format Description Example * ------ --------------------------------------------------------------------------- ----------------------- * %a abbreviated weekday name according to the current localed "Mon" through "Sun" * %A full weekday name according to the current localed "Sunday" through "Saturday" * %b abbreviated month name according to the current localed "Jan" through "Dec" * %B full month name according to the current locale "January" through "December" * %c preferred date and time representation for the current locale "4/13/2008 12:33 PM" * %C century number (the year divided by 100 and truncated to an integer) "00" to "99" * %d day of the month as a decimal number "01" to "31" * %D same as %m/%d/%y "04/13/08" * %e day of the month as a decimal number, a single digit is preceded by a space "1" to "31" * %g like %G, but without the century "08" * %G The 4-digit year corresponding to the ISO week number (see %V). "2008" * This has the same format and value as %Y, except that if the ISO week number * belongs to the previous or next year, that year is used instead. * %h same as %b "Jan" through "Dec" * %H hour as a decimal number using a 24-hour clock. "00" to "23" * %I hour as a decimal number using a 12-hour clock. "01" to "12" * %j day of the year as a decimal number. "001" to "366" * %m month as a decimal number. "01" to "12" * %M minute as a decimal number. "00" to "59" * %n newline character "\n" * %p either "am" or "pm" according to the given time value, or the "am" or "pm" * corresponding strings for the current locale. * %r time in a.m. and p.m. notation "8:44 PM" * %R time in 24 hour notation "20:44" * %S second as a decimal number "00" to "59" * %t tab character "\t" * %T current time, equal to %H:%M:%S "12:49:11" * %u weekday as a decimal number ["1", "7"], with "1" representing Monday "1" to "7" * %U week number of the current year as a decimal number, starting with the "0" to ("52" or "53") * first Sunday as the first day of the first week * %V The ISO 8601:1988 week number of the current year as a decimal number, "00" to ("52" or "53") * range 01 to 53, where week 1 is the first week that has at least 4 days * in the current year, and with Monday as the first day of the week. * (Use %G or %g for the year component that corresponds to the week number * for the specified timestamp.) * %W week number of the current year as a decimal number, starting with the "00" to ("52" or "53") * first Monday as the first day of the first week * %w day of the week as a decimal, Sunday being "0" "0" to "6" * %x preferred date representation for the current locale without the time "4/13/2008" * %X preferred time representation for the current locale without the date "12:53:05" * %y year as a decimal number without a century "00" "99" * %Y year as a decimal number including the century "2008" * %Z time zone or name or abbreviation "UTC", "EST", "PST" * %z same as %Z * %% a literal "%" characters "%" * d Day of the month, 2 digits with leading zeros "01" to "31" * D A textual representation of a day, three letters "Mon" through "Sun" * j Day of the month without leading zeros "1" to "31" * l A full textual representation of the day of the week (lowercase "L") "Sunday" through "Saturday" * N ISO-8601 numeric representation of the day of the week (added in PHP 5.1.0) "1" (for Monday) through "7" (for Sunday) * S English ordinal suffix for the day of the month, 2 characters "st", "nd", "rd" or "th". Works well with j * w Numeric representation of the day of the week "0" (for Sunday) through "6" (for Saturday) * z The day of the year (starting from "0") "0" through "365" * W ISO-8601 week number of year, weeks starting on Monday "00" to ("52" or "53") * F A full textual representation of a month, such as January or March "January" through "December" * m Numeric representation of a month, with leading zeros "01" through "12" * M A short textual representation of a month, three letters "Jan" through "Dec" * n Numeric representation of a month, without leading zeros "1" through "12" * t Number of days in the given month "28" through "31" * L Whether it's a leap year "1" if it is a leap year, "0" otherwise * o ISO-8601 year number. This has the same value as Y, except that if the "2008" * ISO week number (W) belongs to the previous or next year, that year * is used instead. * Y A full numeric representation of a year, 4 digits "2008" * y A two digit representation of a year "08" * a Lowercase Ante meridiem and Post meridiem "am" or "pm" * A Uppercase Ante meridiem and Post meridiem "AM" or "PM" * B Swatch Internet time "000" through "999" * g 12-hour format of an hour without leading zeros "1" through "12" * G 24-hour format of an hour without leading zeros "0" through "23" * h 12-hour format of an hour with leading zeros "01" through "12" * H 24-hour format of an hour with leading zeros "00" through "23" * i Minutes with leading zeros "00" to "59" * s Seconds, with leading zeros "00" through "59" * u Milliseconds "54321" * e Timezone identifier "UTC", "EST", "PST" * I Whether or not the date is in daylight saving time (uppercase i) "1" if Daylight Saving Time, "0" otherwise * O Difference to Greenwich time (GMT) in hours "+0200", "-0600" * P Difference to Greenwich time (GMT) with colon between hours and minutes "+02:00", "-06:00" * T Timezone abbreviation "UTC", "EST", "PST" * Z Timezone offset in seconds. The offset for timezones west of UTC is "-43200" through "50400" * always negative, and for those east of UTC is always positive. * c ISO 8601 date "2004-02-12T15:19:21+00:00" * r RFC 2822 formatted date "Thu, 21 Dec 2000 16:01:07 +0200" * U Seconds since the Unix Epoch (January 1 1970 00:00:00 GMT) "0" * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @return {String} A string representation of the current Date object. */ var formatReplace = function (context) { return function (m) { var formatString, override = false; if (m.charAt(0) === "\\" || m.substring(0, 2) === "%%") { return m.replace("\\", "").replace("%%", "%"); } override = normalizer.shouldOverrideDefaults(m); formatString = $D.normalizeFormat(m, context); if (formatString) { return context.toString(formatString, override); } }; }; $P._format = function (format) { var formatter = formatReplace(this); if (!format) { return this._toString(); } else { return format.replace(/(%|\\)?.|%%/g, formatter); } }; if (!$P.format) { $P.format = $P._format; } }()); (function () { "use strict"; var gFn = function (attr) { return function () { return this[attr]; }; }; var sFn = function (attr) { return function (val) { this[attr] = val; return this; }; }; var attrs = ["years", "months", "days", "hours", "minutes", "seconds", "milliseconds"]; var addSetFuncs = function (context, attrs) { for (var i = 0; i < attrs.length ; i++) { var $a = attrs[i], $b = $a.slice(0, 1).toUpperCase() + $a.slice(1); context.prototype[$a] = 0; context.prototype["get" + $b] = gFn($a); context.prototype["set" + $b] = sFn($a); } }; /** * new TimeSpan(milliseconds); * new TimeSpan(days, hours, minutes, seconds); * new TimeSpan(days, hours, minutes, seconds, milliseconds); */ var TimeSpan = function (days, hours, minutes, seconds, milliseconds) { if (arguments.length === 1 && typeof days === "number") { var orient = (days < 0) ? -1 : +1; var millsLeft = Math.abs(days); this.setDays(Math.floor(millsLeft / 86400000) * orient); millsLeft = millsLeft % 86400000; this.setHours(Math.floor(millsLeft / 3600000) * orient); millsLeft = millsLeft % 3600000; this.setMinutes(Math.floor(millsLeft / 60000) * orient); millsLeft = millsLeft % 60000; this.setSeconds(Math.floor(millsLeft / 1000) * orient); millsLeft = millsLeft % 1000; this.setMilliseconds(millsLeft * orient); } else { this.set(days, hours, minutes, seconds, milliseconds); } this.getTotalMilliseconds = function () { return (this.getDays() * 86400000) + (this.getHours() * 3600000) + (this.getMinutes() * 60000) + (this.getSeconds() * 1000); }; this.compareTo = function (time) { var t1 = new Date(1970, 1, 1, this.getHours(), this.getMinutes(), this.getSeconds()), t2; if (time === null) { t2 = new Date(1970, 1, 1, 0, 0, 0); } else { t2 = new Date(1970, 1, 1, time.getHours(), time.getMinutes(), time.getSeconds()); } return (t1 < t2) ? -1 : (t1 > t2) ? 1 : 0; }; this.equals = function (time) { return (this.compareTo(time) === 0); }; this.add = function (time) { return (time === null) ? this : this.addSeconds(time.getTotalMilliseconds() / 1000); }; this.subtract = function (time) { return (time === null) ? this : this.addSeconds(-time.getTotalMilliseconds() / 1000); }; this.addDays = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 86400000)); }; this.addHours = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 3600000)); }; this.addMinutes = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 60000)); }; this.addSeconds = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 1000)); }; this.addMilliseconds = function (n) { return new TimeSpan(this.getTotalMilliseconds() + n); }; this.get12HourHour = function () { return (this.getHours() > 12) ? this.getHours() - 12 : (this.getHours() === 0) ? 12 : this.getHours(); }; this.getDesignator = function () { return (this.getHours() < 12) ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator; }; this.toString = function (format) { this._toString = function () { if (this.getDays() !== null && this.getDays() > 0) { return this.getDays() + "." + this.getHours() + ":" + this.p(this.getMinutes()) + ":" + this.p(this.getSeconds()); } else { return this.getHours() + ":" + this.p(this.getMinutes()) + ":" + this.p(this.getSeconds()); } }; this.p = function (s) { return (s.toString().length < 2) ? "0" + s : s; }; var me = this; return format ? format.replace(/dd?|HH?|hh?|mm?|ss?|tt?/g, function (format) { switch (format) { case "d": return me.getDays(); case "dd": return me.p(me.getDays()); case "H": return me.getHours(); case "HH": return me.p(me.getHours()); case "h": return me.get12HourHour(); case "hh": return me.p(me.get12HourHour()); case "m": return me.getMinutes(); case "mm": return me.p(me.getMinutes()); case "s": return me.getSeconds(); case "ss": return me.p(me.getSeconds()); case "t": return ((me.getHours() < 12) ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator).substring(0, 1); case "tt": return (me.getHours() < 12) ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator; } } ) : this._toString(); }; return this; }; addSetFuncs(TimeSpan, attrs.slice(2)); TimeSpan.prototype.set = function (days, hours, minutes, seconds, milliseconds){ this.setDays(days || this.getDays()); this.setHours(hours || this.getHours()); this.setMinutes(minutes || this.getMinutes()); this.setSeconds(seconds || this.getSeconds()); this.setMilliseconds(milliseconds || this.getMilliseconds()); }; /** * Gets the time of day for this date instances. * @return {TimeSpan} TimeSpan */ Date.prototype.getTimeOfDay = function () { return new TimeSpan(0, this.getHours(), this.getMinutes(), this.getSeconds(), this.getMilliseconds()); }; Date.TimeSpan = TimeSpan; if (typeof window !== "undefined" ) { // keeping API compatible for v1.x window.TimeSpan = TimeSpan; } }()); (function () { "use strict"; var attrs = ["years", "months", "days", "hours", "minutes", "seconds", "milliseconds"]; var gFn = function (attr) { return function () { return this[attr]; }; }; var sFn = function (attr) { return function (val) { this[attr] = val; return this; }; }; var addSetFuncs = function (context, attrs) { for (var i = 0; i < attrs.length ; i++) { var $a = attrs[i], $b = $a.slice(0, 1).toUpperCase() + $a.slice(1); context.prototype[$a] = 0; context.prototype["get" + $b] = gFn($a); context.prototype["set" + $b] = sFn($a); } }; var setMonthsAndYears = function (orient, d1, d2, context) { function inc() { d1.addMonths(-orient); context.months++; if (context.months === 12) { context.years++; context.months = 0; } } if (orient === +1) { while (d1 > d2) { inc(); } } else { while (d1 < d2) { inc(); } } context.months--; context.months *= orient; context.years *= orient; }; var adjustForDST = function(orient, startDate, endDate) { var hasDSTMismatch = (false === (startDate.isDaylightSavingTime() === endDate.isDaylightSavingTime())); if (hasDSTMismatch && orient === 1) { startDate.addHours(-1); } else if (hasDSTMismatch) { startDate.addHours(1); } }; /** * TimePeriod(startDate, endDate); * TimePeriod(years, months, days, hours, minutes, seconds, milliseconds); */ var TimePeriod = function (years, months, days, hours, minutes, seconds, milliseconds) { if (arguments.length === 7) { this.set(years, months, days, hours, minutes, seconds, milliseconds); } else if (arguments.length === 2 && arguments[0] instanceof Date && arguments[1] instanceof Date) { var startDate = arguments[0].clone(); var endDate = arguments[1].clone(); var orient = (startDate > endDate) ? +1 : -1; this.dates = { start: arguments[0].clone(), end: arguments[1].clone() }; setMonthsAndYears(orient, startDate, endDate, this); adjustForDST(orient, startDate, endDate); // // TODO - adjust for DST var diff = endDate - startDate; if (diff !== 0) { var ts = new TimeSpan(diff); this.set(this.years, this.months, ts.getDays(), ts.getHours(), ts.getMinutes(), ts.getSeconds(), ts.getMilliseconds()); } } return this; }; // create all the set functions. addSetFuncs(TimePeriod, attrs); TimePeriod.prototype.set = function (years, months, days, hours, minutes, seconds, milliseconds){ this.setYears(years || this.getYears()); this.setMonths(months || this.getMonths()); this.setDays(days || this.getDays()); this.setHours(hours || this.getHours()); this.setMinutes(minutes || this.getMinutes()); this.setSeconds(seconds || this.getSeconds()); this.setMilliseconds(milliseconds || this.getMilliseconds()); }; Date.TimePeriod = TimePeriod; if (typeof window !== "undefined") { // keeping API compatible for v1.x window.TimePeriod = TimePeriod; } }()); ================================================ FILE: build/date-fo-FO.js ================================================ /** * @overview datejs * @version 1.0.0-rc3 * @author Gregory Wild-Smith * @copyright 2015 Gregory Wild-Smith * @license MIT * @homepage https://github.com/abritinthebay/datejs */ /* * DateJS Culture String File * Country Code: fo-FO * Name: Faroese (Faroe Islands) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["fo-FO"] = { "name": "fo-FO", "englishName": "Faroese (Faroe Islands)", "nativeName": "føroyskt (Føroyar)", "Sunday": "sunnudagur", "Monday": "mánadagur", "Tuesday": "týsdagur", "Wednesday": "mikudagur", "Thursday": "hósdagur", "Friday": "fríggjadagur", "Saturday": "leygardagur", "Sun": "sun", "Mon": "mán", "Tue": "týs", "Wed": "mik", "Thu": "hós", "Fri": "frí", "Sat": "leyg", "Su": "su", "Mo": "má", "Tu": "tý", "We": "mi", "Th": "hó", "Fr": "fr", "Sa": "ley", "S_Sun_Initial": "s", "M_Mon_Initial": "m", "T_Tue_Initial": "t", "W_Wed_Initial": "m", "T_Thu_Initial": "h", "F_Fri_Initial": "f", "S_Sat_Initial": "l", "January": "januar", "February": "februar", "March": "mars", "April": "apríl", "May": "mai", "June": "juni", "July": "juli", "August": "august", "September": "september", "October": "oktober", "November": "november", "December": "desember", "Jan_Abbr": "jan", "Feb_Abbr": "feb", "Mar_Abbr": "mar", "Apr_Abbr": "apr", "May_Abbr": "mai", "Jun_Abbr": "jun", "Jul_Abbr": "jul", "Aug_Abbr": "aug", "Sep_Abbr": "sep", "Oct_Abbr": "okt", "Nov_Abbr": "nov", "Dec_Abbr": "des", "AM": "", "PM": "", "firstDayOfWeek": 1, "twoDigitYearMax": 2029, "mdy": "dmy", "M/d/yyyy": "dd-MM-yyyy", "dddd, MMMM dd, yyyy": "d. MMMM yyyy", "h:mm tt": "HH.mm", "h:mm:ss tt": "HH.mm.ss", "dddd, MMMM dd, yyyy h:mm:ss tt": "d. MMMM yyyy HH.mm.ss", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "d. MMMM", "MMMM, yyyy": "MMMM yyyy", "/jan(uary)?/": "jan(uar)?", "/feb(ruary)?/": "feb(ruar)?", "/mar(ch)?/": "mar(s)?", "/apr(il)?/": "apr(íl)?", "/may/": "mai", "/jun(e)?/": "jun(i)?", "/jul(y)?/": "jul(i)?", "/aug(ust)?/": "aug(ust)?", "/sep(t(ember)?)?/": "sep(t(ember)?)?", "/oct(ober)?/": "okt(ober)?", "/nov(ember)?/": "nov(ember)?", "/dec(ember)?/": "des(ember)?", "/^su(n(day)?)?/": "^su(n(nudagur)?)?", "/^mo(n(day)?)?/": "^má(n(adagur)?)?", "/^tu(e(s(day)?)?)?/": "^tý(s(dagur)?)?", "/^we(d(nesday)?)?/": "^mi(k(udagur)?)?", "/^th(u(r(s(day)?)?)?)?/": "^hó(s(dagur)?)?", "/^fr(i(day)?)?/": "^fr(í(ggjadagur)?)?", "/^sa(t(urday)?)?/": "^ley(g(ardagur)?)?", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "fo-FO"; /** * @overview datejs * @version 1.0.0-rc3 * @author Gregory Wild-Smith * @copyright 2015 Gregory Wild-Smith * @license MIT * @homepage https://github.com/abritinthebay/datejs */(function () { var $D = Date; var lang = Date.CultureStrings ? Date.CultureStrings.lang : null; var loggedKeys = {}; // for debug purposes. var getText = { getFromKey: function (key, countryCode) { var output; if (Date.CultureStrings && Date.CultureStrings[countryCode] && Date.CultureStrings[countryCode][key]) { output = Date.CultureStrings[countryCode][key]; } else { output = getText.buildFromDefault(key); } if (key.charAt(0) === "/") { // Assume it's a regex output = getText.buildFromRegex(key, countryCode); } return output; }, getFromObjectValues: function (obj, countryCode) { var key, output = {}; for(key in obj) { if (obj.hasOwnProperty(key)) { output[key] = getText.getFromKey(obj[key], countryCode); } } return output; }, getFromObjectKeys: function (obj, countryCode) { var key, output = {}; for(key in obj) { if (obj.hasOwnProperty(key)) { output[getText.getFromKey(key, countryCode)] = obj[key]; } } return output; }, getFromArray: function (arr, countryCode) { var output = []; for (var i=0; i < arr.length; i++){ if (i in arr) { output[i] = getText.getFromKey(arr[i], countryCode); } } return output; }, buildFromDefault: function (key) { var output, length, split, last; switch(key) { case "name": output = "en-US"; break; case "englishName": output = "English (United States)"; break; case "nativeName": output = "English (United States)"; break; case "twoDigitYearMax": output = 2049; break; case "firstDayOfWeek": output = 0; break; default: output = key; split = key.split("_"); length = split.length; if (length > 1 && key.charAt(0) !== "/") { // if the key isn't a regex and it has a split. last = split[(length - 1)].toLowerCase(); if (last === "initial" || last === "abbr") { output = split[0]; } } break; } return output; }, buildFromRegex: function (key, countryCode) { var output; if (Date.CultureStrings && Date.CultureStrings[countryCode] && Date.CultureStrings[countryCode][key]) { output = new RegExp(Date.CultureStrings[countryCode][key], "i"); } else { output = new RegExp(key.replace(new RegExp("/", "g"),""), "i"); } return output; } }; var shallowMerge = function (obj1, obj2) { for (var attrname in obj2) { if (obj2.hasOwnProperty(attrname)) { obj1[attrname] = obj2[attrname]; } } }; var __ = function (key, language) { var countryCode = (language) ? language : lang; loggedKeys[key] = key; if (typeof key === "object") { if (key instanceof Array) { return getText.getFromArray(key, countryCode); } else { return getText.getFromObjectKeys(key, countryCode); } } else { return getText.getFromKey(key, countryCode); } }; var loadI18nScript = function (code) { // paatterned after jQuery's getScript. var url = Date.Config.i18n + code + ".js"; var head = document.getElementsByTagName("head")[0] || document.documentElement; var script = document.createElement("script"); script.src = url; var completed = false; var events = { done: function (){} // placeholder function }; // Attach handlers for all browsers script.onload = script.onreadystatechange = function() { if ( !completed && (!this.readyState || this.readyState === "loaded" || this.readyState === "complete") ) { events.done(); head.removeChild(script); } }; setTimeout(function() { head.insertBefore(script, head.firstChild); }, 0); // allows return to execute first return { done: function (cb) { events.done = function() { if (cb) { setTimeout(cb,0); } }; } }; }; var buildInfo = { buildFromMethodHash: function (obj) { var key; for(key in obj) { if (obj.hasOwnProperty(key)) { obj[key] = buildInfo[obj[key]](); } } return obj; }, timeZoneDST: function () { var DST = { "CHADT": "+1345", "NZDT": "+1300", "AEDT": "+1100", "ACDT": "+1030", "AZST": "+0500", "IRDT": "+0430", "EEST": "+0300", "CEST": "+0200", "BST": "+0100", "PMDT": "-0200", "ADT": "-0300", "NDT": "-0230", "EDT": "-0400", "CDT": "-0500", "MDT": "-0600", "PDT": "-0700", "AKDT": "-0800", "HADT": "-0900" }; return __(DST); }, timeZoneStandard: function () { var standard = { "LINT": "+1400", "TOT": "+1300", "CHAST": "+1245", "NZST": "+1200", "NFT": "+1130", "SBT": "+1100", "AEST": "+1000", "ACST": "+0930", "JST": "+0900", "CWST": "+0845", "CT": "+0800", "ICT": "+0700", "MMT": "+0630", "BST": "+0600", "NPT": "+0545", "IST": "+0530", "PKT": "+0500", "AFT": "+0430", "MSK": "+0400", "IRST": "+0330", "FET": "+0300", "EET": "+0200", "CET": "+0100", "GMT": "+0000", "UTC": "+0000", "CVT": "-0100", "GST": "-0200", "BRT": "-0300", "NST": "-0330", "AST": "-0400", "EST": "-0500", "CST": "-0600", "MST": "-0700", "PST": "-0800", "AKST": "-0900", "MIT": "-0930", "HST": "-1000", "SST": "-1100", "BIT": "-1200" }; return __(standard); }, timeZones: function (data) { var zone; data.timezones = []; for (zone in data.abbreviatedTimeZoneStandard) { if (data.abbreviatedTimeZoneStandard.hasOwnProperty(zone)) { data.timezones.push({ name: zone, offset: data.abbreviatedTimeZoneStandard[zone]}); } } for (zone in data.abbreviatedTimeZoneDST) { if (data.abbreviatedTimeZoneDST.hasOwnProperty(zone)) { data.timezones.push({ name: zone, offset: data.abbreviatedTimeZoneDST[zone], dst: true}); } } return data.timezones; }, days: function () { return __(["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"]); }, dayAbbr: function () { return __(["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"]); }, dayShortNames: function () { return __(["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"]); }, dayFirstLetters: function () { return __(["S_Sun_Initial", "M_Mon_Initial", "T_Tues_Initial", "W_Wed_Initial", "T_Thu_Initial", "F_Fri_Initial", "S_Sat_Initial"]); }, months: function () { return __(["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"]); }, monthAbbr: function () { return __(["Jan_Abbr", "Feb_Abbr", "Mar_Abbr", "Apr_Abbr", "May_Abbr", "Jun_Abbr", "Jul_Abbr", "Aug_Abbr", "Sep_Abbr", "Oct_Abbr", "Nov_Abbr", "Dec_Abbr"]); }, formatPatterns: function () { return getText.getFromObjectValues({ shortDate: "M/d/yyyy", longDate: "dddd, MMMM dd, yyyy", shortTime: "h:mm tt", longTime: "h:mm:ss tt", fullDateTime: "dddd, MMMM dd, yyyy h:mm:ss tt", sortableDateTime: "yyyy-MM-ddTHH:mm:ss", universalSortableDateTime: "yyyy-MM-dd HH:mm:ssZ", rfc1123: "ddd, dd MMM yyyy HH:mm:ss", monthDay: "MMMM dd", yearMonth: "MMMM, yyyy" }, Date.i18n.currentLanguage()); }, regex: function () { return getText.getFromObjectValues({ inTheMorning: "/( in the )(morn(ing)?)\\b/", thisMorning: "/(this )(morn(ing)?)\\b/", amThisMorning: "/(\b\\d(am)? )(this )(morn(ing)?)/", inTheEvening: "/( in the )(even(ing)?)\\b/", thisEvening: "/(this )(even(ing)?)\\b/", pmThisEvening: "/(\b\\d(pm)? )(this )(even(ing)?)/", jan: "/jan(uary)?/", feb: "/feb(ruary)?/", mar: "/mar(ch)?/", apr: "/apr(il)?/", may: "/may/", jun: "/jun(e)?/", jul: "/jul(y)?/", aug: "/aug(ust)?/", sep: "/sep(t(ember)?)?/", oct: "/oct(ober)?/", nov: "/nov(ember)?/", dec: "/dec(ember)?/", sun: "/^su(n(day)?)?/", mon: "/^mo(n(day)?)?/", tue: "/^tu(e(s(day)?)?)?/", wed: "/^we(d(nesday)?)?/", thu: "/^th(u(r(s(day)?)?)?)?/", fri: "/fr(i(day)?)?/", sat: "/^sa(t(urday)?)?/", future: "/^next/", past: "/^last|past|prev(ious)?/", add: "/^(\\+|aft(er)?|from|hence)/", subtract: "/^(\\-|bef(ore)?|ago)/", yesterday: "/^yes(terday)?/", today: "/^t(od(ay)?)?/", tomorrow: "/^tom(orrow)?/", now: "/^n(ow)?/", millisecond: "/^ms|milli(second)?s?/", second: "/^sec(ond)?s?/", minute: "/^mn|min(ute)?s?/", hour: "/^h(our)?s?/", week: "/^w(eek)?s?/", month: "/^m(onth)?s?/", day: "/^d(ay)?s?/", year: "/^y(ear)?s?/", shortMeridian: "/^(a|p)/", longMeridian: "/^(a\\.?m?\\.?|p\\.?m?\\.?)/", timezone: "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/", ordinalSuffix: "/^\\s*(st|nd|rd|th)/", timeContext: "/^\\s*(\\:|a(?!u|p)|p)/" }, Date.i18n.currentLanguage()); } }; var CultureInfo = function () { var info = getText.getFromObjectValues({ name: "name", englishName: "englishName", nativeName: "nativeName", amDesignator: "AM", pmDesignator: "PM", firstDayOfWeek: "firstDayOfWeek", twoDigitYearMax: "twoDigitYearMax", dateElementOrder: "mdy" }, Date.i18n.currentLanguage()); var constructedInfo = buildInfo.buildFromMethodHash({ dayNames: "days", abbreviatedDayNames: "dayAbbr", shortestDayNames: "dayShortNames", firstLetterDayNames: "dayFirstLetters", monthNames: "months", abbreviatedMonthNames: "monthAbbr", formatPatterns: "formatPatterns", regexPatterns: "regex", abbreviatedTimeZoneDST: "timeZoneDST", abbreviatedTimeZoneStandard: "timeZoneStandard" }); shallowMerge(info, constructedInfo); buildInfo.timeZones(info); return info; }; $D.i18n = { __: function (key, lang) { return __(key, lang); }, currentLanguage: function () { return lang || "en-US"; }, setLanguage: function (code, force, cb) { var async = false; if (force || code === "en-US" || (!!Date.CultureStrings && !!Date.CultureStrings[code])) { lang = code; Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings.lang = code; Date.CultureInfo = new CultureInfo(); } else { if (!(!!Date.CultureStrings && !!Date.CultureStrings[code])) { if (typeof exports !== "undefined" && this.exports !== exports) { // we're in a Node enviroment, load it using require try { require("../i18n/" + code + ".js"); lang = code; Date.CultureStrings.lang = code; Date.CultureInfo = new CultureInfo(); } catch (e) { // var str = "The language for '" + code + "' could not be loaded by Node. It likely does not exist."; throw new Error("The DateJS IETF language tag '" + code + "' could not be loaded by Node. It likely does not exist."); } } else if (Date.Config && Date.Config.i18n) { // we know the location of the files, so lets load them async = true; loadI18nScript(code).done(function(){ lang = code; Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings.lang = code; Date.CultureInfo = new CultureInfo(); $D.Parsing.Normalizer.buildReplaceData(); // because this is async if ($D.Grammar) { $D.Grammar.buildGrammarFormats(); // so we can parse those strings... } if (cb) { setTimeout(cb,0); } }); } else { Date.console.error("The DateJS IETF language tag '" + code + "' is not available and has not been loaded."); return false; } } } $D.Parsing.Normalizer.buildReplaceData(); // rebuild normalizer strings if ($D.Grammar) { $D.Grammar.buildGrammarFormats(); // so we can parse those strings... } if (!async && cb) { setTimeout(cb,0); } }, getLoggedKeys: function () { return loggedKeys; }, updateCultureInfo: function () { Date.CultureInfo = new CultureInfo(); } }; $D.i18n.updateCultureInfo(); // run automatically }()); (function () { var $D = Date, $P = $D.prototype, p = function (s, l) { if (!l) { l = 2; } return ("000" + s).slice(l * -1); }; if (typeof window !== "undefined" && typeof window.console !== "undefined" && typeof window.console.log !== "undefined") { $D.console = console; // used only to raise non-critical errors if available } else { // set mock so we don't give errors. $D.console = { log: function(){}, error: function(){} }; } $D.Config = $D.Config || {}; $D.initOverloads = function() { /** * Overload of Date.now. Allows an alternate call for Date.now where it returns the * current Date as an object rather than just milliseconds since the Unix Epoch. * * Also provides an implementation of now() for browsers (IE<9) that don't have it. * * Backwards compatible so with work with either: * Date.now() [returns ms] * or * Date.now(true) [returns Date] */ if (!$D.now) { $D._now = function now() { return new Date().getTime(); }; } else if (!$D._now) { $D._now = $D.now; } $D.now = function (returnObj) { if (returnObj) { return $D.present(); } else { return $D._now(); } }; if ( !$P.toISOString ) { $P.toISOString = function() { return this.getUTCFullYear() + "-" + p(this.getUTCMonth() + 1) + "-" + p(this.getUTCDate()) + "T" + p(this.getUTCHours()) + ":" + p(this.getUTCMinutes()) + ":" + p(this.getUTCSeconds()) + "." + String( (this.getUTCMilliseconds()/1000).toFixed(3)).slice(2, 5) + "Z"; }; } // private if ( $P._toString === undefined ){ $P._toString = $P.toString; } }; $D.initOverloads(); /** * Gets a date that is set to the current date. The time is set to the start of the day (00:00 or 12:00 AM). * @return {Date} The current date. */ $D.today = function () { return new Date().clearTime(); }; /** * Gets a date that is set to the current date and time (same as new Date, but chainable) * @return {Date} The current date. */ $D.present = function () { return new Date(); }; /** * Compares the first date to the second date and returns an number indication of their relative values. * @param {Date} First Date object to compare [Required]. * @param {Date} Second Date object to compare to [Required]. * @return {Number} -1 = date1 is lessthan date2. 0 = values are equal. 1 = date1 is greaterthan date2. */ $D.compare = function (date1, date2) { if (isNaN(date1) || isNaN(date2)) { throw new Error(date1 + " - " + date2); } else if (date1 instanceof Date && date2 instanceof Date) { return (date1 < date2) ? -1 : (date1 > date2) ? 1 : 0; } else { throw new TypeError(date1 + " - " + date2); } }; /** * Compares the first Date object to the second Date object and returns true if they are equal. * @param {Date} First Date object to compare [Required] * @param {Date} Second Date object to compare to [Required] * @return {Boolean} true if dates are equal. false if they are not equal. */ $D.equals = function (date1, date2) { return (date1.compareTo(date2) === 0); }; /** * Gets the language appropriate day name when given the day number(0-6) * eg - 0 == Sunday * @return {String} The day name */ $D.getDayName = function (n) { return Date.CultureInfo.dayNames[n]; }; /** * Gets the day number (0-6) if given a CultureInfo specific string which is a valid dayName, abbreviatedDayName or shortestDayName (two char). * @param {String} The name of the day (eg. "Monday, "Mon", "tuesday", "tue", "We", "we"). * @return {Number} The day number */ $D.getDayNumberFromName = function (name) { var n = Date.CultureInfo.dayNames, m = Date.CultureInfo.abbreviatedDayNames, o = Date.CultureInfo.shortestDayNames, s = name.toLowerCase(); for (var i = 0; i < n.length; i++) { if (n[i].toLowerCase() === s || m[i].toLowerCase() === s || o[i].toLowerCase() === s) { return i; } } return -1; }; /** * Gets the month number (0-11) if given a Culture Info specific string which is a valid monthName or abbreviatedMonthName. * @param {String} The name of the month (eg. "February, "Feb", "october", "oct"). * @return {Number} The day number */ $D.getMonthNumberFromName = function (name) { var n = Date.CultureInfo.monthNames, m = Date.CultureInfo.abbreviatedMonthNames, s = name.toLowerCase(); for (var i = 0; i < n.length; i++) { if (n[i].toLowerCase() === s || m[i].toLowerCase() === s) { return i; } } return -1; }; /** * Gets the language appropriate month name when given the month number(0-11) * eg - 0 == January * @return {String} The month name */ $D.getMonthName = function (n) { return Date.CultureInfo.monthNames[n]; }; /** * Determines if the current date instance is within a LeapYear. * @param {Number} The year. * @return {Boolean} true if date is within a LeapYear, otherwise false. */ $D.isLeapYear = function (year) { return ((year % 4 === 0 && year % 100 !== 0) || year % 400 === 0); }; /** * Gets the number of days in the month, given a year and month value. Automatically corrects for LeapYear. * @param {Number} The year. * @param {Number} The month (0-11). * @return {Number} The number of days in the month. */ $D.getDaysInMonth = function (year, month) { if (!month && $D.validateMonth(year)) { month = year; year = Date.today().getFullYear(); } return [31, ($D.isLeapYear(year) ? 29 : 28), 31, 30, 31, 30, 31, 31, 30, 31, 30, 31][month]; }; $P.getDaysInMonth = function () { return $D.getDaysInMonth(this.getFullYear(), this.getMonth()); }; $D.getTimezoneAbbreviation = function (offset, dst) { var p, n = (dst || false) ? Date.CultureInfo.abbreviatedTimeZoneDST : Date.CultureInfo.abbreviatedTimeZoneStandard; for (p in n) { if (n.hasOwnProperty(p)) { if (n[p] === offset) { return p; } } } return null; }; $D.getTimezoneOffset = function (name, dst) { var i, a =[], z = Date.CultureInfo.timezones; if (!name) { name = (new Date()).getTimezone();} for (i = 0; i < z.length; i++) { if (z[i].name === name.toUpperCase()) { a.push(i); } } if (!z[a[0]]) { return null; } if (a.length === 1 || !dst) { return z[a[0]].offset; } else { for (i=0; i < a.length; i++) { if (z[a[i]].dst) { return z[a[i]].offset; } } } }; $D.getQuarter = function (d) { d = d || new Date(); // If no date supplied, use today var q = [1,2,3,4]; return q[Math.floor(d.getMonth() / 3)]; // ~~~ is a bitwise op. Faster than Math.floor }; $D.getDaysLeftInQuarter = function (d) { d = d || new Date(); var qEnd = new Date(d); qEnd.setMonth(qEnd.getMonth() + 3 - qEnd.getMonth() % 3, 0); return Math.floor((qEnd - d) / 8.64e7); }; // private var validate = function (n, min, max, name) { name = name ? name : "Object"; if (typeof n === "undefined") { return false; } else if (typeof n !== "number") { throw new TypeError(n + " is not a Number."); } else if (n < min || n > max) { // As failing validation is *not* an exceptional circumstance // lets not throw a RangeError Exception here. // It's semantically correct but it's not sensible. return false; } return true; }; /** * Validates the number is within an acceptable range for milliseconds [0-999]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateMillisecond = function (value) { return validate(value, 0, 999, "millisecond"); }; /** * Validates the number is within an acceptable range for seconds [0-59]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateSecond = function (value) { return validate(value, 0, 59, "second"); }; /** * Validates the number is within an acceptable range for minutes [0-59]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateMinute = function (value) { return validate(value, 0, 59, "minute"); }; /** * Validates the number is within an acceptable range for hours [0-23]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateHour = function (value) { return validate(value, 0, 23, "hour"); }; /** * Validates the number is within an acceptable range for the days in a month [0-MaxDaysInMonth]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateDay = function (value, year, month) { if (year === undefined || year === null || month === undefined || month === null) { return false;} return validate(value, 1, $D.getDaysInMonth(year, month), "day"); }; /** * Validates the number is within an acceptable range for months [0-11]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateWeek = function (value) { return validate(value, 0, 53, "week"); }; /** * Validates the number is within an acceptable range for months [0-11]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateMonth = function (value) { return validate(value, 0, 11, "month"); }; /** * Validates the number is within an acceptable range for years. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateYear = function (value) { /** * Per ECMAScript spec the range of times supported by Date objects is * exactly -100,000,000 days to +100,000,000 days measured relative to * midnight at the beginning of 01 January, 1970 UTC. * This gives a range of 8,640,000,000,000,000 milliseconds to either * side of 01 January, 1970 UTC. * * Earliest possible date: Tue, 20 Apr 271,822 B.C. 00:00:00 UTC * Latest possible date: Sat, 13 Sep 275,760 00:00:00 UTC */ return validate(value, -271822, 275760, "year"); }; $D.validateTimezone = function(value) { var timezones = {"ACDT":1,"ACST":1,"ACT":1,"ADT":1,"AEDT":1,"AEST":1,"AFT":1,"AKDT":1,"AKST":1,"AMST":1,"AMT":1,"ART":1,"AST":1,"AWDT":1,"AWST":1,"AZOST":1,"AZT":1,"BDT":1,"BIOT":1,"BIT":1,"BOT":1,"BRT":1,"BST":1,"BTT":1,"CAT":1,"CCT":1,"CDT":1,"CEDT":1,"CEST":1,"CET":1,"CHADT":1,"CHAST":1,"CHOT":1,"ChST":1,"CHUT":1,"CIST":1,"CIT":1,"CKT":1,"CLST":1,"CLT":1,"COST":1,"COT":1,"CST":1,"CT":1,"CVT":1,"CWST":1,"CXT":1,"DAVT":1,"DDUT":1,"DFT":1,"EASST":1,"EAST":1,"EAT":1,"ECT":1,"EDT":1,"EEDT":1,"EEST":1,"EET":1,"EGST":1,"EGT":1,"EIT":1,"EST":1,"FET":1,"FJT":1,"FKST":1,"FKT":1,"FNT":1,"GALT":1,"GAMT":1,"GET":1,"GFT":1,"GILT":1,"GIT":1,"GMT":1,"GST":1,"GYT":1,"HADT":1,"HAEC":1,"HAST":1,"HKT":1,"HMT":1,"HOVT":1,"HST":1,"ICT":1,"IDT":1,"IOT":1,"IRDT":1,"IRKT":1,"IRST":1,"IST":1,"JST":1,"KGT":1,"KOST":1,"KRAT":1,"KST":1,"LHST":1,"LINT":1,"MAGT":1,"MART":1,"MAWT":1,"MDT":1,"MET":1,"MEST":1,"MHT":1,"MIST":1,"MIT":1,"MMT":1,"MSK":1,"MST":1,"MUT":1,"MVT":1,"MYT":1,"NCT":1,"NDT":1,"NFT":1,"NPT":1,"NST":1,"NT":1,"NUT":1,"NZDT":1,"NZST":1,"OMST":1,"ORAT":1,"PDT":1,"PET":1,"PETT":1,"PGT":1,"PHOT":1,"PHT":1,"PKT":1,"PMDT":1,"PMST":1,"PONT":1,"PST":1,"PYST":1,"PYT":1,"RET":1,"ROTT":1,"SAKT":1,"SAMT":1,"SAST":1,"SBT":1,"SCT":1,"SGT":1,"SLST":1,"SRT":1,"SST":1,"SYOT":1,"TAHT":1,"THA":1,"TFT":1,"TJT":1,"TKT":1,"TLT":1,"TMT":1,"TOT":1,"TVT":1,"UCT":1,"ULAT":1,"UTC":1,"UYST":1,"UYT":1,"UZT":1,"VET":1,"VLAT":1,"VOLT":1,"VOST":1,"VUT":1,"WAKT":1,"WAST":1,"WAT":1,"WEDT":1,"WEST":1,"WET":1,"WST":1,"YAKT":1,"YEKT":1,"Z":1}; return (timezones[value] === 1); }; $D.validateTimezoneOffset= function(value) { // timezones go from +14hrs to -12hrs, the +X hours are negative offsets. return (value > -841 && value < 721); }; }()); (function () { var $D = Date, $P = $D.prototype, p = function (s, l) { if (!l) { l = 2; } return ("000" + s).slice(l * -1); }; var validateConfigObject = function (obj) { var result = {}, self = this, prop, testFunc; testFunc = function (prop, func, value) { if (prop === "day") { var month = (obj.month !== undefined) ? obj.month : self.getMonth(); var year = (obj.year !== undefined) ? obj.year : self.getFullYear(); return $D[func](value, year, month); } else { return $D[func](value); } }; for (prop in obj) { if (Object.prototype.hasOwnProperty.call(obj, prop)) { var func = "validate" + prop.charAt(0).toUpperCase() + prop.slice(1); if ($D[func] && obj[prop] !== null && testFunc(prop, func, obj[prop])) { result[prop] = obj[prop]; } } } return result; }; /** * Resets the time of this Date object to 12:00 AM (00:00), which is the start of the day. * @param {Boolean} .clone() this date instance before clearing Time * @return {Date} this */ $P.clearTime = function () { this.setHours(0); this.setMinutes(0); this.setSeconds(0); this.setMilliseconds(0); return this; }; /** * Resets the time of this Date object to the current time ('now'). * @return {Date} this */ $P.setTimeToNow = function () { var n = new Date(); this.setHours(n.getHours()); this.setMinutes(n.getMinutes()); this.setSeconds(n.getSeconds()); this.setMilliseconds(n.getMilliseconds()); return this; }; /** * Returns a new Date object that is an exact date and time copy of the original instance. * @return {Date} A new Date instance */ $P.clone = function () { return new Date(this.getTime()); }; /** * Compares this instance to a Date object and returns an number indication of their relative values. * @param {Date} Date object to compare [Required] * @return {Number} -1 = this is lessthan date. 0 = values are equal. 1 = this is greaterthan date. */ $P.compareTo = function (date) { return Date.compare(this, date); }; /** * Compares this instance to another Date object and returns true if they are equal. * @param {Date} Date object to compare. If no date to compare, new Date() [now] is used. * @return {Boolean} true if dates are equal. false if they are not equal. */ $P.equals = function (date) { return Date.equals(this, (date !== undefined ? date : new Date())); }; /** * Determines if this instance is between a range of two dates or equal to either the start or end dates. * @param {Date} Start of range [Required] * @param {Date} End of range [Required] * @return {Boolean} true is this is between or equal to the start and end dates, else false */ $P.between = function (start, end) { return this.getTime() >= start.getTime() && this.getTime() <= end.getTime(); }; /** * Determines if this date occurs after the date to compare to. * @param {Date} Date object to compare. If no date to compare, new Date() ("now") is used. * @return {Boolean} true if this date instance is greater than the date to compare to (or "now"), otherwise false. */ $P.isAfter = function (date) { return this.compareTo(date || new Date()) === 1; }; /** * Determines if this date occurs before the date to compare to. * @param {Date} Date object to compare. If no date to compare, new Date() ("now") is used. * @return {Boolean} true if this date instance is less than the date to compare to (or "now"). */ $P.isBefore = function (date) { return (this.compareTo(date || new Date()) === -1); }; /** * Determines if the current Date instance occurs today. * @return {Boolean} true if this date instance is 'today', otherwise false. */ /** * Determines if the current Date instance occurs on the same Date as the supplied 'date'. * If no 'date' to compare to is provided, the current Date instance is compared to 'today'. * @param {date} Date object to compare. If no date to compare, the current Date ("now") is used. * @return {Boolean} true if this Date instance occurs on the same Day as the supplied 'date'. */ $P.isToday = $P.isSameDay = function (date) { return this.clone().clearTime().equals((date || new Date()).clone().clearTime()); }; /** * Adds the specified number of milliseconds to this instance. * @param {Number} The number of milliseconds to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addMilliseconds = function (value) { if (!value) { return this; } this.setTime(this.getTime() + value * 1); return this; }; /** * Adds the specified number of seconds to this instance. * @param {Number} The number of seconds to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addSeconds = function (value) { if (!value) { return this; } return this.addMilliseconds(value * 1000); }; /** * Adds the specified number of seconds to this instance. * @param {Number} The number of seconds to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addMinutes = function (value) { if (!value) { return this; } return this.addMilliseconds(value * 60000); // 60*1000 }; /** * Adds the specified number of hours to this instance. * @param {Number} The number of hours to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addHours = function (value) { if (!value) { return this; } return this.addMilliseconds(value * 3600000); // 60*60*1000 }; /** * Adds the specified number of days to this instance. * @param {Number} The number of days to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addDays = function (value) { if (!value) { return this; } this.setDate(this.getDate() + value * 1); return this; }; /** * Adds the specified number of weekdays (ie - not sat or sun) to this instance. * @param {Number} The number of days to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addWeekdays = function (value) { if (!value) { return this; } var day = this.getDay(); var weeks = (Math.ceil(Math.abs(value)/7)); if (day === 0 || day === 6) { if (value > 0) { this.next().monday(); this.addDays(-1); day = this.getDay(); } } if (value < 0) { while (value < 0) { this.addDays(-1); day = this.getDay(); if (day !== 0 && day !== 6) { value++; } } return this; } else if (value > 5 || (6-day) <= value) { value = value + (weeks * 2); } return this.addDays(value); }; /** * Adds the specified number of weeks to this instance. * @param {Number} The number of weeks to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addWeeks = function (value) { if (!value) { return this; } return this.addDays(value * 7); }; /** * Adds the specified number of months to this instance. * @param {Number} The number of months to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addMonths = function (value) { if (!value) { return this; } var n = this.getDate(); this.setDate(1); this.setMonth(this.getMonth() + value * 1); this.setDate(Math.min(n, $D.getDaysInMonth(this.getFullYear(), this.getMonth()))); return this; }; $P.addQuarters = function (value) { if (!value) { return this; } // note this will take you to the same point in the quarter as you are now. // i.e. - if you are 15 days into the quarter you'll be 15 days into the resulting one. // bonus: this allows adding fractional quarters return this.addMonths(value * 3); }; /** * Adds the specified number of years to this instance. * @param {Number} The number of years to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addYears = function (value) { if (!value) { return this; } return this.addMonths(value * 12); }; /** * Adds (or subtracts) to the value of the years, months, weeks, days, hours, minutes, seconds, milliseconds of the date instance using given configuration object. Positive and Negative values allowed. * Example

	Date.today().add( { days: 1, months: 1 } )

	new Date().add( { years: -1 } )
	
* @param {Object} Configuration object containing attributes (months, days, etc.) * @return {Date} this */ $P.add = function (config) { if (typeof config === "number") { this._orient = config; return this; } var x = config; if (x.day) { // If we should be a different date than today (eg: for 'tomorrow -1d', etc). // Should only effect parsing, not direct usage (eg, Finish and FinishExact) if ((x.day - this.getDate()) !== 0) { this.setDate(x.day); } } if (x.milliseconds) { this.addMilliseconds(x.milliseconds); } if (x.seconds) { this.addSeconds(x.seconds); } if (x.minutes) { this.addMinutes(x.minutes); } if (x.hours) { this.addHours(x.hours); } if (x.weeks) { this.addWeeks(x.weeks); } if (x.months) { this.addMonths(x.months); } if (x.years) { this.addYears(x.years); } if (x.days) { this.addDays(x.days); } return this; }; /** * Get the week number. Week one (1) is the week which contains the first Thursday of the year. Monday is considered the first day of the week. * The .getWeek() function does NOT convert the date to UTC. The local datetime is used. * Please use .getISOWeek() to get the week of the UTC converted date. * @return {Number} 1 to 53 */ $P.getWeek = function (utc) { // Create a copy of this date object var self, target = new Date(this.valueOf()); if (utc) { target.addMinutes(target.getTimezoneOffset()); self = target.clone(); } else { self = this; } // ISO week date weeks start on monday // so correct the day number var dayNr = (self.getDay() + 6) % 7; // ISO 8601 states that week 1 is the week // with the first thursday of that year. // Set the target date to the thursday in the target week target.setDate(target.getDate() - dayNr + 3); // Store the millisecond value of the target date var firstThursday = target.valueOf(); // Set the target to the first thursday of the year // First set the target to january first target.setMonth(0, 1); // Not a thursday? Correct the date to the next thursday if (target.getDay() !== 4) { target.setMonth(0, 1 + ((4 - target.getDay()) + 7) % 7); } // The weeknumber is the number of weeks between the // first thursday of the year and the thursday in the target week return 1 + Math.ceil((firstThursday - target) / 604800000); // 604800000 = 7 * 24 * 3600 * 1000 }; /** * Get the ISO 8601 week number. Week one ("01") is the week which contains the first Thursday of the year. Monday is considered the first day of the week. * The .getISOWeek() function does convert the date to it's UTC value. Please use .getWeek() to get the week of the local date. * @return {String} "01" to "53" */ $P.getISOWeek = function () { return p(this.getWeek(true)); }; /** * Moves the date to Monday of the week set. Week one (1) is the week which contains the first Thursday of the year. * @param {Number} A Number (1 to 53) that represents the week of the year. * @return {Date} this */ $P.setWeek = function (n) { if ((n - this.getWeek()) === 0) { if (this.getDay() !== 1) { return this.moveToDayOfWeek(1, (this.getDay() > 1 ? -1 : 1)); } else { return this; } } else { return this.moveToDayOfWeek(1, (this.getDay() > 1 ? -1 : 1)).addWeeks(n - this.getWeek()); } }; $P.setQuarter = function (qtr) { var month = Math.abs(((qtr-1) * 3) + 1); return this.setMonth(month, 1); }; $P.getQuarter = function () { return Date.getQuarter(this); }; $P.getDaysLeftInQuarter = function () { return Date.getDaysLeftInQuarter(this); }; /** * Moves the date to the next n'th occurrence of the dayOfWeek starting from the beginning of the month. The number (-1) is a magic number and will return the last occurrence of the dayOfWeek in the month. * @param {Number} The dayOfWeek to move to * @param {Number} The n'th occurrence to move to. Use (-1) to return the last occurrence in the month * @return {Date} this */ $P.moveToNthOccurrence = function (dayOfWeek, occurrence) { if (dayOfWeek === "Weekday") { if (occurrence > 0) { this.moveToFirstDayOfMonth(); if (this.is().weekday()) { occurrence -= 1; } } else if (occurrence < 0) { this.moveToLastDayOfMonth(); if (this.is().weekday()) { occurrence += 1; } } else { return this; } return this.addWeekdays(occurrence); } var shift = 0; if (occurrence > 0) { shift = occurrence - 1; } else if (occurrence === -1) { this.moveToLastDayOfMonth(); if (this.getDay() !== dayOfWeek) { this.moveToDayOfWeek(dayOfWeek, -1); } return this; } return this.moveToFirstDayOfMonth().addDays(-1).moveToDayOfWeek(dayOfWeek, +1).addWeeks(shift); }; var moveToN = function (getFunc, addFunc, nVal) { return function (value, orient) { var diff = (value - this[getFunc]() + nVal * (orient || +1)) % nVal; return this[addFunc]((diff === 0) ? diff += nVal * (orient || +1) : diff); }; }; /** * Move to the next or last dayOfWeek based on the orient value. * @param {Number} The dayOfWeek to move to * @param {Number} Forward (+1) or Back (-1). Defaults to +1. [Optional] * @return {Date} this */ $P.moveToDayOfWeek = moveToN("getDay", "addDays", 7); /** * Move to the next or last month based on the orient value. * @param {Number} The month to move to. 0 = January, 11 = December * @param {Number} Forward (+1) or Back (-1). Defaults to +1. [Optional] * @return {Date} this */ $P.moveToMonth = moveToN("getMonth", "addMonths", 12); /** * Get the Ordinate of the current day ("th", "st", "rd"). * @return {String} */ $P.getOrdinate = function () { var num = this.getDate(); return ord(num); }; /** * Get the Ordinal day (numeric day number) of the year, adjusted for leap year. * @return {Number} 1 through 365 (366 in leap years) */ $P.getOrdinalNumber = function () { return Math.ceil((this.clone().clearTime() - new Date(this.getFullYear(), 0, 1)) / 86400000) + 1; }; /** * Get the time zone abbreviation of the current date. * @return {String} The abbreviated time zone name (e.g. "EST") */ $P.getTimezone = function () { return $D.getTimezoneAbbreviation(this.getUTCOffset(), this.isDaylightSavingTime()); }; $P.setTimezoneOffset = function (offset) { var here = this.getTimezoneOffset(), there = Number(offset) * -6 / 10; return (there || there === 0) ? this.addMinutes(there - here) : this; }; $P.setTimezone = function (offset) { return this.setTimezoneOffset($D.getTimezoneOffset(offset)); }; /** * Indicates whether Daylight Saving Time is observed in the current time zone. * @return {Boolean} true|false */ $P.hasDaylightSavingTime = function () { return (Date.today().set({month: 0, day: 1}).getTimezoneOffset() !== Date.today().set({month: 6, day: 1}).getTimezoneOffset()); }; /** * Indicates whether this Date instance is within the Daylight Saving Time range for the current time zone. * @return {Boolean} true|false */ $P.isDaylightSavingTime = function () { return Date.today().set({month: 0, day: 1}).getTimezoneOffset() !== this.getTimezoneOffset(); }; /** * Get the offset from UTC of the current date. * @return {String} The 4-character offset string prefixed with + or - (e.g. "-0500") */ $P.getUTCOffset = function (offset) { var n = (offset || this.getTimezoneOffset()) * -10 / 6, r; if (n < 0) { r = (n - 10000).toString(); return r.charAt(0) + r.substr(2); } else { r = (n + 10000).toString(); return "+" + r.substr(1); } }; /** * Returns the number of milliseconds between this date and date. * @param {Date} Defaults to now * @return {Number} The diff in milliseconds */ $P.getElapsed = function (date) { return (date || new Date()) - this; }; /** * Set the value of year, month, day, hour, minute, second, millisecond of date instance using given configuration object. * Example

	Date.today().set( { day: 20, month: 1 } )

	new Date().set( { millisecond: 0 } )
	
* * @param {Object} Configuration object containing attributes (month, day, etc.) * @return {Date} this */ $P.set = function (config) { config = validateConfigObject.call(this, config); var key; for (key in config) { if (Object.prototype.hasOwnProperty.call(config, key)) { var name = key.charAt(0).toUpperCase() + key.slice(1); var addFunc, getFunc; if (key !== "week" && key !== "month" && key !== "timezone" && key !== "timezoneOffset") { name += "s"; } addFunc = "add" + name; getFunc = "get" + name; if (key === "month") { addFunc = addFunc + "s"; } else if (key === "year"){ getFunc = "getFullYear"; } if (key !== "day" && key !== "timezone" && key !== "timezoneOffset" && key !== "week" && key !== "hour") { this[addFunc](config[key] - this[getFunc]()); } else if ( key === "timezone"|| key === "timezoneOffset" || key === "week" || key === "hour") { this["set"+name](config[key]); } } } // day has to go last because you can't validate the day without first knowing the month if (config.day) { this.addDays(config.day - this.getDate()); } return this; }; /** * Moves the date to the first day of the month. * @return {Date} this */ $P.moveToFirstDayOfMonth = function () { return this.set({ day: 1 }); }; /** * Moves the date to the last day of the month. * @return {Date} this */ $P.moveToLastDayOfMonth = function () { return this.set({ day: $D.getDaysInMonth(this.getFullYear(), this.getMonth())}); }; /** * Converts the value of the current Date object to its equivalent string representation. * Format Specifiers * CUSTOM DATE AND TIME FORMAT STRINGS * Format Description Example * ------ --------------------------------------------------------------------------- ----------------------- * s The seconds of the minute between 0-59. "0" to "59" * ss The seconds of the minute with leading zero if required. "00" to "59" * * m The minute of the hour between 0-59. "0" or "59" * mm The minute of the hour with leading zero if required. "00" or "59" * * h The hour of the day between 1-12. "1" to "12" * hh The hour of the day with leading zero if required. "01" to "12" * * H The hour of the day between 0-23. "0" to "23" * HH The hour of the day with leading zero if required. "00" to "23" * * d The day of the month between 1 and 31. "1" to "31" * dd The day of the month with leading zero if required. "01" to "31" * ddd Abbreviated day name. Date.CultureInfo.abbreviatedDayNames. "Mon" to "Sun" * dddd The full day name. Date.CultureInfo.dayNames. "Monday" to "Sunday" * * M The month of the year between 1-12. "1" to "12" * MM The month of the year with leading zero if required. "01" to "12" * MMM Abbreviated month name. Date.CultureInfo.abbreviatedMonthNames. "Jan" to "Dec" * MMMM The full month name. Date.CultureInfo.monthNames. "January" to "December" * * yy The year as a two-digit number. "99" or "08" * yyyy The full four digit year. "1999" or "2008" * * t Displays the first character of the A.M./P.M. designator. "A" or "P" * Date.CultureInfo.amDesignator or Date.CultureInfo.pmDesignator * tt Displays the A.M./P.M. designator. "AM" or "PM" * Date.CultureInfo.amDesignator or Date.CultureInfo.pmDesignator * * S The ordinal suffix ("st, "nd", "rd" or "th") of the current day. "st, "nd", "rd" or "th" * * STANDARD DATE AND TIME FORMAT STRINGS * Format Description Example *------ --------------------------------------------------------------------------- ----------------------- * d The CultureInfo shortDate Format Pattern "M/d/yyyy" * D The CultureInfo longDate Format Pattern "dddd, MMMM dd, yyyy" * F The CultureInfo fullDateTime Format Pattern "dddd, MMMM dd, yyyy h:mm:ss tt" * m The CultureInfo monthDay Format Pattern "MMMM dd" * r The CultureInfo rfc1123 Format Pattern "ddd, dd MMM yyyy HH:mm:ss GMT" * s The CultureInfo sortableDateTime Format Pattern "yyyy-MM-ddTHH:mm:ss" * t The CultureInfo shortTime Format Pattern "h:mm tt" * T The CultureInfo longTime Format Pattern "h:mm:ss tt" * u The CultureInfo universalSortableDateTime Format Pattern "yyyy-MM-dd HH:mm:ssZ" * y The CultureInfo yearMonth Format Pattern "MMMM, yyyy" * * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @return {String} A string representation of the current Date object. */ var ord = function (n) { switch (n * 1) { case 1: case 21: case 31: return "st"; case 2: case 22: return "nd"; case 3: case 23: return "rd"; default: return "th"; } }; var parseStandardFormats = function (format) { var y, c = Date.CultureInfo.formatPatterns; switch (format) { case "d": return this.toString(c.shortDate); case "D": return this.toString(c.longDate); case "F": return this.toString(c.fullDateTime); case "m": return this.toString(c.monthDay); case "r": case "R": y = this.clone().addMinutes(this.getTimezoneOffset()); return y.toString(c.rfc1123) + " GMT"; case "s": return this.toString(c.sortableDateTime); case "t": return this.toString(c.shortTime); case "T": return this.toString(c.longTime); case "u": y = this.clone().addMinutes(this.getTimezoneOffset()); return y.toString(c.universalSortableDateTime); case "y": return this.toString(c.yearMonth); default: return false; } }; var parseFormatStringsClosure = function (context) { return function (m) { if (m.charAt(0) === "\\") { return m.replace("\\", ""); } switch (m) { case "hh": return p(context.getHours() < 13 ? (context.getHours() === 0 ? 12 : context.getHours()) : (context.getHours() - 12)); case "h": return context.getHours() < 13 ? (context.getHours() === 0 ? 12 : context.getHours()) : (context.getHours() - 12); case "HH": return p(context.getHours()); case "H": return context.getHours(); case "mm": return p(context.getMinutes()); case "m": return context.getMinutes(); case "ss": return p(context.getSeconds()); case "s": return context.getSeconds(); case "yyyy": return p(context.getFullYear(), 4); case "yy": return p(context.getFullYear()); case "y": return context.getFullYear(); case "E": case "dddd": return Date.CultureInfo.dayNames[context.getDay()]; case "ddd": return Date.CultureInfo.abbreviatedDayNames[context.getDay()]; case "dd": return p(context.getDate()); case "d": return context.getDate(); case "MMMM": return Date.CultureInfo.monthNames[context.getMonth()]; case "MMM": return Date.CultureInfo.abbreviatedMonthNames[context.getMonth()]; case "MM": return p((context.getMonth() + 1)); case "M": return context.getMonth() + 1; case "t": return context.getHours() < 12 ? Date.CultureInfo.amDesignator.substring(0, 1) : Date.CultureInfo.pmDesignator.substring(0, 1); case "tt": return context.getHours() < 12 ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator; case "S": return ord(context.getDate()); case "W": return context.getWeek(); case "WW": return context.getISOWeek(); case "Q": return "Q" + context.getQuarter(); case "q": return String(context.getQuarter()); case "z": return context.getTimezone(); case "Z": case "X": return Date.getTimezoneOffset(context.getTimezone()); case "ZZ": // Timezone offset in seconds return context.getTimezoneOffset() * -60; case "u": return context.getDay(); case "L": return ($D.isLeapYear(context.getFullYear())) ? 1 : 0; case "B": // Swatch Internet Time (.beats) return "@"+((context.getUTCSeconds() + (context.getUTCMinutes()*60) + ((context.getUTCHours()+1)*3600))/86.4); default: return m; } }; }; $P.toString = function (format, ignoreStandards) { // Standard Date and Time Format Strings. Formats pulled from CultureInfo file and // may vary by culture. if (!ignoreStandards && format && format.length === 1) { output = parseStandardFormats.call(this, format); if (output) { return output; } } var parseFormatStrings = parseFormatStringsClosure(this); return format ? format.replace(/((\\)?(dd?d?d?|MM?M?M?|yy?y?y?|hh?|HH?|mm?|ss?|tt?|S|q|Q|WW?W?W?)(?![^\[]*\]))/g, parseFormatStrings).replace(/\[|\]/g, "") : this._toString(); }; }()); /************************************************************* * SugarPak - Domain Specific Language - Syntactical Sugar * *************************************************************/ (function () { var $D = Date, $P = $D.prototype, $N = Number.prototype; // private $P._orient = +1; // private $P._nth = null; // private $P._is = false; // private $P._same = false; // private $P._isSecond = false; // private $N._dateElement = "days"; /** * Moves the date to the next instance of a date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.today().next().friday();
	Date.today().next().fri();
	Date.today().next().march();
	Date.today().next().mar();
	Date.today().next().week();
	
* * @return {Date} date */ $P.next = function () { this._move = true; this._orient = +1; return this; }; /** * Creates a new Date (Date.today()) and moves the date to the next instance of the date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.next().friday();
	Date.next().fri();
	Date.next().march();
	Date.next().mar();
	Date.next().week();
	
* * @return {Date} date */ $D.next = function () { return $D.today().next(); }; /** * Moves the date to the previous instance of a date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.today().last().friday();
	Date.today().last().fri();
	Date.today().last().march();
	Date.today().last().mar();
	Date.today().last().week();
	
* * @return {Date} date */ $P.last = $P.prev = $P.previous = function () { this._move = true; this._orient = -1; return this; }; /** * Creates a new Date (Date.today()) and moves the date to the previous instance of the date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.last().friday();
	Date.last().fri();
	Date.previous().march();
	Date.prev().mar();
	Date.last().week();
	
* * @return {Date} date */ $D.last = $D.prev = $D.previous = function () { return $D.today().last(); }; /** * Performs a equality check when followed by either a month name, day name or .weekday() function. * Example

	Date.today().is().friday(); // true|false
	Date.today().is().fri();
	Date.today().is().march();
	Date.today().is().mar();
	
* * @return {Boolean} true|false */ $P.is = function () { this._is = true; return this; }; /** * Determines if two date objects occur on/in exactly the same instance of the subsequent date part function. * The function .same() must be followed by a date part function (example: .day(), .month(), .year(), etc). * * An optional Date can be passed in the date part function. If now date is passed as a parameter, 'Now' is used. * * The following example demonstrates how to determine if two dates fall on the exact same day. * * Example

	var d1 = Date.today(); // today at 00:00
	var d2 = new Date();   // exactly now.

	// Do they occur on the same day?
	d1.same().day(d2); // true
	
	// Do they occur on the same hour?
	d1.same().hour(d2); // false, unless d2 hour is '00' (midnight).
	
	// What if it's the same day, but one year apart?
	var nextYear = Date.today().add(1).year();

	d1.same().day(nextYear); // false, because the dates must occur on the exact same day. 
	
* * Scenario: Determine if a given date occurs during some week period 2 months from now. * * Example

	var future = Date.today().add(2).months();
	return someDate.same().week(future); // true|false;
	
* * @return {Boolean} true|false */ $P.same = function () { this._same = true; this._isSecond = false; return this; }; /** * Determines if the current date/time occurs during Today. Must be preceded by the .is() function. * Example

	someDate.is().today();    // true|false
	new Date().is().today();  // true
	Date.today().is().today();// true
	Date.today().add(-1).day().is().today(); // false
	
* * @return {Boolean} true|false */ $P.today = function () { return this.same().day(); }; /** * Determines if the current date is a weekday. This function must be preceded by the .is() function. * Example

	Date.today().is().weekday(); // true|false
	
* * @return {Boolean} true|false */ $P.weekday = function () { if (this._nth) { return df("Weekday").call(this); } if (this._move) { return this.addWeekdays(this._orient); } if (this._is) { this._is = false; return (!this.is().sat() && !this.is().sun()); } return false; }; /** * Determines if the current date is on the weekend. This function must be preceded by the .is() function. * Example

	Date.today().is().weekend(); // true|false
	
* * @return {Boolean} true|false */ $P.weekend = function () { if (this._is) { this._is = false; return (this.is().sat() || this.is().sun()); } return false; }; /** * Sets the Time of the current Date instance. A string "6:15 pm" or config object {hour:18, minute:15} are accepted. * Example

	// Set time to 6:15pm with a String
	Date.today().at("6:15pm");

	// Set time to 6:15pm with a config object
	Date.today().at({hour:18, minute:15});
	
* * @return {Date} date */ $P.at = function (time) { return (typeof time === "string") ? $D.parse(this.toString("d") + " " + time) : this.set(time); }; /** * Creates a new Date() and adds this (Number) to the date based on the preceding date element function (eg. second|minute|hour|day|month|year). * Example

	// Undeclared Numbers must be wrapped with parentheses. Requirment of JavaScript.
	(3).days().fromNow();
	(6).months().fromNow();

	// Declared Number variables do not require parentheses. 
	var n = 6;
	n.months().fromNow();
	
* * @return {Date} A new Date instance */ $N.fromNow = $N.after = function (date) { var c = {}; c[this._dateElement] = this; return ((!date) ? new Date() : date.clone()).add(c); }; /** * Creates a new Date() and subtract this (Number) from the date based on the preceding date element function (eg. second|minute|hour|day|month|year). * Example

	// Undeclared Numbers must be wrapped with parentheses. Requirment of JavaScript.
	(3).days().ago();
	(6).months().ago();

	// Declared Number variables do not require parentheses. 
	var n = 6;
	n.months().ago();
	
* * @return {Date} A new Date instance */ $N.ago = $N.before = function (date) { var c = {}, s = (this._dateElement[this._dateElement.length-1] !== "s") ? this._dateElement + "s" : this._dateElement; c[s] = this * -1; return ((!date) ? new Date() : date.clone()).add(c); }; // Do NOT modify the following string tokens. These tokens are used to build dynamic functions. // All culture-specific strings can be found in the CultureInfo files. var dx = ("sunday monday tuesday wednesday thursday friday saturday").split(/\s/), mx = ("january february march april may june july august september october november december").split(/\s/), px = ("Millisecond Second Minute Hour Day Week Month Year Quarter Weekday").split(/\s/), pxf = ("Milliseconds Seconds Minutes Hours Date Week Month FullYear Quarter").split(/\s/), nth = ("final first second third fourth fifth").split(/\s/), de; /** * Returns an object literal of all the date parts. * Example

	var o = new Date().toObject();
	
	// { year: 2008, month: 4, week: 20, day: 13, hour: 18, minute: 9, second: 32, millisecond: 812 }
	
	// The object properties can be referenced directly from the object.
	
	alert(o.day);  // alerts "13"
	alert(o.year); // alerts "2008"
	
* * @return {Date} An object literal representing the original date object. */ $P.toObject = function () { var o = {}; for (var i = 0; i < px.length; i++) { if (this["get" + pxf[i]]) { o[px[i].toLowerCase()] = this["get" + pxf[i]](); } } return o; }; /** * Returns a date created from an object literal. Ignores the .week property if set in the config. * Example

	var o = new Date().toObject();
	
	return Date.fromObject(o); // will return the same date. 

	var o2 = {month: 1, day: 20, hour: 18}; // birthday party!
	Date.fromObject(o2);
	
* * @return {Date} An object literal representing the original date object. */ $D.fromObject = function(config) { config.week = null; return Date.today().set(config); }; // Create day name functions and abbreviated day name functions (eg. monday(), friday(), fri()). var df = function (n) { return function () { if (this._is) { this._is = false; return this.getDay() === n; } if (this._move) { this._move = null; } if (this._nth !== null) { // If the .second() function was called earlier, remove the _orient // from the date, and then continue. // This is required because 'second' can be used in two different context. // // Example // // Date.today().add(1).second(); // Date.march().second().monday(); // // Things get crazy with the following... // Date.march().add(1).second().second().monday(); // but it works!! // if (this._isSecond) { this.addSeconds(this._orient * -1); } // make sure we reset _isSecond this._isSecond = false; var ntemp = this._nth; this._nth = null; var temp = this.clone().moveToLastDayOfMonth(); this.moveToNthOccurrence(n, ntemp); if (this > temp) { throw new RangeError($D.getDayName(n) + " does not occur " + ntemp + " times in the month of " + $D.getMonthName(temp.getMonth()) + " " + temp.getFullYear() + "."); } return this; } return this.moveToDayOfWeek(n, this._orient); }; }; var sdf = function (n) { return function () { var t = $D.today(), shift = n - t.getDay(); if (n === 0 && Date.CultureInfo.firstDayOfWeek === 1 && t.getDay() !== 0) { shift = shift + 7; } return t.addDays(shift); }; }; // Create month name functions and abbreviated month name functions (eg. january(), march(), mar()). var month_instance_functions = function (n) { return function () { if (this._is) { this._is = false; return this.getMonth() === n; } return this.moveToMonth(n, this._orient); }; }; var month_static_functions = function (n) { return function () { return $D.today().set({ month: n, day: 1 }); }; }; var processTerms = function (names, staticFunc, instanceFunc) { for (var i = 0; i < names.length; i++) { // Create constant static Name variables. $D[names[i].toUpperCase()] = $D[names[i].toUpperCase().substring(0, 3)] = i; // Create Name functions. $D[names[i]] = $D[names[i].substring(0, 3)] = staticFunc(i); // Create Name instance functions. $P[names[i]] = $P[names[i].substring(0, 3)] = instanceFunc(i); } }; processTerms(dx, sdf, df); processTerms(mx, month_static_functions, month_instance_functions); // Create date element functions and plural date element functions used with Date (eg. day(), days(), months()). var ef = function (j) { return function () { // if the .second() function was called earlier, the _orient // has alread been added. Just return this and reset _isSecond. if (this._isSecond) { this._isSecond = false; return this; } if (this._same) { this._same = this._is = false; var o1 = this.toObject(), o2 = (arguments[0] || new Date()).toObject(), v = "", k = j.toLowerCase(); // the substr trick with -1 doesn't work in IE8 or less k = (k[k.length-1] === "s") ? k.substring(0,k.length-1) : k; for (var m = (px.length - 1); m > -1; m--) { v = px[m].toLowerCase(); if (o1[v] !== o2[v]) { return false; } if (k === v) { break; } } return true; } if (j.substring(j.length - 1) !== "s") { j += "s"; } if (this._move) { this._move = null; } return this["add" + j](this._orient); }; }; var nf = function (n) { return function () { this._dateElement = n; return this; }; }; for (var k = 0; k < px.length; k++) { de = px[k].toLowerCase(); if(de !== "weekday") { // Create date element functions and plural date element functions used with Date (eg. day(), days(), months()). $P[de] = $P[de + "s"] = ef(px[k]); // Create date element functions and plural date element functions used with Number (eg. day(), days(), months()). $N[de] = $N[de + "s"] = nf(de + "s"); } } $P._ss = ef("Second"); var nthfn = function (n) { return function (dayOfWeek) { if (this._same) { return this._ss(arguments[0]); } if (dayOfWeek || dayOfWeek === 0) { return this.moveToNthOccurrence(dayOfWeek, n); } this._nth = n; // if the operator is 'second' add the _orient, then deal with it later... if (n === 2 && (dayOfWeek === undefined || dayOfWeek === null)) { this._isSecond = true; return this.addSeconds(this._orient); } return this; }; }; for (var l = 0; l < nth.length; l++) { $P[nth[l]] = (l === 0) ? nthfn(-1) : nthfn(l); } }()); (function () { "use strict"; Date.Parsing = { Exception: function (s) { this.message = "Parse error at '" + s.substring(0, 10) + " ...'"; } }; var $P = Date.Parsing; var dayOffsets = { standard: [0,31,59,90,120,151,181,212,243,273,304,334], leap: [0,31,60,91,121,152,182,213,244,274,305,335] }; $P.isLeapYear = function(year) { return ((year % 4 === 0) && (year % 100 !== 0)) || (year % 400 === 0); }; var utils = { multiReplace : function (str, hash ) { var key; for (key in hash) { if (Object.prototype.hasOwnProperty.call(hash, key)) { var regex; if (typeof hash[key] === "function") { } else { regex = (hash[key] instanceof RegExp) ? hash[key] : new RegExp(hash[key], "g"); } str = str.replace(regex, key); } } return str; }, getDayOfYearFromWeek : function (obj) { var d, jan4, offset; obj.weekDay = (!obj.weekDay && obj.weekDay !== 0) ? 1 : obj.weekDay; d = new Date(obj.year, 0, 4); jan4 = d.getDay() === 0 ? 7 : d.getDay(); // JS is 0 indexed on Sunday. offset = jan4+3; obj.dayOfYear = ((obj.week * 7) + (obj.weekDay === 0 ? 7 : obj.weekDay))-offset; return obj; }, getDayOfYear : function (obj, dayOffset) { if (!obj.dayOfYear) { obj = utils.getDayOfYearFromWeek(obj); } for (var i=0;i <= dayOffset.length;i++) { if (obj.dayOfYear < dayOffset[i] || i === dayOffset.length) { obj.day = obj.day ? obj.day : (obj.dayOfYear - dayOffset[i-1]); break; } else { obj.month = i; } } return obj; }, adjustForTimeZone : function (obj, date) { var offset; if (obj.zone.toUpperCase() === "Z" || (obj.zone_hours === 0 && obj.zone_minutes === 0)) { // it's UTC/GML so work out the current timeszone offset offset = -date.getTimezoneOffset(); } else { offset = (obj.zone_hours*60) + (obj.zone_minutes || 0); if (obj.zone_sign === "+") { offset *= -1; } offset -= date.getTimezoneOffset(); } date.setMinutes(date.getMinutes()+offset); return date; }, setDefaults : function (obj) { obj.year = obj.year || Date.today().getFullYear(); obj.hours = obj.hours || 0; obj.minutes = obj.minutes || 0; obj.seconds = obj.seconds || 0; obj.milliseconds = obj.milliseconds || 0; if (!(!obj.month && (obj.week || obj.dayOfYear))) { // if we have a month, or if we don't but don't have the day calculation data obj.month = obj.month || 0; obj.day = obj.day || 1; } return obj; }, dataNum: function (data, mod, explict, postProcess) { var dataNum = data*1; if (mod) { if (postProcess) { return data ? mod(data)*1 : data; } else { return data ? mod(dataNum) : data; } } else if (!explict){ return data ? dataNum : data; } else { return (data && typeof data !== "undefined") ? dataNum : data; } }, timeDataProcess: function (obj) { var timeObj = {}; for (var x in obj.data) { if (obj.data.hasOwnProperty(x)) { timeObj[x] = obj.ignore[x] ? obj.data[x] : utils.dataNum(obj.data[x], obj.mods[x], obj.explict[x], obj.postProcess[x]); } } if (obj.data.secmins) { obj.data.secmins = obj.data.secmins.replace(",", ".") * 60; if (!timeObj.minutes) { timeObj.minutes = obj.data.secmins; } else if (!timeObj.seconds) { timeObj.seconds = obj.data.secmins; } delete obj.secmins; } return timeObj; }, buildTimeObjectFromData: function (data) { var time = utils.timeDataProcess({ data: { year : data[1], month : data[5], day : data[7], week : data[8], dayOfYear : data[10], hours : data[15], zone_hours : data[23], zone_minutes : data[24], zone : data[21], zone_sign : data[22], weekDay : data[9], minutes: data[16], seconds: data[19], milliseconds: data[20], secmins: data[18] }, mods: { month: function(data) { return data-1; }, weekDay: function (data) { data = Math.abs(data); return (data === 7 ? 0 : data); }, minutes: function (data) { return data.replace(":",""); }, seconds: function (data) { return Math.floor( (data.replace(":","").replace(",","."))*1 ); }, milliseconds: function (data) { return (data.replace(",",".")*1000); } }, postProcess: { minutes: true, seconds: true, milliseconds: true }, explict: { zone_hours: true, zone_minutes: true }, ignore: { zone: true, zone_sign: true, secmins: true } }); return time; }, addToHash: function (hash, keys, data) { keys = keys; data = data; var len = keys.length; for (var i = 0; i < len; i++) { hash[keys[i]] = data[i]; } return hash; }, combineRegex: function (r1, r2) { return new RegExp("(("+r1.source+")\\s("+r2.source+"))"); }, getDateNthString: function(add, last, inc){ if (add) { return Date.today().addDays(inc).toString("d"); } else if (last) { return Date.today().last()[inc]().toString("d"); } }, buildRegexData: function (array) { var arr = []; var len = array.length; for (var i=0; i < len; i++) { if (Object.prototype.toString.call(array[i]) === '[object Array]') { // oldIE compat version of Array.isArray arr.push(this.combineRegex(array[i][0], array[i][1])); } else { arr.push(array[i]); } } return arr; } }; $P.processTimeObject = function (obj) { var date, dayOffset; utils.setDefaults(obj); dayOffset = ($P.isLeapYear(obj.year)) ? dayOffsets.leap : dayOffsets.standard; if (!obj.month && (obj.week || obj.dayOfYear)) { utils.getDayOfYear(obj, dayOffset); } else { obj.dayOfYear = dayOffset[obj.month] + obj.day; } date = new Date(obj.year, obj.month, obj.day, obj.hours, obj.minutes, obj.seconds, obj.milliseconds); if (obj.zone) { utils.adjustForTimeZone(obj, date); // adjust (and calculate) for timezone } return date; }; $P.ISO = { regex : /^([\+-]?\d{4}(?!\d{2}\b))((-?)((0[1-9]|1[0-2])(\3([12]\d|0[1-9]|3[01]))?|W([0-4]\d|5[0-3])(-?[1-7])?|(00[1-9]|0[1-9]\d|[12]\d{2}|3([0-5]\d|6[1-6])))([T\s]((([01]\d|2[0-4])((:?)[0-5]\d)?|24\:?00)([\.,]\d+(?!:))?)?(\17[0-5]\d([\.,]\d+)?)?\s?([zZ]|([\+-])([01]\d|2[0-3]):?([0-5]\d)?)?)?)?$/, parse : function (s) { var time, data = s.match(this.regex); if (!data || !data.length) { return null; } time = utils.buildTimeObjectFromData(data); if (!time.year || (!time.year && (!time.month && !time.day) && (!time.week && !time.dayOfYear)) ) { return null; } return $P.processTimeObject(time); } }; $P.Numeric = { isNumeric: function (e){return!isNaN(parseFloat(e))&&isFinite(e);}, regex: /\b([0-1]?[0-9])([0-3]?[0-9])([0-2]?[0-9]?[0-9][0-9])\b/i, parse: function (s) { var data, i, time = {}, order = Date.CultureInfo.dateElementOrder.split(""); if (!(this.isNumeric(s)) || // if it's non-numeric OR (s[0] === "+" && s[0] === "-")) { // It's an arithmatic string (eg +/-1000) return null; } if (s.length < 5 && s.indexOf(".") < 0 && s.indexOf("/") < 0) { // assume it's just a year. time.year = s; return $P.processTimeObject(time); } data = s.match(this.regex); if (!data || !data.length) { return null; } for (i=0; i < order.length; i++) { switch(order[i]) { case "d": time.day = data[i+1]; break; case "m": time.month = (data[i+1]-1); break; case "y": time.year = data[i+1]; break; } } return $P.processTimeObject(time); } }; $P.Normalizer = { regexData: function () { var $R = Date.CultureInfo.regexPatterns; return utils.buildRegexData([ $R.tomorrow, $R.yesterday, [$R.past, $R.mon], [$R.past, $R.tue], [$R.past, $R.wed], [$R.past, $R.thu], [$R.past, $R.fri], [$R.past, $R.sat], [$R.past, $R.sun] ]); }, basicReplaceHash : function() { var $R = Date.CultureInfo.regexPatterns; return { "January": $R.jan.source, "February": $R.feb, "March": $R.mar, "April": $R.apr, "May": $R.may, "June": $R.jun, "July": $R.jul, "August": $R.aug, "September": $R.sep, "October": $R.oct, "November": $R.nov, "December": $R.dec, "": /\bat\b/gi, " ": /\s{2,}/, "am": $R.inTheMorning, "9am": $R.thisMorning, "pm": $R.inTheEvening, "7pm":$R.thisEvening }; }, keys : function(){ return [ utils.getDateNthString(true, false, 1), // tomorrow utils.getDateNthString(true, false, -1), // yesterday utils.getDateNthString(false, true, "monday"), //last mon utils.getDateNthString(false, true, "tuesday"), //last tues utils.getDateNthString(false, true, "wednesday"), //last wed utils.getDateNthString(false, true, "thursday"), //last thurs utils.getDateNthString(false, true, "friday"), //last fri utils.getDateNthString(false, true, "saturday"), //last sat utils.getDateNthString(false, true, "sunday") //last sun ]; }, buildRegexFunctions: function () { var $R = Date.CultureInfo.regexPatterns; var __ = Date.i18n.__; var tomorrowRE = new RegExp("(\\b\\d\\d?("+__("AM")+"|"+__("PM")+")? )("+$R.tomorrow.source.slice(1)+")", "i"); // adapted tomorrow regex for AM PM relative dates var todayRE = new RegExp($R.today.source + "(?!\\s*([+-]))\\b"); // today, but excludes the math operators (eg "today + 2h") this.replaceFuncs = [ [todayRE, function (full) { return (full.length > 1) ? Date.today().toString("d") : full; }], [tomorrowRE, function(full, m1) { var t = Date.today().addDays(1).toString("d"); return (t + " " + m1); }], [$R.amThisMorning, function(str, am){return am;}], [$R.pmThisEvening, function(str, pm){return pm;}] ]; }, buildReplaceData: function () { this.buildRegexFunctions(); this.replaceHash = utils.addToHash(this.basicReplaceHash(), this.keys(), this.regexData()); }, stringReplaceFuncs: function (s) { for (var i=0; i < this.replaceFuncs.length; i++) { s = s.replace(this.replaceFuncs[i][0], this.replaceFuncs[i][1]); } return s; }, parse: function (s) { s = this.stringReplaceFuncs(s); s = utils.multiReplace(s, this.replaceHash); try { var n = s.split(/([\s\-\.\,\/\x27]+)/); if (n.length === 3 && $P.Numeric.isNumeric(n[0]) && $P.Numeric.isNumeric(n[2]) && (n[2].length >= 4)) { // ok, so we're dealing with x/year. But that's not a full date. // This fixes wonky dateElementOrder parsing when set to dmy order. if (Date.CultureInfo.dateElementOrder[0] === "d") { s = "1/" + n[0] + "/" + n[2]; // set to 1st of month and normalize the seperator } } } catch (e) {} return s; } }; $P.Normalizer.buildReplaceData(); }()); (function () { var $P = Date.Parsing; var _ = $P.Operators = { // // Tokenizers // rtoken: function (r) { // regex token return function (s) { var mx = s.match(r); if (mx) { return ([ mx[0], s.substring(mx[0].length) ]); } else { throw new $P.Exception(s); } }; }, token: function () { // whitespace-eating token return function (s) { return _.rtoken(new RegExp("^\\s*" + s + "\\s*"))(s); }; }, stoken: function (s) { // string token return _.rtoken(new RegExp("^" + s)); }, // Atomic Operators until: function (p) { return function (s) { var qx = [], rx = null; while (s.length) { try { rx = p.call(this, s); } catch (e) { qx.push(rx[0]); s = rx[1]; continue; } break; } return [ qx, s ]; }; }, many: function (p) { return function (s) { var rx = [], r = null; while (s.length) { try { r = p.call(this, s); } catch (e) { return [ rx, s ]; } rx.push(r[0]); s = r[1]; } return [ rx, s ]; }; }, // generator operators -- see below optional: function (p) { return function (s) { var r = null; try { r = p.call(this, s); } catch (e) { return [ null, s ]; } return [ r[0], r[1] ]; }; }, not: function (p) { return function (s) { try { p.call(this, s); } catch (e) { return [null, s]; } throw new $P.Exception(s); }; }, ignore: function (p) { return p ? function (s) { var r = null; r = p.call(this, s); return [null, r[1]]; } : null; }, product: function () { var px = arguments[0], qx = Array.prototype.slice.call(arguments, 1), rx = []; for (var i = 0 ; i < px.length ; i++) { rx.push(_.each(px[i], qx)); } return rx; }, cache: function (rule) { var cache = {}, cache_length = 0, cache_keys = [], CACHE_MAX = Date.Config.CACHE_MAX || 100000, r = null; var cacheCheck = function () { if (cache_length === CACHE_MAX) { // kill several keys, don't want to have to do this all the time... for (var i=0; i < 10; i++) { var key = cache_keys.shift(); if (key) { delete cache[key]; cache_length--; } } } }; return function (s) { cacheCheck(); try { r = cache[s] = (cache[s] || rule.call(this, s)); } catch (e) { r = cache[s] = e; } cache_length++; cache_keys.push(s); if (r instanceof $P.Exception) { throw r; } else { return r; } }; }, // vector operators -- see below any: function () { var px = arguments; return function (s) { var r = null; for (var i = 0; i < px.length; i++) { if (px[i] == null) { continue; } try { r = (px[i].call(this, s)); } catch (e) { r = null; } if (r) { return r; } } throw new $P.Exception(s); }; }, each: function () { var px = arguments; return function (s) { var rx = [], r = null; for (var i = 0; i < px.length ; i++) { if (px[i] == null) { continue; } try { r = (px[i].call(this, s)); } catch (e) { throw new $P.Exception(s); } rx.push(r[0]); s = r[1]; } return [ rx, s]; }; }, all: function () { var px = arguments, _ = _; return _.each(_.optional(px)); }, // delimited operators sequence: function (px, d, c) { d = d || _.rtoken(/^\s*/); c = c || null; if (px.length === 1) { return px[0]; } return function (s) { var r = null, q = null; var rx = []; for (var i = 0; i < px.length ; i++) { try { r = px[i].call(this, s); } catch (e) { break; } rx.push(r[0]); try { q = d.call(this, r[1]); } catch (ex) { q = null; break; } s = q[1]; } if (!r) { throw new $P.Exception(s); } if (q) { throw new $P.Exception(q[1]); } if (c) { try { r = c.call(this, r[1]); } catch (ey) { throw new $P.Exception(r[1]); } } return [ rx, (r?r[1]:s) ]; }; }, // // Composite Operators // between: function (d1, p, d2) { d2 = d2 || d1; var _fn = _.each(_.ignore(d1), p, _.ignore(d2)); return function (s) { var rx = _fn.call(this, s); return [[rx[0][0], r[0][2]], rx[1]]; }; }, list: function (p, d, c) { d = d || _.rtoken(/^\s*/); c = c || null; return (p instanceof Array ? _.each(_.product(p.slice(0, -1), _.ignore(d)), p.slice(-1), _.ignore(c)) : _.each(_.many(_.each(p, _.ignore(d))), px, _.ignore(c))); }, set: function (px, d, c) { d = d || _.rtoken(/^\s*/); c = c || null; return function (s) { // r is the current match, best the current 'best' match // which means it parsed the most amount of input var r = null, p = null, q = null, rx = null, best = [[], s], last = false; // go through the rules in the given set for (var i = 0; i < px.length ; i++) { // last is a flag indicating whether this must be the last element // if there is only 1 element, then it MUST be the last one q = null; p = null; r = null; last = (px.length === 1); // first, we try simply to match the current pattern // if not, try the next pattern try { r = px[i].call(this, s); } catch (e) { continue; } // since we are matching against a set of elements, the first // thing to do is to add r[0] to matched elements rx = [[r[0]], r[1]]; // if we matched and there is still input to parse and // we don't already know this is the last element, // we're going to next check for the delimiter ... // if there's none, or if there's no input left to parse // than this must be the last element after all ... if (r[1].length > 0 && ! last) { try { q = d.call(this, r[1]); } catch (ex) { last = true; } } else { last = true; } // if we parsed the delimiter and now there's no more input, // that means we shouldn't have parsed the delimiter at all // so don't update r and mark this as the last element ... if (!last && q[1].length === 0) { last = true; } // so, if this isn't the last element, we're going to see if // we can get any more matches from the remaining (unmatched) // elements ... if (!last) { // build a list of the remaining rules we can match against, // i.e., all but the one we just matched against var qx = []; for (var j = 0; j < px.length ; j++) { if (i !== j) { qx.push(px[j]); } } // now invoke recursively set with the remaining input // note that we don't include the closing delimiter ... // we'll check for that ourselves at the end p = _.set(qx, d).call(this, q[1]); // if we got a non-empty set as a result ... // (otw rx already contains everything we want to match) if (p[0].length > 0) { // update current result, which is stored in rx ... // basically, pick up the remaining text from p[1] // and concat the result from p[0] so that we don't // get endless nesting ... rx[0] = rx[0].concat(p[0]); rx[1] = p[1]; } } // at this point, rx either contains the last matched element // or the entire matched set that starts with this element. // now we just check to see if this variation is better than // our best so far, in terms of how much of the input is parsed if (rx[1].length < best[1].length) { best = rx; } // if we've parsed all the input, then we're finished if (best[1].length === 0) { break; } } // so now we've either gone through all the patterns trying them // as the initial match; or we found one that parsed the entire // input string ... // if best has no matches, just return empty set ... if (best[0].length === 0) { return best; } // if a closing delimiter is provided, then we have to check it also if (c) { // we try this even if there is no remaining input because the pattern // may well be optional or match empty input ... try { q = c.call(this, best[1]); } catch (ey) { throw new $P.Exception(best[1]); } // it parsed ... be sure to update the best match remaining input best[1] = q[1]; } // if we're here, either there was no closing delimiter or we parsed it // so now we have the best match; just return it! return best; }; }, forward: function (gr, fname) { return function (s) { return gr[fname].call(this, s); }; }, // // Translation Operators // replace: function (rule, repl) { return function (s) { var r = rule.call(this, s); return [repl, r[1]]; }; }, process: function (rule, fn) { return function (s) { var r = rule.call(this, s); return [fn.call(this, r[0]), r[1]]; }; }, min: function (min, rule) { return function (s) { var rx = rule.call(this, s); if (rx[0].length < min) { throw new $P.Exception(s); } return rx; }; } }; // Generator Operators And Vector Operators // Generators are operators that have a signature of F(R) => R, // taking a given rule and returning another rule, such as // ignore, which parses a given rule and throws away the result. // Vector operators are those that have a signature of F(R1,R2,...) => R, // take a list of rules and returning a new rule, such as each. // Generator operators are converted (via the following _generator // function) into functions that can also take a list or array of rules // and return an array of new rules as though the function had been // called on each rule in turn (which is what actually happens). // This allows generators to be used with vector operators more easily. // Example: // each(ignore(foo, bar)) instead of each(ignore(foo), ignore(bar)) // This also turns generators into vector operators, which allows // constructs like: // not(cache(foo, bar)) var _generator = function (op) { function gen() { var args = null, rx = [], px, i; if (arguments.length > 1) { args = Array.prototype.slice.call(arguments); } else if (arguments[0] instanceof Array) { args = arguments[0]; } if (args) { px = args.shift(); if (px.length > 0) { args.unshift(px[i]); rx.push(op.apply(null, args)); args.shift(); return rx; } } else { return op.apply(null, arguments); } } return gen; }; var gx = "optional not ignore cache".split(/\s/); for (var i = 0 ; i < gx.length ; i++) { _[gx[i]] = _generator(_[gx[i]]); } var _vector = function (op) { return function () { if (arguments[0] instanceof Array) { return op.apply(null, arguments[0]); } else { return op.apply(null, arguments); } }; }; var vx = "each any all".split(/\s/); for (var j = 0 ; j < vx.length ; j++) { _[vx[j]] = _vector(_[vx[j]]); } }()); (function () { var $D = Date; var flattenAndCompact = function (ax) { var rx = []; for (var i = 0; i < ax.length; i++) { if (ax[i] instanceof Array) { rx = rx.concat(flattenAndCompact(ax[i])); } else { if (ax[i]) { rx.push(ax[i]); } } } return rx; }; var parseMeridian = function () { if (this.meridian && (this.hour || this.hour === 0)) { if (this.meridian === "a" && this.hour > 11 && Date.Config.strict24hr){ throw "Invalid hour and meridian combination"; } else if (this.meridian === "p" && this.hour < 12 && Date.Config.strict24hr){ throw "Invalid hour and meridian combination"; } else if (this.meridian === "p" && this.hour < 12) { this.hour = this.hour + 12; } else if (this.meridian === "a" && this.hour === 12) { this.hour = 0; } } }; var setDefaults = function () { var now = new Date(); if ((this.hour || this.minute) && (!this.month && !this.year && !this.day)) { this.day = now.getDate(); } if (!this.year) { this.year = now.getFullYear(); } if (!this.month && this.month !== 0) { this.month = now.getMonth(); } if (!this.day) { this.day = 1; } if (!this.hour) { this.hour = 0; } if (!this.minute) { this.minute = 0; } if (!this.second) { this.second = 0; } if (!this.millisecond) { this.millisecond = 0; } }; var finishUtils = { getToday: function () { if (this.now || "hour minute second".indexOf(this.unit) !== -1) { return new Date(); } else { return $D.today(); } }, setDaysFromWeekday: function (today, orient){ var gap; orient = orient || 1; this.unit = "day"; gap = ($D.getDayNumberFromName(this.weekday) - today.getDay()); this.days = gap ? ((gap + (orient * 7)) % 7) : (orient * 7); return this; }, setMonthsFromMonth: function (today, orient) { var gap; orient = orient || 1; this.unit = "month"; gap = (this.month - today.getMonth()); this.months = gap ? ((gap + (orient * 12)) % 12) : (orient * 12); this.month = null; return this; }, setDMYFromWeekday: function () { var d = Date[this.weekday](); this.day = d.getDate(); if (!this.month) { this.month = d.getMonth(); } this.year = d.getFullYear(); return this; }, setUnitValue: function (orient) { if (!this.value && this.operator && this.operator !== null && this[this.unit + "s"] && this[this.unit + "s"] !== null) { this[this.unit + "s"] = this[this.unit + "s"] + ((this.operator === "add") ? 1 : -1) + (this.value||0) * orient; } else if (this[this.unit + "s"] == null || this.operator != null) { if (!this.value) { this.value = 1; } this[this.unit + "s"] = this.value * orient; } }, generateDateFromWeeks: function () { var weekday = (this.weekday !== undefined) ? this.weekday : "today"; var d = Date[weekday]().addWeeks(this.weeks); if (this.now) { d.setTimeToNow(); } return d; } }; $D.Translator = { hour: function (s) { return function () { this.hour = Number(s); }; }, minute: function (s) { return function () { this.minute = Number(s); }; }, second: function (s) { return function () { this.second = Number(s); }; }, /* for ss.s format */ secondAndMillisecond: function (s) { return function () { var mx = s.match(/^([0-5][0-9])\.([0-9]{1,3})/); this.second = Number(mx[1]); this.millisecond = Number(mx[2]); }; }, meridian: function (s) { return function () { this.meridian = s.slice(0, 1).toLowerCase(); }; }, timezone: function (s) { return function () { var n = s.replace(/[^\d\+\-]/g, ""); if (n.length) { this.timezoneOffset = Number(n); } else { this.timezone = s.toLowerCase(); } }; }, day: function (x) { var s = x[0]; return function () { this.day = Number(s.match(/\d+/)[0]); if (this.day < 1) { throw "invalid day"; } }; }, month: function (s) { return function () { this.month = (s.length === 3) ? "jan feb mar apr may jun jul aug sep oct nov dec".indexOf(s)/4 : Number(s) - 1; if (this.month < 0) { throw "invalid month"; } }; }, year: function (s) { return function () { var n = Number(s); this.year = ((s.length > 2) ? n : (n + (((n + 2000) < Date.CultureInfo.twoDigitYearMax) ? 2000 : 1900))); }; }, rday: function (s) { return function () { switch (s) { case "yesterday": this.days = -1; break; case "tomorrow": this.days = 1; break; case "today": this.days = 0; break; case "now": this.days = 0; this.now = true; break; } }; }, finishExact: function (x) { var d; x = (x instanceof Array) ? x : [x]; for (var i = 0 ; i < x.length ; i++) { if (x[i]) { x[i].call(this); } } setDefaults.call(this); parseMeridian.call(this); if (this.day > $D.getDaysInMonth(this.year, this.month)) { throw new RangeError(this.day + " is not a valid value for days."); } d = new Date(this.year, this.month, this.day, this.hour, this.minute, this.second, this.millisecond); if (this.year < 100) { d.setFullYear(this.year); // means years less that 100 are process correctly. JS will parse it otherwise as 1900-1999. } if (this.timezone) { d.set({ timezone: this.timezone }); } else if (this.timezoneOffset) { d.set({ timezoneOffset: this.timezoneOffset }); } return d; }, finish: function (x) { var today, expression, orient, temp; x = (x instanceof Array) ? flattenAndCompact(x) : [ x ]; if (x.length === 0) { return null; } for (var i = 0 ; i < x.length ; i++) { if (typeof x[i] === "function") { x[i].call(this); } } if (this.now && !this.unit && !this.operator) { return new Date(); } else { today = finishUtils.getToday.call(this); } expression = !!(this.days && this.days !== null || this.orient || this.operator); orient = ((this.orient === "past" || this.operator === "subtract") ? -1 : 1); if (this.month && this.unit === "week") { this.value = this.month + 1; delete this.month; delete this.day; } if ((this.month || this.month === 0) && "year day hour minute second".indexOf(this.unit) !== -1) { if (!this.value) { this.value = this.month + 1; } this.month = null; expression = true; } if (!expression && this.weekday && !this.day && !this.days) { finishUtils.setDMYFromWeekday.call(this); } if (expression && this.weekday && this.unit !== "month" && this.unit !== "week") { finishUtils.setDaysFromWeekday.call(this, today, orient); } if (this.weekday && this.unit !== "week" && !this.day && !this.days) { temp = Date[this.weekday](); this.day = temp.getDate(); if (temp.getMonth() !== today.getMonth()) { this.month = temp.getMonth(); } } if (this.month && this.unit === "day" && this.operator) { if (!this.value) { this.value = (this.month + 1); } this.month = null; } if (this.value != null && this.month != null && this.year != null) { this.day = this.value * 1; } if (this.month && !this.day && this.value) { today.set({ day: this.value * 1 }); if (!expression) { this.day = this.value * 1; } } if (!this.month && this.value && this.unit === "month" && !this.now) { this.month = this.value; expression = true; } if (expression && (this.month || this.month === 0) && this.unit !== "year") { finishUtils.setMonthsFromMonth.call(this, today, orient); } if (!this.unit) { this.unit = "day"; } finishUtils.setUnitValue.call(this, orient); parseMeridian.call(this); if ((this.month || this.month === 0) && !this.day) { this.day = 1; } if (!this.orient && !this.operator && this.unit === "week" && this.value && !this.day && !this.month) { return Date.today().setWeek(this.value); } if (this.unit === "week" && this.weeks && !this.day && !this.month) { return finishUtils.generateDateFromWeeks.call(this); } if (expression && this.timezone && this.day && this.days) { this.day = this.days; } if (expression){ today.add(this); } else { today.set(this); } if (this.timezone) { this.timezone = this.timezone.toUpperCase(); var offset = $D.getTimezoneOffset(this.timezone); var timezone; if (today.hasDaylightSavingTime()) { // lets check that we're being sane with timezone setting timezone = $D.getTimezoneAbbreviation(offset, today.isDaylightSavingTime()); if (timezone !== this.timezone) { // bugger, we're in a place where things like EST vs EDT matters. if (today.isDaylightSavingTime()) { today.addHours(-1); } else { today.addHours(1); } } } today.setTimezoneOffset(offset); } return today; } }; }()); (function () { var $D = Date; $D.Grammar = {}; var _ = $D.Parsing.Operators, g = $D.Grammar, t = $D.Translator, _fn; // Allow rolling up into general purpose rules _fn = function () { return _.each(_.any.apply(null, arguments), _.not(g.ctoken2("timeContext"))); }; g.datePartDelimiter = _.rtoken(/^([\s\-\.\,\/\x27]+)/); g.timePartDelimiter = _.stoken(":"); g.whiteSpace = _.rtoken(/^\s*/); g.generalDelimiter = _.rtoken(/^(([\s\,]|at|@|on)+)/); var _C = {}; g.ctoken = function (keys) { var fn = _C[keys]; if (! fn) { var c = Date.CultureInfo.regexPatterns; var kx = keys.split(/\s+/), px = []; for (var i = 0; i < kx.length ; i++) { px.push(_.replace(_.rtoken(c[kx[i]]), kx[i])); } fn = _C[keys] = _.any.apply(null, px); } return fn; }; g.ctoken2 = function (key) { return _.rtoken(Date.CultureInfo.regexPatterns[key]); }; var cacheProcessRtoken = function (key, token, type, eachToken) { if (eachToken) { g[key] = _.cache(_.process(_.each(_.rtoken(token),_.optional(g.ctoken2(eachToken))), type)); } else { g[key] = _.cache(_.process(_.rtoken(token), type)); } }; var cacheProcessCtoken = function (token, type) { return _.cache(_.process(g.ctoken2(token), type)); }; var _F = {}; //function cache var _get = function (f) { _F[f] = (_F[f] || g.format(f)[0]); return _F[f]; }; g.allformats = function (fx) { var rx = []; if (fx instanceof Array) { for (var i = 0; i < fx.length; i++) { rx.push(_get(fx[i])); } } else { rx.push(_get(fx)); } return rx; }; g.formats = function (fx) { if (fx instanceof Array) { var rx = []; for (var i = 0 ; i < fx.length ; i++) { rx.push(_get(fx[i])); } return _.any.apply(null, rx); } else { return _get(fx); } }; var grammarFormats = { timeFormats: function(){ var i, RTokenKeys = [ "h", "hh", "H", "HH", "m", "mm", "s", "ss", "ss.s", "z", "zz" ], RToken = [ /^(0[0-9]|1[0-2]|[1-9])/, /^(0[0-9]|1[0-2])/, /^([0-1][0-9]|2[0-3]|[0-9])/, /^([0-1][0-9]|2[0-3])/, /^([0-5][0-9]|[0-9])/, /^[0-5][0-9]/, /^([0-5][0-9]|[0-9])/, /^[0-5][0-9]/, /^[0-5][0-9]\.[0-9]{1,3}/, /^((\+|\-)\s*\d\d\d\d)|((\+|\-)\d\d\:?\d\d)/, /^((\+|\-)\s*\d\d\d\d)|((\+|\-)\d\d\:?\d\d)/ ], tokens = [ t.hour, t.hour, t.hour, t.hour, t.minute, t.minute, t.second, t.second, t.secondAndMillisecond, t.timezone, t.timezone ]; for (i=0; i < RTokenKeys.length; i++) { cacheProcessRtoken(RTokenKeys[i], RToken[i], tokens[i]); } g.hms = _.cache(_.sequence([g.H, g.m, g.s], g.timePartDelimiter)); g.t = cacheProcessCtoken("shortMeridian", t.meridian); g.tt = cacheProcessCtoken("longMeridian", t.meridian); g.zzz = cacheProcessCtoken("timezone", t.timezone); g.timeSuffix = _.each(_.ignore(g.whiteSpace), _.set([ g.tt, g.zzz ])); g.time = _.each(_.optional(_.ignore(_.stoken("T"))), g.hms, g.timeSuffix); }, dateFormats: function () { // pre-loaded rules for different date part order preferences var _setfn = function () { return _.set(arguments, g.datePartDelimiter); }; var i, RTokenKeys = [ "d", "dd", "M", "MM", "y", "yy", "yyy", "yyyy" ], RToken = [ /^([0-2]\d|3[0-1]|\d)/, /^([0-2]\d|3[0-1])/, /^(1[0-2]|0\d|\d)/, /^(1[0-2]|0\d)/, /^(\d+)/, /^(\d\d)/, /^(\d\d?\d?\d?)/, /^(\d\d\d\d)/ ], tokens = [ t.day, t.day, t.month, t.month, t.year, t.year, t.year, t.year ], eachToken = [ "ordinalSuffix", "ordinalSuffix" ]; for (i=0; i < RTokenKeys.length; i++) { cacheProcessRtoken(RTokenKeys[i], RToken[i], tokens[i], eachToken[i]); } g.MMM = g.MMMM = _.cache(_.process(g.ctoken("jan feb mar apr may jun jul aug sep oct nov dec"), t.month)); g.ddd = g.dddd = _.cache(_.process(g.ctoken("sun mon tue wed thu fri sat"), function (s) { return function () { this.weekday = s; }; } )); g.day = _fn(g.d, g.dd); g.month = _fn(g.M, g.MMM); g.year = _fn(g.yyyy, g.yy); g.mdy = _setfn(g.ddd, g.month, g.day, g.year); g.ymd = _setfn(g.ddd, g.year, g.month, g.day); g.dmy = _setfn(g.ddd, g.day, g.month, g.year); g.date = function (s) { return ((g[Date.CultureInfo.dateElementOrder] || g.mdy).call(this, s)); }; }, relative: function () { // relative date / time expressions g.orientation = _.process(g.ctoken("past future"), function (s) { return function () { this.orient = s; }; } ); g.operator = _.process(g.ctoken("add subtract"), function (s) { return function () { this.operator = s; }; } ); g.rday = _.process(g.ctoken("yesterday tomorrow today now"), t.rday); g.unit = _.process(g.ctoken("second minute hour day week month year"), function (s) { return function () { this.unit = s; }; } ); } }; g.buildGrammarFormats = function () { // these need to be rebuilt every time the language changes. _C = {}; grammarFormats.timeFormats(); grammarFormats.dateFormats(); grammarFormats.relative(); g.value = _.process(_.rtoken(/^([-+]?\d+)?(st|nd|rd|th)?/), function (s) { return function () { this.value = s.replace(/\D/g, ""); }; } ); g.expression = _.set([g.rday, g.operator, g.value, g.unit, g.orientation, g.ddd, g.MMM ]); g.format = _.process(_.many( _.any( // translate format specifiers into grammar rules _.process( _.rtoken(/^(dd?d?d?(?!e)|MM?M?M?|yy?y?y?|hh?|HH?|mm?|ss?|tt?|zz?z?)/), function (fmt) { if (g[fmt]) { return g[fmt]; } else { throw $D.Parsing.Exception(fmt); } } ), // translate separator tokens into token rules _.process(_.rtoken(/^[^dMyhHmstz]+/), // all legal separators function (s) { return _.ignore(_.stoken(s)); } ) ) ), // construct the parser ... function (rules) { return _.process(_.each.apply(null, rules), t.finishExact); } ); // starting rule for general purpose grammar g._start = _.process(_.set([ g.date, g.time, g.expression ], g.generalDelimiter, g.whiteSpace), t.finish); }; g.buildGrammarFormats(); // parsing date format specifiers - ex: "h:m:s tt" // this little guy will generate a custom parser based // on the format string, ex: g.format("h:m:s tt") // check for these formats first g._formats = g.formats([ "\"yyyy-MM-ddTHH:mm:ssZ\"", "yyyy-MM-ddTHH:mm:ss.sz", "yyyy-MM-ddTHH:mm:ssZ", "yyyy-MM-ddTHH:mm:ssz", "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-ddTHH:mmZ", "yyyy-MM-ddTHH:mmz", "yyyy-MM-ddTHH:mm", "ddd, MMM dd, yyyy H:mm:ss tt", "ddd MMM d yyyy HH:mm:ss zzz", "MMddyyyy", "ddMMyyyy", "Mddyyyy", "ddMyyyy", "Mdyyyy", "dMyyyy", "yyyy", "Mdyy", "dMyy", "d" ]); // real starting rule: tries selected formats first, // then general purpose rule g.start = function (s) { try { var r = g._formats.call({}, s); if (r[1].length === 0) { return r; } } catch (e) {} return g._start.call({}, s); }; }()); (function () { var $D = Date; /** * @desc Converts the specified string value into its JavaScript Date equivalent using CultureInfo specific format information. * * Example

	///////////
	// Dates //
	///////////

	// 15-Oct-2004
	var d1 = Date.parse("10/15/2004");

	// 15-Oct-2004
	var d1 = Date.parse("15-Oct-2004");

	// 15-Oct-2004
	var d1 = Date.parse("2004.10.15");

	//Fri Oct 15, 2004
	var d1 = Date.parse("Fri Oct 15, 2004");

	///////////
	// Times //
	///////////

	// Today at 10 PM.
	var d1 = Date.parse("10 PM");

	// Today at 10:30 PM.
	var d1 = Date.parse("10:30 P.M.");

	// Today at 6 AM.
	var d1 = Date.parse("06am");

	/////////////////////
	// Dates and Times //
	/////////////////////

	// 8-July-2004 @ 10:30 PM
	var d1 = Date.parse("July 8th, 2004, 10:30 PM");

	// 1-July-2004 @ 10:30 PM
	var d1 = Date.parse("2004-07-01T22:30:00");

	////////////////////
	// Relative Dates //
	////////////////////

	// Returns today's date. The string "today" is culture specific.
	var d1 = Date.parse("today");

	// Returns yesterday's date. The string "yesterday" is culture specific.
	var d1 = Date.parse("yesterday");

	// Returns the date of the next thursday.
	var d1 = Date.parse("Next thursday");

	// Returns the date of the most previous monday.
	var d1 = Date.parse("last monday");

	// Returns today's day + one year.
	var d1 = Date.parse("next year");

	///////////////
	// Date Math //
	///////////////

	// Today + 2 days
	var d1 = Date.parse("t+2");

	// Today + 2 days
	var d1 = Date.parse("today + 2 days");

	// Today + 3 months
	var d1 = Date.parse("t+3m");

	// Today - 1 year
	var d1 = Date.parse("today - 1 year");

	// Today - 1 year
	var d1 = Date.parse("t-1y"); 


	/////////////////////////////
	// Partial Dates and Times //
	/////////////////////////////

	// July 15th of this year.
	var d1 = Date.parse("July 15");

	// 15th day of current day and year.
	var d1 = Date.parse("15");

	// July 1st of current year at 10pm.
	var d1 = Date.parse("7/1 10pm");
	
* * @param {String} The string value to convert into a Date object [Required] * @return {Date} A Date object or null if the string cannot be converted into a Date. */ var parseUtils = { removeOrds: function (s) { ords = s.match(/\b(\d+)(?:st|nd|rd|th)\b/); // find ordinal matches s = ((ords && ords.length === 2) ? s.replace(ords[0], ords[1]) : s); return s; }, grammarParser: function (s) { var r = null; try { r = $D.Grammar.start.call({}, s.replace(/^\s*(\S*(\s+\S+)*)\s*$/, "$1")); } catch (e) { return null; } return ((r[1].length === 0) ? r[0] : null); }, nativeFallback: function(s) { var t; try { // ok we haven't parsed it, last ditch attempt with the built-in parser. t = Date._parse(s); return (t || t === 0) ? new Date(t) : null; } catch (e) { return null; } } }; function parse (s) { var d; if (!s) { return null; } if (s instanceof Date) { return s.clone(); } if (s.length >= 4 && s.charAt(0) !== "0" && s.charAt(0) !== "+"&& s.charAt(0) !== "-") { // ie: 2004 will pass, 0800 won't. // Start with specific formats d = $D.Parsing.ISO.parse(s) || $D.Parsing.Numeric.parse(s); } if (d instanceof Date && !isNaN(d.getTime())) { return d; } else { // find ordinal dates (1st, 3rd, 8th, etc and remove them as they cause parsing issues) s = $D.Parsing.Normalizer.parse(parseUtils.removeOrds(s)); d = parseUtils.grammarParser(s); if (d !== null) { return d; } else { return parseUtils.nativeFallback(s); } } } if (!$D._parse) { $D._parse = $D.parse; } $D.parse = parse; Date.getParseFunction = function (fx) { var fns = Date.Grammar.allformats(fx); return function (s) { var r = null; for (var i = 0; i < fns.length; i++) { try { r = fns[i].call({}, s); } catch (e) { continue; } if (r[1].length === 0) { return r[0]; } } return null; }; }; /** * Converts the specified string value into its JavaScript Date equivalent using the specified format {String} or formats {Array} and the CultureInfo specific format information. * The format of the string value must match one of the supplied formats exactly. * * Example

	// 15-Oct-2004
	var d1 = Date.parseExact("10/15/2004", "M/d/yyyy");

	// 15-Oct-2004
	var d1 = Date.parse("15-Oct-2004", "M-ddd-yyyy");

	// 15-Oct-2004
	var d1 = Date.parse("2004.10.15", "yyyy.MM.dd");

	// Multiple formats
	var d1 = Date.parseExact("10/15/2004", ["M/d/yyyy", "MMMM d, yyyy"]);
	
* * @param {String} The string value to convert into a Date object [Required]. * @param {Object} The expected format {String} or an array of expected formats {Array} of the date string [Required]. * @return {Date} A Date object or null if the string cannot be converted into a Date. */ $D.parseExact = function (s, fx) { return $D.getParseFunction(fx)(s); }; }()); (function () { var $D = Date, $P = $D.prototype, // $C = $D.CultureInfo, // not used atm p = function (s, l) { if (!l) { l = 2; } return ("000" + s).slice(l * -1); }; /** * Converts a PHP format string to Java/.NET format string. * A PHP format string can be used with ._format or .format. * A Java/.NET format string can be used with .toString(). * The .parseExact function will only accept a Java/.NET format string * * Example * var f1 = "%m/%d/%y" * var f2 = Date.normalizeFormat(f1); // "MM/dd/yy" * * new Date().format(f1); // "04/13/08" * new Date()._format(f1); // "04/13/08" * new Date().toString(f2); // "04/13/08" * * var date = Date.parseExact("04/13/08", f2); // Sun Apr 13 2008 * * @param {String} A PHP format string consisting of one or more format spcifiers. * @return {String} The PHP format converted to a Java/.NET format string. */ var normalizerSubstitutions = { "d" : "dd", "%d": "dd", "D" : "ddd", "%a": "ddd", "j" : "dddd", "l" : "dddd", "%A": "dddd", "S" : "S", "F" : "MMMM", "%B": "MMMM", "m" : "MM", "%m": "MM", "M" : "MMM", "%b": "MMM", "%h": "MMM", "n" : "M", "Y" : "yyyy", "%Y": "yyyy", "y" : "yy", "%y": "yy", "g" : "h", "%I": "h", "G" : "H", "h" : "hh", "H" : "HH", "%H": "HH", "i" : "mm", "%M": "mm", "s" : "ss", "%S": "ss", "%r": "hh:mm tt", "%R": "H:mm", "%T": "H:mm:ss", "%X": "t", "%x": "d", "%e": "d", "%D": "MM/dd/yy", "%n": "\\n", "%t": "\\t", "e" : "z", "T" : "z", "%z": "z", "%Z": "z", "Z" : "ZZ", "N" : "u", "w" : "u", "%w": "u", "W" : "W", "%V": "W" }; var normalizer = { substitutes: function (m) { return normalizerSubstitutions[m]; }, interpreted: function (m, x) { var y; switch (m) { case "%u": return x.getDay() + 1; case "z": return x.getOrdinalNumber(); case "%j": return p(x.getOrdinalNumber(), 3); case "%U": var d1 = x.clone().set({month: 0, day: 1}).addDays(-1).moveToDayOfWeek(0), d2 = x.clone().addDays(1).moveToDayOfWeek(0, -1); return (d2 < d1) ? "00" : p((d2.getOrdinalNumber() - d1.getOrdinalNumber()) / 7 + 1); case "%W": return p(x.getWeek()); case "t": return $D.getDaysInMonth(x.getFullYear(), x.getMonth()); case "o": case "%G": return x.setWeek(x.getISOWeek()).toString("yyyy"); case "%g": return x._format("%G").slice(-2); case "a": case "%p": return t("tt").toLowerCase(); case "A": return t("tt").toUpperCase(); case "u": return p(x.getMilliseconds(), 3); case "I": return (x.isDaylightSavingTime()) ? 1 : 0; case "O": return x.getUTCOffset(); case "P": y = x.getUTCOffset(); return y.substring(0, y.length - 2) + ":" + y.substring(y.length - 2); case "B": var now = new Date(); return Math.floor(((now.getHours() * 3600) + (now.getMinutes() * 60) + now.getSeconds() + (now.getTimezoneOffset() + 60) * 60) / 86.4); case "c": return x.toISOString().replace(/\"/g, ""); case "U": return $D.strtotime("now"); case "%c": return t("d") + " " + t("t"); case "%C": return Math.floor(x.getFullYear() / 100 + 1); } }, shouldOverrideDefaults: function (m) { switch (m) { case "%e": return true; default: return false; } }, parse: function (m, context) { var formatString, c = context || new Date(); formatString = normalizer.substitutes(m); if (formatString) { return formatString; } formatString = normalizer.interpreted(m, c); if (formatString) { return formatString; } else { return m; } } }; $D.normalizeFormat = function (format, context) { return format.replace(/(%|\\)?.|%%/g, function(t){ return normalizer.parse(t, context); }); }; /** * Format a local Unix timestamp according to locale settings * * Example: * Date.strftime("%m/%d/%y", new Date()); // "04/13/08" * Date.strftime("c", "2008-04-13T17:52:03Z"); // "04/13/08" * * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @param {Number|String} The number representing the number of seconds that have elapsed since January 1, 1970 (local time). * @return {String} A string representation of the current Date object. */ $D.strftime = function (format, time) { var d = Date.parse(time); return d._format(format); }; /** * Parse any textual datetime description into a Unix timestamp. * A Unix timestamp is the number of seconds that have elapsed since January 1, 1970 (midnight UTC/GMT). * * Example: * Date.strtotime("04/13/08"); // 1208044800 * Date.strtotime("1970-01-01T00:00:00Z"); // 0 * * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @param {Object} A string or date object. * @return {String} A string representation of the current Date object. */ $D.strtotime = function (time) { var d = $D.parse(time); return Math.round($D.UTC(d.getUTCFullYear(), d.getUTCMonth(), d.getUTCDate(), d.getUTCHours(), d.getUTCMinutes(), d.getUTCSeconds(), d.getUTCMilliseconds()) / 1000); }; /** * Converts the value of the current Date object to its equivalent string representation using a PHP/Unix style of date format specifiers. * Format Specifiers * Format Description Example * ------ --------------------------------------------------------------------------- ----------------------- * %a abbreviated weekday name according to the current localed "Mon" through "Sun" * %A full weekday name according to the current localed "Sunday" through "Saturday" * %b abbreviated month name according to the current localed "Jan" through "Dec" * %B full month name according to the current locale "January" through "December" * %c preferred date and time representation for the current locale "4/13/2008 12:33 PM" * %C century number (the year divided by 100 and truncated to an integer) "00" to "99" * %d day of the month as a decimal number "01" to "31" * %D same as %m/%d/%y "04/13/08" * %e day of the month as a decimal number, a single digit is preceded by a space "1" to "31" * %g like %G, but without the century "08" * %G The 4-digit year corresponding to the ISO week number (see %V). "2008" * This has the same format and value as %Y, except that if the ISO week number * belongs to the previous or next year, that year is used instead. * %h same as %b "Jan" through "Dec" * %H hour as a decimal number using a 24-hour clock. "00" to "23" * %I hour as a decimal number using a 12-hour clock. "01" to "12" * %j day of the year as a decimal number. "001" to "366" * %m month as a decimal number. "01" to "12" * %M minute as a decimal number. "00" to "59" * %n newline character "\n" * %p either "am" or "pm" according to the given time value, or the "am" or "pm" * corresponding strings for the current locale. * %r time in a.m. and p.m. notation "8:44 PM" * %R time in 24 hour notation "20:44" * %S second as a decimal number "00" to "59" * %t tab character "\t" * %T current time, equal to %H:%M:%S "12:49:11" * %u weekday as a decimal number ["1", "7"], with "1" representing Monday "1" to "7" * %U week number of the current year as a decimal number, starting with the "0" to ("52" or "53") * first Sunday as the first day of the first week * %V The ISO 8601:1988 week number of the current year as a decimal number, "00" to ("52" or "53") * range 01 to 53, where week 1 is the first week that has at least 4 days * in the current year, and with Monday as the first day of the week. * (Use %G or %g for the year component that corresponds to the week number * for the specified timestamp.) * %W week number of the current year as a decimal number, starting with the "00" to ("52" or "53") * first Monday as the first day of the first week * %w day of the week as a decimal, Sunday being "0" "0" to "6" * %x preferred date representation for the current locale without the time "4/13/2008" * %X preferred time representation for the current locale without the date "12:53:05" * %y year as a decimal number without a century "00" "99" * %Y year as a decimal number including the century "2008" * %Z time zone or name or abbreviation "UTC", "EST", "PST" * %z same as %Z * %% a literal "%" characters "%" * d Day of the month, 2 digits with leading zeros "01" to "31" * D A textual representation of a day, three letters "Mon" through "Sun" * j Day of the month without leading zeros "1" to "31" * l A full textual representation of the day of the week (lowercase "L") "Sunday" through "Saturday" * N ISO-8601 numeric representation of the day of the week (added in PHP 5.1.0) "1" (for Monday) through "7" (for Sunday) * S English ordinal suffix for the day of the month, 2 characters "st", "nd", "rd" or "th". Works well with j * w Numeric representation of the day of the week "0" (for Sunday) through "6" (for Saturday) * z The day of the year (starting from "0") "0" through "365" * W ISO-8601 week number of year, weeks starting on Monday "00" to ("52" or "53") * F A full textual representation of a month, such as January or March "January" through "December" * m Numeric representation of a month, with leading zeros "01" through "12" * M A short textual representation of a month, three letters "Jan" through "Dec" * n Numeric representation of a month, without leading zeros "1" through "12" * t Number of days in the given month "28" through "31" * L Whether it's a leap year "1" if it is a leap year, "0" otherwise * o ISO-8601 year number. This has the same value as Y, except that if the "2008" * ISO week number (W) belongs to the previous or next year, that year * is used instead. * Y A full numeric representation of a year, 4 digits "2008" * y A two digit representation of a year "08" * a Lowercase Ante meridiem and Post meridiem "am" or "pm" * A Uppercase Ante meridiem and Post meridiem "AM" or "PM" * B Swatch Internet time "000" through "999" * g 12-hour format of an hour without leading zeros "1" through "12" * G 24-hour format of an hour without leading zeros "0" through "23" * h 12-hour format of an hour with leading zeros "01" through "12" * H 24-hour format of an hour with leading zeros "00" through "23" * i Minutes with leading zeros "00" to "59" * s Seconds, with leading zeros "00" through "59" * u Milliseconds "54321" * e Timezone identifier "UTC", "EST", "PST" * I Whether or not the date is in daylight saving time (uppercase i) "1" if Daylight Saving Time, "0" otherwise * O Difference to Greenwich time (GMT) in hours "+0200", "-0600" * P Difference to Greenwich time (GMT) with colon between hours and minutes "+02:00", "-06:00" * T Timezone abbreviation "UTC", "EST", "PST" * Z Timezone offset in seconds. The offset for timezones west of UTC is "-43200" through "50400" * always negative, and for those east of UTC is always positive. * c ISO 8601 date "2004-02-12T15:19:21+00:00" * r RFC 2822 formatted date "Thu, 21 Dec 2000 16:01:07 +0200" * U Seconds since the Unix Epoch (January 1 1970 00:00:00 GMT) "0" * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @return {String} A string representation of the current Date object. */ var formatReplace = function (context) { return function (m) { var formatString, override = false; if (m.charAt(0) === "\\" || m.substring(0, 2) === "%%") { return m.replace("\\", "").replace("%%", "%"); } override = normalizer.shouldOverrideDefaults(m); formatString = $D.normalizeFormat(m, context); if (formatString) { return context.toString(formatString, override); } }; }; $P._format = function (format) { var formatter = formatReplace(this); if (!format) { return this._toString(); } else { return format.replace(/(%|\\)?.|%%/g, formatter); } }; if (!$P.format) { $P.format = $P._format; } }()); (function () { "use strict"; var gFn = function (attr) { return function () { return this[attr]; }; }; var sFn = function (attr) { return function (val) { this[attr] = val; return this; }; }; var attrs = ["years", "months", "days", "hours", "minutes", "seconds", "milliseconds"]; var addSetFuncs = function (context, attrs) { for (var i = 0; i < attrs.length ; i++) { var $a = attrs[i], $b = $a.slice(0, 1).toUpperCase() + $a.slice(1); context.prototype[$a] = 0; context.prototype["get" + $b] = gFn($a); context.prototype["set" + $b] = sFn($a); } }; /** * new TimeSpan(milliseconds); * new TimeSpan(days, hours, minutes, seconds); * new TimeSpan(days, hours, minutes, seconds, milliseconds); */ var TimeSpan = function (days, hours, minutes, seconds, milliseconds) { if (arguments.length === 1 && typeof days === "number") { var orient = (days < 0) ? -1 : +1; var millsLeft = Math.abs(days); this.setDays(Math.floor(millsLeft / 86400000) * orient); millsLeft = millsLeft % 86400000; this.setHours(Math.floor(millsLeft / 3600000) * orient); millsLeft = millsLeft % 3600000; this.setMinutes(Math.floor(millsLeft / 60000) * orient); millsLeft = millsLeft % 60000; this.setSeconds(Math.floor(millsLeft / 1000) * orient); millsLeft = millsLeft % 1000; this.setMilliseconds(millsLeft * orient); } else { this.set(days, hours, minutes, seconds, milliseconds); } this.getTotalMilliseconds = function () { return (this.getDays() * 86400000) + (this.getHours() * 3600000) + (this.getMinutes() * 60000) + (this.getSeconds() * 1000); }; this.compareTo = function (time) { var t1 = new Date(1970, 1, 1, this.getHours(), this.getMinutes(), this.getSeconds()), t2; if (time === null) { t2 = new Date(1970, 1, 1, 0, 0, 0); } else { t2 = new Date(1970, 1, 1, time.getHours(), time.getMinutes(), time.getSeconds()); } return (t1 < t2) ? -1 : (t1 > t2) ? 1 : 0; }; this.equals = function (time) { return (this.compareTo(time) === 0); }; this.add = function (time) { return (time === null) ? this : this.addSeconds(time.getTotalMilliseconds() / 1000); }; this.subtract = function (time) { return (time === null) ? this : this.addSeconds(-time.getTotalMilliseconds() / 1000); }; this.addDays = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 86400000)); }; this.addHours = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 3600000)); }; this.addMinutes = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 60000)); }; this.addSeconds = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 1000)); }; this.addMilliseconds = function (n) { return new TimeSpan(this.getTotalMilliseconds() + n); }; this.get12HourHour = function () { return (this.getHours() > 12) ? this.getHours() - 12 : (this.getHours() === 0) ? 12 : this.getHours(); }; this.getDesignator = function () { return (this.getHours() < 12) ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator; }; this.toString = function (format) { this._toString = function () { if (this.getDays() !== null && this.getDays() > 0) { return this.getDays() + "." + this.getHours() + ":" + this.p(this.getMinutes()) + ":" + this.p(this.getSeconds()); } else { return this.getHours() + ":" + this.p(this.getMinutes()) + ":" + this.p(this.getSeconds()); } }; this.p = function (s) { return (s.toString().length < 2) ? "0" + s : s; }; var me = this; return format ? format.replace(/dd?|HH?|hh?|mm?|ss?|tt?/g, function (format) { switch (format) { case "d": return me.getDays(); case "dd": return me.p(me.getDays()); case "H": return me.getHours(); case "HH": return me.p(me.getHours()); case "h": return me.get12HourHour(); case "hh": return me.p(me.get12HourHour()); case "m": return me.getMinutes(); case "mm": return me.p(me.getMinutes()); case "s": return me.getSeconds(); case "ss": return me.p(me.getSeconds()); case "t": return ((me.getHours() < 12) ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator).substring(0, 1); case "tt": return (me.getHours() < 12) ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator; } } ) : this._toString(); }; return this; }; addSetFuncs(TimeSpan, attrs.slice(2)); TimeSpan.prototype.set = function (days, hours, minutes, seconds, milliseconds){ this.setDays(days || this.getDays()); this.setHours(hours || this.getHours()); this.setMinutes(minutes || this.getMinutes()); this.setSeconds(seconds || this.getSeconds()); this.setMilliseconds(milliseconds || this.getMilliseconds()); }; /** * Gets the time of day for this date instances. * @return {TimeSpan} TimeSpan */ Date.prototype.getTimeOfDay = function () { return new TimeSpan(0, this.getHours(), this.getMinutes(), this.getSeconds(), this.getMilliseconds()); }; Date.TimeSpan = TimeSpan; if (typeof window !== "undefined" ) { // keeping API compatible for v1.x window.TimeSpan = TimeSpan; } }()); (function () { "use strict"; var attrs = ["years", "months", "days", "hours", "minutes", "seconds", "milliseconds"]; var gFn = function (attr) { return function () { return this[attr]; }; }; var sFn = function (attr) { return function (val) { this[attr] = val; return this; }; }; var addSetFuncs = function (context, attrs) { for (var i = 0; i < attrs.length ; i++) { var $a = attrs[i], $b = $a.slice(0, 1).toUpperCase() + $a.slice(1); context.prototype[$a] = 0; context.prototype["get" + $b] = gFn($a); context.prototype["set" + $b] = sFn($a); } }; var setMonthsAndYears = function (orient, d1, d2, context) { function inc() { d1.addMonths(-orient); context.months++; if (context.months === 12) { context.years++; context.months = 0; } } if (orient === +1) { while (d1 > d2) { inc(); } } else { while (d1 < d2) { inc(); } } context.months--; context.months *= orient; context.years *= orient; }; var adjustForDST = function(orient, startDate, endDate) { var hasDSTMismatch = (false === (startDate.isDaylightSavingTime() === endDate.isDaylightSavingTime())); if (hasDSTMismatch && orient === 1) { startDate.addHours(-1); } else if (hasDSTMismatch) { startDate.addHours(1); } }; /** * TimePeriod(startDate, endDate); * TimePeriod(years, months, days, hours, minutes, seconds, milliseconds); */ var TimePeriod = function (years, months, days, hours, minutes, seconds, milliseconds) { if (arguments.length === 7) { this.set(years, months, days, hours, minutes, seconds, milliseconds); } else if (arguments.length === 2 && arguments[0] instanceof Date && arguments[1] instanceof Date) { var startDate = arguments[0].clone(); var endDate = arguments[1].clone(); var orient = (startDate > endDate) ? +1 : -1; this.dates = { start: arguments[0].clone(), end: arguments[1].clone() }; setMonthsAndYears(orient, startDate, endDate, this); adjustForDST(orient, startDate, endDate); // // TODO - adjust for DST var diff = endDate - startDate; if (diff !== 0) { var ts = new TimeSpan(diff); this.set(this.years, this.months, ts.getDays(), ts.getHours(), ts.getMinutes(), ts.getSeconds(), ts.getMilliseconds()); } } return this; }; // create all the set functions. addSetFuncs(TimePeriod, attrs); TimePeriod.prototype.set = function (years, months, days, hours, minutes, seconds, milliseconds){ this.setYears(years || this.getYears()); this.setMonths(months || this.getMonths()); this.setDays(days || this.getDays()); this.setHours(hours || this.getHours()); this.setMinutes(minutes || this.getMinutes()); this.setSeconds(seconds || this.getSeconds()); this.setMilliseconds(milliseconds || this.getMilliseconds()); }; Date.TimePeriod = TimePeriod; if (typeof window !== "undefined") { // keeping API compatible for v1.x window.TimePeriod = TimePeriod; } }()); ================================================ FILE: build/date-fr-BE.js ================================================ /** * @overview datejs * @version 1.0.0-rc3 * @author Gregory Wild-Smith * @copyright 2015 Gregory Wild-Smith * @license MIT * @homepage https://github.com/abritinthebay/datejs */ /* * DateJS Culture String File * Country Code: fr-BE * Name: French (Belgium) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["fr-BE"] = { "name": "fr-BE", "englishName": "French (Belgium)", "nativeName": "français (Belgique)", "Sunday": "dimanche", "Monday": "lundi", "Tuesday": "mardi", "Wednesday": "mercredi", "Thursday": "jeudi", "Friday": "vendredi", "Saturday": "samedi", "Sun": "dim.", "Mon": "lun.", "Tue": "mar.", "Wed": "mer.", "Thu": "jeu.", "Fri": "ven.", "Sat": "sam.", "Su": "di", "Mo": "lu", "Tu": "ma", "We": "me", "Th": "je", "Fr": "ve", "Sa": "sa", "S_Sun_Initial": "d", "M_Mon_Initial": "l", "T_Tue_Initial": "m", "W_Wed_Initial": "m", "T_Thu_Initial": "j", "F_Fri_Initial": "v", "S_Sat_Initial": "s", "January": "janvier", "February": "février", "March": "mars", "April": "avril", "May": "mai", "June": "juin", "July": "juillet", "August": "août", "September": "septembre", "October": "octobre", "November": "novembre", "December": "décembre", "Jan_Abbr": "janv.", "Feb_Abbr": "févr.", "Mar_Abbr": "mars", "Apr_Abbr": "avr.", "May_Abbr": "mai", "Jun_Abbr": "juin", "Jul_Abbr": "juil.", "Aug_Abbr": "août", "Sep_Abbr": "sept.", "Oct_Abbr": "oct.", "Nov_Abbr": "nov.", "Dec_Abbr": "déc.", "AM": "", "PM": "", "firstDayOfWeek": 1, "twoDigitYearMax": 2029, "mdy": "dmy", "M/d/yyyy": "d/MM/yyyy", "dddd, MMMM dd, yyyy": "dddd d MMMM yyyy", "h:mm tt": "H:mm", "h:mm:ss tt": "H:mm:ss", "dddd, MMMM dd, yyyy h:mm:ss tt": "dddd d MMMM yyyy H:mm:ss", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "d MMMM", "MMMM, yyyy": "MMMM yyyy", "/jan(uary)?/": "janv(.(ier)?)?", "/feb(ruary)?/": "févr(.(ier)?)?", "/mar(ch)?/": "mars", "/apr(il)?/": "avr(.(il)?)?", "/may/": "mai", "/jun(e)?/": "juin", "/jul(y)?/": "juil(.(let)?)?", "/aug(ust)?/": "août", "/sep(t(ember)?)?/": "sept(.(embre)?)?", "/oct(ober)?/": "oct(.(obre)?)?", "/nov(ember)?/": "nov(.(embre)?)?", "/dec(ember)?/": "déc(.(embre)?)?", "/^su(n(day)?)?/": "^di(m(.(anche)?)?)?", "/^mo(n(day)?)?/": "^lu(n(.(di)?)?)?", "/^tu(e(s(day)?)?)?/": "^ma(r(.(di)?)?)?", "/^we(d(nesday)?)?/": "^me(r(.(credi)?)?)?", "/^th(u(r(s(day)?)?)?)?/": "^je(u(.(di)?)?)?", "/^fr(i(day)?)?/": "^ve(n(.(dredi)?)?)?", "/^sa(t(urday)?)?/": "^sa(m(.(edi)?)?)?", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "fr-BE"; /** * @overview datejs * @version 1.0.0-rc3 * @author Gregory Wild-Smith * @copyright 2015 Gregory Wild-Smith * @license MIT * @homepage https://github.com/abritinthebay/datejs */(function () { var $D = Date; var lang = Date.CultureStrings ? Date.CultureStrings.lang : null; var loggedKeys = {}; // for debug purposes. var getText = { getFromKey: function (key, countryCode) { var output; if (Date.CultureStrings && Date.CultureStrings[countryCode] && Date.CultureStrings[countryCode][key]) { output = Date.CultureStrings[countryCode][key]; } else { output = getText.buildFromDefault(key); } if (key.charAt(0) === "/") { // Assume it's a regex output = getText.buildFromRegex(key, countryCode); } return output; }, getFromObjectValues: function (obj, countryCode) { var key, output = {}; for(key in obj) { if (obj.hasOwnProperty(key)) { output[key] = getText.getFromKey(obj[key], countryCode); } } return output; }, getFromObjectKeys: function (obj, countryCode) { var key, output = {}; for(key in obj) { if (obj.hasOwnProperty(key)) { output[getText.getFromKey(key, countryCode)] = obj[key]; } } return output; }, getFromArray: function (arr, countryCode) { var output = []; for (var i=0; i < arr.length; i++){ if (i in arr) { output[i] = getText.getFromKey(arr[i], countryCode); } } return output; }, buildFromDefault: function (key) { var output, length, split, last; switch(key) { case "name": output = "en-US"; break; case "englishName": output = "English (United States)"; break; case "nativeName": output = "English (United States)"; break; case "twoDigitYearMax": output = 2049; break; case "firstDayOfWeek": output = 0; break; default: output = key; split = key.split("_"); length = split.length; if (length > 1 && key.charAt(0) !== "/") { // if the key isn't a regex and it has a split. last = split[(length - 1)].toLowerCase(); if (last === "initial" || last === "abbr") { output = split[0]; } } break; } return output; }, buildFromRegex: function (key, countryCode) { var output; if (Date.CultureStrings && Date.CultureStrings[countryCode] && Date.CultureStrings[countryCode][key]) { output = new RegExp(Date.CultureStrings[countryCode][key], "i"); } else { output = new RegExp(key.replace(new RegExp("/", "g"),""), "i"); } return output; } }; var shallowMerge = function (obj1, obj2) { for (var attrname in obj2) { if (obj2.hasOwnProperty(attrname)) { obj1[attrname] = obj2[attrname]; } } }; var __ = function (key, language) { var countryCode = (language) ? language : lang; loggedKeys[key] = key; if (typeof key === "object") { if (key instanceof Array) { return getText.getFromArray(key, countryCode); } else { return getText.getFromObjectKeys(key, countryCode); } } else { return getText.getFromKey(key, countryCode); } }; var loadI18nScript = function (code) { // paatterned after jQuery's getScript. var url = Date.Config.i18n + code + ".js"; var head = document.getElementsByTagName("head")[0] || document.documentElement; var script = document.createElement("script"); script.src = url; var completed = false; var events = { done: function (){} // placeholder function }; // Attach handlers for all browsers script.onload = script.onreadystatechange = function() { if ( !completed && (!this.readyState || this.readyState === "loaded" || this.readyState === "complete") ) { events.done(); head.removeChild(script); } }; setTimeout(function() { head.insertBefore(script, head.firstChild); }, 0); // allows return to execute first return { done: function (cb) { events.done = function() { if (cb) { setTimeout(cb,0); } }; } }; }; var buildInfo = { buildFromMethodHash: function (obj) { var key; for(key in obj) { if (obj.hasOwnProperty(key)) { obj[key] = buildInfo[obj[key]](); } } return obj; }, timeZoneDST: function () { var DST = { "CHADT": "+1345", "NZDT": "+1300", "AEDT": "+1100", "ACDT": "+1030", "AZST": "+0500", "IRDT": "+0430", "EEST": "+0300", "CEST": "+0200", "BST": "+0100", "PMDT": "-0200", "ADT": "-0300", "NDT": "-0230", "EDT": "-0400", "CDT": "-0500", "MDT": "-0600", "PDT": "-0700", "AKDT": "-0800", "HADT": "-0900" }; return __(DST); }, timeZoneStandard: function () { var standard = { "LINT": "+1400", "TOT": "+1300", "CHAST": "+1245", "NZST": "+1200", "NFT": "+1130", "SBT": "+1100", "AEST": "+1000", "ACST": "+0930", "JST": "+0900", "CWST": "+0845", "CT": "+0800", "ICT": "+0700", "MMT": "+0630", "BST": "+0600", "NPT": "+0545", "IST": "+0530", "PKT": "+0500", "AFT": "+0430", "MSK": "+0400", "IRST": "+0330", "FET": "+0300", "EET": "+0200", "CET": "+0100", "GMT": "+0000", "UTC": "+0000", "CVT": "-0100", "GST": "-0200", "BRT": "-0300", "NST": "-0330", "AST": "-0400", "EST": "-0500", "CST": "-0600", "MST": "-0700", "PST": "-0800", "AKST": "-0900", "MIT": "-0930", "HST": "-1000", "SST": "-1100", "BIT": "-1200" }; return __(standard); }, timeZones: function (data) { var zone; data.timezones = []; for (zone in data.abbreviatedTimeZoneStandard) { if (data.abbreviatedTimeZoneStandard.hasOwnProperty(zone)) { data.timezones.push({ name: zone, offset: data.abbreviatedTimeZoneStandard[zone]}); } } for (zone in data.abbreviatedTimeZoneDST) { if (data.abbreviatedTimeZoneDST.hasOwnProperty(zone)) { data.timezones.push({ name: zone, offset: data.abbreviatedTimeZoneDST[zone], dst: true}); } } return data.timezones; }, days: function () { return __(["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"]); }, dayAbbr: function () { return __(["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"]); }, dayShortNames: function () { return __(["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"]); }, dayFirstLetters: function () { return __(["S_Sun_Initial", "M_Mon_Initial", "T_Tues_Initial", "W_Wed_Initial", "T_Thu_Initial", "F_Fri_Initial", "S_Sat_Initial"]); }, months: function () { return __(["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"]); }, monthAbbr: function () { return __(["Jan_Abbr", "Feb_Abbr", "Mar_Abbr", "Apr_Abbr", "May_Abbr", "Jun_Abbr", "Jul_Abbr", "Aug_Abbr", "Sep_Abbr", "Oct_Abbr", "Nov_Abbr", "Dec_Abbr"]); }, formatPatterns: function () { return getText.getFromObjectValues({ shortDate: "M/d/yyyy", longDate: "dddd, MMMM dd, yyyy", shortTime: "h:mm tt", longTime: "h:mm:ss tt", fullDateTime: "dddd, MMMM dd, yyyy h:mm:ss tt", sortableDateTime: "yyyy-MM-ddTHH:mm:ss", universalSortableDateTime: "yyyy-MM-dd HH:mm:ssZ", rfc1123: "ddd, dd MMM yyyy HH:mm:ss", monthDay: "MMMM dd", yearMonth: "MMMM, yyyy" }, Date.i18n.currentLanguage()); }, regex: function () { return getText.getFromObjectValues({ inTheMorning: "/( in the )(morn(ing)?)\\b/", thisMorning: "/(this )(morn(ing)?)\\b/", amThisMorning: "/(\b\\d(am)? )(this )(morn(ing)?)/", inTheEvening: "/( in the )(even(ing)?)\\b/", thisEvening: "/(this )(even(ing)?)\\b/", pmThisEvening: "/(\b\\d(pm)? )(this )(even(ing)?)/", jan: "/jan(uary)?/", feb: "/feb(ruary)?/", mar: "/mar(ch)?/", apr: "/apr(il)?/", may: "/may/", jun: "/jun(e)?/", jul: "/jul(y)?/", aug: "/aug(ust)?/", sep: "/sep(t(ember)?)?/", oct: "/oct(ober)?/", nov: "/nov(ember)?/", dec: "/dec(ember)?/", sun: "/^su(n(day)?)?/", mon: "/^mo(n(day)?)?/", tue: "/^tu(e(s(day)?)?)?/", wed: "/^we(d(nesday)?)?/", thu: "/^th(u(r(s(day)?)?)?)?/", fri: "/fr(i(day)?)?/", sat: "/^sa(t(urday)?)?/", future: "/^next/", past: "/^last|past|prev(ious)?/", add: "/^(\\+|aft(er)?|from|hence)/", subtract: "/^(\\-|bef(ore)?|ago)/", yesterday: "/^yes(terday)?/", today: "/^t(od(ay)?)?/", tomorrow: "/^tom(orrow)?/", now: "/^n(ow)?/", millisecond: "/^ms|milli(second)?s?/", second: "/^sec(ond)?s?/", minute: "/^mn|min(ute)?s?/", hour: "/^h(our)?s?/", week: "/^w(eek)?s?/", month: "/^m(onth)?s?/", day: "/^d(ay)?s?/", year: "/^y(ear)?s?/", shortMeridian: "/^(a|p)/", longMeridian: "/^(a\\.?m?\\.?|p\\.?m?\\.?)/", timezone: "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/", ordinalSuffix: "/^\\s*(st|nd|rd|th)/", timeContext: "/^\\s*(\\:|a(?!u|p)|p)/" }, Date.i18n.currentLanguage()); } }; var CultureInfo = function () { var info = getText.getFromObjectValues({ name: "name", englishName: "englishName", nativeName: "nativeName", amDesignator: "AM", pmDesignator: "PM", firstDayOfWeek: "firstDayOfWeek", twoDigitYearMax: "twoDigitYearMax", dateElementOrder: "mdy" }, Date.i18n.currentLanguage()); var constructedInfo = buildInfo.buildFromMethodHash({ dayNames: "days", abbreviatedDayNames: "dayAbbr", shortestDayNames: "dayShortNames", firstLetterDayNames: "dayFirstLetters", monthNames: "months", abbreviatedMonthNames: "monthAbbr", formatPatterns: "formatPatterns", regexPatterns: "regex", abbreviatedTimeZoneDST: "timeZoneDST", abbreviatedTimeZoneStandard: "timeZoneStandard" }); shallowMerge(info, constructedInfo); buildInfo.timeZones(info); return info; }; $D.i18n = { __: function (key, lang) { return __(key, lang); }, currentLanguage: function () { return lang || "en-US"; }, setLanguage: function (code, force, cb) { var async = false; if (force || code === "en-US" || (!!Date.CultureStrings && !!Date.CultureStrings[code])) { lang = code; Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings.lang = code; Date.CultureInfo = new CultureInfo(); } else { if (!(!!Date.CultureStrings && !!Date.CultureStrings[code])) { if (typeof exports !== "undefined" && this.exports !== exports) { // we're in a Node enviroment, load it using require try { require("../i18n/" + code + ".js"); lang = code; Date.CultureStrings.lang = code; Date.CultureInfo = new CultureInfo(); } catch (e) { // var str = "The language for '" + code + "' could not be loaded by Node. It likely does not exist."; throw new Error("The DateJS IETF language tag '" + code + "' could not be loaded by Node. It likely does not exist."); } } else if (Date.Config && Date.Config.i18n) { // we know the location of the files, so lets load them async = true; loadI18nScript(code).done(function(){ lang = code; Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings.lang = code; Date.CultureInfo = new CultureInfo(); $D.Parsing.Normalizer.buildReplaceData(); // because this is async if ($D.Grammar) { $D.Grammar.buildGrammarFormats(); // so we can parse those strings... } if (cb) { setTimeout(cb,0); } }); } else { Date.console.error("The DateJS IETF language tag '" + code + "' is not available and has not been loaded."); return false; } } } $D.Parsing.Normalizer.buildReplaceData(); // rebuild normalizer strings if ($D.Grammar) { $D.Grammar.buildGrammarFormats(); // so we can parse those strings... } if (!async && cb) { setTimeout(cb,0); } }, getLoggedKeys: function () { return loggedKeys; }, updateCultureInfo: function () { Date.CultureInfo = new CultureInfo(); } }; $D.i18n.updateCultureInfo(); // run automatically }()); (function () { var $D = Date, $P = $D.prototype, p = function (s, l) { if (!l) { l = 2; } return ("000" + s).slice(l * -1); }; if (typeof window !== "undefined" && typeof window.console !== "undefined" && typeof window.console.log !== "undefined") { $D.console = console; // used only to raise non-critical errors if available } else { // set mock so we don't give errors. $D.console = { log: function(){}, error: function(){} }; } $D.Config = $D.Config || {}; $D.initOverloads = function() { /** * Overload of Date.now. Allows an alternate call for Date.now where it returns the * current Date as an object rather than just milliseconds since the Unix Epoch. * * Also provides an implementation of now() for browsers (IE<9) that don't have it. * * Backwards compatible so with work with either: * Date.now() [returns ms] * or * Date.now(true) [returns Date] */ if (!$D.now) { $D._now = function now() { return new Date().getTime(); }; } else if (!$D._now) { $D._now = $D.now; } $D.now = function (returnObj) { if (returnObj) { return $D.present(); } else { return $D._now(); } }; if ( !$P.toISOString ) { $P.toISOString = function() { return this.getUTCFullYear() + "-" + p(this.getUTCMonth() + 1) + "-" + p(this.getUTCDate()) + "T" + p(this.getUTCHours()) + ":" + p(this.getUTCMinutes()) + ":" + p(this.getUTCSeconds()) + "." + String( (this.getUTCMilliseconds()/1000).toFixed(3)).slice(2, 5) + "Z"; }; } // private if ( $P._toString === undefined ){ $P._toString = $P.toString; } }; $D.initOverloads(); /** * Gets a date that is set to the current date. The time is set to the start of the day (00:00 or 12:00 AM). * @return {Date} The current date. */ $D.today = function () { return new Date().clearTime(); }; /** * Gets a date that is set to the current date and time (same as new Date, but chainable) * @return {Date} The current date. */ $D.present = function () { return new Date(); }; /** * Compares the first date to the second date and returns an number indication of their relative values. * @param {Date} First Date object to compare [Required]. * @param {Date} Second Date object to compare to [Required]. * @return {Number} -1 = date1 is lessthan date2. 0 = values are equal. 1 = date1 is greaterthan date2. */ $D.compare = function (date1, date2) { if (isNaN(date1) || isNaN(date2)) { throw new Error(date1 + " - " + date2); } else if (date1 instanceof Date && date2 instanceof Date) { return (date1 < date2) ? -1 : (date1 > date2) ? 1 : 0; } else { throw new TypeError(date1 + " - " + date2); } }; /** * Compares the first Date object to the second Date object and returns true if they are equal. * @param {Date} First Date object to compare [Required] * @param {Date} Second Date object to compare to [Required] * @return {Boolean} true if dates are equal. false if they are not equal. */ $D.equals = function (date1, date2) { return (date1.compareTo(date2) === 0); }; /** * Gets the language appropriate day name when given the day number(0-6) * eg - 0 == Sunday * @return {String} The day name */ $D.getDayName = function (n) { return Date.CultureInfo.dayNames[n]; }; /** * Gets the day number (0-6) if given a CultureInfo specific string which is a valid dayName, abbreviatedDayName or shortestDayName (two char). * @param {String} The name of the day (eg. "Monday, "Mon", "tuesday", "tue", "We", "we"). * @return {Number} The day number */ $D.getDayNumberFromName = function (name) { var n = Date.CultureInfo.dayNames, m = Date.CultureInfo.abbreviatedDayNames, o = Date.CultureInfo.shortestDayNames, s = name.toLowerCase(); for (var i = 0; i < n.length; i++) { if (n[i].toLowerCase() === s || m[i].toLowerCase() === s || o[i].toLowerCase() === s) { return i; } } return -1; }; /** * Gets the month number (0-11) if given a Culture Info specific string which is a valid monthName or abbreviatedMonthName. * @param {String} The name of the month (eg. "February, "Feb", "october", "oct"). * @return {Number} The day number */ $D.getMonthNumberFromName = function (name) { var n = Date.CultureInfo.monthNames, m = Date.CultureInfo.abbreviatedMonthNames, s = name.toLowerCase(); for (var i = 0; i < n.length; i++) { if (n[i].toLowerCase() === s || m[i].toLowerCase() === s) { return i; } } return -1; }; /** * Gets the language appropriate month name when given the month number(0-11) * eg - 0 == January * @return {String} The month name */ $D.getMonthName = function (n) { return Date.CultureInfo.monthNames[n]; }; /** * Determines if the current date instance is within a LeapYear. * @param {Number} The year. * @return {Boolean} true if date is within a LeapYear, otherwise false. */ $D.isLeapYear = function (year) { return ((year % 4 === 0 && year % 100 !== 0) || year % 400 === 0); }; /** * Gets the number of days in the month, given a year and month value. Automatically corrects for LeapYear. * @param {Number} The year. * @param {Number} The month (0-11). * @return {Number} The number of days in the month. */ $D.getDaysInMonth = function (year, month) { if (!month && $D.validateMonth(year)) { month = year; year = Date.today().getFullYear(); } return [31, ($D.isLeapYear(year) ? 29 : 28), 31, 30, 31, 30, 31, 31, 30, 31, 30, 31][month]; }; $P.getDaysInMonth = function () { return $D.getDaysInMonth(this.getFullYear(), this.getMonth()); }; $D.getTimezoneAbbreviation = function (offset, dst) { var p, n = (dst || false) ? Date.CultureInfo.abbreviatedTimeZoneDST : Date.CultureInfo.abbreviatedTimeZoneStandard; for (p in n) { if (n.hasOwnProperty(p)) { if (n[p] === offset) { return p; } } } return null; }; $D.getTimezoneOffset = function (name, dst) { var i, a =[], z = Date.CultureInfo.timezones; if (!name) { name = (new Date()).getTimezone();} for (i = 0; i < z.length; i++) { if (z[i].name === name.toUpperCase()) { a.push(i); } } if (!z[a[0]]) { return null; } if (a.length === 1 || !dst) { return z[a[0]].offset; } else { for (i=0; i < a.length; i++) { if (z[a[i]].dst) { return z[a[i]].offset; } } } }; $D.getQuarter = function (d) { d = d || new Date(); // If no date supplied, use today var q = [1,2,3,4]; return q[Math.floor(d.getMonth() / 3)]; // ~~~ is a bitwise op. Faster than Math.floor }; $D.getDaysLeftInQuarter = function (d) { d = d || new Date(); var qEnd = new Date(d); qEnd.setMonth(qEnd.getMonth() + 3 - qEnd.getMonth() % 3, 0); return Math.floor((qEnd - d) / 8.64e7); }; // private var validate = function (n, min, max, name) { name = name ? name : "Object"; if (typeof n === "undefined") { return false; } else if (typeof n !== "number") { throw new TypeError(n + " is not a Number."); } else if (n < min || n > max) { // As failing validation is *not* an exceptional circumstance // lets not throw a RangeError Exception here. // It's semantically correct but it's not sensible. return false; } return true; }; /** * Validates the number is within an acceptable range for milliseconds [0-999]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateMillisecond = function (value) { return validate(value, 0, 999, "millisecond"); }; /** * Validates the number is within an acceptable range for seconds [0-59]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateSecond = function (value) { return validate(value, 0, 59, "second"); }; /** * Validates the number is within an acceptable range for minutes [0-59]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateMinute = function (value) { return validate(value, 0, 59, "minute"); }; /** * Validates the number is within an acceptable range for hours [0-23]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateHour = function (value) { return validate(value, 0, 23, "hour"); }; /** * Validates the number is within an acceptable range for the days in a month [0-MaxDaysInMonth]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateDay = function (value, year, month) { if (year === undefined || year === null || month === undefined || month === null) { return false;} return validate(value, 1, $D.getDaysInMonth(year, month), "day"); }; /** * Validates the number is within an acceptable range for months [0-11]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateWeek = function (value) { return validate(value, 0, 53, "week"); }; /** * Validates the number is within an acceptable range for months [0-11]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateMonth = function (value) { return validate(value, 0, 11, "month"); }; /** * Validates the number is within an acceptable range for years. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateYear = function (value) { /** * Per ECMAScript spec the range of times supported by Date objects is * exactly -100,000,000 days to +100,000,000 days measured relative to * midnight at the beginning of 01 January, 1970 UTC. * This gives a range of 8,640,000,000,000,000 milliseconds to either * side of 01 January, 1970 UTC. * * Earliest possible date: Tue, 20 Apr 271,822 B.C. 00:00:00 UTC * Latest possible date: Sat, 13 Sep 275,760 00:00:00 UTC */ return validate(value, -271822, 275760, "year"); }; $D.validateTimezone = function(value) { var timezones = {"ACDT":1,"ACST":1,"ACT":1,"ADT":1,"AEDT":1,"AEST":1,"AFT":1,"AKDT":1,"AKST":1,"AMST":1,"AMT":1,"ART":1,"AST":1,"AWDT":1,"AWST":1,"AZOST":1,"AZT":1,"BDT":1,"BIOT":1,"BIT":1,"BOT":1,"BRT":1,"BST":1,"BTT":1,"CAT":1,"CCT":1,"CDT":1,"CEDT":1,"CEST":1,"CET":1,"CHADT":1,"CHAST":1,"CHOT":1,"ChST":1,"CHUT":1,"CIST":1,"CIT":1,"CKT":1,"CLST":1,"CLT":1,"COST":1,"COT":1,"CST":1,"CT":1,"CVT":1,"CWST":1,"CXT":1,"DAVT":1,"DDUT":1,"DFT":1,"EASST":1,"EAST":1,"EAT":1,"ECT":1,"EDT":1,"EEDT":1,"EEST":1,"EET":1,"EGST":1,"EGT":1,"EIT":1,"EST":1,"FET":1,"FJT":1,"FKST":1,"FKT":1,"FNT":1,"GALT":1,"GAMT":1,"GET":1,"GFT":1,"GILT":1,"GIT":1,"GMT":1,"GST":1,"GYT":1,"HADT":1,"HAEC":1,"HAST":1,"HKT":1,"HMT":1,"HOVT":1,"HST":1,"ICT":1,"IDT":1,"IOT":1,"IRDT":1,"IRKT":1,"IRST":1,"IST":1,"JST":1,"KGT":1,"KOST":1,"KRAT":1,"KST":1,"LHST":1,"LINT":1,"MAGT":1,"MART":1,"MAWT":1,"MDT":1,"MET":1,"MEST":1,"MHT":1,"MIST":1,"MIT":1,"MMT":1,"MSK":1,"MST":1,"MUT":1,"MVT":1,"MYT":1,"NCT":1,"NDT":1,"NFT":1,"NPT":1,"NST":1,"NT":1,"NUT":1,"NZDT":1,"NZST":1,"OMST":1,"ORAT":1,"PDT":1,"PET":1,"PETT":1,"PGT":1,"PHOT":1,"PHT":1,"PKT":1,"PMDT":1,"PMST":1,"PONT":1,"PST":1,"PYST":1,"PYT":1,"RET":1,"ROTT":1,"SAKT":1,"SAMT":1,"SAST":1,"SBT":1,"SCT":1,"SGT":1,"SLST":1,"SRT":1,"SST":1,"SYOT":1,"TAHT":1,"THA":1,"TFT":1,"TJT":1,"TKT":1,"TLT":1,"TMT":1,"TOT":1,"TVT":1,"UCT":1,"ULAT":1,"UTC":1,"UYST":1,"UYT":1,"UZT":1,"VET":1,"VLAT":1,"VOLT":1,"VOST":1,"VUT":1,"WAKT":1,"WAST":1,"WAT":1,"WEDT":1,"WEST":1,"WET":1,"WST":1,"YAKT":1,"YEKT":1,"Z":1}; return (timezones[value] === 1); }; $D.validateTimezoneOffset= function(value) { // timezones go from +14hrs to -12hrs, the +X hours are negative offsets. return (value > -841 && value < 721); }; }()); (function () { var $D = Date, $P = $D.prototype, p = function (s, l) { if (!l) { l = 2; } return ("000" + s).slice(l * -1); }; var validateConfigObject = function (obj) { var result = {}, self = this, prop, testFunc; testFunc = function (prop, func, value) { if (prop === "day") { var month = (obj.month !== undefined) ? obj.month : self.getMonth(); var year = (obj.year !== undefined) ? obj.year : self.getFullYear(); return $D[func](value, year, month); } else { return $D[func](value); } }; for (prop in obj) { if (Object.prototype.hasOwnProperty.call(obj, prop)) { var func = "validate" + prop.charAt(0).toUpperCase() + prop.slice(1); if ($D[func] && obj[prop] !== null && testFunc(prop, func, obj[prop])) { result[prop] = obj[prop]; } } } return result; }; /** * Resets the time of this Date object to 12:00 AM (00:00), which is the start of the day. * @param {Boolean} .clone() this date instance before clearing Time * @return {Date} this */ $P.clearTime = function () { this.setHours(0); this.setMinutes(0); this.setSeconds(0); this.setMilliseconds(0); return this; }; /** * Resets the time of this Date object to the current time ('now'). * @return {Date} this */ $P.setTimeToNow = function () { var n = new Date(); this.setHours(n.getHours()); this.setMinutes(n.getMinutes()); this.setSeconds(n.getSeconds()); this.setMilliseconds(n.getMilliseconds()); return this; }; /** * Returns a new Date object that is an exact date and time copy of the original instance. * @return {Date} A new Date instance */ $P.clone = function () { return new Date(this.getTime()); }; /** * Compares this instance to a Date object and returns an number indication of their relative values. * @param {Date} Date object to compare [Required] * @return {Number} -1 = this is lessthan date. 0 = values are equal. 1 = this is greaterthan date. */ $P.compareTo = function (date) { return Date.compare(this, date); }; /** * Compares this instance to another Date object and returns true if they are equal. * @param {Date} Date object to compare. If no date to compare, new Date() [now] is used. * @return {Boolean} true if dates are equal. false if they are not equal. */ $P.equals = function (date) { return Date.equals(this, (date !== undefined ? date : new Date())); }; /** * Determines if this instance is between a range of two dates or equal to either the start or end dates. * @param {Date} Start of range [Required] * @param {Date} End of range [Required] * @return {Boolean} true is this is between or equal to the start and end dates, else false */ $P.between = function (start, end) { return this.getTime() >= start.getTime() && this.getTime() <= end.getTime(); }; /** * Determines if this date occurs after the date to compare to. * @param {Date} Date object to compare. If no date to compare, new Date() ("now") is used. * @return {Boolean} true if this date instance is greater than the date to compare to (or "now"), otherwise false. */ $P.isAfter = function (date) { return this.compareTo(date || new Date()) === 1; }; /** * Determines if this date occurs before the date to compare to. * @param {Date} Date object to compare. If no date to compare, new Date() ("now") is used. * @return {Boolean} true if this date instance is less than the date to compare to (or "now"). */ $P.isBefore = function (date) { return (this.compareTo(date || new Date()) === -1); }; /** * Determines if the current Date instance occurs today. * @return {Boolean} true if this date instance is 'today', otherwise false. */ /** * Determines if the current Date instance occurs on the same Date as the supplied 'date'. * If no 'date' to compare to is provided, the current Date instance is compared to 'today'. * @param {date} Date object to compare. If no date to compare, the current Date ("now") is used. * @return {Boolean} true if this Date instance occurs on the same Day as the supplied 'date'. */ $P.isToday = $P.isSameDay = function (date) { return this.clone().clearTime().equals((date || new Date()).clone().clearTime()); }; /** * Adds the specified number of milliseconds to this instance. * @param {Number} The number of milliseconds to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addMilliseconds = function (value) { if (!value) { return this; } this.setTime(this.getTime() + value * 1); return this; }; /** * Adds the specified number of seconds to this instance. * @param {Number} The number of seconds to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addSeconds = function (value) { if (!value) { return this; } return this.addMilliseconds(value * 1000); }; /** * Adds the specified number of seconds to this instance. * @param {Number} The number of seconds to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addMinutes = function (value) { if (!value) { return this; } return this.addMilliseconds(value * 60000); // 60*1000 }; /** * Adds the specified number of hours to this instance. * @param {Number} The number of hours to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addHours = function (value) { if (!value) { return this; } return this.addMilliseconds(value * 3600000); // 60*60*1000 }; /** * Adds the specified number of days to this instance. * @param {Number} The number of days to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addDays = function (value) { if (!value) { return this; } this.setDate(this.getDate() + value * 1); return this; }; /** * Adds the specified number of weekdays (ie - not sat or sun) to this instance. * @param {Number} The number of days to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addWeekdays = function (value) { if (!value) { return this; } var day = this.getDay(); var weeks = (Math.ceil(Math.abs(value)/7)); if (day === 0 || day === 6) { if (value > 0) { this.next().monday(); this.addDays(-1); day = this.getDay(); } } if (value < 0) { while (value < 0) { this.addDays(-1); day = this.getDay(); if (day !== 0 && day !== 6) { value++; } } return this; } else if (value > 5 || (6-day) <= value) { value = value + (weeks * 2); } return this.addDays(value); }; /** * Adds the specified number of weeks to this instance. * @param {Number} The number of weeks to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addWeeks = function (value) { if (!value) { return this; } return this.addDays(value * 7); }; /** * Adds the specified number of months to this instance. * @param {Number} The number of months to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addMonths = function (value) { if (!value) { return this; } var n = this.getDate(); this.setDate(1); this.setMonth(this.getMonth() + value * 1); this.setDate(Math.min(n, $D.getDaysInMonth(this.getFullYear(), this.getMonth()))); return this; }; $P.addQuarters = function (value) { if (!value) { return this; } // note this will take you to the same point in the quarter as you are now. // i.e. - if you are 15 days into the quarter you'll be 15 days into the resulting one. // bonus: this allows adding fractional quarters return this.addMonths(value * 3); }; /** * Adds the specified number of years to this instance. * @param {Number} The number of years to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addYears = function (value) { if (!value) { return this; } return this.addMonths(value * 12); }; /** * Adds (or subtracts) to the value of the years, months, weeks, days, hours, minutes, seconds, milliseconds of the date instance using given configuration object. Positive and Negative values allowed. * Example

	Date.today().add( { days: 1, months: 1 } )

	new Date().add( { years: -1 } )
	
* @param {Object} Configuration object containing attributes (months, days, etc.) * @return {Date} this */ $P.add = function (config) { if (typeof config === "number") { this._orient = config; return this; } var x = config; if (x.day) { // If we should be a different date than today (eg: for 'tomorrow -1d', etc). // Should only effect parsing, not direct usage (eg, Finish and FinishExact) if ((x.day - this.getDate()) !== 0) { this.setDate(x.day); } } if (x.milliseconds) { this.addMilliseconds(x.milliseconds); } if (x.seconds) { this.addSeconds(x.seconds); } if (x.minutes) { this.addMinutes(x.minutes); } if (x.hours) { this.addHours(x.hours); } if (x.weeks) { this.addWeeks(x.weeks); } if (x.months) { this.addMonths(x.months); } if (x.years) { this.addYears(x.years); } if (x.days) { this.addDays(x.days); } return this; }; /** * Get the week number. Week one (1) is the week which contains the first Thursday of the year. Monday is considered the first day of the week. * The .getWeek() function does NOT convert the date to UTC. The local datetime is used. * Please use .getISOWeek() to get the week of the UTC converted date. * @return {Number} 1 to 53 */ $P.getWeek = function (utc) { // Create a copy of this date object var self, target = new Date(this.valueOf()); if (utc) { target.addMinutes(target.getTimezoneOffset()); self = target.clone(); } else { self = this; } // ISO week date weeks start on monday // so correct the day number var dayNr = (self.getDay() + 6) % 7; // ISO 8601 states that week 1 is the week // with the first thursday of that year. // Set the target date to the thursday in the target week target.setDate(target.getDate() - dayNr + 3); // Store the millisecond value of the target date var firstThursday = target.valueOf(); // Set the target to the first thursday of the year // First set the target to january first target.setMonth(0, 1); // Not a thursday? Correct the date to the next thursday if (target.getDay() !== 4) { target.setMonth(0, 1 + ((4 - target.getDay()) + 7) % 7); } // The weeknumber is the number of weeks between the // first thursday of the year and the thursday in the target week return 1 + Math.ceil((firstThursday - target) / 604800000); // 604800000 = 7 * 24 * 3600 * 1000 }; /** * Get the ISO 8601 week number. Week one ("01") is the week which contains the first Thursday of the year. Monday is considered the first day of the week. * The .getISOWeek() function does convert the date to it's UTC value. Please use .getWeek() to get the week of the local date. * @return {String} "01" to "53" */ $P.getISOWeek = function () { return p(this.getWeek(true)); }; /** * Moves the date to Monday of the week set. Week one (1) is the week which contains the first Thursday of the year. * @param {Number} A Number (1 to 53) that represents the week of the year. * @return {Date} this */ $P.setWeek = function (n) { if ((n - this.getWeek()) === 0) { if (this.getDay() !== 1) { return this.moveToDayOfWeek(1, (this.getDay() > 1 ? -1 : 1)); } else { return this; } } else { return this.moveToDayOfWeek(1, (this.getDay() > 1 ? -1 : 1)).addWeeks(n - this.getWeek()); } }; $P.setQuarter = function (qtr) { var month = Math.abs(((qtr-1) * 3) + 1); return this.setMonth(month, 1); }; $P.getQuarter = function () { return Date.getQuarter(this); }; $P.getDaysLeftInQuarter = function () { return Date.getDaysLeftInQuarter(this); }; /** * Moves the date to the next n'th occurrence of the dayOfWeek starting from the beginning of the month. The number (-1) is a magic number and will return the last occurrence of the dayOfWeek in the month. * @param {Number} The dayOfWeek to move to * @param {Number} The n'th occurrence to move to. Use (-1) to return the last occurrence in the month * @return {Date} this */ $P.moveToNthOccurrence = function (dayOfWeek, occurrence) { if (dayOfWeek === "Weekday") { if (occurrence > 0) { this.moveToFirstDayOfMonth(); if (this.is().weekday()) { occurrence -= 1; } } else if (occurrence < 0) { this.moveToLastDayOfMonth(); if (this.is().weekday()) { occurrence += 1; } } else { return this; } return this.addWeekdays(occurrence); } var shift = 0; if (occurrence > 0) { shift = occurrence - 1; } else if (occurrence === -1) { this.moveToLastDayOfMonth(); if (this.getDay() !== dayOfWeek) { this.moveToDayOfWeek(dayOfWeek, -1); } return this; } return this.moveToFirstDayOfMonth().addDays(-1).moveToDayOfWeek(dayOfWeek, +1).addWeeks(shift); }; var moveToN = function (getFunc, addFunc, nVal) { return function (value, orient) { var diff = (value - this[getFunc]() + nVal * (orient || +1)) % nVal; return this[addFunc]((diff === 0) ? diff += nVal * (orient || +1) : diff); }; }; /** * Move to the next or last dayOfWeek based on the orient value. * @param {Number} The dayOfWeek to move to * @param {Number} Forward (+1) or Back (-1). Defaults to +1. [Optional] * @return {Date} this */ $P.moveToDayOfWeek = moveToN("getDay", "addDays", 7); /** * Move to the next or last month based on the orient value. * @param {Number} The month to move to. 0 = January, 11 = December * @param {Number} Forward (+1) or Back (-1). Defaults to +1. [Optional] * @return {Date} this */ $P.moveToMonth = moveToN("getMonth", "addMonths", 12); /** * Get the Ordinate of the current day ("th", "st", "rd"). * @return {String} */ $P.getOrdinate = function () { var num = this.getDate(); return ord(num); }; /** * Get the Ordinal day (numeric day number) of the year, adjusted for leap year. * @return {Number} 1 through 365 (366 in leap years) */ $P.getOrdinalNumber = function () { return Math.ceil((this.clone().clearTime() - new Date(this.getFullYear(), 0, 1)) / 86400000) + 1; }; /** * Get the time zone abbreviation of the current date. * @return {String} The abbreviated time zone name (e.g. "EST") */ $P.getTimezone = function () { return $D.getTimezoneAbbreviation(this.getUTCOffset(), this.isDaylightSavingTime()); }; $P.setTimezoneOffset = function (offset) { var here = this.getTimezoneOffset(), there = Number(offset) * -6 / 10; return (there || there === 0) ? this.addMinutes(there - here) : this; }; $P.setTimezone = function (offset) { return this.setTimezoneOffset($D.getTimezoneOffset(offset)); }; /** * Indicates whether Daylight Saving Time is observed in the current time zone. * @return {Boolean} true|false */ $P.hasDaylightSavingTime = function () { return (Date.today().set({month: 0, day: 1}).getTimezoneOffset() !== Date.today().set({month: 6, day: 1}).getTimezoneOffset()); }; /** * Indicates whether this Date instance is within the Daylight Saving Time range for the current time zone. * @return {Boolean} true|false */ $P.isDaylightSavingTime = function () { return Date.today().set({month: 0, day: 1}).getTimezoneOffset() !== this.getTimezoneOffset(); }; /** * Get the offset from UTC of the current date. * @return {String} The 4-character offset string prefixed with + or - (e.g. "-0500") */ $P.getUTCOffset = function (offset) { var n = (offset || this.getTimezoneOffset()) * -10 / 6, r; if (n < 0) { r = (n - 10000).toString(); return r.charAt(0) + r.substr(2); } else { r = (n + 10000).toString(); return "+" + r.substr(1); } }; /** * Returns the number of milliseconds between this date and date. * @param {Date} Defaults to now * @return {Number} The diff in milliseconds */ $P.getElapsed = function (date) { return (date || new Date()) - this; }; /** * Set the value of year, month, day, hour, minute, second, millisecond of date instance using given configuration object. * Example

	Date.today().set( { day: 20, month: 1 } )

	new Date().set( { millisecond: 0 } )
	
* * @param {Object} Configuration object containing attributes (month, day, etc.) * @return {Date} this */ $P.set = function (config) { config = validateConfigObject.call(this, config); var key; for (key in config) { if (Object.prototype.hasOwnProperty.call(config, key)) { var name = key.charAt(0).toUpperCase() + key.slice(1); var addFunc, getFunc; if (key !== "week" && key !== "month" && key !== "timezone" && key !== "timezoneOffset") { name += "s"; } addFunc = "add" + name; getFunc = "get" + name; if (key === "month") { addFunc = addFunc + "s"; } else if (key === "year"){ getFunc = "getFullYear"; } if (key !== "day" && key !== "timezone" && key !== "timezoneOffset" && key !== "week" && key !== "hour") { this[addFunc](config[key] - this[getFunc]()); } else if ( key === "timezone"|| key === "timezoneOffset" || key === "week" || key === "hour") { this["set"+name](config[key]); } } } // day has to go last because you can't validate the day without first knowing the month if (config.day) { this.addDays(config.day - this.getDate()); } return this; }; /** * Moves the date to the first day of the month. * @return {Date} this */ $P.moveToFirstDayOfMonth = function () { return this.set({ day: 1 }); }; /** * Moves the date to the last day of the month. * @return {Date} this */ $P.moveToLastDayOfMonth = function () { return this.set({ day: $D.getDaysInMonth(this.getFullYear(), this.getMonth())}); }; /** * Converts the value of the current Date object to its equivalent string representation. * Format Specifiers * CUSTOM DATE AND TIME FORMAT STRINGS * Format Description Example * ------ --------------------------------------------------------------------------- ----------------------- * s The seconds of the minute between 0-59. "0" to "59" * ss The seconds of the minute with leading zero if required. "00" to "59" * * m The minute of the hour between 0-59. "0" or "59" * mm The minute of the hour with leading zero if required. "00" or "59" * * h The hour of the day between 1-12. "1" to "12" * hh The hour of the day with leading zero if required. "01" to "12" * * H The hour of the day between 0-23. "0" to "23" * HH The hour of the day with leading zero if required. "00" to "23" * * d The day of the month between 1 and 31. "1" to "31" * dd The day of the month with leading zero if required. "01" to "31" * ddd Abbreviated day name. Date.CultureInfo.abbreviatedDayNames. "Mon" to "Sun" * dddd The full day name. Date.CultureInfo.dayNames. "Monday" to "Sunday" * * M The month of the year between 1-12. "1" to "12" * MM The month of the year with leading zero if required. "01" to "12" * MMM Abbreviated month name. Date.CultureInfo.abbreviatedMonthNames. "Jan" to "Dec" * MMMM The full month name. Date.CultureInfo.monthNames. "January" to "December" * * yy The year as a two-digit number. "99" or "08" * yyyy The full four digit year. "1999" or "2008" * * t Displays the first character of the A.M./P.M. designator. "A" or "P" * Date.CultureInfo.amDesignator or Date.CultureInfo.pmDesignator * tt Displays the A.M./P.M. designator. "AM" or "PM" * Date.CultureInfo.amDesignator or Date.CultureInfo.pmDesignator * * S The ordinal suffix ("st, "nd", "rd" or "th") of the current day. "st, "nd", "rd" or "th" * * STANDARD DATE AND TIME FORMAT STRINGS * Format Description Example *------ --------------------------------------------------------------------------- ----------------------- * d The CultureInfo shortDate Format Pattern "M/d/yyyy" * D The CultureInfo longDate Format Pattern "dddd, MMMM dd, yyyy" * F The CultureInfo fullDateTime Format Pattern "dddd, MMMM dd, yyyy h:mm:ss tt" * m The CultureInfo monthDay Format Pattern "MMMM dd" * r The CultureInfo rfc1123 Format Pattern "ddd, dd MMM yyyy HH:mm:ss GMT" * s The CultureInfo sortableDateTime Format Pattern "yyyy-MM-ddTHH:mm:ss" * t The CultureInfo shortTime Format Pattern "h:mm tt" * T The CultureInfo longTime Format Pattern "h:mm:ss tt" * u The CultureInfo universalSortableDateTime Format Pattern "yyyy-MM-dd HH:mm:ssZ" * y The CultureInfo yearMonth Format Pattern "MMMM, yyyy" * * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @return {String} A string representation of the current Date object. */ var ord = function (n) { switch (n * 1) { case 1: case 21: case 31: return "st"; case 2: case 22: return "nd"; case 3: case 23: return "rd"; default: return "th"; } }; var parseStandardFormats = function (format) { var y, c = Date.CultureInfo.formatPatterns; switch (format) { case "d": return this.toString(c.shortDate); case "D": return this.toString(c.longDate); case "F": return this.toString(c.fullDateTime); case "m": return this.toString(c.monthDay); case "r": case "R": y = this.clone().addMinutes(this.getTimezoneOffset()); return y.toString(c.rfc1123) + " GMT"; case "s": return this.toString(c.sortableDateTime); case "t": return this.toString(c.shortTime); case "T": return this.toString(c.longTime); case "u": y = this.clone().addMinutes(this.getTimezoneOffset()); return y.toString(c.universalSortableDateTime); case "y": return this.toString(c.yearMonth); default: return false; } }; var parseFormatStringsClosure = function (context) { return function (m) { if (m.charAt(0) === "\\") { return m.replace("\\", ""); } switch (m) { case "hh": return p(context.getHours() < 13 ? (context.getHours() === 0 ? 12 : context.getHours()) : (context.getHours() - 12)); case "h": return context.getHours() < 13 ? (context.getHours() === 0 ? 12 : context.getHours()) : (context.getHours() - 12); case "HH": return p(context.getHours()); case "H": return context.getHours(); case "mm": return p(context.getMinutes()); case "m": return context.getMinutes(); case "ss": return p(context.getSeconds()); case "s": return context.getSeconds(); case "yyyy": return p(context.getFullYear(), 4); case "yy": return p(context.getFullYear()); case "y": return context.getFullYear(); case "E": case "dddd": return Date.CultureInfo.dayNames[context.getDay()]; case "ddd": return Date.CultureInfo.abbreviatedDayNames[context.getDay()]; case "dd": return p(context.getDate()); case "d": return context.getDate(); case "MMMM": return Date.CultureInfo.monthNames[context.getMonth()]; case "MMM": return Date.CultureInfo.abbreviatedMonthNames[context.getMonth()]; case "MM": return p((context.getMonth() + 1)); case "M": return context.getMonth() + 1; case "t": return context.getHours() < 12 ? Date.CultureInfo.amDesignator.substring(0, 1) : Date.CultureInfo.pmDesignator.substring(0, 1); case "tt": return context.getHours() < 12 ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator; case "S": return ord(context.getDate()); case "W": return context.getWeek(); case "WW": return context.getISOWeek(); case "Q": return "Q" + context.getQuarter(); case "q": return String(context.getQuarter()); case "z": return context.getTimezone(); case "Z": case "X": return Date.getTimezoneOffset(context.getTimezone()); case "ZZ": // Timezone offset in seconds return context.getTimezoneOffset() * -60; case "u": return context.getDay(); case "L": return ($D.isLeapYear(context.getFullYear())) ? 1 : 0; case "B": // Swatch Internet Time (.beats) return "@"+((context.getUTCSeconds() + (context.getUTCMinutes()*60) + ((context.getUTCHours()+1)*3600))/86.4); default: return m; } }; }; $P.toString = function (format, ignoreStandards) { // Standard Date and Time Format Strings. Formats pulled from CultureInfo file and // may vary by culture. if (!ignoreStandards && format && format.length === 1) { output = parseStandardFormats.call(this, format); if (output) { return output; } } var parseFormatStrings = parseFormatStringsClosure(this); return format ? format.replace(/((\\)?(dd?d?d?|MM?M?M?|yy?y?y?|hh?|HH?|mm?|ss?|tt?|S|q|Q|WW?W?W?)(?![^\[]*\]))/g, parseFormatStrings).replace(/\[|\]/g, "") : this._toString(); }; }()); /************************************************************* * SugarPak - Domain Specific Language - Syntactical Sugar * *************************************************************/ (function () { var $D = Date, $P = $D.prototype, $N = Number.prototype; // private $P._orient = +1; // private $P._nth = null; // private $P._is = false; // private $P._same = false; // private $P._isSecond = false; // private $N._dateElement = "days"; /** * Moves the date to the next instance of a date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.today().next().friday();
	Date.today().next().fri();
	Date.today().next().march();
	Date.today().next().mar();
	Date.today().next().week();
	
* * @return {Date} date */ $P.next = function () { this._move = true; this._orient = +1; return this; }; /** * Creates a new Date (Date.today()) and moves the date to the next instance of the date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.next().friday();
	Date.next().fri();
	Date.next().march();
	Date.next().mar();
	Date.next().week();
	
* * @return {Date} date */ $D.next = function () { return $D.today().next(); }; /** * Moves the date to the previous instance of a date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.today().last().friday();
	Date.today().last().fri();
	Date.today().last().march();
	Date.today().last().mar();
	Date.today().last().week();
	
* * @return {Date} date */ $P.last = $P.prev = $P.previous = function () { this._move = true; this._orient = -1; return this; }; /** * Creates a new Date (Date.today()) and moves the date to the previous instance of the date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.last().friday();
	Date.last().fri();
	Date.previous().march();
	Date.prev().mar();
	Date.last().week();
	
* * @return {Date} date */ $D.last = $D.prev = $D.previous = function () { return $D.today().last(); }; /** * Performs a equality check when followed by either a month name, day name or .weekday() function. * Example

	Date.today().is().friday(); // true|false
	Date.today().is().fri();
	Date.today().is().march();
	Date.today().is().mar();
	
* * @return {Boolean} true|false */ $P.is = function () { this._is = true; return this; }; /** * Determines if two date objects occur on/in exactly the same instance of the subsequent date part function. * The function .same() must be followed by a date part function (example: .day(), .month(), .year(), etc). * * An optional Date can be passed in the date part function. If now date is passed as a parameter, 'Now' is used. * * The following example demonstrates how to determine if two dates fall on the exact same day. * * Example

	var d1 = Date.today(); // today at 00:00
	var d2 = new Date();   // exactly now.

	// Do they occur on the same day?
	d1.same().day(d2); // true
	
	// Do they occur on the same hour?
	d1.same().hour(d2); // false, unless d2 hour is '00' (midnight).
	
	// What if it's the same day, but one year apart?
	var nextYear = Date.today().add(1).year();

	d1.same().day(nextYear); // false, because the dates must occur on the exact same day. 
	
* * Scenario: Determine if a given date occurs during some week period 2 months from now. * * Example

	var future = Date.today().add(2).months();
	return someDate.same().week(future); // true|false;
	
* * @return {Boolean} true|false */ $P.same = function () { this._same = true; this._isSecond = false; return this; }; /** * Determines if the current date/time occurs during Today. Must be preceded by the .is() function. * Example

	someDate.is().today();    // true|false
	new Date().is().today();  // true
	Date.today().is().today();// true
	Date.today().add(-1).day().is().today(); // false
	
* * @return {Boolean} true|false */ $P.today = function () { return this.same().day(); }; /** * Determines if the current date is a weekday. This function must be preceded by the .is() function. * Example

	Date.today().is().weekday(); // true|false
	
* * @return {Boolean} true|false */ $P.weekday = function () { if (this._nth) { return df("Weekday").call(this); } if (this._move) { return this.addWeekdays(this._orient); } if (this._is) { this._is = false; return (!this.is().sat() && !this.is().sun()); } return false; }; /** * Determines if the current date is on the weekend. This function must be preceded by the .is() function. * Example

	Date.today().is().weekend(); // true|false
	
* * @return {Boolean} true|false */ $P.weekend = function () { if (this._is) { this._is = false; return (this.is().sat() || this.is().sun()); } return false; }; /** * Sets the Time of the current Date instance. A string "6:15 pm" or config object {hour:18, minute:15} are accepted. * Example

	// Set time to 6:15pm with a String
	Date.today().at("6:15pm");

	// Set time to 6:15pm with a config object
	Date.today().at({hour:18, minute:15});
	
* * @return {Date} date */ $P.at = function (time) { return (typeof time === "string") ? $D.parse(this.toString("d") + " " + time) : this.set(time); }; /** * Creates a new Date() and adds this (Number) to the date based on the preceding date element function (eg. second|minute|hour|day|month|year). * Example

	// Undeclared Numbers must be wrapped with parentheses. Requirment of JavaScript.
	(3).days().fromNow();
	(6).months().fromNow();

	// Declared Number variables do not require parentheses. 
	var n = 6;
	n.months().fromNow();
	
* * @return {Date} A new Date instance */ $N.fromNow = $N.after = function (date) { var c = {}; c[this._dateElement] = this; return ((!date) ? new Date() : date.clone()).add(c); }; /** * Creates a new Date() and subtract this (Number) from the date based on the preceding date element function (eg. second|minute|hour|day|month|year). * Example

	// Undeclared Numbers must be wrapped with parentheses. Requirment of JavaScript.
	(3).days().ago();
	(6).months().ago();

	// Declared Number variables do not require parentheses. 
	var n = 6;
	n.months().ago();
	
* * @return {Date} A new Date instance */ $N.ago = $N.before = function (date) { var c = {}, s = (this._dateElement[this._dateElement.length-1] !== "s") ? this._dateElement + "s" : this._dateElement; c[s] = this * -1; return ((!date) ? new Date() : date.clone()).add(c); }; // Do NOT modify the following string tokens. These tokens are used to build dynamic functions. // All culture-specific strings can be found in the CultureInfo files. var dx = ("sunday monday tuesday wednesday thursday friday saturday").split(/\s/), mx = ("january february march april may june july august september october november december").split(/\s/), px = ("Millisecond Second Minute Hour Day Week Month Year Quarter Weekday").split(/\s/), pxf = ("Milliseconds Seconds Minutes Hours Date Week Month FullYear Quarter").split(/\s/), nth = ("final first second third fourth fifth").split(/\s/), de; /** * Returns an object literal of all the date parts. * Example

	var o = new Date().toObject();
	
	// { year: 2008, month: 4, week: 20, day: 13, hour: 18, minute: 9, second: 32, millisecond: 812 }
	
	// The object properties can be referenced directly from the object.
	
	alert(o.day);  // alerts "13"
	alert(o.year); // alerts "2008"
	
* * @return {Date} An object literal representing the original date object. */ $P.toObject = function () { var o = {}; for (var i = 0; i < px.length; i++) { if (this["get" + pxf[i]]) { o[px[i].toLowerCase()] = this["get" + pxf[i]](); } } return o; }; /** * Returns a date created from an object literal. Ignores the .week property if set in the config. * Example

	var o = new Date().toObject();
	
	return Date.fromObject(o); // will return the same date. 

	var o2 = {month: 1, day: 20, hour: 18}; // birthday party!
	Date.fromObject(o2);
	
* * @return {Date} An object literal representing the original date object. */ $D.fromObject = function(config) { config.week = null; return Date.today().set(config); }; // Create day name functions and abbreviated day name functions (eg. monday(), friday(), fri()). var df = function (n) { return function () { if (this._is) { this._is = false; return this.getDay() === n; } if (this._move) { this._move = null; } if (this._nth !== null) { // If the .second() function was called earlier, remove the _orient // from the date, and then continue. // This is required because 'second' can be used in two different context. // // Example // // Date.today().add(1).second(); // Date.march().second().monday(); // // Things get crazy with the following... // Date.march().add(1).second().second().monday(); // but it works!! // if (this._isSecond) { this.addSeconds(this._orient * -1); } // make sure we reset _isSecond this._isSecond = false; var ntemp = this._nth; this._nth = null; var temp = this.clone().moveToLastDayOfMonth(); this.moveToNthOccurrence(n, ntemp); if (this > temp) { throw new RangeError($D.getDayName(n) + " does not occur " + ntemp + " times in the month of " + $D.getMonthName(temp.getMonth()) + " " + temp.getFullYear() + "."); } return this; } return this.moveToDayOfWeek(n, this._orient); }; }; var sdf = function (n) { return function () { var t = $D.today(), shift = n - t.getDay(); if (n === 0 && Date.CultureInfo.firstDayOfWeek === 1 && t.getDay() !== 0) { shift = shift + 7; } return t.addDays(shift); }; }; // Create month name functions and abbreviated month name functions (eg. january(), march(), mar()). var month_instance_functions = function (n) { return function () { if (this._is) { this._is = false; return this.getMonth() === n; } return this.moveToMonth(n, this._orient); }; }; var month_static_functions = function (n) { return function () { return $D.today().set({ month: n, day: 1 }); }; }; var processTerms = function (names, staticFunc, instanceFunc) { for (var i = 0; i < names.length; i++) { // Create constant static Name variables. $D[names[i].toUpperCase()] = $D[names[i].toUpperCase().substring(0, 3)] = i; // Create Name functions. $D[names[i]] = $D[names[i].substring(0, 3)] = staticFunc(i); // Create Name instance functions. $P[names[i]] = $P[names[i].substring(0, 3)] = instanceFunc(i); } }; processTerms(dx, sdf, df); processTerms(mx, month_static_functions, month_instance_functions); // Create date element functions and plural date element functions used with Date (eg. day(), days(), months()). var ef = function (j) { return function () { // if the .second() function was called earlier, the _orient // has alread been added. Just return this and reset _isSecond. if (this._isSecond) { this._isSecond = false; return this; } if (this._same) { this._same = this._is = false; var o1 = this.toObject(), o2 = (arguments[0] || new Date()).toObject(), v = "", k = j.toLowerCase(); // the substr trick with -1 doesn't work in IE8 or less k = (k[k.length-1] === "s") ? k.substring(0,k.length-1) : k; for (var m = (px.length - 1); m > -1; m--) { v = px[m].toLowerCase(); if (o1[v] !== o2[v]) { return false; } if (k === v) { break; } } return true; } if (j.substring(j.length - 1) !== "s") { j += "s"; } if (this._move) { this._move = null; } return this["add" + j](this._orient); }; }; var nf = function (n) { return function () { this._dateElement = n; return this; }; }; for (var k = 0; k < px.length; k++) { de = px[k].toLowerCase(); if(de !== "weekday") { // Create date element functions and plural date element functions used with Date (eg. day(), days(), months()). $P[de] = $P[de + "s"] = ef(px[k]); // Create date element functions and plural date element functions used with Number (eg. day(), days(), months()). $N[de] = $N[de + "s"] = nf(de + "s"); } } $P._ss = ef("Second"); var nthfn = function (n) { return function (dayOfWeek) { if (this._same) { return this._ss(arguments[0]); } if (dayOfWeek || dayOfWeek === 0) { return this.moveToNthOccurrence(dayOfWeek, n); } this._nth = n; // if the operator is 'second' add the _orient, then deal with it later... if (n === 2 && (dayOfWeek === undefined || dayOfWeek === null)) { this._isSecond = true; return this.addSeconds(this._orient); } return this; }; }; for (var l = 0; l < nth.length; l++) { $P[nth[l]] = (l === 0) ? nthfn(-1) : nthfn(l); } }()); (function () { "use strict"; Date.Parsing = { Exception: function (s) { this.message = "Parse error at '" + s.substring(0, 10) + " ...'"; } }; var $P = Date.Parsing; var dayOffsets = { standard: [0,31,59,90,120,151,181,212,243,273,304,334], leap: [0,31,60,91,121,152,182,213,244,274,305,335] }; $P.isLeapYear = function(year) { return ((year % 4 === 0) && (year % 100 !== 0)) || (year % 400 === 0); }; var utils = { multiReplace : function (str, hash ) { var key; for (key in hash) { if (Object.prototype.hasOwnProperty.call(hash, key)) { var regex; if (typeof hash[key] === "function") { } else { regex = (hash[key] instanceof RegExp) ? hash[key] : new RegExp(hash[key], "g"); } str = str.replace(regex, key); } } return str; }, getDayOfYearFromWeek : function (obj) { var d, jan4, offset; obj.weekDay = (!obj.weekDay && obj.weekDay !== 0) ? 1 : obj.weekDay; d = new Date(obj.year, 0, 4); jan4 = d.getDay() === 0 ? 7 : d.getDay(); // JS is 0 indexed on Sunday. offset = jan4+3; obj.dayOfYear = ((obj.week * 7) + (obj.weekDay === 0 ? 7 : obj.weekDay))-offset; return obj; }, getDayOfYear : function (obj, dayOffset) { if (!obj.dayOfYear) { obj = utils.getDayOfYearFromWeek(obj); } for (var i=0;i <= dayOffset.length;i++) { if (obj.dayOfYear < dayOffset[i] || i === dayOffset.length) { obj.day = obj.day ? obj.day : (obj.dayOfYear - dayOffset[i-1]); break; } else { obj.month = i; } } return obj; }, adjustForTimeZone : function (obj, date) { var offset; if (obj.zone.toUpperCase() === "Z" || (obj.zone_hours === 0 && obj.zone_minutes === 0)) { // it's UTC/GML so work out the current timeszone offset offset = -date.getTimezoneOffset(); } else { offset = (obj.zone_hours*60) + (obj.zone_minutes || 0); if (obj.zone_sign === "+") { offset *= -1; } offset -= date.getTimezoneOffset(); } date.setMinutes(date.getMinutes()+offset); return date; }, setDefaults : function (obj) { obj.year = obj.year || Date.today().getFullYear(); obj.hours = obj.hours || 0; obj.minutes = obj.minutes || 0; obj.seconds = obj.seconds || 0; obj.milliseconds = obj.milliseconds || 0; if (!(!obj.month && (obj.week || obj.dayOfYear))) { // if we have a month, or if we don't but don't have the day calculation data obj.month = obj.month || 0; obj.day = obj.day || 1; } return obj; }, dataNum: function (data, mod, explict, postProcess) { var dataNum = data*1; if (mod) { if (postProcess) { return data ? mod(data)*1 : data; } else { return data ? mod(dataNum) : data; } } else if (!explict){ return data ? dataNum : data; } else { return (data && typeof data !== "undefined") ? dataNum : data; } }, timeDataProcess: function (obj) { var timeObj = {}; for (var x in obj.data) { if (obj.data.hasOwnProperty(x)) { timeObj[x] = obj.ignore[x] ? obj.data[x] : utils.dataNum(obj.data[x], obj.mods[x], obj.explict[x], obj.postProcess[x]); } } if (obj.data.secmins) { obj.data.secmins = obj.data.secmins.replace(",", ".") * 60; if (!timeObj.minutes) { timeObj.minutes = obj.data.secmins; } else if (!timeObj.seconds) { timeObj.seconds = obj.data.secmins; } delete obj.secmins; } return timeObj; }, buildTimeObjectFromData: function (data) { var time = utils.timeDataProcess({ data: { year : data[1], month : data[5], day : data[7], week : data[8], dayOfYear : data[10], hours : data[15], zone_hours : data[23], zone_minutes : data[24], zone : data[21], zone_sign : data[22], weekDay : data[9], minutes: data[16], seconds: data[19], milliseconds: data[20], secmins: data[18] }, mods: { month: function(data) { return data-1; }, weekDay: function (data) { data = Math.abs(data); return (data === 7 ? 0 : data); }, minutes: function (data) { return data.replace(":",""); }, seconds: function (data) { return Math.floor( (data.replace(":","").replace(",","."))*1 ); }, milliseconds: function (data) { return (data.replace(",",".")*1000); } }, postProcess: { minutes: true, seconds: true, milliseconds: true }, explict: { zone_hours: true, zone_minutes: true }, ignore: { zone: true, zone_sign: true, secmins: true } }); return time; }, addToHash: function (hash, keys, data) { keys = keys; data = data; var len = keys.length; for (var i = 0; i < len; i++) { hash[keys[i]] = data[i]; } return hash; }, combineRegex: function (r1, r2) { return new RegExp("(("+r1.source+")\\s("+r2.source+"))"); }, getDateNthString: function(add, last, inc){ if (add) { return Date.today().addDays(inc).toString("d"); } else if (last) { return Date.today().last()[inc]().toString("d"); } }, buildRegexData: function (array) { var arr = []; var len = array.length; for (var i=0; i < len; i++) { if (Object.prototype.toString.call(array[i]) === '[object Array]') { // oldIE compat version of Array.isArray arr.push(this.combineRegex(array[i][0], array[i][1])); } else { arr.push(array[i]); } } return arr; } }; $P.processTimeObject = function (obj) { var date, dayOffset; utils.setDefaults(obj); dayOffset = ($P.isLeapYear(obj.year)) ? dayOffsets.leap : dayOffsets.standard; if (!obj.month && (obj.week || obj.dayOfYear)) { utils.getDayOfYear(obj, dayOffset); } else { obj.dayOfYear = dayOffset[obj.month] + obj.day; } date = new Date(obj.year, obj.month, obj.day, obj.hours, obj.minutes, obj.seconds, obj.milliseconds); if (obj.zone) { utils.adjustForTimeZone(obj, date); // adjust (and calculate) for timezone } return date; }; $P.ISO = { regex : /^([\+-]?\d{4}(?!\d{2}\b))((-?)((0[1-9]|1[0-2])(\3([12]\d|0[1-9]|3[01]))?|W([0-4]\d|5[0-3])(-?[1-7])?|(00[1-9]|0[1-9]\d|[12]\d{2}|3([0-5]\d|6[1-6])))([T\s]((([01]\d|2[0-4])((:?)[0-5]\d)?|24\:?00)([\.,]\d+(?!:))?)?(\17[0-5]\d([\.,]\d+)?)?\s?([zZ]|([\+-])([01]\d|2[0-3]):?([0-5]\d)?)?)?)?$/, parse : function (s) { var time, data = s.match(this.regex); if (!data || !data.length) { return null; } time = utils.buildTimeObjectFromData(data); if (!time.year || (!time.year && (!time.month && !time.day) && (!time.week && !time.dayOfYear)) ) { return null; } return $P.processTimeObject(time); } }; $P.Numeric = { isNumeric: function (e){return!isNaN(parseFloat(e))&&isFinite(e);}, regex: /\b([0-1]?[0-9])([0-3]?[0-9])([0-2]?[0-9]?[0-9][0-9])\b/i, parse: function (s) { var data, i, time = {}, order = Date.CultureInfo.dateElementOrder.split(""); if (!(this.isNumeric(s)) || // if it's non-numeric OR (s[0] === "+" && s[0] === "-")) { // It's an arithmatic string (eg +/-1000) return null; } if (s.length < 5 && s.indexOf(".") < 0 && s.indexOf("/") < 0) { // assume it's just a year. time.year = s; return $P.processTimeObject(time); } data = s.match(this.regex); if (!data || !data.length) { return null; } for (i=0; i < order.length; i++) { switch(order[i]) { case "d": time.day = data[i+1]; break; case "m": time.month = (data[i+1]-1); break; case "y": time.year = data[i+1]; break; } } return $P.processTimeObject(time); } }; $P.Normalizer = { regexData: function () { var $R = Date.CultureInfo.regexPatterns; return utils.buildRegexData([ $R.tomorrow, $R.yesterday, [$R.past, $R.mon], [$R.past, $R.tue], [$R.past, $R.wed], [$R.past, $R.thu], [$R.past, $R.fri], [$R.past, $R.sat], [$R.past, $R.sun] ]); }, basicReplaceHash : function() { var $R = Date.CultureInfo.regexPatterns; return { "January": $R.jan.source, "February": $R.feb, "March": $R.mar, "April": $R.apr, "May": $R.may, "June": $R.jun, "July": $R.jul, "August": $R.aug, "September": $R.sep, "October": $R.oct, "November": $R.nov, "December": $R.dec, "": /\bat\b/gi, " ": /\s{2,}/, "am": $R.inTheMorning, "9am": $R.thisMorning, "pm": $R.inTheEvening, "7pm":$R.thisEvening }; }, keys : function(){ return [ utils.getDateNthString(true, false, 1), // tomorrow utils.getDateNthString(true, false, -1), // yesterday utils.getDateNthString(false, true, "monday"), //last mon utils.getDateNthString(false, true, "tuesday"), //last tues utils.getDateNthString(false, true, "wednesday"), //last wed utils.getDateNthString(false, true, "thursday"), //last thurs utils.getDateNthString(false, true, "friday"), //last fri utils.getDateNthString(false, true, "saturday"), //last sat utils.getDateNthString(false, true, "sunday") //last sun ]; }, buildRegexFunctions: function () { var $R = Date.CultureInfo.regexPatterns; var __ = Date.i18n.__; var tomorrowRE = new RegExp("(\\b\\d\\d?("+__("AM")+"|"+__("PM")+")? )("+$R.tomorrow.source.slice(1)+")", "i"); // adapted tomorrow regex for AM PM relative dates var todayRE = new RegExp($R.today.source + "(?!\\s*([+-]))\\b"); // today, but excludes the math operators (eg "today + 2h") this.replaceFuncs = [ [todayRE, function (full) { return (full.length > 1) ? Date.today().toString("d") : full; }], [tomorrowRE, function(full, m1) { var t = Date.today().addDays(1).toString("d"); return (t + " " + m1); }], [$R.amThisMorning, function(str, am){return am;}], [$R.pmThisEvening, function(str, pm){return pm;}] ]; }, buildReplaceData: function () { this.buildRegexFunctions(); this.replaceHash = utils.addToHash(this.basicReplaceHash(), this.keys(), this.regexData()); }, stringReplaceFuncs: function (s) { for (var i=0; i < this.replaceFuncs.length; i++) { s = s.replace(this.replaceFuncs[i][0], this.replaceFuncs[i][1]); } return s; }, parse: function (s) { s = this.stringReplaceFuncs(s); s = utils.multiReplace(s, this.replaceHash); try { var n = s.split(/([\s\-\.\,\/\x27]+)/); if (n.length === 3 && $P.Numeric.isNumeric(n[0]) && $P.Numeric.isNumeric(n[2]) && (n[2].length >= 4)) { // ok, so we're dealing with x/year. But that's not a full date. // This fixes wonky dateElementOrder parsing when set to dmy order. if (Date.CultureInfo.dateElementOrder[0] === "d") { s = "1/" + n[0] + "/" + n[2]; // set to 1st of month and normalize the seperator } } } catch (e) {} return s; } }; $P.Normalizer.buildReplaceData(); }()); (function () { var $P = Date.Parsing; var _ = $P.Operators = { // // Tokenizers // rtoken: function (r) { // regex token return function (s) { var mx = s.match(r); if (mx) { return ([ mx[0], s.substring(mx[0].length) ]); } else { throw new $P.Exception(s); } }; }, token: function () { // whitespace-eating token return function (s) { return _.rtoken(new RegExp("^\\s*" + s + "\\s*"))(s); }; }, stoken: function (s) { // string token return _.rtoken(new RegExp("^" + s)); }, // Atomic Operators until: function (p) { return function (s) { var qx = [], rx = null; while (s.length) { try { rx = p.call(this, s); } catch (e) { qx.push(rx[0]); s = rx[1]; continue; } break; } return [ qx, s ]; }; }, many: function (p) { return function (s) { var rx = [], r = null; while (s.length) { try { r = p.call(this, s); } catch (e) { return [ rx, s ]; } rx.push(r[0]); s = r[1]; } return [ rx, s ]; }; }, // generator operators -- see below optional: function (p) { return function (s) { var r = null; try { r = p.call(this, s); } catch (e) { return [ null, s ]; } return [ r[0], r[1] ]; }; }, not: function (p) { return function (s) { try { p.call(this, s); } catch (e) { return [null, s]; } throw new $P.Exception(s); }; }, ignore: function (p) { return p ? function (s) { var r = null; r = p.call(this, s); return [null, r[1]]; } : null; }, product: function () { var px = arguments[0], qx = Array.prototype.slice.call(arguments, 1), rx = []; for (var i = 0 ; i < px.length ; i++) { rx.push(_.each(px[i], qx)); } return rx; }, cache: function (rule) { var cache = {}, cache_length = 0, cache_keys = [], CACHE_MAX = Date.Config.CACHE_MAX || 100000, r = null; var cacheCheck = function () { if (cache_length === CACHE_MAX) { // kill several keys, don't want to have to do this all the time... for (var i=0; i < 10; i++) { var key = cache_keys.shift(); if (key) { delete cache[key]; cache_length--; } } } }; return function (s) { cacheCheck(); try { r = cache[s] = (cache[s] || rule.call(this, s)); } catch (e) { r = cache[s] = e; } cache_length++; cache_keys.push(s); if (r instanceof $P.Exception) { throw r; } else { return r; } }; }, // vector operators -- see below any: function () { var px = arguments; return function (s) { var r = null; for (var i = 0; i < px.length; i++) { if (px[i] == null) { continue; } try { r = (px[i].call(this, s)); } catch (e) { r = null; } if (r) { return r; } } throw new $P.Exception(s); }; }, each: function () { var px = arguments; return function (s) { var rx = [], r = null; for (var i = 0; i < px.length ; i++) { if (px[i] == null) { continue; } try { r = (px[i].call(this, s)); } catch (e) { throw new $P.Exception(s); } rx.push(r[0]); s = r[1]; } return [ rx, s]; }; }, all: function () { var px = arguments, _ = _; return _.each(_.optional(px)); }, // delimited operators sequence: function (px, d, c) { d = d || _.rtoken(/^\s*/); c = c || null; if (px.length === 1) { return px[0]; } return function (s) { var r = null, q = null; var rx = []; for (var i = 0; i < px.length ; i++) { try { r = px[i].call(this, s); } catch (e) { break; } rx.push(r[0]); try { q = d.call(this, r[1]); } catch (ex) { q = null; break; } s = q[1]; } if (!r) { throw new $P.Exception(s); } if (q) { throw new $P.Exception(q[1]); } if (c) { try { r = c.call(this, r[1]); } catch (ey) { throw new $P.Exception(r[1]); } } return [ rx, (r?r[1]:s) ]; }; }, // // Composite Operators // between: function (d1, p, d2) { d2 = d2 || d1; var _fn = _.each(_.ignore(d1), p, _.ignore(d2)); return function (s) { var rx = _fn.call(this, s); return [[rx[0][0], r[0][2]], rx[1]]; }; }, list: function (p, d, c) { d = d || _.rtoken(/^\s*/); c = c || null; return (p instanceof Array ? _.each(_.product(p.slice(0, -1), _.ignore(d)), p.slice(-1), _.ignore(c)) : _.each(_.many(_.each(p, _.ignore(d))), px, _.ignore(c))); }, set: function (px, d, c) { d = d || _.rtoken(/^\s*/); c = c || null; return function (s) { // r is the current match, best the current 'best' match // which means it parsed the most amount of input var r = null, p = null, q = null, rx = null, best = [[], s], last = false; // go through the rules in the given set for (var i = 0; i < px.length ; i++) { // last is a flag indicating whether this must be the last element // if there is only 1 element, then it MUST be the last one q = null; p = null; r = null; last = (px.length === 1); // first, we try simply to match the current pattern // if not, try the next pattern try { r = px[i].call(this, s); } catch (e) { continue; } // since we are matching against a set of elements, the first // thing to do is to add r[0] to matched elements rx = [[r[0]], r[1]]; // if we matched and there is still input to parse and // we don't already know this is the last element, // we're going to next check for the delimiter ... // if there's none, or if there's no input left to parse // than this must be the last element after all ... if (r[1].length > 0 && ! last) { try { q = d.call(this, r[1]); } catch (ex) { last = true; } } else { last = true; } // if we parsed the delimiter and now there's no more input, // that means we shouldn't have parsed the delimiter at all // so don't update r and mark this as the last element ... if (!last && q[1].length === 0) { last = true; } // so, if this isn't the last element, we're going to see if // we can get any more matches from the remaining (unmatched) // elements ... if (!last) { // build a list of the remaining rules we can match against, // i.e., all but the one we just matched against var qx = []; for (var j = 0; j < px.length ; j++) { if (i !== j) { qx.push(px[j]); } } // now invoke recursively set with the remaining input // note that we don't include the closing delimiter ... // we'll check for that ourselves at the end p = _.set(qx, d).call(this, q[1]); // if we got a non-empty set as a result ... // (otw rx already contains everything we want to match) if (p[0].length > 0) { // update current result, which is stored in rx ... // basically, pick up the remaining text from p[1] // and concat the result from p[0] so that we don't // get endless nesting ... rx[0] = rx[0].concat(p[0]); rx[1] = p[1]; } } // at this point, rx either contains the last matched element // or the entire matched set that starts with this element. // now we just check to see if this variation is better than // our best so far, in terms of how much of the input is parsed if (rx[1].length < best[1].length) { best = rx; } // if we've parsed all the input, then we're finished if (best[1].length === 0) { break; } } // so now we've either gone through all the patterns trying them // as the initial match; or we found one that parsed the entire // input string ... // if best has no matches, just return empty set ... if (best[0].length === 0) { return best; } // if a closing delimiter is provided, then we have to check it also if (c) { // we try this even if there is no remaining input because the pattern // may well be optional or match empty input ... try { q = c.call(this, best[1]); } catch (ey) { throw new $P.Exception(best[1]); } // it parsed ... be sure to update the best match remaining input best[1] = q[1]; } // if we're here, either there was no closing delimiter or we parsed it // so now we have the best match; just return it! return best; }; }, forward: function (gr, fname) { return function (s) { return gr[fname].call(this, s); }; }, // // Translation Operators // replace: function (rule, repl) { return function (s) { var r = rule.call(this, s); return [repl, r[1]]; }; }, process: function (rule, fn) { return function (s) { var r = rule.call(this, s); return [fn.call(this, r[0]), r[1]]; }; }, min: function (min, rule) { return function (s) { var rx = rule.call(this, s); if (rx[0].length < min) { throw new $P.Exception(s); } return rx; }; } }; // Generator Operators And Vector Operators // Generators are operators that have a signature of F(R) => R, // taking a given rule and returning another rule, such as // ignore, which parses a given rule and throws away the result. // Vector operators are those that have a signature of F(R1,R2,...) => R, // take a list of rules and returning a new rule, such as each. // Generator operators are converted (via the following _generator // function) into functions that can also take a list or array of rules // and return an array of new rules as though the function had been // called on each rule in turn (which is what actually happens). // This allows generators to be used with vector operators more easily. // Example: // each(ignore(foo, bar)) instead of each(ignore(foo), ignore(bar)) // This also turns generators into vector operators, which allows // constructs like: // not(cache(foo, bar)) var _generator = function (op) { function gen() { var args = null, rx = [], px, i; if (arguments.length > 1) { args = Array.prototype.slice.call(arguments); } else if (arguments[0] instanceof Array) { args = arguments[0]; } if (args) { px = args.shift(); if (px.length > 0) { args.unshift(px[i]); rx.push(op.apply(null, args)); args.shift(); return rx; } } else { return op.apply(null, arguments); } } return gen; }; var gx = "optional not ignore cache".split(/\s/); for (var i = 0 ; i < gx.length ; i++) { _[gx[i]] = _generator(_[gx[i]]); } var _vector = function (op) { return function () { if (arguments[0] instanceof Array) { return op.apply(null, arguments[0]); } else { return op.apply(null, arguments); } }; }; var vx = "each any all".split(/\s/); for (var j = 0 ; j < vx.length ; j++) { _[vx[j]] = _vector(_[vx[j]]); } }()); (function () { var $D = Date; var flattenAndCompact = function (ax) { var rx = []; for (var i = 0; i < ax.length; i++) { if (ax[i] instanceof Array) { rx = rx.concat(flattenAndCompact(ax[i])); } else { if (ax[i]) { rx.push(ax[i]); } } } return rx; }; var parseMeridian = function () { if (this.meridian && (this.hour || this.hour === 0)) { if (this.meridian === "a" && this.hour > 11 && Date.Config.strict24hr){ throw "Invalid hour and meridian combination"; } else if (this.meridian === "p" && this.hour < 12 && Date.Config.strict24hr){ throw "Invalid hour and meridian combination"; } else if (this.meridian === "p" && this.hour < 12) { this.hour = this.hour + 12; } else if (this.meridian === "a" && this.hour === 12) { this.hour = 0; } } }; var setDefaults = function () { var now = new Date(); if ((this.hour || this.minute) && (!this.month && !this.year && !this.day)) { this.day = now.getDate(); } if (!this.year) { this.year = now.getFullYear(); } if (!this.month && this.month !== 0) { this.month = now.getMonth(); } if (!this.day) { this.day = 1; } if (!this.hour) { this.hour = 0; } if (!this.minute) { this.minute = 0; } if (!this.second) { this.second = 0; } if (!this.millisecond) { this.millisecond = 0; } }; var finishUtils = { getToday: function () { if (this.now || "hour minute second".indexOf(this.unit) !== -1) { return new Date(); } else { return $D.today(); } }, setDaysFromWeekday: function (today, orient){ var gap; orient = orient || 1; this.unit = "day"; gap = ($D.getDayNumberFromName(this.weekday) - today.getDay()); this.days = gap ? ((gap + (orient * 7)) % 7) : (orient * 7); return this; }, setMonthsFromMonth: function (today, orient) { var gap; orient = orient || 1; this.unit = "month"; gap = (this.month - today.getMonth()); this.months = gap ? ((gap + (orient * 12)) % 12) : (orient * 12); this.month = null; return this; }, setDMYFromWeekday: function () { var d = Date[this.weekday](); this.day = d.getDate(); if (!this.month) { this.month = d.getMonth(); } this.year = d.getFullYear(); return this; }, setUnitValue: function (orient) { if (!this.value && this.operator && this.operator !== null && this[this.unit + "s"] && this[this.unit + "s"] !== null) { this[this.unit + "s"] = this[this.unit + "s"] + ((this.operator === "add") ? 1 : -1) + (this.value||0) * orient; } else if (this[this.unit + "s"] == null || this.operator != null) { if (!this.value) { this.value = 1; } this[this.unit + "s"] = this.value * orient; } }, generateDateFromWeeks: function () { var weekday = (this.weekday !== undefined) ? this.weekday : "today"; var d = Date[weekday]().addWeeks(this.weeks); if (this.now) { d.setTimeToNow(); } return d; } }; $D.Translator = { hour: function (s) { return function () { this.hour = Number(s); }; }, minute: function (s) { return function () { this.minute = Number(s); }; }, second: function (s) { return function () { this.second = Number(s); }; }, /* for ss.s format */ secondAndMillisecond: function (s) { return function () { var mx = s.match(/^([0-5][0-9])\.([0-9]{1,3})/); this.second = Number(mx[1]); this.millisecond = Number(mx[2]); }; }, meridian: function (s) { return function () { this.meridian = s.slice(0, 1).toLowerCase(); }; }, timezone: function (s) { return function () { var n = s.replace(/[^\d\+\-]/g, ""); if (n.length) { this.timezoneOffset = Number(n); } else { this.timezone = s.toLowerCase(); } }; }, day: function (x) { var s = x[0]; return function () { this.day = Number(s.match(/\d+/)[0]); if (this.day < 1) { throw "invalid day"; } }; }, month: function (s) { return function () { this.month = (s.length === 3) ? "jan feb mar apr may jun jul aug sep oct nov dec".indexOf(s)/4 : Number(s) - 1; if (this.month < 0) { throw "invalid month"; } }; }, year: function (s) { return function () { var n = Number(s); this.year = ((s.length > 2) ? n : (n + (((n + 2000) < Date.CultureInfo.twoDigitYearMax) ? 2000 : 1900))); }; }, rday: function (s) { return function () { switch (s) { case "yesterday": this.days = -1; break; case "tomorrow": this.days = 1; break; case "today": this.days = 0; break; case "now": this.days = 0; this.now = true; break; } }; }, finishExact: function (x) { var d; x = (x instanceof Array) ? x : [x]; for (var i = 0 ; i < x.length ; i++) { if (x[i]) { x[i].call(this); } } setDefaults.call(this); parseMeridian.call(this); if (this.day > $D.getDaysInMonth(this.year, this.month)) { throw new RangeError(this.day + " is not a valid value for days."); } d = new Date(this.year, this.month, this.day, this.hour, this.minute, this.second, this.millisecond); if (this.year < 100) { d.setFullYear(this.year); // means years less that 100 are process correctly. JS will parse it otherwise as 1900-1999. } if (this.timezone) { d.set({ timezone: this.timezone }); } else if (this.timezoneOffset) { d.set({ timezoneOffset: this.timezoneOffset }); } return d; }, finish: function (x) { var today, expression, orient, temp; x = (x instanceof Array) ? flattenAndCompact(x) : [ x ]; if (x.length === 0) { return null; } for (var i = 0 ; i < x.length ; i++) { if (typeof x[i] === "function") { x[i].call(this); } } if (this.now && !this.unit && !this.operator) { return new Date(); } else { today = finishUtils.getToday.call(this); } expression = !!(this.days && this.days !== null || this.orient || this.operator); orient = ((this.orient === "past" || this.operator === "subtract") ? -1 : 1); if (this.month && this.unit === "week") { this.value = this.month + 1; delete this.month; delete this.day; } if ((this.month || this.month === 0) && "year day hour minute second".indexOf(this.unit) !== -1) { if (!this.value) { this.value = this.month + 1; } this.month = null; expression = true; } if (!expression && this.weekday && !this.day && !this.days) { finishUtils.setDMYFromWeekday.call(this); } if (expression && this.weekday && this.unit !== "month" && this.unit !== "week") { finishUtils.setDaysFromWeekday.call(this, today, orient); } if (this.weekday && this.unit !== "week" && !this.day && !this.days) { temp = Date[this.weekday](); this.day = temp.getDate(); if (temp.getMonth() !== today.getMonth()) { this.month = temp.getMonth(); } } if (this.month && this.unit === "day" && this.operator) { if (!this.value) { this.value = (this.month + 1); } this.month = null; } if (this.value != null && this.month != null && this.year != null) { this.day = this.value * 1; } if (this.month && !this.day && this.value) { today.set({ day: this.value * 1 }); if (!expression) { this.day = this.value * 1; } } if (!this.month && this.value && this.unit === "month" && !this.now) { this.month = this.value; expression = true; } if (expression && (this.month || this.month === 0) && this.unit !== "year") { finishUtils.setMonthsFromMonth.call(this, today, orient); } if (!this.unit) { this.unit = "day"; } finishUtils.setUnitValue.call(this, orient); parseMeridian.call(this); if ((this.month || this.month === 0) && !this.day) { this.day = 1; } if (!this.orient && !this.operator && this.unit === "week" && this.value && !this.day && !this.month) { return Date.today().setWeek(this.value); } if (this.unit === "week" && this.weeks && !this.day && !this.month) { return finishUtils.generateDateFromWeeks.call(this); } if (expression && this.timezone && this.day && this.days) { this.day = this.days; } if (expression){ today.add(this); } else { today.set(this); } if (this.timezone) { this.timezone = this.timezone.toUpperCase(); var offset = $D.getTimezoneOffset(this.timezone); var timezone; if (today.hasDaylightSavingTime()) { // lets check that we're being sane with timezone setting timezone = $D.getTimezoneAbbreviation(offset, today.isDaylightSavingTime()); if (timezone !== this.timezone) { // bugger, we're in a place where things like EST vs EDT matters. if (today.isDaylightSavingTime()) { today.addHours(-1); } else { today.addHours(1); } } } today.setTimezoneOffset(offset); } return today; } }; }()); (function () { var $D = Date; $D.Grammar = {}; var _ = $D.Parsing.Operators, g = $D.Grammar, t = $D.Translator, _fn; // Allow rolling up into general purpose rules _fn = function () { return _.each(_.any.apply(null, arguments), _.not(g.ctoken2("timeContext"))); }; g.datePartDelimiter = _.rtoken(/^([\s\-\.\,\/\x27]+)/); g.timePartDelimiter = _.stoken(":"); g.whiteSpace = _.rtoken(/^\s*/); g.generalDelimiter = _.rtoken(/^(([\s\,]|at|@|on)+)/); var _C = {}; g.ctoken = function (keys) { var fn = _C[keys]; if (! fn) { var c = Date.CultureInfo.regexPatterns; var kx = keys.split(/\s+/), px = []; for (var i = 0; i < kx.length ; i++) { px.push(_.replace(_.rtoken(c[kx[i]]), kx[i])); } fn = _C[keys] = _.any.apply(null, px); } return fn; }; g.ctoken2 = function (key) { return _.rtoken(Date.CultureInfo.regexPatterns[key]); }; var cacheProcessRtoken = function (key, token, type, eachToken) { if (eachToken) { g[key] = _.cache(_.process(_.each(_.rtoken(token),_.optional(g.ctoken2(eachToken))), type)); } else { g[key] = _.cache(_.process(_.rtoken(token), type)); } }; var cacheProcessCtoken = function (token, type) { return _.cache(_.process(g.ctoken2(token), type)); }; var _F = {}; //function cache var _get = function (f) { _F[f] = (_F[f] || g.format(f)[0]); return _F[f]; }; g.allformats = function (fx) { var rx = []; if (fx instanceof Array) { for (var i = 0; i < fx.length; i++) { rx.push(_get(fx[i])); } } else { rx.push(_get(fx)); } return rx; }; g.formats = function (fx) { if (fx instanceof Array) { var rx = []; for (var i = 0 ; i < fx.length ; i++) { rx.push(_get(fx[i])); } return _.any.apply(null, rx); } else { return _get(fx); } }; var grammarFormats = { timeFormats: function(){ var i, RTokenKeys = [ "h", "hh", "H", "HH", "m", "mm", "s", "ss", "ss.s", "z", "zz" ], RToken = [ /^(0[0-9]|1[0-2]|[1-9])/, /^(0[0-9]|1[0-2])/, /^([0-1][0-9]|2[0-3]|[0-9])/, /^([0-1][0-9]|2[0-3])/, /^([0-5][0-9]|[0-9])/, /^[0-5][0-9]/, /^([0-5][0-9]|[0-9])/, /^[0-5][0-9]/, /^[0-5][0-9]\.[0-9]{1,3}/, /^((\+|\-)\s*\d\d\d\d)|((\+|\-)\d\d\:?\d\d)/, /^((\+|\-)\s*\d\d\d\d)|((\+|\-)\d\d\:?\d\d)/ ], tokens = [ t.hour, t.hour, t.hour, t.hour, t.minute, t.minute, t.second, t.second, t.secondAndMillisecond, t.timezone, t.timezone ]; for (i=0; i < RTokenKeys.length; i++) { cacheProcessRtoken(RTokenKeys[i], RToken[i], tokens[i]); } g.hms = _.cache(_.sequence([g.H, g.m, g.s], g.timePartDelimiter)); g.t = cacheProcessCtoken("shortMeridian", t.meridian); g.tt = cacheProcessCtoken("longMeridian", t.meridian); g.zzz = cacheProcessCtoken("timezone", t.timezone); g.timeSuffix = _.each(_.ignore(g.whiteSpace), _.set([ g.tt, g.zzz ])); g.time = _.each(_.optional(_.ignore(_.stoken("T"))), g.hms, g.timeSuffix); }, dateFormats: function () { // pre-loaded rules for different date part order preferences var _setfn = function () { return _.set(arguments, g.datePartDelimiter); }; var i, RTokenKeys = [ "d", "dd", "M", "MM", "y", "yy", "yyy", "yyyy" ], RToken = [ /^([0-2]\d|3[0-1]|\d)/, /^([0-2]\d|3[0-1])/, /^(1[0-2]|0\d|\d)/, /^(1[0-2]|0\d)/, /^(\d+)/, /^(\d\d)/, /^(\d\d?\d?\d?)/, /^(\d\d\d\d)/ ], tokens = [ t.day, t.day, t.month, t.month, t.year, t.year, t.year, t.year ], eachToken = [ "ordinalSuffix", "ordinalSuffix" ]; for (i=0; i < RTokenKeys.length; i++) { cacheProcessRtoken(RTokenKeys[i], RToken[i], tokens[i], eachToken[i]); } g.MMM = g.MMMM = _.cache(_.process(g.ctoken("jan feb mar apr may jun jul aug sep oct nov dec"), t.month)); g.ddd = g.dddd = _.cache(_.process(g.ctoken("sun mon tue wed thu fri sat"), function (s) { return function () { this.weekday = s; }; } )); g.day = _fn(g.d, g.dd); g.month = _fn(g.M, g.MMM); g.year = _fn(g.yyyy, g.yy); g.mdy = _setfn(g.ddd, g.month, g.day, g.year); g.ymd = _setfn(g.ddd, g.year, g.month, g.day); g.dmy = _setfn(g.ddd, g.day, g.month, g.year); g.date = function (s) { return ((g[Date.CultureInfo.dateElementOrder] || g.mdy).call(this, s)); }; }, relative: function () { // relative date / time expressions g.orientation = _.process(g.ctoken("past future"), function (s) { return function () { this.orient = s; }; } ); g.operator = _.process(g.ctoken("add subtract"), function (s) { return function () { this.operator = s; }; } ); g.rday = _.process(g.ctoken("yesterday tomorrow today now"), t.rday); g.unit = _.process(g.ctoken("second minute hour day week month year"), function (s) { return function () { this.unit = s; }; } ); } }; g.buildGrammarFormats = function () { // these need to be rebuilt every time the language changes. _C = {}; grammarFormats.timeFormats(); grammarFormats.dateFormats(); grammarFormats.relative(); g.value = _.process(_.rtoken(/^([-+]?\d+)?(st|nd|rd|th)?/), function (s) { return function () { this.value = s.replace(/\D/g, ""); }; } ); g.expression = _.set([g.rday, g.operator, g.value, g.unit, g.orientation, g.ddd, g.MMM ]); g.format = _.process(_.many( _.any( // translate format specifiers into grammar rules _.process( _.rtoken(/^(dd?d?d?(?!e)|MM?M?M?|yy?y?y?|hh?|HH?|mm?|ss?|tt?|zz?z?)/), function (fmt) { if (g[fmt]) { return g[fmt]; } else { throw $D.Parsing.Exception(fmt); } } ), // translate separator tokens into token rules _.process(_.rtoken(/^[^dMyhHmstz]+/), // all legal separators function (s) { return _.ignore(_.stoken(s)); } ) ) ), // construct the parser ... function (rules) { return _.process(_.each.apply(null, rules), t.finishExact); } ); // starting rule for general purpose grammar g._start = _.process(_.set([ g.date, g.time, g.expression ], g.generalDelimiter, g.whiteSpace), t.finish); }; g.buildGrammarFormats(); // parsing date format specifiers - ex: "h:m:s tt" // this little guy will generate a custom parser based // on the format string, ex: g.format("h:m:s tt") // check for these formats first g._formats = g.formats([ "\"yyyy-MM-ddTHH:mm:ssZ\"", "yyyy-MM-ddTHH:mm:ss.sz", "yyyy-MM-ddTHH:mm:ssZ", "yyyy-MM-ddTHH:mm:ssz", "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-ddTHH:mmZ", "yyyy-MM-ddTHH:mmz", "yyyy-MM-ddTHH:mm", "ddd, MMM dd, yyyy H:mm:ss tt", "ddd MMM d yyyy HH:mm:ss zzz", "MMddyyyy", "ddMMyyyy", "Mddyyyy", "ddMyyyy", "Mdyyyy", "dMyyyy", "yyyy", "Mdyy", "dMyy", "d" ]); // real starting rule: tries selected formats first, // then general purpose rule g.start = function (s) { try { var r = g._formats.call({}, s); if (r[1].length === 0) { return r; } } catch (e) {} return g._start.call({}, s); }; }()); (function () { var $D = Date; /** * @desc Converts the specified string value into its JavaScript Date equivalent using CultureInfo specific format information. * * Example

	///////////
	// Dates //
	///////////

	// 15-Oct-2004
	var d1 = Date.parse("10/15/2004");

	// 15-Oct-2004
	var d1 = Date.parse("15-Oct-2004");

	// 15-Oct-2004
	var d1 = Date.parse("2004.10.15");

	//Fri Oct 15, 2004
	var d1 = Date.parse("Fri Oct 15, 2004");

	///////////
	// Times //
	///////////

	// Today at 10 PM.
	var d1 = Date.parse("10 PM");

	// Today at 10:30 PM.
	var d1 = Date.parse("10:30 P.M.");

	// Today at 6 AM.
	var d1 = Date.parse("06am");

	/////////////////////
	// Dates and Times //
	/////////////////////

	// 8-July-2004 @ 10:30 PM
	var d1 = Date.parse("July 8th, 2004, 10:30 PM");

	// 1-July-2004 @ 10:30 PM
	var d1 = Date.parse("2004-07-01T22:30:00");

	////////////////////
	// Relative Dates //
	////////////////////

	// Returns today's date. The string "today" is culture specific.
	var d1 = Date.parse("today");

	// Returns yesterday's date. The string "yesterday" is culture specific.
	var d1 = Date.parse("yesterday");

	// Returns the date of the next thursday.
	var d1 = Date.parse("Next thursday");

	// Returns the date of the most previous monday.
	var d1 = Date.parse("last monday");

	// Returns today's day + one year.
	var d1 = Date.parse("next year");

	///////////////
	// Date Math //
	///////////////

	// Today + 2 days
	var d1 = Date.parse("t+2");

	// Today + 2 days
	var d1 = Date.parse("today + 2 days");

	// Today + 3 months
	var d1 = Date.parse("t+3m");

	// Today - 1 year
	var d1 = Date.parse("today - 1 year");

	// Today - 1 year
	var d1 = Date.parse("t-1y"); 


	/////////////////////////////
	// Partial Dates and Times //
	/////////////////////////////

	// July 15th of this year.
	var d1 = Date.parse("July 15");

	// 15th day of current day and year.
	var d1 = Date.parse("15");

	// July 1st of current year at 10pm.
	var d1 = Date.parse("7/1 10pm");
	
* * @param {String} The string value to convert into a Date object [Required] * @return {Date} A Date object or null if the string cannot be converted into a Date. */ var parseUtils = { removeOrds: function (s) { ords = s.match(/\b(\d+)(?:st|nd|rd|th)\b/); // find ordinal matches s = ((ords && ords.length === 2) ? s.replace(ords[0], ords[1]) : s); return s; }, grammarParser: function (s) { var r = null; try { r = $D.Grammar.start.call({}, s.replace(/^\s*(\S*(\s+\S+)*)\s*$/, "$1")); } catch (e) { return null; } return ((r[1].length === 0) ? r[0] : null); }, nativeFallback: function(s) { var t; try { // ok we haven't parsed it, last ditch attempt with the built-in parser. t = Date._parse(s); return (t || t === 0) ? new Date(t) : null; } catch (e) { return null; } } }; function parse (s) { var d; if (!s) { return null; } if (s instanceof Date) { return s.clone(); } if (s.length >= 4 && s.charAt(0) !== "0" && s.charAt(0) !== "+"&& s.charAt(0) !== "-") { // ie: 2004 will pass, 0800 won't. // Start with specific formats d = $D.Parsing.ISO.parse(s) || $D.Parsing.Numeric.parse(s); } if (d instanceof Date && !isNaN(d.getTime())) { return d; } else { // find ordinal dates (1st, 3rd, 8th, etc and remove them as they cause parsing issues) s = $D.Parsing.Normalizer.parse(parseUtils.removeOrds(s)); d = parseUtils.grammarParser(s); if (d !== null) { return d; } else { return parseUtils.nativeFallback(s); } } } if (!$D._parse) { $D._parse = $D.parse; } $D.parse = parse; Date.getParseFunction = function (fx) { var fns = Date.Grammar.allformats(fx); return function (s) { var r = null; for (var i = 0; i < fns.length; i++) { try { r = fns[i].call({}, s); } catch (e) { continue; } if (r[1].length === 0) { return r[0]; } } return null; }; }; /** * Converts the specified string value into its JavaScript Date equivalent using the specified format {String} or formats {Array} and the CultureInfo specific format information. * The format of the string value must match one of the supplied formats exactly. * * Example

	// 15-Oct-2004
	var d1 = Date.parseExact("10/15/2004", "M/d/yyyy");

	// 15-Oct-2004
	var d1 = Date.parse("15-Oct-2004", "M-ddd-yyyy");

	// 15-Oct-2004
	var d1 = Date.parse("2004.10.15", "yyyy.MM.dd");

	// Multiple formats
	var d1 = Date.parseExact("10/15/2004", ["M/d/yyyy", "MMMM d, yyyy"]);
	
* * @param {String} The string value to convert into a Date object [Required]. * @param {Object} The expected format {String} or an array of expected formats {Array} of the date string [Required]. * @return {Date} A Date object or null if the string cannot be converted into a Date. */ $D.parseExact = function (s, fx) { return $D.getParseFunction(fx)(s); }; }()); (function () { var $D = Date, $P = $D.prototype, // $C = $D.CultureInfo, // not used atm p = function (s, l) { if (!l) { l = 2; } return ("000" + s).slice(l * -1); }; /** * Converts a PHP format string to Java/.NET format string. * A PHP format string can be used with ._format or .format. * A Java/.NET format string can be used with .toString(). * The .parseExact function will only accept a Java/.NET format string * * Example * var f1 = "%m/%d/%y" * var f2 = Date.normalizeFormat(f1); // "MM/dd/yy" * * new Date().format(f1); // "04/13/08" * new Date()._format(f1); // "04/13/08" * new Date().toString(f2); // "04/13/08" * * var date = Date.parseExact("04/13/08", f2); // Sun Apr 13 2008 * * @param {String} A PHP format string consisting of one or more format spcifiers. * @return {String} The PHP format converted to a Java/.NET format string. */ var normalizerSubstitutions = { "d" : "dd", "%d": "dd", "D" : "ddd", "%a": "ddd", "j" : "dddd", "l" : "dddd", "%A": "dddd", "S" : "S", "F" : "MMMM", "%B": "MMMM", "m" : "MM", "%m": "MM", "M" : "MMM", "%b": "MMM", "%h": "MMM", "n" : "M", "Y" : "yyyy", "%Y": "yyyy", "y" : "yy", "%y": "yy", "g" : "h", "%I": "h", "G" : "H", "h" : "hh", "H" : "HH", "%H": "HH", "i" : "mm", "%M": "mm", "s" : "ss", "%S": "ss", "%r": "hh:mm tt", "%R": "H:mm", "%T": "H:mm:ss", "%X": "t", "%x": "d", "%e": "d", "%D": "MM/dd/yy", "%n": "\\n", "%t": "\\t", "e" : "z", "T" : "z", "%z": "z", "%Z": "z", "Z" : "ZZ", "N" : "u", "w" : "u", "%w": "u", "W" : "W", "%V": "W" }; var normalizer = { substitutes: function (m) { return normalizerSubstitutions[m]; }, interpreted: function (m, x) { var y; switch (m) { case "%u": return x.getDay() + 1; case "z": return x.getOrdinalNumber(); case "%j": return p(x.getOrdinalNumber(), 3); case "%U": var d1 = x.clone().set({month: 0, day: 1}).addDays(-1).moveToDayOfWeek(0), d2 = x.clone().addDays(1).moveToDayOfWeek(0, -1); return (d2 < d1) ? "00" : p((d2.getOrdinalNumber() - d1.getOrdinalNumber()) / 7 + 1); case "%W": return p(x.getWeek()); case "t": return $D.getDaysInMonth(x.getFullYear(), x.getMonth()); case "o": case "%G": return x.setWeek(x.getISOWeek()).toString("yyyy"); case "%g": return x._format("%G").slice(-2); case "a": case "%p": return t("tt").toLowerCase(); case "A": return t("tt").toUpperCase(); case "u": return p(x.getMilliseconds(), 3); case "I": return (x.isDaylightSavingTime()) ? 1 : 0; case "O": return x.getUTCOffset(); case "P": y = x.getUTCOffset(); return y.substring(0, y.length - 2) + ":" + y.substring(y.length - 2); case "B": var now = new Date(); return Math.floor(((now.getHours() * 3600) + (now.getMinutes() * 60) + now.getSeconds() + (now.getTimezoneOffset() + 60) * 60) / 86.4); case "c": return x.toISOString().replace(/\"/g, ""); case "U": return $D.strtotime("now"); case "%c": return t("d") + " " + t("t"); case "%C": return Math.floor(x.getFullYear() / 100 + 1); } }, shouldOverrideDefaults: function (m) { switch (m) { case "%e": return true; default: return false; } }, parse: function (m, context) { var formatString, c = context || new Date(); formatString = normalizer.substitutes(m); if (formatString) { return formatString; } formatString = normalizer.interpreted(m, c); if (formatString) { return formatString; } else { return m; } } }; $D.normalizeFormat = function (format, context) { return format.replace(/(%|\\)?.|%%/g, function(t){ return normalizer.parse(t, context); }); }; /** * Format a local Unix timestamp according to locale settings * * Example: * Date.strftime("%m/%d/%y", new Date()); // "04/13/08" * Date.strftime("c", "2008-04-13T17:52:03Z"); // "04/13/08" * * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @param {Number|String} The number representing the number of seconds that have elapsed since January 1, 1970 (local time). * @return {String} A string representation of the current Date object. */ $D.strftime = function (format, time) { var d = Date.parse(time); return d._format(format); }; /** * Parse any textual datetime description into a Unix timestamp. * A Unix timestamp is the number of seconds that have elapsed since January 1, 1970 (midnight UTC/GMT). * * Example: * Date.strtotime("04/13/08"); // 1208044800 * Date.strtotime("1970-01-01T00:00:00Z"); // 0 * * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @param {Object} A string or date object. * @return {String} A string representation of the current Date object. */ $D.strtotime = function (time) { var d = $D.parse(time); return Math.round($D.UTC(d.getUTCFullYear(), d.getUTCMonth(), d.getUTCDate(), d.getUTCHours(), d.getUTCMinutes(), d.getUTCSeconds(), d.getUTCMilliseconds()) / 1000); }; /** * Converts the value of the current Date object to its equivalent string representation using a PHP/Unix style of date format specifiers. * Format Specifiers * Format Description Example * ------ --------------------------------------------------------------------------- ----------------------- * %a abbreviated weekday name according to the current localed "Mon" through "Sun" * %A full weekday name according to the current localed "Sunday" through "Saturday" * %b abbreviated month name according to the current localed "Jan" through "Dec" * %B full month name according to the current locale "January" through "December" * %c preferred date and time representation for the current locale "4/13/2008 12:33 PM" * %C century number (the year divided by 100 and truncated to an integer) "00" to "99" * %d day of the month as a decimal number "01" to "31" * %D same as %m/%d/%y "04/13/08" * %e day of the month as a decimal number, a single digit is preceded by a space "1" to "31" * %g like %G, but without the century "08" * %G The 4-digit year corresponding to the ISO week number (see %V). "2008" * This has the same format and value as %Y, except that if the ISO week number * belongs to the previous or next year, that year is used instead. * %h same as %b "Jan" through "Dec" * %H hour as a decimal number using a 24-hour clock. "00" to "23" * %I hour as a decimal number using a 12-hour clock. "01" to "12" * %j day of the year as a decimal number. "001" to "366" * %m month as a decimal number. "01" to "12" * %M minute as a decimal number. "00" to "59" * %n newline character "\n" * %p either "am" or "pm" according to the given time value, or the "am" or "pm" * corresponding strings for the current locale. * %r time in a.m. and p.m. notation "8:44 PM" * %R time in 24 hour notation "20:44" * %S second as a decimal number "00" to "59" * %t tab character "\t" * %T current time, equal to %H:%M:%S "12:49:11" * %u weekday as a decimal number ["1", "7"], with "1" representing Monday "1" to "7" * %U week number of the current year as a decimal number, starting with the "0" to ("52" or "53") * first Sunday as the first day of the first week * %V The ISO 8601:1988 week number of the current year as a decimal number, "00" to ("52" or "53") * range 01 to 53, where week 1 is the first week that has at least 4 days * in the current year, and with Monday as the first day of the week. * (Use %G or %g for the year component that corresponds to the week number * for the specified timestamp.) * %W week number of the current year as a decimal number, starting with the "00" to ("52" or "53") * first Monday as the first day of the first week * %w day of the week as a decimal, Sunday being "0" "0" to "6" * %x preferred date representation for the current locale without the time "4/13/2008" * %X preferred time representation for the current locale without the date "12:53:05" * %y year as a decimal number without a century "00" "99" * %Y year as a decimal number including the century "2008" * %Z time zone or name or abbreviation "UTC", "EST", "PST" * %z same as %Z * %% a literal "%" characters "%" * d Day of the month, 2 digits with leading zeros "01" to "31" * D A textual representation of a day, three letters "Mon" through "Sun" * j Day of the month without leading zeros "1" to "31" * l A full textual representation of the day of the week (lowercase "L") "Sunday" through "Saturday" * N ISO-8601 numeric representation of the day of the week (added in PHP 5.1.0) "1" (for Monday) through "7" (for Sunday) * S English ordinal suffix for the day of the month, 2 characters "st", "nd", "rd" or "th". Works well with j * w Numeric representation of the day of the week "0" (for Sunday) through "6" (for Saturday) * z The day of the year (starting from "0") "0" through "365" * W ISO-8601 week number of year, weeks starting on Monday "00" to ("52" or "53") * F A full textual representation of a month, such as January or March "January" through "December" * m Numeric representation of a month, with leading zeros "01" through "12" * M A short textual representation of a month, three letters "Jan" through "Dec" * n Numeric representation of a month, without leading zeros "1" through "12" * t Number of days in the given month "28" through "31" * L Whether it's a leap year "1" if it is a leap year, "0" otherwise * o ISO-8601 year number. This has the same value as Y, except that if the "2008" * ISO week number (W) belongs to the previous or next year, that year * is used instead. * Y A full numeric representation of a year, 4 digits "2008" * y A two digit representation of a year "08" * a Lowercase Ante meridiem and Post meridiem "am" or "pm" * A Uppercase Ante meridiem and Post meridiem "AM" or "PM" * B Swatch Internet time "000" through "999" * g 12-hour format of an hour without leading zeros "1" through "12" * G 24-hour format of an hour without leading zeros "0" through "23" * h 12-hour format of an hour with leading zeros "01" through "12" * H 24-hour format of an hour with leading zeros "00" through "23" * i Minutes with leading zeros "00" to "59" * s Seconds, with leading zeros "00" through "59" * u Milliseconds "54321" * e Timezone identifier "UTC", "EST", "PST" * I Whether or not the date is in daylight saving time (uppercase i) "1" if Daylight Saving Time, "0" otherwise * O Difference to Greenwich time (GMT) in hours "+0200", "-0600" * P Difference to Greenwich time (GMT) with colon between hours and minutes "+02:00", "-06:00" * T Timezone abbreviation "UTC", "EST", "PST" * Z Timezone offset in seconds. The offset for timezones west of UTC is "-43200" through "50400" * always negative, and for those east of UTC is always positive. * c ISO 8601 date "2004-02-12T15:19:21+00:00" * r RFC 2822 formatted date "Thu, 21 Dec 2000 16:01:07 +0200" * U Seconds since the Unix Epoch (January 1 1970 00:00:00 GMT) "0" * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @return {String} A string representation of the current Date object. */ var formatReplace = function (context) { return function (m) { var formatString, override = false; if (m.charAt(0) === "\\" || m.substring(0, 2) === "%%") { return m.replace("\\", "").replace("%%", "%"); } override = normalizer.shouldOverrideDefaults(m); formatString = $D.normalizeFormat(m, context); if (formatString) { return context.toString(formatString, override); } }; }; $P._format = function (format) { var formatter = formatReplace(this); if (!format) { return this._toString(); } else { return format.replace(/(%|\\)?.|%%/g, formatter); } }; if (!$P.format) { $P.format = $P._format; } }()); (function () { "use strict"; var gFn = function (attr) { return function () { return this[attr]; }; }; var sFn = function (attr) { return function (val) { this[attr] = val; return this; }; }; var attrs = ["years", "months", "days", "hours", "minutes", "seconds", "milliseconds"]; var addSetFuncs = function (context, attrs) { for (var i = 0; i < attrs.length ; i++) { var $a = attrs[i], $b = $a.slice(0, 1).toUpperCase() + $a.slice(1); context.prototype[$a] = 0; context.prototype["get" + $b] = gFn($a); context.prototype["set" + $b] = sFn($a); } }; /** * new TimeSpan(milliseconds); * new TimeSpan(days, hours, minutes, seconds); * new TimeSpan(days, hours, minutes, seconds, milliseconds); */ var TimeSpan = function (days, hours, minutes, seconds, milliseconds) { if (arguments.length === 1 && typeof days === "number") { var orient = (days < 0) ? -1 : +1; var millsLeft = Math.abs(days); this.setDays(Math.floor(millsLeft / 86400000) * orient); millsLeft = millsLeft % 86400000; this.setHours(Math.floor(millsLeft / 3600000) * orient); millsLeft = millsLeft % 3600000; this.setMinutes(Math.floor(millsLeft / 60000) * orient); millsLeft = millsLeft % 60000; this.setSeconds(Math.floor(millsLeft / 1000) * orient); millsLeft = millsLeft % 1000; this.setMilliseconds(millsLeft * orient); } else { this.set(days, hours, minutes, seconds, milliseconds); } this.getTotalMilliseconds = function () { return (this.getDays() * 86400000) + (this.getHours() * 3600000) + (this.getMinutes() * 60000) + (this.getSeconds() * 1000); }; this.compareTo = function (time) { var t1 = new Date(1970, 1, 1, this.getHours(), this.getMinutes(), this.getSeconds()), t2; if (time === null) { t2 = new Date(1970, 1, 1, 0, 0, 0); } else { t2 = new Date(1970, 1, 1, time.getHours(), time.getMinutes(), time.getSeconds()); } return (t1 < t2) ? -1 : (t1 > t2) ? 1 : 0; }; this.equals = function (time) { return (this.compareTo(time) === 0); }; this.add = function (time) { return (time === null) ? this : this.addSeconds(time.getTotalMilliseconds() / 1000); }; this.subtract = function (time) { return (time === null) ? this : this.addSeconds(-time.getTotalMilliseconds() / 1000); }; this.addDays = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 86400000)); }; this.addHours = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 3600000)); }; this.addMinutes = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 60000)); }; this.addSeconds = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 1000)); }; this.addMilliseconds = function (n) { return new TimeSpan(this.getTotalMilliseconds() + n); }; this.get12HourHour = function () { return (this.getHours() > 12) ? this.getHours() - 12 : (this.getHours() === 0) ? 12 : this.getHours(); }; this.getDesignator = function () { return (this.getHours() < 12) ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator; }; this.toString = function (format) { this._toString = function () { if (this.getDays() !== null && this.getDays() > 0) { return this.getDays() + "." + this.getHours() + ":" + this.p(this.getMinutes()) + ":" + this.p(this.getSeconds()); } else { return this.getHours() + ":" + this.p(this.getMinutes()) + ":" + this.p(this.getSeconds()); } }; this.p = function (s) { return (s.toString().length < 2) ? "0" + s : s; }; var me = this; return format ? format.replace(/dd?|HH?|hh?|mm?|ss?|tt?/g, function (format) { switch (format) { case "d": return me.getDays(); case "dd": return me.p(me.getDays()); case "H": return me.getHours(); case "HH": return me.p(me.getHours()); case "h": return me.get12HourHour(); case "hh": return me.p(me.get12HourHour()); case "m": return me.getMinutes(); case "mm": return me.p(me.getMinutes()); case "s": return me.getSeconds(); case "ss": return me.p(me.getSeconds()); case "t": return ((me.getHours() < 12) ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator).substring(0, 1); case "tt": return (me.getHours() < 12) ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator; } } ) : this._toString(); }; return this; }; addSetFuncs(TimeSpan, attrs.slice(2)); TimeSpan.prototype.set = function (days, hours, minutes, seconds, milliseconds){ this.setDays(days || this.getDays()); this.setHours(hours || this.getHours()); this.setMinutes(minutes || this.getMinutes()); this.setSeconds(seconds || this.getSeconds()); this.setMilliseconds(milliseconds || this.getMilliseconds()); }; /** * Gets the time of day for this date instances. * @return {TimeSpan} TimeSpan */ Date.prototype.getTimeOfDay = function () { return new TimeSpan(0, this.getHours(), this.getMinutes(), this.getSeconds(), this.getMilliseconds()); }; Date.TimeSpan = TimeSpan; if (typeof window !== "undefined" ) { // keeping API compatible for v1.x window.TimeSpan = TimeSpan; } }()); (function () { "use strict"; var attrs = ["years", "months", "days", "hours", "minutes", "seconds", "milliseconds"]; var gFn = function (attr) { return function () { return this[attr]; }; }; var sFn = function (attr) { return function (val) { this[attr] = val; return this; }; }; var addSetFuncs = function (context, attrs) { for (var i = 0; i < attrs.length ; i++) { var $a = attrs[i], $b = $a.slice(0, 1).toUpperCase() + $a.slice(1); context.prototype[$a] = 0; context.prototype["get" + $b] = gFn($a); context.prototype["set" + $b] = sFn($a); } }; var setMonthsAndYears = function (orient, d1, d2, context) { function inc() { d1.addMonths(-orient); context.months++; if (context.months === 12) { context.years++; context.months = 0; } } if (orient === +1) { while (d1 > d2) { inc(); } } else { while (d1 < d2) { inc(); } } context.months--; context.months *= orient; context.years *= orient; }; var adjustForDST = function(orient, startDate, endDate) { var hasDSTMismatch = (false === (startDate.isDaylightSavingTime() === endDate.isDaylightSavingTime())); if (hasDSTMismatch && orient === 1) { startDate.addHours(-1); } else if (hasDSTMismatch) { startDate.addHours(1); } }; /** * TimePeriod(startDate, endDate); * TimePeriod(years, months, days, hours, minutes, seconds, milliseconds); */ var TimePeriod = function (years, months, days, hours, minutes, seconds, milliseconds) { if (arguments.length === 7) { this.set(years, months, days, hours, minutes, seconds, milliseconds); } else if (arguments.length === 2 && arguments[0] instanceof Date && arguments[1] instanceof Date) { var startDate = arguments[0].clone(); var endDate = arguments[1].clone(); var orient = (startDate > endDate) ? +1 : -1; this.dates = { start: arguments[0].clone(), end: arguments[1].clone() }; setMonthsAndYears(orient, startDate, endDate, this); adjustForDST(orient, startDate, endDate); // // TODO - adjust for DST var diff = endDate - startDate; if (diff !== 0) { var ts = new TimeSpan(diff); this.set(this.years, this.months, ts.getDays(), ts.getHours(), ts.getMinutes(), ts.getSeconds(), ts.getMilliseconds()); } } return this; }; // create all the set functions. addSetFuncs(TimePeriod, attrs); TimePeriod.prototype.set = function (years, months, days, hours, minutes, seconds, milliseconds){ this.setYears(years || this.getYears()); this.setMonths(months || this.getMonths()); this.setDays(days || this.getDays()); this.setHours(hours || this.getHours()); this.setMinutes(minutes || this.getMinutes()); this.setSeconds(seconds || this.getSeconds()); this.setMilliseconds(milliseconds || this.getMilliseconds()); }; Date.TimePeriod = TimePeriod; if (typeof window !== "undefined") { // keeping API compatible for v1.x window.TimePeriod = TimePeriod; } }()); ================================================ FILE: build/date-fr-CA.js ================================================ /** * @overview datejs * @version 1.0.0-rc3 * @author Gregory Wild-Smith * @copyright 2015 Gregory Wild-Smith * @license MIT * @homepage https://github.com/abritinthebay/datejs */ /* * DateJS Culture String File * Country Code: fr-CA * Name: French (Canada) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["fr-CA"] = { "name": "fr-CA", "englishName": "French (Canada)", "nativeName": "français (Canada)", "Sunday": "dimanche", "Monday": "lundi", "Tuesday": "mardi", "Wednesday": "mercredi", "Thursday": "jeudi", "Friday": "vendredi", "Saturday": "samedi", "Sun": "dim.", "Mon": "lun.", "Tue": "mar.", "Wed": "mer.", "Thu": "jeu.", "Fri": "ven.", "Sat": "sam.", "Su": "di", "Mo": "lu", "Tu": "ma", "We": "me", "Th": "je", "Fr": "ve", "Sa": "sa", "S_Sun_Initial": "d", "M_Mon_Initial": "l", "T_Tue_Initial": "m", "W_Wed_Initial": "m", "T_Thu_Initial": "j", "F_Fri_Initial": "v", "S_Sat_Initial": "s", "January": "janvier", "February": "février", "March": "mars", "April": "avril", "May": "mai", "June": "juin", "July": "juillet", "August": "août", "September": "septembre", "October": "octobre", "November": "novembre", "December": "décembre", "Jan_Abbr": "janv.", "Feb_Abbr": "févr.", "Mar_Abbr": "mars", "Apr_Abbr": "avr.", "May_Abbr": "mai", "Jun_Abbr": "juin", "Jul_Abbr": "juil.", "Aug_Abbr": "août", "Sep_Abbr": "sept.", "Oct_Abbr": "oct.", "Nov_Abbr": "nov.", "Dec_Abbr": "déc.", "AM": "", "PM": "", "firstDayOfWeek": 0, "twoDigitYearMax": 2029, "mdy": "ymd", "M/d/yyyy": "yyyy-MM-dd", "dddd, MMMM dd, yyyy": "d MMMM yyyy", "h:mm tt": "HH:mm", "h:mm:ss tt": "HH:mm:ss", "dddd, MMMM dd, yyyy h:mm:ss tt": "d MMMM yyyy HH:mm:ss", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "d MMMM", "MMMM, yyyy": "MMMM, yyyy", "/jan(uary)?/": "janv((ier)?)?", "/feb(ruary)?/": "févr((ier)?)?", "/mar(ch)?/": "mars", "/apr(il)?/": "avr((il)?)?", "/may/": "mai", "/jun(e)?/": "juin", "/jul(y)?/": "juil((let)?)?", "/aug(ust)?/": "août", "/sep(t(ember)?)?/": "sept((embre)?)?", "/oct(ober)?/": "oct((obre)?)?", "/nov(ember)?/": "nov((embre)?)?", "/dec(ember)?/": "déc((embre)?)?", "/^su(n(day)?)?/": "^di(m((anche)?)?)?", "/^mo(n(day)?)?/": "^lu(n((di)?)?)?", "/^tu(e(s(day)?)?)?/": "^ma(r((di)?)?)?", "/^we(d(nesday)?)?/": "^me(r((credi)?)?)?", "/^th(u(r(s(day)?)?)?)?/": "^je(u((di)?)?)?", "/^fr(i(day)?)?/": "^ve(n((dredi)?)?)?", "/^sa(t(urday)?)?/": "^sa(m((edi)?)?)?", "/^next/": "^prochain", "/^last|past|prev(ious)?/": "^dernier", "/^(\\+|aft(er)?|from|hence)/": "^précédant", "/^(\\-|bef(ore)?|ago)/": "^succédant", "/^yes(terday)?/": "^hier", "/^t(od(ay)?)?/": "^aujourd\'hui", "/^tom(orrow)?/": "^demain", "/^n(ow)?/": "^maintenant", "/^ms|milli(second)?s?/": "^ms|milli(seconde)?s?", "/^sec(ond)?s?/": "^sec(onde)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(eure)?s?", "/^w(eek)?s?/": "^sem(aine)?s?", "/^m(onth)?s?/": "^m(ois)?", "/^d(ay)?s?/": "^j(our)?s?", "/^y(ear)?s?/": "^a(nnée)?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "fr-CA"; /** * @overview datejs * @version 1.0.0-rc3 * @author Gregory Wild-Smith * @copyright 2015 Gregory Wild-Smith * @license MIT * @homepage https://github.com/abritinthebay/datejs */(function () { var $D = Date; var lang = Date.CultureStrings ? Date.CultureStrings.lang : null; var loggedKeys = {}; // for debug purposes. var getText = { getFromKey: function (key, countryCode) { var output; if (Date.CultureStrings && Date.CultureStrings[countryCode] && Date.CultureStrings[countryCode][key]) { output = Date.CultureStrings[countryCode][key]; } else { output = getText.buildFromDefault(key); } if (key.charAt(0) === "/") { // Assume it's a regex output = getText.buildFromRegex(key, countryCode); } return output; }, getFromObjectValues: function (obj, countryCode) { var key, output = {}; for(key in obj) { if (obj.hasOwnProperty(key)) { output[key] = getText.getFromKey(obj[key], countryCode); } } return output; }, getFromObjectKeys: function (obj, countryCode) { var key, output = {}; for(key in obj) { if (obj.hasOwnProperty(key)) { output[getText.getFromKey(key, countryCode)] = obj[key]; } } return output; }, getFromArray: function (arr, countryCode) { var output = []; for (var i=0; i < arr.length; i++){ if (i in arr) { output[i] = getText.getFromKey(arr[i], countryCode); } } return output; }, buildFromDefault: function (key) { var output, length, split, last; switch(key) { case "name": output = "en-US"; break; case "englishName": output = "English (United States)"; break; case "nativeName": output = "English (United States)"; break; case "twoDigitYearMax": output = 2049; break; case "firstDayOfWeek": output = 0; break; default: output = key; split = key.split("_"); length = split.length; if (length > 1 && key.charAt(0) !== "/") { // if the key isn't a regex and it has a split. last = split[(length - 1)].toLowerCase(); if (last === "initial" || last === "abbr") { output = split[0]; } } break; } return output; }, buildFromRegex: function (key, countryCode) { var output; if (Date.CultureStrings && Date.CultureStrings[countryCode] && Date.CultureStrings[countryCode][key]) { output = new RegExp(Date.CultureStrings[countryCode][key], "i"); } else { output = new RegExp(key.replace(new RegExp("/", "g"),""), "i"); } return output; } }; var shallowMerge = function (obj1, obj2) { for (var attrname in obj2) { if (obj2.hasOwnProperty(attrname)) { obj1[attrname] = obj2[attrname]; } } }; var __ = function (key, language) { var countryCode = (language) ? language : lang; loggedKeys[key] = key; if (typeof key === "object") { if (key instanceof Array) { return getText.getFromArray(key, countryCode); } else { return getText.getFromObjectKeys(key, countryCode); } } else { return getText.getFromKey(key, countryCode); } }; var loadI18nScript = function (code) { // paatterned after jQuery's getScript. var url = Date.Config.i18n + code + ".js"; var head = document.getElementsByTagName("head")[0] || document.documentElement; var script = document.createElement("script"); script.src = url; var completed = false; var events = { done: function (){} // placeholder function }; // Attach handlers for all browsers script.onload = script.onreadystatechange = function() { if ( !completed && (!this.readyState || this.readyState === "loaded" || this.readyState === "complete") ) { events.done(); head.removeChild(script); } }; setTimeout(function() { head.insertBefore(script, head.firstChild); }, 0); // allows return to execute first return { done: function (cb) { events.done = function() { if (cb) { setTimeout(cb,0); } }; } }; }; var buildInfo = { buildFromMethodHash: function (obj) { var key; for(key in obj) { if (obj.hasOwnProperty(key)) { obj[key] = buildInfo[obj[key]](); } } return obj; }, timeZoneDST: function () { var DST = { "CHADT": "+1345", "NZDT": "+1300", "AEDT": "+1100", "ACDT": "+1030", "AZST": "+0500", "IRDT": "+0430", "EEST": "+0300", "CEST": "+0200", "BST": "+0100", "PMDT": "-0200", "ADT": "-0300", "NDT": "-0230", "EDT": "-0400", "CDT": "-0500", "MDT": "-0600", "PDT": "-0700", "AKDT": "-0800", "HADT": "-0900" }; return __(DST); }, timeZoneStandard: function () { var standard = { "LINT": "+1400", "TOT": "+1300", "CHAST": "+1245", "NZST": "+1200", "NFT": "+1130", "SBT": "+1100", "AEST": "+1000", "ACST": "+0930", "JST": "+0900", "CWST": "+0845", "CT": "+0800", "ICT": "+0700", "MMT": "+0630", "BST": "+0600", "NPT": "+0545", "IST": "+0530", "PKT": "+0500", "AFT": "+0430", "MSK": "+0400", "IRST": "+0330", "FET": "+0300", "EET": "+0200", "CET": "+0100", "GMT": "+0000", "UTC": "+0000", "CVT": "-0100", "GST": "-0200", "BRT": "-0300", "NST": "-0330", "AST": "-0400", "EST": "-0500", "CST": "-0600", "MST": "-0700", "PST": "-0800", "AKST": "-0900", "MIT": "-0930", "HST": "-1000", "SST": "-1100", "BIT": "-1200" }; return __(standard); }, timeZones: function (data) { var zone; data.timezones = []; for (zone in data.abbreviatedTimeZoneStandard) { if (data.abbreviatedTimeZoneStandard.hasOwnProperty(zone)) { data.timezones.push({ name: zone, offset: data.abbreviatedTimeZoneStandard[zone]}); } } for (zone in data.abbreviatedTimeZoneDST) { if (data.abbreviatedTimeZoneDST.hasOwnProperty(zone)) { data.timezones.push({ name: zone, offset: data.abbreviatedTimeZoneDST[zone], dst: true}); } } return data.timezones; }, days: function () { return __(["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"]); }, dayAbbr: function () { return __(["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"]); }, dayShortNames: function () { return __(["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"]); }, dayFirstLetters: function () { return __(["S_Sun_Initial", "M_Mon_Initial", "T_Tues_Initial", "W_Wed_Initial", "T_Thu_Initial", "F_Fri_Initial", "S_Sat_Initial"]); }, months: function () { return __(["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"]); }, monthAbbr: function () { return __(["Jan_Abbr", "Feb_Abbr", "Mar_Abbr", "Apr_Abbr", "May_Abbr", "Jun_Abbr", "Jul_Abbr", "Aug_Abbr", "Sep_Abbr", "Oct_Abbr", "Nov_Abbr", "Dec_Abbr"]); }, formatPatterns: function () { return getText.getFromObjectValues({ shortDate: "M/d/yyyy", longDate: "dddd, MMMM dd, yyyy", shortTime: "h:mm tt", longTime: "h:mm:ss tt", fullDateTime: "dddd, MMMM dd, yyyy h:mm:ss tt", sortableDateTime: "yyyy-MM-ddTHH:mm:ss", universalSortableDateTime: "yyyy-MM-dd HH:mm:ssZ", rfc1123: "ddd, dd MMM yyyy HH:mm:ss", monthDay: "MMMM dd", yearMonth: "MMMM, yyyy" }, Date.i18n.currentLanguage()); }, regex: function () { return getText.getFromObjectValues({ inTheMorning: "/( in the )(morn(ing)?)\\b/", thisMorning: "/(this )(morn(ing)?)\\b/", amThisMorning: "/(\b\\d(am)? )(this )(morn(ing)?)/", inTheEvening: "/( in the )(even(ing)?)\\b/", thisEvening: "/(this )(even(ing)?)\\b/", pmThisEvening: "/(\b\\d(pm)? )(this )(even(ing)?)/", jan: "/jan(uary)?/", feb: "/feb(ruary)?/", mar: "/mar(ch)?/", apr: "/apr(il)?/", may: "/may/", jun: "/jun(e)?/", jul: "/jul(y)?/", aug: "/aug(ust)?/", sep: "/sep(t(ember)?)?/", oct: "/oct(ober)?/", nov: "/nov(ember)?/", dec: "/dec(ember)?/", sun: "/^su(n(day)?)?/", mon: "/^mo(n(day)?)?/", tue: "/^tu(e(s(day)?)?)?/", wed: "/^we(d(nesday)?)?/", thu: "/^th(u(r(s(day)?)?)?)?/", fri: "/fr(i(day)?)?/", sat: "/^sa(t(urday)?)?/", future: "/^next/", past: "/^last|past|prev(ious)?/", add: "/^(\\+|aft(er)?|from|hence)/", subtract: "/^(\\-|bef(ore)?|ago)/", yesterday: "/^yes(terday)?/", today: "/^t(od(ay)?)?/", tomorrow: "/^tom(orrow)?/", now: "/^n(ow)?/", millisecond: "/^ms|milli(second)?s?/", second: "/^sec(ond)?s?/", minute: "/^mn|min(ute)?s?/", hour: "/^h(our)?s?/", week: "/^w(eek)?s?/", month: "/^m(onth)?s?/", day: "/^d(ay)?s?/", year: "/^y(ear)?s?/", shortMeridian: "/^(a|p)/", longMeridian: "/^(a\\.?m?\\.?|p\\.?m?\\.?)/", timezone: "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/", ordinalSuffix: "/^\\s*(st|nd|rd|th)/", timeContext: "/^\\s*(\\:|a(?!u|p)|p)/" }, Date.i18n.currentLanguage()); } }; var CultureInfo = function () { var info = getText.getFromObjectValues({ name: "name", englishName: "englishName", nativeName: "nativeName", amDesignator: "AM", pmDesignator: "PM", firstDayOfWeek: "firstDayOfWeek", twoDigitYearMax: "twoDigitYearMax", dateElementOrder: "mdy" }, Date.i18n.currentLanguage()); var constructedInfo = buildInfo.buildFromMethodHash({ dayNames: "days", abbreviatedDayNames: "dayAbbr", shortestDayNames: "dayShortNames", firstLetterDayNames: "dayFirstLetters", monthNames: "months", abbreviatedMonthNames: "monthAbbr", formatPatterns: "formatPatterns", regexPatterns: "regex", abbreviatedTimeZoneDST: "timeZoneDST", abbreviatedTimeZoneStandard: "timeZoneStandard" }); shallowMerge(info, constructedInfo); buildInfo.timeZones(info); return info; }; $D.i18n = { __: function (key, lang) { return __(key, lang); }, currentLanguage: function () { return lang || "en-US"; }, setLanguage: function (code, force, cb) { var async = false; if (force || code === "en-US" || (!!Date.CultureStrings && !!Date.CultureStrings[code])) { lang = code; Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings.lang = code; Date.CultureInfo = new CultureInfo(); } else { if (!(!!Date.CultureStrings && !!Date.CultureStrings[code])) { if (typeof exports !== "undefined" && this.exports !== exports) { // we're in a Node enviroment, load it using require try { require("../i18n/" + code + ".js"); lang = code; Date.CultureStrings.lang = code; Date.CultureInfo = new CultureInfo(); } catch (e) { // var str = "The language for '" + code + "' could not be loaded by Node. It likely does not exist."; throw new Error("The DateJS IETF language tag '" + code + "' could not be loaded by Node. It likely does not exist."); } } else if (Date.Config && Date.Config.i18n) { // we know the location of the files, so lets load them async = true; loadI18nScript(code).done(function(){ lang = code; Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings.lang = code; Date.CultureInfo = new CultureInfo(); $D.Parsing.Normalizer.buildReplaceData(); // because this is async if ($D.Grammar) { $D.Grammar.buildGrammarFormats(); // so we can parse those strings... } if (cb) { setTimeout(cb,0); } }); } else { Date.console.error("The DateJS IETF language tag '" + code + "' is not available and has not been loaded."); return false; } } } $D.Parsing.Normalizer.buildReplaceData(); // rebuild normalizer strings if ($D.Grammar) { $D.Grammar.buildGrammarFormats(); // so we can parse those strings... } if (!async && cb) { setTimeout(cb,0); } }, getLoggedKeys: function () { return loggedKeys; }, updateCultureInfo: function () { Date.CultureInfo = new CultureInfo(); } }; $D.i18n.updateCultureInfo(); // run automatically }()); (function () { var $D = Date, $P = $D.prototype, p = function (s, l) { if (!l) { l = 2; } return ("000" + s).slice(l * -1); }; if (typeof window !== "undefined" && typeof window.console !== "undefined" && typeof window.console.log !== "undefined") { $D.console = console; // used only to raise non-critical errors if available } else { // set mock so we don't give errors. $D.console = { log: function(){}, error: function(){} }; } $D.Config = $D.Config || {}; $D.initOverloads = function() { /** * Overload of Date.now. Allows an alternate call for Date.now where it returns the * current Date as an object rather than just milliseconds since the Unix Epoch. * * Also provides an implementation of now() for browsers (IE<9) that don't have it. * * Backwards compatible so with work with either: * Date.now() [returns ms] * or * Date.now(true) [returns Date] */ if (!$D.now) { $D._now = function now() { return new Date().getTime(); }; } else if (!$D._now) { $D._now = $D.now; } $D.now = function (returnObj) { if (returnObj) { return $D.present(); } else { return $D._now(); } }; if ( !$P.toISOString ) { $P.toISOString = function() { return this.getUTCFullYear() + "-" + p(this.getUTCMonth() + 1) + "-" + p(this.getUTCDate()) + "T" + p(this.getUTCHours()) + ":" + p(this.getUTCMinutes()) + ":" + p(this.getUTCSeconds()) + "." + String( (this.getUTCMilliseconds()/1000).toFixed(3)).slice(2, 5) + "Z"; }; } // private if ( $P._toString === undefined ){ $P._toString = $P.toString; } }; $D.initOverloads(); /** * Gets a date that is set to the current date. The time is set to the start of the day (00:00 or 12:00 AM). * @return {Date} The current date. */ $D.today = function () { return new Date().clearTime(); }; /** * Gets a date that is set to the current date and time (same as new Date, but chainable) * @return {Date} The current date. */ $D.present = function () { return new Date(); }; /** * Compares the first date to the second date and returns an number indication of their relative values. * @param {Date} First Date object to compare [Required]. * @param {Date} Second Date object to compare to [Required]. * @return {Number} -1 = date1 is lessthan date2. 0 = values are equal. 1 = date1 is greaterthan date2. */ $D.compare = function (date1, date2) { if (isNaN(date1) || isNaN(date2)) { throw new Error(date1 + " - " + date2); } else if (date1 instanceof Date && date2 instanceof Date) { return (date1 < date2) ? -1 : (date1 > date2) ? 1 : 0; } else { throw new TypeError(date1 + " - " + date2); } }; /** * Compares the first Date object to the second Date object and returns true if they are equal. * @param {Date} First Date object to compare [Required] * @param {Date} Second Date object to compare to [Required] * @return {Boolean} true if dates are equal. false if they are not equal. */ $D.equals = function (date1, date2) { return (date1.compareTo(date2) === 0); }; /** * Gets the language appropriate day name when given the day number(0-6) * eg - 0 == Sunday * @return {String} The day name */ $D.getDayName = function (n) { return Date.CultureInfo.dayNames[n]; }; /** * Gets the day number (0-6) if given a CultureInfo specific string which is a valid dayName, abbreviatedDayName or shortestDayName (two char). * @param {String} The name of the day (eg. "Monday, "Mon", "tuesday", "tue", "We", "we"). * @return {Number} The day number */ $D.getDayNumberFromName = function (name) { var n = Date.CultureInfo.dayNames, m = Date.CultureInfo.abbreviatedDayNames, o = Date.CultureInfo.shortestDayNames, s = name.toLowerCase(); for (var i = 0; i < n.length; i++) { if (n[i].toLowerCase() === s || m[i].toLowerCase() === s || o[i].toLowerCase() === s) { return i; } } return -1; }; /** * Gets the month number (0-11) if given a Culture Info specific string which is a valid monthName or abbreviatedMonthName. * @param {String} The name of the month (eg. "February, "Feb", "october", "oct"). * @return {Number} The day number */ $D.getMonthNumberFromName = function (name) { var n = Date.CultureInfo.monthNames, m = Date.CultureInfo.abbreviatedMonthNames, s = name.toLowerCase(); for (var i = 0; i < n.length; i++) { if (n[i].toLowerCase() === s || m[i].toLowerCase() === s) { return i; } } return -1; }; /** * Gets the language appropriate month name when given the month number(0-11) * eg - 0 == January * @return {String} The month name */ $D.getMonthName = function (n) { return Date.CultureInfo.monthNames[n]; }; /** * Determines if the current date instance is within a LeapYear. * @param {Number} The year. * @return {Boolean} true if date is within a LeapYear, otherwise false. */ $D.isLeapYear = function (year) { return ((year % 4 === 0 && year % 100 !== 0) || year % 400 === 0); }; /** * Gets the number of days in the month, given a year and month value. Automatically corrects for LeapYear. * @param {Number} The year. * @param {Number} The month (0-11). * @return {Number} The number of days in the month. */ $D.getDaysInMonth = function (year, month) { if (!month && $D.validateMonth(year)) { month = year; year = Date.today().getFullYear(); } return [31, ($D.isLeapYear(year) ? 29 : 28), 31, 30, 31, 30, 31, 31, 30, 31, 30, 31][month]; }; $P.getDaysInMonth = function () { return $D.getDaysInMonth(this.getFullYear(), this.getMonth()); }; $D.getTimezoneAbbreviation = function (offset, dst) { var p, n = (dst || false) ? Date.CultureInfo.abbreviatedTimeZoneDST : Date.CultureInfo.abbreviatedTimeZoneStandard; for (p in n) { if (n.hasOwnProperty(p)) { if (n[p] === offset) { return p; } } } return null; }; $D.getTimezoneOffset = function (name, dst) { var i, a =[], z = Date.CultureInfo.timezones; if (!name) { name = (new Date()).getTimezone();} for (i = 0; i < z.length; i++) { if (z[i].name === name.toUpperCase()) { a.push(i); } } if (!z[a[0]]) { return null; } if (a.length === 1 || !dst) { return z[a[0]].offset; } else { for (i=0; i < a.length; i++) { if (z[a[i]].dst) { return z[a[i]].offset; } } } }; $D.getQuarter = function (d) { d = d || new Date(); // If no date supplied, use today var q = [1,2,3,4]; return q[Math.floor(d.getMonth() / 3)]; // ~~~ is a bitwise op. Faster than Math.floor }; $D.getDaysLeftInQuarter = function (d) { d = d || new Date(); var qEnd = new Date(d); qEnd.setMonth(qEnd.getMonth() + 3 - qEnd.getMonth() % 3, 0); return Math.floor((qEnd - d) / 8.64e7); }; // private var validate = function (n, min, max, name) { name = name ? name : "Object"; if (typeof n === "undefined") { return false; } else if (typeof n !== "number") { throw new TypeError(n + " is not a Number."); } else if (n < min || n > max) { // As failing validation is *not* an exceptional circumstance // lets not throw a RangeError Exception here. // It's semantically correct but it's not sensible. return false; } return true; }; /** * Validates the number is within an acceptable range for milliseconds [0-999]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateMillisecond = function (value) { return validate(value, 0, 999, "millisecond"); }; /** * Validates the number is within an acceptable range for seconds [0-59]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateSecond = function (value) { return validate(value, 0, 59, "second"); }; /** * Validates the number is within an acceptable range for minutes [0-59]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateMinute = function (value) { return validate(value, 0, 59, "minute"); }; /** * Validates the number is within an acceptable range for hours [0-23]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateHour = function (value) { return validate(value, 0, 23, "hour"); }; /** * Validates the number is within an acceptable range for the days in a month [0-MaxDaysInMonth]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateDay = function (value, year, month) { if (year === undefined || year === null || month === undefined || month === null) { return false;} return validate(value, 1, $D.getDaysInMonth(year, month), "day"); }; /** * Validates the number is within an acceptable range for months [0-11]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateWeek = function (value) { return validate(value, 0, 53, "week"); }; /** * Validates the number is within an acceptable range for months [0-11]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateMonth = function (value) { return validate(value, 0, 11, "month"); }; /** * Validates the number is within an acceptable range for years. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateYear = function (value) { /** * Per ECMAScript spec the range of times supported by Date objects is * exactly -100,000,000 days to +100,000,000 days measured relative to * midnight at the beginning of 01 January, 1970 UTC. * This gives a range of 8,640,000,000,000,000 milliseconds to either * side of 01 January, 1970 UTC. * * Earliest possible date: Tue, 20 Apr 271,822 B.C. 00:00:00 UTC * Latest possible date: Sat, 13 Sep 275,760 00:00:00 UTC */ return validate(value, -271822, 275760, "year"); }; $D.validateTimezone = function(value) { var timezones = {"ACDT":1,"ACST":1,"ACT":1,"ADT":1,"AEDT":1,"AEST":1,"AFT":1,"AKDT":1,"AKST":1,"AMST":1,"AMT":1,"ART":1,"AST":1,"AWDT":1,"AWST":1,"AZOST":1,"AZT":1,"BDT":1,"BIOT":1,"BIT":1,"BOT":1,"BRT":1,"BST":1,"BTT":1,"CAT":1,"CCT":1,"CDT":1,"CEDT":1,"CEST":1,"CET":1,"CHADT":1,"CHAST":1,"CHOT":1,"ChST":1,"CHUT":1,"CIST":1,"CIT":1,"CKT":1,"CLST":1,"CLT":1,"COST":1,"COT":1,"CST":1,"CT":1,"CVT":1,"CWST":1,"CXT":1,"DAVT":1,"DDUT":1,"DFT":1,"EASST":1,"EAST":1,"EAT":1,"ECT":1,"EDT":1,"EEDT":1,"EEST":1,"EET":1,"EGST":1,"EGT":1,"EIT":1,"EST":1,"FET":1,"FJT":1,"FKST":1,"FKT":1,"FNT":1,"GALT":1,"GAMT":1,"GET":1,"GFT":1,"GILT":1,"GIT":1,"GMT":1,"GST":1,"GYT":1,"HADT":1,"HAEC":1,"HAST":1,"HKT":1,"HMT":1,"HOVT":1,"HST":1,"ICT":1,"IDT":1,"IOT":1,"IRDT":1,"IRKT":1,"IRST":1,"IST":1,"JST":1,"KGT":1,"KOST":1,"KRAT":1,"KST":1,"LHST":1,"LINT":1,"MAGT":1,"MART":1,"MAWT":1,"MDT":1,"MET":1,"MEST":1,"MHT":1,"MIST":1,"MIT":1,"MMT":1,"MSK":1,"MST":1,"MUT":1,"MVT":1,"MYT":1,"NCT":1,"NDT":1,"NFT":1,"NPT":1,"NST":1,"NT":1,"NUT":1,"NZDT":1,"NZST":1,"OMST":1,"ORAT":1,"PDT":1,"PET":1,"PETT":1,"PGT":1,"PHOT":1,"PHT":1,"PKT":1,"PMDT":1,"PMST":1,"PONT":1,"PST":1,"PYST":1,"PYT":1,"RET":1,"ROTT":1,"SAKT":1,"SAMT":1,"SAST":1,"SBT":1,"SCT":1,"SGT":1,"SLST":1,"SRT":1,"SST":1,"SYOT":1,"TAHT":1,"THA":1,"TFT":1,"TJT":1,"TKT":1,"TLT":1,"TMT":1,"TOT":1,"TVT":1,"UCT":1,"ULAT":1,"UTC":1,"UYST":1,"UYT":1,"UZT":1,"VET":1,"VLAT":1,"VOLT":1,"VOST":1,"VUT":1,"WAKT":1,"WAST":1,"WAT":1,"WEDT":1,"WEST":1,"WET":1,"WST":1,"YAKT":1,"YEKT":1,"Z":1}; return (timezones[value] === 1); }; $D.validateTimezoneOffset= function(value) { // timezones go from +14hrs to -12hrs, the +X hours are negative offsets. return (value > -841 && value < 721); }; }()); (function () { var $D = Date, $P = $D.prototype, p = function (s, l) { if (!l) { l = 2; } return ("000" + s).slice(l * -1); }; var validateConfigObject = function (obj) { var result = {}, self = this, prop, testFunc; testFunc = function (prop, func, value) { if (prop === "day") { var month = (obj.month !== undefined) ? obj.month : self.getMonth(); var year = (obj.year !== undefined) ? obj.year : self.getFullYear(); return $D[func](value, year, month); } else { return $D[func](value); } }; for (prop in obj) { if (Object.prototype.hasOwnProperty.call(obj, prop)) { var func = "validate" + prop.charAt(0).toUpperCase() + prop.slice(1); if ($D[func] && obj[prop] !== null && testFunc(prop, func, obj[prop])) { result[prop] = obj[prop]; } } } return result; }; /** * Resets the time of this Date object to 12:00 AM (00:00), which is the start of the day. * @param {Boolean} .clone() this date instance before clearing Time * @return {Date} this */ $P.clearTime = function () { this.setHours(0); this.setMinutes(0); this.setSeconds(0); this.setMilliseconds(0); return this; }; /** * Resets the time of this Date object to the current time ('now'). * @return {Date} this */ $P.setTimeToNow = function () { var n = new Date(); this.setHours(n.getHours()); this.setMinutes(n.getMinutes()); this.setSeconds(n.getSeconds()); this.setMilliseconds(n.getMilliseconds()); return this; }; /** * Returns a new Date object that is an exact date and time copy of the original instance. * @return {Date} A new Date instance */ $P.clone = function () { return new Date(this.getTime()); }; /** * Compares this instance to a Date object and returns an number indication of their relative values. * @param {Date} Date object to compare [Required] * @return {Number} -1 = this is lessthan date. 0 = values are equal. 1 = this is greaterthan date. */ $P.compareTo = function (date) { return Date.compare(this, date); }; /** * Compares this instance to another Date object and returns true if they are equal. * @param {Date} Date object to compare. If no date to compare, new Date() [now] is used. * @return {Boolean} true if dates are equal. false if they are not equal. */ $P.equals = function (date) { return Date.equals(this, (date !== undefined ? date : new Date())); }; /** * Determines if this instance is between a range of two dates or equal to either the start or end dates. * @param {Date} Start of range [Required] * @param {Date} End of range [Required] * @return {Boolean} true is this is between or equal to the start and end dates, else false */ $P.between = function (start, end) { return this.getTime() >= start.getTime() && this.getTime() <= end.getTime(); }; /** * Determines if this date occurs after the date to compare to. * @param {Date} Date object to compare. If no date to compare, new Date() ("now") is used. * @return {Boolean} true if this date instance is greater than the date to compare to (or "now"), otherwise false. */ $P.isAfter = function (date) { return this.compareTo(date || new Date()) === 1; }; /** * Determines if this date occurs before the date to compare to. * @param {Date} Date object to compare. If no date to compare, new Date() ("now") is used. * @return {Boolean} true if this date instance is less than the date to compare to (or "now"). */ $P.isBefore = function (date) { return (this.compareTo(date || new Date()) === -1); }; /** * Determines if the current Date instance occurs today. * @return {Boolean} true if this date instance is 'today', otherwise false. */ /** * Determines if the current Date instance occurs on the same Date as the supplied 'date'. * If no 'date' to compare to is provided, the current Date instance is compared to 'today'. * @param {date} Date object to compare. If no date to compare, the current Date ("now") is used. * @return {Boolean} true if this Date instance occurs on the same Day as the supplied 'date'. */ $P.isToday = $P.isSameDay = function (date) { return this.clone().clearTime().equals((date || new Date()).clone().clearTime()); }; /** * Adds the specified number of milliseconds to this instance. * @param {Number} The number of milliseconds to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addMilliseconds = function (value) { if (!value) { return this; } this.setTime(this.getTime() + value * 1); return this; }; /** * Adds the specified number of seconds to this instance. * @param {Number} The number of seconds to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addSeconds = function (value) { if (!value) { return this; } return this.addMilliseconds(value * 1000); }; /** * Adds the specified number of seconds to this instance. * @param {Number} The number of seconds to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addMinutes = function (value) { if (!value) { return this; } return this.addMilliseconds(value * 60000); // 60*1000 }; /** * Adds the specified number of hours to this instance. * @param {Number} The number of hours to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addHours = function (value) { if (!value) { return this; } return this.addMilliseconds(value * 3600000); // 60*60*1000 }; /** * Adds the specified number of days to this instance. * @param {Number} The number of days to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addDays = function (value) { if (!value) { return this; } this.setDate(this.getDate() + value * 1); return this; }; /** * Adds the specified number of weekdays (ie - not sat or sun) to this instance. * @param {Number} The number of days to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addWeekdays = function (value) { if (!value) { return this; } var day = this.getDay(); var weeks = (Math.ceil(Math.abs(value)/7)); if (day === 0 || day === 6) { if (value > 0) { this.next().monday(); this.addDays(-1); day = this.getDay(); } } if (value < 0) { while (value < 0) { this.addDays(-1); day = this.getDay(); if (day !== 0 && day !== 6) { value++; } } return this; } else if (value > 5 || (6-day) <= value) { value = value + (weeks * 2); } return this.addDays(value); }; /** * Adds the specified number of weeks to this instance. * @param {Number} The number of weeks to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addWeeks = function (value) { if (!value) { return this; } return this.addDays(value * 7); }; /** * Adds the specified number of months to this instance. * @param {Number} The number of months to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addMonths = function (value) { if (!value) { return this; } var n = this.getDate(); this.setDate(1); this.setMonth(this.getMonth() + value * 1); this.setDate(Math.min(n, $D.getDaysInMonth(this.getFullYear(), this.getMonth()))); return this; }; $P.addQuarters = function (value) { if (!value) { return this; } // note this will take you to the same point in the quarter as you are now. // i.e. - if you are 15 days into the quarter you'll be 15 days into the resulting one. // bonus: this allows adding fractional quarters return this.addMonths(value * 3); }; /** * Adds the specified number of years to this instance. * @param {Number} The number of years to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addYears = function (value) { if (!value) { return this; } return this.addMonths(value * 12); }; /** * Adds (or subtracts) to the value of the years, months, weeks, days, hours, minutes, seconds, milliseconds of the date instance using given configuration object. Positive and Negative values allowed. * Example

	Date.today().add( { days: 1, months: 1 } )

	new Date().add( { years: -1 } )
	
* @param {Object} Configuration object containing attributes (months, days, etc.) * @return {Date} this */ $P.add = function (config) { if (typeof config === "number") { this._orient = config; return this; } var x = config; if (x.day) { // If we should be a different date than today (eg: for 'tomorrow -1d', etc). // Should only effect parsing, not direct usage (eg, Finish and FinishExact) if ((x.day - this.getDate()) !== 0) { this.setDate(x.day); } } if (x.milliseconds) { this.addMilliseconds(x.milliseconds); } if (x.seconds) { this.addSeconds(x.seconds); } if (x.minutes) { this.addMinutes(x.minutes); } if (x.hours) { this.addHours(x.hours); } if (x.weeks) { this.addWeeks(x.weeks); } if (x.months) { this.addMonths(x.months); } if (x.years) { this.addYears(x.years); } if (x.days) { this.addDays(x.days); } return this; }; /** * Get the week number. Week one (1) is the week which contains the first Thursday of the year. Monday is considered the first day of the week. * The .getWeek() function does NOT convert the date to UTC. The local datetime is used. * Please use .getISOWeek() to get the week of the UTC converted date. * @return {Number} 1 to 53 */ $P.getWeek = function (utc) { // Create a copy of this date object var self, target = new Date(this.valueOf()); if (utc) { target.addMinutes(target.getTimezoneOffset()); self = target.clone(); } else { self = this; } // ISO week date weeks start on monday // so correct the day number var dayNr = (self.getDay() + 6) % 7; // ISO 8601 states that week 1 is the week // with the first thursday of that year. // Set the target date to the thursday in the target week target.setDate(target.getDate() - dayNr + 3); // Store the millisecond value of the target date var firstThursday = target.valueOf(); // Set the target to the first thursday of the year // First set the target to january first target.setMonth(0, 1); // Not a thursday? Correct the date to the next thursday if (target.getDay() !== 4) { target.setMonth(0, 1 + ((4 - target.getDay()) + 7) % 7); } // The weeknumber is the number of weeks between the // first thursday of the year and the thursday in the target week return 1 + Math.ceil((firstThursday - target) / 604800000); // 604800000 = 7 * 24 * 3600 * 1000 }; /** * Get the ISO 8601 week number. Week one ("01") is the week which contains the first Thursday of the year. Monday is considered the first day of the week. * The .getISOWeek() function does convert the date to it's UTC value. Please use .getWeek() to get the week of the local date. * @return {String} "01" to "53" */ $P.getISOWeek = function () { return p(this.getWeek(true)); }; /** * Moves the date to Monday of the week set. Week one (1) is the week which contains the first Thursday of the year. * @param {Number} A Number (1 to 53) that represents the week of the year. * @return {Date} this */ $P.setWeek = function (n) { if ((n - this.getWeek()) === 0) { if (this.getDay() !== 1) { return this.moveToDayOfWeek(1, (this.getDay() > 1 ? -1 : 1)); } else { return this; } } else { return this.moveToDayOfWeek(1, (this.getDay() > 1 ? -1 : 1)).addWeeks(n - this.getWeek()); } }; $P.setQuarter = function (qtr) { var month = Math.abs(((qtr-1) * 3) + 1); return this.setMonth(month, 1); }; $P.getQuarter = function () { return Date.getQuarter(this); }; $P.getDaysLeftInQuarter = function () { return Date.getDaysLeftInQuarter(this); }; /** * Moves the date to the next n'th occurrence of the dayOfWeek starting from the beginning of the month. The number (-1) is a magic number and will return the last occurrence of the dayOfWeek in the month. * @param {Number} The dayOfWeek to move to * @param {Number} The n'th occurrence to move to. Use (-1) to return the last occurrence in the month * @return {Date} this */ $P.moveToNthOccurrence = function (dayOfWeek, occurrence) { if (dayOfWeek === "Weekday") { if (occurrence > 0) { this.moveToFirstDayOfMonth(); if (this.is().weekday()) { occurrence -= 1; } } else if (occurrence < 0) { this.moveToLastDayOfMonth(); if (this.is().weekday()) { occurrence += 1; } } else { return this; } return this.addWeekdays(occurrence); } var shift = 0; if (occurrence > 0) { shift = occurrence - 1; } else if (occurrence === -1) { this.moveToLastDayOfMonth(); if (this.getDay() !== dayOfWeek) { this.moveToDayOfWeek(dayOfWeek, -1); } return this; } return this.moveToFirstDayOfMonth().addDays(-1).moveToDayOfWeek(dayOfWeek, +1).addWeeks(shift); }; var moveToN = function (getFunc, addFunc, nVal) { return function (value, orient) { var diff = (value - this[getFunc]() + nVal * (orient || +1)) % nVal; return this[addFunc]((diff === 0) ? diff += nVal * (orient || +1) : diff); }; }; /** * Move to the next or last dayOfWeek based on the orient value. * @param {Number} The dayOfWeek to move to * @param {Number} Forward (+1) or Back (-1). Defaults to +1. [Optional] * @return {Date} this */ $P.moveToDayOfWeek = moveToN("getDay", "addDays", 7); /** * Move to the next or last month based on the orient value. * @param {Number} The month to move to. 0 = January, 11 = December * @param {Number} Forward (+1) or Back (-1). Defaults to +1. [Optional] * @return {Date} this */ $P.moveToMonth = moveToN("getMonth", "addMonths", 12); /** * Get the Ordinate of the current day ("th", "st", "rd"). * @return {String} */ $P.getOrdinate = function () { var num = this.getDate(); return ord(num); }; /** * Get the Ordinal day (numeric day number) of the year, adjusted for leap year. * @return {Number} 1 through 365 (366 in leap years) */ $P.getOrdinalNumber = function () { return Math.ceil((this.clone().clearTime() - new Date(this.getFullYear(), 0, 1)) / 86400000) + 1; }; /** * Get the time zone abbreviation of the current date. * @return {String} The abbreviated time zone name (e.g. "EST") */ $P.getTimezone = function () { return $D.getTimezoneAbbreviation(this.getUTCOffset(), this.isDaylightSavingTime()); }; $P.setTimezoneOffset = function (offset) { var here = this.getTimezoneOffset(), there = Number(offset) * -6 / 10; return (there || there === 0) ? this.addMinutes(there - here) : this; }; $P.setTimezone = function (offset) { return this.setTimezoneOffset($D.getTimezoneOffset(offset)); }; /** * Indicates whether Daylight Saving Time is observed in the current time zone. * @return {Boolean} true|false */ $P.hasDaylightSavingTime = function () { return (Date.today().set({month: 0, day: 1}).getTimezoneOffset() !== Date.today().set({month: 6, day: 1}).getTimezoneOffset()); }; /** * Indicates whether this Date instance is within the Daylight Saving Time range for the current time zone. * @return {Boolean} true|false */ $P.isDaylightSavingTime = function () { return Date.today().set({month: 0, day: 1}).getTimezoneOffset() !== this.getTimezoneOffset(); }; /** * Get the offset from UTC of the current date. * @return {String} The 4-character offset string prefixed with + or - (e.g. "-0500") */ $P.getUTCOffset = function (offset) { var n = (offset || this.getTimezoneOffset()) * -10 / 6, r; if (n < 0) { r = (n - 10000).toString(); return r.charAt(0) + r.substr(2); } else { r = (n + 10000).toString(); return "+" + r.substr(1); } }; /** * Returns the number of milliseconds between this date and date. * @param {Date} Defaults to now * @return {Number} The diff in milliseconds */ $P.getElapsed = function (date) { return (date || new Date()) - this; }; /** * Set the value of year, month, day, hour, minute, second, millisecond of date instance using given configuration object. * Example

	Date.today().set( { day: 20, month: 1 } )

	new Date().set( { millisecond: 0 } )
	
* * @param {Object} Configuration object containing attributes (month, day, etc.) * @return {Date} this */ $P.set = function (config) { config = validateConfigObject.call(this, config); var key; for (key in config) { if (Object.prototype.hasOwnProperty.call(config, key)) { var name = key.charAt(0).toUpperCase() + key.slice(1); var addFunc, getFunc; if (key !== "week" && key !== "month" && key !== "timezone" && key !== "timezoneOffset") { name += "s"; } addFunc = "add" + name; getFunc = "get" + name; if (key === "month") { addFunc = addFunc + "s"; } else if (key === "year"){ getFunc = "getFullYear"; } if (key !== "day" && key !== "timezone" && key !== "timezoneOffset" && key !== "week" && key !== "hour") { this[addFunc](config[key] - this[getFunc]()); } else if ( key === "timezone"|| key === "timezoneOffset" || key === "week" || key === "hour") { this["set"+name](config[key]); } } } // day has to go last because you can't validate the day without first knowing the month if (config.day) { this.addDays(config.day - this.getDate()); } return this; }; /** * Moves the date to the first day of the month. * @return {Date} this */ $P.moveToFirstDayOfMonth = function () { return this.set({ day: 1 }); }; /** * Moves the date to the last day of the month. * @return {Date} this */ $P.moveToLastDayOfMonth = function () { return this.set({ day: $D.getDaysInMonth(this.getFullYear(), this.getMonth())}); }; /** * Converts the value of the current Date object to its equivalent string representation. * Format Specifiers * CUSTOM DATE AND TIME FORMAT STRINGS * Format Description Example * ------ --------------------------------------------------------------------------- ----------------------- * s The seconds of the minute between 0-59. "0" to "59" * ss The seconds of the minute with leading zero if required. "00" to "59" * * m The minute of the hour between 0-59. "0" or "59" * mm The minute of the hour with leading zero if required. "00" or "59" * * h The hour of the day between 1-12. "1" to "12" * hh The hour of the day with leading zero if required. "01" to "12" * * H The hour of the day between 0-23. "0" to "23" * HH The hour of the day with leading zero if required. "00" to "23" * * d The day of the month between 1 and 31. "1" to "31" * dd The day of the month with leading zero if required. "01" to "31" * ddd Abbreviated day name. Date.CultureInfo.abbreviatedDayNames. "Mon" to "Sun" * dddd The full day name. Date.CultureInfo.dayNames. "Monday" to "Sunday" * * M The month of the year between 1-12. "1" to "12" * MM The month of the year with leading zero if required. "01" to "12" * MMM Abbreviated month name. Date.CultureInfo.abbreviatedMonthNames. "Jan" to "Dec" * MMMM The full month name. Date.CultureInfo.monthNames. "January" to "December" * * yy The year as a two-digit number. "99" or "08" * yyyy The full four digit year. "1999" or "2008" * * t Displays the first character of the A.M./P.M. designator. "A" or "P" * Date.CultureInfo.amDesignator or Date.CultureInfo.pmDesignator * tt Displays the A.M./P.M. designator. "AM" or "PM" * Date.CultureInfo.amDesignator or Date.CultureInfo.pmDesignator * * S The ordinal suffix ("st, "nd", "rd" or "th") of the current day. "st, "nd", "rd" or "th" * * STANDARD DATE AND TIME FORMAT STRINGS * Format Description Example *------ --------------------------------------------------------------------------- ----------------------- * d The CultureInfo shortDate Format Pattern "M/d/yyyy" * D The CultureInfo longDate Format Pattern "dddd, MMMM dd, yyyy" * F The CultureInfo fullDateTime Format Pattern "dddd, MMMM dd, yyyy h:mm:ss tt" * m The CultureInfo monthDay Format Pattern "MMMM dd" * r The CultureInfo rfc1123 Format Pattern "ddd, dd MMM yyyy HH:mm:ss GMT" * s The CultureInfo sortableDateTime Format Pattern "yyyy-MM-ddTHH:mm:ss" * t The CultureInfo shortTime Format Pattern "h:mm tt" * T The CultureInfo longTime Format Pattern "h:mm:ss tt" * u The CultureInfo universalSortableDateTime Format Pattern "yyyy-MM-dd HH:mm:ssZ" * y The CultureInfo yearMonth Format Pattern "MMMM, yyyy" * * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @return {String} A string representation of the current Date object. */ var ord = function (n) { switch (n * 1) { case 1: case 21: case 31: return "st"; case 2: case 22: return "nd"; case 3: case 23: return "rd"; default: return "th"; } }; var parseStandardFormats = function (format) { var y, c = Date.CultureInfo.formatPatterns; switch (format) { case "d": return this.toString(c.shortDate); case "D": return this.toString(c.longDate); case "F": return this.toString(c.fullDateTime); case "m": return this.toString(c.monthDay); case "r": case "R": y = this.clone().addMinutes(this.getTimezoneOffset()); return y.toString(c.rfc1123) + " GMT"; case "s": return this.toString(c.sortableDateTime); case "t": return this.toString(c.shortTime); case "T": return this.toString(c.longTime); case "u": y = this.clone().addMinutes(this.getTimezoneOffset()); return y.toString(c.universalSortableDateTime); case "y": return this.toString(c.yearMonth); default: return false; } }; var parseFormatStringsClosure = function (context) { return function (m) { if (m.charAt(0) === "\\") { return m.replace("\\", ""); } switch (m) { case "hh": return p(context.getHours() < 13 ? (context.getHours() === 0 ? 12 : context.getHours()) : (context.getHours() - 12)); case "h": return context.getHours() < 13 ? (context.getHours() === 0 ? 12 : context.getHours()) : (context.getHours() - 12); case "HH": return p(context.getHours()); case "H": return context.getHours(); case "mm": return p(context.getMinutes()); case "m": return context.getMinutes(); case "ss": return p(context.getSeconds()); case "s": return context.getSeconds(); case "yyyy": return p(context.getFullYear(), 4); case "yy": return p(context.getFullYear()); case "y": return context.getFullYear(); case "E": case "dddd": return Date.CultureInfo.dayNames[context.getDay()]; case "ddd": return Date.CultureInfo.abbreviatedDayNames[context.getDay()]; case "dd": return p(context.getDate()); case "d": return context.getDate(); case "MMMM": return Date.CultureInfo.monthNames[context.getMonth()]; case "MMM": return Date.CultureInfo.abbreviatedMonthNames[context.getMonth()]; case "MM": return p((context.getMonth() + 1)); case "M": return context.getMonth() + 1; case "t": return context.getHours() < 12 ? Date.CultureInfo.amDesignator.substring(0, 1) : Date.CultureInfo.pmDesignator.substring(0, 1); case "tt": return context.getHours() < 12 ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator; case "S": return ord(context.getDate()); case "W": return context.getWeek(); case "WW": return context.getISOWeek(); case "Q": return "Q" + context.getQuarter(); case "q": return String(context.getQuarter()); case "z": return context.getTimezone(); case "Z": case "X": return Date.getTimezoneOffset(context.getTimezone()); case "ZZ": // Timezone offset in seconds return context.getTimezoneOffset() * -60; case "u": return context.getDay(); case "L": return ($D.isLeapYear(context.getFullYear())) ? 1 : 0; case "B": // Swatch Internet Time (.beats) return "@"+((context.getUTCSeconds() + (context.getUTCMinutes()*60) + ((context.getUTCHours()+1)*3600))/86.4); default: return m; } }; }; $P.toString = function (format, ignoreStandards) { // Standard Date and Time Format Strings. Formats pulled from CultureInfo file and // may vary by culture. if (!ignoreStandards && format && format.length === 1) { output = parseStandardFormats.call(this, format); if (output) { return output; } } var parseFormatStrings = parseFormatStringsClosure(this); return format ? format.replace(/((\\)?(dd?d?d?|MM?M?M?|yy?y?y?|hh?|HH?|mm?|ss?|tt?|S|q|Q|WW?W?W?)(?![^\[]*\]))/g, parseFormatStrings).replace(/\[|\]/g, "") : this._toString(); }; }()); /************************************************************* * SugarPak - Domain Specific Language - Syntactical Sugar * *************************************************************/ (function () { var $D = Date, $P = $D.prototype, $N = Number.prototype; // private $P._orient = +1; // private $P._nth = null; // private $P._is = false; // private $P._same = false; // private $P._isSecond = false; // private $N._dateElement = "days"; /** * Moves the date to the next instance of a date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.today().next().friday();
	Date.today().next().fri();
	Date.today().next().march();
	Date.today().next().mar();
	Date.today().next().week();
	
* * @return {Date} date */ $P.next = function () { this._move = true; this._orient = +1; return this; }; /** * Creates a new Date (Date.today()) and moves the date to the next instance of the date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.next().friday();
	Date.next().fri();
	Date.next().march();
	Date.next().mar();
	Date.next().week();
	
* * @return {Date} date */ $D.next = function () { return $D.today().next(); }; /** * Moves the date to the previous instance of a date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.today().last().friday();
	Date.today().last().fri();
	Date.today().last().march();
	Date.today().last().mar();
	Date.today().last().week();
	
* * @return {Date} date */ $P.last = $P.prev = $P.previous = function () { this._move = true; this._orient = -1; return this; }; /** * Creates a new Date (Date.today()) and moves the date to the previous instance of the date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.last().friday();
	Date.last().fri();
	Date.previous().march();
	Date.prev().mar();
	Date.last().week();
	
* * @return {Date} date */ $D.last = $D.prev = $D.previous = function () { return $D.today().last(); }; /** * Performs a equality check when followed by either a month name, day name or .weekday() function. * Example

	Date.today().is().friday(); // true|false
	Date.today().is().fri();
	Date.today().is().march();
	Date.today().is().mar();
	
* * @return {Boolean} true|false */ $P.is = function () { this._is = true; return this; }; /** * Determines if two date objects occur on/in exactly the same instance of the subsequent date part function. * The function .same() must be followed by a date part function (example: .day(), .month(), .year(), etc). * * An optional Date can be passed in the date part function. If now date is passed as a parameter, 'Now' is used. * * The following example demonstrates how to determine if two dates fall on the exact same day. * * Example

	var d1 = Date.today(); // today at 00:00
	var d2 = new Date();   // exactly now.

	// Do they occur on the same day?
	d1.same().day(d2); // true
	
	// Do they occur on the same hour?
	d1.same().hour(d2); // false, unless d2 hour is '00' (midnight).
	
	// What if it's the same day, but one year apart?
	var nextYear = Date.today().add(1).year();

	d1.same().day(nextYear); // false, because the dates must occur on the exact same day. 
	
* * Scenario: Determine if a given date occurs during some week period 2 months from now. * * Example

	var future = Date.today().add(2).months();
	return someDate.same().week(future); // true|false;
	
* * @return {Boolean} true|false */ $P.same = function () { this._same = true; this._isSecond = false; return this; }; /** * Determines if the current date/time occurs during Today. Must be preceded by the .is() function. * Example

	someDate.is().today();    // true|false
	new Date().is().today();  // true
	Date.today().is().today();// true
	Date.today().add(-1).day().is().today(); // false
	
* * @return {Boolean} true|false */ $P.today = function () { return this.same().day(); }; /** * Determines if the current date is a weekday. This function must be preceded by the .is() function. * Example

	Date.today().is().weekday(); // true|false
	
* * @return {Boolean} true|false */ $P.weekday = function () { if (this._nth) { return df("Weekday").call(this); } if (this._move) { return this.addWeekdays(this._orient); } if (this._is) { this._is = false; return (!this.is().sat() && !this.is().sun()); } return false; }; /** * Determines if the current date is on the weekend. This function must be preceded by the .is() function. * Example

	Date.today().is().weekend(); // true|false
	
* * @return {Boolean} true|false */ $P.weekend = function () { if (this._is) { this._is = false; return (this.is().sat() || this.is().sun()); } return false; }; /** * Sets the Time of the current Date instance. A string "6:15 pm" or config object {hour:18, minute:15} are accepted. * Example

	// Set time to 6:15pm with a String
	Date.today().at("6:15pm");

	// Set time to 6:15pm with a config object
	Date.today().at({hour:18, minute:15});
	
* * @return {Date} date */ $P.at = function (time) { return (typeof time === "string") ? $D.parse(this.toString("d") + " " + time) : this.set(time); }; /** * Creates a new Date() and adds this (Number) to the date based on the preceding date element function (eg. second|minute|hour|day|month|year). * Example

	// Undeclared Numbers must be wrapped with parentheses. Requirment of JavaScript.
	(3).days().fromNow();
	(6).months().fromNow();

	// Declared Number variables do not require parentheses. 
	var n = 6;
	n.months().fromNow();
	
* * @return {Date} A new Date instance */ $N.fromNow = $N.after = function (date) { var c = {}; c[this._dateElement] = this; return ((!date) ? new Date() : date.clone()).add(c); }; /** * Creates a new Date() and subtract this (Number) from the date based on the preceding date element function (eg. second|minute|hour|day|month|year). * Example

	// Undeclared Numbers must be wrapped with parentheses. Requirment of JavaScript.
	(3).days().ago();
	(6).months().ago();

	// Declared Number variables do not require parentheses. 
	var n = 6;
	n.months().ago();
	
* * @return {Date} A new Date instance */ $N.ago = $N.before = function (date) { var c = {}, s = (this._dateElement[this._dateElement.length-1] !== "s") ? this._dateElement + "s" : this._dateElement; c[s] = this * -1; return ((!date) ? new Date() : date.clone()).add(c); }; // Do NOT modify the following string tokens. These tokens are used to build dynamic functions. // All culture-specific strings can be found in the CultureInfo files. var dx = ("sunday monday tuesday wednesday thursday friday saturday").split(/\s/), mx = ("january february march april may june july august september october november december").split(/\s/), px = ("Millisecond Second Minute Hour Day Week Month Year Quarter Weekday").split(/\s/), pxf = ("Milliseconds Seconds Minutes Hours Date Week Month FullYear Quarter").split(/\s/), nth = ("final first second third fourth fifth").split(/\s/), de; /** * Returns an object literal of all the date parts. * Example

	var o = new Date().toObject();
	
	// { year: 2008, month: 4, week: 20, day: 13, hour: 18, minute: 9, second: 32, millisecond: 812 }
	
	// The object properties can be referenced directly from the object.
	
	alert(o.day);  // alerts "13"
	alert(o.year); // alerts "2008"
	
* * @return {Date} An object literal representing the original date object. */ $P.toObject = function () { var o = {}; for (var i = 0; i < px.length; i++) { if (this["get" + pxf[i]]) { o[px[i].toLowerCase()] = this["get" + pxf[i]](); } } return o; }; /** * Returns a date created from an object literal. Ignores the .week property if set in the config. * Example

	var o = new Date().toObject();
	
	return Date.fromObject(o); // will return the same date. 

	var o2 = {month: 1, day: 20, hour: 18}; // birthday party!
	Date.fromObject(o2);
	
* * @return {Date} An object literal representing the original date object. */ $D.fromObject = function(config) { config.week = null; return Date.today().set(config); }; // Create day name functions and abbreviated day name functions (eg. monday(), friday(), fri()). var df = function (n) { return function () { if (this._is) { this._is = false; return this.getDay() === n; } if (this._move) { this._move = null; } if (this._nth !== null) { // If the .second() function was called earlier, remove the _orient // from the date, and then continue. // This is required because 'second' can be used in two different context. // // Example // // Date.today().add(1).second(); // Date.march().second().monday(); // // Things get crazy with the following... // Date.march().add(1).second().second().monday(); // but it works!! // if (this._isSecond) { this.addSeconds(this._orient * -1); } // make sure we reset _isSecond this._isSecond = false; var ntemp = this._nth; this._nth = null; var temp = this.clone().moveToLastDayOfMonth(); this.moveToNthOccurrence(n, ntemp); if (this > temp) { throw new RangeError($D.getDayName(n) + " does not occur " + ntemp + " times in the month of " + $D.getMonthName(temp.getMonth()) + " " + temp.getFullYear() + "."); } return this; } return this.moveToDayOfWeek(n, this._orient); }; }; var sdf = function (n) { return function () { var t = $D.today(), shift = n - t.getDay(); if (n === 0 && Date.CultureInfo.firstDayOfWeek === 1 && t.getDay() !== 0) { shift = shift + 7; } return t.addDays(shift); }; }; // Create month name functions and abbreviated month name functions (eg. january(), march(), mar()). var month_instance_functions = function (n) { return function () { if (this._is) { this._is = false; return this.getMonth() === n; } return this.moveToMonth(n, this._orient); }; }; var month_static_functions = function (n) { return function () { return $D.today().set({ month: n, day: 1 }); }; }; var processTerms = function (names, staticFunc, instanceFunc) { for (var i = 0; i < names.length; i++) { // Create constant static Name variables. $D[names[i].toUpperCase()] = $D[names[i].toUpperCase().substring(0, 3)] = i; // Create Name functions. $D[names[i]] = $D[names[i].substring(0, 3)] = staticFunc(i); // Create Name instance functions. $P[names[i]] = $P[names[i].substring(0, 3)] = instanceFunc(i); } }; processTerms(dx, sdf, df); processTerms(mx, month_static_functions, month_instance_functions); // Create date element functions and plural date element functions used with Date (eg. day(), days(), months()). var ef = function (j) { return function () { // if the .second() function was called earlier, the _orient // has alread been added. Just return this and reset _isSecond. if (this._isSecond) { this._isSecond = false; return this; } if (this._same) { this._same = this._is = false; var o1 = this.toObject(), o2 = (arguments[0] || new Date()).toObject(), v = "", k = j.toLowerCase(); // the substr trick with -1 doesn't work in IE8 or less k = (k[k.length-1] === "s") ? k.substring(0,k.length-1) : k; for (var m = (px.length - 1); m > -1; m--) { v = px[m].toLowerCase(); if (o1[v] !== o2[v]) { return false; } if (k === v) { break; } } return true; } if (j.substring(j.length - 1) !== "s") { j += "s"; } if (this._move) { this._move = null; } return this["add" + j](this._orient); }; }; var nf = function (n) { return function () { this._dateElement = n; return this; }; }; for (var k = 0; k < px.length; k++) { de = px[k].toLowerCase(); if(de !== "weekday") { // Create date element functions and plural date element functions used with Date (eg. day(), days(), months()). $P[de] = $P[de + "s"] = ef(px[k]); // Create date element functions and plural date element functions used with Number (eg. day(), days(), months()). $N[de] = $N[de + "s"] = nf(de + "s"); } } $P._ss = ef("Second"); var nthfn = function (n) { return function (dayOfWeek) { if (this._same) { return this._ss(arguments[0]); } if (dayOfWeek || dayOfWeek === 0) { return this.moveToNthOccurrence(dayOfWeek, n); } this._nth = n; // if the operator is 'second' add the _orient, then deal with it later... if (n === 2 && (dayOfWeek === undefined || dayOfWeek === null)) { this._isSecond = true; return this.addSeconds(this._orient); } return this; }; }; for (var l = 0; l < nth.length; l++) { $P[nth[l]] = (l === 0) ? nthfn(-1) : nthfn(l); } }()); (function () { "use strict"; Date.Parsing = { Exception: function (s) { this.message = "Parse error at '" + s.substring(0, 10) + " ...'"; } }; var $P = Date.Parsing; var dayOffsets = { standard: [0,31,59,90,120,151,181,212,243,273,304,334], leap: [0,31,60,91,121,152,182,213,244,274,305,335] }; $P.isLeapYear = function(year) { return ((year % 4 === 0) && (year % 100 !== 0)) || (year % 400 === 0); }; var utils = { multiReplace : function (str, hash ) { var key; for (key in hash) { if (Object.prototype.hasOwnProperty.call(hash, key)) { var regex; if (typeof hash[key] === "function") { } else { regex = (hash[key] instanceof RegExp) ? hash[key] : new RegExp(hash[key], "g"); } str = str.replace(regex, key); } } return str; }, getDayOfYearFromWeek : function (obj) { var d, jan4, offset; obj.weekDay = (!obj.weekDay && obj.weekDay !== 0) ? 1 : obj.weekDay; d = new Date(obj.year, 0, 4); jan4 = d.getDay() === 0 ? 7 : d.getDay(); // JS is 0 indexed on Sunday. offset = jan4+3; obj.dayOfYear = ((obj.week * 7) + (obj.weekDay === 0 ? 7 : obj.weekDay))-offset; return obj; }, getDayOfYear : function (obj, dayOffset) { if (!obj.dayOfYear) { obj = utils.getDayOfYearFromWeek(obj); } for (var i=0;i <= dayOffset.length;i++) { if (obj.dayOfYear < dayOffset[i] || i === dayOffset.length) { obj.day = obj.day ? obj.day : (obj.dayOfYear - dayOffset[i-1]); break; } else { obj.month = i; } } return obj; }, adjustForTimeZone : function (obj, date) { var offset; if (obj.zone.toUpperCase() === "Z" || (obj.zone_hours === 0 && obj.zone_minutes === 0)) { // it's UTC/GML so work out the current timeszone offset offset = -date.getTimezoneOffset(); } else { offset = (obj.zone_hours*60) + (obj.zone_minutes || 0); if (obj.zone_sign === "+") { offset *= -1; } offset -= date.getTimezoneOffset(); } date.setMinutes(date.getMinutes()+offset); return date; }, setDefaults : function (obj) { obj.year = obj.year || Date.today().getFullYear(); obj.hours = obj.hours || 0; obj.minutes = obj.minutes || 0; obj.seconds = obj.seconds || 0; obj.milliseconds = obj.milliseconds || 0; if (!(!obj.month && (obj.week || obj.dayOfYear))) { // if we have a month, or if we don't but don't have the day calculation data obj.month = obj.month || 0; obj.day = obj.day || 1; } return obj; }, dataNum: function (data, mod, explict, postProcess) { var dataNum = data*1; if (mod) { if (postProcess) { return data ? mod(data)*1 : data; } else { return data ? mod(dataNum) : data; } } else if (!explict){ return data ? dataNum : data; } else { return (data && typeof data !== "undefined") ? dataNum : data; } }, timeDataProcess: function (obj) { var timeObj = {}; for (var x in obj.data) { if (obj.data.hasOwnProperty(x)) { timeObj[x] = obj.ignore[x] ? obj.data[x] : utils.dataNum(obj.data[x], obj.mods[x], obj.explict[x], obj.postProcess[x]); } } if (obj.data.secmins) { obj.data.secmins = obj.data.secmins.replace(",", ".") * 60; if (!timeObj.minutes) { timeObj.minutes = obj.data.secmins; } else if (!timeObj.seconds) { timeObj.seconds = obj.data.secmins; } delete obj.secmins; } return timeObj; }, buildTimeObjectFromData: function (data) { var time = utils.timeDataProcess({ data: { year : data[1], month : data[5], day : data[7], week : data[8], dayOfYear : data[10], hours : data[15], zone_hours : data[23], zone_minutes : data[24], zone : data[21], zone_sign : data[22], weekDay : data[9], minutes: data[16], seconds: data[19], milliseconds: data[20], secmins: data[18] }, mods: { month: function(data) { return data-1; }, weekDay: function (data) { data = Math.abs(data); return (data === 7 ? 0 : data); }, minutes: function (data) { return data.replace(":",""); }, seconds: function (data) { return Math.floor( (data.replace(":","").replace(",","."))*1 ); }, milliseconds: function (data) { return (data.replace(",",".")*1000); } }, postProcess: { minutes: true, seconds: true, milliseconds: true }, explict: { zone_hours: true, zone_minutes: true }, ignore: { zone: true, zone_sign: true, secmins: true } }); return time; }, addToHash: function (hash, keys, data) { keys = keys; data = data; var len = keys.length; for (var i = 0; i < len; i++) { hash[keys[i]] = data[i]; } return hash; }, combineRegex: function (r1, r2) { return new RegExp("(("+r1.source+")\\s("+r2.source+"))"); }, getDateNthString: function(add, last, inc){ if (add) { return Date.today().addDays(inc).toString("d"); } else if (last) { return Date.today().last()[inc]().toString("d"); } }, buildRegexData: function (array) { var arr = []; var len = array.length; for (var i=0; i < len; i++) { if (Object.prototype.toString.call(array[i]) === '[object Array]') { // oldIE compat version of Array.isArray arr.push(this.combineRegex(array[i][0], array[i][1])); } else { arr.push(array[i]); } } return arr; } }; $P.processTimeObject = function (obj) { var date, dayOffset; utils.setDefaults(obj); dayOffset = ($P.isLeapYear(obj.year)) ? dayOffsets.leap : dayOffsets.standard; if (!obj.month && (obj.week || obj.dayOfYear)) { utils.getDayOfYear(obj, dayOffset); } else { obj.dayOfYear = dayOffset[obj.month] + obj.day; } date = new Date(obj.year, obj.month, obj.day, obj.hours, obj.minutes, obj.seconds, obj.milliseconds); if (obj.zone) { utils.adjustForTimeZone(obj, date); // adjust (and calculate) for timezone } return date; }; $P.ISO = { regex : /^([\+-]?\d{4}(?!\d{2}\b))((-?)((0[1-9]|1[0-2])(\3([12]\d|0[1-9]|3[01]))?|W([0-4]\d|5[0-3])(-?[1-7])?|(00[1-9]|0[1-9]\d|[12]\d{2}|3([0-5]\d|6[1-6])))([T\s]((([01]\d|2[0-4])((:?)[0-5]\d)?|24\:?00)([\.,]\d+(?!:))?)?(\17[0-5]\d([\.,]\d+)?)?\s?([zZ]|([\+-])([01]\d|2[0-3]):?([0-5]\d)?)?)?)?$/, parse : function (s) { var time, data = s.match(this.regex); if (!data || !data.length) { return null; } time = utils.buildTimeObjectFromData(data); if (!time.year || (!time.year && (!time.month && !time.day) && (!time.week && !time.dayOfYear)) ) { return null; } return $P.processTimeObject(time); } }; $P.Numeric = { isNumeric: function (e){return!isNaN(parseFloat(e))&&isFinite(e);}, regex: /\b([0-1]?[0-9])([0-3]?[0-9])([0-2]?[0-9]?[0-9][0-9])\b/i, parse: function (s) { var data, i, time = {}, order = Date.CultureInfo.dateElementOrder.split(""); if (!(this.isNumeric(s)) || // if it's non-numeric OR (s[0] === "+" && s[0] === "-")) { // It's an arithmatic string (eg +/-1000) return null; } if (s.length < 5 && s.indexOf(".") < 0 && s.indexOf("/") < 0) { // assume it's just a year. time.year = s; return $P.processTimeObject(time); } data = s.match(this.regex); if (!data || !data.length) { return null; } for (i=0; i < order.length; i++) { switch(order[i]) { case "d": time.day = data[i+1]; break; case "m": time.month = (data[i+1]-1); break; case "y": time.year = data[i+1]; break; } } return $P.processTimeObject(time); } }; $P.Normalizer = { regexData: function () { var $R = Date.CultureInfo.regexPatterns; return utils.buildRegexData([ $R.tomorrow, $R.yesterday, [$R.past, $R.mon], [$R.past, $R.tue], [$R.past, $R.wed], [$R.past, $R.thu], [$R.past, $R.fri], [$R.past, $R.sat], [$R.past, $R.sun] ]); }, basicReplaceHash : function() { var $R = Date.CultureInfo.regexPatterns; return { "January": $R.jan.source, "February": $R.feb, "March": $R.mar, "April": $R.apr, "May": $R.may, "June": $R.jun, "July": $R.jul, "August": $R.aug, "September": $R.sep, "October": $R.oct, "November": $R.nov, "December": $R.dec, "": /\bat\b/gi, " ": /\s{2,}/, "am": $R.inTheMorning, "9am": $R.thisMorning, "pm": $R.inTheEvening, "7pm":$R.thisEvening }; }, keys : function(){ return [ utils.getDateNthString(true, false, 1), // tomorrow utils.getDateNthString(true, false, -1), // yesterday utils.getDateNthString(false, true, "monday"), //last mon utils.getDateNthString(false, true, "tuesday"), //last tues utils.getDateNthString(false, true, "wednesday"), //last wed utils.getDateNthString(false, true, "thursday"), //last thurs utils.getDateNthString(false, true, "friday"), //last fri utils.getDateNthString(false, true, "saturday"), //last sat utils.getDateNthString(false, true, "sunday") //last sun ]; }, buildRegexFunctions: function () { var $R = Date.CultureInfo.regexPatterns; var __ = Date.i18n.__; var tomorrowRE = new RegExp("(\\b\\d\\d?("+__("AM")+"|"+__("PM")+")? )("+$R.tomorrow.source.slice(1)+")", "i"); // adapted tomorrow regex for AM PM relative dates var todayRE = new RegExp($R.today.source + "(?!\\s*([+-]))\\b"); // today, but excludes the math operators (eg "today + 2h") this.replaceFuncs = [ [todayRE, function (full) { return (full.length > 1) ? Date.today().toString("d") : full; }], [tomorrowRE, function(full, m1) { var t = Date.today().addDays(1).toString("d"); return (t + " " + m1); }], [$R.amThisMorning, function(str, am){return am;}], [$R.pmThisEvening, function(str, pm){return pm;}] ]; }, buildReplaceData: function () { this.buildRegexFunctions(); this.replaceHash = utils.addToHash(this.basicReplaceHash(), this.keys(), this.regexData()); }, stringReplaceFuncs: function (s) { for (var i=0; i < this.replaceFuncs.length; i++) { s = s.replace(this.replaceFuncs[i][0], this.replaceFuncs[i][1]); } return s; }, parse: function (s) { s = this.stringReplaceFuncs(s); s = utils.multiReplace(s, this.replaceHash); try { var n = s.split(/([\s\-\.\,\/\x27]+)/); if (n.length === 3 && $P.Numeric.isNumeric(n[0]) && $P.Numeric.isNumeric(n[2]) && (n[2].length >= 4)) { // ok, so we're dealing with x/year. But that's not a full date. // This fixes wonky dateElementOrder parsing when set to dmy order. if (Date.CultureInfo.dateElementOrder[0] === "d") { s = "1/" + n[0] + "/" + n[2]; // set to 1st of month and normalize the seperator } } } catch (e) {} return s; } }; $P.Normalizer.buildReplaceData(); }()); (function () { var $P = Date.Parsing; var _ = $P.Operators = { // // Tokenizers // rtoken: function (r) { // regex token return function (s) { var mx = s.match(r); if (mx) { return ([ mx[0], s.substring(mx[0].length) ]); } else { throw new $P.Exception(s); } }; }, token: function () { // whitespace-eating token return function (s) { return _.rtoken(new RegExp("^\\s*" + s + "\\s*"))(s); }; }, stoken: function (s) { // string token return _.rtoken(new RegExp("^" + s)); }, // Atomic Operators until: function (p) { return function (s) { var qx = [], rx = null; while (s.length) { try { rx = p.call(this, s); } catch (e) { qx.push(rx[0]); s = rx[1]; continue; } break; } return [ qx, s ]; }; }, many: function (p) { return function (s) { var rx = [], r = null; while (s.length) { try { r = p.call(this, s); } catch (e) { return [ rx, s ]; } rx.push(r[0]); s = r[1]; } return [ rx, s ]; }; }, // generator operators -- see below optional: function (p) { return function (s) { var r = null; try { r = p.call(this, s); } catch (e) { return [ null, s ]; } return [ r[0], r[1] ]; }; }, not: function (p) { return function (s) { try { p.call(this, s); } catch (e) { return [null, s]; } throw new $P.Exception(s); }; }, ignore: function (p) { return p ? function (s) { var r = null; r = p.call(this, s); return [null, r[1]]; } : null; }, product: function () { var px = arguments[0], qx = Array.prototype.slice.call(arguments, 1), rx = []; for (var i = 0 ; i < px.length ; i++) { rx.push(_.each(px[i], qx)); } return rx; }, cache: function (rule) { var cache = {}, cache_length = 0, cache_keys = [], CACHE_MAX = Date.Config.CACHE_MAX || 100000, r = null; var cacheCheck = function () { if (cache_length === CACHE_MAX) { // kill several keys, don't want to have to do this all the time... for (var i=0; i < 10; i++) { var key = cache_keys.shift(); if (key) { delete cache[key]; cache_length--; } } } }; return function (s) { cacheCheck(); try { r = cache[s] = (cache[s] || rule.call(this, s)); } catch (e) { r = cache[s] = e; } cache_length++; cache_keys.push(s); if (r instanceof $P.Exception) { throw r; } else { return r; } }; }, // vector operators -- see below any: function () { var px = arguments; return function (s) { var r = null; for (var i = 0; i < px.length; i++) { if (px[i] == null) { continue; } try { r = (px[i].call(this, s)); } catch (e) { r = null; } if (r) { return r; } } throw new $P.Exception(s); }; }, each: function () { var px = arguments; return function (s) { var rx = [], r = null; for (var i = 0; i < px.length ; i++) { if (px[i] == null) { continue; } try { r = (px[i].call(this, s)); } catch (e) { throw new $P.Exception(s); } rx.push(r[0]); s = r[1]; } return [ rx, s]; }; }, all: function () { var px = arguments, _ = _; return _.each(_.optional(px)); }, // delimited operators sequence: function (px, d, c) { d = d || _.rtoken(/^\s*/); c = c || null; if (px.length === 1) { return px[0]; } return function (s) { var r = null, q = null; var rx = []; for (var i = 0; i < px.length ; i++) { try { r = px[i].call(this, s); } catch (e) { break; } rx.push(r[0]); try { q = d.call(this, r[1]); } catch (ex) { q = null; break; } s = q[1]; } if (!r) { throw new $P.Exception(s); } if (q) { throw new $P.Exception(q[1]); } if (c) { try { r = c.call(this, r[1]); } catch (ey) { throw new $P.Exception(r[1]); } } return [ rx, (r?r[1]:s) ]; }; }, // // Composite Operators // between: function (d1, p, d2) { d2 = d2 || d1; var _fn = _.each(_.ignore(d1), p, _.ignore(d2)); return function (s) { var rx = _fn.call(this, s); return [[rx[0][0], r[0][2]], rx[1]]; }; }, list: function (p, d, c) { d = d || _.rtoken(/^\s*/); c = c || null; return (p instanceof Array ? _.each(_.product(p.slice(0, -1), _.ignore(d)), p.slice(-1), _.ignore(c)) : _.each(_.many(_.each(p, _.ignore(d))), px, _.ignore(c))); }, set: function (px, d, c) { d = d || _.rtoken(/^\s*/); c = c || null; return function (s) { // r is the current match, best the current 'best' match // which means it parsed the most amount of input var r = null, p = null, q = null, rx = null, best = [[], s], last = false; // go through the rules in the given set for (var i = 0; i < px.length ; i++) { // last is a flag indicating whether this must be the last element // if there is only 1 element, then it MUST be the last one q = null; p = null; r = null; last = (px.length === 1); // first, we try simply to match the current pattern // if not, try the next pattern try { r = px[i].call(this, s); } catch (e) { continue; } // since we are matching against a set of elements, the first // thing to do is to add r[0] to matched elements rx = [[r[0]], r[1]]; // if we matched and there is still input to parse and // we don't already know this is the last element, // we're going to next check for the delimiter ... // if there's none, or if there's no input left to parse // than this must be the last element after all ... if (r[1].length > 0 && ! last) { try { q = d.call(this, r[1]); } catch (ex) { last = true; } } else { last = true; } // if we parsed the delimiter and now there's no more input, // that means we shouldn't have parsed the delimiter at all // so don't update r and mark this as the last element ... if (!last && q[1].length === 0) { last = true; } // so, if this isn't the last element, we're going to see if // we can get any more matches from the remaining (unmatched) // elements ... if (!last) { // build a list of the remaining rules we can match against, // i.e., all but the one we just matched against var qx = []; for (var j = 0; j < px.length ; j++) { if (i !== j) { qx.push(px[j]); } } // now invoke recursively set with the remaining input // note that we don't include the closing delimiter ... // we'll check for that ourselves at the end p = _.set(qx, d).call(this, q[1]); // if we got a non-empty set as a result ... // (otw rx already contains everything we want to match) if (p[0].length > 0) { // update current result, which is stored in rx ... // basically, pick up the remaining text from p[1] // and concat the result from p[0] so that we don't // get endless nesting ... rx[0] = rx[0].concat(p[0]); rx[1] = p[1]; } } // at this point, rx either contains the last matched element // or the entire matched set that starts with this element. // now we just check to see if this variation is better than // our best so far, in terms of how much of the input is parsed if (rx[1].length < best[1].length) { best = rx; } // if we've parsed all the input, then we're finished if (best[1].length === 0) { break; } } // so now we've either gone through all the patterns trying them // as the initial match; or we found one that parsed the entire // input string ... // if best has no matches, just return empty set ... if (best[0].length === 0) { return best; } // if a closing delimiter is provided, then we have to check it also if (c) { // we try this even if there is no remaining input because the pattern // may well be optional or match empty input ... try { q = c.call(this, best[1]); } catch (ey) { throw new $P.Exception(best[1]); } // it parsed ... be sure to update the best match remaining input best[1] = q[1]; } // if we're here, either there was no closing delimiter or we parsed it // so now we have the best match; just return it! return best; }; }, forward: function (gr, fname) { return function (s) { return gr[fname].call(this, s); }; }, // // Translation Operators // replace: function (rule, repl) { return function (s) { var r = rule.call(this, s); return [repl, r[1]]; }; }, process: function (rule, fn) { return function (s) { var r = rule.call(this, s); return [fn.call(this, r[0]), r[1]]; }; }, min: function (min, rule) { return function (s) { var rx = rule.call(this, s); if (rx[0].length < min) { throw new $P.Exception(s); } return rx; }; } }; // Generator Operators And Vector Operators // Generators are operators that have a signature of F(R) => R, // taking a given rule and returning another rule, such as // ignore, which parses a given rule and throws away the result. // Vector operators are those that have a signature of F(R1,R2,...) => R, // take a list of rules and returning a new rule, such as each. // Generator operators are converted (via the following _generator // function) into functions that can also take a list or array of rules // and return an array of new rules as though the function had been // called on each rule in turn (which is what actually happens). // This allows generators to be used with vector operators more easily. // Example: // each(ignore(foo, bar)) instead of each(ignore(foo), ignore(bar)) // This also turns generators into vector operators, which allows // constructs like: // not(cache(foo, bar)) var _generator = function (op) { function gen() { var args = null, rx = [], px, i; if (arguments.length > 1) { args = Array.prototype.slice.call(arguments); } else if (arguments[0] instanceof Array) { args = arguments[0]; } if (args) { px = args.shift(); if (px.length > 0) { args.unshift(px[i]); rx.push(op.apply(null, args)); args.shift(); return rx; } } else { return op.apply(null, arguments); } } return gen; }; var gx = "optional not ignore cache".split(/\s/); for (var i = 0 ; i < gx.length ; i++) { _[gx[i]] = _generator(_[gx[i]]); } var _vector = function (op) { return function () { if (arguments[0] instanceof Array) { return op.apply(null, arguments[0]); } else { return op.apply(null, arguments); } }; }; var vx = "each any all".split(/\s/); for (var j = 0 ; j < vx.length ; j++) { _[vx[j]] = _vector(_[vx[j]]); } }()); (function () { var $D = Date; var flattenAndCompact = function (ax) { var rx = []; for (var i = 0; i < ax.length; i++) { if (ax[i] instanceof Array) { rx = rx.concat(flattenAndCompact(ax[i])); } else { if (ax[i]) { rx.push(ax[i]); } } } return rx; }; var parseMeridian = function () { if (this.meridian && (this.hour || this.hour === 0)) { if (this.meridian === "a" && this.hour > 11 && Date.Config.strict24hr){ throw "Invalid hour and meridian combination"; } else if (this.meridian === "p" && this.hour < 12 && Date.Config.strict24hr){ throw "Invalid hour and meridian combination"; } else if (this.meridian === "p" && this.hour < 12) { this.hour = this.hour + 12; } else if (this.meridian === "a" && this.hour === 12) { this.hour = 0; } } }; var setDefaults = function () { var now = new Date(); if ((this.hour || this.minute) && (!this.month && !this.year && !this.day)) { this.day = now.getDate(); } if (!this.year) { this.year = now.getFullYear(); } if (!this.month && this.month !== 0) { this.month = now.getMonth(); } if (!this.day) { this.day = 1; } if (!this.hour) { this.hour = 0; } if (!this.minute) { this.minute = 0; } if (!this.second) { this.second = 0; } if (!this.millisecond) { this.millisecond = 0; } }; var finishUtils = { getToday: function () { if (this.now || "hour minute second".indexOf(this.unit) !== -1) { return new Date(); } else { return $D.today(); } }, setDaysFromWeekday: function (today, orient){ var gap; orient = orient || 1; this.unit = "day"; gap = ($D.getDayNumberFromName(this.weekday) - today.getDay()); this.days = gap ? ((gap + (orient * 7)) % 7) : (orient * 7); return this; }, setMonthsFromMonth: function (today, orient) { var gap; orient = orient || 1; this.unit = "month"; gap = (this.month - today.getMonth()); this.months = gap ? ((gap + (orient * 12)) % 12) : (orient * 12); this.month = null; return this; }, setDMYFromWeekday: function () { var d = Date[this.weekday](); this.day = d.getDate(); if (!this.month) { this.month = d.getMonth(); } this.year = d.getFullYear(); return this; }, setUnitValue: function (orient) { if (!this.value && this.operator && this.operator !== null && this[this.unit + "s"] && this[this.unit + "s"] !== null) { this[this.unit + "s"] = this[this.unit + "s"] + ((this.operator === "add") ? 1 : -1) + (this.value||0) * orient; } else if (this[this.unit + "s"] == null || this.operator != null) { if (!this.value) { this.value = 1; } this[this.unit + "s"] = this.value * orient; } }, generateDateFromWeeks: function () { var weekday = (this.weekday !== undefined) ? this.weekday : "today"; var d = Date[weekday]().addWeeks(this.weeks); if (this.now) { d.setTimeToNow(); } return d; } }; $D.Translator = { hour: function (s) { return function () { this.hour = Number(s); }; }, minute: function (s) { return function () { this.minute = Number(s); }; }, second: function (s) { return function () { this.second = Number(s); }; }, /* for ss.s format */ secondAndMillisecond: function (s) { return function () { var mx = s.match(/^([0-5][0-9])\.([0-9]{1,3})/); this.second = Number(mx[1]); this.millisecond = Number(mx[2]); }; }, meridian: function (s) { return function () { this.meridian = s.slice(0, 1).toLowerCase(); }; }, timezone: function (s) { return function () { var n = s.replace(/[^\d\+\-]/g, ""); if (n.length) { this.timezoneOffset = Number(n); } else { this.timezone = s.toLowerCase(); } }; }, day: function (x) { var s = x[0]; return function () { this.day = Number(s.match(/\d+/)[0]); if (this.day < 1) { throw "invalid day"; } }; }, month: function (s) { return function () { this.month = (s.length === 3) ? "jan feb mar apr may jun jul aug sep oct nov dec".indexOf(s)/4 : Number(s) - 1; if (this.month < 0) { throw "invalid month"; } }; }, year: function (s) { return function () { var n = Number(s); this.year = ((s.length > 2) ? n : (n + (((n + 2000) < Date.CultureInfo.twoDigitYearMax) ? 2000 : 1900))); }; }, rday: function (s) { return function () { switch (s) { case "yesterday": this.days = -1; break; case "tomorrow": this.days = 1; break; case "today": this.days = 0; break; case "now": this.days = 0; this.now = true; break; } }; }, finishExact: function (x) { var d; x = (x instanceof Array) ? x : [x]; for (var i = 0 ; i < x.length ; i++) { if (x[i]) { x[i].call(this); } } setDefaults.call(this); parseMeridian.call(this); if (this.day > $D.getDaysInMonth(this.year, this.month)) { throw new RangeError(this.day + " is not a valid value for days."); } d = new Date(this.year, this.month, this.day, this.hour, this.minute, this.second, this.millisecond); if (this.year < 100) { d.setFullYear(this.year); // means years less that 100 are process correctly. JS will parse it otherwise as 1900-1999. } if (this.timezone) { d.set({ timezone: this.timezone }); } else if (this.timezoneOffset) { d.set({ timezoneOffset: this.timezoneOffset }); } return d; }, finish: function (x) { var today, expression, orient, temp; x = (x instanceof Array) ? flattenAndCompact(x) : [ x ]; if (x.length === 0) { return null; } for (var i = 0 ; i < x.length ; i++) { if (typeof x[i] === "function") { x[i].call(this); } } if (this.now && !this.unit && !this.operator) { return new Date(); } else { today = finishUtils.getToday.call(this); } expression = !!(this.days && this.days !== null || this.orient || this.operator); orient = ((this.orient === "past" || this.operator === "subtract") ? -1 : 1); if (this.month && this.unit === "week") { this.value = this.month + 1; delete this.month; delete this.day; } if ((this.month || this.month === 0) && "year day hour minute second".indexOf(this.unit) !== -1) { if (!this.value) { this.value = this.month + 1; } this.month = null; expression = true; } if (!expression && this.weekday && !this.day && !this.days) { finishUtils.setDMYFromWeekday.call(this); } if (expression && this.weekday && this.unit !== "month" && this.unit !== "week") { finishUtils.setDaysFromWeekday.call(this, today, orient); } if (this.weekday && this.unit !== "week" && !this.day && !this.days) { temp = Date[this.weekday](); this.day = temp.getDate(); if (temp.getMonth() !== today.getMonth()) { this.month = temp.getMonth(); } } if (this.month && this.unit === "day" && this.operator) { if (!this.value) { this.value = (this.month + 1); } this.month = null; } if (this.value != null && this.month != null && this.year != null) { this.day = this.value * 1; } if (this.month && !this.day && this.value) { today.set({ day: this.value * 1 }); if (!expression) { this.day = this.value * 1; } } if (!this.month && this.value && this.unit === "month" && !this.now) { this.month = this.value; expression = true; } if (expression && (this.month || this.month === 0) && this.unit !== "year") { finishUtils.setMonthsFromMonth.call(this, today, orient); } if (!this.unit) { this.unit = "day"; } finishUtils.setUnitValue.call(this, orient); parseMeridian.call(this); if ((this.month || this.month === 0) && !this.day) { this.day = 1; } if (!this.orient && !this.operator && this.unit === "week" && this.value && !this.day && !this.month) { return Date.today().setWeek(this.value); } if (this.unit === "week" && this.weeks && !this.day && !this.month) { return finishUtils.generateDateFromWeeks.call(this); } if (expression && this.timezone && this.day && this.days) { this.day = this.days; } if (expression){ today.add(this); } else { today.set(this); } if (this.timezone) { this.timezone = this.timezone.toUpperCase(); var offset = $D.getTimezoneOffset(this.timezone); var timezone; if (today.hasDaylightSavingTime()) { // lets check that we're being sane with timezone setting timezone = $D.getTimezoneAbbreviation(offset, today.isDaylightSavingTime()); if (timezone !== this.timezone) { // bugger, we're in a place where things like EST vs EDT matters. if (today.isDaylightSavingTime()) { today.addHours(-1); } else { today.addHours(1); } } } today.setTimezoneOffset(offset); } return today; } }; }()); (function () { var $D = Date; $D.Grammar = {}; var _ = $D.Parsing.Operators, g = $D.Grammar, t = $D.Translator, _fn; // Allow rolling up into general purpose rules _fn = function () { return _.each(_.any.apply(null, arguments), _.not(g.ctoken2("timeContext"))); }; g.datePartDelimiter = _.rtoken(/^([\s\-\.\,\/\x27]+)/); g.timePartDelimiter = _.stoken(":"); g.whiteSpace = _.rtoken(/^\s*/); g.generalDelimiter = _.rtoken(/^(([\s\,]|at|@|on)+)/); var _C = {}; g.ctoken = function (keys) { var fn = _C[keys]; if (! fn) { var c = Date.CultureInfo.regexPatterns; var kx = keys.split(/\s+/), px = []; for (var i = 0; i < kx.length ; i++) { px.push(_.replace(_.rtoken(c[kx[i]]), kx[i])); } fn = _C[keys] = _.any.apply(null, px); } return fn; }; g.ctoken2 = function (key) { return _.rtoken(Date.CultureInfo.regexPatterns[key]); }; var cacheProcessRtoken = function (key, token, type, eachToken) { if (eachToken) { g[key] = _.cache(_.process(_.each(_.rtoken(token),_.optional(g.ctoken2(eachToken))), type)); } else { g[key] = _.cache(_.process(_.rtoken(token), type)); } }; var cacheProcessCtoken = function (token, type) { return _.cache(_.process(g.ctoken2(token), type)); }; var _F = {}; //function cache var _get = function (f) { _F[f] = (_F[f] || g.format(f)[0]); return _F[f]; }; g.allformats = function (fx) { var rx = []; if (fx instanceof Array) { for (var i = 0; i < fx.length; i++) { rx.push(_get(fx[i])); } } else { rx.push(_get(fx)); } return rx; }; g.formats = function (fx) { if (fx instanceof Array) { var rx = []; for (var i = 0 ; i < fx.length ; i++) { rx.push(_get(fx[i])); } return _.any.apply(null, rx); } else { return _get(fx); } }; var grammarFormats = { timeFormats: function(){ var i, RTokenKeys = [ "h", "hh", "H", "HH", "m", "mm", "s", "ss", "ss.s", "z", "zz" ], RToken = [ /^(0[0-9]|1[0-2]|[1-9])/, /^(0[0-9]|1[0-2])/, /^([0-1][0-9]|2[0-3]|[0-9])/, /^([0-1][0-9]|2[0-3])/, /^([0-5][0-9]|[0-9])/, /^[0-5][0-9]/, /^([0-5][0-9]|[0-9])/, /^[0-5][0-9]/, /^[0-5][0-9]\.[0-9]{1,3}/, /^((\+|\-)\s*\d\d\d\d)|((\+|\-)\d\d\:?\d\d)/, /^((\+|\-)\s*\d\d\d\d)|((\+|\-)\d\d\:?\d\d)/ ], tokens = [ t.hour, t.hour, t.hour, t.hour, t.minute, t.minute, t.second, t.second, t.secondAndMillisecond, t.timezone, t.timezone ]; for (i=0; i < RTokenKeys.length; i++) { cacheProcessRtoken(RTokenKeys[i], RToken[i], tokens[i]); } g.hms = _.cache(_.sequence([g.H, g.m, g.s], g.timePartDelimiter)); g.t = cacheProcessCtoken("shortMeridian", t.meridian); g.tt = cacheProcessCtoken("longMeridian", t.meridian); g.zzz = cacheProcessCtoken("timezone", t.timezone); g.timeSuffix = _.each(_.ignore(g.whiteSpace), _.set([ g.tt, g.zzz ])); g.time = _.each(_.optional(_.ignore(_.stoken("T"))), g.hms, g.timeSuffix); }, dateFormats: function () { // pre-loaded rules for different date part order preferences var _setfn = function () { return _.set(arguments, g.datePartDelimiter); }; var i, RTokenKeys = [ "d", "dd", "M", "MM", "y", "yy", "yyy", "yyyy" ], RToken = [ /^([0-2]\d|3[0-1]|\d)/, /^([0-2]\d|3[0-1])/, /^(1[0-2]|0\d|\d)/, /^(1[0-2]|0\d)/, /^(\d+)/, /^(\d\d)/, /^(\d\d?\d?\d?)/, /^(\d\d\d\d)/ ], tokens = [ t.day, t.day, t.month, t.month, t.year, t.year, t.year, t.year ], eachToken = [ "ordinalSuffix", "ordinalSuffix" ]; for (i=0; i < RTokenKeys.length; i++) { cacheProcessRtoken(RTokenKeys[i], RToken[i], tokens[i], eachToken[i]); } g.MMM = g.MMMM = _.cache(_.process(g.ctoken("jan feb mar apr may jun jul aug sep oct nov dec"), t.month)); g.ddd = g.dddd = _.cache(_.process(g.ctoken("sun mon tue wed thu fri sat"), function (s) { return function () { this.weekday = s; }; } )); g.day = _fn(g.d, g.dd); g.month = _fn(g.M, g.MMM); g.year = _fn(g.yyyy, g.yy); g.mdy = _setfn(g.ddd, g.month, g.day, g.year); g.ymd = _setfn(g.ddd, g.year, g.month, g.day); g.dmy = _setfn(g.ddd, g.day, g.month, g.year); g.date = function (s) { return ((g[Date.CultureInfo.dateElementOrder] || g.mdy).call(this, s)); }; }, relative: function () { // relative date / time expressions g.orientation = _.process(g.ctoken("past future"), function (s) { return function () { this.orient = s; }; } ); g.operator = _.process(g.ctoken("add subtract"), function (s) { return function () { this.operator = s; }; } ); g.rday = _.process(g.ctoken("yesterday tomorrow today now"), t.rday); g.unit = _.process(g.ctoken("second minute hour day week month year"), function (s) { return function () { this.unit = s; }; } ); } }; g.buildGrammarFormats = function () { // these need to be rebuilt every time the language changes. _C = {}; grammarFormats.timeFormats(); grammarFormats.dateFormats(); grammarFormats.relative(); g.value = _.process(_.rtoken(/^([-+]?\d+)?(st|nd|rd|th)?/), function (s) { return function () { this.value = s.replace(/\D/g, ""); }; } ); g.expression = _.set([g.rday, g.operator, g.value, g.unit, g.orientation, g.ddd, g.MMM ]); g.format = _.process(_.many( _.any( // translate format specifiers into grammar rules _.process( _.rtoken(/^(dd?d?d?(?!e)|MM?M?M?|yy?y?y?|hh?|HH?|mm?|ss?|tt?|zz?z?)/), function (fmt) { if (g[fmt]) { return g[fmt]; } else { throw $D.Parsing.Exception(fmt); } } ), // translate separator tokens into token rules _.process(_.rtoken(/^[^dMyhHmstz]+/), // all legal separators function (s) { return _.ignore(_.stoken(s)); } ) ) ), // construct the parser ... function (rules) { return _.process(_.each.apply(null, rules), t.finishExact); } ); // starting rule for general purpose grammar g._start = _.process(_.set([ g.date, g.time, g.expression ], g.generalDelimiter, g.whiteSpace), t.finish); }; g.buildGrammarFormats(); // parsing date format specifiers - ex: "h:m:s tt" // this little guy will generate a custom parser based // on the format string, ex: g.format("h:m:s tt") // check for these formats first g._formats = g.formats([ "\"yyyy-MM-ddTHH:mm:ssZ\"", "yyyy-MM-ddTHH:mm:ss.sz", "yyyy-MM-ddTHH:mm:ssZ", "yyyy-MM-ddTHH:mm:ssz", "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-ddTHH:mmZ", "yyyy-MM-ddTHH:mmz", "yyyy-MM-ddTHH:mm", "ddd, MMM dd, yyyy H:mm:ss tt", "ddd MMM d yyyy HH:mm:ss zzz", "MMddyyyy", "ddMMyyyy", "Mddyyyy", "ddMyyyy", "Mdyyyy", "dMyyyy", "yyyy", "Mdyy", "dMyy", "d" ]); // real starting rule: tries selected formats first, // then general purpose rule g.start = function (s) { try { var r = g._formats.call({}, s); if (r[1].length === 0) { return r; } } catch (e) {} return g._start.call({}, s); }; }()); (function () { var $D = Date; /** * @desc Converts the specified string value into its JavaScript Date equivalent using CultureInfo specific format information. * * Example

	///////////
	// Dates //
	///////////

	// 15-Oct-2004
	var d1 = Date.parse("10/15/2004");

	// 15-Oct-2004
	var d1 = Date.parse("15-Oct-2004");

	// 15-Oct-2004
	var d1 = Date.parse("2004.10.15");

	//Fri Oct 15, 2004
	var d1 = Date.parse("Fri Oct 15, 2004");

	///////////
	// Times //
	///////////

	// Today at 10 PM.
	var d1 = Date.parse("10 PM");

	// Today at 10:30 PM.
	var d1 = Date.parse("10:30 P.M.");

	// Today at 6 AM.
	var d1 = Date.parse("06am");

	/////////////////////
	// Dates and Times //
	/////////////////////

	// 8-July-2004 @ 10:30 PM
	var d1 = Date.parse("July 8th, 2004, 10:30 PM");

	// 1-July-2004 @ 10:30 PM
	var d1 = Date.parse("2004-07-01T22:30:00");

	////////////////////
	// Relative Dates //
	////////////////////

	// Returns today's date. The string "today" is culture specific.
	var d1 = Date.parse("today");

	// Returns yesterday's date. The string "yesterday" is culture specific.
	var d1 = Date.parse("yesterday");

	// Returns the date of the next thursday.
	var d1 = Date.parse("Next thursday");

	// Returns the date of the most previous monday.
	var d1 = Date.parse("last monday");

	// Returns today's day + one year.
	var d1 = Date.parse("next year");

	///////////////
	// Date Math //
	///////////////

	// Today + 2 days
	var d1 = Date.parse("t+2");

	// Today + 2 days
	var d1 = Date.parse("today + 2 days");

	// Today + 3 months
	var d1 = Date.parse("t+3m");

	// Today - 1 year
	var d1 = Date.parse("today - 1 year");

	// Today - 1 year
	var d1 = Date.parse("t-1y"); 


	/////////////////////////////
	// Partial Dates and Times //
	/////////////////////////////

	// July 15th of this year.
	var d1 = Date.parse("July 15");

	// 15th day of current day and year.
	var d1 = Date.parse("15");

	// July 1st of current year at 10pm.
	var d1 = Date.parse("7/1 10pm");
	
* * @param {String} The string value to convert into a Date object [Required] * @return {Date} A Date object or null if the string cannot be converted into a Date. */ var parseUtils = { removeOrds: function (s) { ords = s.match(/\b(\d+)(?:st|nd|rd|th)\b/); // find ordinal matches s = ((ords && ords.length === 2) ? s.replace(ords[0], ords[1]) : s); return s; }, grammarParser: function (s) { var r = null; try { r = $D.Grammar.start.call({}, s.replace(/^\s*(\S*(\s+\S+)*)\s*$/, "$1")); } catch (e) { return null; } return ((r[1].length === 0) ? r[0] : null); }, nativeFallback: function(s) { var t; try { // ok we haven't parsed it, last ditch attempt with the built-in parser. t = Date._parse(s); return (t || t === 0) ? new Date(t) : null; } catch (e) { return null; } } }; function parse (s) { var d; if (!s) { return null; } if (s instanceof Date) { return s.clone(); } if (s.length >= 4 && s.charAt(0) !== "0" && s.charAt(0) !== "+"&& s.charAt(0) !== "-") { // ie: 2004 will pass, 0800 won't. // Start with specific formats d = $D.Parsing.ISO.parse(s) || $D.Parsing.Numeric.parse(s); } if (d instanceof Date && !isNaN(d.getTime())) { return d; } else { // find ordinal dates (1st, 3rd, 8th, etc and remove them as they cause parsing issues) s = $D.Parsing.Normalizer.parse(parseUtils.removeOrds(s)); d = parseUtils.grammarParser(s); if (d !== null) { return d; } else { return parseUtils.nativeFallback(s); } } } if (!$D._parse) { $D._parse = $D.parse; } $D.parse = parse; Date.getParseFunction = function (fx) { var fns = Date.Grammar.allformats(fx); return function (s) { var r = null; for (var i = 0; i < fns.length; i++) { try { r = fns[i].call({}, s); } catch (e) { continue; } if (r[1].length === 0) { return r[0]; } } return null; }; }; /** * Converts the specified string value into its JavaScript Date equivalent using the specified format {String} or formats {Array} and the CultureInfo specific format information. * The format of the string value must match one of the supplied formats exactly. * * Example

	// 15-Oct-2004
	var d1 = Date.parseExact("10/15/2004", "M/d/yyyy");

	// 15-Oct-2004
	var d1 = Date.parse("15-Oct-2004", "M-ddd-yyyy");

	// 15-Oct-2004
	var d1 = Date.parse("2004.10.15", "yyyy.MM.dd");

	// Multiple formats
	var d1 = Date.parseExact("10/15/2004", ["M/d/yyyy", "MMMM d, yyyy"]);
	
* * @param {String} The string value to convert into a Date object [Required]. * @param {Object} The expected format {String} or an array of expected formats {Array} of the date string [Required]. * @return {Date} A Date object or null if the string cannot be converted into a Date. */ $D.parseExact = function (s, fx) { return $D.getParseFunction(fx)(s); }; }()); (function () { var $D = Date, $P = $D.prototype, // $C = $D.CultureInfo, // not used atm p = function (s, l) { if (!l) { l = 2; } return ("000" + s).slice(l * -1); }; /** * Converts a PHP format string to Java/.NET format string. * A PHP format string can be used with ._format or .format. * A Java/.NET format string can be used with .toString(). * The .parseExact function will only accept a Java/.NET format string * * Example * var f1 = "%m/%d/%y" * var f2 = Date.normalizeFormat(f1); // "MM/dd/yy" * * new Date().format(f1); // "04/13/08" * new Date()._format(f1); // "04/13/08" * new Date().toString(f2); // "04/13/08" * * var date = Date.parseExact("04/13/08", f2); // Sun Apr 13 2008 * * @param {String} A PHP format string consisting of one or more format spcifiers. * @return {String} The PHP format converted to a Java/.NET format string. */ var normalizerSubstitutions = { "d" : "dd", "%d": "dd", "D" : "ddd", "%a": "ddd", "j" : "dddd", "l" : "dddd", "%A": "dddd", "S" : "S", "F" : "MMMM", "%B": "MMMM", "m" : "MM", "%m": "MM", "M" : "MMM", "%b": "MMM", "%h": "MMM", "n" : "M", "Y" : "yyyy", "%Y": "yyyy", "y" : "yy", "%y": "yy", "g" : "h", "%I": "h", "G" : "H", "h" : "hh", "H" : "HH", "%H": "HH", "i" : "mm", "%M": "mm", "s" : "ss", "%S": "ss", "%r": "hh:mm tt", "%R": "H:mm", "%T": "H:mm:ss", "%X": "t", "%x": "d", "%e": "d", "%D": "MM/dd/yy", "%n": "\\n", "%t": "\\t", "e" : "z", "T" : "z", "%z": "z", "%Z": "z", "Z" : "ZZ", "N" : "u", "w" : "u", "%w": "u", "W" : "W", "%V": "W" }; var normalizer = { substitutes: function (m) { return normalizerSubstitutions[m]; }, interpreted: function (m, x) { var y; switch (m) { case "%u": return x.getDay() + 1; case "z": return x.getOrdinalNumber(); case "%j": return p(x.getOrdinalNumber(), 3); case "%U": var d1 = x.clone().set({month: 0, day: 1}).addDays(-1).moveToDayOfWeek(0), d2 = x.clone().addDays(1).moveToDayOfWeek(0, -1); return (d2 < d1) ? "00" : p((d2.getOrdinalNumber() - d1.getOrdinalNumber()) / 7 + 1); case "%W": return p(x.getWeek()); case "t": return $D.getDaysInMonth(x.getFullYear(), x.getMonth()); case "o": case "%G": return x.setWeek(x.getISOWeek()).toString("yyyy"); case "%g": return x._format("%G").slice(-2); case "a": case "%p": return t("tt").toLowerCase(); case "A": return t("tt").toUpperCase(); case "u": return p(x.getMilliseconds(), 3); case "I": return (x.isDaylightSavingTime()) ? 1 : 0; case "O": return x.getUTCOffset(); case "P": y = x.getUTCOffset(); return y.substring(0, y.length - 2) + ":" + y.substring(y.length - 2); case "B": var now = new Date(); return Math.floor(((now.getHours() * 3600) + (now.getMinutes() * 60) + now.getSeconds() + (now.getTimezoneOffset() + 60) * 60) / 86.4); case "c": return x.toISOString().replace(/\"/g, ""); case "U": return $D.strtotime("now"); case "%c": return t("d") + " " + t("t"); case "%C": return Math.floor(x.getFullYear() / 100 + 1); } }, shouldOverrideDefaults: function (m) { switch (m) { case "%e": return true; default: return false; } }, parse: function (m, context) { var formatString, c = context || new Date(); formatString = normalizer.substitutes(m); if (formatString) { return formatString; } formatString = normalizer.interpreted(m, c); if (formatString) { return formatString; } else { return m; } } }; $D.normalizeFormat = function (format, context) { return format.replace(/(%|\\)?.|%%/g, function(t){ return normalizer.parse(t, context); }); }; /** * Format a local Unix timestamp according to locale settings * * Example: * Date.strftime("%m/%d/%y", new Date()); // "04/13/08" * Date.strftime("c", "2008-04-13T17:52:03Z"); // "04/13/08" * * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @param {Number|String} The number representing the number of seconds that have elapsed since January 1, 1970 (local time). * @return {String} A string representation of the current Date object. */ $D.strftime = function (format, time) { var d = Date.parse(time); return d._format(format); }; /** * Parse any textual datetime description into a Unix timestamp. * A Unix timestamp is the number of seconds that have elapsed since January 1, 1970 (midnight UTC/GMT). * * Example: * Date.strtotime("04/13/08"); // 1208044800 * Date.strtotime("1970-01-01T00:00:00Z"); // 0 * * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @param {Object} A string or date object. * @return {String} A string representation of the current Date object. */ $D.strtotime = function (time) { var d = $D.parse(time); return Math.round($D.UTC(d.getUTCFullYear(), d.getUTCMonth(), d.getUTCDate(), d.getUTCHours(), d.getUTCMinutes(), d.getUTCSeconds(), d.getUTCMilliseconds()) / 1000); }; /** * Converts the value of the current Date object to its equivalent string representation using a PHP/Unix style of date format specifiers. * Format Specifiers * Format Description Example * ------ --------------------------------------------------------------------------- ----------------------- * %a abbreviated weekday name according to the current localed "Mon" through "Sun" * %A full weekday name according to the current localed "Sunday" through "Saturday" * %b abbreviated month name according to the current localed "Jan" through "Dec" * %B full month name according to the current locale "January" through "December" * %c preferred date and time representation for the current locale "4/13/2008 12:33 PM" * %C century number (the year divided by 100 and truncated to an integer) "00" to "99" * %d day of the month as a decimal number "01" to "31" * %D same as %m/%d/%y "04/13/08" * %e day of the month as a decimal number, a single digit is preceded by a space "1" to "31" * %g like %G, but without the century "08" * %G The 4-digit year corresponding to the ISO week number (see %V). "2008" * This has the same format and value as %Y, except that if the ISO week number * belongs to the previous or next year, that year is used instead. * %h same as %b "Jan" through "Dec" * %H hour as a decimal number using a 24-hour clock. "00" to "23" * %I hour as a decimal number using a 12-hour clock. "01" to "12" * %j day of the year as a decimal number. "001" to "366" * %m month as a decimal number. "01" to "12" * %M minute as a decimal number. "00" to "59" * %n newline character "\n" * %p either "am" or "pm" according to the given time value, or the "am" or "pm" * corresponding strings for the current locale. * %r time in a.m. and p.m. notation "8:44 PM" * %R time in 24 hour notation "20:44" * %S second as a decimal number "00" to "59" * %t tab character "\t" * %T current time, equal to %H:%M:%S "12:49:11" * %u weekday as a decimal number ["1", "7"], with "1" representing Monday "1" to "7" * %U week number of the current year as a decimal number, starting with the "0" to ("52" or "53") * first Sunday as the first day of the first week * %V The ISO 8601:1988 week number of the current year as a decimal number, "00" to ("52" or "53") * range 01 to 53, where week 1 is the first week that has at least 4 days * in the current year, and with Monday as the first day of the week. * (Use %G or %g for the year component that corresponds to the week number * for the specified timestamp.) * %W week number of the current year as a decimal number, starting with the "00" to ("52" or "53") * first Monday as the first day of the first week * %w day of the week as a decimal, Sunday being "0" "0" to "6" * %x preferred date representation for the current locale without the time "4/13/2008" * %X preferred time representation for the current locale without the date "12:53:05" * %y year as a decimal number without a century "00" "99" * %Y year as a decimal number including the century "2008" * %Z time zone or name or abbreviation "UTC", "EST", "PST" * %z same as %Z * %% a literal "%" characters "%" * d Day of the month, 2 digits with leading zeros "01" to "31" * D A textual representation of a day, three letters "Mon" through "Sun" * j Day of the month without leading zeros "1" to "31" * l A full textual representation of the day of the week (lowercase "L") "Sunday" through "Saturday" * N ISO-8601 numeric representation of the day of the week (added in PHP 5.1.0) "1" (for Monday) through "7" (for Sunday) * S English ordinal suffix for the day of the month, 2 characters "st", "nd", "rd" or "th". Works well with j * w Numeric representation of the day of the week "0" (for Sunday) through "6" (for Saturday) * z The day of the year (starting from "0") "0" through "365" * W ISO-8601 week number of year, weeks starting on Monday "00" to ("52" or "53") * F A full textual representation of a month, such as January or March "January" through "December" * m Numeric representation of a month, with leading zeros "01" through "12" * M A short textual representation of a month, three letters "Jan" through "Dec" * n Numeric representation of a month, without leading zeros "1" through "12" * t Number of days in the given month "28" through "31" * L Whether it's a leap year "1" if it is a leap year, "0" otherwise * o ISO-8601 year number. This has the same value as Y, except that if the "2008" * ISO week number (W) belongs to the previous or next year, that year * is used instead. * Y A full numeric representation of a year, 4 digits "2008" * y A two digit representation of a year "08" * a Lowercase Ante meridiem and Post meridiem "am" or "pm" * A Uppercase Ante meridiem and Post meridiem "AM" or "PM" * B Swatch Internet time "000" through "999" * g 12-hour format of an hour without leading zeros "1" through "12" * G 24-hour format of an hour without leading zeros "0" through "23" * h 12-hour format of an hour with leading zeros "01" through "12" * H 24-hour format of an hour with leading zeros "00" through "23" * i Minutes with leading zeros "00" to "59" * s Seconds, with leading zeros "00" through "59" * u Milliseconds "54321" * e Timezone identifier "UTC", "EST", "PST" * I Whether or not the date is in daylight saving time (uppercase i) "1" if Daylight Saving Time, "0" otherwise * O Difference to Greenwich time (GMT) in hours "+0200", "-0600" * P Difference to Greenwich time (GMT) with colon between hours and minutes "+02:00", "-06:00" * T Timezone abbreviation "UTC", "EST", "PST" * Z Timezone offset in seconds. The offset for timezones west of UTC is "-43200" through "50400" * always negative, and for those east of UTC is always positive. * c ISO 8601 date "2004-02-12T15:19:21+00:00" * r RFC 2822 formatted date "Thu, 21 Dec 2000 16:01:07 +0200" * U Seconds since the Unix Epoch (January 1 1970 00:00:00 GMT) "0" * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @return {String} A string representation of the current Date object. */ var formatReplace = function (context) { return function (m) { var formatString, override = false; if (m.charAt(0) === "\\" || m.substring(0, 2) === "%%") { return m.replace("\\", "").replace("%%", "%"); } override = normalizer.shouldOverrideDefaults(m); formatString = $D.normalizeFormat(m, context); if (formatString) { return context.toString(formatString, override); } }; }; $P._format = function (format) { var formatter = formatReplace(this); if (!format) { return this._toString(); } else { return format.replace(/(%|\\)?.|%%/g, formatter); } }; if (!$P.format) { $P.format = $P._format; } }()); (function () { "use strict"; var gFn = function (attr) { return function () { return this[attr]; }; }; var sFn = function (attr) { return function (val) { this[attr] = val; return this; }; }; var attrs = ["years", "months", "days", "hours", "minutes", "seconds", "milliseconds"]; var addSetFuncs = function (context, attrs) { for (var i = 0; i < attrs.length ; i++) { var $a = attrs[i], $b = $a.slice(0, 1).toUpperCase() + $a.slice(1); context.prototype[$a] = 0; context.prototype["get" + $b] = gFn($a); context.prototype["set" + $b] = sFn($a); } }; /** * new TimeSpan(milliseconds); * new TimeSpan(days, hours, minutes, seconds); * new TimeSpan(days, hours, minutes, seconds, milliseconds); */ var TimeSpan = function (days, hours, minutes, seconds, milliseconds) { if (arguments.length === 1 && typeof days === "number") { var orient = (days < 0) ? -1 : +1; var millsLeft = Math.abs(days); this.setDays(Math.floor(millsLeft / 86400000) * orient); millsLeft = millsLeft % 86400000; this.setHours(Math.floor(millsLeft / 3600000) * orient); millsLeft = millsLeft % 3600000; this.setMinutes(Math.floor(millsLeft / 60000) * orient); millsLeft = millsLeft % 60000; this.setSeconds(Math.floor(millsLeft / 1000) * orient); millsLeft = millsLeft % 1000; this.setMilliseconds(millsLeft * orient); } else { this.set(days, hours, minutes, seconds, milliseconds); } this.getTotalMilliseconds = function () { return (this.getDays() * 86400000) + (this.getHours() * 3600000) + (this.getMinutes() * 60000) + (this.getSeconds() * 1000); }; this.compareTo = function (time) { var t1 = new Date(1970, 1, 1, this.getHours(), this.getMinutes(), this.getSeconds()), t2; if (time === null) { t2 = new Date(1970, 1, 1, 0, 0, 0); } else { t2 = new Date(1970, 1, 1, time.getHours(), time.getMinutes(), time.getSeconds()); } return (t1 < t2) ? -1 : (t1 > t2) ? 1 : 0; }; this.equals = function (time) { return (this.compareTo(time) === 0); }; this.add = function (time) { return (time === null) ? this : this.addSeconds(time.getTotalMilliseconds() / 1000); }; this.subtract = function (time) { return (time === null) ? this : this.addSeconds(-time.getTotalMilliseconds() / 1000); }; this.addDays = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 86400000)); }; this.addHours = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 3600000)); }; this.addMinutes = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 60000)); }; this.addSeconds = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 1000)); }; this.addMilliseconds = function (n) { return new TimeSpan(this.getTotalMilliseconds() + n); }; this.get12HourHour = function () { return (this.getHours() > 12) ? this.getHours() - 12 : (this.getHours() === 0) ? 12 : this.getHours(); }; this.getDesignator = function () { return (this.getHours() < 12) ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator; }; this.toString = function (format) { this._toString = function () { if (this.getDays() !== null && this.getDays() > 0) { return this.getDays() + "." + this.getHours() + ":" + this.p(this.getMinutes()) + ":" + this.p(this.getSeconds()); } else { return this.getHours() + ":" + this.p(this.getMinutes()) + ":" + this.p(this.getSeconds()); } }; this.p = function (s) { return (s.toString().length < 2) ? "0" + s : s; }; var me = this; return format ? format.replace(/dd?|HH?|hh?|mm?|ss?|tt?/g, function (format) { switch (format) { case "d": return me.getDays(); case "dd": return me.p(me.getDays()); case "H": return me.getHours(); case "HH": return me.p(me.getHours()); case "h": return me.get12HourHour(); case "hh": return me.p(me.get12HourHour()); case "m": return me.getMinutes(); case "mm": return me.p(me.getMinutes()); case "s": return me.getSeconds(); case "ss": return me.p(me.getSeconds()); case "t": return ((me.getHours() < 12) ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator).substring(0, 1); case "tt": return (me.getHours() < 12) ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator; } } ) : this._toString(); }; return this; }; addSetFuncs(TimeSpan, attrs.slice(2)); TimeSpan.prototype.set = function (days, hours, minutes, seconds, milliseconds){ this.setDays(days || this.getDays()); this.setHours(hours || this.getHours()); this.setMinutes(minutes || this.getMinutes()); this.setSeconds(seconds || this.getSeconds()); this.setMilliseconds(milliseconds || this.getMilliseconds()); }; /** * Gets the time of day for this date instances. * @return {TimeSpan} TimeSpan */ Date.prototype.getTimeOfDay = function () { return new TimeSpan(0, this.getHours(), this.getMinutes(), this.getSeconds(), this.getMilliseconds()); }; Date.TimeSpan = TimeSpan; if (typeof window !== "undefined" ) { // keeping API compatible for v1.x window.TimeSpan = TimeSpan; } }()); (function () { "use strict"; var attrs = ["years", "months", "days", "hours", "minutes", "seconds", "milliseconds"]; var gFn = function (attr) { return function () { return this[attr]; }; }; var sFn = function (attr) { return function (val) { this[attr] = val; return this; }; }; var addSetFuncs = function (context, attrs) { for (var i = 0; i < attrs.length ; i++) { var $a = attrs[i], $b = $a.slice(0, 1).toUpperCase() + $a.slice(1); context.prototype[$a] = 0; context.prototype["get" + $b] = gFn($a); context.prototype["set" + $b] = sFn($a); } }; var setMonthsAndYears = function (orient, d1, d2, context) { function inc() { d1.addMonths(-orient); context.months++; if (context.months === 12) { context.years++; context.months = 0; } } if (orient === +1) { while (d1 > d2) { inc(); } } else { while (d1 < d2) { inc(); } } context.months--; context.months *= orient; context.years *= orient; }; var adjustForDST = function(orient, startDate, endDate) { var hasDSTMismatch = (false === (startDate.isDaylightSavingTime() === endDate.isDaylightSavingTime())); if (hasDSTMismatch && orient === 1) { startDate.addHours(-1); } else if (hasDSTMismatch) { startDate.addHours(1); } }; /** * TimePeriod(startDate, endDate); * TimePeriod(years, months, days, hours, minutes, seconds, milliseconds); */ var TimePeriod = function (years, months, days, hours, minutes, seconds, milliseconds) { if (arguments.length === 7) { this.set(years, months, days, hours, minutes, seconds, milliseconds); } else if (arguments.length === 2 && arguments[0] instanceof Date && arguments[1] instanceof Date) { var startDate = arguments[0].clone(); var endDate = arguments[1].clone(); var orient = (startDate > endDate) ? +1 : -1; this.dates = { start: arguments[0].clone(), end: arguments[1].clone() }; setMonthsAndYears(orient, startDate, endDate, this); adjustForDST(orient, startDate, endDate); // // TODO - adjust for DST var diff = endDate - startDate; if (diff !== 0) { var ts = new TimeSpan(diff); this.set(this.years, this.months, ts.getDays(), ts.getHours(), ts.getMinutes(), ts.getSeconds(), ts.getMilliseconds()); } } return this; }; // create all the set functions. addSetFuncs(TimePeriod, attrs); TimePeriod.prototype.set = function (years, months, days, hours, minutes, seconds, milliseconds){ this.setYears(years || this.getYears()); this.setMonths(months || this.getMonths()); this.setDays(days || this.getDays()); this.setHours(hours || this.getHours()); this.setMinutes(minutes || this.getMinutes()); this.setSeconds(seconds || this.getSeconds()); this.setMilliseconds(milliseconds || this.getMilliseconds()); }; Date.TimePeriod = TimePeriod; if (typeof window !== "undefined") { // keeping API compatible for v1.x window.TimePeriod = TimePeriod; } }()); ================================================ FILE: build/date-fr-CH.js ================================================ /** * @overview datejs * @version 1.0.0-rc3 * @author Gregory Wild-Smith * @copyright 2015 Gregory Wild-Smith * @license MIT * @homepage https://github.com/abritinthebay/datejs */ /* * DateJS Culture String File * Country Code: fr-CH * Name: French (Switzerland) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["fr-CH"] = { "name": "fr-CH", "englishName": "French (Switzerland)", "nativeName": "français (Suisse)", "Sunday": "dimanche", "Monday": "lundi", "Tuesday": "mardi", "Wednesday": "mercredi", "Thursday": "jeudi", "Friday": "vendredi", "Saturday": "samedi", "Sun": "dim.", "Mon": "lun.", "Tue": "mar.", "Wed": "mer.", "Thu": "jeu.", "Fri": "ven.", "Sat": "sam.", "Su": "di", "Mo": "lu", "Tu": "ma", "We": "me", "Th": "je", "Fr": "ve", "Sa": "sa", "S_Sun_Initial": "d", "M_Mon_Initial": "l", "T_Tue_Initial": "m", "W_Wed_Initial": "m", "T_Thu_Initial": "j", "F_Fri_Initial": "v", "S_Sat_Initial": "s", "January": "janvier", "February": "février", "March": "mars", "April": "avril", "May": "mai", "June": "juin", "July": "juillet", "August": "août", "September": "septembre", "October": "octobre", "November": "novembre", "December": "décembre", "Jan_Abbr": "janv.", "Feb_Abbr": "févr.", "Mar_Abbr": "mars", "Apr_Abbr": "avr.", "May_Abbr": "mai", "Jun_Abbr": "juin", "Jul_Abbr": "juil.", "Aug_Abbr": "août", "Sep_Abbr": "sept.", "Oct_Abbr": "oct.", "Nov_Abbr": "nov.", "Dec_Abbr": "déc.", "AM": "", "PM": "", "firstDayOfWeek": 1, "twoDigitYearMax": 2029, "mdy": "dmy", "M/d/yyyy": "dd.MM.yyyy", "dddd, MMMM dd, yyyy": "dddd, d. MMMM yyyy", "h:mm tt": "HH:mm", "h:mm:ss tt": "HH:mm:ss", "dddd, MMMM dd, yyyy h:mm:ss tt": "dddd, d. MMMM yyyy HH:mm:ss", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "d MMMM", "MMMM, yyyy": "MMMM yyyy", "/jan(uary)?/": "janv(.(ier)?)?", "/feb(ruary)?/": "févr(.(ier)?)?", "/mar(ch)?/": "mars", "/apr(il)?/": "avr(.(il)?)?", "/may/": "mai", "/jun(e)?/": "juin", "/jul(y)?/": "juil(.(let)?)?", "/aug(ust)?/": "août", "/sep(t(ember)?)?/": "sept(.(embre)?)?", "/oct(ober)?/": "oct(.(obre)?)?", "/nov(ember)?/": "nov(.(embre)?)?", "/dec(ember)?/": "déc(.(embre)?)?", "/^su(n(day)?)?/": "^di(m(.(anche)?)?)?", "/^mo(n(day)?)?/": "^lu(n(.(di)?)?)?", "/^tu(e(s(day)?)?)?/": "^ma(r(.(di)?)?)?", "/^we(d(nesday)?)?/": "^me(r(.(credi)?)?)?", "/^th(u(r(s(day)?)?)?)?/": "^je(u(.(di)?)?)?", "/^fr(i(day)?)?/": "^ve(n(.(dredi)?)?)?", "/^sa(t(urday)?)?/": "^sa(m(.(edi)?)?)?", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "fr-CH"; /** * @overview datejs * @version 1.0.0-rc3 * @author Gregory Wild-Smith * @copyright 2015 Gregory Wild-Smith * @license MIT * @homepage https://github.com/abritinthebay/datejs */(function () { var $D = Date; var lang = Date.CultureStrings ? Date.CultureStrings.lang : null; var loggedKeys = {}; // for debug purposes. var getText = { getFromKey: function (key, countryCode) { var output; if (Date.CultureStrings && Date.CultureStrings[countryCode] && Date.CultureStrings[countryCode][key]) { output = Date.CultureStrings[countryCode][key]; } else { output = getText.buildFromDefault(key); } if (key.charAt(0) === "/") { // Assume it's a regex output = getText.buildFromRegex(key, countryCode); } return output; }, getFromObjectValues: function (obj, countryCode) { var key, output = {}; for(key in obj) { if (obj.hasOwnProperty(key)) { output[key] = getText.getFromKey(obj[key], countryCode); } } return output; }, getFromObjectKeys: function (obj, countryCode) { var key, output = {}; for(key in obj) { if (obj.hasOwnProperty(key)) { output[getText.getFromKey(key, countryCode)] = obj[key]; } } return output; }, getFromArray: function (arr, countryCode) { var output = []; for (var i=0; i < arr.length; i++){ if (i in arr) { output[i] = getText.getFromKey(arr[i], countryCode); } } return output; }, buildFromDefault: function (key) { var output, length, split, last; switch(key) { case "name": output = "en-US"; break; case "englishName": output = "English (United States)"; break; case "nativeName": output = "English (United States)"; break; case "twoDigitYearMax": output = 2049; break; case "firstDayOfWeek": output = 0; break; default: output = key; split = key.split("_"); length = split.length; if (length > 1 && key.charAt(0) !== "/") { // if the key isn't a regex and it has a split. last = split[(length - 1)].toLowerCase(); if (last === "initial" || last === "abbr") { output = split[0]; } } break; } return output; }, buildFromRegex: function (key, countryCode) { var output; if (Date.CultureStrings && Date.CultureStrings[countryCode] && Date.CultureStrings[countryCode][key]) { output = new RegExp(Date.CultureStrings[countryCode][key], "i"); } else { output = new RegExp(key.replace(new RegExp("/", "g"),""), "i"); } return output; } }; var shallowMerge = function (obj1, obj2) { for (var attrname in obj2) { if (obj2.hasOwnProperty(attrname)) { obj1[attrname] = obj2[attrname]; } } }; var __ = function (key, language) { var countryCode = (language) ? language : lang; loggedKeys[key] = key; if (typeof key === "object") { if (key instanceof Array) { return getText.getFromArray(key, countryCode); } else { return getText.getFromObjectKeys(key, countryCode); } } else { return getText.getFromKey(key, countryCode); } }; var loadI18nScript = function (code) { // paatterned after jQuery's getScript. var url = Date.Config.i18n + code + ".js"; var head = document.getElementsByTagName("head")[0] || document.documentElement; var script = document.createElement("script"); script.src = url; var completed = false; var events = { done: function (){} // placeholder function }; // Attach handlers for all browsers script.onload = script.onreadystatechange = function() { if ( !completed && (!this.readyState || this.readyState === "loaded" || this.readyState === "complete") ) { events.done(); head.removeChild(script); } }; setTimeout(function() { head.insertBefore(script, head.firstChild); }, 0); // allows return to execute first return { done: function (cb) { events.done = function() { if (cb) { setTimeout(cb,0); } }; } }; }; var buildInfo = { buildFromMethodHash: function (obj) { var key; for(key in obj) { if (obj.hasOwnProperty(key)) { obj[key] = buildInfo[obj[key]](); } } return obj; }, timeZoneDST: function () { var DST = { "CHADT": "+1345", "NZDT": "+1300", "AEDT": "+1100", "ACDT": "+1030", "AZST": "+0500", "IRDT": "+0430", "EEST": "+0300", "CEST": "+0200", "BST": "+0100", "PMDT": "-0200", "ADT": "-0300", "NDT": "-0230", "EDT": "-0400", "CDT": "-0500", "MDT": "-0600", "PDT": "-0700", "AKDT": "-0800", "HADT": "-0900" }; return __(DST); }, timeZoneStandard: function () { var standard = { "LINT": "+1400", "TOT": "+1300", "CHAST": "+1245", "NZST": "+1200", "NFT": "+1130", "SBT": "+1100", "AEST": "+1000", "ACST": "+0930", "JST": "+0900", "CWST": "+0845", "CT": "+0800", "ICT": "+0700", "MMT": "+0630", "BST": "+0600", "NPT": "+0545", "IST": "+0530", "PKT": "+0500", "AFT": "+0430", "MSK": "+0400", "IRST": "+0330", "FET": "+0300", "EET": "+0200", "CET": "+0100", "GMT": "+0000", "UTC": "+0000", "CVT": "-0100", "GST": "-0200", "BRT": "-0300", "NST": "-0330", "AST": "-0400", "EST": "-0500", "CST": "-0600", "MST": "-0700", "PST": "-0800", "AKST": "-0900", "MIT": "-0930", "HST": "-1000", "SST": "-1100", "BIT": "-1200" }; return __(standard); }, timeZones: function (data) { var zone; data.timezones = []; for (zone in data.abbreviatedTimeZoneStandard) { if (data.abbreviatedTimeZoneStandard.hasOwnProperty(zone)) { data.timezones.push({ name: zone, offset: data.abbreviatedTimeZoneStandard[zone]}); } } for (zone in data.abbreviatedTimeZoneDST) { if (data.abbreviatedTimeZoneDST.hasOwnProperty(zone)) { data.timezones.push({ name: zone, offset: data.abbreviatedTimeZoneDST[zone], dst: true}); } } return data.timezones; }, days: function () { return __(["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"]); }, dayAbbr: function () { return __(["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"]); }, dayShortNames: function () { return __(["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"]); }, dayFirstLetters: function () { return __(["S_Sun_Initial", "M_Mon_Initial", "T_Tues_Initial", "W_Wed_Initial", "T_Thu_Initial", "F_Fri_Initial", "S_Sat_Initial"]); }, months: function () { return __(["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"]); }, monthAbbr: function () { return __(["Jan_Abbr", "Feb_Abbr", "Mar_Abbr", "Apr_Abbr", "May_Abbr", "Jun_Abbr", "Jul_Abbr", "Aug_Abbr", "Sep_Abbr", "Oct_Abbr", "Nov_Abbr", "Dec_Abbr"]); }, formatPatterns: function () { return getText.getFromObjectValues({ shortDate: "M/d/yyyy", longDate: "dddd, MMMM dd, yyyy", shortTime: "h:mm tt", longTime: "h:mm:ss tt", fullDateTime: "dddd, MMMM dd, yyyy h:mm:ss tt", sortableDateTime: "yyyy-MM-ddTHH:mm:ss", universalSortableDateTime: "yyyy-MM-dd HH:mm:ssZ", rfc1123: "ddd, dd MMM yyyy HH:mm:ss", monthDay: "MMMM dd", yearMonth: "MMMM, yyyy" }, Date.i18n.currentLanguage()); }, regex: function () { return getText.getFromObjectValues({ inTheMorning: "/( in the )(morn(ing)?)\\b/", thisMorning: "/(this )(morn(ing)?)\\b/", amThisMorning: "/(\b\\d(am)? )(this )(morn(ing)?)/", inTheEvening: "/( in the )(even(ing)?)\\b/", thisEvening: "/(this )(even(ing)?)\\b/", pmThisEvening: "/(\b\\d(pm)? )(this )(even(ing)?)/", jan: "/jan(uary)?/", feb: "/feb(ruary)?/", mar: "/mar(ch)?/", apr: "/apr(il)?/", may: "/may/", jun: "/jun(e)?/", jul: "/jul(y)?/", aug: "/aug(ust)?/", sep: "/sep(t(ember)?)?/", oct: "/oct(ober)?/", nov: "/nov(ember)?/", dec: "/dec(ember)?/", sun: "/^su(n(day)?)?/", mon: "/^mo(n(day)?)?/", tue: "/^tu(e(s(day)?)?)?/", wed: "/^we(d(nesday)?)?/", thu: "/^th(u(r(s(day)?)?)?)?/", fri: "/fr(i(day)?)?/", sat: "/^sa(t(urday)?)?/", future: "/^next/", past: "/^last|past|prev(ious)?/", add: "/^(\\+|aft(er)?|from|hence)/", subtract: "/^(\\-|bef(ore)?|ago)/", yesterday: "/^yes(terday)?/", today: "/^t(od(ay)?)?/", tomorrow: "/^tom(orrow)?/", now: "/^n(ow)?/", millisecond: "/^ms|milli(second)?s?/", second: "/^sec(ond)?s?/", minute: "/^mn|min(ute)?s?/", hour: "/^h(our)?s?/", week: "/^w(eek)?s?/", month: "/^m(onth)?s?/", day: "/^d(ay)?s?/", year: "/^y(ear)?s?/", shortMeridian: "/^(a|p)/", longMeridian: "/^(a\\.?m?\\.?|p\\.?m?\\.?)/", timezone: "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/", ordinalSuffix: "/^\\s*(st|nd|rd|th)/", timeContext: "/^\\s*(\\:|a(?!u|p)|p)/" }, Date.i18n.currentLanguage()); } }; var CultureInfo = function () { var info = getText.getFromObjectValues({ name: "name", englishName: "englishName", nativeName: "nativeName", amDesignator: "AM", pmDesignator: "PM", firstDayOfWeek: "firstDayOfWeek", twoDigitYearMax: "twoDigitYearMax", dateElementOrder: "mdy" }, Date.i18n.currentLanguage()); var constructedInfo = buildInfo.buildFromMethodHash({ dayNames: "days", abbreviatedDayNames: "dayAbbr", shortestDayNames: "dayShortNames", firstLetterDayNames: "dayFirstLetters", monthNames: "months", abbreviatedMonthNames: "monthAbbr", formatPatterns: "formatPatterns", regexPatterns: "regex", abbreviatedTimeZoneDST: "timeZoneDST", abbreviatedTimeZoneStandard: "timeZoneStandard" }); shallowMerge(info, constructedInfo); buildInfo.timeZones(info); return info; }; $D.i18n = { __: function (key, lang) { return __(key, lang); }, currentLanguage: function () { return lang || "en-US"; }, setLanguage: function (code, force, cb) { var async = false; if (force || code === "en-US" || (!!Date.CultureStrings && !!Date.CultureStrings[code])) { lang = code; Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings.lang = code; Date.CultureInfo = new CultureInfo(); } else { if (!(!!Date.CultureStrings && !!Date.CultureStrings[code])) { if (typeof exports !== "undefined" && this.exports !== exports) { // we're in a Node enviroment, load it using require try { require("../i18n/" + code + ".js"); lang = code; Date.CultureStrings.lang = code; Date.CultureInfo = new CultureInfo(); } catch (e) { // var str = "The language for '" + code + "' could not be loaded by Node. It likely does not exist."; throw new Error("The DateJS IETF language tag '" + code + "' could not be loaded by Node. It likely does not exist."); } } else if (Date.Config && Date.Config.i18n) { // we know the location of the files, so lets load them async = true; loadI18nScript(code).done(function(){ lang = code; Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings.lang = code; Date.CultureInfo = new CultureInfo(); $D.Parsing.Normalizer.buildReplaceData(); // because this is async if ($D.Grammar) { $D.Grammar.buildGrammarFormats(); // so we can parse those strings... } if (cb) { setTimeout(cb,0); } }); } else { Date.console.error("The DateJS IETF language tag '" + code + "' is not available and has not been loaded."); return false; } } } $D.Parsing.Normalizer.buildReplaceData(); // rebuild normalizer strings if ($D.Grammar) { $D.Grammar.buildGrammarFormats(); // so we can parse those strings... } if (!async && cb) { setTimeout(cb,0); } }, getLoggedKeys: function () { return loggedKeys; }, updateCultureInfo: function () { Date.CultureInfo = new CultureInfo(); } }; $D.i18n.updateCultureInfo(); // run automatically }()); (function () { var $D = Date, $P = $D.prototype, p = function (s, l) { if (!l) { l = 2; } return ("000" + s).slice(l * -1); }; if (typeof window !== "undefined" && typeof window.console !== "undefined" && typeof window.console.log !== "undefined") { $D.console = console; // used only to raise non-critical errors if available } else { // set mock so we don't give errors. $D.console = { log: function(){}, error: function(){} }; } $D.Config = $D.Config || {}; $D.initOverloads = function() { /** * Overload of Date.now. Allows an alternate call for Date.now where it returns the * current Date as an object rather than just milliseconds since the Unix Epoch. * * Also provides an implementation of now() for browsers (IE<9) that don't have it. * * Backwards compatible so with work with either: * Date.now() [returns ms] * or * Date.now(true) [returns Date] */ if (!$D.now) { $D._now = function now() { return new Date().getTime(); }; } else if (!$D._now) { $D._now = $D.now; } $D.now = function (returnObj) { if (returnObj) { return $D.present(); } else { return $D._now(); } }; if ( !$P.toISOString ) { $P.toISOString = function() { return this.getUTCFullYear() + "-" + p(this.getUTCMonth() + 1) + "-" + p(this.getUTCDate()) + "T" + p(this.getUTCHours()) + ":" + p(this.getUTCMinutes()) + ":" + p(this.getUTCSeconds()) + "." + String( (this.getUTCMilliseconds()/1000).toFixed(3)).slice(2, 5) + "Z"; }; } // private if ( $P._toString === undefined ){ $P._toString = $P.toString; } }; $D.initOverloads(); /** * Gets a date that is set to the current date. The time is set to the start of the day (00:00 or 12:00 AM). * @return {Date} The current date. */ $D.today = function () { return new Date().clearTime(); }; /** * Gets a date that is set to the current date and time (same as new Date, but chainable) * @return {Date} The current date. */ $D.present = function () { return new Date(); }; /** * Compares the first date to the second date and returns an number indication of their relative values. * @param {Date} First Date object to compare [Required]. * @param {Date} Second Date object to compare to [Required]. * @return {Number} -1 = date1 is lessthan date2. 0 = values are equal. 1 = date1 is greaterthan date2. */ $D.compare = function (date1, date2) { if (isNaN(date1) || isNaN(date2)) { throw new Error(date1 + " - " + date2); } else if (date1 instanceof Date && date2 instanceof Date) { return (date1 < date2) ? -1 : (date1 > date2) ? 1 : 0; } else { throw new TypeError(date1 + " - " + date2); } }; /** * Compares the first Date object to the second Date object and returns true if they are equal. * @param {Date} First Date object to compare [Required] * @param {Date} Second Date object to compare to [Required] * @return {Boolean} true if dates are equal. false if they are not equal. */ $D.equals = function (date1, date2) { return (date1.compareTo(date2) === 0); }; /** * Gets the language appropriate day name when given the day number(0-6) * eg - 0 == Sunday * @return {String} The day name */ $D.getDayName = function (n) { return Date.CultureInfo.dayNames[n]; }; /** * Gets the day number (0-6) if given a CultureInfo specific string which is a valid dayName, abbreviatedDayName or shortestDayName (two char). * @param {String} The name of the day (eg. "Monday, "Mon", "tuesday", "tue", "We", "we"). * @return {Number} The day number */ $D.getDayNumberFromName = function (name) { var n = Date.CultureInfo.dayNames, m = Date.CultureInfo.abbreviatedDayNames, o = Date.CultureInfo.shortestDayNames, s = name.toLowerCase(); for (var i = 0; i < n.length; i++) { if (n[i].toLowerCase() === s || m[i].toLowerCase() === s || o[i].toLowerCase() === s) { return i; } } return -1; }; /** * Gets the month number (0-11) if given a Culture Info specific string which is a valid monthName or abbreviatedMonthName. * @param {String} The name of the month (eg. "February, "Feb", "october", "oct"). * @return {Number} The day number */ $D.getMonthNumberFromName = function (name) { var n = Date.CultureInfo.monthNames, m = Date.CultureInfo.abbreviatedMonthNames, s = name.toLowerCase(); for (var i = 0; i < n.length; i++) { if (n[i].toLowerCase() === s || m[i].toLowerCase() === s) { return i; } } return -1; }; /** * Gets the language appropriate month name when given the month number(0-11) * eg - 0 == January * @return {String} The month name */ $D.getMonthName = function (n) { return Date.CultureInfo.monthNames[n]; }; /** * Determines if the current date instance is within a LeapYear. * @param {Number} The year. * @return {Boolean} true if date is within a LeapYear, otherwise false. */ $D.isLeapYear = function (year) { return ((year % 4 === 0 && year % 100 !== 0) || year % 400 === 0); }; /** * Gets the number of days in the month, given a year and month value. Automatically corrects for LeapYear. * @param {Number} The year. * @param {Number} The month (0-11). * @return {Number} The number of days in the month. */ $D.getDaysInMonth = function (year, month) { if (!month && $D.validateMonth(year)) { month = year; year = Date.today().getFullYear(); } return [31, ($D.isLeapYear(year) ? 29 : 28), 31, 30, 31, 30, 31, 31, 30, 31, 30, 31][month]; }; $P.getDaysInMonth = function () { return $D.getDaysInMonth(this.getFullYear(), this.getMonth()); }; $D.getTimezoneAbbreviation = function (offset, dst) { var p, n = (dst || false) ? Date.CultureInfo.abbreviatedTimeZoneDST : Date.CultureInfo.abbreviatedTimeZoneStandard; for (p in n) { if (n.hasOwnProperty(p)) { if (n[p] === offset) { return p; } } } return null; }; $D.getTimezoneOffset = function (name, dst) { var i, a =[], z = Date.CultureInfo.timezones; if (!name) { name = (new Date()).getTimezone();} for (i = 0; i < z.length; i++) { if (z[i].name === name.toUpperCase()) { a.push(i); } } if (!z[a[0]]) { return null; } if (a.length === 1 || !dst) { return z[a[0]].offset; } else { for (i=0; i < a.length; i++) { if (z[a[i]].dst) { return z[a[i]].offset; } } } }; $D.getQuarter = function (d) { d = d || new Date(); // If no date supplied, use today var q = [1,2,3,4]; return q[Math.floor(d.getMonth() / 3)]; // ~~~ is a bitwise op. Faster than Math.floor }; $D.getDaysLeftInQuarter = function (d) { d = d || new Date(); var qEnd = new Date(d); qEnd.setMonth(qEnd.getMonth() + 3 - qEnd.getMonth() % 3, 0); return Math.floor((qEnd - d) / 8.64e7); }; // private var validate = function (n, min, max, name) { name = name ? name : "Object"; if (typeof n === "undefined") { return false; } else if (typeof n !== "number") { throw new TypeError(n + " is not a Number."); } else if (n < min || n > max) { // As failing validation is *not* an exceptional circumstance // lets not throw a RangeError Exception here. // It's semantically correct but it's not sensible. return false; } return true; }; /** * Validates the number is within an acceptable range for milliseconds [0-999]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateMillisecond = function (value) { return validate(value, 0, 999, "millisecond"); }; /** * Validates the number is within an acceptable range for seconds [0-59]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateSecond = function (value) { return validate(value, 0, 59, "second"); }; /** * Validates the number is within an acceptable range for minutes [0-59]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateMinute = function (value) { return validate(value, 0, 59, "minute"); }; /** * Validates the number is within an acceptable range for hours [0-23]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateHour = function (value) { return validate(value, 0, 23, "hour"); }; /** * Validates the number is within an acceptable range for the days in a month [0-MaxDaysInMonth]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateDay = function (value, year, month) { if (year === undefined || year === null || month === undefined || month === null) { return false;} return validate(value, 1, $D.getDaysInMonth(year, month), "day"); }; /** * Validates the number is within an acceptable range for months [0-11]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateWeek = function (value) { return validate(value, 0, 53, "week"); }; /** * Validates the number is within an acceptable range for months [0-11]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateMonth = function (value) { return validate(value, 0, 11, "month"); }; /** * Validates the number is within an acceptable range for years. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateYear = function (value) { /** * Per ECMAScript spec the range of times supported by Date objects is * exactly -100,000,000 days to +100,000,000 days measured relative to * midnight at the beginning of 01 January, 1970 UTC. * This gives a range of 8,640,000,000,000,000 milliseconds to either * side of 01 January, 1970 UTC. * * Earliest possible date: Tue, 20 Apr 271,822 B.C. 00:00:00 UTC * Latest possible date: Sat, 13 Sep 275,760 00:00:00 UTC */ return validate(value, -271822, 275760, "year"); }; $D.validateTimezone = function(value) { var timezones = {"ACDT":1,"ACST":1,"ACT":1,"ADT":1,"AEDT":1,"AEST":1,"AFT":1,"AKDT":1,"AKST":1,"AMST":1,"AMT":1,"ART":1,"AST":1,"AWDT":1,"AWST":1,"AZOST":1,"AZT":1,"BDT":1,"BIOT":1,"BIT":1,"BOT":1,"BRT":1,"BST":1,"BTT":1,"CAT":1,"CCT":1,"CDT":1,"CEDT":1,"CEST":1,"CET":1,"CHADT":1,"CHAST":1,"CHOT":1,"ChST":1,"CHUT":1,"CIST":1,"CIT":1,"CKT":1,"CLST":1,"CLT":1,"COST":1,"COT":1,"CST":1,"CT":1,"CVT":1,"CWST":1,"CXT":1,"DAVT":1,"DDUT":1,"DFT":1,"EASST":1,"EAST":1,"EAT":1,"ECT":1,"EDT":1,"EEDT":1,"EEST":1,"EET":1,"EGST":1,"EGT":1,"EIT":1,"EST":1,"FET":1,"FJT":1,"FKST":1,"FKT":1,"FNT":1,"GALT":1,"GAMT":1,"GET":1,"GFT":1,"GILT":1,"GIT":1,"GMT":1,"GST":1,"GYT":1,"HADT":1,"HAEC":1,"HAST":1,"HKT":1,"HMT":1,"HOVT":1,"HST":1,"ICT":1,"IDT":1,"IOT":1,"IRDT":1,"IRKT":1,"IRST":1,"IST":1,"JST":1,"KGT":1,"KOST":1,"KRAT":1,"KST":1,"LHST":1,"LINT":1,"MAGT":1,"MART":1,"MAWT":1,"MDT":1,"MET":1,"MEST":1,"MHT":1,"MIST":1,"MIT":1,"MMT":1,"MSK":1,"MST":1,"MUT":1,"MVT":1,"MYT":1,"NCT":1,"NDT":1,"NFT":1,"NPT":1,"NST":1,"NT":1,"NUT":1,"NZDT":1,"NZST":1,"OMST":1,"ORAT":1,"PDT":1,"PET":1,"PETT":1,"PGT":1,"PHOT":1,"PHT":1,"PKT":1,"PMDT":1,"PMST":1,"PONT":1,"PST":1,"PYST":1,"PYT":1,"RET":1,"ROTT":1,"SAKT":1,"SAMT":1,"SAST":1,"SBT":1,"SCT":1,"SGT":1,"SLST":1,"SRT":1,"SST":1,"SYOT":1,"TAHT":1,"THA":1,"TFT":1,"TJT":1,"TKT":1,"TLT":1,"TMT":1,"TOT":1,"TVT":1,"UCT":1,"ULAT":1,"UTC":1,"UYST":1,"UYT":1,"UZT":1,"VET":1,"VLAT":1,"VOLT":1,"VOST":1,"VUT":1,"WAKT":1,"WAST":1,"WAT":1,"WEDT":1,"WEST":1,"WET":1,"WST":1,"YAKT":1,"YEKT":1,"Z":1}; return (timezones[value] === 1); }; $D.validateTimezoneOffset= function(value) { // timezones go from +14hrs to -12hrs, the +X hours are negative offsets. return (value > -841 && value < 721); }; }()); (function () { var $D = Date, $P = $D.prototype, p = function (s, l) { if (!l) { l = 2; } return ("000" + s).slice(l * -1); }; var validateConfigObject = function (obj) { var result = {}, self = this, prop, testFunc; testFunc = function (prop, func, value) { if (prop === "day") { var month = (obj.month !== undefined) ? obj.month : self.getMonth(); var year = (obj.year !== undefined) ? obj.year : self.getFullYear(); return $D[func](value, year, month); } else { return $D[func](value); } }; for (prop in obj) { if (Object.prototype.hasOwnProperty.call(obj, prop)) { var func = "validate" + prop.charAt(0).toUpperCase() + prop.slice(1); if ($D[func] && obj[prop] !== null && testFunc(prop, func, obj[prop])) { result[prop] = obj[prop]; } } } return result; }; /** * Resets the time of this Date object to 12:00 AM (00:00), which is the start of the day. * @param {Boolean} .clone() this date instance before clearing Time * @return {Date} this */ $P.clearTime = function () { this.setHours(0); this.setMinutes(0); this.setSeconds(0); this.setMilliseconds(0); return this; }; /** * Resets the time of this Date object to the current time ('now'). * @return {Date} this */ $P.setTimeToNow = function () { var n = new Date(); this.setHours(n.getHours()); this.setMinutes(n.getMinutes()); this.setSeconds(n.getSeconds()); this.setMilliseconds(n.getMilliseconds()); return this; }; /** * Returns a new Date object that is an exact date and time copy of the original instance. * @return {Date} A new Date instance */ $P.clone = function () { return new Date(this.getTime()); }; /** * Compares this instance to a Date object and returns an number indication of their relative values. * @param {Date} Date object to compare [Required] * @return {Number} -1 = this is lessthan date. 0 = values are equal. 1 = this is greaterthan date. */ $P.compareTo = function (date) { return Date.compare(this, date); }; /** * Compares this instance to another Date object and returns true if they are equal. * @param {Date} Date object to compare. If no date to compare, new Date() [now] is used. * @return {Boolean} true if dates are equal. false if they are not equal. */ $P.equals = function (date) { return Date.equals(this, (date !== undefined ? date : new Date())); }; /** * Determines if this instance is between a range of two dates or equal to either the start or end dates. * @param {Date} Start of range [Required] * @param {Date} End of range [Required] * @return {Boolean} true is this is between or equal to the start and end dates, else false */ $P.between = function (start, end) { return this.getTime() >= start.getTime() && this.getTime() <= end.getTime(); }; /** * Determines if this date occurs after the date to compare to. * @param {Date} Date object to compare. If no date to compare, new Date() ("now") is used. * @return {Boolean} true if this date instance is greater than the date to compare to (or "now"), otherwise false. */ $P.isAfter = function (date) { return this.compareTo(date || new Date()) === 1; }; /** * Determines if this date occurs before the date to compare to. * @param {Date} Date object to compare. If no date to compare, new Date() ("now") is used. * @return {Boolean} true if this date instance is less than the date to compare to (or "now"). */ $P.isBefore = function (date) { return (this.compareTo(date || new Date()) === -1); }; /** * Determines if the current Date instance occurs today. * @return {Boolean} true if this date instance is 'today', otherwise false. */ /** * Determines if the current Date instance occurs on the same Date as the supplied 'date'. * If no 'date' to compare to is provided, the current Date instance is compared to 'today'. * @param {date} Date object to compare. If no date to compare, the current Date ("now") is used. * @return {Boolean} true if this Date instance occurs on the same Day as the supplied 'date'. */ $P.isToday = $P.isSameDay = function (date) { return this.clone().clearTime().equals((date || new Date()).clone().clearTime()); }; /** * Adds the specified number of milliseconds to this instance. * @param {Number} The number of milliseconds to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addMilliseconds = function (value) { if (!value) { return this; } this.setTime(this.getTime() + value * 1); return this; }; /** * Adds the specified number of seconds to this instance. * @param {Number} The number of seconds to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addSeconds = function (value) { if (!value) { return this; } return this.addMilliseconds(value * 1000); }; /** * Adds the specified number of seconds to this instance. * @param {Number} The number of seconds to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addMinutes = function (value) { if (!value) { return this; } return this.addMilliseconds(value * 60000); // 60*1000 }; /** * Adds the specified number of hours to this instance. * @param {Number} The number of hours to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addHours = function (value) { if (!value) { return this; } return this.addMilliseconds(value * 3600000); // 60*60*1000 }; /** * Adds the specified number of days to this instance. * @param {Number} The number of days to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addDays = function (value) { if (!value) { return this; } this.setDate(this.getDate() + value * 1); return this; }; /** * Adds the specified number of weekdays (ie - not sat or sun) to this instance. * @param {Number} The number of days to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addWeekdays = function (value) { if (!value) { return this; } var day = this.getDay(); var weeks = (Math.ceil(Math.abs(value)/7)); if (day === 0 || day === 6) { if (value > 0) { this.next().monday(); this.addDays(-1); day = this.getDay(); } } if (value < 0) { while (value < 0) { this.addDays(-1); day = this.getDay(); if (day !== 0 && day !== 6) { value++; } } return this; } else if (value > 5 || (6-day) <= value) { value = value + (weeks * 2); } return this.addDays(value); }; /** * Adds the specified number of weeks to this instance. * @param {Number} The number of weeks to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addWeeks = function (value) { if (!value) { return this; } return this.addDays(value * 7); }; /** * Adds the specified number of months to this instance. * @param {Number} The number of months to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addMonths = function (value) { if (!value) { return this; } var n = this.getDate(); this.setDate(1); this.setMonth(this.getMonth() + value * 1); this.setDate(Math.min(n, $D.getDaysInMonth(this.getFullYear(), this.getMonth()))); return this; }; $P.addQuarters = function (value) { if (!value) { return this; } // note this will take you to the same point in the quarter as you are now. // i.e. - if you are 15 days into the quarter you'll be 15 days into the resulting one. // bonus: this allows adding fractional quarters return this.addMonths(value * 3); }; /** * Adds the specified number of years to this instance. * @param {Number} The number of years to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addYears = function (value) { if (!value) { return this; } return this.addMonths(value * 12); }; /** * Adds (or subtracts) to the value of the years, months, weeks, days, hours, minutes, seconds, milliseconds of the date instance using given configuration object. Positive and Negative values allowed. * Example

	Date.today().add( { days: 1, months: 1 } )

	new Date().add( { years: -1 } )
	
* @param {Object} Configuration object containing attributes (months, days, etc.) * @return {Date} this */ $P.add = function (config) { if (typeof config === "number") { this._orient = config; return this; } var x = config; if (x.day) { // If we should be a different date than today (eg: for 'tomorrow -1d', etc). // Should only effect parsing, not direct usage (eg, Finish and FinishExact) if ((x.day - this.getDate()) !== 0) { this.setDate(x.day); } } if (x.milliseconds) { this.addMilliseconds(x.milliseconds); } if (x.seconds) { this.addSeconds(x.seconds); } if (x.minutes) { this.addMinutes(x.minutes); } if (x.hours) { this.addHours(x.hours); } if (x.weeks) { this.addWeeks(x.weeks); } if (x.months) { this.addMonths(x.months); } if (x.years) { this.addYears(x.years); } if (x.days) { this.addDays(x.days); } return this; }; /** * Get the week number. Week one (1) is the week which contains the first Thursday of the year. Monday is considered the first day of the week. * The .getWeek() function does NOT convert the date to UTC. The local datetime is used. * Please use .getISOWeek() to get the week of the UTC converted date. * @return {Number} 1 to 53 */ $P.getWeek = function (utc) { // Create a copy of this date object var self, target = new Date(this.valueOf()); if (utc) { target.addMinutes(target.getTimezoneOffset()); self = target.clone(); } else { self = this; } // ISO week date weeks start on monday // so correct the day number var dayNr = (self.getDay() + 6) % 7; // ISO 8601 states that week 1 is the week // with the first thursday of that year. // Set the target date to the thursday in the target week target.setDate(target.getDate() - dayNr + 3); // Store the millisecond value of the target date var firstThursday = target.valueOf(); // Set the target to the first thursday of the year // First set the target to january first target.setMonth(0, 1); // Not a thursday? Correct the date to the next thursday if (target.getDay() !== 4) { target.setMonth(0, 1 + ((4 - target.getDay()) + 7) % 7); } // The weeknumber is the number of weeks between the // first thursday of the year and the thursday in the target week return 1 + Math.ceil((firstThursday - target) / 604800000); // 604800000 = 7 * 24 * 3600 * 1000 }; /** * Get the ISO 8601 week number. Week one ("01") is the week which contains the first Thursday of the year. Monday is considered the first day of the week. * The .getISOWeek() function does convert the date to it's UTC value. Please use .getWeek() to get the week of the local date. * @return {String} "01" to "53" */ $P.getISOWeek = function () { return p(this.getWeek(true)); }; /** * Moves the date to Monday of the week set. Week one (1) is the week which contains the first Thursday of the year. * @param {Number} A Number (1 to 53) that represents the week of the year. * @return {Date} this */ $P.setWeek = function (n) { if ((n - this.getWeek()) === 0) { if (this.getDay() !== 1) { return this.moveToDayOfWeek(1, (this.getDay() > 1 ? -1 : 1)); } else { return this; } } else { return this.moveToDayOfWeek(1, (this.getDay() > 1 ? -1 : 1)).addWeeks(n - this.getWeek()); } }; $P.setQuarter = function (qtr) { var month = Math.abs(((qtr-1) * 3) + 1); return this.setMonth(month, 1); }; $P.getQuarter = function () { return Date.getQuarter(this); }; $P.getDaysLeftInQuarter = function () { return Date.getDaysLeftInQuarter(this); }; /** * Moves the date to the next n'th occurrence of the dayOfWeek starting from the beginning of the month. The number (-1) is a magic number and will return the last occurrence of the dayOfWeek in the month. * @param {Number} The dayOfWeek to move to * @param {Number} The n'th occurrence to move to. Use (-1) to return the last occurrence in the month * @return {Date} this */ $P.moveToNthOccurrence = function (dayOfWeek, occurrence) { if (dayOfWeek === "Weekday") { if (occurrence > 0) { this.moveToFirstDayOfMonth(); if (this.is().weekday()) { occurrence -= 1; } } else if (occurrence < 0) { this.moveToLastDayOfMonth(); if (this.is().weekday()) { occurrence += 1; } } else { return this; } return this.addWeekdays(occurrence); } var shift = 0; if (occurrence > 0) { shift = occurrence - 1; } else if (occurrence === -1) { this.moveToLastDayOfMonth(); if (this.getDay() !== dayOfWeek) { this.moveToDayOfWeek(dayOfWeek, -1); } return this; } return this.moveToFirstDayOfMonth().addDays(-1).moveToDayOfWeek(dayOfWeek, +1).addWeeks(shift); }; var moveToN = function (getFunc, addFunc, nVal) { return function (value, orient) { var diff = (value - this[getFunc]() + nVal * (orient || +1)) % nVal; return this[addFunc]((diff === 0) ? diff += nVal * (orient || +1) : diff); }; }; /** * Move to the next or last dayOfWeek based on the orient value. * @param {Number} The dayOfWeek to move to * @param {Number} Forward (+1) or Back (-1). Defaults to +1. [Optional] * @return {Date} this */ $P.moveToDayOfWeek = moveToN("getDay", "addDays", 7); /** * Move to the next or last month based on the orient value. * @param {Number} The month to move to. 0 = January, 11 = December * @param {Number} Forward (+1) or Back (-1). Defaults to +1. [Optional] * @return {Date} this */ $P.moveToMonth = moveToN("getMonth", "addMonths", 12); /** * Get the Ordinate of the current day ("th", "st", "rd"). * @return {String} */ $P.getOrdinate = function () { var num = this.getDate(); return ord(num); }; /** * Get the Ordinal day (numeric day number) of the year, adjusted for leap year. * @return {Number} 1 through 365 (366 in leap years) */ $P.getOrdinalNumber = function () { return Math.ceil((this.clone().clearTime() - new Date(this.getFullYear(), 0, 1)) / 86400000) + 1; }; /** * Get the time zone abbreviation of the current date. * @return {String} The abbreviated time zone name (e.g. "EST") */ $P.getTimezone = function () { return $D.getTimezoneAbbreviation(this.getUTCOffset(), this.isDaylightSavingTime()); }; $P.setTimezoneOffset = function (offset) { var here = this.getTimezoneOffset(), there = Number(offset) * -6 / 10; return (there || there === 0) ? this.addMinutes(there - here) : this; }; $P.setTimezone = function (offset) { return this.setTimezoneOffset($D.getTimezoneOffset(offset)); }; /** * Indicates whether Daylight Saving Time is observed in the current time zone. * @return {Boolean} true|false */ $P.hasDaylightSavingTime = function () { return (Date.today().set({month: 0, day: 1}).getTimezoneOffset() !== Date.today().set({month: 6, day: 1}).getTimezoneOffset()); }; /** * Indicates whether this Date instance is within the Daylight Saving Time range for the current time zone. * @return {Boolean} true|false */ $P.isDaylightSavingTime = function () { return Date.today().set({month: 0, day: 1}).getTimezoneOffset() !== this.getTimezoneOffset(); }; /** * Get the offset from UTC of the current date. * @return {String} The 4-character offset string prefixed with + or - (e.g. "-0500") */ $P.getUTCOffset = function (offset) { var n = (offset || this.getTimezoneOffset()) * -10 / 6, r; if (n < 0) { r = (n - 10000).toString(); return r.charAt(0) + r.substr(2); } else { r = (n + 10000).toString(); return "+" + r.substr(1); } }; /** * Returns the number of milliseconds between this date and date. * @param {Date} Defaults to now * @return {Number} The diff in milliseconds */ $P.getElapsed = function (date) { return (date || new Date()) - this; }; /** * Set the value of year, month, day, hour, minute, second, millisecond of date instance using given configuration object. * Example

	Date.today().set( { day: 20, month: 1 } )

	new Date().set( { millisecond: 0 } )
	
* * @param {Object} Configuration object containing attributes (month, day, etc.) * @return {Date} this */ $P.set = function (config) { config = validateConfigObject.call(this, config); var key; for (key in config) { if (Object.prototype.hasOwnProperty.call(config, key)) { var name = key.charAt(0).toUpperCase() + key.slice(1); var addFunc, getFunc; if (key !== "week" && key !== "month" && key !== "timezone" && key !== "timezoneOffset") { name += "s"; } addFunc = "add" + name; getFunc = "get" + name; if (key === "month") { addFunc = addFunc + "s"; } else if (key === "year"){ getFunc = "getFullYear"; } if (key !== "day" && key !== "timezone" && key !== "timezoneOffset" && key !== "week" && key !== "hour") { this[addFunc](config[key] - this[getFunc]()); } else if ( key === "timezone"|| key === "timezoneOffset" || key === "week" || key === "hour") { this["set"+name](config[key]); } } } // day has to go last because you can't validate the day without first knowing the month if (config.day) { this.addDays(config.day - this.getDate()); } return this; }; /** * Moves the date to the first day of the month. * @return {Date} this */ $P.moveToFirstDayOfMonth = function () { return this.set({ day: 1 }); }; /** * Moves the date to the last day of the month. * @return {Date} this */ $P.moveToLastDayOfMonth = function () { return this.set({ day: $D.getDaysInMonth(this.getFullYear(), this.getMonth())}); }; /** * Converts the value of the current Date object to its equivalent string representation. * Format Specifiers * CUSTOM DATE AND TIME FORMAT STRINGS * Format Description Example * ------ --------------------------------------------------------------------------- ----------------------- * s The seconds of the minute between 0-59. "0" to "59" * ss The seconds of the minute with leading zero if required. "00" to "59" * * m The minute of the hour between 0-59. "0" or "59" * mm The minute of the hour with leading zero if required. "00" or "59" * * h The hour of the day between 1-12. "1" to "12" * hh The hour of the day with leading zero if required. "01" to "12" * * H The hour of the day between 0-23. "0" to "23" * HH The hour of the day with leading zero if required. "00" to "23" * * d The day of the month between 1 and 31. "1" to "31" * dd The day of the month with leading zero if required. "01" to "31" * ddd Abbreviated day name. Date.CultureInfo.abbreviatedDayNames. "Mon" to "Sun" * dddd The full day name. Date.CultureInfo.dayNames. "Monday" to "Sunday" * * M The month of the year between 1-12. "1" to "12" * MM The month of the year with leading zero if required. "01" to "12" * MMM Abbreviated month name. Date.CultureInfo.abbreviatedMonthNames. "Jan" to "Dec" * MMMM The full month name. Date.CultureInfo.monthNames. "January" to "December" * * yy The year as a two-digit number. "99" or "08" * yyyy The full four digit year. "1999" or "2008" * * t Displays the first character of the A.M./P.M. designator. "A" or "P" * Date.CultureInfo.amDesignator or Date.CultureInfo.pmDesignator * tt Displays the A.M./P.M. designator. "AM" or "PM" * Date.CultureInfo.amDesignator or Date.CultureInfo.pmDesignator * * S The ordinal suffix ("st, "nd", "rd" or "th") of the current day. "st, "nd", "rd" or "th" * * STANDARD DATE AND TIME FORMAT STRINGS * Format Description Example *------ --------------------------------------------------------------------------- ----------------------- * d The CultureInfo shortDate Format Pattern "M/d/yyyy" * D The CultureInfo longDate Format Pattern "dddd, MMMM dd, yyyy" * F The CultureInfo fullDateTime Format Pattern "dddd, MMMM dd, yyyy h:mm:ss tt" * m The CultureInfo monthDay Format Pattern "MMMM dd" * r The CultureInfo rfc1123 Format Pattern "ddd, dd MMM yyyy HH:mm:ss GMT" * s The CultureInfo sortableDateTime Format Pattern "yyyy-MM-ddTHH:mm:ss" * t The CultureInfo shortTime Format Pattern "h:mm tt" * T The CultureInfo longTime Format Pattern "h:mm:ss tt" * u The CultureInfo universalSortableDateTime Format Pattern "yyyy-MM-dd HH:mm:ssZ" * y The CultureInfo yearMonth Format Pattern "MMMM, yyyy" * * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @return {String} A string representation of the current Date object. */ var ord = function (n) { switch (n * 1) { case 1: case 21: case 31: return "st"; case 2: case 22: return "nd"; case 3: case 23: return "rd"; default: return "th"; } }; var parseStandardFormats = function (format) { var y, c = Date.CultureInfo.formatPatterns; switch (format) { case "d": return this.toString(c.shortDate); case "D": return this.toString(c.longDate); case "F": return this.toString(c.fullDateTime); case "m": return this.toString(c.monthDay); case "r": case "R": y = this.clone().addMinutes(this.getTimezoneOffset()); return y.toString(c.rfc1123) + " GMT"; case "s": return this.toString(c.sortableDateTime); case "t": return this.toString(c.shortTime); case "T": return this.toString(c.longTime); case "u": y = this.clone().addMinutes(this.getTimezoneOffset()); return y.toString(c.universalSortableDateTime); case "y": return this.toString(c.yearMonth); default: return false; } }; var parseFormatStringsClosure = function (context) { return function (m) { if (m.charAt(0) === "\\") { return m.replace("\\", ""); } switch (m) { case "hh": return p(context.getHours() < 13 ? (context.getHours() === 0 ? 12 : context.getHours()) : (context.getHours() - 12)); case "h": return context.getHours() < 13 ? (context.getHours() === 0 ? 12 : context.getHours()) : (context.getHours() - 12); case "HH": return p(context.getHours()); case "H": return context.getHours(); case "mm": return p(context.getMinutes()); case "m": return context.getMinutes(); case "ss": return p(context.getSeconds()); case "s": return context.getSeconds(); case "yyyy": return p(context.getFullYear(), 4); case "yy": return p(context.getFullYear()); case "y": return context.getFullYear(); case "E": case "dddd": return Date.CultureInfo.dayNames[context.getDay()]; case "ddd": return Date.CultureInfo.abbreviatedDayNames[context.getDay()]; case "dd": return p(context.getDate()); case "d": return context.getDate(); case "MMMM": return Date.CultureInfo.monthNames[context.getMonth()]; case "MMM": return Date.CultureInfo.abbreviatedMonthNames[context.getMonth()]; case "MM": return p((context.getMonth() + 1)); case "M": return context.getMonth() + 1; case "t": return context.getHours() < 12 ? Date.CultureInfo.amDesignator.substring(0, 1) : Date.CultureInfo.pmDesignator.substring(0, 1); case "tt": return context.getHours() < 12 ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator; case "S": return ord(context.getDate()); case "W": return context.getWeek(); case "WW": return context.getISOWeek(); case "Q": return "Q" + context.getQuarter(); case "q": return String(context.getQuarter()); case "z": return context.getTimezone(); case "Z": case "X": return Date.getTimezoneOffset(context.getTimezone()); case "ZZ": // Timezone offset in seconds return context.getTimezoneOffset() * -60; case "u": return context.getDay(); case "L": return ($D.isLeapYear(context.getFullYear())) ? 1 : 0; case "B": // Swatch Internet Time (.beats) return "@"+((context.getUTCSeconds() + (context.getUTCMinutes()*60) + ((context.getUTCHours()+1)*3600))/86.4); default: return m; } }; }; $P.toString = function (format, ignoreStandards) { // Standard Date and Time Format Strings. Formats pulled from CultureInfo file and // may vary by culture. if (!ignoreStandards && format && format.length === 1) { output = parseStandardFormats.call(this, format); if (output) { return output; } } var parseFormatStrings = parseFormatStringsClosure(this); return format ? format.replace(/((\\)?(dd?d?d?|MM?M?M?|yy?y?y?|hh?|HH?|mm?|ss?|tt?|S|q|Q|WW?W?W?)(?![^\[]*\]))/g, parseFormatStrings).replace(/\[|\]/g, "") : this._toString(); }; }()); /************************************************************* * SugarPak - Domain Specific Language - Syntactical Sugar * *************************************************************/ (function () { var $D = Date, $P = $D.prototype, $N = Number.prototype; // private $P._orient = +1; // private $P._nth = null; // private $P._is = false; // private $P._same = false; // private $P._isSecond = false; // private $N._dateElement = "days"; /** * Moves the date to the next instance of a date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.today().next().friday();
	Date.today().next().fri();
	Date.today().next().march();
	Date.today().next().mar();
	Date.today().next().week();
	
* * @return {Date} date */ $P.next = function () { this._move = true; this._orient = +1; return this; }; /** * Creates a new Date (Date.today()) and moves the date to the next instance of the date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.next().friday();
	Date.next().fri();
	Date.next().march();
	Date.next().mar();
	Date.next().week();
	
* * @return {Date} date */ $D.next = function () { return $D.today().next(); }; /** * Moves the date to the previous instance of a date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.today().last().friday();
	Date.today().last().fri();
	Date.today().last().march();
	Date.today().last().mar();
	Date.today().last().week();
	
* * @return {Date} date */ $P.last = $P.prev = $P.previous = function () { this._move = true; this._orient = -1; return this; }; /** * Creates a new Date (Date.today()) and moves the date to the previous instance of the date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.last().friday();
	Date.last().fri();
	Date.previous().march();
	Date.prev().mar();
	Date.last().week();
	
* * @return {Date} date */ $D.last = $D.prev = $D.previous = function () { return $D.today().last(); }; /** * Performs a equality check when followed by either a month name, day name or .weekday() function. * Example

	Date.today().is().friday(); // true|false
	Date.today().is().fri();
	Date.today().is().march();
	Date.today().is().mar();
	
* * @return {Boolean} true|false */ $P.is = function () { this._is = true; return this; }; /** * Determines if two date objects occur on/in exactly the same instance of the subsequent date part function. * The function .same() must be followed by a date part function (example: .day(), .month(), .year(), etc). * * An optional Date can be passed in the date part function. If now date is passed as a parameter, 'Now' is used. * * The following example demonstrates how to determine if two dates fall on the exact same day. * * Example

	var d1 = Date.today(); // today at 00:00
	var d2 = new Date();   // exactly now.

	// Do they occur on the same day?
	d1.same().day(d2); // true
	
	// Do they occur on the same hour?
	d1.same().hour(d2); // false, unless d2 hour is '00' (midnight).
	
	// What if it's the same day, but one year apart?
	var nextYear = Date.today().add(1).year();

	d1.same().day(nextYear); // false, because the dates must occur on the exact same day. 
	
* * Scenario: Determine if a given date occurs during some week period 2 months from now. * * Example

	var future = Date.today().add(2).months();
	return someDate.same().week(future); // true|false;
	
* * @return {Boolean} true|false */ $P.same = function () { this._same = true; this._isSecond = false; return this; }; /** * Determines if the current date/time occurs during Today. Must be preceded by the .is() function. * Example

	someDate.is().today();    // true|false
	new Date().is().today();  // true
	Date.today().is().today();// true
	Date.today().add(-1).day().is().today(); // false
	
* * @return {Boolean} true|false */ $P.today = function () { return this.same().day(); }; /** * Determines if the current date is a weekday. This function must be preceded by the .is() function. * Example

	Date.today().is().weekday(); // true|false
	
* * @return {Boolean} true|false */ $P.weekday = function () { if (this._nth) { return df("Weekday").call(this); } if (this._move) { return this.addWeekdays(this._orient); } if (this._is) { this._is = false; return (!this.is().sat() && !this.is().sun()); } return false; }; /** * Determines if the current date is on the weekend. This function must be preceded by the .is() function. * Example

	Date.today().is().weekend(); // true|false
	
* * @return {Boolean} true|false */ $P.weekend = function () { if (this._is) { this._is = false; return (this.is().sat() || this.is().sun()); } return false; }; /** * Sets the Time of the current Date instance. A string "6:15 pm" or config object {hour:18, minute:15} are accepted. * Example

	// Set time to 6:15pm with a String
	Date.today().at("6:15pm");

	// Set time to 6:15pm with a config object
	Date.today().at({hour:18, minute:15});
	
* * @return {Date} date */ $P.at = function (time) { return (typeof time === "string") ? $D.parse(this.toString("d") + " " + time) : this.set(time); }; /** * Creates a new Date() and adds this (Number) to the date based on the preceding date element function (eg. second|minute|hour|day|month|year). * Example

	// Undeclared Numbers must be wrapped with parentheses. Requirment of JavaScript.
	(3).days().fromNow();
	(6).months().fromNow();

	// Declared Number variables do not require parentheses. 
	var n = 6;
	n.months().fromNow();
	
* * @return {Date} A new Date instance */ $N.fromNow = $N.after = function (date) { var c = {}; c[this._dateElement] = this; return ((!date) ? new Date() : date.clone()).add(c); }; /** * Creates a new Date() and subtract this (Number) from the date based on the preceding date element function (eg. second|minute|hour|day|month|year). * Example

	// Undeclared Numbers must be wrapped with parentheses. Requirment of JavaScript.
	(3).days().ago();
	(6).months().ago();

	// Declared Number variables do not require parentheses. 
	var n = 6;
	n.months().ago();
	
* * @return {Date} A new Date instance */ $N.ago = $N.before = function (date) { var c = {}, s = (this._dateElement[this._dateElement.length-1] !== "s") ? this._dateElement + "s" : this._dateElement; c[s] = this * -1; return ((!date) ? new Date() : date.clone()).add(c); }; // Do NOT modify the following string tokens. These tokens are used to build dynamic functions. // All culture-specific strings can be found in the CultureInfo files. var dx = ("sunday monday tuesday wednesday thursday friday saturday").split(/\s/), mx = ("january february march april may june july august september october november december").split(/\s/), px = ("Millisecond Second Minute Hour Day Week Month Year Quarter Weekday").split(/\s/), pxf = ("Milliseconds Seconds Minutes Hours Date Week Month FullYear Quarter").split(/\s/), nth = ("final first second third fourth fifth").split(/\s/), de; /** * Returns an object literal of all the date parts. * Example

	var o = new Date().toObject();
	
	// { year: 2008, month: 4, week: 20, day: 13, hour: 18, minute: 9, second: 32, millisecond: 812 }
	
	// The object properties can be referenced directly from the object.
	
	alert(o.day);  // alerts "13"
	alert(o.year); // alerts "2008"
	
* * @return {Date} An object literal representing the original date object. */ $P.toObject = function () { var o = {}; for (var i = 0; i < px.length; i++) { if (this["get" + pxf[i]]) { o[px[i].toLowerCase()] = this["get" + pxf[i]](); } } return o; }; /** * Returns a date created from an object literal. Ignores the .week property if set in the config. * Example

	var o = new Date().toObject();
	
	return Date.fromObject(o); // will return the same date. 

	var o2 = {month: 1, day: 20, hour: 18}; // birthday party!
	Date.fromObject(o2);
	
* * @return {Date} An object literal representing the original date object. */ $D.fromObject = function(config) { config.week = null; return Date.today().set(config); }; // Create day name functions and abbreviated day name functions (eg. monday(), friday(), fri()). var df = function (n) { return function () { if (this._is) { this._is = false; return this.getDay() === n; } if (this._move) { this._move = null; } if (this._nth !== null) { // If the .second() function was called earlier, remove the _orient // from the date, and then continue. // This is required because 'second' can be used in two different context. // // Example // // Date.today().add(1).second(); // Date.march().second().monday(); // // Things get crazy with the following... // Date.march().add(1).second().second().monday(); // but it works!! // if (this._isSecond) { this.addSeconds(this._orient * -1); } // make sure we reset _isSecond this._isSecond = false; var ntemp = this._nth; this._nth = null; var temp = this.clone().moveToLastDayOfMonth(); this.moveToNthOccurrence(n, ntemp); if (this > temp) { throw new RangeError($D.getDayName(n) + " does not occur " + ntemp + " times in the month of " + $D.getMonthName(temp.getMonth()) + " " + temp.getFullYear() + "."); } return this; } return this.moveToDayOfWeek(n, this._orient); }; }; var sdf = function (n) { return function () { var t = $D.today(), shift = n - t.getDay(); if (n === 0 && Date.CultureInfo.firstDayOfWeek === 1 && t.getDay() !== 0) { shift = shift + 7; } return t.addDays(shift); }; }; // Create month name functions and abbreviated month name functions (eg. january(), march(), mar()). var month_instance_functions = function (n) { return function () { if (this._is) { this._is = false; return this.getMonth() === n; } return this.moveToMonth(n, this._orient); }; }; var month_static_functions = function (n) { return function () { return $D.today().set({ month: n, day: 1 }); }; }; var processTerms = function (names, staticFunc, instanceFunc) { for (var i = 0; i < names.length; i++) { // Create constant static Name variables. $D[names[i].toUpperCase()] = $D[names[i].toUpperCase().substring(0, 3)] = i; // Create Name functions. $D[names[i]] = $D[names[i].substring(0, 3)] = staticFunc(i); // Create Name instance functions. $P[names[i]] = $P[names[i].substring(0, 3)] = instanceFunc(i); } }; processTerms(dx, sdf, df); processTerms(mx, month_static_functions, month_instance_functions); // Create date element functions and plural date element functions used with Date (eg. day(), days(), months()). var ef = function (j) { return function () { // if the .second() function was called earlier, the _orient // has alread been added. Just return this and reset _isSecond. if (this._isSecond) { this._isSecond = false; return this; } if (this._same) { this._same = this._is = false; var o1 = this.toObject(), o2 = (arguments[0] || new Date()).toObject(), v = "", k = j.toLowerCase(); // the substr trick with -1 doesn't work in IE8 or less k = (k[k.length-1] === "s") ? k.substring(0,k.length-1) : k; for (var m = (px.length - 1); m > -1; m--) { v = px[m].toLowerCase(); if (o1[v] !== o2[v]) { return false; } if (k === v) { break; } } return true; } if (j.substring(j.length - 1) !== "s") { j += "s"; } if (this._move) { this._move = null; } return this["add" + j](this._orient); }; }; var nf = function (n) { return function () { this._dateElement = n; return this; }; }; for (var k = 0; k < px.length; k++) { de = px[k].toLowerCase(); if(de !== "weekday") { // Create date element functions and plural date element functions used with Date (eg. day(), days(), months()). $P[de] = $P[de + "s"] = ef(px[k]); // Create date element functions and plural date element functions used with Number (eg. day(), days(), months()). $N[de] = $N[de + "s"] = nf(de + "s"); } } $P._ss = ef("Second"); var nthfn = function (n) { return function (dayOfWeek) { if (this._same) { return this._ss(arguments[0]); } if (dayOfWeek || dayOfWeek === 0) { return this.moveToNthOccurrence(dayOfWeek, n); } this._nth = n; // if the operator is 'second' add the _orient, then deal with it later... if (n === 2 && (dayOfWeek === undefined || dayOfWeek === null)) { this._isSecond = true; return this.addSeconds(this._orient); } return this; }; }; for (var l = 0; l < nth.length; l++) { $P[nth[l]] = (l === 0) ? nthfn(-1) : nthfn(l); } }()); (function () { "use strict"; Date.Parsing = { Exception: function (s) { this.message = "Parse error at '" + s.substring(0, 10) + " ...'"; } }; var $P = Date.Parsing; var dayOffsets = { standard: [0,31,59,90,120,151,181,212,243,273,304,334], leap: [0,31,60,91,121,152,182,213,244,274,305,335] }; $P.isLeapYear = function(year) { return ((year % 4 === 0) && (year % 100 !== 0)) || (year % 400 === 0); }; var utils = { multiReplace : function (str, hash ) { var key; for (key in hash) { if (Object.prototype.hasOwnProperty.call(hash, key)) { var regex; if (typeof hash[key] === "function") { } else { regex = (hash[key] instanceof RegExp) ? hash[key] : new RegExp(hash[key], "g"); } str = str.replace(regex, key); } } return str; }, getDayOfYearFromWeek : function (obj) { var d, jan4, offset; obj.weekDay = (!obj.weekDay && obj.weekDay !== 0) ? 1 : obj.weekDay; d = new Date(obj.year, 0, 4); jan4 = d.getDay() === 0 ? 7 : d.getDay(); // JS is 0 indexed on Sunday. offset = jan4+3; obj.dayOfYear = ((obj.week * 7) + (obj.weekDay === 0 ? 7 : obj.weekDay))-offset; return obj; }, getDayOfYear : function (obj, dayOffset) { if (!obj.dayOfYear) { obj = utils.getDayOfYearFromWeek(obj); } for (var i=0;i <= dayOffset.length;i++) { if (obj.dayOfYear < dayOffset[i] || i === dayOffset.length) { obj.day = obj.day ? obj.day : (obj.dayOfYear - dayOffset[i-1]); break; } else { obj.month = i; } } return obj; }, adjustForTimeZone : function (obj, date) { var offset; if (obj.zone.toUpperCase() === "Z" || (obj.zone_hours === 0 && obj.zone_minutes === 0)) { // it's UTC/GML so work out the current timeszone offset offset = -date.getTimezoneOffset(); } else { offset = (obj.zone_hours*60) + (obj.zone_minutes || 0); if (obj.zone_sign === "+") { offset *= -1; } offset -= date.getTimezoneOffset(); } date.setMinutes(date.getMinutes()+offset); return date; }, setDefaults : function (obj) { obj.year = obj.year || Date.today().getFullYear(); obj.hours = obj.hours || 0; obj.minutes = obj.minutes || 0; obj.seconds = obj.seconds || 0; obj.milliseconds = obj.milliseconds || 0; if (!(!obj.month && (obj.week || obj.dayOfYear))) { // if we have a month, or if we don't but don't have the day calculation data obj.month = obj.month || 0; obj.day = obj.day || 1; } return obj; }, dataNum: function (data, mod, explict, postProcess) { var dataNum = data*1; if (mod) { if (postProcess) { return data ? mod(data)*1 : data; } else { return data ? mod(dataNum) : data; } } else if (!explict){ return data ? dataNum : data; } else { return (data && typeof data !== "undefined") ? dataNum : data; } }, timeDataProcess: function (obj) { var timeObj = {}; for (var x in obj.data) { if (obj.data.hasOwnProperty(x)) { timeObj[x] = obj.ignore[x] ? obj.data[x] : utils.dataNum(obj.data[x], obj.mods[x], obj.explict[x], obj.postProcess[x]); } } if (obj.data.secmins) { obj.data.secmins = obj.data.secmins.replace(",", ".") * 60; if (!timeObj.minutes) { timeObj.minutes = obj.data.secmins; } else if (!timeObj.seconds) { timeObj.seconds = obj.data.secmins; } delete obj.secmins; } return timeObj; }, buildTimeObjectFromData: function (data) { var time = utils.timeDataProcess({ data: { year : data[1], month : data[5], day : data[7], week : data[8], dayOfYear : data[10], hours : data[15], zone_hours : data[23], zone_minutes : data[24], zone : data[21], zone_sign : data[22], weekDay : data[9], minutes: data[16], seconds: data[19], milliseconds: data[20], secmins: data[18] }, mods: { month: function(data) { return data-1; }, weekDay: function (data) { data = Math.abs(data); return (data === 7 ? 0 : data); }, minutes: function (data) { return data.replace(":",""); }, seconds: function (data) { return Math.floor( (data.replace(":","").replace(",","."))*1 ); }, milliseconds: function (data) { return (data.replace(",",".")*1000); } }, postProcess: { minutes: true, seconds: true, milliseconds: true }, explict: { zone_hours: true, zone_minutes: true }, ignore: { zone: true, zone_sign: true, secmins: true } }); return time; }, addToHash: function (hash, keys, data) { keys = keys; data = data; var len = keys.length; for (var i = 0; i < len; i++) { hash[keys[i]] = data[i]; } return hash; }, combineRegex: function (r1, r2) { return new RegExp("(("+r1.source+")\\s("+r2.source+"))"); }, getDateNthString: function(add, last, inc){ if (add) { return Date.today().addDays(inc).toString("d"); } else if (last) { return Date.today().last()[inc]().toString("d"); } }, buildRegexData: function (array) { var arr = []; var len = array.length; for (var i=0; i < len; i++) { if (Object.prototype.toString.call(array[i]) === '[object Array]') { // oldIE compat version of Array.isArray arr.push(this.combineRegex(array[i][0], array[i][1])); } else { arr.push(array[i]); } } return arr; } }; $P.processTimeObject = function (obj) { var date, dayOffset; utils.setDefaults(obj); dayOffset = ($P.isLeapYear(obj.year)) ? dayOffsets.leap : dayOffsets.standard; if (!obj.month && (obj.week || obj.dayOfYear)) { utils.getDayOfYear(obj, dayOffset); } else { obj.dayOfYear = dayOffset[obj.month] + obj.day; } date = new Date(obj.year, obj.month, obj.day, obj.hours, obj.minutes, obj.seconds, obj.milliseconds); if (obj.zone) { utils.adjustForTimeZone(obj, date); // adjust (and calculate) for timezone } return date; }; $P.ISO = { regex : /^([\+-]?\d{4}(?!\d{2}\b))((-?)((0[1-9]|1[0-2])(\3([12]\d|0[1-9]|3[01]))?|W([0-4]\d|5[0-3])(-?[1-7])?|(00[1-9]|0[1-9]\d|[12]\d{2}|3([0-5]\d|6[1-6])))([T\s]((([01]\d|2[0-4])((:?)[0-5]\d)?|24\:?00)([\.,]\d+(?!:))?)?(\17[0-5]\d([\.,]\d+)?)?\s?([zZ]|([\+-])([01]\d|2[0-3]):?([0-5]\d)?)?)?)?$/, parse : function (s) { var time, data = s.match(this.regex); if (!data || !data.length) { return null; } time = utils.buildTimeObjectFromData(data); if (!time.year || (!time.year && (!time.month && !time.day) && (!time.week && !time.dayOfYear)) ) { return null; } return $P.processTimeObject(time); } }; $P.Numeric = { isNumeric: function (e){return!isNaN(parseFloat(e))&&isFinite(e);}, regex: /\b([0-1]?[0-9])([0-3]?[0-9])([0-2]?[0-9]?[0-9][0-9])\b/i, parse: function (s) { var data, i, time = {}, order = Date.CultureInfo.dateElementOrder.split(""); if (!(this.isNumeric(s)) || // if it's non-numeric OR (s[0] === "+" && s[0] === "-")) { // It's an arithmatic string (eg +/-1000) return null; } if (s.length < 5 && s.indexOf(".") < 0 && s.indexOf("/") < 0) { // assume it's just a year. time.year = s; return $P.processTimeObject(time); } data = s.match(this.regex); if (!data || !data.length) { return null; } for (i=0; i < order.length; i++) { switch(order[i]) { case "d": time.day = data[i+1]; break; case "m": time.month = (data[i+1]-1); break; case "y": time.year = data[i+1]; break; } } return $P.processTimeObject(time); } }; $P.Normalizer = { regexData: function () { var $R = Date.CultureInfo.regexPatterns; return utils.buildRegexData([ $R.tomorrow, $R.yesterday, [$R.past, $R.mon], [$R.past, $R.tue], [$R.past, $R.wed], [$R.past, $R.thu], [$R.past, $R.fri], [$R.past, $R.sat], [$R.past, $R.sun] ]); }, basicReplaceHash : function() { var $R = Date.CultureInfo.regexPatterns; return { "January": $R.jan.source, "February": $R.feb, "March": $R.mar, "April": $R.apr, "May": $R.may, "June": $R.jun, "July": $R.jul, "August": $R.aug, "September": $R.sep, "October": $R.oct, "November": $R.nov, "December": $R.dec, "": /\bat\b/gi, " ": /\s{2,}/, "am": $R.inTheMorning, "9am": $R.thisMorning, "pm": $R.inTheEvening, "7pm":$R.thisEvening }; }, keys : function(){ return [ utils.getDateNthString(true, false, 1), // tomorrow utils.getDateNthString(true, false, -1), // yesterday utils.getDateNthString(false, true, "monday"), //last mon utils.getDateNthString(false, true, "tuesday"), //last tues utils.getDateNthString(false, true, "wednesday"), //last wed utils.getDateNthString(false, true, "thursday"), //last thurs utils.getDateNthString(false, true, "friday"), //last fri utils.getDateNthString(false, true, "saturday"), //last sat utils.getDateNthString(false, true, "sunday") //last sun ]; }, buildRegexFunctions: function () { var $R = Date.CultureInfo.regexPatterns; var __ = Date.i18n.__; var tomorrowRE = new RegExp("(\\b\\d\\d?("+__("AM")+"|"+__("PM")+")? )("+$R.tomorrow.source.slice(1)+")", "i"); // adapted tomorrow regex for AM PM relative dates var todayRE = new RegExp($R.today.source + "(?!\\s*([+-]))\\b"); // today, but excludes the math operators (eg "today + 2h") this.replaceFuncs = [ [todayRE, function (full) { return (full.length > 1) ? Date.today().toString("d") : full; }], [tomorrowRE, function(full, m1) { var t = Date.today().addDays(1).toString("d"); return (t + " " + m1); }], [$R.amThisMorning, function(str, am){return am;}], [$R.pmThisEvening, function(str, pm){return pm;}] ]; }, buildReplaceData: function () { this.buildRegexFunctions(); this.replaceHash = utils.addToHash(this.basicReplaceHash(), this.keys(), this.regexData()); }, stringReplaceFuncs: function (s) { for (var i=0; i < this.replaceFuncs.length; i++) { s = s.replace(this.replaceFuncs[i][0], this.replaceFuncs[i][1]); } return s; }, parse: function (s) { s = this.stringReplaceFuncs(s); s = utils.multiReplace(s, this.replaceHash); try { var n = s.split(/([\s\-\.\,\/\x27]+)/); if (n.length === 3 && $P.Numeric.isNumeric(n[0]) && $P.Numeric.isNumeric(n[2]) && (n[2].length >= 4)) { // ok, so we're dealing with x/year. But that's not a full date. // This fixes wonky dateElementOrder parsing when set to dmy order. if (Date.CultureInfo.dateElementOrder[0] === "d") { s = "1/" + n[0] + "/" + n[2]; // set to 1st of month and normalize the seperator } } } catch (e) {} return s; } }; $P.Normalizer.buildReplaceData(); }()); (function () { var $P = Date.Parsing; var _ = $P.Operators = { // // Tokenizers // rtoken: function (r) { // regex token return function (s) { var mx = s.match(r); if (mx) { return ([ mx[0], s.substring(mx[0].length) ]); } else { throw new $P.Exception(s); } }; }, token: function () { // whitespace-eating token return function (s) { return _.rtoken(new RegExp("^\\s*" + s + "\\s*"))(s); }; }, stoken: function (s) { // string token return _.rtoken(new RegExp("^" + s)); }, // Atomic Operators until: function (p) { return function (s) { var qx = [], rx = null; while (s.length) { try { rx = p.call(this, s); } catch (e) { qx.push(rx[0]); s = rx[1]; continue; } break; } return [ qx, s ]; }; }, many: function (p) { return function (s) { var rx = [], r = null; while (s.length) { try { r = p.call(this, s); } catch (e) { return [ rx, s ]; } rx.push(r[0]); s = r[1]; } return [ rx, s ]; }; }, // generator operators -- see below optional: function (p) { return function (s) { var r = null; try { r = p.call(this, s); } catch (e) { return [ null, s ]; } return [ r[0], r[1] ]; }; }, not: function (p) { return function (s) { try { p.call(this, s); } catch (e) { return [null, s]; } throw new $P.Exception(s); }; }, ignore: function (p) { return p ? function (s) { var r = null; r = p.call(this, s); return [null, r[1]]; } : null; }, product: function () { var px = arguments[0], qx = Array.prototype.slice.call(arguments, 1), rx = []; for (var i = 0 ; i < px.length ; i++) { rx.push(_.each(px[i], qx)); } return rx; }, cache: function (rule) { var cache = {}, cache_length = 0, cache_keys = [], CACHE_MAX = Date.Config.CACHE_MAX || 100000, r = null; var cacheCheck = function () { if (cache_length === CACHE_MAX) { // kill several keys, don't want to have to do this all the time... for (var i=0; i < 10; i++) { var key = cache_keys.shift(); if (key) { delete cache[key]; cache_length--; } } } }; return function (s) { cacheCheck(); try { r = cache[s] = (cache[s] || rule.call(this, s)); } catch (e) { r = cache[s] = e; } cache_length++; cache_keys.push(s); if (r instanceof $P.Exception) { throw r; } else { return r; } }; }, // vector operators -- see below any: function () { var px = arguments; return function (s) { var r = null; for (var i = 0; i < px.length; i++) { if (px[i] == null) { continue; } try { r = (px[i].call(this, s)); } catch (e) { r = null; } if (r) { return r; } } throw new $P.Exception(s); }; }, each: function () { var px = arguments; return function (s) { var rx = [], r = null; for (var i = 0; i < px.length ; i++) { if (px[i] == null) { continue; } try { r = (px[i].call(this, s)); } catch (e) { throw new $P.Exception(s); } rx.push(r[0]); s = r[1]; } return [ rx, s]; }; }, all: function () { var px = arguments, _ = _; return _.each(_.optional(px)); }, // delimited operators sequence: function (px, d, c) { d = d || _.rtoken(/^\s*/); c = c || null; if (px.length === 1) { return px[0]; } return function (s) { var r = null, q = null; var rx = []; for (var i = 0; i < px.length ; i++) { try { r = px[i].call(this, s); } catch (e) { break; } rx.push(r[0]); try { q = d.call(this, r[1]); } catch (ex) { q = null; break; } s = q[1]; } if (!r) { throw new $P.Exception(s); } if (q) { throw new $P.Exception(q[1]); } if (c) { try { r = c.call(this, r[1]); } catch (ey) { throw new $P.Exception(r[1]); } } return [ rx, (r?r[1]:s) ]; }; }, // // Composite Operators // between: function (d1, p, d2) { d2 = d2 || d1; var _fn = _.each(_.ignore(d1), p, _.ignore(d2)); return function (s) { var rx = _fn.call(this, s); return [[rx[0][0], r[0][2]], rx[1]]; }; }, list: function (p, d, c) { d = d || _.rtoken(/^\s*/); c = c || null; return (p instanceof Array ? _.each(_.product(p.slice(0, -1), _.ignore(d)), p.slice(-1), _.ignore(c)) : _.each(_.many(_.each(p, _.ignore(d))), px, _.ignore(c))); }, set: function (px, d, c) { d = d || _.rtoken(/^\s*/); c = c || null; return function (s) { // r is the current match, best the current 'best' match // which means it parsed the most amount of input var r = null, p = null, q = null, rx = null, best = [[], s], last = false; // go through the rules in the given set for (var i = 0; i < px.length ; i++) { // last is a flag indicating whether this must be the last element // if there is only 1 element, then it MUST be the last one q = null; p = null; r = null; last = (px.length === 1); // first, we try simply to match the current pattern // if not, try the next pattern try { r = px[i].call(this, s); } catch (e) { continue; } // since we are matching against a set of elements, the first // thing to do is to add r[0] to matched elements rx = [[r[0]], r[1]]; // if we matched and there is still input to parse and // we don't already know this is the last element, // we're going to next check for the delimiter ... // if there's none, or if there's no input left to parse // than this must be the last element after all ... if (r[1].length > 0 && ! last) { try { q = d.call(this, r[1]); } catch (ex) { last = true; } } else { last = true; } // if we parsed the delimiter and now there's no more input, // that means we shouldn't have parsed the delimiter at all // so don't update r and mark this as the last element ... if (!last && q[1].length === 0) { last = true; } // so, if this isn't the last element, we're going to see if // we can get any more matches from the remaining (unmatched) // elements ... if (!last) { // build a list of the remaining rules we can match against, // i.e., all but the one we just matched against var qx = []; for (var j = 0; j < px.length ; j++) { if (i !== j) { qx.push(px[j]); } } // now invoke recursively set with the remaining input // note that we don't include the closing delimiter ... // we'll check for that ourselves at the end p = _.set(qx, d).call(this, q[1]); // if we got a non-empty set as a result ... // (otw rx already contains everything we want to match) if (p[0].length > 0) { // update current result, which is stored in rx ... // basically, pick up the remaining text from p[1] // and concat the result from p[0] so that we don't // get endless nesting ... rx[0] = rx[0].concat(p[0]); rx[1] = p[1]; } } // at this point, rx either contains the last matched element // or the entire matched set that starts with this element. // now we just check to see if this variation is better than // our best so far, in terms of how much of the input is parsed if (rx[1].length < best[1].length) { best = rx; } // if we've parsed all the input, then we're finished if (best[1].length === 0) { break; } } // so now we've either gone through all the patterns trying them // as the initial match; or we found one that parsed the entire // input string ... // if best has no matches, just return empty set ... if (best[0].length === 0) { return best; } // if a closing delimiter is provided, then we have to check it also if (c) { // we try this even if there is no remaining input because the pattern // may well be optional or match empty input ... try { q = c.call(this, best[1]); } catch (ey) { throw new $P.Exception(best[1]); } // it parsed ... be sure to update the best match remaining input best[1] = q[1]; } // if we're here, either there was no closing delimiter or we parsed it // so now we have the best match; just return it! return best; }; }, forward: function (gr, fname) { return function (s) { return gr[fname].call(this, s); }; }, // // Translation Operators // replace: function (rule, repl) { return function (s) { var r = rule.call(this, s); return [repl, r[1]]; }; }, process: function (rule, fn) { return function (s) { var r = rule.call(this, s); return [fn.call(this, r[0]), r[1]]; }; }, min: function (min, rule) { return function (s) { var rx = rule.call(this, s); if (rx[0].length < min) { throw new $P.Exception(s); } return rx; }; } }; // Generator Operators And Vector Operators // Generators are operators that have a signature of F(R) => R, // taking a given rule and returning another rule, such as // ignore, which parses a given rule and throws away the result. // Vector operators are those that have a signature of F(R1,R2,...) => R, // take a list of rules and returning a new rule, such as each. // Generator operators are converted (via the following _generator // function) into functions that can also take a list or array of rules // and return an array of new rules as though the function had been // called on each rule in turn (which is what actually happens). // This allows generators to be used with vector operators more easily. // Example: // each(ignore(foo, bar)) instead of each(ignore(foo), ignore(bar)) // This also turns generators into vector operators, which allows // constructs like: // not(cache(foo, bar)) var _generator = function (op) { function gen() { var args = null, rx = [], px, i; if (arguments.length > 1) { args = Array.prototype.slice.call(arguments); } else if (arguments[0] instanceof Array) { args = arguments[0]; } if (args) { px = args.shift(); if (px.length > 0) { args.unshift(px[i]); rx.push(op.apply(null, args)); args.shift(); return rx; } } else { return op.apply(null, arguments); } } return gen; }; var gx = "optional not ignore cache".split(/\s/); for (var i = 0 ; i < gx.length ; i++) { _[gx[i]] = _generator(_[gx[i]]); } var _vector = function (op) { return function () { if (arguments[0] instanceof Array) { return op.apply(null, arguments[0]); } else { return op.apply(null, arguments); } }; }; var vx = "each any all".split(/\s/); for (var j = 0 ; j < vx.length ; j++) { _[vx[j]] = _vector(_[vx[j]]); } }()); (function () { var $D = Date; var flattenAndCompact = function (ax) { var rx = []; for (var i = 0; i < ax.length; i++) { if (ax[i] instanceof Array) { rx = rx.concat(flattenAndCompact(ax[i])); } else { if (ax[i]) { rx.push(ax[i]); } } } return rx; }; var parseMeridian = function () { if (this.meridian && (this.hour || this.hour === 0)) { if (this.meridian === "a" && this.hour > 11 && Date.Config.strict24hr){ throw "Invalid hour and meridian combination"; } else if (this.meridian === "p" && this.hour < 12 && Date.Config.strict24hr){ throw "Invalid hour and meridian combination"; } else if (this.meridian === "p" && this.hour < 12) { this.hour = this.hour + 12; } else if (this.meridian === "a" && this.hour === 12) { this.hour = 0; } } }; var setDefaults = function () { var now = new Date(); if ((this.hour || this.minute) && (!this.month && !this.year && !this.day)) { this.day = now.getDate(); } if (!this.year) { this.year = now.getFullYear(); } if (!this.month && this.month !== 0) { this.month = now.getMonth(); } if (!this.day) { this.day = 1; } if (!this.hour) { this.hour = 0; } if (!this.minute) { this.minute = 0; } if (!this.second) { this.second = 0; } if (!this.millisecond) { this.millisecond = 0; } }; var finishUtils = { getToday: function () { if (this.now || "hour minute second".indexOf(this.unit) !== -1) { return new Date(); } else { return $D.today(); } }, setDaysFromWeekday: function (today, orient){ var gap; orient = orient || 1; this.unit = "day"; gap = ($D.getDayNumberFromName(this.weekday) - today.getDay()); this.days = gap ? ((gap + (orient * 7)) % 7) : (orient * 7); return this; }, setMonthsFromMonth: function (today, orient) { var gap; orient = orient || 1; this.unit = "month"; gap = (this.month - today.getMonth()); this.months = gap ? ((gap + (orient * 12)) % 12) : (orient * 12); this.month = null; return this; }, setDMYFromWeekday: function () { var d = Date[this.weekday](); this.day = d.getDate(); if (!this.month) { this.month = d.getMonth(); } this.year = d.getFullYear(); return this; }, setUnitValue: function (orient) { if (!this.value && this.operator && this.operator !== null && this[this.unit + "s"] && this[this.unit + "s"] !== null) { this[this.unit + "s"] = this[this.unit + "s"] + ((this.operator === "add") ? 1 : -1) + (this.value||0) * orient; } else if (this[this.unit + "s"] == null || this.operator != null) { if (!this.value) { this.value = 1; } this[this.unit + "s"] = this.value * orient; } }, generateDateFromWeeks: function () { var weekday = (this.weekday !== undefined) ? this.weekday : "today"; var d = Date[weekday]().addWeeks(this.weeks); if (this.now) { d.setTimeToNow(); } return d; } }; $D.Translator = { hour: function (s) { return function () { this.hour = Number(s); }; }, minute: function (s) { return function () { this.minute = Number(s); }; }, second: function (s) { return function () { this.second = Number(s); }; }, /* for ss.s format */ secondAndMillisecond: function (s) { return function () { var mx = s.match(/^([0-5][0-9])\.([0-9]{1,3})/); this.second = Number(mx[1]); this.millisecond = Number(mx[2]); }; }, meridian: function (s) { return function () { this.meridian = s.slice(0, 1).toLowerCase(); }; }, timezone: function (s) { return function () { var n = s.replace(/[^\d\+\-]/g, ""); if (n.length) { this.timezoneOffset = Number(n); } else { this.timezone = s.toLowerCase(); } }; }, day: function (x) { var s = x[0]; return function () { this.day = Number(s.match(/\d+/)[0]); if (this.day < 1) { throw "invalid day"; } }; }, month: function (s) { return function () { this.month = (s.length === 3) ? "jan feb mar apr may jun jul aug sep oct nov dec".indexOf(s)/4 : Number(s) - 1; if (this.month < 0) { throw "invalid month"; } }; }, year: function (s) { return function () { var n = Number(s); this.year = ((s.length > 2) ? n : (n + (((n + 2000) < Date.CultureInfo.twoDigitYearMax) ? 2000 : 1900))); }; }, rday: function (s) { return function () { switch (s) { case "yesterday": this.days = -1; break; case "tomorrow": this.days = 1; break; case "today": this.days = 0; break; case "now": this.days = 0; this.now = true; break; } }; }, finishExact: function (x) { var d; x = (x instanceof Array) ? x : [x]; for (var i = 0 ; i < x.length ; i++) { if (x[i]) { x[i].call(this); } } setDefaults.call(this); parseMeridian.call(this); if (this.day > $D.getDaysInMonth(this.year, this.month)) { throw new RangeError(this.day + " is not a valid value for days."); } d = new Date(this.year, this.month, this.day, this.hour, this.minute, this.second, this.millisecond); if (this.year < 100) { d.setFullYear(this.year); // means years less that 100 are process correctly. JS will parse it otherwise as 1900-1999. } if (this.timezone) { d.set({ timezone: this.timezone }); } else if (this.timezoneOffset) { d.set({ timezoneOffset: this.timezoneOffset }); } return d; }, finish: function (x) { var today, expression, orient, temp; x = (x instanceof Array) ? flattenAndCompact(x) : [ x ]; if (x.length === 0) { return null; } for (var i = 0 ; i < x.length ; i++) { if (typeof x[i] === "function") { x[i].call(this); } } if (this.now && !this.unit && !this.operator) { return new Date(); } else { today = finishUtils.getToday.call(this); } expression = !!(this.days && this.days !== null || this.orient || this.operator); orient = ((this.orient === "past" || this.operator === "subtract") ? -1 : 1); if (this.month && this.unit === "week") { this.value = this.month + 1; delete this.month; delete this.day; } if ((this.month || this.month === 0) && "year day hour minute second".indexOf(this.unit) !== -1) { if (!this.value) { this.value = this.month + 1; } this.month = null; expression = true; } if (!expression && this.weekday && !this.day && !this.days) { finishUtils.setDMYFromWeekday.call(this); } if (expression && this.weekday && this.unit !== "month" && this.unit !== "week") { finishUtils.setDaysFromWeekday.call(this, today, orient); } if (this.weekday && this.unit !== "week" && !this.day && !this.days) { temp = Date[this.weekday](); this.day = temp.getDate(); if (temp.getMonth() !== today.getMonth()) { this.month = temp.getMonth(); } } if (this.month && this.unit === "day" && this.operator) { if (!this.value) { this.value = (this.month + 1); } this.month = null; } if (this.value != null && this.month != null && this.year != null) { this.day = this.value * 1; } if (this.month && !this.day && this.value) { today.set({ day: this.value * 1 }); if (!expression) { this.day = this.value * 1; } } if (!this.month && this.value && this.unit === "month" && !this.now) { this.month = this.value; expression = true; } if (expression && (this.month || this.month === 0) && this.unit !== "year") { finishUtils.setMonthsFromMonth.call(this, today, orient); } if (!this.unit) { this.unit = "day"; } finishUtils.setUnitValue.call(this, orient); parseMeridian.call(this); if ((this.month || this.month === 0) && !this.day) { this.day = 1; } if (!this.orient && !this.operator && this.unit === "week" && this.value && !this.day && !this.month) { return Date.today().setWeek(this.value); } if (this.unit === "week" && this.weeks && !this.day && !this.month) { return finishUtils.generateDateFromWeeks.call(this); } if (expression && this.timezone && this.day && this.days) { this.day = this.days; } if (expression){ today.add(this); } else { today.set(this); } if (this.timezone) { this.timezone = this.timezone.toUpperCase(); var offset = $D.getTimezoneOffset(this.timezone); var timezone; if (today.hasDaylightSavingTime()) { // lets check that we're being sane with timezone setting timezone = $D.getTimezoneAbbreviation(offset, today.isDaylightSavingTime()); if (timezone !== this.timezone) { // bugger, we're in a place where things like EST vs EDT matters. if (today.isDaylightSavingTime()) { today.addHours(-1); } else { today.addHours(1); } } } today.setTimezoneOffset(offset); } return today; } }; }()); (function () { var $D = Date; $D.Grammar = {}; var _ = $D.Parsing.Operators, g = $D.Grammar, t = $D.Translator, _fn; // Allow rolling up into general purpose rules _fn = function () { return _.each(_.any.apply(null, arguments), _.not(g.ctoken2("timeContext"))); }; g.datePartDelimiter = _.rtoken(/^([\s\-\.\,\/\x27]+)/); g.timePartDelimiter = _.stoken(":"); g.whiteSpace = _.rtoken(/^\s*/); g.generalDelimiter = _.rtoken(/^(([\s\,]|at|@|on)+)/); var _C = {}; g.ctoken = function (keys) { var fn = _C[keys]; if (! fn) { var c = Date.CultureInfo.regexPatterns; var kx = keys.split(/\s+/), px = []; for (var i = 0; i < kx.length ; i++) { px.push(_.replace(_.rtoken(c[kx[i]]), kx[i])); } fn = _C[keys] = _.any.apply(null, px); } return fn; }; g.ctoken2 = function (key) { return _.rtoken(Date.CultureInfo.regexPatterns[key]); }; var cacheProcessRtoken = function (key, token, type, eachToken) { if (eachToken) { g[key] = _.cache(_.process(_.each(_.rtoken(token),_.optional(g.ctoken2(eachToken))), type)); } else { g[key] = _.cache(_.process(_.rtoken(token), type)); } }; var cacheProcessCtoken = function (token, type) { return _.cache(_.process(g.ctoken2(token), type)); }; var _F = {}; //function cache var _get = function (f) { _F[f] = (_F[f] || g.format(f)[0]); return _F[f]; }; g.allformats = function (fx) { var rx = []; if (fx instanceof Array) { for (var i = 0; i < fx.length; i++) { rx.push(_get(fx[i])); } } else { rx.push(_get(fx)); } return rx; }; g.formats = function (fx) { if (fx instanceof Array) { var rx = []; for (var i = 0 ; i < fx.length ; i++) { rx.push(_get(fx[i])); } return _.any.apply(null, rx); } else { return _get(fx); } }; var grammarFormats = { timeFormats: function(){ var i, RTokenKeys = [ "h", "hh", "H", "HH", "m", "mm", "s", "ss", "ss.s", "z", "zz" ], RToken = [ /^(0[0-9]|1[0-2]|[1-9])/, /^(0[0-9]|1[0-2])/, /^([0-1][0-9]|2[0-3]|[0-9])/, /^([0-1][0-9]|2[0-3])/, /^([0-5][0-9]|[0-9])/, /^[0-5][0-9]/, /^([0-5][0-9]|[0-9])/, /^[0-5][0-9]/, /^[0-5][0-9]\.[0-9]{1,3}/, /^((\+|\-)\s*\d\d\d\d)|((\+|\-)\d\d\:?\d\d)/, /^((\+|\-)\s*\d\d\d\d)|((\+|\-)\d\d\:?\d\d)/ ], tokens = [ t.hour, t.hour, t.hour, t.hour, t.minute, t.minute, t.second, t.second, t.secondAndMillisecond, t.timezone, t.timezone ]; for (i=0; i < RTokenKeys.length; i++) { cacheProcessRtoken(RTokenKeys[i], RToken[i], tokens[i]); } g.hms = _.cache(_.sequence([g.H, g.m, g.s], g.timePartDelimiter)); g.t = cacheProcessCtoken("shortMeridian", t.meridian); g.tt = cacheProcessCtoken("longMeridian", t.meridian); g.zzz = cacheProcessCtoken("timezone", t.timezone); g.timeSuffix = _.each(_.ignore(g.whiteSpace), _.set([ g.tt, g.zzz ])); g.time = _.each(_.optional(_.ignore(_.stoken("T"))), g.hms, g.timeSuffix); }, dateFormats: function () { // pre-loaded rules for different date part order preferences var _setfn = function () { return _.set(arguments, g.datePartDelimiter); }; var i, RTokenKeys = [ "d", "dd", "M", "MM", "y", "yy", "yyy", "yyyy" ], RToken = [ /^([0-2]\d|3[0-1]|\d)/, /^([0-2]\d|3[0-1])/, /^(1[0-2]|0\d|\d)/, /^(1[0-2]|0\d)/, /^(\d+)/, /^(\d\d)/, /^(\d\d?\d?\d?)/, /^(\d\d\d\d)/ ], tokens = [ t.day, t.day, t.month, t.month, t.year, t.year, t.year, t.year ], eachToken = [ "ordinalSuffix", "ordinalSuffix" ]; for (i=0; i < RTokenKeys.length; i++) { cacheProcessRtoken(RTokenKeys[i], RToken[i], tokens[i], eachToken[i]); } g.MMM = g.MMMM = _.cache(_.process(g.ctoken("jan feb mar apr may jun jul aug sep oct nov dec"), t.month)); g.ddd = g.dddd = _.cache(_.process(g.ctoken("sun mon tue wed thu fri sat"), function (s) { return function () { this.weekday = s; }; } )); g.day = _fn(g.d, g.dd); g.month = _fn(g.M, g.MMM); g.year = _fn(g.yyyy, g.yy); g.mdy = _setfn(g.ddd, g.month, g.day, g.year); g.ymd = _setfn(g.ddd, g.year, g.month, g.day); g.dmy = _setfn(g.ddd, g.day, g.month, g.year); g.date = function (s) { return ((g[Date.CultureInfo.dateElementOrder] || g.mdy).call(this, s)); }; }, relative: function () { // relative date / time expressions g.orientation = _.process(g.ctoken("past future"), function (s) { return function () { this.orient = s; }; } ); g.operator = _.process(g.ctoken("add subtract"), function (s) { return function () { this.operator = s; }; } ); g.rday = _.process(g.ctoken("yesterday tomorrow today now"), t.rday); g.unit = _.process(g.ctoken("second minute hour day week month year"), function (s) { return function () { this.unit = s; }; } ); } }; g.buildGrammarFormats = function () { // these need to be rebuilt every time the language changes. _C = {}; grammarFormats.timeFormats(); grammarFormats.dateFormats(); grammarFormats.relative(); g.value = _.process(_.rtoken(/^([-+]?\d+)?(st|nd|rd|th)?/), function (s) { return function () { this.value = s.replace(/\D/g, ""); }; } ); g.expression = _.set([g.rday, g.operator, g.value, g.unit, g.orientation, g.ddd, g.MMM ]); g.format = _.process(_.many( _.any( // translate format specifiers into grammar rules _.process( _.rtoken(/^(dd?d?d?(?!e)|MM?M?M?|yy?y?y?|hh?|HH?|mm?|ss?|tt?|zz?z?)/), function (fmt) { if (g[fmt]) { return g[fmt]; } else { throw $D.Parsing.Exception(fmt); } } ), // translate separator tokens into token rules _.process(_.rtoken(/^[^dMyhHmstz]+/), // all legal separators function (s) { return _.ignore(_.stoken(s)); } ) ) ), // construct the parser ... function (rules) { return _.process(_.each.apply(null, rules), t.finishExact); } ); // starting rule for general purpose grammar g._start = _.process(_.set([ g.date, g.time, g.expression ], g.generalDelimiter, g.whiteSpace), t.finish); }; g.buildGrammarFormats(); // parsing date format specifiers - ex: "h:m:s tt" // this little guy will generate a custom parser based // on the format string, ex: g.format("h:m:s tt") // check for these formats first g._formats = g.formats([ "\"yyyy-MM-ddTHH:mm:ssZ\"", "yyyy-MM-ddTHH:mm:ss.sz", "yyyy-MM-ddTHH:mm:ssZ", "yyyy-MM-ddTHH:mm:ssz", "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-ddTHH:mmZ", "yyyy-MM-ddTHH:mmz", "yyyy-MM-ddTHH:mm", "ddd, MMM dd, yyyy H:mm:ss tt", "ddd MMM d yyyy HH:mm:ss zzz", "MMddyyyy", "ddMMyyyy", "Mddyyyy", "ddMyyyy", "Mdyyyy", "dMyyyy", "yyyy", "Mdyy", "dMyy", "d" ]); // real starting rule: tries selected formats first, // then general purpose rule g.start = function (s) { try { var r = g._formats.call({}, s); if (r[1].length === 0) { return r; } } catch (e) {} return g._start.call({}, s); }; }()); (function () { var $D = Date; /** * @desc Converts the specified string value into its JavaScript Date equivalent using CultureInfo specific format information. * * Example

	///////////
	// Dates //
	///////////

	// 15-Oct-2004
	var d1 = Date.parse("10/15/2004");

	// 15-Oct-2004
	var d1 = Date.parse("15-Oct-2004");

	// 15-Oct-2004
	var d1 = Date.parse("2004.10.15");

	//Fri Oct 15, 2004
	var d1 = Date.parse("Fri Oct 15, 2004");

	///////////
	// Times //
	///////////

	// Today at 10 PM.
	var d1 = Date.parse("10 PM");

	// Today at 10:30 PM.
	var d1 = Date.parse("10:30 P.M.");

	// Today at 6 AM.
	var d1 = Date.parse("06am");

	/////////////////////
	// Dates and Times //
	/////////////////////

	// 8-July-2004 @ 10:30 PM
	var d1 = Date.parse("July 8th, 2004, 10:30 PM");

	// 1-July-2004 @ 10:30 PM
	var d1 = Date.parse("2004-07-01T22:30:00");

	////////////////////
	// Relative Dates //
	////////////////////

	// Returns today's date. The string "today" is culture specific.
	var d1 = Date.parse("today");

	// Returns yesterday's date. The string "yesterday" is culture specific.
	var d1 = Date.parse("yesterday");

	// Returns the date of the next thursday.
	var d1 = Date.parse("Next thursday");

	// Returns the date of the most previous monday.
	var d1 = Date.parse("last monday");

	// Returns today's day + one year.
	var d1 = Date.parse("next year");

	///////////////
	// Date Math //
	///////////////

	// Today + 2 days
	var d1 = Date.parse("t+2");

	// Today + 2 days
	var d1 = Date.parse("today + 2 days");

	// Today + 3 months
	var d1 = Date.parse("t+3m");

	// Today - 1 year
	var d1 = Date.parse("today - 1 year");

	// Today - 1 year
	var d1 = Date.parse("t-1y"); 


	/////////////////////////////
	// Partial Dates and Times //
	/////////////////////////////

	// July 15th of this year.
	var d1 = Date.parse("July 15");

	// 15th day of current day and year.
	var d1 = Date.parse("15");

	// July 1st of current year at 10pm.
	var d1 = Date.parse("7/1 10pm");
	
* * @param {String} The string value to convert into a Date object [Required] * @return {Date} A Date object or null if the string cannot be converted into a Date. */ var parseUtils = { removeOrds: function (s) { ords = s.match(/\b(\d+)(?:st|nd|rd|th)\b/); // find ordinal matches s = ((ords && ords.length === 2) ? s.replace(ords[0], ords[1]) : s); return s; }, grammarParser: function (s) { var r = null; try { r = $D.Grammar.start.call({}, s.replace(/^\s*(\S*(\s+\S+)*)\s*$/, "$1")); } catch (e) { return null; } return ((r[1].length === 0) ? r[0] : null); }, nativeFallback: function(s) { var t; try { // ok we haven't parsed it, last ditch attempt with the built-in parser. t = Date._parse(s); return (t || t === 0) ? new Date(t) : null; } catch (e) { return null; } } }; function parse (s) { var d; if (!s) { return null; } if (s instanceof Date) { return s.clone(); } if (s.length >= 4 && s.charAt(0) !== "0" && s.charAt(0) !== "+"&& s.charAt(0) !== "-") { // ie: 2004 will pass, 0800 won't. // Start with specific formats d = $D.Parsing.ISO.parse(s) || $D.Parsing.Numeric.parse(s); } if (d instanceof Date && !isNaN(d.getTime())) { return d; } else { // find ordinal dates (1st, 3rd, 8th, etc and remove them as they cause parsing issues) s = $D.Parsing.Normalizer.parse(parseUtils.removeOrds(s)); d = parseUtils.grammarParser(s); if (d !== null) { return d; } else { return parseUtils.nativeFallback(s); } } } if (!$D._parse) { $D._parse = $D.parse; } $D.parse = parse; Date.getParseFunction = function (fx) { var fns = Date.Grammar.allformats(fx); return function (s) { var r = null; for (var i = 0; i < fns.length; i++) { try { r = fns[i].call({}, s); } catch (e) { continue; } if (r[1].length === 0) { return r[0]; } } return null; }; }; /** * Converts the specified string value into its JavaScript Date equivalent using the specified format {String} or formats {Array} and the CultureInfo specific format information. * The format of the string value must match one of the supplied formats exactly. * * Example

	// 15-Oct-2004
	var d1 = Date.parseExact("10/15/2004", "M/d/yyyy");

	// 15-Oct-2004
	var d1 = Date.parse("15-Oct-2004", "M-ddd-yyyy");

	// 15-Oct-2004
	var d1 = Date.parse("2004.10.15", "yyyy.MM.dd");

	// Multiple formats
	var d1 = Date.parseExact("10/15/2004", ["M/d/yyyy", "MMMM d, yyyy"]);
	
* * @param {String} The string value to convert into a Date object [Required]. * @param {Object} The expected format {String} or an array of expected formats {Array} of the date string [Required]. * @return {Date} A Date object or null if the string cannot be converted into a Date. */ $D.parseExact = function (s, fx) { return $D.getParseFunction(fx)(s); }; }()); (function () { var $D = Date, $P = $D.prototype, // $C = $D.CultureInfo, // not used atm p = function (s, l) { if (!l) { l = 2; } return ("000" + s).slice(l * -1); }; /** * Converts a PHP format string to Java/.NET format string. * A PHP format string can be used with ._format or .format. * A Java/.NET format string can be used with .toString(). * The .parseExact function will only accept a Java/.NET format string * * Example * var f1 = "%m/%d/%y" * var f2 = Date.normalizeFormat(f1); // "MM/dd/yy" * * new Date().format(f1); // "04/13/08" * new Date()._format(f1); // "04/13/08" * new Date().toString(f2); // "04/13/08" * * var date = Date.parseExact("04/13/08", f2); // Sun Apr 13 2008 * * @param {String} A PHP format string consisting of one or more format spcifiers. * @return {String} The PHP format converted to a Java/.NET format string. */ var normalizerSubstitutions = { "d" : "dd", "%d": "dd", "D" : "ddd", "%a": "ddd", "j" : "dddd", "l" : "dddd", "%A": "dddd", "S" : "S", "F" : "MMMM", "%B": "MMMM", "m" : "MM", "%m": "MM", "M" : "MMM", "%b": "MMM", "%h": "MMM", "n" : "M", "Y" : "yyyy", "%Y": "yyyy", "y" : "yy", "%y": "yy", "g" : "h", "%I": "h", "G" : "H", "h" : "hh", "H" : "HH", "%H": "HH", "i" : "mm", "%M": "mm", "s" : "ss", "%S": "ss", "%r": "hh:mm tt", "%R": "H:mm", "%T": "H:mm:ss", "%X": "t", "%x": "d", "%e": "d", "%D": "MM/dd/yy", "%n": "\\n", "%t": "\\t", "e" : "z", "T" : "z", "%z": "z", "%Z": "z", "Z" : "ZZ", "N" : "u", "w" : "u", "%w": "u", "W" : "W", "%V": "W" }; var normalizer = { substitutes: function (m) { return normalizerSubstitutions[m]; }, interpreted: function (m, x) { var y; switch (m) { case "%u": return x.getDay() + 1; case "z": return x.getOrdinalNumber(); case "%j": return p(x.getOrdinalNumber(), 3); case "%U": var d1 = x.clone().set({month: 0, day: 1}).addDays(-1).moveToDayOfWeek(0), d2 = x.clone().addDays(1).moveToDayOfWeek(0, -1); return (d2 < d1) ? "00" : p((d2.getOrdinalNumber() - d1.getOrdinalNumber()) / 7 + 1); case "%W": return p(x.getWeek()); case "t": return $D.getDaysInMonth(x.getFullYear(), x.getMonth()); case "o": case "%G": return x.setWeek(x.getISOWeek()).toString("yyyy"); case "%g": return x._format("%G").slice(-2); case "a": case "%p": return t("tt").toLowerCase(); case "A": return t("tt").toUpperCase(); case "u": return p(x.getMilliseconds(), 3); case "I": return (x.isDaylightSavingTime()) ? 1 : 0; case "O": return x.getUTCOffset(); case "P": y = x.getUTCOffset(); return y.substring(0, y.length - 2) + ":" + y.substring(y.length - 2); case "B": var now = new Date(); return Math.floor(((now.getHours() * 3600) + (now.getMinutes() * 60) + now.getSeconds() + (now.getTimezoneOffset() + 60) * 60) / 86.4); case "c": return x.toISOString().replace(/\"/g, ""); case "U": return $D.strtotime("now"); case "%c": return t("d") + " " + t("t"); case "%C": return Math.floor(x.getFullYear() / 100 + 1); } }, shouldOverrideDefaults: function (m) { switch (m) { case "%e": return true; default: return false; } }, parse: function (m, context) { var formatString, c = context || new Date(); formatString = normalizer.substitutes(m); if (formatString) { return formatString; } formatString = normalizer.interpreted(m, c); if (formatString) { return formatString; } else { return m; } } }; $D.normalizeFormat = function (format, context) { return format.replace(/(%|\\)?.|%%/g, function(t){ return normalizer.parse(t, context); }); }; /** * Format a local Unix timestamp according to locale settings * * Example: * Date.strftime("%m/%d/%y", new Date()); // "04/13/08" * Date.strftime("c", "2008-04-13T17:52:03Z"); // "04/13/08" * * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @param {Number|String} The number representing the number of seconds that have elapsed since January 1, 1970 (local time). * @return {String} A string representation of the current Date object. */ $D.strftime = function (format, time) { var d = Date.parse(time); return d._format(format); }; /** * Parse any textual datetime description into a Unix timestamp. * A Unix timestamp is the number of seconds that have elapsed since January 1, 1970 (midnight UTC/GMT). * * Example: * Date.strtotime("04/13/08"); // 1208044800 * Date.strtotime("1970-01-01T00:00:00Z"); // 0 * * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @param {Object} A string or date object. * @return {String} A string representation of the current Date object. */ $D.strtotime = function (time) { var d = $D.parse(time); return Math.round($D.UTC(d.getUTCFullYear(), d.getUTCMonth(), d.getUTCDate(), d.getUTCHours(), d.getUTCMinutes(), d.getUTCSeconds(), d.getUTCMilliseconds()) / 1000); }; /** * Converts the value of the current Date object to its equivalent string representation using a PHP/Unix style of date format specifiers. * Format Specifiers * Format Description Example * ------ --------------------------------------------------------------------------- ----------------------- * %a abbreviated weekday name according to the current localed "Mon" through "Sun" * %A full weekday name according to the current localed "Sunday" through "Saturday" * %b abbreviated month name according to the current localed "Jan" through "Dec" * %B full month name according to the current locale "January" through "December" * %c preferred date and time representation for the current locale "4/13/2008 12:33 PM" * %C century number (the year divided by 100 and truncated to an integer) "00" to "99" * %d day of the month as a decimal number "01" to "31" * %D same as %m/%d/%y "04/13/08" * %e day of the month as a decimal number, a single digit is preceded by a space "1" to "31" * %g like %G, but without the century "08" * %G The 4-digit year corresponding to the ISO week number (see %V). "2008" * This has the same format and value as %Y, except that if the ISO week number * belongs to the previous or next year, that year is used instead. * %h same as %b "Jan" through "Dec" * %H hour as a decimal number using a 24-hour clock. "00" to "23" * %I hour as a decimal number using a 12-hour clock. "01" to "12" * %j day of the year as a decimal number. "001" to "366" * %m month as a decimal number. "01" to "12" * %M minute as a decimal number. "00" to "59" * %n newline character "\n" * %p either "am" or "pm" according to the given time value, or the "am" or "pm" * corresponding strings for the current locale. * %r time in a.m. and p.m. notation "8:44 PM" * %R time in 24 hour notation "20:44" * %S second as a decimal number "00" to "59" * %t tab character "\t" * %T current time, equal to %H:%M:%S "12:49:11" * %u weekday as a decimal number ["1", "7"], with "1" representing Monday "1" to "7" * %U week number of the current year as a decimal number, starting with the "0" to ("52" or "53") * first Sunday as the first day of the first week * %V The ISO 8601:1988 week number of the current year as a decimal number, "00" to ("52" or "53") * range 01 to 53, where week 1 is the first week that has at least 4 days * in the current year, and with Monday as the first day of the week. * (Use %G or %g for the year component that corresponds to the week number * for the specified timestamp.) * %W week number of the current year as a decimal number, starting with the "00" to ("52" or "53") * first Monday as the first day of the first week * %w day of the week as a decimal, Sunday being "0" "0" to "6" * %x preferred date representation for the current locale without the time "4/13/2008" * %X preferred time representation for the current locale without the date "12:53:05" * %y year as a decimal number without a century "00" "99" * %Y year as a decimal number including the century "2008" * %Z time zone or name or abbreviation "UTC", "EST", "PST" * %z same as %Z * %% a literal "%" characters "%" * d Day of the month, 2 digits with leading zeros "01" to "31" * D A textual representation of a day, three letters "Mon" through "Sun" * j Day of the month without leading zeros "1" to "31" * l A full textual representation of the day of the week (lowercase "L") "Sunday" through "Saturday" * N ISO-8601 numeric representation of the day of the week (added in PHP 5.1.0) "1" (for Monday) through "7" (for Sunday) * S English ordinal suffix for the day of the month, 2 characters "st", "nd", "rd" or "th". Works well with j * w Numeric representation of the day of the week "0" (for Sunday) through "6" (for Saturday) * z The day of the year (starting from "0") "0" through "365" * W ISO-8601 week number of year, weeks starting on Monday "00" to ("52" or "53") * F A full textual representation of a month, such as January or March "January" through "December" * m Numeric representation of a month, with leading zeros "01" through "12" * M A short textual representation of a month, three letters "Jan" through "Dec" * n Numeric representation of a month, without leading zeros "1" through "12" * t Number of days in the given month "28" through "31" * L Whether it's a leap year "1" if it is a leap year, "0" otherwise * o ISO-8601 year number. This has the same value as Y, except that if the "2008" * ISO week number (W) belongs to the previous or next year, that year * is used instead. * Y A full numeric representation of a year, 4 digits "2008" * y A two digit representation of a year "08" * a Lowercase Ante meridiem and Post meridiem "am" or "pm" * A Uppercase Ante meridiem and Post meridiem "AM" or "PM" * B Swatch Internet time "000" through "999" * g 12-hour format of an hour without leading zeros "1" through "12" * G 24-hour format of an hour without leading zeros "0" through "23" * h 12-hour format of an hour with leading zeros "01" through "12" * H 24-hour format of an hour with leading zeros "00" through "23" * i Minutes with leading zeros "00" to "59" * s Seconds, with leading zeros "00" through "59" * u Milliseconds "54321" * e Timezone identifier "UTC", "EST", "PST" * I Whether or not the date is in daylight saving time (uppercase i) "1" if Daylight Saving Time, "0" otherwise * O Difference to Greenwich time (GMT) in hours "+0200", "-0600" * P Difference to Greenwich time (GMT) with colon between hours and minutes "+02:00", "-06:00" * T Timezone abbreviation "UTC", "EST", "PST" * Z Timezone offset in seconds. The offset for timezones west of UTC is "-43200" through "50400" * always negative, and for those east of UTC is always positive. * c ISO 8601 date "2004-02-12T15:19:21+00:00" * r RFC 2822 formatted date "Thu, 21 Dec 2000 16:01:07 +0200" * U Seconds since the Unix Epoch (January 1 1970 00:00:00 GMT) "0" * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @return {String} A string representation of the current Date object. */ var formatReplace = function (context) { return function (m) { var formatString, override = false; if (m.charAt(0) === "\\" || m.substring(0, 2) === "%%") { return m.replace("\\", "").replace("%%", "%"); } override = normalizer.shouldOverrideDefaults(m); formatString = $D.normalizeFormat(m, context); if (formatString) { return context.toString(formatString, override); } }; }; $P._format = function (format) { var formatter = formatReplace(this); if (!format) { return this._toString(); } else { return format.replace(/(%|\\)?.|%%/g, formatter); } }; if (!$P.format) { $P.format = $P._format; } }()); (function () { "use strict"; var gFn = function (attr) { return function () { return this[attr]; }; }; var sFn = function (attr) { return function (val) { this[attr] = val; return this; }; }; var attrs = ["years", "months", "days", "hours", "minutes", "seconds", "milliseconds"]; var addSetFuncs = function (context, attrs) { for (var i = 0; i < attrs.length ; i++) { var $a = attrs[i], $b = $a.slice(0, 1).toUpperCase() + $a.slice(1); context.prototype[$a] = 0; context.prototype["get" + $b] = gFn($a); context.prototype["set" + $b] = sFn($a); } }; /** * new TimeSpan(milliseconds); * new TimeSpan(days, hours, minutes, seconds); * new TimeSpan(days, hours, minutes, seconds, milliseconds); */ var TimeSpan = function (days, hours, minutes, seconds, milliseconds) { if (arguments.length === 1 && typeof days === "number") { var orient = (days < 0) ? -1 : +1; var millsLeft = Math.abs(days); this.setDays(Math.floor(millsLeft / 86400000) * orient); millsLeft = millsLeft % 86400000; this.setHours(Math.floor(millsLeft / 3600000) * orient); millsLeft = millsLeft % 3600000; this.setMinutes(Math.floor(millsLeft / 60000) * orient); millsLeft = millsLeft % 60000; this.setSeconds(Math.floor(millsLeft / 1000) * orient); millsLeft = millsLeft % 1000; this.setMilliseconds(millsLeft * orient); } else { this.set(days, hours, minutes, seconds, milliseconds); } this.getTotalMilliseconds = function () { return (this.getDays() * 86400000) + (this.getHours() * 3600000) + (this.getMinutes() * 60000) + (this.getSeconds() * 1000); }; this.compareTo = function (time) { var t1 = new Date(1970, 1, 1, this.getHours(), this.getMinutes(), this.getSeconds()), t2; if (time === null) { t2 = new Date(1970, 1, 1, 0, 0, 0); } else { t2 = new Date(1970, 1, 1, time.getHours(), time.getMinutes(), time.getSeconds()); } return (t1 < t2) ? -1 : (t1 > t2) ? 1 : 0; }; this.equals = function (time) { return (this.compareTo(time) === 0); }; this.add = function (time) { return (time === null) ? this : this.addSeconds(time.getTotalMilliseconds() / 1000); }; this.subtract = function (time) { return (time === null) ? this : this.addSeconds(-time.getTotalMilliseconds() / 1000); }; this.addDays = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 86400000)); }; this.addHours = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 3600000)); }; this.addMinutes = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 60000)); }; this.addSeconds = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 1000)); }; this.addMilliseconds = function (n) { return new TimeSpan(this.getTotalMilliseconds() + n); }; this.get12HourHour = function () { return (this.getHours() > 12) ? this.getHours() - 12 : (this.getHours() === 0) ? 12 : this.getHours(); }; this.getDesignator = function () { return (this.getHours() < 12) ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator; }; this.toString = function (format) { this._toString = function () { if (this.getDays() !== null && this.getDays() > 0) { return this.getDays() + "." + this.getHours() + ":" + this.p(this.getMinutes()) + ":" + this.p(this.getSeconds()); } else { return this.getHours() + ":" + this.p(this.getMinutes()) + ":" + this.p(this.getSeconds()); } }; this.p = function (s) { return (s.toString().length < 2) ? "0" + s : s; }; var me = this; return format ? format.replace(/dd?|HH?|hh?|mm?|ss?|tt?/g, function (format) { switch (format) { case "d": return me.getDays(); case "dd": return me.p(me.getDays()); case "H": return me.getHours(); case "HH": return me.p(me.getHours()); case "h": return me.get12HourHour(); case "hh": return me.p(me.get12HourHour()); case "m": return me.getMinutes(); case "mm": return me.p(me.getMinutes()); case "s": return me.getSeconds(); case "ss": return me.p(me.getSeconds()); case "t": return ((me.getHours() < 12) ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator).substring(0, 1); case "tt": return (me.getHours() < 12) ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator; } } ) : this._toString(); }; return this; }; addSetFuncs(TimeSpan, attrs.slice(2)); TimeSpan.prototype.set = function (days, hours, minutes, seconds, milliseconds){ this.setDays(days || this.getDays()); this.setHours(hours || this.getHours()); this.setMinutes(minutes || this.getMinutes()); this.setSeconds(seconds || this.getSeconds()); this.setMilliseconds(milliseconds || this.getMilliseconds()); }; /** * Gets the time of day for this date instances. * @return {TimeSpan} TimeSpan */ Date.prototype.getTimeOfDay = function () { return new TimeSpan(0, this.getHours(), this.getMinutes(), this.getSeconds(), this.getMilliseconds()); }; Date.TimeSpan = TimeSpan; if (typeof window !== "undefined" ) { // keeping API compatible for v1.x window.TimeSpan = TimeSpan; } }()); (function () { "use strict"; var attrs = ["years", "months", "days", "hours", "minutes", "seconds", "milliseconds"]; var gFn = function (attr) { return function () { return this[attr]; }; }; var sFn = function (attr) { return function (val) { this[attr] = val; return this; }; }; var addSetFuncs = function (context, attrs) { for (var i = 0; i < attrs.length ; i++) { var $a = attrs[i], $b = $a.slice(0, 1).toUpperCase() + $a.slice(1); context.prototype[$a] = 0; context.prototype["get" + $b] = gFn($a); context.prototype["set" + $b] = sFn($a); } }; var setMonthsAndYears = function (orient, d1, d2, context) { function inc() { d1.addMonths(-orient); context.months++; if (context.months === 12) { context.years++; context.months = 0; } } if (orient === +1) { while (d1 > d2) { inc(); } } else { while (d1 < d2) { inc(); } } context.months--; context.months *= orient; context.years *= orient; }; var adjustForDST = function(orient, startDate, endDate) { var hasDSTMismatch = (false === (startDate.isDaylightSavingTime() === endDate.isDaylightSavingTime())); if (hasDSTMismatch && orient === 1) { startDate.addHours(-1); } else if (hasDSTMismatch) { startDate.addHours(1); } }; /** * TimePeriod(startDate, endDate); * TimePeriod(years, months, days, hours, minutes, seconds, milliseconds); */ var TimePeriod = function (years, months, days, hours, minutes, seconds, milliseconds) { if (arguments.length === 7) { this.set(years, months, days, hours, minutes, seconds, milliseconds); } else if (arguments.length === 2 && arguments[0] instanceof Date && arguments[1] instanceof Date) { var startDate = arguments[0].clone(); var endDate = arguments[1].clone(); var orient = (startDate > endDate) ? +1 : -1; this.dates = { start: arguments[0].clone(), end: arguments[1].clone() }; setMonthsAndYears(orient, startDate, endDate, this); adjustForDST(orient, startDate, endDate); // // TODO - adjust for DST var diff = endDate - startDate; if (diff !== 0) { var ts = new TimeSpan(diff); this.set(this.years, this.months, ts.getDays(), ts.getHours(), ts.getMinutes(), ts.getSeconds(), ts.getMilliseconds()); } } return this; }; // create all the set functions. addSetFuncs(TimePeriod, attrs); TimePeriod.prototype.set = function (years, months, days, hours, minutes, seconds, milliseconds){ this.setYears(years || this.getYears()); this.setMonths(months || this.getMonths()); this.setDays(days || this.getDays()); this.setHours(hours || this.getHours()); this.setMinutes(minutes || this.getMinutes()); this.setSeconds(seconds || this.getSeconds()); this.setMilliseconds(milliseconds || this.getMilliseconds()); }; Date.TimePeriod = TimePeriod; if (typeof window !== "undefined") { // keeping API compatible for v1.x window.TimePeriod = TimePeriod; } }()); ================================================ FILE: build/date-fr-FR.js ================================================ /** * @overview datejs * @version 1.0.0-rc3 * @author Gregory Wild-Smith * @copyright 2015 Gregory Wild-Smith * @license MIT * @homepage https://github.com/abritinthebay/datejs */ /* * DateJS Culture String File * Country Code: fr-FR * Name: French (France) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["fr-FR"] = { "name": "fr-FR", "englishName": "French (France)", "nativeName": "français (France)", "Sunday": "dimanche", "Monday": "lundi", "Tuesday": "mardi", "Wednesday": "mercredi", "Thursday": "jeudi", "Friday": "vendredi", "Saturday": "samedi", "Sun": "dim.", "Mon": "lun.", "Tue": "mar.", "Wed": "mer.", "Thu": "jeu.", "Fri": "ven.", "Sat": "sam.", "Su": "di", "Mo": "lu", "Tu": "ma", "We": "me", "Th": "je", "Fr": "ve", "Sa": "sa", "S_Sun_Initial": "d", "M_Mon_Initial": "l", "T_Tue_Initial": "m", "W_Wed_Initial": "m", "T_Thu_Initial": "j", "F_Fri_Initial": "v", "S_Sat_Initial": "s", "January": "janvier", "February": "février", "March": "mars", "April": "avril", "May": "mai", "June": "juin", "July": "juillet", "August": "août", "September": "septembre", "October": "octobre", "November": "novembre", "December": "décembre", "Jan_Abbr": "janv.", "Feb_Abbr": "févr.", "Mar_Abbr": "mars", "Apr_Abbr": "avr.", "May_Abbr": "mai", "Jun_Abbr": "juin", "Jul_Abbr": "juil.", "Aug_Abbr": "août", "Sep_Abbr": "sept.", "Oct_Abbr": "oct.", "Nov_Abbr": "nov.", "Dec_Abbr": "déc.", "AM": "", "PM": "", "firstDayOfWeek": 1, "twoDigitYearMax": 2029, "mdy": "dmy", "M/d/yyyy": "dd/MM/yyyy", "dddd, MMMM dd, yyyy": "dddd d MMMM yyyy", "h:mm tt": "HH:mm", "h:mm:ss tt": "HH:mm:ss", "dddd, MMMM dd, yyyy h:mm:ss tt": "dddd d MMMM yyyy HH:mm:ss", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "d MMMM", "MMMM, yyyy": "MMMM yyyy", "/jan(uary)?/": "janv(.(ier)?)?", "/feb(ruary)?/": "févr(.(ier)?)?", "/mar(ch)?/": "mars", "/apr(il)?/": "avr(.(il)?)?", "/may/": "mai", "/jun(e)?/": "juin", "/jul(y)?/": "juil(.(let)?)?", "/aug(ust)?/": "août", "/sep(t(ember)?)?/": "sept(.(embre)?)?", "/oct(ober)?/": "oct(.(obre)?)?", "/nov(ember)?/": "nov(.(embre)?)?", "/dec(ember)?/": "déc(.(embre)?)?", "/^su(n(day)?)?/": "^di(m(.(anche)?)?)?", "/^mo(n(day)?)?/": "^lu(n(.(di)?)?)?", "/^tu(e(s(day)?)?)?/": "^ma(r(.(di)?)?)?", "/^we(d(nesday)?)?/": "^me(r(.(credi)?)?)?", "/^th(u(r(s(day)?)?)?)?/": "^je(u(.(di)?)?)?", "/^fr(i(day)?)?/": "^ve(n(.(dredi)?)?)?", "/^sa(t(urday)?)?/": "^sa(m(.(edi)?)?)?", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "fr-FR"; /** * @overview datejs * @version 1.0.0-rc3 * @author Gregory Wild-Smith * @copyright 2015 Gregory Wild-Smith * @license MIT * @homepage https://github.com/abritinthebay/datejs */(function () { var $D = Date; var lang = Date.CultureStrings ? Date.CultureStrings.lang : null; var loggedKeys = {}; // for debug purposes. var getText = { getFromKey: function (key, countryCode) { var output; if (Date.CultureStrings && Date.CultureStrings[countryCode] && Date.CultureStrings[countryCode][key]) { output = Date.CultureStrings[countryCode][key]; } else { output = getText.buildFromDefault(key); } if (key.charAt(0) === "/") { // Assume it's a regex output = getText.buildFromRegex(key, countryCode); } return output; }, getFromObjectValues: function (obj, countryCode) { var key, output = {}; for(key in obj) { if (obj.hasOwnProperty(key)) { output[key] = getText.getFromKey(obj[key], countryCode); } } return output; }, getFromObjectKeys: function (obj, countryCode) { var key, output = {}; for(key in obj) { if (obj.hasOwnProperty(key)) { output[getText.getFromKey(key, countryCode)] = obj[key]; } } return output; }, getFromArray: function (arr, countryCode) { var output = []; for (var i=0; i < arr.length; i++){ if (i in arr) { output[i] = getText.getFromKey(arr[i], countryCode); } } return output; }, buildFromDefault: function (key) { var output, length, split, last; switch(key) { case "name": output = "en-US"; break; case "englishName": output = "English (United States)"; break; case "nativeName": output = "English (United States)"; break; case "twoDigitYearMax": output = 2049; break; case "firstDayOfWeek": output = 0; break; default: output = key; split = key.split("_"); length = split.length; if (length > 1 && key.charAt(0) !== "/") { // if the key isn't a regex and it has a split. last = split[(length - 1)].toLowerCase(); if (last === "initial" || last === "abbr") { output = split[0]; } } break; } return output; }, buildFromRegex: function (key, countryCode) { var output; if (Date.CultureStrings && Date.CultureStrings[countryCode] && Date.CultureStrings[countryCode][key]) { output = new RegExp(Date.CultureStrings[countryCode][key], "i"); } else { output = new RegExp(key.replace(new RegExp("/", "g"),""), "i"); } return output; } }; var shallowMerge = function (obj1, obj2) { for (var attrname in obj2) { if (obj2.hasOwnProperty(attrname)) { obj1[attrname] = obj2[attrname]; } } }; var __ = function (key, language) { var countryCode = (language) ? language : lang; loggedKeys[key] = key; if (typeof key === "object") { if (key instanceof Array) { return getText.getFromArray(key, countryCode); } else { return getText.getFromObjectKeys(key, countryCode); } } else { return getText.getFromKey(key, countryCode); } }; var loadI18nScript = function (code) { // paatterned after jQuery's getScript. var url = Date.Config.i18n + code + ".js"; var head = document.getElementsByTagName("head")[0] || document.documentElement; var script = document.createElement("script"); script.src = url; var completed = false; var events = { done: function (){} // placeholder function }; // Attach handlers for all browsers script.onload = script.onreadystatechange = function() { if ( !completed && (!this.readyState || this.readyState === "loaded" || this.readyState === "complete") ) { events.done(); head.removeChild(script); } }; setTimeout(function() { head.insertBefore(script, head.firstChild); }, 0); // allows return to execute first return { done: function (cb) { events.done = function() { if (cb) { setTimeout(cb,0); } }; } }; }; var buildInfo = { buildFromMethodHash: function (obj) { var key; for(key in obj) { if (obj.hasOwnProperty(key)) { obj[key] = buildInfo[obj[key]](); } } return obj; }, timeZoneDST: function () { var DST = { "CHADT": "+1345", "NZDT": "+1300", "AEDT": "+1100", "ACDT": "+1030", "AZST": "+0500", "IRDT": "+0430", "EEST": "+0300", "CEST": "+0200", "BST": "+0100", "PMDT": "-0200", "ADT": "-0300", "NDT": "-0230", "EDT": "-0400", "CDT": "-0500", "MDT": "-0600", "PDT": "-0700", "AKDT": "-0800", "HADT": "-0900" }; return __(DST); }, timeZoneStandard: function () { var standard = { "LINT": "+1400", "TOT": "+1300", "CHAST": "+1245", "NZST": "+1200", "NFT": "+1130", "SBT": "+1100", "AEST": "+1000", "ACST": "+0930", "JST": "+0900", "CWST": "+0845", "CT": "+0800", "ICT": "+0700", "MMT": "+0630", "BST": "+0600", "NPT": "+0545", "IST": "+0530", "PKT": "+0500", "AFT": "+0430", "MSK": "+0400", "IRST": "+0330", "FET": "+0300", "EET": "+0200", "CET": "+0100", "GMT": "+0000", "UTC": "+0000", "CVT": "-0100", "GST": "-0200", "BRT": "-0300", "NST": "-0330", "AST": "-0400", "EST": "-0500", "CST": "-0600", "MST": "-0700", "PST": "-0800", "AKST": "-0900", "MIT": "-0930", "HST": "-1000", "SST": "-1100", "BIT": "-1200" }; return __(standard); }, timeZones: function (data) { var zone; data.timezones = []; for (zone in data.abbreviatedTimeZoneStandard) { if (data.abbreviatedTimeZoneStandard.hasOwnProperty(zone)) { data.timezones.push({ name: zone, offset: data.abbreviatedTimeZoneStandard[zone]}); } } for (zone in data.abbreviatedTimeZoneDST) { if (data.abbreviatedTimeZoneDST.hasOwnProperty(zone)) { data.timezones.push({ name: zone, offset: data.abbreviatedTimeZoneDST[zone], dst: true}); } } return data.timezones; }, days: function () { return __(["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"]); }, dayAbbr: function () { return __(["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"]); }, dayShortNames: function () { return __(["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"]); }, dayFirstLetters: function () { return __(["S_Sun_Initial", "M_Mon_Initial", "T_Tues_Initial", "W_Wed_Initial", "T_Thu_Initial", "F_Fri_Initial", "S_Sat_Initial"]); }, months: function () { return __(["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"]); }, monthAbbr: function () { return __(["Jan_Abbr", "Feb_Abbr", "Mar_Abbr", "Apr_Abbr", "May_Abbr", "Jun_Abbr", "Jul_Abbr", "Aug_Abbr", "Sep_Abbr", "Oct_Abbr", "Nov_Abbr", "Dec_Abbr"]); }, formatPatterns: function () { return getText.getFromObjectValues({ shortDate: "M/d/yyyy", longDate: "dddd, MMMM dd, yyyy", shortTime: "h:mm tt", longTime: "h:mm:ss tt", fullDateTime: "dddd, MMMM dd, yyyy h:mm:ss tt", sortableDateTime: "yyyy-MM-ddTHH:mm:ss", universalSortableDateTime: "yyyy-MM-dd HH:mm:ssZ", rfc1123: "ddd, dd MMM yyyy HH:mm:ss", monthDay: "MMMM dd", yearMonth: "MMMM, yyyy" }, Date.i18n.currentLanguage()); }, regex: function () { return getText.getFromObjectValues({ inTheMorning: "/( in the )(morn(ing)?)\\b/", thisMorning: "/(this )(morn(ing)?)\\b/", amThisMorning: "/(\b\\d(am)? )(this )(morn(ing)?)/", inTheEvening: "/( in the )(even(ing)?)\\b/", thisEvening: "/(this )(even(ing)?)\\b/", pmThisEvening: "/(\b\\d(pm)? )(this )(even(ing)?)/", jan: "/jan(uary)?/", feb: "/feb(ruary)?/", mar: "/mar(ch)?/", apr: "/apr(il)?/", may: "/may/", jun: "/jun(e)?/", jul: "/jul(y)?/", aug: "/aug(ust)?/", sep: "/sep(t(ember)?)?/", oct: "/oct(ober)?/", nov: "/nov(ember)?/", dec: "/dec(ember)?/", sun: "/^su(n(day)?)?/", mon: "/^mo(n(day)?)?/", tue: "/^tu(e(s(day)?)?)?/", wed: "/^we(d(nesday)?)?/", thu: "/^th(u(r(s(day)?)?)?)?/", fri: "/fr(i(day)?)?/", sat: "/^sa(t(urday)?)?/", future: "/^next/", past: "/^last|past|prev(ious)?/", add: "/^(\\+|aft(er)?|from|hence)/", subtract: "/^(\\-|bef(ore)?|ago)/", yesterday: "/^yes(terday)?/", today: "/^t(od(ay)?)?/", tomorrow: "/^tom(orrow)?/", now: "/^n(ow)?/", millisecond: "/^ms|milli(second)?s?/", second: "/^sec(ond)?s?/", minute: "/^mn|min(ute)?s?/", hour: "/^h(our)?s?/", week: "/^w(eek)?s?/", month: "/^m(onth)?s?/", day: "/^d(ay)?s?/", year: "/^y(ear)?s?/", shortMeridian: "/^(a|p)/", longMeridian: "/^(a\\.?m?\\.?|p\\.?m?\\.?)/", timezone: "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/", ordinalSuffix: "/^\\s*(st|nd|rd|th)/", timeContext: "/^\\s*(\\:|a(?!u|p)|p)/" }, Date.i18n.currentLanguage()); } }; var CultureInfo = function () { var info = getText.getFromObjectValues({ name: "name", englishName: "englishName", nativeName: "nativeName", amDesignator: "AM", pmDesignator: "PM", firstDayOfWeek: "firstDayOfWeek", twoDigitYearMax: "twoDigitYearMax", dateElementOrder: "mdy" }, Date.i18n.currentLanguage()); var constructedInfo = buildInfo.buildFromMethodHash({ dayNames: "days", abbreviatedDayNames: "dayAbbr", shortestDayNames: "dayShortNames", firstLetterDayNames: "dayFirstLetters", monthNames: "months", abbreviatedMonthNames: "monthAbbr", formatPatterns: "formatPatterns", regexPatterns: "regex", abbreviatedTimeZoneDST: "timeZoneDST", abbreviatedTimeZoneStandard: "timeZoneStandard" }); shallowMerge(info, constructedInfo); buildInfo.timeZones(info); return info; }; $D.i18n = { __: function (key, lang) { return __(key, lang); }, currentLanguage: function () { return lang || "en-US"; }, setLanguage: function (code, force, cb) { var async = false; if (force || code === "en-US" || (!!Date.CultureStrings && !!Date.CultureStrings[code])) { lang = code; Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings.lang = code; Date.CultureInfo = new CultureInfo(); } else { if (!(!!Date.CultureStrings && !!Date.CultureStrings[code])) { if (typeof exports !== "undefined" && this.exports !== exports) { // we're in a Node enviroment, load it using require try { require("../i18n/" + code + ".js"); lang = code; Date.CultureStrings.lang = code; Date.CultureInfo = new CultureInfo(); } catch (e) { // var str = "The language for '" + code + "' could not be loaded by Node. It likely does not exist."; throw new Error("The DateJS IETF language tag '" + code + "' could not be loaded by Node. It likely does not exist."); } } else if (Date.Config && Date.Config.i18n) { // we know the location of the files, so lets load them async = true; loadI18nScript(code).done(function(){ lang = code; Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings.lang = code; Date.CultureInfo = new CultureInfo(); $D.Parsing.Normalizer.buildReplaceData(); // because this is async if ($D.Grammar) { $D.Grammar.buildGrammarFormats(); // so we can parse those strings... } if (cb) { setTimeout(cb,0); } }); } else { Date.console.error("The DateJS IETF language tag '" + code + "' is not available and has not been loaded."); return false; } } } $D.Parsing.Normalizer.buildReplaceData(); // rebuild normalizer strings if ($D.Grammar) { $D.Grammar.buildGrammarFormats(); // so we can parse those strings... } if (!async && cb) { setTimeout(cb,0); } }, getLoggedKeys: function () { return loggedKeys; }, updateCultureInfo: function () { Date.CultureInfo = new CultureInfo(); } }; $D.i18n.updateCultureInfo(); // run automatically }()); (function () { var $D = Date, $P = $D.prototype, p = function (s, l) { if (!l) { l = 2; } return ("000" + s).slice(l * -1); }; if (typeof window !== "undefined" && typeof window.console !== "undefined" && typeof window.console.log !== "undefined") { $D.console = console; // used only to raise non-critical errors if available } else { // set mock so we don't give errors. $D.console = { log: function(){}, error: function(){} }; } $D.Config = $D.Config || {}; $D.initOverloads = function() { /** * Overload of Date.now. Allows an alternate call for Date.now where it returns the * current Date as an object rather than just milliseconds since the Unix Epoch. * * Also provides an implementation of now() for browsers (IE<9) that don't have it. * * Backwards compatible so with work with either: * Date.now() [returns ms] * or * Date.now(true) [returns Date] */ if (!$D.now) { $D._now = function now() { return new Date().getTime(); }; } else if (!$D._now) { $D._now = $D.now; } $D.now = function (returnObj) { if (returnObj) { return $D.present(); } else { return $D._now(); } }; if ( !$P.toISOString ) { $P.toISOString = function() { return this.getUTCFullYear() + "-" + p(this.getUTCMonth() + 1) + "-" + p(this.getUTCDate()) + "T" + p(this.getUTCHours()) + ":" + p(this.getUTCMinutes()) + ":" + p(this.getUTCSeconds()) + "." + String( (this.getUTCMilliseconds()/1000).toFixed(3)).slice(2, 5) + "Z"; }; } // private if ( $P._toString === undefined ){ $P._toString = $P.toString; } }; $D.initOverloads(); /** * Gets a date that is set to the current date. The time is set to the start of the day (00:00 or 12:00 AM). * @return {Date} The current date. */ $D.today = function () { return new Date().clearTime(); }; /** * Gets a date that is set to the current date and time (same as new Date, but chainable) * @return {Date} The current date. */ $D.present = function () { return new Date(); }; /** * Compares the first date to the second date and returns an number indication of their relative values. * @param {Date} First Date object to compare [Required]. * @param {Date} Second Date object to compare to [Required]. * @return {Number} -1 = date1 is lessthan date2. 0 = values are equal. 1 = date1 is greaterthan date2. */ $D.compare = function (date1, date2) { if (isNaN(date1) || isNaN(date2)) { throw new Error(date1 + " - " + date2); } else if (date1 instanceof Date && date2 instanceof Date) { return (date1 < date2) ? -1 : (date1 > date2) ? 1 : 0; } else { throw new TypeError(date1 + " - " + date2); } }; /** * Compares the first Date object to the second Date object and returns true if they are equal. * @param {Date} First Date object to compare [Required] * @param {Date} Second Date object to compare to [Required] * @return {Boolean} true if dates are equal. false if they are not equal. */ $D.equals = function (date1, date2) { return (date1.compareTo(date2) === 0); }; /** * Gets the language appropriate day name when given the day number(0-6) * eg - 0 == Sunday * @return {String} The day name */ $D.getDayName = function (n) { return Date.CultureInfo.dayNames[n]; }; /** * Gets the day number (0-6) if given a CultureInfo specific string which is a valid dayName, abbreviatedDayName or shortestDayName (two char). * @param {String} The name of the day (eg. "Monday, "Mon", "tuesday", "tue", "We", "we"). * @return {Number} The day number */ $D.getDayNumberFromName = function (name) { var n = Date.CultureInfo.dayNames, m = Date.CultureInfo.abbreviatedDayNames, o = Date.CultureInfo.shortestDayNames, s = name.toLowerCase(); for (var i = 0; i < n.length; i++) { if (n[i].toLowerCase() === s || m[i].toLowerCase() === s || o[i].toLowerCase() === s) { return i; } } return -1; }; /** * Gets the month number (0-11) if given a Culture Info specific string which is a valid monthName or abbreviatedMonthName. * @param {String} The name of the month (eg. "February, "Feb", "october", "oct"). * @return {Number} The day number */ $D.getMonthNumberFromName = function (name) { var n = Date.CultureInfo.monthNames, m = Date.CultureInfo.abbreviatedMonthNames, s = name.toLowerCase(); for (var i = 0; i < n.length; i++) { if (n[i].toLowerCase() === s || m[i].toLowerCase() === s) { return i; } } return -1; }; /** * Gets the language appropriate month name when given the month number(0-11) * eg - 0 == January * @return {String} The month name */ $D.getMonthName = function (n) { return Date.CultureInfo.monthNames[n]; }; /** * Determines if the current date instance is within a LeapYear. * @param {Number} The year. * @return {Boolean} true if date is within a LeapYear, otherwise false. */ $D.isLeapYear = function (year) { return ((year % 4 === 0 && year % 100 !== 0) || year % 400 === 0); }; /** * Gets the number of days in the month, given a year and month value. Automatically corrects for LeapYear. * @param {Number} The year. * @param {Number} The month (0-11). * @return {Number} The number of days in the month. */ $D.getDaysInMonth = function (year, month) { if (!month && $D.validateMonth(year)) { month = year; year = Date.today().getFullYear(); } return [31, ($D.isLeapYear(year) ? 29 : 28), 31, 30, 31, 30, 31, 31, 30, 31, 30, 31][month]; }; $P.getDaysInMonth = function () { return $D.getDaysInMonth(this.getFullYear(), this.getMonth()); }; $D.getTimezoneAbbreviation = function (offset, dst) { var p, n = (dst || false) ? Date.CultureInfo.abbreviatedTimeZoneDST : Date.CultureInfo.abbreviatedTimeZoneStandard; for (p in n) { if (n.hasOwnProperty(p)) { if (n[p] === offset) { return p; } } } return null; }; $D.getTimezoneOffset = function (name, dst) { var i, a =[], z = Date.CultureInfo.timezones; if (!name) { name = (new Date()).getTimezone();} for (i = 0; i < z.length; i++) { if (z[i].name === name.toUpperCase()) { a.push(i); } } if (!z[a[0]]) { return null; } if (a.length === 1 || !dst) { return z[a[0]].offset; } else { for (i=0; i < a.length; i++) { if (z[a[i]].dst) { return z[a[i]].offset; } } } }; $D.getQuarter = function (d) { d = d || new Date(); // If no date supplied, use today var q = [1,2,3,4]; return q[Math.floor(d.getMonth() / 3)]; // ~~~ is a bitwise op. Faster than Math.floor }; $D.getDaysLeftInQuarter = function (d) { d = d || new Date(); var qEnd = new Date(d); qEnd.setMonth(qEnd.getMonth() + 3 - qEnd.getMonth() % 3, 0); return Math.floor((qEnd - d) / 8.64e7); }; // private var validate = function (n, min, max, name) { name = name ? name : "Object"; if (typeof n === "undefined") { return false; } else if (typeof n !== "number") { throw new TypeError(n + " is not a Number."); } else if (n < min || n > max) { // As failing validation is *not* an exceptional circumstance // lets not throw a RangeError Exception here. // It's semantically correct but it's not sensible. return false; } return true; }; /** * Validates the number is within an acceptable range for milliseconds [0-999]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateMillisecond = function (value) { return validate(value, 0, 999, "millisecond"); }; /** * Validates the number is within an acceptable range for seconds [0-59]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateSecond = function (value) { return validate(value, 0, 59, "second"); }; /** * Validates the number is within an acceptable range for minutes [0-59]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateMinute = function (value) { return validate(value, 0, 59, "minute"); }; /** * Validates the number is within an acceptable range for hours [0-23]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateHour = function (value) { return validate(value, 0, 23, "hour"); }; /** * Validates the number is within an acceptable range for the days in a month [0-MaxDaysInMonth]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateDay = function (value, year, month) { if (year === undefined || year === null || month === undefined || month === null) { return false;} return validate(value, 1, $D.getDaysInMonth(year, month), "day"); }; /** * Validates the number is within an acceptable range for months [0-11]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateWeek = function (value) { return validate(value, 0, 53, "week"); }; /** * Validates the number is within an acceptable range for months [0-11]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateMonth = function (value) { return validate(value, 0, 11, "month"); }; /** * Validates the number is within an acceptable range for years. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateYear = function (value) { /** * Per ECMAScript spec the range of times supported by Date objects is * exactly -100,000,000 days to +100,000,000 days measured relative to * midnight at the beginning of 01 January, 1970 UTC. * This gives a range of 8,640,000,000,000,000 milliseconds to either * side of 01 January, 1970 UTC. * * Earliest possible date: Tue, 20 Apr 271,822 B.C. 00:00:00 UTC * Latest possible date: Sat, 13 Sep 275,760 00:00:00 UTC */ return validate(value, -271822, 275760, "year"); }; $D.validateTimezone = function(value) { var timezones = {"ACDT":1,"ACST":1,"ACT":1,"ADT":1,"AEDT":1,"AEST":1,"AFT":1,"AKDT":1,"AKST":1,"AMST":1,"AMT":1,"ART":1,"AST":1,"AWDT":1,"AWST":1,"AZOST":1,"AZT":1,"BDT":1,"BIOT":1,"BIT":1,"BOT":1,"BRT":1,"BST":1,"BTT":1,"CAT":1,"CCT":1,"CDT":1,"CEDT":1,"CEST":1,"CET":1,"CHADT":1,"CHAST":1,"CHOT":1,"ChST":1,"CHUT":1,"CIST":1,"CIT":1,"CKT":1,"CLST":1,"CLT":1,"COST":1,"COT":1,"CST":1,"CT":1,"CVT":1,"CWST":1,"CXT":1,"DAVT":1,"DDUT":1,"DFT":1,"EASST":1,"EAST":1,"EAT":1,"ECT":1,"EDT":1,"EEDT":1,"EEST":1,"EET":1,"EGST":1,"EGT":1,"EIT":1,"EST":1,"FET":1,"FJT":1,"FKST":1,"FKT":1,"FNT":1,"GALT":1,"GAMT":1,"GET":1,"GFT":1,"GILT":1,"GIT":1,"GMT":1,"GST":1,"GYT":1,"HADT":1,"HAEC":1,"HAST":1,"HKT":1,"HMT":1,"HOVT":1,"HST":1,"ICT":1,"IDT":1,"IOT":1,"IRDT":1,"IRKT":1,"IRST":1,"IST":1,"JST":1,"KGT":1,"KOST":1,"KRAT":1,"KST":1,"LHST":1,"LINT":1,"MAGT":1,"MART":1,"MAWT":1,"MDT":1,"MET":1,"MEST":1,"MHT":1,"MIST":1,"MIT":1,"MMT":1,"MSK":1,"MST":1,"MUT":1,"MVT":1,"MYT":1,"NCT":1,"NDT":1,"NFT":1,"NPT":1,"NST":1,"NT":1,"NUT":1,"NZDT":1,"NZST":1,"OMST":1,"ORAT":1,"PDT":1,"PET":1,"PETT":1,"PGT":1,"PHOT":1,"PHT":1,"PKT":1,"PMDT":1,"PMST":1,"PONT":1,"PST":1,"PYST":1,"PYT":1,"RET":1,"ROTT":1,"SAKT":1,"SAMT":1,"SAST":1,"SBT":1,"SCT":1,"SGT":1,"SLST":1,"SRT":1,"SST":1,"SYOT":1,"TAHT":1,"THA":1,"TFT":1,"TJT":1,"TKT":1,"TLT":1,"TMT":1,"TOT":1,"TVT":1,"UCT":1,"ULAT":1,"UTC":1,"UYST":1,"UYT":1,"UZT":1,"VET":1,"VLAT":1,"VOLT":1,"VOST":1,"VUT":1,"WAKT":1,"WAST":1,"WAT":1,"WEDT":1,"WEST":1,"WET":1,"WST":1,"YAKT":1,"YEKT":1,"Z":1}; return (timezones[value] === 1); }; $D.validateTimezoneOffset= function(value) { // timezones go from +14hrs to -12hrs, the +X hours are negative offsets. return (value > -841 && value < 721); }; }()); (function () { var $D = Date, $P = $D.prototype, p = function (s, l) { if (!l) { l = 2; } return ("000" + s).slice(l * -1); }; var validateConfigObject = function (obj) { var result = {}, self = this, prop, testFunc; testFunc = function (prop, func, value) { if (prop === "day") { var month = (obj.month !== undefined) ? obj.month : self.getMonth(); var year = (obj.year !== undefined) ? obj.year : self.getFullYear(); return $D[func](value, year, month); } else { return $D[func](value); } }; for (prop in obj) { if (Object.prototype.hasOwnProperty.call(obj, prop)) { var func = "validate" + prop.charAt(0).toUpperCase() + prop.slice(1); if ($D[func] && obj[prop] !== null && testFunc(prop, func, obj[prop])) { result[prop] = obj[prop]; } } } return result; }; /** * Resets the time of this Date object to 12:00 AM (00:00), which is the start of the day. * @param {Boolean} .clone() this date instance before clearing Time * @return {Date} this */ $P.clearTime = function () { this.setHours(0); this.setMinutes(0); this.setSeconds(0); this.setMilliseconds(0); return this; }; /** * Resets the time of this Date object to the current time ('now'). * @return {Date} this */ $P.setTimeToNow = function () { var n = new Date(); this.setHours(n.getHours()); this.setMinutes(n.getMinutes()); this.setSeconds(n.getSeconds()); this.setMilliseconds(n.getMilliseconds()); return this; }; /** * Returns a new Date object that is an exact date and time copy of the original instance. * @return {Date} A new Date instance */ $P.clone = function () { return new Date(this.getTime()); }; /** * Compares this instance to a Date object and returns an number indication of their relative values. * @param {Date} Date object to compare [Required] * @return {Number} -1 = this is lessthan date. 0 = values are equal. 1 = this is greaterthan date. */ $P.compareTo = function (date) { return Date.compare(this, date); }; /** * Compares this instance to another Date object and returns true if they are equal. * @param {Date} Date object to compare. If no date to compare, new Date() [now] is used. * @return {Boolean} true if dates are equal. false if they are not equal. */ $P.equals = function (date) { return Date.equals(this, (date !== undefined ? date : new Date())); }; /** * Determines if this instance is between a range of two dates or equal to either the start or end dates. * @param {Date} Start of range [Required] * @param {Date} End of range [Required] * @return {Boolean} true is this is between or equal to the start and end dates, else false */ $P.between = function (start, end) { return this.getTime() >= start.getTime() && this.getTime() <= end.getTime(); }; /** * Determines if this date occurs after the date to compare to. * @param {Date} Date object to compare. If no date to compare, new Date() ("now") is used. * @return {Boolean} true if this date instance is greater than the date to compare to (or "now"), otherwise false. */ $P.isAfter = function (date) { return this.compareTo(date || new Date()) === 1; }; /** * Determines if this date occurs before the date to compare to. * @param {Date} Date object to compare. If no date to compare, new Date() ("now") is used. * @return {Boolean} true if this date instance is less than the date to compare to (or "now"). */ $P.isBefore = function (date) { return (this.compareTo(date || new Date()) === -1); }; /** * Determines if the current Date instance occurs today. * @return {Boolean} true if this date instance is 'today', otherwise false. */ /** * Determines if the current Date instance occurs on the same Date as the supplied 'date'. * If no 'date' to compare to is provided, the current Date instance is compared to 'today'. * @param {date} Date object to compare. If no date to compare, the current Date ("now") is used. * @return {Boolean} true if this Date instance occurs on the same Day as the supplied 'date'. */ $P.isToday = $P.isSameDay = function (date) { return this.clone().clearTime().equals((date || new Date()).clone().clearTime()); }; /** * Adds the specified number of milliseconds to this instance. * @param {Number} The number of milliseconds to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addMilliseconds = function (value) { if (!value) { return this; } this.setTime(this.getTime() + value * 1); return this; }; /** * Adds the specified number of seconds to this instance. * @param {Number} The number of seconds to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addSeconds = function (value) { if (!value) { return this; } return this.addMilliseconds(value * 1000); }; /** * Adds the specified number of seconds to this instance. * @param {Number} The number of seconds to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addMinutes = function (value) { if (!value) { return this; } return this.addMilliseconds(value * 60000); // 60*1000 }; /** * Adds the specified number of hours to this instance. * @param {Number} The number of hours to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addHours = function (value) { if (!value) { return this; } return this.addMilliseconds(value * 3600000); // 60*60*1000 }; /** * Adds the specified number of days to this instance. * @param {Number} The number of days to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addDays = function (value) { if (!value) { return this; } this.setDate(this.getDate() + value * 1); return this; }; /** * Adds the specified number of weekdays (ie - not sat or sun) to this instance. * @param {Number} The number of days to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addWeekdays = function (value) { if (!value) { return this; } var day = this.getDay(); var weeks = (Math.ceil(Math.abs(value)/7)); if (day === 0 || day === 6) { if (value > 0) { this.next().monday(); this.addDays(-1); day = this.getDay(); } } if (value < 0) { while (value < 0) { this.addDays(-1); day = this.getDay(); if (day !== 0 && day !== 6) { value++; } } return this; } else if (value > 5 || (6-day) <= value) { value = value + (weeks * 2); } return this.addDays(value); }; /** * Adds the specified number of weeks to this instance. * @param {Number} The number of weeks to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addWeeks = function (value) { if (!value) { return this; } return this.addDays(value * 7); }; /** * Adds the specified number of months to this instance. * @param {Number} The number of months to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addMonths = function (value) { if (!value) { return this; } var n = this.getDate(); this.setDate(1); this.setMonth(this.getMonth() + value * 1); this.setDate(Math.min(n, $D.getDaysInMonth(this.getFullYear(), this.getMonth()))); return this; }; $P.addQuarters = function (value) { if (!value) { return this; } // note this will take you to the same point in the quarter as you are now. // i.e. - if you are 15 days into the quarter you'll be 15 days into the resulting one. // bonus: this allows adding fractional quarters return this.addMonths(value * 3); }; /** * Adds the specified number of years to this instance. * @param {Number} The number of years to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addYears = function (value) { if (!value) { return this; } return this.addMonths(value * 12); }; /** * Adds (or subtracts) to the value of the years, months, weeks, days, hours, minutes, seconds, milliseconds of the date instance using given configuration object. Positive and Negative values allowed. * Example

	Date.today().add( { days: 1, months: 1 } )

	new Date().add( { years: -1 } )
	
* @param {Object} Configuration object containing attributes (months, days, etc.) * @return {Date} this */ $P.add = function (config) { if (typeof config === "number") { this._orient = config; return this; } var x = config; if (x.day) { // If we should be a different date than today (eg: for 'tomorrow -1d', etc). // Should only effect parsing, not direct usage (eg, Finish and FinishExact) if ((x.day - this.getDate()) !== 0) { this.setDate(x.day); } } if (x.milliseconds) { this.addMilliseconds(x.milliseconds); } if (x.seconds) { this.addSeconds(x.seconds); } if (x.minutes) { this.addMinutes(x.minutes); } if (x.hours) { this.addHours(x.hours); } if (x.weeks) { this.addWeeks(x.weeks); } if (x.months) { this.addMonths(x.months); } if (x.years) { this.addYears(x.years); } if (x.days) { this.addDays(x.days); } return this; }; /** * Get the week number. Week one (1) is the week which contains the first Thursday of the year. Monday is considered the first day of the week. * The .getWeek() function does NOT convert the date to UTC. The local datetime is used. * Please use .getISOWeek() to get the week of the UTC converted date. * @return {Number} 1 to 53 */ $P.getWeek = function (utc) { // Create a copy of this date object var self, target = new Date(this.valueOf()); if (utc) { target.addMinutes(target.getTimezoneOffset()); self = target.clone(); } else { self = this; } // ISO week date weeks start on monday // so correct the day number var dayNr = (self.getDay() + 6) % 7; // ISO 8601 states that week 1 is the week // with the first thursday of that year. // Set the target date to the thursday in the target week target.setDate(target.getDate() - dayNr + 3); // Store the millisecond value of the target date var firstThursday = target.valueOf(); // Set the target to the first thursday of the year // First set the target to january first target.setMonth(0, 1); // Not a thursday? Correct the date to the next thursday if (target.getDay() !== 4) { target.setMonth(0, 1 + ((4 - target.getDay()) + 7) % 7); } // The weeknumber is the number of weeks between the // first thursday of the year and the thursday in the target week return 1 + Math.ceil((firstThursday - target) / 604800000); // 604800000 = 7 * 24 * 3600 * 1000 }; /** * Get the ISO 8601 week number. Week one ("01") is the week which contains the first Thursday of the year. Monday is considered the first day of the week. * The .getISOWeek() function does convert the date to it's UTC value. Please use .getWeek() to get the week of the local date. * @return {String} "01" to "53" */ $P.getISOWeek = function () { return p(this.getWeek(true)); }; /** * Moves the date to Monday of the week set. Week one (1) is the week which contains the first Thursday of the year. * @param {Number} A Number (1 to 53) that represents the week of the year. * @return {Date} this */ $P.setWeek = function (n) { if ((n - this.getWeek()) === 0) { if (this.getDay() !== 1) { return this.moveToDayOfWeek(1, (this.getDay() > 1 ? -1 : 1)); } else { return this; } } else { return this.moveToDayOfWeek(1, (this.getDay() > 1 ? -1 : 1)).addWeeks(n - this.getWeek()); } }; $P.setQuarter = function (qtr) { var month = Math.abs(((qtr-1) * 3) + 1); return this.setMonth(month, 1); }; $P.getQuarter = function () { return Date.getQuarter(this); }; $P.getDaysLeftInQuarter = function () { return Date.getDaysLeftInQuarter(this); }; /** * Moves the date to the next n'th occurrence of the dayOfWeek starting from the beginning of the month. The number (-1) is a magic number and will return the last occurrence of the dayOfWeek in the month. * @param {Number} The dayOfWeek to move to * @param {Number} The n'th occurrence to move to. Use (-1) to return the last occurrence in the month * @return {Date} this */ $P.moveToNthOccurrence = function (dayOfWeek, occurrence) { if (dayOfWeek === "Weekday") { if (occurrence > 0) { this.moveToFirstDayOfMonth(); if (this.is().weekday()) { occurrence -= 1; } } else if (occurrence < 0) { this.moveToLastDayOfMonth(); if (this.is().weekday()) { occurrence += 1; } } else { return this; } return this.addWeekdays(occurrence); } var shift = 0; if (occurrence > 0) { shift = occurrence - 1; } else if (occurrence === -1) { this.moveToLastDayOfMonth(); if (this.getDay() !== dayOfWeek) { this.moveToDayOfWeek(dayOfWeek, -1); } return this; } return this.moveToFirstDayOfMonth().addDays(-1).moveToDayOfWeek(dayOfWeek, +1).addWeeks(shift); }; var moveToN = function (getFunc, addFunc, nVal) { return function (value, orient) { var diff = (value - this[getFunc]() + nVal * (orient || +1)) % nVal; return this[addFunc]((diff === 0) ? diff += nVal * (orient || +1) : diff); }; }; /** * Move to the next or last dayOfWeek based on the orient value. * @param {Number} The dayOfWeek to move to * @param {Number} Forward (+1) or Back (-1). Defaults to +1. [Optional] * @return {Date} this */ $P.moveToDayOfWeek = moveToN("getDay", "addDays", 7); /** * Move to the next or last month based on the orient value. * @param {Number} The month to move to. 0 = January, 11 = December * @param {Number} Forward (+1) or Back (-1). Defaults to +1. [Optional] * @return {Date} this */ $P.moveToMonth = moveToN("getMonth", "addMonths", 12); /** * Get the Ordinate of the current day ("th", "st", "rd"). * @return {String} */ $P.getOrdinate = function () { var num = this.getDate(); return ord(num); }; /** * Get the Ordinal day (numeric day number) of the year, adjusted for leap year. * @return {Number} 1 through 365 (366 in leap years) */ $P.getOrdinalNumber = function () { return Math.ceil((this.clone().clearTime() - new Date(this.getFullYear(), 0, 1)) / 86400000) + 1; }; /** * Get the time zone abbreviation of the current date. * @return {String} The abbreviated time zone name (e.g. "EST") */ $P.getTimezone = function () { return $D.getTimezoneAbbreviation(this.getUTCOffset(), this.isDaylightSavingTime()); }; $P.setTimezoneOffset = function (offset) { var here = this.getTimezoneOffset(), there = Number(offset) * -6 / 10; return (there || there === 0) ? this.addMinutes(there - here) : this; }; $P.setTimezone = function (offset) { return this.setTimezoneOffset($D.getTimezoneOffset(offset)); }; /** * Indicates whether Daylight Saving Time is observed in the current time zone. * @return {Boolean} true|false */ $P.hasDaylightSavingTime = function () { return (Date.today().set({month: 0, day: 1}).getTimezoneOffset() !== Date.today().set({month: 6, day: 1}).getTimezoneOffset()); }; /** * Indicates whether this Date instance is within the Daylight Saving Time range for the current time zone. * @return {Boolean} true|false */ $P.isDaylightSavingTime = function () { return Date.today().set({month: 0, day: 1}).getTimezoneOffset() !== this.getTimezoneOffset(); }; /** * Get the offset from UTC of the current date. * @return {String} The 4-character offset string prefixed with + or - (e.g. "-0500") */ $P.getUTCOffset = function (offset) { var n = (offset || this.getTimezoneOffset()) * -10 / 6, r; if (n < 0) { r = (n - 10000).toString(); return r.charAt(0) + r.substr(2); } else { r = (n + 10000).toString(); return "+" + r.substr(1); } }; /** * Returns the number of milliseconds between this date and date. * @param {Date} Defaults to now * @return {Number} The diff in milliseconds */ $P.getElapsed = function (date) { return (date || new Date()) - this; }; /** * Set the value of year, month, day, hour, minute, second, millisecond of date instance using given configuration object. * Example

	Date.today().set( { day: 20, month: 1 } )

	new Date().set( { millisecond: 0 } )
	
* * @param {Object} Configuration object containing attributes (month, day, etc.) * @return {Date} this */ $P.set = function (config) { config = validateConfigObject.call(this, config); var key; for (key in config) { if (Object.prototype.hasOwnProperty.call(config, key)) { var name = key.charAt(0).toUpperCase() + key.slice(1); var addFunc, getFunc; if (key !== "week" && key !== "month" && key !== "timezone" && key !== "timezoneOffset") { name += "s"; } addFunc = "add" + name; getFunc = "get" + name; if (key === "month") { addFunc = addFunc + "s"; } else if (key === "year"){ getFunc = "getFullYear"; } if (key !== "day" && key !== "timezone" && key !== "timezoneOffset" && key !== "week" && key !== "hour") { this[addFunc](config[key] - this[getFunc]()); } else if ( key === "timezone"|| key === "timezoneOffset" || key === "week" || key === "hour") { this["set"+name](config[key]); } } } // day has to go last because you can't validate the day without first knowing the month if (config.day) { this.addDays(config.day - this.getDate()); } return this; }; /** * Moves the date to the first day of the month. * @return {Date} this */ $P.moveToFirstDayOfMonth = function () { return this.set({ day: 1 }); }; /** * Moves the date to the last day of the month. * @return {Date} this */ $P.moveToLastDayOfMonth = function () { return this.set({ day: $D.getDaysInMonth(this.getFullYear(), this.getMonth())}); }; /** * Converts the value of the current Date object to its equivalent string representation. * Format Specifiers * CUSTOM DATE AND TIME FORMAT STRINGS * Format Description Example * ------ --------------------------------------------------------------------------- ----------------------- * s The seconds of the minute between 0-59. "0" to "59" * ss The seconds of the minute with leading zero if required. "00" to "59" * * m The minute of the hour between 0-59. "0" or "59" * mm The minute of the hour with leading zero if required. "00" or "59" * * h The hour of the day between 1-12. "1" to "12" * hh The hour of the day with leading zero if required. "01" to "12" * * H The hour of the day between 0-23. "0" to "23" * HH The hour of the day with leading zero if required. "00" to "23" * * d The day of the month between 1 and 31. "1" to "31" * dd The day of the month with leading zero if required. "01" to "31" * ddd Abbreviated day name. Date.CultureInfo.abbreviatedDayNames. "Mon" to "Sun" * dddd The full day name. Date.CultureInfo.dayNames. "Monday" to "Sunday" * * M The month of the year between 1-12. "1" to "12" * MM The month of the year with leading zero if required. "01" to "12" * MMM Abbreviated month name. Date.CultureInfo.abbreviatedMonthNames. "Jan" to "Dec" * MMMM The full month name. Date.CultureInfo.monthNames. "January" to "December" * * yy The year as a two-digit number. "99" or "08" * yyyy The full four digit year. "1999" or "2008" * * t Displays the first character of the A.M./P.M. designator. "A" or "P" * Date.CultureInfo.amDesignator or Date.CultureInfo.pmDesignator * tt Displays the A.M./P.M. designator. "AM" or "PM" * Date.CultureInfo.amDesignator or Date.CultureInfo.pmDesignator * * S The ordinal suffix ("st, "nd", "rd" or "th") of the current day. "st, "nd", "rd" or "th" * * STANDARD DATE AND TIME FORMAT STRINGS * Format Description Example *------ --------------------------------------------------------------------------- ----------------------- * d The CultureInfo shortDate Format Pattern "M/d/yyyy" * D The CultureInfo longDate Format Pattern "dddd, MMMM dd, yyyy" * F The CultureInfo fullDateTime Format Pattern "dddd, MMMM dd, yyyy h:mm:ss tt" * m The CultureInfo monthDay Format Pattern "MMMM dd" * r The CultureInfo rfc1123 Format Pattern "ddd, dd MMM yyyy HH:mm:ss GMT" * s The CultureInfo sortableDateTime Format Pattern "yyyy-MM-ddTHH:mm:ss" * t The CultureInfo shortTime Format Pattern "h:mm tt" * T The CultureInfo longTime Format Pattern "h:mm:ss tt" * u The CultureInfo universalSortableDateTime Format Pattern "yyyy-MM-dd HH:mm:ssZ" * y The CultureInfo yearMonth Format Pattern "MMMM, yyyy" * * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @return {String} A string representation of the current Date object. */ var ord = function (n) { switch (n * 1) { case 1: case 21: case 31: return "st"; case 2: case 22: return "nd"; case 3: case 23: return "rd"; default: return "th"; } }; var parseStandardFormats = function (format) { var y, c = Date.CultureInfo.formatPatterns; switch (format) { case "d": return this.toString(c.shortDate); case "D": return this.toString(c.longDate); case "F": return this.toString(c.fullDateTime); case "m": return this.toString(c.monthDay); case "r": case "R": y = this.clone().addMinutes(this.getTimezoneOffset()); return y.toString(c.rfc1123) + " GMT"; case "s": return this.toString(c.sortableDateTime); case "t": return this.toString(c.shortTime); case "T": return this.toString(c.longTime); case "u": y = this.clone().addMinutes(this.getTimezoneOffset()); return y.toString(c.universalSortableDateTime); case "y": return this.toString(c.yearMonth); default: return false; } }; var parseFormatStringsClosure = function (context) { return function (m) { if (m.charAt(0) === "\\") { return m.replace("\\", ""); } switch (m) { case "hh": return p(context.getHours() < 13 ? (context.getHours() === 0 ? 12 : context.getHours()) : (context.getHours() - 12)); case "h": return context.getHours() < 13 ? (context.getHours() === 0 ? 12 : context.getHours()) : (context.getHours() - 12); case "HH": return p(context.getHours()); case "H": return context.getHours(); case "mm": return p(context.getMinutes()); case "m": return context.getMinutes(); case "ss": return p(context.getSeconds()); case "s": return context.getSeconds(); case "yyyy": return p(context.getFullYear(), 4); case "yy": return p(context.getFullYear()); case "y": return context.getFullYear(); case "E": case "dddd": return Date.CultureInfo.dayNames[context.getDay()]; case "ddd": return Date.CultureInfo.abbreviatedDayNames[context.getDay()]; case "dd": return p(context.getDate()); case "d": return context.getDate(); case "MMMM": return Date.CultureInfo.monthNames[context.getMonth()]; case "MMM": return Date.CultureInfo.abbreviatedMonthNames[context.getMonth()]; case "MM": return p((context.getMonth() + 1)); case "M": return context.getMonth() + 1; case "t": return context.getHours() < 12 ? Date.CultureInfo.amDesignator.substring(0, 1) : Date.CultureInfo.pmDesignator.substring(0, 1); case "tt": return context.getHours() < 12 ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator; case "S": return ord(context.getDate()); case "W": return context.getWeek(); case "WW": return context.getISOWeek(); case "Q": return "Q" + context.getQuarter(); case "q": return String(context.getQuarter()); case "z": return context.getTimezone(); case "Z": case "X": return Date.getTimezoneOffset(context.getTimezone()); case "ZZ": // Timezone offset in seconds return context.getTimezoneOffset() * -60; case "u": return context.getDay(); case "L": return ($D.isLeapYear(context.getFullYear())) ? 1 : 0; case "B": // Swatch Internet Time (.beats) return "@"+((context.getUTCSeconds() + (context.getUTCMinutes()*60) + ((context.getUTCHours()+1)*3600))/86.4); default: return m; } }; }; $P.toString = function (format, ignoreStandards) { // Standard Date and Time Format Strings. Formats pulled from CultureInfo file and // may vary by culture. if (!ignoreStandards && format && format.length === 1) { output = parseStandardFormats.call(this, format); if (output) { return output; } } var parseFormatStrings = parseFormatStringsClosure(this); return format ? format.replace(/((\\)?(dd?d?d?|MM?M?M?|yy?y?y?|hh?|HH?|mm?|ss?|tt?|S|q|Q|WW?W?W?)(?![^\[]*\]))/g, parseFormatStrings).replace(/\[|\]/g, "") : this._toString(); }; }()); /************************************************************* * SugarPak - Domain Specific Language - Syntactical Sugar * *************************************************************/ (function () { var $D = Date, $P = $D.prototype, $N = Number.prototype; // private $P._orient = +1; // private $P._nth = null; // private $P._is = false; // private $P._same = false; // private $P._isSecond = false; // private $N._dateElement = "days"; /** * Moves the date to the next instance of a date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.today().next().friday();
	Date.today().next().fri();
	Date.today().next().march();
	Date.today().next().mar();
	Date.today().next().week();
	
* * @return {Date} date */ $P.next = function () { this._move = true; this._orient = +1; return this; }; /** * Creates a new Date (Date.today()) and moves the date to the next instance of the date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.next().friday();
	Date.next().fri();
	Date.next().march();
	Date.next().mar();
	Date.next().week();
	
* * @return {Date} date */ $D.next = function () { return $D.today().next(); }; /** * Moves the date to the previous instance of a date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.today().last().friday();
	Date.today().last().fri();
	Date.today().last().march();
	Date.today().last().mar();
	Date.today().last().week();
	
* * @return {Date} date */ $P.last = $P.prev = $P.previous = function () { this._move = true; this._orient = -1; return this; }; /** * Creates a new Date (Date.today()) and moves the date to the previous instance of the date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.last().friday();
	Date.last().fri();
	Date.previous().march();
	Date.prev().mar();
	Date.last().week();
	
* * @return {Date} date */ $D.last = $D.prev = $D.previous = function () { return $D.today().last(); }; /** * Performs a equality check when followed by either a month name, day name or .weekday() function. * Example

	Date.today().is().friday(); // true|false
	Date.today().is().fri();
	Date.today().is().march();
	Date.today().is().mar();
	
* * @return {Boolean} true|false */ $P.is = function () { this._is = true; return this; }; /** * Determines if two date objects occur on/in exactly the same instance of the subsequent date part function. * The function .same() must be followed by a date part function (example: .day(), .month(), .year(), etc). * * An optional Date can be passed in the date part function. If now date is passed as a parameter, 'Now' is used. * * The following example demonstrates how to determine if two dates fall on the exact same day. * * Example

	var d1 = Date.today(); // today at 00:00
	var d2 = new Date();   // exactly now.

	// Do they occur on the same day?
	d1.same().day(d2); // true
	
	// Do they occur on the same hour?
	d1.same().hour(d2); // false, unless d2 hour is '00' (midnight).
	
	// What if it's the same day, but one year apart?
	var nextYear = Date.today().add(1).year();

	d1.same().day(nextYear); // false, because the dates must occur on the exact same day. 
	
* * Scenario: Determine if a given date occurs during some week period 2 months from now. * * Example

	var future = Date.today().add(2).months();
	return someDate.same().week(future); // true|false;
	
* * @return {Boolean} true|false */ $P.same = function () { this._same = true; this._isSecond = false; return this; }; /** * Determines if the current date/time occurs during Today. Must be preceded by the .is() function. * Example

	someDate.is().today();    // true|false
	new Date().is().today();  // true
	Date.today().is().today();// true
	Date.today().add(-1).day().is().today(); // false
	
* * @return {Boolean} true|false */ $P.today = function () { return this.same().day(); }; /** * Determines if the current date is a weekday. This function must be preceded by the .is() function. * Example

	Date.today().is().weekday(); // true|false
	
* * @return {Boolean} true|false */ $P.weekday = function () { if (this._nth) { return df("Weekday").call(this); } if (this._move) { return this.addWeekdays(this._orient); } if (this._is) { this._is = false; return (!this.is().sat() && !this.is().sun()); } return false; }; /** * Determines if the current date is on the weekend. This function must be preceded by the .is() function. * Example

	Date.today().is().weekend(); // true|false
	
* * @return {Boolean} true|false */ $P.weekend = function () { if (this._is) { this._is = false; return (this.is().sat() || this.is().sun()); } return false; }; /** * Sets the Time of the current Date instance. A string "6:15 pm" or config object {hour:18, minute:15} are accepted. * Example

	// Set time to 6:15pm with a String
	Date.today().at("6:15pm");

	// Set time to 6:15pm with a config object
	Date.today().at({hour:18, minute:15});
	
* * @return {Date} date */ $P.at = function (time) { return (typeof time === "string") ? $D.parse(this.toString("d") + " " + time) : this.set(time); }; /** * Creates a new Date() and adds this (Number) to the date based on the preceding date element function (eg. second|minute|hour|day|month|year). * Example

	// Undeclared Numbers must be wrapped with parentheses. Requirment of JavaScript.
	(3).days().fromNow();
	(6).months().fromNow();

	// Declared Number variables do not require parentheses. 
	var n = 6;
	n.months().fromNow();
	
* * @return {Date} A new Date instance */ $N.fromNow = $N.after = function (date) { var c = {}; c[this._dateElement] = this; return ((!date) ? new Date() : date.clone()).add(c); }; /** * Creates a new Date() and subtract this (Number) from the date based on the preceding date element function (eg. second|minute|hour|day|month|year). * Example

	// Undeclared Numbers must be wrapped with parentheses. Requirment of JavaScript.
	(3).days().ago();
	(6).months().ago();

	// Declared Number variables do not require parentheses. 
	var n = 6;
	n.months().ago();
	
* * @return {Date} A new Date instance */ $N.ago = $N.before = function (date) { var c = {}, s = (this._dateElement[this._dateElement.length-1] !== "s") ? this._dateElement + "s" : this._dateElement; c[s] = this * -1; return ((!date) ? new Date() : date.clone()).add(c); }; // Do NOT modify the following string tokens. These tokens are used to build dynamic functions. // All culture-specific strings can be found in the CultureInfo files. var dx = ("sunday monday tuesday wednesday thursday friday saturday").split(/\s/), mx = ("january february march april may june july august september october november december").split(/\s/), px = ("Millisecond Second Minute Hour Day Week Month Year Quarter Weekday").split(/\s/), pxf = ("Milliseconds Seconds Minutes Hours Date Week Month FullYear Quarter").split(/\s/), nth = ("final first second third fourth fifth").split(/\s/), de; /** * Returns an object literal of all the date parts. * Example

	var o = new Date().toObject();
	
	// { year: 2008, month: 4, week: 20, day: 13, hour: 18, minute: 9, second: 32, millisecond: 812 }
	
	// The object properties can be referenced directly from the object.
	
	alert(o.day);  // alerts "13"
	alert(o.year); // alerts "2008"
	
* * @return {Date} An object literal representing the original date object. */ $P.toObject = function () { var o = {}; for (var i = 0; i < px.length; i++) { if (this["get" + pxf[i]]) { o[px[i].toLowerCase()] = this["get" + pxf[i]](); } } return o; }; /** * Returns a date created from an object literal. Ignores the .week property if set in the config. * Example

	var o = new Date().toObject();
	
	return Date.fromObject(o); // will return the same date. 

	var o2 = {month: 1, day: 20, hour: 18}; // birthday party!
	Date.fromObject(o2);
	
* * @return {Date} An object literal representing the original date object. */ $D.fromObject = function(config) { config.week = null; return Date.today().set(config); }; // Create day name functions and abbreviated day name functions (eg. monday(), friday(), fri()). var df = function (n) { return function () { if (this._is) { this._is = false; return this.getDay() === n; } if (this._move) { this._move = null; } if (this._nth !== null) { // If the .second() function was called earlier, remove the _orient // from the date, and then continue. // This is required because 'second' can be used in two different context. // // Example // // Date.today().add(1).second(); // Date.march().second().monday(); // // Things get crazy with the following... // Date.march().add(1).second().second().monday(); // but it works!! // if (this._isSecond) { this.addSeconds(this._orient * -1); } // make sure we reset _isSecond this._isSecond = false; var ntemp = this._nth; this._nth = null; var temp = this.clone().moveToLastDayOfMonth(); this.moveToNthOccurrence(n, ntemp); if (this > temp) { throw new RangeError($D.getDayName(n) + " does not occur " + ntemp + " times in the month of " + $D.getMonthName(temp.getMonth()) + " " + temp.getFullYear() + "."); } return this; } return this.moveToDayOfWeek(n, this._orient); }; }; var sdf = function (n) { return function () { var t = $D.today(), shift = n - t.getDay(); if (n === 0 && Date.CultureInfo.firstDayOfWeek === 1 && t.getDay() !== 0) { shift = shift + 7; } return t.addDays(shift); }; }; // Create month name functions and abbreviated month name functions (eg. january(), march(), mar()). var month_instance_functions = function (n) { return function () { if (this._is) { this._is = false; return this.getMonth() === n; } return this.moveToMonth(n, this._orient); }; }; var month_static_functions = function (n) { return function () { return $D.today().set({ month: n, day: 1 }); }; }; var processTerms = function (names, staticFunc, instanceFunc) { for (var i = 0; i < names.length; i++) { // Create constant static Name variables. $D[names[i].toUpperCase()] = $D[names[i].toUpperCase().substring(0, 3)] = i; // Create Name functions. $D[names[i]] = $D[names[i].substring(0, 3)] = staticFunc(i); // Create Name instance functions. $P[names[i]] = $P[names[i].substring(0, 3)] = instanceFunc(i); } }; processTerms(dx, sdf, df); processTerms(mx, month_static_functions, month_instance_functions); // Create date element functions and plural date element functions used with Date (eg. day(), days(), months()). var ef = function (j) { return function () { // if the .second() function was called earlier, the _orient // has alread been added. Just return this and reset _isSecond. if (this._isSecond) { this._isSecond = false; return this; } if (this._same) { this._same = this._is = false; var o1 = this.toObject(), o2 = (arguments[0] || new Date()).toObject(), v = "", k = j.toLowerCase(); // the substr trick with -1 doesn't work in IE8 or less k = (k[k.length-1] === "s") ? k.substring(0,k.length-1) : k; for (var m = (px.length - 1); m > -1; m--) { v = px[m].toLowerCase(); if (o1[v] !== o2[v]) { return false; } if (k === v) { break; } } return true; } if (j.substring(j.length - 1) !== "s") { j += "s"; } if (this._move) { this._move = null; } return this["add" + j](this._orient); }; }; var nf = function (n) { return function () { this._dateElement = n; return this; }; }; for (var k = 0; k < px.length; k++) { de = px[k].toLowerCase(); if(de !== "weekday") { // Create date element functions and plural date element functions used with Date (eg. day(), days(), months()). $P[de] = $P[de + "s"] = ef(px[k]); // Create date element functions and plural date element functions used with Number (eg. day(), days(), months()). $N[de] = $N[de + "s"] = nf(de + "s"); } } $P._ss = ef("Second"); var nthfn = function (n) { return function (dayOfWeek) { if (this._same) { return this._ss(arguments[0]); } if (dayOfWeek || dayOfWeek === 0) { return this.moveToNthOccurrence(dayOfWeek, n); } this._nth = n; // if the operator is 'second' add the _orient, then deal with it later... if (n === 2 && (dayOfWeek === undefined || dayOfWeek === null)) { this._isSecond = true; return this.addSeconds(this._orient); } return this; }; }; for (var l = 0; l < nth.length; l++) { $P[nth[l]] = (l === 0) ? nthfn(-1) : nthfn(l); } }()); (function () { "use strict"; Date.Parsing = { Exception: function (s) { this.message = "Parse error at '" + s.substring(0, 10) + " ...'"; } }; var $P = Date.Parsing; var dayOffsets = { standard: [0,31,59,90,120,151,181,212,243,273,304,334], leap: [0,31,60,91,121,152,182,213,244,274,305,335] }; $P.isLeapYear = function(year) { return ((year % 4 === 0) && (year % 100 !== 0)) || (year % 400 === 0); }; var utils = { multiReplace : function (str, hash ) { var key; for (key in hash) { if (Object.prototype.hasOwnProperty.call(hash, key)) { var regex; if (typeof hash[key] === "function") { } else { regex = (hash[key] instanceof RegExp) ? hash[key] : new RegExp(hash[key], "g"); } str = str.replace(regex, key); } } return str; }, getDayOfYearFromWeek : function (obj) { var d, jan4, offset; obj.weekDay = (!obj.weekDay && obj.weekDay !== 0) ? 1 : obj.weekDay; d = new Date(obj.year, 0, 4); jan4 = d.getDay() === 0 ? 7 : d.getDay(); // JS is 0 indexed on Sunday. offset = jan4+3; obj.dayOfYear = ((obj.week * 7) + (obj.weekDay === 0 ? 7 : obj.weekDay))-offset; return obj; }, getDayOfYear : function (obj, dayOffset) { if (!obj.dayOfYear) { obj = utils.getDayOfYearFromWeek(obj); } for (var i=0;i <= dayOffset.length;i++) { if (obj.dayOfYear < dayOffset[i] || i === dayOffset.length) { obj.day = obj.day ? obj.day : (obj.dayOfYear - dayOffset[i-1]); break; } else { obj.month = i; } } return obj; }, adjustForTimeZone : function (obj, date) { var offset; if (obj.zone.toUpperCase() === "Z" || (obj.zone_hours === 0 && obj.zone_minutes === 0)) { // it's UTC/GML so work out the current timeszone offset offset = -date.getTimezoneOffset(); } else { offset = (obj.zone_hours*60) + (obj.zone_minutes || 0); if (obj.zone_sign === "+") { offset *= -1; } offset -= date.getTimezoneOffset(); } date.setMinutes(date.getMinutes()+offset); return date; }, setDefaults : function (obj) { obj.year = obj.year || Date.today().getFullYear(); obj.hours = obj.hours || 0; obj.minutes = obj.minutes || 0; obj.seconds = obj.seconds || 0; obj.milliseconds = obj.milliseconds || 0; if (!(!obj.month && (obj.week || obj.dayOfYear))) { // if we have a month, or if we don't but don't have the day calculation data obj.month = obj.month || 0; obj.day = obj.day || 1; } return obj; }, dataNum: function (data, mod, explict, postProcess) { var dataNum = data*1; if (mod) { if (postProcess) { return data ? mod(data)*1 : data; } else { return data ? mod(dataNum) : data; } } else if (!explict){ return data ? dataNum : data; } else { return (data && typeof data !== "undefined") ? dataNum : data; } }, timeDataProcess: function (obj) { var timeObj = {}; for (var x in obj.data) { if (obj.data.hasOwnProperty(x)) { timeObj[x] = obj.ignore[x] ? obj.data[x] : utils.dataNum(obj.data[x], obj.mods[x], obj.explict[x], obj.postProcess[x]); } } if (obj.data.secmins) { obj.data.secmins = obj.data.secmins.replace(",", ".") * 60; if (!timeObj.minutes) { timeObj.minutes = obj.data.secmins; } else if (!timeObj.seconds) { timeObj.seconds = obj.data.secmins; } delete obj.secmins; } return timeObj; }, buildTimeObjectFromData: function (data) { var time = utils.timeDataProcess({ data: { year : data[1], month : data[5], day : data[7], week : data[8], dayOfYear : data[10], hours : data[15], zone_hours : data[23], zone_minutes : data[24], zone : data[21], zone_sign : data[22], weekDay : data[9], minutes: data[16], seconds: data[19], milliseconds: data[20], secmins: data[18] }, mods: { month: function(data) { return data-1; }, weekDay: function (data) { data = Math.abs(data); return (data === 7 ? 0 : data); }, minutes: function (data) { return data.replace(":",""); }, seconds: function (data) { return Math.floor( (data.replace(":","").replace(",","."))*1 ); }, milliseconds: function (data) { return (data.replace(",",".")*1000); } }, postProcess: { minutes: true, seconds: true, milliseconds: true }, explict: { zone_hours: true, zone_minutes: true }, ignore: { zone: true, zone_sign: true, secmins: true } }); return time; }, addToHash: function (hash, keys, data) { keys = keys; data = data; var len = keys.length; for (var i = 0; i < len; i++) { hash[keys[i]] = data[i]; } return hash; }, combineRegex: function (r1, r2) { return new RegExp("(("+r1.source+")\\s("+r2.source+"))"); }, getDateNthString: function(add, last, inc){ if (add) { return Date.today().addDays(inc).toString("d"); } else if (last) { return Date.today().last()[inc]().toString("d"); } }, buildRegexData: function (array) { var arr = []; var len = array.length; for (var i=0; i < len; i++) { if (Object.prototype.toString.call(array[i]) === '[object Array]') { // oldIE compat version of Array.isArray arr.push(this.combineRegex(array[i][0], array[i][1])); } else { arr.push(array[i]); } } return arr; } }; $P.processTimeObject = function (obj) { var date, dayOffset; utils.setDefaults(obj); dayOffset = ($P.isLeapYear(obj.year)) ? dayOffsets.leap : dayOffsets.standard; if (!obj.month && (obj.week || obj.dayOfYear)) { utils.getDayOfYear(obj, dayOffset); } else { obj.dayOfYear = dayOffset[obj.month] + obj.day; } date = new Date(obj.year, obj.month, obj.day, obj.hours, obj.minutes, obj.seconds, obj.milliseconds); if (obj.zone) { utils.adjustForTimeZone(obj, date); // adjust (and calculate) for timezone } return date; }; $P.ISO = { regex : /^([\+-]?\d{4}(?!\d{2}\b))((-?)((0[1-9]|1[0-2])(\3([12]\d|0[1-9]|3[01]))?|W([0-4]\d|5[0-3])(-?[1-7])?|(00[1-9]|0[1-9]\d|[12]\d{2}|3([0-5]\d|6[1-6])))([T\s]((([01]\d|2[0-4])((:?)[0-5]\d)?|24\:?00)([\.,]\d+(?!:))?)?(\17[0-5]\d([\.,]\d+)?)?\s?([zZ]|([\+-])([01]\d|2[0-3]):?([0-5]\d)?)?)?)?$/, parse : function (s) { var time, data = s.match(this.regex); if (!data || !data.length) { return null; } time = utils.buildTimeObjectFromData(data); if (!time.year || (!time.year && (!time.month && !time.day) && (!time.week && !time.dayOfYear)) ) { return null; } return $P.processTimeObject(time); } }; $P.Numeric = { isNumeric: function (e){return!isNaN(parseFloat(e))&&isFinite(e);}, regex: /\b([0-1]?[0-9])([0-3]?[0-9])([0-2]?[0-9]?[0-9][0-9])\b/i, parse: function (s) { var data, i, time = {}, order = Date.CultureInfo.dateElementOrder.split(""); if (!(this.isNumeric(s)) || // if it's non-numeric OR (s[0] === "+" && s[0] === "-")) { // It's an arithmatic string (eg +/-1000) return null; } if (s.length < 5 && s.indexOf(".") < 0 && s.indexOf("/") < 0) { // assume it's just a year. time.year = s; return $P.processTimeObject(time); } data = s.match(this.regex); if (!data || !data.length) { return null; } for (i=0; i < order.length; i++) { switch(order[i]) { case "d": time.day = data[i+1]; break; case "m": time.month = (data[i+1]-1); break; case "y": time.year = data[i+1]; break; } } return $P.processTimeObject(time); } }; $P.Normalizer = { regexData: function () { var $R = Date.CultureInfo.regexPatterns; return utils.buildRegexData([ $R.tomorrow, $R.yesterday, [$R.past, $R.mon], [$R.past, $R.tue], [$R.past, $R.wed], [$R.past, $R.thu], [$R.past, $R.fri], [$R.past, $R.sat], [$R.past, $R.sun] ]); }, basicReplaceHash : function() { var $R = Date.CultureInfo.regexPatterns; return { "January": $R.jan.source, "February": $R.feb, "March": $R.mar, "April": $R.apr, "May": $R.may, "June": $R.jun, "July": $R.jul, "August": $R.aug, "September": $R.sep, "October": $R.oct, "November": $R.nov, "December": $R.dec, "": /\bat\b/gi, " ": /\s{2,}/, "am": $R.inTheMorning, "9am": $R.thisMorning, "pm": $R.inTheEvening, "7pm":$R.thisEvening }; }, keys : function(){ return [ utils.getDateNthString(true, false, 1), // tomorrow utils.getDateNthString(true, false, -1), // yesterday utils.getDateNthString(false, true, "monday"), //last mon utils.getDateNthString(false, true, "tuesday"), //last tues utils.getDateNthString(false, true, "wednesday"), //last wed utils.getDateNthString(false, true, "thursday"), //last thurs utils.getDateNthString(false, true, "friday"), //last fri utils.getDateNthString(false, true, "saturday"), //last sat utils.getDateNthString(false, true, "sunday") //last sun ]; }, buildRegexFunctions: function () { var $R = Date.CultureInfo.regexPatterns; var __ = Date.i18n.__; var tomorrowRE = new RegExp("(\\b\\d\\d?("+__("AM")+"|"+__("PM")+")? )("+$R.tomorrow.source.slice(1)+")", "i"); // adapted tomorrow regex for AM PM relative dates var todayRE = new RegExp($R.today.source + "(?!\\s*([+-]))\\b"); // today, but excludes the math operators (eg "today + 2h") this.replaceFuncs = [ [todayRE, function (full) { return (full.length > 1) ? Date.today().toString("d") : full; }], [tomorrowRE, function(full, m1) { var t = Date.today().addDays(1).toString("d"); return (t + " " + m1); }], [$R.amThisMorning, function(str, am){return am;}], [$R.pmThisEvening, function(str, pm){return pm;}] ]; }, buildReplaceData: function () { this.buildRegexFunctions(); this.replaceHash = utils.addToHash(this.basicReplaceHash(), this.keys(), this.regexData()); }, stringReplaceFuncs: function (s) { for (var i=0; i < this.replaceFuncs.length; i++) { s = s.replace(this.replaceFuncs[i][0], this.replaceFuncs[i][1]); } return s; }, parse: function (s) { s = this.stringReplaceFuncs(s); s = utils.multiReplace(s, this.replaceHash); try { var n = s.split(/([\s\-\.\,\/\x27]+)/); if (n.length === 3 && $P.Numeric.isNumeric(n[0]) && $P.Numeric.isNumeric(n[2]) && (n[2].length >= 4)) { // ok, so we're dealing with x/year. But that's not a full date. // This fixes wonky dateElementOrder parsing when set to dmy order. if (Date.CultureInfo.dateElementOrder[0] === "d") { s = "1/" + n[0] + "/" + n[2]; // set to 1st of month and normalize the seperator } } } catch (e) {} return s; } }; $P.Normalizer.buildReplaceData(); }()); (function () { var $P = Date.Parsing; var _ = $P.Operators = { // // Tokenizers // rtoken: function (r) { // regex token return function (s) { var mx = s.match(r); if (mx) { return ([ mx[0], s.substring(mx[0].length) ]); } else { throw new $P.Exception(s); } }; }, token: function () { // whitespace-eating token return function (s) { return _.rtoken(new RegExp("^\\s*" + s + "\\s*"))(s); }; }, stoken: function (s) { // string token return _.rtoken(new RegExp("^" + s)); }, // Atomic Operators until: function (p) { return function (s) { var qx = [], rx = null; while (s.length) { try { rx = p.call(this, s); } catch (e) { qx.push(rx[0]); s = rx[1]; continue; } break; } return [ qx, s ]; }; }, many: function (p) { return function (s) { var rx = [], r = null; while (s.length) { try { r = p.call(this, s); } catch (e) { return [ rx, s ]; } rx.push(r[0]); s = r[1]; } return [ rx, s ]; }; }, // generator operators -- see below optional: function (p) { return function (s) { var r = null; try { r = p.call(this, s); } catch (e) { return [ null, s ]; } return [ r[0], r[1] ]; }; }, not: function (p) { return function (s) { try { p.call(this, s); } catch (e) { return [null, s]; } throw new $P.Exception(s); }; }, ignore: function (p) { return p ? function (s) { var r = null; r = p.call(this, s); return [null, r[1]]; } : null; }, product: function () { var px = arguments[0], qx = Array.prototype.slice.call(arguments, 1), rx = []; for (var i = 0 ; i < px.length ; i++) { rx.push(_.each(px[i], qx)); } return rx; }, cache: function (rule) { var cache = {}, cache_length = 0, cache_keys = [], CACHE_MAX = Date.Config.CACHE_MAX || 100000, r = null; var cacheCheck = function () { if (cache_length === CACHE_MAX) { // kill several keys, don't want to have to do this all the time... for (var i=0; i < 10; i++) { var key = cache_keys.shift(); if (key) { delete cache[key]; cache_length--; } } } }; return function (s) { cacheCheck(); try { r = cache[s] = (cache[s] || rule.call(this, s)); } catch (e) { r = cache[s] = e; } cache_length++; cache_keys.push(s); if (r instanceof $P.Exception) { throw r; } else { return r; } }; }, // vector operators -- see below any: function () { var px = arguments; return function (s) { var r = null; for (var i = 0; i < px.length; i++) { if (px[i] == null) { continue; } try { r = (px[i].call(this, s)); } catch (e) { r = null; } if (r) { return r; } } throw new $P.Exception(s); }; }, each: function () { var px = arguments; return function (s) { var rx = [], r = null; for (var i = 0; i < px.length ; i++) { if (px[i] == null) { continue; } try { r = (px[i].call(this, s)); } catch (e) { throw new $P.Exception(s); } rx.push(r[0]); s = r[1]; } return [ rx, s]; }; }, all: function () { var px = arguments, _ = _; return _.each(_.optional(px)); }, // delimited operators sequence: function (px, d, c) { d = d || _.rtoken(/^\s*/); c = c || null; if (px.length === 1) { return px[0]; } return function (s) { var r = null, q = null; var rx = []; for (var i = 0; i < px.length ; i++) { try { r = px[i].call(this, s); } catch (e) { break; } rx.push(r[0]); try { q = d.call(this, r[1]); } catch (ex) { q = null; break; } s = q[1]; } if (!r) { throw new $P.Exception(s); } if (q) { throw new $P.Exception(q[1]); } if (c) { try { r = c.call(this, r[1]); } catch (ey) { throw new $P.Exception(r[1]); } } return [ rx, (r?r[1]:s) ]; }; }, // // Composite Operators // between: function (d1, p, d2) { d2 = d2 || d1; var _fn = _.each(_.ignore(d1), p, _.ignore(d2)); return function (s) { var rx = _fn.call(this, s); return [[rx[0][0], r[0][2]], rx[1]]; }; }, list: function (p, d, c) { d = d || _.rtoken(/^\s*/); c = c || null; return (p instanceof Array ? _.each(_.product(p.slice(0, -1), _.ignore(d)), p.slice(-1), _.ignore(c)) : _.each(_.many(_.each(p, _.ignore(d))), px, _.ignore(c))); }, set: function (px, d, c) { d = d || _.rtoken(/^\s*/); c = c || null; return function (s) { // r is the current match, best the current 'best' match // which means it parsed the most amount of input var r = null, p = null, q = null, rx = null, best = [[], s], last = false; // go through the rules in the given set for (var i = 0; i < px.length ; i++) { // last is a flag indicating whether this must be the last element // if there is only 1 element, then it MUST be the last one q = null; p = null; r = null; last = (px.length === 1); // first, we try simply to match the current pattern // if not, try the next pattern try { r = px[i].call(this, s); } catch (e) { continue; } // since we are matching against a set of elements, the first // thing to do is to add r[0] to matched elements rx = [[r[0]], r[1]]; // if we matched and there is still input to parse and // we don't already know this is the last element, // we're going to next check for the delimiter ... // if there's none, or if there's no input left to parse // than this must be the last element after all ... if (r[1].length > 0 && ! last) { try { q = d.call(this, r[1]); } catch (ex) { last = true; } } else { last = true; } // if we parsed the delimiter and now there's no more input, // that means we shouldn't have parsed the delimiter at all // so don't update r and mark this as the last element ... if (!last && q[1].length === 0) { last = true; } // so, if this isn't the last element, we're going to see if // we can get any more matches from the remaining (unmatched) // elements ... if (!last) { // build a list of the remaining rules we can match against, // i.e., all but the one we just matched against var qx = []; for (var j = 0; j < px.length ; j++) { if (i !== j) { qx.push(px[j]); } } // now invoke recursively set with the remaining input // note that we don't include the closing delimiter ... // we'll check for that ourselves at the end p = _.set(qx, d).call(this, q[1]); // if we got a non-empty set as a result ... // (otw rx already contains everything we want to match) if (p[0].length > 0) { // update current result, which is stored in rx ... // basically, pick up the remaining text from p[1] // and concat the result from p[0] so that we don't // get endless nesting ... rx[0] = rx[0].concat(p[0]); rx[1] = p[1]; } } // at this point, rx either contains the last matched element // or the entire matched set that starts with this element. // now we just check to see if this variation is better than // our best so far, in terms of how much of the input is parsed if (rx[1].length < best[1].length) { best = rx; } // if we've parsed all the input, then we're finished if (best[1].length === 0) { break; } } // so now we've either gone through all the patterns trying them // as the initial match; or we found one that parsed the entire // input string ... // if best has no matches, just return empty set ... if (best[0].length === 0) { return best; } // if a closing delimiter is provided, then we have to check it also if (c) { // we try this even if there is no remaining input because the pattern // may well be optional or match empty input ... try { q = c.call(this, best[1]); } catch (ey) { throw new $P.Exception(best[1]); } // it parsed ... be sure to update the best match remaining input best[1] = q[1]; } // if we're here, either there was no closing delimiter or we parsed it // so now we have the best match; just return it! return best; }; }, forward: function (gr, fname) { return function (s) { return gr[fname].call(this, s); }; }, // // Translation Operators // replace: function (rule, repl) { return function (s) { var r = rule.call(this, s); return [repl, r[1]]; }; }, process: function (rule, fn) { return function (s) { var r = rule.call(this, s); return [fn.call(this, r[0]), r[1]]; }; }, min: function (min, rule) { return function (s) { var rx = rule.call(this, s); if (rx[0].length < min) { throw new $P.Exception(s); } return rx; }; } }; // Generator Operators And Vector Operators // Generators are operators that have a signature of F(R) => R, // taking a given rule and returning another rule, such as // ignore, which parses a given rule and throws away the result. // Vector operators are those that have a signature of F(R1,R2,...) => R, // take a list of rules and returning a new rule, such as each. // Generator operators are converted (via the following _generator // function) into functions that can also take a list or array of rules // and return an array of new rules as though the function had been // called on each rule in turn (which is what actually happens). // This allows generators to be used with vector operators more easily. // Example: // each(ignore(foo, bar)) instead of each(ignore(foo), ignore(bar)) // This also turns generators into vector operators, which allows // constructs like: // not(cache(foo, bar)) var _generator = function (op) { function gen() { var args = null, rx = [], px, i; if (arguments.length > 1) { args = Array.prototype.slice.call(arguments); } else if (arguments[0] instanceof Array) { args = arguments[0]; } if (args) { px = args.shift(); if (px.length > 0) { args.unshift(px[i]); rx.push(op.apply(null, args)); args.shift(); return rx; } } else { return op.apply(null, arguments); } } return gen; }; var gx = "optional not ignore cache".split(/\s/); for (var i = 0 ; i < gx.length ; i++) { _[gx[i]] = _generator(_[gx[i]]); } var _vector = function (op) { return function () { if (arguments[0] instanceof Array) { return op.apply(null, arguments[0]); } else { return op.apply(null, arguments); } }; }; var vx = "each any all".split(/\s/); for (var j = 0 ; j < vx.length ; j++) { _[vx[j]] = _vector(_[vx[j]]); } }()); (function () { var $D = Date; var flattenAndCompact = function (ax) { var rx = []; for (var i = 0; i < ax.length; i++) { if (ax[i] instanceof Array) { rx = rx.concat(flattenAndCompact(ax[i])); } else { if (ax[i]) { rx.push(ax[i]); } } } return rx; }; var parseMeridian = function () { if (this.meridian && (this.hour || this.hour === 0)) { if (this.meridian === "a" && this.hour > 11 && Date.Config.strict24hr){ throw "Invalid hour and meridian combination"; } else if (this.meridian === "p" && this.hour < 12 && Date.Config.strict24hr){ throw "Invalid hour and meridian combination"; } else if (this.meridian === "p" && this.hour < 12) { this.hour = this.hour + 12; } else if (this.meridian === "a" && this.hour === 12) { this.hour = 0; } } }; var setDefaults = function () { var now = new Date(); if ((this.hour || this.minute) && (!this.month && !this.year && !this.day)) { this.day = now.getDate(); } if (!this.year) { this.year = now.getFullYear(); } if (!this.month && this.month !== 0) { this.month = now.getMonth(); } if (!this.day) { this.day = 1; } if (!this.hour) { this.hour = 0; } if (!this.minute) { this.minute = 0; } if (!this.second) { this.second = 0; } if (!this.millisecond) { this.millisecond = 0; } }; var finishUtils = { getToday: function () { if (this.now || "hour minute second".indexOf(this.unit) !== -1) { return new Date(); } else { return $D.today(); } }, setDaysFromWeekday: function (today, orient){ var gap; orient = orient || 1; this.unit = "day"; gap = ($D.getDayNumberFromName(this.weekday) - today.getDay()); this.days = gap ? ((gap + (orient * 7)) % 7) : (orient * 7); return this; }, setMonthsFromMonth: function (today, orient) { var gap; orient = orient || 1; this.unit = "month"; gap = (this.month - today.getMonth()); this.months = gap ? ((gap + (orient * 12)) % 12) : (orient * 12); this.month = null; return this; }, setDMYFromWeekday: function () { var d = Date[this.weekday](); this.day = d.getDate(); if (!this.month) { this.month = d.getMonth(); } this.year = d.getFullYear(); return this; }, setUnitValue: function (orient) { if (!this.value && this.operator && this.operator !== null && this[this.unit + "s"] && this[this.unit + "s"] !== null) { this[this.unit + "s"] = this[this.unit + "s"] + ((this.operator === "add") ? 1 : -1) + (this.value||0) * orient; } else if (this[this.unit + "s"] == null || this.operator != null) { if (!this.value) { this.value = 1; } this[this.unit + "s"] = this.value * orient; } }, generateDateFromWeeks: function () { var weekday = (this.weekday !== undefined) ? this.weekday : "today"; var d = Date[weekday]().addWeeks(this.weeks); if (this.now) { d.setTimeToNow(); } return d; } }; $D.Translator = { hour: function (s) { return function () { this.hour = Number(s); }; }, minute: function (s) { return function () { this.minute = Number(s); }; }, second: function (s) { return function () { this.second = Number(s); }; }, /* for ss.s format */ secondAndMillisecond: function (s) { return function () { var mx = s.match(/^([0-5][0-9])\.([0-9]{1,3})/); this.second = Number(mx[1]); this.millisecond = Number(mx[2]); }; }, meridian: function (s) { return function () { this.meridian = s.slice(0, 1).toLowerCase(); }; }, timezone: function (s) { return function () { var n = s.replace(/[^\d\+\-]/g, ""); if (n.length) { this.timezoneOffset = Number(n); } else { this.timezone = s.toLowerCase(); } }; }, day: function (x) { var s = x[0]; return function () { this.day = Number(s.match(/\d+/)[0]); if (this.day < 1) { throw "invalid day"; } }; }, month: function (s) { return function () { this.month = (s.length === 3) ? "jan feb mar apr may jun jul aug sep oct nov dec".indexOf(s)/4 : Number(s) - 1; if (this.month < 0) { throw "invalid month"; } }; }, year: function (s) { return function () { var n = Number(s); this.year = ((s.length > 2) ? n : (n + (((n + 2000) < Date.CultureInfo.twoDigitYearMax) ? 2000 : 1900))); }; }, rday: function (s) { return function () { switch (s) { case "yesterday": this.days = -1; break; case "tomorrow": this.days = 1; break; case "today": this.days = 0; break; case "now": this.days = 0; this.now = true; break; } }; }, finishExact: function (x) { var d; x = (x instanceof Array) ? x : [x]; for (var i = 0 ; i < x.length ; i++) { if (x[i]) { x[i].call(this); } } setDefaults.call(this); parseMeridian.call(this); if (this.day > $D.getDaysInMonth(this.year, this.month)) { throw new RangeError(this.day + " is not a valid value for days."); } d = new Date(this.year, this.month, this.day, this.hour, this.minute, this.second, this.millisecond); if (this.year < 100) { d.setFullYear(this.year); // means years less that 100 are process correctly. JS will parse it otherwise as 1900-1999. } if (this.timezone) { d.set({ timezone: this.timezone }); } else if (this.timezoneOffset) { d.set({ timezoneOffset: this.timezoneOffset }); } return d; }, finish: function (x) { var today, expression, orient, temp; x = (x instanceof Array) ? flattenAndCompact(x) : [ x ]; if (x.length === 0) { return null; } for (var i = 0 ; i < x.length ; i++) { if (typeof x[i] === "function") { x[i].call(this); } } if (this.now && !this.unit && !this.operator) { return new Date(); } else { today = finishUtils.getToday.call(this); } expression = !!(this.days && this.days !== null || this.orient || this.operator); orient = ((this.orient === "past" || this.operator === "subtract") ? -1 : 1); if (this.month && this.unit === "week") { this.value = this.month + 1; delete this.month; delete this.day; } if ((this.month || this.month === 0) && "year day hour minute second".indexOf(this.unit) !== -1) { if (!this.value) { this.value = this.month + 1; } this.month = null; expression = true; } if (!expression && this.weekday && !this.day && !this.days) { finishUtils.setDMYFromWeekday.call(this); } if (expression && this.weekday && this.unit !== "month" && this.unit !== "week") { finishUtils.setDaysFromWeekday.call(this, today, orient); } if (this.weekday && this.unit !== "week" && !this.day && !this.days) { temp = Date[this.weekday](); this.day = temp.getDate(); if (temp.getMonth() !== today.getMonth()) { this.month = temp.getMonth(); } } if (this.month && this.unit === "day" && this.operator) { if (!this.value) { this.value = (this.month + 1); } this.month = null; } if (this.value != null && this.month != null && this.year != null) { this.day = this.value * 1; } if (this.month && !this.day && this.value) { today.set({ day: this.value * 1 }); if (!expression) { this.day = this.value * 1; } } if (!this.month && this.value && this.unit === "month" && !this.now) { this.month = this.value; expression = true; } if (expression && (this.month || this.month === 0) && this.unit !== "year") { finishUtils.setMonthsFromMonth.call(this, today, orient); } if (!this.unit) { this.unit = "day"; } finishUtils.setUnitValue.call(this, orient); parseMeridian.call(this); if ((this.month || this.month === 0) && !this.day) { this.day = 1; } if (!this.orient && !this.operator && this.unit === "week" && this.value && !this.day && !this.month) { return Date.today().setWeek(this.value); } if (this.unit === "week" && this.weeks && !this.day && !this.month) { return finishUtils.generateDateFromWeeks.call(this); } if (expression && this.timezone && this.day && this.days) { this.day = this.days; } if (expression){ today.add(this); } else { today.set(this); } if (this.timezone) { this.timezone = this.timezone.toUpperCase(); var offset = $D.getTimezoneOffset(this.timezone); var timezone; if (today.hasDaylightSavingTime()) { // lets check that we're being sane with timezone setting timezone = $D.getTimezoneAbbreviation(offset, today.isDaylightSavingTime()); if (timezone !== this.timezone) { // bugger, we're in a place where things like EST vs EDT matters. if (today.isDaylightSavingTime()) { today.addHours(-1); } else { today.addHours(1); } } } today.setTimezoneOffset(offset); } return today; } }; }()); (function () { var $D = Date; $D.Grammar = {}; var _ = $D.Parsing.Operators, g = $D.Grammar, t = $D.Translator, _fn; // Allow rolling up into general purpose rules _fn = function () { return _.each(_.any.apply(null, arguments), _.not(g.ctoken2("timeContext"))); }; g.datePartDelimiter = _.rtoken(/^([\s\-\.\,\/\x27]+)/); g.timePartDelimiter = _.stoken(":"); g.whiteSpace = _.rtoken(/^\s*/); g.generalDelimiter = _.rtoken(/^(([\s\,]|at|@|on)+)/); var _C = {}; g.ctoken = function (keys) { var fn = _C[keys]; if (! fn) { var c = Date.CultureInfo.regexPatterns; var kx = keys.split(/\s+/), px = []; for (var i = 0; i < kx.length ; i++) { px.push(_.replace(_.rtoken(c[kx[i]]), kx[i])); } fn = _C[keys] = _.any.apply(null, px); } return fn; }; g.ctoken2 = function (key) { return _.rtoken(Date.CultureInfo.regexPatterns[key]); }; var cacheProcessRtoken = function (key, token, type, eachToken) { if (eachToken) { g[key] = _.cache(_.process(_.each(_.rtoken(token),_.optional(g.ctoken2(eachToken))), type)); } else { g[key] = _.cache(_.process(_.rtoken(token), type)); } }; var cacheProcessCtoken = function (token, type) { return _.cache(_.process(g.ctoken2(token), type)); }; var _F = {}; //function cache var _get = function (f) { _F[f] = (_F[f] || g.format(f)[0]); return _F[f]; }; g.allformats = function (fx) { var rx = []; if (fx instanceof Array) { for (var i = 0; i < fx.length; i++) { rx.push(_get(fx[i])); } } else { rx.push(_get(fx)); } return rx; }; g.formats = function (fx) { if (fx instanceof Array) { var rx = []; for (var i = 0 ; i < fx.length ; i++) { rx.push(_get(fx[i])); } return _.any.apply(null, rx); } else { return _get(fx); } }; var grammarFormats = { timeFormats: function(){ var i, RTokenKeys = [ "h", "hh", "H", "HH", "m", "mm", "s", "ss", "ss.s", "z", "zz" ], RToken = [ /^(0[0-9]|1[0-2]|[1-9])/, /^(0[0-9]|1[0-2])/, /^([0-1][0-9]|2[0-3]|[0-9])/, /^([0-1][0-9]|2[0-3])/, /^([0-5][0-9]|[0-9])/, /^[0-5][0-9]/, /^([0-5][0-9]|[0-9])/, /^[0-5][0-9]/, /^[0-5][0-9]\.[0-9]{1,3}/, /^((\+|\-)\s*\d\d\d\d)|((\+|\-)\d\d\:?\d\d)/, /^((\+|\-)\s*\d\d\d\d)|((\+|\-)\d\d\:?\d\d)/ ], tokens = [ t.hour, t.hour, t.hour, t.hour, t.minute, t.minute, t.second, t.second, t.secondAndMillisecond, t.timezone, t.timezone ]; for (i=0; i < RTokenKeys.length; i++) { cacheProcessRtoken(RTokenKeys[i], RToken[i], tokens[i]); } g.hms = _.cache(_.sequence([g.H, g.m, g.s], g.timePartDelimiter)); g.t = cacheProcessCtoken("shortMeridian", t.meridian); g.tt = cacheProcessCtoken("longMeridian", t.meridian); g.zzz = cacheProcessCtoken("timezone", t.timezone); g.timeSuffix = _.each(_.ignore(g.whiteSpace), _.set([ g.tt, g.zzz ])); g.time = _.each(_.optional(_.ignore(_.stoken("T"))), g.hms, g.timeSuffix); }, dateFormats: function () { // pre-loaded rules for different date part order preferences var _setfn = function () { return _.set(arguments, g.datePartDelimiter); }; var i, RTokenKeys = [ "d", "dd", "M", "MM", "y", "yy", "yyy", "yyyy" ], RToken = [ /^([0-2]\d|3[0-1]|\d)/, /^([0-2]\d|3[0-1])/, /^(1[0-2]|0\d|\d)/, /^(1[0-2]|0\d)/, /^(\d+)/, /^(\d\d)/, /^(\d\d?\d?\d?)/, /^(\d\d\d\d)/ ], tokens = [ t.day, t.day, t.month, t.month, t.year, t.year, t.year, t.year ], eachToken = [ "ordinalSuffix", "ordinalSuffix" ]; for (i=0; i < RTokenKeys.length; i++) { cacheProcessRtoken(RTokenKeys[i], RToken[i], tokens[i], eachToken[i]); } g.MMM = g.MMMM = _.cache(_.process(g.ctoken("jan feb mar apr may jun jul aug sep oct nov dec"), t.month)); g.ddd = g.dddd = _.cache(_.process(g.ctoken("sun mon tue wed thu fri sat"), function (s) { return function () { this.weekday = s; }; } )); g.day = _fn(g.d, g.dd); g.month = _fn(g.M, g.MMM); g.year = _fn(g.yyyy, g.yy); g.mdy = _setfn(g.ddd, g.month, g.day, g.year); g.ymd = _setfn(g.ddd, g.year, g.month, g.day); g.dmy = _setfn(g.ddd, g.day, g.month, g.year); g.date = function (s) { return ((g[Date.CultureInfo.dateElementOrder] || g.mdy).call(this, s)); }; }, relative: function () { // relative date / time expressions g.orientation = _.process(g.ctoken("past future"), function (s) { return function () { this.orient = s; }; } ); g.operator = _.process(g.ctoken("add subtract"), function (s) { return function () { this.operator = s; }; } ); g.rday = _.process(g.ctoken("yesterday tomorrow today now"), t.rday); g.unit = _.process(g.ctoken("second minute hour day week month year"), function (s) { return function () { this.unit = s; }; } ); } }; g.buildGrammarFormats = function () { // these need to be rebuilt every time the language changes. _C = {}; grammarFormats.timeFormats(); grammarFormats.dateFormats(); grammarFormats.relative(); g.value = _.process(_.rtoken(/^([-+]?\d+)?(st|nd|rd|th)?/), function (s) { return function () { this.value = s.replace(/\D/g, ""); }; } ); g.expression = _.set([g.rday, g.operator, g.value, g.unit, g.orientation, g.ddd, g.MMM ]); g.format = _.process(_.many( _.any( // translate format specifiers into grammar rules _.process( _.rtoken(/^(dd?d?d?(?!e)|MM?M?M?|yy?y?y?|hh?|HH?|mm?|ss?|tt?|zz?z?)/), function (fmt) { if (g[fmt]) { return g[fmt]; } else { throw $D.Parsing.Exception(fmt); } } ), // translate separator tokens into token rules _.process(_.rtoken(/^[^dMyhHmstz]+/), // all legal separators function (s) { return _.ignore(_.stoken(s)); } ) ) ), // construct the parser ... function (rules) { return _.process(_.each.apply(null, rules), t.finishExact); } ); // starting rule for general purpose grammar g._start = _.process(_.set([ g.date, g.time, g.expression ], g.generalDelimiter, g.whiteSpace), t.finish); }; g.buildGrammarFormats(); // parsing date format specifiers - ex: "h:m:s tt" // this little guy will generate a custom parser based // on the format string, ex: g.format("h:m:s tt") // check for these formats first g._formats = g.formats([ "\"yyyy-MM-ddTHH:mm:ssZ\"", "yyyy-MM-ddTHH:mm:ss.sz", "yyyy-MM-ddTHH:mm:ssZ", "yyyy-MM-ddTHH:mm:ssz", "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-ddTHH:mmZ", "yyyy-MM-ddTHH:mmz", "yyyy-MM-ddTHH:mm", "ddd, MMM dd, yyyy H:mm:ss tt", "ddd MMM d yyyy HH:mm:ss zzz", "MMddyyyy", "ddMMyyyy", "Mddyyyy", "ddMyyyy", "Mdyyyy", "dMyyyy", "yyyy", "Mdyy", "dMyy", "d" ]); // real starting rule: tries selected formats first, // then general purpose rule g.start = function (s) { try { var r = g._formats.call({}, s); if (r[1].length === 0) { return r; } } catch (e) {} return g._start.call({}, s); }; }()); (function () { var $D = Date; /** * @desc Converts the specified string value into its JavaScript Date equivalent using CultureInfo specific format information. * * Example

	///////////
	// Dates //
	///////////

	// 15-Oct-2004
	var d1 = Date.parse("10/15/2004");

	// 15-Oct-2004
	var d1 = Date.parse("15-Oct-2004");

	// 15-Oct-2004
	var d1 = Date.parse("2004.10.15");

	//Fri Oct 15, 2004
	var d1 = Date.parse("Fri Oct 15, 2004");

	///////////
	// Times //
	///////////

	// Today at 10 PM.
	var d1 = Date.parse("10 PM");

	// Today at 10:30 PM.
	var d1 = Date.parse("10:30 P.M.");

	// Today at 6 AM.
	var d1 = Date.parse("06am");

	/////////////////////
	// Dates and Times //
	/////////////////////

	// 8-July-2004 @ 10:30 PM
	var d1 = Date.parse("July 8th, 2004, 10:30 PM");

	// 1-July-2004 @ 10:30 PM
	var d1 = Date.parse("2004-07-01T22:30:00");

	////////////////////
	// Relative Dates //
	////////////////////

	// Returns today's date. The string "today" is culture specific.
	var d1 = Date.parse("today");

	// Returns yesterday's date. The string "yesterday" is culture specific.
	var d1 = Date.parse("yesterday");

	// Returns the date of the next thursday.
	var d1 = Date.parse("Next thursday");

	// Returns the date of the most previous monday.
	var d1 = Date.parse("last monday");

	// Returns today's day + one year.
	var d1 = Date.parse("next year");

	///////////////
	// Date Math //
	///////////////

	// Today + 2 days
	var d1 = Date.parse("t+2");

	// Today + 2 days
	var d1 = Date.parse("today + 2 days");

	// Today + 3 months
	var d1 = Date.parse("t+3m");

	// Today - 1 year
	var d1 = Date.parse("today - 1 year");

	// Today - 1 year
	var d1 = Date.parse("t-1y"); 


	/////////////////////////////
	// Partial Dates and Times //
	/////////////////////////////

	// July 15th of this year.
	var d1 = Date.parse("July 15");

	// 15th day of current day and year.
	var d1 = Date.parse("15");

	// July 1st of current year at 10pm.
	var d1 = Date.parse("7/1 10pm");
	
* * @param {String} The string value to convert into a Date object [Required] * @return {Date} A Date object or null if the string cannot be converted into a Date. */ var parseUtils = { removeOrds: function (s) { ords = s.match(/\b(\d+)(?:st|nd|rd|th)\b/); // find ordinal matches s = ((ords && ords.length === 2) ? s.replace(ords[0], ords[1]) : s); return s; }, grammarParser: function (s) { var r = null; try { r = $D.Grammar.start.call({}, s.replace(/^\s*(\S*(\s+\S+)*)\s*$/, "$1")); } catch (e) { return null; } return ((r[1].length === 0) ? r[0] : null); }, nativeFallback: function(s) { var t; try { // ok we haven't parsed it, last ditch attempt with the built-in parser. t = Date._parse(s); return (t || t === 0) ? new Date(t) : null; } catch (e) { return null; } } }; function parse (s) { var d; if (!s) { return null; } if (s instanceof Date) { return s.clone(); } if (s.length >= 4 && s.charAt(0) !== "0" && s.charAt(0) !== "+"&& s.charAt(0) !== "-") { // ie: 2004 will pass, 0800 won't. // Start with specific formats d = $D.Parsing.ISO.parse(s) || $D.Parsing.Numeric.parse(s); } if (d instanceof Date && !isNaN(d.getTime())) { return d; } else { // find ordinal dates (1st, 3rd, 8th, etc and remove them as they cause parsing issues) s = $D.Parsing.Normalizer.parse(parseUtils.removeOrds(s)); d = parseUtils.grammarParser(s); if (d !== null) { return d; } else { return parseUtils.nativeFallback(s); } } } if (!$D._parse) { $D._parse = $D.parse; } $D.parse = parse; Date.getParseFunction = function (fx) { var fns = Date.Grammar.allformats(fx); return function (s) { var r = null; for (var i = 0; i < fns.length; i++) { try { r = fns[i].call({}, s); } catch (e) { continue; } if (r[1].length === 0) { return r[0]; } } return null; }; }; /** * Converts the specified string value into its JavaScript Date equivalent using the specified format {String} or formats {Array} and the CultureInfo specific format information. * The format of the string value must match one of the supplied formats exactly. * * Example

	// 15-Oct-2004
	var d1 = Date.parseExact("10/15/2004", "M/d/yyyy");

	// 15-Oct-2004
	var d1 = Date.parse("15-Oct-2004", "M-ddd-yyyy");

	// 15-Oct-2004
	var d1 = Date.parse("2004.10.15", "yyyy.MM.dd");

	// Multiple formats
	var d1 = Date.parseExact("10/15/2004", ["M/d/yyyy", "MMMM d, yyyy"]);
	
* * @param {String} The string value to convert into a Date object [Required]. * @param {Object} The expected format {String} or an array of expected formats {Array} of the date string [Required]. * @return {Date} A Date object or null if the string cannot be converted into a Date. */ $D.parseExact = function (s, fx) { return $D.getParseFunction(fx)(s); }; }()); (function () { var $D = Date, $P = $D.prototype, // $C = $D.CultureInfo, // not used atm p = function (s, l) { if (!l) { l = 2; } return ("000" + s).slice(l * -1); }; /** * Converts a PHP format string to Java/.NET format string. * A PHP format string can be used with ._format or .format. * A Java/.NET format string can be used with .toString(). * The .parseExact function will only accept a Java/.NET format string * * Example * var f1 = "%m/%d/%y" * var f2 = Date.normalizeFormat(f1); // "MM/dd/yy" * * new Date().format(f1); // "04/13/08" * new Date()._format(f1); // "04/13/08" * new Date().toString(f2); // "04/13/08" * * var date = Date.parseExact("04/13/08", f2); // Sun Apr 13 2008 * * @param {String} A PHP format string consisting of one or more format spcifiers. * @return {String} The PHP format converted to a Java/.NET format string. */ var normalizerSubstitutions = { "d" : "dd", "%d": "dd", "D" : "ddd", "%a": "ddd", "j" : "dddd", "l" : "dddd", "%A": "dddd", "S" : "S", "F" : "MMMM", "%B": "MMMM", "m" : "MM", "%m": "MM", "M" : "MMM", "%b": "MMM", "%h": "MMM", "n" : "M", "Y" : "yyyy", "%Y": "yyyy", "y" : "yy", "%y": "yy", "g" : "h", "%I": "h", "G" : "H", "h" : "hh", "H" : "HH", "%H": "HH", "i" : "mm", "%M": "mm", "s" : "ss", "%S": "ss", "%r": "hh:mm tt", "%R": "H:mm", "%T": "H:mm:ss", "%X": "t", "%x": "d", "%e": "d", "%D": "MM/dd/yy", "%n": "\\n", "%t": "\\t", "e" : "z", "T" : "z", "%z": "z", "%Z": "z", "Z" : "ZZ", "N" : "u", "w" : "u", "%w": "u", "W" : "W", "%V": "W" }; var normalizer = { substitutes: function (m) { return normalizerSubstitutions[m]; }, interpreted: function (m, x) { var y; switch (m) { case "%u": return x.getDay() + 1; case "z": return x.getOrdinalNumber(); case "%j": return p(x.getOrdinalNumber(), 3); case "%U": var d1 = x.clone().set({month: 0, day: 1}).addDays(-1).moveToDayOfWeek(0), d2 = x.clone().addDays(1).moveToDayOfWeek(0, -1); return (d2 < d1) ? "00" : p((d2.getOrdinalNumber() - d1.getOrdinalNumber()) / 7 + 1); case "%W": return p(x.getWeek()); case "t": return $D.getDaysInMonth(x.getFullYear(), x.getMonth()); case "o": case "%G": return x.setWeek(x.getISOWeek()).toString("yyyy"); case "%g": return x._format("%G").slice(-2); case "a": case "%p": return t("tt").toLowerCase(); case "A": return t("tt").toUpperCase(); case "u": return p(x.getMilliseconds(), 3); case "I": return (x.isDaylightSavingTime()) ? 1 : 0; case "O": return x.getUTCOffset(); case "P": y = x.getUTCOffset(); return y.substring(0, y.length - 2) + ":" + y.substring(y.length - 2); case "B": var now = new Date(); return Math.floor(((now.getHours() * 3600) + (now.getMinutes() * 60) + now.getSeconds() + (now.getTimezoneOffset() + 60) * 60) / 86.4); case "c": return x.toISOString().replace(/\"/g, ""); case "U": return $D.strtotime("now"); case "%c": return t("d") + " " + t("t"); case "%C": return Math.floor(x.getFullYear() / 100 + 1); } }, shouldOverrideDefaults: function (m) { switch (m) { case "%e": return true; default: return false; } }, parse: function (m, context) { var formatString, c = context || new Date(); formatString = normalizer.substitutes(m); if (formatString) { return formatString; } formatString = normalizer.interpreted(m, c); if (formatString) { return formatString; } else { return m; } } }; $D.normalizeFormat = function (format, context) { return format.replace(/(%|\\)?.|%%/g, function(t){ return normalizer.parse(t, context); }); }; /** * Format a local Unix timestamp according to locale settings * * Example: * Date.strftime("%m/%d/%y", new Date()); // "04/13/08" * Date.strftime("c", "2008-04-13T17:52:03Z"); // "04/13/08" * * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @param {Number|String} The number representing the number of seconds that have elapsed since January 1, 1970 (local time). * @return {String} A string representation of the current Date object. */ $D.strftime = function (format, time) { var d = Date.parse(time); return d._format(format); }; /** * Parse any textual datetime description into a Unix timestamp. * A Unix timestamp is the number of seconds that have elapsed since January 1, 1970 (midnight UTC/GMT). * * Example: * Date.strtotime("04/13/08"); // 1208044800 * Date.strtotime("1970-01-01T00:00:00Z"); // 0 * * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @param {Object} A string or date object. * @return {String} A string representation of the current Date object. */ $D.strtotime = function (time) { var d = $D.parse(time); return Math.round($D.UTC(d.getUTCFullYear(), d.getUTCMonth(), d.getUTCDate(), d.getUTCHours(), d.getUTCMinutes(), d.getUTCSeconds(), d.getUTCMilliseconds()) / 1000); }; /** * Converts the value of the current Date object to its equivalent string representation using a PHP/Unix style of date format specifiers. * Format Specifiers * Format Description Example * ------ --------------------------------------------------------------------------- ----------------------- * %a abbreviated weekday name according to the current localed "Mon" through "Sun" * %A full weekday name according to the current localed "Sunday" through "Saturday" * %b abbreviated month name according to the current localed "Jan" through "Dec" * %B full month name according to the current locale "January" through "December" * %c preferred date and time representation for the current locale "4/13/2008 12:33 PM" * %C century number (the year divided by 100 and truncated to an integer) "00" to "99" * %d day of the month as a decimal number "01" to "31" * %D same as %m/%d/%y "04/13/08" * %e day of the month as a decimal number, a single digit is preceded by a space "1" to "31" * %g like %G, but without the century "08" * %G The 4-digit year corresponding to the ISO week number (see %V). "2008" * This has the same format and value as %Y, except that if the ISO week number * belongs to the previous or next year, that year is used instead. * %h same as %b "Jan" through "Dec" * %H hour as a decimal number using a 24-hour clock. "00" to "23" * %I hour as a decimal number using a 12-hour clock. "01" to "12" * %j day of the year as a decimal number. "001" to "366" * %m month as a decimal number. "01" to "12" * %M minute as a decimal number. "00" to "59" * %n newline character "\n" * %p either "am" or "pm" according to the given time value, or the "am" or "pm" * corresponding strings for the current locale. * %r time in a.m. and p.m. notation "8:44 PM" * %R time in 24 hour notation "20:44" * %S second as a decimal number "00" to "59" * %t tab character "\t" * %T current time, equal to %H:%M:%S "12:49:11" * %u weekday as a decimal number ["1", "7"], with "1" representing Monday "1" to "7" * %U week number of the current year as a decimal number, starting with the "0" to ("52" or "53") * first Sunday as the first day of the first week * %V The ISO 8601:1988 week number of the current year as a decimal number, "00" to ("52" or "53") * range 01 to 53, where week 1 is the first week that has at least 4 days * in the current year, and with Monday as the first day of the week. * (Use %G or %g for the year component that corresponds to the week number * for the specified timestamp.) * %W week number of the current year as a decimal number, starting with the "00" to ("52" or "53") * first Monday as the first day of the first week * %w day of the week as a decimal, Sunday being "0" "0" to "6" * %x preferred date representation for the current locale without the time "4/13/2008" * %X preferred time representation for the current locale without the date "12:53:05" * %y year as a decimal number without a century "00" "99" * %Y year as a decimal number including the century "2008" * %Z time zone or name or abbreviation "UTC", "EST", "PST" * %z same as %Z * %% a literal "%" characters "%" * d Day of the month, 2 digits with leading zeros "01" to "31" * D A textual representation of a day, three letters "Mon" through "Sun" * j Day of the month without leading zeros "1" to "31" * l A full textual representation of the day of the week (lowercase "L") "Sunday" through "Saturday" * N ISO-8601 numeric representation of the day of the week (added in PHP 5.1.0) "1" (for Monday) through "7" (for Sunday) * S English ordinal suffix for the day of the month, 2 characters "st", "nd", "rd" or "th". Works well with j * w Numeric representation of the day of the week "0" (for Sunday) through "6" (for Saturday) * z The day of the year (starting from "0") "0" through "365" * W ISO-8601 week number of year, weeks starting on Monday "00" to ("52" or "53") * F A full textual representation of a month, such as January or March "January" through "December" * m Numeric representation of a month, with leading zeros "01" through "12" * M A short textual representation of a month, three letters "Jan" through "Dec" * n Numeric representation of a month, without leading zeros "1" through "12" * t Number of days in the given month "28" through "31" * L Whether it's a leap year "1" if it is a leap year, "0" otherwise * o ISO-8601 year number. This has the same value as Y, except that if the "2008" * ISO week number (W) belongs to the previous or next year, that year * is used instead. * Y A full numeric representation of a year, 4 digits "2008" * y A two digit representation of a year "08" * a Lowercase Ante meridiem and Post meridiem "am" or "pm" * A Uppercase Ante meridiem and Post meridiem "AM" or "PM" * B Swatch Internet time "000" through "999" * g 12-hour format of an hour without leading zeros "1" through "12" * G 24-hour format of an hour without leading zeros "0" through "23" * h 12-hour format of an hour with leading zeros "01" through "12" * H 24-hour format of an hour with leading zeros "00" through "23" * i Minutes with leading zeros "00" to "59" * s Seconds, with leading zeros "00" through "59" * u Milliseconds "54321" * e Timezone identifier "UTC", "EST", "PST" * I Whether or not the date is in daylight saving time (uppercase i) "1" if Daylight Saving Time, "0" otherwise * O Difference to Greenwich time (GMT) in hours "+0200", "-0600" * P Difference to Greenwich time (GMT) with colon between hours and minutes "+02:00", "-06:00" * T Timezone abbreviation "UTC", "EST", "PST" * Z Timezone offset in seconds. The offset for timezones west of UTC is "-43200" through "50400" * always negative, and for those east of UTC is always positive. * c ISO 8601 date "2004-02-12T15:19:21+00:00" * r RFC 2822 formatted date "Thu, 21 Dec 2000 16:01:07 +0200" * U Seconds since the Unix Epoch (January 1 1970 00:00:00 GMT) "0" * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @return {String} A string representation of the current Date object. */ var formatReplace = function (context) { return function (m) { var formatString, override = false; if (m.charAt(0) === "\\" || m.substring(0, 2) === "%%") { return m.replace("\\", "").replace("%%", "%"); } override = normalizer.shouldOverrideDefaults(m); formatString = $D.normalizeFormat(m, context); if (formatString) { return context.toString(formatString, override); } }; }; $P._format = function (format) { var formatter = formatReplace(this); if (!format) { return this._toString(); } else { return format.replace(/(%|\\)?.|%%/g, formatter); } }; if (!$P.format) { $P.format = $P._format; } }()); (function () { "use strict"; var gFn = function (attr) { return function () { return this[attr]; }; }; var sFn = function (attr) { return function (val) { this[attr] = val; return this; }; }; var attrs = ["years", "months", "days", "hours", "minutes", "seconds", "milliseconds"]; var addSetFuncs = function (context, attrs) { for (var i = 0; i < attrs.length ; i++) { var $a = attrs[i], $b = $a.slice(0, 1).toUpperCase() + $a.slice(1); context.prototype[$a] = 0; context.prototype["get" + $b] = gFn($a); context.prototype["set" + $b] = sFn($a); } }; /** * new TimeSpan(milliseconds); * new TimeSpan(days, hours, minutes, seconds); * new TimeSpan(days, hours, minutes, seconds, milliseconds); */ var TimeSpan = function (days, hours, minutes, seconds, milliseconds) { if (arguments.length === 1 && typeof days === "number") { var orient = (days < 0) ? -1 : +1; var millsLeft = Math.abs(days); this.setDays(Math.floor(millsLeft / 86400000) * orient); millsLeft = millsLeft % 86400000; this.setHours(Math.floor(millsLeft / 3600000) * orient); millsLeft = millsLeft % 3600000; this.setMinutes(Math.floor(millsLeft / 60000) * orient); millsLeft = millsLeft % 60000; this.setSeconds(Math.floor(millsLeft / 1000) * orient); millsLeft = millsLeft % 1000; this.setMilliseconds(millsLeft * orient); } else { this.set(days, hours, minutes, seconds, milliseconds); } this.getTotalMilliseconds = function () { return (this.getDays() * 86400000) + (this.getHours() * 3600000) + (this.getMinutes() * 60000) + (this.getSeconds() * 1000); }; this.compareTo = function (time) { var t1 = new Date(1970, 1, 1, this.getHours(), this.getMinutes(), this.getSeconds()), t2; if (time === null) { t2 = new Date(1970, 1, 1, 0, 0, 0); } else { t2 = new Date(1970, 1, 1, time.getHours(), time.getMinutes(), time.getSeconds()); } return (t1 < t2) ? -1 : (t1 > t2) ? 1 : 0; }; this.equals = function (time) { return (this.compareTo(time) === 0); }; this.add = function (time) { return (time === null) ? this : this.addSeconds(time.getTotalMilliseconds() / 1000); }; this.subtract = function (time) { return (time === null) ? this : this.addSeconds(-time.getTotalMilliseconds() / 1000); }; this.addDays = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 86400000)); }; this.addHours = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 3600000)); }; this.addMinutes = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 60000)); }; this.addSeconds = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 1000)); }; this.addMilliseconds = function (n) { return new TimeSpan(this.getTotalMilliseconds() + n); }; this.get12HourHour = function () { return (this.getHours() > 12) ? this.getHours() - 12 : (this.getHours() === 0) ? 12 : this.getHours(); }; this.getDesignator = function () { return (this.getHours() < 12) ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator; }; this.toString = function (format) { this._toString = function () { if (this.getDays() !== null && this.getDays() > 0) { return this.getDays() + "." + this.getHours() + ":" + this.p(this.getMinutes()) + ":" + this.p(this.getSeconds()); } else { return this.getHours() + ":" + this.p(this.getMinutes()) + ":" + this.p(this.getSeconds()); } }; this.p = function (s) { return (s.toString().length < 2) ? "0" + s : s; }; var me = this; return format ? format.replace(/dd?|HH?|hh?|mm?|ss?|tt?/g, function (format) { switch (format) { case "d": return me.getDays(); case "dd": return me.p(me.getDays()); case "H": return me.getHours(); case "HH": return me.p(me.getHours()); case "h": return me.get12HourHour(); case "hh": return me.p(me.get12HourHour()); case "m": return me.getMinutes(); case "mm": return me.p(me.getMinutes()); case "s": return me.getSeconds(); case "ss": return me.p(me.getSeconds()); case "t": return ((me.getHours() < 12) ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator).substring(0, 1); case "tt": return (me.getHours() < 12) ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator; } } ) : this._toString(); }; return this; }; addSetFuncs(TimeSpan, attrs.slice(2)); TimeSpan.prototype.set = function (days, hours, minutes, seconds, milliseconds){ this.setDays(days || this.getDays()); this.setHours(hours || this.getHours()); this.setMinutes(minutes || this.getMinutes()); this.setSeconds(seconds || this.getSeconds()); this.setMilliseconds(milliseconds || this.getMilliseconds()); }; /** * Gets the time of day for this date instances. * @return {TimeSpan} TimeSpan */ Date.prototype.getTimeOfDay = function () { return new TimeSpan(0, this.getHours(), this.getMinutes(), this.getSeconds(), this.getMilliseconds()); }; Date.TimeSpan = TimeSpan; if (typeof window !== "undefined" ) { // keeping API compatible for v1.x window.TimeSpan = TimeSpan; } }()); (function () { "use strict"; var attrs = ["years", "months", "days", "hours", "minutes", "seconds", "milliseconds"]; var gFn = function (attr) { return function () { return this[attr]; }; }; var sFn = function (attr) { return function (val) { this[attr] = val; return this; }; }; var addSetFuncs = function (context, attrs) { for (var i = 0; i < attrs.length ; i++) { var $a = attrs[i], $b = $a.slice(0, 1).toUpperCase() + $a.slice(1); context.prototype[$a] = 0; context.prototype["get" + $b] = gFn($a); context.prototype["set" + $b] = sFn($a); } }; var setMonthsAndYears = function (orient, d1, d2, context) { function inc() { d1.addMonths(-orient); context.months++; if (context.months === 12) { context.years++; context.months = 0; } } if (orient === +1) { while (d1 > d2) { inc(); } } else { while (d1 < d2) { inc(); } } context.months--; context.months *= orient; context.years *= orient; }; var adjustForDST = function(orient, startDate, endDate) { var hasDSTMismatch = (false === (startDate.isDaylightSavingTime() === endDate.isDaylightSavingTime())); if (hasDSTMismatch && orient === 1) { startDate.addHours(-1); } else if (hasDSTMismatch) { startDate.addHours(1); } }; /** * TimePeriod(startDate, endDate); * TimePeriod(years, months, days, hours, minutes, seconds, milliseconds); */ var TimePeriod = function (years, months, days, hours, minutes, seconds, milliseconds) { if (arguments.length === 7) { this.set(years, months, days, hours, minutes, seconds, milliseconds); } else if (arguments.length === 2 && arguments[0] instanceof Date && arguments[1] instanceof Date) { var startDate = arguments[0].clone(); var endDate = arguments[1].clone(); var orient = (startDate > endDate) ? +1 : -1; this.dates = { start: arguments[0].clone(), end: arguments[1].clone() }; setMonthsAndYears(orient, startDate, endDate, this); adjustForDST(orient, startDate, endDate); // // TODO - adjust for DST var diff = endDate - startDate; if (diff !== 0) { var ts = new TimeSpan(diff); this.set(this.years, this.months, ts.getDays(), ts.getHours(), ts.getMinutes(), ts.getSeconds(), ts.getMilliseconds()); } } return this; }; // create all the set functions. addSetFuncs(TimePeriod, attrs); TimePeriod.prototype.set = function (years, months, days, hours, minutes, seconds, milliseconds){ this.setYears(years || this.getYears()); this.setMonths(months || this.getMonths()); this.setDays(days || this.getDays()); this.setHours(hours || this.getHours()); this.setMinutes(minutes || this.getMinutes()); this.setSeconds(seconds || this.getSeconds()); this.setMilliseconds(milliseconds || this.getMilliseconds()); }; Date.TimePeriod = TimePeriod; if (typeof window !== "undefined") { // keeping API compatible for v1.x window.TimePeriod = TimePeriod; } }()); ================================================ FILE: build/date-fr-LU.js ================================================ /** * @overview datejs * @version 1.0.0-rc3 * @author Gregory Wild-Smith * @copyright 2015 Gregory Wild-Smith * @license MIT * @homepage https://github.com/abritinthebay/datejs */ /* * DateJS Culture String File * Country Code: fr-LU * Name: French (Luxembourg) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["fr-LU"] = { "name": "fr-LU", "englishName": "French (Luxembourg)", "nativeName": "français (Luxembourg)", "Sunday": "dimanche", "Monday": "lundi", "Tuesday": "mardi", "Wednesday": "mercredi", "Thursday": "jeudi", "Friday": "vendredi", "Saturday": "samedi", "Sun": "dim.", "Mon": "lun.", "Tue": "mar.", "Wed": "mer.", "Thu": "jeu.", "Fri": "ven.", "Sat": "sam.", "Su": "di", "Mo": "lu", "Tu": "ma", "We": "me", "Th": "je", "Fr": "ve", "Sa": "sa", "S_Sun_Initial": "d", "M_Mon_Initial": "l", "T_Tue_Initial": "m", "W_Wed_Initial": "m", "T_Thu_Initial": "j", "F_Fri_Initial": "v", "S_Sat_Initial": "s", "January": "janvier", "February": "février", "March": "mars", "April": "avril", "May": "mai", "June": "juin", "July": "juillet", "August": "août", "September": "septembre", "October": "octobre", "November": "novembre", "December": "décembre", "Jan_Abbr": "janv.", "Feb_Abbr": "févr.", "Mar_Abbr": "mars", "Apr_Abbr": "avr.", "May_Abbr": "mai", "Jun_Abbr": "juin", "Jul_Abbr": "juil.", "Aug_Abbr": "août", "Sep_Abbr": "sept.", "Oct_Abbr": "oct.", "Nov_Abbr": "nov.", "Dec_Abbr": "déc.", "AM": "", "PM": "", "firstDayOfWeek": 1, "twoDigitYearMax": 2029, "mdy": "dmy", "M/d/yyyy": "dd/MM/yyyy", "dddd, MMMM dd, yyyy": "dddd d MMMM yyyy", "h:mm tt": "HH:mm", "h:mm:ss tt": "HH:mm:ss", "dddd, MMMM dd, yyyy h:mm:ss tt": "dddd d MMMM yyyy HH:mm:ss", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "d MMMM", "MMMM, yyyy": "MMMM yyyy", "/jan(uary)?/": "janv(.(ier)?)?", "/feb(ruary)?/": "févr(.(ier)?)?", "/mar(ch)?/": "mars", "/apr(il)?/": "avr(.(il)?)?", "/may/": "mai", "/jun(e)?/": "juin", "/jul(y)?/": "juil(.(let)?)?", "/aug(ust)?/": "août", "/sep(t(ember)?)?/": "sept(.(embre)?)?", "/oct(ober)?/": "oct(.(obre)?)?", "/nov(ember)?/": "nov(.(embre)?)?", "/dec(ember)?/": "déc(.(embre)?)?", "/^su(n(day)?)?/": "^di(m(.(anche)?)?)?", "/^mo(n(day)?)?/": "^lu(n(.(di)?)?)?", "/^tu(e(s(day)?)?)?/": "^ma(r(.(di)?)?)?", "/^we(d(nesday)?)?/": "^me(r(.(credi)?)?)?", "/^th(u(r(s(day)?)?)?)?/": "^je(u(.(di)?)?)?", "/^fr(i(day)?)?/": "^ve(n(.(dredi)?)?)?", "/^sa(t(urday)?)?/": "^sa(m(.(edi)?)?)?", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "fr-LU"; /** * @overview datejs * @version 1.0.0-rc3 * @author Gregory Wild-Smith * @copyright 2015 Gregory Wild-Smith * @license MIT * @homepage https://github.com/abritinthebay/datejs */(function () { var $D = Date; var lang = Date.CultureStrings ? Date.CultureStrings.lang : null; var loggedKeys = {}; // for debug purposes. var getText = { getFromKey: function (key, countryCode) { var output; if (Date.CultureStrings && Date.CultureStrings[countryCode] && Date.CultureStrings[countryCode][key]) { output = Date.CultureStrings[countryCode][key]; } else { output = getText.buildFromDefault(key); } if (key.charAt(0) === "/") { // Assume it's a regex output = getText.buildFromRegex(key, countryCode); } return output; }, getFromObjectValues: function (obj, countryCode) { var key, output = {}; for(key in obj) { if (obj.hasOwnProperty(key)) { output[key] = getText.getFromKey(obj[key], countryCode); } } return output; }, getFromObjectKeys: function (obj, countryCode) { var key, output = {}; for(key in obj) { if (obj.hasOwnProperty(key)) { output[getText.getFromKey(key, countryCode)] = obj[key]; } } return output; }, getFromArray: function (arr, countryCode) { var output = []; for (var i=0; i < arr.length; i++){ if (i in arr) { output[i] = getText.getFromKey(arr[i], countryCode); } } return output; }, buildFromDefault: function (key) { var output, length, split, last; switch(key) { case "name": output = "en-US"; break; case "englishName": output = "English (United States)"; break; case "nativeName": output = "English (United States)"; break; case "twoDigitYearMax": output = 2049; break; case "firstDayOfWeek": output = 0; break; default: output = key; split = key.split("_"); length = split.length; if (length > 1 && key.charAt(0) !== "/") { // if the key isn't a regex and it has a split. last = split[(length - 1)].toLowerCase(); if (last === "initial" || last === "abbr") { output = split[0]; } } break; } return output; }, buildFromRegex: function (key, countryCode) { var output; if (Date.CultureStrings && Date.CultureStrings[countryCode] && Date.CultureStrings[countryCode][key]) { output = new RegExp(Date.CultureStrings[countryCode][key], "i"); } else { output = new RegExp(key.replace(new RegExp("/", "g"),""), "i"); } return output; } }; var shallowMerge = function (obj1, obj2) { for (var attrname in obj2) { if (obj2.hasOwnProperty(attrname)) { obj1[attrname] = obj2[attrname]; } } }; var __ = function (key, language) { var countryCode = (language) ? language : lang; loggedKeys[key] = key; if (typeof key === "object") { if (key instanceof Array) { return getText.getFromArray(key, countryCode); } else { return getText.getFromObjectKeys(key, countryCode); } } else { return getText.getFromKey(key, countryCode); } }; var loadI18nScript = function (code) { // paatterned after jQuery's getScript. var url = Date.Config.i18n + code + ".js"; var head = document.getElementsByTagName("head")[0] || document.documentElement; var script = document.createElement("script"); script.src = url; var completed = false; var events = { done: function (){} // placeholder function }; // Attach handlers for all browsers script.onload = script.onreadystatechange = function() { if ( !completed && (!this.readyState || this.readyState === "loaded" || this.readyState === "complete") ) { events.done(); head.removeChild(script); } }; setTimeout(function() { head.insertBefore(script, head.firstChild); }, 0); // allows return to execute first return { done: function (cb) { events.done = function() { if (cb) { setTimeout(cb,0); } }; } }; }; var buildInfo = { buildFromMethodHash: function (obj) { var key; for(key in obj) { if (obj.hasOwnProperty(key)) { obj[key] = buildInfo[obj[key]](); } } return obj; }, timeZoneDST: function () { var DST = { "CHADT": "+1345", "NZDT": "+1300", "AEDT": "+1100", "ACDT": "+1030", "AZST": "+0500", "IRDT": "+0430", "EEST": "+0300", "CEST": "+0200", "BST": "+0100", "PMDT": "-0200", "ADT": "-0300", "NDT": "-0230", "EDT": "-0400", "CDT": "-0500", "MDT": "-0600", "PDT": "-0700", "AKDT": "-0800", "HADT": "-0900" }; return __(DST); }, timeZoneStandard: function () { var standard = { "LINT": "+1400", "TOT": "+1300", "CHAST": "+1245", "NZST": "+1200", "NFT": "+1130", "SBT": "+1100", "AEST": "+1000", "ACST": "+0930", "JST": "+0900", "CWST": "+0845", "CT": "+0800", "ICT": "+0700", "MMT": "+0630", "BST": "+0600", "NPT": "+0545", "IST": "+0530", "PKT": "+0500", "AFT": "+0430", "MSK": "+0400", "IRST": "+0330", "FET": "+0300", "EET": "+0200", "CET": "+0100", "GMT": "+0000", "UTC": "+0000", "CVT": "-0100", "GST": "-0200", "BRT": "-0300", "NST": "-0330", "AST": "-0400", "EST": "-0500", "CST": "-0600", "MST": "-0700", "PST": "-0800", "AKST": "-0900", "MIT": "-0930", "HST": "-1000", "SST": "-1100", "BIT": "-1200" }; return __(standard); }, timeZones: function (data) { var zone; data.timezones = []; for (zone in data.abbreviatedTimeZoneStandard) { if (data.abbreviatedTimeZoneStandard.hasOwnProperty(zone)) { data.timezones.push({ name: zone, offset: data.abbreviatedTimeZoneStandard[zone]}); } } for (zone in data.abbreviatedTimeZoneDST) { if (data.abbreviatedTimeZoneDST.hasOwnProperty(zone)) { data.timezones.push({ name: zone, offset: data.abbreviatedTimeZoneDST[zone], dst: true}); } } return data.timezones; }, days: function () { return __(["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"]); }, dayAbbr: function () { return __(["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"]); }, dayShortNames: function () { return __(["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"]); }, dayFirstLetters: function () { return __(["S_Sun_Initial", "M_Mon_Initial", "T_Tues_Initial", "W_Wed_Initial", "T_Thu_Initial", "F_Fri_Initial", "S_Sat_Initial"]); }, months: function () { return __(["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"]); }, monthAbbr: function () { return __(["Jan_Abbr", "Feb_Abbr", "Mar_Abbr", "Apr_Abbr", "May_Abbr", "Jun_Abbr", "Jul_Abbr", "Aug_Abbr", "Sep_Abbr", "Oct_Abbr", "Nov_Abbr", "Dec_Abbr"]); }, formatPatterns: function () { return getText.getFromObjectValues({ shortDate: "M/d/yyyy", longDate: "dddd, MMMM dd, yyyy", shortTime: "h:mm tt", longTime: "h:mm:ss tt", fullDateTime: "dddd, MMMM dd, yyyy h:mm:ss tt", sortableDateTime: "yyyy-MM-ddTHH:mm:ss", universalSortableDateTime: "yyyy-MM-dd HH:mm:ssZ", rfc1123: "ddd, dd MMM yyyy HH:mm:ss", monthDay: "MMMM dd", yearMonth: "MMMM, yyyy" }, Date.i18n.currentLanguage()); }, regex: function () { return getText.getFromObjectValues({ inTheMorning: "/( in the )(morn(ing)?)\\b/", thisMorning: "/(this )(morn(ing)?)\\b/", amThisMorning: "/(\b\\d(am)? )(this )(morn(ing)?)/", inTheEvening: "/( in the )(even(ing)?)\\b/", thisEvening: "/(this )(even(ing)?)\\b/", pmThisEvening: "/(\b\\d(pm)? )(this )(even(ing)?)/", jan: "/jan(uary)?/", feb: "/feb(ruary)?/", mar: "/mar(ch)?/", apr: "/apr(il)?/", may: "/may/", jun: "/jun(e)?/", jul: "/jul(y)?/", aug: "/aug(ust)?/", sep: "/sep(t(ember)?)?/", oct: "/oct(ober)?/", nov: "/nov(ember)?/", dec: "/dec(ember)?/", sun: "/^su(n(day)?)?/", mon: "/^mo(n(day)?)?/", tue: "/^tu(e(s(day)?)?)?/", wed: "/^we(d(nesday)?)?/", thu: "/^th(u(r(s(day)?)?)?)?/", fri: "/fr(i(day)?)?/", sat: "/^sa(t(urday)?)?/", future: "/^next/", past: "/^last|past|prev(ious)?/", add: "/^(\\+|aft(er)?|from|hence)/", subtract: "/^(\\-|bef(ore)?|ago)/", yesterday: "/^yes(terday)?/", today: "/^t(od(ay)?)?/", tomorrow: "/^tom(orrow)?/", now: "/^n(ow)?/", millisecond: "/^ms|milli(second)?s?/", second: "/^sec(ond)?s?/", minute: "/^mn|min(ute)?s?/", hour: "/^h(our)?s?/", week: "/^w(eek)?s?/", month: "/^m(onth)?s?/", day: "/^d(ay)?s?/", year: "/^y(ear)?s?/", shortMeridian: "/^(a|p)/", longMeridian: "/^(a\\.?m?\\.?|p\\.?m?\\.?)/", timezone: "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/", ordinalSuffix: "/^\\s*(st|nd|rd|th)/", timeContext: "/^\\s*(\\:|a(?!u|p)|p)/" }, Date.i18n.currentLanguage()); } }; var CultureInfo = function () { var info = getText.getFromObjectValues({ name: "name", englishName: "englishName", nativeName: "nativeName", amDesignator: "AM", pmDesignator: "PM", firstDayOfWeek: "firstDayOfWeek", twoDigitYearMax: "twoDigitYearMax", dateElementOrder: "mdy" }, Date.i18n.currentLanguage()); var constructedInfo = buildInfo.buildFromMethodHash({ dayNames: "days", abbreviatedDayNames: "dayAbbr", shortestDayNames: "dayShortNames", firstLetterDayNames: "dayFirstLetters", monthNames: "months", abbreviatedMonthNames: "monthAbbr", formatPatterns: "formatPatterns", regexPatterns: "regex", abbreviatedTimeZoneDST: "timeZoneDST", abbreviatedTimeZoneStandard: "timeZoneStandard" }); shallowMerge(info, constructedInfo); buildInfo.timeZones(info); return info; }; $D.i18n = { __: function (key, lang) { return __(key, lang); }, currentLanguage: function () { return lang || "en-US"; }, setLanguage: function (code, force, cb) { var async = false; if (force || code === "en-US" || (!!Date.CultureStrings && !!Date.CultureStrings[code])) { lang = code; Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings.lang = code; Date.CultureInfo = new CultureInfo(); } else { if (!(!!Date.CultureStrings && !!Date.CultureStrings[code])) { if (typeof exports !== "undefined" && this.exports !== exports) { // we're in a Node enviroment, load it using require try { require("../i18n/" + code + ".js"); lang = code; Date.CultureStrings.lang = code; Date.CultureInfo = new CultureInfo(); } catch (e) { // var str = "The language for '" + code + "' could not be loaded by Node. It likely does not exist."; throw new Error("The DateJS IETF language tag '" + code + "' could not be loaded by Node. It likely does not exist."); } } else if (Date.Config && Date.Config.i18n) { // we know the location of the files, so lets load them async = true; loadI18nScript(code).done(function(){ lang = code; Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings.lang = code; Date.CultureInfo = new CultureInfo(); $D.Parsing.Normalizer.buildReplaceData(); // because this is async if ($D.Grammar) { $D.Grammar.buildGrammarFormats(); // so we can parse those strings... } if (cb) { setTimeout(cb,0); } }); } else { Date.console.error("The DateJS IETF language tag '" + code + "' is not available and has not been loaded."); return false; } } } $D.Parsing.Normalizer.buildReplaceData(); // rebuild normalizer strings if ($D.Grammar) { $D.Grammar.buildGrammarFormats(); // so we can parse those strings... } if (!async && cb) { setTimeout(cb,0); } }, getLoggedKeys: function () { return loggedKeys; }, updateCultureInfo: function () { Date.CultureInfo = new CultureInfo(); } }; $D.i18n.updateCultureInfo(); // run automatically }()); (function () { var $D = Date, $P = $D.prototype, p = function (s, l) { if (!l) { l = 2; } return ("000" + s).slice(l * -1); }; if (typeof window !== "undefined" && typeof window.console !== "undefined" && typeof window.console.log !== "undefined") { $D.console = console; // used only to raise non-critical errors if available } else { // set mock so we don't give errors. $D.console = { log: function(){}, error: function(){} }; } $D.Config = $D.Config || {}; $D.initOverloads = function() { /** * Overload of Date.now. Allows an alternate call for Date.now where it returns the * current Date as an object rather than just milliseconds since the Unix Epoch. * * Also provides an implementation of now() for browsers (IE<9) that don't have it. * * Backwards compatible so with work with either: * Date.now() [returns ms] * or * Date.now(true) [returns Date] */ if (!$D.now) { $D._now = function now() { return new Date().getTime(); }; } else if (!$D._now) { $D._now = $D.now; } $D.now = function (returnObj) { if (returnObj) { return $D.present(); } else { return $D._now(); } }; if ( !$P.toISOString ) { $P.toISOString = function() { return this.getUTCFullYear() + "-" + p(this.getUTCMonth() + 1) + "-" + p(this.getUTCDate()) + "T" + p(this.getUTCHours()) + ":" + p(this.getUTCMinutes()) + ":" + p(this.getUTCSeconds()) + "." + String( (this.getUTCMilliseconds()/1000).toFixed(3)).slice(2, 5) + "Z"; }; } // private if ( $P._toString === undefined ){ $P._toString = $P.toString; } }; $D.initOverloads(); /** * Gets a date that is set to the current date. The time is set to the start of the day (00:00 or 12:00 AM). * @return {Date} The current date. */ $D.today = function () { return new Date().clearTime(); }; /** * Gets a date that is set to the current date and time (same as new Date, but chainable) * @return {Date} The current date. */ $D.present = function () { return new Date(); }; /** * Compares the first date to the second date and returns an number indication of their relative values. * @param {Date} First Date object to compare [Required]. * @param {Date} Second Date object to compare to [Required]. * @return {Number} -1 = date1 is lessthan date2. 0 = values are equal. 1 = date1 is greaterthan date2. */ $D.compare = function (date1, date2) { if (isNaN(date1) || isNaN(date2)) { throw new Error(date1 + " - " + date2); } else if (date1 instanceof Date && date2 instanceof Date) { return (date1 < date2) ? -1 : (date1 > date2) ? 1 : 0; } else { throw new TypeError(date1 + " - " + date2); } }; /** * Compares the first Date object to the second Date object and returns true if they are equal. * @param {Date} First Date object to compare [Required] * @param {Date} Second Date object to compare to [Required] * @return {Boolean} true if dates are equal. false if they are not equal. */ $D.equals = function (date1, date2) { return (date1.compareTo(date2) === 0); }; /** * Gets the language appropriate day name when given the day number(0-6) * eg - 0 == Sunday * @return {String} The day name */ $D.getDayName = function (n) { return Date.CultureInfo.dayNames[n]; }; /** * Gets the day number (0-6) if given a CultureInfo specific string which is a valid dayName, abbreviatedDayName or shortestDayName (two char). * @param {String} The name of the day (eg. "Monday, "Mon", "tuesday", "tue", "We", "we"). * @return {Number} The day number */ $D.getDayNumberFromName = function (name) { var n = Date.CultureInfo.dayNames, m = Date.CultureInfo.abbreviatedDayNames, o = Date.CultureInfo.shortestDayNames, s = name.toLowerCase(); for (var i = 0; i < n.length; i++) { if (n[i].toLowerCase() === s || m[i].toLowerCase() === s || o[i].toLowerCase() === s) { return i; } } return -1; }; /** * Gets the month number (0-11) if given a Culture Info specific string which is a valid monthName or abbreviatedMonthName. * @param {String} The name of the month (eg. "February, "Feb", "october", "oct"). * @return {Number} The day number */ $D.getMonthNumberFromName = function (name) { var n = Date.CultureInfo.monthNames, m = Date.CultureInfo.abbreviatedMonthNames, s = name.toLowerCase(); for (var i = 0; i < n.length; i++) { if (n[i].toLowerCase() === s || m[i].toLowerCase() === s) { return i; } } return -1; }; /** * Gets the language appropriate month name when given the month number(0-11) * eg - 0 == January * @return {String} The month name */ $D.getMonthName = function (n) { return Date.CultureInfo.monthNames[n]; }; /** * Determines if the current date instance is within a LeapYear. * @param {Number} The year. * @return {Boolean} true if date is within a LeapYear, otherwise false. */ $D.isLeapYear = function (year) { return ((year % 4 === 0 && year % 100 !== 0) || year % 400 === 0); }; /** * Gets the number of days in the month, given a year and month value. Automatically corrects for LeapYear. * @param {Number} The year. * @param {Number} The month (0-11). * @return {Number} The number of days in the month. */ $D.getDaysInMonth = function (year, month) { if (!month && $D.validateMonth(year)) { month = year; year = Date.today().getFullYear(); } return [31, ($D.isLeapYear(year) ? 29 : 28), 31, 30, 31, 30, 31, 31, 30, 31, 30, 31][month]; }; $P.getDaysInMonth = function () { return $D.getDaysInMonth(this.getFullYear(), this.getMonth()); }; $D.getTimezoneAbbreviation = function (offset, dst) { var p, n = (dst || false) ? Date.CultureInfo.abbreviatedTimeZoneDST : Date.CultureInfo.abbreviatedTimeZoneStandard; for (p in n) { if (n.hasOwnProperty(p)) { if (n[p] === offset) { return p; } } } return null; }; $D.getTimezoneOffset = function (name, dst) { var i, a =[], z = Date.CultureInfo.timezones; if (!name) { name = (new Date()).getTimezone();} for (i = 0; i < z.length; i++) { if (z[i].name === name.toUpperCase()) { a.push(i); } } if (!z[a[0]]) { return null; } if (a.length === 1 || !dst) { return z[a[0]].offset; } else { for (i=0; i < a.length; i++) { if (z[a[i]].dst) { return z[a[i]].offset; } } } }; $D.getQuarter = function (d) { d = d || new Date(); // If no date supplied, use today var q = [1,2,3,4]; return q[Math.floor(d.getMonth() / 3)]; // ~~~ is a bitwise op. Faster than Math.floor }; $D.getDaysLeftInQuarter = function (d) { d = d || new Date(); var qEnd = new Date(d); qEnd.setMonth(qEnd.getMonth() + 3 - qEnd.getMonth() % 3, 0); return Math.floor((qEnd - d) / 8.64e7); }; // private var validate = function (n, min, max, name) { name = name ? name : "Object"; if (typeof n === "undefined") { return false; } else if (typeof n !== "number") { throw new TypeError(n + " is not a Number."); } else if (n < min || n > max) { // As failing validation is *not* an exceptional circumstance // lets not throw a RangeError Exception here. // It's semantically correct but it's not sensible. return false; } return true; }; /** * Validates the number is within an acceptable range for milliseconds [0-999]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateMillisecond = function (value) { return validate(value, 0, 999, "millisecond"); }; /** * Validates the number is within an acceptable range for seconds [0-59]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateSecond = function (value) { return validate(value, 0, 59, "second"); }; /** * Validates the number is within an acceptable range for minutes [0-59]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateMinute = function (value) { return validate(value, 0, 59, "minute"); }; /** * Validates the number is within an acceptable range for hours [0-23]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateHour = function (value) { return validate(value, 0, 23, "hour"); }; /** * Validates the number is within an acceptable range for the days in a month [0-MaxDaysInMonth]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateDay = function (value, year, month) { if (year === undefined || year === null || month === undefined || month === null) { return false;} return validate(value, 1, $D.getDaysInMonth(year, month), "day"); }; /** * Validates the number is within an acceptable range for months [0-11]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateWeek = function (value) { return validate(value, 0, 53, "week"); }; /** * Validates the number is within an acceptable range for months [0-11]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateMonth = function (value) { return validate(value, 0, 11, "month"); }; /** * Validates the number is within an acceptable range for years. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateYear = function (value) { /** * Per ECMAScript spec the range of times supported by Date objects is * exactly -100,000,000 days to +100,000,000 days measured relative to * midnight at the beginning of 01 January, 1970 UTC. * This gives a range of 8,640,000,000,000,000 milliseconds to either * side of 01 January, 1970 UTC. * * Earliest possible date: Tue, 20 Apr 271,822 B.C. 00:00:00 UTC * Latest possible date: Sat, 13 Sep 275,760 00:00:00 UTC */ return validate(value, -271822, 275760, "year"); }; $D.validateTimezone = function(value) { var timezones = {"ACDT":1,"ACST":1,"ACT":1,"ADT":1,"AEDT":1,"AEST":1,"AFT":1,"AKDT":1,"AKST":1,"AMST":1,"AMT":1,"ART":1,"AST":1,"AWDT":1,"AWST":1,"AZOST":1,"AZT":1,"BDT":1,"BIOT":1,"BIT":1,"BOT":1,"BRT":1,"BST":1,"BTT":1,"CAT":1,"CCT":1,"CDT":1,"CEDT":1,"CEST":1,"CET":1,"CHADT":1,"CHAST":1,"CHOT":1,"ChST":1,"CHUT":1,"CIST":1,"CIT":1,"CKT":1,"CLST":1,"CLT":1,"COST":1,"COT":1,"CST":1,"CT":1,"CVT":1,"CWST":1,"CXT":1,"DAVT":1,"DDUT":1,"DFT":1,"EASST":1,"EAST":1,"EAT":1,"ECT":1,"EDT":1,"EEDT":1,"EEST":1,"EET":1,"EGST":1,"EGT":1,"EIT":1,"EST":1,"FET":1,"FJT":1,"FKST":1,"FKT":1,"FNT":1,"GALT":1,"GAMT":1,"GET":1,"GFT":1,"GILT":1,"GIT":1,"GMT":1,"GST":1,"GYT":1,"HADT":1,"HAEC":1,"HAST":1,"HKT":1,"HMT":1,"HOVT":1,"HST":1,"ICT":1,"IDT":1,"IOT":1,"IRDT":1,"IRKT":1,"IRST":1,"IST":1,"JST":1,"KGT":1,"KOST":1,"KRAT":1,"KST":1,"LHST":1,"LINT":1,"MAGT":1,"MART":1,"MAWT":1,"MDT":1,"MET":1,"MEST":1,"MHT":1,"MIST":1,"MIT":1,"MMT":1,"MSK":1,"MST":1,"MUT":1,"MVT":1,"MYT":1,"NCT":1,"NDT":1,"NFT":1,"NPT":1,"NST":1,"NT":1,"NUT":1,"NZDT":1,"NZST":1,"OMST":1,"ORAT":1,"PDT":1,"PET":1,"PETT":1,"PGT":1,"PHOT":1,"PHT":1,"PKT":1,"PMDT":1,"PMST":1,"PONT":1,"PST":1,"PYST":1,"PYT":1,"RET":1,"ROTT":1,"SAKT":1,"SAMT":1,"SAST":1,"SBT":1,"SCT":1,"SGT":1,"SLST":1,"SRT":1,"SST":1,"SYOT":1,"TAHT":1,"THA":1,"TFT":1,"TJT":1,"TKT":1,"TLT":1,"TMT":1,"TOT":1,"TVT":1,"UCT":1,"ULAT":1,"UTC":1,"UYST":1,"UYT":1,"UZT":1,"VET":1,"VLAT":1,"VOLT":1,"VOST":1,"VUT":1,"WAKT":1,"WAST":1,"WAT":1,"WEDT":1,"WEST":1,"WET":1,"WST":1,"YAKT":1,"YEKT":1,"Z":1}; return (timezones[value] === 1); }; $D.validateTimezoneOffset= function(value) { // timezones go from +14hrs to -12hrs, the +X hours are negative offsets. return (value > -841 && value < 721); }; }()); (function () { var $D = Date, $P = $D.prototype, p = function (s, l) { if (!l) { l = 2; } return ("000" + s).slice(l * -1); }; var validateConfigObject = function (obj) { var result = {}, self = this, prop, testFunc; testFunc = function (prop, func, value) { if (prop === "day") { var month = (obj.month !== undefined) ? obj.month : self.getMonth(); var year = (obj.year !== undefined) ? obj.year : self.getFullYear(); return $D[func](value, year, month); } else { return $D[func](value); } }; for (prop in obj) { if (Object.prototype.hasOwnProperty.call(obj, prop)) { var func = "validate" + prop.charAt(0).toUpperCase() + prop.slice(1); if ($D[func] && obj[prop] !== null && testFunc(prop, func, obj[prop])) { result[prop] = obj[prop]; } } } return result; }; /** * Resets the time of this Date object to 12:00 AM (00:00), which is the start of the day. * @param {Boolean} .clone() this date instance before clearing Time * @return {Date} this */ $P.clearTime = function () { this.setHours(0); this.setMinutes(0); this.setSeconds(0); this.setMilliseconds(0); return this; }; /** * Resets the time of this Date object to the current time ('now'). * @return {Date} this */ $P.setTimeToNow = function () { var n = new Date(); this.setHours(n.getHours()); this.setMinutes(n.getMinutes()); this.setSeconds(n.getSeconds()); this.setMilliseconds(n.getMilliseconds()); return this; }; /** * Returns a new Date object that is an exact date and time copy of the original instance. * @return {Date} A new Date instance */ $P.clone = function () { return new Date(this.getTime()); }; /** * Compares this instance to a Date object and returns an number indication of their relative values. * @param {Date} Date object to compare [Required] * @return {Number} -1 = this is lessthan date. 0 = values are equal. 1 = this is greaterthan date. */ $P.compareTo = function (date) { return Date.compare(this, date); }; /** * Compares this instance to another Date object and returns true if they are equal. * @param {Date} Date object to compare. If no date to compare, new Date() [now] is used. * @return {Boolean} true if dates are equal. false if they are not equal. */ $P.equals = function (date) { return Date.equals(this, (date !== undefined ? date : new Date())); }; /** * Determines if this instance is between a range of two dates or equal to either the start or end dates. * @param {Date} Start of range [Required] * @param {Date} End of range [Required] * @return {Boolean} true is this is between or equal to the start and end dates, else false */ $P.between = function (start, end) { return this.getTime() >= start.getTime() && this.getTime() <= end.getTime(); }; /** * Determines if this date occurs after the date to compare to. * @param {Date} Date object to compare. If no date to compare, new Date() ("now") is used. * @return {Boolean} true if this date instance is greater than the date to compare to (or "now"), otherwise false. */ $P.isAfter = function (date) { return this.compareTo(date || new Date()) === 1; }; /** * Determines if this date occurs before the date to compare to. * @param {Date} Date object to compare. If no date to compare, new Date() ("now") is used. * @return {Boolean} true if this date instance is less than the date to compare to (or "now"). */ $P.isBefore = function (date) { return (this.compareTo(date || new Date()) === -1); }; /** * Determines if the current Date instance occurs today. * @return {Boolean} true if this date instance is 'today', otherwise false. */ /** * Determines if the current Date instance occurs on the same Date as the supplied 'date'. * If no 'date' to compare to is provided, the current Date instance is compared to 'today'. * @param {date} Date object to compare. If no date to compare, the current Date ("now") is used. * @return {Boolean} true if this Date instance occurs on the same Day as the supplied 'date'. */ $P.isToday = $P.isSameDay = function (date) { return this.clone().clearTime().equals((date || new Date()).clone().clearTime()); }; /** * Adds the specified number of milliseconds to this instance. * @param {Number} The number of milliseconds to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addMilliseconds = function (value) { if (!value) { return this; } this.setTime(this.getTime() + value * 1); return this; }; /** * Adds the specified number of seconds to this instance. * @param {Number} The number of seconds to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addSeconds = function (value) { if (!value) { return this; } return this.addMilliseconds(value * 1000); }; /** * Adds the specified number of seconds to this instance. * @param {Number} The number of seconds to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addMinutes = function (value) { if (!value) { return this; } return this.addMilliseconds(value * 60000); // 60*1000 }; /** * Adds the specified number of hours to this instance. * @param {Number} The number of hours to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addHours = function (value) { if (!value) { return this; } return this.addMilliseconds(value * 3600000); // 60*60*1000 }; /** * Adds the specified number of days to this instance. * @param {Number} The number of days to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addDays = function (value) { if (!value) { return this; } this.setDate(this.getDate() + value * 1); return this; }; /** * Adds the specified number of weekdays (ie - not sat or sun) to this instance. * @param {Number} The number of days to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addWeekdays = function (value) { if (!value) { return this; } var day = this.getDay(); var weeks = (Math.ceil(Math.abs(value)/7)); if (day === 0 || day === 6) { if (value > 0) { this.next().monday(); this.addDays(-1); day = this.getDay(); } } if (value < 0) { while (value < 0) { this.addDays(-1); day = this.getDay(); if (day !== 0 && day !== 6) { value++; } } return this; } else if (value > 5 || (6-day) <= value) { value = value + (weeks * 2); } return this.addDays(value); }; /** * Adds the specified number of weeks to this instance. * @param {Number} The number of weeks to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addWeeks = function (value) { if (!value) { return this; } return this.addDays(value * 7); }; /** * Adds the specified number of months to this instance. * @param {Number} The number of months to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addMonths = function (value) { if (!value) { return this; } var n = this.getDate(); this.setDate(1); this.setMonth(this.getMonth() + value * 1); this.setDate(Math.min(n, $D.getDaysInMonth(this.getFullYear(), this.getMonth()))); return this; }; $P.addQuarters = function (value) { if (!value) { return this; } // note this will take you to the same point in the quarter as you are now. // i.e. - if you are 15 days into the quarter you'll be 15 days into the resulting one. // bonus: this allows adding fractional quarters return this.addMonths(value * 3); }; /** * Adds the specified number of years to this instance. * @param {Number} The number of years to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addYears = function (value) { if (!value) { return this; } return this.addMonths(value * 12); }; /** * Adds (or subtracts) to the value of the years, months, weeks, days, hours, minutes, seconds, milliseconds of the date instance using given configuration object. Positive and Negative values allowed. * Example

	Date.today().add( { days: 1, months: 1 } )

	new Date().add( { years: -1 } )
	
* @param {Object} Configuration object containing attributes (months, days, etc.) * @return {Date} this */ $P.add = function (config) { if (typeof config === "number") { this._orient = config; return this; } var x = config; if (x.day) { // If we should be a different date than today (eg: for 'tomorrow -1d', etc). // Should only effect parsing, not direct usage (eg, Finish and FinishExact) if ((x.day - this.getDate()) !== 0) { this.setDate(x.day); } } if (x.milliseconds) { this.addMilliseconds(x.milliseconds); } if (x.seconds) { this.addSeconds(x.seconds); } if (x.minutes) { this.addMinutes(x.minutes); } if (x.hours) { this.addHours(x.hours); } if (x.weeks) { this.addWeeks(x.weeks); } if (x.months) { this.addMonths(x.months); } if (x.years) { this.addYears(x.years); } if (x.days) { this.addDays(x.days); } return this; }; /** * Get the week number. Week one (1) is the week which contains the first Thursday of the year. Monday is considered the first day of the week. * The .getWeek() function does NOT convert the date to UTC. The local datetime is used. * Please use .getISOWeek() to get the week of the UTC converted date. * @return {Number} 1 to 53 */ $P.getWeek = function (utc) { // Create a copy of this date object var self, target = new Date(this.valueOf()); if (utc) { target.addMinutes(target.getTimezoneOffset()); self = target.clone(); } else { self = this; } // ISO week date weeks start on monday // so correct the day number var dayNr = (self.getDay() + 6) % 7; // ISO 8601 states that week 1 is the week // with the first thursday of that year. // Set the target date to the thursday in the target week target.setDate(target.getDate() - dayNr + 3); // Store the millisecond value of the target date var firstThursday = target.valueOf(); // Set the target to the first thursday of the year // First set the target to january first target.setMonth(0, 1); // Not a thursday? Correct the date to the next thursday if (target.getDay() !== 4) { target.setMonth(0, 1 + ((4 - target.getDay()) + 7) % 7); } // The weeknumber is the number of weeks between the // first thursday of the year and the thursday in the target week return 1 + Math.ceil((firstThursday - target) / 604800000); // 604800000 = 7 * 24 * 3600 * 1000 }; /** * Get the ISO 8601 week number. Week one ("01") is the week which contains the first Thursday of the year. Monday is considered the first day of the week. * The .getISOWeek() function does convert the date to it's UTC value. Please use .getWeek() to get the week of the local date. * @return {String} "01" to "53" */ $P.getISOWeek = function () { return p(this.getWeek(true)); }; /** * Moves the date to Monday of the week set. Week one (1) is the week which contains the first Thursday of the year. * @param {Number} A Number (1 to 53) that represents the week of the year. * @return {Date} this */ $P.setWeek = function (n) { if ((n - this.getWeek()) === 0) { if (this.getDay() !== 1) { return this.moveToDayOfWeek(1, (this.getDay() > 1 ? -1 : 1)); } else { return this; } } else { return this.moveToDayOfWeek(1, (this.getDay() > 1 ? -1 : 1)).addWeeks(n - this.getWeek()); } }; $P.setQuarter = function (qtr) { var month = Math.abs(((qtr-1) * 3) + 1); return this.setMonth(month, 1); }; $P.getQuarter = function () { return Date.getQuarter(this); }; $P.getDaysLeftInQuarter = function () { return Date.getDaysLeftInQuarter(this); }; /** * Moves the date to the next n'th occurrence of the dayOfWeek starting from the beginning of the month. The number (-1) is a magic number and will return the last occurrence of the dayOfWeek in the month. * @param {Number} The dayOfWeek to move to * @param {Number} The n'th occurrence to move to. Use (-1) to return the last occurrence in the month * @return {Date} this */ $P.moveToNthOccurrence = function (dayOfWeek, occurrence) { if (dayOfWeek === "Weekday") { if (occurrence > 0) { this.moveToFirstDayOfMonth(); if (this.is().weekday()) { occurrence -= 1; } } else if (occurrence < 0) { this.moveToLastDayOfMonth(); if (this.is().weekday()) { occurrence += 1; } } else { return this; } return this.addWeekdays(occurrence); } var shift = 0; if (occurrence > 0) { shift = occurrence - 1; } else if (occurrence === -1) { this.moveToLastDayOfMonth(); if (this.getDay() !== dayOfWeek) { this.moveToDayOfWeek(dayOfWeek, -1); } return this; } return this.moveToFirstDayOfMonth().addDays(-1).moveToDayOfWeek(dayOfWeek, +1).addWeeks(shift); }; var moveToN = function (getFunc, addFunc, nVal) { return function (value, orient) { var diff = (value - this[getFunc]() + nVal * (orient || +1)) % nVal; return this[addFunc]((diff === 0) ? diff += nVal * (orient || +1) : diff); }; }; /** * Move to the next or last dayOfWeek based on the orient value. * @param {Number} The dayOfWeek to move to * @param {Number} Forward (+1) or Back (-1). Defaults to +1. [Optional] * @return {Date} this */ $P.moveToDayOfWeek = moveToN("getDay", "addDays", 7); /** * Move to the next or last month based on the orient value. * @param {Number} The month to move to. 0 = January, 11 = December * @param {Number} Forward (+1) or Back (-1). Defaults to +1. [Optional] * @return {Date} this */ $P.moveToMonth = moveToN("getMonth", "addMonths", 12); /** * Get the Ordinate of the current day ("th", "st", "rd"). * @return {String} */ $P.getOrdinate = function () { var num = this.getDate(); return ord(num); }; /** * Get the Ordinal day (numeric day number) of the year, adjusted for leap year. * @return {Number} 1 through 365 (366 in leap years) */ $P.getOrdinalNumber = function () { return Math.ceil((this.clone().clearTime() - new Date(this.getFullYear(), 0, 1)) / 86400000) + 1; }; /** * Get the time zone abbreviation of the current date. * @return {String} The abbreviated time zone name (e.g. "EST") */ $P.getTimezone = function () { return $D.getTimezoneAbbreviation(this.getUTCOffset(), this.isDaylightSavingTime()); }; $P.setTimezoneOffset = function (offset) { var here = this.getTimezoneOffset(), there = Number(offset) * -6 / 10; return (there || there === 0) ? this.addMinutes(there - here) : this; }; $P.setTimezone = function (offset) { return this.setTimezoneOffset($D.getTimezoneOffset(offset)); }; /** * Indicates whether Daylight Saving Time is observed in the current time zone. * @return {Boolean} true|false */ $P.hasDaylightSavingTime = function () { return (Date.today().set({month: 0, day: 1}).getTimezoneOffset() !== Date.today().set({month: 6, day: 1}).getTimezoneOffset()); }; /** * Indicates whether this Date instance is within the Daylight Saving Time range for the current time zone. * @return {Boolean} true|false */ $P.isDaylightSavingTime = function () { return Date.today().set({month: 0, day: 1}).getTimezoneOffset() !== this.getTimezoneOffset(); }; /** * Get the offset from UTC of the current date. * @return {String} The 4-character offset string prefixed with + or - (e.g. "-0500") */ $P.getUTCOffset = function (offset) { var n = (offset || this.getTimezoneOffset()) * -10 / 6, r; if (n < 0) { r = (n - 10000).toString(); return r.charAt(0) + r.substr(2); } else { r = (n + 10000).toString(); return "+" + r.substr(1); } }; /** * Returns the number of milliseconds between this date and date. * @param {Date} Defaults to now * @return {Number} The diff in milliseconds */ $P.getElapsed = function (date) { return (date || new Date()) - this; }; /** * Set the value of year, month, day, hour, minute, second, millisecond of date instance using given configuration object. * Example

	Date.today().set( { day: 20, month: 1 } )

	new Date().set( { millisecond: 0 } )
	
* * @param {Object} Configuration object containing attributes (month, day, etc.) * @return {Date} this */ $P.set = function (config) { config = validateConfigObject.call(this, config); var key; for (key in config) { if (Object.prototype.hasOwnProperty.call(config, key)) { var name = key.charAt(0).toUpperCase() + key.slice(1); var addFunc, getFunc; if (key !== "week" && key !== "month" && key !== "timezone" && key !== "timezoneOffset") { name += "s"; } addFunc = "add" + name; getFunc = "get" + name; if (key === "month") { addFunc = addFunc + "s"; } else if (key === "year"){ getFunc = "getFullYear"; } if (key !== "day" && key !== "timezone" && key !== "timezoneOffset" && key !== "week" && key !== "hour") { this[addFunc](config[key] - this[getFunc]()); } else if ( key === "timezone"|| key === "timezoneOffset" || key === "week" || key === "hour") { this["set"+name](config[key]); } } } // day has to go last because you can't validate the day without first knowing the month if (config.day) { this.addDays(config.day - this.getDate()); } return this; }; /** * Moves the date to the first day of the month. * @return {Date} this */ $P.moveToFirstDayOfMonth = function () { return this.set({ day: 1 }); }; /** * Moves the date to the last day of the month. * @return {Date} this */ $P.moveToLastDayOfMonth = function () { return this.set({ day: $D.getDaysInMonth(this.getFullYear(), this.getMonth())}); }; /** * Converts the value of the current Date object to its equivalent string representation. * Format Specifiers * CUSTOM DATE AND TIME FORMAT STRINGS * Format Description Example * ------ --------------------------------------------------------------------------- ----------------------- * s The seconds of the minute between 0-59. "0" to "59" * ss The seconds of the minute with leading zero if required. "00" to "59" * * m The minute of the hour between 0-59. "0" or "59" * mm The minute of the hour with leading zero if required. "00" or "59" * * h The hour of the day between 1-12. "1" to "12" * hh The hour of the day with leading zero if required. "01" to "12" * * H The hour of the day between 0-23. "0" to "23" * HH The hour of the day with leading zero if required. "00" to "23" * * d The day of the month between 1 and 31. "1" to "31" * dd The day of the month with leading zero if required. "01" to "31" * ddd Abbreviated day name. Date.CultureInfo.abbreviatedDayNames. "Mon" to "Sun" * dddd The full day name. Date.CultureInfo.dayNames. "Monday" to "Sunday" * * M The month of the year between 1-12. "1" to "12" * MM The month of the year with leading zero if required. "01" to "12" * MMM Abbreviated month name. Date.CultureInfo.abbreviatedMonthNames. "Jan" to "Dec" * MMMM The full month name. Date.CultureInfo.monthNames. "January" to "December" * * yy The year as a two-digit number. "99" or "08" * yyyy The full four digit year. "1999" or "2008" * * t Displays the first character of the A.M./P.M. designator. "A" or "P" * Date.CultureInfo.amDesignator or Date.CultureInfo.pmDesignator * tt Displays the A.M./P.M. designator. "AM" or "PM" * Date.CultureInfo.amDesignator or Date.CultureInfo.pmDesignator * * S The ordinal suffix ("st, "nd", "rd" or "th") of the current day. "st, "nd", "rd" or "th" * * STANDARD DATE AND TIME FORMAT STRINGS * Format Description Example *------ --------------------------------------------------------------------------- ----------------------- * d The CultureInfo shortDate Format Pattern "M/d/yyyy" * D The CultureInfo longDate Format Pattern "dddd, MMMM dd, yyyy" * F The CultureInfo fullDateTime Format Pattern "dddd, MMMM dd, yyyy h:mm:ss tt" * m The CultureInfo monthDay Format Pattern "MMMM dd" * r The CultureInfo rfc1123 Format Pattern "ddd, dd MMM yyyy HH:mm:ss GMT" * s The CultureInfo sortableDateTime Format Pattern "yyyy-MM-ddTHH:mm:ss" * t The CultureInfo shortTime Format Pattern "h:mm tt" * T The CultureInfo longTime Format Pattern "h:mm:ss tt" * u The CultureInfo universalSortableDateTime Format Pattern "yyyy-MM-dd HH:mm:ssZ" * y The CultureInfo yearMonth Format Pattern "MMMM, yyyy" * * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @return {String} A string representation of the current Date object. */ var ord = function (n) { switch (n * 1) { case 1: case 21: case 31: return "st"; case 2: case 22: return "nd"; case 3: case 23: return "rd"; default: return "th"; } }; var parseStandardFormats = function (format) { var y, c = Date.CultureInfo.formatPatterns; switch (format) { case "d": return this.toString(c.shortDate); case "D": return this.toString(c.longDate); case "F": return this.toString(c.fullDateTime); case "m": return this.toString(c.monthDay); case "r": case "R": y = this.clone().addMinutes(this.getTimezoneOffset()); return y.toString(c.rfc1123) + " GMT"; case "s": return this.toString(c.sortableDateTime); case "t": return this.toString(c.shortTime); case "T": return this.toString(c.longTime); case "u": y = this.clone().addMinutes(this.getTimezoneOffset()); return y.toString(c.universalSortableDateTime); case "y": return this.toString(c.yearMonth); default: return false; } }; var parseFormatStringsClosure = function (context) { return function (m) { if (m.charAt(0) === "\\") { return m.replace("\\", ""); } switch (m) { case "hh": return p(context.getHours() < 13 ? (context.getHours() === 0 ? 12 : context.getHours()) : (context.getHours() - 12)); case "h": return context.getHours() < 13 ? (context.getHours() === 0 ? 12 : context.getHours()) : (context.getHours() - 12); case "HH": return p(context.getHours()); case "H": return context.getHours(); case "mm": return p(context.getMinutes()); case "m": return context.getMinutes(); case "ss": return p(context.getSeconds()); case "s": return context.getSeconds(); case "yyyy": return p(context.getFullYear(), 4); case "yy": return p(context.getFullYear()); case "y": return context.getFullYear(); case "E": case "dddd": return Date.CultureInfo.dayNames[context.getDay()]; case "ddd": return Date.CultureInfo.abbreviatedDayNames[context.getDay()]; case "dd": return p(context.getDate()); case "d": return context.getDate(); case "MMMM": return Date.CultureInfo.monthNames[context.getMonth()]; case "MMM": return Date.CultureInfo.abbreviatedMonthNames[context.getMonth()]; case "MM": return p((context.getMonth() + 1)); case "M": return context.getMonth() + 1; case "t": return context.getHours() < 12 ? Date.CultureInfo.amDesignator.substring(0, 1) : Date.CultureInfo.pmDesignator.substring(0, 1); case "tt": return context.getHours() < 12 ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator; case "S": return ord(context.getDate()); case "W": return context.getWeek(); case "WW": return context.getISOWeek(); case "Q": return "Q" + context.getQuarter(); case "q": return String(context.getQuarter()); case "z": return context.getTimezone(); case "Z": case "X": return Date.getTimezoneOffset(context.getTimezone()); case "ZZ": // Timezone offset in seconds return context.getTimezoneOffset() * -60; case "u": return context.getDay(); case "L": return ($D.isLeapYear(context.getFullYear())) ? 1 : 0; case "B": // Swatch Internet Time (.beats) return "@"+((context.getUTCSeconds() + (context.getUTCMinutes()*60) + ((context.getUTCHours()+1)*3600))/86.4); default: return m; } }; }; $P.toString = function (format, ignoreStandards) { // Standard Date and Time Format Strings. Formats pulled from CultureInfo file and // may vary by culture. if (!ignoreStandards && format && format.length === 1) { output = parseStandardFormats.call(this, format); if (output) { return output; } } var parseFormatStrings = parseFormatStringsClosure(this); return format ? format.replace(/((\\)?(dd?d?d?|MM?M?M?|yy?y?y?|hh?|HH?|mm?|ss?|tt?|S|q|Q|WW?W?W?)(?![^\[]*\]))/g, parseFormatStrings).replace(/\[|\]/g, "") : this._toString(); }; }()); /************************************************************* * SugarPak - Domain Specific Language - Syntactical Sugar * *************************************************************/ (function () { var $D = Date, $P = $D.prototype, $N = Number.prototype; // private $P._orient = +1; // private $P._nth = null; // private $P._is = false; // private $P._same = false; // private $P._isSecond = false; // private $N._dateElement = "days"; /** * Moves the date to the next instance of a date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.today().next().friday();
	Date.today().next().fri();
	Date.today().next().march();
	Date.today().next().mar();
	Date.today().next().week();
	
* * @return {Date} date */ $P.next = function () { this._move = true; this._orient = +1; return this; }; /** * Creates a new Date (Date.today()) and moves the date to the next instance of the date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.next().friday();
	Date.next().fri();
	Date.next().march();
	Date.next().mar();
	Date.next().week();
	
* * @return {Date} date */ $D.next = function () { return $D.today().next(); }; /** * Moves the date to the previous instance of a date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.today().last().friday();
	Date.today().last().fri();
	Date.today().last().march();
	Date.today().last().mar();
	Date.today().last().week();
	
* * @return {Date} date */ $P.last = $P.prev = $P.previous = function () { this._move = true; this._orient = -1; return this; }; /** * Creates a new Date (Date.today()) and moves the date to the previous instance of the date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.last().friday();
	Date.last().fri();
	Date.previous().march();
	Date.prev().mar();
	Date.last().week();
	
* * @return {Date} date */ $D.last = $D.prev = $D.previous = function () { return $D.today().last(); }; /** * Performs a equality check when followed by either a month name, day name or .weekday() function. * Example

	Date.today().is().friday(); // true|false
	Date.today().is().fri();
	Date.today().is().march();
	Date.today().is().mar();
	
* * @return {Boolean} true|false */ $P.is = function () { this._is = true; return this; }; /** * Determines if two date objects occur on/in exactly the same instance of the subsequent date part function. * The function .same() must be followed by a date part function (example: .day(), .month(), .year(), etc). * * An optional Date can be passed in the date part function. If now date is passed as a parameter, 'Now' is used. * * The following example demonstrates how to determine if two dates fall on the exact same day. * * Example

	var d1 = Date.today(); // today at 00:00
	var d2 = new Date();   // exactly now.

	// Do they occur on the same day?
	d1.same().day(d2); // true
	
	// Do they occur on the same hour?
	d1.same().hour(d2); // false, unless d2 hour is '00' (midnight).
	
	// What if it's the same day, but one year apart?
	var nextYear = Date.today().add(1).year();

	d1.same().day(nextYear); // false, because the dates must occur on the exact same day. 
	
* * Scenario: Determine if a given date occurs during some week period 2 months from now. * * Example

	var future = Date.today().add(2).months();
	return someDate.same().week(future); // true|false;
	
* * @return {Boolean} true|false */ $P.same = function () { this._same = true; this._isSecond = false; return this; }; /** * Determines if the current date/time occurs during Today. Must be preceded by the .is() function. * Example

	someDate.is().today();    // true|false
	new Date().is().today();  // true
	Date.today().is().today();// true
	Date.today().add(-1).day().is().today(); // false
	
* * @return {Boolean} true|false */ $P.today = function () { return this.same().day(); }; /** * Determines if the current date is a weekday. This function must be preceded by the .is() function. * Example

	Date.today().is().weekday(); // true|false
	
* * @return {Boolean} true|false */ $P.weekday = function () { if (this._nth) { return df("Weekday").call(this); } if (this._move) { return this.addWeekdays(this._orient); } if (this._is) { this._is = false; return (!this.is().sat() && !this.is().sun()); } return false; }; /** * Determines if the current date is on the weekend. This function must be preceded by the .is() function. * Example

	Date.today().is().weekend(); // true|false
	
* * @return {Boolean} true|false */ $P.weekend = function () { if (this._is) { this._is = false; return (this.is().sat() || this.is().sun()); } return false; }; /** * Sets the Time of the current Date instance. A string "6:15 pm" or config object {hour:18, minute:15} are accepted. * Example

	// Set time to 6:15pm with a String
	Date.today().at("6:15pm");

	// Set time to 6:15pm with a config object
	Date.today().at({hour:18, minute:15});
	
* * @return {Date} date */ $P.at = function (time) { return (typeof time === "string") ? $D.parse(this.toString("d") + " " + time) : this.set(time); }; /** * Creates a new Date() and adds this (Number) to the date based on the preceding date element function (eg. second|minute|hour|day|month|year). * Example

	// Undeclared Numbers must be wrapped with parentheses. Requirment of JavaScript.
	(3).days().fromNow();
	(6).months().fromNow();

	// Declared Number variables do not require parentheses. 
	var n = 6;
	n.months().fromNow();
	
* * @return {Date} A new Date instance */ $N.fromNow = $N.after = function (date) { var c = {}; c[this._dateElement] = this; return ((!date) ? new Date() : date.clone()).add(c); }; /** * Creates a new Date() and subtract this (Number) from the date based on the preceding date element function (eg. second|minute|hour|day|month|year). * Example

	// Undeclared Numbers must be wrapped with parentheses. Requirment of JavaScript.
	(3).days().ago();
	(6).months().ago();

	// Declared Number variables do not require parentheses. 
	var n = 6;
	n.months().ago();
	
* * @return {Date} A new Date instance */ $N.ago = $N.before = function (date) { var c = {}, s = (this._dateElement[this._dateElement.length-1] !== "s") ? this._dateElement + "s" : this._dateElement; c[s] = this * -1; return ((!date) ? new Date() : date.clone()).add(c); }; // Do NOT modify the following string tokens. These tokens are used to build dynamic functions. // All culture-specific strings can be found in the CultureInfo files. var dx = ("sunday monday tuesday wednesday thursday friday saturday").split(/\s/), mx = ("january february march april may june july august september october november december").split(/\s/), px = ("Millisecond Second Minute Hour Day Week Month Year Quarter Weekday").split(/\s/), pxf = ("Milliseconds Seconds Minutes Hours Date Week Month FullYear Quarter").split(/\s/), nth = ("final first second third fourth fifth").split(/\s/), de; /** * Returns an object literal of all the date parts. * Example

	var o = new Date().toObject();
	
	// { year: 2008, month: 4, week: 20, day: 13, hour: 18, minute: 9, second: 32, millisecond: 812 }
	
	// The object properties can be referenced directly from the object.
	
	alert(o.day);  // alerts "13"
	alert(o.year); // alerts "2008"
	
* * @return {Date} An object literal representing the original date object. */ $P.toObject = function () { var o = {}; for (var i = 0; i < px.length; i++) { if (this["get" + pxf[i]]) { o[px[i].toLowerCase()] = this["get" + pxf[i]](); } } return o; }; /** * Returns a date created from an object literal. Ignores the .week property if set in the config. * Example

	var o = new Date().toObject();
	
	return Date.fromObject(o); // will return the same date. 

	var o2 = {month: 1, day: 20, hour: 18}; // birthday party!
	Date.fromObject(o2);
	
* * @return {Date} An object literal representing the original date object. */ $D.fromObject = function(config) { config.week = null; return Date.today().set(config); }; // Create day name functions and abbreviated day name functions (eg. monday(), friday(), fri()). var df = function (n) { return function () { if (this._is) { this._is = false; return this.getDay() === n; } if (this._move) { this._move = null; } if (this._nth !== null) { // If the .second() function was called earlier, remove the _orient // from the date, and then continue. // This is required because 'second' can be used in two different context. // // Example // // Date.today().add(1).second(); // Date.march().second().monday(); // // Things get crazy with the following... // Date.march().add(1).second().second().monday(); // but it works!! // if (this._isSecond) { this.addSeconds(this._orient * -1); } // make sure we reset _isSecond this._isSecond = false; var ntemp = this._nth; this._nth = null; var temp = this.clone().moveToLastDayOfMonth(); this.moveToNthOccurrence(n, ntemp); if (this > temp) { throw new RangeError($D.getDayName(n) + " does not occur " + ntemp + " times in the month of " + $D.getMonthName(temp.getMonth()) + " " + temp.getFullYear() + "."); } return this; } return this.moveToDayOfWeek(n, this._orient); }; }; var sdf = function (n) { return function () { var t = $D.today(), shift = n - t.getDay(); if (n === 0 && Date.CultureInfo.firstDayOfWeek === 1 && t.getDay() !== 0) { shift = shift + 7; } return t.addDays(shift); }; }; // Create month name functions and abbreviated month name functions (eg. january(), march(), mar()). var month_instance_functions = function (n) { return function () { if (this._is) { this._is = false; return this.getMonth() === n; } return this.moveToMonth(n, this._orient); }; }; var month_static_functions = function (n) { return function () { return $D.today().set({ month: n, day: 1 }); }; }; var processTerms = function (names, staticFunc, instanceFunc) { for (var i = 0; i < names.length; i++) { // Create constant static Name variables. $D[names[i].toUpperCase()] = $D[names[i].toUpperCase().substring(0, 3)] = i; // Create Name functions. $D[names[i]] = $D[names[i].substring(0, 3)] = staticFunc(i); // Create Name instance functions. $P[names[i]] = $P[names[i].substring(0, 3)] = instanceFunc(i); } }; processTerms(dx, sdf, df); processTerms(mx, month_static_functions, month_instance_functions); // Create date element functions and plural date element functions used with Date (eg. day(), days(), months()). var ef = function (j) { return function () { // if the .second() function was called earlier, the _orient // has alread been added. Just return this and reset _isSecond. if (this._isSecond) { this._isSecond = false; return this; } if (this._same) { this._same = this._is = false; var o1 = this.toObject(), o2 = (arguments[0] || new Date()).toObject(), v = "", k = j.toLowerCase(); // the substr trick with -1 doesn't work in IE8 or less k = (k[k.length-1] === "s") ? k.substring(0,k.length-1) : k; for (var m = (px.length - 1); m > -1; m--) { v = px[m].toLowerCase(); if (o1[v] !== o2[v]) { return false; } if (k === v) { break; } } return true; } if (j.substring(j.length - 1) !== "s") { j += "s"; } if (this._move) { this._move = null; } return this["add" + j](this._orient); }; }; var nf = function (n) { return function () { this._dateElement = n; return this; }; }; for (var k = 0; k < px.length; k++) { de = px[k].toLowerCase(); if(de !== "weekday") { // Create date element functions and plural date element functions used with Date (eg. day(), days(), months()). $P[de] = $P[de + "s"] = ef(px[k]); // Create date element functions and plural date element functions used with Number (eg. day(), days(), months()). $N[de] = $N[de + "s"] = nf(de + "s"); } } $P._ss = ef("Second"); var nthfn = function (n) { return function (dayOfWeek) { if (this._same) { return this._ss(arguments[0]); } if (dayOfWeek || dayOfWeek === 0) { return this.moveToNthOccurrence(dayOfWeek, n); } this._nth = n; // if the operator is 'second' add the _orient, then deal with it later... if (n === 2 && (dayOfWeek === undefined || dayOfWeek === null)) { this._isSecond = true; return this.addSeconds(this._orient); } return this; }; }; for (var l = 0; l < nth.length; l++) { $P[nth[l]] = (l === 0) ? nthfn(-1) : nthfn(l); } }()); (function () { "use strict"; Date.Parsing = { Exception: function (s) { this.message = "Parse error at '" + s.substring(0, 10) + " ...'"; } }; var $P = Date.Parsing; var dayOffsets = { standard: [0,31,59,90,120,151,181,212,243,273,304,334], leap: [0,31,60,91,121,152,182,213,244,274,305,335] }; $P.isLeapYear = function(year) { return ((year % 4 === 0) && (year % 100 !== 0)) || (year % 400 === 0); }; var utils = { multiReplace : function (str, hash ) { var key; for (key in hash) { if (Object.prototype.hasOwnProperty.call(hash, key)) { var regex; if (typeof hash[key] === "function") { } else { regex = (hash[key] instanceof RegExp) ? hash[key] : new RegExp(hash[key], "g"); } str = str.replace(regex, key); } } return str; }, getDayOfYearFromWeek : function (obj) { var d, jan4, offset; obj.weekDay = (!obj.weekDay && obj.weekDay !== 0) ? 1 : obj.weekDay; d = new Date(obj.year, 0, 4); jan4 = d.getDay() === 0 ? 7 : d.getDay(); // JS is 0 indexed on Sunday. offset = jan4+3; obj.dayOfYear = ((obj.week * 7) + (obj.weekDay === 0 ? 7 : obj.weekDay))-offset; return obj; }, getDayOfYear : function (obj, dayOffset) { if (!obj.dayOfYear) { obj = utils.getDayOfYearFromWeek(obj); } for (var i=0;i <= dayOffset.length;i++) { if (obj.dayOfYear < dayOffset[i] || i === dayOffset.length) { obj.day = obj.day ? obj.day : (obj.dayOfYear - dayOffset[i-1]); break; } else { obj.month = i; } } return obj; }, adjustForTimeZone : function (obj, date) { var offset; if (obj.zone.toUpperCase() === "Z" || (obj.zone_hours === 0 && obj.zone_minutes === 0)) { // it's UTC/GML so work out the current timeszone offset offset = -date.getTimezoneOffset(); } else { offset = (obj.zone_hours*60) + (obj.zone_minutes || 0); if (obj.zone_sign === "+") { offset *= -1; } offset -= date.getTimezoneOffset(); } date.setMinutes(date.getMinutes()+offset); return date; }, setDefaults : function (obj) { obj.year = obj.year || Date.today().getFullYear(); obj.hours = obj.hours || 0; obj.minutes = obj.minutes || 0; obj.seconds = obj.seconds || 0; obj.milliseconds = obj.milliseconds || 0; if (!(!obj.month && (obj.week || obj.dayOfYear))) { // if we have a month, or if we don't but don't have the day calculation data obj.month = obj.month || 0; obj.day = obj.day || 1; } return obj; }, dataNum: function (data, mod, explict, postProcess) { var dataNum = data*1; if (mod) { if (postProcess) { return data ? mod(data)*1 : data; } else { return data ? mod(dataNum) : data; } } else if (!explict){ return data ? dataNum : data; } else { return (data && typeof data !== "undefined") ? dataNum : data; } }, timeDataProcess: function (obj) { var timeObj = {}; for (var x in obj.data) { if (obj.data.hasOwnProperty(x)) { timeObj[x] = obj.ignore[x] ? obj.data[x] : utils.dataNum(obj.data[x], obj.mods[x], obj.explict[x], obj.postProcess[x]); } } if (obj.data.secmins) { obj.data.secmins = obj.data.secmins.replace(",", ".") * 60; if (!timeObj.minutes) { timeObj.minutes = obj.data.secmins; } else if (!timeObj.seconds) { timeObj.seconds = obj.data.secmins; } delete obj.secmins; } return timeObj; }, buildTimeObjectFromData: function (data) { var time = utils.timeDataProcess({ data: { year : data[1], month : data[5], day : data[7], week : data[8], dayOfYear : data[10], hours : data[15], zone_hours : data[23], zone_minutes : data[24], zone : data[21], zone_sign : data[22], weekDay : data[9], minutes: data[16], seconds: data[19], milliseconds: data[20], secmins: data[18] }, mods: { month: function(data) { return data-1; }, weekDay: function (data) { data = Math.abs(data); return (data === 7 ? 0 : data); }, minutes: function (data) { return data.replace(":",""); }, seconds: function (data) { return Math.floor( (data.replace(":","").replace(",","."))*1 ); }, milliseconds: function (data) { return (data.replace(",",".")*1000); } }, postProcess: { minutes: true, seconds: true, milliseconds: true }, explict: { zone_hours: true, zone_minutes: true }, ignore: { zone: true, zone_sign: true, secmins: true } }); return time; }, addToHash: function (hash, keys, data) { keys = keys; data = data; var len = keys.length; for (var i = 0; i < len; i++) { hash[keys[i]] = data[i]; } return hash; }, combineRegex: function (r1, r2) { return new RegExp("(("+r1.source+")\\s("+r2.source+"))"); }, getDateNthString: function(add, last, inc){ if (add) { return Date.today().addDays(inc).toString("d"); } else if (last) { return Date.today().last()[inc]().toString("d"); } }, buildRegexData: function (array) { var arr = []; var len = array.length; for (var i=0; i < len; i++) { if (Object.prototype.toString.call(array[i]) === '[object Array]') { // oldIE compat version of Array.isArray arr.push(this.combineRegex(array[i][0], array[i][1])); } else { arr.push(array[i]); } } return arr; } }; $P.processTimeObject = function (obj) { var date, dayOffset; utils.setDefaults(obj); dayOffset = ($P.isLeapYear(obj.year)) ? dayOffsets.leap : dayOffsets.standard; if (!obj.month && (obj.week || obj.dayOfYear)) { utils.getDayOfYear(obj, dayOffset); } else { obj.dayOfYear = dayOffset[obj.month] + obj.day; } date = new Date(obj.year, obj.month, obj.day, obj.hours, obj.minutes, obj.seconds, obj.milliseconds); if (obj.zone) { utils.adjustForTimeZone(obj, date); // adjust (and calculate) for timezone } return date; }; $P.ISO = { regex : /^([\+-]?\d{4}(?!\d{2}\b))((-?)((0[1-9]|1[0-2])(\3([12]\d|0[1-9]|3[01]))?|W([0-4]\d|5[0-3])(-?[1-7])?|(00[1-9]|0[1-9]\d|[12]\d{2}|3([0-5]\d|6[1-6])))([T\s]((([01]\d|2[0-4])((:?)[0-5]\d)?|24\:?00)([\.,]\d+(?!:))?)?(\17[0-5]\d([\.,]\d+)?)?\s?([zZ]|([\+-])([01]\d|2[0-3]):?([0-5]\d)?)?)?)?$/, parse : function (s) { var time, data = s.match(this.regex); if (!data || !data.length) { return null; } time = utils.buildTimeObjectFromData(data); if (!time.year || (!time.year && (!time.month && !time.day) && (!time.week && !time.dayOfYear)) ) { return null; } return $P.processTimeObject(time); } }; $P.Numeric = { isNumeric: function (e){return!isNaN(parseFloat(e))&&isFinite(e);}, regex: /\b([0-1]?[0-9])([0-3]?[0-9])([0-2]?[0-9]?[0-9][0-9])\b/i, parse: function (s) { var data, i, time = {}, order = Date.CultureInfo.dateElementOrder.split(""); if (!(this.isNumeric(s)) || // if it's non-numeric OR (s[0] === "+" && s[0] === "-")) { // It's an arithmatic string (eg +/-1000) return null; } if (s.length < 5 && s.indexOf(".") < 0 && s.indexOf("/") < 0) { // assume it's just a year. time.year = s; return $P.processTimeObject(time); } data = s.match(this.regex); if (!data || !data.length) { return null; } for (i=0; i < order.length; i++) { switch(order[i]) { case "d": time.day = data[i+1]; break; case "m": time.month = (data[i+1]-1); break; case "y": time.year = data[i+1]; break; } } return $P.processTimeObject(time); } }; $P.Normalizer = { regexData: function () { var $R = Date.CultureInfo.regexPatterns; return utils.buildRegexData([ $R.tomorrow, $R.yesterday, [$R.past, $R.mon], [$R.past, $R.tue], [$R.past, $R.wed], [$R.past, $R.thu], [$R.past, $R.fri], [$R.past, $R.sat], [$R.past, $R.sun] ]); }, basicReplaceHash : function() { var $R = Date.CultureInfo.regexPatterns; return { "January": $R.jan.source, "February": $R.feb, "March": $R.mar, "April": $R.apr, "May": $R.may, "June": $R.jun, "July": $R.jul, "August": $R.aug, "September": $R.sep, "October": $R.oct, "November": $R.nov, "December": $R.dec, "": /\bat\b/gi, " ": /\s{2,}/, "am": $R.inTheMorning, "9am": $R.thisMorning, "pm": $R.inTheEvening, "7pm":$R.thisEvening }; }, keys : function(){ return [ utils.getDateNthString(true, false, 1), // tomorrow utils.getDateNthString(true, false, -1), // yesterday utils.getDateNthString(false, true, "monday"), //last mon utils.getDateNthString(false, true, "tuesday"), //last tues utils.getDateNthString(false, true, "wednesday"), //last wed utils.getDateNthString(false, true, "thursday"), //last thurs utils.getDateNthString(false, true, "friday"), //last fri utils.getDateNthString(false, true, "saturday"), //last sat utils.getDateNthString(false, true, "sunday") //last sun ]; }, buildRegexFunctions: function () { var $R = Date.CultureInfo.regexPatterns; var __ = Date.i18n.__; var tomorrowRE = new RegExp("(\\b\\d\\d?("+__("AM")+"|"+__("PM")+")? )("+$R.tomorrow.source.slice(1)+")", "i"); // adapted tomorrow regex for AM PM relative dates var todayRE = new RegExp($R.today.source + "(?!\\s*([+-]))\\b"); // today, but excludes the math operators (eg "today + 2h") this.replaceFuncs = [ [todayRE, function (full) { return (full.length > 1) ? Date.today().toString("d") : full; }], [tomorrowRE, function(full, m1) { var t = Date.today().addDays(1).toString("d"); return (t + " " + m1); }], [$R.amThisMorning, function(str, am){return am;}], [$R.pmThisEvening, function(str, pm){return pm;}] ]; }, buildReplaceData: function () { this.buildRegexFunctions(); this.replaceHash = utils.addToHash(this.basicReplaceHash(), this.keys(), this.regexData()); }, stringReplaceFuncs: function (s) { for (var i=0; i < this.replaceFuncs.length; i++) { s = s.replace(this.replaceFuncs[i][0], this.replaceFuncs[i][1]); } return s; }, parse: function (s) { s = this.stringReplaceFuncs(s); s = utils.multiReplace(s, this.replaceHash); try { var n = s.split(/([\s\-\.\,\/\x27]+)/); if (n.length === 3 && $P.Numeric.isNumeric(n[0]) && $P.Numeric.isNumeric(n[2]) && (n[2].length >= 4)) { // ok, so we're dealing with x/year. But that's not a full date. // This fixes wonky dateElementOrder parsing when set to dmy order. if (Date.CultureInfo.dateElementOrder[0] === "d") { s = "1/" + n[0] + "/" + n[2]; // set to 1st of month and normalize the seperator } } } catch (e) {} return s; } }; $P.Normalizer.buildReplaceData(); }()); (function () { var $P = Date.Parsing; var _ = $P.Operators = { // // Tokenizers // rtoken: function (r) { // regex token return function (s) { var mx = s.match(r); if (mx) { return ([ mx[0], s.substring(mx[0].length) ]); } else { throw new $P.Exception(s); } }; }, token: function () { // whitespace-eating token return function (s) { return _.rtoken(new RegExp("^\\s*" + s + "\\s*"))(s); }; }, stoken: function (s) { // string token return _.rtoken(new RegExp("^" + s)); }, // Atomic Operators until: function (p) { return function (s) { var qx = [], rx = null; while (s.length) { try { rx = p.call(this, s); } catch (e) { qx.push(rx[0]); s = rx[1]; continue; } break; } return [ qx, s ]; }; }, many: function (p) { return function (s) { var rx = [], r = null; while (s.length) { try { r = p.call(this, s); } catch (e) { return [ rx, s ]; } rx.push(r[0]); s = r[1]; } return [ rx, s ]; }; }, // generator operators -- see below optional: function (p) { return function (s) { var r = null; try { r = p.call(this, s); } catch (e) { return [ null, s ]; } return [ r[0], r[1] ]; }; }, not: function (p) { return function (s) { try { p.call(this, s); } catch (e) { return [null, s]; } throw new $P.Exception(s); }; }, ignore: function (p) { return p ? function (s) { var r = null; r = p.call(this, s); return [null, r[1]]; } : null; }, product: function () { var px = arguments[0], qx = Array.prototype.slice.call(arguments, 1), rx = []; for (var i = 0 ; i < px.length ; i++) { rx.push(_.each(px[i], qx)); } return rx; }, cache: function (rule) { var cache = {}, cache_length = 0, cache_keys = [], CACHE_MAX = Date.Config.CACHE_MAX || 100000, r = null; var cacheCheck = function () { if (cache_length === CACHE_MAX) { // kill several keys, don't want to have to do this all the time... for (var i=0; i < 10; i++) { var key = cache_keys.shift(); if (key) { delete cache[key]; cache_length--; } } } }; return function (s) { cacheCheck(); try { r = cache[s] = (cache[s] || rule.call(this, s)); } catch (e) { r = cache[s] = e; } cache_length++; cache_keys.push(s); if (r instanceof $P.Exception) { throw r; } else { return r; } }; }, // vector operators -- see below any: function () { var px = arguments; return function (s) { var r = null; for (var i = 0; i < px.length; i++) { if (px[i] == null) { continue; } try { r = (px[i].call(this, s)); } catch (e) { r = null; } if (r) { return r; } } throw new $P.Exception(s); }; }, each: function () { var px = arguments; return function (s) { var rx = [], r = null; for (var i = 0; i < px.length ; i++) { if (px[i] == null) { continue; } try { r = (px[i].call(this, s)); } catch (e) { throw new $P.Exception(s); } rx.push(r[0]); s = r[1]; } return [ rx, s]; }; }, all: function () { var px = arguments, _ = _; return _.each(_.optional(px)); }, // delimited operators sequence: function (px, d, c) { d = d || _.rtoken(/^\s*/); c = c || null; if (px.length === 1) { return px[0]; } return function (s) { var r = null, q = null; var rx = []; for (var i = 0; i < px.length ; i++) { try { r = px[i].call(this, s); } catch (e) { break; } rx.push(r[0]); try { q = d.call(this, r[1]); } catch (ex) { q = null; break; } s = q[1]; } if (!r) { throw new $P.Exception(s); } if (q) { throw new $P.Exception(q[1]); } if (c) { try { r = c.call(this, r[1]); } catch (ey) { throw new $P.Exception(r[1]); } } return [ rx, (r?r[1]:s) ]; }; }, // // Composite Operators // between: function (d1, p, d2) { d2 = d2 || d1; var _fn = _.each(_.ignore(d1), p, _.ignore(d2)); return function (s) { var rx = _fn.call(this, s); return [[rx[0][0], r[0][2]], rx[1]]; }; }, list: function (p, d, c) { d = d || _.rtoken(/^\s*/); c = c || null; return (p instanceof Array ? _.each(_.product(p.slice(0, -1), _.ignore(d)), p.slice(-1), _.ignore(c)) : _.each(_.many(_.each(p, _.ignore(d))), px, _.ignore(c))); }, set: function (px, d, c) { d = d || _.rtoken(/^\s*/); c = c || null; return function (s) { // r is the current match, best the current 'best' match // which means it parsed the most amount of input var r = null, p = null, q = null, rx = null, best = [[], s], last = false; // go through the rules in the given set for (var i = 0; i < px.length ; i++) { // last is a flag indicating whether this must be the last element // if there is only 1 element, then it MUST be the last one q = null; p = null; r = null; last = (px.length === 1); // first, we try simply to match the current pattern // if not, try the next pattern try { r = px[i].call(this, s); } catch (e) { continue; } // since we are matching against a set of elements, the first // thing to do is to add r[0] to matched elements rx = [[r[0]], r[1]]; // if we matched and there is still input to parse and // we don't already know this is the last element, // we're going to next check for the delimiter ... // if there's none, or if there's no input left to parse // than this must be the last element after all ... if (r[1].length > 0 && ! last) { try { q = d.call(this, r[1]); } catch (ex) { last = true; } } else { last = true; } // if we parsed the delimiter and now there's no more input, // that means we shouldn't have parsed the delimiter at all // so don't update r and mark this as the last element ... if (!last && q[1].length === 0) { last = true; } // so, if this isn't the last element, we're going to see if // we can get any more matches from the remaining (unmatched) // elements ... if (!last) { // build a list of the remaining rules we can match against, // i.e., all but the one we just matched against var qx = []; for (var j = 0; j < px.length ; j++) { if (i !== j) { qx.push(px[j]); } } // now invoke recursively set with the remaining input // note that we don't include the closing delimiter ... // we'll check for that ourselves at the end p = _.set(qx, d).call(this, q[1]); // if we got a non-empty set as a result ... // (otw rx already contains everything we want to match) if (p[0].length > 0) { // update current result, which is stored in rx ... // basically, pick up the remaining text from p[1] // and concat the result from p[0] so that we don't // get endless nesting ... rx[0] = rx[0].concat(p[0]); rx[1] = p[1]; } } // at this point, rx either contains the last matched element // or the entire matched set that starts with this element. // now we just check to see if this variation is better than // our best so far, in terms of how much of the input is parsed if (rx[1].length < best[1].length) { best = rx; } // if we've parsed all the input, then we're finished if (best[1].length === 0) { break; } } // so now we've either gone through all the patterns trying them // as the initial match; or we found one that parsed the entire // input string ... // if best has no matches, just return empty set ... if (best[0].length === 0) { return best; } // if a closing delimiter is provided, then we have to check it also if (c) { // we try this even if there is no remaining input because the pattern // may well be optional or match empty input ... try { q = c.call(this, best[1]); } catch (ey) { throw new $P.Exception(best[1]); } // it parsed ... be sure to update the best match remaining input best[1] = q[1]; } // if we're here, either there was no closing delimiter or we parsed it // so now we have the best match; just return it! return best; }; }, forward: function (gr, fname) { return function (s) { return gr[fname].call(this, s); }; }, // // Translation Operators // replace: function (rule, repl) { return function (s) { var r = rule.call(this, s); return [repl, r[1]]; }; }, process: function (rule, fn) { return function (s) { var r = rule.call(this, s); return [fn.call(this, r[0]), r[1]]; }; }, min: function (min, rule) { return function (s) { var rx = rule.call(this, s); if (rx[0].length < min) { throw new $P.Exception(s); } return rx; }; } }; // Generator Operators And Vector Operators // Generators are operators that have a signature of F(R) => R, // taking a given rule and returning another rule, such as // ignore, which parses a given rule and throws away the result. // Vector operators are those that have a signature of F(R1,R2,...) => R, // take a list of rules and returning a new rule, such as each. // Generator operators are converted (via the following _generator // function) into functions that can also take a list or array of rules // and return an array of new rules as though the function had been // called on each rule in turn (which is what actually happens). // This allows generators to be used with vector operators more easily. // Example: // each(ignore(foo, bar)) instead of each(ignore(foo), ignore(bar)) // This also turns generators into vector operators, which allows // constructs like: // not(cache(foo, bar)) var _generator = function (op) { function gen() { var args = null, rx = [], px, i; if (arguments.length > 1) { args = Array.prototype.slice.call(arguments); } else if (arguments[0] instanceof Array) { args = arguments[0]; } if (args) { px = args.shift(); if (px.length > 0) { args.unshift(px[i]); rx.push(op.apply(null, args)); args.shift(); return rx; } } else { return op.apply(null, arguments); } } return gen; }; var gx = "optional not ignore cache".split(/\s/); for (var i = 0 ; i < gx.length ; i++) { _[gx[i]] = _generator(_[gx[i]]); } var _vector = function (op) { return function () { if (arguments[0] instanceof Array) { return op.apply(null, arguments[0]); } else { return op.apply(null, arguments); } }; }; var vx = "each any all".split(/\s/); for (var j = 0 ; j < vx.length ; j++) { _[vx[j]] = _vector(_[vx[j]]); } }()); (function () { var $D = Date; var flattenAndCompact = function (ax) { var rx = []; for (var i = 0; i < ax.length; i++) { if (ax[i] instanceof Array) { rx = rx.concat(flattenAndCompact(ax[i])); } else { if (ax[i]) { rx.push(ax[i]); } } } return rx; }; var parseMeridian = function () { if (this.meridian && (this.hour || this.hour === 0)) { if (this.meridian === "a" && this.hour > 11 && Date.Config.strict24hr){ throw "Invalid hour and meridian combination"; } else if (this.meridian === "p" && this.hour < 12 && Date.Config.strict24hr){ throw "Invalid hour and meridian combination"; } else if (this.meridian === "p" && this.hour < 12) { this.hour = this.hour + 12; } else if (this.meridian === "a" && this.hour === 12) { this.hour = 0; } } }; var setDefaults = function () { var now = new Date(); if ((this.hour || this.minute) && (!this.month && !this.year && !this.day)) { this.day = now.getDate(); } if (!this.year) { this.year = now.getFullYear(); } if (!this.month && this.month !== 0) { this.month = now.getMonth(); } if (!this.day) { this.day = 1; } if (!this.hour) { this.hour = 0; } if (!this.minute) { this.minute = 0; } if (!this.second) { this.second = 0; } if (!this.millisecond) { this.millisecond = 0; } }; var finishUtils = { getToday: function () { if (this.now || "hour minute second".indexOf(this.unit) !== -1) { return new Date(); } else { return $D.today(); } }, setDaysFromWeekday: function (today, orient){ var gap; orient = orient || 1; this.unit = "day"; gap = ($D.getDayNumberFromName(this.weekday) - today.getDay()); this.days = gap ? ((gap + (orient * 7)) % 7) : (orient * 7); return this; }, setMonthsFromMonth: function (today, orient) { var gap; orient = orient || 1; this.unit = "month"; gap = (this.month - today.getMonth()); this.months = gap ? ((gap + (orient * 12)) % 12) : (orient * 12); this.month = null; return this; }, setDMYFromWeekday: function () { var d = Date[this.weekday](); this.day = d.getDate(); if (!this.month) { this.month = d.getMonth(); } this.year = d.getFullYear(); return this; }, setUnitValue: function (orient) { if (!this.value && this.operator && this.operator !== null && this[this.unit + "s"] && this[this.unit + "s"] !== null) { this[this.unit + "s"] = this[this.unit + "s"] + ((this.operator === "add") ? 1 : -1) + (this.value||0) * orient; } else if (this[this.unit + "s"] == null || this.operator != null) { if (!this.value) { this.value = 1; } this[this.unit + "s"] = this.value * orient; } }, generateDateFromWeeks: function () { var weekday = (this.weekday !== undefined) ? this.weekday : "today"; var d = Date[weekday]().addWeeks(this.weeks); if (this.now) { d.setTimeToNow(); } return d; } }; $D.Translator = { hour: function (s) { return function () { this.hour = Number(s); }; }, minute: function (s) { return function () { this.minute = Number(s); }; }, second: function (s) { return function () { this.second = Number(s); }; }, /* for ss.s format */ secondAndMillisecond: function (s) { return function () { var mx = s.match(/^([0-5][0-9])\.([0-9]{1,3})/); this.second = Number(mx[1]); this.millisecond = Number(mx[2]); }; }, meridian: function (s) { return function () { this.meridian = s.slice(0, 1).toLowerCase(); }; }, timezone: function (s) { return function () { var n = s.replace(/[^\d\+\-]/g, ""); if (n.length) { this.timezoneOffset = Number(n); } else { this.timezone = s.toLowerCase(); } }; }, day: function (x) { var s = x[0]; return function () { this.day = Number(s.match(/\d+/)[0]); if (this.day < 1) { throw "invalid day"; } }; }, month: function (s) { return function () { this.month = (s.length === 3) ? "jan feb mar apr may jun jul aug sep oct nov dec".indexOf(s)/4 : Number(s) - 1; if (this.month < 0) { throw "invalid month"; } }; }, year: function (s) { return function () { var n = Number(s); this.year = ((s.length > 2) ? n : (n + (((n + 2000) < Date.CultureInfo.twoDigitYearMax) ? 2000 : 1900))); }; }, rday: function (s) { return function () { switch (s) { case "yesterday": this.days = -1; break; case "tomorrow": this.days = 1; break; case "today": this.days = 0; break; case "now": this.days = 0; this.now = true; break; } }; }, finishExact: function (x) { var d; x = (x instanceof Array) ? x : [x]; for (var i = 0 ; i < x.length ; i++) { if (x[i]) { x[i].call(this); } } setDefaults.call(this); parseMeridian.call(this); if (this.day > $D.getDaysInMonth(this.year, this.month)) { throw new RangeError(this.day + " is not a valid value for days."); } d = new Date(this.year, this.month, this.day, this.hour, this.minute, this.second, this.millisecond); if (this.year < 100) { d.setFullYear(this.year); // means years less that 100 are process correctly. JS will parse it otherwise as 1900-1999. } if (this.timezone) { d.set({ timezone: this.timezone }); } else if (this.timezoneOffset) { d.set({ timezoneOffset: this.timezoneOffset }); } return d; }, finish: function (x) { var today, expression, orient, temp; x = (x instanceof Array) ? flattenAndCompact(x) : [ x ]; if (x.length === 0) { return null; } for (var i = 0 ; i < x.length ; i++) { if (typeof x[i] === "function") { x[i].call(this); } } if (this.now && !this.unit && !this.operator) { return new Date(); } else { today = finishUtils.getToday.call(this); } expression = !!(this.days && this.days !== null || this.orient || this.operator); orient = ((this.orient === "past" || this.operator === "subtract") ? -1 : 1); if (this.month && this.unit === "week") { this.value = this.month + 1; delete this.month; delete this.day; } if ((this.month || this.month === 0) && "year day hour minute second".indexOf(this.unit) !== -1) { if (!this.value) { this.value = this.month + 1; } this.month = null; expression = true; } if (!expression && this.weekday && !this.day && !this.days) { finishUtils.setDMYFromWeekday.call(this); } if (expression && this.weekday && this.unit !== "month" && this.unit !== "week") { finishUtils.setDaysFromWeekday.call(this, today, orient); } if (this.weekday && this.unit !== "week" && !this.day && !this.days) { temp = Date[this.weekday](); this.day = temp.getDate(); if (temp.getMonth() !== today.getMonth()) { this.month = temp.getMonth(); } } if (this.month && this.unit === "day" && this.operator) { if (!this.value) { this.value = (this.month + 1); } this.month = null; } if (this.value != null && this.month != null && this.year != null) { this.day = this.value * 1; } if (this.month && !this.day && this.value) { today.set({ day: this.value * 1 }); if (!expression) { this.day = this.value * 1; } } if (!this.month && this.value && this.unit === "month" && !this.now) { this.month = this.value; expression = true; } if (expression && (this.month || this.month === 0) && this.unit !== "year") { finishUtils.setMonthsFromMonth.call(this, today, orient); } if (!this.unit) { this.unit = "day"; } finishUtils.setUnitValue.call(this, orient); parseMeridian.call(this); if ((this.month || this.month === 0) && !this.day) { this.day = 1; } if (!this.orient && !this.operator && this.unit === "week" && this.value && !this.day && !this.month) { return Date.today().setWeek(this.value); } if (this.unit === "week" && this.weeks && !this.day && !this.month) { return finishUtils.generateDateFromWeeks.call(this); } if (expression && this.timezone && this.day && this.days) { this.day = this.days; } if (expression){ today.add(this); } else { today.set(this); } if (this.timezone) { this.timezone = this.timezone.toUpperCase(); var offset = $D.getTimezoneOffset(this.timezone); var timezone; if (today.hasDaylightSavingTime()) { // lets check that we're being sane with timezone setting timezone = $D.getTimezoneAbbreviation(offset, today.isDaylightSavingTime()); if (timezone !== this.timezone) { // bugger, we're in a place where things like EST vs EDT matters. if (today.isDaylightSavingTime()) { today.addHours(-1); } else { today.addHours(1); } } } today.setTimezoneOffset(offset); } return today; } }; }()); (function () { var $D = Date; $D.Grammar = {}; var _ = $D.Parsing.Operators, g = $D.Grammar, t = $D.Translator, _fn; // Allow rolling up into general purpose rules _fn = function () { return _.each(_.any.apply(null, arguments), _.not(g.ctoken2("timeContext"))); }; g.datePartDelimiter = _.rtoken(/^([\s\-\.\,\/\x27]+)/); g.timePartDelimiter = _.stoken(":"); g.whiteSpace = _.rtoken(/^\s*/); g.generalDelimiter = _.rtoken(/^(([\s\,]|at|@|on)+)/); var _C = {}; g.ctoken = function (keys) { var fn = _C[keys]; if (! fn) { var c = Date.CultureInfo.regexPatterns; var kx = keys.split(/\s+/), px = []; for (var i = 0; i < kx.length ; i++) { px.push(_.replace(_.rtoken(c[kx[i]]), kx[i])); } fn = _C[keys] = _.any.apply(null, px); } return fn; }; g.ctoken2 = function (key) { return _.rtoken(Date.CultureInfo.regexPatterns[key]); }; var cacheProcessRtoken = function (key, token, type, eachToken) { if (eachToken) { g[key] = _.cache(_.process(_.each(_.rtoken(token),_.optional(g.ctoken2(eachToken))), type)); } else { g[key] = _.cache(_.process(_.rtoken(token), type)); } }; var cacheProcessCtoken = function (token, type) { return _.cache(_.process(g.ctoken2(token), type)); }; var _F = {}; //function cache var _get = function (f) { _F[f] = (_F[f] || g.format(f)[0]); return _F[f]; }; g.allformats = function (fx) { var rx = []; if (fx instanceof Array) { for (var i = 0; i < fx.length; i++) { rx.push(_get(fx[i])); } } else { rx.push(_get(fx)); } return rx; }; g.formats = function (fx) { if (fx instanceof Array) { var rx = []; for (var i = 0 ; i < fx.length ; i++) { rx.push(_get(fx[i])); } return _.any.apply(null, rx); } else { return _get(fx); } }; var grammarFormats = { timeFormats: function(){ var i, RTokenKeys = [ "h", "hh", "H", "HH", "m", "mm", "s", "ss", "ss.s", "z", "zz" ], RToken = [ /^(0[0-9]|1[0-2]|[1-9])/, /^(0[0-9]|1[0-2])/, /^([0-1][0-9]|2[0-3]|[0-9])/, /^([0-1][0-9]|2[0-3])/, /^([0-5][0-9]|[0-9])/, /^[0-5][0-9]/, /^([0-5][0-9]|[0-9])/, /^[0-5][0-9]/, /^[0-5][0-9]\.[0-9]{1,3}/, /^((\+|\-)\s*\d\d\d\d)|((\+|\-)\d\d\:?\d\d)/, /^((\+|\-)\s*\d\d\d\d)|((\+|\-)\d\d\:?\d\d)/ ], tokens = [ t.hour, t.hour, t.hour, t.hour, t.minute, t.minute, t.second, t.second, t.secondAndMillisecond, t.timezone, t.timezone ]; for (i=0; i < RTokenKeys.length; i++) { cacheProcessRtoken(RTokenKeys[i], RToken[i], tokens[i]); } g.hms = _.cache(_.sequence([g.H, g.m, g.s], g.timePartDelimiter)); g.t = cacheProcessCtoken("shortMeridian", t.meridian); g.tt = cacheProcessCtoken("longMeridian", t.meridian); g.zzz = cacheProcessCtoken("timezone", t.timezone); g.timeSuffix = _.each(_.ignore(g.whiteSpace), _.set([ g.tt, g.zzz ])); g.time = _.each(_.optional(_.ignore(_.stoken("T"))), g.hms, g.timeSuffix); }, dateFormats: function () { // pre-loaded rules for different date part order preferences var _setfn = function () { return _.set(arguments, g.datePartDelimiter); }; var i, RTokenKeys = [ "d", "dd", "M", "MM", "y", "yy", "yyy", "yyyy" ], RToken = [ /^([0-2]\d|3[0-1]|\d)/, /^([0-2]\d|3[0-1])/, /^(1[0-2]|0\d|\d)/, /^(1[0-2]|0\d)/, /^(\d+)/, /^(\d\d)/, /^(\d\d?\d?\d?)/, /^(\d\d\d\d)/ ], tokens = [ t.day, t.day, t.month, t.month, t.year, t.year, t.year, t.year ], eachToken = [ "ordinalSuffix", "ordinalSuffix" ]; for (i=0; i < RTokenKeys.length; i++) { cacheProcessRtoken(RTokenKeys[i], RToken[i], tokens[i], eachToken[i]); } g.MMM = g.MMMM = _.cache(_.process(g.ctoken("jan feb mar apr may jun jul aug sep oct nov dec"), t.month)); g.ddd = g.dddd = _.cache(_.process(g.ctoken("sun mon tue wed thu fri sat"), function (s) { return function () { this.weekday = s; }; } )); g.day = _fn(g.d, g.dd); g.month = _fn(g.M, g.MMM); g.year = _fn(g.yyyy, g.yy); g.mdy = _setfn(g.ddd, g.month, g.day, g.year); g.ymd = _setfn(g.ddd, g.year, g.month, g.day); g.dmy = _setfn(g.ddd, g.day, g.month, g.year); g.date = function (s) { return ((g[Date.CultureInfo.dateElementOrder] || g.mdy).call(this, s)); }; }, relative: function () { // relative date / time expressions g.orientation = _.process(g.ctoken("past future"), function (s) { return function () { this.orient = s; }; } ); g.operator = _.process(g.ctoken("add subtract"), function (s) { return function () { this.operator = s; }; } ); g.rday = _.process(g.ctoken("yesterday tomorrow today now"), t.rday); g.unit = _.process(g.ctoken("second minute hour day week month year"), function (s) { return function () { this.unit = s; }; } ); } }; g.buildGrammarFormats = function () { // these need to be rebuilt every time the language changes. _C = {}; grammarFormats.timeFormats(); grammarFormats.dateFormats(); grammarFormats.relative(); g.value = _.process(_.rtoken(/^([-+]?\d+)?(st|nd|rd|th)?/), function (s) { return function () { this.value = s.replace(/\D/g, ""); }; } ); g.expression = _.set([g.rday, g.operator, g.value, g.unit, g.orientation, g.ddd, g.MMM ]); g.format = _.process(_.many( _.any( // translate format specifiers into grammar rules _.process( _.rtoken(/^(dd?d?d?(?!e)|MM?M?M?|yy?y?y?|hh?|HH?|mm?|ss?|tt?|zz?z?)/), function (fmt) { if (g[fmt]) { return g[fmt]; } else { throw $D.Parsing.Exception(fmt); } } ), // translate separator tokens into token rules _.process(_.rtoken(/^[^dMyhHmstz]+/), // all legal separators function (s) { return _.ignore(_.stoken(s)); } ) ) ), // construct the parser ... function (rules) { return _.process(_.each.apply(null, rules), t.finishExact); } ); // starting rule for general purpose grammar g._start = _.process(_.set([ g.date, g.time, g.expression ], g.generalDelimiter, g.whiteSpace), t.finish); }; g.buildGrammarFormats(); // parsing date format specifiers - ex: "h:m:s tt" // this little guy will generate a custom parser based // on the format string, ex: g.format("h:m:s tt") // check for these formats first g._formats = g.formats([ "\"yyyy-MM-ddTHH:mm:ssZ\"", "yyyy-MM-ddTHH:mm:ss.sz", "yyyy-MM-ddTHH:mm:ssZ", "yyyy-MM-ddTHH:mm:ssz", "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-ddTHH:mmZ", "yyyy-MM-ddTHH:mmz", "yyyy-MM-ddTHH:mm", "ddd, MMM dd, yyyy H:mm:ss tt", "ddd MMM d yyyy HH:mm:ss zzz", "MMddyyyy", "ddMMyyyy", "Mddyyyy", "ddMyyyy", "Mdyyyy", "dMyyyy", "yyyy", "Mdyy", "dMyy", "d" ]); // real starting rule: tries selected formats first, // then general purpose rule g.start = function (s) { try { var r = g._formats.call({}, s); if (r[1].length === 0) { return r; } } catch (e) {} return g._start.call({}, s); }; }()); (function () { var $D = Date; /** * @desc Converts the specified string value into its JavaScript Date equivalent using CultureInfo specific format information. * * Example

	///////////
	// Dates //
	///////////

	// 15-Oct-2004
	var d1 = Date.parse("10/15/2004");

	// 15-Oct-2004
	var d1 = Date.parse("15-Oct-2004");

	// 15-Oct-2004
	var d1 = Date.parse("2004.10.15");

	//Fri Oct 15, 2004
	var d1 = Date.parse("Fri Oct 15, 2004");

	///////////
	// Times //
	///////////

	// Today at 10 PM.
	var d1 = Date.parse("10 PM");

	// Today at 10:30 PM.
	var d1 = Date.parse("10:30 P.M.");

	// Today at 6 AM.
	var d1 = Date.parse("06am");

	/////////////////////
	// Dates and Times //
	/////////////////////

	// 8-July-2004 @ 10:30 PM
	var d1 = Date.parse("July 8th, 2004, 10:30 PM");

	// 1-July-2004 @ 10:30 PM
	var d1 = Date.parse("2004-07-01T22:30:00");

	////////////////////
	// Relative Dates //
	////////////////////

	// Returns today's date. The string "today" is culture specific.
	var d1 = Date.parse("today");

	// Returns yesterday's date. The string "yesterday" is culture specific.
	var d1 = Date.parse("yesterday");

	// Returns the date of the next thursday.
	var d1 = Date.parse("Next thursday");

	// Returns the date of the most previous monday.
	var d1 = Date.parse("last monday");

	// Returns today's day + one year.
	var d1 = Date.parse("next year");

	///////////////
	// Date Math //
	///////////////

	// Today + 2 days
	var d1 = Date.parse("t+2");

	// Today + 2 days
	var d1 = Date.parse("today + 2 days");

	// Today + 3 months
	var d1 = Date.parse("t+3m");

	// Today - 1 year
	var d1 = Date.parse("today - 1 year");

	// Today - 1 year
	var d1 = Date.parse("t-1y"); 


	/////////////////////////////
	// Partial Dates and Times //
	/////////////////////////////

	// July 15th of this year.
	var d1 = Date.parse("July 15");

	// 15th day of current day and year.
	var d1 = Date.parse("15");

	// July 1st of current year at 10pm.
	var d1 = Date.parse("7/1 10pm");
	
* * @param {String} The string value to convert into a Date object [Required] * @return {Date} A Date object or null if the string cannot be converted into a Date. */ var parseUtils = { removeOrds: function (s) { ords = s.match(/\b(\d+)(?:st|nd|rd|th)\b/); // find ordinal matches s = ((ords && ords.length === 2) ? s.replace(ords[0], ords[1]) : s); return s; }, grammarParser: function (s) { var r = null; try { r = $D.Grammar.start.call({}, s.replace(/^\s*(\S*(\s+\S+)*)\s*$/, "$1")); } catch (e) { return null; } return ((r[1].length === 0) ? r[0] : null); }, nativeFallback: function(s) { var t; try { // ok we haven't parsed it, last ditch attempt with the built-in parser. t = Date._parse(s); return (t || t === 0) ? new Date(t) : null; } catch (e) { return null; } } }; function parse (s) { var d; if (!s) { return null; } if (s instanceof Date) { return s.clone(); } if (s.length >= 4 && s.charAt(0) !== "0" && s.charAt(0) !== "+"&& s.charAt(0) !== "-") { // ie: 2004 will pass, 0800 won't. // Start with specific formats d = $D.Parsing.ISO.parse(s) || $D.Parsing.Numeric.parse(s); } if (d instanceof Date && !isNaN(d.getTime())) { return d; } else { // find ordinal dates (1st, 3rd, 8th, etc and remove them as they cause parsing issues) s = $D.Parsing.Normalizer.parse(parseUtils.removeOrds(s)); d = parseUtils.grammarParser(s); if (d !== null) { return d; } else { return parseUtils.nativeFallback(s); } } } if (!$D._parse) { $D._parse = $D.parse; } $D.parse = parse; Date.getParseFunction = function (fx) { var fns = Date.Grammar.allformats(fx); return function (s) { var r = null; for (var i = 0; i < fns.length; i++) { try { r = fns[i].call({}, s); } catch (e) { continue; } if (r[1].length === 0) { return r[0]; } } return null; }; }; /** * Converts the specified string value into its JavaScript Date equivalent using the specified format {String} or formats {Array} and the CultureInfo specific format information. * The format of the string value must match one of the supplied formats exactly. * * Example

	// 15-Oct-2004
	var d1 = Date.parseExact("10/15/2004", "M/d/yyyy");

	// 15-Oct-2004
	var d1 = Date.parse("15-Oct-2004", "M-ddd-yyyy");

	// 15-Oct-2004
	var d1 = Date.parse("2004.10.15", "yyyy.MM.dd");

	// Multiple formats
	var d1 = Date.parseExact("10/15/2004", ["M/d/yyyy", "MMMM d, yyyy"]);
	
* * @param {String} The string value to convert into a Date object [Required]. * @param {Object} The expected format {String} or an array of expected formats {Array} of the date string [Required]. * @return {Date} A Date object or null if the string cannot be converted into a Date. */ $D.parseExact = function (s, fx) { return $D.getParseFunction(fx)(s); }; }()); (function () { var $D = Date, $P = $D.prototype, // $C = $D.CultureInfo, // not used atm p = function (s, l) { if (!l) { l = 2; } return ("000" + s).slice(l * -1); }; /** * Converts a PHP format string to Java/.NET format string. * A PHP format string can be used with ._format or .format. * A Java/.NET format string can be used with .toString(). * The .parseExact function will only accept a Java/.NET format string * * Example * var f1 = "%m/%d/%y" * var f2 = Date.normalizeFormat(f1); // "MM/dd/yy" * * new Date().format(f1); // "04/13/08" * new Date()._format(f1); // "04/13/08" * new Date().toString(f2); // "04/13/08" * * var date = Date.parseExact("04/13/08", f2); // Sun Apr 13 2008 * * @param {String} A PHP format string consisting of one or more format spcifiers. * @return {String} The PHP format converted to a Java/.NET format string. */ var normalizerSubstitutions = { "d" : "dd", "%d": "dd", "D" : "ddd", "%a": "ddd", "j" : "dddd", "l" : "dddd", "%A": "dddd", "S" : "S", "F" : "MMMM", "%B": "MMMM", "m" : "MM", "%m": "MM", "M" : "MMM", "%b": "MMM", "%h": "MMM", "n" : "M", "Y" : "yyyy", "%Y": "yyyy", "y" : "yy", "%y": "yy", "g" : "h", "%I": "h", "G" : "H", "h" : "hh", "H" : "HH", "%H": "HH", "i" : "mm", "%M": "mm", "s" : "ss", "%S": "ss", "%r": "hh:mm tt", "%R": "H:mm", "%T": "H:mm:ss", "%X": "t", "%x": "d", "%e": "d", "%D": "MM/dd/yy", "%n": "\\n", "%t": "\\t", "e" : "z", "T" : "z", "%z": "z", "%Z": "z", "Z" : "ZZ", "N" : "u", "w" : "u", "%w": "u", "W" : "W", "%V": "W" }; var normalizer = { substitutes: function (m) { return normalizerSubstitutions[m]; }, interpreted: function (m, x) { var y; switch (m) { case "%u": return x.getDay() + 1; case "z": return x.getOrdinalNumber(); case "%j": return p(x.getOrdinalNumber(), 3); case "%U": var d1 = x.clone().set({month: 0, day: 1}).addDays(-1).moveToDayOfWeek(0), d2 = x.clone().addDays(1).moveToDayOfWeek(0, -1); return (d2 < d1) ? "00" : p((d2.getOrdinalNumber() - d1.getOrdinalNumber()) / 7 + 1); case "%W": return p(x.getWeek()); case "t": return $D.getDaysInMonth(x.getFullYear(), x.getMonth()); case "o": case "%G": return x.setWeek(x.getISOWeek()).toString("yyyy"); case "%g": return x._format("%G").slice(-2); case "a": case "%p": return t("tt").toLowerCase(); case "A": return t("tt").toUpperCase(); case "u": return p(x.getMilliseconds(), 3); case "I": return (x.isDaylightSavingTime()) ? 1 : 0; case "O": return x.getUTCOffset(); case "P": y = x.getUTCOffset(); return y.substring(0, y.length - 2) + ":" + y.substring(y.length - 2); case "B": var now = new Date(); return Math.floor(((now.getHours() * 3600) + (now.getMinutes() * 60) + now.getSeconds() + (now.getTimezoneOffset() + 60) * 60) / 86.4); case "c": return x.toISOString().replace(/\"/g, ""); case "U": return $D.strtotime("now"); case "%c": return t("d") + " " + t("t"); case "%C": return Math.floor(x.getFullYear() / 100 + 1); } }, shouldOverrideDefaults: function (m) { switch (m) { case "%e": return true; default: return false; } }, parse: function (m, context) { var formatString, c = context || new Date(); formatString = normalizer.substitutes(m); if (formatString) { return formatString; } formatString = normalizer.interpreted(m, c); if (formatString) { return formatString; } else { return m; } } }; $D.normalizeFormat = function (format, context) { return format.replace(/(%|\\)?.|%%/g, function(t){ return normalizer.parse(t, context); }); }; /** * Format a local Unix timestamp according to locale settings * * Example: * Date.strftime("%m/%d/%y", new Date()); // "04/13/08" * Date.strftime("c", "2008-04-13T17:52:03Z"); // "04/13/08" * * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @param {Number|String} The number representing the number of seconds that have elapsed since January 1, 1970 (local time). * @return {String} A string representation of the current Date object. */ $D.strftime = function (format, time) { var d = Date.parse(time); return d._format(format); }; /** * Parse any textual datetime description into a Unix timestamp. * A Unix timestamp is the number of seconds that have elapsed since January 1, 1970 (midnight UTC/GMT). * * Example: * Date.strtotime("04/13/08"); // 1208044800 * Date.strtotime("1970-01-01T00:00:00Z"); // 0 * * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @param {Object} A string or date object. * @return {String} A string representation of the current Date object. */ $D.strtotime = function (time) { var d = $D.parse(time); return Math.round($D.UTC(d.getUTCFullYear(), d.getUTCMonth(), d.getUTCDate(), d.getUTCHours(), d.getUTCMinutes(), d.getUTCSeconds(), d.getUTCMilliseconds()) / 1000); }; /** * Converts the value of the current Date object to its equivalent string representation using a PHP/Unix style of date format specifiers. * Format Specifiers * Format Description Example * ------ --------------------------------------------------------------------------- ----------------------- * %a abbreviated weekday name according to the current localed "Mon" through "Sun" * %A full weekday name according to the current localed "Sunday" through "Saturday" * %b abbreviated month name according to the current localed "Jan" through "Dec" * %B full month name according to the current locale "January" through "December" * %c preferred date and time representation for the current locale "4/13/2008 12:33 PM" * %C century number (the year divided by 100 and truncated to an integer) "00" to "99" * %d day of the month as a decimal number "01" to "31" * %D same as %m/%d/%y "04/13/08" * %e day of the month as a decimal number, a single digit is preceded by a space "1" to "31" * %g like %G, but without the century "08" * %G The 4-digit year corresponding to the ISO week number (see %V). "2008" * This has the same format and value as %Y, except that if the ISO week number * belongs to the previous or next year, that year is used instead. * %h same as %b "Jan" through "Dec" * %H hour as a decimal number using a 24-hour clock. "00" to "23" * %I hour as a decimal number using a 12-hour clock. "01" to "12" * %j day of the year as a decimal number. "001" to "366" * %m month as a decimal number. "01" to "12" * %M minute as a decimal number. "00" to "59" * %n newline character "\n" * %p either "am" or "pm" according to the given time value, or the "am" or "pm" * corresponding strings for the current locale. * %r time in a.m. and p.m. notation "8:44 PM" * %R time in 24 hour notation "20:44" * %S second as a decimal number "00" to "59" * %t tab character "\t" * %T current time, equal to %H:%M:%S "12:49:11" * %u weekday as a decimal number ["1", "7"], with "1" representing Monday "1" to "7" * %U week number of the current year as a decimal number, starting with the "0" to ("52" or "53") * first Sunday as the first day of the first week * %V The ISO 8601:1988 week number of the current year as a decimal number, "00" to ("52" or "53") * range 01 to 53, where week 1 is the first week that has at least 4 days * in the current year, and with Monday as the first day of the week. * (Use %G or %g for the year component that corresponds to the week number * for the specified timestamp.) * %W week number of the current year as a decimal number, starting with the "00" to ("52" or "53") * first Monday as the first day of the first week * %w day of the week as a decimal, Sunday being "0" "0" to "6" * %x preferred date representation for the current locale without the time "4/13/2008" * %X preferred time representation for the current locale without the date "12:53:05" * %y year as a decimal number without a century "00" "99" * %Y year as a decimal number including the century "2008" * %Z time zone or name or abbreviation "UTC", "EST", "PST" * %z same as %Z * %% a literal "%" characters "%" * d Day of the month, 2 digits with leading zeros "01" to "31" * D A textual representation of a day, three letters "Mon" through "Sun" * j Day of the month without leading zeros "1" to "31" * l A full textual representation of the day of the week (lowercase "L") "Sunday" through "Saturday" * N ISO-8601 numeric representation of the day of the week (added in PHP 5.1.0) "1" (for Monday) through "7" (for Sunday) * S English ordinal suffix for the day of the month, 2 characters "st", "nd", "rd" or "th". Works well with j * w Numeric representation of the day of the week "0" (for Sunday) through "6" (for Saturday) * z The day of the year (starting from "0") "0" through "365" * W ISO-8601 week number of year, weeks starting on Monday "00" to ("52" or "53") * F A full textual representation of a month, such as January or March "January" through "December" * m Numeric representation of a month, with leading zeros "01" through "12" * M A short textual representation of a month, three letters "Jan" through "Dec" * n Numeric representation of a month, without leading zeros "1" through "12" * t Number of days in the given month "28" through "31" * L Whether it's a leap year "1" if it is a leap year, "0" otherwise * o ISO-8601 year number. This has the same value as Y, except that if the "2008" * ISO week number (W) belongs to the previous or next year, that year * is used instead. * Y A full numeric representation of a year, 4 digits "2008" * y A two digit representation of a year "08" * a Lowercase Ante meridiem and Post meridiem "am" or "pm" * A Uppercase Ante meridiem and Post meridiem "AM" or "PM" * B Swatch Internet time "000" through "999" * g 12-hour format of an hour without leading zeros "1" through "12" * G 24-hour format of an hour without leading zeros "0" through "23" * h 12-hour format of an hour with leading zeros "01" through "12" * H 24-hour format of an hour with leading zeros "00" through "23" * i Minutes with leading zeros "00" to "59" * s Seconds, with leading zeros "00" through "59" * u Milliseconds "54321" * e Timezone identifier "UTC", "EST", "PST" * I Whether or not the date is in daylight saving time (uppercase i) "1" if Daylight Saving Time, "0" otherwise * O Difference to Greenwich time (GMT) in hours "+0200", "-0600" * P Difference to Greenwich time (GMT) with colon between hours and minutes "+02:00", "-06:00" * T Timezone abbreviation "UTC", "EST", "PST" * Z Timezone offset in seconds. The offset for timezones west of UTC is "-43200" through "50400" * always negative, and for those east of UTC is always positive. * c ISO 8601 date "2004-02-12T15:19:21+00:00" * r RFC 2822 formatted date "Thu, 21 Dec 2000 16:01:07 +0200" * U Seconds since the Unix Epoch (January 1 1970 00:00:00 GMT) "0" * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @return {String} A string representation of the current Date object. */ var formatReplace = function (context) { return function (m) { var formatString, override = false; if (m.charAt(0) === "\\" || m.substring(0, 2) === "%%") { return m.replace("\\", "").replace("%%", "%"); } override = normalizer.shouldOverrideDefaults(m); formatString = $D.normalizeFormat(m, context); if (formatString) { return context.toString(formatString, override); } }; }; $P._format = function (format) { var formatter = formatReplace(this); if (!format) { return this._toString(); } else { return format.replace(/(%|\\)?.|%%/g, formatter); } }; if (!$P.format) { $P.format = $P._format; } }()); (function () { "use strict"; var gFn = function (attr) { return function () { return this[attr]; }; }; var sFn = function (attr) { return function (val) { this[attr] = val; return this; }; }; var attrs = ["years", "months", "days", "hours", "minutes", "seconds", "milliseconds"]; var addSetFuncs = function (context, attrs) { for (var i = 0; i < attrs.length ; i++) { var $a = attrs[i], $b = $a.slice(0, 1).toUpperCase() + $a.slice(1); context.prototype[$a] = 0; context.prototype["get" + $b] = gFn($a); context.prototype["set" + $b] = sFn($a); } }; /** * new TimeSpan(milliseconds); * new TimeSpan(days, hours, minutes, seconds); * new TimeSpan(days, hours, minutes, seconds, milliseconds); */ var TimeSpan = function (days, hours, minutes, seconds, milliseconds) { if (arguments.length === 1 && typeof days === "number") { var orient = (days < 0) ? -1 : +1; var millsLeft = Math.abs(days); this.setDays(Math.floor(millsLeft / 86400000) * orient); millsLeft = millsLeft % 86400000; this.setHours(Math.floor(millsLeft / 3600000) * orient); millsLeft = millsLeft % 3600000; this.setMinutes(Math.floor(millsLeft / 60000) * orient); millsLeft = millsLeft % 60000; this.setSeconds(Math.floor(millsLeft / 1000) * orient); millsLeft = millsLeft % 1000; this.setMilliseconds(millsLeft * orient); } else { this.set(days, hours, minutes, seconds, milliseconds); } this.getTotalMilliseconds = function () { return (this.getDays() * 86400000) + (this.getHours() * 3600000) + (this.getMinutes() * 60000) + (this.getSeconds() * 1000); }; this.compareTo = function (time) { var t1 = new Date(1970, 1, 1, this.getHours(), this.getMinutes(), this.getSeconds()), t2; if (time === null) { t2 = new Date(1970, 1, 1, 0, 0, 0); } else { t2 = new Date(1970, 1, 1, time.getHours(), time.getMinutes(), time.getSeconds()); } return (t1 < t2) ? -1 : (t1 > t2) ? 1 : 0; }; this.equals = function (time) { return (this.compareTo(time) === 0); }; this.add = function (time) { return (time === null) ? this : this.addSeconds(time.getTotalMilliseconds() / 1000); }; this.subtract = function (time) { return (time === null) ? this : this.addSeconds(-time.getTotalMilliseconds() / 1000); }; this.addDays = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 86400000)); }; this.addHours = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 3600000)); }; this.addMinutes = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 60000)); }; this.addSeconds = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 1000)); }; this.addMilliseconds = function (n) { return new TimeSpan(this.getTotalMilliseconds() + n); }; this.get12HourHour = function () { return (this.getHours() > 12) ? this.getHours() - 12 : (this.getHours() === 0) ? 12 : this.getHours(); }; this.getDesignator = function () { return (this.getHours() < 12) ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator; }; this.toString = function (format) { this._toString = function () { if (this.getDays() !== null && this.getDays() > 0) { return this.getDays() + "." + this.getHours() + ":" + this.p(this.getMinutes()) + ":" + this.p(this.getSeconds()); } else { return this.getHours() + ":" + this.p(this.getMinutes()) + ":" + this.p(this.getSeconds()); } }; this.p = function (s) { return (s.toString().length < 2) ? "0" + s : s; }; var me = this; return format ? format.replace(/dd?|HH?|hh?|mm?|ss?|tt?/g, function (format) { switch (format) { case "d": return me.getDays(); case "dd": return me.p(me.getDays()); case "H": return me.getHours(); case "HH": return me.p(me.getHours()); case "h": return me.get12HourHour(); case "hh": return me.p(me.get12HourHour()); case "m": return me.getMinutes(); case "mm": return me.p(me.getMinutes()); case "s": return me.getSeconds(); case "ss": return me.p(me.getSeconds()); case "t": return ((me.getHours() < 12) ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator).substring(0, 1); case "tt": return (me.getHours() < 12) ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator; } } ) : this._toString(); }; return this; }; addSetFuncs(TimeSpan, attrs.slice(2)); TimeSpan.prototype.set = function (days, hours, minutes, seconds, milliseconds){ this.setDays(days || this.getDays()); this.setHours(hours || this.getHours()); this.setMinutes(minutes || this.getMinutes()); this.setSeconds(seconds || this.getSeconds()); this.setMilliseconds(milliseconds || this.getMilliseconds()); }; /** * Gets the time of day for this date instances. * @return {TimeSpan} TimeSpan */ Date.prototype.getTimeOfDay = function () { return new TimeSpan(0, this.getHours(), this.getMinutes(), this.getSeconds(), this.getMilliseconds()); }; Date.TimeSpan = TimeSpan; if (typeof window !== "undefined" ) { // keeping API compatible for v1.x window.TimeSpan = TimeSpan; } }()); (function () { "use strict"; var attrs = ["years", "months", "days", "hours", "minutes", "seconds", "milliseconds"]; var gFn = function (attr) { return function () { return this[attr]; }; }; var sFn = function (attr) { return function (val) { this[attr] = val; return this; }; }; var addSetFuncs = function (context, attrs) { for (var i = 0; i < attrs.length ; i++) { var $a = attrs[i], $b = $a.slice(0, 1).toUpperCase() + $a.slice(1); context.prototype[$a] = 0; context.prototype["get" + $b] = gFn($a); context.prototype["set" + $b] = sFn($a); } }; var setMonthsAndYears = function (orient, d1, d2, context) { function inc() { d1.addMonths(-orient); context.months++; if (context.months === 12) { context.years++; context.months = 0; } } if (orient === +1) { while (d1 > d2) { inc(); } } else { while (d1 < d2) { inc(); } } context.months--; context.months *= orient; context.years *= orient; }; var adjustForDST = function(orient, startDate, endDate) { var hasDSTMismatch = (false === (startDate.isDaylightSavingTime() === endDate.isDaylightSavingTime())); if (hasDSTMismatch && orient === 1) { startDate.addHours(-1); } else if (hasDSTMismatch) { startDate.addHours(1); } }; /** * TimePeriod(startDate, endDate); * TimePeriod(years, months, days, hours, minutes, seconds, milliseconds); */ var TimePeriod = function (years, months, days, hours, minutes, seconds, milliseconds) { if (arguments.length === 7) { this.set(years, months, days, hours, minutes, seconds, milliseconds); } else if (arguments.length === 2 && arguments[0] instanceof Date && arguments[1] instanceof Date) { var startDate = arguments[0].clone(); var endDate = arguments[1].clone(); var orient = (startDate > endDate) ? +1 : -1; this.dates = { start: arguments[0].clone(), end: arguments[1].clone() }; setMonthsAndYears(orient, startDate, endDate, this); adjustForDST(orient, startDate, endDate); // // TODO - adjust for DST var diff = endDate - startDate; if (diff !== 0) { var ts = new TimeSpan(diff); this.set(this.years, this.months, ts.getDays(), ts.getHours(), ts.getMinutes(), ts.getSeconds(), ts.getMilliseconds()); } } return this; }; // create all the set functions. addSetFuncs(TimePeriod, attrs); TimePeriod.prototype.set = function (years, months, days, hours, minutes, seconds, milliseconds){ this.setYears(years || this.getYears()); this.setMonths(months || this.getMonths()); this.setDays(days || this.getDays()); this.setHours(hours || this.getHours()); this.setMinutes(minutes || this.getMinutes()); this.setSeconds(seconds || this.getSeconds()); this.setMilliseconds(milliseconds || this.getMilliseconds()); }; Date.TimePeriod = TimePeriod; if (typeof window !== "undefined") { // keeping API compatible for v1.x window.TimePeriod = TimePeriod; } }()); ================================================ FILE: build/date-fr-MC.js ================================================ /** * @overview datejs * @version 1.0.0-rc3 * @author Gregory Wild-Smith * @copyright 2015 Gregory Wild-Smith * @license MIT * @homepage https://github.com/abritinthebay/datejs */ /* * DateJS Culture String File * Country Code: fr-MC * Name: French (Principality of Monaco) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["fr-MC"] = { "name": "fr-MC", "englishName": "French (Principality of Monaco)", "nativeName": "français (Principauté de Monaco)", "Sunday": "dimanche", "Monday": "lundi", "Tuesday": "mardi", "Wednesday": "mercredi", "Thursday": "jeudi", "Friday": "vendredi", "Saturday": "samedi", "Sun": "dim.", "Mon": "lun.", "Tue": "mar.", "Wed": "mer.", "Thu": "jeu.", "Fri": "ven.", "Sat": "sam.", "Su": "di", "Mo": "lu", "Tu": "ma", "We": "me", "Th": "je", "Fr": "ve", "Sa": "sa", "S_Sun_Initial": "d", "M_Mon_Initial": "l", "T_Tue_Initial": "m", "W_Wed_Initial": "m", "T_Thu_Initial": "j", "F_Fri_Initial": "v", "S_Sat_Initial": "s", "January": "janvier", "February": "février", "March": "mars", "April": "avril", "May": "mai", "June": "juin", "July": "juillet", "August": "août", "September": "septembre", "October": "octobre", "November": "novembre", "December": "décembre", "Jan_Abbr": "janv.", "Feb_Abbr": "févr.", "Mar_Abbr": "mars", "Apr_Abbr": "avr.", "May_Abbr": "mai", "Jun_Abbr": "juin", "Jul_Abbr": "juil.", "Aug_Abbr": "août", "Sep_Abbr": "sept.", "Oct_Abbr": "oct.", "Nov_Abbr": "nov.", "Dec_Abbr": "déc.", "AM": "", "PM": "", "firstDayOfWeek": 1, "twoDigitYearMax": 2029, "mdy": "dmy", "M/d/yyyy": "dd/MM/yyyy", "dddd, MMMM dd, yyyy": "dddd d MMMM yyyy", "h:mm tt": "HH:mm", "h:mm:ss tt": "HH:mm:ss", "dddd, MMMM dd, yyyy h:mm:ss tt": "dddd d MMMM yyyy HH:mm:ss", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "d MMMM", "MMMM, yyyy": "MMMM yyyy", "/jan(uary)?/": "janv(.(ier)?)?", "/feb(ruary)?/": "févr(.(ier)?)?", "/mar(ch)?/": "mars", "/apr(il)?/": "avr(.(il)?)?", "/may/": "mai", "/jun(e)?/": "juin", "/jul(y)?/": "juil(.(let)?)?", "/aug(ust)?/": "août", "/sep(t(ember)?)?/": "sept(.(embre)?)?", "/oct(ober)?/": "oct(.(obre)?)?", "/nov(ember)?/": "nov(.(embre)?)?", "/dec(ember)?/": "déc(.(embre)?)?", "/^su(n(day)?)?/": "^di(m(.(anche)?)?)?", "/^mo(n(day)?)?/": "^lu(n(.(di)?)?)?", "/^tu(e(s(day)?)?)?/": "^ma(r(.(di)?)?)?", "/^we(d(nesday)?)?/": "^me(r(.(credi)?)?)?", "/^th(u(r(s(day)?)?)?)?/": "^je(u(.(di)?)?)?", "/^fr(i(day)?)?/": "^ve(n(.(dredi)?)?)?", "/^sa(t(urday)?)?/": "^sa(m(.(edi)?)?)?", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "fr-MC"; /** * @overview datejs * @version 1.0.0-rc3 * @author Gregory Wild-Smith * @copyright 2015 Gregory Wild-Smith * @license MIT * @homepage https://github.com/abritinthebay/datejs */(function () { var $D = Date; var lang = Date.CultureStrings ? Date.CultureStrings.lang : null; var loggedKeys = {}; // for debug purposes. var getText = { getFromKey: function (key, countryCode) { var output; if (Date.CultureStrings && Date.CultureStrings[countryCode] && Date.CultureStrings[countryCode][key]) { output = Date.CultureStrings[countryCode][key]; } else { output = getText.buildFromDefault(key); } if (key.charAt(0) === "/") { // Assume it's a regex output = getText.buildFromRegex(key, countryCode); } return output; }, getFromObjectValues: function (obj, countryCode) { var key, output = {}; for(key in obj) { if (obj.hasOwnProperty(key)) { output[key] = getText.getFromKey(obj[key], countryCode); } } return output; }, getFromObjectKeys: function (obj, countryCode) { var key, output = {}; for(key in obj) { if (obj.hasOwnProperty(key)) { output[getText.getFromKey(key, countryCode)] = obj[key]; } } return output; }, getFromArray: function (arr, countryCode) { var output = []; for (var i=0; i < arr.length; i++){ if (i in arr) { output[i] = getText.getFromKey(arr[i], countryCode); } } return output; }, buildFromDefault: function (key) { var output, length, split, last; switch(key) { case "name": output = "en-US"; break; case "englishName": output = "English (United States)"; break; case "nativeName": output = "English (United States)"; break; case "twoDigitYearMax": output = 2049; break; case "firstDayOfWeek": output = 0; break; default: output = key; split = key.split("_"); length = split.length; if (length > 1 && key.charAt(0) !== "/") { // if the key isn't a regex and it has a split. last = split[(length - 1)].toLowerCase(); if (last === "initial" || last === "abbr") { output = split[0]; } } break; } return output; }, buildFromRegex: function (key, countryCode) { var output; if (Date.CultureStrings && Date.CultureStrings[countryCode] && Date.CultureStrings[countryCode][key]) { output = new RegExp(Date.CultureStrings[countryCode][key], "i"); } else { output = new RegExp(key.replace(new RegExp("/", "g"),""), "i"); } return output; } }; var shallowMerge = function (obj1, obj2) { for (var attrname in obj2) { if (obj2.hasOwnProperty(attrname)) { obj1[attrname] = obj2[attrname]; } } }; var __ = function (key, language) { var countryCode = (language) ? language : lang; loggedKeys[key] = key; if (typeof key === "object") { if (key instanceof Array) { return getText.getFromArray(key, countryCode); } else { return getText.getFromObjectKeys(key, countryCode); } } else { return getText.getFromKey(key, countryCode); } }; var loadI18nScript = function (code) { // paatterned after jQuery's getScript. var url = Date.Config.i18n + code + ".js"; var head = document.getElementsByTagName("head")[0] || document.documentElement; var script = document.createElement("script"); script.src = url; var completed = false; var events = { done: function (){} // placeholder function }; // Attach handlers for all browsers script.onload = script.onreadystatechange = function() { if ( !completed && (!this.readyState || this.readyState === "loaded" || this.readyState === "complete") ) { events.done(); head.removeChild(script); } }; setTimeout(function() { head.insertBefore(script, head.firstChild); }, 0); // allows return to execute first return { done: function (cb) { events.done = function() { if (cb) { setTimeout(cb,0); } }; } }; }; var buildInfo = { buildFromMethodHash: function (obj) { var key; for(key in obj) { if (obj.hasOwnProperty(key)) { obj[key] = buildInfo[obj[key]](); } } return obj; }, timeZoneDST: function () { var DST = { "CHADT": "+1345", "NZDT": "+1300", "AEDT": "+1100", "ACDT": "+1030", "AZST": "+0500", "IRDT": "+0430", "EEST": "+0300", "CEST": "+0200", "BST": "+0100", "PMDT": "-0200", "ADT": "-0300", "NDT": "-0230", "EDT": "-0400", "CDT": "-0500", "MDT": "-0600", "PDT": "-0700", "AKDT": "-0800", "HADT": "-0900" }; return __(DST); }, timeZoneStandard: function () { var standard = { "LINT": "+1400", "TOT": "+1300", "CHAST": "+1245", "NZST": "+1200", "NFT": "+1130", "SBT": "+1100", "AEST": "+1000", "ACST": "+0930", "JST": "+0900", "CWST": "+0845", "CT": "+0800", "ICT": "+0700", "MMT": "+0630", "BST": "+0600", "NPT": "+0545", "IST": "+0530", "PKT": "+0500", "AFT": "+0430", "MSK": "+0400", "IRST": "+0330", "FET": "+0300", "EET": "+0200", "CET": "+0100", "GMT": "+0000", "UTC": "+0000", "CVT": "-0100", "GST": "-0200", "BRT": "-0300", "NST": "-0330", "AST": "-0400", "EST": "-0500", "CST": "-0600", "MST": "-0700", "PST": "-0800", "AKST": "-0900", "MIT": "-0930", "HST": "-1000", "SST": "-1100", "BIT": "-1200" }; return __(standard); }, timeZones: function (data) { var zone; data.timezones = []; for (zone in data.abbreviatedTimeZoneStandard) { if (data.abbreviatedTimeZoneStandard.hasOwnProperty(zone)) { data.timezones.push({ name: zone, offset: data.abbreviatedTimeZoneStandard[zone]}); } } for (zone in data.abbreviatedTimeZoneDST) { if (data.abbreviatedTimeZoneDST.hasOwnProperty(zone)) { data.timezones.push({ name: zone, offset: data.abbreviatedTimeZoneDST[zone], dst: true}); } } return data.timezones; }, days: function () { return __(["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"]); }, dayAbbr: function () { return __(["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"]); }, dayShortNames: function () { return __(["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"]); }, dayFirstLetters: function () { return __(["S_Sun_Initial", "M_Mon_Initial", "T_Tues_Initial", "W_Wed_Initial", "T_Thu_Initial", "F_Fri_Initial", "S_Sat_Initial"]); }, months: function () { return __(["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"]); }, monthAbbr: function () { return __(["Jan_Abbr", "Feb_Abbr", "Mar_Abbr", "Apr_Abbr", "May_Abbr", "Jun_Abbr", "Jul_Abbr", "Aug_Abbr", "Sep_Abbr", "Oct_Abbr", "Nov_Abbr", "Dec_Abbr"]); }, formatPatterns: function () { return getText.getFromObjectValues({ shortDate: "M/d/yyyy", longDate: "dddd, MMMM dd, yyyy", shortTime: "h:mm tt", longTime: "h:mm:ss tt", fullDateTime: "dddd, MMMM dd, yyyy h:mm:ss tt", sortableDateTime: "yyyy-MM-ddTHH:mm:ss", universalSortableDateTime: "yyyy-MM-dd HH:mm:ssZ", rfc1123: "ddd, dd MMM yyyy HH:mm:ss", monthDay: "MMMM dd", yearMonth: "MMMM, yyyy" }, Date.i18n.currentLanguage()); }, regex: function () { return getText.getFromObjectValues({ inTheMorning: "/( in the )(morn(ing)?)\\b/", thisMorning: "/(this )(morn(ing)?)\\b/", amThisMorning: "/(\b\\d(am)? )(this )(morn(ing)?)/", inTheEvening: "/( in the )(even(ing)?)\\b/", thisEvening: "/(this )(even(ing)?)\\b/", pmThisEvening: "/(\b\\d(pm)? )(this )(even(ing)?)/", jan: "/jan(uary)?/", feb: "/feb(ruary)?/", mar: "/mar(ch)?/", apr: "/apr(il)?/", may: "/may/", jun: "/jun(e)?/", jul: "/jul(y)?/", aug: "/aug(ust)?/", sep: "/sep(t(ember)?)?/", oct: "/oct(ober)?/", nov: "/nov(ember)?/", dec: "/dec(ember)?/", sun: "/^su(n(day)?)?/", mon: "/^mo(n(day)?)?/", tue: "/^tu(e(s(day)?)?)?/", wed: "/^we(d(nesday)?)?/", thu: "/^th(u(r(s(day)?)?)?)?/", fri: "/fr(i(day)?)?/", sat: "/^sa(t(urday)?)?/", future: "/^next/", past: "/^last|past|prev(ious)?/", add: "/^(\\+|aft(er)?|from|hence)/", subtract: "/^(\\-|bef(ore)?|ago)/", yesterday: "/^yes(terday)?/", today: "/^t(od(ay)?)?/", tomorrow: "/^tom(orrow)?/", now: "/^n(ow)?/", millisecond: "/^ms|milli(second)?s?/", second: "/^sec(ond)?s?/", minute: "/^mn|min(ute)?s?/", hour: "/^h(our)?s?/", week: "/^w(eek)?s?/", month: "/^m(onth)?s?/", day: "/^d(ay)?s?/", year: "/^y(ear)?s?/", shortMeridian: "/^(a|p)/", longMeridian: "/^(a\\.?m?\\.?|p\\.?m?\\.?)/", timezone: "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/", ordinalSuffix: "/^\\s*(st|nd|rd|th)/", timeContext: "/^\\s*(\\:|a(?!u|p)|p)/" }, Date.i18n.currentLanguage()); } }; var CultureInfo = function () { var info = getText.getFromObjectValues({ name: "name", englishName: "englishName", nativeName: "nativeName", amDesignator: "AM", pmDesignator: "PM", firstDayOfWeek: "firstDayOfWeek", twoDigitYearMax: "twoDigitYearMax", dateElementOrder: "mdy" }, Date.i18n.currentLanguage()); var constructedInfo = buildInfo.buildFromMethodHash({ dayNames: "days", abbreviatedDayNames: "dayAbbr", shortestDayNames: "dayShortNames", firstLetterDayNames: "dayFirstLetters", monthNames: "months", abbreviatedMonthNames: "monthAbbr", formatPatterns: "formatPatterns", regexPatterns: "regex", abbreviatedTimeZoneDST: "timeZoneDST", abbreviatedTimeZoneStandard: "timeZoneStandard" }); shallowMerge(info, constructedInfo); buildInfo.timeZones(info); return info; }; $D.i18n = { __: function (key, lang) { return __(key, lang); }, currentLanguage: function () { return lang || "en-US"; }, setLanguage: function (code, force, cb) { var async = false; if (force || code === "en-US" || (!!Date.CultureStrings && !!Date.CultureStrings[code])) { lang = code; Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings.lang = code; Date.CultureInfo = new CultureInfo(); } else { if (!(!!Date.CultureStrings && !!Date.CultureStrings[code])) { if (typeof exports !== "undefined" && this.exports !== exports) { // we're in a Node enviroment, load it using require try { require("../i18n/" + code + ".js"); lang = code; Date.CultureStrings.lang = code; Date.CultureInfo = new CultureInfo(); } catch (e) { // var str = "The language for '" + code + "' could not be loaded by Node. It likely does not exist."; throw new Error("The DateJS IETF language tag '" + code + "' could not be loaded by Node. It likely does not exist."); } } else if (Date.Config && Date.Config.i18n) { // we know the location of the files, so lets load them async = true; loadI18nScript(code).done(function(){ lang = code; Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings.lang = code; Date.CultureInfo = new CultureInfo(); $D.Parsing.Normalizer.buildReplaceData(); // because this is async if ($D.Grammar) { $D.Grammar.buildGrammarFormats(); // so we can parse those strings... } if (cb) { setTimeout(cb,0); } }); } else { Date.console.error("The DateJS IETF language tag '" + code + "' is not available and has not been loaded."); return false; } } } $D.Parsing.Normalizer.buildReplaceData(); // rebuild normalizer strings if ($D.Grammar) { $D.Grammar.buildGrammarFormats(); // so we can parse those strings... } if (!async && cb) { setTimeout(cb,0); } }, getLoggedKeys: function () { return loggedKeys; }, updateCultureInfo: function () { Date.CultureInfo = new CultureInfo(); } }; $D.i18n.updateCultureInfo(); // run automatically }()); (function () { var $D = Date, $P = $D.prototype, p = function (s, l) { if (!l) { l = 2; } return ("000" + s).slice(l * -1); }; if (typeof window !== "undefined" && typeof window.console !== "undefined" && typeof window.console.log !== "undefined") { $D.console = console; // used only to raise non-critical errors if available } else { // set mock so we don't give errors. $D.console = { log: function(){}, error: function(){} }; } $D.Config = $D.Config || {}; $D.initOverloads = function() { /** * Overload of Date.now. Allows an alternate call for Date.now where it returns the * current Date as an object rather than just milliseconds since the Unix Epoch. * * Also provides an implementation of now() for browsers (IE<9) that don't have it. * * Backwards compatible so with work with either: * Date.now() [returns ms] * or * Date.now(true) [returns Date] */ if (!$D.now) { $D._now = function now() { return new Date().getTime(); }; } else if (!$D._now) { $D._now = $D.now; } $D.now = function (returnObj) { if (returnObj) { return $D.present(); } else { return $D._now(); } }; if ( !$P.toISOString ) { $P.toISOString = function() { return this.getUTCFullYear() + "-" + p(this.getUTCMonth() + 1) + "-" + p(this.getUTCDate()) + "T" + p(this.getUTCHours()) + ":" + p(this.getUTCMinutes()) + ":" + p(this.getUTCSeconds()) + "." + String( (this.getUTCMilliseconds()/1000).toFixed(3)).slice(2, 5) + "Z"; }; } // private if ( $P._toString === undefined ){ $P._toString = $P.toString; } }; $D.initOverloads(); /** * Gets a date that is set to the current date. The time is set to the start of the day (00:00 or 12:00 AM). * @return {Date} The current date. */ $D.today = function () { return new Date().clearTime(); }; /** * Gets a date that is set to the current date and time (same as new Date, but chainable) * @return {Date} The current date. */ $D.present = function () { return new Date(); }; /** * Compares the first date to the second date and returns an number indication of their relative values. * @param {Date} First Date object to compare [Required]. * @param {Date} Second Date object to compare to [Required]. * @return {Number} -1 = date1 is lessthan date2. 0 = values are equal. 1 = date1 is greaterthan date2. */ $D.compare = function (date1, date2) { if (isNaN(date1) || isNaN(date2)) { throw new Error(date1 + " - " + date2); } else if (date1 instanceof Date && date2 instanceof Date) { return (date1 < date2) ? -1 : (date1 > date2) ? 1 : 0; } else { throw new TypeError(date1 + " - " + date2); } }; /** * Compares the first Date object to the second Date object and returns true if they are equal. * @param {Date} First Date object to compare [Required] * @param {Date} Second Date object to compare to [Required] * @return {Boolean} true if dates are equal. false if they are not equal. */ $D.equals = function (date1, date2) { return (date1.compareTo(date2) === 0); }; /** * Gets the language appropriate day name when given the day number(0-6) * eg - 0 == Sunday * @return {String} The day name */ $D.getDayName = function (n) { return Date.CultureInfo.dayNames[n]; }; /** * Gets the day number (0-6) if given a CultureInfo specific string which is a valid dayName, abbreviatedDayName or shortestDayName (two char). * @param {String} The name of the day (eg. "Monday, "Mon", "tuesday", "tue", "We", "we"). * @return {Number} The day number */ $D.getDayNumberFromName = function (name) { var n = Date.CultureInfo.dayNames, m = Date.CultureInfo.abbreviatedDayNames, o = Date.CultureInfo.shortestDayNames, s = name.toLowerCase(); for (var i = 0; i < n.length; i++) { if (n[i].toLowerCase() === s || m[i].toLowerCase() === s || o[i].toLowerCase() === s) { return i; } } return -1; }; /** * Gets the month number (0-11) if given a Culture Info specific string which is a valid monthName or abbreviatedMonthName. * @param {String} The name of the month (eg. "February, "Feb", "october", "oct"). * @return {Number} The day number */ $D.getMonthNumberFromName = function (name) { var n = Date.CultureInfo.monthNames, m = Date.CultureInfo.abbreviatedMonthNames, s = name.toLowerCase(); for (var i = 0; i < n.length; i++) { if (n[i].toLowerCase() === s || m[i].toLowerCase() === s) { return i; } } return -1; }; /** * Gets the language appropriate month name when given the month number(0-11) * eg - 0 == January * @return {String} The month name */ $D.getMonthName = function (n) { return Date.CultureInfo.monthNames[n]; }; /** * Determines if the current date instance is within a LeapYear. * @param {Number} The year. * @return {Boolean} true if date is within a LeapYear, otherwise false. */ $D.isLeapYear = function (year) { return ((year % 4 === 0 && year % 100 !== 0) || year % 400 === 0); }; /** * Gets the number of days in the month, given a year and month value. Automatically corrects for LeapYear. * @param {Number} The year. * @param {Number} The month (0-11). * @return {Number} The number of days in the month. */ $D.getDaysInMonth = function (year, month) { if (!month && $D.validateMonth(year)) { month = year; year = Date.today().getFullYear(); } return [31, ($D.isLeapYear(year) ? 29 : 28), 31, 30, 31, 30, 31, 31, 30, 31, 30, 31][month]; }; $P.getDaysInMonth = function () { return $D.getDaysInMonth(this.getFullYear(), this.getMonth()); }; $D.getTimezoneAbbreviation = function (offset, dst) { var p, n = (dst || false) ? Date.CultureInfo.abbreviatedTimeZoneDST : Date.CultureInfo.abbreviatedTimeZoneStandard; for (p in n) { if (n.hasOwnProperty(p)) { if (n[p] === offset) { return p; } } } return null; }; $D.getTimezoneOffset = function (name, dst) { var i, a =[], z = Date.CultureInfo.timezones; if (!name) { name = (new Date()).getTimezone();} for (i = 0; i < z.length; i++) { if (z[i].name === name.toUpperCase()) { a.push(i); } } if (!z[a[0]]) { return null; } if (a.length === 1 || !dst) { return z[a[0]].offset; } else { for (i=0; i < a.length; i++) { if (z[a[i]].dst) { return z[a[i]].offset; } } } }; $D.getQuarter = function (d) { d = d || new Date(); // If no date supplied, use today var q = [1,2,3,4]; return q[Math.floor(d.getMonth() / 3)]; // ~~~ is a bitwise op. Faster than Math.floor }; $D.getDaysLeftInQuarter = function (d) { d = d || new Date(); var qEnd = new Date(d); qEnd.setMonth(qEnd.getMonth() + 3 - qEnd.getMonth() % 3, 0); return Math.floor((qEnd - d) / 8.64e7); }; // private var validate = function (n, min, max, name) { name = name ? name : "Object"; if (typeof n === "undefined") { return false; } else if (typeof n !== "number") { throw new TypeError(n + " is not a Number."); } else if (n < min || n > max) { // As failing validation is *not* an exceptional circumstance // lets not throw a RangeError Exception here. // It's semantically correct but it's not sensible. return false; } return true; }; /** * Validates the number is within an acceptable range for milliseconds [0-999]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateMillisecond = function (value) { return validate(value, 0, 999, "millisecond"); }; /** * Validates the number is within an acceptable range for seconds [0-59]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateSecond = function (value) { return validate(value, 0, 59, "second"); }; /** * Validates the number is within an acceptable range for minutes [0-59]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateMinute = function (value) { return validate(value, 0, 59, "minute"); }; /** * Validates the number is within an acceptable range for hours [0-23]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateHour = function (value) { return validate(value, 0, 23, "hour"); }; /** * Validates the number is within an acceptable range for the days in a month [0-MaxDaysInMonth]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateDay = function (value, year, month) { if (year === undefined || year === null || month === undefined || month === null) { return false;} return validate(value, 1, $D.getDaysInMonth(year, month), "day"); }; /** * Validates the number is within an acceptable range for months [0-11]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateWeek = function (value) { return validate(value, 0, 53, "week"); }; /** * Validates the number is within an acceptable range for months [0-11]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateMonth = function (value) { return validate(value, 0, 11, "month"); }; /** * Validates the number is within an acceptable range for years. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateYear = function (value) { /** * Per ECMAScript spec the range of times supported by Date objects is * exactly -100,000,000 days to +100,000,000 days measured relative to * midnight at the beginning of 01 January, 1970 UTC. * This gives a range of 8,640,000,000,000,000 milliseconds to either * side of 01 January, 1970 UTC. * * Earliest possible date: Tue, 20 Apr 271,822 B.C. 00:00:00 UTC * Latest possible date: Sat, 13 Sep 275,760 00:00:00 UTC */ return validate(value, -271822, 275760, "year"); }; $D.validateTimezone = function(value) { var timezones = {"ACDT":1,"ACST":1,"ACT":1,"ADT":1,"AEDT":1,"AEST":1,"AFT":1,"AKDT":1,"AKST":1,"AMST":1,"AMT":1,"ART":1,"AST":1,"AWDT":1,"AWST":1,"AZOST":1,"AZT":1,"BDT":1,"BIOT":1,"BIT":1,"BOT":1,"BRT":1,"BST":1,"BTT":1,"CAT":1,"CCT":1,"CDT":1,"CEDT":1,"CEST":1,"CET":1,"CHADT":1,"CHAST":1,"CHOT":1,"ChST":1,"CHUT":1,"CIST":1,"CIT":1,"CKT":1,"CLST":1,"CLT":1,"COST":1,"COT":1,"CST":1,"CT":1,"CVT":1,"CWST":1,"CXT":1,"DAVT":1,"DDUT":1,"DFT":1,"EASST":1,"EAST":1,"EAT":1,"ECT":1,"EDT":1,"EEDT":1,"EEST":1,"EET":1,"EGST":1,"EGT":1,"EIT":1,"EST":1,"FET":1,"FJT":1,"FKST":1,"FKT":1,"FNT":1,"GALT":1,"GAMT":1,"GET":1,"GFT":1,"GILT":1,"GIT":1,"GMT":1,"GST":1,"GYT":1,"HADT":1,"HAEC":1,"HAST":1,"HKT":1,"HMT":1,"HOVT":1,"HST":1,"ICT":1,"IDT":1,"IOT":1,"IRDT":1,"IRKT":1,"IRST":1,"IST":1,"JST":1,"KGT":1,"KOST":1,"KRAT":1,"KST":1,"LHST":1,"LINT":1,"MAGT":1,"MART":1,"MAWT":1,"MDT":1,"MET":1,"MEST":1,"MHT":1,"MIST":1,"MIT":1,"MMT":1,"MSK":1,"MST":1,"MUT":1,"MVT":1,"MYT":1,"NCT":1,"NDT":1,"NFT":1,"NPT":1,"NST":1,"NT":1,"NUT":1,"NZDT":1,"NZST":1,"OMST":1,"ORAT":1,"PDT":1,"PET":1,"PETT":1,"PGT":1,"PHOT":1,"PHT":1,"PKT":1,"PMDT":1,"PMST":1,"PONT":1,"PST":1,"PYST":1,"PYT":1,"RET":1,"ROTT":1,"SAKT":1,"SAMT":1,"SAST":1,"SBT":1,"SCT":1,"SGT":1,"SLST":1,"SRT":1,"SST":1,"SYOT":1,"TAHT":1,"THA":1,"TFT":1,"TJT":1,"TKT":1,"TLT":1,"TMT":1,"TOT":1,"TVT":1,"UCT":1,"ULAT":1,"UTC":1,"UYST":1,"UYT":1,"UZT":1,"VET":1,"VLAT":1,"VOLT":1,"VOST":1,"VUT":1,"WAKT":1,"WAST":1,"WAT":1,"WEDT":1,"WEST":1,"WET":1,"WST":1,"YAKT":1,"YEKT":1,"Z":1}; return (timezones[value] === 1); }; $D.validateTimezoneOffset= function(value) { // timezones go from +14hrs to -12hrs, the +X hours are negative offsets. return (value > -841 && value < 721); }; }()); (function () { var $D = Date, $P = $D.prototype, p = function (s, l) { if (!l) { l = 2; } return ("000" + s).slice(l * -1); }; var validateConfigObject = function (obj) { var result = {}, self = this, prop, testFunc; testFunc = function (prop, func, value) { if (prop === "day") { var month = (obj.month !== undefined) ? obj.month : self.getMonth(); var year = (obj.year !== undefined) ? obj.year : self.getFullYear(); return $D[func](value, year, month); } else { return $D[func](value); } }; for (prop in obj) { if (Object.prototype.hasOwnProperty.call(obj, prop)) { var func = "validate" + prop.charAt(0).toUpperCase() + prop.slice(1); if ($D[func] && obj[prop] !== null && testFunc(prop, func, obj[prop])) { result[prop] = obj[prop]; } } } return result; }; /** * Resets the time of this Date object to 12:00 AM (00:00), which is the start of the day. * @param {Boolean} .clone() this date instance before clearing Time * @return {Date} this */ $P.clearTime = function () { this.setHours(0); this.setMinutes(0); this.setSeconds(0); this.setMilliseconds(0); return this; }; /** * Resets the time of this Date object to the current time ('now'). * @return {Date} this */ $P.setTimeToNow = function () { var n = new Date(); this.setHours(n.getHours()); this.setMinutes(n.getMinutes()); this.setSeconds(n.getSeconds()); this.setMilliseconds(n.getMilliseconds()); return this; }; /** * Returns a new Date object that is an exact date and time copy of the original instance. * @return {Date} A new Date instance */ $P.clone = function () { return new Date(this.getTime()); }; /** * Compares this instance to a Date object and returns an number indication of their relative values. * @param {Date} Date object to compare [Required] * @return {Number} -1 = this is lessthan date. 0 = values are equal. 1 = this is greaterthan date. */ $P.compareTo = function (date) { return Date.compare(this, date); }; /** * Compares this instance to another Date object and returns true if they are equal. * @param {Date} Date object to compare. If no date to compare, new Date() [now] is used. * @return {Boolean} true if dates are equal. false if they are not equal. */ $P.equals = function (date) { return Date.equals(this, (date !== undefined ? date : new Date())); }; /** * Determines if this instance is between a range of two dates or equal to either the start or end dates. * @param {Date} Start of range [Required] * @param {Date} End of range [Required] * @return {Boolean} true is this is between or equal to the start and end dates, else false */ $P.between = function (start, end) { return this.getTime() >= start.getTime() && this.getTime() <= end.getTime(); }; /** * Determines if this date occurs after the date to compare to. * @param {Date} Date object to compare. If no date to compare, new Date() ("now") is used. * @return {Boolean} true if this date instance is greater than the date to compare to (or "now"), otherwise false. */ $P.isAfter = function (date) { return this.compareTo(date || new Date()) === 1; }; /** * Determines if this date occurs before the date to compare to. * @param {Date} Date object to compare. If no date to compare, new Date() ("now") is used. * @return {Boolean} true if this date instance is less than the date to compare to (or "now"). */ $P.isBefore = function (date) { return (this.compareTo(date || new Date()) === -1); }; /** * Determines if the current Date instance occurs today. * @return {Boolean} true if this date instance is 'today', otherwise false. */ /** * Determines if the current Date instance occurs on the same Date as the supplied 'date'. * If no 'date' to compare to is provided, the current Date instance is compared to 'today'. * @param {date} Date object to compare. If no date to compare, the current Date ("now") is used. * @return {Boolean} true if this Date instance occurs on the same Day as the supplied 'date'. */ $P.isToday = $P.isSameDay = function (date) { return this.clone().clearTime().equals((date || new Date()).clone().clearTime()); }; /** * Adds the specified number of milliseconds to this instance. * @param {Number} The number of milliseconds to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addMilliseconds = function (value) { if (!value) { return this; } this.setTime(this.getTime() + value * 1); return this; }; /** * Adds the specified number of seconds to this instance. * @param {Number} The number of seconds to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addSeconds = function (value) { if (!value) { return this; } return this.addMilliseconds(value * 1000); }; /** * Adds the specified number of seconds to this instance. * @param {Number} The number of seconds to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addMinutes = function (value) { if (!value) { return this; } return this.addMilliseconds(value * 60000); // 60*1000 }; /** * Adds the specified number of hours to this instance. * @param {Number} The number of hours to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addHours = function (value) { if (!value) { return this; } return this.addMilliseconds(value * 3600000); // 60*60*1000 }; /** * Adds the specified number of days to this instance. * @param {Number} The number of days to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addDays = function (value) { if (!value) { return this; } this.setDate(this.getDate() + value * 1); return this; }; /** * Adds the specified number of weekdays (ie - not sat or sun) to this instance. * @param {Number} The number of days to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addWeekdays = function (value) { if (!value) { return this; } var day = this.getDay(); var weeks = (Math.ceil(Math.abs(value)/7)); if (day === 0 || day === 6) { if (value > 0) { this.next().monday(); this.addDays(-1); day = this.getDay(); } } if (value < 0) { while (value < 0) { this.addDays(-1); day = this.getDay(); if (day !== 0 && day !== 6) { value++; } } return this; } else if (value > 5 || (6-day) <= value) { value = value + (weeks * 2); } return this.addDays(value); }; /** * Adds the specified number of weeks to this instance. * @param {Number} The number of weeks to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addWeeks = function (value) { if (!value) { return this; } return this.addDays(value * 7); }; /** * Adds the specified number of months to this instance. * @param {Number} The number of months to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addMonths = function (value) { if (!value) { return this; } var n = this.getDate(); this.setDate(1); this.setMonth(this.getMonth() + value * 1); this.setDate(Math.min(n, $D.getDaysInMonth(this.getFullYear(), this.getMonth()))); return this; }; $P.addQuarters = function (value) { if (!value) { return this; } // note this will take you to the same point in the quarter as you are now. // i.e. - if you are 15 days into the quarter you'll be 15 days into the resulting one. // bonus: this allows adding fractional quarters return this.addMonths(value * 3); }; /** * Adds the specified number of years to this instance. * @param {Number} The number of years to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addYears = function (value) { if (!value) { return this; } return this.addMonths(value * 12); }; /** * Adds (or subtracts) to the value of the years, months, weeks, days, hours, minutes, seconds, milliseconds of the date instance using given configuration object. Positive and Negative values allowed. * Example

	Date.today().add( { days: 1, months: 1 } )

	new Date().add( { years: -1 } )
	
* @param {Object} Configuration object containing attributes (months, days, etc.) * @return {Date} this */ $P.add = function (config) { if (typeof config === "number") { this._orient = config; return this; } var x = config; if (x.day) { // If we should be a different date than today (eg: for 'tomorrow -1d', etc). // Should only effect parsing, not direct usage (eg, Finish and FinishExact) if ((x.day - this.getDate()) !== 0) { this.setDate(x.day); } } if (x.milliseconds) { this.addMilliseconds(x.milliseconds); } if (x.seconds) { this.addSeconds(x.seconds); } if (x.minutes) { this.addMinutes(x.minutes); } if (x.hours) { this.addHours(x.hours); } if (x.weeks) { this.addWeeks(x.weeks); } if (x.months) { this.addMonths(x.months); } if (x.years) { this.addYears(x.years); } if (x.days) { this.addDays(x.days); } return this; }; /** * Get the week number. Week one (1) is the week which contains the first Thursday of the year. Monday is considered the first day of the week. * The .getWeek() function does NOT convert the date to UTC. The local datetime is used. * Please use .getISOWeek() to get the week of the UTC converted date. * @return {Number} 1 to 53 */ $P.getWeek = function (utc) { // Create a copy of this date object var self, target = new Date(this.valueOf()); if (utc) { target.addMinutes(target.getTimezoneOffset()); self = target.clone(); } else { self = this; } // ISO week date weeks start on monday // so correct the day number var dayNr = (self.getDay() + 6) % 7; // ISO 8601 states that week 1 is the week // with the first thursday of that year. // Set the target date to the thursday in the target week target.setDate(target.getDate() - dayNr + 3); // Store the millisecond value of the target date var firstThursday = target.valueOf(); // Set the target to the first thursday of the year // First set the target to january first target.setMonth(0, 1); // Not a thursday? Correct the date to the next thursday if (target.getDay() !== 4) { target.setMonth(0, 1 + ((4 - target.getDay()) + 7) % 7); } // The weeknumber is the number of weeks between the // first thursday of the year and the thursday in the target week return 1 + Math.ceil((firstThursday - target) / 604800000); // 604800000 = 7 * 24 * 3600 * 1000 }; /** * Get the ISO 8601 week number. Week one ("01") is the week which contains the first Thursday of the year. Monday is considered the first day of the week. * The .getISOWeek() function does convert the date to it's UTC value. Please use .getWeek() to get the week of the local date. * @return {String} "01" to "53" */ $P.getISOWeek = function () { return p(this.getWeek(true)); }; /** * Moves the date to Monday of the week set. Week one (1) is the week which contains the first Thursday of the year. * @param {Number} A Number (1 to 53) that represents the week of the year. * @return {Date} this */ $P.setWeek = function (n) { if ((n - this.getWeek()) === 0) { if (this.getDay() !== 1) { return this.moveToDayOfWeek(1, (this.getDay() > 1 ? -1 : 1)); } else { return this; } } else { return this.moveToDayOfWeek(1, (this.getDay() > 1 ? -1 : 1)).addWeeks(n - this.getWeek()); } }; $P.setQuarter = function (qtr) { var month = Math.abs(((qtr-1) * 3) + 1); return this.setMonth(month, 1); }; $P.getQuarter = function () { return Date.getQuarter(this); }; $P.getDaysLeftInQuarter = function () { return Date.getDaysLeftInQuarter(this); }; /** * Moves the date to the next n'th occurrence of the dayOfWeek starting from the beginning of the month. The number (-1) is a magic number and will return the last occurrence of the dayOfWeek in the month. * @param {Number} The dayOfWeek to move to * @param {Number} The n'th occurrence to move to. Use (-1) to return the last occurrence in the month * @return {Date} this */ $P.moveToNthOccurrence = function (dayOfWeek, occurrence) { if (dayOfWeek === "Weekday") { if (occurrence > 0) { this.moveToFirstDayOfMonth(); if (this.is().weekday()) { occurrence -= 1; } } else if (occurrence < 0) { this.moveToLastDayOfMonth(); if (this.is().weekday()) { occurrence += 1; } } else { return this; } return this.addWeekdays(occurrence); } var shift = 0; if (occurrence > 0) { shift = occurrence - 1; } else if (occurrence === -1) { this.moveToLastDayOfMonth(); if (this.getDay() !== dayOfWeek) { this.moveToDayOfWeek(dayOfWeek, -1); } return this; } return this.moveToFirstDayOfMonth().addDays(-1).moveToDayOfWeek(dayOfWeek, +1).addWeeks(shift); }; var moveToN = function (getFunc, addFunc, nVal) { return function (value, orient) { var diff = (value - this[getFunc]() + nVal * (orient || +1)) % nVal; return this[addFunc]((diff === 0) ? diff += nVal * (orient || +1) : diff); }; }; /** * Move to the next or last dayOfWeek based on the orient value. * @param {Number} The dayOfWeek to move to * @param {Number} Forward (+1) or Back (-1). Defaults to +1. [Optional] * @return {Date} this */ $P.moveToDayOfWeek = moveToN("getDay", "addDays", 7); /** * Move to the next or last month based on the orient value. * @param {Number} The month to move to. 0 = January, 11 = December * @param {Number} Forward (+1) or Back (-1). Defaults to +1. [Optional] * @return {Date} this */ $P.moveToMonth = moveToN("getMonth", "addMonths", 12); /** * Get the Ordinate of the current day ("th", "st", "rd"). * @return {String} */ $P.getOrdinate = function () { var num = this.getDate(); return ord(num); }; /** * Get the Ordinal day (numeric day number) of the year, adjusted for leap year. * @return {Number} 1 through 365 (366 in leap years) */ $P.getOrdinalNumber = function () { return Math.ceil((this.clone().clearTime() - new Date(this.getFullYear(), 0, 1)) / 86400000) + 1; }; /** * Get the time zone abbreviation of the current date. * @return {String} The abbreviated time zone name (e.g. "EST") */ $P.getTimezone = function () { return $D.getTimezoneAbbreviation(this.getUTCOffset(), this.isDaylightSavingTime()); }; $P.setTimezoneOffset = function (offset) { var here = this.getTimezoneOffset(), there = Number(offset) * -6 / 10; return (there || there === 0) ? this.addMinutes(there - here) : this; }; $P.setTimezone = function (offset) { return this.setTimezoneOffset($D.getTimezoneOffset(offset)); }; /** * Indicates whether Daylight Saving Time is observed in the current time zone. * @return {Boolean} true|false */ $P.hasDaylightSavingTime = function () { return (Date.today().set({month: 0, day: 1}).getTimezoneOffset() !== Date.today().set({month: 6, day: 1}).getTimezoneOffset()); }; /** * Indicates whether this Date instance is within the Daylight Saving Time range for the current time zone. * @return {Boolean} true|false */ $P.isDaylightSavingTime = function () { return Date.today().set({month: 0, day: 1}).getTimezoneOffset() !== this.getTimezoneOffset(); }; /** * Get the offset from UTC of the current date. * @return {String} The 4-character offset string prefixed with + or - (e.g. "-0500") */ $P.getUTCOffset = function (offset) { var n = (offset || this.getTimezoneOffset()) * -10 / 6, r; if (n < 0) { r = (n - 10000).toString(); return r.charAt(0) + r.substr(2); } else { r = (n + 10000).toString(); return "+" + r.substr(1); } }; /** * Returns the number of milliseconds between this date and date. * @param {Date} Defaults to now * @return {Number} The diff in milliseconds */ $P.getElapsed = function (date) { return (date || new Date()) - this; }; /** * Set the value of year, month, day, hour, minute, second, millisecond of date instance using given configuration object. * Example

	Date.today().set( { day: 20, month: 1 } )

	new Date().set( { millisecond: 0 } )
	
* * @param {Object} Configuration object containing attributes (month, day, etc.) * @return {Date} this */ $P.set = function (config) { config = validateConfigObject.call(this, config); var key; for (key in config) { if (Object.prototype.hasOwnProperty.call(config, key)) { var name = key.charAt(0).toUpperCase() + key.slice(1); var addFunc, getFunc; if (key !== "week" && key !== "month" && key !== "timezone" && key !== "timezoneOffset") { name += "s"; } addFunc = "add" + name; getFunc = "get" + name; if (key === "month") { addFunc = addFunc + "s"; } else if (key === "year"){ getFunc = "getFullYear"; } if (key !== "day" && key !== "timezone" && key !== "timezoneOffset" && key !== "week" && key !== "hour") { this[addFunc](config[key] - this[getFunc]()); } else if ( key === "timezone"|| key === "timezoneOffset" || key === "week" || key === "hour") { this["set"+name](config[key]); } } } // day has to go last because you can't validate the day without first knowing the month if (config.day) { this.addDays(config.day - this.getDate()); } return this; }; /** * Moves the date to the first day of the month. * @return {Date} this */ $P.moveToFirstDayOfMonth = function () { return this.set({ day: 1 }); }; /** * Moves the date to the last day of the month. * @return {Date} this */ $P.moveToLastDayOfMonth = function () { return this.set({ day: $D.getDaysInMonth(this.getFullYear(), this.getMonth())}); }; /** * Converts the value of the current Date object to its equivalent string representation. * Format Specifiers * CUSTOM DATE AND TIME FORMAT STRINGS * Format Description Example * ------ --------------------------------------------------------------------------- ----------------------- * s The seconds of the minute between 0-59. "0" to "59" * ss The seconds of the minute with leading zero if required. "00" to "59" * * m The minute of the hour between 0-59. "0" or "59" * mm The minute of the hour with leading zero if required. "00" or "59" * * h The hour of the day between 1-12. "1" to "12" * hh The hour of the day with leading zero if required. "01" to "12" * * H The hour of the day between 0-23. "0" to "23" * HH The hour of the day with leading zero if required. "00" to "23" * * d The day of the month between 1 and 31. "1" to "31" * dd The day of the month with leading zero if required. "01" to "31" * ddd Abbreviated day name. Date.CultureInfo.abbreviatedDayNames. "Mon" to "Sun" * dddd The full day name. Date.CultureInfo.dayNames. "Monday" to "Sunday" * * M The month of the year between 1-12. "1" to "12" * MM The month of the year with leading zero if required. "01" to "12" * MMM Abbreviated month name. Date.CultureInfo.abbreviatedMonthNames. "Jan" to "Dec" * MMMM The full month name. Date.CultureInfo.monthNames. "January" to "December" * * yy The year as a two-digit number. "99" or "08" * yyyy The full four digit year. "1999" or "2008" * * t Displays the first character of the A.M./P.M. designator. "A" or "P" * Date.CultureInfo.amDesignator or Date.CultureInfo.pmDesignator * tt Displays the A.M./P.M. designator. "AM" or "PM" * Date.CultureInfo.amDesignator or Date.CultureInfo.pmDesignator * * S The ordinal suffix ("st, "nd", "rd" or "th") of the current day. "st, "nd", "rd" or "th" * * STANDARD DATE AND TIME FORMAT STRINGS * Format Description Example *------ --------------------------------------------------------------------------- ----------------------- * d The CultureInfo shortDate Format Pattern "M/d/yyyy" * D The CultureInfo longDate Format Pattern "dddd, MMMM dd, yyyy" * F The CultureInfo fullDateTime Format Pattern "dddd, MMMM dd, yyyy h:mm:ss tt" * m The CultureInfo monthDay Format Pattern "MMMM dd" * r The CultureInfo rfc1123 Format Pattern "ddd, dd MMM yyyy HH:mm:ss GMT" * s The CultureInfo sortableDateTime Format Pattern "yyyy-MM-ddTHH:mm:ss" * t The CultureInfo shortTime Format Pattern "h:mm tt" * T The CultureInfo longTime Format Pattern "h:mm:ss tt" * u The CultureInfo universalSortableDateTime Format Pattern "yyyy-MM-dd HH:mm:ssZ" * y The CultureInfo yearMonth Format Pattern "MMMM, yyyy" * * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @return {String} A string representation of the current Date object. */ var ord = function (n) { switch (n * 1) { case 1: case 21: case 31: return "st"; case 2: case 22: return "nd"; case 3: case 23: return "rd"; default: return "th"; } }; var parseStandardFormats = function (format) { var y, c = Date.CultureInfo.formatPatterns; switch (format) { case "d": return this.toString(c.shortDate); case "D": return this.toString(c.longDate); case "F": return this.toString(c.fullDateTime); case "m": return this.toString(c.monthDay); case "r": case "R": y = this.clone().addMinutes(this.getTimezoneOffset()); return y.toString(c.rfc1123) + " GMT"; case "s": return this.toString(c.sortableDateTime); case "t": return this.toString(c.shortTime); case "T": return this.toString(c.longTime); case "u": y = this.clone().addMinutes(this.getTimezoneOffset()); return y.toString(c.universalSortableDateTime); case "y": return this.toString(c.yearMonth); default: return false; } }; var parseFormatStringsClosure = function (context) { return function (m) { if (m.charAt(0) === "\\") { return m.replace("\\", ""); } switch (m) { case "hh": return p(context.getHours() < 13 ? (context.getHours() === 0 ? 12 : context.getHours()) : (context.getHours() - 12)); case "h": return context.getHours() < 13 ? (context.getHours() === 0 ? 12 : context.getHours()) : (context.getHours() - 12); case "HH": return p(context.getHours()); case "H": return context.getHours(); case "mm": return p(context.getMinutes()); case "m": return context.getMinutes(); case "ss": return p(context.getSeconds()); case "s": return context.getSeconds(); case "yyyy": return p(context.getFullYear(), 4); case "yy": return p(context.getFullYear()); case "y": return context.getFullYear(); case "E": case "dddd": return Date.CultureInfo.dayNames[context.getDay()]; case "ddd": return Date.CultureInfo.abbreviatedDayNames[context.getDay()]; case "dd": return p(context.getDate()); case "d": return context.getDate(); case "MMMM": return Date.CultureInfo.monthNames[context.getMonth()]; case "MMM": return Date.CultureInfo.abbreviatedMonthNames[context.getMonth()]; case "MM": return p((context.getMonth() + 1)); case "M": return context.getMonth() + 1; case "t": return context.getHours() < 12 ? Date.CultureInfo.amDesignator.substring(0, 1) : Date.CultureInfo.pmDesignator.substring(0, 1); case "tt": return context.getHours() < 12 ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator; case "S": return ord(context.getDate()); case "W": return context.getWeek(); case "WW": return context.getISOWeek(); case "Q": return "Q" + context.getQuarter(); case "q": return String(context.getQuarter()); case "z": return context.getTimezone(); case "Z": case "X": return Date.getTimezoneOffset(context.getTimezone()); case "ZZ": // Timezone offset in seconds return context.getTimezoneOffset() * -60; case "u": return context.getDay(); case "L": return ($D.isLeapYear(context.getFullYear())) ? 1 : 0; case "B": // Swatch Internet Time (.beats) return "@"+((context.getUTCSeconds() + (context.getUTCMinutes()*60) + ((context.getUTCHours()+1)*3600))/86.4); default: return m; } }; }; $P.toString = function (format, ignoreStandards) { // Standard Date and Time Format Strings. Formats pulled from CultureInfo file and // may vary by culture. if (!ignoreStandards && format && format.length === 1) { output = parseStandardFormats.call(this, format); if (output) { return output; } } var parseFormatStrings = parseFormatStringsClosure(this); return format ? format.replace(/((\\)?(dd?d?d?|MM?M?M?|yy?y?y?|hh?|HH?|mm?|ss?|tt?|S|q|Q|WW?W?W?)(?![^\[]*\]))/g, parseFormatStrings).replace(/\[|\]/g, "") : this._toString(); }; }()); /************************************************************* * SugarPak - Domain Specific Language - Syntactical Sugar * *************************************************************/ (function () { var $D = Date, $P = $D.prototype, $N = Number.prototype; // private $P._orient = +1; // private $P._nth = null; // private $P._is = false; // private $P._same = false; // private $P._isSecond = false; // private $N._dateElement = "days"; /** * Moves the date to the next instance of a date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.today().next().friday();
	Date.today().next().fri();
	Date.today().next().march();
	Date.today().next().mar();
	Date.today().next().week();
	
* * @return {Date} date */ $P.next = function () { this._move = true; this._orient = +1; return this; }; /** * Creates a new Date (Date.today()) and moves the date to the next instance of the date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.next().friday();
	Date.next().fri();
	Date.next().march();
	Date.next().mar();
	Date.next().week();
	
* * @return {Date} date */ $D.next = function () { return $D.today().next(); }; /** * Moves the date to the previous instance of a date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.today().last().friday();
	Date.today().last().fri();
	Date.today().last().march();
	Date.today().last().mar();
	Date.today().last().week();
	
* * @return {Date} date */ $P.last = $P.prev = $P.previous = function () { this._move = true; this._orient = -1; return this; }; /** * Creates a new Date (Date.today()) and moves the date to the previous instance of the date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.last().friday();
	Date.last().fri();
	Date.previous().march();
	Date.prev().mar();
	Date.last().week();
	
* * @return {Date} date */ $D.last = $D.prev = $D.previous = function () { return $D.today().last(); }; /** * Performs a equality check when followed by either a month name, day name or .weekday() function. * Example

	Date.today().is().friday(); // true|false
	Date.today().is().fri();
	Date.today().is().march();
	Date.today().is().mar();
	
* * @return {Boolean} true|false */ $P.is = function () { this._is = true; return this; }; /** * Determines if two date objects occur on/in exactly the same instance of the subsequent date part function. * The function .same() must be followed by a date part function (example: .day(), .month(), .year(), etc). * * An optional Date can be passed in the date part function. If now date is passed as a parameter, 'Now' is used. * * The following example demonstrates how to determine if two dates fall on the exact same day. * * Example

	var d1 = Date.today(); // today at 00:00
	var d2 = new Date();   // exactly now.

	// Do they occur on the same day?
	d1.same().day(d2); // true
	
	// Do they occur on the same hour?
	d1.same().hour(d2); // false, unless d2 hour is '00' (midnight).
	
	// What if it's the same day, but one year apart?
	var nextYear = Date.today().add(1).year();

	d1.same().day(nextYear); // false, because the dates must occur on the exact same day. 
	
* * Scenario: Determine if a given date occurs during some week period 2 months from now. * * Example

	var future = Date.today().add(2).months();
	return someDate.same().week(future); // true|false;
	
* * @return {Boolean} true|false */ $P.same = function () { this._same = true; this._isSecond = false; return this; }; /** * Determines if the current date/time occurs during Today. Must be preceded by the .is() function. * Example

	someDate.is().today();    // true|false
	new Date().is().today();  // true
	Date.today().is().today();// true
	Date.today().add(-1).day().is().today(); // false
	
* * @return {Boolean} true|false */ $P.today = function () { return this.same().day(); }; /** * Determines if the current date is a weekday. This function must be preceded by the .is() function. * Example

	Date.today().is().weekday(); // true|false
	
* * @return {Boolean} true|false */ $P.weekday = function () { if (this._nth) { return df("Weekday").call(this); } if (this._move) { return this.addWeekdays(this._orient); } if (this._is) { this._is = false; return (!this.is().sat() && !this.is().sun()); } return false; }; /** * Determines if the current date is on the weekend. This function must be preceded by the .is() function. * Example

	Date.today().is().weekend(); // true|false
	
* * @return {Boolean} true|false */ $P.weekend = function () { if (this._is) { this._is = false; return (this.is().sat() || this.is().sun()); } return false; }; /** * Sets the Time of the current Date instance. A string "6:15 pm" or config object {hour:18, minute:15} are accepted. * Example

	// Set time to 6:15pm with a String
	Date.today().at("6:15pm");

	// Set time to 6:15pm with a config object
	Date.today().at({hour:18, minute:15});
	
* * @return {Date} date */ $P.at = function (time) { return (typeof time === "string") ? $D.parse(this.toString("d") + " " + time) : this.set(time); }; /** * Creates a new Date() and adds this (Number) to the date based on the preceding date element function (eg. second|minute|hour|day|month|year). * Example

	// Undeclared Numbers must be wrapped with parentheses. Requirment of JavaScript.
	(3).days().fromNow();
	(6).months().fromNow();

	// Declared Number variables do not require parentheses. 
	var n = 6;
	n.months().fromNow();
	
* * @return {Date} A new Date instance */ $N.fromNow = $N.after = function (date) { var c = {}; c[this._dateElement] = this; return ((!date) ? new Date() : date.clone()).add(c); }; /** * Creates a new Date() and subtract this (Number) from the date based on the preceding date element function (eg. second|minute|hour|day|month|year). * Example

	// Undeclared Numbers must be wrapped with parentheses. Requirment of JavaScript.
	(3).days().ago();
	(6).months().ago();

	// Declared Number variables do not require parentheses. 
	var n = 6;
	n.months().ago();
	
* * @return {Date} A new Date instance */ $N.ago = $N.before = function (date) { var c = {}, s = (this._dateElement[this._dateElement.length-1] !== "s") ? this._dateElement + "s" : this._dateElement; c[s] = this * -1; return ((!date) ? new Date() : date.clone()).add(c); }; // Do NOT modify the following string tokens. These tokens are used to build dynamic functions. // All culture-specific strings can be found in the CultureInfo files. var dx = ("sunday monday tuesday wednesday thursday friday saturday").split(/\s/), mx = ("january february march april may june july august september october november december").split(/\s/), px = ("Millisecond Second Minute Hour Day Week Month Year Quarter Weekday").split(/\s/), pxf = ("Milliseconds Seconds Minutes Hours Date Week Month FullYear Quarter").split(/\s/), nth = ("final first second third fourth fifth").split(/\s/), de; /** * Returns an object literal of all the date parts. * Example

	var o = new Date().toObject();
	
	// { year: 2008, month: 4, week: 20, day: 13, hour: 18, minute: 9, second: 32, millisecond: 812 }
	
	// The object properties can be referenced directly from the object.
	
	alert(o.day);  // alerts "13"
	alert(o.year); // alerts "2008"
	
* * @return {Date} An object literal representing the original date object. */ $P.toObject = function () { var o = {}; for (var i = 0; i < px.length; i++) { if (this["get" + pxf[i]]) { o[px[i].toLowerCase()] = this["get" + pxf[i]](); } } return o; }; /** * Returns a date created from an object literal. Ignores the .week property if set in the config. * Example

	var o = new Date().toObject();
	
	return Date.fromObject(o); // will return the same date. 

	var o2 = {month: 1, day: 20, hour: 18}; // birthday party!
	Date.fromObject(o2);
	
* * @return {Date} An object literal representing the original date object. */ $D.fromObject = function(config) { config.week = null; return Date.today().set(config); }; // Create day name functions and abbreviated day name functions (eg. monday(), friday(), fri()). var df = function (n) { return function () { if (this._is) { this._is = false; return this.getDay() === n; } if (this._move) { this._move = null; } if (this._nth !== null) { // If the .second() function was called earlier, remove the _orient // from the date, and then continue. // This is required because 'second' can be used in two different context. // // Example // // Date.today().add(1).second(); // Date.march().second().monday(); // // Things get crazy with the following... // Date.march().add(1).second().second().monday(); // but it works!! // if (this._isSecond) { this.addSeconds(this._orient * -1); } // make sure we reset _isSecond this._isSecond = false; var ntemp = this._nth; this._nth = null; var temp = this.clone().moveToLastDayOfMonth(); this.moveToNthOccurrence(n, ntemp); if (this > temp) { throw new RangeError($D.getDayName(n) + " does not occur " + ntemp + " times in the month of " + $D.getMonthName(temp.getMonth()) + " " + temp.getFullYear() + "."); } return this; } return this.moveToDayOfWeek(n, this._orient); }; }; var sdf = function (n) { return function () { var t = $D.today(), shift = n - t.getDay(); if (n === 0 && Date.CultureInfo.firstDayOfWeek === 1 && t.getDay() !== 0) { shift = shift + 7; } return t.addDays(shift); }; }; // Create month name functions and abbreviated month name functions (eg. january(), march(), mar()). var month_instance_functions = function (n) { return function () { if (this._is) { this._is = false; return this.getMonth() === n; } return this.moveToMonth(n, this._orient); }; }; var month_static_functions = function (n) { return function () { return $D.today().set({ month: n, day: 1 }); }; }; var processTerms = function (names, staticFunc, instanceFunc) { for (var i = 0; i < names.length; i++) { // Create constant static Name variables. $D[names[i].toUpperCase()] = $D[names[i].toUpperCase().substring(0, 3)] = i; // Create Name functions. $D[names[i]] = $D[names[i].substring(0, 3)] = staticFunc(i); // Create Name instance functions. $P[names[i]] = $P[names[i].substring(0, 3)] = instanceFunc(i); } }; processTerms(dx, sdf, df); processTerms(mx, month_static_functions, month_instance_functions); // Create date element functions and plural date element functions used with Date (eg. day(), days(), months()). var ef = function (j) { return function () { // if the .second() function was called earlier, the _orient // has alread been added. Just return this and reset _isSecond. if (this._isSecond) { this._isSecond = false; return this; } if (this._same) { this._same = this._is = false; var o1 = this.toObject(), o2 = (arguments[0] || new Date()).toObject(), v = "", k = j.toLowerCase(); // the substr trick with -1 doesn't work in IE8 or less k = (k[k.length-1] === "s") ? k.substring(0,k.length-1) : k; for (var m = (px.length - 1); m > -1; m--) { v = px[m].toLowerCase(); if (o1[v] !== o2[v]) { return false; } if (k === v) { break; } } return true; } if (j.substring(j.length - 1) !== "s") { j += "s"; } if (this._move) { this._move = null; } return this["add" + j](this._orient); }; }; var nf = function (n) { return function () { this._dateElement = n; return this; }; }; for (var k = 0; k < px.length; k++) { de = px[k].toLowerCase(); if(de !== "weekday") { // Create date element functions and plural date element functions used with Date (eg. day(), days(), months()). $P[de] = $P[de + "s"] = ef(px[k]); // Create date element functions and plural date element functions used with Number (eg. day(), days(), months()). $N[de] = $N[de + "s"] = nf(de + "s"); } } $P._ss = ef("Second"); var nthfn = function (n) { return function (dayOfWeek) { if (this._same) { return this._ss(arguments[0]); } if (dayOfWeek || dayOfWeek === 0) { return this.moveToNthOccurrence(dayOfWeek, n); } this._nth = n; // if the operator is 'second' add the _orient, then deal with it later... if (n === 2 && (dayOfWeek === undefined || dayOfWeek === null)) { this._isSecond = true; return this.addSeconds(this._orient); } return this; }; }; for (var l = 0; l < nth.length; l++) { $P[nth[l]] = (l === 0) ? nthfn(-1) : nthfn(l); } }()); (function () { "use strict"; Date.Parsing = { Exception: function (s) { this.message = "Parse error at '" + s.substring(0, 10) + " ...'"; } }; var $P = Date.Parsing; var dayOffsets = { standard: [0,31,59,90,120,151,181,212,243,273,304,334], leap: [0,31,60,91,121,152,182,213,244,274,305,335] }; $P.isLeapYear = function(year) { return ((year % 4 === 0) && (year % 100 !== 0)) || (year % 400 === 0); }; var utils = { multiReplace : function (str, hash ) { var key; for (key in hash) { if (Object.prototype.hasOwnProperty.call(hash, key)) { var regex; if (typeof hash[key] === "function") { } else { regex = (hash[key] instanceof RegExp) ? hash[key] : new RegExp(hash[key], "g"); } str = str.replace(regex, key); } } return str; }, getDayOfYearFromWeek : function (obj) { var d, jan4, offset; obj.weekDay = (!obj.weekDay && obj.weekDay !== 0) ? 1 : obj.weekDay; d = new Date(obj.year, 0, 4); jan4 = d.getDay() === 0 ? 7 : d.getDay(); // JS is 0 indexed on Sunday. offset = jan4+3; obj.dayOfYear = ((obj.week * 7) + (obj.weekDay === 0 ? 7 : obj.weekDay))-offset; return obj; }, getDayOfYear : function (obj, dayOffset) { if (!obj.dayOfYear) { obj = utils.getDayOfYearFromWeek(obj); } for (var i=0;i <= dayOffset.length;i++) { if (obj.dayOfYear < dayOffset[i] || i === dayOffset.length) { obj.day = obj.day ? obj.day : (obj.dayOfYear - dayOffset[i-1]); break; } else { obj.month = i; } } return obj; }, adjustForTimeZone : function (obj, date) { var offset; if (obj.zone.toUpperCase() === "Z" || (obj.zone_hours === 0 && obj.zone_minutes === 0)) { // it's UTC/GML so work out the current timeszone offset offset = -date.getTimezoneOffset(); } else { offset = (obj.zone_hours*60) + (obj.zone_minutes || 0); if (obj.zone_sign === "+") { offset *= -1; } offset -= date.getTimezoneOffset(); } date.setMinutes(date.getMinutes()+offset); return date; }, setDefaults : function (obj) { obj.year = obj.year || Date.today().getFullYear(); obj.hours = obj.hours || 0; obj.minutes = obj.minutes || 0; obj.seconds = obj.seconds || 0; obj.milliseconds = obj.milliseconds || 0; if (!(!obj.month && (obj.week || obj.dayOfYear))) { // if we have a month, or if we don't but don't have the day calculation data obj.month = obj.month || 0; obj.day = obj.day || 1; } return obj; }, dataNum: function (data, mod, explict, postProcess) { var dataNum = data*1; if (mod) { if (postProcess) { return data ? mod(data)*1 : data; } else { return data ? mod(dataNum) : data; } } else if (!explict){ return data ? dataNum : data; } else { return (data && typeof data !== "undefined") ? dataNum : data; } }, timeDataProcess: function (obj) { var timeObj = {}; for (var x in obj.data) { if (obj.data.hasOwnProperty(x)) { timeObj[x] = obj.ignore[x] ? obj.data[x] : utils.dataNum(obj.data[x], obj.mods[x], obj.explict[x], obj.postProcess[x]); } } if (obj.data.secmins) { obj.data.secmins = obj.data.secmins.replace(",", ".") * 60; if (!timeObj.minutes) { timeObj.minutes = obj.data.secmins; } else if (!timeObj.seconds) { timeObj.seconds = obj.data.secmins; } delete obj.secmins; } return timeObj; }, buildTimeObjectFromData: function (data) { var time = utils.timeDataProcess({ data: { year : data[1], month : data[5], day : data[7], week : data[8], dayOfYear : data[10], hours : data[15], zone_hours : data[23], zone_minutes : data[24], zone : data[21], zone_sign : data[22], weekDay : data[9], minutes: data[16], seconds: data[19], milliseconds: data[20], secmins: data[18] }, mods: { month: function(data) { return data-1; }, weekDay: function (data) { data = Math.abs(data); return (data === 7 ? 0 : data); }, minutes: function (data) { return data.replace(":",""); }, seconds: function (data) { return Math.floor( (data.replace(":","").replace(",","."))*1 ); }, milliseconds: function (data) { return (data.replace(",",".")*1000); } }, postProcess: { minutes: true, seconds: true, milliseconds: true }, explict: { zone_hours: true, zone_minutes: true }, ignore: { zone: true, zone_sign: true, secmins: true } }); return time; }, addToHash: function (hash, keys, data) { keys = keys; data = data; var len = keys.length; for (var i = 0; i < len; i++) { hash[keys[i]] = data[i]; } return hash; }, combineRegex: function (r1, r2) { return new RegExp("(("+r1.source+")\\s("+r2.source+"))"); }, getDateNthString: function(add, last, inc){ if (add) { return Date.today().addDays(inc).toString("d"); } else if (last) { return Date.today().last()[inc]().toString("d"); } }, buildRegexData: function (array) { var arr = []; var len = array.length; for (var i=0; i < len; i++) { if (Object.prototype.toString.call(array[i]) === '[object Array]') { // oldIE compat version of Array.isArray arr.push(this.combineRegex(array[i][0], array[i][1])); } else { arr.push(array[i]); } } return arr; } }; $P.processTimeObject = function (obj) { var date, dayOffset; utils.setDefaults(obj); dayOffset = ($P.isLeapYear(obj.year)) ? dayOffsets.leap : dayOffsets.standard; if (!obj.month && (obj.week || obj.dayOfYear)) { utils.getDayOfYear(obj, dayOffset); } else { obj.dayOfYear = dayOffset[obj.month] + obj.day; } date = new Date(obj.year, obj.month, obj.day, obj.hours, obj.minutes, obj.seconds, obj.milliseconds); if (obj.zone) { utils.adjustForTimeZone(obj, date); // adjust (and calculate) for timezone } return date; }; $P.ISO = { regex : /^([\+-]?\d{4}(?!\d{2}\b))((-?)((0[1-9]|1[0-2])(\3([12]\d|0[1-9]|3[01]))?|W([0-4]\d|5[0-3])(-?[1-7])?|(00[1-9]|0[1-9]\d|[12]\d{2}|3([0-5]\d|6[1-6])))([T\s]((([01]\d|2[0-4])((:?)[0-5]\d)?|24\:?00)([\.,]\d+(?!:))?)?(\17[0-5]\d([\.,]\d+)?)?\s?([zZ]|([\+-])([01]\d|2[0-3]):?([0-5]\d)?)?)?)?$/, parse : function (s) { var time, data = s.match(this.regex); if (!data || !data.length) { return null; } time = utils.buildTimeObjectFromData(data); if (!time.year || (!time.year && (!time.month && !time.day) && (!time.week && !time.dayOfYear)) ) { return null; } return $P.processTimeObject(time); } }; $P.Numeric = { isNumeric: function (e){return!isNaN(parseFloat(e))&&isFinite(e);}, regex: /\b([0-1]?[0-9])([0-3]?[0-9])([0-2]?[0-9]?[0-9][0-9])\b/i, parse: function (s) { var data, i, time = {}, order = Date.CultureInfo.dateElementOrder.split(""); if (!(this.isNumeric(s)) || // if it's non-numeric OR (s[0] === "+" && s[0] === "-")) { // It's an arithmatic string (eg +/-1000) return null; } if (s.length < 5 && s.indexOf(".") < 0 && s.indexOf("/") < 0) { // assume it's just a year. time.year = s; return $P.processTimeObject(time); } data = s.match(this.regex); if (!data || !data.length) { return null; } for (i=0; i < order.length; i++) { switch(order[i]) { case "d": time.day = data[i+1]; break; case "m": time.month = (data[i+1]-1); break; case "y": time.year = data[i+1]; break; } } return $P.processTimeObject(time); } }; $P.Normalizer = { regexData: function () { var $R = Date.CultureInfo.regexPatterns; return utils.buildRegexData([ $R.tomorrow, $R.yesterday, [$R.past, $R.mon], [$R.past, $R.tue], [$R.past, $R.wed], [$R.past, $R.thu], [$R.past, $R.fri], [$R.past, $R.sat], [$R.past, $R.sun] ]); }, basicReplaceHash : function() { var $R = Date.CultureInfo.regexPatterns; return { "January": $R.jan.source, "February": $R.feb, "March": $R.mar, "April": $R.apr, "May": $R.may, "June": $R.jun, "July": $R.jul, "August": $R.aug, "September": $R.sep, "October": $R.oct, "November": $R.nov, "December": $R.dec, "": /\bat\b/gi, " ": /\s{2,}/, "am": $R.inTheMorning, "9am": $R.thisMorning, "pm": $R.inTheEvening, "7pm":$R.thisEvening }; }, keys : function(){ return [ utils.getDateNthString(true, false, 1), // tomorrow utils.getDateNthString(true, false, -1), // yesterday utils.getDateNthString(false, true, "monday"), //last mon utils.getDateNthString(false, true, "tuesday"), //last tues utils.getDateNthString(false, true, "wednesday"), //last wed utils.getDateNthString(false, true, "thursday"), //last thurs utils.getDateNthString(false, true, "friday"), //last fri utils.getDateNthString(false, true, "saturday"), //last sat utils.getDateNthString(false, true, "sunday") //last sun ]; }, buildRegexFunctions: function () { var $R = Date.CultureInfo.regexPatterns; var __ = Date.i18n.__; var tomorrowRE = new RegExp("(\\b\\d\\d?("+__("AM")+"|"+__("PM")+")? )("+$R.tomorrow.source.slice(1)+")", "i"); // adapted tomorrow regex for AM PM relative dates var todayRE = new RegExp($R.today.source + "(?!\\s*([+-]))\\b"); // today, but excludes the math operators (eg "today + 2h") this.replaceFuncs = [ [todayRE, function (full) { return (full.length > 1) ? Date.today().toString("d") : full; }], [tomorrowRE, function(full, m1) { var t = Date.today().addDays(1).toString("d"); return (t + " " + m1); }], [$R.amThisMorning, function(str, am){return am;}], [$R.pmThisEvening, function(str, pm){return pm;}] ]; }, buildReplaceData: function () { this.buildRegexFunctions(); this.replaceHash = utils.addToHash(this.basicReplaceHash(), this.keys(), this.regexData()); }, stringReplaceFuncs: function (s) { for (var i=0; i < this.replaceFuncs.length; i++) { s = s.replace(this.replaceFuncs[i][0], this.replaceFuncs[i][1]); } return s; }, parse: function (s) { s = this.stringReplaceFuncs(s); s = utils.multiReplace(s, this.replaceHash); try { var n = s.split(/([\s\-\.\,\/\x27]+)/); if (n.length === 3 && $P.Numeric.isNumeric(n[0]) && $P.Numeric.isNumeric(n[2]) && (n[2].length >= 4)) { // ok, so we're dealing with x/year. But that's not a full date. // This fixes wonky dateElementOrder parsing when set to dmy order. if (Date.CultureInfo.dateElementOrder[0] === "d") { s = "1/" + n[0] + "/" + n[2]; // set to 1st of month and normalize the seperator } } } catch (e) {} return s; } }; $P.Normalizer.buildReplaceData(); }()); (function () { var $P = Date.Parsing; var _ = $P.Operators = { // // Tokenizers // rtoken: function (r) { // regex token return function (s) { var mx = s.match(r); if (mx) { return ([ mx[0], s.substring(mx[0].length) ]); } else { throw new $P.Exception(s); } }; }, token: function () { // whitespace-eating token return function (s) { return _.rtoken(new RegExp("^\\s*" + s + "\\s*"))(s); }; }, stoken: function (s) { // string token return _.rtoken(new RegExp("^" + s)); }, // Atomic Operators until: function (p) { return function (s) { var qx = [], rx = null; while (s.length) { try { rx = p.call(this, s); } catch (e) { qx.push(rx[0]); s = rx[1]; continue; } break; } return [ qx, s ]; }; }, many: function (p) { return function (s) { var rx = [], r = null; while (s.length) { try { r = p.call(this, s); } catch (e) { return [ rx, s ]; } rx.push(r[0]); s = r[1]; } return [ rx, s ]; }; }, // generator operators -- see below optional: function (p) { return function (s) { var r = null; try { r = p.call(this, s); } catch (e) { return [ null, s ]; } return [ r[0], r[1] ]; }; }, not: function (p) { return function (s) { try { p.call(this, s); } catch (e) { return [null, s]; } throw new $P.Exception(s); }; }, ignore: function (p) { return p ? function (s) { var r = null; r = p.call(this, s); return [null, r[1]]; } : null; }, product: function () { var px = arguments[0], qx = Array.prototype.slice.call(arguments, 1), rx = []; for (var i = 0 ; i < px.length ; i++) { rx.push(_.each(px[i], qx)); } return rx; }, cache: function (rule) { var cache = {}, cache_length = 0, cache_keys = [], CACHE_MAX = Date.Config.CACHE_MAX || 100000, r = null; var cacheCheck = function () { if (cache_length === CACHE_MAX) { // kill several keys, don't want to have to do this all the time... for (var i=0; i < 10; i++) { var key = cache_keys.shift(); if (key) { delete cache[key]; cache_length--; } } } }; return function (s) { cacheCheck(); try { r = cache[s] = (cache[s] || rule.call(this, s)); } catch (e) { r = cache[s] = e; } cache_length++; cache_keys.push(s); if (r instanceof $P.Exception) { throw r; } else { return r; } }; }, // vector operators -- see below any: function () { var px = arguments; return function (s) { var r = null; for (var i = 0; i < px.length; i++) { if (px[i] == null) { continue; } try { r = (px[i].call(this, s)); } catch (e) { r = null; } if (r) { return r; } } throw new $P.Exception(s); }; }, each: function () { var px = arguments; return function (s) { var rx = [], r = null; for (var i = 0; i < px.length ; i++) { if (px[i] == null) { continue; } try { r = (px[i].call(this, s)); } catch (e) { throw new $P.Exception(s); } rx.push(r[0]); s = r[1]; } return [ rx, s]; }; }, all: function () { var px = arguments, _ = _; return _.each(_.optional(px)); }, // delimited operators sequence: function (px, d, c) { d = d || _.rtoken(/^\s*/); c = c || null; if (px.length === 1) { return px[0]; } return function (s) { var r = null, q = null; var rx = []; for (var i = 0; i < px.length ; i++) { try { r = px[i].call(this, s); } catch (e) { break; } rx.push(r[0]); try { q = d.call(this, r[1]); } catch (ex) { q = null; break; } s = q[1]; } if (!r) { throw new $P.Exception(s); } if (q) { throw new $P.Exception(q[1]); } if (c) { try { r = c.call(this, r[1]); } catch (ey) { throw new $P.Exception(r[1]); } } return [ rx, (r?r[1]:s) ]; }; }, // // Composite Operators // between: function (d1, p, d2) { d2 = d2 || d1; var _fn = _.each(_.ignore(d1), p, _.ignore(d2)); return function (s) { var rx = _fn.call(this, s); return [[rx[0][0], r[0][2]], rx[1]]; }; }, list: function (p, d, c) { d = d || _.rtoken(/^\s*/); c = c || null; return (p instanceof Array ? _.each(_.product(p.slice(0, -1), _.ignore(d)), p.slice(-1), _.ignore(c)) : _.each(_.many(_.each(p, _.ignore(d))), px, _.ignore(c))); }, set: function (px, d, c) { d = d || _.rtoken(/^\s*/); c = c || null; return function (s) { // r is the current match, best the current 'best' match // which means it parsed the most amount of input var r = null, p = null, q = null, rx = null, best = [[], s], last = false; // go through the rules in the given set for (var i = 0; i < px.length ; i++) { // last is a flag indicating whether this must be the last element // if there is only 1 element, then it MUST be the last one q = null; p = null; r = null; last = (px.length === 1); // first, we try simply to match the current pattern // if not, try the next pattern try { r = px[i].call(this, s); } catch (e) { continue; } // since we are matching against a set of elements, the first // thing to do is to add r[0] to matched elements rx = [[r[0]], r[1]]; // if we matched and there is still input to parse and // we don't already know this is the last element, // we're going to next check for the delimiter ... // if there's none, or if there's no input left to parse // than this must be the last element after all ... if (r[1].length > 0 && ! last) { try { q = d.call(this, r[1]); } catch (ex) { last = true; } } else { last = true; } // if we parsed the delimiter and now there's no more input, // that means we shouldn't have parsed the delimiter at all // so don't update r and mark this as the last element ... if (!last && q[1].length === 0) { last = true; } // so, if this isn't the last element, we're going to see if // we can get any more matches from the remaining (unmatched) // elements ... if (!last) { // build a list of the remaining rules we can match against, // i.e., all but the one we just matched against var qx = []; for (var j = 0; j < px.length ; j++) { if (i !== j) { qx.push(px[j]); } } // now invoke recursively set with the remaining input // note that we don't include the closing delimiter ... // we'll check for that ourselves at the end p = _.set(qx, d).call(this, q[1]); // if we got a non-empty set as a result ... // (otw rx already contains everything we want to match) if (p[0].length > 0) { // update current result, which is stored in rx ... // basically, pick up the remaining text from p[1] // and concat the result from p[0] so that we don't // get endless nesting ... rx[0] = rx[0].concat(p[0]); rx[1] = p[1]; } } // at this point, rx either contains the last matched element // or the entire matched set that starts with this element. // now we just check to see if this variation is better than // our best so far, in terms of how much of the input is parsed if (rx[1].length < best[1].length) { best = rx; } // if we've parsed all the input, then we're finished if (best[1].length === 0) { break; } } // so now we've either gone through all the patterns trying them // as the initial match; or we found one that parsed the entire // input string ... // if best has no matches, just return empty set ... if (best[0].length === 0) { return best; } // if a closing delimiter is provided, then we have to check it also if (c) { // we try this even if there is no remaining input because the pattern // may well be optional or match empty input ... try { q = c.call(this, best[1]); } catch (ey) { throw new $P.Exception(best[1]); } // it parsed ... be sure to update the best match remaining input best[1] = q[1]; } // if we're here, either there was no closing delimiter or we parsed it // so now we have the best match; just return it! return best; }; }, forward: function (gr, fname) { return function (s) { return gr[fname].call(this, s); }; }, // // Translation Operators // replace: function (rule, repl) { return function (s) { var r = rule.call(this, s); return [repl, r[1]]; }; }, process: function (rule, fn) { return function (s) { var r = rule.call(this, s); return [fn.call(this, r[0]), r[1]]; }; }, min: function (min, rule) { return function (s) { var rx = rule.call(this, s); if (rx[0].length < min) { throw new $P.Exception(s); } return rx; }; } }; // Generator Operators And Vector Operators // Generators are operators that have a signature of F(R) => R, // taking a given rule and returning another rule, such as // ignore, which parses a given rule and throws away the result. // Vector operators are those that have a signature of F(R1,R2,...) => R, // take a list of rules and returning a new rule, such as each. // Generator operators are converted (via the following _generator // function) into functions that can also take a list or array of rules // and return an array of new rules as though the function had been // called on each rule in turn (which is what actually happens). // This allows generators to be used with vector operators more easily. // Example: // each(ignore(foo, bar)) instead of each(ignore(foo), ignore(bar)) // This also turns generators into vector operators, which allows // constructs like: // not(cache(foo, bar)) var _generator = function (op) { function gen() { var args = null, rx = [], px, i; if (arguments.length > 1) { args = Array.prototype.slice.call(arguments); } else if (arguments[0] instanceof Array) { args = arguments[0]; } if (args) { px = args.shift(); if (px.length > 0) { args.unshift(px[i]); rx.push(op.apply(null, args)); args.shift(); return rx; } } else { return op.apply(null, arguments); } } return gen; }; var gx = "optional not ignore cache".split(/\s/); for (var i = 0 ; i < gx.length ; i++) { _[gx[i]] = _generator(_[gx[i]]); } var _vector = function (op) { return function () { if (arguments[0] instanceof Array) { return op.apply(null, arguments[0]); } else { return op.apply(null, arguments); } }; }; var vx = "each any all".split(/\s/); for (var j = 0 ; j < vx.length ; j++) { _[vx[j]] = _vector(_[vx[j]]); } }()); (function () { var $D = Date; var flattenAndCompact = function (ax) { var rx = []; for (var i = 0; i < ax.length; i++) { if (ax[i] instanceof Array) { rx = rx.concat(flattenAndCompact(ax[i])); } else { if (ax[i]) { rx.push(ax[i]); } } } return rx; }; var parseMeridian = function () { if (this.meridian && (this.hour || this.hour === 0)) { if (this.meridian === "a" && this.hour > 11 && Date.Config.strict24hr){ throw "Invalid hour and meridian combination"; } else if (this.meridian === "p" && this.hour < 12 && Date.Config.strict24hr){ throw "Invalid hour and meridian combination"; } else if (this.meridian === "p" && this.hour < 12) { this.hour = this.hour + 12; } else if (this.meridian === "a" && this.hour === 12) { this.hour = 0; } } }; var setDefaults = function () { var now = new Date(); if ((this.hour || this.minute) && (!this.month && !this.year && !this.day)) { this.day = now.getDate(); } if (!this.year) { this.year = now.getFullYear(); } if (!this.month && this.month !== 0) { this.month = now.getMonth(); } if (!this.day) { this.day = 1; } if (!this.hour) { this.hour = 0; } if (!this.minute) { this.minute = 0; } if (!this.second) { this.second = 0; } if (!this.millisecond) { this.millisecond = 0; } }; var finishUtils = { getToday: function () { if (this.now || "hour minute second".indexOf(this.unit) !== -1) { return new Date(); } else { return $D.today(); } }, setDaysFromWeekday: function (today, orient){ var gap; orient = orient || 1; this.unit = "day"; gap = ($D.getDayNumberFromName(this.weekday) - today.getDay()); this.days = gap ? ((gap + (orient * 7)) % 7) : (orient * 7); return this; }, setMonthsFromMonth: function (today, orient) { var gap; orient = orient || 1; this.unit = "month"; gap = (this.month - today.getMonth()); this.months = gap ? ((gap + (orient * 12)) % 12) : (orient * 12); this.month = null; return this; }, setDMYFromWeekday: function () { var d = Date[this.weekday](); this.day = d.getDate(); if (!this.month) { this.month = d.getMonth(); } this.year = d.getFullYear(); return this; }, setUnitValue: function (orient) { if (!this.value && this.operator && this.operator !== null && this[this.unit + "s"] && this[this.unit + "s"] !== null) { this[this.unit + "s"] = this[this.unit + "s"] + ((this.operator === "add") ? 1 : -1) + (this.value||0) * orient; } else if (this[this.unit + "s"] == null || this.operator != null) { if (!this.value) { this.value = 1; } this[this.unit + "s"] = this.value * orient; } }, generateDateFromWeeks: function () { var weekday = (this.weekday !== undefined) ? this.weekday : "today"; var d = Date[weekday]().addWeeks(this.weeks); if (this.now) { d.setTimeToNow(); } return d; } }; $D.Translator = { hour: function (s) { return function () { this.hour = Number(s); }; }, minute: function (s) { return function () { this.minute = Number(s); }; }, second: function (s) { return function () { this.second = Number(s); }; }, /* for ss.s format */ secondAndMillisecond: function (s) { return function () { var mx = s.match(/^([0-5][0-9])\.([0-9]{1,3})/); this.second = Number(mx[1]); this.millisecond = Number(mx[2]); }; }, meridian: function (s) { return function () { this.meridian = s.slice(0, 1).toLowerCase(); }; }, timezone: function (s) { return function () { var n = s.replace(/[^\d\+\-]/g, ""); if (n.length) { this.timezoneOffset = Number(n); } else { this.timezone = s.toLowerCase(); } }; }, day: function (x) { var s = x[0]; return function () { this.day = Number(s.match(/\d+/)[0]); if (this.day < 1) { throw "invalid day"; } }; }, month: function (s) { return function () { this.month = (s.length === 3) ? "jan feb mar apr may jun jul aug sep oct nov dec".indexOf(s)/4 : Number(s) - 1; if (this.month < 0) { throw "invalid month"; } }; }, year: function (s) { return function () { var n = Number(s); this.year = ((s.length > 2) ? n : (n + (((n + 2000) < Date.CultureInfo.twoDigitYearMax) ? 2000 : 1900))); }; }, rday: function (s) { return function () { switch (s) { case "yesterday": this.days = -1; break; case "tomorrow": this.days = 1; break; case "today": this.days = 0; break; case "now": this.days = 0; this.now = true; break; } }; }, finishExact: function (x) { var d; x = (x instanceof Array) ? x : [x]; for (var i = 0 ; i < x.length ; i++) { if (x[i]) { x[i].call(this); } } setDefaults.call(this); parseMeridian.call(this); if (this.day > $D.getDaysInMonth(this.year, this.month)) { throw new RangeError(this.day + " is not a valid value for days."); } d = new Date(this.year, this.month, this.day, this.hour, this.minute, this.second, this.millisecond); if (this.year < 100) { d.setFullYear(this.year); // means years less that 100 are process correctly. JS will parse it otherwise as 1900-1999. } if (this.timezone) { d.set({ timezone: this.timezone }); } else if (this.timezoneOffset) { d.set({ timezoneOffset: this.timezoneOffset }); } return d; }, finish: function (x) { var today, expression, orient, temp; x = (x instanceof Array) ? flattenAndCompact(x) : [ x ]; if (x.length === 0) { return null; } for (var i = 0 ; i < x.length ; i++) { if (typeof x[i] === "function") { x[i].call(this); } } if (this.now && !this.unit && !this.operator) { return new Date(); } else { today = finishUtils.getToday.call(this); } expression = !!(this.days && this.days !== null || this.orient || this.operator); orient = ((this.orient === "past" || this.operator === "subtract") ? -1 : 1); if (this.month && this.unit === "week") { this.value = this.month + 1; delete this.month; delete this.day; } if ((this.month || this.month === 0) && "year day hour minute second".indexOf(this.unit) !== -1) { if (!this.value) { this.value = this.month + 1; } this.month = null; expression = true; } if (!expression && this.weekday && !this.day && !this.days) { finishUtils.setDMYFromWeekday.call(this); } if (expression && this.weekday && this.unit !== "month" && this.unit !== "week") { finishUtils.setDaysFromWeekday.call(this, today, orient); } if (this.weekday && this.unit !== "week" && !this.day && !this.days) { temp = Date[this.weekday](); this.day = temp.getDate(); if (temp.getMonth() !== today.getMonth()) { this.month = temp.getMonth(); } } if (this.month && this.unit === "day" && this.operator) { if (!this.value) { this.value = (this.month + 1); } this.month = null; } if (this.value != null && this.month != null && this.year != null) { this.day = this.value * 1; } if (this.month && !this.day && this.value) { today.set({ day: this.value * 1 }); if (!expression) { this.day = this.value * 1; } } if (!this.month && this.value && this.unit === "month" && !this.now) { this.month = this.value; expression = true; } if (expression && (this.month || this.month === 0) && this.unit !== "year") { finishUtils.setMonthsFromMonth.call(this, today, orient); } if (!this.unit) { this.unit = "day"; } finishUtils.setUnitValue.call(this, orient); parseMeridian.call(this); if ((this.month || this.month === 0) && !this.day) { this.day = 1; } if (!this.orient && !this.operator && this.unit === "week" && this.value && !this.day && !this.month) { return Date.today().setWeek(this.value); } if (this.unit === "week" && this.weeks && !this.day && !this.month) { return finishUtils.generateDateFromWeeks.call(this); } if (expression && this.timezone && this.day && this.days) { this.day = this.days; } if (expression){ today.add(this); } else { today.set(this); } if (this.timezone) { this.timezone = this.timezone.toUpperCase(); var offset = $D.getTimezoneOffset(this.timezone); var timezone; if (today.hasDaylightSavingTime()) { // lets check that we're being sane with timezone setting timezone = $D.getTimezoneAbbreviation(offset, today.isDaylightSavingTime()); if (timezone !== this.timezone) { // bugger, we're in a place where things like EST vs EDT matters. if (today.isDaylightSavingTime()) { today.addHours(-1); } else { today.addHours(1); } } } today.setTimezoneOffset(offset); } return today; } }; }()); (function () { var $D = Date; $D.Grammar = {}; var _ = $D.Parsing.Operators, g = $D.Grammar, t = $D.Translator, _fn; // Allow rolling up into general purpose rules _fn = function () { return _.each(_.any.apply(null, arguments), _.not(g.ctoken2("timeContext"))); }; g.datePartDelimiter = _.rtoken(/^([\s\-\.\,\/\x27]+)/); g.timePartDelimiter = _.stoken(":"); g.whiteSpace = _.rtoken(/^\s*/); g.generalDelimiter = _.rtoken(/^(([\s\,]|at|@|on)+)/); var _C = {}; g.ctoken = function (keys) { var fn = _C[keys]; if (! fn) { var c = Date.CultureInfo.regexPatterns; var kx = keys.split(/\s+/), px = []; for (var i = 0; i < kx.length ; i++) { px.push(_.replace(_.rtoken(c[kx[i]]), kx[i])); } fn = _C[keys] = _.any.apply(null, px); } return fn; }; g.ctoken2 = function (key) { return _.rtoken(Date.CultureInfo.regexPatterns[key]); }; var cacheProcessRtoken = function (key, token, type, eachToken) { if (eachToken) { g[key] = _.cache(_.process(_.each(_.rtoken(token),_.optional(g.ctoken2(eachToken))), type)); } else { g[key] = _.cache(_.process(_.rtoken(token), type)); } }; var cacheProcessCtoken = function (token, type) { return _.cache(_.process(g.ctoken2(token), type)); }; var _F = {}; //function cache var _get = function (f) { _F[f] = (_F[f] || g.format(f)[0]); return _F[f]; }; g.allformats = function (fx) { var rx = []; if (fx instanceof Array) { for (var i = 0; i < fx.length; i++) { rx.push(_get(fx[i])); } } else { rx.push(_get(fx)); } return rx; }; g.formats = function (fx) { if (fx instanceof Array) { var rx = []; for (var i = 0 ; i < fx.length ; i++) { rx.push(_get(fx[i])); } return _.any.apply(null, rx); } else { return _get(fx); } }; var grammarFormats = { timeFormats: function(){ var i, RTokenKeys = [ "h", "hh", "H", "HH", "m", "mm", "s", "ss", "ss.s", "z", "zz" ], RToken = [ /^(0[0-9]|1[0-2]|[1-9])/, /^(0[0-9]|1[0-2])/, /^([0-1][0-9]|2[0-3]|[0-9])/, /^([0-1][0-9]|2[0-3])/, /^([0-5][0-9]|[0-9])/, /^[0-5][0-9]/, /^([0-5][0-9]|[0-9])/, /^[0-5][0-9]/, /^[0-5][0-9]\.[0-9]{1,3}/, /^((\+|\-)\s*\d\d\d\d)|((\+|\-)\d\d\:?\d\d)/, /^((\+|\-)\s*\d\d\d\d)|((\+|\-)\d\d\:?\d\d)/ ], tokens = [ t.hour, t.hour, t.hour, t.hour, t.minute, t.minute, t.second, t.second, t.secondAndMillisecond, t.timezone, t.timezone ]; for (i=0; i < RTokenKeys.length; i++) { cacheProcessRtoken(RTokenKeys[i], RToken[i], tokens[i]); } g.hms = _.cache(_.sequence([g.H, g.m, g.s], g.timePartDelimiter)); g.t = cacheProcessCtoken("shortMeridian", t.meridian); g.tt = cacheProcessCtoken("longMeridian", t.meridian); g.zzz = cacheProcessCtoken("timezone", t.timezone); g.timeSuffix = _.each(_.ignore(g.whiteSpace), _.set([ g.tt, g.zzz ])); g.time = _.each(_.optional(_.ignore(_.stoken("T"))), g.hms, g.timeSuffix); }, dateFormats: function () { // pre-loaded rules for different date part order preferences var _setfn = function () { return _.set(arguments, g.datePartDelimiter); }; var i, RTokenKeys = [ "d", "dd", "M", "MM", "y", "yy", "yyy", "yyyy" ], RToken = [ /^([0-2]\d|3[0-1]|\d)/, /^([0-2]\d|3[0-1])/, /^(1[0-2]|0\d|\d)/, /^(1[0-2]|0\d)/, /^(\d+)/, /^(\d\d)/, /^(\d\d?\d?\d?)/, /^(\d\d\d\d)/ ], tokens = [ t.day, t.day, t.month, t.month, t.year, t.year, t.year, t.year ], eachToken = [ "ordinalSuffix", "ordinalSuffix" ]; for (i=0; i < RTokenKeys.length; i++) { cacheProcessRtoken(RTokenKeys[i], RToken[i], tokens[i], eachToken[i]); } g.MMM = g.MMMM = _.cache(_.process(g.ctoken("jan feb mar apr may jun jul aug sep oct nov dec"), t.month)); g.ddd = g.dddd = _.cache(_.process(g.ctoken("sun mon tue wed thu fri sat"), function (s) { return function () { this.weekday = s; }; } )); g.day = _fn(g.d, g.dd); g.month = _fn(g.M, g.MMM); g.year = _fn(g.yyyy, g.yy); g.mdy = _setfn(g.ddd, g.month, g.day, g.year); g.ymd = _setfn(g.ddd, g.year, g.month, g.day); g.dmy = _setfn(g.ddd, g.day, g.month, g.year); g.date = function (s) { return ((g[Date.CultureInfo.dateElementOrder] || g.mdy).call(this, s)); }; }, relative: function () { // relative date / time expressions g.orientation = _.process(g.ctoken("past future"), function (s) { return function () { this.orient = s; }; } ); g.operator = _.process(g.ctoken("add subtract"), function (s) { return function () { this.operator = s; }; } ); g.rday = _.process(g.ctoken("yesterday tomorrow today now"), t.rday); g.unit = _.process(g.ctoken("second minute hour day week month year"), function (s) { return function () { this.unit = s; }; } ); } }; g.buildGrammarFormats = function () { // these need to be rebuilt every time the language changes. _C = {}; grammarFormats.timeFormats(); grammarFormats.dateFormats(); grammarFormats.relative(); g.value = _.process(_.rtoken(/^([-+]?\d+)?(st|nd|rd|th)?/), function (s) { return function () { this.value = s.replace(/\D/g, ""); }; } ); g.expression = _.set([g.rday, g.operator, g.value, g.unit, g.orientation, g.ddd, g.MMM ]); g.format = _.process(_.many( _.any( // translate format specifiers into grammar rules _.process( _.rtoken(/^(dd?d?d?(?!e)|MM?M?M?|yy?y?y?|hh?|HH?|mm?|ss?|tt?|zz?z?)/), function (fmt) { if (g[fmt]) { return g[fmt]; } else { throw $D.Parsing.Exception(fmt); } } ), // translate separator tokens into token rules _.process(_.rtoken(/^[^dMyhHmstz]+/), // all legal separators function (s) { return _.ignore(_.stoken(s)); } ) ) ), // construct the parser ... function (rules) { return _.process(_.each.apply(null, rules), t.finishExact); } ); // starting rule for general purpose grammar g._start = _.process(_.set([ g.date, g.time, g.expression ], g.generalDelimiter, g.whiteSpace), t.finish); }; g.buildGrammarFormats(); // parsing date format specifiers - ex: "h:m:s tt" // this little guy will generate a custom parser based // on the format string, ex: g.format("h:m:s tt") // check for these formats first g._formats = g.formats([ "\"yyyy-MM-ddTHH:mm:ssZ\"", "yyyy-MM-ddTHH:mm:ss.sz", "yyyy-MM-ddTHH:mm:ssZ", "yyyy-MM-ddTHH:mm:ssz", "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-ddTHH:mmZ", "yyyy-MM-ddTHH:mmz", "yyyy-MM-ddTHH:mm", "ddd, MMM dd, yyyy H:mm:ss tt", "ddd MMM d yyyy HH:mm:ss zzz", "MMddyyyy", "ddMMyyyy", "Mddyyyy", "ddMyyyy", "Mdyyyy", "dMyyyy", "yyyy", "Mdyy", "dMyy", "d" ]); // real starting rule: tries selected formats first, // then general purpose rule g.start = function (s) { try { var r = g._formats.call({}, s); if (r[1].length === 0) { return r; } } catch (e) {} return g._start.call({}, s); }; }()); (function () { var $D = Date; /** * @desc Converts the specified string value into its JavaScript Date equivalent using CultureInfo specific format information. * * Example

	///////////
	// Dates //
	///////////

	// 15-Oct-2004
	var d1 = Date.parse("10/15/2004");

	// 15-Oct-2004
	var d1 = Date.parse("15-Oct-2004");

	// 15-Oct-2004
	var d1 = Date.parse("2004.10.15");

	//Fri Oct 15, 2004
	var d1 = Date.parse("Fri Oct 15, 2004");

	///////////
	// Times //
	///////////

	// Today at 10 PM.
	var d1 = Date.parse("10 PM");

	// Today at 10:30 PM.
	var d1 = Date.parse("10:30 P.M.");

	// Today at 6 AM.
	var d1 = Date.parse("06am");

	/////////////////////
	// Dates and Times //
	/////////////////////

	// 8-July-2004 @ 10:30 PM
	var d1 = Date.parse("July 8th, 2004, 10:30 PM");

	// 1-July-2004 @ 10:30 PM
	var d1 = Date.parse("2004-07-01T22:30:00");

	////////////////////
	// Relative Dates //
	////////////////////

	// Returns today's date. The string "today" is culture specific.
	var d1 = Date.parse("today");

	// Returns yesterday's date. The string "yesterday" is culture specific.
	var d1 = Date.parse("yesterday");

	// Returns the date of the next thursday.
	var d1 = Date.parse("Next thursday");

	// Returns the date of the most previous monday.
	var d1 = Date.parse("last monday");

	// Returns today's day + one year.
	var d1 = Date.parse("next year");

	///////////////
	// Date Math //
	///////////////

	// Today + 2 days
	var d1 = Date.parse("t+2");

	// Today + 2 days
	var d1 = Date.parse("today + 2 days");

	// Today + 3 months
	var d1 = Date.parse("t+3m");

	// Today - 1 year
	var d1 = Date.parse("today - 1 year");

	// Today - 1 year
	var d1 = Date.parse("t-1y"); 


	/////////////////////////////
	// Partial Dates and Times //
	/////////////////////////////

	// July 15th of this year.
	var d1 = Date.parse("July 15");

	// 15th day of current day and year.
	var d1 = Date.parse("15");

	// July 1st of current year at 10pm.
	var d1 = Date.parse("7/1 10pm");
	
* * @param {String} The string value to convert into a Date object [Required] * @return {Date} A Date object or null if the string cannot be converted into a Date. */ var parseUtils = { removeOrds: function (s) { ords = s.match(/\b(\d+)(?:st|nd|rd|th)\b/); // find ordinal matches s = ((ords && ords.length === 2) ? s.replace(ords[0], ords[1]) : s); return s; }, grammarParser: function (s) { var r = null; try { r = $D.Grammar.start.call({}, s.replace(/^\s*(\S*(\s+\S+)*)\s*$/, "$1")); } catch (e) { return null; } return ((r[1].length === 0) ? r[0] : null); }, nativeFallback: function(s) { var t; try { // ok we haven't parsed it, last ditch attempt with the built-in parser. t = Date._parse(s); return (t || t === 0) ? new Date(t) : null; } catch (e) { return null; } } }; function parse (s) { var d; if (!s) { return null; } if (s instanceof Date) { return s.clone(); } if (s.length >= 4 && s.charAt(0) !== "0" && s.charAt(0) !== "+"&& s.charAt(0) !== "-") { // ie: 2004 will pass, 0800 won't. // Start with specific formats d = $D.Parsing.ISO.parse(s) || $D.Parsing.Numeric.parse(s); } if (d instanceof Date && !isNaN(d.getTime())) { return d; } else { // find ordinal dates (1st, 3rd, 8th, etc and remove them as they cause parsing issues) s = $D.Parsing.Normalizer.parse(parseUtils.removeOrds(s)); d = parseUtils.grammarParser(s); if (d !== null) { return d; } else { return parseUtils.nativeFallback(s); } } } if (!$D._parse) { $D._parse = $D.parse; } $D.parse = parse; Date.getParseFunction = function (fx) { var fns = Date.Grammar.allformats(fx); return function (s) { var r = null; for (var i = 0; i < fns.length; i++) { try { r = fns[i].call({}, s); } catch (e) { continue; } if (r[1].length === 0) { return r[0]; } } return null; }; }; /** * Converts the specified string value into its JavaScript Date equivalent using the specified format {String} or formats {Array} and the CultureInfo specific format information. * The format of the string value must match one of the supplied formats exactly. * * Example

	// 15-Oct-2004
	var d1 = Date.parseExact("10/15/2004", "M/d/yyyy");

	// 15-Oct-2004
	var d1 = Date.parse("15-Oct-2004", "M-ddd-yyyy");

	// 15-Oct-2004
	var d1 = Date.parse("2004.10.15", "yyyy.MM.dd");

	// Multiple formats
	var d1 = Date.parseExact("10/15/2004", ["M/d/yyyy", "MMMM d, yyyy"]);
	
* * @param {String} The string value to convert into a Date object [Required]. * @param {Object} The expected format {String} or an array of expected formats {Array} of the date string [Required]. * @return {Date} A Date object or null if the string cannot be converted into a Date. */ $D.parseExact = function (s, fx) { return $D.getParseFunction(fx)(s); }; }()); (function () { var $D = Date, $P = $D.prototype, // $C = $D.CultureInfo, // not used atm p = function (s, l) { if (!l) { l = 2; } return ("000" + s).slice(l * -1); }; /** * Converts a PHP format string to Java/.NET format string. * A PHP format string can be used with ._format or .format. * A Java/.NET format string can be used with .toString(). * The .parseExact function will only accept a Java/.NET format string * * Example * var f1 = "%m/%d/%y" * var f2 = Date.normalizeFormat(f1); // "MM/dd/yy" * * new Date().format(f1); // "04/13/08" * new Date()._format(f1); // "04/13/08" * new Date().toString(f2); // "04/13/08" * * var date = Date.parseExact("04/13/08", f2); // Sun Apr 13 2008 * * @param {String} A PHP format string consisting of one or more format spcifiers. * @return {String} The PHP format converted to a Java/.NET format string. */ var normalizerSubstitutions = { "d" : "dd", "%d": "dd", "D" : "ddd", "%a": "ddd", "j" : "dddd", "l" : "dddd", "%A": "dddd", "S" : "S", "F" : "MMMM", "%B": "MMMM", "m" : "MM", "%m": "MM", "M" : "MMM", "%b": "MMM", "%h": "MMM", "n" : "M", "Y" : "yyyy", "%Y": "yyyy", "y" : "yy", "%y": "yy", "g" : "h", "%I": "h", "G" : "H", "h" : "hh", "H" : "HH", "%H": "HH", "i" : "mm", "%M": "mm", "s" : "ss", "%S": "ss", "%r": "hh:mm tt", "%R": "H:mm", "%T": "H:mm:ss", "%X": "t", "%x": "d", "%e": "d", "%D": "MM/dd/yy", "%n": "\\n", "%t": "\\t", "e" : "z", "T" : "z", "%z": "z", "%Z": "z", "Z" : "ZZ", "N" : "u", "w" : "u", "%w": "u", "W" : "W", "%V": "W" }; var normalizer = { substitutes: function (m) { return normalizerSubstitutions[m]; }, interpreted: function (m, x) { var y; switch (m) { case "%u": return x.getDay() + 1; case "z": return x.getOrdinalNumber(); case "%j": return p(x.getOrdinalNumber(), 3); case "%U": var d1 = x.clone().set({month: 0, day: 1}).addDays(-1).moveToDayOfWeek(0), d2 = x.clone().addDays(1).moveToDayOfWeek(0, -1); return (d2 < d1) ? "00" : p((d2.getOrdinalNumber() - d1.getOrdinalNumber()) / 7 + 1); case "%W": return p(x.getWeek()); case "t": return $D.getDaysInMonth(x.getFullYear(), x.getMonth()); case "o": case "%G": return x.setWeek(x.getISOWeek()).toString("yyyy"); case "%g": return x._format("%G").slice(-2); case "a": case "%p": return t("tt").toLowerCase(); case "A": return t("tt").toUpperCase(); case "u": return p(x.getMilliseconds(), 3); case "I": return (x.isDaylightSavingTime()) ? 1 : 0; case "O": return x.getUTCOffset(); case "P": y = x.getUTCOffset(); return y.substring(0, y.length - 2) + ":" + y.substring(y.length - 2); case "B": var now = new Date(); return Math.floor(((now.getHours() * 3600) + (now.getMinutes() * 60) + now.getSeconds() + (now.getTimezoneOffset() + 60) * 60) / 86.4); case "c": return x.toISOString().replace(/\"/g, ""); case "U": return $D.strtotime("now"); case "%c": return t("d") + " " + t("t"); case "%C": return Math.floor(x.getFullYear() / 100 + 1); } }, shouldOverrideDefaults: function (m) { switch (m) { case "%e": return true; default: return false; } }, parse: function (m, context) { var formatString, c = context || new Date(); formatString = normalizer.substitutes(m); if (formatString) { return formatString; } formatString = normalizer.interpreted(m, c); if (formatString) { return formatString; } else { return m; } } }; $D.normalizeFormat = function (format, context) { return format.replace(/(%|\\)?.|%%/g, function(t){ return normalizer.parse(t, context); }); }; /** * Format a local Unix timestamp according to locale settings * * Example: * Date.strftime("%m/%d/%y", new Date()); // "04/13/08" * Date.strftime("c", "2008-04-13T17:52:03Z"); // "04/13/08" * * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @param {Number|String} The number representing the number of seconds that have elapsed since January 1, 1970 (local time). * @return {String} A string representation of the current Date object. */ $D.strftime = function (format, time) { var d = Date.parse(time); return d._format(format); }; /** * Parse any textual datetime description into a Unix timestamp. * A Unix timestamp is the number of seconds that have elapsed since January 1, 1970 (midnight UTC/GMT). * * Example: * Date.strtotime("04/13/08"); // 1208044800 * Date.strtotime("1970-01-01T00:00:00Z"); // 0 * * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @param {Object} A string or date object. * @return {String} A string representation of the current Date object. */ $D.strtotime = function (time) { var d = $D.parse(time); return Math.round($D.UTC(d.getUTCFullYear(), d.getUTCMonth(), d.getUTCDate(), d.getUTCHours(), d.getUTCMinutes(), d.getUTCSeconds(), d.getUTCMilliseconds()) / 1000); }; /** * Converts the value of the current Date object to its equivalent string representation using a PHP/Unix style of date format specifiers. * Format Specifiers * Format Description Example * ------ --------------------------------------------------------------------------- ----------------------- * %a abbreviated weekday name according to the current localed "Mon" through "Sun" * %A full weekday name according to the current localed "Sunday" through "Saturday" * %b abbreviated month name according to the current localed "Jan" through "Dec" * %B full month name according to the current locale "January" through "December" * %c preferred date and time representation for the current locale "4/13/2008 12:33 PM" * %C century number (the year divided by 100 and truncated to an integer) "00" to "99" * %d day of the month as a decimal number "01" to "31" * %D same as %m/%d/%y "04/13/08" * %e day of the month as a decimal number, a single digit is preceded by a space "1" to "31" * %g like %G, but without the century "08" * %G The 4-digit year corresponding to the ISO week number (see %V). "2008" * This has the same format and value as %Y, except that if the ISO week number * belongs to the previous or next year, that year is used instead. * %h same as %b "Jan" through "Dec" * %H hour as a decimal number using a 24-hour clock. "00" to "23" * %I hour as a decimal number using a 12-hour clock. "01" to "12" * %j day of the year as a decimal number. "001" to "366" * %m month as a decimal number. "01" to "12" * %M minute as a decimal number. "00" to "59" * %n newline character "\n" * %p either "am" or "pm" according to the given time value, or the "am" or "pm" * corresponding strings for the current locale. * %r time in a.m. and p.m. notation "8:44 PM" * %R time in 24 hour notation "20:44" * %S second as a decimal number "00" to "59" * %t tab character "\t" * %T current time, equal to %H:%M:%S "12:49:11" * %u weekday as a decimal number ["1", "7"], with "1" representing Monday "1" to "7" * %U week number of the current year as a decimal number, starting with the "0" to ("52" or "53") * first Sunday as the first day of the first week * %V The ISO 8601:1988 week number of the current year as a decimal number, "00" to ("52" or "53") * range 01 to 53, where week 1 is the first week that has at least 4 days * in the current year, and with Monday as the first day of the week. * (Use %G or %g for the year component that corresponds to the week number * for the specified timestamp.) * %W week number of the current year as a decimal number, starting with the "00" to ("52" or "53") * first Monday as the first day of the first week * %w day of the week as a decimal, Sunday being "0" "0" to "6" * %x preferred date representation for the current locale without the time "4/13/2008" * %X preferred time representation for the current locale without the date "12:53:05" * %y year as a decimal number without a century "00" "99" * %Y year as a decimal number including the century "2008" * %Z time zone or name or abbreviation "UTC", "EST", "PST" * %z same as %Z * %% a literal "%" characters "%" * d Day of the month, 2 digits with leading zeros "01" to "31" * D A textual representation of a day, three letters "Mon" through "Sun" * j Day of the month without leading zeros "1" to "31" * l A full textual representation of the day of the week (lowercase "L") "Sunday" through "Saturday" * N ISO-8601 numeric representation of the day of the week (added in PHP 5.1.0) "1" (for Monday) through "7" (for Sunday) * S English ordinal suffix for the day of the month, 2 characters "st", "nd", "rd" or "th". Works well with j * w Numeric representation of the day of the week "0" (for Sunday) through "6" (for Saturday) * z The day of the year (starting from "0") "0" through "365" * W ISO-8601 week number of year, weeks starting on Monday "00" to ("52" or "53") * F A full textual representation of a month, such as January or March "January" through "December" * m Numeric representation of a month, with leading zeros "01" through "12" * M A short textual representation of a month, three letters "Jan" through "Dec" * n Numeric representation of a month, without leading zeros "1" through "12" * t Number of days in the given month "28" through "31" * L Whether it's a leap year "1" if it is a leap year, "0" otherwise * o ISO-8601 year number. This has the same value as Y, except that if the "2008" * ISO week number (W) belongs to the previous or next year, that year * is used instead. * Y A full numeric representation of a year, 4 digits "2008" * y A two digit representation of a year "08" * a Lowercase Ante meridiem and Post meridiem "am" or "pm" * A Uppercase Ante meridiem and Post meridiem "AM" or "PM" * B Swatch Internet time "000" through "999" * g 12-hour format of an hour without leading zeros "1" through "12" * G 24-hour format of an hour without leading zeros "0" through "23" * h 12-hour format of an hour with leading zeros "01" through "12" * H 24-hour format of an hour with leading zeros "00" through "23" * i Minutes with leading zeros "00" to "59" * s Seconds, with leading zeros "00" through "59" * u Milliseconds "54321" * e Timezone identifier "UTC", "EST", "PST" * I Whether or not the date is in daylight saving time (uppercase i) "1" if Daylight Saving Time, "0" otherwise * O Difference to Greenwich time (GMT) in hours "+0200", "-0600" * P Difference to Greenwich time (GMT) with colon between hours and minutes "+02:00", "-06:00" * T Timezone abbreviation "UTC", "EST", "PST" * Z Timezone offset in seconds. The offset for timezones west of UTC is "-43200" through "50400" * always negative, and for those east of UTC is always positive. * c ISO 8601 date "2004-02-12T15:19:21+00:00" * r RFC 2822 formatted date "Thu, 21 Dec 2000 16:01:07 +0200" * U Seconds since the Unix Epoch (January 1 1970 00:00:00 GMT) "0" * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @return {String} A string representation of the current Date object. */ var formatReplace = function (context) { return function (m) { var formatString, override = false; if (m.charAt(0) === "\\" || m.substring(0, 2) === "%%") { return m.replace("\\", "").replace("%%", "%"); } override = normalizer.shouldOverrideDefaults(m); formatString = $D.normalizeFormat(m, context); if (formatString) { return context.toString(formatString, override); } }; }; $P._format = function (format) { var formatter = formatReplace(this); if (!format) { return this._toString(); } else { return format.replace(/(%|\\)?.|%%/g, formatter); } }; if (!$P.format) { $P.format = $P._format; } }()); (function () { "use strict"; var gFn = function (attr) { return function () { return this[attr]; }; }; var sFn = function (attr) { return function (val) { this[attr] = val; return this; }; }; var attrs = ["years", "months", "days", "hours", "minutes", "seconds", "milliseconds"]; var addSetFuncs = function (context, attrs) { for (var i = 0; i < attrs.length ; i++) { var $a = attrs[i], $b = $a.slice(0, 1).toUpperCase() + $a.slice(1); context.prototype[$a] = 0; context.prototype["get" + $b] = gFn($a); context.prototype["set" + $b] = sFn($a); } }; /** * new TimeSpan(milliseconds); * new TimeSpan(days, hours, minutes, seconds); * new TimeSpan(days, hours, minutes, seconds, milliseconds); */ var TimeSpan = function (days, hours, minutes, seconds, milliseconds) { if (arguments.length === 1 && typeof days === "number") { var orient = (days < 0) ? -1 : +1; var millsLeft = Math.abs(days); this.setDays(Math.floor(millsLeft / 86400000) * orient); millsLeft = millsLeft % 86400000; this.setHours(Math.floor(millsLeft / 3600000) * orient); millsLeft = millsLeft % 3600000; this.setMinutes(Math.floor(millsLeft / 60000) * orient); millsLeft = millsLeft % 60000; this.setSeconds(Math.floor(millsLeft / 1000) * orient); millsLeft = millsLeft % 1000; this.setMilliseconds(millsLeft * orient); } else { this.set(days, hours, minutes, seconds, milliseconds); } this.getTotalMilliseconds = function () { return (this.getDays() * 86400000) + (this.getHours() * 3600000) + (this.getMinutes() * 60000) + (this.getSeconds() * 1000); }; this.compareTo = function (time) { var t1 = new Date(1970, 1, 1, this.getHours(), this.getMinutes(), this.getSeconds()), t2; if (time === null) { t2 = new Date(1970, 1, 1, 0, 0, 0); } else { t2 = new Date(1970, 1, 1, time.getHours(), time.getMinutes(), time.getSeconds()); } return (t1 < t2) ? -1 : (t1 > t2) ? 1 : 0; }; this.equals = function (time) { return (this.compareTo(time) === 0); }; this.add = function (time) { return (time === null) ? this : this.addSeconds(time.getTotalMilliseconds() / 1000); }; this.subtract = function (time) { return (time === null) ? this : this.addSeconds(-time.getTotalMilliseconds() / 1000); }; this.addDays = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 86400000)); }; this.addHours = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 3600000)); }; this.addMinutes = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 60000)); }; this.addSeconds = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 1000)); }; this.addMilliseconds = function (n) { return new TimeSpan(this.getTotalMilliseconds() + n); }; this.get12HourHour = function () { return (this.getHours() > 12) ? this.getHours() - 12 : (this.getHours() === 0) ? 12 : this.getHours(); }; this.getDesignator = function () { return (this.getHours() < 12) ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator; }; this.toString = function (format) { this._toString = function () { if (this.getDays() !== null && this.getDays() > 0) { return this.getDays() + "." + this.getHours() + ":" + this.p(this.getMinutes()) + ":" + this.p(this.getSeconds()); } else { return this.getHours() + ":" + this.p(this.getMinutes()) + ":" + this.p(this.getSeconds()); } }; this.p = function (s) { return (s.toString().length < 2) ? "0" + s : s; }; var me = this; return format ? format.replace(/dd?|HH?|hh?|mm?|ss?|tt?/g, function (format) { switch (format) { case "d": return me.getDays(); case "dd": return me.p(me.getDays()); case "H": return me.getHours(); case "HH": return me.p(me.getHours()); case "h": return me.get12HourHour(); case "hh": return me.p(me.get12HourHour()); case "m": return me.getMinutes(); case "mm": return me.p(me.getMinutes()); case "s": return me.getSeconds(); case "ss": return me.p(me.getSeconds()); case "t": return ((me.getHours() < 12) ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator).substring(0, 1); case "tt": return (me.getHours() < 12) ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator; } } ) : this._toString(); }; return this; }; addSetFuncs(TimeSpan, attrs.slice(2)); TimeSpan.prototype.set = function (days, hours, minutes, seconds, milliseconds){ this.setDays(days || this.getDays()); this.setHours(hours || this.getHours()); this.setMinutes(minutes || this.getMinutes()); this.setSeconds(seconds || this.getSeconds()); this.setMilliseconds(milliseconds || this.getMilliseconds()); }; /** * Gets the time of day for this date instances. * @return {TimeSpan} TimeSpan */ Date.prototype.getTimeOfDay = function () { return new TimeSpan(0, this.getHours(), this.getMinutes(), this.getSeconds(), this.getMilliseconds()); }; Date.TimeSpan = TimeSpan; if (typeof window !== "undefined" ) { // keeping API compatible for v1.x window.TimeSpan = TimeSpan; } }()); (function () { "use strict"; var attrs = ["years", "months", "days", "hours", "minutes", "seconds", "milliseconds"]; var gFn = function (attr) { return function () { return this[attr]; }; }; var sFn = function (attr) { return function (val) { this[attr] = val; return this; }; }; var addSetFuncs = function (context, attrs) { for (var i = 0; i < attrs.length ; i++) { var $a = attrs[i], $b = $a.slice(0, 1).toUpperCase() + $a.slice(1); context.prototype[$a] = 0; context.prototype["get" + $b] = gFn($a); context.prototype["set" + $b] = sFn($a); } }; var setMonthsAndYears = function (orient, d1, d2, context) { function inc() { d1.addMonths(-orient); context.months++; if (context.months === 12) { context.years++; context.months = 0; } } if (orient === +1) { while (d1 > d2) { inc(); } } else { while (d1 < d2) { inc(); } } context.months--; context.months *= orient; context.years *= orient; }; var adjustForDST = function(orient, startDate, endDate) { var hasDSTMismatch = (false === (startDate.isDaylightSavingTime() === endDate.isDaylightSavingTime())); if (hasDSTMismatch && orient === 1) { startDate.addHours(-1); } else if (hasDSTMismatch) { startDate.addHours(1); } }; /** * TimePeriod(startDate, endDate); * TimePeriod(years, months, days, hours, minutes, seconds, milliseconds); */ var TimePeriod = function (years, months, days, hours, minutes, seconds, milliseconds) { if (arguments.length === 7) { this.set(years, months, days, hours, minutes, seconds, milliseconds); } else if (arguments.length === 2 && arguments[0] instanceof Date && arguments[1] instanceof Date) { var startDate = arguments[0].clone(); var endDate = arguments[1].clone(); var orient = (startDate > endDate) ? +1 : -1; this.dates = { start: arguments[0].clone(), end: arguments[1].clone() }; setMonthsAndYears(orient, startDate, endDate, this); adjustForDST(orient, startDate, endDate); // // TODO - adjust for DST var diff = endDate - startDate; if (diff !== 0) { var ts = new TimeSpan(diff); this.set(this.years, this.months, ts.getDays(), ts.getHours(), ts.getMinutes(), ts.getSeconds(), ts.getMilliseconds()); } } return this; }; // create all the set functions. addSetFuncs(TimePeriod, attrs); TimePeriod.prototype.set = function (years, months, days, hours, minutes, seconds, milliseconds){ this.setYears(years || this.getYears()); this.setMonths(months || this.getMonths()); this.setDays(days || this.getDays()); this.setHours(hours || this.getHours()); this.setMinutes(minutes || this.getMinutes()); this.setSeconds(seconds || this.getSeconds()); this.setMilliseconds(milliseconds || this.getMilliseconds()); }; Date.TimePeriod = TimePeriod; if (typeof window !== "undefined") { // keeping API compatible for v1.x window.TimePeriod = TimePeriod; } }()); ================================================ FILE: build/date-gl-ES.js ================================================ /** * @overview datejs * @version 1.0.0-rc3 * @author Gregory Wild-Smith * @copyright 2015 Gregory Wild-Smith * @license MIT * @homepage https://github.com/abritinthebay/datejs */ /* * DateJS Culture String File * Country Code: gl-ES * Name: Galician (Galician) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["gl-ES"] = { "name": "gl-ES", "englishName": "Galician (Galician)", "nativeName": "galego (galego)", "Sunday": "domingo", "Monday": "luns", "Tuesday": "martes", "Wednesday": "mércores", "Thursday": "xoves", "Friday": "venres", "Saturday": "sábado", "Sun": "dom", "Mon": "luns", "Tue": "mar", "Wed": "mér", "Thu": "xov", "Fri": "ven", "Sat": "sab", "Su": "do", "Mo": "lu", "Tu": "ma", "We": "mé", "Th": "xo", "Fr": "ve", "Sa": "sa", "S_Sun_Initial": "d", "M_Mon_Initial": "l", "T_Tue_Initial": "m", "W_Wed_Initial": "m", "T_Thu_Initial": "x", "F_Fri_Initial": "v", "S_Sat_Initial": "s", "January": "xaneiro", "February": "febreiro", "March": "marzo", "April": "abril", "May": "maio", "June": "xuño", "July": "xullo", "August": "agosto", "September": "setembro", "October": "outubro", "November": "novembro", "December": "decembro", "Jan_Abbr": "xan", "Feb_Abbr": "feb", "Mar_Abbr": "mar", "Apr_Abbr": "abr", "May_Abbr": "maio", "Jun_Abbr": "xuñ", "Jul_Abbr": "xull", "Aug_Abbr": "ago", "Sep_Abbr": "set", "Oct_Abbr": "out", "Nov_Abbr": "nov", "Dec_Abbr": "dec", "AM": "a.m.", "PM": "p.m.", "firstDayOfWeek": 1, "twoDigitYearMax": 2029, "mdy": "dmy", "M/d/yyyy": "dd/MM/yy", "dddd, MMMM dd, yyyy": "dddd, dd' de 'MMMM' de 'yyyy", "h:mm tt": "H:mm", "h:mm:ss tt": "H:mm:ss", "dddd, MMMM dd, yyyy h:mm:ss tt": "dddd, dd' de 'MMMM' de 'yyyy H:mm:ss", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "dd MMMM", "MMMM, yyyy": "MMMM' de 'yyyy", "/jan(uary)?/": "xan(eiro)?", "/feb(ruary)?/": "feb(reiro)?", "/mar(ch)?/": "mar(zo)?", "/apr(il)?/": "abr(il)?", "/may/": "maio", "/jun(e)?/": "xuñ(o)?", "/jul(y)?/": "xull(o)?", "/aug(ust)?/": "ago(sto)?", "/sep(t(ember)?)?/": "set(embro)?", "/oct(ober)?/": "out(ubro)?", "/nov(ember)?/": "nov(embro)?", "/dec(ember)?/": "dec(embro)?", "/^su(n(day)?)?/": "^do(m(ingo)?)?", "/^mo(n(day)?)?/": "^lu(1)?", "/^tu(e(s(day)?)?)?/": "^ma(r(tes)?)?", "/^we(d(nesday)?)?/": "^mé(r(cores)?)?", "/^th(u(r(s(day)?)?)?)?/": "^xo(v(es)?)?", "/^fr(i(day)?)?/": "^ve(n(res)?)?", "/^sa(t(urday)?)?/": "^sa(b(ado)?)?", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "gl-ES"; /** * @overview datejs * @version 1.0.0-rc3 * @author Gregory Wild-Smith * @copyright 2015 Gregory Wild-Smith * @license MIT * @homepage https://github.com/abritinthebay/datejs */(function () { var $D = Date; var lang = Date.CultureStrings ? Date.CultureStrings.lang : null; var loggedKeys = {}; // for debug purposes. var getText = { getFromKey: function (key, countryCode) { var output; if (Date.CultureStrings && Date.CultureStrings[countryCode] && Date.CultureStrings[countryCode][key]) { output = Date.CultureStrings[countryCode][key]; } else { output = getText.buildFromDefault(key); } if (key.charAt(0) === "/") { // Assume it's a regex output = getText.buildFromRegex(key, countryCode); } return output; }, getFromObjectValues: function (obj, countryCode) { var key, output = {}; for(key in obj) { if (obj.hasOwnProperty(key)) { output[key] = getText.getFromKey(obj[key], countryCode); } } return output; }, getFromObjectKeys: function (obj, countryCode) { var key, output = {}; for(key in obj) { if (obj.hasOwnProperty(key)) { output[getText.getFromKey(key, countryCode)] = obj[key]; } } return output; }, getFromArray: function (arr, countryCode) { var output = []; for (var i=0; i < arr.length; i++){ if (i in arr) { output[i] = getText.getFromKey(arr[i], countryCode); } } return output; }, buildFromDefault: function (key) { var output, length, split, last; switch(key) { case "name": output = "en-US"; break; case "englishName": output = "English (United States)"; break; case "nativeName": output = "English (United States)"; break; case "twoDigitYearMax": output = 2049; break; case "firstDayOfWeek": output = 0; break; default: output = key; split = key.split("_"); length = split.length; if (length > 1 && key.charAt(0) !== "/") { // if the key isn't a regex and it has a split. last = split[(length - 1)].toLowerCase(); if (last === "initial" || last === "abbr") { output = split[0]; } } break; } return output; }, buildFromRegex: function (key, countryCode) { var output; if (Date.CultureStrings && Date.CultureStrings[countryCode] && Date.CultureStrings[countryCode][key]) { output = new RegExp(Date.CultureStrings[countryCode][key], "i"); } else { output = new RegExp(key.replace(new RegExp("/", "g"),""), "i"); } return output; } }; var shallowMerge = function (obj1, obj2) { for (var attrname in obj2) { if (obj2.hasOwnProperty(attrname)) { obj1[attrname] = obj2[attrname]; } } }; var __ = function (key, language) { var countryCode = (language) ? language : lang; loggedKeys[key] = key; if (typeof key === "object") { if (key instanceof Array) { return getText.getFromArray(key, countryCode); } else { return getText.getFromObjectKeys(key, countryCode); } } else { return getText.getFromKey(key, countryCode); } }; var loadI18nScript = function (code) { // paatterned after jQuery's getScript. var url = Date.Config.i18n + code + ".js"; var head = document.getElementsByTagName("head")[0] || document.documentElement; var script = document.createElement("script"); script.src = url; var completed = false; var events = { done: function (){} // placeholder function }; // Attach handlers for all browsers script.onload = script.onreadystatechange = function() { if ( !completed && (!this.readyState || this.readyState === "loaded" || this.readyState === "complete") ) { events.done(); head.removeChild(script); } }; setTimeout(function() { head.insertBefore(script, head.firstChild); }, 0); // allows return to execute first return { done: function (cb) { events.done = function() { if (cb) { setTimeout(cb,0); } }; } }; }; var buildInfo = { buildFromMethodHash: function (obj) { var key; for(key in obj) { if (obj.hasOwnProperty(key)) { obj[key] = buildInfo[obj[key]](); } } return obj; }, timeZoneDST: function () { var DST = { "CHADT": "+1345", "NZDT": "+1300", "AEDT": "+1100", "ACDT": "+1030", "AZST": "+0500", "IRDT": "+0430", "EEST": "+0300", "CEST": "+0200", "BST": "+0100", "PMDT": "-0200", "ADT": "-0300", "NDT": "-0230", "EDT": "-0400", "CDT": "-0500", "MDT": "-0600", "PDT": "-0700", "AKDT": "-0800", "HADT": "-0900" }; return __(DST); }, timeZoneStandard: function () { var standard = { "LINT": "+1400", "TOT": "+1300", "CHAST": "+1245", "NZST": "+1200", "NFT": "+1130", "SBT": "+1100", "AEST": "+1000", "ACST": "+0930", "JST": "+0900", "CWST": "+0845", "CT": "+0800", "ICT": "+0700", "MMT": "+0630", "BST": "+0600", "NPT": "+0545", "IST": "+0530", "PKT": "+0500", "AFT": "+0430", "MSK": "+0400", "IRST": "+0330", "FET": "+0300", "EET": "+0200", "CET": "+0100", "GMT": "+0000", "UTC": "+0000", "CVT": "-0100", "GST": "-0200", "BRT": "-0300", "NST": "-0330", "AST": "-0400", "EST": "-0500", "CST": "-0600", "MST": "-0700", "PST": "-0800", "AKST": "-0900", "MIT": "-0930", "HST": "-1000", "SST": "-1100", "BIT": "-1200" }; return __(standard); }, timeZones: function (data) { var zone; data.timezones = []; for (zone in data.abbreviatedTimeZoneStandard) { if (data.abbreviatedTimeZoneStandard.hasOwnProperty(zone)) { data.timezones.push({ name: zone, offset: data.abbreviatedTimeZoneStandard[zone]}); } } for (zone in data.abbreviatedTimeZoneDST) { if (data.abbreviatedTimeZoneDST.hasOwnProperty(zone)) { data.timezones.push({ name: zone, offset: data.abbreviatedTimeZoneDST[zone], dst: true}); } } return data.timezones; }, days: function () { return __(["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"]); }, dayAbbr: function () { return __(["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"]); }, dayShortNames: function () { return __(["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"]); }, dayFirstLetters: function () { return __(["S_Sun_Initial", "M_Mon_Initial", "T_Tues_Initial", "W_Wed_Initial", "T_Thu_Initial", "F_Fri_Initial", "S_Sat_Initial"]); }, months: function () { return __(["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"]); }, monthAbbr: function () { return __(["Jan_Abbr", "Feb_Abbr", "Mar_Abbr", "Apr_Abbr", "May_Abbr", "Jun_Abbr", "Jul_Abbr", "Aug_Abbr", "Sep_Abbr", "Oct_Abbr", "Nov_Abbr", "Dec_Abbr"]); }, formatPatterns: function () { return getText.getFromObjectValues({ shortDate: "M/d/yyyy", longDate: "dddd, MMMM dd, yyyy", shortTime: "h:mm tt", longTime: "h:mm:ss tt", fullDateTime: "dddd, MMMM dd, yyyy h:mm:ss tt", sortableDateTime: "yyyy-MM-ddTHH:mm:ss", universalSortableDateTime: "yyyy-MM-dd HH:mm:ssZ", rfc1123: "ddd, dd MMM yyyy HH:mm:ss", monthDay: "MMMM dd", yearMonth: "MMMM, yyyy" }, Date.i18n.currentLanguage()); }, regex: function () { return getText.getFromObjectValues({ inTheMorning: "/( in the )(morn(ing)?)\\b/", thisMorning: "/(this )(morn(ing)?)\\b/", amThisMorning: "/(\b\\d(am)? )(this )(morn(ing)?)/", inTheEvening: "/( in the )(even(ing)?)\\b/", thisEvening: "/(this )(even(ing)?)\\b/", pmThisEvening: "/(\b\\d(pm)? )(this )(even(ing)?)/", jan: "/jan(uary)?/", feb: "/feb(ruary)?/", mar: "/mar(ch)?/", apr: "/apr(il)?/", may: "/may/", jun: "/jun(e)?/", jul: "/jul(y)?/", aug: "/aug(ust)?/", sep: "/sep(t(ember)?)?/", oct: "/oct(ober)?/", nov: "/nov(ember)?/", dec: "/dec(ember)?/", sun: "/^su(n(day)?)?/", mon: "/^mo(n(day)?)?/", tue: "/^tu(e(s(day)?)?)?/", wed: "/^we(d(nesday)?)?/", thu: "/^th(u(r(s(day)?)?)?)?/", fri: "/fr(i(day)?)?/", sat: "/^sa(t(urday)?)?/", future: "/^next/", past: "/^last|past|prev(ious)?/", add: "/^(\\+|aft(er)?|from|hence)/", subtract: "/^(\\-|bef(ore)?|ago)/", yesterday: "/^yes(terday)?/", today: "/^t(od(ay)?)?/", tomorrow: "/^tom(orrow)?/", now: "/^n(ow)?/", millisecond: "/^ms|milli(second)?s?/", second: "/^sec(ond)?s?/", minute: "/^mn|min(ute)?s?/", hour: "/^h(our)?s?/", week: "/^w(eek)?s?/", month: "/^m(onth)?s?/", day: "/^d(ay)?s?/", year: "/^y(ear)?s?/", shortMeridian: "/^(a|p)/", longMeridian: "/^(a\\.?m?\\.?|p\\.?m?\\.?)/", timezone: "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/", ordinalSuffix: "/^\\s*(st|nd|rd|th)/", timeContext: "/^\\s*(\\:|a(?!u|p)|p)/" }, Date.i18n.currentLanguage()); } }; var CultureInfo = function () { var info = getText.getFromObjectValues({ name: "name", englishName: "englishName", nativeName: "nativeName", amDesignator: "AM", pmDesignator: "PM", firstDayOfWeek: "firstDayOfWeek", twoDigitYearMax: "twoDigitYearMax", dateElementOrder: "mdy" }, Date.i18n.currentLanguage()); var constructedInfo = buildInfo.buildFromMethodHash({ dayNames: "days", abbreviatedDayNames: "dayAbbr", shortestDayNames: "dayShortNames", firstLetterDayNames: "dayFirstLetters", monthNames: "months", abbreviatedMonthNames: "monthAbbr", formatPatterns: "formatPatterns", regexPatterns: "regex", abbreviatedTimeZoneDST: "timeZoneDST", abbreviatedTimeZoneStandard: "timeZoneStandard" }); shallowMerge(info, constructedInfo); buildInfo.timeZones(info); return info; }; $D.i18n = { __: function (key, lang) { return __(key, lang); }, currentLanguage: function () { return lang || "en-US"; }, setLanguage: function (code, force, cb) { var async = false; if (force || code === "en-US" || (!!Date.CultureStrings && !!Date.CultureStrings[code])) { lang = code; Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings.lang = code; Date.CultureInfo = new CultureInfo(); } else { if (!(!!Date.CultureStrings && !!Date.CultureStrings[code])) { if (typeof exports !== "undefined" && this.exports !== exports) { // we're in a Node enviroment, load it using require try { require("../i18n/" + code + ".js"); lang = code; Date.CultureStrings.lang = code; Date.CultureInfo = new CultureInfo(); } catch (e) { // var str = "The language for '" + code + "' could not be loaded by Node. It likely does not exist."; throw new Error("The DateJS IETF language tag '" + code + "' could not be loaded by Node. It likely does not exist."); } } else if (Date.Config && Date.Config.i18n) { // we know the location of the files, so lets load them async = true; loadI18nScript(code).done(function(){ lang = code; Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings.lang = code; Date.CultureInfo = new CultureInfo(); $D.Parsing.Normalizer.buildReplaceData(); // because this is async if ($D.Grammar) { $D.Grammar.buildGrammarFormats(); // so we can parse those strings... } if (cb) { setTimeout(cb,0); } }); } else { Date.console.error("The DateJS IETF language tag '" + code + "' is not available and has not been loaded."); return false; } } } $D.Parsing.Normalizer.buildReplaceData(); // rebuild normalizer strings if ($D.Grammar) { $D.Grammar.buildGrammarFormats(); // so we can parse those strings... } if (!async && cb) { setTimeout(cb,0); } }, getLoggedKeys: function () { return loggedKeys; }, updateCultureInfo: function () { Date.CultureInfo = new CultureInfo(); } }; $D.i18n.updateCultureInfo(); // run automatically }()); (function () { var $D = Date, $P = $D.prototype, p = function (s, l) { if (!l) { l = 2; } return ("000" + s).slice(l * -1); }; if (typeof window !== "undefined" && typeof window.console !== "undefined" && typeof window.console.log !== "undefined") { $D.console = console; // used only to raise non-critical errors if available } else { // set mock so we don't give errors. $D.console = { log: function(){}, error: function(){} }; } $D.Config = $D.Config || {}; $D.initOverloads = function() { /** * Overload of Date.now. Allows an alternate call for Date.now where it returns the * current Date as an object rather than just milliseconds since the Unix Epoch. * * Also provides an implementation of now() for browsers (IE<9) that don't have it. * * Backwards compatible so with work with either: * Date.now() [returns ms] * or * Date.now(true) [returns Date] */ if (!$D.now) { $D._now = function now() { return new Date().getTime(); }; } else if (!$D._now) { $D._now = $D.now; } $D.now = function (returnObj) { if (returnObj) { return $D.present(); } else { return $D._now(); } }; if ( !$P.toISOString ) { $P.toISOString = function() { return this.getUTCFullYear() + "-" + p(this.getUTCMonth() + 1) + "-" + p(this.getUTCDate()) + "T" + p(this.getUTCHours()) + ":" + p(this.getUTCMinutes()) + ":" + p(this.getUTCSeconds()) + "." + String( (this.getUTCMilliseconds()/1000).toFixed(3)).slice(2, 5) + "Z"; }; } // private if ( $P._toString === undefined ){ $P._toString = $P.toString; } }; $D.initOverloads(); /** * Gets a date that is set to the current date. The time is set to the start of the day (00:00 or 12:00 AM). * @return {Date} The current date. */ $D.today = function () { return new Date().clearTime(); }; /** * Gets a date that is set to the current date and time (same as new Date, but chainable) * @return {Date} The current date. */ $D.present = function () { return new Date(); }; /** * Compares the first date to the second date and returns an number indication of their relative values. * @param {Date} First Date object to compare [Required]. * @param {Date} Second Date object to compare to [Required]. * @return {Number} -1 = date1 is lessthan date2. 0 = values are equal. 1 = date1 is greaterthan date2. */ $D.compare = function (date1, date2) { if (isNaN(date1) || isNaN(date2)) { throw new Error(date1 + " - " + date2); } else if (date1 instanceof Date && date2 instanceof Date) { return (date1 < date2) ? -1 : (date1 > date2) ? 1 : 0; } else { throw new TypeError(date1 + " - " + date2); } }; /** * Compares the first Date object to the second Date object and returns true if they are equal. * @param {Date} First Date object to compare [Required] * @param {Date} Second Date object to compare to [Required] * @return {Boolean} true if dates are equal. false if they are not equal. */ $D.equals = function (date1, date2) { return (date1.compareTo(date2) === 0); }; /** * Gets the language appropriate day name when given the day number(0-6) * eg - 0 == Sunday * @return {String} The day name */ $D.getDayName = function (n) { return Date.CultureInfo.dayNames[n]; }; /** * Gets the day number (0-6) if given a CultureInfo specific string which is a valid dayName, abbreviatedDayName or shortestDayName (two char). * @param {String} The name of the day (eg. "Monday, "Mon", "tuesday", "tue", "We", "we"). * @return {Number} The day number */ $D.getDayNumberFromName = function (name) { var n = Date.CultureInfo.dayNames, m = Date.CultureInfo.abbreviatedDayNames, o = Date.CultureInfo.shortestDayNames, s = name.toLowerCase(); for (var i = 0; i < n.length; i++) { if (n[i].toLowerCase() === s || m[i].toLowerCase() === s || o[i].toLowerCase() === s) { return i; } } return -1; }; /** * Gets the month number (0-11) if given a Culture Info specific string which is a valid monthName or abbreviatedMonthName. * @param {String} The name of the month (eg. "February, "Feb", "october", "oct"). * @return {Number} The day number */ $D.getMonthNumberFromName = function (name) { var n = Date.CultureInfo.monthNames, m = Date.CultureInfo.abbreviatedMonthNames, s = name.toLowerCase(); for (var i = 0; i < n.length; i++) { if (n[i].toLowerCase() === s || m[i].toLowerCase() === s) { return i; } } return -1; }; /** * Gets the language appropriate month name when given the month number(0-11) * eg - 0 == January * @return {String} The month name */ $D.getMonthName = function (n) { return Date.CultureInfo.monthNames[n]; }; /** * Determines if the current date instance is within a LeapYear. * @param {Number} The year. * @return {Boolean} true if date is within a LeapYear, otherwise false. */ $D.isLeapYear = function (year) { return ((year % 4 === 0 && year % 100 !== 0) || year % 400 === 0); }; /** * Gets the number of days in the month, given a year and month value. Automatically corrects for LeapYear. * @param {Number} The year. * @param {Number} The month (0-11). * @return {Number} The number of days in the month. */ $D.getDaysInMonth = function (year, month) { if (!month && $D.validateMonth(year)) { month = year; year = Date.today().getFullYear(); } return [31, ($D.isLeapYear(year) ? 29 : 28), 31, 30, 31, 30, 31, 31, 30, 31, 30, 31][month]; }; $P.getDaysInMonth = function () { return $D.getDaysInMonth(this.getFullYear(), this.getMonth()); }; $D.getTimezoneAbbreviation = function (offset, dst) { var p, n = (dst || false) ? Date.CultureInfo.abbreviatedTimeZoneDST : Date.CultureInfo.abbreviatedTimeZoneStandard; for (p in n) { if (n.hasOwnProperty(p)) { if (n[p] === offset) { return p; } } } return null; }; $D.getTimezoneOffset = function (name, dst) { var i, a =[], z = Date.CultureInfo.timezones; if (!name) { name = (new Date()).getTimezone();} for (i = 0; i < z.length; i++) { if (z[i].name === name.toUpperCase()) { a.push(i); } } if (!z[a[0]]) { return null; } if (a.length === 1 || !dst) { return z[a[0]].offset; } else { for (i=0; i < a.length; i++) { if (z[a[i]].dst) { return z[a[i]].offset; } } } }; $D.getQuarter = function (d) { d = d || new Date(); // If no date supplied, use today var q = [1,2,3,4]; return q[Math.floor(d.getMonth() / 3)]; // ~~~ is a bitwise op. Faster than Math.floor }; $D.getDaysLeftInQuarter = function (d) { d = d || new Date(); var qEnd = new Date(d); qEnd.setMonth(qEnd.getMonth() + 3 - qEnd.getMonth() % 3, 0); return Math.floor((qEnd - d) / 8.64e7); }; // private var validate = function (n, min, max, name) { name = name ? name : "Object"; if (typeof n === "undefined") { return false; } else if (typeof n !== "number") { throw new TypeError(n + " is not a Number."); } else if (n < min || n > max) { // As failing validation is *not* an exceptional circumstance // lets not throw a RangeError Exception here. // It's semantically correct but it's not sensible. return false; } return true; }; /** * Validates the number is within an acceptable range for milliseconds [0-999]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateMillisecond = function (value) { return validate(value, 0, 999, "millisecond"); }; /** * Validates the number is within an acceptable range for seconds [0-59]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateSecond = function (value) { return validate(value, 0, 59, "second"); }; /** * Validates the number is within an acceptable range for minutes [0-59]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateMinute = function (value) { return validate(value, 0, 59, "minute"); }; /** * Validates the number is within an acceptable range for hours [0-23]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateHour = function (value) { return validate(value, 0, 23, "hour"); }; /** * Validates the number is within an acceptable range for the days in a month [0-MaxDaysInMonth]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateDay = function (value, year, month) { if (year === undefined || year === null || month === undefined || month === null) { return false;} return validate(value, 1, $D.getDaysInMonth(year, month), "day"); }; /** * Validates the number is within an acceptable range for months [0-11]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateWeek = function (value) { return validate(value, 0, 53, "week"); }; /** * Validates the number is within an acceptable range for months [0-11]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateMonth = function (value) { return validate(value, 0, 11, "month"); }; /** * Validates the number is within an acceptable range for years. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateYear = function (value) { /** * Per ECMAScript spec the range of times supported by Date objects is * exactly -100,000,000 days to +100,000,000 days measured relative to * midnight at the beginning of 01 January, 1970 UTC. * This gives a range of 8,640,000,000,000,000 milliseconds to either * side of 01 January, 1970 UTC. * * Earliest possible date: Tue, 20 Apr 271,822 B.C. 00:00:00 UTC * Latest possible date: Sat, 13 Sep 275,760 00:00:00 UTC */ return validate(value, -271822, 275760, "year"); }; $D.validateTimezone = function(value) { var timezones = {"ACDT":1,"ACST":1,"ACT":1,"ADT":1,"AEDT":1,"AEST":1,"AFT":1,"AKDT":1,"AKST":1,"AMST":1,"AMT":1,"ART":1,"AST":1,"AWDT":1,"AWST":1,"AZOST":1,"AZT":1,"BDT":1,"BIOT":1,"BIT":1,"BOT":1,"BRT":1,"BST":1,"BTT":1,"CAT":1,"CCT":1,"CDT":1,"CEDT":1,"CEST":1,"CET":1,"CHADT":1,"CHAST":1,"CHOT":1,"ChST":1,"CHUT":1,"CIST":1,"CIT":1,"CKT":1,"CLST":1,"CLT":1,"COST":1,"COT":1,"CST":1,"CT":1,"CVT":1,"CWST":1,"CXT":1,"DAVT":1,"DDUT":1,"DFT":1,"EASST":1,"EAST":1,"EAT":1,"ECT":1,"EDT":1,"EEDT":1,"EEST":1,"EET":1,"EGST":1,"EGT":1,"EIT":1,"EST":1,"FET":1,"FJT":1,"FKST":1,"FKT":1,"FNT":1,"GALT":1,"GAMT":1,"GET":1,"GFT":1,"GILT":1,"GIT":1,"GMT":1,"GST":1,"GYT":1,"HADT":1,"HAEC":1,"HAST":1,"HKT":1,"HMT":1,"HOVT":1,"HST":1,"ICT":1,"IDT":1,"IOT":1,"IRDT":1,"IRKT":1,"IRST":1,"IST":1,"JST":1,"KGT":1,"KOST":1,"KRAT":1,"KST":1,"LHST":1,"LINT":1,"MAGT":1,"MART":1,"MAWT":1,"MDT":1,"MET":1,"MEST":1,"MHT":1,"MIST":1,"MIT":1,"MMT":1,"MSK":1,"MST":1,"MUT":1,"MVT":1,"MYT":1,"NCT":1,"NDT":1,"NFT":1,"NPT":1,"NST":1,"NT":1,"NUT":1,"NZDT":1,"NZST":1,"OMST":1,"ORAT":1,"PDT":1,"PET":1,"PETT":1,"PGT":1,"PHOT":1,"PHT":1,"PKT":1,"PMDT":1,"PMST":1,"PONT":1,"PST":1,"PYST":1,"PYT":1,"RET":1,"ROTT":1,"SAKT":1,"SAMT":1,"SAST":1,"SBT":1,"SCT":1,"SGT":1,"SLST":1,"SRT":1,"SST":1,"SYOT":1,"TAHT":1,"THA":1,"TFT":1,"TJT":1,"TKT":1,"TLT":1,"TMT":1,"TOT":1,"TVT":1,"UCT":1,"ULAT":1,"UTC":1,"UYST":1,"UYT":1,"UZT":1,"VET":1,"VLAT":1,"VOLT":1,"VOST":1,"VUT":1,"WAKT":1,"WAST":1,"WAT":1,"WEDT":1,"WEST":1,"WET":1,"WST":1,"YAKT":1,"YEKT":1,"Z":1}; return (timezones[value] === 1); }; $D.validateTimezoneOffset= function(value) { // timezones go from +14hrs to -12hrs, the +X hours are negative offsets. return (value > -841 && value < 721); }; }()); (function () { var $D = Date, $P = $D.prototype, p = function (s, l) { if (!l) { l = 2; } return ("000" + s).slice(l * -1); }; var validateConfigObject = function (obj) { var result = {}, self = this, prop, testFunc; testFunc = function (prop, func, value) { if (prop === "day") { var month = (obj.month !== undefined) ? obj.month : self.getMonth(); var year = (obj.year !== undefined) ? obj.year : self.getFullYear(); return $D[func](value, year, month); } else { return $D[func](value); } }; for (prop in obj) { if (Object.prototype.hasOwnProperty.call(obj, prop)) { var func = "validate" + prop.charAt(0).toUpperCase() + prop.slice(1); if ($D[func] && obj[prop] !== null && testFunc(prop, func, obj[prop])) { result[prop] = obj[prop]; } } } return result; }; /** * Resets the time of this Date object to 12:00 AM (00:00), which is the start of the day. * @param {Boolean} .clone() this date instance before clearing Time * @return {Date} this */ $P.clearTime = function () { this.setHours(0); this.setMinutes(0); this.setSeconds(0); this.setMilliseconds(0); return this; }; /** * Resets the time of this Date object to the current time ('now'). * @return {Date} this */ $P.setTimeToNow = function () { var n = new Date(); this.setHours(n.getHours()); this.setMinutes(n.getMinutes()); this.setSeconds(n.getSeconds()); this.setMilliseconds(n.getMilliseconds()); return this; }; /** * Returns a new Date object that is an exact date and time copy of the original instance. * @return {Date} A new Date instance */ $P.clone = function () { return new Date(this.getTime()); }; /** * Compares this instance to a Date object and returns an number indication of their relative values. * @param {Date} Date object to compare [Required] * @return {Number} -1 = this is lessthan date. 0 = values are equal. 1 = this is greaterthan date. */ $P.compareTo = function (date) { return Date.compare(this, date); }; /** * Compares this instance to another Date object and returns true if they are equal. * @param {Date} Date object to compare. If no date to compare, new Date() [now] is used. * @return {Boolean} true if dates are equal. false if they are not equal. */ $P.equals = function (date) { return Date.equals(this, (date !== undefined ? date : new Date())); }; /** * Determines if this instance is between a range of two dates or equal to either the start or end dates. * @param {Date} Start of range [Required] * @param {Date} End of range [Required] * @return {Boolean} true is this is between or equal to the start and end dates, else false */ $P.between = function (start, end) { return this.getTime() >= start.getTime() && this.getTime() <= end.getTime(); }; /** * Determines if this date occurs after the date to compare to. * @param {Date} Date object to compare. If no date to compare, new Date() ("now") is used. * @return {Boolean} true if this date instance is greater than the date to compare to (or "now"), otherwise false. */ $P.isAfter = function (date) { return this.compareTo(date || new Date()) === 1; }; /** * Determines if this date occurs before the date to compare to. * @param {Date} Date object to compare. If no date to compare, new Date() ("now") is used. * @return {Boolean} true if this date instance is less than the date to compare to (or "now"). */ $P.isBefore = function (date) { return (this.compareTo(date || new Date()) === -1); }; /** * Determines if the current Date instance occurs today. * @return {Boolean} true if this date instance is 'today', otherwise false. */ /** * Determines if the current Date instance occurs on the same Date as the supplied 'date'. * If no 'date' to compare to is provided, the current Date instance is compared to 'today'. * @param {date} Date object to compare. If no date to compare, the current Date ("now") is used. * @return {Boolean} true if this Date instance occurs on the same Day as the supplied 'date'. */ $P.isToday = $P.isSameDay = function (date) { return this.clone().clearTime().equals((date || new Date()).clone().clearTime()); }; /** * Adds the specified number of milliseconds to this instance. * @param {Number} The number of milliseconds to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addMilliseconds = function (value) { if (!value) { return this; } this.setTime(this.getTime() + value * 1); return this; }; /** * Adds the specified number of seconds to this instance. * @param {Number} The number of seconds to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addSeconds = function (value) { if (!value) { return this; } return this.addMilliseconds(value * 1000); }; /** * Adds the specified number of seconds to this instance. * @param {Number} The number of seconds to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addMinutes = function (value) { if (!value) { return this; } return this.addMilliseconds(value * 60000); // 60*1000 }; /** * Adds the specified number of hours to this instance. * @param {Number} The number of hours to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addHours = function (value) { if (!value) { return this; } return this.addMilliseconds(value * 3600000); // 60*60*1000 }; /** * Adds the specified number of days to this instance. * @param {Number} The number of days to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addDays = function (value) { if (!value) { return this; } this.setDate(this.getDate() + value * 1); return this; }; /** * Adds the specified number of weekdays (ie - not sat or sun) to this instance. * @param {Number} The number of days to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addWeekdays = function (value) { if (!value) { return this; } var day = this.getDay(); var weeks = (Math.ceil(Math.abs(value)/7)); if (day === 0 || day === 6) { if (value > 0) { this.next().monday(); this.addDays(-1); day = this.getDay(); } } if (value < 0) { while (value < 0) { this.addDays(-1); day = this.getDay(); if (day !== 0 && day !== 6) { value++; } } return this; } else if (value > 5 || (6-day) <= value) { value = value + (weeks * 2); } return this.addDays(value); }; /** * Adds the specified number of weeks to this instance. * @param {Number} The number of weeks to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addWeeks = function (value) { if (!value) { return this; } return this.addDays(value * 7); }; /** * Adds the specified number of months to this instance. * @param {Number} The number of months to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addMonths = function (value) { if (!value) { return this; } var n = this.getDate(); this.setDate(1); this.setMonth(this.getMonth() + value * 1); this.setDate(Math.min(n, $D.getDaysInMonth(this.getFullYear(), this.getMonth()))); return this; }; $P.addQuarters = function (value) { if (!value) { return this; } // note this will take you to the same point in the quarter as you are now. // i.e. - if you are 15 days into the quarter you'll be 15 days into the resulting one. // bonus: this allows adding fractional quarters return this.addMonths(value * 3); }; /** * Adds the specified number of years to this instance. * @param {Number} The number of years to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addYears = function (value) { if (!value) { return this; } return this.addMonths(value * 12); }; /** * Adds (or subtracts) to the value of the years, months, weeks, days, hours, minutes, seconds, milliseconds of the date instance using given configuration object. Positive and Negative values allowed. * Example

	Date.today().add( { days: 1, months: 1 } )

	new Date().add( { years: -1 } )
	
* @param {Object} Configuration object containing attributes (months, days, etc.) * @return {Date} this */ $P.add = function (config) { if (typeof config === "number") { this._orient = config; return this; } var x = config; if (x.day) { // If we should be a different date than today (eg: for 'tomorrow -1d', etc). // Should only effect parsing, not direct usage (eg, Finish and FinishExact) if ((x.day - this.getDate()) !== 0) { this.setDate(x.day); } } if (x.milliseconds) { this.addMilliseconds(x.milliseconds); } if (x.seconds) { this.addSeconds(x.seconds); } if (x.minutes) { this.addMinutes(x.minutes); } if (x.hours) { this.addHours(x.hours); } if (x.weeks) { this.addWeeks(x.weeks); } if (x.months) { this.addMonths(x.months); } if (x.years) { this.addYears(x.years); } if (x.days) { this.addDays(x.days); } return this; }; /** * Get the week number. Week one (1) is the week which contains the first Thursday of the year. Monday is considered the first day of the week. * The .getWeek() function does NOT convert the date to UTC. The local datetime is used. * Please use .getISOWeek() to get the week of the UTC converted date. * @return {Number} 1 to 53 */ $P.getWeek = function (utc) { // Create a copy of this date object var self, target = new Date(this.valueOf()); if (utc) { target.addMinutes(target.getTimezoneOffset()); self = target.clone(); } else { self = this; } // ISO week date weeks start on monday // so correct the day number var dayNr = (self.getDay() + 6) % 7; // ISO 8601 states that week 1 is the week // with the first thursday of that year. // Set the target date to the thursday in the target week target.setDate(target.getDate() - dayNr + 3); // Store the millisecond value of the target date var firstThursday = target.valueOf(); // Set the target to the first thursday of the year // First set the target to january first target.setMonth(0, 1); // Not a thursday? Correct the date to the next thursday if (target.getDay() !== 4) { target.setMonth(0, 1 + ((4 - target.getDay()) + 7) % 7); } // The weeknumber is the number of weeks between the // first thursday of the year and the thursday in the target week return 1 + Math.ceil((firstThursday - target) / 604800000); // 604800000 = 7 * 24 * 3600 * 1000 }; /** * Get the ISO 8601 week number. Week one ("01") is the week which contains the first Thursday of the year. Monday is considered the first day of the week. * The .getISOWeek() function does convert the date to it's UTC value. Please use .getWeek() to get the week of the local date. * @return {String} "01" to "53" */ $P.getISOWeek = function () { return p(this.getWeek(true)); }; /** * Moves the date to Monday of the week set. Week one (1) is the week which contains the first Thursday of the year. * @param {Number} A Number (1 to 53) that represents the week of the year. * @return {Date} this */ $P.setWeek = function (n) { if ((n - this.getWeek()) === 0) { if (this.getDay() !== 1) { return this.moveToDayOfWeek(1, (this.getDay() > 1 ? -1 : 1)); } else { return this; } } else { return this.moveToDayOfWeek(1, (this.getDay() > 1 ? -1 : 1)).addWeeks(n - this.getWeek()); } }; $P.setQuarter = function (qtr) { var month = Math.abs(((qtr-1) * 3) + 1); return this.setMonth(month, 1); }; $P.getQuarter = function () { return Date.getQuarter(this); }; $P.getDaysLeftInQuarter = function () { return Date.getDaysLeftInQuarter(this); }; /** * Moves the date to the next n'th occurrence of the dayOfWeek starting from the beginning of the month. The number (-1) is a magic number and will return the last occurrence of the dayOfWeek in the month. * @param {Number} The dayOfWeek to move to * @param {Number} The n'th occurrence to move to. Use (-1) to return the last occurrence in the month * @return {Date} this */ $P.moveToNthOccurrence = function (dayOfWeek, occurrence) { if (dayOfWeek === "Weekday") { if (occurrence > 0) { this.moveToFirstDayOfMonth(); if (this.is().weekday()) { occurrence -= 1; } } else if (occurrence < 0) { this.moveToLastDayOfMonth(); if (this.is().weekday()) { occurrence += 1; } } else { return this; } return this.addWeekdays(occurrence); } var shift = 0; if (occurrence > 0) { shift = occurrence - 1; } else if (occurrence === -1) { this.moveToLastDayOfMonth(); if (this.getDay() !== dayOfWeek) { this.moveToDayOfWeek(dayOfWeek, -1); } return this; } return this.moveToFirstDayOfMonth().addDays(-1).moveToDayOfWeek(dayOfWeek, +1).addWeeks(shift); }; var moveToN = function (getFunc, addFunc, nVal) { return function (value, orient) { var diff = (value - this[getFunc]() + nVal * (orient || +1)) % nVal; return this[addFunc]((diff === 0) ? diff += nVal * (orient || +1) : diff); }; }; /** * Move to the next or last dayOfWeek based on the orient value. * @param {Number} The dayOfWeek to move to * @param {Number} Forward (+1) or Back (-1). Defaults to +1. [Optional] * @return {Date} this */ $P.moveToDayOfWeek = moveToN("getDay", "addDays", 7); /** * Move to the next or last month based on the orient value. * @param {Number} The month to move to. 0 = January, 11 = December * @param {Number} Forward (+1) or Back (-1). Defaults to +1. [Optional] * @return {Date} this */ $P.moveToMonth = moveToN("getMonth", "addMonths", 12); /** * Get the Ordinate of the current day ("th", "st", "rd"). * @return {String} */ $P.getOrdinate = function () { var num = this.getDate(); return ord(num); }; /** * Get the Ordinal day (numeric day number) of the year, adjusted for leap year. * @return {Number} 1 through 365 (366 in leap years) */ $P.getOrdinalNumber = function () { return Math.ceil((this.clone().clearTime() - new Date(this.getFullYear(), 0, 1)) / 86400000) + 1; }; /** * Get the time zone abbreviation of the current date. * @return {String} The abbreviated time zone name (e.g. "EST") */ $P.getTimezone = function () { return $D.getTimezoneAbbreviation(this.getUTCOffset(), this.isDaylightSavingTime()); }; $P.setTimezoneOffset = function (offset) { var here = this.getTimezoneOffset(), there = Number(offset) * -6 / 10; return (there || there === 0) ? this.addMinutes(there - here) : this; }; $P.setTimezone = function (offset) { return this.setTimezoneOffset($D.getTimezoneOffset(offset)); }; /** * Indicates whether Daylight Saving Time is observed in the current time zone. * @return {Boolean} true|false */ $P.hasDaylightSavingTime = function () { return (Date.today().set({month: 0, day: 1}).getTimezoneOffset() !== Date.today().set({month: 6, day: 1}).getTimezoneOffset()); }; /** * Indicates whether this Date instance is within the Daylight Saving Time range for the current time zone. * @return {Boolean} true|false */ $P.isDaylightSavingTime = function () { return Date.today().set({month: 0, day: 1}).getTimezoneOffset() !== this.getTimezoneOffset(); }; /** * Get the offset from UTC of the current date. * @return {String} The 4-character offset string prefixed with + or - (e.g. "-0500") */ $P.getUTCOffset = function (offset) { var n = (offset || this.getTimezoneOffset()) * -10 / 6, r; if (n < 0) { r = (n - 10000).toString(); return r.charAt(0) + r.substr(2); } else { r = (n + 10000).toString(); return "+" + r.substr(1); } }; /** * Returns the number of milliseconds between this date and date. * @param {Date} Defaults to now * @return {Number} The diff in milliseconds */ $P.getElapsed = function (date) { return (date || new Date()) - this; }; /** * Set the value of year, month, day, hour, minute, second, millisecond of date instance using given configuration object. * Example

	Date.today().set( { day: 20, month: 1 } )

	new Date().set( { millisecond: 0 } )
	
* * @param {Object} Configuration object containing attributes (month, day, etc.) * @return {Date} this */ $P.set = function (config) { config = validateConfigObject.call(this, config); var key; for (key in config) { if (Object.prototype.hasOwnProperty.call(config, key)) { var name = key.charAt(0).toUpperCase() + key.slice(1); var addFunc, getFunc; if (key !== "week" && key !== "month" && key !== "timezone" && key !== "timezoneOffset") { name += "s"; } addFunc = "add" + name; getFunc = "get" + name; if (key === "month") { addFunc = addFunc + "s"; } else if (key === "year"){ getFunc = "getFullYear"; } if (key !== "day" && key !== "timezone" && key !== "timezoneOffset" && key !== "week" && key !== "hour") { this[addFunc](config[key] - this[getFunc]()); } else if ( key === "timezone"|| key === "timezoneOffset" || key === "week" || key === "hour") { this["set"+name](config[key]); } } } // day has to go last because you can't validate the day without first knowing the month if (config.day) { this.addDays(config.day - this.getDate()); } return this; }; /** * Moves the date to the first day of the month. * @return {Date} this */ $P.moveToFirstDayOfMonth = function () { return this.set({ day: 1 }); }; /** * Moves the date to the last day of the month. * @return {Date} this */ $P.moveToLastDayOfMonth = function () { return this.set({ day: $D.getDaysInMonth(this.getFullYear(), this.getMonth())}); }; /** * Converts the value of the current Date object to its equivalent string representation. * Format Specifiers * CUSTOM DATE AND TIME FORMAT STRINGS * Format Description Example * ------ --------------------------------------------------------------------------- ----------------------- * s The seconds of the minute between 0-59. "0" to "59" * ss The seconds of the minute with leading zero if required. "00" to "59" * * m The minute of the hour between 0-59. "0" or "59" * mm The minute of the hour with leading zero if required. "00" or "59" * * h The hour of the day between 1-12. "1" to "12" * hh The hour of the day with leading zero if required. "01" to "12" * * H The hour of the day between 0-23. "0" to "23" * HH The hour of the day with leading zero if required. "00" to "23" * * d The day of the month between 1 and 31. "1" to "31" * dd The day of the month with leading zero if required. "01" to "31" * ddd Abbreviated day name. Date.CultureInfo.abbreviatedDayNames. "Mon" to "Sun" * dddd The full day name. Date.CultureInfo.dayNames. "Monday" to "Sunday" * * M The month of the year between 1-12. "1" to "12" * MM The month of the year with leading zero if required. "01" to "12" * MMM Abbreviated month name. Date.CultureInfo.abbreviatedMonthNames. "Jan" to "Dec" * MMMM The full month name. Date.CultureInfo.monthNames. "January" to "December" * * yy The year as a two-digit number. "99" or "08" * yyyy The full four digit year. "1999" or "2008" * * t Displays the first character of the A.M./P.M. designator. "A" or "P" * Date.CultureInfo.amDesignator or Date.CultureInfo.pmDesignator * tt Displays the A.M./P.M. designator. "AM" or "PM" * Date.CultureInfo.amDesignator or Date.CultureInfo.pmDesignator * * S The ordinal suffix ("st, "nd", "rd" or "th") of the current day. "st, "nd", "rd" or "th" * * STANDARD DATE AND TIME FORMAT STRINGS * Format Description Example *------ --------------------------------------------------------------------------- ----------------------- * d The CultureInfo shortDate Format Pattern "M/d/yyyy" * D The CultureInfo longDate Format Pattern "dddd, MMMM dd, yyyy" * F The CultureInfo fullDateTime Format Pattern "dddd, MMMM dd, yyyy h:mm:ss tt" * m The CultureInfo monthDay Format Pattern "MMMM dd" * r The CultureInfo rfc1123 Format Pattern "ddd, dd MMM yyyy HH:mm:ss GMT" * s The CultureInfo sortableDateTime Format Pattern "yyyy-MM-ddTHH:mm:ss" * t The CultureInfo shortTime Format Pattern "h:mm tt" * T The CultureInfo longTime Format Pattern "h:mm:ss tt" * u The CultureInfo universalSortableDateTime Format Pattern "yyyy-MM-dd HH:mm:ssZ" * y The CultureInfo yearMonth Format Pattern "MMMM, yyyy" * * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @return {String} A string representation of the current Date object. */ var ord = function (n) { switch (n * 1) { case 1: case 21: case 31: return "st"; case 2: case 22: return "nd"; case 3: case 23: return "rd"; default: return "th"; } }; var parseStandardFormats = function (format) { var y, c = Date.CultureInfo.formatPatterns; switch (format) { case "d": return this.toString(c.shortDate); case "D": return this.toString(c.longDate); case "F": return this.toString(c.fullDateTime); case "m": return this.toString(c.monthDay); case "r": case "R": y = this.clone().addMinutes(this.getTimezoneOffset()); return y.toString(c.rfc1123) + " GMT"; case "s": return this.toString(c.sortableDateTime); case "t": return this.toString(c.shortTime); case "T": return this.toString(c.longTime); case "u": y = this.clone().addMinutes(this.getTimezoneOffset()); return y.toString(c.universalSortableDateTime); case "y": return this.toString(c.yearMonth); default: return false; } }; var parseFormatStringsClosure = function (context) { return function (m) { if (m.charAt(0) === "\\") { return m.replace("\\", ""); } switch (m) { case "hh": return p(context.getHours() < 13 ? (context.getHours() === 0 ? 12 : context.getHours()) : (context.getHours() - 12)); case "h": return context.getHours() < 13 ? (context.getHours() === 0 ? 12 : context.getHours()) : (context.getHours() - 12); case "HH": return p(context.getHours()); case "H": return context.getHours(); case "mm": return p(context.getMinutes()); case "m": return context.getMinutes(); case "ss": return p(context.getSeconds()); case "s": return context.getSeconds(); case "yyyy": return p(context.getFullYear(), 4); case "yy": return p(context.getFullYear()); case "y": return context.getFullYear(); case "E": case "dddd": return Date.CultureInfo.dayNames[context.getDay()]; case "ddd": return Date.CultureInfo.abbreviatedDayNames[context.getDay()]; case "dd": return p(context.getDate()); case "d": return context.getDate(); case "MMMM": return Date.CultureInfo.monthNames[context.getMonth()]; case "MMM": return Date.CultureInfo.abbreviatedMonthNames[context.getMonth()]; case "MM": return p((context.getMonth() + 1)); case "M": return context.getMonth() + 1; case "t": return context.getHours() < 12 ? Date.CultureInfo.amDesignator.substring(0, 1) : Date.CultureInfo.pmDesignator.substring(0, 1); case "tt": return context.getHours() < 12 ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator; case "S": return ord(context.getDate()); case "W": return context.getWeek(); case "WW": return context.getISOWeek(); case "Q": return "Q" + context.getQuarter(); case "q": return String(context.getQuarter()); case "z": return context.getTimezone(); case "Z": case "X": return Date.getTimezoneOffset(context.getTimezone()); case "ZZ": // Timezone offset in seconds return context.getTimezoneOffset() * -60; case "u": return context.getDay(); case "L": return ($D.isLeapYear(context.getFullYear())) ? 1 : 0; case "B": // Swatch Internet Time (.beats) return "@"+((context.getUTCSeconds() + (context.getUTCMinutes()*60) + ((context.getUTCHours()+1)*3600))/86.4); default: return m; } }; }; $P.toString = function (format, ignoreStandards) { // Standard Date and Time Format Strings. Formats pulled from CultureInfo file and // may vary by culture. if (!ignoreStandards && format && format.length === 1) { output = parseStandardFormats.call(this, format); if (output) { return output; } } var parseFormatStrings = parseFormatStringsClosure(this); return format ? format.replace(/((\\)?(dd?d?d?|MM?M?M?|yy?y?y?|hh?|HH?|mm?|ss?|tt?|S|q|Q|WW?W?W?)(?![^\[]*\]))/g, parseFormatStrings).replace(/\[|\]/g, "") : this._toString(); }; }()); /************************************************************* * SugarPak - Domain Specific Language - Syntactical Sugar * *************************************************************/ (function () { var $D = Date, $P = $D.prototype, $N = Number.prototype; // private $P._orient = +1; // private $P._nth = null; // private $P._is = false; // private $P._same = false; // private $P._isSecond = false; // private $N._dateElement = "days"; /** * Moves the date to the next instance of a date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.today().next().friday();
	Date.today().next().fri();
	Date.today().next().march();
	Date.today().next().mar();
	Date.today().next().week();
	
* * @return {Date} date */ $P.next = function () { this._move = true; this._orient = +1; return this; }; /** * Creates a new Date (Date.today()) and moves the date to the next instance of the date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.next().friday();
	Date.next().fri();
	Date.next().march();
	Date.next().mar();
	Date.next().week();
	
* * @return {Date} date */ $D.next = function () { return $D.today().next(); }; /** * Moves the date to the previous instance of a date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.today().last().friday();
	Date.today().last().fri();
	Date.today().last().march();
	Date.today().last().mar();
	Date.today().last().week();
	
* * @return {Date} date */ $P.last = $P.prev = $P.previous = function () { this._move = true; this._orient = -1; return this; }; /** * Creates a new Date (Date.today()) and moves the date to the previous instance of the date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.last().friday();
	Date.last().fri();
	Date.previous().march();
	Date.prev().mar();
	Date.last().week();
	
* * @return {Date} date */ $D.last = $D.prev = $D.previous = function () { return $D.today().last(); }; /** * Performs a equality check when followed by either a month name, day name or .weekday() function. * Example

	Date.today().is().friday(); // true|false
	Date.today().is().fri();
	Date.today().is().march();
	Date.today().is().mar();
	
* * @return {Boolean} true|false */ $P.is = function () { this._is = true; return this; }; /** * Determines if two date objects occur on/in exactly the same instance of the subsequent date part function. * The function .same() must be followed by a date part function (example: .day(), .month(), .year(), etc). * * An optional Date can be passed in the date part function. If now date is passed as a parameter, 'Now' is used. * * The following example demonstrates how to determine if two dates fall on the exact same day. * * Example

	var d1 = Date.today(); // today at 00:00
	var d2 = new Date();   // exactly now.

	// Do they occur on the same day?
	d1.same().day(d2); // true
	
	// Do they occur on the same hour?
	d1.same().hour(d2); // false, unless d2 hour is '00' (midnight).
	
	// What if it's the same day, but one year apart?
	var nextYear = Date.today().add(1).year();

	d1.same().day(nextYear); // false, because the dates must occur on the exact same day. 
	
* * Scenario: Determine if a given date occurs during some week period 2 months from now. * * Example

	var future = Date.today().add(2).months();
	return someDate.same().week(future); // true|false;
	
* * @return {Boolean} true|false */ $P.same = function () { this._same = true; this._isSecond = false; return this; }; /** * Determines if the current date/time occurs during Today. Must be preceded by the .is() function. * Example

	someDate.is().today();    // true|false
	new Date().is().today();  // true
	Date.today().is().today();// true
	Date.today().add(-1).day().is().today(); // false
	
* * @return {Boolean} true|false */ $P.today = function () { return this.same().day(); }; /** * Determines if the current date is a weekday. This function must be preceded by the .is() function. * Example

	Date.today().is().weekday(); // true|false
	
* * @return {Boolean} true|false */ $P.weekday = function () { if (this._nth) { return df("Weekday").call(this); } if (this._move) { return this.addWeekdays(this._orient); } if (this._is) { this._is = false; return (!this.is().sat() && !this.is().sun()); } return false; }; /** * Determines if the current date is on the weekend. This function must be preceded by the .is() function. * Example

	Date.today().is().weekend(); // true|false
	
* * @return {Boolean} true|false */ $P.weekend = function () { if (this._is) { this._is = false; return (this.is().sat() || this.is().sun()); } return false; }; /** * Sets the Time of the current Date instance. A string "6:15 pm" or config object {hour:18, minute:15} are accepted. * Example

	// Set time to 6:15pm with a String
	Date.today().at("6:15pm");

	// Set time to 6:15pm with a config object
	Date.today().at({hour:18, minute:15});
	
* * @return {Date} date */ $P.at = function (time) { return (typeof time === "string") ? $D.parse(this.toString("d") + " " + time) : this.set(time); }; /** * Creates a new Date() and adds this (Number) to the date based on the preceding date element function (eg. second|minute|hour|day|month|year). * Example

	// Undeclared Numbers must be wrapped with parentheses. Requirment of JavaScript.
	(3).days().fromNow();
	(6).months().fromNow();

	// Declared Number variables do not require parentheses. 
	var n = 6;
	n.months().fromNow();
	
* * @return {Date} A new Date instance */ $N.fromNow = $N.after = function (date) { var c = {}; c[this._dateElement] = this; return ((!date) ? new Date() : date.clone()).add(c); }; /** * Creates a new Date() and subtract this (Number) from the date based on the preceding date element function (eg. second|minute|hour|day|month|year). * Example

	// Undeclared Numbers must be wrapped with parentheses. Requirment of JavaScript.
	(3).days().ago();
	(6).months().ago();

	// Declared Number variables do not require parentheses. 
	var n = 6;
	n.months().ago();
	
* * @return {Date} A new Date instance */ $N.ago = $N.before = function (date) { var c = {}, s = (this._dateElement[this._dateElement.length-1] !== "s") ? this._dateElement + "s" : this._dateElement; c[s] = this * -1; return ((!date) ? new Date() : date.clone()).add(c); }; // Do NOT modify the following string tokens. These tokens are used to build dynamic functions. // All culture-specific strings can be found in the CultureInfo files. var dx = ("sunday monday tuesday wednesday thursday friday saturday").split(/\s/), mx = ("january february march april may june july august september october november december").split(/\s/), px = ("Millisecond Second Minute Hour Day Week Month Year Quarter Weekday").split(/\s/), pxf = ("Milliseconds Seconds Minutes Hours Date Week Month FullYear Quarter").split(/\s/), nth = ("final first second third fourth fifth").split(/\s/), de; /** * Returns an object literal of all the date parts. * Example

	var o = new Date().toObject();
	
	// { year: 2008, month: 4, week: 20, day: 13, hour: 18, minute: 9, second: 32, millisecond: 812 }
	
	// The object properties can be referenced directly from the object.
	
	alert(o.day);  // alerts "13"
	alert(o.year); // alerts "2008"
	
* * @return {Date} An object literal representing the original date object. */ $P.toObject = function () { var o = {}; for (var i = 0; i < px.length; i++) { if (this["get" + pxf[i]]) { o[px[i].toLowerCase()] = this["get" + pxf[i]](); } } return o; }; /** * Returns a date created from an object literal. Ignores the .week property if set in the config. * Example

	var o = new Date().toObject();
	
	return Date.fromObject(o); // will return the same date. 

	var o2 = {month: 1, day: 20, hour: 18}; // birthday party!
	Date.fromObject(o2);
	
* * @return {Date} An object literal representing the original date object. */ $D.fromObject = function(config) { config.week = null; return Date.today().set(config); }; // Create day name functions and abbreviated day name functions (eg. monday(), friday(), fri()). var df = function (n) { return function () { if (this._is) { this._is = false; return this.getDay() === n; } if (this._move) { this._move = null; } if (this._nth !== null) { // If the .second() function was called earlier, remove the _orient // from the date, and then continue. // This is required because 'second' can be used in two different context. // // Example // // Date.today().add(1).second(); // Date.march().second().monday(); // // Things get crazy with the following... // Date.march().add(1).second().second().monday(); // but it works!! // if (this._isSecond) { this.addSeconds(this._orient * -1); } // make sure we reset _isSecond this._isSecond = false; var ntemp = this._nth; this._nth = null; var temp = this.clone().moveToLastDayOfMonth(); this.moveToNthOccurrence(n, ntemp); if (this > temp) { throw new RangeError($D.getDayName(n) + " does not occur " + ntemp + " times in the month of " + $D.getMonthName(temp.getMonth()) + " " + temp.getFullYear() + "."); } return this; } return this.moveToDayOfWeek(n, this._orient); }; }; var sdf = function (n) { return function () { var t = $D.today(), shift = n - t.getDay(); if (n === 0 && Date.CultureInfo.firstDayOfWeek === 1 && t.getDay() !== 0) { shift = shift + 7; } return t.addDays(shift); }; }; // Create month name functions and abbreviated month name functions (eg. january(), march(), mar()). var month_instance_functions = function (n) { return function () { if (this._is) { this._is = false; return this.getMonth() === n; } return this.moveToMonth(n, this._orient); }; }; var month_static_functions = function (n) { return function () { return $D.today().set({ month: n, day: 1 }); }; }; var processTerms = function (names, staticFunc, instanceFunc) { for (var i = 0; i < names.length; i++) { // Create constant static Name variables. $D[names[i].toUpperCase()] = $D[names[i].toUpperCase().substring(0, 3)] = i; // Create Name functions. $D[names[i]] = $D[names[i].substring(0, 3)] = staticFunc(i); // Create Name instance functions. $P[names[i]] = $P[names[i].substring(0, 3)] = instanceFunc(i); } }; processTerms(dx, sdf, df); processTerms(mx, month_static_functions, month_instance_functions); // Create date element functions and plural date element functions used with Date (eg. day(), days(), months()). var ef = function (j) { return function () { // if the .second() function was called earlier, the _orient // has alread been added. Just return this and reset _isSecond. if (this._isSecond) { this._isSecond = false; return this; } if (this._same) { this._same = this._is = false; var o1 = this.toObject(), o2 = (arguments[0] || new Date()).toObject(), v = "", k = j.toLowerCase(); // the substr trick with -1 doesn't work in IE8 or less k = (k[k.length-1] === "s") ? k.substring(0,k.length-1) : k; for (var m = (px.length - 1); m > -1; m--) { v = px[m].toLowerCase(); if (o1[v] !== o2[v]) { return false; } if (k === v) { break; } } return true; } if (j.substring(j.length - 1) !== "s") { j += "s"; } if (this._move) { this._move = null; } return this["add" + j](this._orient); }; }; var nf = function (n) { return function () { this._dateElement = n; return this; }; }; for (var k = 0; k < px.length; k++) { de = px[k].toLowerCase(); if(de !== "weekday") { // Create date element functions and plural date element functions used with Date (eg. day(), days(), months()). $P[de] = $P[de + "s"] = ef(px[k]); // Create date element functions and plural date element functions used with Number (eg. day(), days(), months()). $N[de] = $N[de + "s"] = nf(de + "s"); } } $P._ss = ef("Second"); var nthfn = function (n) { return function (dayOfWeek) { if (this._same) { return this._ss(arguments[0]); } if (dayOfWeek || dayOfWeek === 0) { return this.moveToNthOccurrence(dayOfWeek, n); } this._nth = n; // if the operator is 'second' add the _orient, then deal with it later... if (n === 2 && (dayOfWeek === undefined || dayOfWeek === null)) { this._isSecond = true; return this.addSeconds(this._orient); } return this; }; }; for (var l = 0; l < nth.length; l++) { $P[nth[l]] = (l === 0) ? nthfn(-1) : nthfn(l); } }()); (function () { "use strict"; Date.Parsing = { Exception: function (s) { this.message = "Parse error at '" + s.substring(0, 10) + " ...'"; } }; var $P = Date.Parsing; var dayOffsets = { standard: [0,31,59,90,120,151,181,212,243,273,304,334], leap: [0,31,60,91,121,152,182,213,244,274,305,335] }; $P.isLeapYear = function(year) { return ((year % 4 === 0) && (year % 100 !== 0)) || (year % 400 === 0); }; var utils = { multiReplace : function (str, hash ) { var key; for (key in hash) { if (Object.prototype.hasOwnProperty.call(hash, key)) { var regex; if (typeof hash[key] === "function") { } else { regex = (hash[key] instanceof RegExp) ? hash[key] : new RegExp(hash[key], "g"); } str = str.replace(regex, key); } } return str; }, getDayOfYearFromWeek : function (obj) { var d, jan4, offset; obj.weekDay = (!obj.weekDay && obj.weekDay !== 0) ? 1 : obj.weekDay; d = new Date(obj.year, 0, 4); jan4 = d.getDay() === 0 ? 7 : d.getDay(); // JS is 0 indexed on Sunday. offset = jan4+3; obj.dayOfYear = ((obj.week * 7) + (obj.weekDay === 0 ? 7 : obj.weekDay))-offset; return obj; }, getDayOfYear : function (obj, dayOffset) { if (!obj.dayOfYear) { obj = utils.getDayOfYearFromWeek(obj); } for (var i=0;i <= dayOffset.length;i++) { if (obj.dayOfYear < dayOffset[i] || i === dayOffset.length) { obj.day = obj.day ? obj.day : (obj.dayOfYear - dayOffset[i-1]); break; } else { obj.month = i; } } return obj; }, adjustForTimeZone : function (obj, date) { var offset; if (obj.zone.toUpperCase() === "Z" || (obj.zone_hours === 0 && obj.zone_minutes === 0)) { // it's UTC/GML so work out the current timeszone offset offset = -date.getTimezoneOffset(); } else { offset = (obj.zone_hours*60) + (obj.zone_minutes || 0); if (obj.zone_sign === "+") { offset *= -1; } offset -= date.getTimezoneOffset(); } date.setMinutes(date.getMinutes()+offset); return date; }, setDefaults : function (obj) { obj.year = obj.year || Date.today().getFullYear(); obj.hours = obj.hours || 0; obj.minutes = obj.minutes || 0; obj.seconds = obj.seconds || 0; obj.milliseconds = obj.milliseconds || 0; if (!(!obj.month && (obj.week || obj.dayOfYear))) { // if we have a month, or if we don't but don't have the day calculation data obj.month = obj.month || 0; obj.day = obj.day || 1; } return obj; }, dataNum: function (data, mod, explict, postProcess) { var dataNum = data*1; if (mod) { if (postProcess) { return data ? mod(data)*1 : data; } else { return data ? mod(dataNum) : data; } } else if (!explict){ return data ? dataNum : data; } else { return (data && typeof data !== "undefined") ? dataNum : data; } }, timeDataProcess: function (obj) { var timeObj = {}; for (var x in obj.data) { if (obj.data.hasOwnProperty(x)) { timeObj[x] = obj.ignore[x] ? obj.data[x] : utils.dataNum(obj.data[x], obj.mods[x], obj.explict[x], obj.postProcess[x]); } } if (obj.data.secmins) { obj.data.secmins = obj.data.secmins.replace(",", ".") * 60; if (!timeObj.minutes) { timeObj.minutes = obj.data.secmins; } else if (!timeObj.seconds) { timeObj.seconds = obj.data.secmins; } delete obj.secmins; } return timeObj; }, buildTimeObjectFromData: function (data) { var time = utils.timeDataProcess({ data: { year : data[1], month : data[5], day : data[7], week : data[8], dayOfYear : data[10], hours : data[15], zone_hours : data[23], zone_minutes : data[24], zone : data[21], zone_sign : data[22], weekDay : data[9], minutes: data[16], seconds: data[19], milliseconds: data[20], secmins: data[18] }, mods: { month: function(data) { return data-1; }, weekDay: function (data) { data = Math.abs(data); return (data === 7 ? 0 : data); }, minutes: function (data) { return data.replace(":",""); }, seconds: function (data) { return Math.floor( (data.replace(":","").replace(",","."))*1 ); }, milliseconds: function (data) { return (data.replace(",",".")*1000); } }, postProcess: { minutes: true, seconds: true, milliseconds: true }, explict: { zone_hours: true, zone_minutes: true }, ignore: { zone: true, zone_sign: true, secmins: true } }); return time; }, addToHash: function (hash, keys, data) { keys = keys; data = data; var len = keys.length; for (var i = 0; i < len; i++) { hash[keys[i]] = data[i]; } return hash; }, combineRegex: function (r1, r2) { return new RegExp("(("+r1.source+")\\s("+r2.source+"))"); }, getDateNthString: function(add, last, inc){ if (add) { return Date.today().addDays(inc).toString("d"); } else if (last) { return Date.today().last()[inc]().toString("d"); } }, buildRegexData: function (array) { var arr = []; var len = array.length; for (var i=0; i < len; i++) { if (Object.prototype.toString.call(array[i]) === '[object Array]') { // oldIE compat version of Array.isArray arr.push(this.combineRegex(array[i][0], array[i][1])); } else { arr.push(array[i]); } } return arr; } }; $P.processTimeObject = function (obj) { var date, dayOffset; utils.setDefaults(obj); dayOffset = ($P.isLeapYear(obj.year)) ? dayOffsets.leap : dayOffsets.standard; if (!obj.month && (obj.week || obj.dayOfYear)) { utils.getDayOfYear(obj, dayOffset); } else { obj.dayOfYear = dayOffset[obj.month] + obj.day; } date = new Date(obj.year, obj.month, obj.day, obj.hours, obj.minutes, obj.seconds, obj.milliseconds); if (obj.zone) { utils.adjustForTimeZone(obj, date); // adjust (and calculate) for timezone } return date; }; $P.ISO = { regex : /^([\+-]?\d{4}(?!\d{2}\b))((-?)((0[1-9]|1[0-2])(\3([12]\d|0[1-9]|3[01]))?|W([0-4]\d|5[0-3])(-?[1-7])?|(00[1-9]|0[1-9]\d|[12]\d{2}|3([0-5]\d|6[1-6])))([T\s]((([01]\d|2[0-4])((:?)[0-5]\d)?|24\:?00)([\.,]\d+(?!:))?)?(\17[0-5]\d([\.,]\d+)?)?\s?([zZ]|([\+-])([01]\d|2[0-3]):?([0-5]\d)?)?)?)?$/, parse : function (s) { var time, data = s.match(this.regex); if (!data || !data.length) { return null; } time = utils.buildTimeObjectFromData(data); if (!time.year || (!time.year && (!time.month && !time.day) && (!time.week && !time.dayOfYear)) ) { return null; } return $P.processTimeObject(time); } }; $P.Numeric = { isNumeric: function (e){return!isNaN(parseFloat(e))&&isFinite(e);}, regex: /\b([0-1]?[0-9])([0-3]?[0-9])([0-2]?[0-9]?[0-9][0-9])\b/i, parse: function (s) { var data, i, time = {}, order = Date.CultureInfo.dateElementOrder.split(""); if (!(this.isNumeric(s)) || // if it's non-numeric OR (s[0] === "+" && s[0] === "-")) { // It's an arithmatic string (eg +/-1000) return null; } if (s.length < 5 && s.indexOf(".") < 0 && s.indexOf("/") < 0) { // assume it's just a year. time.year = s; return $P.processTimeObject(time); } data = s.match(this.regex); if (!data || !data.length) { return null; } for (i=0; i < order.length; i++) { switch(order[i]) { case "d": time.day = data[i+1]; break; case "m": time.month = (data[i+1]-1); break; case "y": time.year = data[i+1]; break; } } return $P.processTimeObject(time); } }; $P.Normalizer = { regexData: function () { var $R = Date.CultureInfo.regexPatterns; return utils.buildRegexData([ $R.tomorrow, $R.yesterday, [$R.past, $R.mon], [$R.past, $R.tue], [$R.past, $R.wed], [$R.past, $R.thu], [$R.past, $R.fri], [$R.past, $R.sat], [$R.past, $R.sun] ]); }, basicReplaceHash : function() { var $R = Date.CultureInfo.regexPatterns; return { "January": $R.jan.source, "February": $R.feb, "March": $R.mar, "April": $R.apr, "May": $R.may, "June": $R.jun, "July": $R.jul, "August": $R.aug, "September": $R.sep, "October": $R.oct, "November": $R.nov, "December": $R.dec, "": /\bat\b/gi, " ": /\s{2,}/, "am": $R.inTheMorning, "9am": $R.thisMorning, "pm": $R.inTheEvening, "7pm":$R.thisEvening }; }, keys : function(){ return [ utils.getDateNthString(true, false, 1), // tomorrow utils.getDateNthString(true, false, -1), // yesterday utils.getDateNthString(false, true, "monday"), //last mon utils.getDateNthString(false, true, "tuesday"), //last tues utils.getDateNthString(false, true, "wednesday"), //last wed utils.getDateNthString(false, true, "thursday"), //last thurs utils.getDateNthString(false, true, "friday"), //last fri utils.getDateNthString(false, true, "saturday"), //last sat utils.getDateNthString(false, true, "sunday") //last sun ]; }, buildRegexFunctions: function () { var $R = Date.CultureInfo.regexPatterns; var __ = Date.i18n.__; var tomorrowRE = new RegExp("(\\b\\d\\d?("+__("AM")+"|"+__("PM")+")? )("+$R.tomorrow.source.slice(1)+")", "i"); // adapted tomorrow regex for AM PM relative dates var todayRE = new RegExp($R.today.source + "(?!\\s*([+-]))\\b"); // today, but excludes the math operators (eg "today + 2h") this.replaceFuncs = [ [todayRE, function (full) { return (full.length > 1) ? Date.today().toString("d") : full; }], [tomorrowRE, function(full, m1) { var t = Date.today().addDays(1).toString("d"); return (t + " " + m1); }], [$R.amThisMorning, function(str, am){return am;}], [$R.pmThisEvening, function(str, pm){return pm;}] ]; }, buildReplaceData: function () { this.buildRegexFunctions(); this.replaceHash = utils.addToHash(this.basicReplaceHash(), this.keys(), this.regexData()); }, stringReplaceFuncs: function (s) { for (var i=0; i < this.replaceFuncs.length; i++) { s = s.replace(this.replaceFuncs[i][0], this.replaceFuncs[i][1]); } return s; }, parse: function (s) { s = this.stringReplaceFuncs(s); s = utils.multiReplace(s, this.replaceHash); try { var n = s.split(/([\s\-\.\,\/\x27]+)/); if (n.length === 3 && $P.Numeric.isNumeric(n[0]) && $P.Numeric.isNumeric(n[2]) && (n[2].length >= 4)) { // ok, so we're dealing with x/year. But that's not a full date. // This fixes wonky dateElementOrder parsing when set to dmy order. if (Date.CultureInfo.dateElementOrder[0] === "d") { s = "1/" + n[0] + "/" + n[2]; // set to 1st of month and normalize the seperator } } } catch (e) {} return s; } }; $P.Normalizer.buildReplaceData(); }()); (function () { var $P = Date.Parsing; var _ = $P.Operators = { // // Tokenizers // rtoken: function (r) { // regex token return function (s) { var mx = s.match(r); if (mx) { return ([ mx[0], s.substring(mx[0].length) ]); } else { throw new $P.Exception(s); } }; }, token: function () { // whitespace-eating token return function (s) { return _.rtoken(new RegExp("^\\s*" + s + "\\s*"))(s); }; }, stoken: function (s) { // string token return _.rtoken(new RegExp("^" + s)); }, // Atomic Operators until: function (p) { return function (s) { var qx = [], rx = null; while (s.length) { try { rx = p.call(this, s); } catch (e) { qx.push(rx[0]); s = rx[1]; continue; } break; } return [ qx, s ]; }; }, many: function (p) { return function (s) { var rx = [], r = null; while (s.length) { try { r = p.call(this, s); } catch (e) { return [ rx, s ]; } rx.push(r[0]); s = r[1]; } return [ rx, s ]; }; }, // generator operators -- see below optional: function (p) { return function (s) { var r = null; try { r = p.call(this, s); } catch (e) { return [ null, s ]; } return [ r[0], r[1] ]; }; }, not: function (p) { return function (s) { try { p.call(this, s); } catch (e) { return [null, s]; } throw new $P.Exception(s); }; }, ignore: function (p) { return p ? function (s) { var r = null; r = p.call(this, s); return [null, r[1]]; } : null; }, product: function () { var px = arguments[0], qx = Array.prototype.slice.call(arguments, 1), rx = []; for (var i = 0 ; i < px.length ; i++) { rx.push(_.each(px[i], qx)); } return rx; }, cache: function (rule) { var cache = {}, cache_length = 0, cache_keys = [], CACHE_MAX = Date.Config.CACHE_MAX || 100000, r = null; var cacheCheck = function () { if (cache_length === CACHE_MAX) { // kill several keys, don't want to have to do this all the time... for (var i=0; i < 10; i++) { var key = cache_keys.shift(); if (key) { delete cache[key]; cache_length--; } } } }; return function (s) { cacheCheck(); try { r = cache[s] = (cache[s] || rule.call(this, s)); } catch (e) { r = cache[s] = e; } cache_length++; cache_keys.push(s); if (r instanceof $P.Exception) { throw r; } else { return r; } }; }, // vector operators -- see below any: function () { var px = arguments; return function (s) { var r = null; for (var i = 0; i < px.length; i++) { if (px[i] == null) { continue; } try { r = (px[i].call(this, s)); } catch (e) { r = null; } if (r) { return r; } } throw new $P.Exception(s); }; }, each: function () { var px = arguments; return function (s) { var rx = [], r = null; for (var i = 0; i < px.length ; i++) { if (px[i] == null) { continue; } try { r = (px[i].call(this, s)); } catch (e) { throw new $P.Exception(s); } rx.push(r[0]); s = r[1]; } return [ rx, s]; }; }, all: function () { var px = arguments, _ = _; return _.each(_.optional(px)); }, // delimited operators sequence: function (px, d, c) { d = d || _.rtoken(/^\s*/); c = c || null; if (px.length === 1) { return px[0]; } return function (s) { var r = null, q = null; var rx = []; for (var i = 0; i < px.length ; i++) { try { r = px[i].call(this, s); } catch (e) { break; } rx.push(r[0]); try { q = d.call(this, r[1]); } catch (ex) { q = null; break; } s = q[1]; } if (!r) { throw new $P.Exception(s); } if (q) { throw new $P.Exception(q[1]); } if (c) { try { r = c.call(this, r[1]); } catch (ey) { throw new $P.Exception(r[1]); } } return [ rx, (r?r[1]:s) ]; }; }, // // Composite Operators // between: function (d1, p, d2) { d2 = d2 || d1; var _fn = _.each(_.ignore(d1), p, _.ignore(d2)); return function (s) { var rx = _fn.call(this, s); return [[rx[0][0], r[0][2]], rx[1]]; }; }, list: function (p, d, c) { d = d || _.rtoken(/^\s*/); c = c || null; return (p instanceof Array ? _.each(_.product(p.slice(0, -1), _.ignore(d)), p.slice(-1), _.ignore(c)) : _.each(_.many(_.each(p, _.ignore(d))), px, _.ignore(c))); }, set: function (px, d, c) { d = d || _.rtoken(/^\s*/); c = c || null; return function (s) { // r is the current match, best the current 'best' match // which means it parsed the most amount of input var r = null, p = null, q = null, rx = null, best = [[], s], last = false; // go through the rules in the given set for (var i = 0; i < px.length ; i++) { // last is a flag indicating whether this must be the last element // if there is only 1 element, then it MUST be the last one q = null; p = null; r = null; last = (px.length === 1); // first, we try simply to match the current pattern // if not, try the next pattern try { r = px[i].call(this, s); } catch (e) { continue; } // since we are matching against a set of elements, the first // thing to do is to add r[0] to matched elements rx = [[r[0]], r[1]]; // if we matched and there is still input to parse and // we don't already know this is the last element, // we're going to next check for the delimiter ... // if there's none, or if there's no input left to parse // than this must be the last element after all ... if (r[1].length > 0 && ! last) { try { q = d.call(this, r[1]); } catch (ex) { last = true; } } else { last = true; } // if we parsed the delimiter and now there's no more input, // that means we shouldn't have parsed the delimiter at all // so don't update r and mark this as the last element ... if (!last && q[1].length === 0) { last = true; } // so, if this isn't the last element, we're going to see if // we can get any more matches from the remaining (unmatched) // elements ... if (!last) { // build a list of the remaining rules we can match against, // i.e., all but the one we just matched against var qx = []; for (var j = 0; j < px.length ; j++) { if (i !== j) { qx.push(px[j]); } } // now invoke recursively set with the remaining input // note that we don't include the closing delimiter ... // we'll check for that ourselves at the end p = _.set(qx, d).call(this, q[1]); // if we got a non-empty set as a result ... // (otw rx already contains everything we want to match) if (p[0].length > 0) { // update current result, which is stored in rx ... // basically, pick up the remaining text from p[1] // and concat the result from p[0] so that we don't // get endless nesting ... rx[0] = rx[0].concat(p[0]); rx[1] = p[1]; } } // at this point, rx either contains the last matched element // or the entire matched set that starts with this element. // now we just check to see if this variation is better than // our best so far, in terms of how much of the input is parsed if (rx[1].length < best[1].length) { best = rx; } // if we've parsed all the input, then we're finished if (best[1].length === 0) { break; } } // so now we've either gone through all the patterns trying them // as the initial match; or we found one that parsed the entire // input string ... // if best has no matches, just return empty set ... if (best[0].length === 0) { return best; } // if a closing delimiter is provided, then we have to check it also if (c) { // we try this even if there is no remaining input because the pattern // may well be optional or match empty input ... try { q = c.call(this, best[1]); } catch (ey) { throw new $P.Exception(best[1]); } // it parsed ... be sure to update the best match remaining input best[1] = q[1]; } // if we're here, either there was no closing delimiter or we parsed it // so now we have the best match; just return it! return best; }; }, forward: function (gr, fname) { return function (s) { return gr[fname].call(this, s); }; }, // // Translation Operators // replace: function (rule, repl) { return function (s) { var r = rule.call(this, s); return [repl, r[1]]; }; }, process: function (rule, fn) { return function (s) { var r = rule.call(this, s); return [fn.call(this, r[0]), r[1]]; }; }, min: function (min, rule) { return function (s) { var rx = rule.call(this, s); if (rx[0].length < min) { throw new $P.Exception(s); } return rx; }; } }; // Generator Operators And Vector Operators // Generators are operators that have a signature of F(R) => R, // taking a given rule and returning another rule, such as // ignore, which parses a given rule and throws away the result. // Vector operators are those that have a signature of F(R1,R2,...) => R, // take a list of rules and returning a new rule, such as each. // Generator operators are converted (via the following _generator // function) into functions that can also take a list or array of rules // and return an array of new rules as though the function had been // called on each rule in turn (which is what actually happens). // This allows generators to be used with vector operators more easily. // Example: // each(ignore(foo, bar)) instead of each(ignore(foo), ignore(bar)) // This also turns generators into vector operators, which allows // constructs like: // not(cache(foo, bar)) var _generator = function (op) { function gen() { var args = null, rx = [], px, i; if (arguments.length > 1) { args = Array.prototype.slice.call(arguments); } else if (arguments[0] instanceof Array) { args = arguments[0]; } if (args) { px = args.shift(); if (px.length > 0) { args.unshift(px[i]); rx.push(op.apply(null, args)); args.shift(); return rx; } } else { return op.apply(null, arguments); } } return gen; }; var gx = "optional not ignore cache".split(/\s/); for (var i = 0 ; i < gx.length ; i++) { _[gx[i]] = _generator(_[gx[i]]); } var _vector = function (op) { return function () { if (arguments[0] instanceof Array) { return op.apply(null, arguments[0]); } else { return op.apply(null, arguments); } }; }; var vx = "each any all".split(/\s/); for (var j = 0 ; j < vx.length ; j++) { _[vx[j]] = _vector(_[vx[j]]); } }()); (function () { var $D = Date; var flattenAndCompact = function (ax) { var rx = []; for (var i = 0; i < ax.length; i++) { if (ax[i] instanceof Array) { rx = rx.concat(flattenAndCompact(ax[i])); } else { if (ax[i]) { rx.push(ax[i]); } } } return rx; }; var parseMeridian = function () { if (this.meridian && (this.hour || this.hour === 0)) { if (this.meridian === "a" && this.hour > 11 && Date.Config.strict24hr){ throw "Invalid hour and meridian combination"; } else if (this.meridian === "p" && this.hour < 12 && Date.Config.strict24hr){ throw "Invalid hour and meridian combination"; } else if (this.meridian === "p" && this.hour < 12) { this.hour = this.hour + 12; } else if (this.meridian === "a" && this.hour === 12) { this.hour = 0; } } }; var setDefaults = function () { var now = new Date(); if ((this.hour || this.minute) && (!this.month && !this.year && !this.day)) { this.day = now.getDate(); } if (!this.year) { this.year = now.getFullYear(); } if (!this.month && this.month !== 0) { this.month = now.getMonth(); } if (!this.day) { this.day = 1; } if (!this.hour) { this.hour = 0; } if (!this.minute) { this.minute = 0; } if (!this.second) { this.second = 0; } if (!this.millisecond) { this.millisecond = 0; } }; var finishUtils = { getToday: function () { if (this.now || "hour minute second".indexOf(this.unit) !== -1) { return new Date(); } else { return $D.today(); } }, setDaysFromWeekday: function (today, orient){ var gap; orient = orient || 1; this.unit = "day"; gap = ($D.getDayNumberFromName(this.weekday) - today.getDay()); this.days = gap ? ((gap + (orient * 7)) % 7) : (orient * 7); return this; }, setMonthsFromMonth: function (today, orient) { var gap; orient = orient || 1; this.unit = "month"; gap = (this.month - today.getMonth()); this.months = gap ? ((gap + (orient * 12)) % 12) : (orient * 12); this.month = null; return this; }, setDMYFromWeekday: function () { var d = Date[this.weekday](); this.day = d.getDate(); if (!this.month) { this.month = d.getMonth(); } this.year = d.getFullYear(); return this; }, setUnitValue: function (orient) { if (!this.value && this.operator && this.operator !== null && this[this.unit + "s"] && this[this.unit + "s"] !== null) { this[this.unit + "s"] = this[this.unit + "s"] + ((this.operator === "add") ? 1 : -1) + (this.value||0) * orient; } else if (this[this.unit + "s"] == null || this.operator != null) { if (!this.value) { this.value = 1; } this[this.unit + "s"] = this.value * orient; } }, generateDateFromWeeks: function () { var weekday = (this.weekday !== undefined) ? this.weekday : "today"; var d = Date[weekday]().addWeeks(this.weeks); if (this.now) { d.setTimeToNow(); } return d; } }; $D.Translator = { hour: function (s) { return function () { this.hour = Number(s); }; }, minute: function (s) { return function () { this.minute = Number(s); }; }, second: function (s) { return function () { this.second = Number(s); }; }, /* for ss.s format */ secondAndMillisecond: function (s) { return function () { var mx = s.match(/^([0-5][0-9])\.([0-9]{1,3})/); this.second = Number(mx[1]); this.millisecond = Number(mx[2]); }; }, meridian: function (s) { return function () { this.meridian = s.slice(0, 1).toLowerCase(); }; }, timezone: function (s) { return function () { var n = s.replace(/[^\d\+\-]/g, ""); if (n.length) { this.timezoneOffset = Number(n); } else { this.timezone = s.toLowerCase(); } }; }, day: function (x) { var s = x[0]; return function () { this.day = Number(s.match(/\d+/)[0]); if (this.day < 1) { throw "invalid day"; } }; }, month: function (s) { return function () { this.month = (s.length === 3) ? "jan feb mar apr may jun jul aug sep oct nov dec".indexOf(s)/4 : Number(s) - 1; if (this.month < 0) { throw "invalid month"; } }; }, year: function (s) { return function () { var n = Number(s); this.year = ((s.length > 2) ? n : (n + (((n + 2000) < Date.CultureInfo.twoDigitYearMax) ? 2000 : 1900))); }; }, rday: function (s) { return function () { switch (s) { case "yesterday": this.days = -1; break; case "tomorrow": this.days = 1; break; case "today": this.days = 0; break; case "now": this.days = 0; this.now = true; break; } }; }, finishExact: function (x) { var d; x = (x instanceof Array) ? x : [x]; for (var i = 0 ; i < x.length ; i++) { if (x[i]) { x[i].call(this); } } setDefaults.call(this); parseMeridian.call(this); if (this.day > $D.getDaysInMonth(this.year, this.month)) { throw new RangeError(this.day + " is not a valid value for days."); } d = new Date(this.year, this.month, this.day, this.hour, this.minute, this.second, this.millisecond); if (this.year < 100) { d.setFullYear(this.year); // means years less that 100 are process correctly. JS will parse it otherwise as 1900-1999. } if (this.timezone) { d.set({ timezone: this.timezone }); } else if (this.timezoneOffset) { d.set({ timezoneOffset: this.timezoneOffset }); } return d; }, finish: function (x) { var today, expression, orient, temp; x = (x instanceof Array) ? flattenAndCompact(x) : [ x ]; if (x.length === 0) { return null; } for (var i = 0 ; i < x.length ; i++) { if (typeof x[i] === "function") { x[i].call(this); } } if (this.now && !this.unit && !this.operator) { return new Date(); } else { today = finishUtils.getToday.call(this); } expression = !!(this.days && this.days !== null || this.orient || this.operator); orient = ((this.orient === "past" || this.operator === "subtract") ? -1 : 1); if (this.month && this.unit === "week") { this.value = this.month + 1; delete this.month; delete this.day; } if ((this.month || this.month === 0) && "year day hour minute second".indexOf(this.unit) !== -1) { if (!this.value) { this.value = this.month + 1; } this.month = null; expression = true; } if (!expression && this.weekday && !this.day && !this.days) { finishUtils.setDMYFromWeekday.call(this); } if (expression && this.weekday && this.unit !== "month" && this.unit !== "week") { finishUtils.setDaysFromWeekday.call(this, today, orient); } if (this.weekday && this.unit !== "week" && !this.day && !this.days) { temp = Date[this.weekday](); this.day = temp.getDate(); if (temp.getMonth() !== today.getMonth()) { this.month = temp.getMonth(); } } if (this.month && this.unit === "day" && this.operator) { if (!this.value) { this.value = (this.month + 1); } this.month = null; } if (this.value != null && this.month != null && this.year != null) { this.day = this.value * 1; } if (this.month && !this.day && this.value) { today.set({ day: this.value * 1 }); if (!expression) { this.day = this.value * 1; } } if (!this.month && this.value && this.unit === "month" && !this.now) { this.month = this.value; expression = true; } if (expression && (this.month || this.month === 0) && this.unit !== "year") { finishUtils.setMonthsFromMonth.call(this, today, orient); } if (!this.unit) { this.unit = "day"; } finishUtils.setUnitValue.call(this, orient); parseMeridian.call(this); if ((this.month || this.month === 0) && !this.day) { this.day = 1; } if (!this.orient && !this.operator && this.unit === "week" && this.value && !this.day && !this.month) { return Date.today().setWeek(this.value); } if (this.unit === "week" && this.weeks && !this.day && !this.month) { return finishUtils.generateDateFromWeeks.call(this); } if (expression && this.timezone && this.day && this.days) { this.day = this.days; } if (expression){ today.add(this); } else { today.set(this); } if (this.timezone) { this.timezone = this.timezone.toUpperCase(); var offset = $D.getTimezoneOffset(this.timezone); var timezone; if (today.hasDaylightSavingTime()) { // lets check that we're being sane with timezone setting timezone = $D.getTimezoneAbbreviation(offset, today.isDaylightSavingTime()); if (timezone !== this.timezone) { // bugger, we're in a place where things like EST vs EDT matters. if (today.isDaylightSavingTime()) { today.addHours(-1); } else { today.addHours(1); } } } today.setTimezoneOffset(offset); } return today; } }; }()); (function () { var $D = Date; $D.Grammar = {}; var _ = $D.Parsing.Operators, g = $D.Grammar, t = $D.Translator, _fn; // Allow rolling up into general purpose rules _fn = function () { return _.each(_.any.apply(null, arguments), _.not(g.ctoken2("timeContext"))); }; g.datePartDelimiter = _.rtoken(/^([\s\-\.\,\/\x27]+)/); g.timePartDelimiter = _.stoken(":"); g.whiteSpace = _.rtoken(/^\s*/); g.generalDelimiter = _.rtoken(/^(([\s\,]|at|@|on)+)/); var _C = {}; g.ctoken = function (keys) { var fn = _C[keys]; if (! fn) { var c = Date.CultureInfo.regexPatterns; var kx = keys.split(/\s+/), px = []; for (var i = 0; i < kx.length ; i++) { px.push(_.replace(_.rtoken(c[kx[i]]), kx[i])); } fn = _C[keys] = _.any.apply(null, px); } return fn; }; g.ctoken2 = function (key) { return _.rtoken(Date.CultureInfo.regexPatterns[key]); }; var cacheProcessRtoken = function (key, token, type, eachToken) { if (eachToken) { g[key] = _.cache(_.process(_.each(_.rtoken(token),_.optional(g.ctoken2(eachToken))), type)); } else { g[key] = _.cache(_.process(_.rtoken(token), type)); } }; var cacheProcessCtoken = function (token, type) { return _.cache(_.process(g.ctoken2(token), type)); }; var _F = {}; //function cache var _get = function (f) { _F[f] = (_F[f] || g.format(f)[0]); return _F[f]; }; g.allformats = function (fx) { var rx = []; if (fx instanceof Array) { for (var i = 0; i < fx.length; i++) { rx.push(_get(fx[i])); } } else { rx.push(_get(fx)); } return rx; }; g.formats = function (fx) { if (fx instanceof Array) { var rx = []; for (var i = 0 ; i < fx.length ; i++) { rx.push(_get(fx[i])); } return _.any.apply(null, rx); } else { return _get(fx); } }; var grammarFormats = { timeFormats: function(){ var i, RTokenKeys = [ "h", "hh", "H", "HH", "m", "mm", "s", "ss", "ss.s", "z", "zz" ], RToken = [ /^(0[0-9]|1[0-2]|[1-9])/, /^(0[0-9]|1[0-2])/, /^([0-1][0-9]|2[0-3]|[0-9])/, /^([0-1][0-9]|2[0-3])/, /^([0-5][0-9]|[0-9])/, /^[0-5][0-9]/, /^([0-5][0-9]|[0-9])/, /^[0-5][0-9]/, /^[0-5][0-9]\.[0-9]{1,3}/, /^((\+|\-)\s*\d\d\d\d)|((\+|\-)\d\d\:?\d\d)/, /^((\+|\-)\s*\d\d\d\d)|((\+|\-)\d\d\:?\d\d)/ ], tokens = [ t.hour, t.hour, t.hour, t.hour, t.minute, t.minute, t.second, t.second, t.secondAndMillisecond, t.timezone, t.timezone ]; for (i=0; i < RTokenKeys.length; i++) { cacheProcessRtoken(RTokenKeys[i], RToken[i], tokens[i]); } g.hms = _.cache(_.sequence([g.H, g.m, g.s], g.timePartDelimiter)); g.t = cacheProcessCtoken("shortMeridian", t.meridian); g.tt = cacheProcessCtoken("longMeridian", t.meridian); g.zzz = cacheProcessCtoken("timezone", t.timezone); g.timeSuffix = _.each(_.ignore(g.whiteSpace), _.set([ g.tt, g.zzz ])); g.time = _.each(_.optional(_.ignore(_.stoken("T"))), g.hms, g.timeSuffix); }, dateFormats: function () { // pre-loaded rules for different date part order preferences var _setfn = function () { return _.set(arguments, g.datePartDelimiter); }; var i, RTokenKeys = [ "d", "dd", "M", "MM", "y", "yy", "yyy", "yyyy" ], RToken = [ /^([0-2]\d|3[0-1]|\d)/, /^([0-2]\d|3[0-1])/, /^(1[0-2]|0\d|\d)/, /^(1[0-2]|0\d)/, /^(\d+)/, /^(\d\d)/, /^(\d\d?\d?\d?)/, /^(\d\d\d\d)/ ], tokens = [ t.day, t.day, t.month, t.month, t.year, t.year, t.year, t.year ], eachToken = [ "ordinalSuffix", "ordinalSuffix" ]; for (i=0; i < RTokenKeys.length; i++) { cacheProcessRtoken(RTokenKeys[i], RToken[i], tokens[i], eachToken[i]); } g.MMM = g.MMMM = _.cache(_.process(g.ctoken("jan feb mar apr may jun jul aug sep oct nov dec"), t.month)); g.ddd = g.dddd = _.cache(_.process(g.ctoken("sun mon tue wed thu fri sat"), function (s) { return function () { this.weekday = s; }; } )); g.day = _fn(g.d, g.dd); g.month = _fn(g.M, g.MMM); g.year = _fn(g.yyyy, g.yy); g.mdy = _setfn(g.ddd, g.month, g.day, g.year); g.ymd = _setfn(g.ddd, g.year, g.month, g.day); g.dmy = _setfn(g.ddd, g.day, g.month, g.year); g.date = function (s) { return ((g[Date.CultureInfo.dateElementOrder] || g.mdy).call(this, s)); }; }, relative: function () { // relative date / time expressions g.orientation = _.process(g.ctoken("past future"), function (s) { return function () { this.orient = s; }; } ); g.operator = _.process(g.ctoken("add subtract"), function (s) { return function () { this.operator = s; }; } ); g.rday = _.process(g.ctoken("yesterday tomorrow today now"), t.rday); g.unit = _.process(g.ctoken("second minute hour day week month year"), function (s) { return function () { this.unit = s; }; } ); } }; g.buildGrammarFormats = function () { // these need to be rebuilt every time the language changes. _C = {}; grammarFormats.timeFormats(); grammarFormats.dateFormats(); grammarFormats.relative(); g.value = _.process(_.rtoken(/^([-+]?\d+)?(st|nd|rd|th)?/), function (s) { return function () { this.value = s.replace(/\D/g, ""); }; } ); g.expression = _.set([g.rday, g.operator, g.value, g.unit, g.orientation, g.ddd, g.MMM ]); g.format = _.process(_.many( _.any( // translate format specifiers into grammar rules _.process( _.rtoken(/^(dd?d?d?(?!e)|MM?M?M?|yy?y?y?|hh?|HH?|mm?|ss?|tt?|zz?z?)/), function (fmt) { if (g[fmt]) { return g[fmt]; } else { throw $D.Parsing.Exception(fmt); } } ), // translate separator tokens into token rules _.process(_.rtoken(/^[^dMyhHmstz]+/), // all legal separators function (s) { return _.ignore(_.stoken(s)); } ) ) ), // construct the parser ... function (rules) { return _.process(_.each.apply(null, rules), t.finishExact); } ); // starting rule for general purpose grammar g._start = _.process(_.set([ g.date, g.time, g.expression ], g.generalDelimiter, g.whiteSpace), t.finish); }; g.buildGrammarFormats(); // parsing date format specifiers - ex: "h:m:s tt" // this little guy will generate a custom parser based // on the format string, ex: g.format("h:m:s tt") // check for these formats first g._formats = g.formats([ "\"yyyy-MM-ddTHH:mm:ssZ\"", "yyyy-MM-ddTHH:mm:ss.sz", "yyyy-MM-ddTHH:mm:ssZ", "yyyy-MM-ddTHH:mm:ssz", "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-ddTHH:mmZ", "yyyy-MM-ddTHH:mmz", "yyyy-MM-ddTHH:mm", "ddd, MMM dd, yyyy H:mm:ss tt", "ddd MMM d yyyy HH:mm:ss zzz", "MMddyyyy", "ddMMyyyy", "Mddyyyy", "ddMyyyy", "Mdyyyy", "dMyyyy", "yyyy", "Mdyy", "dMyy", "d" ]); // real starting rule: tries selected formats first, // then general purpose rule g.start = function (s) { try { var r = g._formats.call({}, s); if (r[1].length === 0) { return r; } } catch (e) {} return g._start.call({}, s); }; }()); (function () { var $D = Date; /** * @desc Converts the specified string value into its JavaScript Date equivalent using CultureInfo specific format information. * * Example

	///////////
	// Dates //
	///////////

	// 15-Oct-2004
	var d1 = Date.parse("10/15/2004");

	// 15-Oct-2004
	var d1 = Date.parse("15-Oct-2004");

	// 15-Oct-2004
	var d1 = Date.parse("2004.10.15");

	//Fri Oct 15, 2004
	var d1 = Date.parse("Fri Oct 15, 2004");

	///////////
	// Times //
	///////////

	// Today at 10 PM.
	var d1 = Date.parse("10 PM");

	// Today at 10:30 PM.
	var d1 = Date.parse("10:30 P.M.");

	// Today at 6 AM.
	var d1 = Date.parse("06am");

	/////////////////////
	// Dates and Times //
	/////////////////////

	// 8-July-2004 @ 10:30 PM
	var d1 = Date.parse("July 8th, 2004, 10:30 PM");

	// 1-July-2004 @ 10:30 PM
	var d1 = Date.parse("2004-07-01T22:30:00");

	////////////////////
	// Relative Dates //
	////////////////////

	// Returns today's date. The string "today" is culture specific.
	var d1 = Date.parse("today");

	// Returns yesterday's date. The string "yesterday" is culture specific.
	var d1 = Date.parse("yesterday");

	// Returns the date of the next thursday.
	var d1 = Date.parse("Next thursday");

	// Returns the date of the most previous monday.
	var d1 = Date.parse("last monday");

	// Returns today's day + one year.
	var d1 = Date.parse("next year");

	///////////////
	// Date Math //
	///////////////

	// Today + 2 days
	var d1 = Date.parse("t+2");

	// Today + 2 days
	var d1 = Date.parse("today + 2 days");

	// Today + 3 months
	var d1 = Date.parse("t+3m");

	// Today - 1 year
	var d1 = Date.parse("today - 1 year");

	// Today - 1 year
	var d1 = Date.parse("t-1y"); 


	/////////////////////////////
	// Partial Dates and Times //
	/////////////////////////////

	// July 15th of this year.
	var d1 = Date.parse("July 15");

	// 15th day of current day and year.
	var d1 = Date.parse("15");

	// July 1st of current year at 10pm.
	var d1 = Date.parse("7/1 10pm");
	
* * @param {String} The string value to convert into a Date object [Required] * @return {Date} A Date object or null if the string cannot be converted into a Date. */ var parseUtils = { removeOrds: function (s) { ords = s.match(/\b(\d+)(?:st|nd|rd|th)\b/); // find ordinal matches s = ((ords && ords.length === 2) ? s.replace(ords[0], ords[1]) : s); return s; }, grammarParser: function (s) { var r = null; try { r = $D.Grammar.start.call({}, s.replace(/^\s*(\S*(\s+\S+)*)\s*$/, "$1")); } catch (e) { return null; } return ((r[1].length === 0) ? r[0] : null); }, nativeFallback: function(s) { var t; try { // ok we haven't parsed it, last ditch attempt with the built-in parser. t = Date._parse(s); return (t || t === 0) ? new Date(t) : null; } catch (e) { return null; } } }; function parse (s) { var d; if (!s) { return null; } if (s instanceof Date) { return s.clone(); } if (s.length >= 4 && s.charAt(0) !== "0" && s.charAt(0) !== "+"&& s.charAt(0) !== "-") { // ie: 2004 will pass, 0800 won't. // Start with specific formats d = $D.Parsing.ISO.parse(s) || $D.Parsing.Numeric.parse(s); } if (d instanceof Date && !isNaN(d.getTime())) { return d; } else { // find ordinal dates (1st, 3rd, 8th, etc and remove them as they cause parsing issues) s = $D.Parsing.Normalizer.parse(parseUtils.removeOrds(s)); d = parseUtils.grammarParser(s); if (d !== null) { return d; } else { return parseUtils.nativeFallback(s); } } } if (!$D._parse) { $D._parse = $D.parse; } $D.parse = parse; Date.getParseFunction = function (fx) { var fns = Date.Grammar.allformats(fx); return function (s) { var r = null; for (var i = 0; i < fns.length; i++) { try { r = fns[i].call({}, s); } catch (e) { continue; } if (r[1].length === 0) { return r[0]; } } return null; }; }; /** * Converts the specified string value into its JavaScript Date equivalent using the specified format {String} or formats {Array} and the CultureInfo specific format information. * The format of the string value must match one of the supplied formats exactly. * * Example

	// 15-Oct-2004
	var d1 = Date.parseExact("10/15/2004", "M/d/yyyy");

	// 15-Oct-2004
	var d1 = Date.parse("15-Oct-2004", "M-ddd-yyyy");

	// 15-Oct-2004
	var d1 = Date.parse("2004.10.15", "yyyy.MM.dd");

	// Multiple formats
	var d1 = Date.parseExact("10/15/2004", ["M/d/yyyy", "MMMM d, yyyy"]);
	
* * @param {String} The string value to convert into a Date object [Required]. * @param {Object} The expected format {String} or an array of expected formats {Array} of the date string [Required]. * @return {Date} A Date object or null if the string cannot be converted into a Date. */ $D.parseExact = function (s, fx) { return $D.getParseFunction(fx)(s); }; }()); (function () { var $D = Date, $P = $D.prototype, // $C = $D.CultureInfo, // not used atm p = function (s, l) { if (!l) { l = 2; } return ("000" + s).slice(l * -1); }; /** * Converts a PHP format string to Java/.NET format string. * A PHP format string can be used with ._format or .format. * A Java/.NET format string can be used with .toString(). * The .parseExact function will only accept a Java/.NET format string * * Example * var f1 = "%m/%d/%y" * var f2 = Date.normalizeFormat(f1); // "MM/dd/yy" * * new Date().format(f1); // "04/13/08" * new Date()._format(f1); // "04/13/08" * new Date().toString(f2); // "04/13/08" * * var date = Date.parseExact("04/13/08", f2); // Sun Apr 13 2008 * * @param {String} A PHP format string consisting of one or more format spcifiers. * @return {String} The PHP format converted to a Java/.NET format string. */ var normalizerSubstitutions = { "d" : "dd", "%d": "dd", "D" : "ddd", "%a": "ddd", "j" : "dddd", "l" : "dddd", "%A": "dddd", "S" : "S", "F" : "MMMM", "%B": "MMMM", "m" : "MM", "%m": "MM", "M" : "MMM", "%b": "MMM", "%h": "MMM", "n" : "M", "Y" : "yyyy", "%Y": "yyyy", "y" : "yy", "%y": "yy", "g" : "h", "%I": "h", "G" : "H", "h" : "hh", "H" : "HH", "%H": "HH", "i" : "mm", "%M": "mm", "s" : "ss", "%S": "ss", "%r": "hh:mm tt", "%R": "H:mm", "%T": "H:mm:ss", "%X": "t", "%x": "d", "%e": "d", "%D": "MM/dd/yy", "%n": "\\n", "%t": "\\t", "e" : "z", "T" : "z", "%z": "z", "%Z": "z", "Z" : "ZZ", "N" : "u", "w" : "u", "%w": "u", "W" : "W", "%V": "W" }; var normalizer = { substitutes: function (m) { return normalizerSubstitutions[m]; }, interpreted: function (m, x) { var y; switch (m) { case "%u": return x.getDay() + 1; case "z": return x.getOrdinalNumber(); case "%j": return p(x.getOrdinalNumber(), 3); case "%U": var d1 = x.clone().set({month: 0, day: 1}).addDays(-1).moveToDayOfWeek(0), d2 = x.clone().addDays(1).moveToDayOfWeek(0, -1); return (d2 < d1) ? "00" : p((d2.getOrdinalNumber() - d1.getOrdinalNumber()) / 7 + 1); case "%W": return p(x.getWeek()); case "t": return $D.getDaysInMonth(x.getFullYear(), x.getMonth()); case "o": case "%G": return x.setWeek(x.getISOWeek()).toString("yyyy"); case "%g": return x._format("%G").slice(-2); case "a": case "%p": return t("tt").toLowerCase(); case "A": return t("tt").toUpperCase(); case "u": return p(x.getMilliseconds(), 3); case "I": return (x.isDaylightSavingTime()) ? 1 : 0; case "O": return x.getUTCOffset(); case "P": y = x.getUTCOffset(); return y.substring(0, y.length - 2) + ":" + y.substring(y.length - 2); case "B": var now = new Date(); return Math.floor(((now.getHours() * 3600) + (now.getMinutes() * 60) + now.getSeconds() + (now.getTimezoneOffset() + 60) * 60) / 86.4); case "c": return x.toISOString().replace(/\"/g, ""); case "U": return $D.strtotime("now"); case "%c": return t("d") + " " + t("t"); case "%C": return Math.floor(x.getFullYear() / 100 + 1); } }, shouldOverrideDefaults: function (m) { switch (m) { case "%e": return true; default: return false; } }, parse: function (m, context) { var formatString, c = context || new Date(); formatString = normalizer.substitutes(m); if (formatString) { return formatString; } formatString = normalizer.interpreted(m, c); if (formatString) { return formatString; } else { return m; } } }; $D.normalizeFormat = function (format, context) { return format.replace(/(%|\\)?.|%%/g, function(t){ return normalizer.parse(t, context); }); }; /** * Format a local Unix timestamp according to locale settings * * Example: * Date.strftime("%m/%d/%y", new Date()); // "04/13/08" * Date.strftime("c", "2008-04-13T17:52:03Z"); // "04/13/08" * * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @param {Number|String} The number representing the number of seconds that have elapsed since January 1, 1970 (local time). * @return {String} A string representation of the current Date object. */ $D.strftime = function (format, time) { var d = Date.parse(time); return d._format(format); }; /** * Parse any textual datetime description into a Unix timestamp. * A Unix timestamp is the number of seconds that have elapsed since January 1, 1970 (midnight UTC/GMT). * * Example: * Date.strtotime("04/13/08"); // 1208044800 * Date.strtotime("1970-01-01T00:00:00Z"); // 0 * * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @param {Object} A string or date object. * @return {String} A string representation of the current Date object. */ $D.strtotime = function (time) { var d = $D.parse(time); return Math.round($D.UTC(d.getUTCFullYear(), d.getUTCMonth(), d.getUTCDate(), d.getUTCHours(), d.getUTCMinutes(), d.getUTCSeconds(), d.getUTCMilliseconds()) / 1000); }; /** * Converts the value of the current Date object to its equivalent string representation using a PHP/Unix style of date format specifiers. * Format Specifiers * Format Description Example * ------ --------------------------------------------------------------------------- ----------------------- * %a abbreviated weekday name according to the current localed "Mon" through "Sun" * %A full weekday name according to the current localed "Sunday" through "Saturday" * %b abbreviated month name according to the current localed "Jan" through "Dec" * %B full month name according to the current locale "January" through "December" * %c preferred date and time representation for the current locale "4/13/2008 12:33 PM" * %C century number (the year divided by 100 and truncated to an integer) "00" to "99" * %d day of the month as a decimal number "01" to "31" * %D same as %m/%d/%y "04/13/08" * %e day of the month as a decimal number, a single digit is preceded by a space "1" to "31" * %g like %G, but without the century "08" * %G The 4-digit year corresponding to the ISO week number (see %V). "2008" * This has the same format and value as %Y, except that if the ISO week number * belongs to the previous or next year, that year is used instead. * %h same as %b "Jan" through "Dec" * %H hour as a decimal number using a 24-hour clock. "00" to "23" * %I hour as a decimal number using a 12-hour clock. "01" to "12" * %j day of the year as a decimal number. "001" to "366" * %m month as a decimal number. "01" to "12" * %M minute as a decimal number. "00" to "59" * %n newline character "\n" * %p either "am" or "pm" according to the given time value, or the "am" or "pm" * corresponding strings for the current locale. * %r time in a.m. and p.m. notation "8:44 PM" * %R time in 24 hour notation "20:44" * %S second as a decimal number "00" to "59" * %t tab character "\t" * %T current time, equal to %H:%M:%S "12:49:11" * %u weekday as a decimal number ["1", "7"], with "1" representing Monday "1" to "7" * %U week number of the current year as a decimal number, starting with the "0" to ("52" or "53") * first Sunday as the first day of the first week * %V The ISO 8601:1988 week number of the current year as a decimal number, "00" to ("52" or "53") * range 01 to 53, where week 1 is the first week that has at least 4 days * in the current year, and with Monday as the first day of the week. * (Use %G or %g for the year component that corresponds to the week number * for the specified timestamp.) * %W week number of the current year as a decimal number, starting with the "00" to ("52" or "53") * first Monday as the first day of the first week * %w day of the week as a decimal, Sunday being "0" "0" to "6" * %x preferred date representation for the current locale without the time "4/13/2008" * %X preferred time representation for the current locale without the date "12:53:05" * %y year as a decimal number without a century "00" "99" * %Y year as a decimal number including the century "2008" * %Z time zone or name or abbreviation "UTC", "EST", "PST" * %z same as %Z * %% a literal "%" characters "%" * d Day of the month, 2 digits with leading zeros "01" to "31" * D A textual representation of a day, three letters "Mon" through "Sun" * j Day of the month without leading zeros "1" to "31" * l A full textual representation of the day of the week (lowercase "L") "Sunday" through "Saturday" * N ISO-8601 numeric representation of the day of the week (added in PHP 5.1.0) "1" (for Monday) through "7" (for Sunday) * S English ordinal suffix for the day of the month, 2 characters "st", "nd", "rd" or "th". Works well with j * w Numeric representation of the day of the week "0" (for Sunday) through "6" (for Saturday) * z The day of the year (starting from "0") "0" through "365" * W ISO-8601 week number of year, weeks starting on Monday "00" to ("52" or "53") * F A full textual representation of a month, such as January or March "January" through "December" * m Numeric representation of a month, with leading zeros "01" through "12" * M A short textual representation of a month, three letters "Jan" through "Dec" * n Numeric representation of a month, without leading zeros "1" through "12" * t Number of days in the given month "28" through "31" * L Whether it's a leap year "1" if it is a leap year, "0" otherwise * o ISO-8601 year number. This has the same value as Y, except that if the "2008" * ISO week number (W) belongs to the previous or next year, that year * is used instead. * Y A full numeric representation of a year, 4 digits "2008" * y A two digit representation of a year "08" * a Lowercase Ante meridiem and Post meridiem "am" or "pm" * A Uppercase Ante meridiem and Post meridiem "AM" or "PM" * B Swatch Internet time "000" through "999" * g 12-hour format of an hour without leading zeros "1" through "12" * G 24-hour format of an hour without leading zeros "0" through "23" * h 12-hour format of an hour with leading zeros "01" through "12" * H 24-hour format of an hour with leading zeros "00" through "23" * i Minutes with leading zeros "00" to "59" * s Seconds, with leading zeros "00" through "59" * u Milliseconds "54321" * e Timezone identifier "UTC", "EST", "PST" * I Whether or not the date is in daylight saving time (uppercase i) "1" if Daylight Saving Time, "0" otherwise * O Difference to Greenwich time (GMT) in hours "+0200", "-0600" * P Difference to Greenwich time (GMT) with colon between hours and minutes "+02:00", "-06:00" * T Timezone abbreviation "UTC", "EST", "PST" * Z Timezone offset in seconds. The offset for timezones west of UTC is "-43200" through "50400" * always negative, and for those east of UTC is always positive. * c ISO 8601 date "2004-02-12T15:19:21+00:00" * r RFC 2822 formatted date "Thu, 21 Dec 2000 16:01:07 +0200" * U Seconds since the Unix Epoch (January 1 1970 00:00:00 GMT) "0" * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @return {String} A string representation of the current Date object. */ var formatReplace = function (context) { return function (m) { var formatString, override = false; if (m.charAt(0) === "\\" || m.substring(0, 2) === "%%") { return m.replace("\\", "").replace("%%", "%"); } override = normalizer.shouldOverrideDefaults(m); formatString = $D.normalizeFormat(m, context); if (formatString) { return context.toString(formatString, override); } }; }; $P._format = function (format) { var formatter = formatReplace(this); if (!format) { return this._toString(); } else { return format.replace(/(%|\\)?.|%%/g, formatter); } }; if (!$P.format) { $P.format = $P._format; } }()); (function () { "use strict"; var gFn = function (attr) { return function () { return this[attr]; }; }; var sFn = function (attr) { return function (val) { this[attr] = val; return this; }; }; var attrs = ["years", "months", "days", "hours", "minutes", "seconds", "milliseconds"]; var addSetFuncs = function (context, attrs) { for (var i = 0; i < attrs.length ; i++) { var $a = attrs[i], $b = $a.slice(0, 1).toUpperCase() + $a.slice(1); context.prototype[$a] = 0; context.prototype["get" + $b] = gFn($a); context.prototype["set" + $b] = sFn($a); } }; /** * new TimeSpan(milliseconds); * new TimeSpan(days, hours, minutes, seconds); * new TimeSpan(days, hours, minutes, seconds, milliseconds); */ var TimeSpan = function (days, hours, minutes, seconds, milliseconds) { if (arguments.length === 1 && typeof days === "number") { var orient = (days < 0) ? -1 : +1; var millsLeft = Math.abs(days); this.setDays(Math.floor(millsLeft / 86400000) * orient); millsLeft = millsLeft % 86400000; this.setHours(Math.floor(millsLeft / 3600000) * orient); millsLeft = millsLeft % 3600000; this.setMinutes(Math.floor(millsLeft / 60000) * orient); millsLeft = millsLeft % 60000; this.setSeconds(Math.floor(millsLeft / 1000) * orient); millsLeft = millsLeft % 1000; this.setMilliseconds(millsLeft * orient); } else { this.set(days, hours, minutes, seconds, milliseconds); } this.getTotalMilliseconds = function () { return (this.getDays() * 86400000) + (this.getHours() * 3600000) + (this.getMinutes() * 60000) + (this.getSeconds() * 1000); }; this.compareTo = function (time) { var t1 = new Date(1970, 1, 1, this.getHours(), this.getMinutes(), this.getSeconds()), t2; if (time === null) { t2 = new Date(1970, 1, 1, 0, 0, 0); } else { t2 = new Date(1970, 1, 1, time.getHours(), time.getMinutes(), time.getSeconds()); } return (t1 < t2) ? -1 : (t1 > t2) ? 1 : 0; }; this.equals = function (time) { return (this.compareTo(time) === 0); }; this.add = function (time) { return (time === null) ? this : this.addSeconds(time.getTotalMilliseconds() / 1000); }; this.subtract = function (time) { return (time === null) ? this : this.addSeconds(-time.getTotalMilliseconds() / 1000); }; this.addDays = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 86400000)); }; this.addHours = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 3600000)); }; this.addMinutes = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 60000)); }; this.addSeconds = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 1000)); }; this.addMilliseconds = function (n) { return new TimeSpan(this.getTotalMilliseconds() + n); }; this.get12HourHour = function () { return (this.getHours() > 12) ? this.getHours() - 12 : (this.getHours() === 0) ? 12 : this.getHours(); }; this.getDesignator = function () { return (this.getHours() < 12) ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator; }; this.toString = function (format) { this._toString = function () { if (this.getDays() !== null && this.getDays() > 0) { return this.getDays() + "." + this.getHours() + ":" + this.p(this.getMinutes()) + ":" + this.p(this.getSeconds()); } else { return this.getHours() + ":" + this.p(this.getMinutes()) + ":" + this.p(this.getSeconds()); } }; this.p = function (s) { return (s.toString().length < 2) ? "0" + s : s; }; var me = this; return format ? format.replace(/dd?|HH?|hh?|mm?|ss?|tt?/g, function (format) { switch (format) { case "d": return me.getDays(); case "dd": return me.p(me.getDays()); case "H": return me.getHours(); case "HH": return me.p(me.getHours()); case "h": return me.get12HourHour(); case "hh": return me.p(me.get12HourHour()); case "m": return me.getMinutes(); case "mm": return me.p(me.getMinutes()); case "s": return me.getSeconds(); case "ss": return me.p(me.getSeconds()); case "t": return ((me.getHours() < 12) ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator).substring(0, 1); case "tt": return (me.getHours() < 12) ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator; } } ) : this._toString(); }; return this; }; addSetFuncs(TimeSpan, attrs.slice(2)); TimeSpan.prototype.set = function (days, hours, minutes, seconds, milliseconds){ this.setDays(days || this.getDays()); this.setHours(hours || this.getHours()); this.setMinutes(minutes || this.getMinutes()); this.setSeconds(seconds || this.getSeconds()); this.setMilliseconds(milliseconds || this.getMilliseconds()); }; /** * Gets the time of day for this date instances. * @return {TimeSpan} TimeSpan */ Date.prototype.getTimeOfDay = function () { return new TimeSpan(0, this.getHours(), this.getMinutes(), this.getSeconds(), this.getMilliseconds()); }; Date.TimeSpan = TimeSpan; if (typeof window !== "undefined" ) { // keeping API compatible for v1.x window.TimeSpan = TimeSpan; } }()); (function () { "use strict"; var attrs = ["years", "months", "days", "hours", "minutes", "seconds", "milliseconds"]; var gFn = function (attr) { return function () { return this[attr]; }; }; var sFn = function (attr) { return function (val) { this[attr] = val; return this; }; }; var addSetFuncs = function (context, attrs) { for (var i = 0; i < attrs.length ; i++) { var $a = attrs[i], $b = $a.slice(0, 1).toUpperCase() + $a.slice(1); context.prototype[$a] = 0; context.prototype["get" + $b] = gFn($a); context.prototype["set" + $b] = sFn($a); } }; var setMonthsAndYears = function (orient, d1, d2, context) { function inc() { d1.addMonths(-orient); context.months++; if (context.months === 12) { context.years++; context.months = 0; } } if (orient === +1) { while (d1 > d2) { inc(); } } else { while (d1 < d2) { inc(); } } context.months--; context.months *= orient; context.years *= orient; }; var adjustForDST = function(orient, startDate, endDate) { var hasDSTMismatch = (false === (startDate.isDaylightSavingTime() === endDate.isDaylightSavingTime())); if (hasDSTMismatch && orient === 1) { startDate.addHours(-1); } else if (hasDSTMismatch) { startDate.addHours(1); } }; /** * TimePeriod(startDate, endDate); * TimePeriod(years, months, days, hours, minutes, seconds, milliseconds); */ var TimePeriod = function (years, months, days, hours, minutes, seconds, milliseconds) { if (arguments.length === 7) { this.set(years, months, days, hours, minutes, seconds, milliseconds); } else if (arguments.length === 2 && arguments[0] instanceof Date && arguments[1] instanceof Date) { var startDate = arguments[0].clone(); var endDate = arguments[1].clone(); var orient = (startDate > endDate) ? +1 : -1; this.dates = { start: arguments[0].clone(), end: arguments[1].clone() }; setMonthsAndYears(orient, startDate, endDate, this); adjustForDST(orient, startDate, endDate); // // TODO - adjust for DST var diff = endDate - startDate; if (diff !== 0) { var ts = new TimeSpan(diff); this.set(this.years, this.months, ts.getDays(), ts.getHours(), ts.getMinutes(), ts.getSeconds(), ts.getMilliseconds()); } } return this; }; // create all the set functions. addSetFuncs(TimePeriod, attrs); TimePeriod.prototype.set = function (years, months, days, hours, minutes, seconds, milliseconds){ this.setYears(years || this.getYears()); this.setMonths(months || this.getMonths()); this.setDays(days || this.getDays()); this.setHours(hours || this.getHours()); this.setMinutes(minutes || this.getMinutes()); this.setSeconds(seconds || this.getSeconds()); this.setMilliseconds(milliseconds || this.getMilliseconds()); }; Date.TimePeriod = TimePeriod; if (typeof window !== "undefined") { // keeping API compatible for v1.x window.TimePeriod = TimePeriod; } }()); ================================================ FILE: build/date-gu-IN.js ================================================ /** * @overview datejs * @version 1.0.0-rc3 * @author Gregory Wild-Smith * @copyright 2015 Gregory Wild-Smith * @license MIT * @homepage https://github.com/abritinthebay/datejs */ /* * DateJS Culture String File * Country Code: gu-IN * Name: Gujarati (India) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["gu-IN"] = { "name": "gu-IN", "englishName": "Gujarati (India)", "nativeName": "ગુજરાતી (ભારત)", "Sunday": "રવિવાર", "Monday": "સોમવાર", "Tuesday": "મંગળવાર", "Wednesday": "બુધવાર", "Thursday": "ગુરુવાર", "Friday": "શુક્રવાર", "Saturday": "શનિવાર", "Sun": "રવિ", "Mon": "સોમ", "Tue": "મંગળ", "Wed": "બુધ", "Thu": "ગુરુ", "Fri": "શુક્ર", "Sat": "શનિ", "Su": "ર", "Mo": "સ", "Tu": "મ", "We": "બ", "Th": "ગ", "Fr": "શ", "Sa": "શ", "S_Sun_Initial": "ર", "M_Mon_Initial": "સ", "T_Tue_Initial": "મ", "W_Wed_Initial": "બ", "T_Thu_Initial": "ગ", "F_Fri_Initial": "શ", "S_Sat_Initial": "શ", "January": "જાન્યુઆરી", "February": "ફેબ્રુઆરી", "March": "માર્ચ", "April": "એપ્રિલ", "May": "મે", "June": "જૂન", "July": "જુલાઈ", "August": "ઑગસ્ટ", "September": "સપ્ટેમ્બર", "October": "ઑક્ટ્બર", "November": "નવેમ્બર", "December": "ડિસેમ્બર", "Jan_Abbr": "જાન્યુ", "Feb_Abbr": "ફેબ્રુ", "Mar_Abbr": "માર્ચ", "Apr_Abbr": "એપ્રિલ", "May_Abbr": "મે", "Jun_Abbr": "જૂન", "Jul_Abbr": "જુલાઈ", "Aug_Abbr": "ઑગસ્ટ", "Sep_Abbr": "સપ્ટે", "Oct_Abbr": "ઑક્ટો", "Nov_Abbr": "નવે", "Dec_Abbr": "ડિસે", "AM": "પૂર્વ મધ્યાહ્ન", "PM": "ઉત્તર મધ્યાહ્ન", "firstDayOfWeek": 1, "twoDigitYearMax": 2029, "mdy": "dmy", "M/d/yyyy": "dd-MM-yy", "dddd, MMMM dd, yyyy": "dd MMMM yyyy", "h:mm tt": "HH:mm", "h:mm:ss tt": "HH:mm:ss", "dddd, MMMM dd, yyyy h:mm:ss tt": "dd MMMM yyyy HH:mm:ss", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "dd MMMM", "MMMM, yyyy": "MMMM, yyyy", "/jan(uary)?/": "જાન્યુ(આરી)?", "/feb(ruary)?/": "ફેબ્રુ(આરી)?", "/mar(ch)?/": "માર્ચ", "/apr(il)?/": "એપ્રિલ", "/may/": "મે", "/jun(e)?/": "જૂન", "/jul(y)?/": "જુલાઈ", "/aug(ust)?/": "ઑગસ્ટ", "/sep(t(ember)?)?/": "સપ્ટે(મ્બર)?", "/oct(ober)?/": "ઑક્ટ્બર", "/nov(ember)?/": "નવે(મ્બર)?", "/dec(ember)?/": "ડિસે(મ્બર)?", "/^su(n(day)?)?/": "^ર(વિ(વાર)?)?", "/^mo(n(day)?)?/": "^સ(ોમ(વાર)?)?", "/^tu(e(s(day)?)?)?/": "^મ(ંગળ(વાર)?)?", "/^we(d(nesday)?)?/": "^બ(ુધ(વાર)?)?", "/^th(u(r(s(day)?)?)?)?/": "^ગ(ુરુ(વાર)?)?", "/^fr(i(day)?)?/": "^શ(ુક્ર(વાર)?)?", "/^sa(t(urday)?)?/": "^શ(નિ(વાર)?)?", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "gu-IN"; /** * @overview datejs * @version 1.0.0-rc3 * @author Gregory Wild-Smith * @copyright 2015 Gregory Wild-Smith * @license MIT * @homepage https://github.com/abritinthebay/datejs */(function () { var $D = Date; var lang = Date.CultureStrings ? Date.CultureStrings.lang : null; var loggedKeys = {}; // for debug purposes. var getText = { getFromKey: function (key, countryCode) { var output; if (Date.CultureStrings && Date.CultureStrings[countryCode] && Date.CultureStrings[countryCode][key]) { output = Date.CultureStrings[countryCode][key]; } else { output = getText.buildFromDefault(key); } if (key.charAt(0) === "/") { // Assume it's a regex output = getText.buildFromRegex(key, countryCode); } return output; }, getFromObjectValues: function (obj, countryCode) { var key, output = {}; for(key in obj) { if (obj.hasOwnProperty(key)) { output[key] = getText.getFromKey(obj[key], countryCode); } } return output; }, getFromObjectKeys: function (obj, countryCode) { var key, output = {}; for(key in obj) { if (obj.hasOwnProperty(key)) { output[getText.getFromKey(key, countryCode)] = obj[key]; } } return output; }, getFromArray: function (arr, countryCode) { var output = []; for (var i=0; i < arr.length; i++){ if (i in arr) { output[i] = getText.getFromKey(arr[i], countryCode); } } return output; }, buildFromDefault: function (key) { var output, length, split, last; switch(key) { case "name": output = "en-US"; break; case "englishName": output = "English (United States)"; break; case "nativeName": output = "English (United States)"; break; case "twoDigitYearMax": output = 2049; break; case "firstDayOfWeek": output = 0; break; default: output = key; split = key.split("_"); length = split.length; if (length > 1 && key.charAt(0) !== "/") { // if the key isn't a regex and it has a split. last = split[(length - 1)].toLowerCase(); if (last === "initial" || last === "abbr") { output = split[0]; } } break; } return output; }, buildFromRegex: function (key, countryCode) { var output; if (Date.CultureStrings && Date.CultureStrings[countryCode] && Date.CultureStrings[countryCode][key]) { output = new RegExp(Date.CultureStrings[countryCode][key], "i"); } else { output = new RegExp(key.replace(new RegExp("/", "g"),""), "i"); } return output; } }; var shallowMerge = function (obj1, obj2) { for (var attrname in obj2) { if (obj2.hasOwnProperty(attrname)) { obj1[attrname] = obj2[attrname]; } } }; var __ = function (key, language) { var countryCode = (language) ? language : lang; loggedKeys[key] = key; if (typeof key === "object") { if (key instanceof Array) { return getText.getFromArray(key, countryCode); } else { return getText.getFromObjectKeys(key, countryCode); } } else { return getText.getFromKey(key, countryCode); } }; var loadI18nScript = function (code) { // paatterned after jQuery's getScript. var url = Date.Config.i18n + code + ".js"; var head = document.getElementsByTagName("head")[0] || document.documentElement; var script = document.createElement("script"); script.src = url; var completed = false; var events = { done: function (){} // placeholder function }; // Attach handlers for all browsers script.onload = script.onreadystatechange = function() { if ( !completed && (!this.readyState || this.readyState === "loaded" || this.readyState === "complete") ) { events.done(); head.removeChild(script); } }; setTimeout(function() { head.insertBefore(script, head.firstChild); }, 0); // allows return to execute first return { done: function (cb) { events.done = function() { if (cb) { setTimeout(cb,0); } }; } }; }; var buildInfo = { buildFromMethodHash: function (obj) { var key; for(key in obj) { if (obj.hasOwnProperty(key)) { obj[key] = buildInfo[obj[key]](); } } return obj; }, timeZoneDST: function () { var DST = { "CHADT": "+1345", "NZDT": "+1300", "AEDT": "+1100", "ACDT": "+1030", "AZST": "+0500", "IRDT": "+0430", "EEST": "+0300", "CEST": "+0200", "BST": "+0100", "PMDT": "-0200", "ADT": "-0300", "NDT": "-0230", "EDT": "-0400", "CDT": "-0500", "MDT": "-0600", "PDT": "-0700", "AKDT": "-0800", "HADT": "-0900" }; return __(DST); }, timeZoneStandard: function () { var standard = { "LINT": "+1400", "TOT": "+1300", "CHAST": "+1245", "NZST": "+1200", "NFT": "+1130", "SBT": "+1100", "AEST": "+1000", "ACST": "+0930", "JST": "+0900", "CWST": "+0845", "CT": "+0800", "ICT": "+0700", "MMT": "+0630", "BST": "+0600", "NPT": "+0545", "IST": "+0530", "PKT": "+0500", "AFT": "+0430", "MSK": "+0400", "IRST": "+0330", "FET": "+0300", "EET": "+0200", "CET": "+0100", "GMT": "+0000", "UTC": "+0000", "CVT": "-0100", "GST": "-0200", "BRT": "-0300", "NST": "-0330", "AST": "-0400", "EST": "-0500", "CST": "-0600", "MST": "-0700", "PST": "-0800", "AKST": "-0900", "MIT": "-0930", "HST": "-1000", "SST": "-1100", "BIT": "-1200" }; return __(standard); }, timeZones: function (data) { var zone; data.timezones = []; for (zone in data.abbreviatedTimeZoneStandard) { if (data.abbreviatedTimeZoneStandard.hasOwnProperty(zone)) { data.timezones.push({ name: zone, offset: data.abbreviatedTimeZoneStandard[zone]}); } } for (zone in data.abbreviatedTimeZoneDST) { if (data.abbreviatedTimeZoneDST.hasOwnProperty(zone)) { data.timezones.push({ name: zone, offset: data.abbreviatedTimeZoneDST[zone], dst: true}); } } return data.timezones; }, days: function () { return __(["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"]); }, dayAbbr: function () { return __(["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"]); }, dayShortNames: function () { return __(["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"]); }, dayFirstLetters: function () { return __(["S_Sun_Initial", "M_Mon_Initial", "T_Tues_Initial", "W_Wed_Initial", "T_Thu_Initial", "F_Fri_Initial", "S_Sat_Initial"]); }, months: function () { return __(["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"]); }, monthAbbr: function () { return __(["Jan_Abbr", "Feb_Abbr", "Mar_Abbr", "Apr_Abbr", "May_Abbr", "Jun_Abbr", "Jul_Abbr", "Aug_Abbr", "Sep_Abbr", "Oct_Abbr", "Nov_Abbr", "Dec_Abbr"]); }, formatPatterns: function () { return getText.getFromObjectValues({ shortDate: "M/d/yyyy", longDate: "dddd, MMMM dd, yyyy", shortTime: "h:mm tt", longTime: "h:mm:ss tt", fullDateTime: "dddd, MMMM dd, yyyy h:mm:ss tt", sortableDateTime: "yyyy-MM-ddTHH:mm:ss", universalSortableDateTime: "yyyy-MM-dd HH:mm:ssZ", rfc1123: "ddd, dd MMM yyyy HH:mm:ss", monthDay: "MMMM dd", yearMonth: "MMMM, yyyy" }, Date.i18n.currentLanguage()); }, regex: function () { return getText.getFromObjectValues({ inTheMorning: "/( in the )(morn(ing)?)\\b/", thisMorning: "/(this )(morn(ing)?)\\b/", amThisMorning: "/(\b\\d(am)? )(this )(morn(ing)?)/", inTheEvening: "/( in the )(even(ing)?)\\b/", thisEvening: "/(this )(even(ing)?)\\b/", pmThisEvening: "/(\b\\d(pm)? )(this )(even(ing)?)/", jan: "/jan(uary)?/", feb: "/feb(ruary)?/", mar: "/mar(ch)?/", apr: "/apr(il)?/", may: "/may/", jun: "/jun(e)?/", jul: "/jul(y)?/", aug: "/aug(ust)?/", sep: "/sep(t(ember)?)?/", oct: "/oct(ober)?/", nov: "/nov(ember)?/", dec: "/dec(ember)?/", sun: "/^su(n(day)?)?/", mon: "/^mo(n(day)?)?/", tue: "/^tu(e(s(day)?)?)?/", wed: "/^we(d(nesday)?)?/", thu: "/^th(u(r(s(day)?)?)?)?/", fri: "/fr(i(day)?)?/", sat: "/^sa(t(urday)?)?/", future: "/^next/", past: "/^last|past|prev(ious)?/", add: "/^(\\+|aft(er)?|from|hence)/", subtract: "/^(\\-|bef(ore)?|ago)/", yesterday: "/^yes(terday)?/", today: "/^t(od(ay)?)?/", tomorrow: "/^tom(orrow)?/", now: "/^n(ow)?/", millisecond: "/^ms|milli(second)?s?/", second: "/^sec(ond)?s?/", minute: "/^mn|min(ute)?s?/", hour: "/^h(our)?s?/", week: "/^w(eek)?s?/", month: "/^m(onth)?s?/", day: "/^d(ay)?s?/", year: "/^y(ear)?s?/", shortMeridian: "/^(a|p)/", longMeridian: "/^(a\\.?m?\\.?|p\\.?m?\\.?)/", timezone: "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/", ordinalSuffix: "/^\\s*(st|nd|rd|th)/", timeContext: "/^\\s*(\\:|a(?!u|p)|p)/" }, Date.i18n.currentLanguage()); } }; var CultureInfo = function () { var info = getText.getFromObjectValues({ name: "name", englishName: "englishName", nativeName: "nativeName", amDesignator: "AM", pmDesignator: "PM", firstDayOfWeek: "firstDayOfWeek", twoDigitYearMax: "twoDigitYearMax", dateElementOrder: "mdy" }, Date.i18n.currentLanguage()); var constructedInfo = buildInfo.buildFromMethodHash({ dayNames: "days", abbreviatedDayNames: "dayAbbr", shortestDayNames: "dayShortNames", firstLetterDayNames: "dayFirstLetters", monthNames: "months", abbreviatedMonthNames: "monthAbbr", formatPatterns: "formatPatterns", regexPatterns: "regex", abbreviatedTimeZoneDST: "timeZoneDST", abbreviatedTimeZoneStandard: "timeZoneStandard" }); shallowMerge(info, constructedInfo); buildInfo.timeZones(info); return info; }; $D.i18n = { __: function (key, lang) { return __(key, lang); }, currentLanguage: function () { return lang || "en-US"; }, setLanguage: function (code, force, cb) { var async = false; if (force || code === "en-US" || (!!Date.CultureStrings && !!Date.CultureStrings[code])) { lang = code; Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings.lang = code; Date.CultureInfo = new CultureInfo(); } else { if (!(!!Date.CultureStrings && !!Date.CultureStrings[code])) { if (typeof exports !== "undefined" && this.exports !== exports) { // we're in a Node enviroment, load it using require try { require("../i18n/" + code + ".js"); lang = code; Date.CultureStrings.lang = code; Date.CultureInfo = new CultureInfo(); } catch (e) { // var str = "The language for '" + code + "' could not be loaded by Node. It likely does not exist."; throw new Error("The DateJS IETF language tag '" + code + "' could not be loaded by Node. It likely does not exist."); } } else if (Date.Config && Date.Config.i18n) { // we know the location of the files, so lets load them async = true; loadI18nScript(code).done(function(){ lang = code; Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings.lang = code; Date.CultureInfo = new CultureInfo(); $D.Parsing.Normalizer.buildReplaceData(); // because this is async if ($D.Grammar) { $D.Grammar.buildGrammarFormats(); // so we can parse those strings... } if (cb) { setTimeout(cb,0); } }); } else { Date.console.error("The DateJS IETF language tag '" + code + "' is not available and has not been loaded."); return false; } } } $D.Parsing.Normalizer.buildReplaceData(); // rebuild normalizer strings if ($D.Grammar) { $D.Grammar.buildGrammarFormats(); // so we can parse those strings... } if (!async && cb) { setTimeout(cb,0); } }, getLoggedKeys: function () { return loggedKeys; }, updateCultureInfo: function () { Date.CultureInfo = new CultureInfo(); } }; $D.i18n.updateCultureInfo(); // run automatically }()); (function () { var $D = Date, $P = $D.prototype, p = function (s, l) { if (!l) { l = 2; } return ("000" + s).slice(l * -1); }; if (typeof window !== "undefined" && typeof window.console !== "undefined" && typeof window.console.log !== "undefined") { $D.console = console; // used only to raise non-critical errors if available } else { // set mock so we don't give errors. $D.console = { log: function(){}, error: function(){} }; } $D.Config = $D.Config || {}; $D.initOverloads = function() { /** * Overload of Date.now. Allows an alternate call for Date.now where it returns the * current Date as an object rather than just milliseconds since the Unix Epoch. * * Also provides an implementation of now() for browsers (IE<9) that don't have it. * * Backwards compatible so with work with either: * Date.now() [returns ms] * or * Date.now(true) [returns Date] */ if (!$D.now) { $D._now = function now() { return new Date().getTime(); }; } else if (!$D._now) { $D._now = $D.now; } $D.now = function (returnObj) { if (returnObj) { return $D.present(); } else { return $D._now(); } }; if ( !$P.toISOString ) { $P.toISOString = function() { return this.getUTCFullYear() + "-" + p(this.getUTCMonth() + 1) + "-" + p(this.getUTCDate()) + "T" + p(this.getUTCHours()) + ":" + p(this.getUTCMinutes()) + ":" + p(this.getUTCSeconds()) + "." + String( (this.getUTCMilliseconds()/1000).toFixed(3)).slice(2, 5) + "Z"; }; } // private if ( $P._toString === undefined ){ $P._toString = $P.toString; } }; $D.initOverloads(); /** * Gets a date that is set to the current date. The time is set to the start of the day (00:00 or 12:00 AM). * @return {Date} The current date. */ $D.today = function () { return new Date().clearTime(); }; /** * Gets a date that is set to the current date and time (same as new Date, but chainable) * @return {Date} The current date. */ $D.present = function () { return new Date(); }; /** * Compares the first date to the second date and returns an number indication of their relative values. * @param {Date} First Date object to compare [Required]. * @param {Date} Second Date object to compare to [Required]. * @return {Number} -1 = date1 is lessthan date2. 0 = values are equal. 1 = date1 is greaterthan date2. */ $D.compare = function (date1, date2) { if (isNaN(date1) || isNaN(date2)) { throw new Error(date1 + " - " + date2); } else if (date1 instanceof Date && date2 instanceof Date) { return (date1 < date2) ? -1 : (date1 > date2) ? 1 : 0; } else { throw new TypeError(date1 + " - " + date2); } }; /** * Compares the first Date object to the second Date object and returns true if they are equal. * @param {Date} First Date object to compare [Required] * @param {Date} Second Date object to compare to [Required] * @return {Boolean} true if dates are equal. false if they are not equal. */ $D.equals = function (date1, date2) { return (date1.compareTo(date2) === 0); }; /** * Gets the language appropriate day name when given the day number(0-6) * eg - 0 == Sunday * @return {String} The day name */ $D.getDayName = function (n) { return Date.CultureInfo.dayNames[n]; }; /** * Gets the day number (0-6) if given a CultureInfo specific string which is a valid dayName, abbreviatedDayName or shortestDayName (two char). * @param {String} The name of the day (eg. "Monday, "Mon", "tuesday", "tue", "We", "we"). * @return {Number} The day number */ $D.getDayNumberFromName = function (name) { var n = Date.CultureInfo.dayNames, m = Date.CultureInfo.abbreviatedDayNames, o = Date.CultureInfo.shortestDayNames, s = name.toLowerCase(); for (var i = 0; i < n.length; i++) { if (n[i].toLowerCase() === s || m[i].toLowerCase() === s || o[i].toLowerCase() === s) { return i; } } return -1; }; /** * Gets the month number (0-11) if given a Culture Info specific string which is a valid monthName or abbreviatedMonthName. * @param {String} The name of the month (eg. "February, "Feb", "october", "oct"). * @return {Number} The day number */ $D.getMonthNumberFromName = function (name) { var n = Date.CultureInfo.monthNames, m = Date.CultureInfo.abbreviatedMonthNames, s = name.toLowerCase(); for (var i = 0; i < n.length; i++) { if (n[i].toLowerCase() === s || m[i].toLowerCase() === s) { return i; } } return -1; }; /** * Gets the language appropriate month name when given the month number(0-11) * eg - 0 == January * @return {String} The month name */ $D.getMonthName = function (n) { return Date.CultureInfo.monthNames[n]; }; /** * Determines if the current date instance is within a LeapYear. * @param {Number} The year. * @return {Boolean} true if date is within a LeapYear, otherwise false. */ $D.isLeapYear = function (year) { return ((year % 4 === 0 && year % 100 !== 0) || year % 400 === 0); }; /** * Gets the number of days in the month, given a year and month value. Automatically corrects for LeapYear. * @param {Number} The year. * @param {Number} The month (0-11). * @return {Number} The number of days in the month. */ $D.getDaysInMonth = function (year, month) { if (!month && $D.validateMonth(year)) { month = year; year = Date.today().getFullYear(); } return [31, ($D.isLeapYear(year) ? 29 : 28), 31, 30, 31, 30, 31, 31, 30, 31, 30, 31][month]; }; $P.getDaysInMonth = function () { return $D.getDaysInMonth(this.getFullYear(), this.getMonth()); }; $D.getTimezoneAbbreviation = function (offset, dst) { var p, n = (dst || false) ? Date.CultureInfo.abbreviatedTimeZoneDST : Date.CultureInfo.abbreviatedTimeZoneStandard; for (p in n) { if (n.hasOwnProperty(p)) { if (n[p] === offset) { return p; } } } return null; }; $D.getTimezoneOffset = function (name, dst) { var i, a =[], z = Date.CultureInfo.timezones; if (!name) { name = (new Date()).getTimezone();} for (i = 0; i < z.length; i++) { if (z[i].name === name.toUpperCase()) { a.push(i); } } if (!z[a[0]]) { return null; } if (a.length === 1 || !dst) { return z[a[0]].offset; } else { for (i=0; i < a.length; i++) { if (z[a[i]].dst) { return z[a[i]].offset; } } } }; $D.getQuarter = function (d) { d = d || new Date(); // If no date supplied, use today var q = [1,2,3,4]; return q[Math.floor(d.getMonth() / 3)]; // ~~~ is a bitwise op. Faster than Math.floor }; $D.getDaysLeftInQuarter = function (d) { d = d || new Date(); var qEnd = new Date(d); qEnd.setMonth(qEnd.getMonth() + 3 - qEnd.getMonth() % 3, 0); return Math.floor((qEnd - d) / 8.64e7); }; // private var validate = function (n, min, max, name) { name = name ? name : "Object"; if (typeof n === "undefined") { return false; } else if (typeof n !== "number") { throw new TypeError(n + " is not a Number."); } else if (n < min || n > max) { // As failing validation is *not* an exceptional circumstance // lets not throw a RangeError Exception here. // It's semantically correct but it's not sensible. return false; } return true; }; /** * Validates the number is within an acceptable range for milliseconds [0-999]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateMillisecond = function (value) { return validate(value, 0, 999, "millisecond"); }; /** * Validates the number is within an acceptable range for seconds [0-59]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateSecond = function (value) { return validate(value, 0, 59, "second"); }; /** * Validates the number is within an acceptable range for minutes [0-59]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateMinute = function (value) { return validate(value, 0, 59, "minute"); }; /** * Validates the number is within an acceptable range for hours [0-23]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateHour = function (value) { return validate(value, 0, 23, "hour"); }; /** * Validates the number is within an acceptable range for the days in a month [0-MaxDaysInMonth]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateDay = function (value, year, month) { if (year === undefined || year === null || month === undefined || month === null) { return false;} return validate(value, 1, $D.getDaysInMonth(year, month), "day"); }; /** * Validates the number is within an acceptable range for months [0-11]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateWeek = function (value) { return validate(value, 0, 53, "week"); }; /** * Validates the number is within an acceptable range for months [0-11]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateMonth = function (value) { return validate(value, 0, 11, "month"); }; /** * Validates the number is within an acceptable range for years. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateYear = function (value) { /** * Per ECMAScript spec the range of times supported by Date objects is * exactly -100,000,000 days to +100,000,000 days measured relative to * midnight at the beginning of 01 January, 1970 UTC. * This gives a range of 8,640,000,000,000,000 milliseconds to either * side of 01 January, 1970 UTC. * * Earliest possible date: Tue, 20 Apr 271,822 B.C. 00:00:00 UTC * Latest possible date: Sat, 13 Sep 275,760 00:00:00 UTC */ return validate(value, -271822, 275760, "year"); }; $D.validateTimezone = function(value) { var timezones = {"ACDT":1,"ACST":1,"ACT":1,"ADT":1,"AEDT":1,"AEST":1,"AFT":1,"AKDT":1,"AKST":1,"AMST":1,"AMT":1,"ART":1,"AST":1,"AWDT":1,"AWST":1,"AZOST":1,"AZT":1,"BDT":1,"BIOT":1,"BIT":1,"BOT":1,"BRT":1,"BST":1,"BTT":1,"CAT":1,"CCT":1,"CDT":1,"CEDT":1,"CEST":1,"CET":1,"CHADT":1,"CHAST":1,"CHOT":1,"ChST":1,"CHUT":1,"CIST":1,"CIT":1,"CKT":1,"CLST":1,"CLT":1,"COST":1,"COT":1,"CST":1,"CT":1,"CVT":1,"CWST":1,"CXT":1,"DAVT":1,"DDUT":1,"DFT":1,"EASST":1,"EAST":1,"EAT":1,"ECT":1,"EDT":1,"EEDT":1,"EEST":1,"EET":1,"EGST":1,"EGT":1,"EIT":1,"EST":1,"FET":1,"FJT":1,"FKST":1,"FKT":1,"FNT":1,"GALT":1,"GAMT":1,"GET":1,"GFT":1,"GILT":1,"GIT":1,"GMT":1,"GST":1,"GYT":1,"HADT":1,"HAEC":1,"HAST":1,"HKT":1,"HMT":1,"HOVT":1,"HST":1,"ICT":1,"IDT":1,"IOT":1,"IRDT":1,"IRKT":1,"IRST":1,"IST":1,"JST":1,"KGT":1,"KOST":1,"KRAT":1,"KST":1,"LHST":1,"LINT":1,"MAGT":1,"MART":1,"MAWT":1,"MDT":1,"MET":1,"MEST":1,"MHT":1,"MIST":1,"MIT":1,"MMT":1,"MSK":1,"MST":1,"MUT":1,"MVT":1,"MYT":1,"NCT":1,"NDT":1,"NFT":1,"NPT":1,"NST":1,"NT":1,"NUT":1,"NZDT":1,"NZST":1,"OMST":1,"ORAT":1,"PDT":1,"PET":1,"PETT":1,"PGT":1,"PHOT":1,"PHT":1,"PKT":1,"PMDT":1,"PMST":1,"PONT":1,"PST":1,"PYST":1,"PYT":1,"RET":1,"ROTT":1,"SAKT":1,"SAMT":1,"SAST":1,"SBT":1,"SCT":1,"SGT":1,"SLST":1,"SRT":1,"SST":1,"SYOT":1,"TAHT":1,"THA":1,"TFT":1,"TJT":1,"TKT":1,"TLT":1,"TMT":1,"TOT":1,"TVT":1,"UCT":1,"ULAT":1,"UTC":1,"UYST":1,"UYT":1,"UZT":1,"VET":1,"VLAT":1,"VOLT":1,"VOST":1,"VUT":1,"WAKT":1,"WAST":1,"WAT":1,"WEDT":1,"WEST":1,"WET":1,"WST":1,"YAKT":1,"YEKT":1,"Z":1}; return (timezones[value] === 1); }; $D.validateTimezoneOffset= function(value) { // timezones go from +14hrs to -12hrs, the +X hours are negative offsets. return (value > -841 && value < 721); }; }()); (function () { var $D = Date, $P = $D.prototype, p = function (s, l) { if (!l) { l = 2; } return ("000" + s).slice(l * -1); }; var validateConfigObject = function (obj) { var result = {}, self = this, prop, testFunc; testFunc = function (prop, func, value) { if (prop === "day") { var month = (obj.month !== undefined) ? obj.month : self.getMonth(); var year = (obj.year !== undefined) ? obj.year : self.getFullYear(); return $D[func](value, year, month); } else { return $D[func](value); } }; for (prop in obj) { if (Object.prototype.hasOwnProperty.call(obj, prop)) { var func = "validate" + prop.charAt(0).toUpperCase() + prop.slice(1); if ($D[func] && obj[prop] !== null && testFunc(prop, func, obj[prop])) { result[prop] = obj[prop]; } } } return result; }; /** * Resets the time of this Date object to 12:00 AM (00:00), which is the start of the day. * @param {Boolean} .clone() this date instance before clearing Time * @return {Date} this */ $P.clearTime = function () { this.setHours(0); this.setMinutes(0); this.setSeconds(0); this.setMilliseconds(0); return this; }; /** * Resets the time of this Date object to the current time ('now'). * @return {Date} this */ $P.setTimeToNow = function () { var n = new Date(); this.setHours(n.getHours()); this.setMinutes(n.getMinutes()); this.setSeconds(n.getSeconds()); this.setMilliseconds(n.getMilliseconds()); return this; }; /** * Returns a new Date object that is an exact date and time copy of the original instance. * @return {Date} A new Date instance */ $P.clone = function () { return new Date(this.getTime()); }; /** * Compares this instance to a Date object and returns an number indication of their relative values. * @param {Date} Date object to compare [Required] * @return {Number} -1 = this is lessthan date. 0 = values are equal. 1 = this is greaterthan date. */ $P.compareTo = function (date) { return Date.compare(this, date); }; /** * Compares this instance to another Date object and returns true if they are equal. * @param {Date} Date object to compare. If no date to compare, new Date() [now] is used. * @return {Boolean} true if dates are equal. false if they are not equal. */ $P.equals = function (date) { return Date.equals(this, (date !== undefined ? date : new Date())); }; /** * Determines if this instance is between a range of two dates or equal to either the start or end dates. * @param {Date} Start of range [Required] * @param {Date} End of range [Required] * @return {Boolean} true is this is between or equal to the start and end dates, else false */ $P.between = function (start, end) { return this.getTime() >= start.getTime() && this.getTime() <= end.getTime(); }; /** * Determines if this date occurs after the date to compare to. * @param {Date} Date object to compare. If no date to compare, new Date() ("now") is used. * @return {Boolean} true if this date instance is greater than the date to compare to (or "now"), otherwise false. */ $P.isAfter = function (date) { return this.compareTo(date || new Date()) === 1; }; /** * Determines if this date occurs before the date to compare to. * @param {Date} Date object to compare. If no date to compare, new Date() ("now") is used. * @return {Boolean} true if this date instance is less than the date to compare to (or "now"). */ $P.isBefore = function (date) { return (this.compareTo(date || new Date()) === -1); }; /** * Determines if the current Date instance occurs today. * @return {Boolean} true if this date instance is 'today', otherwise false. */ /** * Determines if the current Date instance occurs on the same Date as the supplied 'date'. * If no 'date' to compare to is provided, the current Date instance is compared to 'today'. * @param {date} Date object to compare. If no date to compare, the current Date ("now") is used. * @return {Boolean} true if this Date instance occurs on the same Day as the supplied 'date'. */ $P.isToday = $P.isSameDay = function (date) { return this.clone().clearTime().equals((date || new Date()).clone().clearTime()); }; /** * Adds the specified number of milliseconds to this instance. * @param {Number} The number of milliseconds to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addMilliseconds = function (value) { if (!value) { return this; } this.setTime(this.getTime() + value * 1); return this; }; /** * Adds the specified number of seconds to this instance. * @param {Number} The number of seconds to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addSeconds = function (value) { if (!value) { return this; } return this.addMilliseconds(value * 1000); }; /** * Adds the specified number of seconds to this instance. * @param {Number} The number of seconds to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addMinutes = function (value) { if (!value) { return this; } return this.addMilliseconds(value * 60000); // 60*1000 }; /** * Adds the specified number of hours to this instance. * @param {Number} The number of hours to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addHours = function (value) { if (!value) { return this; } return this.addMilliseconds(value * 3600000); // 60*60*1000 }; /** * Adds the specified number of days to this instance. * @param {Number} The number of days to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addDays = function (value) { if (!value) { return this; } this.setDate(this.getDate() + value * 1); return this; }; /** * Adds the specified number of weekdays (ie - not sat or sun) to this instance. * @param {Number} The number of days to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addWeekdays = function (value) { if (!value) { return this; } var day = this.getDay(); var weeks = (Math.ceil(Math.abs(value)/7)); if (day === 0 || day === 6) { if (value > 0) { this.next().monday(); this.addDays(-1); day = this.getDay(); } } if (value < 0) { while (value < 0) { this.addDays(-1); day = this.getDay(); if (day !== 0 && day !== 6) { value++; } } return this; } else if (value > 5 || (6-day) <= value) { value = value + (weeks * 2); } return this.addDays(value); }; /** * Adds the specified number of weeks to this instance. * @param {Number} The number of weeks to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addWeeks = function (value) { if (!value) { return this; } return this.addDays(value * 7); }; /** * Adds the specified number of months to this instance. * @param {Number} The number of months to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addMonths = function (value) { if (!value) { return this; } var n = this.getDate(); this.setDate(1); this.setMonth(this.getMonth() + value * 1); this.setDate(Math.min(n, $D.getDaysInMonth(this.getFullYear(), this.getMonth()))); return this; }; $P.addQuarters = function (value) { if (!value) { return this; } // note this will take you to the same point in the quarter as you are now. // i.e. - if you are 15 days into the quarter you'll be 15 days into the resulting one. // bonus: this allows adding fractional quarters return this.addMonths(value * 3); }; /** * Adds the specified number of years to this instance. * @param {Number} The number of years to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addYears = function (value) { if (!value) { return this; } return this.addMonths(value * 12); }; /** * Adds (or subtracts) to the value of the years, months, weeks, days, hours, minutes, seconds, milliseconds of the date instance using given configuration object. Positive and Negative values allowed. * Example

	Date.today().add( { days: 1, months: 1 } )

	new Date().add( { years: -1 } )
	
* @param {Object} Configuration object containing attributes (months, days, etc.) * @return {Date} this */ $P.add = function (config) { if (typeof config === "number") { this._orient = config; return this; } var x = config; if (x.day) { // If we should be a different date than today (eg: for 'tomorrow -1d', etc). // Should only effect parsing, not direct usage (eg, Finish and FinishExact) if ((x.day - this.getDate()) !== 0) { this.setDate(x.day); } } if (x.milliseconds) { this.addMilliseconds(x.milliseconds); } if (x.seconds) { this.addSeconds(x.seconds); } if (x.minutes) { this.addMinutes(x.minutes); } if (x.hours) { this.addHours(x.hours); } if (x.weeks) { this.addWeeks(x.weeks); } if (x.months) { this.addMonths(x.months); } if (x.years) { this.addYears(x.years); } if (x.days) { this.addDays(x.days); } return this; }; /** * Get the week number. Week one (1) is the week which contains the first Thursday of the year. Monday is considered the first day of the week. * The .getWeek() function does NOT convert the date to UTC. The local datetime is used. * Please use .getISOWeek() to get the week of the UTC converted date. * @return {Number} 1 to 53 */ $P.getWeek = function (utc) { // Create a copy of this date object var self, target = new Date(this.valueOf()); if (utc) { target.addMinutes(target.getTimezoneOffset()); self = target.clone(); } else { self = this; } // ISO week date weeks start on monday // so correct the day number var dayNr = (self.getDay() + 6) % 7; // ISO 8601 states that week 1 is the week // with the first thursday of that year. // Set the target date to the thursday in the target week target.setDate(target.getDate() - dayNr + 3); // Store the millisecond value of the target date var firstThursday = target.valueOf(); // Set the target to the first thursday of the year // First set the target to january first target.setMonth(0, 1); // Not a thursday? Correct the date to the next thursday if (target.getDay() !== 4) { target.setMonth(0, 1 + ((4 - target.getDay()) + 7) % 7); } // The weeknumber is the number of weeks between the // first thursday of the year and the thursday in the target week return 1 + Math.ceil((firstThursday - target) / 604800000); // 604800000 = 7 * 24 * 3600 * 1000 }; /** * Get the ISO 8601 week number. Week one ("01") is the week which contains the first Thursday of the year. Monday is considered the first day of the week. * The .getISOWeek() function does convert the date to it's UTC value. Please use .getWeek() to get the week of the local date. * @return {String} "01" to "53" */ $P.getISOWeek = function () { return p(this.getWeek(true)); }; /** * Moves the date to Monday of the week set. Week one (1) is the week which contains the first Thursday of the year. * @param {Number} A Number (1 to 53) that represents the week of the year. * @return {Date} this */ $P.setWeek = function (n) { if ((n - this.getWeek()) === 0) { if (this.getDay() !== 1) { return this.moveToDayOfWeek(1, (this.getDay() > 1 ? -1 : 1)); } else { return this; } } else { return this.moveToDayOfWeek(1, (this.getDay() > 1 ? -1 : 1)).addWeeks(n - this.getWeek()); } }; $P.setQuarter = function (qtr) { var month = Math.abs(((qtr-1) * 3) + 1); return this.setMonth(month, 1); }; $P.getQuarter = function () { return Date.getQuarter(this); }; $P.getDaysLeftInQuarter = function () { return Date.getDaysLeftInQuarter(this); }; /** * Moves the date to the next n'th occurrence of the dayOfWeek starting from the beginning of the month. The number (-1) is a magic number and will return the last occurrence of the dayOfWeek in the month. * @param {Number} The dayOfWeek to move to * @param {Number} The n'th occurrence to move to. Use (-1) to return the last occurrence in the month * @return {Date} this */ $P.moveToNthOccurrence = function (dayOfWeek, occurrence) { if (dayOfWeek === "Weekday") { if (occurrence > 0) { this.moveToFirstDayOfMonth(); if (this.is().weekday()) { occurrence -= 1; } } else if (occurrence < 0) { this.moveToLastDayOfMonth(); if (this.is().weekday()) { occurrence += 1; } } else { return this; } return this.addWeekdays(occurrence); } var shift = 0; if (occurrence > 0) { shift = occurrence - 1; } else if (occurrence === -1) { this.moveToLastDayOfMonth(); if (this.getDay() !== dayOfWeek) { this.moveToDayOfWeek(dayOfWeek, -1); } return this; } return this.moveToFirstDayOfMonth().addDays(-1).moveToDayOfWeek(dayOfWeek, +1).addWeeks(shift); }; var moveToN = function (getFunc, addFunc, nVal) { return function (value, orient) { var diff = (value - this[getFunc]() + nVal * (orient || +1)) % nVal; return this[addFunc]((diff === 0) ? diff += nVal * (orient || +1) : diff); }; }; /** * Move to the next or last dayOfWeek based on the orient value. * @param {Number} The dayOfWeek to move to * @param {Number} Forward (+1) or Back (-1). Defaults to +1. [Optional] * @return {Date} this */ $P.moveToDayOfWeek = moveToN("getDay", "addDays", 7); /** * Move to the next or last month based on the orient value. * @param {Number} The month to move to. 0 = January, 11 = December * @param {Number} Forward (+1) or Back (-1). Defaults to +1. [Optional] * @return {Date} this */ $P.moveToMonth = moveToN("getMonth", "addMonths", 12); /** * Get the Ordinate of the current day ("th", "st", "rd"). * @return {String} */ $P.getOrdinate = function () { var num = this.getDate(); return ord(num); }; /** * Get the Ordinal day (numeric day number) of the year, adjusted for leap year. * @return {Number} 1 through 365 (366 in leap years) */ $P.getOrdinalNumber = function () { return Math.ceil((this.clone().clearTime() - new Date(this.getFullYear(), 0, 1)) / 86400000) + 1; }; /** * Get the time zone abbreviation of the current date. * @return {String} The abbreviated time zone name (e.g. "EST") */ $P.getTimezone = function () { return $D.getTimezoneAbbreviation(this.getUTCOffset(), this.isDaylightSavingTime()); }; $P.setTimezoneOffset = function (offset) { var here = this.getTimezoneOffset(), there = Number(offset) * -6 / 10; return (there || there === 0) ? this.addMinutes(there - here) : this; }; $P.setTimezone = function (offset) { return this.setTimezoneOffset($D.getTimezoneOffset(offset)); }; /** * Indicates whether Daylight Saving Time is observed in the current time zone. * @return {Boolean} true|false */ $P.hasDaylightSavingTime = function () { return (Date.today().set({month: 0, day: 1}).getTimezoneOffset() !== Date.today().set({month: 6, day: 1}).getTimezoneOffset()); }; /** * Indicates whether this Date instance is within the Daylight Saving Time range for the current time zone. * @return {Boolean} true|false */ $P.isDaylightSavingTime = function () { return Date.today().set({month: 0, day: 1}).getTimezoneOffset() !== this.getTimezoneOffset(); }; /** * Get the offset from UTC of the current date. * @return {String} The 4-character offset string prefixed with + or - (e.g. "-0500") */ $P.getUTCOffset = function (offset) { var n = (offset || this.getTimezoneOffset()) * -10 / 6, r; if (n < 0) { r = (n - 10000).toString(); return r.charAt(0) + r.substr(2); } else { r = (n + 10000).toString(); return "+" + r.substr(1); } }; /** * Returns the number of milliseconds between this date and date. * @param {Date} Defaults to now * @return {Number} The diff in milliseconds */ $P.getElapsed = function (date) { return (date || new Date()) - this; }; /** * Set the value of year, month, day, hour, minute, second, millisecond of date instance using given configuration object. * Example

	Date.today().set( { day: 20, month: 1 } )

	new Date().set( { millisecond: 0 } )
	
* * @param {Object} Configuration object containing attributes (month, day, etc.) * @return {Date} this */ $P.set = function (config) { config = validateConfigObject.call(this, config); var key; for (key in config) { if (Object.prototype.hasOwnProperty.call(config, key)) { var name = key.charAt(0).toUpperCase() + key.slice(1); var addFunc, getFunc; if (key !== "week" && key !== "month" && key !== "timezone" && key !== "timezoneOffset") { name += "s"; } addFunc = "add" + name; getFunc = "get" + name; if (key === "month") { addFunc = addFunc + "s"; } else if (key === "year"){ getFunc = "getFullYear"; } if (key !== "day" && key !== "timezone" && key !== "timezoneOffset" && key !== "week" && key !== "hour") { this[addFunc](config[key] - this[getFunc]()); } else if ( key === "timezone"|| key === "timezoneOffset" || key === "week" || key === "hour") { this["set"+name](config[key]); } } } // day has to go last because you can't validate the day without first knowing the month if (config.day) { this.addDays(config.day - this.getDate()); } return this; }; /** * Moves the date to the first day of the month. * @return {Date} this */ $P.moveToFirstDayOfMonth = function () { return this.set({ day: 1 }); }; /** * Moves the date to the last day of the month. * @return {Date} this */ $P.moveToLastDayOfMonth = function () { return this.set({ day: $D.getDaysInMonth(this.getFullYear(), this.getMonth())}); }; /** * Converts the value of the current Date object to its equivalent string representation. * Format Specifiers * CUSTOM DATE AND TIME FORMAT STRINGS * Format Description Example * ------ --------------------------------------------------------------------------- ----------------------- * s The seconds of the minute between 0-59. "0" to "59" * ss The seconds of the minute with leading zero if required. "00" to "59" * * m The minute of the hour between 0-59. "0" or "59" * mm The minute of the hour with leading zero if required. "00" or "59" * * h The hour of the day between 1-12. "1" to "12" * hh The hour of the day with leading zero if required. "01" to "12" * * H The hour of the day between 0-23. "0" to "23" * HH The hour of the day with leading zero if required. "00" to "23" * * d The day of the month between 1 and 31. "1" to "31" * dd The day of the month with leading zero if required. "01" to "31" * ddd Abbreviated day name. Date.CultureInfo.abbreviatedDayNames. "Mon" to "Sun" * dddd The full day name. Date.CultureInfo.dayNames. "Monday" to "Sunday" * * M The month of the year between 1-12. "1" to "12" * MM The month of the year with leading zero if required. "01" to "12" * MMM Abbreviated month name. Date.CultureInfo.abbreviatedMonthNames. "Jan" to "Dec" * MMMM The full month name. Date.CultureInfo.monthNames. "January" to "December" * * yy The year as a two-digit number. "99" or "08" * yyyy The full four digit year. "1999" or "2008" * * t Displays the first character of the A.M./P.M. designator. "A" or "P" * Date.CultureInfo.amDesignator or Date.CultureInfo.pmDesignator * tt Displays the A.M./P.M. designator. "AM" or "PM" * Date.CultureInfo.amDesignator or Date.CultureInfo.pmDesignator * * S The ordinal suffix ("st, "nd", "rd" or "th") of the current day. "st, "nd", "rd" or "th" * * STANDARD DATE AND TIME FORMAT STRINGS * Format Description Example *------ --------------------------------------------------------------------------- ----------------------- * d The CultureInfo shortDate Format Pattern "M/d/yyyy" * D The CultureInfo longDate Format Pattern "dddd, MMMM dd, yyyy" * F The CultureInfo fullDateTime Format Pattern "dddd, MMMM dd, yyyy h:mm:ss tt" * m The CultureInfo monthDay Format Pattern "MMMM dd" * r The CultureInfo rfc1123 Format Pattern "ddd, dd MMM yyyy HH:mm:ss GMT" * s The CultureInfo sortableDateTime Format Pattern "yyyy-MM-ddTHH:mm:ss" * t The CultureInfo shortTime Format Pattern "h:mm tt" * T The CultureInfo longTime Format Pattern "h:mm:ss tt" * u The CultureInfo universalSortableDateTime Format Pattern "yyyy-MM-dd HH:mm:ssZ" * y The CultureInfo yearMonth Format Pattern "MMMM, yyyy" * * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @return {String} A string representation of the current Date object. */ var ord = function (n) { switch (n * 1) { case 1: case 21: case 31: return "st"; case 2: case 22: return "nd"; case 3: case 23: return "rd"; default: return "th"; } }; var parseStandardFormats = function (format) { var y, c = Date.CultureInfo.formatPatterns; switch (format) { case "d": return this.toString(c.shortDate); case "D": return this.toString(c.longDate); case "F": return this.toString(c.fullDateTime); case "m": return this.toString(c.monthDay); case "r": case "R": y = this.clone().addMinutes(this.getTimezoneOffset()); return y.toString(c.rfc1123) + " GMT"; case "s": return this.toString(c.sortableDateTime); case "t": return this.toString(c.shortTime); case "T": return this.toString(c.longTime); case "u": y = this.clone().addMinutes(this.getTimezoneOffset()); return y.toString(c.universalSortableDateTime); case "y": return this.toString(c.yearMonth); default: return false; } }; var parseFormatStringsClosure = function (context) { return function (m) { if (m.charAt(0) === "\\") { return m.replace("\\", ""); } switch (m) { case "hh": return p(context.getHours() < 13 ? (context.getHours() === 0 ? 12 : context.getHours()) : (context.getHours() - 12)); case "h": return context.getHours() < 13 ? (context.getHours() === 0 ? 12 : context.getHours()) : (context.getHours() - 12); case "HH": return p(context.getHours()); case "H": return context.getHours(); case "mm": return p(context.getMinutes()); case "m": return context.getMinutes(); case "ss": return p(context.getSeconds()); case "s": return context.getSeconds(); case "yyyy": return p(context.getFullYear(), 4); case "yy": return p(context.getFullYear()); case "y": return context.getFullYear(); case "E": case "dddd": return Date.CultureInfo.dayNames[context.getDay()]; case "ddd": return Date.CultureInfo.abbreviatedDayNames[context.getDay()]; case "dd": return p(context.getDate()); case "d": return context.getDate(); case "MMMM": return Date.CultureInfo.monthNames[context.getMonth()]; case "MMM": return Date.CultureInfo.abbreviatedMonthNames[context.getMonth()]; case "MM": return p((context.getMonth() + 1)); case "M": return context.getMonth() + 1; case "t": return context.getHours() < 12 ? Date.CultureInfo.amDesignator.substring(0, 1) : Date.CultureInfo.pmDesignator.substring(0, 1); case "tt": return context.getHours() < 12 ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator; case "S": return ord(context.getDate()); case "W": return context.getWeek(); case "WW": return context.getISOWeek(); case "Q": return "Q" + context.getQuarter(); case "q": return String(context.getQuarter()); case "z": return context.getTimezone(); case "Z": case "X": return Date.getTimezoneOffset(context.getTimezone()); case "ZZ": // Timezone offset in seconds return context.getTimezoneOffset() * -60; case "u": return context.getDay(); case "L": return ($D.isLeapYear(context.getFullYear())) ? 1 : 0; case "B": // Swatch Internet Time (.beats) return "@"+((context.getUTCSeconds() + (context.getUTCMinutes()*60) + ((context.getUTCHours()+1)*3600))/86.4); default: return m; } }; }; $P.toString = function (format, ignoreStandards) { // Standard Date and Time Format Strings. Formats pulled from CultureInfo file and // may vary by culture. if (!ignoreStandards && format && format.length === 1) { output = parseStandardFormats.call(this, format); if (output) { return output; } } var parseFormatStrings = parseFormatStringsClosure(this); return format ? format.replace(/((\\)?(dd?d?d?|MM?M?M?|yy?y?y?|hh?|HH?|mm?|ss?|tt?|S|q|Q|WW?W?W?)(?![^\[]*\]))/g, parseFormatStrings).replace(/\[|\]/g, "") : this._toString(); }; }()); /************************************************************* * SugarPak - Domain Specific Language - Syntactical Sugar * *************************************************************/ (function () { var $D = Date, $P = $D.prototype, $N = Number.prototype; // private $P._orient = +1; // private $P._nth = null; // private $P._is = false; // private $P._same = false; // private $P._isSecond = false; // private $N._dateElement = "days"; /** * Moves the date to the next instance of a date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.today().next().friday();
	Date.today().next().fri();
	Date.today().next().march();
	Date.today().next().mar();
	Date.today().next().week();
	
* * @return {Date} date */ $P.next = function () { this._move = true; this._orient = +1; return this; }; /** * Creates a new Date (Date.today()) and moves the date to the next instance of the date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.next().friday();
	Date.next().fri();
	Date.next().march();
	Date.next().mar();
	Date.next().week();
	
* * @return {Date} date */ $D.next = function () { return $D.today().next(); }; /** * Moves the date to the previous instance of a date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.today().last().friday();
	Date.today().last().fri();
	Date.today().last().march();
	Date.today().last().mar();
	Date.today().last().week();
	
* * @return {Date} date */ $P.last = $P.prev = $P.previous = function () { this._move = true; this._orient = -1; return this; }; /** * Creates a new Date (Date.today()) and moves the date to the previous instance of the date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.last().friday();
	Date.last().fri();
	Date.previous().march();
	Date.prev().mar();
	Date.last().week();
	
* * @return {Date} date */ $D.last = $D.prev = $D.previous = function () { return $D.today().last(); }; /** * Performs a equality check when followed by either a month name, day name or .weekday() function. * Example

	Date.today().is().friday(); // true|false
	Date.today().is().fri();
	Date.today().is().march();
	Date.today().is().mar();
	
* * @return {Boolean} true|false */ $P.is = function () { this._is = true; return this; }; /** * Determines if two date objects occur on/in exactly the same instance of the subsequent date part function. * The function .same() must be followed by a date part function (example: .day(), .month(), .year(), etc). * * An optional Date can be passed in the date part function. If now date is passed as a parameter, 'Now' is used. * * The following example demonstrates how to determine if two dates fall on the exact same day. * * Example

	var d1 = Date.today(); // today at 00:00
	var d2 = new Date();   // exactly now.

	// Do they occur on the same day?
	d1.same().day(d2); // true
	
	// Do they occur on the same hour?
	d1.same().hour(d2); // false, unless d2 hour is '00' (midnight).
	
	// What if it's the same day, but one year apart?
	var nextYear = Date.today().add(1).year();

	d1.same().day(nextYear); // false, because the dates must occur on the exact same day. 
	
* * Scenario: Determine if a given date occurs during some week period 2 months from now. * * Example

	var future = Date.today().add(2).months();
	return someDate.same().week(future); // true|false;
	
* * @return {Boolean} true|false */ $P.same = function () { this._same = true; this._isSecond = false; return this; }; /** * Determines if the current date/time occurs during Today. Must be preceded by the .is() function. * Example

	someDate.is().today();    // true|false
	new Date().is().today();  // true
	Date.today().is().today();// true
	Date.today().add(-1).day().is().today(); // false
	
* * @return {Boolean} true|false */ $P.today = function () { return this.same().day(); }; /** * Determines if the current date is a weekday. This function must be preceded by the .is() function. * Example

	Date.today().is().weekday(); // true|false
	
* * @return {Boolean} true|false */ $P.weekday = function () { if (this._nth) { return df("Weekday").call(this); } if (this._move) { return this.addWeekdays(this._orient); } if (this._is) { this._is = false; return (!this.is().sat() && !this.is().sun()); } return false; }; /** * Determines if the current date is on the weekend. This function must be preceded by the .is() function. * Example

	Date.today().is().weekend(); // true|false
	
* * @return {Boolean} true|false */ $P.weekend = function () { if (this._is) { this._is = false; return (this.is().sat() || this.is().sun()); } return false; }; /** * Sets the Time of the current Date instance. A string "6:15 pm" or config object {hour:18, minute:15} are accepted. * Example

	// Set time to 6:15pm with a String
	Date.today().at("6:15pm");

	// Set time to 6:15pm with a config object
	Date.today().at({hour:18, minute:15});
	
* * @return {Date} date */ $P.at = function (time) { return (typeof time === "string") ? $D.parse(this.toString("d") + " " + time) : this.set(time); }; /** * Creates a new Date() and adds this (Number) to the date based on the preceding date element function (eg. second|minute|hour|day|month|year). * Example

	// Undeclared Numbers must be wrapped with parentheses. Requirment of JavaScript.
	(3).days().fromNow();
	(6).months().fromNow();

	// Declared Number variables do not require parentheses. 
	var n = 6;
	n.months().fromNow();
	
* * @return {Date} A new Date instance */ $N.fromNow = $N.after = function (date) { var c = {}; c[this._dateElement] = this; return ((!date) ? new Date() : date.clone()).add(c); }; /** * Creates a new Date() and subtract this (Number) from the date based on the preceding date element function (eg. second|minute|hour|day|month|year). * Example

	// Undeclared Numbers must be wrapped with parentheses. Requirment of JavaScript.
	(3).days().ago();
	(6).months().ago();

	// Declared Number variables do not require parentheses. 
	var n = 6;
	n.months().ago();
	
* * @return {Date} A new Date instance */ $N.ago = $N.before = function (date) { var c = {}, s = (this._dateElement[this._dateElement.length-1] !== "s") ? this._dateElement + "s" : this._dateElement; c[s] = this * -1; return ((!date) ? new Date() : date.clone()).add(c); }; // Do NOT modify the following string tokens. These tokens are used to build dynamic functions. // All culture-specific strings can be found in the CultureInfo files. var dx = ("sunday monday tuesday wednesday thursday friday saturday").split(/\s/), mx = ("january february march april may june july august september october november december").split(/\s/), px = ("Millisecond Second Minute Hour Day Week Month Year Quarter Weekday").split(/\s/), pxf = ("Milliseconds Seconds Minutes Hours Date Week Month FullYear Quarter").split(/\s/), nth = ("final first second third fourth fifth").split(/\s/), de; /** * Returns an object literal of all the date parts. * Example

	var o = new Date().toObject();
	
	// { year: 2008, month: 4, week: 20, day: 13, hour: 18, minute: 9, second: 32, millisecond: 812 }
	
	// The object properties can be referenced directly from the object.
	
	alert(o.day);  // alerts "13"
	alert(o.year); // alerts "2008"
	
* * @return {Date} An object literal representing the original date object. */ $P.toObject = function () { var o = {}; for (var i = 0; i < px.length; i++) { if (this["get" + pxf[i]]) { o[px[i].toLowerCase()] = this["get" + pxf[i]](); } } return o; }; /** * Returns a date created from an object literal. Ignores the .week property if set in the config. * Example

	var o = new Date().toObject();
	
	return Date.fromObject(o); // will return the same date. 

	var o2 = {month: 1, day: 20, hour: 18}; // birthday party!
	Date.fromObject(o2);
	
* * @return {Date} An object literal representing the original date object. */ $D.fromObject = function(config) { config.week = null; return Date.today().set(config); }; // Create day name functions and abbreviated day name functions (eg. monday(), friday(), fri()). var df = function (n) { return function () { if (this._is) { this._is = false; return this.getDay() === n; } if (this._move) { this._move = null; } if (this._nth !== null) { // If the .second() function was called earlier, remove the _orient // from the date, and then continue. // This is required because 'second' can be used in two different context. // // Example // // Date.today().add(1).second(); // Date.march().second().monday(); // // Things get crazy with the following... // Date.march().add(1).second().second().monday(); // but it works!! // if (this._isSecond) { this.addSeconds(this._orient * -1); } // make sure we reset _isSecond this._isSecond = false; var ntemp = this._nth; this._nth = null; var temp = this.clone().moveToLastDayOfMonth(); this.moveToNthOccurrence(n, ntemp); if (this > temp) { throw new RangeError($D.getDayName(n) + " does not occur " + ntemp + " times in the month of " + $D.getMonthName(temp.getMonth()) + " " + temp.getFullYear() + "."); } return this; } return this.moveToDayOfWeek(n, this._orient); }; }; var sdf = function (n) { return function () { var t = $D.today(), shift = n - t.getDay(); if (n === 0 && Date.CultureInfo.firstDayOfWeek === 1 && t.getDay() !== 0) { shift = shift + 7; } return t.addDays(shift); }; }; // Create month name functions and abbreviated month name functions (eg. january(), march(), mar()). var month_instance_functions = function (n) { return function () { if (this._is) { this._is = false; return this.getMonth() === n; } return this.moveToMonth(n, this._orient); }; }; var month_static_functions = function (n) { return function () { return $D.today().set({ month: n, day: 1 }); }; }; var processTerms = function (names, staticFunc, instanceFunc) { for (var i = 0; i < names.length; i++) { // Create constant static Name variables. $D[names[i].toUpperCase()] = $D[names[i].toUpperCase().substring(0, 3)] = i; // Create Name functions. $D[names[i]] = $D[names[i].substring(0, 3)] = staticFunc(i); // Create Name instance functions. $P[names[i]] = $P[names[i].substring(0, 3)] = instanceFunc(i); } }; processTerms(dx, sdf, df); processTerms(mx, month_static_functions, month_instance_functions); // Create date element functions and plural date element functions used with Date (eg. day(), days(), months()). var ef = function (j) { return function () { // if the .second() function was called earlier, the _orient // has alread been added. Just return this and reset _isSecond. if (this._isSecond) { this._isSecond = false; return this; } if (this._same) { this._same = this._is = false; var o1 = this.toObject(), o2 = (arguments[0] || new Date()).toObject(), v = "", k = j.toLowerCase(); // the substr trick with -1 doesn't work in IE8 or less k = (k[k.length-1] === "s") ? k.substring(0,k.length-1) : k; for (var m = (px.length - 1); m > -1; m--) { v = px[m].toLowerCase(); if (o1[v] !== o2[v]) { return false; } if (k === v) { break; } } return true; } if (j.substring(j.length - 1) !== "s") { j += "s"; } if (this._move) { this._move = null; } return this["add" + j](this._orient); }; }; var nf = function (n) { return function () { this._dateElement = n; return this; }; }; for (var k = 0; k < px.length; k++) { de = px[k].toLowerCase(); if(de !== "weekday") { // Create date element functions and plural date element functions used with Date (eg. day(), days(), months()). $P[de] = $P[de + "s"] = ef(px[k]); // Create date element functions and plural date element functions used with Number (eg. day(), days(), months()). $N[de] = $N[de + "s"] = nf(de + "s"); } } $P._ss = ef("Second"); var nthfn = function (n) { return function (dayOfWeek) { if (this._same) { return this._ss(arguments[0]); } if (dayOfWeek || dayOfWeek === 0) { return this.moveToNthOccurrence(dayOfWeek, n); } this._nth = n; // if the operator is 'second' add the _orient, then deal with it later... if (n === 2 && (dayOfWeek === undefined || dayOfWeek === null)) { this._isSecond = true; return this.addSeconds(this._orient); } return this; }; }; for (var l = 0; l < nth.length; l++) { $P[nth[l]] = (l === 0) ? nthfn(-1) : nthfn(l); } }()); (function () { "use strict"; Date.Parsing = { Exception: function (s) { this.message = "Parse error at '" + s.substring(0, 10) + " ...'"; } }; var $P = Date.Parsing; var dayOffsets = { standard: [0,31,59,90,120,151,181,212,243,273,304,334], leap: [0,31,60,91,121,152,182,213,244,274,305,335] }; $P.isLeapYear = function(year) { return ((year % 4 === 0) && (year % 100 !== 0)) || (year % 400 === 0); }; var utils = { multiReplace : function (str, hash ) { var key; for (key in hash) { if (Object.prototype.hasOwnProperty.call(hash, key)) { var regex; if (typeof hash[key] === "function") { } else { regex = (hash[key] instanceof RegExp) ? hash[key] : new RegExp(hash[key], "g"); } str = str.replace(regex, key); } } return str; }, getDayOfYearFromWeek : function (obj) { var d, jan4, offset; obj.weekDay = (!obj.weekDay && obj.weekDay !== 0) ? 1 : obj.weekDay; d = new Date(obj.year, 0, 4); jan4 = d.getDay() === 0 ? 7 : d.getDay(); // JS is 0 indexed on Sunday. offset = jan4+3; obj.dayOfYear = ((obj.week * 7) + (obj.weekDay === 0 ? 7 : obj.weekDay))-offset; return obj; }, getDayOfYear : function (obj, dayOffset) { if (!obj.dayOfYear) { obj = utils.getDayOfYearFromWeek(obj); } for (var i=0;i <= dayOffset.length;i++) { if (obj.dayOfYear < dayOffset[i] || i === dayOffset.length) { obj.day = obj.day ? obj.day : (obj.dayOfYear - dayOffset[i-1]); break; } else { obj.month = i; } } return obj; }, adjustForTimeZone : function (obj, date) { var offset; if (obj.zone.toUpperCase() === "Z" || (obj.zone_hours === 0 && obj.zone_minutes === 0)) { // it's UTC/GML so work out the current timeszone offset offset = -date.getTimezoneOffset(); } else { offset = (obj.zone_hours*60) + (obj.zone_minutes || 0); if (obj.zone_sign === "+") { offset *= -1; } offset -= date.getTimezoneOffset(); } date.setMinutes(date.getMinutes()+offset); return date; }, setDefaults : function (obj) { obj.year = obj.year || Date.today().getFullYear(); obj.hours = obj.hours || 0; obj.minutes = obj.minutes || 0; obj.seconds = obj.seconds || 0; obj.milliseconds = obj.milliseconds || 0; if (!(!obj.month && (obj.week || obj.dayOfYear))) { // if we have a month, or if we don't but don't have the day calculation data obj.month = obj.month || 0; obj.day = obj.day || 1; } return obj; }, dataNum: function (data, mod, explict, postProcess) { var dataNum = data*1; if (mod) { if (postProcess) { return data ? mod(data)*1 : data; } else { return data ? mod(dataNum) : data; } } else if (!explict){ return data ? dataNum : data; } else { return (data && typeof data !== "undefined") ? dataNum : data; } }, timeDataProcess: function (obj) { var timeObj = {}; for (var x in obj.data) { if (obj.data.hasOwnProperty(x)) { timeObj[x] = obj.ignore[x] ? obj.data[x] : utils.dataNum(obj.data[x], obj.mods[x], obj.explict[x], obj.postProcess[x]); } } if (obj.data.secmins) { obj.data.secmins = obj.data.secmins.replace(",", ".") * 60; if (!timeObj.minutes) { timeObj.minutes = obj.data.secmins; } else if (!timeObj.seconds) { timeObj.seconds = obj.data.secmins; } delete obj.secmins; } return timeObj; }, buildTimeObjectFromData: function (data) { var time = utils.timeDataProcess({ data: { year : data[1], month : data[5], day : data[7], week : data[8], dayOfYear : data[10], hours : data[15], zone_hours : data[23], zone_minutes : data[24], zone : data[21], zone_sign : data[22], weekDay : data[9], minutes: data[16], seconds: data[19], milliseconds: data[20], secmins: data[18] }, mods: { month: function(data) { return data-1; }, weekDay: function (data) { data = Math.abs(data); return (data === 7 ? 0 : data); }, minutes: function (data) { return data.replace(":",""); }, seconds: function (data) { return Math.floor( (data.replace(":","").replace(",","."))*1 ); }, milliseconds: function (data) { return (data.replace(",",".")*1000); } }, postProcess: { minutes: true, seconds: true, milliseconds: true }, explict: { zone_hours: true, zone_minutes: true }, ignore: { zone: true, zone_sign: true, secmins: true } }); return time; }, addToHash: function (hash, keys, data) { keys = keys; data = data; var len = keys.length; for (var i = 0; i < len; i++) { hash[keys[i]] = data[i]; } return hash; }, combineRegex: function (r1, r2) { return new RegExp("(("+r1.source+")\\s("+r2.source+"))"); }, getDateNthString: function(add, last, inc){ if (add) { return Date.today().addDays(inc).toString("d"); } else if (last) { return Date.today().last()[inc]().toString("d"); } }, buildRegexData: function (array) { var arr = []; var len = array.length; for (var i=0; i < len; i++) { if (Object.prototype.toString.call(array[i]) === '[object Array]') { // oldIE compat version of Array.isArray arr.push(this.combineRegex(array[i][0], array[i][1])); } else { arr.push(array[i]); } } return arr; } }; $P.processTimeObject = function (obj) { var date, dayOffset; utils.setDefaults(obj); dayOffset = ($P.isLeapYear(obj.year)) ? dayOffsets.leap : dayOffsets.standard; if (!obj.month && (obj.week || obj.dayOfYear)) { utils.getDayOfYear(obj, dayOffset); } else { obj.dayOfYear = dayOffset[obj.month] + obj.day; } date = new Date(obj.year, obj.month, obj.day, obj.hours, obj.minutes, obj.seconds, obj.milliseconds); if (obj.zone) { utils.adjustForTimeZone(obj, date); // adjust (and calculate) for timezone } return date; }; $P.ISO = { regex : /^([\+-]?\d{4}(?!\d{2}\b))((-?)((0[1-9]|1[0-2])(\3([12]\d|0[1-9]|3[01]))?|W([0-4]\d|5[0-3])(-?[1-7])?|(00[1-9]|0[1-9]\d|[12]\d{2}|3([0-5]\d|6[1-6])))([T\s]((([01]\d|2[0-4])((:?)[0-5]\d)?|24\:?00)([\.,]\d+(?!:))?)?(\17[0-5]\d([\.,]\d+)?)?\s?([zZ]|([\+-])([01]\d|2[0-3]):?([0-5]\d)?)?)?)?$/, parse : function (s) { var time, data = s.match(this.regex); if (!data || !data.length) { return null; } time = utils.buildTimeObjectFromData(data); if (!time.year || (!time.year && (!time.month && !time.day) && (!time.week && !time.dayOfYear)) ) { return null; } return $P.processTimeObject(time); } }; $P.Numeric = { isNumeric: function (e){return!isNaN(parseFloat(e))&&isFinite(e);}, regex: /\b([0-1]?[0-9])([0-3]?[0-9])([0-2]?[0-9]?[0-9][0-9])\b/i, parse: function (s) { var data, i, time = {}, order = Date.CultureInfo.dateElementOrder.split(""); if (!(this.isNumeric(s)) || // if it's non-numeric OR (s[0] === "+" && s[0] === "-")) { // It's an arithmatic string (eg +/-1000) return null; } if (s.length < 5 && s.indexOf(".") < 0 && s.indexOf("/") < 0) { // assume it's just a year. time.year = s; return $P.processTimeObject(time); } data = s.match(this.regex); if (!data || !data.length) { return null; } for (i=0; i < order.length; i++) { switch(order[i]) { case "d": time.day = data[i+1]; break; case "m": time.month = (data[i+1]-1); break; case "y": time.year = data[i+1]; break; } } return $P.processTimeObject(time); } }; $P.Normalizer = { regexData: function () { var $R = Date.CultureInfo.regexPatterns; return utils.buildRegexData([ $R.tomorrow, $R.yesterday, [$R.past, $R.mon], [$R.past, $R.tue], [$R.past, $R.wed], [$R.past, $R.thu], [$R.past, $R.fri], [$R.past, $R.sat], [$R.past, $R.sun] ]); }, basicReplaceHash : function() { var $R = Date.CultureInfo.regexPatterns; return { "January": $R.jan.source, "February": $R.feb, "March": $R.mar, "April": $R.apr, "May": $R.may, "June": $R.jun, "July": $R.jul, "August": $R.aug, "September": $R.sep, "October": $R.oct, "November": $R.nov, "December": $R.dec, "": /\bat\b/gi, " ": /\s{2,}/, "am": $R.inTheMorning, "9am": $R.thisMorning, "pm": $R.inTheEvening, "7pm":$R.thisEvening }; }, keys : function(){ return [ utils.getDateNthString(true, false, 1), // tomorrow utils.getDateNthString(true, false, -1), // yesterday utils.getDateNthString(false, true, "monday"), //last mon utils.getDateNthString(false, true, "tuesday"), //last tues utils.getDateNthString(false, true, "wednesday"), //last wed utils.getDateNthString(false, true, "thursday"), //last thurs utils.getDateNthString(false, true, "friday"), //last fri utils.getDateNthString(false, true, "saturday"), //last sat utils.getDateNthString(false, true, "sunday") //last sun ]; }, buildRegexFunctions: function () { var $R = Date.CultureInfo.regexPatterns; var __ = Date.i18n.__; var tomorrowRE = new RegExp("(\\b\\d\\d?("+__("AM")+"|"+__("PM")+")? )("+$R.tomorrow.source.slice(1)+")", "i"); // adapted tomorrow regex for AM PM relative dates var todayRE = new RegExp($R.today.source + "(?!\\s*([+-]))\\b"); // today, but excludes the math operators (eg "today + 2h") this.replaceFuncs = [ [todayRE, function (full) { return (full.length > 1) ? Date.today().toString("d") : full; }], [tomorrowRE, function(full, m1) { var t = Date.today().addDays(1).toString("d"); return (t + " " + m1); }], [$R.amThisMorning, function(str, am){return am;}], [$R.pmThisEvening, function(str, pm){return pm;}] ]; }, buildReplaceData: function () { this.buildRegexFunctions(); this.replaceHash = utils.addToHash(this.basicReplaceHash(), this.keys(), this.regexData()); }, stringReplaceFuncs: function (s) { for (var i=0; i < this.replaceFuncs.length; i++) { s = s.replace(this.replaceFuncs[i][0], this.replaceFuncs[i][1]); } return s; }, parse: function (s) { s = this.stringReplaceFuncs(s); s = utils.multiReplace(s, this.replaceHash); try { var n = s.split(/([\s\-\.\,\/\x27]+)/); if (n.length === 3 && $P.Numeric.isNumeric(n[0]) && $P.Numeric.isNumeric(n[2]) && (n[2].length >= 4)) { // ok, so we're dealing with x/year. But that's not a full date. // This fixes wonky dateElementOrder parsing when set to dmy order. if (Date.CultureInfo.dateElementOrder[0] === "d") { s = "1/" + n[0] + "/" + n[2]; // set to 1st of month and normalize the seperator } } } catch (e) {} return s; } }; $P.Normalizer.buildReplaceData(); }()); (function () { var $P = Date.Parsing; var _ = $P.Operators = { // // Tokenizers // rtoken: function (r) { // regex token return function (s) { var mx = s.match(r); if (mx) { return ([ mx[0], s.substring(mx[0].length) ]); } else { throw new $P.Exception(s); } }; }, token: function () { // whitespace-eating token return function (s) { return _.rtoken(new RegExp("^\\s*" + s + "\\s*"))(s); }; }, stoken: function (s) { // string token return _.rtoken(new RegExp("^" + s)); }, // Atomic Operators until: function (p) { return function (s) { var qx = [], rx = null; while (s.length) { try { rx = p.call(this, s); } catch (e) { qx.push(rx[0]); s = rx[1]; continue; } break; } return [ qx, s ]; }; }, many: function (p) { return function (s) { var rx = [], r = null; while (s.length) { try { r = p.call(this, s); } catch (e) { return [ rx, s ]; } rx.push(r[0]); s = r[1]; } return [ rx, s ]; }; }, // generator operators -- see below optional: function (p) { return function (s) { var r = null; try { r = p.call(this, s); } catch (e) { return [ null, s ]; } return [ r[0], r[1] ]; }; }, not: function (p) { return function (s) { try { p.call(this, s); } catch (e) { return [null, s]; } throw new $P.Exception(s); }; }, ignore: function (p) { return p ? function (s) { var r = null; r = p.call(this, s); return [null, r[1]]; } : null; }, product: function () { var px = arguments[0], qx = Array.prototype.slice.call(arguments, 1), rx = []; for (var i = 0 ; i < px.length ; i++) { rx.push(_.each(px[i], qx)); } return rx; }, cache: function (rule) { var cache = {}, cache_length = 0, cache_keys = [], CACHE_MAX = Date.Config.CACHE_MAX || 100000, r = null; var cacheCheck = function () { if (cache_length === CACHE_MAX) { // kill several keys, don't want to have to do this all the time... for (var i=0; i < 10; i++) { var key = cache_keys.shift(); if (key) { delete cache[key]; cache_length--; } } } }; return function (s) { cacheCheck(); try { r = cache[s] = (cache[s] || rule.call(this, s)); } catch (e) { r = cache[s] = e; } cache_length++; cache_keys.push(s); if (r instanceof $P.Exception) { throw r; } else { return r; } }; }, // vector operators -- see below any: function () { var px = arguments; return function (s) { var r = null; for (var i = 0; i < px.length; i++) { if (px[i] == null) { continue; } try { r = (px[i].call(this, s)); } catch (e) { r = null; } if (r) { return r; } } throw new $P.Exception(s); }; }, each: function () { var px = arguments; return function (s) { var rx = [], r = null; for (var i = 0; i < px.length ; i++) { if (px[i] == null) { continue; } try { r = (px[i].call(this, s)); } catch (e) { throw new $P.Exception(s); } rx.push(r[0]); s = r[1]; } return [ rx, s]; }; }, all: function () { var px = arguments, _ = _; return _.each(_.optional(px)); }, // delimited operators sequence: function (px, d, c) { d = d || _.rtoken(/^\s*/); c = c || null; if (px.length === 1) { return px[0]; } return function (s) { var r = null, q = null; var rx = []; for (var i = 0; i < px.length ; i++) { try { r = px[i].call(this, s); } catch (e) { break; } rx.push(r[0]); try { q = d.call(this, r[1]); } catch (ex) { q = null; break; } s = q[1]; } if (!r) { throw new $P.Exception(s); } if (q) { throw new $P.Exception(q[1]); } if (c) { try { r = c.call(this, r[1]); } catch (ey) { throw new $P.Exception(r[1]); } } return [ rx, (r?r[1]:s) ]; }; }, // // Composite Operators // between: function (d1, p, d2) { d2 = d2 || d1; var _fn = _.each(_.ignore(d1), p, _.ignore(d2)); return function (s) { var rx = _fn.call(this, s); return [[rx[0][0], r[0][2]], rx[1]]; }; }, list: function (p, d, c) { d = d || _.rtoken(/^\s*/); c = c || null; return (p instanceof Array ? _.each(_.product(p.slice(0, -1), _.ignore(d)), p.slice(-1), _.ignore(c)) : _.each(_.many(_.each(p, _.ignore(d))), px, _.ignore(c))); }, set: function (px, d, c) { d = d || _.rtoken(/^\s*/); c = c || null; return function (s) { // r is the current match, best the current 'best' match // which means it parsed the most amount of input var r = null, p = null, q = null, rx = null, best = [[], s], last = false; // go through the rules in the given set for (var i = 0; i < px.length ; i++) { // last is a flag indicating whether this must be the last element // if there is only 1 element, then it MUST be the last one q = null; p = null; r = null; last = (px.length === 1); // first, we try simply to match the current pattern // if not, try the next pattern try { r = px[i].call(this, s); } catch (e) { continue; } // since we are matching against a set of elements, the first // thing to do is to add r[0] to matched elements rx = [[r[0]], r[1]]; // if we matched and there is still input to parse and // we don't already know this is the last element, // we're going to next check for the delimiter ... // if there's none, or if there's no input left to parse // than this must be the last element after all ... if (r[1].length > 0 && ! last) { try { q = d.call(this, r[1]); } catch (ex) { last = true; } } else { last = true; } // if we parsed the delimiter and now there's no more input, // that means we shouldn't have parsed the delimiter at all // so don't update r and mark this as the last element ... if (!last && q[1].length === 0) { last = true; } // so, if this isn't the last element, we're going to see if // we can get any more matches from the remaining (unmatched) // elements ... if (!last) { // build a list of the remaining rules we can match against, // i.e., all but the one we just matched against var qx = []; for (var j = 0; j < px.length ; j++) { if (i !== j) { qx.push(px[j]); } } // now invoke recursively set with the remaining input // note that we don't include the closing delimiter ... // we'll check for that ourselves at the end p = _.set(qx, d).call(this, q[1]); // if we got a non-empty set as a result ... // (otw rx already contains everything we want to match) if (p[0].length > 0) { // update current result, which is stored in rx ... // basically, pick up the remaining text from p[1] // and concat the result from p[0] so that we don't // get endless nesting ... rx[0] = rx[0].concat(p[0]); rx[1] = p[1]; } } // at this point, rx either contains the last matched element // or the entire matched set that starts with this element. // now we just check to see if this variation is better than // our best so far, in terms of how much of the input is parsed if (rx[1].length < best[1].length) { best = rx; } // if we've parsed all the input, then we're finished if (best[1].length === 0) { break; } } // so now we've either gone through all the patterns trying them // as the initial match; or we found one that parsed the entire // input string ... // if best has no matches, just return empty set ... if (best[0].length === 0) { return best; } // if a closing delimiter is provided, then we have to check it also if (c) { // we try this even if there is no remaining input because the pattern // may well be optional or match empty input ... try { q = c.call(this, best[1]); } catch (ey) { throw new $P.Exception(best[1]); } // it parsed ... be sure to update the best match remaining input best[1] = q[1]; } // if we're here, either there was no closing delimiter or we parsed it // so now we have the best match; just return it! return best; }; }, forward: function (gr, fname) { return function (s) { return gr[fname].call(this, s); }; }, // // Translation Operators // replace: function (rule, repl) { return function (s) { var r = rule.call(this, s); return [repl, r[1]]; }; }, process: function (rule, fn) { return function (s) { var r = rule.call(this, s); return [fn.call(this, r[0]), r[1]]; }; }, min: function (min, rule) { return function (s) { var rx = rule.call(this, s); if (rx[0].length < min) { throw new $P.Exception(s); } return rx; }; } }; // Generator Operators And Vector Operators // Generators are operators that have a signature of F(R) => R, // taking a given rule and returning another rule, such as // ignore, which parses a given rule and throws away the result. // Vector operators are those that have a signature of F(R1,R2,...) => R, // take a list of rules and returning a new rule, such as each. // Generator operators are converted (via the following _generator // function) into functions that can also take a list or array of rules // and return an array of new rules as though the function had been // called on each rule in turn (which is what actually happens). // This allows generators to be used with vector operators more easily. // Example: // each(ignore(foo, bar)) instead of each(ignore(foo), ignore(bar)) // This also turns generators into vector operators, which allows // constructs like: // not(cache(foo, bar)) var _generator = function (op) { function gen() { var args = null, rx = [], px, i; if (arguments.length > 1) { args = Array.prototype.slice.call(arguments); } else if (arguments[0] instanceof Array) { args = arguments[0]; } if (args) { px = args.shift(); if (px.length > 0) { args.unshift(px[i]); rx.push(op.apply(null, args)); args.shift(); return rx; } } else { return op.apply(null, arguments); } } return gen; }; var gx = "optional not ignore cache".split(/\s/); for (var i = 0 ; i < gx.length ; i++) { _[gx[i]] = _generator(_[gx[i]]); } var _vector = function (op) { return function () { if (arguments[0] instanceof Array) { return op.apply(null, arguments[0]); } else { return op.apply(null, arguments); } }; }; var vx = "each any all".split(/\s/); for (var j = 0 ; j < vx.length ; j++) { _[vx[j]] = _vector(_[vx[j]]); } }()); (function () { var $D = Date; var flattenAndCompact = function (ax) { var rx = []; for (var i = 0; i < ax.length; i++) { if (ax[i] instanceof Array) { rx = rx.concat(flattenAndCompact(ax[i])); } else { if (ax[i]) { rx.push(ax[i]); } } } return rx; }; var parseMeridian = function () { if (this.meridian && (this.hour || this.hour === 0)) { if (this.meridian === "a" && this.hour > 11 && Date.Config.strict24hr){ throw "Invalid hour and meridian combination"; } else if (this.meridian === "p" && this.hour < 12 && Date.Config.strict24hr){ throw "Invalid hour and meridian combination"; } else if (this.meridian === "p" && this.hour < 12) { this.hour = this.hour + 12; } else if (this.meridian === "a" && this.hour === 12) { this.hour = 0; } } }; var setDefaults = function () { var now = new Date(); if ((this.hour || this.minute) && (!this.month && !this.year && !this.day)) { this.day = now.getDate(); } if (!this.year) { this.year = now.getFullYear(); } if (!this.month && this.month !== 0) { this.month = now.getMonth(); } if (!this.day) { this.day = 1; } if (!this.hour) { this.hour = 0; } if (!this.minute) { this.minute = 0; } if (!this.second) { this.second = 0; } if (!this.millisecond) { this.millisecond = 0; } }; var finishUtils = { getToday: function () { if (this.now || "hour minute second".indexOf(this.unit) !== -1) { return new Date(); } else { return $D.today(); } }, setDaysFromWeekday: function (today, orient){ var gap; orient = orient || 1; this.unit = "day"; gap = ($D.getDayNumberFromName(this.weekday) - today.getDay()); this.days = gap ? ((gap + (orient * 7)) % 7) : (orient * 7); return this; }, setMonthsFromMonth: function (today, orient) { var gap; orient = orient || 1; this.unit = "month"; gap = (this.month - today.getMonth()); this.months = gap ? ((gap + (orient * 12)) % 12) : (orient * 12); this.month = null; return this; }, setDMYFromWeekday: function () { var d = Date[this.weekday](); this.day = d.getDate(); if (!this.month) { this.month = d.getMonth(); } this.year = d.getFullYear(); return this; }, setUnitValue: function (orient) { if (!this.value && this.operator && this.operator !== null && this[this.unit + "s"] && this[this.unit + "s"] !== null) { this[this.unit + "s"] = this[this.unit + "s"] + ((this.operator === "add") ? 1 : -1) + (this.value||0) * orient; } else if (this[this.unit + "s"] == null || this.operator != null) { if (!this.value) { this.value = 1; } this[this.unit + "s"] = this.value * orient; } }, generateDateFromWeeks: function () { var weekday = (this.weekday !== undefined) ? this.weekday : "today"; var d = Date[weekday]().addWeeks(this.weeks); if (this.now) { d.setTimeToNow(); } return d; } }; $D.Translator = { hour: function (s) { return function () { this.hour = Number(s); }; }, minute: function (s) { return function () { this.minute = Number(s); }; }, second: function (s) { return function () { this.second = Number(s); }; }, /* for ss.s format */ secondAndMillisecond: function (s) { return function () { var mx = s.match(/^([0-5][0-9])\.([0-9]{1,3})/); this.second = Number(mx[1]); this.millisecond = Number(mx[2]); }; }, meridian: function (s) { return function () { this.meridian = s.slice(0, 1).toLowerCase(); }; }, timezone: function (s) { return function () { var n = s.replace(/[^\d\+\-]/g, ""); if (n.length) { this.timezoneOffset = Number(n); } else { this.timezone = s.toLowerCase(); } }; }, day: function (x) { var s = x[0]; return function () { this.day = Number(s.match(/\d+/)[0]); if (this.day < 1) { throw "invalid day"; } }; }, month: function (s) { return function () { this.month = (s.length === 3) ? "jan feb mar apr may jun jul aug sep oct nov dec".indexOf(s)/4 : Number(s) - 1; if (this.month < 0) { throw "invalid month"; } }; }, year: function (s) { return function () { var n = Number(s); this.year = ((s.length > 2) ? n : (n + (((n + 2000) < Date.CultureInfo.twoDigitYearMax) ? 2000 : 1900))); }; }, rday: function (s) { return function () { switch (s) { case "yesterday": this.days = -1; break; case "tomorrow": this.days = 1; break; case "today": this.days = 0; break; case "now": this.days = 0; this.now = true; break; } }; }, finishExact: function (x) { var d; x = (x instanceof Array) ? x : [x]; for (var i = 0 ; i < x.length ; i++) { if (x[i]) { x[i].call(this); } } setDefaults.call(this); parseMeridian.call(this); if (this.day > $D.getDaysInMonth(this.year, this.month)) { throw new RangeError(this.day + " is not a valid value for days."); } d = new Date(this.year, this.month, this.day, this.hour, this.minute, this.second, this.millisecond); if (this.year < 100) { d.setFullYear(this.year); // means years less that 100 are process correctly. JS will parse it otherwise as 1900-1999. } if (this.timezone) { d.set({ timezone: this.timezone }); } else if (this.timezoneOffset) { d.set({ timezoneOffset: this.timezoneOffset }); } return d; }, finish: function (x) { var today, expression, orient, temp; x = (x instanceof Array) ? flattenAndCompact(x) : [ x ]; if (x.length === 0) { return null; } for (var i = 0 ; i < x.length ; i++) { if (typeof x[i] === "function") { x[i].call(this); } } if (this.now && !this.unit && !this.operator) { return new Date(); } else { today = finishUtils.getToday.call(this); } expression = !!(this.days && this.days !== null || this.orient || this.operator); orient = ((this.orient === "past" || this.operator === "subtract") ? -1 : 1); if (this.month && this.unit === "week") { this.value = this.month + 1; delete this.month; delete this.day; } if ((this.month || this.month === 0) && "year day hour minute second".indexOf(this.unit) !== -1) { if (!this.value) { this.value = this.month + 1; } this.month = null; expression = true; } if (!expression && this.weekday && !this.day && !this.days) { finishUtils.setDMYFromWeekday.call(this); } if (expression && this.weekday && this.unit !== "month" && this.unit !== "week") { finishUtils.setDaysFromWeekday.call(this, today, orient); } if (this.weekday && this.unit !== "week" && !this.day && !this.days) { temp = Date[this.weekday](); this.day = temp.getDate(); if (temp.getMonth() !== today.getMonth()) { this.month = temp.getMonth(); } } if (this.month && this.unit === "day" && this.operator) { if (!this.value) { this.value = (this.month + 1); } this.month = null; } if (this.value != null && this.month != null && this.year != null) { this.day = this.value * 1; } if (this.month && !this.day && this.value) { today.set({ day: this.value * 1 }); if (!expression) { this.day = this.value * 1; } } if (!this.month && this.value && this.unit === "month" && !this.now) { this.month = this.value; expression = true; } if (expression && (this.month || this.month === 0) && this.unit !== "year") { finishUtils.setMonthsFromMonth.call(this, today, orient); } if (!this.unit) { this.unit = "day"; } finishUtils.setUnitValue.call(this, orient); parseMeridian.call(this); if ((this.month || this.month === 0) && !this.day) { this.day = 1; } if (!this.orient && !this.operator && this.unit === "week" && this.value && !this.day && !this.month) { return Date.today().setWeek(this.value); } if (this.unit === "week" && this.weeks && !this.day && !this.month) { return finishUtils.generateDateFromWeeks.call(this); } if (expression && this.timezone && this.day && this.days) { this.day = this.days; } if (expression){ today.add(this); } else { today.set(this); } if (this.timezone) { this.timezone = this.timezone.toUpperCase(); var offset = $D.getTimezoneOffset(this.timezone); var timezone; if (today.hasDaylightSavingTime()) { // lets check that we're being sane with timezone setting timezone = $D.getTimezoneAbbreviation(offset, today.isDaylightSavingTime()); if (timezone !== this.timezone) { // bugger, we're in a place where things like EST vs EDT matters. if (today.isDaylightSavingTime()) { today.addHours(-1); } else { today.addHours(1); } } } today.setTimezoneOffset(offset); } return today; } }; }()); (function () { var $D = Date; $D.Grammar = {}; var _ = $D.Parsing.Operators, g = $D.Grammar, t = $D.Translator, _fn; // Allow rolling up into general purpose rules _fn = function () { return _.each(_.any.apply(null, arguments), _.not(g.ctoken2("timeContext"))); }; g.datePartDelimiter = _.rtoken(/^([\s\-\.\,\/\x27]+)/); g.timePartDelimiter = _.stoken(":"); g.whiteSpace = _.rtoken(/^\s*/); g.generalDelimiter = _.rtoken(/^(([\s\,]|at|@|on)+)/); var _C = {}; g.ctoken = function (keys) { var fn = _C[keys]; if (! fn) { var c = Date.CultureInfo.regexPatterns; var kx = keys.split(/\s+/), px = []; for (var i = 0; i < kx.length ; i++) { px.push(_.replace(_.rtoken(c[kx[i]]), kx[i])); } fn = _C[keys] = _.any.apply(null, px); } return fn; }; g.ctoken2 = function (key) { return _.rtoken(Date.CultureInfo.regexPatterns[key]); }; var cacheProcessRtoken = function (key, token, type, eachToken) { if (eachToken) { g[key] = _.cache(_.process(_.each(_.rtoken(token),_.optional(g.ctoken2(eachToken))), type)); } else { g[key] = _.cache(_.process(_.rtoken(token), type)); } }; var cacheProcessCtoken = function (token, type) { return _.cache(_.process(g.ctoken2(token), type)); }; var _F = {}; //function cache var _get = function (f) { _F[f] = (_F[f] || g.format(f)[0]); return _F[f]; }; g.allformats = function (fx) { var rx = []; if (fx instanceof Array) { for (var i = 0; i < fx.length; i++) { rx.push(_get(fx[i])); } } else { rx.push(_get(fx)); } return rx; }; g.formats = function (fx) { if (fx instanceof Array) { var rx = []; for (var i = 0 ; i < fx.length ; i++) { rx.push(_get(fx[i])); } return _.any.apply(null, rx); } else { return _get(fx); } }; var grammarFormats = { timeFormats: function(){ var i, RTokenKeys = [ "h", "hh", "H", "HH", "m", "mm", "s", "ss", "ss.s", "z", "zz" ], RToken = [ /^(0[0-9]|1[0-2]|[1-9])/, /^(0[0-9]|1[0-2])/, /^([0-1][0-9]|2[0-3]|[0-9])/, /^([0-1][0-9]|2[0-3])/, /^([0-5][0-9]|[0-9])/, /^[0-5][0-9]/, /^([0-5][0-9]|[0-9])/, /^[0-5][0-9]/, /^[0-5][0-9]\.[0-9]{1,3}/, /^((\+|\-)\s*\d\d\d\d)|((\+|\-)\d\d\:?\d\d)/, /^((\+|\-)\s*\d\d\d\d)|((\+|\-)\d\d\:?\d\d)/ ], tokens = [ t.hour, t.hour, t.hour, t.hour, t.minute, t.minute, t.second, t.second, t.secondAndMillisecond, t.timezone, t.timezone ]; for (i=0; i < RTokenKeys.length; i++) { cacheProcessRtoken(RTokenKeys[i], RToken[i], tokens[i]); } g.hms = _.cache(_.sequence([g.H, g.m, g.s], g.timePartDelimiter)); g.t = cacheProcessCtoken("shortMeridian", t.meridian); g.tt = cacheProcessCtoken("longMeridian", t.meridian); g.zzz = cacheProcessCtoken("timezone", t.timezone); g.timeSuffix = _.each(_.ignore(g.whiteSpace), _.set([ g.tt, g.zzz ])); g.time = _.each(_.optional(_.ignore(_.stoken("T"))), g.hms, g.timeSuffix); }, dateFormats: function () { // pre-loaded rules for different date part order preferences var _setfn = function () { return _.set(arguments, g.datePartDelimiter); }; var i, RTokenKeys = [ "d", "dd", "M", "MM", "y", "yy", "yyy", "yyyy" ], RToken = [ /^([0-2]\d|3[0-1]|\d)/, /^([0-2]\d|3[0-1])/, /^(1[0-2]|0\d|\d)/, /^(1[0-2]|0\d)/, /^(\d+)/, /^(\d\d)/, /^(\d\d?\d?\d?)/, /^(\d\d\d\d)/ ], tokens = [ t.day, t.day, t.month, t.month, t.year, t.year, t.year, t.year ], eachToken = [ "ordinalSuffix", "ordinalSuffix" ]; for (i=0; i < RTokenKeys.length; i++) { cacheProcessRtoken(RTokenKeys[i], RToken[i], tokens[i], eachToken[i]); } g.MMM = g.MMMM = _.cache(_.process(g.ctoken("jan feb mar apr may jun jul aug sep oct nov dec"), t.month)); g.ddd = g.dddd = _.cache(_.process(g.ctoken("sun mon tue wed thu fri sat"), function (s) { return function () { this.weekday = s; }; } )); g.day = _fn(g.d, g.dd); g.month = _fn(g.M, g.MMM); g.year = _fn(g.yyyy, g.yy); g.mdy = _setfn(g.ddd, g.month, g.day, g.year); g.ymd = _setfn(g.ddd, g.year, g.month, g.day); g.dmy = _setfn(g.ddd, g.day, g.month, g.year); g.date = function (s) { return ((g[Date.CultureInfo.dateElementOrder] || g.mdy).call(this, s)); }; }, relative: function () { // relative date / time expressions g.orientation = _.process(g.ctoken("past future"), function (s) { return function () { this.orient = s; }; } ); g.operator = _.process(g.ctoken("add subtract"), function (s) { return function () { this.operator = s; }; } ); g.rday = _.process(g.ctoken("yesterday tomorrow today now"), t.rday); g.unit = _.process(g.ctoken("second minute hour day week month year"), function (s) { return function () { this.unit = s; }; } ); } }; g.buildGrammarFormats = function () { // these need to be rebuilt every time the language changes. _C = {}; grammarFormats.timeFormats(); grammarFormats.dateFormats(); grammarFormats.relative(); g.value = _.process(_.rtoken(/^([-+]?\d+)?(st|nd|rd|th)?/), function (s) { return function () { this.value = s.replace(/\D/g, ""); }; } ); g.expression = _.set([g.rday, g.operator, g.value, g.unit, g.orientation, g.ddd, g.MMM ]); g.format = _.process(_.many( _.any( // translate format specifiers into grammar rules _.process( _.rtoken(/^(dd?d?d?(?!e)|MM?M?M?|yy?y?y?|hh?|HH?|mm?|ss?|tt?|zz?z?)/), function (fmt) { if (g[fmt]) { return g[fmt]; } else { throw $D.Parsing.Exception(fmt); } } ), // translate separator tokens into token rules _.process(_.rtoken(/^[^dMyhHmstz]+/), // all legal separators function (s) { return _.ignore(_.stoken(s)); } ) ) ), // construct the parser ... function (rules) { return _.process(_.each.apply(null, rules), t.finishExact); } ); // starting rule for general purpose grammar g._start = _.process(_.set([ g.date, g.time, g.expression ], g.generalDelimiter, g.whiteSpace), t.finish); }; g.buildGrammarFormats(); // parsing date format specifiers - ex: "h:m:s tt" // this little guy will generate a custom parser based // on the format string, ex: g.format("h:m:s tt") // check for these formats first g._formats = g.formats([ "\"yyyy-MM-ddTHH:mm:ssZ\"", "yyyy-MM-ddTHH:mm:ss.sz", "yyyy-MM-ddTHH:mm:ssZ", "yyyy-MM-ddTHH:mm:ssz", "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-ddTHH:mmZ", "yyyy-MM-ddTHH:mmz", "yyyy-MM-ddTHH:mm", "ddd, MMM dd, yyyy H:mm:ss tt", "ddd MMM d yyyy HH:mm:ss zzz", "MMddyyyy", "ddMMyyyy", "Mddyyyy", "ddMyyyy", "Mdyyyy", "dMyyyy", "yyyy", "Mdyy", "dMyy", "d" ]); // real starting rule: tries selected formats first, // then general purpose rule g.start = function (s) { try { var r = g._formats.call({}, s); if (r[1].length === 0) { return r; } } catch (e) {} return g._start.call({}, s); }; }()); (function () { var $D = Date; /** * @desc Converts the specified string value into its JavaScript Date equivalent using CultureInfo specific format information. * * Example

	///////////
	// Dates //
	///////////

	// 15-Oct-2004
	var d1 = Date.parse("10/15/2004");

	// 15-Oct-2004
	var d1 = Date.parse("15-Oct-2004");

	// 15-Oct-2004
	var d1 = Date.parse("2004.10.15");

	//Fri Oct 15, 2004
	var d1 = Date.parse("Fri Oct 15, 2004");

	///////////
	// Times //
	///////////

	// Today at 10 PM.
	var d1 = Date.parse("10 PM");

	// Today at 10:30 PM.
	var d1 = Date.parse("10:30 P.M.");

	// Today at 6 AM.
	var d1 = Date.parse("06am");

	/////////////////////
	// Dates and Times //
	/////////////////////

	// 8-July-2004 @ 10:30 PM
	var d1 = Date.parse("July 8th, 2004, 10:30 PM");

	// 1-July-2004 @ 10:30 PM
	var d1 = Date.parse("2004-07-01T22:30:00");

	////////////////////
	// Relative Dates //
	////////////////////

	// Returns today's date. The string "today" is culture specific.
	var d1 = Date.parse("today");

	// Returns yesterday's date. The string "yesterday" is culture specific.
	var d1 = Date.parse("yesterday");

	// Returns the date of the next thursday.
	var d1 = Date.parse("Next thursday");

	// Returns the date of the most previous monday.
	var d1 = Date.parse("last monday");

	// Returns today's day + one year.
	var d1 = Date.parse("next year");

	///////////////
	// Date Math //
	///////////////

	// Today + 2 days
	var d1 = Date.parse("t+2");

	// Today + 2 days
	var d1 = Date.parse("today + 2 days");

	// Today + 3 months
	var d1 = Date.parse("t+3m");

	// Today - 1 year
	var d1 = Date.parse("today - 1 year");

	// Today - 1 year
	var d1 = Date.parse("t-1y"); 


	/////////////////////////////
	// Partial Dates and Times //
	/////////////////////////////

	// July 15th of this year.
	var d1 = Date.parse("July 15");

	// 15th day of current day and year.
	var d1 = Date.parse("15");

	// July 1st of current year at 10pm.
	var d1 = Date.parse("7/1 10pm");
	
* * @param {String} The string value to convert into a Date object [Required] * @return {Date} A Date object or null if the string cannot be converted into a Date. */ var parseUtils = { removeOrds: function (s) { ords = s.match(/\b(\d+)(?:st|nd|rd|th)\b/); // find ordinal matches s = ((ords && ords.length === 2) ? s.replace(ords[0], ords[1]) : s); return s; }, grammarParser: function (s) { var r = null; try { r = $D.Grammar.start.call({}, s.replace(/^\s*(\S*(\s+\S+)*)\s*$/, "$1")); } catch (e) { return null; } return ((r[1].length === 0) ? r[0] : null); }, nativeFallback: function(s) { var t; try { // ok we haven't parsed it, last ditch attempt with the built-in parser. t = Date._parse(s); return (t || t === 0) ? new Date(t) : null; } catch (e) { return null; } } }; function parse (s) { var d; if (!s) { return null; } if (s instanceof Date) { return s.clone(); } if (s.length >= 4 && s.charAt(0) !== "0" && s.charAt(0) !== "+"&& s.charAt(0) !== "-") { // ie: 2004 will pass, 0800 won't. // Start with specific formats d = $D.Parsing.ISO.parse(s) || $D.Parsing.Numeric.parse(s); } if (d instanceof Date && !isNaN(d.getTime())) { return d; } else { // find ordinal dates (1st, 3rd, 8th, etc and remove them as they cause parsing issues) s = $D.Parsing.Normalizer.parse(parseUtils.removeOrds(s)); d = parseUtils.grammarParser(s); if (d !== null) { return d; } else { return parseUtils.nativeFallback(s); } } } if (!$D._parse) { $D._parse = $D.parse; } $D.parse = parse; Date.getParseFunction = function (fx) { var fns = Date.Grammar.allformats(fx); return function (s) { var r = null; for (var i = 0; i < fns.length; i++) { try { r = fns[i].call({}, s); } catch (e) { continue; } if (r[1].length === 0) { return r[0]; } } return null; }; }; /** * Converts the specified string value into its JavaScript Date equivalent using the specified format {String} or formats {Array} and the CultureInfo specific format information. * The format of the string value must match one of the supplied formats exactly. * * Example

	// 15-Oct-2004
	var d1 = Date.parseExact("10/15/2004", "M/d/yyyy");

	// 15-Oct-2004
	var d1 = Date.parse("15-Oct-2004", "M-ddd-yyyy");

	// 15-Oct-2004
	var d1 = Date.parse("2004.10.15", "yyyy.MM.dd");

	// Multiple formats
	var d1 = Date.parseExact("10/15/2004", ["M/d/yyyy", "MMMM d, yyyy"]);
	
* * @param {String} The string value to convert into a Date object [Required]. * @param {Object} The expected format {String} or an array of expected formats {Array} of the date string [Required]. * @return {Date} A Date object or null if the string cannot be converted into a Date. */ $D.parseExact = function (s, fx) { return $D.getParseFunction(fx)(s); }; }()); (function () { var $D = Date, $P = $D.prototype, // $C = $D.CultureInfo, // not used atm p = function (s, l) { if (!l) { l = 2; } return ("000" + s).slice(l * -1); }; /** * Converts a PHP format string to Java/.NET format string. * A PHP format string can be used with ._format or .format. * A Java/.NET format string can be used with .toString(). * The .parseExact function will only accept a Java/.NET format string * * Example * var f1 = "%m/%d/%y" * var f2 = Date.normalizeFormat(f1); // "MM/dd/yy" * * new Date().format(f1); // "04/13/08" * new Date()._format(f1); // "04/13/08" * new Date().toString(f2); // "04/13/08" * * var date = Date.parseExact("04/13/08", f2); // Sun Apr 13 2008 * * @param {String} A PHP format string consisting of one or more format spcifiers. * @return {String} The PHP format converted to a Java/.NET format string. */ var normalizerSubstitutions = { "d" : "dd", "%d": "dd", "D" : "ddd", "%a": "ddd", "j" : "dddd", "l" : "dddd", "%A": "dddd", "S" : "S", "F" : "MMMM", "%B": "MMMM", "m" : "MM", "%m": "MM", "M" : "MMM", "%b": "MMM", "%h": "MMM", "n" : "M", "Y" : "yyyy", "%Y": "yyyy", "y" : "yy", "%y": "yy", "g" : "h", "%I": "h", "G" : "H", "h" : "hh", "H" : "HH", "%H": "HH", "i" : "mm", "%M": "mm", "s" : "ss", "%S": "ss", "%r": "hh:mm tt", "%R": "H:mm", "%T": "H:mm:ss", "%X": "t", "%x": "d", "%e": "d", "%D": "MM/dd/yy", "%n": "\\n", "%t": "\\t", "e" : "z", "T" : "z", "%z": "z", "%Z": "z", "Z" : "ZZ", "N" : "u", "w" : "u", "%w": "u", "W" : "W", "%V": "W" }; var normalizer = { substitutes: function (m) { return normalizerSubstitutions[m]; }, interpreted: function (m, x) { var y; switch (m) { case "%u": return x.getDay() + 1; case "z": return x.getOrdinalNumber(); case "%j": return p(x.getOrdinalNumber(), 3); case "%U": var d1 = x.clone().set({month: 0, day: 1}).addDays(-1).moveToDayOfWeek(0), d2 = x.clone().addDays(1).moveToDayOfWeek(0, -1); return (d2 < d1) ? "00" : p((d2.getOrdinalNumber() - d1.getOrdinalNumber()) / 7 + 1); case "%W": return p(x.getWeek()); case "t": return $D.getDaysInMonth(x.getFullYear(), x.getMonth()); case "o": case "%G": return x.setWeek(x.getISOWeek()).toString("yyyy"); case "%g": return x._format("%G").slice(-2); case "a": case "%p": return t("tt").toLowerCase(); case "A": return t("tt").toUpperCase(); case "u": return p(x.getMilliseconds(), 3); case "I": return (x.isDaylightSavingTime()) ? 1 : 0; case "O": return x.getUTCOffset(); case "P": y = x.getUTCOffset(); return y.substring(0, y.length - 2) + ":" + y.substring(y.length - 2); case "B": var now = new Date(); return Math.floor(((now.getHours() * 3600) + (now.getMinutes() * 60) + now.getSeconds() + (now.getTimezoneOffset() + 60) * 60) / 86.4); case "c": return x.toISOString().replace(/\"/g, ""); case "U": return $D.strtotime("now"); case "%c": return t("d") + " " + t("t"); case "%C": return Math.floor(x.getFullYear() / 100 + 1); } }, shouldOverrideDefaults: function (m) { switch (m) { case "%e": return true; default: return false; } }, parse: function (m, context) { var formatString, c = context || new Date(); formatString = normalizer.substitutes(m); if (formatString) { return formatString; } formatString = normalizer.interpreted(m, c); if (formatString) { return formatString; } else { return m; } } }; $D.normalizeFormat = function (format, context) { return format.replace(/(%|\\)?.|%%/g, function(t){ return normalizer.parse(t, context); }); }; /** * Format a local Unix timestamp according to locale settings * * Example: * Date.strftime("%m/%d/%y", new Date()); // "04/13/08" * Date.strftime("c", "2008-04-13T17:52:03Z"); // "04/13/08" * * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @param {Number|String} The number representing the number of seconds that have elapsed since January 1, 1970 (local time). * @return {String} A string representation of the current Date object. */ $D.strftime = function (format, time) { var d = Date.parse(time); return d._format(format); }; /** * Parse any textual datetime description into a Unix timestamp. * A Unix timestamp is the number of seconds that have elapsed since January 1, 1970 (midnight UTC/GMT). * * Example: * Date.strtotime("04/13/08"); // 1208044800 * Date.strtotime("1970-01-01T00:00:00Z"); // 0 * * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @param {Object} A string or date object. * @return {String} A string representation of the current Date object. */ $D.strtotime = function (time) { var d = $D.parse(time); return Math.round($D.UTC(d.getUTCFullYear(), d.getUTCMonth(), d.getUTCDate(), d.getUTCHours(), d.getUTCMinutes(), d.getUTCSeconds(), d.getUTCMilliseconds()) / 1000); }; /** * Converts the value of the current Date object to its equivalent string representation using a PHP/Unix style of date format specifiers. * Format Specifiers * Format Description Example * ------ --------------------------------------------------------------------------- ----------------------- * %a abbreviated weekday name according to the current localed "Mon" through "Sun" * %A full weekday name according to the current localed "Sunday" through "Saturday" * %b abbreviated month name according to the current localed "Jan" through "Dec" * %B full month name according to the current locale "January" through "December" * %c preferred date and time representation for the current locale "4/13/2008 12:33 PM" * %C century number (the year divided by 100 and truncated to an integer) "00" to "99" * %d day of the month as a decimal number "01" to "31" * %D same as %m/%d/%y "04/13/08" * %e day of the month as a decimal number, a single digit is preceded by a space "1" to "31" * %g like %G, but without the century "08" * %G The 4-digit year corresponding to the ISO week number (see %V). "2008" * This has the same format and value as %Y, except that if the ISO week number * belongs to the previous or next year, that year is used instead. * %h same as %b "Jan" through "Dec" * %H hour as a decimal number using a 24-hour clock. "00" to "23" * %I hour as a decimal number using a 12-hour clock. "01" to "12" * %j day of the year as a decimal number. "001" to "366" * %m month as a decimal number. "01" to "12" * %M minute as a decimal number. "00" to "59" * %n newline character "\n" * %p either "am" or "pm" according to the given time value, or the "am" or "pm" * corresponding strings for the current locale. * %r time in a.m. and p.m. notation "8:44 PM" * %R time in 24 hour notation "20:44" * %S second as a decimal number "00" to "59" * %t tab character "\t" * %T current time, equal to %H:%M:%S "12:49:11" * %u weekday as a decimal number ["1", "7"], with "1" representing Monday "1" to "7" * %U week number of the current year as a decimal number, starting with the "0" to ("52" or "53") * first Sunday as the first day of the first week * %V The ISO 8601:1988 week number of the current year as a decimal number, "00" to ("52" or "53") * range 01 to 53, where week 1 is the first week that has at least 4 days * in the current year, and with Monday as the first day of the week. * (Use %G or %g for the year component that corresponds to the week number * for the specified timestamp.) * %W week number of the current year as a decimal number, starting with the "00" to ("52" or "53") * first Monday as the first day of the first week * %w day of the week as a decimal, Sunday being "0" "0" to "6" * %x preferred date representation for the current locale without the time "4/13/2008" * %X preferred time representation for the current locale without the date "12:53:05" * %y year as a decimal number without a century "00" "99" * %Y year as a decimal number including the century "2008" * %Z time zone or name or abbreviation "UTC", "EST", "PST" * %z same as %Z * %% a literal "%" characters "%" * d Day of the month, 2 digits with leading zeros "01" to "31" * D A textual representation of a day, three letters "Mon" through "Sun" * j Day of the month without leading zeros "1" to "31" * l A full textual representation of the day of the week (lowercase "L") "Sunday" through "Saturday" * N ISO-8601 numeric representation of the day of the week (added in PHP 5.1.0) "1" (for Monday) through "7" (for Sunday) * S English ordinal suffix for the day of the month, 2 characters "st", "nd", "rd" or "th". Works well with j * w Numeric representation of the day of the week "0" (for Sunday) through "6" (for Saturday) * z The day of the year (starting from "0") "0" through "365" * W ISO-8601 week number of year, weeks starting on Monday "00" to ("52" or "53") * F A full textual representation of a month, such as January or March "January" through "December" * m Numeric representation of a month, with leading zeros "01" through "12" * M A short textual representation of a month, three letters "Jan" through "Dec" * n Numeric representation of a month, without leading zeros "1" through "12" * t Number of days in the given month "28" through "31" * L Whether it's a leap year "1" if it is a leap year, "0" otherwise * o ISO-8601 year number. This has the same value as Y, except that if the "2008" * ISO week number (W) belongs to the previous or next year, that year * is used instead. * Y A full numeric representation of a year, 4 digits "2008" * y A two digit representation of a year "08" * a Lowercase Ante meridiem and Post meridiem "am" or "pm" * A Uppercase Ante meridiem and Post meridiem "AM" or "PM" * B Swatch Internet time "000" through "999" * g 12-hour format of an hour without leading zeros "1" through "12" * G 24-hour format of an hour without leading zeros "0" through "23" * h 12-hour format of an hour with leading zeros "01" through "12" * H 24-hour format of an hour with leading zeros "00" through "23" * i Minutes with leading zeros "00" to "59" * s Seconds, with leading zeros "00" through "59" * u Milliseconds "54321" * e Timezone identifier "UTC", "EST", "PST" * I Whether or not the date is in daylight saving time (uppercase i) "1" if Daylight Saving Time, "0" otherwise * O Difference to Greenwich time (GMT) in hours "+0200", "-0600" * P Difference to Greenwich time (GMT) with colon between hours and minutes "+02:00", "-06:00" * T Timezone abbreviation "UTC", "EST", "PST" * Z Timezone offset in seconds. The offset for timezones west of UTC is "-43200" through "50400" * always negative, and for those east of UTC is always positive. * c ISO 8601 date "2004-02-12T15:19:21+00:00" * r RFC 2822 formatted date "Thu, 21 Dec 2000 16:01:07 +0200" * U Seconds since the Unix Epoch (January 1 1970 00:00:00 GMT) "0" * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @return {String} A string representation of the current Date object. */ var formatReplace = function (context) { return function (m) { var formatString, override = false; if (m.charAt(0) === "\\" || m.substring(0, 2) === "%%") { return m.replace("\\", "").replace("%%", "%"); } override = normalizer.shouldOverrideDefaults(m); formatString = $D.normalizeFormat(m, context); if (formatString) { return context.toString(formatString, override); } }; }; $P._format = function (format) { var formatter = formatReplace(this); if (!format) { return this._toString(); } else { return format.replace(/(%|\\)?.|%%/g, formatter); } }; if (!$P.format) { $P.format = $P._format; } }()); (function () { "use strict"; var gFn = function (attr) { return function () { return this[attr]; }; }; var sFn = function (attr) { return function (val) { this[attr] = val; return this; }; }; var attrs = ["years", "months", "days", "hours", "minutes", "seconds", "milliseconds"]; var addSetFuncs = function (context, attrs) { for (var i = 0; i < attrs.length ; i++) { var $a = attrs[i], $b = $a.slice(0, 1).toUpperCase() + $a.slice(1); context.prototype[$a] = 0; context.prototype["get" + $b] = gFn($a); context.prototype["set" + $b] = sFn($a); } }; /** * new TimeSpan(milliseconds); * new TimeSpan(days, hours, minutes, seconds); * new TimeSpan(days, hours, minutes, seconds, milliseconds); */ var TimeSpan = function (days, hours, minutes, seconds, milliseconds) { if (arguments.length === 1 && typeof days === "number") { var orient = (days < 0) ? -1 : +1; var millsLeft = Math.abs(days); this.setDays(Math.floor(millsLeft / 86400000) * orient); millsLeft = millsLeft % 86400000; this.setHours(Math.floor(millsLeft / 3600000) * orient); millsLeft = millsLeft % 3600000; this.setMinutes(Math.floor(millsLeft / 60000) * orient); millsLeft = millsLeft % 60000; this.setSeconds(Math.floor(millsLeft / 1000) * orient); millsLeft = millsLeft % 1000; this.setMilliseconds(millsLeft * orient); } else { this.set(days, hours, minutes, seconds, milliseconds); } this.getTotalMilliseconds = function () { return (this.getDays() * 86400000) + (this.getHours() * 3600000) + (this.getMinutes() * 60000) + (this.getSeconds() * 1000); }; this.compareTo = function (time) { var t1 = new Date(1970, 1, 1, this.getHours(), this.getMinutes(), this.getSeconds()), t2; if (time === null) { t2 = new Date(1970, 1, 1, 0, 0, 0); } else { t2 = new Date(1970, 1, 1, time.getHours(), time.getMinutes(), time.getSeconds()); } return (t1 < t2) ? -1 : (t1 > t2) ? 1 : 0; }; this.equals = function (time) { return (this.compareTo(time) === 0); }; this.add = function (time) { return (time === null) ? this : this.addSeconds(time.getTotalMilliseconds() / 1000); }; this.subtract = function (time) { return (time === null) ? this : this.addSeconds(-time.getTotalMilliseconds() / 1000); }; this.addDays = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 86400000)); }; this.addHours = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 3600000)); }; this.addMinutes = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 60000)); }; this.addSeconds = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 1000)); }; this.addMilliseconds = function (n) { return new TimeSpan(this.getTotalMilliseconds() + n); }; this.get12HourHour = function () { return (this.getHours() > 12) ? this.getHours() - 12 : (this.getHours() === 0) ? 12 : this.getHours(); }; this.getDesignator = function () { return (this.getHours() < 12) ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator; }; this.toString = function (format) { this._toString = function () { if (this.getDays() !== null && this.getDays() > 0) { return this.getDays() + "." + this.getHours() + ":" + this.p(this.getMinutes()) + ":" + this.p(this.getSeconds()); } else { return this.getHours() + ":" + this.p(this.getMinutes()) + ":" + this.p(this.getSeconds()); } }; this.p = function (s) { return (s.toString().length < 2) ? "0" + s : s; }; var me = this; return format ? format.replace(/dd?|HH?|hh?|mm?|ss?|tt?/g, function (format) { switch (format) { case "d": return me.getDays(); case "dd": return me.p(me.getDays()); case "H": return me.getHours(); case "HH": return me.p(me.getHours()); case "h": return me.get12HourHour(); case "hh": return me.p(me.get12HourHour()); case "m": return me.getMinutes(); case "mm": return me.p(me.getMinutes()); case "s": return me.getSeconds(); case "ss": return me.p(me.getSeconds()); case "t": return ((me.getHours() < 12) ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator).substring(0, 1); case "tt": return (me.getHours() < 12) ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator; } } ) : this._toString(); }; return this; }; addSetFuncs(TimeSpan, attrs.slice(2)); TimeSpan.prototype.set = function (days, hours, minutes, seconds, milliseconds){ this.setDays(days || this.getDays()); this.setHours(hours || this.getHours()); this.setMinutes(minutes || this.getMinutes()); this.setSeconds(seconds || this.getSeconds()); this.setMilliseconds(milliseconds || this.getMilliseconds()); }; /** * Gets the time of day for this date instances. * @return {TimeSpan} TimeSpan */ Date.prototype.getTimeOfDay = function () { return new TimeSpan(0, this.getHours(), this.getMinutes(), this.getSeconds(), this.getMilliseconds()); }; Date.TimeSpan = TimeSpan; if (typeof window !== "undefined" ) { // keeping API compatible for v1.x window.TimeSpan = TimeSpan; } }()); (function () { "use strict"; var attrs = ["years", "months", "days", "hours", "minutes", "seconds", "milliseconds"]; var gFn = function (attr) { return function () { return this[attr]; }; }; var sFn = function (attr) { return function (val) { this[attr] = val; return this; }; }; var addSetFuncs = function (context, attrs) { for (var i = 0; i < attrs.length ; i++) { var $a = attrs[i], $b = $a.slice(0, 1).toUpperCase() + $a.slice(1); context.prototype[$a] = 0; context.prototype["get" + $b] = gFn($a); context.prototype["set" + $b] = sFn($a); } }; var setMonthsAndYears = function (orient, d1, d2, context) { function inc() { d1.addMonths(-orient); context.months++; if (context.months === 12) { context.years++; context.months = 0; } } if (orient === +1) { while (d1 > d2) { inc(); } } else { while (d1 < d2) { inc(); } } context.months--; context.months *= orient; context.years *= orient; }; var adjustForDST = function(orient, startDate, endDate) { var hasDSTMismatch = (false === (startDate.isDaylightSavingTime() === endDate.isDaylightSavingTime())); if (hasDSTMismatch && orient === 1) { startDate.addHours(-1); } else if (hasDSTMismatch) { startDate.addHours(1); } }; /** * TimePeriod(startDate, endDate); * TimePeriod(years, months, days, hours, minutes, seconds, milliseconds); */ var TimePeriod = function (years, months, days, hours, minutes, seconds, milliseconds) { if (arguments.length === 7) { this.set(years, months, days, hours, minutes, seconds, milliseconds); } else if (arguments.length === 2 && arguments[0] instanceof Date && arguments[1] instanceof Date) { var startDate = arguments[0].clone(); var endDate = arguments[1].clone(); var orient = (startDate > endDate) ? +1 : -1; this.dates = { start: arguments[0].clone(), end: arguments[1].clone() }; setMonthsAndYears(orient, startDate, endDate, this); adjustForDST(orient, startDate, endDate); // // TODO - adjust for DST var diff = endDate - startDate; if (diff !== 0) { var ts = new TimeSpan(diff); this.set(this.years, this.months, ts.getDays(), ts.getHours(), ts.getMinutes(), ts.getSeconds(), ts.getMilliseconds()); } } return this; }; // create all the set functions. addSetFuncs(TimePeriod, attrs); TimePeriod.prototype.set = function (years, months, days, hours, minutes, seconds, milliseconds){ this.setYears(years || this.getYears()); this.setMonths(months || this.getMonths()); this.setDays(days || this.getDays()); this.setHours(hours || this.getHours()); this.setMinutes(minutes || this.getMinutes()); this.setSeconds(seconds || this.getSeconds()); this.setMilliseconds(milliseconds || this.getMilliseconds()); }; Date.TimePeriod = TimePeriod; if (typeof window !== "undefined") { // keeping API compatible for v1.x window.TimePeriod = TimePeriod; } }()); ================================================ FILE: build/date-he-IL.js ================================================ /** * @overview datejs * @version 1.0.0-rc3 * @author Gregory Wild-Smith * @copyright 2015 Gregory Wild-Smith * @license MIT * @homepage https://github.com/abritinthebay/datejs */ /* * DateJS Culture String File * Country Code: he-IL * Name: Hebrew (Israel) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["he-IL"] = { "name": "he-IL", "englishName": "Hebrew (Israel)", "nativeName": "עברית (ישראל)", "Sunday": "יום ראשון", "Monday": "יום שני", "Tuesday": "יום שלישי", "Wednesday": "יום רביעי", "Thursday": "יום חמישי", "Friday": "יום שישי", "Saturday": "שבת", "Sun": "יום א", "Mon": "יום ב", "Tue": "יום ג", "Wed": "יום ד", "Thu": "יום ה", "Fri": "יום ו", "Sat": "שבת", "Su": "א", "Mo": "ב", "Tu": "ג", "We": "ד", "Th": "ה", "Fr": "ו", "Sa": "ש", "S_Sun_Initial": "א", "M_Mon_Initial": "ב", "T_Tue_Initial": "ג", "W_Wed_Initial": "ד", "T_Thu_Initial": "ה", "F_Fri_Initial": "ו", "S_Sat_Initial": "ש", "January": "ינואר", "February": "פברואר", "March": "מרץ", "April": "אפריל", "May": "מאי", "June": "יוני", "July": "יולי", "August": "אוגוסט", "September": "ספטמבר", "October": "אוקטובר", "November": "נובמבר", "December": "דצמבר", "Jan_Abbr": "ינו", "Feb_Abbr": "פבר", "Mar_Abbr": "מרץ", "Apr_Abbr": "אפר", "May_Abbr": "מאי", "Jun_Abbr": "יונ", "Jul_Abbr": "יול", "Aug_Abbr": "אוג", "Sep_Abbr": "ספט", "Oct_Abbr": "אוק", "Nov_Abbr": "נוב", "Dec_Abbr": "דצמ", "AM": "AM", "PM": "PM", "firstDayOfWeek": 0, "twoDigitYearMax": 2029, "mdy": "dmy", "M/d/yyyy": "dd/MM/yyyy", "dddd, MMMM dd, yyyy": "dddd dd MMMM yyyy", "h:mm tt": "HH:mm", "h:mm:ss tt": "HH:mm:ss", "dddd, MMMM dd, yyyy h:mm:ss tt": "dddd dd MMMM yyyy HH:mm:ss", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "dd MMMM", "MMMM, yyyy": "MMMM yyyy", "/jan(uary)?/": "ינו(אר)?", "/feb(ruary)?/": "פבר(ואר)?", "/mar(ch)?/": "מרץ", "/apr(il)?/": "אפר(יל)?", "/may/": "מאי", "/jun(e)?/": "יונ(י)?", "/jul(y)?/": "יול(י)?", "/aug(ust)?/": "אוג(וסט)?", "/sep(t(ember)?)?/": "ספט(מבר)?", "/oct(ober)?/": "אוק(טובר)?", "/nov(ember)?/": "נוב(מבר)?", "/dec(ember)?/": "דצמ(בר)?", "/^su(n(day)?)?/": "^א(ום א(אשון)?)?", "/^mo(n(day)?)?/": "^ב(ום ב(ני)?)?", "/^tu(e(s(day)?)?)?/": "^ג(ום ג(לישי)?)?", "/^we(d(nesday)?)?/": "^ד(ום ד(ביעי)?)?", "/^th(u(r(s(day)?)?)?)?/": "^ה(ום ה(מישי)?)?", "/^fr(i(day)?)?/": "^ו(ום ו(ישי)?)?", "/^sa(t(urday)?)?/": "^ש(1)?", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "he-IL"; /** * @overview datejs * @version 1.0.0-rc3 * @author Gregory Wild-Smith * @copyright 2015 Gregory Wild-Smith * @license MIT * @homepage https://github.com/abritinthebay/datejs */(function () { var $D = Date; var lang = Date.CultureStrings ? Date.CultureStrings.lang : null; var loggedKeys = {}; // for debug purposes. var getText = { getFromKey: function (key, countryCode) { var output; if (Date.CultureStrings && Date.CultureStrings[countryCode] && Date.CultureStrings[countryCode][key]) { output = Date.CultureStrings[countryCode][key]; } else { output = getText.buildFromDefault(key); } if (key.charAt(0) === "/") { // Assume it's a regex output = getText.buildFromRegex(key, countryCode); } return output; }, getFromObjectValues: function (obj, countryCode) { var key, output = {}; for(key in obj) { if (obj.hasOwnProperty(key)) { output[key] = getText.getFromKey(obj[key], countryCode); } } return output; }, getFromObjectKeys: function (obj, countryCode) { var key, output = {}; for(key in obj) { if (obj.hasOwnProperty(key)) { output[getText.getFromKey(key, countryCode)] = obj[key]; } } return output; }, getFromArray: function (arr, countryCode) { var output = []; for (var i=0; i < arr.length; i++){ if (i in arr) { output[i] = getText.getFromKey(arr[i], countryCode); } } return output; }, buildFromDefault: function (key) { var output, length, split, last; switch(key) { case "name": output = "en-US"; break; case "englishName": output = "English (United States)"; break; case "nativeName": output = "English (United States)"; break; case "twoDigitYearMax": output = 2049; break; case "firstDayOfWeek": output = 0; break; default: output = key; split = key.split("_"); length = split.length; if (length > 1 && key.charAt(0) !== "/") { // if the key isn't a regex and it has a split. last = split[(length - 1)].toLowerCase(); if (last === "initial" || last === "abbr") { output = split[0]; } } break; } return output; }, buildFromRegex: function (key, countryCode) { var output; if (Date.CultureStrings && Date.CultureStrings[countryCode] && Date.CultureStrings[countryCode][key]) { output = new RegExp(Date.CultureStrings[countryCode][key], "i"); } else { output = new RegExp(key.replace(new RegExp("/", "g"),""), "i"); } return output; } }; var shallowMerge = function (obj1, obj2) { for (var attrname in obj2) { if (obj2.hasOwnProperty(attrname)) { obj1[attrname] = obj2[attrname]; } } }; var __ = function (key, language) { var countryCode = (language) ? language : lang; loggedKeys[key] = key; if (typeof key === "object") { if (key instanceof Array) { return getText.getFromArray(key, countryCode); } else { return getText.getFromObjectKeys(key, countryCode); } } else { return getText.getFromKey(key, countryCode); } }; var loadI18nScript = function (code) { // paatterned after jQuery's getScript. var url = Date.Config.i18n + code + ".js"; var head = document.getElementsByTagName("head")[0] || document.documentElement; var script = document.createElement("script"); script.src = url; var completed = false; var events = { done: function (){} // placeholder function }; // Attach handlers for all browsers script.onload = script.onreadystatechange = function() { if ( !completed && (!this.readyState || this.readyState === "loaded" || this.readyState === "complete") ) { events.done(); head.removeChild(script); } }; setTimeout(function() { head.insertBefore(script, head.firstChild); }, 0); // allows return to execute first return { done: function (cb) { events.done = function() { if (cb) { setTimeout(cb,0); } }; } }; }; var buildInfo = { buildFromMethodHash: function (obj) { var key; for(key in obj) { if (obj.hasOwnProperty(key)) { obj[key] = buildInfo[obj[key]](); } } return obj; }, timeZoneDST: function () { var DST = { "CHADT": "+1345", "NZDT": "+1300", "AEDT": "+1100", "ACDT": "+1030", "AZST": "+0500", "IRDT": "+0430", "EEST": "+0300", "CEST": "+0200", "BST": "+0100", "PMDT": "-0200", "ADT": "-0300", "NDT": "-0230", "EDT": "-0400", "CDT": "-0500", "MDT": "-0600", "PDT": "-0700", "AKDT": "-0800", "HADT": "-0900" }; return __(DST); }, timeZoneStandard: function () { var standard = { "LINT": "+1400", "TOT": "+1300", "CHAST": "+1245", "NZST": "+1200", "NFT": "+1130", "SBT": "+1100", "AEST": "+1000", "ACST": "+0930", "JST": "+0900", "CWST": "+0845", "CT": "+0800", "ICT": "+0700", "MMT": "+0630", "BST": "+0600", "NPT": "+0545", "IST": "+0530", "PKT": "+0500", "AFT": "+0430", "MSK": "+0400", "IRST": "+0330", "FET": "+0300", "EET": "+0200", "CET": "+0100", "GMT": "+0000", "UTC": "+0000", "CVT": "-0100", "GST": "-0200", "BRT": "-0300", "NST": "-0330", "AST": "-0400", "EST": "-0500", "CST": "-0600", "MST": "-0700", "PST": "-0800", "AKST": "-0900", "MIT": "-0930", "HST": "-1000", "SST": "-1100", "BIT": "-1200" }; return __(standard); }, timeZones: function (data) { var zone; data.timezones = []; for (zone in data.abbreviatedTimeZoneStandard) { if (data.abbreviatedTimeZoneStandard.hasOwnProperty(zone)) { data.timezones.push({ name: zone, offset: data.abbreviatedTimeZoneStandard[zone]}); } } for (zone in data.abbreviatedTimeZoneDST) { if (data.abbreviatedTimeZoneDST.hasOwnProperty(zone)) { data.timezones.push({ name: zone, offset: data.abbreviatedTimeZoneDST[zone], dst: true}); } } return data.timezones; }, days: function () { return __(["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"]); }, dayAbbr: function () { return __(["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"]); }, dayShortNames: function () { return __(["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"]); }, dayFirstLetters: function () { return __(["S_Sun_Initial", "M_Mon_Initial", "T_Tues_Initial", "W_Wed_Initial", "T_Thu_Initial", "F_Fri_Initial", "S_Sat_Initial"]); }, months: function () { return __(["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"]); }, monthAbbr: function () { return __(["Jan_Abbr", "Feb_Abbr", "Mar_Abbr", "Apr_Abbr", "May_Abbr", "Jun_Abbr", "Jul_Abbr", "Aug_Abbr", "Sep_Abbr", "Oct_Abbr", "Nov_Abbr", "Dec_Abbr"]); }, formatPatterns: function () { return getText.getFromObjectValues({ shortDate: "M/d/yyyy", longDate: "dddd, MMMM dd, yyyy", shortTime: "h:mm tt", longTime: "h:mm:ss tt", fullDateTime: "dddd, MMMM dd, yyyy h:mm:ss tt", sortableDateTime: "yyyy-MM-ddTHH:mm:ss", universalSortableDateTime: "yyyy-MM-dd HH:mm:ssZ", rfc1123: "ddd, dd MMM yyyy HH:mm:ss", monthDay: "MMMM dd", yearMonth: "MMMM, yyyy" }, Date.i18n.currentLanguage()); }, regex: function () { return getText.getFromObjectValues({ inTheMorning: "/( in the )(morn(ing)?)\\b/", thisMorning: "/(this )(morn(ing)?)\\b/", amThisMorning: "/(\b\\d(am)? )(this )(morn(ing)?)/", inTheEvening: "/( in the )(even(ing)?)\\b/", thisEvening: "/(this )(even(ing)?)\\b/", pmThisEvening: "/(\b\\d(pm)? )(this )(even(ing)?)/", jan: "/jan(uary)?/", feb: "/feb(ruary)?/", mar: "/mar(ch)?/", apr: "/apr(il)?/", may: "/may/", jun: "/jun(e)?/", jul: "/jul(y)?/", aug: "/aug(ust)?/", sep: "/sep(t(ember)?)?/", oct: "/oct(ober)?/", nov: "/nov(ember)?/", dec: "/dec(ember)?/", sun: "/^su(n(day)?)?/", mon: "/^mo(n(day)?)?/", tue: "/^tu(e(s(day)?)?)?/", wed: "/^we(d(nesday)?)?/", thu: "/^th(u(r(s(day)?)?)?)?/", fri: "/fr(i(day)?)?/", sat: "/^sa(t(urday)?)?/", future: "/^next/", past: "/^last|past|prev(ious)?/", add: "/^(\\+|aft(er)?|from|hence)/", subtract: "/^(\\-|bef(ore)?|ago)/", yesterday: "/^yes(terday)?/", today: "/^t(od(ay)?)?/", tomorrow: "/^tom(orrow)?/", now: "/^n(ow)?/", millisecond: "/^ms|milli(second)?s?/", second: "/^sec(ond)?s?/", minute: "/^mn|min(ute)?s?/", hour: "/^h(our)?s?/", week: "/^w(eek)?s?/", month: "/^m(onth)?s?/", day: "/^d(ay)?s?/", year: "/^y(ear)?s?/", shortMeridian: "/^(a|p)/", longMeridian: "/^(a\\.?m?\\.?|p\\.?m?\\.?)/", timezone: "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/", ordinalSuffix: "/^\\s*(st|nd|rd|th)/", timeContext: "/^\\s*(\\:|a(?!u|p)|p)/" }, Date.i18n.currentLanguage()); } }; var CultureInfo = function () { var info = getText.getFromObjectValues({ name: "name", englishName: "englishName", nativeName: "nativeName", amDesignator: "AM", pmDesignator: "PM", firstDayOfWeek: "firstDayOfWeek", twoDigitYearMax: "twoDigitYearMax", dateElementOrder: "mdy" }, Date.i18n.currentLanguage()); var constructedInfo = buildInfo.buildFromMethodHash({ dayNames: "days", abbreviatedDayNames: "dayAbbr", shortestDayNames: "dayShortNames", firstLetterDayNames: "dayFirstLetters", monthNames: "months", abbreviatedMonthNames: "monthAbbr", formatPatterns: "formatPatterns", regexPatterns: "regex", abbreviatedTimeZoneDST: "timeZoneDST", abbreviatedTimeZoneStandard: "timeZoneStandard" }); shallowMerge(info, constructedInfo); buildInfo.timeZones(info); return info; }; $D.i18n = { __: function (key, lang) { return __(key, lang); }, currentLanguage: function () { return lang || "en-US"; }, setLanguage: function (code, force, cb) { var async = false; if (force || code === "en-US" || (!!Date.CultureStrings && !!Date.CultureStrings[code])) { lang = code; Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings.lang = code; Date.CultureInfo = new CultureInfo(); } else { if (!(!!Date.CultureStrings && !!Date.CultureStrings[code])) { if (typeof exports !== "undefined" && this.exports !== exports) { // we're in a Node enviroment, load it using require try { require("../i18n/" + code + ".js"); lang = code; Date.CultureStrings.lang = code; Date.CultureInfo = new CultureInfo(); } catch (e) { // var str = "The language for '" + code + "' could not be loaded by Node. It likely does not exist."; throw new Error("The DateJS IETF language tag '" + code + "' could not be loaded by Node. It likely does not exist."); } } else if (Date.Config && Date.Config.i18n) { // we know the location of the files, so lets load them async = true; loadI18nScript(code).done(function(){ lang = code; Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings.lang = code; Date.CultureInfo = new CultureInfo(); $D.Parsing.Normalizer.buildReplaceData(); // because this is async if ($D.Grammar) { $D.Grammar.buildGrammarFormats(); // so we can parse those strings... } if (cb) { setTimeout(cb,0); } }); } else { Date.console.error("The DateJS IETF language tag '" + code + "' is not available and has not been loaded."); return false; } } } $D.Parsing.Normalizer.buildReplaceData(); // rebuild normalizer strings if ($D.Grammar) { $D.Grammar.buildGrammarFormats(); // so we can parse those strings... } if (!async && cb) { setTimeout(cb,0); } }, getLoggedKeys: function () { return loggedKeys; }, updateCultureInfo: function () { Date.CultureInfo = new CultureInfo(); } }; $D.i18n.updateCultureInfo(); // run automatically }()); (function () { var $D = Date, $P = $D.prototype, p = function (s, l) { if (!l) { l = 2; } return ("000" + s).slice(l * -1); }; if (typeof window !== "undefined" && typeof window.console !== "undefined" && typeof window.console.log !== "undefined") { $D.console = console; // used only to raise non-critical errors if available } else { // set mock so we don't give errors. $D.console = { log: function(){}, error: function(){} }; } $D.Config = $D.Config || {}; $D.initOverloads = function() { /** * Overload of Date.now. Allows an alternate call for Date.now where it returns the * current Date as an object rather than just milliseconds since the Unix Epoch. * * Also provides an implementation of now() for browsers (IE<9) that don't have it. * * Backwards compatible so with work with either: * Date.now() [returns ms] * or * Date.now(true) [returns Date] */ if (!$D.now) { $D._now = function now() { return new Date().getTime(); }; } else if (!$D._now) { $D._now = $D.now; } $D.now = function (returnObj) { if (returnObj) { return $D.present(); } else { return $D._now(); } }; if ( !$P.toISOString ) { $P.toISOString = function() { return this.getUTCFullYear() + "-" + p(this.getUTCMonth() + 1) + "-" + p(this.getUTCDate()) + "T" + p(this.getUTCHours()) + ":" + p(this.getUTCMinutes()) + ":" + p(this.getUTCSeconds()) + "." + String( (this.getUTCMilliseconds()/1000).toFixed(3)).slice(2, 5) + "Z"; }; } // private if ( $P._toString === undefined ){ $P._toString = $P.toString; } }; $D.initOverloads(); /** * Gets a date that is set to the current date. The time is set to the start of the day (00:00 or 12:00 AM). * @return {Date} The current date. */ $D.today = function () { return new Date().clearTime(); }; /** * Gets a date that is set to the current date and time (same as new Date, but chainable) * @return {Date} The current date. */ $D.present = function () { return new Date(); }; /** * Compares the first date to the second date and returns an number indication of their relative values. * @param {Date} First Date object to compare [Required]. * @param {Date} Second Date object to compare to [Required]. * @return {Number} -1 = date1 is lessthan date2. 0 = values are equal. 1 = date1 is greaterthan date2. */ $D.compare = function (date1, date2) { if (isNaN(date1) || isNaN(date2)) { throw new Error(date1 + " - " + date2); } else if (date1 instanceof Date && date2 instanceof Date) { return (date1 < date2) ? -1 : (date1 > date2) ? 1 : 0; } else { throw new TypeError(date1 + " - " + date2); } }; /** * Compares the first Date object to the second Date object and returns true if they are equal. * @param {Date} First Date object to compare [Required] * @param {Date} Second Date object to compare to [Required] * @return {Boolean} true if dates are equal. false if they are not equal. */ $D.equals = function (date1, date2) { return (date1.compareTo(date2) === 0); }; /** * Gets the language appropriate day name when given the day number(0-6) * eg - 0 == Sunday * @return {String} The day name */ $D.getDayName = function (n) { return Date.CultureInfo.dayNames[n]; }; /** * Gets the day number (0-6) if given a CultureInfo specific string which is a valid dayName, abbreviatedDayName or shortestDayName (two char). * @param {String} The name of the day (eg. "Monday, "Mon", "tuesday", "tue", "We", "we"). * @return {Number} The day number */ $D.getDayNumberFromName = function (name) { var n = Date.CultureInfo.dayNames, m = Date.CultureInfo.abbreviatedDayNames, o = Date.CultureInfo.shortestDayNames, s = name.toLowerCase(); for (var i = 0; i < n.length; i++) { if (n[i].toLowerCase() === s || m[i].toLowerCase() === s || o[i].toLowerCase() === s) { return i; } } return -1; }; /** * Gets the month number (0-11) if given a Culture Info specific string which is a valid monthName or abbreviatedMonthName. * @param {String} The name of the month (eg. "February, "Feb", "october", "oct"). * @return {Number} The day number */ $D.getMonthNumberFromName = function (name) { var n = Date.CultureInfo.monthNames, m = Date.CultureInfo.abbreviatedMonthNames, s = name.toLowerCase(); for (var i = 0; i < n.length; i++) { if (n[i].toLowerCase() === s || m[i].toLowerCase() === s) { return i; } } return -1; }; /** * Gets the language appropriate month name when given the month number(0-11) * eg - 0 == January * @return {String} The month name */ $D.getMonthName = function (n) { return Date.CultureInfo.monthNames[n]; }; /** * Determines if the current date instance is within a LeapYear. * @param {Number} The year. * @return {Boolean} true if date is within a LeapYear, otherwise false. */ $D.isLeapYear = function (year) { return ((year % 4 === 0 && year % 100 !== 0) || year % 400 === 0); }; /** * Gets the number of days in the month, given a year and month value. Automatically corrects for LeapYear. * @param {Number} The year. * @param {Number} The month (0-11). * @return {Number} The number of days in the month. */ $D.getDaysInMonth = function (year, month) { if (!month && $D.validateMonth(year)) { month = year; year = Date.today().getFullYear(); } return [31, ($D.isLeapYear(year) ? 29 : 28), 31, 30, 31, 30, 31, 31, 30, 31, 30, 31][month]; }; $P.getDaysInMonth = function () { return $D.getDaysInMonth(this.getFullYear(), this.getMonth()); }; $D.getTimezoneAbbreviation = function (offset, dst) { var p, n = (dst || false) ? Date.CultureInfo.abbreviatedTimeZoneDST : Date.CultureInfo.abbreviatedTimeZoneStandard; for (p in n) { if (n.hasOwnProperty(p)) { if (n[p] === offset) { return p; } } } return null; }; $D.getTimezoneOffset = function (name, dst) { var i, a =[], z = Date.CultureInfo.timezones; if (!name) { name = (new Date()).getTimezone();} for (i = 0; i < z.length; i++) { if (z[i].name === name.toUpperCase()) { a.push(i); } } if (!z[a[0]]) { return null; } if (a.length === 1 || !dst) { return z[a[0]].offset; } else { for (i=0; i < a.length; i++) { if (z[a[i]].dst) { return z[a[i]].offset; } } } }; $D.getQuarter = function (d) { d = d || new Date(); // If no date supplied, use today var q = [1,2,3,4]; return q[Math.floor(d.getMonth() / 3)]; // ~~~ is a bitwise op. Faster than Math.floor }; $D.getDaysLeftInQuarter = function (d) { d = d || new Date(); var qEnd = new Date(d); qEnd.setMonth(qEnd.getMonth() + 3 - qEnd.getMonth() % 3, 0); return Math.floor((qEnd - d) / 8.64e7); }; // private var validate = function (n, min, max, name) { name = name ? name : "Object"; if (typeof n === "undefined") { return false; } else if (typeof n !== "number") { throw new TypeError(n + " is not a Number."); } else if (n < min || n > max) { // As failing validation is *not* an exceptional circumstance // lets not throw a RangeError Exception here. // It's semantically correct but it's not sensible. return false; } return true; }; /** * Validates the number is within an acceptable range for milliseconds [0-999]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateMillisecond = function (value) { return validate(value, 0, 999, "millisecond"); }; /** * Validates the number is within an acceptable range for seconds [0-59]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateSecond = function (value) { return validate(value, 0, 59, "second"); }; /** * Validates the number is within an acceptable range for minutes [0-59]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateMinute = function (value) { return validate(value, 0, 59, "minute"); }; /** * Validates the number is within an acceptable range for hours [0-23]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateHour = function (value) { return validate(value, 0, 23, "hour"); }; /** * Validates the number is within an acceptable range for the days in a month [0-MaxDaysInMonth]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateDay = function (value, year, month) { if (year === undefined || year === null || month === undefined || month === null) { return false;} return validate(value, 1, $D.getDaysInMonth(year, month), "day"); }; /** * Validates the number is within an acceptable range for months [0-11]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateWeek = function (value) { return validate(value, 0, 53, "week"); }; /** * Validates the number is within an acceptable range for months [0-11]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateMonth = function (value) { return validate(value, 0, 11, "month"); }; /** * Validates the number is within an acceptable range for years. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateYear = function (value) { /** * Per ECMAScript spec the range of times supported by Date objects is * exactly -100,000,000 days to +100,000,000 days measured relative to * midnight at the beginning of 01 January, 1970 UTC. * This gives a range of 8,640,000,000,000,000 milliseconds to either * side of 01 January, 1970 UTC. * * Earliest possible date: Tue, 20 Apr 271,822 B.C. 00:00:00 UTC * Latest possible date: Sat, 13 Sep 275,760 00:00:00 UTC */ return validate(value, -271822, 275760, "year"); }; $D.validateTimezone = function(value) { var timezones = {"ACDT":1,"ACST":1,"ACT":1,"ADT":1,"AEDT":1,"AEST":1,"AFT":1,"AKDT":1,"AKST":1,"AMST":1,"AMT":1,"ART":1,"AST":1,"AWDT":1,"AWST":1,"AZOST":1,"AZT":1,"BDT":1,"BIOT":1,"BIT":1,"BOT":1,"BRT":1,"BST":1,"BTT":1,"CAT":1,"CCT":1,"CDT":1,"CEDT":1,"CEST":1,"CET":1,"CHADT":1,"CHAST":1,"CHOT":1,"ChST":1,"CHUT":1,"CIST":1,"CIT":1,"CKT":1,"CLST":1,"CLT":1,"COST":1,"COT":1,"CST":1,"CT":1,"CVT":1,"CWST":1,"CXT":1,"DAVT":1,"DDUT":1,"DFT":1,"EASST":1,"EAST":1,"EAT":1,"ECT":1,"EDT":1,"EEDT":1,"EEST":1,"EET":1,"EGST":1,"EGT":1,"EIT":1,"EST":1,"FET":1,"FJT":1,"FKST":1,"FKT":1,"FNT":1,"GALT":1,"GAMT":1,"GET":1,"GFT":1,"GILT":1,"GIT":1,"GMT":1,"GST":1,"GYT":1,"HADT":1,"HAEC":1,"HAST":1,"HKT":1,"HMT":1,"HOVT":1,"HST":1,"ICT":1,"IDT":1,"IOT":1,"IRDT":1,"IRKT":1,"IRST":1,"IST":1,"JST":1,"KGT":1,"KOST":1,"KRAT":1,"KST":1,"LHST":1,"LINT":1,"MAGT":1,"MART":1,"MAWT":1,"MDT":1,"MET":1,"MEST":1,"MHT":1,"MIST":1,"MIT":1,"MMT":1,"MSK":1,"MST":1,"MUT":1,"MVT":1,"MYT":1,"NCT":1,"NDT":1,"NFT":1,"NPT":1,"NST":1,"NT":1,"NUT":1,"NZDT":1,"NZST":1,"OMST":1,"ORAT":1,"PDT":1,"PET":1,"PETT":1,"PGT":1,"PHOT":1,"PHT":1,"PKT":1,"PMDT":1,"PMST":1,"PONT":1,"PST":1,"PYST":1,"PYT":1,"RET":1,"ROTT":1,"SAKT":1,"SAMT":1,"SAST":1,"SBT":1,"SCT":1,"SGT":1,"SLST":1,"SRT":1,"SST":1,"SYOT":1,"TAHT":1,"THA":1,"TFT":1,"TJT":1,"TKT":1,"TLT":1,"TMT":1,"TOT":1,"TVT":1,"UCT":1,"ULAT":1,"UTC":1,"UYST":1,"UYT":1,"UZT":1,"VET":1,"VLAT":1,"VOLT":1,"VOST":1,"VUT":1,"WAKT":1,"WAST":1,"WAT":1,"WEDT":1,"WEST":1,"WET":1,"WST":1,"YAKT":1,"YEKT":1,"Z":1}; return (timezones[value] === 1); }; $D.validateTimezoneOffset= function(value) { // timezones go from +14hrs to -12hrs, the +X hours are negative offsets. return (value > -841 && value < 721); }; }()); (function () { var $D = Date, $P = $D.prototype, p = function (s, l) { if (!l) { l = 2; } return ("000" + s).slice(l * -1); }; var validateConfigObject = function (obj) { var result = {}, self = this, prop, testFunc; testFunc = function (prop, func, value) { if (prop === "day") { var month = (obj.month !== undefined) ? obj.month : self.getMonth(); var year = (obj.year !== undefined) ? obj.year : self.getFullYear(); return $D[func](value, year, month); } else { return $D[func](value); } }; for (prop in obj) { if (Object.prototype.hasOwnProperty.call(obj, prop)) { var func = "validate" + prop.charAt(0).toUpperCase() + prop.slice(1); if ($D[func] && obj[prop] !== null && testFunc(prop, func, obj[prop])) { result[prop] = obj[prop]; } } } return result; }; /** * Resets the time of this Date object to 12:00 AM (00:00), which is the start of the day. * @param {Boolean} .clone() this date instance before clearing Time * @return {Date} this */ $P.clearTime = function () { this.setHours(0); this.setMinutes(0); this.setSeconds(0); this.setMilliseconds(0); return this; }; /** * Resets the time of this Date object to the current time ('now'). * @return {Date} this */ $P.setTimeToNow = function () { var n = new Date(); this.setHours(n.getHours()); this.setMinutes(n.getMinutes()); this.setSeconds(n.getSeconds()); this.setMilliseconds(n.getMilliseconds()); return this; }; /** * Returns a new Date object that is an exact date and time copy of the original instance. * @return {Date} A new Date instance */ $P.clone = function () { return new Date(this.getTime()); }; /** * Compares this instance to a Date object and returns an number indication of their relative values. * @param {Date} Date object to compare [Required] * @return {Number} -1 = this is lessthan date. 0 = values are equal. 1 = this is greaterthan date. */ $P.compareTo = function (date) { return Date.compare(this, date); }; /** * Compares this instance to another Date object and returns true if they are equal. * @param {Date} Date object to compare. If no date to compare, new Date() [now] is used. * @return {Boolean} true if dates are equal. false if they are not equal. */ $P.equals = function (date) { return Date.equals(this, (date !== undefined ? date : new Date())); }; /** * Determines if this instance is between a range of two dates or equal to either the start or end dates. * @param {Date} Start of range [Required] * @param {Date} End of range [Required] * @return {Boolean} true is this is between or equal to the start and end dates, else false */ $P.between = function (start, end) { return this.getTime() >= start.getTime() && this.getTime() <= end.getTime(); }; /** * Determines if this date occurs after the date to compare to. * @param {Date} Date object to compare. If no date to compare, new Date() ("now") is used. * @return {Boolean} true if this date instance is greater than the date to compare to (or "now"), otherwise false. */ $P.isAfter = function (date) { return this.compareTo(date || new Date()) === 1; }; /** * Determines if this date occurs before the date to compare to. * @param {Date} Date object to compare. If no date to compare, new Date() ("now") is used. * @return {Boolean} true if this date instance is less than the date to compare to (or "now"). */ $P.isBefore = function (date) { return (this.compareTo(date || new Date()) === -1); }; /** * Determines if the current Date instance occurs today. * @return {Boolean} true if this date instance is 'today', otherwise false. */ /** * Determines if the current Date instance occurs on the same Date as the supplied 'date'. * If no 'date' to compare to is provided, the current Date instance is compared to 'today'. * @param {date} Date object to compare. If no date to compare, the current Date ("now") is used. * @return {Boolean} true if this Date instance occurs on the same Day as the supplied 'date'. */ $P.isToday = $P.isSameDay = function (date) { return this.clone().clearTime().equals((date || new Date()).clone().clearTime()); }; /** * Adds the specified number of milliseconds to this instance. * @param {Number} The number of milliseconds to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addMilliseconds = function (value) { if (!value) { return this; } this.setTime(this.getTime() + value * 1); return this; }; /** * Adds the specified number of seconds to this instance. * @param {Number} The number of seconds to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addSeconds = function (value) { if (!value) { return this; } return this.addMilliseconds(value * 1000); }; /** * Adds the specified number of seconds to this instance. * @param {Number} The number of seconds to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addMinutes = function (value) { if (!value) { return this; } return this.addMilliseconds(value * 60000); // 60*1000 }; /** * Adds the specified number of hours to this instance. * @param {Number} The number of hours to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addHours = function (value) { if (!value) { return this; } return this.addMilliseconds(value * 3600000); // 60*60*1000 }; /** * Adds the specified number of days to this instance. * @param {Number} The number of days to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addDays = function (value) { if (!value) { return this; } this.setDate(this.getDate() + value * 1); return this; }; /** * Adds the specified number of weekdays (ie - not sat or sun) to this instance. * @param {Number} The number of days to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addWeekdays = function (value) { if (!value) { return this; } var day = this.getDay(); var weeks = (Math.ceil(Math.abs(value)/7)); if (day === 0 || day === 6) { if (value > 0) { this.next().monday(); this.addDays(-1); day = this.getDay(); } } if (value < 0) { while (value < 0) { this.addDays(-1); day = this.getDay(); if (day !== 0 && day !== 6) { value++; } } return this; } else if (value > 5 || (6-day) <= value) { value = value + (weeks * 2); } return this.addDays(value); }; /** * Adds the specified number of weeks to this instance. * @param {Number} The number of weeks to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addWeeks = function (value) { if (!value) { return this; } return this.addDays(value * 7); }; /** * Adds the specified number of months to this instance. * @param {Number} The number of months to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addMonths = function (value) { if (!value) { return this; } var n = this.getDate(); this.setDate(1); this.setMonth(this.getMonth() + value * 1); this.setDate(Math.min(n, $D.getDaysInMonth(this.getFullYear(), this.getMonth()))); return this; }; $P.addQuarters = function (value) { if (!value) { return this; } // note this will take you to the same point in the quarter as you are now. // i.e. - if you are 15 days into the quarter you'll be 15 days into the resulting one. // bonus: this allows adding fractional quarters return this.addMonths(value * 3); }; /** * Adds the specified number of years to this instance. * @param {Number} The number of years to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addYears = function (value) { if (!value) { return this; } return this.addMonths(value * 12); }; /** * Adds (or subtracts) to the value of the years, months, weeks, days, hours, minutes, seconds, milliseconds of the date instance using given configuration object. Positive and Negative values allowed. * Example

	Date.today().add( { days: 1, months: 1 } )

	new Date().add( { years: -1 } )
	
* @param {Object} Configuration object containing attributes (months, days, etc.) * @return {Date} this */ $P.add = function (config) { if (typeof config === "number") { this._orient = config; return this; } var x = config; if (x.day) { // If we should be a different date than today (eg: for 'tomorrow -1d', etc). // Should only effect parsing, not direct usage (eg, Finish and FinishExact) if ((x.day - this.getDate()) !== 0) { this.setDate(x.day); } } if (x.milliseconds) { this.addMilliseconds(x.milliseconds); } if (x.seconds) { this.addSeconds(x.seconds); } if (x.minutes) { this.addMinutes(x.minutes); } if (x.hours) { this.addHours(x.hours); } if (x.weeks) { this.addWeeks(x.weeks); } if (x.months) { this.addMonths(x.months); } if (x.years) { this.addYears(x.years); } if (x.days) { this.addDays(x.days); } return this; }; /** * Get the week number. Week one (1) is the week which contains the first Thursday of the year. Monday is considered the first day of the week. * The .getWeek() function does NOT convert the date to UTC. The local datetime is used. * Please use .getISOWeek() to get the week of the UTC converted date. * @return {Number} 1 to 53 */ $P.getWeek = function (utc) { // Create a copy of this date object var self, target = new Date(this.valueOf()); if (utc) { target.addMinutes(target.getTimezoneOffset()); self = target.clone(); } else { self = this; } // ISO week date weeks start on monday // so correct the day number var dayNr = (self.getDay() + 6) % 7; // ISO 8601 states that week 1 is the week // with the first thursday of that year. // Set the target date to the thursday in the target week target.setDate(target.getDate() - dayNr + 3); // Store the millisecond value of the target date var firstThursday = target.valueOf(); // Set the target to the first thursday of the year // First set the target to january first target.setMonth(0, 1); // Not a thursday? Correct the date to the next thursday if (target.getDay() !== 4) { target.setMonth(0, 1 + ((4 - target.getDay()) + 7) % 7); } // The weeknumber is the number of weeks between the // first thursday of the year and the thursday in the target week return 1 + Math.ceil((firstThursday - target) / 604800000); // 604800000 = 7 * 24 * 3600 * 1000 }; /** * Get the ISO 8601 week number. Week one ("01") is the week which contains the first Thursday of the year. Monday is considered the first day of the week. * The .getISOWeek() function does convert the date to it's UTC value. Please use .getWeek() to get the week of the local date. * @return {String} "01" to "53" */ $P.getISOWeek = function () { return p(this.getWeek(true)); }; /** * Moves the date to Monday of the week set. Week one (1) is the week which contains the first Thursday of the year. * @param {Number} A Number (1 to 53) that represents the week of the year. * @return {Date} this */ $P.setWeek = function (n) { if ((n - this.getWeek()) === 0) { if (this.getDay() !== 1) { return this.moveToDayOfWeek(1, (this.getDay() > 1 ? -1 : 1)); } else { return this; } } else { return this.moveToDayOfWeek(1, (this.getDay() > 1 ? -1 : 1)).addWeeks(n - this.getWeek()); } }; $P.setQuarter = function (qtr) { var month = Math.abs(((qtr-1) * 3) + 1); return this.setMonth(month, 1); }; $P.getQuarter = function () { return Date.getQuarter(this); }; $P.getDaysLeftInQuarter = function () { return Date.getDaysLeftInQuarter(this); }; /** * Moves the date to the next n'th occurrence of the dayOfWeek starting from the beginning of the month. The number (-1) is a magic number and will return the last occurrence of the dayOfWeek in the month. * @param {Number} The dayOfWeek to move to * @param {Number} The n'th occurrence to move to. Use (-1) to return the last occurrence in the month * @return {Date} this */ $P.moveToNthOccurrence = function (dayOfWeek, occurrence) { if (dayOfWeek === "Weekday") { if (occurrence > 0) { this.moveToFirstDayOfMonth(); if (this.is().weekday()) { occurrence -= 1; } } else if (occurrence < 0) { this.moveToLastDayOfMonth(); if (this.is().weekday()) { occurrence += 1; } } else { return this; } return this.addWeekdays(occurrence); } var shift = 0; if (occurrence > 0) { shift = occurrence - 1; } else if (occurrence === -1) { this.moveToLastDayOfMonth(); if (this.getDay() !== dayOfWeek) { this.moveToDayOfWeek(dayOfWeek, -1); } return this; } return this.moveToFirstDayOfMonth().addDays(-1).moveToDayOfWeek(dayOfWeek, +1).addWeeks(shift); }; var moveToN = function (getFunc, addFunc, nVal) { return function (value, orient) { var diff = (value - this[getFunc]() + nVal * (orient || +1)) % nVal; return this[addFunc]((diff === 0) ? diff += nVal * (orient || +1) : diff); }; }; /** * Move to the next or last dayOfWeek based on the orient value. * @param {Number} The dayOfWeek to move to * @param {Number} Forward (+1) or Back (-1). Defaults to +1. [Optional] * @return {Date} this */ $P.moveToDayOfWeek = moveToN("getDay", "addDays", 7); /** * Move to the next or last month based on the orient value. * @param {Number} The month to move to. 0 = January, 11 = December * @param {Number} Forward (+1) or Back (-1). Defaults to +1. [Optional] * @return {Date} this */ $P.moveToMonth = moveToN("getMonth", "addMonths", 12); /** * Get the Ordinate of the current day ("th", "st", "rd"). * @return {String} */ $P.getOrdinate = function () { var num = this.getDate(); return ord(num); }; /** * Get the Ordinal day (numeric day number) of the year, adjusted for leap year. * @return {Number} 1 through 365 (366 in leap years) */ $P.getOrdinalNumber = function () { return Math.ceil((this.clone().clearTime() - new Date(this.getFullYear(), 0, 1)) / 86400000) + 1; }; /** * Get the time zone abbreviation of the current date. * @return {String} The abbreviated time zone name (e.g. "EST") */ $P.getTimezone = function () { return $D.getTimezoneAbbreviation(this.getUTCOffset(), this.isDaylightSavingTime()); }; $P.setTimezoneOffset = function (offset) { var here = this.getTimezoneOffset(), there = Number(offset) * -6 / 10; return (there || there === 0) ? this.addMinutes(there - here) : this; }; $P.setTimezone = function (offset) { return this.setTimezoneOffset($D.getTimezoneOffset(offset)); }; /** * Indicates whether Daylight Saving Time is observed in the current time zone. * @return {Boolean} true|false */ $P.hasDaylightSavingTime = function () { return (Date.today().set({month: 0, day: 1}).getTimezoneOffset() !== Date.today().set({month: 6, day: 1}).getTimezoneOffset()); }; /** * Indicates whether this Date instance is within the Daylight Saving Time range for the current time zone. * @return {Boolean} true|false */ $P.isDaylightSavingTime = function () { return Date.today().set({month: 0, day: 1}).getTimezoneOffset() !== this.getTimezoneOffset(); }; /** * Get the offset from UTC of the current date. * @return {String} The 4-character offset string prefixed with + or - (e.g. "-0500") */ $P.getUTCOffset = function (offset) { var n = (offset || this.getTimezoneOffset()) * -10 / 6, r; if (n < 0) { r = (n - 10000).toString(); return r.charAt(0) + r.substr(2); } else { r = (n + 10000).toString(); return "+" + r.substr(1); } }; /** * Returns the number of milliseconds between this date and date. * @param {Date} Defaults to now * @return {Number} The diff in milliseconds */ $P.getElapsed = function (date) { return (date || new Date()) - this; }; /** * Set the value of year, month, day, hour, minute, second, millisecond of date instance using given configuration object. * Example

	Date.today().set( { day: 20, month: 1 } )

	new Date().set( { millisecond: 0 } )
	
* * @param {Object} Configuration object containing attributes (month, day, etc.) * @return {Date} this */ $P.set = function (config) { config = validateConfigObject.call(this, config); var key; for (key in config) { if (Object.prototype.hasOwnProperty.call(config, key)) { var name = key.charAt(0).toUpperCase() + key.slice(1); var addFunc, getFunc; if (key !== "week" && key !== "month" && key !== "timezone" && key !== "timezoneOffset") { name += "s"; } addFunc = "add" + name; getFunc = "get" + name; if (key === "month") { addFunc = addFunc + "s"; } else if (key === "year"){ getFunc = "getFullYear"; } if (key !== "day" && key !== "timezone" && key !== "timezoneOffset" && key !== "week" && key !== "hour") { this[addFunc](config[key] - this[getFunc]()); } else if ( key === "timezone"|| key === "timezoneOffset" || key === "week" || key === "hour") { this["set"+name](config[key]); } } } // day has to go last because you can't validate the day without first knowing the month if (config.day) { this.addDays(config.day - this.getDate()); } return this; }; /** * Moves the date to the first day of the month. * @return {Date} this */ $P.moveToFirstDayOfMonth = function () { return this.set({ day: 1 }); }; /** * Moves the date to the last day of the month. * @return {Date} this */ $P.moveToLastDayOfMonth = function () { return this.set({ day: $D.getDaysInMonth(this.getFullYear(), this.getMonth())}); }; /** * Converts the value of the current Date object to its equivalent string representation. * Format Specifiers * CUSTOM DATE AND TIME FORMAT STRINGS * Format Description Example * ------ --------------------------------------------------------------------------- ----------------------- * s The seconds of the minute between 0-59. "0" to "59" * ss The seconds of the minute with leading zero if required. "00" to "59" * * m The minute of the hour between 0-59. "0" or "59" * mm The minute of the hour with leading zero if required. "00" or "59" * * h The hour of the day between 1-12. "1" to "12" * hh The hour of the day with leading zero if required. "01" to "12" * * H The hour of the day between 0-23. "0" to "23" * HH The hour of the day with leading zero if required. "00" to "23" * * d The day of the month between 1 and 31. "1" to "31" * dd The day of the month with leading zero if required. "01" to "31" * ddd Abbreviated day name. Date.CultureInfo.abbreviatedDayNames. "Mon" to "Sun" * dddd The full day name. Date.CultureInfo.dayNames. "Monday" to "Sunday" * * M The month of the year between 1-12. "1" to "12" * MM The month of the year with leading zero if required. "01" to "12" * MMM Abbreviated month name. Date.CultureInfo.abbreviatedMonthNames. "Jan" to "Dec" * MMMM The full month name. Date.CultureInfo.monthNames. "January" to "December" * * yy The year as a two-digit number. "99" or "08" * yyyy The full four digit year. "1999" or "2008" * * t Displays the first character of the A.M./P.M. designator. "A" or "P" * Date.CultureInfo.amDesignator or Date.CultureInfo.pmDesignator * tt Displays the A.M./P.M. designator. "AM" or "PM" * Date.CultureInfo.amDesignator or Date.CultureInfo.pmDesignator * * S The ordinal suffix ("st, "nd", "rd" or "th") of the current day. "st, "nd", "rd" or "th" * * STANDARD DATE AND TIME FORMAT STRINGS * Format Description Example *------ --------------------------------------------------------------------------- ----------------------- * d The CultureInfo shortDate Format Pattern "M/d/yyyy" * D The CultureInfo longDate Format Pattern "dddd, MMMM dd, yyyy" * F The CultureInfo fullDateTime Format Pattern "dddd, MMMM dd, yyyy h:mm:ss tt" * m The CultureInfo monthDay Format Pattern "MMMM dd" * r The CultureInfo rfc1123 Format Pattern "ddd, dd MMM yyyy HH:mm:ss GMT" * s The CultureInfo sortableDateTime Format Pattern "yyyy-MM-ddTHH:mm:ss" * t The CultureInfo shortTime Format Pattern "h:mm tt" * T The CultureInfo longTime Format Pattern "h:mm:ss tt" * u The CultureInfo universalSortableDateTime Format Pattern "yyyy-MM-dd HH:mm:ssZ" * y The CultureInfo yearMonth Format Pattern "MMMM, yyyy" * * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @return {String} A string representation of the current Date object. */ var ord = function (n) { switch (n * 1) { case 1: case 21: case 31: return "st"; case 2: case 22: return "nd"; case 3: case 23: return "rd"; default: return "th"; } }; var parseStandardFormats = function (format) { var y, c = Date.CultureInfo.formatPatterns; switch (format) { case "d": return this.toString(c.shortDate); case "D": return this.toString(c.longDate); case "F": return this.toString(c.fullDateTime); case "m": return this.toString(c.monthDay); case "r": case "R": y = this.clone().addMinutes(this.getTimezoneOffset()); return y.toString(c.rfc1123) + " GMT"; case "s": return this.toString(c.sortableDateTime); case "t": return this.toString(c.shortTime); case "T": return this.toString(c.longTime); case "u": y = this.clone().addMinutes(this.getTimezoneOffset()); return y.toString(c.universalSortableDateTime); case "y": return this.toString(c.yearMonth); default: return false; } }; var parseFormatStringsClosure = function (context) { return function (m) { if (m.charAt(0) === "\\") { return m.replace("\\", ""); } switch (m) { case "hh": return p(context.getHours() < 13 ? (context.getHours() === 0 ? 12 : context.getHours()) : (context.getHours() - 12)); case "h": return context.getHours() < 13 ? (context.getHours() === 0 ? 12 : context.getHours()) : (context.getHours() - 12); case "HH": return p(context.getHours()); case "H": return context.getHours(); case "mm": return p(context.getMinutes()); case "m": return context.getMinutes(); case "ss": return p(context.getSeconds()); case "s": return context.getSeconds(); case "yyyy": return p(context.getFullYear(), 4); case "yy": return p(context.getFullYear()); case "y": return context.getFullYear(); case "E": case "dddd": return Date.CultureInfo.dayNames[context.getDay()]; case "ddd": return Date.CultureInfo.abbreviatedDayNames[context.getDay()]; case "dd": return p(context.getDate()); case "d": return context.getDate(); case "MMMM": return Date.CultureInfo.monthNames[context.getMonth()]; case "MMM": return Date.CultureInfo.abbreviatedMonthNames[context.getMonth()]; case "MM": return p((context.getMonth() + 1)); case "M": return context.getMonth() + 1; case "t": return context.getHours() < 12 ? Date.CultureInfo.amDesignator.substring(0, 1) : Date.CultureInfo.pmDesignator.substring(0, 1); case "tt": return context.getHours() < 12 ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator; case "S": return ord(context.getDate()); case "W": return context.getWeek(); case "WW": return context.getISOWeek(); case "Q": return "Q" + context.getQuarter(); case "q": return String(context.getQuarter()); case "z": return context.getTimezone(); case "Z": case "X": return Date.getTimezoneOffset(context.getTimezone()); case "ZZ": // Timezone offset in seconds return context.getTimezoneOffset() * -60; case "u": return context.getDay(); case "L": return ($D.isLeapYear(context.getFullYear())) ? 1 : 0; case "B": // Swatch Internet Time (.beats) return "@"+((context.getUTCSeconds() + (context.getUTCMinutes()*60) + ((context.getUTCHours()+1)*3600))/86.4); default: return m; } }; }; $P.toString = function (format, ignoreStandards) { // Standard Date and Time Format Strings. Formats pulled from CultureInfo file and // may vary by culture. if (!ignoreStandards && format && format.length === 1) { output = parseStandardFormats.call(this, format); if (output) { return output; } } var parseFormatStrings = parseFormatStringsClosure(this); return format ? format.replace(/((\\)?(dd?d?d?|MM?M?M?|yy?y?y?|hh?|HH?|mm?|ss?|tt?|S|q|Q|WW?W?W?)(?![^\[]*\]))/g, parseFormatStrings).replace(/\[|\]/g, "") : this._toString(); }; }()); /************************************************************* * SugarPak - Domain Specific Language - Syntactical Sugar * *************************************************************/ (function () { var $D = Date, $P = $D.prototype, $N = Number.prototype; // private $P._orient = +1; // private $P._nth = null; // private $P._is = false; // private $P._same = false; // private $P._isSecond = false; // private $N._dateElement = "days"; /** * Moves the date to the next instance of a date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.today().next().friday();
	Date.today().next().fri();
	Date.today().next().march();
	Date.today().next().mar();
	Date.today().next().week();
	
* * @return {Date} date */ $P.next = function () { this._move = true; this._orient = +1; return this; }; /** * Creates a new Date (Date.today()) and moves the date to the next instance of the date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.next().friday();
	Date.next().fri();
	Date.next().march();
	Date.next().mar();
	Date.next().week();
	
* * @return {Date} date */ $D.next = function () { return $D.today().next(); }; /** * Moves the date to the previous instance of a date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.today().last().friday();
	Date.today().last().fri();
	Date.today().last().march();
	Date.today().last().mar();
	Date.today().last().week();
	
* * @return {Date} date */ $P.last = $P.prev = $P.previous = function () { this._move = true; this._orient = -1; return this; }; /** * Creates a new Date (Date.today()) and moves the date to the previous instance of the date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.last().friday();
	Date.last().fri();
	Date.previous().march();
	Date.prev().mar();
	Date.last().week();
	
* * @return {Date} date */ $D.last = $D.prev = $D.previous = function () { return $D.today().last(); }; /** * Performs a equality check when followed by either a month name, day name or .weekday() function. * Example

	Date.today().is().friday(); // true|false
	Date.today().is().fri();
	Date.today().is().march();
	Date.today().is().mar();
	
* * @return {Boolean} true|false */ $P.is = function () { this._is = true; return this; }; /** * Determines if two date objects occur on/in exactly the same instance of the subsequent date part function. * The function .same() must be followed by a date part function (example: .day(), .month(), .year(), etc). * * An optional Date can be passed in the date part function. If now date is passed as a parameter, 'Now' is used. * * The following example demonstrates how to determine if two dates fall on the exact same day. * * Example

	var d1 = Date.today(); // today at 00:00
	var d2 = new Date();   // exactly now.

	// Do they occur on the same day?
	d1.same().day(d2); // true
	
	// Do they occur on the same hour?
	d1.same().hour(d2); // false, unless d2 hour is '00' (midnight).
	
	// What if it's the same day, but one year apart?
	var nextYear = Date.today().add(1).year();

	d1.same().day(nextYear); // false, because the dates must occur on the exact same day. 
	
* * Scenario: Determine if a given date occurs during some week period 2 months from now. * * Example

	var future = Date.today().add(2).months();
	return someDate.same().week(future); // true|false;
	
* * @return {Boolean} true|false */ $P.same = function () { this._same = true; this._isSecond = false; return this; }; /** * Determines if the current date/time occurs during Today. Must be preceded by the .is() function. * Example

	someDate.is().today();    // true|false
	new Date().is().today();  // true
	Date.today().is().today();// true
	Date.today().add(-1).day().is().today(); // false
	
* * @return {Boolean} true|false */ $P.today = function () { return this.same().day(); }; /** * Determines if the current date is a weekday. This function must be preceded by the .is() function. * Example

	Date.today().is().weekday(); // true|false
	
* * @return {Boolean} true|false */ $P.weekday = function () { if (this._nth) { return df("Weekday").call(this); } if (this._move) { return this.addWeekdays(this._orient); } if (this._is) { this._is = false; return (!this.is().sat() && !this.is().sun()); } return false; }; /** * Determines if the current date is on the weekend. This function must be preceded by the .is() function. * Example

	Date.today().is().weekend(); // true|false
	
* * @return {Boolean} true|false */ $P.weekend = function () { if (this._is) { this._is = false; return (this.is().sat() || this.is().sun()); } return false; }; /** * Sets the Time of the current Date instance. A string "6:15 pm" or config object {hour:18, minute:15} are accepted. * Example

	// Set time to 6:15pm with a String
	Date.today().at("6:15pm");

	// Set time to 6:15pm with a config object
	Date.today().at({hour:18, minute:15});
	
* * @return {Date} date */ $P.at = function (time) { return (typeof time === "string") ? $D.parse(this.toString("d") + " " + time) : this.set(time); }; /** * Creates a new Date() and adds this (Number) to the date based on the preceding date element function (eg. second|minute|hour|day|month|year). * Example

	// Undeclared Numbers must be wrapped with parentheses. Requirment of JavaScript.
	(3).days().fromNow();
	(6).months().fromNow();

	// Declared Number variables do not require parentheses. 
	var n = 6;
	n.months().fromNow();
	
* * @return {Date} A new Date instance */ $N.fromNow = $N.after = function (date) { var c = {}; c[this._dateElement] = this; return ((!date) ? new Date() : date.clone()).add(c); }; /** * Creates a new Date() and subtract this (Number) from the date based on the preceding date element function (eg. second|minute|hour|day|month|year). * Example

	// Undeclared Numbers must be wrapped with parentheses. Requirment of JavaScript.
	(3).days().ago();
	(6).months().ago();

	// Declared Number variables do not require parentheses. 
	var n = 6;
	n.months().ago();
	
* * @return {Date} A new Date instance */ $N.ago = $N.before = function (date) { var c = {}, s = (this._dateElement[this._dateElement.length-1] !== "s") ? this._dateElement + "s" : this._dateElement; c[s] = this * -1; return ((!date) ? new Date() : date.clone()).add(c); }; // Do NOT modify the following string tokens. These tokens are used to build dynamic functions. // All culture-specific strings can be found in the CultureInfo files. var dx = ("sunday monday tuesday wednesday thursday friday saturday").split(/\s/), mx = ("january february march april may june july august september october november december").split(/\s/), px = ("Millisecond Second Minute Hour Day Week Month Year Quarter Weekday").split(/\s/), pxf = ("Milliseconds Seconds Minutes Hours Date Week Month FullYear Quarter").split(/\s/), nth = ("final first second third fourth fifth").split(/\s/), de; /** * Returns an object literal of all the date parts. * Example

	var o = new Date().toObject();
	
	// { year: 2008, month: 4, week: 20, day: 13, hour: 18, minute: 9, second: 32, millisecond: 812 }
	
	// The object properties can be referenced directly from the object.
	
	alert(o.day);  // alerts "13"
	alert(o.year); // alerts "2008"
	
* * @return {Date} An object literal representing the original date object. */ $P.toObject = function () { var o = {}; for (var i = 0; i < px.length; i++) { if (this["get" + pxf[i]]) { o[px[i].toLowerCase()] = this["get" + pxf[i]](); } } return o; }; /** * Returns a date created from an object literal. Ignores the .week property if set in the config. * Example

	var o = new Date().toObject();
	
	return Date.fromObject(o); // will return the same date. 

	var o2 = {month: 1, day: 20, hour: 18}; // birthday party!
	Date.fromObject(o2);
	
* * @return {Date} An object literal representing the original date object. */ $D.fromObject = function(config) { config.week = null; return Date.today().set(config); }; // Create day name functions and abbreviated day name functions (eg. monday(), friday(), fri()). var df = function (n) { return function () { if (this._is) { this._is = false; return this.getDay() === n; } if (this._move) { this._move = null; } if (this._nth !== null) { // If the .second() function was called earlier, remove the _orient // from the date, and then continue. // This is required because 'second' can be used in two different context. // // Example // // Date.today().add(1).second(); // Date.march().second().monday(); // // Things get crazy with the following... // Date.march().add(1).second().second().monday(); // but it works!! // if (this._isSecond) { this.addSeconds(this._orient * -1); } // make sure we reset _isSecond this._isSecond = false; var ntemp = this._nth; this._nth = null; var temp = this.clone().moveToLastDayOfMonth(); this.moveToNthOccurrence(n, ntemp); if (this > temp) { throw new RangeError($D.getDayName(n) + " does not occur " + ntemp + " times in the month of " + $D.getMonthName(temp.getMonth()) + " " + temp.getFullYear() + "."); } return this; } return this.moveToDayOfWeek(n, this._orient); }; }; var sdf = function (n) { return function () { var t = $D.today(), shift = n - t.getDay(); if (n === 0 && Date.CultureInfo.firstDayOfWeek === 1 && t.getDay() !== 0) { shift = shift + 7; } return t.addDays(shift); }; }; // Create month name functions and abbreviated month name functions (eg. january(), march(), mar()). var month_instance_functions = function (n) { return function () { if (this._is) { this._is = false; return this.getMonth() === n; } return this.moveToMonth(n, this._orient); }; }; var month_static_functions = function (n) { return function () { return $D.today().set({ month: n, day: 1 }); }; }; var processTerms = function (names, staticFunc, instanceFunc) { for (var i = 0; i < names.length; i++) { // Create constant static Name variables. $D[names[i].toUpperCase()] = $D[names[i].toUpperCase().substring(0, 3)] = i; // Create Name functions. $D[names[i]] = $D[names[i].substring(0, 3)] = staticFunc(i); // Create Name instance functions. $P[names[i]] = $P[names[i].substring(0, 3)] = instanceFunc(i); } }; processTerms(dx, sdf, df); processTerms(mx, month_static_functions, month_instance_functions); // Create date element functions and plural date element functions used with Date (eg. day(), days(), months()). var ef = function (j) { return function () { // if the .second() function was called earlier, the _orient // has alread been added. Just return this and reset _isSecond. if (this._isSecond) { this._isSecond = false; return this; } if (this._same) { this._same = this._is = false; var o1 = this.toObject(), o2 = (arguments[0] || new Date()).toObject(), v = "", k = j.toLowerCase(); // the substr trick with -1 doesn't work in IE8 or less k = (k[k.length-1] === "s") ? k.substring(0,k.length-1) : k; for (var m = (px.length - 1); m > -1; m--) { v = px[m].toLowerCase(); if (o1[v] !== o2[v]) { return false; } if (k === v) { break; } } return true; } if (j.substring(j.length - 1) !== "s") { j += "s"; } if (this._move) { this._move = null; } return this["add" + j](this._orient); }; }; var nf = function (n) { return function () { this._dateElement = n; return this; }; }; for (var k = 0; k < px.length; k++) { de = px[k].toLowerCase(); if(de !== "weekday") { // Create date element functions and plural date element functions used with Date (eg. day(), days(), months()). $P[de] = $P[de + "s"] = ef(px[k]); // Create date element functions and plural date element functions used with Number (eg. day(), days(), months()). $N[de] = $N[de + "s"] = nf(de + "s"); } } $P._ss = ef("Second"); var nthfn = function (n) { return function (dayOfWeek) { if (this._same) { return this._ss(arguments[0]); } if (dayOfWeek || dayOfWeek === 0) { return this.moveToNthOccurrence(dayOfWeek, n); } this._nth = n; // if the operator is 'second' add the _orient, then deal with it later... if (n === 2 && (dayOfWeek === undefined || dayOfWeek === null)) { this._isSecond = true; return this.addSeconds(this._orient); } return this; }; }; for (var l = 0; l < nth.length; l++) { $P[nth[l]] = (l === 0) ? nthfn(-1) : nthfn(l); } }()); (function () { "use strict"; Date.Parsing = { Exception: function (s) { this.message = "Parse error at '" + s.substring(0, 10) + " ...'"; } }; var $P = Date.Parsing; var dayOffsets = { standard: [0,31,59,90,120,151,181,212,243,273,304,334], leap: [0,31,60,91,121,152,182,213,244,274,305,335] }; $P.isLeapYear = function(year) { return ((year % 4 === 0) && (year % 100 !== 0)) || (year % 400 === 0); }; var utils = { multiReplace : function (str, hash ) { var key; for (key in hash) { if (Object.prototype.hasOwnProperty.call(hash, key)) { var regex; if (typeof hash[key] === "function") { } else { regex = (hash[key] instanceof RegExp) ? hash[key] : new RegExp(hash[key], "g"); } str = str.replace(regex, key); } } return str; }, getDayOfYearFromWeek : function (obj) { var d, jan4, offset; obj.weekDay = (!obj.weekDay && obj.weekDay !== 0) ? 1 : obj.weekDay; d = new Date(obj.year, 0, 4); jan4 = d.getDay() === 0 ? 7 : d.getDay(); // JS is 0 indexed on Sunday. offset = jan4+3; obj.dayOfYear = ((obj.week * 7) + (obj.weekDay === 0 ? 7 : obj.weekDay))-offset; return obj; }, getDayOfYear : function (obj, dayOffset) { if (!obj.dayOfYear) { obj = utils.getDayOfYearFromWeek(obj); } for (var i=0;i <= dayOffset.length;i++) { if (obj.dayOfYear < dayOffset[i] || i === dayOffset.length) { obj.day = obj.day ? obj.day : (obj.dayOfYear - dayOffset[i-1]); break; } else { obj.month = i; } } return obj; }, adjustForTimeZone : function (obj, date) { var offset; if (obj.zone.toUpperCase() === "Z" || (obj.zone_hours === 0 && obj.zone_minutes === 0)) { // it's UTC/GML so work out the current timeszone offset offset = -date.getTimezoneOffset(); } else { offset = (obj.zone_hours*60) + (obj.zone_minutes || 0); if (obj.zone_sign === "+") { offset *= -1; } offset -= date.getTimezoneOffset(); } date.setMinutes(date.getMinutes()+offset); return date; }, setDefaults : function (obj) { obj.year = obj.year || Date.today().getFullYear(); obj.hours = obj.hours || 0; obj.minutes = obj.minutes || 0; obj.seconds = obj.seconds || 0; obj.milliseconds = obj.milliseconds || 0; if (!(!obj.month && (obj.week || obj.dayOfYear))) { // if we have a month, or if we don't but don't have the day calculation data obj.month = obj.month || 0; obj.day = obj.day || 1; } return obj; }, dataNum: function (data, mod, explict, postProcess) { var dataNum = data*1; if (mod) { if (postProcess) { return data ? mod(data)*1 : data; } else { return data ? mod(dataNum) : data; } } else if (!explict){ return data ? dataNum : data; } else { return (data && typeof data !== "undefined") ? dataNum : data; } }, timeDataProcess: function (obj) { var timeObj = {}; for (var x in obj.data) { if (obj.data.hasOwnProperty(x)) { timeObj[x] = obj.ignore[x] ? obj.data[x] : utils.dataNum(obj.data[x], obj.mods[x], obj.explict[x], obj.postProcess[x]); } } if (obj.data.secmins) { obj.data.secmins = obj.data.secmins.replace(",", ".") * 60; if (!timeObj.minutes) { timeObj.minutes = obj.data.secmins; } else if (!timeObj.seconds) { timeObj.seconds = obj.data.secmins; } delete obj.secmins; } return timeObj; }, buildTimeObjectFromData: function (data) { var time = utils.timeDataProcess({ data: { year : data[1], month : data[5], day : data[7], week : data[8], dayOfYear : data[10], hours : data[15], zone_hours : data[23], zone_minutes : data[24], zone : data[21], zone_sign : data[22], weekDay : data[9], minutes: data[16], seconds: data[19], milliseconds: data[20], secmins: data[18] }, mods: { month: function(data) { return data-1; }, weekDay: function (data) { data = Math.abs(data); return (data === 7 ? 0 : data); }, minutes: function (data) { return data.replace(":",""); }, seconds: function (data) { return Math.floor( (data.replace(":","").replace(",","."))*1 ); }, milliseconds: function (data) { return (data.replace(",",".")*1000); } }, postProcess: { minutes: true, seconds: true, milliseconds: true }, explict: { zone_hours: true, zone_minutes: true }, ignore: { zone: true, zone_sign: true, secmins: true } }); return time; }, addToHash: function (hash, keys, data) { keys = keys; data = data; var len = keys.length; for (var i = 0; i < len; i++) { hash[keys[i]] = data[i]; } return hash; }, combineRegex: function (r1, r2) { return new RegExp("(("+r1.source+")\\s("+r2.source+"))"); }, getDateNthString: function(add, last, inc){ if (add) { return Date.today().addDays(inc).toString("d"); } else if (last) { return Date.today().last()[inc]().toString("d"); } }, buildRegexData: function (array) { var arr = []; var len = array.length; for (var i=0; i < len; i++) { if (Object.prototype.toString.call(array[i]) === '[object Array]') { // oldIE compat version of Array.isArray arr.push(this.combineRegex(array[i][0], array[i][1])); } else { arr.push(array[i]); } } return arr; } }; $P.processTimeObject = function (obj) { var date, dayOffset; utils.setDefaults(obj); dayOffset = ($P.isLeapYear(obj.year)) ? dayOffsets.leap : dayOffsets.standard; if (!obj.month && (obj.week || obj.dayOfYear)) { utils.getDayOfYear(obj, dayOffset); } else { obj.dayOfYear = dayOffset[obj.month] + obj.day; } date = new Date(obj.year, obj.month, obj.day, obj.hours, obj.minutes, obj.seconds, obj.milliseconds); if (obj.zone) { utils.adjustForTimeZone(obj, date); // adjust (and calculate) for timezone } return date; }; $P.ISO = { regex : /^([\+-]?\d{4}(?!\d{2}\b))((-?)((0[1-9]|1[0-2])(\3([12]\d|0[1-9]|3[01]))?|W([0-4]\d|5[0-3])(-?[1-7])?|(00[1-9]|0[1-9]\d|[12]\d{2}|3([0-5]\d|6[1-6])))([T\s]((([01]\d|2[0-4])((:?)[0-5]\d)?|24\:?00)([\.,]\d+(?!:))?)?(\17[0-5]\d([\.,]\d+)?)?\s?([zZ]|([\+-])([01]\d|2[0-3]):?([0-5]\d)?)?)?)?$/, parse : function (s) { var time, data = s.match(this.regex); if (!data || !data.length) { return null; } time = utils.buildTimeObjectFromData(data); if (!time.year || (!time.year && (!time.month && !time.day) && (!time.week && !time.dayOfYear)) ) { return null; } return $P.processTimeObject(time); } }; $P.Numeric = { isNumeric: function (e){return!isNaN(parseFloat(e))&&isFinite(e);}, regex: /\b([0-1]?[0-9])([0-3]?[0-9])([0-2]?[0-9]?[0-9][0-9])\b/i, parse: function (s) { var data, i, time = {}, order = Date.CultureInfo.dateElementOrder.split(""); if (!(this.isNumeric(s)) || // if it's non-numeric OR (s[0] === "+" && s[0] === "-")) { // It's an arithmatic string (eg +/-1000) return null; } if (s.length < 5 && s.indexOf(".") < 0 && s.indexOf("/") < 0) { // assume it's just a year. time.year = s; return $P.processTimeObject(time); } data = s.match(this.regex); if (!data || !data.length) { return null; } for (i=0; i < order.length; i++) { switch(order[i]) { case "d": time.day = data[i+1]; break; case "m": time.month = (data[i+1]-1); break; case "y": time.year = data[i+1]; break; } } return $P.processTimeObject(time); } }; $P.Normalizer = { regexData: function () { var $R = Date.CultureInfo.regexPatterns; return utils.buildRegexData([ $R.tomorrow, $R.yesterday, [$R.past, $R.mon], [$R.past, $R.tue], [$R.past, $R.wed], [$R.past, $R.thu], [$R.past, $R.fri], [$R.past, $R.sat], [$R.past, $R.sun] ]); }, basicReplaceHash : function() { var $R = Date.CultureInfo.regexPatterns; return { "January": $R.jan.source, "February": $R.feb, "March": $R.mar, "April": $R.apr, "May": $R.may, "June": $R.jun, "July": $R.jul, "August": $R.aug, "September": $R.sep, "October": $R.oct, "November": $R.nov, "December": $R.dec, "": /\bat\b/gi, " ": /\s{2,}/, "am": $R.inTheMorning, "9am": $R.thisMorning, "pm": $R.inTheEvening, "7pm":$R.thisEvening }; }, keys : function(){ return [ utils.getDateNthString(true, false, 1), // tomorrow utils.getDateNthString(true, false, -1), // yesterday utils.getDateNthString(false, true, "monday"), //last mon utils.getDateNthString(false, true, "tuesday"), //last tues utils.getDateNthString(false, true, "wednesday"), //last wed utils.getDateNthString(false, true, "thursday"), //last thurs utils.getDateNthString(false, true, "friday"), //last fri utils.getDateNthString(false, true, "saturday"), //last sat utils.getDateNthString(false, true, "sunday") //last sun ]; }, buildRegexFunctions: function () { var $R = Date.CultureInfo.regexPatterns; var __ = Date.i18n.__; var tomorrowRE = new RegExp("(\\b\\d\\d?("+__("AM")+"|"+__("PM")+")? )("+$R.tomorrow.source.slice(1)+")", "i"); // adapted tomorrow regex for AM PM relative dates var todayRE = new RegExp($R.today.source + "(?!\\s*([+-]))\\b"); // today, but excludes the math operators (eg "today + 2h") this.replaceFuncs = [ [todayRE, function (full) { return (full.length > 1) ? Date.today().toString("d") : full; }], [tomorrowRE, function(full, m1) { var t = Date.today().addDays(1).toString("d"); return (t + " " + m1); }], [$R.amThisMorning, function(str, am){return am;}], [$R.pmThisEvening, function(str, pm){return pm;}] ]; }, buildReplaceData: function () { this.buildRegexFunctions(); this.replaceHash = utils.addToHash(this.basicReplaceHash(), this.keys(), this.regexData()); }, stringReplaceFuncs: function (s) { for (var i=0; i < this.replaceFuncs.length; i++) { s = s.replace(this.replaceFuncs[i][0], this.replaceFuncs[i][1]); } return s; }, parse: function (s) { s = this.stringReplaceFuncs(s); s = utils.multiReplace(s, this.replaceHash); try { var n = s.split(/([\s\-\.\,\/\x27]+)/); if (n.length === 3 && $P.Numeric.isNumeric(n[0]) && $P.Numeric.isNumeric(n[2]) && (n[2].length >= 4)) { // ok, so we're dealing with x/year. But that's not a full date. // This fixes wonky dateElementOrder parsing when set to dmy order. if (Date.CultureInfo.dateElementOrder[0] === "d") { s = "1/" + n[0] + "/" + n[2]; // set to 1st of month and normalize the seperator } } } catch (e) {} return s; } }; $P.Normalizer.buildReplaceData(); }()); (function () { var $P = Date.Parsing; var _ = $P.Operators = { // // Tokenizers // rtoken: function (r) { // regex token return function (s) { var mx = s.match(r); if (mx) { return ([ mx[0], s.substring(mx[0].length) ]); } else { throw new $P.Exception(s); } }; }, token: function () { // whitespace-eating token return function (s) { return _.rtoken(new RegExp("^\\s*" + s + "\\s*"))(s); }; }, stoken: function (s) { // string token return _.rtoken(new RegExp("^" + s)); }, // Atomic Operators until: function (p) { return function (s) { var qx = [], rx = null; while (s.length) { try { rx = p.call(this, s); } catch (e) { qx.push(rx[0]); s = rx[1]; continue; } break; } return [ qx, s ]; }; }, many: function (p) { return function (s) { var rx = [], r = null; while (s.length) { try { r = p.call(this, s); } catch (e) { return [ rx, s ]; } rx.push(r[0]); s = r[1]; } return [ rx, s ]; }; }, // generator operators -- see below optional: function (p) { return function (s) { var r = null; try { r = p.call(this, s); } catch (e) { return [ null, s ]; } return [ r[0], r[1] ]; }; }, not: function (p) { return function (s) { try { p.call(this, s); } catch (e) { return [null, s]; } throw new $P.Exception(s); }; }, ignore: function (p) { return p ? function (s) { var r = null; r = p.call(this, s); return [null, r[1]]; } : null; }, product: function () { var px = arguments[0], qx = Array.prototype.slice.call(arguments, 1), rx = []; for (var i = 0 ; i < px.length ; i++) { rx.push(_.each(px[i], qx)); } return rx; }, cache: function (rule) { var cache = {}, cache_length = 0, cache_keys = [], CACHE_MAX = Date.Config.CACHE_MAX || 100000, r = null; var cacheCheck = function () { if (cache_length === CACHE_MAX) { // kill several keys, don't want to have to do this all the time... for (var i=0; i < 10; i++) { var key = cache_keys.shift(); if (key) { delete cache[key]; cache_length--; } } } }; return function (s) { cacheCheck(); try { r = cache[s] = (cache[s] || rule.call(this, s)); } catch (e) { r = cache[s] = e; } cache_length++; cache_keys.push(s); if (r instanceof $P.Exception) { throw r; } else { return r; } }; }, // vector operators -- see below any: function () { var px = arguments; return function (s) { var r = null; for (var i = 0; i < px.length; i++) { if (px[i] == null) { continue; } try { r = (px[i].call(this, s)); } catch (e) { r = null; } if (r) { return r; } } throw new $P.Exception(s); }; }, each: function () { var px = arguments; return function (s) { var rx = [], r = null; for (var i = 0; i < px.length ; i++) { if (px[i] == null) { continue; } try { r = (px[i].call(this, s)); } catch (e) { throw new $P.Exception(s); } rx.push(r[0]); s = r[1]; } return [ rx, s]; }; }, all: function () { var px = arguments, _ = _; return _.each(_.optional(px)); }, // delimited operators sequence: function (px, d, c) { d = d || _.rtoken(/^\s*/); c = c || null; if (px.length === 1) { return px[0]; } return function (s) { var r = null, q = null; var rx = []; for (var i = 0; i < px.length ; i++) { try { r = px[i].call(this, s); } catch (e) { break; } rx.push(r[0]); try { q = d.call(this, r[1]); } catch (ex) { q = null; break; } s = q[1]; } if (!r) { throw new $P.Exception(s); } if (q) { throw new $P.Exception(q[1]); } if (c) { try { r = c.call(this, r[1]); } catch (ey) { throw new $P.Exception(r[1]); } } return [ rx, (r?r[1]:s) ]; }; }, // // Composite Operators // between: function (d1, p, d2) { d2 = d2 || d1; var _fn = _.each(_.ignore(d1), p, _.ignore(d2)); return function (s) { var rx = _fn.call(this, s); return [[rx[0][0], r[0][2]], rx[1]]; }; }, list: function (p, d, c) { d = d || _.rtoken(/^\s*/); c = c || null; return (p instanceof Array ? _.each(_.product(p.slice(0, -1), _.ignore(d)), p.slice(-1), _.ignore(c)) : _.each(_.many(_.each(p, _.ignore(d))), px, _.ignore(c))); }, set: function (px, d, c) { d = d || _.rtoken(/^\s*/); c = c || null; return function (s) { // r is the current match, best the current 'best' match // which means it parsed the most amount of input var r = null, p = null, q = null, rx = null, best = [[], s], last = false; // go through the rules in the given set for (var i = 0; i < px.length ; i++) { // last is a flag indicating whether this must be the last element // if there is only 1 element, then it MUST be the last one q = null; p = null; r = null; last = (px.length === 1); // first, we try simply to match the current pattern // if not, try the next pattern try { r = px[i].call(this, s); } catch (e) { continue; } // since we are matching against a set of elements, the first // thing to do is to add r[0] to matched elements rx = [[r[0]], r[1]]; // if we matched and there is still input to parse and // we don't already know this is the last element, // we're going to next check for the delimiter ... // if there's none, or if there's no input left to parse // than this must be the last element after all ... if (r[1].length > 0 && ! last) { try { q = d.call(this, r[1]); } catch (ex) { last = true; } } else { last = true; } // if we parsed the delimiter and now there's no more input, // that means we shouldn't have parsed the delimiter at all // so don't update r and mark this as the last element ... if (!last && q[1].length === 0) { last = true; } // so, if this isn't the last element, we're going to see if // we can get any more matches from the remaining (unmatched) // elements ... if (!last) { // build a list of the remaining rules we can match against, // i.e., all but the one we just matched against var qx = []; for (var j = 0; j < px.length ; j++) { if (i !== j) { qx.push(px[j]); } } // now invoke recursively set with the remaining input // note that we don't include the closing delimiter ... // we'll check for that ourselves at the end p = _.set(qx, d).call(this, q[1]); // if we got a non-empty set as a result ... // (otw rx already contains everything we want to match) if (p[0].length > 0) { // update current result, which is stored in rx ... // basically, pick up the remaining text from p[1] // and concat the result from p[0] so that we don't // get endless nesting ... rx[0] = rx[0].concat(p[0]); rx[1] = p[1]; } } // at this point, rx either contains the last matched element // or the entire matched set that starts with this element. // now we just check to see if this variation is better than // our best so far, in terms of how much of the input is parsed if (rx[1].length < best[1].length) { best = rx; } // if we've parsed all the input, then we're finished if (best[1].length === 0) { break; } } // so now we've either gone through all the patterns trying them // as the initial match; or we found one that parsed the entire // input string ... // if best has no matches, just return empty set ... if (best[0].length === 0) { return best; } // if a closing delimiter is provided, then we have to check it also if (c) { // we try this even if there is no remaining input because the pattern // may well be optional or match empty input ... try { q = c.call(this, best[1]); } catch (ey) { throw new $P.Exception(best[1]); } // it parsed ... be sure to update the best match remaining input best[1] = q[1]; } // if we're here, either there was no closing delimiter or we parsed it // so now we have the best match; just return it! return best; }; }, forward: function (gr, fname) { return function (s) { return gr[fname].call(this, s); }; }, // // Translation Operators // replace: function (rule, repl) { return function (s) { var r = rule.call(this, s); return [repl, r[1]]; }; }, process: function (rule, fn) { return function (s) { var r = rule.call(this, s); return [fn.call(this, r[0]), r[1]]; }; }, min: function (min, rule) { return function (s) { var rx = rule.call(this, s); if (rx[0].length < min) { throw new $P.Exception(s); } return rx; }; } }; // Generator Operators And Vector Operators // Generators are operators that have a signature of F(R) => R, // taking a given rule and returning another rule, such as // ignore, which parses a given rule and throws away the result. // Vector operators are those that have a signature of F(R1,R2,...) => R, // take a list of rules and returning a new rule, such as each. // Generator operators are converted (via the following _generator // function) into functions that can also take a list or array of rules // and return an array of new rules as though the function had been // called on each rule in turn (which is what actually happens). // This allows generators to be used with vector operators more easily. // Example: // each(ignore(foo, bar)) instead of each(ignore(foo), ignore(bar)) // This also turns generators into vector operators, which allows // constructs like: // not(cache(foo, bar)) var _generator = function (op) { function gen() { var args = null, rx = [], px, i; if (arguments.length > 1) { args = Array.prototype.slice.call(arguments); } else if (arguments[0] instanceof Array) { args = arguments[0]; } if (args) { px = args.shift(); if (px.length > 0) { args.unshift(px[i]); rx.push(op.apply(null, args)); args.shift(); return rx; } } else { return op.apply(null, arguments); } } return gen; }; var gx = "optional not ignore cache".split(/\s/); for (var i = 0 ; i < gx.length ; i++) { _[gx[i]] = _generator(_[gx[i]]); } var _vector = function (op) { return function () { if (arguments[0] instanceof Array) { return op.apply(null, arguments[0]); } else { return op.apply(null, arguments); } }; }; var vx = "each any all".split(/\s/); for (var j = 0 ; j < vx.length ; j++) { _[vx[j]] = _vector(_[vx[j]]); } }()); (function () { var $D = Date; var flattenAndCompact = function (ax) { var rx = []; for (var i = 0; i < ax.length; i++) { if (ax[i] instanceof Array) { rx = rx.concat(flattenAndCompact(ax[i])); } else { if (ax[i]) { rx.push(ax[i]); } } } return rx; }; var parseMeridian = function () { if (this.meridian && (this.hour || this.hour === 0)) { if (this.meridian === "a" && this.hour > 11 && Date.Config.strict24hr){ throw "Invalid hour and meridian combination"; } else if (this.meridian === "p" && this.hour < 12 && Date.Config.strict24hr){ throw "Invalid hour and meridian combination"; } else if (this.meridian === "p" && this.hour < 12) { this.hour = this.hour + 12; } else if (this.meridian === "a" && this.hour === 12) { this.hour = 0; } } }; var setDefaults = function () { var now = new Date(); if ((this.hour || this.minute) && (!this.month && !this.year && !this.day)) { this.day = now.getDate(); } if (!this.year) { this.year = now.getFullYear(); } if (!this.month && this.month !== 0) { this.month = now.getMonth(); } if (!this.day) { this.day = 1; } if (!this.hour) { this.hour = 0; } if (!this.minute) { this.minute = 0; } if (!this.second) { this.second = 0; } if (!this.millisecond) { this.millisecond = 0; } }; var finishUtils = { getToday: function () { if (this.now || "hour minute second".indexOf(this.unit) !== -1) { return new Date(); } else { return $D.today(); } }, setDaysFromWeekday: function (today, orient){ var gap; orient = orient || 1; this.unit = "day"; gap = ($D.getDayNumberFromName(this.weekday) - today.getDay()); this.days = gap ? ((gap + (orient * 7)) % 7) : (orient * 7); return this; }, setMonthsFromMonth: function (today, orient) { var gap; orient = orient || 1; this.unit = "month"; gap = (this.month - today.getMonth()); this.months = gap ? ((gap + (orient * 12)) % 12) : (orient * 12); this.month = null; return this; }, setDMYFromWeekday: function () { var d = Date[this.weekday](); this.day = d.getDate(); if (!this.month) { this.month = d.getMonth(); } this.year = d.getFullYear(); return this; }, setUnitValue: function (orient) { if (!this.value && this.operator && this.operator !== null && this[this.unit + "s"] && this[this.unit + "s"] !== null) { this[this.unit + "s"] = this[this.unit + "s"] + ((this.operator === "add") ? 1 : -1) + (this.value||0) * orient; } else if (this[this.unit + "s"] == null || this.operator != null) { if (!this.value) { this.value = 1; } this[this.unit + "s"] = this.value * orient; } }, generateDateFromWeeks: function () { var weekday = (this.weekday !== undefined) ? this.weekday : "today"; var d = Date[weekday]().addWeeks(this.weeks); if (this.now) { d.setTimeToNow(); } return d; } }; $D.Translator = { hour: function (s) { return function () { this.hour = Number(s); }; }, minute: function (s) { return function () { this.minute = Number(s); }; }, second: function (s) { return function () { this.second = Number(s); }; }, /* for ss.s format */ secondAndMillisecond: function (s) { return function () { var mx = s.match(/^([0-5][0-9])\.([0-9]{1,3})/); this.second = Number(mx[1]); this.millisecond = Number(mx[2]); }; }, meridian: function (s) { return function () { this.meridian = s.slice(0, 1).toLowerCase(); }; }, timezone: function (s) { return function () { var n = s.replace(/[^\d\+\-]/g, ""); if (n.length) { this.timezoneOffset = Number(n); } else { this.timezone = s.toLowerCase(); } }; }, day: function (x) { var s = x[0]; return function () { this.day = Number(s.match(/\d+/)[0]); if (this.day < 1) { throw "invalid day"; } }; }, month: function (s) { return function () { this.month = (s.length === 3) ? "jan feb mar apr may jun jul aug sep oct nov dec".indexOf(s)/4 : Number(s) - 1; if (this.month < 0) { throw "invalid month"; } }; }, year: function (s) { return function () { var n = Number(s); this.year = ((s.length > 2) ? n : (n + (((n + 2000) < Date.CultureInfo.twoDigitYearMax) ? 2000 : 1900))); }; }, rday: function (s) { return function () { switch (s) { case "yesterday": this.days = -1; break; case "tomorrow": this.days = 1; break; case "today": this.days = 0; break; case "now": this.days = 0; this.now = true; break; } }; }, finishExact: function (x) { var d; x = (x instanceof Array) ? x : [x]; for (var i = 0 ; i < x.length ; i++) { if (x[i]) { x[i].call(this); } } setDefaults.call(this); parseMeridian.call(this); if (this.day > $D.getDaysInMonth(this.year, this.month)) { throw new RangeError(this.day + " is not a valid value for days."); } d = new Date(this.year, this.month, this.day, this.hour, this.minute, this.second, this.millisecond); if (this.year < 100) { d.setFullYear(this.year); // means years less that 100 are process correctly. JS will parse it otherwise as 1900-1999. } if (this.timezone) { d.set({ timezone: this.timezone }); } else if (this.timezoneOffset) { d.set({ timezoneOffset: this.timezoneOffset }); } return d; }, finish: function (x) { var today, expression, orient, temp; x = (x instanceof Array) ? flattenAndCompact(x) : [ x ]; if (x.length === 0) { return null; } for (var i = 0 ; i < x.length ; i++) { if (typeof x[i] === "function") { x[i].call(this); } } if (this.now && !this.unit && !this.operator) { return new Date(); } else { today = finishUtils.getToday.call(this); } expression = !!(this.days && this.days !== null || this.orient || this.operator); orient = ((this.orient === "past" || this.operator === "subtract") ? -1 : 1); if (this.month && this.unit === "week") { this.value = this.month + 1; delete this.month; delete this.day; } if ((this.month || this.month === 0) && "year day hour minute second".indexOf(this.unit) !== -1) { if (!this.value) { this.value = this.month + 1; } this.month = null; expression = true; } if (!expression && this.weekday && !this.day && !this.days) { finishUtils.setDMYFromWeekday.call(this); } if (expression && this.weekday && this.unit !== "month" && this.unit !== "week") { finishUtils.setDaysFromWeekday.call(this, today, orient); } if (this.weekday && this.unit !== "week" && !this.day && !this.days) { temp = Date[this.weekday](); this.day = temp.getDate(); if (temp.getMonth() !== today.getMonth()) { this.month = temp.getMonth(); } } if (this.month && this.unit === "day" && this.operator) { if (!this.value) { this.value = (this.month + 1); } this.month = null; } if (this.value != null && this.month != null && this.year != null) { this.day = this.value * 1; } if (this.month && !this.day && this.value) { today.set({ day: this.value * 1 }); if (!expression) { this.day = this.value * 1; } } if (!this.month && this.value && this.unit === "month" && !this.now) { this.month = this.value; expression = true; } if (expression && (this.month || this.month === 0) && this.unit !== "year") { finishUtils.setMonthsFromMonth.call(this, today, orient); } if (!this.unit) { this.unit = "day"; } finishUtils.setUnitValue.call(this, orient); parseMeridian.call(this); if ((this.month || this.month === 0) && !this.day) { this.day = 1; } if (!this.orient && !this.operator && this.unit === "week" && this.value && !this.day && !this.month) { return Date.today().setWeek(this.value); } if (this.unit === "week" && this.weeks && !this.day && !this.month) { return finishUtils.generateDateFromWeeks.call(this); } if (expression && this.timezone && this.day && this.days) { this.day = this.days; } if (expression){ today.add(this); } else { today.set(this); } if (this.timezone) { this.timezone = this.timezone.toUpperCase(); var offset = $D.getTimezoneOffset(this.timezone); var timezone; if (today.hasDaylightSavingTime()) { // lets check that we're being sane with timezone setting timezone = $D.getTimezoneAbbreviation(offset, today.isDaylightSavingTime()); if (timezone !== this.timezone) { // bugger, we're in a place where things like EST vs EDT matters. if (today.isDaylightSavingTime()) { today.addHours(-1); } else { today.addHours(1); } } } today.setTimezoneOffset(offset); } return today; } }; }()); (function () { var $D = Date; $D.Grammar = {}; var _ = $D.Parsing.Operators, g = $D.Grammar, t = $D.Translator, _fn; // Allow rolling up into general purpose rules _fn = function () { return _.each(_.any.apply(null, arguments), _.not(g.ctoken2("timeContext"))); }; g.datePartDelimiter = _.rtoken(/^([\s\-\.\,\/\x27]+)/); g.timePartDelimiter = _.stoken(":"); g.whiteSpace = _.rtoken(/^\s*/); g.generalDelimiter = _.rtoken(/^(([\s\,]|at|@|on)+)/); var _C = {}; g.ctoken = function (keys) { var fn = _C[keys]; if (! fn) { var c = Date.CultureInfo.regexPatterns; var kx = keys.split(/\s+/), px = []; for (var i = 0; i < kx.length ; i++) { px.push(_.replace(_.rtoken(c[kx[i]]), kx[i])); } fn = _C[keys] = _.any.apply(null, px); } return fn; }; g.ctoken2 = function (key) { return _.rtoken(Date.CultureInfo.regexPatterns[key]); }; var cacheProcessRtoken = function (key, token, type, eachToken) { if (eachToken) { g[key] = _.cache(_.process(_.each(_.rtoken(token),_.optional(g.ctoken2(eachToken))), type)); } else { g[key] = _.cache(_.process(_.rtoken(token), type)); } }; var cacheProcessCtoken = function (token, type) { return _.cache(_.process(g.ctoken2(token), type)); }; var _F = {}; //function cache var _get = function (f) { _F[f] = (_F[f] || g.format(f)[0]); return _F[f]; }; g.allformats = function (fx) { var rx = []; if (fx instanceof Array) { for (var i = 0; i < fx.length; i++) { rx.push(_get(fx[i])); } } else { rx.push(_get(fx)); } return rx; }; g.formats = function (fx) { if (fx instanceof Array) { var rx = []; for (var i = 0 ; i < fx.length ; i++) { rx.push(_get(fx[i])); } return _.any.apply(null, rx); } else { return _get(fx); } }; var grammarFormats = { timeFormats: function(){ var i, RTokenKeys = [ "h", "hh", "H", "HH", "m", "mm", "s", "ss", "ss.s", "z", "zz" ], RToken = [ /^(0[0-9]|1[0-2]|[1-9])/, /^(0[0-9]|1[0-2])/, /^([0-1][0-9]|2[0-3]|[0-9])/, /^([0-1][0-9]|2[0-3])/, /^([0-5][0-9]|[0-9])/, /^[0-5][0-9]/, /^([0-5][0-9]|[0-9])/, /^[0-5][0-9]/, /^[0-5][0-9]\.[0-9]{1,3}/, /^((\+|\-)\s*\d\d\d\d)|((\+|\-)\d\d\:?\d\d)/, /^((\+|\-)\s*\d\d\d\d)|((\+|\-)\d\d\:?\d\d)/ ], tokens = [ t.hour, t.hour, t.hour, t.hour, t.minute, t.minute, t.second, t.second, t.secondAndMillisecond, t.timezone, t.timezone ]; for (i=0; i < RTokenKeys.length; i++) { cacheProcessRtoken(RTokenKeys[i], RToken[i], tokens[i]); } g.hms = _.cache(_.sequence([g.H, g.m, g.s], g.timePartDelimiter)); g.t = cacheProcessCtoken("shortMeridian", t.meridian); g.tt = cacheProcessCtoken("longMeridian", t.meridian); g.zzz = cacheProcessCtoken("timezone", t.timezone); g.timeSuffix = _.each(_.ignore(g.whiteSpace), _.set([ g.tt, g.zzz ])); g.time = _.each(_.optional(_.ignore(_.stoken("T"))), g.hms, g.timeSuffix); }, dateFormats: function () { // pre-loaded rules for different date part order preferences var _setfn = function () { return _.set(arguments, g.datePartDelimiter); }; var i, RTokenKeys = [ "d", "dd", "M", "MM", "y", "yy", "yyy", "yyyy" ], RToken = [ /^([0-2]\d|3[0-1]|\d)/, /^([0-2]\d|3[0-1])/, /^(1[0-2]|0\d|\d)/, /^(1[0-2]|0\d)/, /^(\d+)/, /^(\d\d)/, /^(\d\d?\d?\d?)/, /^(\d\d\d\d)/ ], tokens = [ t.day, t.day, t.month, t.month, t.year, t.year, t.year, t.year ], eachToken = [ "ordinalSuffix", "ordinalSuffix" ]; for (i=0; i < RTokenKeys.length; i++) { cacheProcessRtoken(RTokenKeys[i], RToken[i], tokens[i], eachToken[i]); } g.MMM = g.MMMM = _.cache(_.process(g.ctoken("jan feb mar apr may jun jul aug sep oct nov dec"), t.month)); g.ddd = g.dddd = _.cache(_.process(g.ctoken("sun mon tue wed thu fri sat"), function (s) { return function () { this.weekday = s; }; } )); g.day = _fn(g.d, g.dd); g.month = _fn(g.M, g.MMM); g.year = _fn(g.yyyy, g.yy); g.mdy = _setfn(g.ddd, g.month, g.day, g.year); g.ymd = _setfn(g.ddd, g.year, g.month, g.day); g.dmy = _setfn(g.ddd, g.day, g.month, g.year); g.date = function (s) { return ((g[Date.CultureInfo.dateElementOrder] || g.mdy).call(this, s)); }; }, relative: function () { // relative date / time expressions g.orientation = _.process(g.ctoken("past future"), function (s) { return function () { this.orient = s; }; } ); g.operator = _.process(g.ctoken("add subtract"), function (s) { return function () { this.operator = s; }; } ); g.rday = _.process(g.ctoken("yesterday tomorrow today now"), t.rday); g.unit = _.process(g.ctoken("second minute hour day week month year"), function (s) { return function () { this.unit = s; }; } ); } }; g.buildGrammarFormats = function () { // these need to be rebuilt every time the language changes. _C = {}; grammarFormats.timeFormats(); grammarFormats.dateFormats(); grammarFormats.relative(); g.value = _.process(_.rtoken(/^([-+]?\d+)?(st|nd|rd|th)?/), function (s) { return function () { this.value = s.replace(/\D/g, ""); }; } ); g.expression = _.set([g.rday, g.operator, g.value, g.unit, g.orientation, g.ddd, g.MMM ]); g.format = _.process(_.many( _.any( // translate format specifiers into grammar rules _.process( _.rtoken(/^(dd?d?d?(?!e)|MM?M?M?|yy?y?y?|hh?|HH?|mm?|ss?|tt?|zz?z?)/), function (fmt) { if (g[fmt]) { return g[fmt]; } else { throw $D.Parsing.Exception(fmt); } } ), // translate separator tokens into token rules _.process(_.rtoken(/^[^dMyhHmstz]+/), // all legal separators function (s) { return _.ignore(_.stoken(s)); } ) ) ), // construct the parser ... function (rules) { return _.process(_.each.apply(null, rules), t.finishExact); } ); // starting rule for general purpose grammar g._start = _.process(_.set([ g.date, g.time, g.expression ], g.generalDelimiter, g.whiteSpace), t.finish); }; g.buildGrammarFormats(); // parsing date format specifiers - ex: "h:m:s tt" // this little guy will generate a custom parser based // on the format string, ex: g.format("h:m:s tt") // check for these formats first g._formats = g.formats([ "\"yyyy-MM-ddTHH:mm:ssZ\"", "yyyy-MM-ddTHH:mm:ss.sz", "yyyy-MM-ddTHH:mm:ssZ", "yyyy-MM-ddTHH:mm:ssz", "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-ddTHH:mmZ", "yyyy-MM-ddTHH:mmz", "yyyy-MM-ddTHH:mm", "ddd, MMM dd, yyyy H:mm:ss tt", "ddd MMM d yyyy HH:mm:ss zzz", "MMddyyyy", "ddMMyyyy", "Mddyyyy", "ddMyyyy", "Mdyyyy", "dMyyyy", "yyyy", "Mdyy", "dMyy", "d" ]); // real starting rule: tries selected formats first, // then general purpose rule g.start = function (s) { try { var r = g._formats.call({}, s); if (r[1].length === 0) { return r; } } catch (e) {} return g._start.call({}, s); }; }()); (function () { var $D = Date; /** * @desc Converts the specified string value into its JavaScript Date equivalent using CultureInfo specific format information. * * Example

	///////////
	// Dates //
	///////////

	// 15-Oct-2004
	var d1 = Date.parse("10/15/2004");

	// 15-Oct-2004
	var d1 = Date.parse("15-Oct-2004");

	// 15-Oct-2004
	var d1 = Date.parse("2004.10.15");

	//Fri Oct 15, 2004
	var d1 = Date.parse("Fri Oct 15, 2004");

	///////////
	// Times //
	///////////

	// Today at 10 PM.
	var d1 = Date.parse("10 PM");

	// Today at 10:30 PM.
	var d1 = Date.parse("10:30 P.M.");

	// Today at 6 AM.
	var d1 = Date.parse("06am");

	/////////////////////
	// Dates and Times //
	/////////////////////

	// 8-July-2004 @ 10:30 PM
	var d1 = Date.parse("July 8th, 2004, 10:30 PM");

	// 1-July-2004 @ 10:30 PM
	var d1 = Date.parse("2004-07-01T22:30:00");

	////////////////////
	// Relative Dates //
	////////////////////

	// Returns today's date. The string "today" is culture specific.
	var d1 = Date.parse("today");

	// Returns yesterday's date. The string "yesterday" is culture specific.
	var d1 = Date.parse("yesterday");

	// Returns the date of the next thursday.
	var d1 = Date.parse("Next thursday");

	// Returns the date of the most previous monday.
	var d1 = Date.parse("last monday");

	// Returns today's day + one year.
	var d1 = Date.parse("next year");

	///////////////
	// Date Math //
	///////////////

	// Today + 2 days
	var d1 = Date.parse("t+2");

	// Today + 2 days
	var d1 = Date.parse("today + 2 days");

	// Today + 3 months
	var d1 = Date.parse("t+3m");

	// Today - 1 year
	var d1 = Date.parse("today - 1 year");

	// Today - 1 year
	var d1 = Date.parse("t-1y"); 


	/////////////////////////////
	// Partial Dates and Times //
	/////////////////////////////

	// July 15th of this year.
	var d1 = Date.parse("July 15");

	// 15th day of current day and year.
	var d1 = Date.parse("15");

	// July 1st of current year at 10pm.
	var d1 = Date.parse("7/1 10pm");
	
* * @param {String} The string value to convert into a Date object [Required] * @return {Date} A Date object or null if the string cannot be converted into a Date. */ var parseUtils = { removeOrds: function (s) { ords = s.match(/\b(\d+)(?:st|nd|rd|th)\b/); // find ordinal matches s = ((ords && ords.length === 2) ? s.replace(ords[0], ords[1]) : s); return s; }, grammarParser: function (s) { var r = null; try { r = $D.Grammar.start.call({}, s.replace(/^\s*(\S*(\s+\S+)*)\s*$/, "$1")); } catch (e) { return null; } return ((r[1].length === 0) ? r[0] : null); }, nativeFallback: function(s) { var t; try { // ok we haven't parsed it, last ditch attempt with the built-in parser. t = Date._parse(s); return (t || t === 0) ? new Date(t) : null; } catch (e) { return null; } } }; function parse (s) { var d; if (!s) { return null; } if (s instanceof Date) { return s.clone(); } if (s.length >= 4 && s.charAt(0) !== "0" && s.charAt(0) !== "+"&& s.charAt(0) !== "-") { // ie: 2004 will pass, 0800 won't. // Start with specific formats d = $D.Parsing.ISO.parse(s) || $D.Parsing.Numeric.parse(s); } if (d instanceof Date && !isNaN(d.getTime())) { return d; } else { // find ordinal dates (1st, 3rd, 8th, etc and remove them as they cause parsing issues) s = $D.Parsing.Normalizer.parse(parseUtils.removeOrds(s)); d = parseUtils.grammarParser(s); if (d !== null) { return d; } else { return parseUtils.nativeFallback(s); } } } if (!$D._parse) { $D._parse = $D.parse; } $D.parse = parse; Date.getParseFunction = function (fx) { var fns = Date.Grammar.allformats(fx); return function (s) { var r = null; for (var i = 0; i < fns.length; i++) { try { r = fns[i].call({}, s); } catch (e) { continue; } if (r[1].length === 0) { return r[0]; } } return null; }; }; /** * Converts the specified string value into its JavaScript Date equivalent using the specified format {String} or formats {Array} and the CultureInfo specific format information. * The format of the string value must match one of the supplied formats exactly. * * Example

	// 15-Oct-2004
	var d1 = Date.parseExact("10/15/2004", "M/d/yyyy");

	// 15-Oct-2004
	var d1 = Date.parse("15-Oct-2004", "M-ddd-yyyy");

	// 15-Oct-2004
	var d1 = Date.parse("2004.10.15", "yyyy.MM.dd");

	// Multiple formats
	var d1 = Date.parseExact("10/15/2004", ["M/d/yyyy", "MMMM d, yyyy"]);
	
* * @param {String} The string value to convert into a Date object [Required]. * @param {Object} The expected format {String} or an array of expected formats {Array} of the date string [Required]. * @return {Date} A Date object or null if the string cannot be converted into a Date. */ $D.parseExact = function (s, fx) { return $D.getParseFunction(fx)(s); }; }()); (function () { var $D = Date, $P = $D.prototype, // $C = $D.CultureInfo, // not used atm p = function (s, l) { if (!l) { l = 2; } return ("000" + s).slice(l * -1); }; /** * Converts a PHP format string to Java/.NET format string. * A PHP format string can be used with ._format or .format. * A Java/.NET format string can be used with .toString(). * The .parseExact function will only accept a Java/.NET format string * * Example * var f1 = "%m/%d/%y" * var f2 = Date.normalizeFormat(f1); // "MM/dd/yy" * * new Date().format(f1); // "04/13/08" * new Date()._format(f1); // "04/13/08" * new Date().toString(f2); // "04/13/08" * * var date = Date.parseExact("04/13/08", f2); // Sun Apr 13 2008 * * @param {String} A PHP format string consisting of one or more format spcifiers. * @return {String} The PHP format converted to a Java/.NET format string. */ var normalizerSubstitutions = { "d" : "dd", "%d": "dd", "D" : "ddd", "%a": "ddd", "j" : "dddd", "l" : "dddd", "%A": "dddd", "S" : "S", "F" : "MMMM", "%B": "MMMM", "m" : "MM", "%m": "MM", "M" : "MMM", "%b": "MMM", "%h": "MMM", "n" : "M", "Y" : "yyyy", "%Y": "yyyy", "y" : "yy", "%y": "yy", "g" : "h", "%I": "h", "G" : "H", "h" : "hh", "H" : "HH", "%H": "HH", "i" : "mm", "%M": "mm", "s" : "ss", "%S": "ss", "%r": "hh:mm tt", "%R": "H:mm", "%T": "H:mm:ss", "%X": "t", "%x": "d", "%e": "d", "%D": "MM/dd/yy", "%n": "\\n", "%t": "\\t", "e" : "z", "T" : "z", "%z": "z", "%Z": "z", "Z" : "ZZ", "N" : "u", "w" : "u", "%w": "u", "W" : "W", "%V": "W" }; var normalizer = { substitutes: function (m) { return normalizerSubstitutions[m]; }, interpreted: function (m, x) { var y; switch (m) { case "%u": return x.getDay() + 1; case "z": return x.getOrdinalNumber(); case "%j": return p(x.getOrdinalNumber(), 3); case "%U": var d1 = x.clone().set({month: 0, day: 1}).addDays(-1).moveToDayOfWeek(0), d2 = x.clone().addDays(1).moveToDayOfWeek(0, -1); return (d2 < d1) ? "00" : p((d2.getOrdinalNumber() - d1.getOrdinalNumber()) / 7 + 1); case "%W": return p(x.getWeek()); case "t": return $D.getDaysInMonth(x.getFullYear(), x.getMonth()); case "o": case "%G": return x.setWeek(x.getISOWeek()).toString("yyyy"); case "%g": return x._format("%G").slice(-2); case "a": case "%p": return t("tt").toLowerCase(); case "A": return t("tt").toUpperCase(); case "u": return p(x.getMilliseconds(), 3); case "I": return (x.isDaylightSavingTime()) ? 1 : 0; case "O": return x.getUTCOffset(); case "P": y = x.getUTCOffset(); return y.substring(0, y.length - 2) + ":" + y.substring(y.length - 2); case "B": var now = new Date(); return Math.floor(((now.getHours() * 3600) + (now.getMinutes() * 60) + now.getSeconds() + (now.getTimezoneOffset() + 60) * 60) / 86.4); case "c": return x.toISOString().replace(/\"/g, ""); case "U": return $D.strtotime("now"); case "%c": return t("d") + " " + t("t"); case "%C": return Math.floor(x.getFullYear() / 100 + 1); } }, shouldOverrideDefaults: function (m) { switch (m) { case "%e": return true; default: return false; } }, parse: function (m, context) { var formatString, c = context || new Date(); formatString = normalizer.substitutes(m); if (formatString) { return formatString; } formatString = normalizer.interpreted(m, c); if (formatString) { return formatString; } else { return m; } } }; $D.normalizeFormat = function (format, context) { return format.replace(/(%|\\)?.|%%/g, function(t){ return normalizer.parse(t, context); }); }; /** * Format a local Unix timestamp according to locale settings * * Example: * Date.strftime("%m/%d/%y", new Date()); // "04/13/08" * Date.strftime("c", "2008-04-13T17:52:03Z"); // "04/13/08" * * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @param {Number|String} The number representing the number of seconds that have elapsed since January 1, 1970 (local time). * @return {String} A string representation of the current Date object. */ $D.strftime = function (format, time) { var d = Date.parse(time); return d._format(format); }; /** * Parse any textual datetime description into a Unix timestamp. * A Unix timestamp is the number of seconds that have elapsed since January 1, 1970 (midnight UTC/GMT). * * Example: * Date.strtotime("04/13/08"); // 1208044800 * Date.strtotime("1970-01-01T00:00:00Z"); // 0 * * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @param {Object} A string or date object. * @return {String} A string representation of the current Date object. */ $D.strtotime = function (time) { var d = $D.parse(time); return Math.round($D.UTC(d.getUTCFullYear(), d.getUTCMonth(), d.getUTCDate(), d.getUTCHours(), d.getUTCMinutes(), d.getUTCSeconds(), d.getUTCMilliseconds()) / 1000); }; /** * Converts the value of the current Date object to its equivalent string representation using a PHP/Unix style of date format specifiers. * Format Specifiers * Format Description Example * ------ --------------------------------------------------------------------------- ----------------------- * %a abbreviated weekday name according to the current localed "Mon" through "Sun" * %A full weekday name according to the current localed "Sunday" through "Saturday" * %b abbreviated month name according to the current localed "Jan" through "Dec" * %B full month name according to the current locale "January" through "December" * %c preferred date and time representation for the current locale "4/13/2008 12:33 PM" * %C century number (the year divided by 100 and truncated to an integer) "00" to "99" * %d day of the month as a decimal number "01" to "31" * %D same as %m/%d/%y "04/13/08" * %e day of the month as a decimal number, a single digit is preceded by a space "1" to "31" * %g like %G, but without the century "08" * %G The 4-digit year corresponding to the ISO week number (see %V). "2008" * This has the same format and value as %Y, except that if the ISO week number * belongs to the previous or next year, that year is used instead. * %h same as %b "Jan" through "Dec" * %H hour as a decimal number using a 24-hour clock. "00" to "23" * %I hour as a decimal number using a 12-hour clock. "01" to "12" * %j day of the year as a decimal number. "001" to "366" * %m month as a decimal number. "01" to "12" * %M minute as a decimal number. "00" to "59" * %n newline character "\n" * %p either "am" or "pm" according to the given time value, or the "am" or "pm" * corresponding strings for the current locale. * %r time in a.m. and p.m. notation "8:44 PM" * %R time in 24 hour notation "20:44" * %S second as a decimal number "00" to "59" * %t tab character "\t" * %T current time, equal to %H:%M:%S "12:49:11" * %u weekday as a decimal number ["1", "7"], with "1" representing Monday "1" to "7" * %U week number of the current year as a decimal number, starting with the "0" to ("52" or "53") * first Sunday as the first day of the first week * %V The ISO 8601:1988 week number of the current year as a decimal number, "00" to ("52" or "53") * range 01 to 53, where week 1 is the first week that has at least 4 days * in the current year, and with Monday as the first day of the week. * (Use %G or %g for the year component that corresponds to the week number * for the specified timestamp.) * %W week number of the current year as a decimal number, starting with the "00" to ("52" or "53") * first Monday as the first day of the first week * %w day of the week as a decimal, Sunday being "0" "0" to "6" * %x preferred date representation for the current locale without the time "4/13/2008" * %X preferred time representation for the current locale without the date "12:53:05" * %y year as a decimal number without a century "00" "99" * %Y year as a decimal number including the century "2008" * %Z time zone or name or abbreviation "UTC", "EST", "PST" * %z same as %Z * %% a literal "%" characters "%" * d Day of the month, 2 digits with leading zeros "01" to "31" * D A textual representation of a day, three letters "Mon" through "Sun" * j Day of the month without leading zeros "1" to "31" * l A full textual representation of the day of the week (lowercase "L") "Sunday" through "Saturday" * N ISO-8601 numeric representation of the day of the week (added in PHP 5.1.0) "1" (for Monday) through "7" (for Sunday) * S English ordinal suffix for the day of the month, 2 characters "st", "nd", "rd" or "th". Works well with j * w Numeric representation of the day of the week "0" (for Sunday) through "6" (for Saturday) * z The day of the year (starting from "0") "0" through "365" * W ISO-8601 week number of year, weeks starting on Monday "00" to ("52" or "53") * F A full textual representation of a month, such as January or March "January" through "December" * m Numeric representation of a month, with leading zeros "01" through "12" * M A short textual representation of a month, three letters "Jan" through "Dec" * n Numeric representation of a month, without leading zeros "1" through "12" * t Number of days in the given month "28" through "31" * L Whether it's a leap year "1" if it is a leap year, "0" otherwise * o ISO-8601 year number. This has the same value as Y, except that if the "2008" * ISO week number (W) belongs to the previous or next year, that year * is used instead. * Y A full numeric representation of a year, 4 digits "2008" * y A two digit representation of a year "08" * a Lowercase Ante meridiem and Post meridiem "am" or "pm" * A Uppercase Ante meridiem and Post meridiem "AM" or "PM" * B Swatch Internet time "000" through "999" * g 12-hour format of an hour without leading zeros "1" through "12" * G 24-hour format of an hour without leading zeros "0" through "23" * h 12-hour format of an hour with leading zeros "01" through "12" * H 24-hour format of an hour with leading zeros "00" through "23" * i Minutes with leading zeros "00" to "59" * s Seconds, with leading zeros "00" through "59" * u Milliseconds "54321" * e Timezone identifier "UTC", "EST", "PST" * I Whether or not the date is in daylight saving time (uppercase i) "1" if Daylight Saving Time, "0" otherwise * O Difference to Greenwich time (GMT) in hours "+0200", "-0600" * P Difference to Greenwich time (GMT) with colon between hours and minutes "+02:00", "-06:00" * T Timezone abbreviation "UTC", "EST", "PST" * Z Timezone offset in seconds. The offset for timezones west of UTC is "-43200" through "50400" * always negative, and for those east of UTC is always positive. * c ISO 8601 date "2004-02-12T15:19:21+00:00" * r RFC 2822 formatted date "Thu, 21 Dec 2000 16:01:07 +0200" * U Seconds since the Unix Epoch (January 1 1970 00:00:00 GMT) "0" * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @return {String} A string representation of the current Date object. */ var formatReplace = function (context) { return function (m) { var formatString, override = false; if (m.charAt(0) === "\\" || m.substring(0, 2) === "%%") { return m.replace("\\", "").replace("%%", "%"); } override = normalizer.shouldOverrideDefaults(m); formatString = $D.normalizeFormat(m, context); if (formatString) { return context.toString(formatString, override); } }; }; $P._format = function (format) { var formatter = formatReplace(this); if (!format) { return this._toString(); } else { return format.replace(/(%|\\)?.|%%/g, formatter); } }; if (!$P.format) { $P.format = $P._format; } }()); (function () { "use strict"; var gFn = function (attr) { return function () { return this[attr]; }; }; var sFn = function (attr) { return function (val) { this[attr] = val; return this; }; }; var attrs = ["years", "months", "days", "hours", "minutes", "seconds", "milliseconds"]; var addSetFuncs = function (context, attrs) { for (var i = 0; i < attrs.length ; i++) { var $a = attrs[i], $b = $a.slice(0, 1).toUpperCase() + $a.slice(1); context.prototype[$a] = 0; context.prototype["get" + $b] = gFn($a); context.prototype["set" + $b] = sFn($a); } }; /** * new TimeSpan(milliseconds); * new TimeSpan(days, hours, minutes, seconds); * new TimeSpan(days, hours, minutes, seconds, milliseconds); */ var TimeSpan = function (days, hours, minutes, seconds, milliseconds) { if (arguments.length === 1 && typeof days === "number") { var orient = (days < 0) ? -1 : +1; var millsLeft = Math.abs(days); this.setDays(Math.floor(millsLeft / 86400000) * orient); millsLeft = millsLeft % 86400000; this.setHours(Math.floor(millsLeft / 3600000) * orient); millsLeft = millsLeft % 3600000; this.setMinutes(Math.floor(millsLeft / 60000) * orient); millsLeft = millsLeft % 60000; this.setSeconds(Math.floor(millsLeft / 1000) * orient); millsLeft = millsLeft % 1000; this.setMilliseconds(millsLeft * orient); } else { this.set(days, hours, minutes, seconds, milliseconds); } this.getTotalMilliseconds = function () { return (this.getDays() * 86400000) + (this.getHours() * 3600000) + (this.getMinutes() * 60000) + (this.getSeconds() * 1000); }; this.compareTo = function (time) { var t1 = new Date(1970, 1, 1, this.getHours(), this.getMinutes(), this.getSeconds()), t2; if (time === null) { t2 = new Date(1970, 1, 1, 0, 0, 0); } else { t2 = new Date(1970, 1, 1, time.getHours(), time.getMinutes(), time.getSeconds()); } return (t1 < t2) ? -1 : (t1 > t2) ? 1 : 0; }; this.equals = function (time) { return (this.compareTo(time) === 0); }; this.add = function (time) { return (time === null) ? this : this.addSeconds(time.getTotalMilliseconds() / 1000); }; this.subtract = function (time) { return (time === null) ? this : this.addSeconds(-time.getTotalMilliseconds() / 1000); }; this.addDays = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 86400000)); }; this.addHours = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 3600000)); }; this.addMinutes = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 60000)); }; this.addSeconds = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 1000)); }; this.addMilliseconds = function (n) { return new TimeSpan(this.getTotalMilliseconds() + n); }; this.get12HourHour = function () { return (this.getHours() > 12) ? this.getHours() - 12 : (this.getHours() === 0) ? 12 : this.getHours(); }; this.getDesignator = function () { return (this.getHours() < 12) ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator; }; this.toString = function (format) { this._toString = function () { if (this.getDays() !== null && this.getDays() > 0) { return this.getDays() + "." + this.getHours() + ":" + this.p(this.getMinutes()) + ":" + this.p(this.getSeconds()); } else { return this.getHours() + ":" + this.p(this.getMinutes()) + ":" + this.p(this.getSeconds()); } }; this.p = function (s) { return (s.toString().length < 2) ? "0" + s : s; }; var me = this; return format ? format.replace(/dd?|HH?|hh?|mm?|ss?|tt?/g, function (format) { switch (format) { case "d": return me.getDays(); case "dd": return me.p(me.getDays()); case "H": return me.getHours(); case "HH": return me.p(me.getHours()); case "h": return me.get12HourHour(); case "hh": return me.p(me.get12HourHour()); case "m": return me.getMinutes(); case "mm": return me.p(me.getMinutes()); case "s": return me.getSeconds(); case "ss": return me.p(me.getSeconds()); case "t": return ((me.getHours() < 12) ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator).substring(0, 1); case "tt": return (me.getHours() < 12) ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator; } } ) : this._toString(); }; return this; }; addSetFuncs(TimeSpan, attrs.slice(2)); TimeSpan.prototype.set = function (days, hours, minutes, seconds, milliseconds){ this.setDays(days || this.getDays()); this.setHours(hours || this.getHours()); this.setMinutes(minutes || this.getMinutes()); this.setSeconds(seconds || this.getSeconds()); this.setMilliseconds(milliseconds || this.getMilliseconds()); }; /** * Gets the time of day for this date instances. * @return {TimeSpan} TimeSpan */ Date.prototype.getTimeOfDay = function () { return new TimeSpan(0, this.getHours(), this.getMinutes(), this.getSeconds(), this.getMilliseconds()); }; Date.TimeSpan = TimeSpan; if (typeof window !== "undefined" ) { // keeping API compatible for v1.x window.TimeSpan = TimeSpan; } }()); (function () { "use strict"; var attrs = ["years", "months", "days", "hours", "minutes", "seconds", "milliseconds"]; var gFn = function (attr) { return function () { return this[attr]; }; }; var sFn = function (attr) { return function (val) { this[attr] = val; return this; }; }; var addSetFuncs = function (context, attrs) { for (var i = 0; i < attrs.length ; i++) { var $a = attrs[i], $b = $a.slice(0, 1).toUpperCase() + $a.slice(1); context.prototype[$a] = 0; context.prototype["get" + $b] = gFn($a); context.prototype["set" + $b] = sFn($a); } }; var setMonthsAndYears = function (orient, d1, d2, context) { function inc() { d1.addMonths(-orient); context.months++; if (context.months === 12) { context.years++; context.months = 0; } } if (orient === +1) { while (d1 > d2) { inc(); } } else { while (d1 < d2) { inc(); } } context.months--; context.months *= orient; context.years *= orient; }; var adjustForDST = function(orient, startDate, endDate) { var hasDSTMismatch = (false === (startDate.isDaylightSavingTime() === endDate.isDaylightSavingTime())); if (hasDSTMismatch && orient === 1) { startDate.addHours(-1); } else if (hasDSTMismatch) { startDate.addHours(1); } }; /** * TimePeriod(startDate, endDate); * TimePeriod(years, months, days, hours, minutes, seconds, milliseconds); */ var TimePeriod = function (years, months, days, hours, minutes, seconds, milliseconds) { if (arguments.length === 7) { this.set(years, months, days, hours, minutes, seconds, milliseconds); } else if (arguments.length === 2 && arguments[0] instanceof Date && arguments[1] instanceof Date) { var startDate = arguments[0].clone(); var endDate = arguments[1].clone(); var orient = (startDate > endDate) ? +1 : -1; this.dates = { start: arguments[0].clone(), end: arguments[1].clone() }; setMonthsAndYears(orient, startDate, endDate, this); adjustForDST(orient, startDate, endDate); // // TODO - adjust for DST var diff = endDate - startDate; if (diff !== 0) { var ts = new TimeSpan(diff); this.set(this.years, this.months, ts.getDays(), ts.getHours(), ts.getMinutes(), ts.getSeconds(), ts.getMilliseconds()); } } return this; }; // create all the set functions. addSetFuncs(TimePeriod, attrs); TimePeriod.prototype.set = function (years, months, days, hours, minutes, seconds, milliseconds){ this.setYears(years || this.getYears()); this.setMonths(months || this.getMonths()); this.setDays(days || this.getDays()); this.setHours(hours || this.getHours()); this.setMinutes(minutes || this.getMinutes()); this.setSeconds(seconds || this.getSeconds()); this.setMilliseconds(milliseconds || this.getMilliseconds()); }; Date.TimePeriod = TimePeriod; if (typeof window !== "undefined") { // keeping API compatible for v1.x window.TimePeriod = TimePeriod; } }()); ================================================ FILE: build/date-hi-IN.js ================================================ /** * @overview datejs * @version 1.0.0-rc3 * @author Gregory Wild-Smith * @copyright 2015 Gregory Wild-Smith * @license MIT * @homepage https://github.com/abritinthebay/datejs */ /* * DateJS Culture String File * Country Code: hi-IN * Name: Hindi (India) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["hi-IN"] = { "name": "hi-IN", "englishName": "Hindi (India)", "nativeName": "हिंदी (भारत)", "Sunday": "रविवार", "Monday": "सोमवार", "Tuesday": "मंगलवार", "Wednesday": "बुधवार", "Thursday": "गुरुवार", "Friday": "शुक्रवार", "Saturday": "शनिवार", "Sun": "रवि.", "Mon": "सोम.", "Tue": "मंगल.", "Wed": "बुध.", "Thu": "गुरु.", "Fri": "शुक्र.", "Sat": "शनि.", "Su": "र", "Mo": "स", "Tu": "म", "We": "ब", "Th": "ग", "Fr": "श", "Sa": "श", "S_Sun_Initial": "र", "M_Mon_Initial": "स", "T_Tue_Initial": "म", "W_Wed_Initial": "ब", "T_Thu_Initial": "ग", "F_Fri_Initial": "श", "S_Sat_Initial": "श", "January": "जनवरी", "February": "फरवरी", "March": "मार्च", "April": "अप्रैल", "May": "मई", "June": "जून", "July": "जुलाई", "August": "अगस्त", "September": "सितम्बर", "October": "अक्तूबर", "November": "नवम्बर", "December": "दिसम्बर", "Jan_Abbr": "जनवरी", "Feb_Abbr": "फरवरी", "Mar_Abbr": "मार्च", "Apr_Abbr": "अप्रैल", "May_Abbr": "मई", "Jun_Abbr": "जून", "Jul_Abbr": "जुलाई", "Aug_Abbr": "अगस्त", "Sep_Abbr": "सितम्बर", "Oct_Abbr": "अक्तूबर", "Nov_Abbr": "नवम्बर", "Dec_Abbr": "दिसम्बर", "AM": "पूर्वाह्न", "PM": "अपराह्न", "firstDayOfWeek": 1, "twoDigitYearMax": 2029, "mdy": "dmy", "M/d/yyyy": "dd-MM-yyyy", "dddd, MMMM dd, yyyy": "dd MMMM yyyy", "h:mm tt": "HH:mm", "h:mm:ss tt": "HH:mm:ss", "dddd, MMMM dd, yyyy h:mm:ss tt": "dd MMMM yyyy HH:mm:ss", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "dd MMMM", "MMMM, yyyy": "MMMM, yyyy", "/jan(uary)?/": "जनवरी", "/feb(ruary)?/": "फरवरी", "/mar(ch)?/": "मार्च", "/apr(il)?/": "अप्रैल", "/may/": "मई", "/jun(e)?/": "जून", "/jul(y)?/": "जुलाई", "/aug(ust)?/": "अगस्त", "/sep(t(ember)?)?/": "सितम्बर", "/oct(ober)?/": "अक्तूबर", "/nov(ember)?/": "नवम्बर", "/dec(ember)?/": "दिसम्बर", "/^su(n(day)?)?/": "^र(वि(.(वार)?)?)?", "/^mo(n(day)?)?/": "^स(ोम(.(वार)?)?)?", "/^tu(e(s(day)?)?)?/": "^म(ंगल(.(वार)?)?)?", "/^we(d(nesday)?)?/": "^ब(ुध(.(वार)?)?)?", "/^th(u(r(s(day)?)?)?)?/": "^ग(ुरु(.(वार)?)?)?", "/^fr(i(day)?)?/": "^श(ुक्र(.(वार)?)?)?", "/^sa(t(urday)?)?/": "^श(नि(.(वार)?)?)?", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "hi-IN"; /** * @overview datejs * @version 1.0.0-rc3 * @author Gregory Wild-Smith * @copyright 2015 Gregory Wild-Smith * @license MIT * @homepage https://github.com/abritinthebay/datejs */(function () { var $D = Date; var lang = Date.CultureStrings ? Date.CultureStrings.lang : null; var loggedKeys = {}; // for debug purposes. var getText = { getFromKey: function (key, countryCode) { var output; if (Date.CultureStrings && Date.CultureStrings[countryCode] && Date.CultureStrings[countryCode][key]) { output = Date.CultureStrings[countryCode][key]; } else { output = getText.buildFromDefault(key); } if (key.charAt(0) === "/") { // Assume it's a regex output = getText.buildFromRegex(key, countryCode); } return output; }, getFromObjectValues: function (obj, countryCode) { var key, output = {}; for(key in obj) { if (obj.hasOwnProperty(key)) { output[key] = getText.getFromKey(obj[key], countryCode); } } return output; }, getFromObjectKeys: function (obj, countryCode) { var key, output = {}; for(key in obj) { if (obj.hasOwnProperty(key)) { output[getText.getFromKey(key, countryCode)] = obj[key]; } } return output; }, getFromArray: function (arr, countryCode) { var output = []; for (var i=0; i < arr.length; i++){ if (i in arr) { output[i] = getText.getFromKey(arr[i], countryCode); } } return output; }, buildFromDefault: function (key) { var output, length, split, last; switch(key) { case "name": output = "en-US"; break; case "englishName": output = "English (United States)"; break; case "nativeName": output = "English (United States)"; break; case "twoDigitYearMax": output = 2049; break; case "firstDayOfWeek": output = 0; break; default: output = key; split = key.split("_"); length = split.length; if (length > 1 && key.charAt(0) !== "/") { // if the key isn't a regex and it has a split. last = split[(length - 1)].toLowerCase(); if (last === "initial" || last === "abbr") { output = split[0]; } } break; } return output; }, buildFromRegex: function (key, countryCode) { var output; if (Date.CultureStrings && Date.CultureStrings[countryCode] && Date.CultureStrings[countryCode][key]) { output = new RegExp(Date.CultureStrings[countryCode][key], "i"); } else { output = new RegExp(key.replace(new RegExp("/", "g"),""), "i"); } return output; } }; var shallowMerge = function (obj1, obj2) { for (var attrname in obj2) { if (obj2.hasOwnProperty(attrname)) { obj1[attrname] = obj2[attrname]; } } }; var __ = function (key, language) { var countryCode = (language) ? language : lang; loggedKeys[key] = key; if (typeof key === "object") { if (key instanceof Array) { return getText.getFromArray(key, countryCode); } else { return getText.getFromObjectKeys(key, countryCode); } } else { return getText.getFromKey(key, countryCode); } }; var loadI18nScript = function (code) { // paatterned after jQuery's getScript. var url = Date.Config.i18n + code + ".js"; var head = document.getElementsByTagName("head")[0] || document.documentElement; var script = document.createElement("script"); script.src = url; var completed = false; var events = { done: function (){} // placeholder function }; // Attach handlers for all browsers script.onload = script.onreadystatechange = function() { if ( !completed && (!this.readyState || this.readyState === "loaded" || this.readyState === "complete") ) { events.done(); head.removeChild(script); } }; setTimeout(function() { head.insertBefore(script, head.firstChild); }, 0); // allows return to execute first return { done: function (cb) { events.done = function() { if (cb) { setTimeout(cb,0); } }; } }; }; var buildInfo = { buildFromMethodHash: function (obj) { var key; for(key in obj) { if (obj.hasOwnProperty(key)) { obj[key] = buildInfo[obj[key]](); } } return obj; }, timeZoneDST: function () { var DST = { "CHADT": "+1345", "NZDT": "+1300", "AEDT": "+1100", "ACDT": "+1030", "AZST": "+0500", "IRDT": "+0430", "EEST": "+0300", "CEST": "+0200", "BST": "+0100", "PMDT": "-0200", "ADT": "-0300", "NDT": "-0230", "EDT": "-0400", "CDT": "-0500", "MDT": "-0600", "PDT": "-0700", "AKDT": "-0800", "HADT": "-0900" }; return __(DST); }, timeZoneStandard: function () { var standard = { "LINT": "+1400", "TOT": "+1300", "CHAST": "+1245", "NZST": "+1200", "NFT": "+1130", "SBT": "+1100", "AEST": "+1000", "ACST": "+0930", "JST": "+0900", "CWST": "+0845", "CT": "+0800", "ICT": "+0700", "MMT": "+0630", "BST": "+0600", "NPT": "+0545", "IST": "+0530", "PKT": "+0500", "AFT": "+0430", "MSK": "+0400", "IRST": "+0330", "FET": "+0300", "EET": "+0200", "CET": "+0100", "GMT": "+0000", "UTC": "+0000", "CVT": "-0100", "GST": "-0200", "BRT": "-0300", "NST": "-0330", "AST": "-0400", "EST": "-0500", "CST": "-0600", "MST": "-0700", "PST": "-0800", "AKST": "-0900", "MIT": "-0930", "HST": "-1000", "SST": "-1100", "BIT": "-1200" }; return __(standard); }, timeZones: function (data) { var zone; data.timezones = []; for (zone in data.abbreviatedTimeZoneStandard) { if (data.abbreviatedTimeZoneStandard.hasOwnProperty(zone)) { data.timezones.push({ name: zone, offset: data.abbreviatedTimeZoneStandard[zone]}); } } for (zone in data.abbreviatedTimeZoneDST) { if (data.abbreviatedTimeZoneDST.hasOwnProperty(zone)) { data.timezones.push({ name: zone, offset: data.abbreviatedTimeZoneDST[zone], dst: true}); } } return data.timezones; }, days: function () { return __(["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"]); }, dayAbbr: function () { return __(["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"]); }, dayShortNames: function () { return __(["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"]); }, dayFirstLetters: function () { return __(["S_Sun_Initial", "M_Mon_Initial", "T_Tues_Initial", "W_Wed_Initial", "T_Thu_Initial", "F_Fri_Initial", "S_Sat_Initial"]); }, months: function () { return __(["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"]); }, monthAbbr: function () { return __(["Jan_Abbr", "Feb_Abbr", "Mar_Abbr", "Apr_Abbr", "May_Abbr", "Jun_Abbr", "Jul_Abbr", "Aug_Abbr", "Sep_Abbr", "Oct_Abbr", "Nov_Abbr", "Dec_Abbr"]); }, formatPatterns: function () { return getText.getFromObjectValues({ shortDate: "M/d/yyyy", longDate: "dddd, MMMM dd, yyyy", shortTime: "h:mm tt", longTime: "h:mm:ss tt", fullDateTime: "dddd, MMMM dd, yyyy h:mm:ss tt", sortableDateTime: "yyyy-MM-ddTHH:mm:ss", universalSortableDateTime: "yyyy-MM-dd HH:mm:ssZ", rfc1123: "ddd, dd MMM yyyy HH:mm:ss", monthDay: "MMMM dd", yearMonth: "MMMM, yyyy" }, Date.i18n.currentLanguage()); }, regex: function () { return getText.getFromObjectValues({ inTheMorning: "/( in the )(morn(ing)?)\\b/", thisMorning: "/(this )(morn(ing)?)\\b/", amThisMorning: "/(\b\\d(am)? )(this )(morn(ing)?)/", inTheEvening: "/( in the )(even(ing)?)\\b/", thisEvening: "/(this )(even(ing)?)\\b/", pmThisEvening: "/(\b\\d(pm)? )(this )(even(ing)?)/", jan: "/jan(uary)?/", feb: "/feb(ruary)?/", mar: "/mar(ch)?/", apr: "/apr(il)?/", may: "/may/", jun: "/jun(e)?/", jul: "/jul(y)?/", aug: "/aug(ust)?/", sep: "/sep(t(ember)?)?/", oct: "/oct(ober)?/", nov: "/nov(ember)?/", dec: "/dec(ember)?/", sun: "/^su(n(day)?)?/", mon: "/^mo(n(day)?)?/", tue: "/^tu(e(s(day)?)?)?/", wed: "/^we(d(nesday)?)?/", thu: "/^th(u(r(s(day)?)?)?)?/", fri: "/fr(i(day)?)?/", sat: "/^sa(t(urday)?)?/", future: "/^next/", past: "/^last|past|prev(ious)?/", add: "/^(\\+|aft(er)?|from|hence)/", subtract: "/^(\\-|bef(ore)?|ago)/", yesterday: "/^yes(terday)?/", today: "/^t(od(ay)?)?/", tomorrow: "/^tom(orrow)?/", now: "/^n(ow)?/", millisecond: "/^ms|milli(second)?s?/", second: "/^sec(ond)?s?/", minute: "/^mn|min(ute)?s?/", hour: "/^h(our)?s?/", week: "/^w(eek)?s?/", month: "/^m(onth)?s?/", day: "/^d(ay)?s?/", year: "/^y(ear)?s?/", shortMeridian: "/^(a|p)/", longMeridian: "/^(a\\.?m?\\.?|p\\.?m?\\.?)/", timezone: "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/", ordinalSuffix: "/^\\s*(st|nd|rd|th)/", timeContext: "/^\\s*(\\:|a(?!u|p)|p)/" }, Date.i18n.currentLanguage()); } }; var CultureInfo = function () { var info = getText.getFromObjectValues({ name: "name", englishName: "englishName", nativeName: "nativeName", amDesignator: "AM", pmDesignator: "PM", firstDayOfWeek: "firstDayOfWeek", twoDigitYearMax: "twoDigitYearMax", dateElementOrder: "mdy" }, Date.i18n.currentLanguage()); var constructedInfo = buildInfo.buildFromMethodHash({ dayNames: "days", abbreviatedDayNames: "dayAbbr", shortestDayNames: "dayShortNames", firstLetterDayNames: "dayFirstLetters", monthNames: "months", abbreviatedMonthNames: "monthAbbr", formatPatterns: "formatPatterns", regexPatterns: "regex", abbreviatedTimeZoneDST: "timeZoneDST", abbreviatedTimeZoneStandard: "timeZoneStandard" }); shallowMerge(info, constructedInfo); buildInfo.timeZones(info); return info; }; $D.i18n = { __: function (key, lang) { return __(key, lang); }, currentLanguage: function () { return lang || "en-US"; }, setLanguage: function (code, force, cb) { var async = false; if (force || code === "en-US" || (!!Date.CultureStrings && !!Date.CultureStrings[code])) { lang = code; Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings.lang = code; Date.CultureInfo = new CultureInfo(); } else { if (!(!!Date.CultureStrings && !!Date.CultureStrings[code])) { if (typeof exports !== "undefined" && this.exports !== exports) { // we're in a Node enviroment, load it using require try { require("../i18n/" + code + ".js"); lang = code; Date.CultureStrings.lang = code; Date.CultureInfo = new CultureInfo(); } catch (e) { // var str = "The language for '" + code + "' could not be loaded by Node. It likely does not exist."; throw new Error("The DateJS IETF language tag '" + code + "' could not be loaded by Node. It likely does not exist."); } } else if (Date.Config && Date.Config.i18n) { // we know the location of the files, so lets load them async = true; loadI18nScript(code).done(function(){ lang = code; Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings.lang = code; Date.CultureInfo = new CultureInfo(); $D.Parsing.Normalizer.buildReplaceData(); // because this is async if ($D.Grammar) { $D.Grammar.buildGrammarFormats(); // so we can parse those strings... } if (cb) { setTimeout(cb,0); } }); } else { Date.console.error("The DateJS IETF language tag '" + code + "' is not available and has not been loaded."); return false; } } } $D.Parsing.Normalizer.buildReplaceData(); // rebuild normalizer strings if ($D.Grammar) { $D.Grammar.buildGrammarFormats(); // so we can parse those strings... } if (!async && cb) { setTimeout(cb,0); } }, getLoggedKeys: function () { return loggedKeys; }, updateCultureInfo: function () { Date.CultureInfo = new CultureInfo(); } }; $D.i18n.updateCultureInfo(); // run automatically }()); (function () { var $D = Date, $P = $D.prototype, p = function (s, l) { if (!l) { l = 2; } return ("000" + s).slice(l * -1); }; if (typeof window !== "undefined" && typeof window.console !== "undefined" && typeof window.console.log !== "undefined") { $D.console = console; // used only to raise non-critical errors if available } else { // set mock so we don't give errors. $D.console = { log: function(){}, error: function(){} }; } $D.Config = $D.Config || {}; $D.initOverloads = function() { /** * Overload of Date.now. Allows an alternate call for Date.now where it returns the * current Date as an object rather than just milliseconds since the Unix Epoch. * * Also provides an implementation of now() for browsers (IE<9) that don't have it. * * Backwards compatible so with work with either: * Date.now() [returns ms] * or * Date.now(true) [returns Date] */ if (!$D.now) { $D._now = function now() { return new Date().getTime(); }; } else if (!$D._now) { $D._now = $D.now; } $D.now = function (returnObj) { if (returnObj) { return $D.present(); } else { return $D._now(); } }; if ( !$P.toISOString ) { $P.toISOString = function() { return this.getUTCFullYear() + "-" + p(this.getUTCMonth() + 1) + "-" + p(this.getUTCDate()) + "T" + p(this.getUTCHours()) + ":" + p(this.getUTCMinutes()) + ":" + p(this.getUTCSeconds()) + "." + String( (this.getUTCMilliseconds()/1000).toFixed(3)).slice(2, 5) + "Z"; }; } // private if ( $P._toString === undefined ){ $P._toString = $P.toString; } }; $D.initOverloads(); /** * Gets a date that is set to the current date. The time is set to the start of the day (00:00 or 12:00 AM). * @return {Date} The current date. */ $D.today = function () { return new Date().clearTime(); }; /** * Gets a date that is set to the current date and time (same as new Date, but chainable) * @return {Date} The current date. */ $D.present = function () { return new Date(); }; /** * Compares the first date to the second date and returns an number indication of their relative values. * @param {Date} First Date object to compare [Required]. * @param {Date} Second Date object to compare to [Required]. * @return {Number} -1 = date1 is lessthan date2. 0 = values are equal. 1 = date1 is greaterthan date2. */ $D.compare = function (date1, date2) { if (isNaN(date1) || isNaN(date2)) { throw new Error(date1 + " - " + date2); } else if (date1 instanceof Date && date2 instanceof Date) { return (date1 < date2) ? -1 : (date1 > date2) ? 1 : 0; } else { throw new TypeError(date1 + " - " + date2); } }; /** * Compares the first Date object to the second Date object and returns true if they are equal. * @param {Date} First Date object to compare [Required] * @param {Date} Second Date object to compare to [Required] * @return {Boolean} true if dates are equal. false if they are not equal. */ $D.equals = function (date1, date2) { return (date1.compareTo(date2) === 0); }; /** * Gets the language appropriate day name when given the day number(0-6) * eg - 0 == Sunday * @return {String} The day name */ $D.getDayName = function (n) { return Date.CultureInfo.dayNames[n]; }; /** * Gets the day number (0-6) if given a CultureInfo specific string which is a valid dayName, abbreviatedDayName or shortestDayName (two char). * @param {String} The name of the day (eg. "Monday, "Mon", "tuesday", "tue", "We", "we"). * @return {Number} The day number */ $D.getDayNumberFromName = function (name) { var n = Date.CultureInfo.dayNames, m = Date.CultureInfo.abbreviatedDayNames, o = Date.CultureInfo.shortestDayNames, s = name.toLowerCase(); for (var i = 0; i < n.length; i++) { if (n[i].toLowerCase() === s || m[i].toLowerCase() === s || o[i].toLowerCase() === s) { return i; } } return -1; }; /** * Gets the month number (0-11) if given a Culture Info specific string which is a valid monthName or abbreviatedMonthName. * @param {String} The name of the month (eg. "February, "Feb", "october", "oct"). * @return {Number} The day number */ $D.getMonthNumberFromName = function (name) { var n = Date.CultureInfo.monthNames, m = Date.CultureInfo.abbreviatedMonthNames, s = name.toLowerCase(); for (var i = 0; i < n.length; i++) { if (n[i].toLowerCase() === s || m[i].toLowerCase() === s) { return i; } } return -1; }; /** * Gets the language appropriate month name when given the month number(0-11) * eg - 0 == January * @return {String} The month name */ $D.getMonthName = function (n) { return Date.CultureInfo.monthNames[n]; }; /** * Determines if the current date instance is within a LeapYear. * @param {Number} The year. * @return {Boolean} true if date is within a LeapYear, otherwise false. */ $D.isLeapYear = function (year) { return ((year % 4 === 0 && year % 100 !== 0) || year % 400 === 0); }; /** * Gets the number of days in the month, given a year and month value. Automatically corrects for LeapYear. * @param {Number} The year. * @param {Number} The month (0-11). * @return {Number} The number of days in the month. */ $D.getDaysInMonth = function (year, month) { if (!month && $D.validateMonth(year)) { month = year; year = Date.today().getFullYear(); } return [31, ($D.isLeapYear(year) ? 29 : 28), 31, 30, 31, 30, 31, 31, 30, 31, 30, 31][month]; }; $P.getDaysInMonth = function () { return $D.getDaysInMonth(this.getFullYear(), this.getMonth()); }; $D.getTimezoneAbbreviation = function (offset, dst) { var p, n = (dst || false) ? Date.CultureInfo.abbreviatedTimeZoneDST : Date.CultureInfo.abbreviatedTimeZoneStandard; for (p in n) { if (n.hasOwnProperty(p)) { if (n[p] === offset) { return p; } } } return null; }; $D.getTimezoneOffset = function (name, dst) { var i, a =[], z = Date.CultureInfo.timezones; if (!name) { name = (new Date()).getTimezone();} for (i = 0; i < z.length; i++) { if (z[i].name === name.toUpperCase()) { a.push(i); } } if (!z[a[0]]) { return null; } if (a.length === 1 || !dst) { return z[a[0]].offset; } else { for (i=0; i < a.length; i++) { if (z[a[i]].dst) { return z[a[i]].offset; } } } }; $D.getQuarter = function (d) { d = d || new Date(); // If no date supplied, use today var q = [1,2,3,4]; return q[Math.floor(d.getMonth() / 3)]; // ~~~ is a bitwise op. Faster than Math.floor }; $D.getDaysLeftInQuarter = function (d) { d = d || new Date(); var qEnd = new Date(d); qEnd.setMonth(qEnd.getMonth() + 3 - qEnd.getMonth() % 3, 0); return Math.floor((qEnd - d) / 8.64e7); }; // private var validate = function (n, min, max, name) { name = name ? name : "Object"; if (typeof n === "undefined") { return false; } else if (typeof n !== "number") { throw new TypeError(n + " is not a Number."); } else if (n < min || n > max) { // As failing validation is *not* an exceptional circumstance // lets not throw a RangeError Exception here. // It's semantically correct but it's not sensible. return false; } return true; }; /** * Validates the number is within an acceptable range for milliseconds [0-999]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateMillisecond = function (value) { return validate(value, 0, 999, "millisecond"); }; /** * Validates the number is within an acceptable range for seconds [0-59]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateSecond = function (value) { return validate(value, 0, 59, "second"); }; /** * Validates the number is within an acceptable range for minutes [0-59]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateMinute = function (value) { return validate(value, 0, 59, "minute"); }; /** * Validates the number is within an acceptable range for hours [0-23]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateHour = function (value) { return validate(value, 0, 23, "hour"); }; /** * Validates the number is within an acceptable range for the days in a month [0-MaxDaysInMonth]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateDay = function (value, year, month) { if (year === undefined || year === null || month === undefined || month === null) { return false;} return validate(value, 1, $D.getDaysInMonth(year, month), "day"); }; /** * Validates the number is within an acceptable range for months [0-11]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateWeek = function (value) { return validate(value, 0, 53, "week"); }; /** * Validates the number is within an acceptable range for months [0-11]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateMonth = function (value) { return validate(value, 0, 11, "month"); }; /** * Validates the number is within an acceptable range for years. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateYear = function (value) { /** * Per ECMAScript spec the range of times supported by Date objects is * exactly -100,000,000 days to +100,000,000 days measured relative to * midnight at the beginning of 01 January, 1970 UTC. * This gives a range of 8,640,000,000,000,000 milliseconds to either * side of 01 January, 1970 UTC. * * Earliest possible date: Tue, 20 Apr 271,822 B.C. 00:00:00 UTC * Latest possible date: Sat, 13 Sep 275,760 00:00:00 UTC */ return validate(value, -271822, 275760, "year"); }; $D.validateTimezone = function(value) { var timezones = {"ACDT":1,"ACST":1,"ACT":1,"ADT":1,"AEDT":1,"AEST":1,"AFT":1,"AKDT":1,"AKST":1,"AMST":1,"AMT":1,"ART":1,"AST":1,"AWDT":1,"AWST":1,"AZOST":1,"AZT":1,"BDT":1,"BIOT":1,"BIT":1,"BOT":1,"BRT":1,"BST":1,"BTT":1,"CAT":1,"CCT":1,"CDT":1,"CEDT":1,"CEST":1,"CET":1,"CHADT":1,"CHAST":1,"CHOT":1,"ChST":1,"CHUT":1,"CIST":1,"CIT":1,"CKT":1,"CLST":1,"CLT":1,"COST":1,"COT":1,"CST":1,"CT":1,"CVT":1,"CWST":1,"CXT":1,"DAVT":1,"DDUT":1,"DFT":1,"EASST":1,"EAST":1,"EAT":1,"ECT":1,"EDT":1,"EEDT":1,"EEST":1,"EET":1,"EGST":1,"EGT":1,"EIT":1,"EST":1,"FET":1,"FJT":1,"FKST":1,"FKT":1,"FNT":1,"GALT":1,"GAMT":1,"GET":1,"GFT":1,"GILT":1,"GIT":1,"GMT":1,"GST":1,"GYT":1,"HADT":1,"HAEC":1,"HAST":1,"HKT":1,"HMT":1,"HOVT":1,"HST":1,"ICT":1,"IDT":1,"IOT":1,"IRDT":1,"IRKT":1,"IRST":1,"IST":1,"JST":1,"KGT":1,"KOST":1,"KRAT":1,"KST":1,"LHST":1,"LINT":1,"MAGT":1,"MART":1,"MAWT":1,"MDT":1,"MET":1,"MEST":1,"MHT":1,"MIST":1,"MIT":1,"MMT":1,"MSK":1,"MST":1,"MUT":1,"MVT":1,"MYT":1,"NCT":1,"NDT":1,"NFT":1,"NPT":1,"NST":1,"NT":1,"NUT":1,"NZDT":1,"NZST":1,"OMST":1,"ORAT":1,"PDT":1,"PET":1,"PETT":1,"PGT":1,"PHOT":1,"PHT":1,"PKT":1,"PMDT":1,"PMST":1,"PONT":1,"PST":1,"PYST":1,"PYT":1,"RET":1,"ROTT":1,"SAKT":1,"SAMT":1,"SAST":1,"SBT":1,"SCT":1,"SGT":1,"SLST":1,"SRT":1,"SST":1,"SYOT":1,"TAHT":1,"THA":1,"TFT":1,"TJT":1,"TKT":1,"TLT":1,"TMT":1,"TOT":1,"TVT":1,"UCT":1,"ULAT":1,"UTC":1,"UYST":1,"UYT":1,"UZT":1,"VET":1,"VLAT":1,"VOLT":1,"VOST":1,"VUT":1,"WAKT":1,"WAST":1,"WAT":1,"WEDT":1,"WEST":1,"WET":1,"WST":1,"YAKT":1,"YEKT":1,"Z":1}; return (timezones[value] === 1); }; $D.validateTimezoneOffset= function(value) { // timezones go from +14hrs to -12hrs, the +X hours are negative offsets. return (value > -841 && value < 721); }; }()); (function () { var $D = Date, $P = $D.prototype, p = function (s, l) { if (!l) { l = 2; } return ("000" + s).slice(l * -1); }; var validateConfigObject = function (obj) { var result = {}, self = this, prop, testFunc; testFunc = function (prop, func, value) { if (prop === "day") { var month = (obj.month !== undefined) ? obj.month : self.getMonth(); var year = (obj.year !== undefined) ? obj.year : self.getFullYear(); return $D[func](value, year, month); } else { return $D[func](value); } }; for (prop in obj) { if (Object.prototype.hasOwnProperty.call(obj, prop)) { var func = "validate" + prop.charAt(0).toUpperCase() + prop.slice(1); if ($D[func] && obj[prop] !== null && testFunc(prop, func, obj[prop])) { result[prop] = obj[prop]; } } } return result; }; /** * Resets the time of this Date object to 12:00 AM (00:00), which is the start of the day. * @param {Boolean} .clone() this date instance before clearing Time * @return {Date} this */ $P.clearTime = function () { this.setHours(0); this.setMinutes(0); this.setSeconds(0); this.setMilliseconds(0); return this; }; /** * Resets the time of this Date object to the current time ('now'). * @return {Date} this */ $P.setTimeToNow = function () { var n = new Date(); this.setHours(n.getHours()); this.setMinutes(n.getMinutes()); this.setSeconds(n.getSeconds()); this.setMilliseconds(n.getMilliseconds()); return this; }; /** * Returns a new Date object that is an exact date and time copy of the original instance. * @return {Date} A new Date instance */ $P.clone = function () { return new Date(this.getTime()); }; /** * Compares this instance to a Date object and returns an number indication of their relative values. * @param {Date} Date object to compare [Required] * @return {Number} -1 = this is lessthan date. 0 = values are equal. 1 = this is greaterthan date. */ $P.compareTo = function (date) { return Date.compare(this, date); }; /** * Compares this instance to another Date object and returns true if they are equal. * @param {Date} Date object to compare. If no date to compare, new Date() [now] is used. * @return {Boolean} true if dates are equal. false if they are not equal. */ $P.equals = function (date) { return Date.equals(this, (date !== undefined ? date : new Date())); }; /** * Determines if this instance is between a range of two dates or equal to either the start or end dates. * @param {Date} Start of range [Required] * @param {Date} End of range [Required] * @return {Boolean} true is this is between or equal to the start and end dates, else false */ $P.between = function (start, end) { return this.getTime() >= start.getTime() && this.getTime() <= end.getTime(); }; /** * Determines if this date occurs after the date to compare to. * @param {Date} Date object to compare. If no date to compare, new Date() ("now") is used. * @return {Boolean} true if this date instance is greater than the date to compare to (or "now"), otherwise false. */ $P.isAfter = function (date) { return this.compareTo(date || new Date()) === 1; }; /** * Determines if this date occurs before the date to compare to. * @param {Date} Date object to compare. If no date to compare, new Date() ("now") is used. * @return {Boolean} true if this date instance is less than the date to compare to (or "now"). */ $P.isBefore = function (date) { return (this.compareTo(date || new Date()) === -1); }; /** * Determines if the current Date instance occurs today. * @return {Boolean} true if this date instance is 'today', otherwise false. */ /** * Determines if the current Date instance occurs on the same Date as the supplied 'date'. * If no 'date' to compare to is provided, the current Date instance is compared to 'today'. * @param {date} Date object to compare. If no date to compare, the current Date ("now") is used. * @return {Boolean} true if this Date instance occurs on the same Day as the supplied 'date'. */ $P.isToday = $P.isSameDay = function (date) { return this.clone().clearTime().equals((date || new Date()).clone().clearTime()); }; /** * Adds the specified number of milliseconds to this instance. * @param {Number} The number of milliseconds to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addMilliseconds = function (value) { if (!value) { return this; } this.setTime(this.getTime() + value * 1); return this; }; /** * Adds the specified number of seconds to this instance. * @param {Number} The number of seconds to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addSeconds = function (value) { if (!value) { return this; } return this.addMilliseconds(value * 1000); }; /** * Adds the specified number of seconds to this instance. * @param {Number} The number of seconds to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addMinutes = function (value) { if (!value) { return this; } return this.addMilliseconds(value * 60000); // 60*1000 }; /** * Adds the specified number of hours to this instance. * @param {Number} The number of hours to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addHours = function (value) { if (!value) { return this; } return this.addMilliseconds(value * 3600000); // 60*60*1000 }; /** * Adds the specified number of days to this instance. * @param {Number} The number of days to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addDays = function (value) { if (!value) { return this; } this.setDate(this.getDate() + value * 1); return this; }; /** * Adds the specified number of weekdays (ie - not sat or sun) to this instance. * @param {Number} The number of days to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addWeekdays = function (value) { if (!value) { return this; } var day = this.getDay(); var weeks = (Math.ceil(Math.abs(value)/7)); if (day === 0 || day === 6) { if (value > 0) { this.next().monday(); this.addDays(-1); day = this.getDay(); } } if (value < 0) { while (value < 0) { this.addDays(-1); day = this.getDay(); if (day !== 0 && day !== 6) { value++; } } return this; } else if (value > 5 || (6-day) <= value) { value = value + (weeks * 2); } return this.addDays(value); }; /** * Adds the specified number of weeks to this instance. * @param {Number} The number of weeks to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addWeeks = function (value) { if (!value) { return this; } return this.addDays(value * 7); }; /** * Adds the specified number of months to this instance. * @param {Number} The number of months to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addMonths = function (value) { if (!value) { return this; } var n = this.getDate(); this.setDate(1); this.setMonth(this.getMonth() + value * 1); this.setDate(Math.min(n, $D.getDaysInMonth(this.getFullYear(), this.getMonth()))); return this; }; $P.addQuarters = function (value) { if (!value) { return this; } // note this will take you to the same point in the quarter as you are now. // i.e. - if you are 15 days into the quarter you'll be 15 days into the resulting one. // bonus: this allows adding fractional quarters return this.addMonths(value * 3); }; /** * Adds the specified number of years to this instance. * @param {Number} The number of years to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addYears = function (value) { if (!value) { return this; } return this.addMonths(value * 12); }; /** * Adds (or subtracts) to the value of the years, months, weeks, days, hours, minutes, seconds, milliseconds of the date instance using given configuration object. Positive and Negative values allowed. * Example

	Date.today().add( { days: 1, months: 1 } )

	new Date().add( { years: -1 } )
	
* @param {Object} Configuration object containing attributes (months, days, etc.) * @return {Date} this */ $P.add = function (config) { if (typeof config === "number") { this._orient = config; return this; } var x = config; if (x.day) { // If we should be a different date than today (eg: for 'tomorrow -1d', etc). // Should only effect parsing, not direct usage (eg, Finish and FinishExact) if ((x.day - this.getDate()) !== 0) { this.setDate(x.day); } } if (x.milliseconds) { this.addMilliseconds(x.milliseconds); } if (x.seconds) { this.addSeconds(x.seconds); } if (x.minutes) { this.addMinutes(x.minutes); } if (x.hours) { this.addHours(x.hours); } if (x.weeks) { this.addWeeks(x.weeks); } if (x.months) { this.addMonths(x.months); } if (x.years) { this.addYears(x.years); } if (x.days) { this.addDays(x.days); } return this; }; /** * Get the week number. Week one (1) is the week which contains the first Thursday of the year. Monday is considered the first day of the week. * The .getWeek() function does NOT convert the date to UTC. The local datetime is used. * Please use .getISOWeek() to get the week of the UTC converted date. * @return {Number} 1 to 53 */ $P.getWeek = function (utc) { // Create a copy of this date object var self, target = new Date(this.valueOf()); if (utc) { target.addMinutes(target.getTimezoneOffset()); self = target.clone(); } else { self = this; } // ISO week date weeks start on monday // so correct the day number var dayNr = (self.getDay() + 6) % 7; // ISO 8601 states that week 1 is the week // with the first thursday of that year. // Set the target date to the thursday in the target week target.setDate(target.getDate() - dayNr + 3); // Store the millisecond value of the target date var firstThursday = target.valueOf(); // Set the target to the first thursday of the year // First set the target to january first target.setMonth(0, 1); // Not a thursday? Correct the date to the next thursday if (target.getDay() !== 4) { target.setMonth(0, 1 + ((4 - target.getDay()) + 7) % 7); } // The weeknumber is the number of weeks between the // first thursday of the year and the thursday in the target week return 1 + Math.ceil((firstThursday - target) / 604800000); // 604800000 = 7 * 24 * 3600 * 1000 }; /** * Get the ISO 8601 week number. Week one ("01") is the week which contains the first Thursday of the year. Monday is considered the first day of the week. * The .getISOWeek() function does convert the date to it's UTC value. Please use .getWeek() to get the week of the local date. * @return {String} "01" to "53" */ $P.getISOWeek = function () { return p(this.getWeek(true)); }; /** * Moves the date to Monday of the week set. Week one (1) is the week which contains the first Thursday of the year. * @param {Number} A Number (1 to 53) that represents the week of the year. * @return {Date} this */ $P.setWeek = function (n) { if ((n - this.getWeek()) === 0) { if (this.getDay() !== 1) { return this.moveToDayOfWeek(1, (this.getDay() > 1 ? -1 : 1)); } else { return this; } } else { return this.moveToDayOfWeek(1, (this.getDay() > 1 ? -1 : 1)).addWeeks(n - this.getWeek()); } }; $P.setQuarter = function (qtr) { var month = Math.abs(((qtr-1) * 3) + 1); return this.setMonth(month, 1); }; $P.getQuarter = function () { return Date.getQuarter(this); }; $P.getDaysLeftInQuarter = function () { return Date.getDaysLeftInQuarter(this); }; /** * Moves the date to the next n'th occurrence of the dayOfWeek starting from the beginning of the month. The number (-1) is a magic number and will return the last occurrence of the dayOfWeek in the month. * @param {Number} The dayOfWeek to move to * @param {Number} The n'th occurrence to move to. Use (-1) to return the last occurrence in the month * @return {Date} this */ $P.moveToNthOccurrence = function (dayOfWeek, occurrence) { if (dayOfWeek === "Weekday") { if (occurrence > 0) { this.moveToFirstDayOfMonth(); if (this.is().weekday()) { occurrence -= 1; } } else if (occurrence < 0) { this.moveToLastDayOfMonth(); if (this.is().weekday()) { occurrence += 1; } } else { return this; } return this.addWeekdays(occurrence); } var shift = 0; if (occurrence > 0) { shift = occurrence - 1; } else if (occurrence === -1) { this.moveToLastDayOfMonth(); if (this.getDay() !== dayOfWeek) { this.moveToDayOfWeek(dayOfWeek, -1); } return this; } return this.moveToFirstDayOfMonth().addDays(-1).moveToDayOfWeek(dayOfWeek, +1).addWeeks(shift); }; var moveToN = function (getFunc, addFunc, nVal) { return function (value, orient) { var diff = (value - this[getFunc]() + nVal * (orient || +1)) % nVal; return this[addFunc]((diff === 0) ? diff += nVal * (orient || +1) : diff); }; }; /** * Move to the next or last dayOfWeek based on the orient value. * @param {Number} The dayOfWeek to move to * @param {Number} Forward (+1) or Back (-1). Defaults to +1. [Optional] * @return {Date} this */ $P.moveToDayOfWeek = moveToN("getDay", "addDays", 7); /** * Move to the next or last month based on the orient value. * @param {Number} The month to move to. 0 = January, 11 = December * @param {Number} Forward (+1) or Back (-1). Defaults to +1. [Optional] * @return {Date} this */ $P.moveToMonth = moveToN("getMonth", "addMonths", 12); /** * Get the Ordinate of the current day ("th", "st", "rd"). * @return {String} */ $P.getOrdinate = function () { var num = this.getDate(); return ord(num); }; /** * Get the Ordinal day (numeric day number) of the year, adjusted for leap year. * @return {Number} 1 through 365 (366 in leap years) */ $P.getOrdinalNumber = function () { return Math.ceil((this.clone().clearTime() - new Date(this.getFullYear(), 0, 1)) / 86400000) + 1; }; /** * Get the time zone abbreviation of the current date. * @return {String} The abbreviated time zone name (e.g. "EST") */ $P.getTimezone = function () { return $D.getTimezoneAbbreviation(this.getUTCOffset(), this.isDaylightSavingTime()); }; $P.setTimezoneOffset = function (offset) { var here = this.getTimezoneOffset(), there = Number(offset) * -6 / 10; return (there || there === 0) ? this.addMinutes(there - here) : this; }; $P.setTimezone = function (offset) { return this.setTimezoneOffset($D.getTimezoneOffset(offset)); }; /** * Indicates whether Daylight Saving Time is observed in the current time zone. * @return {Boolean} true|false */ $P.hasDaylightSavingTime = function () { return (Date.today().set({month: 0, day: 1}).getTimezoneOffset() !== Date.today().set({month: 6, day: 1}).getTimezoneOffset()); }; /** * Indicates whether this Date instance is within the Daylight Saving Time range for the current time zone. * @return {Boolean} true|false */ $P.isDaylightSavingTime = function () { return Date.today().set({month: 0, day: 1}).getTimezoneOffset() !== this.getTimezoneOffset(); }; /** * Get the offset from UTC of the current date. * @return {String} The 4-character offset string prefixed with + or - (e.g. "-0500") */ $P.getUTCOffset = function (offset) { var n = (offset || this.getTimezoneOffset()) * -10 / 6, r; if (n < 0) { r = (n - 10000).toString(); return r.charAt(0) + r.substr(2); } else { r = (n + 10000).toString(); return "+" + r.substr(1); } }; /** * Returns the number of milliseconds between this date and date. * @param {Date} Defaults to now * @return {Number} The diff in milliseconds */ $P.getElapsed = function (date) { return (date || new Date()) - this; }; /** * Set the value of year, month, day, hour, minute, second, millisecond of date instance using given configuration object. * Example

	Date.today().set( { day: 20, month: 1 } )

	new Date().set( { millisecond: 0 } )
	
* * @param {Object} Configuration object containing attributes (month, day, etc.) * @return {Date} this */ $P.set = function (config) { config = validateConfigObject.call(this, config); var key; for (key in config) { if (Object.prototype.hasOwnProperty.call(config, key)) { var name = key.charAt(0).toUpperCase() + key.slice(1); var addFunc, getFunc; if (key !== "week" && key !== "month" && key !== "timezone" && key !== "timezoneOffset") { name += "s"; } addFunc = "add" + name; getFunc = "get" + name; if (key === "month") { addFunc = addFunc + "s"; } else if (key === "year"){ getFunc = "getFullYear"; } if (key !== "day" && key !== "timezone" && key !== "timezoneOffset" && key !== "week" && key !== "hour") { this[addFunc](config[key] - this[getFunc]()); } else if ( key === "timezone"|| key === "timezoneOffset" || key === "week" || key === "hour") { this["set"+name](config[key]); } } } // day has to go last because you can't validate the day without first knowing the month if (config.day) { this.addDays(config.day - this.getDate()); } return this; }; /** * Moves the date to the first day of the month. * @return {Date} this */ $P.moveToFirstDayOfMonth = function () { return this.set({ day: 1 }); }; /** * Moves the date to the last day of the month. * @return {Date} this */ $P.moveToLastDayOfMonth = function () { return this.set({ day: $D.getDaysInMonth(this.getFullYear(), this.getMonth())}); }; /** * Converts the value of the current Date object to its equivalent string representation. * Format Specifiers * CUSTOM DATE AND TIME FORMAT STRINGS * Format Description Example * ------ --------------------------------------------------------------------------- ----------------------- * s The seconds of the minute between 0-59. "0" to "59" * ss The seconds of the minute with leading zero if required. "00" to "59" * * m The minute of the hour between 0-59. "0" or "59" * mm The minute of the hour with leading zero if required. "00" or "59" * * h The hour of the day between 1-12. "1" to "12" * hh The hour of the day with leading zero if required. "01" to "12" * * H The hour of the day between 0-23. "0" to "23" * HH The hour of the day with leading zero if required. "00" to "23" * * d The day of the month between 1 and 31. "1" to "31" * dd The day of the month with leading zero if required. "01" to "31" * ddd Abbreviated day name. Date.CultureInfo.abbreviatedDayNames. "Mon" to "Sun" * dddd The full day name. Date.CultureInfo.dayNames. "Monday" to "Sunday" * * M The month of the year between 1-12. "1" to "12" * MM The month of the year with leading zero if required. "01" to "12" * MMM Abbreviated month name. Date.CultureInfo.abbreviatedMonthNames. "Jan" to "Dec" * MMMM The full month name. Date.CultureInfo.monthNames. "January" to "December" * * yy The year as a two-digit number. "99" or "08" * yyyy The full four digit year. "1999" or "2008" * * t Displays the first character of the A.M./P.M. designator. "A" or "P" * Date.CultureInfo.amDesignator or Date.CultureInfo.pmDesignator * tt Displays the A.M./P.M. designator. "AM" or "PM" * Date.CultureInfo.amDesignator or Date.CultureInfo.pmDesignator * * S The ordinal suffix ("st, "nd", "rd" or "th") of the current day. "st, "nd", "rd" or "th" * * STANDARD DATE AND TIME FORMAT STRINGS * Format Description Example *------ --------------------------------------------------------------------------- ----------------------- * d The CultureInfo shortDate Format Pattern "M/d/yyyy" * D The CultureInfo longDate Format Pattern "dddd, MMMM dd, yyyy" * F The CultureInfo fullDateTime Format Pattern "dddd, MMMM dd, yyyy h:mm:ss tt" * m The CultureInfo monthDay Format Pattern "MMMM dd" * r The CultureInfo rfc1123 Format Pattern "ddd, dd MMM yyyy HH:mm:ss GMT" * s The CultureInfo sortableDateTime Format Pattern "yyyy-MM-ddTHH:mm:ss" * t The CultureInfo shortTime Format Pattern "h:mm tt" * T The CultureInfo longTime Format Pattern "h:mm:ss tt" * u The CultureInfo universalSortableDateTime Format Pattern "yyyy-MM-dd HH:mm:ssZ" * y The CultureInfo yearMonth Format Pattern "MMMM, yyyy" * * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @return {String} A string representation of the current Date object. */ var ord = function (n) { switch (n * 1) { case 1: case 21: case 31: return "st"; case 2: case 22: return "nd"; case 3: case 23: return "rd"; default: return "th"; } }; var parseStandardFormats = function (format) { var y, c = Date.CultureInfo.formatPatterns; switch (format) { case "d": return this.toString(c.shortDate); case "D": return this.toString(c.longDate); case "F": return this.toString(c.fullDateTime); case "m": return this.toString(c.monthDay); case "r": case "R": y = this.clone().addMinutes(this.getTimezoneOffset()); return y.toString(c.rfc1123) + " GMT"; case "s": return this.toString(c.sortableDateTime); case "t": return this.toString(c.shortTime); case "T": return this.toString(c.longTime); case "u": y = this.clone().addMinutes(this.getTimezoneOffset()); return y.toString(c.universalSortableDateTime); case "y": return this.toString(c.yearMonth); default: return false; } }; var parseFormatStringsClosure = function (context) { return function (m) { if (m.charAt(0) === "\\") { return m.replace("\\", ""); } switch (m) { case "hh": return p(context.getHours() < 13 ? (context.getHours() === 0 ? 12 : context.getHours()) : (context.getHours() - 12)); case "h": return context.getHours() < 13 ? (context.getHours() === 0 ? 12 : context.getHours()) : (context.getHours() - 12); case "HH": return p(context.getHours()); case "H": return context.getHours(); case "mm": return p(context.getMinutes()); case "m": return context.getMinutes(); case "ss": return p(context.getSeconds()); case "s": return context.getSeconds(); case "yyyy": return p(context.getFullYear(), 4); case "yy": return p(context.getFullYear()); case "y": return context.getFullYear(); case "E": case "dddd": return Date.CultureInfo.dayNames[context.getDay()]; case "ddd": return Date.CultureInfo.abbreviatedDayNames[context.getDay()]; case "dd": return p(context.getDate()); case "d": return context.getDate(); case "MMMM": return Date.CultureInfo.monthNames[context.getMonth()]; case "MMM": return Date.CultureInfo.abbreviatedMonthNames[context.getMonth()]; case "MM": return p((context.getMonth() + 1)); case "M": return context.getMonth() + 1; case "t": return context.getHours() < 12 ? Date.CultureInfo.amDesignator.substring(0, 1) : Date.CultureInfo.pmDesignator.substring(0, 1); case "tt": return context.getHours() < 12 ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator; case "S": return ord(context.getDate()); case "W": return context.getWeek(); case "WW": return context.getISOWeek(); case "Q": return "Q" + context.getQuarter(); case "q": return String(context.getQuarter()); case "z": return context.getTimezone(); case "Z": case "X": return Date.getTimezoneOffset(context.getTimezone()); case "ZZ": // Timezone offset in seconds return context.getTimezoneOffset() * -60; case "u": return context.getDay(); case "L": return ($D.isLeapYear(context.getFullYear())) ? 1 : 0; case "B": // Swatch Internet Time (.beats) return "@"+((context.getUTCSeconds() + (context.getUTCMinutes()*60) + ((context.getUTCHours()+1)*3600))/86.4); default: return m; } }; }; $P.toString = function (format, ignoreStandards) { // Standard Date and Time Format Strings. Formats pulled from CultureInfo file and // may vary by culture. if (!ignoreStandards && format && format.length === 1) { output = parseStandardFormats.call(this, format); if (output) { return output; } } var parseFormatStrings = parseFormatStringsClosure(this); return format ? format.replace(/((\\)?(dd?d?d?|MM?M?M?|yy?y?y?|hh?|HH?|mm?|ss?|tt?|S|q|Q|WW?W?W?)(?![^\[]*\]))/g, parseFormatStrings).replace(/\[|\]/g, "") : this._toString(); }; }()); /************************************************************* * SugarPak - Domain Specific Language - Syntactical Sugar * *************************************************************/ (function () { var $D = Date, $P = $D.prototype, $N = Number.prototype; // private $P._orient = +1; // private $P._nth = null; // private $P._is = false; // private $P._same = false; // private $P._isSecond = false; // private $N._dateElement = "days"; /** * Moves the date to the next instance of a date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.today().next().friday();
	Date.today().next().fri();
	Date.today().next().march();
	Date.today().next().mar();
	Date.today().next().week();
	
* * @return {Date} date */ $P.next = function () { this._move = true; this._orient = +1; return this; }; /** * Creates a new Date (Date.today()) and moves the date to the next instance of the date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.next().friday();
	Date.next().fri();
	Date.next().march();
	Date.next().mar();
	Date.next().week();
	
* * @return {Date} date */ $D.next = function () { return $D.today().next(); }; /** * Moves the date to the previous instance of a date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.today().last().friday();
	Date.today().last().fri();
	Date.today().last().march();
	Date.today().last().mar();
	Date.today().last().week();
	
* * @return {Date} date */ $P.last = $P.prev = $P.previous = function () { this._move = true; this._orient = -1; return this; }; /** * Creates a new Date (Date.today()) and moves the date to the previous instance of the date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.last().friday();
	Date.last().fri();
	Date.previous().march();
	Date.prev().mar();
	Date.last().week();
	
* * @return {Date} date */ $D.last = $D.prev = $D.previous = function () { return $D.today().last(); }; /** * Performs a equality check when followed by either a month name, day name or .weekday() function. * Example

	Date.today().is().friday(); // true|false
	Date.today().is().fri();
	Date.today().is().march();
	Date.today().is().mar();
	
* * @return {Boolean} true|false */ $P.is = function () { this._is = true; return this; }; /** * Determines if two date objects occur on/in exactly the same instance of the subsequent date part function. * The function .same() must be followed by a date part function (example: .day(), .month(), .year(), etc). * * An optional Date can be passed in the date part function. If now date is passed as a parameter, 'Now' is used. * * The following example demonstrates how to determine if two dates fall on the exact same day. * * Example

	var d1 = Date.today(); // today at 00:00
	var d2 = new Date();   // exactly now.

	// Do they occur on the same day?
	d1.same().day(d2); // true
	
	// Do they occur on the same hour?
	d1.same().hour(d2); // false, unless d2 hour is '00' (midnight).
	
	// What if it's the same day, but one year apart?
	var nextYear = Date.today().add(1).year();

	d1.same().day(nextYear); // false, because the dates must occur on the exact same day. 
	
* * Scenario: Determine if a given date occurs during some week period 2 months from now. * * Example

	var future = Date.today().add(2).months();
	return someDate.same().week(future); // true|false;
	
* * @return {Boolean} true|false */ $P.same = function () { this._same = true; this._isSecond = false; return this; }; /** * Determines if the current date/time occurs during Today. Must be preceded by the .is() function. * Example

	someDate.is().today();    // true|false
	new Date().is().today();  // true
	Date.today().is().today();// true
	Date.today().add(-1).day().is().today(); // false
	
* * @return {Boolean} true|false */ $P.today = function () { return this.same().day(); }; /** * Determines if the current date is a weekday. This function must be preceded by the .is() function. * Example

	Date.today().is().weekday(); // true|false
	
* * @return {Boolean} true|false */ $P.weekday = function () { if (this._nth) { return df("Weekday").call(this); } if (this._move) { return this.addWeekdays(this._orient); } if (this._is) { this._is = false; return (!this.is().sat() && !this.is().sun()); } return false; }; /** * Determines if the current date is on the weekend. This function must be preceded by the .is() function. * Example

	Date.today().is().weekend(); // true|false
	
* * @return {Boolean} true|false */ $P.weekend = function () { if (this._is) { this._is = false; return (this.is().sat() || this.is().sun()); } return false; }; /** * Sets the Time of the current Date instance. A string "6:15 pm" or config object {hour:18, minute:15} are accepted. * Example

	// Set time to 6:15pm with a String
	Date.today().at("6:15pm");

	// Set time to 6:15pm with a config object
	Date.today().at({hour:18, minute:15});
	
* * @return {Date} date */ $P.at = function (time) { return (typeof time === "string") ? $D.parse(this.toString("d") + " " + time) : this.set(time); }; /** * Creates a new Date() and adds this (Number) to the date based on the preceding date element function (eg. second|minute|hour|day|month|year). * Example

	// Undeclared Numbers must be wrapped with parentheses. Requirment of JavaScript.
	(3).days().fromNow();
	(6).months().fromNow();

	// Declared Number variables do not require parentheses. 
	var n = 6;
	n.months().fromNow();
	
* * @return {Date} A new Date instance */ $N.fromNow = $N.after = function (date) { var c = {}; c[this._dateElement] = this; return ((!date) ? new Date() : date.clone()).add(c); }; /** * Creates a new Date() and subtract this (Number) from the date based on the preceding date element function (eg. second|minute|hour|day|month|year). * Example

	// Undeclared Numbers must be wrapped with parentheses. Requirment of JavaScript.
	(3).days().ago();
	(6).months().ago();

	// Declared Number variables do not require parentheses. 
	var n = 6;
	n.months().ago();
	
* * @return {Date} A new Date instance */ $N.ago = $N.before = function (date) { var c = {}, s = (this._dateElement[this._dateElement.length-1] !== "s") ? this._dateElement + "s" : this._dateElement; c[s] = this * -1; return ((!date) ? new Date() : date.clone()).add(c); }; // Do NOT modify the following string tokens. These tokens are used to build dynamic functions. // All culture-specific strings can be found in the CultureInfo files. var dx = ("sunday monday tuesday wednesday thursday friday saturday").split(/\s/), mx = ("january february march april may june july august september october november december").split(/\s/), px = ("Millisecond Second Minute Hour Day Week Month Year Quarter Weekday").split(/\s/), pxf = ("Milliseconds Seconds Minutes Hours Date Week Month FullYear Quarter").split(/\s/), nth = ("final first second third fourth fifth").split(/\s/), de; /** * Returns an object literal of all the date parts. * Example

	var o = new Date().toObject();
	
	// { year: 2008, month: 4, week: 20, day: 13, hour: 18, minute: 9, second: 32, millisecond: 812 }
	
	// The object properties can be referenced directly from the object.
	
	alert(o.day);  // alerts "13"
	alert(o.year); // alerts "2008"
	
* * @return {Date} An object literal representing the original date object. */ $P.toObject = function () { var o = {}; for (var i = 0; i < px.length; i++) { if (this["get" + pxf[i]]) { o[px[i].toLowerCase()] = this["get" + pxf[i]](); } } return o; }; /** * Returns a date created from an object literal. Ignores the .week property if set in the config. * Example

	var o = new Date().toObject();
	
	return Date.fromObject(o); // will return the same date. 

	var o2 = {month: 1, day: 20, hour: 18}; // birthday party!
	Date.fromObject(o2);
	
* * @return {Date} An object literal representing the original date object. */ $D.fromObject = function(config) { config.week = null; return Date.today().set(config); }; // Create day name functions and abbreviated day name functions (eg. monday(), friday(), fri()). var df = function (n) { return function () { if (this._is) { this._is = false; return this.getDay() === n; } if (this._move) { this._move = null; } if (this._nth !== null) { // If the .second() function was called earlier, remove the _orient // from the date, and then continue. // This is required because 'second' can be used in two different context. // // Example // // Date.today().add(1).second(); // Date.march().second().monday(); // // Things get crazy with the following... // Date.march().add(1).second().second().monday(); // but it works!! // if (this._isSecond) { this.addSeconds(this._orient * -1); } // make sure we reset _isSecond this._isSecond = false; var ntemp = this._nth; this._nth = null; var temp = this.clone().moveToLastDayOfMonth(); this.moveToNthOccurrence(n, ntemp); if (this > temp) { throw new RangeError($D.getDayName(n) + " does not occur " + ntemp + " times in the month of " + $D.getMonthName(temp.getMonth()) + " " + temp.getFullYear() + "."); } return this; } return this.moveToDayOfWeek(n, this._orient); }; }; var sdf = function (n) { return function () { var t = $D.today(), shift = n - t.getDay(); if (n === 0 && Date.CultureInfo.firstDayOfWeek === 1 && t.getDay() !== 0) { shift = shift + 7; } return t.addDays(shift); }; }; // Create month name functions and abbreviated month name functions (eg. january(), march(), mar()). var month_instance_functions = function (n) { return function () { if (this._is) { this._is = false; return this.getMonth() === n; } return this.moveToMonth(n, this._orient); }; }; var month_static_functions = function (n) { return function () { return $D.today().set({ month: n, day: 1 }); }; }; var processTerms = function (names, staticFunc, instanceFunc) { for (var i = 0; i < names.length; i++) { // Create constant static Name variables. $D[names[i].toUpperCase()] = $D[names[i].toUpperCase().substring(0, 3)] = i; // Create Name functions. $D[names[i]] = $D[names[i].substring(0, 3)] = staticFunc(i); // Create Name instance functions. $P[names[i]] = $P[names[i].substring(0, 3)] = instanceFunc(i); } }; processTerms(dx, sdf, df); processTerms(mx, month_static_functions, month_instance_functions); // Create date element functions and plural date element functions used with Date (eg. day(), days(), months()). var ef = function (j) { return function () { // if the .second() function was called earlier, the _orient // has alread been added. Just return this and reset _isSecond. if (this._isSecond) { this._isSecond = false; return this; } if (this._same) { this._same = this._is = false; var o1 = this.toObject(), o2 = (arguments[0] || new Date()).toObject(), v = "", k = j.toLowerCase(); // the substr trick with -1 doesn't work in IE8 or less k = (k[k.length-1] === "s") ? k.substring(0,k.length-1) : k; for (var m = (px.length - 1); m > -1; m--) { v = px[m].toLowerCase(); if (o1[v] !== o2[v]) { return false; } if (k === v) { break; } } return true; } if (j.substring(j.length - 1) !== "s") { j += "s"; } if (this._move) { this._move = null; } return this["add" + j](this._orient); }; }; var nf = function (n) { return function () { this._dateElement = n; return this; }; }; for (var k = 0; k < px.length; k++) { de = px[k].toLowerCase(); if(de !== "weekday") { // Create date element functions and plural date element functions used with Date (eg. day(), days(), months()). $P[de] = $P[de + "s"] = ef(px[k]); // Create date element functions and plural date element functions used with Number (eg. day(), days(), months()). $N[de] = $N[de + "s"] = nf(de + "s"); } } $P._ss = ef("Second"); var nthfn = function (n) { return function (dayOfWeek) { if (this._same) { return this._ss(arguments[0]); } if (dayOfWeek || dayOfWeek === 0) { return this.moveToNthOccurrence(dayOfWeek, n); } this._nth = n; // if the operator is 'second' add the _orient, then deal with it later... if (n === 2 && (dayOfWeek === undefined || dayOfWeek === null)) { this._isSecond = true; return this.addSeconds(this._orient); } return this; }; }; for (var l = 0; l < nth.length; l++) { $P[nth[l]] = (l === 0) ? nthfn(-1) : nthfn(l); } }()); (function () { "use strict"; Date.Parsing = { Exception: function (s) { this.message = "Parse error at '" + s.substring(0, 10) + " ...'"; } }; var $P = Date.Parsing; var dayOffsets = { standard: [0,31,59,90,120,151,181,212,243,273,304,334], leap: [0,31,60,91,121,152,182,213,244,274,305,335] }; $P.isLeapYear = function(year) { return ((year % 4 === 0) && (year % 100 !== 0)) || (year % 400 === 0); }; var utils = { multiReplace : function (str, hash ) { var key; for (key in hash) { if (Object.prototype.hasOwnProperty.call(hash, key)) { var regex; if (typeof hash[key] === "function") { } else { regex = (hash[key] instanceof RegExp) ? hash[key] : new RegExp(hash[key], "g"); } str = str.replace(regex, key); } } return str; }, getDayOfYearFromWeek : function (obj) { var d, jan4, offset; obj.weekDay = (!obj.weekDay && obj.weekDay !== 0) ? 1 : obj.weekDay; d = new Date(obj.year, 0, 4); jan4 = d.getDay() === 0 ? 7 : d.getDay(); // JS is 0 indexed on Sunday. offset = jan4+3; obj.dayOfYear = ((obj.week * 7) + (obj.weekDay === 0 ? 7 : obj.weekDay))-offset; return obj; }, getDayOfYear : function (obj, dayOffset) { if (!obj.dayOfYear) { obj = utils.getDayOfYearFromWeek(obj); } for (var i=0;i <= dayOffset.length;i++) { if (obj.dayOfYear < dayOffset[i] || i === dayOffset.length) { obj.day = obj.day ? obj.day : (obj.dayOfYear - dayOffset[i-1]); break; } else { obj.month = i; } } return obj; }, adjustForTimeZone : function (obj, date) { var offset; if (obj.zone.toUpperCase() === "Z" || (obj.zone_hours === 0 && obj.zone_minutes === 0)) { // it's UTC/GML so work out the current timeszone offset offset = -date.getTimezoneOffset(); } else { offset = (obj.zone_hours*60) + (obj.zone_minutes || 0); if (obj.zone_sign === "+") { offset *= -1; } offset -= date.getTimezoneOffset(); } date.setMinutes(date.getMinutes()+offset); return date; }, setDefaults : function (obj) { obj.year = obj.year || Date.today().getFullYear(); obj.hours = obj.hours || 0; obj.minutes = obj.minutes || 0; obj.seconds = obj.seconds || 0; obj.milliseconds = obj.milliseconds || 0; if (!(!obj.month && (obj.week || obj.dayOfYear))) { // if we have a month, or if we don't but don't have the day calculation data obj.month = obj.month || 0; obj.day = obj.day || 1; } return obj; }, dataNum: function (data, mod, explict, postProcess) { var dataNum = data*1; if (mod) { if (postProcess) { return data ? mod(data)*1 : data; } else { return data ? mod(dataNum) : data; } } else if (!explict){ return data ? dataNum : data; } else { return (data && typeof data !== "undefined") ? dataNum : data; } }, timeDataProcess: function (obj) { var timeObj = {}; for (var x in obj.data) { if (obj.data.hasOwnProperty(x)) { timeObj[x] = obj.ignore[x] ? obj.data[x] : utils.dataNum(obj.data[x], obj.mods[x], obj.explict[x], obj.postProcess[x]); } } if (obj.data.secmins) { obj.data.secmins = obj.data.secmins.replace(",", ".") * 60; if (!timeObj.minutes) { timeObj.minutes = obj.data.secmins; } else if (!timeObj.seconds) { timeObj.seconds = obj.data.secmins; } delete obj.secmins; } return timeObj; }, buildTimeObjectFromData: function (data) { var time = utils.timeDataProcess({ data: { year : data[1], month : data[5], day : data[7], week : data[8], dayOfYear : data[10], hours : data[15], zone_hours : data[23], zone_minutes : data[24], zone : data[21], zone_sign : data[22], weekDay : data[9], minutes: data[16], seconds: data[19], milliseconds: data[20], secmins: data[18] }, mods: { month: function(data) { return data-1; }, weekDay: function (data) { data = Math.abs(data); return (data === 7 ? 0 : data); }, minutes: function (data) { return data.replace(":",""); }, seconds: function (data) { return Math.floor( (data.replace(":","").replace(",","."))*1 ); }, milliseconds: function (data) { return (data.replace(",",".")*1000); } }, postProcess: { minutes: true, seconds: true, milliseconds: true }, explict: { zone_hours: true, zone_minutes: true }, ignore: { zone: true, zone_sign: true, secmins: true } }); return time; }, addToHash: function (hash, keys, data) { keys = keys; data = data; var len = keys.length; for (var i = 0; i < len; i++) { hash[keys[i]] = data[i]; } return hash; }, combineRegex: function (r1, r2) { return new RegExp("(("+r1.source+")\\s("+r2.source+"))"); }, getDateNthString: function(add, last, inc){ if (add) { return Date.today().addDays(inc).toString("d"); } else if (last) { return Date.today().last()[inc]().toString("d"); } }, buildRegexData: function (array) { var arr = []; var len = array.length; for (var i=0; i < len; i++) { if (Object.prototype.toString.call(array[i]) === '[object Array]') { // oldIE compat version of Array.isArray arr.push(this.combineRegex(array[i][0], array[i][1])); } else { arr.push(array[i]); } } return arr; } }; $P.processTimeObject = function (obj) { var date, dayOffset; utils.setDefaults(obj); dayOffset = ($P.isLeapYear(obj.year)) ? dayOffsets.leap : dayOffsets.standard; if (!obj.month && (obj.week || obj.dayOfYear)) { utils.getDayOfYear(obj, dayOffset); } else { obj.dayOfYear = dayOffset[obj.month] + obj.day; } date = new Date(obj.year, obj.month, obj.day, obj.hours, obj.minutes, obj.seconds, obj.milliseconds); if (obj.zone) { utils.adjustForTimeZone(obj, date); // adjust (and calculate) for timezone } return date; }; $P.ISO = { regex : /^([\+-]?\d{4}(?!\d{2}\b))((-?)((0[1-9]|1[0-2])(\3([12]\d|0[1-9]|3[01]))?|W([0-4]\d|5[0-3])(-?[1-7])?|(00[1-9]|0[1-9]\d|[12]\d{2}|3([0-5]\d|6[1-6])))([T\s]((([01]\d|2[0-4])((:?)[0-5]\d)?|24\:?00)([\.,]\d+(?!:))?)?(\17[0-5]\d([\.,]\d+)?)?\s?([zZ]|([\+-])([01]\d|2[0-3]):?([0-5]\d)?)?)?)?$/, parse : function (s) { var time, data = s.match(this.regex); if (!data || !data.length) { return null; } time = utils.buildTimeObjectFromData(data); if (!time.year || (!time.year && (!time.month && !time.day) && (!time.week && !time.dayOfYear)) ) { return null; } return $P.processTimeObject(time); } }; $P.Numeric = { isNumeric: function (e){return!isNaN(parseFloat(e))&&isFinite(e);}, regex: /\b([0-1]?[0-9])([0-3]?[0-9])([0-2]?[0-9]?[0-9][0-9])\b/i, parse: function (s) { var data, i, time = {}, order = Date.CultureInfo.dateElementOrder.split(""); if (!(this.isNumeric(s)) || // if it's non-numeric OR (s[0] === "+" && s[0] === "-")) { // It's an arithmatic string (eg +/-1000) return null; } if (s.length < 5 && s.indexOf(".") < 0 && s.indexOf("/") < 0) { // assume it's just a year. time.year = s; return $P.processTimeObject(time); } data = s.match(this.regex); if (!data || !data.length) { return null; } for (i=0; i < order.length; i++) { switch(order[i]) { case "d": time.day = data[i+1]; break; case "m": time.month = (data[i+1]-1); break; case "y": time.year = data[i+1]; break; } } return $P.processTimeObject(time); } }; $P.Normalizer = { regexData: function () { var $R = Date.CultureInfo.regexPatterns; return utils.buildRegexData([ $R.tomorrow, $R.yesterday, [$R.past, $R.mon], [$R.past, $R.tue], [$R.past, $R.wed], [$R.past, $R.thu], [$R.past, $R.fri], [$R.past, $R.sat], [$R.past, $R.sun] ]); }, basicReplaceHash : function() { var $R = Date.CultureInfo.regexPatterns; return { "January": $R.jan.source, "February": $R.feb, "March": $R.mar, "April": $R.apr, "May": $R.may, "June": $R.jun, "July": $R.jul, "August": $R.aug, "September": $R.sep, "October": $R.oct, "November": $R.nov, "December": $R.dec, "": /\bat\b/gi, " ": /\s{2,}/, "am": $R.inTheMorning, "9am": $R.thisMorning, "pm": $R.inTheEvening, "7pm":$R.thisEvening }; }, keys : function(){ return [ utils.getDateNthString(true, false, 1), // tomorrow utils.getDateNthString(true, false, -1), // yesterday utils.getDateNthString(false, true, "monday"), //last mon utils.getDateNthString(false, true, "tuesday"), //last tues utils.getDateNthString(false, true, "wednesday"), //last wed utils.getDateNthString(false, true, "thursday"), //last thurs utils.getDateNthString(false, true, "friday"), //last fri utils.getDateNthString(false, true, "saturday"), //last sat utils.getDateNthString(false, true, "sunday") //last sun ]; }, buildRegexFunctions: function () { var $R = Date.CultureInfo.regexPatterns; var __ = Date.i18n.__; var tomorrowRE = new RegExp("(\\b\\d\\d?("+__("AM")+"|"+__("PM")+")? )("+$R.tomorrow.source.slice(1)+")", "i"); // adapted tomorrow regex for AM PM relative dates var todayRE = new RegExp($R.today.source + "(?!\\s*([+-]))\\b"); // today, but excludes the math operators (eg "today + 2h") this.replaceFuncs = [ [todayRE, function (full) { return (full.length > 1) ? Date.today().toString("d") : full; }], [tomorrowRE, function(full, m1) { var t = Date.today().addDays(1).toString("d"); return (t + " " + m1); }], [$R.amThisMorning, function(str, am){return am;}], [$R.pmThisEvening, function(str, pm){return pm;}] ]; }, buildReplaceData: function () { this.buildRegexFunctions(); this.replaceHash = utils.addToHash(this.basicReplaceHash(), this.keys(), this.regexData()); }, stringReplaceFuncs: function (s) { for (var i=0; i < this.replaceFuncs.length; i++) { s = s.replace(this.replaceFuncs[i][0], this.replaceFuncs[i][1]); } return s; }, parse: function (s) { s = this.stringReplaceFuncs(s); s = utils.multiReplace(s, this.replaceHash); try { var n = s.split(/([\s\-\.\,\/\x27]+)/); if (n.length === 3 && $P.Numeric.isNumeric(n[0]) && $P.Numeric.isNumeric(n[2]) && (n[2].length >= 4)) { // ok, so we're dealing with x/year. But that's not a full date. // This fixes wonky dateElementOrder parsing when set to dmy order. if (Date.CultureInfo.dateElementOrder[0] === "d") { s = "1/" + n[0] + "/" + n[2]; // set to 1st of month and normalize the seperator } } } catch (e) {} return s; } }; $P.Normalizer.buildReplaceData(); }()); (function () { var $P = Date.Parsing; var _ = $P.Operators = { // // Tokenizers // rtoken: function (r) { // regex token return function (s) { var mx = s.match(r); if (mx) { return ([ mx[0], s.substring(mx[0].length) ]); } else { throw new $P.Exception(s); } }; }, token: function () { // whitespace-eating token return function (s) { return _.rtoken(new RegExp("^\\s*" + s + "\\s*"))(s); }; }, stoken: function (s) { // string token return _.rtoken(new RegExp("^" + s)); }, // Atomic Operators until: function (p) { return function (s) { var qx = [], rx = null; while (s.length) { try { rx = p.call(this, s); } catch (e) { qx.push(rx[0]); s = rx[1]; continue; } break; } return [ qx, s ]; }; }, many: function (p) { return function (s) { var rx = [], r = null; while (s.length) { try { r = p.call(this, s); } catch (e) { return [ rx, s ]; } rx.push(r[0]); s = r[1]; } return [ rx, s ]; }; }, // generator operators -- see below optional: function (p) { return function (s) { var r = null; try { r = p.call(this, s); } catch (e) { return [ null, s ]; } return [ r[0], r[1] ]; }; }, not: function (p) { return function (s) { try { p.call(this, s); } catch (e) { return [null, s]; } throw new $P.Exception(s); }; }, ignore: function (p) { return p ? function (s) { var r = null; r = p.call(this, s); return [null, r[1]]; } : null; }, product: function () { var px = arguments[0], qx = Array.prototype.slice.call(arguments, 1), rx = []; for (var i = 0 ; i < px.length ; i++) { rx.push(_.each(px[i], qx)); } return rx; }, cache: function (rule) { var cache = {}, cache_length = 0, cache_keys = [], CACHE_MAX = Date.Config.CACHE_MAX || 100000, r = null; var cacheCheck = function () { if (cache_length === CACHE_MAX) { // kill several keys, don't want to have to do this all the time... for (var i=0; i < 10; i++) { var key = cache_keys.shift(); if (key) { delete cache[key]; cache_length--; } } } }; return function (s) { cacheCheck(); try { r = cache[s] = (cache[s] || rule.call(this, s)); } catch (e) { r = cache[s] = e; } cache_length++; cache_keys.push(s); if (r instanceof $P.Exception) { throw r; } else { return r; } }; }, // vector operators -- see below any: function () { var px = arguments; return function (s) { var r = null; for (var i = 0; i < px.length; i++) { if (px[i] == null) { continue; } try { r = (px[i].call(this, s)); } catch (e) { r = null; } if (r) { return r; } } throw new $P.Exception(s); }; }, each: function () { var px = arguments; return function (s) { var rx = [], r = null; for (var i = 0; i < px.length ; i++) { if (px[i] == null) { continue; } try { r = (px[i].call(this, s)); } catch (e) { throw new $P.Exception(s); } rx.push(r[0]); s = r[1]; } return [ rx, s]; }; }, all: function () { var px = arguments, _ = _; return _.each(_.optional(px)); }, // delimited operators sequence: function (px, d, c) { d = d || _.rtoken(/^\s*/); c = c || null; if (px.length === 1) { return px[0]; } return function (s) { var r = null, q = null; var rx = []; for (var i = 0; i < px.length ; i++) { try { r = px[i].call(this, s); } catch (e) { break; } rx.push(r[0]); try { q = d.call(this, r[1]); } catch (ex) { q = null; break; } s = q[1]; } if (!r) { throw new $P.Exception(s); } if (q) { throw new $P.Exception(q[1]); } if (c) { try { r = c.call(this, r[1]); } catch (ey) { throw new $P.Exception(r[1]); } } return [ rx, (r?r[1]:s) ]; }; }, // // Composite Operators // between: function (d1, p, d2) { d2 = d2 || d1; var _fn = _.each(_.ignore(d1), p, _.ignore(d2)); return function (s) { var rx = _fn.call(this, s); return [[rx[0][0], r[0][2]], rx[1]]; }; }, list: function (p, d, c) { d = d || _.rtoken(/^\s*/); c = c || null; return (p instanceof Array ? _.each(_.product(p.slice(0, -1), _.ignore(d)), p.slice(-1), _.ignore(c)) : _.each(_.many(_.each(p, _.ignore(d))), px, _.ignore(c))); }, set: function (px, d, c) { d = d || _.rtoken(/^\s*/); c = c || null; return function (s) { // r is the current match, best the current 'best' match // which means it parsed the most amount of input var r = null, p = null, q = null, rx = null, best = [[], s], last = false; // go through the rules in the given set for (var i = 0; i < px.length ; i++) { // last is a flag indicating whether this must be the last element // if there is only 1 element, then it MUST be the last one q = null; p = null; r = null; last = (px.length === 1); // first, we try simply to match the current pattern // if not, try the next pattern try { r = px[i].call(this, s); } catch (e) { continue; } // since we are matching against a set of elements, the first // thing to do is to add r[0] to matched elements rx = [[r[0]], r[1]]; // if we matched and there is still input to parse and // we don't already know this is the last element, // we're going to next check for the delimiter ... // if there's none, or if there's no input left to parse // than this must be the last element after all ... if (r[1].length > 0 && ! last) { try { q = d.call(this, r[1]); } catch (ex) { last = true; } } else { last = true; } // if we parsed the delimiter and now there's no more input, // that means we shouldn't have parsed the delimiter at all // so don't update r and mark this as the last element ... if (!last && q[1].length === 0) { last = true; } // so, if this isn't the last element, we're going to see if // we can get any more matches from the remaining (unmatched) // elements ... if (!last) { // build a list of the remaining rules we can match against, // i.e., all but the one we just matched against var qx = []; for (var j = 0; j < px.length ; j++) { if (i !== j) { qx.push(px[j]); } } // now invoke recursively set with the remaining input // note that we don't include the closing delimiter ... // we'll check for that ourselves at the end p = _.set(qx, d).call(this, q[1]); // if we got a non-empty set as a result ... // (otw rx already contains everything we want to match) if (p[0].length > 0) { // update current result, which is stored in rx ... // basically, pick up the remaining text from p[1] // and concat the result from p[0] so that we don't // get endless nesting ... rx[0] = rx[0].concat(p[0]); rx[1] = p[1]; } } // at this point, rx either contains the last matched element // or the entire matched set that starts with this element. // now we just check to see if this variation is better than // our best so far, in terms of how much of the input is parsed if (rx[1].length < best[1].length) { best = rx; } // if we've parsed all the input, then we're finished if (best[1].length === 0) { break; } } // so now we've either gone through all the patterns trying them // as the initial match; or we found one that parsed the entire // input string ... // if best has no matches, just return empty set ... if (best[0].length === 0) { return best; } // if a closing delimiter is provided, then we have to check it also if (c) { // we try this even if there is no remaining input because the pattern // may well be optional or match empty input ... try { q = c.call(this, best[1]); } catch (ey) { throw new $P.Exception(best[1]); } // it parsed ... be sure to update the best match remaining input best[1] = q[1]; } // if we're here, either there was no closing delimiter or we parsed it // so now we have the best match; just return it! return best; }; }, forward: function (gr, fname) { return function (s) { return gr[fname].call(this, s); }; }, // // Translation Operators // replace: function (rule, repl) { return function (s) { var r = rule.call(this, s); return [repl, r[1]]; }; }, process: function (rule, fn) { return function (s) { var r = rule.call(this, s); return [fn.call(this, r[0]), r[1]]; }; }, min: function (min, rule) { return function (s) { var rx = rule.call(this, s); if (rx[0].length < min) { throw new $P.Exception(s); } return rx; }; } }; // Generator Operators And Vector Operators // Generators are operators that have a signature of F(R) => R, // taking a given rule and returning another rule, such as // ignore, which parses a given rule and throws away the result. // Vector operators are those that have a signature of F(R1,R2,...) => R, // take a list of rules and returning a new rule, such as each. // Generator operators are converted (via the following _generator // function) into functions that can also take a list or array of rules // and return an array of new rules as though the function had been // called on each rule in turn (which is what actually happens). // This allows generators to be used with vector operators more easily. // Example: // each(ignore(foo, bar)) instead of each(ignore(foo), ignore(bar)) // This also turns generators into vector operators, which allows // constructs like: // not(cache(foo, bar)) var _generator = function (op) { function gen() { var args = null, rx = [], px, i; if (arguments.length > 1) { args = Array.prototype.slice.call(arguments); } else if (arguments[0] instanceof Array) { args = arguments[0]; } if (args) { px = args.shift(); if (px.length > 0) { args.unshift(px[i]); rx.push(op.apply(null, args)); args.shift(); return rx; } } else { return op.apply(null, arguments); } } return gen; }; var gx = "optional not ignore cache".split(/\s/); for (var i = 0 ; i < gx.length ; i++) { _[gx[i]] = _generator(_[gx[i]]); } var _vector = function (op) { return function () { if (arguments[0] instanceof Array) { return op.apply(null, arguments[0]); } else { return op.apply(null, arguments); } }; }; var vx = "each any all".split(/\s/); for (var j = 0 ; j < vx.length ; j++) { _[vx[j]] = _vector(_[vx[j]]); } }()); (function () { var $D = Date; var flattenAndCompact = function (ax) { var rx = []; for (var i = 0; i < ax.length; i++) { if (ax[i] instanceof Array) { rx = rx.concat(flattenAndCompact(ax[i])); } else { if (ax[i]) { rx.push(ax[i]); } } } return rx; }; var parseMeridian = function () { if (this.meridian && (this.hour || this.hour === 0)) { if (this.meridian === "a" && this.hour > 11 && Date.Config.strict24hr){ throw "Invalid hour and meridian combination"; } else if (this.meridian === "p" && this.hour < 12 && Date.Config.strict24hr){ throw "Invalid hour and meridian combination"; } else if (this.meridian === "p" && this.hour < 12) { this.hour = this.hour + 12; } else if (this.meridian === "a" && this.hour === 12) { this.hour = 0; } } }; var setDefaults = function () { var now = new Date(); if ((this.hour || this.minute) && (!this.month && !this.year && !this.day)) { this.day = now.getDate(); } if (!this.year) { this.year = now.getFullYear(); } if (!this.month && this.month !== 0) { this.month = now.getMonth(); } if (!this.day) { this.day = 1; } if (!this.hour) { this.hour = 0; } if (!this.minute) { this.minute = 0; } if (!this.second) { this.second = 0; } if (!this.millisecond) { this.millisecond = 0; } }; var finishUtils = { getToday: function () { if (this.now || "hour minute second".indexOf(this.unit) !== -1) { return new Date(); } else { return $D.today(); } }, setDaysFromWeekday: function (today, orient){ var gap; orient = orient || 1; this.unit = "day"; gap = ($D.getDayNumberFromName(this.weekday) - today.getDay()); this.days = gap ? ((gap + (orient * 7)) % 7) : (orient * 7); return this; }, setMonthsFromMonth: function (today, orient) { var gap; orient = orient || 1; this.unit = "month"; gap = (this.month - today.getMonth()); this.months = gap ? ((gap + (orient * 12)) % 12) : (orient * 12); this.month = null; return this; }, setDMYFromWeekday: function () { var d = Date[this.weekday](); this.day = d.getDate(); if (!this.month) { this.month = d.getMonth(); } this.year = d.getFullYear(); return this; }, setUnitValue: function (orient) { if (!this.value && this.operator && this.operator !== null && this[this.unit + "s"] && this[this.unit + "s"] !== null) { this[this.unit + "s"] = this[this.unit + "s"] + ((this.operator === "add") ? 1 : -1) + (this.value||0) * orient; } else if (this[this.unit + "s"] == null || this.operator != null) { if (!this.value) { this.value = 1; } this[this.unit + "s"] = this.value * orient; } }, generateDateFromWeeks: function () { var weekday = (this.weekday !== undefined) ? this.weekday : "today"; var d = Date[weekday]().addWeeks(this.weeks); if (this.now) { d.setTimeToNow(); } return d; } }; $D.Translator = { hour: function (s) { return function () { this.hour = Number(s); }; }, minute: function (s) { return function () { this.minute = Number(s); }; }, second: function (s) { return function () { this.second = Number(s); }; }, /* for ss.s format */ secondAndMillisecond: function (s) { return function () { var mx = s.match(/^([0-5][0-9])\.([0-9]{1,3})/); this.second = Number(mx[1]); this.millisecond = Number(mx[2]); }; }, meridian: function (s) { return function () { this.meridian = s.slice(0, 1).toLowerCase(); }; }, timezone: function (s) { return function () { var n = s.replace(/[^\d\+\-]/g, ""); if (n.length) { this.timezoneOffset = Number(n); } else { this.timezone = s.toLowerCase(); } }; }, day: function (x) { var s = x[0]; return function () { this.day = Number(s.match(/\d+/)[0]); if (this.day < 1) { throw "invalid day"; } }; }, month: function (s) { return function () { this.month = (s.length === 3) ? "jan feb mar apr may jun jul aug sep oct nov dec".indexOf(s)/4 : Number(s) - 1; if (this.month < 0) { throw "invalid month"; } }; }, year: function (s) { return function () { var n = Number(s); this.year = ((s.length > 2) ? n : (n + (((n + 2000) < Date.CultureInfo.twoDigitYearMax) ? 2000 : 1900))); }; }, rday: function (s) { return function () { switch (s) { case "yesterday": this.days = -1; break; case "tomorrow": this.days = 1; break; case "today": this.days = 0; break; case "now": this.days = 0; this.now = true; break; } }; }, finishExact: function (x) { var d; x = (x instanceof Array) ? x : [x]; for (var i = 0 ; i < x.length ; i++) { if (x[i]) { x[i].call(this); } } setDefaults.call(this); parseMeridian.call(this); if (this.day > $D.getDaysInMonth(this.year, this.month)) { throw new RangeError(this.day + " is not a valid value for days."); } d = new Date(this.year, this.month, this.day, this.hour, this.minute, this.second, this.millisecond); if (this.year < 100) { d.setFullYear(this.year); // means years less that 100 are process correctly. JS will parse it otherwise as 1900-1999. } if (this.timezone) { d.set({ timezone: this.timezone }); } else if (this.timezoneOffset) { d.set({ timezoneOffset: this.timezoneOffset }); } return d; }, finish: function (x) { var today, expression, orient, temp; x = (x instanceof Array) ? flattenAndCompact(x) : [ x ]; if (x.length === 0) { return null; } for (var i = 0 ; i < x.length ; i++) { if (typeof x[i] === "function") { x[i].call(this); } } if (this.now && !this.unit && !this.operator) { return new Date(); } else { today = finishUtils.getToday.call(this); } expression = !!(this.days && this.days !== null || this.orient || this.operator); orient = ((this.orient === "past" || this.operator === "subtract") ? -1 : 1); if (this.month && this.unit === "week") { this.value = this.month + 1; delete this.month; delete this.day; } if ((this.month || this.month === 0) && "year day hour minute second".indexOf(this.unit) !== -1) { if (!this.value) { this.value = this.month + 1; } this.month = null; expression = true; } if (!expression && this.weekday && !this.day && !this.days) { finishUtils.setDMYFromWeekday.call(this); } if (expression && this.weekday && this.unit !== "month" && this.unit !== "week") { finishUtils.setDaysFromWeekday.call(this, today, orient); } if (this.weekday && this.unit !== "week" && !this.day && !this.days) { temp = Date[this.weekday](); this.day = temp.getDate(); if (temp.getMonth() !== today.getMonth()) { this.month = temp.getMonth(); } } if (this.month && this.unit === "day" && this.operator) { if (!this.value) { this.value = (this.month + 1); } this.month = null; } if (this.value != null && this.month != null && this.year != null) { this.day = this.value * 1; } if (this.month && !this.day && this.value) { today.set({ day: this.value * 1 }); if (!expression) { this.day = this.value * 1; } } if (!this.month && this.value && this.unit === "month" && !this.now) { this.month = this.value; expression = true; } if (expression && (this.month || this.month === 0) && this.unit !== "year") { finishUtils.setMonthsFromMonth.call(this, today, orient); } if (!this.unit) { this.unit = "day"; } finishUtils.setUnitValue.call(this, orient); parseMeridian.call(this); if ((this.month || this.month === 0) && !this.day) { this.day = 1; } if (!this.orient && !this.operator && this.unit === "week" && this.value && !this.day && !this.month) { return Date.today().setWeek(this.value); } if (this.unit === "week" && this.weeks && !this.day && !this.month) { return finishUtils.generateDateFromWeeks.call(this); } if (expression && this.timezone && this.day && this.days) { this.day = this.days; } if (expression){ today.add(this); } else { today.set(this); } if (this.timezone) { this.timezone = this.timezone.toUpperCase(); var offset = $D.getTimezoneOffset(this.timezone); var timezone; if (today.hasDaylightSavingTime()) { // lets check that we're being sane with timezone setting timezone = $D.getTimezoneAbbreviation(offset, today.isDaylightSavingTime()); if (timezone !== this.timezone) { // bugger, we're in a place where things like EST vs EDT matters. if (today.isDaylightSavingTime()) { today.addHours(-1); } else { today.addHours(1); } } } today.setTimezoneOffset(offset); } return today; } }; }()); (function () { var $D = Date; $D.Grammar = {}; var _ = $D.Parsing.Operators, g = $D.Grammar, t = $D.Translator, _fn; // Allow rolling up into general purpose rules _fn = function () { return _.each(_.any.apply(null, arguments), _.not(g.ctoken2("timeContext"))); }; g.datePartDelimiter = _.rtoken(/^([\s\-\.\,\/\x27]+)/); g.timePartDelimiter = _.stoken(":"); g.whiteSpace = _.rtoken(/^\s*/); g.generalDelimiter = _.rtoken(/^(([\s\,]|at|@|on)+)/); var _C = {}; g.ctoken = function (keys) { var fn = _C[keys]; if (! fn) { var c = Date.CultureInfo.regexPatterns; var kx = keys.split(/\s+/), px = []; for (var i = 0; i < kx.length ; i++) { px.push(_.replace(_.rtoken(c[kx[i]]), kx[i])); } fn = _C[keys] = _.any.apply(null, px); } return fn; }; g.ctoken2 = function (key) { return _.rtoken(Date.CultureInfo.regexPatterns[key]); }; var cacheProcessRtoken = function (key, token, type, eachToken) { if (eachToken) { g[key] = _.cache(_.process(_.each(_.rtoken(token),_.optional(g.ctoken2(eachToken))), type)); } else { g[key] = _.cache(_.process(_.rtoken(token), type)); } }; var cacheProcessCtoken = function (token, type) { return _.cache(_.process(g.ctoken2(token), type)); }; var _F = {}; //function cache var _get = function (f) { _F[f] = (_F[f] || g.format(f)[0]); return _F[f]; }; g.allformats = function (fx) { var rx = []; if (fx instanceof Array) { for (var i = 0; i < fx.length; i++) { rx.push(_get(fx[i])); } } else { rx.push(_get(fx)); } return rx; }; g.formats = function (fx) { if (fx instanceof Array) { var rx = []; for (var i = 0 ; i < fx.length ; i++) { rx.push(_get(fx[i])); } return _.any.apply(null, rx); } else { return _get(fx); } }; var grammarFormats = { timeFormats: function(){ var i, RTokenKeys = [ "h", "hh", "H", "HH", "m", "mm", "s", "ss", "ss.s", "z", "zz" ], RToken = [ /^(0[0-9]|1[0-2]|[1-9])/, /^(0[0-9]|1[0-2])/, /^([0-1][0-9]|2[0-3]|[0-9])/, /^([0-1][0-9]|2[0-3])/, /^([0-5][0-9]|[0-9])/, /^[0-5][0-9]/, /^([0-5][0-9]|[0-9])/, /^[0-5][0-9]/, /^[0-5][0-9]\.[0-9]{1,3}/, /^((\+|\-)\s*\d\d\d\d)|((\+|\-)\d\d\:?\d\d)/, /^((\+|\-)\s*\d\d\d\d)|((\+|\-)\d\d\:?\d\d)/ ], tokens = [ t.hour, t.hour, t.hour, t.hour, t.minute, t.minute, t.second, t.second, t.secondAndMillisecond, t.timezone, t.timezone ]; for (i=0; i < RTokenKeys.length; i++) { cacheProcessRtoken(RTokenKeys[i], RToken[i], tokens[i]); } g.hms = _.cache(_.sequence([g.H, g.m, g.s], g.timePartDelimiter)); g.t = cacheProcessCtoken("shortMeridian", t.meridian); g.tt = cacheProcessCtoken("longMeridian", t.meridian); g.zzz = cacheProcessCtoken("timezone", t.timezone); g.timeSuffix = _.each(_.ignore(g.whiteSpace), _.set([ g.tt, g.zzz ])); g.time = _.each(_.optional(_.ignore(_.stoken("T"))), g.hms, g.timeSuffix); }, dateFormats: function () { // pre-loaded rules for different date part order preferences var _setfn = function () { return _.set(arguments, g.datePartDelimiter); }; var i, RTokenKeys = [ "d", "dd", "M", "MM", "y", "yy", "yyy", "yyyy" ], RToken = [ /^([0-2]\d|3[0-1]|\d)/, /^([0-2]\d|3[0-1])/, /^(1[0-2]|0\d|\d)/, /^(1[0-2]|0\d)/, /^(\d+)/, /^(\d\d)/, /^(\d\d?\d?\d?)/, /^(\d\d\d\d)/ ], tokens = [ t.day, t.day, t.month, t.month, t.year, t.year, t.year, t.year ], eachToken = [ "ordinalSuffix", "ordinalSuffix" ]; for (i=0; i < RTokenKeys.length; i++) { cacheProcessRtoken(RTokenKeys[i], RToken[i], tokens[i], eachToken[i]); } g.MMM = g.MMMM = _.cache(_.process(g.ctoken("jan feb mar apr may jun jul aug sep oct nov dec"), t.month)); g.ddd = g.dddd = _.cache(_.process(g.ctoken("sun mon tue wed thu fri sat"), function (s) { return function () { this.weekday = s; }; } )); g.day = _fn(g.d, g.dd); g.month = _fn(g.M, g.MMM); g.year = _fn(g.yyyy, g.yy); g.mdy = _setfn(g.ddd, g.month, g.day, g.year); g.ymd = _setfn(g.ddd, g.year, g.month, g.day); g.dmy = _setfn(g.ddd, g.day, g.month, g.year); g.date = function (s) { return ((g[Date.CultureInfo.dateElementOrder] || g.mdy).call(this, s)); }; }, relative: function () { // relative date / time expressions g.orientation = _.process(g.ctoken("past future"), function (s) { return function () { this.orient = s; }; } ); g.operator = _.process(g.ctoken("add subtract"), function (s) { return function () { this.operator = s; }; } ); g.rday = _.process(g.ctoken("yesterday tomorrow today now"), t.rday); g.unit = _.process(g.ctoken("second minute hour day week month year"), function (s) { return function () { this.unit = s; }; } ); } }; g.buildGrammarFormats = function () { // these need to be rebuilt every time the language changes. _C = {}; grammarFormats.timeFormats(); grammarFormats.dateFormats(); grammarFormats.relative(); g.value = _.process(_.rtoken(/^([-+]?\d+)?(st|nd|rd|th)?/), function (s) { return function () { this.value = s.replace(/\D/g, ""); }; } ); g.expression = _.set([g.rday, g.operator, g.value, g.unit, g.orientation, g.ddd, g.MMM ]); g.format = _.process(_.many( _.any( // translate format specifiers into grammar rules _.process( _.rtoken(/^(dd?d?d?(?!e)|MM?M?M?|yy?y?y?|hh?|HH?|mm?|ss?|tt?|zz?z?)/), function (fmt) { if (g[fmt]) { return g[fmt]; } else { throw $D.Parsing.Exception(fmt); } } ), // translate separator tokens into token rules _.process(_.rtoken(/^[^dMyhHmstz]+/), // all legal separators function (s) { return _.ignore(_.stoken(s)); } ) ) ), // construct the parser ... function (rules) { return _.process(_.each.apply(null, rules), t.finishExact); } ); // starting rule for general purpose grammar g._start = _.process(_.set([ g.date, g.time, g.expression ], g.generalDelimiter, g.whiteSpace), t.finish); }; g.buildGrammarFormats(); // parsing date format specifiers - ex: "h:m:s tt" // this little guy will generate a custom parser based // on the format string, ex: g.format("h:m:s tt") // check for these formats first g._formats = g.formats([ "\"yyyy-MM-ddTHH:mm:ssZ\"", "yyyy-MM-ddTHH:mm:ss.sz", "yyyy-MM-ddTHH:mm:ssZ", "yyyy-MM-ddTHH:mm:ssz", "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-ddTHH:mmZ", "yyyy-MM-ddTHH:mmz", "yyyy-MM-ddTHH:mm", "ddd, MMM dd, yyyy H:mm:ss tt", "ddd MMM d yyyy HH:mm:ss zzz", "MMddyyyy", "ddMMyyyy", "Mddyyyy", "ddMyyyy", "Mdyyyy", "dMyyyy", "yyyy", "Mdyy", "dMyy", "d" ]); // real starting rule: tries selected formats first, // then general purpose rule g.start = function (s) { try { var r = g._formats.call({}, s); if (r[1].length === 0) { return r; } } catch (e) {} return g._start.call({}, s); }; }()); (function () { var $D = Date; /** * @desc Converts the specified string value into its JavaScript Date equivalent using CultureInfo specific format information. * * Example

	///////////
	// Dates //
	///////////

	// 15-Oct-2004
	var d1 = Date.parse("10/15/2004");

	// 15-Oct-2004
	var d1 = Date.parse("15-Oct-2004");

	// 15-Oct-2004
	var d1 = Date.parse("2004.10.15");

	//Fri Oct 15, 2004
	var d1 = Date.parse("Fri Oct 15, 2004");

	///////////
	// Times //
	///////////

	// Today at 10 PM.
	var d1 = Date.parse("10 PM");

	// Today at 10:30 PM.
	var d1 = Date.parse("10:30 P.M.");

	// Today at 6 AM.
	var d1 = Date.parse("06am");

	/////////////////////
	// Dates and Times //
	/////////////////////

	// 8-July-2004 @ 10:30 PM
	var d1 = Date.parse("July 8th, 2004, 10:30 PM");

	// 1-July-2004 @ 10:30 PM
	var d1 = Date.parse("2004-07-01T22:30:00");

	////////////////////
	// Relative Dates //
	////////////////////

	// Returns today's date. The string "today" is culture specific.
	var d1 = Date.parse("today");

	// Returns yesterday's date. The string "yesterday" is culture specific.
	var d1 = Date.parse("yesterday");

	// Returns the date of the next thursday.
	var d1 = Date.parse("Next thursday");

	// Returns the date of the most previous monday.
	var d1 = Date.parse("last monday");

	// Returns today's day + one year.
	var d1 = Date.parse("next year");

	///////////////
	// Date Math //
	///////////////

	// Today + 2 days
	var d1 = Date.parse("t+2");

	// Today + 2 days
	var d1 = Date.parse("today + 2 days");

	// Today + 3 months
	var d1 = Date.parse("t+3m");

	// Today - 1 year
	var d1 = Date.parse("today - 1 year");

	// Today - 1 year
	var d1 = Date.parse("t-1y"); 


	/////////////////////////////
	// Partial Dates and Times //
	/////////////////////////////

	// July 15th of this year.
	var d1 = Date.parse("July 15");

	// 15th day of current day and year.
	var d1 = Date.parse("15");

	// July 1st of current year at 10pm.
	var d1 = Date.parse("7/1 10pm");
	
* * @param {String} The string value to convert into a Date object [Required] * @return {Date} A Date object or null if the string cannot be converted into a Date. */ var parseUtils = { removeOrds: function (s) { ords = s.match(/\b(\d+)(?:st|nd|rd|th)\b/); // find ordinal matches s = ((ords && ords.length === 2) ? s.replace(ords[0], ords[1]) : s); return s; }, grammarParser: function (s) { var r = null; try { r = $D.Grammar.start.call({}, s.replace(/^\s*(\S*(\s+\S+)*)\s*$/, "$1")); } catch (e) { return null; } return ((r[1].length === 0) ? r[0] : null); }, nativeFallback: function(s) { var t; try { // ok we haven't parsed it, last ditch attempt with the built-in parser. t = Date._parse(s); return (t || t === 0) ? new Date(t) : null; } catch (e) { return null; } } }; function parse (s) { var d; if (!s) { return null; } if (s instanceof Date) { return s.clone(); } if (s.length >= 4 && s.charAt(0) !== "0" && s.charAt(0) !== "+"&& s.charAt(0) !== "-") { // ie: 2004 will pass, 0800 won't. // Start with specific formats d = $D.Parsing.ISO.parse(s) || $D.Parsing.Numeric.parse(s); } if (d instanceof Date && !isNaN(d.getTime())) { return d; } else { // find ordinal dates (1st, 3rd, 8th, etc and remove them as they cause parsing issues) s = $D.Parsing.Normalizer.parse(parseUtils.removeOrds(s)); d = parseUtils.grammarParser(s); if (d !== null) { return d; } else { return parseUtils.nativeFallback(s); } } } if (!$D._parse) { $D._parse = $D.parse; } $D.parse = parse; Date.getParseFunction = function (fx) { var fns = Date.Grammar.allformats(fx); return function (s) { var r = null; for (var i = 0; i < fns.length; i++) { try { r = fns[i].call({}, s); } catch (e) { continue; } if (r[1].length === 0) { return r[0]; } } return null; }; }; /** * Converts the specified string value into its JavaScript Date equivalent using the specified format {String} or formats {Array} and the CultureInfo specific format information. * The format of the string value must match one of the supplied formats exactly. * * Example

	// 15-Oct-2004
	var d1 = Date.parseExact("10/15/2004", "M/d/yyyy");

	// 15-Oct-2004
	var d1 = Date.parse("15-Oct-2004", "M-ddd-yyyy");

	// 15-Oct-2004
	var d1 = Date.parse("2004.10.15", "yyyy.MM.dd");

	// Multiple formats
	var d1 = Date.parseExact("10/15/2004", ["M/d/yyyy", "MMMM d, yyyy"]);
	
* * @param {String} The string value to convert into a Date object [Required]. * @param {Object} The expected format {String} or an array of expected formats {Array} of the date string [Required]. * @return {Date} A Date object or null if the string cannot be converted into a Date. */ $D.parseExact = function (s, fx) { return $D.getParseFunction(fx)(s); }; }()); (function () { var $D = Date, $P = $D.prototype, // $C = $D.CultureInfo, // not used atm p = function (s, l) { if (!l) { l = 2; } return ("000" + s).slice(l * -1); }; /** * Converts a PHP format string to Java/.NET format string. * A PHP format string can be used with ._format or .format. * A Java/.NET format string can be used with .toString(). * The .parseExact function will only accept a Java/.NET format string * * Example * var f1 = "%m/%d/%y" * var f2 = Date.normalizeFormat(f1); // "MM/dd/yy" * * new Date().format(f1); // "04/13/08" * new Date()._format(f1); // "04/13/08" * new Date().toString(f2); // "04/13/08" * * var date = Date.parseExact("04/13/08", f2); // Sun Apr 13 2008 * * @param {String} A PHP format string consisting of one or more format spcifiers. * @return {String} The PHP format converted to a Java/.NET format string. */ var normalizerSubstitutions = { "d" : "dd", "%d": "dd", "D" : "ddd", "%a": "ddd", "j" : "dddd", "l" : "dddd", "%A": "dddd", "S" : "S", "F" : "MMMM", "%B": "MMMM", "m" : "MM", "%m": "MM", "M" : "MMM", "%b": "MMM", "%h": "MMM", "n" : "M", "Y" : "yyyy", "%Y": "yyyy", "y" : "yy", "%y": "yy", "g" : "h", "%I": "h", "G" : "H", "h" : "hh", "H" : "HH", "%H": "HH", "i" : "mm", "%M": "mm", "s" : "ss", "%S": "ss", "%r": "hh:mm tt", "%R": "H:mm", "%T": "H:mm:ss", "%X": "t", "%x": "d", "%e": "d", "%D": "MM/dd/yy", "%n": "\\n", "%t": "\\t", "e" : "z", "T" : "z", "%z": "z", "%Z": "z", "Z" : "ZZ", "N" : "u", "w" : "u", "%w": "u", "W" : "W", "%V": "W" }; var normalizer = { substitutes: function (m) { return normalizerSubstitutions[m]; }, interpreted: function (m, x) { var y; switch (m) { case "%u": return x.getDay() + 1; case "z": return x.getOrdinalNumber(); case "%j": return p(x.getOrdinalNumber(), 3); case "%U": var d1 = x.clone().set({month: 0, day: 1}).addDays(-1).moveToDayOfWeek(0), d2 = x.clone().addDays(1).moveToDayOfWeek(0, -1); return (d2 < d1) ? "00" : p((d2.getOrdinalNumber() - d1.getOrdinalNumber()) / 7 + 1); case "%W": return p(x.getWeek()); case "t": return $D.getDaysInMonth(x.getFullYear(), x.getMonth()); case "o": case "%G": return x.setWeek(x.getISOWeek()).toString("yyyy"); case "%g": return x._format("%G").slice(-2); case "a": case "%p": return t("tt").toLowerCase(); case "A": return t("tt").toUpperCase(); case "u": return p(x.getMilliseconds(), 3); case "I": return (x.isDaylightSavingTime()) ? 1 : 0; case "O": return x.getUTCOffset(); case "P": y = x.getUTCOffset(); return y.substring(0, y.length - 2) + ":" + y.substring(y.length - 2); case "B": var now = new Date(); return Math.floor(((now.getHours() * 3600) + (now.getMinutes() * 60) + now.getSeconds() + (now.getTimezoneOffset() + 60) * 60) / 86.4); case "c": return x.toISOString().replace(/\"/g, ""); case "U": return $D.strtotime("now"); case "%c": return t("d") + " " + t("t"); case "%C": return Math.floor(x.getFullYear() / 100 + 1); } }, shouldOverrideDefaults: function (m) { switch (m) { case "%e": return true; default: return false; } }, parse: function (m, context) { var formatString, c = context || new Date(); formatString = normalizer.substitutes(m); if (formatString) { return formatString; } formatString = normalizer.interpreted(m, c); if (formatString) { return formatString; } else { return m; } } }; $D.normalizeFormat = function (format, context) { return format.replace(/(%|\\)?.|%%/g, function(t){ return normalizer.parse(t, context); }); }; /** * Format a local Unix timestamp according to locale settings * * Example: * Date.strftime("%m/%d/%y", new Date()); // "04/13/08" * Date.strftime("c", "2008-04-13T17:52:03Z"); // "04/13/08" * * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @param {Number|String} The number representing the number of seconds that have elapsed since January 1, 1970 (local time). * @return {String} A string representation of the current Date object. */ $D.strftime = function (format, time) { var d = Date.parse(time); return d._format(format); }; /** * Parse any textual datetime description into a Unix timestamp. * A Unix timestamp is the number of seconds that have elapsed since January 1, 1970 (midnight UTC/GMT). * * Example: * Date.strtotime("04/13/08"); // 1208044800 * Date.strtotime("1970-01-01T00:00:00Z"); // 0 * * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @param {Object} A string or date object. * @return {String} A string representation of the current Date object. */ $D.strtotime = function (time) { var d = $D.parse(time); return Math.round($D.UTC(d.getUTCFullYear(), d.getUTCMonth(), d.getUTCDate(), d.getUTCHours(), d.getUTCMinutes(), d.getUTCSeconds(), d.getUTCMilliseconds()) / 1000); }; /** * Converts the value of the current Date object to its equivalent string representation using a PHP/Unix style of date format specifiers. * Format Specifiers * Format Description Example * ------ --------------------------------------------------------------------------- ----------------------- * %a abbreviated weekday name according to the current localed "Mon" through "Sun" * %A full weekday name according to the current localed "Sunday" through "Saturday" * %b abbreviated month name according to the current localed "Jan" through "Dec" * %B full month name according to the current locale "January" through "December" * %c preferred date and time representation for the current locale "4/13/2008 12:33 PM" * %C century number (the year divided by 100 and truncated to an integer) "00" to "99" * %d day of the month as a decimal number "01" to "31" * %D same as %m/%d/%y "04/13/08" * %e day of the month as a decimal number, a single digit is preceded by a space "1" to "31" * %g like %G, but without the century "08" * %G The 4-digit year corresponding to the ISO week number (see %V). "2008" * This has the same format and value as %Y, except that if the ISO week number * belongs to the previous or next year, that year is used instead. * %h same as %b "Jan" through "Dec" * %H hour as a decimal number using a 24-hour clock. "00" to "23" * %I hour as a decimal number using a 12-hour clock. "01" to "12" * %j day of the year as a decimal number. "001" to "366" * %m month as a decimal number. "01" to "12" * %M minute as a decimal number. "00" to "59" * %n newline character "\n" * %p either "am" or "pm" according to the given time value, or the "am" or "pm" * corresponding strings for the current locale. * %r time in a.m. and p.m. notation "8:44 PM" * %R time in 24 hour notation "20:44" * %S second as a decimal number "00" to "59" * %t tab character "\t" * %T current time, equal to %H:%M:%S "12:49:11" * %u weekday as a decimal number ["1", "7"], with "1" representing Monday "1" to "7" * %U week number of the current year as a decimal number, starting with the "0" to ("52" or "53") * first Sunday as the first day of the first week * %V The ISO 8601:1988 week number of the current year as a decimal number, "00" to ("52" or "53") * range 01 to 53, where week 1 is the first week that has at least 4 days * in the current year, and with Monday as the first day of the week. * (Use %G or %g for the year component that corresponds to the week number * for the specified timestamp.) * %W week number of the current year as a decimal number, starting with the "00" to ("52" or "53") * first Monday as the first day of the first week * %w day of the week as a decimal, Sunday being "0" "0" to "6" * %x preferred date representation for the current locale without the time "4/13/2008" * %X preferred time representation for the current locale without the date "12:53:05" * %y year as a decimal number without a century "00" "99" * %Y year as a decimal number including the century "2008" * %Z time zone or name or abbreviation "UTC", "EST", "PST" * %z same as %Z * %% a literal "%" characters "%" * d Day of the month, 2 digits with leading zeros "01" to "31" * D A textual representation of a day, three letters "Mon" through "Sun" * j Day of the month without leading zeros "1" to "31" * l A full textual representation of the day of the week (lowercase "L") "Sunday" through "Saturday" * N ISO-8601 numeric representation of the day of the week (added in PHP 5.1.0) "1" (for Monday) through "7" (for Sunday) * S English ordinal suffix for the day of the month, 2 characters "st", "nd", "rd" or "th". Works well with j * w Numeric representation of the day of the week "0" (for Sunday) through "6" (for Saturday) * z The day of the year (starting from "0") "0" through "365" * W ISO-8601 week number of year, weeks starting on Monday "00" to ("52" or "53") * F A full textual representation of a month, such as January or March "January" through "December" * m Numeric representation of a month, with leading zeros "01" through "12" * M A short textual representation of a month, three letters "Jan" through "Dec" * n Numeric representation of a month, without leading zeros "1" through "12" * t Number of days in the given month "28" through "31" * L Whether it's a leap year "1" if it is a leap year, "0" otherwise * o ISO-8601 year number. This has the same value as Y, except that if the "2008" * ISO week number (W) belongs to the previous or next year, that year * is used instead. * Y A full numeric representation of a year, 4 digits "2008" * y A two digit representation of a year "08" * a Lowercase Ante meridiem and Post meridiem "am" or "pm" * A Uppercase Ante meridiem and Post meridiem "AM" or "PM" * B Swatch Internet time "000" through "999" * g 12-hour format of an hour without leading zeros "1" through "12" * G 24-hour format of an hour without leading zeros "0" through "23" * h 12-hour format of an hour with leading zeros "01" through "12" * H 24-hour format of an hour with leading zeros "00" through "23" * i Minutes with leading zeros "00" to "59" * s Seconds, with leading zeros "00" through "59" * u Milliseconds "54321" * e Timezone identifier "UTC", "EST", "PST" * I Whether or not the date is in daylight saving time (uppercase i) "1" if Daylight Saving Time, "0" otherwise * O Difference to Greenwich time (GMT) in hours "+0200", "-0600" * P Difference to Greenwich time (GMT) with colon between hours and minutes "+02:00", "-06:00" * T Timezone abbreviation "UTC", "EST", "PST" * Z Timezone offset in seconds. The offset for timezones west of UTC is "-43200" through "50400" * always negative, and for those east of UTC is always positive. * c ISO 8601 date "2004-02-12T15:19:21+00:00" * r RFC 2822 formatted date "Thu, 21 Dec 2000 16:01:07 +0200" * U Seconds since the Unix Epoch (January 1 1970 00:00:00 GMT) "0" * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @return {String} A string representation of the current Date object. */ var formatReplace = function (context) { return function (m) { var formatString, override = false; if (m.charAt(0) === "\\" || m.substring(0, 2) === "%%") { return m.replace("\\", "").replace("%%", "%"); } override = normalizer.shouldOverrideDefaults(m); formatString = $D.normalizeFormat(m, context); if (formatString) { return context.toString(formatString, override); } }; }; $P._format = function (format) { var formatter = formatReplace(this); if (!format) { return this._toString(); } else { return format.replace(/(%|\\)?.|%%/g, formatter); } }; if (!$P.format) { $P.format = $P._format; } }()); (function () { "use strict"; var gFn = function (attr) { return function () { return this[attr]; }; }; var sFn = function (attr) { return function (val) { this[attr] = val; return this; }; }; var attrs = ["years", "months", "days", "hours", "minutes", "seconds", "milliseconds"]; var addSetFuncs = function (context, attrs) { for (var i = 0; i < attrs.length ; i++) { var $a = attrs[i], $b = $a.slice(0, 1).toUpperCase() + $a.slice(1); context.prototype[$a] = 0; context.prototype["get" + $b] = gFn($a); context.prototype["set" + $b] = sFn($a); } }; /** * new TimeSpan(milliseconds); * new TimeSpan(days, hours, minutes, seconds); * new TimeSpan(days, hours, minutes, seconds, milliseconds); */ var TimeSpan = function (days, hours, minutes, seconds, milliseconds) { if (arguments.length === 1 && typeof days === "number") { var orient = (days < 0) ? -1 : +1; var millsLeft = Math.abs(days); this.setDays(Math.floor(millsLeft / 86400000) * orient); millsLeft = millsLeft % 86400000; this.setHours(Math.floor(millsLeft / 3600000) * orient); millsLeft = millsLeft % 3600000; this.setMinutes(Math.floor(millsLeft / 60000) * orient); millsLeft = millsLeft % 60000; this.setSeconds(Math.floor(millsLeft / 1000) * orient); millsLeft = millsLeft % 1000; this.setMilliseconds(millsLeft * orient); } else { this.set(days, hours, minutes, seconds, milliseconds); } this.getTotalMilliseconds = function () { return (this.getDays() * 86400000) + (this.getHours() * 3600000) + (this.getMinutes() * 60000) + (this.getSeconds() * 1000); }; this.compareTo = function (time) { var t1 = new Date(1970, 1, 1, this.getHours(), this.getMinutes(), this.getSeconds()), t2; if (time === null) { t2 = new Date(1970, 1, 1, 0, 0, 0); } else { t2 = new Date(1970, 1, 1, time.getHours(), time.getMinutes(), time.getSeconds()); } return (t1 < t2) ? -1 : (t1 > t2) ? 1 : 0; }; this.equals = function (time) { return (this.compareTo(time) === 0); }; this.add = function (time) { return (time === null) ? this : this.addSeconds(time.getTotalMilliseconds() / 1000); }; this.subtract = function (time) { return (time === null) ? this : this.addSeconds(-time.getTotalMilliseconds() / 1000); }; this.addDays = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 86400000)); }; this.addHours = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 3600000)); }; this.addMinutes = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 60000)); }; this.addSeconds = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 1000)); }; this.addMilliseconds = function (n) { return new TimeSpan(this.getTotalMilliseconds() + n); }; this.get12HourHour = function () { return (this.getHours() > 12) ? this.getHours() - 12 : (this.getHours() === 0) ? 12 : this.getHours(); }; this.getDesignator = function () { return (this.getHours() < 12) ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator; }; this.toString = function (format) { this._toString = function () { if (this.getDays() !== null && this.getDays() > 0) { return this.getDays() + "." + this.getHours() + ":" + this.p(this.getMinutes()) + ":" + this.p(this.getSeconds()); } else { return this.getHours() + ":" + this.p(this.getMinutes()) + ":" + this.p(this.getSeconds()); } }; this.p = function (s) { return (s.toString().length < 2) ? "0" + s : s; }; var me = this; return format ? format.replace(/dd?|HH?|hh?|mm?|ss?|tt?/g, function (format) { switch (format) { case "d": return me.getDays(); case "dd": return me.p(me.getDays()); case "H": return me.getHours(); case "HH": return me.p(me.getHours()); case "h": return me.get12HourHour(); case "hh": return me.p(me.get12HourHour()); case "m": return me.getMinutes(); case "mm": return me.p(me.getMinutes()); case "s": return me.getSeconds(); case "ss": return me.p(me.getSeconds()); case "t": return ((me.getHours() < 12) ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator).substring(0, 1); case "tt": return (me.getHours() < 12) ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator; } } ) : this._toString(); }; return this; }; addSetFuncs(TimeSpan, attrs.slice(2)); TimeSpan.prototype.set = function (days, hours, minutes, seconds, milliseconds){ this.setDays(days || this.getDays()); this.setHours(hours || this.getHours()); this.setMinutes(minutes || this.getMinutes()); this.setSeconds(seconds || this.getSeconds()); this.setMilliseconds(milliseconds || this.getMilliseconds()); }; /** * Gets the time of day for this date instances. * @return {TimeSpan} TimeSpan */ Date.prototype.getTimeOfDay = function () { return new TimeSpan(0, this.getHours(), this.getMinutes(), this.getSeconds(), this.getMilliseconds()); }; Date.TimeSpan = TimeSpan; if (typeof window !== "undefined" ) { // keeping API compatible for v1.x window.TimeSpan = TimeSpan; } }()); (function () { "use strict"; var attrs = ["years", "months", "days", "hours", "minutes", "seconds", "milliseconds"]; var gFn = function (attr) { return function () { return this[attr]; }; }; var sFn = function (attr) { return function (val) { this[attr] = val; return this; }; }; var addSetFuncs = function (context, attrs) { for (var i = 0; i < attrs.length ; i++) { var $a = attrs[i], $b = $a.slice(0, 1).toUpperCase() + $a.slice(1); context.prototype[$a] = 0; context.prototype["get" + $b] = gFn($a); context.prototype["set" + $b] = sFn($a); } }; var setMonthsAndYears = function (orient, d1, d2, context) { function inc() { d1.addMonths(-orient); context.months++; if (context.months === 12) { context.years++; context.months = 0; } } if (orient === +1) { while (d1 > d2) { inc(); } } else { while (d1 < d2) { inc(); } } context.months--; context.months *= orient; context.years *= orient; }; var adjustForDST = function(orient, startDate, endDate) { var hasDSTMismatch = (false === (startDate.isDaylightSavingTime() === endDate.isDaylightSavingTime())); if (hasDSTMismatch && orient === 1) { startDate.addHours(-1); } else if (hasDSTMismatch) { startDate.addHours(1); } }; /** * TimePeriod(startDate, endDate); * TimePeriod(years, months, days, hours, minutes, seconds, milliseconds); */ var TimePeriod = function (years, months, days, hours, minutes, seconds, milliseconds) { if (arguments.length === 7) { this.set(years, months, days, hours, minutes, seconds, milliseconds); } else if (arguments.length === 2 && arguments[0] instanceof Date && arguments[1] instanceof Date) { var startDate = arguments[0].clone(); var endDate = arguments[1].clone(); var orient = (startDate > endDate) ? +1 : -1; this.dates = { start: arguments[0].clone(), end: arguments[1].clone() }; setMonthsAndYears(orient, startDate, endDate, this); adjustForDST(orient, startDate, endDate); // // TODO - adjust for DST var diff = endDate - startDate; if (diff !== 0) { var ts = new TimeSpan(diff); this.set(this.years, this.months, ts.getDays(), ts.getHours(), ts.getMinutes(), ts.getSeconds(), ts.getMilliseconds()); } } return this; }; // create all the set functions. addSetFuncs(TimePeriod, attrs); TimePeriod.prototype.set = function (years, months, days, hours, minutes, seconds, milliseconds){ this.setYears(years || this.getYears()); this.setMonths(months || this.getMonths()); this.setDays(days || this.getDays()); this.setHours(hours || this.getHours()); this.setMinutes(minutes || this.getMinutes()); this.setSeconds(seconds || this.getSeconds()); this.setMilliseconds(milliseconds || this.getMilliseconds()); }; Date.TimePeriod = TimePeriod; if (typeof window !== "undefined") { // keeping API compatible for v1.x window.TimePeriod = TimePeriod; } }()); ================================================ FILE: build/date-hr-BA.js ================================================ /** * @overview datejs * @version 1.0.0-rc3 * @author Gregory Wild-Smith * @copyright 2015 Gregory Wild-Smith * @license MIT * @homepage https://github.com/abritinthebay/datejs */ /* * DateJS Culture String File * Country Code: hr-BA * Name: Croatian (Bosnia and Herzegovina) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["hr-BA"] = { "name": "hr-BA", "englishName": "Croatian (Bosnia and Herzegovina)", "nativeName": "hrvatski (Bosna i Hercegovina)", "Sunday": "nedjelja", "Monday": "ponedjeljak", "Tuesday": "utorak", "Wednesday": "srijeda", "Thursday": "četvrtak", "Friday": "petak", "Saturday": "subota", "Sun": "ned", "Mon": "pon", "Tue": "uto", "Wed": "sri", "Thu": "čet", "Fri": "pet", "Sat": "sub", "Su": "ned", "Mo": "pon", "Tu": "uto", "We": "sri", "Th": "čet", "Fr": "pet", "Sa": "sub", "S_Sun_Initial": "n", "M_Mon_Initial": "p", "T_Tue_Initial": "u", "W_Wed_Initial": "s", "T_Thu_Initial": "č", "F_Fri_Initial": "p", "S_Sat_Initial": "s", "January": "siječanj", "February": "veljača", "March": "ožujak", "April": "travanj", "May": "svibanj", "June": "lipanj", "July": "srpanj", "August": "kolovoz", "September": "rujan", "October": "listopad", "November": "studeni", "December": "prosinac", "Jan_Abbr": "sij", "Feb_Abbr": "vlj", "Mar_Abbr": "ožu", "Apr_Abbr": "tra", "May_Abbr": "svi", "Jun_Abbr": "lip", "Jul_Abbr": "srp", "Aug_Abbr": "kol", "Sep_Abbr": "ruj", "Oct_Abbr": "lis", "Nov_Abbr": "stu", "Dec_Abbr": "pro", "AM": "", "PM": "", "firstDayOfWeek": 1, "twoDigitYearMax": 2029, "mdy": "dmy", "M/d/yyyy": "d.M.yyyy", "dddd, MMMM dd, yyyy": "d. MMMM yyyy", "h:mm tt": "H:mm:ss", "h:mm:ss tt": "H:mm:ss", "dddd, MMMM dd, yyyy h:mm:ss tt": "d. MMMM yyyy H:mm:ss", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "MMMM dd", "MMMM, yyyy": "MMMM, yyyy", "/jan(uary)?/": "sij(ečanj)?", "/feb(ruary)?/": "veljača", "/mar(ch)?/": "ožu(jak)?", "/apr(il)?/": "tra(vanj)?", "/may/": "svi(banj)?", "/jun(e)?/": "lip(anj)?", "/jul(y)?/": "srp(anj)?", "/aug(ust)?/": "kol(ovoz)?", "/sep(t(ember)?)?/": "ruj(an)?", "/oct(ober)?/": "lis(topad)?", "/nov(ember)?/": "stu(deni)?", "/dec(ember)?/": "pro(sinac)?", "/^su(n(day)?)?/": "^nedjelja", "/^mo(n(day)?)?/": "^ponedjeljak", "/^tu(e(s(day)?)?)?/": "^utorak", "/^we(d(nesday)?)?/": "^srijeda", "/^th(u(r(s(day)?)?)?)?/": "^četvrtak", "/^fr(i(day)?)?/": "^petak", "/^sa(t(urday)?)?/": "^subota", "/^next/": "^slijedeć(i|e|eg)", "/^last|past|prev(ious)?/": "^zadnji|posljednji|prethodni", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|pos(lije)?|od|odsad(a)?)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|pr(ije)?pred)", "/^yes(terday)?/": "^jučer", "/^t(od(ay)?)?/": "^danas", "/^tom(orrow)?/": "^sutra", "/^n(ow)?/": "^sad(a)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sek(und(a|e|i)?)?", "/^mn|min(ute)?s?/": "^mn|min(ut(a|e|i)?)?", "/^h(our)?s?/": "^s(at(a|i)?)?", "/^w(eek)?s?/": "^tj(edan(a|i)?)?", "/^m(onth)?s?/": "^mj(esec(a|i)?)?", "/^d(ay)?s?/": "^dan(a|i)?", "/^y(ear)?s?/": "^god(in(a|e|i|u))?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "hr-BA"; /** * @overview datejs * @version 1.0.0-rc3 * @author Gregory Wild-Smith * @copyright 2015 Gregory Wild-Smith * @license MIT * @homepage https://github.com/abritinthebay/datejs */(function () { var $D = Date; var lang = Date.CultureStrings ? Date.CultureStrings.lang : null; var loggedKeys = {}; // for debug purposes. var getText = { getFromKey: function (key, countryCode) { var output; if (Date.CultureStrings && Date.CultureStrings[countryCode] && Date.CultureStrings[countryCode][key]) { output = Date.CultureStrings[countryCode][key]; } else { output = getText.buildFromDefault(key); } if (key.charAt(0) === "/") { // Assume it's a regex output = getText.buildFromRegex(key, countryCode); } return output; }, getFromObjectValues: function (obj, countryCode) { var key, output = {}; for(key in obj) { if (obj.hasOwnProperty(key)) { output[key] = getText.getFromKey(obj[key], countryCode); } } return output; }, getFromObjectKeys: function (obj, countryCode) { var key, output = {}; for(key in obj) { if (obj.hasOwnProperty(key)) { output[getText.getFromKey(key, countryCode)] = obj[key]; } } return output; }, getFromArray: function (arr, countryCode) { var output = []; for (var i=0; i < arr.length; i++){ if (i in arr) { output[i] = getText.getFromKey(arr[i], countryCode); } } return output; }, buildFromDefault: function (key) { var output, length, split, last; switch(key) { case "name": output = "en-US"; break; case "englishName": output = "English (United States)"; break; case "nativeName": output = "English (United States)"; break; case "twoDigitYearMax": output = 2049; break; case "firstDayOfWeek": output = 0; break; default: output = key; split = key.split("_"); length = split.length; if (length > 1 && key.charAt(0) !== "/") { // if the key isn't a regex and it has a split. last = split[(length - 1)].toLowerCase(); if (last === "initial" || last === "abbr") { output = split[0]; } } break; } return output; }, buildFromRegex: function (key, countryCode) { var output; if (Date.CultureStrings && Date.CultureStrings[countryCode] && Date.CultureStrings[countryCode][key]) { output = new RegExp(Date.CultureStrings[countryCode][key], "i"); } else { output = new RegExp(key.replace(new RegExp("/", "g"),""), "i"); } return output; } }; var shallowMerge = function (obj1, obj2) { for (var attrname in obj2) { if (obj2.hasOwnProperty(attrname)) { obj1[attrname] = obj2[attrname]; } } }; var __ = function (key, language) { var countryCode = (language) ? language : lang; loggedKeys[key] = key; if (typeof key === "object") { if (key instanceof Array) { return getText.getFromArray(key, countryCode); } else { return getText.getFromObjectKeys(key, countryCode); } } else { return getText.getFromKey(key, countryCode); } }; var loadI18nScript = function (code) { // paatterned after jQuery's getScript. var url = Date.Config.i18n + code + ".js"; var head = document.getElementsByTagName("head")[0] || document.documentElement; var script = document.createElement("script"); script.src = url; var completed = false; var events = { done: function (){} // placeholder function }; // Attach handlers for all browsers script.onload = script.onreadystatechange = function() { if ( !completed && (!this.readyState || this.readyState === "loaded" || this.readyState === "complete") ) { events.done(); head.removeChild(script); } }; setTimeout(function() { head.insertBefore(script, head.firstChild); }, 0); // allows return to execute first return { done: function (cb) { events.done = function() { if (cb) { setTimeout(cb,0); } }; } }; }; var buildInfo = { buildFromMethodHash: function (obj) { var key; for(key in obj) { if (obj.hasOwnProperty(key)) { obj[key] = buildInfo[obj[key]](); } } return obj; }, timeZoneDST: function () { var DST = { "CHADT": "+1345", "NZDT": "+1300", "AEDT": "+1100", "ACDT": "+1030", "AZST": "+0500", "IRDT": "+0430", "EEST": "+0300", "CEST": "+0200", "BST": "+0100", "PMDT": "-0200", "ADT": "-0300", "NDT": "-0230", "EDT": "-0400", "CDT": "-0500", "MDT": "-0600", "PDT": "-0700", "AKDT": "-0800", "HADT": "-0900" }; return __(DST); }, timeZoneStandard: function () { var standard = { "LINT": "+1400", "TOT": "+1300", "CHAST": "+1245", "NZST": "+1200", "NFT": "+1130", "SBT": "+1100", "AEST": "+1000", "ACST": "+0930", "JST": "+0900", "CWST": "+0845", "CT": "+0800", "ICT": "+0700", "MMT": "+0630", "BST": "+0600", "NPT": "+0545", "IST": "+0530", "PKT": "+0500", "AFT": "+0430", "MSK": "+0400", "IRST": "+0330", "FET": "+0300", "EET": "+0200", "CET": "+0100", "GMT": "+0000", "UTC": "+0000", "CVT": "-0100", "GST": "-0200", "BRT": "-0300", "NST": "-0330", "AST": "-0400", "EST": "-0500", "CST": "-0600", "MST": "-0700", "PST": "-0800", "AKST": "-0900", "MIT": "-0930", "HST": "-1000", "SST": "-1100", "BIT": "-1200" }; return __(standard); }, timeZones: function (data) { var zone; data.timezones = []; for (zone in data.abbreviatedTimeZoneStandard) { if (data.abbreviatedTimeZoneStandard.hasOwnProperty(zone)) { data.timezones.push({ name: zone, offset: data.abbreviatedTimeZoneStandard[zone]}); } } for (zone in data.abbreviatedTimeZoneDST) { if (data.abbreviatedTimeZoneDST.hasOwnProperty(zone)) { data.timezones.push({ name: zone, offset: data.abbreviatedTimeZoneDST[zone], dst: true}); } } return data.timezones; }, days: function () { return __(["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"]); }, dayAbbr: function () { return __(["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"]); }, dayShortNames: function () { return __(["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"]); }, dayFirstLetters: function () { return __(["S_Sun_Initial", "M_Mon_Initial", "T_Tues_Initial", "W_Wed_Initial", "T_Thu_Initial", "F_Fri_Initial", "S_Sat_Initial"]); }, months: function () { return __(["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"]); }, monthAbbr: function () { return __(["Jan_Abbr", "Feb_Abbr", "Mar_Abbr", "Apr_Abbr", "May_Abbr", "Jun_Abbr", "Jul_Abbr", "Aug_Abbr", "Sep_Abbr", "Oct_Abbr", "Nov_Abbr", "Dec_Abbr"]); }, formatPatterns: function () { return getText.getFromObjectValues({ shortDate: "M/d/yyyy", longDate: "dddd, MMMM dd, yyyy", shortTime: "h:mm tt", longTime: "h:mm:ss tt", fullDateTime: "dddd, MMMM dd, yyyy h:mm:ss tt", sortableDateTime: "yyyy-MM-ddTHH:mm:ss", universalSortableDateTime: "yyyy-MM-dd HH:mm:ssZ", rfc1123: "ddd, dd MMM yyyy HH:mm:ss", monthDay: "MMMM dd", yearMonth: "MMMM, yyyy" }, Date.i18n.currentLanguage()); }, regex: function () { return getText.getFromObjectValues({ inTheMorning: "/( in the )(morn(ing)?)\\b/", thisMorning: "/(this )(morn(ing)?)\\b/", amThisMorning: "/(\b\\d(am)? )(this )(morn(ing)?)/", inTheEvening: "/( in the )(even(ing)?)\\b/", thisEvening: "/(this )(even(ing)?)\\b/", pmThisEvening: "/(\b\\d(pm)? )(this )(even(ing)?)/", jan: "/jan(uary)?/", feb: "/feb(ruary)?/", mar: "/mar(ch)?/", apr: "/apr(il)?/", may: "/may/", jun: "/jun(e)?/", jul: "/jul(y)?/", aug: "/aug(ust)?/", sep: "/sep(t(ember)?)?/", oct: "/oct(ober)?/", nov: "/nov(ember)?/", dec: "/dec(ember)?/", sun: "/^su(n(day)?)?/", mon: "/^mo(n(day)?)?/", tue: "/^tu(e(s(day)?)?)?/", wed: "/^we(d(nesday)?)?/", thu: "/^th(u(r(s(day)?)?)?)?/", fri: "/fr(i(day)?)?/", sat: "/^sa(t(urday)?)?/", future: "/^next/", past: "/^last|past|prev(ious)?/", add: "/^(\\+|aft(er)?|from|hence)/", subtract: "/^(\\-|bef(ore)?|ago)/", yesterday: "/^yes(terday)?/", today: "/^t(od(ay)?)?/", tomorrow: "/^tom(orrow)?/", now: "/^n(ow)?/", millisecond: "/^ms|milli(second)?s?/", second: "/^sec(ond)?s?/", minute: "/^mn|min(ute)?s?/", hour: "/^h(our)?s?/", week: "/^w(eek)?s?/", month: "/^m(onth)?s?/", day: "/^d(ay)?s?/", year: "/^y(ear)?s?/", shortMeridian: "/^(a|p)/", longMeridian: "/^(a\\.?m?\\.?|p\\.?m?\\.?)/", timezone: "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/", ordinalSuffix: "/^\\s*(st|nd|rd|th)/", timeContext: "/^\\s*(\\:|a(?!u|p)|p)/" }, Date.i18n.currentLanguage()); } }; var CultureInfo = function () { var info = getText.getFromObjectValues({ name: "name", englishName: "englishName", nativeName: "nativeName", amDesignator: "AM", pmDesignator: "PM", firstDayOfWeek: "firstDayOfWeek", twoDigitYearMax: "twoDigitYearMax", dateElementOrder: "mdy" }, Date.i18n.currentLanguage()); var constructedInfo = buildInfo.buildFromMethodHash({ dayNames: "days", abbreviatedDayNames: "dayAbbr", shortestDayNames: "dayShortNames", firstLetterDayNames: "dayFirstLetters", monthNames: "months", abbreviatedMonthNames: "monthAbbr", formatPatterns: "formatPatterns", regexPatterns: "regex", abbreviatedTimeZoneDST: "timeZoneDST", abbreviatedTimeZoneStandard: "timeZoneStandard" }); shallowMerge(info, constructedInfo); buildInfo.timeZones(info); return info; }; $D.i18n = { __: function (key, lang) { return __(key, lang); }, currentLanguage: function () { return lang || "en-US"; }, setLanguage: function (code, force, cb) { var async = false; if (force || code === "en-US" || (!!Date.CultureStrings && !!Date.CultureStrings[code])) { lang = code; Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings.lang = code; Date.CultureInfo = new CultureInfo(); } else { if (!(!!Date.CultureStrings && !!Date.CultureStrings[code])) { if (typeof exports !== "undefined" && this.exports !== exports) { // we're in a Node enviroment, load it using require try { require("../i18n/" + code + ".js"); lang = code; Date.CultureStrings.lang = code; Date.CultureInfo = new CultureInfo(); } catch (e) { // var str = "The language for '" + code + "' could not be loaded by Node. It likely does not exist."; throw new Error("The DateJS IETF language tag '" + code + "' could not be loaded by Node. It likely does not exist."); } } else if (Date.Config && Date.Config.i18n) { // we know the location of the files, so lets load them async = true; loadI18nScript(code).done(function(){ lang = code; Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings.lang = code; Date.CultureInfo = new CultureInfo(); $D.Parsing.Normalizer.buildReplaceData(); // because this is async if ($D.Grammar) { $D.Grammar.buildGrammarFormats(); // so we can parse those strings... } if (cb) { setTimeout(cb,0); } }); } else { Date.console.error("The DateJS IETF language tag '" + code + "' is not available and has not been loaded."); return false; } } } $D.Parsing.Normalizer.buildReplaceData(); // rebuild normalizer strings if ($D.Grammar) { $D.Grammar.buildGrammarFormats(); // so we can parse those strings... } if (!async && cb) { setTimeout(cb,0); } }, getLoggedKeys: function () { return loggedKeys; }, updateCultureInfo: function () { Date.CultureInfo = new CultureInfo(); } }; $D.i18n.updateCultureInfo(); // run automatically }()); (function () { var $D = Date, $P = $D.prototype, p = function (s, l) { if (!l) { l = 2; } return ("000" + s).slice(l * -1); }; if (typeof window !== "undefined" && typeof window.console !== "undefined" && typeof window.console.log !== "undefined") { $D.console = console; // used only to raise non-critical errors if available } else { // set mock so we don't give errors. $D.console = { log: function(){}, error: function(){} }; } $D.Config = $D.Config || {}; $D.initOverloads = function() { /** * Overload of Date.now. Allows an alternate call for Date.now where it returns the * current Date as an object rather than just milliseconds since the Unix Epoch. * * Also provides an implementation of now() for browsers (IE<9) that don't have it. * * Backwards compatible so with work with either: * Date.now() [returns ms] * or * Date.now(true) [returns Date] */ if (!$D.now) { $D._now = function now() { return new Date().getTime(); }; } else if (!$D._now) { $D._now = $D.now; } $D.now = function (returnObj) { if (returnObj) { return $D.present(); } else { return $D._now(); } }; if ( !$P.toISOString ) { $P.toISOString = function() { return this.getUTCFullYear() + "-" + p(this.getUTCMonth() + 1) + "-" + p(this.getUTCDate()) + "T" + p(this.getUTCHours()) + ":" + p(this.getUTCMinutes()) + ":" + p(this.getUTCSeconds()) + "." + String( (this.getUTCMilliseconds()/1000).toFixed(3)).slice(2, 5) + "Z"; }; } // private if ( $P._toString === undefined ){ $P._toString = $P.toString; } }; $D.initOverloads(); /** * Gets a date that is set to the current date. The time is set to the start of the day (00:00 or 12:00 AM). * @return {Date} The current date. */ $D.today = function () { return new Date().clearTime(); }; /** * Gets a date that is set to the current date and time (same as new Date, but chainable) * @return {Date} The current date. */ $D.present = function () { return new Date(); }; /** * Compares the first date to the second date and returns an number indication of their relative values. * @param {Date} First Date object to compare [Required]. * @param {Date} Second Date object to compare to [Required]. * @return {Number} -1 = date1 is lessthan date2. 0 = values are equal. 1 = date1 is greaterthan date2. */ $D.compare = function (date1, date2) { if (isNaN(date1) || isNaN(date2)) { throw new Error(date1 + " - " + date2); } else if (date1 instanceof Date && date2 instanceof Date) { return (date1 < date2) ? -1 : (date1 > date2) ? 1 : 0; } else { throw new TypeError(date1 + " - " + date2); } }; /** * Compares the first Date object to the second Date object and returns true if they are equal. * @param {Date} First Date object to compare [Required] * @param {Date} Second Date object to compare to [Required] * @return {Boolean} true if dates are equal. false if they are not equal. */ $D.equals = function (date1, date2) { return (date1.compareTo(date2) === 0); }; /** * Gets the language appropriate day name when given the day number(0-6) * eg - 0 == Sunday * @return {String} The day name */ $D.getDayName = function (n) { return Date.CultureInfo.dayNames[n]; }; /** * Gets the day number (0-6) if given a CultureInfo specific string which is a valid dayName, abbreviatedDayName or shortestDayName (two char). * @param {String} The name of the day (eg. "Monday, "Mon", "tuesday", "tue", "We", "we"). * @return {Number} The day number */ $D.getDayNumberFromName = function (name) { var n = Date.CultureInfo.dayNames, m = Date.CultureInfo.abbreviatedDayNames, o = Date.CultureInfo.shortestDayNames, s = name.toLowerCase(); for (var i = 0; i < n.length; i++) { if (n[i].toLowerCase() === s || m[i].toLowerCase() === s || o[i].toLowerCase() === s) { return i; } } return -1; }; /** * Gets the month number (0-11) if given a Culture Info specific string which is a valid monthName or abbreviatedMonthName. * @param {String} The name of the month (eg. "February, "Feb", "october", "oct"). * @return {Number} The day number */ $D.getMonthNumberFromName = function (name) { var n = Date.CultureInfo.monthNames, m = Date.CultureInfo.abbreviatedMonthNames, s = name.toLowerCase(); for (var i = 0; i < n.length; i++) { if (n[i].toLowerCase() === s || m[i].toLowerCase() === s) { return i; } } return -1; }; /** * Gets the language appropriate month name when given the month number(0-11) * eg - 0 == January * @return {String} The month name */ $D.getMonthName = function (n) { return Date.CultureInfo.monthNames[n]; }; /** * Determines if the current date instance is within a LeapYear. * @param {Number} The year. * @return {Boolean} true if date is within a LeapYear, otherwise false. */ $D.isLeapYear = function (year) { return ((year % 4 === 0 && year % 100 !== 0) || year % 400 === 0); }; /** * Gets the number of days in the month, given a year and month value. Automatically corrects for LeapYear. * @param {Number} The year. * @param {Number} The month (0-11). * @return {Number} The number of days in the month. */ $D.getDaysInMonth = function (year, month) { if (!month && $D.validateMonth(year)) { month = year; year = Date.today().getFullYear(); } return [31, ($D.isLeapYear(year) ? 29 : 28), 31, 30, 31, 30, 31, 31, 30, 31, 30, 31][month]; }; $P.getDaysInMonth = function () { return $D.getDaysInMonth(this.getFullYear(), this.getMonth()); }; $D.getTimezoneAbbreviation = function (offset, dst) { var p, n = (dst || false) ? Date.CultureInfo.abbreviatedTimeZoneDST : Date.CultureInfo.abbreviatedTimeZoneStandard; for (p in n) { if (n.hasOwnProperty(p)) { if (n[p] === offset) { return p; } } } return null; }; $D.getTimezoneOffset = function (name, dst) { var i, a =[], z = Date.CultureInfo.timezones; if (!name) { name = (new Date()).getTimezone();} for (i = 0; i < z.length; i++) { if (z[i].name === name.toUpperCase()) { a.push(i); } } if (!z[a[0]]) { return null; } if (a.length === 1 || !dst) { return z[a[0]].offset; } else { for (i=0; i < a.length; i++) { if (z[a[i]].dst) { return z[a[i]].offset; } } } }; $D.getQuarter = function (d) { d = d || new Date(); // If no date supplied, use today var q = [1,2,3,4]; return q[Math.floor(d.getMonth() / 3)]; // ~~~ is a bitwise op. Faster than Math.floor }; $D.getDaysLeftInQuarter = function (d) { d = d || new Date(); var qEnd = new Date(d); qEnd.setMonth(qEnd.getMonth() + 3 - qEnd.getMonth() % 3, 0); return Math.floor((qEnd - d) / 8.64e7); }; // private var validate = function (n, min, max, name) { name = name ? name : "Object"; if (typeof n === "undefined") { return false; } else if (typeof n !== "number") { throw new TypeError(n + " is not a Number."); } else if (n < min || n > max) { // As failing validation is *not* an exceptional circumstance // lets not throw a RangeError Exception here. // It's semantically correct but it's not sensible. return false; } return true; }; /** * Validates the number is within an acceptable range for milliseconds [0-999]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateMillisecond = function (value) { return validate(value, 0, 999, "millisecond"); }; /** * Validates the number is within an acceptable range for seconds [0-59]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateSecond = function (value) { return validate(value, 0, 59, "second"); }; /** * Validates the number is within an acceptable range for minutes [0-59]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateMinute = function (value) { return validate(value, 0, 59, "minute"); }; /** * Validates the number is within an acceptable range for hours [0-23]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateHour = function (value) { return validate(value, 0, 23, "hour"); }; /** * Validates the number is within an acceptable range for the days in a month [0-MaxDaysInMonth]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateDay = function (value, year, month) { if (year === undefined || year === null || month === undefined || month === null) { return false;} return validate(value, 1, $D.getDaysInMonth(year, month), "day"); }; /** * Validates the number is within an acceptable range for months [0-11]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateWeek = function (value) { return validate(value, 0, 53, "week"); }; /** * Validates the number is within an acceptable range for months [0-11]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateMonth = function (value) { return validate(value, 0, 11, "month"); }; /** * Validates the number is within an acceptable range for years. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateYear = function (value) { /** * Per ECMAScript spec the range of times supported by Date objects is * exactly -100,000,000 days to +100,000,000 days measured relative to * midnight at the beginning of 01 January, 1970 UTC. * This gives a range of 8,640,000,000,000,000 milliseconds to either * side of 01 January, 1970 UTC. * * Earliest possible date: Tue, 20 Apr 271,822 B.C. 00:00:00 UTC * Latest possible date: Sat, 13 Sep 275,760 00:00:00 UTC */ return validate(value, -271822, 275760, "year"); }; $D.validateTimezone = function(value) { var timezones = {"ACDT":1,"ACST":1,"ACT":1,"ADT":1,"AEDT":1,"AEST":1,"AFT":1,"AKDT":1,"AKST":1,"AMST":1,"AMT":1,"ART":1,"AST":1,"AWDT":1,"AWST":1,"AZOST":1,"AZT":1,"BDT":1,"BIOT":1,"BIT":1,"BOT":1,"BRT":1,"BST":1,"BTT":1,"CAT":1,"CCT":1,"CDT":1,"CEDT":1,"CEST":1,"CET":1,"CHADT":1,"CHAST":1,"CHOT":1,"ChST":1,"CHUT":1,"CIST":1,"CIT":1,"CKT":1,"CLST":1,"CLT":1,"COST":1,"COT":1,"CST":1,"CT":1,"CVT":1,"CWST":1,"CXT":1,"DAVT":1,"DDUT":1,"DFT":1,"EASST":1,"EAST":1,"EAT":1,"ECT":1,"EDT":1,"EEDT":1,"EEST":1,"EET":1,"EGST":1,"EGT":1,"EIT":1,"EST":1,"FET":1,"FJT":1,"FKST":1,"FKT":1,"FNT":1,"GALT":1,"GAMT":1,"GET":1,"GFT":1,"GILT":1,"GIT":1,"GMT":1,"GST":1,"GYT":1,"HADT":1,"HAEC":1,"HAST":1,"HKT":1,"HMT":1,"HOVT":1,"HST":1,"ICT":1,"IDT":1,"IOT":1,"IRDT":1,"IRKT":1,"IRST":1,"IST":1,"JST":1,"KGT":1,"KOST":1,"KRAT":1,"KST":1,"LHST":1,"LINT":1,"MAGT":1,"MART":1,"MAWT":1,"MDT":1,"MET":1,"MEST":1,"MHT":1,"MIST":1,"MIT":1,"MMT":1,"MSK":1,"MST":1,"MUT":1,"MVT":1,"MYT":1,"NCT":1,"NDT":1,"NFT":1,"NPT":1,"NST":1,"NT":1,"NUT":1,"NZDT":1,"NZST":1,"OMST":1,"ORAT":1,"PDT":1,"PET":1,"PETT":1,"PGT":1,"PHOT":1,"PHT":1,"PKT":1,"PMDT":1,"PMST":1,"PONT":1,"PST":1,"PYST":1,"PYT":1,"RET":1,"ROTT":1,"SAKT":1,"SAMT":1,"SAST":1,"SBT":1,"SCT":1,"SGT":1,"SLST":1,"SRT":1,"SST":1,"SYOT":1,"TAHT":1,"THA":1,"TFT":1,"TJT":1,"TKT":1,"TLT":1,"TMT":1,"TOT":1,"TVT":1,"UCT":1,"ULAT":1,"UTC":1,"UYST":1,"UYT":1,"UZT":1,"VET":1,"VLAT":1,"VOLT":1,"VOST":1,"VUT":1,"WAKT":1,"WAST":1,"WAT":1,"WEDT":1,"WEST":1,"WET":1,"WST":1,"YAKT":1,"YEKT":1,"Z":1}; return (timezones[value] === 1); }; $D.validateTimezoneOffset= function(value) { // timezones go from +14hrs to -12hrs, the +X hours are negative offsets. return (value > -841 && value < 721); }; }()); (function () { var $D = Date, $P = $D.prototype, p = function (s, l) { if (!l) { l = 2; } return ("000" + s).slice(l * -1); }; var validateConfigObject = function (obj) { var result = {}, self = this, prop, testFunc; testFunc = function (prop, func, value) { if (prop === "day") { var month = (obj.month !== undefined) ? obj.month : self.getMonth(); var year = (obj.year !== undefined) ? obj.year : self.getFullYear(); return $D[func](value, year, month); } else { return $D[func](value); } }; for (prop in obj) { if (Object.prototype.hasOwnProperty.call(obj, prop)) { var func = "validate" + prop.charAt(0).toUpperCase() + prop.slice(1); if ($D[func] && obj[prop] !== null && testFunc(prop, func, obj[prop])) { result[prop] = obj[prop]; } } } return result; }; /** * Resets the time of this Date object to 12:00 AM (00:00), which is the start of the day. * @param {Boolean} .clone() this date instance before clearing Time * @return {Date} this */ $P.clearTime = function () { this.setHours(0); this.setMinutes(0); this.setSeconds(0); this.setMilliseconds(0); return this; }; /** * Resets the time of this Date object to the current time ('now'). * @return {Date} this */ $P.setTimeToNow = function () { var n = new Date(); this.setHours(n.getHours()); this.setMinutes(n.getMinutes()); this.setSeconds(n.getSeconds()); this.setMilliseconds(n.getMilliseconds()); return this; }; /** * Returns a new Date object that is an exact date and time copy of the original instance. * @return {Date} A new Date instance */ $P.clone = function () { return new Date(this.getTime()); }; /** * Compares this instance to a Date object and returns an number indication of their relative values. * @param {Date} Date object to compare [Required] * @return {Number} -1 = this is lessthan date. 0 = values are equal. 1 = this is greaterthan date. */ $P.compareTo = function (date) { return Date.compare(this, date); }; /** * Compares this instance to another Date object and returns true if they are equal. * @param {Date} Date object to compare. If no date to compare, new Date() [now] is used. * @return {Boolean} true if dates are equal. false if they are not equal. */ $P.equals = function (date) { return Date.equals(this, (date !== undefined ? date : new Date())); }; /** * Determines if this instance is between a range of two dates or equal to either the start or end dates. * @param {Date} Start of range [Required] * @param {Date} End of range [Required] * @return {Boolean} true is this is between or equal to the start and end dates, else false */ $P.between = function (start, end) { return this.getTime() >= start.getTime() && this.getTime() <= end.getTime(); }; /** * Determines if this date occurs after the date to compare to. * @param {Date} Date object to compare. If no date to compare, new Date() ("now") is used. * @return {Boolean} true if this date instance is greater than the date to compare to (or "now"), otherwise false. */ $P.isAfter = function (date) { return this.compareTo(date || new Date()) === 1; }; /** * Determines if this date occurs before the date to compare to. * @param {Date} Date object to compare. If no date to compare, new Date() ("now") is used. * @return {Boolean} true if this date instance is less than the date to compare to (or "now"). */ $P.isBefore = function (date) { return (this.compareTo(date || new Date()) === -1); }; /** * Determines if the current Date instance occurs today. * @return {Boolean} true if this date instance is 'today', otherwise false. */ /** * Determines if the current Date instance occurs on the same Date as the supplied 'date'. * If no 'date' to compare to is provided, the current Date instance is compared to 'today'. * @param {date} Date object to compare. If no date to compare, the current Date ("now") is used. * @return {Boolean} true if this Date instance occurs on the same Day as the supplied 'date'. */ $P.isToday = $P.isSameDay = function (date) { return this.clone().clearTime().equals((date || new Date()).clone().clearTime()); }; /** * Adds the specified number of milliseconds to this instance. * @param {Number} The number of milliseconds to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addMilliseconds = function (value) { if (!value) { return this; } this.setTime(this.getTime() + value * 1); return this; }; /** * Adds the specified number of seconds to this instance. * @param {Number} The number of seconds to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addSeconds = function (value) { if (!value) { return this; } return this.addMilliseconds(value * 1000); }; /** * Adds the specified number of seconds to this instance. * @param {Number} The number of seconds to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addMinutes = function (value) { if (!value) { return this; } return this.addMilliseconds(value * 60000); // 60*1000 }; /** * Adds the specified number of hours to this instance. * @param {Number} The number of hours to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addHours = function (value) { if (!value) { return this; } return this.addMilliseconds(value * 3600000); // 60*60*1000 }; /** * Adds the specified number of days to this instance. * @param {Number} The number of days to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addDays = function (value) { if (!value) { return this; } this.setDate(this.getDate() + value * 1); return this; }; /** * Adds the specified number of weekdays (ie - not sat or sun) to this instance. * @param {Number} The number of days to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addWeekdays = function (value) { if (!value) { return this; } var day = this.getDay(); var weeks = (Math.ceil(Math.abs(value)/7)); if (day === 0 || day === 6) { if (value > 0) { this.next().monday(); this.addDays(-1); day = this.getDay(); } } if (value < 0) { while (value < 0) { this.addDays(-1); day = this.getDay(); if (day !== 0 && day !== 6) { value++; } } return this; } else if (value > 5 || (6-day) <= value) { value = value + (weeks * 2); } return this.addDays(value); }; /** * Adds the specified number of weeks to this instance. * @param {Number} The number of weeks to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addWeeks = function (value) { if (!value) { return this; } return this.addDays(value * 7); }; /** * Adds the specified number of months to this instance. * @param {Number} The number of months to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addMonths = function (value) { if (!value) { return this; } var n = this.getDate(); this.setDate(1); this.setMonth(this.getMonth() + value * 1); this.setDate(Math.min(n, $D.getDaysInMonth(this.getFullYear(), this.getMonth()))); return this; }; $P.addQuarters = function (value) { if (!value) { return this; } // note this will take you to the same point in the quarter as you are now. // i.e. - if you are 15 days into the quarter you'll be 15 days into the resulting one. // bonus: this allows adding fractional quarters return this.addMonths(value * 3); }; /** * Adds the specified number of years to this instance. * @param {Number} The number of years to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addYears = function (value) { if (!value) { return this; } return this.addMonths(value * 12); }; /** * Adds (or subtracts) to the value of the years, months, weeks, days, hours, minutes, seconds, milliseconds of the date instance using given configuration object. Positive and Negative values allowed. * Example

	Date.today().add( { days: 1, months: 1 } )

	new Date().add( { years: -1 } )
	
* @param {Object} Configuration object containing attributes (months, days, etc.) * @return {Date} this */ $P.add = function (config) { if (typeof config === "number") { this._orient = config; return this; } var x = config; if (x.day) { // If we should be a different date than today (eg: for 'tomorrow -1d', etc). // Should only effect parsing, not direct usage (eg, Finish and FinishExact) if ((x.day - this.getDate()) !== 0) { this.setDate(x.day); } } if (x.milliseconds) { this.addMilliseconds(x.milliseconds); } if (x.seconds) { this.addSeconds(x.seconds); } if (x.minutes) { this.addMinutes(x.minutes); } if (x.hours) { this.addHours(x.hours); } if (x.weeks) { this.addWeeks(x.weeks); } if (x.months) { this.addMonths(x.months); } if (x.years) { this.addYears(x.years); } if (x.days) { this.addDays(x.days); } return this; }; /** * Get the week number. Week one (1) is the week which contains the first Thursday of the year. Monday is considered the first day of the week. * The .getWeek() function does NOT convert the date to UTC. The local datetime is used. * Please use .getISOWeek() to get the week of the UTC converted date. * @return {Number} 1 to 53 */ $P.getWeek = function (utc) { // Create a copy of this date object var self, target = new Date(this.valueOf()); if (utc) { target.addMinutes(target.getTimezoneOffset()); self = target.clone(); } else { self = this; } // ISO week date weeks start on monday // so correct the day number var dayNr = (self.getDay() + 6) % 7; // ISO 8601 states that week 1 is the week // with the first thursday of that year. // Set the target date to the thursday in the target week target.setDate(target.getDate() - dayNr + 3); // Store the millisecond value of the target date var firstThursday = target.valueOf(); // Set the target to the first thursday of the year // First set the target to january first target.setMonth(0, 1); // Not a thursday? Correct the date to the next thursday if (target.getDay() !== 4) { target.setMonth(0, 1 + ((4 - target.getDay()) + 7) % 7); } // The weeknumber is the number of weeks between the // first thursday of the year and the thursday in the target week return 1 + Math.ceil((firstThursday - target) / 604800000); // 604800000 = 7 * 24 * 3600 * 1000 }; /** * Get the ISO 8601 week number. Week one ("01") is the week which contains the first Thursday of the year. Monday is considered the first day of the week. * The .getISOWeek() function does convert the date to it's UTC value. Please use .getWeek() to get the week of the local date. * @return {String} "01" to "53" */ $P.getISOWeek = function () { return p(this.getWeek(true)); }; /** * Moves the date to Monday of the week set. Week one (1) is the week which contains the first Thursday of the year. * @param {Number} A Number (1 to 53) that represents the week of the year. * @return {Date} this */ $P.setWeek = function (n) { if ((n - this.getWeek()) === 0) { if (this.getDay() !== 1) { return this.moveToDayOfWeek(1, (this.getDay() > 1 ? -1 : 1)); } else { return this; } } else { return this.moveToDayOfWeek(1, (this.getDay() > 1 ? -1 : 1)).addWeeks(n - this.getWeek()); } }; $P.setQuarter = function (qtr) { var month = Math.abs(((qtr-1) * 3) + 1); return this.setMonth(month, 1); }; $P.getQuarter = function () { return Date.getQuarter(this); }; $P.getDaysLeftInQuarter = function () { return Date.getDaysLeftInQuarter(this); }; /** * Moves the date to the next n'th occurrence of the dayOfWeek starting from the beginning of the month. The number (-1) is a magic number and will return the last occurrence of the dayOfWeek in the month. * @param {Number} The dayOfWeek to move to * @param {Number} The n'th occurrence to move to. Use (-1) to return the last occurrence in the month * @return {Date} this */ $P.moveToNthOccurrence = function (dayOfWeek, occurrence) { if (dayOfWeek === "Weekday") { if (occurrence > 0) { this.moveToFirstDayOfMonth(); if (this.is().weekday()) { occurrence -= 1; } } else if (occurrence < 0) { this.moveToLastDayOfMonth(); if (this.is().weekday()) { occurrence += 1; } } else { return this; } return this.addWeekdays(occurrence); } var shift = 0; if (occurrence > 0) { shift = occurrence - 1; } else if (occurrence === -1) { this.moveToLastDayOfMonth(); if (this.getDay() !== dayOfWeek) { this.moveToDayOfWeek(dayOfWeek, -1); } return this; } return this.moveToFirstDayOfMonth().addDays(-1).moveToDayOfWeek(dayOfWeek, +1).addWeeks(shift); }; var moveToN = function (getFunc, addFunc, nVal) { return function (value, orient) { var diff = (value - this[getFunc]() + nVal * (orient || +1)) % nVal; return this[addFunc]((diff === 0) ? diff += nVal * (orient || +1) : diff); }; }; /** * Move to the next or last dayOfWeek based on the orient value. * @param {Number} The dayOfWeek to move to * @param {Number} Forward (+1) or Back (-1). Defaults to +1. [Optional] * @return {Date} this */ $P.moveToDayOfWeek = moveToN("getDay", "addDays", 7); /** * Move to the next or last month based on the orient value. * @param {Number} The month to move to. 0 = January, 11 = December * @param {Number} Forward (+1) or Back (-1). Defaults to +1. [Optional] * @return {Date} this */ $P.moveToMonth = moveToN("getMonth", "addMonths", 12); /** * Get the Ordinate of the current day ("th", "st", "rd"). * @return {String} */ $P.getOrdinate = function () { var num = this.getDate(); return ord(num); }; /** * Get the Ordinal day (numeric day number) of the year, adjusted for leap year. * @return {Number} 1 through 365 (366 in leap years) */ $P.getOrdinalNumber = function () { return Math.ceil((this.clone().clearTime() - new Date(this.getFullYear(), 0, 1)) / 86400000) + 1; }; /** * Get the time zone abbreviation of the current date. * @return {String} The abbreviated time zone name (e.g. "EST") */ $P.getTimezone = function () { return $D.getTimezoneAbbreviation(this.getUTCOffset(), this.isDaylightSavingTime()); }; $P.setTimezoneOffset = function (offset) { var here = this.getTimezoneOffset(), there = Number(offset) * -6 / 10; return (there || there === 0) ? this.addMinutes(there - here) : this; }; $P.setTimezone = function (offset) { return this.setTimezoneOffset($D.getTimezoneOffset(offset)); }; /** * Indicates whether Daylight Saving Time is observed in the current time zone. * @return {Boolean} true|false */ $P.hasDaylightSavingTime = function () { return (Date.today().set({month: 0, day: 1}).getTimezoneOffset() !== Date.today().set({month: 6, day: 1}).getTimezoneOffset()); }; /** * Indicates whether this Date instance is within the Daylight Saving Time range for the current time zone. * @return {Boolean} true|false */ $P.isDaylightSavingTime = function () { return Date.today().set({month: 0, day: 1}).getTimezoneOffset() !== this.getTimezoneOffset(); }; /** * Get the offset from UTC of the current date. * @return {String} The 4-character offset string prefixed with + or - (e.g. "-0500") */ $P.getUTCOffset = function (offset) { var n = (offset || this.getTimezoneOffset()) * -10 / 6, r; if (n < 0) { r = (n - 10000).toString(); return r.charAt(0) + r.substr(2); } else { r = (n + 10000).toString(); return "+" + r.substr(1); } }; /** * Returns the number of milliseconds between this date and date. * @param {Date} Defaults to now * @return {Number} The diff in milliseconds */ $P.getElapsed = function (date) { return (date || new Date()) - this; }; /** * Set the value of year, month, day, hour, minute, second, millisecond of date instance using given configuration object. * Example

	Date.today().set( { day: 20, month: 1 } )

	new Date().set( { millisecond: 0 } )
	
* * @param {Object} Configuration object containing attributes (month, day, etc.) * @return {Date} this */ $P.set = function (config) { config = validateConfigObject.call(this, config); var key; for (key in config) { if (Object.prototype.hasOwnProperty.call(config, key)) { var name = key.charAt(0).toUpperCase() + key.slice(1); var addFunc, getFunc; if (key !== "week" && key !== "month" && key !== "timezone" && key !== "timezoneOffset") { name += "s"; } addFunc = "add" + name; getFunc = "get" + name; if (key === "month") { addFunc = addFunc + "s"; } else if (key === "year"){ getFunc = "getFullYear"; } if (key !== "day" && key !== "timezone" && key !== "timezoneOffset" && key !== "week" && key !== "hour") { this[addFunc](config[key] - this[getFunc]()); } else if ( key === "timezone"|| key === "timezoneOffset" || key === "week" || key === "hour") { this["set"+name](config[key]); } } } // day has to go last because you can't validate the day without first knowing the month if (config.day) { this.addDays(config.day - this.getDate()); } return this; }; /** * Moves the date to the first day of the month. * @return {Date} this */ $P.moveToFirstDayOfMonth = function () { return this.set({ day: 1 }); }; /** * Moves the date to the last day of the month. * @return {Date} this */ $P.moveToLastDayOfMonth = function () { return this.set({ day: $D.getDaysInMonth(this.getFullYear(), this.getMonth())}); }; /** * Converts the value of the current Date object to its equivalent string representation. * Format Specifiers * CUSTOM DATE AND TIME FORMAT STRINGS * Format Description Example * ------ --------------------------------------------------------------------------- ----------------------- * s The seconds of the minute between 0-59. "0" to "59" * ss The seconds of the minute with leading zero if required. "00" to "59" * * m The minute of the hour between 0-59. "0" or "59" * mm The minute of the hour with leading zero if required. "00" or "59" * * h The hour of the day between 1-12. "1" to "12" * hh The hour of the day with leading zero if required. "01" to "12" * * H The hour of the day between 0-23. "0" to "23" * HH The hour of the day with leading zero if required. "00" to "23" * * d The day of the month between 1 and 31. "1" to "31" * dd The day of the month with leading zero if required. "01" to "31" * ddd Abbreviated day name. Date.CultureInfo.abbreviatedDayNames. "Mon" to "Sun" * dddd The full day name. Date.CultureInfo.dayNames. "Monday" to "Sunday" * * M The month of the year between 1-12. "1" to "12" * MM The month of the year with leading zero if required. "01" to "12" * MMM Abbreviated month name. Date.CultureInfo.abbreviatedMonthNames. "Jan" to "Dec" * MMMM The full month name. Date.CultureInfo.monthNames. "January" to "December" * * yy The year as a two-digit number. "99" or "08" * yyyy The full four digit year. "1999" or "2008" * * t Displays the first character of the A.M./P.M. designator. "A" or "P" * Date.CultureInfo.amDesignator or Date.CultureInfo.pmDesignator * tt Displays the A.M./P.M. designator. "AM" or "PM" * Date.CultureInfo.amDesignator or Date.CultureInfo.pmDesignator * * S The ordinal suffix ("st, "nd", "rd" or "th") of the current day. "st, "nd", "rd" or "th" * * STANDARD DATE AND TIME FORMAT STRINGS * Format Description Example *------ --------------------------------------------------------------------------- ----------------------- * d The CultureInfo shortDate Format Pattern "M/d/yyyy" * D The CultureInfo longDate Format Pattern "dddd, MMMM dd, yyyy" * F The CultureInfo fullDateTime Format Pattern "dddd, MMMM dd, yyyy h:mm:ss tt" * m The CultureInfo monthDay Format Pattern "MMMM dd" * r The CultureInfo rfc1123 Format Pattern "ddd, dd MMM yyyy HH:mm:ss GMT" * s The CultureInfo sortableDateTime Format Pattern "yyyy-MM-ddTHH:mm:ss" * t The CultureInfo shortTime Format Pattern "h:mm tt" * T The CultureInfo longTime Format Pattern "h:mm:ss tt" * u The CultureInfo universalSortableDateTime Format Pattern "yyyy-MM-dd HH:mm:ssZ" * y The CultureInfo yearMonth Format Pattern "MMMM, yyyy" * * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @return {String} A string representation of the current Date object. */ var ord = function (n) { switch (n * 1) { case 1: case 21: case 31: return "st"; case 2: case 22: return "nd"; case 3: case 23: return "rd"; default: return "th"; } }; var parseStandardFormats = function (format) { var y, c = Date.CultureInfo.formatPatterns; switch (format) { case "d": return this.toString(c.shortDate); case "D": return this.toString(c.longDate); case "F": return this.toString(c.fullDateTime); case "m": return this.toString(c.monthDay); case "r": case "R": y = this.clone().addMinutes(this.getTimezoneOffset()); return y.toString(c.rfc1123) + " GMT"; case "s": return this.toString(c.sortableDateTime); case "t": return this.toString(c.shortTime); case "T": return this.toString(c.longTime); case "u": y = this.clone().addMinutes(this.getTimezoneOffset()); return y.toString(c.universalSortableDateTime); case "y": return this.toString(c.yearMonth); default: return false; } }; var parseFormatStringsClosure = function (context) { return function (m) { if (m.charAt(0) === "\\") { return m.replace("\\", ""); } switch (m) { case "hh": return p(context.getHours() < 13 ? (context.getHours() === 0 ? 12 : context.getHours()) : (context.getHours() - 12)); case "h": return context.getHours() < 13 ? (context.getHours() === 0 ? 12 : context.getHours()) : (context.getHours() - 12); case "HH": return p(context.getHours()); case "H": return context.getHours(); case "mm": return p(context.getMinutes()); case "m": return context.getMinutes(); case "ss": return p(context.getSeconds()); case "s": return context.getSeconds(); case "yyyy": return p(context.getFullYear(), 4); case "yy": return p(context.getFullYear()); case "y": return context.getFullYear(); case "E": case "dddd": return Date.CultureInfo.dayNames[context.getDay()]; case "ddd": return Date.CultureInfo.abbreviatedDayNames[context.getDay()]; case "dd": return p(context.getDate()); case "d": return context.getDate(); case "MMMM": return Date.CultureInfo.monthNames[context.getMonth()]; case "MMM": return Date.CultureInfo.abbreviatedMonthNames[context.getMonth()]; case "MM": return p((context.getMonth() + 1)); case "M": return context.getMonth() + 1; case "t": return context.getHours() < 12 ? Date.CultureInfo.amDesignator.substring(0, 1) : Date.CultureInfo.pmDesignator.substring(0, 1); case "tt": return context.getHours() < 12 ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator; case "S": return ord(context.getDate()); case "W": return context.getWeek(); case "WW": return context.getISOWeek(); case "Q": return "Q" + context.getQuarter(); case "q": return String(context.getQuarter()); case "z": return context.getTimezone(); case "Z": case "X": return Date.getTimezoneOffset(context.getTimezone()); case "ZZ": // Timezone offset in seconds return context.getTimezoneOffset() * -60; case "u": return context.getDay(); case "L": return ($D.isLeapYear(context.getFullYear())) ? 1 : 0; case "B": // Swatch Internet Time (.beats) return "@"+((context.getUTCSeconds() + (context.getUTCMinutes()*60) + ((context.getUTCHours()+1)*3600))/86.4); default: return m; } }; }; $P.toString = function (format, ignoreStandards) { // Standard Date and Time Format Strings. Formats pulled from CultureInfo file and // may vary by culture. if (!ignoreStandards && format && format.length === 1) { output = parseStandardFormats.call(this, format); if (output) { return output; } } var parseFormatStrings = parseFormatStringsClosure(this); return format ? format.replace(/((\\)?(dd?d?d?|MM?M?M?|yy?y?y?|hh?|HH?|mm?|ss?|tt?|S|q|Q|WW?W?W?)(?![^\[]*\]))/g, parseFormatStrings).replace(/\[|\]/g, "") : this._toString(); }; }()); /************************************************************* * SugarPak - Domain Specific Language - Syntactical Sugar * *************************************************************/ (function () { var $D = Date, $P = $D.prototype, $N = Number.prototype; // private $P._orient = +1; // private $P._nth = null; // private $P._is = false; // private $P._same = false; // private $P._isSecond = false; // private $N._dateElement = "days"; /** * Moves the date to the next instance of a date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.today().next().friday();
	Date.today().next().fri();
	Date.today().next().march();
	Date.today().next().mar();
	Date.today().next().week();
	
* * @return {Date} date */ $P.next = function () { this._move = true; this._orient = +1; return this; }; /** * Creates a new Date (Date.today()) and moves the date to the next instance of the date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.next().friday();
	Date.next().fri();
	Date.next().march();
	Date.next().mar();
	Date.next().week();
	
* * @return {Date} date */ $D.next = function () { return $D.today().next(); }; /** * Moves the date to the previous instance of a date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.today().last().friday();
	Date.today().last().fri();
	Date.today().last().march();
	Date.today().last().mar();
	Date.today().last().week();
	
* * @return {Date} date */ $P.last = $P.prev = $P.previous = function () { this._move = true; this._orient = -1; return this; }; /** * Creates a new Date (Date.today()) and moves the date to the previous instance of the date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.last().friday();
	Date.last().fri();
	Date.previous().march();
	Date.prev().mar();
	Date.last().week();
	
* * @return {Date} date */ $D.last = $D.prev = $D.previous = function () { return $D.today().last(); }; /** * Performs a equality check when followed by either a month name, day name or .weekday() function. * Example

	Date.today().is().friday(); // true|false
	Date.today().is().fri();
	Date.today().is().march();
	Date.today().is().mar();
	
* * @return {Boolean} true|false */ $P.is = function () { this._is = true; return this; }; /** * Determines if two date objects occur on/in exactly the same instance of the subsequent date part function. * The function .same() must be followed by a date part function (example: .day(), .month(), .year(), etc). * * An optional Date can be passed in the date part function. If now date is passed as a parameter, 'Now' is used. * * The following example demonstrates how to determine if two dates fall on the exact same day. * * Example

	var d1 = Date.today(); // today at 00:00
	var d2 = new Date();   // exactly now.

	// Do they occur on the same day?
	d1.same().day(d2); // true
	
	// Do they occur on the same hour?
	d1.same().hour(d2); // false, unless d2 hour is '00' (midnight).
	
	// What if it's the same day, but one year apart?
	var nextYear = Date.today().add(1).year();

	d1.same().day(nextYear); // false, because the dates must occur on the exact same day. 
	
* * Scenario: Determine if a given date occurs during some week period 2 months from now. * * Example

	var future = Date.today().add(2).months();
	return someDate.same().week(future); // true|false;
	
* * @return {Boolean} true|false */ $P.same = function () { this._same = true; this._isSecond = false; return this; }; /** * Determines if the current date/time occurs during Today. Must be preceded by the .is() function. * Example

	someDate.is().today();    // true|false
	new Date().is().today();  // true
	Date.today().is().today();// true
	Date.today().add(-1).day().is().today(); // false
	
* * @return {Boolean} true|false */ $P.today = function () { return this.same().day(); }; /** * Determines if the current date is a weekday. This function must be preceded by the .is() function. * Example

	Date.today().is().weekday(); // true|false
	
* * @return {Boolean} true|false */ $P.weekday = function () { if (this._nth) { return df("Weekday").call(this); } if (this._move) { return this.addWeekdays(this._orient); } if (this._is) { this._is = false; return (!this.is().sat() && !this.is().sun()); } return false; }; /** * Determines if the current date is on the weekend. This function must be preceded by the .is() function. * Example

	Date.today().is().weekend(); // true|false
	
* * @return {Boolean} true|false */ $P.weekend = function () { if (this._is) { this._is = false; return (this.is().sat() || this.is().sun()); } return false; }; /** * Sets the Time of the current Date instance. A string "6:15 pm" or config object {hour:18, minute:15} are accepted. * Example

	// Set time to 6:15pm with a String
	Date.today().at("6:15pm");

	// Set time to 6:15pm with a config object
	Date.today().at({hour:18, minute:15});
	
* * @return {Date} date */ $P.at = function (time) { return (typeof time === "string") ? $D.parse(this.toString("d") + " " + time) : this.set(time); }; /** * Creates a new Date() and adds this (Number) to the date based on the preceding date element function (eg. second|minute|hour|day|month|year). * Example

	// Undeclared Numbers must be wrapped with parentheses. Requirment of JavaScript.
	(3).days().fromNow();
	(6).months().fromNow();

	// Declared Number variables do not require parentheses. 
	var n = 6;
	n.months().fromNow();
	
* * @return {Date} A new Date instance */ $N.fromNow = $N.after = function (date) { var c = {}; c[this._dateElement] = this; return ((!date) ? new Date() : date.clone()).add(c); }; /** * Creates a new Date() and subtract this (Number) from the date based on the preceding date element function (eg. second|minute|hour|day|month|year). * Example

	// Undeclared Numbers must be wrapped with parentheses. Requirment of JavaScript.
	(3).days().ago();
	(6).months().ago();

	// Declared Number variables do not require parentheses. 
	var n = 6;
	n.months().ago();
	
* * @return {Date} A new Date instance */ $N.ago = $N.before = function (date) { var c = {}, s = (this._dateElement[this._dateElement.length-1] !== "s") ? this._dateElement + "s" : this._dateElement; c[s] = this * -1; return ((!date) ? new Date() : date.clone()).add(c); }; // Do NOT modify the following string tokens. These tokens are used to build dynamic functions. // All culture-specific strings can be found in the CultureInfo files. var dx = ("sunday monday tuesday wednesday thursday friday saturday").split(/\s/), mx = ("january february march april may june july august september october november december").split(/\s/), px = ("Millisecond Second Minute Hour Day Week Month Year Quarter Weekday").split(/\s/), pxf = ("Milliseconds Seconds Minutes Hours Date Week Month FullYear Quarter").split(/\s/), nth = ("final first second third fourth fifth").split(/\s/), de; /** * Returns an object literal of all the date parts. * Example

	var o = new Date().toObject();
	
	// { year: 2008, month: 4, week: 20, day: 13, hour: 18, minute: 9, second: 32, millisecond: 812 }
	
	// The object properties can be referenced directly from the object.
	
	alert(o.day);  // alerts "13"
	alert(o.year); // alerts "2008"
	
* * @return {Date} An object literal representing the original date object. */ $P.toObject = function () { var o = {}; for (var i = 0; i < px.length; i++) { if (this["get" + pxf[i]]) { o[px[i].toLowerCase()] = this["get" + pxf[i]](); } } return o; }; /** * Returns a date created from an object literal. Ignores the .week property if set in the config. * Example

	var o = new Date().toObject();
	
	return Date.fromObject(o); // will return the same date. 

	var o2 = {month: 1, day: 20, hour: 18}; // birthday party!
	Date.fromObject(o2);
	
* * @return {Date} An object literal representing the original date object. */ $D.fromObject = function(config) { config.week = null; return Date.today().set(config); }; // Create day name functions and abbreviated day name functions (eg. monday(), friday(), fri()). var df = function (n) { return function () { if (this._is) { this._is = false; return this.getDay() === n; } if (this._move) { this._move = null; } if (this._nth !== null) { // If the .second() function was called earlier, remove the _orient // from the date, and then continue. // This is required because 'second' can be used in two different context. // // Example // // Date.today().add(1).second(); // Date.march().second().monday(); // // Things get crazy with the following... // Date.march().add(1).second().second().monday(); // but it works!! // if (this._isSecond) { this.addSeconds(this._orient * -1); } // make sure we reset _isSecond this._isSecond = false; var ntemp = this._nth; this._nth = null; var temp = this.clone().moveToLastDayOfMonth(); this.moveToNthOccurrence(n, ntemp); if (this > temp) { throw new RangeError($D.getDayName(n) + " does not occur " + ntemp + " times in the month of " + $D.getMonthName(temp.getMonth()) + " " + temp.getFullYear() + "."); } return this; } return this.moveToDayOfWeek(n, this._orient); }; }; var sdf = function (n) { return function () { var t = $D.today(), shift = n - t.getDay(); if (n === 0 && Date.CultureInfo.firstDayOfWeek === 1 && t.getDay() !== 0) { shift = shift + 7; } return t.addDays(shift); }; }; // Create month name functions and abbreviated month name functions (eg. january(), march(), mar()). var month_instance_functions = function (n) { return function () { if (this._is) { this._is = false; return this.getMonth() === n; } return this.moveToMonth(n, this._orient); }; }; var month_static_functions = function (n) { return function () { return $D.today().set({ month: n, day: 1 }); }; }; var processTerms = function (names, staticFunc, instanceFunc) { for (var i = 0; i < names.length; i++) { // Create constant static Name variables. $D[names[i].toUpperCase()] = $D[names[i].toUpperCase().substring(0, 3)] = i; // Create Name functions. $D[names[i]] = $D[names[i].substring(0, 3)] = staticFunc(i); // Create Name instance functions. $P[names[i]] = $P[names[i].substring(0, 3)] = instanceFunc(i); } }; processTerms(dx, sdf, df); processTerms(mx, month_static_functions, month_instance_functions); // Create date element functions and plural date element functions used with Date (eg. day(), days(), months()). var ef = function (j) { return function () { // if the .second() function was called earlier, the _orient // has alread been added. Just return this and reset _isSecond. if (this._isSecond) { this._isSecond = false; return this; } if (this._same) { this._same = this._is = false; var o1 = this.toObject(), o2 = (arguments[0] || new Date()).toObject(), v = "", k = j.toLowerCase(); // the substr trick with -1 doesn't work in IE8 or less k = (k[k.length-1] === "s") ? k.substring(0,k.length-1) : k; for (var m = (px.length - 1); m > -1; m--) { v = px[m].toLowerCase(); if (o1[v] !== o2[v]) { return false; } if (k === v) { break; } } return true; } if (j.substring(j.length - 1) !== "s") { j += "s"; } if (this._move) { this._move = null; } return this["add" + j](this._orient); }; }; var nf = function (n) { return function () { this._dateElement = n; return this; }; }; for (var k = 0; k < px.length; k++) { de = px[k].toLowerCase(); if(de !== "weekday") { // Create date element functions and plural date element functions used with Date (eg. day(), days(), months()). $P[de] = $P[de + "s"] = ef(px[k]); // Create date element functions and plural date element functions used with Number (eg. day(), days(), months()). $N[de] = $N[de + "s"] = nf(de + "s"); } } $P._ss = ef("Second"); var nthfn = function (n) { return function (dayOfWeek) { if (this._same) { return this._ss(arguments[0]); } if (dayOfWeek || dayOfWeek === 0) { return this.moveToNthOccurrence(dayOfWeek, n); } this._nth = n; // if the operator is 'second' add the _orient, then deal with it later... if (n === 2 && (dayOfWeek === undefined || dayOfWeek === null)) { this._isSecond = true; return this.addSeconds(this._orient); } return this; }; }; for (var l = 0; l < nth.length; l++) { $P[nth[l]] = (l === 0) ? nthfn(-1) : nthfn(l); } }()); (function () { "use strict"; Date.Parsing = { Exception: function (s) { this.message = "Parse error at '" + s.substring(0, 10) + " ...'"; } }; var $P = Date.Parsing; var dayOffsets = { standard: [0,31,59,90,120,151,181,212,243,273,304,334], leap: [0,31,60,91,121,152,182,213,244,274,305,335] }; $P.isLeapYear = function(year) { return ((year % 4 === 0) && (year % 100 !== 0)) || (year % 400 === 0); }; var utils = { multiReplace : function (str, hash ) { var key; for (key in hash) { if (Object.prototype.hasOwnProperty.call(hash, key)) { var regex; if (typeof hash[key] === "function") { } else { regex = (hash[key] instanceof RegExp) ? hash[key] : new RegExp(hash[key], "g"); } str = str.replace(regex, key); } } return str; }, getDayOfYearFromWeek : function (obj) { var d, jan4, offset; obj.weekDay = (!obj.weekDay && obj.weekDay !== 0) ? 1 : obj.weekDay; d = new Date(obj.year, 0, 4); jan4 = d.getDay() === 0 ? 7 : d.getDay(); // JS is 0 indexed on Sunday. offset = jan4+3; obj.dayOfYear = ((obj.week * 7) + (obj.weekDay === 0 ? 7 : obj.weekDay))-offset; return obj; }, getDayOfYear : function (obj, dayOffset) { if (!obj.dayOfYear) { obj = utils.getDayOfYearFromWeek(obj); } for (var i=0;i <= dayOffset.length;i++) { if (obj.dayOfYear < dayOffset[i] || i === dayOffset.length) { obj.day = obj.day ? obj.day : (obj.dayOfYear - dayOffset[i-1]); break; } else { obj.month = i; } } return obj; }, adjustForTimeZone : function (obj, date) { var offset; if (obj.zone.toUpperCase() === "Z" || (obj.zone_hours === 0 && obj.zone_minutes === 0)) { // it's UTC/GML so work out the current timeszone offset offset = -date.getTimezoneOffset(); } else { offset = (obj.zone_hours*60) + (obj.zone_minutes || 0); if (obj.zone_sign === "+") { offset *= -1; } offset -= date.getTimezoneOffset(); } date.setMinutes(date.getMinutes()+offset); return date; }, setDefaults : function (obj) { obj.year = obj.year || Date.today().getFullYear(); obj.hours = obj.hours || 0; obj.minutes = obj.minutes || 0; obj.seconds = obj.seconds || 0; obj.milliseconds = obj.milliseconds || 0; if (!(!obj.month && (obj.week || obj.dayOfYear))) { // if we have a month, or if we don't but don't have the day calculation data obj.month = obj.month || 0; obj.day = obj.day || 1; } return obj; }, dataNum: function (data, mod, explict, postProcess) { var dataNum = data*1; if (mod) { if (postProcess) { return data ? mod(data)*1 : data; } else { return data ? mod(dataNum) : data; } } else if (!explict){ return data ? dataNum : data; } else { return (data && typeof data !== "undefined") ? dataNum : data; } }, timeDataProcess: function (obj) { var timeObj = {}; for (var x in obj.data) { if (obj.data.hasOwnProperty(x)) { timeObj[x] = obj.ignore[x] ? obj.data[x] : utils.dataNum(obj.data[x], obj.mods[x], obj.explict[x], obj.postProcess[x]); } } if (obj.data.secmins) { obj.data.secmins = obj.data.secmins.replace(",", ".") * 60; if (!timeObj.minutes) { timeObj.minutes = obj.data.secmins; } else if (!timeObj.seconds) { timeObj.seconds = obj.data.secmins; } delete obj.secmins; } return timeObj; }, buildTimeObjectFromData: function (data) { var time = utils.timeDataProcess({ data: { year : data[1], month : data[5], day : data[7], week : data[8], dayOfYear : data[10], hours : data[15], zone_hours : data[23], zone_minutes : data[24], zone : data[21], zone_sign : data[22], weekDay : data[9], minutes: data[16], seconds: data[19], milliseconds: data[20], secmins: data[18] }, mods: { month: function(data) { return data-1; }, weekDay: function (data) { data = Math.abs(data); return (data === 7 ? 0 : data); }, minutes: function (data) { return data.replace(":",""); }, seconds: function (data) { return Math.floor( (data.replace(":","").replace(",","."))*1 ); }, milliseconds: function (data) { return (data.replace(",",".")*1000); } }, postProcess: { minutes: true, seconds: true, milliseconds: true }, explict: { zone_hours: true, zone_minutes: true }, ignore: { zone: true, zone_sign: true, secmins: true } }); return time; }, addToHash: function (hash, keys, data) { keys = keys; data = data; var len = keys.length; for (var i = 0; i < len; i++) { hash[keys[i]] = data[i]; } return hash; }, combineRegex: function (r1, r2) { return new RegExp("(("+r1.source+")\\s("+r2.source+"))"); }, getDateNthString: function(add, last, inc){ if (add) { return Date.today().addDays(inc).toString("d"); } else if (last) { return Date.today().last()[inc]().toString("d"); } }, buildRegexData: function (array) { var arr = []; var len = array.length; for (var i=0; i < len; i++) { if (Object.prototype.toString.call(array[i]) === '[object Array]') { // oldIE compat version of Array.isArray arr.push(this.combineRegex(array[i][0], array[i][1])); } else { arr.push(array[i]); } } return arr; } }; $P.processTimeObject = function (obj) { var date, dayOffset; utils.setDefaults(obj); dayOffset = ($P.isLeapYear(obj.year)) ? dayOffsets.leap : dayOffsets.standard; if (!obj.month && (obj.week || obj.dayOfYear)) { utils.getDayOfYear(obj, dayOffset); } else { obj.dayOfYear = dayOffset[obj.month] + obj.day; } date = new Date(obj.year, obj.month, obj.day, obj.hours, obj.minutes, obj.seconds, obj.milliseconds); if (obj.zone) { utils.adjustForTimeZone(obj, date); // adjust (and calculate) for timezone } return date; }; $P.ISO = { regex : /^([\+-]?\d{4}(?!\d{2}\b))((-?)((0[1-9]|1[0-2])(\3([12]\d|0[1-9]|3[01]))?|W([0-4]\d|5[0-3])(-?[1-7])?|(00[1-9]|0[1-9]\d|[12]\d{2}|3([0-5]\d|6[1-6])))([T\s]((([01]\d|2[0-4])((:?)[0-5]\d)?|24\:?00)([\.,]\d+(?!:))?)?(\17[0-5]\d([\.,]\d+)?)?\s?([zZ]|([\+-])([01]\d|2[0-3]):?([0-5]\d)?)?)?)?$/, parse : function (s) { var time, data = s.match(this.regex); if (!data || !data.length) { return null; } time = utils.buildTimeObjectFromData(data); if (!time.year || (!time.year && (!time.month && !time.day) && (!time.week && !time.dayOfYear)) ) { return null; } return $P.processTimeObject(time); } }; $P.Numeric = { isNumeric: function (e){return!isNaN(parseFloat(e))&&isFinite(e);}, regex: /\b([0-1]?[0-9])([0-3]?[0-9])([0-2]?[0-9]?[0-9][0-9])\b/i, parse: function (s) { var data, i, time = {}, order = Date.CultureInfo.dateElementOrder.split(""); if (!(this.isNumeric(s)) || // if it's non-numeric OR (s[0] === "+" && s[0] === "-")) { // It's an arithmatic string (eg +/-1000) return null; } if (s.length < 5 && s.indexOf(".") < 0 && s.indexOf("/") < 0) { // assume it's just a year. time.year = s; return $P.processTimeObject(time); } data = s.match(this.regex); if (!data || !data.length) { return null; } for (i=0; i < order.length; i++) { switch(order[i]) { case "d": time.day = data[i+1]; break; case "m": time.month = (data[i+1]-1); break; case "y": time.year = data[i+1]; break; } } return $P.processTimeObject(time); } }; $P.Normalizer = { regexData: function () { var $R = Date.CultureInfo.regexPatterns; return utils.buildRegexData([ $R.tomorrow, $R.yesterday, [$R.past, $R.mon], [$R.past, $R.tue], [$R.past, $R.wed], [$R.past, $R.thu], [$R.past, $R.fri], [$R.past, $R.sat], [$R.past, $R.sun] ]); }, basicReplaceHash : function() { var $R = Date.CultureInfo.regexPatterns; return { "January": $R.jan.source, "February": $R.feb, "March": $R.mar, "April": $R.apr, "May": $R.may, "June": $R.jun, "July": $R.jul, "August": $R.aug, "September": $R.sep, "October": $R.oct, "November": $R.nov, "December": $R.dec, "": /\bat\b/gi, " ": /\s{2,}/, "am": $R.inTheMorning, "9am": $R.thisMorning, "pm": $R.inTheEvening, "7pm":$R.thisEvening }; }, keys : function(){ return [ utils.getDateNthString(true, false, 1), // tomorrow utils.getDateNthString(true, false, -1), // yesterday utils.getDateNthString(false, true, "monday"), //last mon utils.getDateNthString(false, true, "tuesday"), //last tues utils.getDateNthString(false, true, "wednesday"), //last wed utils.getDateNthString(false, true, "thursday"), //last thurs utils.getDateNthString(false, true, "friday"), //last fri utils.getDateNthString(false, true, "saturday"), //last sat utils.getDateNthString(false, true, "sunday") //last sun ]; }, buildRegexFunctions: function () { var $R = Date.CultureInfo.regexPatterns; var __ = Date.i18n.__; var tomorrowRE = new RegExp("(\\b\\d\\d?("+__("AM")+"|"+__("PM")+")? )("+$R.tomorrow.source.slice(1)+")", "i"); // adapted tomorrow regex for AM PM relative dates var todayRE = new RegExp($R.today.source + "(?!\\s*([+-]))\\b"); // today, but excludes the math operators (eg "today + 2h") this.replaceFuncs = [ [todayRE, function (full) { return (full.length > 1) ? Date.today().toString("d") : full; }], [tomorrowRE, function(full, m1) { var t = Date.today().addDays(1).toString("d"); return (t + " " + m1); }], [$R.amThisMorning, function(str, am){return am;}], [$R.pmThisEvening, function(str, pm){return pm;}] ]; }, buildReplaceData: function () { this.buildRegexFunctions(); this.replaceHash = utils.addToHash(this.basicReplaceHash(), this.keys(), this.regexData()); }, stringReplaceFuncs: function (s) { for (var i=0; i < this.replaceFuncs.length; i++) { s = s.replace(this.replaceFuncs[i][0], this.replaceFuncs[i][1]); } return s; }, parse: function (s) { s = this.stringReplaceFuncs(s); s = utils.multiReplace(s, this.replaceHash); try { var n = s.split(/([\s\-\.\,\/\x27]+)/); if (n.length === 3 && $P.Numeric.isNumeric(n[0]) && $P.Numeric.isNumeric(n[2]) && (n[2].length >= 4)) { // ok, so we're dealing with x/year. But that's not a full date. // This fixes wonky dateElementOrder parsing when set to dmy order. if (Date.CultureInfo.dateElementOrder[0] === "d") { s = "1/" + n[0] + "/" + n[2]; // set to 1st of month and normalize the seperator } } } catch (e) {} return s; } }; $P.Normalizer.buildReplaceData(); }()); (function () { var $P = Date.Parsing; var _ = $P.Operators = { // // Tokenizers // rtoken: function (r) { // regex token return function (s) { var mx = s.match(r); if (mx) { return ([ mx[0], s.substring(mx[0].length) ]); } else { throw new $P.Exception(s); } }; }, token: function () { // whitespace-eating token return function (s) { return _.rtoken(new RegExp("^\\s*" + s + "\\s*"))(s); }; }, stoken: function (s) { // string token return _.rtoken(new RegExp("^" + s)); }, // Atomic Operators until: function (p) { return function (s) { var qx = [], rx = null; while (s.length) { try { rx = p.call(this, s); } catch (e) { qx.push(rx[0]); s = rx[1]; continue; } break; } return [ qx, s ]; }; }, many: function (p) { return function (s) { var rx = [], r = null; while (s.length) { try { r = p.call(this, s); } catch (e) { return [ rx, s ]; } rx.push(r[0]); s = r[1]; } return [ rx, s ]; }; }, // generator operators -- see below optional: function (p) { return function (s) { var r = null; try { r = p.call(this, s); } catch (e) { return [ null, s ]; } return [ r[0], r[1] ]; }; }, not: function (p) { return function (s) { try { p.call(this, s); } catch (e) { return [null, s]; } throw new $P.Exception(s); }; }, ignore: function (p) { return p ? function (s) { var r = null; r = p.call(this, s); return [null, r[1]]; } : null; }, product: function () { var px = arguments[0], qx = Array.prototype.slice.call(arguments, 1), rx = []; for (var i = 0 ; i < px.length ; i++) { rx.push(_.each(px[i], qx)); } return rx; }, cache: function (rule) { var cache = {}, cache_length = 0, cache_keys = [], CACHE_MAX = Date.Config.CACHE_MAX || 100000, r = null; var cacheCheck = function () { if (cache_length === CACHE_MAX) { // kill several keys, don't want to have to do this all the time... for (var i=0; i < 10; i++) { var key = cache_keys.shift(); if (key) { delete cache[key]; cache_length--; } } } }; return function (s) { cacheCheck(); try { r = cache[s] = (cache[s] || rule.call(this, s)); } catch (e) { r = cache[s] = e; } cache_length++; cache_keys.push(s); if (r instanceof $P.Exception) { throw r; } else { return r; } }; }, // vector operators -- see below any: function () { var px = arguments; return function (s) { var r = null; for (var i = 0; i < px.length; i++) { if (px[i] == null) { continue; } try { r = (px[i].call(this, s)); } catch (e) { r = null; } if (r) { return r; } } throw new $P.Exception(s); }; }, each: function () { var px = arguments; return function (s) { var rx = [], r = null; for (var i = 0; i < px.length ; i++) { if (px[i] == null) { continue; } try { r = (px[i].call(this, s)); } catch (e) { throw new $P.Exception(s); } rx.push(r[0]); s = r[1]; } return [ rx, s]; }; }, all: function () { var px = arguments, _ = _; return _.each(_.optional(px)); }, // delimited operators sequence: function (px, d, c) { d = d || _.rtoken(/^\s*/); c = c || null; if (px.length === 1) { return px[0]; } return function (s) { var r = null, q = null; var rx = []; for (var i = 0; i < px.length ; i++) { try { r = px[i].call(this, s); } catch (e) { break; } rx.push(r[0]); try { q = d.call(this, r[1]); } catch (ex) { q = null; break; } s = q[1]; } if (!r) { throw new $P.Exception(s); } if (q) { throw new $P.Exception(q[1]); } if (c) { try { r = c.call(this, r[1]); } catch (ey) { throw new $P.Exception(r[1]); } } return [ rx, (r?r[1]:s) ]; }; }, // // Composite Operators // between: function (d1, p, d2) { d2 = d2 || d1; var _fn = _.each(_.ignore(d1), p, _.ignore(d2)); return function (s) { var rx = _fn.call(this, s); return [[rx[0][0], r[0][2]], rx[1]]; }; }, list: function (p, d, c) { d = d || _.rtoken(/^\s*/); c = c || null; return (p instanceof Array ? _.each(_.product(p.slice(0, -1), _.ignore(d)), p.slice(-1), _.ignore(c)) : _.each(_.many(_.each(p, _.ignore(d))), px, _.ignore(c))); }, set: function (px, d, c) { d = d || _.rtoken(/^\s*/); c = c || null; return function (s) { // r is the current match, best the current 'best' match // which means it parsed the most amount of input var r = null, p = null, q = null, rx = null, best = [[], s], last = false; // go through the rules in the given set for (var i = 0; i < px.length ; i++) { // last is a flag indicating whether this must be the last element // if there is only 1 element, then it MUST be the last one q = null; p = null; r = null; last = (px.length === 1); // first, we try simply to match the current pattern // if not, try the next pattern try { r = px[i].call(this, s); } catch (e) { continue; } // since we are matching against a set of elements, the first // thing to do is to add r[0] to matched elements rx = [[r[0]], r[1]]; // if we matched and there is still input to parse and // we don't already know this is the last element, // we're going to next check for the delimiter ... // if there's none, or if there's no input left to parse // than this must be the last element after all ... if (r[1].length > 0 && ! last) { try { q = d.call(this, r[1]); } catch (ex) { last = true; } } else { last = true; } // if we parsed the delimiter and now there's no more input, // that means we shouldn't have parsed the delimiter at all // so don't update r and mark this as the last element ... if (!last && q[1].length === 0) { last = true; } // so, if this isn't the last element, we're going to see if // we can get any more matches from the remaining (unmatched) // elements ... if (!last) { // build a list of the remaining rules we can match against, // i.e., all but the one we just matched against var qx = []; for (var j = 0; j < px.length ; j++) { if (i !== j) { qx.push(px[j]); } } // now invoke recursively set with the remaining input // note that we don't include the closing delimiter ... // we'll check for that ourselves at the end p = _.set(qx, d).call(this, q[1]); // if we got a non-empty set as a result ... // (otw rx already contains everything we want to match) if (p[0].length > 0) { // update current result, which is stored in rx ... // basically, pick up the remaining text from p[1] // and concat the result from p[0] so that we don't // get endless nesting ... rx[0] = rx[0].concat(p[0]); rx[1] = p[1]; } } // at this point, rx either contains the last matched element // or the entire matched set that starts with this element. // now we just check to see if this variation is better than // our best so far, in terms of how much of the input is parsed if (rx[1].length < best[1].length) { best = rx; } // if we've parsed all the input, then we're finished if (best[1].length === 0) { break; } } // so now we've either gone through all the patterns trying them // as the initial match; or we found one that parsed the entire // input string ... // if best has no matches, just return empty set ... if (best[0].length === 0) { return best; } // if a closing delimiter is provided, then we have to check it also if (c) { // we try this even if there is no remaining input because the pattern // may well be optional or match empty input ... try { q = c.call(this, best[1]); } catch (ey) { throw new $P.Exception(best[1]); } // it parsed ... be sure to update the best match remaining input best[1] = q[1]; } // if we're here, either there was no closing delimiter or we parsed it // so now we have the best match; just return it! return best; }; }, forward: function (gr, fname) { return function (s) { return gr[fname].call(this, s); }; }, // // Translation Operators // replace: function (rule, repl) { return function (s) { var r = rule.call(this, s); return [repl, r[1]]; }; }, process: function (rule, fn) { return function (s) { var r = rule.call(this, s); return [fn.call(this, r[0]), r[1]]; }; }, min: function (min, rule) { return function (s) { var rx = rule.call(this, s); if (rx[0].length < min) { throw new $P.Exception(s); } return rx; }; } }; // Generator Operators And Vector Operators // Generators are operators that have a signature of F(R) => R, // taking a given rule and returning another rule, such as // ignore, which parses a given rule and throws away the result. // Vector operators are those that have a signature of F(R1,R2,...) => R, // take a list of rules and returning a new rule, such as each. // Generator operators are converted (via the following _generator // function) into functions that can also take a list or array of rules // and return an array of new rules as though the function had been // called on each rule in turn (which is what actually happens). // This allows generators to be used with vector operators more easily. // Example: // each(ignore(foo, bar)) instead of each(ignore(foo), ignore(bar)) // This also turns generators into vector operators, which allows // constructs like: // not(cache(foo, bar)) var _generator = function (op) { function gen() { var args = null, rx = [], px, i; if (arguments.length > 1) { args = Array.prototype.slice.call(arguments); } else if (arguments[0] instanceof Array) { args = arguments[0]; } if (args) { px = args.shift(); if (px.length > 0) { args.unshift(px[i]); rx.push(op.apply(null, args)); args.shift(); return rx; } } else { return op.apply(null, arguments); } } return gen; }; var gx = "optional not ignore cache".split(/\s/); for (var i = 0 ; i < gx.length ; i++) { _[gx[i]] = _generator(_[gx[i]]); } var _vector = function (op) { return function () { if (arguments[0] instanceof Array) { return op.apply(null, arguments[0]); } else { return op.apply(null, arguments); } }; }; var vx = "each any all".split(/\s/); for (var j = 0 ; j < vx.length ; j++) { _[vx[j]] = _vector(_[vx[j]]); } }()); (function () { var $D = Date; var flattenAndCompact = function (ax) { var rx = []; for (var i = 0; i < ax.length; i++) { if (ax[i] instanceof Array) { rx = rx.concat(flattenAndCompact(ax[i])); } else { if (ax[i]) { rx.push(ax[i]); } } } return rx; }; var parseMeridian = function () { if (this.meridian && (this.hour || this.hour === 0)) { if (this.meridian === "a" && this.hour > 11 && Date.Config.strict24hr){ throw "Invalid hour and meridian combination"; } else if (this.meridian === "p" && this.hour < 12 && Date.Config.strict24hr){ throw "Invalid hour and meridian combination"; } else if (this.meridian === "p" && this.hour < 12) { this.hour = this.hour + 12; } else if (this.meridian === "a" && this.hour === 12) { this.hour = 0; } } }; var setDefaults = function () { var now = new Date(); if ((this.hour || this.minute) && (!this.month && !this.year && !this.day)) { this.day = now.getDate(); } if (!this.year) { this.year = now.getFullYear(); } if (!this.month && this.month !== 0) { this.month = now.getMonth(); } if (!this.day) { this.day = 1; } if (!this.hour) { this.hour = 0; } if (!this.minute) { this.minute = 0; } if (!this.second) { this.second = 0; } if (!this.millisecond) { this.millisecond = 0; } }; var finishUtils = { getToday: function () { if (this.now || "hour minute second".indexOf(this.unit) !== -1) { return new Date(); } else { return $D.today(); } }, setDaysFromWeekday: function (today, orient){ var gap; orient = orient || 1; this.unit = "day"; gap = ($D.getDayNumberFromName(this.weekday) - today.getDay()); this.days = gap ? ((gap + (orient * 7)) % 7) : (orient * 7); return this; }, setMonthsFromMonth: function (today, orient) { var gap; orient = orient || 1; this.unit = "month"; gap = (this.month - today.getMonth()); this.months = gap ? ((gap + (orient * 12)) % 12) : (orient * 12); this.month = null; return this; }, setDMYFromWeekday: function () { var d = Date[this.weekday](); this.day = d.getDate(); if (!this.month) { this.month = d.getMonth(); } this.year = d.getFullYear(); return this; }, setUnitValue: function (orient) { if (!this.value && this.operator && this.operator !== null && this[this.unit + "s"] && this[this.unit + "s"] !== null) { this[this.unit + "s"] = this[this.unit + "s"] + ((this.operator === "add") ? 1 : -1) + (this.value||0) * orient; } else if (this[this.unit + "s"] == null || this.operator != null) { if (!this.value) { this.value = 1; } this[this.unit + "s"] = this.value * orient; } }, generateDateFromWeeks: function () { var weekday = (this.weekday !== undefined) ? this.weekday : "today"; var d = Date[weekday]().addWeeks(this.weeks); if (this.now) { d.setTimeToNow(); } return d; } }; $D.Translator = { hour: function (s) { return function () { this.hour = Number(s); }; }, minute: function (s) { return function () { this.minute = Number(s); }; }, second: function (s) { return function () { this.second = Number(s); }; }, /* for ss.s format */ secondAndMillisecond: function (s) { return function () { var mx = s.match(/^([0-5][0-9])\.([0-9]{1,3})/); this.second = Number(mx[1]); this.millisecond = Number(mx[2]); }; }, meridian: function (s) { return function () { this.meridian = s.slice(0, 1).toLowerCase(); }; }, timezone: function (s) { return function () { var n = s.replace(/[^\d\+\-]/g, ""); if (n.length) { this.timezoneOffset = Number(n); } else { this.timezone = s.toLowerCase(); } }; }, day: function (x) { var s = x[0]; return function () { this.day = Number(s.match(/\d+/)[0]); if (this.day < 1) { throw "invalid day"; } }; }, month: function (s) { return function () { this.month = (s.length === 3) ? "jan feb mar apr may jun jul aug sep oct nov dec".indexOf(s)/4 : Number(s) - 1; if (this.month < 0) { throw "invalid month"; } }; }, year: function (s) { return function () { var n = Number(s); this.year = ((s.length > 2) ? n : (n + (((n + 2000) < Date.CultureInfo.twoDigitYearMax) ? 2000 : 1900))); }; }, rday: function (s) { return function () { switch (s) { case "yesterday": this.days = -1; break; case "tomorrow": this.days = 1; break; case "today": this.days = 0; break; case "now": this.days = 0; this.now = true; break; } }; }, finishExact: function (x) { var d; x = (x instanceof Array) ? x : [x]; for (var i = 0 ; i < x.length ; i++) { if (x[i]) { x[i].call(this); } } setDefaults.call(this); parseMeridian.call(this); if (this.day > $D.getDaysInMonth(this.year, this.month)) { throw new RangeError(this.day + " is not a valid value for days."); } d = new Date(this.year, this.month, this.day, this.hour, this.minute, this.second, this.millisecond); if (this.year < 100) { d.setFullYear(this.year); // means years less that 100 are process correctly. JS will parse it otherwise as 1900-1999. } if (this.timezone) { d.set({ timezone: this.timezone }); } else if (this.timezoneOffset) { d.set({ timezoneOffset: this.timezoneOffset }); } return d; }, finish: function (x) { var today, expression, orient, temp; x = (x instanceof Array) ? flattenAndCompact(x) : [ x ]; if (x.length === 0) { return null; } for (var i = 0 ; i < x.length ; i++) { if (typeof x[i] === "function") { x[i].call(this); } } if (this.now && !this.unit && !this.operator) { return new Date(); } else { today = finishUtils.getToday.call(this); } expression = !!(this.days && this.days !== null || this.orient || this.operator); orient = ((this.orient === "past" || this.operator === "subtract") ? -1 : 1); if (this.month && this.unit === "week") { this.value = this.month + 1; delete this.month; delete this.day; } if ((this.month || this.month === 0) && "year day hour minute second".indexOf(this.unit) !== -1) { if (!this.value) { this.value = this.month + 1; } this.month = null; expression = true; } if (!expression && this.weekday && !this.day && !this.days) { finishUtils.setDMYFromWeekday.call(this); } if (expression && this.weekday && this.unit !== "month" && this.unit !== "week") { finishUtils.setDaysFromWeekday.call(this, today, orient); } if (this.weekday && this.unit !== "week" && !this.day && !this.days) { temp = Date[this.weekday](); this.day = temp.getDate(); if (temp.getMonth() !== today.getMonth()) { this.month = temp.getMonth(); } } if (this.month && this.unit === "day" && this.operator) { if (!this.value) { this.value = (this.month + 1); } this.month = null; } if (this.value != null && this.month != null && this.year != null) { this.day = this.value * 1; } if (this.month && !this.day && this.value) { today.set({ day: this.value * 1 }); if (!expression) { this.day = this.value * 1; } } if (!this.month && this.value && this.unit === "month" && !this.now) { this.month = this.value; expression = true; } if (expression && (this.month || this.month === 0) && this.unit !== "year") { finishUtils.setMonthsFromMonth.call(this, today, orient); } if (!this.unit) { this.unit = "day"; } finishUtils.setUnitValue.call(this, orient); parseMeridian.call(this); if ((this.month || this.month === 0) && !this.day) { this.day = 1; } if (!this.orient && !this.operator && this.unit === "week" && this.value && !this.day && !this.month) { return Date.today().setWeek(this.value); } if (this.unit === "week" && this.weeks && !this.day && !this.month) { return finishUtils.generateDateFromWeeks.call(this); } if (expression && this.timezone && this.day && this.days) { this.day = this.days; } if (expression){ today.add(this); } else { today.set(this); } if (this.timezone) { this.timezone = this.timezone.toUpperCase(); var offset = $D.getTimezoneOffset(this.timezone); var timezone; if (today.hasDaylightSavingTime()) { // lets check that we're being sane with timezone setting timezone = $D.getTimezoneAbbreviation(offset, today.isDaylightSavingTime()); if (timezone !== this.timezone) { // bugger, we're in a place where things like EST vs EDT matters. if (today.isDaylightSavingTime()) { today.addHours(-1); } else { today.addHours(1); } } } today.setTimezoneOffset(offset); } return today; } }; }()); (function () { var $D = Date; $D.Grammar = {}; var _ = $D.Parsing.Operators, g = $D.Grammar, t = $D.Translator, _fn; // Allow rolling up into general purpose rules _fn = function () { return _.each(_.any.apply(null, arguments), _.not(g.ctoken2("timeContext"))); }; g.datePartDelimiter = _.rtoken(/^([\s\-\.\,\/\x27]+)/); g.timePartDelimiter = _.stoken(":"); g.whiteSpace = _.rtoken(/^\s*/); g.generalDelimiter = _.rtoken(/^(([\s\,]|at|@|on)+)/); var _C = {}; g.ctoken = function (keys) { var fn = _C[keys]; if (! fn) { var c = Date.CultureInfo.regexPatterns; var kx = keys.split(/\s+/), px = []; for (var i = 0; i < kx.length ; i++) { px.push(_.replace(_.rtoken(c[kx[i]]), kx[i])); } fn = _C[keys] = _.any.apply(null, px); } return fn; }; g.ctoken2 = function (key) { return _.rtoken(Date.CultureInfo.regexPatterns[key]); }; var cacheProcessRtoken = function (key, token, type, eachToken) { if (eachToken) { g[key] = _.cache(_.process(_.each(_.rtoken(token),_.optional(g.ctoken2(eachToken))), type)); } else { g[key] = _.cache(_.process(_.rtoken(token), type)); } }; var cacheProcessCtoken = function (token, type) { return _.cache(_.process(g.ctoken2(token), type)); }; var _F = {}; //function cache var _get = function (f) { _F[f] = (_F[f] || g.format(f)[0]); return _F[f]; }; g.allformats = function (fx) { var rx = []; if (fx instanceof Array) { for (var i = 0; i < fx.length; i++) { rx.push(_get(fx[i])); } } else { rx.push(_get(fx)); } return rx; }; g.formats = function (fx) { if (fx instanceof Array) { var rx = []; for (var i = 0 ; i < fx.length ; i++) { rx.push(_get(fx[i])); } return _.any.apply(null, rx); } else { return _get(fx); } }; var grammarFormats = { timeFormats: function(){ var i, RTokenKeys = [ "h", "hh", "H", "HH", "m", "mm", "s", "ss", "ss.s", "z", "zz" ], RToken = [ /^(0[0-9]|1[0-2]|[1-9])/, /^(0[0-9]|1[0-2])/, /^([0-1][0-9]|2[0-3]|[0-9])/, /^([0-1][0-9]|2[0-3])/, /^([0-5][0-9]|[0-9])/, /^[0-5][0-9]/, /^([0-5][0-9]|[0-9])/, /^[0-5][0-9]/, /^[0-5][0-9]\.[0-9]{1,3}/, /^((\+|\-)\s*\d\d\d\d)|((\+|\-)\d\d\:?\d\d)/, /^((\+|\-)\s*\d\d\d\d)|((\+|\-)\d\d\:?\d\d)/ ], tokens = [ t.hour, t.hour, t.hour, t.hour, t.minute, t.minute, t.second, t.second, t.secondAndMillisecond, t.timezone, t.timezone ]; for (i=0; i < RTokenKeys.length; i++) { cacheProcessRtoken(RTokenKeys[i], RToken[i], tokens[i]); } g.hms = _.cache(_.sequence([g.H, g.m, g.s], g.timePartDelimiter)); g.t = cacheProcessCtoken("shortMeridian", t.meridian); g.tt = cacheProcessCtoken("longMeridian", t.meridian); g.zzz = cacheProcessCtoken("timezone", t.timezone); g.timeSuffix = _.each(_.ignore(g.whiteSpace), _.set([ g.tt, g.zzz ])); g.time = _.each(_.optional(_.ignore(_.stoken("T"))), g.hms, g.timeSuffix); }, dateFormats: function () { // pre-loaded rules for different date part order preferences var _setfn = function () { return _.set(arguments, g.datePartDelimiter); }; var i, RTokenKeys = [ "d", "dd", "M", "MM", "y", "yy", "yyy", "yyyy" ], RToken = [ /^([0-2]\d|3[0-1]|\d)/, /^([0-2]\d|3[0-1])/, /^(1[0-2]|0\d|\d)/, /^(1[0-2]|0\d)/, /^(\d+)/, /^(\d\d)/, /^(\d\d?\d?\d?)/, /^(\d\d\d\d)/ ], tokens = [ t.day, t.day, t.month, t.month, t.year, t.year, t.year, t.year ], eachToken = [ "ordinalSuffix", "ordinalSuffix" ]; for (i=0; i < RTokenKeys.length; i++) { cacheProcessRtoken(RTokenKeys[i], RToken[i], tokens[i], eachToken[i]); } g.MMM = g.MMMM = _.cache(_.process(g.ctoken("jan feb mar apr may jun jul aug sep oct nov dec"), t.month)); g.ddd = g.dddd = _.cache(_.process(g.ctoken("sun mon tue wed thu fri sat"), function (s) { return function () { this.weekday = s; }; } )); g.day = _fn(g.d, g.dd); g.month = _fn(g.M, g.MMM); g.year = _fn(g.yyyy, g.yy); g.mdy = _setfn(g.ddd, g.month, g.day, g.year); g.ymd = _setfn(g.ddd, g.year, g.month, g.day); g.dmy = _setfn(g.ddd, g.day, g.month, g.year); g.date = function (s) { return ((g[Date.CultureInfo.dateElementOrder] || g.mdy).call(this, s)); }; }, relative: function () { // relative date / time expressions g.orientation = _.process(g.ctoken("past future"), function (s) { return function () { this.orient = s; }; } ); g.operator = _.process(g.ctoken("add subtract"), function (s) { return function () { this.operator = s; }; } ); g.rday = _.process(g.ctoken("yesterday tomorrow today now"), t.rday); g.unit = _.process(g.ctoken("second minute hour day week month year"), function (s) { return function () { this.unit = s; }; } ); } }; g.buildGrammarFormats = function () { // these need to be rebuilt every time the language changes. _C = {}; grammarFormats.timeFormats(); grammarFormats.dateFormats(); grammarFormats.relative(); g.value = _.process(_.rtoken(/^([-+]?\d+)?(st|nd|rd|th)?/), function (s) { return function () { this.value = s.replace(/\D/g, ""); }; } ); g.expression = _.set([g.rday, g.operator, g.value, g.unit, g.orientation, g.ddd, g.MMM ]); g.format = _.process(_.many( _.any( // translate format specifiers into grammar rules _.process( _.rtoken(/^(dd?d?d?(?!e)|MM?M?M?|yy?y?y?|hh?|HH?|mm?|ss?|tt?|zz?z?)/), function (fmt) { if (g[fmt]) { return g[fmt]; } else { throw $D.Parsing.Exception(fmt); } } ), // translate separator tokens into token rules _.process(_.rtoken(/^[^dMyhHmstz]+/), // all legal separators function (s) { return _.ignore(_.stoken(s)); } ) ) ), // construct the parser ... function (rules) { return _.process(_.each.apply(null, rules), t.finishExact); } ); // starting rule for general purpose grammar g._start = _.process(_.set([ g.date, g.time, g.expression ], g.generalDelimiter, g.whiteSpace), t.finish); }; g.buildGrammarFormats(); // parsing date format specifiers - ex: "h:m:s tt" // this little guy will generate a custom parser based // on the format string, ex: g.format("h:m:s tt") // check for these formats first g._formats = g.formats([ "\"yyyy-MM-ddTHH:mm:ssZ\"", "yyyy-MM-ddTHH:mm:ss.sz", "yyyy-MM-ddTHH:mm:ssZ", "yyyy-MM-ddTHH:mm:ssz", "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-ddTHH:mmZ", "yyyy-MM-ddTHH:mmz", "yyyy-MM-ddTHH:mm", "ddd, MMM dd, yyyy H:mm:ss tt", "ddd MMM d yyyy HH:mm:ss zzz", "MMddyyyy", "ddMMyyyy", "Mddyyyy", "ddMyyyy", "Mdyyyy", "dMyyyy", "yyyy", "Mdyy", "dMyy", "d" ]); // real starting rule: tries selected formats first, // then general purpose rule g.start = function (s) { try { var r = g._formats.call({}, s); if (r[1].length === 0) { return r; } } catch (e) {} return g._start.call({}, s); }; }()); (function () { var $D = Date; /** * @desc Converts the specified string value into its JavaScript Date equivalent using CultureInfo specific format information. * * Example

	///////////
	// Dates //
	///////////

	// 15-Oct-2004
	var d1 = Date.parse("10/15/2004");

	// 15-Oct-2004
	var d1 = Date.parse("15-Oct-2004");

	// 15-Oct-2004
	var d1 = Date.parse("2004.10.15");

	//Fri Oct 15, 2004
	var d1 = Date.parse("Fri Oct 15, 2004");

	///////////
	// Times //
	///////////

	// Today at 10 PM.
	var d1 = Date.parse("10 PM");

	// Today at 10:30 PM.
	var d1 = Date.parse("10:30 P.M.");

	// Today at 6 AM.
	var d1 = Date.parse("06am");

	/////////////////////
	// Dates and Times //
	/////////////////////

	// 8-July-2004 @ 10:30 PM
	var d1 = Date.parse("July 8th, 2004, 10:30 PM");

	// 1-July-2004 @ 10:30 PM
	var d1 = Date.parse("2004-07-01T22:30:00");

	////////////////////
	// Relative Dates //
	////////////////////

	// Returns today's date. The string "today" is culture specific.
	var d1 = Date.parse("today");

	// Returns yesterday's date. The string "yesterday" is culture specific.
	var d1 = Date.parse("yesterday");

	// Returns the date of the next thursday.
	var d1 = Date.parse("Next thursday");

	// Returns the date of the most previous monday.
	var d1 = Date.parse("last monday");

	// Returns today's day + one year.
	var d1 = Date.parse("next year");

	///////////////
	// Date Math //
	///////////////

	// Today + 2 days
	var d1 = Date.parse("t+2");

	// Today + 2 days
	var d1 = Date.parse("today + 2 days");

	// Today + 3 months
	var d1 = Date.parse("t+3m");

	// Today - 1 year
	var d1 = Date.parse("today - 1 year");

	// Today - 1 year
	var d1 = Date.parse("t-1y"); 


	/////////////////////////////
	// Partial Dates and Times //
	/////////////////////////////

	// July 15th of this year.
	var d1 = Date.parse("July 15");

	// 15th day of current day and year.
	var d1 = Date.parse("15");

	// July 1st of current year at 10pm.
	var d1 = Date.parse("7/1 10pm");
	
* * @param {String} The string value to convert into a Date object [Required] * @return {Date} A Date object or null if the string cannot be converted into a Date. */ var parseUtils = { removeOrds: function (s) { ords = s.match(/\b(\d+)(?:st|nd|rd|th)\b/); // find ordinal matches s = ((ords && ords.length === 2) ? s.replace(ords[0], ords[1]) : s); return s; }, grammarParser: function (s) { var r = null; try { r = $D.Grammar.start.call({}, s.replace(/^\s*(\S*(\s+\S+)*)\s*$/, "$1")); } catch (e) { return null; } return ((r[1].length === 0) ? r[0] : null); }, nativeFallback: function(s) { var t; try { // ok we haven't parsed it, last ditch attempt with the built-in parser. t = Date._parse(s); return (t || t === 0) ? new Date(t) : null; } catch (e) { return null; } } }; function parse (s) { var d; if (!s) { return null; } if (s instanceof Date) { return s.clone(); } if (s.length >= 4 && s.charAt(0) !== "0" && s.charAt(0) !== "+"&& s.charAt(0) !== "-") { // ie: 2004 will pass, 0800 won't. // Start with specific formats d = $D.Parsing.ISO.parse(s) || $D.Parsing.Numeric.parse(s); } if (d instanceof Date && !isNaN(d.getTime())) { return d; } else { // find ordinal dates (1st, 3rd, 8th, etc and remove them as they cause parsing issues) s = $D.Parsing.Normalizer.parse(parseUtils.removeOrds(s)); d = parseUtils.grammarParser(s); if (d !== null) { return d; } else { return parseUtils.nativeFallback(s); } } } if (!$D._parse) { $D._parse = $D.parse; } $D.parse = parse; Date.getParseFunction = function (fx) { var fns = Date.Grammar.allformats(fx); return function (s) { var r = null; for (var i = 0; i < fns.length; i++) { try { r = fns[i].call({}, s); } catch (e) { continue; } if (r[1].length === 0) { return r[0]; } } return null; }; }; /** * Converts the specified string value into its JavaScript Date equivalent using the specified format {String} or formats {Array} and the CultureInfo specific format information. * The format of the string value must match one of the supplied formats exactly. * * Example

	// 15-Oct-2004
	var d1 = Date.parseExact("10/15/2004", "M/d/yyyy");

	// 15-Oct-2004
	var d1 = Date.parse("15-Oct-2004", "M-ddd-yyyy");

	// 15-Oct-2004
	var d1 = Date.parse("2004.10.15", "yyyy.MM.dd");

	// Multiple formats
	var d1 = Date.parseExact("10/15/2004", ["M/d/yyyy", "MMMM d, yyyy"]);
	
* * @param {String} The string value to convert into a Date object [Required]. * @param {Object} The expected format {String} or an array of expected formats {Array} of the date string [Required]. * @return {Date} A Date object or null if the string cannot be converted into a Date. */ $D.parseExact = function (s, fx) { return $D.getParseFunction(fx)(s); }; }()); (function () { var $D = Date, $P = $D.prototype, // $C = $D.CultureInfo, // not used atm p = function (s, l) { if (!l) { l = 2; } return ("000" + s).slice(l * -1); }; /** * Converts a PHP format string to Java/.NET format string. * A PHP format string can be used with ._format or .format. * A Java/.NET format string can be used with .toString(). * The .parseExact function will only accept a Java/.NET format string * * Example * var f1 = "%m/%d/%y" * var f2 = Date.normalizeFormat(f1); // "MM/dd/yy" * * new Date().format(f1); // "04/13/08" * new Date()._format(f1); // "04/13/08" * new Date().toString(f2); // "04/13/08" * * var date = Date.parseExact("04/13/08", f2); // Sun Apr 13 2008 * * @param {String} A PHP format string consisting of one or more format spcifiers. * @return {String} The PHP format converted to a Java/.NET format string. */ var normalizerSubstitutions = { "d" : "dd", "%d": "dd", "D" : "ddd", "%a": "ddd", "j" : "dddd", "l" : "dddd", "%A": "dddd", "S" : "S", "F" : "MMMM", "%B": "MMMM", "m" : "MM", "%m": "MM", "M" : "MMM", "%b": "MMM", "%h": "MMM", "n" : "M", "Y" : "yyyy", "%Y": "yyyy", "y" : "yy", "%y": "yy", "g" : "h", "%I": "h", "G" : "H", "h" : "hh", "H" : "HH", "%H": "HH", "i" : "mm", "%M": "mm", "s" : "ss", "%S": "ss", "%r": "hh:mm tt", "%R": "H:mm", "%T": "H:mm:ss", "%X": "t", "%x": "d", "%e": "d", "%D": "MM/dd/yy", "%n": "\\n", "%t": "\\t", "e" : "z", "T" : "z", "%z": "z", "%Z": "z", "Z" : "ZZ", "N" : "u", "w" : "u", "%w": "u", "W" : "W", "%V": "W" }; var normalizer = { substitutes: function (m) { return normalizerSubstitutions[m]; }, interpreted: function (m, x) { var y; switch (m) { case "%u": return x.getDay() + 1; case "z": return x.getOrdinalNumber(); case "%j": return p(x.getOrdinalNumber(), 3); case "%U": var d1 = x.clone().set({month: 0, day: 1}).addDays(-1).moveToDayOfWeek(0), d2 = x.clone().addDays(1).moveToDayOfWeek(0, -1); return (d2 < d1) ? "00" : p((d2.getOrdinalNumber() - d1.getOrdinalNumber()) / 7 + 1); case "%W": return p(x.getWeek()); case "t": return $D.getDaysInMonth(x.getFullYear(), x.getMonth()); case "o": case "%G": return x.setWeek(x.getISOWeek()).toString("yyyy"); case "%g": return x._format("%G").slice(-2); case "a": case "%p": return t("tt").toLowerCase(); case "A": return t("tt").toUpperCase(); case "u": return p(x.getMilliseconds(), 3); case "I": return (x.isDaylightSavingTime()) ? 1 : 0; case "O": return x.getUTCOffset(); case "P": y = x.getUTCOffset(); return y.substring(0, y.length - 2) + ":" + y.substring(y.length - 2); case "B": var now = new Date(); return Math.floor(((now.getHours() * 3600) + (now.getMinutes() * 60) + now.getSeconds() + (now.getTimezoneOffset() + 60) * 60) / 86.4); case "c": return x.toISOString().replace(/\"/g, ""); case "U": return $D.strtotime("now"); case "%c": return t("d") + " " + t("t"); case "%C": return Math.floor(x.getFullYear() / 100 + 1); } }, shouldOverrideDefaults: function (m) { switch (m) { case "%e": return true; default: return false; } }, parse: function (m, context) { var formatString, c = context || new Date(); formatString = normalizer.substitutes(m); if (formatString) { return formatString; } formatString = normalizer.interpreted(m, c); if (formatString) { return formatString; } else { return m; } } }; $D.normalizeFormat = function (format, context) { return format.replace(/(%|\\)?.|%%/g, function(t){ return normalizer.parse(t, context); }); }; /** * Format a local Unix timestamp according to locale settings * * Example: * Date.strftime("%m/%d/%y", new Date()); // "04/13/08" * Date.strftime("c", "2008-04-13T17:52:03Z"); // "04/13/08" * * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @param {Number|String} The number representing the number of seconds that have elapsed since January 1, 1970 (local time). * @return {String} A string representation of the current Date object. */ $D.strftime = function (format, time) { var d = Date.parse(time); return d._format(format); }; /** * Parse any textual datetime description into a Unix timestamp. * A Unix timestamp is the number of seconds that have elapsed since January 1, 1970 (midnight UTC/GMT). * * Example: * Date.strtotime("04/13/08"); // 1208044800 * Date.strtotime("1970-01-01T00:00:00Z"); // 0 * * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @param {Object} A string or date object. * @return {String} A string representation of the current Date object. */ $D.strtotime = function (time) { var d = $D.parse(time); return Math.round($D.UTC(d.getUTCFullYear(), d.getUTCMonth(), d.getUTCDate(), d.getUTCHours(), d.getUTCMinutes(), d.getUTCSeconds(), d.getUTCMilliseconds()) / 1000); }; /** * Converts the value of the current Date object to its equivalent string representation using a PHP/Unix style of date format specifiers. * Format Specifiers * Format Description Example * ------ --------------------------------------------------------------------------- ----------------------- * %a abbreviated weekday name according to the current localed "Mon" through "Sun" * %A full weekday name according to the current localed "Sunday" through "Saturday" * %b abbreviated month name according to the current localed "Jan" through "Dec" * %B full month name according to the current locale "January" through "December" * %c preferred date and time representation for the current locale "4/13/2008 12:33 PM" * %C century number (the year divided by 100 and truncated to an integer) "00" to "99" * %d day of the month as a decimal number "01" to "31" * %D same as %m/%d/%y "04/13/08" * %e day of the month as a decimal number, a single digit is preceded by a space "1" to "31" * %g like %G, but without the century "08" * %G The 4-digit year corresponding to the ISO week number (see %V). "2008" * This has the same format and value as %Y, except that if the ISO week number * belongs to the previous or next year, that year is used instead. * %h same as %b "Jan" through "Dec" * %H hour as a decimal number using a 24-hour clock. "00" to "23" * %I hour as a decimal number using a 12-hour clock. "01" to "12" * %j day of the year as a decimal number. "001" to "366" * %m month as a decimal number. "01" to "12" * %M minute as a decimal number. "00" to "59" * %n newline character "\n" * %p either "am" or "pm" according to the given time value, or the "am" or "pm" * corresponding strings for the current locale. * %r time in a.m. and p.m. notation "8:44 PM" * %R time in 24 hour notation "20:44" * %S second as a decimal number "00" to "59" * %t tab character "\t" * %T current time, equal to %H:%M:%S "12:49:11" * %u weekday as a decimal number ["1", "7"], with "1" representing Monday "1" to "7" * %U week number of the current year as a decimal number, starting with the "0" to ("52" or "53") * first Sunday as the first day of the first week * %V The ISO 8601:1988 week number of the current year as a decimal number, "00" to ("52" or "53") * range 01 to 53, where week 1 is the first week that has at least 4 days * in the current year, and with Monday as the first day of the week. * (Use %G or %g for the year component that corresponds to the week number * for the specified timestamp.) * %W week number of the current year as a decimal number, starting with the "00" to ("52" or "53") * first Monday as the first day of the first week * %w day of the week as a decimal, Sunday being "0" "0" to "6" * %x preferred date representation for the current locale without the time "4/13/2008" * %X preferred time representation for the current locale without the date "12:53:05" * %y year as a decimal number without a century "00" "99" * %Y year as a decimal number including the century "2008" * %Z time zone or name or abbreviation "UTC", "EST", "PST" * %z same as %Z * %% a literal "%" characters "%" * d Day of the month, 2 digits with leading zeros "01" to "31" * D A textual representation of a day, three letters "Mon" through "Sun" * j Day of the month without leading zeros "1" to "31" * l A full textual representation of the day of the week (lowercase "L") "Sunday" through "Saturday" * N ISO-8601 numeric representation of the day of the week (added in PHP 5.1.0) "1" (for Monday) through "7" (for Sunday) * S English ordinal suffix for the day of the month, 2 characters "st", "nd", "rd" or "th". Works well with j * w Numeric representation of the day of the week "0" (for Sunday) through "6" (for Saturday) * z The day of the year (starting from "0") "0" through "365" * W ISO-8601 week number of year, weeks starting on Monday "00" to ("52" or "53") * F A full textual representation of a month, such as January or March "January" through "December" * m Numeric representation of a month, with leading zeros "01" through "12" * M A short textual representation of a month, three letters "Jan" through "Dec" * n Numeric representation of a month, without leading zeros "1" through "12" * t Number of days in the given month "28" through "31" * L Whether it's a leap year "1" if it is a leap year, "0" otherwise * o ISO-8601 year number. This has the same value as Y, except that if the "2008" * ISO week number (W) belongs to the previous or next year, that year * is used instead. * Y A full numeric representation of a year, 4 digits "2008" * y A two digit representation of a year "08" * a Lowercase Ante meridiem and Post meridiem "am" or "pm" * A Uppercase Ante meridiem and Post meridiem "AM" or "PM" * B Swatch Internet time "000" through "999" * g 12-hour format of an hour without leading zeros "1" through "12" * G 24-hour format of an hour without leading zeros "0" through "23" * h 12-hour format of an hour with leading zeros "01" through "12" * H 24-hour format of an hour with leading zeros "00" through "23" * i Minutes with leading zeros "00" to "59" * s Seconds, with leading zeros "00" through "59" * u Milliseconds "54321" * e Timezone identifier "UTC", "EST", "PST" * I Whether or not the date is in daylight saving time (uppercase i) "1" if Daylight Saving Time, "0" otherwise * O Difference to Greenwich time (GMT) in hours "+0200", "-0600" * P Difference to Greenwich time (GMT) with colon between hours and minutes "+02:00", "-06:00" * T Timezone abbreviation "UTC", "EST", "PST" * Z Timezone offset in seconds. The offset for timezones west of UTC is "-43200" through "50400" * always negative, and for those east of UTC is always positive. * c ISO 8601 date "2004-02-12T15:19:21+00:00" * r RFC 2822 formatted date "Thu, 21 Dec 2000 16:01:07 +0200" * U Seconds since the Unix Epoch (January 1 1970 00:00:00 GMT) "0" * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @return {String} A string representation of the current Date object. */ var formatReplace = function (context) { return function (m) { var formatString, override = false; if (m.charAt(0) === "\\" || m.substring(0, 2) === "%%") { return m.replace("\\", "").replace("%%", "%"); } override = normalizer.shouldOverrideDefaults(m); formatString = $D.normalizeFormat(m, context); if (formatString) { return context.toString(formatString, override); } }; }; $P._format = function (format) { var formatter = formatReplace(this); if (!format) { return this._toString(); } else { return format.replace(/(%|\\)?.|%%/g, formatter); } }; if (!$P.format) { $P.format = $P._format; } }()); (function () { "use strict"; var gFn = function (attr) { return function () { return this[attr]; }; }; var sFn = function (attr) { return function (val) { this[attr] = val; return this; }; }; var attrs = ["years", "months", "days", "hours", "minutes", "seconds", "milliseconds"]; var addSetFuncs = function (context, attrs) { for (var i = 0; i < attrs.length ; i++) { var $a = attrs[i], $b = $a.slice(0, 1).toUpperCase() + $a.slice(1); context.prototype[$a] = 0; context.prototype["get" + $b] = gFn($a); context.prototype["set" + $b] = sFn($a); } }; /** * new TimeSpan(milliseconds); * new TimeSpan(days, hours, minutes, seconds); * new TimeSpan(days, hours, minutes, seconds, milliseconds); */ var TimeSpan = function (days, hours, minutes, seconds, milliseconds) { if (arguments.length === 1 && typeof days === "number") { var orient = (days < 0) ? -1 : +1; var millsLeft = Math.abs(days); this.setDays(Math.floor(millsLeft / 86400000) * orient); millsLeft = millsLeft % 86400000; this.setHours(Math.floor(millsLeft / 3600000) * orient); millsLeft = millsLeft % 3600000; this.setMinutes(Math.floor(millsLeft / 60000) * orient); millsLeft = millsLeft % 60000; this.setSeconds(Math.floor(millsLeft / 1000) * orient); millsLeft = millsLeft % 1000; this.setMilliseconds(millsLeft * orient); } else { this.set(days, hours, minutes, seconds, milliseconds); } this.getTotalMilliseconds = function () { return (this.getDays() * 86400000) + (this.getHours() * 3600000) + (this.getMinutes() * 60000) + (this.getSeconds() * 1000); }; this.compareTo = function (time) { var t1 = new Date(1970, 1, 1, this.getHours(), this.getMinutes(), this.getSeconds()), t2; if (time === null) { t2 = new Date(1970, 1, 1, 0, 0, 0); } else { t2 = new Date(1970, 1, 1, time.getHours(), time.getMinutes(), time.getSeconds()); } return (t1 < t2) ? -1 : (t1 > t2) ? 1 : 0; }; this.equals = function (time) { return (this.compareTo(time) === 0); }; this.add = function (time) { return (time === null) ? this : this.addSeconds(time.getTotalMilliseconds() / 1000); }; this.subtract = function (time) { return (time === null) ? this : this.addSeconds(-time.getTotalMilliseconds() / 1000); }; this.addDays = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 86400000)); }; this.addHours = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 3600000)); }; this.addMinutes = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 60000)); }; this.addSeconds = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 1000)); }; this.addMilliseconds = function (n) { return new TimeSpan(this.getTotalMilliseconds() + n); }; this.get12HourHour = function () { return (this.getHours() > 12) ? this.getHours() - 12 : (this.getHours() === 0) ? 12 : this.getHours(); }; this.getDesignator = function () { return (this.getHours() < 12) ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator; }; this.toString = function (format) { this._toString = function () { if (this.getDays() !== null && this.getDays() > 0) { return this.getDays() + "." + this.getHours() + ":" + this.p(this.getMinutes()) + ":" + this.p(this.getSeconds()); } else { return this.getHours() + ":" + this.p(this.getMinutes()) + ":" + this.p(this.getSeconds()); } }; this.p = function (s) { return (s.toString().length < 2) ? "0" + s : s; }; var me = this; return format ? format.replace(/dd?|HH?|hh?|mm?|ss?|tt?/g, function (format) { switch (format) { case "d": return me.getDays(); case "dd": return me.p(me.getDays()); case "H": return me.getHours(); case "HH": return me.p(me.getHours()); case "h": return me.get12HourHour(); case "hh": return me.p(me.get12HourHour()); case "m": return me.getMinutes(); case "mm": return me.p(me.getMinutes()); case "s": return me.getSeconds(); case "ss": return me.p(me.getSeconds()); case "t": return ((me.getHours() < 12) ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator).substring(0, 1); case "tt": return (me.getHours() < 12) ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator; } } ) : this._toString(); }; return this; }; addSetFuncs(TimeSpan, attrs.slice(2)); TimeSpan.prototype.set = function (days, hours, minutes, seconds, milliseconds){ this.setDays(days || this.getDays()); this.setHours(hours || this.getHours()); this.setMinutes(minutes || this.getMinutes()); this.setSeconds(seconds || this.getSeconds()); this.setMilliseconds(milliseconds || this.getMilliseconds()); }; /** * Gets the time of day for this date instances. * @return {TimeSpan} TimeSpan */ Date.prototype.getTimeOfDay = function () { return new TimeSpan(0, this.getHours(), this.getMinutes(), this.getSeconds(), this.getMilliseconds()); }; Date.TimeSpan = TimeSpan; if (typeof window !== "undefined" ) { // keeping API compatible for v1.x window.TimeSpan = TimeSpan; } }()); (function () { "use strict"; var attrs = ["years", "months", "days", "hours", "minutes", "seconds", "milliseconds"]; var gFn = function (attr) { return function () { return this[attr]; }; }; var sFn = function (attr) { return function (val) { this[attr] = val; return this; }; }; var addSetFuncs = function (context, attrs) { for (var i = 0; i < attrs.length ; i++) { var $a = attrs[i], $b = $a.slice(0, 1).toUpperCase() + $a.slice(1); context.prototype[$a] = 0; context.prototype["get" + $b] = gFn($a); context.prototype["set" + $b] = sFn($a); } }; var setMonthsAndYears = function (orient, d1, d2, context) { function inc() { d1.addMonths(-orient); context.months++; if (context.months === 12) { context.years++; context.months = 0; } } if (orient === +1) { while (d1 > d2) { inc(); } } else { while (d1 < d2) { inc(); } } context.months--; context.months *= orient; context.years *= orient; }; var adjustForDST = function(orient, startDate, endDate) { var hasDSTMismatch = (false === (startDate.isDaylightSavingTime() === endDate.isDaylightSavingTime())); if (hasDSTMismatch && orient === 1) { startDate.addHours(-1); } else if (hasDSTMismatch) { startDate.addHours(1); } }; /** * TimePeriod(startDate, endDate); * TimePeriod(years, months, days, hours, minutes, seconds, milliseconds); */ var TimePeriod = function (years, months, days, hours, minutes, seconds, milliseconds) { if (arguments.length === 7) { this.set(years, months, days, hours, minutes, seconds, milliseconds); } else if (arguments.length === 2 && arguments[0] instanceof Date && arguments[1] instanceof Date) { var startDate = arguments[0].clone(); var endDate = arguments[1].clone(); var orient = (startDate > endDate) ? +1 : -1; this.dates = { start: arguments[0].clone(), end: arguments[1].clone() }; setMonthsAndYears(orient, startDate, endDate, this); adjustForDST(orient, startDate, endDate); // // TODO - adjust for DST var diff = endDate - startDate; if (diff !== 0) { var ts = new TimeSpan(diff); this.set(this.years, this.months, ts.getDays(), ts.getHours(), ts.getMinutes(), ts.getSeconds(), ts.getMilliseconds()); } } return this; }; // create all the set functions. addSetFuncs(TimePeriod, attrs); TimePeriod.prototype.set = function (years, months, days, hours, minutes, seconds, milliseconds){ this.setYears(years || this.getYears()); this.setMonths(months || this.getMonths()); this.setDays(days || this.getDays()); this.setHours(hours || this.getHours()); this.setMinutes(minutes || this.getMinutes()); this.setSeconds(seconds || this.getSeconds()); this.setMilliseconds(milliseconds || this.getMilliseconds()); }; Date.TimePeriod = TimePeriod; if (typeof window !== "undefined") { // keeping API compatible for v1.x window.TimePeriod = TimePeriod; } }()); ================================================ FILE: build/date-hr-HR.js ================================================ /** * @overview datejs * @version 1.0.0-rc3 * @author Gregory Wild-Smith * @copyright 2015 Gregory Wild-Smith * @license MIT * @homepage https://github.com/abritinthebay/datejs */ /* * DateJS Culture String File * Country Code: hr-HR * Name: Croatian (Croatia) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["hr-HR"] = { "name": "hr-HR", "englishName": "Croatian (Croatia)", "nativeName": "hrvatski (Hrvatska)", "Sunday": "nedjelja", "Monday": "ponedjeljak", "Tuesday": "utorak", "Wednesday": "srijeda", "Thursday": "četvrtak", "Friday": "petak", "Saturday": "subota", "Sun": "ned", "Mon": "pon", "Tue": "uto", "Wed": "sri", "Thu": "čet", "Fri": "pet", "Sat": "sub", "Su": "ne", "Mo": "po", "Tu": "ut", "We": "sr", "Th": "če", "Fr": "pe", "Sa": "su", "S_Sun_Initial": "n", "M_Mon_Initial": "p", "T_Tue_Initial": "u", "W_Wed_Initial": "s", "T_Thu_Initial": "č", "F_Fri_Initial": "p", "S_Sat_Initial": "s", "January": "siječanj", "February": "veljača", "March": "ožujak", "April": "travanj", "May": "svibanj", "June": "lipanj", "July": "srpanj", "August": "kolovoz", "September": "rujan", "October": "listopad", "November": "studeni", "December": "prosinac", "Jan_Abbr": "sij", "Feb_Abbr": "vlj", "Mar_Abbr": "ožu", "Apr_Abbr": "tra", "May_Abbr": "svi", "Jun_Abbr": "lip", "Jul_Abbr": "srp", "Aug_Abbr": "kol", "Sep_Abbr": "ruj", "Oct_Abbr": "lis", "Nov_Abbr": "stu", "Dec_Abbr": "pro", "AM": "", "PM": "", "firstDayOfWeek": 1, "twoDigitYearMax": 2029, "mdy": "dmy", "M/d/yyyy": "d.M.yyyy", "dddd, MMMM dd, yyyy": "d. MMMM yyyy", "h:mm tt": "H:mm", "h:mm:ss tt": "H:mm:ss", "dddd, MMMM dd, yyyy h:mm:ss tt": "d. MMMM yyyy H:mm:ss", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "d. MMMM", "MMMM, yyyy": "MMMM, yyyy", "/jan(uary)?/": "sij(ečanj)?", "/feb(ruary)?/": "veljača", "/mar(ch)?/": "ožu(jak)?", "/apr(il)?/": "tra(vanj)?", "/may/": "svi(banj)?", "/jun(e)?/": "lip(anj)?", "/jul(y)?/": "srp(anj)?", "/aug(ust)?/": "kol(ovoz)?", "/sep(t(ember)?)?/": "ruj(an)?", "/oct(ober)?/": "lis(topad)?", "/nov(ember)?/": "stu(deni)?", "/dec(ember)?/": "pro(sinac)?", "/^su(n(day)?)?/": "^ne(d(jelja)?)?", "/^mo(n(day)?)?/": "^po(n(edjeljak)?)?", "/^tu(e(s(day)?)?)?/": "^ut(o(rak)?)?", "/^we(d(nesday)?)?/": "^sr(i(jeda)?)?", "/^th(u(r(s(day)?)?)?)?/": "^če(t(vrtak)?)?", "/^fr(i(day)?)?/": "^pe(t(ak)?)?", "/^sa(t(urday)?)?/": "^su(b(ota)?)?", "/^next/": "^slijedeć(i|e|eg)", "/^last|past|prev(ious)?/": "^zadnji|posljednji|prethodni", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|pos(lije)?|od|odsad(a)?)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|pr(ije)?pred)", "/^yes(terday)?/": "^jučer", "/^t(od(ay)?)?/": "^danas", "/^tom(orrow)?/": "^sutra", "/^n(ow)?/": "^sad(a)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sek(und(a|e|i)?)?", "/^mn|min(ute)?s?/": "^mn|min(ut(a|e|i)?)?", "/^h(our)?s?/": "^s(at(a|i)?)?", "/^w(eek)?s?/": "^tj(edan(a|i)?)?", "/^m(onth)?s?/": "^mj(esec(a|i)?)?", "/^d(ay)?s?/": "^dan(a|i)?", "/^y(ear)?s?/": "^god(in(a|e|i|u))?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "hr-HR"; /** * @overview datejs * @version 1.0.0-rc3 * @author Gregory Wild-Smith * @copyright 2015 Gregory Wild-Smith * @license MIT * @homepage https://github.com/abritinthebay/datejs */(function () { var $D = Date; var lang = Date.CultureStrings ? Date.CultureStrings.lang : null; var loggedKeys = {}; // for debug purposes. var getText = { getFromKey: function (key, countryCode) { var output; if (Date.CultureStrings && Date.CultureStrings[countryCode] && Date.CultureStrings[countryCode][key]) { output = Date.CultureStrings[countryCode][key]; } else { output = getText.buildFromDefault(key); } if (key.charAt(0) === "/") { // Assume it's a regex output = getText.buildFromRegex(key, countryCode); } return output; }, getFromObjectValues: function (obj, countryCode) { var key, output = {}; for(key in obj) { if (obj.hasOwnProperty(key)) { output[key] = getText.getFromKey(obj[key], countryCode); } } return output; }, getFromObjectKeys: function (obj, countryCode) { var key, output = {}; for(key in obj) { if (obj.hasOwnProperty(key)) { output[getText.getFromKey(key, countryCode)] = obj[key]; } } return output; }, getFromArray: function (arr, countryCode) { var output = []; for (var i=0; i < arr.length; i++){ if (i in arr) { output[i] = getText.getFromKey(arr[i], countryCode); } } return output; }, buildFromDefault: function (key) { var output, length, split, last; switch(key) { case "name": output = "en-US"; break; case "englishName": output = "English (United States)"; break; case "nativeName": output = "English (United States)"; break; case "twoDigitYearMax": output = 2049; break; case "firstDayOfWeek": output = 0; break; default: output = key; split = key.split("_"); length = split.length; if (length > 1 && key.charAt(0) !== "/") { // if the key isn't a regex and it has a split. last = split[(length - 1)].toLowerCase(); if (last === "initial" || last === "abbr") { output = split[0]; } } break; } return output; }, buildFromRegex: function (key, countryCode) { var output; if (Date.CultureStrings && Date.CultureStrings[countryCode] && Date.CultureStrings[countryCode][key]) { output = new RegExp(Date.CultureStrings[countryCode][key], "i"); } else { output = new RegExp(key.replace(new RegExp("/", "g"),""), "i"); } return output; } }; var shallowMerge = function (obj1, obj2) { for (var attrname in obj2) { if (obj2.hasOwnProperty(attrname)) { obj1[attrname] = obj2[attrname]; } } }; var __ = function (key, language) { var countryCode = (language) ? language : lang; loggedKeys[key] = key; if (typeof key === "object") { if (key instanceof Array) { return getText.getFromArray(key, countryCode); } else { return getText.getFromObjectKeys(key, countryCode); } } else { return getText.getFromKey(key, countryCode); } }; var loadI18nScript = function (code) { // paatterned after jQuery's getScript. var url = Date.Config.i18n + code + ".js"; var head = document.getElementsByTagName("head")[0] || document.documentElement; var script = document.createElement("script"); script.src = url; var completed = false; var events = { done: function (){} // placeholder function }; // Attach handlers for all browsers script.onload = script.onreadystatechange = function() { if ( !completed && (!this.readyState || this.readyState === "loaded" || this.readyState === "complete") ) { events.done(); head.removeChild(script); } }; setTimeout(function() { head.insertBefore(script, head.firstChild); }, 0); // allows return to execute first return { done: function (cb) { events.done = function() { if (cb) { setTimeout(cb,0); } }; } }; }; var buildInfo = { buildFromMethodHash: function (obj) { var key; for(key in obj) { if (obj.hasOwnProperty(key)) { obj[key] = buildInfo[obj[key]](); } } return obj; }, timeZoneDST: function () { var DST = { "CHADT": "+1345", "NZDT": "+1300", "AEDT": "+1100", "ACDT": "+1030", "AZST": "+0500", "IRDT": "+0430", "EEST": "+0300", "CEST": "+0200", "BST": "+0100", "PMDT": "-0200", "ADT": "-0300", "NDT": "-0230", "EDT": "-0400", "CDT": "-0500", "MDT": "-0600", "PDT": "-0700", "AKDT": "-0800", "HADT": "-0900" }; return __(DST); }, timeZoneStandard: function () { var standard = { "LINT": "+1400", "TOT": "+1300", "CHAST": "+1245", "NZST": "+1200", "NFT": "+1130", "SBT": "+1100", "AEST": "+1000", "ACST": "+0930", "JST": "+0900", "CWST": "+0845", "CT": "+0800", "ICT": "+0700", "MMT": "+0630", "BST": "+0600", "NPT": "+0545", "IST": "+0530", "PKT": "+0500", "AFT": "+0430", "MSK": "+0400", "IRST": "+0330", "FET": "+0300", "EET": "+0200", "CET": "+0100", "GMT": "+0000", "UTC": "+0000", "CVT": "-0100", "GST": "-0200", "BRT": "-0300", "NST": "-0330", "AST": "-0400", "EST": "-0500", "CST": "-0600", "MST": "-0700", "PST": "-0800", "AKST": "-0900", "MIT": "-0930", "HST": "-1000", "SST": "-1100", "BIT": "-1200" }; return __(standard); }, timeZones: function (data) { var zone; data.timezones = []; for (zone in data.abbreviatedTimeZoneStandard) { if (data.abbreviatedTimeZoneStandard.hasOwnProperty(zone)) { data.timezones.push({ name: zone, offset: data.abbreviatedTimeZoneStandard[zone]}); } } for (zone in data.abbreviatedTimeZoneDST) { if (data.abbreviatedTimeZoneDST.hasOwnProperty(zone)) { data.timezones.push({ name: zone, offset: data.abbreviatedTimeZoneDST[zone], dst: true}); } } return data.timezones; }, days: function () { return __(["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"]); }, dayAbbr: function () { return __(["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"]); }, dayShortNames: function () { return __(["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"]); }, dayFirstLetters: function () { return __(["S_Sun_Initial", "M_Mon_Initial", "T_Tues_Initial", "W_Wed_Initial", "T_Thu_Initial", "F_Fri_Initial", "S_Sat_Initial"]); }, months: function () { return __(["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"]); }, monthAbbr: function () { return __(["Jan_Abbr", "Feb_Abbr", "Mar_Abbr", "Apr_Abbr", "May_Abbr", "Jun_Abbr", "Jul_Abbr", "Aug_Abbr", "Sep_Abbr", "Oct_Abbr", "Nov_Abbr", "Dec_Abbr"]); }, formatPatterns: function () { return getText.getFromObjectValues({ shortDate: "M/d/yyyy", longDate: "dddd, MMMM dd, yyyy", shortTime: "h:mm tt", longTime: "h:mm:ss tt", fullDateTime: "dddd, MMMM dd, yyyy h:mm:ss tt", sortableDateTime: "yyyy-MM-ddTHH:mm:ss", universalSortableDateTime: "yyyy-MM-dd HH:mm:ssZ", rfc1123: "ddd, dd MMM yyyy HH:mm:ss", monthDay: "MMMM dd", yearMonth: "MMMM, yyyy" }, Date.i18n.currentLanguage()); }, regex: function () { return getText.getFromObjectValues({ inTheMorning: "/( in the )(morn(ing)?)\\b/", thisMorning: "/(this )(morn(ing)?)\\b/", amThisMorning: "/(\b\\d(am)? )(this )(morn(ing)?)/", inTheEvening: "/( in the )(even(ing)?)\\b/", thisEvening: "/(this )(even(ing)?)\\b/", pmThisEvening: "/(\b\\d(pm)? )(this )(even(ing)?)/", jan: "/jan(uary)?/", feb: "/feb(ruary)?/", mar: "/mar(ch)?/", apr: "/apr(il)?/", may: "/may/", jun: "/jun(e)?/", jul: "/jul(y)?/", aug: "/aug(ust)?/", sep: "/sep(t(ember)?)?/", oct: "/oct(ober)?/", nov: "/nov(ember)?/", dec: "/dec(ember)?/", sun: "/^su(n(day)?)?/", mon: "/^mo(n(day)?)?/", tue: "/^tu(e(s(day)?)?)?/", wed: "/^we(d(nesday)?)?/", thu: "/^th(u(r(s(day)?)?)?)?/", fri: "/fr(i(day)?)?/", sat: "/^sa(t(urday)?)?/", future: "/^next/", past: "/^last|past|prev(ious)?/", add: "/^(\\+|aft(er)?|from|hence)/", subtract: "/^(\\-|bef(ore)?|ago)/", yesterday: "/^yes(terday)?/", today: "/^t(od(ay)?)?/", tomorrow: "/^tom(orrow)?/", now: "/^n(ow)?/", millisecond: "/^ms|milli(second)?s?/", second: "/^sec(ond)?s?/", minute: "/^mn|min(ute)?s?/", hour: "/^h(our)?s?/", week: "/^w(eek)?s?/", month: "/^m(onth)?s?/", day: "/^d(ay)?s?/", year: "/^y(ear)?s?/", shortMeridian: "/^(a|p)/", longMeridian: "/^(a\\.?m?\\.?|p\\.?m?\\.?)/", timezone: "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/", ordinalSuffix: "/^\\s*(st|nd|rd|th)/", timeContext: "/^\\s*(\\:|a(?!u|p)|p)/" }, Date.i18n.currentLanguage()); } }; var CultureInfo = function () { var info = getText.getFromObjectValues({ name: "name", englishName: "englishName", nativeName: "nativeName", amDesignator: "AM", pmDesignator: "PM", firstDayOfWeek: "firstDayOfWeek", twoDigitYearMax: "twoDigitYearMax", dateElementOrder: "mdy" }, Date.i18n.currentLanguage()); var constructedInfo = buildInfo.buildFromMethodHash({ dayNames: "days", abbreviatedDayNames: "dayAbbr", shortestDayNames: "dayShortNames", firstLetterDayNames: "dayFirstLetters", monthNames: "months", abbreviatedMonthNames: "monthAbbr", formatPatterns: "formatPatterns", regexPatterns: "regex", abbreviatedTimeZoneDST: "timeZoneDST", abbreviatedTimeZoneStandard: "timeZoneStandard" }); shallowMerge(info, constructedInfo); buildInfo.timeZones(info); return info; }; $D.i18n = { __: function (key, lang) { return __(key, lang); }, currentLanguage: function () { return lang || "en-US"; }, setLanguage: function (code, force, cb) { var async = false; if (force || code === "en-US" || (!!Date.CultureStrings && !!Date.CultureStrings[code])) { lang = code; Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings.lang = code; Date.CultureInfo = new CultureInfo(); } else { if (!(!!Date.CultureStrings && !!Date.CultureStrings[code])) { if (typeof exports !== "undefined" && this.exports !== exports) { // we're in a Node enviroment, load it using require try { require("../i18n/" + code + ".js"); lang = code; Date.CultureStrings.lang = code; Date.CultureInfo = new CultureInfo(); } catch (e) { // var str = "The language for '" + code + "' could not be loaded by Node. It likely does not exist."; throw new Error("The DateJS IETF language tag '" + code + "' could not be loaded by Node. It likely does not exist."); } } else if (Date.Config && Date.Config.i18n) { // we know the location of the files, so lets load them async = true; loadI18nScript(code).done(function(){ lang = code; Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings.lang = code; Date.CultureInfo = new CultureInfo(); $D.Parsing.Normalizer.buildReplaceData(); // because this is async if ($D.Grammar) { $D.Grammar.buildGrammarFormats(); // so we can parse those strings... } if (cb) { setTimeout(cb,0); } }); } else { Date.console.error("The DateJS IETF language tag '" + code + "' is not available and has not been loaded."); return false; } } } $D.Parsing.Normalizer.buildReplaceData(); // rebuild normalizer strings if ($D.Grammar) { $D.Grammar.buildGrammarFormats(); // so we can parse those strings... } if (!async && cb) { setTimeout(cb,0); } }, getLoggedKeys: function () { return loggedKeys; }, updateCultureInfo: function () { Date.CultureInfo = new CultureInfo(); } }; $D.i18n.updateCultureInfo(); // run automatically }()); (function () { var $D = Date, $P = $D.prototype, p = function (s, l) { if (!l) { l = 2; } return ("000" + s).slice(l * -1); }; if (typeof window !== "undefined" && typeof window.console !== "undefined" && typeof window.console.log !== "undefined") { $D.console = console; // used only to raise non-critical errors if available } else { // set mock so we don't give errors. $D.console = { log: function(){}, error: function(){} }; } $D.Config = $D.Config || {}; $D.initOverloads = function() { /** * Overload of Date.now. Allows an alternate call for Date.now where it returns the * current Date as an object rather than just milliseconds since the Unix Epoch. * * Also provides an implementation of now() for browsers (IE<9) that don't have it. * * Backwards compatible so with work with either: * Date.now() [returns ms] * or * Date.now(true) [returns Date] */ if (!$D.now) { $D._now = function now() { return new Date().getTime(); }; } else if (!$D._now) { $D._now = $D.now; } $D.now = function (returnObj) { if (returnObj) { return $D.present(); } else { return $D._now(); } }; if ( !$P.toISOString ) { $P.toISOString = function() { return this.getUTCFullYear() + "-" + p(this.getUTCMonth() + 1) + "-" + p(this.getUTCDate()) + "T" + p(this.getUTCHours()) + ":" + p(this.getUTCMinutes()) + ":" + p(this.getUTCSeconds()) + "." + String( (this.getUTCMilliseconds()/1000).toFixed(3)).slice(2, 5) + "Z"; }; } // private if ( $P._toString === undefined ){ $P._toString = $P.toString; } }; $D.initOverloads(); /** * Gets a date that is set to the current date. The time is set to the start of the day (00:00 or 12:00 AM). * @return {Date} The current date. */ $D.today = function () { return new Date().clearTime(); }; /** * Gets a date that is set to the current date and time (same as new Date, but chainable) * @return {Date} The current date. */ $D.present = function () { return new Date(); }; /** * Compares the first date to the second date and returns an number indication of their relative values. * @param {Date} First Date object to compare [Required]. * @param {Date} Second Date object to compare to [Required]. * @return {Number} -1 = date1 is lessthan date2. 0 = values are equal. 1 = date1 is greaterthan date2. */ $D.compare = function (date1, date2) { if (isNaN(date1) || isNaN(date2)) { throw new Error(date1 + " - " + date2); } else if (date1 instanceof Date && date2 instanceof Date) { return (date1 < date2) ? -1 : (date1 > date2) ? 1 : 0; } else { throw new TypeError(date1 + " - " + date2); } }; /** * Compares the first Date object to the second Date object and returns true if they are equal. * @param {Date} First Date object to compare [Required] * @param {Date} Second Date object to compare to [Required] * @return {Boolean} true if dates are equal. false if they are not equal. */ $D.equals = function (date1, date2) { return (date1.compareTo(date2) === 0); }; /** * Gets the language appropriate day name when given the day number(0-6) * eg - 0 == Sunday * @return {String} The day name */ $D.getDayName = function (n) { return Date.CultureInfo.dayNames[n]; }; /** * Gets the day number (0-6) if given a CultureInfo specific string which is a valid dayName, abbreviatedDayName or shortestDayName (two char). * @param {String} The name of the day (eg. "Monday, "Mon", "tuesday", "tue", "We", "we"). * @return {Number} The day number */ $D.getDayNumberFromName = function (name) { var n = Date.CultureInfo.dayNames, m = Date.CultureInfo.abbreviatedDayNames, o = Date.CultureInfo.shortestDayNames, s = name.toLowerCase(); for (var i = 0; i < n.length; i++) { if (n[i].toLowerCase() === s || m[i].toLowerCase() === s || o[i].toLowerCase() === s) { return i; } } return -1; }; /** * Gets the month number (0-11) if given a Culture Info specific string which is a valid monthName or abbreviatedMonthName. * @param {String} The name of the month (eg. "February, "Feb", "october", "oct"). * @return {Number} The day number */ $D.getMonthNumberFromName = function (name) { var n = Date.CultureInfo.monthNames, m = Date.CultureInfo.abbreviatedMonthNames, s = name.toLowerCase(); for (var i = 0; i < n.length; i++) { if (n[i].toLowerCase() === s || m[i].toLowerCase() === s) { return i; } } return -1; }; /** * Gets the language appropriate month name when given the month number(0-11) * eg - 0 == January * @return {String} The month name */ $D.getMonthName = function (n) { return Date.CultureInfo.monthNames[n]; }; /** * Determines if the current date instance is within a LeapYear. * @param {Number} The year. * @return {Boolean} true if date is within a LeapYear, otherwise false. */ $D.isLeapYear = function (year) { return ((year % 4 === 0 && year % 100 !== 0) || year % 400 === 0); }; /** * Gets the number of days in the month, given a year and month value. Automatically corrects for LeapYear. * @param {Number} The year. * @param {Number} The month (0-11). * @return {Number} The number of days in the month. */ $D.getDaysInMonth = function (year, month) { if (!month && $D.validateMonth(year)) { month = year; year = Date.today().getFullYear(); } return [31, ($D.isLeapYear(year) ? 29 : 28), 31, 30, 31, 30, 31, 31, 30, 31, 30, 31][month]; }; $P.getDaysInMonth = function () { return $D.getDaysInMonth(this.getFullYear(), this.getMonth()); }; $D.getTimezoneAbbreviation = function (offset, dst) { var p, n = (dst || false) ? Date.CultureInfo.abbreviatedTimeZoneDST : Date.CultureInfo.abbreviatedTimeZoneStandard; for (p in n) { if (n.hasOwnProperty(p)) { if (n[p] === offset) { return p; } } } return null; }; $D.getTimezoneOffset = function (name, dst) { var i, a =[], z = Date.CultureInfo.timezones; if (!name) { name = (new Date()).getTimezone();} for (i = 0; i < z.length; i++) { if (z[i].name === name.toUpperCase()) { a.push(i); } } if (!z[a[0]]) { return null; } if (a.length === 1 || !dst) { return z[a[0]].offset; } else { for (i=0; i < a.length; i++) { if (z[a[i]].dst) { return z[a[i]].offset; } } } }; $D.getQuarter = function (d) { d = d || new Date(); // If no date supplied, use today var q = [1,2,3,4]; return q[Math.floor(d.getMonth() / 3)]; // ~~~ is a bitwise op. Faster than Math.floor }; $D.getDaysLeftInQuarter = function (d) { d = d || new Date(); var qEnd = new Date(d); qEnd.setMonth(qEnd.getMonth() + 3 - qEnd.getMonth() % 3, 0); return Math.floor((qEnd - d) / 8.64e7); }; // private var validate = function (n, min, max, name) { name = name ? name : "Object"; if (typeof n === "undefined") { return false; } else if (typeof n !== "number") { throw new TypeError(n + " is not a Number."); } else if (n < min || n > max) { // As failing validation is *not* an exceptional circumstance // lets not throw a RangeError Exception here. // It's semantically correct but it's not sensible. return false; } return true; }; /** * Validates the number is within an acceptable range for milliseconds [0-999]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateMillisecond = function (value) { return validate(value, 0, 999, "millisecond"); }; /** * Validates the number is within an acceptable range for seconds [0-59]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateSecond = function (value) { return validate(value, 0, 59, "second"); }; /** * Validates the number is within an acceptable range for minutes [0-59]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateMinute = function (value) { return validate(value, 0, 59, "minute"); }; /** * Validates the number is within an acceptable range for hours [0-23]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateHour = function (value) { return validate(value, 0, 23, "hour"); }; /** * Validates the number is within an acceptable range for the days in a month [0-MaxDaysInMonth]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateDay = function (value, year, month) { if (year === undefined || year === null || month === undefined || month === null) { return false;} return validate(value, 1, $D.getDaysInMonth(year, month), "day"); }; /** * Validates the number is within an acceptable range for months [0-11]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateWeek = function (value) { return validate(value, 0, 53, "week"); }; /** * Validates the number is within an acceptable range for months [0-11]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateMonth = function (value) { return validate(value, 0, 11, "month"); }; /** * Validates the number is within an acceptable range for years. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateYear = function (value) { /** * Per ECMAScript spec the range of times supported by Date objects is * exactly -100,000,000 days to +100,000,000 days measured relative to * midnight at the beginning of 01 January, 1970 UTC. * This gives a range of 8,640,000,000,000,000 milliseconds to either * side of 01 January, 1970 UTC. * * Earliest possible date: Tue, 20 Apr 271,822 B.C. 00:00:00 UTC * Latest possible date: Sat, 13 Sep 275,760 00:00:00 UTC */ return validate(value, -271822, 275760, "year"); }; $D.validateTimezone = function(value) { var timezones = {"ACDT":1,"ACST":1,"ACT":1,"ADT":1,"AEDT":1,"AEST":1,"AFT":1,"AKDT":1,"AKST":1,"AMST":1,"AMT":1,"ART":1,"AST":1,"AWDT":1,"AWST":1,"AZOST":1,"AZT":1,"BDT":1,"BIOT":1,"BIT":1,"BOT":1,"BRT":1,"BST":1,"BTT":1,"CAT":1,"CCT":1,"CDT":1,"CEDT":1,"CEST":1,"CET":1,"CHADT":1,"CHAST":1,"CHOT":1,"ChST":1,"CHUT":1,"CIST":1,"CIT":1,"CKT":1,"CLST":1,"CLT":1,"COST":1,"COT":1,"CST":1,"CT":1,"CVT":1,"CWST":1,"CXT":1,"DAVT":1,"DDUT":1,"DFT":1,"EASST":1,"EAST":1,"EAT":1,"ECT":1,"EDT":1,"EEDT":1,"EEST":1,"EET":1,"EGST":1,"EGT":1,"EIT":1,"EST":1,"FET":1,"FJT":1,"FKST":1,"FKT":1,"FNT":1,"GALT":1,"GAMT":1,"GET":1,"GFT":1,"GILT":1,"GIT":1,"GMT":1,"GST":1,"GYT":1,"HADT":1,"HAEC":1,"HAST":1,"HKT":1,"HMT":1,"HOVT":1,"HST":1,"ICT":1,"IDT":1,"IOT":1,"IRDT":1,"IRKT":1,"IRST":1,"IST":1,"JST":1,"KGT":1,"KOST":1,"KRAT":1,"KST":1,"LHST":1,"LINT":1,"MAGT":1,"MART":1,"MAWT":1,"MDT":1,"MET":1,"MEST":1,"MHT":1,"MIST":1,"MIT":1,"MMT":1,"MSK":1,"MST":1,"MUT":1,"MVT":1,"MYT":1,"NCT":1,"NDT":1,"NFT":1,"NPT":1,"NST":1,"NT":1,"NUT":1,"NZDT":1,"NZST":1,"OMST":1,"ORAT":1,"PDT":1,"PET":1,"PETT":1,"PGT":1,"PHOT":1,"PHT":1,"PKT":1,"PMDT":1,"PMST":1,"PONT":1,"PST":1,"PYST":1,"PYT":1,"RET":1,"ROTT":1,"SAKT":1,"SAMT":1,"SAST":1,"SBT":1,"SCT":1,"SGT":1,"SLST":1,"SRT":1,"SST":1,"SYOT":1,"TAHT":1,"THA":1,"TFT":1,"TJT":1,"TKT":1,"TLT":1,"TMT":1,"TOT":1,"TVT":1,"UCT":1,"ULAT":1,"UTC":1,"UYST":1,"UYT":1,"UZT":1,"VET":1,"VLAT":1,"VOLT":1,"VOST":1,"VUT":1,"WAKT":1,"WAST":1,"WAT":1,"WEDT":1,"WEST":1,"WET":1,"WST":1,"YAKT":1,"YEKT":1,"Z":1}; return (timezones[value] === 1); }; $D.validateTimezoneOffset= function(value) { // timezones go from +14hrs to -12hrs, the +X hours are negative offsets. return (value > -841 && value < 721); }; }()); (function () { var $D = Date, $P = $D.prototype, p = function (s, l) { if (!l) { l = 2; } return ("000" + s).slice(l * -1); }; var validateConfigObject = function (obj) { var result = {}, self = this, prop, testFunc; testFunc = function (prop, func, value) { if (prop === "day") { var month = (obj.month !== undefined) ? obj.month : self.getMonth(); var year = (obj.year !== undefined) ? obj.year : self.getFullYear(); return $D[func](value, year, month); } else { return $D[func](value); } }; for (prop in obj) { if (Object.prototype.hasOwnProperty.call(obj, prop)) { var func = "validate" + prop.charAt(0).toUpperCase() + prop.slice(1); if ($D[func] && obj[prop] !== null && testFunc(prop, func, obj[prop])) { result[prop] = obj[prop]; } } } return result; }; /** * Resets the time of this Date object to 12:00 AM (00:00), which is the start of the day. * @param {Boolean} .clone() this date instance before clearing Time * @return {Date} this */ $P.clearTime = function () { this.setHours(0); this.setMinutes(0); this.setSeconds(0); this.setMilliseconds(0); return this; }; /** * Resets the time of this Date object to the current time ('now'). * @return {Date} this */ $P.setTimeToNow = function () { var n = new Date(); this.setHours(n.getHours()); this.setMinutes(n.getMinutes()); this.setSeconds(n.getSeconds()); this.setMilliseconds(n.getMilliseconds()); return this; }; /** * Returns a new Date object that is an exact date and time copy of the original instance. * @return {Date} A new Date instance */ $P.clone = function () { return new Date(this.getTime()); }; /** * Compares this instance to a Date object and returns an number indication of their relative values. * @param {Date} Date object to compare [Required] * @return {Number} -1 = this is lessthan date. 0 = values are equal. 1 = this is greaterthan date. */ $P.compareTo = function (date) { return Date.compare(this, date); }; /** * Compares this instance to another Date object and returns true if they are equal. * @param {Date} Date object to compare. If no date to compare, new Date() [now] is used. * @return {Boolean} true if dates are equal. false if they are not equal. */ $P.equals = function (date) { return Date.equals(this, (date !== undefined ? date : new Date())); }; /** * Determines if this instance is between a range of two dates or equal to either the start or end dates. * @param {Date} Start of range [Required] * @param {Date} End of range [Required] * @return {Boolean} true is this is between or equal to the start and end dates, else false */ $P.between = function (start, end) { return this.getTime() >= start.getTime() && this.getTime() <= end.getTime(); }; /** * Determines if this date occurs after the date to compare to. * @param {Date} Date object to compare. If no date to compare, new Date() ("now") is used. * @return {Boolean} true if this date instance is greater than the date to compare to (or "now"), otherwise false. */ $P.isAfter = function (date) { return this.compareTo(date || new Date()) === 1; }; /** * Determines if this date occurs before the date to compare to. * @param {Date} Date object to compare. If no date to compare, new Date() ("now") is used. * @return {Boolean} true if this date instance is less than the date to compare to (or "now"). */ $P.isBefore = function (date) { return (this.compareTo(date || new Date()) === -1); }; /** * Determines if the current Date instance occurs today. * @return {Boolean} true if this date instance is 'today', otherwise false. */ /** * Determines if the current Date instance occurs on the same Date as the supplied 'date'. * If no 'date' to compare to is provided, the current Date instance is compared to 'today'. * @param {date} Date object to compare. If no date to compare, the current Date ("now") is used. * @return {Boolean} true if this Date instance occurs on the same Day as the supplied 'date'. */ $P.isToday = $P.isSameDay = function (date) { return this.clone().clearTime().equals((date || new Date()).clone().clearTime()); }; /** * Adds the specified number of milliseconds to this instance. * @param {Number} The number of milliseconds to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addMilliseconds = function (value) { if (!value) { return this; } this.setTime(this.getTime() + value * 1); return this; }; /** * Adds the specified number of seconds to this instance. * @param {Number} The number of seconds to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addSeconds = function (value) { if (!value) { return this; } return this.addMilliseconds(value * 1000); }; /** * Adds the specified number of seconds to this instance. * @param {Number} The number of seconds to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addMinutes = function (value) { if (!value) { return this; } return this.addMilliseconds(value * 60000); // 60*1000 }; /** * Adds the specified number of hours to this instance. * @param {Number} The number of hours to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addHours = function (value) { if (!value) { return this; } return this.addMilliseconds(value * 3600000); // 60*60*1000 }; /** * Adds the specified number of days to this instance. * @param {Number} The number of days to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addDays = function (value) { if (!value) { return this; } this.setDate(this.getDate() + value * 1); return this; }; /** * Adds the specified number of weekdays (ie - not sat or sun) to this instance. * @param {Number} The number of days to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addWeekdays = function (value) { if (!value) { return this; } var day = this.getDay(); var weeks = (Math.ceil(Math.abs(value)/7)); if (day === 0 || day === 6) { if (value > 0) { this.next().monday(); this.addDays(-1); day = this.getDay(); } } if (value < 0) { while (value < 0) { this.addDays(-1); day = this.getDay(); if (day !== 0 && day !== 6) { value++; } } return this; } else if (value > 5 || (6-day) <= value) { value = value + (weeks * 2); } return this.addDays(value); }; /** * Adds the specified number of weeks to this instance. * @param {Number} The number of weeks to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addWeeks = function (value) { if (!value) { return this; } return this.addDays(value * 7); }; /** * Adds the specified number of months to this instance. * @param {Number} The number of months to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addMonths = function (value) { if (!value) { return this; } var n = this.getDate(); this.setDate(1); this.setMonth(this.getMonth() + value * 1); this.setDate(Math.min(n, $D.getDaysInMonth(this.getFullYear(), this.getMonth()))); return this; }; $P.addQuarters = function (value) { if (!value) { return this; } // note this will take you to the same point in the quarter as you are now. // i.e. - if you are 15 days into the quarter you'll be 15 days into the resulting one. // bonus: this allows adding fractional quarters return this.addMonths(value * 3); }; /** * Adds the specified number of years to this instance. * @param {Number} The number of years to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addYears = function (value) { if (!value) { return this; } return this.addMonths(value * 12); }; /** * Adds (or subtracts) to the value of the years, months, weeks, days, hours, minutes, seconds, milliseconds of the date instance using given configuration object. Positive and Negative values allowed. * Example

	Date.today().add( { days: 1, months: 1 } )

	new Date().add( { years: -1 } )
	
* @param {Object} Configuration object containing attributes (months, days, etc.) * @return {Date} this */ $P.add = function (config) { if (typeof config === "number") { this._orient = config; return this; } var x = config; if (x.day) { // If we should be a different date than today (eg: for 'tomorrow -1d', etc). // Should only effect parsing, not direct usage (eg, Finish and FinishExact) if ((x.day - this.getDate()) !== 0) { this.setDate(x.day); } } if (x.milliseconds) { this.addMilliseconds(x.milliseconds); } if (x.seconds) { this.addSeconds(x.seconds); } if (x.minutes) { this.addMinutes(x.minutes); } if (x.hours) { this.addHours(x.hours); } if (x.weeks) { this.addWeeks(x.weeks); } if (x.months) { this.addMonths(x.months); } if (x.years) { this.addYears(x.years); } if (x.days) { this.addDays(x.days); } return this; }; /** * Get the week number. Week one (1) is the week which contains the first Thursday of the year. Monday is considered the first day of the week. * The .getWeek() function does NOT convert the date to UTC. The local datetime is used. * Please use .getISOWeek() to get the week of the UTC converted date. * @return {Number} 1 to 53 */ $P.getWeek = function (utc) { // Create a copy of this date object var self, target = new Date(this.valueOf()); if (utc) { target.addMinutes(target.getTimezoneOffset()); self = target.clone(); } else { self = this; } // ISO week date weeks start on monday // so correct the day number var dayNr = (self.getDay() + 6) % 7; // ISO 8601 states that week 1 is the week // with the first thursday of that year. // Set the target date to the thursday in the target week target.setDate(target.getDate() - dayNr + 3); // Store the millisecond value of the target date var firstThursday = target.valueOf(); // Set the target to the first thursday of the year // First set the target to january first target.setMonth(0, 1); // Not a thursday? Correct the date to the next thursday if (target.getDay() !== 4) { target.setMonth(0, 1 + ((4 - target.getDay()) + 7) % 7); } // The weeknumber is the number of weeks between the // first thursday of the year and the thursday in the target week return 1 + Math.ceil((firstThursday - target) / 604800000); // 604800000 = 7 * 24 * 3600 * 1000 }; /** * Get the ISO 8601 week number. Week one ("01") is the week which contains the first Thursday of the year. Monday is considered the first day of the week. * The .getISOWeek() function does convert the date to it's UTC value. Please use .getWeek() to get the week of the local date. * @return {String} "01" to "53" */ $P.getISOWeek = function () { return p(this.getWeek(true)); }; /** * Moves the date to Monday of the week set. Week one (1) is the week which contains the first Thursday of the year. * @param {Number} A Number (1 to 53) that represents the week of the year. * @return {Date} this */ $P.setWeek = function (n) { if ((n - this.getWeek()) === 0) { if (this.getDay() !== 1) { return this.moveToDayOfWeek(1, (this.getDay() > 1 ? -1 : 1)); } else { return this; } } else { return this.moveToDayOfWeek(1, (this.getDay() > 1 ? -1 : 1)).addWeeks(n - this.getWeek()); } }; $P.setQuarter = function (qtr) { var month = Math.abs(((qtr-1) * 3) + 1); return this.setMonth(month, 1); }; $P.getQuarter = function () { return Date.getQuarter(this); }; $P.getDaysLeftInQuarter = function () { return Date.getDaysLeftInQuarter(this); }; /** * Moves the date to the next n'th occurrence of the dayOfWeek starting from the beginning of the month. The number (-1) is a magic number and will return the last occurrence of the dayOfWeek in the month. * @param {Number} The dayOfWeek to move to * @param {Number} The n'th occurrence to move to. Use (-1) to return the last occurrence in the month * @return {Date} this */ $P.moveToNthOccurrence = function (dayOfWeek, occurrence) { if (dayOfWeek === "Weekday") { if (occurrence > 0) { this.moveToFirstDayOfMonth(); if (this.is().weekday()) { occurrence -= 1; } } else if (occurrence < 0) { this.moveToLastDayOfMonth(); if (this.is().weekday()) { occurrence += 1; } } else { return this; } return this.addWeekdays(occurrence); } var shift = 0; if (occurrence > 0) { shift = occurrence - 1; } else if (occurrence === -1) { this.moveToLastDayOfMonth(); if (this.getDay() !== dayOfWeek) { this.moveToDayOfWeek(dayOfWeek, -1); } return this; } return this.moveToFirstDayOfMonth().addDays(-1).moveToDayOfWeek(dayOfWeek, +1).addWeeks(shift); }; var moveToN = function (getFunc, addFunc, nVal) { return function (value, orient) { var diff = (value - this[getFunc]() + nVal * (orient || +1)) % nVal; return this[addFunc]((diff === 0) ? diff += nVal * (orient || +1) : diff); }; }; /** * Move to the next or last dayOfWeek based on the orient value. * @param {Number} The dayOfWeek to move to * @param {Number} Forward (+1) or Back (-1). Defaults to +1. [Optional] * @return {Date} this */ $P.moveToDayOfWeek = moveToN("getDay", "addDays", 7); /** * Move to the next or last month based on the orient value. * @param {Number} The month to move to. 0 = January, 11 = December * @param {Number} Forward (+1) or Back (-1). Defaults to +1. [Optional] * @return {Date} this */ $P.moveToMonth = moveToN("getMonth", "addMonths", 12); /** * Get the Ordinate of the current day ("th", "st", "rd"). * @return {String} */ $P.getOrdinate = function () { var num = this.getDate(); return ord(num); }; /** * Get the Ordinal day (numeric day number) of the year, adjusted for leap year. * @return {Number} 1 through 365 (366 in leap years) */ $P.getOrdinalNumber = function () { return Math.ceil((this.clone().clearTime() - new Date(this.getFullYear(), 0, 1)) / 86400000) + 1; }; /** * Get the time zone abbreviation of the current date. * @return {String} The abbreviated time zone name (e.g. "EST") */ $P.getTimezone = function () { return $D.getTimezoneAbbreviation(this.getUTCOffset(), this.isDaylightSavingTime()); }; $P.setTimezoneOffset = function (offset) { var here = this.getTimezoneOffset(), there = Number(offset) * -6 / 10; return (there || there === 0) ? this.addMinutes(there - here) : this; }; $P.setTimezone = function (offset) { return this.setTimezoneOffset($D.getTimezoneOffset(offset)); }; /** * Indicates whether Daylight Saving Time is observed in the current time zone. * @return {Boolean} true|false */ $P.hasDaylightSavingTime = function () { return (Date.today().set({month: 0, day: 1}).getTimezoneOffset() !== Date.today().set({month: 6, day: 1}).getTimezoneOffset()); }; /** * Indicates whether this Date instance is within the Daylight Saving Time range for the current time zone. * @return {Boolean} true|false */ $P.isDaylightSavingTime = function () { return Date.today().set({month: 0, day: 1}).getTimezoneOffset() !== this.getTimezoneOffset(); }; /** * Get the offset from UTC of the current date. * @return {String} The 4-character offset string prefixed with + or - (e.g. "-0500") */ $P.getUTCOffset = function (offset) { var n = (offset || this.getTimezoneOffset()) * -10 / 6, r; if (n < 0) { r = (n - 10000).toString(); return r.charAt(0) + r.substr(2); } else { r = (n + 10000).toString(); return "+" + r.substr(1); } }; /** * Returns the number of milliseconds between this date and date. * @param {Date} Defaults to now * @return {Number} The diff in milliseconds */ $P.getElapsed = function (date) { return (date || new Date()) - this; }; /** * Set the value of year, month, day, hour, minute, second, millisecond of date instance using given configuration object. * Example

	Date.today().set( { day: 20, month: 1 } )

	new Date().set( { millisecond: 0 } )
	
* * @param {Object} Configuration object containing attributes (month, day, etc.) * @return {Date} this */ $P.set = function (config) { config = validateConfigObject.call(this, config); var key; for (key in config) { if (Object.prototype.hasOwnProperty.call(config, key)) { var name = key.charAt(0).toUpperCase() + key.slice(1); var addFunc, getFunc; if (key !== "week" && key !== "month" && key !== "timezone" && key !== "timezoneOffset") { name += "s"; } addFunc = "add" + name; getFunc = "get" + name; if (key === "month") { addFunc = addFunc + "s"; } else if (key === "year"){ getFunc = "getFullYear"; } if (key !== "day" && key !== "timezone" && key !== "timezoneOffset" && key !== "week" && key !== "hour") { this[addFunc](config[key] - this[getFunc]()); } else if ( key === "timezone"|| key === "timezoneOffset" || key === "week" || key === "hour") { this["set"+name](config[key]); } } } // day has to go last because you can't validate the day without first knowing the month if (config.day) { this.addDays(config.day - this.getDate()); } return this; }; /** * Moves the date to the first day of the month. * @return {Date} this */ $P.moveToFirstDayOfMonth = function () { return this.set({ day: 1 }); }; /** * Moves the date to the last day of the month. * @return {Date} this */ $P.moveToLastDayOfMonth = function () { return this.set({ day: $D.getDaysInMonth(this.getFullYear(), this.getMonth())}); }; /** * Converts the value of the current Date object to its equivalent string representation. * Format Specifiers * CUSTOM DATE AND TIME FORMAT STRINGS * Format Description Example * ------ --------------------------------------------------------------------------- ----------------------- * s The seconds of the minute between 0-59. "0" to "59" * ss The seconds of the minute with leading zero if required. "00" to "59" * * m The minute of the hour between 0-59. "0" or "59" * mm The minute of the hour with leading zero if required. "00" or "59" * * h The hour of the day between 1-12. "1" to "12" * hh The hour of the day with leading zero if required. "01" to "12" * * H The hour of the day between 0-23. "0" to "23" * HH The hour of the day with leading zero if required. "00" to "23" * * d The day of the month between 1 and 31. "1" to "31" * dd The day of the month with leading zero if required. "01" to "31" * ddd Abbreviated day name. Date.CultureInfo.abbreviatedDayNames. "Mon" to "Sun" * dddd The full day name. Date.CultureInfo.dayNames. "Monday" to "Sunday" * * M The month of the year between 1-12. "1" to "12" * MM The month of the year with leading zero if required. "01" to "12" * MMM Abbreviated month name. Date.CultureInfo.abbreviatedMonthNames. "Jan" to "Dec" * MMMM The full month name. Date.CultureInfo.monthNames. "January" to "December" * * yy The year as a two-digit number. "99" or "08" * yyyy The full four digit year. "1999" or "2008" * * t Displays the first character of the A.M./P.M. designator. "A" or "P" * Date.CultureInfo.amDesignator or Date.CultureInfo.pmDesignator * tt Displays the A.M./P.M. designator. "AM" or "PM" * Date.CultureInfo.amDesignator or Date.CultureInfo.pmDesignator * * S The ordinal suffix ("st, "nd", "rd" or "th") of the current day. "st, "nd", "rd" or "th" * * STANDARD DATE AND TIME FORMAT STRINGS * Format Description Example *------ --------------------------------------------------------------------------- ----------------------- * d The CultureInfo shortDate Format Pattern "M/d/yyyy" * D The CultureInfo longDate Format Pattern "dddd, MMMM dd, yyyy" * F The CultureInfo fullDateTime Format Pattern "dddd, MMMM dd, yyyy h:mm:ss tt" * m The CultureInfo monthDay Format Pattern "MMMM dd" * r The CultureInfo rfc1123 Format Pattern "ddd, dd MMM yyyy HH:mm:ss GMT" * s The CultureInfo sortableDateTime Format Pattern "yyyy-MM-ddTHH:mm:ss" * t The CultureInfo shortTime Format Pattern "h:mm tt" * T The CultureInfo longTime Format Pattern "h:mm:ss tt" * u The CultureInfo universalSortableDateTime Format Pattern "yyyy-MM-dd HH:mm:ssZ" * y The CultureInfo yearMonth Format Pattern "MMMM, yyyy" * * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @return {String} A string representation of the current Date object. */ var ord = function (n) { switch (n * 1) { case 1: case 21: case 31: return "st"; case 2: case 22: return "nd"; case 3: case 23: return "rd"; default: return "th"; } }; var parseStandardFormats = function (format) { var y, c = Date.CultureInfo.formatPatterns; switch (format) { case "d": return this.toString(c.shortDate); case "D": return this.toString(c.longDate); case "F": return this.toString(c.fullDateTime); case "m": return this.toString(c.monthDay); case "r": case "R": y = this.clone().addMinutes(this.getTimezoneOffset()); return y.toString(c.rfc1123) + " GMT"; case "s": return this.toString(c.sortableDateTime); case "t": return this.toString(c.shortTime); case "T": return this.toString(c.longTime); case "u": y = this.clone().addMinutes(this.getTimezoneOffset()); return y.toString(c.universalSortableDateTime); case "y": return this.toString(c.yearMonth); default: return false; } }; var parseFormatStringsClosure = function (context) { return function (m) { if (m.charAt(0) === "\\") { return m.replace("\\", ""); } switch (m) { case "hh": return p(context.getHours() < 13 ? (context.getHours() === 0 ? 12 : context.getHours()) : (context.getHours() - 12)); case "h": return context.getHours() < 13 ? (context.getHours() === 0 ? 12 : context.getHours()) : (context.getHours() - 12); case "HH": return p(context.getHours()); case "H": return context.getHours(); case "mm": return p(context.getMinutes()); case "m": return context.getMinutes(); case "ss": return p(context.getSeconds()); case "s": return context.getSeconds(); case "yyyy": return p(context.getFullYear(), 4); case "yy": return p(context.getFullYear()); case "y": return context.getFullYear(); case "E": case "dddd": return Date.CultureInfo.dayNames[context.getDay()]; case "ddd": return Date.CultureInfo.abbreviatedDayNames[context.getDay()]; case "dd": return p(context.getDate()); case "d": return context.getDate(); case "MMMM": return Date.CultureInfo.monthNames[context.getMonth()]; case "MMM": return Date.CultureInfo.abbreviatedMonthNames[context.getMonth()]; case "MM": return p((context.getMonth() + 1)); case "M": return context.getMonth() + 1; case "t": return context.getHours() < 12 ? Date.CultureInfo.amDesignator.substring(0, 1) : Date.CultureInfo.pmDesignator.substring(0, 1); case "tt": return context.getHours() < 12 ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator; case "S": return ord(context.getDate()); case "W": return context.getWeek(); case "WW": return context.getISOWeek(); case "Q": return "Q" + context.getQuarter(); case "q": return String(context.getQuarter()); case "z": return context.getTimezone(); case "Z": case "X": return Date.getTimezoneOffset(context.getTimezone()); case "ZZ": // Timezone offset in seconds return context.getTimezoneOffset() * -60; case "u": return context.getDay(); case "L": return ($D.isLeapYear(context.getFullYear())) ? 1 : 0; case "B": // Swatch Internet Time (.beats) return "@"+((context.getUTCSeconds() + (context.getUTCMinutes()*60) + ((context.getUTCHours()+1)*3600))/86.4); default: return m; } }; }; $P.toString = function (format, ignoreStandards) { // Standard Date and Time Format Strings. Formats pulled from CultureInfo file and // may vary by culture. if (!ignoreStandards && format && format.length === 1) { output = parseStandardFormats.call(this, format); if (output) { return output; } } var parseFormatStrings = parseFormatStringsClosure(this); return format ? format.replace(/((\\)?(dd?d?d?|MM?M?M?|yy?y?y?|hh?|HH?|mm?|ss?|tt?|S|q|Q|WW?W?W?)(?![^\[]*\]))/g, parseFormatStrings).replace(/\[|\]/g, "") : this._toString(); }; }()); /************************************************************* * SugarPak - Domain Specific Language - Syntactical Sugar * *************************************************************/ (function () { var $D = Date, $P = $D.prototype, $N = Number.prototype; // private $P._orient = +1; // private $P._nth = null; // private $P._is = false; // private $P._same = false; // private $P._isSecond = false; // private $N._dateElement = "days"; /** * Moves the date to the next instance of a date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.today().next().friday();
	Date.today().next().fri();
	Date.today().next().march();
	Date.today().next().mar();
	Date.today().next().week();
	
* * @return {Date} date */ $P.next = function () { this._move = true; this._orient = +1; return this; }; /** * Creates a new Date (Date.today()) and moves the date to the next instance of the date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.next().friday();
	Date.next().fri();
	Date.next().march();
	Date.next().mar();
	Date.next().week();
	
* * @return {Date} date */ $D.next = function () { return $D.today().next(); }; /** * Moves the date to the previous instance of a date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.today().last().friday();
	Date.today().last().fri();
	Date.today().last().march();
	Date.today().last().mar();
	Date.today().last().week();
	
* * @return {Date} date */ $P.last = $P.prev = $P.previous = function () { this._move = true; this._orient = -1; return this; }; /** * Creates a new Date (Date.today()) and moves the date to the previous instance of the date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.last().friday();
	Date.last().fri();
	Date.previous().march();
	Date.prev().mar();
	Date.last().week();
	
* * @return {Date} date */ $D.last = $D.prev = $D.previous = function () { return $D.today().last(); }; /** * Performs a equality check when followed by either a month name, day name or .weekday() function. * Example

	Date.today().is().friday(); // true|false
	Date.today().is().fri();
	Date.today().is().march();
	Date.today().is().mar();
	
* * @return {Boolean} true|false */ $P.is = function () { this._is = true; return this; }; /** * Determines if two date objects occur on/in exactly the same instance of the subsequent date part function. * The function .same() must be followed by a date part function (example: .day(), .month(), .year(), etc). * * An optional Date can be passed in the date part function. If now date is passed as a parameter, 'Now' is used. * * The following example demonstrates how to determine if two dates fall on the exact same day. * * Example

	var d1 = Date.today(); // today at 00:00
	var d2 = new Date();   // exactly now.

	// Do they occur on the same day?
	d1.same().day(d2); // true
	
	// Do they occur on the same hour?
	d1.same().hour(d2); // false, unless d2 hour is '00' (midnight).
	
	// What if it's the same day, but one year apart?
	var nextYear = Date.today().add(1).year();

	d1.same().day(nextYear); // false, because the dates must occur on the exact same day. 
	
* * Scenario: Determine if a given date occurs during some week period 2 months from now. * * Example

	var future = Date.today().add(2).months();
	return someDate.same().week(future); // true|false;
	
* * @return {Boolean} true|false */ $P.same = function () { this._same = true; this._isSecond = false; return this; }; /** * Determines if the current date/time occurs during Today. Must be preceded by the .is() function. * Example

	someDate.is().today();    // true|false
	new Date().is().today();  // true
	Date.today().is().today();// true
	Date.today().add(-1).day().is().today(); // false
	
* * @return {Boolean} true|false */ $P.today = function () { return this.same().day(); }; /** * Determines if the current date is a weekday. This function must be preceded by the .is() function. * Example

	Date.today().is().weekday(); // true|false
	
* * @return {Boolean} true|false */ $P.weekday = function () { if (this._nth) { return df("Weekday").call(this); } if (this._move) { return this.addWeekdays(this._orient); } if (this._is) { this._is = false; return (!this.is().sat() && !this.is().sun()); } return false; }; /** * Determines if the current date is on the weekend. This function must be preceded by the .is() function. * Example

	Date.today().is().weekend(); // true|false
	
* * @return {Boolean} true|false */ $P.weekend = function () { if (this._is) { this._is = false; return (this.is().sat() || this.is().sun()); } return false; }; /** * Sets the Time of the current Date instance. A string "6:15 pm" or config object {hour:18, minute:15} are accepted. * Example

	// Set time to 6:15pm with a String
	Date.today().at("6:15pm");

	// Set time to 6:15pm with a config object
	Date.today().at({hour:18, minute:15});
	
* * @return {Date} date */ $P.at = function (time) { return (typeof time === "string") ? $D.parse(this.toString("d") + " " + time) : this.set(time); }; /** * Creates a new Date() and adds this (Number) to the date based on the preceding date element function (eg. second|minute|hour|day|month|year). * Example

	// Undeclared Numbers must be wrapped with parentheses. Requirment of JavaScript.
	(3).days().fromNow();
	(6).months().fromNow();

	// Declared Number variables do not require parentheses. 
	var n = 6;
	n.months().fromNow();
	
* * @return {Date} A new Date instance */ $N.fromNow = $N.after = function (date) { var c = {}; c[this._dateElement] = this; return ((!date) ? new Date() : date.clone()).add(c); }; /** * Creates a new Date() and subtract this (Number) from the date based on the preceding date element function (eg. second|minute|hour|day|month|year). * Example

	// Undeclared Numbers must be wrapped with parentheses. Requirment of JavaScript.
	(3).days().ago();
	(6).months().ago();

	// Declared Number variables do not require parentheses. 
	var n = 6;
	n.months().ago();
	
* * @return {Date} A new Date instance */ $N.ago = $N.before = function (date) { var c = {}, s = (this._dateElement[this._dateElement.length-1] !== "s") ? this._dateElement + "s" : this._dateElement; c[s] = this * -1; return ((!date) ? new Date() : date.clone()).add(c); }; // Do NOT modify the following string tokens. These tokens are used to build dynamic functions. // All culture-specific strings can be found in the CultureInfo files. var dx = ("sunday monday tuesday wednesday thursday friday saturday").split(/\s/), mx = ("january february march april may june july august september october november december").split(/\s/), px = ("Millisecond Second Minute Hour Day Week Month Year Quarter Weekday").split(/\s/), pxf = ("Milliseconds Seconds Minutes Hours Date Week Month FullYear Quarter").split(/\s/), nth = ("final first second third fourth fifth").split(/\s/), de; /** * Returns an object literal of all the date parts. * Example

	var o = new Date().toObject();
	
	// { year: 2008, month: 4, week: 20, day: 13, hour: 18, minute: 9, second: 32, millisecond: 812 }
	
	// The object properties can be referenced directly from the object.
	
	alert(o.day);  // alerts "13"
	alert(o.year); // alerts "2008"
	
* * @return {Date} An object literal representing the original date object. */ $P.toObject = function () { var o = {}; for (var i = 0; i < px.length; i++) { if (this["get" + pxf[i]]) { o[px[i].toLowerCase()] = this["get" + pxf[i]](); } } return o; }; /** * Returns a date created from an object literal. Ignores the .week property if set in the config. * Example

	var o = new Date().toObject();
	
	return Date.fromObject(o); // will return the same date. 

	var o2 = {month: 1, day: 20, hour: 18}; // birthday party!
	Date.fromObject(o2);
	
* * @return {Date} An object literal representing the original date object. */ $D.fromObject = function(config) { config.week = null; return Date.today().set(config); }; // Create day name functions and abbreviated day name functions (eg. monday(), friday(), fri()). var df = function (n) { return function () { if (this._is) { this._is = false; return this.getDay() === n; } if (this._move) { this._move = null; } if (this._nth !== null) { // If the .second() function was called earlier, remove the _orient // from the date, and then continue. // This is required because 'second' can be used in two different context. // // Example // // Date.today().add(1).second(); // Date.march().second().monday(); // // Things get crazy with the following... // Date.march().add(1).second().second().monday(); // but it works!! // if (this._isSecond) { this.addSeconds(this._orient * -1); } // make sure we reset _isSecond this._isSecond = false; var ntemp = this._nth; this._nth = null; var temp = this.clone().moveToLastDayOfMonth(); this.moveToNthOccurrence(n, ntemp); if (this > temp) { throw new RangeError($D.getDayName(n) + " does not occur " + ntemp + " times in the month of " + $D.getMonthName(temp.getMonth()) + " " + temp.getFullYear() + "."); } return this; } return this.moveToDayOfWeek(n, this._orient); }; }; var sdf = function (n) { return function () { var t = $D.today(), shift = n - t.getDay(); if (n === 0 && Date.CultureInfo.firstDayOfWeek === 1 && t.getDay() !== 0) { shift = shift + 7; } return t.addDays(shift); }; }; // Create month name functions and abbreviated month name functions (eg. january(), march(), mar()). var month_instance_functions = function (n) { return function () { if (this._is) { this._is = false; return this.getMonth() === n; } return this.moveToMonth(n, this._orient); }; }; var month_static_functions = function (n) { return function () { return $D.today().set({ month: n, day: 1 }); }; }; var processTerms = function (names, staticFunc, instanceFunc) { for (var i = 0; i < names.length; i++) { // Create constant static Name variables. $D[names[i].toUpperCase()] = $D[names[i].toUpperCase().substring(0, 3)] = i; // Create Name functions. $D[names[i]] = $D[names[i].substring(0, 3)] = staticFunc(i); // Create Name instance functions. $P[names[i]] = $P[names[i].substring(0, 3)] = instanceFunc(i); } }; processTerms(dx, sdf, df); processTerms(mx, month_static_functions, month_instance_functions); // Create date element functions and plural date element functions used with Date (eg. day(), days(), months()). var ef = function (j) { return function () { // if the .second() function was called earlier, the _orient // has alread been added. Just return this and reset _isSecond. if (this._isSecond) { this._isSecond = false; return this; } if (this._same) { this._same = this._is = false; var o1 = this.toObject(), o2 = (arguments[0] || new Date()).toObject(), v = "", k = j.toLowerCase(); // the substr trick with -1 doesn't work in IE8 or less k = (k[k.length-1] === "s") ? k.substring(0,k.length-1) : k; for (var m = (px.length - 1); m > -1; m--) { v = px[m].toLowerCase(); if (o1[v] !== o2[v]) { return false; } if (k === v) { break; } } return true; } if (j.substring(j.length - 1) !== "s") { j += "s"; } if (this._move) { this._move = null; } return this["add" + j](this._orient); }; }; var nf = function (n) { return function () { this._dateElement = n; return this; }; }; for (var k = 0; k < px.length; k++) { de = px[k].toLowerCase(); if(de !== "weekday") { // Create date element functions and plural date element functions used with Date (eg. day(), days(), months()). $P[de] = $P[de + "s"] = ef(px[k]); // Create date element functions and plural date element functions used with Number (eg. day(), days(), months()). $N[de] = $N[de + "s"] = nf(de + "s"); } } $P._ss = ef("Second"); var nthfn = function (n) { return function (dayOfWeek) { if (this._same) { return this._ss(arguments[0]); } if (dayOfWeek || dayOfWeek === 0) { return this.moveToNthOccurrence(dayOfWeek, n); } this._nth = n; // if the operator is 'second' add the _orient, then deal with it later... if (n === 2 && (dayOfWeek === undefined || dayOfWeek === null)) { this._isSecond = true; return this.addSeconds(this._orient); } return this; }; }; for (var l = 0; l < nth.length; l++) { $P[nth[l]] = (l === 0) ? nthfn(-1) : nthfn(l); } }()); (function () { "use strict"; Date.Parsing = { Exception: function (s) { this.message = "Parse error at '" + s.substring(0, 10) + " ...'"; } }; var $P = Date.Parsing; var dayOffsets = { standard: [0,31,59,90,120,151,181,212,243,273,304,334], leap: [0,31,60,91,121,152,182,213,244,274,305,335] }; $P.isLeapYear = function(year) { return ((year % 4 === 0) && (year % 100 !== 0)) || (year % 400 === 0); }; var utils = { multiReplace : function (str, hash ) { var key; for (key in hash) { if (Object.prototype.hasOwnProperty.call(hash, key)) { var regex; if (typeof hash[key] === "function") { } else { regex = (hash[key] instanceof RegExp) ? hash[key] : new RegExp(hash[key], "g"); } str = str.replace(regex, key); } } return str; }, getDayOfYearFromWeek : function (obj) { var d, jan4, offset; obj.weekDay = (!obj.weekDay && obj.weekDay !== 0) ? 1 : obj.weekDay; d = new Date(obj.year, 0, 4); jan4 = d.getDay() === 0 ? 7 : d.getDay(); // JS is 0 indexed on Sunday. offset = jan4+3; obj.dayOfYear = ((obj.week * 7) + (obj.weekDay === 0 ? 7 : obj.weekDay))-offset; return obj; }, getDayOfYear : function (obj, dayOffset) { if (!obj.dayOfYear) { obj = utils.getDayOfYearFromWeek(obj); } for (var i=0;i <= dayOffset.length;i++) { if (obj.dayOfYear < dayOffset[i] || i === dayOffset.length) { obj.day = obj.day ? obj.day : (obj.dayOfYear - dayOffset[i-1]); break; } else { obj.month = i; } } return obj; }, adjustForTimeZone : function (obj, date) { var offset; if (obj.zone.toUpperCase() === "Z" || (obj.zone_hours === 0 && obj.zone_minutes === 0)) { // it's UTC/GML so work out the current timeszone offset offset = -date.getTimezoneOffset(); } else { offset = (obj.zone_hours*60) + (obj.zone_minutes || 0); if (obj.zone_sign === "+") { offset *= -1; } offset -= date.getTimezoneOffset(); } date.setMinutes(date.getMinutes()+offset); return date; }, setDefaults : function (obj) { obj.year = obj.year || Date.today().getFullYear(); obj.hours = obj.hours || 0; obj.minutes = obj.minutes || 0; obj.seconds = obj.seconds || 0; obj.milliseconds = obj.milliseconds || 0; if (!(!obj.month && (obj.week || obj.dayOfYear))) { // if we have a month, or if we don't but don't have the day calculation data obj.month = obj.month || 0; obj.day = obj.day || 1; } return obj; }, dataNum: function (data, mod, explict, postProcess) { var dataNum = data*1; if (mod) { if (postProcess) { return data ? mod(data)*1 : data; } else { return data ? mod(dataNum) : data; } } else if (!explict){ return data ? dataNum : data; } else { return (data && typeof data !== "undefined") ? dataNum : data; } }, timeDataProcess: function (obj) { var timeObj = {}; for (var x in obj.data) { if (obj.data.hasOwnProperty(x)) { timeObj[x] = obj.ignore[x] ? obj.data[x] : utils.dataNum(obj.data[x], obj.mods[x], obj.explict[x], obj.postProcess[x]); } } if (obj.data.secmins) { obj.data.secmins = obj.data.secmins.replace(",", ".") * 60; if (!timeObj.minutes) { timeObj.minutes = obj.data.secmins; } else if (!timeObj.seconds) { timeObj.seconds = obj.data.secmins; } delete obj.secmins; } return timeObj; }, buildTimeObjectFromData: function (data) { var time = utils.timeDataProcess({ data: { year : data[1], month : data[5], day : data[7], week : data[8], dayOfYear : data[10], hours : data[15], zone_hours : data[23], zone_minutes : data[24], zone : data[21], zone_sign : data[22], weekDay : data[9], minutes: data[16], seconds: data[19], milliseconds: data[20], secmins: data[18] }, mods: { month: function(data) { return data-1; }, weekDay: function (data) { data = Math.abs(data); return (data === 7 ? 0 : data); }, minutes: function (data) { return data.replace(":",""); }, seconds: function (data) { return Math.floor( (data.replace(":","").replace(",","."))*1 ); }, milliseconds: function (data) { return (data.replace(",",".")*1000); } }, postProcess: { minutes: true, seconds: true, milliseconds: true }, explict: { zone_hours: true, zone_minutes: true }, ignore: { zone: true, zone_sign: true, secmins: true } }); return time; }, addToHash: function (hash, keys, data) { keys = keys; data = data; var len = keys.length; for (var i = 0; i < len; i++) { hash[keys[i]] = data[i]; } return hash; }, combineRegex: function (r1, r2) { return new RegExp("(("+r1.source+")\\s("+r2.source+"))"); }, getDateNthString: function(add, last, inc){ if (add) { return Date.today().addDays(inc).toString("d"); } else if (last) { return Date.today().last()[inc]().toString("d"); } }, buildRegexData: function (array) { var arr = []; var len = array.length; for (var i=0; i < len; i++) { if (Object.prototype.toString.call(array[i]) === '[object Array]') { // oldIE compat version of Array.isArray arr.push(this.combineRegex(array[i][0], array[i][1])); } else { arr.push(array[i]); } } return arr; } }; $P.processTimeObject = function (obj) { var date, dayOffset; utils.setDefaults(obj); dayOffset = ($P.isLeapYear(obj.year)) ? dayOffsets.leap : dayOffsets.standard; if (!obj.month && (obj.week || obj.dayOfYear)) { utils.getDayOfYear(obj, dayOffset); } else { obj.dayOfYear = dayOffset[obj.month] + obj.day; } date = new Date(obj.year, obj.month, obj.day, obj.hours, obj.minutes, obj.seconds, obj.milliseconds); if (obj.zone) { utils.adjustForTimeZone(obj, date); // adjust (and calculate) for timezone } return date; }; $P.ISO = { regex : /^([\+-]?\d{4}(?!\d{2}\b))((-?)((0[1-9]|1[0-2])(\3([12]\d|0[1-9]|3[01]))?|W([0-4]\d|5[0-3])(-?[1-7])?|(00[1-9]|0[1-9]\d|[12]\d{2}|3([0-5]\d|6[1-6])))([T\s]((([01]\d|2[0-4])((:?)[0-5]\d)?|24\:?00)([\.,]\d+(?!:))?)?(\17[0-5]\d([\.,]\d+)?)?\s?([zZ]|([\+-])([01]\d|2[0-3]):?([0-5]\d)?)?)?)?$/, parse : function (s) { var time, data = s.match(this.regex); if (!data || !data.length) { return null; } time = utils.buildTimeObjectFromData(data); if (!time.year || (!time.year && (!time.month && !time.day) && (!time.week && !time.dayOfYear)) ) { return null; } return $P.processTimeObject(time); } }; $P.Numeric = { isNumeric: function (e){return!isNaN(parseFloat(e))&&isFinite(e);}, regex: /\b([0-1]?[0-9])([0-3]?[0-9])([0-2]?[0-9]?[0-9][0-9])\b/i, parse: function (s) { var data, i, time = {}, order = Date.CultureInfo.dateElementOrder.split(""); if (!(this.isNumeric(s)) || // if it's non-numeric OR (s[0] === "+" && s[0] === "-")) { // It's an arithmatic string (eg +/-1000) return null; } if (s.length < 5 && s.indexOf(".") < 0 && s.indexOf("/") < 0) { // assume it's just a year. time.year = s; return $P.processTimeObject(time); } data = s.match(this.regex); if (!data || !data.length) { return null; } for (i=0; i < order.length; i++) { switch(order[i]) { case "d": time.day = data[i+1]; break; case "m": time.month = (data[i+1]-1); break; case "y": time.year = data[i+1]; break; } } return $P.processTimeObject(time); } }; $P.Normalizer = { regexData: function () { var $R = Date.CultureInfo.regexPatterns; return utils.buildRegexData([ $R.tomorrow, $R.yesterday, [$R.past, $R.mon], [$R.past, $R.tue], [$R.past, $R.wed], [$R.past, $R.thu], [$R.past, $R.fri], [$R.past, $R.sat], [$R.past, $R.sun] ]); }, basicReplaceHash : function() { var $R = Date.CultureInfo.regexPatterns; return { "January": $R.jan.source, "February": $R.feb, "March": $R.mar, "April": $R.apr, "May": $R.may, "June": $R.jun, "July": $R.jul, "August": $R.aug, "September": $R.sep, "October": $R.oct, "November": $R.nov, "December": $R.dec, "": /\bat\b/gi, " ": /\s{2,}/, "am": $R.inTheMorning, "9am": $R.thisMorning, "pm": $R.inTheEvening, "7pm":$R.thisEvening }; }, keys : function(){ return [ utils.getDateNthString(true, false, 1), // tomorrow utils.getDateNthString(true, false, -1), // yesterday utils.getDateNthString(false, true, "monday"), //last mon utils.getDateNthString(false, true, "tuesday"), //last tues utils.getDateNthString(false, true, "wednesday"), //last wed utils.getDateNthString(false, true, "thursday"), //last thurs utils.getDateNthString(false, true, "friday"), //last fri utils.getDateNthString(false, true, "saturday"), //last sat utils.getDateNthString(false, true, "sunday") //last sun ]; }, buildRegexFunctions: function () { var $R = Date.CultureInfo.regexPatterns; var __ = Date.i18n.__; var tomorrowRE = new RegExp("(\\b\\d\\d?("+__("AM")+"|"+__("PM")+")? )("+$R.tomorrow.source.slice(1)+")", "i"); // adapted tomorrow regex for AM PM relative dates var todayRE = new RegExp($R.today.source + "(?!\\s*([+-]))\\b"); // today, but excludes the math operators (eg "today + 2h") this.replaceFuncs = [ [todayRE, function (full) { return (full.length > 1) ? Date.today().toString("d") : full; }], [tomorrowRE, function(full, m1) { var t = Date.today().addDays(1).toString("d"); return (t + " " + m1); }], [$R.amThisMorning, function(str, am){return am;}], [$R.pmThisEvening, function(str, pm){return pm;}] ]; }, buildReplaceData: function () { this.buildRegexFunctions(); this.replaceHash = utils.addToHash(this.basicReplaceHash(), this.keys(), this.regexData()); }, stringReplaceFuncs: function (s) { for (var i=0; i < this.replaceFuncs.length; i++) { s = s.replace(this.replaceFuncs[i][0], this.replaceFuncs[i][1]); } return s; }, parse: function (s) { s = this.stringReplaceFuncs(s); s = utils.multiReplace(s, this.replaceHash); try { var n = s.split(/([\s\-\.\,\/\x27]+)/); if (n.length === 3 && $P.Numeric.isNumeric(n[0]) && $P.Numeric.isNumeric(n[2]) && (n[2].length >= 4)) { // ok, so we're dealing with x/year. But that's not a full date. // This fixes wonky dateElementOrder parsing when set to dmy order. if (Date.CultureInfo.dateElementOrder[0] === "d") { s = "1/" + n[0] + "/" + n[2]; // set to 1st of month and normalize the seperator } } } catch (e) {} return s; } }; $P.Normalizer.buildReplaceData(); }()); (function () { var $P = Date.Parsing; var _ = $P.Operators = { // // Tokenizers // rtoken: function (r) { // regex token return function (s) { var mx = s.match(r); if (mx) { return ([ mx[0], s.substring(mx[0].length) ]); } else { throw new $P.Exception(s); } }; }, token: function () { // whitespace-eating token return function (s) { return _.rtoken(new RegExp("^\\s*" + s + "\\s*"))(s); }; }, stoken: function (s) { // string token return _.rtoken(new RegExp("^" + s)); }, // Atomic Operators until: function (p) { return function (s) { var qx = [], rx = null; while (s.length) { try { rx = p.call(this, s); } catch (e) { qx.push(rx[0]); s = rx[1]; continue; } break; } return [ qx, s ]; }; }, many: function (p) { return function (s) { var rx = [], r = null; while (s.length) { try { r = p.call(this, s); } catch (e) { return [ rx, s ]; } rx.push(r[0]); s = r[1]; } return [ rx, s ]; }; }, // generator operators -- see below optional: function (p) { return function (s) { var r = null; try { r = p.call(this, s); } catch (e) { return [ null, s ]; } return [ r[0], r[1] ]; }; }, not: function (p) { return function (s) { try { p.call(this, s); } catch (e) { return [null, s]; } throw new $P.Exception(s); }; }, ignore: function (p) { return p ? function (s) { var r = null; r = p.call(this, s); return [null, r[1]]; } : null; }, product: function () { var px = arguments[0], qx = Array.prototype.slice.call(arguments, 1), rx = []; for (var i = 0 ; i < px.length ; i++) { rx.push(_.each(px[i], qx)); } return rx; }, cache: function (rule) { var cache = {}, cache_length = 0, cache_keys = [], CACHE_MAX = Date.Config.CACHE_MAX || 100000, r = null; var cacheCheck = function () { if (cache_length === CACHE_MAX) { // kill several keys, don't want to have to do this all the time... for (var i=0; i < 10; i++) { var key = cache_keys.shift(); if (key) { delete cache[key]; cache_length--; } } } }; return function (s) { cacheCheck(); try { r = cache[s] = (cache[s] || rule.call(this, s)); } catch (e) { r = cache[s] = e; } cache_length++; cache_keys.push(s); if (r instanceof $P.Exception) { throw r; } else { return r; } }; }, // vector operators -- see below any: function () { var px = arguments; return function (s) { var r = null; for (var i = 0; i < px.length; i++) { if (px[i] == null) { continue; } try { r = (px[i].call(this, s)); } catch (e) { r = null; } if (r) { return r; } } throw new $P.Exception(s); }; }, each: function () { var px = arguments; return function (s) { var rx = [], r = null; for (var i = 0; i < px.length ; i++) { if (px[i] == null) { continue; } try { r = (px[i].call(this, s)); } catch (e) { throw new $P.Exception(s); } rx.push(r[0]); s = r[1]; } return [ rx, s]; }; }, all: function () { var px = arguments, _ = _; return _.each(_.optional(px)); }, // delimited operators sequence: function (px, d, c) { d = d || _.rtoken(/^\s*/); c = c || null; if (px.length === 1) { return px[0]; } return function (s) { var r = null, q = null; var rx = []; for (var i = 0; i < px.length ; i++) { try { r = px[i].call(this, s); } catch (e) { break; } rx.push(r[0]); try { q = d.call(this, r[1]); } catch (ex) { q = null; break; } s = q[1]; } if (!r) { throw new $P.Exception(s); } if (q) { throw new $P.Exception(q[1]); } if (c) { try { r = c.call(this, r[1]); } catch (ey) { throw new $P.Exception(r[1]); } } return [ rx, (r?r[1]:s) ]; }; }, // // Composite Operators // between: function (d1, p, d2) { d2 = d2 || d1; var _fn = _.each(_.ignore(d1), p, _.ignore(d2)); return function (s) { var rx = _fn.call(this, s); return [[rx[0][0], r[0][2]], rx[1]]; }; }, list: function (p, d, c) { d = d || _.rtoken(/^\s*/); c = c || null; return (p instanceof Array ? _.each(_.product(p.slice(0, -1), _.ignore(d)), p.slice(-1), _.ignore(c)) : _.each(_.many(_.each(p, _.ignore(d))), px, _.ignore(c))); }, set: function (px, d, c) { d = d || _.rtoken(/^\s*/); c = c || null; return function (s) { // r is the current match, best the current 'best' match // which means it parsed the most amount of input var r = null, p = null, q = null, rx = null, best = [[], s], last = false; // go through the rules in the given set for (var i = 0; i < px.length ; i++) { // last is a flag indicating whether this must be the last element // if there is only 1 element, then it MUST be the last one q = null; p = null; r = null; last = (px.length === 1); // first, we try simply to match the current pattern // if not, try the next pattern try { r = px[i].call(this, s); } catch (e) { continue; } // since we are matching against a set of elements, the first // thing to do is to add r[0] to matched elements rx = [[r[0]], r[1]]; // if we matched and there is still input to parse and // we don't already know this is the last element, // we're going to next check for the delimiter ... // if there's none, or if there's no input left to parse // than this must be the last element after all ... if (r[1].length > 0 && ! last) { try { q = d.call(this, r[1]); } catch (ex) { last = true; } } else { last = true; } // if we parsed the delimiter and now there's no more input, // that means we shouldn't have parsed the delimiter at all // so don't update r and mark this as the last element ... if (!last && q[1].length === 0) { last = true; } // so, if this isn't the last element, we're going to see if // we can get any more matches from the remaining (unmatched) // elements ... if (!last) { // build a list of the remaining rules we can match against, // i.e., all but the one we just matched against var qx = []; for (var j = 0; j < px.length ; j++) { if (i !== j) { qx.push(px[j]); } } // now invoke recursively set with the remaining input // note that we don't include the closing delimiter ... // we'll check for that ourselves at the end p = _.set(qx, d).call(this, q[1]); // if we got a non-empty set as a result ... // (otw rx already contains everything we want to match) if (p[0].length > 0) { // update current result, which is stored in rx ... // basically, pick up the remaining text from p[1] // and concat the result from p[0] so that we don't // get endless nesting ... rx[0] = rx[0].concat(p[0]); rx[1] = p[1]; } } // at this point, rx either contains the last matched element // or the entire matched set that starts with this element. // now we just check to see if this variation is better than // our best so far, in terms of how much of the input is parsed if (rx[1].length < best[1].length) { best = rx; } // if we've parsed all the input, then we're finished if (best[1].length === 0) { break; } } // so now we've either gone through all the patterns trying them // as the initial match; or we found one that parsed the entire // input string ... // if best has no matches, just return empty set ... if (best[0].length === 0) { return best; } // if a closing delimiter is provided, then we have to check it also if (c) { // we try this even if there is no remaining input because the pattern // may well be optional or match empty input ... try { q = c.call(this, best[1]); } catch (ey) { throw new $P.Exception(best[1]); } // it parsed ... be sure to update the best match remaining input best[1] = q[1]; } // if we're here, either there was no closing delimiter or we parsed it // so now we have the best match; just return it! return best; }; }, forward: function (gr, fname) { return function (s) { return gr[fname].call(this, s); }; }, // // Translation Operators // replace: function (rule, repl) { return function (s) { var r = rule.call(this, s); return [repl, r[1]]; }; }, process: function (rule, fn) { return function (s) { var r = rule.call(this, s); return [fn.call(this, r[0]), r[1]]; }; }, min: function (min, rule) { return function (s) { var rx = rule.call(this, s); if (rx[0].length < min) { throw new $P.Exception(s); } return rx; }; } }; // Generator Operators And Vector Operators // Generators are operators that have a signature of F(R) => R, // taking a given rule and returning another rule, such as // ignore, which parses a given rule and throws away the result. // Vector operators are those that have a signature of F(R1,R2,...) => R, // take a list of rules and returning a new rule, such as each. // Generator operators are converted (via the following _generator // function) into functions that can also take a list or array of rules // and return an array of new rules as though the function had been // called on each rule in turn (which is what actually happens). // This allows generators to be used with vector operators more easily. // Example: // each(ignore(foo, bar)) instead of each(ignore(foo), ignore(bar)) // This also turns generators into vector operators, which allows // constructs like: // not(cache(foo, bar)) var _generator = function (op) { function gen() { var args = null, rx = [], px, i; if (arguments.length > 1) { args = Array.prototype.slice.call(arguments); } else if (arguments[0] instanceof Array) { args = arguments[0]; } if (args) { px = args.shift(); if (px.length > 0) { args.unshift(px[i]); rx.push(op.apply(null, args)); args.shift(); return rx; } } else { return op.apply(null, arguments); } } return gen; }; var gx = "optional not ignore cache".split(/\s/); for (var i = 0 ; i < gx.length ; i++) { _[gx[i]] = _generator(_[gx[i]]); } var _vector = function (op) { return function () { if (arguments[0] instanceof Array) { return op.apply(null, arguments[0]); } else { return op.apply(null, arguments); } }; }; var vx = "each any all".split(/\s/); for (var j = 0 ; j < vx.length ; j++) { _[vx[j]] = _vector(_[vx[j]]); } }()); (function () { var $D = Date; var flattenAndCompact = function (ax) { var rx = []; for (var i = 0; i < ax.length; i++) { if (ax[i] instanceof Array) { rx = rx.concat(flattenAndCompact(ax[i])); } else { if (ax[i]) { rx.push(ax[i]); } } } return rx; }; var parseMeridian = function () { if (this.meridian && (this.hour || this.hour === 0)) { if (this.meridian === "a" && this.hour > 11 && Date.Config.strict24hr){ throw "Invalid hour and meridian combination"; } else if (this.meridian === "p" && this.hour < 12 && Date.Config.strict24hr){ throw "Invalid hour and meridian combination"; } else if (this.meridian === "p" && this.hour < 12) { this.hour = this.hour + 12; } else if (this.meridian === "a" && this.hour === 12) { this.hour = 0; } } }; var setDefaults = function () { var now = new Date(); if ((this.hour || this.minute) && (!this.month && !this.year && !this.day)) { this.day = now.getDate(); } if (!this.year) { this.year = now.getFullYear(); } if (!this.month && this.month !== 0) { this.month = now.getMonth(); } if (!this.day) { this.day = 1; } if (!this.hour) { this.hour = 0; } if (!this.minute) { this.minute = 0; } if (!this.second) { this.second = 0; } if (!this.millisecond) { this.millisecond = 0; } }; var finishUtils = { getToday: function () { if (this.now || "hour minute second".indexOf(this.unit) !== -1) { return new Date(); } else { return $D.today(); } }, setDaysFromWeekday: function (today, orient){ var gap; orient = orient || 1; this.unit = "day"; gap = ($D.getDayNumberFromName(this.weekday) - today.getDay()); this.days = gap ? ((gap + (orient * 7)) % 7) : (orient * 7); return this; }, setMonthsFromMonth: function (today, orient) { var gap; orient = orient || 1; this.unit = "month"; gap = (this.month - today.getMonth()); this.months = gap ? ((gap + (orient * 12)) % 12) : (orient * 12); this.month = null; return this; }, setDMYFromWeekday: function () { var d = Date[this.weekday](); this.day = d.getDate(); if (!this.month) { this.month = d.getMonth(); } this.year = d.getFullYear(); return this; }, setUnitValue: function (orient) { if (!this.value && this.operator && this.operator !== null && this[this.unit + "s"] && this[this.unit + "s"] !== null) { this[this.unit + "s"] = this[this.unit + "s"] + ((this.operator === "add") ? 1 : -1) + (this.value||0) * orient; } else if (this[this.unit + "s"] == null || this.operator != null) { if (!this.value) { this.value = 1; } this[this.unit + "s"] = this.value * orient; } }, generateDateFromWeeks: function () { var weekday = (this.weekday !== undefined) ? this.weekday : "today"; var d = Date[weekday]().addWeeks(this.weeks); if (this.now) { d.setTimeToNow(); } return d; } }; $D.Translator = { hour: function (s) { return function () { this.hour = Number(s); }; }, minute: function (s) { return function () { this.minute = Number(s); }; }, second: function (s) { return function () { this.second = Number(s); }; }, /* for ss.s format */ secondAndMillisecond: function (s) { return function () { var mx = s.match(/^([0-5][0-9])\.([0-9]{1,3})/); this.second = Number(mx[1]); this.millisecond = Number(mx[2]); }; }, meridian: function (s) { return function () { this.meridian = s.slice(0, 1).toLowerCase(); }; }, timezone: function (s) { return function () { var n = s.replace(/[^\d\+\-]/g, ""); if (n.length) { this.timezoneOffset = Number(n); } else { this.timezone = s.toLowerCase(); } }; }, day: function (x) { var s = x[0]; return function () { this.day = Number(s.match(/\d+/)[0]); if (this.day < 1) { throw "invalid day"; } }; }, month: function (s) { return function () { this.month = (s.length === 3) ? "jan feb mar apr may jun jul aug sep oct nov dec".indexOf(s)/4 : Number(s) - 1; if (this.month < 0) { throw "invalid month"; } }; }, year: function (s) { return function () { var n = Number(s); this.year = ((s.length > 2) ? n : (n + (((n + 2000) < Date.CultureInfo.twoDigitYearMax) ? 2000 : 1900))); }; }, rday: function (s) { return function () { switch (s) { case "yesterday": this.days = -1; break; case "tomorrow": this.days = 1; break; case "today": this.days = 0; break; case "now": this.days = 0; this.now = true; break; } }; }, finishExact: function (x) { var d; x = (x instanceof Array) ? x : [x]; for (var i = 0 ; i < x.length ; i++) { if (x[i]) { x[i].call(this); } } setDefaults.call(this); parseMeridian.call(this); if (this.day > $D.getDaysInMonth(this.year, this.month)) { throw new RangeError(this.day + " is not a valid value for days."); } d = new Date(this.year, this.month, this.day, this.hour, this.minute, this.second, this.millisecond); if (this.year < 100) { d.setFullYear(this.year); // means years less that 100 are process correctly. JS will parse it otherwise as 1900-1999. } if (this.timezone) { d.set({ timezone: this.timezone }); } else if (this.timezoneOffset) { d.set({ timezoneOffset: this.timezoneOffset }); } return d; }, finish: function (x) { var today, expression, orient, temp; x = (x instanceof Array) ? flattenAndCompact(x) : [ x ]; if (x.length === 0) { return null; } for (var i = 0 ; i < x.length ; i++) { if (typeof x[i] === "function") { x[i].call(this); } } if (this.now && !this.unit && !this.operator) { return new Date(); } else { today = finishUtils.getToday.call(this); } expression = !!(this.days && this.days !== null || this.orient || this.operator); orient = ((this.orient === "past" || this.operator === "subtract") ? -1 : 1); if (this.month && this.unit === "week") { this.value = this.month + 1; delete this.month; delete this.day; } if ((this.month || this.month === 0) && "year day hour minute second".indexOf(this.unit) !== -1) { if (!this.value) { this.value = this.month + 1; } this.month = null; expression = true; } if (!expression && this.weekday && !this.day && !this.days) { finishUtils.setDMYFromWeekday.call(this); } if (expression && this.weekday && this.unit !== "month" && this.unit !== "week") { finishUtils.setDaysFromWeekday.call(this, today, orient); } if (this.weekday && this.unit !== "week" && !this.day && !this.days) { temp = Date[this.weekday](); this.day = temp.getDate(); if (temp.getMonth() !== today.getMonth()) { this.month = temp.getMonth(); } } if (this.month && this.unit === "day" && this.operator) { if (!this.value) { this.value = (this.month + 1); } this.month = null; } if (this.value != null && this.month != null && this.year != null) { this.day = this.value * 1; } if (this.month && !this.day && this.value) { today.set({ day: this.value * 1 }); if (!expression) { this.day = this.value * 1; } } if (!this.month && this.value && this.unit === "month" && !this.now) { this.month = this.value; expression = true; } if (expression && (this.month || this.month === 0) && this.unit !== "year") { finishUtils.setMonthsFromMonth.call(this, today, orient); } if (!this.unit) { this.unit = "day"; } finishUtils.setUnitValue.call(this, orient); parseMeridian.call(this); if ((this.month || this.month === 0) && !this.day) { this.day = 1; } if (!this.orient && !this.operator && this.unit === "week" && this.value && !this.day && !this.month) { return Date.today().setWeek(this.value); } if (this.unit === "week" && this.weeks && !this.day && !this.month) { return finishUtils.generateDateFromWeeks.call(this); } if (expression && this.timezone && this.day && this.days) { this.day = this.days; } if (expression){ today.add(this); } else { today.set(this); } if (this.timezone) { this.timezone = this.timezone.toUpperCase(); var offset = $D.getTimezoneOffset(this.timezone); var timezone; if (today.hasDaylightSavingTime()) { // lets check that we're being sane with timezone setting timezone = $D.getTimezoneAbbreviation(offset, today.isDaylightSavingTime()); if (timezone !== this.timezone) { // bugger, we're in a place where things like EST vs EDT matters. if (today.isDaylightSavingTime()) { today.addHours(-1); } else { today.addHours(1); } } } today.setTimezoneOffset(offset); } return today; } }; }()); (function () { var $D = Date; $D.Grammar = {}; var _ = $D.Parsing.Operators, g = $D.Grammar, t = $D.Translator, _fn; // Allow rolling up into general purpose rules _fn = function () { return _.each(_.any.apply(null, arguments), _.not(g.ctoken2("timeContext"))); }; g.datePartDelimiter = _.rtoken(/^([\s\-\.\,\/\x27]+)/); g.timePartDelimiter = _.stoken(":"); g.whiteSpace = _.rtoken(/^\s*/); g.generalDelimiter = _.rtoken(/^(([\s\,]|at|@|on)+)/); var _C = {}; g.ctoken = function (keys) { var fn = _C[keys]; if (! fn) { var c = Date.CultureInfo.regexPatterns; var kx = keys.split(/\s+/), px = []; for (var i = 0; i < kx.length ; i++) { px.push(_.replace(_.rtoken(c[kx[i]]), kx[i])); } fn = _C[keys] = _.any.apply(null, px); } return fn; }; g.ctoken2 = function (key) { return _.rtoken(Date.CultureInfo.regexPatterns[key]); }; var cacheProcessRtoken = function (key, token, type, eachToken) { if (eachToken) { g[key] = _.cache(_.process(_.each(_.rtoken(token),_.optional(g.ctoken2(eachToken))), type)); } else { g[key] = _.cache(_.process(_.rtoken(token), type)); } }; var cacheProcessCtoken = function (token, type) { return _.cache(_.process(g.ctoken2(token), type)); }; var _F = {}; //function cache var _get = function (f) { _F[f] = (_F[f] || g.format(f)[0]); return _F[f]; }; g.allformats = function (fx) { var rx = []; if (fx instanceof Array) { for (var i = 0; i < fx.length; i++) { rx.push(_get(fx[i])); } } else { rx.push(_get(fx)); } return rx; }; g.formats = function (fx) { if (fx instanceof Array) { var rx = []; for (var i = 0 ; i < fx.length ; i++) { rx.push(_get(fx[i])); } return _.any.apply(null, rx); } else { return _get(fx); } }; var grammarFormats = { timeFormats: function(){ var i, RTokenKeys = [ "h", "hh", "H", "HH", "m", "mm", "s", "ss", "ss.s", "z", "zz" ], RToken = [ /^(0[0-9]|1[0-2]|[1-9])/, /^(0[0-9]|1[0-2])/, /^([0-1][0-9]|2[0-3]|[0-9])/, /^([0-1][0-9]|2[0-3])/, /^([0-5][0-9]|[0-9])/, /^[0-5][0-9]/, /^([0-5][0-9]|[0-9])/, /^[0-5][0-9]/, /^[0-5][0-9]\.[0-9]{1,3}/, /^((\+|\-)\s*\d\d\d\d)|((\+|\-)\d\d\:?\d\d)/, /^((\+|\-)\s*\d\d\d\d)|((\+|\-)\d\d\:?\d\d)/ ], tokens = [ t.hour, t.hour, t.hour, t.hour, t.minute, t.minute, t.second, t.second, t.secondAndMillisecond, t.timezone, t.timezone ]; for (i=0; i < RTokenKeys.length; i++) { cacheProcessRtoken(RTokenKeys[i], RToken[i], tokens[i]); } g.hms = _.cache(_.sequence([g.H, g.m, g.s], g.timePartDelimiter)); g.t = cacheProcessCtoken("shortMeridian", t.meridian); g.tt = cacheProcessCtoken("longMeridian", t.meridian); g.zzz = cacheProcessCtoken("timezone", t.timezone); g.timeSuffix = _.each(_.ignore(g.whiteSpace), _.set([ g.tt, g.zzz ])); g.time = _.each(_.optional(_.ignore(_.stoken("T"))), g.hms, g.timeSuffix); }, dateFormats: function () { // pre-loaded rules for different date part order preferences var _setfn = function () { return _.set(arguments, g.datePartDelimiter); }; var i, RTokenKeys = [ "d", "dd", "M", "MM", "y", "yy", "yyy", "yyyy" ], RToken = [ /^([0-2]\d|3[0-1]|\d)/, /^([0-2]\d|3[0-1])/, /^(1[0-2]|0\d|\d)/, /^(1[0-2]|0\d)/, /^(\d+)/, /^(\d\d)/, /^(\d\d?\d?\d?)/, /^(\d\d\d\d)/ ], tokens = [ t.day, t.day, t.month, t.month, t.year, t.year, t.year, t.year ], eachToken = [ "ordinalSuffix", "ordinalSuffix" ]; for (i=0; i < RTokenKeys.length; i++) { cacheProcessRtoken(RTokenKeys[i], RToken[i], tokens[i], eachToken[i]); } g.MMM = g.MMMM = _.cache(_.process(g.ctoken("jan feb mar apr may jun jul aug sep oct nov dec"), t.month)); g.ddd = g.dddd = _.cache(_.process(g.ctoken("sun mon tue wed thu fri sat"), function (s) { return function () { this.weekday = s; }; } )); g.day = _fn(g.d, g.dd); g.month = _fn(g.M, g.MMM); g.year = _fn(g.yyyy, g.yy); g.mdy = _setfn(g.ddd, g.month, g.day, g.year); g.ymd = _setfn(g.ddd, g.year, g.month, g.day); g.dmy = _setfn(g.ddd, g.day, g.month, g.year); g.date = function (s) { return ((g[Date.CultureInfo.dateElementOrder] || g.mdy).call(this, s)); }; }, relative: function () { // relative date / time expressions g.orientation = _.process(g.ctoken("past future"), function (s) { return function () { this.orient = s; }; } ); g.operator = _.process(g.ctoken("add subtract"), function (s) { return function () { this.operator = s; }; } ); g.rday = _.process(g.ctoken("yesterday tomorrow today now"), t.rday); g.unit = _.process(g.ctoken("second minute hour day week month year"), function (s) { return function () { this.unit = s; }; } ); } }; g.buildGrammarFormats = function () { // these need to be rebuilt every time the language changes. _C = {}; grammarFormats.timeFormats(); grammarFormats.dateFormats(); grammarFormats.relative(); g.value = _.process(_.rtoken(/^([-+]?\d+)?(st|nd|rd|th)?/), function (s) { return function () { this.value = s.replace(/\D/g, ""); }; } ); g.expression = _.set([g.rday, g.operator, g.value, g.unit, g.orientation, g.ddd, g.MMM ]); g.format = _.process(_.many( _.any( // translate format specifiers into grammar rules _.process( _.rtoken(/^(dd?d?d?(?!e)|MM?M?M?|yy?y?y?|hh?|HH?|mm?|ss?|tt?|zz?z?)/), function (fmt) { if (g[fmt]) { return g[fmt]; } else { throw $D.Parsing.Exception(fmt); } } ), // translate separator tokens into token rules _.process(_.rtoken(/^[^dMyhHmstz]+/), // all legal separators function (s) { return _.ignore(_.stoken(s)); } ) ) ), // construct the parser ... function (rules) { return _.process(_.each.apply(null, rules), t.finishExact); } ); // starting rule for general purpose grammar g._start = _.process(_.set([ g.date, g.time, g.expression ], g.generalDelimiter, g.whiteSpace), t.finish); }; g.buildGrammarFormats(); // parsing date format specifiers - ex: "h:m:s tt" // this little guy will generate a custom parser based // on the format string, ex: g.format("h:m:s tt") // check for these formats first g._formats = g.formats([ "\"yyyy-MM-ddTHH:mm:ssZ\"", "yyyy-MM-ddTHH:mm:ss.sz", "yyyy-MM-ddTHH:mm:ssZ", "yyyy-MM-ddTHH:mm:ssz", "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-ddTHH:mmZ", "yyyy-MM-ddTHH:mmz", "yyyy-MM-ddTHH:mm", "ddd, MMM dd, yyyy H:mm:ss tt", "ddd MMM d yyyy HH:mm:ss zzz", "MMddyyyy", "ddMMyyyy", "Mddyyyy", "ddMyyyy", "Mdyyyy", "dMyyyy", "yyyy", "Mdyy", "dMyy", "d" ]); // real starting rule: tries selected formats first, // then general purpose rule g.start = function (s) { try { var r = g._formats.call({}, s); if (r[1].length === 0) { return r; } } catch (e) {} return g._start.call({}, s); }; }()); (function () { var $D = Date; /** * @desc Converts the specified string value into its JavaScript Date equivalent using CultureInfo specific format information. * * Example

	///////////
	// Dates //
	///////////

	// 15-Oct-2004
	var d1 = Date.parse("10/15/2004");

	// 15-Oct-2004
	var d1 = Date.parse("15-Oct-2004");

	// 15-Oct-2004
	var d1 = Date.parse("2004.10.15");

	//Fri Oct 15, 2004
	var d1 = Date.parse("Fri Oct 15, 2004");

	///////////
	// Times //
	///////////

	// Today at 10 PM.
	var d1 = Date.parse("10 PM");

	// Today at 10:30 PM.
	var d1 = Date.parse("10:30 P.M.");

	// Today at 6 AM.
	var d1 = Date.parse("06am");

	/////////////////////
	// Dates and Times //
	/////////////////////

	// 8-July-2004 @ 10:30 PM
	var d1 = Date.parse("July 8th, 2004, 10:30 PM");

	// 1-July-2004 @ 10:30 PM
	var d1 = Date.parse("2004-07-01T22:30:00");

	////////////////////
	// Relative Dates //
	////////////////////

	// Returns today's date. The string "today" is culture specific.
	var d1 = Date.parse("today");

	// Returns yesterday's date. The string "yesterday" is culture specific.
	var d1 = Date.parse("yesterday");

	// Returns the date of the next thursday.
	var d1 = Date.parse("Next thursday");

	// Returns the date of the most previous monday.
	var d1 = Date.parse("last monday");

	// Returns today's day + one year.
	var d1 = Date.parse("next year");

	///////////////
	// Date Math //
	///////////////

	// Today + 2 days
	var d1 = Date.parse("t+2");

	// Today + 2 days
	var d1 = Date.parse("today + 2 days");

	// Today + 3 months
	var d1 = Date.parse("t+3m");

	// Today - 1 year
	var d1 = Date.parse("today - 1 year");

	// Today - 1 year
	var d1 = Date.parse("t-1y"); 


	/////////////////////////////
	// Partial Dates and Times //
	/////////////////////////////

	// July 15th of this year.
	var d1 = Date.parse("July 15");

	// 15th day of current day and year.
	var d1 = Date.parse("15");

	// July 1st of current year at 10pm.
	var d1 = Date.parse("7/1 10pm");
	
* * @param {String} The string value to convert into a Date object [Required] * @return {Date} A Date object or null if the string cannot be converted into a Date. */ var parseUtils = { removeOrds: function (s) { ords = s.match(/\b(\d+)(?:st|nd|rd|th)\b/); // find ordinal matches s = ((ords && ords.length === 2) ? s.replace(ords[0], ords[1]) : s); return s; }, grammarParser: function (s) { var r = null; try { r = $D.Grammar.start.call({}, s.replace(/^\s*(\S*(\s+\S+)*)\s*$/, "$1")); } catch (e) { return null; } return ((r[1].length === 0) ? r[0] : null); }, nativeFallback: function(s) { var t; try { // ok we haven't parsed it, last ditch attempt with the built-in parser. t = Date._parse(s); return (t || t === 0) ? new Date(t) : null; } catch (e) { return null; } } }; function parse (s) { var d; if (!s) { return null; } if (s instanceof Date) { return s.clone(); } if (s.length >= 4 && s.charAt(0) !== "0" && s.charAt(0) !== "+"&& s.charAt(0) !== "-") { // ie: 2004 will pass, 0800 won't. // Start with specific formats d = $D.Parsing.ISO.parse(s) || $D.Parsing.Numeric.parse(s); } if (d instanceof Date && !isNaN(d.getTime())) { return d; } else { // find ordinal dates (1st, 3rd, 8th, etc and remove them as they cause parsing issues) s = $D.Parsing.Normalizer.parse(parseUtils.removeOrds(s)); d = parseUtils.grammarParser(s); if (d !== null) { return d; } else { return parseUtils.nativeFallback(s); } } } if (!$D._parse) { $D._parse = $D.parse; } $D.parse = parse; Date.getParseFunction = function (fx) { var fns = Date.Grammar.allformats(fx); return function (s) { var r = null; for (var i = 0; i < fns.length; i++) { try { r = fns[i].call({}, s); } catch (e) { continue; } if (r[1].length === 0) { return r[0]; } } return null; }; }; /** * Converts the specified string value into its JavaScript Date equivalent using the specified format {String} or formats {Array} and the CultureInfo specific format information. * The format of the string value must match one of the supplied formats exactly. * * Example

	// 15-Oct-2004
	var d1 = Date.parseExact("10/15/2004", "M/d/yyyy");

	// 15-Oct-2004
	var d1 = Date.parse("15-Oct-2004", "M-ddd-yyyy");

	// 15-Oct-2004
	var d1 = Date.parse("2004.10.15", "yyyy.MM.dd");

	// Multiple formats
	var d1 = Date.parseExact("10/15/2004", ["M/d/yyyy", "MMMM d, yyyy"]);
	
* * @param {String} The string value to convert into a Date object [Required]. * @param {Object} The expected format {String} or an array of expected formats {Array} of the date string [Required]. * @return {Date} A Date object or null if the string cannot be converted into a Date. */ $D.parseExact = function (s, fx) { return $D.getParseFunction(fx)(s); }; }()); (function () { var $D = Date, $P = $D.prototype, // $C = $D.CultureInfo, // not used atm p = function (s, l) { if (!l) { l = 2; } return ("000" + s).slice(l * -1); }; /** * Converts a PHP format string to Java/.NET format string. * A PHP format string can be used with ._format or .format. * A Java/.NET format string can be used with .toString(). * The .parseExact function will only accept a Java/.NET format string * * Example * var f1 = "%m/%d/%y" * var f2 = Date.normalizeFormat(f1); // "MM/dd/yy" * * new Date().format(f1); // "04/13/08" * new Date()._format(f1); // "04/13/08" * new Date().toString(f2); // "04/13/08" * * var date = Date.parseExact("04/13/08", f2); // Sun Apr 13 2008 * * @param {String} A PHP format string consisting of one or more format spcifiers. * @return {String} The PHP format converted to a Java/.NET format string. */ var normalizerSubstitutions = { "d" : "dd", "%d": "dd", "D" : "ddd", "%a": "ddd", "j" : "dddd", "l" : "dddd", "%A": "dddd", "S" : "S", "F" : "MMMM", "%B": "MMMM", "m" : "MM", "%m": "MM", "M" : "MMM", "%b": "MMM", "%h": "MMM", "n" : "M", "Y" : "yyyy", "%Y": "yyyy", "y" : "yy", "%y": "yy", "g" : "h", "%I": "h", "G" : "H", "h" : "hh", "H" : "HH", "%H": "HH", "i" : "mm", "%M": "mm", "s" : "ss", "%S": "ss", "%r": "hh:mm tt", "%R": "H:mm", "%T": "H:mm:ss", "%X": "t", "%x": "d", "%e": "d", "%D": "MM/dd/yy", "%n": "\\n", "%t": "\\t", "e" : "z", "T" : "z", "%z": "z", "%Z": "z", "Z" : "ZZ", "N" : "u", "w" : "u", "%w": "u", "W" : "W", "%V": "W" }; var normalizer = { substitutes: function (m) { return normalizerSubstitutions[m]; }, interpreted: function (m, x) { var y; switch (m) { case "%u": return x.getDay() + 1; case "z": return x.getOrdinalNumber(); case "%j": return p(x.getOrdinalNumber(), 3); case "%U": var d1 = x.clone().set({month: 0, day: 1}).addDays(-1).moveToDayOfWeek(0), d2 = x.clone().addDays(1).moveToDayOfWeek(0, -1); return (d2 < d1) ? "00" : p((d2.getOrdinalNumber() - d1.getOrdinalNumber()) / 7 + 1); case "%W": return p(x.getWeek()); case "t": return $D.getDaysInMonth(x.getFullYear(), x.getMonth()); case "o": case "%G": return x.setWeek(x.getISOWeek()).toString("yyyy"); case "%g": return x._format("%G").slice(-2); case "a": case "%p": return t("tt").toLowerCase(); case "A": return t("tt").toUpperCase(); case "u": return p(x.getMilliseconds(), 3); case "I": return (x.isDaylightSavingTime()) ? 1 : 0; case "O": return x.getUTCOffset(); case "P": y = x.getUTCOffset(); return y.substring(0, y.length - 2) + ":" + y.substring(y.length - 2); case "B": var now = new Date(); return Math.floor(((now.getHours() * 3600) + (now.getMinutes() * 60) + now.getSeconds() + (now.getTimezoneOffset() + 60) * 60) / 86.4); case "c": return x.toISOString().replace(/\"/g, ""); case "U": return $D.strtotime("now"); case "%c": return t("d") + " " + t("t"); case "%C": return Math.floor(x.getFullYear() / 100 + 1); } }, shouldOverrideDefaults: function (m) { switch (m) { case "%e": return true; default: return false; } }, parse: function (m, context) { var formatString, c = context || new Date(); formatString = normalizer.substitutes(m); if (formatString) { return formatString; } formatString = normalizer.interpreted(m, c); if (formatString) { return formatString; } else { return m; } } }; $D.normalizeFormat = function (format, context) { return format.replace(/(%|\\)?.|%%/g, function(t){ return normalizer.parse(t, context); }); }; /** * Format a local Unix timestamp according to locale settings * * Example: * Date.strftime("%m/%d/%y", new Date()); // "04/13/08" * Date.strftime("c", "2008-04-13T17:52:03Z"); // "04/13/08" * * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @param {Number|String} The number representing the number of seconds that have elapsed since January 1, 1970 (local time). * @return {String} A string representation of the current Date object. */ $D.strftime = function (format, time) { var d = Date.parse(time); return d._format(format); }; /** * Parse any textual datetime description into a Unix timestamp. * A Unix timestamp is the number of seconds that have elapsed since January 1, 1970 (midnight UTC/GMT). * * Example: * Date.strtotime("04/13/08"); // 1208044800 * Date.strtotime("1970-01-01T00:00:00Z"); // 0 * * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @param {Object} A string or date object. * @return {String} A string representation of the current Date object. */ $D.strtotime = function (time) { var d = $D.parse(time); return Math.round($D.UTC(d.getUTCFullYear(), d.getUTCMonth(), d.getUTCDate(), d.getUTCHours(), d.getUTCMinutes(), d.getUTCSeconds(), d.getUTCMilliseconds()) / 1000); }; /** * Converts the value of the current Date object to its equivalent string representation using a PHP/Unix style of date format specifiers. * Format Specifiers * Format Description Example * ------ --------------------------------------------------------------------------- ----------------------- * %a abbreviated weekday name according to the current localed "Mon" through "Sun" * %A full weekday name according to the current localed "Sunday" through "Saturday" * %b abbreviated month name according to the current localed "Jan" through "Dec" * %B full month name according to the current locale "January" through "December" * %c preferred date and time representation for the current locale "4/13/2008 12:33 PM" * %C century number (the year divided by 100 and truncated to an integer) "00" to "99" * %d day of the month as a decimal number "01" to "31" * %D same as %m/%d/%y "04/13/08" * %e day of the month as a decimal number, a single digit is preceded by a space "1" to "31" * %g like %G, but without the century "08" * %G The 4-digit year corresponding to the ISO week number (see %V). "2008" * This has the same format and value as %Y, except that if the ISO week number * belongs to the previous or next year, that year is used instead. * %h same as %b "Jan" through "Dec" * %H hour as a decimal number using a 24-hour clock. "00" to "23" * %I hour as a decimal number using a 12-hour clock. "01" to "12" * %j day of the year as a decimal number. "001" to "366" * %m month as a decimal number. "01" to "12" * %M minute as a decimal number. "00" to "59" * %n newline character "\n" * %p either "am" or "pm" according to the given time value, or the "am" or "pm" * corresponding strings for the current locale. * %r time in a.m. and p.m. notation "8:44 PM" * %R time in 24 hour notation "20:44" * %S second as a decimal number "00" to "59" * %t tab character "\t" * %T current time, equal to %H:%M:%S "12:49:11" * %u weekday as a decimal number ["1", "7"], with "1" representing Monday "1" to "7" * %U week number of the current year as a decimal number, starting with the "0" to ("52" or "53") * first Sunday as the first day of the first week * %V The ISO 8601:1988 week number of the current year as a decimal number, "00" to ("52" or "53") * range 01 to 53, where week 1 is the first week that has at least 4 days * in the current year, and with Monday as the first day of the week. * (Use %G or %g for the year component that corresponds to the week number * for the specified timestamp.) * %W week number of the current year as a decimal number, starting with the "00" to ("52" or "53") * first Monday as the first day of the first week * %w day of the week as a decimal, Sunday being "0" "0" to "6" * %x preferred date representation for the current locale without the time "4/13/2008" * %X preferred time representation for the current locale without the date "12:53:05" * %y year as a decimal number without a century "00" "99" * %Y year as a decimal number including the century "2008" * %Z time zone or name or abbreviation "UTC", "EST", "PST" * %z same as %Z * %% a literal "%" characters "%" * d Day of the month, 2 digits with leading zeros "01" to "31" * D A textual representation of a day, three letters "Mon" through "Sun" * j Day of the month without leading zeros "1" to "31" * l A full textual representation of the day of the week (lowercase "L") "Sunday" through "Saturday" * N ISO-8601 numeric representation of the day of the week (added in PHP 5.1.0) "1" (for Monday) through "7" (for Sunday) * S English ordinal suffix for the day of the month, 2 characters "st", "nd", "rd" or "th". Works well with j * w Numeric representation of the day of the week "0" (for Sunday) through "6" (for Saturday) * z The day of the year (starting from "0") "0" through "365" * W ISO-8601 week number of year, weeks starting on Monday "00" to ("52" or "53") * F A full textual representation of a month, such as January or March "January" through "December" * m Numeric representation of a month, with leading zeros "01" through "12" * M A short textual representation of a month, three letters "Jan" through "Dec" * n Numeric representation of a month, without leading zeros "1" through "12" * t Number of days in the given month "28" through "31" * L Whether it's a leap year "1" if it is a leap year, "0" otherwise * o ISO-8601 year number. This has the same value as Y, except that if the "2008" * ISO week number (W) belongs to the previous or next year, that year * is used instead. * Y A full numeric representation of a year, 4 digits "2008" * y A two digit representation of a year "08" * a Lowercase Ante meridiem and Post meridiem "am" or "pm" * A Uppercase Ante meridiem and Post meridiem "AM" or "PM" * B Swatch Internet time "000" through "999" * g 12-hour format of an hour without leading zeros "1" through "12" * G 24-hour format of an hour without leading zeros "0" through "23" * h 12-hour format of an hour with leading zeros "01" through "12" * H 24-hour format of an hour with leading zeros "00" through "23" * i Minutes with leading zeros "00" to "59" * s Seconds, with leading zeros "00" through "59" * u Milliseconds "54321" * e Timezone identifier "UTC", "EST", "PST" * I Whether or not the date is in daylight saving time (uppercase i) "1" if Daylight Saving Time, "0" otherwise * O Difference to Greenwich time (GMT) in hours "+0200", "-0600" * P Difference to Greenwich time (GMT) with colon between hours and minutes "+02:00", "-06:00" * T Timezone abbreviation "UTC", "EST", "PST" * Z Timezone offset in seconds. The offset for timezones west of UTC is "-43200" through "50400" * always negative, and for those east of UTC is always positive. * c ISO 8601 date "2004-02-12T15:19:21+00:00" * r RFC 2822 formatted date "Thu, 21 Dec 2000 16:01:07 +0200" * U Seconds since the Unix Epoch (January 1 1970 00:00:00 GMT) "0" * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @return {String} A string representation of the current Date object. */ var formatReplace = function (context) { return function (m) { var formatString, override = false; if (m.charAt(0) === "\\" || m.substring(0, 2) === "%%") { return m.replace("\\", "").replace("%%", "%"); } override = normalizer.shouldOverrideDefaults(m); formatString = $D.normalizeFormat(m, context); if (formatString) { return context.toString(formatString, override); } }; }; $P._format = function (format) { var formatter = formatReplace(this); if (!format) { return this._toString(); } else { return format.replace(/(%|\\)?.|%%/g, formatter); } }; if (!$P.format) { $P.format = $P._format; } }()); (function () { "use strict"; var gFn = function (attr) { return function () { return this[attr]; }; }; var sFn = function (attr) { return function (val) { this[attr] = val; return this; }; }; var attrs = ["years", "months", "days", "hours", "minutes", "seconds", "milliseconds"]; var addSetFuncs = function (context, attrs) { for (var i = 0; i < attrs.length ; i++) { var $a = attrs[i], $b = $a.slice(0, 1).toUpperCase() + $a.slice(1); context.prototype[$a] = 0; context.prototype["get" + $b] = gFn($a); context.prototype["set" + $b] = sFn($a); } }; /** * new TimeSpan(milliseconds); * new TimeSpan(days, hours, minutes, seconds); * new TimeSpan(days, hours, minutes, seconds, milliseconds); */ var TimeSpan = function (days, hours, minutes, seconds, milliseconds) { if (arguments.length === 1 && typeof days === "number") { var orient = (days < 0) ? -1 : +1; var millsLeft = Math.abs(days); this.setDays(Math.floor(millsLeft / 86400000) * orient); millsLeft = millsLeft % 86400000; this.setHours(Math.floor(millsLeft / 3600000) * orient); millsLeft = millsLeft % 3600000; this.setMinutes(Math.floor(millsLeft / 60000) * orient); millsLeft = millsLeft % 60000; this.setSeconds(Math.floor(millsLeft / 1000) * orient); millsLeft = millsLeft % 1000; this.setMilliseconds(millsLeft * orient); } else { this.set(days, hours, minutes, seconds, milliseconds); } this.getTotalMilliseconds = function () { return (this.getDays() * 86400000) + (this.getHours() * 3600000) + (this.getMinutes() * 60000) + (this.getSeconds() * 1000); }; this.compareTo = function (time) { var t1 = new Date(1970, 1, 1, this.getHours(), this.getMinutes(), this.getSeconds()), t2; if (time === null) { t2 = new Date(1970, 1, 1, 0, 0, 0); } else { t2 = new Date(1970, 1, 1, time.getHours(), time.getMinutes(), time.getSeconds()); } return (t1 < t2) ? -1 : (t1 > t2) ? 1 : 0; }; this.equals = function (time) { return (this.compareTo(time) === 0); }; this.add = function (time) { return (time === null) ? this : this.addSeconds(time.getTotalMilliseconds() / 1000); }; this.subtract = function (time) { return (time === null) ? this : this.addSeconds(-time.getTotalMilliseconds() / 1000); }; this.addDays = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 86400000)); }; this.addHours = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 3600000)); }; this.addMinutes = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 60000)); }; this.addSeconds = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 1000)); }; this.addMilliseconds = function (n) { return new TimeSpan(this.getTotalMilliseconds() + n); }; this.get12HourHour = function () { return (this.getHours() > 12) ? this.getHours() - 12 : (this.getHours() === 0) ? 12 : this.getHours(); }; this.getDesignator = function () { return (this.getHours() < 12) ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator; }; this.toString = function (format) { this._toString = function () { if (this.getDays() !== null && this.getDays() > 0) { return this.getDays() + "." + this.getHours() + ":" + this.p(this.getMinutes()) + ":" + this.p(this.getSeconds()); } else { return this.getHours() + ":" + this.p(this.getMinutes()) + ":" + this.p(this.getSeconds()); } }; this.p = function (s) { return (s.toString().length < 2) ? "0" + s : s; }; var me = this; return format ? format.replace(/dd?|HH?|hh?|mm?|ss?|tt?/g, function (format) { switch (format) { case "d": return me.getDays(); case "dd": return me.p(me.getDays()); case "H": return me.getHours(); case "HH": return me.p(me.getHours()); case "h": return me.get12HourHour(); case "hh": return me.p(me.get12HourHour()); case "m": return me.getMinutes(); case "mm": return me.p(me.getMinutes()); case "s": return me.getSeconds(); case "ss": return me.p(me.getSeconds()); case "t": return ((me.getHours() < 12) ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator).substring(0, 1); case "tt": return (me.getHours() < 12) ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator; } } ) : this._toString(); }; return this; }; addSetFuncs(TimeSpan, attrs.slice(2)); TimeSpan.prototype.set = function (days, hours, minutes, seconds, milliseconds){ this.setDays(days || this.getDays()); this.setHours(hours || this.getHours()); this.setMinutes(minutes || this.getMinutes()); this.setSeconds(seconds || this.getSeconds()); this.setMilliseconds(milliseconds || this.getMilliseconds()); }; /** * Gets the time of day for this date instances. * @return {TimeSpan} TimeSpan */ Date.prototype.getTimeOfDay = function () { return new TimeSpan(0, this.getHours(), this.getMinutes(), this.getSeconds(), this.getMilliseconds()); }; Date.TimeSpan = TimeSpan; if (typeof window !== "undefined" ) { // keeping API compatible for v1.x window.TimeSpan = TimeSpan; } }()); (function () { "use strict"; var attrs = ["years", "months", "days", "hours", "minutes", "seconds", "milliseconds"]; var gFn = function (attr) { return function () { return this[attr]; }; }; var sFn = function (attr) { return function (val) { this[attr] = val; return this; }; }; var addSetFuncs = function (context, attrs) { for (var i = 0; i < attrs.length ; i++) { var $a = attrs[i], $b = $a.slice(0, 1).toUpperCase() + $a.slice(1); context.prototype[$a] = 0; context.prototype["get" + $b] = gFn($a); context.prototype["set" + $b] = sFn($a); } }; var setMonthsAndYears = function (orient, d1, d2, context) { function inc() { d1.addMonths(-orient); context.months++; if (context.months === 12) { context.years++; context.months = 0; } } if (orient === +1) { while (d1 > d2) { inc(); } } else { while (d1 < d2) { inc(); } } context.months--; context.months *= orient; context.years *= orient; }; var adjustForDST = function(orient, startDate, endDate) { var hasDSTMismatch = (false === (startDate.isDaylightSavingTime() === endDate.isDaylightSavingTime())); if (hasDSTMismatch && orient === 1) { startDate.addHours(-1); } else if (hasDSTMismatch) { startDate.addHours(1); } }; /** * TimePeriod(startDate, endDate); * TimePeriod(years, months, days, hours, minutes, seconds, milliseconds); */ var TimePeriod = function (years, months, days, hours, minutes, seconds, milliseconds) { if (arguments.length === 7) { this.set(years, months, days, hours, minutes, seconds, milliseconds); } else if (arguments.length === 2 && arguments[0] instanceof Date && arguments[1] instanceof Date) { var startDate = arguments[0].clone(); var endDate = arguments[1].clone(); var orient = (startDate > endDate) ? +1 : -1; this.dates = { start: arguments[0].clone(), end: arguments[1].clone() }; setMonthsAndYears(orient, startDate, endDate, this); adjustForDST(orient, startDate, endDate); // // TODO - adjust for DST var diff = endDate - startDate; if (diff !== 0) { var ts = new TimeSpan(diff); this.set(this.years, this.months, ts.getDays(), ts.getHours(), ts.getMinutes(), ts.getSeconds(), ts.getMilliseconds()); } } return this; }; // create all the set functions. addSetFuncs(TimePeriod, attrs); TimePeriod.prototype.set = function (years, months, days, hours, minutes, seconds, milliseconds){ this.setYears(years || this.getYears()); this.setMonths(months || this.getMonths()); this.setDays(days || this.getDays()); this.setHours(hours || this.getHours()); this.setMinutes(minutes || this.getMinutes()); this.setSeconds(seconds || this.getSeconds()); this.setMilliseconds(milliseconds || this.getMilliseconds()); }; Date.TimePeriod = TimePeriod; if (typeof window !== "undefined") { // keeping API compatible for v1.x window.TimePeriod = TimePeriod; } }()); ================================================ FILE: build/date-hu-HU.js ================================================ /** * @overview datejs * @version 1.0.0-rc3 * @author Gregory Wild-Smith * @copyright 2015 Gregory Wild-Smith * @license MIT * @homepage https://github.com/abritinthebay/datejs */ /* * DateJS Culture String File * Country Code: hu-HU * Name: Hungarian (Hungary) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["hu-HU"] = { "name": "hu-HU", "englishName": "Hungarian (Hungary)", "nativeName": "magyar (Magyarország)", "Sunday": "vasárnap", "Monday": "hétfő", "Tuesday": "kedd", "Wednesday": "szerda", "Thursday": "csütörtök", "Friday": "péntek", "Saturday": "szombat", "Sun": "V", "Mon": "H", "Tue": "K", "Wed": "Sze", "Thu": "Cs", "Fri": "P", "Sat": "Szo", "Su": "V", "Mo": "H", "Tu": "K", "We": "Sze", "Th": "Cs", "Fr": "P", "Sa": "Szo", "S_Sun_Initial": "V", "M_Mon_Initial": "H", "T_Tue_Initial": "K", "W_Wed_Initial": "S", "T_Thu_Initial": "C", "F_Fri_Initial": "P", "S_Sat_Initial": "S", "January": "január", "February": "február", "March": "március", "April": "április", "May": "május", "June": "június", "July": "július", "August": "augusztus", "September": "szeptember", "October": "október", "November": "november", "December": "december", "Jan_Abbr": "jan.", "Feb_Abbr": "febr.", "Mar_Abbr": "márc.", "Apr_Abbr": "ápr.", "May_Abbr": "máj.", "Jun_Abbr": "jún.", "Jul_Abbr": "júl.", "Aug_Abbr": "aug.", "Sep_Abbr": "szept.", "Oct_Abbr": "okt.", "Nov_Abbr": "nov.", "Dec_Abbr": "dec.", "AM": "de.", "PM": "du.", "firstDayOfWeek": 1, "twoDigitYearMax": 2029, "mdy": "ymd", "M/d/yyyy": "yyyy. MM. dd.", "dddd, MMMM dd, yyyy": "yyyy. MMMM d.", "h:mm tt": "H:mm", "h:mm:ss tt": "H:mm:ss", "dddd, MMMM dd, yyyy h:mm:ss tt": "yyyy. MMMM d. H:mm:ss", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "MMMM d.", "MMMM, yyyy": "yyyy. MMMM", "/jan(uary)?/": "jan(.(uár)?)?", "/feb(ruary)?/": "febr(.(uár)?)?", "/mar(ch)?/": "márc(.(ius)?)?", "/apr(il)?/": "ápr(.(ilis)?)?", "/may/": "máj(.(us)?)?", "/jun(e)?/": "jún(.(ius)?)?", "/jul(y)?/": "júl(.(ius)?)?", "/aug(ust)?/": "aug(.(usztus)?)?", "/sep(t(ember)?)?/": "szept(.(ember)?)?", "/oct(ober)?/": "okt(.(óber)?)?", "/nov(ember)?/": "nov(.(ember)?)?", "/dec(ember)?/": "dec(.(ember)?)?", "/^su(n(day)?)?/": "^vasárnap", "/^mo(n(day)?)?/": "^hétfő", "/^tu(e(s(day)?)?)?/": "^kedd", "/^we(d(nesday)?)?/": "^szerda", "/^th(u(r(s(day)?)?)?)?/": "^csütörtök", "/^fr(i(day)?)?/": "^péntek", "/^sa(t(urday)?)?/": "^szombat", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "hu-HU"; /** * @overview datejs * @version 1.0.0-rc3 * @author Gregory Wild-Smith * @copyright 2015 Gregory Wild-Smith * @license MIT * @homepage https://github.com/abritinthebay/datejs */(function () { var $D = Date; var lang = Date.CultureStrings ? Date.CultureStrings.lang : null; var loggedKeys = {}; // for debug purposes. var getText = { getFromKey: function (key, countryCode) { var output; if (Date.CultureStrings && Date.CultureStrings[countryCode] && Date.CultureStrings[countryCode][key]) { output = Date.CultureStrings[countryCode][key]; } else { output = getText.buildFromDefault(key); } if (key.charAt(0) === "/") { // Assume it's a regex output = getText.buildFromRegex(key, countryCode); } return output; }, getFromObjectValues: function (obj, countryCode) { var key, output = {}; for(key in obj) { if (obj.hasOwnProperty(key)) { output[key] = getText.getFromKey(obj[key], countryCode); } } return output; }, getFromObjectKeys: function (obj, countryCode) { var key, output = {}; for(key in obj) { if (obj.hasOwnProperty(key)) { output[getText.getFromKey(key, countryCode)] = obj[key]; } } return output; }, getFromArray: function (arr, countryCode) { var output = []; for (var i=0; i < arr.length; i++){ if (i in arr) { output[i] = getText.getFromKey(arr[i], countryCode); } } return output; }, buildFromDefault: function (key) { var output, length, split, last; switch(key) { case "name": output = "en-US"; break; case "englishName": output = "English (United States)"; break; case "nativeName": output = "English (United States)"; break; case "twoDigitYearMax": output = 2049; break; case "firstDayOfWeek": output = 0; break; default: output = key; split = key.split("_"); length = split.length; if (length > 1 && key.charAt(0) !== "/") { // if the key isn't a regex and it has a split. last = split[(length - 1)].toLowerCase(); if (last === "initial" || last === "abbr") { output = split[0]; } } break; } return output; }, buildFromRegex: function (key, countryCode) { var output; if (Date.CultureStrings && Date.CultureStrings[countryCode] && Date.CultureStrings[countryCode][key]) { output = new RegExp(Date.CultureStrings[countryCode][key], "i"); } else { output = new RegExp(key.replace(new RegExp("/", "g"),""), "i"); } return output; } }; var shallowMerge = function (obj1, obj2) { for (var attrname in obj2) { if (obj2.hasOwnProperty(attrname)) { obj1[attrname] = obj2[attrname]; } } }; var __ = function (key, language) { var countryCode = (language) ? language : lang; loggedKeys[key] = key; if (typeof key === "object") { if (key instanceof Array) { return getText.getFromArray(key, countryCode); } else { return getText.getFromObjectKeys(key, countryCode); } } else { return getText.getFromKey(key, countryCode); } }; var loadI18nScript = function (code) { // paatterned after jQuery's getScript. var url = Date.Config.i18n + code + ".js"; var head = document.getElementsByTagName("head")[0] || document.documentElement; var script = document.createElement("script"); script.src = url; var completed = false; var events = { done: function (){} // placeholder function }; // Attach handlers for all browsers script.onload = script.onreadystatechange = function() { if ( !completed && (!this.readyState || this.readyState === "loaded" || this.readyState === "complete") ) { events.done(); head.removeChild(script); } }; setTimeout(function() { head.insertBefore(script, head.firstChild); }, 0); // allows return to execute first return { done: function (cb) { events.done = function() { if (cb) { setTimeout(cb,0); } }; } }; }; var buildInfo = { buildFromMethodHash: function (obj) { var key; for(key in obj) { if (obj.hasOwnProperty(key)) { obj[key] = buildInfo[obj[key]](); } } return obj; }, timeZoneDST: function () { var DST = { "CHADT": "+1345", "NZDT": "+1300", "AEDT": "+1100", "ACDT": "+1030", "AZST": "+0500", "IRDT": "+0430", "EEST": "+0300", "CEST": "+0200", "BST": "+0100", "PMDT": "-0200", "ADT": "-0300", "NDT": "-0230", "EDT": "-0400", "CDT": "-0500", "MDT": "-0600", "PDT": "-0700", "AKDT": "-0800", "HADT": "-0900" }; return __(DST); }, timeZoneStandard: function () { var standard = { "LINT": "+1400", "TOT": "+1300", "CHAST": "+1245", "NZST": "+1200", "NFT": "+1130", "SBT": "+1100", "AEST": "+1000", "ACST": "+0930", "JST": "+0900", "CWST": "+0845", "CT": "+0800", "ICT": "+0700", "MMT": "+0630", "BST": "+0600", "NPT": "+0545", "IST": "+0530", "PKT": "+0500", "AFT": "+0430", "MSK": "+0400", "IRST": "+0330", "FET": "+0300", "EET": "+0200", "CET": "+0100", "GMT": "+0000", "UTC": "+0000", "CVT": "-0100", "GST": "-0200", "BRT": "-0300", "NST": "-0330", "AST": "-0400", "EST": "-0500", "CST": "-0600", "MST": "-0700", "PST": "-0800", "AKST": "-0900", "MIT": "-0930", "HST": "-1000", "SST": "-1100", "BIT": "-1200" }; return __(standard); }, timeZones: function (data) { var zone; data.timezones = []; for (zone in data.abbreviatedTimeZoneStandard) { if (data.abbreviatedTimeZoneStandard.hasOwnProperty(zone)) { data.timezones.push({ name: zone, offset: data.abbreviatedTimeZoneStandard[zone]}); } } for (zone in data.abbreviatedTimeZoneDST) { if (data.abbreviatedTimeZoneDST.hasOwnProperty(zone)) { data.timezones.push({ name: zone, offset: data.abbreviatedTimeZoneDST[zone], dst: true}); } } return data.timezones; }, days: function () { return __(["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"]); }, dayAbbr: function () { return __(["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"]); }, dayShortNames: function () { return __(["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"]); }, dayFirstLetters: function () { return __(["S_Sun_Initial", "M_Mon_Initial", "T_Tues_Initial", "W_Wed_Initial", "T_Thu_Initial", "F_Fri_Initial", "S_Sat_Initial"]); }, months: function () { return __(["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"]); }, monthAbbr: function () { return __(["Jan_Abbr", "Feb_Abbr", "Mar_Abbr", "Apr_Abbr", "May_Abbr", "Jun_Abbr", "Jul_Abbr", "Aug_Abbr", "Sep_Abbr", "Oct_Abbr", "Nov_Abbr", "Dec_Abbr"]); }, formatPatterns: function () { return getText.getFromObjectValues({ shortDate: "M/d/yyyy", longDate: "dddd, MMMM dd, yyyy", shortTime: "h:mm tt", longTime: "h:mm:ss tt", fullDateTime: "dddd, MMMM dd, yyyy h:mm:ss tt", sortableDateTime: "yyyy-MM-ddTHH:mm:ss", universalSortableDateTime: "yyyy-MM-dd HH:mm:ssZ", rfc1123: "ddd, dd MMM yyyy HH:mm:ss", monthDay: "MMMM dd", yearMonth: "MMMM, yyyy" }, Date.i18n.currentLanguage()); }, regex: function () { return getText.getFromObjectValues({ inTheMorning: "/( in the )(morn(ing)?)\\b/", thisMorning: "/(this )(morn(ing)?)\\b/", amThisMorning: "/(\b\\d(am)? )(this )(morn(ing)?)/", inTheEvening: "/( in the )(even(ing)?)\\b/", thisEvening: "/(this )(even(ing)?)\\b/", pmThisEvening: "/(\b\\d(pm)? )(this )(even(ing)?)/", jan: "/jan(uary)?/", feb: "/feb(ruary)?/", mar: "/mar(ch)?/", apr: "/apr(il)?/", may: "/may/", jun: "/jun(e)?/", jul: "/jul(y)?/", aug: "/aug(ust)?/", sep: "/sep(t(ember)?)?/", oct: "/oct(ober)?/", nov: "/nov(ember)?/", dec: "/dec(ember)?/", sun: "/^su(n(day)?)?/", mon: "/^mo(n(day)?)?/", tue: "/^tu(e(s(day)?)?)?/", wed: "/^we(d(nesday)?)?/", thu: "/^th(u(r(s(day)?)?)?)?/", fri: "/fr(i(day)?)?/", sat: "/^sa(t(urday)?)?/", future: "/^next/", past: "/^last|past|prev(ious)?/", add: "/^(\\+|aft(er)?|from|hence)/", subtract: "/^(\\-|bef(ore)?|ago)/", yesterday: "/^yes(terday)?/", today: "/^t(od(ay)?)?/", tomorrow: "/^tom(orrow)?/", now: "/^n(ow)?/", millisecond: "/^ms|milli(second)?s?/", second: "/^sec(ond)?s?/", minute: "/^mn|min(ute)?s?/", hour: "/^h(our)?s?/", week: "/^w(eek)?s?/", month: "/^m(onth)?s?/", day: "/^d(ay)?s?/", year: "/^y(ear)?s?/", shortMeridian: "/^(a|p)/", longMeridian: "/^(a\\.?m?\\.?|p\\.?m?\\.?)/", timezone: "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/", ordinalSuffix: "/^\\s*(st|nd|rd|th)/", timeContext: "/^\\s*(\\:|a(?!u|p)|p)/" }, Date.i18n.currentLanguage()); } }; var CultureInfo = function () { var info = getText.getFromObjectValues({ name: "name", englishName: "englishName", nativeName: "nativeName", amDesignator: "AM", pmDesignator: "PM", firstDayOfWeek: "firstDayOfWeek", twoDigitYearMax: "twoDigitYearMax", dateElementOrder: "mdy" }, Date.i18n.currentLanguage()); var constructedInfo = buildInfo.buildFromMethodHash({ dayNames: "days", abbreviatedDayNames: "dayAbbr", shortestDayNames: "dayShortNames", firstLetterDayNames: "dayFirstLetters", monthNames: "months", abbreviatedMonthNames: "monthAbbr", formatPatterns: "formatPatterns", regexPatterns: "regex", abbreviatedTimeZoneDST: "timeZoneDST", abbreviatedTimeZoneStandard: "timeZoneStandard" }); shallowMerge(info, constructedInfo); buildInfo.timeZones(info); return info; }; $D.i18n = { __: function (key, lang) { return __(key, lang); }, currentLanguage: function () { return lang || "en-US"; }, setLanguage: function (code, force, cb) { var async = false; if (force || code === "en-US" || (!!Date.CultureStrings && !!Date.CultureStrings[code])) { lang = code; Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings.lang = code; Date.CultureInfo = new CultureInfo(); } else { if (!(!!Date.CultureStrings && !!Date.CultureStrings[code])) { if (typeof exports !== "undefined" && this.exports !== exports) { // we're in a Node enviroment, load it using require try { require("../i18n/" + code + ".js"); lang = code; Date.CultureStrings.lang = code; Date.CultureInfo = new CultureInfo(); } catch (e) { // var str = "The language for '" + code + "' could not be loaded by Node. It likely does not exist."; throw new Error("The DateJS IETF language tag '" + code + "' could not be loaded by Node. It likely does not exist."); } } else if (Date.Config && Date.Config.i18n) { // we know the location of the files, so lets load them async = true; loadI18nScript(code).done(function(){ lang = code; Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings.lang = code; Date.CultureInfo = new CultureInfo(); $D.Parsing.Normalizer.buildReplaceData(); // because this is async if ($D.Grammar) { $D.Grammar.buildGrammarFormats(); // so we can parse those strings... } if (cb) { setTimeout(cb,0); } }); } else { Date.console.error("The DateJS IETF language tag '" + code + "' is not available and has not been loaded."); return false; } } } $D.Parsing.Normalizer.buildReplaceData(); // rebuild normalizer strings if ($D.Grammar) { $D.Grammar.buildGrammarFormats(); // so we can parse those strings... } if (!async && cb) { setTimeout(cb,0); } }, getLoggedKeys: function () { return loggedKeys; }, updateCultureInfo: function () { Date.CultureInfo = new CultureInfo(); } }; $D.i18n.updateCultureInfo(); // run automatically }()); (function () { var $D = Date, $P = $D.prototype, p = function (s, l) { if (!l) { l = 2; } return ("000" + s).slice(l * -1); }; if (typeof window !== "undefined" && typeof window.console !== "undefined" && typeof window.console.log !== "undefined") { $D.console = console; // used only to raise non-critical errors if available } else { // set mock so we don't give errors. $D.console = { log: function(){}, error: function(){} }; } $D.Config = $D.Config || {}; $D.initOverloads = function() { /** * Overload of Date.now. Allows an alternate call for Date.now where it returns the * current Date as an object rather than just milliseconds since the Unix Epoch. * * Also provides an implementation of now() for browsers (IE<9) that don't have it. * * Backwards compatible so with work with either: * Date.now() [returns ms] * or * Date.now(true) [returns Date] */ if (!$D.now) { $D._now = function now() { return new Date().getTime(); }; } else if (!$D._now) { $D._now = $D.now; } $D.now = function (returnObj) { if (returnObj) { return $D.present(); } else { return $D._now(); } }; if ( !$P.toISOString ) { $P.toISOString = function() { return this.getUTCFullYear() + "-" + p(this.getUTCMonth() + 1) + "-" + p(this.getUTCDate()) + "T" + p(this.getUTCHours()) + ":" + p(this.getUTCMinutes()) + ":" + p(this.getUTCSeconds()) + "." + String( (this.getUTCMilliseconds()/1000).toFixed(3)).slice(2, 5) + "Z"; }; } // private if ( $P._toString === undefined ){ $P._toString = $P.toString; } }; $D.initOverloads(); /** * Gets a date that is set to the current date. The time is set to the start of the day (00:00 or 12:00 AM). * @return {Date} The current date. */ $D.today = function () { return new Date().clearTime(); }; /** * Gets a date that is set to the current date and time (same as new Date, but chainable) * @return {Date} The current date. */ $D.present = function () { return new Date(); }; /** * Compares the first date to the second date and returns an number indication of their relative values. * @param {Date} First Date object to compare [Required]. * @param {Date} Second Date object to compare to [Required]. * @return {Number} -1 = date1 is lessthan date2. 0 = values are equal. 1 = date1 is greaterthan date2. */ $D.compare = function (date1, date2) { if (isNaN(date1) || isNaN(date2)) { throw new Error(date1 + " - " + date2); } else if (date1 instanceof Date && date2 instanceof Date) { return (date1 < date2) ? -1 : (date1 > date2) ? 1 : 0; } else { throw new TypeError(date1 + " - " + date2); } }; /** * Compares the first Date object to the second Date object and returns true if they are equal. * @param {Date} First Date object to compare [Required] * @param {Date} Second Date object to compare to [Required] * @return {Boolean} true if dates are equal. false if they are not equal. */ $D.equals = function (date1, date2) { return (date1.compareTo(date2) === 0); }; /** * Gets the language appropriate day name when given the day number(0-6) * eg - 0 == Sunday * @return {String} The day name */ $D.getDayName = function (n) { return Date.CultureInfo.dayNames[n]; }; /** * Gets the day number (0-6) if given a CultureInfo specific string which is a valid dayName, abbreviatedDayName or shortestDayName (two char). * @param {String} The name of the day (eg. "Monday, "Mon", "tuesday", "tue", "We", "we"). * @return {Number} The day number */ $D.getDayNumberFromName = function (name) { var n = Date.CultureInfo.dayNames, m = Date.CultureInfo.abbreviatedDayNames, o = Date.CultureInfo.shortestDayNames, s = name.toLowerCase(); for (var i = 0; i < n.length; i++) { if (n[i].toLowerCase() === s || m[i].toLowerCase() === s || o[i].toLowerCase() === s) { return i; } } return -1; }; /** * Gets the month number (0-11) if given a Culture Info specific string which is a valid monthName or abbreviatedMonthName. * @param {String} The name of the month (eg. "February, "Feb", "october", "oct"). * @return {Number} The day number */ $D.getMonthNumberFromName = function (name) { var n = Date.CultureInfo.monthNames, m = Date.CultureInfo.abbreviatedMonthNames, s = name.toLowerCase(); for (var i = 0; i < n.length; i++) { if (n[i].toLowerCase() === s || m[i].toLowerCase() === s) { return i; } } return -1; }; /** * Gets the language appropriate month name when given the month number(0-11) * eg - 0 == January * @return {String} The month name */ $D.getMonthName = function (n) { return Date.CultureInfo.monthNames[n]; }; /** * Determines if the current date instance is within a LeapYear. * @param {Number} The year. * @return {Boolean} true if date is within a LeapYear, otherwise false. */ $D.isLeapYear = function (year) { return ((year % 4 === 0 && year % 100 !== 0) || year % 400 === 0); }; /** * Gets the number of days in the month, given a year and month value. Automatically corrects for LeapYear. * @param {Number} The year. * @param {Number} The month (0-11). * @return {Number} The number of days in the month. */ $D.getDaysInMonth = function (year, month) { if (!month && $D.validateMonth(year)) { month = year; year = Date.today().getFullYear(); } return [31, ($D.isLeapYear(year) ? 29 : 28), 31, 30, 31, 30, 31, 31, 30, 31, 30, 31][month]; }; $P.getDaysInMonth = function () { return $D.getDaysInMonth(this.getFullYear(), this.getMonth()); }; $D.getTimezoneAbbreviation = function (offset, dst) { var p, n = (dst || false) ? Date.CultureInfo.abbreviatedTimeZoneDST : Date.CultureInfo.abbreviatedTimeZoneStandard; for (p in n) { if (n.hasOwnProperty(p)) { if (n[p] === offset) { return p; } } } return null; }; $D.getTimezoneOffset = function (name, dst) { var i, a =[], z = Date.CultureInfo.timezones; if (!name) { name = (new Date()).getTimezone();} for (i = 0; i < z.length; i++) { if (z[i].name === name.toUpperCase()) { a.push(i); } } if (!z[a[0]]) { return null; } if (a.length === 1 || !dst) { return z[a[0]].offset; } else { for (i=0; i < a.length; i++) { if (z[a[i]].dst) { return z[a[i]].offset; } } } }; $D.getQuarter = function (d) { d = d || new Date(); // If no date supplied, use today var q = [1,2,3,4]; return q[Math.floor(d.getMonth() / 3)]; // ~~~ is a bitwise op. Faster than Math.floor }; $D.getDaysLeftInQuarter = function (d) { d = d || new Date(); var qEnd = new Date(d); qEnd.setMonth(qEnd.getMonth() + 3 - qEnd.getMonth() % 3, 0); return Math.floor((qEnd - d) / 8.64e7); }; // private var validate = function (n, min, max, name) { name = name ? name : "Object"; if (typeof n === "undefined") { return false; } else if (typeof n !== "number") { throw new TypeError(n + " is not a Number."); } else if (n < min || n > max) { // As failing validation is *not* an exceptional circumstance // lets not throw a RangeError Exception here. // It's semantically correct but it's not sensible. return false; } return true; }; /** * Validates the number is within an acceptable range for milliseconds [0-999]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateMillisecond = function (value) { return validate(value, 0, 999, "millisecond"); }; /** * Validates the number is within an acceptable range for seconds [0-59]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateSecond = function (value) { return validate(value, 0, 59, "second"); }; /** * Validates the number is within an acceptable range for minutes [0-59]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateMinute = function (value) { return validate(value, 0, 59, "minute"); }; /** * Validates the number is within an acceptable range for hours [0-23]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateHour = function (value) { return validate(value, 0, 23, "hour"); }; /** * Validates the number is within an acceptable range for the days in a month [0-MaxDaysInMonth]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateDay = function (value, year, month) { if (year === undefined || year === null || month === undefined || month === null) { return false;} return validate(value, 1, $D.getDaysInMonth(year, month), "day"); }; /** * Validates the number is within an acceptable range for months [0-11]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateWeek = function (value) { return validate(value, 0, 53, "week"); }; /** * Validates the number is within an acceptable range for months [0-11]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateMonth = function (value) { return validate(value, 0, 11, "month"); }; /** * Validates the number is within an acceptable range for years. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateYear = function (value) { /** * Per ECMAScript spec the range of times supported by Date objects is * exactly -100,000,000 days to +100,000,000 days measured relative to * midnight at the beginning of 01 January, 1970 UTC. * This gives a range of 8,640,000,000,000,000 milliseconds to either * side of 01 January, 1970 UTC. * * Earliest possible date: Tue, 20 Apr 271,822 B.C. 00:00:00 UTC * Latest possible date: Sat, 13 Sep 275,760 00:00:00 UTC */ return validate(value, -271822, 275760, "year"); }; $D.validateTimezone = function(value) { var timezones = {"ACDT":1,"ACST":1,"ACT":1,"ADT":1,"AEDT":1,"AEST":1,"AFT":1,"AKDT":1,"AKST":1,"AMST":1,"AMT":1,"ART":1,"AST":1,"AWDT":1,"AWST":1,"AZOST":1,"AZT":1,"BDT":1,"BIOT":1,"BIT":1,"BOT":1,"BRT":1,"BST":1,"BTT":1,"CAT":1,"CCT":1,"CDT":1,"CEDT":1,"CEST":1,"CET":1,"CHADT":1,"CHAST":1,"CHOT":1,"ChST":1,"CHUT":1,"CIST":1,"CIT":1,"CKT":1,"CLST":1,"CLT":1,"COST":1,"COT":1,"CST":1,"CT":1,"CVT":1,"CWST":1,"CXT":1,"DAVT":1,"DDUT":1,"DFT":1,"EASST":1,"EAST":1,"EAT":1,"ECT":1,"EDT":1,"EEDT":1,"EEST":1,"EET":1,"EGST":1,"EGT":1,"EIT":1,"EST":1,"FET":1,"FJT":1,"FKST":1,"FKT":1,"FNT":1,"GALT":1,"GAMT":1,"GET":1,"GFT":1,"GILT":1,"GIT":1,"GMT":1,"GST":1,"GYT":1,"HADT":1,"HAEC":1,"HAST":1,"HKT":1,"HMT":1,"HOVT":1,"HST":1,"ICT":1,"IDT":1,"IOT":1,"IRDT":1,"IRKT":1,"IRST":1,"IST":1,"JST":1,"KGT":1,"KOST":1,"KRAT":1,"KST":1,"LHST":1,"LINT":1,"MAGT":1,"MART":1,"MAWT":1,"MDT":1,"MET":1,"MEST":1,"MHT":1,"MIST":1,"MIT":1,"MMT":1,"MSK":1,"MST":1,"MUT":1,"MVT":1,"MYT":1,"NCT":1,"NDT":1,"NFT":1,"NPT":1,"NST":1,"NT":1,"NUT":1,"NZDT":1,"NZST":1,"OMST":1,"ORAT":1,"PDT":1,"PET":1,"PETT":1,"PGT":1,"PHOT":1,"PHT":1,"PKT":1,"PMDT":1,"PMST":1,"PONT":1,"PST":1,"PYST":1,"PYT":1,"RET":1,"ROTT":1,"SAKT":1,"SAMT":1,"SAST":1,"SBT":1,"SCT":1,"SGT":1,"SLST":1,"SRT":1,"SST":1,"SYOT":1,"TAHT":1,"THA":1,"TFT":1,"TJT":1,"TKT":1,"TLT":1,"TMT":1,"TOT":1,"TVT":1,"UCT":1,"ULAT":1,"UTC":1,"UYST":1,"UYT":1,"UZT":1,"VET":1,"VLAT":1,"VOLT":1,"VOST":1,"VUT":1,"WAKT":1,"WAST":1,"WAT":1,"WEDT":1,"WEST":1,"WET":1,"WST":1,"YAKT":1,"YEKT":1,"Z":1}; return (timezones[value] === 1); }; $D.validateTimezoneOffset= function(value) { // timezones go from +14hrs to -12hrs, the +X hours are negative offsets. return (value > -841 && value < 721); }; }()); (function () { var $D = Date, $P = $D.prototype, p = function (s, l) { if (!l) { l = 2; } return ("000" + s).slice(l * -1); }; var validateConfigObject = function (obj) { var result = {}, self = this, prop, testFunc; testFunc = function (prop, func, value) { if (prop === "day") { var month = (obj.month !== undefined) ? obj.month : self.getMonth(); var year = (obj.year !== undefined) ? obj.year : self.getFullYear(); return $D[func](value, year, month); } else { return $D[func](value); } }; for (prop in obj) { if (Object.prototype.hasOwnProperty.call(obj, prop)) { var func = "validate" + prop.charAt(0).toUpperCase() + prop.slice(1); if ($D[func] && obj[prop] !== null && testFunc(prop, func, obj[prop])) { result[prop] = obj[prop]; } } } return result; }; /** * Resets the time of this Date object to 12:00 AM (00:00), which is the start of the day. * @param {Boolean} .clone() this date instance before clearing Time * @return {Date} this */ $P.clearTime = function () { this.setHours(0); this.setMinutes(0); this.setSeconds(0); this.setMilliseconds(0); return this; }; /** * Resets the time of this Date object to the current time ('now'). * @return {Date} this */ $P.setTimeToNow = function () { var n = new Date(); this.setHours(n.getHours()); this.setMinutes(n.getMinutes()); this.setSeconds(n.getSeconds()); this.setMilliseconds(n.getMilliseconds()); return this; }; /** * Returns a new Date object that is an exact date and time copy of the original instance. * @return {Date} A new Date instance */ $P.clone = function () { return new Date(this.getTime()); }; /** * Compares this instance to a Date object and returns an number indication of their relative values. * @param {Date} Date object to compare [Required] * @return {Number} -1 = this is lessthan date. 0 = values are equal. 1 = this is greaterthan date. */ $P.compareTo = function (date) { return Date.compare(this, date); }; /** * Compares this instance to another Date object and returns true if they are equal. * @param {Date} Date object to compare. If no date to compare, new Date() [now] is used. * @return {Boolean} true if dates are equal. false if they are not equal. */ $P.equals = function (date) { return Date.equals(this, (date !== undefined ? date : new Date())); }; /** * Determines if this instance is between a range of two dates or equal to either the start or end dates. * @param {Date} Start of range [Required] * @param {Date} End of range [Required] * @return {Boolean} true is this is between or equal to the start and end dates, else false */ $P.between = function (start, end) { return this.getTime() >= start.getTime() && this.getTime() <= end.getTime(); }; /** * Determines if this date occurs after the date to compare to. * @param {Date} Date object to compare. If no date to compare, new Date() ("now") is used. * @return {Boolean} true if this date instance is greater than the date to compare to (or "now"), otherwise false. */ $P.isAfter = function (date) { return this.compareTo(date || new Date()) === 1; }; /** * Determines if this date occurs before the date to compare to. * @param {Date} Date object to compare. If no date to compare, new Date() ("now") is used. * @return {Boolean} true if this date instance is less than the date to compare to (or "now"). */ $P.isBefore = function (date) { return (this.compareTo(date || new Date()) === -1); }; /** * Determines if the current Date instance occurs today. * @return {Boolean} true if this date instance is 'today', otherwise false. */ /** * Determines if the current Date instance occurs on the same Date as the supplied 'date'. * If no 'date' to compare to is provided, the current Date instance is compared to 'today'. * @param {date} Date object to compare. If no date to compare, the current Date ("now") is used. * @return {Boolean} true if this Date instance occurs on the same Day as the supplied 'date'. */ $P.isToday = $P.isSameDay = function (date) { return this.clone().clearTime().equals((date || new Date()).clone().clearTime()); }; /** * Adds the specified number of milliseconds to this instance. * @param {Number} The number of milliseconds to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addMilliseconds = function (value) { if (!value) { return this; } this.setTime(this.getTime() + value * 1); return this; }; /** * Adds the specified number of seconds to this instance. * @param {Number} The number of seconds to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addSeconds = function (value) { if (!value) { return this; } return this.addMilliseconds(value * 1000); }; /** * Adds the specified number of seconds to this instance. * @param {Number} The number of seconds to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addMinutes = function (value) { if (!value) { return this; } return this.addMilliseconds(value * 60000); // 60*1000 }; /** * Adds the specified number of hours to this instance. * @param {Number} The number of hours to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addHours = function (value) { if (!value) { return this; } return this.addMilliseconds(value * 3600000); // 60*60*1000 }; /** * Adds the specified number of days to this instance. * @param {Number} The number of days to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addDays = function (value) { if (!value) { return this; } this.setDate(this.getDate() + value * 1); return this; }; /** * Adds the specified number of weekdays (ie - not sat or sun) to this instance. * @param {Number} The number of days to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addWeekdays = function (value) { if (!value) { return this; } var day = this.getDay(); var weeks = (Math.ceil(Math.abs(value)/7)); if (day === 0 || day === 6) { if (value > 0) { this.next().monday(); this.addDays(-1); day = this.getDay(); } } if (value < 0) { while (value < 0) { this.addDays(-1); day = this.getDay(); if (day !== 0 && day !== 6) { value++; } } return this; } else if (value > 5 || (6-day) <= value) { value = value + (weeks * 2); } return this.addDays(value); }; /** * Adds the specified number of weeks to this instance. * @param {Number} The number of weeks to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addWeeks = function (value) { if (!value) { return this; } return this.addDays(value * 7); }; /** * Adds the specified number of months to this instance. * @param {Number} The number of months to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addMonths = function (value) { if (!value) { return this; } var n = this.getDate(); this.setDate(1); this.setMonth(this.getMonth() + value * 1); this.setDate(Math.min(n, $D.getDaysInMonth(this.getFullYear(), this.getMonth()))); return this; }; $P.addQuarters = function (value) { if (!value) { return this; } // note this will take you to the same point in the quarter as you are now. // i.e. - if you are 15 days into the quarter you'll be 15 days into the resulting one. // bonus: this allows adding fractional quarters return this.addMonths(value * 3); }; /** * Adds the specified number of years to this instance. * @param {Number} The number of years to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addYears = function (value) { if (!value) { return this; } return this.addMonths(value * 12); }; /** * Adds (or subtracts) to the value of the years, months, weeks, days, hours, minutes, seconds, milliseconds of the date instance using given configuration object. Positive and Negative values allowed. * Example

	Date.today().add( { days: 1, months: 1 } )

	new Date().add( { years: -1 } )
	
* @param {Object} Configuration object containing attributes (months, days, etc.) * @return {Date} this */ $P.add = function (config) { if (typeof config === "number") { this._orient = config; return this; } var x = config; if (x.day) { // If we should be a different date than today (eg: for 'tomorrow -1d', etc). // Should only effect parsing, not direct usage (eg, Finish and FinishExact) if ((x.day - this.getDate()) !== 0) { this.setDate(x.day); } } if (x.milliseconds) { this.addMilliseconds(x.milliseconds); } if (x.seconds) { this.addSeconds(x.seconds); } if (x.minutes) { this.addMinutes(x.minutes); } if (x.hours) { this.addHours(x.hours); } if (x.weeks) { this.addWeeks(x.weeks); } if (x.months) { this.addMonths(x.months); } if (x.years) { this.addYears(x.years); } if (x.days) { this.addDays(x.days); } return this; }; /** * Get the week number. Week one (1) is the week which contains the first Thursday of the year. Monday is considered the first day of the week. * The .getWeek() function does NOT convert the date to UTC. The local datetime is used. * Please use .getISOWeek() to get the week of the UTC converted date. * @return {Number} 1 to 53 */ $P.getWeek = function (utc) { // Create a copy of this date object var self, target = new Date(this.valueOf()); if (utc) { target.addMinutes(target.getTimezoneOffset()); self = target.clone(); } else { self = this; } // ISO week date weeks start on monday // so correct the day number var dayNr = (self.getDay() + 6) % 7; // ISO 8601 states that week 1 is the week // with the first thursday of that year. // Set the target date to the thursday in the target week target.setDate(target.getDate() - dayNr + 3); // Store the millisecond value of the target date var firstThursday = target.valueOf(); // Set the target to the first thursday of the year // First set the target to january first target.setMonth(0, 1); // Not a thursday? Correct the date to the next thursday if (target.getDay() !== 4) { target.setMonth(0, 1 + ((4 - target.getDay()) + 7) % 7); } // The weeknumber is the number of weeks between the // first thursday of the year and the thursday in the target week return 1 + Math.ceil((firstThursday - target) / 604800000); // 604800000 = 7 * 24 * 3600 * 1000 }; /** * Get the ISO 8601 week number. Week one ("01") is the week which contains the first Thursday of the year. Monday is considered the first day of the week. * The .getISOWeek() function does convert the date to it's UTC value. Please use .getWeek() to get the week of the local date. * @return {String} "01" to "53" */ $P.getISOWeek = function () { return p(this.getWeek(true)); }; /** * Moves the date to Monday of the week set. Week one (1) is the week which contains the first Thursday of the year. * @param {Number} A Number (1 to 53) that represents the week of the year. * @return {Date} this */ $P.setWeek = function (n) { if ((n - this.getWeek()) === 0) { if (this.getDay() !== 1) { return this.moveToDayOfWeek(1, (this.getDay() > 1 ? -1 : 1)); } else { return this; } } else { return this.moveToDayOfWeek(1, (this.getDay() > 1 ? -1 : 1)).addWeeks(n - this.getWeek()); } }; $P.setQuarter = function (qtr) { var month = Math.abs(((qtr-1) * 3) + 1); return this.setMonth(month, 1); }; $P.getQuarter = function () { return Date.getQuarter(this); }; $P.getDaysLeftInQuarter = function () { return Date.getDaysLeftInQuarter(this); }; /** * Moves the date to the next n'th occurrence of the dayOfWeek starting from the beginning of the month. The number (-1) is a magic number and will return the last occurrence of the dayOfWeek in the month. * @param {Number} The dayOfWeek to move to * @param {Number} The n'th occurrence to move to. Use (-1) to return the last occurrence in the month * @return {Date} this */ $P.moveToNthOccurrence = function (dayOfWeek, occurrence) { if (dayOfWeek === "Weekday") { if (occurrence > 0) { this.moveToFirstDayOfMonth(); if (this.is().weekday()) { occurrence -= 1; } } else if (occurrence < 0) { this.moveToLastDayOfMonth(); if (this.is().weekday()) { occurrence += 1; } } else { return this; } return this.addWeekdays(occurrence); } var shift = 0; if (occurrence > 0) { shift = occurrence - 1; } else if (occurrence === -1) { this.moveToLastDayOfMonth(); if (this.getDay() !== dayOfWeek) { this.moveToDayOfWeek(dayOfWeek, -1); } return this; } return this.moveToFirstDayOfMonth().addDays(-1).moveToDayOfWeek(dayOfWeek, +1).addWeeks(shift); }; var moveToN = function (getFunc, addFunc, nVal) { return function (value, orient) { var diff = (value - this[getFunc]() + nVal * (orient || +1)) % nVal; return this[addFunc]((diff === 0) ? diff += nVal * (orient || +1) : diff); }; }; /** * Move to the next or last dayOfWeek based on the orient value. * @param {Number} The dayOfWeek to move to * @param {Number} Forward (+1) or Back (-1). Defaults to +1. [Optional] * @return {Date} this */ $P.moveToDayOfWeek = moveToN("getDay", "addDays", 7); /** * Move to the next or last month based on the orient value. * @param {Number} The month to move to. 0 = January, 11 = December * @param {Number} Forward (+1) or Back (-1). Defaults to +1. [Optional] * @return {Date} this */ $P.moveToMonth = moveToN("getMonth", "addMonths", 12); /** * Get the Ordinate of the current day ("th", "st", "rd"). * @return {String} */ $P.getOrdinate = function () { var num = this.getDate(); return ord(num); }; /** * Get the Ordinal day (numeric day number) of the year, adjusted for leap year. * @return {Number} 1 through 365 (366 in leap years) */ $P.getOrdinalNumber = function () { return Math.ceil((this.clone().clearTime() - new Date(this.getFullYear(), 0, 1)) / 86400000) + 1; }; /** * Get the time zone abbreviation of the current date. * @return {String} The abbreviated time zone name (e.g. "EST") */ $P.getTimezone = function () { return $D.getTimezoneAbbreviation(this.getUTCOffset(), this.isDaylightSavingTime()); }; $P.setTimezoneOffset = function (offset) { var here = this.getTimezoneOffset(), there = Number(offset) * -6 / 10; return (there || there === 0) ? this.addMinutes(there - here) : this; }; $P.setTimezone = function (offset) { return this.setTimezoneOffset($D.getTimezoneOffset(offset)); }; /** * Indicates whether Daylight Saving Time is observed in the current time zone. * @return {Boolean} true|false */ $P.hasDaylightSavingTime = function () { return (Date.today().set({month: 0, day: 1}).getTimezoneOffset() !== Date.today().set({month: 6, day: 1}).getTimezoneOffset()); }; /** * Indicates whether this Date instance is within the Daylight Saving Time range for the current time zone. * @return {Boolean} true|false */ $P.isDaylightSavingTime = function () { return Date.today().set({month: 0, day: 1}).getTimezoneOffset() !== this.getTimezoneOffset(); }; /** * Get the offset from UTC of the current date. * @return {String} The 4-character offset string prefixed with + or - (e.g. "-0500") */ $P.getUTCOffset = function (offset) { var n = (offset || this.getTimezoneOffset()) * -10 / 6, r; if (n < 0) { r = (n - 10000).toString(); return r.charAt(0) + r.substr(2); } else { r = (n + 10000).toString(); return "+" + r.substr(1); } }; /** * Returns the number of milliseconds between this date and date. * @param {Date} Defaults to now * @return {Number} The diff in milliseconds */ $P.getElapsed = function (date) { return (date || new Date()) - this; }; /** * Set the value of year, month, day, hour, minute, second, millisecond of date instance using given configuration object. * Example

	Date.today().set( { day: 20, month: 1 } )

	new Date().set( { millisecond: 0 } )
	
* * @param {Object} Configuration object containing attributes (month, day, etc.) * @return {Date} this */ $P.set = function (config) { config = validateConfigObject.call(this, config); var key; for (key in config) { if (Object.prototype.hasOwnProperty.call(config, key)) { var name = key.charAt(0).toUpperCase() + key.slice(1); var addFunc, getFunc; if (key !== "week" && key !== "month" && key !== "timezone" && key !== "timezoneOffset") { name += "s"; } addFunc = "add" + name; getFunc = "get" + name; if (key === "month") { addFunc = addFunc + "s"; } else if (key === "year"){ getFunc = "getFullYear"; } if (key !== "day" && key !== "timezone" && key !== "timezoneOffset" && key !== "week" && key !== "hour") { this[addFunc](config[key] - this[getFunc]()); } else if ( key === "timezone"|| key === "timezoneOffset" || key === "week" || key === "hour") { this["set"+name](config[key]); } } } // day has to go last because you can't validate the day without first knowing the month if (config.day) { this.addDays(config.day - this.getDate()); } return this; }; /** * Moves the date to the first day of the month. * @return {Date} this */ $P.moveToFirstDayOfMonth = function () { return this.set({ day: 1 }); }; /** * Moves the date to the last day of the month. * @return {Date} this */ $P.moveToLastDayOfMonth = function () { return this.set({ day: $D.getDaysInMonth(this.getFullYear(), this.getMonth())}); }; /** * Converts the value of the current Date object to its equivalent string representation. * Format Specifiers * CUSTOM DATE AND TIME FORMAT STRINGS * Format Description Example * ------ --------------------------------------------------------------------------- ----------------------- * s The seconds of the minute between 0-59. "0" to "59" * ss The seconds of the minute with leading zero if required. "00" to "59" * * m The minute of the hour between 0-59. "0" or "59" * mm The minute of the hour with leading zero if required. "00" or "59" * * h The hour of the day between 1-12. "1" to "12" * hh The hour of the day with leading zero if required. "01" to "12" * * H The hour of the day between 0-23. "0" to "23" * HH The hour of the day with leading zero if required. "00" to "23" * * d The day of the month between 1 and 31. "1" to "31" * dd The day of the month with leading zero if required. "01" to "31" * ddd Abbreviated day name. Date.CultureInfo.abbreviatedDayNames. "Mon" to "Sun" * dddd The full day name. Date.CultureInfo.dayNames. "Monday" to "Sunday" * * M The month of the year between 1-12. "1" to "12" * MM The month of the year with leading zero if required. "01" to "12" * MMM Abbreviated month name. Date.CultureInfo.abbreviatedMonthNames. "Jan" to "Dec" * MMMM The full month name. Date.CultureInfo.monthNames. "January" to "December" * * yy The year as a two-digit number. "99" or "08" * yyyy The full four digit year. "1999" or "2008" * * t Displays the first character of the A.M./P.M. designator. "A" or "P" * Date.CultureInfo.amDesignator or Date.CultureInfo.pmDesignator * tt Displays the A.M./P.M. designator. "AM" or "PM" * Date.CultureInfo.amDesignator or Date.CultureInfo.pmDesignator * * S The ordinal suffix ("st, "nd", "rd" or "th") of the current day. "st, "nd", "rd" or "th" * * STANDARD DATE AND TIME FORMAT STRINGS * Format Description Example *------ --------------------------------------------------------------------------- ----------------------- * d The CultureInfo shortDate Format Pattern "M/d/yyyy" * D The CultureInfo longDate Format Pattern "dddd, MMMM dd, yyyy" * F The CultureInfo fullDateTime Format Pattern "dddd, MMMM dd, yyyy h:mm:ss tt" * m The CultureInfo monthDay Format Pattern "MMMM dd" * r The CultureInfo rfc1123 Format Pattern "ddd, dd MMM yyyy HH:mm:ss GMT" * s The CultureInfo sortableDateTime Format Pattern "yyyy-MM-ddTHH:mm:ss" * t The CultureInfo shortTime Format Pattern "h:mm tt" * T The CultureInfo longTime Format Pattern "h:mm:ss tt" * u The CultureInfo universalSortableDateTime Format Pattern "yyyy-MM-dd HH:mm:ssZ" * y The CultureInfo yearMonth Format Pattern "MMMM, yyyy" * * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @return {String} A string representation of the current Date object. */ var ord = function (n) { switch (n * 1) { case 1: case 21: case 31: return "st"; case 2: case 22: return "nd"; case 3: case 23: return "rd"; default: return "th"; } }; var parseStandardFormats = function (format) { var y, c = Date.CultureInfo.formatPatterns; switch (format) { case "d": return this.toString(c.shortDate); case "D": return this.toString(c.longDate); case "F": return this.toString(c.fullDateTime); case "m": return this.toString(c.monthDay); case "r": case "R": y = this.clone().addMinutes(this.getTimezoneOffset()); return y.toString(c.rfc1123) + " GMT"; case "s": return this.toString(c.sortableDateTime); case "t": return this.toString(c.shortTime); case "T": return this.toString(c.longTime); case "u": y = this.clone().addMinutes(this.getTimezoneOffset()); return y.toString(c.universalSortableDateTime); case "y": return this.toString(c.yearMonth); default: return false; } }; var parseFormatStringsClosure = function (context) { return function (m) { if (m.charAt(0) === "\\") { return m.replace("\\", ""); } switch (m) { case "hh": return p(context.getHours() < 13 ? (context.getHours() === 0 ? 12 : context.getHours()) : (context.getHours() - 12)); case "h": return context.getHours() < 13 ? (context.getHours() === 0 ? 12 : context.getHours()) : (context.getHours() - 12); case "HH": return p(context.getHours()); case "H": return context.getHours(); case "mm": return p(context.getMinutes()); case "m": return context.getMinutes(); case "ss": return p(context.getSeconds()); case "s": return context.getSeconds(); case "yyyy": return p(context.getFullYear(), 4); case "yy": return p(context.getFullYear()); case "y": return context.getFullYear(); case "E": case "dddd": return Date.CultureInfo.dayNames[context.getDay()]; case "ddd": return Date.CultureInfo.abbreviatedDayNames[context.getDay()]; case "dd": return p(context.getDate()); case "d": return context.getDate(); case "MMMM": return Date.CultureInfo.monthNames[context.getMonth()]; case "MMM": return Date.CultureInfo.abbreviatedMonthNames[context.getMonth()]; case "MM": return p((context.getMonth() + 1)); case "M": return context.getMonth() + 1; case "t": return context.getHours() < 12 ? Date.CultureInfo.amDesignator.substring(0, 1) : Date.CultureInfo.pmDesignator.substring(0, 1); case "tt": return context.getHours() < 12 ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator; case "S": return ord(context.getDate()); case "W": return context.getWeek(); case "WW": return context.getISOWeek(); case "Q": return "Q" + context.getQuarter(); case "q": return String(context.getQuarter()); case "z": return context.getTimezone(); case "Z": case "X": return Date.getTimezoneOffset(context.getTimezone()); case "ZZ": // Timezone offset in seconds return context.getTimezoneOffset() * -60; case "u": return context.getDay(); case "L": return ($D.isLeapYear(context.getFullYear())) ? 1 : 0; case "B": // Swatch Internet Time (.beats) return "@"+((context.getUTCSeconds() + (context.getUTCMinutes()*60) + ((context.getUTCHours()+1)*3600))/86.4); default: return m; } }; }; $P.toString = function (format, ignoreStandards) { // Standard Date and Time Format Strings. Formats pulled from CultureInfo file and // may vary by culture. if (!ignoreStandards && format && format.length === 1) { output = parseStandardFormats.call(this, format); if (output) { return output; } } var parseFormatStrings = parseFormatStringsClosure(this); return format ? format.replace(/((\\)?(dd?d?d?|MM?M?M?|yy?y?y?|hh?|HH?|mm?|ss?|tt?|S|q|Q|WW?W?W?)(?![^\[]*\]))/g, parseFormatStrings).replace(/\[|\]/g, "") : this._toString(); }; }()); /************************************************************* * SugarPak - Domain Specific Language - Syntactical Sugar * *************************************************************/ (function () { var $D = Date, $P = $D.prototype, $N = Number.prototype; // private $P._orient = +1; // private $P._nth = null; // private $P._is = false; // private $P._same = false; // private $P._isSecond = false; // private $N._dateElement = "days"; /** * Moves the date to the next instance of a date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.today().next().friday();
	Date.today().next().fri();
	Date.today().next().march();
	Date.today().next().mar();
	Date.today().next().week();
	
* * @return {Date} date */ $P.next = function () { this._move = true; this._orient = +1; return this; }; /** * Creates a new Date (Date.today()) and moves the date to the next instance of the date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.next().friday();
	Date.next().fri();
	Date.next().march();
	Date.next().mar();
	Date.next().week();
	
* * @return {Date} date */ $D.next = function () { return $D.today().next(); }; /** * Moves the date to the previous instance of a date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.today().last().friday();
	Date.today().last().fri();
	Date.today().last().march();
	Date.today().last().mar();
	Date.today().last().week();
	
* * @return {Date} date */ $P.last = $P.prev = $P.previous = function () { this._move = true; this._orient = -1; return this; }; /** * Creates a new Date (Date.today()) and moves the date to the previous instance of the date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.last().friday();
	Date.last().fri();
	Date.previous().march();
	Date.prev().mar();
	Date.last().week();
	
* * @return {Date} date */ $D.last = $D.prev = $D.previous = function () { return $D.today().last(); }; /** * Performs a equality check when followed by either a month name, day name or .weekday() function. * Example

	Date.today().is().friday(); // true|false
	Date.today().is().fri();
	Date.today().is().march();
	Date.today().is().mar();
	
* * @return {Boolean} true|false */ $P.is = function () { this._is = true; return this; }; /** * Determines if two date objects occur on/in exactly the same instance of the subsequent date part function. * The function .same() must be followed by a date part function (example: .day(), .month(), .year(), etc). * * An optional Date can be passed in the date part function. If now date is passed as a parameter, 'Now' is used. * * The following example demonstrates how to determine if two dates fall on the exact same day. * * Example

	var d1 = Date.today(); // today at 00:00
	var d2 = new Date();   // exactly now.

	// Do they occur on the same day?
	d1.same().day(d2); // true
	
	// Do they occur on the same hour?
	d1.same().hour(d2); // false, unless d2 hour is '00' (midnight).
	
	// What if it's the same day, but one year apart?
	var nextYear = Date.today().add(1).year();

	d1.same().day(nextYear); // false, because the dates must occur on the exact same day. 
	
* * Scenario: Determine if a given date occurs during some week period 2 months from now. * * Example

	var future = Date.today().add(2).months();
	return someDate.same().week(future); // true|false;
	
* * @return {Boolean} true|false */ $P.same = function () { this._same = true; this._isSecond = false; return this; }; /** * Determines if the current date/time occurs during Today. Must be preceded by the .is() function. * Example

	someDate.is().today();    // true|false
	new Date().is().today();  // true
	Date.today().is().today();// true
	Date.today().add(-1).day().is().today(); // false
	
* * @return {Boolean} true|false */ $P.today = function () { return this.same().day(); }; /** * Determines if the current date is a weekday. This function must be preceded by the .is() function. * Example

	Date.today().is().weekday(); // true|false
	
* * @return {Boolean} true|false */ $P.weekday = function () { if (this._nth) { return df("Weekday").call(this); } if (this._move) { return this.addWeekdays(this._orient); } if (this._is) { this._is = false; return (!this.is().sat() && !this.is().sun()); } return false; }; /** * Determines if the current date is on the weekend. This function must be preceded by the .is() function. * Example

	Date.today().is().weekend(); // true|false
	
* * @return {Boolean} true|false */ $P.weekend = function () { if (this._is) { this._is = false; return (this.is().sat() || this.is().sun()); } return false; }; /** * Sets the Time of the current Date instance. A string "6:15 pm" or config object {hour:18, minute:15} are accepted. * Example

	// Set time to 6:15pm with a String
	Date.today().at("6:15pm");

	// Set time to 6:15pm with a config object
	Date.today().at({hour:18, minute:15});
	
* * @return {Date} date */ $P.at = function (time) { return (typeof time === "string") ? $D.parse(this.toString("d") + " " + time) : this.set(time); }; /** * Creates a new Date() and adds this (Number) to the date based on the preceding date element function (eg. second|minute|hour|day|month|year). * Example

	// Undeclared Numbers must be wrapped with parentheses. Requirment of JavaScript.
	(3).days().fromNow();
	(6).months().fromNow();

	// Declared Number variables do not require parentheses. 
	var n = 6;
	n.months().fromNow();
	
* * @return {Date} A new Date instance */ $N.fromNow = $N.after = function (date) { var c = {}; c[this._dateElement] = this; return ((!date) ? new Date() : date.clone()).add(c); }; /** * Creates a new Date() and subtract this (Number) from the date based on the preceding date element function (eg. second|minute|hour|day|month|year). * Example

	// Undeclared Numbers must be wrapped with parentheses. Requirment of JavaScript.
	(3).days().ago();
	(6).months().ago();

	// Declared Number variables do not require parentheses. 
	var n = 6;
	n.months().ago();
	
* * @return {Date} A new Date instance */ $N.ago = $N.before = function (date) { var c = {}, s = (this._dateElement[this._dateElement.length-1] !== "s") ? this._dateElement + "s" : this._dateElement; c[s] = this * -1; return ((!date) ? new Date() : date.clone()).add(c); }; // Do NOT modify the following string tokens. These tokens are used to build dynamic functions. // All culture-specific strings can be found in the CultureInfo files. var dx = ("sunday monday tuesday wednesday thursday friday saturday").split(/\s/), mx = ("january february march april may june july august september october november december").split(/\s/), px = ("Millisecond Second Minute Hour Day Week Month Year Quarter Weekday").split(/\s/), pxf = ("Milliseconds Seconds Minutes Hours Date Week Month FullYear Quarter").split(/\s/), nth = ("final first second third fourth fifth").split(/\s/), de; /** * Returns an object literal of all the date parts. * Example

	var o = new Date().toObject();
	
	// { year: 2008, month: 4, week: 20, day: 13, hour: 18, minute: 9, second: 32, millisecond: 812 }
	
	// The object properties can be referenced directly from the object.
	
	alert(o.day);  // alerts "13"
	alert(o.year); // alerts "2008"
	
* * @return {Date} An object literal representing the original date object. */ $P.toObject = function () { var o = {}; for (var i = 0; i < px.length; i++) { if (this["get" + pxf[i]]) { o[px[i].toLowerCase()] = this["get" + pxf[i]](); } } return o; }; /** * Returns a date created from an object literal. Ignores the .week property if set in the config. * Example

	var o = new Date().toObject();
	
	return Date.fromObject(o); // will return the same date. 

	var o2 = {month: 1, day: 20, hour: 18}; // birthday party!
	Date.fromObject(o2);
	
* * @return {Date} An object literal representing the original date object. */ $D.fromObject = function(config) { config.week = null; return Date.today().set(config); }; // Create day name functions and abbreviated day name functions (eg. monday(), friday(), fri()). var df = function (n) { return function () { if (this._is) { this._is = false; return this.getDay() === n; } if (this._move) { this._move = null; } if (this._nth !== null) { // If the .second() function was called earlier, remove the _orient // from the date, and then continue. // This is required because 'second' can be used in two different context. // // Example // // Date.today().add(1).second(); // Date.march().second().monday(); // // Things get crazy with the following... // Date.march().add(1).second().second().monday(); // but it works!! // if (this._isSecond) { this.addSeconds(this._orient * -1); } // make sure we reset _isSecond this._isSecond = false; var ntemp = this._nth; this._nth = null; var temp = this.clone().moveToLastDayOfMonth(); this.moveToNthOccurrence(n, ntemp); if (this > temp) { throw new RangeError($D.getDayName(n) + " does not occur " + ntemp + " times in the month of " + $D.getMonthName(temp.getMonth()) + " " + temp.getFullYear() + "."); } return this; } return this.moveToDayOfWeek(n, this._orient); }; }; var sdf = function (n) { return function () { var t = $D.today(), shift = n - t.getDay(); if (n === 0 && Date.CultureInfo.firstDayOfWeek === 1 && t.getDay() !== 0) { shift = shift + 7; } return t.addDays(shift); }; }; // Create month name functions and abbreviated month name functions (eg. january(), march(), mar()). var month_instance_functions = function (n) { return function () { if (this._is) { this._is = false; return this.getMonth() === n; } return this.moveToMonth(n, this._orient); }; }; var month_static_functions = function (n) { return function () { return $D.today().set({ month: n, day: 1 }); }; }; var processTerms = function (names, staticFunc, instanceFunc) { for (var i = 0; i < names.length; i++) { // Create constant static Name variables. $D[names[i].toUpperCase()] = $D[names[i].toUpperCase().substring(0, 3)] = i; // Create Name functions. $D[names[i]] = $D[names[i].substring(0, 3)] = staticFunc(i); // Create Name instance functions. $P[names[i]] = $P[names[i].substring(0, 3)] = instanceFunc(i); } }; processTerms(dx, sdf, df); processTerms(mx, month_static_functions, month_instance_functions); // Create date element functions and plural date element functions used with Date (eg. day(), days(), months()). var ef = function (j) { return function () { // if the .second() function was called earlier, the _orient // has alread been added. Just return this and reset _isSecond. if (this._isSecond) { this._isSecond = false; return this; } if (this._same) { this._same = this._is = false; var o1 = this.toObject(), o2 = (arguments[0] || new Date()).toObject(), v = "", k = j.toLowerCase(); // the substr trick with -1 doesn't work in IE8 or less k = (k[k.length-1] === "s") ? k.substring(0,k.length-1) : k; for (var m = (px.length - 1); m > -1; m--) { v = px[m].toLowerCase(); if (o1[v] !== o2[v]) { return false; } if (k === v) { break; } } return true; } if (j.substring(j.length - 1) !== "s") { j += "s"; } if (this._move) { this._move = null; } return this["add" + j](this._orient); }; }; var nf = function (n) { return function () { this._dateElement = n; return this; }; }; for (var k = 0; k < px.length; k++) { de = px[k].toLowerCase(); if(de !== "weekday") { // Create date element functions and plural date element functions used with Date (eg. day(), days(), months()). $P[de] = $P[de + "s"] = ef(px[k]); // Create date element functions and plural date element functions used with Number (eg. day(), days(), months()). $N[de] = $N[de + "s"] = nf(de + "s"); } } $P._ss = ef("Second"); var nthfn = function (n) { return function (dayOfWeek) { if (this._same) { return this._ss(arguments[0]); } if (dayOfWeek || dayOfWeek === 0) { return this.moveToNthOccurrence(dayOfWeek, n); } this._nth = n; // if the operator is 'second' add the _orient, then deal with it later... if (n === 2 && (dayOfWeek === undefined || dayOfWeek === null)) { this._isSecond = true; return this.addSeconds(this._orient); } return this; }; }; for (var l = 0; l < nth.length; l++) { $P[nth[l]] = (l === 0) ? nthfn(-1) : nthfn(l); } }()); (function () { "use strict"; Date.Parsing = { Exception: function (s) { this.message = "Parse error at '" + s.substring(0, 10) + " ...'"; } }; var $P = Date.Parsing; var dayOffsets = { standard: [0,31,59,90,120,151,181,212,243,273,304,334], leap: [0,31,60,91,121,152,182,213,244,274,305,335] }; $P.isLeapYear = function(year) { return ((year % 4 === 0) && (year % 100 !== 0)) || (year % 400 === 0); }; var utils = { multiReplace : function (str, hash ) { var key; for (key in hash) { if (Object.prototype.hasOwnProperty.call(hash, key)) { var regex; if (typeof hash[key] === "function") { } else { regex = (hash[key] instanceof RegExp) ? hash[key] : new RegExp(hash[key], "g"); } str = str.replace(regex, key); } } return str; }, getDayOfYearFromWeek : function (obj) { var d, jan4, offset; obj.weekDay = (!obj.weekDay && obj.weekDay !== 0) ? 1 : obj.weekDay; d = new Date(obj.year, 0, 4); jan4 = d.getDay() === 0 ? 7 : d.getDay(); // JS is 0 indexed on Sunday. offset = jan4+3; obj.dayOfYear = ((obj.week * 7) + (obj.weekDay === 0 ? 7 : obj.weekDay))-offset; return obj; }, getDayOfYear : function (obj, dayOffset) { if (!obj.dayOfYear) { obj = utils.getDayOfYearFromWeek(obj); } for (var i=0;i <= dayOffset.length;i++) { if (obj.dayOfYear < dayOffset[i] || i === dayOffset.length) { obj.day = obj.day ? obj.day : (obj.dayOfYear - dayOffset[i-1]); break; } else { obj.month = i; } } return obj; }, adjustForTimeZone : function (obj, date) { var offset; if (obj.zone.toUpperCase() === "Z" || (obj.zone_hours === 0 && obj.zone_minutes === 0)) { // it's UTC/GML so work out the current timeszone offset offset = -date.getTimezoneOffset(); } else { offset = (obj.zone_hours*60) + (obj.zone_minutes || 0); if (obj.zone_sign === "+") { offset *= -1; } offset -= date.getTimezoneOffset(); } date.setMinutes(date.getMinutes()+offset); return date; }, setDefaults : function (obj) { obj.year = obj.year || Date.today().getFullYear(); obj.hours = obj.hours || 0; obj.minutes = obj.minutes || 0; obj.seconds = obj.seconds || 0; obj.milliseconds = obj.milliseconds || 0; if (!(!obj.month && (obj.week || obj.dayOfYear))) { // if we have a month, or if we don't but don't have the day calculation data obj.month = obj.month || 0; obj.day = obj.day || 1; } return obj; }, dataNum: function (data, mod, explict, postProcess) { var dataNum = data*1; if (mod) { if (postProcess) { return data ? mod(data)*1 : data; } else { return data ? mod(dataNum) : data; } } else if (!explict){ return data ? dataNum : data; } else { return (data && typeof data !== "undefined") ? dataNum : data; } }, timeDataProcess: function (obj) { var timeObj = {}; for (var x in obj.data) { if (obj.data.hasOwnProperty(x)) { timeObj[x] = obj.ignore[x] ? obj.data[x] : utils.dataNum(obj.data[x], obj.mods[x], obj.explict[x], obj.postProcess[x]); } } if (obj.data.secmins) { obj.data.secmins = obj.data.secmins.replace(",", ".") * 60; if (!timeObj.minutes) { timeObj.minutes = obj.data.secmins; } else if (!timeObj.seconds) { timeObj.seconds = obj.data.secmins; } delete obj.secmins; } return timeObj; }, buildTimeObjectFromData: function (data) { var time = utils.timeDataProcess({ data: { year : data[1], month : data[5], day : data[7], week : data[8], dayOfYear : data[10], hours : data[15], zone_hours : data[23], zone_minutes : data[24], zone : data[21], zone_sign : data[22], weekDay : data[9], minutes: data[16], seconds: data[19], milliseconds: data[20], secmins: data[18] }, mods: { month: function(data) { return data-1; }, weekDay: function (data) { data = Math.abs(data); return (data === 7 ? 0 : data); }, minutes: function (data) { return data.replace(":",""); }, seconds: function (data) { return Math.floor( (data.replace(":","").replace(",","."))*1 ); }, milliseconds: function (data) { return (data.replace(",",".")*1000); } }, postProcess: { minutes: true, seconds: true, milliseconds: true }, explict: { zone_hours: true, zone_minutes: true }, ignore: { zone: true, zone_sign: true, secmins: true } }); return time; }, addToHash: function (hash, keys, data) { keys = keys; data = data; var len = keys.length; for (var i = 0; i < len; i++) { hash[keys[i]] = data[i]; } return hash; }, combineRegex: function (r1, r2) { return new RegExp("(("+r1.source+")\\s("+r2.source+"))"); }, getDateNthString: function(add, last, inc){ if (add) { return Date.today().addDays(inc).toString("d"); } else if (last) { return Date.today().last()[inc]().toString("d"); } }, buildRegexData: function (array) { var arr = []; var len = array.length; for (var i=0; i < len; i++) { if (Object.prototype.toString.call(array[i]) === '[object Array]') { // oldIE compat version of Array.isArray arr.push(this.combineRegex(array[i][0], array[i][1])); } else { arr.push(array[i]); } } return arr; } }; $P.processTimeObject = function (obj) { var date, dayOffset; utils.setDefaults(obj); dayOffset = ($P.isLeapYear(obj.year)) ? dayOffsets.leap : dayOffsets.standard; if (!obj.month && (obj.week || obj.dayOfYear)) { utils.getDayOfYear(obj, dayOffset); } else { obj.dayOfYear = dayOffset[obj.month] + obj.day; } date = new Date(obj.year, obj.month, obj.day, obj.hours, obj.minutes, obj.seconds, obj.milliseconds); if (obj.zone) { utils.adjustForTimeZone(obj, date); // adjust (and calculate) for timezone } return date; }; $P.ISO = { regex : /^([\+-]?\d{4}(?!\d{2}\b))((-?)((0[1-9]|1[0-2])(\3([12]\d|0[1-9]|3[01]))?|W([0-4]\d|5[0-3])(-?[1-7])?|(00[1-9]|0[1-9]\d|[12]\d{2}|3([0-5]\d|6[1-6])))([T\s]((([01]\d|2[0-4])((:?)[0-5]\d)?|24\:?00)([\.,]\d+(?!:))?)?(\17[0-5]\d([\.,]\d+)?)?\s?([zZ]|([\+-])([01]\d|2[0-3]):?([0-5]\d)?)?)?)?$/, parse : function (s) { var time, data = s.match(this.regex); if (!data || !data.length) { return null; } time = utils.buildTimeObjectFromData(data); if (!time.year || (!time.year && (!time.month && !time.day) && (!time.week && !time.dayOfYear)) ) { return null; } return $P.processTimeObject(time); } }; $P.Numeric = { isNumeric: function (e){return!isNaN(parseFloat(e))&&isFinite(e);}, regex: /\b([0-1]?[0-9])([0-3]?[0-9])([0-2]?[0-9]?[0-9][0-9])\b/i, parse: function (s) { var data, i, time = {}, order = Date.CultureInfo.dateElementOrder.split(""); if (!(this.isNumeric(s)) || // if it's non-numeric OR (s[0] === "+" && s[0] === "-")) { // It's an arithmatic string (eg +/-1000) return null; } if (s.length < 5 && s.indexOf(".") < 0 && s.indexOf("/") < 0) { // assume it's just a year. time.year = s; return $P.processTimeObject(time); } data = s.match(this.regex); if (!data || !data.length) { return null; } for (i=0; i < order.length; i++) { switch(order[i]) { case "d": time.day = data[i+1]; break; case "m": time.month = (data[i+1]-1); break; case "y": time.year = data[i+1]; break; } } return $P.processTimeObject(time); } }; $P.Normalizer = { regexData: function () { var $R = Date.CultureInfo.regexPatterns; return utils.buildRegexData([ $R.tomorrow, $R.yesterday, [$R.past, $R.mon], [$R.past, $R.tue], [$R.past, $R.wed], [$R.past, $R.thu], [$R.past, $R.fri], [$R.past, $R.sat], [$R.past, $R.sun] ]); }, basicReplaceHash : function() { var $R = Date.CultureInfo.regexPatterns; return { "January": $R.jan.source, "February": $R.feb, "March": $R.mar, "April": $R.apr, "May": $R.may, "June": $R.jun, "July": $R.jul, "August": $R.aug, "September": $R.sep, "October": $R.oct, "November": $R.nov, "December": $R.dec, "": /\bat\b/gi, " ": /\s{2,}/, "am": $R.inTheMorning, "9am": $R.thisMorning, "pm": $R.inTheEvening, "7pm":$R.thisEvening }; }, keys : function(){ return [ utils.getDateNthString(true, false, 1), // tomorrow utils.getDateNthString(true, false, -1), // yesterday utils.getDateNthString(false, true, "monday"), //last mon utils.getDateNthString(false, true, "tuesday"), //last tues utils.getDateNthString(false, true, "wednesday"), //last wed utils.getDateNthString(false, true, "thursday"), //last thurs utils.getDateNthString(false, true, "friday"), //last fri utils.getDateNthString(false, true, "saturday"), //last sat utils.getDateNthString(false, true, "sunday") //last sun ]; }, buildRegexFunctions: function () { var $R = Date.CultureInfo.regexPatterns; var __ = Date.i18n.__; var tomorrowRE = new RegExp("(\\b\\d\\d?("+__("AM")+"|"+__("PM")+")? )("+$R.tomorrow.source.slice(1)+")", "i"); // adapted tomorrow regex for AM PM relative dates var todayRE = new RegExp($R.today.source + "(?!\\s*([+-]))\\b"); // today, but excludes the math operators (eg "today + 2h") this.replaceFuncs = [ [todayRE, function (full) { return (full.length > 1) ? Date.today().toString("d") : full; }], [tomorrowRE, function(full, m1) { var t = Date.today().addDays(1).toString("d"); return (t + " " + m1); }], [$R.amThisMorning, function(str, am){return am;}], [$R.pmThisEvening, function(str, pm){return pm;}] ]; }, buildReplaceData: function () { this.buildRegexFunctions(); this.replaceHash = utils.addToHash(this.basicReplaceHash(), this.keys(), this.regexData()); }, stringReplaceFuncs: function (s) { for (var i=0; i < this.replaceFuncs.length; i++) { s = s.replace(this.replaceFuncs[i][0], this.replaceFuncs[i][1]); } return s; }, parse: function (s) { s = this.stringReplaceFuncs(s); s = utils.multiReplace(s, this.replaceHash); try { var n = s.split(/([\s\-\.\,\/\x27]+)/); if (n.length === 3 && $P.Numeric.isNumeric(n[0]) && $P.Numeric.isNumeric(n[2]) && (n[2].length >= 4)) { // ok, so we're dealing with x/year. But that's not a full date. // This fixes wonky dateElementOrder parsing when set to dmy order. if (Date.CultureInfo.dateElementOrder[0] === "d") { s = "1/" + n[0] + "/" + n[2]; // set to 1st of month and normalize the seperator } } } catch (e) {} return s; } }; $P.Normalizer.buildReplaceData(); }()); (function () { var $P = Date.Parsing; var _ = $P.Operators = { // // Tokenizers // rtoken: function (r) { // regex token return function (s) { var mx = s.match(r); if (mx) { return ([ mx[0], s.substring(mx[0].length) ]); } else { throw new $P.Exception(s); } }; }, token: function () { // whitespace-eating token return function (s) { return _.rtoken(new RegExp("^\\s*" + s + "\\s*"))(s); }; }, stoken: function (s) { // string token return _.rtoken(new RegExp("^" + s)); }, // Atomic Operators until: function (p) { return function (s) { var qx = [], rx = null; while (s.length) { try { rx = p.call(this, s); } catch (e) { qx.push(rx[0]); s = rx[1]; continue; } break; } return [ qx, s ]; }; }, many: function (p) { return function (s) { var rx = [], r = null; while (s.length) { try { r = p.call(this, s); } catch (e) { return [ rx, s ]; } rx.push(r[0]); s = r[1]; } return [ rx, s ]; }; }, // generator operators -- see below optional: function (p) { return function (s) { var r = null; try { r = p.call(this, s); } catch (e) { return [ null, s ]; } return [ r[0], r[1] ]; }; }, not: function (p) { return function (s) { try { p.call(this, s); } catch (e) { return [null, s]; } throw new $P.Exception(s); }; }, ignore: function (p) { return p ? function (s) { var r = null; r = p.call(this, s); return [null, r[1]]; } : null; }, product: function () { var px = arguments[0], qx = Array.prototype.slice.call(arguments, 1), rx = []; for (var i = 0 ; i < px.length ; i++) { rx.push(_.each(px[i], qx)); } return rx; }, cache: function (rule) { var cache = {}, cache_length = 0, cache_keys = [], CACHE_MAX = Date.Config.CACHE_MAX || 100000, r = null; var cacheCheck = function () { if (cache_length === CACHE_MAX) { // kill several keys, don't want to have to do this all the time... for (var i=0; i < 10; i++) { var key = cache_keys.shift(); if (key) { delete cache[key]; cache_length--; } } } }; return function (s) { cacheCheck(); try { r = cache[s] = (cache[s] || rule.call(this, s)); } catch (e) { r = cache[s] = e; } cache_length++; cache_keys.push(s); if (r instanceof $P.Exception) { throw r; } else { return r; } }; }, // vector operators -- see below any: function () { var px = arguments; return function (s) { var r = null; for (var i = 0; i < px.length; i++) { if (px[i] == null) { continue; } try { r = (px[i].call(this, s)); } catch (e) { r = null; } if (r) { return r; } } throw new $P.Exception(s); }; }, each: function () { var px = arguments; return function (s) { var rx = [], r = null; for (var i = 0; i < px.length ; i++) { if (px[i] == null) { continue; } try { r = (px[i].call(this, s)); } catch (e) { throw new $P.Exception(s); } rx.push(r[0]); s = r[1]; } return [ rx, s]; }; }, all: function () { var px = arguments, _ = _; return _.each(_.optional(px)); }, // delimited operators sequence: function (px, d, c) { d = d || _.rtoken(/^\s*/); c = c || null; if (px.length === 1) { return px[0]; } return function (s) { var r = null, q = null; var rx = []; for (var i = 0; i < px.length ; i++) { try { r = px[i].call(this, s); } catch (e) { break; } rx.push(r[0]); try { q = d.call(this, r[1]); } catch (ex) { q = null; break; } s = q[1]; } if (!r) { throw new $P.Exception(s); } if (q) { throw new $P.Exception(q[1]); } if (c) { try { r = c.call(this, r[1]); } catch (ey) { throw new $P.Exception(r[1]); } } return [ rx, (r?r[1]:s) ]; }; }, // // Composite Operators // between: function (d1, p, d2) { d2 = d2 || d1; var _fn = _.each(_.ignore(d1), p, _.ignore(d2)); return function (s) { var rx = _fn.call(this, s); return [[rx[0][0], r[0][2]], rx[1]]; }; }, list: function (p, d, c) { d = d || _.rtoken(/^\s*/); c = c || null; return (p instanceof Array ? _.each(_.product(p.slice(0, -1), _.ignore(d)), p.slice(-1), _.ignore(c)) : _.each(_.many(_.each(p, _.ignore(d))), px, _.ignore(c))); }, set: function (px, d, c) { d = d || _.rtoken(/^\s*/); c = c || null; return function (s) { // r is the current match, best the current 'best' match // which means it parsed the most amount of input var r = null, p = null, q = null, rx = null, best = [[], s], last = false; // go through the rules in the given set for (var i = 0; i < px.length ; i++) { // last is a flag indicating whether this must be the last element // if there is only 1 element, then it MUST be the last one q = null; p = null; r = null; last = (px.length === 1); // first, we try simply to match the current pattern // if not, try the next pattern try { r = px[i].call(this, s); } catch (e) { continue; } // since we are matching against a set of elements, the first // thing to do is to add r[0] to matched elements rx = [[r[0]], r[1]]; // if we matched and there is still input to parse and // we don't already know this is the last element, // we're going to next check for the delimiter ... // if there's none, or if there's no input left to parse // than this must be the last element after all ... if (r[1].length > 0 && ! last) { try { q = d.call(this, r[1]); } catch (ex) { last = true; } } else { last = true; } // if we parsed the delimiter and now there's no more input, // that means we shouldn't have parsed the delimiter at all // so don't update r and mark this as the last element ... if (!last && q[1].length === 0) { last = true; } // so, if this isn't the last element, we're going to see if // we can get any more matches from the remaining (unmatched) // elements ... if (!last) { // build a list of the remaining rules we can match against, // i.e., all but the one we just matched against var qx = []; for (var j = 0; j < px.length ; j++) { if (i !== j) { qx.push(px[j]); } } // now invoke recursively set with the remaining input // note that we don't include the closing delimiter ... // we'll check for that ourselves at the end p = _.set(qx, d).call(this, q[1]); // if we got a non-empty set as a result ... // (otw rx already contains everything we want to match) if (p[0].length > 0) { // update current result, which is stored in rx ... // basically, pick up the remaining text from p[1] // and concat the result from p[0] so that we don't // get endless nesting ... rx[0] = rx[0].concat(p[0]); rx[1] = p[1]; } } // at this point, rx either contains the last matched element // or the entire matched set that starts with this element. // now we just check to see if this variation is better than // our best so far, in terms of how much of the input is parsed if (rx[1].length < best[1].length) { best = rx; } // if we've parsed all the input, then we're finished if (best[1].length === 0) { break; } } // so now we've either gone through all the patterns trying them // as the initial match; or we found one that parsed the entire // input string ... // if best has no matches, just return empty set ... if (best[0].length === 0) { return best; } // if a closing delimiter is provided, then we have to check it also if (c) { // we try this even if there is no remaining input because the pattern // may well be optional or match empty input ... try { q = c.call(this, best[1]); } catch (ey) { throw new $P.Exception(best[1]); } // it parsed ... be sure to update the best match remaining input best[1] = q[1]; } // if we're here, either there was no closing delimiter or we parsed it // so now we have the best match; just return it! return best; }; }, forward: function (gr, fname) { return function (s) { return gr[fname].call(this, s); }; }, // // Translation Operators // replace: function (rule, repl) { return function (s) { var r = rule.call(this, s); return [repl, r[1]]; }; }, process: function (rule, fn) { return function (s) { var r = rule.call(this, s); return [fn.call(this, r[0]), r[1]]; }; }, min: function (min, rule) { return function (s) { var rx = rule.call(this, s); if (rx[0].length < min) { throw new $P.Exception(s); } return rx; }; } }; // Generator Operators And Vector Operators // Generators are operators that have a signature of F(R) => R, // taking a given rule and returning another rule, such as // ignore, which parses a given rule and throws away the result. // Vector operators are those that have a signature of F(R1,R2,...) => R, // take a list of rules and returning a new rule, such as each. // Generator operators are converted (via the following _generator // function) into functions that can also take a list or array of rules // and return an array of new rules as though the function had been // called on each rule in turn (which is what actually happens). // This allows generators to be used with vector operators more easily. // Example: // each(ignore(foo, bar)) instead of each(ignore(foo), ignore(bar)) // This also turns generators into vector operators, which allows // constructs like: // not(cache(foo, bar)) var _generator = function (op) { function gen() { var args = null, rx = [], px, i; if (arguments.length > 1) { args = Array.prototype.slice.call(arguments); } else if (arguments[0] instanceof Array) { args = arguments[0]; } if (args) { px = args.shift(); if (px.length > 0) { args.unshift(px[i]); rx.push(op.apply(null, args)); args.shift(); return rx; } } else { return op.apply(null, arguments); } } return gen; }; var gx = "optional not ignore cache".split(/\s/); for (var i = 0 ; i < gx.length ; i++) { _[gx[i]] = _generator(_[gx[i]]); } var _vector = function (op) { return function () { if (arguments[0] instanceof Array) { return op.apply(null, arguments[0]); } else { return op.apply(null, arguments); } }; }; var vx = "each any all".split(/\s/); for (var j = 0 ; j < vx.length ; j++) { _[vx[j]] = _vector(_[vx[j]]); } }()); (function () { var $D = Date; var flattenAndCompact = function (ax) { var rx = []; for (var i = 0; i < ax.length; i++) { if (ax[i] instanceof Array) { rx = rx.concat(flattenAndCompact(ax[i])); } else { if (ax[i]) { rx.push(ax[i]); } } } return rx; }; var parseMeridian = function () { if (this.meridian && (this.hour || this.hour === 0)) { if (this.meridian === "a" && this.hour > 11 && Date.Config.strict24hr){ throw "Invalid hour and meridian combination"; } else if (this.meridian === "p" && this.hour < 12 && Date.Config.strict24hr){ throw "Invalid hour and meridian combination"; } else if (this.meridian === "p" && this.hour < 12) { this.hour = this.hour + 12; } else if (this.meridian === "a" && this.hour === 12) { this.hour = 0; } } }; var setDefaults = function () { var now = new Date(); if ((this.hour || this.minute) && (!this.month && !this.year && !this.day)) { this.day = now.getDate(); } if (!this.year) { this.year = now.getFullYear(); } if (!this.month && this.month !== 0) { this.month = now.getMonth(); } if (!this.day) { this.day = 1; } if (!this.hour) { this.hour = 0; } if (!this.minute) { this.minute = 0; } if (!this.second) { this.second = 0; } if (!this.millisecond) { this.millisecond = 0; } }; var finishUtils = { getToday: function () { if (this.now || "hour minute second".indexOf(this.unit) !== -1) { return new Date(); } else { return $D.today(); } }, setDaysFromWeekday: function (today, orient){ var gap; orient = orient || 1; this.unit = "day"; gap = ($D.getDayNumberFromName(this.weekday) - today.getDay()); this.days = gap ? ((gap + (orient * 7)) % 7) : (orient * 7); return this; }, setMonthsFromMonth: function (today, orient) { var gap; orient = orient || 1; this.unit = "month"; gap = (this.month - today.getMonth()); this.months = gap ? ((gap + (orient * 12)) % 12) : (orient * 12); this.month = null; return this; }, setDMYFromWeekday: function () { var d = Date[this.weekday](); this.day = d.getDate(); if (!this.month) { this.month = d.getMonth(); } this.year = d.getFullYear(); return this; }, setUnitValue: function (orient) { if (!this.value && this.operator && this.operator !== null && this[this.unit + "s"] && this[this.unit + "s"] !== null) { this[this.unit + "s"] = this[this.unit + "s"] + ((this.operator === "add") ? 1 : -1) + (this.value||0) * orient; } else if (this[this.unit + "s"] == null || this.operator != null) { if (!this.value) { this.value = 1; } this[this.unit + "s"] = this.value * orient; } }, generateDateFromWeeks: function () { var weekday = (this.weekday !== undefined) ? this.weekday : "today"; var d = Date[weekday]().addWeeks(this.weeks); if (this.now) { d.setTimeToNow(); } return d; } }; $D.Translator = { hour: function (s) { return function () { this.hour = Number(s); }; }, minute: function (s) { return function () { this.minute = Number(s); }; }, second: function (s) { return function () { this.second = Number(s); }; }, /* for ss.s format */ secondAndMillisecond: function (s) { return function () { var mx = s.match(/^([0-5][0-9])\.([0-9]{1,3})/); this.second = Number(mx[1]); this.millisecond = Number(mx[2]); }; }, meridian: function (s) { return function () { this.meridian = s.slice(0, 1).toLowerCase(); }; }, timezone: function (s) { return function () { var n = s.replace(/[^\d\+\-]/g, ""); if (n.length) { this.timezoneOffset = Number(n); } else { this.timezone = s.toLowerCase(); } }; }, day: function (x) { var s = x[0]; return function () { this.day = Number(s.match(/\d+/)[0]); if (this.day < 1) { throw "invalid day"; } }; }, month: function (s) { return function () { this.month = (s.length === 3) ? "jan feb mar apr may jun jul aug sep oct nov dec".indexOf(s)/4 : Number(s) - 1; if (this.month < 0) { throw "invalid month"; } }; }, year: function (s) { return function () { var n = Number(s); this.year = ((s.length > 2) ? n : (n + (((n + 2000) < Date.CultureInfo.twoDigitYearMax) ? 2000 : 1900))); }; }, rday: function (s) { return function () { switch (s) { case "yesterday": this.days = -1; break; case "tomorrow": this.days = 1; break; case "today": this.days = 0; break; case "now": this.days = 0; this.now = true; break; } }; }, finishExact: function (x) { var d; x = (x instanceof Array) ? x : [x]; for (var i = 0 ; i < x.length ; i++) { if (x[i]) { x[i].call(this); } } setDefaults.call(this); parseMeridian.call(this); if (this.day > $D.getDaysInMonth(this.year, this.month)) { throw new RangeError(this.day + " is not a valid value for days."); } d = new Date(this.year, this.month, this.day, this.hour, this.minute, this.second, this.millisecond); if (this.year < 100) { d.setFullYear(this.year); // means years less that 100 are process correctly. JS will parse it otherwise as 1900-1999. } if (this.timezone) { d.set({ timezone: this.timezone }); } else if (this.timezoneOffset) { d.set({ timezoneOffset: this.timezoneOffset }); } return d; }, finish: function (x) { var today, expression, orient, temp; x = (x instanceof Array) ? flattenAndCompact(x) : [ x ]; if (x.length === 0) { return null; } for (var i = 0 ; i < x.length ; i++) { if (typeof x[i] === "function") { x[i].call(this); } } if (this.now && !this.unit && !this.operator) { return new Date(); } else { today = finishUtils.getToday.call(this); } expression = !!(this.days && this.days !== null || this.orient || this.operator); orient = ((this.orient === "past" || this.operator === "subtract") ? -1 : 1); if (this.month && this.unit === "week") { this.value = this.month + 1; delete this.month; delete this.day; } if ((this.month || this.month === 0) && "year day hour minute second".indexOf(this.unit) !== -1) { if (!this.value) { this.value = this.month + 1; } this.month = null; expression = true; } if (!expression && this.weekday && !this.day && !this.days) { finishUtils.setDMYFromWeekday.call(this); } if (expression && this.weekday && this.unit !== "month" && this.unit !== "week") { finishUtils.setDaysFromWeekday.call(this, today, orient); } if (this.weekday && this.unit !== "week" && !this.day && !this.days) { temp = Date[this.weekday](); this.day = temp.getDate(); if (temp.getMonth() !== today.getMonth()) { this.month = temp.getMonth(); } } if (this.month && this.unit === "day" && this.operator) { if (!this.value) { this.value = (this.month + 1); } this.month = null; } if (this.value != null && this.month != null && this.year != null) { this.day = this.value * 1; } if (this.month && !this.day && this.value) { today.set({ day: this.value * 1 }); if (!expression) { this.day = this.value * 1; } } if (!this.month && this.value && this.unit === "month" && !this.now) { this.month = this.value; expression = true; } if (expression && (this.month || this.month === 0) && this.unit !== "year") { finishUtils.setMonthsFromMonth.call(this, today, orient); } if (!this.unit) { this.unit = "day"; } finishUtils.setUnitValue.call(this, orient); parseMeridian.call(this); if ((this.month || this.month === 0) && !this.day) { this.day = 1; } if (!this.orient && !this.operator && this.unit === "week" && this.value && !this.day && !this.month) { return Date.today().setWeek(this.value); } if (this.unit === "week" && this.weeks && !this.day && !this.month) { return finishUtils.generateDateFromWeeks.call(this); } if (expression && this.timezone && this.day && this.days) { this.day = this.days; } if (expression){ today.add(this); } else { today.set(this); } if (this.timezone) { this.timezone = this.timezone.toUpperCase(); var offset = $D.getTimezoneOffset(this.timezone); var timezone; if (today.hasDaylightSavingTime()) { // lets check that we're being sane with timezone setting timezone = $D.getTimezoneAbbreviation(offset, today.isDaylightSavingTime()); if (timezone !== this.timezone) { // bugger, we're in a place where things like EST vs EDT matters. if (today.isDaylightSavingTime()) { today.addHours(-1); } else { today.addHours(1); } } } today.setTimezoneOffset(offset); } return today; } }; }()); (function () { var $D = Date; $D.Grammar = {}; var _ = $D.Parsing.Operators, g = $D.Grammar, t = $D.Translator, _fn; // Allow rolling up into general purpose rules _fn = function () { return _.each(_.any.apply(null, arguments), _.not(g.ctoken2("timeContext"))); }; g.datePartDelimiter = _.rtoken(/^([\s\-\.\,\/\x27]+)/); g.timePartDelimiter = _.stoken(":"); g.whiteSpace = _.rtoken(/^\s*/); g.generalDelimiter = _.rtoken(/^(([\s\,]|at|@|on)+)/); var _C = {}; g.ctoken = function (keys) { var fn = _C[keys]; if (! fn) { var c = Date.CultureInfo.regexPatterns; var kx = keys.split(/\s+/), px = []; for (var i = 0; i < kx.length ; i++) { px.push(_.replace(_.rtoken(c[kx[i]]), kx[i])); } fn = _C[keys] = _.any.apply(null, px); } return fn; }; g.ctoken2 = function (key) { return _.rtoken(Date.CultureInfo.regexPatterns[key]); }; var cacheProcessRtoken = function (key, token, type, eachToken) { if (eachToken) { g[key] = _.cache(_.process(_.each(_.rtoken(token),_.optional(g.ctoken2(eachToken))), type)); } else { g[key] = _.cache(_.process(_.rtoken(token), type)); } }; var cacheProcessCtoken = function (token, type) { return _.cache(_.process(g.ctoken2(token), type)); }; var _F = {}; //function cache var _get = function (f) { _F[f] = (_F[f] || g.format(f)[0]); return _F[f]; }; g.allformats = function (fx) { var rx = []; if (fx instanceof Array) { for (var i = 0; i < fx.length; i++) { rx.push(_get(fx[i])); } } else { rx.push(_get(fx)); } return rx; }; g.formats = function (fx) { if (fx instanceof Array) { var rx = []; for (var i = 0 ; i < fx.length ; i++) { rx.push(_get(fx[i])); } return _.any.apply(null, rx); } else { return _get(fx); } }; var grammarFormats = { timeFormats: function(){ var i, RTokenKeys = [ "h", "hh", "H", "HH", "m", "mm", "s", "ss", "ss.s", "z", "zz" ], RToken = [ /^(0[0-9]|1[0-2]|[1-9])/, /^(0[0-9]|1[0-2])/, /^([0-1][0-9]|2[0-3]|[0-9])/, /^([0-1][0-9]|2[0-3])/, /^([0-5][0-9]|[0-9])/, /^[0-5][0-9]/, /^([0-5][0-9]|[0-9])/, /^[0-5][0-9]/, /^[0-5][0-9]\.[0-9]{1,3}/, /^((\+|\-)\s*\d\d\d\d)|((\+|\-)\d\d\:?\d\d)/, /^((\+|\-)\s*\d\d\d\d)|((\+|\-)\d\d\:?\d\d)/ ], tokens = [ t.hour, t.hour, t.hour, t.hour, t.minute, t.minute, t.second, t.second, t.secondAndMillisecond, t.timezone, t.timezone ]; for (i=0; i < RTokenKeys.length; i++) { cacheProcessRtoken(RTokenKeys[i], RToken[i], tokens[i]); } g.hms = _.cache(_.sequence([g.H, g.m, g.s], g.timePartDelimiter)); g.t = cacheProcessCtoken("shortMeridian", t.meridian); g.tt = cacheProcessCtoken("longMeridian", t.meridian); g.zzz = cacheProcessCtoken("timezone", t.timezone); g.timeSuffix = _.each(_.ignore(g.whiteSpace), _.set([ g.tt, g.zzz ])); g.time = _.each(_.optional(_.ignore(_.stoken("T"))), g.hms, g.timeSuffix); }, dateFormats: function () { // pre-loaded rules for different date part order preferences var _setfn = function () { return _.set(arguments, g.datePartDelimiter); }; var i, RTokenKeys = [ "d", "dd", "M", "MM", "y", "yy", "yyy", "yyyy" ], RToken = [ /^([0-2]\d|3[0-1]|\d)/, /^([0-2]\d|3[0-1])/, /^(1[0-2]|0\d|\d)/, /^(1[0-2]|0\d)/, /^(\d+)/, /^(\d\d)/, /^(\d\d?\d?\d?)/, /^(\d\d\d\d)/ ], tokens = [ t.day, t.day, t.month, t.month, t.year, t.year, t.year, t.year ], eachToken = [ "ordinalSuffix", "ordinalSuffix" ]; for (i=0; i < RTokenKeys.length; i++) { cacheProcessRtoken(RTokenKeys[i], RToken[i], tokens[i], eachToken[i]); } g.MMM = g.MMMM = _.cache(_.process(g.ctoken("jan feb mar apr may jun jul aug sep oct nov dec"), t.month)); g.ddd = g.dddd = _.cache(_.process(g.ctoken("sun mon tue wed thu fri sat"), function (s) { return function () { this.weekday = s; }; } )); g.day = _fn(g.d, g.dd); g.month = _fn(g.M, g.MMM); g.year = _fn(g.yyyy, g.yy); g.mdy = _setfn(g.ddd, g.month, g.day, g.year); g.ymd = _setfn(g.ddd, g.year, g.month, g.day); g.dmy = _setfn(g.ddd, g.day, g.month, g.year); g.date = function (s) { return ((g[Date.CultureInfo.dateElementOrder] || g.mdy).call(this, s)); }; }, relative: function () { // relative date / time expressions g.orientation = _.process(g.ctoken("past future"), function (s) { return function () { this.orient = s; }; } ); g.operator = _.process(g.ctoken("add subtract"), function (s) { return function () { this.operator = s; }; } ); g.rday = _.process(g.ctoken("yesterday tomorrow today now"), t.rday); g.unit = _.process(g.ctoken("second minute hour day week month year"), function (s) { return function () { this.unit = s; }; } ); } }; g.buildGrammarFormats = function () { // these need to be rebuilt every time the language changes. _C = {}; grammarFormats.timeFormats(); grammarFormats.dateFormats(); grammarFormats.relative(); g.value = _.process(_.rtoken(/^([-+]?\d+)?(st|nd|rd|th)?/), function (s) { return function () { this.value = s.replace(/\D/g, ""); }; } ); g.expression = _.set([g.rday, g.operator, g.value, g.unit, g.orientation, g.ddd, g.MMM ]); g.format = _.process(_.many( _.any( // translate format specifiers into grammar rules _.process( _.rtoken(/^(dd?d?d?(?!e)|MM?M?M?|yy?y?y?|hh?|HH?|mm?|ss?|tt?|zz?z?)/), function (fmt) { if (g[fmt]) { return g[fmt]; } else { throw $D.Parsing.Exception(fmt); } } ), // translate separator tokens into token rules _.process(_.rtoken(/^[^dMyhHmstz]+/), // all legal separators function (s) { return _.ignore(_.stoken(s)); } ) ) ), // construct the parser ... function (rules) { return _.process(_.each.apply(null, rules), t.finishExact); } ); // starting rule for general purpose grammar g._start = _.process(_.set([ g.date, g.time, g.expression ], g.generalDelimiter, g.whiteSpace), t.finish); }; g.buildGrammarFormats(); // parsing date format specifiers - ex: "h:m:s tt" // this little guy will generate a custom parser based // on the format string, ex: g.format("h:m:s tt") // check for these formats first g._formats = g.formats([ "\"yyyy-MM-ddTHH:mm:ssZ\"", "yyyy-MM-ddTHH:mm:ss.sz", "yyyy-MM-ddTHH:mm:ssZ", "yyyy-MM-ddTHH:mm:ssz", "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-ddTHH:mmZ", "yyyy-MM-ddTHH:mmz", "yyyy-MM-ddTHH:mm", "ddd, MMM dd, yyyy H:mm:ss tt", "ddd MMM d yyyy HH:mm:ss zzz", "MMddyyyy", "ddMMyyyy", "Mddyyyy", "ddMyyyy", "Mdyyyy", "dMyyyy", "yyyy", "Mdyy", "dMyy", "d" ]); // real starting rule: tries selected formats first, // then general purpose rule g.start = function (s) { try { var r = g._formats.call({}, s); if (r[1].length === 0) { return r; } } catch (e) {} return g._start.call({}, s); }; }()); (function () { var $D = Date; /** * @desc Converts the specified string value into its JavaScript Date equivalent using CultureInfo specific format information. * * Example

	///////////
	// Dates //
	///////////

	// 15-Oct-2004
	var d1 = Date.parse("10/15/2004");

	// 15-Oct-2004
	var d1 = Date.parse("15-Oct-2004");

	// 15-Oct-2004
	var d1 = Date.parse("2004.10.15");

	//Fri Oct 15, 2004
	var d1 = Date.parse("Fri Oct 15, 2004");

	///////////
	// Times //
	///////////

	// Today at 10 PM.
	var d1 = Date.parse("10 PM");

	// Today at 10:30 PM.
	var d1 = Date.parse("10:30 P.M.");

	// Today at 6 AM.
	var d1 = Date.parse("06am");

	/////////////////////
	// Dates and Times //
	/////////////////////

	// 8-July-2004 @ 10:30 PM
	var d1 = Date.parse("July 8th, 2004, 10:30 PM");

	// 1-July-2004 @ 10:30 PM
	var d1 = Date.parse("2004-07-01T22:30:00");

	////////////////////
	// Relative Dates //
	////////////////////

	// Returns today's date. The string "today" is culture specific.
	var d1 = Date.parse("today");

	// Returns yesterday's date. The string "yesterday" is culture specific.
	var d1 = Date.parse("yesterday");

	// Returns the date of the next thursday.
	var d1 = Date.parse("Next thursday");

	// Returns the date of the most previous monday.
	var d1 = Date.parse("last monday");

	// Returns today's day + one year.
	var d1 = Date.parse("next year");

	///////////////
	// Date Math //
	///////////////

	// Today + 2 days
	var d1 = Date.parse("t+2");

	// Today + 2 days
	var d1 = Date.parse("today + 2 days");

	// Today + 3 months
	var d1 = Date.parse("t+3m");

	// Today - 1 year
	var d1 = Date.parse("today - 1 year");

	// Today - 1 year
	var d1 = Date.parse("t-1y"); 


	/////////////////////////////
	// Partial Dates and Times //
	/////////////////////////////

	// July 15th of this year.
	var d1 = Date.parse("July 15");

	// 15th day of current day and year.
	var d1 = Date.parse("15");

	// July 1st of current year at 10pm.
	var d1 = Date.parse("7/1 10pm");
	
* * @param {String} The string value to convert into a Date object [Required] * @return {Date} A Date object or null if the string cannot be converted into a Date. */ var parseUtils = { removeOrds: function (s) { ords = s.match(/\b(\d+)(?:st|nd|rd|th)\b/); // find ordinal matches s = ((ords && ords.length === 2) ? s.replace(ords[0], ords[1]) : s); return s; }, grammarParser: function (s) { var r = null; try { r = $D.Grammar.start.call({}, s.replace(/^\s*(\S*(\s+\S+)*)\s*$/, "$1")); } catch (e) { return null; } return ((r[1].length === 0) ? r[0] : null); }, nativeFallback: function(s) { var t; try { // ok we haven't parsed it, last ditch attempt with the built-in parser. t = Date._parse(s); return (t || t === 0) ? new Date(t) : null; } catch (e) { return null; } } }; function parse (s) { var d; if (!s) { return null; } if (s instanceof Date) { return s.clone(); } if (s.length >= 4 && s.charAt(0) !== "0" && s.charAt(0) !== "+"&& s.charAt(0) !== "-") { // ie: 2004 will pass, 0800 won't. // Start with specific formats d = $D.Parsing.ISO.parse(s) || $D.Parsing.Numeric.parse(s); } if (d instanceof Date && !isNaN(d.getTime())) { return d; } else { // find ordinal dates (1st, 3rd, 8th, etc and remove them as they cause parsing issues) s = $D.Parsing.Normalizer.parse(parseUtils.removeOrds(s)); d = parseUtils.grammarParser(s); if (d !== null) { return d; } else { return parseUtils.nativeFallback(s); } } } if (!$D._parse) { $D._parse = $D.parse; } $D.parse = parse; Date.getParseFunction = function (fx) { var fns = Date.Grammar.allformats(fx); return function (s) { var r = null; for (var i = 0; i < fns.length; i++) { try { r = fns[i].call({}, s); } catch (e) { continue; } if (r[1].length === 0) { return r[0]; } } return null; }; }; /** * Converts the specified string value into its JavaScript Date equivalent using the specified format {String} or formats {Array} and the CultureInfo specific format information. * The format of the string value must match one of the supplied formats exactly. * * Example

	// 15-Oct-2004
	var d1 = Date.parseExact("10/15/2004", "M/d/yyyy");

	// 15-Oct-2004
	var d1 = Date.parse("15-Oct-2004", "M-ddd-yyyy");

	// 15-Oct-2004
	var d1 = Date.parse("2004.10.15", "yyyy.MM.dd");

	// Multiple formats
	var d1 = Date.parseExact("10/15/2004", ["M/d/yyyy", "MMMM d, yyyy"]);
	
* * @param {String} The string value to convert into a Date object [Required]. * @param {Object} The expected format {String} or an array of expected formats {Array} of the date string [Required]. * @return {Date} A Date object or null if the string cannot be converted into a Date. */ $D.parseExact = function (s, fx) { return $D.getParseFunction(fx)(s); }; }()); (function () { var $D = Date, $P = $D.prototype, // $C = $D.CultureInfo, // not used atm p = function (s, l) { if (!l) { l = 2; } return ("000" + s).slice(l * -1); }; /** * Converts a PHP format string to Java/.NET format string. * A PHP format string can be used with ._format or .format. * A Java/.NET format string can be used with .toString(). * The .parseExact function will only accept a Java/.NET format string * * Example * var f1 = "%m/%d/%y" * var f2 = Date.normalizeFormat(f1); // "MM/dd/yy" * * new Date().format(f1); // "04/13/08" * new Date()._format(f1); // "04/13/08" * new Date().toString(f2); // "04/13/08" * * var date = Date.parseExact("04/13/08", f2); // Sun Apr 13 2008 * * @param {String} A PHP format string consisting of one or more format spcifiers. * @return {String} The PHP format converted to a Java/.NET format string. */ var normalizerSubstitutions = { "d" : "dd", "%d": "dd", "D" : "ddd", "%a": "ddd", "j" : "dddd", "l" : "dddd", "%A": "dddd", "S" : "S", "F" : "MMMM", "%B": "MMMM", "m" : "MM", "%m": "MM", "M" : "MMM", "%b": "MMM", "%h": "MMM", "n" : "M", "Y" : "yyyy", "%Y": "yyyy", "y" : "yy", "%y": "yy", "g" : "h", "%I": "h", "G" : "H", "h" : "hh", "H" : "HH", "%H": "HH", "i" : "mm", "%M": "mm", "s" : "ss", "%S": "ss", "%r": "hh:mm tt", "%R": "H:mm", "%T": "H:mm:ss", "%X": "t", "%x": "d", "%e": "d", "%D": "MM/dd/yy", "%n": "\\n", "%t": "\\t", "e" : "z", "T" : "z", "%z": "z", "%Z": "z", "Z" : "ZZ", "N" : "u", "w" : "u", "%w": "u", "W" : "W", "%V": "W" }; var normalizer = { substitutes: function (m) { return normalizerSubstitutions[m]; }, interpreted: function (m, x) { var y; switch (m) { case "%u": return x.getDay() + 1; case "z": return x.getOrdinalNumber(); case "%j": return p(x.getOrdinalNumber(), 3); case "%U": var d1 = x.clone().set({month: 0, day: 1}).addDays(-1).moveToDayOfWeek(0), d2 = x.clone().addDays(1).moveToDayOfWeek(0, -1); return (d2 < d1) ? "00" : p((d2.getOrdinalNumber() - d1.getOrdinalNumber()) / 7 + 1); case "%W": return p(x.getWeek()); case "t": return $D.getDaysInMonth(x.getFullYear(), x.getMonth()); case "o": case "%G": return x.setWeek(x.getISOWeek()).toString("yyyy"); case "%g": return x._format("%G").slice(-2); case "a": case "%p": return t("tt").toLowerCase(); case "A": return t("tt").toUpperCase(); case "u": return p(x.getMilliseconds(), 3); case "I": return (x.isDaylightSavingTime()) ? 1 : 0; case "O": return x.getUTCOffset(); case "P": y = x.getUTCOffset(); return y.substring(0, y.length - 2) + ":" + y.substring(y.length - 2); case "B": var now = new Date(); return Math.floor(((now.getHours() * 3600) + (now.getMinutes() * 60) + now.getSeconds() + (now.getTimezoneOffset() + 60) * 60) / 86.4); case "c": return x.toISOString().replace(/\"/g, ""); case "U": return $D.strtotime("now"); case "%c": return t("d") + " " + t("t"); case "%C": return Math.floor(x.getFullYear() / 100 + 1); } }, shouldOverrideDefaults: function (m) { switch (m) { case "%e": return true; default: return false; } }, parse: function (m, context) { var formatString, c = context || new Date(); formatString = normalizer.substitutes(m); if (formatString) { return formatString; } formatString = normalizer.interpreted(m, c); if (formatString) { return formatString; } else { return m; } } }; $D.normalizeFormat = function (format, context) { return format.replace(/(%|\\)?.|%%/g, function(t){ return normalizer.parse(t, context); }); }; /** * Format a local Unix timestamp according to locale settings * * Example: * Date.strftime("%m/%d/%y", new Date()); // "04/13/08" * Date.strftime("c", "2008-04-13T17:52:03Z"); // "04/13/08" * * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @param {Number|String} The number representing the number of seconds that have elapsed since January 1, 1970 (local time). * @return {String} A string representation of the current Date object. */ $D.strftime = function (format, time) { var d = Date.parse(time); return d._format(format); }; /** * Parse any textual datetime description into a Unix timestamp. * A Unix timestamp is the number of seconds that have elapsed since January 1, 1970 (midnight UTC/GMT). * * Example: * Date.strtotime("04/13/08"); // 1208044800 * Date.strtotime("1970-01-01T00:00:00Z"); // 0 * * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @param {Object} A string or date object. * @return {String} A string representation of the current Date object. */ $D.strtotime = function (time) { var d = $D.parse(time); return Math.round($D.UTC(d.getUTCFullYear(), d.getUTCMonth(), d.getUTCDate(), d.getUTCHours(), d.getUTCMinutes(), d.getUTCSeconds(), d.getUTCMilliseconds()) / 1000); }; /** * Converts the value of the current Date object to its equivalent string representation using a PHP/Unix style of date format specifiers. * Format Specifiers * Format Description Example * ------ --------------------------------------------------------------------------- ----------------------- * %a abbreviated weekday name according to the current localed "Mon" through "Sun" * %A full weekday name according to the current localed "Sunday" through "Saturday" * %b abbreviated month name according to the current localed "Jan" through "Dec" * %B full month name according to the current locale "January" through "December" * %c preferred date and time representation for the current locale "4/13/2008 12:33 PM" * %C century number (the year divided by 100 and truncated to an integer) "00" to "99" * %d day of the month as a decimal number "01" to "31" * %D same as %m/%d/%y "04/13/08" * %e day of the month as a decimal number, a single digit is preceded by a space "1" to "31" * %g like %G, but without the century "08" * %G The 4-digit year corresponding to the ISO week number (see %V). "2008" * This has the same format and value as %Y, except that if the ISO week number * belongs to the previous or next year, that year is used instead. * %h same as %b "Jan" through "Dec" * %H hour as a decimal number using a 24-hour clock. "00" to "23" * %I hour as a decimal number using a 12-hour clock. "01" to "12" * %j day of the year as a decimal number. "001" to "366" * %m month as a decimal number. "01" to "12" * %M minute as a decimal number. "00" to "59" * %n newline character "\n" * %p either "am" or "pm" according to the given time value, or the "am" or "pm" * corresponding strings for the current locale. * %r time in a.m. and p.m. notation "8:44 PM" * %R time in 24 hour notation "20:44" * %S second as a decimal number "00" to "59" * %t tab character "\t" * %T current time, equal to %H:%M:%S "12:49:11" * %u weekday as a decimal number ["1", "7"], with "1" representing Monday "1" to "7" * %U week number of the current year as a decimal number, starting with the "0" to ("52" or "53") * first Sunday as the first day of the first week * %V The ISO 8601:1988 week number of the current year as a decimal number, "00" to ("52" or "53") * range 01 to 53, where week 1 is the first week that has at least 4 days * in the current year, and with Monday as the first day of the week. * (Use %G or %g for the year component that corresponds to the week number * for the specified timestamp.) * %W week number of the current year as a decimal number, starting with the "00" to ("52" or "53") * first Monday as the first day of the first week * %w day of the week as a decimal, Sunday being "0" "0" to "6" * %x preferred date representation for the current locale without the time "4/13/2008" * %X preferred time representation for the current locale without the date "12:53:05" * %y year as a decimal number without a century "00" "99" * %Y year as a decimal number including the century "2008" * %Z time zone or name or abbreviation "UTC", "EST", "PST" * %z same as %Z * %% a literal "%" characters "%" * d Day of the month, 2 digits with leading zeros "01" to "31" * D A textual representation of a day, three letters "Mon" through "Sun" * j Day of the month without leading zeros "1" to "31" * l A full textual representation of the day of the week (lowercase "L") "Sunday" through "Saturday" * N ISO-8601 numeric representation of the day of the week (added in PHP 5.1.0) "1" (for Monday) through "7" (for Sunday) * S English ordinal suffix for the day of the month, 2 characters "st", "nd", "rd" or "th". Works well with j * w Numeric representation of the day of the week "0" (for Sunday) through "6" (for Saturday) * z The day of the year (starting from "0") "0" through "365" * W ISO-8601 week number of year, weeks starting on Monday "00" to ("52" or "53") * F A full textual representation of a month, such as January or March "January" through "December" * m Numeric representation of a month, with leading zeros "01" through "12" * M A short textual representation of a month, three letters "Jan" through "Dec" * n Numeric representation of a month, without leading zeros "1" through "12" * t Number of days in the given month "28" through "31" * L Whether it's a leap year "1" if it is a leap year, "0" otherwise * o ISO-8601 year number. This has the same value as Y, except that if the "2008" * ISO week number (W) belongs to the previous or next year, that year * is used instead. * Y A full numeric representation of a year, 4 digits "2008" * y A two digit representation of a year "08" * a Lowercase Ante meridiem and Post meridiem "am" or "pm" * A Uppercase Ante meridiem and Post meridiem "AM" or "PM" * B Swatch Internet time "000" through "999" * g 12-hour format of an hour without leading zeros "1" through "12" * G 24-hour format of an hour without leading zeros "0" through "23" * h 12-hour format of an hour with leading zeros "01" through "12" * H 24-hour format of an hour with leading zeros "00" through "23" * i Minutes with leading zeros "00" to "59" * s Seconds, with leading zeros "00" through "59" * u Milliseconds "54321" * e Timezone identifier "UTC", "EST", "PST" * I Whether or not the date is in daylight saving time (uppercase i) "1" if Daylight Saving Time, "0" otherwise * O Difference to Greenwich time (GMT) in hours "+0200", "-0600" * P Difference to Greenwich time (GMT) with colon between hours and minutes "+02:00", "-06:00" * T Timezone abbreviation "UTC", "EST", "PST" * Z Timezone offset in seconds. The offset for timezones west of UTC is "-43200" through "50400" * always negative, and for those east of UTC is always positive. * c ISO 8601 date "2004-02-12T15:19:21+00:00" * r RFC 2822 formatted date "Thu, 21 Dec 2000 16:01:07 +0200" * U Seconds since the Unix Epoch (January 1 1970 00:00:00 GMT) "0" * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @return {String} A string representation of the current Date object. */ var formatReplace = function (context) { return function (m) { var formatString, override = false; if (m.charAt(0) === "\\" || m.substring(0, 2) === "%%") { return m.replace("\\", "").replace("%%", "%"); } override = normalizer.shouldOverrideDefaults(m); formatString = $D.normalizeFormat(m, context); if (formatString) { return context.toString(formatString, override); } }; }; $P._format = function (format) { var formatter = formatReplace(this); if (!format) { return this._toString(); } else { return format.replace(/(%|\\)?.|%%/g, formatter); } }; if (!$P.format) { $P.format = $P._format; } }()); (function () { "use strict"; var gFn = function (attr) { return function () { return this[attr]; }; }; var sFn = function (attr) { return function (val) { this[attr] = val; return this; }; }; var attrs = ["years", "months", "days", "hours", "minutes", "seconds", "milliseconds"]; var addSetFuncs = function (context, attrs) { for (var i = 0; i < attrs.length ; i++) { var $a = attrs[i], $b = $a.slice(0, 1).toUpperCase() + $a.slice(1); context.prototype[$a] = 0; context.prototype["get" + $b] = gFn($a); context.prototype["set" + $b] = sFn($a); } }; /** * new TimeSpan(milliseconds); * new TimeSpan(days, hours, minutes, seconds); * new TimeSpan(days, hours, minutes, seconds, milliseconds); */ var TimeSpan = function (days, hours, minutes, seconds, milliseconds) { if (arguments.length === 1 && typeof days === "number") { var orient = (days < 0) ? -1 : +1; var millsLeft = Math.abs(days); this.setDays(Math.floor(millsLeft / 86400000) * orient); millsLeft = millsLeft % 86400000; this.setHours(Math.floor(millsLeft / 3600000) * orient); millsLeft = millsLeft % 3600000; this.setMinutes(Math.floor(millsLeft / 60000) * orient); millsLeft = millsLeft % 60000; this.setSeconds(Math.floor(millsLeft / 1000) * orient); millsLeft = millsLeft % 1000; this.setMilliseconds(millsLeft * orient); } else { this.set(days, hours, minutes, seconds, milliseconds); } this.getTotalMilliseconds = function () { return (this.getDays() * 86400000) + (this.getHours() * 3600000) + (this.getMinutes() * 60000) + (this.getSeconds() * 1000); }; this.compareTo = function (time) { var t1 = new Date(1970, 1, 1, this.getHours(), this.getMinutes(), this.getSeconds()), t2; if (time === null) { t2 = new Date(1970, 1, 1, 0, 0, 0); } else { t2 = new Date(1970, 1, 1, time.getHours(), time.getMinutes(), time.getSeconds()); } return (t1 < t2) ? -1 : (t1 > t2) ? 1 : 0; }; this.equals = function (time) { return (this.compareTo(time) === 0); }; this.add = function (time) { return (time === null) ? this : this.addSeconds(time.getTotalMilliseconds() / 1000); }; this.subtract = function (time) { return (time === null) ? this : this.addSeconds(-time.getTotalMilliseconds() / 1000); }; this.addDays = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 86400000)); }; this.addHours = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 3600000)); }; this.addMinutes = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 60000)); }; this.addSeconds = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 1000)); }; this.addMilliseconds = function (n) { return new TimeSpan(this.getTotalMilliseconds() + n); }; this.get12HourHour = function () { return (this.getHours() > 12) ? this.getHours() - 12 : (this.getHours() === 0) ? 12 : this.getHours(); }; this.getDesignator = function () { return (this.getHours() < 12) ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator; }; this.toString = function (format) { this._toString = function () { if (this.getDays() !== null && this.getDays() > 0) { return this.getDays() + "." + this.getHours() + ":" + this.p(this.getMinutes()) + ":" + this.p(this.getSeconds()); } else { return this.getHours() + ":" + this.p(this.getMinutes()) + ":" + this.p(this.getSeconds()); } }; this.p = function (s) { return (s.toString().length < 2) ? "0" + s : s; }; var me = this; return format ? format.replace(/dd?|HH?|hh?|mm?|ss?|tt?/g, function (format) { switch (format) { case "d": return me.getDays(); case "dd": return me.p(me.getDays()); case "H": return me.getHours(); case "HH": return me.p(me.getHours()); case "h": return me.get12HourHour(); case "hh": return me.p(me.get12HourHour()); case "m": return me.getMinutes(); case "mm": return me.p(me.getMinutes()); case "s": return me.getSeconds(); case "ss": return me.p(me.getSeconds()); case "t": return ((me.getHours() < 12) ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator).substring(0, 1); case "tt": return (me.getHours() < 12) ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator; } } ) : this._toString(); }; return this; }; addSetFuncs(TimeSpan, attrs.slice(2)); TimeSpan.prototype.set = function (days, hours, minutes, seconds, milliseconds){ this.setDays(days || this.getDays()); this.setHours(hours || this.getHours()); this.setMinutes(minutes || this.getMinutes()); this.setSeconds(seconds || this.getSeconds()); this.setMilliseconds(milliseconds || this.getMilliseconds()); }; /** * Gets the time of day for this date instances. * @return {TimeSpan} TimeSpan */ Date.prototype.getTimeOfDay = function () { return new TimeSpan(0, this.getHours(), this.getMinutes(), this.getSeconds(), this.getMilliseconds()); }; Date.TimeSpan = TimeSpan; if (typeof window !== "undefined" ) { // keeping API compatible for v1.x window.TimeSpan = TimeSpan; } }()); (function () { "use strict"; var attrs = ["years", "months", "days", "hours", "minutes", "seconds", "milliseconds"]; var gFn = function (attr) { return function () { return this[attr]; }; }; var sFn = function (attr) { return function (val) { this[attr] = val; return this; }; }; var addSetFuncs = function (context, attrs) { for (var i = 0; i < attrs.length ; i++) { var $a = attrs[i], $b = $a.slice(0, 1).toUpperCase() + $a.slice(1); context.prototype[$a] = 0; context.prototype["get" + $b] = gFn($a); context.prototype["set" + $b] = sFn($a); } }; var setMonthsAndYears = function (orient, d1, d2, context) { function inc() { d1.addMonths(-orient); context.months++; if (context.months === 12) { context.years++; context.months = 0; } } if (orient === +1) { while (d1 > d2) { inc(); } } else { while (d1 < d2) { inc(); } } context.months--; context.months *= orient; context.years *= orient; }; var adjustForDST = function(orient, startDate, endDate) { var hasDSTMismatch = (false === (startDate.isDaylightSavingTime() === endDate.isDaylightSavingTime())); if (hasDSTMismatch && orient === 1) { startDate.addHours(-1); } else if (hasDSTMismatch) { startDate.addHours(1); } }; /** * TimePeriod(startDate, endDate); * TimePeriod(years, months, days, hours, minutes, seconds, milliseconds); */ var TimePeriod = function (years, months, days, hours, minutes, seconds, milliseconds) { if (arguments.length === 7) { this.set(years, months, days, hours, minutes, seconds, milliseconds); } else if (arguments.length === 2 && arguments[0] instanceof Date && arguments[1] instanceof Date) { var startDate = arguments[0].clone(); var endDate = arguments[1].clone(); var orient = (startDate > endDate) ? +1 : -1; this.dates = { start: arguments[0].clone(), end: arguments[1].clone() }; setMonthsAndYears(orient, startDate, endDate, this); adjustForDST(orient, startDate, endDate); // // TODO - adjust for DST var diff = endDate - startDate; if (diff !== 0) { var ts = new TimeSpan(diff); this.set(this.years, this.months, ts.getDays(), ts.getHours(), ts.getMinutes(), ts.getSeconds(), ts.getMilliseconds()); } } return this; }; // create all the set functions. addSetFuncs(TimePeriod, attrs); TimePeriod.prototype.set = function (years, months, days, hours, minutes, seconds, milliseconds){ this.setYears(years || this.getYears()); this.setMonths(months || this.getMonths()); this.setDays(days || this.getDays()); this.setHours(hours || this.getHours()); this.setMinutes(minutes || this.getMinutes()); this.setSeconds(seconds || this.getSeconds()); this.setMilliseconds(milliseconds || this.getMilliseconds()); }; Date.TimePeriod = TimePeriod; if (typeof window !== "undefined") { // keeping API compatible for v1.x window.TimePeriod = TimePeriod; } }()); ================================================ FILE: build/date-hy-AM.js ================================================ /** * @overview datejs * @version 1.0.0-rc3 * @author Gregory Wild-Smith * @copyright 2015 Gregory Wild-Smith * @license MIT * @homepage https://github.com/abritinthebay/datejs */ /* * DateJS Culture String File * Country Code: hy-AM * Name: Armenian (Armenia) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["hy-AM"] = { "name": "hy-AM", "englishName": "Armenian (Armenia)", "nativeName": "Հայերեն (Հայաստան)", "Sunday": "Կիրակի", "Monday": "Երկուշաբթի", "Tuesday": "Երեքշաբթի", "Wednesday": "Չորեքշաբթի", "Thursday": "Հինգշաբթի", "Friday": "ՈՒրբաթ", "Saturday": "Շաբաթ", "Sun": "Կիր", "Mon": "Երկ", "Tue": "Երք", "Wed": "Չրք", "Thu": "Հնգ", "Fri": "ՈՒր", "Sat": "Շբթ", "Su": "Կ", "Mo": "Ե", "Tu": "Ե", "We": "Չ", "Th": "Հ", "Fr": "Ո", "Sa": "Շ", "S_Sun_Initial": "Կ", "M_Mon_Initial": "Ե", "T_Tue_Initial": "Ե", "W_Wed_Initial": "Չ", "T_Thu_Initial": "Հ", "F_Fri_Initial": "Ո", "S_Sat_Initial": "Շ", "January": "Հունվար", "February": "Փետրվար", "March": "Մարտ", "April": "Ապրիլ", "May": "Մայիս", "June": "Հունիս", "July": "Հուլիս", "August": "Օգոստոս", "September": "Սեպտեմբեր", "October": "Հոկտեմբեր", "November": "Նոյեմբեր", "December": "Դեկտեմբեր", "Jan_Abbr": "ՀՆՎ", "Feb_Abbr": "ՓՏՎ", "Mar_Abbr": "ՄՐՏ", "Apr_Abbr": "ԱՊՐ", "May_Abbr": "ՄՅՍ", "Jun_Abbr": "ՀՆՍ", "Jul_Abbr": "ՀԼՍ", "Aug_Abbr": "ՕԳՍ", "Sep_Abbr": "ՍԵՊ", "Oct_Abbr": "ՀՈԿ", "Nov_Abbr": "ՆՈՅ", "Dec_Abbr": "ԴԵԿ", "AM": "", "PM": "", "firstDayOfWeek": 1, "twoDigitYearMax": 2029, "mdy": "dmy", "M/d/yyyy": "dd.MM.yyyy", "dddd, MMMM dd, yyyy": "d MMMM, yyyy", "h:mm tt": "H:mm", "h:mm:ss tt": "H:mm:ss", "dddd, MMMM dd, yyyy h:mm:ss tt": "d MMMM, yyyy H:mm:ss", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "d MMMM", "MMMM, yyyy": "MMMM, yyyy", "/jan(uary)?/": "հունվար", "/feb(ruary)?/": "փետրվար", "/mar(ch)?/": "մարտ", "/apr(il)?/": "ապր(իլ)?", "/may/": "մայիս", "/jun(e)?/": "հունիս", "/jul(y)?/": "հուլիս", "/aug(ust)?/": "օգոստոս", "/sep(t(ember)?)?/": "սեպ(տեմբեր)?", "/oct(ober)?/": "հոկ(տեմբեր)?", "/nov(ember)?/": "նոյ(եմբեր)?", "/dec(ember)?/": "դեկ(տեմբեր)?", "/^su(n(day)?)?/": "^կ(իր(ակի)?)?", "/^mo(n(day)?)?/": "^ե(րկ(ուշաբթի)?)?", "/^tu(e(s(day)?)?)?/": "^ե(րք(քշաբթի)?)?", "/^we(d(nesday)?)?/": "^չ(րք(եքշաբթի)?)?", "/^th(u(r(s(day)?)?)?)?/": "^հ(նգ(գշաբթի)?)?", "/^fr(i(day)?)?/": "^ո(ւր(բաթ)?)?", "/^sa(t(urday)?)?/": "^շ(բթ(աթ)?)?", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "hy-AM"; /** * @overview datejs * @version 1.0.0-rc3 * @author Gregory Wild-Smith * @copyright 2015 Gregory Wild-Smith * @license MIT * @homepage https://github.com/abritinthebay/datejs */(function () { var $D = Date; var lang = Date.CultureStrings ? Date.CultureStrings.lang : null; var loggedKeys = {}; // for debug purposes. var getText = { getFromKey: function (key, countryCode) { var output; if (Date.CultureStrings && Date.CultureStrings[countryCode] && Date.CultureStrings[countryCode][key]) { output = Date.CultureStrings[countryCode][key]; } else { output = getText.buildFromDefault(key); } if (key.charAt(0) === "/") { // Assume it's a regex output = getText.buildFromRegex(key, countryCode); } return output; }, getFromObjectValues: function (obj, countryCode) { var key, output = {}; for(key in obj) { if (obj.hasOwnProperty(key)) { output[key] = getText.getFromKey(obj[key], countryCode); } } return output; }, getFromObjectKeys: function (obj, countryCode) { var key, output = {}; for(key in obj) { if (obj.hasOwnProperty(key)) { output[getText.getFromKey(key, countryCode)] = obj[key]; } } return output; }, getFromArray: function (arr, countryCode) { var output = []; for (var i=0; i < arr.length; i++){ if (i in arr) { output[i] = getText.getFromKey(arr[i], countryCode); } } return output; }, buildFromDefault: function (key) { var output, length, split, last; switch(key) { case "name": output = "en-US"; break; case "englishName": output = "English (United States)"; break; case "nativeName": output = "English (United States)"; break; case "twoDigitYearMax": output = 2049; break; case "firstDayOfWeek": output = 0; break; default: output = key; split = key.split("_"); length = split.length; if (length > 1 && key.charAt(0) !== "/") { // if the key isn't a regex and it has a split. last = split[(length - 1)].toLowerCase(); if (last === "initial" || last === "abbr") { output = split[0]; } } break; } return output; }, buildFromRegex: function (key, countryCode) { var output; if (Date.CultureStrings && Date.CultureStrings[countryCode] && Date.CultureStrings[countryCode][key]) { output = new RegExp(Date.CultureStrings[countryCode][key], "i"); } else { output = new RegExp(key.replace(new RegExp("/", "g"),""), "i"); } return output; } }; var shallowMerge = function (obj1, obj2) { for (var attrname in obj2) { if (obj2.hasOwnProperty(attrname)) { obj1[attrname] = obj2[attrname]; } } }; var __ = function (key, language) { var countryCode = (language) ? language : lang; loggedKeys[key] = key; if (typeof key === "object") { if (key instanceof Array) { return getText.getFromArray(key, countryCode); } else { return getText.getFromObjectKeys(key, countryCode); } } else { return getText.getFromKey(key, countryCode); } }; var loadI18nScript = function (code) { // paatterned after jQuery's getScript. var url = Date.Config.i18n + code + ".js"; var head = document.getElementsByTagName("head")[0] || document.documentElement; var script = document.createElement("script"); script.src = url; var completed = false; var events = { done: function (){} // placeholder function }; // Attach handlers for all browsers script.onload = script.onreadystatechange = function() { if ( !completed && (!this.readyState || this.readyState === "loaded" || this.readyState === "complete") ) { events.done(); head.removeChild(script); } }; setTimeout(function() { head.insertBefore(script, head.firstChild); }, 0); // allows return to execute first return { done: function (cb) { events.done = function() { if (cb) { setTimeout(cb,0); } }; } }; }; var buildInfo = { buildFromMethodHash: function (obj) { var key; for(key in obj) { if (obj.hasOwnProperty(key)) { obj[key] = buildInfo[obj[key]](); } } return obj; }, timeZoneDST: function () { var DST = { "CHADT": "+1345", "NZDT": "+1300", "AEDT": "+1100", "ACDT": "+1030", "AZST": "+0500", "IRDT": "+0430", "EEST": "+0300", "CEST": "+0200", "BST": "+0100", "PMDT": "-0200", "ADT": "-0300", "NDT": "-0230", "EDT": "-0400", "CDT": "-0500", "MDT": "-0600", "PDT": "-0700", "AKDT": "-0800", "HADT": "-0900" }; return __(DST); }, timeZoneStandard: function () { var standard = { "LINT": "+1400", "TOT": "+1300", "CHAST": "+1245", "NZST": "+1200", "NFT": "+1130", "SBT": "+1100", "AEST": "+1000", "ACST": "+0930", "JST": "+0900", "CWST": "+0845", "CT": "+0800", "ICT": "+0700", "MMT": "+0630", "BST": "+0600", "NPT": "+0545", "IST": "+0530", "PKT": "+0500", "AFT": "+0430", "MSK": "+0400", "IRST": "+0330", "FET": "+0300", "EET": "+0200", "CET": "+0100", "GMT": "+0000", "UTC": "+0000", "CVT": "-0100", "GST": "-0200", "BRT": "-0300", "NST": "-0330", "AST": "-0400", "EST": "-0500", "CST": "-0600", "MST": "-0700", "PST": "-0800", "AKST": "-0900", "MIT": "-0930", "HST": "-1000", "SST": "-1100", "BIT": "-1200" }; return __(standard); }, timeZones: function (data) { var zone; data.timezones = []; for (zone in data.abbreviatedTimeZoneStandard) { if (data.abbreviatedTimeZoneStandard.hasOwnProperty(zone)) { data.timezones.push({ name: zone, offset: data.abbreviatedTimeZoneStandard[zone]}); } } for (zone in data.abbreviatedTimeZoneDST) { if (data.abbreviatedTimeZoneDST.hasOwnProperty(zone)) { data.timezones.push({ name: zone, offset: data.abbreviatedTimeZoneDST[zone], dst: true}); } } return data.timezones; }, days: function () { return __(["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"]); }, dayAbbr: function () { return __(["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"]); }, dayShortNames: function () { return __(["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"]); }, dayFirstLetters: function () { return __(["S_Sun_Initial", "M_Mon_Initial", "T_Tues_Initial", "W_Wed_Initial", "T_Thu_Initial", "F_Fri_Initial", "S_Sat_Initial"]); }, months: function () { return __(["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"]); }, monthAbbr: function () { return __(["Jan_Abbr", "Feb_Abbr", "Mar_Abbr", "Apr_Abbr", "May_Abbr", "Jun_Abbr", "Jul_Abbr", "Aug_Abbr", "Sep_Abbr", "Oct_Abbr", "Nov_Abbr", "Dec_Abbr"]); }, formatPatterns: function () { return getText.getFromObjectValues({ shortDate: "M/d/yyyy", longDate: "dddd, MMMM dd, yyyy", shortTime: "h:mm tt", longTime: "h:mm:ss tt", fullDateTime: "dddd, MMMM dd, yyyy h:mm:ss tt", sortableDateTime: "yyyy-MM-ddTHH:mm:ss", universalSortableDateTime: "yyyy-MM-dd HH:mm:ssZ", rfc1123: "ddd, dd MMM yyyy HH:mm:ss", monthDay: "MMMM dd", yearMonth: "MMMM, yyyy" }, Date.i18n.currentLanguage()); }, regex: function () { return getText.getFromObjectValues({ inTheMorning: "/( in the )(morn(ing)?)\\b/", thisMorning: "/(this )(morn(ing)?)\\b/", amThisMorning: "/(\b\\d(am)? )(this )(morn(ing)?)/", inTheEvening: "/( in the )(even(ing)?)\\b/", thisEvening: "/(this )(even(ing)?)\\b/", pmThisEvening: "/(\b\\d(pm)? )(this )(even(ing)?)/", jan: "/jan(uary)?/", feb: "/feb(ruary)?/", mar: "/mar(ch)?/", apr: "/apr(il)?/", may: "/may/", jun: "/jun(e)?/", jul: "/jul(y)?/", aug: "/aug(ust)?/", sep: "/sep(t(ember)?)?/", oct: "/oct(ober)?/", nov: "/nov(ember)?/", dec: "/dec(ember)?/", sun: "/^su(n(day)?)?/", mon: "/^mo(n(day)?)?/", tue: "/^tu(e(s(day)?)?)?/", wed: "/^we(d(nesday)?)?/", thu: "/^th(u(r(s(day)?)?)?)?/", fri: "/fr(i(day)?)?/", sat: "/^sa(t(urday)?)?/", future: "/^next/", past: "/^last|past|prev(ious)?/", add: "/^(\\+|aft(er)?|from|hence)/", subtract: "/^(\\-|bef(ore)?|ago)/", yesterday: "/^yes(terday)?/", today: "/^t(od(ay)?)?/", tomorrow: "/^tom(orrow)?/", now: "/^n(ow)?/", millisecond: "/^ms|milli(second)?s?/", second: "/^sec(ond)?s?/", minute: "/^mn|min(ute)?s?/", hour: "/^h(our)?s?/", week: "/^w(eek)?s?/", month: "/^m(onth)?s?/", day: "/^d(ay)?s?/", year: "/^y(ear)?s?/", shortMeridian: "/^(a|p)/", longMeridian: "/^(a\\.?m?\\.?|p\\.?m?\\.?)/", timezone: "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/", ordinalSuffix: "/^\\s*(st|nd|rd|th)/", timeContext: "/^\\s*(\\:|a(?!u|p)|p)/" }, Date.i18n.currentLanguage()); } }; var CultureInfo = function () { var info = getText.getFromObjectValues({ name: "name", englishName: "englishName", nativeName: "nativeName", amDesignator: "AM", pmDesignator: "PM", firstDayOfWeek: "firstDayOfWeek", twoDigitYearMax: "twoDigitYearMax", dateElementOrder: "mdy" }, Date.i18n.currentLanguage()); var constructedInfo = buildInfo.buildFromMethodHash({ dayNames: "days", abbreviatedDayNames: "dayAbbr", shortestDayNames: "dayShortNames", firstLetterDayNames: "dayFirstLetters", monthNames: "months", abbreviatedMonthNames: "monthAbbr", formatPatterns: "formatPatterns", regexPatterns: "regex", abbreviatedTimeZoneDST: "timeZoneDST", abbreviatedTimeZoneStandard: "timeZoneStandard" }); shallowMerge(info, constructedInfo); buildInfo.timeZones(info); return info; }; $D.i18n = { __: function (key, lang) { return __(key, lang); }, currentLanguage: function () { return lang || "en-US"; }, setLanguage: function (code, force, cb) { var async = false; if (force || code === "en-US" || (!!Date.CultureStrings && !!Date.CultureStrings[code])) { lang = code; Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings.lang = code; Date.CultureInfo = new CultureInfo(); } else { if (!(!!Date.CultureStrings && !!Date.CultureStrings[code])) { if (typeof exports !== "undefined" && this.exports !== exports) { // we're in a Node enviroment, load it using require try { require("../i18n/" + code + ".js"); lang = code; Date.CultureStrings.lang = code; Date.CultureInfo = new CultureInfo(); } catch (e) { // var str = "The language for '" + code + "' could not be loaded by Node. It likely does not exist."; throw new Error("The DateJS IETF language tag '" + code + "' could not be loaded by Node. It likely does not exist."); } } else if (Date.Config && Date.Config.i18n) { // we know the location of the files, so lets load them async = true; loadI18nScript(code).done(function(){ lang = code; Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings.lang = code; Date.CultureInfo = new CultureInfo(); $D.Parsing.Normalizer.buildReplaceData(); // because this is async if ($D.Grammar) { $D.Grammar.buildGrammarFormats(); // so we can parse those strings... } if (cb) { setTimeout(cb,0); } }); } else { Date.console.error("The DateJS IETF language tag '" + code + "' is not available and has not been loaded."); return false; } } } $D.Parsing.Normalizer.buildReplaceData(); // rebuild normalizer strings if ($D.Grammar) { $D.Grammar.buildGrammarFormats(); // so we can parse those strings... } if (!async && cb) { setTimeout(cb,0); } }, getLoggedKeys: function () { return loggedKeys; }, updateCultureInfo: function () { Date.CultureInfo = new CultureInfo(); } }; $D.i18n.updateCultureInfo(); // run automatically }()); (function () { var $D = Date, $P = $D.prototype, p = function (s, l) { if (!l) { l = 2; } return ("000" + s).slice(l * -1); }; if (typeof window !== "undefined" && typeof window.console !== "undefined" && typeof window.console.log !== "undefined") { $D.console = console; // used only to raise non-critical errors if available } else { // set mock so we don't give errors. $D.console = { log: function(){}, error: function(){} }; } $D.Config = $D.Config || {}; $D.initOverloads = function() { /** * Overload of Date.now. Allows an alternate call for Date.now where it returns the * current Date as an object rather than just milliseconds since the Unix Epoch. * * Also provides an implementation of now() for browsers (IE<9) that don't have it. * * Backwards compatible so with work with either: * Date.now() [returns ms] * or * Date.now(true) [returns Date] */ if (!$D.now) { $D._now = function now() { return new Date().getTime(); }; } else if (!$D._now) { $D._now = $D.now; } $D.now = function (returnObj) { if (returnObj) { return $D.present(); } else { return $D._now(); } }; if ( !$P.toISOString ) { $P.toISOString = function() { return this.getUTCFullYear() + "-" + p(this.getUTCMonth() + 1) + "-" + p(this.getUTCDate()) + "T" + p(this.getUTCHours()) + ":" + p(this.getUTCMinutes()) + ":" + p(this.getUTCSeconds()) + "." + String( (this.getUTCMilliseconds()/1000).toFixed(3)).slice(2, 5) + "Z"; }; } // private if ( $P._toString === undefined ){ $P._toString = $P.toString; } }; $D.initOverloads(); /** * Gets a date that is set to the current date. The time is set to the start of the day (00:00 or 12:00 AM). * @return {Date} The current date. */ $D.today = function () { return new Date().clearTime(); }; /** * Gets a date that is set to the current date and time (same as new Date, but chainable) * @return {Date} The current date. */ $D.present = function () { return new Date(); }; /** * Compares the first date to the second date and returns an number indication of their relative values. * @param {Date} First Date object to compare [Required]. * @param {Date} Second Date object to compare to [Required]. * @return {Number} -1 = date1 is lessthan date2. 0 = values are equal. 1 = date1 is greaterthan date2. */ $D.compare = function (date1, date2) { if (isNaN(date1) || isNaN(date2)) { throw new Error(date1 + " - " + date2); } else if (date1 instanceof Date && date2 instanceof Date) { return (date1 < date2) ? -1 : (date1 > date2) ? 1 : 0; } else { throw new TypeError(date1 + " - " + date2); } }; /** * Compares the first Date object to the second Date object and returns true if they are equal. * @param {Date} First Date object to compare [Required] * @param {Date} Second Date object to compare to [Required] * @return {Boolean} true if dates are equal. false if they are not equal. */ $D.equals = function (date1, date2) { return (date1.compareTo(date2) === 0); }; /** * Gets the language appropriate day name when given the day number(0-6) * eg - 0 == Sunday * @return {String} The day name */ $D.getDayName = function (n) { return Date.CultureInfo.dayNames[n]; }; /** * Gets the day number (0-6) if given a CultureInfo specific string which is a valid dayName, abbreviatedDayName or shortestDayName (two char). * @param {String} The name of the day (eg. "Monday, "Mon", "tuesday", "tue", "We", "we"). * @return {Number} The day number */ $D.getDayNumberFromName = function (name) { var n = Date.CultureInfo.dayNames, m = Date.CultureInfo.abbreviatedDayNames, o = Date.CultureInfo.shortestDayNames, s = name.toLowerCase(); for (var i = 0; i < n.length; i++) { if (n[i].toLowerCase() === s || m[i].toLowerCase() === s || o[i].toLowerCase() === s) { return i; } } return -1; }; /** * Gets the month number (0-11) if given a Culture Info specific string which is a valid monthName or abbreviatedMonthName. * @param {String} The name of the month (eg. "February, "Feb", "october", "oct"). * @return {Number} The day number */ $D.getMonthNumberFromName = function (name) { var n = Date.CultureInfo.monthNames, m = Date.CultureInfo.abbreviatedMonthNames, s = name.toLowerCase(); for (var i = 0; i < n.length; i++) { if (n[i].toLowerCase() === s || m[i].toLowerCase() === s) { return i; } } return -1; }; /** * Gets the language appropriate month name when given the month number(0-11) * eg - 0 == January * @return {String} The month name */ $D.getMonthName = function (n) { return Date.CultureInfo.monthNames[n]; }; /** * Determines if the current date instance is within a LeapYear. * @param {Number} The year. * @return {Boolean} true if date is within a LeapYear, otherwise false. */ $D.isLeapYear = function (year) { return ((year % 4 === 0 && year % 100 !== 0) || year % 400 === 0); }; /** * Gets the number of days in the month, given a year and month value. Automatically corrects for LeapYear. * @param {Number} The year. * @param {Number} The month (0-11). * @return {Number} The number of days in the month. */ $D.getDaysInMonth = function (year, month) { if (!month && $D.validateMonth(year)) { month = year; year = Date.today().getFullYear(); } return [31, ($D.isLeapYear(year) ? 29 : 28), 31, 30, 31, 30, 31, 31, 30, 31, 30, 31][month]; }; $P.getDaysInMonth = function () { return $D.getDaysInMonth(this.getFullYear(), this.getMonth()); }; $D.getTimezoneAbbreviation = function (offset, dst) { var p, n = (dst || false) ? Date.CultureInfo.abbreviatedTimeZoneDST : Date.CultureInfo.abbreviatedTimeZoneStandard; for (p in n) { if (n.hasOwnProperty(p)) { if (n[p] === offset) { return p; } } } return null; }; $D.getTimezoneOffset = function (name, dst) { var i, a =[], z = Date.CultureInfo.timezones; if (!name) { name = (new Date()).getTimezone();} for (i = 0; i < z.length; i++) { if (z[i].name === name.toUpperCase()) { a.push(i); } } if (!z[a[0]]) { return null; } if (a.length === 1 || !dst) { return z[a[0]].offset; } else { for (i=0; i < a.length; i++) { if (z[a[i]].dst) { return z[a[i]].offset; } } } }; $D.getQuarter = function (d) { d = d || new Date(); // If no date supplied, use today var q = [1,2,3,4]; return q[Math.floor(d.getMonth() / 3)]; // ~~~ is a bitwise op. Faster than Math.floor }; $D.getDaysLeftInQuarter = function (d) { d = d || new Date(); var qEnd = new Date(d); qEnd.setMonth(qEnd.getMonth() + 3 - qEnd.getMonth() % 3, 0); return Math.floor((qEnd - d) / 8.64e7); }; // private var validate = function (n, min, max, name) { name = name ? name : "Object"; if (typeof n === "undefined") { return false; } else if (typeof n !== "number") { throw new TypeError(n + " is not a Number."); } else if (n < min || n > max) { // As failing validation is *not* an exceptional circumstance // lets not throw a RangeError Exception here. // It's semantically correct but it's not sensible. return false; } return true; }; /** * Validates the number is within an acceptable range for milliseconds [0-999]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateMillisecond = function (value) { return validate(value, 0, 999, "millisecond"); }; /** * Validates the number is within an acceptable range for seconds [0-59]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateSecond = function (value) { return validate(value, 0, 59, "second"); }; /** * Validates the number is within an acceptable range for minutes [0-59]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateMinute = function (value) { return validate(value, 0, 59, "minute"); }; /** * Validates the number is within an acceptable range for hours [0-23]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateHour = function (value) { return validate(value, 0, 23, "hour"); }; /** * Validates the number is within an acceptable range for the days in a month [0-MaxDaysInMonth]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateDay = function (value, year, month) { if (year === undefined || year === null || month === undefined || month === null) { return false;} return validate(value, 1, $D.getDaysInMonth(year, month), "day"); }; /** * Validates the number is within an acceptable range for months [0-11]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateWeek = function (value) { return validate(value, 0, 53, "week"); }; /** * Validates the number is within an acceptable range for months [0-11]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateMonth = function (value) { return validate(value, 0, 11, "month"); }; /** * Validates the number is within an acceptable range for years. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateYear = function (value) { /** * Per ECMAScript spec the range of times supported by Date objects is * exactly -100,000,000 days to +100,000,000 days measured relative to * midnight at the beginning of 01 January, 1970 UTC. * This gives a range of 8,640,000,000,000,000 milliseconds to either * side of 01 January, 1970 UTC. * * Earliest possible date: Tue, 20 Apr 271,822 B.C. 00:00:00 UTC * Latest possible date: Sat, 13 Sep 275,760 00:00:00 UTC */ return validate(value, -271822, 275760, "year"); }; $D.validateTimezone = function(value) { var timezones = {"ACDT":1,"ACST":1,"ACT":1,"ADT":1,"AEDT":1,"AEST":1,"AFT":1,"AKDT":1,"AKST":1,"AMST":1,"AMT":1,"ART":1,"AST":1,"AWDT":1,"AWST":1,"AZOST":1,"AZT":1,"BDT":1,"BIOT":1,"BIT":1,"BOT":1,"BRT":1,"BST":1,"BTT":1,"CAT":1,"CCT":1,"CDT":1,"CEDT":1,"CEST":1,"CET":1,"CHADT":1,"CHAST":1,"CHOT":1,"ChST":1,"CHUT":1,"CIST":1,"CIT":1,"CKT":1,"CLST":1,"CLT":1,"COST":1,"COT":1,"CST":1,"CT":1,"CVT":1,"CWST":1,"CXT":1,"DAVT":1,"DDUT":1,"DFT":1,"EASST":1,"EAST":1,"EAT":1,"ECT":1,"EDT":1,"EEDT":1,"EEST":1,"EET":1,"EGST":1,"EGT":1,"EIT":1,"EST":1,"FET":1,"FJT":1,"FKST":1,"FKT":1,"FNT":1,"GALT":1,"GAMT":1,"GET":1,"GFT":1,"GILT":1,"GIT":1,"GMT":1,"GST":1,"GYT":1,"HADT":1,"HAEC":1,"HAST":1,"HKT":1,"HMT":1,"HOVT":1,"HST":1,"ICT":1,"IDT":1,"IOT":1,"IRDT":1,"IRKT":1,"IRST":1,"IST":1,"JST":1,"KGT":1,"KOST":1,"KRAT":1,"KST":1,"LHST":1,"LINT":1,"MAGT":1,"MART":1,"MAWT":1,"MDT":1,"MET":1,"MEST":1,"MHT":1,"MIST":1,"MIT":1,"MMT":1,"MSK":1,"MST":1,"MUT":1,"MVT":1,"MYT":1,"NCT":1,"NDT":1,"NFT":1,"NPT":1,"NST":1,"NT":1,"NUT":1,"NZDT":1,"NZST":1,"OMST":1,"ORAT":1,"PDT":1,"PET":1,"PETT":1,"PGT":1,"PHOT":1,"PHT":1,"PKT":1,"PMDT":1,"PMST":1,"PONT":1,"PST":1,"PYST":1,"PYT":1,"RET":1,"ROTT":1,"SAKT":1,"SAMT":1,"SAST":1,"SBT":1,"SCT":1,"SGT":1,"SLST":1,"SRT":1,"SST":1,"SYOT":1,"TAHT":1,"THA":1,"TFT":1,"TJT":1,"TKT":1,"TLT":1,"TMT":1,"TOT":1,"TVT":1,"UCT":1,"ULAT":1,"UTC":1,"UYST":1,"UYT":1,"UZT":1,"VET":1,"VLAT":1,"VOLT":1,"VOST":1,"VUT":1,"WAKT":1,"WAST":1,"WAT":1,"WEDT":1,"WEST":1,"WET":1,"WST":1,"YAKT":1,"YEKT":1,"Z":1}; return (timezones[value] === 1); }; $D.validateTimezoneOffset= function(value) { // timezones go from +14hrs to -12hrs, the +X hours are negative offsets. return (value > -841 && value < 721); }; }()); (function () { var $D = Date, $P = $D.prototype, p = function (s, l) { if (!l) { l = 2; } return ("000" + s).slice(l * -1); }; var validateConfigObject = function (obj) { var result = {}, self = this, prop, testFunc; testFunc = function (prop, func, value) { if (prop === "day") { var month = (obj.month !== undefined) ? obj.month : self.getMonth(); var year = (obj.year !== undefined) ? obj.year : self.getFullYear(); return $D[func](value, year, month); } else { return $D[func](value); } }; for (prop in obj) { if (Object.prototype.hasOwnProperty.call(obj, prop)) { var func = "validate" + prop.charAt(0).toUpperCase() + prop.slice(1); if ($D[func] && obj[prop] !== null && testFunc(prop, func, obj[prop])) { result[prop] = obj[prop]; } } } return result; }; /** * Resets the time of this Date object to 12:00 AM (00:00), which is the start of the day. * @param {Boolean} .clone() this date instance before clearing Time * @return {Date} this */ $P.clearTime = function () { this.setHours(0); this.setMinutes(0); this.setSeconds(0); this.setMilliseconds(0); return this; }; /** * Resets the time of this Date object to the current time ('now'). * @return {Date} this */ $P.setTimeToNow = function () { var n = new Date(); this.setHours(n.getHours()); this.setMinutes(n.getMinutes()); this.setSeconds(n.getSeconds()); this.setMilliseconds(n.getMilliseconds()); return this; }; /** * Returns a new Date object that is an exact date and time copy of the original instance. * @return {Date} A new Date instance */ $P.clone = function () { return new Date(this.getTime()); }; /** * Compares this instance to a Date object and returns an number indication of their relative values. * @param {Date} Date object to compare [Required] * @return {Number} -1 = this is lessthan date. 0 = values are equal. 1 = this is greaterthan date. */ $P.compareTo = function (date) { return Date.compare(this, date); }; /** * Compares this instance to another Date object and returns true if they are equal. * @param {Date} Date object to compare. If no date to compare, new Date() [now] is used. * @return {Boolean} true if dates are equal. false if they are not equal. */ $P.equals = function (date) { return Date.equals(this, (date !== undefined ? date : new Date())); }; /** * Determines if this instance is between a range of two dates or equal to either the start or end dates. * @param {Date} Start of range [Required] * @param {Date} End of range [Required] * @return {Boolean} true is this is between or equal to the start and end dates, else false */ $P.between = function (start, end) { return this.getTime() >= start.getTime() && this.getTime() <= end.getTime(); }; /** * Determines if this date occurs after the date to compare to. * @param {Date} Date object to compare. If no date to compare, new Date() ("now") is used. * @return {Boolean} true if this date instance is greater than the date to compare to (or "now"), otherwise false. */ $P.isAfter = function (date) { return this.compareTo(date || new Date()) === 1; }; /** * Determines if this date occurs before the date to compare to. * @param {Date} Date object to compare. If no date to compare, new Date() ("now") is used. * @return {Boolean} true if this date instance is less than the date to compare to (or "now"). */ $P.isBefore = function (date) { return (this.compareTo(date || new Date()) === -1); }; /** * Determines if the current Date instance occurs today. * @return {Boolean} true if this date instance is 'today', otherwise false. */ /** * Determines if the current Date instance occurs on the same Date as the supplied 'date'. * If no 'date' to compare to is provided, the current Date instance is compared to 'today'. * @param {date} Date object to compare. If no date to compare, the current Date ("now") is used. * @return {Boolean} true if this Date instance occurs on the same Day as the supplied 'date'. */ $P.isToday = $P.isSameDay = function (date) { return this.clone().clearTime().equals((date || new Date()).clone().clearTime()); }; /** * Adds the specified number of milliseconds to this instance. * @param {Number} The number of milliseconds to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addMilliseconds = function (value) { if (!value) { return this; } this.setTime(this.getTime() + value * 1); return this; }; /** * Adds the specified number of seconds to this instance. * @param {Number} The number of seconds to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addSeconds = function (value) { if (!value) { return this; } return this.addMilliseconds(value * 1000); }; /** * Adds the specified number of seconds to this instance. * @param {Number} The number of seconds to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addMinutes = function (value) { if (!value) { return this; } return this.addMilliseconds(value * 60000); // 60*1000 }; /** * Adds the specified number of hours to this instance. * @param {Number} The number of hours to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addHours = function (value) { if (!value) { return this; } return this.addMilliseconds(value * 3600000); // 60*60*1000 }; /** * Adds the specified number of days to this instance. * @param {Number} The number of days to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addDays = function (value) { if (!value) { return this; } this.setDate(this.getDate() + value * 1); return this; }; /** * Adds the specified number of weekdays (ie - not sat or sun) to this instance. * @param {Number} The number of days to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addWeekdays = function (value) { if (!value) { return this; } var day = this.getDay(); var weeks = (Math.ceil(Math.abs(value)/7)); if (day === 0 || day === 6) { if (value > 0) { this.next().monday(); this.addDays(-1); day = this.getDay(); } } if (value < 0) { while (value < 0) { this.addDays(-1); day = this.getDay(); if (day !== 0 && day !== 6) { value++; } } return this; } else if (value > 5 || (6-day) <= value) { value = value + (weeks * 2); } return this.addDays(value); }; /** * Adds the specified number of weeks to this instance. * @param {Number} The number of weeks to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addWeeks = function (value) { if (!value) { return this; } return this.addDays(value * 7); }; /** * Adds the specified number of months to this instance. * @param {Number} The number of months to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addMonths = function (value) { if (!value) { return this; } var n = this.getDate(); this.setDate(1); this.setMonth(this.getMonth() + value * 1); this.setDate(Math.min(n, $D.getDaysInMonth(this.getFullYear(), this.getMonth()))); return this; }; $P.addQuarters = function (value) { if (!value) { return this; } // note this will take you to the same point in the quarter as you are now. // i.e. - if you are 15 days into the quarter you'll be 15 days into the resulting one. // bonus: this allows adding fractional quarters return this.addMonths(value * 3); }; /** * Adds the specified number of years to this instance. * @param {Number} The number of years to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addYears = function (value) { if (!value) { return this; } return this.addMonths(value * 12); }; /** * Adds (or subtracts) to the value of the years, months, weeks, days, hours, minutes, seconds, milliseconds of the date instance using given configuration object. Positive and Negative values allowed. * Example

	Date.today().add( { days: 1, months: 1 } )

	new Date().add( { years: -1 } )
	
* @param {Object} Configuration object containing attributes (months, days, etc.) * @return {Date} this */ $P.add = function (config) { if (typeof config === "number") { this._orient = config; return this; } var x = config; if (x.day) { // If we should be a different date than today (eg: for 'tomorrow -1d', etc). // Should only effect parsing, not direct usage (eg, Finish and FinishExact) if ((x.day - this.getDate()) !== 0) { this.setDate(x.day); } } if (x.milliseconds) { this.addMilliseconds(x.milliseconds); } if (x.seconds) { this.addSeconds(x.seconds); } if (x.minutes) { this.addMinutes(x.minutes); } if (x.hours) { this.addHours(x.hours); } if (x.weeks) { this.addWeeks(x.weeks); } if (x.months) { this.addMonths(x.months); } if (x.years) { this.addYears(x.years); } if (x.days) { this.addDays(x.days); } return this; }; /** * Get the week number. Week one (1) is the week which contains the first Thursday of the year. Monday is considered the first day of the week. * The .getWeek() function does NOT convert the date to UTC. The local datetime is used. * Please use .getISOWeek() to get the week of the UTC converted date. * @return {Number} 1 to 53 */ $P.getWeek = function (utc) { // Create a copy of this date object var self, target = new Date(this.valueOf()); if (utc) { target.addMinutes(target.getTimezoneOffset()); self = target.clone(); } else { self = this; } // ISO week date weeks start on monday // so correct the day number var dayNr = (self.getDay() + 6) % 7; // ISO 8601 states that week 1 is the week // with the first thursday of that year. // Set the target date to the thursday in the target week target.setDate(target.getDate() - dayNr + 3); // Store the millisecond value of the target date var firstThursday = target.valueOf(); // Set the target to the first thursday of the year // First set the target to january first target.setMonth(0, 1); // Not a thursday? Correct the date to the next thursday if (target.getDay() !== 4) { target.setMonth(0, 1 + ((4 - target.getDay()) + 7) % 7); } // The weeknumber is the number of weeks between the // first thursday of the year and the thursday in the target week return 1 + Math.ceil((firstThursday - target) / 604800000); // 604800000 = 7 * 24 * 3600 * 1000 }; /** * Get the ISO 8601 week number. Week one ("01") is the week which contains the first Thursday of the year. Monday is considered the first day of the week. * The .getISOWeek() function does convert the date to it's UTC value. Please use .getWeek() to get the week of the local date. * @return {String} "01" to "53" */ $P.getISOWeek = function () { return p(this.getWeek(true)); }; /** * Moves the date to Monday of the week set. Week one (1) is the week which contains the first Thursday of the year. * @param {Number} A Number (1 to 53) that represents the week of the year. * @return {Date} this */ $P.setWeek = function (n) { if ((n - this.getWeek()) === 0) { if (this.getDay() !== 1) { return this.moveToDayOfWeek(1, (this.getDay() > 1 ? -1 : 1)); } else { return this; } } else { return this.moveToDayOfWeek(1, (this.getDay() > 1 ? -1 : 1)).addWeeks(n - this.getWeek()); } }; $P.setQuarter = function (qtr) { var month = Math.abs(((qtr-1) * 3) + 1); return this.setMonth(month, 1); }; $P.getQuarter = function () { return Date.getQuarter(this); }; $P.getDaysLeftInQuarter = function () { return Date.getDaysLeftInQuarter(this); }; /** * Moves the date to the next n'th occurrence of the dayOfWeek starting from the beginning of the month. The number (-1) is a magic number and will return the last occurrence of the dayOfWeek in the month. * @param {Number} The dayOfWeek to move to * @param {Number} The n'th occurrence to move to. Use (-1) to return the last occurrence in the month * @return {Date} this */ $P.moveToNthOccurrence = function (dayOfWeek, occurrence) { if (dayOfWeek === "Weekday") { if (occurrence > 0) { this.moveToFirstDayOfMonth(); if (this.is().weekday()) { occurrence -= 1; } } else if (occurrence < 0) { this.moveToLastDayOfMonth(); if (this.is().weekday()) { occurrence += 1; } } else { return this; } return this.addWeekdays(occurrence); } var shift = 0; if (occurrence > 0) { shift = occurrence - 1; } else if (occurrence === -1) { this.moveToLastDayOfMonth(); if (this.getDay() !== dayOfWeek) { this.moveToDayOfWeek(dayOfWeek, -1); } return this; } return this.moveToFirstDayOfMonth().addDays(-1).moveToDayOfWeek(dayOfWeek, +1).addWeeks(shift); }; var moveToN = function (getFunc, addFunc, nVal) { return function (value, orient) { var diff = (value - this[getFunc]() + nVal * (orient || +1)) % nVal; return this[addFunc]((diff === 0) ? diff += nVal * (orient || +1) : diff); }; }; /** * Move to the next or last dayOfWeek based on the orient value. * @param {Number} The dayOfWeek to move to * @param {Number} Forward (+1) or Back (-1). Defaults to +1. [Optional] * @return {Date} this */ $P.moveToDayOfWeek = moveToN("getDay", "addDays", 7); /** * Move to the next or last month based on the orient value. * @param {Number} The month to move to. 0 = January, 11 = December * @param {Number} Forward (+1) or Back (-1). Defaults to +1. [Optional] * @return {Date} this */ $P.moveToMonth = moveToN("getMonth", "addMonths", 12); /** * Get the Ordinate of the current day ("th", "st", "rd"). * @return {String} */ $P.getOrdinate = function () { var num = this.getDate(); return ord(num); }; /** * Get the Ordinal day (numeric day number) of the year, adjusted for leap year. * @return {Number} 1 through 365 (366 in leap years) */ $P.getOrdinalNumber = function () { return Math.ceil((this.clone().clearTime() - new Date(this.getFullYear(), 0, 1)) / 86400000) + 1; }; /** * Get the time zone abbreviation of the current date. * @return {String} The abbreviated time zone name (e.g. "EST") */ $P.getTimezone = function () { return $D.getTimezoneAbbreviation(this.getUTCOffset(), this.isDaylightSavingTime()); }; $P.setTimezoneOffset = function (offset) { var here = this.getTimezoneOffset(), there = Number(offset) * -6 / 10; return (there || there === 0) ? this.addMinutes(there - here) : this; }; $P.setTimezone = function (offset) { return this.setTimezoneOffset($D.getTimezoneOffset(offset)); }; /** * Indicates whether Daylight Saving Time is observed in the current time zone. * @return {Boolean} true|false */ $P.hasDaylightSavingTime = function () { return (Date.today().set({month: 0, day: 1}).getTimezoneOffset() !== Date.today().set({month: 6, day: 1}).getTimezoneOffset()); }; /** * Indicates whether this Date instance is within the Daylight Saving Time range for the current time zone. * @return {Boolean} true|false */ $P.isDaylightSavingTime = function () { return Date.today().set({month: 0, day: 1}).getTimezoneOffset() !== this.getTimezoneOffset(); }; /** * Get the offset from UTC of the current date. * @return {String} The 4-character offset string prefixed with + or - (e.g. "-0500") */ $P.getUTCOffset = function (offset) { var n = (offset || this.getTimezoneOffset()) * -10 / 6, r; if (n < 0) { r = (n - 10000).toString(); return r.charAt(0) + r.substr(2); } else { r = (n + 10000).toString(); return "+" + r.substr(1); } }; /** * Returns the number of milliseconds between this date and date. * @param {Date} Defaults to now * @return {Number} The diff in milliseconds */ $P.getElapsed = function (date) { return (date || new Date()) - this; }; /** * Set the value of year, month, day, hour, minute, second, millisecond of date instance using given configuration object. * Example

	Date.today().set( { day: 20, month: 1 } )

	new Date().set( { millisecond: 0 } )
	
* * @param {Object} Configuration object containing attributes (month, day, etc.) * @return {Date} this */ $P.set = function (config) { config = validateConfigObject.call(this, config); var key; for (key in config) { if (Object.prototype.hasOwnProperty.call(config, key)) { var name = key.charAt(0).toUpperCase() + key.slice(1); var addFunc, getFunc; if (key !== "week" && key !== "month" && key !== "timezone" && key !== "timezoneOffset") { name += "s"; } addFunc = "add" + name; getFunc = "get" + name; if (key === "month") { addFunc = addFunc + "s"; } else if (key === "year"){ getFunc = "getFullYear"; } if (key !== "day" && key !== "timezone" && key !== "timezoneOffset" && key !== "week" && key !== "hour") { this[addFunc](config[key] - this[getFunc]()); } else if ( key === "timezone"|| key === "timezoneOffset" || key === "week" || key === "hour") { this["set"+name](config[key]); } } } // day has to go last because you can't validate the day without first knowing the month if (config.day) { this.addDays(config.day - this.getDate()); } return this; }; /** * Moves the date to the first day of the month. * @return {Date} this */ $P.moveToFirstDayOfMonth = function () { return this.set({ day: 1 }); }; /** * Moves the date to the last day of the month. * @return {Date} this */ $P.moveToLastDayOfMonth = function () { return this.set({ day: $D.getDaysInMonth(this.getFullYear(), this.getMonth())}); }; /** * Converts the value of the current Date object to its equivalent string representation. * Format Specifiers * CUSTOM DATE AND TIME FORMAT STRINGS * Format Description Example * ------ --------------------------------------------------------------------------- ----------------------- * s The seconds of the minute between 0-59. "0" to "59" * ss The seconds of the minute with leading zero if required. "00" to "59" * * m The minute of the hour between 0-59. "0" or "59" * mm The minute of the hour with leading zero if required. "00" or "59" * * h The hour of the day between 1-12. "1" to "12" * hh The hour of the day with leading zero if required. "01" to "12" * * H The hour of the day between 0-23. "0" to "23" * HH The hour of the day with leading zero if required. "00" to "23" * * d The day of the month between 1 and 31. "1" to "31" * dd The day of the month with leading zero if required. "01" to "31" * ddd Abbreviated day name. Date.CultureInfo.abbreviatedDayNames. "Mon" to "Sun" * dddd The full day name. Date.CultureInfo.dayNames. "Monday" to "Sunday" * * M The month of the year between 1-12. "1" to "12" * MM The month of the year with leading zero if required. "01" to "12" * MMM Abbreviated month name. Date.CultureInfo.abbreviatedMonthNames. "Jan" to "Dec" * MMMM The full month name. Date.CultureInfo.monthNames. "January" to "December" * * yy The year as a two-digit number. "99" or "08" * yyyy The full four digit year. "1999" or "2008" * * t Displays the first character of the A.M./P.M. designator. "A" or "P" * Date.CultureInfo.amDesignator or Date.CultureInfo.pmDesignator * tt Displays the A.M./P.M. designator. "AM" or "PM" * Date.CultureInfo.amDesignator or Date.CultureInfo.pmDesignator * * S The ordinal suffix ("st, "nd", "rd" or "th") of the current day. "st, "nd", "rd" or "th" * * STANDARD DATE AND TIME FORMAT STRINGS * Format Description Example *------ --------------------------------------------------------------------------- ----------------------- * d The CultureInfo shortDate Format Pattern "M/d/yyyy" * D The CultureInfo longDate Format Pattern "dddd, MMMM dd, yyyy" * F The CultureInfo fullDateTime Format Pattern "dddd, MMMM dd, yyyy h:mm:ss tt" * m The CultureInfo monthDay Format Pattern "MMMM dd" * r The CultureInfo rfc1123 Format Pattern "ddd, dd MMM yyyy HH:mm:ss GMT" * s The CultureInfo sortableDateTime Format Pattern "yyyy-MM-ddTHH:mm:ss" * t The CultureInfo shortTime Format Pattern "h:mm tt" * T The CultureInfo longTime Format Pattern "h:mm:ss tt" * u The CultureInfo universalSortableDateTime Format Pattern "yyyy-MM-dd HH:mm:ssZ" * y The CultureInfo yearMonth Format Pattern "MMMM, yyyy" * * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @return {String} A string representation of the current Date object. */ var ord = function (n) { switch (n * 1) { case 1: case 21: case 31: return "st"; case 2: case 22: return "nd"; case 3: case 23: return "rd"; default: return "th"; } }; var parseStandardFormats = function (format) { var y, c = Date.CultureInfo.formatPatterns; switch (format) { case "d": return this.toString(c.shortDate); case "D": return this.toString(c.longDate); case "F": return this.toString(c.fullDateTime); case "m": return this.toString(c.monthDay); case "r": case "R": y = this.clone().addMinutes(this.getTimezoneOffset()); return y.toString(c.rfc1123) + " GMT"; case "s": return this.toString(c.sortableDateTime); case "t": return this.toString(c.shortTime); case "T": return this.toString(c.longTime); case "u": y = this.clone().addMinutes(this.getTimezoneOffset()); return y.toString(c.universalSortableDateTime); case "y": return this.toString(c.yearMonth); default: return false; } }; var parseFormatStringsClosure = function (context) { return function (m) { if (m.charAt(0) === "\\") { return m.replace("\\", ""); } switch (m) { case "hh": return p(context.getHours() < 13 ? (context.getHours() === 0 ? 12 : context.getHours()) : (context.getHours() - 12)); case "h": return context.getHours() < 13 ? (context.getHours() === 0 ? 12 : context.getHours()) : (context.getHours() - 12); case "HH": return p(context.getHours()); case "H": return context.getHours(); case "mm": return p(context.getMinutes()); case "m": return context.getMinutes(); case "ss": return p(context.getSeconds()); case "s": return context.getSeconds(); case "yyyy": return p(context.getFullYear(), 4); case "yy": return p(context.getFullYear()); case "y": return context.getFullYear(); case "E": case "dddd": return Date.CultureInfo.dayNames[context.getDay()]; case "ddd": return Date.CultureInfo.abbreviatedDayNames[context.getDay()]; case "dd": return p(context.getDate()); case "d": return context.getDate(); case "MMMM": return Date.CultureInfo.monthNames[context.getMonth()]; case "MMM": return Date.CultureInfo.abbreviatedMonthNames[context.getMonth()]; case "MM": return p((context.getMonth() + 1)); case "M": return context.getMonth() + 1; case "t": return context.getHours() < 12 ? Date.CultureInfo.amDesignator.substring(0, 1) : Date.CultureInfo.pmDesignator.substring(0, 1); case "tt": return context.getHours() < 12 ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator; case "S": return ord(context.getDate()); case "W": return context.getWeek(); case "WW": return context.getISOWeek(); case "Q": return "Q" + context.getQuarter(); case "q": return String(context.getQuarter()); case "z": return context.getTimezone(); case "Z": case "X": return Date.getTimezoneOffset(context.getTimezone()); case "ZZ": // Timezone offset in seconds return context.getTimezoneOffset() * -60; case "u": return context.getDay(); case "L": return ($D.isLeapYear(context.getFullYear())) ? 1 : 0; case "B": // Swatch Internet Time (.beats) return "@"+((context.getUTCSeconds() + (context.getUTCMinutes()*60) + ((context.getUTCHours()+1)*3600))/86.4); default: return m; } }; }; $P.toString = function (format, ignoreStandards) { // Standard Date and Time Format Strings. Formats pulled from CultureInfo file and // may vary by culture. if (!ignoreStandards && format && format.length === 1) { output = parseStandardFormats.call(this, format); if (output) { return output; } } var parseFormatStrings = parseFormatStringsClosure(this); return format ? format.replace(/((\\)?(dd?d?d?|MM?M?M?|yy?y?y?|hh?|HH?|mm?|ss?|tt?|S|q|Q|WW?W?W?)(?![^\[]*\]))/g, parseFormatStrings).replace(/\[|\]/g, "") : this._toString(); }; }()); /************************************************************* * SugarPak - Domain Specific Language - Syntactical Sugar * *************************************************************/ (function () { var $D = Date, $P = $D.prototype, $N = Number.prototype; // private $P._orient = +1; // private $P._nth = null; // private $P._is = false; // private $P._same = false; // private $P._isSecond = false; // private $N._dateElement = "days"; /** * Moves the date to the next instance of a date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.today().next().friday();
	Date.today().next().fri();
	Date.today().next().march();
	Date.today().next().mar();
	Date.today().next().week();
	
* * @return {Date} date */ $P.next = function () { this._move = true; this._orient = +1; return this; }; /** * Creates a new Date (Date.today()) and moves the date to the next instance of the date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.next().friday();
	Date.next().fri();
	Date.next().march();
	Date.next().mar();
	Date.next().week();
	
* * @return {Date} date */ $D.next = function () { return $D.today().next(); }; /** * Moves the date to the previous instance of a date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.today().last().friday();
	Date.today().last().fri();
	Date.today().last().march();
	Date.today().last().mar();
	Date.today().last().week();
	
* * @return {Date} date */ $P.last = $P.prev = $P.previous = function () { this._move = true; this._orient = -1; return this; }; /** * Creates a new Date (Date.today()) and moves the date to the previous instance of the date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.last().friday();
	Date.last().fri();
	Date.previous().march();
	Date.prev().mar();
	Date.last().week();
	
* * @return {Date} date */ $D.last = $D.prev = $D.previous = function () { return $D.today().last(); }; /** * Performs a equality check when followed by either a month name, day name or .weekday() function. * Example

	Date.today().is().friday(); // true|false
	Date.today().is().fri();
	Date.today().is().march();
	Date.today().is().mar();
	
* * @return {Boolean} true|false */ $P.is = function () { this._is = true; return this; }; /** * Determines if two date objects occur on/in exactly the same instance of the subsequent date part function. * The function .same() must be followed by a date part function (example: .day(), .month(), .year(), etc). * * An optional Date can be passed in the date part function. If now date is passed as a parameter, 'Now' is used. * * The following example demonstrates how to determine if two dates fall on the exact same day. * * Example

	var d1 = Date.today(); // today at 00:00
	var d2 = new Date();   // exactly now.

	// Do they occur on the same day?
	d1.same().day(d2); // true
	
	// Do they occur on the same hour?
	d1.same().hour(d2); // false, unless d2 hour is '00' (midnight).
	
	// What if it's the same day, but one year apart?
	var nextYear = Date.today().add(1).year();

	d1.same().day(nextYear); // false, because the dates must occur on the exact same day. 
	
* * Scenario: Determine if a given date occurs during some week period 2 months from now. * * Example

	var future = Date.today().add(2).months();
	return someDate.same().week(future); // true|false;
	
* * @return {Boolean} true|false */ $P.same = function () { this._same = true; this._isSecond = false; return this; }; /** * Determines if the current date/time occurs during Today. Must be preceded by the .is() function. * Example

	someDate.is().today();    // true|false
	new Date().is().today();  // true
	Date.today().is().today();// true
	Date.today().add(-1).day().is().today(); // false
	
* * @return {Boolean} true|false */ $P.today = function () { return this.same().day(); }; /** * Determines if the current date is a weekday. This function must be preceded by the .is() function. * Example

	Date.today().is().weekday(); // true|false
	
* * @return {Boolean} true|false */ $P.weekday = function () { if (this._nth) { return df("Weekday").call(this); } if (this._move) { return this.addWeekdays(this._orient); } if (this._is) { this._is = false; return (!this.is().sat() && !this.is().sun()); } return false; }; /** * Determines if the current date is on the weekend. This function must be preceded by the .is() function. * Example

	Date.today().is().weekend(); // true|false
	
* * @return {Boolean} true|false */ $P.weekend = function () { if (this._is) { this._is = false; return (this.is().sat() || this.is().sun()); } return false; }; /** * Sets the Time of the current Date instance. A string "6:15 pm" or config object {hour:18, minute:15} are accepted. * Example

	// Set time to 6:15pm with a String
	Date.today().at("6:15pm");

	// Set time to 6:15pm with a config object
	Date.today().at({hour:18, minute:15});
	
* * @return {Date} date */ $P.at = function (time) { return (typeof time === "string") ? $D.parse(this.toString("d") + " " + time) : this.set(time); }; /** * Creates a new Date() and adds this (Number) to the date based on the preceding date element function (eg. second|minute|hour|day|month|year). * Example

	// Undeclared Numbers must be wrapped with parentheses. Requirment of JavaScript.
	(3).days().fromNow();
	(6).months().fromNow();

	// Declared Number variables do not require parentheses. 
	var n = 6;
	n.months().fromNow();
	
* * @return {Date} A new Date instance */ $N.fromNow = $N.after = function (date) { var c = {}; c[this._dateElement] = this; return ((!date) ? new Date() : date.clone()).add(c); }; /** * Creates a new Date() and subtract this (Number) from the date based on the preceding date element function (eg. second|minute|hour|day|month|year). * Example

	// Undeclared Numbers must be wrapped with parentheses. Requirment of JavaScript.
	(3).days().ago();
	(6).months().ago();

	// Declared Number variables do not require parentheses. 
	var n = 6;
	n.months().ago();
	
* * @return {Date} A new Date instance */ $N.ago = $N.before = function (date) { var c = {}, s = (this._dateElement[this._dateElement.length-1] !== "s") ? this._dateElement + "s" : this._dateElement; c[s] = this * -1; return ((!date) ? new Date() : date.clone()).add(c); }; // Do NOT modify the following string tokens. These tokens are used to build dynamic functions. // All culture-specific strings can be found in the CultureInfo files. var dx = ("sunday monday tuesday wednesday thursday friday saturday").split(/\s/), mx = ("january february march april may june july august september october november december").split(/\s/), px = ("Millisecond Second Minute Hour Day Week Month Year Quarter Weekday").split(/\s/), pxf = ("Milliseconds Seconds Minutes Hours Date Week Month FullYear Quarter").split(/\s/), nth = ("final first second third fourth fifth").split(/\s/), de; /** * Returns an object literal of all the date parts. * Example

	var o = new Date().toObject();
	
	// { year: 2008, month: 4, week: 20, day: 13, hour: 18, minute: 9, second: 32, millisecond: 812 }
	
	// The object properties can be referenced directly from the object.
	
	alert(o.day);  // alerts "13"
	alert(o.year); // alerts "2008"
	
* * @return {Date} An object literal representing the original date object. */ $P.toObject = function () { var o = {}; for (var i = 0; i < px.length; i++) { if (this["get" + pxf[i]]) { o[px[i].toLowerCase()] = this["get" + pxf[i]](); } } return o; }; /** * Returns a date created from an object literal. Ignores the .week property if set in the config. * Example

	var o = new Date().toObject();
	
	return Date.fromObject(o); // will return the same date. 

	var o2 = {month: 1, day: 20, hour: 18}; // birthday party!
	Date.fromObject(o2);
	
* * @return {Date} An object literal representing the original date object. */ $D.fromObject = function(config) { config.week = null; return Date.today().set(config); }; // Create day name functions and abbreviated day name functions (eg. monday(), friday(), fri()). var df = function (n) { return function () { if (this._is) { this._is = false; return this.getDay() === n; } if (this._move) { this._move = null; } if (this._nth !== null) { // If the .second() function was called earlier, remove the _orient // from the date, and then continue. // This is required because 'second' can be used in two different context. // // Example // // Date.today().add(1).second(); // Date.march().second().monday(); // // Things get crazy with the following... // Date.march().add(1).second().second().monday(); // but it works!! // if (this._isSecond) { this.addSeconds(this._orient * -1); } // make sure we reset _isSecond this._isSecond = false; var ntemp = this._nth; this._nth = null; var temp = this.clone().moveToLastDayOfMonth(); this.moveToNthOccurrence(n, ntemp); if (this > temp) { throw new RangeError($D.getDayName(n) + " does not occur " + ntemp + " times in the month of " + $D.getMonthName(temp.getMonth()) + " " + temp.getFullYear() + "."); } return this; } return this.moveToDayOfWeek(n, this._orient); }; }; var sdf = function (n) { return function () { var t = $D.today(), shift = n - t.getDay(); if (n === 0 && Date.CultureInfo.firstDayOfWeek === 1 && t.getDay() !== 0) { shift = shift + 7; } return t.addDays(shift); }; }; // Create month name functions and abbreviated month name functions (eg. january(), march(), mar()). var month_instance_functions = function (n) { return function () { if (this._is) { this._is = false; return this.getMonth() === n; } return this.moveToMonth(n, this._orient); }; }; var month_static_functions = function (n) { return function () { return $D.today().set({ month: n, day: 1 }); }; }; var processTerms = function (names, staticFunc, instanceFunc) { for (var i = 0; i < names.length; i++) { // Create constant static Name variables. $D[names[i].toUpperCase()] = $D[names[i].toUpperCase().substring(0, 3)] = i; // Create Name functions. $D[names[i]] = $D[names[i].substring(0, 3)] = staticFunc(i); // Create Name instance functions. $P[names[i]] = $P[names[i].substring(0, 3)] = instanceFunc(i); } }; processTerms(dx, sdf, df); processTerms(mx, month_static_functions, month_instance_functions); // Create date element functions and plural date element functions used with Date (eg. day(), days(), months()). var ef = function (j) { return function () { // if the .second() function was called earlier, the _orient // has alread been added. Just return this and reset _isSecond. if (this._isSecond) { this._isSecond = false; return this; } if (this._same) { this._same = this._is = false; var o1 = this.toObject(), o2 = (arguments[0] || new Date()).toObject(), v = "", k = j.toLowerCase(); // the substr trick with -1 doesn't work in IE8 or less k = (k[k.length-1] === "s") ? k.substring(0,k.length-1) : k; for (var m = (px.length - 1); m > -1; m--) { v = px[m].toLowerCase(); if (o1[v] !== o2[v]) { return false; } if (k === v) { break; } } return true; } if (j.substring(j.length - 1) !== "s") { j += "s"; } if (this._move) { this._move = null; } return this["add" + j](this._orient); }; }; var nf = function (n) { return function () { this._dateElement = n; return this; }; }; for (var k = 0; k < px.length; k++) { de = px[k].toLowerCase(); if(de !== "weekday") { // Create date element functions and plural date element functions used with Date (eg. day(), days(), months()). $P[de] = $P[de + "s"] = ef(px[k]); // Create date element functions and plural date element functions used with Number (eg. day(), days(), months()). $N[de] = $N[de + "s"] = nf(de + "s"); } } $P._ss = ef("Second"); var nthfn = function (n) { return function (dayOfWeek) { if (this._same) { return this._ss(arguments[0]); } if (dayOfWeek || dayOfWeek === 0) { return this.moveToNthOccurrence(dayOfWeek, n); } this._nth = n; // if the operator is 'second' add the _orient, then deal with it later... if (n === 2 && (dayOfWeek === undefined || dayOfWeek === null)) { this._isSecond = true; return this.addSeconds(this._orient); } return this; }; }; for (var l = 0; l < nth.length; l++) { $P[nth[l]] = (l === 0) ? nthfn(-1) : nthfn(l); } }()); (function () { "use strict"; Date.Parsing = { Exception: function (s) { this.message = "Parse error at '" + s.substring(0, 10) + " ...'"; } }; var $P = Date.Parsing; var dayOffsets = { standard: [0,31,59,90,120,151,181,212,243,273,304,334], leap: [0,31,60,91,121,152,182,213,244,274,305,335] }; $P.isLeapYear = function(year) { return ((year % 4 === 0) && (year % 100 !== 0)) || (year % 400 === 0); }; var utils = { multiReplace : function (str, hash ) { var key; for (key in hash) { if (Object.prototype.hasOwnProperty.call(hash, key)) { var regex; if (typeof hash[key] === "function") { } else { regex = (hash[key] instanceof RegExp) ? hash[key] : new RegExp(hash[key], "g"); } str = str.replace(regex, key); } } return str; }, getDayOfYearFromWeek : function (obj) { var d, jan4, offset; obj.weekDay = (!obj.weekDay && obj.weekDay !== 0) ? 1 : obj.weekDay; d = new Date(obj.year, 0, 4); jan4 = d.getDay() === 0 ? 7 : d.getDay(); // JS is 0 indexed on Sunday. offset = jan4+3; obj.dayOfYear = ((obj.week * 7) + (obj.weekDay === 0 ? 7 : obj.weekDay))-offset; return obj; }, getDayOfYear : function (obj, dayOffset) { if (!obj.dayOfYear) { obj = utils.getDayOfYearFromWeek(obj); } for (var i=0;i <= dayOffset.length;i++) { if (obj.dayOfYear < dayOffset[i] || i === dayOffset.length) { obj.day = obj.day ? obj.day : (obj.dayOfYear - dayOffset[i-1]); break; } else { obj.month = i; } } return obj; }, adjustForTimeZone : function (obj, date) { var offset; if (obj.zone.toUpperCase() === "Z" || (obj.zone_hours === 0 && obj.zone_minutes === 0)) { // it's UTC/GML so work out the current timeszone offset offset = -date.getTimezoneOffset(); } else { offset = (obj.zone_hours*60) + (obj.zone_minutes || 0); if (obj.zone_sign === "+") { offset *= -1; } offset -= date.getTimezoneOffset(); } date.setMinutes(date.getMinutes()+offset); return date; }, setDefaults : function (obj) { obj.year = obj.year || Date.today().getFullYear(); obj.hours = obj.hours || 0; obj.minutes = obj.minutes || 0; obj.seconds = obj.seconds || 0; obj.milliseconds = obj.milliseconds || 0; if (!(!obj.month && (obj.week || obj.dayOfYear))) { // if we have a month, or if we don't but don't have the day calculation data obj.month = obj.month || 0; obj.day = obj.day || 1; } return obj; }, dataNum: function (data, mod, explict, postProcess) { var dataNum = data*1; if (mod) { if (postProcess) { return data ? mod(data)*1 : data; } else { return data ? mod(dataNum) : data; } } else if (!explict){ return data ? dataNum : data; } else { return (data && typeof data !== "undefined") ? dataNum : data; } }, timeDataProcess: function (obj) { var timeObj = {}; for (var x in obj.data) { if (obj.data.hasOwnProperty(x)) { timeObj[x] = obj.ignore[x] ? obj.data[x] : utils.dataNum(obj.data[x], obj.mods[x], obj.explict[x], obj.postProcess[x]); } } if (obj.data.secmins) { obj.data.secmins = obj.data.secmins.replace(",", ".") * 60; if (!timeObj.minutes) { timeObj.minutes = obj.data.secmins; } else if (!timeObj.seconds) { timeObj.seconds = obj.data.secmins; } delete obj.secmins; } return timeObj; }, buildTimeObjectFromData: function (data) { var time = utils.timeDataProcess({ data: { year : data[1], month : data[5], day : data[7], week : data[8], dayOfYear : data[10], hours : data[15], zone_hours : data[23], zone_minutes : data[24], zone : data[21], zone_sign : data[22], weekDay : data[9], minutes: data[16], seconds: data[19], milliseconds: data[20], secmins: data[18] }, mods: { month: function(data) { return data-1; }, weekDay: function (data) { data = Math.abs(data); return (data === 7 ? 0 : data); }, minutes: function (data) { return data.replace(":",""); }, seconds: function (data) { return Math.floor( (data.replace(":","").replace(",","."))*1 ); }, milliseconds: function (data) { return (data.replace(",",".")*1000); } }, postProcess: { minutes: true, seconds: true, milliseconds: true }, explict: { zone_hours: true, zone_minutes: true }, ignore: { zone: true, zone_sign: true, secmins: true } }); return time; }, addToHash: function (hash, keys, data) { keys = keys; data = data; var len = keys.length; for (var i = 0; i < len; i++) { hash[keys[i]] = data[i]; } return hash; }, combineRegex: function (r1, r2) { return new RegExp("(("+r1.source+")\\s("+r2.source+"))"); }, getDateNthString: function(add, last, inc){ if (add) { return Date.today().addDays(inc).toString("d"); } else if (last) { return Date.today().last()[inc]().toString("d"); } }, buildRegexData: function (array) { var arr = []; var len = array.length; for (var i=0; i < len; i++) { if (Object.prototype.toString.call(array[i]) === '[object Array]') { // oldIE compat version of Array.isArray arr.push(this.combineRegex(array[i][0], array[i][1])); } else { arr.push(array[i]); } } return arr; } }; $P.processTimeObject = function (obj) { var date, dayOffset; utils.setDefaults(obj); dayOffset = ($P.isLeapYear(obj.year)) ? dayOffsets.leap : dayOffsets.standard; if (!obj.month && (obj.week || obj.dayOfYear)) { utils.getDayOfYear(obj, dayOffset); } else { obj.dayOfYear = dayOffset[obj.month] + obj.day; } date = new Date(obj.year, obj.month, obj.day, obj.hours, obj.minutes, obj.seconds, obj.milliseconds); if (obj.zone) { utils.adjustForTimeZone(obj, date); // adjust (and calculate) for timezone } return date; }; $P.ISO = { regex : /^([\+-]?\d{4}(?!\d{2}\b))((-?)((0[1-9]|1[0-2])(\3([12]\d|0[1-9]|3[01]))?|W([0-4]\d|5[0-3])(-?[1-7])?|(00[1-9]|0[1-9]\d|[12]\d{2}|3([0-5]\d|6[1-6])))([T\s]((([01]\d|2[0-4])((:?)[0-5]\d)?|24\:?00)([\.,]\d+(?!:))?)?(\17[0-5]\d([\.,]\d+)?)?\s?([zZ]|([\+-])([01]\d|2[0-3]):?([0-5]\d)?)?)?)?$/, parse : function (s) { var time, data = s.match(this.regex); if (!data || !data.length) { return null; } time = utils.buildTimeObjectFromData(data); if (!time.year || (!time.year && (!time.month && !time.day) && (!time.week && !time.dayOfYear)) ) { return null; } return $P.processTimeObject(time); } }; $P.Numeric = { isNumeric: function (e){return!isNaN(parseFloat(e))&&isFinite(e);}, regex: /\b([0-1]?[0-9])([0-3]?[0-9])([0-2]?[0-9]?[0-9][0-9])\b/i, parse: function (s) { var data, i, time = {}, order = Date.CultureInfo.dateElementOrder.split(""); if (!(this.isNumeric(s)) || // if it's non-numeric OR (s[0] === "+" && s[0] === "-")) { // It's an arithmatic string (eg +/-1000) return null; } if (s.length < 5 && s.indexOf(".") < 0 && s.indexOf("/") < 0) { // assume it's just a year. time.year = s; return $P.processTimeObject(time); } data = s.match(this.regex); if (!data || !data.length) { return null; } for (i=0; i < order.length; i++) { switch(order[i]) { case "d": time.day = data[i+1]; break; case "m": time.month = (data[i+1]-1); break; case "y": time.year = data[i+1]; break; } } return $P.processTimeObject(time); } }; $P.Normalizer = { regexData: function () { var $R = Date.CultureInfo.regexPatterns; return utils.buildRegexData([ $R.tomorrow, $R.yesterday, [$R.past, $R.mon], [$R.past, $R.tue], [$R.past, $R.wed], [$R.past, $R.thu], [$R.past, $R.fri], [$R.past, $R.sat], [$R.past, $R.sun] ]); }, basicReplaceHash : function() { var $R = Date.CultureInfo.regexPatterns; return { "January": $R.jan.source, "February": $R.feb, "March": $R.mar, "April": $R.apr, "May": $R.may, "June": $R.jun, "July": $R.jul, "August": $R.aug, "September": $R.sep, "October": $R.oct, "November": $R.nov, "December": $R.dec, "": /\bat\b/gi, " ": /\s{2,}/, "am": $R.inTheMorning, "9am": $R.thisMorning, "pm": $R.inTheEvening, "7pm":$R.thisEvening }; }, keys : function(){ return [ utils.getDateNthString(true, false, 1), // tomorrow utils.getDateNthString(true, false, -1), // yesterday utils.getDateNthString(false, true, "monday"), //last mon utils.getDateNthString(false, true, "tuesday"), //last tues utils.getDateNthString(false, true, "wednesday"), //last wed utils.getDateNthString(false, true, "thursday"), //last thurs utils.getDateNthString(false, true, "friday"), //last fri utils.getDateNthString(false, true, "saturday"), //last sat utils.getDateNthString(false, true, "sunday") //last sun ]; }, buildRegexFunctions: function () { var $R = Date.CultureInfo.regexPatterns; var __ = Date.i18n.__; var tomorrowRE = new RegExp("(\\b\\d\\d?("+__("AM")+"|"+__("PM")+")? )("+$R.tomorrow.source.slice(1)+")", "i"); // adapted tomorrow regex for AM PM relative dates var todayRE = new RegExp($R.today.source + "(?!\\s*([+-]))\\b"); // today, but excludes the math operators (eg "today + 2h") this.replaceFuncs = [ [todayRE, function (full) { return (full.length > 1) ? Date.today().toString("d") : full; }], [tomorrowRE, function(full, m1) { var t = Date.today().addDays(1).toString("d"); return (t + " " + m1); }], [$R.amThisMorning, function(str, am){return am;}], [$R.pmThisEvening, function(str, pm){return pm;}] ]; }, buildReplaceData: function () { this.buildRegexFunctions(); this.replaceHash = utils.addToHash(this.basicReplaceHash(), this.keys(), this.regexData()); }, stringReplaceFuncs: function (s) { for (var i=0; i < this.replaceFuncs.length; i++) { s = s.replace(this.replaceFuncs[i][0], this.replaceFuncs[i][1]); } return s; }, parse: function (s) { s = this.stringReplaceFuncs(s); s = utils.multiReplace(s, this.replaceHash); try { var n = s.split(/([\s\-\.\,\/\x27]+)/); if (n.length === 3 && $P.Numeric.isNumeric(n[0]) && $P.Numeric.isNumeric(n[2]) && (n[2].length >= 4)) { // ok, so we're dealing with x/year. But that's not a full date. // This fixes wonky dateElementOrder parsing when set to dmy order. if (Date.CultureInfo.dateElementOrder[0] === "d") { s = "1/" + n[0] + "/" + n[2]; // set to 1st of month and normalize the seperator } } } catch (e) {} return s; } }; $P.Normalizer.buildReplaceData(); }()); (function () { var $P = Date.Parsing; var _ = $P.Operators = { // // Tokenizers // rtoken: function (r) { // regex token return function (s) { var mx = s.match(r); if (mx) { return ([ mx[0], s.substring(mx[0].length) ]); } else { throw new $P.Exception(s); } }; }, token: function () { // whitespace-eating token return function (s) { return _.rtoken(new RegExp("^\\s*" + s + "\\s*"))(s); }; }, stoken: function (s) { // string token return _.rtoken(new RegExp("^" + s)); }, // Atomic Operators until: function (p) { return function (s) { var qx = [], rx = null; while (s.length) { try { rx = p.call(this, s); } catch (e) { qx.push(rx[0]); s = rx[1]; continue; } break; } return [ qx, s ]; }; }, many: function (p) { return function (s) { var rx = [], r = null; while (s.length) { try { r = p.call(this, s); } catch (e) { return [ rx, s ]; } rx.push(r[0]); s = r[1]; } return [ rx, s ]; }; }, // generator operators -- see below optional: function (p) { return function (s) { var r = null; try { r = p.call(this, s); } catch (e) { return [ null, s ]; } return [ r[0], r[1] ]; }; }, not: function (p) { return function (s) { try { p.call(this, s); } catch (e) { return [null, s]; } throw new $P.Exception(s); }; }, ignore: function (p) { return p ? function (s) { var r = null; r = p.call(this, s); return [null, r[1]]; } : null; }, product: function () { var px = arguments[0], qx = Array.prototype.slice.call(arguments, 1), rx = []; for (var i = 0 ; i < px.length ; i++) { rx.push(_.each(px[i], qx)); } return rx; }, cache: function (rule) { var cache = {}, cache_length = 0, cache_keys = [], CACHE_MAX = Date.Config.CACHE_MAX || 100000, r = null; var cacheCheck = function () { if (cache_length === CACHE_MAX) { // kill several keys, don't want to have to do this all the time... for (var i=0; i < 10; i++) { var key = cache_keys.shift(); if (key) { delete cache[key]; cache_length--; } } } }; return function (s) { cacheCheck(); try { r = cache[s] = (cache[s] || rule.call(this, s)); } catch (e) { r = cache[s] = e; } cache_length++; cache_keys.push(s); if (r instanceof $P.Exception) { throw r; } else { return r; } }; }, // vector operators -- see below any: function () { var px = arguments; return function (s) { var r = null; for (var i = 0; i < px.length; i++) { if (px[i] == null) { continue; } try { r = (px[i].call(this, s)); } catch (e) { r = null; } if (r) { return r; } } throw new $P.Exception(s); }; }, each: function () { var px = arguments; return function (s) { var rx = [], r = null; for (var i = 0; i < px.length ; i++) { if (px[i] == null) { continue; } try { r = (px[i].call(this, s)); } catch (e) { throw new $P.Exception(s); } rx.push(r[0]); s = r[1]; } return [ rx, s]; }; }, all: function () { var px = arguments, _ = _; return _.each(_.optional(px)); }, // delimited operators sequence: function (px, d, c) { d = d || _.rtoken(/^\s*/); c = c || null; if (px.length === 1) { return px[0]; } return function (s) { var r = null, q = null; var rx = []; for (var i = 0; i < px.length ; i++) { try { r = px[i].call(this, s); } catch (e) { break; } rx.push(r[0]); try { q = d.call(this, r[1]); } catch (ex) { q = null; break; } s = q[1]; } if (!r) { throw new $P.Exception(s); } if (q) { throw new $P.Exception(q[1]); } if (c) { try { r = c.call(this, r[1]); } catch (ey) { throw new $P.Exception(r[1]); } } return [ rx, (r?r[1]:s) ]; }; }, // // Composite Operators // between: function (d1, p, d2) { d2 = d2 || d1; var _fn = _.each(_.ignore(d1), p, _.ignore(d2)); return function (s) { var rx = _fn.call(this, s); return [[rx[0][0], r[0][2]], rx[1]]; }; }, list: function (p, d, c) { d = d || _.rtoken(/^\s*/); c = c || null; return (p instanceof Array ? _.each(_.product(p.slice(0, -1), _.ignore(d)), p.slice(-1), _.ignore(c)) : _.each(_.many(_.each(p, _.ignore(d))), px, _.ignore(c))); }, set: function (px, d, c) { d = d || _.rtoken(/^\s*/); c = c || null; return function (s) { // r is the current match, best the current 'best' match // which means it parsed the most amount of input var r = null, p = null, q = null, rx = null, best = [[], s], last = false; // go through the rules in the given set for (var i = 0; i < px.length ; i++) { // last is a flag indicating whether this must be the last element // if there is only 1 element, then it MUST be the last one q = null; p = null; r = null; last = (px.length === 1); // first, we try simply to match the current pattern // if not, try the next pattern try { r = px[i].call(this, s); } catch (e) { continue; } // since we are matching against a set of elements, the first // thing to do is to add r[0] to matched elements rx = [[r[0]], r[1]]; // if we matched and there is still input to parse and // we don't already know this is the last element, // we're going to next check for the delimiter ... // if there's none, or if there's no input left to parse // than this must be the last element after all ... if (r[1].length > 0 && ! last) { try { q = d.call(this, r[1]); } catch (ex) { last = true; } } else { last = true; } // if we parsed the delimiter and now there's no more input, // that means we shouldn't have parsed the delimiter at all // so don't update r and mark this as the last element ... if (!last && q[1].length === 0) { last = true; } // so, if this isn't the last element, we're going to see if // we can get any more matches from the remaining (unmatched) // elements ... if (!last) { // build a list of the remaining rules we can match against, // i.e., all but the one we just matched against var qx = []; for (var j = 0; j < px.length ; j++) { if (i !== j) { qx.push(px[j]); } } // now invoke recursively set with the remaining input // note that we don't include the closing delimiter ... // we'll check for that ourselves at the end p = _.set(qx, d).call(this, q[1]); // if we got a non-empty set as a result ... // (otw rx already contains everything we want to match) if (p[0].length > 0) { // update current result, which is stored in rx ... // basically, pick up the remaining text from p[1] // and concat the result from p[0] so that we don't // get endless nesting ... rx[0] = rx[0].concat(p[0]); rx[1] = p[1]; } } // at this point, rx either contains the last matched element // or the entire matched set that starts with this element. // now we just check to see if this variation is better than // our best so far, in terms of how much of the input is parsed if (rx[1].length < best[1].length) { best = rx; } // if we've parsed all the input, then we're finished if (best[1].length === 0) { break; } } // so now we've either gone through all the patterns trying them // as the initial match; or we found one that parsed the entire // input string ... // if best has no matches, just return empty set ... if (best[0].length === 0) { return best; } // if a closing delimiter is provided, then we have to check it also if (c) { // we try this even if there is no remaining input because the pattern // may well be optional or match empty input ... try { q = c.call(this, best[1]); } catch (ey) { throw new $P.Exception(best[1]); } // it parsed ... be sure to update the best match remaining input best[1] = q[1]; } // if we're here, either there was no closing delimiter or we parsed it // so now we have the best match; just return it! return best; }; }, forward: function (gr, fname) { return function (s) { return gr[fname].call(this, s); }; }, // // Translation Operators // replace: function (rule, repl) { return function (s) { var r = rule.call(this, s); return [repl, r[1]]; }; }, process: function (rule, fn) { return function (s) { var r = rule.call(this, s); return [fn.call(this, r[0]), r[1]]; }; }, min: function (min, rule) { return function (s) { var rx = rule.call(this, s); if (rx[0].length < min) { throw new $P.Exception(s); } return rx; }; } }; // Generator Operators And Vector Operators // Generators are operators that have a signature of F(R) => R, // taking a given rule and returning another rule, such as // ignore, which parses a given rule and throws away the result. // Vector operators are those that have a signature of F(R1,R2,...) => R, // take a list of rules and returning a new rule, such as each. // Generator operators are converted (via the following _generator // function) into functions that can also take a list or array of rules // and return an array of new rules as though the function had been // called on each rule in turn (which is what actually happens). // This allows generators to be used with vector operators more easily. // Example: // each(ignore(foo, bar)) instead of each(ignore(foo), ignore(bar)) // This also turns generators into vector operators, which allows // constructs like: // not(cache(foo, bar)) var _generator = function (op) { function gen() { var args = null, rx = [], px, i; if (arguments.length > 1) { args = Array.prototype.slice.call(arguments); } else if (arguments[0] instanceof Array) { args = arguments[0]; } if (args) { px = args.shift(); if (px.length > 0) { args.unshift(px[i]); rx.push(op.apply(null, args)); args.shift(); return rx; } } else { return op.apply(null, arguments); } } return gen; }; var gx = "optional not ignore cache".split(/\s/); for (var i = 0 ; i < gx.length ; i++) { _[gx[i]] = _generator(_[gx[i]]); } var _vector = function (op) { return function () { if (arguments[0] instanceof Array) { return op.apply(null, arguments[0]); } else { return op.apply(null, arguments); } }; }; var vx = "each any all".split(/\s/); for (var j = 0 ; j < vx.length ; j++) { _[vx[j]] = _vector(_[vx[j]]); } }()); (function () { var $D = Date; var flattenAndCompact = function (ax) { var rx = []; for (var i = 0; i < ax.length; i++) { if (ax[i] instanceof Array) { rx = rx.concat(flattenAndCompact(ax[i])); } else { if (ax[i]) { rx.push(ax[i]); } } } return rx; }; var parseMeridian = function () { if (this.meridian && (this.hour || this.hour === 0)) { if (this.meridian === "a" && this.hour > 11 && Date.Config.strict24hr){ throw "Invalid hour and meridian combination"; } else if (this.meridian === "p" && this.hour < 12 && Date.Config.strict24hr){ throw "Invalid hour and meridian combination"; } else if (this.meridian === "p" && this.hour < 12) { this.hour = this.hour + 12; } else if (this.meridian === "a" && this.hour === 12) { this.hour = 0; } } }; var setDefaults = function () { var now = new Date(); if ((this.hour || this.minute) && (!this.month && !this.year && !this.day)) { this.day = now.getDate(); } if (!this.year) { this.year = now.getFullYear(); } if (!this.month && this.month !== 0) { this.month = now.getMonth(); } if (!this.day) { this.day = 1; } if (!this.hour) { this.hour = 0; } if (!this.minute) { this.minute = 0; } if (!this.second) { this.second = 0; } if (!this.millisecond) { this.millisecond = 0; } }; var finishUtils = { getToday: function () { if (this.now || "hour minute second".indexOf(this.unit) !== -1) { return new Date(); } else { return $D.today(); } }, setDaysFromWeekday: function (today, orient){ var gap; orient = orient || 1; this.unit = "day"; gap = ($D.getDayNumberFromName(this.weekday) - today.getDay()); this.days = gap ? ((gap + (orient * 7)) % 7) : (orient * 7); return this; }, setMonthsFromMonth: function (today, orient) { var gap; orient = orient || 1; this.unit = "month"; gap = (this.month - today.getMonth()); this.months = gap ? ((gap + (orient * 12)) % 12) : (orient * 12); this.month = null; return this; }, setDMYFromWeekday: function () { var d = Date[this.weekday](); this.day = d.getDate(); if (!this.month) { this.month = d.getMonth(); } this.year = d.getFullYear(); return this; }, setUnitValue: function (orient) { if (!this.value && this.operator && this.operator !== null && this[this.unit + "s"] && this[this.unit + "s"] !== null) { this[this.unit + "s"] = this[this.unit + "s"] + ((this.operator === "add") ? 1 : -1) + (this.value||0) * orient; } else if (this[this.unit + "s"] == null || this.operator != null) { if (!this.value) { this.value = 1; } this[this.unit + "s"] = this.value * orient; } }, generateDateFromWeeks: function () { var weekday = (this.weekday !== undefined) ? this.weekday : "today"; var d = Date[weekday]().addWeeks(this.weeks); if (this.now) { d.setTimeToNow(); } return d; } }; $D.Translator = { hour: function (s) { return function () { this.hour = Number(s); }; }, minute: function (s) { return function () { this.minute = Number(s); }; }, second: function (s) { return function () { this.second = Number(s); }; }, /* for ss.s format */ secondAndMillisecond: function (s) { return function () { var mx = s.match(/^([0-5][0-9])\.([0-9]{1,3})/); this.second = Number(mx[1]); this.millisecond = Number(mx[2]); }; }, meridian: function (s) { return function () { this.meridian = s.slice(0, 1).toLowerCase(); }; }, timezone: function (s) { return function () { var n = s.replace(/[^\d\+\-]/g, ""); if (n.length) { this.timezoneOffset = Number(n); } else { this.timezone = s.toLowerCase(); } }; }, day: function (x) { var s = x[0]; return function () { this.day = Number(s.match(/\d+/)[0]); if (this.day < 1) { throw "invalid day"; } }; }, month: function (s) { return function () { this.month = (s.length === 3) ? "jan feb mar apr may jun jul aug sep oct nov dec".indexOf(s)/4 : Number(s) - 1; if (this.month < 0) { throw "invalid month"; } }; }, year: function (s) { return function () { var n = Number(s); this.year = ((s.length > 2) ? n : (n + (((n + 2000) < Date.CultureInfo.twoDigitYearMax) ? 2000 : 1900))); }; }, rday: function (s) { return function () { switch (s) { case "yesterday": this.days = -1; break; case "tomorrow": this.days = 1; break; case "today": this.days = 0; break; case "now": this.days = 0; this.now = true; break; } }; }, finishExact: function (x) { var d; x = (x instanceof Array) ? x : [x]; for (var i = 0 ; i < x.length ; i++) { if (x[i]) { x[i].call(this); } } setDefaults.call(this); parseMeridian.call(this); if (this.day > $D.getDaysInMonth(this.year, this.month)) { throw new RangeError(this.day + " is not a valid value for days."); } d = new Date(this.year, this.month, this.day, this.hour, this.minute, this.second, this.millisecond); if (this.year < 100) { d.setFullYear(this.year); // means years less that 100 are process correctly. JS will parse it otherwise as 1900-1999. } if (this.timezone) { d.set({ timezone: this.timezone }); } else if (this.timezoneOffset) { d.set({ timezoneOffset: this.timezoneOffset }); } return d; }, finish: function (x) { var today, expression, orient, temp; x = (x instanceof Array) ? flattenAndCompact(x) : [ x ]; if (x.length === 0) { return null; } for (var i = 0 ; i < x.length ; i++) { if (typeof x[i] === "function") { x[i].call(this); } } if (this.now && !this.unit && !this.operator) { return new Date(); } else { today = finishUtils.getToday.call(this); } expression = !!(this.days && this.days !== null || this.orient || this.operator); orient = ((this.orient === "past" || this.operator === "subtract") ? -1 : 1); if (this.month && this.unit === "week") { this.value = this.month + 1; delete this.month; delete this.day; } if ((this.month || this.month === 0) && "year day hour minute second".indexOf(this.unit) !== -1) { if (!this.value) { this.value = this.month + 1; } this.month = null; expression = true; } if (!expression && this.weekday && !this.day && !this.days) { finishUtils.setDMYFromWeekday.call(this); } if (expression && this.weekday && this.unit !== "month" && this.unit !== "week") { finishUtils.setDaysFromWeekday.call(this, today, orient); } if (this.weekday && this.unit !== "week" && !this.day && !this.days) { temp = Date[this.weekday](); this.day = temp.getDate(); if (temp.getMonth() !== today.getMonth()) { this.month = temp.getMonth(); } } if (this.month && this.unit === "day" && this.operator) { if (!this.value) { this.value = (this.month + 1); } this.month = null; } if (this.value != null && this.month != null && this.year != null) { this.day = this.value * 1; } if (this.month && !this.day && this.value) { today.set({ day: this.value * 1 }); if (!expression) { this.day = this.value * 1; } } if (!this.month && this.value && this.unit === "month" && !this.now) { this.month = this.value; expression = true; } if (expression && (this.month || this.month === 0) && this.unit !== "year") { finishUtils.setMonthsFromMonth.call(this, today, orient); } if (!this.unit) { this.unit = "day"; } finishUtils.setUnitValue.call(this, orient); parseMeridian.call(this); if ((this.month || this.month === 0) && !this.day) { this.day = 1; } if (!this.orient && !this.operator && this.unit === "week" && this.value && !this.day && !this.month) { return Date.today().setWeek(this.value); } if (this.unit === "week" && this.weeks && !this.day && !this.month) { return finishUtils.generateDateFromWeeks.call(this); } if (expression && this.timezone && this.day && this.days) { this.day = this.days; } if (expression){ today.add(this); } else { today.set(this); } if (this.timezone) { this.timezone = this.timezone.toUpperCase(); var offset = $D.getTimezoneOffset(this.timezone); var timezone; if (today.hasDaylightSavingTime()) { // lets check that we're being sane with timezone setting timezone = $D.getTimezoneAbbreviation(offset, today.isDaylightSavingTime()); if (timezone !== this.timezone) { // bugger, we're in a place where things like EST vs EDT matters. if (today.isDaylightSavingTime()) { today.addHours(-1); } else { today.addHours(1); } } } today.setTimezoneOffset(offset); } return today; } }; }()); (function () { var $D = Date; $D.Grammar = {}; var _ = $D.Parsing.Operators, g = $D.Grammar, t = $D.Translator, _fn; // Allow rolling up into general purpose rules _fn = function () { return _.each(_.any.apply(null, arguments), _.not(g.ctoken2("timeContext"))); }; g.datePartDelimiter = _.rtoken(/^([\s\-\.\,\/\x27]+)/); g.timePartDelimiter = _.stoken(":"); g.whiteSpace = _.rtoken(/^\s*/); g.generalDelimiter = _.rtoken(/^(([\s\,]|at|@|on)+)/); var _C = {}; g.ctoken = function (keys) { var fn = _C[keys]; if (! fn) { var c = Date.CultureInfo.regexPatterns; var kx = keys.split(/\s+/), px = []; for (var i = 0; i < kx.length ; i++) { px.push(_.replace(_.rtoken(c[kx[i]]), kx[i])); } fn = _C[keys] = _.any.apply(null, px); } return fn; }; g.ctoken2 = function (key) { return _.rtoken(Date.CultureInfo.regexPatterns[key]); }; var cacheProcessRtoken = function (key, token, type, eachToken) { if (eachToken) { g[key] = _.cache(_.process(_.each(_.rtoken(token),_.optional(g.ctoken2(eachToken))), type)); } else { g[key] = _.cache(_.process(_.rtoken(token), type)); } }; var cacheProcessCtoken = function (token, type) { return _.cache(_.process(g.ctoken2(token), type)); }; var _F = {}; //function cache var _get = function (f) { _F[f] = (_F[f] || g.format(f)[0]); return _F[f]; }; g.allformats = function (fx) { var rx = []; if (fx instanceof Array) { for (var i = 0; i < fx.length; i++) { rx.push(_get(fx[i])); } } else { rx.push(_get(fx)); } return rx; }; g.formats = function (fx) { if (fx instanceof Array) { var rx = []; for (var i = 0 ; i < fx.length ; i++) { rx.push(_get(fx[i])); } return _.any.apply(null, rx); } else { return _get(fx); } }; var grammarFormats = { timeFormats: function(){ var i, RTokenKeys = [ "h", "hh", "H", "HH", "m", "mm", "s", "ss", "ss.s", "z", "zz" ], RToken = [ /^(0[0-9]|1[0-2]|[1-9])/, /^(0[0-9]|1[0-2])/, /^([0-1][0-9]|2[0-3]|[0-9])/, /^([0-1][0-9]|2[0-3])/, /^([0-5][0-9]|[0-9])/, /^[0-5][0-9]/, /^([0-5][0-9]|[0-9])/, /^[0-5][0-9]/, /^[0-5][0-9]\.[0-9]{1,3}/, /^((\+|\-)\s*\d\d\d\d)|((\+|\-)\d\d\:?\d\d)/, /^((\+|\-)\s*\d\d\d\d)|((\+|\-)\d\d\:?\d\d)/ ], tokens = [ t.hour, t.hour, t.hour, t.hour, t.minute, t.minute, t.second, t.second, t.secondAndMillisecond, t.timezone, t.timezone ]; for (i=0; i < RTokenKeys.length; i++) { cacheProcessRtoken(RTokenKeys[i], RToken[i], tokens[i]); } g.hms = _.cache(_.sequence([g.H, g.m, g.s], g.timePartDelimiter)); g.t = cacheProcessCtoken("shortMeridian", t.meridian); g.tt = cacheProcessCtoken("longMeridian", t.meridian); g.zzz = cacheProcessCtoken("timezone", t.timezone); g.timeSuffix = _.each(_.ignore(g.whiteSpace), _.set([ g.tt, g.zzz ])); g.time = _.each(_.optional(_.ignore(_.stoken("T"))), g.hms, g.timeSuffix); }, dateFormats: function () { // pre-loaded rules for different date part order preferences var _setfn = function () { return _.set(arguments, g.datePartDelimiter); }; var i, RTokenKeys = [ "d", "dd", "M", "MM", "y", "yy", "yyy", "yyyy" ], RToken = [ /^([0-2]\d|3[0-1]|\d)/, /^([0-2]\d|3[0-1])/, /^(1[0-2]|0\d|\d)/, /^(1[0-2]|0\d)/, /^(\d+)/, /^(\d\d)/, /^(\d\d?\d?\d?)/, /^(\d\d\d\d)/ ], tokens = [ t.day, t.day, t.month, t.month, t.year, t.year, t.year, t.year ], eachToken = [ "ordinalSuffix", "ordinalSuffix" ]; for (i=0; i < RTokenKeys.length; i++) { cacheProcessRtoken(RTokenKeys[i], RToken[i], tokens[i], eachToken[i]); } g.MMM = g.MMMM = _.cache(_.process(g.ctoken("jan feb mar apr may jun jul aug sep oct nov dec"), t.month)); g.ddd = g.dddd = _.cache(_.process(g.ctoken("sun mon tue wed thu fri sat"), function (s) { return function () { this.weekday = s; }; } )); g.day = _fn(g.d, g.dd); g.month = _fn(g.M, g.MMM); g.year = _fn(g.yyyy, g.yy); g.mdy = _setfn(g.ddd, g.month, g.day, g.year); g.ymd = _setfn(g.ddd, g.year, g.month, g.day); g.dmy = _setfn(g.ddd, g.day, g.month, g.year); g.date = function (s) { return ((g[Date.CultureInfo.dateElementOrder] || g.mdy).call(this, s)); }; }, relative: function () { // relative date / time expressions g.orientation = _.process(g.ctoken("past future"), function (s) { return function () { this.orient = s; }; } ); g.operator = _.process(g.ctoken("add subtract"), function (s) { return function () { this.operator = s; }; } ); g.rday = _.process(g.ctoken("yesterday tomorrow today now"), t.rday); g.unit = _.process(g.ctoken("second minute hour day week month year"), function (s) { return function () { this.unit = s; }; } ); } }; g.buildGrammarFormats = function () { // these need to be rebuilt every time the language changes. _C = {}; grammarFormats.timeFormats(); grammarFormats.dateFormats(); grammarFormats.relative(); g.value = _.process(_.rtoken(/^([-+]?\d+)?(st|nd|rd|th)?/), function (s) { return function () { this.value = s.replace(/\D/g, ""); }; } ); g.expression = _.set([g.rday, g.operator, g.value, g.unit, g.orientation, g.ddd, g.MMM ]); g.format = _.process(_.many( _.any( // translate format specifiers into grammar rules _.process( _.rtoken(/^(dd?d?d?(?!e)|MM?M?M?|yy?y?y?|hh?|HH?|mm?|ss?|tt?|zz?z?)/), function (fmt) { if (g[fmt]) { return g[fmt]; } else { throw $D.Parsing.Exception(fmt); } } ), // translate separator tokens into token rules _.process(_.rtoken(/^[^dMyhHmstz]+/), // all legal separators function (s) { return _.ignore(_.stoken(s)); } ) ) ), // construct the parser ... function (rules) { return _.process(_.each.apply(null, rules), t.finishExact); } ); // starting rule for general purpose grammar g._start = _.process(_.set([ g.date, g.time, g.expression ], g.generalDelimiter, g.whiteSpace), t.finish); }; g.buildGrammarFormats(); // parsing date format specifiers - ex: "h:m:s tt" // this little guy will generate a custom parser based // on the format string, ex: g.format("h:m:s tt") // check for these formats first g._formats = g.formats([ "\"yyyy-MM-ddTHH:mm:ssZ\"", "yyyy-MM-ddTHH:mm:ss.sz", "yyyy-MM-ddTHH:mm:ssZ", "yyyy-MM-ddTHH:mm:ssz", "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-ddTHH:mmZ", "yyyy-MM-ddTHH:mmz", "yyyy-MM-ddTHH:mm", "ddd, MMM dd, yyyy H:mm:ss tt", "ddd MMM d yyyy HH:mm:ss zzz", "MMddyyyy", "ddMMyyyy", "Mddyyyy", "ddMyyyy", "Mdyyyy", "dMyyyy", "yyyy", "Mdyy", "dMyy", "d" ]); // real starting rule: tries selected formats first, // then general purpose rule g.start = function (s) { try { var r = g._formats.call({}, s); if (r[1].length === 0) { return r; } } catch (e) {} return g._start.call({}, s); }; }()); (function () { var $D = Date; /** * @desc Converts the specified string value into its JavaScript Date equivalent using CultureInfo specific format information. * * Example

	///////////
	// Dates //
	///////////

	// 15-Oct-2004
	var d1 = Date.parse("10/15/2004");

	// 15-Oct-2004
	var d1 = Date.parse("15-Oct-2004");

	// 15-Oct-2004
	var d1 = Date.parse("2004.10.15");

	//Fri Oct 15, 2004
	var d1 = Date.parse("Fri Oct 15, 2004");

	///////////
	// Times //
	///////////

	// Today at 10 PM.
	var d1 = Date.parse("10 PM");

	// Today at 10:30 PM.
	var d1 = Date.parse("10:30 P.M.");

	// Today at 6 AM.
	var d1 = Date.parse("06am");

	/////////////////////
	// Dates and Times //
	/////////////////////

	// 8-July-2004 @ 10:30 PM
	var d1 = Date.parse("July 8th, 2004, 10:30 PM");

	// 1-July-2004 @ 10:30 PM
	var d1 = Date.parse("2004-07-01T22:30:00");

	////////////////////
	// Relative Dates //
	////////////////////

	// Returns today's date. The string "today" is culture specific.
	var d1 = Date.parse("today");

	// Returns yesterday's date. The string "yesterday" is culture specific.
	var d1 = Date.parse("yesterday");

	// Returns the date of the next thursday.
	var d1 = Date.parse("Next thursday");

	// Returns the date of the most previous monday.
	var d1 = Date.parse("last monday");

	// Returns today's day + one year.
	var d1 = Date.parse("next year");

	///////////////
	// Date Math //
	///////////////

	// Today + 2 days
	var d1 = Date.parse("t+2");

	// Today + 2 days
	var d1 = Date.parse("today + 2 days");

	// Today + 3 months
	var d1 = Date.parse("t+3m");

	// Today - 1 year
	var d1 = Date.parse("today - 1 year");

	// Today - 1 year
	var d1 = Date.parse("t-1y"); 


	/////////////////////////////
	// Partial Dates and Times //
	/////////////////////////////

	// July 15th of this year.
	var d1 = Date.parse("July 15");

	// 15th day of current day and year.
	var d1 = Date.parse("15");

	// July 1st of current year at 10pm.
	var d1 = Date.parse("7/1 10pm");
	
* * @param {String} The string value to convert into a Date object [Required] * @return {Date} A Date object or null if the string cannot be converted into a Date. */ var parseUtils = { removeOrds: function (s) { ords = s.match(/\b(\d+)(?:st|nd|rd|th)\b/); // find ordinal matches s = ((ords && ords.length === 2) ? s.replace(ords[0], ords[1]) : s); return s; }, grammarParser: function (s) { var r = null; try { r = $D.Grammar.start.call({}, s.replace(/^\s*(\S*(\s+\S+)*)\s*$/, "$1")); } catch (e) { return null; } return ((r[1].length === 0) ? r[0] : null); }, nativeFallback: function(s) { var t; try { // ok we haven't parsed it, last ditch attempt with the built-in parser. t = Date._parse(s); return (t || t === 0) ? new Date(t) : null; } catch (e) { return null; } } }; function parse (s) { var d; if (!s) { return null; } if (s instanceof Date) { return s.clone(); } if (s.length >= 4 && s.charAt(0) !== "0" && s.charAt(0) !== "+"&& s.charAt(0) !== "-") { // ie: 2004 will pass, 0800 won't. // Start with specific formats d = $D.Parsing.ISO.parse(s) || $D.Parsing.Numeric.parse(s); } if (d instanceof Date && !isNaN(d.getTime())) { return d; } else { // find ordinal dates (1st, 3rd, 8th, etc and remove them as they cause parsing issues) s = $D.Parsing.Normalizer.parse(parseUtils.removeOrds(s)); d = parseUtils.grammarParser(s); if (d !== null) { return d; } else { return parseUtils.nativeFallback(s); } } } if (!$D._parse) { $D._parse = $D.parse; } $D.parse = parse; Date.getParseFunction = function (fx) { var fns = Date.Grammar.allformats(fx); return function (s) { var r = null; for (var i = 0; i < fns.length; i++) { try { r = fns[i].call({}, s); } catch (e) { continue; } if (r[1].length === 0) { return r[0]; } } return null; }; }; /** * Converts the specified string value into its JavaScript Date equivalent using the specified format {String} or formats {Array} and the CultureInfo specific format information. * The format of the string value must match one of the supplied formats exactly. * * Example

	// 15-Oct-2004
	var d1 = Date.parseExact("10/15/2004", "M/d/yyyy");

	// 15-Oct-2004
	var d1 = Date.parse("15-Oct-2004", "M-ddd-yyyy");

	// 15-Oct-2004
	var d1 = Date.parse("2004.10.15", "yyyy.MM.dd");

	// Multiple formats
	var d1 = Date.parseExact("10/15/2004", ["M/d/yyyy", "MMMM d, yyyy"]);
	
* * @param {String} The string value to convert into a Date object [Required]. * @param {Object} The expected format {String} or an array of expected formats {Array} of the date string [Required]. * @return {Date} A Date object or null if the string cannot be converted into a Date. */ $D.parseExact = function (s, fx) { return $D.getParseFunction(fx)(s); }; }()); (function () { var $D = Date, $P = $D.prototype, // $C = $D.CultureInfo, // not used atm p = function (s, l) { if (!l) { l = 2; } return ("000" + s).slice(l * -1); }; /** * Converts a PHP format string to Java/.NET format string. * A PHP format string can be used with ._format or .format. * A Java/.NET format string can be used with .toString(). * The .parseExact function will only accept a Java/.NET format string * * Example * var f1 = "%m/%d/%y" * var f2 = Date.normalizeFormat(f1); // "MM/dd/yy" * * new Date().format(f1); // "04/13/08" * new Date()._format(f1); // "04/13/08" * new Date().toString(f2); // "04/13/08" * * var date = Date.parseExact("04/13/08", f2); // Sun Apr 13 2008 * * @param {String} A PHP format string consisting of one or more format spcifiers. * @return {String} The PHP format converted to a Java/.NET format string. */ var normalizerSubstitutions = { "d" : "dd", "%d": "dd", "D" : "ddd", "%a": "ddd", "j" : "dddd", "l" : "dddd", "%A": "dddd", "S" : "S", "F" : "MMMM", "%B": "MMMM", "m" : "MM", "%m": "MM", "M" : "MMM", "%b": "MMM", "%h": "MMM", "n" : "M", "Y" : "yyyy", "%Y": "yyyy", "y" : "yy", "%y": "yy", "g" : "h", "%I": "h", "G" : "H", "h" : "hh", "H" : "HH", "%H": "HH", "i" : "mm", "%M": "mm", "s" : "ss", "%S": "ss", "%r": "hh:mm tt", "%R": "H:mm", "%T": "H:mm:ss", "%X": "t", "%x": "d", "%e": "d", "%D": "MM/dd/yy", "%n": "\\n", "%t": "\\t", "e" : "z", "T" : "z", "%z": "z", "%Z": "z", "Z" : "ZZ", "N" : "u", "w" : "u", "%w": "u", "W" : "W", "%V": "W" }; var normalizer = { substitutes: function (m) { return normalizerSubstitutions[m]; }, interpreted: function (m, x) { var y; switch (m) { case "%u": return x.getDay() + 1; case "z": return x.getOrdinalNumber(); case "%j": return p(x.getOrdinalNumber(), 3); case "%U": var d1 = x.clone().set({month: 0, day: 1}).addDays(-1).moveToDayOfWeek(0), d2 = x.clone().addDays(1).moveToDayOfWeek(0, -1); return (d2 < d1) ? "00" : p((d2.getOrdinalNumber() - d1.getOrdinalNumber()) / 7 + 1); case "%W": return p(x.getWeek()); case "t": return $D.getDaysInMonth(x.getFullYear(), x.getMonth()); case "o": case "%G": return x.setWeek(x.getISOWeek()).toString("yyyy"); case "%g": return x._format("%G").slice(-2); case "a": case "%p": return t("tt").toLowerCase(); case "A": return t("tt").toUpperCase(); case "u": return p(x.getMilliseconds(), 3); case "I": return (x.isDaylightSavingTime()) ? 1 : 0; case "O": return x.getUTCOffset(); case "P": y = x.getUTCOffset(); return y.substring(0, y.length - 2) + ":" + y.substring(y.length - 2); case "B": var now = new Date(); return Math.floor(((now.getHours() * 3600) + (now.getMinutes() * 60) + now.getSeconds() + (now.getTimezoneOffset() + 60) * 60) / 86.4); case "c": return x.toISOString().replace(/\"/g, ""); case "U": return $D.strtotime("now"); case "%c": return t("d") + " " + t("t"); case "%C": return Math.floor(x.getFullYear() / 100 + 1); } }, shouldOverrideDefaults: function (m) { switch (m) { case "%e": return true; default: return false; } }, parse: function (m, context) { var formatString, c = context || new Date(); formatString = normalizer.substitutes(m); if (formatString) { return formatString; } formatString = normalizer.interpreted(m, c); if (formatString) { return formatString; } else { return m; } } }; $D.normalizeFormat = function (format, context) { return format.replace(/(%|\\)?.|%%/g, function(t){ return normalizer.parse(t, context); }); }; /** * Format a local Unix timestamp according to locale settings * * Example: * Date.strftime("%m/%d/%y", new Date()); // "04/13/08" * Date.strftime("c", "2008-04-13T17:52:03Z"); // "04/13/08" * * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @param {Number|String} The number representing the number of seconds that have elapsed since January 1, 1970 (local time). * @return {String} A string representation of the current Date object. */ $D.strftime = function (format, time) { var d = Date.parse(time); return d._format(format); }; /** * Parse any textual datetime description into a Unix timestamp. * A Unix timestamp is the number of seconds that have elapsed since January 1, 1970 (midnight UTC/GMT). * * Example: * Date.strtotime("04/13/08"); // 1208044800 * Date.strtotime("1970-01-01T00:00:00Z"); // 0 * * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @param {Object} A string or date object. * @return {String} A string representation of the current Date object. */ $D.strtotime = function (time) { var d = $D.parse(time); return Math.round($D.UTC(d.getUTCFullYear(), d.getUTCMonth(), d.getUTCDate(), d.getUTCHours(), d.getUTCMinutes(), d.getUTCSeconds(), d.getUTCMilliseconds()) / 1000); }; /** * Converts the value of the current Date object to its equivalent string representation using a PHP/Unix style of date format specifiers. * Format Specifiers * Format Description Example * ------ --------------------------------------------------------------------------- ----------------------- * %a abbreviated weekday name according to the current localed "Mon" through "Sun" * %A full weekday name according to the current localed "Sunday" through "Saturday" * %b abbreviated month name according to the current localed "Jan" through "Dec" * %B full month name according to the current locale "January" through "December" * %c preferred date and time representation for the current locale "4/13/2008 12:33 PM" * %C century number (the year divided by 100 and truncated to an integer) "00" to "99" * %d day of the month as a decimal number "01" to "31" * %D same as %m/%d/%y "04/13/08" * %e day of the month as a decimal number, a single digit is preceded by a space "1" to "31" * %g like %G, but without the century "08" * %G The 4-digit year corresponding to the ISO week number (see %V). "2008" * This has the same format and value as %Y, except that if the ISO week number * belongs to the previous or next year, that year is used instead. * %h same as %b "Jan" through "Dec" * %H hour as a decimal number using a 24-hour clock. "00" to "23" * %I hour as a decimal number using a 12-hour clock. "01" to "12" * %j day of the year as a decimal number. "001" to "366" * %m month as a decimal number. "01" to "12" * %M minute as a decimal number. "00" to "59" * %n newline character "\n" * %p either "am" or "pm" according to the given time value, or the "am" or "pm" * corresponding strings for the current locale. * %r time in a.m. and p.m. notation "8:44 PM" * %R time in 24 hour notation "20:44" * %S second as a decimal number "00" to "59" * %t tab character "\t" * %T current time, equal to %H:%M:%S "12:49:11" * %u weekday as a decimal number ["1", "7"], with "1" representing Monday "1" to "7" * %U week number of the current year as a decimal number, starting with the "0" to ("52" or "53") * first Sunday as the first day of the first week * %V The ISO 8601:1988 week number of the current year as a decimal number, "00" to ("52" or "53") * range 01 to 53, where week 1 is the first week that has at least 4 days * in the current year, and with Monday as the first day of the week. * (Use %G or %g for the year component that corresponds to the week number * for the specified timestamp.) * %W week number of the current year as a decimal number, starting with the "00" to ("52" or "53") * first Monday as the first day of the first week * %w day of the week as a decimal, Sunday being "0" "0" to "6" * %x preferred date representation for the current locale without the time "4/13/2008" * %X preferred time representation for the current locale without the date "12:53:05" * %y year as a decimal number without a century "00" "99" * %Y year as a decimal number including the century "2008" * %Z time zone or name or abbreviation "UTC", "EST", "PST" * %z same as %Z * %% a literal "%" characters "%" * d Day of the month, 2 digits with leading zeros "01" to "31" * D A textual representation of a day, three letters "Mon" through "Sun" * j Day of the month without leading zeros "1" to "31" * l A full textual representation of the day of the week (lowercase "L") "Sunday" through "Saturday" * N ISO-8601 numeric representation of the day of the week (added in PHP 5.1.0) "1" (for Monday) through "7" (for Sunday) * S English ordinal suffix for the day of the month, 2 characters "st", "nd", "rd" or "th". Works well with j * w Numeric representation of the day of the week "0" (for Sunday) through "6" (for Saturday) * z The day of the year (starting from "0") "0" through "365" * W ISO-8601 week number of year, weeks starting on Monday "00" to ("52" or "53") * F A full textual representation of a month, such as January or March "January" through "December" * m Numeric representation of a month, with leading zeros "01" through "12" * M A short textual representation of a month, three letters "Jan" through "Dec" * n Numeric representation of a month, without leading zeros "1" through "12" * t Number of days in the given month "28" through "31" * L Whether it's a leap year "1" if it is a leap year, "0" otherwise * o ISO-8601 year number. This has the same value as Y, except that if the "2008" * ISO week number (W) belongs to the previous or next year, that year * is used instead. * Y A full numeric representation of a year, 4 digits "2008" * y A two digit representation of a year "08" * a Lowercase Ante meridiem and Post meridiem "am" or "pm" * A Uppercase Ante meridiem and Post meridiem "AM" or "PM" * B Swatch Internet time "000" through "999" * g 12-hour format of an hour without leading zeros "1" through "12" * G 24-hour format of an hour without leading zeros "0" through "23" * h 12-hour format of an hour with leading zeros "01" through "12" * H 24-hour format of an hour with leading zeros "00" through "23" * i Minutes with leading zeros "00" to "59" * s Seconds, with leading zeros "00" through "59" * u Milliseconds "54321" * e Timezone identifier "UTC", "EST", "PST" * I Whether or not the date is in daylight saving time (uppercase i) "1" if Daylight Saving Time, "0" otherwise * O Difference to Greenwich time (GMT) in hours "+0200", "-0600" * P Difference to Greenwich time (GMT) with colon between hours and minutes "+02:00", "-06:00" * T Timezone abbreviation "UTC", "EST", "PST" * Z Timezone offset in seconds. The offset for timezones west of UTC is "-43200" through "50400" * always negative, and for those east of UTC is always positive. * c ISO 8601 date "2004-02-12T15:19:21+00:00" * r RFC 2822 formatted date "Thu, 21 Dec 2000 16:01:07 +0200" * U Seconds since the Unix Epoch (January 1 1970 00:00:00 GMT) "0" * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @return {String} A string representation of the current Date object. */ var formatReplace = function (context) { return function (m) { var formatString, override = false; if (m.charAt(0) === "\\" || m.substring(0, 2) === "%%") { return m.replace("\\", "").replace("%%", "%"); } override = normalizer.shouldOverrideDefaults(m); formatString = $D.normalizeFormat(m, context); if (formatString) { return context.toString(formatString, override); } }; }; $P._format = function (format) { var formatter = formatReplace(this); if (!format) { return this._toString(); } else { return format.replace(/(%|\\)?.|%%/g, formatter); } }; if (!$P.format) { $P.format = $P._format; } }()); (function () { "use strict"; var gFn = function (attr) { return function () { return this[attr]; }; }; var sFn = function (attr) { return function (val) { this[attr] = val; return this; }; }; var attrs = ["years", "months", "days", "hours", "minutes", "seconds", "milliseconds"]; var addSetFuncs = function (context, attrs) { for (var i = 0; i < attrs.length ; i++) { var $a = attrs[i], $b = $a.slice(0, 1).toUpperCase() + $a.slice(1); context.prototype[$a] = 0; context.prototype["get" + $b] = gFn($a); context.prototype["set" + $b] = sFn($a); } }; /** * new TimeSpan(milliseconds); * new TimeSpan(days, hours, minutes, seconds); * new TimeSpan(days, hours, minutes, seconds, milliseconds); */ var TimeSpan = function (days, hours, minutes, seconds, milliseconds) { if (arguments.length === 1 && typeof days === "number") { var orient = (days < 0) ? -1 : +1; var millsLeft = Math.abs(days); this.setDays(Math.floor(millsLeft / 86400000) * orient); millsLeft = millsLeft % 86400000; this.setHours(Math.floor(millsLeft / 3600000) * orient); millsLeft = millsLeft % 3600000; this.setMinutes(Math.floor(millsLeft / 60000) * orient); millsLeft = millsLeft % 60000; this.setSeconds(Math.floor(millsLeft / 1000) * orient); millsLeft = millsLeft % 1000; this.setMilliseconds(millsLeft * orient); } else { this.set(days, hours, minutes, seconds, milliseconds); } this.getTotalMilliseconds = function () { return (this.getDays() * 86400000) + (this.getHours() * 3600000) + (this.getMinutes() * 60000) + (this.getSeconds() * 1000); }; this.compareTo = function (time) { var t1 = new Date(1970, 1, 1, this.getHours(), this.getMinutes(), this.getSeconds()), t2; if (time === null) { t2 = new Date(1970, 1, 1, 0, 0, 0); } else { t2 = new Date(1970, 1, 1, time.getHours(), time.getMinutes(), time.getSeconds()); } return (t1 < t2) ? -1 : (t1 > t2) ? 1 : 0; }; this.equals = function (time) { return (this.compareTo(time) === 0); }; this.add = function (time) { return (time === null) ? this : this.addSeconds(time.getTotalMilliseconds() / 1000); }; this.subtract = function (time) { return (time === null) ? this : this.addSeconds(-time.getTotalMilliseconds() / 1000); }; this.addDays = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 86400000)); }; this.addHours = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 3600000)); }; this.addMinutes = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 60000)); }; this.addSeconds = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 1000)); }; this.addMilliseconds = function (n) { return new TimeSpan(this.getTotalMilliseconds() + n); }; this.get12HourHour = function () { return (this.getHours() > 12) ? this.getHours() - 12 : (this.getHours() === 0) ? 12 : this.getHours(); }; this.getDesignator = function () { return (this.getHours() < 12) ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator; }; this.toString = function (format) { this._toString = function () { if (this.getDays() !== null && this.getDays() > 0) { return this.getDays() + "." + this.getHours() + ":" + this.p(this.getMinutes()) + ":" + this.p(this.getSeconds()); } else { return this.getHours() + ":" + this.p(this.getMinutes()) + ":" + this.p(this.getSeconds()); } }; this.p = function (s) { return (s.toString().length < 2) ? "0" + s : s; }; var me = this; return format ? format.replace(/dd?|HH?|hh?|mm?|ss?|tt?/g, function (format) { switch (format) { case "d": return me.getDays(); case "dd": return me.p(me.getDays()); case "H": return me.getHours(); case "HH": return me.p(me.getHours()); case "h": return me.get12HourHour(); case "hh": return me.p(me.get12HourHour()); case "m": return me.getMinutes(); case "mm": return me.p(me.getMinutes()); case "s": return me.getSeconds(); case "ss": return me.p(me.getSeconds()); case "t": return ((me.getHours() < 12) ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator).substring(0, 1); case "tt": return (me.getHours() < 12) ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator; } } ) : this._toString(); }; return this; }; addSetFuncs(TimeSpan, attrs.slice(2)); TimeSpan.prototype.set = function (days, hours, minutes, seconds, milliseconds){ this.setDays(days || this.getDays()); this.setHours(hours || this.getHours()); this.setMinutes(minutes || this.getMinutes()); this.setSeconds(seconds || this.getSeconds()); this.setMilliseconds(milliseconds || this.getMilliseconds()); }; /** * Gets the time of day for this date instances. * @return {TimeSpan} TimeSpan */ Date.prototype.getTimeOfDay = function () { return new TimeSpan(0, this.getHours(), this.getMinutes(), this.getSeconds(), this.getMilliseconds()); }; Date.TimeSpan = TimeSpan; if (typeof window !== "undefined" ) { // keeping API compatible for v1.x window.TimeSpan = TimeSpan; } }()); (function () { "use strict"; var attrs = ["years", "months", "days", "hours", "minutes", "seconds", "milliseconds"]; var gFn = function (attr) { return function () { return this[attr]; }; }; var sFn = function (attr) { return function (val) { this[attr] = val; return this; }; }; var addSetFuncs = function (context, attrs) { for (var i = 0; i < attrs.length ; i++) { var $a = attrs[i], $b = $a.slice(0, 1).toUpperCase() + $a.slice(1); context.prototype[$a] = 0; context.prototype["get" + $b] = gFn($a); context.prototype["set" + $b] = sFn($a); } }; var setMonthsAndYears = function (orient, d1, d2, context) { function inc() { d1.addMonths(-orient); context.months++; if (context.months === 12) { context.years++; context.months = 0; } } if (orient === +1) { while (d1 > d2) { inc(); } } else { while (d1 < d2) { inc(); } } context.months--; context.months *= orient; context.years *= orient; }; var adjustForDST = function(orient, startDate, endDate) { var hasDSTMismatch = (false === (startDate.isDaylightSavingTime() === endDate.isDaylightSavingTime())); if (hasDSTMismatch && orient === 1) { startDate.addHours(-1); } else if (hasDSTMismatch) { startDate.addHours(1); } }; /** * TimePeriod(startDate, endDate); * TimePeriod(years, months, days, hours, minutes, seconds, milliseconds); */ var TimePeriod = function (years, months, days, hours, minutes, seconds, milliseconds) { if (arguments.length === 7) { this.set(years, months, days, hours, minutes, seconds, milliseconds); } else if (arguments.length === 2 && arguments[0] instanceof Date && arguments[1] instanceof Date) { var startDate = arguments[0].clone(); var endDate = arguments[1].clone(); var orient = (startDate > endDate) ? +1 : -1; this.dates = { start: arguments[0].clone(), end: arguments[1].clone() }; setMonthsAndYears(orient, startDate, endDate, this); adjustForDST(orient, startDate, endDate); // // TODO - adjust for DST var diff = endDate - startDate; if (diff !== 0) { var ts = new TimeSpan(diff); this.set(this.years, this.months, ts.getDays(), ts.getHours(), ts.getMinutes(), ts.getSeconds(), ts.getMilliseconds()); } } return this; }; // create all the set functions. addSetFuncs(TimePeriod, attrs); TimePeriod.prototype.set = function (years, months, days, hours, minutes, seconds, milliseconds){ this.setYears(years || this.getYears()); this.setMonths(months || this.getMonths()); this.setDays(days || this.getDays()); this.setHours(hours || this.getHours()); this.setMinutes(minutes || this.getMinutes()); this.setSeconds(seconds || this.getSeconds()); this.setMilliseconds(milliseconds || this.getMilliseconds()); }; Date.TimePeriod = TimePeriod; if (typeof window !== "undefined") { // keeping API compatible for v1.x window.TimePeriod = TimePeriod; } }()); ================================================ FILE: build/date-id-ID.js ================================================ /** * @overview datejs * @version 1.0.0-rc3 * @author Gregory Wild-Smith * @copyright 2015 Gregory Wild-Smith * @license MIT * @homepage https://github.com/abritinthebay/datejs */ /* * DateJS Culture String File * Country Code: id-ID * Name: Indonesian (Indonesia) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["id-ID"] = { "name": "id-ID", "englishName": "Indonesian (Indonesia)", "nativeName": "Bahasa Indonesia (Indonesia)", "Sunday": "Minggu", "Monday": "Senin", "Tuesday": "Selasa", "Wednesday": "Rabu", "Thursday": "Kamis", "Friday": "Jumat", "Saturday": "Sabtu", "Sun": "Minggu", "Mon": "Sen", "Tue": "Sel", "Wed": "Rabu", "Thu": "Kamis", "Fri": "Jumat", "Sat": "Sabtu", "Su": "M", "Mo": "S", "Tu": "S", "We": "R", "Th": "K", "Fr": "J", "Sa": "S", "S_Sun_Initial": "M", "M_Mon_Initial": "S", "T_Tue_Initial": "S", "W_Wed_Initial": "R", "T_Thu_Initial": "K", "F_Fri_Initial": "J", "S_Sat_Initial": "S", "January": "Januari", "February": "Februari", "March": "Maret", "April": "April", "May": "Mei", "June": "Juni", "July": "Juli", "August": "Agustus", "September": "September", "October": "Oktober", "November": "Nopember", "December": "Desember", "Jan_Abbr": "Jan", "Feb_Abbr": "Feb", "Mar_Abbr": "Mar", "Apr_Abbr": "Apr", "May_Abbr": "Mei", "Jun_Abbr": "Jun", "Jul_Abbr": "Jul", "Aug_Abbr": "Agust", "Sep_Abbr": "Sep", "Oct_Abbr": "Okt", "Nov_Abbr": "Nop", "Dec_Abbr": "Des", "AM": "", "PM": "", "firstDayOfWeek": 1, "twoDigitYearMax": 2029, "mdy": "dmy", "M/d/yyyy": "dd/MM/yyyy", "dddd, MMMM dd, yyyy": "dd MMMM yyyy", "h:mm tt": "H:mm", "h:mm:ss tt": "H:mm:ss", "dddd, MMMM dd, yyyy h:mm:ss tt": "dd MMMM yyyy H:mm:ss", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "dd MMMM", "MMMM, yyyy": "MMMM yyyy", "/jan(uary)?/": "jan(uari)?", "/feb(ruary)?/": "feb(ruari)?", "/mar(ch)?/": "mar(et)?", "/apr(il)?/": "apr(il)?", "/may/": "mei", "/jun(e)?/": "jun(i)?", "/jul(y)?/": "jul(i)?", "/aug(ust)?/": "agust(us)?", "/sep(t(ember)?)?/": "sep(t(ember)?)?", "/oct(ober)?/": "okt(ober)?", "/nov(ember)?/": "nop(ember)?", "/dec(ember)?/": "des(ember)?", "/^su(n(day)?)?/": "^m(1)?", "/^mo(n(day)?)?/": "^s(en(in)?)?", "/^tu(e(s(day)?)?)?/": "^s(el(asa)?)?", "/^we(d(nesday)?)?/": "^r(1)?", "/^th(u(r(s(day)?)?)?)?/": "^k(1)?", "/^fr(i(day)?)?/": "^j(1)?", "/^sa(t(urday)?)?/": "^s(1)?", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "id-ID"; /** * @overview datejs * @version 1.0.0-rc3 * @author Gregory Wild-Smith * @copyright 2015 Gregory Wild-Smith * @license MIT * @homepage https://github.com/abritinthebay/datejs */(function () { var $D = Date; var lang = Date.CultureStrings ? Date.CultureStrings.lang : null; var loggedKeys = {}; // for debug purposes. var getText = { getFromKey: function (key, countryCode) { var output; if (Date.CultureStrings && Date.CultureStrings[countryCode] && Date.CultureStrings[countryCode][key]) { output = Date.CultureStrings[countryCode][key]; } else { output = getText.buildFromDefault(key); } if (key.charAt(0) === "/") { // Assume it's a regex output = getText.buildFromRegex(key, countryCode); } return output; }, getFromObjectValues: function (obj, countryCode) { var key, output = {}; for(key in obj) { if (obj.hasOwnProperty(key)) { output[key] = getText.getFromKey(obj[key], countryCode); } } return output; }, getFromObjectKeys: function (obj, countryCode) { var key, output = {}; for(key in obj) { if (obj.hasOwnProperty(key)) { output[getText.getFromKey(key, countryCode)] = obj[key]; } } return output; }, getFromArray: function (arr, countryCode) { var output = []; for (var i=0; i < arr.length; i++){ if (i in arr) { output[i] = getText.getFromKey(arr[i], countryCode); } } return output; }, buildFromDefault: function (key) { var output, length, split, last; switch(key) { case "name": output = "en-US"; break; case "englishName": output = "English (United States)"; break; case "nativeName": output = "English (United States)"; break; case "twoDigitYearMax": output = 2049; break; case "firstDayOfWeek": output = 0; break; default: output = key; split = key.split("_"); length = split.length; if (length > 1 && key.charAt(0) !== "/") { // if the key isn't a regex and it has a split. last = split[(length - 1)].toLowerCase(); if (last === "initial" || last === "abbr") { output = split[0]; } } break; } return output; }, buildFromRegex: function (key, countryCode) { var output; if (Date.CultureStrings && Date.CultureStrings[countryCode] && Date.CultureStrings[countryCode][key]) { output = new RegExp(Date.CultureStrings[countryCode][key], "i"); } else { output = new RegExp(key.replace(new RegExp("/", "g"),""), "i"); } return output; } }; var shallowMerge = function (obj1, obj2) { for (var attrname in obj2) { if (obj2.hasOwnProperty(attrname)) { obj1[attrname] = obj2[attrname]; } } }; var __ = function (key, language) { var countryCode = (language) ? language : lang; loggedKeys[key] = key; if (typeof key === "object") { if (key instanceof Array) { return getText.getFromArray(key, countryCode); } else { return getText.getFromObjectKeys(key, countryCode); } } else { return getText.getFromKey(key, countryCode); } }; var loadI18nScript = function (code) { // paatterned after jQuery's getScript. var url = Date.Config.i18n + code + ".js"; var head = document.getElementsByTagName("head")[0] || document.documentElement; var script = document.createElement("script"); script.src = url; var completed = false; var events = { done: function (){} // placeholder function }; // Attach handlers for all browsers script.onload = script.onreadystatechange = function() { if ( !completed && (!this.readyState || this.readyState === "loaded" || this.readyState === "complete") ) { events.done(); head.removeChild(script); } }; setTimeout(function() { head.insertBefore(script, head.firstChild); }, 0); // allows return to execute first return { done: function (cb) { events.done = function() { if (cb) { setTimeout(cb,0); } }; } }; }; var buildInfo = { buildFromMethodHash: function (obj) { var key; for(key in obj) { if (obj.hasOwnProperty(key)) { obj[key] = buildInfo[obj[key]](); } } return obj; }, timeZoneDST: function () { var DST = { "CHADT": "+1345", "NZDT": "+1300", "AEDT": "+1100", "ACDT": "+1030", "AZST": "+0500", "IRDT": "+0430", "EEST": "+0300", "CEST": "+0200", "BST": "+0100", "PMDT": "-0200", "ADT": "-0300", "NDT": "-0230", "EDT": "-0400", "CDT": "-0500", "MDT": "-0600", "PDT": "-0700", "AKDT": "-0800", "HADT": "-0900" }; return __(DST); }, timeZoneStandard: function () { var standard = { "LINT": "+1400", "TOT": "+1300", "CHAST": "+1245", "NZST": "+1200", "NFT": "+1130", "SBT": "+1100", "AEST": "+1000", "ACST": "+0930", "JST": "+0900", "CWST": "+0845", "CT": "+0800", "ICT": "+0700", "MMT": "+0630", "BST": "+0600", "NPT": "+0545", "IST": "+0530", "PKT": "+0500", "AFT": "+0430", "MSK": "+0400", "IRST": "+0330", "FET": "+0300", "EET": "+0200", "CET": "+0100", "GMT": "+0000", "UTC": "+0000", "CVT": "-0100", "GST": "-0200", "BRT": "-0300", "NST": "-0330", "AST": "-0400", "EST": "-0500", "CST": "-0600", "MST": "-0700", "PST": "-0800", "AKST": "-0900", "MIT": "-0930", "HST": "-1000", "SST": "-1100", "BIT": "-1200" }; return __(standard); }, timeZones: function (data) { var zone; data.timezones = []; for (zone in data.abbreviatedTimeZoneStandard) { if (data.abbreviatedTimeZoneStandard.hasOwnProperty(zone)) { data.timezones.push({ name: zone, offset: data.abbreviatedTimeZoneStandard[zone]}); } } for (zone in data.abbreviatedTimeZoneDST) { if (data.abbreviatedTimeZoneDST.hasOwnProperty(zone)) { data.timezones.push({ name: zone, offset: data.abbreviatedTimeZoneDST[zone], dst: true}); } } return data.timezones; }, days: function () { return __(["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"]); }, dayAbbr: function () { return __(["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"]); }, dayShortNames: function () { return __(["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"]); }, dayFirstLetters: function () { return __(["S_Sun_Initial", "M_Mon_Initial", "T_Tues_Initial", "W_Wed_Initial", "T_Thu_Initial", "F_Fri_Initial", "S_Sat_Initial"]); }, months: function () { return __(["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"]); }, monthAbbr: function () { return __(["Jan_Abbr", "Feb_Abbr", "Mar_Abbr", "Apr_Abbr", "May_Abbr", "Jun_Abbr", "Jul_Abbr", "Aug_Abbr", "Sep_Abbr", "Oct_Abbr", "Nov_Abbr", "Dec_Abbr"]); }, formatPatterns: function () { return getText.getFromObjectValues({ shortDate: "M/d/yyyy", longDate: "dddd, MMMM dd, yyyy", shortTime: "h:mm tt", longTime: "h:mm:ss tt", fullDateTime: "dddd, MMMM dd, yyyy h:mm:ss tt", sortableDateTime: "yyyy-MM-ddTHH:mm:ss", universalSortableDateTime: "yyyy-MM-dd HH:mm:ssZ", rfc1123: "ddd, dd MMM yyyy HH:mm:ss", monthDay: "MMMM dd", yearMonth: "MMMM, yyyy" }, Date.i18n.currentLanguage()); }, regex: function () { return getText.getFromObjectValues({ inTheMorning: "/( in the )(morn(ing)?)\\b/", thisMorning: "/(this )(morn(ing)?)\\b/", amThisMorning: "/(\b\\d(am)? )(this )(morn(ing)?)/", inTheEvening: "/( in the )(even(ing)?)\\b/", thisEvening: "/(this )(even(ing)?)\\b/", pmThisEvening: "/(\b\\d(pm)? )(this )(even(ing)?)/", jan: "/jan(uary)?/", feb: "/feb(ruary)?/", mar: "/mar(ch)?/", apr: "/apr(il)?/", may: "/may/", jun: "/jun(e)?/", jul: "/jul(y)?/", aug: "/aug(ust)?/", sep: "/sep(t(ember)?)?/", oct: "/oct(ober)?/", nov: "/nov(ember)?/", dec: "/dec(ember)?/", sun: "/^su(n(day)?)?/", mon: "/^mo(n(day)?)?/", tue: "/^tu(e(s(day)?)?)?/", wed: "/^we(d(nesday)?)?/", thu: "/^th(u(r(s(day)?)?)?)?/", fri: "/fr(i(day)?)?/", sat: "/^sa(t(urday)?)?/", future: "/^next/", past: "/^last|past|prev(ious)?/", add: "/^(\\+|aft(er)?|from|hence)/", subtract: "/^(\\-|bef(ore)?|ago)/", yesterday: "/^yes(terday)?/", today: "/^t(od(ay)?)?/", tomorrow: "/^tom(orrow)?/", now: "/^n(ow)?/", millisecond: "/^ms|milli(second)?s?/", second: "/^sec(ond)?s?/", minute: "/^mn|min(ute)?s?/", hour: "/^h(our)?s?/", week: "/^w(eek)?s?/", month: "/^m(onth)?s?/", day: "/^d(ay)?s?/", year: "/^y(ear)?s?/", shortMeridian: "/^(a|p)/", longMeridian: "/^(a\\.?m?\\.?|p\\.?m?\\.?)/", timezone: "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/", ordinalSuffix: "/^\\s*(st|nd|rd|th)/", timeContext: "/^\\s*(\\:|a(?!u|p)|p)/" }, Date.i18n.currentLanguage()); } }; var CultureInfo = function () { var info = getText.getFromObjectValues({ name: "name", englishName: "englishName", nativeName: "nativeName", amDesignator: "AM", pmDesignator: "PM", firstDayOfWeek: "firstDayOfWeek", twoDigitYearMax: "twoDigitYearMax", dateElementOrder: "mdy" }, Date.i18n.currentLanguage()); var constructedInfo = buildInfo.buildFromMethodHash({ dayNames: "days", abbreviatedDayNames: "dayAbbr", shortestDayNames: "dayShortNames", firstLetterDayNames: "dayFirstLetters", monthNames: "months", abbreviatedMonthNames: "monthAbbr", formatPatterns: "formatPatterns", regexPatterns: "regex", abbreviatedTimeZoneDST: "timeZoneDST", abbreviatedTimeZoneStandard: "timeZoneStandard" }); shallowMerge(info, constructedInfo); buildInfo.timeZones(info); return info; }; $D.i18n = { __: function (key, lang) { return __(key, lang); }, currentLanguage: function () { return lang || "en-US"; }, setLanguage: function (code, force, cb) { var async = false; if (force || code === "en-US" || (!!Date.CultureStrings && !!Date.CultureStrings[code])) { lang = code; Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings.lang = code; Date.CultureInfo = new CultureInfo(); } else { if (!(!!Date.CultureStrings && !!Date.CultureStrings[code])) { if (typeof exports !== "undefined" && this.exports !== exports) { // we're in a Node enviroment, load it using require try { require("../i18n/" + code + ".js"); lang = code; Date.CultureStrings.lang = code; Date.CultureInfo = new CultureInfo(); } catch (e) { // var str = "The language for '" + code + "' could not be loaded by Node. It likely does not exist."; throw new Error("The DateJS IETF language tag '" + code + "' could not be loaded by Node. It likely does not exist."); } } else if (Date.Config && Date.Config.i18n) { // we know the location of the files, so lets load them async = true; loadI18nScript(code).done(function(){ lang = code; Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings.lang = code; Date.CultureInfo = new CultureInfo(); $D.Parsing.Normalizer.buildReplaceData(); // because this is async if ($D.Grammar) { $D.Grammar.buildGrammarFormats(); // so we can parse those strings... } if (cb) { setTimeout(cb,0); } }); } else { Date.console.error("The DateJS IETF language tag '" + code + "' is not available and has not been loaded."); return false; } } } $D.Parsing.Normalizer.buildReplaceData(); // rebuild normalizer strings if ($D.Grammar) { $D.Grammar.buildGrammarFormats(); // so we can parse those strings... } if (!async && cb) { setTimeout(cb,0); } }, getLoggedKeys: function () { return loggedKeys; }, updateCultureInfo: function () { Date.CultureInfo = new CultureInfo(); } }; $D.i18n.updateCultureInfo(); // run automatically }()); (function () { var $D = Date, $P = $D.prototype, p = function (s, l) { if (!l) { l = 2; } return ("000" + s).slice(l * -1); }; if (typeof window !== "undefined" && typeof window.console !== "undefined" && typeof window.console.log !== "undefined") { $D.console = console; // used only to raise non-critical errors if available } else { // set mock so we don't give errors. $D.console = { log: function(){}, error: function(){} }; } $D.Config = $D.Config || {}; $D.initOverloads = function() { /** * Overload of Date.now. Allows an alternate call for Date.now where it returns the * current Date as an object rather than just milliseconds since the Unix Epoch. * * Also provides an implementation of now() for browsers (IE<9) that don't have it. * * Backwards compatible so with work with either: * Date.now() [returns ms] * or * Date.now(true) [returns Date] */ if (!$D.now) { $D._now = function now() { return new Date().getTime(); }; } else if (!$D._now) { $D._now = $D.now; } $D.now = function (returnObj) { if (returnObj) { return $D.present(); } else { return $D._now(); } }; if ( !$P.toISOString ) { $P.toISOString = function() { return this.getUTCFullYear() + "-" + p(this.getUTCMonth() + 1) + "-" + p(this.getUTCDate()) + "T" + p(this.getUTCHours()) + ":" + p(this.getUTCMinutes()) + ":" + p(this.getUTCSeconds()) + "." + String( (this.getUTCMilliseconds()/1000).toFixed(3)).slice(2, 5) + "Z"; }; } // private if ( $P._toString === undefined ){ $P._toString = $P.toString; } }; $D.initOverloads(); /** * Gets a date that is set to the current date. The time is set to the start of the day (00:00 or 12:00 AM). * @return {Date} The current date. */ $D.today = function () { return new Date().clearTime(); }; /** * Gets a date that is set to the current date and time (same as new Date, but chainable) * @return {Date} The current date. */ $D.present = function () { return new Date(); }; /** * Compares the first date to the second date and returns an number indication of their relative values. * @param {Date} First Date object to compare [Required]. * @param {Date} Second Date object to compare to [Required]. * @return {Number} -1 = date1 is lessthan date2. 0 = values are equal. 1 = date1 is greaterthan date2. */ $D.compare = function (date1, date2) { if (isNaN(date1) || isNaN(date2)) { throw new Error(date1 + " - " + date2); } else if (date1 instanceof Date && date2 instanceof Date) { return (date1 < date2) ? -1 : (date1 > date2) ? 1 : 0; } else { throw new TypeError(date1 + " - " + date2); } }; /** * Compares the first Date object to the second Date object and returns true if they are equal. * @param {Date} First Date object to compare [Required] * @param {Date} Second Date object to compare to [Required] * @return {Boolean} true if dates are equal. false if they are not equal. */ $D.equals = function (date1, date2) { return (date1.compareTo(date2) === 0); }; /** * Gets the language appropriate day name when given the day number(0-6) * eg - 0 == Sunday * @return {String} The day name */ $D.getDayName = function (n) { return Date.CultureInfo.dayNames[n]; }; /** * Gets the day number (0-6) if given a CultureInfo specific string which is a valid dayName, abbreviatedDayName or shortestDayName (two char). * @param {String} The name of the day (eg. "Monday, "Mon", "tuesday", "tue", "We", "we"). * @return {Number} The day number */ $D.getDayNumberFromName = function (name) { var n = Date.CultureInfo.dayNames, m = Date.CultureInfo.abbreviatedDayNames, o = Date.CultureInfo.shortestDayNames, s = name.toLowerCase(); for (var i = 0; i < n.length; i++) { if (n[i].toLowerCase() === s || m[i].toLowerCase() === s || o[i].toLowerCase() === s) { return i; } } return -1; }; /** * Gets the month number (0-11) if given a Culture Info specific string which is a valid monthName or abbreviatedMonthName. * @param {String} The name of the month (eg. "February, "Feb", "october", "oct"). * @return {Number} The day number */ $D.getMonthNumberFromName = function (name) { var n = Date.CultureInfo.monthNames, m = Date.CultureInfo.abbreviatedMonthNames, s = name.toLowerCase(); for (var i = 0; i < n.length; i++) { if (n[i].toLowerCase() === s || m[i].toLowerCase() === s) { return i; } } return -1; }; /** * Gets the language appropriate month name when given the month number(0-11) * eg - 0 == January * @return {String} The month name */ $D.getMonthName = function (n) { return Date.CultureInfo.monthNames[n]; }; /** * Determines if the current date instance is within a LeapYear. * @param {Number} The year. * @return {Boolean} true if date is within a LeapYear, otherwise false. */ $D.isLeapYear = function (year) { return ((year % 4 === 0 && year % 100 !== 0) || year % 400 === 0); }; /** * Gets the number of days in the month, given a year and month value. Automatically corrects for LeapYear. * @param {Number} The year. * @param {Number} The month (0-11). * @return {Number} The number of days in the month. */ $D.getDaysInMonth = function (year, month) { if (!month && $D.validateMonth(year)) { month = year; year = Date.today().getFullYear(); } return [31, ($D.isLeapYear(year) ? 29 : 28), 31, 30, 31, 30, 31, 31, 30, 31, 30, 31][month]; }; $P.getDaysInMonth = function () { return $D.getDaysInMonth(this.getFullYear(), this.getMonth()); }; $D.getTimezoneAbbreviation = function (offset, dst) { var p, n = (dst || false) ? Date.CultureInfo.abbreviatedTimeZoneDST : Date.CultureInfo.abbreviatedTimeZoneStandard; for (p in n) { if (n.hasOwnProperty(p)) { if (n[p] === offset) { return p; } } } return null; }; $D.getTimezoneOffset = function (name, dst) { var i, a =[], z = Date.CultureInfo.timezones; if (!name) { name = (new Date()).getTimezone();} for (i = 0; i < z.length; i++) { if (z[i].name === name.toUpperCase()) { a.push(i); } } if (!z[a[0]]) { return null; } if (a.length === 1 || !dst) { return z[a[0]].offset; } else { for (i=0; i < a.length; i++) { if (z[a[i]].dst) { return z[a[i]].offset; } } } }; $D.getQuarter = function (d) { d = d || new Date(); // If no date supplied, use today var q = [1,2,3,4]; return q[Math.floor(d.getMonth() / 3)]; // ~~~ is a bitwise op. Faster than Math.floor }; $D.getDaysLeftInQuarter = function (d) { d = d || new Date(); var qEnd = new Date(d); qEnd.setMonth(qEnd.getMonth() + 3 - qEnd.getMonth() % 3, 0); return Math.floor((qEnd - d) / 8.64e7); }; // private var validate = function (n, min, max, name) { name = name ? name : "Object"; if (typeof n === "undefined") { return false; } else if (typeof n !== "number") { throw new TypeError(n + " is not a Number."); } else if (n < min || n > max) { // As failing validation is *not* an exceptional circumstance // lets not throw a RangeError Exception here. // It's semantically correct but it's not sensible. return false; } return true; }; /** * Validates the number is within an acceptable range for milliseconds [0-999]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateMillisecond = function (value) { return validate(value, 0, 999, "millisecond"); }; /** * Validates the number is within an acceptable range for seconds [0-59]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateSecond = function (value) { return validate(value, 0, 59, "second"); }; /** * Validates the number is within an acceptable range for minutes [0-59]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateMinute = function (value) { return validate(value, 0, 59, "minute"); }; /** * Validates the number is within an acceptable range for hours [0-23]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateHour = function (value) { return validate(value, 0, 23, "hour"); }; /** * Validates the number is within an acceptable range for the days in a month [0-MaxDaysInMonth]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateDay = function (value, year, month) { if (year === undefined || year === null || month === undefined || month === null) { return false;} return validate(value, 1, $D.getDaysInMonth(year, month), "day"); }; /** * Validates the number is within an acceptable range for months [0-11]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateWeek = function (value) { return validate(value, 0, 53, "week"); }; /** * Validates the number is within an acceptable range for months [0-11]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateMonth = function (value) { return validate(value, 0, 11, "month"); }; /** * Validates the number is within an acceptable range for years. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateYear = function (value) { /** * Per ECMAScript spec the range of times supported by Date objects is * exactly -100,000,000 days to +100,000,000 days measured relative to * midnight at the beginning of 01 January, 1970 UTC. * This gives a range of 8,640,000,000,000,000 milliseconds to either * side of 01 January, 1970 UTC. * * Earliest possible date: Tue, 20 Apr 271,822 B.C. 00:00:00 UTC * Latest possible date: Sat, 13 Sep 275,760 00:00:00 UTC */ return validate(value, -271822, 275760, "year"); }; $D.validateTimezone = function(value) { var timezones = {"ACDT":1,"ACST":1,"ACT":1,"ADT":1,"AEDT":1,"AEST":1,"AFT":1,"AKDT":1,"AKST":1,"AMST":1,"AMT":1,"ART":1,"AST":1,"AWDT":1,"AWST":1,"AZOST":1,"AZT":1,"BDT":1,"BIOT":1,"BIT":1,"BOT":1,"BRT":1,"BST":1,"BTT":1,"CAT":1,"CCT":1,"CDT":1,"CEDT":1,"CEST":1,"CET":1,"CHADT":1,"CHAST":1,"CHOT":1,"ChST":1,"CHUT":1,"CIST":1,"CIT":1,"CKT":1,"CLST":1,"CLT":1,"COST":1,"COT":1,"CST":1,"CT":1,"CVT":1,"CWST":1,"CXT":1,"DAVT":1,"DDUT":1,"DFT":1,"EASST":1,"EAST":1,"EAT":1,"ECT":1,"EDT":1,"EEDT":1,"EEST":1,"EET":1,"EGST":1,"EGT":1,"EIT":1,"EST":1,"FET":1,"FJT":1,"FKST":1,"FKT":1,"FNT":1,"GALT":1,"GAMT":1,"GET":1,"GFT":1,"GILT":1,"GIT":1,"GMT":1,"GST":1,"GYT":1,"HADT":1,"HAEC":1,"HAST":1,"HKT":1,"HMT":1,"HOVT":1,"HST":1,"ICT":1,"IDT":1,"IOT":1,"IRDT":1,"IRKT":1,"IRST":1,"IST":1,"JST":1,"KGT":1,"KOST":1,"KRAT":1,"KST":1,"LHST":1,"LINT":1,"MAGT":1,"MART":1,"MAWT":1,"MDT":1,"MET":1,"MEST":1,"MHT":1,"MIST":1,"MIT":1,"MMT":1,"MSK":1,"MST":1,"MUT":1,"MVT":1,"MYT":1,"NCT":1,"NDT":1,"NFT":1,"NPT":1,"NST":1,"NT":1,"NUT":1,"NZDT":1,"NZST":1,"OMST":1,"ORAT":1,"PDT":1,"PET":1,"PETT":1,"PGT":1,"PHOT":1,"PHT":1,"PKT":1,"PMDT":1,"PMST":1,"PONT":1,"PST":1,"PYST":1,"PYT":1,"RET":1,"ROTT":1,"SAKT":1,"SAMT":1,"SAST":1,"SBT":1,"SCT":1,"SGT":1,"SLST":1,"SRT":1,"SST":1,"SYOT":1,"TAHT":1,"THA":1,"TFT":1,"TJT":1,"TKT":1,"TLT":1,"TMT":1,"TOT":1,"TVT":1,"UCT":1,"ULAT":1,"UTC":1,"UYST":1,"UYT":1,"UZT":1,"VET":1,"VLAT":1,"VOLT":1,"VOST":1,"VUT":1,"WAKT":1,"WAST":1,"WAT":1,"WEDT":1,"WEST":1,"WET":1,"WST":1,"YAKT":1,"YEKT":1,"Z":1}; return (timezones[value] === 1); }; $D.validateTimezoneOffset= function(value) { // timezones go from +14hrs to -12hrs, the +X hours are negative offsets. return (value > -841 && value < 721); }; }()); (function () { var $D = Date, $P = $D.prototype, p = function (s, l) { if (!l) { l = 2; } return ("000" + s).slice(l * -1); }; var validateConfigObject = function (obj) { var result = {}, self = this, prop, testFunc; testFunc = function (prop, func, value) { if (prop === "day") { var month = (obj.month !== undefined) ? obj.month : self.getMonth(); var year = (obj.year !== undefined) ? obj.year : self.getFullYear(); return $D[func](value, year, month); } else { return $D[func](value); } }; for (prop in obj) { if (Object.prototype.hasOwnProperty.call(obj, prop)) { var func = "validate" + prop.charAt(0).toUpperCase() + prop.slice(1); if ($D[func] && obj[prop] !== null && testFunc(prop, func, obj[prop])) { result[prop] = obj[prop]; } } } return result; }; /** * Resets the time of this Date object to 12:00 AM (00:00), which is the start of the day. * @param {Boolean} .clone() this date instance before clearing Time * @return {Date} this */ $P.clearTime = function () { this.setHours(0); this.setMinutes(0); this.setSeconds(0); this.setMilliseconds(0); return this; }; /** * Resets the time of this Date object to the current time ('now'). * @return {Date} this */ $P.setTimeToNow = function () { var n = new Date(); this.setHours(n.getHours()); this.setMinutes(n.getMinutes()); this.setSeconds(n.getSeconds()); this.setMilliseconds(n.getMilliseconds()); return this; }; /** * Returns a new Date object that is an exact date and time copy of the original instance. * @return {Date} A new Date instance */ $P.clone = function () { return new Date(this.getTime()); }; /** * Compares this instance to a Date object and returns an number indication of their relative values. * @param {Date} Date object to compare [Required] * @return {Number} -1 = this is lessthan date. 0 = values are equal. 1 = this is greaterthan date. */ $P.compareTo = function (date) { return Date.compare(this, date); }; /** * Compares this instance to another Date object and returns true if they are equal. * @param {Date} Date object to compare. If no date to compare, new Date() [now] is used. * @return {Boolean} true if dates are equal. false if they are not equal. */ $P.equals = function (date) { return Date.equals(this, (date !== undefined ? date : new Date())); }; /** * Determines if this instance is between a range of two dates or equal to either the start or end dates. * @param {Date} Start of range [Required] * @param {Date} End of range [Required] * @return {Boolean} true is this is between or equal to the start and end dates, else false */ $P.between = function (start, end) { return this.getTime() >= start.getTime() && this.getTime() <= end.getTime(); }; /** * Determines if this date occurs after the date to compare to. * @param {Date} Date object to compare. If no date to compare, new Date() ("now") is used. * @return {Boolean} true if this date instance is greater than the date to compare to (or "now"), otherwise false. */ $P.isAfter = function (date) { return this.compareTo(date || new Date()) === 1; }; /** * Determines if this date occurs before the date to compare to. * @param {Date} Date object to compare. If no date to compare, new Date() ("now") is used. * @return {Boolean} true if this date instance is less than the date to compare to (or "now"). */ $P.isBefore = function (date) { return (this.compareTo(date || new Date()) === -1); }; /** * Determines if the current Date instance occurs today. * @return {Boolean} true if this date instance is 'today', otherwise false. */ /** * Determines if the current Date instance occurs on the same Date as the supplied 'date'. * If no 'date' to compare to is provided, the current Date instance is compared to 'today'. * @param {date} Date object to compare. If no date to compare, the current Date ("now") is used. * @return {Boolean} true if this Date instance occurs on the same Day as the supplied 'date'. */ $P.isToday = $P.isSameDay = function (date) { return this.clone().clearTime().equals((date || new Date()).clone().clearTime()); }; /** * Adds the specified number of milliseconds to this instance. * @param {Number} The number of milliseconds to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addMilliseconds = function (value) { if (!value) { return this; } this.setTime(this.getTime() + value * 1); return this; }; /** * Adds the specified number of seconds to this instance. * @param {Number} The number of seconds to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addSeconds = function (value) { if (!value) { return this; } return this.addMilliseconds(value * 1000); }; /** * Adds the specified number of seconds to this instance. * @param {Number} The number of seconds to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addMinutes = function (value) { if (!value) { return this; } return this.addMilliseconds(value * 60000); // 60*1000 }; /** * Adds the specified number of hours to this instance. * @param {Number} The number of hours to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addHours = function (value) { if (!value) { return this; } return this.addMilliseconds(value * 3600000); // 60*60*1000 }; /** * Adds the specified number of days to this instance. * @param {Number} The number of days to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addDays = function (value) { if (!value) { return this; } this.setDate(this.getDate() + value * 1); return this; }; /** * Adds the specified number of weekdays (ie - not sat or sun) to this instance. * @param {Number} The number of days to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addWeekdays = function (value) { if (!value) { return this; } var day = this.getDay(); var weeks = (Math.ceil(Math.abs(value)/7)); if (day === 0 || day === 6) { if (value > 0) { this.next().monday(); this.addDays(-1); day = this.getDay(); } } if (value < 0) { while (value < 0) { this.addDays(-1); day = this.getDay(); if (day !== 0 && day !== 6) { value++; } } return this; } else if (value > 5 || (6-day) <= value) { value = value + (weeks * 2); } return this.addDays(value); }; /** * Adds the specified number of weeks to this instance. * @param {Number} The number of weeks to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addWeeks = function (value) { if (!value) { return this; } return this.addDays(value * 7); }; /** * Adds the specified number of months to this instance. * @param {Number} The number of months to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addMonths = function (value) { if (!value) { return this; } var n = this.getDate(); this.setDate(1); this.setMonth(this.getMonth() + value * 1); this.setDate(Math.min(n, $D.getDaysInMonth(this.getFullYear(), this.getMonth()))); return this; }; $P.addQuarters = function (value) { if (!value) { return this; } // note this will take you to the same point in the quarter as you are now. // i.e. - if you are 15 days into the quarter you'll be 15 days into the resulting one. // bonus: this allows adding fractional quarters return this.addMonths(value * 3); }; /** * Adds the specified number of years to this instance. * @param {Number} The number of years to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addYears = function (value) { if (!value) { return this; } return this.addMonths(value * 12); }; /** * Adds (or subtracts) to the value of the years, months, weeks, days, hours, minutes, seconds, milliseconds of the date instance using given configuration object. Positive and Negative values allowed. * Example

	Date.today().add( { days: 1, months: 1 } )

	new Date().add( { years: -1 } )
	
* @param {Object} Configuration object containing attributes (months, days, etc.) * @return {Date} this */ $P.add = function (config) { if (typeof config === "number") { this._orient = config; return this; } var x = config; if (x.day) { // If we should be a different date than today (eg: for 'tomorrow -1d', etc). // Should only effect parsing, not direct usage (eg, Finish and FinishExact) if ((x.day - this.getDate()) !== 0) { this.setDate(x.day); } } if (x.milliseconds) { this.addMilliseconds(x.milliseconds); } if (x.seconds) { this.addSeconds(x.seconds); } if (x.minutes) { this.addMinutes(x.minutes); } if (x.hours) { this.addHours(x.hours); } if (x.weeks) { this.addWeeks(x.weeks); } if (x.months) { this.addMonths(x.months); } if (x.years) { this.addYears(x.years); } if (x.days) { this.addDays(x.days); } return this; }; /** * Get the week number. Week one (1) is the week which contains the first Thursday of the year. Monday is considered the first day of the week. * The .getWeek() function does NOT convert the date to UTC. The local datetime is used. * Please use .getISOWeek() to get the week of the UTC converted date. * @return {Number} 1 to 53 */ $P.getWeek = function (utc) { // Create a copy of this date object var self, target = new Date(this.valueOf()); if (utc) { target.addMinutes(target.getTimezoneOffset()); self = target.clone(); } else { self = this; } // ISO week date weeks start on monday // so correct the day number var dayNr = (self.getDay() + 6) % 7; // ISO 8601 states that week 1 is the week // with the first thursday of that year. // Set the target date to the thursday in the target week target.setDate(target.getDate() - dayNr + 3); // Store the millisecond value of the target date var firstThursday = target.valueOf(); // Set the target to the first thursday of the year // First set the target to january first target.setMonth(0, 1); // Not a thursday? Correct the date to the next thursday if (target.getDay() !== 4) { target.setMonth(0, 1 + ((4 - target.getDay()) + 7) % 7); } // The weeknumber is the number of weeks between the // first thursday of the year and the thursday in the target week return 1 + Math.ceil((firstThursday - target) / 604800000); // 604800000 = 7 * 24 * 3600 * 1000 }; /** * Get the ISO 8601 week number. Week one ("01") is the week which contains the first Thursday of the year. Monday is considered the first day of the week. * The .getISOWeek() function does convert the date to it's UTC value. Please use .getWeek() to get the week of the local date. * @return {String} "01" to "53" */ $P.getISOWeek = function () { return p(this.getWeek(true)); }; /** * Moves the date to Monday of the week set. Week one (1) is the week which contains the first Thursday of the year. * @param {Number} A Number (1 to 53) that represents the week of the year. * @return {Date} this */ $P.setWeek = function (n) { if ((n - this.getWeek()) === 0) { if (this.getDay() !== 1) { return this.moveToDayOfWeek(1, (this.getDay() > 1 ? -1 : 1)); } else { return this; } } else { return this.moveToDayOfWeek(1, (this.getDay() > 1 ? -1 : 1)).addWeeks(n - this.getWeek()); } }; $P.setQuarter = function (qtr) { var month = Math.abs(((qtr-1) * 3) + 1); return this.setMonth(month, 1); }; $P.getQuarter = function () { return Date.getQuarter(this); }; $P.getDaysLeftInQuarter = function () { return Date.getDaysLeftInQuarter(this); }; /** * Moves the date to the next n'th occurrence of the dayOfWeek starting from the beginning of the month. The number (-1) is a magic number and will return the last occurrence of the dayOfWeek in the month. * @param {Number} The dayOfWeek to move to * @param {Number} The n'th occurrence to move to. Use (-1) to return the last occurrence in the month * @return {Date} this */ $P.moveToNthOccurrence = function (dayOfWeek, occurrence) { if (dayOfWeek === "Weekday") { if (occurrence > 0) { this.moveToFirstDayOfMonth(); if (this.is().weekday()) { occurrence -= 1; } } else if (occurrence < 0) { this.moveToLastDayOfMonth(); if (this.is().weekday()) { occurrence += 1; } } else { return this; } return this.addWeekdays(occurrence); } var shift = 0; if (occurrence > 0) { shift = occurrence - 1; } else if (occurrence === -1) { this.moveToLastDayOfMonth(); if (this.getDay() !== dayOfWeek) { this.moveToDayOfWeek(dayOfWeek, -1); } return this; } return this.moveToFirstDayOfMonth().addDays(-1).moveToDayOfWeek(dayOfWeek, +1).addWeeks(shift); }; var moveToN = function (getFunc, addFunc, nVal) { return function (value, orient) { var diff = (value - this[getFunc]() + nVal * (orient || +1)) % nVal; return this[addFunc]((diff === 0) ? diff += nVal * (orient || +1) : diff); }; }; /** * Move to the next or last dayOfWeek based on the orient value. * @param {Number} The dayOfWeek to move to * @param {Number} Forward (+1) or Back (-1). Defaults to +1. [Optional] * @return {Date} this */ $P.moveToDayOfWeek = moveToN("getDay", "addDays", 7); /** * Move to the next or last month based on the orient value. * @param {Number} The month to move to. 0 = January, 11 = December * @param {Number} Forward (+1) or Back (-1). Defaults to +1. [Optional] * @return {Date} this */ $P.moveToMonth = moveToN("getMonth", "addMonths", 12); /** * Get the Ordinate of the current day ("th", "st", "rd"). * @return {String} */ $P.getOrdinate = function () { var num = this.getDate(); return ord(num); }; /** * Get the Ordinal day (numeric day number) of the year, adjusted for leap year. * @return {Number} 1 through 365 (366 in leap years) */ $P.getOrdinalNumber = function () { return Math.ceil((this.clone().clearTime() - new Date(this.getFullYear(), 0, 1)) / 86400000) + 1; }; /** * Get the time zone abbreviation of the current date. * @return {String} The abbreviated time zone name (e.g. "EST") */ $P.getTimezone = function () { return $D.getTimezoneAbbreviation(this.getUTCOffset(), this.isDaylightSavingTime()); }; $P.setTimezoneOffset = function (offset) { var here = this.getTimezoneOffset(), there = Number(offset) * -6 / 10; return (there || there === 0) ? this.addMinutes(there - here) : this; }; $P.setTimezone = function (offset) { return this.setTimezoneOffset($D.getTimezoneOffset(offset)); }; /** * Indicates whether Daylight Saving Time is observed in the current time zone. * @return {Boolean} true|false */ $P.hasDaylightSavingTime = function () { return (Date.today().set({month: 0, day: 1}).getTimezoneOffset() !== Date.today().set({month: 6, day: 1}).getTimezoneOffset()); }; /** * Indicates whether this Date instance is within the Daylight Saving Time range for the current time zone. * @return {Boolean} true|false */ $P.isDaylightSavingTime = function () { return Date.today().set({month: 0, day: 1}).getTimezoneOffset() !== this.getTimezoneOffset(); }; /** * Get the offset from UTC of the current date. * @return {String} The 4-character offset string prefixed with + or - (e.g. "-0500") */ $P.getUTCOffset = function (offset) { var n = (offset || this.getTimezoneOffset()) * -10 / 6, r; if (n < 0) { r = (n - 10000).toString(); return r.charAt(0) + r.substr(2); } else { r = (n + 10000).toString(); return "+" + r.substr(1); } }; /** * Returns the number of milliseconds between this date and date. * @param {Date} Defaults to now * @return {Number} The diff in milliseconds */ $P.getElapsed = function (date) { return (date || new Date()) - this; }; /** * Set the value of year, month, day, hour, minute, second, millisecond of date instance using given configuration object. * Example

	Date.today().set( { day: 20, month: 1 } )

	new Date().set( { millisecond: 0 } )
	
* * @param {Object} Configuration object containing attributes (month, day, etc.) * @return {Date} this */ $P.set = function (config) { config = validateConfigObject.call(this, config); var key; for (key in config) { if (Object.prototype.hasOwnProperty.call(config, key)) { var name = key.charAt(0).toUpperCase() + key.slice(1); var addFunc, getFunc; if (key !== "week" && key !== "month" && key !== "timezone" && key !== "timezoneOffset") { name += "s"; } addFunc = "add" + name; getFunc = "get" + name; if (key === "month") { addFunc = addFunc + "s"; } else if (key === "year"){ getFunc = "getFullYear"; } if (key !== "day" && key !== "timezone" && key !== "timezoneOffset" && key !== "week" && key !== "hour") { this[addFunc](config[key] - this[getFunc]()); } else if ( key === "timezone"|| key === "timezoneOffset" || key === "week" || key === "hour") { this["set"+name](config[key]); } } } // day has to go last because you can't validate the day without first knowing the month if (config.day) { this.addDays(config.day - this.getDate()); } return this; }; /** * Moves the date to the first day of the month. * @return {Date} this */ $P.moveToFirstDayOfMonth = function () { return this.set({ day: 1 }); }; /** * Moves the date to the last day of the month. * @return {Date} this */ $P.moveToLastDayOfMonth = function () { return this.set({ day: $D.getDaysInMonth(this.getFullYear(), this.getMonth())}); }; /** * Converts the value of the current Date object to its equivalent string representation. * Format Specifiers * CUSTOM DATE AND TIME FORMAT STRINGS * Format Description Example * ------ --------------------------------------------------------------------------- ----------------------- * s The seconds of the minute between 0-59. "0" to "59" * ss The seconds of the minute with leading zero if required. "00" to "59" * * m The minute of the hour between 0-59. "0" or "59" * mm The minute of the hour with leading zero if required. "00" or "59" * * h The hour of the day between 1-12. "1" to "12" * hh The hour of the day with leading zero if required. "01" to "12" * * H The hour of the day between 0-23. "0" to "23" * HH The hour of the day with leading zero if required. "00" to "23" * * d The day of the month between 1 and 31. "1" to "31" * dd The day of the month with leading zero if required. "01" to "31" * ddd Abbreviated day name. Date.CultureInfo.abbreviatedDayNames. "Mon" to "Sun" * dddd The full day name. Date.CultureInfo.dayNames. "Monday" to "Sunday" * * M The month of the year between 1-12. "1" to "12" * MM The month of the year with leading zero if required. "01" to "12" * MMM Abbreviated month name. Date.CultureInfo.abbreviatedMonthNames. "Jan" to "Dec" * MMMM The full month name. Date.CultureInfo.monthNames. "January" to "December" * * yy The year as a two-digit number. "99" or "08" * yyyy The full four digit year. "1999" or "2008" * * t Displays the first character of the A.M./P.M. designator. "A" or "P" * Date.CultureInfo.amDesignator or Date.CultureInfo.pmDesignator * tt Displays the A.M./P.M. designator. "AM" or "PM" * Date.CultureInfo.amDesignator or Date.CultureInfo.pmDesignator * * S The ordinal suffix ("st, "nd", "rd" or "th") of the current day. "st, "nd", "rd" or "th" * * STANDARD DATE AND TIME FORMAT STRINGS * Format Description Example *------ --------------------------------------------------------------------------- ----------------------- * d The CultureInfo shortDate Format Pattern "M/d/yyyy" * D The CultureInfo longDate Format Pattern "dddd, MMMM dd, yyyy" * F The CultureInfo fullDateTime Format Pattern "dddd, MMMM dd, yyyy h:mm:ss tt" * m The CultureInfo monthDay Format Pattern "MMMM dd" * r The CultureInfo rfc1123 Format Pattern "ddd, dd MMM yyyy HH:mm:ss GMT" * s The CultureInfo sortableDateTime Format Pattern "yyyy-MM-ddTHH:mm:ss" * t The CultureInfo shortTime Format Pattern "h:mm tt" * T The CultureInfo longTime Format Pattern "h:mm:ss tt" * u The CultureInfo universalSortableDateTime Format Pattern "yyyy-MM-dd HH:mm:ssZ" * y The CultureInfo yearMonth Format Pattern "MMMM, yyyy" * * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @return {String} A string representation of the current Date object. */ var ord = function (n) { switch (n * 1) { case 1: case 21: case 31: return "st"; case 2: case 22: return "nd"; case 3: case 23: return "rd"; default: return "th"; } }; var parseStandardFormats = function (format) { var y, c = Date.CultureInfo.formatPatterns; switch (format) { case "d": return this.toString(c.shortDate); case "D": return this.toString(c.longDate); case "F": return this.toString(c.fullDateTime); case "m": return this.toString(c.monthDay); case "r": case "R": y = this.clone().addMinutes(this.getTimezoneOffset()); return y.toString(c.rfc1123) + " GMT"; case "s": return this.toString(c.sortableDateTime); case "t": return this.toString(c.shortTime); case "T": return this.toString(c.longTime); case "u": y = this.clone().addMinutes(this.getTimezoneOffset()); return y.toString(c.universalSortableDateTime); case "y": return this.toString(c.yearMonth); default: return false; } }; var parseFormatStringsClosure = function (context) { return function (m) { if (m.charAt(0) === "\\") { return m.replace("\\", ""); } switch (m) { case "hh": return p(context.getHours() < 13 ? (context.getHours() === 0 ? 12 : context.getHours()) : (context.getHours() - 12)); case "h": return context.getHours() < 13 ? (context.getHours() === 0 ? 12 : context.getHours()) : (context.getHours() - 12); case "HH": return p(context.getHours()); case "H": return context.getHours(); case "mm": return p(context.getMinutes()); case "m": return context.getMinutes(); case "ss": return p(context.getSeconds()); case "s": return context.getSeconds(); case "yyyy": return p(context.getFullYear(), 4); case "yy": return p(context.getFullYear()); case "y": return context.getFullYear(); case "E": case "dddd": return Date.CultureInfo.dayNames[context.getDay()]; case "ddd": return Date.CultureInfo.abbreviatedDayNames[context.getDay()]; case "dd": return p(context.getDate()); case "d": return context.getDate(); case "MMMM": return Date.CultureInfo.monthNames[context.getMonth()]; case "MMM": return Date.CultureInfo.abbreviatedMonthNames[context.getMonth()]; case "MM": return p((context.getMonth() + 1)); case "M": return context.getMonth() + 1; case "t": return context.getHours() < 12 ? Date.CultureInfo.amDesignator.substring(0, 1) : Date.CultureInfo.pmDesignator.substring(0, 1); case "tt": return context.getHours() < 12 ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator; case "S": return ord(context.getDate()); case "W": return context.getWeek(); case "WW": return context.getISOWeek(); case "Q": return "Q" + context.getQuarter(); case "q": return String(context.getQuarter()); case "z": return context.getTimezone(); case "Z": case "X": return Date.getTimezoneOffset(context.getTimezone()); case "ZZ": // Timezone offset in seconds return context.getTimezoneOffset() * -60; case "u": return context.getDay(); case "L": return ($D.isLeapYear(context.getFullYear())) ? 1 : 0; case "B": // Swatch Internet Time (.beats) return "@"+((context.getUTCSeconds() + (context.getUTCMinutes()*60) + ((context.getUTCHours()+1)*3600))/86.4); default: return m; } }; }; $P.toString = function (format, ignoreStandards) { // Standard Date and Time Format Strings. Formats pulled from CultureInfo file and // may vary by culture. if (!ignoreStandards && format && format.length === 1) { output = parseStandardFormats.call(this, format); if (output) { return output; } } var parseFormatStrings = parseFormatStringsClosure(this); return format ? format.replace(/((\\)?(dd?d?d?|MM?M?M?|yy?y?y?|hh?|HH?|mm?|ss?|tt?|S|q|Q|WW?W?W?)(?![^\[]*\]))/g, parseFormatStrings).replace(/\[|\]/g, "") : this._toString(); }; }()); /************************************************************* * SugarPak - Domain Specific Language - Syntactical Sugar * *************************************************************/ (function () { var $D = Date, $P = $D.prototype, $N = Number.prototype; // private $P._orient = +1; // private $P._nth = null; // private $P._is = false; // private $P._same = false; // private $P._isSecond = false; // private $N._dateElement = "days"; /** * Moves the date to the next instance of a date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.today().next().friday();
	Date.today().next().fri();
	Date.today().next().march();
	Date.today().next().mar();
	Date.today().next().week();
	
* * @return {Date} date */ $P.next = function () { this._move = true; this._orient = +1; return this; }; /** * Creates a new Date (Date.today()) and moves the date to the next instance of the date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.next().friday();
	Date.next().fri();
	Date.next().march();
	Date.next().mar();
	Date.next().week();
	
* * @return {Date} date */ $D.next = function () { return $D.today().next(); }; /** * Moves the date to the previous instance of a date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.today().last().friday();
	Date.today().last().fri();
	Date.today().last().march();
	Date.today().last().mar();
	Date.today().last().week();
	
* * @return {Date} date */ $P.last = $P.prev = $P.previous = function () { this._move = true; this._orient = -1; return this; }; /** * Creates a new Date (Date.today()) and moves the date to the previous instance of the date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.last().friday();
	Date.last().fri();
	Date.previous().march();
	Date.prev().mar();
	Date.last().week();
	
* * @return {Date} date */ $D.last = $D.prev = $D.previous = function () { return $D.today().last(); }; /** * Performs a equality check when followed by either a month name, day name or .weekday() function. * Example

	Date.today().is().friday(); // true|false
	Date.today().is().fri();
	Date.today().is().march();
	Date.today().is().mar();
	
* * @return {Boolean} true|false */ $P.is = function () { this._is = true; return this; }; /** * Determines if two date objects occur on/in exactly the same instance of the subsequent date part function. * The function .same() must be followed by a date part function (example: .day(), .month(), .year(), etc). * * An optional Date can be passed in the date part function. If now date is passed as a parameter, 'Now' is used. * * The following example demonstrates how to determine if two dates fall on the exact same day. * * Example

	var d1 = Date.today(); // today at 00:00
	var d2 = new Date();   // exactly now.

	// Do they occur on the same day?
	d1.same().day(d2); // true
	
	// Do they occur on the same hour?
	d1.same().hour(d2); // false, unless d2 hour is '00' (midnight).
	
	// What if it's the same day, but one year apart?
	var nextYear = Date.today().add(1).year();

	d1.same().day(nextYear); // false, because the dates must occur on the exact same day. 
	
* * Scenario: Determine if a given date occurs during some week period 2 months from now. * * Example

	var future = Date.today().add(2).months();
	return someDate.same().week(future); // true|false;
	
* * @return {Boolean} true|false */ $P.same = function () { this._same = true; this._isSecond = false; return this; }; /** * Determines if the current date/time occurs during Today. Must be preceded by the .is() function. * Example

	someDate.is().today();    // true|false
	new Date().is().today();  // true
	Date.today().is().today();// true
	Date.today().add(-1).day().is().today(); // false
	
* * @return {Boolean} true|false */ $P.today = function () { return this.same().day(); }; /** * Determines if the current date is a weekday. This function must be preceded by the .is() function. * Example

	Date.today().is().weekday(); // true|false
	
* * @return {Boolean} true|false */ $P.weekday = function () { if (this._nth) { return df("Weekday").call(this); } if (this._move) { return this.addWeekdays(this._orient); } if (this._is) { this._is = false; return (!this.is().sat() && !this.is().sun()); } return false; }; /** * Determines if the current date is on the weekend. This function must be preceded by the .is() function. * Example

	Date.today().is().weekend(); // true|false
	
* * @return {Boolean} true|false */ $P.weekend = function () { if (this._is) { this._is = false; return (this.is().sat() || this.is().sun()); } return false; }; /** * Sets the Time of the current Date instance. A string "6:15 pm" or config object {hour:18, minute:15} are accepted. * Example

	// Set time to 6:15pm with a String
	Date.today().at("6:15pm");

	// Set time to 6:15pm with a config object
	Date.today().at({hour:18, minute:15});
	
* * @return {Date} date */ $P.at = function (time) { return (typeof time === "string") ? $D.parse(this.toString("d") + " " + time) : this.set(time); }; /** * Creates a new Date() and adds this (Number) to the date based on the preceding date element function (eg. second|minute|hour|day|month|year). * Example

	// Undeclared Numbers must be wrapped with parentheses. Requirment of JavaScript.
	(3).days().fromNow();
	(6).months().fromNow();

	// Declared Number variables do not require parentheses. 
	var n = 6;
	n.months().fromNow();
	
* * @return {Date} A new Date instance */ $N.fromNow = $N.after = function (date) { var c = {}; c[this._dateElement] = this; return ((!date) ? new Date() : date.clone()).add(c); }; /** * Creates a new Date() and subtract this (Number) from the date based on the preceding date element function (eg. second|minute|hour|day|month|year). * Example

	// Undeclared Numbers must be wrapped with parentheses. Requirment of JavaScript.
	(3).days().ago();
	(6).months().ago();

	// Declared Number variables do not require parentheses. 
	var n = 6;
	n.months().ago();
	
* * @return {Date} A new Date instance */ $N.ago = $N.before = function (date) { var c = {}, s = (this._dateElement[this._dateElement.length-1] !== "s") ? this._dateElement + "s" : this._dateElement; c[s] = this * -1; return ((!date) ? new Date() : date.clone()).add(c); }; // Do NOT modify the following string tokens. These tokens are used to build dynamic functions. // All culture-specific strings can be found in the CultureInfo files. var dx = ("sunday monday tuesday wednesday thursday friday saturday").split(/\s/), mx = ("january february march april may june july august september october november december").split(/\s/), px = ("Millisecond Second Minute Hour Day Week Month Year Quarter Weekday").split(/\s/), pxf = ("Milliseconds Seconds Minutes Hours Date Week Month FullYear Quarter").split(/\s/), nth = ("final first second third fourth fifth").split(/\s/), de; /** * Returns an object literal of all the date parts. * Example

	var o = new Date().toObject();
	
	// { year: 2008, month: 4, week: 20, day: 13, hour: 18, minute: 9, second: 32, millisecond: 812 }
	
	// The object properties can be referenced directly from the object.
	
	alert(o.day);  // alerts "13"
	alert(o.year); // alerts "2008"
	
* * @return {Date} An object literal representing the original date object. */ $P.toObject = function () { var o = {}; for (var i = 0; i < px.length; i++) { if (this["get" + pxf[i]]) { o[px[i].toLowerCase()] = this["get" + pxf[i]](); } } return o; }; /** * Returns a date created from an object literal. Ignores the .week property if set in the config. * Example

	var o = new Date().toObject();
	
	return Date.fromObject(o); // will return the same date. 

	var o2 = {month: 1, day: 20, hour: 18}; // birthday party!
	Date.fromObject(o2);
	
* * @return {Date} An object literal representing the original date object. */ $D.fromObject = function(config) { config.week = null; return Date.today().set(config); }; // Create day name functions and abbreviated day name functions (eg. monday(), friday(), fri()). var df = function (n) { return function () { if (this._is) { this._is = false; return this.getDay() === n; } if (this._move) { this._move = null; } if (this._nth !== null) { // If the .second() function was called earlier, remove the _orient // from the date, and then continue. // This is required because 'second' can be used in two different context. // // Example // // Date.today().add(1).second(); // Date.march().second().monday(); // // Things get crazy with the following... // Date.march().add(1).second().second().monday(); // but it works!! // if (this._isSecond) { this.addSeconds(this._orient * -1); } // make sure we reset _isSecond this._isSecond = false; var ntemp = this._nth; this._nth = null; var temp = this.clone().moveToLastDayOfMonth(); this.moveToNthOccurrence(n, ntemp); if (this > temp) { throw new RangeError($D.getDayName(n) + " does not occur " + ntemp + " times in the month of " + $D.getMonthName(temp.getMonth()) + " " + temp.getFullYear() + "."); } return this; } return this.moveToDayOfWeek(n, this._orient); }; }; var sdf = function (n) { return function () { var t = $D.today(), shift = n - t.getDay(); if (n === 0 && Date.CultureInfo.firstDayOfWeek === 1 && t.getDay() !== 0) { shift = shift + 7; } return t.addDays(shift); }; }; // Create month name functions and abbreviated month name functions (eg. january(), march(), mar()). var month_instance_functions = function (n) { return function () { if (this._is) { this._is = false; return this.getMonth() === n; } return this.moveToMonth(n, this._orient); }; }; var month_static_functions = function (n) { return function () { return $D.today().set({ month: n, day: 1 }); }; }; var processTerms = function (names, staticFunc, instanceFunc) { for (var i = 0; i < names.length; i++) { // Create constant static Name variables. $D[names[i].toUpperCase()] = $D[names[i].toUpperCase().substring(0, 3)] = i; // Create Name functions. $D[names[i]] = $D[names[i].substring(0, 3)] = staticFunc(i); // Create Name instance functions. $P[names[i]] = $P[names[i].substring(0, 3)] = instanceFunc(i); } }; processTerms(dx, sdf, df); processTerms(mx, month_static_functions, month_instance_functions); // Create date element functions and plural date element functions used with Date (eg. day(), days(), months()). var ef = function (j) { return function () { // if the .second() function was called earlier, the _orient // has alread been added. Just return this and reset _isSecond. if (this._isSecond) { this._isSecond = false; return this; } if (this._same) { this._same = this._is = false; var o1 = this.toObject(), o2 = (arguments[0] || new Date()).toObject(), v = "", k = j.toLowerCase(); // the substr trick with -1 doesn't work in IE8 or less k = (k[k.length-1] === "s") ? k.substring(0,k.length-1) : k; for (var m = (px.length - 1); m > -1; m--) { v = px[m].toLowerCase(); if (o1[v] !== o2[v]) { return false; } if (k === v) { break; } } return true; } if (j.substring(j.length - 1) !== "s") { j += "s"; } if (this._move) { this._move = null; } return this["add" + j](this._orient); }; }; var nf = function (n) { return function () { this._dateElement = n; return this; }; }; for (var k = 0; k < px.length; k++) { de = px[k].toLowerCase(); if(de !== "weekday") { // Create date element functions and plural date element functions used with Date (eg. day(), days(), months()). $P[de] = $P[de + "s"] = ef(px[k]); // Create date element functions and plural date element functions used with Number (eg. day(), days(), months()). $N[de] = $N[de + "s"] = nf(de + "s"); } } $P._ss = ef("Second"); var nthfn = function (n) { return function (dayOfWeek) { if (this._same) { return this._ss(arguments[0]); } if (dayOfWeek || dayOfWeek === 0) { return this.moveToNthOccurrence(dayOfWeek, n); } this._nth = n; // if the operator is 'second' add the _orient, then deal with it later... if (n === 2 && (dayOfWeek === undefined || dayOfWeek === null)) { this._isSecond = true; return this.addSeconds(this._orient); } return this; }; }; for (var l = 0; l < nth.length; l++) { $P[nth[l]] = (l === 0) ? nthfn(-1) : nthfn(l); } }()); (function () { "use strict"; Date.Parsing = { Exception: function (s) { this.message = "Parse error at '" + s.substring(0, 10) + " ...'"; } }; var $P = Date.Parsing; var dayOffsets = { standard: [0,31,59,90,120,151,181,212,243,273,304,334], leap: [0,31,60,91,121,152,182,213,244,274,305,335] }; $P.isLeapYear = function(year) { return ((year % 4 === 0) && (year % 100 !== 0)) || (year % 400 === 0); }; var utils = { multiReplace : function (str, hash ) { var key; for (key in hash) { if (Object.prototype.hasOwnProperty.call(hash, key)) { var regex; if (typeof hash[key] === "function") { } else { regex = (hash[key] instanceof RegExp) ? hash[key] : new RegExp(hash[key], "g"); } str = str.replace(regex, key); } } return str; }, getDayOfYearFromWeek : function (obj) { var d, jan4, offset; obj.weekDay = (!obj.weekDay && obj.weekDay !== 0) ? 1 : obj.weekDay; d = new Date(obj.year, 0, 4); jan4 = d.getDay() === 0 ? 7 : d.getDay(); // JS is 0 indexed on Sunday. offset = jan4+3; obj.dayOfYear = ((obj.week * 7) + (obj.weekDay === 0 ? 7 : obj.weekDay))-offset; return obj; }, getDayOfYear : function (obj, dayOffset) { if (!obj.dayOfYear) { obj = utils.getDayOfYearFromWeek(obj); } for (var i=0;i <= dayOffset.length;i++) { if (obj.dayOfYear < dayOffset[i] || i === dayOffset.length) { obj.day = obj.day ? obj.day : (obj.dayOfYear - dayOffset[i-1]); break; } else { obj.month = i; } } return obj; }, adjustForTimeZone : function (obj, date) { var offset; if (obj.zone.toUpperCase() === "Z" || (obj.zone_hours === 0 && obj.zone_minutes === 0)) { // it's UTC/GML so work out the current timeszone offset offset = -date.getTimezoneOffset(); } else { offset = (obj.zone_hours*60) + (obj.zone_minutes || 0); if (obj.zone_sign === "+") { offset *= -1; } offset -= date.getTimezoneOffset(); } date.setMinutes(date.getMinutes()+offset); return date; }, setDefaults : function (obj) { obj.year = obj.year || Date.today().getFullYear(); obj.hours = obj.hours || 0; obj.minutes = obj.minutes || 0; obj.seconds = obj.seconds || 0; obj.milliseconds = obj.milliseconds || 0; if (!(!obj.month && (obj.week || obj.dayOfYear))) { // if we have a month, or if we don't but don't have the day calculation data obj.month = obj.month || 0; obj.day = obj.day || 1; } return obj; }, dataNum: function (data, mod, explict, postProcess) { var dataNum = data*1; if (mod) { if (postProcess) { return data ? mod(data)*1 : data; } else { return data ? mod(dataNum) : data; } } else if (!explict){ return data ? dataNum : data; } else { return (data && typeof data !== "undefined") ? dataNum : data; } }, timeDataProcess: function (obj) { var timeObj = {}; for (var x in obj.data) { if (obj.data.hasOwnProperty(x)) { timeObj[x] = obj.ignore[x] ? obj.data[x] : utils.dataNum(obj.data[x], obj.mods[x], obj.explict[x], obj.postProcess[x]); } } if (obj.data.secmins) { obj.data.secmins = obj.data.secmins.replace(",", ".") * 60; if (!timeObj.minutes) { timeObj.minutes = obj.data.secmins; } else if (!timeObj.seconds) { timeObj.seconds = obj.data.secmins; } delete obj.secmins; } return timeObj; }, buildTimeObjectFromData: function (data) { var time = utils.timeDataProcess({ data: { year : data[1], month : data[5], day : data[7], week : data[8], dayOfYear : data[10], hours : data[15], zone_hours : data[23], zone_minutes : data[24], zone : data[21], zone_sign : data[22], weekDay : data[9], minutes: data[16], seconds: data[19], milliseconds: data[20], secmins: data[18] }, mods: { month: function(data) { return data-1; }, weekDay: function (data) { data = Math.abs(data); return (data === 7 ? 0 : data); }, minutes: function (data) { return data.replace(":",""); }, seconds: function (data) { return Math.floor( (data.replace(":","").replace(",","."))*1 ); }, milliseconds: function (data) { return (data.replace(",",".")*1000); } }, postProcess: { minutes: true, seconds: true, milliseconds: true }, explict: { zone_hours: true, zone_minutes: true }, ignore: { zone: true, zone_sign: true, secmins: true } }); return time; }, addToHash: function (hash, keys, data) { keys = keys; data = data; var len = keys.length; for (var i = 0; i < len; i++) { hash[keys[i]] = data[i]; } return hash; }, combineRegex: function (r1, r2) { return new RegExp("(("+r1.source+")\\s("+r2.source+"))"); }, getDateNthString: function(add, last, inc){ if (add) { return Date.today().addDays(inc).toString("d"); } else if (last) { return Date.today().last()[inc]().toString("d"); } }, buildRegexData: function (array) { var arr = []; var len = array.length; for (var i=0; i < len; i++) { if (Object.prototype.toString.call(array[i]) === '[object Array]') { // oldIE compat version of Array.isArray arr.push(this.combineRegex(array[i][0], array[i][1])); } else { arr.push(array[i]); } } return arr; } }; $P.processTimeObject = function (obj) { var date, dayOffset; utils.setDefaults(obj); dayOffset = ($P.isLeapYear(obj.year)) ? dayOffsets.leap : dayOffsets.standard; if (!obj.month && (obj.week || obj.dayOfYear)) { utils.getDayOfYear(obj, dayOffset); } else { obj.dayOfYear = dayOffset[obj.month] + obj.day; } date = new Date(obj.year, obj.month, obj.day, obj.hours, obj.minutes, obj.seconds, obj.milliseconds); if (obj.zone) { utils.adjustForTimeZone(obj, date); // adjust (and calculate) for timezone } return date; }; $P.ISO = { regex : /^([\+-]?\d{4}(?!\d{2}\b))((-?)((0[1-9]|1[0-2])(\3([12]\d|0[1-9]|3[01]))?|W([0-4]\d|5[0-3])(-?[1-7])?|(00[1-9]|0[1-9]\d|[12]\d{2}|3([0-5]\d|6[1-6])))([T\s]((([01]\d|2[0-4])((:?)[0-5]\d)?|24\:?00)([\.,]\d+(?!:))?)?(\17[0-5]\d([\.,]\d+)?)?\s?([zZ]|([\+-])([01]\d|2[0-3]):?([0-5]\d)?)?)?)?$/, parse : function (s) { var time, data = s.match(this.regex); if (!data || !data.length) { return null; } time = utils.buildTimeObjectFromData(data); if (!time.year || (!time.year && (!time.month && !time.day) && (!time.week && !time.dayOfYear)) ) { return null; } return $P.processTimeObject(time); } }; $P.Numeric = { isNumeric: function (e){return!isNaN(parseFloat(e))&&isFinite(e);}, regex: /\b([0-1]?[0-9])([0-3]?[0-9])([0-2]?[0-9]?[0-9][0-9])\b/i, parse: function (s) { var data, i, time = {}, order = Date.CultureInfo.dateElementOrder.split(""); if (!(this.isNumeric(s)) || // if it's non-numeric OR (s[0] === "+" && s[0] === "-")) { // It's an arithmatic string (eg +/-1000) return null; } if (s.length < 5 && s.indexOf(".") < 0 && s.indexOf("/") < 0) { // assume it's just a year. time.year = s; return $P.processTimeObject(time); } data = s.match(this.regex); if (!data || !data.length) { return null; } for (i=0; i < order.length; i++) { switch(order[i]) { case "d": time.day = data[i+1]; break; case "m": time.month = (data[i+1]-1); break; case "y": time.year = data[i+1]; break; } } return $P.processTimeObject(time); } }; $P.Normalizer = { regexData: function () { var $R = Date.CultureInfo.regexPatterns; return utils.buildRegexData([ $R.tomorrow, $R.yesterday, [$R.past, $R.mon], [$R.past, $R.tue], [$R.past, $R.wed], [$R.past, $R.thu], [$R.past, $R.fri], [$R.past, $R.sat], [$R.past, $R.sun] ]); }, basicReplaceHash : function() { var $R = Date.CultureInfo.regexPatterns; return { "January": $R.jan.source, "February": $R.feb, "March": $R.mar, "April": $R.apr, "May": $R.may, "June": $R.jun, "July": $R.jul, "August": $R.aug, "September": $R.sep, "October": $R.oct, "November": $R.nov, "December": $R.dec, "": /\bat\b/gi, " ": /\s{2,}/, "am": $R.inTheMorning, "9am": $R.thisMorning, "pm": $R.inTheEvening, "7pm":$R.thisEvening }; }, keys : function(){ return [ utils.getDateNthString(true, false, 1), // tomorrow utils.getDateNthString(true, false, -1), // yesterday utils.getDateNthString(false, true, "monday"), //last mon utils.getDateNthString(false, true, "tuesday"), //last tues utils.getDateNthString(false, true, "wednesday"), //last wed utils.getDateNthString(false, true, "thursday"), //last thurs utils.getDateNthString(false, true, "friday"), //last fri utils.getDateNthString(false, true, "saturday"), //last sat utils.getDateNthString(false, true, "sunday") //last sun ]; }, buildRegexFunctions: function () { var $R = Date.CultureInfo.regexPatterns; var __ = Date.i18n.__; var tomorrowRE = new RegExp("(\\b\\d\\d?("+__("AM")+"|"+__("PM")+")? )("+$R.tomorrow.source.slice(1)+")", "i"); // adapted tomorrow regex for AM PM relative dates var todayRE = new RegExp($R.today.source + "(?!\\s*([+-]))\\b"); // today, but excludes the math operators (eg "today + 2h") this.replaceFuncs = [ [todayRE, function (full) { return (full.length > 1) ? Date.today().toString("d") : full; }], [tomorrowRE, function(full, m1) { var t = Date.today().addDays(1).toString("d"); return (t + " " + m1); }], [$R.amThisMorning, function(str, am){return am;}], [$R.pmThisEvening, function(str, pm){return pm;}] ]; }, buildReplaceData: function () { this.buildRegexFunctions(); this.replaceHash = utils.addToHash(this.basicReplaceHash(), this.keys(), this.regexData()); }, stringReplaceFuncs: function (s) { for (var i=0; i < this.replaceFuncs.length; i++) { s = s.replace(this.replaceFuncs[i][0], this.replaceFuncs[i][1]); } return s; }, parse: function (s) { s = this.stringReplaceFuncs(s); s = utils.multiReplace(s, this.replaceHash); try { var n = s.split(/([\s\-\.\,\/\x27]+)/); if (n.length === 3 && $P.Numeric.isNumeric(n[0]) && $P.Numeric.isNumeric(n[2]) && (n[2].length >= 4)) { // ok, so we're dealing with x/year. But that's not a full date. // This fixes wonky dateElementOrder parsing when set to dmy order. if (Date.CultureInfo.dateElementOrder[0] === "d") { s = "1/" + n[0] + "/" + n[2]; // set to 1st of month and normalize the seperator } } } catch (e) {} return s; } }; $P.Normalizer.buildReplaceData(); }()); (function () { var $P = Date.Parsing; var _ = $P.Operators = { // // Tokenizers // rtoken: function (r) { // regex token return function (s) { var mx = s.match(r); if (mx) { return ([ mx[0], s.substring(mx[0].length) ]); } else { throw new $P.Exception(s); } }; }, token: function () { // whitespace-eating token return function (s) { return _.rtoken(new RegExp("^\\s*" + s + "\\s*"))(s); }; }, stoken: function (s) { // string token return _.rtoken(new RegExp("^" + s)); }, // Atomic Operators until: function (p) { return function (s) { var qx = [], rx = null; while (s.length) { try { rx = p.call(this, s); } catch (e) { qx.push(rx[0]); s = rx[1]; continue; } break; } return [ qx, s ]; }; }, many: function (p) { return function (s) { var rx = [], r = null; while (s.length) { try { r = p.call(this, s); } catch (e) { return [ rx, s ]; } rx.push(r[0]); s = r[1]; } return [ rx, s ]; }; }, // generator operators -- see below optional: function (p) { return function (s) { var r = null; try { r = p.call(this, s); } catch (e) { return [ null, s ]; } return [ r[0], r[1] ]; }; }, not: function (p) { return function (s) { try { p.call(this, s); } catch (e) { return [null, s]; } throw new $P.Exception(s); }; }, ignore: function (p) { return p ? function (s) { var r = null; r = p.call(this, s); return [null, r[1]]; } : null; }, product: function () { var px = arguments[0], qx = Array.prototype.slice.call(arguments, 1), rx = []; for (var i = 0 ; i < px.length ; i++) { rx.push(_.each(px[i], qx)); } return rx; }, cache: function (rule) { var cache = {}, cache_length = 0, cache_keys = [], CACHE_MAX = Date.Config.CACHE_MAX || 100000, r = null; var cacheCheck = function () { if (cache_length === CACHE_MAX) { // kill several keys, don't want to have to do this all the time... for (var i=0; i < 10; i++) { var key = cache_keys.shift(); if (key) { delete cache[key]; cache_length--; } } } }; return function (s) { cacheCheck(); try { r = cache[s] = (cache[s] || rule.call(this, s)); } catch (e) { r = cache[s] = e; } cache_length++; cache_keys.push(s); if (r instanceof $P.Exception) { throw r; } else { return r; } }; }, // vector operators -- see below any: function () { var px = arguments; return function (s) { var r = null; for (var i = 0; i < px.length; i++) { if (px[i] == null) { continue; } try { r = (px[i].call(this, s)); } catch (e) { r = null; } if (r) { return r; } } throw new $P.Exception(s); }; }, each: function () { var px = arguments; return function (s) { var rx = [], r = null; for (var i = 0; i < px.length ; i++) { if (px[i] == null) { continue; } try { r = (px[i].call(this, s)); } catch (e) { throw new $P.Exception(s); } rx.push(r[0]); s = r[1]; } return [ rx, s]; }; }, all: function () { var px = arguments, _ = _; return _.each(_.optional(px)); }, // delimited operators sequence: function (px, d, c) { d = d || _.rtoken(/^\s*/); c = c || null; if (px.length === 1) { return px[0]; } return function (s) { var r = null, q = null; var rx = []; for (var i = 0; i < px.length ; i++) { try { r = px[i].call(this, s); } catch (e) { break; } rx.push(r[0]); try { q = d.call(this, r[1]); } catch (ex) { q = null; break; } s = q[1]; } if (!r) { throw new $P.Exception(s); } if (q) { throw new $P.Exception(q[1]); } if (c) { try { r = c.call(this, r[1]); } catch (ey) { throw new $P.Exception(r[1]); } } return [ rx, (r?r[1]:s) ]; }; }, // // Composite Operators // between: function (d1, p, d2) { d2 = d2 || d1; var _fn = _.each(_.ignore(d1), p, _.ignore(d2)); return function (s) { var rx = _fn.call(this, s); return [[rx[0][0], r[0][2]], rx[1]]; }; }, list: function (p, d, c) { d = d || _.rtoken(/^\s*/); c = c || null; return (p instanceof Array ? _.each(_.product(p.slice(0, -1), _.ignore(d)), p.slice(-1), _.ignore(c)) : _.each(_.many(_.each(p, _.ignore(d))), px, _.ignore(c))); }, set: function (px, d, c) { d = d || _.rtoken(/^\s*/); c = c || null; return function (s) { // r is the current match, best the current 'best' match // which means it parsed the most amount of input var r = null, p = null, q = null, rx = null, best = [[], s], last = false; // go through the rules in the given set for (var i = 0; i < px.length ; i++) { // last is a flag indicating whether this must be the last element // if there is only 1 element, then it MUST be the last one q = null; p = null; r = null; last = (px.length === 1); // first, we try simply to match the current pattern // if not, try the next pattern try { r = px[i].call(this, s); } catch (e) { continue; } // since we are matching against a set of elements, the first // thing to do is to add r[0] to matched elements rx = [[r[0]], r[1]]; // if we matched and there is still input to parse and // we don't already know this is the last element, // we're going to next check for the delimiter ... // if there's none, or if there's no input left to parse // than this must be the last element after all ... if (r[1].length > 0 && ! last) { try { q = d.call(this, r[1]); } catch (ex) { last = true; } } else { last = true; } // if we parsed the delimiter and now there's no more input, // that means we shouldn't have parsed the delimiter at all // so don't update r and mark this as the last element ... if (!last && q[1].length === 0) { last = true; } // so, if this isn't the last element, we're going to see if // we can get any more matches from the remaining (unmatched) // elements ... if (!last) { // build a list of the remaining rules we can match against, // i.e., all but the one we just matched against var qx = []; for (var j = 0; j < px.length ; j++) { if (i !== j) { qx.push(px[j]); } } // now invoke recursively set with the remaining input // note that we don't include the closing delimiter ... // we'll check for that ourselves at the end p = _.set(qx, d).call(this, q[1]); // if we got a non-empty set as a result ... // (otw rx already contains everything we want to match) if (p[0].length > 0) { // update current result, which is stored in rx ... // basically, pick up the remaining text from p[1] // and concat the result from p[0] so that we don't // get endless nesting ... rx[0] = rx[0].concat(p[0]); rx[1] = p[1]; } } // at this point, rx either contains the last matched element // or the entire matched set that starts with this element. // now we just check to see if this variation is better than // our best so far, in terms of how much of the input is parsed if (rx[1].length < best[1].length) { best = rx; } // if we've parsed all the input, then we're finished if (best[1].length === 0) { break; } } // so now we've either gone through all the patterns trying them // as the initial match; or we found one that parsed the entire // input string ... // if best has no matches, just return empty set ... if (best[0].length === 0) { return best; } // if a closing delimiter is provided, then we have to check it also if (c) { // we try this even if there is no remaining input because the pattern // may well be optional or match empty input ... try { q = c.call(this, best[1]); } catch (ey) { throw new $P.Exception(best[1]); } // it parsed ... be sure to update the best match remaining input best[1] = q[1]; } // if we're here, either there was no closing delimiter or we parsed it // so now we have the best match; just return it! return best; }; }, forward: function (gr, fname) { return function (s) { return gr[fname].call(this, s); }; }, // // Translation Operators // replace: function (rule, repl) { return function (s) { var r = rule.call(this, s); return [repl, r[1]]; }; }, process: function (rule, fn) { return function (s) { var r = rule.call(this, s); return [fn.call(this, r[0]), r[1]]; }; }, min: function (min, rule) { return function (s) { var rx = rule.call(this, s); if (rx[0].length < min) { throw new $P.Exception(s); } return rx; }; } }; // Generator Operators And Vector Operators // Generators are operators that have a signature of F(R) => R, // taking a given rule and returning another rule, such as // ignore, which parses a given rule and throws away the result. // Vector operators are those that have a signature of F(R1,R2,...) => R, // take a list of rules and returning a new rule, such as each. // Generator operators are converted (via the following _generator // function) into functions that can also take a list or array of rules // and return an array of new rules as though the function had been // called on each rule in turn (which is what actually happens). // This allows generators to be used with vector operators more easily. // Example: // each(ignore(foo, bar)) instead of each(ignore(foo), ignore(bar)) // This also turns generators into vector operators, which allows // constructs like: // not(cache(foo, bar)) var _generator = function (op) { function gen() { var args = null, rx = [], px, i; if (arguments.length > 1) { args = Array.prototype.slice.call(arguments); } else if (arguments[0] instanceof Array) { args = arguments[0]; } if (args) { px = args.shift(); if (px.length > 0) { args.unshift(px[i]); rx.push(op.apply(null, args)); args.shift(); return rx; } } else { return op.apply(null, arguments); } } return gen; }; var gx = "optional not ignore cache".split(/\s/); for (var i = 0 ; i < gx.length ; i++) { _[gx[i]] = _generator(_[gx[i]]); } var _vector = function (op) { return function () { if (arguments[0] instanceof Array) { return op.apply(null, arguments[0]); } else { return op.apply(null, arguments); } }; }; var vx = "each any all".split(/\s/); for (var j = 0 ; j < vx.length ; j++) { _[vx[j]] = _vector(_[vx[j]]); } }()); (function () { var $D = Date; var flattenAndCompact = function (ax) { var rx = []; for (var i = 0; i < ax.length; i++) { if (ax[i] instanceof Array) { rx = rx.concat(flattenAndCompact(ax[i])); } else { if (ax[i]) { rx.push(ax[i]); } } } return rx; }; var parseMeridian = function () { if (this.meridian && (this.hour || this.hour === 0)) { if (this.meridian === "a" && this.hour > 11 && Date.Config.strict24hr){ throw "Invalid hour and meridian combination"; } else if (this.meridian === "p" && this.hour < 12 && Date.Config.strict24hr){ throw "Invalid hour and meridian combination"; } else if (this.meridian === "p" && this.hour < 12) { this.hour = this.hour + 12; } else if (this.meridian === "a" && this.hour === 12) { this.hour = 0; } } }; var setDefaults = function () { var now = new Date(); if ((this.hour || this.minute) && (!this.month && !this.year && !this.day)) { this.day = now.getDate(); } if (!this.year) { this.year = now.getFullYear(); } if (!this.month && this.month !== 0) { this.month = now.getMonth(); } if (!this.day) { this.day = 1; } if (!this.hour) { this.hour = 0; } if (!this.minute) { this.minute = 0; } if (!this.second) { this.second = 0; } if (!this.millisecond) { this.millisecond = 0; } }; var finishUtils = { getToday: function () { if (this.now || "hour minute second".indexOf(this.unit) !== -1) { return new Date(); } else { return $D.today(); } }, setDaysFromWeekday: function (today, orient){ var gap; orient = orient || 1; this.unit = "day"; gap = ($D.getDayNumberFromName(this.weekday) - today.getDay()); this.days = gap ? ((gap + (orient * 7)) % 7) : (orient * 7); return this; }, setMonthsFromMonth: function (today, orient) { var gap; orient = orient || 1; this.unit = "month"; gap = (this.month - today.getMonth()); this.months = gap ? ((gap + (orient * 12)) % 12) : (orient * 12); this.month = null; return this; }, setDMYFromWeekday: function () { var d = Date[this.weekday](); this.day = d.getDate(); if (!this.month) { this.month = d.getMonth(); } this.year = d.getFullYear(); return this; }, setUnitValue: function (orient) { if (!this.value && this.operator && this.operator !== null && this[this.unit + "s"] && this[this.unit + "s"] !== null) { this[this.unit + "s"] = this[this.unit + "s"] + ((this.operator === "add") ? 1 : -1) + (this.value||0) * orient; } else if (this[this.unit + "s"] == null || this.operator != null) { if (!this.value) { this.value = 1; } this[this.unit + "s"] = this.value * orient; } }, generateDateFromWeeks: function () { var weekday = (this.weekday !== undefined) ? this.weekday : "today"; var d = Date[weekday]().addWeeks(this.weeks); if (this.now) { d.setTimeToNow(); } return d; } }; $D.Translator = { hour: function (s) { return function () { this.hour = Number(s); }; }, minute: function (s) { return function () { this.minute = Number(s); }; }, second: function (s) { return function () { this.second = Number(s); }; }, /* for ss.s format */ secondAndMillisecond: function (s) { return function () { var mx = s.match(/^([0-5][0-9])\.([0-9]{1,3})/); this.second = Number(mx[1]); this.millisecond = Number(mx[2]); }; }, meridian: function (s) { return function () { this.meridian = s.slice(0, 1).toLowerCase(); }; }, timezone: function (s) { return function () { var n = s.replace(/[^\d\+\-]/g, ""); if (n.length) { this.timezoneOffset = Number(n); } else { this.timezone = s.toLowerCase(); } }; }, day: function (x) { var s = x[0]; return function () { this.day = Number(s.match(/\d+/)[0]); if (this.day < 1) { throw "invalid day"; } }; }, month: function (s) { return function () { this.month = (s.length === 3) ? "jan feb mar apr may jun jul aug sep oct nov dec".indexOf(s)/4 : Number(s) - 1; if (this.month < 0) { throw "invalid month"; } }; }, year: function (s) { return function () { var n = Number(s); this.year = ((s.length > 2) ? n : (n + (((n + 2000) < Date.CultureInfo.twoDigitYearMax) ? 2000 : 1900))); }; }, rday: function (s) { return function () { switch (s) { case "yesterday": this.days = -1; break; case "tomorrow": this.days = 1; break; case "today": this.days = 0; break; case "now": this.days = 0; this.now = true; break; } }; }, finishExact: function (x) { var d; x = (x instanceof Array) ? x : [x]; for (var i = 0 ; i < x.length ; i++) { if (x[i]) { x[i].call(this); } } setDefaults.call(this); parseMeridian.call(this); if (this.day > $D.getDaysInMonth(this.year, this.month)) { throw new RangeError(this.day + " is not a valid value for days."); } d = new Date(this.year, this.month, this.day, this.hour, this.minute, this.second, this.millisecond); if (this.year < 100) { d.setFullYear(this.year); // means years less that 100 are process correctly. JS will parse it otherwise as 1900-1999. } if (this.timezone) { d.set({ timezone: this.timezone }); } else if (this.timezoneOffset) { d.set({ timezoneOffset: this.timezoneOffset }); } return d; }, finish: function (x) { var today, expression, orient, temp; x = (x instanceof Array) ? flattenAndCompact(x) : [ x ]; if (x.length === 0) { return null; } for (var i = 0 ; i < x.length ; i++) { if (typeof x[i] === "function") { x[i].call(this); } } if (this.now && !this.unit && !this.operator) { return new Date(); } else { today = finishUtils.getToday.call(this); } expression = !!(this.days && this.days !== null || this.orient || this.operator); orient = ((this.orient === "past" || this.operator === "subtract") ? -1 : 1); if (this.month && this.unit === "week") { this.value = this.month + 1; delete this.month; delete this.day; } if ((this.month || this.month === 0) && "year day hour minute second".indexOf(this.unit) !== -1) { if (!this.value) { this.value = this.month + 1; } this.month = null; expression = true; } if (!expression && this.weekday && !this.day && !this.days) { finishUtils.setDMYFromWeekday.call(this); } if (expression && this.weekday && this.unit !== "month" && this.unit !== "week") { finishUtils.setDaysFromWeekday.call(this, today, orient); } if (this.weekday && this.unit !== "week" && !this.day && !this.days) { temp = Date[this.weekday](); this.day = temp.getDate(); if (temp.getMonth() !== today.getMonth()) { this.month = temp.getMonth(); } } if (this.month && this.unit === "day" && this.operator) { if (!this.value) { this.value = (this.month + 1); } this.month = null; } if (this.value != null && this.month != null && this.year != null) { this.day = this.value * 1; } if (this.month && !this.day && this.value) { today.set({ day: this.value * 1 }); if (!expression) { this.day = this.value * 1; } } if (!this.month && this.value && this.unit === "month" && !this.now) { this.month = this.value; expression = true; } if (expression && (this.month || this.month === 0) && this.unit !== "year") { finishUtils.setMonthsFromMonth.call(this, today, orient); } if (!this.unit) { this.unit = "day"; } finishUtils.setUnitValue.call(this, orient); parseMeridian.call(this); if ((this.month || this.month === 0) && !this.day) { this.day = 1; } if (!this.orient && !this.operator && this.unit === "week" && this.value && !this.day && !this.month) { return Date.today().setWeek(this.value); } if (this.unit === "week" && this.weeks && !this.day && !this.month) { return finishUtils.generateDateFromWeeks.call(this); } if (expression && this.timezone && this.day && this.days) { this.day = this.days; } if (expression){ today.add(this); } else { today.set(this); } if (this.timezone) { this.timezone = this.timezone.toUpperCase(); var offset = $D.getTimezoneOffset(this.timezone); var timezone; if (today.hasDaylightSavingTime()) { // lets check that we're being sane with timezone setting timezone = $D.getTimezoneAbbreviation(offset, today.isDaylightSavingTime()); if (timezone !== this.timezone) { // bugger, we're in a place where things like EST vs EDT matters. if (today.isDaylightSavingTime()) { today.addHours(-1); } else { today.addHours(1); } } } today.setTimezoneOffset(offset); } return today; } }; }()); (function () { var $D = Date; $D.Grammar = {}; var _ = $D.Parsing.Operators, g = $D.Grammar, t = $D.Translator, _fn; // Allow rolling up into general purpose rules _fn = function () { return _.each(_.any.apply(null, arguments), _.not(g.ctoken2("timeContext"))); }; g.datePartDelimiter = _.rtoken(/^([\s\-\.\,\/\x27]+)/); g.timePartDelimiter = _.stoken(":"); g.whiteSpace = _.rtoken(/^\s*/); g.generalDelimiter = _.rtoken(/^(([\s\,]|at|@|on)+)/); var _C = {}; g.ctoken = function (keys) { var fn = _C[keys]; if (! fn) { var c = Date.CultureInfo.regexPatterns; var kx = keys.split(/\s+/), px = []; for (var i = 0; i < kx.length ; i++) { px.push(_.replace(_.rtoken(c[kx[i]]), kx[i])); } fn = _C[keys] = _.any.apply(null, px); } return fn; }; g.ctoken2 = function (key) { return _.rtoken(Date.CultureInfo.regexPatterns[key]); }; var cacheProcessRtoken = function (key, token, type, eachToken) { if (eachToken) { g[key] = _.cache(_.process(_.each(_.rtoken(token),_.optional(g.ctoken2(eachToken))), type)); } else { g[key] = _.cache(_.process(_.rtoken(token), type)); } }; var cacheProcessCtoken = function (token, type) { return _.cache(_.process(g.ctoken2(token), type)); }; var _F = {}; //function cache var _get = function (f) { _F[f] = (_F[f] || g.format(f)[0]); return _F[f]; }; g.allformats = function (fx) { var rx = []; if (fx instanceof Array) { for (var i = 0; i < fx.length; i++) { rx.push(_get(fx[i])); } } else { rx.push(_get(fx)); } return rx; }; g.formats = function (fx) { if (fx instanceof Array) { var rx = []; for (var i = 0 ; i < fx.length ; i++) { rx.push(_get(fx[i])); } return _.any.apply(null, rx); } else { return _get(fx); } }; var grammarFormats = { timeFormats: function(){ var i, RTokenKeys = [ "h", "hh", "H", "HH", "m", "mm", "s", "ss", "ss.s", "z", "zz" ], RToken = [ /^(0[0-9]|1[0-2]|[1-9])/, /^(0[0-9]|1[0-2])/, /^([0-1][0-9]|2[0-3]|[0-9])/, /^([0-1][0-9]|2[0-3])/, /^([0-5][0-9]|[0-9])/, /^[0-5][0-9]/, /^([0-5][0-9]|[0-9])/, /^[0-5][0-9]/, /^[0-5][0-9]\.[0-9]{1,3}/, /^((\+|\-)\s*\d\d\d\d)|((\+|\-)\d\d\:?\d\d)/, /^((\+|\-)\s*\d\d\d\d)|((\+|\-)\d\d\:?\d\d)/ ], tokens = [ t.hour, t.hour, t.hour, t.hour, t.minute, t.minute, t.second, t.second, t.secondAndMillisecond, t.timezone, t.timezone ]; for (i=0; i < RTokenKeys.length; i++) { cacheProcessRtoken(RTokenKeys[i], RToken[i], tokens[i]); } g.hms = _.cache(_.sequence([g.H, g.m, g.s], g.timePartDelimiter)); g.t = cacheProcessCtoken("shortMeridian", t.meridian); g.tt = cacheProcessCtoken("longMeridian", t.meridian); g.zzz = cacheProcessCtoken("timezone", t.timezone); g.timeSuffix = _.each(_.ignore(g.whiteSpace), _.set([ g.tt, g.zzz ])); g.time = _.each(_.optional(_.ignore(_.stoken("T"))), g.hms, g.timeSuffix); }, dateFormats: function () { // pre-loaded rules for different date part order preferences var _setfn = function () { return _.set(arguments, g.datePartDelimiter); }; var i, RTokenKeys = [ "d", "dd", "M", "MM", "y", "yy", "yyy", "yyyy" ], RToken = [ /^([0-2]\d|3[0-1]|\d)/, /^([0-2]\d|3[0-1])/, /^(1[0-2]|0\d|\d)/, /^(1[0-2]|0\d)/, /^(\d+)/, /^(\d\d)/, /^(\d\d?\d?\d?)/, /^(\d\d\d\d)/ ], tokens = [ t.day, t.day, t.month, t.month, t.year, t.year, t.year, t.year ], eachToken = [ "ordinalSuffix", "ordinalSuffix" ]; for (i=0; i < RTokenKeys.length; i++) { cacheProcessRtoken(RTokenKeys[i], RToken[i], tokens[i], eachToken[i]); } g.MMM = g.MMMM = _.cache(_.process(g.ctoken("jan feb mar apr may jun jul aug sep oct nov dec"), t.month)); g.ddd = g.dddd = _.cache(_.process(g.ctoken("sun mon tue wed thu fri sat"), function (s) { return function () { this.weekday = s; }; } )); g.day = _fn(g.d, g.dd); g.month = _fn(g.M, g.MMM); g.year = _fn(g.yyyy, g.yy); g.mdy = _setfn(g.ddd, g.month, g.day, g.year); g.ymd = _setfn(g.ddd, g.year, g.month, g.day); g.dmy = _setfn(g.ddd, g.day, g.month, g.year); g.date = function (s) { return ((g[Date.CultureInfo.dateElementOrder] || g.mdy).call(this, s)); }; }, relative: function () { // relative date / time expressions g.orientation = _.process(g.ctoken("past future"), function (s) { return function () { this.orient = s; }; } ); g.operator = _.process(g.ctoken("add subtract"), function (s) { return function () { this.operator = s; }; } ); g.rday = _.process(g.ctoken("yesterday tomorrow today now"), t.rday); g.unit = _.process(g.ctoken("second minute hour day week month year"), function (s) { return function () { this.unit = s; }; } ); } }; g.buildGrammarFormats = function () { // these need to be rebuilt every time the language changes. _C = {}; grammarFormats.timeFormats(); grammarFormats.dateFormats(); grammarFormats.relative(); g.value = _.process(_.rtoken(/^([-+]?\d+)?(st|nd|rd|th)?/), function (s) { return function () { this.value = s.replace(/\D/g, ""); }; } ); g.expression = _.set([g.rday, g.operator, g.value, g.unit, g.orientation, g.ddd, g.MMM ]); g.format = _.process(_.many( _.any( // translate format specifiers into grammar rules _.process( _.rtoken(/^(dd?d?d?(?!e)|MM?M?M?|yy?y?y?|hh?|HH?|mm?|ss?|tt?|zz?z?)/), function (fmt) { if (g[fmt]) { return g[fmt]; } else { throw $D.Parsing.Exception(fmt); } } ), // translate separator tokens into token rules _.process(_.rtoken(/^[^dMyhHmstz]+/), // all legal separators function (s) { return _.ignore(_.stoken(s)); } ) ) ), // construct the parser ... function (rules) { return _.process(_.each.apply(null, rules), t.finishExact); } ); // starting rule for general purpose grammar g._start = _.process(_.set([ g.date, g.time, g.expression ], g.generalDelimiter, g.whiteSpace), t.finish); }; g.buildGrammarFormats(); // parsing date format specifiers - ex: "h:m:s tt" // this little guy will generate a custom parser based // on the format string, ex: g.format("h:m:s tt") // check for these formats first g._formats = g.formats([ "\"yyyy-MM-ddTHH:mm:ssZ\"", "yyyy-MM-ddTHH:mm:ss.sz", "yyyy-MM-ddTHH:mm:ssZ", "yyyy-MM-ddTHH:mm:ssz", "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-ddTHH:mmZ", "yyyy-MM-ddTHH:mmz", "yyyy-MM-ddTHH:mm", "ddd, MMM dd, yyyy H:mm:ss tt", "ddd MMM d yyyy HH:mm:ss zzz", "MMddyyyy", "ddMMyyyy", "Mddyyyy", "ddMyyyy", "Mdyyyy", "dMyyyy", "yyyy", "Mdyy", "dMyy", "d" ]); // real starting rule: tries selected formats first, // then general purpose rule g.start = function (s) { try { var r = g._formats.call({}, s); if (r[1].length === 0) { return r; } } catch (e) {} return g._start.call({}, s); }; }()); (function () { var $D = Date; /** * @desc Converts the specified string value into its JavaScript Date equivalent using CultureInfo specific format information. * * Example

	///////////
	// Dates //
	///////////

	// 15-Oct-2004
	var d1 = Date.parse("10/15/2004");

	// 15-Oct-2004
	var d1 = Date.parse("15-Oct-2004");

	// 15-Oct-2004
	var d1 = Date.parse("2004.10.15");

	//Fri Oct 15, 2004
	var d1 = Date.parse("Fri Oct 15, 2004");

	///////////
	// Times //
	///////////

	// Today at 10 PM.
	var d1 = Date.parse("10 PM");

	// Today at 10:30 PM.
	var d1 = Date.parse("10:30 P.M.");

	// Today at 6 AM.
	var d1 = Date.parse("06am");

	/////////////////////
	// Dates and Times //
	/////////////////////

	// 8-July-2004 @ 10:30 PM
	var d1 = Date.parse("July 8th, 2004, 10:30 PM");

	// 1-July-2004 @ 10:30 PM
	var d1 = Date.parse("2004-07-01T22:30:00");

	////////////////////
	// Relative Dates //
	////////////////////

	// Returns today's date. The string "today" is culture specific.
	var d1 = Date.parse("today");

	// Returns yesterday's date. The string "yesterday" is culture specific.
	var d1 = Date.parse("yesterday");

	// Returns the date of the next thursday.
	var d1 = Date.parse("Next thursday");

	// Returns the date of the most previous monday.
	var d1 = Date.parse("last monday");

	// Returns today's day + one year.
	var d1 = Date.parse("next year");

	///////////////
	// Date Math //
	///////////////

	// Today + 2 days
	var d1 = Date.parse("t+2");

	// Today + 2 days
	var d1 = Date.parse("today + 2 days");

	// Today + 3 months
	var d1 = Date.parse("t+3m");

	// Today - 1 year
	var d1 = Date.parse("today - 1 year");

	// Today - 1 year
	var d1 = Date.parse("t-1y"); 


	/////////////////////////////
	// Partial Dates and Times //
	/////////////////////////////

	// July 15th of this year.
	var d1 = Date.parse("July 15");

	// 15th day of current day and year.
	var d1 = Date.parse("15");

	// July 1st of current year at 10pm.
	var d1 = Date.parse("7/1 10pm");
	
* * @param {String} The string value to convert into a Date object [Required] * @return {Date} A Date object or null if the string cannot be converted into a Date. */ var parseUtils = { removeOrds: function (s) { ords = s.match(/\b(\d+)(?:st|nd|rd|th)\b/); // find ordinal matches s = ((ords && ords.length === 2) ? s.replace(ords[0], ords[1]) : s); return s; }, grammarParser: function (s) { var r = null; try { r = $D.Grammar.start.call({}, s.replace(/^\s*(\S*(\s+\S+)*)\s*$/, "$1")); } catch (e) { return null; } return ((r[1].length === 0) ? r[0] : null); }, nativeFallback: function(s) { var t; try { // ok we haven't parsed it, last ditch attempt with the built-in parser. t = Date._parse(s); return (t || t === 0) ? new Date(t) : null; } catch (e) { return null; } } }; function parse (s) { var d; if (!s) { return null; } if (s instanceof Date) { return s.clone(); } if (s.length >= 4 && s.charAt(0) !== "0" && s.charAt(0) !== "+"&& s.charAt(0) !== "-") { // ie: 2004 will pass, 0800 won't. // Start with specific formats d = $D.Parsing.ISO.parse(s) || $D.Parsing.Numeric.parse(s); } if (d instanceof Date && !isNaN(d.getTime())) { return d; } else { // find ordinal dates (1st, 3rd, 8th, etc and remove them as they cause parsing issues) s = $D.Parsing.Normalizer.parse(parseUtils.removeOrds(s)); d = parseUtils.grammarParser(s); if (d !== null) { return d; } else { return parseUtils.nativeFallback(s); } } } if (!$D._parse) { $D._parse = $D.parse; } $D.parse = parse; Date.getParseFunction = function (fx) { var fns = Date.Grammar.allformats(fx); return function (s) { var r = null; for (var i = 0; i < fns.length; i++) { try { r = fns[i].call({}, s); } catch (e) { continue; } if (r[1].length === 0) { return r[0]; } } return null; }; }; /** * Converts the specified string value into its JavaScript Date equivalent using the specified format {String} or formats {Array} and the CultureInfo specific format information. * The format of the string value must match one of the supplied formats exactly. * * Example

	// 15-Oct-2004
	var d1 = Date.parseExact("10/15/2004", "M/d/yyyy");

	// 15-Oct-2004
	var d1 = Date.parse("15-Oct-2004", "M-ddd-yyyy");

	// 15-Oct-2004
	var d1 = Date.parse("2004.10.15", "yyyy.MM.dd");

	// Multiple formats
	var d1 = Date.parseExact("10/15/2004", ["M/d/yyyy", "MMMM d, yyyy"]);
	
* * @param {String} The string value to convert into a Date object [Required]. * @param {Object} The expected format {String} or an array of expected formats {Array} of the date string [Required]. * @return {Date} A Date object or null if the string cannot be converted into a Date. */ $D.parseExact = function (s, fx) { return $D.getParseFunction(fx)(s); }; }()); (function () { var $D = Date, $P = $D.prototype, // $C = $D.CultureInfo, // not used atm p = function (s, l) { if (!l) { l = 2; } return ("000" + s).slice(l * -1); }; /** * Converts a PHP format string to Java/.NET format string. * A PHP format string can be used with ._format or .format. * A Java/.NET format string can be used with .toString(). * The .parseExact function will only accept a Java/.NET format string * * Example * var f1 = "%m/%d/%y" * var f2 = Date.normalizeFormat(f1); // "MM/dd/yy" * * new Date().format(f1); // "04/13/08" * new Date()._format(f1); // "04/13/08" * new Date().toString(f2); // "04/13/08" * * var date = Date.parseExact("04/13/08", f2); // Sun Apr 13 2008 * * @param {String} A PHP format string consisting of one or more format spcifiers. * @return {String} The PHP format converted to a Java/.NET format string. */ var normalizerSubstitutions = { "d" : "dd", "%d": "dd", "D" : "ddd", "%a": "ddd", "j" : "dddd", "l" : "dddd", "%A": "dddd", "S" : "S", "F" : "MMMM", "%B": "MMMM", "m" : "MM", "%m": "MM", "M" : "MMM", "%b": "MMM", "%h": "MMM", "n" : "M", "Y" : "yyyy", "%Y": "yyyy", "y" : "yy", "%y": "yy", "g" : "h", "%I": "h", "G" : "H", "h" : "hh", "H" : "HH", "%H": "HH", "i" : "mm", "%M": "mm", "s" : "ss", "%S": "ss", "%r": "hh:mm tt", "%R": "H:mm", "%T": "H:mm:ss", "%X": "t", "%x": "d", "%e": "d", "%D": "MM/dd/yy", "%n": "\\n", "%t": "\\t", "e" : "z", "T" : "z", "%z": "z", "%Z": "z", "Z" : "ZZ", "N" : "u", "w" : "u", "%w": "u", "W" : "W", "%V": "W" }; var normalizer = { substitutes: function (m) { return normalizerSubstitutions[m]; }, interpreted: function (m, x) { var y; switch (m) { case "%u": return x.getDay() + 1; case "z": return x.getOrdinalNumber(); case "%j": return p(x.getOrdinalNumber(), 3); case "%U": var d1 = x.clone().set({month: 0, day: 1}).addDays(-1).moveToDayOfWeek(0), d2 = x.clone().addDays(1).moveToDayOfWeek(0, -1); return (d2 < d1) ? "00" : p((d2.getOrdinalNumber() - d1.getOrdinalNumber()) / 7 + 1); case "%W": return p(x.getWeek()); case "t": return $D.getDaysInMonth(x.getFullYear(), x.getMonth()); case "o": case "%G": return x.setWeek(x.getISOWeek()).toString("yyyy"); case "%g": return x._format("%G").slice(-2); case "a": case "%p": return t("tt").toLowerCase(); case "A": return t("tt").toUpperCase(); case "u": return p(x.getMilliseconds(), 3); case "I": return (x.isDaylightSavingTime()) ? 1 : 0; case "O": return x.getUTCOffset(); case "P": y = x.getUTCOffset(); return y.substring(0, y.length - 2) + ":" + y.substring(y.length - 2); case "B": var now = new Date(); return Math.floor(((now.getHours() * 3600) + (now.getMinutes() * 60) + now.getSeconds() + (now.getTimezoneOffset() + 60) * 60) / 86.4); case "c": return x.toISOString().replace(/\"/g, ""); case "U": return $D.strtotime("now"); case "%c": return t("d") + " " + t("t"); case "%C": return Math.floor(x.getFullYear() / 100 + 1); } }, shouldOverrideDefaults: function (m) { switch (m) { case "%e": return true; default: return false; } }, parse: function (m, context) { var formatString, c = context || new Date(); formatString = normalizer.substitutes(m); if (formatString) { return formatString; } formatString = normalizer.interpreted(m, c); if (formatString) { return formatString; } else { return m; } } }; $D.normalizeFormat = function (format, context) { return format.replace(/(%|\\)?.|%%/g, function(t){ return normalizer.parse(t, context); }); }; /** * Format a local Unix timestamp according to locale settings * * Example: * Date.strftime("%m/%d/%y", new Date()); // "04/13/08" * Date.strftime("c", "2008-04-13T17:52:03Z"); // "04/13/08" * * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @param {Number|String} The number representing the number of seconds that have elapsed since January 1, 1970 (local time). * @return {String} A string representation of the current Date object. */ $D.strftime = function (format, time) { var d = Date.parse(time); return d._format(format); }; /** * Parse any textual datetime description into a Unix timestamp. * A Unix timestamp is the number of seconds that have elapsed since January 1, 1970 (midnight UTC/GMT). * * Example: * Date.strtotime("04/13/08"); // 1208044800 * Date.strtotime("1970-01-01T00:00:00Z"); // 0 * * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @param {Object} A string or date object. * @return {String} A string representation of the current Date object. */ $D.strtotime = function (time) { var d = $D.parse(time); return Math.round($D.UTC(d.getUTCFullYear(), d.getUTCMonth(), d.getUTCDate(), d.getUTCHours(), d.getUTCMinutes(), d.getUTCSeconds(), d.getUTCMilliseconds()) / 1000); }; /** * Converts the value of the current Date object to its equivalent string representation using a PHP/Unix style of date format specifiers. * Format Specifiers * Format Description Example * ------ --------------------------------------------------------------------------- ----------------------- * %a abbreviated weekday name according to the current localed "Mon" through "Sun" * %A full weekday name according to the current localed "Sunday" through "Saturday" * %b abbreviated month name according to the current localed "Jan" through "Dec" * %B full month name according to the current locale "January" through "December" * %c preferred date and time representation for the current locale "4/13/2008 12:33 PM" * %C century number (the year divided by 100 and truncated to an integer) "00" to "99" * %d day of the month as a decimal number "01" to "31" * %D same as %m/%d/%y "04/13/08" * %e day of the month as a decimal number, a single digit is preceded by a space "1" to "31" * %g like %G, but without the century "08" * %G The 4-digit year corresponding to the ISO week number (see %V). "2008" * This has the same format and value as %Y, except that if the ISO week number * belongs to the previous or next year, that year is used instead. * %h same as %b "Jan" through "Dec" * %H hour as a decimal number using a 24-hour clock. "00" to "23" * %I hour as a decimal number using a 12-hour clock. "01" to "12" * %j day of the year as a decimal number. "001" to "366" * %m month as a decimal number. "01" to "12" * %M minute as a decimal number. "00" to "59" * %n newline character "\n" * %p either "am" or "pm" according to the given time value, or the "am" or "pm" * corresponding strings for the current locale. * %r time in a.m. and p.m. notation "8:44 PM" * %R time in 24 hour notation "20:44" * %S second as a decimal number "00" to "59" * %t tab character "\t" * %T current time, equal to %H:%M:%S "12:49:11" * %u weekday as a decimal number ["1", "7"], with "1" representing Monday "1" to "7" * %U week number of the current year as a decimal number, starting with the "0" to ("52" or "53") * first Sunday as the first day of the first week * %V The ISO 8601:1988 week number of the current year as a decimal number, "00" to ("52" or "53") * range 01 to 53, where week 1 is the first week that has at least 4 days * in the current year, and with Monday as the first day of the week. * (Use %G or %g for the year component that corresponds to the week number * for the specified timestamp.) * %W week number of the current year as a decimal number, starting with the "00" to ("52" or "53") * first Monday as the first day of the first week * %w day of the week as a decimal, Sunday being "0" "0" to "6" * %x preferred date representation for the current locale without the time "4/13/2008" * %X preferred time representation for the current locale without the date "12:53:05" * %y year as a decimal number without a century "00" "99" * %Y year as a decimal number including the century "2008" * %Z time zone or name or abbreviation "UTC", "EST", "PST" * %z same as %Z * %% a literal "%" characters "%" * d Day of the month, 2 digits with leading zeros "01" to "31" * D A textual representation of a day, three letters "Mon" through "Sun" * j Day of the month without leading zeros "1" to "31" * l A full textual representation of the day of the week (lowercase "L") "Sunday" through "Saturday" * N ISO-8601 numeric representation of the day of the week (added in PHP 5.1.0) "1" (for Monday) through "7" (for Sunday) * S English ordinal suffix for the day of the month, 2 characters "st", "nd", "rd" or "th". Works well with j * w Numeric representation of the day of the week "0" (for Sunday) through "6" (for Saturday) * z The day of the year (starting from "0") "0" through "365" * W ISO-8601 week number of year, weeks starting on Monday "00" to ("52" or "53") * F A full textual representation of a month, such as January or March "January" through "December" * m Numeric representation of a month, with leading zeros "01" through "12" * M A short textual representation of a month, three letters "Jan" through "Dec" * n Numeric representation of a month, without leading zeros "1" through "12" * t Number of days in the given month "28" through "31" * L Whether it's a leap year "1" if it is a leap year, "0" otherwise * o ISO-8601 year number. This has the same value as Y, except that if the "2008" * ISO week number (W) belongs to the previous or next year, that year * is used instead. * Y A full numeric representation of a year, 4 digits "2008" * y A two digit representation of a year "08" * a Lowercase Ante meridiem and Post meridiem "am" or "pm" * A Uppercase Ante meridiem and Post meridiem "AM" or "PM" * B Swatch Internet time "000" through "999" * g 12-hour format of an hour without leading zeros "1" through "12" * G 24-hour format of an hour without leading zeros "0" through "23" * h 12-hour format of an hour with leading zeros "01" through "12" * H 24-hour format of an hour with leading zeros "00" through "23" * i Minutes with leading zeros "00" to "59" * s Seconds, with leading zeros "00" through "59" * u Milliseconds "54321" * e Timezone identifier "UTC", "EST", "PST" * I Whether or not the date is in daylight saving time (uppercase i) "1" if Daylight Saving Time, "0" otherwise * O Difference to Greenwich time (GMT) in hours "+0200", "-0600" * P Difference to Greenwich time (GMT) with colon between hours and minutes "+02:00", "-06:00" * T Timezone abbreviation "UTC", "EST", "PST" * Z Timezone offset in seconds. The offset for timezones west of UTC is "-43200" through "50400" * always negative, and for those east of UTC is always positive. * c ISO 8601 date "2004-02-12T15:19:21+00:00" * r RFC 2822 formatted date "Thu, 21 Dec 2000 16:01:07 +0200" * U Seconds since the Unix Epoch (January 1 1970 00:00:00 GMT) "0" * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @return {String} A string representation of the current Date object. */ var formatReplace = function (context) { return function (m) { var formatString, override = false; if (m.charAt(0) === "\\" || m.substring(0, 2) === "%%") { return m.replace("\\", "").replace("%%", "%"); } override = normalizer.shouldOverrideDefaults(m); formatString = $D.normalizeFormat(m, context); if (formatString) { return context.toString(formatString, override); } }; }; $P._format = function (format) { var formatter = formatReplace(this); if (!format) { return this._toString(); } else { return format.replace(/(%|\\)?.|%%/g, formatter); } }; if (!$P.format) { $P.format = $P._format; } }()); (function () { "use strict"; var gFn = function (attr) { return function () { return this[attr]; }; }; var sFn = function (attr) { return function (val) { this[attr] = val; return this; }; }; var attrs = ["years", "months", "days", "hours", "minutes", "seconds", "milliseconds"]; var addSetFuncs = function (context, attrs) { for (var i = 0; i < attrs.length ; i++) { var $a = attrs[i], $b = $a.slice(0, 1).toUpperCase() + $a.slice(1); context.prototype[$a] = 0; context.prototype["get" + $b] = gFn($a); context.prototype["set" + $b] = sFn($a); } }; /** * new TimeSpan(milliseconds); * new TimeSpan(days, hours, minutes, seconds); * new TimeSpan(days, hours, minutes, seconds, milliseconds); */ var TimeSpan = function (days, hours, minutes, seconds, milliseconds) { if (arguments.length === 1 && typeof days === "number") { var orient = (days < 0) ? -1 : +1; var millsLeft = Math.abs(days); this.setDays(Math.floor(millsLeft / 86400000) * orient); millsLeft = millsLeft % 86400000; this.setHours(Math.floor(millsLeft / 3600000) * orient); millsLeft = millsLeft % 3600000; this.setMinutes(Math.floor(millsLeft / 60000) * orient); millsLeft = millsLeft % 60000; this.setSeconds(Math.floor(millsLeft / 1000) * orient); millsLeft = millsLeft % 1000; this.setMilliseconds(millsLeft * orient); } else { this.set(days, hours, minutes, seconds, milliseconds); } this.getTotalMilliseconds = function () { return (this.getDays() * 86400000) + (this.getHours() * 3600000) + (this.getMinutes() * 60000) + (this.getSeconds() * 1000); }; this.compareTo = function (time) { var t1 = new Date(1970, 1, 1, this.getHours(), this.getMinutes(), this.getSeconds()), t2; if (time === null) { t2 = new Date(1970, 1, 1, 0, 0, 0); } else { t2 = new Date(1970, 1, 1, time.getHours(), time.getMinutes(), time.getSeconds()); } return (t1 < t2) ? -1 : (t1 > t2) ? 1 : 0; }; this.equals = function (time) { return (this.compareTo(time) === 0); }; this.add = function (time) { return (time === null) ? this : this.addSeconds(time.getTotalMilliseconds() / 1000); }; this.subtract = function (time) { return (time === null) ? this : this.addSeconds(-time.getTotalMilliseconds() / 1000); }; this.addDays = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 86400000)); }; this.addHours = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 3600000)); }; this.addMinutes = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 60000)); }; this.addSeconds = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 1000)); }; this.addMilliseconds = function (n) { return new TimeSpan(this.getTotalMilliseconds() + n); }; this.get12HourHour = function () { return (this.getHours() > 12) ? this.getHours() - 12 : (this.getHours() === 0) ? 12 : this.getHours(); }; this.getDesignator = function () { return (this.getHours() < 12) ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator; }; this.toString = function (format) { this._toString = function () { if (this.getDays() !== null && this.getDays() > 0) { return this.getDays() + "." + this.getHours() + ":" + this.p(this.getMinutes()) + ":" + this.p(this.getSeconds()); } else { return this.getHours() + ":" + this.p(this.getMinutes()) + ":" + this.p(this.getSeconds()); } }; this.p = function (s) { return (s.toString().length < 2) ? "0" + s : s; }; var me = this; return format ? format.replace(/dd?|HH?|hh?|mm?|ss?|tt?/g, function (format) { switch (format) { case "d": return me.getDays(); case "dd": return me.p(me.getDays()); case "H": return me.getHours(); case "HH": return me.p(me.getHours()); case "h": return me.get12HourHour(); case "hh": return me.p(me.get12HourHour()); case "m": return me.getMinutes(); case "mm": return me.p(me.getMinutes()); case "s": return me.getSeconds(); case "ss": return me.p(me.getSeconds()); case "t": return ((me.getHours() < 12) ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator).substring(0, 1); case "tt": return (me.getHours() < 12) ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator; } } ) : this._toString(); }; return this; }; addSetFuncs(TimeSpan, attrs.slice(2)); TimeSpan.prototype.set = function (days, hours, minutes, seconds, milliseconds){ this.setDays(days || this.getDays()); this.setHours(hours || this.getHours()); this.setMinutes(minutes || this.getMinutes()); this.setSeconds(seconds || this.getSeconds()); this.setMilliseconds(milliseconds || this.getMilliseconds()); }; /** * Gets the time of day for this date instances. * @return {TimeSpan} TimeSpan */ Date.prototype.getTimeOfDay = function () { return new TimeSpan(0, this.getHours(), this.getMinutes(), this.getSeconds(), this.getMilliseconds()); }; Date.TimeSpan = TimeSpan; if (typeof window !== "undefined" ) { // keeping API compatible for v1.x window.TimeSpan = TimeSpan; } }()); (function () { "use strict"; var attrs = ["years", "months", "days", "hours", "minutes", "seconds", "milliseconds"]; var gFn = function (attr) { return function () { return this[attr]; }; }; var sFn = function (attr) { return function (val) { this[attr] = val; return this; }; }; var addSetFuncs = function (context, attrs) { for (var i = 0; i < attrs.length ; i++) { var $a = attrs[i], $b = $a.slice(0, 1).toUpperCase() + $a.slice(1); context.prototype[$a] = 0; context.prototype["get" + $b] = gFn($a); context.prototype["set" + $b] = sFn($a); } }; var setMonthsAndYears = function (orient, d1, d2, context) { function inc() { d1.addMonths(-orient); context.months++; if (context.months === 12) { context.years++; context.months = 0; } } if (orient === +1) { while (d1 > d2) { inc(); } } else { while (d1 < d2) { inc(); } } context.months--; context.months *= orient; context.years *= orient; }; var adjustForDST = function(orient, startDate, endDate) { var hasDSTMismatch = (false === (startDate.isDaylightSavingTime() === endDate.isDaylightSavingTime())); if (hasDSTMismatch && orient === 1) { startDate.addHours(-1); } else if (hasDSTMismatch) { startDate.addHours(1); } }; /** * TimePeriod(startDate, endDate); * TimePeriod(years, months, days, hours, minutes, seconds, milliseconds); */ var TimePeriod = function (years, months, days, hours, minutes, seconds, milliseconds) { if (arguments.length === 7) { this.set(years, months, days, hours, minutes, seconds, milliseconds); } else if (arguments.length === 2 && arguments[0] instanceof Date && arguments[1] instanceof Date) { var startDate = arguments[0].clone(); var endDate = arguments[1].clone(); var orient = (startDate > endDate) ? +1 : -1; this.dates = { start: arguments[0].clone(), end: arguments[1].clone() }; setMonthsAndYears(orient, startDate, endDate, this); adjustForDST(orient, startDate, endDate); // // TODO - adjust for DST var diff = endDate - startDate; if (diff !== 0) { var ts = new TimeSpan(diff); this.set(this.years, this.months, ts.getDays(), ts.getHours(), ts.getMinutes(), ts.getSeconds(), ts.getMilliseconds()); } } return this; }; // create all the set functions. addSetFuncs(TimePeriod, attrs); TimePeriod.prototype.set = function (years, months, days, hours, minutes, seconds, milliseconds){ this.setYears(years || this.getYears()); this.setMonths(months || this.getMonths()); this.setDays(days || this.getDays()); this.setHours(hours || this.getHours()); this.setMinutes(minutes || this.getMinutes()); this.setSeconds(seconds || this.getSeconds()); this.setMilliseconds(milliseconds || this.getMilliseconds()); }; Date.TimePeriod = TimePeriod; if (typeof window !== "undefined") { // keeping API compatible for v1.x window.TimePeriod = TimePeriod; } }()); ================================================ FILE: build/date-is-IS.js ================================================ /** * @overview datejs * @version 1.0.0-rc3 * @author Gregory Wild-Smith * @copyright 2015 Gregory Wild-Smith * @license MIT * @homepage https://github.com/abritinthebay/datejs */ /* * DateJS Culture String File * Country Code: is-IS * Name: Icelandic (Iceland) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["is-IS"] = { "name": "is-IS", "englishName": "Icelandic (Iceland)", "nativeName": "íslenska (Ísland)", "Sunday": "sunnudagur", "Monday": "mánudagur", "Tuesday": "þriðjudagur", "Wednesday": "miðvikudagur", "Thursday": "fimmtudagur", "Friday": "föstudagur", "Saturday": "laugardagur", "Sun": "sun.", "Mon": "mán.", "Tue": "þri.", "Wed": "mið.", "Thu": "fim.", "Fri": "fös.", "Sat": "lau.", "Su": "su", "Mo": "má", "Tu": "þr", "We": "mi", "Th": "fi", "Fr": "fö", "Sa": "la", "S_Sun_Initial": "s", "M_Mon_Initial": "m", "T_Tue_Initial": "þ", "W_Wed_Initial": "m", "T_Thu_Initial": "f", "F_Fri_Initial": "f", "S_Sat_Initial": "l", "January": "janúar", "February": "febrúar", "March": "mars", "April": "apríl", "May": "maí", "June": "júní", "July": "júlí", "August": "ágúst", "September": "september", "October": "október", "November": "nóvember", "December": "desember", "Jan_Abbr": "jan.", "Feb_Abbr": "feb.", "Mar_Abbr": "mar.", "Apr_Abbr": "apr.", "May_Abbr": "maí", "Jun_Abbr": "jún.", "Jul_Abbr": "júl.", "Aug_Abbr": "ágú.", "Sep_Abbr": "sep.", "Oct_Abbr": "okt.", "Nov_Abbr": "nóv.", "Dec_Abbr": "des.", "AM": "", "PM": "", "firstDayOfWeek": 1, "twoDigitYearMax": 2029, "mdy": "dmy", "M/d/yyyy": "d.M.yyyy", "dddd, MMMM dd, yyyy": "d. MMMM yyyy", "h:mm tt": "HH:mm", "h:mm:ss tt": "HH:mm:ss", "dddd, MMMM dd, yyyy h:mm:ss tt": "d. MMMM yyyy HH:mm:ss", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "d. MMMM", "MMMM, yyyy": "MMMM yyyy", "/jan(uary)?/": "jan(.(úar)?)?", "/feb(ruary)?/": "feb(.(rúar)?)?", "/mar(ch)?/": "mar(.(s)?)?", "/apr(il)?/": "apr(.(íl)?)?", "/may/": "maí", "/jun(e)?/": "jún(.(í)?)?", "/jul(y)?/": "júl(.(í)?)?", "/aug(ust)?/": "ágú(.(st)?)?", "/sep(t(ember)?)?/": "sep(t(ember)?)?", "/oct(ober)?/": "okt(.(óber)?)?", "/nov(ember)?/": "nóv(.(ember)?)?", "/dec(ember)?/": "des(.(ember)?)?", "/^su(n(day)?)?/": "^su(n(.(nudagur)?)?)?", "/^mo(n(day)?)?/": "^má(n(.(udagur)?)?)?", "/^tu(e(s(day)?)?)?/": "^þr(i(.(ðjudagur)?)?)?", "/^we(d(nesday)?)?/": "^mi(ð(.(vikudagur)?)?)?", "/^th(u(r(s(day)?)?)?)?/": "^fi(m(.(mtudagur)?)?)?", "/^fr(i(day)?)?/": "^fö(s(.(tudagur)?)?)?", "/^sa(t(urday)?)?/": "^la(u(.(gardagur)?)?)?", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "is-IS"; /** * @overview datejs * @version 1.0.0-rc3 * @author Gregory Wild-Smith * @copyright 2015 Gregory Wild-Smith * @license MIT * @homepage https://github.com/abritinthebay/datejs */(function () { var $D = Date; var lang = Date.CultureStrings ? Date.CultureStrings.lang : null; var loggedKeys = {}; // for debug purposes. var getText = { getFromKey: function (key, countryCode) { var output; if (Date.CultureStrings && Date.CultureStrings[countryCode] && Date.CultureStrings[countryCode][key]) { output = Date.CultureStrings[countryCode][key]; } else { output = getText.buildFromDefault(key); } if (key.charAt(0) === "/") { // Assume it's a regex output = getText.buildFromRegex(key, countryCode); } return output; }, getFromObjectValues: function (obj, countryCode) { var key, output = {}; for(key in obj) { if (obj.hasOwnProperty(key)) { output[key] = getText.getFromKey(obj[key], countryCode); } } return output; }, getFromObjectKeys: function (obj, countryCode) { var key, output = {}; for(key in obj) { if (obj.hasOwnProperty(key)) { output[getText.getFromKey(key, countryCode)] = obj[key]; } } return output; }, getFromArray: function (arr, countryCode) { var output = []; for (var i=0; i < arr.length; i++){ if (i in arr) { output[i] = getText.getFromKey(arr[i], countryCode); } } return output; }, buildFromDefault: function (key) { var output, length, split, last; switch(key) { case "name": output = "en-US"; break; case "englishName": output = "English (United States)"; break; case "nativeName": output = "English (United States)"; break; case "twoDigitYearMax": output = 2049; break; case "firstDayOfWeek": output = 0; break; default: output = key; split = key.split("_"); length = split.length; if (length > 1 && key.charAt(0) !== "/") { // if the key isn't a regex and it has a split. last = split[(length - 1)].toLowerCase(); if (last === "initial" || last === "abbr") { output = split[0]; } } break; } return output; }, buildFromRegex: function (key, countryCode) { var output; if (Date.CultureStrings && Date.CultureStrings[countryCode] && Date.CultureStrings[countryCode][key]) { output = new RegExp(Date.CultureStrings[countryCode][key], "i"); } else { output = new RegExp(key.replace(new RegExp("/", "g"),""), "i"); } return output; } }; var shallowMerge = function (obj1, obj2) { for (var attrname in obj2) { if (obj2.hasOwnProperty(attrname)) { obj1[attrname] = obj2[attrname]; } } }; var __ = function (key, language) { var countryCode = (language) ? language : lang; loggedKeys[key] = key; if (typeof key === "object") { if (key instanceof Array) { return getText.getFromArray(key, countryCode); } else { return getText.getFromObjectKeys(key, countryCode); } } else { return getText.getFromKey(key, countryCode); } }; var loadI18nScript = function (code) { // paatterned after jQuery's getScript. var url = Date.Config.i18n + code + ".js"; var head = document.getElementsByTagName("head")[0] || document.documentElement; var script = document.createElement("script"); script.src = url; var completed = false; var events = { done: function (){} // placeholder function }; // Attach handlers for all browsers script.onload = script.onreadystatechange = function() { if ( !completed && (!this.readyState || this.readyState === "loaded" || this.readyState === "complete") ) { events.done(); head.removeChild(script); } }; setTimeout(function() { head.insertBefore(script, head.firstChild); }, 0); // allows return to execute first return { done: function (cb) { events.done = function() { if (cb) { setTimeout(cb,0); } }; } }; }; var buildInfo = { buildFromMethodHash: function (obj) { var key; for(key in obj) { if (obj.hasOwnProperty(key)) { obj[key] = buildInfo[obj[key]](); } } return obj; }, timeZoneDST: function () { var DST = { "CHADT": "+1345", "NZDT": "+1300", "AEDT": "+1100", "ACDT": "+1030", "AZST": "+0500", "IRDT": "+0430", "EEST": "+0300", "CEST": "+0200", "BST": "+0100", "PMDT": "-0200", "ADT": "-0300", "NDT": "-0230", "EDT": "-0400", "CDT": "-0500", "MDT": "-0600", "PDT": "-0700", "AKDT": "-0800", "HADT": "-0900" }; return __(DST); }, timeZoneStandard: function () { var standard = { "LINT": "+1400", "TOT": "+1300", "CHAST": "+1245", "NZST": "+1200", "NFT": "+1130", "SBT": "+1100", "AEST": "+1000", "ACST": "+0930", "JST": "+0900", "CWST": "+0845", "CT": "+0800", "ICT": "+0700", "MMT": "+0630", "BST": "+0600", "NPT": "+0545", "IST": "+0530", "PKT": "+0500", "AFT": "+0430", "MSK": "+0400", "IRST": "+0330", "FET": "+0300", "EET": "+0200", "CET": "+0100", "GMT": "+0000", "UTC": "+0000", "CVT": "-0100", "GST": "-0200", "BRT": "-0300", "NST": "-0330", "AST": "-0400", "EST": "-0500", "CST": "-0600", "MST": "-0700", "PST": "-0800", "AKST": "-0900", "MIT": "-0930", "HST": "-1000", "SST": "-1100", "BIT": "-1200" }; return __(standard); }, timeZones: function (data) { var zone; data.timezones = []; for (zone in data.abbreviatedTimeZoneStandard) { if (data.abbreviatedTimeZoneStandard.hasOwnProperty(zone)) { data.timezones.push({ name: zone, offset: data.abbreviatedTimeZoneStandard[zone]}); } } for (zone in data.abbreviatedTimeZoneDST) { if (data.abbreviatedTimeZoneDST.hasOwnProperty(zone)) { data.timezones.push({ name: zone, offset: data.abbreviatedTimeZoneDST[zone], dst: true}); } } return data.timezones; }, days: function () { return __(["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"]); }, dayAbbr: function () { return __(["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"]); }, dayShortNames: function () { return __(["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"]); }, dayFirstLetters: function () { return __(["S_Sun_Initial", "M_Mon_Initial", "T_Tues_Initial", "W_Wed_Initial", "T_Thu_Initial", "F_Fri_Initial", "S_Sat_Initial"]); }, months: function () { return __(["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"]); }, monthAbbr: function () { return __(["Jan_Abbr", "Feb_Abbr", "Mar_Abbr", "Apr_Abbr", "May_Abbr", "Jun_Abbr", "Jul_Abbr", "Aug_Abbr", "Sep_Abbr", "Oct_Abbr", "Nov_Abbr", "Dec_Abbr"]); }, formatPatterns: function () { return getText.getFromObjectValues({ shortDate: "M/d/yyyy", longDate: "dddd, MMMM dd, yyyy", shortTime: "h:mm tt", longTime: "h:mm:ss tt", fullDateTime: "dddd, MMMM dd, yyyy h:mm:ss tt", sortableDateTime: "yyyy-MM-ddTHH:mm:ss", universalSortableDateTime: "yyyy-MM-dd HH:mm:ssZ", rfc1123: "ddd, dd MMM yyyy HH:mm:ss", monthDay: "MMMM dd", yearMonth: "MMMM, yyyy" }, Date.i18n.currentLanguage()); }, regex: function () { return getText.getFromObjectValues({ inTheMorning: "/( in the )(morn(ing)?)\\b/", thisMorning: "/(this )(morn(ing)?)\\b/", amThisMorning: "/(\b\\d(am)? )(this )(morn(ing)?)/", inTheEvening: "/( in the )(even(ing)?)\\b/", thisEvening: "/(this )(even(ing)?)\\b/", pmThisEvening: "/(\b\\d(pm)? )(this )(even(ing)?)/", jan: "/jan(uary)?/", feb: "/feb(ruary)?/", mar: "/mar(ch)?/", apr: "/apr(il)?/", may: "/may/", jun: "/jun(e)?/", jul: "/jul(y)?/", aug: "/aug(ust)?/", sep: "/sep(t(ember)?)?/", oct: "/oct(ober)?/", nov: "/nov(ember)?/", dec: "/dec(ember)?/", sun: "/^su(n(day)?)?/", mon: "/^mo(n(day)?)?/", tue: "/^tu(e(s(day)?)?)?/", wed: "/^we(d(nesday)?)?/", thu: "/^th(u(r(s(day)?)?)?)?/", fri: "/fr(i(day)?)?/", sat: "/^sa(t(urday)?)?/", future: "/^next/", past: "/^last|past|prev(ious)?/", add: "/^(\\+|aft(er)?|from|hence)/", subtract: "/^(\\-|bef(ore)?|ago)/", yesterday: "/^yes(terday)?/", today: "/^t(od(ay)?)?/", tomorrow: "/^tom(orrow)?/", now: "/^n(ow)?/", millisecond: "/^ms|milli(second)?s?/", second: "/^sec(ond)?s?/", minute: "/^mn|min(ute)?s?/", hour: "/^h(our)?s?/", week: "/^w(eek)?s?/", month: "/^m(onth)?s?/", day: "/^d(ay)?s?/", year: "/^y(ear)?s?/", shortMeridian: "/^(a|p)/", longMeridian: "/^(a\\.?m?\\.?|p\\.?m?\\.?)/", timezone: "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/", ordinalSuffix: "/^\\s*(st|nd|rd|th)/", timeContext: "/^\\s*(\\:|a(?!u|p)|p)/" }, Date.i18n.currentLanguage()); } }; var CultureInfo = function () { var info = getText.getFromObjectValues({ name: "name", englishName: "englishName", nativeName: "nativeName", amDesignator: "AM", pmDesignator: "PM", firstDayOfWeek: "firstDayOfWeek", twoDigitYearMax: "twoDigitYearMax", dateElementOrder: "mdy" }, Date.i18n.currentLanguage()); var constructedInfo = buildInfo.buildFromMethodHash({ dayNames: "days", abbreviatedDayNames: "dayAbbr", shortestDayNames: "dayShortNames", firstLetterDayNames: "dayFirstLetters", monthNames: "months", abbreviatedMonthNames: "monthAbbr", formatPatterns: "formatPatterns", regexPatterns: "regex", abbreviatedTimeZoneDST: "timeZoneDST", abbreviatedTimeZoneStandard: "timeZoneStandard" }); shallowMerge(info, constructedInfo); buildInfo.timeZones(info); return info; }; $D.i18n = { __: function (key, lang) { return __(key, lang); }, currentLanguage: function () { return lang || "en-US"; }, setLanguage: function (code, force, cb) { var async = false; if (force || code === "en-US" || (!!Date.CultureStrings && !!Date.CultureStrings[code])) { lang = code; Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings.lang = code; Date.CultureInfo = new CultureInfo(); } else { if (!(!!Date.CultureStrings && !!Date.CultureStrings[code])) { if (typeof exports !== "undefined" && this.exports !== exports) { // we're in a Node enviroment, load it using require try { require("../i18n/" + code + ".js"); lang = code; Date.CultureStrings.lang = code; Date.CultureInfo = new CultureInfo(); } catch (e) { // var str = "The language for '" + code + "' could not be loaded by Node. It likely does not exist."; throw new Error("The DateJS IETF language tag '" + code + "' could not be loaded by Node. It likely does not exist."); } } else if (Date.Config && Date.Config.i18n) { // we know the location of the files, so lets load them async = true; loadI18nScript(code).done(function(){ lang = code; Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings.lang = code; Date.CultureInfo = new CultureInfo(); $D.Parsing.Normalizer.buildReplaceData(); // because this is async if ($D.Grammar) { $D.Grammar.buildGrammarFormats(); // so we can parse those strings... } if (cb) { setTimeout(cb,0); } }); } else { Date.console.error("The DateJS IETF language tag '" + code + "' is not available and has not been loaded."); return false; } } } $D.Parsing.Normalizer.buildReplaceData(); // rebuild normalizer strings if ($D.Grammar) { $D.Grammar.buildGrammarFormats(); // so we can parse those strings... } if (!async && cb) { setTimeout(cb,0); } }, getLoggedKeys: function () { return loggedKeys; }, updateCultureInfo: function () { Date.CultureInfo = new CultureInfo(); } }; $D.i18n.updateCultureInfo(); // run automatically }()); (function () { var $D = Date, $P = $D.prototype, p = function (s, l) { if (!l) { l = 2; } return ("000" + s).slice(l * -1); }; if (typeof window !== "undefined" && typeof window.console !== "undefined" && typeof window.console.log !== "undefined") { $D.console = console; // used only to raise non-critical errors if available } else { // set mock so we don't give errors. $D.console = { log: function(){}, error: function(){} }; } $D.Config = $D.Config || {}; $D.initOverloads = function() { /** * Overload of Date.now. Allows an alternate call for Date.now where it returns the * current Date as an object rather than just milliseconds since the Unix Epoch. * * Also provides an implementation of now() for browsers (IE<9) that don't have it. * * Backwards compatible so with work with either: * Date.now() [returns ms] * or * Date.now(true) [returns Date] */ if (!$D.now) { $D._now = function now() { return new Date().getTime(); }; } else if (!$D._now) { $D._now = $D.now; } $D.now = function (returnObj) { if (returnObj) { return $D.present(); } else { return $D._now(); } }; if ( !$P.toISOString ) { $P.toISOString = function() { return this.getUTCFullYear() + "-" + p(this.getUTCMonth() + 1) + "-" + p(this.getUTCDate()) + "T" + p(this.getUTCHours()) + ":" + p(this.getUTCMinutes()) + ":" + p(this.getUTCSeconds()) + "." + String( (this.getUTCMilliseconds()/1000).toFixed(3)).slice(2, 5) + "Z"; }; } // private if ( $P._toString === undefined ){ $P._toString = $P.toString; } }; $D.initOverloads(); /** * Gets a date that is set to the current date. The time is set to the start of the day (00:00 or 12:00 AM). * @return {Date} The current date. */ $D.today = function () { return new Date().clearTime(); }; /** * Gets a date that is set to the current date and time (same as new Date, but chainable) * @return {Date} The current date. */ $D.present = function () { return new Date(); }; /** * Compares the first date to the second date and returns an number indication of their relative values. * @param {Date} First Date object to compare [Required]. * @param {Date} Second Date object to compare to [Required]. * @return {Number} -1 = date1 is lessthan date2. 0 = values are equal. 1 = date1 is greaterthan date2. */ $D.compare = function (date1, date2) { if (isNaN(date1) || isNaN(date2)) { throw new Error(date1 + " - " + date2); } else if (date1 instanceof Date && date2 instanceof Date) { return (date1 < date2) ? -1 : (date1 > date2) ? 1 : 0; } else { throw new TypeError(date1 + " - " + date2); } }; /** * Compares the first Date object to the second Date object and returns true if they are equal. * @param {Date} First Date object to compare [Required] * @param {Date} Second Date object to compare to [Required] * @return {Boolean} true if dates are equal. false if they are not equal. */ $D.equals = function (date1, date2) { return (date1.compareTo(date2) === 0); }; /** * Gets the language appropriate day name when given the day number(0-6) * eg - 0 == Sunday * @return {String} The day name */ $D.getDayName = function (n) { return Date.CultureInfo.dayNames[n]; }; /** * Gets the day number (0-6) if given a CultureInfo specific string which is a valid dayName, abbreviatedDayName or shortestDayName (two char). * @param {String} The name of the day (eg. "Monday, "Mon", "tuesday", "tue", "We", "we"). * @return {Number} The day number */ $D.getDayNumberFromName = function (name) { var n = Date.CultureInfo.dayNames, m = Date.CultureInfo.abbreviatedDayNames, o = Date.CultureInfo.shortestDayNames, s = name.toLowerCase(); for (var i = 0; i < n.length; i++) { if (n[i].toLowerCase() === s || m[i].toLowerCase() === s || o[i].toLowerCase() === s) { return i; } } return -1; }; /** * Gets the month number (0-11) if given a Culture Info specific string which is a valid monthName or abbreviatedMonthName. * @param {String} The name of the month (eg. "February, "Feb", "october", "oct"). * @return {Number} The day number */ $D.getMonthNumberFromName = function (name) { var n = Date.CultureInfo.monthNames, m = Date.CultureInfo.abbreviatedMonthNames, s = name.toLowerCase(); for (var i = 0; i < n.length; i++) { if (n[i].toLowerCase() === s || m[i].toLowerCase() === s) { return i; } } return -1; }; /** * Gets the language appropriate month name when given the month number(0-11) * eg - 0 == January * @return {String} The month name */ $D.getMonthName = function (n) { return Date.CultureInfo.monthNames[n]; }; /** * Determines if the current date instance is within a LeapYear. * @param {Number} The year. * @return {Boolean} true if date is within a LeapYear, otherwise false. */ $D.isLeapYear = function (year) { return ((year % 4 === 0 && year % 100 !== 0) || year % 400 === 0); }; /** * Gets the number of days in the month, given a year and month value. Automatically corrects for LeapYear. * @param {Number} The year. * @param {Number} The month (0-11). * @return {Number} The number of days in the month. */ $D.getDaysInMonth = function (year, month) { if (!month && $D.validateMonth(year)) { month = year; year = Date.today().getFullYear(); } return [31, ($D.isLeapYear(year) ? 29 : 28), 31, 30, 31, 30, 31, 31, 30, 31, 30, 31][month]; }; $P.getDaysInMonth = function () { return $D.getDaysInMonth(this.getFullYear(), this.getMonth()); }; $D.getTimezoneAbbreviation = function (offset, dst) { var p, n = (dst || false) ? Date.CultureInfo.abbreviatedTimeZoneDST : Date.CultureInfo.abbreviatedTimeZoneStandard; for (p in n) { if (n.hasOwnProperty(p)) { if (n[p] === offset) { return p; } } } return null; }; $D.getTimezoneOffset = function (name, dst) { var i, a =[], z = Date.CultureInfo.timezones; if (!name) { name = (new Date()).getTimezone();} for (i = 0; i < z.length; i++) { if (z[i].name === name.toUpperCase()) { a.push(i); } } if (!z[a[0]]) { return null; } if (a.length === 1 || !dst) { return z[a[0]].offset; } else { for (i=0; i < a.length; i++) { if (z[a[i]].dst) { return z[a[i]].offset; } } } }; $D.getQuarter = function (d) { d = d || new Date(); // If no date supplied, use today var q = [1,2,3,4]; return q[Math.floor(d.getMonth() / 3)]; // ~~~ is a bitwise op. Faster than Math.floor }; $D.getDaysLeftInQuarter = function (d) { d = d || new Date(); var qEnd = new Date(d); qEnd.setMonth(qEnd.getMonth() + 3 - qEnd.getMonth() % 3, 0); return Math.floor((qEnd - d) / 8.64e7); }; // private var validate = function (n, min, max, name) { name = name ? name : "Object"; if (typeof n === "undefined") { return false; } else if (typeof n !== "number") { throw new TypeError(n + " is not a Number."); } else if (n < min || n > max) { // As failing validation is *not* an exceptional circumstance // lets not throw a RangeError Exception here. // It's semantically correct but it's not sensible. return false; } return true; }; /** * Validates the number is within an acceptable range for milliseconds [0-999]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateMillisecond = function (value) { return validate(value, 0, 999, "millisecond"); }; /** * Validates the number is within an acceptable range for seconds [0-59]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateSecond = function (value) { return validate(value, 0, 59, "second"); }; /** * Validates the number is within an acceptable range for minutes [0-59]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateMinute = function (value) { return validate(value, 0, 59, "minute"); }; /** * Validates the number is within an acceptable range for hours [0-23]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateHour = function (value) { return validate(value, 0, 23, "hour"); }; /** * Validates the number is within an acceptable range for the days in a month [0-MaxDaysInMonth]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateDay = function (value, year, month) { if (year === undefined || year === null || month === undefined || month === null) { return false;} return validate(value, 1, $D.getDaysInMonth(year, month), "day"); }; /** * Validates the number is within an acceptable range for months [0-11]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateWeek = function (value) { return validate(value, 0, 53, "week"); }; /** * Validates the number is within an acceptable range for months [0-11]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateMonth = function (value) { return validate(value, 0, 11, "month"); }; /** * Validates the number is within an acceptable range for years. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateYear = function (value) { /** * Per ECMAScript spec the range of times supported by Date objects is * exactly -100,000,000 days to +100,000,000 days measured relative to * midnight at the beginning of 01 January, 1970 UTC. * This gives a range of 8,640,000,000,000,000 milliseconds to either * side of 01 January, 1970 UTC. * * Earliest possible date: Tue, 20 Apr 271,822 B.C. 00:00:00 UTC * Latest possible date: Sat, 13 Sep 275,760 00:00:00 UTC */ return validate(value, -271822, 275760, "year"); }; $D.validateTimezone = function(value) { var timezones = {"ACDT":1,"ACST":1,"ACT":1,"ADT":1,"AEDT":1,"AEST":1,"AFT":1,"AKDT":1,"AKST":1,"AMST":1,"AMT":1,"ART":1,"AST":1,"AWDT":1,"AWST":1,"AZOST":1,"AZT":1,"BDT":1,"BIOT":1,"BIT":1,"BOT":1,"BRT":1,"BST":1,"BTT":1,"CAT":1,"CCT":1,"CDT":1,"CEDT":1,"CEST":1,"CET":1,"CHADT":1,"CHAST":1,"CHOT":1,"ChST":1,"CHUT":1,"CIST":1,"CIT":1,"CKT":1,"CLST":1,"CLT":1,"COST":1,"COT":1,"CST":1,"CT":1,"CVT":1,"CWST":1,"CXT":1,"DAVT":1,"DDUT":1,"DFT":1,"EASST":1,"EAST":1,"EAT":1,"ECT":1,"EDT":1,"EEDT":1,"EEST":1,"EET":1,"EGST":1,"EGT":1,"EIT":1,"EST":1,"FET":1,"FJT":1,"FKST":1,"FKT":1,"FNT":1,"GALT":1,"GAMT":1,"GET":1,"GFT":1,"GILT":1,"GIT":1,"GMT":1,"GST":1,"GYT":1,"HADT":1,"HAEC":1,"HAST":1,"HKT":1,"HMT":1,"HOVT":1,"HST":1,"ICT":1,"IDT":1,"IOT":1,"IRDT":1,"IRKT":1,"IRST":1,"IST":1,"JST":1,"KGT":1,"KOST":1,"KRAT":1,"KST":1,"LHST":1,"LINT":1,"MAGT":1,"MART":1,"MAWT":1,"MDT":1,"MET":1,"MEST":1,"MHT":1,"MIST":1,"MIT":1,"MMT":1,"MSK":1,"MST":1,"MUT":1,"MVT":1,"MYT":1,"NCT":1,"NDT":1,"NFT":1,"NPT":1,"NST":1,"NT":1,"NUT":1,"NZDT":1,"NZST":1,"OMST":1,"ORAT":1,"PDT":1,"PET":1,"PETT":1,"PGT":1,"PHOT":1,"PHT":1,"PKT":1,"PMDT":1,"PMST":1,"PONT":1,"PST":1,"PYST":1,"PYT":1,"RET":1,"ROTT":1,"SAKT":1,"SAMT":1,"SAST":1,"SBT":1,"SCT":1,"SGT":1,"SLST":1,"SRT":1,"SST":1,"SYOT":1,"TAHT":1,"THA":1,"TFT":1,"TJT":1,"TKT":1,"TLT":1,"TMT":1,"TOT":1,"TVT":1,"UCT":1,"ULAT":1,"UTC":1,"UYST":1,"UYT":1,"UZT":1,"VET":1,"VLAT":1,"VOLT":1,"VOST":1,"VUT":1,"WAKT":1,"WAST":1,"WAT":1,"WEDT":1,"WEST":1,"WET":1,"WST":1,"YAKT":1,"YEKT":1,"Z":1}; return (timezones[value] === 1); }; $D.validateTimezoneOffset= function(value) { // timezones go from +14hrs to -12hrs, the +X hours are negative offsets. return (value > -841 && value < 721); }; }()); (function () { var $D = Date, $P = $D.prototype, p = function (s, l) { if (!l) { l = 2; } return ("000" + s).slice(l * -1); }; var validateConfigObject = function (obj) { var result = {}, self = this, prop, testFunc; testFunc = function (prop, func, value) { if (prop === "day") { var month = (obj.month !== undefined) ? obj.month : self.getMonth(); var year = (obj.year !== undefined) ? obj.year : self.getFullYear(); return $D[func](value, year, month); } else { return $D[func](value); } }; for (prop in obj) { if (Object.prototype.hasOwnProperty.call(obj, prop)) { var func = "validate" + prop.charAt(0).toUpperCase() + prop.slice(1); if ($D[func] && obj[prop] !== null && testFunc(prop, func, obj[prop])) { result[prop] = obj[prop]; } } } return result; }; /** * Resets the time of this Date object to 12:00 AM (00:00), which is the start of the day. * @param {Boolean} .clone() this date instance before clearing Time * @return {Date} this */ $P.clearTime = function () { this.setHours(0); this.setMinutes(0); this.setSeconds(0); this.setMilliseconds(0); return this; }; /** * Resets the time of this Date object to the current time ('now'). * @return {Date} this */ $P.setTimeToNow = function () { var n = new Date(); this.setHours(n.getHours()); this.setMinutes(n.getMinutes()); this.setSeconds(n.getSeconds()); this.setMilliseconds(n.getMilliseconds()); return this; }; /** * Returns a new Date object that is an exact date and time copy of the original instance. * @return {Date} A new Date instance */ $P.clone = function () { return new Date(this.getTime()); }; /** * Compares this instance to a Date object and returns an number indication of their relative values. * @param {Date} Date object to compare [Required] * @return {Number} -1 = this is lessthan date. 0 = values are equal. 1 = this is greaterthan date. */ $P.compareTo = function (date) { return Date.compare(this, date); }; /** * Compares this instance to another Date object and returns true if they are equal. * @param {Date} Date object to compare. If no date to compare, new Date() [now] is used. * @return {Boolean} true if dates are equal. false if they are not equal. */ $P.equals = function (date) { return Date.equals(this, (date !== undefined ? date : new Date())); }; /** * Determines if this instance is between a range of two dates or equal to either the start or end dates. * @param {Date} Start of range [Required] * @param {Date} End of range [Required] * @return {Boolean} true is this is between or equal to the start and end dates, else false */ $P.between = function (start, end) { return this.getTime() >= start.getTime() && this.getTime() <= end.getTime(); }; /** * Determines if this date occurs after the date to compare to. * @param {Date} Date object to compare. If no date to compare, new Date() ("now") is used. * @return {Boolean} true if this date instance is greater than the date to compare to (or "now"), otherwise false. */ $P.isAfter = function (date) { return this.compareTo(date || new Date()) === 1; }; /** * Determines if this date occurs before the date to compare to. * @param {Date} Date object to compare. If no date to compare, new Date() ("now") is used. * @return {Boolean} true if this date instance is less than the date to compare to (or "now"). */ $P.isBefore = function (date) { return (this.compareTo(date || new Date()) === -1); }; /** * Determines if the current Date instance occurs today. * @return {Boolean} true if this date instance is 'today', otherwise false. */ /** * Determines if the current Date instance occurs on the same Date as the supplied 'date'. * If no 'date' to compare to is provided, the current Date instance is compared to 'today'. * @param {date} Date object to compare. If no date to compare, the current Date ("now") is used. * @return {Boolean} true if this Date instance occurs on the same Day as the supplied 'date'. */ $P.isToday = $P.isSameDay = function (date) { return this.clone().clearTime().equals((date || new Date()).clone().clearTime()); }; /** * Adds the specified number of milliseconds to this instance. * @param {Number} The number of milliseconds to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addMilliseconds = function (value) { if (!value) { return this; } this.setTime(this.getTime() + value * 1); return this; }; /** * Adds the specified number of seconds to this instance. * @param {Number} The number of seconds to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addSeconds = function (value) { if (!value) { return this; } return this.addMilliseconds(value * 1000); }; /** * Adds the specified number of seconds to this instance. * @param {Number} The number of seconds to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addMinutes = function (value) { if (!value) { return this; } return this.addMilliseconds(value * 60000); // 60*1000 }; /** * Adds the specified number of hours to this instance. * @param {Number} The number of hours to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addHours = function (value) { if (!value) { return this; } return this.addMilliseconds(value * 3600000); // 60*60*1000 }; /** * Adds the specified number of days to this instance. * @param {Number} The number of days to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addDays = function (value) { if (!value) { return this; } this.setDate(this.getDate() + value * 1); return this; }; /** * Adds the specified number of weekdays (ie - not sat or sun) to this instance. * @param {Number} The number of days to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addWeekdays = function (value) { if (!value) { return this; } var day = this.getDay(); var weeks = (Math.ceil(Math.abs(value)/7)); if (day === 0 || day === 6) { if (value > 0) { this.next().monday(); this.addDays(-1); day = this.getDay(); } } if (value < 0) { while (value < 0) { this.addDays(-1); day = this.getDay(); if (day !== 0 && day !== 6) { value++; } } return this; } else if (value > 5 || (6-day) <= value) { value = value + (weeks * 2); } return this.addDays(value); }; /** * Adds the specified number of weeks to this instance. * @param {Number} The number of weeks to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addWeeks = function (value) { if (!value) { return this; } return this.addDays(value * 7); }; /** * Adds the specified number of months to this instance. * @param {Number} The number of months to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addMonths = function (value) { if (!value) { return this; } var n = this.getDate(); this.setDate(1); this.setMonth(this.getMonth() + value * 1); this.setDate(Math.min(n, $D.getDaysInMonth(this.getFullYear(), this.getMonth()))); return this; }; $P.addQuarters = function (value) { if (!value) { return this; } // note this will take you to the same point in the quarter as you are now. // i.e. - if you are 15 days into the quarter you'll be 15 days into the resulting one. // bonus: this allows adding fractional quarters return this.addMonths(value * 3); }; /** * Adds the specified number of years to this instance. * @param {Number} The number of years to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addYears = function (value) { if (!value) { return this; } return this.addMonths(value * 12); }; /** * Adds (or subtracts) to the value of the years, months, weeks, days, hours, minutes, seconds, milliseconds of the date instance using given configuration object. Positive and Negative values allowed. * Example

	Date.today().add( { days: 1, months: 1 } )

	new Date().add( { years: -1 } )
	
* @param {Object} Configuration object containing attributes (months, days, etc.) * @return {Date} this */ $P.add = function (config) { if (typeof config === "number") { this._orient = config; return this; } var x = config; if (x.day) { // If we should be a different date than today (eg: for 'tomorrow -1d', etc). // Should only effect parsing, not direct usage (eg, Finish and FinishExact) if ((x.day - this.getDate()) !== 0) { this.setDate(x.day); } } if (x.milliseconds) { this.addMilliseconds(x.milliseconds); } if (x.seconds) { this.addSeconds(x.seconds); } if (x.minutes) { this.addMinutes(x.minutes); } if (x.hours) { this.addHours(x.hours); } if (x.weeks) { this.addWeeks(x.weeks); } if (x.months) { this.addMonths(x.months); } if (x.years) { this.addYears(x.years); } if (x.days) { this.addDays(x.days); } return this; }; /** * Get the week number. Week one (1) is the week which contains the first Thursday of the year. Monday is considered the first day of the week. * The .getWeek() function does NOT convert the date to UTC. The local datetime is used. * Please use .getISOWeek() to get the week of the UTC converted date. * @return {Number} 1 to 53 */ $P.getWeek = function (utc) { // Create a copy of this date object var self, target = new Date(this.valueOf()); if (utc) { target.addMinutes(target.getTimezoneOffset()); self = target.clone(); } else { self = this; } // ISO week date weeks start on monday // so correct the day number var dayNr = (self.getDay() + 6) % 7; // ISO 8601 states that week 1 is the week // with the first thursday of that year. // Set the target date to the thursday in the target week target.setDate(target.getDate() - dayNr + 3); // Store the millisecond value of the target date var firstThursday = target.valueOf(); // Set the target to the first thursday of the year // First set the target to january first target.setMonth(0, 1); // Not a thursday? Correct the date to the next thursday if (target.getDay() !== 4) { target.setMonth(0, 1 + ((4 - target.getDay()) + 7) % 7); } // The weeknumber is the number of weeks between the // first thursday of the year and the thursday in the target week return 1 + Math.ceil((firstThursday - target) / 604800000); // 604800000 = 7 * 24 * 3600 * 1000 }; /** * Get the ISO 8601 week number. Week one ("01") is the week which contains the first Thursday of the year. Monday is considered the first day of the week. * The .getISOWeek() function does convert the date to it's UTC value. Please use .getWeek() to get the week of the local date. * @return {String} "01" to "53" */ $P.getISOWeek = function () { return p(this.getWeek(true)); }; /** * Moves the date to Monday of the week set. Week one (1) is the week which contains the first Thursday of the year. * @param {Number} A Number (1 to 53) that represents the week of the year. * @return {Date} this */ $P.setWeek = function (n) { if ((n - this.getWeek()) === 0) { if (this.getDay() !== 1) { return this.moveToDayOfWeek(1, (this.getDay() > 1 ? -1 : 1)); } else { return this; } } else { return this.moveToDayOfWeek(1, (this.getDay() > 1 ? -1 : 1)).addWeeks(n - this.getWeek()); } }; $P.setQuarter = function (qtr) { var month = Math.abs(((qtr-1) * 3) + 1); return this.setMonth(month, 1); }; $P.getQuarter = function () { return Date.getQuarter(this); }; $P.getDaysLeftInQuarter = function () { return Date.getDaysLeftInQuarter(this); }; /** * Moves the date to the next n'th occurrence of the dayOfWeek starting from the beginning of the month. The number (-1) is a magic number and will return the last occurrence of the dayOfWeek in the month. * @param {Number} The dayOfWeek to move to * @param {Number} The n'th occurrence to move to. Use (-1) to return the last occurrence in the month * @return {Date} this */ $P.moveToNthOccurrence = function (dayOfWeek, occurrence) { if (dayOfWeek === "Weekday") { if (occurrence > 0) { this.moveToFirstDayOfMonth(); if (this.is().weekday()) { occurrence -= 1; } } else if (occurrence < 0) { this.moveToLastDayOfMonth(); if (this.is().weekday()) { occurrence += 1; } } else { return this; } return this.addWeekdays(occurrence); } var shift = 0; if (occurrence > 0) { shift = occurrence - 1; } else if (occurrence === -1) { this.moveToLastDayOfMonth(); if (this.getDay() !== dayOfWeek) { this.moveToDayOfWeek(dayOfWeek, -1); } return this; } return this.moveToFirstDayOfMonth().addDays(-1).moveToDayOfWeek(dayOfWeek, +1).addWeeks(shift); }; var moveToN = function (getFunc, addFunc, nVal) { return function (value, orient) { var diff = (value - this[getFunc]() + nVal * (orient || +1)) % nVal; return this[addFunc]((diff === 0) ? diff += nVal * (orient || +1) : diff); }; }; /** * Move to the next or last dayOfWeek based on the orient value. * @param {Number} The dayOfWeek to move to * @param {Number} Forward (+1) or Back (-1). Defaults to +1. [Optional] * @return {Date} this */ $P.moveToDayOfWeek = moveToN("getDay", "addDays", 7); /** * Move to the next or last month based on the orient value. * @param {Number} The month to move to. 0 = January, 11 = December * @param {Number} Forward (+1) or Back (-1). Defaults to +1. [Optional] * @return {Date} this */ $P.moveToMonth = moveToN("getMonth", "addMonths", 12); /** * Get the Ordinate of the current day ("th", "st", "rd"). * @return {String} */ $P.getOrdinate = function () { var num = this.getDate(); return ord(num); }; /** * Get the Ordinal day (numeric day number) of the year, adjusted for leap year. * @return {Number} 1 through 365 (366 in leap years) */ $P.getOrdinalNumber = function () { return Math.ceil((this.clone().clearTime() - new Date(this.getFullYear(), 0, 1)) / 86400000) + 1; }; /** * Get the time zone abbreviation of the current date. * @return {String} The abbreviated time zone name (e.g. "EST") */ $P.getTimezone = function () { return $D.getTimezoneAbbreviation(this.getUTCOffset(), this.isDaylightSavingTime()); }; $P.setTimezoneOffset = function (offset) { var here = this.getTimezoneOffset(), there = Number(offset) * -6 / 10; return (there || there === 0) ? this.addMinutes(there - here) : this; }; $P.setTimezone = function (offset) { return this.setTimezoneOffset($D.getTimezoneOffset(offset)); }; /** * Indicates whether Daylight Saving Time is observed in the current time zone. * @return {Boolean} true|false */ $P.hasDaylightSavingTime = function () { return (Date.today().set({month: 0, day: 1}).getTimezoneOffset() !== Date.today().set({month: 6, day: 1}).getTimezoneOffset()); }; /** * Indicates whether this Date instance is within the Daylight Saving Time range for the current time zone. * @return {Boolean} true|false */ $P.isDaylightSavingTime = function () { return Date.today().set({month: 0, day: 1}).getTimezoneOffset() !== this.getTimezoneOffset(); }; /** * Get the offset from UTC of the current date. * @return {String} The 4-character offset string prefixed with + or - (e.g. "-0500") */ $P.getUTCOffset = function (offset) { var n = (offset || this.getTimezoneOffset()) * -10 / 6, r; if (n < 0) { r = (n - 10000).toString(); return r.charAt(0) + r.substr(2); } else { r = (n + 10000).toString(); return "+" + r.substr(1); } }; /** * Returns the number of milliseconds between this date and date. * @param {Date} Defaults to now * @return {Number} The diff in milliseconds */ $P.getElapsed = function (date) { return (date || new Date()) - this; }; /** * Set the value of year, month, day, hour, minute, second, millisecond of date instance using given configuration object. * Example

	Date.today().set( { day: 20, month: 1 } )

	new Date().set( { millisecond: 0 } )
	
* * @param {Object} Configuration object containing attributes (month, day, etc.) * @return {Date} this */ $P.set = function (config) { config = validateConfigObject.call(this, config); var key; for (key in config) { if (Object.prototype.hasOwnProperty.call(config, key)) { var name = key.charAt(0).toUpperCase() + key.slice(1); var addFunc, getFunc; if (key !== "week" && key !== "month" && key !== "timezone" && key !== "timezoneOffset") { name += "s"; } addFunc = "add" + name; getFunc = "get" + name; if (key === "month") { addFunc = addFunc + "s"; } else if (key === "year"){ getFunc = "getFullYear"; } if (key !== "day" && key !== "timezone" && key !== "timezoneOffset" && key !== "week" && key !== "hour") { this[addFunc](config[key] - this[getFunc]()); } else if ( key === "timezone"|| key === "timezoneOffset" || key === "week" || key === "hour") { this["set"+name](config[key]); } } } // day has to go last because you can't validate the day without first knowing the month if (config.day) { this.addDays(config.day - this.getDate()); } return this; }; /** * Moves the date to the first day of the month. * @return {Date} this */ $P.moveToFirstDayOfMonth = function () { return this.set({ day: 1 }); }; /** * Moves the date to the last day of the month. * @return {Date} this */ $P.moveToLastDayOfMonth = function () { return this.set({ day: $D.getDaysInMonth(this.getFullYear(), this.getMonth())}); }; /** * Converts the value of the current Date object to its equivalent string representation. * Format Specifiers * CUSTOM DATE AND TIME FORMAT STRINGS * Format Description Example * ------ --------------------------------------------------------------------------- ----------------------- * s The seconds of the minute between 0-59. "0" to "59" * ss The seconds of the minute with leading zero if required. "00" to "59" * * m The minute of the hour between 0-59. "0" or "59" * mm The minute of the hour with leading zero if required. "00" or "59" * * h The hour of the day between 1-12. "1" to "12" * hh The hour of the day with leading zero if required. "01" to "12" * * H The hour of the day between 0-23. "0" to "23" * HH The hour of the day with leading zero if required. "00" to "23" * * d The day of the month between 1 and 31. "1" to "31" * dd The day of the month with leading zero if required. "01" to "31" * ddd Abbreviated day name. Date.CultureInfo.abbreviatedDayNames. "Mon" to "Sun" * dddd The full day name. Date.CultureInfo.dayNames. "Monday" to "Sunday" * * M The month of the year between 1-12. "1" to "12" * MM The month of the year with leading zero if required. "01" to "12" * MMM Abbreviated month name. Date.CultureInfo.abbreviatedMonthNames. "Jan" to "Dec" * MMMM The full month name. Date.CultureInfo.monthNames. "January" to "December" * * yy The year as a two-digit number. "99" or "08" * yyyy The full four digit year. "1999" or "2008" * * t Displays the first character of the A.M./P.M. designator. "A" or "P" * Date.CultureInfo.amDesignator or Date.CultureInfo.pmDesignator * tt Displays the A.M./P.M. designator. "AM" or "PM" * Date.CultureInfo.amDesignator or Date.CultureInfo.pmDesignator * * S The ordinal suffix ("st, "nd", "rd" or "th") of the current day. "st, "nd", "rd" or "th" * * STANDARD DATE AND TIME FORMAT STRINGS * Format Description Example *------ --------------------------------------------------------------------------- ----------------------- * d The CultureInfo shortDate Format Pattern "M/d/yyyy" * D The CultureInfo longDate Format Pattern "dddd, MMMM dd, yyyy" * F The CultureInfo fullDateTime Format Pattern "dddd, MMMM dd, yyyy h:mm:ss tt" * m The CultureInfo monthDay Format Pattern "MMMM dd" * r The CultureInfo rfc1123 Format Pattern "ddd, dd MMM yyyy HH:mm:ss GMT" * s The CultureInfo sortableDateTime Format Pattern "yyyy-MM-ddTHH:mm:ss" * t The CultureInfo shortTime Format Pattern "h:mm tt" * T The CultureInfo longTime Format Pattern "h:mm:ss tt" * u The CultureInfo universalSortableDateTime Format Pattern "yyyy-MM-dd HH:mm:ssZ" * y The CultureInfo yearMonth Format Pattern "MMMM, yyyy" * * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @return {String} A string representation of the current Date object. */ var ord = function (n) { switch (n * 1) { case 1: case 21: case 31: return "st"; case 2: case 22: return "nd"; case 3: case 23: return "rd"; default: return "th"; } }; var parseStandardFormats = function (format) { var y, c = Date.CultureInfo.formatPatterns; switch (format) { case "d": return this.toString(c.shortDate); case "D": return this.toString(c.longDate); case "F": return this.toString(c.fullDateTime); case "m": return this.toString(c.monthDay); case "r": case "R": y = this.clone().addMinutes(this.getTimezoneOffset()); return y.toString(c.rfc1123) + " GMT"; case "s": return this.toString(c.sortableDateTime); case "t": return this.toString(c.shortTime); case "T": return this.toString(c.longTime); case "u": y = this.clone().addMinutes(this.getTimezoneOffset()); return y.toString(c.universalSortableDateTime); case "y": return this.toString(c.yearMonth); default: return false; } }; var parseFormatStringsClosure = function (context) { return function (m) { if (m.charAt(0) === "\\") { return m.replace("\\", ""); } switch (m) { case "hh": return p(context.getHours() < 13 ? (context.getHours() === 0 ? 12 : context.getHours()) : (context.getHours() - 12)); case "h": return context.getHours() < 13 ? (context.getHours() === 0 ? 12 : context.getHours()) : (context.getHours() - 12); case "HH": return p(context.getHours()); case "H": return context.getHours(); case "mm": return p(context.getMinutes()); case "m": return context.getMinutes(); case "ss": return p(context.getSeconds()); case "s": return context.getSeconds(); case "yyyy": return p(context.getFullYear(), 4); case "yy": return p(context.getFullYear()); case "y": return context.getFullYear(); case "E": case "dddd": return Date.CultureInfo.dayNames[context.getDay()]; case "ddd": return Date.CultureInfo.abbreviatedDayNames[context.getDay()]; case "dd": return p(context.getDate()); case "d": return context.getDate(); case "MMMM": return Date.CultureInfo.monthNames[context.getMonth()]; case "MMM": return Date.CultureInfo.abbreviatedMonthNames[context.getMonth()]; case "MM": return p((context.getMonth() + 1)); case "M": return context.getMonth() + 1; case "t": return context.getHours() < 12 ? Date.CultureInfo.amDesignator.substring(0, 1) : Date.CultureInfo.pmDesignator.substring(0, 1); case "tt": return context.getHours() < 12 ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator; case "S": return ord(context.getDate()); case "W": return context.getWeek(); case "WW": return context.getISOWeek(); case "Q": return "Q" + context.getQuarter(); case "q": return String(context.getQuarter()); case "z": return context.getTimezone(); case "Z": case "X": return Date.getTimezoneOffset(context.getTimezone()); case "ZZ": // Timezone offset in seconds return context.getTimezoneOffset() * -60; case "u": return context.getDay(); case "L": return ($D.isLeapYear(context.getFullYear())) ? 1 : 0; case "B": // Swatch Internet Time (.beats) return "@"+((context.getUTCSeconds() + (context.getUTCMinutes()*60) + ((context.getUTCHours()+1)*3600))/86.4); default: return m; } }; }; $P.toString = function (format, ignoreStandards) { // Standard Date and Time Format Strings. Formats pulled from CultureInfo file and // may vary by culture. if (!ignoreStandards && format && format.length === 1) { output = parseStandardFormats.call(this, format); if (output) { return output; } } var parseFormatStrings = parseFormatStringsClosure(this); return format ? format.replace(/((\\)?(dd?d?d?|MM?M?M?|yy?y?y?|hh?|HH?|mm?|ss?|tt?|S|q|Q|WW?W?W?)(?![^\[]*\]))/g, parseFormatStrings).replace(/\[|\]/g, "") : this._toString(); }; }()); /************************************************************* * SugarPak - Domain Specific Language - Syntactical Sugar * *************************************************************/ (function () { var $D = Date, $P = $D.prototype, $N = Number.prototype; // private $P._orient = +1; // private $P._nth = null; // private $P._is = false; // private $P._same = false; // private $P._isSecond = false; // private $N._dateElement = "days"; /** * Moves the date to the next instance of a date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.today().next().friday();
	Date.today().next().fri();
	Date.today().next().march();
	Date.today().next().mar();
	Date.today().next().week();
	
* * @return {Date} date */ $P.next = function () { this._move = true; this._orient = +1; return this; }; /** * Creates a new Date (Date.today()) and moves the date to the next instance of the date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.next().friday();
	Date.next().fri();
	Date.next().march();
	Date.next().mar();
	Date.next().week();
	
* * @return {Date} date */ $D.next = function () { return $D.today().next(); }; /** * Moves the date to the previous instance of a date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.today().last().friday();
	Date.today().last().fri();
	Date.today().last().march();
	Date.today().last().mar();
	Date.today().last().week();
	
* * @return {Date} date */ $P.last = $P.prev = $P.previous = function () { this._move = true; this._orient = -1; return this; }; /** * Creates a new Date (Date.today()) and moves the date to the previous instance of the date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.last().friday();
	Date.last().fri();
	Date.previous().march();
	Date.prev().mar();
	Date.last().week();
	
* * @return {Date} date */ $D.last = $D.prev = $D.previous = function () { return $D.today().last(); }; /** * Performs a equality check when followed by either a month name, day name or .weekday() function. * Example

	Date.today().is().friday(); // true|false
	Date.today().is().fri();
	Date.today().is().march();
	Date.today().is().mar();
	
* * @return {Boolean} true|false */ $P.is = function () { this._is = true; return this; }; /** * Determines if two date objects occur on/in exactly the same instance of the subsequent date part function. * The function .same() must be followed by a date part function (example: .day(), .month(), .year(), etc). * * An optional Date can be passed in the date part function. If now date is passed as a parameter, 'Now' is used. * * The following example demonstrates how to determine if two dates fall on the exact same day. * * Example

	var d1 = Date.today(); // today at 00:00
	var d2 = new Date();   // exactly now.

	// Do they occur on the same day?
	d1.same().day(d2); // true
	
	// Do they occur on the same hour?
	d1.same().hour(d2); // false, unless d2 hour is '00' (midnight).
	
	// What if it's the same day, but one year apart?
	var nextYear = Date.today().add(1).year();

	d1.same().day(nextYear); // false, because the dates must occur on the exact same day. 
	
* * Scenario: Determine if a given date occurs during some week period 2 months from now. * * Example

	var future = Date.today().add(2).months();
	return someDate.same().week(future); // true|false;
	
* * @return {Boolean} true|false */ $P.same = function () { this._same = true; this._isSecond = false; return this; }; /** * Determines if the current date/time occurs during Today. Must be preceded by the .is() function. * Example

	someDate.is().today();    // true|false
	new Date().is().today();  // true
	Date.today().is().today();// true
	Date.today().add(-1).day().is().today(); // false
	
* * @return {Boolean} true|false */ $P.today = function () { return this.same().day(); }; /** * Determines if the current date is a weekday. This function must be preceded by the .is() function. * Example

	Date.today().is().weekday(); // true|false
	
* * @return {Boolean} true|false */ $P.weekday = function () { if (this._nth) { return df("Weekday").call(this); } if (this._move) { return this.addWeekdays(this._orient); } if (this._is) { this._is = false; return (!this.is().sat() && !this.is().sun()); } return false; }; /** * Determines if the current date is on the weekend. This function must be preceded by the .is() function. * Example

	Date.today().is().weekend(); // true|false
	
* * @return {Boolean} true|false */ $P.weekend = function () { if (this._is) { this._is = false; return (this.is().sat() || this.is().sun()); } return false; }; /** * Sets the Time of the current Date instance. A string "6:15 pm" or config object {hour:18, minute:15} are accepted. * Example

	// Set time to 6:15pm with a String
	Date.today().at("6:15pm");

	// Set time to 6:15pm with a config object
	Date.today().at({hour:18, minute:15});
	
* * @return {Date} date */ $P.at = function (time) { return (typeof time === "string") ? $D.parse(this.toString("d") + " " + time) : this.set(time); }; /** * Creates a new Date() and adds this (Number) to the date based on the preceding date element function (eg. second|minute|hour|day|month|year). * Example

	// Undeclared Numbers must be wrapped with parentheses. Requirment of JavaScript.
	(3).days().fromNow();
	(6).months().fromNow();

	// Declared Number variables do not require parentheses. 
	var n = 6;
	n.months().fromNow();
	
* * @return {Date} A new Date instance */ $N.fromNow = $N.after = function (date) { var c = {}; c[this._dateElement] = this; return ((!date) ? new Date() : date.clone()).add(c); }; /** * Creates a new Date() and subtract this (Number) from the date based on the preceding date element function (eg. second|minute|hour|day|month|year). * Example

	// Undeclared Numbers must be wrapped with parentheses. Requirment of JavaScript.
	(3).days().ago();
	(6).months().ago();

	// Declared Number variables do not require parentheses. 
	var n = 6;
	n.months().ago();
	
* * @return {Date} A new Date instance */ $N.ago = $N.before = function (date) { var c = {}, s = (this._dateElement[this._dateElement.length-1] !== "s") ? this._dateElement + "s" : this._dateElement; c[s] = this * -1; return ((!date) ? new Date() : date.clone()).add(c); }; // Do NOT modify the following string tokens. These tokens are used to build dynamic functions. // All culture-specific strings can be found in the CultureInfo files. var dx = ("sunday monday tuesday wednesday thursday friday saturday").split(/\s/), mx = ("january february march april may june july august september october november december").split(/\s/), px = ("Millisecond Second Minute Hour Day Week Month Year Quarter Weekday").split(/\s/), pxf = ("Milliseconds Seconds Minutes Hours Date Week Month FullYear Quarter").split(/\s/), nth = ("final first second third fourth fifth").split(/\s/), de; /** * Returns an object literal of all the date parts. * Example

	var o = new Date().toObject();
	
	// { year: 2008, month: 4, week: 20, day: 13, hour: 18, minute: 9, second: 32, millisecond: 812 }
	
	// The object properties can be referenced directly from the object.
	
	alert(o.day);  // alerts "13"
	alert(o.year); // alerts "2008"
	
* * @return {Date} An object literal representing the original date object. */ $P.toObject = function () { var o = {}; for (var i = 0; i < px.length; i++) { if (this["get" + pxf[i]]) { o[px[i].toLowerCase()] = this["get" + pxf[i]](); } } return o; }; /** * Returns a date created from an object literal. Ignores the .week property if set in the config. * Example

	var o = new Date().toObject();
	
	return Date.fromObject(o); // will return the same date. 

	var o2 = {month: 1, day: 20, hour: 18}; // birthday party!
	Date.fromObject(o2);
	
* * @return {Date} An object literal representing the original date object. */ $D.fromObject = function(config) { config.week = null; return Date.today().set(config); }; // Create day name functions and abbreviated day name functions (eg. monday(), friday(), fri()). var df = function (n) { return function () { if (this._is) { this._is = false; return this.getDay() === n; } if (this._move) { this._move = null; } if (this._nth !== null) { // If the .second() function was called earlier, remove the _orient // from the date, and then continue. // This is required because 'second' can be used in two different context. // // Example // // Date.today().add(1).second(); // Date.march().second().monday(); // // Things get crazy with the following... // Date.march().add(1).second().second().monday(); // but it works!! // if (this._isSecond) { this.addSeconds(this._orient * -1); } // make sure we reset _isSecond this._isSecond = false; var ntemp = this._nth; this._nth = null; var temp = this.clone().moveToLastDayOfMonth(); this.moveToNthOccurrence(n, ntemp); if (this > temp) { throw new RangeError($D.getDayName(n) + " does not occur " + ntemp + " times in the month of " + $D.getMonthName(temp.getMonth()) + " " + temp.getFullYear() + "."); } return this; } return this.moveToDayOfWeek(n, this._orient); }; }; var sdf = function (n) { return function () { var t = $D.today(), shift = n - t.getDay(); if (n === 0 && Date.CultureInfo.firstDayOfWeek === 1 && t.getDay() !== 0) { shift = shift + 7; } return t.addDays(shift); }; }; // Create month name functions and abbreviated month name functions (eg. january(), march(), mar()). var month_instance_functions = function (n) { return function () { if (this._is) { this._is = false; return this.getMonth() === n; } return this.moveToMonth(n, this._orient); }; }; var month_static_functions = function (n) { return function () { return $D.today().set({ month: n, day: 1 }); }; }; var processTerms = function (names, staticFunc, instanceFunc) { for (var i = 0; i < names.length; i++) { // Create constant static Name variables. $D[names[i].toUpperCase()] = $D[names[i].toUpperCase().substring(0, 3)] = i; // Create Name functions. $D[names[i]] = $D[names[i].substring(0, 3)] = staticFunc(i); // Create Name instance functions. $P[names[i]] = $P[names[i].substring(0, 3)] = instanceFunc(i); } }; processTerms(dx, sdf, df); processTerms(mx, month_static_functions, month_instance_functions); // Create date element functions and plural date element functions used with Date (eg. day(), days(), months()). var ef = function (j) { return function () { // if the .second() function was called earlier, the _orient // has alread been added. Just return this and reset _isSecond. if (this._isSecond) { this._isSecond = false; return this; } if (this._same) { this._same = this._is = false; var o1 = this.toObject(), o2 = (arguments[0] || new Date()).toObject(), v = "", k = j.toLowerCase(); // the substr trick with -1 doesn't work in IE8 or less k = (k[k.length-1] === "s") ? k.substring(0,k.length-1) : k; for (var m = (px.length - 1); m > -1; m--) { v = px[m].toLowerCase(); if (o1[v] !== o2[v]) { return false; } if (k === v) { break; } } return true; } if (j.substring(j.length - 1) !== "s") { j += "s"; } if (this._move) { this._move = null; } return this["add" + j](this._orient); }; }; var nf = function (n) { return function () { this._dateElement = n; return this; }; }; for (var k = 0; k < px.length; k++) { de = px[k].toLowerCase(); if(de !== "weekday") { // Create date element functions and plural date element functions used with Date (eg. day(), days(), months()). $P[de] = $P[de + "s"] = ef(px[k]); // Create date element functions and plural date element functions used with Number (eg. day(), days(), months()). $N[de] = $N[de + "s"] = nf(de + "s"); } } $P._ss = ef("Second"); var nthfn = function (n) { return function (dayOfWeek) { if (this._same) { return this._ss(arguments[0]); } if (dayOfWeek || dayOfWeek === 0) { return this.moveToNthOccurrence(dayOfWeek, n); } this._nth = n; // if the operator is 'second' add the _orient, then deal with it later... if (n === 2 && (dayOfWeek === undefined || dayOfWeek === null)) { this._isSecond = true; return this.addSeconds(this._orient); } return this; }; }; for (var l = 0; l < nth.length; l++) { $P[nth[l]] = (l === 0) ? nthfn(-1) : nthfn(l); } }()); (function () { "use strict"; Date.Parsing = { Exception: function (s) { this.message = "Parse error at '" + s.substring(0, 10) + " ...'"; } }; var $P = Date.Parsing; var dayOffsets = { standard: [0,31,59,90,120,151,181,212,243,273,304,334], leap: [0,31,60,91,121,152,182,213,244,274,305,335] }; $P.isLeapYear = function(year) { return ((year % 4 === 0) && (year % 100 !== 0)) || (year % 400 === 0); }; var utils = { multiReplace : function (str, hash ) { var key; for (key in hash) { if (Object.prototype.hasOwnProperty.call(hash, key)) { var regex; if (typeof hash[key] === "function") { } else { regex = (hash[key] instanceof RegExp) ? hash[key] : new RegExp(hash[key], "g"); } str = str.replace(regex, key); } } return str; }, getDayOfYearFromWeek : function (obj) { var d, jan4, offset; obj.weekDay = (!obj.weekDay && obj.weekDay !== 0) ? 1 : obj.weekDay; d = new Date(obj.year, 0, 4); jan4 = d.getDay() === 0 ? 7 : d.getDay(); // JS is 0 indexed on Sunday. offset = jan4+3; obj.dayOfYear = ((obj.week * 7) + (obj.weekDay === 0 ? 7 : obj.weekDay))-offset; return obj; }, getDayOfYear : function (obj, dayOffset) { if (!obj.dayOfYear) { obj = utils.getDayOfYearFromWeek(obj); } for (var i=0;i <= dayOffset.length;i++) { if (obj.dayOfYear < dayOffset[i] || i === dayOffset.length) { obj.day = obj.day ? obj.day : (obj.dayOfYear - dayOffset[i-1]); break; } else { obj.month = i; } } return obj; }, adjustForTimeZone : function (obj, date) { var offset; if (obj.zone.toUpperCase() === "Z" || (obj.zone_hours === 0 && obj.zone_minutes === 0)) { // it's UTC/GML so work out the current timeszone offset offset = -date.getTimezoneOffset(); } else { offset = (obj.zone_hours*60) + (obj.zone_minutes || 0); if (obj.zone_sign === "+") { offset *= -1; } offset -= date.getTimezoneOffset(); } date.setMinutes(date.getMinutes()+offset); return date; }, setDefaults : function (obj) { obj.year = obj.year || Date.today().getFullYear(); obj.hours = obj.hours || 0; obj.minutes = obj.minutes || 0; obj.seconds = obj.seconds || 0; obj.milliseconds = obj.milliseconds || 0; if (!(!obj.month && (obj.week || obj.dayOfYear))) { // if we have a month, or if we don't but don't have the day calculation data obj.month = obj.month || 0; obj.day = obj.day || 1; } return obj; }, dataNum: function (data, mod, explict, postProcess) { var dataNum = data*1; if (mod) { if (postProcess) { return data ? mod(data)*1 : data; } else { return data ? mod(dataNum) : data; } } else if (!explict){ return data ? dataNum : data; } else { return (data && typeof data !== "undefined") ? dataNum : data; } }, timeDataProcess: function (obj) { var timeObj = {}; for (var x in obj.data) { if (obj.data.hasOwnProperty(x)) { timeObj[x] = obj.ignore[x] ? obj.data[x] : utils.dataNum(obj.data[x], obj.mods[x], obj.explict[x], obj.postProcess[x]); } } if (obj.data.secmins) { obj.data.secmins = obj.data.secmins.replace(",", ".") * 60; if (!timeObj.minutes) { timeObj.minutes = obj.data.secmins; } else if (!timeObj.seconds) { timeObj.seconds = obj.data.secmins; } delete obj.secmins; } return timeObj; }, buildTimeObjectFromData: function (data) { var time = utils.timeDataProcess({ data: { year : data[1], month : data[5], day : data[7], week : data[8], dayOfYear : data[10], hours : data[15], zone_hours : data[23], zone_minutes : data[24], zone : data[21], zone_sign : data[22], weekDay : data[9], minutes: data[16], seconds: data[19], milliseconds: data[20], secmins: data[18] }, mods: { month: function(data) { return data-1; }, weekDay: function (data) { data = Math.abs(data); return (data === 7 ? 0 : data); }, minutes: function (data) { return data.replace(":",""); }, seconds: function (data) { return Math.floor( (data.replace(":","").replace(",","."))*1 ); }, milliseconds: function (data) { return (data.replace(",",".")*1000); } }, postProcess: { minutes: true, seconds: true, milliseconds: true }, explict: { zone_hours: true, zone_minutes: true }, ignore: { zone: true, zone_sign: true, secmins: true } }); return time; }, addToHash: function (hash, keys, data) { keys = keys; data = data; var len = keys.length; for (var i = 0; i < len; i++) { hash[keys[i]] = data[i]; } return hash; }, combineRegex: function (r1, r2) { return new RegExp("(("+r1.source+")\\s("+r2.source+"))"); }, getDateNthString: function(add, last, inc){ if (add) { return Date.today().addDays(inc).toString("d"); } else if (last) { return Date.today().last()[inc]().toString("d"); } }, buildRegexData: function (array) { var arr = []; var len = array.length; for (var i=0; i < len; i++) { if (Object.prototype.toString.call(array[i]) === '[object Array]') { // oldIE compat version of Array.isArray arr.push(this.combineRegex(array[i][0], array[i][1])); } else { arr.push(array[i]); } } return arr; } }; $P.processTimeObject = function (obj) { var date, dayOffset; utils.setDefaults(obj); dayOffset = ($P.isLeapYear(obj.year)) ? dayOffsets.leap : dayOffsets.standard; if (!obj.month && (obj.week || obj.dayOfYear)) { utils.getDayOfYear(obj, dayOffset); } else { obj.dayOfYear = dayOffset[obj.month] + obj.day; } date = new Date(obj.year, obj.month, obj.day, obj.hours, obj.minutes, obj.seconds, obj.milliseconds); if (obj.zone) { utils.adjustForTimeZone(obj, date); // adjust (and calculate) for timezone } return date; }; $P.ISO = { regex : /^([\+-]?\d{4}(?!\d{2}\b))((-?)((0[1-9]|1[0-2])(\3([12]\d|0[1-9]|3[01]))?|W([0-4]\d|5[0-3])(-?[1-7])?|(00[1-9]|0[1-9]\d|[12]\d{2}|3([0-5]\d|6[1-6])))([T\s]((([01]\d|2[0-4])((:?)[0-5]\d)?|24\:?00)([\.,]\d+(?!:))?)?(\17[0-5]\d([\.,]\d+)?)?\s?([zZ]|([\+-])([01]\d|2[0-3]):?([0-5]\d)?)?)?)?$/, parse : function (s) { var time, data = s.match(this.regex); if (!data || !data.length) { return null; } time = utils.buildTimeObjectFromData(data); if (!time.year || (!time.year && (!time.month && !time.day) && (!time.week && !time.dayOfYear)) ) { return null; } return $P.processTimeObject(time); } }; $P.Numeric = { isNumeric: function (e){return!isNaN(parseFloat(e))&&isFinite(e);}, regex: /\b([0-1]?[0-9])([0-3]?[0-9])([0-2]?[0-9]?[0-9][0-9])\b/i, parse: function (s) { var data, i, time = {}, order = Date.CultureInfo.dateElementOrder.split(""); if (!(this.isNumeric(s)) || // if it's non-numeric OR (s[0] === "+" && s[0] === "-")) { // It's an arithmatic string (eg +/-1000) return null; } if (s.length < 5 && s.indexOf(".") < 0 && s.indexOf("/") < 0) { // assume it's just a year. time.year = s; return $P.processTimeObject(time); } data = s.match(this.regex); if (!data || !data.length) { return null; } for (i=0; i < order.length; i++) { switch(order[i]) { case "d": time.day = data[i+1]; break; case "m": time.month = (data[i+1]-1); break; case "y": time.year = data[i+1]; break; } } return $P.processTimeObject(time); } }; $P.Normalizer = { regexData: function () { var $R = Date.CultureInfo.regexPatterns; return utils.buildRegexData([ $R.tomorrow, $R.yesterday, [$R.past, $R.mon], [$R.past, $R.tue], [$R.past, $R.wed], [$R.past, $R.thu], [$R.past, $R.fri], [$R.past, $R.sat], [$R.past, $R.sun] ]); }, basicReplaceHash : function() { var $R = Date.CultureInfo.regexPatterns; return { "January": $R.jan.source, "February": $R.feb, "March": $R.mar, "April": $R.apr, "May": $R.may, "June": $R.jun, "July": $R.jul, "August": $R.aug, "September": $R.sep, "October": $R.oct, "November": $R.nov, "December": $R.dec, "": /\bat\b/gi, " ": /\s{2,}/, "am": $R.inTheMorning, "9am": $R.thisMorning, "pm": $R.inTheEvening, "7pm":$R.thisEvening }; }, keys : function(){ return [ utils.getDateNthString(true, false, 1), // tomorrow utils.getDateNthString(true, false, -1), // yesterday utils.getDateNthString(false, true, "monday"), //last mon utils.getDateNthString(false, true, "tuesday"), //last tues utils.getDateNthString(false, true, "wednesday"), //last wed utils.getDateNthString(false, true, "thursday"), //last thurs utils.getDateNthString(false, true, "friday"), //last fri utils.getDateNthString(false, true, "saturday"), //last sat utils.getDateNthString(false, true, "sunday") //last sun ]; }, buildRegexFunctions: function () { var $R = Date.CultureInfo.regexPatterns; var __ = Date.i18n.__; var tomorrowRE = new RegExp("(\\b\\d\\d?("+__("AM")+"|"+__("PM")+")? )("+$R.tomorrow.source.slice(1)+")", "i"); // adapted tomorrow regex for AM PM relative dates var todayRE = new RegExp($R.today.source + "(?!\\s*([+-]))\\b"); // today, but excludes the math operators (eg "today + 2h") this.replaceFuncs = [ [todayRE, function (full) { return (full.length > 1) ? Date.today().toString("d") : full; }], [tomorrowRE, function(full, m1) { var t = Date.today().addDays(1).toString("d"); return (t + " " + m1); }], [$R.amThisMorning, function(str, am){return am;}], [$R.pmThisEvening, function(str, pm){return pm;}] ]; }, buildReplaceData: function () { this.buildRegexFunctions(); this.replaceHash = utils.addToHash(this.basicReplaceHash(), this.keys(), this.regexData()); }, stringReplaceFuncs: function (s) { for (var i=0; i < this.replaceFuncs.length; i++) { s = s.replace(this.replaceFuncs[i][0], this.replaceFuncs[i][1]); } return s; }, parse: function (s) { s = this.stringReplaceFuncs(s); s = utils.multiReplace(s, this.replaceHash); try { var n = s.split(/([\s\-\.\,\/\x27]+)/); if (n.length === 3 && $P.Numeric.isNumeric(n[0]) && $P.Numeric.isNumeric(n[2]) && (n[2].length >= 4)) { // ok, so we're dealing with x/year. But that's not a full date. // This fixes wonky dateElementOrder parsing when set to dmy order. if (Date.CultureInfo.dateElementOrder[0] === "d") { s = "1/" + n[0] + "/" + n[2]; // set to 1st of month and normalize the seperator } } } catch (e) {} return s; } }; $P.Normalizer.buildReplaceData(); }()); (function () { var $P = Date.Parsing; var _ = $P.Operators = { // // Tokenizers // rtoken: function (r) { // regex token return function (s) { var mx = s.match(r); if (mx) { return ([ mx[0], s.substring(mx[0].length) ]); } else { throw new $P.Exception(s); } }; }, token: function () { // whitespace-eating token return function (s) { return _.rtoken(new RegExp("^\\s*" + s + "\\s*"))(s); }; }, stoken: function (s) { // string token return _.rtoken(new RegExp("^" + s)); }, // Atomic Operators until: function (p) { return function (s) { var qx = [], rx = null; while (s.length) { try { rx = p.call(this, s); } catch (e) { qx.push(rx[0]); s = rx[1]; continue; } break; } return [ qx, s ]; }; }, many: function (p) { return function (s) { var rx = [], r = null; while (s.length) { try { r = p.call(this, s); } catch (e) { return [ rx, s ]; } rx.push(r[0]); s = r[1]; } return [ rx, s ]; }; }, // generator operators -- see below optional: function (p) { return function (s) { var r = null; try { r = p.call(this, s); } catch (e) { return [ null, s ]; } return [ r[0], r[1] ]; }; }, not: function (p) { return function (s) { try { p.call(this, s); } catch (e) { return [null, s]; } throw new $P.Exception(s); }; }, ignore: function (p) { return p ? function (s) { var r = null; r = p.call(this, s); return [null, r[1]]; } : null; }, product: function () { var px = arguments[0], qx = Array.prototype.slice.call(arguments, 1), rx = []; for (var i = 0 ; i < px.length ; i++) { rx.push(_.each(px[i], qx)); } return rx; }, cache: function (rule) { var cache = {}, cache_length = 0, cache_keys = [], CACHE_MAX = Date.Config.CACHE_MAX || 100000, r = null; var cacheCheck = function () { if (cache_length === CACHE_MAX) { // kill several keys, don't want to have to do this all the time... for (var i=0; i < 10; i++) { var key = cache_keys.shift(); if (key) { delete cache[key]; cache_length--; } } } }; return function (s) { cacheCheck(); try { r = cache[s] = (cache[s] || rule.call(this, s)); } catch (e) { r = cache[s] = e; } cache_length++; cache_keys.push(s); if (r instanceof $P.Exception) { throw r; } else { return r; } }; }, // vector operators -- see below any: function () { var px = arguments; return function (s) { var r = null; for (var i = 0; i < px.length; i++) { if (px[i] == null) { continue; } try { r = (px[i].call(this, s)); } catch (e) { r = null; } if (r) { return r; } } throw new $P.Exception(s); }; }, each: function () { var px = arguments; return function (s) { var rx = [], r = null; for (var i = 0; i < px.length ; i++) { if (px[i] == null) { continue; } try { r = (px[i].call(this, s)); } catch (e) { throw new $P.Exception(s); } rx.push(r[0]); s = r[1]; } return [ rx, s]; }; }, all: function () { var px = arguments, _ = _; return _.each(_.optional(px)); }, // delimited operators sequence: function (px, d, c) { d = d || _.rtoken(/^\s*/); c = c || null; if (px.length === 1) { return px[0]; } return function (s) { var r = null, q = null; var rx = []; for (var i = 0; i < px.length ; i++) { try { r = px[i].call(this, s); } catch (e) { break; } rx.push(r[0]); try { q = d.call(this, r[1]); } catch (ex) { q = null; break; } s = q[1]; } if (!r) { throw new $P.Exception(s); } if (q) { throw new $P.Exception(q[1]); } if (c) { try { r = c.call(this, r[1]); } catch (ey) { throw new $P.Exception(r[1]); } } return [ rx, (r?r[1]:s) ]; }; }, // // Composite Operators // between: function (d1, p, d2) { d2 = d2 || d1; var _fn = _.each(_.ignore(d1), p, _.ignore(d2)); return function (s) { var rx = _fn.call(this, s); return [[rx[0][0], r[0][2]], rx[1]]; }; }, list: function (p, d, c) { d = d || _.rtoken(/^\s*/); c = c || null; return (p instanceof Array ? _.each(_.product(p.slice(0, -1), _.ignore(d)), p.slice(-1), _.ignore(c)) : _.each(_.many(_.each(p, _.ignore(d))), px, _.ignore(c))); }, set: function (px, d, c) { d = d || _.rtoken(/^\s*/); c = c || null; return function (s) { // r is the current match, best the current 'best' match // which means it parsed the most amount of input var r = null, p = null, q = null, rx = null, best = [[], s], last = false; // go through the rules in the given set for (var i = 0; i < px.length ; i++) { // last is a flag indicating whether this must be the last element // if there is only 1 element, then it MUST be the last one q = null; p = null; r = null; last = (px.length === 1); // first, we try simply to match the current pattern // if not, try the next pattern try { r = px[i].call(this, s); } catch (e) { continue; } // since we are matching against a set of elements, the first // thing to do is to add r[0] to matched elements rx = [[r[0]], r[1]]; // if we matched and there is still input to parse and // we don't already know this is the last element, // we're going to next check for the delimiter ... // if there's none, or if there's no input left to parse // than this must be the last element after all ... if (r[1].length > 0 && ! last) { try { q = d.call(this, r[1]); } catch (ex) { last = true; } } else { last = true; } // if we parsed the delimiter and now there's no more input, // that means we shouldn't have parsed the delimiter at all // so don't update r and mark this as the last element ... if (!last && q[1].length === 0) { last = true; } // so, if this isn't the last element, we're going to see if // we can get any more matches from the remaining (unmatched) // elements ... if (!last) { // build a list of the remaining rules we can match against, // i.e., all but the one we just matched against var qx = []; for (var j = 0; j < px.length ; j++) { if (i !== j) { qx.push(px[j]); } } // now invoke recursively set with the remaining input // note that we don't include the closing delimiter ... // we'll check for that ourselves at the end p = _.set(qx, d).call(this, q[1]); // if we got a non-empty set as a result ... // (otw rx already contains everything we want to match) if (p[0].length > 0) { // update current result, which is stored in rx ... // basically, pick up the remaining text from p[1] // and concat the result from p[0] so that we don't // get endless nesting ... rx[0] = rx[0].concat(p[0]); rx[1] = p[1]; } } // at this point, rx either contains the last matched element // or the entire matched set that starts with this element. // now we just check to see if this variation is better than // our best so far, in terms of how much of the input is parsed if (rx[1].length < best[1].length) { best = rx; } // if we've parsed all the input, then we're finished if (best[1].length === 0) { break; } } // so now we've either gone through all the patterns trying them // as the initial match; or we found one that parsed the entire // input string ... // if best has no matches, just return empty set ... if (best[0].length === 0) { return best; } // if a closing delimiter is provided, then we have to check it also if (c) { // we try this even if there is no remaining input because the pattern // may well be optional or match empty input ... try { q = c.call(this, best[1]); } catch (ey) { throw new $P.Exception(best[1]); } // it parsed ... be sure to update the best match remaining input best[1] = q[1]; } // if we're here, either there was no closing delimiter or we parsed it // so now we have the best match; just return it! return best; }; }, forward: function (gr, fname) { return function (s) { return gr[fname].call(this, s); }; }, // // Translation Operators // replace: function (rule, repl) { return function (s) { var r = rule.call(this, s); return [repl, r[1]]; }; }, process: function (rule, fn) { return function (s) { var r = rule.call(this, s); return [fn.call(this, r[0]), r[1]]; }; }, min: function (min, rule) { return function (s) { var rx = rule.call(this, s); if (rx[0].length < min) { throw new $P.Exception(s); } return rx; }; } }; // Generator Operators And Vector Operators // Generators are operators that have a signature of F(R) => R, // taking a given rule and returning another rule, such as // ignore, which parses a given rule and throws away the result. // Vector operators are those that have a signature of F(R1,R2,...) => R, // take a list of rules and returning a new rule, such as each. // Generator operators are converted (via the following _generator // function) into functions that can also take a list or array of rules // and return an array of new rules as though the function had been // called on each rule in turn (which is what actually happens). // This allows generators to be used with vector operators more easily. // Example: // each(ignore(foo, bar)) instead of each(ignore(foo), ignore(bar)) // This also turns generators into vector operators, which allows // constructs like: // not(cache(foo, bar)) var _generator = function (op) { function gen() { var args = null, rx = [], px, i; if (arguments.length > 1) { args = Array.prototype.slice.call(arguments); } else if (arguments[0] instanceof Array) { args = arguments[0]; } if (args) { px = args.shift(); if (px.length > 0) { args.unshift(px[i]); rx.push(op.apply(null, args)); args.shift(); return rx; } } else { return op.apply(null, arguments); } } return gen; }; var gx = "optional not ignore cache".split(/\s/); for (var i = 0 ; i < gx.length ; i++) { _[gx[i]] = _generator(_[gx[i]]); } var _vector = function (op) { return function () { if (arguments[0] instanceof Array) { return op.apply(null, arguments[0]); } else { return op.apply(null, arguments); } }; }; var vx = "each any all".split(/\s/); for (var j = 0 ; j < vx.length ; j++) { _[vx[j]] = _vector(_[vx[j]]); } }()); (function () { var $D = Date; var flattenAndCompact = function (ax) { var rx = []; for (var i = 0; i < ax.length; i++) { if (ax[i] instanceof Array) { rx = rx.concat(flattenAndCompact(ax[i])); } else { if (ax[i]) { rx.push(ax[i]); } } } return rx; }; var parseMeridian = function () { if (this.meridian && (this.hour || this.hour === 0)) { if (this.meridian === "a" && this.hour > 11 && Date.Config.strict24hr){ throw "Invalid hour and meridian combination"; } else if (this.meridian === "p" && this.hour < 12 && Date.Config.strict24hr){ throw "Invalid hour and meridian combination"; } else if (this.meridian === "p" && this.hour < 12) { this.hour = this.hour + 12; } else if (this.meridian === "a" && this.hour === 12) { this.hour = 0; } } }; var setDefaults = function () { var now = new Date(); if ((this.hour || this.minute) && (!this.month && !this.year && !this.day)) { this.day = now.getDate(); } if (!this.year) { this.year = now.getFullYear(); } if (!this.month && this.month !== 0) { this.month = now.getMonth(); } if (!this.day) { this.day = 1; } if (!this.hour) { this.hour = 0; } if (!this.minute) { this.minute = 0; } if (!this.second) { this.second = 0; } if (!this.millisecond) { this.millisecond = 0; } }; var finishUtils = { getToday: function () { if (this.now || "hour minute second".indexOf(this.unit) !== -1) { return new Date(); } else { return $D.today(); } }, setDaysFromWeekday: function (today, orient){ var gap; orient = orient || 1; this.unit = "day"; gap = ($D.getDayNumberFromName(this.weekday) - today.getDay()); this.days = gap ? ((gap + (orient * 7)) % 7) : (orient * 7); return this; }, setMonthsFromMonth: function (today, orient) { var gap; orient = orient || 1; this.unit = "month"; gap = (this.month - today.getMonth()); this.months = gap ? ((gap + (orient * 12)) % 12) : (orient * 12); this.month = null; return this; }, setDMYFromWeekday: function () { var d = Date[this.weekday](); this.day = d.getDate(); if (!this.month) { this.month = d.getMonth(); } this.year = d.getFullYear(); return this; }, setUnitValue: function (orient) { if (!this.value && this.operator && this.operator !== null && this[this.unit + "s"] && this[this.unit + "s"] !== null) { this[this.unit + "s"] = this[this.unit + "s"] + ((this.operator === "add") ? 1 : -1) + (this.value||0) * orient; } else if (this[this.unit + "s"] == null || this.operator != null) { if (!this.value) { this.value = 1; } this[this.unit + "s"] = this.value * orient; } }, generateDateFromWeeks: function () { var weekday = (this.weekday !== undefined) ? this.weekday : "today"; var d = Date[weekday]().addWeeks(this.weeks); if (this.now) { d.setTimeToNow(); } return d; } }; $D.Translator = { hour: function (s) { return function () { this.hour = Number(s); }; }, minute: function (s) { return function () { this.minute = Number(s); }; }, second: function (s) { return function () { this.second = Number(s); }; }, /* for ss.s format */ secondAndMillisecond: function (s) { return function () { var mx = s.match(/^([0-5][0-9])\.([0-9]{1,3})/); this.second = Number(mx[1]); this.millisecond = Number(mx[2]); }; }, meridian: function (s) { return function () { this.meridian = s.slice(0, 1).toLowerCase(); }; }, timezone: function (s) { return function () { var n = s.replace(/[^\d\+\-]/g, ""); if (n.length) { this.timezoneOffset = Number(n); } else { this.timezone = s.toLowerCase(); } }; }, day: function (x) { var s = x[0]; return function () { this.day = Number(s.match(/\d+/)[0]); if (this.day < 1) { throw "invalid day"; } }; }, month: function (s) { return function () { this.month = (s.length === 3) ? "jan feb mar apr may jun jul aug sep oct nov dec".indexOf(s)/4 : Number(s) - 1; if (this.month < 0) { throw "invalid month"; } }; }, year: function (s) { return function () { var n = Number(s); this.year = ((s.length > 2) ? n : (n + (((n + 2000) < Date.CultureInfo.twoDigitYearMax) ? 2000 : 1900))); }; }, rday: function (s) { return function () { switch (s) { case "yesterday": this.days = -1; break; case "tomorrow": this.days = 1; break; case "today": this.days = 0; break; case "now": this.days = 0; this.now = true; break; } }; }, finishExact: function (x) { var d; x = (x instanceof Array) ? x : [x]; for (var i = 0 ; i < x.length ; i++) { if (x[i]) { x[i].call(this); } } setDefaults.call(this); parseMeridian.call(this); if (this.day > $D.getDaysInMonth(this.year, this.month)) { throw new RangeError(this.day + " is not a valid value for days."); } d = new Date(this.year, this.month, this.day, this.hour, this.minute, this.second, this.millisecond); if (this.year < 100) { d.setFullYear(this.year); // means years less that 100 are process correctly. JS will parse it otherwise as 1900-1999. } if (this.timezone) { d.set({ timezone: this.timezone }); } else if (this.timezoneOffset) { d.set({ timezoneOffset: this.timezoneOffset }); } return d; }, finish: function (x) { var today, expression, orient, temp; x = (x instanceof Array) ? flattenAndCompact(x) : [ x ]; if (x.length === 0) { return null; } for (var i = 0 ; i < x.length ; i++) { if (typeof x[i] === "function") { x[i].call(this); } } if (this.now && !this.unit && !this.operator) { return new Date(); } else { today = finishUtils.getToday.call(this); } expression = !!(this.days && this.days !== null || this.orient || this.operator); orient = ((this.orient === "past" || this.operator === "subtract") ? -1 : 1); if (this.month && this.unit === "week") { this.value = this.month + 1; delete this.month; delete this.day; } if ((this.month || this.month === 0) && "year day hour minute second".indexOf(this.unit) !== -1) { if (!this.value) { this.value = this.month + 1; } this.month = null; expression = true; } if (!expression && this.weekday && !this.day && !this.days) { finishUtils.setDMYFromWeekday.call(this); } if (expression && this.weekday && this.unit !== "month" && this.unit !== "week") { finishUtils.setDaysFromWeekday.call(this, today, orient); } if (this.weekday && this.unit !== "week" && !this.day && !this.days) { temp = Date[this.weekday](); this.day = temp.getDate(); if (temp.getMonth() !== today.getMonth()) { this.month = temp.getMonth(); } } if (this.month && this.unit === "day" && this.operator) { if (!this.value) { this.value = (this.month + 1); } this.month = null; } if (this.value != null && this.month != null && this.year != null) { this.day = this.value * 1; } if (this.month && !this.day && this.value) { today.set({ day: this.value * 1 }); if (!expression) { this.day = this.value * 1; } } if (!this.month && this.value && this.unit === "month" && !this.now) { this.month = this.value; expression = true; } if (expression && (this.month || this.month === 0) && this.unit !== "year") { finishUtils.setMonthsFromMonth.call(this, today, orient); } if (!this.unit) { this.unit = "day"; } finishUtils.setUnitValue.call(this, orient); parseMeridian.call(this); if ((this.month || this.month === 0) && !this.day) { this.day = 1; } if (!this.orient && !this.operator && this.unit === "week" && this.value && !this.day && !this.month) { return Date.today().setWeek(this.value); } if (this.unit === "week" && this.weeks && !this.day && !this.month) { return finishUtils.generateDateFromWeeks.call(this); } if (expression && this.timezone && this.day && this.days) { this.day = this.days; } if (expression){ today.add(this); } else { today.set(this); } if (this.timezone) { this.timezone = this.timezone.toUpperCase(); var offset = $D.getTimezoneOffset(this.timezone); var timezone; if (today.hasDaylightSavingTime()) { // lets check that we're being sane with timezone setting timezone = $D.getTimezoneAbbreviation(offset, today.isDaylightSavingTime()); if (timezone !== this.timezone) { // bugger, we're in a place where things like EST vs EDT matters. if (today.isDaylightSavingTime()) { today.addHours(-1); } else { today.addHours(1); } } } today.setTimezoneOffset(offset); } return today; } }; }()); (function () { var $D = Date; $D.Grammar = {}; var _ = $D.Parsing.Operators, g = $D.Grammar, t = $D.Translator, _fn; // Allow rolling up into general purpose rules _fn = function () { return _.each(_.any.apply(null, arguments), _.not(g.ctoken2("timeContext"))); }; g.datePartDelimiter = _.rtoken(/^([\s\-\.\,\/\x27]+)/); g.timePartDelimiter = _.stoken(":"); g.whiteSpace = _.rtoken(/^\s*/); g.generalDelimiter = _.rtoken(/^(([\s\,]|at|@|on)+)/); var _C = {}; g.ctoken = function (keys) { var fn = _C[keys]; if (! fn) { var c = Date.CultureInfo.regexPatterns; var kx = keys.split(/\s+/), px = []; for (var i = 0; i < kx.length ; i++) { px.push(_.replace(_.rtoken(c[kx[i]]), kx[i])); } fn = _C[keys] = _.any.apply(null, px); } return fn; }; g.ctoken2 = function (key) { return _.rtoken(Date.CultureInfo.regexPatterns[key]); }; var cacheProcessRtoken = function (key, token, type, eachToken) { if (eachToken) { g[key] = _.cache(_.process(_.each(_.rtoken(token),_.optional(g.ctoken2(eachToken))), type)); } else { g[key] = _.cache(_.process(_.rtoken(token), type)); } }; var cacheProcessCtoken = function (token, type) { return _.cache(_.process(g.ctoken2(token), type)); }; var _F = {}; //function cache var _get = function (f) { _F[f] = (_F[f] || g.format(f)[0]); return _F[f]; }; g.allformats = function (fx) { var rx = []; if (fx instanceof Array) { for (var i = 0; i < fx.length; i++) { rx.push(_get(fx[i])); } } else { rx.push(_get(fx)); } return rx; }; g.formats = function (fx) { if (fx instanceof Array) { var rx = []; for (var i = 0 ; i < fx.length ; i++) { rx.push(_get(fx[i])); } return _.any.apply(null, rx); } else { return _get(fx); } }; var grammarFormats = { timeFormats: function(){ var i, RTokenKeys = [ "h", "hh", "H", "HH", "m", "mm", "s", "ss", "ss.s", "z", "zz" ], RToken = [ /^(0[0-9]|1[0-2]|[1-9])/, /^(0[0-9]|1[0-2])/, /^([0-1][0-9]|2[0-3]|[0-9])/, /^([0-1][0-9]|2[0-3])/, /^([0-5][0-9]|[0-9])/, /^[0-5][0-9]/, /^([0-5][0-9]|[0-9])/, /^[0-5][0-9]/, /^[0-5][0-9]\.[0-9]{1,3}/, /^((\+|\-)\s*\d\d\d\d)|((\+|\-)\d\d\:?\d\d)/, /^((\+|\-)\s*\d\d\d\d)|((\+|\-)\d\d\:?\d\d)/ ], tokens = [ t.hour, t.hour, t.hour, t.hour, t.minute, t.minute, t.second, t.second, t.secondAndMillisecond, t.timezone, t.timezone ]; for (i=0; i < RTokenKeys.length; i++) { cacheProcessRtoken(RTokenKeys[i], RToken[i], tokens[i]); } g.hms = _.cache(_.sequence([g.H, g.m, g.s], g.timePartDelimiter)); g.t = cacheProcessCtoken("shortMeridian", t.meridian); g.tt = cacheProcessCtoken("longMeridian", t.meridian); g.zzz = cacheProcessCtoken("timezone", t.timezone); g.timeSuffix = _.each(_.ignore(g.whiteSpace), _.set([ g.tt, g.zzz ])); g.time = _.each(_.optional(_.ignore(_.stoken("T"))), g.hms, g.timeSuffix); }, dateFormats: function () { // pre-loaded rules for different date part order preferences var _setfn = function () { return _.set(arguments, g.datePartDelimiter); }; var i, RTokenKeys = [ "d", "dd", "M", "MM", "y", "yy", "yyy", "yyyy" ], RToken = [ /^([0-2]\d|3[0-1]|\d)/, /^([0-2]\d|3[0-1])/, /^(1[0-2]|0\d|\d)/, /^(1[0-2]|0\d)/, /^(\d+)/, /^(\d\d)/, /^(\d\d?\d?\d?)/, /^(\d\d\d\d)/ ], tokens = [ t.day, t.day, t.month, t.month, t.year, t.year, t.year, t.year ], eachToken = [ "ordinalSuffix", "ordinalSuffix" ]; for (i=0; i < RTokenKeys.length; i++) { cacheProcessRtoken(RTokenKeys[i], RToken[i], tokens[i], eachToken[i]); } g.MMM = g.MMMM = _.cache(_.process(g.ctoken("jan feb mar apr may jun jul aug sep oct nov dec"), t.month)); g.ddd = g.dddd = _.cache(_.process(g.ctoken("sun mon tue wed thu fri sat"), function (s) { return function () { this.weekday = s; }; } )); g.day = _fn(g.d, g.dd); g.month = _fn(g.M, g.MMM); g.year = _fn(g.yyyy, g.yy); g.mdy = _setfn(g.ddd, g.month, g.day, g.year); g.ymd = _setfn(g.ddd, g.year, g.month, g.day); g.dmy = _setfn(g.ddd, g.day, g.month, g.year); g.date = function (s) { return ((g[Date.CultureInfo.dateElementOrder] || g.mdy).call(this, s)); }; }, relative: function () { // relative date / time expressions g.orientation = _.process(g.ctoken("past future"), function (s) { return function () { this.orient = s; }; } ); g.operator = _.process(g.ctoken("add subtract"), function (s) { return function () { this.operator = s; }; } ); g.rday = _.process(g.ctoken("yesterday tomorrow today now"), t.rday); g.unit = _.process(g.ctoken("second minute hour day week month year"), function (s) { return function () { this.unit = s; }; } ); } }; g.buildGrammarFormats = function () { // these need to be rebuilt every time the language changes. _C = {}; grammarFormats.timeFormats(); grammarFormats.dateFormats(); grammarFormats.relative(); g.value = _.process(_.rtoken(/^([-+]?\d+)?(st|nd|rd|th)?/), function (s) { return function () { this.value = s.replace(/\D/g, ""); }; } ); g.expression = _.set([g.rday, g.operator, g.value, g.unit, g.orientation, g.ddd, g.MMM ]); g.format = _.process(_.many( _.any( // translate format specifiers into grammar rules _.process( _.rtoken(/^(dd?d?d?(?!e)|MM?M?M?|yy?y?y?|hh?|HH?|mm?|ss?|tt?|zz?z?)/), function (fmt) { if (g[fmt]) { return g[fmt]; } else { throw $D.Parsing.Exception(fmt); } } ), // translate separator tokens into token rules _.process(_.rtoken(/^[^dMyhHmstz]+/), // all legal separators function (s) { return _.ignore(_.stoken(s)); } ) ) ), // construct the parser ... function (rules) { return _.process(_.each.apply(null, rules), t.finishExact); } ); // starting rule for general purpose grammar g._start = _.process(_.set([ g.date, g.time, g.expression ], g.generalDelimiter, g.whiteSpace), t.finish); }; g.buildGrammarFormats(); // parsing date format specifiers - ex: "h:m:s tt" // this little guy will generate a custom parser based // on the format string, ex: g.format("h:m:s tt") // check for these formats first g._formats = g.formats([ "\"yyyy-MM-ddTHH:mm:ssZ\"", "yyyy-MM-ddTHH:mm:ss.sz", "yyyy-MM-ddTHH:mm:ssZ", "yyyy-MM-ddTHH:mm:ssz", "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-ddTHH:mmZ", "yyyy-MM-ddTHH:mmz", "yyyy-MM-ddTHH:mm", "ddd, MMM dd, yyyy H:mm:ss tt", "ddd MMM d yyyy HH:mm:ss zzz", "MMddyyyy", "ddMMyyyy", "Mddyyyy", "ddMyyyy", "Mdyyyy", "dMyyyy", "yyyy", "Mdyy", "dMyy", "d" ]); // real starting rule: tries selected formats first, // then general purpose rule g.start = function (s) { try { var r = g._formats.call({}, s); if (r[1].length === 0) { return r; } } catch (e) {} return g._start.call({}, s); }; }()); (function () { var $D = Date; /** * @desc Converts the specified string value into its JavaScript Date equivalent using CultureInfo specific format information. * * Example

	///////////
	// Dates //
	///////////

	// 15-Oct-2004
	var d1 = Date.parse("10/15/2004");

	// 15-Oct-2004
	var d1 = Date.parse("15-Oct-2004");

	// 15-Oct-2004
	var d1 = Date.parse("2004.10.15");

	//Fri Oct 15, 2004
	var d1 = Date.parse("Fri Oct 15, 2004");

	///////////
	// Times //
	///////////

	// Today at 10 PM.
	var d1 = Date.parse("10 PM");

	// Today at 10:30 PM.
	var d1 = Date.parse("10:30 P.M.");

	// Today at 6 AM.
	var d1 = Date.parse("06am");

	/////////////////////
	// Dates and Times //
	/////////////////////

	// 8-July-2004 @ 10:30 PM
	var d1 = Date.parse("July 8th, 2004, 10:30 PM");

	// 1-July-2004 @ 10:30 PM
	var d1 = Date.parse("2004-07-01T22:30:00");

	////////////////////
	// Relative Dates //
	////////////////////

	// Returns today's date. The string "today" is culture specific.
	var d1 = Date.parse("today");

	// Returns yesterday's date. The string "yesterday" is culture specific.
	var d1 = Date.parse("yesterday");

	// Returns the date of the next thursday.
	var d1 = Date.parse("Next thursday");

	// Returns the date of the most previous monday.
	var d1 = Date.parse("last monday");

	// Returns today's day + one year.
	var d1 = Date.parse("next year");

	///////////////
	// Date Math //
	///////////////

	// Today + 2 days
	var d1 = Date.parse("t+2");

	// Today + 2 days
	var d1 = Date.parse("today + 2 days");

	// Today + 3 months
	var d1 = Date.parse("t+3m");

	// Today - 1 year
	var d1 = Date.parse("today - 1 year");

	// Today - 1 year
	var d1 = Date.parse("t-1y"); 


	/////////////////////////////
	// Partial Dates and Times //
	/////////////////////////////

	// July 15th of this year.
	var d1 = Date.parse("July 15");

	// 15th day of current day and year.
	var d1 = Date.parse("15");

	// July 1st of current year at 10pm.
	var d1 = Date.parse("7/1 10pm");
	
* * @param {String} The string value to convert into a Date object [Required] * @return {Date} A Date object or null if the string cannot be converted into a Date. */ var parseUtils = { removeOrds: function (s) { ords = s.match(/\b(\d+)(?:st|nd|rd|th)\b/); // find ordinal matches s = ((ords && ords.length === 2) ? s.replace(ords[0], ords[1]) : s); return s; }, grammarParser: function (s) { var r = null; try { r = $D.Grammar.start.call({}, s.replace(/^\s*(\S*(\s+\S+)*)\s*$/, "$1")); } catch (e) { return null; } return ((r[1].length === 0) ? r[0] : null); }, nativeFallback: function(s) { var t; try { // ok we haven't parsed it, last ditch attempt with the built-in parser. t = Date._parse(s); return (t || t === 0) ? new Date(t) : null; } catch (e) { return null; } } }; function parse (s) { var d; if (!s) { return null; } if (s instanceof Date) { return s.clone(); } if (s.length >= 4 && s.charAt(0) !== "0" && s.charAt(0) !== "+"&& s.charAt(0) !== "-") { // ie: 2004 will pass, 0800 won't. // Start with specific formats d = $D.Parsing.ISO.parse(s) || $D.Parsing.Numeric.parse(s); } if (d instanceof Date && !isNaN(d.getTime())) { return d; } else { // find ordinal dates (1st, 3rd, 8th, etc and remove them as they cause parsing issues) s = $D.Parsing.Normalizer.parse(parseUtils.removeOrds(s)); d = parseUtils.grammarParser(s); if (d !== null) { return d; } else { return parseUtils.nativeFallback(s); } } } if (!$D._parse) { $D._parse = $D.parse; } $D.parse = parse; Date.getParseFunction = function (fx) { var fns = Date.Grammar.allformats(fx); return function (s) { var r = null; for (var i = 0; i < fns.length; i++) { try { r = fns[i].call({}, s); } catch (e) { continue; } if (r[1].length === 0) { return r[0]; } } return null; }; }; /** * Converts the specified string value into its JavaScript Date equivalent using the specified format {String} or formats {Array} and the CultureInfo specific format information. * The format of the string value must match one of the supplied formats exactly. * * Example

	// 15-Oct-2004
	var d1 = Date.parseExact("10/15/2004", "M/d/yyyy");

	// 15-Oct-2004
	var d1 = Date.parse("15-Oct-2004", "M-ddd-yyyy");

	// 15-Oct-2004
	var d1 = Date.parse("2004.10.15", "yyyy.MM.dd");

	// Multiple formats
	var d1 = Date.parseExact("10/15/2004", ["M/d/yyyy", "MMMM d, yyyy"]);
	
* * @param {String} The string value to convert into a Date object [Required]. * @param {Object} The expected format {String} or an array of expected formats {Array} of the date string [Required]. * @return {Date} A Date object or null if the string cannot be converted into a Date. */ $D.parseExact = function (s, fx) { return $D.getParseFunction(fx)(s); }; }()); (function () { var $D = Date, $P = $D.prototype, // $C = $D.CultureInfo, // not used atm p = function (s, l) { if (!l) { l = 2; } return ("000" + s).slice(l * -1); }; /** * Converts a PHP format string to Java/.NET format string. * A PHP format string can be used with ._format or .format. * A Java/.NET format string can be used with .toString(). * The .parseExact function will only accept a Java/.NET format string * * Example * var f1 = "%m/%d/%y" * var f2 = Date.normalizeFormat(f1); // "MM/dd/yy" * * new Date().format(f1); // "04/13/08" * new Date()._format(f1); // "04/13/08" * new Date().toString(f2); // "04/13/08" * * var date = Date.parseExact("04/13/08", f2); // Sun Apr 13 2008 * * @param {String} A PHP format string consisting of one or more format spcifiers. * @return {String} The PHP format converted to a Java/.NET format string. */ var normalizerSubstitutions = { "d" : "dd", "%d": "dd", "D" : "ddd", "%a": "ddd", "j" : "dddd", "l" : "dddd", "%A": "dddd", "S" : "S", "F" : "MMMM", "%B": "MMMM", "m" : "MM", "%m": "MM", "M" : "MMM", "%b": "MMM", "%h": "MMM", "n" : "M", "Y" : "yyyy", "%Y": "yyyy", "y" : "yy", "%y": "yy", "g" : "h", "%I": "h", "G" : "H", "h" : "hh", "H" : "HH", "%H": "HH", "i" : "mm", "%M": "mm", "s" : "ss", "%S": "ss", "%r": "hh:mm tt", "%R": "H:mm", "%T": "H:mm:ss", "%X": "t", "%x": "d", "%e": "d", "%D": "MM/dd/yy", "%n": "\\n", "%t": "\\t", "e" : "z", "T" : "z", "%z": "z", "%Z": "z", "Z" : "ZZ", "N" : "u", "w" : "u", "%w": "u", "W" : "W", "%V": "W" }; var normalizer = { substitutes: function (m) { return normalizerSubstitutions[m]; }, interpreted: function (m, x) { var y; switch (m) { case "%u": return x.getDay() + 1; case "z": return x.getOrdinalNumber(); case "%j": return p(x.getOrdinalNumber(), 3); case "%U": var d1 = x.clone().set({month: 0, day: 1}).addDays(-1).moveToDayOfWeek(0), d2 = x.clone().addDays(1).moveToDayOfWeek(0, -1); return (d2 < d1) ? "00" : p((d2.getOrdinalNumber() - d1.getOrdinalNumber()) / 7 + 1); case "%W": return p(x.getWeek()); case "t": return $D.getDaysInMonth(x.getFullYear(), x.getMonth()); case "o": case "%G": return x.setWeek(x.getISOWeek()).toString("yyyy"); case "%g": return x._format("%G").slice(-2); case "a": case "%p": return t("tt").toLowerCase(); case "A": return t("tt").toUpperCase(); case "u": return p(x.getMilliseconds(), 3); case "I": return (x.isDaylightSavingTime()) ? 1 : 0; case "O": return x.getUTCOffset(); case "P": y = x.getUTCOffset(); return y.substring(0, y.length - 2) + ":" + y.substring(y.length - 2); case "B": var now = new Date(); return Math.floor(((now.getHours() * 3600) + (now.getMinutes() * 60) + now.getSeconds() + (now.getTimezoneOffset() + 60) * 60) / 86.4); case "c": return x.toISOString().replace(/\"/g, ""); case "U": return $D.strtotime("now"); case "%c": return t("d") + " " + t("t"); case "%C": return Math.floor(x.getFullYear() / 100 + 1); } }, shouldOverrideDefaults: function (m) { switch (m) { case "%e": return true; default: return false; } }, parse: function (m, context) { var formatString, c = context || new Date(); formatString = normalizer.substitutes(m); if (formatString) { return formatString; } formatString = normalizer.interpreted(m, c); if (formatString) { return formatString; } else { return m; } } }; $D.normalizeFormat = function (format, context) { return format.replace(/(%|\\)?.|%%/g, function(t){ return normalizer.parse(t, context); }); }; /** * Format a local Unix timestamp according to locale settings * * Example: * Date.strftime("%m/%d/%y", new Date()); // "04/13/08" * Date.strftime("c", "2008-04-13T17:52:03Z"); // "04/13/08" * * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @param {Number|String} The number representing the number of seconds that have elapsed since January 1, 1970 (local time). * @return {String} A string representation of the current Date object. */ $D.strftime = function (format, time) { var d = Date.parse(time); return d._format(format); }; /** * Parse any textual datetime description into a Unix timestamp. * A Unix timestamp is the number of seconds that have elapsed since January 1, 1970 (midnight UTC/GMT). * * Example: * Date.strtotime("04/13/08"); // 1208044800 * Date.strtotime("1970-01-01T00:00:00Z"); // 0 * * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @param {Object} A string or date object. * @return {String} A string representation of the current Date object. */ $D.strtotime = function (time) { var d = $D.parse(time); return Math.round($D.UTC(d.getUTCFullYear(), d.getUTCMonth(), d.getUTCDate(), d.getUTCHours(), d.getUTCMinutes(), d.getUTCSeconds(), d.getUTCMilliseconds()) / 1000); }; /** * Converts the value of the current Date object to its equivalent string representation using a PHP/Unix style of date format specifiers. * Format Specifiers * Format Description Example * ------ --------------------------------------------------------------------------- ----------------------- * %a abbreviated weekday name according to the current localed "Mon" through "Sun" * %A full weekday name according to the current localed "Sunday" through "Saturday" * %b abbreviated month name according to the current localed "Jan" through "Dec" * %B full month name according to the current locale "January" through "December" * %c preferred date and time representation for the current locale "4/13/2008 12:33 PM" * %C century number (the year divided by 100 and truncated to an integer) "00" to "99" * %d day of the month as a decimal number "01" to "31" * %D same as %m/%d/%y "04/13/08" * %e day of the month as a decimal number, a single digit is preceded by a space "1" to "31" * %g like %G, but without the century "08" * %G The 4-digit year corresponding to the ISO week number (see %V). "2008" * This has the same format and value as %Y, except that if the ISO week number * belongs to the previous or next year, that year is used instead. * %h same as %b "Jan" through "Dec" * %H hour as a decimal number using a 24-hour clock. "00" to "23" * %I hour as a decimal number using a 12-hour clock. "01" to "12" * %j day of the year as a decimal number. "001" to "366" * %m month as a decimal number. "01" to "12" * %M minute as a decimal number. "00" to "59" * %n newline character "\n" * %p either "am" or "pm" according to the given time value, or the "am" or "pm" * corresponding strings for the current locale. * %r time in a.m. and p.m. notation "8:44 PM" * %R time in 24 hour notation "20:44" * %S second as a decimal number "00" to "59" * %t tab character "\t" * %T current time, equal to %H:%M:%S "12:49:11" * %u weekday as a decimal number ["1", "7"], with "1" representing Monday "1" to "7" * %U week number of the current year as a decimal number, starting with the "0" to ("52" or "53") * first Sunday as the first day of the first week * %V The ISO 8601:1988 week number of the current year as a decimal number, "00" to ("52" or "53") * range 01 to 53, where week 1 is the first week that has at least 4 days * in the current year, and with Monday as the first day of the week. * (Use %G or %g for the year component that corresponds to the week number * for the specified timestamp.) * %W week number of the current year as a decimal number, starting with the "00" to ("52" or "53") * first Monday as the first day of the first week * %w day of the week as a decimal, Sunday being "0" "0" to "6" * %x preferred date representation for the current locale without the time "4/13/2008" * %X preferred time representation for the current locale without the date "12:53:05" * %y year as a decimal number without a century "00" "99" * %Y year as a decimal number including the century "2008" * %Z time zone or name or abbreviation "UTC", "EST", "PST" * %z same as %Z * %% a literal "%" characters "%" * d Day of the month, 2 digits with leading zeros "01" to "31" * D A textual representation of a day, three letters "Mon" through "Sun" * j Day of the month without leading zeros "1" to "31" * l A full textual representation of the day of the week (lowercase "L") "Sunday" through "Saturday" * N ISO-8601 numeric representation of the day of the week (added in PHP 5.1.0) "1" (for Monday) through "7" (for Sunday) * S English ordinal suffix for the day of the month, 2 characters "st", "nd", "rd" or "th". Works well with j * w Numeric representation of the day of the week "0" (for Sunday) through "6" (for Saturday) * z The day of the year (starting from "0") "0" through "365" * W ISO-8601 week number of year, weeks starting on Monday "00" to ("52" or "53") * F A full textual representation of a month, such as January or March "January" through "December" * m Numeric representation of a month, with leading zeros "01" through "12" * M A short textual representation of a month, three letters "Jan" through "Dec" * n Numeric representation of a month, without leading zeros "1" through "12" * t Number of days in the given month "28" through "31" * L Whether it's a leap year "1" if it is a leap year, "0" otherwise * o ISO-8601 year number. This has the same value as Y, except that if the "2008" * ISO week number (W) belongs to the previous or next year, that year * is used instead. * Y A full numeric representation of a year, 4 digits "2008" * y A two digit representation of a year "08" * a Lowercase Ante meridiem and Post meridiem "am" or "pm" * A Uppercase Ante meridiem and Post meridiem "AM" or "PM" * B Swatch Internet time "000" through "999" * g 12-hour format of an hour without leading zeros "1" through "12" * G 24-hour format of an hour without leading zeros "0" through "23" * h 12-hour format of an hour with leading zeros "01" through "12" * H 24-hour format of an hour with leading zeros "00" through "23" * i Minutes with leading zeros "00" to "59" * s Seconds, with leading zeros "00" through "59" * u Milliseconds "54321" * e Timezone identifier "UTC", "EST", "PST" * I Whether or not the date is in daylight saving time (uppercase i) "1" if Daylight Saving Time, "0" otherwise * O Difference to Greenwich time (GMT) in hours "+0200", "-0600" * P Difference to Greenwich time (GMT) with colon between hours and minutes "+02:00", "-06:00" * T Timezone abbreviation "UTC", "EST", "PST" * Z Timezone offset in seconds. The offset for timezones west of UTC is "-43200" through "50400" * always negative, and for those east of UTC is always positive. * c ISO 8601 date "2004-02-12T15:19:21+00:00" * r RFC 2822 formatted date "Thu, 21 Dec 2000 16:01:07 +0200" * U Seconds since the Unix Epoch (January 1 1970 00:00:00 GMT) "0" * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @return {String} A string representation of the current Date object. */ var formatReplace = function (context) { return function (m) { var formatString, override = false; if (m.charAt(0) === "\\" || m.substring(0, 2) === "%%") { return m.replace("\\", "").replace("%%", "%"); } override = normalizer.shouldOverrideDefaults(m); formatString = $D.normalizeFormat(m, context); if (formatString) { return context.toString(formatString, override); } }; }; $P._format = function (format) { var formatter = formatReplace(this); if (!format) { return this._toString(); } else { return format.replace(/(%|\\)?.|%%/g, formatter); } }; if (!$P.format) { $P.format = $P._format; } }()); (function () { "use strict"; var gFn = function (attr) { return function () { return this[attr]; }; }; var sFn = function (attr) { return function (val) { this[attr] = val; return this; }; }; var attrs = ["years", "months", "days", "hours", "minutes", "seconds", "milliseconds"]; var addSetFuncs = function (context, attrs) { for (var i = 0; i < attrs.length ; i++) { var $a = attrs[i], $b = $a.slice(0, 1).toUpperCase() + $a.slice(1); context.prototype[$a] = 0; context.prototype["get" + $b] = gFn($a); context.prototype["set" + $b] = sFn($a); } }; /** * new TimeSpan(milliseconds); * new TimeSpan(days, hours, minutes, seconds); * new TimeSpan(days, hours, minutes, seconds, milliseconds); */ var TimeSpan = function (days, hours, minutes, seconds, milliseconds) { if (arguments.length === 1 && typeof days === "number") { var orient = (days < 0) ? -1 : +1; var millsLeft = Math.abs(days); this.setDays(Math.floor(millsLeft / 86400000) * orient); millsLeft = millsLeft % 86400000; this.setHours(Math.floor(millsLeft / 3600000) * orient); millsLeft = millsLeft % 3600000; this.setMinutes(Math.floor(millsLeft / 60000) * orient); millsLeft = millsLeft % 60000; this.setSeconds(Math.floor(millsLeft / 1000) * orient); millsLeft = millsLeft % 1000; this.setMilliseconds(millsLeft * orient); } else { this.set(days, hours, minutes, seconds, milliseconds); } this.getTotalMilliseconds = function () { return (this.getDays() * 86400000) + (this.getHours() * 3600000) + (this.getMinutes() * 60000) + (this.getSeconds() * 1000); }; this.compareTo = function (time) { var t1 = new Date(1970, 1, 1, this.getHours(), this.getMinutes(), this.getSeconds()), t2; if (time === null) { t2 = new Date(1970, 1, 1, 0, 0, 0); } else { t2 = new Date(1970, 1, 1, time.getHours(), time.getMinutes(), time.getSeconds()); } return (t1 < t2) ? -1 : (t1 > t2) ? 1 : 0; }; this.equals = function (time) { return (this.compareTo(time) === 0); }; this.add = function (time) { return (time === null) ? this : this.addSeconds(time.getTotalMilliseconds() / 1000); }; this.subtract = function (time) { return (time === null) ? this : this.addSeconds(-time.getTotalMilliseconds() / 1000); }; this.addDays = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 86400000)); }; this.addHours = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 3600000)); }; this.addMinutes = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 60000)); }; this.addSeconds = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 1000)); }; this.addMilliseconds = function (n) { return new TimeSpan(this.getTotalMilliseconds() + n); }; this.get12HourHour = function () { return (this.getHours() > 12) ? this.getHours() - 12 : (this.getHours() === 0) ? 12 : this.getHours(); }; this.getDesignator = function () { return (this.getHours() < 12) ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator; }; this.toString = function (format) { this._toString = function () { if (this.getDays() !== null && this.getDays() > 0) { return this.getDays() + "." + this.getHours() + ":" + this.p(this.getMinutes()) + ":" + this.p(this.getSeconds()); } else { return this.getHours() + ":" + this.p(this.getMinutes()) + ":" + this.p(this.getSeconds()); } }; this.p = function (s) { return (s.toString().length < 2) ? "0" + s : s; }; var me = this; return format ? format.replace(/dd?|HH?|hh?|mm?|ss?|tt?/g, function (format) { switch (format) { case "d": return me.getDays(); case "dd": return me.p(me.getDays()); case "H": return me.getHours(); case "HH": return me.p(me.getHours()); case "h": return me.get12HourHour(); case "hh": return me.p(me.get12HourHour()); case "m": return me.getMinutes(); case "mm": return me.p(me.getMinutes()); case "s": return me.getSeconds(); case "ss": return me.p(me.getSeconds()); case "t": return ((me.getHours() < 12) ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator).substring(0, 1); case "tt": return (me.getHours() < 12) ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator; } } ) : this._toString(); }; return this; }; addSetFuncs(TimeSpan, attrs.slice(2)); TimeSpan.prototype.set = function (days, hours, minutes, seconds, milliseconds){ this.setDays(days || this.getDays()); this.setHours(hours || this.getHours()); this.setMinutes(minutes || this.getMinutes()); this.setSeconds(seconds || this.getSeconds()); this.setMilliseconds(milliseconds || this.getMilliseconds()); }; /** * Gets the time of day for this date instances. * @return {TimeSpan} TimeSpan */ Date.prototype.getTimeOfDay = function () { return new TimeSpan(0, this.getHours(), this.getMinutes(), this.getSeconds(), this.getMilliseconds()); }; Date.TimeSpan = TimeSpan; if (typeof window !== "undefined" ) { // keeping API compatible for v1.x window.TimeSpan = TimeSpan; } }()); (function () { "use strict"; var attrs = ["years", "months", "days", "hours", "minutes", "seconds", "milliseconds"]; var gFn = function (attr) { return function () { return this[attr]; }; }; var sFn = function (attr) { return function (val) { this[attr] = val; return this; }; }; var addSetFuncs = function (context, attrs) { for (var i = 0; i < attrs.length ; i++) { var $a = attrs[i], $b = $a.slice(0, 1).toUpperCase() + $a.slice(1); context.prototype[$a] = 0; context.prototype["get" + $b] = gFn($a); context.prototype["set" + $b] = sFn($a); } }; var setMonthsAndYears = function (orient, d1, d2, context) { function inc() { d1.addMonths(-orient); context.months++; if (context.months === 12) { context.years++; context.months = 0; } } if (orient === +1) { while (d1 > d2) { inc(); } } else { while (d1 < d2) { inc(); } } context.months--; context.months *= orient; context.years *= orient; }; var adjustForDST = function(orient, startDate, endDate) { var hasDSTMismatch = (false === (startDate.isDaylightSavingTime() === endDate.isDaylightSavingTime())); if (hasDSTMismatch && orient === 1) { startDate.addHours(-1); } else if (hasDSTMismatch) { startDate.addHours(1); } }; /** * TimePeriod(startDate, endDate); * TimePeriod(years, months, days, hours, minutes, seconds, milliseconds); */ var TimePeriod = function (years, months, days, hours, minutes, seconds, milliseconds) { if (arguments.length === 7) { this.set(years, months, days, hours, minutes, seconds, milliseconds); } else if (arguments.length === 2 && arguments[0] instanceof Date && arguments[1] instanceof Date) { var startDate = arguments[0].clone(); var endDate = arguments[1].clone(); var orient = (startDate > endDate) ? +1 : -1; this.dates = { start: arguments[0].clone(), end: arguments[1].clone() }; setMonthsAndYears(orient, startDate, endDate, this); adjustForDST(orient, startDate, endDate); // // TODO - adjust for DST var diff = endDate - startDate; if (diff !== 0) { var ts = new TimeSpan(diff); this.set(this.years, this.months, ts.getDays(), ts.getHours(), ts.getMinutes(), ts.getSeconds(), ts.getMilliseconds()); } } return this; }; // create all the set functions. addSetFuncs(TimePeriod, attrs); TimePeriod.prototype.set = function (years, months, days, hours, minutes, seconds, milliseconds){ this.setYears(years || this.getYears()); this.setMonths(months || this.getMonths()); this.setDays(days || this.getDays()); this.setHours(hours || this.getHours()); this.setMinutes(minutes || this.getMinutes()); this.setSeconds(seconds || this.getSeconds()); this.setMilliseconds(milliseconds || this.getMilliseconds()); }; Date.TimePeriod = TimePeriod; if (typeof window !== "undefined") { // keeping API compatible for v1.x window.TimePeriod = TimePeriod; } }()); ================================================ FILE: build/date-it-CH.js ================================================ /** * @overview datejs * @version 1.0.0-rc3 * @author Gregory Wild-Smith * @copyright 2015 Gregory Wild-Smith * @license MIT * @homepage https://github.com/abritinthebay/datejs */ /* * DateJS Culture String File * Country Code: it-CH * Name: Italian (Switzerland) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["it-CH"] = { "name": "it-CH", "englishName": "Italian (Switzerland)", "nativeName": "italiano (Svizzera)", "Sunday": "domenica", "Monday": "lunedì", "Tuesday": "martedì", "Wednesday": "mercoledì", "Thursday": "giovedì", "Friday": "venerdì", "Saturday": "sabato", "Sun": "dom", "Mon": "lun", "Tue": "mar", "Wed": "mer", "Thu": "gio", "Fri": "ven", "Sat": "sab", "Su": "do", "Mo": "lu", "Tu": "ma", "We": "me", "Th": "gi", "Fr": "ve", "Sa": "sa", "S_Sun_Initial": "d", "M_Mon_Initial": "l", "T_Tue_Initial": "m", "W_Wed_Initial": "m", "T_Thu_Initial": "g", "F_Fri_Initial": "v", "S_Sat_Initial": "s", "January": "gennaio", "February": "febbraio", "March": "marzo", "April": "aprile", "May": "maggio", "June": "giugno", "July": "luglio", "August": "agosto", "September": "settembre", "October": "ottobre", "November": "novembre", "December": "dicembre", "Jan_Abbr": "gen", "Feb_Abbr": "feb", "Mar_Abbr": "mar", "Apr_Abbr": "apr", "May_Abbr": "mag", "Jun_Abbr": "gio", "Jul_Abbr": "lug", "Aug_Abbr": "ago", "Sep_Abbr": "set", "Oct_Abbr": "ott", "Nov_Abbr": "nov", "Dec_Abbr": "dic", "AM": "", "PM": "", "firstDayOfWeek": 1, "twoDigitYearMax": 2029, "mdy": "dmy", "M/d/yyyy": "dd.MM.yyyy", "dddd, MMMM dd, yyyy": "dddd, d. MMMM yyyy", "h:mm tt": "HH:mm", "h:mm:ss tt": "HH:mm:ss", "dddd, MMMM dd, yyyy h:mm:ss tt": "dddd, d. MMMM yyyy HH:mm:ss", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "d. MMMM", "MMMM, yyyy": "MMMM yyyy", "/jan(uary)?/": "gen(naio)?", "/feb(ruary)?/": "feb(braio)?", "/mar(ch)?/": "mar(zo)?", "/apr(il)?/": "apr(ile)?", "/may/": "mag(gio)?", "/jun(e)?/": "giugno", "/jul(y)?/": "lug(lio)?", "/aug(ust)?/": "ago(sto)?", "/sep(t(ember)?)?/": "set(tembre)?", "/oct(ober)?/": "ott(obre)?", "/nov(ember)?/": "nov(embre)?", "/dec(ember)?/": "dic(embre)?", "/^su(n(day)?)?/": "^do(m(enica)?)?", "/^mo(n(day)?)?/": "^lu(n(edì)?)?", "/^tu(e(s(day)?)?)?/": "^ma(r(tedì)?)?", "/^we(d(nesday)?)?/": "^me(r(coledì)?)?", "/^th(u(r(s(day)?)?)?)?/": "^gi(o(vedì)?)?", "/^fr(i(day)?)?/": "^ve(n(erdì)?)?", "/^sa(t(urday)?)?/": "^sa(b(ato)?)?", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "it-CH"; /** * @overview datejs * @version 1.0.0-rc3 * @author Gregory Wild-Smith * @copyright 2015 Gregory Wild-Smith * @license MIT * @homepage https://github.com/abritinthebay/datejs */(function () { var $D = Date; var lang = Date.CultureStrings ? Date.CultureStrings.lang : null; var loggedKeys = {}; // for debug purposes. var getText = { getFromKey: function (key, countryCode) { var output; if (Date.CultureStrings && Date.CultureStrings[countryCode] && Date.CultureStrings[countryCode][key]) { output = Date.CultureStrings[countryCode][key]; } else { output = getText.buildFromDefault(key); } if (key.charAt(0) === "/") { // Assume it's a regex output = getText.buildFromRegex(key, countryCode); } return output; }, getFromObjectValues: function (obj, countryCode) { var key, output = {}; for(key in obj) { if (obj.hasOwnProperty(key)) { output[key] = getText.getFromKey(obj[key], countryCode); } } return output; }, getFromObjectKeys: function (obj, countryCode) { var key, output = {}; for(key in obj) { if (obj.hasOwnProperty(key)) { output[getText.getFromKey(key, countryCode)] = obj[key]; } } return output; }, getFromArray: function (arr, countryCode) { var output = []; for (var i=0; i < arr.length; i++){ if (i in arr) { output[i] = getText.getFromKey(arr[i], countryCode); } } return output; }, buildFromDefault: function (key) { var output, length, split, last; switch(key) { case "name": output = "en-US"; break; case "englishName": output = "English (United States)"; break; case "nativeName": output = "English (United States)"; break; case "twoDigitYearMax": output = 2049; break; case "firstDayOfWeek": output = 0; break; default: output = key; split = key.split("_"); length = split.length; if (length > 1 && key.charAt(0) !== "/") { // if the key isn't a regex and it has a split. last = split[(length - 1)].toLowerCase(); if (last === "initial" || last === "abbr") { output = split[0]; } } break; } return output; }, buildFromRegex: function (key, countryCode) { var output; if (Date.CultureStrings && Date.CultureStrings[countryCode] && Date.CultureStrings[countryCode][key]) { output = new RegExp(Date.CultureStrings[countryCode][key], "i"); } else { output = new RegExp(key.replace(new RegExp("/", "g"),""), "i"); } return output; } }; var shallowMerge = function (obj1, obj2) { for (var attrname in obj2) { if (obj2.hasOwnProperty(attrname)) { obj1[attrname] = obj2[attrname]; } } }; var __ = function (key, language) { var countryCode = (language) ? language : lang; loggedKeys[key] = key; if (typeof key === "object") { if (key instanceof Array) { return getText.getFromArray(key, countryCode); } else { return getText.getFromObjectKeys(key, countryCode); } } else { return getText.getFromKey(key, countryCode); } }; var loadI18nScript = function (code) { // paatterned after jQuery's getScript. var url = Date.Config.i18n + code + ".js"; var head = document.getElementsByTagName("head")[0] || document.documentElement; var script = document.createElement("script"); script.src = url; var completed = false; var events = { done: function (){} // placeholder function }; // Attach handlers for all browsers script.onload = script.onreadystatechange = function() { if ( !completed && (!this.readyState || this.readyState === "loaded" || this.readyState === "complete") ) { events.done(); head.removeChild(script); } }; setTimeout(function() { head.insertBefore(script, head.firstChild); }, 0); // allows return to execute first return { done: function (cb) { events.done = function() { if (cb) { setTimeout(cb,0); } }; } }; }; var buildInfo = { buildFromMethodHash: function (obj) { var key; for(key in obj) { if (obj.hasOwnProperty(key)) { obj[key] = buildInfo[obj[key]](); } } return obj; }, timeZoneDST: function () { var DST = { "CHADT": "+1345", "NZDT": "+1300", "AEDT": "+1100", "ACDT": "+1030", "AZST": "+0500", "IRDT": "+0430", "EEST": "+0300", "CEST": "+0200", "BST": "+0100", "PMDT": "-0200", "ADT": "-0300", "NDT": "-0230", "EDT": "-0400", "CDT": "-0500", "MDT": "-0600", "PDT": "-0700", "AKDT": "-0800", "HADT": "-0900" }; return __(DST); }, timeZoneStandard: function () { var standard = { "LINT": "+1400", "TOT": "+1300", "CHAST": "+1245", "NZST": "+1200", "NFT": "+1130", "SBT": "+1100", "AEST": "+1000", "ACST": "+0930", "JST": "+0900", "CWST": "+0845", "CT": "+0800", "ICT": "+0700", "MMT": "+0630", "BST": "+0600", "NPT": "+0545", "IST": "+0530", "PKT": "+0500", "AFT": "+0430", "MSK": "+0400", "IRST": "+0330", "FET": "+0300", "EET": "+0200", "CET": "+0100", "GMT": "+0000", "UTC": "+0000", "CVT": "-0100", "GST": "-0200", "BRT": "-0300", "NST": "-0330", "AST": "-0400", "EST": "-0500", "CST": "-0600", "MST": "-0700", "PST": "-0800", "AKST": "-0900", "MIT": "-0930", "HST": "-1000", "SST": "-1100", "BIT": "-1200" }; return __(standard); }, timeZones: function (data) { var zone; data.timezones = []; for (zone in data.abbreviatedTimeZoneStandard) { if (data.abbreviatedTimeZoneStandard.hasOwnProperty(zone)) { data.timezones.push({ name: zone, offset: data.abbreviatedTimeZoneStandard[zone]}); } } for (zone in data.abbreviatedTimeZoneDST) { if (data.abbreviatedTimeZoneDST.hasOwnProperty(zone)) { data.timezones.push({ name: zone, offset: data.abbreviatedTimeZoneDST[zone], dst: true}); } } return data.timezones; }, days: function () { return __(["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"]); }, dayAbbr: function () { return __(["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"]); }, dayShortNames: function () { return __(["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"]); }, dayFirstLetters: function () { return __(["S_Sun_Initial", "M_Mon_Initial", "T_Tues_Initial", "W_Wed_Initial", "T_Thu_Initial", "F_Fri_Initial", "S_Sat_Initial"]); }, months: function () { return __(["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"]); }, monthAbbr: function () { return __(["Jan_Abbr", "Feb_Abbr", "Mar_Abbr", "Apr_Abbr", "May_Abbr", "Jun_Abbr", "Jul_Abbr", "Aug_Abbr", "Sep_Abbr", "Oct_Abbr", "Nov_Abbr", "Dec_Abbr"]); }, formatPatterns: function () { return getText.getFromObjectValues({ shortDate: "M/d/yyyy", longDate: "dddd, MMMM dd, yyyy", shortTime: "h:mm tt", longTime: "h:mm:ss tt", fullDateTime: "dddd, MMMM dd, yyyy h:mm:ss tt", sortableDateTime: "yyyy-MM-ddTHH:mm:ss", universalSortableDateTime: "yyyy-MM-dd HH:mm:ssZ", rfc1123: "ddd, dd MMM yyyy HH:mm:ss", monthDay: "MMMM dd", yearMonth: "MMMM, yyyy" }, Date.i18n.currentLanguage()); }, regex: function () { return getText.getFromObjectValues({ inTheMorning: "/( in the )(morn(ing)?)\\b/", thisMorning: "/(this )(morn(ing)?)\\b/", amThisMorning: "/(\b\\d(am)? )(this )(morn(ing)?)/", inTheEvening: "/( in the )(even(ing)?)\\b/", thisEvening: "/(this )(even(ing)?)\\b/", pmThisEvening: "/(\b\\d(pm)? )(this )(even(ing)?)/", jan: "/jan(uary)?/", feb: "/feb(ruary)?/", mar: "/mar(ch)?/", apr: "/apr(il)?/", may: "/may/", jun: "/jun(e)?/", jul: "/jul(y)?/", aug: "/aug(ust)?/", sep: "/sep(t(ember)?)?/", oct: "/oct(ober)?/", nov: "/nov(ember)?/", dec: "/dec(ember)?/", sun: "/^su(n(day)?)?/", mon: "/^mo(n(day)?)?/", tue: "/^tu(e(s(day)?)?)?/", wed: "/^we(d(nesday)?)?/", thu: "/^th(u(r(s(day)?)?)?)?/", fri: "/fr(i(day)?)?/", sat: "/^sa(t(urday)?)?/", future: "/^next/", past: "/^last|past|prev(ious)?/", add: "/^(\\+|aft(er)?|from|hence)/", subtract: "/^(\\-|bef(ore)?|ago)/", yesterday: "/^yes(terday)?/", today: "/^t(od(ay)?)?/", tomorrow: "/^tom(orrow)?/", now: "/^n(ow)?/", millisecond: "/^ms|milli(second)?s?/", second: "/^sec(ond)?s?/", minute: "/^mn|min(ute)?s?/", hour: "/^h(our)?s?/", week: "/^w(eek)?s?/", month: "/^m(onth)?s?/", day: "/^d(ay)?s?/", year: "/^y(ear)?s?/", shortMeridian: "/^(a|p)/", longMeridian: "/^(a\\.?m?\\.?|p\\.?m?\\.?)/", timezone: "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/", ordinalSuffix: "/^\\s*(st|nd|rd|th)/", timeContext: "/^\\s*(\\:|a(?!u|p)|p)/" }, Date.i18n.currentLanguage()); } }; var CultureInfo = function () { var info = getText.getFromObjectValues({ name: "name", englishName: "englishName", nativeName: "nativeName", amDesignator: "AM", pmDesignator: "PM", firstDayOfWeek: "firstDayOfWeek", twoDigitYearMax: "twoDigitYearMax", dateElementOrder: "mdy" }, Date.i18n.currentLanguage()); var constructedInfo = buildInfo.buildFromMethodHash({ dayNames: "days", abbreviatedDayNames: "dayAbbr", shortestDayNames: "dayShortNames", firstLetterDayNames: "dayFirstLetters", monthNames: "months", abbreviatedMonthNames: "monthAbbr", formatPatterns: "formatPatterns", regexPatterns: "regex", abbreviatedTimeZoneDST: "timeZoneDST", abbreviatedTimeZoneStandard: "timeZoneStandard" }); shallowMerge(info, constructedInfo); buildInfo.timeZones(info); return info; }; $D.i18n = { __: function (key, lang) { return __(key, lang); }, currentLanguage: function () { return lang || "en-US"; }, setLanguage: function (code, force, cb) { var async = false; if (force || code === "en-US" || (!!Date.CultureStrings && !!Date.CultureStrings[code])) { lang = code; Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings.lang = code; Date.CultureInfo = new CultureInfo(); } else { if (!(!!Date.CultureStrings && !!Date.CultureStrings[code])) { if (typeof exports !== "undefined" && this.exports !== exports) { // we're in a Node enviroment, load it using require try { require("../i18n/" + code + ".js"); lang = code; Date.CultureStrings.lang = code; Date.CultureInfo = new CultureInfo(); } catch (e) { // var str = "The language for '" + code + "' could not be loaded by Node. It likely does not exist."; throw new Error("The DateJS IETF language tag '" + code + "' could not be loaded by Node. It likely does not exist."); } } else if (Date.Config && Date.Config.i18n) { // we know the location of the files, so lets load them async = true; loadI18nScript(code).done(function(){ lang = code; Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings.lang = code; Date.CultureInfo = new CultureInfo(); $D.Parsing.Normalizer.buildReplaceData(); // because this is async if ($D.Grammar) { $D.Grammar.buildGrammarFormats(); // so we can parse those strings... } if (cb) { setTimeout(cb,0); } }); } else { Date.console.error("The DateJS IETF language tag '" + code + "' is not available and has not been loaded."); return false; } } } $D.Parsing.Normalizer.buildReplaceData(); // rebuild normalizer strings if ($D.Grammar) { $D.Grammar.buildGrammarFormats(); // so we can parse those strings... } if (!async && cb) { setTimeout(cb,0); } }, getLoggedKeys: function () { return loggedKeys; }, updateCultureInfo: function () { Date.CultureInfo = new CultureInfo(); } }; $D.i18n.updateCultureInfo(); // run automatically }()); (function () { var $D = Date, $P = $D.prototype, p = function (s, l) { if (!l) { l = 2; } return ("000" + s).slice(l * -1); }; if (typeof window !== "undefined" && typeof window.console !== "undefined" && typeof window.console.log !== "undefined") { $D.console = console; // used only to raise non-critical errors if available } else { // set mock so we don't give errors. $D.console = { log: function(){}, error: function(){} }; } $D.Config = $D.Config || {}; $D.initOverloads = function() { /** * Overload of Date.now. Allows an alternate call for Date.now where it returns the * current Date as an object rather than just milliseconds since the Unix Epoch. * * Also provides an implementation of now() for browsers (IE<9) that don't have it. * * Backwards compatible so with work with either: * Date.now() [returns ms] * or * Date.now(true) [returns Date] */ if (!$D.now) { $D._now = function now() { return new Date().getTime(); }; } else if (!$D._now) { $D._now = $D.now; } $D.now = function (returnObj) { if (returnObj) { return $D.present(); } else { return $D._now(); } }; if ( !$P.toISOString ) { $P.toISOString = function() { return this.getUTCFullYear() + "-" + p(this.getUTCMonth() + 1) + "-" + p(this.getUTCDate()) + "T" + p(this.getUTCHours()) + ":" + p(this.getUTCMinutes()) + ":" + p(this.getUTCSeconds()) + "." + String( (this.getUTCMilliseconds()/1000).toFixed(3)).slice(2, 5) + "Z"; }; } // private if ( $P._toString === undefined ){ $P._toString = $P.toString; } }; $D.initOverloads(); /** * Gets a date that is set to the current date. The time is set to the start of the day (00:00 or 12:00 AM). * @return {Date} The current date. */ $D.today = function () { return new Date().clearTime(); }; /** * Gets a date that is set to the current date and time (same as new Date, but chainable) * @return {Date} The current date. */ $D.present = function () { return new Date(); }; /** * Compares the first date to the second date and returns an number indication of their relative values. * @param {Date} First Date object to compare [Required]. * @param {Date} Second Date object to compare to [Required]. * @return {Number} -1 = date1 is lessthan date2. 0 = values are equal. 1 = date1 is greaterthan date2. */ $D.compare = function (date1, date2) { if (isNaN(date1) || isNaN(date2)) { throw new Error(date1 + " - " + date2); } else if (date1 instanceof Date && date2 instanceof Date) { return (date1 < date2) ? -1 : (date1 > date2) ? 1 : 0; } else { throw new TypeError(date1 + " - " + date2); } }; /** * Compares the first Date object to the second Date object and returns true if they are equal. * @param {Date} First Date object to compare [Required] * @param {Date} Second Date object to compare to [Required] * @return {Boolean} true if dates are equal. false if they are not equal. */ $D.equals = function (date1, date2) { return (date1.compareTo(date2) === 0); }; /** * Gets the language appropriate day name when given the day number(0-6) * eg - 0 == Sunday * @return {String} The day name */ $D.getDayName = function (n) { return Date.CultureInfo.dayNames[n]; }; /** * Gets the day number (0-6) if given a CultureInfo specific string which is a valid dayName, abbreviatedDayName or shortestDayName (two char). * @param {String} The name of the day (eg. "Monday, "Mon", "tuesday", "tue", "We", "we"). * @return {Number} The day number */ $D.getDayNumberFromName = function (name) { var n = Date.CultureInfo.dayNames, m = Date.CultureInfo.abbreviatedDayNames, o = Date.CultureInfo.shortestDayNames, s = name.toLowerCase(); for (var i = 0; i < n.length; i++) { if (n[i].toLowerCase() === s || m[i].toLowerCase() === s || o[i].toLowerCase() === s) { return i; } } return -1; }; /** * Gets the month number (0-11) if given a Culture Info specific string which is a valid monthName or abbreviatedMonthName. * @param {String} The name of the month (eg. "February, "Feb", "october", "oct"). * @return {Number} The day number */ $D.getMonthNumberFromName = function (name) { var n = Date.CultureInfo.monthNames, m = Date.CultureInfo.abbreviatedMonthNames, s = name.toLowerCase(); for (var i = 0; i < n.length; i++) { if (n[i].toLowerCase() === s || m[i].toLowerCase() === s) { return i; } } return -1; }; /** * Gets the language appropriate month name when given the month number(0-11) * eg - 0 == January * @return {String} The month name */ $D.getMonthName = function (n) { return Date.CultureInfo.monthNames[n]; }; /** * Determines if the current date instance is within a LeapYear. * @param {Number} The year. * @return {Boolean} true if date is within a LeapYear, otherwise false. */ $D.isLeapYear = function (year) { return ((year % 4 === 0 && year % 100 !== 0) || year % 400 === 0); }; /** * Gets the number of days in the month, given a year and month value. Automatically corrects for LeapYear. * @param {Number} The year. * @param {Number} The month (0-11). * @return {Number} The number of days in the month. */ $D.getDaysInMonth = function (year, month) { if (!month && $D.validateMonth(year)) { month = year; year = Date.today().getFullYear(); } return [31, ($D.isLeapYear(year) ? 29 : 28), 31, 30, 31, 30, 31, 31, 30, 31, 30, 31][month]; }; $P.getDaysInMonth = function () { return $D.getDaysInMonth(this.getFullYear(), this.getMonth()); }; $D.getTimezoneAbbreviation = function (offset, dst) { var p, n = (dst || false) ? Date.CultureInfo.abbreviatedTimeZoneDST : Date.CultureInfo.abbreviatedTimeZoneStandard; for (p in n) { if (n.hasOwnProperty(p)) { if (n[p] === offset) { return p; } } } return null; }; $D.getTimezoneOffset = function (name, dst) { var i, a =[], z = Date.CultureInfo.timezones; if (!name) { name = (new Date()).getTimezone();} for (i = 0; i < z.length; i++) { if (z[i].name === name.toUpperCase()) { a.push(i); } } if (!z[a[0]]) { return null; } if (a.length === 1 || !dst) { return z[a[0]].offset; } else { for (i=0; i < a.length; i++) { if (z[a[i]].dst) { return z[a[i]].offset; } } } }; $D.getQuarter = function (d) { d = d || new Date(); // If no date supplied, use today var q = [1,2,3,4]; return q[Math.floor(d.getMonth() / 3)]; // ~~~ is a bitwise op. Faster than Math.floor }; $D.getDaysLeftInQuarter = function (d) { d = d || new Date(); var qEnd = new Date(d); qEnd.setMonth(qEnd.getMonth() + 3 - qEnd.getMonth() % 3, 0); return Math.floor((qEnd - d) / 8.64e7); }; // private var validate = function (n, min, max, name) { name = name ? name : "Object"; if (typeof n === "undefined") { return false; } else if (typeof n !== "number") { throw new TypeError(n + " is not a Number."); } else if (n < min || n > max) { // As failing validation is *not* an exceptional circumstance // lets not throw a RangeError Exception here. // It's semantically correct but it's not sensible. return false; } return true; }; /** * Validates the number is within an acceptable range for milliseconds [0-999]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateMillisecond = function (value) { return validate(value, 0, 999, "millisecond"); }; /** * Validates the number is within an acceptable range for seconds [0-59]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateSecond = function (value) { return validate(value, 0, 59, "second"); }; /** * Validates the number is within an acceptable range for minutes [0-59]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateMinute = function (value) { return validate(value, 0, 59, "minute"); }; /** * Validates the number is within an acceptable range for hours [0-23]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateHour = function (value) { return validate(value, 0, 23, "hour"); }; /** * Validates the number is within an acceptable range for the days in a month [0-MaxDaysInMonth]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateDay = function (value, year, month) { if (year === undefined || year === null || month === undefined || month === null) { return false;} return validate(value, 1, $D.getDaysInMonth(year, month), "day"); }; /** * Validates the number is within an acceptable range for months [0-11]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateWeek = function (value) { return validate(value, 0, 53, "week"); }; /** * Validates the number is within an acceptable range for months [0-11]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateMonth = function (value) { return validate(value, 0, 11, "month"); }; /** * Validates the number is within an acceptable range for years. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateYear = function (value) { /** * Per ECMAScript spec the range of times supported by Date objects is * exactly -100,000,000 days to +100,000,000 days measured relative to * midnight at the beginning of 01 January, 1970 UTC. * This gives a range of 8,640,000,000,000,000 milliseconds to either * side of 01 January, 1970 UTC. * * Earliest possible date: Tue, 20 Apr 271,822 B.C. 00:00:00 UTC * Latest possible date: Sat, 13 Sep 275,760 00:00:00 UTC */ return validate(value, -271822, 275760, "year"); }; $D.validateTimezone = function(value) { var timezones = {"ACDT":1,"ACST":1,"ACT":1,"ADT":1,"AEDT":1,"AEST":1,"AFT":1,"AKDT":1,"AKST":1,"AMST":1,"AMT":1,"ART":1,"AST":1,"AWDT":1,"AWST":1,"AZOST":1,"AZT":1,"BDT":1,"BIOT":1,"BIT":1,"BOT":1,"BRT":1,"BST":1,"BTT":1,"CAT":1,"CCT":1,"CDT":1,"CEDT":1,"CEST":1,"CET":1,"CHADT":1,"CHAST":1,"CHOT":1,"ChST":1,"CHUT":1,"CIST":1,"CIT":1,"CKT":1,"CLST":1,"CLT":1,"COST":1,"COT":1,"CST":1,"CT":1,"CVT":1,"CWST":1,"CXT":1,"DAVT":1,"DDUT":1,"DFT":1,"EASST":1,"EAST":1,"EAT":1,"ECT":1,"EDT":1,"EEDT":1,"EEST":1,"EET":1,"EGST":1,"EGT":1,"EIT":1,"EST":1,"FET":1,"FJT":1,"FKST":1,"FKT":1,"FNT":1,"GALT":1,"GAMT":1,"GET":1,"GFT":1,"GILT":1,"GIT":1,"GMT":1,"GST":1,"GYT":1,"HADT":1,"HAEC":1,"HAST":1,"HKT":1,"HMT":1,"HOVT":1,"HST":1,"ICT":1,"IDT":1,"IOT":1,"IRDT":1,"IRKT":1,"IRST":1,"IST":1,"JST":1,"KGT":1,"KOST":1,"KRAT":1,"KST":1,"LHST":1,"LINT":1,"MAGT":1,"MART":1,"MAWT":1,"MDT":1,"MET":1,"MEST":1,"MHT":1,"MIST":1,"MIT":1,"MMT":1,"MSK":1,"MST":1,"MUT":1,"MVT":1,"MYT":1,"NCT":1,"NDT":1,"NFT":1,"NPT":1,"NST":1,"NT":1,"NUT":1,"NZDT":1,"NZST":1,"OMST":1,"ORAT":1,"PDT":1,"PET":1,"PETT":1,"PGT":1,"PHOT":1,"PHT":1,"PKT":1,"PMDT":1,"PMST":1,"PONT":1,"PST":1,"PYST":1,"PYT":1,"RET":1,"ROTT":1,"SAKT":1,"SAMT":1,"SAST":1,"SBT":1,"SCT":1,"SGT":1,"SLST":1,"SRT":1,"SST":1,"SYOT":1,"TAHT":1,"THA":1,"TFT":1,"TJT":1,"TKT":1,"TLT":1,"TMT":1,"TOT":1,"TVT":1,"UCT":1,"ULAT":1,"UTC":1,"UYST":1,"UYT":1,"UZT":1,"VET":1,"VLAT":1,"VOLT":1,"VOST":1,"VUT":1,"WAKT":1,"WAST":1,"WAT":1,"WEDT":1,"WEST":1,"WET":1,"WST":1,"YAKT":1,"YEKT":1,"Z":1}; return (timezones[value] === 1); }; $D.validateTimezoneOffset= function(value) { // timezones go from +14hrs to -12hrs, the +X hours are negative offsets. return (value > -841 && value < 721); }; }()); (function () { var $D = Date, $P = $D.prototype, p = function (s, l) { if (!l) { l = 2; } return ("000" + s).slice(l * -1); }; var validateConfigObject = function (obj) { var result = {}, self = this, prop, testFunc; testFunc = function (prop, func, value) { if (prop === "day") { var month = (obj.month !== undefined) ? obj.month : self.getMonth(); var year = (obj.year !== undefined) ? obj.year : self.getFullYear(); return $D[func](value, year, month); } else { return $D[func](value); } }; for (prop in obj) { if (Object.prototype.hasOwnProperty.call(obj, prop)) { var func = "validate" + prop.charAt(0).toUpperCase() + prop.slice(1); if ($D[func] && obj[prop] !== null && testFunc(prop, func, obj[prop])) { result[prop] = obj[prop]; } } } return result; }; /** * Resets the time of this Date object to 12:00 AM (00:00), which is the start of the day. * @param {Boolean} .clone() this date instance before clearing Time * @return {Date} this */ $P.clearTime = function () { this.setHours(0); this.setMinutes(0); this.setSeconds(0); this.setMilliseconds(0); return this; }; /** * Resets the time of this Date object to the current time ('now'). * @return {Date} this */ $P.setTimeToNow = function () { var n = new Date(); this.setHours(n.getHours()); this.setMinutes(n.getMinutes()); this.setSeconds(n.getSeconds()); this.setMilliseconds(n.getMilliseconds()); return this; }; /** * Returns a new Date object that is an exact date and time copy of the original instance. * @return {Date} A new Date instance */ $P.clone = function () { return new Date(this.getTime()); }; /** * Compares this instance to a Date object and returns an number indication of their relative values. * @param {Date} Date object to compare [Required] * @return {Number} -1 = this is lessthan date. 0 = values are equal. 1 = this is greaterthan date. */ $P.compareTo = function (date) { return Date.compare(this, date); }; /** * Compares this instance to another Date object and returns true if they are equal. * @param {Date} Date object to compare. If no date to compare, new Date() [now] is used. * @return {Boolean} true if dates are equal. false if they are not equal. */ $P.equals = function (date) { return Date.equals(this, (date !== undefined ? date : new Date())); }; /** * Determines if this instance is between a range of two dates or equal to either the start or end dates. * @param {Date} Start of range [Required] * @param {Date} End of range [Required] * @return {Boolean} true is this is between or equal to the start and end dates, else false */ $P.between = function (start, end) { return this.getTime() >= start.getTime() && this.getTime() <= end.getTime(); }; /** * Determines if this date occurs after the date to compare to. * @param {Date} Date object to compare. If no date to compare, new Date() ("now") is used. * @return {Boolean} true if this date instance is greater than the date to compare to (or "now"), otherwise false. */ $P.isAfter = function (date) { return this.compareTo(date || new Date()) === 1; }; /** * Determines if this date occurs before the date to compare to. * @param {Date} Date object to compare. If no date to compare, new Date() ("now") is used. * @return {Boolean} true if this date instance is less than the date to compare to (or "now"). */ $P.isBefore = function (date) { return (this.compareTo(date || new Date()) === -1); }; /** * Determines if the current Date instance occurs today. * @return {Boolean} true if this date instance is 'today', otherwise false. */ /** * Determines if the current Date instance occurs on the same Date as the supplied 'date'. * If no 'date' to compare to is provided, the current Date instance is compared to 'today'. * @param {date} Date object to compare. If no date to compare, the current Date ("now") is used. * @return {Boolean} true if this Date instance occurs on the same Day as the supplied 'date'. */ $P.isToday = $P.isSameDay = function (date) { return this.clone().clearTime().equals((date || new Date()).clone().clearTime()); }; /** * Adds the specified number of milliseconds to this instance. * @param {Number} The number of milliseconds to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addMilliseconds = function (value) { if (!value) { return this; } this.setTime(this.getTime() + value * 1); return this; }; /** * Adds the specified number of seconds to this instance. * @param {Number} The number of seconds to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addSeconds = function (value) { if (!value) { return this; } return this.addMilliseconds(value * 1000); }; /** * Adds the specified number of seconds to this instance. * @param {Number} The number of seconds to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addMinutes = function (value) { if (!value) { return this; } return this.addMilliseconds(value * 60000); // 60*1000 }; /** * Adds the specified number of hours to this instance. * @param {Number} The number of hours to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addHours = function (value) { if (!value) { return this; } return this.addMilliseconds(value * 3600000); // 60*60*1000 }; /** * Adds the specified number of days to this instance. * @param {Number} The number of days to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addDays = function (value) { if (!value) { return this; } this.setDate(this.getDate() + value * 1); return this; }; /** * Adds the specified number of weekdays (ie - not sat or sun) to this instance. * @param {Number} The number of days to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addWeekdays = function (value) { if (!value) { return this; } var day = this.getDay(); var weeks = (Math.ceil(Math.abs(value)/7)); if (day === 0 || day === 6) { if (value > 0) { this.next().monday(); this.addDays(-1); day = this.getDay(); } } if (value < 0) { while (value < 0) { this.addDays(-1); day = this.getDay(); if (day !== 0 && day !== 6) { value++; } } return this; } else if (value > 5 || (6-day) <= value) { value = value + (weeks * 2); } return this.addDays(value); }; /** * Adds the specified number of weeks to this instance. * @param {Number} The number of weeks to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addWeeks = function (value) { if (!value) { return this; } return this.addDays(value * 7); }; /** * Adds the specified number of months to this instance. * @param {Number} The number of months to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addMonths = function (value) { if (!value) { return this; } var n = this.getDate(); this.setDate(1); this.setMonth(this.getMonth() + value * 1); this.setDate(Math.min(n, $D.getDaysInMonth(this.getFullYear(), this.getMonth()))); return this; }; $P.addQuarters = function (value) { if (!value) { return this; } // note this will take you to the same point in the quarter as you are now. // i.e. - if you are 15 days into the quarter you'll be 15 days into the resulting one. // bonus: this allows adding fractional quarters return this.addMonths(value * 3); }; /** * Adds the specified number of years to this instance. * @param {Number} The number of years to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addYears = function (value) { if (!value) { return this; } return this.addMonths(value * 12); }; /** * Adds (or subtracts) to the value of the years, months, weeks, days, hours, minutes, seconds, milliseconds of the date instance using given configuration object. Positive and Negative values allowed. * Example

	Date.today().add( { days: 1, months: 1 } )

	new Date().add( { years: -1 } )
	
* @param {Object} Configuration object containing attributes (months, days, etc.) * @return {Date} this */ $P.add = function (config) { if (typeof config === "number") { this._orient = config; return this; } var x = config; if (x.day) { // If we should be a different date than today (eg: for 'tomorrow -1d', etc). // Should only effect parsing, not direct usage (eg, Finish and FinishExact) if ((x.day - this.getDate()) !== 0) { this.setDate(x.day); } } if (x.milliseconds) { this.addMilliseconds(x.milliseconds); } if (x.seconds) { this.addSeconds(x.seconds); } if (x.minutes) { this.addMinutes(x.minutes); } if (x.hours) { this.addHours(x.hours); } if (x.weeks) { this.addWeeks(x.weeks); } if (x.months) { this.addMonths(x.months); } if (x.years) { this.addYears(x.years); } if (x.days) { this.addDays(x.days); } return this; }; /** * Get the week number. Week one (1) is the week which contains the first Thursday of the year. Monday is considered the first day of the week. * The .getWeek() function does NOT convert the date to UTC. The local datetime is used. * Please use .getISOWeek() to get the week of the UTC converted date. * @return {Number} 1 to 53 */ $P.getWeek = function (utc) { // Create a copy of this date object var self, target = new Date(this.valueOf()); if (utc) { target.addMinutes(target.getTimezoneOffset()); self = target.clone(); } else { self = this; } // ISO week date weeks start on monday // so correct the day number var dayNr = (self.getDay() + 6) % 7; // ISO 8601 states that week 1 is the week // with the first thursday of that year. // Set the target date to the thursday in the target week target.setDate(target.getDate() - dayNr + 3); // Store the millisecond value of the target date var firstThursday = target.valueOf(); // Set the target to the first thursday of the year // First set the target to january first target.setMonth(0, 1); // Not a thursday? Correct the date to the next thursday if (target.getDay() !== 4) { target.setMonth(0, 1 + ((4 - target.getDay()) + 7) % 7); } // The weeknumber is the number of weeks between the // first thursday of the year and the thursday in the target week return 1 + Math.ceil((firstThursday - target) / 604800000); // 604800000 = 7 * 24 * 3600 * 1000 }; /** * Get the ISO 8601 week number. Week one ("01") is the week which contains the first Thursday of the year. Monday is considered the first day of the week. * The .getISOWeek() function does convert the date to it's UTC value. Please use .getWeek() to get the week of the local date. * @return {String} "01" to "53" */ $P.getISOWeek = function () { return p(this.getWeek(true)); }; /** * Moves the date to Monday of the week set. Week one (1) is the week which contains the first Thursday of the year. * @param {Number} A Number (1 to 53) that represents the week of the year. * @return {Date} this */ $P.setWeek = function (n) { if ((n - this.getWeek()) === 0) { if (this.getDay() !== 1) { return this.moveToDayOfWeek(1, (this.getDay() > 1 ? -1 : 1)); } else { return this; } } else { return this.moveToDayOfWeek(1, (this.getDay() > 1 ? -1 : 1)).addWeeks(n - this.getWeek()); } }; $P.setQuarter = function (qtr) { var month = Math.abs(((qtr-1) * 3) + 1); return this.setMonth(month, 1); }; $P.getQuarter = function () { return Date.getQuarter(this); }; $P.getDaysLeftInQuarter = function () { return Date.getDaysLeftInQuarter(this); }; /** * Moves the date to the next n'th occurrence of the dayOfWeek starting from the beginning of the month. The number (-1) is a magic number and will return the last occurrence of the dayOfWeek in the month. * @param {Number} The dayOfWeek to move to * @param {Number} The n'th occurrence to move to. Use (-1) to return the last occurrence in the month * @return {Date} this */ $P.moveToNthOccurrence = function (dayOfWeek, occurrence) { if (dayOfWeek === "Weekday") { if (occurrence > 0) { this.moveToFirstDayOfMonth(); if (this.is().weekday()) { occurrence -= 1; } } else if (occurrence < 0) { this.moveToLastDayOfMonth(); if (this.is().weekday()) { occurrence += 1; } } else { return this; } return this.addWeekdays(occurrence); } var shift = 0; if (occurrence > 0) { shift = occurrence - 1; } else if (occurrence === -1) { this.moveToLastDayOfMonth(); if (this.getDay() !== dayOfWeek) { this.moveToDayOfWeek(dayOfWeek, -1); } return this; } return this.moveToFirstDayOfMonth().addDays(-1).moveToDayOfWeek(dayOfWeek, +1).addWeeks(shift); }; var moveToN = function (getFunc, addFunc, nVal) { return function (value, orient) { var diff = (value - this[getFunc]() + nVal * (orient || +1)) % nVal; return this[addFunc]((diff === 0) ? diff += nVal * (orient || +1) : diff); }; }; /** * Move to the next or last dayOfWeek based on the orient value. * @param {Number} The dayOfWeek to move to * @param {Number} Forward (+1) or Back (-1). Defaults to +1. [Optional] * @return {Date} this */ $P.moveToDayOfWeek = moveToN("getDay", "addDays", 7); /** * Move to the next or last month based on the orient value. * @param {Number} The month to move to. 0 = January, 11 = December * @param {Number} Forward (+1) or Back (-1). Defaults to +1. [Optional] * @return {Date} this */ $P.moveToMonth = moveToN("getMonth", "addMonths", 12); /** * Get the Ordinate of the current day ("th", "st", "rd"). * @return {String} */ $P.getOrdinate = function () { var num = this.getDate(); return ord(num); }; /** * Get the Ordinal day (numeric day number) of the year, adjusted for leap year. * @return {Number} 1 through 365 (366 in leap years) */ $P.getOrdinalNumber = function () { return Math.ceil((this.clone().clearTime() - new Date(this.getFullYear(), 0, 1)) / 86400000) + 1; }; /** * Get the time zone abbreviation of the current date. * @return {String} The abbreviated time zone name (e.g. "EST") */ $P.getTimezone = function () { return $D.getTimezoneAbbreviation(this.getUTCOffset(), this.isDaylightSavingTime()); }; $P.setTimezoneOffset = function (offset) { var here = this.getTimezoneOffset(), there = Number(offset) * -6 / 10; return (there || there === 0) ? this.addMinutes(there - here) : this; }; $P.setTimezone = function (offset) { return this.setTimezoneOffset($D.getTimezoneOffset(offset)); }; /** * Indicates whether Daylight Saving Time is observed in the current time zone. * @return {Boolean} true|false */ $P.hasDaylightSavingTime = function () { return (Date.today().set({month: 0, day: 1}).getTimezoneOffset() !== Date.today().set({month: 6, day: 1}).getTimezoneOffset()); }; /** * Indicates whether this Date instance is within the Daylight Saving Time range for the current time zone. * @return {Boolean} true|false */ $P.isDaylightSavingTime = function () { return Date.today().set({month: 0, day: 1}).getTimezoneOffset() !== this.getTimezoneOffset(); }; /** * Get the offset from UTC of the current date. * @return {String} The 4-character offset string prefixed with + or - (e.g. "-0500") */ $P.getUTCOffset = function (offset) { var n = (offset || this.getTimezoneOffset()) * -10 / 6, r; if (n < 0) { r = (n - 10000).toString(); return r.charAt(0) + r.substr(2); } else { r = (n + 10000).toString(); return "+" + r.substr(1); } }; /** * Returns the number of milliseconds between this date and date. * @param {Date} Defaults to now * @return {Number} The diff in milliseconds */ $P.getElapsed = function (date) { return (date || new Date()) - this; }; /** * Set the value of year, month, day, hour, minute, second, millisecond of date instance using given configuration object. * Example

	Date.today().set( { day: 20, month: 1 } )

	new Date().set( { millisecond: 0 } )
	
* * @param {Object} Configuration object containing attributes (month, day, etc.) * @return {Date} this */ $P.set = function (config) { config = validateConfigObject.call(this, config); var key; for (key in config) { if (Object.prototype.hasOwnProperty.call(config, key)) { var name = key.charAt(0).toUpperCase() + key.slice(1); var addFunc, getFunc; if (key !== "week" && key !== "month" && key !== "timezone" && key !== "timezoneOffset") { name += "s"; } addFunc = "add" + name; getFunc = "get" + name; if (key === "month") { addFunc = addFunc + "s"; } else if (key === "year"){ getFunc = "getFullYear"; } if (key !== "day" && key !== "timezone" && key !== "timezoneOffset" && key !== "week" && key !== "hour") { this[addFunc](config[key] - this[getFunc]()); } else if ( key === "timezone"|| key === "timezoneOffset" || key === "week" || key === "hour") { this["set"+name](config[key]); } } } // day has to go last because you can't validate the day without first knowing the month if (config.day) { this.addDays(config.day - this.getDate()); } return this; }; /** * Moves the date to the first day of the month. * @return {Date} this */ $P.moveToFirstDayOfMonth = function () { return this.set({ day: 1 }); }; /** * Moves the date to the last day of the month. * @return {Date} this */ $P.moveToLastDayOfMonth = function () { return this.set({ day: $D.getDaysInMonth(this.getFullYear(), this.getMonth())}); }; /** * Converts the value of the current Date object to its equivalent string representation. * Format Specifiers * CUSTOM DATE AND TIME FORMAT STRINGS * Format Description Example * ------ --------------------------------------------------------------------------- ----------------------- * s The seconds of the minute between 0-59. "0" to "59" * ss The seconds of the minute with leading zero if required. "00" to "59" * * m The minute of the hour between 0-59. "0" or "59" * mm The minute of the hour with leading zero if required. "00" or "59" * * h The hour of the day between 1-12. "1" to "12" * hh The hour of the day with leading zero if required. "01" to "12" * * H The hour of the day between 0-23. "0" to "23" * HH The hour of the day with leading zero if required. "00" to "23" * * d The day of the month between 1 and 31. "1" to "31" * dd The day of the month with leading zero if required. "01" to "31" * ddd Abbreviated day name. Date.CultureInfo.abbreviatedDayNames. "Mon" to "Sun" * dddd The full day name. Date.CultureInfo.dayNames. "Monday" to "Sunday" * * M The month of the year between 1-12. "1" to "12" * MM The month of the year with leading zero if required. "01" to "12" * MMM Abbreviated month name. Date.CultureInfo.abbreviatedMonthNames. "Jan" to "Dec" * MMMM The full month name. Date.CultureInfo.monthNames. "January" to "December" * * yy The year as a two-digit number. "99" or "08" * yyyy The full four digit year. "1999" or "2008" * * t Displays the first character of the A.M./P.M. designator. "A" or "P" * Date.CultureInfo.amDesignator or Date.CultureInfo.pmDesignator * tt Displays the A.M./P.M. designator. "AM" or "PM" * Date.CultureInfo.amDesignator or Date.CultureInfo.pmDesignator * * S The ordinal suffix ("st, "nd", "rd" or "th") of the current day. "st, "nd", "rd" or "th" * * STANDARD DATE AND TIME FORMAT STRINGS * Format Description Example *------ --------------------------------------------------------------------------- ----------------------- * d The CultureInfo shortDate Format Pattern "M/d/yyyy" * D The CultureInfo longDate Format Pattern "dddd, MMMM dd, yyyy" * F The CultureInfo fullDateTime Format Pattern "dddd, MMMM dd, yyyy h:mm:ss tt" * m The CultureInfo monthDay Format Pattern "MMMM dd" * r The CultureInfo rfc1123 Format Pattern "ddd, dd MMM yyyy HH:mm:ss GMT" * s The CultureInfo sortableDateTime Format Pattern "yyyy-MM-ddTHH:mm:ss" * t The CultureInfo shortTime Format Pattern "h:mm tt" * T The CultureInfo longTime Format Pattern "h:mm:ss tt" * u The CultureInfo universalSortableDateTime Format Pattern "yyyy-MM-dd HH:mm:ssZ" * y The CultureInfo yearMonth Format Pattern "MMMM, yyyy" * * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @return {String} A string representation of the current Date object. */ var ord = function (n) { switch (n * 1) { case 1: case 21: case 31: return "st"; case 2: case 22: return "nd"; case 3: case 23: return "rd"; default: return "th"; } }; var parseStandardFormats = function (format) { var y, c = Date.CultureInfo.formatPatterns; switch (format) { case "d": return this.toString(c.shortDate); case "D": return this.toString(c.longDate); case "F": return this.toString(c.fullDateTime); case "m": return this.toString(c.monthDay); case "r": case "R": y = this.clone().addMinutes(this.getTimezoneOffset()); return y.toString(c.rfc1123) + " GMT"; case "s": return this.toString(c.sortableDateTime); case "t": return this.toString(c.shortTime); case "T": return this.toString(c.longTime); case "u": y = this.clone().addMinutes(this.getTimezoneOffset()); return y.toString(c.universalSortableDateTime); case "y": return this.toString(c.yearMonth); default: return false; } }; var parseFormatStringsClosure = function (context) { return function (m) { if (m.charAt(0) === "\\") { return m.replace("\\", ""); } switch (m) { case "hh": return p(context.getHours() < 13 ? (context.getHours() === 0 ? 12 : context.getHours()) : (context.getHours() - 12)); case "h": return context.getHours() < 13 ? (context.getHours() === 0 ? 12 : context.getHours()) : (context.getHours() - 12); case "HH": return p(context.getHours()); case "H": return context.getHours(); case "mm": return p(context.getMinutes()); case "m": return context.getMinutes(); case "ss": return p(context.getSeconds()); case "s": return context.getSeconds(); case "yyyy": return p(context.getFullYear(), 4); case "yy": return p(context.getFullYear()); case "y": return context.getFullYear(); case "E": case "dddd": return Date.CultureInfo.dayNames[context.getDay()]; case "ddd": return Date.CultureInfo.abbreviatedDayNames[context.getDay()]; case "dd": return p(context.getDate()); case "d": return context.getDate(); case "MMMM": return Date.CultureInfo.monthNames[context.getMonth()]; case "MMM": return Date.CultureInfo.abbreviatedMonthNames[context.getMonth()]; case "MM": return p((context.getMonth() + 1)); case "M": return context.getMonth() + 1; case "t": return context.getHours() < 12 ? Date.CultureInfo.amDesignator.substring(0, 1) : Date.CultureInfo.pmDesignator.substring(0, 1); case "tt": return context.getHours() < 12 ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator; case "S": return ord(context.getDate()); case "W": return context.getWeek(); case "WW": return context.getISOWeek(); case "Q": return "Q" + context.getQuarter(); case "q": return String(context.getQuarter()); case "z": return context.getTimezone(); case "Z": case "X": return Date.getTimezoneOffset(context.getTimezone()); case "ZZ": // Timezone offset in seconds return context.getTimezoneOffset() * -60; case "u": return context.getDay(); case "L": return ($D.isLeapYear(context.getFullYear())) ? 1 : 0; case "B": // Swatch Internet Time (.beats) return "@"+((context.getUTCSeconds() + (context.getUTCMinutes()*60) + ((context.getUTCHours()+1)*3600))/86.4); default: return m; } }; }; $P.toString = function (format, ignoreStandards) { // Standard Date and Time Format Strings. Formats pulled from CultureInfo file and // may vary by culture. if (!ignoreStandards && format && format.length === 1) { output = parseStandardFormats.call(this, format); if (output) { return output; } } var parseFormatStrings = parseFormatStringsClosure(this); return format ? format.replace(/((\\)?(dd?d?d?|MM?M?M?|yy?y?y?|hh?|HH?|mm?|ss?|tt?|S|q|Q|WW?W?W?)(?![^\[]*\]))/g, parseFormatStrings).replace(/\[|\]/g, "") : this._toString(); }; }()); /************************************************************* * SugarPak - Domain Specific Language - Syntactical Sugar * *************************************************************/ (function () { var $D = Date, $P = $D.prototype, $N = Number.prototype; // private $P._orient = +1; // private $P._nth = null; // private $P._is = false; // private $P._same = false; // private $P._isSecond = false; // private $N._dateElement = "days"; /** * Moves the date to the next instance of a date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.today().next().friday();
	Date.today().next().fri();
	Date.today().next().march();
	Date.today().next().mar();
	Date.today().next().week();
	
* * @return {Date} date */ $P.next = function () { this._move = true; this._orient = +1; return this; }; /** * Creates a new Date (Date.today()) and moves the date to the next instance of the date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.next().friday();
	Date.next().fri();
	Date.next().march();
	Date.next().mar();
	Date.next().week();
	
* * @return {Date} date */ $D.next = function () { return $D.today().next(); }; /** * Moves the date to the previous instance of a date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.today().last().friday();
	Date.today().last().fri();
	Date.today().last().march();
	Date.today().last().mar();
	Date.today().last().week();
	
* * @return {Date} date */ $P.last = $P.prev = $P.previous = function () { this._move = true; this._orient = -1; return this; }; /** * Creates a new Date (Date.today()) and moves the date to the previous instance of the date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.last().friday();
	Date.last().fri();
	Date.previous().march();
	Date.prev().mar();
	Date.last().week();
	
* * @return {Date} date */ $D.last = $D.prev = $D.previous = function () { return $D.today().last(); }; /** * Performs a equality check when followed by either a month name, day name or .weekday() function. * Example

	Date.today().is().friday(); // true|false
	Date.today().is().fri();
	Date.today().is().march();
	Date.today().is().mar();
	
* * @return {Boolean} true|false */ $P.is = function () { this._is = true; return this; }; /** * Determines if two date objects occur on/in exactly the same instance of the subsequent date part function. * The function .same() must be followed by a date part function (example: .day(), .month(), .year(), etc). * * An optional Date can be passed in the date part function. If now date is passed as a parameter, 'Now' is used. * * The following example demonstrates how to determine if two dates fall on the exact same day. * * Example

	var d1 = Date.today(); // today at 00:00
	var d2 = new Date();   // exactly now.

	// Do they occur on the same day?
	d1.same().day(d2); // true
	
	// Do they occur on the same hour?
	d1.same().hour(d2); // false, unless d2 hour is '00' (midnight).
	
	// What if it's the same day, but one year apart?
	var nextYear = Date.today().add(1).year();

	d1.same().day(nextYear); // false, because the dates must occur on the exact same day. 
	
* * Scenario: Determine if a given date occurs during some week period 2 months from now. * * Example

	var future = Date.today().add(2).months();
	return someDate.same().week(future); // true|false;
	
* * @return {Boolean} true|false */ $P.same = function () { this._same = true; this._isSecond = false; return this; }; /** * Determines if the current date/time occurs during Today. Must be preceded by the .is() function. * Example

	someDate.is().today();    // true|false
	new Date().is().today();  // true
	Date.today().is().today();// true
	Date.today().add(-1).day().is().today(); // false
	
* * @return {Boolean} true|false */ $P.today = function () { return this.same().day(); }; /** * Determines if the current date is a weekday. This function must be preceded by the .is() function. * Example

	Date.today().is().weekday(); // true|false
	
* * @return {Boolean} true|false */ $P.weekday = function () { if (this._nth) { return df("Weekday").call(this); } if (this._move) { return this.addWeekdays(this._orient); } if (this._is) { this._is = false; return (!this.is().sat() && !this.is().sun()); } return false; }; /** * Determines if the current date is on the weekend. This function must be preceded by the .is() function. * Example

	Date.today().is().weekend(); // true|false
	
* * @return {Boolean} true|false */ $P.weekend = function () { if (this._is) { this._is = false; return (this.is().sat() || this.is().sun()); } return false; }; /** * Sets the Time of the current Date instance. A string "6:15 pm" or config object {hour:18, minute:15} are accepted. * Example

	// Set time to 6:15pm with a String
	Date.today().at("6:15pm");

	// Set time to 6:15pm with a config object
	Date.today().at({hour:18, minute:15});
	
* * @return {Date} date */ $P.at = function (time) { return (typeof time === "string") ? $D.parse(this.toString("d") + " " + time) : this.set(time); }; /** * Creates a new Date() and adds this (Number) to the date based on the preceding date element function (eg. second|minute|hour|day|month|year). * Example

	// Undeclared Numbers must be wrapped with parentheses. Requirment of JavaScript.
	(3).days().fromNow();
	(6).months().fromNow();

	// Declared Number variables do not require parentheses. 
	var n = 6;
	n.months().fromNow();
	
* * @return {Date} A new Date instance */ $N.fromNow = $N.after = function (date) { var c = {}; c[this._dateElement] = this; return ((!date) ? new Date() : date.clone()).add(c); }; /** * Creates a new Date() and subtract this (Number) from the date based on the preceding date element function (eg. second|minute|hour|day|month|year). * Example

	// Undeclared Numbers must be wrapped with parentheses. Requirment of JavaScript.
	(3).days().ago();
	(6).months().ago();

	// Declared Number variables do not require parentheses. 
	var n = 6;
	n.months().ago();
	
* * @return {Date} A new Date instance */ $N.ago = $N.before = function (date) { var c = {}, s = (this._dateElement[this._dateElement.length-1] !== "s") ? this._dateElement + "s" : this._dateElement; c[s] = this * -1; return ((!date) ? new Date() : date.clone()).add(c); }; // Do NOT modify the following string tokens. These tokens are used to build dynamic functions. // All culture-specific strings can be found in the CultureInfo files. var dx = ("sunday monday tuesday wednesday thursday friday saturday").split(/\s/), mx = ("january february march april may june july august september october november december").split(/\s/), px = ("Millisecond Second Minute Hour Day Week Month Year Quarter Weekday").split(/\s/), pxf = ("Milliseconds Seconds Minutes Hours Date Week Month FullYear Quarter").split(/\s/), nth = ("final first second third fourth fifth").split(/\s/), de; /** * Returns an object literal of all the date parts. * Example

	var o = new Date().toObject();
	
	// { year: 2008, month: 4, week: 20, day: 13, hour: 18, minute: 9, second: 32, millisecond: 812 }
	
	// The object properties can be referenced directly from the object.
	
	alert(o.day);  // alerts "13"
	alert(o.year); // alerts "2008"
	
* * @return {Date} An object literal representing the original date object. */ $P.toObject = function () { var o = {}; for (var i = 0; i < px.length; i++) { if (this["get" + pxf[i]]) { o[px[i].toLowerCase()] = this["get" + pxf[i]](); } } return o; }; /** * Returns a date created from an object literal. Ignores the .week property if set in the config. * Example

	var o = new Date().toObject();
	
	return Date.fromObject(o); // will return the same date. 

	var o2 = {month: 1, day: 20, hour: 18}; // birthday party!
	Date.fromObject(o2);
	
* * @return {Date} An object literal representing the original date object. */ $D.fromObject = function(config) { config.week = null; return Date.today().set(config); }; // Create day name functions and abbreviated day name functions (eg. monday(), friday(), fri()). var df = function (n) { return function () { if (this._is) { this._is = false; return this.getDay() === n; } if (this._move) { this._move = null; } if (this._nth !== null) { // If the .second() function was called earlier, remove the _orient // from the date, and then continue. // This is required because 'second' can be used in two different context. // // Example // // Date.today().add(1).second(); // Date.march().second().monday(); // // Things get crazy with the following... // Date.march().add(1).second().second().monday(); // but it works!! // if (this._isSecond) { this.addSeconds(this._orient * -1); } // make sure we reset _isSecond this._isSecond = false; var ntemp = this._nth; this._nth = null; var temp = this.clone().moveToLastDayOfMonth(); this.moveToNthOccurrence(n, ntemp); if (this > temp) { throw new RangeError($D.getDayName(n) + " does not occur " + ntemp + " times in the month of " + $D.getMonthName(temp.getMonth()) + " " + temp.getFullYear() + "."); } return this; } return this.moveToDayOfWeek(n, this._orient); }; }; var sdf = function (n) { return function () { var t = $D.today(), shift = n - t.getDay(); if (n === 0 && Date.CultureInfo.firstDayOfWeek === 1 && t.getDay() !== 0) { shift = shift + 7; } return t.addDays(shift); }; }; // Create month name functions and abbreviated month name functions (eg. january(), march(), mar()). var month_instance_functions = function (n) { return function () { if (this._is) { this._is = false; return this.getMonth() === n; } return this.moveToMonth(n, this._orient); }; }; var month_static_functions = function (n) { return function () { return $D.today().set({ month: n, day: 1 }); }; }; var processTerms = function (names, staticFunc, instanceFunc) { for (var i = 0; i < names.length; i++) { // Create constant static Name variables. $D[names[i].toUpperCase()] = $D[names[i].toUpperCase().substring(0, 3)] = i; // Create Name functions. $D[names[i]] = $D[names[i].substring(0, 3)] = staticFunc(i); // Create Name instance functions. $P[names[i]] = $P[names[i].substring(0, 3)] = instanceFunc(i); } }; processTerms(dx, sdf, df); processTerms(mx, month_static_functions, month_instance_functions); // Create date element functions and plural date element functions used with Date (eg. day(), days(), months()). var ef = function (j) { return function () { // if the .second() function was called earlier, the _orient // has alread been added. Just return this and reset _isSecond. if (this._isSecond) { this._isSecond = false; return this; } if (this._same) { this._same = this._is = false; var o1 = this.toObject(), o2 = (arguments[0] || new Date()).toObject(), v = "", k = j.toLowerCase(); // the substr trick with -1 doesn't work in IE8 or less k = (k[k.length-1] === "s") ? k.substring(0,k.length-1) : k; for (var m = (px.length - 1); m > -1; m--) { v = px[m].toLowerCase(); if (o1[v] !== o2[v]) { return false; } if (k === v) { break; } } return true; } if (j.substring(j.length - 1) !== "s") { j += "s"; } if (this._move) { this._move = null; } return this["add" + j](this._orient); }; }; var nf = function (n) { return function () { this._dateElement = n; return this; }; }; for (var k = 0; k < px.length; k++) { de = px[k].toLowerCase(); if(de !== "weekday") { // Create date element functions and plural date element functions used with Date (eg. day(), days(), months()). $P[de] = $P[de + "s"] = ef(px[k]); // Create date element functions and plural date element functions used with Number (eg. day(), days(), months()). $N[de] = $N[de + "s"] = nf(de + "s"); } } $P._ss = ef("Second"); var nthfn = function (n) { return function (dayOfWeek) { if (this._same) { return this._ss(arguments[0]); } if (dayOfWeek || dayOfWeek === 0) { return this.moveToNthOccurrence(dayOfWeek, n); } this._nth = n; // if the operator is 'second' add the _orient, then deal with it later... if (n === 2 && (dayOfWeek === undefined || dayOfWeek === null)) { this._isSecond = true; return this.addSeconds(this._orient); } return this; }; }; for (var l = 0; l < nth.length; l++) { $P[nth[l]] = (l === 0) ? nthfn(-1) : nthfn(l); } }()); (function () { "use strict"; Date.Parsing = { Exception: function (s) { this.message = "Parse error at '" + s.substring(0, 10) + " ...'"; } }; var $P = Date.Parsing; var dayOffsets = { standard: [0,31,59,90,120,151,181,212,243,273,304,334], leap: [0,31,60,91,121,152,182,213,244,274,305,335] }; $P.isLeapYear = function(year) { return ((year % 4 === 0) && (year % 100 !== 0)) || (year % 400 === 0); }; var utils = { multiReplace : function (str, hash ) { var key; for (key in hash) { if (Object.prototype.hasOwnProperty.call(hash, key)) { var regex; if (typeof hash[key] === "function") { } else { regex = (hash[key] instanceof RegExp) ? hash[key] : new RegExp(hash[key], "g"); } str = str.replace(regex, key); } } return str; }, getDayOfYearFromWeek : function (obj) { var d, jan4, offset; obj.weekDay = (!obj.weekDay && obj.weekDay !== 0) ? 1 : obj.weekDay; d = new Date(obj.year, 0, 4); jan4 = d.getDay() === 0 ? 7 : d.getDay(); // JS is 0 indexed on Sunday. offset = jan4+3; obj.dayOfYear = ((obj.week * 7) + (obj.weekDay === 0 ? 7 : obj.weekDay))-offset; return obj; }, getDayOfYear : function (obj, dayOffset) { if (!obj.dayOfYear) { obj = utils.getDayOfYearFromWeek(obj); } for (var i=0;i <= dayOffset.length;i++) { if (obj.dayOfYear < dayOffset[i] || i === dayOffset.length) { obj.day = obj.day ? obj.day : (obj.dayOfYear - dayOffset[i-1]); break; } else { obj.month = i; } } return obj; }, adjustForTimeZone : function (obj, date) { var offset; if (obj.zone.toUpperCase() === "Z" || (obj.zone_hours === 0 && obj.zone_minutes === 0)) { // it's UTC/GML so work out the current timeszone offset offset = -date.getTimezoneOffset(); } else { offset = (obj.zone_hours*60) + (obj.zone_minutes || 0); if (obj.zone_sign === "+") { offset *= -1; } offset -= date.getTimezoneOffset(); } date.setMinutes(date.getMinutes()+offset); return date; }, setDefaults : function (obj) { obj.year = obj.year || Date.today().getFullYear(); obj.hours = obj.hours || 0; obj.minutes = obj.minutes || 0; obj.seconds = obj.seconds || 0; obj.milliseconds = obj.milliseconds || 0; if (!(!obj.month && (obj.week || obj.dayOfYear))) { // if we have a month, or if we don't but don't have the day calculation data obj.month = obj.month || 0; obj.day = obj.day || 1; } return obj; }, dataNum: function (data, mod, explict, postProcess) { var dataNum = data*1; if (mod) { if (postProcess) { return data ? mod(data)*1 : data; } else { return data ? mod(dataNum) : data; } } else if (!explict){ return data ? dataNum : data; } else { return (data && typeof data !== "undefined") ? dataNum : data; } }, timeDataProcess: function (obj) { var timeObj = {}; for (var x in obj.data) { if (obj.data.hasOwnProperty(x)) { timeObj[x] = obj.ignore[x] ? obj.data[x] : utils.dataNum(obj.data[x], obj.mods[x], obj.explict[x], obj.postProcess[x]); } } if (obj.data.secmins) { obj.data.secmins = obj.data.secmins.replace(",", ".") * 60; if (!timeObj.minutes) { timeObj.minutes = obj.data.secmins; } else if (!timeObj.seconds) { timeObj.seconds = obj.data.secmins; } delete obj.secmins; } return timeObj; }, buildTimeObjectFromData: function (data) { var time = utils.timeDataProcess({ data: { year : data[1], month : data[5], day : data[7], week : data[8], dayOfYear : data[10], hours : data[15], zone_hours : data[23], zone_minutes : data[24], zone : data[21], zone_sign : data[22], weekDay : data[9], minutes: data[16], seconds: data[19], milliseconds: data[20], secmins: data[18] }, mods: { month: function(data) { return data-1; }, weekDay: function (data) { data = Math.abs(data); return (data === 7 ? 0 : data); }, minutes: function (data) { return data.replace(":",""); }, seconds: function (data) { return Math.floor( (data.replace(":","").replace(",","."))*1 ); }, milliseconds: function (data) { return (data.replace(",",".")*1000); } }, postProcess: { minutes: true, seconds: true, milliseconds: true }, explict: { zone_hours: true, zone_minutes: true }, ignore: { zone: true, zone_sign: true, secmins: true } }); return time; }, addToHash: function (hash, keys, data) { keys = keys; data = data; var len = keys.length; for (var i = 0; i < len; i++) { hash[keys[i]] = data[i]; } return hash; }, combineRegex: function (r1, r2) { return new RegExp("(("+r1.source+")\\s("+r2.source+"))"); }, getDateNthString: function(add, last, inc){ if (add) { return Date.today().addDays(inc).toString("d"); } else if (last) { return Date.today().last()[inc]().toString("d"); } }, buildRegexData: function (array) { var arr = []; var len = array.length; for (var i=0; i < len; i++) { if (Object.prototype.toString.call(array[i]) === '[object Array]') { // oldIE compat version of Array.isArray arr.push(this.combineRegex(array[i][0], array[i][1])); } else { arr.push(array[i]); } } return arr; } }; $P.processTimeObject = function (obj) { var date, dayOffset; utils.setDefaults(obj); dayOffset = ($P.isLeapYear(obj.year)) ? dayOffsets.leap : dayOffsets.standard; if (!obj.month && (obj.week || obj.dayOfYear)) { utils.getDayOfYear(obj, dayOffset); } else { obj.dayOfYear = dayOffset[obj.month] + obj.day; } date = new Date(obj.year, obj.month, obj.day, obj.hours, obj.minutes, obj.seconds, obj.milliseconds); if (obj.zone) { utils.adjustForTimeZone(obj, date); // adjust (and calculate) for timezone } return date; }; $P.ISO = { regex : /^([\+-]?\d{4}(?!\d{2}\b))((-?)((0[1-9]|1[0-2])(\3([12]\d|0[1-9]|3[01]))?|W([0-4]\d|5[0-3])(-?[1-7])?|(00[1-9]|0[1-9]\d|[12]\d{2}|3([0-5]\d|6[1-6])))([T\s]((([01]\d|2[0-4])((:?)[0-5]\d)?|24\:?00)([\.,]\d+(?!:))?)?(\17[0-5]\d([\.,]\d+)?)?\s?([zZ]|([\+-])([01]\d|2[0-3]):?([0-5]\d)?)?)?)?$/, parse : function (s) { var time, data = s.match(this.regex); if (!data || !data.length) { return null; } time = utils.buildTimeObjectFromData(data); if (!time.year || (!time.year && (!time.month && !time.day) && (!time.week && !time.dayOfYear)) ) { return null; } return $P.processTimeObject(time); } }; $P.Numeric = { isNumeric: function (e){return!isNaN(parseFloat(e))&&isFinite(e);}, regex: /\b([0-1]?[0-9])([0-3]?[0-9])([0-2]?[0-9]?[0-9][0-9])\b/i, parse: function (s) { var data, i, time = {}, order = Date.CultureInfo.dateElementOrder.split(""); if (!(this.isNumeric(s)) || // if it's non-numeric OR (s[0] === "+" && s[0] === "-")) { // It's an arithmatic string (eg +/-1000) return null; } if (s.length < 5 && s.indexOf(".") < 0 && s.indexOf("/") < 0) { // assume it's just a year. time.year = s; return $P.processTimeObject(time); } data = s.match(this.regex); if (!data || !data.length) { return null; } for (i=0; i < order.length; i++) { switch(order[i]) { case "d": time.day = data[i+1]; break; case "m": time.month = (data[i+1]-1); break; case "y": time.year = data[i+1]; break; } } return $P.processTimeObject(time); } }; $P.Normalizer = { regexData: function () { var $R = Date.CultureInfo.regexPatterns; return utils.buildRegexData([ $R.tomorrow, $R.yesterday, [$R.past, $R.mon], [$R.past, $R.tue], [$R.past, $R.wed], [$R.past, $R.thu], [$R.past, $R.fri], [$R.past, $R.sat], [$R.past, $R.sun] ]); }, basicReplaceHash : function() { var $R = Date.CultureInfo.regexPatterns; return { "January": $R.jan.source, "February": $R.feb, "March": $R.mar, "April": $R.apr, "May": $R.may, "June": $R.jun, "July": $R.jul, "August": $R.aug, "September": $R.sep, "October": $R.oct, "November": $R.nov, "December": $R.dec, "": /\bat\b/gi, " ": /\s{2,}/, "am": $R.inTheMorning, "9am": $R.thisMorning, "pm": $R.inTheEvening, "7pm":$R.thisEvening }; }, keys : function(){ return [ utils.getDateNthString(true, false, 1), // tomorrow utils.getDateNthString(true, false, -1), // yesterday utils.getDateNthString(false, true, "monday"), //last mon utils.getDateNthString(false, true, "tuesday"), //last tues utils.getDateNthString(false, true, "wednesday"), //last wed utils.getDateNthString(false, true, "thursday"), //last thurs utils.getDateNthString(false, true, "friday"), //last fri utils.getDateNthString(false, true, "saturday"), //last sat utils.getDateNthString(false, true, "sunday") //last sun ]; }, buildRegexFunctions: function () { var $R = Date.CultureInfo.regexPatterns; var __ = Date.i18n.__; var tomorrowRE = new RegExp("(\\b\\d\\d?("+__("AM")+"|"+__("PM")+")? )("+$R.tomorrow.source.slice(1)+")", "i"); // adapted tomorrow regex for AM PM relative dates var todayRE = new RegExp($R.today.source + "(?!\\s*([+-]))\\b"); // today, but excludes the math operators (eg "today + 2h") this.replaceFuncs = [ [todayRE, function (full) { return (full.length > 1) ? Date.today().toString("d") : full; }], [tomorrowRE, function(full, m1) { var t = Date.today().addDays(1).toString("d"); return (t + " " + m1); }], [$R.amThisMorning, function(str, am){return am;}], [$R.pmThisEvening, function(str, pm){return pm;}] ]; }, buildReplaceData: function () { this.buildRegexFunctions(); this.replaceHash = utils.addToHash(this.basicReplaceHash(), this.keys(), this.regexData()); }, stringReplaceFuncs: function (s) { for (var i=0; i < this.replaceFuncs.length; i++) { s = s.replace(this.replaceFuncs[i][0], this.replaceFuncs[i][1]); } return s; }, parse: function (s) { s = this.stringReplaceFuncs(s); s = utils.multiReplace(s, this.replaceHash); try { var n = s.split(/([\s\-\.\,\/\x27]+)/); if (n.length === 3 && $P.Numeric.isNumeric(n[0]) && $P.Numeric.isNumeric(n[2]) && (n[2].length >= 4)) { // ok, so we're dealing with x/year. But that's not a full date. // This fixes wonky dateElementOrder parsing when set to dmy order. if (Date.CultureInfo.dateElementOrder[0] === "d") { s = "1/" + n[0] + "/" + n[2]; // set to 1st of month and normalize the seperator } } } catch (e) {} return s; } }; $P.Normalizer.buildReplaceData(); }()); (function () { var $P = Date.Parsing; var _ = $P.Operators = { // // Tokenizers // rtoken: function (r) { // regex token return function (s) { var mx = s.match(r); if (mx) { return ([ mx[0], s.substring(mx[0].length) ]); } else { throw new $P.Exception(s); } }; }, token: function () { // whitespace-eating token return function (s) { return _.rtoken(new RegExp("^\\s*" + s + "\\s*"))(s); }; }, stoken: function (s) { // string token return _.rtoken(new RegExp("^" + s)); }, // Atomic Operators until: function (p) { return function (s) { var qx = [], rx = null; while (s.length) { try { rx = p.call(this, s); } catch (e) { qx.push(rx[0]); s = rx[1]; continue; } break; } return [ qx, s ]; }; }, many: function (p) { return function (s) { var rx = [], r = null; while (s.length) { try { r = p.call(this, s); } catch (e) { return [ rx, s ]; } rx.push(r[0]); s = r[1]; } return [ rx, s ]; }; }, // generator operators -- see below optional: function (p) { return function (s) { var r = null; try { r = p.call(this, s); } catch (e) { return [ null, s ]; } return [ r[0], r[1] ]; }; }, not: function (p) { return function (s) { try { p.call(this, s); } catch (e) { return [null, s]; } throw new $P.Exception(s); }; }, ignore: function (p) { return p ? function (s) { var r = null; r = p.call(this, s); return [null, r[1]]; } : null; }, product: function () { var px = arguments[0], qx = Array.prototype.slice.call(arguments, 1), rx = []; for (var i = 0 ; i < px.length ; i++) { rx.push(_.each(px[i], qx)); } return rx; }, cache: function (rule) { var cache = {}, cache_length = 0, cache_keys = [], CACHE_MAX = Date.Config.CACHE_MAX || 100000, r = null; var cacheCheck = function () { if (cache_length === CACHE_MAX) { // kill several keys, don't want to have to do this all the time... for (var i=0; i < 10; i++) { var key = cache_keys.shift(); if (key) { delete cache[key]; cache_length--; } } } }; return function (s) { cacheCheck(); try { r = cache[s] = (cache[s] || rule.call(this, s)); } catch (e) { r = cache[s] = e; } cache_length++; cache_keys.push(s); if (r instanceof $P.Exception) { throw r; } else { return r; } }; }, // vector operators -- see below any: function () { var px = arguments; return function (s) { var r = null; for (var i = 0; i < px.length; i++) { if (px[i] == null) { continue; } try { r = (px[i].call(this, s)); } catch (e) { r = null; } if (r) { return r; } } throw new $P.Exception(s); }; }, each: function () { var px = arguments; return function (s) { var rx = [], r = null; for (var i = 0; i < px.length ; i++) { if (px[i] == null) { continue; } try { r = (px[i].call(this, s)); } catch (e) { throw new $P.Exception(s); } rx.push(r[0]); s = r[1]; } return [ rx, s]; }; }, all: function () { var px = arguments, _ = _; return _.each(_.optional(px)); }, // delimited operators sequence: function (px, d, c) { d = d || _.rtoken(/^\s*/); c = c || null; if (px.length === 1) { return px[0]; } return function (s) { var r = null, q = null; var rx = []; for (var i = 0; i < px.length ; i++) { try { r = px[i].call(this, s); } catch (e) { break; } rx.push(r[0]); try { q = d.call(this, r[1]); } catch (ex) { q = null; break; } s = q[1]; } if (!r) { throw new $P.Exception(s); } if (q) { throw new $P.Exception(q[1]); } if (c) { try { r = c.call(this, r[1]); } catch (ey) { throw new $P.Exception(r[1]); } } return [ rx, (r?r[1]:s) ]; }; }, // // Composite Operators // between: function (d1, p, d2) { d2 = d2 || d1; var _fn = _.each(_.ignore(d1), p, _.ignore(d2)); return function (s) { var rx = _fn.call(this, s); return [[rx[0][0], r[0][2]], rx[1]]; }; }, list: function (p, d, c) { d = d || _.rtoken(/^\s*/); c = c || null; return (p instanceof Array ? _.each(_.product(p.slice(0, -1), _.ignore(d)), p.slice(-1), _.ignore(c)) : _.each(_.many(_.each(p, _.ignore(d))), px, _.ignore(c))); }, set: function (px, d, c) { d = d || _.rtoken(/^\s*/); c = c || null; return function (s) { // r is the current match, best the current 'best' match // which means it parsed the most amount of input var r = null, p = null, q = null, rx = null, best = [[], s], last = false; // go through the rules in the given set for (var i = 0; i < px.length ; i++) { // last is a flag indicating whether this must be the last element // if there is only 1 element, then it MUST be the last one q = null; p = null; r = null; last = (px.length === 1); // first, we try simply to match the current pattern // if not, try the next pattern try { r = px[i].call(this, s); } catch (e) { continue; } // since we are matching against a set of elements, the first // thing to do is to add r[0] to matched elements rx = [[r[0]], r[1]]; // if we matched and there is still input to parse and // we don't already know this is the last element, // we're going to next check for the delimiter ... // if there's none, or if there's no input left to parse // than this must be the last element after all ... if (r[1].length > 0 && ! last) { try { q = d.call(this, r[1]); } catch (ex) { last = true; } } else { last = true; } // if we parsed the delimiter and now there's no more input, // that means we shouldn't have parsed the delimiter at all // so don't update r and mark this as the last element ... if (!last && q[1].length === 0) { last = true; } // so, if this isn't the last element, we're going to see if // we can get any more matches from the remaining (unmatched) // elements ... if (!last) { // build a list of the remaining rules we can match against, // i.e., all but the one we just matched against var qx = []; for (var j = 0; j < px.length ; j++) { if (i !== j) { qx.push(px[j]); } } // now invoke recursively set with the remaining input // note that we don't include the closing delimiter ... // we'll check for that ourselves at the end p = _.set(qx, d).call(this, q[1]); // if we got a non-empty set as a result ... // (otw rx already contains everything we want to match) if (p[0].length > 0) { // update current result, which is stored in rx ... // basically, pick up the remaining text from p[1] // and concat the result from p[0] so that we don't // get endless nesting ... rx[0] = rx[0].concat(p[0]); rx[1] = p[1]; } } // at this point, rx either contains the last matched element // or the entire matched set that starts with this element. // now we just check to see if this variation is better than // our best so far, in terms of how much of the input is parsed if (rx[1].length < best[1].length) { best = rx; } // if we've parsed all the input, then we're finished if (best[1].length === 0) { break; } } // so now we've either gone through all the patterns trying them // as the initial match; or we found one that parsed the entire // input string ... // if best has no matches, just return empty set ... if (best[0].length === 0) { return best; } // if a closing delimiter is provided, then we have to check it also if (c) { // we try this even if there is no remaining input because the pattern // may well be optional or match empty input ... try { q = c.call(this, best[1]); } catch (ey) { throw new $P.Exception(best[1]); } // it parsed ... be sure to update the best match remaining input best[1] = q[1]; } // if we're here, either there was no closing delimiter or we parsed it // so now we have the best match; just return it! return best; }; }, forward: function (gr, fname) { return function (s) { return gr[fname].call(this, s); }; }, // // Translation Operators // replace: function (rule, repl) { return function (s) { var r = rule.call(this, s); return [repl, r[1]]; }; }, process: function (rule, fn) { return function (s) { var r = rule.call(this, s); return [fn.call(this, r[0]), r[1]]; }; }, min: function (min, rule) { return function (s) { var rx = rule.call(this, s); if (rx[0].length < min) { throw new $P.Exception(s); } return rx; }; } }; // Generator Operators And Vector Operators // Generators are operators that have a signature of F(R) => R, // taking a given rule and returning another rule, such as // ignore, which parses a given rule and throws away the result. // Vector operators are those that have a signature of F(R1,R2,...) => R, // take a list of rules and returning a new rule, such as each. // Generator operators are converted (via the following _generator // function) into functions that can also take a list or array of rules // and return an array of new rules as though the function had been // called on each rule in turn (which is what actually happens). // This allows generators to be used with vector operators more easily. // Example: // each(ignore(foo, bar)) instead of each(ignore(foo), ignore(bar)) // This also turns generators into vector operators, which allows // constructs like: // not(cache(foo, bar)) var _generator = function (op) { function gen() { var args = null, rx = [], px, i; if (arguments.length > 1) { args = Array.prototype.slice.call(arguments); } else if (arguments[0] instanceof Array) { args = arguments[0]; } if (args) { px = args.shift(); if (px.length > 0) { args.unshift(px[i]); rx.push(op.apply(null, args)); args.shift(); return rx; } } else { return op.apply(null, arguments); } } return gen; }; var gx = "optional not ignore cache".split(/\s/); for (var i = 0 ; i < gx.length ; i++) { _[gx[i]] = _generator(_[gx[i]]); } var _vector = function (op) { return function () { if (arguments[0] instanceof Array) { return op.apply(null, arguments[0]); } else { return op.apply(null, arguments); } }; }; var vx = "each any all".split(/\s/); for (var j = 0 ; j < vx.length ; j++) { _[vx[j]] = _vector(_[vx[j]]); } }()); (function () { var $D = Date; var flattenAndCompact = function (ax) { var rx = []; for (var i = 0; i < ax.length; i++) { if (ax[i] instanceof Array) { rx = rx.concat(flattenAndCompact(ax[i])); } else { if (ax[i]) { rx.push(ax[i]); } } } return rx; }; var parseMeridian = function () { if (this.meridian && (this.hour || this.hour === 0)) { if (this.meridian === "a" && this.hour > 11 && Date.Config.strict24hr){ throw "Invalid hour and meridian combination"; } else if (this.meridian === "p" && this.hour < 12 && Date.Config.strict24hr){ throw "Invalid hour and meridian combination"; } else if (this.meridian === "p" && this.hour < 12) { this.hour = this.hour + 12; } else if (this.meridian === "a" && this.hour === 12) { this.hour = 0; } } }; var setDefaults = function () { var now = new Date(); if ((this.hour || this.minute) && (!this.month && !this.year && !this.day)) { this.day = now.getDate(); } if (!this.year) { this.year = now.getFullYear(); } if (!this.month && this.month !== 0) { this.month = now.getMonth(); } if (!this.day) { this.day = 1; } if (!this.hour) { this.hour = 0; } if (!this.minute) { this.minute = 0; } if (!this.second) { this.second = 0; } if (!this.millisecond) { this.millisecond = 0; } }; var finishUtils = { getToday: function () { if (this.now || "hour minute second".indexOf(this.unit) !== -1) { return new Date(); } else { return $D.today(); } }, setDaysFromWeekday: function (today, orient){ var gap; orient = orient || 1; this.unit = "day"; gap = ($D.getDayNumberFromName(this.weekday) - today.getDay()); this.days = gap ? ((gap + (orient * 7)) % 7) : (orient * 7); return this; }, setMonthsFromMonth: function (today, orient) { var gap; orient = orient || 1; this.unit = "month"; gap = (this.month - today.getMonth()); this.months = gap ? ((gap + (orient * 12)) % 12) : (orient * 12); this.month = null; return this; }, setDMYFromWeekday: function () { var d = Date[this.weekday](); this.day = d.getDate(); if (!this.month) { this.month = d.getMonth(); } this.year = d.getFullYear(); return this; }, setUnitValue: function (orient) { if (!this.value && this.operator && this.operator !== null && this[this.unit + "s"] && this[this.unit + "s"] !== null) { this[this.unit + "s"] = this[this.unit + "s"] + ((this.operator === "add") ? 1 : -1) + (this.value||0) * orient; } else if (this[this.unit + "s"] == null || this.operator != null) { if (!this.value) { this.value = 1; } this[this.unit + "s"] = this.value * orient; } }, generateDateFromWeeks: function () { var weekday = (this.weekday !== undefined) ? this.weekday : "today"; var d = Date[weekday]().addWeeks(this.weeks); if (this.now) { d.setTimeToNow(); } return d; } }; $D.Translator = { hour: function (s) { return function () { this.hour = Number(s); }; }, minute: function (s) { return function () { this.minute = Number(s); }; }, second: function (s) { return function () { this.second = Number(s); }; }, /* for ss.s format */ secondAndMillisecond: function (s) { return function () { var mx = s.match(/^([0-5][0-9])\.([0-9]{1,3})/); this.second = Number(mx[1]); this.millisecond = Number(mx[2]); }; }, meridian: function (s) { return function () { this.meridian = s.slice(0, 1).toLowerCase(); }; }, timezone: function (s) { return function () { var n = s.replace(/[^\d\+\-]/g, ""); if (n.length) { this.timezoneOffset = Number(n); } else { this.timezone = s.toLowerCase(); } }; }, day: function (x) { var s = x[0]; return function () { this.day = Number(s.match(/\d+/)[0]); if (this.day < 1) { throw "invalid day"; } }; }, month: function (s) { return function () { this.month = (s.length === 3) ? "jan feb mar apr may jun jul aug sep oct nov dec".indexOf(s)/4 : Number(s) - 1; if (this.month < 0) { throw "invalid month"; } }; }, year: function (s) { return function () { var n = Number(s); this.year = ((s.length > 2) ? n : (n + (((n + 2000) < Date.CultureInfo.twoDigitYearMax) ? 2000 : 1900))); }; }, rday: function (s) { return function () { switch (s) { case "yesterday": this.days = -1; break; case "tomorrow": this.days = 1; break; case "today": this.days = 0; break; case "now": this.days = 0; this.now = true; break; } }; }, finishExact: function (x) { var d; x = (x instanceof Array) ? x : [x]; for (var i = 0 ; i < x.length ; i++) { if (x[i]) { x[i].call(this); } } setDefaults.call(this); parseMeridian.call(this); if (this.day > $D.getDaysInMonth(this.year, this.month)) { throw new RangeError(this.day + " is not a valid value for days."); } d = new Date(this.year, this.month, this.day, this.hour, this.minute, this.second, this.millisecond); if (this.year < 100) { d.setFullYear(this.year); // means years less that 100 are process correctly. JS will parse it otherwise as 1900-1999. } if (this.timezone) { d.set({ timezone: this.timezone }); } else if (this.timezoneOffset) { d.set({ timezoneOffset: this.timezoneOffset }); } return d; }, finish: function (x) { var today, expression, orient, temp; x = (x instanceof Array) ? flattenAndCompact(x) : [ x ]; if (x.length === 0) { return null; } for (var i = 0 ; i < x.length ; i++) { if (typeof x[i] === "function") { x[i].call(this); } } if (this.now && !this.unit && !this.operator) { return new Date(); } else { today = finishUtils.getToday.call(this); } expression = !!(this.days && this.days !== null || this.orient || this.operator); orient = ((this.orient === "past" || this.operator === "subtract") ? -1 : 1); if (this.month && this.unit === "week") { this.value = this.month + 1; delete this.month; delete this.day; } if ((this.month || this.month === 0) && "year day hour minute second".indexOf(this.unit) !== -1) { if (!this.value) { this.value = this.month + 1; } this.month = null; expression = true; } if (!expression && this.weekday && !this.day && !this.days) { finishUtils.setDMYFromWeekday.call(this); } if (expression && this.weekday && this.unit !== "month" && this.unit !== "week") { finishUtils.setDaysFromWeekday.call(this, today, orient); } if (this.weekday && this.unit !== "week" && !this.day && !this.days) { temp = Date[this.weekday](); this.day = temp.getDate(); if (temp.getMonth() !== today.getMonth()) { this.month = temp.getMonth(); } } if (this.month && this.unit === "day" && this.operator) { if (!this.value) { this.value = (this.month + 1); } this.month = null; } if (this.value != null && this.month != null && this.year != null) { this.day = this.value * 1; } if (this.month && !this.day && this.value) { today.set({ day: this.value * 1 }); if (!expression) { this.day = this.value * 1; } } if (!this.month && this.value && this.unit === "month" && !this.now) { this.month = this.value; expression = true; } if (expression && (this.month || this.month === 0) && this.unit !== "year") { finishUtils.setMonthsFromMonth.call(this, today, orient); } if (!this.unit) { this.unit = "day"; } finishUtils.setUnitValue.call(this, orient); parseMeridian.call(this); if ((this.month || this.month === 0) && !this.day) { this.day = 1; } if (!this.orient && !this.operator && this.unit === "week" && this.value && !this.day && !this.month) { return Date.today().setWeek(this.value); } if (this.unit === "week" && this.weeks && !this.day && !this.month) { return finishUtils.generateDateFromWeeks.call(this); } if (expression && this.timezone && this.day && this.days) { this.day = this.days; } if (expression){ today.add(this); } else { today.set(this); } if (this.timezone) { this.timezone = this.timezone.toUpperCase(); var offset = $D.getTimezoneOffset(this.timezone); var timezone; if (today.hasDaylightSavingTime()) { // lets check that we're being sane with timezone setting timezone = $D.getTimezoneAbbreviation(offset, today.isDaylightSavingTime()); if (timezone !== this.timezone) { // bugger, we're in a place where things like EST vs EDT matters. if (today.isDaylightSavingTime()) { today.addHours(-1); } else { today.addHours(1); } } } today.setTimezoneOffset(offset); } return today; } }; }()); (function () { var $D = Date; $D.Grammar = {}; var _ = $D.Parsing.Operators, g = $D.Grammar, t = $D.Translator, _fn; // Allow rolling up into general purpose rules _fn = function () { return _.each(_.any.apply(null, arguments), _.not(g.ctoken2("timeContext"))); }; g.datePartDelimiter = _.rtoken(/^([\s\-\.\,\/\x27]+)/); g.timePartDelimiter = _.stoken(":"); g.whiteSpace = _.rtoken(/^\s*/); g.generalDelimiter = _.rtoken(/^(([\s\,]|at|@|on)+)/); var _C = {}; g.ctoken = function (keys) { var fn = _C[keys]; if (! fn) { var c = Date.CultureInfo.regexPatterns; var kx = keys.split(/\s+/), px = []; for (var i = 0; i < kx.length ; i++) { px.push(_.replace(_.rtoken(c[kx[i]]), kx[i])); } fn = _C[keys] = _.any.apply(null, px); } return fn; }; g.ctoken2 = function (key) { return _.rtoken(Date.CultureInfo.regexPatterns[key]); }; var cacheProcessRtoken = function (key, token, type, eachToken) { if (eachToken) { g[key] = _.cache(_.process(_.each(_.rtoken(token),_.optional(g.ctoken2(eachToken))), type)); } else { g[key] = _.cache(_.process(_.rtoken(token), type)); } }; var cacheProcessCtoken = function (token, type) { return _.cache(_.process(g.ctoken2(token), type)); }; var _F = {}; //function cache var _get = function (f) { _F[f] = (_F[f] || g.format(f)[0]); return _F[f]; }; g.allformats = function (fx) { var rx = []; if (fx instanceof Array) { for (var i = 0; i < fx.length; i++) { rx.push(_get(fx[i])); } } else { rx.push(_get(fx)); } return rx; }; g.formats = function (fx) { if (fx instanceof Array) { var rx = []; for (var i = 0 ; i < fx.length ; i++) { rx.push(_get(fx[i])); } return _.any.apply(null, rx); } else { return _get(fx); } }; var grammarFormats = { timeFormats: function(){ var i, RTokenKeys = [ "h", "hh", "H", "HH", "m", "mm", "s", "ss", "ss.s", "z", "zz" ], RToken = [ /^(0[0-9]|1[0-2]|[1-9])/, /^(0[0-9]|1[0-2])/, /^([0-1][0-9]|2[0-3]|[0-9])/, /^([0-1][0-9]|2[0-3])/, /^([0-5][0-9]|[0-9])/, /^[0-5][0-9]/, /^([0-5][0-9]|[0-9])/, /^[0-5][0-9]/, /^[0-5][0-9]\.[0-9]{1,3}/, /^((\+|\-)\s*\d\d\d\d)|((\+|\-)\d\d\:?\d\d)/, /^((\+|\-)\s*\d\d\d\d)|((\+|\-)\d\d\:?\d\d)/ ], tokens = [ t.hour, t.hour, t.hour, t.hour, t.minute, t.minute, t.second, t.second, t.secondAndMillisecond, t.timezone, t.timezone ]; for (i=0; i < RTokenKeys.length; i++) { cacheProcessRtoken(RTokenKeys[i], RToken[i], tokens[i]); } g.hms = _.cache(_.sequence([g.H, g.m, g.s], g.timePartDelimiter)); g.t = cacheProcessCtoken("shortMeridian", t.meridian); g.tt = cacheProcessCtoken("longMeridian", t.meridian); g.zzz = cacheProcessCtoken("timezone", t.timezone); g.timeSuffix = _.each(_.ignore(g.whiteSpace), _.set([ g.tt, g.zzz ])); g.time = _.each(_.optional(_.ignore(_.stoken("T"))), g.hms, g.timeSuffix); }, dateFormats: function () { // pre-loaded rules for different date part order preferences var _setfn = function () { return _.set(arguments, g.datePartDelimiter); }; var i, RTokenKeys = [ "d", "dd", "M", "MM", "y", "yy", "yyy", "yyyy" ], RToken = [ /^([0-2]\d|3[0-1]|\d)/, /^([0-2]\d|3[0-1])/, /^(1[0-2]|0\d|\d)/, /^(1[0-2]|0\d)/, /^(\d+)/, /^(\d\d)/, /^(\d\d?\d?\d?)/, /^(\d\d\d\d)/ ], tokens = [ t.day, t.day, t.month, t.month, t.year, t.year, t.year, t.year ], eachToken = [ "ordinalSuffix", "ordinalSuffix" ]; for (i=0; i < RTokenKeys.length; i++) { cacheProcessRtoken(RTokenKeys[i], RToken[i], tokens[i], eachToken[i]); } g.MMM = g.MMMM = _.cache(_.process(g.ctoken("jan feb mar apr may jun jul aug sep oct nov dec"), t.month)); g.ddd = g.dddd = _.cache(_.process(g.ctoken("sun mon tue wed thu fri sat"), function (s) { return function () { this.weekday = s; }; } )); g.day = _fn(g.d, g.dd); g.month = _fn(g.M, g.MMM); g.year = _fn(g.yyyy, g.yy); g.mdy = _setfn(g.ddd, g.month, g.day, g.year); g.ymd = _setfn(g.ddd, g.year, g.month, g.day); g.dmy = _setfn(g.ddd, g.day, g.month, g.year); g.date = function (s) { return ((g[Date.CultureInfo.dateElementOrder] || g.mdy).call(this, s)); }; }, relative: function () { // relative date / time expressions g.orientation = _.process(g.ctoken("past future"), function (s) { return function () { this.orient = s; }; } ); g.operator = _.process(g.ctoken("add subtract"), function (s) { return function () { this.operator = s; }; } ); g.rday = _.process(g.ctoken("yesterday tomorrow today now"), t.rday); g.unit = _.process(g.ctoken("second minute hour day week month year"), function (s) { return function () { this.unit = s; }; } ); } }; g.buildGrammarFormats = function () { // these need to be rebuilt every time the language changes. _C = {}; grammarFormats.timeFormats(); grammarFormats.dateFormats(); grammarFormats.relative(); g.value = _.process(_.rtoken(/^([-+]?\d+)?(st|nd|rd|th)?/), function (s) { return function () { this.value = s.replace(/\D/g, ""); }; } ); g.expression = _.set([g.rday, g.operator, g.value, g.unit, g.orientation, g.ddd, g.MMM ]); g.format = _.process(_.many( _.any( // translate format specifiers into grammar rules _.process( _.rtoken(/^(dd?d?d?(?!e)|MM?M?M?|yy?y?y?|hh?|HH?|mm?|ss?|tt?|zz?z?)/), function (fmt) { if (g[fmt]) { return g[fmt]; } else { throw $D.Parsing.Exception(fmt); } } ), // translate separator tokens into token rules _.process(_.rtoken(/^[^dMyhHmstz]+/), // all legal separators function (s) { return _.ignore(_.stoken(s)); } ) ) ), // construct the parser ... function (rules) { return _.process(_.each.apply(null, rules), t.finishExact); } ); // starting rule for general purpose grammar g._start = _.process(_.set([ g.date, g.time, g.expression ], g.generalDelimiter, g.whiteSpace), t.finish); }; g.buildGrammarFormats(); // parsing date format specifiers - ex: "h:m:s tt" // this little guy will generate a custom parser based // on the format string, ex: g.format("h:m:s tt") // check for these formats first g._formats = g.formats([ "\"yyyy-MM-ddTHH:mm:ssZ\"", "yyyy-MM-ddTHH:mm:ss.sz", "yyyy-MM-ddTHH:mm:ssZ", "yyyy-MM-ddTHH:mm:ssz", "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-ddTHH:mmZ", "yyyy-MM-ddTHH:mmz", "yyyy-MM-ddTHH:mm", "ddd, MMM dd, yyyy H:mm:ss tt", "ddd MMM d yyyy HH:mm:ss zzz", "MMddyyyy", "ddMMyyyy", "Mddyyyy", "ddMyyyy", "Mdyyyy", "dMyyyy", "yyyy", "Mdyy", "dMyy", "d" ]); // real starting rule: tries selected formats first, // then general purpose rule g.start = function (s) { try { var r = g._formats.call({}, s); if (r[1].length === 0) { return r; } } catch (e) {} return g._start.call({}, s); }; }()); (function () { var $D = Date; /** * @desc Converts the specified string value into its JavaScript Date equivalent using CultureInfo specific format information. * * Example

	///////////
	// Dates //
	///////////

	// 15-Oct-2004
	var d1 = Date.parse("10/15/2004");

	// 15-Oct-2004
	var d1 = Date.parse("15-Oct-2004");

	// 15-Oct-2004
	var d1 = Date.parse("2004.10.15");

	//Fri Oct 15, 2004
	var d1 = Date.parse("Fri Oct 15, 2004");

	///////////
	// Times //
	///////////

	// Today at 10 PM.
	var d1 = Date.parse("10 PM");

	// Today at 10:30 PM.
	var d1 = Date.parse("10:30 P.M.");

	// Today at 6 AM.
	var d1 = Date.parse("06am");

	/////////////////////
	// Dates and Times //
	/////////////////////

	// 8-July-2004 @ 10:30 PM
	var d1 = Date.parse("July 8th, 2004, 10:30 PM");

	// 1-July-2004 @ 10:30 PM
	var d1 = Date.parse("2004-07-01T22:30:00");

	////////////////////
	// Relative Dates //
	////////////////////

	// Returns today's date. The string "today" is culture specific.
	var d1 = Date.parse("today");

	// Returns yesterday's date. The string "yesterday" is culture specific.
	var d1 = Date.parse("yesterday");

	// Returns the date of the next thursday.
	var d1 = Date.parse("Next thursday");

	// Returns the date of the most previous monday.
	var d1 = Date.parse("last monday");

	// Returns today's day + one year.
	var d1 = Date.parse("next year");

	///////////////
	// Date Math //
	///////////////

	// Today + 2 days
	var d1 = Date.parse("t+2");

	// Today + 2 days
	var d1 = Date.parse("today + 2 days");

	// Today + 3 months
	var d1 = Date.parse("t+3m");

	// Today - 1 year
	var d1 = Date.parse("today - 1 year");

	// Today - 1 year
	var d1 = Date.parse("t-1y"); 


	/////////////////////////////
	// Partial Dates and Times //
	/////////////////////////////

	// July 15th of this year.
	var d1 = Date.parse("July 15");

	// 15th day of current day and year.
	var d1 = Date.parse("15");

	// July 1st of current year at 10pm.
	var d1 = Date.parse("7/1 10pm");
	
* * @param {String} The string value to convert into a Date object [Required] * @return {Date} A Date object or null if the string cannot be converted into a Date. */ var parseUtils = { removeOrds: function (s) { ords = s.match(/\b(\d+)(?:st|nd|rd|th)\b/); // find ordinal matches s = ((ords && ords.length === 2) ? s.replace(ords[0], ords[1]) : s); return s; }, grammarParser: function (s) { var r = null; try { r = $D.Grammar.start.call({}, s.replace(/^\s*(\S*(\s+\S+)*)\s*$/, "$1")); } catch (e) { return null; } return ((r[1].length === 0) ? r[0] : null); }, nativeFallback: function(s) { var t; try { // ok we haven't parsed it, last ditch attempt with the built-in parser. t = Date._parse(s); return (t || t === 0) ? new Date(t) : null; } catch (e) { return null; } } }; function parse (s) { var d; if (!s) { return null; } if (s instanceof Date) { return s.clone(); } if (s.length >= 4 && s.charAt(0) !== "0" && s.charAt(0) !== "+"&& s.charAt(0) !== "-") { // ie: 2004 will pass, 0800 won't. // Start with specific formats d = $D.Parsing.ISO.parse(s) || $D.Parsing.Numeric.parse(s); } if (d instanceof Date && !isNaN(d.getTime())) { return d; } else { // find ordinal dates (1st, 3rd, 8th, etc and remove them as they cause parsing issues) s = $D.Parsing.Normalizer.parse(parseUtils.removeOrds(s)); d = parseUtils.grammarParser(s); if (d !== null) { return d; } else { return parseUtils.nativeFallback(s); } } } if (!$D._parse) { $D._parse = $D.parse; } $D.parse = parse; Date.getParseFunction = function (fx) { var fns = Date.Grammar.allformats(fx); return function (s) { var r = null; for (var i = 0; i < fns.length; i++) { try { r = fns[i].call({}, s); } catch (e) { continue; } if (r[1].length === 0) { return r[0]; } } return null; }; }; /** * Converts the specified string value into its JavaScript Date equivalent using the specified format {String} or formats {Array} and the CultureInfo specific format information. * The format of the string value must match one of the supplied formats exactly. * * Example

	// 15-Oct-2004
	var d1 = Date.parseExact("10/15/2004", "M/d/yyyy");

	// 15-Oct-2004
	var d1 = Date.parse("15-Oct-2004", "M-ddd-yyyy");

	// 15-Oct-2004
	var d1 = Date.parse("2004.10.15", "yyyy.MM.dd");

	// Multiple formats
	var d1 = Date.parseExact("10/15/2004", ["M/d/yyyy", "MMMM d, yyyy"]);
	
* * @param {String} The string value to convert into a Date object [Required]. * @param {Object} The expected format {String} or an array of expected formats {Array} of the date string [Required]. * @return {Date} A Date object or null if the string cannot be converted into a Date. */ $D.parseExact = function (s, fx) { return $D.getParseFunction(fx)(s); }; }()); (function () { var $D = Date, $P = $D.prototype, // $C = $D.CultureInfo, // not used atm p = function (s, l) { if (!l) { l = 2; } return ("000" + s).slice(l * -1); }; /** * Converts a PHP format string to Java/.NET format string. * A PHP format string can be used with ._format or .format. * A Java/.NET format string can be used with .toString(). * The .parseExact function will only accept a Java/.NET format string * * Example * var f1 = "%m/%d/%y" * var f2 = Date.normalizeFormat(f1); // "MM/dd/yy" * * new Date().format(f1); // "04/13/08" * new Date()._format(f1); // "04/13/08" * new Date().toString(f2); // "04/13/08" * * var date = Date.parseExact("04/13/08", f2); // Sun Apr 13 2008 * * @param {String} A PHP format string consisting of one or more format spcifiers. * @return {String} The PHP format converted to a Java/.NET format string. */ var normalizerSubstitutions = { "d" : "dd", "%d": "dd", "D" : "ddd", "%a": "ddd", "j" : "dddd", "l" : "dddd", "%A": "dddd", "S" : "S", "F" : "MMMM", "%B": "MMMM", "m" : "MM", "%m": "MM", "M" : "MMM", "%b": "MMM", "%h": "MMM", "n" : "M", "Y" : "yyyy", "%Y": "yyyy", "y" : "yy", "%y": "yy", "g" : "h", "%I": "h", "G" : "H", "h" : "hh", "H" : "HH", "%H": "HH", "i" : "mm", "%M": "mm", "s" : "ss", "%S": "ss", "%r": "hh:mm tt", "%R": "H:mm", "%T": "H:mm:ss", "%X": "t", "%x": "d", "%e": "d", "%D": "MM/dd/yy", "%n": "\\n", "%t": "\\t", "e" : "z", "T" : "z", "%z": "z", "%Z": "z", "Z" : "ZZ", "N" : "u", "w" : "u", "%w": "u", "W" : "W", "%V": "W" }; var normalizer = { substitutes: function (m) { return normalizerSubstitutions[m]; }, interpreted: function (m, x) { var y; switch (m) { case "%u": return x.getDay() + 1; case "z": return x.getOrdinalNumber(); case "%j": return p(x.getOrdinalNumber(), 3); case "%U": var d1 = x.clone().set({month: 0, day: 1}).addDays(-1).moveToDayOfWeek(0), d2 = x.clone().addDays(1).moveToDayOfWeek(0, -1); return (d2 < d1) ? "00" : p((d2.getOrdinalNumber() - d1.getOrdinalNumber()) / 7 + 1); case "%W": return p(x.getWeek()); case "t": return $D.getDaysInMonth(x.getFullYear(), x.getMonth()); case "o": case "%G": return x.setWeek(x.getISOWeek()).toString("yyyy"); case "%g": return x._format("%G").slice(-2); case "a": case "%p": return t("tt").toLowerCase(); case "A": return t("tt").toUpperCase(); case "u": return p(x.getMilliseconds(), 3); case "I": return (x.isDaylightSavingTime()) ? 1 : 0; case "O": return x.getUTCOffset(); case "P": y = x.getUTCOffset(); return y.substring(0, y.length - 2) + ":" + y.substring(y.length - 2); case "B": var now = new Date(); return Math.floor(((now.getHours() * 3600) + (now.getMinutes() * 60) + now.getSeconds() + (now.getTimezoneOffset() + 60) * 60) / 86.4); case "c": return x.toISOString().replace(/\"/g, ""); case "U": return $D.strtotime("now"); case "%c": return t("d") + " " + t("t"); case "%C": return Math.floor(x.getFullYear() / 100 + 1); } }, shouldOverrideDefaults: function (m) { switch (m) { case "%e": return true; default: return false; } }, parse: function (m, context) { var formatString, c = context || new Date(); formatString = normalizer.substitutes(m); if (formatString) { return formatString; } formatString = normalizer.interpreted(m, c); if (formatString) { return formatString; } else { return m; } } }; $D.normalizeFormat = function (format, context) { return format.replace(/(%|\\)?.|%%/g, function(t){ return normalizer.parse(t, context); }); }; /** * Format a local Unix timestamp according to locale settings * * Example: * Date.strftime("%m/%d/%y", new Date()); // "04/13/08" * Date.strftime("c", "2008-04-13T17:52:03Z"); // "04/13/08" * * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @param {Number|String} The number representing the number of seconds that have elapsed since January 1, 1970 (local time). * @return {String} A string representation of the current Date object. */ $D.strftime = function (format, time) { var d = Date.parse(time); return d._format(format); }; /** * Parse any textual datetime description into a Unix timestamp. * A Unix timestamp is the number of seconds that have elapsed since January 1, 1970 (midnight UTC/GMT). * * Example: * Date.strtotime("04/13/08"); // 1208044800 * Date.strtotime("1970-01-01T00:00:00Z"); // 0 * * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @param {Object} A string or date object. * @return {String} A string representation of the current Date object. */ $D.strtotime = function (time) { var d = $D.parse(time); return Math.round($D.UTC(d.getUTCFullYear(), d.getUTCMonth(), d.getUTCDate(), d.getUTCHours(), d.getUTCMinutes(), d.getUTCSeconds(), d.getUTCMilliseconds()) / 1000); }; /** * Converts the value of the current Date object to its equivalent string representation using a PHP/Unix style of date format specifiers. * Format Specifiers * Format Description Example * ------ --------------------------------------------------------------------------- ----------------------- * %a abbreviated weekday name according to the current localed "Mon" through "Sun" * %A full weekday name according to the current localed "Sunday" through "Saturday" * %b abbreviated month name according to the current localed "Jan" through "Dec" * %B full month name according to the current locale "January" through "December" * %c preferred date and time representation for the current locale "4/13/2008 12:33 PM" * %C century number (the year divided by 100 and truncated to an integer) "00" to "99" * %d day of the month as a decimal number "01" to "31" * %D same as %m/%d/%y "04/13/08" * %e day of the month as a decimal number, a single digit is preceded by a space "1" to "31" * %g like %G, but without the century "08" * %G The 4-digit year corresponding to the ISO week number (see %V). "2008" * This has the same format and value as %Y, except that if the ISO week number * belongs to the previous or next year, that year is used instead. * %h same as %b "Jan" through "Dec" * %H hour as a decimal number using a 24-hour clock. "00" to "23" * %I hour as a decimal number using a 12-hour clock. "01" to "12" * %j day of the year as a decimal number. "001" to "366" * %m month as a decimal number. "01" to "12" * %M minute as a decimal number. "00" to "59" * %n newline character "\n" * %p either "am" or "pm" according to the given time value, or the "am" or "pm" * corresponding strings for the current locale. * %r time in a.m. and p.m. notation "8:44 PM" * %R time in 24 hour notation "20:44" * %S second as a decimal number "00" to "59" * %t tab character "\t" * %T current time, equal to %H:%M:%S "12:49:11" * %u weekday as a decimal number ["1", "7"], with "1" representing Monday "1" to "7" * %U week number of the current year as a decimal number, starting with the "0" to ("52" or "53") * first Sunday as the first day of the first week * %V The ISO 8601:1988 week number of the current year as a decimal number, "00" to ("52" or "53") * range 01 to 53, where week 1 is the first week that has at least 4 days * in the current year, and with Monday as the first day of the week. * (Use %G or %g for the year component that corresponds to the week number * for the specified timestamp.) * %W week number of the current year as a decimal number, starting with the "00" to ("52" or "53") * first Monday as the first day of the first week * %w day of the week as a decimal, Sunday being "0" "0" to "6" * %x preferred date representation for the current locale without the time "4/13/2008" * %X preferred time representation for the current locale without the date "12:53:05" * %y year as a decimal number without a century "00" "99" * %Y year as a decimal number including the century "2008" * %Z time zone or name or abbreviation "UTC", "EST", "PST" * %z same as %Z * %% a literal "%" characters "%" * d Day of the month, 2 digits with leading zeros "01" to "31" * D A textual representation of a day, three letters "Mon" through "Sun" * j Day of the month without leading zeros "1" to "31" * l A full textual representation of the day of the week (lowercase "L") "Sunday" through "Saturday" * N ISO-8601 numeric representation of the day of the week (added in PHP 5.1.0) "1" (for Monday) through "7" (for Sunday) * S English ordinal suffix for the day of the month, 2 characters "st", "nd", "rd" or "th". Works well with j * w Numeric representation of the day of the week "0" (for Sunday) through "6" (for Saturday) * z The day of the year (starting from "0") "0" through "365" * W ISO-8601 week number of year, weeks starting on Monday "00" to ("52" or "53") * F A full textual representation of a month, such as January or March "January" through "December" * m Numeric representation of a month, with leading zeros "01" through "12" * M A short textual representation of a month, three letters "Jan" through "Dec" * n Numeric representation of a month, without leading zeros "1" through "12" * t Number of days in the given month "28" through "31" * L Whether it's a leap year "1" if it is a leap year, "0" otherwise * o ISO-8601 year number. This has the same value as Y, except that if the "2008" * ISO week number (W) belongs to the previous or next year, that year * is used instead. * Y A full numeric representation of a year, 4 digits "2008" * y A two digit representation of a year "08" * a Lowercase Ante meridiem and Post meridiem "am" or "pm" * A Uppercase Ante meridiem and Post meridiem "AM" or "PM" * B Swatch Internet time "000" through "999" * g 12-hour format of an hour without leading zeros "1" through "12" * G 24-hour format of an hour without leading zeros "0" through "23" * h 12-hour format of an hour with leading zeros "01" through "12" * H 24-hour format of an hour with leading zeros "00" through "23" * i Minutes with leading zeros "00" to "59" * s Seconds, with leading zeros "00" through "59" * u Milliseconds "54321" * e Timezone identifier "UTC", "EST", "PST" * I Whether or not the date is in daylight saving time (uppercase i) "1" if Daylight Saving Time, "0" otherwise * O Difference to Greenwich time (GMT) in hours "+0200", "-0600" * P Difference to Greenwich time (GMT) with colon between hours and minutes "+02:00", "-06:00" * T Timezone abbreviation "UTC", "EST", "PST" * Z Timezone offset in seconds. The offset for timezones west of UTC is "-43200" through "50400" * always negative, and for those east of UTC is always positive. * c ISO 8601 date "2004-02-12T15:19:21+00:00" * r RFC 2822 formatted date "Thu, 21 Dec 2000 16:01:07 +0200" * U Seconds since the Unix Epoch (January 1 1970 00:00:00 GMT) "0" * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @return {String} A string representation of the current Date object. */ var formatReplace = function (context) { return function (m) { var formatString, override = false; if (m.charAt(0) === "\\" || m.substring(0, 2) === "%%") { return m.replace("\\", "").replace("%%", "%"); } override = normalizer.shouldOverrideDefaults(m); formatString = $D.normalizeFormat(m, context); if (formatString) { return context.toString(formatString, override); } }; }; $P._format = function (format) { var formatter = formatReplace(this); if (!format) { return this._toString(); } else { return format.replace(/(%|\\)?.|%%/g, formatter); } }; if (!$P.format) { $P.format = $P._format; } }()); (function () { "use strict"; var gFn = function (attr) { return function () { return this[attr]; }; }; var sFn = function (attr) { return function (val) { this[attr] = val; return this; }; }; var attrs = ["years", "months", "days", "hours", "minutes", "seconds", "milliseconds"]; var addSetFuncs = function (context, attrs) { for (var i = 0; i < attrs.length ; i++) { var $a = attrs[i], $b = $a.slice(0, 1).toUpperCase() + $a.slice(1); context.prototype[$a] = 0; context.prototype["get" + $b] = gFn($a); context.prototype["set" + $b] = sFn($a); } }; /** * new TimeSpan(milliseconds); * new TimeSpan(days, hours, minutes, seconds); * new TimeSpan(days, hours, minutes, seconds, milliseconds); */ var TimeSpan = function (days, hours, minutes, seconds, milliseconds) { if (arguments.length === 1 && typeof days === "number") { var orient = (days < 0) ? -1 : +1; var millsLeft = Math.abs(days); this.setDays(Math.floor(millsLeft / 86400000) * orient); millsLeft = millsLeft % 86400000; this.setHours(Math.floor(millsLeft / 3600000) * orient); millsLeft = millsLeft % 3600000; this.setMinutes(Math.floor(millsLeft / 60000) * orient); millsLeft = millsLeft % 60000; this.setSeconds(Math.floor(millsLeft / 1000) * orient); millsLeft = millsLeft % 1000; this.setMilliseconds(millsLeft * orient); } else { this.set(days, hours, minutes, seconds, milliseconds); } this.getTotalMilliseconds = function () { return (this.getDays() * 86400000) + (this.getHours() * 3600000) + (this.getMinutes() * 60000) + (this.getSeconds() * 1000); }; this.compareTo = function (time) { var t1 = new Date(1970, 1, 1, this.getHours(), this.getMinutes(), this.getSeconds()), t2; if (time === null) { t2 = new Date(1970, 1, 1, 0, 0, 0); } else { t2 = new Date(1970, 1, 1, time.getHours(), time.getMinutes(), time.getSeconds()); } return (t1 < t2) ? -1 : (t1 > t2) ? 1 : 0; }; this.equals = function (time) { return (this.compareTo(time) === 0); }; this.add = function (time) { return (time === null) ? this : this.addSeconds(time.getTotalMilliseconds() / 1000); }; this.subtract = function (time) { return (time === null) ? this : this.addSeconds(-time.getTotalMilliseconds() / 1000); }; this.addDays = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 86400000)); }; this.addHours = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 3600000)); }; this.addMinutes = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 60000)); }; this.addSeconds = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 1000)); }; this.addMilliseconds = function (n) { return new TimeSpan(this.getTotalMilliseconds() + n); }; this.get12HourHour = function () { return (this.getHours() > 12) ? this.getHours() - 12 : (this.getHours() === 0) ? 12 : this.getHours(); }; this.getDesignator = function () { return (this.getHours() < 12) ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator; }; this.toString = function (format) { this._toString = function () { if (this.getDays() !== null && this.getDays() > 0) { return this.getDays() + "." + this.getHours() + ":" + this.p(this.getMinutes()) + ":" + this.p(this.getSeconds()); } else { return this.getHours() + ":" + this.p(this.getMinutes()) + ":" + this.p(this.getSeconds()); } }; this.p = function (s) { return (s.toString().length < 2) ? "0" + s : s; }; var me = this; return format ? format.replace(/dd?|HH?|hh?|mm?|ss?|tt?/g, function (format) { switch (format) { case "d": return me.getDays(); case "dd": return me.p(me.getDays()); case "H": return me.getHours(); case "HH": return me.p(me.getHours()); case "h": return me.get12HourHour(); case "hh": return me.p(me.get12HourHour()); case "m": return me.getMinutes(); case "mm": return me.p(me.getMinutes()); case "s": return me.getSeconds(); case "ss": return me.p(me.getSeconds()); case "t": return ((me.getHours() < 12) ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator).substring(0, 1); case "tt": return (me.getHours() < 12) ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator; } } ) : this._toString(); }; return this; }; addSetFuncs(TimeSpan, attrs.slice(2)); TimeSpan.prototype.set = function (days, hours, minutes, seconds, milliseconds){ this.setDays(days || this.getDays()); this.setHours(hours || this.getHours()); this.setMinutes(minutes || this.getMinutes()); this.setSeconds(seconds || this.getSeconds()); this.setMilliseconds(milliseconds || this.getMilliseconds()); }; /** * Gets the time of day for this date instances. * @return {TimeSpan} TimeSpan */ Date.prototype.getTimeOfDay = function () { return new TimeSpan(0, this.getHours(), this.getMinutes(), this.getSeconds(), this.getMilliseconds()); }; Date.TimeSpan = TimeSpan; if (typeof window !== "undefined" ) { // keeping API compatible for v1.x window.TimeSpan = TimeSpan; } }()); (function () { "use strict"; var attrs = ["years", "months", "days", "hours", "minutes", "seconds", "milliseconds"]; var gFn = function (attr) { return function () { return this[attr]; }; }; var sFn = function (attr) { return function (val) { this[attr] = val; return this; }; }; var addSetFuncs = function (context, attrs) { for (var i = 0; i < attrs.length ; i++) { var $a = attrs[i], $b = $a.slice(0, 1).toUpperCase() + $a.slice(1); context.prototype[$a] = 0; context.prototype["get" + $b] = gFn($a); context.prototype["set" + $b] = sFn($a); } }; var setMonthsAndYears = function (orient, d1, d2, context) { function inc() { d1.addMonths(-orient); context.months++; if (context.months === 12) { context.years++; context.months = 0; } } if (orient === +1) { while (d1 > d2) { inc(); } } else { while (d1 < d2) { inc(); } } context.months--; context.months *= orient; context.years *= orient; }; var adjustForDST = function(orient, startDate, endDate) { var hasDSTMismatch = (false === (startDate.isDaylightSavingTime() === endDate.isDaylightSavingTime())); if (hasDSTMismatch && orient === 1) { startDate.addHours(-1); } else if (hasDSTMismatch) { startDate.addHours(1); } }; /** * TimePeriod(startDate, endDate); * TimePeriod(years, months, days, hours, minutes, seconds, milliseconds); */ var TimePeriod = function (years, months, days, hours, minutes, seconds, milliseconds) { if (arguments.length === 7) { this.set(years, months, days, hours, minutes, seconds, milliseconds); } else if (arguments.length === 2 && arguments[0] instanceof Date && arguments[1] instanceof Date) { var startDate = arguments[0].clone(); var endDate = arguments[1].clone(); var orient = (startDate > endDate) ? +1 : -1; this.dates = { start: arguments[0].clone(), end: arguments[1].clone() }; setMonthsAndYears(orient, startDate, endDate, this); adjustForDST(orient, startDate, endDate); // // TODO - adjust for DST var diff = endDate - startDate; if (diff !== 0) { var ts = new TimeSpan(diff); this.set(this.years, this.months, ts.getDays(), ts.getHours(), ts.getMinutes(), ts.getSeconds(), ts.getMilliseconds()); } } return this; }; // create all the set functions. addSetFuncs(TimePeriod, attrs); TimePeriod.prototype.set = function (years, months, days, hours, minutes, seconds, milliseconds){ this.setYears(years || this.getYears()); this.setMonths(months || this.getMonths()); this.setDays(days || this.getDays()); this.setHours(hours || this.getHours()); this.setMinutes(minutes || this.getMinutes()); this.setSeconds(seconds || this.getSeconds()); this.setMilliseconds(milliseconds || this.getMilliseconds()); }; Date.TimePeriod = TimePeriod; if (typeof window !== "undefined") { // keeping API compatible for v1.x window.TimePeriod = TimePeriod; } }()); ================================================ FILE: build/date-it-IT.js ================================================ /** * @overview datejs * @version 1.0.0-rc3 * @author Gregory Wild-Smith * @copyright 2015 Gregory Wild-Smith * @license MIT * @homepage https://github.com/abritinthebay/datejs */ /* * DateJS Culture String File * Country Code: it-IT * Name: Italian (Italy) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["it-IT"] = { "name": "it-IT", "englishName": "Italian (Italy)", "nativeName": "italiano (Italia)", "Sunday": "domenica", "Monday": "lunedì", "Tuesday": "martedì", "Wednesday": "mercoledì", "Thursday": "giovedì", "Friday": "venerdì", "Saturday": "sabato", "Sun": "dom", "Mon": "lun", "Tue": "mar", "Wed": "mer", "Thu": "gio", "Fri": "ven", "Sat": "sab", "Su": "do", "Mo": "lu", "Tu": "ma", "We": "me", "Th": "gi", "Fr": "ve", "Sa": "sa", "S_Sun_Initial": "d", "M_Mon_Initial": "l", "T_Tue_Initial": "m", "W_Wed_Initial": "m", "T_Thu_Initial": "g", "F_Fri_Initial": "v", "S_Sat_Initial": "s", "January": "gennaio", "February": "febbraio", "March": "marzo", "April": "aprile", "May": "maggio", "June": "giugno", "July": "luglio", "August": "agosto", "September": "settembre", "October": "ottobre", "November": "novembre", "December": "dicembre", "Jan_Abbr": "gen", "Feb_Abbr": "feb", "Mar_Abbr": "mar", "Apr_Abbr": "apr", "May_Abbr": "mag", "Jun_Abbr": "giu", "Jul_Abbr": "lug", "Aug_Abbr": "ago", "Sep_Abbr": "set", "Oct_Abbr": "ott", "Nov_Abbr": "nov", "Dec_Abbr": "dic", "AM": "", "PM": "", "firstDayOfWeek": 1, "twoDigitYearMax": 2029, "mdy": "dmy", "M/d/yyyy": "dd/MM/yyyy", "dddd, MMMM dd, yyyy": "dddd d MMMM yyyy", "h:mm tt": "H.mm", "h:mm:ss tt": "H.mm.ss", "dddd, MMMM dd, yyyy h:mm:ss tt": "dddd d MMMM yyyy H.mm.ss", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "dd MMMM", "MMMM, yyyy": "MMMM yyyy", "/jan(uary)?/": "gen(naio)?", "/feb(ruary)?/": "feb(braio)?", "/mar(ch)?/": "mar(zo)?", "/apr(il)?/": "apr(ile)?", "/may/": "mag(gio)?", "/jun(e)?/": "giu(gno)?", "/jul(y)?/": "lug(lio)?", "/aug(ust)?/": "ago(sto)?", "/sep(t(ember)?)?/": "set(tembre)?", "/oct(ober)?/": "ott(obre)?", "/nov(ember)?/": "nov(embre)?", "/dec(ember)?/": "dic(embre)?", "/^su(n(day)?)?/": "^do(m(enica)?)?", "/^mo(n(day)?)?/": "^lu(n(edì)?)?", "/^tu(e(s(day)?)?)?/": "^ma(r(tedì)?)?", "/^we(d(nesday)?)?/": "^me(r(coledì)?)?", "/^th(u(r(s(day)?)?)?)?/": "^gi(o(vedì)?)?", "/^fr(i(day)?)?/": "^ve(n(erdì)?)?", "/^sa(t(urday)?)?/": "^sa(b(ato)?)?", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "it-IT"; /** * @overview datejs * @version 1.0.0-rc3 * @author Gregory Wild-Smith * @copyright 2015 Gregory Wild-Smith * @license MIT * @homepage https://github.com/abritinthebay/datejs */(function () { var $D = Date; var lang = Date.CultureStrings ? Date.CultureStrings.lang : null; var loggedKeys = {}; // for debug purposes. var getText = { getFromKey: function (key, countryCode) { var output; if (Date.CultureStrings && Date.CultureStrings[countryCode] && Date.CultureStrings[countryCode][key]) { output = Date.CultureStrings[countryCode][key]; } else { output = getText.buildFromDefault(key); } if (key.charAt(0) === "/") { // Assume it's a regex output = getText.buildFromRegex(key, countryCode); } return output; }, getFromObjectValues: function (obj, countryCode) { var key, output = {}; for(key in obj) { if (obj.hasOwnProperty(key)) { output[key] = getText.getFromKey(obj[key], countryCode); } } return output; }, getFromObjectKeys: function (obj, countryCode) { var key, output = {}; for(key in obj) { if (obj.hasOwnProperty(key)) { output[getText.getFromKey(key, countryCode)] = obj[key]; } } return output; }, getFromArray: function (arr, countryCode) { var output = []; for (var i=0; i < arr.length; i++){ if (i in arr) { output[i] = getText.getFromKey(arr[i], countryCode); } } return output; }, buildFromDefault: function (key) { var output, length, split, last; switch(key) { case "name": output = "en-US"; break; case "englishName": output = "English (United States)"; break; case "nativeName": output = "English (United States)"; break; case "twoDigitYearMax": output = 2049; break; case "firstDayOfWeek": output = 0; break; default: output = key; split = key.split("_"); length = split.length; if (length > 1 && key.charAt(0) !== "/") { // if the key isn't a regex and it has a split. last = split[(length - 1)].toLowerCase(); if (last === "initial" || last === "abbr") { output = split[0]; } } break; } return output; }, buildFromRegex: function (key, countryCode) { var output; if (Date.CultureStrings && Date.CultureStrings[countryCode] && Date.CultureStrings[countryCode][key]) { output = new RegExp(Date.CultureStrings[countryCode][key], "i"); } else { output = new RegExp(key.replace(new RegExp("/", "g"),""), "i"); } return output; } }; var shallowMerge = function (obj1, obj2) { for (var attrname in obj2) { if (obj2.hasOwnProperty(attrname)) { obj1[attrname] = obj2[attrname]; } } }; var __ = function (key, language) { var countryCode = (language) ? language : lang; loggedKeys[key] = key; if (typeof key === "object") { if (key instanceof Array) { return getText.getFromArray(key, countryCode); } else { return getText.getFromObjectKeys(key, countryCode); } } else { return getText.getFromKey(key, countryCode); } }; var loadI18nScript = function (code) { // paatterned after jQuery's getScript. var url = Date.Config.i18n + code + ".js"; var head = document.getElementsByTagName("head")[0] || document.documentElement; var script = document.createElement("script"); script.src = url; var completed = false; var events = { done: function (){} // placeholder function }; // Attach handlers for all browsers script.onload = script.onreadystatechange = function() { if ( !completed && (!this.readyState || this.readyState === "loaded" || this.readyState === "complete") ) { events.done(); head.removeChild(script); } }; setTimeout(function() { head.insertBefore(script, head.firstChild); }, 0); // allows return to execute first return { done: function (cb) { events.done = function() { if (cb) { setTimeout(cb,0); } }; } }; }; var buildInfo = { buildFromMethodHash: function (obj) { var key; for(key in obj) { if (obj.hasOwnProperty(key)) { obj[key] = buildInfo[obj[key]](); } } return obj; }, timeZoneDST: function () { var DST = { "CHADT": "+1345", "NZDT": "+1300", "AEDT": "+1100", "ACDT": "+1030", "AZST": "+0500", "IRDT": "+0430", "EEST": "+0300", "CEST": "+0200", "BST": "+0100", "PMDT": "-0200", "ADT": "-0300", "NDT": "-0230", "EDT": "-0400", "CDT": "-0500", "MDT": "-0600", "PDT": "-0700", "AKDT": "-0800", "HADT": "-0900" }; return __(DST); }, timeZoneStandard: function () { var standard = { "LINT": "+1400", "TOT": "+1300", "CHAST": "+1245", "NZST": "+1200", "NFT": "+1130", "SBT": "+1100", "AEST": "+1000", "ACST": "+0930", "JST": "+0900", "CWST": "+0845", "CT": "+0800", "ICT": "+0700", "MMT": "+0630", "BST": "+0600", "NPT": "+0545", "IST": "+0530", "PKT": "+0500", "AFT": "+0430", "MSK": "+0400", "IRST": "+0330", "FET": "+0300", "EET": "+0200", "CET": "+0100", "GMT": "+0000", "UTC": "+0000", "CVT": "-0100", "GST": "-0200", "BRT": "-0300", "NST": "-0330", "AST": "-0400", "EST": "-0500", "CST": "-0600", "MST": "-0700", "PST": "-0800", "AKST": "-0900", "MIT": "-0930", "HST": "-1000", "SST": "-1100", "BIT": "-1200" }; return __(standard); }, timeZones: function (data) { var zone; data.timezones = []; for (zone in data.abbreviatedTimeZoneStandard) { if (data.abbreviatedTimeZoneStandard.hasOwnProperty(zone)) { data.timezones.push({ name: zone, offset: data.abbreviatedTimeZoneStandard[zone]}); } } for (zone in data.abbreviatedTimeZoneDST) { if (data.abbreviatedTimeZoneDST.hasOwnProperty(zone)) { data.timezones.push({ name: zone, offset: data.abbreviatedTimeZoneDST[zone], dst: true}); } } return data.timezones; }, days: function () { return __(["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"]); }, dayAbbr: function () { return __(["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"]); }, dayShortNames: function () { return __(["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"]); }, dayFirstLetters: function () { return __(["S_Sun_Initial", "M_Mon_Initial", "T_Tues_Initial", "W_Wed_Initial", "T_Thu_Initial", "F_Fri_Initial", "S_Sat_Initial"]); }, months: function () { return __(["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"]); }, monthAbbr: function () { return __(["Jan_Abbr", "Feb_Abbr", "Mar_Abbr", "Apr_Abbr", "May_Abbr", "Jun_Abbr", "Jul_Abbr", "Aug_Abbr", "Sep_Abbr", "Oct_Abbr", "Nov_Abbr", "Dec_Abbr"]); }, formatPatterns: function () { return getText.getFromObjectValues({ shortDate: "M/d/yyyy", longDate: "dddd, MMMM dd, yyyy", shortTime: "h:mm tt", longTime: "h:mm:ss tt", fullDateTime: "dddd, MMMM dd, yyyy h:mm:ss tt", sortableDateTime: "yyyy-MM-ddTHH:mm:ss", universalSortableDateTime: "yyyy-MM-dd HH:mm:ssZ", rfc1123: "ddd, dd MMM yyyy HH:mm:ss", monthDay: "MMMM dd", yearMonth: "MMMM, yyyy" }, Date.i18n.currentLanguage()); }, regex: function () { return getText.getFromObjectValues({ inTheMorning: "/( in the )(morn(ing)?)\\b/", thisMorning: "/(this )(morn(ing)?)\\b/", amThisMorning: "/(\b\\d(am)? )(this )(morn(ing)?)/", inTheEvening: "/( in the )(even(ing)?)\\b/", thisEvening: "/(this )(even(ing)?)\\b/", pmThisEvening: "/(\b\\d(pm)? )(this )(even(ing)?)/", jan: "/jan(uary)?/", feb: "/feb(ruary)?/", mar: "/mar(ch)?/", apr: "/apr(il)?/", may: "/may/", jun: "/jun(e)?/", jul: "/jul(y)?/", aug: "/aug(ust)?/", sep: "/sep(t(ember)?)?/", oct: "/oct(ober)?/", nov: "/nov(ember)?/", dec: "/dec(ember)?/", sun: "/^su(n(day)?)?/", mon: "/^mo(n(day)?)?/", tue: "/^tu(e(s(day)?)?)?/", wed: "/^we(d(nesday)?)?/", thu: "/^th(u(r(s(day)?)?)?)?/", fri: "/fr(i(day)?)?/", sat: "/^sa(t(urday)?)?/", future: "/^next/", past: "/^last|past|prev(ious)?/", add: "/^(\\+|aft(er)?|from|hence)/", subtract: "/^(\\-|bef(ore)?|ago)/", yesterday: "/^yes(terday)?/", today: "/^t(od(ay)?)?/", tomorrow: "/^tom(orrow)?/", now: "/^n(ow)?/", millisecond: "/^ms|milli(second)?s?/", second: "/^sec(ond)?s?/", minute: "/^mn|min(ute)?s?/", hour: "/^h(our)?s?/", week: "/^w(eek)?s?/", month: "/^m(onth)?s?/", day: "/^d(ay)?s?/", year: "/^y(ear)?s?/", shortMeridian: "/^(a|p)/", longMeridian: "/^(a\\.?m?\\.?|p\\.?m?\\.?)/", timezone: "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/", ordinalSuffix: "/^\\s*(st|nd|rd|th)/", timeContext: "/^\\s*(\\:|a(?!u|p)|p)/" }, Date.i18n.currentLanguage()); } }; var CultureInfo = function () { var info = getText.getFromObjectValues({ name: "name", englishName: "englishName", nativeName: "nativeName", amDesignator: "AM", pmDesignator: "PM", firstDayOfWeek: "firstDayOfWeek", twoDigitYearMax: "twoDigitYearMax", dateElementOrder: "mdy" }, Date.i18n.currentLanguage()); var constructedInfo = buildInfo.buildFromMethodHash({ dayNames: "days", abbreviatedDayNames: "dayAbbr", shortestDayNames: "dayShortNames", firstLetterDayNames: "dayFirstLetters", monthNames: "months", abbreviatedMonthNames: "monthAbbr", formatPatterns: "formatPatterns", regexPatterns: "regex", abbreviatedTimeZoneDST: "timeZoneDST", abbreviatedTimeZoneStandard: "timeZoneStandard" }); shallowMerge(info, constructedInfo); buildInfo.timeZones(info); return info; }; $D.i18n = { __: function (key, lang) { return __(key, lang); }, currentLanguage: function () { return lang || "en-US"; }, setLanguage: function (code, force, cb) { var async = false; if (force || code === "en-US" || (!!Date.CultureStrings && !!Date.CultureStrings[code])) { lang = code; Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings.lang = code; Date.CultureInfo = new CultureInfo(); } else { if (!(!!Date.CultureStrings && !!Date.CultureStrings[code])) { if (typeof exports !== "undefined" && this.exports !== exports) { // we're in a Node enviroment, load it using require try { require("../i18n/" + code + ".js"); lang = code; Date.CultureStrings.lang = code; Date.CultureInfo = new CultureInfo(); } catch (e) { // var str = "The language for '" + code + "' could not be loaded by Node. It likely does not exist."; throw new Error("The DateJS IETF language tag '" + code + "' could not be loaded by Node. It likely does not exist."); } } else if (Date.Config && Date.Config.i18n) { // we know the location of the files, so lets load them async = true; loadI18nScript(code).done(function(){ lang = code; Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings.lang = code; Date.CultureInfo = new CultureInfo(); $D.Parsing.Normalizer.buildReplaceData(); // because this is async if ($D.Grammar) { $D.Grammar.buildGrammarFormats(); // so we can parse those strings... } if (cb) { setTimeout(cb,0); } }); } else { Date.console.error("The DateJS IETF language tag '" + code + "' is not available and has not been loaded."); return false; } } } $D.Parsing.Normalizer.buildReplaceData(); // rebuild normalizer strings if ($D.Grammar) { $D.Grammar.buildGrammarFormats(); // so we can parse those strings... } if (!async && cb) { setTimeout(cb,0); } }, getLoggedKeys: function () { return loggedKeys; }, updateCultureInfo: function () { Date.CultureInfo = new CultureInfo(); } }; $D.i18n.updateCultureInfo(); // run automatically }()); (function () { var $D = Date, $P = $D.prototype, p = function (s, l) { if (!l) { l = 2; } return ("000" + s).slice(l * -1); }; if (typeof window !== "undefined" && typeof window.console !== "undefined" && typeof window.console.log !== "undefined") { $D.console = console; // used only to raise non-critical errors if available } else { // set mock so we don't give errors. $D.console = { log: function(){}, error: function(){} }; } $D.Config = $D.Config || {}; $D.initOverloads = function() { /** * Overload of Date.now. Allows an alternate call for Date.now where it returns the * current Date as an object rather than just milliseconds since the Unix Epoch. * * Also provides an implementation of now() for browsers (IE<9) that don't have it. * * Backwards compatible so with work with either: * Date.now() [returns ms] * or * Date.now(true) [returns Date] */ if (!$D.now) { $D._now = function now() { return new Date().getTime(); }; } else if (!$D._now) { $D._now = $D.now; } $D.now = function (returnObj) { if (returnObj) { return $D.present(); } else { return $D._now(); } }; if ( !$P.toISOString ) { $P.toISOString = function() { return this.getUTCFullYear() + "-" + p(this.getUTCMonth() + 1) + "-" + p(this.getUTCDate()) + "T" + p(this.getUTCHours()) + ":" + p(this.getUTCMinutes()) + ":" + p(this.getUTCSeconds()) + "." + String( (this.getUTCMilliseconds()/1000).toFixed(3)).slice(2, 5) + "Z"; }; } // private if ( $P._toString === undefined ){ $P._toString = $P.toString; } }; $D.initOverloads(); /** * Gets a date that is set to the current date. The time is set to the start of the day (00:00 or 12:00 AM). * @return {Date} The current date. */ $D.today = function () { return new Date().clearTime(); }; /** * Gets a date that is set to the current date and time (same as new Date, but chainable) * @return {Date} The current date. */ $D.present = function () { return new Date(); }; /** * Compares the first date to the second date and returns an number indication of their relative values. * @param {Date} First Date object to compare [Required]. * @param {Date} Second Date object to compare to [Required]. * @return {Number} -1 = date1 is lessthan date2. 0 = values are equal. 1 = date1 is greaterthan date2. */ $D.compare = function (date1, date2) { if (isNaN(date1) || isNaN(date2)) { throw new Error(date1 + " - " + date2); } else if (date1 instanceof Date && date2 instanceof Date) { return (date1 < date2) ? -1 : (date1 > date2) ? 1 : 0; } else { throw new TypeError(date1 + " - " + date2); } }; /** * Compares the first Date object to the second Date object and returns true if they are equal. * @param {Date} First Date object to compare [Required] * @param {Date} Second Date object to compare to [Required] * @return {Boolean} true if dates are equal. false if they are not equal. */ $D.equals = function (date1, date2) { return (date1.compareTo(date2) === 0); }; /** * Gets the language appropriate day name when given the day number(0-6) * eg - 0 == Sunday * @return {String} The day name */ $D.getDayName = function (n) { return Date.CultureInfo.dayNames[n]; }; /** * Gets the day number (0-6) if given a CultureInfo specific string which is a valid dayName, abbreviatedDayName or shortestDayName (two char). * @param {String} The name of the day (eg. "Monday, "Mon", "tuesday", "tue", "We", "we"). * @return {Number} The day number */ $D.getDayNumberFromName = function (name) { var n = Date.CultureInfo.dayNames, m = Date.CultureInfo.abbreviatedDayNames, o = Date.CultureInfo.shortestDayNames, s = name.toLowerCase(); for (var i = 0; i < n.length; i++) { if (n[i].toLowerCase() === s || m[i].toLowerCase() === s || o[i].toLowerCase() === s) { return i; } } return -1; }; /** * Gets the month number (0-11) if given a Culture Info specific string which is a valid monthName or abbreviatedMonthName. * @param {String} The name of the month (eg. "February, "Feb", "october", "oct"). * @return {Number} The day number */ $D.getMonthNumberFromName = function (name) { var n = Date.CultureInfo.monthNames, m = Date.CultureInfo.abbreviatedMonthNames, s = name.toLowerCase(); for (var i = 0; i < n.length; i++) { if (n[i].toLowerCase() === s || m[i].toLowerCase() === s) { return i; } } return -1; }; /** * Gets the language appropriate month name when given the month number(0-11) * eg - 0 == January * @return {String} The month name */ $D.getMonthName = function (n) { return Date.CultureInfo.monthNames[n]; }; /** * Determines if the current date instance is within a LeapYear. * @param {Number} The year. * @return {Boolean} true if date is within a LeapYear, otherwise false. */ $D.isLeapYear = function (year) { return ((year % 4 === 0 && year % 100 !== 0) || year % 400 === 0); }; /** * Gets the number of days in the month, given a year and month value. Automatically corrects for LeapYear. * @param {Number} The year. * @param {Number} The month (0-11). * @return {Number} The number of days in the month. */ $D.getDaysInMonth = function (year, month) { if (!month && $D.validateMonth(year)) { month = year; year = Date.today().getFullYear(); } return [31, ($D.isLeapYear(year) ? 29 : 28), 31, 30, 31, 30, 31, 31, 30, 31, 30, 31][month]; }; $P.getDaysInMonth = function () { return $D.getDaysInMonth(this.getFullYear(), this.getMonth()); }; $D.getTimezoneAbbreviation = function (offset, dst) { var p, n = (dst || false) ? Date.CultureInfo.abbreviatedTimeZoneDST : Date.CultureInfo.abbreviatedTimeZoneStandard; for (p in n) { if (n.hasOwnProperty(p)) { if (n[p] === offset) { return p; } } } return null; }; $D.getTimezoneOffset = function (name, dst) { var i, a =[], z = Date.CultureInfo.timezones; if (!name) { name = (new Date()).getTimezone();} for (i = 0; i < z.length; i++) { if (z[i].name === name.toUpperCase()) { a.push(i); } } if (!z[a[0]]) { return null; } if (a.length === 1 || !dst) { return z[a[0]].offset; } else { for (i=0; i < a.length; i++) { if (z[a[i]].dst) { return z[a[i]].offset; } } } }; $D.getQuarter = function (d) { d = d || new Date(); // If no date supplied, use today var q = [1,2,3,4]; return q[Math.floor(d.getMonth() / 3)]; // ~~~ is a bitwise op. Faster than Math.floor }; $D.getDaysLeftInQuarter = function (d) { d = d || new Date(); var qEnd = new Date(d); qEnd.setMonth(qEnd.getMonth() + 3 - qEnd.getMonth() % 3, 0); return Math.floor((qEnd - d) / 8.64e7); }; // private var validate = function (n, min, max, name) { name = name ? name : "Object"; if (typeof n === "undefined") { return false; } else if (typeof n !== "number") { throw new TypeError(n + " is not a Number."); } else if (n < min || n > max) { // As failing validation is *not* an exceptional circumstance // lets not throw a RangeError Exception here. // It's semantically correct but it's not sensible. return false; } return true; }; /** * Validates the number is within an acceptable range for milliseconds [0-999]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateMillisecond = function (value) { return validate(value, 0, 999, "millisecond"); }; /** * Validates the number is within an acceptable range for seconds [0-59]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateSecond = function (value) { return validate(value, 0, 59, "second"); }; /** * Validates the number is within an acceptable range for minutes [0-59]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateMinute = function (value) { return validate(value, 0, 59, "minute"); }; /** * Validates the number is within an acceptable range for hours [0-23]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateHour = function (value) { return validate(value, 0, 23, "hour"); }; /** * Validates the number is within an acceptable range for the days in a month [0-MaxDaysInMonth]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateDay = function (value, year, month) { if (year === undefined || year === null || month === undefined || month === null) { return false;} return validate(value, 1, $D.getDaysInMonth(year, month), "day"); }; /** * Validates the number is within an acceptable range for months [0-11]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateWeek = function (value) { return validate(value, 0, 53, "week"); }; /** * Validates the number is within an acceptable range for months [0-11]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateMonth = function (value) { return validate(value, 0, 11, "month"); }; /** * Validates the number is within an acceptable range for years. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateYear = function (value) { /** * Per ECMAScript spec the range of times supported by Date objects is * exactly -100,000,000 days to +100,000,000 days measured relative to * midnight at the beginning of 01 January, 1970 UTC. * This gives a range of 8,640,000,000,000,000 milliseconds to either * side of 01 January, 1970 UTC. * * Earliest possible date: Tue, 20 Apr 271,822 B.C. 00:00:00 UTC * Latest possible date: Sat, 13 Sep 275,760 00:00:00 UTC */ return validate(value, -271822, 275760, "year"); }; $D.validateTimezone = function(value) { var timezones = {"ACDT":1,"ACST":1,"ACT":1,"ADT":1,"AEDT":1,"AEST":1,"AFT":1,"AKDT":1,"AKST":1,"AMST":1,"AMT":1,"ART":1,"AST":1,"AWDT":1,"AWST":1,"AZOST":1,"AZT":1,"BDT":1,"BIOT":1,"BIT":1,"BOT":1,"BRT":1,"BST":1,"BTT":1,"CAT":1,"CCT":1,"CDT":1,"CEDT":1,"CEST":1,"CET":1,"CHADT":1,"CHAST":1,"CHOT":1,"ChST":1,"CHUT":1,"CIST":1,"CIT":1,"CKT":1,"CLST":1,"CLT":1,"COST":1,"COT":1,"CST":1,"CT":1,"CVT":1,"CWST":1,"CXT":1,"DAVT":1,"DDUT":1,"DFT":1,"EASST":1,"EAST":1,"EAT":1,"ECT":1,"EDT":1,"EEDT":1,"EEST":1,"EET":1,"EGST":1,"EGT":1,"EIT":1,"EST":1,"FET":1,"FJT":1,"FKST":1,"FKT":1,"FNT":1,"GALT":1,"GAMT":1,"GET":1,"GFT":1,"GILT":1,"GIT":1,"GMT":1,"GST":1,"GYT":1,"HADT":1,"HAEC":1,"HAST":1,"HKT":1,"HMT":1,"HOVT":1,"HST":1,"ICT":1,"IDT":1,"IOT":1,"IRDT":1,"IRKT":1,"IRST":1,"IST":1,"JST":1,"KGT":1,"KOST":1,"KRAT":1,"KST":1,"LHST":1,"LINT":1,"MAGT":1,"MART":1,"MAWT":1,"MDT":1,"MET":1,"MEST":1,"MHT":1,"MIST":1,"MIT":1,"MMT":1,"MSK":1,"MST":1,"MUT":1,"MVT":1,"MYT":1,"NCT":1,"NDT":1,"NFT":1,"NPT":1,"NST":1,"NT":1,"NUT":1,"NZDT":1,"NZST":1,"OMST":1,"ORAT":1,"PDT":1,"PET":1,"PETT":1,"PGT":1,"PHOT":1,"PHT":1,"PKT":1,"PMDT":1,"PMST":1,"PONT":1,"PST":1,"PYST":1,"PYT":1,"RET":1,"ROTT":1,"SAKT":1,"SAMT":1,"SAST":1,"SBT":1,"SCT":1,"SGT":1,"SLST":1,"SRT":1,"SST":1,"SYOT":1,"TAHT":1,"THA":1,"TFT":1,"TJT":1,"TKT":1,"TLT":1,"TMT":1,"TOT":1,"TVT":1,"UCT":1,"ULAT":1,"UTC":1,"UYST":1,"UYT":1,"UZT":1,"VET":1,"VLAT":1,"VOLT":1,"VOST":1,"VUT":1,"WAKT":1,"WAST":1,"WAT":1,"WEDT":1,"WEST":1,"WET":1,"WST":1,"YAKT":1,"YEKT":1,"Z":1}; return (timezones[value] === 1); }; $D.validateTimezoneOffset= function(value) { // timezones go from +14hrs to -12hrs, the +X hours are negative offsets. return (value > -841 && value < 721); }; }()); (function () { var $D = Date, $P = $D.prototype, p = function (s, l) { if (!l) { l = 2; } return ("000" + s).slice(l * -1); }; var validateConfigObject = function (obj) { var result = {}, self = this, prop, testFunc; testFunc = function (prop, func, value) { if (prop === "day") { var month = (obj.month !== undefined) ? obj.month : self.getMonth(); var year = (obj.year !== undefined) ? obj.year : self.getFullYear(); return $D[func](value, year, month); } else { return $D[func](value); } }; for (prop in obj) { if (Object.prototype.hasOwnProperty.call(obj, prop)) { var func = "validate" + prop.charAt(0).toUpperCase() + prop.slice(1); if ($D[func] && obj[prop] !== null && testFunc(prop, func, obj[prop])) { result[prop] = obj[prop]; } } } return result; }; /** * Resets the time of this Date object to 12:00 AM (00:00), which is the start of the day. * @param {Boolean} .clone() this date instance before clearing Time * @return {Date} this */ $P.clearTime = function () { this.setHours(0); this.setMinutes(0); this.setSeconds(0); this.setMilliseconds(0); return this; }; /** * Resets the time of this Date object to the current time ('now'). * @return {Date} this */ $P.setTimeToNow = function () { var n = new Date(); this.setHours(n.getHours()); this.setMinutes(n.getMinutes()); this.setSeconds(n.getSeconds()); this.setMilliseconds(n.getMilliseconds()); return this; }; /** * Returns a new Date object that is an exact date and time copy of the original instance. * @return {Date} A new Date instance */ $P.clone = function () { return new Date(this.getTime()); }; /** * Compares this instance to a Date object and returns an number indication of their relative values. * @param {Date} Date object to compare [Required] * @return {Number} -1 = this is lessthan date. 0 = values are equal. 1 = this is greaterthan date. */ $P.compareTo = function (date) { return Date.compare(this, date); }; /** * Compares this instance to another Date object and returns true if they are equal. * @param {Date} Date object to compare. If no date to compare, new Date() [now] is used. * @return {Boolean} true if dates are equal. false if they are not equal. */ $P.equals = function (date) { return Date.equals(this, (date !== undefined ? date : new Date())); }; /** * Determines if this instance is between a range of two dates or equal to either the start or end dates. * @param {Date} Start of range [Required] * @param {Date} End of range [Required] * @return {Boolean} true is this is between or equal to the start and end dates, else false */ $P.between = function (start, end) { return this.getTime() >= start.getTime() && this.getTime() <= end.getTime(); }; /** * Determines if this date occurs after the date to compare to. * @param {Date} Date object to compare. If no date to compare, new Date() ("now") is used. * @return {Boolean} true if this date instance is greater than the date to compare to (or "now"), otherwise false. */ $P.isAfter = function (date) { return this.compareTo(date || new Date()) === 1; }; /** * Determines if this date occurs before the date to compare to. * @param {Date} Date object to compare. If no date to compare, new Date() ("now") is used. * @return {Boolean} true if this date instance is less than the date to compare to (or "now"). */ $P.isBefore = function (date) { return (this.compareTo(date || new Date()) === -1); }; /** * Determines if the current Date instance occurs today. * @return {Boolean} true if this date instance is 'today', otherwise false. */ /** * Determines if the current Date instance occurs on the same Date as the supplied 'date'. * If no 'date' to compare to is provided, the current Date instance is compared to 'today'. * @param {date} Date object to compare. If no date to compare, the current Date ("now") is used. * @return {Boolean} true if this Date instance occurs on the same Day as the supplied 'date'. */ $P.isToday = $P.isSameDay = function (date) { return this.clone().clearTime().equals((date || new Date()).clone().clearTime()); }; /** * Adds the specified number of milliseconds to this instance. * @param {Number} The number of milliseconds to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addMilliseconds = function (value) { if (!value) { return this; } this.setTime(this.getTime() + value * 1); return this; }; /** * Adds the specified number of seconds to this instance. * @param {Number} The number of seconds to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addSeconds = function (value) { if (!value) { return this; } return this.addMilliseconds(value * 1000); }; /** * Adds the specified number of seconds to this instance. * @param {Number} The number of seconds to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addMinutes = function (value) { if (!value) { return this; } return this.addMilliseconds(value * 60000); // 60*1000 }; /** * Adds the specified number of hours to this instance. * @param {Number} The number of hours to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addHours = function (value) { if (!value) { return this; } return this.addMilliseconds(value * 3600000); // 60*60*1000 }; /** * Adds the specified number of days to this instance. * @param {Number} The number of days to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addDays = function (value) { if (!value) { return this; } this.setDate(this.getDate() + value * 1); return this; }; /** * Adds the specified number of weekdays (ie - not sat or sun) to this instance. * @param {Number} The number of days to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addWeekdays = function (value) { if (!value) { return this; } var day = this.getDay(); var weeks = (Math.ceil(Math.abs(value)/7)); if (day === 0 || day === 6) { if (value > 0) { this.next().monday(); this.addDays(-1); day = this.getDay(); } } if (value < 0) { while (value < 0) { this.addDays(-1); day = this.getDay(); if (day !== 0 && day !== 6) { value++; } } return this; } else if (value > 5 || (6-day) <= value) { value = value + (weeks * 2); } return this.addDays(value); }; /** * Adds the specified number of weeks to this instance. * @param {Number} The number of weeks to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addWeeks = function (value) { if (!value) { return this; } return this.addDays(value * 7); }; /** * Adds the specified number of months to this instance. * @param {Number} The number of months to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addMonths = function (value) { if (!value) { return this; } var n = this.getDate(); this.setDate(1); this.setMonth(this.getMonth() + value * 1); this.setDate(Math.min(n, $D.getDaysInMonth(this.getFullYear(), this.getMonth()))); return this; }; $P.addQuarters = function (value) { if (!value) { return this; } // note this will take you to the same point in the quarter as you are now. // i.e. - if you are 15 days into the quarter you'll be 15 days into the resulting one. // bonus: this allows adding fractional quarters return this.addMonths(value * 3); }; /** * Adds the specified number of years to this instance. * @param {Number} The number of years to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addYears = function (value) { if (!value) { return this; } return this.addMonths(value * 12); }; /** * Adds (or subtracts) to the value of the years, months, weeks, days, hours, minutes, seconds, milliseconds of the date instance using given configuration object. Positive and Negative values allowed. * Example

	Date.today().add( { days: 1, months: 1 } )

	new Date().add( { years: -1 } )
	
* @param {Object} Configuration object containing attributes (months, days, etc.) * @return {Date} this */ $P.add = function (config) { if (typeof config === "number") { this._orient = config; return this; } var x = config; if (x.day) { // If we should be a different date than today (eg: for 'tomorrow -1d', etc). // Should only effect parsing, not direct usage (eg, Finish and FinishExact) if ((x.day - this.getDate()) !== 0) { this.setDate(x.day); } } if (x.milliseconds) { this.addMilliseconds(x.milliseconds); } if (x.seconds) { this.addSeconds(x.seconds); } if (x.minutes) { this.addMinutes(x.minutes); } if (x.hours) { this.addHours(x.hours); } if (x.weeks) { this.addWeeks(x.weeks); } if (x.months) { this.addMonths(x.months); } if (x.years) { this.addYears(x.years); } if (x.days) { this.addDays(x.days); } return this; }; /** * Get the week number. Week one (1) is the week which contains the first Thursday of the year. Monday is considered the first day of the week. * The .getWeek() function does NOT convert the date to UTC. The local datetime is used. * Please use .getISOWeek() to get the week of the UTC converted date. * @return {Number} 1 to 53 */ $P.getWeek = function (utc) { // Create a copy of this date object var self, target = new Date(this.valueOf()); if (utc) { target.addMinutes(target.getTimezoneOffset()); self = target.clone(); } else { self = this; } // ISO week date weeks start on monday // so correct the day number var dayNr = (self.getDay() + 6) % 7; // ISO 8601 states that week 1 is the week // with the first thursday of that year. // Set the target date to the thursday in the target week target.setDate(target.getDate() - dayNr + 3); // Store the millisecond value of the target date var firstThursday = target.valueOf(); // Set the target to the first thursday of the year // First set the target to january first target.setMonth(0, 1); // Not a thursday? Correct the date to the next thursday if (target.getDay() !== 4) { target.setMonth(0, 1 + ((4 - target.getDay()) + 7) % 7); } // The weeknumber is the number of weeks between the // first thursday of the year and the thursday in the target week return 1 + Math.ceil((firstThursday - target) / 604800000); // 604800000 = 7 * 24 * 3600 * 1000 }; /** * Get the ISO 8601 week number. Week one ("01") is the week which contains the first Thursday of the year. Monday is considered the first day of the week. * The .getISOWeek() function does convert the date to it's UTC value. Please use .getWeek() to get the week of the local date. * @return {String} "01" to "53" */ $P.getISOWeek = function () { return p(this.getWeek(true)); }; /** * Moves the date to Monday of the week set. Week one (1) is the week which contains the first Thursday of the year. * @param {Number} A Number (1 to 53) that represents the week of the year. * @return {Date} this */ $P.setWeek = function (n) { if ((n - this.getWeek()) === 0) { if (this.getDay() !== 1) { return this.moveToDayOfWeek(1, (this.getDay() > 1 ? -1 : 1)); } else { return this; } } else { return this.moveToDayOfWeek(1, (this.getDay() > 1 ? -1 : 1)).addWeeks(n - this.getWeek()); } }; $P.setQuarter = function (qtr) { var month = Math.abs(((qtr-1) * 3) + 1); return this.setMonth(month, 1); }; $P.getQuarter = function () { return Date.getQuarter(this); }; $P.getDaysLeftInQuarter = function () { return Date.getDaysLeftInQuarter(this); }; /** * Moves the date to the next n'th occurrence of the dayOfWeek starting from the beginning of the month. The number (-1) is a magic number and will return the last occurrence of the dayOfWeek in the month. * @param {Number} The dayOfWeek to move to * @param {Number} The n'th occurrence to move to. Use (-1) to return the last occurrence in the month * @return {Date} this */ $P.moveToNthOccurrence = function (dayOfWeek, occurrence) { if (dayOfWeek === "Weekday") { if (occurrence > 0) { this.moveToFirstDayOfMonth(); if (this.is().weekday()) { occurrence -= 1; } } else if (occurrence < 0) { this.moveToLastDayOfMonth(); if (this.is().weekday()) { occurrence += 1; } } else { return this; } return this.addWeekdays(occurrence); } var shift = 0; if (occurrence > 0) { shift = occurrence - 1; } else if (occurrence === -1) { this.moveToLastDayOfMonth(); if (this.getDay() !== dayOfWeek) { this.moveToDayOfWeek(dayOfWeek, -1); } return this; } return this.moveToFirstDayOfMonth().addDays(-1).moveToDayOfWeek(dayOfWeek, +1).addWeeks(shift); }; var moveToN = function (getFunc, addFunc, nVal) { return function (value, orient) { var diff = (value - this[getFunc]() + nVal * (orient || +1)) % nVal; return this[addFunc]((diff === 0) ? diff += nVal * (orient || +1) : diff); }; }; /** * Move to the next or last dayOfWeek based on the orient value. * @param {Number} The dayOfWeek to move to * @param {Number} Forward (+1) or Back (-1). Defaults to +1. [Optional] * @return {Date} this */ $P.moveToDayOfWeek = moveToN("getDay", "addDays", 7); /** * Move to the next or last month based on the orient value. * @param {Number} The month to move to. 0 = January, 11 = December * @param {Number} Forward (+1) or Back (-1). Defaults to +1. [Optional] * @return {Date} this */ $P.moveToMonth = moveToN("getMonth", "addMonths", 12); /** * Get the Ordinate of the current day ("th", "st", "rd"). * @return {String} */ $P.getOrdinate = function () { var num = this.getDate(); return ord(num); }; /** * Get the Ordinal day (numeric day number) of the year, adjusted for leap year. * @return {Number} 1 through 365 (366 in leap years) */ $P.getOrdinalNumber = function () { return Math.ceil((this.clone().clearTime() - new Date(this.getFullYear(), 0, 1)) / 86400000) + 1; }; /** * Get the time zone abbreviation of the current date. * @return {String} The abbreviated time zone name (e.g. "EST") */ $P.getTimezone = function () { return $D.getTimezoneAbbreviation(this.getUTCOffset(), this.isDaylightSavingTime()); }; $P.setTimezoneOffset = function (offset) { var here = this.getTimezoneOffset(), there = Number(offset) * -6 / 10; return (there || there === 0) ? this.addMinutes(there - here) : this; }; $P.setTimezone = function (offset) { return this.setTimezoneOffset($D.getTimezoneOffset(offset)); }; /** * Indicates whether Daylight Saving Time is observed in the current time zone. * @return {Boolean} true|false */ $P.hasDaylightSavingTime = function () { return (Date.today().set({month: 0, day: 1}).getTimezoneOffset() !== Date.today().set({month: 6, day: 1}).getTimezoneOffset()); }; /** * Indicates whether this Date instance is within the Daylight Saving Time range for the current time zone. * @return {Boolean} true|false */ $P.isDaylightSavingTime = function () { return Date.today().set({month: 0, day: 1}).getTimezoneOffset() !== this.getTimezoneOffset(); }; /** * Get the offset from UTC of the current date. * @return {String} The 4-character offset string prefixed with + or - (e.g. "-0500") */ $P.getUTCOffset = function (offset) { var n = (offset || this.getTimezoneOffset()) * -10 / 6, r; if (n < 0) { r = (n - 10000).toString(); return r.charAt(0) + r.substr(2); } else { r = (n + 10000).toString(); return "+" + r.substr(1); } }; /** * Returns the number of milliseconds between this date and date. * @param {Date} Defaults to now * @return {Number} The diff in milliseconds */ $P.getElapsed = function (date) { return (date || new Date()) - this; }; /** * Set the value of year, month, day, hour, minute, second, millisecond of date instance using given configuration object. * Example

	Date.today().set( { day: 20, month: 1 } )

	new Date().set( { millisecond: 0 } )
	
* * @param {Object} Configuration object containing attributes (month, day, etc.) * @return {Date} this */ $P.set = function (config) { config = validateConfigObject.call(this, config); var key; for (key in config) { if (Object.prototype.hasOwnProperty.call(config, key)) { var name = key.charAt(0).toUpperCase() + key.slice(1); var addFunc, getFunc; if (key !== "week" && key !== "month" && key !== "timezone" && key !== "timezoneOffset") { name += "s"; } addFunc = "add" + name; getFunc = "get" + name; if (key === "month") { addFunc = addFunc + "s"; } else if (key === "year"){ getFunc = "getFullYear"; } if (key !== "day" && key !== "timezone" && key !== "timezoneOffset" && key !== "week" && key !== "hour") { this[addFunc](config[key] - this[getFunc]()); } else if ( key === "timezone"|| key === "timezoneOffset" || key === "week" || key === "hour") { this["set"+name](config[key]); } } } // day has to go last because you can't validate the day without first knowing the month if (config.day) { this.addDays(config.day - this.getDate()); } return this; }; /** * Moves the date to the first day of the month. * @return {Date} this */ $P.moveToFirstDayOfMonth = function () { return this.set({ day: 1 }); }; /** * Moves the date to the last day of the month. * @return {Date} this */ $P.moveToLastDayOfMonth = function () { return this.set({ day: $D.getDaysInMonth(this.getFullYear(), this.getMonth())}); }; /** * Converts the value of the current Date object to its equivalent string representation. * Format Specifiers * CUSTOM DATE AND TIME FORMAT STRINGS * Format Description Example * ------ --------------------------------------------------------------------------- ----------------------- * s The seconds of the minute between 0-59. "0" to "59" * ss The seconds of the minute with leading zero if required. "00" to "59" * * m The minute of the hour between 0-59. "0" or "59" * mm The minute of the hour with leading zero if required. "00" or "59" * * h The hour of the day between 1-12. "1" to "12" * hh The hour of the day with leading zero if required. "01" to "12" * * H The hour of the day between 0-23. "0" to "23" * HH The hour of the day with leading zero if required. "00" to "23" * * d The day of the month between 1 and 31. "1" to "31" * dd The day of the month with leading zero if required. "01" to "31" * ddd Abbreviated day name. Date.CultureInfo.abbreviatedDayNames. "Mon" to "Sun" * dddd The full day name. Date.CultureInfo.dayNames. "Monday" to "Sunday" * * M The month of the year between 1-12. "1" to "12" * MM The month of the year with leading zero if required. "01" to "12" * MMM Abbreviated month name. Date.CultureInfo.abbreviatedMonthNames. "Jan" to "Dec" * MMMM The full month name. Date.CultureInfo.monthNames. "January" to "December" * * yy The year as a two-digit number. "99" or "08" * yyyy The full four digit year. "1999" or "2008" * * t Displays the first character of the A.M./P.M. designator. "A" or "P" * Date.CultureInfo.amDesignator or Date.CultureInfo.pmDesignator * tt Displays the A.M./P.M. designator. "AM" or "PM" * Date.CultureInfo.amDesignator or Date.CultureInfo.pmDesignator * * S The ordinal suffix ("st, "nd", "rd" or "th") of the current day. "st, "nd", "rd" or "th" * * STANDARD DATE AND TIME FORMAT STRINGS * Format Description Example *------ --------------------------------------------------------------------------- ----------------------- * d The CultureInfo shortDate Format Pattern "M/d/yyyy" * D The CultureInfo longDate Format Pattern "dddd, MMMM dd, yyyy" * F The CultureInfo fullDateTime Format Pattern "dddd, MMMM dd, yyyy h:mm:ss tt" * m The CultureInfo monthDay Format Pattern "MMMM dd" * r The CultureInfo rfc1123 Format Pattern "ddd, dd MMM yyyy HH:mm:ss GMT" * s The CultureInfo sortableDateTime Format Pattern "yyyy-MM-ddTHH:mm:ss" * t The CultureInfo shortTime Format Pattern "h:mm tt" * T The CultureInfo longTime Format Pattern "h:mm:ss tt" * u The CultureInfo universalSortableDateTime Format Pattern "yyyy-MM-dd HH:mm:ssZ" * y The CultureInfo yearMonth Format Pattern "MMMM, yyyy" * * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @return {String} A string representation of the current Date object. */ var ord = function (n) { switch (n * 1) { case 1: case 21: case 31: return "st"; case 2: case 22: return "nd"; case 3: case 23: return "rd"; default: return "th"; } }; var parseStandardFormats = function (format) { var y, c = Date.CultureInfo.formatPatterns; switch (format) { case "d": return this.toString(c.shortDate); case "D": return this.toString(c.longDate); case "F": return this.toString(c.fullDateTime); case "m": return this.toString(c.monthDay); case "r": case "R": y = this.clone().addMinutes(this.getTimezoneOffset()); return y.toString(c.rfc1123) + " GMT"; case "s": return this.toString(c.sortableDateTime); case "t": return this.toString(c.shortTime); case "T": return this.toString(c.longTime); case "u": y = this.clone().addMinutes(this.getTimezoneOffset()); return y.toString(c.universalSortableDateTime); case "y": return this.toString(c.yearMonth); default: return false; } }; var parseFormatStringsClosure = function (context) { return function (m) { if (m.charAt(0) === "\\") { return m.replace("\\", ""); } switch (m) { case "hh": return p(context.getHours() < 13 ? (context.getHours() === 0 ? 12 : context.getHours()) : (context.getHours() - 12)); case "h": return context.getHours() < 13 ? (context.getHours() === 0 ? 12 : context.getHours()) : (context.getHours() - 12); case "HH": return p(context.getHours()); case "H": return context.getHours(); case "mm": return p(context.getMinutes()); case "m": return context.getMinutes(); case "ss": return p(context.getSeconds()); case "s": return context.getSeconds(); case "yyyy": return p(context.getFullYear(), 4); case "yy": return p(context.getFullYear()); case "y": return context.getFullYear(); case "E": case "dddd": return Date.CultureInfo.dayNames[context.getDay()]; case "ddd": return Date.CultureInfo.abbreviatedDayNames[context.getDay()]; case "dd": return p(context.getDate()); case "d": return context.getDate(); case "MMMM": return Date.CultureInfo.monthNames[context.getMonth()]; case "MMM": return Date.CultureInfo.abbreviatedMonthNames[context.getMonth()]; case "MM": return p((context.getMonth() + 1)); case "M": return context.getMonth() + 1; case "t": return context.getHours() < 12 ? Date.CultureInfo.amDesignator.substring(0, 1) : Date.CultureInfo.pmDesignator.substring(0, 1); case "tt": return context.getHours() < 12 ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator; case "S": return ord(context.getDate()); case "W": return context.getWeek(); case "WW": return context.getISOWeek(); case "Q": return "Q" + context.getQuarter(); case "q": return String(context.getQuarter()); case "z": return context.getTimezone(); case "Z": case "X": return Date.getTimezoneOffset(context.getTimezone()); case "ZZ": // Timezone offset in seconds return context.getTimezoneOffset() * -60; case "u": return context.getDay(); case "L": return ($D.isLeapYear(context.getFullYear())) ? 1 : 0; case "B": // Swatch Internet Time (.beats) return "@"+((context.getUTCSeconds() + (context.getUTCMinutes()*60) + ((context.getUTCHours()+1)*3600))/86.4); default: return m; } }; }; $P.toString = function (format, ignoreStandards) { // Standard Date and Time Format Strings. Formats pulled from CultureInfo file and // may vary by culture. if (!ignoreStandards && format && format.length === 1) { output = parseStandardFormats.call(this, format); if (output) { return output; } } var parseFormatStrings = parseFormatStringsClosure(this); return format ? format.replace(/((\\)?(dd?d?d?|MM?M?M?|yy?y?y?|hh?|HH?|mm?|ss?|tt?|S|q|Q|WW?W?W?)(?![^\[]*\]))/g, parseFormatStrings).replace(/\[|\]/g, "") : this._toString(); }; }()); /************************************************************* * SugarPak - Domain Specific Language - Syntactical Sugar * *************************************************************/ (function () { var $D = Date, $P = $D.prototype, $N = Number.prototype; // private $P._orient = +1; // private $P._nth = null; // private $P._is = false; // private $P._same = false; // private $P._isSecond = false; // private $N._dateElement = "days"; /** * Moves the date to the next instance of a date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.today().next().friday();
	Date.today().next().fri();
	Date.today().next().march();
	Date.today().next().mar();
	Date.today().next().week();
	
* * @return {Date} date */ $P.next = function () { this._move = true; this._orient = +1; return this; }; /** * Creates a new Date (Date.today()) and moves the date to the next instance of the date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.next().friday();
	Date.next().fri();
	Date.next().march();
	Date.next().mar();
	Date.next().week();
	
* * @return {Date} date */ $D.next = function () { return $D.today().next(); }; /** * Moves the date to the previous instance of a date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.today().last().friday();
	Date.today().last().fri();
	Date.today().last().march();
	Date.today().last().mar();
	Date.today().last().week();
	
* * @return {Date} date */ $P.last = $P.prev = $P.previous = function () { this._move = true; this._orient = -1; return this; }; /** * Creates a new Date (Date.today()) and moves the date to the previous instance of the date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.last().friday();
	Date.last().fri();
	Date.previous().march();
	Date.prev().mar();
	Date.last().week();
	
* * @return {Date} date */ $D.last = $D.prev = $D.previous = function () { return $D.today().last(); }; /** * Performs a equality check when followed by either a month name, day name or .weekday() function. * Example

	Date.today().is().friday(); // true|false
	Date.today().is().fri();
	Date.today().is().march();
	Date.today().is().mar();
	
* * @return {Boolean} true|false */ $P.is = function () { this._is = true; return this; }; /** * Determines if two date objects occur on/in exactly the same instance of the subsequent date part function. * The function .same() must be followed by a date part function (example: .day(), .month(), .year(), etc). * * An optional Date can be passed in the date part function. If now date is passed as a parameter, 'Now' is used. * * The following example demonstrates how to determine if two dates fall on the exact same day. * * Example

	var d1 = Date.today(); // today at 00:00
	var d2 = new Date();   // exactly now.

	// Do they occur on the same day?
	d1.same().day(d2); // true
	
	// Do they occur on the same hour?
	d1.same().hour(d2); // false, unless d2 hour is '00' (midnight).
	
	// What if it's the same day, but one year apart?
	var nextYear = Date.today().add(1).year();

	d1.same().day(nextYear); // false, because the dates must occur on the exact same day. 
	
* * Scenario: Determine if a given date occurs during some week period 2 months from now. * * Example

	var future = Date.today().add(2).months();
	return someDate.same().week(future); // true|false;
	
* * @return {Boolean} true|false */ $P.same = function () { this._same = true; this._isSecond = false; return this; }; /** * Determines if the current date/time occurs during Today. Must be preceded by the .is() function. * Example

	someDate.is().today();    // true|false
	new Date().is().today();  // true
	Date.today().is().today();// true
	Date.today().add(-1).day().is().today(); // false
	
* * @return {Boolean} true|false */ $P.today = function () { return this.same().day(); }; /** * Determines if the current date is a weekday. This function must be preceded by the .is() function. * Example

	Date.today().is().weekday(); // true|false
	
* * @return {Boolean} true|false */ $P.weekday = function () { if (this._nth) { return df("Weekday").call(this); } if (this._move) { return this.addWeekdays(this._orient); } if (this._is) { this._is = false; return (!this.is().sat() && !this.is().sun()); } return false; }; /** * Determines if the current date is on the weekend. This function must be preceded by the .is() function. * Example

	Date.today().is().weekend(); // true|false
	
* * @return {Boolean} true|false */ $P.weekend = function () { if (this._is) { this._is = false; return (this.is().sat() || this.is().sun()); } return false; }; /** * Sets the Time of the current Date instance. A string "6:15 pm" or config object {hour:18, minute:15} are accepted. * Example

	// Set time to 6:15pm with a String
	Date.today().at("6:15pm");

	// Set time to 6:15pm with a config object
	Date.today().at({hour:18, minute:15});
	
* * @return {Date} date */ $P.at = function (time) { return (typeof time === "string") ? $D.parse(this.toString("d") + " " + time) : this.set(time); }; /** * Creates a new Date() and adds this (Number) to the date based on the preceding date element function (eg. second|minute|hour|day|month|year). * Example

	// Undeclared Numbers must be wrapped with parentheses. Requirment of JavaScript.
	(3).days().fromNow();
	(6).months().fromNow();

	// Declared Number variables do not require parentheses. 
	var n = 6;
	n.months().fromNow();
	
* * @return {Date} A new Date instance */ $N.fromNow = $N.after = function (date) { var c = {}; c[this._dateElement] = this; return ((!date) ? new Date() : date.clone()).add(c); }; /** * Creates a new Date() and subtract this (Number) from the date based on the preceding date element function (eg. second|minute|hour|day|month|year). * Example

	// Undeclared Numbers must be wrapped with parentheses. Requirment of JavaScript.
	(3).days().ago();
	(6).months().ago();

	// Declared Number variables do not require parentheses. 
	var n = 6;
	n.months().ago();
	
* * @return {Date} A new Date instance */ $N.ago = $N.before = function (date) { var c = {}, s = (this._dateElement[this._dateElement.length-1] !== "s") ? this._dateElement + "s" : this._dateElement; c[s] = this * -1; return ((!date) ? new Date() : date.clone()).add(c); }; // Do NOT modify the following string tokens. These tokens are used to build dynamic functions. // All culture-specific strings can be found in the CultureInfo files. var dx = ("sunday monday tuesday wednesday thursday friday saturday").split(/\s/), mx = ("january february march april may june july august september october november december").split(/\s/), px = ("Millisecond Second Minute Hour Day Week Month Year Quarter Weekday").split(/\s/), pxf = ("Milliseconds Seconds Minutes Hours Date Week Month FullYear Quarter").split(/\s/), nth = ("final first second third fourth fifth").split(/\s/), de; /** * Returns an object literal of all the date parts. * Example

	var o = new Date().toObject();
	
	// { year: 2008, month: 4, week: 20, day: 13, hour: 18, minute: 9, second: 32, millisecond: 812 }
	
	// The object properties can be referenced directly from the object.
	
	alert(o.day);  // alerts "13"
	alert(o.year); // alerts "2008"
	
* * @return {Date} An object literal representing the original date object. */ $P.toObject = function () { var o = {}; for (var i = 0; i < px.length; i++) { if (this["get" + pxf[i]]) { o[px[i].toLowerCase()] = this["get" + pxf[i]](); } } return o; }; /** * Returns a date created from an object literal. Ignores the .week property if set in the config. * Example

	var o = new Date().toObject();
	
	return Date.fromObject(o); // will return the same date. 

	var o2 = {month: 1, day: 20, hour: 18}; // birthday party!
	Date.fromObject(o2);
	
* * @return {Date} An object literal representing the original date object. */ $D.fromObject = function(config) { config.week = null; return Date.today().set(config); }; // Create day name functions and abbreviated day name functions (eg. monday(), friday(), fri()). var df = function (n) { return function () { if (this._is) { this._is = false; return this.getDay() === n; } if (this._move) { this._move = null; } if (this._nth !== null) { // If the .second() function was called earlier, remove the _orient // from the date, and then continue. // This is required because 'second' can be used in two different context. // // Example // // Date.today().add(1).second(); // Date.march().second().monday(); // // Things get crazy with the following... // Date.march().add(1).second().second().monday(); // but it works!! // if (this._isSecond) { this.addSeconds(this._orient * -1); } // make sure we reset _isSecond this._isSecond = false; var ntemp = this._nth; this._nth = null; var temp = this.clone().moveToLastDayOfMonth(); this.moveToNthOccurrence(n, ntemp); if (this > temp) { throw new RangeError($D.getDayName(n) + " does not occur " + ntemp + " times in the month of " + $D.getMonthName(temp.getMonth()) + " " + temp.getFullYear() + "."); } return this; } return this.moveToDayOfWeek(n, this._orient); }; }; var sdf = function (n) { return function () { var t = $D.today(), shift = n - t.getDay(); if (n === 0 && Date.CultureInfo.firstDayOfWeek === 1 && t.getDay() !== 0) { shift = shift + 7; } return t.addDays(shift); }; }; // Create month name functions and abbreviated month name functions (eg. january(), march(), mar()). var month_instance_functions = function (n) { return function () { if (this._is) { this._is = false; return this.getMonth() === n; } return this.moveToMonth(n, this._orient); }; }; var month_static_functions = function (n) { return function () { return $D.today().set({ month: n, day: 1 }); }; }; var processTerms = function (names, staticFunc, instanceFunc) { for (var i = 0; i < names.length; i++) { // Create constant static Name variables. $D[names[i].toUpperCase()] = $D[names[i].toUpperCase().substring(0, 3)] = i; // Create Name functions. $D[names[i]] = $D[names[i].substring(0, 3)] = staticFunc(i); // Create Name instance functions. $P[names[i]] = $P[names[i].substring(0, 3)] = instanceFunc(i); } }; processTerms(dx, sdf, df); processTerms(mx, month_static_functions, month_instance_functions); // Create date element functions and plural date element functions used with Date (eg. day(), days(), months()). var ef = function (j) { return function () { // if the .second() function was called earlier, the _orient // has alread been added. Just return this and reset _isSecond. if (this._isSecond) { this._isSecond = false; return this; } if (this._same) { this._same = this._is = false; var o1 = this.toObject(), o2 = (arguments[0] || new Date()).toObject(), v = "", k = j.toLowerCase(); // the substr trick with -1 doesn't work in IE8 or less k = (k[k.length-1] === "s") ? k.substring(0,k.length-1) : k; for (var m = (px.length - 1); m > -1; m--) { v = px[m].toLowerCase(); if (o1[v] !== o2[v]) { return false; } if (k === v) { break; } } return true; } if (j.substring(j.length - 1) !== "s") { j += "s"; } if (this._move) { this._move = null; } return this["add" + j](this._orient); }; }; var nf = function (n) { return function () { this._dateElement = n; return this; }; }; for (var k = 0; k < px.length; k++) { de = px[k].toLowerCase(); if(de !== "weekday") { // Create date element functions and plural date element functions used with Date (eg. day(), days(), months()). $P[de] = $P[de + "s"] = ef(px[k]); // Create date element functions and plural date element functions used with Number (eg. day(), days(), months()). $N[de] = $N[de + "s"] = nf(de + "s"); } } $P._ss = ef("Second"); var nthfn = function (n) { return function (dayOfWeek) { if (this._same) { return this._ss(arguments[0]); } if (dayOfWeek || dayOfWeek === 0) { return this.moveToNthOccurrence(dayOfWeek, n); } this._nth = n; // if the operator is 'second' add the _orient, then deal with it later... if (n === 2 && (dayOfWeek === undefined || dayOfWeek === null)) { this._isSecond = true; return this.addSeconds(this._orient); } return this; }; }; for (var l = 0; l < nth.length; l++) { $P[nth[l]] = (l === 0) ? nthfn(-1) : nthfn(l); } }()); (function () { "use strict"; Date.Parsing = { Exception: function (s) { this.message = "Parse error at '" + s.substring(0, 10) + " ...'"; } }; var $P = Date.Parsing; var dayOffsets = { standard: [0,31,59,90,120,151,181,212,243,273,304,334], leap: [0,31,60,91,121,152,182,213,244,274,305,335] }; $P.isLeapYear = function(year) { return ((year % 4 === 0) && (year % 100 !== 0)) || (year % 400 === 0); }; var utils = { multiReplace : function (str, hash ) { var key; for (key in hash) { if (Object.prototype.hasOwnProperty.call(hash, key)) { var regex; if (typeof hash[key] === "function") { } else { regex = (hash[key] instanceof RegExp) ? hash[key] : new RegExp(hash[key], "g"); } str = str.replace(regex, key); } } return str; }, getDayOfYearFromWeek : function (obj) { var d, jan4, offset; obj.weekDay = (!obj.weekDay && obj.weekDay !== 0) ? 1 : obj.weekDay; d = new Date(obj.year, 0, 4); jan4 = d.getDay() === 0 ? 7 : d.getDay(); // JS is 0 indexed on Sunday. offset = jan4+3; obj.dayOfYear = ((obj.week * 7) + (obj.weekDay === 0 ? 7 : obj.weekDay))-offset; return obj; }, getDayOfYear : function (obj, dayOffset) { if (!obj.dayOfYear) { obj = utils.getDayOfYearFromWeek(obj); } for (var i=0;i <= dayOffset.length;i++) { if (obj.dayOfYear < dayOffset[i] || i === dayOffset.length) { obj.day = obj.day ? obj.day : (obj.dayOfYear - dayOffset[i-1]); break; } else { obj.month = i; } } return obj; }, adjustForTimeZone : function (obj, date) { var offset; if (obj.zone.toUpperCase() === "Z" || (obj.zone_hours === 0 && obj.zone_minutes === 0)) { // it's UTC/GML so work out the current timeszone offset offset = -date.getTimezoneOffset(); } else { offset = (obj.zone_hours*60) + (obj.zone_minutes || 0); if (obj.zone_sign === "+") { offset *= -1; } offset -= date.getTimezoneOffset(); } date.setMinutes(date.getMinutes()+offset); return date; }, setDefaults : function (obj) { obj.year = obj.year || Date.today().getFullYear(); obj.hours = obj.hours || 0; obj.minutes = obj.minutes || 0; obj.seconds = obj.seconds || 0; obj.milliseconds = obj.milliseconds || 0; if (!(!obj.month && (obj.week || obj.dayOfYear))) { // if we have a month, or if we don't but don't have the day calculation data obj.month = obj.month || 0; obj.day = obj.day || 1; } return obj; }, dataNum: function (data, mod, explict, postProcess) { var dataNum = data*1; if (mod) { if (postProcess) { return data ? mod(data)*1 : data; } else { return data ? mod(dataNum) : data; } } else if (!explict){ return data ? dataNum : data; } else { return (data && typeof data !== "undefined") ? dataNum : data; } }, timeDataProcess: function (obj) { var timeObj = {}; for (var x in obj.data) { if (obj.data.hasOwnProperty(x)) { timeObj[x] = obj.ignore[x] ? obj.data[x] : utils.dataNum(obj.data[x], obj.mods[x], obj.explict[x], obj.postProcess[x]); } } if (obj.data.secmins) { obj.data.secmins = obj.data.secmins.replace(",", ".") * 60; if (!timeObj.minutes) { timeObj.minutes = obj.data.secmins; } else if (!timeObj.seconds) { timeObj.seconds = obj.data.secmins; } delete obj.secmins; } return timeObj; }, buildTimeObjectFromData: function (data) { var time = utils.timeDataProcess({ data: { year : data[1], month : data[5], day : data[7], week : data[8], dayOfYear : data[10], hours : data[15], zone_hours : data[23], zone_minutes : data[24], zone : data[21], zone_sign : data[22], weekDay : data[9], minutes: data[16], seconds: data[19], milliseconds: data[20], secmins: data[18] }, mods: { month: function(data) { return data-1; }, weekDay: function (data) { data = Math.abs(data); return (data === 7 ? 0 : data); }, minutes: function (data) { return data.replace(":",""); }, seconds: function (data) { return Math.floor( (data.replace(":","").replace(",","."))*1 ); }, milliseconds: function (data) { return (data.replace(",",".")*1000); } }, postProcess: { minutes: true, seconds: true, milliseconds: true }, explict: { zone_hours: true, zone_minutes: true }, ignore: { zone: true, zone_sign: true, secmins: true } }); return time; }, addToHash: function (hash, keys, data) { keys = keys; data = data; var len = keys.length; for (var i = 0; i < len; i++) { hash[keys[i]] = data[i]; } return hash; }, combineRegex: function (r1, r2) { return new RegExp("(("+r1.source+")\\s("+r2.source+"))"); }, getDateNthString: function(add, last, inc){ if (add) { return Date.today().addDays(inc).toString("d"); } else if (last) { return Date.today().last()[inc]().toString("d"); } }, buildRegexData: function (array) { var arr = []; var len = array.length; for (var i=0; i < len; i++) { if (Object.prototype.toString.call(array[i]) === '[object Array]') { // oldIE compat version of Array.isArray arr.push(this.combineRegex(array[i][0], array[i][1])); } else { arr.push(array[i]); } } return arr; } }; $P.processTimeObject = function (obj) { var date, dayOffset; utils.setDefaults(obj); dayOffset = ($P.isLeapYear(obj.year)) ? dayOffsets.leap : dayOffsets.standard; if (!obj.month && (obj.week || obj.dayOfYear)) { utils.getDayOfYear(obj, dayOffset); } else { obj.dayOfYear = dayOffset[obj.month] + obj.day; } date = new Date(obj.year, obj.month, obj.day, obj.hours, obj.minutes, obj.seconds, obj.milliseconds); if (obj.zone) { utils.adjustForTimeZone(obj, date); // adjust (and calculate) for timezone } return date; }; $P.ISO = { regex : /^([\+-]?\d{4}(?!\d{2}\b))((-?)((0[1-9]|1[0-2])(\3([12]\d|0[1-9]|3[01]))?|W([0-4]\d|5[0-3])(-?[1-7])?|(00[1-9]|0[1-9]\d|[12]\d{2}|3([0-5]\d|6[1-6])))([T\s]((([01]\d|2[0-4])((:?)[0-5]\d)?|24\:?00)([\.,]\d+(?!:))?)?(\17[0-5]\d([\.,]\d+)?)?\s?([zZ]|([\+-])([01]\d|2[0-3]):?([0-5]\d)?)?)?)?$/, parse : function (s) { var time, data = s.match(this.regex); if (!data || !data.length) { return null; } time = utils.buildTimeObjectFromData(data); if (!time.year || (!time.year && (!time.month && !time.day) && (!time.week && !time.dayOfYear)) ) { return null; } return $P.processTimeObject(time); } }; $P.Numeric = { isNumeric: function (e){return!isNaN(parseFloat(e))&&isFinite(e);}, regex: /\b([0-1]?[0-9])([0-3]?[0-9])([0-2]?[0-9]?[0-9][0-9])\b/i, parse: function (s) { var data, i, time = {}, order = Date.CultureInfo.dateElementOrder.split(""); if (!(this.isNumeric(s)) || // if it's non-numeric OR (s[0] === "+" && s[0] === "-")) { // It's an arithmatic string (eg +/-1000) return null; } if (s.length < 5 && s.indexOf(".") < 0 && s.indexOf("/") < 0) { // assume it's just a year. time.year = s; return $P.processTimeObject(time); } data = s.match(this.regex); if (!data || !data.length) { return null; } for (i=0; i < order.length; i++) { switch(order[i]) { case "d": time.day = data[i+1]; break; case "m": time.month = (data[i+1]-1); break; case "y": time.year = data[i+1]; break; } } return $P.processTimeObject(time); } }; $P.Normalizer = { regexData: function () { var $R = Date.CultureInfo.regexPatterns; return utils.buildRegexData([ $R.tomorrow, $R.yesterday, [$R.past, $R.mon], [$R.past, $R.tue], [$R.past, $R.wed], [$R.past, $R.thu], [$R.past, $R.fri], [$R.past, $R.sat], [$R.past, $R.sun] ]); }, basicReplaceHash : function() { var $R = Date.CultureInfo.regexPatterns; return { "January": $R.jan.source, "February": $R.feb, "March": $R.mar, "April": $R.apr, "May": $R.may, "June": $R.jun, "July": $R.jul, "August": $R.aug, "September": $R.sep, "October": $R.oct, "November": $R.nov, "December": $R.dec, "": /\bat\b/gi, " ": /\s{2,}/, "am": $R.inTheMorning, "9am": $R.thisMorning, "pm": $R.inTheEvening, "7pm":$R.thisEvening }; }, keys : function(){ return [ utils.getDateNthString(true, false, 1), // tomorrow utils.getDateNthString(true, false, -1), // yesterday utils.getDateNthString(false, true, "monday"), //last mon utils.getDateNthString(false, true, "tuesday"), //last tues utils.getDateNthString(false, true, "wednesday"), //last wed utils.getDateNthString(false, true, "thursday"), //last thurs utils.getDateNthString(false, true, "friday"), //last fri utils.getDateNthString(false, true, "saturday"), //last sat utils.getDateNthString(false, true, "sunday") //last sun ]; }, buildRegexFunctions: function () { var $R = Date.CultureInfo.regexPatterns; var __ = Date.i18n.__; var tomorrowRE = new RegExp("(\\b\\d\\d?("+__("AM")+"|"+__("PM")+")? )("+$R.tomorrow.source.slice(1)+")", "i"); // adapted tomorrow regex for AM PM relative dates var todayRE = new RegExp($R.today.source + "(?!\\s*([+-]))\\b"); // today, but excludes the math operators (eg "today + 2h") this.replaceFuncs = [ [todayRE, function (full) { return (full.length > 1) ? Date.today().toString("d") : full; }], [tomorrowRE, function(full, m1) { var t = Date.today().addDays(1).toString("d"); return (t + " " + m1); }], [$R.amThisMorning, function(str, am){return am;}], [$R.pmThisEvening, function(str, pm){return pm;}] ]; }, buildReplaceData: function () { this.buildRegexFunctions(); this.replaceHash = utils.addToHash(this.basicReplaceHash(), this.keys(), this.regexData()); }, stringReplaceFuncs: function (s) { for (var i=0; i < this.replaceFuncs.length; i++) { s = s.replace(this.replaceFuncs[i][0], this.replaceFuncs[i][1]); } return s; }, parse: function (s) { s = this.stringReplaceFuncs(s); s = utils.multiReplace(s, this.replaceHash); try { var n = s.split(/([\s\-\.\,\/\x27]+)/); if (n.length === 3 && $P.Numeric.isNumeric(n[0]) && $P.Numeric.isNumeric(n[2]) && (n[2].length >= 4)) { // ok, so we're dealing with x/year. But that's not a full date. // This fixes wonky dateElementOrder parsing when set to dmy order. if (Date.CultureInfo.dateElementOrder[0] === "d") { s = "1/" + n[0] + "/" + n[2]; // set to 1st of month and normalize the seperator } } } catch (e) {} return s; } }; $P.Normalizer.buildReplaceData(); }()); (function () { var $P = Date.Parsing; var _ = $P.Operators = { // // Tokenizers // rtoken: function (r) { // regex token return function (s) { var mx = s.match(r); if (mx) { return ([ mx[0], s.substring(mx[0].length) ]); } else { throw new $P.Exception(s); } }; }, token: function () { // whitespace-eating token return function (s) { return _.rtoken(new RegExp("^\\s*" + s + "\\s*"))(s); }; }, stoken: function (s) { // string token return _.rtoken(new RegExp("^" + s)); }, // Atomic Operators until: function (p) { return function (s) { var qx = [], rx = null; while (s.length) { try { rx = p.call(this, s); } catch (e) { qx.push(rx[0]); s = rx[1]; continue; } break; } return [ qx, s ]; }; }, many: function (p) { return function (s) { var rx = [], r = null; while (s.length) { try { r = p.call(this, s); } catch (e) { return [ rx, s ]; } rx.push(r[0]); s = r[1]; } return [ rx, s ]; }; }, // generator operators -- see below optional: function (p) { return function (s) { var r = null; try { r = p.call(this, s); } catch (e) { return [ null, s ]; } return [ r[0], r[1] ]; }; }, not: function (p) { return function (s) { try { p.call(this, s); } catch (e) { return [null, s]; } throw new $P.Exception(s); }; }, ignore: function (p) { return p ? function (s) { var r = null; r = p.call(this, s); return [null, r[1]]; } : null; }, product: function () { var px = arguments[0], qx = Array.prototype.slice.call(arguments, 1), rx = []; for (var i = 0 ; i < px.length ; i++) { rx.push(_.each(px[i], qx)); } return rx; }, cache: function (rule) { var cache = {}, cache_length = 0, cache_keys = [], CACHE_MAX = Date.Config.CACHE_MAX || 100000, r = null; var cacheCheck = function () { if (cache_length === CACHE_MAX) { // kill several keys, don't want to have to do this all the time... for (var i=0; i < 10; i++) { var key = cache_keys.shift(); if (key) { delete cache[key]; cache_length--; } } } }; return function (s) { cacheCheck(); try { r = cache[s] = (cache[s] || rule.call(this, s)); } catch (e) { r = cache[s] = e; } cache_length++; cache_keys.push(s); if (r instanceof $P.Exception) { throw r; } else { return r; } }; }, // vector operators -- see below any: function () { var px = arguments; return function (s) { var r = null; for (var i = 0; i < px.length; i++) { if (px[i] == null) { continue; } try { r = (px[i].call(this, s)); } catch (e) { r = null; } if (r) { return r; } } throw new $P.Exception(s); }; }, each: function () { var px = arguments; return function (s) { var rx = [], r = null; for (var i = 0; i < px.length ; i++) { if (px[i] == null) { continue; } try { r = (px[i].call(this, s)); } catch (e) { throw new $P.Exception(s); } rx.push(r[0]); s = r[1]; } return [ rx, s]; }; }, all: function () { var px = arguments, _ = _; return _.each(_.optional(px)); }, // delimited operators sequence: function (px, d, c) { d = d || _.rtoken(/^\s*/); c = c || null; if (px.length === 1) { return px[0]; } return function (s) { var r = null, q = null; var rx = []; for (var i = 0; i < px.length ; i++) { try { r = px[i].call(this, s); } catch (e) { break; } rx.push(r[0]); try { q = d.call(this, r[1]); } catch (ex) { q = null; break; } s = q[1]; } if (!r) { throw new $P.Exception(s); } if (q) { throw new $P.Exception(q[1]); } if (c) { try { r = c.call(this, r[1]); } catch (ey) { throw new $P.Exception(r[1]); } } return [ rx, (r?r[1]:s) ]; }; }, // // Composite Operators // between: function (d1, p, d2) { d2 = d2 || d1; var _fn = _.each(_.ignore(d1), p, _.ignore(d2)); return function (s) { var rx = _fn.call(this, s); return [[rx[0][0], r[0][2]], rx[1]]; }; }, list: function (p, d, c) { d = d || _.rtoken(/^\s*/); c = c || null; return (p instanceof Array ? _.each(_.product(p.slice(0, -1), _.ignore(d)), p.slice(-1), _.ignore(c)) : _.each(_.many(_.each(p, _.ignore(d))), px, _.ignore(c))); }, set: function (px, d, c) { d = d || _.rtoken(/^\s*/); c = c || null; return function (s) { // r is the current match, best the current 'best' match // which means it parsed the most amount of input var r = null, p = null, q = null, rx = null, best = [[], s], last = false; // go through the rules in the given set for (var i = 0; i < px.length ; i++) { // last is a flag indicating whether this must be the last element // if there is only 1 element, then it MUST be the last one q = null; p = null; r = null; last = (px.length === 1); // first, we try simply to match the current pattern // if not, try the next pattern try { r = px[i].call(this, s); } catch (e) { continue; } // since we are matching against a set of elements, the first // thing to do is to add r[0] to matched elements rx = [[r[0]], r[1]]; // if we matched and there is still input to parse and // we don't already know this is the last element, // we're going to next check for the delimiter ... // if there's none, or if there's no input left to parse // than this must be the last element after all ... if (r[1].length > 0 && ! last) { try { q = d.call(this, r[1]); } catch (ex) { last = true; } } else { last = true; } // if we parsed the delimiter and now there's no more input, // that means we shouldn't have parsed the delimiter at all // so don't update r and mark this as the last element ... if (!last && q[1].length === 0) { last = true; } // so, if this isn't the last element, we're going to see if // we can get any more matches from the remaining (unmatched) // elements ... if (!last) { // build a list of the remaining rules we can match against, // i.e., all but the one we just matched against var qx = []; for (var j = 0; j < px.length ; j++) { if (i !== j) { qx.push(px[j]); } } // now invoke recursively set with the remaining input // note that we don't include the closing delimiter ... // we'll check for that ourselves at the end p = _.set(qx, d).call(this, q[1]); // if we got a non-empty set as a result ... // (otw rx already contains everything we want to match) if (p[0].length > 0) { // update current result, which is stored in rx ... // basically, pick up the remaining text from p[1] // and concat the result from p[0] so that we don't // get endless nesting ... rx[0] = rx[0].concat(p[0]); rx[1] = p[1]; } } // at this point, rx either contains the last matched element // or the entire matched set that starts with this element. // now we just check to see if this variation is better than // our best so far, in terms of how much of the input is parsed if (rx[1].length < best[1].length) { best = rx; } // if we've parsed all the input, then we're finished if (best[1].length === 0) { break; } } // so now we've either gone through all the patterns trying them // as the initial match; or we found one that parsed the entire // input string ... // if best has no matches, just return empty set ... if (best[0].length === 0) { return best; } // if a closing delimiter is provided, then we have to check it also if (c) { // we try this even if there is no remaining input because the pattern // may well be optional or match empty input ... try { q = c.call(this, best[1]); } catch (ey) { throw new $P.Exception(best[1]); } // it parsed ... be sure to update the best match remaining input best[1] = q[1]; } // if we're here, either there was no closing delimiter or we parsed it // so now we have the best match; just return it! return best; }; }, forward: function (gr, fname) { return function (s) { return gr[fname].call(this, s); }; }, // // Translation Operators // replace: function (rule, repl) { return function (s) { var r = rule.call(this, s); return [repl, r[1]]; }; }, process: function (rule, fn) { return function (s) { var r = rule.call(this, s); return [fn.call(this, r[0]), r[1]]; }; }, min: function (min, rule) { return function (s) { var rx = rule.call(this, s); if (rx[0].length < min) { throw new $P.Exception(s); } return rx; }; } }; // Generator Operators And Vector Operators // Generators are operators that have a signature of F(R) => R, // taking a given rule and returning another rule, such as // ignore, which parses a given rule and throws away the result. // Vector operators are those that have a signature of F(R1,R2,...) => R, // take a list of rules and returning a new rule, such as each. // Generator operators are converted (via the following _generator // function) into functions that can also take a list or array of rules // and return an array of new rules as though the function had been // called on each rule in turn (which is what actually happens). // This allows generators to be used with vector operators more easily. // Example: // each(ignore(foo, bar)) instead of each(ignore(foo), ignore(bar)) // This also turns generators into vector operators, which allows // constructs like: // not(cache(foo, bar)) var _generator = function (op) { function gen() { var args = null, rx = [], px, i; if (arguments.length > 1) { args = Array.prototype.slice.call(arguments); } else if (arguments[0] instanceof Array) { args = arguments[0]; } if (args) { px = args.shift(); if (px.length > 0) { args.unshift(px[i]); rx.push(op.apply(null, args)); args.shift(); return rx; } } else { return op.apply(null, arguments); } } return gen; }; var gx = "optional not ignore cache".split(/\s/); for (var i = 0 ; i < gx.length ; i++) { _[gx[i]] = _generator(_[gx[i]]); } var _vector = function (op) { return function () { if (arguments[0] instanceof Array) { return op.apply(null, arguments[0]); } else { return op.apply(null, arguments); } }; }; var vx = "each any all".split(/\s/); for (var j = 0 ; j < vx.length ; j++) { _[vx[j]] = _vector(_[vx[j]]); } }()); (function () { var $D = Date; var flattenAndCompact = function (ax) { var rx = []; for (var i = 0; i < ax.length; i++) { if (ax[i] instanceof Array) { rx = rx.concat(flattenAndCompact(ax[i])); } else { if (ax[i]) { rx.push(ax[i]); } } } return rx; }; var parseMeridian = function () { if (this.meridian && (this.hour || this.hour === 0)) { if (this.meridian === "a" && this.hour > 11 && Date.Config.strict24hr){ throw "Invalid hour and meridian combination"; } else if (this.meridian === "p" && this.hour < 12 && Date.Config.strict24hr){ throw "Invalid hour and meridian combination"; } else if (this.meridian === "p" && this.hour < 12) { this.hour = this.hour + 12; } else if (this.meridian === "a" && this.hour === 12) { this.hour = 0; } } }; var setDefaults = function () { var now = new Date(); if ((this.hour || this.minute) && (!this.month && !this.year && !this.day)) { this.day = now.getDate(); } if (!this.year) { this.year = now.getFullYear(); } if (!this.month && this.month !== 0) { this.month = now.getMonth(); } if (!this.day) { this.day = 1; } if (!this.hour) { this.hour = 0; } if (!this.minute) { this.minute = 0; } if (!this.second) { this.second = 0; } if (!this.millisecond) { this.millisecond = 0; } }; var finishUtils = { getToday: function () { if (this.now || "hour minute second".indexOf(this.unit) !== -1) { return new Date(); } else { return $D.today(); } }, setDaysFromWeekday: function (today, orient){ var gap; orient = orient || 1; this.unit = "day"; gap = ($D.getDayNumberFromName(this.weekday) - today.getDay()); this.days = gap ? ((gap + (orient * 7)) % 7) : (orient * 7); return this; }, setMonthsFromMonth: function (today, orient) { var gap; orient = orient || 1; this.unit = "month"; gap = (this.month - today.getMonth()); this.months = gap ? ((gap + (orient * 12)) % 12) : (orient * 12); this.month = null; return this; }, setDMYFromWeekday: function () { var d = Date[this.weekday](); this.day = d.getDate(); if (!this.month) { this.month = d.getMonth(); } this.year = d.getFullYear(); return this; }, setUnitValue: function (orient) { if (!this.value && this.operator && this.operator !== null && this[this.unit + "s"] && this[this.unit + "s"] !== null) { this[this.unit + "s"] = this[this.unit + "s"] + ((this.operator === "add") ? 1 : -1) + (this.value||0) * orient; } else if (this[this.unit + "s"] == null || this.operator != null) { if (!this.value) { this.value = 1; } this[this.unit + "s"] = this.value * orient; } }, generateDateFromWeeks: function () { var weekday = (this.weekday !== undefined) ? this.weekday : "today"; var d = Date[weekday]().addWeeks(this.weeks); if (this.now) { d.setTimeToNow(); } return d; } }; $D.Translator = { hour: function (s) { return function () { this.hour = Number(s); }; }, minute: function (s) { return function () { this.minute = Number(s); }; }, second: function (s) { return function () { this.second = Number(s); }; }, /* for ss.s format */ secondAndMillisecond: function (s) { return function () { var mx = s.match(/^([0-5][0-9])\.([0-9]{1,3})/); this.second = Number(mx[1]); this.millisecond = Number(mx[2]); }; }, meridian: function (s) { return function () { this.meridian = s.slice(0, 1).toLowerCase(); }; }, timezone: function (s) { return function () { var n = s.replace(/[^\d\+\-]/g, ""); if (n.length) { this.timezoneOffset = Number(n); } else { this.timezone = s.toLowerCase(); } }; }, day: function (x) { var s = x[0]; return function () { this.day = Number(s.match(/\d+/)[0]); if (this.day < 1) { throw "invalid day"; } }; }, month: function (s) { return function () { this.month = (s.length === 3) ? "jan feb mar apr may jun jul aug sep oct nov dec".indexOf(s)/4 : Number(s) - 1; if (this.month < 0) { throw "invalid month"; } }; }, year: function (s) { return function () { var n = Number(s); this.year = ((s.length > 2) ? n : (n + (((n + 2000) < Date.CultureInfo.twoDigitYearMax) ? 2000 : 1900))); }; }, rday: function (s) { return function () { switch (s) { case "yesterday": this.days = -1; break; case "tomorrow": this.days = 1; break; case "today": this.days = 0; break; case "now": this.days = 0; this.now = true; break; } }; }, finishExact: function (x) { var d; x = (x instanceof Array) ? x : [x]; for (var i = 0 ; i < x.length ; i++) { if (x[i]) { x[i].call(this); } } setDefaults.call(this); parseMeridian.call(this); if (this.day > $D.getDaysInMonth(this.year, this.month)) { throw new RangeError(this.day + " is not a valid value for days."); } d = new Date(this.year, this.month, this.day, this.hour, this.minute, this.second, this.millisecond); if (this.year < 100) { d.setFullYear(this.year); // means years less that 100 are process correctly. JS will parse it otherwise as 1900-1999. } if (this.timezone) { d.set({ timezone: this.timezone }); } else if (this.timezoneOffset) { d.set({ timezoneOffset: this.timezoneOffset }); } return d; }, finish: function (x) { var today, expression, orient, temp; x = (x instanceof Array) ? flattenAndCompact(x) : [ x ]; if (x.length === 0) { return null; } for (var i = 0 ; i < x.length ; i++) { if (typeof x[i] === "function") { x[i].call(this); } } if (this.now && !this.unit && !this.operator) { return new Date(); } else { today = finishUtils.getToday.call(this); } expression = !!(this.days && this.days !== null || this.orient || this.operator); orient = ((this.orient === "past" || this.operator === "subtract") ? -1 : 1); if (this.month && this.unit === "week") { this.value = this.month + 1; delete this.month; delete this.day; } if ((this.month || this.month === 0) && "year day hour minute second".indexOf(this.unit) !== -1) { if (!this.value) { this.value = this.month + 1; } this.month = null; expression = true; } if (!expression && this.weekday && !this.day && !this.days) { finishUtils.setDMYFromWeekday.call(this); } if (expression && this.weekday && this.unit !== "month" && this.unit !== "week") { finishUtils.setDaysFromWeekday.call(this, today, orient); } if (this.weekday && this.unit !== "week" && !this.day && !this.days) { temp = Date[this.weekday](); this.day = temp.getDate(); if (temp.getMonth() !== today.getMonth()) { this.month = temp.getMonth(); } } if (this.month && this.unit === "day" && this.operator) { if (!this.value) { this.value = (this.month + 1); } this.month = null; } if (this.value != null && this.month != null && this.year != null) { this.day = this.value * 1; } if (this.month && !this.day && this.value) { today.set({ day: this.value * 1 }); if (!expression) { this.day = this.value * 1; } } if (!this.month && this.value && this.unit === "month" && !this.now) { this.month = this.value; expression = true; } if (expression && (this.month || this.month === 0) && this.unit !== "year") { finishUtils.setMonthsFromMonth.call(this, today, orient); } if (!this.unit) { this.unit = "day"; } finishUtils.setUnitValue.call(this, orient); parseMeridian.call(this); if ((this.month || this.month === 0) && !this.day) { this.day = 1; } if (!this.orient && !this.operator && this.unit === "week" && this.value && !this.day && !this.month) { return Date.today().setWeek(this.value); } if (this.unit === "week" && this.weeks && !this.day && !this.month) { return finishUtils.generateDateFromWeeks.call(this); } if (expression && this.timezone && this.day && this.days) { this.day = this.days; } if (expression){ today.add(this); } else { today.set(this); } if (this.timezone) { this.timezone = this.timezone.toUpperCase(); var offset = $D.getTimezoneOffset(this.timezone); var timezone; if (today.hasDaylightSavingTime()) { // lets check that we're being sane with timezone setting timezone = $D.getTimezoneAbbreviation(offset, today.isDaylightSavingTime()); if (timezone !== this.timezone) { // bugger, we're in a place where things like EST vs EDT matters. if (today.isDaylightSavingTime()) { today.addHours(-1); } else { today.addHours(1); } } } today.setTimezoneOffset(offset); } return today; } }; }()); (function () { var $D = Date; $D.Grammar = {}; var _ = $D.Parsing.Operators, g = $D.Grammar, t = $D.Translator, _fn; // Allow rolling up into general purpose rules _fn = function () { return _.each(_.any.apply(null, arguments), _.not(g.ctoken2("timeContext"))); }; g.datePartDelimiter = _.rtoken(/^([\s\-\.\,\/\x27]+)/); g.timePartDelimiter = _.stoken(":"); g.whiteSpace = _.rtoken(/^\s*/); g.generalDelimiter = _.rtoken(/^(([\s\,]|at|@|on)+)/); var _C = {}; g.ctoken = function (keys) { var fn = _C[keys]; if (! fn) { var c = Date.CultureInfo.regexPatterns; var kx = keys.split(/\s+/), px = []; for (var i = 0; i < kx.length ; i++) { px.push(_.replace(_.rtoken(c[kx[i]]), kx[i])); } fn = _C[keys] = _.any.apply(null, px); } return fn; }; g.ctoken2 = function (key) { return _.rtoken(Date.CultureInfo.regexPatterns[key]); }; var cacheProcessRtoken = function (key, token, type, eachToken) { if (eachToken) { g[key] = _.cache(_.process(_.each(_.rtoken(token),_.optional(g.ctoken2(eachToken))), type)); } else { g[key] = _.cache(_.process(_.rtoken(token), type)); } }; var cacheProcessCtoken = function (token, type) { return _.cache(_.process(g.ctoken2(token), type)); }; var _F = {}; //function cache var _get = function (f) { _F[f] = (_F[f] || g.format(f)[0]); return _F[f]; }; g.allformats = function (fx) { var rx = []; if (fx instanceof Array) { for (var i = 0; i < fx.length; i++) { rx.push(_get(fx[i])); } } else { rx.push(_get(fx)); } return rx; }; g.formats = function (fx) { if (fx instanceof Array) { var rx = []; for (var i = 0 ; i < fx.length ; i++) { rx.push(_get(fx[i])); } return _.any.apply(null, rx); } else { return _get(fx); } }; var grammarFormats = { timeFormats: function(){ var i, RTokenKeys = [ "h", "hh", "H", "HH", "m", "mm", "s", "ss", "ss.s", "z", "zz" ], RToken = [ /^(0[0-9]|1[0-2]|[1-9])/, /^(0[0-9]|1[0-2])/, /^([0-1][0-9]|2[0-3]|[0-9])/, /^([0-1][0-9]|2[0-3])/, /^([0-5][0-9]|[0-9])/, /^[0-5][0-9]/, /^([0-5][0-9]|[0-9])/, /^[0-5][0-9]/, /^[0-5][0-9]\.[0-9]{1,3}/, /^((\+|\-)\s*\d\d\d\d)|((\+|\-)\d\d\:?\d\d)/, /^((\+|\-)\s*\d\d\d\d)|((\+|\-)\d\d\:?\d\d)/ ], tokens = [ t.hour, t.hour, t.hour, t.hour, t.minute, t.minute, t.second, t.second, t.secondAndMillisecond, t.timezone, t.timezone ]; for (i=0; i < RTokenKeys.length; i++) { cacheProcessRtoken(RTokenKeys[i], RToken[i], tokens[i]); } g.hms = _.cache(_.sequence([g.H, g.m, g.s], g.timePartDelimiter)); g.t = cacheProcessCtoken("shortMeridian", t.meridian); g.tt = cacheProcessCtoken("longMeridian", t.meridian); g.zzz = cacheProcessCtoken("timezone", t.timezone); g.timeSuffix = _.each(_.ignore(g.whiteSpace), _.set([ g.tt, g.zzz ])); g.time = _.each(_.optional(_.ignore(_.stoken("T"))), g.hms, g.timeSuffix); }, dateFormats: function () { // pre-loaded rules for different date part order preferences var _setfn = function () { return _.set(arguments, g.datePartDelimiter); }; var i, RTokenKeys = [ "d", "dd", "M", "MM", "y", "yy", "yyy", "yyyy" ], RToken = [ /^([0-2]\d|3[0-1]|\d)/, /^([0-2]\d|3[0-1])/, /^(1[0-2]|0\d|\d)/, /^(1[0-2]|0\d)/, /^(\d+)/, /^(\d\d)/, /^(\d\d?\d?\d?)/, /^(\d\d\d\d)/ ], tokens = [ t.day, t.day, t.month, t.month, t.year, t.year, t.year, t.year ], eachToken = [ "ordinalSuffix", "ordinalSuffix" ]; for (i=0; i < RTokenKeys.length; i++) { cacheProcessRtoken(RTokenKeys[i], RToken[i], tokens[i], eachToken[i]); } g.MMM = g.MMMM = _.cache(_.process(g.ctoken("jan feb mar apr may jun jul aug sep oct nov dec"), t.month)); g.ddd = g.dddd = _.cache(_.process(g.ctoken("sun mon tue wed thu fri sat"), function (s) { return function () { this.weekday = s; }; } )); g.day = _fn(g.d, g.dd); g.month = _fn(g.M, g.MMM); g.year = _fn(g.yyyy, g.yy); g.mdy = _setfn(g.ddd, g.month, g.day, g.year); g.ymd = _setfn(g.ddd, g.year, g.month, g.day); g.dmy = _setfn(g.ddd, g.day, g.month, g.year); g.date = function (s) { return ((g[Date.CultureInfo.dateElementOrder] || g.mdy).call(this, s)); }; }, relative: function () { // relative date / time expressions g.orientation = _.process(g.ctoken("past future"), function (s) { return function () { this.orient = s; }; } ); g.operator = _.process(g.ctoken("add subtract"), function (s) { return function () { this.operator = s; }; } ); g.rday = _.process(g.ctoken("yesterday tomorrow today now"), t.rday); g.unit = _.process(g.ctoken("second minute hour day week month year"), function (s) { return function () { this.unit = s; }; } ); } }; g.buildGrammarFormats = function () { // these need to be rebuilt every time the language changes. _C = {}; grammarFormats.timeFormats(); grammarFormats.dateFormats(); grammarFormats.relative(); g.value = _.process(_.rtoken(/^([-+]?\d+)?(st|nd|rd|th)?/), function (s) { return function () { this.value = s.replace(/\D/g, ""); }; } ); g.expression = _.set([g.rday, g.operator, g.value, g.unit, g.orientation, g.ddd, g.MMM ]); g.format = _.process(_.many( _.any( // translate format specifiers into grammar rules _.process( _.rtoken(/^(dd?d?d?(?!e)|MM?M?M?|yy?y?y?|hh?|HH?|mm?|ss?|tt?|zz?z?)/), function (fmt) { if (g[fmt]) { return g[fmt]; } else { throw $D.Parsing.Exception(fmt); } } ), // translate separator tokens into token rules _.process(_.rtoken(/^[^dMyhHmstz]+/), // all legal separators function (s) { return _.ignore(_.stoken(s)); } ) ) ), // construct the parser ... function (rules) { return _.process(_.each.apply(null, rules), t.finishExact); } ); // starting rule for general purpose grammar g._start = _.process(_.set([ g.date, g.time, g.expression ], g.generalDelimiter, g.whiteSpace), t.finish); }; g.buildGrammarFormats(); // parsing date format specifiers - ex: "h:m:s tt" // this little guy will generate a custom parser based // on the format string, ex: g.format("h:m:s tt") // check for these formats first g._formats = g.formats([ "\"yyyy-MM-ddTHH:mm:ssZ\"", "yyyy-MM-ddTHH:mm:ss.sz", "yyyy-MM-ddTHH:mm:ssZ", "yyyy-MM-ddTHH:mm:ssz", "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-ddTHH:mmZ", "yyyy-MM-ddTHH:mmz", "yyyy-MM-ddTHH:mm", "ddd, MMM dd, yyyy H:mm:ss tt", "ddd MMM d yyyy HH:mm:ss zzz", "MMddyyyy", "ddMMyyyy", "Mddyyyy", "ddMyyyy", "Mdyyyy", "dMyyyy", "yyyy", "Mdyy", "dMyy", "d" ]); // real starting rule: tries selected formats first, // then general purpose rule g.start = function (s) { try { var r = g._formats.call({}, s); if (r[1].length === 0) { return r; } } catch (e) {} return g._start.call({}, s); }; }()); (function () { var $D = Date; /** * @desc Converts the specified string value into its JavaScript Date equivalent using CultureInfo specific format information. * * Example

	///////////
	// Dates //
	///////////

	// 15-Oct-2004
	var d1 = Date.parse("10/15/2004");

	// 15-Oct-2004
	var d1 = Date.parse("15-Oct-2004");

	// 15-Oct-2004
	var d1 = Date.parse("2004.10.15");

	//Fri Oct 15, 2004
	var d1 = Date.parse("Fri Oct 15, 2004");

	///////////
	// Times //
	///////////

	// Today at 10 PM.
	var d1 = Date.parse("10 PM");

	// Today at 10:30 PM.
	var d1 = Date.parse("10:30 P.M.");

	// Today at 6 AM.
	var d1 = Date.parse("06am");

	/////////////////////
	// Dates and Times //
	/////////////////////

	// 8-July-2004 @ 10:30 PM
	var d1 = Date.parse("July 8th, 2004, 10:30 PM");

	// 1-July-2004 @ 10:30 PM
	var d1 = Date.parse("2004-07-01T22:30:00");

	////////////////////
	// Relative Dates //
	////////////////////

	// Returns today's date. The string "today" is culture specific.
	var d1 = Date.parse("today");

	// Returns yesterday's date. The string "yesterday" is culture specific.
	var d1 = Date.parse("yesterday");

	// Returns the date of the next thursday.
	var d1 = Date.parse("Next thursday");

	// Returns the date of the most previous monday.
	var d1 = Date.parse("last monday");

	// Returns today's day + one year.
	var d1 = Date.parse("next year");

	///////////////
	// Date Math //
	///////////////

	// Today + 2 days
	var d1 = Date.parse("t+2");

	// Today + 2 days
	var d1 = Date.parse("today + 2 days");

	// Today + 3 months
	var d1 = Date.parse("t+3m");

	// Today - 1 year
	var d1 = Date.parse("today - 1 year");

	// Today - 1 year
	var d1 = Date.parse("t-1y"); 


	/////////////////////////////
	// Partial Dates and Times //
	/////////////////////////////

	// July 15th of this year.
	var d1 = Date.parse("July 15");

	// 15th day of current day and year.
	var d1 = Date.parse("15");

	// July 1st of current year at 10pm.
	var d1 = Date.parse("7/1 10pm");
	
* * @param {String} The string value to convert into a Date object [Required] * @return {Date} A Date object or null if the string cannot be converted into a Date. */ var parseUtils = { removeOrds: function (s) { ords = s.match(/\b(\d+)(?:st|nd|rd|th)\b/); // find ordinal matches s = ((ords && ords.length === 2) ? s.replace(ords[0], ords[1]) : s); return s; }, grammarParser: function (s) { var r = null; try { r = $D.Grammar.start.call({}, s.replace(/^\s*(\S*(\s+\S+)*)\s*$/, "$1")); } catch (e) { return null; } return ((r[1].length === 0) ? r[0] : null); }, nativeFallback: function(s) { var t; try { // ok we haven't parsed it, last ditch attempt with the built-in parser. t = Date._parse(s); return (t || t === 0) ? new Date(t) : null; } catch (e) { return null; } } }; function parse (s) { var d; if (!s) { return null; } if (s instanceof Date) { return s.clone(); } if (s.length >= 4 && s.charAt(0) !== "0" && s.charAt(0) !== "+"&& s.charAt(0) !== "-") { // ie: 2004 will pass, 0800 won't. // Start with specific formats d = $D.Parsing.ISO.parse(s) || $D.Parsing.Numeric.parse(s); } if (d instanceof Date && !isNaN(d.getTime())) { return d; } else { // find ordinal dates (1st, 3rd, 8th, etc and remove them as they cause parsing issues) s = $D.Parsing.Normalizer.parse(parseUtils.removeOrds(s)); d = parseUtils.grammarParser(s); if (d !== null) { return d; } else { return parseUtils.nativeFallback(s); } } } if (!$D._parse) { $D._parse = $D.parse; } $D.parse = parse; Date.getParseFunction = function (fx) { var fns = Date.Grammar.allformats(fx); return function (s) { var r = null; for (var i = 0; i < fns.length; i++) { try { r = fns[i].call({}, s); } catch (e) { continue; } if (r[1].length === 0) { return r[0]; } } return null; }; }; /** * Converts the specified string value into its JavaScript Date equivalent using the specified format {String} or formats {Array} and the CultureInfo specific format information. * The format of the string value must match one of the supplied formats exactly. * * Example

	// 15-Oct-2004
	var d1 = Date.parseExact("10/15/2004", "M/d/yyyy");

	// 15-Oct-2004
	var d1 = Date.parse("15-Oct-2004", "M-ddd-yyyy");

	// 15-Oct-2004
	var d1 = Date.parse("2004.10.15", "yyyy.MM.dd");

	// Multiple formats
	var d1 = Date.parseExact("10/15/2004", ["M/d/yyyy", "MMMM d, yyyy"]);
	
* * @param {String} The string value to convert into a Date object [Required]. * @param {Object} The expected format {String} or an array of expected formats {Array} of the date string [Required]. * @return {Date} A Date object or null if the string cannot be converted into a Date. */ $D.parseExact = function (s, fx) { return $D.getParseFunction(fx)(s); }; }()); (function () { var $D = Date, $P = $D.prototype, // $C = $D.CultureInfo, // not used atm p = function (s, l) { if (!l) { l = 2; } return ("000" + s).slice(l * -1); }; /** * Converts a PHP format string to Java/.NET format string. * A PHP format string can be used with ._format or .format. * A Java/.NET format string can be used with .toString(). * The .parseExact function will only accept a Java/.NET format string * * Example * var f1 = "%m/%d/%y" * var f2 = Date.normalizeFormat(f1); // "MM/dd/yy" * * new Date().format(f1); // "04/13/08" * new Date()._format(f1); // "04/13/08" * new Date().toString(f2); // "04/13/08" * * var date = Date.parseExact("04/13/08", f2); // Sun Apr 13 2008 * * @param {String} A PHP format string consisting of one or more format spcifiers. * @return {String} The PHP format converted to a Java/.NET format string. */ var normalizerSubstitutions = { "d" : "dd", "%d": "dd", "D" : "ddd", "%a": "ddd", "j" : "dddd", "l" : "dddd", "%A": "dddd", "S" : "S", "F" : "MMMM", "%B": "MMMM", "m" : "MM", "%m": "MM", "M" : "MMM", "%b": "MMM", "%h": "MMM", "n" : "M", "Y" : "yyyy", "%Y": "yyyy", "y" : "yy", "%y": "yy", "g" : "h", "%I": "h", "G" : "H", "h" : "hh", "H" : "HH", "%H": "HH", "i" : "mm", "%M": "mm", "s" : "ss", "%S": "ss", "%r": "hh:mm tt", "%R": "H:mm", "%T": "H:mm:ss", "%X": "t", "%x": "d", "%e": "d", "%D": "MM/dd/yy", "%n": "\\n", "%t": "\\t", "e" : "z", "T" : "z", "%z": "z", "%Z": "z", "Z" : "ZZ", "N" : "u", "w" : "u", "%w": "u", "W" : "W", "%V": "W" }; var normalizer = { substitutes: function (m) { return normalizerSubstitutions[m]; }, interpreted: function (m, x) { var y; switch (m) { case "%u": return x.getDay() + 1; case "z": return x.getOrdinalNumber(); case "%j": return p(x.getOrdinalNumber(), 3); case "%U": var d1 = x.clone().set({month: 0, day: 1}).addDays(-1).moveToDayOfWeek(0), d2 = x.clone().addDays(1).moveToDayOfWeek(0, -1); return (d2 < d1) ? "00" : p((d2.getOrdinalNumber() - d1.getOrdinalNumber()) / 7 + 1); case "%W": return p(x.getWeek()); case "t": return $D.getDaysInMonth(x.getFullYear(), x.getMonth()); case "o": case "%G": return x.setWeek(x.getISOWeek()).toString("yyyy"); case "%g": return x._format("%G").slice(-2); case "a": case "%p": return t("tt").toLowerCase(); case "A": return t("tt").toUpperCase(); case "u": return p(x.getMilliseconds(), 3); case "I": return (x.isDaylightSavingTime()) ? 1 : 0; case "O": return x.getUTCOffset(); case "P": y = x.getUTCOffset(); return y.substring(0, y.length - 2) + ":" + y.substring(y.length - 2); case "B": var now = new Date(); return Math.floor(((now.getHours() * 3600) + (now.getMinutes() * 60) + now.getSeconds() + (now.getTimezoneOffset() + 60) * 60) / 86.4); case "c": return x.toISOString().replace(/\"/g, ""); case "U": return $D.strtotime("now"); case "%c": return t("d") + " " + t("t"); case "%C": return Math.floor(x.getFullYear() / 100 + 1); } }, shouldOverrideDefaults: function (m) { switch (m) { case "%e": return true; default: return false; } }, parse: function (m, context) { var formatString, c = context || new Date(); formatString = normalizer.substitutes(m); if (formatString) { return formatString; } formatString = normalizer.interpreted(m, c); if (formatString) { return formatString; } else { return m; } } }; $D.normalizeFormat = function (format, context) { return format.replace(/(%|\\)?.|%%/g, function(t){ return normalizer.parse(t, context); }); }; /** * Format a local Unix timestamp according to locale settings * * Example: * Date.strftime("%m/%d/%y", new Date()); // "04/13/08" * Date.strftime("c", "2008-04-13T17:52:03Z"); // "04/13/08" * * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @param {Number|String} The number representing the number of seconds that have elapsed since January 1, 1970 (local time). * @return {String} A string representation of the current Date object. */ $D.strftime = function (format, time) { var d = Date.parse(time); return d._format(format); }; /** * Parse any textual datetime description into a Unix timestamp. * A Unix timestamp is the number of seconds that have elapsed since January 1, 1970 (midnight UTC/GMT). * * Example: * Date.strtotime("04/13/08"); // 1208044800 * Date.strtotime("1970-01-01T00:00:00Z"); // 0 * * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @param {Object} A string or date object. * @return {String} A string representation of the current Date object. */ $D.strtotime = function (time) { var d = $D.parse(time); return Math.round($D.UTC(d.getUTCFullYear(), d.getUTCMonth(), d.getUTCDate(), d.getUTCHours(), d.getUTCMinutes(), d.getUTCSeconds(), d.getUTCMilliseconds()) / 1000); }; /** * Converts the value of the current Date object to its equivalent string representation using a PHP/Unix style of date format specifiers. * Format Specifiers * Format Description Example * ------ --------------------------------------------------------------------------- ----------------------- * %a abbreviated weekday name according to the current localed "Mon" through "Sun" * %A full weekday name according to the current localed "Sunday" through "Saturday" * %b abbreviated month name according to the current localed "Jan" through "Dec" * %B full month name according to the current locale "January" through "December" * %c preferred date and time representation for the current locale "4/13/2008 12:33 PM" * %C century number (the year divided by 100 and truncated to an integer) "00" to "99" * %d day of the month as a decimal number "01" to "31" * %D same as %m/%d/%y "04/13/08" * %e day of the month as a decimal number, a single digit is preceded by a space "1" to "31" * %g like %G, but without the century "08" * %G The 4-digit year corresponding to the ISO week number (see %V). "2008" * This has the same format and value as %Y, except that if the ISO week number * belongs to the previous or next year, that year is used instead. * %h same as %b "Jan" through "Dec" * %H hour as a decimal number using a 24-hour clock. "00" to "23" * %I hour as a decimal number using a 12-hour clock. "01" to "12" * %j day of the year as a decimal number. "001" to "366" * %m month as a decimal number. "01" to "12" * %M minute as a decimal number. "00" to "59" * %n newline character "\n" * %p either "am" or "pm" according to the given time value, or the "am" or "pm" * corresponding strings for the current locale. * %r time in a.m. and p.m. notation "8:44 PM" * %R time in 24 hour notation "20:44" * %S second as a decimal number "00" to "59" * %t tab character "\t" * %T current time, equal to %H:%M:%S "12:49:11" * %u weekday as a decimal number ["1", "7"], with "1" representing Monday "1" to "7" * %U week number of the current year as a decimal number, starting with the "0" to ("52" or "53") * first Sunday as the first day of the first week * %V The ISO 8601:1988 week number of the current year as a decimal number, "00" to ("52" or "53") * range 01 to 53, where week 1 is the first week that has at least 4 days * in the current year, and with Monday as the first day of the week. * (Use %G or %g for the year component that corresponds to the week number * for the specified timestamp.) * %W week number of the current year as a decimal number, starting with the "00" to ("52" or "53") * first Monday as the first day of the first week * %w day of the week as a decimal, Sunday being "0" "0" to "6" * %x preferred date representation for the current locale without the time "4/13/2008" * %X preferred time representation for the current locale without the date "12:53:05" * %y year as a decimal number without a century "00" "99" * %Y year as a decimal number including the century "2008" * %Z time zone or name or abbreviation "UTC", "EST", "PST" * %z same as %Z * %% a literal "%" characters "%" * d Day of the month, 2 digits with leading zeros "01" to "31" * D A textual representation of a day, three letters "Mon" through "Sun" * j Day of the month without leading zeros "1" to "31" * l A full textual representation of the day of the week (lowercase "L") "Sunday" through "Saturday" * N ISO-8601 numeric representation of the day of the week (added in PHP 5.1.0) "1" (for Monday) through "7" (for Sunday) * S English ordinal suffix for the day of the month, 2 characters "st", "nd", "rd" or "th". Works well with j * w Numeric representation of the day of the week "0" (for Sunday) through "6" (for Saturday) * z The day of the year (starting from "0") "0" through "365" * W ISO-8601 week number of year, weeks starting on Monday "00" to ("52" or "53") * F A full textual representation of a month, such as January or March "January" through "December" * m Numeric representation of a month, with leading zeros "01" through "12" * M A short textual representation of a month, three letters "Jan" through "Dec" * n Numeric representation of a month, without leading zeros "1" through "12" * t Number of days in the given month "28" through "31" * L Whether it's a leap year "1" if it is a leap year, "0" otherwise * o ISO-8601 year number. This has the same value as Y, except that if the "2008" * ISO week number (W) belongs to the previous or next year, that year * is used instead. * Y A full numeric representation of a year, 4 digits "2008" * y A two digit representation of a year "08" * a Lowercase Ante meridiem and Post meridiem "am" or "pm" * A Uppercase Ante meridiem and Post meridiem "AM" or "PM" * B Swatch Internet time "000" through "999" * g 12-hour format of an hour without leading zeros "1" through "12" * G 24-hour format of an hour without leading zeros "0" through "23" * h 12-hour format of an hour with leading zeros "01" through "12" * H 24-hour format of an hour with leading zeros "00" through "23" * i Minutes with leading zeros "00" to "59" * s Seconds, with leading zeros "00" through "59" * u Milliseconds "54321" * e Timezone identifier "UTC", "EST", "PST" * I Whether or not the date is in daylight saving time (uppercase i) "1" if Daylight Saving Time, "0" otherwise * O Difference to Greenwich time (GMT) in hours "+0200", "-0600" * P Difference to Greenwich time (GMT) with colon between hours and minutes "+02:00", "-06:00" * T Timezone abbreviation "UTC", "EST", "PST" * Z Timezone offset in seconds. The offset for timezones west of UTC is "-43200" through "50400" * always negative, and for those east of UTC is always positive. * c ISO 8601 date "2004-02-12T15:19:21+00:00" * r RFC 2822 formatted date "Thu, 21 Dec 2000 16:01:07 +0200" * U Seconds since the Unix Epoch (January 1 1970 00:00:00 GMT) "0" * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @return {String} A string representation of the current Date object. */ var formatReplace = function (context) { return function (m) { var formatString, override = false; if (m.charAt(0) === "\\" || m.substring(0, 2) === "%%") { return m.replace("\\", "").replace("%%", "%"); } override = normalizer.shouldOverrideDefaults(m); formatString = $D.normalizeFormat(m, context); if (formatString) { return context.toString(formatString, override); } }; }; $P._format = function (format) { var formatter = formatReplace(this); if (!format) { return this._toString(); } else { return format.replace(/(%|\\)?.|%%/g, formatter); } }; if (!$P.format) { $P.format = $P._format; } }()); (function () { "use strict"; var gFn = function (attr) { return function () { return this[attr]; }; }; var sFn = function (attr) { return function (val) { this[attr] = val; return this; }; }; var attrs = ["years", "months", "days", "hours", "minutes", "seconds", "milliseconds"]; var addSetFuncs = function (context, attrs) { for (var i = 0; i < attrs.length ; i++) { var $a = attrs[i], $b = $a.slice(0, 1).toUpperCase() + $a.slice(1); context.prototype[$a] = 0; context.prototype["get" + $b] = gFn($a); context.prototype["set" + $b] = sFn($a); } }; /** * new TimeSpan(milliseconds); * new TimeSpan(days, hours, minutes, seconds); * new TimeSpan(days, hours, minutes, seconds, milliseconds); */ var TimeSpan = function (days, hours, minutes, seconds, milliseconds) { if (arguments.length === 1 && typeof days === "number") { var orient = (days < 0) ? -1 : +1; var millsLeft = Math.abs(days); this.setDays(Math.floor(millsLeft / 86400000) * orient); millsLeft = millsLeft % 86400000; this.setHours(Math.floor(millsLeft / 3600000) * orient); millsLeft = millsLeft % 3600000; this.setMinutes(Math.floor(millsLeft / 60000) * orient); millsLeft = millsLeft % 60000; this.setSeconds(Math.floor(millsLeft / 1000) * orient); millsLeft = millsLeft % 1000; this.setMilliseconds(millsLeft * orient); } else { this.set(days, hours, minutes, seconds, milliseconds); } this.getTotalMilliseconds = function () { return (this.getDays() * 86400000) + (this.getHours() * 3600000) + (this.getMinutes() * 60000) + (this.getSeconds() * 1000); }; this.compareTo = function (time) { var t1 = new Date(1970, 1, 1, this.getHours(), this.getMinutes(), this.getSeconds()), t2; if (time === null) { t2 = new Date(1970, 1, 1, 0, 0, 0); } else { t2 = new Date(1970, 1, 1, time.getHours(), time.getMinutes(), time.getSeconds()); } return (t1 < t2) ? -1 : (t1 > t2) ? 1 : 0; }; this.equals = function (time) { return (this.compareTo(time) === 0); }; this.add = function (time) { return (time === null) ? this : this.addSeconds(time.getTotalMilliseconds() / 1000); }; this.subtract = function (time) { return (time === null) ? this : this.addSeconds(-time.getTotalMilliseconds() / 1000); }; this.addDays = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 86400000)); }; this.addHours = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 3600000)); }; this.addMinutes = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 60000)); }; this.addSeconds = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 1000)); }; this.addMilliseconds = function (n) { return new TimeSpan(this.getTotalMilliseconds() + n); }; this.get12HourHour = function () { return (this.getHours() > 12) ? this.getHours() - 12 : (this.getHours() === 0) ? 12 : this.getHours(); }; this.getDesignator = function () { return (this.getHours() < 12) ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator; }; this.toString = function (format) { this._toString = function () { if (this.getDays() !== null && this.getDays() > 0) { return this.getDays() + "." + this.getHours() + ":" + this.p(this.getMinutes()) + ":" + this.p(this.getSeconds()); } else { return this.getHours() + ":" + this.p(this.getMinutes()) + ":" + this.p(this.getSeconds()); } }; this.p = function (s) { return (s.toString().length < 2) ? "0" + s : s; }; var me = this; return format ? format.replace(/dd?|HH?|hh?|mm?|ss?|tt?/g, function (format) { switch (format) { case "d": return me.getDays(); case "dd": return me.p(me.getDays()); case "H": return me.getHours(); case "HH": return me.p(me.getHours()); case "h": return me.get12HourHour(); case "hh": return me.p(me.get12HourHour()); case "m": return me.getMinutes(); case "mm": return me.p(me.getMinutes()); case "s": return me.getSeconds(); case "ss": return me.p(me.getSeconds()); case "t": return ((me.getHours() < 12) ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator).substring(0, 1); case "tt": return (me.getHours() < 12) ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator; } } ) : this._toString(); }; return this; }; addSetFuncs(TimeSpan, attrs.slice(2)); TimeSpan.prototype.set = function (days, hours, minutes, seconds, milliseconds){ this.setDays(days || this.getDays()); this.setHours(hours || this.getHours()); this.setMinutes(minutes || this.getMinutes()); this.setSeconds(seconds || this.getSeconds()); this.setMilliseconds(milliseconds || this.getMilliseconds()); }; /** * Gets the time of day for this date instances. * @return {TimeSpan} TimeSpan */ Date.prototype.getTimeOfDay = function () { return new TimeSpan(0, this.getHours(), this.getMinutes(), this.getSeconds(), this.getMilliseconds()); }; Date.TimeSpan = TimeSpan; if (typeof window !== "undefined" ) { // keeping API compatible for v1.x window.TimeSpan = TimeSpan; } }()); (function () { "use strict"; var attrs = ["years", "months", "days", "hours", "minutes", "seconds", "milliseconds"]; var gFn = function (attr) { return function () { return this[attr]; }; }; var sFn = function (attr) { return function (val) { this[attr] = val; return this; }; }; var addSetFuncs = function (context, attrs) { for (var i = 0; i < attrs.length ; i++) { var $a = attrs[i], $b = $a.slice(0, 1).toUpperCase() + $a.slice(1); context.prototype[$a] = 0; context.prototype["get" + $b] = gFn($a); context.prototype["set" + $b] = sFn($a); } }; var setMonthsAndYears = function (orient, d1, d2, context) { function inc() { d1.addMonths(-orient); context.months++; if (context.months === 12) { context.years++; context.months = 0; } } if (orient === +1) { while (d1 > d2) { inc(); } } else { while (d1 < d2) { inc(); } } context.months--; context.months *= orient; context.years *= orient; }; var adjustForDST = function(orient, startDate, endDate) { var hasDSTMismatch = (false === (startDate.isDaylightSavingTime() === endDate.isDaylightSavingTime())); if (hasDSTMismatch && orient === 1) { startDate.addHours(-1); } else if (hasDSTMismatch) { startDate.addHours(1); } }; /** * TimePeriod(startDate, endDate); * TimePeriod(years, months, days, hours, minutes, seconds, milliseconds); */ var TimePeriod = function (years, months, days, hours, minutes, seconds, milliseconds) { if (arguments.length === 7) { this.set(years, months, days, hours, minutes, seconds, milliseconds); } else if (arguments.length === 2 && arguments[0] instanceof Date && arguments[1] instanceof Date) { var startDate = arguments[0].clone(); var endDate = arguments[1].clone(); var orient = (startDate > endDate) ? +1 : -1; this.dates = { start: arguments[0].clone(), end: arguments[1].clone() }; setMonthsAndYears(orient, startDate, endDate, this); adjustForDST(orient, startDate, endDate); // // TODO - adjust for DST var diff = endDate - startDate; if (diff !== 0) { var ts = new TimeSpan(diff); this.set(this.years, this.months, ts.getDays(), ts.getHours(), ts.getMinutes(), ts.getSeconds(), ts.getMilliseconds()); } } return this; }; // create all the set functions. addSetFuncs(TimePeriod, attrs); TimePeriod.prototype.set = function (years, months, days, hours, minutes, seconds, milliseconds){ this.setYears(years || this.getYears()); this.setMonths(months || this.getMonths()); this.setDays(days || this.getDays()); this.setHours(hours || this.getHours()); this.setMinutes(minutes || this.getMinutes()); this.setSeconds(seconds || this.getSeconds()); this.setMilliseconds(milliseconds || this.getMilliseconds()); }; Date.TimePeriod = TimePeriod; if (typeof window !== "undefined") { // keeping API compatible for v1.x window.TimePeriod = TimePeriod; } }()); ================================================ FILE: build/date-ja-JP.js ================================================ /** * @overview datejs * @version 1.0.0-rc3 * @author Gregory Wild-Smith * @copyright 2015 Gregory Wild-Smith * @license MIT * @homepage https://github.com/abritinthebay/datejs */ /* * DateJS Culture String File * Country Code: ja-JP * Name: Japanese (Japan) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["ja-JP"] = { "name": "ja-JP", "englishName": "Japanese (Japan)", "nativeName": "日本語 (日本)", "Sunday": "日曜日", "Monday": "月曜日", "Tuesday": "火曜日", "Wednesday": "水曜日", "Thursday": "木曜日", "Friday": "金曜日", "Saturday": "土曜日", "Sun": "日", "Mon": "月", "Tue": "火", "Wed": "水", "Thu": "木", "Fri": "金", "Sat": "土", "Su": "日", "Mo": "月", "Tu": "火", "We": "水", "Th": "木", "Fr": "金", "Sa": "土", "S_Sun_Initial": "日", "M_Mon_Initial": "月", "T_Tue_Initial": "火", "W_Wed_Initial": "水", "T_Thu_Initial": "木", "F_Fri_Initial": "金", "S_Sat_Initial": "土", "January": "1月", "February": "2月", "March": "3月", "April": "4月", "May": "5月", "June": "6月", "July": "7月", "August": "8月", "September": "9月", "October": "10月", "November": "11月", "December": "12月", "Jan_Abbr": "1", "Feb_Abbr": "2", "Mar_Abbr": "3", "Apr_Abbr": "4", "May_Abbr": "5", "Jun_Abbr": "6", "Jul_Abbr": "7", "Aug_Abbr": "8", "Sep_Abbr": "9", "Oct_Abbr": "10", "Nov_Abbr": "11", "Dec_Abbr": "12", "AM": "午前", "PM": "午後", "firstDayOfWeek": 0, "twoDigitYearMax": 2029, "mdy": "ymd", "M/d/yyyy": "yyyy/MM/dd", "dddd, MMMM dd, yyyy": "yyyy'年'M'月'd'日'", "h:mm tt": "H:mm", "h:mm:ss tt": "H:mm:ss", "dddd, MMMM dd, yyyy h:mm:ss tt": "yyyy'年'M'月'd'日' H:mm:ss", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "M'月'd'日'", "MMMM, yyyy": "yyyy'年'M'月'", "/jan(uary)?/": "1(月)?", "/feb(ruary)?/": "2(月)?", "/mar(ch)?/": "3(月)?", "/apr(il)?/": "4(月)?", "/may/": "5(月)?", "/jun(e)?/": "6(月)?", "/jul(y)?/": "7(月)?", "/aug(ust)?/": "8(月)?", "/sep(t(ember)?)?/": "9(月)?", "/oct(ober)?/": "10(月)?", "/nov(ember)?/": "11(月)?", "/dec(ember)?/": "12(月)?", "/^su(n(day)?)?/": "^日曜日", "/^mo(n(day)?)?/": "^月曜日", "/^tu(e(s(day)?)?)?/": "^火曜日", "/^we(d(nesday)?)?/": "^水曜日", "/^th(u(r(s(day)?)?)?)?/": "^木曜日", "/^fr(i(day)?)?/": "^金曜日", "/^sa(t(urday)?)?/": "^土曜日", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "ja-JP"; /** * @overview datejs * @version 1.0.0-rc3 * @author Gregory Wild-Smith * @copyright 2015 Gregory Wild-Smith * @license MIT * @homepage https://github.com/abritinthebay/datejs */(function () { var $D = Date; var lang = Date.CultureStrings ? Date.CultureStrings.lang : null; var loggedKeys = {}; // for debug purposes. var getText = { getFromKey: function (key, countryCode) { var output; if (Date.CultureStrings && Date.CultureStrings[countryCode] && Date.CultureStrings[countryCode][key]) { output = Date.CultureStrings[countryCode][key]; } else { output = getText.buildFromDefault(key); } if (key.charAt(0) === "/") { // Assume it's a regex output = getText.buildFromRegex(key, countryCode); } return output; }, getFromObjectValues: function (obj, countryCode) { var key, output = {}; for(key in obj) { if (obj.hasOwnProperty(key)) { output[key] = getText.getFromKey(obj[key], countryCode); } } return output; }, getFromObjectKeys: function (obj, countryCode) { var key, output = {}; for(key in obj) { if (obj.hasOwnProperty(key)) { output[getText.getFromKey(key, countryCode)] = obj[key]; } } return output; }, getFromArray: function (arr, countryCode) { var output = []; for (var i=0; i < arr.length; i++){ if (i in arr) { output[i] = getText.getFromKey(arr[i], countryCode); } } return output; }, buildFromDefault: function (key) { var output, length, split, last; switch(key) { case "name": output = "en-US"; break; case "englishName": output = "English (United States)"; break; case "nativeName": output = "English (United States)"; break; case "twoDigitYearMax": output = 2049; break; case "firstDayOfWeek": output = 0; break; default: output = key; split = key.split("_"); length = split.length; if (length > 1 && key.charAt(0) !== "/") { // if the key isn't a regex and it has a split. last = split[(length - 1)].toLowerCase(); if (last === "initial" || last === "abbr") { output = split[0]; } } break; } return output; }, buildFromRegex: function (key, countryCode) { var output; if (Date.CultureStrings && Date.CultureStrings[countryCode] && Date.CultureStrings[countryCode][key]) { output = new RegExp(Date.CultureStrings[countryCode][key], "i"); } else { output = new RegExp(key.replace(new RegExp("/", "g"),""), "i"); } return output; } }; var shallowMerge = function (obj1, obj2) { for (var attrname in obj2) { if (obj2.hasOwnProperty(attrname)) { obj1[attrname] = obj2[attrname]; } } }; var __ = function (key, language) { var countryCode = (language) ? language : lang; loggedKeys[key] = key; if (typeof key === "object") { if (key instanceof Array) { return getText.getFromArray(key, countryCode); } else { return getText.getFromObjectKeys(key, countryCode); } } else { return getText.getFromKey(key, countryCode); } }; var loadI18nScript = function (code) { // paatterned after jQuery's getScript. var url = Date.Config.i18n + code + ".js"; var head = document.getElementsByTagName("head")[0] || document.documentElement; var script = document.createElement("script"); script.src = url; var completed = false; var events = { done: function (){} // placeholder function }; // Attach handlers for all browsers script.onload = script.onreadystatechange = function() { if ( !completed && (!this.readyState || this.readyState === "loaded" || this.readyState === "complete") ) { events.done(); head.removeChild(script); } }; setTimeout(function() { head.insertBefore(script, head.firstChild); }, 0); // allows return to execute first return { done: function (cb) { events.done = function() { if (cb) { setTimeout(cb,0); } }; } }; }; var buildInfo = { buildFromMethodHash: function (obj) { var key; for(key in obj) { if (obj.hasOwnProperty(key)) { obj[key] = buildInfo[obj[key]](); } } return obj; }, timeZoneDST: function () { var DST = { "CHADT": "+1345", "NZDT": "+1300", "AEDT": "+1100", "ACDT": "+1030", "AZST": "+0500", "IRDT": "+0430", "EEST": "+0300", "CEST": "+0200", "BST": "+0100", "PMDT": "-0200", "ADT": "-0300", "NDT": "-0230", "EDT": "-0400", "CDT": "-0500", "MDT": "-0600", "PDT": "-0700", "AKDT": "-0800", "HADT": "-0900" }; return __(DST); }, timeZoneStandard: function () { var standard = { "LINT": "+1400", "TOT": "+1300", "CHAST": "+1245", "NZST": "+1200", "NFT": "+1130", "SBT": "+1100", "AEST": "+1000", "ACST": "+0930", "JST": "+0900", "CWST": "+0845", "CT": "+0800", "ICT": "+0700", "MMT": "+0630", "BST": "+0600", "NPT": "+0545", "IST": "+0530", "PKT": "+0500", "AFT": "+0430", "MSK": "+0400", "IRST": "+0330", "FET": "+0300", "EET": "+0200", "CET": "+0100", "GMT": "+0000", "UTC": "+0000", "CVT": "-0100", "GST": "-0200", "BRT": "-0300", "NST": "-0330", "AST": "-0400", "EST": "-0500", "CST": "-0600", "MST": "-0700", "PST": "-0800", "AKST": "-0900", "MIT": "-0930", "HST": "-1000", "SST": "-1100", "BIT": "-1200" }; return __(standard); }, timeZones: function (data) { var zone; data.timezones = []; for (zone in data.abbreviatedTimeZoneStandard) { if (data.abbreviatedTimeZoneStandard.hasOwnProperty(zone)) { data.timezones.push({ name: zone, offset: data.abbreviatedTimeZoneStandard[zone]}); } } for (zone in data.abbreviatedTimeZoneDST) { if (data.abbreviatedTimeZoneDST.hasOwnProperty(zone)) { data.timezones.push({ name: zone, offset: data.abbreviatedTimeZoneDST[zone], dst: true}); } } return data.timezones; }, days: function () { return __(["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"]); }, dayAbbr: function () { return __(["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"]); }, dayShortNames: function () { return __(["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"]); }, dayFirstLetters: function () { return __(["S_Sun_Initial", "M_Mon_Initial", "T_Tues_Initial", "W_Wed_Initial", "T_Thu_Initial", "F_Fri_Initial", "S_Sat_Initial"]); }, months: function () { return __(["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"]); }, monthAbbr: function () { return __(["Jan_Abbr", "Feb_Abbr", "Mar_Abbr", "Apr_Abbr", "May_Abbr", "Jun_Abbr", "Jul_Abbr", "Aug_Abbr", "Sep_Abbr", "Oct_Abbr", "Nov_Abbr", "Dec_Abbr"]); }, formatPatterns: function () { return getText.getFromObjectValues({ shortDate: "M/d/yyyy", longDate: "dddd, MMMM dd, yyyy", shortTime: "h:mm tt", longTime: "h:mm:ss tt", fullDateTime: "dddd, MMMM dd, yyyy h:mm:ss tt", sortableDateTime: "yyyy-MM-ddTHH:mm:ss", universalSortableDateTime: "yyyy-MM-dd HH:mm:ssZ", rfc1123: "ddd, dd MMM yyyy HH:mm:ss", monthDay: "MMMM dd", yearMonth: "MMMM, yyyy" }, Date.i18n.currentLanguage()); }, regex: function () { return getText.getFromObjectValues({ inTheMorning: "/( in the )(morn(ing)?)\\b/", thisMorning: "/(this )(morn(ing)?)\\b/", amThisMorning: "/(\b\\d(am)? )(this )(morn(ing)?)/", inTheEvening: "/( in the )(even(ing)?)\\b/", thisEvening: "/(this )(even(ing)?)\\b/", pmThisEvening: "/(\b\\d(pm)? )(this )(even(ing)?)/", jan: "/jan(uary)?/", feb: "/feb(ruary)?/", mar: "/mar(ch)?/", apr: "/apr(il)?/", may: "/may/", jun: "/jun(e)?/", jul: "/jul(y)?/", aug: "/aug(ust)?/", sep: "/sep(t(ember)?)?/", oct: "/oct(ober)?/", nov: "/nov(ember)?/", dec: "/dec(ember)?/", sun: "/^su(n(day)?)?/", mon: "/^mo(n(day)?)?/", tue: "/^tu(e(s(day)?)?)?/", wed: "/^we(d(nesday)?)?/", thu: "/^th(u(r(s(day)?)?)?)?/", fri: "/fr(i(day)?)?/", sat: "/^sa(t(urday)?)?/", future: "/^next/", past: "/^last|past|prev(ious)?/", add: "/^(\\+|aft(er)?|from|hence)/", subtract: "/^(\\-|bef(ore)?|ago)/", yesterday: "/^yes(terday)?/", today: "/^t(od(ay)?)?/", tomorrow: "/^tom(orrow)?/", now: "/^n(ow)?/", millisecond: "/^ms|milli(second)?s?/", second: "/^sec(ond)?s?/", minute: "/^mn|min(ute)?s?/", hour: "/^h(our)?s?/", week: "/^w(eek)?s?/", month: "/^m(onth)?s?/", day: "/^d(ay)?s?/", year: "/^y(ear)?s?/", shortMeridian: "/^(a|p)/", longMeridian: "/^(a\\.?m?\\.?|p\\.?m?\\.?)/", timezone: "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/", ordinalSuffix: "/^\\s*(st|nd|rd|th)/", timeContext: "/^\\s*(\\:|a(?!u|p)|p)/" }, Date.i18n.currentLanguage()); } }; var CultureInfo = function () { var info = getText.getFromObjectValues({ name: "name", englishName: "englishName", nativeName: "nativeName", amDesignator: "AM", pmDesignator: "PM", firstDayOfWeek: "firstDayOfWeek", twoDigitYearMax: "twoDigitYearMax", dateElementOrder: "mdy" }, Date.i18n.currentLanguage()); var constructedInfo = buildInfo.buildFromMethodHash({ dayNames: "days", abbreviatedDayNames: "dayAbbr", shortestDayNames: "dayShortNames", firstLetterDayNames: "dayFirstLetters", monthNames: "months", abbreviatedMonthNames: "monthAbbr", formatPatterns: "formatPatterns", regexPatterns: "regex", abbreviatedTimeZoneDST: "timeZoneDST", abbreviatedTimeZoneStandard: "timeZoneStandard" }); shallowMerge(info, constructedInfo); buildInfo.timeZones(info); return info; }; $D.i18n = { __: function (key, lang) { return __(key, lang); }, currentLanguage: function () { return lang || "en-US"; }, setLanguage: function (code, force, cb) { var async = false; if (force || code === "en-US" || (!!Date.CultureStrings && !!Date.CultureStrings[code])) { lang = code; Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings.lang = code; Date.CultureInfo = new CultureInfo(); } else { if (!(!!Date.CultureStrings && !!Date.CultureStrings[code])) { if (typeof exports !== "undefined" && this.exports !== exports) { // we're in a Node enviroment, load it using require try { require("../i18n/" + code + ".js"); lang = code; Date.CultureStrings.lang = code; Date.CultureInfo = new CultureInfo(); } catch (e) { // var str = "The language for '" + code + "' could not be loaded by Node. It likely does not exist."; throw new Error("The DateJS IETF language tag '" + code + "' could not be loaded by Node. It likely does not exist."); } } else if (Date.Config && Date.Config.i18n) { // we know the location of the files, so lets load them async = true; loadI18nScript(code).done(function(){ lang = code; Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings.lang = code; Date.CultureInfo = new CultureInfo(); $D.Parsing.Normalizer.buildReplaceData(); // because this is async if ($D.Grammar) { $D.Grammar.buildGrammarFormats(); // so we can parse those strings... } if (cb) { setTimeout(cb,0); } }); } else { Date.console.error("The DateJS IETF language tag '" + code + "' is not available and has not been loaded."); return false; } } } $D.Parsing.Normalizer.buildReplaceData(); // rebuild normalizer strings if ($D.Grammar) { $D.Grammar.buildGrammarFormats(); // so we can parse those strings... } if (!async && cb) { setTimeout(cb,0); } }, getLoggedKeys: function () { return loggedKeys; }, updateCultureInfo: function () { Date.CultureInfo = new CultureInfo(); } }; $D.i18n.updateCultureInfo(); // run automatically }()); (function () { var $D = Date, $P = $D.prototype, p = function (s, l) { if (!l) { l = 2; } return ("000" + s).slice(l * -1); }; if (typeof window !== "undefined" && typeof window.console !== "undefined" && typeof window.console.log !== "undefined") { $D.console = console; // used only to raise non-critical errors if available } else { // set mock so we don't give errors. $D.console = { log: function(){}, error: function(){} }; } $D.Config = $D.Config || {}; $D.initOverloads = function() { /** * Overload of Date.now. Allows an alternate call for Date.now where it returns the * current Date as an object rather than just milliseconds since the Unix Epoch. * * Also provides an implementation of now() for browsers (IE<9) that don't have it. * * Backwards compatible so with work with either: * Date.now() [returns ms] * or * Date.now(true) [returns Date] */ if (!$D.now) { $D._now = function now() { return new Date().getTime(); }; } else if (!$D._now) { $D._now = $D.now; } $D.now = function (returnObj) { if (returnObj) { return $D.present(); } else { return $D._now(); } }; if ( !$P.toISOString ) { $P.toISOString = function() { return this.getUTCFullYear() + "-" + p(this.getUTCMonth() + 1) + "-" + p(this.getUTCDate()) + "T" + p(this.getUTCHours()) + ":" + p(this.getUTCMinutes()) + ":" + p(this.getUTCSeconds()) + "." + String( (this.getUTCMilliseconds()/1000).toFixed(3)).slice(2, 5) + "Z"; }; } // private if ( $P._toString === undefined ){ $P._toString = $P.toString; } }; $D.initOverloads(); /** * Gets a date that is set to the current date. The time is set to the start of the day (00:00 or 12:00 AM). * @return {Date} The current date. */ $D.today = function () { return new Date().clearTime(); }; /** * Gets a date that is set to the current date and time (same as new Date, but chainable) * @return {Date} The current date. */ $D.present = function () { return new Date(); }; /** * Compares the first date to the second date and returns an number indication of their relative values. * @param {Date} First Date object to compare [Required]. * @param {Date} Second Date object to compare to [Required]. * @return {Number} -1 = date1 is lessthan date2. 0 = values are equal. 1 = date1 is greaterthan date2. */ $D.compare = function (date1, date2) { if (isNaN(date1) || isNaN(date2)) { throw new Error(date1 + " - " + date2); } else if (date1 instanceof Date && date2 instanceof Date) { return (date1 < date2) ? -1 : (date1 > date2) ? 1 : 0; } else { throw new TypeError(date1 + " - " + date2); } }; /** * Compares the first Date object to the second Date object and returns true if they are equal. * @param {Date} First Date object to compare [Required] * @param {Date} Second Date object to compare to [Required] * @return {Boolean} true if dates are equal. false if they are not equal. */ $D.equals = function (date1, date2) { return (date1.compareTo(date2) === 0); }; /** * Gets the language appropriate day name when given the day number(0-6) * eg - 0 == Sunday * @return {String} The day name */ $D.getDayName = function (n) { return Date.CultureInfo.dayNames[n]; }; /** * Gets the day number (0-6) if given a CultureInfo specific string which is a valid dayName, abbreviatedDayName or shortestDayName (two char). * @param {String} The name of the day (eg. "Monday, "Mon", "tuesday", "tue", "We", "we"). * @return {Number} The day number */ $D.getDayNumberFromName = function (name) { var n = Date.CultureInfo.dayNames, m = Date.CultureInfo.abbreviatedDayNames, o = Date.CultureInfo.shortestDayNames, s = name.toLowerCase(); for (var i = 0; i < n.length; i++) { if (n[i].toLowerCase() === s || m[i].toLowerCase() === s || o[i].toLowerCase() === s) { return i; } } return -1; }; /** * Gets the month number (0-11) if given a Culture Info specific string which is a valid monthName or abbreviatedMonthName. * @param {String} The name of the month (eg. "February, "Feb", "october", "oct"). * @return {Number} The day number */ $D.getMonthNumberFromName = function (name) { var n = Date.CultureInfo.monthNames, m = Date.CultureInfo.abbreviatedMonthNames, s = name.toLowerCase(); for (var i = 0; i < n.length; i++) { if (n[i].toLowerCase() === s || m[i].toLowerCase() === s) { return i; } } return -1; }; /** * Gets the language appropriate month name when given the month number(0-11) * eg - 0 == January * @return {String} The month name */ $D.getMonthName = function (n) { return Date.CultureInfo.monthNames[n]; }; /** * Determines if the current date instance is within a LeapYear. * @param {Number} The year. * @return {Boolean} true if date is within a LeapYear, otherwise false. */ $D.isLeapYear = function (year) { return ((year % 4 === 0 && year % 100 !== 0) || year % 400 === 0); }; /** * Gets the number of days in the month, given a year and month value. Automatically corrects for LeapYear. * @param {Number} The year. * @param {Number} The month (0-11). * @return {Number} The number of days in the month. */ $D.getDaysInMonth = function (year, month) { if (!month && $D.validateMonth(year)) { month = year; year = Date.today().getFullYear(); } return [31, ($D.isLeapYear(year) ? 29 : 28), 31, 30, 31, 30, 31, 31, 30, 31, 30, 31][month]; }; $P.getDaysInMonth = function () { return $D.getDaysInMonth(this.getFullYear(), this.getMonth()); }; $D.getTimezoneAbbreviation = function (offset, dst) { var p, n = (dst || false) ? Date.CultureInfo.abbreviatedTimeZoneDST : Date.CultureInfo.abbreviatedTimeZoneStandard; for (p in n) { if (n.hasOwnProperty(p)) { if (n[p] === offset) { return p; } } } return null; }; $D.getTimezoneOffset = function (name, dst) { var i, a =[], z = Date.CultureInfo.timezones; if (!name) { name = (new Date()).getTimezone();} for (i = 0; i < z.length; i++) { if (z[i].name === name.toUpperCase()) { a.push(i); } } if (!z[a[0]]) { return null; } if (a.length === 1 || !dst) { return z[a[0]].offset; } else { for (i=0; i < a.length; i++) { if (z[a[i]].dst) { return z[a[i]].offset; } } } }; $D.getQuarter = function (d) { d = d || new Date(); // If no date supplied, use today var q = [1,2,3,4]; return q[Math.floor(d.getMonth() / 3)]; // ~~~ is a bitwise op. Faster than Math.floor }; $D.getDaysLeftInQuarter = function (d) { d = d || new Date(); var qEnd = new Date(d); qEnd.setMonth(qEnd.getMonth() + 3 - qEnd.getMonth() % 3, 0); return Math.floor((qEnd - d) / 8.64e7); }; // private var validate = function (n, min, max, name) { name = name ? name : "Object"; if (typeof n === "undefined") { return false; } else if (typeof n !== "number") { throw new TypeError(n + " is not a Number."); } else if (n < min || n > max) { // As failing validation is *not* an exceptional circumstance // lets not throw a RangeError Exception here. // It's semantically correct but it's not sensible. return false; } return true; }; /** * Validates the number is within an acceptable range for milliseconds [0-999]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateMillisecond = function (value) { return validate(value, 0, 999, "millisecond"); }; /** * Validates the number is within an acceptable range for seconds [0-59]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateSecond = function (value) { return validate(value, 0, 59, "second"); }; /** * Validates the number is within an acceptable range for minutes [0-59]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateMinute = function (value) { return validate(value, 0, 59, "minute"); }; /** * Validates the number is within an acceptable range for hours [0-23]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateHour = function (value) { return validate(value, 0, 23, "hour"); }; /** * Validates the number is within an acceptable range for the days in a month [0-MaxDaysInMonth]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateDay = function (value, year, month) { if (year === undefined || year === null || month === undefined || month === null) { return false;} return validate(value, 1, $D.getDaysInMonth(year, month), "day"); }; /** * Validates the number is within an acceptable range for months [0-11]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateWeek = function (value) { return validate(value, 0, 53, "week"); }; /** * Validates the number is within an acceptable range for months [0-11]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateMonth = function (value) { return validate(value, 0, 11, "month"); }; /** * Validates the number is within an acceptable range for years. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateYear = function (value) { /** * Per ECMAScript spec the range of times supported by Date objects is * exactly -100,000,000 days to +100,000,000 days measured relative to * midnight at the beginning of 01 January, 1970 UTC. * This gives a range of 8,640,000,000,000,000 milliseconds to either * side of 01 January, 1970 UTC. * * Earliest possible date: Tue, 20 Apr 271,822 B.C. 00:00:00 UTC * Latest possible date: Sat, 13 Sep 275,760 00:00:00 UTC */ return validate(value, -271822, 275760, "year"); }; $D.validateTimezone = function(value) { var timezones = {"ACDT":1,"ACST":1,"ACT":1,"ADT":1,"AEDT":1,"AEST":1,"AFT":1,"AKDT":1,"AKST":1,"AMST":1,"AMT":1,"ART":1,"AST":1,"AWDT":1,"AWST":1,"AZOST":1,"AZT":1,"BDT":1,"BIOT":1,"BIT":1,"BOT":1,"BRT":1,"BST":1,"BTT":1,"CAT":1,"CCT":1,"CDT":1,"CEDT":1,"CEST":1,"CET":1,"CHADT":1,"CHAST":1,"CHOT":1,"ChST":1,"CHUT":1,"CIST":1,"CIT":1,"CKT":1,"CLST":1,"CLT":1,"COST":1,"COT":1,"CST":1,"CT":1,"CVT":1,"CWST":1,"CXT":1,"DAVT":1,"DDUT":1,"DFT":1,"EASST":1,"EAST":1,"EAT":1,"ECT":1,"EDT":1,"EEDT":1,"EEST":1,"EET":1,"EGST":1,"EGT":1,"EIT":1,"EST":1,"FET":1,"FJT":1,"FKST":1,"FKT":1,"FNT":1,"GALT":1,"GAMT":1,"GET":1,"GFT":1,"GILT":1,"GIT":1,"GMT":1,"GST":1,"GYT":1,"HADT":1,"HAEC":1,"HAST":1,"HKT":1,"HMT":1,"HOVT":1,"HST":1,"ICT":1,"IDT":1,"IOT":1,"IRDT":1,"IRKT":1,"IRST":1,"IST":1,"JST":1,"KGT":1,"KOST":1,"KRAT":1,"KST":1,"LHST":1,"LINT":1,"MAGT":1,"MART":1,"MAWT":1,"MDT":1,"MET":1,"MEST":1,"MHT":1,"MIST":1,"MIT":1,"MMT":1,"MSK":1,"MST":1,"MUT":1,"MVT":1,"MYT":1,"NCT":1,"NDT":1,"NFT":1,"NPT":1,"NST":1,"NT":1,"NUT":1,"NZDT":1,"NZST":1,"OMST":1,"ORAT":1,"PDT":1,"PET":1,"PETT":1,"PGT":1,"PHOT":1,"PHT":1,"PKT":1,"PMDT":1,"PMST":1,"PONT":1,"PST":1,"PYST":1,"PYT":1,"RET":1,"ROTT":1,"SAKT":1,"SAMT":1,"SAST":1,"SBT":1,"SCT":1,"SGT":1,"SLST":1,"SRT":1,"SST":1,"SYOT":1,"TAHT":1,"THA":1,"TFT":1,"TJT":1,"TKT":1,"TLT":1,"TMT":1,"TOT":1,"TVT":1,"UCT":1,"ULAT":1,"UTC":1,"UYST":1,"UYT":1,"UZT":1,"VET":1,"VLAT":1,"VOLT":1,"VOST":1,"VUT":1,"WAKT":1,"WAST":1,"WAT":1,"WEDT":1,"WEST":1,"WET":1,"WST":1,"YAKT":1,"YEKT":1,"Z":1}; return (timezones[value] === 1); }; $D.validateTimezoneOffset= function(value) { // timezones go from +14hrs to -12hrs, the +X hours are negative offsets. return (value > -841 && value < 721); }; }()); (function () { var $D = Date, $P = $D.prototype, p = function (s, l) { if (!l) { l = 2; } return ("000" + s).slice(l * -1); }; var validateConfigObject = function (obj) { var result = {}, self = this, prop, testFunc; testFunc = function (prop, func, value) { if (prop === "day") { var month = (obj.month !== undefined) ? obj.month : self.getMonth(); var year = (obj.year !== undefined) ? obj.year : self.getFullYear(); return $D[func](value, year, month); } else { return $D[func](value); } }; for (prop in obj) { if (Object.prototype.hasOwnProperty.call(obj, prop)) { var func = "validate" + prop.charAt(0).toUpperCase() + prop.slice(1); if ($D[func] && obj[prop] !== null && testFunc(prop, func, obj[prop])) { result[prop] = obj[prop]; } } } return result; }; /** * Resets the time of this Date object to 12:00 AM (00:00), which is the start of the day. * @param {Boolean} .clone() this date instance before clearing Time * @return {Date} this */ $P.clearTime = function () { this.setHours(0); this.setMinutes(0); this.setSeconds(0); this.setMilliseconds(0); return this; }; /** * Resets the time of this Date object to the current time ('now'). * @return {Date} this */ $P.setTimeToNow = function () { var n = new Date(); this.setHours(n.getHours()); this.setMinutes(n.getMinutes()); this.setSeconds(n.getSeconds()); this.setMilliseconds(n.getMilliseconds()); return this; }; /** * Returns a new Date object that is an exact date and time copy of the original instance. * @return {Date} A new Date instance */ $P.clone = function () { return new Date(this.getTime()); }; /** * Compares this instance to a Date object and returns an number indication of their relative values. * @param {Date} Date object to compare [Required] * @return {Number} -1 = this is lessthan date. 0 = values are equal. 1 = this is greaterthan date. */ $P.compareTo = function (date) { return Date.compare(this, date); }; /** * Compares this instance to another Date object and returns true if they are equal. * @param {Date} Date object to compare. If no date to compare, new Date() [now] is used. * @return {Boolean} true if dates are equal. false if they are not equal. */ $P.equals = function (date) { return Date.equals(this, (date !== undefined ? date : new Date())); }; /** * Determines if this instance is between a range of two dates or equal to either the start or end dates. * @param {Date} Start of range [Required] * @param {Date} End of range [Required] * @return {Boolean} true is this is between or equal to the start and end dates, else false */ $P.between = function (start, end) { return this.getTime() >= start.getTime() && this.getTime() <= end.getTime(); }; /** * Determines if this date occurs after the date to compare to. * @param {Date} Date object to compare. If no date to compare, new Date() ("now") is used. * @return {Boolean} true if this date instance is greater than the date to compare to (or "now"), otherwise false. */ $P.isAfter = function (date) { return this.compareTo(date || new Date()) === 1; }; /** * Determines if this date occurs before the date to compare to. * @param {Date} Date object to compare. If no date to compare, new Date() ("now") is used. * @return {Boolean} true if this date instance is less than the date to compare to (or "now"). */ $P.isBefore = function (date) { return (this.compareTo(date || new Date()) === -1); }; /** * Determines if the current Date instance occurs today. * @return {Boolean} true if this date instance is 'today', otherwise false. */ /** * Determines if the current Date instance occurs on the same Date as the supplied 'date'. * If no 'date' to compare to is provided, the current Date instance is compared to 'today'. * @param {date} Date object to compare. If no date to compare, the current Date ("now") is used. * @return {Boolean} true if this Date instance occurs on the same Day as the supplied 'date'. */ $P.isToday = $P.isSameDay = function (date) { return this.clone().clearTime().equals((date || new Date()).clone().clearTime()); }; /** * Adds the specified number of milliseconds to this instance. * @param {Number} The number of milliseconds to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addMilliseconds = function (value) { if (!value) { return this; } this.setTime(this.getTime() + value * 1); return this; }; /** * Adds the specified number of seconds to this instance. * @param {Number} The number of seconds to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addSeconds = function (value) { if (!value) { return this; } return this.addMilliseconds(value * 1000); }; /** * Adds the specified number of seconds to this instance. * @param {Number} The number of seconds to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addMinutes = function (value) { if (!value) { return this; } return this.addMilliseconds(value * 60000); // 60*1000 }; /** * Adds the specified number of hours to this instance. * @param {Number} The number of hours to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addHours = function (value) { if (!value) { return this; } return this.addMilliseconds(value * 3600000); // 60*60*1000 }; /** * Adds the specified number of days to this instance. * @param {Number} The number of days to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addDays = function (value) { if (!value) { return this; } this.setDate(this.getDate() + value * 1); return this; }; /** * Adds the specified number of weekdays (ie - not sat or sun) to this instance. * @param {Number} The number of days to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addWeekdays = function (value) { if (!value) { return this; } var day = this.getDay(); var weeks = (Math.ceil(Math.abs(value)/7)); if (day === 0 || day === 6) { if (value > 0) { this.next().monday(); this.addDays(-1); day = this.getDay(); } } if (value < 0) { while (value < 0) { this.addDays(-1); day = this.getDay(); if (day !== 0 && day !== 6) { value++; } } return this; } else if (value > 5 || (6-day) <= value) { value = value + (weeks * 2); } return this.addDays(value); }; /** * Adds the specified number of weeks to this instance. * @param {Number} The number of weeks to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addWeeks = function (value) { if (!value) { return this; } return this.addDays(value * 7); }; /** * Adds the specified number of months to this instance. * @param {Number} The number of months to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addMonths = function (value) { if (!value) { return this; } var n = this.getDate(); this.setDate(1); this.setMonth(this.getMonth() + value * 1); this.setDate(Math.min(n, $D.getDaysInMonth(this.getFullYear(), this.getMonth()))); return this; }; $P.addQuarters = function (value) { if (!value) { return this; } // note this will take you to the same point in the quarter as you are now. // i.e. - if you are 15 days into the quarter you'll be 15 days into the resulting one. // bonus: this allows adding fractional quarters return this.addMonths(value * 3); }; /** * Adds the specified number of years to this instance. * @param {Number} The number of years to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addYears = function (value) { if (!value) { return this; } return this.addMonths(value * 12); }; /** * Adds (or subtracts) to the value of the years, months, weeks, days, hours, minutes, seconds, milliseconds of the date instance using given configuration object. Positive and Negative values allowed. * Example

	Date.today().add( { days: 1, months: 1 } )

	new Date().add( { years: -1 } )
	
* @param {Object} Configuration object containing attributes (months, days, etc.) * @return {Date} this */ $P.add = function (config) { if (typeof config === "number") { this._orient = config; return this; } var x = config; if (x.day) { // If we should be a different date than today (eg: for 'tomorrow -1d', etc). // Should only effect parsing, not direct usage (eg, Finish and FinishExact) if ((x.day - this.getDate()) !== 0) { this.setDate(x.day); } } if (x.milliseconds) { this.addMilliseconds(x.milliseconds); } if (x.seconds) { this.addSeconds(x.seconds); } if (x.minutes) { this.addMinutes(x.minutes); } if (x.hours) { this.addHours(x.hours); } if (x.weeks) { this.addWeeks(x.weeks); } if (x.months) { this.addMonths(x.months); } if (x.years) { this.addYears(x.years); } if (x.days) { this.addDays(x.days); } return this; }; /** * Get the week number. Week one (1) is the week which contains the first Thursday of the year. Monday is considered the first day of the week. * The .getWeek() function does NOT convert the date to UTC. The local datetime is used. * Please use .getISOWeek() to get the week of the UTC converted date. * @return {Number} 1 to 53 */ $P.getWeek = function (utc) { // Create a copy of this date object var self, target = new Date(this.valueOf()); if (utc) { target.addMinutes(target.getTimezoneOffset()); self = target.clone(); } else { self = this; } // ISO week date weeks start on monday // so correct the day number var dayNr = (self.getDay() + 6) % 7; // ISO 8601 states that week 1 is the week // with the first thursday of that year. // Set the target date to the thursday in the target week target.setDate(target.getDate() - dayNr + 3); // Store the millisecond value of the target date var firstThursday = target.valueOf(); // Set the target to the first thursday of the year // First set the target to january first target.setMonth(0, 1); // Not a thursday? Correct the date to the next thursday if (target.getDay() !== 4) { target.setMonth(0, 1 + ((4 - target.getDay()) + 7) % 7); } // The weeknumber is the number of weeks between the // first thursday of the year and the thursday in the target week return 1 + Math.ceil((firstThursday - target) / 604800000); // 604800000 = 7 * 24 * 3600 * 1000 }; /** * Get the ISO 8601 week number. Week one ("01") is the week which contains the first Thursday of the year. Monday is considered the first day of the week. * The .getISOWeek() function does convert the date to it's UTC value. Please use .getWeek() to get the week of the local date. * @return {String} "01" to "53" */ $P.getISOWeek = function () { return p(this.getWeek(true)); }; /** * Moves the date to Monday of the week set. Week one (1) is the week which contains the first Thursday of the year. * @param {Number} A Number (1 to 53) that represents the week of the year. * @return {Date} this */ $P.setWeek = function (n) { if ((n - this.getWeek()) === 0) { if (this.getDay() !== 1) { return this.moveToDayOfWeek(1, (this.getDay() > 1 ? -1 : 1)); } else { return this; } } else { return this.moveToDayOfWeek(1, (this.getDay() > 1 ? -1 : 1)).addWeeks(n - this.getWeek()); } }; $P.setQuarter = function (qtr) { var month = Math.abs(((qtr-1) * 3) + 1); return this.setMonth(month, 1); }; $P.getQuarter = function () { return Date.getQuarter(this); }; $P.getDaysLeftInQuarter = function () { return Date.getDaysLeftInQuarter(this); }; /** * Moves the date to the next n'th occurrence of the dayOfWeek starting from the beginning of the month. The number (-1) is a magic number and will return the last occurrence of the dayOfWeek in the month. * @param {Number} The dayOfWeek to move to * @param {Number} The n'th occurrence to move to. Use (-1) to return the last occurrence in the month * @return {Date} this */ $P.moveToNthOccurrence = function (dayOfWeek, occurrence) { if (dayOfWeek === "Weekday") { if (occurrence > 0) { this.moveToFirstDayOfMonth(); if (this.is().weekday()) { occurrence -= 1; } } else if (occurrence < 0) { this.moveToLastDayOfMonth(); if (this.is().weekday()) { occurrence += 1; } } else { return this; } return this.addWeekdays(occurrence); } var shift = 0; if (occurrence > 0) { shift = occurrence - 1; } else if (occurrence === -1) { this.moveToLastDayOfMonth(); if (this.getDay() !== dayOfWeek) { this.moveToDayOfWeek(dayOfWeek, -1); } return this; } return this.moveToFirstDayOfMonth().addDays(-1).moveToDayOfWeek(dayOfWeek, +1).addWeeks(shift); }; var moveToN = function (getFunc, addFunc, nVal) { return function (value, orient) { var diff = (value - this[getFunc]() + nVal * (orient || +1)) % nVal; return this[addFunc]((diff === 0) ? diff += nVal * (orient || +1) : diff); }; }; /** * Move to the next or last dayOfWeek based on the orient value. * @param {Number} The dayOfWeek to move to * @param {Number} Forward (+1) or Back (-1). Defaults to +1. [Optional] * @return {Date} this */ $P.moveToDayOfWeek = moveToN("getDay", "addDays", 7); /** * Move to the next or last month based on the orient value. * @param {Number} The month to move to. 0 = January, 11 = December * @param {Number} Forward (+1) or Back (-1). Defaults to +1. [Optional] * @return {Date} this */ $P.moveToMonth = moveToN("getMonth", "addMonths", 12); /** * Get the Ordinate of the current day ("th", "st", "rd"). * @return {String} */ $P.getOrdinate = function () { var num = this.getDate(); return ord(num); }; /** * Get the Ordinal day (numeric day number) of the year, adjusted for leap year. * @return {Number} 1 through 365 (366 in leap years) */ $P.getOrdinalNumber = function () { return Math.ceil((this.clone().clearTime() - new Date(this.getFullYear(), 0, 1)) / 86400000) + 1; }; /** * Get the time zone abbreviation of the current date. * @return {String} The abbreviated time zone name (e.g. "EST") */ $P.getTimezone = function () { return $D.getTimezoneAbbreviation(this.getUTCOffset(), this.isDaylightSavingTime()); }; $P.setTimezoneOffset = function (offset) { var here = this.getTimezoneOffset(), there = Number(offset) * -6 / 10; return (there || there === 0) ? this.addMinutes(there - here) : this; }; $P.setTimezone = function (offset) { return this.setTimezoneOffset($D.getTimezoneOffset(offset)); }; /** * Indicates whether Daylight Saving Time is observed in the current time zone. * @return {Boolean} true|false */ $P.hasDaylightSavingTime = function () { return (Date.today().set({month: 0, day: 1}).getTimezoneOffset() !== Date.today().set({month: 6, day: 1}).getTimezoneOffset()); }; /** * Indicates whether this Date instance is within the Daylight Saving Time range for the current time zone. * @return {Boolean} true|false */ $P.isDaylightSavingTime = function () { return Date.today().set({month: 0, day: 1}).getTimezoneOffset() !== this.getTimezoneOffset(); }; /** * Get the offset from UTC of the current date. * @return {String} The 4-character offset string prefixed with + or - (e.g. "-0500") */ $P.getUTCOffset = function (offset) { var n = (offset || this.getTimezoneOffset()) * -10 / 6, r; if (n < 0) { r = (n - 10000).toString(); return r.charAt(0) + r.substr(2); } else { r = (n + 10000).toString(); return "+" + r.substr(1); } }; /** * Returns the number of milliseconds between this date and date. * @param {Date} Defaults to now * @return {Number} The diff in milliseconds */ $P.getElapsed = function (date) { return (date || new Date()) - this; }; /** * Set the value of year, month, day, hour, minute, second, millisecond of date instance using given configuration object. * Example

	Date.today().set( { day: 20, month: 1 } )

	new Date().set( { millisecond: 0 } )
	
* * @param {Object} Configuration object containing attributes (month, day, etc.) * @return {Date} this */ $P.set = function (config) { config = validateConfigObject.call(this, config); var key; for (key in config) { if (Object.prototype.hasOwnProperty.call(config, key)) { var name = key.charAt(0).toUpperCase() + key.slice(1); var addFunc, getFunc; if (key !== "week" && key !== "month" && key !== "timezone" && key !== "timezoneOffset") { name += "s"; } addFunc = "add" + name; getFunc = "get" + name; if (key === "month") { addFunc = addFunc + "s"; } else if (key === "year"){ getFunc = "getFullYear"; } if (key !== "day" && key !== "timezone" && key !== "timezoneOffset" && key !== "week" && key !== "hour") { this[addFunc](config[key] - this[getFunc]()); } else if ( key === "timezone"|| key === "timezoneOffset" || key === "week" || key === "hour") { this["set"+name](config[key]); } } } // day has to go last because you can't validate the day without first knowing the month if (config.day) { this.addDays(config.day - this.getDate()); } return this; }; /** * Moves the date to the first day of the month. * @return {Date} this */ $P.moveToFirstDayOfMonth = function () { return this.set({ day: 1 }); }; /** * Moves the date to the last day of the month. * @return {Date} this */ $P.moveToLastDayOfMonth = function () { return this.set({ day: $D.getDaysInMonth(this.getFullYear(), this.getMonth())}); }; /** * Converts the value of the current Date object to its equivalent string representation. * Format Specifiers * CUSTOM DATE AND TIME FORMAT STRINGS * Format Description Example * ------ --------------------------------------------------------------------------- ----------------------- * s The seconds of the minute between 0-59. "0" to "59" * ss The seconds of the minute with leading zero if required. "00" to "59" * * m The minute of the hour between 0-59. "0" or "59" * mm The minute of the hour with leading zero if required. "00" or "59" * * h The hour of the day between 1-12. "1" to "12" * hh The hour of the day with leading zero if required. "01" to "12" * * H The hour of the day between 0-23. "0" to "23" * HH The hour of the day with leading zero if required. "00" to "23" * * d The day of the month between 1 and 31. "1" to "31" * dd The day of the month with leading zero if required. "01" to "31" * ddd Abbreviated day name. Date.CultureInfo.abbreviatedDayNames. "Mon" to "Sun" * dddd The full day name. Date.CultureInfo.dayNames. "Monday" to "Sunday" * * M The month of the year between 1-12. "1" to "12" * MM The month of the year with leading zero if required. "01" to "12" * MMM Abbreviated month name. Date.CultureInfo.abbreviatedMonthNames. "Jan" to "Dec" * MMMM The full month name. Date.CultureInfo.monthNames. "January" to "December" * * yy The year as a two-digit number. "99" or "08" * yyyy The full four digit year. "1999" or "2008" * * t Displays the first character of the A.M./P.M. designator. "A" or "P" * Date.CultureInfo.amDesignator or Date.CultureInfo.pmDesignator * tt Displays the A.M./P.M. designator. "AM" or "PM" * Date.CultureInfo.amDesignator or Date.CultureInfo.pmDesignator * * S The ordinal suffix ("st, "nd", "rd" or "th") of the current day. "st, "nd", "rd" or "th" * * STANDARD DATE AND TIME FORMAT STRINGS * Format Description Example *------ --------------------------------------------------------------------------- ----------------------- * d The CultureInfo shortDate Format Pattern "M/d/yyyy" * D The CultureInfo longDate Format Pattern "dddd, MMMM dd, yyyy" * F The CultureInfo fullDateTime Format Pattern "dddd, MMMM dd, yyyy h:mm:ss tt" * m The CultureInfo monthDay Format Pattern "MMMM dd" * r The CultureInfo rfc1123 Format Pattern "ddd, dd MMM yyyy HH:mm:ss GMT" * s The CultureInfo sortableDateTime Format Pattern "yyyy-MM-ddTHH:mm:ss" * t The CultureInfo shortTime Format Pattern "h:mm tt" * T The CultureInfo longTime Format Pattern "h:mm:ss tt" * u The CultureInfo universalSortableDateTime Format Pattern "yyyy-MM-dd HH:mm:ssZ" * y The CultureInfo yearMonth Format Pattern "MMMM, yyyy" * * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @return {String} A string representation of the current Date object. */ var ord = function (n) { switch (n * 1) { case 1: case 21: case 31: return "st"; case 2: case 22: return "nd"; case 3: case 23: return "rd"; default: return "th"; } }; var parseStandardFormats = function (format) { var y, c = Date.CultureInfo.formatPatterns; switch (format) { case "d": return this.toString(c.shortDate); case "D": return this.toString(c.longDate); case "F": return this.toString(c.fullDateTime); case "m": return this.toString(c.monthDay); case "r": case "R": y = this.clone().addMinutes(this.getTimezoneOffset()); return y.toString(c.rfc1123) + " GMT"; case "s": return this.toString(c.sortableDateTime); case "t": return this.toString(c.shortTime); case "T": return this.toString(c.longTime); case "u": y = this.clone().addMinutes(this.getTimezoneOffset()); return y.toString(c.universalSortableDateTime); case "y": return this.toString(c.yearMonth); default: return false; } }; var parseFormatStringsClosure = function (context) { return function (m) { if (m.charAt(0) === "\\") { return m.replace("\\", ""); } switch (m) { case "hh": return p(context.getHours() < 13 ? (context.getHours() === 0 ? 12 : context.getHours()) : (context.getHours() - 12)); case "h": return context.getHours() < 13 ? (context.getHours() === 0 ? 12 : context.getHours()) : (context.getHours() - 12); case "HH": return p(context.getHours()); case "H": return context.getHours(); case "mm": return p(context.getMinutes()); case "m": return context.getMinutes(); case "ss": return p(context.getSeconds()); case "s": return context.getSeconds(); case "yyyy": return p(context.getFullYear(), 4); case "yy": return p(context.getFullYear()); case "y": return context.getFullYear(); case "E": case "dddd": return Date.CultureInfo.dayNames[context.getDay()]; case "ddd": return Date.CultureInfo.abbreviatedDayNames[context.getDay()]; case "dd": return p(context.getDate()); case "d": return context.getDate(); case "MMMM": return Date.CultureInfo.monthNames[context.getMonth()]; case "MMM": return Date.CultureInfo.abbreviatedMonthNames[context.getMonth()]; case "MM": return p((context.getMonth() + 1)); case "M": return context.getMonth() + 1; case "t": return context.getHours() < 12 ? Date.CultureInfo.amDesignator.substring(0, 1) : Date.CultureInfo.pmDesignator.substring(0, 1); case "tt": return context.getHours() < 12 ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator; case "S": return ord(context.getDate()); case "W": return context.getWeek(); case "WW": return context.getISOWeek(); case "Q": return "Q" + context.getQuarter(); case "q": return String(context.getQuarter()); case "z": return context.getTimezone(); case "Z": case "X": return Date.getTimezoneOffset(context.getTimezone()); case "ZZ": // Timezone offset in seconds return context.getTimezoneOffset() * -60; case "u": return context.getDay(); case "L": return ($D.isLeapYear(context.getFullYear())) ? 1 : 0; case "B": // Swatch Internet Time (.beats) return "@"+((context.getUTCSeconds() + (context.getUTCMinutes()*60) + ((context.getUTCHours()+1)*3600))/86.4); default: return m; } }; }; $P.toString = function (format, ignoreStandards) { // Standard Date and Time Format Strings. Formats pulled from CultureInfo file and // may vary by culture. if (!ignoreStandards && format && format.length === 1) { output = parseStandardFormats.call(this, format); if (output) { return output; } } var parseFormatStrings = parseFormatStringsClosure(this); return format ? format.replace(/((\\)?(dd?d?d?|MM?M?M?|yy?y?y?|hh?|HH?|mm?|ss?|tt?|S|q|Q|WW?W?W?)(?![^\[]*\]))/g, parseFormatStrings).replace(/\[|\]/g, "") : this._toString(); }; }()); /************************************************************* * SugarPak - Domain Specific Language - Syntactical Sugar * *************************************************************/ (function () { var $D = Date, $P = $D.prototype, $N = Number.prototype; // private $P._orient = +1; // private $P._nth = null; // private $P._is = false; // private $P._same = false; // private $P._isSecond = false; // private $N._dateElement = "days"; /** * Moves the date to the next instance of a date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.today().next().friday();
	Date.today().next().fri();
	Date.today().next().march();
	Date.today().next().mar();
	Date.today().next().week();
	
* * @return {Date} date */ $P.next = function () { this._move = true; this._orient = +1; return this; }; /** * Creates a new Date (Date.today()) and moves the date to the next instance of the date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.next().friday();
	Date.next().fri();
	Date.next().march();
	Date.next().mar();
	Date.next().week();
	
* * @return {Date} date */ $D.next = function () { return $D.today().next(); }; /** * Moves the date to the previous instance of a date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.today().last().friday();
	Date.today().last().fri();
	Date.today().last().march();
	Date.today().last().mar();
	Date.today().last().week();
	
* * @return {Date} date */ $P.last = $P.prev = $P.previous = function () { this._move = true; this._orient = -1; return this; }; /** * Creates a new Date (Date.today()) and moves the date to the previous instance of the date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.last().friday();
	Date.last().fri();
	Date.previous().march();
	Date.prev().mar();
	Date.last().week();
	
* * @return {Date} date */ $D.last = $D.prev = $D.previous = function () { return $D.today().last(); }; /** * Performs a equality check when followed by either a month name, day name or .weekday() function. * Example

	Date.today().is().friday(); // true|false
	Date.today().is().fri();
	Date.today().is().march();
	Date.today().is().mar();
	
* * @return {Boolean} true|false */ $P.is = function () { this._is = true; return this; }; /** * Determines if two date objects occur on/in exactly the same instance of the subsequent date part function. * The function .same() must be followed by a date part function (example: .day(), .month(), .year(), etc). * * An optional Date can be passed in the date part function. If now date is passed as a parameter, 'Now' is used. * * The following example demonstrates how to determine if two dates fall on the exact same day. * * Example

	var d1 = Date.today(); // today at 00:00
	var d2 = new Date();   // exactly now.

	// Do they occur on the same day?
	d1.same().day(d2); // true
	
	// Do they occur on the same hour?
	d1.same().hour(d2); // false, unless d2 hour is '00' (midnight).
	
	// What if it's the same day, but one year apart?
	var nextYear = Date.today().add(1).year();

	d1.same().day(nextYear); // false, because the dates must occur on the exact same day. 
	
* * Scenario: Determine if a given date occurs during some week period 2 months from now. * * Example

	var future = Date.today().add(2).months();
	return someDate.same().week(future); // true|false;
	
* * @return {Boolean} true|false */ $P.same = function () { this._same = true; this._isSecond = false; return this; }; /** * Determines if the current date/time occurs during Today. Must be preceded by the .is() function. * Example

	someDate.is().today();    // true|false
	new Date().is().today();  // true
	Date.today().is().today();// true
	Date.today().add(-1).day().is().today(); // false
	
* * @return {Boolean} true|false */ $P.today = function () { return this.same().day(); }; /** * Determines if the current date is a weekday. This function must be preceded by the .is() function. * Example

	Date.today().is().weekday(); // true|false
	
* * @return {Boolean} true|false */ $P.weekday = function () { if (this._nth) { return df("Weekday").call(this); } if (this._move) { return this.addWeekdays(this._orient); } if (this._is) { this._is = false; return (!this.is().sat() && !this.is().sun()); } return false; }; /** * Determines if the current date is on the weekend. This function must be preceded by the .is() function. * Example

	Date.today().is().weekend(); // true|false
	
* * @return {Boolean} true|false */ $P.weekend = function () { if (this._is) { this._is = false; return (this.is().sat() || this.is().sun()); } return false; }; /** * Sets the Time of the current Date instance. A string "6:15 pm" or config object {hour:18, minute:15} are accepted. * Example

	// Set time to 6:15pm with a String
	Date.today().at("6:15pm");

	// Set time to 6:15pm with a config object
	Date.today().at({hour:18, minute:15});
	
* * @return {Date} date */ $P.at = function (time) { return (typeof time === "string") ? $D.parse(this.toString("d") + " " + time) : this.set(time); }; /** * Creates a new Date() and adds this (Number) to the date based on the preceding date element function (eg. second|minute|hour|day|month|year). * Example

	// Undeclared Numbers must be wrapped with parentheses. Requirment of JavaScript.
	(3).days().fromNow();
	(6).months().fromNow();

	// Declared Number variables do not require parentheses. 
	var n = 6;
	n.months().fromNow();
	
* * @return {Date} A new Date instance */ $N.fromNow = $N.after = function (date) { var c = {}; c[this._dateElement] = this; return ((!date) ? new Date() : date.clone()).add(c); }; /** * Creates a new Date() and subtract this (Number) from the date based on the preceding date element function (eg. second|minute|hour|day|month|year). * Example

	// Undeclared Numbers must be wrapped with parentheses. Requirment of JavaScript.
	(3).days().ago();
	(6).months().ago();

	// Declared Number variables do not require parentheses. 
	var n = 6;
	n.months().ago();
	
* * @return {Date} A new Date instance */ $N.ago = $N.before = function (date) { var c = {}, s = (this._dateElement[this._dateElement.length-1] !== "s") ? this._dateElement + "s" : this._dateElement; c[s] = this * -1; return ((!date) ? new Date() : date.clone()).add(c); }; // Do NOT modify the following string tokens. These tokens are used to build dynamic functions. // All culture-specific strings can be found in the CultureInfo files. var dx = ("sunday monday tuesday wednesday thursday friday saturday").split(/\s/), mx = ("january february march april may june july august september october november december").split(/\s/), px = ("Millisecond Second Minute Hour Day Week Month Year Quarter Weekday").split(/\s/), pxf = ("Milliseconds Seconds Minutes Hours Date Week Month FullYear Quarter").split(/\s/), nth = ("final first second third fourth fifth").split(/\s/), de; /** * Returns an object literal of all the date parts. * Example

	var o = new Date().toObject();
	
	// { year: 2008, month: 4, week: 20, day: 13, hour: 18, minute: 9, second: 32, millisecond: 812 }
	
	// The object properties can be referenced directly from the object.
	
	alert(o.day);  // alerts "13"
	alert(o.year); // alerts "2008"
	
* * @return {Date} An object literal representing the original date object. */ $P.toObject = function () { var o = {}; for (var i = 0; i < px.length; i++) { if (this["get" + pxf[i]]) { o[px[i].toLowerCase()] = this["get" + pxf[i]](); } } return o; }; /** * Returns a date created from an object literal. Ignores the .week property if set in the config. * Example

	var o = new Date().toObject();
	
	return Date.fromObject(o); // will return the same date. 

	var o2 = {month: 1, day: 20, hour: 18}; // birthday party!
	Date.fromObject(o2);
	
* * @return {Date} An object literal representing the original date object. */ $D.fromObject = function(config) { config.week = null; return Date.today().set(config); }; // Create day name functions and abbreviated day name functions (eg. monday(), friday(), fri()). var df = function (n) { return function () { if (this._is) { this._is = false; return this.getDay() === n; } if (this._move) { this._move = null; } if (this._nth !== null) { // If the .second() function was called earlier, remove the _orient // from the date, and then continue. // This is required because 'second' can be used in two different context. // // Example // // Date.today().add(1).second(); // Date.march().second().monday(); // // Things get crazy with the following... // Date.march().add(1).second().second().monday(); // but it works!! // if (this._isSecond) { this.addSeconds(this._orient * -1); } // make sure we reset _isSecond this._isSecond = false; var ntemp = this._nth; this._nth = null; var temp = this.clone().moveToLastDayOfMonth(); this.moveToNthOccurrence(n, ntemp); if (this > temp) { throw new RangeError($D.getDayName(n) + " does not occur " + ntemp + " times in the month of " + $D.getMonthName(temp.getMonth()) + " " + temp.getFullYear() + "."); } return this; } return this.moveToDayOfWeek(n, this._orient); }; }; var sdf = function (n) { return function () { var t = $D.today(), shift = n - t.getDay(); if (n === 0 && Date.CultureInfo.firstDayOfWeek === 1 && t.getDay() !== 0) { shift = shift + 7; } return t.addDays(shift); }; }; // Create month name functions and abbreviated month name functions (eg. january(), march(), mar()). var month_instance_functions = function (n) { return function () { if (this._is) { this._is = false; return this.getMonth() === n; } return this.moveToMonth(n, this._orient); }; }; var month_static_functions = function (n) { return function () { return $D.today().set({ month: n, day: 1 }); }; }; var processTerms = function (names, staticFunc, instanceFunc) { for (var i = 0; i < names.length; i++) { // Create constant static Name variables. $D[names[i].toUpperCase()] = $D[names[i].toUpperCase().substring(0, 3)] = i; // Create Name functions. $D[names[i]] = $D[names[i].substring(0, 3)] = staticFunc(i); // Create Name instance functions. $P[names[i]] = $P[names[i].substring(0, 3)] = instanceFunc(i); } }; processTerms(dx, sdf, df); processTerms(mx, month_static_functions, month_instance_functions); // Create date element functions and plural date element functions used with Date (eg. day(), days(), months()). var ef = function (j) { return function () { // if the .second() function was called earlier, the _orient // has alread been added. Just return this and reset _isSecond. if (this._isSecond) { this._isSecond = false; return this; } if (this._same) { this._same = this._is = false; var o1 = this.toObject(), o2 = (arguments[0] || new Date()).toObject(), v = "", k = j.toLowerCase(); // the substr trick with -1 doesn't work in IE8 or less k = (k[k.length-1] === "s") ? k.substring(0,k.length-1) : k; for (var m = (px.length - 1); m > -1; m--) { v = px[m].toLowerCase(); if (o1[v] !== o2[v]) { return false; } if (k === v) { break; } } return true; } if (j.substring(j.length - 1) !== "s") { j += "s"; } if (this._move) { this._move = null; } return this["add" + j](this._orient); }; }; var nf = function (n) { return function () { this._dateElement = n; return this; }; }; for (var k = 0; k < px.length; k++) { de = px[k].toLowerCase(); if(de !== "weekday") { // Create date element functions and plural date element functions used with Date (eg. day(), days(), months()). $P[de] = $P[de + "s"] = ef(px[k]); // Create date element functions and plural date element functions used with Number (eg. day(), days(), months()). $N[de] = $N[de + "s"] = nf(de + "s"); } } $P._ss = ef("Second"); var nthfn = function (n) { return function (dayOfWeek) { if (this._same) { return this._ss(arguments[0]); } if (dayOfWeek || dayOfWeek === 0) { return this.moveToNthOccurrence(dayOfWeek, n); } this._nth = n; // if the operator is 'second' add the _orient, then deal with it later... if (n === 2 && (dayOfWeek === undefined || dayOfWeek === null)) { this._isSecond = true; return this.addSeconds(this._orient); } return this; }; }; for (var l = 0; l < nth.length; l++) { $P[nth[l]] = (l === 0) ? nthfn(-1) : nthfn(l); } }()); (function () { "use strict"; Date.Parsing = { Exception: function (s) { this.message = "Parse error at '" + s.substring(0, 10) + " ...'"; } }; var $P = Date.Parsing; var dayOffsets = { standard: [0,31,59,90,120,151,181,212,243,273,304,334], leap: [0,31,60,91,121,152,182,213,244,274,305,335] }; $P.isLeapYear = function(year) { return ((year % 4 === 0) && (year % 100 !== 0)) || (year % 400 === 0); }; var utils = { multiReplace : function (str, hash ) { var key; for (key in hash) { if (Object.prototype.hasOwnProperty.call(hash, key)) { var regex; if (typeof hash[key] === "function") { } else { regex = (hash[key] instanceof RegExp) ? hash[key] : new RegExp(hash[key], "g"); } str = str.replace(regex, key); } } return str; }, getDayOfYearFromWeek : function (obj) { var d, jan4, offset; obj.weekDay = (!obj.weekDay && obj.weekDay !== 0) ? 1 : obj.weekDay; d = new Date(obj.year, 0, 4); jan4 = d.getDay() === 0 ? 7 : d.getDay(); // JS is 0 indexed on Sunday. offset = jan4+3; obj.dayOfYear = ((obj.week * 7) + (obj.weekDay === 0 ? 7 : obj.weekDay))-offset; return obj; }, getDayOfYear : function (obj, dayOffset) { if (!obj.dayOfYear) { obj = utils.getDayOfYearFromWeek(obj); } for (var i=0;i <= dayOffset.length;i++) { if (obj.dayOfYear < dayOffset[i] || i === dayOffset.length) { obj.day = obj.day ? obj.day : (obj.dayOfYear - dayOffset[i-1]); break; } else { obj.month = i; } } return obj; }, adjustForTimeZone : function (obj, date) { var offset; if (obj.zone.toUpperCase() === "Z" || (obj.zone_hours === 0 && obj.zone_minutes === 0)) { // it's UTC/GML so work out the current timeszone offset offset = -date.getTimezoneOffset(); } else { offset = (obj.zone_hours*60) + (obj.zone_minutes || 0); if (obj.zone_sign === "+") { offset *= -1; } offset -= date.getTimezoneOffset(); } date.setMinutes(date.getMinutes()+offset); return date; }, setDefaults : function (obj) { obj.year = obj.year || Date.today().getFullYear(); obj.hours = obj.hours || 0; obj.minutes = obj.minutes || 0; obj.seconds = obj.seconds || 0; obj.milliseconds = obj.milliseconds || 0; if (!(!obj.month && (obj.week || obj.dayOfYear))) { // if we have a month, or if we don't but don't have the day calculation data obj.month = obj.month || 0; obj.day = obj.day || 1; } return obj; }, dataNum: function (data, mod, explict, postProcess) { var dataNum = data*1; if (mod) { if (postProcess) { return data ? mod(data)*1 : data; } else { return data ? mod(dataNum) : data; } } else if (!explict){ return data ? dataNum : data; } else { return (data && typeof data !== "undefined") ? dataNum : data; } }, timeDataProcess: function (obj) { var timeObj = {}; for (var x in obj.data) { if (obj.data.hasOwnProperty(x)) { timeObj[x] = obj.ignore[x] ? obj.data[x] : utils.dataNum(obj.data[x], obj.mods[x], obj.explict[x], obj.postProcess[x]); } } if (obj.data.secmins) { obj.data.secmins = obj.data.secmins.replace(",", ".") * 60; if (!timeObj.minutes) { timeObj.minutes = obj.data.secmins; } else if (!timeObj.seconds) { timeObj.seconds = obj.data.secmins; } delete obj.secmins; } return timeObj; }, buildTimeObjectFromData: function (data) { var time = utils.timeDataProcess({ data: { year : data[1], month : data[5], day : data[7], week : data[8], dayOfYear : data[10], hours : data[15], zone_hours : data[23], zone_minutes : data[24], zone : data[21], zone_sign : data[22], weekDay : data[9], minutes: data[16], seconds: data[19], milliseconds: data[20], secmins: data[18] }, mods: { month: function(data) { return data-1; }, weekDay: function (data) { data = Math.abs(data); return (data === 7 ? 0 : data); }, minutes: function (data) { return data.replace(":",""); }, seconds: function (data) { return Math.floor( (data.replace(":","").replace(",","."))*1 ); }, milliseconds: function (data) { return (data.replace(",",".")*1000); } }, postProcess: { minutes: true, seconds: true, milliseconds: true }, explict: { zone_hours: true, zone_minutes: true }, ignore: { zone: true, zone_sign: true, secmins: true } }); return time; }, addToHash: function (hash, keys, data) { keys = keys; data = data; var len = keys.length; for (var i = 0; i < len; i++) { hash[keys[i]] = data[i]; } return hash; }, combineRegex: function (r1, r2) { return new RegExp("(("+r1.source+")\\s("+r2.source+"))"); }, getDateNthString: function(add, last, inc){ if (add) { return Date.today().addDays(inc).toString("d"); } else if (last) { return Date.today().last()[inc]().toString("d"); } }, buildRegexData: function (array) { var arr = []; var len = array.length; for (var i=0; i < len; i++) { if (Object.prototype.toString.call(array[i]) === '[object Array]') { // oldIE compat version of Array.isArray arr.push(this.combineRegex(array[i][0], array[i][1])); } else { arr.push(array[i]); } } return arr; } }; $P.processTimeObject = function (obj) { var date, dayOffset; utils.setDefaults(obj); dayOffset = ($P.isLeapYear(obj.year)) ? dayOffsets.leap : dayOffsets.standard; if (!obj.month && (obj.week || obj.dayOfYear)) { utils.getDayOfYear(obj, dayOffset); } else { obj.dayOfYear = dayOffset[obj.month] + obj.day; } date = new Date(obj.year, obj.month, obj.day, obj.hours, obj.minutes, obj.seconds, obj.milliseconds); if (obj.zone) { utils.adjustForTimeZone(obj, date); // adjust (and calculate) for timezone } return date; }; $P.ISO = { regex : /^([\+-]?\d{4}(?!\d{2}\b))((-?)((0[1-9]|1[0-2])(\3([12]\d|0[1-9]|3[01]))?|W([0-4]\d|5[0-3])(-?[1-7])?|(00[1-9]|0[1-9]\d|[12]\d{2}|3([0-5]\d|6[1-6])))([T\s]((([01]\d|2[0-4])((:?)[0-5]\d)?|24\:?00)([\.,]\d+(?!:))?)?(\17[0-5]\d([\.,]\d+)?)?\s?([zZ]|([\+-])([01]\d|2[0-3]):?([0-5]\d)?)?)?)?$/, parse : function (s) { var time, data = s.match(this.regex); if (!data || !data.length) { return null; } time = utils.buildTimeObjectFromData(data); if (!time.year || (!time.year && (!time.month && !time.day) && (!time.week && !time.dayOfYear)) ) { return null; } return $P.processTimeObject(time); } }; $P.Numeric = { isNumeric: function (e){return!isNaN(parseFloat(e))&&isFinite(e);}, regex: /\b([0-1]?[0-9])([0-3]?[0-9])([0-2]?[0-9]?[0-9][0-9])\b/i, parse: function (s) { var data, i, time = {}, order = Date.CultureInfo.dateElementOrder.split(""); if (!(this.isNumeric(s)) || // if it's non-numeric OR (s[0] === "+" && s[0] === "-")) { // It's an arithmatic string (eg +/-1000) return null; } if (s.length < 5 && s.indexOf(".") < 0 && s.indexOf("/") < 0) { // assume it's just a year. time.year = s; return $P.processTimeObject(time); } data = s.match(this.regex); if (!data || !data.length) { return null; } for (i=0; i < order.length; i++) { switch(order[i]) { case "d": time.day = data[i+1]; break; case "m": time.month = (data[i+1]-1); break; case "y": time.year = data[i+1]; break; } } return $P.processTimeObject(time); } }; $P.Normalizer = { regexData: function () { var $R = Date.CultureInfo.regexPatterns; return utils.buildRegexData([ $R.tomorrow, $R.yesterday, [$R.past, $R.mon], [$R.past, $R.tue], [$R.past, $R.wed], [$R.past, $R.thu], [$R.past, $R.fri], [$R.past, $R.sat], [$R.past, $R.sun] ]); }, basicReplaceHash : function() { var $R = Date.CultureInfo.regexPatterns; return { "January": $R.jan.source, "February": $R.feb, "March": $R.mar, "April": $R.apr, "May": $R.may, "June": $R.jun, "July": $R.jul, "August": $R.aug, "September": $R.sep, "October": $R.oct, "November": $R.nov, "December": $R.dec, "": /\bat\b/gi, " ": /\s{2,}/, "am": $R.inTheMorning, "9am": $R.thisMorning, "pm": $R.inTheEvening, "7pm":$R.thisEvening }; }, keys : function(){ return [ utils.getDateNthString(true, false, 1), // tomorrow utils.getDateNthString(true, false, -1), // yesterday utils.getDateNthString(false, true, "monday"), //last mon utils.getDateNthString(false, true, "tuesday"), //last tues utils.getDateNthString(false, true, "wednesday"), //last wed utils.getDateNthString(false, true, "thursday"), //last thurs utils.getDateNthString(false, true, "friday"), //last fri utils.getDateNthString(false, true, "saturday"), //last sat utils.getDateNthString(false, true, "sunday") //last sun ]; }, buildRegexFunctions: function () { var $R = Date.CultureInfo.regexPatterns; var __ = Date.i18n.__; var tomorrowRE = new RegExp("(\\b\\d\\d?("+__("AM")+"|"+__("PM")+")? )("+$R.tomorrow.source.slice(1)+")", "i"); // adapted tomorrow regex for AM PM relative dates var todayRE = new RegExp($R.today.source + "(?!\\s*([+-]))\\b"); // today, but excludes the math operators (eg "today + 2h") this.replaceFuncs = [ [todayRE, function (full) { return (full.length > 1) ? Date.today().toString("d") : full; }], [tomorrowRE, function(full, m1) { var t = Date.today().addDays(1).toString("d"); return (t + " " + m1); }], [$R.amThisMorning, function(str, am){return am;}], [$R.pmThisEvening, function(str, pm){return pm;}] ]; }, buildReplaceData: function () { this.buildRegexFunctions(); this.replaceHash = utils.addToHash(this.basicReplaceHash(), this.keys(), this.regexData()); }, stringReplaceFuncs: function (s) { for (var i=0; i < this.replaceFuncs.length; i++) { s = s.replace(this.replaceFuncs[i][0], this.replaceFuncs[i][1]); } return s; }, parse: function (s) { s = this.stringReplaceFuncs(s); s = utils.multiReplace(s, this.replaceHash); try { var n = s.split(/([\s\-\.\,\/\x27]+)/); if (n.length === 3 && $P.Numeric.isNumeric(n[0]) && $P.Numeric.isNumeric(n[2]) && (n[2].length >= 4)) { // ok, so we're dealing with x/year. But that's not a full date. // This fixes wonky dateElementOrder parsing when set to dmy order. if (Date.CultureInfo.dateElementOrder[0] === "d") { s = "1/" + n[0] + "/" + n[2]; // set to 1st of month and normalize the seperator } } } catch (e) {} return s; } }; $P.Normalizer.buildReplaceData(); }()); (function () { var $P = Date.Parsing; var _ = $P.Operators = { // // Tokenizers // rtoken: function (r) { // regex token return function (s) { var mx = s.match(r); if (mx) { return ([ mx[0], s.substring(mx[0].length) ]); } else { throw new $P.Exception(s); } }; }, token: function () { // whitespace-eating token return function (s) { return _.rtoken(new RegExp("^\\s*" + s + "\\s*"))(s); }; }, stoken: function (s) { // string token return _.rtoken(new RegExp("^" + s)); }, // Atomic Operators until: function (p) { return function (s) { var qx = [], rx = null; while (s.length) { try { rx = p.call(this, s); } catch (e) { qx.push(rx[0]); s = rx[1]; continue; } break; } return [ qx, s ]; }; }, many: function (p) { return function (s) { var rx = [], r = null; while (s.length) { try { r = p.call(this, s); } catch (e) { return [ rx, s ]; } rx.push(r[0]); s = r[1]; } return [ rx, s ]; }; }, // generator operators -- see below optional: function (p) { return function (s) { var r = null; try { r = p.call(this, s); } catch (e) { return [ null, s ]; } return [ r[0], r[1] ]; }; }, not: function (p) { return function (s) { try { p.call(this, s); } catch (e) { return [null, s]; } throw new $P.Exception(s); }; }, ignore: function (p) { return p ? function (s) { var r = null; r = p.call(this, s); return [null, r[1]]; } : null; }, product: function () { var px = arguments[0], qx = Array.prototype.slice.call(arguments, 1), rx = []; for (var i = 0 ; i < px.length ; i++) { rx.push(_.each(px[i], qx)); } return rx; }, cache: function (rule) { var cache = {}, cache_length = 0, cache_keys = [], CACHE_MAX = Date.Config.CACHE_MAX || 100000, r = null; var cacheCheck = function () { if (cache_length === CACHE_MAX) { // kill several keys, don't want to have to do this all the time... for (var i=0; i < 10; i++) { var key = cache_keys.shift(); if (key) { delete cache[key]; cache_length--; } } } }; return function (s) { cacheCheck(); try { r = cache[s] = (cache[s] || rule.call(this, s)); } catch (e) { r = cache[s] = e; } cache_length++; cache_keys.push(s); if (r instanceof $P.Exception) { throw r; } else { return r; } }; }, // vector operators -- see below any: function () { var px = arguments; return function (s) { var r = null; for (var i = 0; i < px.length; i++) { if (px[i] == null) { continue; } try { r = (px[i].call(this, s)); } catch (e) { r = null; } if (r) { return r; } } throw new $P.Exception(s); }; }, each: function () { var px = arguments; return function (s) { var rx = [], r = null; for (var i = 0; i < px.length ; i++) { if (px[i] == null) { continue; } try { r = (px[i].call(this, s)); } catch (e) { throw new $P.Exception(s); } rx.push(r[0]); s = r[1]; } return [ rx, s]; }; }, all: function () { var px = arguments, _ = _; return _.each(_.optional(px)); }, // delimited operators sequence: function (px, d, c) { d = d || _.rtoken(/^\s*/); c = c || null; if (px.length === 1) { return px[0]; } return function (s) { var r = null, q = null; var rx = []; for (var i = 0; i < px.length ; i++) { try { r = px[i].call(this, s); } catch (e) { break; } rx.push(r[0]); try { q = d.call(this, r[1]); } catch (ex) { q = null; break; } s = q[1]; } if (!r) { throw new $P.Exception(s); } if (q) { throw new $P.Exception(q[1]); } if (c) { try { r = c.call(this, r[1]); } catch (ey) { throw new $P.Exception(r[1]); } } return [ rx, (r?r[1]:s) ]; }; }, // // Composite Operators // between: function (d1, p, d2) { d2 = d2 || d1; var _fn = _.each(_.ignore(d1), p, _.ignore(d2)); return function (s) { var rx = _fn.call(this, s); return [[rx[0][0], r[0][2]], rx[1]]; }; }, list: function (p, d, c) { d = d || _.rtoken(/^\s*/); c = c || null; return (p instanceof Array ? _.each(_.product(p.slice(0, -1), _.ignore(d)), p.slice(-1), _.ignore(c)) : _.each(_.many(_.each(p, _.ignore(d))), px, _.ignore(c))); }, set: function (px, d, c) { d = d || _.rtoken(/^\s*/); c = c || null; return function (s) { // r is the current match, best the current 'best' match // which means it parsed the most amount of input var r = null, p = null, q = null, rx = null, best = [[], s], last = false; // go through the rules in the given set for (var i = 0; i < px.length ; i++) { // last is a flag indicating whether this must be the last element // if there is only 1 element, then it MUST be the last one q = null; p = null; r = null; last = (px.length === 1); // first, we try simply to match the current pattern // if not, try the next pattern try { r = px[i].call(this, s); } catch (e) { continue; } // since we are matching against a set of elements, the first // thing to do is to add r[0] to matched elements rx = [[r[0]], r[1]]; // if we matched and there is still input to parse and // we don't already know this is the last element, // we're going to next check for the delimiter ... // if there's none, or if there's no input left to parse // than this must be the last element after all ... if (r[1].length > 0 && ! last) { try { q = d.call(this, r[1]); } catch (ex) { last = true; } } else { last = true; } // if we parsed the delimiter and now there's no more input, // that means we shouldn't have parsed the delimiter at all // so don't update r and mark this as the last element ... if (!last && q[1].length === 0) { last = true; } // so, if this isn't the last element, we're going to see if // we can get any more matches from the remaining (unmatched) // elements ... if (!last) { // build a list of the remaining rules we can match against, // i.e., all but the one we just matched against var qx = []; for (var j = 0; j < px.length ; j++) { if (i !== j) { qx.push(px[j]); } } // now invoke recursively set with the remaining input // note that we don't include the closing delimiter ... // we'll check for that ourselves at the end p = _.set(qx, d).call(this, q[1]); // if we got a non-empty set as a result ... // (otw rx already contains everything we want to match) if (p[0].length > 0) { // update current result, which is stored in rx ... // basically, pick up the remaining text from p[1] // and concat the result from p[0] so that we don't // get endless nesting ... rx[0] = rx[0].concat(p[0]); rx[1] = p[1]; } } // at this point, rx either contains the last matched element // or the entire matched set that starts with this element. // now we just check to see if this variation is better than // our best so far, in terms of how much of the input is parsed if (rx[1].length < best[1].length) { best = rx; } // if we've parsed all the input, then we're finished if (best[1].length === 0) { break; } } // so now we've either gone through all the patterns trying them // as the initial match; or we found one that parsed the entire // input string ... // if best has no matches, just return empty set ... if (best[0].length === 0) { return best; } // if a closing delimiter is provided, then we have to check it also if (c) { // we try this even if there is no remaining input because the pattern // may well be optional or match empty input ... try { q = c.call(this, best[1]); } catch (ey) { throw new $P.Exception(best[1]); } // it parsed ... be sure to update the best match remaining input best[1] = q[1]; } // if we're here, either there was no closing delimiter or we parsed it // so now we have the best match; just return it! return best; }; }, forward: function (gr, fname) { return function (s) { return gr[fname].call(this, s); }; }, // // Translation Operators // replace: function (rule, repl) { return function (s) { var r = rule.call(this, s); return [repl, r[1]]; }; }, process: function (rule, fn) { return function (s) { var r = rule.call(this, s); return [fn.call(this, r[0]), r[1]]; }; }, min: function (min, rule) { return function (s) { var rx = rule.call(this, s); if (rx[0].length < min) { throw new $P.Exception(s); } return rx; }; } }; // Generator Operators And Vector Operators // Generators are operators that have a signature of F(R) => R, // taking a given rule and returning another rule, such as // ignore, which parses a given rule and throws away the result. // Vector operators are those that have a signature of F(R1,R2,...) => R, // take a list of rules and returning a new rule, such as each. // Generator operators are converted (via the following _generator // function) into functions that can also take a list or array of rules // and return an array of new rules as though the function had been // called on each rule in turn (which is what actually happens). // This allows generators to be used with vector operators more easily. // Example: // each(ignore(foo, bar)) instead of each(ignore(foo), ignore(bar)) // This also turns generators into vector operators, which allows // constructs like: // not(cache(foo, bar)) var _generator = function (op) { function gen() { var args = null, rx = [], px, i; if (arguments.length > 1) { args = Array.prototype.slice.call(arguments); } else if (arguments[0] instanceof Array) { args = arguments[0]; } if (args) { px = args.shift(); if (px.length > 0) { args.unshift(px[i]); rx.push(op.apply(null, args)); args.shift(); return rx; } } else { return op.apply(null, arguments); } } return gen; }; var gx = "optional not ignore cache".split(/\s/); for (var i = 0 ; i < gx.length ; i++) { _[gx[i]] = _generator(_[gx[i]]); } var _vector = function (op) { return function () { if (arguments[0] instanceof Array) { return op.apply(null, arguments[0]); } else { return op.apply(null, arguments); } }; }; var vx = "each any all".split(/\s/); for (var j = 0 ; j < vx.length ; j++) { _[vx[j]] = _vector(_[vx[j]]); } }()); (function () { var $D = Date; var flattenAndCompact = function (ax) { var rx = []; for (var i = 0; i < ax.length; i++) { if (ax[i] instanceof Array) { rx = rx.concat(flattenAndCompact(ax[i])); } else { if (ax[i]) { rx.push(ax[i]); } } } return rx; }; var parseMeridian = function () { if (this.meridian && (this.hour || this.hour === 0)) { if (this.meridian === "a" && this.hour > 11 && Date.Config.strict24hr){ throw "Invalid hour and meridian combination"; } else if (this.meridian === "p" && this.hour < 12 && Date.Config.strict24hr){ throw "Invalid hour and meridian combination"; } else if (this.meridian === "p" && this.hour < 12) { this.hour = this.hour + 12; } else if (this.meridian === "a" && this.hour === 12) { this.hour = 0; } } }; var setDefaults = function () { var now = new Date(); if ((this.hour || this.minute) && (!this.month && !this.year && !this.day)) { this.day = now.getDate(); } if (!this.year) { this.year = now.getFullYear(); } if (!this.month && this.month !== 0) { this.month = now.getMonth(); } if (!this.day) { this.day = 1; } if (!this.hour) { this.hour = 0; } if (!this.minute) { this.minute = 0; } if (!this.second) { this.second = 0; } if (!this.millisecond) { this.millisecond = 0; } }; var finishUtils = { getToday: function () { if (this.now || "hour minute second".indexOf(this.unit) !== -1) { return new Date(); } else { return $D.today(); } }, setDaysFromWeekday: function (today, orient){ var gap; orient = orient || 1; this.unit = "day"; gap = ($D.getDayNumberFromName(this.weekday) - today.getDay()); this.days = gap ? ((gap + (orient * 7)) % 7) : (orient * 7); return this; }, setMonthsFromMonth: function (today, orient) { var gap; orient = orient || 1; this.unit = "month"; gap = (this.month - today.getMonth()); this.months = gap ? ((gap + (orient * 12)) % 12) : (orient * 12); this.month = null; return this; }, setDMYFromWeekday: function () { var d = Date[this.weekday](); this.day = d.getDate(); if (!this.month) { this.month = d.getMonth(); } this.year = d.getFullYear(); return this; }, setUnitValue: function (orient) { if (!this.value && this.operator && this.operator !== null && this[this.unit + "s"] && this[this.unit + "s"] !== null) { this[this.unit + "s"] = this[this.unit + "s"] + ((this.operator === "add") ? 1 : -1) + (this.value||0) * orient; } else if (this[this.unit + "s"] == null || this.operator != null) { if (!this.value) { this.value = 1; } this[this.unit + "s"] = this.value * orient; } }, generateDateFromWeeks: function () { var weekday = (this.weekday !== undefined) ? this.weekday : "today"; var d = Date[weekday]().addWeeks(this.weeks); if (this.now) { d.setTimeToNow(); } return d; } }; $D.Translator = { hour: function (s) { return function () { this.hour = Number(s); }; }, minute: function (s) { return function () { this.minute = Number(s); }; }, second: function (s) { return function () { this.second = Number(s); }; }, /* for ss.s format */ secondAndMillisecond: function (s) { return function () { var mx = s.match(/^([0-5][0-9])\.([0-9]{1,3})/); this.second = Number(mx[1]); this.millisecond = Number(mx[2]); }; }, meridian: function (s) { return function () { this.meridian = s.slice(0, 1).toLowerCase(); }; }, timezone: function (s) { return function () { var n = s.replace(/[^\d\+\-]/g, ""); if (n.length) { this.timezoneOffset = Number(n); } else { this.timezone = s.toLowerCase(); } }; }, day: function (x) { var s = x[0]; return function () { this.day = Number(s.match(/\d+/)[0]); if (this.day < 1) { throw "invalid day"; } }; }, month: function (s) { return function () { this.month = (s.length === 3) ? "jan feb mar apr may jun jul aug sep oct nov dec".indexOf(s)/4 : Number(s) - 1; if (this.month < 0) { throw "invalid month"; } }; }, year: function (s) { return function () { var n = Number(s); this.year = ((s.length > 2) ? n : (n + (((n + 2000) < Date.CultureInfo.twoDigitYearMax) ? 2000 : 1900))); }; }, rday: function (s) { return function () { switch (s) { case "yesterday": this.days = -1; break; case "tomorrow": this.days = 1; break; case "today": this.days = 0; break; case "now": this.days = 0; this.now = true; break; } }; }, finishExact: function (x) { var d; x = (x instanceof Array) ? x : [x]; for (var i = 0 ; i < x.length ; i++) { if (x[i]) { x[i].call(this); } } setDefaults.call(this); parseMeridian.call(this); if (this.day > $D.getDaysInMonth(this.year, this.month)) { throw new RangeError(this.day + " is not a valid value for days."); } d = new Date(this.year, this.month, this.day, this.hour, this.minute, this.second, this.millisecond); if (this.year < 100) { d.setFullYear(this.year); // means years less that 100 are process correctly. JS will parse it otherwise as 1900-1999. } if (this.timezone) { d.set({ timezone: this.timezone }); } else if (this.timezoneOffset) { d.set({ timezoneOffset: this.timezoneOffset }); } return d; }, finish: function (x) { var today, expression, orient, temp; x = (x instanceof Array) ? flattenAndCompact(x) : [ x ]; if (x.length === 0) { return null; } for (var i = 0 ; i < x.length ; i++) { if (typeof x[i] === "function") { x[i].call(this); } } if (this.now && !this.unit && !this.operator) { return new Date(); } else { today = finishUtils.getToday.call(this); } expression = !!(this.days && this.days !== null || this.orient || this.operator); orient = ((this.orient === "past" || this.operator === "subtract") ? -1 : 1); if (this.month && this.unit === "week") { this.value = this.month + 1; delete this.month; delete this.day; } if ((this.month || this.month === 0) && "year day hour minute second".indexOf(this.unit) !== -1) { if (!this.value) { this.value = this.month + 1; } this.month = null; expression = true; } if (!expression && this.weekday && !this.day && !this.days) { finishUtils.setDMYFromWeekday.call(this); } if (expression && this.weekday && this.unit !== "month" && this.unit !== "week") { finishUtils.setDaysFromWeekday.call(this, today, orient); } if (this.weekday && this.unit !== "week" && !this.day && !this.days) { temp = Date[this.weekday](); this.day = temp.getDate(); if (temp.getMonth() !== today.getMonth()) { this.month = temp.getMonth(); } } if (this.month && this.unit === "day" && this.operator) { if (!this.value) { this.value = (this.month + 1); } this.month = null; } if (this.value != null && this.month != null && this.year != null) { this.day = this.value * 1; } if (this.month && !this.day && this.value) { today.set({ day: this.value * 1 }); if (!expression) { this.day = this.value * 1; } } if (!this.month && this.value && this.unit === "month" && !this.now) { this.month = this.value; expression = true; } if (expression && (this.month || this.month === 0) && this.unit !== "year") { finishUtils.setMonthsFromMonth.call(this, today, orient); } if (!this.unit) { this.unit = "day"; } finishUtils.setUnitValue.call(this, orient); parseMeridian.call(this); if ((this.month || this.month === 0) && !this.day) { this.day = 1; } if (!this.orient && !this.operator && this.unit === "week" && this.value && !this.day && !this.month) { return Date.today().setWeek(this.value); } if (this.unit === "week" && this.weeks && !this.day && !this.month) { return finishUtils.generateDateFromWeeks.call(this); } if (expression && this.timezone && this.day && this.days) { this.day = this.days; } if (expression){ today.add(this); } else { today.set(this); } if (this.timezone) { this.timezone = this.timezone.toUpperCase(); var offset = $D.getTimezoneOffset(this.timezone); var timezone; if (today.hasDaylightSavingTime()) { // lets check that we're being sane with timezone setting timezone = $D.getTimezoneAbbreviation(offset, today.isDaylightSavingTime()); if (timezone !== this.timezone) { // bugger, we're in a place where things like EST vs EDT matters. if (today.isDaylightSavingTime()) { today.addHours(-1); } else { today.addHours(1); } } } today.setTimezoneOffset(offset); } return today; } }; }()); (function () { var $D = Date; $D.Grammar = {}; var _ = $D.Parsing.Operators, g = $D.Grammar, t = $D.Translator, _fn; // Allow rolling up into general purpose rules _fn = function () { return _.each(_.any.apply(null, arguments), _.not(g.ctoken2("timeContext"))); }; g.datePartDelimiter = _.rtoken(/^([\s\-\.\,\/\x27]+)/); g.timePartDelimiter = _.stoken(":"); g.whiteSpace = _.rtoken(/^\s*/); g.generalDelimiter = _.rtoken(/^(([\s\,]|at|@|on)+)/); var _C = {}; g.ctoken = function (keys) { var fn = _C[keys]; if (! fn) { var c = Date.CultureInfo.regexPatterns; var kx = keys.split(/\s+/), px = []; for (var i = 0; i < kx.length ; i++) { px.push(_.replace(_.rtoken(c[kx[i]]), kx[i])); } fn = _C[keys] = _.any.apply(null, px); } return fn; }; g.ctoken2 = function (key) { return _.rtoken(Date.CultureInfo.regexPatterns[key]); }; var cacheProcessRtoken = function (key, token, type, eachToken) { if (eachToken) { g[key] = _.cache(_.process(_.each(_.rtoken(token),_.optional(g.ctoken2(eachToken))), type)); } else { g[key] = _.cache(_.process(_.rtoken(token), type)); } }; var cacheProcessCtoken = function (token, type) { return _.cache(_.process(g.ctoken2(token), type)); }; var _F = {}; //function cache var _get = function (f) { _F[f] = (_F[f] || g.format(f)[0]); return _F[f]; }; g.allformats = function (fx) { var rx = []; if (fx instanceof Array) { for (var i = 0; i < fx.length; i++) { rx.push(_get(fx[i])); } } else { rx.push(_get(fx)); } return rx; }; g.formats = function (fx) { if (fx instanceof Array) { var rx = []; for (var i = 0 ; i < fx.length ; i++) { rx.push(_get(fx[i])); } return _.any.apply(null, rx); } else { return _get(fx); } }; var grammarFormats = { timeFormats: function(){ var i, RTokenKeys = [ "h", "hh", "H", "HH", "m", "mm", "s", "ss", "ss.s", "z", "zz" ], RToken = [ /^(0[0-9]|1[0-2]|[1-9])/, /^(0[0-9]|1[0-2])/, /^([0-1][0-9]|2[0-3]|[0-9])/, /^([0-1][0-9]|2[0-3])/, /^([0-5][0-9]|[0-9])/, /^[0-5][0-9]/, /^([0-5][0-9]|[0-9])/, /^[0-5][0-9]/, /^[0-5][0-9]\.[0-9]{1,3}/, /^((\+|\-)\s*\d\d\d\d)|((\+|\-)\d\d\:?\d\d)/, /^((\+|\-)\s*\d\d\d\d)|((\+|\-)\d\d\:?\d\d)/ ], tokens = [ t.hour, t.hour, t.hour, t.hour, t.minute, t.minute, t.second, t.second, t.secondAndMillisecond, t.timezone, t.timezone ]; for (i=0; i < RTokenKeys.length; i++) { cacheProcessRtoken(RTokenKeys[i], RToken[i], tokens[i]); } g.hms = _.cache(_.sequence([g.H, g.m, g.s], g.timePartDelimiter)); g.t = cacheProcessCtoken("shortMeridian", t.meridian); g.tt = cacheProcessCtoken("longMeridian", t.meridian); g.zzz = cacheProcessCtoken("timezone", t.timezone); g.timeSuffix = _.each(_.ignore(g.whiteSpace), _.set([ g.tt, g.zzz ])); g.time = _.each(_.optional(_.ignore(_.stoken("T"))), g.hms, g.timeSuffix); }, dateFormats: function () { // pre-loaded rules for different date part order preferences var _setfn = function () { return _.set(arguments, g.datePartDelimiter); }; var i, RTokenKeys = [ "d", "dd", "M", "MM", "y", "yy", "yyy", "yyyy" ], RToken = [ /^([0-2]\d|3[0-1]|\d)/, /^([0-2]\d|3[0-1])/, /^(1[0-2]|0\d|\d)/, /^(1[0-2]|0\d)/, /^(\d+)/, /^(\d\d)/, /^(\d\d?\d?\d?)/, /^(\d\d\d\d)/ ], tokens = [ t.day, t.day, t.month, t.month, t.year, t.year, t.year, t.year ], eachToken = [ "ordinalSuffix", "ordinalSuffix" ]; for (i=0; i < RTokenKeys.length; i++) { cacheProcessRtoken(RTokenKeys[i], RToken[i], tokens[i], eachToken[i]); } g.MMM = g.MMMM = _.cache(_.process(g.ctoken("jan feb mar apr may jun jul aug sep oct nov dec"), t.month)); g.ddd = g.dddd = _.cache(_.process(g.ctoken("sun mon tue wed thu fri sat"), function (s) { return function () { this.weekday = s; }; } )); g.day = _fn(g.d, g.dd); g.month = _fn(g.M, g.MMM); g.year = _fn(g.yyyy, g.yy); g.mdy = _setfn(g.ddd, g.month, g.day, g.year); g.ymd = _setfn(g.ddd, g.year, g.month, g.day); g.dmy = _setfn(g.ddd, g.day, g.month, g.year); g.date = function (s) { return ((g[Date.CultureInfo.dateElementOrder] || g.mdy).call(this, s)); }; }, relative: function () { // relative date / time expressions g.orientation = _.process(g.ctoken("past future"), function (s) { return function () { this.orient = s; }; } ); g.operator = _.process(g.ctoken("add subtract"), function (s) { return function () { this.operator = s; }; } ); g.rday = _.process(g.ctoken("yesterday tomorrow today now"), t.rday); g.unit = _.process(g.ctoken("second minute hour day week month year"), function (s) { return function () { this.unit = s; }; } ); } }; g.buildGrammarFormats = function () { // these need to be rebuilt every time the language changes. _C = {}; grammarFormats.timeFormats(); grammarFormats.dateFormats(); grammarFormats.relative(); g.value = _.process(_.rtoken(/^([-+]?\d+)?(st|nd|rd|th)?/), function (s) { return function () { this.value = s.replace(/\D/g, ""); }; } ); g.expression = _.set([g.rday, g.operator, g.value, g.unit, g.orientation, g.ddd, g.MMM ]); g.format = _.process(_.many( _.any( // translate format specifiers into grammar rules _.process( _.rtoken(/^(dd?d?d?(?!e)|MM?M?M?|yy?y?y?|hh?|HH?|mm?|ss?|tt?|zz?z?)/), function (fmt) { if (g[fmt]) { return g[fmt]; } else { throw $D.Parsing.Exception(fmt); } } ), // translate separator tokens into token rules _.process(_.rtoken(/^[^dMyhHmstz]+/), // all legal separators function (s) { return _.ignore(_.stoken(s)); } ) ) ), // construct the parser ... function (rules) { return _.process(_.each.apply(null, rules), t.finishExact); } ); // starting rule for general purpose grammar g._start = _.process(_.set([ g.date, g.time, g.expression ], g.generalDelimiter, g.whiteSpace), t.finish); }; g.buildGrammarFormats(); // parsing date format specifiers - ex: "h:m:s tt" // this little guy will generate a custom parser based // on the format string, ex: g.format("h:m:s tt") // check for these formats first g._formats = g.formats([ "\"yyyy-MM-ddTHH:mm:ssZ\"", "yyyy-MM-ddTHH:mm:ss.sz", "yyyy-MM-ddTHH:mm:ssZ", "yyyy-MM-ddTHH:mm:ssz", "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-ddTHH:mmZ", "yyyy-MM-ddTHH:mmz", "yyyy-MM-ddTHH:mm", "ddd, MMM dd, yyyy H:mm:ss tt", "ddd MMM d yyyy HH:mm:ss zzz", "MMddyyyy", "ddMMyyyy", "Mddyyyy", "ddMyyyy", "Mdyyyy", "dMyyyy", "yyyy", "Mdyy", "dMyy", "d" ]); // real starting rule: tries selected formats first, // then general purpose rule g.start = function (s) { try { var r = g._formats.call({}, s); if (r[1].length === 0) { return r; } } catch (e) {} return g._start.call({}, s); }; }()); (function () { var $D = Date; /** * @desc Converts the specified string value into its JavaScript Date equivalent using CultureInfo specific format information. * * Example

	///////////
	// Dates //
	///////////

	// 15-Oct-2004
	var d1 = Date.parse("10/15/2004");

	// 15-Oct-2004
	var d1 = Date.parse("15-Oct-2004");

	// 15-Oct-2004
	var d1 = Date.parse("2004.10.15");

	//Fri Oct 15, 2004
	var d1 = Date.parse("Fri Oct 15, 2004");

	///////////
	// Times //
	///////////

	// Today at 10 PM.
	var d1 = Date.parse("10 PM");

	// Today at 10:30 PM.
	var d1 = Date.parse("10:30 P.M.");

	// Today at 6 AM.
	var d1 = Date.parse("06am");

	/////////////////////
	// Dates and Times //
	/////////////////////

	// 8-July-2004 @ 10:30 PM
	var d1 = Date.parse("July 8th, 2004, 10:30 PM");

	// 1-July-2004 @ 10:30 PM
	var d1 = Date.parse("2004-07-01T22:30:00");

	////////////////////
	// Relative Dates //
	////////////////////

	// Returns today's date. The string "today" is culture specific.
	var d1 = Date.parse("today");

	// Returns yesterday's date. The string "yesterday" is culture specific.
	var d1 = Date.parse("yesterday");

	// Returns the date of the next thursday.
	var d1 = Date.parse("Next thursday");

	// Returns the date of the most previous monday.
	var d1 = Date.parse("last monday");

	// Returns today's day + one year.
	var d1 = Date.parse("next year");

	///////////////
	// Date Math //
	///////////////

	// Today + 2 days
	var d1 = Date.parse("t+2");

	// Today + 2 days
	var d1 = Date.parse("today + 2 days");

	// Today + 3 months
	var d1 = Date.parse("t+3m");

	// Today - 1 year
	var d1 = Date.parse("today - 1 year");

	// Today - 1 year
	var d1 = Date.parse("t-1y"); 


	/////////////////////////////
	// Partial Dates and Times //
	/////////////////////////////

	// July 15th of this year.
	var d1 = Date.parse("July 15");

	// 15th day of current day and year.
	var d1 = Date.parse("15");

	// July 1st of current year at 10pm.
	var d1 = Date.parse("7/1 10pm");
	
* * @param {String} The string value to convert into a Date object [Required] * @return {Date} A Date object or null if the string cannot be converted into a Date. */ var parseUtils = { removeOrds: function (s) { ords = s.match(/\b(\d+)(?:st|nd|rd|th)\b/); // find ordinal matches s = ((ords && ords.length === 2) ? s.replace(ords[0], ords[1]) : s); return s; }, grammarParser: function (s) { var r = null; try { r = $D.Grammar.start.call({}, s.replace(/^\s*(\S*(\s+\S+)*)\s*$/, "$1")); } catch (e) { return null; } return ((r[1].length === 0) ? r[0] : null); }, nativeFallback: function(s) { var t; try { // ok we haven't parsed it, last ditch attempt with the built-in parser. t = Date._parse(s); return (t || t === 0) ? new Date(t) : null; } catch (e) { return null; } } }; function parse (s) { var d; if (!s) { return null; } if (s instanceof Date) { return s.clone(); } if (s.length >= 4 && s.charAt(0) !== "0" && s.charAt(0) !== "+"&& s.charAt(0) !== "-") { // ie: 2004 will pass, 0800 won't. // Start with specific formats d = $D.Parsing.ISO.parse(s) || $D.Parsing.Numeric.parse(s); } if (d instanceof Date && !isNaN(d.getTime())) { return d; } else { // find ordinal dates (1st, 3rd, 8th, etc and remove them as they cause parsing issues) s = $D.Parsing.Normalizer.parse(parseUtils.removeOrds(s)); d = parseUtils.grammarParser(s); if (d !== null) { return d; } else { return parseUtils.nativeFallback(s); } } } if (!$D._parse) { $D._parse = $D.parse; } $D.parse = parse; Date.getParseFunction = function (fx) { var fns = Date.Grammar.allformats(fx); return function (s) { var r = null; for (var i = 0; i < fns.length; i++) { try { r = fns[i].call({}, s); } catch (e) { continue; } if (r[1].length === 0) { return r[0]; } } return null; }; }; /** * Converts the specified string value into its JavaScript Date equivalent using the specified format {String} or formats {Array} and the CultureInfo specific format information. * The format of the string value must match one of the supplied formats exactly. * * Example

	// 15-Oct-2004
	var d1 = Date.parseExact("10/15/2004", "M/d/yyyy");

	// 15-Oct-2004
	var d1 = Date.parse("15-Oct-2004", "M-ddd-yyyy");

	// 15-Oct-2004
	var d1 = Date.parse("2004.10.15", "yyyy.MM.dd");

	// Multiple formats
	var d1 = Date.parseExact("10/15/2004", ["M/d/yyyy", "MMMM d, yyyy"]);
	
* * @param {String} The string value to convert into a Date object [Required]. * @param {Object} The expected format {String} or an array of expected formats {Array} of the date string [Required]. * @return {Date} A Date object or null if the string cannot be converted into a Date. */ $D.parseExact = function (s, fx) { return $D.getParseFunction(fx)(s); }; }()); (function () { var $D = Date, $P = $D.prototype, // $C = $D.CultureInfo, // not used atm p = function (s, l) { if (!l) { l = 2; } return ("000" + s).slice(l * -1); }; /** * Converts a PHP format string to Java/.NET format string. * A PHP format string can be used with ._format or .format. * A Java/.NET format string can be used with .toString(). * The .parseExact function will only accept a Java/.NET format string * * Example * var f1 = "%m/%d/%y" * var f2 = Date.normalizeFormat(f1); // "MM/dd/yy" * * new Date().format(f1); // "04/13/08" * new Date()._format(f1); // "04/13/08" * new Date().toString(f2); // "04/13/08" * * var date = Date.parseExact("04/13/08", f2); // Sun Apr 13 2008 * * @param {String} A PHP format string consisting of one or more format spcifiers. * @return {String} The PHP format converted to a Java/.NET format string. */ var normalizerSubstitutions = { "d" : "dd", "%d": "dd", "D" : "ddd", "%a": "ddd", "j" : "dddd", "l" : "dddd", "%A": "dddd", "S" : "S", "F" : "MMMM", "%B": "MMMM", "m" : "MM", "%m": "MM", "M" : "MMM", "%b": "MMM", "%h": "MMM", "n" : "M", "Y" : "yyyy", "%Y": "yyyy", "y" : "yy", "%y": "yy", "g" : "h", "%I": "h", "G" : "H", "h" : "hh", "H" : "HH", "%H": "HH", "i" : "mm", "%M": "mm", "s" : "ss", "%S": "ss", "%r": "hh:mm tt", "%R": "H:mm", "%T": "H:mm:ss", "%X": "t", "%x": "d", "%e": "d", "%D": "MM/dd/yy", "%n": "\\n", "%t": "\\t", "e" : "z", "T" : "z", "%z": "z", "%Z": "z", "Z" : "ZZ", "N" : "u", "w" : "u", "%w": "u", "W" : "W", "%V": "W" }; var normalizer = { substitutes: function (m) { return normalizerSubstitutions[m]; }, interpreted: function (m, x) { var y; switch (m) { case "%u": return x.getDay() + 1; case "z": return x.getOrdinalNumber(); case "%j": return p(x.getOrdinalNumber(), 3); case "%U": var d1 = x.clone().set({month: 0, day: 1}).addDays(-1).moveToDayOfWeek(0), d2 = x.clone().addDays(1).moveToDayOfWeek(0, -1); return (d2 < d1) ? "00" : p((d2.getOrdinalNumber() - d1.getOrdinalNumber()) / 7 + 1); case "%W": return p(x.getWeek()); case "t": return $D.getDaysInMonth(x.getFullYear(), x.getMonth()); case "o": case "%G": return x.setWeek(x.getISOWeek()).toString("yyyy"); case "%g": return x._format("%G").slice(-2); case "a": case "%p": return t("tt").toLowerCase(); case "A": return t("tt").toUpperCase(); case "u": return p(x.getMilliseconds(), 3); case "I": return (x.isDaylightSavingTime()) ? 1 : 0; case "O": return x.getUTCOffset(); case "P": y = x.getUTCOffset(); return y.substring(0, y.length - 2) + ":" + y.substring(y.length - 2); case "B": var now = new Date(); return Math.floor(((now.getHours() * 3600) + (now.getMinutes() * 60) + now.getSeconds() + (now.getTimezoneOffset() + 60) * 60) / 86.4); case "c": return x.toISOString().replace(/\"/g, ""); case "U": return $D.strtotime("now"); case "%c": return t("d") + " " + t("t"); case "%C": return Math.floor(x.getFullYear() / 100 + 1); } }, shouldOverrideDefaults: function (m) { switch (m) { case "%e": return true; default: return false; } }, parse: function (m, context) { var formatString, c = context || new Date(); formatString = normalizer.substitutes(m); if (formatString) { return formatString; } formatString = normalizer.interpreted(m, c); if (formatString) { return formatString; } else { return m; } } }; $D.normalizeFormat = function (format, context) { return format.replace(/(%|\\)?.|%%/g, function(t){ return normalizer.parse(t, context); }); }; /** * Format a local Unix timestamp according to locale settings * * Example: * Date.strftime("%m/%d/%y", new Date()); // "04/13/08" * Date.strftime("c", "2008-04-13T17:52:03Z"); // "04/13/08" * * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @param {Number|String} The number representing the number of seconds that have elapsed since January 1, 1970 (local time). * @return {String} A string representation of the current Date object. */ $D.strftime = function (format, time) { var d = Date.parse(time); return d._format(format); }; /** * Parse any textual datetime description into a Unix timestamp. * A Unix timestamp is the number of seconds that have elapsed since January 1, 1970 (midnight UTC/GMT). * * Example: * Date.strtotime("04/13/08"); // 1208044800 * Date.strtotime("1970-01-01T00:00:00Z"); // 0 * * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @param {Object} A string or date object. * @return {String} A string representation of the current Date object. */ $D.strtotime = function (time) { var d = $D.parse(time); return Math.round($D.UTC(d.getUTCFullYear(), d.getUTCMonth(), d.getUTCDate(), d.getUTCHours(), d.getUTCMinutes(), d.getUTCSeconds(), d.getUTCMilliseconds()) / 1000); }; /** * Converts the value of the current Date object to its equivalent string representation using a PHP/Unix style of date format specifiers. * Format Specifiers * Format Description Example * ------ --------------------------------------------------------------------------- ----------------------- * %a abbreviated weekday name according to the current localed "Mon" through "Sun" * %A full weekday name according to the current localed "Sunday" through "Saturday" * %b abbreviated month name according to the current localed "Jan" through "Dec" * %B full month name according to the current locale "January" through "December" * %c preferred date and time representation for the current locale "4/13/2008 12:33 PM" * %C century number (the year divided by 100 and truncated to an integer) "00" to "99" * %d day of the month as a decimal number "01" to "31" * %D same as %m/%d/%y "04/13/08" * %e day of the month as a decimal number, a single digit is preceded by a space "1" to "31" * %g like %G, but without the century "08" * %G The 4-digit year corresponding to the ISO week number (see %V). "2008" * This has the same format and value as %Y, except that if the ISO week number * belongs to the previous or next year, that year is used instead. * %h same as %b "Jan" through "Dec" * %H hour as a decimal number using a 24-hour clock. "00" to "23" * %I hour as a decimal number using a 12-hour clock. "01" to "12" * %j day of the year as a decimal number. "001" to "366" * %m month as a decimal number. "01" to "12" * %M minute as a decimal number. "00" to "59" * %n newline character "\n" * %p either "am" or "pm" according to the given time value, or the "am" or "pm" * corresponding strings for the current locale. * %r time in a.m. and p.m. notation "8:44 PM" * %R time in 24 hour notation "20:44" * %S second as a decimal number "00" to "59" * %t tab character "\t" * %T current time, equal to %H:%M:%S "12:49:11" * %u weekday as a decimal number ["1", "7"], with "1" representing Monday "1" to "7" * %U week number of the current year as a decimal number, starting with the "0" to ("52" or "53") * first Sunday as the first day of the first week * %V The ISO 8601:1988 week number of the current year as a decimal number, "00" to ("52" or "53") * range 01 to 53, where week 1 is the first week that has at least 4 days * in the current year, and with Monday as the first day of the week. * (Use %G or %g for the year component that corresponds to the week number * for the specified timestamp.) * %W week number of the current year as a decimal number, starting with the "00" to ("52" or "53") * first Monday as the first day of the first week * %w day of the week as a decimal, Sunday being "0" "0" to "6" * %x preferred date representation for the current locale without the time "4/13/2008" * %X preferred time representation for the current locale without the date "12:53:05" * %y year as a decimal number without a century "00" "99" * %Y year as a decimal number including the century "2008" * %Z time zone or name or abbreviation "UTC", "EST", "PST" * %z same as %Z * %% a literal "%" characters "%" * d Day of the month, 2 digits with leading zeros "01" to "31" * D A textual representation of a day, three letters "Mon" through "Sun" * j Day of the month without leading zeros "1" to "31" * l A full textual representation of the day of the week (lowercase "L") "Sunday" through "Saturday" * N ISO-8601 numeric representation of the day of the week (added in PHP 5.1.0) "1" (for Monday) through "7" (for Sunday) * S English ordinal suffix for the day of the month, 2 characters "st", "nd", "rd" or "th". Works well with j * w Numeric representation of the day of the week "0" (for Sunday) through "6" (for Saturday) * z The day of the year (starting from "0") "0" through "365" * W ISO-8601 week number of year, weeks starting on Monday "00" to ("52" or "53") * F A full textual representation of a month, such as January or March "January" through "December" * m Numeric representation of a month, with leading zeros "01" through "12" * M A short textual representation of a month, three letters "Jan" through "Dec" * n Numeric representation of a month, without leading zeros "1" through "12" * t Number of days in the given month "28" through "31" * L Whether it's a leap year "1" if it is a leap year, "0" otherwise * o ISO-8601 year number. This has the same value as Y, except that if the "2008" * ISO week number (W) belongs to the previous or next year, that year * is used instead. * Y A full numeric representation of a year, 4 digits "2008" * y A two digit representation of a year "08" * a Lowercase Ante meridiem and Post meridiem "am" or "pm" * A Uppercase Ante meridiem and Post meridiem "AM" or "PM" * B Swatch Internet time "000" through "999" * g 12-hour format of an hour without leading zeros "1" through "12" * G 24-hour format of an hour without leading zeros "0" through "23" * h 12-hour format of an hour with leading zeros "01" through "12" * H 24-hour format of an hour with leading zeros "00" through "23" * i Minutes with leading zeros "00" to "59" * s Seconds, with leading zeros "00" through "59" * u Milliseconds "54321" * e Timezone identifier "UTC", "EST", "PST" * I Whether or not the date is in daylight saving time (uppercase i) "1" if Daylight Saving Time, "0" otherwise * O Difference to Greenwich time (GMT) in hours "+0200", "-0600" * P Difference to Greenwich time (GMT) with colon between hours and minutes "+02:00", "-06:00" * T Timezone abbreviation "UTC", "EST", "PST" * Z Timezone offset in seconds. The offset for timezones west of UTC is "-43200" through "50400" * always negative, and for those east of UTC is always positive. * c ISO 8601 date "2004-02-12T15:19:21+00:00" * r RFC 2822 formatted date "Thu, 21 Dec 2000 16:01:07 +0200" * U Seconds since the Unix Epoch (January 1 1970 00:00:00 GMT) "0" * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @return {String} A string representation of the current Date object. */ var formatReplace = function (context) { return function (m) { var formatString, override = false; if (m.charAt(0) === "\\" || m.substring(0, 2) === "%%") { return m.replace("\\", "").replace("%%", "%"); } override = normalizer.shouldOverrideDefaults(m); formatString = $D.normalizeFormat(m, context); if (formatString) { return context.toString(formatString, override); } }; }; $P._format = function (format) { var formatter = formatReplace(this); if (!format) { return this._toString(); } else { return format.replace(/(%|\\)?.|%%/g, formatter); } }; if (!$P.format) { $P.format = $P._format; } }()); (function () { "use strict"; var gFn = function (attr) { return function () { return this[attr]; }; }; var sFn = function (attr) { return function (val) { this[attr] = val; return this; }; }; var attrs = ["years", "months", "days", "hours", "minutes", "seconds", "milliseconds"]; var addSetFuncs = function (context, attrs) { for (var i = 0; i < attrs.length ; i++) { var $a = attrs[i], $b = $a.slice(0, 1).toUpperCase() + $a.slice(1); context.prototype[$a] = 0; context.prototype["get" + $b] = gFn($a); context.prototype["set" + $b] = sFn($a); } }; /** * new TimeSpan(milliseconds); * new TimeSpan(days, hours, minutes, seconds); * new TimeSpan(days, hours, minutes, seconds, milliseconds); */ var TimeSpan = function (days, hours, minutes, seconds, milliseconds) { if (arguments.length === 1 && typeof days === "number") { var orient = (days < 0) ? -1 : +1; var millsLeft = Math.abs(days); this.setDays(Math.floor(millsLeft / 86400000) * orient); millsLeft = millsLeft % 86400000; this.setHours(Math.floor(millsLeft / 3600000) * orient); millsLeft = millsLeft % 3600000; this.setMinutes(Math.floor(millsLeft / 60000) * orient); millsLeft = millsLeft % 60000; this.setSeconds(Math.floor(millsLeft / 1000) * orient); millsLeft = millsLeft % 1000; this.setMilliseconds(millsLeft * orient); } else { this.set(days, hours, minutes, seconds, milliseconds); } this.getTotalMilliseconds = function () { return (this.getDays() * 86400000) + (this.getHours() * 3600000) + (this.getMinutes() * 60000) + (this.getSeconds() * 1000); }; this.compareTo = function (time) { var t1 = new Date(1970, 1, 1, this.getHours(), this.getMinutes(), this.getSeconds()), t2; if (time === null) { t2 = new Date(1970, 1, 1, 0, 0, 0); } else { t2 = new Date(1970, 1, 1, time.getHours(), time.getMinutes(), time.getSeconds()); } return (t1 < t2) ? -1 : (t1 > t2) ? 1 : 0; }; this.equals = function (time) { return (this.compareTo(time) === 0); }; this.add = function (time) { return (time === null) ? this : this.addSeconds(time.getTotalMilliseconds() / 1000); }; this.subtract = function (time) { return (time === null) ? this : this.addSeconds(-time.getTotalMilliseconds() / 1000); }; this.addDays = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 86400000)); }; this.addHours = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 3600000)); }; this.addMinutes = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 60000)); }; this.addSeconds = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 1000)); }; this.addMilliseconds = function (n) { return new TimeSpan(this.getTotalMilliseconds() + n); }; this.get12HourHour = function () { return (this.getHours() > 12) ? this.getHours() - 12 : (this.getHours() === 0) ? 12 : this.getHours(); }; this.getDesignator = function () { return (this.getHours() < 12) ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator; }; this.toString = function (format) { this._toString = function () { if (this.getDays() !== null && this.getDays() > 0) { return this.getDays() + "." + this.getHours() + ":" + this.p(this.getMinutes()) + ":" + this.p(this.getSeconds()); } else { return this.getHours() + ":" + this.p(this.getMinutes()) + ":" + this.p(this.getSeconds()); } }; this.p = function (s) { return (s.toString().length < 2) ? "0" + s : s; }; var me = this; return format ? format.replace(/dd?|HH?|hh?|mm?|ss?|tt?/g, function (format) { switch (format) { case "d": return me.getDays(); case "dd": return me.p(me.getDays()); case "H": return me.getHours(); case "HH": return me.p(me.getHours()); case "h": return me.get12HourHour(); case "hh": return me.p(me.get12HourHour()); case "m": return me.getMinutes(); case "mm": return me.p(me.getMinutes()); case "s": return me.getSeconds(); case "ss": return me.p(me.getSeconds()); case "t": return ((me.getHours() < 12) ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator).substring(0, 1); case "tt": return (me.getHours() < 12) ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator; } } ) : this._toString(); }; return this; }; addSetFuncs(TimeSpan, attrs.slice(2)); TimeSpan.prototype.set = function (days, hours, minutes, seconds, milliseconds){ this.setDays(days || this.getDays()); this.setHours(hours || this.getHours()); this.setMinutes(minutes || this.getMinutes()); this.setSeconds(seconds || this.getSeconds()); this.setMilliseconds(milliseconds || this.getMilliseconds()); }; /** * Gets the time of day for this date instances. * @return {TimeSpan} TimeSpan */ Date.prototype.getTimeOfDay = function () { return new TimeSpan(0, this.getHours(), this.getMinutes(), this.getSeconds(), this.getMilliseconds()); }; Date.TimeSpan = TimeSpan; if (typeof window !== "undefined" ) { // keeping API compatible for v1.x window.TimeSpan = TimeSpan; } }()); (function () { "use strict"; var attrs = ["years", "months", "days", "hours", "minutes", "seconds", "milliseconds"]; var gFn = function (attr) { return function () { return this[attr]; }; }; var sFn = function (attr) { return function (val) { this[attr] = val; return this; }; }; var addSetFuncs = function (context, attrs) { for (var i = 0; i < attrs.length ; i++) { var $a = attrs[i], $b = $a.slice(0, 1).toUpperCase() + $a.slice(1); context.prototype[$a] = 0; context.prototype["get" + $b] = gFn($a); context.prototype["set" + $b] = sFn($a); } }; var setMonthsAndYears = function (orient, d1, d2, context) { function inc() { d1.addMonths(-orient); context.months++; if (context.months === 12) { context.years++; context.months = 0; } } if (orient === +1) { while (d1 > d2) { inc(); } } else { while (d1 < d2) { inc(); } } context.months--; context.months *= orient; context.years *= orient; }; var adjustForDST = function(orient, startDate, endDate) { var hasDSTMismatch = (false === (startDate.isDaylightSavingTime() === endDate.isDaylightSavingTime())); if (hasDSTMismatch && orient === 1) { startDate.addHours(-1); } else if (hasDSTMismatch) { startDate.addHours(1); } }; /** * TimePeriod(startDate, endDate); * TimePeriod(years, months, days, hours, minutes, seconds, milliseconds); */ var TimePeriod = function (years, months, days, hours, minutes, seconds, milliseconds) { if (arguments.length === 7) { this.set(years, months, days, hours, minutes, seconds, milliseconds); } else if (arguments.length === 2 && arguments[0] instanceof Date && arguments[1] instanceof Date) { var startDate = arguments[0].clone(); var endDate = arguments[1].clone(); var orient = (startDate > endDate) ? +1 : -1; this.dates = { start: arguments[0].clone(), end: arguments[1].clone() }; setMonthsAndYears(orient, startDate, endDate, this); adjustForDST(orient, startDate, endDate); // // TODO - adjust for DST var diff = endDate - startDate; if (diff !== 0) { var ts = new TimeSpan(diff); this.set(this.years, this.months, ts.getDays(), ts.getHours(), ts.getMinutes(), ts.getSeconds(), ts.getMilliseconds()); } } return this; }; // create all the set functions. addSetFuncs(TimePeriod, attrs); TimePeriod.prototype.set = function (years, months, days, hours, minutes, seconds, milliseconds){ this.setYears(years || this.getYears()); this.setMonths(months || this.getMonths()); this.setDays(days || this.getDays()); this.setHours(hours || this.getHours()); this.setMinutes(minutes || this.getMinutes()); this.setSeconds(seconds || this.getSeconds()); this.setMilliseconds(milliseconds || this.getMilliseconds()); }; Date.TimePeriod = TimePeriod; if (typeof window !== "undefined") { // keeping API compatible for v1.x window.TimePeriod = TimePeriod; } }()); ================================================ FILE: build/date-ka-GE.js ================================================ /** * @overview datejs * @version 1.0.0-rc3 * @author Gregory Wild-Smith * @copyright 2015 Gregory Wild-Smith * @license MIT * @homepage https://github.com/abritinthebay/datejs */ /* * DateJS Culture String File * Country Code: ka-GE * Name: Georgian (Georgia) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["ka-GE"] = { "name": "ka-GE", "englishName": "Georgian (Georgia)", "nativeName": "ქართული (საქართველო)", "Sunday": "კვირა", "Monday": "ორშაბათი", "Tuesday": "სამშაბათი", "Wednesday": "ოთხშაბათი", "Thursday": "ხუთშაბათი", "Friday": "პარასკევი", "Saturday": "შაბათი", "Sun": "კვირა", "Mon": "ორშაბათი", "Tue": "სამშაბათი", "Wed": "ოთხშაბათი", "Thu": "ხუთშაბათი", "Fri": "პარასკევი", "Sat": "შაბათი", "Su": "კ", "Mo": "ო", "Tu": "ს", "We": "ო", "Th": "ხ", "Fr": "პ", "Sa": "შ", "S_Sun_Initial": "კ", "M_Mon_Initial": "ო", "T_Tue_Initial": "ს", "W_Wed_Initial": "ო", "T_Thu_Initial": "ხ", "F_Fri_Initial": "პ", "S_Sat_Initial": "შ", "January": "იანვარი", "February": "თებერვალი", "March": "მარტი", "April": "აპრილი", "May": "მაისი", "June": "ივნისი", "July": "ივლისი", "August": "აგვისტო", "September": "სექტემბერი", "October": "ოქტომბერი", "November": "ნოემბერი", "December": "დეკემბერი", "Jan_Abbr": "იან", "Feb_Abbr": "თებ", "Mar_Abbr": "მარ", "Apr_Abbr": "აპრ", "May_Abbr": "მაის", "Jun_Abbr": "ივნ", "Jul_Abbr": "ივლ", "Aug_Abbr": "აგვ", "Sep_Abbr": "სექ", "Oct_Abbr": "ოქტ", "Nov_Abbr": "ნოემ", "Dec_Abbr": "დეკ", "AM": "", "PM": "", "firstDayOfWeek": 1, "twoDigitYearMax": 2029, "mdy": "dmy", "M/d/yyyy": "dd.MM.yyyy", "dddd, MMMM dd, yyyy": "yyyy 'წლის' dd MM, dddd", "h:mm tt": "H:mm", "h:mm:ss tt": "H:mm:ss", "dddd, MMMM dd, yyyy h:mm:ss tt": "yyyy 'წლის' dd MM, dddd H:mm:ss", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "dd MM", "MMMM, yyyy": "MMMM yyyy", "/jan(uary)?/": "იან(ვარი)?", "/feb(ruary)?/": "თებ(ერვალი)?", "/mar(ch)?/": "მარ(ტი)?", "/apr(il)?/": "აპრ(ილი)?", "/may/": "მაის(ი)?", "/jun(e)?/": "ივნ(ისი)?", "/jul(y)?/": "ივლ(ისი)?", "/aug(ust)?/": "აგვ(ისტო)?", "/sep(t(ember)?)?/": "სექ(ტემბერი)?", "/oct(ober)?/": "ოქტ(ომბერი)?", "/nov(ember)?/": "ნოემ(ბერი)?", "/dec(ember)?/": "დეკ(ემბერი)?", "/^su(n(day)?)?/": "^კ(1)?", "/^mo(n(day)?)?/": "^ო(1)?", "/^tu(e(s(day)?)?)?/": "^ს(1)?", "/^we(d(nesday)?)?/": "^ო(1)?", "/^th(u(r(s(day)?)?)?)?/": "^ხ(1)?", "/^fr(i(day)?)?/": "^პ(1)?", "/^sa(t(urday)?)?/": "^შ(1)?", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "ka-GE"; /** * @overview datejs * @version 1.0.0-rc3 * @author Gregory Wild-Smith * @copyright 2015 Gregory Wild-Smith * @license MIT * @homepage https://github.com/abritinthebay/datejs */(function () { var $D = Date; var lang = Date.CultureStrings ? Date.CultureStrings.lang : null; var loggedKeys = {}; // for debug purposes. var getText = { getFromKey: function (key, countryCode) { var output; if (Date.CultureStrings && Date.CultureStrings[countryCode] && Date.CultureStrings[countryCode][key]) { output = Date.CultureStrings[countryCode][key]; } else { output = getText.buildFromDefault(key); } if (key.charAt(0) === "/") { // Assume it's a regex output = getText.buildFromRegex(key, countryCode); } return output; }, getFromObjectValues: function (obj, countryCode) { var key, output = {}; for(key in obj) { if (obj.hasOwnProperty(key)) { output[key] = getText.getFromKey(obj[key], countryCode); } } return output; }, getFromObjectKeys: function (obj, countryCode) { var key, output = {}; for(key in obj) { if (obj.hasOwnProperty(key)) { output[getText.getFromKey(key, countryCode)] = obj[key]; } } return output; }, getFromArray: function (arr, countryCode) { var output = []; for (var i=0; i < arr.length; i++){ if (i in arr) { output[i] = getText.getFromKey(arr[i], countryCode); } } return output; }, buildFromDefault: function (key) { var output, length, split, last; switch(key) { case "name": output = "en-US"; break; case "englishName": output = "English (United States)"; break; case "nativeName": output = "English (United States)"; break; case "twoDigitYearMax": output = 2049; break; case "firstDayOfWeek": output = 0; break; default: output = key; split = key.split("_"); length = split.length; if (length > 1 && key.charAt(0) !== "/") { // if the key isn't a regex and it has a split. last = split[(length - 1)].toLowerCase(); if (last === "initial" || last === "abbr") { output = split[0]; } } break; } return output; }, buildFromRegex: function (key, countryCode) { var output; if (Date.CultureStrings && Date.CultureStrings[countryCode] && Date.CultureStrings[countryCode][key]) { output = new RegExp(Date.CultureStrings[countryCode][key], "i"); } else { output = new RegExp(key.replace(new RegExp("/", "g"),""), "i"); } return output; } }; var shallowMerge = function (obj1, obj2) { for (var attrname in obj2) { if (obj2.hasOwnProperty(attrname)) { obj1[attrname] = obj2[attrname]; } } }; var __ = function (key, language) { var countryCode = (language) ? language : lang; loggedKeys[key] = key; if (typeof key === "object") { if (key instanceof Array) { return getText.getFromArray(key, countryCode); } else { return getText.getFromObjectKeys(key, countryCode); } } else { return getText.getFromKey(key, countryCode); } }; var loadI18nScript = function (code) { // paatterned after jQuery's getScript. var url = Date.Config.i18n + code + ".js"; var head = document.getElementsByTagName("head")[0] || document.documentElement; var script = document.createElement("script"); script.src = url; var completed = false; var events = { done: function (){} // placeholder function }; // Attach handlers for all browsers script.onload = script.onreadystatechange = function() { if ( !completed && (!this.readyState || this.readyState === "loaded" || this.readyState === "complete") ) { events.done(); head.removeChild(script); } }; setTimeout(function() { head.insertBefore(script, head.firstChild); }, 0); // allows return to execute first return { done: function (cb) { events.done = function() { if (cb) { setTimeout(cb,0); } }; } }; }; var buildInfo = { buildFromMethodHash: function (obj) { var key; for(key in obj) { if (obj.hasOwnProperty(key)) { obj[key] = buildInfo[obj[key]](); } } return obj; }, timeZoneDST: function () { var DST = { "CHADT": "+1345", "NZDT": "+1300", "AEDT": "+1100", "ACDT": "+1030", "AZST": "+0500", "IRDT": "+0430", "EEST": "+0300", "CEST": "+0200", "BST": "+0100", "PMDT": "-0200", "ADT": "-0300", "NDT": "-0230", "EDT": "-0400", "CDT": "-0500", "MDT": "-0600", "PDT": "-0700", "AKDT": "-0800", "HADT": "-0900" }; return __(DST); }, timeZoneStandard: function () { var standard = { "LINT": "+1400", "TOT": "+1300", "CHAST": "+1245", "NZST": "+1200", "NFT": "+1130", "SBT": "+1100", "AEST": "+1000", "ACST": "+0930", "JST": "+0900", "CWST": "+0845", "CT": "+0800", "ICT": "+0700", "MMT": "+0630", "BST": "+0600", "NPT": "+0545", "IST": "+0530", "PKT": "+0500", "AFT": "+0430", "MSK": "+0400", "IRST": "+0330", "FET": "+0300", "EET": "+0200", "CET": "+0100", "GMT": "+0000", "UTC": "+0000", "CVT": "-0100", "GST": "-0200", "BRT": "-0300", "NST": "-0330", "AST": "-0400", "EST": "-0500", "CST": "-0600", "MST": "-0700", "PST": "-0800", "AKST": "-0900", "MIT": "-0930", "HST": "-1000", "SST": "-1100", "BIT": "-1200" }; return __(standard); }, timeZones: function (data) { var zone; data.timezones = []; for (zone in data.abbreviatedTimeZoneStandard) { if (data.abbreviatedTimeZoneStandard.hasOwnProperty(zone)) { data.timezones.push({ name: zone, offset: data.abbreviatedTimeZoneStandard[zone]}); } } for (zone in data.abbreviatedTimeZoneDST) { if (data.abbreviatedTimeZoneDST.hasOwnProperty(zone)) { data.timezones.push({ name: zone, offset: data.abbreviatedTimeZoneDST[zone], dst: true}); } } return data.timezones; }, days: function () { return __(["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"]); }, dayAbbr: function () { return __(["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"]); }, dayShortNames: function () { return __(["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"]); }, dayFirstLetters: function () { return __(["S_Sun_Initial", "M_Mon_Initial", "T_Tues_Initial", "W_Wed_Initial", "T_Thu_Initial", "F_Fri_Initial", "S_Sat_Initial"]); }, months: function () { return __(["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"]); }, monthAbbr: function () { return __(["Jan_Abbr", "Feb_Abbr", "Mar_Abbr", "Apr_Abbr", "May_Abbr", "Jun_Abbr", "Jul_Abbr", "Aug_Abbr", "Sep_Abbr", "Oct_Abbr", "Nov_Abbr", "Dec_Abbr"]); }, formatPatterns: function () { return getText.getFromObjectValues({ shortDate: "M/d/yyyy", longDate: "dddd, MMMM dd, yyyy", shortTime: "h:mm tt", longTime: "h:mm:ss tt", fullDateTime: "dddd, MMMM dd, yyyy h:mm:ss tt", sortableDateTime: "yyyy-MM-ddTHH:mm:ss", universalSortableDateTime: "yyyy-MM-dd HH:mm:ssZ", rfc1123: "ddd, dd MMM yyyy HH:mm:ss", monthDay: "MMMM dd", yearMonth: "MMMM, yyyy" }, Date.i18n.currentLanguage()); }, regex: function () { return getText.getFromObjectValues({ inTheMorning: "/( in the )(morn(ing)?)\\b/", thisMorning: "/(this )(morn(ing)?)\\b/", amThisMorning: "/(\b\\d(am)? )(this )(morn(ing)?)/", inTheEvening: "/( in the )(even(ing)?)\\b/", thisEvening: "/(this )(even(ing)?)\\b/", pmThisEvening: "/(\b\\d(pm)? )(this )(even(ing)?)/", jan: "/jan(uary)?/", feb: "/feb(ruary)?/", mar: "/mar(ch)?/", apr: "/apr(il)?/", may: "/may/", jun: "/jun(e)?/", jul: "/jul(y)?/", aug: "/aug(ust)?/", sep: "/sep(t(ember)?)?/", oct: "/oct(ober)?/", nov: "/nov(ember)?/", dec: "/dec(ember)?/", sun: "/^su(n(day)?)?/", mon: "/^mo(n(day)?)?/", tue: "/^tu(e(s(day)?)?)?/", wed: "/^we(d(nesday)?)?/", thu: "/^th(u(r(s(day)?)?)?)?/", fri: "/fr(i(day)?)?/", sat: "/^sa(t(urday)?)?/", future: "/^next/", past: "/^last|past|prev(ious)?/", add: "/^(\\+|aft(er)?|from|hence)/", subtract: "/^(\\-|bef(ore)?|ago)/", yesterday: "/^yes(terday)?/", today: "/^t(od(ay)?)?/", tomorrow: "/^tom(orrow)?/", now: "/^n(ow)?/", millisecond: "/^ms|milli(second)?s?/", second: "/^sec(ond)?s?/", minute: "/^mn|min(ute)?s?/", hour: "/^h(our)?s?/", week: "/^w(eek)?s?/", month: "/^m(onth)?s?/", day: "/^d(ay)?s?/", year: "/^y(ear)?s?/", shortMeridian: "/^(a|p)/", longMeridian: "/^(a\\.?m?\\.?|p\\.?m?\\.?)/", timezone: "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/", ordinalSuffix: "/^\\s*(st|nd|rd|th)/", timeContext: "/^\\s*(\\:|a(?!u|p)|p)/" }, Date.i18n.currentLanguage()); } }; var CultureInfo = function () { var info = getText.getFromObjectValues({ name: "name", englishName: "englishName", nativeName: "nativeName", amDesignator: "AM", pmDesignator: "PM", firstDayOfWeek: "firstDayOfWeek", twoDigitYearMax: "twoDigitYearMax", dateElementOrder: "mdy" }, Date.i18n.currentLanguage()); var constructedInfo = buildInfo.buildFromMethodHash({ dayNames: "days", abbreviatedDayNames: "dayAbbr", shortestDayNames: "dayShortNames", firstLetterDayNames: "dayFirstLetters", monthNames: "months", abbreviatedMonthNames: "monthAbbr", formatPatterns: "formatPatterns", regexPatterns: "regex", abbreviatedTimeZoneDST: "timeZoneDST", abbreviatedTimeZoneStandard: "timeZoneStandard" }); shallowMerge(info, constructedInfo); buildInfo.timeZones(info); return info; }; $D.i18n = { __: function (key, lang) { return __(key, lang); }, currentLanguage: function () { return lang || "en-US"; }, setLanguage: function (code, force, cb) { var async = false; if (force || code === "en-US" || (!!Date.CultureStrings && !!Date.CultureStrings[code])) { lang = code; Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings.lang = code; Date.CultureInfo = new CultureInfo(); } else { if (!(!!Date.CultureStrings && !!Date.CultureStrings[code])) { if (typeof exports !== "undefined" && this.exports !== exports) { // we're in a Node enviroment, load it using require try { require("../i18n/" + code + ".js"); lang = code; Date.CultureStrings.lang = code; Date.CultureInfo = new CultureInfo(); } catch (e) { // var str = "The language for '" + code + "' could not be loaded by Node. It likely does not exist."; throw new Error("The DateJS IETF language tag '" + code + "' could not be loaded by Node. It likely does not exist."); } } else if (Date.Config && Date.Config.i18n) { // we know the location of the files, so lets load them async = true; loadI18nScript(code).done(function(){ lang = code; Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings.lang = code; Date.CultureInfo = new CultureInfo(); $D.Parsing.Normalizer.buildReplaceData(); // because this is async if ($D.Grammar) { $D.Grammar.buildGrammarFormats(); // so we can parse those strings... } if (cb) { setTimeout(cb,0); } }); } else { Date.console.error("The DateJS IETF language tag '" + code + "' is not available and has not been loaded."); return false; } } } $D.Parsing.Normalizer.buildReplaceData(); // rebuild normalizer strings if ($D.Grammar) { $D.Grammar.buildGrammarFormats(); // so we can parse those strings... } if (!async && cb) { setTimeout(cb,0); } }, getLoggedKeys: function () { return loggedKeys; }, updateCultureInfo: function () { Date.CultureInfo = new CultureInfo(); } }; $D.i18n.updateCultureInfo(); // run automatically }()); (function () { var $D = Date, $P = $D.prototype, p = function (s, l) { if (!l) { l = 2; } return ("000" + s).slice(l * -1); }; if (typeof window !== "undefined" && typeof window.console !== "undefined" && typeof window.console.log !== "undefined") { $D.console = console; // used only to raise non-critical errors if available } else { // set mock so we don't give errors. $D.console = { log: function(){}, error: function(){} }; } $D.Config = $D.Config || {}; $D.initOverloads = function() { /** * Overload of Date.now. Allows an alternate call for Date.now where it returns the * current Date as an object rather than just milliseconds since the Unix Epoch. * * Also provides an implementation of now() for browsers (IE<9) that don't have it. * * Backwards compatible so with work with either: * Date.now() [returns ms] * or * Date.now(true) [returns Date] */ if (!$D.now) { $D._now = function now() { return new Date().getTime(); }; } else if (!$D._now) { $D._now = $D.now; } $D.now = function (returnObj) { if (returnObj) { return $D.present(); } else { return $D._now(); } }; if ( !$P.toISOString ) { $P.toISOString = function() { return this.getUTCFullYear() + "-" + p(this.getUTCMonth() + 1) + "-" + p(this.getUTCDate()) + "T" + p(this.getUTCHours()) + ":" + p(this.getUTCMinutes()) + ":" + p(this.getUTCSeconds()) + "." + String( (this.getUTCMilliseconds()/1000).toFixed(3)).slice(2, 5) + "Z"; }; } // private if ( $P._toString === undefined ){ $P._toString = $P.toString; } }; $D.initOverloads(); /** * Gets a date that is set to the current date. The time is set to the start of the day (00:00 or 12:00 AM). * @return {Date} The current date. */ $D.today = function () { return new Date().clearTime(); }; /** * Gets a date that is set to the current date and time (same as new Date, but chainable) * @return {Date} The current date. */ $D.present = function () { return new Date(); }; /** * Compares the first date to the second date and returns an number indication of their relative values. * @param {Date} First Date object to compare [Required]. * @param {Date} Second Date object to compare to [Required]. * @return {Number} -1 = date1 is lessthan date2. 0 = values are equal. 1 = date1 is greaterthan date2. */ $D.compare = function (date1, date2) { if (isNaN(date1) || isNaN(date2)) { throw new Error(date1 + " - " + date2); } else if (date1 instanceof Date && date2 instanceof Date) { return (date1 < date2) ? -1 : (date1 > date2) ? 1 : 0; } else { throw new TypeError(date1 + " - " + date2); } }; /** * Compares the first Date object to the second Date object and returns true if they are equal. * @param {Date} First Date object to compare [Required] * @param {Date} Second Date object to compare to [Required] * @return {Boolean} true if dates are equal. false if they are not equal. */ $D.equals = function (date1, date2) { return (date1.compareTo(date2) === 0); }; /** * Gets the language appropriate day name when given the day number(0-6) * eg - 0 == Sunday * @return {String} The day name */ $D.getDayName = function (n) { return Date.CultureInfo.dayNames[n]; }; /** * Gets the day number (0-6) if given a CultureInfo specific string which is a valid dayName, abbreviatedDayName or shortestDayName (two char). * @param {String} The name of the day (eg. "Monday, "Mon", "tuesday", "tue", "We", "we"). * @return {Number} The day number */ $D.getDayNumberFromName = function (name) { var n = Date.CultureInfo.dayNames, m = Date.CultureInfo.abbreviatedDayNames, o = Date.CultureInfo.shortestDayNames, s = name.toLowerCase(); for (var i = 0; i < n.length; i++) { if (n[i].toLowerCase() === s || m[i].toLowerCase() === s || o[i].toLowerCase() === s) { return i; } } return -1; }; /** * Gets the month number (0-11) if given a Culture Info specific string which is a valid monthName or abbreviatedMonthName. * @param {String} The name of the month (eg. "February, "Feb", "october", "oct"). * @return {Number} The day number */ $D.getMonthNumberFromName = function (name) { var n = Date.CultureInfo.monthNames, m = Date.CultureInfo.abbreviatedMonthNames, s = name.toLowerCase(); for (var i = 0; i < n.length; i++) { if (n[i].toLowerCase() === s || m[i].toLowerCase() === s) { return i; } } return -1; }; /** * Gets the language appropriate month name when given the month number(0-11) * eg - 0 == January * @return {String} The month name */ $D.getMonthName = function (n) { return Date.CultureInfo.monthNames[n]; }; /** * Determines if the current date instance is within a LeapYear. * @param {Number} The year. * @return {Boolean} true if date is within a LeapYear, otherwise false. */ $D.isLeapYear = function (year) { return ((year % 4 === 0 && year % 100 !== 0) || year % 400 === 0); }; /** * Gets the number of days in the month, given a year and month value. Automatically corrects for LeapYear. * @param {Number} The year. * @param {Number} The month (0-11). * @return {Number} The number of days in the month. */ $D.getDaysInMonth = function (year, month) { if (!month && $D.validateMonth(year)) { month = year; year = Date.today().getFullYear(); } return [31, ($D.isLeapYear(year) ? 29 : 28), 31, 30, 31, 30, 31, 31, 30, 31, 30, 31][month]; }; $P.getDaysInMonth = function () { return $D.getDaysInMonth(this.getFullYear(), this.getMonth()); }; $D.getTimezoneAbbreviation = function (offset, dst) { var p, n = (dst || false) ? Date.CultureInfo.abbreviatedTimeZoneDST : Date.CultureInfo.abbreviatedTimeZoneStandard; for (p in n) { if (n.hasOwnProperty(p)) { if (n[p] === offset) { return p; } } } return null; }; $D.getTimezoneOffset = function (name, dst) { var i, a =[], z = Date.CultureInfo.timezones; if (!name) { name = (new Date()).getTimezone();} for (i = 0; i < z.length; i++) { if (z[i].name === name.toUpperCase()) { a.push(i); } } if (!z[a[0]]) { return null; } if (a.length === 1 || !dst) { return z[a[0]].offset; } else { for (i=0; i < a.length; i++) { if (z[a[i]].dst) { return z[a[i]].offset; } } } }; $D.getQuarter = function (d) { d = d || new Date(); // If no date supplied, use today var q = [1,2,3,4]; return q[Math.floor(d.getMonth() / 3)]; // ~~~ is a bitwise op. Faster than Math.floor }; $D.getDaysLeftInQuarter = function (d) { d = d || new Date(); var qEnd = new Date(d); qEnd.setMonth(qEnd.getMonth() + 3 - qEnd.getMonth() % 3, 0); return Math.floor((qEnd - d) / 8.64e7); }; // private var validate = function (n, min, max, name) { name = name ? name : "Object"; if (typeof n === "undefined") { return false; } else if (typeof n !== "number") { throw new TypeError(n + " is not a Number."); } else if (n < min || n > max) { // As failing validation is *not* an exceptional circumstance // lets not throw a RangeError Exception here. // It's semantically correct but it's not sensible. return false; } return true; }; /** * Validates the number is within an acceptable range for milliseconds [0-999]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateMillisecond = function (value) { return validate(value, 0, 999, "millisecond"); }; /** * Validates the number is within an acceptable range for seconds [0-59]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateSecond = function (value) { return validate(value, 0, 59, "second"); }; /** * Validates the number is within an acceptable range for minutes [0-59]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateMinute = function (value) { return validate(value, 0, 59, "minute"); }; /** * Validates the number is within an acceptable range for hours [0-23]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateHour = function (value) { return validate(value, 0, 23, "hour"); }; /** * Validates the number is within an acceptable range for the days in a month [0-MaxDaysInMonth]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateDay = function (value, year, month) { if (year === undefined || year === null || month === undefined || month === null) { return false;} return validate(value, 1, $D.getDaysInMonth(year, month), "day"); }; /** * Validates the number is within an acceptable range for months [0-11]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateWeek = function (value) { return validate(value, 0, 53, "week"); }; /** * Validates the number is within an acceptable range for months [0-11]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateMonth = function (value) { return validate(value, 0, 11, "month"); }; /** * Validates the number is within an acceptable range for years. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateYear = function (value) { /** * Per ECMAScript spec the range of times supported by Date objects is * exactly -100,000,000 days to +100,000,000 days measured relative to * midnight at the beginning of 01 January, 1970 UTC. * This gives a range of 8,640,000,000,000,000 milliseconds to either * side of 01 January, 1970 UTC. * * Earliest possible date: Tue, 20 Apr 271,822 B.C. 00:00:00 UTC * Latest possible date: Sat, 13 Sep 275,760 00:00:00 UTC */ return validate(value, -271822, 275760, "year"); }; $D.validateTimezone = function(value) { var timezones = {"ACDT":1,"ACST":1,"ACT":1,"ADT":1,"AEDT":1,"AEST":1,"AFT":1,"AKDT":1,"AKST":1,"AMST":1,"AMT":1,"ART":1,"AST":1,"AWDT":1,"AWST":1,"AZOST":1,"AZT":1,"BDT":1,"BIOT":1,"BIT":1,"BOT":1,"BRT":1,"BST":1,"BTT":1,"CAT":1,"CCT":1,"CDT":1,"CEDT":1,"CEST":1,"CET":1,"CHADT":1,"CHAST":1,"CHOT":1,"ChST":1,"CHUT":1,"CIST":1,"CIT":1,"CKT":1,"CLST":1,"CLT":1,"COST":1,"COT":1,"CST":1,"CT":1,"CVT":1,"CWST":1,"CXT":1,"DAVT":1,"DDUT":1,"DFT":1,"EASST":1,"EAST":1,"EAT":1,"ECT":1,"EDT":1,"EEDT":1,"EEST":1,"EET":1,"EGST":1,"EGT":1,"EIT":1,"EST":1,"FET":1,"FJT":1,"FKST":1,"FKT":1,"FNT":1,"GALT":1,"GAMT":1,"GET":1,"GFT":1,"GILT":1,"GIT":1,"GMT":1,"GST":1,"GYT":1,"HADT":1,"HAEC":1,"HAST":1,"HKT":1,"HMT":1,"HOVT":1,"HST":1,"ICT":1,"IDT":1,"IOT":1,"IRDT":1,"IRKT":1,"IRST":1,"IST":1,"JST":1,"KGT":1,"KOST":1,"KRAT":1,"KST":1,"LHST":1,"LINT":1,"MAGT":1,"MART":1,"MAWT":1,"MDT":1,"MET":1,"MEST":1,"MHT":1,"MIST":1,"MIT":1,"MMT":1,"MSK":1,"MST":1,"MUT":1,"MVT":1,"MYT":1,"NCT":1,"NDT":1,"NFT":1,"NPT":1,"NST":1,"NT":1,"NUT":1,"NZDT":1,"NZST":1,"OMST":1,"ORAT":1,"PDT":1,"PET":1,"PETT":1,"PGT":1,"PHOT":1,"PHT":1,"PKT":1,"PMDT":1,"PMST":1,"PONT":1,"PST":1,"PYST":1,"PYT":1,"RET":1,"ROTT":1,"SAKT":1,"SAMT":1,"SAST":1,"SBT":1,"SCT":1,"SGT":1,"SLST":1,"SRT":1,"SST":1,"SYOT":1,"TAHT":1,"THA":1,"TFT":1,"TJT":1,"TKT":1,"TLT":1,"TMT":1,"TOT":1,"TVT":1,"UCT":1,"ULAT":1,"UTC":1,"UYST":1,"UYT":1,"UZT":1,"VET":1,"VLAT":1,"VOLT":1,"VOST":1,"VUT":1,"WAKT":1,"WAST":1,"WAT":1,"WEDT":1,"WEST":1,"WET":1,"WST":1,"YAKT":1,"YEKT":1,"Z":1}; return (timezones[value] === 1); }; $D.validateTimezoneOffset= function(value) { // timezones go from +14hrs to -12hrs, the +X hours are negative offsets. return (value > -841 && value < 721); }; }()); (function () { var $D = Date, $P = $D.prototype, p = function (s, l) { if (!l) { l = 2; } return ("000" + s).slice(l * -1); }; var validateConfigObject = function (obj) { var result = {}, self = this, prop, testFunc; testFunc = function (prop, func, value) { if (prop === "day") { var month = (obj.month !== undefined) ? obj.month : self.getMonth(); var year = (obj.year !== undefined) ? obj.year : self.getFullYear(); return $D[func](value, year, month); } else { return $D[func](value); } }; for (prop in obj) { if (Object.prototype.hasOwnProperty.call(obj, prop)) { var func = "validate" + prop.charAt(0).toUpperCase() + prop.slice(1); if ($D[func] && obj[prop] !== null && testFunc(prop, func, obj[prop])) { result[prop] = obj[prop]; } } } return result; }; /** * Resets the time of this Date object to 12:00 AM (00:00), which is the start of the day. * @param {Boolean} .clone() this date instance before clearing Time * @return {Date} this */ $P.clearTime = function () { this.setHours(0); this.setMinutes(0); this.setSeconds(0); this.setMilliseconds(0); return this; }; /** * Resets the time of this Date object to the current time ('now'). * @return {Date} this */ $P.setTimeToNow = function () { var n = new Date(); this.setHours(n.getHours()); this.setMinutes(n.getMinutes()); this.setSeconds(n.getSeconds()); this.setMilliseconds(n.getMilliseconds()); return this; }; /** * Returns a new Date object that is an exact date and time copy of the original instance. * @return {Date} A new Date instance */ $P.clone = function () { return new Date(this.getTime()); }; /** * Compares this instance to a Date object and returns an number indication of their relative values. * @param {Date} Date object to compare [Required] * @return {Number} -1 = this is lessthan date. 0 = values are equal. 1 = this is greaterthan date. */ $P.compareTo = function (date) { return Date.compare(this, date); }; /** * Compares this instance to another Date object and returns true if they are equal. * @param {Date} Date object to compare. If no date to compare, new Date() [now] is used. * @return {Boolean} true if dates are equal. false if they are not equal. */ $P.equals = function (date) { return Date.equals(this, (date !== undefined ? date : new Date())); }; /** * Determines if this instance is between a range of two dates or equal to either the start or end dates. * @param {Date} Start of range [Required] * @param {Date} End of range [Required] * @return {Boolean} true is this is between or equal to the start and end dates, else false */ $P.between = function (start, end) { return this.getTime() >= start.getTime() && this.getTime() <= end.getTime(); }; /** * Determines if this date occurs after the date to compare to. * @param {Date} Date object to compare. If no date to compare, new Date() ("now") is used. * @return {Boolean} true if this date instance is greater than the date to compare to (or "now"), otherwise false. */ $P.isAfter = function (date) { return this.compareTo(date || new Date()) === 1; }; /** * Determines if this date occurs before the date to compare to. * @param {Date} Date object to compare. If no date to compare, new Date() ("now") is used. * @return {Boolean} true if this date instance is less than the date to compare to (or "now"). */ $P.isBefore = function (date) { return (this.compareTo(date || new Date()) === -1); }; /** * Determines if the current Date instance occurs today. * @return {Boolean} true if this date instance is 'today', otherwise false. */ /** * Determines if the current Date instance occurs on the same Date as the supplied 'date'. * If no 'date' to compare to is provided, the current Date instance is compared to 'today'. * @param {date} Date object to compare. If no date to compare, the current Date ("now") is used. * @return {Boolean} true if this Date instance occurs on the same Day as the supplied 'date'. */ $P.isToday = $P.isSameDay = function (date) { return this.clone().clearTime().equals((date || new Date()).clone().clearTime()); }; /** * Adds the specified number of milliseconds to this instance. * @param {Number} The number of milliseconds to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addMilliseconds = function (value) { if (!value) { return this; } this.setTime(this.getTime() + value * 1); return this; }; /** * Adds the specified number of seconds to this instance. * @param {Number} The number of seconds to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addSeconds = function (value) { if (!value) { return this; } return this.addMilliseconds(value * 1000); }; /** * Adds the specified number of seconds to this instance. * @param {Number} The number of seconds to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addMinutes = function (value) { if (!value) { return this; } return this.addMilliseconds(value * 60000); // 60*1000 }; /** * Adds the specified number of hours to this instance. * @param {Number} The number of hours to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addHours = function (value) { if (!value) { return this; } return this.addMilliseconds(value * 3600000); // 60*60*1000 }; /** * Adds the specified number of days to this instance. * @param {Number} The number of days to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addDays = function (value) { if (!value) { return this; } this.setDate(this.getDate() + value * 1); return this; }; /** * Adds the specified number of weekdays (ie - not sat or sun) to this instance. * @param {Number} The number of days to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addWeekdays = function (value) { if (!value) { return this; } var day = this.getDay(); var weeks = (Math.ceil(Math.abs(value)/7)); if (day === 0 || day === 6) { if (value > 0) { this.next().monday(); this.addDays(-1); day = this.getDay(); } } if (value < 0) { while (value < 0) { this.addDays(-1); day = this.getDay(); if (day !== 0 && day !== 6) { value++; } } return this; } else if (value > 5 || (6-day) <= value) { value = value + (weeks * 2); } return this.addDays(value); }; /** * Adds the specified number of weeks to this instance. * @param {Number} The number of weeks to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addWeeks = function (value) { if (!value) { return this; } return this.addDays(value * 7); }; /** * Adds the specified number of months to this instance. * @param {Number} The number of months to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addMonths = function (value) { if (!value) { return this; } var n = this.getDate(); this.setDate(1); this.setMonth(this.getMonth() + value * 1); this.setDate(Math.min(n, $D.getDaysInMonth(this.getFullYear(), this.getMonth()))); return this; }; $P.addQuarters = function (value) { if (!value) { return this; } // note this will take you to the same point in the quarter as you are now. // i.e. - if you are 15 days into the quarter you'll be 15 days into the resulting one. // bonus: this allows adding fractional quarters return this.addMonths(value * 3); }; /** * Adds the specified number of years to this instance. * @param {Number} The number of years to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addYears = function (value) { if (!value) { return this; } return this.addMonths(value * 12); }; /** * Adds (or subtracts) to the value of the years, months, weeks, days, hours, minutes, seconds, milliseconds of the date instance using given configuration object. Positive and Negative values allowed. * Example

	Date.today().add( { days: 1, months: 1 } )

	new Date().add( { years: -1 } )
	
* @param {Object} Configuration object containing attributes (months, days, etc.) * @return {Date} this */ $P.add = function (config) { if (typeof config === "number") { this._orient = config; return this; } var x = config; if (x.day) { // If we should be a different date than today (eg: for 'tomorrow -1d', etc). // Should only effect parsing, not direct usage (eg, Finish and FinishExact) if ((x.day - this.getDate()) !== 0) { this.setDate(x.day); } } if (x.milliseconds) { this.addMilliseconds(x.milliseconds); } if (x.seconds) { this.addSeconds(x.seconds); } if (x.minutes) { this.addMinutes(x.minutes); } if (x.hours) { this.addHours(x.hours); } if (x.weeks) { this.addWeeks(x.weeks); } if (x.months) { this.addMonths(x.months); } if (x.years) { this.addYears(x.years); } if (x.days) { this.addDays(x.days); } return this; }; /** * Get the week number. Week one (1) is the week which contains the first Thursday of the year. Monday is considered the first day of the week. * The .getWeek() function does NOT convert the date to UTC. The local datetime is used. * Please use .getISOWeek() to get the week of the UTC converted date. * @return {Number} 1 to 53 */ $P.getWeek = function (utc) { // Create a copy of this date object var self, target = new Date(this.valueOf()); if (utc) { target.addMinutes(target.getTimezoneOffset()); self = target.clone(); } else { self = this; } // ISO week date weeks start on monday // so correct the day number var dayNr = (self.getDay() + 6) % 7; // ISO 8601 states that week 1 is the week // with the first thursday of that year. // Set the target date to the thursday in the target week target.setDate(target.getDate() - dayNr + 3); // Store the millisecond value of the target date var firstThursday = target.valueOf(); // Set the target to the first thursday of the year // First set the target to january first target.setMonth(0, 1); // Not a thursday? Correct the date to the next thursday if (target.getDay() !== 4) { target.setMonth(0, 1 + ((4 - target.getDay()) + 7) % 7); } // The weeknumber is the number of weeks between the // first thursday of the year and the thursday in the target week return 1 + Math.ceil((firstThursday - target) / 604800000); // 604800000 = 7 * 24 * 3600 * 1000 }; /** * Get the ISO 8601 week number. Week one ("01") is the week which contains the first Thursday of the year. Monday is considered the first day of the week. * The .getISOWeek() function does convert the date to it's UTC value. Please use .getWeek() to get the week of the local date. * @return {String} "01" to "53" */ $P.getISOWeek = function () { return p(this.getWeek(true)); }; /** * Moves the date to Monday of the week set. Week one (1) is the week which contains the first Thursday of the year. * @param {Number} A Number (1 to 53) that represents the week of the year. * @return {Date} this */ $P.setWeek = function (n) { if ((n - this.getWeek()) === 0) { if (this.getDay() !== 1) { return this.moveToDayOfWeek(1, (this.getDay() > 1 ? -1 : 1)); } else { return this; } } else { return this.moveToDayOfWeek(1, (this.getDay() > 1 ? -1 : 1)).addWeeks(n - this.getWeek()); } }; $P.setQuarter = function (qtr) { var month = Math.abs(((qtr-1) * 3) + 1); return this.setMonth(month, 1); }; $P.getQuarter = function () { return Date.getQuarter(this); }; $P.getDaysLeftInQuarter = function () { return Date.getDaysLeftInQuarter(this); }; /** * Moves the date to the next n'th occurrence of the dayOfWeek starting from the beginning of the month. The number (-1) is a magic number and will return the last occurrence of the dayOfWeek in the month. * @param {Number} The dayOfWeek to move to * @param {Number} The n'th occurrence to move to. Use (-1) to return the last occurrence in the month * @return {Date} this */ $P.moveToNthOccurrence = function (dayOfWeek, occurrence) { if (dayOfWeek === "Weekday") { if (occurrence > 0) { this.moveToFirstDayOfMonth(); if (this.is().weekday()) { occurrence -= 1; } } else if (occurrence < 0) { this.moveToLastDayOfMonth(); if (this.is().weekday()) { occurrence += 1; } } else { return this; } return this.addWeekdays(occurrence); } var shift = 0; if (occurrence > 0) { shift = occurrence - 1; } else if (occurrence === -1) { this.moveToLastDayOfMonth(); if (this.getDay() !== dayOfWeek) { this.moveToDayOfWeek(dayOfWeek, -1); } return this; } return this.moveToFirstDayOfMonth().addDays(-1).moveToDayOfWeek(dayOfWeek, +1).addWeeks(shift); }; var moveToN = function (getFunc, addFunc, nVal) { return function (value, orient) { var diff = (value - this[getFunc]() + nVal * (orient || +1)) % nVal; return this[addFunc]((diff === 0) ? diff += nVal * (orient || +1) : diff); }; }; /** * Move to the next or last dayOfWeek based on the orient value. * @param {Number} The dayOfWeek to move to * @param {Number} Forward (+1) or Back (-1). Defaults to +1. [Optional] * @return {Date} this */ $P.moveToDayOfWeek = moveToN("getDay", "addDays", 7); /** * Move to the next or last month based on the orient value. * @param {Number} The month to move to. 0 = January, 11 = December * @param {Number} Forward (+1) or Back (-1). Defaults to +1. [Optional] * @return {Date} this */ $P.moveToMonth = moveToN("getMonth", "addMonths", 12); /** * Get the Ordinate of the current day ("th", "st", "rd"). * @return {String} */ $P.getOrdinate = function () { var num = this.getDate(); return ord(num); }; /** * Get the Ordinal day (numeric day number) of the year, adjusted for leap year. * @return {Number} 1 through 365 (366 in leap years) */ $P.getOrdinalNumber = function () { return Math.ceil((this.clone().clearTime() - new Date(this.getFullYear(), 0, 1)) / 86400000) + 1; }; /** * Get the time zone abbreviation of the current date. * @return {String} The abbreviated time zone name (e.g. "EST") */ $P.getTimezone = function () { return $D.getTimezoneAbbreviation(this.getUTCOffset(), this.isDaylightSavingTime()); }; $P.setTimezoneOffset = function (offset) { var here = this.getTimezoneOffset(), there = Number(offset) * -6 / 10; return (there || there === 0) ? this.addMinutes(there - here) : this; }; $P.setTimezone = function (offset) { return this.setTimezoneOffset($D.getTimezoneOffset(offset)); }; /** * Indicates whether Daylight Saving Time is observed in the current time zone. * @return {Boolean} true|false */ $P.hasDaylightSavingTime = function () { return (Date.today().set({month: 0, day: 1}).getTimezoneOffset() !== Date.today().set({month: 6, day: 1}).getTimezoneOffset()); }; /** * Indicates whether this Date instance is within the Daylight Saving Time range for the current time zone. * @return {Boolean} true|false */ $P.isDaylightSavingTime = function () { return Date.today().set({month: 0, day: 1}).getTimezoneOffset() !== this.getTimezoneOffset(); }; /** * Get the offset from UTC of the current date. * @return {String} The 4-character offset string prefixed with + or - (e.g. "-0500") */ $P.getUTCOffset = function (offset) { var n = (offset || this.getTimezoneOffset()) * -10 / 6, r; if (n < 0) { r = (n - 10000).toString(); return r.charAt(0) + r.substr(2); } else { r = (n + 10000).toString(); return "+" + r.substr(1); } }; /** * Returns the number of milliseconds between this date and date. * @param {Date} Defaults to now * @return {Number} The diff in milliseconds */ $P.getElapsed = function (date) { return (date || new Date()) - this; }; /** * Set the value of year, month, day, hour, minute, second, millisecond of date instance using given configuration object. * Example

	Date.today().set( { day: 20, month: 1 } )

	new Date().set( { millisecond: 0 } )
	
* * @param {Object} Configuration object containing attributes (month, day, etc.) * @return {Date} this */ $P.set = function (config) { config = validateConfigObject.call(this, config); var key; for (key in config) { if (Object.prototype.hasOwnProperty.call(config, key)) { var name = key.charAt(0).toUpperCase() + key.slice(1); var addFunc, getFunc; if (key !== "week" && key !== "month" && key !== "timezone" && key !== "timezoneOffset") { name += "s"; } addFunc = "add" + name; getFunc = "get" + name; if (key === "month") { addFunc = addFunc + "s"; } else if (key === "year"){ getFunc = "getFullYear"; } if (key !== "day" && key !== "timezone" && key !== "timezoneOffset" && key !== "week" && key !== "hour") { this[addFunc](config[key] - this[getFunc]()); } else if ( key === "timezone"|| key === "timezoneOffset" || key === "week" || key === "hour") { this["set"+name](config[key]); } } } // day has to go last because you can't validate the day without first knowing the month if (config.day) { this.addDays(config.day - this.getDate()); } return this; }; /** * Moves the date to the first day of the month. * @return {Date} this */ $P.moveToFirstDayOfMonth = function () { return this.set({ day: 1 }); }; /** * Moves the date to the last day of the month. * @return {Date} this */ $P.moveToLastDayOfMonth = function () { return this.set({ day: $D.getDaysInMonth(this.getFullYear(), this.getMonth())}); }; /** * Converts the value of the current Date object to its equivalent string representation. * Format Specifiers * CUSTOM DATE AND TIME FORMAT STRINGS * Format Description Example * ------ --------------------------------------------------------------------------- ----------------------- * s The seconds of the minute between 0-59. "0" to "59" * ss The seconds of the minute with leading zero if required. "00" to "59" * * m The minute of the hour between 0-59. "0" or "59" * mm The minute of the hour with leading zero if required. "00" or "59" * * h The hour of the day between 1-12. "1" to "12" * hh The hour of the day with leading zero if required. "01" to "12" * * H The hour of the day between 0-23. "0" to "23" * HH The hour of the day with leading zero if required. "00" to "23" * * d The day of the month between 1 and 31. "1" to "31" * dd The day of the month with leading zero if required. "01" to "31" * ddd Abbreviated day name. Date.CultureInfo.abbreviatedDayNames. "Mon" to "Sun" * dddd The full day name. Date.CultureInfo.dayNames. "Monday" to "Sunday" * * M The month of the year between 1-12. "1" to "12" * MM The month of the year with leading zero if required. "01" to "12" * MMM Abbreviated month name. Date.CultureInfo.abbreviatedMonthNames. "Jan" to "Dec" * MMMM The full month name. Date.CultureInfo.monthNames. "January" to "December" * * yy The year as a two-digit number. "99" or "08" * yyyy The full four digit year. "1999" or "2008" * * t Displays the first character of the A.M./P.M. designator. "A" or "P" * Date.CultureInfo.amDesignator or Date.CultureInfo.pmDesignator * tt Displays the A.M./P.M. designator. "AM" or "PM" * Date.CultureInfo.amDesignator or Date.CultureInfo.pmDesignator * * S The ordinal suffix ("st, "nd", "rd" or "th") of the current day. "st, "nd", "rd" or "th" * * STANDARD DATE AND TIME FORMAT STRINGS * Format Description Example *------ --------------------------------------------------------------------------- ----------------------- * d The CultureInfo shortDate Format Pattern "M/d/yyyy" * D The CultureInfo longDate Format Pattern "dddd, MMMM dd, yyyy" * F The CultureInfo fullDateTime Format Pattern "dddd, MMMM dd, yyyy h:mm:ss tt" * m The CultureInfo monthDay Format Pattern "MMMM dd" * r The CultureInfo rfc1123 Format Pattern "ddd, dd MMM yyyy HH:mm:ss GMT" * s The CultureInfo sortableDateTime Format Pattern "yyyy-MM-ddTHH:mm:ss" * t The CultureInfo shortTime Format Pattern "h:mm tt" * T The CultureInfo longTime Format Pattern "h:mm:ss tt" * u The CultureInfo universalSortableDateTime Format Pattern "yyyy-MM-dd HH:mm:ssZ" * y The CultureInfo yearMonth Format Pattern "MMMM, yyyy" * * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @return {String} A string representation of the current Date object. */ var ord = function (n) { switch (n * 1) { case 1: case 21: case 31: return "st"; case 2: case 22: return "nd"; case 3: case 23: return "rd"; default: return "th"; } }; var parseStandardFormats = function (format) { var y, c = Date.CultureInfo.formatPatterns; switch (format) { case "d": return this.toString(c.shortDate); case "D": return this.toString(c.longDate); case "F": return this.toString(c.fullDateTime); case "m": return this.toString(c.monthDay); case "r": case "R": y = this.clone().addMinutes(this.getTimezoneOffset()); return y.toString(c.rfc1123) + " GMT"; case "s": return this.toString(c.sortableDateTime); case "t": return this.toString(c.shortTime); case "T": return this.toString(c.longTime); case "u": y = this.clone().addMinutes(this.getTimezoneOffset()); return y.toString(c.universalSortableDateTime); case "y": return this.toString(c.yearMonth); default: return false; } }; var parseFormatStringsClosure = function (context) { return function (m) { if (m.charAt(0) === "\\") { return m.replace("\\", ""); } switch (m) { case "hh": return p(context.getHours() < 13 ? (context.getHours() === 0 ? 12 : context.getHours()) : (context.getHours() - 12)); case "h": return context.getHours() < 13 ? (context.getHours() === 0 ? 12 : context.getHours()) : (context.getHours() - 12); case "HH": return p(context.getHours()); case "H": return context.getHours(); case "mm": return p(context.getMinutes()); case "m": return context.getMinutes(); case "ss": return p(context.getSeconds()); case "s": return context.getSeconds(); case "yyyy": return p(context.getFullYear(), 4); case "yy": return p(context.getFullYear()); case "y": return context.getFullYear(); case "E": case "dddd": return Date.CultureInfo.dayNames[context.getDay()]; case "ddd": return Date.CultureInfo.abbreviatedDayNames[context.getDay()]; case "dd": return p(context.getDate()); case "d": return context.getDate(); case "MMMM": return Date.CultureInfo.monthNames[context.getMonth()]; case "MMM": return Date.CultureInfo.abbreviatedMonthNames[context.getMonth()]; case "MM": return p((context.getMonth() + 1)); case "M": return context.getMonth() + 1; case "t": return context.getHours() < 12 ? Date.CultureInfo.amDesignator.substring(0, 1) : Date.CultureInfo.pmDesignator.substring(0, 1); case "tt": return context.getHours() < 12 ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator; case "S": return ord(context.getDate()); case "W": return context.getWeek(); case "WW": return context.getISOWeek(); case "Q": return "Q" + context.getQuarter(); case "q": return String(context.getQuarter()); case "z": return context.getTimezone(); case "Z": case "X": return Date.getTimezoneOffset(context.getTimezone()); case "ZZ": // Timezone offset in seconds return context.getTimezoneOffset() * -60; case "u": return context.getDay(); case "L": return ($D.isLeapYear(context.getFullYear())) ? 1 : 0; case "B": // Swatch Internet Time (.beats) return "@"+((context.getUTCSeconds() + (context.getUTCMinutes()*60) + ((context.getUTCHours()+1)*3600))/86.4); default: return m; } }; }; $P.toString = function (format, ignoreStandards) { // Standard Date and Time Format Strings. Formats pulled from CultureInfo file and // may vary by culture. if (!ignoreStandards && format && format.length === 1) { output = parseStandardFormats.call(this, format); if (output) { return output; } } var parseFormatStrings = parseFormatStringsClosure(this); return format ? format.replace(/((\\)?(dd?d?d?|MM?M?M?|yy?y?y?|hh?|HH?|mm?|ss?|tt?|S|q|Q|WW?W?W?)(?![^\[]*\]))/g, parseFormatStrings).replace(/\[|\]/g, "") : this._toString(); }; }()); /************************************************************* * SugarPak - Domain Specific Language - Syntactical Sugar * *************************************************************/ (function () { var $D = Date, $P = $D.prototype, $N = Number.prototype; // private $P._orient = +1; // private $P._nth = null; // private $P._is = false; // private $P._same = false; // private $P._isSecond = false; // private $N._dateElement = "days"; /** * Moves the date to the next instance of a date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.today().next().friday();
	Date.today().next().fri();
	Date.today().next().march();
	Date.today().next().mar();
	Date.today().next().week();
	
* * @return {Date} date */ $P.next = function () { this._move = true; this._orient = +1; return this; }; /** * Creates a new Date (Date.today()) and moves the date to the next instance of the date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.next().friday();
	Date.next().fri();
	Date.next().march();
	Date.next().mar();
	Date.next().week();
	
* * @return {Date} date */ $D.next = function () { return $D.today().next(); }; /** * Moves the date to the previous instance of a date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.today().last().friday();
	Date.today().last().fri();
	Date.today().last().march();
	Date.today().last().mar();
	Date.today().last().week();
	
* * @return {Date} date */ $P.last = $P.prev = $P.previous = function () { this._move = true; this._orient = -1; return this; }; /** * Creates a new Date (Date.today()) and moves the date to the previous instance of the date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.last().friday();
	Date.last().fri();
	Date.previous().march();
	Date.prev().mar();
	Date.last().week();
	
* * @return {Date} date */ $D.last = $D.prev = $D.previous = function () { return $D.today().last(); }; /** * Performs a equality check when followed by either a month name, day name or .weekday() function. * Example

	Date.today().is().friday(); // true|false
	Date.today().is().fri();
	Date.today().is().march();
	Date.today().is().mar();
	
* * @return {Boolean} true|false */ $P.is = function () { this._is = true; return this; }; /** * Determines if two date objects occur on/in exactly the same instance of the subsequent date part function. * The function .same() must be followed by a date part function (example: .day(), .month(), .year(), etc). * * An optional Date can be passed in the date part function. If now date is passed as a parameter, 'Now' is used. * * The following example demonstrates how to determine if two dates fall on the exact same day. * * Example

	var d1 = Date.today(); // today at 00:00
	var d2 = new Date();   // exactly now.

	// Do they occur on the same day?
	d1.same().day(d2); // true
	
	// Do they occur on the same hour?
	d1.same().hour(d2); // false, unless d2 hour is '00' (midnight).
	
	// What if it's the same day, but one year apart?
	var nextYear = Date.today().add(1).year();

	d1.same().day(nextYear); // false, because the dates must occur on the exact same day. 
	
* * Scenario: Determine if a given date occurs during some week period 2 months from now. * * Example

	var future = Date.today().add(2).months();
	return someDate.same().week(future); // true|false;
	
* * @return {Boolean} true|false */ $P.same = function () { this._same = true; this._isSecond = false; return this; }; /** * Determines if the current date/time occurs during Today. Must be preceded by the .is() function. * Example

	someDate.is().today();    // true|false
	new Date().is().today();  // true
	Date.today().is().today();// true
	Date.today().add(-1).day().is().today(); // false
	
* * @return {Boolean} true|false */ $P.today = function () { return this.same().day(); }; /** * Determines if the current date is a weekday. This function must be preceded by the .is() function. * Example

	Date.today().is().weekday(); // true|false
	
* * @return {Boolean} true|false */ $P.weekday = function () { if (this._nth) { return df("Weekday").call(this); } if (this._move) { return this.addWeekdays(this._orient); } if (this._is) { this._is = false; return (!this.is().sat() && !this.is().sun()); } return false; }; /** * Determines if the current date is on the weekend. This function must be preceded by the .is() function. * Example

	Date.today().is().weekend(); // true|false
	
* * @return {Boolean} true|false */ $P.weekend = function () { if (this._is) { this._is = false; return (this.is().sat() || this.is().sun()); } return false; }; /** * Sets the Time of the current Date instance. A string "6:15 pm" or config object {hour:18, minute:15} are accepted. * Example

	// Set time to 6:15pm with a String
	Date.today().at("6:15pm");

	// Set time to 6:15pm with a config object
	Date.today().at({hour:18, minute:15});
	
* * @return {Date} date */ $P.at = function (time) { return (typeof time === "string") ? $D.parse(this.toString("d") + " " + time) : this.set(time); }; /** * Creates a new Date() and adds this (Number) to the date based on the preceding date element function (eg. second|minute|hour|day|month|year). * Example

	// Undeclared Numbers must be wrapped with parentheses. Requirment of JavaScript.
	(3).days().fromNow();
	(6).months().fromNow();

	// Declared Number variables do not require parentheses. 
	var n = 6;
	n.months().fromNow();
	
* * @return {Date} A new Date instance */ $N.fromNow = $N.after = function (date) { var c = {}; c[this._dateElement] = this; return ((!date) ? new Date() : date.clone()).add(c); }; /** * Creates a new Date() and subtract this (Number) from the date based on the preceding date element function (eg. second|minute|hour|day|month|year). * Example

	// Undeclared Numbers must be wrapped with parentheses. Requirment of JavaScript.
	(3).days().ago();
	(6).months().ago();

	// Declared Number variables do not require parentheses. 
	var n = 6;
	n.months().ago();
	
* * @return {Date} A new Date instance */ $N.ago = $N.before = function (date) { var c = {}, s = (this._dateElement[this._dateElement.length-1] !== "s") ? this._dateElement + "s" : this._dateElement; c[s] = this * -1; return ((!date) ? new Date() : date.clone()).add(c); }; // Do NOT modify the following string tokens. These tokens are used to build dynamic functions. // All culture-specific strings can be found in the CultureInfo files. var dx = ("sunday monday tuesday wednesday thursday friday saturday").split(/\s/), mx = ("january february march april may june july august september october november december").split(/\s/), px = ("Millisecond Second Minute Hour Day Week Month Year Quarter Weekday").split(/\s/), pxf = ("Milliseconds Seconds Minutes Hours Date Week Month FullYear Quarter").split(/\s/), nth = ("final first second third fourth fifth").split(/\s/), de; /** * Returns an object literal of all the date parts. * Example

	var o = new Date().toObject();
	
	// { year: 2008, month: 4, week: 20, day: 13, hour: 18, minute: 9, second: 32, millisecond: 812 }
	
	// The object properties can be referenced directly from the object.
	
	alert(o.day);  // alerts "13"
	alert(o.year); // alerts "2008"
	
* * @return {Date} An object literal representing the original date object. */ $P.toObject = function () { var o = {}; for (var i = 0; i < px.length; i++) { if (this["get" + pxf[i]]) { o[px[i].toLowerCase()] = this["get" + pxf[i]](); } } return o; }; /** * Returns a date created from an object literal. Ignores the .week property if set in the config. * Example

	var o = new Date().toObject();
	
	return Date.fromObject(o); // will return the same date. 

	var o2 = {month: 1, day: 20, hour: 18}; // birthday party!
	Date.fromObject(o2);
	
* * @return {Date} An object literal representing the original date object. */ $D.fromObject = function(config) { config.week = null; return Date.today().set(config); }; // Create day name functions and abbreviated day name functions (eg. monday(), friday(), fri()). var df = function (n) { return function () { if (this._is) { this._is = false; return this.getDay() === n; } if (this._move) { this._move = null; } if (this._nth !== null) { // If the .second() function was called earlier, remove the _orient // from the date, and then continue. // This is required because 'second' can be used in two different context. // // Example // // Date.today().add(1).second(); // Date.march().second().monday(); // // Things get crazy with the following... // Date.march().add(1).second().second().monday(); // but it works!! // if (this._isSecond) { this.addSeconds(this._orient * -1); } // make sure we reset _isSecond this._isSecond = false; var ntemp = this._nth; this._nth = null; var temp = this.clone().moveToLastDayOfMonth(); this.moveToNthOccurrence(n, ntemp); if (this > temp) { throw new RangeError($D.getDayName(n) + " does not occur " + ntemp + " times in the month of " + $D.getMonthName(temp.getMonth()) + " " + temp.getFullYear() + "."); } return this; } return this.moveToDayOfWeek(n, this._orient); }; }; var sdf = function (n) { return function () { var t = $D.today(), shift = n - t.getDay(); if (n === 0 && Date.CultureInfo.firstDayOfWeek === 1 && t.getDay() !== 0) { shift = shift + 7; } return t.addDays(shift); }; }; // Create month name functions and abbreviated month name functions (eg. january(), march(), mar()). var month_instance_functions = function (n) { return function () { if (this._is) { this._is = false; return this.getMonth() === n; } return this.moveToMonth(n, this._orient); }; }; var month_static_functions = function (n) { return function () { return $D.today().set({ month: n, day: 1 }); }; }; var processTerms = function (names, staticFunc, instanceFunc) { for (var i = 0; i < names.length; i++) { // Create constant static Name variables. $D[names[i].toUpperCase()] = $D[names[i].toUpperCase().substring(0, 3)] = i; // Create Name functions. $D[names[i]] = $D[names[i].substring(0, 3)] = staticFunc(i); // Create Name instance functions. $P[names[i]] = $P[names[i].substring(0, 3)] = instanceFunc(i); } }; processTerms(dx, sdf, df); processTerms(mx, month_static_functions, month_instance_functions); // Create date element functions and plural date element functions used with Date (eg. day(), days(), months()). var ef = function (j) { return function () { // if the .second() function was called earlier, the _orient // has alread been added. Just return this and reset _isSecond. if (this._isSecond) { this._isSecond = false; return this; } if (this._same) { this._same = this._is = false; var o1 = this.toObject(), o2 = (arguments[0] || new Date()).toObject(), v = "", k = j.toLowerCase(); // the substr trick with -1 doesn't work in IE8 or less k = (k[k.length-1] === "s") ? k.substring(0,k.length-1) : k; for (var m = (px.length - 1); m > -1; m--) { v = px[m].toLowerCase(); if (o1[v] !== o2[v]) { return false; } if (k === v) { break; } } return true; } if (j.substring(j.length - 1) !== "s") { j += "s"; } if (this._move) { this._move = null; } return this["add" + j](this._orient); }; }; var nf = function (n) { return function () { this._dateElement = n; return this; }; }; for (var k = 0; k < px.length; k++) { de = px[k].toLowerCase(); if(de !== "weekday") { // Create date element functions and plural date element functions used with Date (eg. day(), days(), months()). $P[de] = $P[de + "s"] = ef(px[k]); // Create date element functions and plural date element functions used with Number (eg. day(), days(), months()). $N[de] = $N[de + "s"] = nf(de + "s"); } } $P._ss = ef("Second"); var nthfn = function (n) { return function (dayOfWeek) { if (this._same) { return this._ss(arguments[0]); } if (dayOfWeek || dayOfWeek === 0) { return this.moveToNthOccurrence(dayOfWeek, n); } this._nth = n; // if the operator is 'second' add the _orient, then deal with it later... if (n === 2 && (dayOfWeek === undefined || dayOfWeek === null)) { this._isSecond = true; return this.addSeconds(this._orient); } return this; }; }; for (var l = 0; l < nth.length; l++) { $P[nth[l]] = (l === 0) ? nthfn(-1) : nthfn(l); } }()); (function () { "use strict"; Date.Parsing = { Exception: function (s) { this.message = "Parse error at '" + s.substring(0, 10) + " ...'"; } }; var $P = Date.Parsing; var dayOffsets = { standard: [0,31,59,90,120,151,181,212,243,273,304,334], leap: [0,31,60,91,121,152,182,213,244,274,305,335] }; $P.isLeapYear = function(year) { return ((year % 4 === 0) && (year % 100 !== 0)) || (year % 400 === 0); }; var utils = { multiReplace : function (str, hash ) { var key; for (key in hash) { if (Object.prototype.hasOwnProperty.call(hash, key)) { var regex; if (typeof hash[key] === "function") { } else { regex = (hash[key] instanceof RegExp) ? hash[key] : new RegExp(hash[key], "g"); } str = str.replace(regex, key); } } return str; }, getDayOfYearFromWeek : function (obj) { var d, jan4, offset; obj.weekDay = (!obj.weekDay && obj.weekDay !== 0) ? 1 : obj.weekDay; d = new Date(obj.year, 0, 4); jan4 = d.getDay() === 0 ? 7 : d.getDay(); // JS is 0 indexed on Sunday. offset = jan4+3; obj.dayOfYear = ((obj.week * 7) + (obj.weekDay === 0 ? 7 : obj.weekDay))-offset; return obj; }, getDayOfYear : function (obj, dayOffset) { if (!obj.dayOfYear) { obj = utils.getDayOfYearFromWeek(obj); } for (var i=0;i <= dayOffset.length;i++) { if (obj.dayOfYear < dayOffset[i] || i === dayOffset.length) { obj.day = obj.day ? obj.day : (obj.dayOfYear - dayOffset[i-1]); break; } else { obj.month = i; } } return obj; }, adjustForTimeZone : function (obj, date) { var offset; if (obj.zone.toUpperCase() === "Z" || (obj.zone_hours === 0 && obj.zone_minutes === 0)) { // it's UTC/GML so work out the current timeszone offset offset = -date.getTimezoneOffset(); } else { offset = (obj.zone_hours*60) + (obj.zone_minutes || 0); if (obj.zone_sign === "+") { offset *= -1; } offset -= date.getTimezoneOffset(); } date.setMinutes(date.getMinutes()+offset); return date; }, setDefaults : function (obj) { obj.year = obj.year || Date.today().getFullYear(); obj.hours = obj.hours || 0; obj.minutes = obj.minutes || 0; obj.seconds = obj.seconds || 0; obj.milliseconds = obj.milliseconds || 0; if (!(!obj.month && (obj.week || obj.dayOfYear))) { // if we have a month, or if we don't but don't have the day calculation data obj.month = obj.month || 0; obj.day = obj.day || 1; } return obj; }, dataNum: function (data, mod, explict, postProcess) { var dataNum = data*1; if (mod) { if (postProcess) { return data ? mod(data)*1 : data; } else { return data ? mod(dataNum) : data; } } else if (!explict){ return data ? dataNum : data; } else { return (data && typeof data !== "undefined") ? dataNum : data; } }, timeDataProcess: function (obj) { var timeObj = {}; for (var x in obj.data) { if (obj.data.hasOwnProperty(x)) { timeObj[x] = obj.ignore[x] ? obj.data[x] : utils.dataNum(obj.data[x], obj.mods[x], obj.explict[x], obj.postProcess[x]); } } if (obj.data.secmins) { obj.data.secmins = obj.data.secmins.replace(",", ".") * 60; if (!timeObj.minutes) { timeObj.minutes = obj.data.secmins; } else if (!timeObj.seconds) { timeObj.seconds = obj.data.secmins; } delete obj.secmins; } return timeObj; }, buildTimeObjectFromData: function (data) { var time = utils.timeDataProcess({ data: { year : data[1], month : data[5], day : data[7], week : data[8], dayOfYear : data[10], hours : data[15], zone_hours : data[23], zone_minutes : data[24], zone : data[21], zone_sign : data[22], weekDay : data[9], minutes: data[16], seconds: data[19], milliseconds: data[20], secmins: data[18] }, mods: { month: function(data) { return data-1; }, weekDay: function (data) { data = Math.abs(data); return (data === 7 ? 0 : data); }, minutes: function (data) { return data.replace(":",""); }, seconds: function (data) { return Math.floor( (data.replace(":","").replace(",","."))*1 ); }, milliseconds: function (data) { return (data.replace(",",".")*1000); } }, postProcess: { minutes: true, seconds: true, milliseconds: true }, explict: { zone_hours: true, zone_minutes: true }, ignore: { zone: true, zone_sign: true, secmins: true } }); return time; }, addToHash: function (hash, keys, data) { keys = keys; data = data; var len = keys.length; for (var i = 0; i < len; i++) { hash[keys[i]] = data[i]; } return hash; }, combineRegex: function (r1, r2) { return new RegExp("(("+r1.source+")\\s("+r2.source+"))"); }, getDateNthString: function(add, last, inc){ if (add) { return Date.today().addDays(inc).toString("d"); } else if (last) { return Date.today().last()[inc]().toString("d"); } }, buildRegexData: function (array) { var arr = []; var len = array.length; for (var i=0; i < len; i++) { if (Object.prototype.toString.call(array[i]) === '[object Array]') { // oldIE compat version of Array.isArray arr.push(this.combineRegex(array[i][0], array[i][1])); } else { arr.push(array[i]); } } return arr; } }; $P.processTimeObject = function (obj) { var date, dayOffset; utils.setDefaults(obj); dayOffset = ($P.isLeapYear(obj.year)) ? dayOffsets.leap : dayOffsets.standard; if (!obj.month && (obj.week || obj.dayOfYear)) { utils.getDayOfYear(obj, dayOffset); } else { obj.dayOfYear = dayOffset[obj.month] + obj.day; } date = new Date(obj.year, obj.month, obj.day, obj.hours, obj.minutes, obj.seconds, obj.milliseconds); if (obj.zone) { utils.adjustForTimeZone(obj, date); // adjust (and calculate) for timezone } return date; }; $P.ISO = { regex : /^([\+-]?\d{4}(?!\d{2}\b))((-?)((0[1-9]|1[0-2])(\3([12]\d|0[1-9]|3[01]))?|W([0-4]\d|5[0-3])(-?[1-7])?|(00[1-9]|0[1-9]\d|[12]\d{2}|3([0-5]\d|6[1-6])))([T\s]((([01]\d|2[0-4])((:?)[0-5]\d)?|24\:?00)([\.,]\d+(?!:))?)?(\17[0-5]\d([\.,]\d+)?)?\s?([zZ]|([\+-])([01]\d|2[0-3]):?([0-5]\d)?)?)?)?$/, parse : function (s) { var time, data = s.match(this.regex); if (!data || !data.length) { return null; } time = utils.buildTimeObjectFromData(data); if (!time.year || (!time.year && (!time.month && !time.day) && (!time.week && !time.dayOfYear)) ) { return null; } return $P.processTimeObject(time); } }; $P.Numeric = { isNumeric: function (e){return!isNaN(parseFloat(e))&&isFinite(e);}, regex: /\b([0-1]?[0-9])([0-3]?[0-9])([0-2]?[0-9]?[0-9][0-9])\b/i, parse: function (s) { var data, i, time = {}, order = Date.CultureInfo.dateElementOrder.split(""); if (!(this.isNumeric(s)) || // if it's non-numeric OR (s[0] === "+" && s[0] === "-")) { // It's an arithmatic string (eg +/-1000) return null; } if (s.length < 5 && s.indexOf(".") < 0 && s.indexOf("/") < 0) { // assume it's just a year. time.year = s; return $P.processTimeObject(time); } data = s.match(this.regex); if (!data || !data.length) { return null; } for (i=0; i < order.length; i++) { switch(order[i]) { case "d": time.day = data[i+1]; break; case "m": time.month = (data[i+1]-1); break; case "y": time.year = data[i+1]; break; } } return $P.processTimeObject(time); } }; $P.Normalizer = { regexData: function () { var $R = Date.CultureInfo.regexPatterns; return utils.buildRegexData([ $R.tomorrow, $R.yesterday, [$R.past, $R.mon], [$R.past, $R.tue], [$R.past, $R.wed], [$R.past, $R.thu], [$R.past, $R.fri], [$R.past, $R.sat], [$R.past, $R.sun] ]); }, basicReplaceHash : function() { var $R = Date.CultureInfo.regexPatterns; return { "January": $R.jan.source, "February": $R.feb, "March": $R.mar, "April": $R.apr, "May": $R.may, "June": $R.jun, "July": $R.jul, "August": $R.aug, "September": $R.sep, "October": $R.oct, "November": $R.nov, "December": $R.dec, "": /\bat\b/gi, " ": /\s{2,}/, "am": $R.inTheMorning, "9am": $R.thisMorning, "pm": $R.inTheEvening, "7pm":$R.thisEvening }; }, keys : function(){ return [ utils.getDateNthString(true, false, 1), // tomorrow utils.getDateNthString(true, false, -1), // yesterday utils.getDateNthString(false, true, "monday"), //last mon utils.getDateNthString(false, true, "tuesday"), //last tues utils.getDateNthString(false, true, "wednesday"), //last wed utils.getDateNthString(false, true, "thursday"), //last thurs utils.getDateNthString(false, true, "friday"), //last fri utils.getDateNthString(false, true, "saturday"), //last sat utils.getDateNthString(false, true, "sunday") //last sun ]; }, buildRegexFunctions: function () { var $R = Date.CultureInfo.regexPatterns; var __ = Date.i18n.__; var tomorrowRE = new RegExp("(\\b\\d\\d?("+__("AM")+"|"+__("PM")+")? )("+$R.tomorrow.source.slice(1)+")", "i"); // adapted tomorrow regex for AM PM relative dates var todayRE = new RegExp($R.today.source + "(?!\\s*([+-]))\\b"); // today, but excludes the math operators (eg "today + 2h") this.replaceFuncs = [ [todayRE, function (full) { return (full.length > 1) ? Date.today().toString("d") : full; }], [tomorrowRE, function(full, m1) { var t = Date.today().addDays(1).toString("d"); return (t + " " + m1); }], [$R.amThisMorning, function(str, am){return am;}], [$R.pmThisEvening, function(str, pm){return pm;}] ]; }, buildReplaceData: function () { this.buildRegexFunctions(); this.replaceHash = utils.addToHash(this.basicReplaceHash(), this.keys(), this.regexData()); }, stringReplaceFuncs: function (s) { for (var i=0; i < this.replaceFuncs.length; i++) { s = s.replace(this.replaceFuncs[i][0], this.replaceFuncs[i][1]); } return s; }, parse: function (s) { s = this.stringReplaceFuncs(s); s = utils.multiReplace(s, this.replaceHash); try { var n = s.split(/([\s\-\.\,\/\x27]+)/); if (n.length === 3 && $P.Numeric.isNumeric(n[0]) && $P.Numeric.isNumeric(n[2]) && (n[2].length >= 4)) { // ok, so we're dealing with x/year. But that's not a full date. // This fixes wonky dateElementOrder parsing when set to dmy order. if (Date.CultureInfo.dateElementOrder[0] === "d") { s = "1/" + n[0] + "/" + n[2]; // set to 1st of month and normalize the seperator } } } catch (e) {} return s; } }; $P.Normalizer.buildReplaceData(); }()); (function () { var $P = Date.Parsing; var _ = $P.Operators = { // // Tokenizers // rtoken: function (r) { // regex token return function (s) { var mx = s.match(r); if (mx) { return ([ mx[0], s.substring(mx[0].length) ]); } else { throw new $P.Exception(s); } }; }, token: function () { // whitespace-eating token return function (s) { return _.rtoken(new RegExp("^\\s*" + s + "\\s*"))(s); }; }, stoken: function (s) { // string token return _.rtoken(new RegExp("^" + s)); }, // Atomic Operators until: function (p) { return function (s) { var qx = [], rx = null; while (s.length) { try { rx = p.call(this, s); } catch (e) { qx.push(rx[0]); s = rx[1]; continue; } break; } return [ qx, s ]; }; }, many: function (p) { return function (s) { var rx = [], r = null; while (s.length) { try { r = p.call(this, s); } catch (e) { return [ rx, s ]; } rx.push(r[0]); s = r[1]; } return [ rx, s ]; }; }, // generator operators -- see below optional: function (p) { return function (s) { var r = null; try { r = p.call(this, s); } catch (e) { return [ null, s ]; } return [ r[0], r[1] ]; }; }, not: function (p) { return function (s) { try { p.call(this, s); } catch (e) { return [null, s]; } throw new $P.Exception(s); }; }, ignore: function (p) { return p ? function (s) { var r = null; r = p.call(this, s); return [null, r[1]]; } : null; }, product: function () { var px = arguments[0], qx = Array.prototype.slice.call(arguments, 1), rx = []; for (var i = 0 ; i < px.length ; i++) { rx.push(_.each(px[i], qx)); } return rx; }, cache: function (rule) { var cache = {}, cache_length = 0, cache_keys = [], CACHE_MAX = Date.Config.CACHE_MAX || 100000, r = null; var cacheCheck = function () { if (cache_length === CACHE_MAX) { // kill several keys, don't want to have to do this all the time... for (var i=0; i < 10; i++) { var key = cache_keys.shift(); if (key) { delete cache[key]; cache_length--; } } } }; return function (s) { cacheCheck(); try { r = cache[s] = (cache[s] || rule.call(this, s)); } catch (e) { r = cache[s] = e; } cache_length++; cache_keys.push(s); if (r instanceof $P.Exception) { throw r; } else { return r; } }; }, // vector operators -- see below any: function () { var px = arguments; return function (s) { var r = null; for (var i = 0; i < px.length; i++) { if (px[i] == null) { continue; } try { r = (px[i].call(this, s)); } catch (e) { r = null; } if (r) { return r; } } throw new $P.Exception(s); }; }, each: function () { var px = arguments; return function (s) { var rx = [], r = null; for (var i = 0; i < px.length ; i++) { if (px[i] == null) { continue; } try { r = (px[i].call(this, s)); } catch (e) { throw new $P.Exception(s); } rx.push(r[0]); s = r[1]; } return [ rx, s]; }; }, all: function () { var px = arguments, _ = _; return _.each(_.optional(px)); }, // delimited operators sequence: function (px, d, c) { d = d || _.rtoken(/^\s*/); c = c || null; if (px.length === 1) { return px[0]; } return function (s) { var r = null, q = null; var rx = []; for (var i = 0; i < px.length ; i++) { try { r = px[i].call(this, s); } catch (e) { break; } rx.push(r[0]); try { q = d.call(this, r[1]); } catch (ex) { q = null; break; } s = q[1]; } if (!r) { throw new $P.Exception(s); } if (q) { throw new $P.Exception(q[1]); } if (c) { try { r = c.call(this, r[1]); } catch (ey) { throw new $P.Exception(r[1]); } } return [ rx, (r?r[1]:s) ]; }; }, // // Composite Operators // between: function (d1, p, d2) { d2 = d2 || d1; var _fn = _.each(_.ignore(d1), p, _.ignore(d2)); return function (s) { var rx = _fn.call(this, s); return [[rx[0][0], r[0][2]], rx[1]]; }; }, list: function (p, d, c) { d = d || _.rtoken(/^\s*/); c = c || null; return (p instanceof Array ? _.each(_.product(p.slice(0, -1), _.ignore(d)), p.slice(-1), _.ignore(c)) : _.each(_.many(_.each(p, _.ignore(d))), px, _.ignore(c))); }, set: function (px, d, c) { d = d || _.rtoken(/^\s*/); c = c || null; return function (s) { // r is the current match, best the current 'best' match // which means it parsed the most amount of input var r = null, p = null, q = null, rx = null, best = [[], s], last = false; // go through the rules in the given set for (var i = 0; i < px.length ; i++) { // last is a flag indicating whether this must be the last element // if there is only 1 element, then it MUST be the last one q = null; p = null; r = null; last = (px.length === 1); // first, we try simply to match the current pattern // if not, try the next pattern try { r = px[i].call(this, s); } catch (e) { continue; } // since we are matching against a set of elements, the first // thing to do is to add r[0] to matched elements rx = [[r[0]], r[1]]; // if we matched and there is still input to parse and // we don't already know this is the last element, // we're going to next check for the delimiter ... // if there's none, or if there's no input left to parse // than this must be the last element after all ... if (r[1].length > 0 && ! last) { try { q = d.call(this, r[1]); } catch (ex) { last = true; } } else { last = true; } // if we parsed the delimiter and now there's no more input, // that means we shouldn't have parsed the delimiter at all // so don't update r and mark this as the last element ... if (!last && q[1].length === 0) { last = true; } // so, if this isn't the last element, we're going to see if // we can get any more matches from the remaining (unmatched) // elements ... if (!last) { // build a list of the remaining rules we can match against, // i.e., all but the one we just matched against var qx = []; for (var j = 0; j < px.length ; j++) { if (i !== j) { qx.push(px[j]); } } // now invoke recursively set with the remaining input // note that we don't include the closing delimiter ... // we'll check for that ourselves at the end p = _.set(qx, d).call(this, q[1]); // if we got a non-empty set as a result ... // (otw rx already contains everything we want to match) if (p[0].length > 0) { // update current result, which is stored in rx ... // basically, pick up the remaining text from p[1] // and concat the result from p[0] so that we don't // get endless nesting ... rx[0] = rx[0].concat(p[0]); rx[1] = p[1]; } } // at this point, rx either contains the last matched element // or the entire matched set that starts with this element. // now we just check to see if this variation is better than // our best so far, in terms of how much of the input is parsed if (rx[1].length < best[1].length) { best = rx; } // if we've parsed all the input, then we're finished if (best[1].length === 0) { break; } } // so now we've either gone through all the patterns trying them // as the initial match; or we found one that parsed the entire // input string ... // if best has no matches, just return empty set ... if (best[0].length === 0) { return best; } // if a closing delimiter is provided, then we have to check it also if (c) { // we try this even if there is no remaining input because the pattern // may well be optional or match empty input ... try { q = c.call(this, best[1]); } catch (ey) { throw new $P.Exception(best[1]); } // it parsed ... be sure to update the best match remaining input best[1] = q[1]; } // if we're here, either there was no closing delimiter or we parsed it // so now we have the best match; just return it! return best; }; }, forward: function (gr, fname) { return function (s) { return gr[fname].call(this, s); }; }, // // Translation Operators // replace: function (rule, repl) { return function (s) { var r = rule.call(this, s); return [repl, r[1]]; }; }, process: function (rule, fn) { return function (s) { var r = rule.call(this, s); return [fn.call(this, r[0]), r[1]]; }; }, min: function (min, rule) { return function (s) { var rx = rule.call(this, s); if (rx[0].length < min) { throw new $P.Exception(s); } return rx; }; } }; // Generator Operators And Vector Operators // Generators are operators that have a signature of F(R) => R, // taking a given rule and returning another rule, such as // ignore, which parses a given rule and throws away the result. // Vector operators are those that have a signature of F(R1,R2,...) => R, // take a list of rules and returning a new rule, such as each. // Generator operators are converted (via the following _generator // function) into functions that can also take a list or array of rules // and return an array of new rules as though the function had been // called on each rule in turn (which is what actually happens). // This allows generators to be used with vector operators more easily. // Example: // each(ignore(foo, bar)) instead of each(ignore(foo), ignore(bar)) // This also turns generators into vector operators, which allows // constructs like: // not(cache(foo, bar)) var _generator = function (op) { function gen() { var args = null, rx = [], px, i; if (arguments.length > 1) { args = Array.prototype.slice.call(arguments); } else if (arguments[0] instanceof Array) { args = arguments[0]; } if (args) { px = args.shift(); if (px.length > 0) { args.unshift(px[i]); rx.push(op.apply(null, args)); args.shift(); return rx; } } else { return op.apply(null, arguments); } } return gen; }; var gx = "optional not ignore cache".split(/\s/); for (var i = 0 ; i < gx.length ; i++) { _[gx[i]] = _generator(_[gx[i]]); } var _vector = function (op) { return function () { if (arguments[0] instanceof Array) { return op.apply(null, arguments[0]); } else { return op.apply(null, arguments); } }; }; var vx = "each any all".split(/\s/); for (var j = 0 ; j < vx.length ; j++) { _[vx[j]] = _vector(_[vx[j]]); } }()); (function () { var $D = Date; var flattenAndCompact = function (ax) { var rx = []; for (var i = 0; i < ax.length; i++) { if (ax[i] instanceof Array) { rx = rx.concat(flattenAndCompact(ax[i])); } else { if (ax[i]) { rx.push(ax[i]); } } } return rx; }; var parseMeridian = function () { if (this.meridian && (this.hour || this.hour === 0)) { if (this.meridian === "a" && this.hour > 11 && Date.Config.strict24hr){ throw "Invalid hour and meridian combination"; } else if (this.meridian === "p" && this.hour < 12 && Date.Config.strict24hr){ throw "Invalid hour and meridian combination"; } else if (this.meridian === "p" && this.hour < 12) { this.hour = this.hour + 12; } else if (this.meridian === "a" && this.hour === 12) { this.hour = 0; } } }; var setDefaults = function () { var now = new Date(); if ((this.hour || this.minute) && (!this.month && !this.year && !this.day)) { this.day = now.getDate(); } if (!this.year) { this.year = now.getFullYear(); } if (!this.month && this.month !== 0) { this.month = now.getMonth(); } if (!this.day) { this.day = 1; } if (!this.hour) { this.hour = 0; } if (!this.minute) { this.minute = 0; } if (!this.second) { this.second = 0; } if (!this.millisecond) { this.millisecond = 0; } }; var finishUtils = { getToday: function () { if (this.now || "hour minute second".indexOf(this.unit) !== -1) { return new Date(); } else { return $D.today(); } }, setDaysFromWeekday: function (today, orient){ var gap; orient = orient || 1; this.unit = "day"; gap = ($D.getDayNumberFromName(this.weekday) - today.getDay()); this.days = gap ? ((gap + (orient * 7)) % 7) : (orient * 7); return this; }, setMonthsFromMonth: function (today, orient) { var gap; orient = orient || 1; this.unit = "month"; gap = (this.month - today.getMonth()); this.months = gap ? ((gap + (orient * 12)) % 12) : (orient * 12); this.month = null; return this; }, setDMYFromWeekday: function () { var d = Date[this.weekday](); this.day = d.getDate(); if (!this.month) { this.month = d.getMonth(); } this.year = d.getFullYear(); return this; }, setUnitValue: function (orient) { if (!this.value && this.operator && this.operator !== null && this[this.unit + "s"] && this[this.unit + "s"] !== null) { this[this.unit + "s"] = this[this.unit + "s"] + ((this.operator === "add") ? 1 : -1) + (this.value||0) * orient; } else if (this[this.unit + "s"] == null || this.operator != null) { if (!this.value) { this.value = 1; } this[this.unit + "s"] = this.value * orient; } }, generateDateFromWeeks: function () { var weekday = (this.weekday !== undefined) ? this.weekday : "today"; var d = Date[weekday]().addWeeks(this.weeks); if (this.now) { d.setTimeToNow(); } return d; } }; $D.Translator = { hour: function (s) { return function () { this.hour = Number(s); }; }, minute: function (s) { return function () { this.minute = Number(s); }; }, second: function (s) { return function () { this.second = Number(s); }; }, /* for ss.s format */ secondAndMillisecond: function (s) { return function () { var mx = s.match(/^([0-5][0-9])\.([0-9]{1,3})/); this.second = Number(mx[1]); this.millisecond = Number(mx[2]); }; }, meridian: function (s) { return function () { this.meridian = s.slice(0, 1).toLowerCase(); }; }, timezone: function (s) { return function () { var n = s.replace(/[^\d\+\-]/g, ""); if (n.length) { this.timezoneOffset = Number(n); } else { this.timezone = s.toLowerCase(); } }; }, day: function (x) { var s = x[0]; return function () { this.day = Number(s.match(/\d+/)[0]); if (this.day < 1) { throw "invalid day"; } }; }, month: function (s) { return function () { this.month = (s.length === 3) ? "jan feb mar apr may jun jul aug sep oct nov dec".indexOf(s)/4 : Number(s) - 1; if (this.month < 0) { throw "invalid month"; } }; }, year: function (s) { return function () { var n = Number(s); this.year = ((s.length > 2) ? n : (n + (((n + 2000) < Date.CultureInfo.twoDigitYearMax) ? 2000 : 1900))); }; }, rday: function (s) { return function () { switch (s) { case "yesterday": this.days = -1; break; case "tomorrow": this.days = 1; break; case "today": this.days = 0; break; case "now": this.days = 0; this.now = true; break; } }; }, finishExact: function (x) { var d; x = (x instanceof Array) ? x : [x]; for (var i = 0 ; i < x.length ; i++) { if (x[i]) { x[i].call(this); } } setDefaults.call(this); parseMeridian.call(this); if (this.day > $D.getDaysInMonth(this.year, this.month)) { throw new RangeError(this.day + " is not a valid value for days."); } d = new Date(this.year, this.month, this.day, this.hour, this.minute, this.second, this.millisecond); if (this.year < 100) { d.setFullYear(this.year); // means years less that 100 are process correctly. JS will parse it otherwise as 1900-1999. } if (this.timezone) { d.set({ timezone: this.timezone }); } else if (this.timezoneOffset) { d.set({ timezoneOffset: this.timezoneOffset }); } return d; }, finish: function (x) { var today, expression, orient, temp; x = (x instanceof Array) ? flattenAndCompact(x) : [ x ]; if (x.length === 0) { return null; } for (var i = 0 ; i < x.length ; i++) { if (typeof x[i] === "function") { x[i].call(this); } } if (this.now && !this.unit && !this.operator) { return new Date(); } else { today = finishUtils.getToday.call(this); } expression = !!(this.days && this.days !== null || this.orient || this.operator); orient = ((this.orient === "past" || this.operator === "subtract") ? -1 : 1); if (this.month && this.unit === "week") { this.value = this.month + 1; delete this.month; delete this.day; } if ((this.month || this.month === 0) && "year day hour minute second".indexOf(this.unit) !== -1) { if (!this.value) { this.value = this.month + 1; } this.month = null; expression = true; } if (!expression && this.weekday && !this.day && !this.days) { finishUtils.setDMYFromWeekday.call(this); } if (expression && this.weekday && this.unit !== "month" && this.unit !== "week") { finishUtils.setDaysFromWeekday.call(this, today, orient); } if (this.weekday && this.unit !== "week" && !this.day && !this.days) { temp = Date[this.weekday](); this.day = temp.getDate(); if (temp.getMonth() !== today.getMonth()) { this.month = temp.getMonth(); } } if (this.month && this.unit === "day" && this.operator) { if (!this.value) { this.value = (this.month + 1); } this.month = null; } if (this.value != null && this.month != null && this.year != null) { this.day = this.value * 1; } if (this.month && !this.day && this.value) { today.set({ day: this.value * 1 }); if (!expression) { this.day = this.value * 1; } } if (!this.month && this.value && this.unit === "month" && !this.now) { this.month = this.value; expression = true; } if (expression && (this.month || this.month === 0) && this.unit !== "year") { finishUtils.setMonthsFromMonth.call(this, today, orient); } if (!this.unit) { this.unit = "day"; } finishUtils.setUnitValue.call(this, orient); parseMeridian.call(this); if ((this.month || this.month === 0) && !this.day) { this.day = 1; } if (!this.orient && !this.operator && this.unit === "week" && this.value && !this.day && !this.month) { return Date.today().setWeek(this.value); } if (this.unit === "week" && this.weeks && !this.day && !this.month) { return finishUtils.generateDateFromWeeks.call(this); } if (expression && this.timezone && this.day && this.days) { this.day = this.days; } if (expression){ today.add(this); } else { today.set(this); } if (this.timezone) { this.timezone = this.timezone.toUpperCase(); var offset = $D.getTimezoneOffset(this.timezone); var timezone; if (today.hasDaylightSavingTime()) { // lets check that we're being sane with timezone setting timezone = $D.getTimezoneAbbreviation(offset, today.isDaylightSavingTime()); if (timezone !== this.timezone) { // bugger, we're in a place where things like EST vs EDT matters. if (today.isDaylightSavingTime()) { today.addHours(-1); } else { today.addHours(1); } } } today.setTimezoneOffset(offset); } return today; } }; }()); (function () { var $D = Date; $D.Grammar = {}; var _ = $D.Parsing.Operators, g = $D.Grammar, t = $D.Translator, _fn; // Allow rolling up into general purpose rules _fn = function () { return _.each(_.any.apply(null, arguments), _.not(g.ctoken2("timeContext"))); }; g.datePartDelimiter = _.rtoken(/^([\s\-\.\,\/\x27]+)/); g.timePartDelimiter = _.stoken(":"); g.whiteSpace = _.rtoken(/^\s*/); g.generalDelimiter = _.rtoken(/^(([\s\,]|at|@|on)+)/); var _C = {}; g.ctoken = function (keys) { var fn = _C[keys]; if (! fn) { var c = Date.CultureInfo.regexPatterns; var kx = keys.split(/\s+/), px = []; for (var i = 0; i < kx.length ; i++) { px.push(_.replace(_.rtoken(c[kx[i]]), kx[i])); } fn = _C[keys] = _.any.apply(null, px); } return fn; }; g.ctoken2 = function (key) { return _.rtoken(Date.CultureInfo.regexPatterns[key]); }; var cacheProcessRtoken = function (key, token, type, eachToken) { if (eachToken) { g[key] = _.cache(_.process(_.each(_.rtoken(token),_.optional(g.ctoken2(eachToken))), type)); } else { g[key] = _.cache(_.process(_.rtoken(token), type)); } }; var cacheProcessCtoken = function (token, type) { return _.cache(_.process(g.ctoken2(token), type)); }; var _F = {}; //function cache var _get = function (f) { _F[f] = (_F[f] || g.format(f)[0]); return _F[f]; }; g.allformats = function (fx) { var rx = []; if (fx instanceof Array) { for (var i = 0; i < fx.length; i++) { rx.push(_get(fx[i])); } } else { rx.push(_get(fx)); } return rx; }; g.formats = function (fx) { if (fx instanceof Array) { var rx = []; for (var i = 0 ; i < fx.length ; i++) { rx.push(_get(fx[i])); } return _.any.apply(null, rx); } else { return _get(fx); } }; var grammarFormats = { timeFormats: function(){ var i, RTokenKeys = [ "h", "hh", "H", "HH", "m", "mm", "s", "ss", "ss.s", "z", "zz" ], RToken = [ /^(0[0-9]|1[0-2]|[1-9])/, /^(0[0-9]|1[0-2])/, /^([0-1][0-9]|2[0-3]|[0-9])/, /^([0-1][0-9]|2[0-3])/, /^([0-5][0-9]|[0-9])/, /^[0-5][0-9]/, /^([0-5][0-9]|[0-9])/, /^[0-5][0-9]/, /^[0-5][0-9]\.[0-9]{1,3}/, /^((\+|\-)\s*\d\d\d\d)|((\+|\-)\d\d\:?\d\d)/, /^((\+|\-)\s*\d\d\d\d)|((\+|\-)\d\d\:?\d\d)/ ], tokens = [ t.hour, t.hour, t.hour, t.hour, t.minute, t.minute, t.second, t.second, t.secondAndMillisecond, t.timezone, t.timezone ]; for (i=0; i < RTokenKeys.length; i++) { cacheProcessRtoken(RTokenKeys[i], RToken[i], tokens[i]); } g.hms = _.cache(_.sequence([g.H, g.m, g.s], g.timePartDelimiter)); g.t = cacheProcessCtoken("shortMeridian", t.meridian); g.tt = cacheProcessCtoken("longMeridian", t.meridian); g.zzz = cacheProcessCtoken("timezone", t.timezone); g.timeSuffix = _.each(_.ignore(g.whiteSpace), _.set([ g.tt, g.zzz ])); g.time = _.each(_.optional(_.ignore(_.stoken("T"))), g.hms, g.timeSuffix); }, dateFormats: function () { // pre-loaded rules for different date part order preferences var _setfn = function () { return _.set(arguments, g.datePartDelimiter); }; var i, RTokenKeys = [ "d", "dd", "M", "MM", "y", "yy", "yyy", "yyyy" ], RToken = [ /^([0-2]\d|3[0-1]|\d)/, /^([0-2]\d|3[0-1])/, /^(1[0-2]|0\d|\d)/, /^(1[0-2]|0\d)/, /^(\d+)/, /^(\d\d)/, /^(\d\d?\d?\d?)/, /^(\d\d\d\d)/ ], tokens = [ t.day, t.day, t.month, t.month, t.year, t.year, t.year, t.year ], eachToken = [ "ordinalSuffix", "ordinalSuffix" ]; for (i=0; i < RTokenKeys.length; i++) { cacheProcessRtoken(RTokenKeys[i], RToken[i], tokens[i], eachToken[i]); } g.MMM = g.MMMM = _.cache(_.process(g.ctoken("jan feb mar apr may jun jul aug sep oct nov dec"), t.month)); g.ddd = g.dddd = _.cache(_.process(g.ctoken("sun mon tue wed thu fri sat"), function (s) { return function () { this.weekday = s; }; } )); g.day = _fn(g.d, g.dd); g.month = _fn(g.M, g.MMM); g.year = _fn(g.yyyy, g.yy); g.mdy = _setfn(g.ddd, g.month, g.day, g.year); g.ymd = _setfn(g.ddd, g.year, g.month, g.day); g.dmy = _setfn(g.ddd, g.day, g.month, g.year); g.date = function (s) { return ((g[Date.CultureInfo.dateElementOrder] || g.mdy).call(this, s)); }; }, relative: function () { // relative date / time expressions g.orientation = _.process(g.ctoken("past future"), function (s) { return function () { this.orient = s; }; } ); g.operator = _.process(g.ctoken("add subtract"), function (s) { return function () { this.operator = s; }; } ); g.rday = _.process(g.ctoken("yesterday tomorrow today now"), t.rday); g.unit = _.process(g.ctoken("second minute hour day week month year"), function (s) { return function () { this.unit = s; }; } ); } }; g.buildGrammarFormats = function () { // these need to be rebuilt every time the language changes. _C = {}; grammarFormats.timeFormats(); grammarFormats.dateFormats(); grammarFormats.relative(); g.value = _.process(_.rtoken(/^([-+]?\d+)?(st|nd|rd|th)?/), function (s) { return function () { this.value = s.replace(/\D/g, ""); }; } ); g.expression = _.set([g.rday, g.operator, g.value, g.unit, g.orientation, g.ddd, g.MMM ]); g.format = _.process(_.many( _.any( // translate format specifiers into grammar rules _.process( _.rtoken(/^(dd?d?d?(?!e)|MM?M?M?|yy?y?y?|hh?|HH?|mm?|ss?|tt?|zz?z?)/), function (fmt) { if (g[fmt]) { return g[fmt]; } else { throw $D.Parsing.Exception(fmt); } } ), // translate separator tokens into token rules _.process(_.rtoken(/^[^dMyhHmstz]+/), // all legal separators function (s) { return _.ignore(_.stoken(s)); } ) ) ), // construct the parser ... function (rules) { return _.process(_.each.apply(null, rules), t.finishExact); } ); // starting rule for general purpose grammar g._start = _.process(_.set([ g.date, g.time, g.expression ], g.generalDelimiter, g.whiteSpace), t.finish); }; g.buildGrammarFormats(); // parsing date format specifiers - ex: "h:m:s tt" // this little guy will generate a custom parser based // on the format string, ex: g.format("h:m:s tt") // check for these formats first g._formats = g.formats([ "\"yyyy-MM-ddTHH:mm:ssZ\"", "yyyy-MM-ddTHH:mm:ss.sz", "yyyy-MM-ddTHH:mm:ssZ", "yyyy-MM-ddTHH:mm:ssz", "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-ddTHH:mmZ", "yyyy-MM-ddTHH:mmz", "yyyy-MM-ddTHH:mm", "ddd, MMM dd, yyyy H:mm:ss tt", "ddd MMM d yyyy HH:mm:ss zzz", "MMddyyyy", "ddMMyyyy", "Mddyyyy", "ddMyyyy", "Mdyyyy", "dMyyyy", "yyyy", "Mdyy", "dMyy", "d" ]); // real starting rule: tries selected formats first, // then general purpose rule g.start = function (s) { try { var r = g._formats.call({}, s); if (r[1].length === 0) { return r; } } catch (e) {} return g._start.call({}, s); }; }()); (function () { var $D = Date; /** * @desc Converts the specified string value into its JavaScript Date equivalent using CultureInfo specific format information. * * Example

	///////////
	// Dates //
	///////////

	// 15-Oct-2004
	var d1 = Date.parse("10/15/2004");

	// 15-Oct-2004
	var d1 = Date.parse("15-Oct-2004");

	// 15-Oct-2004
	var d1 = Date.parse("2004.10.15");

	//Fri Oct 15, 2004
	var d1 = Date.parse("Fri Oct 15, 2004");

	///////////
	// Times //
	///////////

	// Today at 10 PM.
	var d1 = Date.parse("10 PM");

	// Today at 10:30 PM.
	var d1 = Date.parse("10:30 P.M.");

	// Today at 6 AM.
	var d1 = Date.parse("06am");

	/////////////////////
	// Dates and Times //
	/////////////////////

	// 8-July-2004 @ 10:30 PM
	var d1 = Date.parse("July 8th, 2004, 10:30 PM");

	// 1-July-2004 @ 10:30 PM
	var d1 = Date.parse("2004-07-01T22:30:00");

	////////////////////
	// Relative Dates //
	////////////////////

	// Returns today's date. The string "today" is culture specific.
	var d1 = Date.parse("today");

	// Returns yesterday's date. The string "yesterday" is culture specific.
	var d1 = Date.parse("yesterday");

	// Returns the date of the next thursday.
	var d1 = Date.parse("Next thursday");

	// Returns the date of the most previous monday.
	var d1 = Date.parse("last monday");

	// Returns today's day + one year.
	var d1 = Date.parse("next year");

	///////////////
	// Date Math //
	///////////////

	// Today + 2 days
	var d1 = Date.parse("t+2");

	// Today + 2 days
	var d1 = Date.parse("today + 2 days");

	// Today + 3 months
	var d1 = Date.parse("t+3m");

	// Today - 1 year
	var d1 = Date.parse("today - 1 year");

	// Today - 1 year
	var d1 = Date.parse("t-1y"); 


	/////////////////////////////
	// Partial Dates and Times //
	/////////////////////////////

	// July 15th of this year.
	var d1 = Date.parse("July 15");

	// 15th day of current day and year.
	var d1 = Date.parse("15");

	// July 1st of current year at 10pm.
	var d1 = Date.parse("7/1 10pm");
	
* * @param {String} The string value to convert into a Date object [Required] * @return {Date} A Date object or null if the string cannot be converted into a Date. */ var parseUtils = { removeOrds: function (s) { ords = s.match(/\b(\d+)(?:st|nd|rd|th)\b/); // find ordinal matches s = ((ords && ords.length === 2) ? s.replace(ords[0], ords[1]) : s); return s; }, grammarParser: function (s) { var r = null; try { r = $D.Grammar.start.call({}, s.replace(/^\s*(\S*(\s+\S+)*)\s*$/, "$1")); } catch (e) { return null; } return ((r[1].length === 0) ? r[0] : null); }, nativeFallback: function(s) { var t; try { // ok we haven't parsed it, last ditch attempt with the built-in parser. t = Date._parse(s); return (t || t === 0) ? new Date(t) : null; } catch (e) { return null; } } }; function parse (s) { var d; if (!s) { return null; } if (s instanceof Date) { return s.clone(); } if (s.length >= 4 && s.charAt(0) !== "0" && s.charAt(0) !== "+"&& s.charAt(0) !== "-") { // ie: 2004 will pass, 0800 won't. // Start with specific formats d = $D.Parsing.ISO.parse(s) || $D.Parsing.Numeric.parse(s); } if (d instanceof Date && !isNaN(d.getTime())) { return d; } else { // find ordinal dates (1st, 3rd, 8th, etc and remove them as they cause parsing issues) s = $D.Parsing.Normalizer.parse(parseUtils.removeOrds(s)); d = parseUtils.grammarParser(s); if (d !== null) { return d; } else { return parseUtils.nativeFallback(s); } } } if (!$D._parse) { $D._parse = $D.parse; } $D.parse = parse; Date.getParseFunction = function (fx) { var fns = Date.Grammar.allformats(fx); return function (s) { var r = null; for (var i = 0; i < fns.length; i++) { try { r = fns[i].call({}, s); } catch (e) { continue; } if (r[1].length === 0) { return r[0]; } } return null; }; }; /** * Converts the specified string value into its JavaScript Date equivalent using the specified format {String} or formats {Array} and the CultureInfo specific format information. * The format of the string value must match one of the supplied formats exactly. * * Example

	// 15-Oct-2004
	var d1 = Date.parseExact("10/15/2004", "M/d/yyyy");

	// 15-Oct-2004
	var d1 = Date.parse("15-Oct-2004", "M-ddd-yyyy");

	// 15-Oct-2004
	var d1 = Date.parse("2004.10.15", "yyyy.MM.dd");

	// Multiple formats
	var d1 = Date.parseExact("10/15/2004", ["M/d/yyyy", "MMMM d, yyyy"]);
	
* * @param {String} The string value to convert into a Date object [Required]. * @param {Object} The expected format {String} or an array of expected formats {Array} of the date string [Required]. * @return {Date} A Date object or null if the string cannot be converted into a Date. */ $D.parseExact = function (s, fx) { return $D.getParseFunction(fx)(s); }; }()); (function () { var $D = Date, $P = $D.prototype, // $C = $D.CultureInfo, // not used atm p = function (s, l) { if (!l) { l = 2; } return ("000" + s).slice(l * -1); }; /** * Converts a PHP format string to Java/.NET format string. * A PHP format string can be used with ._format or .format. * A Java/.NET format string can be used with .toString(). * The .parseExact function will only accept a Java/.NET format string * * Example * var f1 = "%m/%d/%y" * var f2 = Date.normalizeFormat(f1); // "MM/dd/yy" * * new Date().format(f1); // "04/13/08" * new Date()._format(f1); // "04/13/08" * new Date().toString(f2); // "04/13/08" * * var date = Date.parseExact("04/13/08", f2); // Sun Apr 13 2008 * * @param {String} A PHP format string consisting of one or more format spcifiers. * @return {String} The PHP format converted to a Java/.NET format string. */ var normalizerSubstitutions = { "d" : "dd", "%d": "dd", "D" : "ddd", "%a": "ddd", "j" : "dddd", "l" : "dddd", "%A": "dddd", "S" : "S", "F" : "MMMM", "%B": "MMMM", "m" : "MM", "%m": "MM", "M" : "MMM", "%b": "MMM", "%h": "MMM", "n" : "M", "Y" : "yyyy", "%Y": "yyyy", "y" : "yy", "%y": "yy", "g" : "h", "%I": "h", "G" : "H", "h" : "hh", "H" : "HH", "%H": "HH", "i" : "mm", "%M": "mm", "s" : "ss", "%S": "ss", "%r": "hh:mm tt", "%R": "H:mm", "%T": "H:mm:ss", "%X": "t", "%x": "d", "%e": "d", "%D": "MM/dd/yy", "%n": "\\n", "%t": "\\t", "e" : "z", "T" : "z", "%z": "z", "%Z": "z", "Z" : "ZZ", "N" : "u", "w" : "u", "%w": "u", "W" : "W", "%V": "W" }; var normalizer = { substitutes: function (m) { return normalizerSubstitutions[m]; }, interpreted: function (m, x) { var y; switch (m) { case "%u": return x.getDay() + 1; case "z": return x.getOrdinalNumber(); case "%j": return p(x.getOrdinalNumber(), 3); case "%U": var d1 = x.clone().set({month: 0, day: 1}).addDays(-1).moveToDayOfWeek(0), d2 = x.clone().addDays(1).moveToDayOfWeek(0, -1); return (d2 < d1) ? "00" : p((d2.getOrdinalNumber() - d1.getOrdinalNumber()) / 7 + 1); case "%W": return p(x.getWeek()); case "t": return $D.getDaysInMonth(x.getFullYear(), x.getMonth()); case "o": case "%G": return x.setWeek(x.getISOWeek()).toString("yyyy"); case "%g": return x._format("%G").slice(-2); case "a": case "%p": return t("tt").toLowerCase(); case "A": return t("tt").toUpperCase(); case "u": return p(x.getMilliseconds(), 3); case "I": return (x.isDaylightSavingTime()) ? 1 : 0; case "O": return x.getUTCOffset(); case "P": y = x.getUTCOffset(); return y.substring(0, y.length - 2) + ":" + y.substring(y.length - 2); case "B": var now = new Date(); return Math.floor(((now.getHours() * 3600) + (now.getMinutes() * 60) + now.getSeconds() + (now.getTimezoneOffset() + 60) * 60) / 86.4); case "c": return x.toISOString().replace(/\"/g, ""); case "U": return $D.strtotime("now"); case "%c": return t("d") + " " + t("t"); case "%C": return Math.floor(x.getFullYear() / 100 + 1); } }, shouldOverrideDefaults: function (m) { switch (m) { case "%e": return true; default: return false; } }, parse: function (m, context) { var formatString, c = context || new Date(); formatString = normalizer.substitutes(m); if (formatString) { return formatString; } formatString = normalizer.interpreted(m, c); if (formatString) { return formatString; } else { return m; } } }; $D.normalizeFormat = function (format, context) { return format.replace(/(%|\\)?.|%%/g, function(t){ return normalizer.parse(t, context); }); }; /** * Format a local Unix timestamp according to locale settings * * Example: * Date.strftime("%m/%d/%y", new Date()); // "04/13/08" * Date.strftime("c", "2008-04-13T17:52:03Z"); // "04/13/08" * * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @param {Number|String} The number representing the number of seconds that have elapsed since January 1, 1970 (local time). * @return {String} A string representation of the current Date object. */ $D.strftime = function (format, time) { var d = Date.parse(time); return d._format(format); }; /** * Parse any textual datetime description into a Unix timestamp. * A Unix timestamp is the number of seconds that have elapsed since January 1, 1970 (midnight UTC/GMT). * * Example: * Date.strtotime("04/13/08"); // 1208044800 * Date.strtotime("1970-01-01T00:00:00Z"); // 0 * * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @param {Object} A string or date object. * @return {String} A string representation of the current Date object. */ $D.strtotime = function (time) { var d = $D.parse(time); return Math.round($D.UTC(d.getUTCFullYear(), d.getUTCMonth(), d.getUTCDate(), d.getUTCHours(), d.getUTCMinutes(), d.getUTCSeconds(), d.getUTCMilliseconds()) / 1000); }; /** * Converts the value of the current Date object to its equivalent string representation using a PHP/Unix style of date format specifiers. * Format Specifiers * Format Description Example * ------ --------------------------------------------------------------------------- ----------------------- * %a abbreviated weekday name according to the current localed "Mon" through "Sun" * %A full weekday name according to the current localed "Sunday" through "Saturday" * %b abbreviated month name according to the current localed "Jan" through "Dec" * %B full month name according to the current locale "January" through "December" * %c preferred date and time representation for the current locale "4/13/2008 12:33 PM" * %C century number (the year divided by 100 and truncated to an integer) "00" to "99" * %d day of the month as a decimal number "01" to "31" * %D same as %m/%d/%y "04/13/08" * %e day of the month as a decimal number, a single digit is preceded by a space "1" to "31" * %g like %G, but without the century "08" * %G The 4-digit year corresponding to the ISO week number (see %V). "2008" * This has the same format and value as %Y, except that if the ISO week number * belongs to the previous or next year, that year is used instead. * %h same as %b "Jan" through "Dec" * %H hour as a decimal number using a 24-hour clock. "00" to "23" * %I hour as a decimal number using a 12-hour clock. "01" to "12" * %j day of the year as a decimal number. "001" to "366" * %m month as a decimal number. "01" to "12" * %M minute as a decimal number. "00" to "59" * %n newline character "\n" * %p either "am" or "pm" according to the given time value, or the "am" or "pm" * corresponding strings for the current locale. * %r time in a.m. and p.m. notation "8:44 PM" * %R time in 24 hour notation "20:44" * %S second as a decimal number "00" to "59" * %t tab character "\t" * %T current time, equal to %H:%M:%S "12:49:11" * %u weekday as a decimal number ["1", "7"], with "1" representing Monday "1" to "7" * %U week number of the current year as a decimal number, starting with the "0" to ("52" or "53") * first Sunday as the first day of the first week * %V The ISO 8601:1988 week number of the current year as a decimal number, "00" to ("52" or "53") * range 01 to 53, where week 1 is the first week that has at least 4 days * in the current year, and with Monday as the first day of the week. * (Use %G or %g for the year component that corresponds to the week number * for the specified timestamp.) * %W week number of the current year as a decimal number, starting with the "00" to ("52" or "53") * first Monday as the first day of the first week * %w day of the week as a decimal, Sunday being "0" "0" to "6" * %x preferred date representation for the current locale without the time "4/13/2008" * %X preferred time representation for the current locale without the date "12:53:05" * %y year as a decimal number without a century "00" "99" * %Y year as a decimal number including the century "2008" * %Z time zone or name or abbreviation "UTC", "EST", "PST" * %z same as %Z * %% a literal "%" characters "%" * d Day of the month, 2 digits with leading zeros "01" to "31" * D A textual representation of a day, three letters "Mon" through "Sun" * j Day of the month without leading zeros "1" to "31" * l A full textual representation of the day of the week (lowercase "L") "Sunday" through "Saturday" * N ISO-8601 numeric representation of the day of the week (added in PHP 5.1.0) "1" (for Monday) through "7" (for Sunday) * S English ordinal suffix for the day of the month, 2 characters "st", "nd", "rd" or "th". Works well with j * w Numeric representation of the day of the week "0" (for Sunday) through "6" (for Saturday) * z The day of the year (starting from "0") "0" through "365" * W ISO-8601 week number of year, weeks starting on Monday "00" to ("52" or "53") * F A full textual representation of a month, such as January or March "January" through "December" * m Numeric representation of a month, with leading zeros "01" through "12" * M A short textual representation of a month, three letters "Jan" through "Dec" * n Numeric representation of a month, without leading zeros "1" through "12" * t Number of days in the given month "28" through "31" * L Whether it's a leap year "1" if it is a leap year, "0" otherwise * o ISO-8601 year number. This has the same value as Y, except that if the "2008" * ISO week number (W) belongs to the previous or next year, that year * is used instead. * Y A full numeric representation of a year, 4 digits "2008" * y A two digit representation of a year "08" * a Lowercase Ante meridiem and Post meridiem "am" or "pm" * A Uppercase Ante meridiem and Post meridiem "AM" or "PM" * B Swatch Internet time "000" through "999" * g 12-hour format of an hour without leading zeros "1" through "12" * G 24-hour format of an hour without leading zeros "0" through "23" * h 12-hour format of an hour with leading zeros "01" through "12" * H 24-hour format of an hour with leading zeros "00" through "23" * i Minutes with leading zeros "00" to "59" * s Seconds, with leading zeros "00" through "59" * u Milliseconds "54321" * e Timezone identifier "UTC", "EST", "PST" * I Whether or not the date is in daylight saving time (uppercase i) "1" if Daylight Saving Time, "0" otherwise * O Difference to Greenwich time (GMT) in hours "+0200", "-0600" * P Difference to Greenwich time (GMT) with colon between hours and minutes "+02:00", "-06:00" * T Timezone abbreviation "UTC", "EST", "PST" * Z Timezone offset in seconds. The offset for timezones west of UTC is "-43200" through "50400" * always negative, and for those east of UTC is always positive. * c ISO 8601 date "2004-02-12T15:19:21+00:00" * r RFC 2822 formatted date "Thu, 21 Dec 2000 16:01:07 +0200" * U Seconds since the Unix Epoch (January 1 1970 00:00:00 GMT) "0" * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @return {String} A string representation of the current Date object. */ var formatReplace = function (context) { return function (m) { var formatString, override = false; if (m.charAt(0) === "\\" || m.substring(0, 2) === "%%") { return m.replace("\\", "").replace("%%", "%"); } override = normalizer.shouldOverrideDefaults(m); formatString = $D.normalizeFormat(m, context); if (formatString) { return context.toString(formatString, override); } }; }; $P._format = function (format) { var formatter = formatReplace(this); if (!format) { return this._toString(); } else { return format.replace(/(%|\\)?.|%%/g, formatter); } }; if (!$P.format) { $P.format = $P._format; } }()); (function () { "use strict"; var gFn = function (attr) { return function () { return this[attr]; }; }; var sFn = function (attr) { return function (val) { this[attr] = val; return this; }; }; var attrs = ["years", "months", "days", "hours", "minutes", "seconds", "milliseconds"]; var addSetFuncs = function (context, attrs) { for (var i = 0; i < attrs.length ; i++) { var $a = attrs[i], $b = $a.slice(0, 1).toUpperCase() + $a.slice(1); context.prototype[$a] = 0; context.prototype["get" + $b] = gFn($a); context.prototype["set" + $b] = sFn($a); } }; /** * new TimeSpan(milliseconds); * new TimeSpan(days, hours, minutes, seconds); * new TimeSpan(days, hours, minutes, seconds, milliseconds); */ var TimeSpan = function (days, hours, minutes, seconds, milliseconds) { if (arguments.length === 1 && typeof days === "number") { var orient = (days < 0) ? -1 : +1; var millsLeft = Math.abs(days); this.setDays(Math.floor(millsLeft / 86400000) * orient); millsLeft = millsLeft % 86400000; this.setHours(Math.floor(millsLeft / 3600000) * orient); millsLeft = millsLeft % 3600000; this.setMinutes(Math.floor(millsLeft / 60000) * orient); millsLeft = millsLeft % 60000; this.setSeconds(Math.floor(millsLeft / 1000) * orient); millsLeft = millsLeft % 1000; this.setMilliseconds(millsLeft * orient); } else { this.set(days, hours, minutes, seconds, milliseconds); } this.getTotalMilliseconds = function () { return (this.getDays() * 86400000) + (this.getHours() * 3600000) + (this.getMinutes() * 60000) + (this.getSeconds() * 1000); }; this.compareTo = function (time) { var t1 = new Date(1970, 1, 1, this.getHours(), this.getMinutes(), this.getSeconds()), t2; if (time === null) { t2 = new Date(1970, 1, 1, 0, 0, 0); } else { t2 = new Date(1970, 1, 1, time.getHours(), time.getMinutes(), time.getSeconds()); } return (t1 < t2) ? -1 : (t1 > t2) ? 1 : 0; }; this.equals = function (time) { return (this.compareTo(time) === 0); }; this.add = function (time) { return (time === null) ? this : this.addSeconds(time.getTotalMilliseconds() / 1000); }; this.subtract = function (time) { return (time === null) ? this : this.addSeconds(-time.getTotalMilliseconds() / 1000); }; this.addDays = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 86400000)); }; this.addHours = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 3600000)); }; this.addMinutes = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 60000)); }; this.addSeconds = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 1000)); }; this.addMilliseconds = function (n) { return new TimeSpan(this.getTotalMilliseconds() + n); }; this.get12HourHour = function () { return (this.getHours() > 12) ? this.getHours() - 12 : (this.getHours() === 0) ? 12 : this.getHours(); }; this.getDesignator = function () { return (this.getHours() < 12) ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator; }; this.toString = function (format) { this._toString = function () { if (this.getDays() !== null && this.getDays() > 0) { return this.getDays() + "." + this.getHours() + ":" + this.p(this.getMinutes()) + ":" + this.p(this.getSeconds()); } else { return this.getHours() + ":" + this.p(this.getMinutes()) + ":" + this.p(this.getSeconds()); } }; this.p = function (s) { return (s.toString().length < 2) ? "0" + s : s; }; var me = this; return format ? format.replace(/dd?|HH?|hh?|mm?|ss?|tt?/g, function (format) { switch (format) { case "d": return me.getDays(); case "dd": return me.p(me.getDays()); case "H": return me.getHours(); case "HH": return me.p(me.getHours()); case "h": return me.get12HourHour(); case "hh": return me.p(me.get12HourHour()); case "m": return me.getMinutes(); case "mm": return me.p(me.getMinutes()); case "s": return me.getSeconds(); case "ss": return me.p(me.getSeconds()); case "t": return ((me.getHours() < 12) ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator).substring(0, 1); case "tt": return (me.getHours() < 12) ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator; } } ) : this._toString(); }; return this; }; addSetFuncs(TimeSpan, attrs.slice(2)); TimeSpan.prototype.set = function (days, hours, minutes, seconds, milliseconds){ this.setDays(days || this.getDays()); this.setHours(hours || this.getHours()); this.setMinutes(minutes || this.getMinutes()); this.setSeconds(seconds || this.getSeconds()); this.setMilliseconds(milliseconds || this.getMilliseconds()); }; /** * Gets the time of day for this date instances. * @return {TimeSpan} TimeSpan */ Date.prototype.getTimeOfDay = function () { return new TimeSpan(0, this.getHours(), this.getMinutes(), this.getSeconds(), this.getMilliseconds()); }; Date.TimeSpan = TimeSpan; if (typeof window !== "undefined" ) { // keeping API compatible for v1.x window.TimeSpan = TimeSpan; } }()); (function () { "use strict"; var attrs = ["years", "months", "days", "hours", "minutes", "seconds", "milliseconds"]; var gFn = function (attr) { return function () { return this[attr]; }; }; var sFn = function (attr) { return function (val) { this[attr] = val; return this; }; }; var addSetFuncs = function (context, attrs) { for (var i = 0; i < attrs.length ; i++) { var $a = attrs[i], $b = $a.slice(0, 1).toUpperCase() + $a.slice(1); context.prototype[$a] = 0; context.prototype["get" + $b] = gFn($a); context.prototype["set" + $b] = sFn($a); } }; var setMonthsAndYears = function (orient, d1, d2, context) { function inc() { d1.addMonths(-orient); context.months++; if (context.months === 12) { context.years++; context.months = 0; } } if (orient === +1) { while (d1 > d2) { inc(); } } else { while (d1 < d2) { inc(); } } context.months--; context.months *= orient; context.years *= orient; }; var adjustForDST = function(orient, startDate, endDate) { var hasDSTMismatch = (false === (startDate.isDaylightSavingTime() === endDate.isDaylightSavingTime())); if (hasDSTMismatch && orient === 1) { startDate.addHours(-1); } else if (hasDSTMismatch) { startDate.addHours(1); } }; /** * TimePeriod(startDate, endDate); * TimePeriod(years, months, days, hours, minutes, seconds, milliseconds); */ var TimePeriod = function (years, months, days, hours, minutes, seconds, milliseconds) { if (arguments.length === 7) { this.set(years, months, days, hours, minutes, seconds, milliseconds); } else if (arguments.length === 2 && arguments[0] instanceof Date && arguments[1] instanceof Date) { var startDate = arguments[0].clone(); var endDate = arguments[1].clone(); var orient = (startDate > endDate) ? +1 : -1; this.dates = { start: arguments[0].clone(), end: arguments[1].clone() }; setMonthsAndYears(orient, startDate, endDate, this); adjustForDST(orient, startDate, endDate); // // TODO - adjust for DST var diff = endDate - startDate; if (diff !== 0) { var ts = new TimeSpan(diff); this.set(this.years, this.months, ts.getDays(), ts.getHours(), ts.getMinutes(), ts.getSeconds(), ts.getMilliseconds()); } } return this; }; // create all the set functions. addSetFuncs(TimePeriod, attrs); TimePeriod.prototype.set = function (years, months, days, hours, minutes, seconds, milliseconds){ this.setYears(years || this.getYears()); this.setMonths(months || this.getMonths()); this.setDays(days || this.getDays()); this.setHours(hours || this.getHours()); this.setMinutes(minutes || this.getMinutes()); this.setSeconds(seconds || this.getSeconds()); this.setMilliseconds(milliseconds || this.getMilliseconds()); }; Date.TimePeriod = TimePeriod; if (typeof window !== "undefined") { // keeping API compatible for v1.x window.TimePeriod = TimePeriod; } }()); ================================================ FILE: build/date-kk-KZ.js ================================================ /** * @overview datejs * @version 1.0.0-rc3 * @author Gregory Wild-Smith * @copyright 2015 Gregory Wild-Smith * @license MIT * @homepage https://github.com/abritinthebay/datejs */ /* * DateJS Culture String File * Country Code: kk-KZ * Name: Kazakh (Kazakhstan) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["kk-KZ"] = { "name": "kk-KZ", "englishName": "Kazakh (Kazakhstan)", "nativeName": "Қазақ (Қазақстан)", "Sunday": "Жексенбі", "Monday": "Дүйсенбі", "Tuesday": "Сейсенбі", "Wednesday": "Сәрсенбі", "Thursday": "Бейсенбі", "Friday": "Жұма", "Saturday": "Сенбі", "Sun": "Жк", "Mon": "Дс", "Tue": "Сс", "Wed": "Ср", "Thu": "Бс", "Fri": "Жм", "Sat": "Сн", "Su": "Жк", "Mo": "Дс", "Tu": "Сс", "We": "Ср", "Th": "Бс", "Fr": "Жм", "Sa": "Сн", "S_Sun_Initial": "Ж", "M_Mon_Initial": "Д", "T_Tue_Initial": "С", "W_Wed_Initial": "С", "T_Thu_Initial": "Б", "F_Fri_Initial": "Ж", "S_Sat_Initial": "С", "January": "қаңтар", "February": "ақпан", "March": "наурыз", "April": "сәуір", "May": "мамыр", "June": "маусым", "July": "шілде", "August": "тамыз", "September": "қыркүйек", "October": "қазан", "November": "қараша", "December": "желтоқсан", "Jan_Abbr": "Қаң", "Feb_Abbr": "Ақп", "Mar_Abbr": "Нау", "Apr_Abbr": "Сәу", "May_Abbr": "Мам", "Jun_Abbr": "Мау", "Jul_Abbr": "Шіл", "Aug_Abbr": "Там", "Sep_Abbr": "Қыр", "Oct_Abbr": "Қаз", "Nov_Abbr": "Қар", "Dec_Abbr": "Жел", "AM": "", "PM": "", "firstDayOfWeek": 1, "twoDigitYearMax": 2029, "mdy": "dmy", "M/d/yyyy": "dd.MM.yyyy", "dddd, MMMM dd, yyyy": "d MMMM yyyy 'ж.'", "h:mm tt": "H:mm", "h:mm:ss tt": "H:mm:ss", "dddd, MMMM dd, yyyy h:mm:ss tt": "d MMMM yyyy 'ж.' H:mm:ss", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "d MMMM", "MMMM, yyyy": "MMMM yyyy", "/jan(uary)?/": "қаң(тар)?", "/feb(ruary)?/": "ақп(ан)?", "/mar(ch)?/": "нау(рыз)?", "/apr(il)?/": "сәу(ір)?", "/may/": "мам(ыр)?", "/jun(e)?/": "мау(сым)?", "/jul(y)?/": "шіл(де)?", "/aug(ust)?/": "там(ыз)?", "/sep(t(ember)?)?/": "қыр(күйек)?", "/oct(ober)?/": "қаз(ан)?", "/nov(ember)?/": "қар(аша)?", "/dec(ember)?/": "жел(тоқсан)?", "/^su(n(day)?)?/": "^жексенбі", "/^mo(n(day)?)?/": "^дүйсенбі", "/^tu(e(s(day)?)?)?/": "^сейсенбі", "/^we(d(nesday)?)?/": "^сәрсенбі", "/^th(u(r(s(day)?)?)?)?/": "^бейсенбі", "/^fr(i(day)?)?/": "^жұма", "/^sa(t(urday)?)?/": "^сенбі", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "kk-KZ"; /** * @overview datejs * @version 1.0.0-rc3 * @author Gregory Wild-Smith * @copyright 2015 Gregory Wild-Smith * @license MIT * @homepage https://github.com/abritinthebay/datejs */(function () { var $D = Date; var lang = Date.CultureStrings ? Date.CultureStrings.lang : null; var loggedKeys = {}; // for debug purposes. var getText = { getFromKey: function (key, countryCode) { var output; if (Date.CultureStrings && Date.CultureStrings[countryCode] && Date.CultureStrings[countryCode][key]) { output = Date.CultureStrings[countryCode][key]; } else { output = getText.buildFromDefault(key); } if (key.charAt(0) === "/") { // Assume it's a regex output = getText.buildFromRegex(key, countryCode); } return output; }, getFromObjectValues: function (obj, countryCode) { var key, output = {}; for(key in obj) { if (obj.hasOwnProperty(key)) { output[key] = getText.getFromKey(obj[key], countryCode); } } return output; }, getFromObjectKeys: function (obj, countryCode) { var key, output = {}; for(key in obj) { if (obj.hasOwnProperty(key)) { output[getText.getFromKey(key, countryCode)] = obj[key]; } } return output; }, getFromArray: function (arr, countryCode) { var output = []; for (var i=0; i < arr.length; i++){ if (i in arr) { output[i] = getText.getFromKey(arr[i], countryCode); } } return output; }, buildFromDefault: function (key) { var output, length, split, last; switch(key) { case "name": output = "en-US"; break; case "englishName": output = "English (United States)"; break; case "nativeName": output = "English (United States)"; break; case "twoDigitYearMax": output = 2049; break; case "firstDayOfWeek": output = 0; break; default: output = key; split = key.split("_"); length = split.length; if (length > 1 && key.charAt(0) !== "/") { // if the key isn't a regex and it has a split. last = split[(length - 1)].toLowerCase(); if (last === "initial" || last === "abbr") { output = split[0]; } } break; } return output; }, buildFromRegex: function (key, countryCode) { var output; if (Date.CultureStrings && Date.CultureStrings[countryCode] && Date.CultureStrings[countryCode][key]) { output = new RegExp(Date.CultureStrings[countryCode][key], "i"); } else { output = new RegExp(key.replace(new RegExp("/", "g"),""), "i"); } return output; } }; var shallowMerge = function (obj1, obj2) { for (var attrname in obj2) { if (obj2.hasOwnProperty(attrname)) { obj1[attrname] = obj2[attrname]; } } }; var __ = function (key, language) { var countryCode = (language) ? language : lang; loggedKeys[key] = key; if (typeof key === "object") { if (key instanceof Array) { return getText.getFromArray(key, countryCode); } else { return getText.getFromObjectKeys(key, countryCode); } } else { return getText.getFromKey(key, countryCode); } }; var loadI18nScript = function (code) { // paatterned after jQuery's getScript. var url = Date.Config.i18n + code + ".js"; var head = document.getElementsByTagName("head")[0] || document.documentElement; var script = document.createElement("script"); script.src = url; var completed = false; var events = { done: function (){} // placeholder function }; // Attach handlers for all browsers script.onload = script.onreadystatechange = function() { if ( !completed && (!this.readyState || this.readyState === "loaded" || this.readyState === "complete") ) { events.done(); head.removeChild(script); } }; setTimeout(function() { head.insertBefore(script, head.firstChild); }, 0); // allows return to execute first return { done: function (cb) { events.done = function() { if (cb) { setTimeout(cb,0); } }; } }; }; var buildInfo = { buildFromMethodHash: function (obj) { var key; for(key in obj) { if (obj.hasOwnProperty(key)) { obj[key] = buildInfo[obj[key]](); } } return obj; }, timeZoneDST: function () { var DST = { "CHADT": "+1345", "NZDT": "+1300", "AEDT": "+1100", "ACDT": "+1030", "AZST": "+0500", "IRDT": "+0430", "EEST": "+0300", "CEST": "+0200", "BST": "+0100", "PMDT": "-0200", "ADT": "-0300", "NDT": "-0230", "EDT": "-0400", "CDT": "-0500", "MDT": "-0600", "PDT": "-0700", "AKDT": "-0800", "HADT": "-0900" }; return __(DST); }, timeZoneStandard: function () { var standard = { "LINT": "+1400", "TOT": "+1300", "CHAST": "+1245", "NZST": "+1200", "NFT": "+1130", "SBT": "+1100", "AEST": "+1000", "ACST": "+0930", "JST": "+0900", "CWST": "+0845", "CT": "+0800", "ICT": "+0700", "MMT": "+0630", "BST": "+0600", "NPT": "+0545", "IST": "+0530", "PKT": "+0500", "AFT": "+0430", "MSK": "+0400", "IRST": "+0330", "FET": "+0300", "EET": "+0200", "CET": "+0100", "GMT": "+0000", "UTC": "+0000", "CVT": "-0100", "GST": "-0200", "BRT": "-0300", "NST": "-0330", "AST": "-0400", "EST": "-0500", "CST": "-0600", "MST": "-0700", "PST": "-0800", "AKST": "-0900", "MIT": "-0930", "HST": "-1000", "SST": "-1100", "BIT": "-1200" }; return __(standard); }, timeZones: function (data) { var zone; data.timezones = []; for (zone in data.abbreviatedTimeZoneStandard) { if (data.abbreviatedTimeZoneStandard.hasOwnProperty(zone)) { data.timezones.push({ name: zone, offset: data.abbreviatedTimeZoneStandard[zone]}); } } for (zone in data.abbreviatedTimeZoneDST) { if (data.abbreviatedTimeZoneDST.hasOwnProperty(zone)) { data.timezones.push({ name: zone, offset: data.abbreviatedTimeZoneDST[zone], dst: true}); } } return data.timezones; }, days: function () { return __(["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"]); }, dayAbbr: function () { return __(["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"]); }, dayShortNames: function () { return __(["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"]); }, dayFirstLetters: function () { return __(["S_Sun_Initial", "M_Mon_Initial", "T_Tues_Initial", "W_Wed_Initial", "T_Thu_Initial", "F_Fri_Initial", "S_Sat_Initial"]); }, months: function () { return __(["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"]); }, monthAbbr: function () { return __(["Jan_Abbr", "Feb_Abbr", "Mar_Abbr", "Apr_Abbr", "May_Abbr", "Jun_Abbr", "Jul_Abbr", "Aug_Abbr", "Sep_Abbr", "Oct_Abbr", "Nov_Abbr", "Dec_Abbr"]); }, formatPatterns: function () { return getText.getFromObjectValues({ shortDate: "M/d/yyyy", longDate: "dddd, MMMM dd, yyyy", shortTime: "h:mm tt", longTime: "h:mm:ss tt", fullDateTime: "dddd, MMMM dd, yyyy h:mm:ss tt", sortableDateTime: "yyyy-MM-ddTHH:mm:ss", universalSortableDateTime: "yyyy-MM-dd HH:mm:ssZ", rfc1123: "ddd, dd MMM yyyy HH:mm:ss", monthDay: "MMMM dd", yearMonth: "MMMM, yyyy" }, Date.i18n.currentLanguage()); }, regex: function () { return getText.getFromObjectValues({ inTheMorning: "/( in the )(morn(ing)?)\\b/", thisMorning: "/(this )(morn(ing)?)\\b/", amThisMorning: "/(\b\\d(am)? )(this )(morn(ing)?)/", inTheEvening: "/( in the )(even(ing)?)\\b/", thisEvening: "/(this )(even(ing)?)\\b/", pmThisEvening: "/(\b\\d(pm)? )(this )(even(ing)?)/", jan: "/jan(uary)?/", feb: "/feb(ruary)?/", mar: "/mar(ch)?/", apr: "/apr(il)?/", may: "/may/", jun: "/jun(e)?/", jul: "/jul(y)?/", aug: "/aug(ust)?/", sep: "/sep(t(ember)?)?/", oct: "/oct(ober)?/", nov: "/nov(ember)?/", dec: "/dec(ember)?/", sun: "/^su(n(day)?)?/", mon: "/^mo(n(day)?)?/", tue: "/^tu(e(s(day)?)?)?/", wed: "/^we(d(nesday)?)?/", thu: "/^th(u(r(s(day)?)?)?)?/", fri: "/fr(i(day)?)?/", sat: "/^sa(t(urday)?)?/", future: "/^next/", past: "/^last|past|prev(ious)?/", add: "/^(\\+|aft(er)?|from|hence)/", subtract: "/^(\\-|bef(ore)?|ago)/", yesterday: "/^yes(terday)?/", today: "/^t(od(ay)?)?/", tomorrow: "/^tom(orrow)?/", now: "/^n(ow)?/", millisecond: "/^ms|milli(second)?s?/", second: "/^sec(ond)?s?/", minute: "/^mn|min(ute)?s?/", hour: "/^h(our)?s?/", week: "/^w(eek)?s?/", month: "/^m(onth)?s?/", day: "/^d(ay)?s?/", year: "/^y(ear)?s?/", shortMeridian: "/^(a|p)/", longMeridian: "/^(a\\.?m?\\.?|p\\.?m?\\.?)/", timezone: "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/", ordinalSuffix: "/^\\s*(st|nd|rd|th)/", timeContext: "/^\\s*(\\:|a(?!u|p)|p)/" }, Date.i18n.currentLanguage()); } }; var CultureInfo = function () { var info = getText.getFromObjectValues({ name: "name", englishName: "englishName", nativeName: "nativeName", amDesignator: "AM", pmDesignator: "PM", firstDayOfWeek: "firstDayOfWeek", twoDigitYearMax: "twoDigitYearMax", dateElementOrder: "mdy" }, Date.i18n.currentLanguage()); var constructedInfo = buildInfo.buildFromMethodHash({ dayNames: "days", abbreviatedDayNames: "dayAbbr", shortestDayNames: "dayShortNames", firstLetterDayNames: "dayFirstLetters", monthNames: "months", abbreviatedMonthNames: "monthAbbr", formatPatterns: "formatPatterns", regexPatterns: "regex", abbreviatedTimeZoneDST: "timeZoneDST", abbreviatedTimeZoneStandard: "timeZoneStandard" }); shallowMerge(info, constructedInfo); buildInfo.timeZones(info); return info; }; $D.i18n = { __: function (key, lang) { return __(key, lang); }, currentLanguage: function () { return lang || "en-US"; }, setLanguage: function (code, force, cb) { var async = false; if (force || code === "en-US" || (!!Date.CultureStrings && !!Date.CultureStrings[code])) { lang = code; Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings.lang = code; Date.CultureInfo = new CultureInfo(); } else { if (!(!!Date.CultureStrings && !!Date.CultureStrings[code])) { if (typeof exports !== "undefined" && this.exports !== exports) { // we're in a Node enviroment, load it using require try { require("../i18n/" + code + ".js"); lang = code; Date.CultureStrings.lang = code; Date.CultureInfo = new CultureInfo(); } catch (e) { // var str = "The language for '" + code + "' could not be loaded by Node. It likely does not exist."; throw new Error("The DateJS IETF language tag '" + code + "' could not be loaded by Node. It likely does not exist."); } } else if (Date.Config && Date.Config.i18n) { // we know the location of the files, so lets load them async = true; loadI18nScript(code).done(function(){ lang = code; Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings.lang = code; Date.CultureInfo = new CultureInfo(); $D.Parsing.Normalizer.buildReplaceData(); // because this is async if ($D.Grammar) { $D.Grammar.buildGrammarFormats(); // so we can parse those strings... } if (cb) { setTimeout(cb,0); } }); } else { Date.console.error("The DateJS IETF language tag '" + code + "' is not available and has not been loaded."); return false; } } } $D.Parsing.Normalizer.buildReplaceData(); // rebuild normalizer strings if ($D.Grammar) { $D.Grammar.buildGrammarFormats(); // so we can parse those strings... } if (!async && cb) { setTimeout(cb,0); } }, getLoggedKeys: function () { return loggedKeys; }, updateCultureInfo: function () { Date.CultureInfo = new CultureInfo(); } }; $D.i18n.updateCultureInfo(); // run automatically }()); (function () { var $D = Date, $P = $D.prototype, p = function (s, l) { if (!l) { l = 2; } return ("000" + s).slice(l * -1); }; if (typeof window !== "undefined" && typeof window.console !== "undefined" && typeof window.console.log !== "undefined") { $D.console = console; // used only to raise non-critical errors if available } else { // set mock so we don't give errors. $D.console = { log: function(){}, error: function(){} }; } $D.Config = $D.Config || {}; $D.initOverloads = function() { /** * Overload of Date.now. Allows an alternate call for Date.now where it returns the * current Date as an object rather than just milliseconds since the Unix Epoch. * * Also provides an implementation of now() for browsers (IE<9) that don't have it. * * Backwards compatible so with work with either: * Date.now() [returns ms] * or * Date.now(true) [returns Date] */ if (!$D.now) { $D._now = function now() { return new Date().getTime(); }; } else if (!$D._now) { $D._now = $D.now; } $D.now = function (returnObj) { if (returnObj) { return $D.present(); } else { return $D._now(); } }; if ( !$P.toISOString ) { $P.toISOString = function() { return this.getUTCFullYear() + "-" + p(this.getUTCMonth() + 1) + "-" + p(this.getUTCDate()) + "T" + p(this.getUTCHours()) + ":" + p(this.getUTCMinutes()) + ":" + p(this.getUTCSeconds()) + "." + String( (this.getUTCMilliseconds()/1000).toFixed(3)).slice(2, 5) + "Z"; }; } // private if ( $P._toString === undefined ){ $P._toString = $P.toString; } }; $D.initOverloads(); /** * Gets a date that is set to the current date. The time is set to the start of the day (00:00 or 12:00 AM). * @return {Date} The current date. */ $D.today = function () { return new Date().clearTime(); }; /** * Gets a date that is set to the current date and time (same as new Date, but chainable) * @return {Date} The current date. */ $D.present = function () { return new Date(); }; /** * Compares the first date to the second date and returns an number indication of their relative values. * @param {Date} First Date object to compare [Required]. * @param {Date} Second Date object to compare to [Required]. * @return {Number} -1 = date1 is lessthan date2. 0 = values are equal. 1 = date1 is greaterthan date2. */ $D.compare = function (date1, date2) { if (isNaN(date1) || isNaN(date2)) { throw new Error(date1 + " - " + date2); } else if (date1 instanceof Date && date2 instanceof Date) { return (date1 < date2) ? -1 : (date1 > date2) ? 1 : 0; } else { throw new TypeError(date1 + " - " + date2); } }; /** * Compares the first Date object to the second Date object and returns true if they are equal. * @param {Date} First Date object to compare [Required] * @param {Date} Second Date object to compare to [Required] * @return {Boolean} true if dates are equal. false if they are not equal. */ $D.equals = function (date1, date2) { return (date1.compareTo(date2) === 0); }; /** * Gets the language appropriate day name when given the day number(0-6) * eg - 0 == Sunday * @return {String} The day name */ $D.getDayName = function (n) { return Date.CultureInfo.dayNames[n]; }; /** * Gets the day number (0-6) if given a CultureInfo specific string which is a valid dayName, abbreviatedDayName or shortestDayName (two char). * @param {String} The name of the day (eg. "Monday, "Mon", "tuesday", "tue", "We", "we"). * @return {Number} The day number */ $D.getDayNumberFromName = function (name) { var n = Date.CultureInfo.dayNames, m = Date.CultureInfo.abbreviatedDayNames, o = Date.CultureInfo.shortestDayNames, s = name.toLowerCase(); for (var i = 0; i < n.length; i++) { if (n[i].toLowerCase() === s || m[i].toLowerCase() === s || o[i].toLowerCase() === s) { return i; } } return -1; }; /** * Gets the month number (0-11) if given a Culture Info specific string which is a valid monthName or abbreviatedMonthName. * @param {String} The name of the month (eg. "February, "Feb", "october", "oct"). * @return {Number} The day number */ $D.getMonthNumberFromName = function (name) { var n = Date.CultureInfo.monthNames, m = Date.CultureInfo.abbreviatedMonthNames, s = name.toLowerCase(); for (var i = 0; i < n.length; i++) { if (n[i].toLowerCase() === s || m[i].toLowerCase() === s) { return i; } } return -1; }; /** * Gets the language appropriate month name when given the month number(0-11) * eg - 0 == January * @return {String} The month name */ $D.getMonthName = function (n) { return Date.CultureInfo.monthNames[n]; }; /** * Determines if the current date instance is within a LeapYear. * @param {Number} The year. * @return {Boolean} true if date is within a LeapYear, otherwise false. */ $D.isLeapYear = function (year) { return ((year % 4 === 0 && year % 100 !== 0) || year % 400 === 0); }; /** * Gets the number of days in the month, given a year and month value. Automatically corrects for LeapYear. * @param {Number} The year. * @param {Number} The month (0-11). * @return {Number} The number of days in the month. */ $D.getDaysInMonth = function (year, month) { if (!month && $D.validateMonth(year)) { month = year; year = Date.today().getFullYear(); } return [31, ($D.isLeapYear(year) ? 29 : 28), 31, 30, 31, 30, 31, 31, 30, 31, 30, 31][month]; }; $P.getDaysInMonth = function () { return $D.getDaysInMonth(this.getFullYear(), this.getMonth()); }; $D.getTimezoneAbbreviation = function (offset, dst) { var p, n = (dst || false) ? Date.CultureInfo.abbreviatedTimeZoneDST : Date.CultureInfo.abbreviatedTimeZoneStandard; for (p in n) { if (n.hasOwnProperty(p)) { if (n[p] === offset) { return p; } } } return null; }; $D.getTimezoneOffset = function (name, dst) { var i, a =[], z = Date.CultureInfo.timezones; if (!name) { name = (new Date()).getTimezone();} for (i = 0; i < z.length; i++) { if (z[i].name === name.toUpperCase()) { a.push(i); } } if (!z[a[0]]) { return null; } if (a.length === 1 || !dst) { return z[a[0]].offset; } else { for (i=0; i < a.length; i++) { if (z[a[i]].dst) { return z[a[i]].offset; } } } }; $D.getQuarter = function (d) { d = d || new Date(); // If no date supplied, use today var q = [1,2,3,4]; return q[Math.floor(d.getMonth() / 3)]; // ~~~ is a bitwise op. Faster than Math.floor }; $D.getDaysLeftInQuarter = function (d) { d = d || new Date(); var qEnd = new Date(d); qEnd.setMonth(qEnd.getMonth() + 3 - qEnd.getMonth() % 3, 0); return Math.floor((qEnd - d) / 8.64e7); }; // private var validate = function (n, min, max, name) { name = name ? name : "Object"; if (typeof n === "undefined") { return false; } else if (typeof n !== "number") { throw new TypeError(n + " is not a Number."); } else if (n < min || n > max) { // As failing validation is *not* an exceptional circumstance // lets not throw a RangeError Exception here. // It's semantically correct but it's not sensible. return false; } return true; }; /** * Validates the number is within an acceptable range for milliseconds [0-999]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateMillisecond = function (value) { return validate(value, 0, 999, "millisecond"); }; /** * Validates the number is within an acceptable range for seconds [0-59]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateSecond = function (value) { return validate(value, 0, 59, "second"); }; /** * Validates the number is within an acceptable range for minutes [0-59]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateMinute = function (value) { return validate(value, 0, 59, "minute"); }; /** * Validates the number is within an acceptable range for hours [0-23]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateHour = function (value) { return validate(value, 0, 23, "hour"); }; /** * Validates the number is within an acceptable range for the days in a month [0-MaxDaysInMonth]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateDay = function (value, year, month) { if (year === undefined || year === null || month === undefined || month === null) { return false;} return validate(value, 1, $D.getDaysInMonth(year, month), "day"); }; /** * Validates the number is within an acceptable range for months [0-11]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateWeek = function (value) { return validate(value, 0, 53, "week"); }; /** * Validates the number is within an acceptable range for months [0-11]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateMonth = function (value) { return validate(value, 0, 11, "month"); }; /** * Validates the number is within an acceptable range for years. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateYear = function (value) { /** * Per ECMAScript spec the range of times supported by Date objects is * exactly -100,000,000 days to +100,000,000 days measured relative to * midnight at the beginning of 01 January, 1970 UTC. * This gives a range of 8,640,000,000,000,000 milliseconds to either * side of 01 January, 1970 UTC. * * Earliest possible date: Tue, 20 Apr 271,822 B.C. 00:00:00 UTC * Latest possible date: Sat, 13 Sep 275,760 00:00:00 UTC */ return validate(value, -271822, 275760, "year"); }; $D.validateTimezone = function(value) { var timezones = {"ACDT":1,"ACST":1,"ACT":1,"ADT":1,"AEDT":1,"AEST":1,"AFT":1,"AKDT":1,"AKST":1,"AMST":1,"AMT":1,"ART":1,"AST":1,"AWDT":1,"AWST":1,"AZOST":1,"AZT":1,"BDT":1,"BIOT":1,"BIT":1,"BOT":1,"BRT":1,"BST":1,"BTT":1,"CAT":1,"CCT":1,"CDT":1,"CEDT":1,"CEST":1,"CET":1,"CHADT":1,"CHAST":1,"CHOT":1,"ChST":1,"CHUT":1,"CIST":1,"CIT":1,"CKT":1,"CLST":1,"CLT":1,"COST":1,"COT":1,"CST":1,"CT":1,"CVT":1,"CWST":1,"CXT":1,"DAVT":1,"DDUT":1,"DFT":1,"EASST":1,"EAST":1,"EAT":1,"ECT":1,"EDT":1,"EEDT":1,"EEST":1,"EET":1,"EGST":1,"EGT":1,"EIT":1,"EST":1,"FET":1,"FJT":1,"FKST":1,"FKT":1,"FNT":1,"GALT":1,"GAMT":1,"GET":1,"GFT":1,"GILT":1,"GIT":1,"GMT":1,"GST":1,"GYT":1,"HADT":1,"HAEC":1,"HAST":1,"HKT":1,"HMT":1,"HOVT":1,"HST":1,"ICT":1,"IDT":1,"IOT":1,"IRDT":1,"IRKT":1,"IRST":1,"IST":1,"JST":1,"KGT":1,"KOST":1,"KRAT":1,"KST":1,"LHST":1,"LINT":1,"MAGT":1,"MART":1,"MAWT":1,"MDT":1,"MET":1,"MEST":1,"MHT":1,"MIST":1,"MIT":1,"MMT":1,"MSK":1,"MST":1,"MUT":1,"MVT":1,"MYT":1,"NCT":1,"NDT":1,"NFT":1,"NPT":1,"NST":1,"NT":1,"NUT":1,"NZDT":1,"NZST":1,"OMST":1,"ORAT":1,"PDT":1,"PET":1,"PETT":1,"PGT":1,"PHOT":1,"PHT":1,"PKT":1,"PMDT":1,"PMST":1,"PONT":1,"PST":1,"PYST":1,"PYT":1,"RET":1,"ROTT":1,"SAKT":1,"SAMT":1,"SAST":1,"SBT":1,"SCT":1,"SGT":1,"SLST":1,"SRT":1,"SST":1,"SYOT":1,"TAHT":1,"THA":1,"TFT":1,"TJT":1,"TKT":1,"TLT":1,"TMT":1,"TOT":1,"TVT":1,"UCT":1,"ULAT":1,"UTC":1,"UYST":1,"UYT":1,"UZT":1,"VET":1,"VLAT":1,"VOLT":1,"VOST":1,"VUT":1,"WAKT":1,"WAST":1,"WAT":1,"WEDT":1,"WEST":1,"WET":1,"WST":1,"YAKT":1,"YEKT":1,"Z":1}; return (timezones[value] === 1); }; $D.validateTimezoneOffset= function(value) { // timezones go from +14hrs to -12hrs, the +X hours are negative offsets. return (value > -841 && value < 721); }; }()); (function () { var $D = Date, $P = $D.prototype, p = function (s, l) { if (!l) { l = 2; } return ("000" + s).slice(l * -1); }; var validateConfigObject = function (obj) { var result = {}, self = this, prop, testFunc; testFunc = function (prop, func, value) { if (prop === "day") { var month = (obj.month !== undefined) ? obj.month : self.getMonth(); var year = (obj.year !== undefined) ? obj.year : self.getFullYear(); return $D[func](value, year, month); } else { return $D[func](value); } }; for (prop in obj) { if (Object.prototype.hasOwnProperty.call(obj, prop)) { var func = "validate" + prop.charAt(0).toUpperCase() + prop.slice(1); if ($D[func] && obj[prop] !== null && testFunc(prop, func, obj[prop])) { result[prop] = obj[prop]; } } } return result; }; /** * Resets the time of this Date object to 12:00 AM (00:00), which is the start of the day. * @param {Boolean} .clone() this date instance before clearing Time * @return {Date} this */ $P.clearTime = function () { this.setHours(0); this.setMinutes(0); this.setSeconds(0); this.setMilliseconds(0); return this; }; /** * Resets the time of this Date object to the current time ('now'). * @return {Date} this */ $P.setTimeToNow = function () { var n = new Date(); this.setHours(n.getHours()); this.setMinutes(n.getMinutes()); this.setSeconds(n.getSeconds()); this.setMilliseconds(n.getMilliseconds()); return this; }; /** * Returns a new Date object that is an exact date and time copy of the original instance. * @return {Date} A new Date instance */ $P.clone = function () { return new Date(this.getTime()); }; /** * Compares this instance to a Date object and returns an number indication of their relative values. * @param {Date} Date object to compare [Required] * @return {Number} -1 = this is lessthan date. 0 = values are equal. 1 = this is greaterthan date. */ $P.compareTo = function (date) { return Date.compare(this, date); }; /** * Compares this instance to another Date object and returns true if they are equal. * @param {Date} Date object to compare. If no date to compare, new Date() [now] is used. * @return {Boolean} true if dates are equal. false if they are not equal. */ $P.equals = function (date) { return Date.equals(this, (date !== undefined ? date : new Date())); }; /** * Determines if this instance is between a range of two dates or equal to either the start or end dates. * @param {Date} Start of range [Required] * @param {Date} End of range [Required] * @return {Boolean} true is this is between or equal to the start and end dates, else false */ $P.between = function (start, end) { return this.getTime() >= start.getTime() && this.getTime() <= end.getTime(); }; /** * Determines if this date occurs after the date to compare to. * @param {Date} Date object to compare. If no date to compare, new Date() ("now") is used. * @return {Boolean} true if this date instance is greater than the date to compare to (or "now"), otherwise false. */ $P.isAfter = function (date) { return this.compareTo(date || new Date()) === 1; }; /** * Determines if this date occurs before the date to compare to. * @param {Date} Date object to compare. If no date to compare, new Date() ("now") is used. * @return {Boolean} true if this date instance is less than the date to compare to (or "now"). */ $P.isBefore = function (date) { return (this.compareTo(date || new Date()) === -1); }; /** * Determines if the current Date instance occurs today. * @return {Boolean} true if this date instance is 'today', otherwise false. */ /** * Determines if the current Date instance occurs on the same Date as the supplied 'date'. * If no 'date' to compare to is provided, the current Date instance is compared to 'today'. * @param {date} Date object to compare. If no date to compare, the current Date ("now") is used. * @return {Boolean} true if this Date instance occurs on the same Day as the supplied 'date'. */ $P.isToday = $P.isSameDay = function (date) { return this.clone().clearTime().equals((date || new Date()).clone().clearTime()); }; /** * Adds the specified number of milliseconds to this instance. * @param {Number} The number of milliseconds to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addMilliseconds = function (value) { if (!value) { return this; } this.setTime(this.getTime() + value * 1); return this; }; /** * Adds the specified number of seconds to this instance. * @param {Number} The number of seconds to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addSeconds = function (value) { if (!value) { return this; } return this.addMilliseconds(value * 1000); }; /** * Adds the specified number of seconds to this instance. * @param {Number} The number of seconds to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addMinutes = function (value) { if (!value) { return this; } return this.addMilliseconds(value * 60000); // 60*1000 }; /** * Adds the specified number of hours to this instance. * @param {Number} The number of hours to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addHours = function (value) { if (!value) { return this; } return this.addMilliseconds(value * 3600000); // 60*60*1000 }; /** * Adds the specified number of days to this instance. * @param {Number} The number of days to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addDays = function (value) { if (!value) { return this; } this.setDate(this.getDate() + value * 1); return this; }; /** * Adds the specified number of weekdays (ie - not sat or sun) to this instance. * @param {Number} The number of days to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addWeekdays = function (value) { if (!value) { return this; } var day = this.getDay(); var weeks = (Math.ceil(Math.abs(value)/7)); if (day === 0 || day === 6) { if (value > 0) { this.next().monday(); this.addDays(-1); day = this.getDay(); } } if (value < 0) { while (value < 0) { this.addDays(-1); day = this.getDay(); if (day !== 0 && day !== 6) { value++; } } return this; } else if (value > 5 || (6-day) <= value) { value = value + (weeks * 2); } return this.addDays(value); }; /** * Adds the specified number of weeks to this instance. * @param {Number} The number of weeks to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addWeeks = function (value) { if (!value) { return this; } return this.addDays(value * 7); }; /** * Adds the specified number of months to this instance. * @param {Number} The number of months to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addMonths = function (value) { if (!value) { return this; } var n = this.getDate(); this.setDate(1); this.setMonth(this.getMonth() + value * 1); this.setDate(Math.min(n, $D.getDaysInMonth(this.getFullYear(), this.getMonth()))); return this; }; $P.addQuarters = function (value) { if (!value) { return this; } // note this will take you to the same point in the quarter as you are now. // i.e. - if you are 15 days into the quarter you'll be 15 days into the resulting one. // bonus: this allows adding fractional quarters return this.addMonths(value * 3); }; /** * Adds the specified number of years to this instance. * @param {Number} The number of years to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addYears = function (value) { if (!value) { return this; } return this.addMonths(value * 12); }; /** * Adds (or subtracts) to the value of the years, months, weeks, days, hours, minutes, seconds, milliseconds of the date instance using given configuration object. Positive and Negative values allowed. * Example

	Date.today().add( { days: 1, months: 1 } )

	new Date().add( { years: -1 } )
	
* @param {Object} Configuration object containing attributes (months, days, etc.) * @return {Date} this */ $P.add = function (config) { if (typeof config === "number") { this._orient = config; return this; } var x = config; if (x.day) { // If we should be a different date than today (eg: for 'tomorrow -1d', etc). // Should only effect parsing, not direct usage (eg, Finish and FinishExact) if ((x.day - this.getDate()) !== 0) { this.setDate(x.day); } } if (x.milliseconds) { this.addMilliseconds(x.milliseconds); } if (x.seconds) { this.addSeconds(x.seconds); } if (x.minutes) { this.addMinutes(x.minutes); } if (x.hours) { this.addHours(x.hours); } if (x.weeks) { this.addWeeks(x.weeks); } if (x.months) { this.addMonths(x.months); } if (x.years) { this.addYears(x.years); } if (x.days) { this.addDays(x.days); } return this; }; /** * Get the week number. Week one (1) is the week which contains the first Thursday of the year. Monday is considered the first day of the week. * The .getWeek() function does NOT convert the date to UTC. The local datetime is used. * Please use .getISOWeek() to get the week of the UTC converted date. * @return {Number} 1 to 53 */ $P.getWeek = function (utc) { // Create a copy of this date object var self, target = new Date(this.valueOf()); if (utc) { target.addMinutes(target.getTimezoneOffset()); self = target.clone(); } else { self = this; } // ISO week date weeks start on monday // so correct the day number var dayNr = (self.getDay() + 6) % 7; // ISO 8601 states that week 1 is the week // with the first thursday of that year. // Set the target date to the thursday in the target week target.setDate(target.getDate() - dayNr + 3); // Store the millisecond value of the target date var firstThursday = target.valueOf(); // Set the target to the first thursday of the year // First set the target to january first target.setMonth(0, 1); // Not a thursday? Correct the date to the next thursday if (target.getDay() !== 4) { target.setMonth(0, 1 + ((4 - target.getDay()) + 7) % 7); } // The weeknumber is the number of weeks between the // first thursday of the year and the thursday in the target week return 1 + Math.ceil((firstThursday - target) / 604800000); // 604800000 = 7 * 24 * 3600 * 1000 }; /** * Get the ISO 8601 week number. Week one ("01") is the week which contains the first Thursday of the year. Monday is considered the first day of the week. * The .getISOWeek() function does convert the date to it's UTC value. Please use .getWeek() to get the week of the local date. * @return {String} "01" to "53" */ $P.getISOWeek = function () { return p(this.getWeek(true)); }; /** * Moves the date to Monday of the week set. Week one (1) is the week which contains the first Thursday of the year. * @param {Number} A Number (1 to 53) that represents the week of the year. * @return {Date} this */ $P.setWeek = function (n) { if ((n - this.getWeek()) === 0) { if (this.getDay() !== 1) { return this.moveToDayOfWeek(1, (this.getDay() > 1 ? -1 : 1)); } else { return this; } } else { return this.moveToDayOfWeek(1, (this.getDay() > 1 ? -1 : 1)).addWeeks(n - this.getWeek()); } }; $P.setQuarter = function (qtr) { var month = Math.abs(((qtr-1) * 3) + 1); return this.setMonth(month, 1); }; $P.getQuarter = function () { return Date.getQuarter(this); }; $P.getDaysLeftInQuarter = function () { return Date.getDaysLeftInQuarter(this); }; /** * Moves the date to the next n'th occurrence of the dayOfWeek starting from the beginning of the month. The number (-1) is a magic number and will return the last occurrence of the dayOfWeek in the month. * @param {Number} The dayOfWeek to move to * @param {Number} The n'th occurrence to move to. Use (-1) to return the last occurrence in the month * @return {Date} this */ $P.moveToNthOccurrence = function (dayOfWeek, occurrence) { if (dayOfWeek === "Weekday") { if (occurrence > 0) { this.moveToFirstDayOfMonth(); if (this.is().weekday()) { occurrence -= 1; } } else if (occurrence < 0) { this.moveToLastDayOfMonth(); if (this.is().weekday()) { occurrence += 1; } } else { return this; } return this.addWeekdays(occurrence); } var shift = 0; if (occurrence > 0) { shift = occurrence - 1; } else if (occurrence === -1) { this.moveToLastDayOfMonth(); if (this.getDay() !== dayOfWeek) { this.moveToDayOfWeek(dayOfWeek, -1); } return this; } return this.moveToFirstDayOfMonth().addDays(-1).moveToDayOfWeek(dayOfWeek, +1).addWeeks(shift); }; var moveToN = function (getFunc, addFunc, nVal) { return function (value, orient) { var diff = (value - this[getFunc]() + nVal * (orient || +1)) % nVal; return this[addFunc]((diff === 0) ? diff += nVal * (orient || +1) : diff); }; }; /** * Move to the next or last dayOfWeek based on the orient value. * @param {Number} The dayOfWeek to move to * @param {Number} Forward (+1) or Back (-1). Defaults to +1. [Optional] * @return {Date} this */ $P.moveToDayOfWeek = moveToN("getDay", "addDays", 7); /** * Move to the next or last month based on the orient value. * @param {Number} The month to move to. 0 = January, 11 = December * @param {Number} Forward (+1) or Back (-1). Defaults to +1. [Optional] * @return {Date} this */ $P.moveToMonth = moveToN("getMonth", "addMonths", 12); /** * Get the Ordinate of the current day ("th", "st", "rd"). * @return {String} */ $P.getOrdinate = function () { var num = this.getDate(); return ord(num); }; /** * Get the Ordinal day (numeric day number) of the year, adjusted for leap year. * @return {Number} 1 through 365 (366 in leap years) */ $P.getOrdinalNumber = function () { return Math.ceil((this.clone().clearTime() - new Date(this.getFullYear(), 0, 1)) / 86400000) + 1; }; /** * Get the time zone abbreviation of the current date. * @return {String} The abbreviated time zone name (e.g. "EST") */ $P.getTimezone = function () { return $D.getTimezoneAbbreviation(this.getUTCOffset(), this.isDaylightSavingTime()); }; $P.setTimezoneOffset = function (offset) { var here = this.getTimezoneOffset(), there = Number(offset) * -6 / 10; return (there || there === 0) ? this.addMinutes(there - here) : this; }; $P.setTimezone = function (offset) { return this.setTimezoneOffset($D.getTimezoneOffset(offset)); }; /** * Indicates whether Daylight Saving Time is observed in the current time zone. * @return {Boolean} true|false */ $P.hasDaylightSavingTime = function () { return (Date.today().set({month: 0, day: 1}).getTimezoneOffset() !== Date.today().set({month: 6, day: 1}).getTimezoneOffset()); }; /** * Indicates whether this Date instance is within the Daylight Saving Time range for the current time zone. * @return {Boolean} true|false */ $P.isDaylightSavingTime = function () { return Date.today().set({month: 0, day: 1}).getTimezoneOffset() !== this.getTimezoneOffset(); }; /** * Get the offset from UTC of the current date. * @return {String} The 4-character offset string prefixed with + or - (e.g. "-0500") */ $P.getUTCOffset = function (offset) { var n = (offset || this.getTimezoneOffset()) * -10 / 6, r; if (n < 0) { r = (n - 10000).toString(); return r.charAt(0) + r.substr(2); } else { r = (n + 10000).toString(); return "+" + r.substr(1); } }; /** * Returns the number of milliseconds between this date and date. * @param {Date} Defaults to now * @return {Number} The diff in milliseconds */ $P.getElapsed = function (date) { return (date || new Date()) - this; }; /** * Set the value of year, month, day, hour, minute, second, millisecond of date instance using given configuration object. * Example

	Date.today().set( { day: 20, month: 1 } )

	new Date().set( { millisecond: 0 } )
	
* * @param {Object} Configuration object containing attributes (month, day, etc.) * @return {Date} this */ $P.set = function (config) { config = validateConfigObject.call(this, config); var key; for (key in config) { if (Object.prototype.hasOwnProperty.call(config, key)) { var name = key.charAt(0).toUpperCase() + key.slice(1); var addFunc, getFunc; if (key !== "week" && key !== "month" && key !== "timezone" && key !== "timezoneOffset") { name += "s"; } addFunc = "add" + name; getFunc = "get" + name; if (key === "month") { addFunc = addFunc + "s"; } else if (key === "year"){ getFunc = "getFullYear"; } if (key !== "day" && key !== "timezone" && key !== "timezoneOffset" && key !== "week" && key !== "hour") { this[addFunc](config[key] - this[getFunc]()); } else if ( key === "timezone"|| key === "timezoneOffset" || key === "week" || key === "hour") { this["set"+name](config[key]); } } } // day has to go last because you can't validate the day without first knowing the month if (config.day) { this.addDays(config.day - this.getDate()); } return this; }; /** * Moves the date to the first day of the month. * @return {Date} this */ $P.moveToFirstDayOfMonth = function () { return this.set({ day: 1 }); }; /** * Moves the date to the last day of the month. * @return {Date} this */ $P.moveToLastDayOfMonth = function () { return this.set({ day: $D.getDaysInMonth(this.getFullYear(), this.getMonth())}); }; /** * Converts the value of the current Date object to its equivalent string representation. * Format Specifiers * CUSTOM DATE AND TIME FORMAT STRINGS * Format Description Example * ------ --------------------------------------------------------------------------- ----------------------- * s The seconds of the minute between 0-59. "0" to "59" * ss The seconds of the minute with leading zero if required. "00" to "59" * * m The minute of the hour between 0-59. "0" or "59" * mm The minute of the hour with leading zero if required. "00" or "59" * * h The hour of the day between 1-12. "1" to "12" * hh The hour of the day with leading zero if required. "01" to "12" * * H The hour of the day between 0-23. "0" to "23" * HH The hour of the day with leading zero if required. "00" to "23" * * d The day of the month between 1 and 31. "1" to "31" * dd The day of the month with leading zero if required. "01" to "31" * ddd Abbreviated day name. Date.CultureInfo.abbreviatedDayNames. "Mon" to "Sun" * dddd The full day name. Date.CultureInfo.dayNames. "Monday" to "Sunday" * * M The month of the year between 1-12. "1" to "12" * MM The month of the year with leading zero if required. "01" to "12" * MMM Abbreviated month name. Date.CultureInfo.abbreviatedMonthNames. "Jan" to "Dec" * MMMM The full month name. Date.CultureInfo.monthNames. "January" to "December" * * yy The year as a two-digit number. "99" or "08" * yyyy The full four digit year. "1999" or "2008" * * t Displays the first character of the A.M./P.M. designator. "A" or "P" * Date.CultureInfo.amDesignator or Date.CultureInfo.pmDesignator * tt Displays the A.M./P.M. designator. "AM" or "PM" * Date.CultureInfo.amDesignator or Date.CultureInfo.pmDesignator * * S The ordinal suffix ("st, "nd", "rd" or "th") of the current day. "st, "nd", "rd" or "th" * * STANDARD DATE AND TIME FORMAT STRINGS * Format Description Example *------ --------------------------------------------------------------------------- ----------------------- * d The CultureInfo shortDate Format Pattern "M/d/yyyy" * D The CultureInfo longDate Format Pattern "dddd, MMMM dd, yyyy" * F The CultureInfo fullDateTime Format Pattern "dddd, MMMM dd, yyyy h:mm:ss tt" * m The CultureInfo monthDay Format Pattern "MMMM dd" * r The CultureInfo rfc1123 Format Pattern "ddd, dd MMM yyyy HH:mm:ss GMT" * s The CultureInfo sortableDateTime Format Pattern "yyyy-MM-ddTHH:mm:ss" * t The CultureInfo shortTime Format Pattern "h:mm tt" * T The CultureInfo longTime Format Pattern "h:mm:ss tt" * u The CultureInfo universalSortableDateTime Format Pattern "yyyy-MM-dd HH:mm:ssZ" * y The CultureInfo yearMonth Format Pattern "MMMM, yyyy" * * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @return {String} A string representation of the current Date object. */ var ord = function (n) { switch (n * 1) { case 1: case 21: case 31: return "st"; case 2: case 22: return "nd"; case 3: case 23: return "rd"; default: return "th"; } }; var parseStandardFormats = function (format) { var y, c = Date.CultureInfo.formatPatterns; switch (format) { case "d": return this.toString(c.shortDate); case "D": return this.toString(c.longDate); case "F": return this.toString(c.fullDateTime); case "m": return this.toString(c.monthDay); case "r": case "R": y = this.clone().addMinutes(this.getTimezoneOffset()); return y.toString(c.rfc1123) + " GMT"; case "s": return this.toString(c.sortableDateTime); case "t": return this.toString(c.shortTime); case "T": return this.toString(c.longTime); case "u": y = this.clone().addMinutes(this.getTimezoneOffset()); return y.toString(c.universalSortableDateTime); case "y": return this.toString(c.yearMonth); default: return false; } }; var parseFormatStringsClosure = function (context) { return function (m) { if (m.charAt(0) === "\\") { return m.replace("\\", ""); } switch (m) { case "hh": return p(context.getHours() < 13 ? (context.getHours() === 0 ? 12 : context.getHours()) : (context.getHours() - 12)); case "h": return context.getHours() < 13 ? (context.getHours() === 0 ? 12 : context.getHours()) : (context.getHours() - 12); case "HH": return p(context.getHours()); case "H": return context.getHours(); case "mm": return p(context.getMinutes()); case "m": return context.getMinutes(); case "ss": return p(context.getSeconds()); case "s": return context.getSeconds(); case "yyyy": return p(context.getFullYear(), 4); case "yy": return p(context.getFullYear()); case "y": return context.getFullYear(); case "E": case "dddd": return Date.CultureInfo.dayNames[context.getDay()]; case "ddd": return Date.CultureInfo.abbreviatedDayNames[context.getDay()]; case "dd": return p(context.getDate()); case "d": return context.getDate(); case "MMMM": return Date.CultureInfo.monthNames[context.getMonth()]; case "MMM": return Date.CultureInfo.abbreviatedMonthNames[context.getMonth()]; case "MM": return p((context.getMonth() + 1)); case "M": return context.getMonth() + 1; case "t": return context.getHours() < 12 ? Date.CultureInfo.amDesignator.substring(0, 1) : Date.CultureInfo.pmDesignator.substring(0, 1); case "tt": return context.getHours() < 12 ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator; case "S": return ord(context.getDate()); case "W": return context.getWeek(); case "WW": return context.getISOWeek(); case "Q": return "Q" + context.getQuarter(); case "q": return String(context.getQuarter()); case "z": return context.getTimezone(); case "Z": case "X": return Date.getTimezoneOffset(context.getTimezone()); case "ZZ": // Timezone offset in seconds return context.getTimezoneOffset() * -60; case "u": return context.getDay(); case "L": return ($D.isLeapYear(context.getFullYear())) ? 1 : 0; case "B": // Swatch Internet Time (.beats) return "@"+((context.getUTCSeconds() + (context.getUTCMinutes()*60) + ((context.getUTCHours()+1)*3600))/86.4); default: return m; } }; }; $P.toString = function (format, ignoreStandards) { // Standard Date and Time Format Strings. Formats pulled from CultureInfo file and // may vary by culture. if (!ignoreStandards && format && format.length === 1) { output = parseStandardFormats.call(this, format); if (output) { return output; } } var parseFormatStrings = parseFormatStringsClosure(this); return format ? format.replace(/((\\)?(dd?d?d?|MM?M?M?|yy?y?y?|hh?|HH?|mm?|ss?|tt?|S|q|Q|WW?W?W?)(?![^\[]*\]))/g, parseFormatStrings).replace(/\[|\]/g, "") : this._toString(); }; }()); /************************************************************* * SugarPak - Domain Specific Language - Syntactical Sugar * *************************************************************/ (function () { var $D = Date, $P = $D.prototype, $N = Number.prototype; // private $P._orient = +1; // private $P._nth = null; // private $P._is = false; // private $P._same = false; // private $P._isSecond = false; // private $N._dateElement = "days"; /** * Moves the date to the next instance of a date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.today().next().friday();
	Date.today().next().fri();
	Date.today().next().march();
	Date.today().next().mar();
	Date.today().next().week();
	
* * @return {Date} date */ $P.next = function () { this._move = true; this._orient = +1; return this; }; /** * Creates a new Date (Date.today()) and moves the date to the next instance of the date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.next().friday();
	Date.next().fri();
	Date.next().march();
	Date.next().mar();
	Date.next().week();
	
* * @return {Date} date */ $D.next = function () { return $D.today().next(); }; /** * Moves the date to the previous instance of a date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.today().last().friday();
	Date.today().last().fri();
	Date.today().last().march();
	Date.today().last().mar();
	Date.today().last().week();
	
* * @return {Date} date */ $P.last = $P.prev = $P.previous = function () { this._move = true; this._orient = -1; return this; }; /** * Creates a new Date (Date.today()) and moves the date to the previous instance of the date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.last().friday();
	Date.last().fri();
	Date.previous().march();
	Date.prev().mar();
	Date.last().week();
	
* * @return {Date} date */ $D.last = $D.prev = $D.previous = function () { return $D.today().last(); }; /** * Performs a equality check when followed by either a month name, day name or .weekday() function. * Example

	Date.today().is().friday(); // true|false
	Date.today().is().fri();
	Date.today().is().march();
	Date.today().is().mar();
	
* * @return {Boolean} true|false */ $P.is = function () { this._is = true; return this; }; /** * Determines if two date objects occur on/in exactly the same instance of the subsequent date part function. * The function .same() must be followed by a date part function (example: .day(), .month(), .year(), etc). * * An optional Date can be passed in the date part function. If now date is passed as a parameter, 'Now' is used. * * The following example demonstrates how to determine if two dates fall on the exact same day. * * Example

	var d1 = Date.today(); // today at 00:00
	var d2 = new Date();   // exactly now.

	// Do they occur on the same day?
	d1.same().day(d2); // true
	
	// Do they occur on the same hour?
	d1.same().hour(d2); // false, unless d2 hour is '00' (midnight).
	
	// What if it's the same day, but one year apart?
	var nextYear = Date.today().add(1).year();

	d1.same().day(nextYear); // false, because the dates must occur on the exact same day. 
	
* * Scenario: Determine if a given date occurs during some week period 2 months from now. * * Example

	var future = Date.today().add(2).months();
	return someDate.same().week(future); // true|false;
	
* * @return {Boolean} true|false */ $P.same = function () { this._same = true; this._isSecond = false; return this; }; /** * Determines if the current date/time occurs during Today. Must be preceded by the .is() function. * Example

	someDate.is().today();    // true|false
	new Date().is().today();  // true
	Date.today().is().today();// true
	Date.today().add(-1).day().is().today(); // false
	
* * @return {Boolean} true|false */ $P.today = function () { return this.same().day(); }; /** * Determines if the current date is a weekday. This function must be preceded by the .is() function. * Example

	Date.today().is().weekday(); // true|false
	
* * @return {Boolean} true|false */ $P.weekday = function () { if (this._nth) { return df("Weekday").call(this); } if (this._move) { return this.addWeekdays(this._orient); } if (this._is) { this._is = false; return (!this.is().sat() && !this.is().sun()); } return false; }; /** * Determines if the current date is on the weekend. This function must be preceded by the .is() function. * Example

	Date.today().is().weekend(); // true|false
	
* * @return {Boolean} true|false */ $P.weekend = function () { if (this._is) { this._is = false; return (this.is().sat() || this.is().sun()); } return false; }; /** * Sets the Time of the current Date instance. A string "6:15 pm" or config object {hour:18, minute:15} are accepted. * Example

	// Set time to 6:15pm with a String
	Date.today().at("6:15pm");

	// Set time to 6:15pm with a config object
	Date.today().at({hour:18, minute:15});
	
* * @return {Date} date */ $P.at = function (time) { return (typeof time === "string") ? $D.parse(this.toString("d") + " " + time) : this.set(time); }; /** * Creates a new Date() and adds this (Number) to the date based on the preceding date element function (eg. second|minute|hour|day|month|year). * Example

	// Undeclared Numbers must be wrapped with parentheses. Requirment of JavaScript.
	(3).days().fromNow();
	(6).months().fromNow();

	// Declared Number variables do not require parentheses. 
	var n = 6;
	n.months().fromNow();
	
* * @return {Date} A new Date instance */ $N.fromNow = $N.after = function (date) { var c = {}; c[this._dateElement] = this; return ((!date) ? new Date() : date.clone()).add(c); }; /** * Creates a new Date() and subtract this (Number) from the date based on the preceding date element function (eg. second|minute|hour|day|month|year). * Example

	// Undeclared Numbers must be wrapped with parentheses. Requirment of JavaScript.
	(3).days().ago();
	(6).months().ago();

	// Declared Number variables do not require parentheses. 
	var n = 6;
	n.months().ago();
	
* * @return {Date} A new Date instance */ $N.ago = $N.before = function (date) { var c = {}, s = (this._dateElement[this._dateElement.length-1] !== "s") ? this._dateElement + "s" : this._dateElement; c[s] = this * -1; return ((!date) ? new Date() : date.clone()).add(c); }; // Do NOT modify the following string tokens. These tokens are used to build dynamic functions. // All culture-specific strings can be found in the CultureInfo files. var dx = ("sunday monday tuesday wednesday thursday friday saturday").split(/\s/), mx = ("january february march april may june july august september october november december").split(/\s/), px = ("Millisecond Second Minute Hour Day Week Month Year Quarter Weekday").split(/\s/), pxf = ("Milliseconds Seconds Minutes Hours Date Week Month FullYear Quarter").split(/\s/), nth = ("final first second third fourth fifth").split(/\s/), de; /** * Returns an object literal of all the date parts. * Example

	var o = new Date().toObject();
	
	// { year: 2008, month: 4, week: 20, day: 13, hour: 18, minute: 9, second: 32, millisecond: 812 }
	
	// The object properties can be referenced directly from the object.
	
	alert(o.day);  // alerts "13"
	alert(o.year); // alerts "2008"
	
* * @return {Date} An object literal representing the original date object. */ $P.toObject = function () { var o = {}; for (var i = 0; i < px.length; i++) { if (this["get" + pxf[i]]) { o[px[i].toLowerCase()] = this["get" + pxf[i]](); } } return o; }; /** * Returns a date created from an object literal. Ignores the .week property if set in the config. * Example

	var o = new Date().toObject();
	
	return Date.fromObject(o); // will return the same date. 

	var o2 = {month: 1, day: 20, hour: 18}; // birthday party!
	Date.fromObject(o2);
	
* * @return {Date} An object literal representing the original date object. */ $D.fromObject = function(config) { config.week = null; return Date.today().set(config); }; // Create day name functions and abbreviated day name functions (eg. monday(), friday(), fri()). var df = function (n) { return function () { if (this._is) { this._is = false; return this.getDay() === n; } if (this._move) { this._move = null; } if (this._nth !== null) { // If the .second() function was called earlier, remove the _orient // from the date, and then continue. // This is required because 'second' can be used in two different context. // // Example // // Date.today().add(1).second(); // Date.march().second().monday(); // // Things get crazy with the following... // Date.march().add(1).second().second().monday(); // but it works!! // if (this._isSecond) { this.addSeconds(this._orient * -1); } // make sure we reset _isSecond this._isSecond = false; var ntemp = this._nth; this._nth = null; var temp = this.clone().moveToLastDayOfMonth(); this.moveToNthOccurrence(n, ntemp); if (this > temp) { throw new RangeError($D.getDayName(n) + " does not occur " + ntemp + " times in the month of " + $D.getMonthName(temp.getMonth()) + " " + temp.getFullYear() + "."); } return this; } return this.moveToDayOfWeek(n, this._orient); }; }; var sdf = function (n) { return function () { var t = $D.today(), shift = n - t.getDay(); if (n === 0 && Date.CultureInfo.firstDayOfWeek === 1 && t.getDay() !== 0) { shift = shift + 7; } return t.addDays(shift); }; }; // Create month name functions and abbreviated month name functions (eg. january(), march(), mar()). var month_instance_functions = function (n) { return function () { if (this._is) { this._is = false; return this.getMonth() === n; } return this.moveToMonth(n, this._orient); }; }; var month_static_functions = function (n) { return function () { return $D.today().set({ month: n, day: 1 }); }; }; var processTerms = function (names, staticFunc, instanceFunc) { for (var i = 0; i < names.length; i++) { // Create constant static Name variables. $D[names[i].toUpperCase()] = $D[names[i].toUpperCase().substring(0, 3)] = i; // Create Name functions. $D[names[i]] = $D[names[i].substring(0, 3)] = staticFunc(i); // Create Name instance functions. $P[names[i]] = $P[names[i].substring(0, 3)] = instanceFunc(i); } }; processTerms(dx, sdf, df); processTerms(mx, month_static_functions, month_instance_functions); // Create date element functions and plural date element functions used with Date (eg. day(), days(), months()). var ef = function (j) { return function () { // if the .second() function was called earlier, the _orient // has alread been added. Just return this and reset _isSecond. if (this._isSecond) { this._isSecond = false; return this; } if (this._same) { this._same = this._is = false; var o1 = this.toObject(), o2 = (arguments[0] || new Date()).toObject(), v = "", k = j.toLowerCase(); // the substr trick with -1 doesn't work in IE8 or less k = (k[k.length-1] === "s") ? k.substring(0,k.length-1) : k; for (var m = (px.length - 1); m > -1; m--) { v = px[m].toLowerCase(); if (o1[v] !== o2[v]) { return false; } if (k === v) { break; } } return true; } if (j.substring(j.length - 1) !== "s") { j += "s"; } if (this._move) { this._move = null; } return this["add" + j](this._orient); }; }; var nf = function (n) { return function () { this._dateElement = n; return this; }; }; for (var k = 0; k < px.length; k++) { de = px[k].toLowerCase(); if(de !== "weekday") { // Create date element functions and plural date element functions used with Date (eg. day(), days(), months()). $P[de] = $P[de + "s"] = ef(px[k]); // Create date element functions and plural date element functions used with Number (eg. day(), days(), months()). $N[de] = $N[de + "s"] = nf(de + "s"); } } $P._ss = ef("Second"); var nthfn = function (n) { return function (dayOfWeek) { if (this._same) { return this._ss(arguments[0]); } if (dayOfWeek || dayOfWeek === 0) { return this.moveToNthOccurrence(dayOfWeek, n); } this._nth = n; // if the operator is 'second' add the _orient, then deal with it later... if (n === 2 && (dayOfWeek === undefined || dayOfWeek === null)) { this._isSecond = true; return this.addSeconds(this._orient); } return this; }; }; for (var l = 0; l < nth.length; l++) { $P[nth[l]] = (l === 0) ? nthfn(-1) : nthfn(l); } }()); (function () { "use strict"; Date.Parsing = { Exception: function (s) { this.message = "Parse error at '" + s.substring(0, 10) + " ...'"; } }; var $P = Date.Parsing; var dayOffsets = { standard: [0,31,59,90,120,151,181,212,243,273,304,334], leap: [0,31,60,91,121,152,182,213,244,274,305,335] }; $P.isLeapYear = function(year) { return ((year % 4 === 0) && (year % 100 !== 0)) || (year % 400 === 0); }; var utils = { multiReplace : function (str, hash ) { var key; for (key in hash) { if (Object.prototype.hasOwnProperty.call(hash, key)) { var regex; if (typeof hash[key] === "function") { } else { regex = (hash[key] instanceof RegExp) ? hash[key] : new RegExp(hash[key], "g"); } str = str.replace(regex, key); } } return str; }, getDayOfYearFromWeek : function (obj) { var d, jan4, offset; obj.weekDay = (!obj.weekDay && obj.weekDay !== 0) ? 1 : obj.weekDay; d = new Date(obj.year, 0, 4); jan4 = d.getDay() === 0 ? 7 : d.getDay(); // JS is 0 indexed on Sunday. offset = jan4+3; obj.dayOfYear = ((obj.week * 7) + (obj.weekDay === 0 ? 7 : obj.weekDay))-offset; return obj; }, getDayOfYear : function (obj, dayOffset) { if (!obj.dayOfYear) { obj = utils.getDayOfYearFromWeek(obj); } for (var i=0;i <= dayOffset.length;i++) { if (obj.dayOfYear < dayOffset[i] || i === dayOffset.length) { obj.day = obj.day ? obj.day : (obj.dayOfYear - dayOffset[i-1]); break; } else { obj.month = i; } } return obj; }, adjustForTimeZone : function (obj, date) { var offset; if (obj.zone.toUpperCase() === "Z" || (obj.zone_hours === 0 && obj.zone_minutes === 0)) { // it's UTC/GML so work out the current timeszone offset offset = -date.getTimezoneOffset(); } else { offset = (obj.zone_hours*60) + (obj.zone_minutes || 0); if (obj.zone_sign === "+") { offset *= -1; } offset -= date.getTimezoneOffset(); } date.setMinutes(date.getMinutes()+offset); return date; }, setDefaults : function (obj) { obj.year = obj.year || Date.today().getFullYear(); obj.hours = obj.hours || 0; obj.minutes = obj.minutes || 0; obj.seconds = obj.seconds || 0; obj.milliseconds = obj.milliseconds || 0; if (!(!obj.month && (obj.week || obj.dayOfYear))) { // if we have a month, or if we don't but don't have the day calculation data obj.month = obj.month || 0; obj.day = obj.day || 1; } return obj; }, dataNum: function (data, mod, explict, postProcess) { var dataNum = data*1; if (mod) { if (postProcess) { return data ? mod(data)*1 : data; } else { return data ? mod(dataNum) : data; } } else if (!explict){ return data ? dataNum : data; } else { return (data && typeof data !== "undefined") ? dataNum : data; } }, timeDataProcess: function (obj) { var timeObj = {}; for (var x in obj.data) { if (obj.data.hasOwnProperty(x)) { timeObj[x] = obj.ignore[x] ? obj.data[x] : utils.dataNum(obj.data[x], obj.mods[x], obj.explict[x], obj.postProcess[x]); } } if (obj.data.secmins) { obj.data.secmins = obj.data.secmins.replace(",", ".") * 60; if (!timeObj.minutes) { timeObj.minutes = obj.data.secmins; } else if (!timeObj.seconds) { timeObj.seconds = obj.data.secmins; } delete obj.secmins; } return timeObj; }, buildTimeObjectFromData: function (data) { var time = utils.timeDataProcess({ data: { year : data[1], month : data[5], day : data[7], week : data[8], dayOfYear : data[10], hours : data[15], zone_hours : data[23], zone_minutes : data[24], zone : data[21], zone_sign : data[22], weekDay : data[9], minutes: data[16], seconds: data[19], milliseconds: data[20], secmins: data[18] }, mods: { month: function(data) { return data-1; }, weekDay: function (data) { data = Math.abs(data); return (data === 7 ? 0 : data); }, minutes: function (data) { return data.replace(":",""); }, seconds: function (data) { return Math.floor( (data.replace(":","").replace(",","."))*1 ); }, milliseconds: function (data) { return (data.replace(",",".")*1000); } }, postProcess: { minutes: true, seconds: true, milliseconds: true }, explict: { zone_hours: true, zone_minutes: true }, ignore: { zone: true, zone_sign: true, secmins: true } }); return time; }, addToHash: function (hash, keys, data) { keys = keys; data = data; var len = keys.length; for (var i = 0; i < len; i++) { hash[keys[i]] = data[i]; } return hash; }, combineRegex: function (r1, r2) { return new RegExp("(("+r1.source+")\\s("+r2.source+"))"); }, getDateNthString: function(add, last, inc){ if (add) { return Date.today().addDays(inc).toString("d"); } else if (last) { return Date.today().last()[inc]().toString("d"); } }, buildRegexData: function (array) { var arr = []; var len = array.length; for (var i=0; i < len; i++) { if (Object.prototype.toString.call(array[i]) === '[object Array]') { // oldIE compat version of Array.isArray arr.push(this.combineRegex(array[i][0], array[i][1])); } else { arr.push(array[i]); } } return arr; } }; $P.processTimeObject = function (obj) { var date, dayOffset; utils.setDefaults(obj); dayOffset = ($P.isLeapYear(obj.year)) ? dayOffsets.leap : dayOffsets.standard; if (!obj.month && (obj.week || obj.dayOfYear)) { utils.getDayOfYear(obj, dayOffset); } else { obj.dayOfYear = dayOffset[obj.month] + obj.day; } date = new Date(obj.year, obj.month, obj.day, obj.hours, obj.minutes, obj.seconds, obj.milliseconds); if (obj.zone) { utils.adjustForTimeZone(obj, date); // adjust (and calculate) for timezone } return date; }; $P.ISO = { regex : /^([\+-]?\d{4}(?!\d{2}\b))((-?)((0[1-9]|1[0-2])(\3([12]\d|0[1-9]|3[01]))?|W([0-4]\d|5[0-3])(-?[1-7])?|(00[1-9]|0[1-9]\d|[12]\d{2}|3([0-5]\d|6[1-6])))([T\s]((([01]\d|2[0-4])((:?)[0-5]\d)?|24\:?00)([\.,]\d+(?!:))?)?(\17[0-5]\d([\.,]\d+)?)?\s?([zZ]|([\+-])([01]\d|2[0-3]):?([0-5]\d)?)?)?)?$/, parse : function (s) { var time, data = s.match(this.regex); if (!data || !data.length) { return null; } time = utils.buildTimeObjectFromData(data); if (!time.year || (!time.year && (!time.month && !time.day) && (!time.week && !time.dayOfYear)) ) { return null; } return $P.processTimeObject(time); } }; $P.Numeric = { isNumeric: function (e){return!isNaN(parseFloat(e))&&isFinite(e);}, regex: /\b([0-1]?[0-9])([0-3]?[0-9])([0-2]?[0-9]?[0-9][0-9])\b/i, parse: function (s) { var data, i, time = {}, order = Date.CultureInfo.dateElementOrder.split(""); if (!(this.isNumeric(s)) || // if it's non-numeric OR (s[0] === "+" && s[0] === "-")) { // It's an arithmatic string (eg +/-1000) return null; } if (s.length < 5 && s.indexOf(".") < 0 && s.indexOf("/") < 0) { // assume it's just a year. time.year = s; return $P.processTimeObject(time); } data = s.match(this.regex); if (!data || !data.length) { return null; } for (i=0; i < order.length; i++) { switch(order[i]) { case "d": time.day = data[i+1]; break; case "m": time.month = (data[i+1]-1); break; case "y": time.year = data[i+1]; break; } } return $P.processTimeObject(time); } }; $P.Normalizer = { regexData: function () { var $R = Date.CultureInfo.regexPatterns; return utils.buildRegexData([ $R.tomorrow, $R.yesterday, [$R.past, $R.mon], [$R.past, $R.tue], [$R.past, $R.wed], [$R.past, $R.thu], [$R.past, $R.fri], [$R.past, $R.sat], [$R.past, $R.sun] ]); }, basicReplaceHash : function() { var $R = Date.CultureInfo.regexPatterns; return { "January": $R.jan.source, "February": $R.feb, "March": $R.mar, "April": $R.apr, "May": $R.may, "June": $R.jun, "July": $R.jul, "August": $R.aug, "September": $R.sep, "October": $R.oct, "November": $R.nov, "December": $R.dec, "": /\bat\b/gi, " ": /\s{2,}/, "am": $R.inTheMorning, "9am": $R.thisMorning, "pm": $R.inTheEvening, "7pm":$R.thisEvening }; }, keys : function(){ return [ utils.getDateNthString(true, false, 1), // tomorrow utils.getDateNthString(true, false, -1), // yesterday utils.getDateNthString(false, true, "monday"), //last mon utils.getDateNthString(false, true, "tuesday"), //last tues utils.getDateNthString(false, true, "wednesday"), //last wed utils.getDateNthString(false, true, "thursday"), //last thurs utils.getDateNthString(false, true, "friday"), //last fri utils.getDateNthString(false, true, "saturday"), //last sat utils.getDateNthString(false, true, "sunday") //last sun ]; }, buildRegexFunctions: function () { var $R = Date.CultureInfo.regexPatterns; var __ = Date.i18n.__; var tomorrowRE = new RegExp("(\\b\\d\\d?("+__("AM")+"|"+__("PM")+")? )("+$R.tomorrow.source.slice(1)+")", "i"); // adapted tomorrow regex for AM PM relative dates var todayRE = new RegExp($R.today.source + "(?!\\s*([+-]))\\b"); // today, but excludes the math operators (eg "today + 2h") this.replaceFuncs = [ [todayRE, function (full) { return (full.length > 1) ? Date.today().toString("d") : full; }], [tomorrowRE, function(full, m1) { var t = Date.today().addDays(1).toString("d"); return (t + " " + m1); }], [$R.amThisMorning, function(str, am){return am;}], [$R.pmThisEvening, function(str, pm){return pm;}] ]; }, buildReplaceData: function () { this.buildRegexFunctions(); this.replaceHash = utils.addToHash(this.basicReplaceHash(), this.keys(), this.regexData()); }, stringReplaceFuncs: function (s) { for (var i=0; i < this.replaceFuncs.length; i++) { s = s.replace(this.replaceFuncs[i][0], this.replaceFuncs[i][1]); } return s; }, parse: function (s) { s = this.stringReplaceFuncs(s); s = utils.multiReplace(s, this.replaceHash); try { var n = s.split(/([\s\-\.\,\/\x27]+)/); if (n.length === 3 && $P.Numeric.isNumeric(n[0]) && $P.Numeric.isNumeric(n[2]) && (n[2].length >= 4)) { // ok, so we're dealing with x/year. But that's not a full date. // This fixes wonky dateElementOrder parsing when set to dmy order. if (Date.CultureInfo.dateElementOrder[0] === "d") { s = "1/" + n[0] + "/" + n[2]; // set to 1st of month and normalize the seperator } } } catch (e) {} return s; } }; $P.Normalizer.buildReplaceData(); }()); (function () { var $P = Date.Parsing; var _ = $P.Operators = { // // Tokenizers // rtoken: function (r) { // regex token return function (s) { var mx = s.match(r); if (mx) { return ([ mx[0], s.substring(mx[0].length) ]); } else { throw new $P.Exception(s); } }; }, token: function () { // whitespace-eating token return function (s) { return _.rtoken(new RegExp("^\\s*" + s + "\\s*"))(s); }; }, stoken: function (s) { // string token return _.rtoken(new RegExp("^" + s)); }, // Atomic Operators until: function (p) { return function (s) { var qx = [], rx = null; while (s.length) { try { rx = p.call(this, s); } catch (e) { qx.push(rx[0]); s = rx[1]; continue; } break; } return [ qx, s ]; }; }, many: function (p) { return function (s) { var rx = [], r = null; while (s.length) { try { r = p.call(this, s); } catch (e) { return [ rx, s ]; } rx.push(r[0]); s = r[1]; } return [ rx, s ]; }; }, // generator operators -- see below optional: function (p) { return function (s) { var r = null; try { r = p.call(this, s); } catch (e) { return [ null, s ]; } return [ r[0], r[1] ]; }; }, not: function (p) { return function (s) { try { p.call(this, s); } catch (e) { return [null, s]; } throw new $P.Exception(s); }; }, ignore: function (p) { return p ? function (s) { var r = null; r = p.call(this, s); return [null, r[1]]; } : null; }, product: function () { var px = arguments[0], qx = Array.prototype.slice.call(arguments, 1), rx = []; for (var i = 0 ; i < px.length ; i++) { rx.push(_.each(px[i], qx)); } return rx; }, cache: function (rule) { var cache = {}, cache_length = 0, cache_keys = [], CACHE_MAX = Date.Config.CACHE_MAX || 100000, r = null; var cacheCheck = function () { if (cache_length === CACHE_MAX) { // kill several keys, don't want to have to do this all the time... for (var i=0; i < 10; i++) { var key = cache_keys.shift(); if (key) { delete cache[key]; cache_length--; } } } }; return function (s) { cacheCheck(); try { r = cache[s] = (cache[s] || rule.call(this, s)); } catch (e) { r = cache[s] = e; } cache_length++; cache_keys.push(s); if (r instanceof $P.Exception) { throw r; } else { return r; } }; }, // vector operators -- see below any: function () { var px = arguments; return function (s) { var r = null; for (var i = 0; i < px.length; i++) { if (px[i] == null) { continue; } try { r = (px[i].call(this, s)); } catch (e) { r = null; } if (r) { return r; } } throw new $P.Exception(s); }; }, each: function () { var px = arguments; return function (s) { var rx = [], r = null; for (var i = 0; i < px.length ; i++) { if (px[i] == null) { continue; } try { r = (px[i].call(this, s)); } catch (e) { throw new $P.Exception(s); } rx.push(r[0]); s = r[1]; } return [ rx, s]; }; }, all: function () { var px = arguments, _ = _; return _.each(_.optional(px)); }, // delimited operators sequence: function (px, d, c) { d = d || _.rtoken(/^\s*/); c = c || null; if (px.length === 1) { return px[0]; } return function (s) { var r = null, q = null; var rx = []; for (var i = 0; i < px.length ; i++) { try { r = px[i].call(this, s); } catch (e) { break; } rx.push(r[0]); try { q = d.call(this, r[1]); } catch (ex) { q = null; break; } s = q[1]; } if (!r) { throw new $P.Exception(s); } if (q) { throw new $P.Exception(q[1]); } if (c) { try { r = c.call(this, r[1]); } catch (ey) { throw new $P.Exception(r[1]); } } return [ rx, (r?r[1]:s) ]; }; }, // // Composite Operators // between: function (d1, p, d2) { d2 = d2 || d1; var _fn = _.each(_.ignore(d1), p, _.ignore(d2)); return function (s) { var rx = _fn.call(this, s); return [[rx[0][0], r[0][2]], rx[1]]; }; }, list: function (p, d, c) { d = d || _.rtoken(/^\s*/); c = c || null; return (p instanceof Array ? _.each(_.product(p.slice(0, -1), _.ignore(d)), p.slice(-1), _.ignore(c)) : _.each(_.many(_.each(p, _.ignore(d))), px, _.ignore(c))); }, set: function (px, d, c) { d = d || _.rtoken(/^\s*/); c = c || null; return function (s) { // r is the current match, best the current 'best' match // which means it parsed the most amount of input var r = null, p = null, q = null, rx = null, best = [[], s], last = false; // go through the rules in the given set for (var i = 0; i < px.length ; i++) { // last is a flag indicating whether this must be the last element // if there is only 1 element, then it MUST be the last one q = null; p = null; r = null; last = (px.length === 1); // first, we try simply to match the current pattern // if not, try the next pattern try { r = px[i].call(this, s); } catch (e) { continue; } // since we are matching against a set of elements, the first // thing to do is to add r[0] to matched elements rx = [[r[0]], r[1]]; // if we matched and there is still input to parse and // we don't already know this is the last element, // we're going to next check for the delimiter ... // if there's none, or if there's no input left to parse // than this must be the last element after all ... if (r[1].length > 0 && ! last) { try { q = d.call(this, r[1]); } catch (ex) { last = true; } } else { last = true; } // if we parsed the delimiter and now there's no more input, // that means we shouldn't have parsed the delimiter at all // so don't update r and mark this as the last element ... if (!last && q[1].length === 0) { last = true; } // so, if this isn't the last element, we're going to see if // we can get any more matches from the remaining (unmatched) // elements ... if (!last) { // build a list of the remaining rules we can match against, // i.e., all but the one we just matched against var qx = []; for (var j = 0; j < px.length ; j++) { if (i !== j) { qx.push(px[j]); } } // now invoke recursively set with the remaining input // note that we don't include the closing delimiter ... // we'll check for that ourselves at the end p = _.set(qx, d).call(this, q[1]); // if we got a non-empty set as a result ... // (otw rx already contains everything we want to match) if (p[0].length > 0) { // update current result, which is stored in rx ... // basically, pick up the remaining text from p[1] // and concat the result from p[0] so that we don't // get endless nesting ... rx[0] = rx[0].concat(p[0]); rx[1] = p[1]; } } // at this point, rx either contains the last matched element // or the entire matched set that starts with this element. // now we just check to see if this variation is better than // our best so far, in terms of how much of the input is parsed if (rx[1].length < best[1].length) { best = rx; } // if we've parsed all the input, then we're finished if (best[1].length === 0) { break; } } // so now we've either gone through all the patterns trying them // as the initial match; or we found one that parsed the entire // input string ... // if best has no matches, just return empty set ... if (best[0].length === 0) { return best; } // if a closing delimiter is provided, then we have to check it also if (c) { // we try this even if there is no remaining input because the pattern // may well be optional or match empty input ... try { q = c.call(this, best[1]); } catch (ey) { throw new $P.Exception(best[1]); } // it parsed ... be sure to update the best match remaining input best[1] = q[1]; } // if we're here, either there was no closing delimiter or we parsed it // so now we have the best match; just return it! return best; }; }, forward: function (gr, fname) { return function (s) { return gr[fname].call(this, s); }; }, // // Translation Operators // replace: function (rule, repl) { return function (s) { var r = rule.call(this, s); return [repl, r[1]]; }; }, process: function (rule, fn) { return function (s) { var r = rule.call(this, s); return [fn.call(this, r[0]), r[1]]; }; }, min: function (min, rule) { return function (s) { var rx = rule.call(this, s); if (rx[0].length < min) { throw new $P.Exception(s); } return rx; }; } }; // Generator Operators And Vector Operators // Generators are operators that have a signature of F(R) => R, // taking a given rule and returning another rule, such as // ignore, which parses a given rule and throws away the result. // Vector operators are those that have a signature of F(R1,R2,...) => R, // take a list of rules and returning a new rule, such as each. // Generator operators are converted (via the following _generator // function) into functions that can also take a list or array of rules // and return an array of new rules as though the function had been // called on each rule in turn (which is what actually happens). // This allows generators to be used with vector operators more easily. // Example: // each(ignore(foo, bar)) instead of each(ignore(foo), ignore(bar)) // This also turns generators into vector operators, which allows // constructs like: // not(cache(foo, bar)) var _generator = function (op) { function gen() { var args = null, rx = [], px, i; if (arguments.length > 1) { args = Array.prototype.slice.call(arguments); } else if (arguments[0] instanceof Array) { args = arguments[0]; } if (args) { px = args.shift(); if (px.length > 0) { args.unshift(px[i]); rx.push(op.apply(null, args)); args.shift(); return rx; } } else { return op.apply(null, arguments); } } return gen; }; var gx = "optional not ignore cache".split(/\s/); for (var i = 0 ; i < gx.length ; i++) { _[gx[i]] = _generator(_[gx[i]]); } var _vector = function (op) { return function () { if (arguments[0] instanceof Array) { return op.apply(null, arguments[0]); } else { return op.apply(null, arguments); } }; }; var vx = "each any all".split(/\s/); for (var j = 0 ; j < vx.length ; j++) { _[vx[j]] = _vector(_[vx[j]]); } }()); (function () { var $D = Date; var flattenAndCompact = function (ax) { var rx = []; for (var i = 0; i < ax.length; i++) { if (ax[i] instanceof Array) { rx = rx.concat(flattenAndCompact(ax[i])); } else { if (ax[i]) { rx.push(ax[i]); } } } return rx; }; var parseMeridian = function () { if (this.meridian && (this.hour || this.hour === 0)) { if (this.meridian === "a" && this.hour > 11 && Date.Config.strict24hr){ throw "Invalid hour and meridian combination"; } else if (this.meridian === "p" && this.hour < 12 && Date.Config.strict24hr){ throw "Invalid hour and meridian combination"; } else if (this.meridian === "p" && this.hour < 12) { this.hour = this.hour + 12; } else if (this.meridian === "a" && this.hour === 12) { this.hour = 0; } } }; var setDefaults = function () { var now = new Date(); if ((this.hour || this.minute) && (!this.month && !this.year && !this.day)) { this.day = now.getDate(); } if (!this.year) { this.year = now.getFullYear(); } if (!this.month && this.month !== 0) { this.month = now.getMonth(); } if (!this.day) { this.day = 1; } if (!this.hour) { this.hour = 0; } if (!this.minute) { this.minute = 0; } if (!this.second) { this.second = 0; } if (!this.millisecond) { this.millisecond = 0; } }; var finishUtils = { getToday: function () { if (this.now || "hour minute second".indexOf(this.unit) !== -1) { return new Date(); } else { return $D.today(); } }, setDaysFromWeekday: function (today, orient){ var gap; orient = orient || 1; this.unit = "day"; gap = ($D.getDayNumberFromName(this.weekday) - today.getDay()); this.days = gap ? ((gap + (orient * 7)) % 7) : (orient * 7); return this; }, setMonthsFromMonth: function (today, orient) { var gap; orient = orient || 1; this.unit = "month"; gap = (this.month - today.getMonth()); this.months = gap ? ((gap + (orient * 12)) % 12) : (orient * 12); this.month = null; return this; }, setDMYFromWeekday: function () { var d = Date[this.weekday](); this.day = d.getDate(); if (!this.month) { this.month = d.getMonth(); } this.year = d.getFullYear(); return this; }, setUnitValue: function (orient) { if (!this.value && this.operator && this.operator !== null && this[this.unit + "s"] && this[this.unit + "s"] !== null) { this[this.unit + "s"] = this[this.unit + "s"] + ((this.operator === "add") ? 1 : -1) + (this.value||0) * orient; } else if (this[this.unit + "s"] == null || this.operator != null) { if (!this.value) { this.value = 1; } this[this.unit + "s"] = this.value * orient; } }, generateDateFromWeeks: function () { var weekday = (this.weekday !== undefined) ? this.weekday : "today"; var d = Date[weekday]().addWeeks(this.weeks); if (this.now) { d.setTimeToNow(); } return d; } }; $D.Translator = { hour: function (s) { return function () { this.hour = Number(s); }; }, minute: function (s) { return function () { this.minute = Number(s); }; }, second: function (s) { return function () { this.second = Number(s); }; }, /* for ss.s format */ secondAndMillisecond: function (s) { return function () { var mx = s.match(/^([0-5][0-9])\.([0-9]{1,3})/); this.second = Number(mx[1]); this.millisecond = Number(mx[2]); }; }, meridian: function (s) { return function () { this.meridian = s.slice(0, 1).toLowerCase(); }; }, timezone: function (s) { return function () { var n = s.replace(/[^\d\+\-]/g, ""); if (n.length) { this.timezoneOffset = Number(n); } else { this.timezone = s.toLowerCase(); } }; }, day: function (x) { var s = x[0]; return function () { this.day = Number(s.match(/\d+/)[0]); if (this.day < 1) { throw "invalid day"; } }; }, month: function (s) { return function () { this.month = (s.length === 3) ? "jan feb mar apr may jun jul aug sep oct nov dec".indexOf(s)/4 : Number(s) - 1; if (this.month < 0) { throw "invalid month"; } }; }, year: function (s) { return function () { var n = Number(s); this.year = ((s.length > 2) ? n : (n + (((n + 2000) < Date.CultureInfo.twoDigitYearMax) ? 2000 : 1900))); }; }, rday: function (s) { return function () { switch (s) { case "yesterday": this.days = -1; break; case "tomorrow": this.days = 1; break; case "today": this.days = 0; break; case "now": this.days = 0; this.now = true; break; } }; }, finishExact: function (x) { var d; x = (x instanceof Array) ? x : [x]; for (var i = 0 ; i < x.length ; i++) { if (x[i]) { x[i].call(this); } } setDefaults.call(this); parseMeridian.call(this); if (this.day > $D.getDaysInMonth(this.year, this.month)) { throw new RangeError(this.day + " is not a valid value for days."); } d = new Date(this.year, this.month, this.day, this.hour, this.minute, this.second, this.millisecond); if (this.year < 100) { d.setFullYear(this.year); // means years less that 100 are process correctly. JS will parse it otherwise as 1900-1999. } if (this.timezone) { d.set({ timezone: this.timezone }); } else if (this.timezoneOffset) { d.set({ timezoneOffset: this.timezoneOffset }); } return d; }, finish: function (x) { var today, expression, orient, temp; x = (x instanceof Array) ? flattenAndCompact(x) : [ x ]; if (x.length === 0) { return null; } for (var i = 0 ; i < x.length ; i++) { if (typeof x[i] === "function") { x[i].call(this); } } if (this.now && !this.unit && !this.operator) { return new Date(); } else { today = finishUtils.getToday.call(this); } expression = !!(this.days && this.days !== null || this.orient || this.operator); orient = ((this.orient === "past" || this.operator === "subtract") ? -1 : 1); if (this.month && this.unit === "week") { this.value = this.month + 1; delete this.month; delete this.day; } if ((this.month || this.month === 0) && "year day hour minute second".indexOf(this.unit) !== -1) { if (!this.value) { this.value = this.month + 1; } this.month = null; expression = true; } if (!expression && this.weekday && !this.day && !this.days) { finishUtils.setDMYFromWeekday.call(this); } if (expression && this.weekday && this.unit !== "month" && this.unit !== "week") { finishUtils.setDaysFromWeekday.call(this, today, orient); } if (this.weekday && this.unit !== "week" && !this.day && !this.days) { temp = Date[this.weekday](); this.day = temp.getDate(); if (temp.getMonth() !== today.getMonth()) { this.month = temp.getMonth(); } } if (this.month && this.unit === "day" && this.operator) { if (!this.value) { this.value = (this.month + 1); } this.month = null; } if (this.value != null && this.month != null && this.year != null) { this.day = this.value * 1; } if (this.month && !this.day && this.value) { today.set({ day: this.value * 1 }); if (!expression) { this.day = this.value * 1; } } if (!this.month && this.value && this.unit === "month" && !this.now) { this.month = this.value; expression = true; } if (expression && (this.month || this.month === 0) && this.unit !== "year") { finishUtils.setMonthsFromMonth.call(this, today, orient); } if (!this.unit) { this.unit = "day"; } finishUtils.setUnitValue.call(this, orient); parseMeridian.call(this); if ((this.month || this.month === 0) && !this.day) { this.day = 1; } if (!this.orient && !this.operator && this.unit === "week" && this.value && !this.day && !this.month) { return Date.today().setWeek(this.value); } if (this.unit === "week" && this.weeks && !this.day && !this.month) { return finishUtils.generateDateFromWeeks.call(this); } if (expression && this.timezone && this.day && this.days) { this.day = this.days; } if (expression){ today.add(this); } else { today.set(this); } if (this.timezone) { this.timezone = this.timezone.toUpperCase(); var offset = $D.getTimezoneOffset(this.timezone); var timezone; if (today.hasDaylightSavingTime()) { // lets check that we're being sane with timezone setting timezone = $D.getTimezoneAbbreviation(offset, today.isDaylightSavingTime()); if (timezone !== this.timezone) { // bugger, we're in a place where things like EST vs EDT matters. if (today.isDaylightSavingTime()) { today.addHours(-1); } else { today.addHours(1); } } } today.setTimezoneOffset(offset); } return today; } }; }()); (function () { var $D = Date; $D.Grammar = {}; var _ = $D.Parsing.Operators, g = $D.Grammar, t = $D.Translator, _fn; // Allow rolling up into general purpose rules _fn = function () { return _.each(_.any.apply(null, arguments), _.not(g.ctoken2("timeContext"))); }; g.datePartDelimiter = _.rtoken(/^([\s\-\.\,\/\x27]+)/); g.timePartDelimiter = _.stoken(":"); g.whiteSpace = _.rtoken(/^\s*/); g.generalDelimiter = _.rtoken(/^(([\s\,]|at|@|on)+)/); var _C = {}; g.ctoken = function (keys) { var fn = _C[keys]; if (! fn) { var c = Date.CultureInfo.regexPatterns; var kx = keys.split(/\s+/), px = []; for (var i = 0; i < kx.length ; i++) { px.push(_.replace(_.rtoken(c[kx[i]]), kx[i])); } fn = _C[keys] = _.any.apply(null, px); } return fn; }; g.ctoken2 = function (key) { return _.rtoken(Date.CultureInfo.regexPatterns[key]); }; var cacheProcessRtoken = function (key, token, type, eachToken) { if (eachToken) { g[key] = _.cache(_.process(_.each(_.rtoken(token),_.optional(g.ctoken2(eachToken))), type)); } else { g[key] = _.cache(_.process(_.rtoken(token), type)); } }; var cacheProcessCtoken = function (token, type) { return _.cache(_.process(g.ctoken2(token), type)); }; var _F = {}; //function cache var _get = function (f) { _F[f] = (_F[f] || g.format(f)[0]); return _F[f]; }; g.allformats = function (fx) { var rx = []; if (fx instanceof Array) { for (var i = 0; i < fx.length; i++) { rx.push(_get(fx[i])); } } else { rx.push(_get(fx)); } return rx; }; g.formats = function (fx) { if (fx instanceof Array) { var rx = []; for (var i = 0 ; i < fx.length ; i++) { rx.push(_get(fx[i])); } return _.any.apply(null, rx); } else { return _get(fx); } }; var grammarFormats = { timeFormats: function(){ var i, RTokenKeys = [ "h", "hh", "H", "HH", "m", "mm", "s", "ss", "ss.s", "z", "zz" ], RToken = [ /^(0[0-9]|1[0-2]|[1-9])/, /^(0[0-9]|1[0-2])/, /^([0-1][0-9]|2[0-3]|[0-9])/, /^([0-1][0-9]|2[0-3])/, /^([0-5][0-9]|[0-9])/, /^[0-5][0-9]/, /^([0-5][0-9]|[0-9])/, /^[0-5][0-9]/, /^[0-5][0-9]\.[0-9]{1,3}/, /^((\+|\-)\s*\d\d\d\d)|((\+|\-)\d\d\:?\d\d)/, /^((\+|\-)\s*\d\d\d\d)|((\+|\-)\d\d\:?\d\d)/ ], tokens = [ t.hour, t.hour, t.hour, t.hour, t.minute, t.minute, t.second, t.second, t.secondAndMillisecond, t.timezone, t.timezone ]; for (i=0; i < RTokenKeys.length; i++) { cacheProcessRtoken(RTokenKeys[i], RToken[i], tokens[i]); } g.hms = _.cache(_.sequence([g.H, g.m, g.s], g.timePartDelimiter)); g.t = cacheProcessCtoken("shortMeridian", t.meridian); g.tt = cacheProcessCtoken("longMeridian", t.meridian); g.zzz = cacheProcessCtoken("timezone", t.timezone); g.timeSuffix = _.each(_.ignore(g.whiteSpace), _.set([ g.tt, g.zzz ])); g.time = _.each(_.optional(_.ignore(_.stoken("T"))), g.hms, g.timeSuffix); }, dateFormats: function () { // pre-loaded rules for different date part order preferences var _setfn = function () { return _.set(arguments, g.datePartDelimiter); }; var i, RTokenKeys = [ "d", "dd", "M", "MM", "y", "yy", "yyy", "yyyy" ], RToken = [ /^([0-2]\d|3[0-1]|\d)/, /^([0-2]\d|3[0-1])/, /^(1[0-2]|0\d|\d)/, /^(1[0-2]|0\d)/, /^(\d+)/, /^(\d\d)/, /^(\d\d?\d?\d?)/, /^(\d\d\d\d)/ ], tokens = [ t.day, t.day, t.month, t.month, t.year, t.year, t.year, t.year ], eachToken = [ "ordinalSuffix", "ordinalSuffix" ]; for (i=0; i < RTokenKeys.length; i++) { cacheProcessRtoken(RTokenKeys[i], RToken[i], tokens[i], eachToken[i]); } g.MMM = g.MMMM = _.cache(_.process(g.ctoken("jan feb mar apr may jun jul aug sep oct nov dec"), t.month)); g.ddd = g.dddd = _.cache(_.process(g.ctoken("sun mon tue wed thu fri sat"), function (s) { return function () { this.weekday = s; }; } )); g.day = _fn(g.d, g.dd); g.month = _fn(g.M, g.MMM); g.year = _fn(g.yyyy, g.yy); g.mdy = _setfn(g.ddd, g.month, g.day, g.year); g.ymd = _setfn(g.ddd, g.year, g.month, g.day); g.dmy = _setfn(g.ddd, g.day, g.month, g.year); g.date = function (s) { return ((g[Date.CultureInfo.dateElementOrder] || g.mdy).call(this, s)); }; }, relative: function () { // relative date / time expressions g.orientation = _.process(g.ctoken("past future"), function (s) { return function () { this.orient = s; }; } ); g.operator = _.process(g.ctoken("add subtract"), function (s) { return function () { this.operator = s; }; } ); g.rday = _.process(g.ctoken("yesterday tomorrow today now"), t.rday); g.unit = _.process(g.ctoken("second minute hour day week month year"), function (s) { return function () { this.unit = s; }; } ); } }; g.buildGrammarFormats = function () { // these need to be rebuilt every time the language changes. _C = {}; grammarFormats.timeFormats(); grammarFormats.dateFormats(); grammarFormats.relative(); g.value = _.process(_.rtoken(/^([-+]?\d+)?(st|nd|rd|th)?/), function (s) { return function () { this.value = s.replace(/\D/g, ""); }; } ); g.expression = _.set([g.rday, g.operator, g.value, g.unit, g.orientation, g.ddd, g.MMM ]); g.format = _.process(_.many( _.any( // translate format specifiers into grammar rules _.process( _.rtoken(/^(dd?d?d?(?!e)|MM?M?M?|yy?y?y?|hh?|HH?|mm?|ss?|tt?|zz?z?)/), function (fmt) { if (g[fmt]) { return g[fmt]; } else { throw $D.Parsing.Exception(fmt); } } ), // translate separator tokens into token rules _.process(_.rtoken(/^[^dMyhHmstz]+/), // all legal separators function (s) { return _.ignore(_.stoken(s)); } ) ) ), // construct the parser ... function (rules) { return _.process(_.each.apply(null, rules), t.finishExact); } ); // starting rule for general purpose grammar g._start = _.process(_.set([ g.date, g.time, g.expression ], g.generalDelimiter, g.whiteSpace), t.finish); }; g.buildGrammarFormats(); // parsing date format specifiers - ex: "h:m:s tt" // this little guy will generate a custom parser based // on the format string, ex: g.format("h:m:s tt") // check for these formats first g._formats = g.formats([ "\"yyyy-MM-ddTHH:mm:ssZ\"", "yyyy-MM-ddTHH:mm:ss.sz", "yyyy-MM-ddTHH:mm:ssZ", "yyyy-MM-ddTHH:mm:ssz", "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-ddTHH:mmZ", "yyyy-MM-ddTHH:mmz", "yyyy-MM-ddTHH:mm", "ddd, MMM dd, yyyy H:mm:ss tt", "ddd MMM d yyyy HH:mm:ss zzz", "MMddyyyy", "ddMMyyyy", "Mddyyyy", "ddMyyyy", "Mdyyyy", "dMyyyy", "yyyy", "Mdyy", "dMyy", "d" ]); // real starting rule: tries selected formats first, // then general purpose rule g.start = function (s) { try { var r = g._formats.call({}, s); if (r[1].length === 0) { return r; } } catch (e) {} return g._start.call({}, s); }; }()); (function () { var $D = Date; /** * @desc Converts the specified string value into its JavaScript Date equivalent using CultureInfo specific format information. * * Example

	///////////
	// Dates //
	///////////

	// 15-Oct-2004
	var d1 = Date.parse("10/15/2004");

	// 15-Oct-2004
	var d1 = Date.parse("15-Oct-2004");

	// 15-Oct-2004
	var d1 = Date.parse("2004.10.15");

	//Fri Oct 15, 2004
	var d1 = Date.parse("Fri Oct 15, 2004");

	///////////
	// Times //
	///////////

	// Today at 10 PM.
	var d1 = Date.parse("10 PM");

	// Today at 10:30 PM.
	var d1 = Date.parse("10:30 P.M.");

	// Today at 6 AM.
	var d1 = Date.parse("06am");

	/////////////////////
	// Dates and Times //
	/////////////////////

	// 8-July-2004 @ 10:30 PM
	var d1 = Date.parse("July 8th, 2004, 10:30 PM");

	// 1-July-2004 @ 10:30 PM
	var d1 = Date.parse("2004-07-01T22:30:00");

	////////////////////
	// Relative Dates //
	////////////////////

	// Returns today's date. The string "today" is culture specific.
	var d1 = Date.parse("today");

	// Returns yesterday's date. The string "yesterday" is culture specific.
	var d1 = Date.parse("yesterday");

	// Returns the date of the next thursday.
	var d1 = Date.parse("Next thursday");

	// Returns the date of the most previous monday.
	var d1 = Date.parse("last monday");

	// Returns today's day + one year.
	var d1 = Date.parse("next year");

	///////////////
	// Date Math //
	///////////////

	// Today + 2 days
	var d1 = Date.parse("t+2");

	// Today + 2 days
	var d1 = Date.parse("today + 2 days");

	// Today + 3 months
	var d1 = Date.parse("t+3m");

	// Today - 1 year
	var d1 = Date.parse("today - 1 year");

	// Today - 1 year
	var d1 = Date.parse("t-1y"); 


	/////////////////////////////
	// Partial Dates and Times //
	/////////////////////////////

	// July 15th of this year.
	var d1 = Date.parse("July 15");

	// 15th day of current day and year.
	var d1 = Date.parse("15");

	// July 1st of current year at 10pm.
	var d1 = Date.parse("7/1 10pm");
	
* * @param {String} The string value to convert into a Date object [Required] * @return {Date} A Date object or null if the string cannot be converted into a Date. */ var parseUtils = { removeOrds: function (s) { ords = s.match(/\b(\d+)(?:st|nd|rd|th)\b/); // find ordinal matches s = ((ords && ords.length === 2) ? s.replace(ords[0], ords[1]) : s); return s; }, grammarParser: function (s) { var r = null; try { r = $D.Grammar.start.call({}, s.replace(/^\s*(\S*(\s+\S+)*)\s*$/, "$1")); } catch (e) { return null; } return ((r[1].length === 0) ? r[0] : null); }, nativeFallback: function(s) { var t; try { // ok we haven't parsed it, last ditch attempt with the built-in parser. t = Date._parse(s); return (t || t === 0) ? new Date(t) : null; } catch (e) { return null; } } }; function parse (s) { var d; if (!s) { return null; } if (s instanceof Date) { return s.clone(); } if (s.length >= 4 && s.charAt(0) !== "0" && s.charAt(0) !== "+"&& s.charAt(0) !== "-") { // ie: 2004 will pass, 0800 won't. // Start with specific formats d = $D.Parsing.ISO.parse(s) || $D.Parsing.Numeric.parse(s); } if (d instanceof Date && !isNaN(d.getTime())) { return d; } else { // find ordinal dates (1st, 3rd, 8th, etc and remove them as they cause parsing issues) s = $D.Parsing.Normalizer.parse(parseUtils.removeOrds(s)); d = parseUtils.grammarParser(s); if (d !== null) { return d; } else { return parseUtils.nativeFallback(s); } } } if (!$D._parse) { $D._parse = $D.parse; } $D.parse = parse; Date.getParseFunction = function (fx) { var fns = Date.Grammar.allformats(fx); return function (s) { var r = null; for (var i = 0; i < fns.length; i++) { try { r = fns[i].call({}, s); } catch (e) { continue; } if (r[1].length === 0) { return r[0]; } } return null; }; }; /** * Converts the specified string value into its JavaScript Date equivalent using the specified format {String} or formats {Array} and the CultureInfo specific format information. * The format of the string value must match one of the supplied formats exactly. * * Example

	// 15-Oct-2004
	var d1 = Date.parseExact("10/15/2004", "M/d/yyyy");

	// 15-Oct-2004
	var d1 = Date.parse("15-Oct-2004", "M-ddd-yyyy");

	// 15-Oct-2004
	var d1 = Date.parse("2004.10.15", "yyyy.MM.dd");

	// Multiple formats
	var d1 = Date.parseExact("10/15/2004", ["M/d/yyyy", "MMMM d, yyyy"]);
	
* * @param {String} The string value to convert into a Date object [Required]. * @param {Object} The expected format {String} or an array of expected formats {Array} of the date string [Required]. * @return {Date} A Date object or null if the string cannot be converted into a Date. */ $D.parseExact = function (s, fx) { return $D.getParseFunction(fx)(s); }; }()); (function () { var $D = Date, $P = $D.prototype, // $C = $D.CultureInfo, // not used atm p = function (s, l) { if (!l) { l = 2; } return ("000" + s).slice(l * -1); }; /** * Converts a PHP format string to Java/.NET format string. * A PHP format string can be used with ._format or .format. * A Java/.NET format string can be used with .toString(). * The .parseExact function will only accept a Java/.NET format string * * Example * var f1 = "%m/%d/%y" * var f2 = Date.normalizeFormat(f1); // "MM/dd/yy" * * new Date().format(f1); // "04/13/08" * new Date()._format(f1); // "04/13/08" * new Date().toString(f2); // "04/13/08" * * var date = Date.parseExact("04/13/08", f2); // Sun Apr 13 2008 * * @param {String} A PHP format string consisting of one or more format spcifiers. * @return {String} The PHP format converted to a Java/.NET format string. */ var normalizerSubstitutions = { "d" : "dd", "%d": "dd", "D" : "ddd", "%a": "ddd", "j" : "dddd", "l" : "dddd", "%A": "dddd", "S" : "S", "F" : "MMMM", "%B": "MMMM", "m" : "MM", "%m": "MM", "M" : "MMM", "%b": "MMM", "%h": "MMM", "n" : "M", "Y" : "yyyy", "%Y": "yyyy", "y" : "yy", "%y": "yy", "g" : "h", "%I": "h", "G" : "H", "h" : "hh", "H" : "HH", "%H": "HH", "i" : "mm", "%M": "mm", "s" : "ss", "%S": "ss", "%r": "hh:mm tt", "%R": "H:mm", "%T": "H:mm:ss", "%X": "t", "%x": "d", "%e": "d", "%D": "MM/dd/yy", "%n": "\\n", "%t": "\\t", "e" : "z", "T" : "z", "%z": "z", "%Z": "z", "Z" : "ZZ", "N" : "u", "w" : "u", "%w": "u", "W" : "W", "%V": "W" }; var normalizer = { substitutes: function (m) { return normalizerSubstitutions[m]; }, interpreted: function (m, x) { var y; switch (m) { case "%u": return x.getDay() + 1; case "z": return x.getOrdinalNumber(); case "%j": return p(x.getOrdinalNumber(), 3); case "%U": var d1 = x.clone().set({month: 0, day: 1}).addDays(-1).moveToDayOfWeek(0), d2 = x.clone().addDays(1).moveToDayOfWeek(0, -1); return (d2 < d1) ? "00" : p((d2.getOrdinalNumber() - d1.getOrdinalNumber()) / 7 + 1); case "%W": return p(x.getWeek()); case "t": return $D.getDaysInMonth(x.getFullYear(), x.getMonth()); case "o": case "%G": return x.setWeek(x.getISOWeek()).toString("yyyy"); case "%g": return x._format("%G").slice(-2); case "a": case "%p": return t("tt").toLowerCase(); case "A": return t("tt").toUpperCase(); case "u": return p(x.getMilliseconds(), 3); case "I": return (x.isDaylightSavingTime()) ? 1 : 0; case "O": return x.getUTCOffset(); case "P": y = x.getUTCOffset(); return y.substring(0, y.length - 2) + ":" + y.substring(y.length - 2); case "B": var now = new Date(); return Math.floor(((now.getHours() * 3600) + (now.getMinutes() * 60) + now.getSeconds() + (now.getTimezoneOffset() + 60) * 60) / 86.4); case "c": return x.toISOString().replace(/\"/g, ""); case "U": return $D.strtotime("now"); case "%c": return t("d") + " " + t("t"); case "%C": return Math.floor(x.getFullYear() / 100 + 1); } }, shouldOverrideDefaults: function (m) { switch (m) { case "%e": return true; default: return false; } }, parse: function (m, context) { var formatString, c = context || new Date(); formatString = normalizer.substitutes(m); if (formatString) { return formatString; } formatString = normalizer.interpreted(m, c); if (formatString) { return formatString; } else { return m; } } }; $D.normalizeFormat = function (format, context) { return format.replace(/(%|\\)?.|%%/g, function(t){ return normalizer.parse(t, context); }); }; /** * Format a local Unix timestamp according to locale settings * * Example: * Date.strftime("%m/%d/%y", new Date()); // "04/13/08" * Date.strftime("c", "2008-04-13T17:52:03Z"); // "04/13/08" * * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @param {Number|String} The number representing the number of seconds that have elapsed since January 1, 1970 (local time). * @return {String} A string representation of the current Date object. */ $D.strftime = function (format, time) { var d = Date.parse(time); return d._format(format); }; /** * Parse any textual datetime description into a Unix timestamp. * A Unix timestamp is the number of seconds that have elapsed since January 1, 1970 (midnight UTC/GMT). * * Example: * Date.strtotime("04/13/08"); // 1208044800 * Date.strtotime("1970-01-01T00:00:00Z"); // 0 * * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @param {Object} A string or date object. * @return {String} A string representation of the current Date object. */ $D.strtotime = function (time) { var d = $D.parse(time); return Math.round($D.UTC(d.getUTCFullYear(), d.getUTCMonth(), d.getUTCDate(), d.getUTCHours(), d.getUTCMinutes(), d.getUTCSeconds(), d.getUTCMilliseconds()) / 1000); }; /** * Converts the value of the current Date object to its equivalent string representation using a PHP/Unix style of date format specifiers. * Format Specifiers * Format Description Example * ------ --------------------------------------------------------------------------- ----------------------- * %a abbreviated weekday name according to the current localed "Mon" through "Sun" * %A full weekday name according to the current localed "Sunday" through "Saturday" * %b abbreviated month name according to the current localed "Jan" through "Dec" * %B full month name according to the current locale "January" through "December" * %c preferred date and time representation for the current locale "4/13/2008 12:33 PM" * %C century number (the year divided by 100 and truncated to an integer) "00" to "99" * %d day of the month as a decimal number "01" to "31" * %D same as %m/%d/%y "04/13/08" * %e day of the month as a decimal number, a single digit is preceded by a space "1" to "31" * %g like %G, but without the century "08" * %G The 4-digit year corresponding to the ISO week number (see %V). "2008" * This has the same format and value as %Y, except that if the ISO week number * belongs to the previous or next year, that year is used instead. * %h same as %b "Jan" through "Dec" * %H hour as a decimal number using a 24-hour clock. "00" to "23" * %I hour as a decimal number using a 12-hour clock. "01" to "12" * %j day of the year as a decimal number. "001" to "366" * %m month as a decimal number. "01" to "12" * %M minute as a decimal number. "00" to "59" * %n newline character "\n" * %p either "am" or "pm" according to the given time value, or the "am" or "pm" * corresponding strings for the current locale. * %r time in a.m. and p.m. notation "8:44 PM" * %R time in 24 hour notation "20:44" * %S second as a decimal number "00" to "59" * %t tab character "\t" * %T current time, equal to %H:%M:%S "12:49:11" * %u weekday as a decimal number ["1", "7"], with "1" representing Monday "1" to "7" * %U week number of the current year as a decimal number, starting with the "0" to ("52" or "53") * first Sunday as the first day of the first week * %V The ISO 8601:1988 week number of the current year as a decimal number, "00" to ("52" or "53") * range 01 to 53, where week 1 is the first week that has at least 4 days * in the current year, and with Monday as the first day of the week. * (Use %G or %g for the year component that corresponds to the week number * for the specified timestamp.) * %W week number of the current year as a decimal number, starting with the "00" to ("52" or "53") * first Monday as the first day of the first week * %w day of the week as a decimal, Sunday being "0" "0" to "6" * %x preferred date representation for the current locale without the time "4/13/2008" * %X preferred time representation for the current locale without the date "12:53:05" * %y year as a decimal number without a century "00" "99" * %Y year as a decimal number including the century "2008" * %Z time zone or name or abbreviation "UTC", "EST", "PST" * %z same as %Z * %% a literal "%" characters "%" * d Day of the month, 2 digits with leading zeros "01" to "31" * D A textual representation of a day, three letters "Mon" through "Sun" * j Day of the month without leading zeros "1" to "31" * l A full textual representation of the day of the week (lowercase "L") "Sunday" through "Saturday" * N ISO-8601 numeric representation of the day of the week (added in PHP 5.1.0) "1" (for Monday) through "7" (for Sunday) * S English ordinal suffix for the day of the month, 2 characters "st", "nd", "rd" or "th". Works well with j * w Numeric representation of the day of the week "0" (for Sunday) through "6" (for Saturday) * z The day of the year (starting from "0") "0" through "365" * W ISO-8601 week number of year, weeks starting on Monday "00" to ("52" or "53") * F A full textual representation of a month, such as January or March "January" through "December" * m Numeric representation of a month, with leading zeros "01" through "12" * M A short textual representation of a month, three letters "Jan" through "Dec" * n Numeric representation of a month, without leading zeros "1" through "12" * t Number of days in the given month "28" through "31" * L Whether it's a leap year "1" if it is a leap year, "0" otherwise * o ISO-8601 year number. This has the same value as Y, except that if the "2008" * ISO week number (W) belongs to the previous or next year, that year * is used instead. * Y A full numeric representation of a year, 4 digits "2008" * y A two digit representation of a year "08" * a Lowercase Ante meridiem and Post meridiem "am" or "pm" * A Uppercase Ante meridiem and Post meridiem "AM" or "PM" * B Swatch Internet time "000" through "999" * g 12-hour format of an hour without leading zeros "1" through "12" * G 24-hour format of an hour without leading zeros "0" through "23" * h 12-hour format of an hour with leading zeros "01" through "12" * H 24-hour format of an hour with leading zeros "00" through "23" * i Minutes with leading zeros "00" to "59" * s Seconds, with leading zeros "00" through "59" * u Milliseconds "54321" * e Timezone identifier "UTC", "EST", "PST" * I Whether or not the date is in daylight saving time (uppercase i) "1" if Daylight Saving Time, "0" otherwise * O Difference to Greenwich time (GMT) in hours "+0200", "-0600" * P Difference to Greenwich time (GMT) with colon between hours and minutes "+02:00", "-06:00" * T Timezone abbreviation "UTC", "EST", "PST" * Z Timezone offset in seconds. The offset for timezones west of UTC is "-43200" through "50400" * always negative, and for those east of UTC is always positive. * c ISO 8601 date "2004-02-12T15:19:21+00:00" * r RFC 2822 formatted date "Thu, 21 Dec 2000 16:01:07 +0200" * U Seconds since the Unix Epoch (January 1 1970 00:00:00 GMT) "0" * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @return {String} A string representation of the current Date object. */ var formatReplace = function (context) { return function (m) { var formatString, override = false; if (m.charAt(0) === "\\" || m.substring(0, 2) === "%%") { return m.replace("\\", "").replace("%%", "%"); } override = normalizer.shouldOverrideDefaults(m); formatString = $D.normalizeFormat(m, context); if (formatString) { return context.toString(formatString, override); } }; }; $P._format = function (format) { var formatter = formatReplace(this); if (!format) { return this._toString(); } else { return format.replace(/(%|\\)?.|%%/g, formatter); } }; if (!$P.format) { $P.format = $P._format; } }()); (function () { "use strict"; var gFn = function (attr) { return function () { return this[attr]; }; }; var sFn = function (attr) { return function (val) { this[attr] = val; return this; }; }; var attrs = ["years", "months", "days", "hours", "minutes", "seconds", "milliseconds"]; var addSetFuncs = function (context, attrs) { for (var i = 0; i < attrs.length ; i++) { var $a = attrs[i], $b = $a.slice(0, 1).toUpperCase() + $a.slice(1); context.prototype[$a] = 0; context.prototype["get" + $b] = gFn($a); context.prototype["set" + $b] = sFn($a); } }; /** * new TimeSpan(milliseconds); * new TimeSpan(days, hours, minutes, seconds); * new TimeSpan(days, hours, minutes, seconds, milliseconds); */ var TimeSpan = function (days, hours, minutes, seconds, milliseconds) { if (arguments.length === 1 && typeof days === "number") { var orient = (days < 0) ? -1 : +1; var millsLeft = Math.abs(days); this.setDays(Math.floor(millsLeft / 86400000) * orient); millsLeft = millsLeft % 86400000; this.setHours(Math.floor(millsLeft / 3600000) * orient); millsLeft = millsLeft % 3600000; this.setMinutes(Math.floor(millsLeft / 60000) * orient); millsLeft = millsLeft % 60000; this.setSeconds(Math.floor(millsLeft / 1000) * orient); millsLeft = millsLeft % 1000; this.setMilliseconds(millsLeft * orient); } else { this.set(days, hours, minutes, seconds, milliseconds); } this.getTotalMilliseconds = function () { return (this.getDays() * 86400000) + (this.getHours() * 3600000) + (this.getMinutes() * 60000) + (this.getSeconds() * 1000); }; this.compareTo = function (time) { var t1 = new Date(1970, 1, 1, this.getHours(), this.getMinutes(), this.getSeconds()), t2; if (time === null) { t2 = new Date(1970, 1, 1, 0, 0, 0); } else { t2 = new Date(1970, 1, 1, time.getHours(), time.getMinutes(), time.getSeconds()); } return (t1 < t2) ? -1 : (t1 > t2) ? 1 : 0; }; this.equals = function (time) { return (this.compareTo(time) === 0); }; this.add = function (time) { return (time === null) ? this : this.addSeconds(time.getTotalMilliseconds() / 1000); }; this.subtract = function (time) { return (time === null) ? this : this.addSeconds(-time.getTotalMilliseconds() / 1000); }; this.addDays = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 86400000)); }; this.addHours = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 3600000)); }; this.addMinutes = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 60000)); }; this.addSeconds = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 1000)); }; this.addMilliseconds = function (n) { return new TimeSpan(this.getTotalMilliseconds() + n); }; this.get12HourHour = function () { return (this.getHours() > 12) ? this.getHours() - 12 : (this.getHours() === 0) ? 12 : this.getHours(); }; this.getDesignator = function () { return (this.getHours() < 12) ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator; }; this.toString = function (format) { this._toString = function () { if (this.getDays() !== null && this.getDays() > 0) { return this.getDays() + "." + this.getHours() + ":" + this.p(this.getMinutes()) + ":" + this.p(this.getSeconds()); } else { return this.getHours() + ":" + this.p(this.getMinutes()) + ":" + this.p(this.getSeconds()); } }; this.p = function (s) { return (s.toString().length < 2) ? "0" + s : s; }; var me = this; return format ? format.replace(/dd?|HH?|hh?|mm?|ss?|tt?/g, function (format) { switch (format) { case "d": return me.getDays(); case "dd": return me.p(me.getDays()); case "H": return me.getHours(); case "HH": return me.p(me.getHours()); case "h": return me.get12HourHour(); case "hh": return me.p(me.get12HourHour()); case "m": return me.getMinutes(); case "mm": return me.p(me.getMinutes()); case "s": return me.getSeconds(); case "ss": return me.p(me.getSeconds()); case "t": return ((me.getHours() < 12) ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator).substring(0, 1); case "tt": return (me.getHours() < 12) ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator; } } ) : this._toString(); }; return this; }; addSetFuncs(TimeSpan, attrs.slice(2)); TimeSpan.prototype.set = function (days, hours, minutes, seconds, milliseconds){ this.setDays(days || this.getDays()); this.setHours(hours || this.getHours()); this.setMinutes(minutes || this.getMinutes()); this.setSeconds(seconds || this.getSeconds()); this.setMilliseconds(milliseconds || this.getMilliseconds()); }; /** * Gets the time of day for this date instances. * @return {TimeSpan} TimeSpan */ Date.prototype.getTimeOfDay = function () { return new TimeSpan(0, this.getHours(), this.getMinutes(), this.getSeconds(), this.getMilliseconds()); }; Date.TimeSpan = TimeSpan; if (typeof window !== "undefined" ) { // keeping API compatible for v1.x window.TimeSpan = TimeSpan; } }()); (function () { "use strict"; var attrs = ["years", "months", "days", "hours", "minutes", "seconds", "milliseconds"]; var gFn = function (attr) { return function () { return this[attr]; }; }; var sFn = function (attr) { return function (val) { this[attr] = val; return this; }; }; var addSetFuncs = function (context, attrs) { for (var i = 0; i < attrs.length ; i++) { var $a = attrs[i], $b = $a.slice(0, 1).toUpperCase() + $a.slice(1); context.prototype[$a] = 0; context.prototype["get" + $b] = gFn($a); context.prototype["set" + $b] = sFn($a); } }; var setMonthsAndYears = function (orient, d1, d2, context) { function inc() { d1.addMonths(-orient); context.months++; if (context.months === 12) { context.years++; context.months = 0; } } if (orient === +1) { while (d1 > d2) { inc(); } } else { while (d1 < d2) { inc(); } } context.months--; context.months *= orient; context.years *= orient; }; var adjustForDST = function(orient, startDate, endDate) { var hasDSTMismatch = (false === (startDate.isDaylightSavingTime() === endDate.isDaylightSavingTime())); if (hasDSTMismatch && orient === 1) { startDate.addHours(-1); } else if (hasDSTMismatch) { startDate.addHours(1); } }; /** * TimePeriod(startDate, endDate); * TimePeriod(years, months, days, hours, minutes, seconds, milliseconds); */ var TimePeriod = function (years, months, days, hours, minutes, seconds, milliseconds) { if (arguments.length === 7) { this.set(years, months, days, hours, minutes, seconds, milliseconds); } else if (arguments.length === 2 && arguments[0] instanceof Date && arguments[1] instanceof Date) { var startDate = arguments[0].clone(); var endDate = arguments[1].clone(); var orient = (startDate > endDate) ? +1 : -1; this.dates = { start: arguments[0].clone(), end: arguments[1].clone() }; setMonthsAndYears(orient, startDate, endDate, this); adjustForDST(orient, startDate, endDate); // // TODO - adjust for DST var diff = endDate - startDate; if (diff !== 0) { var ts = new TimeSpan(diff); this.set(this.years, this.months, ts.getDays(), ts.getHours(), ts.getMinutes(), ts.getSeconds(), ts.getMilliseconds()); } } return this; }; // create all the set functions. addSetFuncs(TimePeriod, attrs); TimePeriod.prototype.set = function (years, months, days, hours, minutes, seconds, milliseconds){ this.setYears(years || this.getYears()); this.setMonths(months || this.getMonths()); this.setDays(days || this.getDays()); this.setHours(hours || this.getHours()); this.setMinutes(minutes || this.getMinutes()); this.setSeconds(seconds || this.getSeconds()); this.setMilliseconds(milliseconds || this.getMilliseconds()); }; Date.TimePeriod = TimePeriod; if (typeof window !== "undefined") { // keeping API compatible for v1.x window.TimePeriod = TimePeriod; } }()); ================================================ FILE: build/date-kn-IN.js ================================================ /** * @overview datejs * @version 1.0.0-rc3 * @author Gregory Wild-Smith * @copyright 2015 Gregory Wild-Smith * @license MIT * @homepage https://github.com/abritinthebay/datejs */ /* * DateJS Culture String File * Country Code: kn-IN * Name: Kannada (India) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["kn-IN"] = { "name": "kn-IN", "englishName": "Kannada (India)", "nativeName": "ಕನ್ನಡ (ಭಾರತ)", "Sunday": "ಭಾನುವಾರ", "Monday": "ಸೋಮವಾರ", "Tuesday": "ಮಂಗಳವಾರ", "Wednesday": "ಬುಧವಾರ", "Thursday": "ಗುರುವಾರ", "Friday": "ಶುಕ್ರವಾರ", "Saturday": "ಶನಿವಾರ", "Sun": "ಭಾನು.", "Mon": "ಸೋಮ.", "Tue": "ಮಂಗಳ.", "Wed": "ಬುಧ.", "Thu": "ಗುರು.", "Fri": "ಶುಕ್ರ.", "Sat": "ಶನಿ.", "Su": "ರ", "Mo": "ಸ", "Tu": "ಮ", "We": "ಬ", "Th": "ಗ", "Fr": "ಶ", "Sa": "ಶ", "S_Sun_Initial": "ರ", "M_Mon_Initial": "ಸ", "T_Tue_Initial": "ಮ", "W_Wed_Initial": "ಬ", "T_Thu_Initial": "ಗ", "F_Fri_Initial": "ಶ", "S_Sat_Initial": "ಶ", "January": "ಜನವರಿ", "February": "ಫೆಬ್ರವರಿ", "March": "ಮಾರ್ಚ್", "April": "ಎಪ್ರಿಲ್", "May": "ಮೇ", "June": "ಜೂನ್", "July": "ಜುಲೈ", "August": "ಆಗಸ್ಟ್", "September": "ಸೆಪ್ಟಂಬರ್", "October": "ಅಕ್ಟೋಬರ್", "November": "ನವೆಂಬರ್", "December": "ಡಿಸೆಂಬರ್", "Jan_Abbr": "ಜನವರಿ", "Feb_Abbr": "ಫೆಬ್ರವರಿ", "Mar_Abbr": "ಮಾರ್ಚ್", "Apr_Abbr": "ಎಪ್ರಿಲ್", "May_Abbr": "ಮೇ", "Jun_Abbr": "ಜೂನ್", "Jul_Abbr": "ಜುಲೈ", "Aug_Abbr": "ಆಗಸ್ಟ್", "Sep_Abbr": "ಸೆಪ್ಟಂಬರ್", "Oct_Abbr": "ಅಕ್ಟೋಬರ್", "Nov_Abbr": "ನವೆಂಬರ್", "Dec_Abbr": "ಡಿಸೆಂಬರ್", "AM": "ಪೂರ್ವಾಹ್ನ", "PM": "ಅಪರಾಹ್ನ", "firstDayOfWeek": 1, "twoDigitYearMax": 2029, "mdy": "dmy", "M/d/yyyy": "dd-MM-yy", "dddd, MMMM dd, yyyy": "dd MMMM yyyy", "h:mm tt": "HH:mm", "h:mm:ss tt": "HH:mm:ss", "dddd, MMMM dd, yyyy h:mm:ss tt": "dd MMMM yyyy HH:mm:ss", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "dd MMMM", "MMMM, yyyy": "MMMM, yyyy", "/jan(uary)?/": "ಜನವರಿ", "/feb(ruary)?/": "ಫೆಬ್ರವರಿ", "/mar(ch)?/": "ಮಾರ್ಚ್", "/apr(il)?/": "ಎಪ್ರಿಲ್", "/may/": "ಮೇ", "/jun(e)?/": "ಜೂನ್", "/jul(y)?/": "ಜುಲೈ", "/aug(ust)?/": "ಆಗಸ್ಟ್", "/sep(t(ember)?)?/": "ಸೆಪ್ಟಂಬರ್", "/oct(ober)?/": "ಅಕ್ಟೋಬರ್", "/nov(ember)?/": "ನವೆಂಬರ್", "/dec(ember)?/": "ಡಿಸೆಂಬರ್", "/^su(n(day)?)?/": "^ರ(ಾನು(.(ವಾರ)?)?)?", "/^mo(n(day)?)?/": "^ಸ(ೋಮ(.(ವಾರ)?)?)?", "/^tu(e(s(day)?)?)?/": "^ಮ(ಂಗಳ(.(ವಾರ)?)?)?", "/^we(d(nesday)?)?/": "^ಬ(ುಧ(.(ವಾರ)?)?)?", "/^th(u(r(s(day)?)?)?)?/": "^ಗ(ುರು(.(ವಾರ)?)?)?", "/^fr(i(day)?)?/": "^ಶ(ುಕ್ರ(.(ವಾರ)?)?)?", "/^sa(t(urday)?)?/": "^ಶ(ನಿ(.(ವಾರ)?)?)?", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "kn-IN"; /** * @overview datejs * @version 1.0.0-rc3 * @author Gregory Wild-Smith * @copyright 2015 Gregory Wild-Smith * @license MIT * @homepage https://github.com/abritinthebay/datejs */(function () { var $D = Date; var lang = Date.CultureStrings ? Date.CultureStrings.lang : null; var loggedKeys = {}; // for debug purposes. var getText = { getFromKey: function (key, countryCode) { var output; if (Date.CultureStrings && Date.CultureStrings[countryCode] && Date.CultureStrings[countryCode][key]) { output = Date.CultureStrings[countryCode][key]; } else { output = getText.buildFromDefault(key); } if (key.charAt(0) === "/") { // Assume it's a regex output = getText.buildFromRegex(key, countryCode); } return output; }, getFromObjectValues: function (obj, countryCode) { var key, output = {}; for(key in obj) { if (obj.hasOwnProperty(key)) { output[key] = getText.getFromKey(obj[key], countryCode); } } return output; }, getFromObjectKeys: function (obj, countryCode) { var key, output = {}; for(key in obj) { if (obj.hasOwnProperty(key)) { output[getText.getFromKey(key, countryCode)] = obj[key]; } } return output; }, getFromArray: function (arr, countryCode) { var output = []; for (var i=0; i < arr.length; i++){ if (i in arr) { output[i] = getText.getFromKey(arr[i], countryCode); } } return output; }, buildFromDefault: function (key) { var output, length, split, last; switch(key) { case "name": output = "en-US"; break; case "englishName": output = "English (United States)"; break; case "nativeName": output = "English (United States)"; break; case "twoDigitYearMax": output = 2049; break; case "firstDayOfWeek": output = 0; break; default: output = key; split = key.split("_"); length = split.length; if (length > 1 && key.charAt(0) !== "/") { // if the key isn't a regex and it has a split. last = split[(length - 1)].toLowerCase(); if (last === "initial" || last === "abbr") { output = split[0]; } } break; } return output; }, buildFromRegex: function (key, countryCode) { var output; if (Date.CultureStrings && Date.CultureStrings[countryCode] && Date.CultureStrings[countryCode][key]) { output = new RegExp(Date.CultureStrings[countryCode][key], "i"); } else { output = new RegExp(key.replace(new RegExp("/", "g"),""), "i"); } return output; } }; var shallowMerge = function (obj1, obj2) { for (var attrname in obj2) { if (obj2.hasOwnProperty(attrname)) { obj1[attrname] = obj2[attrname]; } } }; var __ = function (key, language) { var countryCode = (language) ? language : lang; loggedKeys[key] = key; if (typeof key === "object") { if (key instanceof Array) { return getText.getFromArray(key, countryCode); } else { return getText.getFromObjectKeys(key, countryCode); } } else { return getText.getFromKey(key, countryCode); } }; var loadI18nScript = function (code) { // paatterned after jQuery's getScript. var url = Date.Config.i18n + code + ".js"; var head = document.getElementsByTagName("head")[0] || document.documentElement; var script = document.createElement("script"); script.src = url; var completed = false; var events = { done: function (){} // placeholder function }; // Attach handlers for all browsers script.onload = script.onreadystatechange = function() { if ( !completed && (!this.readyState || this.readyState === "loaded" || this.readyState === "complete") ) { events.done(); head.removeChild(script); } }; setTimeout(function() { head.insertBefore(script, head.firstChild); }, 0); // allows return to execute first return { done: function (cb) { events.done = function() { if (cb) { setTimeout(cb,0); } }; } }; }; var buildInfo = { buildFromMethodHash: function (obj) { var key; for(key in obj) { if (obj.hasOwnProperty(key)) { obj[key] = buildInfo[obj[key]](); } } return obj; }, timeZoneDST: function () { var DST = { "CHADT": "+1345", "NZDT": "+1300", "AEDT": "+1100", "ACDT": "+1030", "AZST": "+0500", "IRDT": "+0430", "EEST": "+0300", "CEST": "+0200", "BST": "+0100", "PMDT": "-0200", "ADT": "-0300", "NDT": "-0230", "EDT": "-0400", "CDT": "-0500", "MDT": "-0600", "PDT": "-0700", "AKDT": "-0800", "HADT": "-0900" }; return __(DST); }, timeZoneStandard: function () { var standard = { "LINT": "+1400", "TOT": "+1300", "CHAST": "+1245", "NZST": "+1200", "NFT": "+1130", "SBT": "+1100", "AEST": "+1000", "ACST": "+0930", "JST": "+0900", "CWST": "+0845", "CT": "+0800", "ICT": "+0700", "MMT": "+0630", "BST": "+0600", "NPT": "+0545", "IST": "+0530", "PKT": "+0500", "AFT": "+0430", "MSK": "+0400", "IRST": "+0330", "FET": "+0300", "EET": "+0200", "CET": "+0100", "GMT": "+0000", "UTC": "+0000", "CVT": "-0100", "GST": "-0200", "BRT": "-0300", "NST": "-0330", "AST": "-0400", "EST": "-0500", "CST": "-0600", "MST": "-0700", "PST": "-0800", "AKST": "-0900", "MIT": "-0930", "HST": "-1000", "SST": "-1100", "BIT": "-1200" }; return __(standard); }, timeZones: function (data) { var zone; data.timezones = []; for (zone in data.abbreviatedTimeZoneStandard) { if (data.abbreviatedTimeZoneStandard.hasOwnProperty(zone)) { data.timezones.push({ name: zone, offset: data.abbreviatedTimeZoneStandard[zone]}); } } for (zone in data.abbreviatedTimeZoneDST) { if (data.abbreviatedTimeZoneDST.hasOwnProperty(zone)) { data.timezones.push({ name: zone, offset: data.abbreviatedTimeZoneDST[zone], dst: true}); } } return data.timezones; }, days: function () { return __(["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"]); }, dayAbbr: function () { return __(["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"]); }, dayShortNames: function () { return __(["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"]); }, dayFirstLetters: function () { return __(["S_Sun_Initial", "M_Mon_Initial", "T_Tues_Initial", "W_Wed_Initial", "T_Thu_Initial", "F_Fri_Initial", "S_Sat_Initial"]); }, months: function () { return __(["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"]); }, monthAbbr: function () { return __(["Jan_Abbr", "Feb_Abbr", "Mar_Abbr", "Apr_Abbr", "May_Abbr", "Jun_Abbr", "Jul_Abbr", "Aug_Abbr", "Sep_Abbr", "Oct_Abbr", "Nov_Abbr", "Dec_Abbr"]); }, formatPatterns: function () { return getText.getFromObjectValues({ shortDate: "M/d/yyyy", longDate: "dddd, MMMM dd, yyyy", shortTime: "h:mm tt", longTime: "h:mm:ss tt", fullDateTime: "dddd, MMMM dd, yyyy h:mm:ss tt", sortableDateTime: "yyyy-MM-ddTHH:mm:ss", universalSortableDateTime: "yyyy-MM-dd HH:mm:ssZ", rfc1123: "ddd, dd MMM yyyy HH:mm:ss", monthDay: "MMMM dd", yearMonth: "MMMM, yyyy" }, Date.i18n.currentLanguage()); }, regex: function () { return getText.getFromObjectValues({ inTheMorning: "/( in the )(morn(ing)?)\\b/", thisMorning: "/(this )(morn(ing)?)\\b/", amThisMorning: "/(\b\\d(am)? )(this )(morn(ing)?)/", inTheEvening: "/( in the )(even(ing)?)\\b/", thisEvening: "/(this )(even(ing)?)\\b/", pmThisEvening: "/(\b\\d(pm)? )(this )(even(ing)?)/", jan: "/jan(uary)?/", feb: "/feb(ruary)?/", mar: "/mar(ch)?/", apr: "/apr(il)?/", may: "/may/", jun: "/jun(e)?/", jul: "/jul(y)?/", aug: "/aug(ust)?/", sep: "/sep(t(ember)?)?/", oct: "/oct(ober)?/", nov: "/nov(ember)?/", dec: "/dec(ember)?/", sun: "/^su(n(day)?)?/", mon: "/^mo(n(day)?)?/", tue: "/^tu(e(s(day)?)?)?/", wed: "/^we(d(nesday)?)?/", thu: "/^th(u(r(s(day)?)?)?)?/", fri: "/fr(i(day)?)?/", sat: "/^sa(t(urday)?)?/", future: "/^next/", past: "/^last|past|prev(ious)?/", add: "/^(\\+|aft(er)?|from|hence)/", subtract: "/^(\\-|bef(ore)?|ago)/", yesterday: "/^yes(terday)?/", today: "/^t(od(ay)?)?/", tomorrow: "/^tom(orrow)?/", now: "/^n(ow)?/", millisecond: "/^ms|milli(second)?s?/", second: "/^sec(ond)?s?/", minute: "/^mn|min(ute)?s?/", hour: "/^h(our)?s?/", week: "/^w(eek)?s?/", month: "/^m(onth)?s?/", day: "/^d(ay)?s?/", year: "/^y(ear)?s?/", shortMeridian: "/^(a|p)/", longMeridian: "/^(a\\.?m?\\.?|p\\.?m?\\.?)/", timezone: "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/", ordinalSuffix: "/^\\s*(st|nd|rd|th)/", timeContext: "/^\\s*(\\:|a(?!u|p)|p)/" }, Date.i18n.currentLanguage()); } }; var CultureInfo = function () { var info = getText.getFromObjectValues({ name: "name", englishName: "englishName", nativeName: "nativeName", amDesignator: "AM", pmDesignator: "PM", firstDayOfWeek: "firstDayOfWeek", twoDigitYearMax: "twoDigitYearMax", dateElementOrder: "mdy" }, Date.i18n.currentLanguage()); var constructedInfo = buildInfo.buildFromMethodHash({ dayNames: "days", abbreviatedDayNames: "dayAbbr", shortestDayNames: "dayShortNames", firstLetterDayNames: "dayFirstLetters", monthNames: "months", abbreviatedMonthNames: "monthAbbr", formatPatterns: "formatPatterns", regexPatterns: "regex", abbreviatedTimeZoneDST: "timeZoneDST", abbreviatedTimeZoneStandard: "timeZoneStandard" }); shallowMerge(info, constructedInfo); buildInfo.timeZones(info); return info; }; $D.i18n = { __: function (key, lang) { return __(key, lang); }, currentLanguage: function () { return lang || "en-US"; }, setLanguage: function (code, force, cb) { var async = false; if (force || code === "en-US" || (!!Date.CultureStrings && !!Date.CultureStrings[code])) { lang = code; Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings.lang = code; Date.CultureInfo = new CultureInfo(); } else { if (!(!!Date.CultureStrings && !!Date.CultureStrings[code])) { if (typeof exports !== "undefined" && this.exports !== exports) { // we're in a Node enviroment, load it using require try { require("../i18n/" + code + ".js"); lang = code; Date.CultureStrings.lang = code; Date.CultureInfo = new CultureInfo(); } catch (e) { // var str = "The language for '" + code + "' could not be loaded by Node. It likely does not exist."; throw new Error("The DateJS IETF language tag '" + code + "' could not be loaded by Node. It likely does not exist."); } } else if (Date.Config && Date.Config.i18n) { // we know the location of the files, so lets load them async = true; loadI18nScript(code).done(function(){ lang = code; Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings.lang = code; Date.CultureInfo = new CultureInfo(); $D.Parsing.Normalizer.buildReplaceData(); // because this is async if ($D.Grammar) { $D.Grammar.buildGrammarFormats(); // so we can parse those strings... } if (cb) { setTimeout(cb,0); } }); } else { Date.console.error("The DateJS IETF language tag '" + code + "' is not available and has not been loaded."); return false; } } } $D.Parsing.Normalizer.buildReplaceData(); // rebuild normalizer strings if ($D.Grammar) { $D.Grammar.buildGrammarFormats(); // so we can parse those strings... } if (!async && cb) { setTimeout(cb,0); } }, getLoggedKeys: function () { return loggedKeys; }, updateCultureInfo: function () { Date.CultureInfo = new CultureInfo(); } }; $D.i18n.updateCultureInfo(); // run automatically }()); (function () { var $D = Date, $P = $D.prototype, p = function (s, l) { if (!l) { l = 2; } return ("000" + s).slice(l * -1); }; if (typeof window !== "undefined" && typeof window.console !== "undefined" && typeof window.console.log !== "undefined") { $D.console = console; // used only to raise non-critical errors if available } else { // set mock so we don't give errors. $D.console = { log: function(){}, error: function(){} }; } $D.Config = $D.Config || {}; $D.initOverloads = function() { /** * Overload of Date.now. Allows an alternate call for Date.now where it returns the * current Date as an object rather than just milliseconds since the Unix Epoch. * * Also provides an implementation of now() for browsers (IE<9) that don't have it. * * Backwards compatible so with work with either: * Date.now() [returns ms] * or * Date.now(true) [returns Date] */ if (!$D.now) { $D._now = function now() { return new Date().getTime(); }; } else if (!$D._now) { $D._now = $D.now; } $D.now = function (returnObj) { if (returnObj) { return $D.present(); } else { return $D._now(); } }; if ( !$P.toISOString ) { $P.toISOString = function() { return this.getUTCFullYear() + "-" + p(this.getUTCMonth() + 1) + "-" + p(this.getUTCDate()) + "T" + p(this.getUTCHours()) + ":" + p(this.getUTCMinutes()) + ":" + p(this.getUTCSeconds()) + "." + String( (this.getUTCMilliseconds()/1000).toFixed(3)).slice(2, 5) + "Z"; }; } // private if ( $P._toString === undefined ){ $P._toString = $P.toString; } }; $D.initOverloads(); /** * Gets a date that is set to the current date. The time is set to the start of the day (00:00 or 12:00 AM). * @return {Date} The current date. */ $D.today = function () { return new Date().clearTime(); }; /** * Gets a date that is set to the current date and time (same as new Date, but chainable) * @return {Date} The current date. */ $D.present = function () { return new Date(); }; /** * Compares the first date to the second date and returns an number indication of their relative values. * @param {Date} First Date object to compare [Required]. * @param {Date} Second Date object to compare to [Required]. * @return {Number} -1 = date1 is lessthan date2. 0 = values are equal. 1 = date1 is greaterthan date2. */ $D.compare = function (date1, date2) { if (isNaN(date1) || isNaN(date2)) { throw new Error(date1 + " - " + date2); } else if (date1 instanceof Date && date2 instanceof Date) { return (date1 < date2) ? -1 : (date1 > date2) ? 1 : 0; } else { throw new TypeError(date1 + " - " + date2); } }; /** * Compares the first Date object to the second Date object and returns true if they are equal. * @param {Date} First Date object to compare [Required] * @param {Date} Second Date object to compare to [Required] * @return {Boolean} true if dates are equal. false if they are not equal. */ $D.equals = function (date1, date2) { return (date1.compareTo(date2) === 0); }; /** * Gets the language appropriate day name when given the day number(0-6) * eg - 0 == Sunday * @return {String} The day name */ $D.getDayName = function (n) { return Date.CultureInfo.dayNames[n]; }; /** * Gets the day number (0-6) if given a CultureInfo specific string which is a valid dayName, abbreviatedDayName or shortestDayName (two char). * @param {String} The name of the day (eg. "Monday, "Mon", "tuesday", "tue", "We", "we"). * @return {Number} The day number */ $D.getDayNumberFromName = function (name) { var n = Date.CultureInfo.dayNames, m = Date.CultureInfo.abbreviatedDayNames, o = Date.CultureInfo.shortestDayNames, s = name.toLowerCase(); for (var i = 0; i < n.length; i++) { if (n[i].toLowerCase() === s || m[i].toLowerCase() === s || o[i].toLowerCase() === s) { return i; } } return -1; }; /** * Gets the month number (0-11) if given a Culture Info specific string which is a valid monthName or abbreviatedMonthName. * @param {String} The name of the month (eg. "February, "Feb", "october", "oct"). * @return {Number} The day number */ $D.getMonthNumberFromName = function (name) { var n = Date.CultureInfo.monthNames, m = Date.CultureInfo.abbreviatedMonthNames, s = name.toLowerCase(); for (var i = 0; i < n.length; i++) { if (n[i].toLowerCase() === s || m[i].toLowerCase() === s) { return i; } } return -1; }; /** * Gets the language appropriate month name when given the month number(0-11) * eg - 0 == January * @return {String} The month name */ $D.getMonthName = function (n) { return Date.CultureInfo.monthNames[n]; }; /** * Determines if the current date instance is within a LeapYear. * @param {Number} The year. * @return {Boolean} true if date is within a LeapYear, otherwise false. */ $D.isLeapYear = function (year) { return ((year % 4 === 0 && year % 100 !== 0) || year % 400 === 0); }; /** * Gets the number of days in the month, given a year and month value. Automatically corrects for LeapYear. * @param {Number} The year. * @param {Number} The month (0-11). * @return {Number} The number of days in the month. */ $D.getDaysInMonth = function (year, month) { if (!month && $D.validateMonth(year)) { month = year; year = Date.today().getFullYear(); } return [31, ($D.isLeapYear(year) ? 29 : 28), 31, 30, 31, 30, 31, 31, 30, 31, 30, 31][month]; }; $P.getDaysInMonth = function () { return $D.getDaysInMonth(this.getFullYear(), this.getMonth()); }; $D.getTimezoneAbbreviation = function (offset, dst) { var p, n = (dst || false) ? Date.CultureInfo.abbreviatedTimeZoneDST : Date.CultureInfo.abbreviatedTimeZoneStandard; for (p in n) { if (n.hasOwnProperty(p)) { if (n[p] === offset) { return p; } } } return null; }; $D.getTimezoneOffset = function (name, dst) { var i, a =[], z = Date.CultureInfo.timezones; if (!name) { name = (new Date()).getTimezone();} for (i = 0; i < z.length; i++) { if (z[i].name === name.toUpperCase()) { a.push(i); } } if (!z[a[0]]) { return null; } if (a.length === 1 || !dst) { return z[a[0]].offset; } else { for (i=0; i < a.length; i++) { if (z[a[i]].dst) { return z[a[i]].offset; } } } }; $D.getQuarter = function (d) { d = d || new Date(); // If no date supplied, use today var q = [1,2,3,4]; return q[Math.floor(d.getMonth() / 3)]; // ~~~ is a bitwise op. Faster than Math.floor }; $D.getDaysLeftInQuarter = function (d) { d = d || new Date(); var qEnd = new Date(d); qEnd.setMonth(qEnd.getMonth() + 3 - qEnd.getMonth() % 3, 0); return Math.floor((qEnd - d) / 8.64e7); }; // private var validate = function (n, min, max, name) { name = name ? name : "Object"; if (typeof n === "undefined") { return false; } else if (typeof n !== "number") { throw new TypeError(n + " is not a Number."); } else if (n < min || n > max) { // As failing validation is *not* an exceptional circumstance // lets not throw a RangeError Exception here. // It's semantically correct but it's not sensible. return false; } return true; }; /** * Validates the number is within an acceptable range for milliseconds [0-999]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateMillisecond = function (value) { return validate(value, 0, 999, "millisecond"); }; /** * Validates the number is within an acceptable range for seconds [0-59]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateSecond = function (value) { return validate(value, 0, 59, "second"); }; /** * Validates the number is within an acceptable range for minutes [0-59]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateMinute = function (value) { return validate(value, 0, 59, "minute"); }; /** * Validates the number is within an acceptable range for hours [0-23]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateHour = function (value) { return validate(value, 0, 23, "hour"); }; /** * Validates the number is within an acceptable range for the days in a month [0-MaxDaysInMonth]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateDay = function (value, year, month) { if (year === undefined || year === null || month === undefined || month === null) { return false;} return validate(value, 1, $D.getDaysInMonth(year, month), "day"); }; /** * Validates the number is within an acceptable range for months [0-11]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateWeek = function (value) { return validate(value, 0, 53, "week"); }; /** * Validates the number is within an acceptable range for months [0-11]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateMonth = function (value) { return validate(value, 0, 11, "month"); }; /** * Validates the number is within an acceptable range for years. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateYear = function (value) { /** * Per ECMAScript spec the range of times supported by Date objects is * exactly -100,000,000 days to +100,000,000 days measured relative to * midnight at the beginning of 01 January, 1970 UTC. * This gives a range of 8,640,000,000,000,000 milliseconds to either * side of 01 January, 1970 UTC. * * Earliest possible date: Tue, 20 Apr 271,822 B.C. 00:00:00 UTC * Latest possible date: Sat, 13 Sep 275,760 00:00:00 UTC */ return validate(value, -271822, 275760, "year"); }; $D.validateTimezone = function(value) { var timezones = {"ACDT":1,"ACST":1,"ACT":1,"ADT":1,"AEDT":1,"AEST":1,"AFT":1,"AKDT":1,"AKST":1,"AMST":1,"AMT":1,"ART":1,"AST":1,"AWDT":1,"AWST":1,"AZOST":1,"AZT":1,"BDT":1,"BIOT":1,"BIT":1,"BOT":1,"BRT":1,"BST":1,"BTT":1,"CAT":1,"CCT":1,"CDT":1,"CEDT":1,"CEST":1,"CET":1,"CHADT":1,"CHAST":1,"CHOT":1,"ChST":1,"CHUT":1,"CIST":1,"CIT":1,"CKT":1,"CLST":1,"CLT":1,"COST":1,"COT":1,"CST":1,"CT":1,"CVT":1,"CWST":1,"CXT":1,"DAVT":1,"DDUT":1,"DFT":1,"EASST":1,"EAST":1,"EAT":1,"ECT":1,"EDT":1,"EEDT":1,"EEST":1,"EET":1,"EGST":1,"EGT":1,"EIT":1,"EST":1,"FET":1,"FJT":1,"FKST":1,"FKT":1,"FNT":1,"GALT":1,"GAMT":1,"GET":1,"GFT":1,"GILT":1,"GIT":1,"GMT":1,"GST":1,"GYT":1,"HADT":1,"HAEC":1,"HAST":1,"HKT":1,"HMT":1,"HOVT":1,"HST":1,"ICT":1,"IDT":1,"IOT":1,"IRDT":1,"IRKT":1,"IRST":1,"IST":1,"JST":1,"KGT":1,"KOST":1,"KRAT":1,"KST":1,"LHST":1,"LINT":1,"MAGT":1,"MART":1,"MAWT":1,"MDT":1,"MET":1,"MEST":1,"MHT":1,"MIST":1,"MIT":1,"MMT":1,"MSK":1,"MST":1,"MUT":1,"MVT":1,"MYT":1,"NCT":1,"NDT":1,"NFT":1,"NPT":1,"NST":1,"NT":1,"NUT":1,"NZDT":1,"NZST":1,"OMST":1,"ORAT":1,"PDT":1,"PET":1,"PETT":1,"PGT":1,"PHOT":1,"PHT":1,"PKT":1,"PMDT":1,"PMST":1,"PONT":1,"PST":1,"PYST":1,"PYT":1,"RET":1,"ROTT":1,"SAKT":1,"SAMT":1,"SAST":1,"SBT":1,"SCT":1,"SGT":1,"SLST":1,"SRT":1,"SST":1,"SYOT":1,"TAHT":1,"THA":1,"TFT":1,"TJT":1,"TKT":1,"TLT":1,"TMT":1,"TOT":1,"TVT":1,"UCT":1,"ULAT":1,"UTC":1,"UYST":1,"UYT":1,"UZT":1,"VET":1,"VLAT":1,"VOLT":1,"VOST":1,"VUT":1,"WAKT":1,"WAST":1,"WAT":1,"WEDT":1,"WEST":1,"WET":1,"WST":1,"YAKT":1,"YEKT":1,"Z":1}; return (timezones[value] === 1); }; $D.validateTimezoneOffset= function(value) { // timezones go from +14hrs to -12hrs, the +X hours are negative offsets. return (value > -841 && value < 721); }; }()); (function () { var $D = Date, $P = $D.prototype, p = function (s, l) { if (!l) { l = 2; } return ("000" + s).slice(l * -1); }; var validateConfigObject = function (obj) { var result = {}, self = this, prop, testFunc; testFunc = function (prop, func, value) { if (prop === "day") { var month = (obj.month !== undefined) ? obj.month : self.getMonth(); var year = (obj.year !== undefined) ? obj.year : self.getFullYear(); return $D[func](value, year, month); } else { return $D[func](value); } }; for (prop in obj) { if (Object.prototype.hasOwnProperty.call(obj, prop)) { var func = "validate" + prop.charAt(0).toUpperCase() + prop.slice(1); if ($D[func] && obj[prop] !== null && testFunc(prop, func, obj[prop])) { result[prop] = obj[prop]; } } } return result; }; /** * Resets the time of this Date object to 12:00 AM (00:00), which is the start of the day. * @param {Boolean} .clone() this date instance before clearing Time * @return {Date} this */ $P.clearTime = function () { this.setHours(0); this.setMinutes(0); this.setSeconds(0); this.setMilliseconds(0); return this; }; /** * Resets the time of this Date object to the current time ('now'). * @return {Date} this */ $P.setTimeToNow = function () { var n = new Date(); this.setHours(n.getHours()); this.setMinutes(n.getMinutes()); this.setSeconds(n.getSeconds()); this.setMilliseconds(n.getMilliseconds()); return this; }; /** * Returns a new Date object that is an exact date and time copy of the original instance. * @return {Date} A new Date instance */ $P.clone = function () { return new Date(this.getTime()); }; /** * Compares this instance to a Date object and returns an number indication of their relative values. * @param {Date} Date object to compare [Required] * @return {Number} -1 = this is lessthan date. 0 = values are equal. 1 = this is greaterthan date. */ $P.compareTo = function (date) { return Date.compare(this, date); }; /** * Compares this instance to another Date object and returns true if they are equal. * @param {Date} Date object to compare. If no date to compare, new Date() [now] is used. * @return {Boolean} true if dates are equal. false if they are not equal. */ $P.equals = function (date) { return Date.equals(this, (date !== undefined ? date : new Date())); }; /** * Determines if this instance is between a range of two dates or equal to either the start or end dates. * @param {Date} Start of range [Required] * @param {Date} End of range [Required] * @return {Boolean} true is this is between or equal to the start and end dates, else false */ $P.between = function (start, end) { return this.getTime() >= start.getTime() && this.getTime() <= end.getTime(); }; /** * Determines if this date occurs after the date to compare to. * @param {Date} Date object to compare. If no date to compare, new Date() ("now") is used. * @return {Boolean} true if this date instance is greater than the date to compare to (or "now"), otherwise false. */ $P.isAfter = function (date) { return this.compareTo(date || new Date()) === 1; }; /** * Determines if this date occurs before the date to compare to. * @param {Date} Date object to compare. If no date to compare, new Date() ("now") is used. * @return {Boolean} true if this date instance is less than the date to compare to (or "now"). */ $P.isBefore = function (date) { return (this.compareTo(date || new Date()) === -1); }; /** * Determines if the current Date instance occurs today. * @return {Boolean} true if this date instance is 'today', otherwise false. */ /** * Determines if the current Date instance occurs on the same Date as the supplied 'date'. * If no 'date' to compare to is provided, the current Date instance is compared to 'today'. * @param {date} Date object to compare. If no date to compare, the current Date ("now") is used. * @return {Boolean} true if this Date instance occurs on the same Day as the supplied 'date'. */ $P.isToday = $P.isSameDay = function (date) { return this.clone().clearTime().equals((date || new Date()).clone().clearTime()); }; /** * Adds the specified number of milliseconds to this instance. * @param {Number} The number of milliseconds to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addMilliseconds = function (value) { if (!value) { return this; } this.setTime(this.getTime() + value * 1); return this; }; /** * Adds the specified number of seconds to this instance. * @param {Number} The number of seconds to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addSeconds = function (value) { if (!value) { return this; } return this.addMilliseconds(value * 1000); }; /** * Adds the specified number of seconds to this instance. * @param {Number} The number of seconds to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addMinutes = function (value) { if (!value) { return this; } return this.addMilliseconds(value * 60000); // 60*1000 }; /** * Adds the specified number of hours to this instance. * @param {Number} The number of hours to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addHours = function (value) { if (!value) { return this; } return this.addMilliseconds(value * 3600000); // 60*60*1000 }; /** * Adds the specified number of days to this instance. * @param {Number} The number of days to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addDays = function (value) { if (!value) { return this; } this.setDate(this.getDate() + value * 1); return this; }; /** * Adds the specified number of weekdays (ie - not sat or sun) to this instance. * @param {Number} The number of days to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addWeekdays = function (value) { if (!value) { return this; } var day = this.getDay(); var weeks = (Math.ceil(Math.abs(value)/7)); if (day === 0 || day === 6) { if (value > 0) { this.next().monday(); this.addDays(-1); day = this.getDay(); } } if (value < 0) { while (value < 0) { this.addDays(-1); day = this.getDay(); if (day !== 0 && day !== 6) { value++; } } return this; } else if (value > 5 || (6-day) <= value) { value = value + (weeks * 2); } return this.addDays(value); }; /** * Adds the specified number of weeks to this instance. * @param {Number} The number of weeks to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addWeeks = function (value) { if (!value) { return this; } return this.addDays(value * 7); }; /** * Adds the specified number of months to this instance. * @param {Number} The number of months to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addMonths = function (value) { if (!value) { return this; } var n = this.getDate(); this.setDate(1); this.setMonth(this.getMonth() + value * 1); this.setDate(Math.min(n, $D.getDaysInMonth(this.getFullYear(), this.getMonth()))); return this; }; $P.addQuarters = function (value) { if (!value) { return this; } // note this will take you to the same point in the quarter as you are now. // i.e. - if you are 15 days into the quarter you'll be 15 days into the resulting one. // bonus: this allows adding fractional quarters return this.addMonths(value * 3); }; /** * Adds the specified number of years to this instance. * @param {Number} The number of years to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addYears = function (value) { if (!value) { return this; } return this.addMonths(value * 12); }; /** * Adds (or subtracts) to the value of the years, months, weeks, days, hours, minutes, seconds, milliseconds of the date instance using given configuration object. Positive and Negative values allowed. * Example

	Date.today().add( { days: 1, months: 1 } )

	new Date().add( { years: -1 } )
	
* @param {Object} Configuration object containing attributes (months, days, etc.) * @return {Date} this */ $P.add = function (config) { if (typeof config === "number") { this._orient = config; return this; } var x = config; if (x.day) { // If we should be a different date than today (eg: for 'tomorrow -1d', etc). // Should only effect parsing, not direct usage (eg, Finish and FinishExact) if ((x.day - this.getDate()) !== 0) { this.setDate(x.day); } } if (x.milliseconds) { this.addMilliseconds(x.milliseconds); } if (x.seconds) { this.addSeconds(x.seconds); } if (x.minutes) { this.addMinutes(x.minutes); } if (x.hours) { this.addHours(x.hours); } if (x.weeks) { this.addWeeks(x.weeks); } if (x.months) { this.addMonths(x.months); } if (x.years) { this.addYears(x.years); } if (x.days) { this.addDays(x.days); } return this; }; /** * Get the week number. Week one (1) is the week which contains the first Thursday of the year. Monday is considered the first day of the week. * The .getWeek() function does NOT convert the date to UTC. The local datetime is used. * Please use .getISOWeek() to get the week of the UTC converted date. * @return {Number} 1 to 53 */ $P.getWeek = function (utc) { // Create a copy of this date object var self, target = new Date(this.valueOf()); if (utc) { target.addMinutes(target.getTimezoneOffset()); self = target.clone(); } else { self = this; } // ISO week date weeks start on monday // so correct the day number var dayNr = (self.getDay() + 6) % 7; // ISO 8601 states that week 1 is the week // with the first thursday of that year. // Set the target date to the thursday in the target week target.setDate(target.getDate() - dayNr + 3); // Store the millisecond value of the target date var firstThursday = target.valueOf(); // Set the target to the first thursday of the year // First set the target to january first target.setMonth(0, 1); // Not a thursday? Correct the date to the next thursday if (target.getDay() !== 4) { target.setMonth(0, 1 + ((4 - target.getDay()) + 7) % 7); } // The weeknumber is the number of weeks between the // first thursday of the year and the thursday in the target week return 1 + Math.ceil((firstThursday - target) / 604800000); // 604800000 = 7 * 24 * 3600 * 1000 }; /** * Get the ISO 8601 week number. Week one ("01") is the week which contains the first Thursday of the year. Monday is considered the first day of the week. * The .getISOWeek() function does convert the date to it's UTC value. Please use .getWeek() to get the week of the local date. * @return {String} "01" to "53" */ $P.getISOWeek = function () { return p(this.getWeek(true)); }; /** * Moves the date to Monday of the week set. Week one (1) is the week which contains the first Thursday of the year. * @param {Number} A Number (1 to 53) that represents the week of the year. * @return {Date} this */ $P.setWeek = function (n) { if ((n - this.getWeek()) === 0) { if (this.getDay() !== 1) { return this.moveToDayOfWeek(1, (this.getDay() > 1 ? -1 : 1)); } else { return this; } } else { return this.moveToDayOfWeek(1, (this.getDay() > 1 ? -1 : 1)).addWeeks(n - this.getWeek()); } }; $P.setQuarter = function (qtr) { var month = Math.abs(((qtr-1) * 3) + 1); return this.setMonth(month, 1); }; $P.getQuarter = function () { return Date.getQuarter(this); }; $P.getDaysLeftInQuarter = function () { return Date.getDaysLeftInQuarter(this); }; /** * Moves the date to the next n'th occurrence of the dayOfWeek starting from the beginning of the month. The number (-1) is a magic number and will return the last occurrence of the dayOfWeek in the month. * @param {Number} The dayOfWeek to move to * @param {Number} The n'th occurrence to move to. Use (-1) to return the last occurrence in the month * @return {Date} this */ $P.moveToNthOccurrence = function (dayOfWeek, occurrence) { if (dayOfWeek === "Weekday") { if (occurrence > 0) { this.moveToFirstDayOfMonth(); if (this.is().weekday()) { occurrence -= 1; } } else if (occurrence < 0) { this.moveToLastDayOfMonth(); if (this.is().weekday()) { occurrence += 1; } } else { return this; } return this.addWeekdays(occurrence); } var shift = 0; if (occurrence > 0) { shift = occurrence - 1; } else if (occurrence === -1) { this.moveToLastDayOfMonth(); if (this.getDay() !== dayOfWeek) { this.moveToDayOfWeek(dayOfWeek, -1); } return this; } return this.moveToFirstDayOfMonth().addDays(-1).moveToDayOfWeek(dayOfWeek, +1).addWeeks(shift); }; var moveToN = function (getFunc, addFunc, nVal) { return function (value, orient) { var diff = (value - this[getFunc]() + nVal * (orient || +1)) % nVal; return this[addFunc]((diff === 0) ? diff += nVal * (orient || +1) : diff); }; }; /** * Move to the next or last dayOfWeek based on the orient value. * @param {Number} The dayOfWeek to move to * @param {Number} Forward (+1) or Back (-1). Defaults to +1. [Optional] * @return {Date} this */ $P.moveToDayOfWeek = moveToN("getDay", "addDays", 7); /** * Move to the next or last month based on the orient value. * @param {Number} The month to move to. 0 = January, 11 = December * @param {Number} Forward (+1) or Back (-1). Defaults to +1. [Optional] * @return {Date} this */ $P.moveToMonth = moveToN("getMonth", "addMonths", 12); /** * Get the Ordinate of the current day ("th", "st", "rd"). * @return {String} */ $P.getOrdinate = function () { var num = this.getDate(); return ord(num); }; /** * Get the Ordinal day (numeric day number) of the year, adjusted for leap year. * @return {Number} 1 through 365 (366 in leap years) */ $P.getOrdinalNumber = function () { return Math.ceil((this.clone().clearTime() - new Date(this.getFullYear(), 0, 1)) / 86400000) + 1; }; /** * Get the time zone abbreviation of the current date. * @return {String} The abbreviated time zone name (e.g. "EST") */ $P.getTimezone = function () { return $D.getTimezoneAbbreviation(this.getUTCOffset(), this.isDaylightSavingTime()); }; $P.setTimezoneOffset = function (offset) { var here = this.getTimezoneOffset(), there = Number(offset) * -6 / 10; return (there || there === 0) ? this.addMinutes(there - here) : this; }; $P.setTimezone = function (offset) { return this.setTimezoneOffset($D.getTimezoneOffset(offset)); }; /** * Indicates whether Daylight Saving Time is observed in the current time zone. * @return {Boolean} true|false */ $P.hasDaylightSavingTime = function () { return (Date.today().set({month: 0, day: 1}).getTimezoneOffset() !== Date.today().set({month: 6, day: 1}).getTimezoneOffset()); }; /** * Indicates whether this Date instance is within the Daylight Saving Time range for the current time zone. * @return {Boolean} true|false */ $P.isDaylightSavingTime = function () { return Date.today().set({month: 0, day: 1}).getTimezoneOffset() !== this.getTimezoneOffset(); }; /** * Get the offset from UTC of the current date. * @return {String} The 4-character offset string prefixed with + or - (e.g. "-0500") */ $P.getUTCOffset = function (offset) { var n = (offset || this.getTimezoneOffset()) * -10 / 6, r; if (n < 0) { r = (n - 10000).toString(); return r.charAt(0) + r.substr(2); } else { r = (n + 10000).toString(); return "+" + r.substr(1); } }; /** * Returns the number of milliseconds between this date and date. * @param {Date} Defaults to now * @return {Number} The diff in milliseconds */ $P.getElapsed = function (date) { return (date || new Date()) - this; }; /** * Set the value of year, month, day, hour, minute, second, millisecond of date instance using given configuration object. * Example

	Date.today().set( { day: 20, month: 1 } )

	new Date().set( { millisecond: 0 } )
	
* * @param {Object} Configuration object containing attributes (month, day, etc.) * @return {Date} this */ $P.set = function (config) { config = validateConfigObject.call(this, config); var key; for (key in config) { if (Object.prototype.hasOwnProperty.call(config, key)) { var name = key.charAt(0).toUpperCase() + key.slice(1); var addFunc, getFunc; if (key !== "week" && key !== "month" && key !== "timezone" && key !== "timezoneOffset") { name += "s"; } addFunc = "add" + name; getFunc = "get" + name; if (key === "month") { addFunc = addFunc + "s"; } else if (key === "year"){ getFunc = "getFullYear"; } if (key !== "day" && key !== "timezone" && key !== "timezoneOffset" && key !== "week" && key !== "hour") { this[addFunc](config[key] - this[getFunc]()); } else if ( key === "timezone"|| key === "timezoneOffset" || key === "week" || key === "hour") { this["set"+name](config[key]); } } } // day has to go last because you can't validate the day without first knowing the month if (config.day) { this.addDays(config.day - this.getDate()); } return this; }; /** * Moves the date to the first day of the month. * @return {Date} this */ $P.moveToFirstDayOfMonth = function () { return this.set({ day: 1 }); }; /** * Moves the date to the last day of the month. * @return {Date} this */ $P.moveToLastDayOfMonth = function () { return this.set({ day: $D.getDaysInMonth(this.getFullYear(), this.getMonth())}); }; /** * Converts the value of the current Date object to its equivalent string representation. * Format Specifiers * CUSTOM DATE AND TIME FORMAT STRINGS * Format Description Example * ------ --------------------------------------------------------------------------- ----------------------- * s The seconds of the minute between 0-59. "0" to "59" * ss The seconds of the minute with leading zero if required. "00" to "59" * * m The minute of the hour between 0-59. "0" or "59" * mm The minute of the hour with leading zero if required. "00" or "59" * * h The hour of the day between 1-12. "1" to "12" * hh The hour of the day with leading zero if required. "01" to "12" * * H The hour of the day between 0-23. "0" to "23" * HH The hour of the day with leading zero if required. "00" to "23" * * d The day of the month between 1 and 31. "1" to "31" * dd The day of the month with leading zero if required. "01" to "31" * ddd Abbreviated day name. Date.CultureInfo.abbreviatedDayNames. "Mon" to "Sun" * dddd The full day name. Date.CultureInfo.dayNames. "Monday" to "Sunday" * * M The month of the year between 1-12. "1" to "12" * MM The month of the year with leading zero if required. "01" to "12" * MMM Abbreviated month name. Date.CultureInfo.abbreviatedMonthNames. "Jan" to "Dec" * MMMM The full month name. Date.CultureInfo.monthNames. "January" to "December" * * yy The year as a two-digit number. "99" or "08" * yyyy The full four digit year. "1999" or "2008" * * t Displays the first character of the A.M./P.M. designator. "A" or "P" * Date.CultureInfo.amDesignator or Date.CultureInfo.pmDesignator * tt Displays the A.M./P.M. designator. "AM" or "PM" * Date.CultureInfo.amDesignator or Date.CultureInfo.pmDesignator * * S The ordinal suffix ("st, "nd", "rd" or "th") of the current day. "st, "nd", "rd" or "th" * * STANDARD DATE AND TIME FORMAT STRINGS * Format Description Example *------ --------------------------------------------------------------------------- ----------------------- * d The CultureInfo shortDate Format Pattern "M/d/yyyy" * D The CultureInfo longDate Format Pattern "dddd, MMMM dd, yyyy" * F The CultureInfo fullDateTime Format Pattern "dddd, MMMM dd, yyyy h:mm:ss tt" * m The CultureInfo monthDay Format Pattern "MMMM dd" * r The CultureInfo rfc1123 Format Pattern "ddd, dd MMM yyyy HH:mm:ss GMT" * s The CultureInfo sortableDateTime Format Pattern "yyyy-MM-ddTHH:mm:ss" * t The CultureInfo shortTime Format Pattern "h:mm tt" * T The CultureInfo longTime Format Pattern "h:mm:ss tt" * u The CultureInfo universalSortableDateTime Format Pattern "yyyy-MM-dd HH:mm:ssZ" * y The CultureInfo yearMonth Format Pattern "MMMM, yyyy" * * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @return {String} A string representation of the current Date object. */ var ord = function (n) { switch (n * 1) { case 1: case 21: case 31: return "st"; case 2: case 22: return "nd"; case 3: case 23: return "rd"; default: return "th"; } }; var parseStandardFormats = function (format) { var y, c = Date.CultureInfo.formatPatterns; switch (format) { case "d": return this.toString(c.shortDate); case "D": return this.toString(c.longDate); case "F": return this.toString(c.fullDateTime); case "m": return this.toString(c.monthDay); case "r": case "R": y = this.clone().addMinutes(this.getTimezoneOffset()); return y.toString(c.rfc1123) + " GMT"; case "s": return this.toString(c.sortableDateTime); case "t": return this.toString(c.shortTime); case "T": return this.toString(c.longTime); case "u": y = this.clone().addMinutes(this.getTimezoneOffset()); return y.toString(c.universalSortableDateTime); case "y": return this.toString(c.yearMonth); default: return false; } }; var parseFormatStringsClosure = function (context) { return function (m) { if (m.charAt(0) === "\\") { return m.replace("\\", ""); } switch (m) { case "hh": return p(context.getHours() < 13 ? (context.getHours() === 0 ? 12 : context.getHours()) : (context.getHours() - 12)); case "h": return context.getHours() < 13 ? (context.getHours() === 0 ? 12 : context.getHours()) : (context.getHours() - 12); case "HH": return p(context.getHours()); case "H": return context.getHours(); case "mm": return p(context.getMinutes()); case "m": return context.getMinutes(); case "ss": return p(context.getSeconds()); case "s": return context.getSeconds(); case "yyyy": return p(context.getFullYear(), 4); case "yy": return p(context.getFullYear()); case "y": return context.getFullYear(); case "E": case "dddd": return Date.CultureInfo.dayNames[context.getDay()]; case "ddd": return Date.CultureInfo.abbreviatedDayNames[context.getDay()]; case "dd": return p(context.getDate()); case "d": return context.getDate(); case "MMMM": return Date.CultureInfo.monthNames[context.getMonth()]; case "MMM": return Date.CultureInfo.abbreviatedMonthNames[context.getMonth()]; case "MM": return p((context.getMonth() + 1)); case "M": return context.getMonth() + 1; case "t": return context.getHours() < 12 ? Date.CultureInfo.amDesignator.substring(0, 1) : Date.CultureInfo.pmDesignator.substring(0, 1); case "tt": return context.getHours() < 12 ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator; case "S": return ord(context.getDate()); case "W": return context.getWeek(); case "WW": return context.getISOWeek(); case "Q": return "Q" + context.getQuarter(); case "q": return String(context.getQuarter()); case "z": return context.getTimezone(); case "Z": case "X": return Date.getTimezoneOffset(context.getTimezone()); case "ZZ": // Timezone offset in seconds return context.getTimezoneOffset() * -60; case "u": return context.getDay(); case "L": return ($D.isLeapYear(context.getFullYear())) ? 1 : 0; case "B": // Swatch Internet Time (.beats) return "@"+((context.getUTCSeconds() + (context.getUTCMinutes()*60) + ((context.getUTCHours()+1)*3600))/86.4); default: return m; } }; }; $P.toString = function (format, ignoreStandards) { // Standard Date and Time Format Strings. Formats pulled from CultureInfo file and // may vary by culture. if (!ignoreStandards && format && format.length === 1) { output = parseStandardFormats.call(this, format); if (output) { return output; } } var parseFormatStrings = parseFormatStringsClosure(this); return format ? format.replace(/((\\)?(dd?d?d?|MM?M?M?|yy?y?y?|hh?|HH?|mm?|ss?|tt?|S|q|Q|WW?W?W?)(?![^\[]*\]))/g, parseFormatStrings).replace(/\[|\]/g, "") : this._toString(); }; }()); /************************************************************* * SugarPak - Domain Specific Language - Syntactical Sugar * *************************************************************/ (function () { var $D = Date, $P = $D.prototype, $N = Number.prototype; // private $P._orient = +1; // private $P._nth = null; // private $P._is = false; // private $P._same = false; // private $P._isSecond = false; // private $N._dateElement = "days"; /** * Moves the date to the next instance of a date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.today().next().friday();
	Date.today().next().fri();
	Date.today().next().march();
	Date.today().next().mar();
	Date.today().next().week();
	
* * @return {Date} date */ $P.next = function () { this._move = true; this._orient = +1; return this; }; /** * Creates a new Date (Date.today()) and moves the date to the next instance of the date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.next().friday();
	Date.next().fri();
	Date.next().march();
	Date.next().mar();
	Date.next().week();
	
* * @return {Date} date */ $D.next = function () { return $D.today().next(); }; /** * Moves the date to the previous instance of a date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.today().last().friday();
	Date.today().last().fri();
	Date.today().last().march();
	Date.today().last().mar();
	Date.today().last().week();
	
* * @return {Date} date */ $P.last = $P.prev = $P.previous = function () { this._move = true; this._orient = -1; return this; }; /** * Creates a new Date (Date.today()) and moves the date to the previous instance of the date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.last().friday();
	Date.last().fri();
	Date.previous().march();
	Date.prev().mar();
	Date.last().week();
	
* * @return {Date} date */ $D.last = $D.prev = $D.previous = function () { return $D.today().last(); }; /** * Performs a equality check when followed by either a month name, day name or .weekday() function. * Example

	Date.today().is().friday(); // true|false
	Date.today().is().fri();
	Date.today().is().march();
	Date.today().is().mar();
	
* * @return {Boolean} true|false */ $P.is = function () { this._is = true; return this; }; /** * Determines if two date objects occur on/in exactly the same instance of the subsequent date part function. * The function .same() must be followed by a date part function (example: .day(), .month(), .year(), etc). * * An optional Date can be passed in the date part function. If now date is passed as a parameter, 'Now' is used. * * The following example demonstrates how to determine if two dates fall on the exact same day. * * Example

	var d1 = Date.today(); // today at 00:00
	var d2 = new Date();   // exactly now.

	// Do they occur on the same day?
	d1.same().day(d2); // true
	
	// Do they occur on the same hour?
	d1.same().hour(d2); // false, unless d2 hour is '00' (midnight).
	
	// What if it's the same day, but one year apart?
	var nextYear = Date.today().add(1).year();

	d1.same().day(nextYear); // false, because the dates must occur on the exact same day. 
	
* * Scenario: Determine if a given date occurs during some week period 2 months from now. * * Example

	var future = Date.today().add(2).months();
	return someDate.same().week(future); // true|false;
	
* * @return {Boolean} true|false */ $P.same = function () { this._same = true; this._isSecond = false; return this; }; /** * Determines if the current date/time occurs during Today. Must be preceded by the .is() function. * Example

	someDate.is().today();    // true|false
	new Date().is().today();  // true
	Date.today().is().today();// true
	Date.today().add(-1).day().is().today(); // false
	
* * @return {Boolean} true|false */ $P.today = function () { return this.same().day(); }; /** * Determines if the current date is a weekday. This function must be preceded by the .is() function. * Example

	Date.today().is().weekday(); // true|false
	
* * @return {Boolean} true|false */ $P.weekday = function () { if (this._nth) { return df("Weekday").call(this); } if (this._move) { return this.addWeekdays(this._orient); } if (this._is) { this._is = false; return (!this.is().sat() && !this.is().sun()); } return false; }; /** * Determines if the current date is on the weekend. This function must be preceded by the .is() function. * Example

	Date.today().is().weekend(); // true|false
	
* * @return {Boolean} true|false */ $P.weekend = function () { if (this._is) { this._is = false; return (this.is().sat() || this.is().sun()); } return false; }; /** * Sets the Time of the current Date instance. A string "6:15 pm" or config object {hour:18, minute:15} are accepted. * Example

	// Set time to 6:15pm with a String
	Date.today().at("6:15pm");

	// Set time to 6:15pm with a config object
	Date.today().at({hour:18, minute:15});
	
* * @return {Date} date */ $P.at = function (time) { return (typeof time === "string") ? $D.parse(this.toString("d") + " " + time) : this.set(time); }; /** * Creates a new Date() and adds this (Number) to the date based on the preceding date element function (eg. second|minute|hour|day|month|year). * Example

	// Undeclared Numbers must be wrapped with parentheses. Requirment of JavaScript.
	(3).days().fromNow();
	(6).months().fromNow();

	// Declared Number variables do not require parentheses. 
	var n = 6;
	n.months().fromNow();
	
* * @return {Date} A new Date instance */ $N.fromNow = $N.after = function (date) { var c = {}; c[this._dateElement] = this; return ((!date) ? new Date() : date.clone()).add(c); }; /** * Creates a new Date() and subtract this (Number) from the date based on the preceding date element function (eg. second|minute|hour|day|month|year). * Example

	// Undeclared Numbers must be wrapped with parentheses. Requirment of JavaScript.
	(3).days().ago();
	(6).months().ago();

	// Declared Number variables do not require parentheses. 
	var n = 6;
	n.months().ago();
	
* * @return {Date} A new Date instance */ $N.ago = $N.before = function (date) { var c = {}, s = (this._dateElement[this._dateElement.length-1] !== "s") ? this._dateElement + "s" : this._dateElement; c[s] = this * -1; return ((!date) ? new Date() : date.clone()).add(c); }; // Do NOT modify the following string tokens. These tokens are used to build dynamic functions. // All culture-specific strings can be found in the CultureInfo files. var dx = ("sunday monday tuesday wednesday thursday friday saturday").split(/\s/), mx = ("january february march april may june july august september october november december").split(/\s/), px = ("Millisecond Second Minute Hour Day Week Month Year Quarter Weekday").split(/\s/), pxf = ("Milliseconds Seconds Minutes Hours Date Week Month FullYear Quarter").split(/\s/), nth = ("final first second third fourth fifth").split(/\s/), de; /** * Returns an object literal of all the date parts. * Example

	var o = new Date().toObject();
	
	// { year: 2008, month: 4, week: 20, day: 13, hour: 18, minute: 9, second: 32, millisecond: 812 }
	
	// The object properties can be referenced directly from the object.
	
	alert(o.day);  // alerts "13"
	alert(o.year); // alerts "2008"
	
* * @return {Date} An object literal representing the original date object. */ $P.toObject = function () { var o = {}; for (var i = 0; i < px.length; i++) { if (this["get" + pxf[i]]) { o[px[i].toLowerCase()] = this["get" + pxf[i]](); } } return o; }; /** * Returns a date created from an object literal. Ignores the .week property if set in the config. * Example

	var o = new Date().toObject();
	
	return Date.fromObject(o); // will return the same date. 

	var o2 = {month: 1, day: 20, hour: 18}; // birthday party!
	Date.fromObject(o2);
	
* * @return {Date} An object literal representing the original date object. */ $D.fromObject = function(config) { config.week = null; return Date.today().set(config); }; // Create day name functions and abbreviated day name functions (eg. monday(), friday(), fri()). var df = function (n) { return function () { if (this._is) { this._is = false; return this.getDay() === n; } if (this._move) { this._move = null; } if (this._nth !== null) { // If the .second() function was called earlier, remove the _orient // from the date, and then continue. // This is required because 'second' can be used in two different context. // // Example // // Date.today().add(1).second(); // Date.march().second().monday(); // // Things get crazy with the following... // Date.march().add(1).second().second().monday(); // but it works!! // if (this._isSecond) { this.addSeconds(this._orient * -1); } // make sure we reset _isSecond this._isSecond = false; var ntemp = this._nth; this._nth = null; var temp = this.clone().moveToLastDayOfMonth(); this.moveToNthOccurrence(n, ntemp); if (this > temp) { throw new RangeError($D.getDayName(n) + " does not occur " + ntemp + " times in the month of " + $D.getMonthName(temp.getMonth()) + " " + temp.getFullYear() + "."); } return this; } return this.moveToDayOfWeek(n, this._orient); }; }; var sdf = function (n) { return function () { var t = $D.today(), shift = n - t.getDay(); if (n === 0 && Date.CultureInfo.firstDayOfWeek === 1 && t.getDay() !== 0) { shift = shift + 7; } return t.addDays(shift); }; }; // Create month name functions and abbreviated month name functions (eg. january(), march(), mar()). var month_instance_functions = function (n) { return function () { if (this._is) { this._is = false; return this.getMonth() === n; } return this.moveToMonth(n, this._orient); }; }; var month_static_functions = function (n) { return function () { return $D.today().set({ month: n, day: 1 }); }; }; var processTerms = function (names, staticFunc, instanceFunc) { for (var i = 0; i < names.length; i++) { // Create constant static Name variables. $D[names[i].toUpperCase()] = $D[names[i].toUpperCase().substring(0, 3)] = i; // Create Name functions. $D[names[i]] = $D[names[i].substring(0, 3)] = staticFunc(i); // Create Name instance functions. $P[names[i]] = $P[names[i].substring(0, 3)] = instanceFunc(i); } }; processTerms(dx, sdf, df); processTerms(mx, month_static_functions, month_instance_functions); // Create date element functions and plural date element functions used with Date (eg. day(), days(), months()). var ef = function (j) { return function () { // if the .second() function was called earlier, the _orient // has alread been added. Just return this and reset _isSecond. if (this._isSecond) { this._isSecond = false; return this; } if (this._same) { this._same = this._is = false; var o1 = this.toObject(), o2 = (arguments[0] || new Date()).toObject(), v = "", k = j.toLowerCase(); // the substr trick with -1 doesn't work in IE8 or less k = (k[k.length-1] === "s") ? k.substring(0,k.length-1) : k; for (var m = (px.length - 1); m > -1; m--) { v = px[m].toLowerCase(); if (o1[v] !== o2[v]) { return false; } if (k === v) { break; } } return true; } if (j.substring(j.length - 1) !== "s") { j += "s"; } if (this._move) { this._move = null; } return this["add" + j](this._orient); }; }; var nf = function (n) { return function () { this._dateElement = n; return this; }; }; for (var k = 0; k < px.length; k++) { de = px[k].toLowerCase(); if(de !== "weekday") { // Create date element functions and plural date element functions used with Date (eg. day(), days(), months()). $P[de] = $P[de + "s"] = ef(px[k]); // Create date element functions and plural date element functions used with Number (eg. day(), days(), months()). $N[de] = $N[de + "s"] = nf(de + "s"); } } $P._ss = ef("Second"); var nthfn = function (n) { return function (dayOfWeek) { if (this._same) { return this._ss(arguments[0]); } if (dayOfWeek || dayOfWeek === 0) { return this.moveToNthOccurrence(dayOfWeek, n); } this._nth = n; // if the operator is 'second' add the _orient, then deal with it later... if (n === 2 && (dayOfWeek === undefined || dayOfWeek === null)) { this._isSecond = true; return this.addSeconds(this._orient); } return this; }; }; for (var l = 0; l < nth.length; l++) { $P[nth[l]] = (l === 0) ? nthfn(-1) : nthfn(l); } }()); (function () { "use strict"; Date.Parsing = { Exception: function (s) { this.message = "Parse error at '" + s.substring(0, 10) + " ...'"; } }; var $P = Date.Parsing; var dayOffsets = { standard: [0,31,59,90,120,151,181,212,243,273,304,334], leap: [0,31,60,91,121,152,182,213,244,274,305,335] }; $P.isLeapYear = function(year) { return ((year % 4 === 0) && (year % 100 !== 0)) || (year % 400 === 0); }; var utils = { multiReplace : function (str, hash ) { var key; for (key in hash) { if (Object.prototype.hasOwnProperty.call(hash, key)) { var regex; if (typeof hash[key] === "function") { } else { regex = (hash[key] instanceof RegExp) ? hash[key] : new RegExp(hash[key], "g"); } str = str.replace(regex, key); } } return str; }, getDayOfYearFromWeek : function (obj) { var d, jan4, offset; obj.weekDay = (!obj.weekDay && obj.weekDay !== 0) ? 1 : obj.weekDay; d = new Date(obj.year, 0, 4); jan4 = d.getDay() === 0 ? 7 : d.getDay(); // JS is 0 indexed on Sunday. offset = jan4+3; obj.dayOfYear = ((obj.week * 7) + (obj.weekDay === 0 ? 7 : obj.weekDay))-offset; return obj; }, getDayOfYear : function (obj, dayOffset) { if (!obj.dayOfYear) { obj = utils.getDayOfYearFromWeek(obj); } for (var i=0;i <= dayOffset.length;i++) { if (obj.dayOfYear < dayOffset[i] || i === dayOffset.length) { obj.day = obj.day ? obj.day : (obj.dayOfYear - dayOffset[i-1]); break; } else { obj.month = i; } } return obj; }, adjustForTimeZone : function (obj, date) { var offset; if (obj.zone.toUpperCase() === "Z" || (obj.zone_hours === 0 && obj.zone_minutes === 0)) { // it's UTC/GML so work out the current timeszone offset offset = -date.getTimezoneOffset(); } else { offset = (obj.zone_hours*60) + (obj.zone_minutes || 0); if (obj.zone_sign === "+") { offset *= -1; } offset -= date.getTimezoneOffset(); } date.setMinutes(date.getMinutes()+offset); return date; }, setDefaults : function (obj) { obj.year = obj.year || Date.today().getFullYear(); obj.hours = obj.hours || 0; obj.minutes = obj.minutes || 0; obj.seconds = obj.seconds || 0; obj.milliseconds = obj.milliseconds || 0; if (!(!obj.month && (obj.week || obj.dayOfYear))) { // if we have a month, or if we don't but don't have the day calculation data obj.month = obj.month || 0; obj.day = obj.day || 1; } return obj; }, dataNum: function (data, mod, explict, postProcess) { var dataNum = data*1; if (mod) { if (postProcess) { return data ? mod(data)*1 : data; } else { return data ? mod(dataNum) : data; } } else if (!explict){ return data ? dataNum : data; } else { return (data && typeof data !== "undefined") ? dataNum : data; } }, timeDataProcess: function (obj) { var timeObj = {}; for (var x in obj.data) { if (obj.data.hasOwnProperty(x)) { timeObj[x] = obj.ignore[x] ? obj.data[x] : utils.dataNum(obj.data[x], obj.mods[x], obj.explict[x], obj.postProcess[x]); } } if (obj.data.secmins) { obj.data.secmins = obj.data.secmins.replace(",", ".") * 60; if (!timeObj.minutes) { timeObj.minutes = obj.data.secmins; } else if (!timeObj.seconds) { timeObj.seconds = obj.data.secmins; } delete obj.secmins; } return timeObj; }, buildTimeObjectFromData: function (data) { var time = utils.timeDataProcess({ data: { year : data[1], month : data[5], day : data[7], week : data[8], dayOfYear : data[10], hours : data[15], zone_hours : data[23], zone_minutes : data[24], zone : data[21], zone_sign : data[22], weekDay : data[9], minutes: data[16], seconds: data[19], milliseconds: data[20], secmins: data[18] }, mods: { month: function(data) { return data-1; }, weekDay: function (data) { data = Math.abs(data); return (data === 7 ? 0 : data); }, minutes: function (data) { return data.replace(":",""); }, seconds: function (data) { return Math.floor( (data.replace(":","").replace(",","."))*1 ); }, milliseconds: function (data) { return (data.replace(",",".")*1000); } }, postProcess: { minutes: true, seconds: true, milliseconds: true }, explict: { zone_hours: true, zone_minutes: true }, ignore: { zone: true, zone_sign: true, secmins: true } }); return time; }, addToHash: function (hash, keys, data) { keys = keys; data = data; var len = keys.length; for (var i = 0; i < len; i++) { hash[keys[i]] = data[i]; } return hash; }, combineRegex: function (r1, r2) { return new RegExp("(("+r1.source+")\\s("+r2.source+"))"); }, getDateNthString: function(add, last, inc){ if (add) { return Date.today().addDays(inc).toString("d"); } else if (last) { return Date.today().last()[inc]().toString("d"); } }, buildRegexData: function (array) { var arr = []; var len = array.length; for (var i=0; i < len; i++) { if (Object.prototype.toString.call(array[i]) === '[object Array]') { // oldIE compat version of Array.isArray arr.push(this.combineRegex(array[i][0], array[i][1])); } else { arr.push(array[i]); } } return arr; } }; $P.processTimeObject = function (obj) { var date, dayOffset; utils.setDefaults(obj); dayOffset = ($P.isLeapYear(obj.year)) ? dayOffsets.leap : dayOffsets.standard; if (!obj.month && (obj.week || obj.dayOfYear)) { utils.getDayOfYear(obj, dayOffset); } else { obj.dayOfYear = dayOffset[obj.month] + obj.day; } date = new Date(obj.year, obj.month, obj.day, obj.hours, obj.minutes, obj.seconds, obj.milliseconds); if (obj.zone) { utils.adjustForTimeZone(obj, date); // adjust (and calculate) for timezone } return date; }; $P.ISO = { regex : /^([\+-]?\d{4}(?!\d{2}\b))((-?)((0[1-9]|1[0-2])(\3([12]\d|0[1-9]|3[01]))?|W([0-4]\d|5[0-3])(-?[1-7])?|(00[1-9]|0[1-9]\d|[12]\d{2}|3([0-5]\d|6[1-6])))([T\s]((([01]\d|2[0-4])((:?)[0-5]\d)?|24\:?00)([\.,]\d+(?!:))?)?(\17[0-5]\d([\.,]\d+)?)?\s?([zZ]|([\+-])([01]\d|2[0-3]):?([0-5]\d)?)?)?)?$/, parse : function (s) { var time, data = s.match(this.regex); if (!data || !data.length) { return null; } time = utils.buildTimeObjectFromData(data); if (!time.year || (!time.year && (!time.month && !time.day) && (!time.week && !time.dayOfYear)) ) { return null; } return $P.processTimeObject(time); } }; $P.Numeric = { isNumeric: function (e){return!isNaN(parseFloat(e))&&isFinite(e);}, regex: /\b([0-1]?[0-9])([0-3]?[0-9])([0-2]?[0-9]?[0-9][0-9])\b/i, parse: function (s) { var data, i, time = {}, order = Date.CultureInfo.dateElementOrder.split(""); if (!(this.isNumeric(s)) || // if it's non-numeric OR (s[0] === "+" && s[0] === "-")) { // It's an arithmatic string (eg +/-1000) return null; } if (s.length < 5 && s.indexOf(".") < 0 && s.indexOf("/") < 0) { // assume it's just a year. time.year = s; return $P.processTimeObject(time); } data = s.match(this.regex); if (!data || !data.length) { return null; } for (i=0; i < order.length; i++) { switch(order[i]) { case "d": time.day = data[i+1]; break; case "m": time.month = (data[i+1]-1); break; case "y": time.year = data[i+1]; break; } } return $P.processTimeObject(time); } }; $P.Normalizer = { regexData: function () { var $R = Date.CultureInfo.regexPatterns; return utils.buildRegexData([ $R.tomorrow, $R.yesterday, [$R.past, $R.mon], [$R.past, $R.tue], [$R.past, $R.wed], [$R.past, $R.thu], [$R.past, $R.fri], [$R.past, $R.sat], [$R.past, $R.sun] ]); }, basicReplaceHash : function() { var $R = Date.CultureInfo.regexPatterns; return { "January": $R.jan.source, "February": $R.feb, "March": $R.mar, "April": $R.apr, "May": $R.may, "June": $R.jun, "July": $R.jul, "August": $R.aug, "September": $R.sep, "October": $R.oct, "November": $R.nov, "December": $R.dec, "": /\bat\b/gi, " ": /\s{2,}/, "am": $R.inTheMorning, "9am": $R.thisMorning, "pm": $R.inTheEvening, "7pm":$R.thisEvening }; }, keys : function(){ return [ utils.getDateNthString(true, false, 1), // tomorrow utils.getDateNthString(true, false, -1), // yesterday utils.getDateNthString(false, true, "monday"), //last mon utils.getDateNthString(false, true, "tuesday"), //last tues utils.getDateNthString(false, true, "wednesday"), //last wed utils.getDateNthString(false, true, "thursday"), //last thurs utils.getDateNthString(false, true, "friday"), //last fri utils.getDateNthString(false, true, "saturday"), //last sat utils.getDateNthString(false, true, "sunday") //last sun ]; }, buildRegexFunctions: function () { var $R = Date.CultureInfo.regexPatterns; var __ = Date.i18n.__; var tomorrowRE = new RegExp("(\\b\\d\\d?("+__("AM")+"|"+__("PM")+")? )("+$R.tomorrow.source.slice(1)+")", "i"); // adapted tomorrow regex for AM PM relative dates var todayRE = new RegExp($R.today.source + "(?!\\s*([+-]))\\b"); // today, but excludes the math operators (eg "today + 2h") this.replaceFuncs = [ [todayRE, function (full) { return (full.length > 1) ? Date.today().toString("d") : full; }], [tomorrowRE, function(full, m1) { var t = Date.today().addDays(1).toString("d"); return (t + " " + m1); }], [$R.amThisMorning, function(str, am){return am;}], [$R.pmThisEvening, function(str, pm){return pm;}] ]; }, buildReplaceData: function () { this.buildRegexFunctions(); this.replaceHash = utils.addToHash(this.basicReplaceHash(), this.keys(), this.regexData()); }, stringReplaceFuncs: function (s) { for (var i=0; i < this.replaceFuncs.length; i++) { s = s.replace(this.replaceFuncs[i][0], this.replaceFuncs[i][1]); } return s; }, parse: function (s) { s = this.stringReplaceFuncs(s); s = utils.multiReplace(s, this.replaceHash); try { var n = s.split(/([\s\-\.\,\/\x27]+)/); if (n.length === 3 && $P.Numeric.isNumeric(n[0]) && $P.Numeric.isNumeric(n[2]) && (n[2].length >= 4)) { // ok, so we're dealing with x/year. But that's not a full date. // This fixes wonky dateElementOrder parsing when set to dmy order. if (Date.CultureInfo.dateElementOrder[0] === "d") { s = "1/" + n[0] + "/" + n[2]; // set to 1st of month and normalize the seperator } } } catch (e) {} return s; } }; $P.Normalizer.buildReplaceData(); }()); (function () { var $P = Date.Parsing; var _ = $P.Operators = { // // Tokenizers // rtoken: function (r) { // regex token return function (s) { var mx = s.match(r); if (mx) { return ([ mx[0], s.substring(mx[0].length) ]); } else { throw new $P.Exception(s); } }; }, token: function () { // whitespace-eating token return function (s) { return _.rtoken(new RegExp("^\\s*" + s + "\\s*"))(s); }; }, stoken: function (s) { // string token return _.rtoken(new RegExp("^" + s)); }, // Atomic Operators until: function (p) { return function (s) { var qx = [], rx = null; while (s.length) { try { rx = p.call(this, s); } catch (e) { qx.push(rx[0]); s = rx[1]; continue; } break; } return [ qx, s ]; }; }, many: function (p) { return function (s) { var rx = [], r = null; while (s.length) { try { r = p.call(this, s); } catch (e) { return [ rx, s ]; } rx.push(r[0]); s = r[1]; } return [ rx, s ]; }; }, // generator operators -- see below optional: function (p) { return function (s) { var r = null; try { r = p.call(this, s); } catch (e) { return [ null, s ]; } return [ r[0], r[1] ]; }; }, not: function (p) { return function (s) { try { p.call(this, s); } catch (e) { return [null, s]; } throw new $P.Exception(s); }; }, ignore: function (p) { return p ? function (s) { var r = null; r = p.call(this, s); return [null, r[1]]; } : null; }, product: function () { var px = arguments[0], qx = Array.prototype.slice.call(arguments, 1), rx = []; for (var i = 0 ; i < px.length ; i++) { rx.push(_.each(px[i], qx)); } return rx; }, cache: function (rule) { var cache = {}, cache_length = 0, cache_keys = [], CACHE_MAX = Date.Config.CACHE_MAX || 100000, r = null; var cacheCheck = function () { if (cache_length === CACHE_MAX) { // kill several keys, don't want to have to do this all the time... for (var i=0; i < 10; i++) { var key = cache_keys.shift(); if (key) { delete cache[key]; cache_length--; } } } }; return function (s) { cacheCheck(); try { r = cache[s] = (cache[s] || rule.call(this, s)); } catch (e) { r = cache[s] = e; } cache_length++; cache_keys.push(s); if (r instanceof $P.Exception) { throw r; } else { return r; } }; }, // vector operators -- see below any: function () { var px = arguments; return function (s) { var r = null; for (var i = 0; i < px.length; i++) { if (px[i] == null) { continue; } try { r = (px[i].call(this, s)); } catch (e) { r = null; } if (r) { return r; } } throw new $P.Exception(s); }; }, each: function () { var px = arguments; return function (s) { var rx = [], r = null; for (var i = 0; i < px.length ; i++) { if (px[i] == null) { continue; } try { r = (px[i].call(this, s)); } catch (e) { throw new $P.Exception(s); } rx.push(r[0]); s = r[1]; } return [ rx, s]; }; }, all: function () { var px = arguments, _ = _; return _.each(_.optional(px)); }, // delimited operators sequence: function (px, d, c) { d = d || _.rtoken(/^\s*/); c = c || null; if (px.length === 1) { return px[0]; } return function (s) { var r = null, q = null; var rx = []; for (var i = 0; i < px.length ; i++) { try { r = px[i].call(this, s); } catch (e) { break; } rx.push(r[0]); try { q = d.call(this, r[1]); } catch (ex) { q = null; break; } s = q[1]; } if (!r) { throw new $P.Exception(s); } if (q) { throw new $P.Exception(q[1]); } if (c) { try { r = c.call(this, r[1]); } catch (ey) { throw new $P.Exception(r[1]); } } return [ rx, (r?r[1]:s) ]; }; }, // // Composite Operators // between: function (d1, p, d2) { d2 = d2 || d1; var _fn = _.each(_.ignore(d1), p, _.ignore(d2)); return function (s) { var rx = _fn.call(this, s); return [[rx[0][0], r[0][2]], rx[1]]; }; }, list: function (p, d, c) { d = d || _.rtoken(/^\s*/); c = c || null; return (p instanceof Array ? _.each(_.product(p.slice(0, -1), _.ignore(d)), p.slice(-1), _.ignore(c)) : _.each(_.many(_.each(p, _.ignore(d))), px, _.ignore(c))); }, set: function (px, d, c) { d = d || _.rtoken(/^\s*/); c = c || null; return function (s) { // r is the current match, best the current 'best' match // which means it parsed the most amount of input var r = null, p = null, q = null, rx = null, best = [[], s], last = false; // go through the rules in the given set for (var i = 0; i < px.length ; i++) { // last is a flag indicating whether this must be the last element // if there is only 1 element, then it MUST be the last one q = null; p = null; r = null; last = (px.length === 1); // first, we try simply to match the current pattern // if not, try the next pattern try { r = px[i].call(this, s); } catch (e) { continue; } // since we are matching against a set of elements, the first // thing to do is to add r[0] to matched elements rx = [[r[0]], r[1]]; // if we matched and there is still input to parse and // we don't already know this is the last element, // we're going to next check for the delimiter ... // if there's none, or if there's no input left to parse // than this must be the last element after all ... if (r[1].length > 0 && ! last) { try { q = d.call(this, r[1]); } catch (ex) { last = true; } } else { last = true; } // if we parsed the delimiter and now there's no more input, // that means we shouldn't have parsed the delimiter at all // so don't update r and mark this as the last element ... if (!last && q[1].length === 0) { last = true; } // so, if this isn't the last element, we're going to see if // we can get any more matches from the remaining (unmatched) // elements ... if (!last) { // build a list of the remaining rules we can match against, // i.e., all but the one we just matched against var qx = []; for (var j = 0; j < px.length ; j++) { if (i !== j) { qx.push(px[j]); } } // now invoke recursively set with the remaining input // note that we don't include the closing delimiter ... // we'll check for that ourselves at the end p = _.set(qx, d).call(this, q[1]); // if we got a non-empty set as a result ... // (otw rx already contains everything we want to match) if (p[0].length > 0) { // update current result, which is stored in rx ... // basically, pick up the remaining text from p[1] // and concat the result from p[0] so that we don't // get endless nesting ... rx[0] = rx[0].concat(p[0]); rx[1] = p[1]; } } // at this point, rx either contains the last matched element // or the entire matched set that starts with this element. // now we just check to see if this variation is better than // our best so far, in terms of how much of the input is parsed if (rx[1].length < best[1].length) { best = rx; } // if we've parsed all the input, then we're finished if (best[1].length === 0) { break; } } // so now we've either gone through all the patterns trying them // as the initial match; or we found one that parsed the entire // input string ... // if best has no matches, just return empty set ... if (best[0].length === 0) { return best; } // if a closing delimiter is provided, then we have to check it also if (c) { // we try this even if there is no remaining input because the pattern // may well be optional or match empty input ... try { q = c.call(this, best[1]); } catch (ey) { throw new $P.Exception(best[1]); } // it parsed ... be sure to update the best match remaining input best[1] = q[1]; } // if we're here, either there was no closing delimiter or we parsed it // so now we have the best match; just return it! return best; }; }, forward: function (gr, fname) { return function (s) { return gr[fname].call(this, s); }; }, // // Translation Operators // replace: function (rule, repl) { return function (s) { var r = rule.call(this, s); return [repl, r[1]]; }; }, process: function (rule, fn) { return function (s) { var r = rule.call(this, s); return [fn.call(this, r[0]), r[1]]; }; }, min: function (min, rule) { return function (s) { var rx = rule.call(this, s); if (rx[0].length < min) { throw new $P.Exception(s); } return rx; }; } }; // Generator Operators And Vector Operators // Generators are operators that have a signature of F(R) => R, // taking a given rule and returning another rule, such as // ignore, which parses a given rule and throws away the result. // Vector operators are those that have a signature of F(R1,R2,...) => R, // take a list of rules and returning a new rule, such as each. // Generator operators are converted (via the following _generator // function) into functions that can also take a list or array of rules // and return an array of new rules as though the function had been // called on each rule in turn (which is what actually happens). // This allows generators to be used with vector operators more easily. // Example: // each(ignore(foo, bar)) instead of each(ignore(foo), ignore(bar)) // This also turns generators into vector operators, which allows // constructs like: // not(cache(foo, bar)) var _generator = function (op) { function gen() { var args = null, rx = [], px, i; if (arguments.length > 1) { args = Array.prototype.slice.call(arguments); } else if (arguments[0] instanceof Array) { args = arguments[0]; } if (args) { px = args.shift(); if (px.length > 0) { args.unshift(px[i]); rx.push(op.apply(null, args)); args.shift(); return rx; } } else { return op.apply(null, arguments); } } return gen; }; var gx = "optional not ignore cache".split(/\s/); for (var i = 0 ; i < gx.length ; i++) { _[gx[i]] = _generator(_[gx[i]]); } var _vector = function (op) { return function () { if (arguments[0] instanceof Array) { return op.apply(null, arguments[0]); } else { return op.apply(null, arguments); } }; }; var vx = "each any all".split(/\s/); for (var j = 0 ; j < vx.length ; j++) { _[vx[j]] = _vector(_[vx[j]]); } }()); (function () { var $D = Date; var flattenAndCompact = function (ax) { var rx = []; for (var i = 0; i < ax.length; i++) { if (ax[i] instanceof Array) { rx = rx.concat(flattenAndCompact(ax[i])); } else { if (ax[i]) { rx.push(ax[i]); } } } return rx; }; var parseMeridian = function () { if (this.meridian && (this.hour || this.hour === 0)) { if (this.meridian === "a" && this.hour > 11 && Date.Config.strict24hr){ throw "Invalid hour and meridian combination"; } else if (this.meridian === "p" && this.hour < 12 && Date.Config.strict24hr){ throw "Invalid hour and meridian combination"; } else if (this.meridian === "p" && this.hour < 12) { this.hour = this.hour + 12; } else if (this.meridian === "a" && this.hour === 12) { this.hour = 0; } } }; var setDefaults = function () { var now = new Date(); if ((this.hour || this.minute) && (!this.month && !this.year && !this.day)) { this.day = now.getDate(); } if (!this.year) { this.year = now.getFullYear(); } if (!this.month && this.month !== 0) { this.month = now.getMonth(); } if (!this.day) { this.day = 1; } if (!this.hour) { this.hour = 0; } if (!this.minute) { this.minute = 0; } if (!this.second) { this.second = 0; } if (!this.millisecond) { this.millisecond = 0; } }; var finishUtils = { getToday: function () { if (this.now || "hour minute second".indexOf(this.unit) !== -1) { return new Date(); } else { return $D.today(); } }, setDaysFromWeekday: function (today, orient){ var gap; orient = orient || 1; this.unit = "day"; gap = ($D.getDayNumberFromName(this.weekday) - today.getDay()); this.days = gap ? ((gap + (orient * 7)) % 7) : (orient * 7); return this; }, setMonthsFromMonth: function (today, orient) { var gap; orient = orient || 1; this.unit = "month"; gap = (this.month - today.getMonth()); this.months = gap ? ((gap + (orient * 12)) % 12) : (orient * 12); this.month = null; return this; }, setDMYFromWeekday: function () { var d = Date[this.weekday](); this.day = d.getDate(); if (!this.month) { this.month = d.getMonth(); } this.year = d.getFullYear(); return this; }, setUnitValue: function (orient) { if (!this.value && this.operator && this.operator !== null && this[this.unit + "s"] && this[this.unit + "s"] !== null) { this[this.unit + "s"] = this[this.unit + "s"] + ((this.operator === "add") ? 1 : -1) + (this.value||0) * orient; } else if (this[this.unit + "s"] == null || this.operator != null) { if (!this.value) { this.value = 1; } this[this.unit + "s"] = this.value * orient; } }, generateDateFromWeeks: function () { var weekday = (this.weekday !== undefined) ? this.weekday : "today"; var d = Date[weekday]().addWeeks(this.weeks); if (this.now) { d.setTimeToNow(); } return d; } }; $D.Translator = { hour: function (s) { return function () { this.hour = Number(s); }; }, minute: function (s) { return function () { this.minute = Number(s); }; }, second: function (s) { return function () { this.second = Number(s); }; }, /* for ss.s format */ secondAndMillisecond: function (s) { return function () { var mx = s.match(/^([0-5][0-9])\.([0-9]{1,3})/); this.second = Number(mx[1]); this.millisecond = Number(mx[2]); }; }, meridian: function (s) { return function () { this.meridian = s.slice(0, 1).toLowerCase(); }; }, timezone: function (s) { return function () { var n = s.replace(/[^\d\+\-]/g, ""); if (n.length) { this.timezoneOffset = Number(n); } else { this.timezone = s.toLowerCase(); } }; }, day: function (x) { var s = x[0]; return function () { this.day = Number(s.match(/\d+/)[0]); if (this.day < 1) { throw "invalid day"; } }; }, month: function (s) { return function () { this.month = (s.length === 3) ? "jan feb mar apr may jun jul aug sep oct nov dec".indexOf(s)/4 : Number(s) - 1; if (this.month < 0) { throw "invalid month"; } }; }, year: function (s) { return function () { var n = Number(s); this.year = ((s.length > 2) ? n : (n + (((n + 2000) < Date.CultureInfo.twoDigitYearMax) ? 2000 : 1900))); }; }, rday: function (s) { return function () { switch (s) { case "yesterday": this.days = -1; break; case "tomorrow": this.days = 1; break; case "today": this.days = 0; break; case "now": this.days = 0; this.now = true; break; } }; }, finishExact: function (x) { var d; x = (x instanceof Array) ? x : [x]; for (var i = 0 ; i < x.length ; i++) { if (x[i]) { x[i].call(this); } } setDefaults.call(this); parseMeridian.call(this); if (this.day > $D.getDaysInMonth(this.year, this.month)) { throw new RangeError(this.day + " is not a valid value for days."); } d = new Date(this.year, this.month, this.day, this.hour, this.minute, this.second, this.millisecond); if (this.year < 100) { d.setFullYear(this.year); // means years less that 100 are process correctly. JS will parse it otherwise as 1900-1999. } if (this.timezone) { d.set({ timezone: this.timezone }); } else if (this.timezoneOffset) { d.set({ timezoneOffset: this.timezoneOffset }); } return d; }, finish: function (x) { var today, expression, orient, temp; x = (x instanceof Array) ? flattenAndCompact(x) : [ x ]; if (x.length === 0) { return null; } for (var i = 0 ; i < x.length ; i++) { if (typeof x[i] === "function") { x[i].call(this); } } if (this.now && !this.unit && !this.operator) { return new Date(); } else { today = finishUtils.getToday.call(this); } expression = !!(this.days && this.days !== null || this.orient || this.operator); orient = ((this.orient === "past" || this.operator === "subtract") ? -1 : 1); if (this.month && this.unit === "week") { this.value = this.month + 1; delete this.month; delete this.day; } if ((this.month || this.month === 0) && "year day hour minute second".indexOf(this.unit) !== -1) { if (!this.value) { this.value = this.month + 1; } this.month = null; expression = true; } if (!expression && this.weekday && !this.day && !this.days) { finishUtils.setDMYFromWeekday.call(this); } if (expression && this.weekday && this.unit !== "month" && this.unit !== "week") { finishUtils.setDaysFromWeekday.call(this, today, orient); } if (this.weekday && this.unit !== "week" && !this.day && !this.days) { temp = Date[this.weekday](); this.day = temp.getDate(); if (temp.getMonth() !== today.getMonth()) { this.month = temp.getMonth(); } } if (this.month && this.unit === "day" && this.operator) { if (!this.value) { this.value = (this.month + 1); } this.month = null; } if (this.value != null && this.month != null && this.year != null) { this.day = this.value * 1; } if (this.month && !this.day && this.value) { today.set({ day: this.value * 1 }); if (!expression) { this.day = this.value * 1; } } if (!this.month && this.value && this.unit === "month" && !this.now) { this.month = this.value; expression = true; } if (expression && (this.month || this.month === 0) && this.unit !== "year") { finishUtils.setMonthsFromMonth.call(this, today, orient); } if (!this.unit) { this.unit = "day"; } finishUtils.setUnitValue.call(this, orient); parseMeridian.call(this); if ((this.month || this.month === 0) && !this.day) { this.day = 1; } if (!this.orient && !this.operator && this.unit === "week" && this.value && !this.day && !this.month) { return Date.today().setWeek(this.value); } if (this.unit === "week" && this.weeks && !this.day && !this.month) { return finishUtils.generateDateFromWeeks.call(this); } if (expression && this.timezone && this.day && this.days) { this.day = this.days; } if (expression){ today.add(this); } else { today.set(this); } if (this.timezone) { this.timezone = this.timezone.toUpperCase(); var offset = $D.getTimezoneOffset(this.timezone); var timezone; if (today.hasDaylightSavingTime()) { // lets check that we're being sane with timezone setting timezone = $D.getTimezoneAbbreviation(offset, today.isDaylightSavingTime()); if (timezone !== this.timezone) { // bugger, we're in a place where things like EST vs EDT matters. if (today.isDaylightSavingTime()) { today.addHours(-1); } else { today.addHours(1); } } } today.setTimezoneOffset(offset); } return today; } }; }()); (function () { var $D = Date; $D.Grammar = {}; var _ = $D.Parsing.Operators, g = $D.Grammar, t = $D.Translator, _fn; // Allow rolling up into general purpose rules _fn = function () { return _.each(_.any.apply(null, arguments), _.not(g.ctoken2("timeContext"))); }; g.datePartDelimiter = _.rtoken(/^([\s\-\.\,\/\x27]+)/); g.timePartDelimiter = _.stoken(":"); g.whiteSpace = _.rtoken(/^\s*/); g.generalDelimiter = _.rtoken(/^(([\s\,]|at|@|on)+)/); var _C = {}; g.ctoken = function (keys) { var fn = _C[keys]; if (! fn) { var c = Date.CultureInfo.regexPatterns; var kx = keys.split(/\s+/), px = []; for (var i = 0; i < kx.length ; i++) { px.push(_.replace(_.rtoken(c[kx[i]]), kx[i])); } fn = _C[keys] = _.any.apply(null, px); } return fn; }; g.ctoken2 = function (key) { return _.rtoken(Date.CultureInfo.regexPatterns[key]); }; var cacheProcessRtoken = function (key, token, type, eachToken) { if (eachToken) { g[key] = _.cache(_.process(_.each(_.rtoken(token),_.optional(g.ctoken2(eachToken))), type)); } else { g[key] = _.cache(_.process(_.rtoken(token), type)); } }; var cacheProcessCtoken = function (token, type) { return _.cache(_.process(g.ctoken2(token), type)); }; var _F = {}; //function cache var _get = function (f) { _F[f] = (_F[f] || g.format(f)[0]); return _F[f]; }; g.allformats = function (fx) { var rx = []; if (fx instanceof Array) { for (var i = 0; i < fx.length; i++) { rx.push(_get(fx[i])); } } else { rx.push(_get(fx)); } return rx; }; g.formats = function (fx) { if (fx instanceof Array) { var rx = []; for (var i = 0 ; i < fx.length ; i++) { rx.push(_get(fx[i])); } return _.any.apply(null, rx); } else { return _get(fx); } }; var grammarFormats = { timeFormats: function(){ var i, RTokenKeys = [ "h", "hh", "H", "HH", "m", "mm", "s", "ss", "ss.s", "z", "zz" ], RToken = [ /^(0[0-9]|1[0-2]|[1-9])/, /^(0[0-9]|1[0-2])/, /^([0-1][0-9]|2[0-3]|[0-9])/, /^([0-1][0-9]|2[0-3])/, /^([0-5][0-9]|[0-9])/, /^[0-5][0-9]/, /^([0-5][0-9]|[0-9])/, /^[0-5][0-9]/, /^[0-5][0-9]\.[0-9]{1,3}/, /^((\+|\-)\s*\d\d\d\d)|((\+|\-)\d\d\:?\d\d)/, /^((\+|\-)\s*\d\d\d\d)|((\+|\-)\d\d\:?\d\d)/ ], tokens = [ t.hour, t.hour, t.hour, t.hour, t.minute, t.minute, t.second, t.second, t.secondAndMillisecond, t.timezone, t.timezone ]; for (i=0; i < RTokenKeys.length; i++) { cacheProcessRtoken(RTokenKeys[i], RToken[i], tokens[i]); } g.hms = _.cache(_.sequence([g.H, g.m, g.s], g.timePartDelimiter)); g.t = cacheProcessCtoken("shortMeridian", t.meridian); g.tt = cacheProcessCtoken("longMeridian", t.meridian); g.zzz = cacheProcessCtoken("timezone", t.timezone); g.timeSuffix = _.each(_.ignore(g.whiteSpace), _.set([ g.tt, g.zzz ])); g.time = _.each(_.optional(_.ignore(_.stoken("T"))), g.hms, g.timeSuffix); }, dateFormats: function () { // pre-loaded rules for different date part order preferences var _setfn = function () { return _.set(arguments, g.datePartDelimiter); }; var i, RTokenKeys = [ "d", "dd", "M", "MM", "y", "yy", "yyy", "yyyy" ], RToken = [ /^([0-2]\d|3[0-1]|\d)/, /^([0-2]\d|3[0-1])/, /^(1[0-2]|0\d|\d)/, /^(1[0-2]|0\d)/, /^(\d+)/, /^(\d\d)/, /^(\d\d?\d?\d?)/, /^(\d\d\d\d)/ ], tokens = [ t.day, t.day, t.month, t.month, t.year, t.year, t.year, t.year ], eachToken = [ "ordinalSuffix", "ordinalSuffix" ]; for (i=0; i < RTokenKeys.length; i++) { cacheProcessRtoken(RTokenKeys[i], RToken[i], tokens[i], eachToken[i]); } g.MMM = g.MMMM = _.cache(_.process(g.ctoken("jan feb mar apr may jun jul aug sep oct nov dec"), t.month)); g.ddd = g.dddd = _.cache(_.process(g.ctoken("sun mon tue wed thu fri sat"), function (s) { return function () { this.weekday = s; }; } )); g.day = _fn(g.d, g.dd); g.month = _fn(g.M, g.MMM); g.year = _fn(g.yyyy, g.yy); g.mdy = _setfn(g.ddd, g.month, g.day, g.year); g.ymd = _setfn(g.ddd, g.year, g.month, g.day); g.dmy = _setfn(g.ddd, g.day, g.month, g.year); g.date = function (s) { return ((g[Date.CultureInfo.dateElementOrder] || g.mdy).call(this, s)); }; }, relative: function () { // relative date / time expressions g.orientation = _.process(g.ctoken("past future"), function (s) { return function () { this.orient = s; }; } ); g.operator = _.process(g.ctoken("add subtract"), function (s) { return function () { this.operator = s; }; } ); g.rday = _.process(g.ctoken("yesterday tomorrow today now"), t.rday); g.unit = _.process(g.ctoken("second minute hour day week month year"), function (s) { return function () { this.unit = s; }; } ); } }; g.buildGrammarFormats = function () { // these need to be rebuilt every time the language changes. _C = {}; grammarFormats.timeFormats(); grammarFormats.dateFormats(); grammarFormats.relative(); g.value = _.process(_.rtoken(/^([-+]?\d+)?(st|nd|rd|th)?/), function (s) { return function () { this.value = s.replace(/\D/g, ""); }; } ); g.expression = _.set([g.rday, g.operator, g.value, g.unit, g.orientation, g.ddd, g.MMM ]); g.format = _.process(_.many( _.any( // translate format specifiers into grammar rules _.process( _.rtoken(/^(dd?d?d?(?!e)|MM?M?M?|yy?y?y?|hh?|HH?|mm?|ss?|tt?|zz?z?)/), function (fmt) { if (g[fmt]) { return g[fmt]; } else { throw $D.Parsing.Exception(fmt); } } ), // translate separator tokens into token rules _.process(_.rtoken(/^[^dMyhHmstz]+/), // all legal separators function (s) { return _.ignore(_.stoken(s)); } ) ) ), // construct the parser ... function (rules) { return _.process(_.each.apply(null, rules), t.finishExact); } ); // starting rule for general purpose grammar g._start = _.process(_.set([ g.date, g.time, g.expression ], g.generalDelimiter, g.whiteSpace), t.finish); }; g.buildGrammarFormats(); // parsing date format specifiers - ex: "h:m:s tt" // this little guy will generate a custom parser based // on the format string, ex: g.format("h:m:s tt") // check for these formats first g._formats = g.formats([ "\"yyyy-MM-ddTHH:mm:ssZ\"", "yyyy-MM-ddTHH:mm:ss.sz", "yyyy-MM-ddTHH:mm:ssZ", "yyyy-MM-ddTHH:mm:ssz", "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-ddTHH:mmZ", "yyyy-MM-ddTHH:mmz", "yyyy-MM-ddTHH:mm", "ddd, MMM dd, yyyy H:mm:ss tt", "ddd MMM d yyyy HH:mm:ss zzz", "MMddyyyy", "ddMMyyyy", "Mddyyyy", "ddMyyyy", "Mdyyyy", "dMyyyy", "yyyy", "Mdyy", "dMyy", "d" ]); // real starting rule: tries selected formats first, // then general purpose rule g.start = function (s) { try { var r = g._formats.call({}, s); if (r[1].length === 0) { return r; } } catch (e) {} return g._start.call({}, s); }; }()); (function () { var $D = Date; /** * @desc Converts the specified string value into its JavaScript Date equivalent using CultureInfo specific format information. * * Example

	///////////
	// Dates //
	///////////

	// 15-Oct-2004
	var d1 = Date.parse("10/15/2004");

	// 15-Oct-2004
	var d1 = Date.parse("15-Oct-2004");

	// 15-Oct-2004
	var d1 = Date.parse("2004.10.15");

	//Fri Oct 15, 2004
	var d1 = Date.parse("Fri Oct 15, 2004");

	///////////
	// Times //
	///////////

	// Today at 10 PM.
	var d1 = Date.parse("10 PM");

	// Today at 10:30 PM.
	var d1 = Date.parse("10:30 P.M.");

	// Today at 6 AM.
	var d1 = Date.parse("06am");

	/////////////////////
	// Dates and Times //
	/////////////////////

	// 8-July-2004 @ 10:30 PM
	var d1 = Date.parse("July 8th, 2004, 10:30 PM");

	// 1-July-2004 @ 10:30 PM
	var d1 = Date.parse("2004-07-01T22:30:00");

	////////////////////
	// Relative Dates //
	////////////////////

	// Returns today's date. The string "today" is culture specific.
	var d1 = Date.parse("today");

	// Returns yesterday's date. The string "yesterday" is culture specific.
	var d1 = Date.parse("yesterday");

	// Returns the date of the next thursday.
	var d1 = Date.parse("Next thursday");

	// Returns the date of the most previous monday.
	var d1 = Date.parse("last monday");

	// Returns today's day + one year.
	var d1 = Date.parse("next year");

	///////////////
	// Date Math //
	///////////////

	// Today + 2 days
	var d1 = Date.parse("t+2");

	// Today + 2 days
	var d1 = Date.parse("today + 2 days");

	// Today + 3 months
	var d1 = Date.parse("t+3m");

	// Today - 1 year
	var d1 = Date.parse("today - 1 year");

	// Today - 1 year
	var d1 = Date.parse("t-1y"); 


	/////////////////////////////
	// Partial Dates and Times //
	/////////////////////////////

	// July 15th of this year.
	var d1 = Date.parse("July 15");

	// 15th day of current day and year.
	var d1 = Date.parse("15");

	// July 1st of current year at 10pm.
	var d1 = Date.parse("7/1 10pm");
	
* * @param {String} The string value to convert into a Date object [Required] * @return {Date} A Date object or null if the string cannot be converted into a Date. */ var parseUtils = { removeOrds: function (s) { ords = s.match(/\b(\d+)(?:st|nd|rd|th)\b/); // find ordinal matches s = ((ords && ords.length === 2) ? s.replace(ords[0], ords[1]) : s); return s; }, grammarParser: function (s) { var r = null; try { r = $D.Grammar.start.call({}, s.replace(/^\s*(\S*(\s+\S+)*)\s*$/, "$1")); } catch (e) { return null; } return ((r[1].length === 0) ? r[0] : null); }, nativeFallback: function(s) { var t; try { // ok we haven't parsed it, last ditch attempt with the built-in parser. t = Date._parse(s); return (t || t === 0) ? new Date(t) : null; } catch (e) { return null; } } }; function parse (s) { var d; if (!s) { return null; } if (s instanceof Date) { return s.clone(); } if (s.length >= 4 && s.charAt(0) !== "0" && s.charAt(0) !== "+"&& s.charAt(0) !== "-") { // ie: 2004 will pass, 0800 won't. // Start with specific formats d = $D.Parsing.ISO.parse(s) || $D.Parsing.Numeric.parse(s); } if (d instanceof Date && !isNaN(d.getTime())) { return d; } else { // find ordinal dates (1st, 3rd, 8th, etc and remove them as they cause parsing issues) s = $D.Parsing.Normalizer.parse(parseUtils.removeOrds(s)); d = parseUtils.grammarParser(s); if (d !== null) { return d; } else { return parseUtils.nativeFallback(s); } } } if (!$D._parse) { $D._parse = $D.parse; } $D.parse = parse; Date.getParseFunction = function (fx) { var fns = Date.Grammar.allformats(fx); return function (s) { var r = null; for (var i = 0; i < fns.length; i++) { try { r = fns[i].call({}, s); } catch (e) { continue; } if (r[1].length === 0) { return r[0]; } } return null; }; }; /** * Converts the specified string value into its JavaScript Date equivalent using the specified format {String} or formats {Array} and the CultureInfo specific format information. * The format of the string value must match one of the supplied formats exactly. * * Example

	// 15-Oct-2004
	var d1 = Date.parseExact("10/15/2004", "M/d/yyyy");

	// 15-Oct-2004
	var d1 = Date.parse("15-Oct-2004", "M-ddd-yyyy");

	// 15-Oct-2004
	var d1 = Date.parse("2004.10.15", "yyyy.MM.dd");

	// Multiple formats
	var d1 = Date.parseExact("10/15/2004", ["M/d/yyyy", "MMMM d, yyyy"]);
	
* * @param {String} The string value to convert into a Date object [Required]. * @param {Object} The expected format {String} or an array of expected formats {Array} of the date string [Required]. * @return {Date} A Date object or null if the string cannot be converted into a Date. */ $D.parseExact = function (s, fx) { return $D.getParseFunction(fx)(s); }; }()); (function () { var $D = Date, $P = $D.prototype, // $C = $D.CultureInfo, // not used atm p = function (s, l) { if (!l) { l = 2; } return ("000" + s).slice(l * -1); }; /** * Converts a PHP format string to Java/.NET format string. * A PHP format string can be used with ._format or .format. * A Java/.NET format string can be used with .toString(). * The .parseExact function will only accept a Java/.NET format string * * Example * var f1 = "%m/%d/%y" * var f2 = Date.normalizeFormat(f1); // "MM/dd/yy" * * new Date().format(f1); // "04/13/08" * new Date()._format(f1); // "04/13/08" * new Date().toString(f2); // "04/13/08" * * var date = Date.parseExact("04/13/08", f2); // Sun Apr 13 2008 * * @param {String} A PHP format string consisting of one or more format spcifiers. * @return {String} The PHP format converted to a Java/.NET format string. */ var normalizerSubstitutions = { "d" : "dd", "%d": "dd", "D" : "ddd", "%a": "ddd", "j" : "dddd", "l" : "dddd", "%A": "dddd", "S" : "S", "F" : "MMMM", "%B": "MMMM", "m" : "MM", "%m": "MM", "M" : "MMM", "%b": "MMM", "%h": "MMM", "n" : "M", "Y" : "yyyy", "%Y": "yyyy", "y" : "yy", "%y": "yy", "g" : "h", "%I": "h", "G" : "H", "h" : "hh", "H" : "HH", "%H": "HH", "i" : "mm", "%M": "mm", "s" : "ss", "%S": "ss", "%r": "hh:mm tt", "%R": "H:mm", "%T": "H:mm:ss", "%X": "t", "%x": "d", "%e": "d", "%D": "MM/dd/yy", "%n": "\\n", "%t": "\\t", "e" : "z", "T" : "z", "%z": "z", "%Z": "z", "Z" : "ZZ", "N" : "u", "w" : "u", "%w": "u", "W" : "W", "%V": "W" }; var normalizer = { substitutes: function (m) { return normalizerSubstitutions[m]; }, interpreted: function (m, x) { var y; switch (m) { case "%u": return x.getDay() + 1; case "z": return x.getOrdinalNumber(); case "%j": return p(x.getOrdinalNumber(), 3); case "%U": var d1 = x.clone().set({month: 0, day: 1}).addDays(-1).moveToDayOfWeek(0), d2 = x.clone().addDays(1).moveToDayOfWeek(0, -1); return (d2 < d1) ? "00" : p((d2.getOrdinalNumber() - d1.getOrdinalNumber()) / 7 + 1); case "%W": return p(x.getWeek()); case "t": return $D.getDaysInMonth(x.getFullYear(), x.getMonth()); case "o": case "%G": return x.setWeek(x.getISOWeek()).toString("yyyy"); case "%g": return x._format("%G").slice(-2); case "a": case "%p": return t("tt").toLowerCase(); case "A": return t("tt").toUpperCase(); case "u": return p(x.getMilliseconds(), 3); case "I": return (x.isDaylightSavingTime()) ? 1 : 0; case "O": return x.getUTCOffset(); case "P": y = x.getUTCOffset(); return y.substring(0, y.length - 2) + ":" + y.substring(y.length - 2); case "B": var now = new Date(); return Math.floor(((now.getHours() * 3600) + (now.getMinutes() * 60) + now.getSeconds() + (now.getTimezoneOffset() + 60) * 60) / 86.4); case "c": return x.toISOString().replace(/\"/g, ""); case "U": return $D.strtotime("now"); case "%c": return t("d") + " " + t("t"); case "%C": return Math.floor(x.getFullYear() / 100 + 1); } }, shouldOverrideDefaults: function (m) { switch (m) { case "%e": return true; default: return false; } }, parse: function (m, context) { var formatString, c = context || new Date(); formatString = normalizer.substitutes(m); if (formatString) { return formatString; } formatString = normalizer.interpreted(m, c); if (formatString) { return formatString; } else { return m; } } }; $D.normalizeFormat = function (format, context) { return format.replace(/(%|\\)?.|%%/g, function(t){ return normalizer.parse(t, context); }); }; /** * Format a local Unix timestamp according to locale settings * * Example: * Date.strftime("%m/%d/%y", new Date()); // "04/13/08" * Date.strftime("c", "2008-04-13T17:52:03Z"); // "04/13/08" * * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @param {Number|String} The number representing the number of seconds that have elapsed since January 1, 1970 (local time). * @return {String} A string representation of the current Date object. */ $D.strftime = function (format, time) { var d = Date.parse(time); return d._format(format); }; /** * Parse any textual datetime description into a Unix timestamp. * A Unix timestamp is the number of seconds that have elapsed since January 1, 1970 (midnight UTC/GMT). * * Example: * Date.strtotime("04/13/08"); // 1208044800 * Date.strtotime("1970-01-01T00:00:00Z"); // 0 * * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @param {Object} A string or date object. * @return {String} A string representation of the current Date object. */ $D.strtotime = function (time) { var d = $D.parse(time); return Math.round($D.UTC(d.getUTCFullYear(), d.getUTCMonth(), d.getUTCDate(), d.getUTCHours(), d.getUTCMinutes(), d.getUTCSeconds(), d.getUTCMilliseconds()) / 1000); }; /** * Converts the value of the current Date object to its equivalent string representation using a PHP/Unix style of date format specifiers. * Format Specifiers * Format Description Example * ------ --------------------------------------------------------------------------- ----------------------- * %a abbreviated weekday name according to the current localed "Mon" through "Sun" * %A full weekday name according to the current localed "Sunday" through "Saturday" * %b abbreviated month name according to the current localed "Jan" through "Dec" * %B full month name according to the current locale "January" through "December" * %c preferred date and time representation for the current locale "4/13/2008 12:33 PM" * %C century number (the year divided by 100 and truncated to an integer) "00" to "99" * %d day of the month as a decimal number "01" to "31" * %D same as %m/%d/%y "04/13/08" * %e day of the month as a decimal number, a single digit is preceded by a space "1" to "31" * %g like %G, but without the century "08" * %G The 4-digit year corresponding to the ISO week number (see %V). "2008" * This has the same format and value as %Y, except that if the ISO week number * belongs to the previous or next year, that year is used instead. * %h same as %b "Jan" through "Dec" * %H hour as a decimal number using a 24-hour clock. "00" to "23" * %I hour as a decimal number using a 12-hour clock. "01" to "12" * %j day of the year as a decimal number. "001" to "366" * %m month as a decimal number. "01" to "12" * %M minute as a decimal number. "00" to "59" * %n newline character "\n" * %p either "am" or "pm" according to the given time value, or the "am" or "pm" * corresponding strings for the current locale. * %r time in a.m. and p.m. notation "8:44 PM" * %R time in 24 hour notation "20:44" * %S second as a decimal number "00" to "59" * %t tab character "\t" * %T current time, equal to %H:%M:%S "12:49:11" * %u weekday as a decimal number ["1", "7"], with "1" representing Monday "1" to "7" * %U week number of the current year as a decimal number, starting with the "0" to ("52" or "53") * first Sunday as the first day of the first week * %V The ISO 8601:1988 week number of the current year as a decimal number, "00" to ("52" or "53") * range 01 to 53, where week 1 is the first week that has at least 4 days * in the current year, and with Monday as the first day of the week. * (Use %G or %g for the year component that corresponds to the week number * for the specified timestamp.) * %W week number of the current year as a decimal number, starting with the "00" to ("52" or "53") * first Monday as the first day of the first week * %w day of the week as a decimal, Sunday being "0" "0" to "6" * %x preferred date representation for the current locale without the time "4/13/2008" * %X preferred time representation for the current locale without the date "12:53:05" * %y year as a decimal number without a century "00" "99" * %Y year as a decimal number including the century "2008" * %Z time zone or name or abbreviation "UTC", "EST", "PST" * %z same as %Z * %% a literal "%" characters "%" * d Day of the month, 2 digits with leading zeros "01" to "31" * D A textual representation of a day, three letters "Mon" through "Sun" * j Day of the month without leading zeros "1" to "31" * l A full textual representation of the day of the week (lowercase "L") "Sunday" through "Saturday" * N ISO-8601 numeric representation of the day of the week (added in PHP 5.1.0) "1" (for Monday) through "7" (for Sunday) * S English ordinal suffix for the day of the month, 2 characters "st", "nd", "rd" or "th". Works well with j * w Numeric representation of the day of the week "0" (for Sunday) through "6" (for Saturday) * z The day of the year (starting from "0") "0" through "365" * W ISO-8601 week number of year, weeks starting on Monday "00" to ("52" or "53") * F A full textual representation of a month, such as January or March "January" through "December" * m Numeric representation of a month, with leading zeros "01" through "12" * M A short textual representation of a month, three letters "Jan" through "Dec" * n Numeric representation of a month, without leading zeros "1" through "12" * t Number of days in the given month "28" through "31" * L Whether it's a leap year "1" if it is a leap year, "0" otherwise * o ISO-8601 year number. This has the same value as Y, except that if the "2008" * ISO week number (W) belongs to the previous or next year, that year * is used instead. * Y A full numeric representation of a year, 4 digits "2008" * y A two digit representation of a year "08" * a Lowercase Ante meridiem and Post meridiem "am" or "pm" * A Uppercase Ante meridiem and Post meridiem "AM" or "PM" * B Swatch Internet time "000" through "999" * g 12-hour format of an hour without leading zeros "1" through "12" * G 24-hour format of an hour without leading zeros "0" through "23" * h 12-hour format of an hour with leading zeros "01" through "12" * H 24-hour format of an hour with leading zeros "00" through "23" * i Minutes with leading zeros "00" to "59" * s Seconds, with leading zeros "00" through "59" * u Milliseconds "54321" * e Timezone identifier "UTC", "EST", "PST" * I Whether or not the date is in daylight saving time (uppercase i) "1" if Daylight Saving Time, "0" otherwise * O Difference to Greenwich time (GMT) in hours "+0200", "-0600" * P Difference to Greenwich time (GMT) with colon between hours and minutes "+02:00", "-06:00" * T Timezone abbreviation "UTC", "EST", "PST" * Z Timezone offset in seconds. The offset for timezones west of UTC is "-43200" through "50400" * always negative, and for those east of UTC is always positive. * c ISO 8601 date "2004-02-12T15:19:21+00:00" * r RFC 2822 formatted date "Thu, 21 Dec 2000 16:01:07 +0200" * U Seconds since the Unix Epoch (January 1 1970 00:00:00 GMT) "0" * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @return {String} A string representation of the current Date object. */ var formatReplace = function (context) { return function (m) { var formatString, override = false; if (m.charAt(0) === "\\" || m.substring(0, 2) === "%%") { return m.replace("\\", "").replace("%%", "%"); } override = normalizer.shouldOverrideDefaults(m); formatString = $D.normalizeFormat(m, context); if (formatString) { return context.toString(formatString, override); } }; }; $P._format = function (format) { var formatter = formatReplace(this); if (!format) { return this._toString(); } else { return format.replace(/(%|\\)?.|%%/g, formatter); } }; if (!$P.format) { $P.format = $P._format; } }()); (function () { "use strict"; var gFn = function (attr) { return function () { return this[attr]; }; }; var sFn = function (attr) { return function (val) { this[attr] = val; return this; }; }; var attrs = ["years", "months", "days", "hours", "minutes", "seconds", "milliseconds"]; var addSetFuncs = function (context, attrs) { for (var i = 0; i < attrs.length ; i++) { var $a = attrs[i], $b = $a.slice(0, 1).toUpperCase() + $a.slice(1); context.prototype[$a] = 0; context.prototype["get" + $b] = gFn($a); context.prototype["set" + $b] = sFn($a); } }; /** * new TimeSpan(milliseconds); * new TimeSpan(days, hours, minutes, seconds); * new TimeSpan(days, hours, minutes, seconds, milliseconds); */ var TimeSpan = function (days, hours, minutes, seconds, milliseconds) { if (arguments.length === 1 && typeof days === "number") { var orient = (days < 0) ? -1 : +1; var millsLeft = Math.abs(days); this.setDays(Math.floor(millsLeft / 86400000) * orient); millsLeft = millsLeft % 86400000; this.setHours(Math.floor(millsLeft / 3600000) * orient); millsLeft = millsLeft % 3600000; this.setMinutes(Math.floor(millsLeft / 60000) * orient); millsLeft = millsLeft % 60000; this.setSeconds(Math.floor(millsLeft / 1000) * orient); millsLeft = millsLeft % 1000; this.setMilliseconds(millsLeft * orient); } else { this.set(days, hours, minutes, seconds, milliseconds); } this.getTotalMilliseconds = function () { return (this.getDays() * 86400000) + (this.getHours() * 3600000) + (this.getMinutes() * 60000) + (this.getSeconds() * 1000); }; this.compareTo = function (time) { var t1 = new Date(1970, 1, 1, this.getHours(), this.getMinutes(), this.getSeconds()), t2; if (time === null) { t2 = new Date(1970, 1, 1, 0, 0, 0); } else { t2 = new Date(1970, 1, 1, time.getHours(), time.getMinutes(), time.getSeconds()); } return (t1 < t2) ? -1 : (t1 > t2) ? 1 : 0; }; this.equals = function (time) { return (this.compareTo(time) === 0); }; this.add = function (time) { return (time === null) ? this : this.addSeconds(time.getTotalMilliseconds() / 1000); }; this.subtract = function (time) { return (time === null) ? this : this.addSeconds(-time.getTotalMilliseconds() / 1000); }; this.addDays = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 86400000)); }; this.addHours = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 3600000)); }; this.addMinutes = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 60000)); }; this.addSeconds = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 1000)); }; this.addMilliseconds = function (n) { return new TimeSpan(this.getTotalMilliseconds() + n); }; this.get12HourHour = function () { return (this.getHours() > 12) ? this.getHours() - 12 : (this.getHours() === 0) ? 12 : this.getHours(); }; this.getDesignator = function () { return (this.getHours() < 12) ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator; }; this.toString = function (format) { this._toString = function () { if (this.getDays() !== null && this.getDays() > 0) { return this.getDays() + "." + this.getHours() + ":" + this.p(this.getMinutes()) + ":" + this.p(this.getSeconds()); } else { return this.getHours() + ":" + this.p(this.getMinutes()) + ":" + this.p(this.getSeconds()); } }; this.p = function (s) { return (s.toString().length < 2) ? "0" + s : s; }; var me = this; return format ? format.replace(/dd?|HH?|hh?|mm?|ss?|tt?/g, function (format) { switch (format) { case "d": return me.getDays(); case "dd": return me.p(me.getDays()); case "H": return me.getHours(); case "HH": return me.p(me.getHours()); case "h": return me.get12HourHour(); case "hh": return me.p(me.get12HourHour()); case "m": return me.getMinutes(); case "mm": return me.p(me.getMinutes()); case "s": return me.getSeconds(); case "ss": return me.p(me.getSeconds()); case "t": return ((me.getHours() < 12) ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator).substring(0, 1); case "tt": return (me.getHours() < 12) ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator; } } ) : this._toString(); }; return this; }; addSetFuncs(TimeSpan, attrs.slice(2)); TimeSpan.prototype.set = function (days, hours, minutes, seconds, milliseconds){ this.setDays(days || this.getDays()); this.setHours(hours || this.getHours()); this.setMinutes(minutes || this.getMinutes()); this.setSeconds(seconds || this.getSeconds()); this.setMilliseconds(milliseconds || this.getMilliseconds()); }; /** * Gets the time of day for this date instances. * @return {TimeSpan} TimeSpan */ Date.prototype.getTimeOfDay = function () { return new TimeSpan(0, this.getHours(), this.getMinutes(), this.getSeconds(), this.getMilliseconds()); }; Date.TimeSpan = TimeSpan; if (typeof window !== "undefined" ) { // keeping API compatible for v1.x window.TimeSpan = TimeSpan; } }()); (function () { "use strict"; var attrs = ["years", "months", "days", "hours", "minutes", "seconds", "milliseconds"]; var gFn = function (attr) { return function () { return this[attr]; }; }; var sFn = function (attr) { return function (val) { this[attr] = val; return this; }; }; var addSetFuncs = function (context, attrs) { for (var i = 0; i < attrs.length ; i++) { var $a = attrs[i], $b = $a.slice(0, 1).toUpperCase() + $a.slice(1); context.prototype[$a] = 0; context.prototype["get" + $b] = gFn($a); context.prototype["set" + $b] = sFn($a); } }; var setMonthsAndYears = function (orient, d1, d2, context) { function inc() { d1.addMonths(-orient); context.months++; if (context.months === 12) { context.years++; context.months = 0; } } if (orient === +1) { while (d1 > d2) { inc(); } } else { while (d1 < d2) { inc(); } } context.months--; context.months *= orient; context.years *= orient; }; var adjustForDST = function(orient, startDate, endDate) { var hasDSTMismatch = (false === (startDate.isDaylightSavingTime() === endDate.isDaylightSavingTime())); if (hasDSTMismatch && orient === 1) { startDate.addHours(-1); } else if (hasDSTMismatch) { startDate.addHours(1); } }; /** * TimePeriod(startDate, endDate); * TimePeriod(years, months, days, hours, minutes, seconds, milliseconds); */ var TimePeriod = function (years, months, days, hours, minutes, seconds, milliseconds) { if (arguments.length === 7) { this.set(years, months, days, hours, minutes, seconds, milliseconds); } else if (arguments.length === 2 && arguments[0] instanceof Date && arguments[1] instanceof Date) { var startDate = arguments[0].clone(); var endDate = arguments[1].clone(); var orient = (startDate > endDate) ? +1 : -1; this.dates = { start: arguments[0].clone(), end: arguments[1].clone() }; setMonthsAndYears(orient, startDate, endDate, this); adjustForDST(orient, startDate, endDate); // // TODO - adjust for DST var diff = endDate - startDate; if (diff !== 0) { var ts = new TimeSpan(diff); this.set(this.years, this.months, ts.getDays(), ts.getHours(), ts.getMinutes(), ts.getSeconds(), ts.getMilliseconds()); } } return this; }; // create all the set functions. addSetFuncs(TimePeriod, attrs); TimePeriod.prototype.set = function (years, months, days, hours, minutes, seconds, milliseconds){ this.setYears(years || this.getYears()); this.setMonths(months || this.getMonths()); this.setDays(days || this.getDays()); this.setHours(hours || this.getHours()); this.setMinutes(minutes || this.getMinutes()); this.setSeconds(seconds || this.getSeconds()); this.setMilliseconds(milliseconds || this.getMilliseconds()); }; Date.TimePeriod = TimePeriod; if (typeof window !== "undefined") { // keeping API compatible for v1.x window.TimePeriod = TimePeriod; } }()); ================================================ FILE: build/date-ko-KR.js ================================================ /** * @overview datejs * @version 1.0.0-rc3 * @author Gregory Wild-Smith * @copyright 2015 Gregory Wild-Smith * @license MIT * @homepage https://github.com/abritinthebay/datejs */ /* * DateJS Culture String File * Country Code: ko-KR * Name: Korean (Korea) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["ko-KR"] = { "name": "ko-KR", "englishName": "Korean (Korea)", "nativeName": "한국어 (대한민국)", "Sunday": "일요일", "Monday": "월요일", "Tuesday": "화요일", "Wednesday": "수요일", "Thursday": "목요일", "Friday": "금요일", "Saturday": "토요일", "Sun": "일", "Mon": "월", "Tue": "화", "Wed": "수", "Thu": "목", "Fri": "금", "Sat": "토", "Su": "일", "Mo": "월", "Tu": "화", "We": "수", "Th": "목", "Fr": "금", "Sa": "토", "S_Sun_Initial": "일", "M_Mon_Initial": "월", "T_Tue_Initial": "화", "W_Wed_Initial": "수", "T_Thu_Initial": "목", "F_Fri_Initial": "금", "S_Sat_Initial": "토", "January": "1월", "February": "2월", "March": "3월", "April": "4월", "May": "5월", "June": "6월", "July": "7월", "August": "8월", "September": "9월", "October": "10월", "November": "11월", "December": "12월", "Jan_Abbr": "1", "Feb_Abbr": "2", "Mar_Abbr": "3", "Apr_Abbr": "4", "May_Abbr": "5", "Jun_Abbr": "6", "Jul_Abbr": "7", "Aug_Abbr": "8", "Sep_Abbr": "9", "Oct_Abbr": "10", "Nov_Abbr": "11", "Dec_Abbr": "12", "AM": "오전", "PM": "오후", "firstDayOfWeek": 0, "twoDigitYearMax": 2029, "mdy": "ymd", "M/d/yyyy": "yyyy-MM-dd", "dddd, MMMM dd, yyyy": "yyyy'년' M'월' d'일' dddd", "h:mm tt": "tt h:mm", "h:mm:ss tt": "tt h:mm:ss", "dddd, MMMM dd, yyyy h:mm:ss tt": "yyyy'년' M'월' d'일' dddd tt h:mm:ss", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "M'월' d'일'", "MMMM, yyyy": "yyyy'년' M'월'", "/jan(uary)?/": "1(월)?", "/feb(ruary)?/": "2(월)?", "/mar(ch)?/": "3(월)?", "/apr(il)?/": "4(월)?", "/may/": "5(월)?", "/jun(e)?/": "6(월)?", "/jul(y)?/": "7(월)?", "/aug(ust)?/": "8(월)?", "/sep(t(ember)?)?/": "9(월)?", "/oct(ober)?/": "10(월)?", "/nov(ember)?/": "11(월)?", "/dec(ember)?/": "12(월)?", "/^su(n(day)?)?/": "^일요일", "/^mo(n(day)?)?/": "^월요일", "/^tu(e(s(day)?)?)?/": "^화요일", "/^we(d(nesday)?)?/": "^수요일", "/^th(u(r(s(day)?)?)?)?/": "^목요일", "/^fr(i(day)?)?/": "^금요일", "/^sa(t(urday)?)?/": "^토요일", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "ko-KR"; /** * @overview datejs * @version 1.0.0-rc3 * @author Gregory Wild-Smith * @copyright 2015 Gregory Wild-Smith * @license MIT * @homepage https://github.com/abritinthebay/datejs */(function () { var $D = Date; var lang = Date.CultureStrings ? Date.CultureStrings.lang : null; var loggedKeys = {}; // for debug purposes. var getText = { getFromKey: function (key, countryCode) { var output; if (Date.CultureStrings && Date.CultureStrings[countryCode] && Date.CultureStrings[countryCode][key]) { output = Date.CultureStrings[countryCode][key]; } else { output = getText.buildFromDefault(key); } if (key.charAt(0) === "/") { // Assume it's a regex output = getText.buildFromRegex(key, countryCode); } return output; }, getFromObjectValues: function (obj, countryCode) { var key, output = {}; for(key in obj) { if (obj.hasOwnProperty(key)) { output[key] = getText.getFromKey(obj[key], countryCode); } } return output; }, getFromObjectKeys: function (obj, countryCode) { var key, output = {}; for(key in obj) { if (obj.hasOwnProperty(key)) { output[getText.getFromKey(key, countryCode)] = obj[key]; } } return output; }, getFromArray: function (arr, countryCode) { var output = []; for (var i=0; i < arr.length; i++){ if (i in arr) { output[i] = getText.getFromKey(arr[i], countryCode); } } return output; }, buildFromDefault: function (key) { var output, length, split, last; switch(key) { case "name": output = "en-US"; break; case "englishName": output = "English (United States)"; break; case "nativeName": output = "English (United States)"; break; case "twoDigitYearMax": output = 2049; break; case "firstDayOfWeek": output = 0; break; default: output = key; split = key.split("_"); length = split.length; if (length > 1 && key.charAt(0) !== "/") { // if the key isn't a regex and it has a split. last = split[(length - 1)].toLowerCase(); if (last === "initial" || last === "abbr") { output = split[0]; } } break; } return output; }, buildFromRegex: function (key, countryCode) { var output; if (Date.CultureStrings && Date.CultureStrings[countryCode] && Date.CultureStrings[countryCode][key]) { output = new RegExp(Date.CultureStrings[countryCode][key], "i"); } else { output = new RegExp(key.replace(new RegExp("/", "g"),""), "i"); } return output; } }; var shallowMerge = function (obj1, obj2) { for (var attrname in obj2) { if (obj2.hasOwnProperty(attrname)) { obj1[attrname] = obj2[attrname]; } } }; var __ = function (key, language) { var countryCode = (language) ? language : lang; loggedKeys[key] = key; if (typeof key === "object") { if (key instanceof Array) { return getText.getFromArray(key, countryCode); } else { return getText.getFromObjectKeys(key, countryCode); } } else { return getText.getFromKey(key, countryCode); } }; var loadI18nScript = function (code) { // paatterned after jQuery's getScript. var url = Date.Config.i18n + code + ".js"; var head = document.getElementsByTagName("head")[0] || document.documentElement; var script = document.createElement("script"); script.src = url; var completed = false; var events = { done: function (){} // placeholder function }; // Attach handlers for all browsers script.onload = script.onreadystatechange = function() { if ( !completed && (!this.readyState || this.readyState === "loaded" || this.readyState === "complete") ) { events.done(); head.removeChild(script); } }; setTimeout(function() { head.insertBefore(script, head.firstChild); }, 0); // allows return to execute first return { done: function (cb) { events.done = function() { if (cb) { setTimeout(cb,0); } }; } }; }; var buildInfo = { buildFromMethodHash: function (obj) { var key; for(key in obj) { if (obj.hasOwnProperty(key)) { obj[key] = buildInfo[obj[key]](); } } return obj; }, timeZoneDST: function () { var DST = { "CHADT": "+1345", "NZDT": "+1300", "AEDT": "+1100", "ACDT": "+1030", "AZST": "+0500", "IRDT": "+0430", "EEST": "+0300", "CEST": "+0200", "BST": "+0100", "PMDT": "-0200", "ADT": "-0300", "NDT": "-0230", "EDT": "-0400", "CDT": "-0500", "MDT": "-0600", "PDT": "-0700", "AKDT": "-0800", "HADT": "-0900" }; return __(DST); }, timeZoneStandard: function () { var standard = { "LINT": "+1400", "TOT": "+1300", "CHAST": "+1245", "NZST": "+1200", "NFT": "+1130", "SBT": "+1100", "AEST": "+1000", "ACST": "+0930", "JST": "+0900", "CWST": "+0845", "CT": "+0800", "ICT": "+0700", "MMT": "+0630", "BST": "+0600", "NPT": "+0545", "IST": "+0530", "PKT": "+0500", "AFT": "+0430", "MSK": "+0400", "IRST": "+0330", "FET": "+0300", "EET": "+0200", "CET": "+0100", "GMT": "+0000", "UTC": "+0000", "CVT": "-0100", "GST": "-0200", "BRT": "-0300", "NST": "-0330", "AST": "-0400", "EST": "-0500", "CST": "-0600", "MST": "-0700", "PST": "-0800", "AKST": "-0900", "MIT": "-0930", "HST": "-1000", "SST": "-1100", "BIT": "-1200" }; return __(standard); }, timeZones: function (data) { var zone; data.timezones = []; for (zone in data.abbreviatedTimeZoneStandard) { if (data.abbreviatedTimeZoneStandard.hasOwnProperty(zone)) { data.timezones.push({ name: zone, offset: data.abbreviatedTimeZoneStandard[zone]}); } } for (zone in data.abbreviatedTimeZoneDST) { if (data.abbreviatedTimeZoneDST.hasOwnProperty(zone)) { data.timezones.push({ name: zone, offset: data.abbreviatedTimeZoneDST[zone], dst: true}); } } return data.timezones; }, days: function () { return __(["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"]); }, dayAbbr: function () { return __(["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"]); }, dayShortNames: function () { return __(["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"]); }, dayFirstLetters: function () { return __(["S_Sun_Initial", "M_Mon_Initial", "T_Tues_Initial", "W_Wed_Initial", "T_Thu_Initial", "F_Fri_Initial", "S_Sat_Initial"]); }, months: function () { return __(["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"]); }, monthAbbr: function () { return __(["Jan_Abbr", "Feb_Abbr", "Mar_Abbr", "Apr_Abbr", "May_Abbr", "Jun_Abbr", "Jul_Abbr", "Aug_Abbr", "Sep_Abbr", "Oct_Abbr", "Nov_Abbr", "Dec_Abbr"]); }, formatPatterns: function () { return getText.getFromObjectValues({ shortDate: "M/d/yyyy", longDate: "dddd, MMMM dd, yyyy", shortTime: "h:mm tt", longTime: "h:mm:ss tt", fullDateTime: "dddd, MMMM dd, yyyy h:mm:ss tt", sortableDateTime: "yyyy-MM-ddTHH:mm:ss", universalSortableDateTime: "yyyy-MM-dd HH:mm:ssZ", rfc1123: "ddd, dd MMM yyyy HH:mm:ss", monthDay: "MMMM dd", yearMonth: "MMMM, yyyy" }, Date.i18n.currentLanguage()); }, regex: function () { return getText.getFromObjectValues({ inTheMorning: "/( in the )(morn(ing)?)\\b/", thisMorning: "/(this )(morn(ing)?)\\b/", amThisMorning: "/(\b\\d(am)? )(this )(morn(ing)?)/", inTheEvening: "/( in the )(even(ing)?)\\b/", thisEvening: "/(this )(even(ing)?)\\b/", pmThisEvening: "/(\b\\d(pm)? )(this )(even(ing)?)/", jan: "/jan(uary)?/", feb: "/feb(ruary)?/", mar: "/mar(ch)?/", apr: "/apr(il)?/", may: "/may/", jun: "/jun(e)?/", jul: "/jul(y)?/", aug: "/aug(ust)?/", sep: "/sep(t(ember)?)?/", oct: "/oct(ober)?/", nov: "/nov(ember)?/", dec: "/dec(ember)?/", sun: "/^su(n(day)?)?/", mon: "/^mo(n(day)?)?/", tue: "/^tu(e(s(day)?)?)?/", wed: "/^we(d(nesday)?)?/", thu: "/^th(u(r(s(day)?)?)?)?/", fri: "/fr(i(day)?)?/", sat: "/^sa(t(urday)?)?/", future: "/^next/", past: "/^last|past|prev(ious)?/", add: "/^(\\+|aft(er)?|from|hence)/", subtract: "/^(\\-|bef(ore)?|ago)/", yesterday: "/^yes(terday)?/", today: "/^t(od(ay)?)?/", tomorrow: "/^tom(orrow)?/", now: "/^n(ow)?/", millisecond: "/^ms|milli(second)?s?/", second: "/^sec(ond)?s?/", minute: "/^mn|min(ute)?s?/", hour: "/^h(our)?s?/", week: "/^w(eek)?s?/", month: "/^m(onth)?s?/", day: "/^d(ay)?s?/", year: "/^y(ear)?s?/", shortMeridian: "/^(a|p)/", longMeridian: "/^(a\\.?m?\\.?|p\\.?m?\\.?)/", timezone: "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/", ordinalSuffix: "/^\\s*(st|nd|rd|th)/", timeContext: "/^\\s*(\\:|a(?!u|p)|p)/" }, Date.i18n.currentLanguage()); } }; var CultureInfo = function () { var info = getText.getFromObjectValues({ name: "name", englishName: "englishName", nativeName: "nativeName", amDesignator: "AM", pmDesignator: "PM", firstDayOfWeek: "firstDayOfWeek", twoDigitYearMax: "twoDigitYearMax", dateElementOrder: "mdy" }, Date.i18n.currentLanguage()); var constructedInfo = buildInfo.buildFromMethodHash({ dayNames: "days", abbreviatedDayNames: "dayAbbr", shortestDayNames: "dayShortNames", firstLetterDayNames: "dayFirstLetters", monthNames: "months", abbreviatedMonthNames: "monthAbbr", formatPatterns: "formatPatterns", regexPatterns: "regex", abbreviatedTimeZoneDST: "timeZoneDST", abbreviatedTimeZoneStandard: "timeZoneStandard" }); shallowMerge(info, constructedInfo); buildInfo.timeZones(info); return info; }; $D.i18n = { __: function (key, lang) { return __(key, lang); }, currentLanguage: function () { return lang || "en-US"; }, setLanguage: function (code, force, cb) { var async = false; if (force || code === "en-US" || (!!Date.CultureStrings && !!Date.CultureStrings[code])) { lang = code; Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings.lang = code; Date.CultureInfo = new CultureInfo(); } else { if (!(!!Date.CultureStrings && !!Date.CultureStrings[code])) { if (typeof exports !== "undefined" && this.exports !== exports) { // we're in a Node enviroment, load it using require try { require("../i18n/" + code + ".js"); lang = code; Date.CultureStrings.lang = code; Date.CultureInfo = new CultureInfo(); } catch (e) { // var str = "The language for '" + code + "' could not be loaded by Node. It likely does not exist."; throw new Error("The DateJS IETF language tag '" + code + "' could not be loaded by Node. It likely does not exist."); } } else if (Date.Config && Date.Config.i18n) { // we know the location of the files, so lets load them async = true; loadI18nScript(code).done(function(){ lang = code; Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings.lang = code; Date.CultureInfo = new CultureInfo(); $D.Parsing.Normalizer.buildReplaceData(); // because this is async if ($D.Grammar) { $D.Grammar.buildGrammarFormats(); // so we can parse those strings... } if (cb) { setTimeout(cb,0); } }); } else { Date.console.error("The DateJS IETF language tag '" + code + "' is not available and has not been loaded."); return false; } } } $D.Parsing.Normalizer.buildReplaceData(); // rebuild normalizer strings if ($D.Grammar) { $D.Grammar.buildGrammarFormats(); // so we can parse those strings... } if (!async && cb) { setTimeout(cb,0); } }, getLoggedKeys: function () { return loggedKeys; }, updateCultureInfo: function () { Date.CultureInfo = new CultureInfo(); } }; $D.i18n.updateCultureInfo(); // run automatically }()); (function () { var $D = Date, $P = $D.prototype, p = function (s, l) { if (!l) { l = 2; } return ("000" + s).slice(l * -1); }; if (typeof window !== "undefined" && typeof window.console !== "undefined" && typeof window.console.log !== "undefined") { $D.console = console; // used only to raise non-critical errors if available } else { // set mock so we don't give errors. $D.console = { log: function(){}, error: function(){} }; } $D.Config = $D.Config || {}; $D.initOverloads = function() { /** * Overload of Date.now. Allows an alternate call for Date.now where it returns the * current Date as an object rather than just milliseconds since the Unix Epoch. * * Also provides an implementation of now() for browsers (IE<9) that don't have it. * * Backwards compatible so with work with either: * Date.now() [returns ms] * or * Date.now(true) [returns Date] */ if (!$D.now) { $D._now = function now() { return new Date().getTime(); }; } else if (!$D._now) { $D._now = $D.now; } $D.now = function (returnObj) { if (returnObj) { return $D.present(); } else { return $D._now(); } }; if ( !$P.toISOString ) { $P.toISOString = function() { return this.getUTCFullYear() + "-" + p(this.getUTCMonth() + 1) + "-" + p(this.getUTCDate()) + "T" + p(this.getUTCHours()) + ":" + p(this.getUTCMinutes()) + ":" + p(this.getUTCSeconds()) + "." + String( (this.getUTCMilliseconds()/1000).toFixed(3)).slice(2, 5) + "Z"; }; } // private if ( $P._toString === undefined ){ $P._toString = $P.toString; } }; $D.initOverloads(); /** * Gets a date that is set to the current date. The time is set to the start of the day (00:00 or 12:00 AM). * @return {Date} The current date. */ $D.today = function () { return new Date().clearTime(); }; /** * Gets a date that is set to the current date and time (same as new Date, but chainable) * @return {Date} The current date. */ $D.present = function () { return new Date(); }; /** * Compares the first date to the second date and returns an number indication of their relative values. * @param {Date} First Date object to compare [Required]. * @param {Date} Second Date object to compare to [Required]. * @return {Number} -1 = date1 is lessthan date2. 0 = values are equal. 1 = date1 is greaterthan date2. */ $D.compare = function (date1, date2) { if (isNaN(date1) || isNaN(date2)) { throw new Error(date1 + " - " + date2); } else if (date1 instanceof Date && date2 instanceof Date) { return (date1 < date2) ? -1 : (date1 > date2) ? 1 : 0; } else { throw new TypeError(date1 + " - " + date2); } }; /** * Compares the first Date object to the second Date object and returns true if they are equal. * @param {Date} First Date object to compare [Required] * @param {Date} Second Date object to compare to [Required] * @return {Boolean} true if dates are equal. false if they are not equal. */ $D.equals = function (date1, date2) { return (date1.compareTo(date2) === 0); }; /** * Gets the language appropriate day name when given the day number(0-6) * eg - 0 == Sunday * @return {String} The day name */ $D.getDayName = function (n) { return Date.CultureInfo.dayNames[n]; }; /** * Gets the day number (0-6) if given a CultureInfo specific string which is a valid dayName, abbreviatedDayName or shortestDayName (two char). * @param {String} The name of the day (eg. "Monday, "Mon", "tuesday", "tue", "We", "we"). * @return {Number} The day number */ $D.getDayNumberFromName = function (name) { var n = Date.CultureInfo.dayNames, m = Date.CultureInfo.abbreviatedDayNames, o = Date.CultureInfo.shortestDayNames, s = name.toLowerCase(); for (var i = 0; i < n.length; i++) { if (n[i].toLowerCase() === s || m[i].toLowerCase() === s || o[i].toLowerCase() === s) { return i; } } return -1; }; /** * Gets the month number (0-11) if given a Culture Info specific string which is a valid monthName or abbreviatedMonthName. * @param {String} The name of the month (eg. "February, "Feb", "october", "oct"). * @return {Number} The day number */ $D.getMonthNumberFromName = function (name) { var n = Date.CultureInfo.monthNames, m = Date.CultureInfo.abbreviatedMonthNames, s = name.toLowerCase(); for (var i = 0; i < n.length; i++) { if (n[i].toLowerCase() === s || m[i].toLowerCase() === s) { return i; } } return -1; }; /** * Gets the language appropriate month name when given the month number(0-11) * eg - 0 == January * @return {String} The month name */ $D.getMonthName = function (n) { return Date.CultureInfo.monthNames[n]; }; /** * Determines if the current date instance is within a LeapYear. * @param {Number} The year. * @return {Boolean} true if date is within a LeapYear, otherwise false. */ $D.isLeapYear = function (year) { return ((year % 4 === 0 && year % 100 !== 0) || year % 400 === 0); }; /** * Gets the number of days in the month, given a year and month value. Automatically corrects for LeapYear. * @param {Number} The year. * @param {Number} The month (0-11). * @return {Number} The number of days in the month. */ $D.getDaysInMonth = function (year, month) { if (!month && $D.validateMonth(year)) { month = year; year = Date.today().getFullYear(); } return [31, ($D.isLeapYear(year) ? 29 : 28), 31, 30, 31, 30, 31, 31, 30, 31, 30, 31][month]; }; $P.getDaysInMonth = function () { return $D.getDaysInMonth(this.getFullYear(), this.getMonth()); }; $D.getTimezoneAbbreviation = function (offset, dst) { var p, n = (dst || false) ? Date.CultureInfo.abbreviatedTimeZoneDST : Date.CultureInfo.abbreviatedTimeZoneStandard; for (p in n) { if (n.hasOwnProperty(p)) { if (n[p] === offset) { return p; } } } return null; }; $D.getTimezoneOffset = function (name, dst) { var i, a =[], z = Date.CultureInfo.timezones; if (!name) { name = (new Date()).getTimezone();} for (i = 0; i < z.length; i++) { if (z[i].name === name.toUpperCase()) { a.push(i); } } if (!z[a[0]]) { return null; } if (a.length === 1 || !dst) { return z[a[0]].offset; } else { for (i=0; i < a.length; i++) { if (z[a[i]].dst) { return z[a[i]].offset; } } } }; $D.getQuarter = function (d) { d = d || new Date(); // If no date supplied, use today var q = [1,2,3,4]; return q[Math.floor(d.getMonth() / 3)]; // ~~~ is a bitwise op. Faster than Math.floor }; $D.getDaysLeftInQuarter = function (d) { d = d || new Date(); var qEnd = new Date(d); qEnd.setMonth(qEnd.getMonth() + 3 - qEnd.getMonth() % 3, 0); return Math.floor((qEnd - d) / 8.64e7); }; // private var validate = function (n, min, max, name) { name = name ? name : "Object"; if (typeof n === "undefined") { return false; } else if (typeof n !== "number") { throw new TypeError(n + " is not a Number."); } else if (n < min || n > max) { // As failing validation is *not* an exceptional circumstance // lets not throw a RangeError Exception here. // It's semantically correct but it's not sensible. return false; } return true; }; /** * Validates the number is within an acceptable range for milliseconds [0-999]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateMillisecond = function (value) { return validate(value, 0, 999, "millisecond"); }; /** * Validates the number is within an acceptable range for seconds [0-59]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateSecond = function (value) { return validate(value, 0, 59, "second"); }; /** * Validates the number is within an acceptable range for minutes [0-59]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateMinute = function (value) { return validate(value, 0, 59, "minute"); }; /** * Validates the number is within an acceptable range for hours [0-23]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateHour = function (value) { return validate(value, 0, 23, "hour"); }; /** * Validates the number is within an acceptable range for the days in a month [0-MaxDaysInMonth]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateDay = function (value, year, month) { if (year === undefined || year === null || month === undefined || month === null) { return false;} return validate(value, 1, $D.getDaysInMonth(year, month), "day"); }; /** * Validates the number is within an acceptable range for months [0-11]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateWeek = function (value) { return validate(value, 0, 53, "week"); }; /** * Validates the number is within an acceptable range for months [0-11]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateMonth = function (value) { return validate(value, 0, 11, "month"); }; /** * Validates the number is within an acceptable range for years. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateYear = function (value) { /** * Per ECMAScript spec the range of times supported by Date objects is * exactly -100,000,000 days to +100,000,000 days measured relative to * midnight at the beginning of 01 January, 1970 UTC. * This gives a range of 8,640,000,000,000,000 milliseconds to either * side of 01 January, 1970 UTC. * * Earliest possible date: Tue, 20 Apr 271,822 B.C. 00:00:00 UTC * Latest possible date: Sat, 13 Sep 275,760 00:00:00 UTC */ return validate(value, -271822, 275760, "year"); }; $D.validateTimezone = function(value) { var timezones = {"ACDT":1,"ACST":1,"ACT":1,"ADT":1,"AEDT":1,"AEST":1,"AFT":1,"AKDT":1,"AKST":1,"AMST":1,"AMT":1,"ART":1,"AST":1,"AWDT":1,"AWST":1,"AZOST":1,"AZT":1,"BDT":1,"BIOT":1,"BIT":1,"BOT":1,"BRT":1,"BST":1,"BTT":1,"CAT":1,"CCT":1,"CDT":1,"CEDT":1,"CEST":1,"CET":1,"CHADT":1,"CHAST":1,"CHOT":1,"ChST":1,"CHUT":1,"CIST":1,"CIT":1,"CKT":1,"CLST":1,"CLT":1,"COST":1,"COT":1,"CST":1,"CT":1,"CVT":1,"CWST":1,"CXT":1,"DAVT":1,"DDUT":1,"DFT":1,"EASST":1,"EAST":1,"EAT":1,"ECT":1,"EDT":1,"EEDT":1,"EEST":1,"EET":1,"EGST":1,"EGT":1,"EIT":1,"EST":1,"FET":1,"FJT":1,"FKST":1,"FKT":1,"FNT":1,"GALT":1,"GAMT":1,"GET":1,"GFT":1,"GILT":1,"GIT":1,"GMT":1,"GST":1,"GYT":1,"HADT":1,"HAEC":1,"HAST":1,"HKT":1,"HMT":1,"HOVT":1,"HST":1,"ICT":1,"IDT":1,"IOT":1,"IRDT":1,"IRKT":1,"IRST":1,"IST":1,"JST":1,"KGT":1,"KOST":1,"KRAT":1,"KST":1,"LHST":1,"LINT":1,"MAGT":1,"MART":1,"MAWT":1,"MDT":1,"MET":1,"MEST":1,"MHT":1,"MIST":1,"MIT":1,"MMT":1,"MSK":1,"MST":1,"MUT":1,"MVT":1,"MYT":1,"NCT":1,"NDT":1,"NFT":1,"NPT":1,"NST":1,"NT":1,"NUT":1,"NZDT":1,"NZST":1,"OMST":1,"ORAT":1,"PDT":1,"PET":1,"PETT":1,"PGT":1,"PHOT":1,"PHT":1,"PKT":1,"PMDT":1,"PMST":1,"PONT":1,"PST":1,"PYST":1,"PYT":1,"RET":1,"ROTT":1,"SAKT":1,"SAMT":1,"SAST":1,"SBT":1,"SCT":1,"SGT":1,"SLST":1,"SRT":1,"SST":1,"SYOT":1,"TAHT":1,"THA":1,"TFT":1,"TJT":1,"TKT":1,"TLT":1,"TMT":1,"TOT":1,"TVT":1,"UCT":1,"ULAT":1,"UTC":1,"UYST":1,"UYT":1,"UZT":1,"VET":1,"VLAT":1,"VOLT":1,"VOST":1,"VUT":1,"WAKT":1,"WAST":1,"WAT":1,"WEDT":1,"WEST":1,"WET":1,"WST":1,"YAKT":1,"YEKT":1,"Z":1}; return (timezones[value] === 1); }; $D.validateTimezoneOffset= function(value) { // timezones go from +14hrs to -12hrs, the +X hours are negative offsets. return (value > -841 && value < 721); }; }()); (function () { var $D = Date, $P = $D.prototype, p = function (s, l) { if (!l) { l = 2; } return ("000" + s).slice(l * -1); }; var validateConfigObject = function (obj) { var result = {}, self = this, prop, testFunc; testFunc = function (prop, func, value) { if (prop === "day") { var month = (obj.month !== undefined) ? obj.month : self.getMonth(); var year = (obj.year !== undefined) ? obj.year : self.getFullYear(); return $D[func](value, year, month); } else { return $D[func](value); } }; for (prop in obj) { if (Object.prototype.hasOwnProperty.call(obj, prop)) { var func = "validate" + prop.charAt(0).toUpperCase() + prop.slice(1); if ($D[func] && obj[prop] !== null && testFunc(prop, func, obj[prop])) { result[prop] = obj[prop]; } } } return result; }; /** * Resets the time of this Date object to 12:00 AM (00:00), which is the start of the day. * @param {Boolean} .clone() this date instance before clearing Time * @return {Date} this */ $P.clearTime = function () { this.setHours(0); this.setMinutes(0); this.setSeconds(0); this.setMilliseconds(0); return this; }; /** * Resets the time of this Date object to the current time ('now'). * @return {Date} this */ $P.setTimeToNow = function () { var n = new Date(); this.setHours(n.getHours()); this.setMinutes(n.getMinutes()); this.setSeconds(n.getSeconds()); this.setMilliseconds(n.getMilliseconds()); return this; }; /** * Returns a new Date object that is an exact date and time copy of the original instance. * @return {Date} A new Date instance */ $P.clone = function () { return new Date(this.getTime()); }; /** * Compares this instance to a Date object and returns an number indication of their relative values. * @param {Date} Date object to compare [Required] * @return {Number} -1 = this is lessthan date. 0 = values are equal. 1 = this is greaterthan date. */ $P.compareTo = function (date) { return Date.compare(this, date); }; /** * Compares this instance to another Date object and returns true if they are equal. * @param {Date} Date object to compare. If no date to compare, new Date() [now] is used. * @return {Boolean} true if dates are equal. false if they are not equal. */ $P.equals = function (date) { return Date.equals(this, (date !== undefined ? date : new Date())); }; /** * Determines if this instance is between a range of two dates or equal to either the start or end dates. * @param {Date} Start of range [Required] * @param {Date} End of range [Required] * @return {Boolean} true is this is between or equal to the start and end dates, else false */ $P.between = function (start, end) { return this.getTime() >= start.getTime() && this.getTime() <= end.getTime(); }; /** * Determines if this date occurs after the date to compare to. * @param {Date} Date object to compare. If no date to compare, new Date() ("now") is used. * @return {Boolean} true if this date instance is greater than the date to compare to (or "now"), otherwise false. */ $P.isAfter = function (date) { return this.compareTo(date || new Date()) === 1; }; /** * Determines if this date occurs before the date to compare to. * @param {Date} Date object to compare. If no date to compare, new Date() ("now") is used. * @return {Boolean} true if this date instance is less than the date to compare to (or "now"). */ $P.isBefore = function (date) { return (this.compareTo(date || new Date()) === -1); }; /** * Determines if the current Date instance occurs today. * @return {Boolean} true if this date instance is 'today', otherwise false. */ /** * Determines if the current Date instance occurs on the same Date as the supplied 'date'. * If no 'date' to compare to is provided, the current Date instance is compared to 'today'. * @param {date} Date object to compare. If no date to compare, the current Date ("now") is used. * @return {Boolean} true if this Date instance occurs on the same Day as the supplied 'date'. */ $P.isToday = $P.isSameDay = function (date) { return this.clone().clearTime().equals((date || new Date()).clone().clearTime()); }; /** * Adds the specified number of milliseconds to this instance. * @param {Number} The number of milliseconds to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addMilliseconds = function (value) { if (!value) { return this; } this.setTime(this.getTime() + value * 1); return this; }; /** * Adds the specified number of seconds to this instance. * @param {Number} The number of seconds to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addSeconds = function (value) { if (!value) { return this; } return this.addMilliseconds(value * 1000); }; /** * Adds the specified number of seconds to this instance. * @param {Number} The number of seconds to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addMinutes = function (value) { if (!value) { return this; } return this.addMilliseconds(value * 60000); // 60*1000 }; /** * Adds the specified number of hours to this instance. * @param {Number} The number of hours to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addHours = function (value) { if (!value) { return this; } return this.addMilliseconds(value * 3600000); // 60*60*1000 }; /** * Adds the specified number of days to this instance. * @param {Number} The number of days to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addDays = function (value) { if (!value) { return this; } this.setDate(this.getDate() + value * 1); return this; }; /** * Adds the specified number of weekdays (ie - not sat or sun) to this instance. * @param {Number} The number of days to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addWeekdays = function (value) { if (!value) { return this; } var day = this.getDay(); var weeks = (Math.ceil(Math.abs(value)/7)); if (day === 0 || day === 6) { if (value > 0) { this.next().monday(); this.addDays(-1); day = this.getDay(); } } if (value < 0) { while (value < 0) { this.addDays(-1); day = this.getDay(); if (day !== 0 && day !== 6) { value++; } } return this; } else if (value > 5 || (6-day) <= value) { value = value + (weeks * 2); } return this.addDays(value); }; /** * Adds the specified number of weeks to this instance. * @param {Number} The number of weeks to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addWeeks = function (value) { if (!value) { return this; } return this.addDays(value * 7); }; /** * Adds the specified number of months to this instance. * @param {Number} The number of months to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addMonths = function (value) { if (!value) { return this; } var n = this.getDate(); this.setDate(1); this.setMonth(this.getMonth() + value * 1); this.setDate(Math.min(n, $D.getDaysInMonth(this.getFullYear(), this.getMonth()))); return this; }; $P.addQuarters = function (value) { if (!value) { return this; } // note this will take you to the same point in the quarter as you are now. // i.e. - if you are 15 days into the quarter you'll be 15 days into the resulting one. // bonus: this allows adding fractional quarters return this.addMonths(value * 3); }; /** * Adds the specified number of years to this instance. * @param {Number} The number of years to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addYears = function (value) { if (!value) { return this; } return this.addMonths(value * 12); }; /** * Adds (or subtracts) to the value of the years, months, weeks, days, hours, minutes, seconds, milliseconds of the date instance using given configuration object. Positive and Negative values allowed. * Example

	Date.today().add( { days: 1, months: 1 } )

	new Date().add( { years: -1 } )
	
* @param {Object} Configuration object containing attributes (months, days, etc.) * @return {Date} this */ $P.add = function (config) { if (typeof config === "number") { this._orient = config; return this; } var x = config; if (x.day) { // If we should be a different date than today (eg: for 'tomorrow -1d', etc). // Should only effect parsing, not direct usage (eg, Finish and FinishExact) if ((x.day - this.getDate()) !== 0) { this.setDate(x.day); } } if (x.milliseconds) { this.addMilliseconds(x.milliseconds); } if (x.seconds) { this.addSeconds(x.seconds); } if (x.minutes) { this.addMinutes(x.minutes); } if (x.hours) { this.addHours(x.hours); } if (x.weeks) { this.addWeeks(x.weeks); } if (x.months) { this.addMonths(x.months); } if (x.years) { this.addYears(x.years); } if (x.days) { this.addDays(x.days); } return this; }; /** * Get the week number. Week one (1) is the week which contains the first Thursday of the year. Monday is considered the first day of the week. * The .getWeek() function does NOT convert the date to UTC. The local datetime is used. * Please use .getISOWeek() to get the week of the UTC converted date. * @return {Number} 1 to 53 */ $P.getWeek = function (utc) { // Create a copy of this date object var self, target = new Date(this.valueOf()); if (utc) { target.addMinutes(target.getTimezoneOffset()); self = target.clone(); } else { self = this; } // ISO week date weeks start on monday // so correct the day number var dayNr = (self.getDay() + 6) % 7; // ISO 8601 states that week 1 is the week // with the first thursday of that year. // Set the target date to the thursday in the target week target.setDate(target.getDate() - dayNr + 3); // Store the millisecond value of the target date var firstThursday = target.valueOf(); // Set the target to the first thursday of the year // First set the target to january first target.setMonth(0, 1); // Not a thursday? Correct the date to the next thursday if (target.getDay() !== 4) { target.setMonth(0, 1 + ((4 - target.getDay()) + 7) % 7); } // The weeknumber is the number of weeks between the // first thursday of the year and the thursday in the target week return 1 + Math.ceil((firstThursday - target) / 604800000); // 604800000 = 7 * 24 * 3600 * 1000 }; /** * Get the ISO 8601 week number. Week one ("01") is the week which contains the first Thursday of the year. Monday is considered the first day of the week. * The .getISOWeek() function does convert the date to it's UTC value. Please use .getWeek() to get the week of the local date. * @return {String} "01" to "53" */ $P.getISOWeek = function () { return p(this.getWeek(true)); }; /** * Moves the date to Monday of the week set. Week one (1) is the week which contains the first Thursday of the year. * @param {Number} A Number (1 to 53) that represents the week of the year. * @return {Date} this */ $P.setWeek = function (n) { if ((n - this.getWeek()) === 0) { if (this.getDay() !== 1) { return this.moveToDayOfWeek(1, (this.getDay() > 1 ? -1 : 1)); } else { return this; } } else { return this.moveToDayOfWeek(1, (this.getDay() > 1 ? -1 : 1)).addWeeks(n - this.getWeek()); } }; $P.setQuarter = function (qtr) { var month = Math.abs(((qtr-1) * 3) + 1); return this.setMonth(month, 1); }; $P.getQuarter = function () { return Date.getQuarter(this); }; $P.getDaysLeftInQuarter = function () { return Date.getDaysLeftInQuarter(this); }; /** * Moves the date to the next n'th occurrence of the dayOfWeek starting from the beginning of the month. The number (-1) is a magic number and will return the last occurrence of the dayOfWeek in the month. * @param {Number} The dayOfWeek to move to * @param {Number} The n'th occurrence to move to. Use (-1) to return the last occurrence in the month * @return {Date} this */ $P.moveToNthOccurrence = function (dayOfWeek, occurrence) { if (dayOfWeek === "Weekday") { if (occurrence > 0) { this.moveToFirstDayOfMonth(); if (this.is().weekday()) { occurrence -= 1; } } else if (occurrence < 0) { this.moveToLastDayOfMonth(); if (this.is().weekday()) { occurrence += 1; } } else { return this; } return this.addWeekdays(occurrence); } var shift = 0; if (occurrence > 0) { shift = occurrence - 1; } else if (occurrence === -1) { this.moveToLastDayOfMonth(); if (this.getDay() !== dayOfWeek) { this.moveToDayOfWeek(dayOfWeek, -1); } return this; } return this.moveToFirstDayOfMonth().addDays(-1).moveToDayOfWeek(dayOfWeek, +1).addWeeks(shift); }; var moveToN = function (getFunc, addFunc, nVal) { return function (value, orient) { var diff = (value - this[getFunc]() + nVal * (orient || +1)) % nVal; return this[addFunc]((diff === 0) ? diff += nVal * (orient || +1) : diff); }; }; /** * Move to the next or last dayOfWeek based on the orient value. * @param {Number} The dayOfWeek to move to * @param {Number} Forward (+1) or Back (-1). Defaults to +1. [Optional] * @return {Date} this */ $P.moveToDayOfWeek = moveToN("getDay", "addDays", 7); /** * Move to the next or last month based on the orient value. * @param {Number} The month to move to. 0 = January, 11 = December * @param {Number} Forward (+1) or Back (-1). Defaults to +1. [Optional] * @return {Date} this */ $P.moveToMonth = moveToN("getMonth", "addMonths", 12); /** * Get the Ordinate of the current day ("th", "st", "rd"). * @return {String} */ $P.getOrdinate = function () { var num = this.getDate(); return ord(num); }; /** * Get the Ordinal day (numeric day number) of the year, adjusted for leap year. * @return {Number} 1 through 365 (366 in leap years) */ $P.getOrdinalNumber = function () { return Math.ceil((this.clone().clearTime() - new Date(this.getFullYear(), 0, 1)) / 86400000) + 1; }; /** * Get the time zone abbreviation of the current date. * @return {String} The abbreviated time zone name (e.g. "EST") */ $P.getTimezone = function () { return $D.getTimezoneAbbreviation(this.getUTCOffset(), this.isDaylightSavingTime()); }; $P.setTimezoneOffset = function (offset) { var here = this.getTimezoneOffset(), there = Number(offset) * -6 / 10; return (there || there === 0) ? this.addMinutes(there - here) : this; }; $P.setTimezone = function (offset) { return this.setTimezoneOffset($D.getTimezoneOffset(offset)); }; /** * Indicates whether Daylight Saving Time is observed in the current time zone. * @return {Boolean} true|false */ $P.hasDaylightSavingTime = function () { return (Date.today().set({month: 0, day: 1}).getTimezoneOffset() !== Date.today().set({month: 6, day: 1}).getTimezoneOffset()); }; /** * Indicates whether this Date instance is within the Daylight Saving Time range for the current time zone. * @return {Boolean} true|false */ $P.isDaylightSavingTime = function () { return Date.today().set({month: 0, day: 1}).getTimezoneOffset() !== this.getTimezoneOffset(); }; /** * Get the offset from UTC of the current date. * @return {String} The 4-character offset string prefixed with + or - (e.g. "-0500") */ $P.getUTCOffset = function (offset) { var n = (offset || this.getTimezoneOffset()) * -10 / 6, r; if (n < 0) { r = (n - 10000).toString(); return r.charAt(0) + r.substr(2); } else { r = (n + 10000).toString(); return "+" + r.substr(1); } }; /** * Returns the number of milliseconds between this date and date. * @param {Date} Defaults to now * @return {Number} The diff in milliseconds */ $P.getElapsed = function (date) { return (date || new Date()) - this; }; /** * Set the value of year, month, day, hour, minute, second, millisecond of date instance using given configuration object. * Example

	Date.today().set( { day: 20, month: 1 } )

	new Date().set( { millisecond: 0 } )
	
* * @param {Object} Configuration object containing attributes (month, day, etc.) * @return {Date} this */ $P.set = function (config) { config = validateConfigObject.call(this, config); var key; for (key in config) { if (Object.prototype.hasOwnProperty.call(config, key)) { var name = key.charAt(0).toUpperCase() + key.slice(1); var addFunc, getFunc; if (key !== "week" && key !== "month" && key !== "timezone" && key !== "timezoneOffset") { name += "s"; } addFunc = "add" + name; getFunc = "get" + name; if (key === "month") { addFunc = addFunc + "s"; } else if (key === "year"){ getFunc = "getFullYear"; } if (key !== "day" && key !== "timezone" && key !== "timezoneOffset" && key !== "week" && key !== "hour") { this[addFunc](config[key] - this[getFunc]()); } else if ( key === "timezone"|| key === "timezoneOffset" || key === "week" || key === "hour") { this["set"+name](config[key]); } } } // day has to go last because you can't validate the day without first knowing the month if (config.day) { this.addDays(config.day - this.getDate()); } return this; }; /** * Moves the date to the first day of the month. * @return {Date} this */ $P.moveToFirstDayOfMonth = function () { return this.set({ day: 1 }); }; /** * Moves the date to the last day of the month. * @return {Date} this */ $P.moveToLastDayOfMonth = function () { return this.set({ day: $D.getDaysInMonth(this.getFullYear(), this.getMonth())}); }; /** * Converts the value of the current Date object to its equivalent string representation. * Format Specifiers * CUSTOM DATE AND TIME FORMAT STRINGS * Format Description Example * ------ --------------------------------------------------------------------------- ----------------------- * s The seconds of the minute between 0-59. "0" to "59" * ss The seconds of the minute with leading zero if required. "00" to "59" * * m The minute of the hour between 0-59. "0" or "59" * mm The minute of the hour with leading zero if required. "00" or "59" * * h The hour of the day between 1-12. "1" to "12" * hh The hour of the day with leading zero if required. "01" to "12" * * H The hour of the day between 0-23. "0" to "23" * HH The hour of the day with leading zero if required. "00" to "23" * * d The day of the month between 1 and 31. "1" to "31" * dd The day of the month with leading zero if required. "01" to "31" * ddd Abbreviated day name. Date.CultureInfo.abbreviatedDayNames. "Mon" to "Sun" * dddd The full day name. Date.CultureInfo.dayNames. "Monday" to "Sunday" * * M The month of the year between 1-12. "1" to "12" * MM The month of the year with leading zero if required. "01" to "12" * MMM Abbreviated month name. Date.CultureInfo.abbreviatedMonthNames. "Jan" to "Dec" * MMMM The full month name. Date.CultureInfo.monthNames. "January" to "December" * * yy The year as a two-digit number. "99" or "08" * yyyy The full four digit year. "1999" or "2008" * * t Displays the first character of the A.M./P.M. designator. "A" or "P" * Date.CultureInfo.amDesignator or Date.CultureInfo.pmDesignator * tt Displays the A.M./P.M. designator. "AM" or "PM" * Date.CultureInfo.amDesignator or Date.CultureInfo.pmDesignator * * S The ordinal suffix ("st, "nd", "rd" or "th") of the current day. "st, "nd", "rd" or "th" * * STANDARD DATE AND TIME FORMAT STRINGS * Format Description Example *------ --------------------------------------------------------------------------- ----------------------- * d The CultureInfo shortDate Format Pattern "M/d/yyyy" * D The CultureInfo longDate Format Pattern "dddd, MMMM dd, yyyy" * F The CultureInfo fullDateTime Format Pattern "dddd, MMMM dd, yyyy h:mm:ss tt" * m The CultureInfo monthDay Format Pattern "MMMM dd" * r The CultureInfo rfc1123 Format Pattern "ddd, dd MMM yyyy HH:mm:ss GMT" * s The CultureInfo sortableDateTime Format Pattern "yyyy-MM-ddTHH:mm:ss" * t The CultureInfo shortTime Format Pattern "h:mm tt" * T The CultureInfo longTime Format Pattern "h:mm:ss tt" * u The CultureInfo universalSortableDateTime Format Pattern "yyyy-MM-dd HH:mm:ssZ" * y The CultureInfo yearMonth Format Pattern "MMMM, yyyy" * * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @return {String} A string representation of the current Date object. */ var ord = function (n) { switch (n * 1) { case 1: case 21: case 31: return "st"; case 2: case 22: return "nd"; case 3: case 23: return "rd"; default: return "th"; } }; var parseStandardFormats = function (format) { var y, c = Date.CultureInfo.formatPatterns; switch (format) { case "d": return this.toString(c.shortDate); case "D": return this.toString(c.longDate); case "F": return this.toString(c.fullDateTime); case "m": return this.toString(c.monthDay); case "r": case "R": y = this.clone().addMinutes(this.getTimezoneOffset()); return y.toString(c.rfc1123) + " GMT"; case "s": return this.toString(c.sortableDateTime); case "t": return this.toString(c.shortTime); case "T": return this.toString(c.longTime); case "u": y = this.clone().addMinutes(this.getTimezoneOffset()); return y.toString(c.universalSortableDateTime); case "y": return this.toString(c.yearMonth); default: return false; } }; var parseFormatStringsClosure = function (context) { return function (m) { if (m.charAt(0) === "\\") { return m.replace("\\", ""); } switch (m) { case "hh": return p(context.getHours() < 13 ? (context.getHours() === 0 ? 12 : context.getHours()) : (context.getHours() - 12)); case "h": return context.getHours() < 13 ? (context.getHours() === 0 ? 12 : context.getHours()) : (context.getHours() - 12); case "HH": return p(context.getHours()); case "H": return context.getHours(); case "mm": return p(context.getMinutes()); case "m": return context.getMinutes(); case "ss": return p(context.getSeconds()); case "s": return context.getSeconds(); case "yyyy": return p(context.getFullYear(), 4); case "yy": return p(context.getFullYear()); case "y": return context.getFullYear(); case "E": case "dddd": return Date.CultureInfo.dayNames[context.getDay()]; case "ddd": return Date.CultureInfo.abbreviatedDayNames[context.getDay()]; case "dd": return p(context.getDate()); case "d": return context.getDate(); case "MMMM": return Date.CultureInfo.monthNames[context.getMonth()]; case "MMM": return Date.CultureInfo.abbreviatedMonthNames[context.getMonth()]; case "MM": return p((context.getMonth() + 1)); case "M": return context.getMonth() + 1; case "t": return context.getHours() < 12 ? Date.CultureInfo.amDesignator.substring(0, 1) : Date.CultureInfo.pmDesignator.substring(0, 1); case "tt": return context.getHours() < 12 ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator; case "S": return ord(context.getDate()); case "W": return context.getWeek(); case "WW": return context.getISOWeek(); case "Q": return "Q" + context.getQuarter(); case "q": return String(context.getQuarter()); case "z": return context.getTimezone(); case "Z": case "X": return Date.getTimezoneOffset(context.getTimezone()); case "ZZ": // Timezone offset in seconds return context.getTimezoneOffset() * -60; case "u": return context.getDay(); case "L": return ($D.isLeapYear(context.getFullYear())) ? 1 : 0; case "B": // Swatch Internet Time (.beats) return "@"+((context.getUTCSeconds() + (context.getUTCMinutes()*60) + ((context.getUTCHours()+1)*3600))/86.4); default: return m; } }; }; $P.toString = function (format, ignoreStandards) { // Standard Date and Time Format Strings. Formats pulled from CultureInfo file and // may vary by culture. if (!ignoreStandards && format && format.length === 1) { output = parseStandardFormats.call(this, format); if (output) { return output; } } var parseFormatStrings = parseFormatStringsClosure(this); return format ? format.replace(/((\\)?(dd?d?d?|MM?M?M?|yy?y?y?|hh?|HH?|mm?|ss?|tt?|S|q|Q|WW?W?W?)(?![^\[]*\]))/g, parseFormatStrings).replace(/\[|\]/g, "") : this._toString(); }; }()); /************************************************************* * SugarPak - Domain Specific Language - Syntactical Sugar * *************************************************************/ (function () { var $D = Date, $P = $D.prototype, $N = Number.prototype; // private $P._orient = +1; // private $P._nth = null; // private $P._is = false; // private $P._same = false; // private $P._isSecond = false; // private $N._dateElement = "days"; /** * Moves the date to the next instance of a date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.today().next().friday();
	Date.today().next().fri();
	Date.today().next().march();
	Date.today().next().mar();
	Date.today().next().week();
	
* * @return {Date} date */ $P.next = function () { this._move = true; this._orient = +1; return this; }; /** * Creates a new Date (Date.today()) and moves the date to the next instance of the date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.next().friday();
	Date.next().fri();
	Date.next().march();
	Date.next().mar();
	Date.next().week();
	
* * @return {Date} date */ $D.next = function () { return $D.today().next(); }; /** * Moves the date to the previous instance of a date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.today().last().friday();
	Date.today().last().fri();
	Date.today().last().march();
	Date.today().last().mar();
	Date.today().last().week();
	
* * @return {Date} date */ $P.last = $P.prev = $P.previous = function () { this._move = true; this._orient = -1; return this; }; /** * Creates a new Date (Date.today()) and moves the date to the previous instance of the date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.last().friday();
	Date.last().fri();
	Date.previous().march();
	Date.prev().mar();
	Date.last().week();
	
* * @return {Date} date */ $D.last = $D.prev = $D.previous = function () { return $D.today().last(); }; /** * Performs a equality check when followed by either a month name, day name or .weekday() function. * Example

	Date.today().is().friday(); // true|false
	Date.today().is().fri();
	Date.today().is().march();
	Date.today().is().mar();
	
* * @return {Boolean} true|false */ $P.is = function () { this._is = true; return this; }; /** * Determines if two date objects occur on/in exactly the same instance of the subsequent date part function. * The function .same() must be followed by a date part function (example: .day(), .month(), .year(), etc). * * An optional Date can be passed in the date part function. If now date is passed as a parameter, 'Now' is used. * * The following example demonstrates how to determine if two dates fall on the exact same day. * * Example

	var d1 = Date.today(); // today at 00:00
	var d2 = new Date();   // exactly now.

	// Do they occur on the same day?
	d1.same().day(d2); // true
	
	// Do they occur on the same hour?
	d1.same().hour(d2); // false, unless d2 hour is '00' (midnight).
	
	// What if it's the same day, but one year apart?
	var nextYear = Date.today().add(1).year();

	d1.same().day(nextYear); // false, because the dates must occur on the exact same day. 
	
* * Scenario: Determine if a given date occurs during some week period 2 months from now. * * Example

	var future = Date.today().add(2).months();
	return someDate.same().week(future); // true|false;
	
* * @return {Boolean} true|false */ $P.same = function () { this._same = true; this._isSecond = false; return this; }; /** * Determines if the current date/time occurs during Today. Must be preceded by the .is() function. * Example

	someDate.is().today();    // true|false
	new Date().is().today();  // true
	Date.today().is().today();// true
	Date.today().add(-1).day().is().today(); // false
	
* * @return {Boolean} true|false */ $P.today = function () { return this.same().day(); }; /** * Determines if the current date is a weekday. This function must be preceded by the .is() function. * Example

	Date.today().is().weekday(); // true|false
	
* * @return {Boolean} true|false */ $P.weekday = function () { if (this._nth) { return df("Weekday").call(this); } if (this._move) { return this.addWeekdays(this._orient); } if (this._is) { this._is = false; return (!this.is().sat() && !this.is().sun()); } return false; }; /** * Determines if the current date is on the weekend. This function must be preceded by the .is() function. * Example

	Date.today().is().weekend(); // true|false
	
* * @return {Boolean} true|false */ $P.weekend = function () { if (this._is) { this._is = false; return (this.is().sat() || this.is().sun()); } return false; }; /** * Sets the Time of the current Date instance. A string "6:15 pm" or config object {hour:18, minute:15} are accepted. * Example

	// Set time to 6:15pm with a String
	Date.today().at("6:15pm");

	// Set time to 6:15pm with a config object
	Date.today().at({hour:18, minute:15});
	
* * @return {Date} date */ $P.at = function (time) { return (typeof time === "string") ? $D.parse(this.toString("d") + " " + time) : this.set(time); }; /** * Creates a new Date() and adds this (Number) to the date based on the preceding date element function (eg. second|minute|hour|day|month|year). * Example

	// Undeclared Numbers must be wrapped with parentheses. Requirment of JavaScript.
	(3).days().fromNow();
	(6).months().fromNow();

	// Declared Number variables do not require parentheses. 
	var n = 6;
	n.months().fromNow();
	
* * @return {Date} A new Date instance */ $N.fromNow = $N.after = function (date) { var c = {}; c[this._dateElement] = this; return ((!date) ? new Date() : date.clone()).add(c); }; /** * Creates a new Date() and subtract this (Number) from the date based on the preceding date element function (eg. second|minute|hour|day|month|year). * Example

	// Undeclared Numbers must be wrapped with parentheses. Requirment of JavaScript.
	(3).days().ago();
	(6).months().ago();

	// Declared Number variables do not require parentheses. 
	var n = 6;
	n.months().ago();
	
* * @return {Date} A new Date instance */ $N.ago = $N.before = function (date) { var c = {}, s = (this._dateElement[this._dateElement.length-1] !== "s") ? this._dateElement + "s" : this._dateElement; c[s] = this * -1; return ((!date) ? new Date() : date.clone()).add(c); }; // Do NOT modify the following string tokens. These tokens are used to build dynamic functions. // All culture-specific strings can be found in the CultureInfo files. var dx = ("sunday monday tuesday wednesday thursday friday saturday").split(/\s/), mx = ("january february march april may june july august september october november december").split(/\s/), px = ("Millisecond Second Minute Hour Day Week Month Year Quarter Weekday").split(/\s/), pxf = ("Milliseconds Seconds Minutes Hours Date Week Month FullYear Quarter").split(/\s/), nth = ("final first second third fourth fifth").split(/\s/), de; /** * Returns an object literal of all the date parts. * Example

	var o = new Date().toObject();
	
	// { year: 2008, month: 4, week: 20, day: 13, hour: 18, minute: 9, second: 32, millisecond: 812 }
	
	// The object properties can be referenced directly from the object.
	
	alert(o.day);  // alerts "13"
	alert(o.year); // alerts "2008"
	
* * @return {Date} An object literal representing the original date object. */ $P.toObject = function () { var o = {}; for (var i = 0; i < px.length; i++) { if (this["get" + pxf[i]]) { o[px[i].toLowerCase()] = this["get" + pxf[i]](); } } return o; }; /** * Returns a date created from an object literal. Ignores the .week property if set in the config. * Example

	var o = new Date().toObject();
	
	return Date.fromObject(o); // will return the same date. 

	var o2 = {month: 1, day: 20, hour: 18}; // birthday party!
	Date.fromObject(o2);
	
* * @return {Date} An object literal representing the original date object. */ $D.fromObject = function(config) { config.week = null; return Date.today().set(config); }; // Create day name functions and abbreviated day name functions (eg. monday(), friday(), fri()). var df = function (n) { return function () { if (this._is) { this._is = false; return this.getDay() === n; } if (this._move) { this._move = null; } if (this._nth !== null) { // If the .second() function was called earlier, remove the _orient // from the date, and then continue. // This is required because 'second' can be used in two different context. // // Example // // Date.today().add(1).second(); // Date.march().second().monday(); // // Things get crazy with the following... // Date.march().add(1).second().second().monday(); // but it works!! // if (this._isSecond) { this.addSeconds(this._orient * -1); } // make sure we reset _isSecond this._isSecond = false; var ntemp = this._nth; this._nth = null; var temp = this.clone().moveToLastDayOfMonth(); this.moveToNthOccurrence(n, ntemp); if (this > temp) { throw new RangeError($D.getDayName(n) + " does not occur " + ntemp + " times in the month of " + $D.getMonthName(temp.getMonth()) + " " + temp.getFullYear() + "."); } return this; } return this.moveToDayOfWeek(n, this._orient); }; }; var sdf = function (n) { return function () { var t = $D.today(), shift = n - t.getDay(); if (n === 0 && Date.CultureInfo.firstDayOfWeek === 1 && t.getDay() !== 0) { shift = shift + 7; } return t.addDays(shift); }; }; // Create month name functions and abbreviated month name functions (eg. january(), march(), mar()). var month_instance_functions = function (n) { return function () { if (this._is) { this._is = false; return this.getMonth() === n; } return this.moveToMonth(n, this._orient); }; }; var month_static_functions = function (n) { return function () { return $D.today().set({ month: n, day: 1 }); }; }; var processTerms = function (names, staticFunc, instanceFunc) { for (var i = 0; i < names.length; i++) { // Create constant static Name variables. $D[names[i].toUpperCase()] = $D[names[i].toUpperCase().substring(0, 3)] = i; // Create Name functions. $D[names[i]] = $D[names[i].substring(0, 3)] = staticFunc(i); // Create Name instance functions. $P[names[i]] = $P[names[i].substring(0, 3)] = instanceFunc(i); } }; processTerms(dx, sdf, df); processTerms(mx, month_static_functions, month_instance_functions); // Create date element functions and plural date element functions used with Date (eg. day(), days(), months()). var ef = function (j) { return function () { // if the .second() function was called earlier, the _orient // has alread been added. Just return this and reset _isSecond. if (this._isSecond) { this._isSecond = false; return this; } if (this._same) { this._same = this._is = false; var o1 = this.toObject(), o2 = (arguments[0] || new Date()).toObject(), v = "", k = j.toLowerCase(); // the substr trick with -1 doesn't work in IE8 or less k = (k[k.length-1] === "s") ? k.substring(0,k.length-1) : k; for (var m = (px.length - 1); m > -1; m--) { v = px[m].toLowerCase(); if (o1[v] !== o2[v]) { return false; } if (k === v) { break; } } return true; } if (j.substring(j.length - 1) !== "s") { j += "s"; } if (this._move) { this._move = null; } return this["add" + j](this._orient); }; }; var nf = function (n) { return function () { this._dateElement = n; return this; }; }; for (var k = 0; k < px.length; k++) { de = px[k].toLowerCase(); if(de !== "weekday") { // Create date element functions and plural date element functions used with Date (eg. day(), days(), months()). $P[de] = $P[de + "s"] = ef(px[k]); // Create date element functions and plural date element functions used with Number (eg. day(), days(), months()). $N[de] = $N[de + "s"] = nf(de + "s"); } } $P._ss = ef("Second"); var nthfn = function (n) { return function (dayOfWeek) { if (this._same) { return this._ss(arguments[0]); } if (dayOfWeek || dayOfWeek === 0) { return this.moveToNthOccurrence(dayOfWeek, n); } this._nth = n; // if the operator is 'second' add the _orient, then deal with it later... if (n === 2 && (dayOfWeek === undefined || dayOfWeek === null)) { this._isSecond = true; return this.addSeconds(this._orient); } return this; }; }; for (var l = 0; l < nth.length; l++) { $P[nth[l]] = (l === 0) ? nthfn(-1) : nthfn(l); } }()); (function () { "use strict"; Date.Parsing = { Exception: function (s) { this.message = "Parse error at '" + s.substring(0, 10) + " ...'"; } }; var $P = Date.Parsing; var dayOffsets = { standard: [0,31,59,90,120,151,181,212,243,273,304,334], leap: [0,31,60,91,121,152,182,213,244,274,305,335] }; $P.isLeapYear = function(year) { return ((year % 4 === 0) && (year % 100 !== 0)) || (year % 400 === 0); }; var utils = { multiReplace : function (str, hash ) { var key; for (key in hash) { if (Object.prototype.hasOwnProperty.call(hash, key)) { var regex; if (typeof hash[key] === "function") { } else { regex = (hash[key] instanceof RegExp) ? hash[key] : new RegExp(hash[key], "g"); } str = str.replace(regex, key); } } return str; }, getDayOfYearFromWeek : function (obj) { var d, jan4, offset; obj.weekDay = (!obj.weekDay && obj.weekDay !== 0) ? 1 : obj.weekDay; d = new Date(obj.year, 0, 4); jan4 = d.getDay() === 0 ? 7 : d.getDay(); // JS is 0 indexed on Sunday. offset = jan4+3; obj.dayOfYear = ((obj.week * 7) + (obj.weekDay === 0 ? 7 : obj.weekDay))-offset; return obj; }, getDayOfYear : function (obj, dayOffset) { if (!obj.dayOfYear) { obj = utils.getDayOfYearFromWeek(obj); } for (var i=0;i <= dayOffset.length;i++) { if (obj.dayOfYear < dayOffset[i] || i === dayOffset.length) { obj.day = obj.day ? obj.day : (obj.dayOfYear - dayOffset[i-1]); break; } else { obj.month = i; } } return obj; }, adjustForTimeZone : function (obj, date) { var offset; if (obj.zone.toUpperCase() === "Z" || (obj.zone_hours === 0 && obj.zone_minutes === 0)) { // it's UTC/GML so work out the current timeszone offset offset = -date.getTimezoneOffset(); } else { offset = (obj.zone_hours*60) + (obj.zone_minutes || 0); if (obj.zone_sign === "+") { offset *= -1; } offset -= date.getTimezoneOffset(); } date.setMinutes(date.getMinutes()+offset); return date; }, setDefaults : function (obj) { obj.year = obj.year || Date.today().getFullYear(); obj.hours = obj.hours || 0; obj.minutes = obj.minutes || 0; obj.seconds = obj.seconds || 0; obj.milliseconds = obj.milliseconds || 0; if (!(!obj.month && (obj.week || obj.dayOfYear))) { // if we have a month, or if we don't but don't have the day calculation data obj.month = obj.month || 0; obj.day = obj.day || 1; } return obj; }, dataNum: function (data, mod, explict, postProcess) { var dataNum = data*1; if (mod) { if (postProcess) { return data ? mod(data)*1 : data; } else { return data ? mod(dataNum) : data; } } else if (!explict){ return data ? dataNum : data; } else { return (data && typeof data !== "undefined") ? dataNum : data; } }, timeDataProcess: function (obj) { var timeObj = {}; for (var x in obj.data) { if (obj.data.hasOwnProperty(x)) { timeObj[x] = obj.ignore[x] ? obj.data[x] : utils.dataNum(obj.data[x], obj.mods[x], obj.explict[x], obj.postProcess[x]); } } if (obj.data.secmins) { obj.data.secmins = obj.data.secmins.replace(",", ".") * 60; if (!timeObj.minutes) { timeObj.minutes = obj.data.secmins; } else if (!timeObj.seconds) { timeObj.seconds = obj.data.secmins; } delete obj.secmins; } return timeObj; }, buildTimeObjectFromData: function (data) { var time = utils.timeDataProcess({ data: { year : data[1], month : data[5], day : data[7], week : data[8], dayOfYear : data[10], hours : data[15], zone_hours : data[23], zone_minutes : data[24], zone : data[21], zone_sign : data[22], weekDay : data[9], minutes: data[16], seconds: data[19], milliseconds: data[20], secmins: data[18] }, mods: { month: function(data) { return data-1; }, weekDay: function (data) { data = Math.abs(data); return (data === 7 ? 0 : data); }, minutes: function (data) { return data.replace(":",""); }, seconds: function (data) { return Math.floor( (data.replace(":","").replace(",","."))*1 ); }, milliseconds: function (data) { return (data.replace(",",".")*1000); } }, postProcess: { minutes: true, seconds: true, milliseconds: true }, explict: { zone_hours: true, zone_minutes: true }, ignore: { zone: true, zone_sign: true, secmins: true } }); return time; }, addToHash: function (hash, keys, data) { keys = keys; data = data; var len = keys.length; for (var i = 0; i < len; i++) { hash[keys[i]] = data[i]; } return hash; }, combineRegex: function (r1, r2) { return new RegExp("(("+r1.source+")\\s("+r2.source+"))"); }, getDateNthString: function(add, last, inc){ if (add) { return Date.today().addDays(inc).toString("d"); } else if (last) { return Date.today().last()[inc]().toString("d"); } }, buildRegexData: function (array) { var arr = []; var len = array.length; for (var i=0; i < len; i++) { if (Object.prototype.toString.call(array[i]) === '[object Array]') { // oldIE compat version of Array.isArray arr.push(this.combineRegex(array[i][0], array[i][1])); } else { arr.push(array[i]); } } return arr; } }; $P.processTimeObject = function (obj) { var date, dayOffset; utils.setDefaults(obj); dayOffset = ($P.isLeapYear(obj.year)) ? dayOffsets.leap : dayOffsets.standard; if (!obj.month && (obj.week || obj.dayOfYear)) { utils.getDayOfYear(obj, dayOffset); } else { obj.dayOfYear = dayOffset[obj.month] + obj.day; } date = new Date(obj.year, obj.month, obj.day, obj.hours, obj.minutes, obj.seconds, obj.milliseconds); if (obj.zone) { utils.adjustForTimeZone(obj, date); // adjust (and calculate) for timezone } return date; }; $P.ISO = { regex : /^([\+-]?\d{4}(?!\d{2}\b))((-?)((0[1-9]|1[0-2])(\3([12]\d|0[1-9]|3[01]))?|W([0-4]\d|5[0-3])(-?[1-7])?|(00[1-9]|0[1-9]\d|[12]\d{2}|3([0-5]\d|6[1-6])))([T\s]((([01]\d|2[0-4])((:?)[0-5]\d)?|24\:?00)([\.,]\d+(?!:))?)?(\17[0-5]\d([\.,]\d+)?)?\s?([zZ]|([\+-])([01]\d|2[0-3]):?([0-5]\d)?)?)?)?$/, parse : function (s) { var time, data = s.match(this.regex); if (!data || !data.length) { return null; } time = utils.buildTimeObjectFromData(data); if (!time.year || (!time.year && (!time.month && !time.day) && (!time.week && !time.dayOfYear)) ) { return null; } return $P.processTimeObject(time); } }; $P.Numeric = { isNumeric: function (e){return!isNaN(parseFloat(e))&&isFinite(e);}, regex: /\b([0-1]?[0-9])([0-3]?[0-9])([0-2]?[0-9]?[0-9][0-9])\b/i, parse: function (s) { var data, i, time = {}, order = Date.CultureInfo.dateElementOrder.split(""); if (!(this.isNumeric(s)) || // if it's non-numeric OR (s[0] === "+" && s[0] === "-")) { // It's an arithmatic string (eg +/-1000) return null; } if (s.length < 5 && s.indexOf(".") < 0 && s.indexOf("/") < 0) { // assume it's just a year. time.year = s; return $P.processTimeObject(time); } data = s.match(this.regex); if (!data || !data.length) { return null; } for (i=0; i < order.length; i++) { switch(order[i]) { case "d": time.day = data[i+1]; break; case "m": time.month = (data[i+1]-1); break; case "y": time.year = data[i+1]; break; } } return $P.processTimeObject(time); } }; $P.Normalizer = { regexData: function () { var $R = Date.CultureInfo.regexPatterns; return utils.buildRegexData([ $R.tomorrow, $R.yesterday, [$R.past, $R.mon], [$R.past, $R.tue], [$R.past, $R.wed], [$R.past, $R.thu], [$R.past, $R.fri], [$R.past, $R.sat], [$R.past, $R.sun] ]); }, basicReplaceHash : function() { var $R = Date.CultureInfo.regexPatterns; return { "January": $R.jan.source, "February": $R.feb, "March": $R.mar, "April": $R.apr, "May": $R.may, "June": $R.jun, "July": $R.jul, "August": $R.aug, "September": $R.sep, "October": $R.oct, "November": $R.nov, "December": $R.dec, "": /\bat\b/gi, " ": /\s{2,}/, "am": $R.inTheMorning, "9am": $R.thisMorning, "pm": $R.inTheEvening, "7pm":$R.thisEvening }; }, keys : function(){ return [ utils.getDateNthString(true, false, 1), // tomorrow utils.getDateNthString(true, false, -1), // yesterday utils.getDateNthString(false, true, "monday"), //last mon utils.getDateNthString(false, true, "tuesday"), //last tues utils.getDateNthString(false, true, "wednesday"), //last wed utils.getDateNthString(false, true, "thursday"), //last thurs utils.getDateNthString(false, true, "friday"), //last fri utils.getDateNthString(false, true, "saturday"), //last sat utils.getDateNthString(false, true, "sunday") //last sun ]; }, buildRegexFunctions: function () { var $R = Date.CultureInfo.regexPatterns; var __ = Date.i18n.__; var tomorrowRE = new RegExp("(\\b\\d\\d?("+__("AM")+"|"+__("PM")+")? )("+$R.tomorrow.source.slice(1)+")", "i"); // adapted tomorrow regex for AM PM relative dates var todayRE = new RegExp($R.today.source + "(?!\\s*([+-]))\\b"); // today, but excludes the math operators (eg "today + 2h") this.replaceFuncs = [ [todayRE, function (full) { return (full.length > 1) ? Date.today().toString("d") : full; }], [tomorrowRE, function(full, m1) { var t = Date.today().addDays(1).toString("d"); return (t + " " + m1); }], [$R.amThisMorning, function(str, am){return am;}], [$R.pmThisEvening, function(str, pm){return pm;}] ]; }, buildReplaceData: function () { this.buildRegexFunctions(); this.replaceHash = utils.addToHash(this.basicReplaceHash(), this.keys(), this.regexData()); }, stringReplaceFuncs: function (s) { for (var i=0; i < this.replaceFuncs.length; i++) { s = s.replace(this.replaceFuncs[i][0], this.replaceFuncs[i][1]); } return s; }, parse: function (s) { s = this.stringReplaceFuncs(s); s = utils.multiReplace(s, this.replaceHash); try { var n = s.split(/([\s\-\.\,\/\x27]+)/); if (n.length === 3 && $P.Numeric.isNumeric(n[0]) && $P.Numeric.isNumeric(n[2]) && (n[2].length >= 4)) { // ok, so we're dealing with x/year. But that's not a full date. // This fixes wonky dateElementOrder parsing when set to dmy order. if (Date.CultureInfo.dateElementOrder[0] === "d") { s = "1/" + n[0] + "/" + n[2]; // set to 1st of month and normalize the seperator } } } catch (e) {} return s; } }; $P.Normalizer.buildReplaceData(); }()); (function () { var $P = Date.Parsing; var _ = $P.Operators = { // // Tokenizers // rtoken: function (r) { // regex token return function (s) { var mx = s.match(r); if (mx) { return ([ mx[0], s.substring(mx[0].length) ]); } else { throw new $P.Exception(s); } }; }, token: function () { // whitespace-eating token return function (s) { return _.rtoken(new RegExp("^\\s*" + s + "\\s*"))(s); }; }, stoken: function (s) { // string token return _.rtoken(new RegExp("^" + s)); }, // Atomic Operators until: function (p) { return function (s) { var qx = [], rx = null; while (s.length) { try { rx = p.call(this, s); } catch (e) { qx.push(rx[0]); s = rx[1]; continue; } break; } return [ qx, s ]; }; }, many: function (p) { return function (s) { var rx = [], r = null; while (s.length) { try { r = p.call(this, s); } catch (e) { return [ rx, s ]; } rx.push(r[0]); s = r[1]; } return [ rx, s ]; }; }, // generator operators -- see below optional: function (p) { return function (s) { var r = null; try { r = p.call(this, s); } catch (e) { return [ null, s ]; } return [ r[0], r[1] ]; }; }, not: function (p) { return function (s) { try { p.call(this, s); } catch (e) { return [null, s]; } throw new $P.Exception(s); }; }, ignore: function (p) { return p ? function (s) { var r = null; r = p.call(this, s); return [null, r[1]]; } : null; }, product: function () { var px = arguments[0], qx = Array.prototype.slice.call(arguments, 1), rx = []; for (var i = 0 ; i < px.length ; i++) { rx.push(_.each(px[i], qx)); } return rx; }, cache: function (rule) { var cache = {}, cache_length = 0, cache_keys = [], CACHE_MAX = Date.Config.CACHE_MAX || 100000, r = null; var cacheCheck = function () { if (cache_length === CACHE_MAX) { // kill several keys, don't want to have to do this all the time... for (var i=0; i < 10; i++) { var key = cache_keys.shift(); if (key) { delete cache[key]; cache_length--; } } } }; return function (s) { cacheCheck(); try { r = cache[s] = (cache[s] || rule.call(this, s)); } catch (e) { r = cache[s] = e; } cache_length++; cache_keys.push(s); if (r instanceof $P.Exception) { throw r; } else { return r; } }; }, // vector operators -- see below any: function () { var px = arguments; return function (s) { var r = null; for (var i = 0; i < px.length; i++) { if (px[i] == null) { continue; } try { r = (px[i].call(this, s)); } catch (e) { r = null; } if (r) { return r; } } throw new $P.Exception(s); }; }, each: function () { var px = arguments; return function (s) { var rx = [], r = null; for (var i = 0; i < px.length ; i++) { if (px[i] == null) { continue; } try { r = (px[i].call(this, s)); } catch (e) { throw new $P.Exception(s); } rx.push(r[0]); s = r[1]; } return [ rx, s]; }; }, all: function () { var px = arguments, _ = _; return _.each(_.optional(px)); }, // delimited operators sequence: function (px, d, c) { d = d || _.rtoken(/^\s*/); c = c || null; if (px.length === 1) { return px[0]; } return function (s) { var r = null, q = null; var rx = []; for (var i = 0; i < px.length ; i++) { try { r = px[i].call(this, s); } catch (e) { break; } rx.push(r[0]); try { q = d.call(this, r[1]); } catch (ex) { q = null; break; } s = q[1]; } if (!r) { throw new $P.Exception(s); } if (q) { throw new $P.Exception(q[1]); } if (c) { try { r = c.call(this, r[1]); } catch (ey) { throw new $P.Exception(r[1]); } } return [ rx, (r?r[1]:s) ]; }; }, // // Composite Operators // between: function (d1, p, d2) { d2 = d2 || d1; var _fn = _.each(_.ignore(d1), p, _.ignore(d2)); return function (s) { var rx = _fn.call(this, s); return [[rx[0][0], r[0][2]], rx[1]]; }; }, list: function (p, d, c) { d = d || _.rtoken(/^\s*/); c = c || null; return (p instanceof Array ? _.each(_.product(p.slice(0, -1), _.ignore(d)), p.slice(-1), _.ignore(c)) : _.each(_.many(_.each(p, _.ignore(d))), px, _.ignore(c))); }, set: function (px, d, c) { d = d || _.rtoken(/^\s*/); c = c || null; return function (s) { // r is the current match, best the current 'best' match // which means it parsed the most amount of input var r = null, p = null, q = null, rx = null, best = [[], s], last = false; // go through the rules in the given set for (var i = 0; i < px.length ; i++) { // last is a flag indicating whether this must be the last element // if there is only 1 element, then it MUST be the last one q = null; p = null; r = null; last = (px.length === 1); // first, we try simply to match the current pattern // if not, try the next pattern try { r = px[i].call(this, s); } catch (e) { continue; } // since we are matching against a set of elements, the first // thing to do is to add r[0] to matched elements rx = [[r[0]], r[1]]; // if we matched and there is still input to parse and // we don't already know this is the last element, // we're going to next check for the delimiter ... // if there's none, or if there's no input left to parse // than this must be the last element after all ... if (r[1].length > 0 && ! last) { try { q = d.call(this, r[1]); } catch (ex) { last = true; } } else { last = true; } // if we parsed the delimiter and now there's no more input, // that means we shouldn't have parsed the delimiter at all // so don't update r and mark this as the last element ... if (!last && q[1].length === 0) { last = true; } // so, if this isn't the last element, we're going to see if // we can get any more matches from the remaining (unmatched) // elements ... if (!last) { // build a list of the remaining rules we can match against, // i.e., all but the one we just matched against var qx = []; for (var j = 0; j < px.length ; j++) { if (i !== j) { qx.push(px[j]); } } // now invoke recursively set with the remaining input // note that we don't include the closing delimiter ... // we'll check for that ourselves at the end p = _.set(qx, d).call(this, q[1]); // if we got a non-empty set as a result ... // (otw rx already contains everything we want to match) if (p[0].length > 0) { // update current result, which is stored in rx ... // basically, pick up the remaining text from p[1] // and concat the result from p[0] so that we don't // get endless nesting ... rx[0] = rx[0].concat(p[0]); rx[1] = p[1]; } } // at this point, rx either contains the last matched element // or the entire matched set that starts with this element. // now we just check to see if this variation is better than // our best so far, in terms of how much of the input is parsed if (rx[1].length < best[1].length) { best = rx; } // if we've parsed all the input, then we're finished if (best[1].length === 0) { break; } } // so now we've either gone through all the patterns trying them // as the initial match; or we found one that parsed the entire // input string ... // if best has no matches, just return empty set ... if (best[0].length === 0) { return best; } // if a closing delimiter is provided, then we have to check it also if (c) { // we try this even if there is no remaining input because the pattern // may well be optional or match empty input ... try { q = c.call(this, best[1]); } catch (ey) { throw new $P.Exception(best[1]); } // it parsed ... be sure to update the best match remaining input best[1] = q[1]; } // if we're here, either there was no closing delimiter or we parsed it // so now we have the best match; just return it! return best; }; }, forward: function (gr, fname) { return function (s) { return gr[fname].call(this, s); }; }, // // Translation Operators // replace: function (rule, repl) { return function (s) { var r = rule.call(this, s); return [repl, r[1]]; }; }, process: function (rule, fn) { return function (s) { var r = rule.call(this, s); return [fn.call(this, r[0]), r[1]]; }; }, min: function (min, rule) { return function (s) { var rx = rule.call(this, s); if (rx[0].length < min) { throw new $P.Exception(s); } return rx; }; } }; // Generator Operators And Vector Operators // Generators are operators that have a signature of F(R) => R, // taking a given rule and returning another rule, such as // ignore, which parses a given rule and throws away the result. // Vector operators are those that have a signature of F(R1,R2,...) => R, // take a list of rules and returning a new rule, such as each. // Generator operators are converted (via the following _generator // function) into functions that can also take a list or array of rules // and return an array of new rules as though the function had been // called on each rule in turn (which is what actually happens). // This allows generators to be used with vector operators more easily. // Example: // each(ignore(foo, bar)) instead of each(ignore(foo), ignore(bar)) // This also turns generators into vector operators, which allows // constructs like: // not(cache(foo, bar)) var _generator = function (op) { function gen() { var args = null, rx = [], px, i; if (arguments.length > 1) { args = Array.prototype.slice.call(arguments); } else if (arguments[0] instanceof Array) { args = arguments[0]; } if (args) { px = args.shift(); if (px.length > 0) { args.unshift(px[i]); rx.push(op.apply(null, args)); args.shift(); return rx; } } else { return op.apply(null, arguments); } } return gen; }; var gx = "optional not ignore cache".split(/\s/); for (var i = 0 ; i < gx.length ; i++) { _[gx[i]] = _generator(_[gx[i]]); } var _vector = function (op) { return function () { if (arguments[0] instanceof Array) { return op.apply(null, arguments[0]); } else { return op.apply(null, arguments); } }; }; var vx = "each any all".split(/\s/); for (var j = 0 ; j < vx.length ; j++) { _[vx[j]] = _vector(_[vx[j]]); } }()); (function () { var $D = Date; var flattenAndCompact = function (ax) { var rx = []; for (var i = 0; i < ax.length; i++) { if (ax[i] instanceof Array) { rx = rx.concat(flattenAndCompact(ax[i])); } else { if (ax[i]) { rx.push(ax[i]); } } } return rx; }; var parseMeridian = function () { if (this.meridian && (this.hour || this.hour === 0)) { if (this.meridian === "a" && this.hour > 11 && Date.Config.strict24hr){ throw "Invalid hour and meridian combination"; } else if (this.meridian === "p" && this.hour < 12 && Date.Config.strict24hr){ throw "Invalid hour and meridian combination"; } else if (this.meridian === "p" && this.hour < 12) { this.hour = this.hour + 12; } else if (this.meridian === "a" && this.hour === 12) { this.hour = 0; } } }; var setDefaults = function () { var now = new Date(); if ((this.hour || this.minute) && (!this.month && !this.year && !this.day)) { this.day = now.getDate(); } if (!this.year) { this.year = now.getFullYear(); } if (!this.month && this.month !== 0) { this.month = now.getMonth(); } if (!this.day) { this.day = 1; } if (!this.hour) { this.hour = 0; } if (!this.minute) { this.minute = 0; } if (!this.second) { this.second = 0; } if (!this.millisecond) { this.millisecond = 0; } }; var finishUtils = { getToday: function () { if (this.now || "hour minute second".indexOf(this.unit) !== -1) { return new Date(); } else { return $D.today(); } }, setDaysFromWeekday: function (today, orient){ var gap; orient = orient || 1; this.unit = "day"; gap = ($D.getDayNumberFromName(this.weekday) - today.getDay()); this.days = gap ? ((gap + (orient * 7)) % 7) : (orient * 7); return this; }, setMonthsFromMonth: function (today, orient) { var gap; orient = orient || 1; this.unit = "month"; gap = (this.month - today.getMonth()); this.months = gap ? ((gap + (orient * 12)) % 12) : (orient * 12); this.month = null; return this; }, setDMYFromWeekday: function () { var d = Date[this.weekday](); this.day = d.getDate(); if (!this.month) { this.month = d.getMonth(); } this.year = d.getFullYear(); return this; }, setUnitValue: function (orient) { if (!this.value && this.operator && this.operator !== null && this[this.unit + "s"] && this[this.unit + "s"] !== null) { this[this.unit + "s"] = this[this.unit + "s"] + ((this.operator === "add") ? 1 : -1) + (this.value||0) * orient; } else if (this[this.unit + "s"] == null || this.operator != null) { if (!this.value) { this.value = 1; } this[this.unit + "s"] = this.value * orient; } }, generateDateFromWeeks: function () { var weekday = (this.weekday !== undefined) ? this.weekday : "today"; var d = Date[weekday]().addWeeks(this.weeks); if (this.now) { d.setTimeToNow(); } return d; } }; $D.Translator = { hour: function (s) { return function () { this.hour = Number(s); }; }, minute: function (s) { return function () { this.minute = Number(s); }; }, second: function (s) { return function () { this.second = Number(s); }; }, /* for ss.s format */ secondAndMillisecond: function (s) { return function () { var mx = s.match(/^([0-5][0-9])\.([0-9]{1,3})/); this.second = Number(mx[1]); this.millisecond = Number(mx[2]); }; }, meridian: function (s) { return function () { this.meridian = s.slice(0, 1).toLowerCase(); }; }, timezone: function (s) { return function () { var n = s.replace(/[^\d\+\-]/g, ""); if (n.length) { this.timezoneOffset = Number(n); } else { this.timezone = s.toLowerCase(); } }; }, day: function (x) { var s = x[0]; return function () { this.day = Number(s.match(/\d+/)[0]); if (this.day < 1) { throw "invalid day"; } }; }, month: function (s) { return function () { this.month = (s.length === 3) ? "jan feb mar apr may jun jul aug sep oct nov dec".indexOf(s)/4 : Number(s) - 1; if (this.month < 0) { throw "invalid month"; } }; }, year: function (s) { return function () { var n = Number(s); this.year = ((s.length > 2) ? n : (n + (((n + 2000) < Date.CultureInfo.twoDigitYearMax) ? 2000 : 1900))); }; }, rday: function (s) { return function () { switch (s) { case "yesterday": this.days = -1; break; case "tomorrow": this.days = 1; break; case "today": this.days = 0; break; case "now": this.days = 0; this.now = true; break; } }; }, finishExact: function (x) { var d; x = (x instanceof Array) ? x : [x]; for (var i = 0 ; i < x.length ; i++) { if (x[i]) { x[i].call(this); } } setDefaults.call(this); parseMeridian.call(this); if (this.day > $D.getDaysInMonth(this.year, this.month)) { throw new RangeError(this.day + " is not a valid value for days."); } d = new Date(this.year, this.month, this.day, this.hour, this.minute, this.second, this.millisecond); if (this.year < 100) { d.setFullYear(this.year); // means years less that 100 are process correctly. JS will parse it otherwise as 1900-1999. } if (this.timezone) { d.set({ timezone: this.timezone }); } else if (this.timezoneOffset) { d.set({ timezoneOffset: this.timezoneOffset }); } return d; }, finish: function (x) { var today, expression, orient, temp; x = (x instanceof Array) ? flattenAndCompact(x) : [ x ]; if (x.length === 0) { return null; } for (var i = 0 ; i < x.length ; i++) { if (typeof x[i] === "function") { x[i].call(this); } } if (this.now && !this.unit && !this.operator) { return new Date(); } else { today = finishUtils.getToday.call(this); } expression = !!(this.days && this.days !== null || this.orient || this.operator); orient = ((this.orient === "past" || this.operator === "subtract") ? -1 : 1); if (this.month && this.unit === "week") { this.value = this.month + 1; delete this.month; delete this.day; } if ((this.month || this.month === 0) && "year day hour minute second".indexOf(this.unit) !== -1) { if (!this.value) { this.value = this.month + 1; } this.month = null; expression = true; } if (!expression && this.weekday && !this.day && !this.days) { finishUtils.setDMYFromWeekday.call(this); } if (expression && this.weekday && this.unit !== "month" && this.unit !== "week") { finishUtils.setDaysFromWeekday.call(this, today, orient); } if (this.weekday && this.unit !== "week" && !this.day && !this.days) { temp = Date[this.weekday](); this.day = temp.getDate(); if (temp.getMonth() !== today.getMonth()) { this.month = temp.getMonth(); } } if (this.month && this.unit === "day" && this.operator) { if (!this.value) { this.value = (this.month + 1); } this.month = null; } if (this.value != null && this.month != null && this.year != null) { this.day = this.value * 1; } if (this.month && !this.day && this.value) { today.set({ day: this.value * 1 }); if (!expression) { this.day = this.value * 1; } } if (!this.month && this.value && this.unit === "month" && !this.now) { this.month = this.value; expression = true; } if (expression && (this.month || this.month === 0) && this.unit !== "year") { finishUtils.setMonthsFromMonth.call(this, today, orient); } if (!this.unit) { this.unit = "day"; } finishUtils.setUnitValue.call(this, orient); parseMeridian.call(this); if ((this.month || this.month === 0) && !this.day) { this.day = 1; } if (!this.orient && !this.operator && this.unit === "week" && this.value && !this.day && !this.month) { return Date.today().setWeek(this.value); } if (this.unit === "week" && this.weeks && !this.day && !this.month) { return finishUtils.generateDateFromWeeks.call(this); } if (expression && this.timezone && this.day && this.days) { this.day = this.days; } if (expression){ today.add(this); } else { today.set(this); } if (this.timezone) { this.timezone = this.timezone.toUpperCase(); var offset = $D.getTimezoneOffset(this.timezone); var timezone; if (today.hasDaylightSavingTime()) { // lets check that we're being sane with timezone setting timezone = $D.getTimezoneAbbreviation(offset, today.isDaylightSavingTime()); if (timezone !== this.timezone) { // bugger, we're in a place where things like EST vs EDT matters. if (today.isDaylightSavingTime()) { today.addHours(-1); } else { today.addHours(1); } } } today.setTimezoneOffset(offset); } return today; } }; }()); (function () { var $D = Date; $D.Grammar = {}; var _ = $D.Parsing.Operators, g = $D.Grammar, t = $D.Translator, _fn; // Allow rolling up into general purpose rules _fn = function () { return _.each(_.any.apply(null, arguments), _.not(g.ctoken2("timeContext"))); }; g.datePartDelimiter = _.rtoken(/^([\s\-\.\,\/\x27]+)/); g.timePartDelimiter = _.stoken(":"); g.whiteSpace = _.rtoken(/^\s*/); g.generalDelimiter = _.rtoken(/^(([\s\,]|at|@|on)+)/); var _C = {}; g.ctoken = function (keys) { var fn = _C[keys]; if (! fn) { var c = Date.CultureInfo.regexPatterns; var kx = keys.split(/\s+/), px = []; for (var i = 0; i < kx.length ; i++) { px.push(_.replace(_.rtoken(c[kx[i]]), kx[i])); } fn = _C[keys] = _.any.apply(null, px); } return fn; }; g.ctoken2 = function (key) { return _.rtoken(Date.CultureInfo.regexPatterns[key]); }; var cacheProcessRtoken = function (key, token, type, eachToken) { if (eachToken) { g[key] = _.cache(_.process(_.each(_.rtoken(token),_.optional(g.ctoken2(eachToken))), type)); } else { g[key] = _.cache(_.process(_.rtoken(token), type)); } }; var cacheProcessCtoken = function (token, type) { return _.cache(_.process(g.ctoken2(token), type)); }; var _F = {}; //function cache var _get = function (f) { _F[f] = (_F[f] || g.format(f)[0]); return _F[f]; }; g.allformats = function (fx) { var rx = []; if (fx instanceof Array) { for (var i = 0; i < fx.length; i++) { rx.push(_get(fx[i])); } } else { rx.push(_get(fx)); } return rx; }; g.formats = function (fx) { if (fx instanceof Array) { var rx = []; for (var i = 0 ; i < fx.length ; i++) { rx.push(_get(fx[i])); } return _.any.apply(null, rx); } else { return _get(fx); } }; var grammarFormats = { timeFormats: function(){ var i, RTokenKeys = [ "h", "hh", "H", "HH", "m", "mm", "s", "ss", "ss.s", "z", "zz" ], RToken = [ /^(0[0-9]|1[0-2]|[1-9])/, /^(0[0-9]|1[0-2])/, /^([0-1][0-9]|2[0-3]|[0-9])/, /^([0-1][0-9]|2[0-3])/, /^([0-5][0-9]|[0-9])/, /^[0-5][0-9]/, /^([0-5][0-9]|[0-9])/, /^[0-5][0-9]/, /^[0-5][0-9]\.[0-9]{1,3}/, /^((\+|\-)\s*\d\d\d\d)|((\+|\-)\d\d\:?\d\d)/, /^((\+|\-)\s*\d\d\d\d)|((\+|\-)\d\d\:?\d\d)/ ], tokens = [ t.hour, t.hour, t.hour, t.hour, t.minute, t.minute, t.second, t.second, t.secondAndMillisecond, t.timezone, t.timezone ]; for (i=0; i < RTokenKeys.length; i++) { cacheProcessRtoken(RTokenKeys[i], RToken[i], tokens[i]); } g.hms = _.cache(_.sequence([g.H, g.m, g.s], g.timePartDelimiter)); g.t = cacheProcessCtoken("shortMeridian", t.meridian); g.tt = cacheProcessCtoken("longMeridian", t.meridian); g.zzz = cacheProcessCtoken("timezone", t.timezone); g.timeSuffix = _.each(_.ignore(g.whiteSpace), _.set([ g.tt, g.zzz ])); g.time = _.each(_.optional(_.ignore(_.stoken("T"))), g.hms, g.timeSuffix); }, dateFormats: function () { // pre-loaded rules for different date part order preferences var _setfn = function () { return _.set(arguments, g.datePartDelimiter); }; var i, RTokenKeys = [ "d", "dd", "M", "MM", "y", "yy", "yyy", "yyyy" ], RToken = [ /^([0-2]\d|3[0-1]|\d)/, /^([0-2]\d|3[0-1])/, /^(1[0-2]|0\d|\d)/, /^(1[0-2]|0\d)/, /^(\d+)/, /^(\d\d)/, /^(\d\d?\d?\d?)/, /^(\d\d\d\d)/ ], tokens = [ t.day, t.day, t.month, t.month, t.year, t.year, t.year, t.year ], eachToken = [ "ordinalSuffix", "ordinalSuffix" ]; for (i=0; i < RTokenKeys.length; i++) { cacheProcessRtoken(RTokenKeys[i], RToken[i], tokens[i], eachToken[i]); } g.MMM = g.MMMM = _.cache(_.process(g.ctoken("jan feb mar apr may jun jul aug sep oct nov dec"), t.month)); g.ddd = g.dddd = _.cache(_.process(g.ctoken("sun mon tue wed thu fri sat"), function (s) { return function () { this.weekday = s; }; } )); g.day = _fn(g.d, g.dd); g.month = _fn(g.M, g.MMM); g.year = _fn(g.yyyy, g.yy); g.mdy = _setfn(g.ddd, g.month, g.day, g.year); g.ymd = _setfn(g.ddd, g.year, g.month, g.day); g.dmy = _setfn(g.ddd, g.day, g.month, g.year); g.date = function (s) { return ((g[Date.CultureInfo.dateElementOrder] || g.mdy).call(this, s)); }; }, relative: function () { // relative date / time expressions g.orientation = _.process(g.ctoken("past future"), function (s) { return function () { this.orient = s; }; } ); g.operator = _.process(g.ctoken("add subtract"), function (s) { return function () { this.operator = s; }; } ); g.rday = _.process(g.ctoken("yesterday tomorrow today now"), t.rday); g.unit = _.process(g.ctoken("second minute hour day week month year"), function (s) { return function () { this.unit = s; }; } ); } }; g.buildGrammarFormats = function () { // these need to be rebuilt every time the language changes. _C = {}; grammarFormats.timeFormats(); grammarFormats.dateFormats(); grammarFormats.relative(); g.value = _.process(_.rtoken(/^([-+]?\d+)?(st|nd|rd|th)?/), function (s) { return function () { this.value = s.replace(/\D/g, ""); }; } ); g.expression = _.set([g.rday, g.operator, g.value, g.unit, g.orientation, g.ddd, g.MMM ]); g.format = _.process(_.many( _.any( // translate format specifiers into grammar rules _.process( _.rtoken(/^(dd?d?d?(?!e)|MM?M?M?|yy?y?y?|hh?|HH?|mm?|ss?|tt?|zz?z?)/), function (fmt) { if (g[fmt]) { return g[fmt]; } else { throw $D.Parsing.Exception(fmt); } } ), // translate separator tokens into token rules _.process(_.rtoken(/^[^dMyhHmstz]+/), // all legal separators function (s) { return _.ignore(_.stoken(s)); } ) ) ), // construct the parser ... function (rules) { return _.process(_.each.apply(null, rules), t.finishExact); } ); // starting rule for general purpose grammar g._start = _.process(_.set([ g.date, g.time, g.expression ], g.generalDelimiter, g.whiteSpace), t.finish); }; g.buildGrammarFormats(); // parsing date format specifiers - ex: "h:m:s tt" // this little guy will generate a custom parser based // on the format string, ex: g.format("h:m:s tt") // check for these formats first g._formats = g.formats([ "\"yyyy-MM-ddTHH:mm:ssZ\"", "yyyy-MM-ddTHH:mm:ss.sz", "yyyy-MM-ddTHH:mm:ssZ", "yyyy-MM-ddTHH:mm:ssz", "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-ddTHH:mmZ", "yyyy-MM-ddTHH:mmz", "yyyy-MM-ddTHH:mm", "ddd, MMM dd, yyyy H:mm:ss tt", "ddd MMM d yyyy HH:mm:ss zzz", "MMddyyyy", "ddMMyyyy", "Mddyyyy", "ddMyyyy", "Mdyyyy", "dMyyyy", "yyyy", "Mdyy", "dMyy", "d" ]); // real starting rule: tries selected formats first, // then general purpose rule g.start = function (s) { try { var r = g._formats.call({}, s); if (r[1].length === 0) { return r; } } catch (e) {} return g._start.call({}, s); }; }()); (function () { var $D = Date; /** * @desc Converts the specified string value into its JavaScript Date equivalent using CultureInfo specific format information. * * Example

	///////////
	// Dates //
	///////////

	// 15-Oct-2004
	var d1 = Date.parse("10/15/2004");

	// 15-Oct-2004
	var d1 = Date.parse("15-Oct-2004");

	// 15-Oct-2004
	var d1 = Date.parse("2004.10.15");

	//Fri Oct 15, 2004
	var d1 = Date.parse("Fri Oct 15, 2004");

	///////////
	// Times //
	///////////

	// Today at 10 PM.
	var d1 = Date.parse("10 PM");

	// Today at 10:30 PM.
	var d1 = Date.parse("10:30 P.M.");

	// Today at 6 AM.
	var d1 = Date.parse("06am");

	/////////////////////
	// Dates and Times //
	/////////////////////

	// 8-July-2004 @ 10:30 PM
	var d1 = Date.parse("July 8th, 2004, 10:30 PM");

	// 1-July-2004 @ 10:30 PM
	var d1 = Date.parse("2004-07-01T22:30:00");

	////////////////////
	// Relative Dates //
	////////////////////

	// Returns today's date. The string "today" is culture specific.
	var d1 = Date.parse("today");

	// Returns yesterday's date. The string "yesterday" is culture specific.
	var d1 = Date.parse("yesterday");

	// Returns the date of the next thursday.
	var d1 = Date.parse("Next thursday");

	// Returns the date of the most previous monday.
	var d1 = Date.parse("last monday");

	// Returns today's day + one year.
	var d1 = Date.parse("next year");

	///////////////
	// Date Math //
	///////////////

	// Today + 2 days
	var d1 = Date.parse("t+2");

	// Today + 2 days
	var d1 = Date.parse("today + 2 days");

	// Today + 3 months
	var d1 = Date.parse("t+3m");

	// Today - 1 year
	var d1 = Date.parse("today - 1 year");

	// Today - 1 year
	var d1 = Date.parse("t-1y"); 


	/////////////////////////////
	// Partial Dates and Times //
	/////////////////////////////

	// July 15th of this year.
	var d1 = Date.parse("July 15");

	// 15th day of current day and year.
	var d1 = Date.parse("15");

	// July 1st of current year at 10pm.
	var d1 = Date.parse("7/1 10pm");
	
* * @param {String} The string value to convert into a Date object [Required] * @return {Date} A Date object or null if the string cannot be converted into a Date. */ var parseUtils = { removeOrds: function (s) { ords = s.match(/\b(\d+)(?:st|nd|rd|th)\b/); // find ordinal matches s = ((ords && ords.length === 2) ? s.replace(ords[0], ords[1]) : s); return s; }, grammarParser: function (s) { var r = null; try { r = $D.Grammar.start.call({}, s.replace(/^\s*(\S*(\s+\S+)*)\s*$/, "$1")); } catch (e) { return null; } return ((r[1].length === 0) ? r[0] : null); }, nativeFallback: function(s) { var t; try { // ok we haven't parsed it, last ditch attempt with the built-in parser. t = Date._parse(s); return (t || t === 0) ? new Date(t) : null; } catch (e) { return null; } } }; function parse (s) { var d; if (!s) { return null; } if (s instanceof Date) { return s.clone(); } if (s.length >= 4 && s.charAt(0) !== "0" && s.charAt(0) !== "+"&& s.charAt(0) !== "-") { // ie: 2004 will pass, 0800 won't. // Start with specific formats d = $D.Parsing.ISO.parse(s) || $D.Parsing.Numeric.parse(s); } if (d instanceof Date && !isNaN(d.getTime())) { return d; } else { // find ordinal dates (1st, 3rd, 8th, etc and remove them as they cause parsing issues) s = $D.Parsing.Normalizer.parse(parseUtils.removeOrds(s)); d = parseUtils.grammarParser(s); if (d !== null) { return d; } else { return parseUtils.nativeFallback(s); } } } if (!$D._parse) { $D._parse = $D.parse; } $D.parse = parse; Date.getParseFunction = function (fx) { var fns = Date.Grammar.allformats(fx); return function (s) { var r = null; for (var i = 0; i < fns.length; i++) { try { r = fns[i].call({}, s); } catch (e) { continue; } if (r[1].length === 0) { return r[0]; } } return null; }; }; /** * Converts the specified string value into its JavaScript Date equivalent using the specified format {String} or formats {Array} and the CultureInfo specific format information. * The format of the string value must match one of the supplied formats exactly. * * Example

	// 15-Oct-2004
	var d1 = Date.parseExact("10/15/2004", "M/d/yyyy");

	// 15-Oct-2004
	var d1 = Date.parse("15-Oct-2004", "M-ddd-yyyy");

	// 15-Oct-2004
	var d1 = Date.parse("2004.10.15", "yyyy.MM.dd");

	// Multiple formats
	var d1 = Date.parseExact("10/15/2004", ["M/d/yyyy", "MMMM d, yyyy"]);
	
* * @param {String} The string value to convert into a Date object [Required]. * @param {Object} The expected format {String} or an array of expected formats {Array} of the date string [Required]. * @return {Date} A Date object or null if the string cannot be converted into a Date. */ $D.parseExact = function (s, fx) { return $D.getParseFunction(fx)(s); }; }()); (function () { var $D = Date, $P = $D.prototype, // $C = $D.CultureInfo, // not used atm p = function (s, l) { if (!l) { l = 2; } return ("000" + s).slice(l * -1); }; /** * Converts a PHP format string to Java/.NET format string. * A PHP format string can be used with ._format or .format. * A Java/.NET format string can be used with .toString(). * The .parseExact function will only accept a Java/.NET format string * * Example * var f1 = "%m/%d/%y" * var f2 = Date.normalizeFormat(f1); // "MM/dd/yy" * * new Date().format(f1); // "04/13/08" * new Date()._format(f1); // "04/13/08" * new Date().toString(f2); // "04/13/08" * * var date = Date.parseExact("04/13/08", f2); // Sun Apr 13 2008 * * @param {String} A PHP format string consisting of one or more format spcifiers. * @return {String} The PHP format converted to a Java/.NET format string. */ var normalizerSubstitutions = { "d" : "dd", "%d": "dd", "D" : "ddd", "%a": "ddd", "j" : "dddd", "l" : "dddd", "%A": "dddd", "S" : "S", "F" : "MMMM", "%B": "MMMM", "m" : "MM", "%m": "MM", "M" : "MMM", "%b": "MMM", "%h": "MMM", "n" : "M", "Y" : "yyyy", "%Y": "yyyy", "y" : "yy", "%y": "yy", "g" : "h", "%I": "h", "G" : "H", "h" : "hh", "H" : "HH", "%H": "HH", "i" : "mm", "%M": "mm", "s" : "ss", "%S": "ss", "%r": "hh:mm tt", "%R": "H:mm", "%T": "H:mm:ss", "%X": "t", "%x": "d", "%e": "d", "%D": "MM/dd/yy", "%n": "\\n", "%t": "\\t", "e" : "z", "T" : "z", "%z": "z", "%Z": "z", "Z" : "ZZ", "N" : "u", "w" : "u", "%w": "u", "W" : "W", "%V": "W" }; var normalizer = { substitutes: function (m) { return normalizerSubstitutions[m]; }, interpreted: function (m, x) { var y; switch (m) { case "%u": return x.getDay() + 1; case "z": return x.getOrdinalNumber(); case "%j": return p(x.getOrdinalNumber(), 3); case "%U": var d1 = x.clone().set({month: 0, day: 1}).addDays(-1).moveToDayOfWeek(0), d2 = x.clone().addDays(1).moveToDayOfWeek(0, -1); return (d2 < d1) ? "00" : p((d2.getOrdinalNumber() - d1.getOrdinalNumber()) / 7 + 1); case "%W": return p(x.getWeek()); case "t": return $D.getDaysInMonth(x.getFullYear(), x.getMonth()); case "o": case "%G": return x.setWeek(x.getISOWeek()).toString("yyyy"); case "%g": return x._format("%G").slice(-2); case "a": case "%p": return t("tt").toLowerCase(); case "A": return t("tt").toUpperCase(); case "u": return p(x.getMilliseconds(), 3); case "I": return (x.isDaylightSavingTime()) ? 1 : 0; case "O": return x.getUTCOffset(); case "P": y = x.getUTCOffset(); return y.substring(0, y.length - 2) + ":" + y.substring(y.length - 2); case "B": var now = new Date(); return Math.floor(((now.getHours() * 3600) + (now.getMinutes() * 60) + now.getSeconds() + (now.getTimezoneOffset() + 60) * 60) / 86.4); case "c": return x.toISOString().replace(/\"/g, ""); case "U": return $D.strtotime("now"); case "%c": return t("d") + " " + t("t"); case "%C": return Math.floor(x.getFullYear() / 100 + 1); } }, shouldOverrideDefaults: function (m) { switch (m) { case "%e": return true; default: return false; } }, parse: function (m, context) { var formatString, c = context || new Date(); formatString = normalizer.substitutes(m); if (formatString) { return formatString; } formatString = normalizer.interpreted(m, c); if (formatString) { return formatString; } else { return m; } } }; $D.normalizeFormat = function (format, context) { return format.replace(/(%|\\)?.|%%/g, function(t){ return normalizer.parse(t, context); }); }; /** * Format a local Unix timestamp according to locale settings * * Example: * Date.strftime("%m/%d/%y", new Date()); // "04/13/08" * Date.strftime("c", "2008-04-13T17:52:03Z"); // "04/13/08" * * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @param {Number|String} The number representing the number of seconds that have elapsed since January 1, 1970 (local time). * @return {String} A string representation of the current Date object. */ $D.strftime = function (format, time) { var d = Date.parse(time); return d._format(format); }; /** * Parse any textual datetime description into a Unix timestamp. * A Unix timestamp is the number of seconds that have elapsed since January 1, 1970 (midnight UTC/GMT). * * Example: * Date.strtotime("04/13/08"); // 1208044800 * Date.strtotime("1970-01-01T00:00:00Z"); // 0 * * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @param {Object} A string or date object. * @return {String} A string representation of the current Date object. */ $D.strtotime = function (time) { var d = $D.parse(time); return Math.round($D.UTC(d.getUTCFullYear(), d.getUTCMonth(), d.getUTCDate(), d.getUTCHours(), d.getUTCMinutes(), d.getUTCSeconds(), d.getUTCMilliseconds()) / 1000); }; /** * Converts the value of the current Date object to its equivalent string representation using a PHP/Unix style of date format specifiers. * Format Specifiers * Format Description Example * ------ --------------------------------------------------------------------------- ----------------------- * %a abbreviated weekday name according to the current localed "Mon" through "Sun" * %A full weekday name according to the current localed "Sunday" through "Saturday" * %b abbreviated month name according to the current localed "Jan" through "Dec" * %B full month name according to the current locale "January" through "December" * %c preferred date and time representation for the current locale "4/13/2008 12:33 PM" * %C century number (the year divided by 100 and truncated to an integer) "00" to "99" * %d day of the month as a decimal number "01" to "31" * %D same as %m/%d/%y "04/13/08" * %e day of the month as a decimal number, a single digit is preceded by a space "1" to "31" * %g like %G, but without the century "08" * %G The 4-digit year corresponding to the ISO week number (see %V). "2008" * This has the same format and value as %Y, except that if the ISO week number * belongs to the previous or next year, that year is used instead. * %h same as %b "Jan" through "Dec" * %H hour as a decimal number using a 24-hour clock. "00" to "23" * %I hour as a decimal number using a 12-hour clock. "01" to "12" * %j day of the year as a decimal number. "001" to "366" * %m month as a decimal number. "01" to "12" * %M minute as a decimal number. "00" to "59" * %n newline character "\n" * %p either "am" or "pm" according to the given time value, or the "am" or "pm" * corresponding strings for the current locale. * %r time in a.m. and p.m. notation "8:44 PM" * %R time in 24 hour notation "20:44" * %S second as a decimal number "00" to "59" * %t tab character "\t" * %T current time, equal to %H:%M:%S "12:49:11" * %u weekday as a decimal number ["1", "7"], with "1" representing Monday "1" to "7" * %U week number of the current year as a decimal number, starting with the "0" to ("52" or "53") * first Sunday as the first day of the first week * %V The ISO 8601:1988 week number of the current year as a decimal number, "00" to ("52" or "53") * range 01 to 53, where week 1 is the first week that has at least 4 days * in the current year, and with Monday as the first day of the week. * (Use %G or %g for the year component that corresponds to the week number * for the specified timestamp.) * %W week number of the current year as a decimal number, starting with the "00" to ("52" or "53") * first Monday as the first day of the first week * %w day of the week as a decimal, Sunday being "0" "0" to "6" * %x preferred date representation for the current locale without the time "4/13/2008" * %X preferred time representation for the current locale without the date "12:53:05" * %y year as a decimal number without a century "00" "99" * %Y year as a decimal number including the century "2008" * %Z time zone or name or abbreviation "UTC", "EST", "PST" * %z same as %Z * %% a literal "%" characters "%" * d Day of the month, 2 digits with leading zeros "01" to "31" * D A textual representation of a day, three letters "Mon" through "Sun" * j Day of the month without leading zeros "1" to "31" * l A full textual representation of the day of the week (lowercase "L") "Sunday" through "Saturday" * N ISO-8601 numeric representation of the day of the week (added in PHP 5.1.0) "1" (for Monday) through "7" (for Sunday) * S English ordinal suffix for the day of the month, 2 characters "st", "nd", "rd" or "th". Works well with j * w Numeric representation of the day of the week "0" (for Sunday) through "6" (for Saturday) * z The day of the year (starting from "0") "0" through "365" * W ISO-8601 week number of year, weeks starting on Monday "00" to ("52" or "53") * F A full textual representation of a month, such as January or March "January" through "December" * m Numeric representation of a month, with leading zeros "01" through "12" * M A short textual representation of a month, three letters "Jan" through "Dec" * n Numeric representation of a month, without leading zeros "1" through "12" * t Number of days in the given month "28" through "31" * L Whether it's a leap year "1" if it is a leap year, "0" otherwise * o ISO-8601 year number. This has the same value as Y, except that if the "2008" * ISO week number (W) belongs to the previous or next year, that year * is used instead. * Y A full numeric representation of a year, 4 digits "2008" * y A two digit representation of a year "08" * a Lowercase Ante meridiem and Post meridiem "am" or "pm" * A Uppercase Ante meridiem and Post meridiem "AM" or "PM" * B Swatch Internet time "000" through "999" * g 12-hour format of an hour without leading zeros "1" through "12" * G 24-hour format of an hour without leading zeros "0" through "23" * h 12-hour format of an hour with leading zeros "01" through "12" * H 24-hour format of an hour with leading zeros "00" through "23" * i Minutes with leading zeros "00" to "59" * s Seconds, with leading zeros "00" through "59" * u Milliseconds "54321" * e Timezone identifier "UTC", "EST", "PST" * I Whether or not the date is in daylight saving time (uppercase i) "1" if Daylight Saving Time, "0" otherwise * O Difference to Greenwich time (GMT) in hours "+0200", "-0600" * P Difference to Greenwich time (GMT) with colon between hours and minutes "+02:00", "-06:00" * T Timezone abbreviation "UTC", "EST", "PST" * Z Timezone offset in seconds. The offset for timezones west of UTC is "-43200" through "50400" * always negative, and for those east of UTC is always positive. * c ISO 8601 date "2004-02-12T15:19:21+00:00" * r RFC 2822 formatted date "Thu, 21 Dec 2000 16:01:07 +0200" * U Seconds since the Unix Epoch (January 1 1970 00:00:00 GMT) "0" * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @return {String} A string representation of the current Date object. */ var formatReplace = function (context) { return function (m) { var formatString, override = false; if (m.charAt(0) === "\\" || m.substring(0, 2) === "%%") { return m.replace("\\", "").replace("%%", "%"); } override = normalizer.shouldOverrideDefaults(m); formatString = $D.normalizeFormat(m, context); if (formatString) { return context.toString(formatString, override); } }; }; $P._format = function (format) { var formatter = formatReplace(this); if (!format) { return this._toString(); } else { return format.replace(/(%|\\)?.|%%/g, formatter); } }; if (!$P.format) { $P.format = $P._format; } }()); (function () { "use strict"; var gFn = function (attr) { return function () { return this[attr]; }; }; var sFn = function (attr) { return function (val) { this[attr] = val; return this; }; }; var attrs = ["years", "months", "days", "hours", "minutes", "seconds", "milliseconds"]; var addSetFuncs = function (context, attrs) { for (var i = 0; i < attrs.length ; i++) { var $a = attrs[i], $b = $a.slice(0, 1).toUpperCase() + $a.slice(1); context.prototype[$a] = 0; context.prototype["get" + $b] = gFn($a); context.prototype["set" + $b] = sFn($a); } }; /** * new TimeSpan(milliseconds); * new TimeSpan(days, hours, minutes, seconds); * new TimeSpan(days, hours, minutes, seconds, milliseconds); */ var TimeSpan = function (days, hours, minutes, seconds, milliseconds) { if (arguments.length === 1 && typeof days === "number") { var orient = (days < 0) ? -1 : +1; var millsLeft = Math.abs(days); this.setDays(Math.floor(millsLeft / 86400000) * orient); millsLeft = millsLeft % 86400000; this.setHours(Math.floor(millsLeft / 3600000) * orient); millsLeft = millsLeft % 3600000; this.setMinutes(Math.floor(millsLeft / 60000) * orient); millsLeft = millsLeft % 60000; this.setSeconds(Math.floor(millsLeft / 1000) * orient); millsLeft = millsLeft % 1000; this.setMilliseconds(millsLeft * orient); } else { this.set(days, hours, minutes, seconds, milliseconds); } this.getTotalMilliseconds = function () { return (this.getDays() * 86400000) + (this.getHours() * 3600000) + (this.getMinutes() * 60000) + (this.getSeconds() * 1000); }; this.compareTo = function (time) { var t1 = new Date(1970, 1, 1, this.getHours(), this.getMinutes(), this.getSeconds()), t2; if (time === null) { t2 = new Date(1970, 1, 1, 0, 0, 0); } else { t2 = new Date(1970, 1, 1, time.getHours(), time.getMinutes(), time.getSeconds()); } return (t1 < t2) ? -1 : (t1 > t2) ? 1 : 0; }; this.equals = function (time) { return (this.compareTo(time) === 0); }; this.add = function (time) { return (time === null) ? this : this.addSeconds(time.getTotalMilliseconds() / 1000); }; this.subtract = function (time) { return (time === null) ? this : this.addSeconds(-time.getTotalMilliseconds() / 1000); }; this.addDays = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 86400000)); }; this.addHours = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 3600000)); }; this.addMinutes = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 60000)); }; this.addSeconds = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 1000)); }; this.addMilliseconds = function (n) { return new TimeSpan(this.getTotalMilliseconds() + n); }; this.get12HourHour = function () { return (this.getHours() > 12) ? this.getHours() - 12 : (this.getHours() === 0) ? 12 : this.getHours(); }; this.getDesignator = function () { return (this.getHours() < 12) ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator; }; this.toString = function (format) { this._toString = function () { if (this.getDays() !== null && this.getDays() > 0) { return this.getDays() + "." + this.getHours() + ":" + this.p(this.getMinutes()) + ":" + this.p(this.getSeconds()); } else { return this.getHours() + ":" + this.p(this.getMinutes()) + ":" + this.p(this.getSeconds()); } }; this.p = function (s) { return (s.toString().length < 2) ? "0" + s : s; }; var me = this; return format ? format.replace(/dd?|HH?|hh?|mm?|ss?|tt?/g, function (format) { switch (format) { case "d": return me.getDays(); case "dd": return me.p(me.getDays()); case "H": return me.getHours(); case "HH": return me.p(me.getHours()); case "h": return me.get12HourHour(); case "hh": return me.p(me.get12HourHour()); case "m": return me.getMinutes(); case "mm": return me.p(me.getMinutes()); case "s": return me.getSeconds(); case "ss": return me.p(me.getSeconds()); case "t": return ((me.getHours() < 12) ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator).substring(0, 1); case "tt": return (me.getHours() < 12) ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator; } } ) : this._toString(); }; return this; }; addSetFuncs(TimeSpan, attrs.slice(2)); TimeSpan.prototype.set = function (days, hours, minutes, seconds, milliseconds){ this.setDays(days || this.getDays()); this.setHours(hours || this.getHours()); this.setMinutes(minutes || this.getMinutes()); this.setSeconds(seconds || this.getSeconds()); this.setMilliseconds(milliseconds || this.getMilliseconds()); }; /** * Gets the time of day for this date instances. * @return {TimeSpan} TimeSpan */ Date.prototype.getTimeOfDay = function () { return new TimeSpan(0, this.getHours(), this.getMinutes(), this.getSeconds(), this.getMilliseconds()); }; Date.TimeSpan = TimeSpan; if (typeof window !== "undefined" ) { // keeping API compatible for v1.x window.TimeSpan = TimeSpan; } }()); (function () { "use strict"; var attrs = ["years", "months", "days", "hours", "minutes", "seconds", "milliseconds"]; var gFn = function (attr) { return function () { return this[attr]; }; }; var sFn = function (attr) { return function (val) { this[attr] = val; return this; }; }; var addSetFuncs = function (context, attrs) { for (var i = 0; i < attrs.length ; i++) { var $a = attrs[i], $b = $a.slice(0, 1).toUpperCase() + $a.slice(1); context.prototype[$a] = 0; context.prototype["get" + $b] = gFn($a); context.prototype["set" + $b] = sFn($a); } }; var setMonthsAndYears = function (orient, d1, d2, context) { function inc() { d1.addMonths(-orient); context.months++; if (context.months === 12) { context.years++; context.months = 0; } } if (orient === +1) { while (d1 > d2) { inc(); } } else { while (d1 < d2) { inc(); } } context.months--; context.months *= orient; context.years *= orient; }; var adjustForDST = function(orient, startDate, endDate) { var hasDSTMismatch = (false === (startDate.isDaylightSavingTime() === endDate.isDaylightSavingTime())); if (hasDSTMismatch && orient === 1) { startDate.addHours(-1); } else if (hasDSTMismatch) { startDate.addHours(1); } }; /** * TimePeriod(startDate, endDate); * TimePeriod(years, months, days, hours, minutes, seconds, milliseconds); */ var TimePeriod = function (years, months, days, hours, minutes, seconds, milliseconds) { if (arguments.length === 7) { this.set(years, months, days, hours, minutes, seconds, milliseconds); } else if (arguments.length === 2 && arguments[0] instanceof Date && arguments[1] instanceof Date) { var startDate = arguments[0].clone(); var endDate = arguments[1].clone(); var orient = (startDate > endDate) ? +1 : -1; this.dates = { start: arguments[0].clone(), end: arguments[1].clone() }; setMonthsAndYears(orient, startDate, endDate, this); adjustForDST(orient, startDate, endDate); // // TODO - adjust for DST var diff = endDate - startDate; if (diff !== 0) { var ts = new TimeSpan(diff); this.set(this.years, this.months, ts.getDays(), ts.getHours(), ts.getMinutes(), ts.getSeconds(), ts.getMilliseconds()); } } return this; }; // create all the set functions. addSetFuncs(TimePeriod, attrs); TimePeriod.prototype.set = function (years, months, days, hours, minutes, seconds, milliseconds){ this.setYears(years || this.getYears()); this.setMonths(months || this.getMonths()); this.setDays(days || this.getDays()); this.setHours(hours || this.getHours()); this.setMinutes(minutes || this.getMinutes()); this.setSeconds(seconds || this.getSeconds()); this.setMilliseconds(milliseconds || this.getMilliseconds()); }; Date.TimePeriod = TimePeriod; if (typeof window !== "undefined") { // keeping API compatible for v1.x window.TimePeriod = TimePeriod; } }()); ================================================ FILE: build/date-kok-IN.js ================================================ /** * @overview datejs * @version 1.0.0-rc3 * @author Gregory Wild-Smith * @copyright 2015 Gregory Wild-Smith * @license MIT * @homepage https://github.com/abritinthebay/datejs */ /* * DateJS Culture String File * Country Code: kok-IN * Name: Konkani (India) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["kok-IN"] = { "name": "kok-IN", "englishName": "Konkani (India)", "nativeName": "कोंकणी (भारत)", "Sunday": "आयतार", "Monday": "सोमार", "Tuesday": "मंगळार", "Wednesday": "बुधवार", "Thursday": "बिरेस्तार", "Friday": "सुक्रार", "Saturday": "शेनवार", "Sun": "आय.", "Mon": "सोम.", "Tue": "मंगळ.", "Wed": "बुध.", "Thu": "बिरे.", "Fri": "सुक्र.", "Sat": "शेन.", "Su": "आ", "Mo": "स", "Tu": "म", "We": "ब", "Th": "ब", "Fr": "स", "Sa": "श", "S_Sun_Initial": "आ", "M_Mon_Initial": "स", "T_Tue_Initial": "म", "W_Wed_Initial": "ब", "T_Thu_Initial": "ब", "F_Fri_Initial": "स", "S_Sat_Initial": "श", "January": "जानेवारी", "February": "फेब्रुवारी", "March": "मार्च", "April": "एप्रिल", "May": "मे", "June": "जून", "July": "जुलै", "August": "ऑगस्ट", "September": "सप्टेंबर", "October": "ऑक्टोबर", "November": "नोवेम्बर", "December": "डिसेंबर", "Jan_Abbr": "जानेवारी", "Feb_Abbr": "फेब्रुवारी", "Mar_Abbr": "मार्च", "Apr_Abbr": "एप्रिल", "May_Abbr": "मे", "Jun_Abbr": "जून", "Jul_Abbr": "जुलै", "Aug_Abbr": "ऑगस्ट", "Sep_Abbr": "सप्टेंबर", "Oct_Abbr": "ऑक्टोबर", "Nov_Abbr": "नोवेम्बर", "Dec_Abbr": "डिसेंबर", "AM": "म.पू.", "PM": "म.नं.", "firstDayOfWeek": 1, "twoDigitYearMax": 2029, "mdy": "dmy", "M/d/yyyy": "dd-MM-yyyy", "dddd, MMMM dd, yyyy": "dd MMMM yyyy", "h:mm tt": "HH:mm", "h:mm:ss tt": "HH:mm:ss", "dddd, MMMM dd, yyyy h:mm:ss tt": "dd MMMM yyyy HH:mm:ss", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "dd MMMM", "MMMM, yyyy": "MMMM, yyyy", "/jan(uary)?/": "जानेवारी", "/feb(ruary)?/": "फेब्रुवारी", "/mar(ch)?/": "मार्च", "/apr(il)?/": "एप्रिल", "/may/": "मे", "/jun(e)?/": "जून", "/jul(y)?/": "जुलै", "/aug(ust)?/": "ऑगस्ट", "/sep(t(ember)?)?/": "सप्टेंबर", "/oct(ober)?/": "ऑक्टोबर", "/nov(ember)?/": "नोवेम्बर", "/dec(ember)?/": "डिसेंबर", "/^su(n(day)?)?/": "^आ(य(.(तार)?)?)?", "/^mo(n(day)?)?/": "^स(ोम(.(ार)?)?)?", "/^tu(e(s(day)?)?)?/": "^म(ंगळ(.(ार)?)?)?", "/^we(d(nesday)?)?/": "^ब(ुध(.(वार)?)?)?", "/^th(u(r(s(day)?)?)?)?/": "^ब(िरे(.(स्तार)?)?)?", "/^fr(i(day)?)?/": "^स(ुक्र(.(ार)?)?)?", "/^sa(t(urday)?)?/": "^श(ेन(.(वार)?)?)?", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "kok-IN"; /** * @overview datejs * @version 1.0.0-rc3 * @author Gregory Wild-Smith * @copyright 2015 Gregory Wild-Smith * @license MIT * @homepage https://github.com/abritinthebay/datejs */(function () { var $D = Date; var lang = Date.CultureStrings ? Date.CultureStrings.lang : null; var loggedKeys = {}; // for debug purposes. var getText = { getFromKey: function (key, countryCode) { var output; if (Date.CultureStrings && Date.CultureStrings[countryCode] && Date.CultureStrings[countryCode][key]) { output = Date.CultureStrings[countryCode][key]; } else { output = getText.buildFromDefault(key); } if (key.charAt(0) === "/") { // Assume it's a regex output = getText.buildFromRegex(key, countryCode); } return output; }, getFromObjectValues: function (obj, countryCode) { var key, output = {}; for(key in obj) { if (obj.hasOwnProperty(key)) { output[key] = getText.getFromKey(obj[key], countryCode); } } return output; }, getFromObjectKeys: function (obj, countryCode) { var key, output = {}; for(key in obj) { if (obj.hasOwnProperty(key)) { output[getText.getFromKey(key, countryCode)] = obj[key]; } } return output; }, getFromArray: function (arr, countryCode) { var output = []; for (var i=0; i < arr.length; i++){ if (i in arr) { output[i] = getText.getFromKey(arr[i], countryCode); } } return output; }, buildFromDefault: function (key) { var output, length, split, last; switch(key) { case "name": output = "en-US"; break; case "englishName": output = "English (United States)"; break; case "nativeName": output = "English (United States)"; break; case "twoDigitYearMax": output = 2049; break; case "firstDayOfWeek": output = 0; break; default: output = key; split = key.split("_"); length = split.length; if (length > 1 && key.charAt(0) !== "/") { // if the key isn't a regex and it has a split. last = split[(length - 1)].toLowerCase(); if (last === "initial" || last === "abbr") { output = split[0]; } } break; } return output; }, buildFromRegex: function (key, countryCode) { var output; if (Date.CultureStrings && Date.CultureStrings[countryCode] && Date.CultureStrings[countryCode][key]) { output = new RegExp(Date.CultureStrings[countryCode][key], "i"); } else { output = new RegExp(key.replace(new RegExp("/", "g"),""), "i"); } return output; } }; var shallowMerge = function (obj1, obj2) { for (var attrname in obj2) { if (obj2.hasOwnProperty(attrname)) { obj1[attrname] = obj2[attrname]; } } }; var __ = function (key, language) { var countryCode = (language) ? language : lang; loggedKeys[key] = key; if (typeof key === "object") { if (key instanceof Array) { return getText.getFromArray(key, countryCode); } else { return getText.getFromObjectKeys(key, countryCode); } } else { return getText.getFromKey(key, countryCode); } }; var loadI18nScript = function (code) { // paatterned after jQuery's getScript. var url = Date.Config.i18n + code + ".js"; var head = document.getElementsByTagName("head")[0] || document.documentElement; var script = document.createElement("script"); script.src = url; var completed = false; var events = { done: function (){} // placeholder function }; // Attach handlers for all browsers script.onload = script.onreadystatechange = function() { if ( !completed && (!this.readyState || this.readyState === "loaded" || this.readyState === "complete") ) { events.done(); head.removeChild(script); } }; setTimeout(function() { head.insertBefore(script, head.firstChild); }, 0); // allows return to execute first return { done: function (cb) { events.done = function() { if (cb) { setTimeout(cb,0); } }; } }; }; var buildInfo = { buildFromMethodHash: function (obj) { var key; for(key in obj) { if (obj.hasOwnProperty(key)) { obj[key] = buildInfo[obj[key]](); } } return obj; }, timeZoneDST: function () { var DST = { "CHADT": "+1345", "NZDT": "+1300", "AEDT": "+1100", "ACDT": "+1030", "AZST": "+0500", "IRDT": "+0430", "EEST": "+0300", "CEST": "+0200", "BST": "+0100", "PMDT": "-0200", "ADT": "-0300", "NDT": "-0230", "EDT": "-0400", "CDT": "-0500", "MDT": "-0600", "PDT": "-0700", "AKDT": "-0800", "HADT": "-0900" }; return __(DST); }, timeZoneStandard: function () { var standard = { "LINT": "+1400", "TOT": "+1300", "CHAST": "+1245", "NZST": "+1200", "NFT": "+1130", "SBT": "+1100", "AEST": "+1000", "ACST": "+0930", "JST": "+0900", "CWST": "+0845", "CT": "+0800", "ICT": "+0700", "MMT": "+0630", "BST": "+0600", "NPT": "+0545", "IST": "+0530", "PKT": "+0500", "AFT": "+0430", "MSK": "+0400", "IRST": "+0330", "FET": "+0300", "EET": "+0200", "CET": "+0100", "GMT": "+0000", "UTC": "+0000", "CVT": "-0100", "GST": "-0200", "BRT": "-0300", "NST": "-0330", "AST": "-0400", "EST": "-0500", "CST": "-0600", "MST": "-0700", "PST": "-0800", "AKST": "-0900", "MIT": "-0930", "HST": "-1000", "SST": "-1100", "BIT": "-1200" }; return __(standard); }, timeZones: function (data) { var zone; data.timezones = []; for (zone in data.abbreviatedTimeZoneStandard) { if (data.abbreviatedTimeZoneStandard.hasOwnProperty(zone)) { data.timezones.push({ name: zone, offset: data.abbreviatedTimeZoneStandard[zone]}); } } for (zone in data.abbreviatedTimeZoneDST) { if (data.abbreviatedTimeZoneDST.hasOwnProperty(zone)) { data.timezones.push({ name: zone, offset: data.abbreviatedTimeZoneDST[zone], dst: true}); } } return data.timezones; }, days: function () { return __(["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"]); }, dayAbbr: function () { return __(["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"]); }, dayShortNames: function () { return __(["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"]); }, dayFirstLetters: function () { return __(["S_Sun_Initial", "M_Mon_Initial", "T_Tues_Initial", "W_Wed_Initial", "T_Thu_Initial", "F_Fri_Initial", "S_Sat_Initial"]); }, months: function () { return __(["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"]); }, monthAbbr: function () { return __(["Jan_Abbr", "Feb_Abbr", "Mar_Abbr", "Apr_Abbr", "May_Abbr", "Jun_Abbr", "Jul_Abbr", "Aug_Abbr", "Sep_Abbr", "Oct_Abbr", "Nov_Abbr", "Dec_Abbr"]); }, formatPatterns: function () { return getText.getFromObjectValues({ shortDate: "M/d/yyyy", longDate: "dddd, MMMM dd, yyyy", shortTime: "h:mm tt", longTime: "h:mm:ss tt", fullDateTime: "dddd, MMMM dd, yyyy h:mm:ss tt", sortableDateTime: "yyyy-MM-ddTHH:mm:ss", universalSortableDateTime: "yyyy-MM-dd HH:mm:ssZ", rfc1123: "ddd, dd MMM yyyy HH:mm:ss", monthDay: "MMMM dd", yearMonth: "MMMM, yyyy" }, Date.i18n.currentLanguage()); }, regex: function () { return getText.getFromObjectValues({ inTheMorning: "/( in the )(morn(ing)?)\\b/", thisMorning: "/(this )(morn(ing)?)\\b/", amThisMorning: "/(\b\\d(am)? )(this )(morn(ing)?)/", inTheEvening: "/( in the )(even(ing)?)\\b/", thisEvening: "/(this )(even(ing)?)\\b/", pmThisEvening: "/(\b\\d(pm)? )(this )(even(ing)?)/", jan: "/jan(uary)?/", feb: "/feb(ruary)?/", mar: "/mar(ch)?/", apr: "/apr(il)?/", may: "/may/", jun: "/jun(e)?/", jul: "/jul(y)?/", aug: "/aug(ust)?/", sep: "/sep(t(ember)?)?/", oct: "/oct(ober)?/", nov: "/nov(ember)?/", dec: "/dec(ember)?/", sun: "/^su(n(day)?)?/", mon: "/^mo(n(day)?)?/", tue: "/^tu(e(s(day)?)?)?/", wed: "/^we(d(nesday)?)?/", thu: "/^th(u(r(s(day)?)?)?)?/", fri: "/fr(i(day)?)?/", sat: "/^sa(t(urday)?)?/", future: "/^next/", past: "/^last|past|prev(ious)?/", add: "/^(\\+|aft(er)?|from|hence)/", subtract: "/^(\\-|bef(ore)?|ago)/", yesterday: "/^yes(terday)?/", today: "/^t(od(ay)?)?/", tomorrow: "/^tom(orrow)?/", now: "/^n(ow)?/", millisecond: "/^ms|milli(second)?s?/", second: "/^sec(ond)?s?/", minute: "/^mn|min(ute)?s?/", hour: "/^h(our)?s?/", week: "/^w(eek)?s?/", month: "/^m(onth)?s?/", day: "/^d(ay)?s?/", year: "/^y(ear)?s?/", shortMeridian: "/^(a|p)/", longMeridian: "/^(a\\.?m?\\.?|p\\.?m?\\.?)/", timezone: "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/", ordinalSuffix: "/^\\s*(st|nd|rd|th)/", timeContext: "/^\\s*(\\:|a(?!u|p)|p)/" }, Date.i18n.currentLanguage()); } }; var CultureInfo = function () { var info = getText.getFromObjectValues({ name: "name", englishName: "englishName", nativeName: "nativeName", amDesignator: "AM", pmDesignator: "PM", firstDayOfWeek: "firstDayOfWeek", twoDigitYearMax: "twoDigitYearMax", dateElementOrder: "mdy" }, Date.i18n.currentLanguage()); var constructedInfo = buildInfo.buildFromMethodHash({ dayNames: "days", abbreviatedDayNames: "dayAbbr", shortestDayNames: "dayShortNames", firstLetterDayNames: "dayFirstLetters", monthNames: "months", abbreviatedMonthNames: "monthAbbr", formatPatterns: "formatPatterns", regexPatterns: "regex", abbreviatedTimeZoneDST: "timeZoneDST", abbreviatedTimeZoneStandard: "timeZoneStandard" }); shallowMerge(info, constructedInfo); buildInfo.timeZones(info); return info; }; $D.i18n = { __: function (key, lang) { return __(key, lang); }, currentLanguage: function () { return lang || "en-US"; }, setLanguage: function (code, force, cb) { var async = false; if (force || code === "en-US" || (!!Date.CultureStrings && !!Date.CultureStrings[code])) { lang = code; Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings.lang = code; Date.CultureInfo = new CultureInfo(); } else { if (!(!!Date.CultureStrings && !!Date.CultureStrings[code])) { if (typeof exports !== "undefined" && this.exports !== exports) { // we're in a Node enviroment, load it using require try { require("../i18n/" + code + ".js"); lang = code; Date.CultureStrings.lang = code; Date.CultureInfo = new CultureInfo(); } catch (e) { // var str = "The language for '" + code + "' could not be loaded by Node. It likely does not exist."; throw new Error("The DateJS IETF language tag '" + code + "' could not be loaded by Node. It likely does not exist."); } } else if (Date.Config && Date.Config.i18n) { // we know the location of the files, so lets load them async = true; loadI18nScript(code).done(function(){ lang = code; Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings.lang = code; Date.CultureInfo = new CultureInfo(); $D.Parsing.Normalizer.buildReplaceData(); // because this is async if ($D.Grammar) { $D.Grammar.buildGrammarFormats(); // so we can parse those strings... } if (cb) { setTimeout(cb,0); } }); } else { Date.console.error("The DateJS IETF language tag '" + code + "' is not available and has not been loaded."); return false; } } } $D.Parsing.Normalizer.buildReplaceData(); // rebuild normalizer strings if ($D.Grammar) { $D.Grammar.buildGrammarFormats(); // so we can parse those strings... } if (!async && cb) { setTimeout(cb,0); } }, getLoggedKeys: function () { return loggedKeys; }, updateCultureInfo: function () { Date.CultureInfo = new CultureInfo(); } }; $D.i18n.updateCultureInfo(); // run automatically }()); (function () { var $D = Date, $P = $D.prototype, p = function (s, l) { if (!l) { l = 2; } return ("000" + s).slice(l * -1); }; if (typeof window !== "undefined" && typeof window.console !== "undefined" && typeof window.console.log !== "undefined") { $D.console = console; // used only to raise non-critical errors if available } else { // set mock so we don't give errors. $D.console = { log: function(){}, error: function(){} }; } $D.Config = $D.Config || {}; $D.initOverloads = function() { /** * Overload of Date.now. Allows an alternate call for Date.now where it returns the * current Date as an object rather than just milliseconds since the Unix Epoch. * * Also provides an implementation of now() for browsers (IE<9) that don't have it. * * Backwards compatible so with work with either: * Date.now() [returns ms] * or * Date.now(true) [returns Date] */ if (!$D.now) { $D._now = function now() { return new Date().getTime(); }; } else if (!$D._now) { $D._now = $D.now; } $D.now = function (returnObj) { if (returnObj) { return $D.present(); } else { return $D._now(); } }; if ( !$P.toISOString ) { $P.toISOString = function() { return this.getUTCFullYear() + "-" + p(this.getUTCMonth() + 1) + "-" + p(this.getUTCDate()) + "T" + p(this.getUTCHours()) + ":" + p(this.getUTCMinutes()) + ":" + p(this.getUTCSeconds()) + "." + String( (this.getUTCMilliseconds()/1000).toFixed(3)).slice(2, 5) + "Z"; }; } // private if ( $P._toString === undefined ){ $P._toString = $P.toString; } }; $D.initOverloads(); /** * Gets a date that is set to the current date. The time is set to the start of the day (00:00 or 12:00 AM). * @return {Date} The current date. */ $D.today = function () { return new Date().clearTime(); }; /** * Gets a date that is set to the current date and time (same as new Date, but chainable) * @return {Date} The current date. */ $D.present = function () { return new Date(); }; /** * Compares the first date to the second date and returns an number indication of their relative values. * @param {Date} First Date object to compare [Required]. * @param {Date} Second Date object to compare to [Required]. * @return {Number} -1 = date1 is lessthan date2. 0 = values are equal. 1 = date1 is greaterthan date2. */ $D.compare = function (date1, date2) { if (isNaN(date1) || isNaN(date2)) { throw new Error(date1 + " - " + date2); } else if (date1 instanceof Date && date2 instanceof Date) { return (date1 < date2) ? -1 : (date1 > date2) ? 1 : 0; } else { throw new TypeError(date1 + " - " + date2); } }; /** * Compares the first Date object to the second Date object and returns true if they are equal. * @param {Date} First Date object to compare [Required] * @param {Date} Second Date object to compare to [Required] * @return {Boolean} true if dates are equal. false if they are not equal. */ $D.equals = function (date1, date2) { return (date1.compareTo(date2) === 0); }; /** * Gets the language appropriate day name when given the day number(0-6) * eg - 0 == Sunday * @return {String} The day name */ $D.getDayName = function (n) { return Date.CultureInfo.dayNames[n]; }; /** * Gets the day number (0-6) if given a CultureInfo specific string which is a valid dayName, abbreviatedDayName or shortestDayName (two char). * @param {String} The name of the day (eg. "Monday, "Mon", "tuesday", "tue", "We", "we"). * @return {Number} The day number */ $D.getDayNumberFromName = function (name) { var n = Date.CultureInfo.dayNames, m = Date.CultureInfo.abbreviatedDayNames, o = Date.CultureInfo.shortestDayNames, s = name.toLowerCase(); for (var i = 0; i < n.length; i++) { if (n[i].toLowerCase() === s || m[i].toLowerCase() === s || o[i].toLowerCase() === s) { return i; } } return -1; }; /** * Gets the month number (0-11) if given a Culture Info specific string which is a valid monthName or abbreviatedMonthName. * @param {String} The name of the month (eg. "February, "Feb", "october", "oct"). * @return {Number} The day number */ $D.getMonthNumberFromName = function (name) { var n = Date.CultureInfo.monthNames, m = Date.CultureInfo.abbreviatedMonthNames, s = name.toLowerCase(); for (var i = 0; i < n.length; i++) { if (n[i].toLowerCase() === s || m[i].toLowerCase() === s) { return i; } } return -1; }; /** * Gets the language appropriate month name when given the month number(0-11) * eg - 0 == January * @return {String} The month name */ $D.getMonthName = function (n) { return Date.CultureInfo.monthNames[n]; }; /** * Determines if the current date instance is within a LeapYear. * @param {Number} The year. * @return {Boolean} true if date is within a LeapYear, otherwise false. */ $D.isLeapYear = function (year) { return ((year % 4 === 0 && year % 100 !== 0) || year % 400 === 0); }; /** * Gets the number of days in the month, given a year and month value. Automatically corrects for LeapYear. * @param {Number} The year. * @param {Number} The month (0-11). * @return {Number} The number of days in the month. */ $D.getDaysInMonth = function (year, month) { if (!month && $D.validateMonth(year)) { month = year; year = Date.today().getFullYear(); } return [31, ($D.isLeapYear(year) ? 29 : 28), 31, 30, 31, 30, 31, 31, 30, 31, 30, 31][month]; }; $P.getDaysInMonth = function () { return $D.getDaysInMonth(this.getFullYear(), this.getMonth()); }; $D.getTimezoneAbbreviation = function (offset, dst) { var p, n = (dst || false) ? Date.CultureInfo.abbreviatedTimeZoneDST : Date.CultureInfo.abbreviatedTimeZoneStandard; for (p in n) { if (n.hasOwnProperty(p)) { if (n[p] === offset) { return p; } } } return null; }; $D.getTimezoneOffset = function (name, dst) { var i, a =[], z = Date.CultureInfo.timezones; if (!name) { name = (new Date()).getTimezone();} for (i = 0; i < z.length; i++) { if (z[i].name === name.toUpperCase()) { a.push(i); } } if (!z[a[0]]) { return null; } if (a.length === 1 || !dst) { return z[a[0]].offset; } else { for (i=0; i < a.length; i++) { if (z[a[i]].dst) { return z[a[i]].offset; } } } }; $D.getQuarter = function (d) { d = d || new Date(); // If no date supplied, use today var q = [1,2,3,4]; return q[Math.floor(d.getMonth() / 3)]; // ~~~ is a bitwise op. Faster than Math.floor }; $D.getDaysLeftInQuarter = function (d) { d = d || new Date(); var qEnd = new Date(d); qEnd.setMonth(qEnd.getMonth() + 3 - qEnd.getMonth() % 3, 0); return Math.floor((qEnd - d) / 8.64e7); }; // private var validate = function (n, min, max, name) { name = name ? name : "Object"; if (typeof n === "undefined") { return false; } else if (typeof n !== "number") { throw new TypeError(n + " is not a Number."); } else if (n < min || n > max) { // As failing validation is *not* an exceptional circumstance // lets not throw a RangeError Exception here. // It's semantically correct but it's not sensible. return false; } return true; }; /** * Validates the number is within an acceptable range for milliseconds [0-999]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateMillisecond = function (value) { return validate(value, 0, 999, "millisecond"); }; /** * Validates the number is within an acceptable range for seconds [0-59]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateSecond = function (value) { return validate(value, 0, 59, "second"); }; /** * Validates the number is within an acceptable range for minutes [0-59]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateMinute = function (value) { return validate(value, 0, 59, "minute"); }; /** * Validates the number is within an acceptable range for hours [0-23]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateHour = function (value) { return validate(value, 0, 23, "hour"); }; /** * Validates the number is within an acceptable range for the days in a month [0-MaxDaysInMonth]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateDay = function (value, year, month) { if (year === undefined || year === null || month === undefined || month === null) { return false;} return validate(value, 1, $D.getDaysInMonth(year, month), "day"); }; /** * Validates the number is within an acceptable range for months [0-11]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateWeek = function (value) { return validate(value, 0, 53, "week"); }; /** * Validates the number is within an acceptable range for months [0-11]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateMonth = function (value) { return validate(value, 0, 11, "month"); }; /** * Validates the number is within an acceptable range for years. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateYear = function (value) { /** * Per ECMAScript spec the range of times supported by Date objects is * exactly -100,000,000 days to +100,000,000 days measured relative to * midnight at the beginning of 01 January, 1970 UTC. * This gives a range of 8,640,000,000,000,000 milliseconds to either * side of 01 January, 1970 UTC. * * Earliest possible date: Tue, 20 Apr 271,822 B.C. 00:00:00 UTC * Latest possible date: Sat, 13 Sep 275,760 00:00:00 UTC */ return validate(value, -271822, 275760, "year"); }; $D.validateTimezone = function(value) { var timezones = {"ACDT":1,"ACST":1,"ACT":1,"ADT":1,"AEDT":1,"AEST":1,"AFT":1,"AKDT":1,"AKST":1,"AMST":1,"AMT":1,"ART":1,"AST":1,"AWDT":1,"AWST":1,"AZOST":1,"AZT":1,"BDT":1,"BIOT":1,"BIT":1,"BOT":1,"BRT":1,"BST":1,"BTT":1,"CAT":1,"CCT":1,"CDT":1,"CEDT":1,"CEST":1,"CET":1,"CHADT":1,"CHAST":1,"CHOT":1,"ChST":1,"CHUT":1,"CIST":1,"CIT":1,"CKT":1,"CLST":1,"CLT":1,"COST":1,"COT":1,"CST":1,"CT":1,"CVT":1,"CWST":1,"CXT":1,"DAVT":1,"DDUT":1,"DFT":1,"EASST":1,"EAST":1,"EAT":1,"ECT":1,"EDT":1,"EEDT":1,"EEST":1,"EET":1,"EGST":1,"EGT":1,"EIT":1,"EST":1,"FET":1,"FJT":1,"FKST":1,"FKT":1,"FNT":1,"GALT":1,"GAMT":1,"GET":1,"GFT":1,"GILT":1,"GIT":1,"GMT":1,"GST":1,"GYT":1,"HADT":1,"HAEC":1,"HAST":1,"HKT":1,"HMT":1,"HOVT":1,"HST":1,"ICT":1,"IDT":1,"IOT":1,"IRDT":1,"IRKT":1,"IRST":1,"IST":1,"JST":1,"KGT":1,"KOST":1,"KRAT":1,"KST":1,"LHST":1,"LINT":1,"MAGT":1,"MART":1,"MAWT":1,"MDT":1,"MET":1,"MEST":1,"MHT":1,"MIST":1,"MIT":1,"MMT":1,"MSK":1,"MST":1,"MUT":1,"MVT":1,"MYT":1,"NCT":1,"NDT":1,"NFT":1,"NPT":1,"NST":1,"NT":1,"NUT":1,"NZDT":1,"NZST":1,"OMST":1,"ORAT":1,"PDT":1,"PET":1,"PETT":1,"PGT":1,"PHOT":1,"PHT":1,"PKT":1,"PMDT":1,"PMST":1,"PONT":1,"PST":1,"PYST":1,"PYT":1,"RET":1,"ROTT":1,"SAKT":1,"SAMT":1,"SAST":1,"SBT":1,"SCT":1,"SGT":1,"SLST":1,"SRT":1,"SST":1,"SYOT":1,"TAHT":1,"THA":1,"TFT":1,"TJT":1,"TKT":1,"TLT":1,"TMT":1,"TOT":1,"TVT":1,"UCT":1,"ULAT":1,"UTC":1,"UYST":1,"UYT":1,"UZT":1,"VET":1,"VLAT":1,"VOLT":1,"VOST":1,"VUT":1,"WAKT":1,"WAST":1,"WAT":1,"WEDT":1,"WEST":1,"WET":1,"WST":1,"YAKT":1,"YEKT":1,"Z":1}; return (timezones[value] === 1); }; $D.validateTimezoneOffset= function(value) { // timezones go from +14hrs to -12hrs, the +X hours are negative offsets. return (value > -841 && value < 721); }; }()); (function () { var $D = Date, $P = $D.prototype, p = function (s, l) { if (!l) { l = 2; } return ("000" + s).slice(l * -1); }; var validateConfigObject = function (obj) { var result = {}, self = this, prop, testFunc; testFunc = function (prop, func, value) { if (prop === "day") { var month = (obj.month !== undefined) ? obj.month : self.getMonth(); var year = (obj.year !== undefined) ? obj.year : self.getFullYear(); return $D[func](value, year, month); } else { return $D[func](value); } }; for (prop in obj) { if (Object.prototype.hasOwnProperty.call(obj, prop)) { var func = "validate" + prop.charAt(0).toUpperCase() + prop.slice(1); if ($D[func] && obj[prop] !== null && testFunc(prop, func, obj[prop])) { result[prop] = obj[prop]; } } } return result; }; /** * Resets the time of this Date object to 12:00 AM (00:00), which is the start of the day. * @param {Boolean} .clone() this date instance before clearing Time * @return {Date} this */ $P.clearTime = function () { this.setHours(0); this.setMinutes(0); this.setSeconds(0); this.setMilliseconds(0); return this; }; /** * Resets the time of this Date object to the current time ('now'). * @return {Date} this */ $P.setTimeToNow = function () { var n = new Date(); this.setHours(n.getHours()); this.setMinutes(n.getMinutes()); this.setSeconds(n.getSeconds()); this.setMilliseconds(n.getMilliseconds()); return this; }; /** * Returns a new Date object that is an exact date and time copy of the original instance. * @return {Date} A new Date instance */ $P.clone = function () { return new Date(this.getTime()); }; /** * Compares this instance to a Date object and returns an number indication of their relative values. * @param {Date} Date object to compare [Required] * @return {Number} -1 = this is lessthan date. 0 = values are equal. 1 = this is greaterthan date. */ $P.compareTo = function (date) { return Date.compare(this, date); }; /** * Compares this instance to another Date object and returns true if they are equal. * @param {Date} Date object to compare. If no date to compare, new Date() [now] is used. * @return {Boolean} true if dates are equal. false if they are not equal. */ $P.equals = function (date) { return Date.equals(this, (date !== undefined ? date : new Date())); }; /** * Determines if this instance is between a range of two dates or equal to either the start or end dates. * @param {Date} Start of range [Required] * @param {Date} End of range [Required] * @return {Boolean} true is this is between or equal to the start and end dates, else false */ $P.between = function (start, end) { return this.getTime() >= start.getTime() && this.getTime() <= end.getTime(); }; /** * Determines if this date occurs after the date to compare to. * @param {Date} Date object to compare. If no date to compare, new Date() ("now") is used. * @return {Boolean} true if this date instance is greater than the date to compare to (or "now"), otherwise false. */ $P.isAfter = function (date) { return this.compareTo(date || new Date()) === 1; }; /** * Determines if this date occurs before the date to compare to. * @param {Date} Date object to compare. If no date to compare, new Date() ("now") is used. * @return {Boolean} true if this date instance is less than the date to compare to (or "now"). */ $P.isBefore = function (date) { return (this.compareTo(date || new Date()) === -1); }; /** * Determines if the current Date instance occurs today. * @return {Boolean} true if this date instance is 'today', otherwise false. */ /** * Determines if the current Date instance occurs on the same Date as the supplied 'date'. * If no 'date' to compare to is provided, the current Date instance is compared to 'today'. * @param {date} Date object to compare. If no date to compare, the current Date ("now") is used. * @return {Boolean} true if this Date instance occurs on the same Day as the supplied 'date'. */ $P.isToday = $P.isSameDay = function (date) { return this.clone().clearTime().equals((date || new Date()).clone().clearTime()); }; /** * Adds the specified number of milliseconds to this instance. * @param {Number} The number of milliseconds to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addMilliseconds = function (value) { if (!value) { return this; } this.setTime(this.getTime() + value * 1); return this; }; /** * Adds the specified number of seconds to this instance. * @param {Number} The number of seconds to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addSeconds = function (value) { if (!value) { return this; } return this.addMilliseconds(value * 1000); }; /** * Adds the specified number of seconds to this instance. * @param {Number} The number of seconds to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addMinutes = function (value) { if (!value) { return this; } return this.addMilliseconds(value * 60000); // 60*1000 }; /** * Adds the specified number of hours to this instance. * @param {Number} The number of hours to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addHours = function (value) { if (!value) { return this; } return this.addMilliseconds(value * 3600000); // 60*60*1000 }; /** * Adds the specified number of days to this instance. * @param {Number} The number of days to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addDays = function (value) { if (!value) { return this; } this.setDate(this.getDate() + value * 1); return this; }; /** * Adds the specified number of weekdays (ie - not sat or sun) to this instance. * @param {Number} The number of days to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addWeekdays = function (value) { if (!value) { return this; } var day = this.getDay(); var weeks = (Math.ceil(Math.abs(value)/7)); if (day === 0 || day === 6) { if (value > 0) { this.next().monday(); this.addDays(-1); day = this.getDay(); } } if (value < 0) { while (value < 0) { this.addDays(-1); day = this.getDay(); if (day !== 0 && day !== 6) { value++; } } return this; } else if (value > 5 || (6-day) <= value) { value = value + (weeks * 2); } return this.addDays(value); }; /** * Adds the specified number of weeks to this instance. * @param {Number} The number of weeks to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addWeeks = function (value) { if (!value) { return this; } return this.addDays(value * 7); }; /** * Adds the specified number of months to this instance. * @param {Number} The number of months to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addMonths = function (value) { if (!value) { return this; } var n = this.getDate(); this.setDate(1); this.setMonth(this.getMonth() + value * 1); this.setDate(Math.min(n, $D.getDaysInMonth(this.getFullYear(), this.getMonth()))); return this; }; $P.addQuarters = function (value) { if (!value) { return this; } // note this will take you to the same point in the quarter as you are now. // i.e. - if you are 15 days into the quarter you'll be 15 days into the resulting one. // bonus: this allows adding fractional quarters return this.addMonths(value * 3); }; /** * Adds the specified number of years to this instance. * @param {Number} The number of years to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addYears = function (value) { if (!value) { return this; } return this.addMonths(value * 12); }; /** * Adds (or subtracts) to the value of the years, months, weeks, days, hours, minutes, seconds, milliseconds of the date instance using given configuration object. Positive and Negative values allowed. * Example

	Date.today().add( { days: 1, months: 1 } )

	new Date().add( { years: -1 } )
	
* @param {Object} Configuration object containing attributes (months, days, etc.) * @return {Date} this */ $P.add = function (config) { if (typeof config === "number") { this._orient = config; return this; } var x = config; if (x.day) { // If we should be a different date than today (eg: for 'tomorrow -1d', etc). // Should only effect parsing, not direct usage (eg, Finish and FinishExact) if ((x.day - this.getDate()) !== 0) { this.setDate(x.day); } } if (x.milliseconds) { this.addMilliseconds(x.milliseconds); } if (x.seconds) { this.addSeconds(x.seconds); } if (x.minutes) { this.addMinutes(x.minutes); } if (x.hours) { this.addHours(x.hours); } if (x.weeks) { this.addWeeks(x.weeks); } if (x.months) { this.addMonths(x.months); } if (x.years) { this.addYears(x.years); } if (x.days) { this.addDays(x.days); } return this; }; /** * Get the week number. Week one (1) is the week which contains the first Thursday of the year. Monday is considered the first day of the week. * The .getWeek() function does NOT convert the date to UTC. The local datetime is used. * Please use .getISOWeek() to get the week of the UTC converted date. * @return {Number} 1 to 53 */ $P.getWeek = function (utc) { // Create a copy of this date object var self, target = new Date(this.valueOf()); if (utc) { target.addMinutes(target.getTimezoneOffset()); self = target.clone(); } else { self = this; } // ISO week date weeks start on monday // so correct the day number var dayNr = (self.getDay() + 6) % 7; // ISO 8601 states that week 1 is the week // with the first thursday of that year. // Set the target date to the thursday in the target week target.setDate(target.getDate() - dayNr + 3); // Store the millisecond value of the target date var firstThursday = target.valueOf(); // Set the target to the first thursday of the year // First set the target to january first target.setMonth(0, 1); // Not a thursday? Correct the date to the next thursday if (target.getDay() !== 4) { target.setMonth(0, 1 + ((4 - target.getDay()) + 7) % 7); } // The weeknumber is the number of weeks between the // first thursday of the year and the thursday in the target week return 1 + Math.ceil((firstThursday - target) / 604800000); // 604800000 = 7 * 24 * 3600 * 1000 }; /** * Get the ISO 8601 week number. Week one ("01") is the week which contains the first Thursday of the year. Monday is considered the first day of the week. * The .getISOWeek() function does convert the date to it's UTC value. Please use .getWeek() to get the week of the local date. * @return {String} "01" to "53" */ $P.getISOWeek = function () { return p(this.getWeek(true)); }; /** * Moves the date to Monday of the week set. Week one (1) is the week which contains the first Thursday of the year. * @param {Number} A Number (1 to 53) that represents the week of the year. * @return {Date} this */ $P.setWeek = function (n) { if ((n - this.getWeek()) === 0) { if (this.getDay() !== 1) { return this.moveToDayOfWeek(1, (this.getDay() > 1 ? -1 : 1)); } else { return this; } } else { return this.moveToDayOfWeek(1, (this.getDay() > 1 ? -1 : 1)).addWeeks(n - this.getWeek()); } }; $P.setQuarter = function (qtr) { var month = Math.abs(((qtr-1) * 3) + 1); return this.setMonth(month, 1); }; $P.getQuarter = function () { return Date.getQuarter(this); }; $P.getDaysLeftInQuarter = function () { return Date.getDaysLeftInQuarter(this); }; /** * Moves the date to the next n'th occurrence of the dayOfWeek starting from the beginning of the month. The number (-1) is a magic number and will return the last occurrence of the dayOfWeek in the month. * @param {Number} The dayOfWeek to move to * @param {Number} The n'th occurrence to move to. Use (-1) to return the last occurrence in the month * @return {Date} this */ $P.moveToNthOccurrence = function (dayOfWeek, occurrence) { if (dayOfWeek === "Weekday") { if (occurrence > 0) { this.moveToFirstDayOfMonth(); if (this.is().weekday()) { occurrence -= 1; } } else if (occurrence < 0) { this.moveToLastDayOfMonth(); if (this.is().weekday()) { occurrence += 1; } } else { return this; } return this.addWeekdays(occurrence); } var shift = 0; if (occurrence > 0) { shift = occurrence - 1; } else if (occurrence === -1) { this.moveToLastDayOfMonth(); if (this.getDay() !== dayOfWeek) { this.moveToDayOfWeek(dayOfWeek, -1); } return this; } return this.moveToFirstDayOfMonth().addDays(-1).moveToDayOfWeek(dayOfWeek, +1).addWeeks(shift); }; var moveToN = function (getFunc, addFunc, nVal) { return function (value, orient) { var diff = (value - this[getFunc]() + nVal * (orient || +1)) % nVal; return this[addFunc]((diff === 0) ? diff += nVal * (orient || +1) : diff); }; }; /** * Move to the next or last dayOfWeek based on the orient value. * @param {Number} The dayOfWeek to move to * @param {Number} Forward (+1) or Back (-1). Defaults to +1. [Optional] * @return {Date} this */ $P.moveToDayOfWeek = moveToN("getDay", "addDays", 7); /** * Move to the next or last month based on the orient value. * @param {Number} The month to move to. 0 = January, 11 = December * @param {Number} Forward (+1) or Back (-1). Defaults to +1. [Optional] * @return {Date} this */ $P.moveToMonth = moveToN("getMonth", "addMonths", 12); /** * Get the Ordinate of the current day ("th", "st", "rd"). * @return {String} */ $P.getOrdinate = function () { var num = this.getDate(); return ord(num); }; /** * Get the Ordinal day (numeric day number) of the year, adjusted for leap year. * @return {Number} 1 through 365 (366 in leap years) */ $P.getOrdinalNumber = function () { return Math.ceil((this.clone().clearTime() - new Date(this.getFullYear(), 0, 1)) / 86400000) + 1; }; /** * Get the time zone abbreviation of the current date. * @return {String} The abbreviated time zone name (e.g. "EST") */ $P.getTimezone = function () { return $D.getTimezoneAbbreviation(this.getUTCOffset(), this.isDaylightSavingTime()); }; $P.setTimezoneOffset = function (offset) { var here = this.getTimezoneOffset(), there = Number(offset) * -6 / 10; return (there || there === 0) ? this.addMinutes(there - here) : this; }; $P.setTimezone = function (offset) { return this.setTimezoneOffset($D.getTimezoneOffset(offset)); }; /** * Indicates whether Daylight Saving Time is observed in the current time zone. * @return {Boolean} true|false */ $P.hasDaylightSavingTime = function () { return (Date.today().set({month: 0, day: 1}).getTimezoneOffset() !== Date.today().set({month: 6, day: 1}).getTimezoneOffset()); }; /** * Indicates whether this Date instance is within the Daylight Saving Time range for the current time zone. * @return {Boolean} true|false */ $P.isDaylightSavingTime = function () { return Date.today().set({month: 0, day: 1}).getTimezoneOffset() !== this.getTimezoneOffset(); }; /** * Get the offset from UTC of the current date. * @return {String} The 4-character offset string prefixed with + or - (e.g. "-0500") */ $P.getUTCOffset = function (offset) { var n = (offset || this.getTimezoneOffset()) * -10 / 6, r; if (n < 0) { r = (n - 10000).toString(); return r.charAt(0) + r.substr(2); } else { r = (n + 10000).toString(); return "+" + r.substr(1); } }; /** * Returns the number of milliseconds between this date and date. * @param {Date} Defaults to now * @return {Number} The diff in milliseconds */ $P.getElapsed = function (date) { return (date || new Date()) - this; }; /** * Set the value of year, month, day, hour, minute, second, millisecond of date instance using given configuration object. * Example

	Date.today().set( { day: 20, month: 1 } )

	new Date().set( { millisecond: 0 } )
	
* * @param {Object} Configuration object containing attributes (month, day, etc.) * @return {Date} this */ $P.set = function (config) { config = validateConfigObject.call(this, config); var key; for (key in config) { if (Object.prototype.hasOwnProperty.call(config, key)) { var name = key.charAt(0).toUpperCase() + key.slice(1); var addFunc, getFunc; if (key !== "week" && key !== "month" && key !== "timezone" && key !== "timezoneOffset") { name += "s"; } addFunc = "add" + name; getFunc = "get" + name; if (key === "month") { addFunc = addFunc + "s"; } else if (key === "year"){ getFunc = "getFullYear"; } if (key !== "day" && key !== "timezone" && key !== "timezoneOffset" && key !== "week" && key !== "hour") { this[addFunc](config[key] - this[getFunc]()); } else if ( key === "timezone"|| key === "timezoneOffset" || key === "week" || key === "hour") { this["set"+name](config[key]); } } } // day has to go last because you can't validate the day without first knowing the month if (config.day) { this.addDays(config.day - this.getDate()); } return this; }; /** * Moves the date to the first day of the month. * @return {Date} this */ $P.moveToFirstDayOfMonth = function () { return this.set({ day: 1 }); }; /** * Moves the date to the last day of the month. * @return {Date} this */ $P.moveToLastDayOfMonth = function () { return this.set({ day: $D.getDaysInMonth(this.getFullYear(), this.getMonth())}); }; /** * Converts the value of the current Date object to its equivalent string representation. * Format Specifiers * CUSTOM DATE AND TIME FORMAT STRINGS * Format Description Example * ------ --------------------------------------------------------------------------- ----------------------- * s The seconds of the minute between 0-59. "0" to "59" * ss The seconds of the minute with leading zero if required. "00" to "59" * * m The minute of the hour between 0-59. "0" or "59" * mm The minute of the hour with leading zero if required. "00" or "59" * * h The hour of the day between 1-12. "1" to "12" * hh The hour of the day with leading zero if required. "01" to "12" * * H The hour of the day between 0-23. "0" to "23" * HH The hour of the day with leading zero if required. "00" to "23" * * d The day of the month between 1 and 31. "1" to "31" * dd The day of the month with leading zero if required. "01" to "31" * ddd Abbreviated day name. Date.CultureInfo.abbreviatedDayNames. "Mon" to "Sun" * dddd The full day name. Date.CultureInfo.dayNames. "Monday" to "Sunday" * * M The month of the year between 1-12. "1" to "12" * MM The month of the year with leading zero if required. "01" to "12" * MMM Abbreviated month name. Date.CultureInfo.abbreviatedMonthNames. "Jan" to "Dec" * MMMM The full month name. Date.CultureInfo.monthNames. "January" to "December" * * yy The year as a two-digit number. "99" or "08" * yyyy The full four digit year. "1999" or "2008" * * t Displays the first character of the A.M./P.M. designator. "A" or "P" * Date.CultureInfo.amDesignator or Date.CultureInfo.pmDesignator * tt Displays the A.M./P.M. designator. "AM" or "PM" * Date.CultureInfo.amDesignator or Date.CultureInfo.pmDesignator * * S The ordinal suffix ("st, "nd", "rd" or "th") of the current day. "st, "nd", "rd" or "th" * * STANDARD DATE AND TIME FORMAT STRINGS * Format Description Example *------ --------------------------------------------------------------------------- ----------------------- * d The CultureInfo shortDate Format Pattern "M/d/yyyy" * D The CultureInfo longDate Format Pattern "dddd, MMMM dd, yyyy" * F The CultureInfo fullDateTime Format Pattern "dddd, MMMM dd, yyyy h:mm:ss tt" * m The CultureInfo monthDay Format Pattern "MMMM dd" * r The CultureInfo rfc1123 Format Pattern "ddd, dd MMM yyyy HH:mm:ss GMT" * s The CultureInfo sortableDateTime Format Pattern "yyyy-MM-ddTHH:mm:ss" * t The CultureInfo shortTime Format Pattern "h:mm tt" * T The CultureInfo longTime Format Pattern "h:mm:ss tt" * u The CultureInfo universalSortableDateTime Format Pattern "yyyy-MM-dd HH:mm:ssZ" * y The CultureInfo yearMonth Format Pattern "MMMM, yyyy" * * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @return {String} A string representation of the current Date object. */ var ord = function (n) { switch (n * 1) { case 1: case 21: case 31: return "st"; case 2: case 22: return "nd"; case 3: case 23: return "rd"; default: return "th"; } }; var parseStandardFormats = function (format) { var y, c = Date.CultureInfo.formatPatterns; switch (format) { case "d": return this.toString(c.shortDate); case "D": return this.toString(c.longDate); case "F": return this.toString(c.fullDateTime); case "m": return this.toString(c.monthDay); case "r": case "R": y = this.clone().addMinutes(this.getTimezoneOffset()); return y.toString(c.rfc1123) + " GMT"; case "s": return this.toString(c.sortableDateTime); case "t": return this.toString(c.shortTime); case "T": return this.toString(c.longTime); case "u": y = this.clone().addMinutes(this.getTimezoneOffset()); return y.toString(c.universalSortableDateTime); case "y": return this.toString(c.yearMonth); default: return false; } }; var parseFormatStringsClosure = function (context) { return function (m) { if (m.charAt(0) === "\\") { return m.replace("\\", ""); } switch (m) { case "hh": return p(context.getHours() < 13 ? (context.getHours() === 0 ? 12 : context.getHours()) : (context.getHours() - 12)); case "h": return context.getHours() < 13 ? (context.getHours() === 0 ? 12 : context.getHours()) : (context.getHours() - 12); case "HH": return p(context.getHours()); case "H": return context.getHours(); case "mm": return p(context.getMinutes()); case "m": return context.getMinutes(); case "ss": return p(context.getSeconds()); case "s": return context.getSeconds(); case "yyyy": return p(context.getFullYear(), 4); case "yy": return p(context.getFullYear()); case "y": return context.getFullYear(); case "E": case "dddd": return Date.CultureInfo.dayNames[context.getDay()]; case "ddd": return Date.CultureInfo.abbreviatedDayNames[context.getDay()]; case "dd": return p(context.getDate()); case "d": return context.getDate(); case "MMMM": return Date.CultureInfo.monthNames[context.getMonth()]; case "MMM": return Date.CultureInfo.abbreviatedMonthNames[context.getMonth()]; case "MM": return p((context.getMonth() + 1)); case "M": return context.getMonth() + 1; case "t": return context.getHours() < 12 ? Date.CultureInfo.amDesignator.substring(0, 1) : Date.CultureInfo.pmDesignator.substring(0, 1); case "tt": return context.getHours() < 12 ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator; case "S": return ord(context.getDate()); case "W": return context.getWeek(); case "WW": return context.getISOWeek(); case "Q": return "Q" + context.getQuarter(); case "q": return String(context.getQuarter()); case "z": return context.getTimezone(); case "Z": case "X": return Date.getTimezoneOffset(context.getTimezone()); case "ZZ": // Timezone offset in seconds return context.getTimezoneOffset() * -60; case "u": return context.getDay(); case "L": return ($D.isLeapYear(context.getFullYear())) ? 1 : 0; case "B": // Swatch Internet Time (.beats) return "@"+((context.getUTCSeconds() + (context.getUTCMinutes()*60) + ((context.getUTCHours()+1)*3600))/86.4); default: return m; } }; }; $P.toString = function (format, ignoreStandards) { // Standard Date and Time Format Strings. Formats pulled from CultureInfo file and // may vary by culture. if (!ignoreStandards && format && format.length === 1) { output = parseStandardFormats.call(this, format); if (output) { return output; } } var parseFormatStrings = parseFormatStringsClosure(this); return format ? format.replace(/((\\)?(dd?d?d?|MM?M?M?|yy?y?y?|hh?|HH?|mm?|ss?|tt?|S|q|Q|WW?W?W?)(?![^\[]*\]))/g, parseFormatStrings).replace(/\[|\]/g, "") : this._toString(); }; }()); /************************************************************* * SugarPak - Domain Specific Language - Syntactical Sugar * *************************************************************/ (function () { var $D = Date, $P = $D.prototype, $N = Number.prototype; // private $P._orient = +1; // private $P._nth = null; // private $P._is = false; // private $P._same = false; // private $P._isSecond = false; // private $N._dateElement = "days"; /** * Moves the date to the next instance of a date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.today().next().friday();
	Date.today().next().fri();
	Date.today().next().march();
	Date.today().next().mar();
	Date.today().next().week();
	
* * @return {Date} date */ $P.next = function () { this._move = true; this._orient = +1; return this; }; /** * Creates a new Date (Date.today()) and moves the date to the next instance of the date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.next().friday();
	Date.next().fri();
	Date.next().march();
	Date.next().mar();
	Date.next().week();
	
* * @return {Date} date */ $D.next = function () { return $D.today().next(); }; /** * Moves the date to the previous instance of a date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.today().last().friday();
	Date.today().last().fri();
	Date.today().last().march();
	Date.today().last().mar();
	Date.today().last().week();
	
* * @return {Date} date */ $P.last = $P.prev = $P.previous = function () { this._move = true; this._orient = -1; return this; }; /** * Creates a new Date (Date.today()) and moves the date to the previous instance of the date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.last().friday();
	Date.last().fri();
	Date.previous().march();
	Date.prev().mar();
	Date.last().week();
	
* * @return {Date} date */ $D.last = $D.prev = $D.previous = function () { return $D.today().last(); }; /** * Performs a equality check when followed by either a month name, day name or .weekday() function. * Example

	Date.today().is().friday(); // true|false
	Date.today().is().fri();
	Date.today().is().march();
	Date.today().is().mar();
	
* * @return {Boolean} true|false */ $P.is = function () { this._is = true; return this; }; /** * Determines if two date objects occur on/in exactly the same instance of the subsequent date part function. * The function .same() must be followed by a date part function (example: .day(), .month(), .year(), etc). * * An optional Date can be passed in the date part function. If now date is passed as a parameter, 'Now' is used. * * The following example demonstrates how to determine if two dates fall on the exact same day. * * Example

	var d1 = Date.today(); // today at 00:00
	var d2 = new Date();   // exactly now.

	// Do they occur on the same day?
	d1.same().day(d2); // true
	
	// Do they occur on the same hour?
	d1.same().hour(d2); // false, unless d2 hour is '00' (midnight).
	
	// What if it's the same day, but one year apart?
	var nextYear = Date.today().add(1).year();

	d1.same().day(nextYear); // false, because the dates must occur on the exact same day. 
	
* * Scenario: Determine if a given date occurs during some week period 2 months from now. * * Example

	var future = Date.today().add(2).months();
	return someDate.same().week(future); // true|false;
	
* * @return {Boolean} true|false */ $P.same = function () { this._same = true; this._isSecond = false; return this; }; /** * Determines if the current date/time occurs during Today. Must be preceded by the .is() function. * Example

	someDate.is().today();    // true|false
	new Date().is().today();  // true
	Date.today().is().today();// true
	Date.today().add(-1).day().is().today(); // false
	
* * @return {Boolean} true|false */ $P.today = function () { return this.same().day(); }; /** * Determines if the current date is a weekday. This function must be preceded by the .is() function. * Example

	Date.today().is().weekday(); // true|false
	
* * @return {Boolean} true|false */ $P.weekday = function () { if (this._nth) { return df("Weekday").call(this); } if (this._move) { return this.addWeekdays(this._orient); } if (this._is) { this._is = false; return (!this.is().sat() && !this.is().sun()); } return false; }; /** * Determines if the current date is on the weekend. This function must be preceded by the .is() function. * Example

	Date.today().is().weekend(); // true|false
	
* * @return {Boolean} true|false */ $P.weekend = function () { if (this._is) { this._is = false; return (this.is().sat() || this.is().sun()); } return false; }; /** * Sets the Time of the current Date instance. A string "6:15 pm" or config object {hour:18, minute:15} are accepted. * Example

	// Set time to 6:15pm with a String
	Date.today().at("6:15pm");

	// Set time to 6:15pm with a config object
	Date.today().at({hour:18, minute:15});
	
* * @return {Date} date */ $P.at = function (time) { return (typeof time === "string") ? $D.parse(this.toString("d") + " " + time) : this.set(time); }; /** * Creates a new Date() and adds this (Number) to the date based on the preceding date element function (eg. second|minute|hour|day|month|year). * Example

	// Undeclared Numbers must be wrapped with parentheses. Requirment of JavaScript.
	(3).days().fromNow();
	(6).months().fromNow();

	// Declared Number variables do not require parentheses. 
	var n = 6;
	n.months().fromNow();
	
* * @return {Date} A new Date instance */ $N.fromNow = $N.after = function (date) { var c = {}; c[this._dateElement] = this; return ((!date) ? new Date() : date.clone()).add(c); }; /** * Creates a new Date() and subtract this (Number) from the date based on the preceding date element function (eg. second|minute|hour|day|month|year). * Example

	// Undeclared Numbers must be wrapped with parentheses. Requirment of JavaScript.
	(3).days().ago();
	(6).months().ago();

	// Declared Number variables do not require parentheses. 
	var n = 6;
	n.months().ago();
	
* * @return {Date} A new Date instance */ $N.ago = $N.before = function (date) { var c = {}, s = (this._dateElement[this._dateElement.length-1] !== "s") ? this._dateElement + "s" : this._dateElement; c[s] = this * -1; return ((!date) ? new Date() : date.clone()).add(c); }; // Do NOT modify the following string tokens. These tokens are used to build dynamic functions. // All culture-specific strings can be found in the CultureInfo files. var dx = ("sunday monday tuesday wednesday thursday friday saturday").split(/\s/), mx = ("january february march april may june july august september october november december").split(/\s/), px = ("Millisecond Second Minute Hour Day Week Month Year Quarter Weekday").split(/\s/), pxf = ("Milliseconds Seconds Minutes Hours Date Week Month FullYear Quarter").split(/\s/), nth = ("final first second third fourth fifth").split(/\s/), de; /** * Returns an object literal of all the date parts. * Example

	var o = new Date().toObject();
	
	// { year: 2008, month: 4, week: 20, day: 13, hour: 18, minute: 9, second: 32, millisecond: 812 }
	
	// The object properties can be referenced directly from the object.
	
	alert(o.day);  // alerts "13"
	alert(o.year); // alerts "2008"
	
* * @return {Date} An object literal representing the original date object. */ $P.toObject = function () { var o = {}; for (var i = 0; i < px.length; i++) { if (this["get" + pxf[i]]) { o[px[i].toLowerCase()] = this["get" + pxf[i]](); } } return o; }; /** * Returns a date created from an object literal. Ignores the .week property if set in the config. * Example

	var o = new Date().toObject();
	
	return Date.fromObject(o); // will return the same date. 

	var o2 = {month: 1, day: 20, hour: 18}; // birthday party!
	Date.fromObject(o2);
	
* * @return {Date} An object literal representing the original date object. */ $D.fromObject = function(config) { config.week = null; return Date.today().set(config); }; // Create day name functions and abbreviated day name functions (eg. monday(), friday(), fri()). var df = function (n) { return function () { if (this._is) { this._is = false; return this.getDay() === n; } if (this._move) { this._move = null; } if (this._nth !== null) { // If the .second() function was called earlier, remove the _orient // from the date, and then continue. // This is required because 'second' can be used in two different context. // // Example // // Date.today().add(1).second(); // Date.march().second().monday(); // // Things get crazy with the following... // Date.march().add(1).second().second().monday(); // but it works!! // if (this._isSecond) { this.addSeconds(this._orient * -1); } // make sure we reset _isSecond this._isSecond = false; var ntemp = this._nth; this._nth = null; var temp = this.clone().moveToLastDayOfMonth(); this.moveToNthOccurrence(n, ntemp); if (this > temp) { throw new RangeError($D.getDayName(n) + " does not occur " + ntemp + " times in the month of " + $D.getMonthName(temp.getMonth()) + " " + temp.getFullYear() + "."); } return this; } return this.moveToDayOfWeek(n, this._orient); }; }; var sdf = function (n) { return function () { var t = $D.today(), shift = n - t.getDay(); if (n === 0 && Date.CultureInfo.firstDayOfWeek === 1 && t.getDay() !== 0) { shift = shift + 7; } return t.addDays(shift); }; }; // Create month name functions and abbreviated month name functions (eg. january(), march(), mar()). var month_instance_functions = function (n) { return function () { if (this._is) { this._is = false; return this.getMonth() === n; } return this.moveToMonth(n, this._orient); }; }; var month_static_functions = function (n) { return function () { return $D.today().set({ month: n, day: 1 }); }; }; var processTerms = function (names, staticFunc, instanceFunc) { for (var i = 0; i < names.length; i++) { // Create constant static Name variables. $D[names[i].toUpperCase()] = $D[names[i].toUpperCase().substring(0, 3)] = i; // Create Name functions. $D[names[i]] = $D[names[i].substring(0, 3)] = staticFunc(i); // Create Name instance functions. $P[names[i]] = $P[names[i].substring(0, 3)] = instanceFunc(i); } }; processTerms(dx, sdf, df); processTerms(mx, month_static_functions, month_instance_functions); // Create date element functions and plural date element functions used with Date (eg. day(), days(), months()). var ef = function (j) { return function () { // if the .second() function was called earlier, the _orient // has alread been added. Just return this and reset _isSecond. if (this._isSecond) { this._isSecond = false; return this; } if (this._same) { this._same = this._is = false; var o1 = this.toObject(), o2 = (arguments[0] || new Date()).toObject(), v = "", k = j.toLowerCase(); // the substr trick with -1 doesn't work in IE8 or less k = (k[k.length-1] === "s") ? k.substring(0,k.length-1) : k; for (var m = (px.length - 1); m > -1; m--) { v = px[m].toLowerCase(); if (o1[v] !== o2[v]) { return false; } if (k === v) { break; } } return true; } if (j.substring(j.length - 1) !== "s") { j += "s"; } if (this._move) { this._move = null; } return this["add" + j](this._orient); }; }; var nf = function (n) { return function () { this._dateElement = n; return this; }; }; for (var k = 0; k < px.length; k++) { de = px[k].toLowerCase(); if(de !== "weekday") { // Create date element functions and plural date element functions used with Date (eg. day(), days(), months()). $P[de] = $P[de + "s"] = ef(px[k]); // Create date element functions and plural date element functions used with Number (eg. day(), days(), months()). $N[de] = $N[de + "s"] = nf(de + "s"); } } $P._ss = ef("Second"); var nthfn = function (n) { return function (dayOfWeek) { if (this._same) { return this._ss(arguments[0]); } if (dayOfWeek || dayOfWeek === 0) { return this.moveToNthOccurrence(dayOfWeek, n); } this._nth = n; // if the operator is 'second' add the _orient, then deal with it later... if (n === 2 && (dayOfWeek === undefined || dayOfWeek === null)) { this._isSecond = true; return this.addSeconds(this._orient); } return this; }; }; for (var l = 0; l < nth.length; l++) { $P[nth[l]] = (l === 0) ? nthfn(-1) : nthfn(l); } }()); (function () { "use strict"; Date.Parsing = { Exception: function (s) { this.message = "Parse error at '" + s.substring(0, 10) + " ...'"; } }; var $P = Date.Parsing; var dayOffsets = { standard: [0,31,59,90,120,151,181,212,243,273,304,334], leap: [0,31,60,91,121,152,182,213,244,274,305,335] }; $P.isLeapYear = function(year) { return ((year % 4 === 0) && (year % 100 !== 0)) || (year % 400 === 0); }; var utils = { multiReplace : function (str, hash ) { var key; for (key in hash) { if (Object.prototype.hasOwnProperty.call(hash, key)) { var regex; if (typeof hash[key] === "function") { } else { regex = (hash[key] instanceof RegExp) ? hash[key] : new RegExp(hash[key], "g"); } str = str.replace(regex, key); } } return str; }, getDayOfYearFromWeek : function (obj) { var d, jan4, offset; obj.weekDay = (!obj.weekDay && obj.weekDay !== 0) ? 1 : obj.weekDay; d = new Date(obj.year, 0, 4); jan4 = d.getDay() === 0 ? 7 : d.getDay(); // JS is 0 indexed on Sunday. offset = jan4+3; obj.dayOfYear = ((obj.week * 7) + (obj.weekDay === 0 ? 7 : obj.weekDay))-offset; return obj; }, getDayOfYear : function (obj, dayOffset) { if (!obj.dayOfYear) { obj = utils.getDayOfYearFromWeek(obj); } for (var i=0;i <= dayOffset.length;i++) { if (obj.dayOfYear < dayOffset[i] || i === dayOffset.length) { obj.day = obj.day ? obj.day : (obj.dayOfYear - dayOffset[i-1]); break; } else { obj.month = i; } } return obj; }, adjustForTimeZone : function (obj, date) { var offset; if (obj.zone.toUpperCase() === "Z" || (obj.zone_hours === 0 && obj.zone_minutes === 0)) { // it's UTC/GML so work out the current timeszone offset offset = -date.getTimezoneOffset(); } else { offset = (obj.zone_hours*60) + (obj.zone_minutes || 0); if (obj.zone_sign === "+") { offset *= -1; } offset -= date.getTimezoneOffset(); } date.setMinutes(date.getMinutes()+offset); return date; }, setDefaults : function (obj) { obj.year = obj.year || Date.today().getFullYear(); obj.hours = obj.hours || 0; obj.minutes = obj.minutes || 0; obj.seconds = obj.seconds || 0; obj.milliseconds = obj.milliseconds || 0; if (!(!obj.month && (obj.week || obj.dayOfYear))) { // if we have a month, or if we don't but don't have the day calculation data obj.month = obj.month || 0; obj.day = obj.day || 1; } return obj; }, dataNum: function (data, mod, explict, postProcess) { var dataNum = data*1; if (mod) { if (postProcess) { return data ? mod(data)*1 : data; } else { return data ? mod(dataNum) : data; } } else if (!explict){ return data ? dataNum : data; } else { return (data && typeof data !== "undefined") ? dataNum : data; } }, timeDataProcess: function (obj) { var timeObj = {}; for (var x in obj.data) { if (obj.data.hasOwnProperty(x)) { timeObj[x] = obj.ignore[x] ? obj.data[x] : utils.dataNum(obj.data[x], obj.mods[x], obj.explict[x], obj.postProcess[x]); } } if (obj.data.secmins) { obj.data.secmins = obj.data.secmins.replace(",", ".") * 60; if (!timeObj.minutes) { timeObj.minutes = obj.data.secmins; } else if (!timeObj.seconds) { timeObj.seconds = obj.data.secmins; } delete obj.secmins; } return timeObj; }, buildTimeObjectFromData: function (data) { var time = utils.timeDataProcess({ data: { year : data[1], month : data[5], day : data[7], week : data[8], dayOfYear : data[10], hours : data[15], zone_hours : data[23], zone_minutes : data[24], zone : data[21], zone_sign : data[22], weekDay : data[9], minutes: data[16], seconds: data[19], milliseconds: data[20], secmins: data[18] }, mods: { month: function(data) { return data-1; }, weekDay: function (data) { data = Math.abs(data); return (data === 7 ? 0 : data); }, minutes: function (data) { return data.replace(":",""); }, seconds: function (data) { return Math.floor( (data.replace(":","").replace(",","."))*1 ); }, milliseconds: function (data) { return (data.replace(",",".")*1000); } }, postProcess: { minutes: true, seconds: true, milliseconds: true }, explict: { zone_hours: true, zone_minutes: true }, ignore: { zone: true, zone_sign: true, secmins: true } }); return time; }, addToHash: function (hash, keys, data) { keys = keys; data = data; var len = keys.length; for (var i = 0; i < len; i++) { hash[keys[i]] = data[i]; } return hash; }, combineRegex: function (r1, r2) { return new RegExp("(("+r1.source+")\\s("+r2.source+"))"); }, getDateNthString: function(add, last, inc){ if (add) { return Date.today().addDays(inc).toString("d"); } else if (last) { return Date.today().last()[inc]().toString("d"); } }, buildRegexData: function (array) { var arr = []; var len = array.length; for (var i=0; i < len; i++) { if (Object.prototype.toString.call(array[i]) === '[object Array]') { // oldIE compat version of Array.isArray arr.push(this.combineRegex(array[i][0], array[i][1])); } else { arr.push(array[i]); } } return arr; } }; $P.processTimeObject = function (obj) { var date, dayOffset; utils.setDefaults(obj); dayOffset = ($P.isLeapYear(obj.year)) ? dayOffsets.leap : dayOffsets.standard; if (!obj.month && (obj.week || obj.dayOfYear)) { utils.getDayOfYear(obj, dayOffset); } else { obj.dayOfYear = dayOffset[obj.month] + obj.day; } date = new Date(obj.year, obj.month, obj.day, obj.hours, obj.minutes, obj.seconds, obj.milliseconds); if (obj.zone) { utils.adjustForTimeZone(obj, date); // adjust (and calculate) for timezone } return date; }; $P.ISO = { regex : /^([\+-]?\d{4}(?!\d{2}\b))((-?)((0[1-9]|1[0-2])(\3([12]\d|0[1-9]|3[01]))?|W([0-4]\d|5[0-3])(-?[1-7])?|(00[1-9]|0[1-9]\d|[12]\d{2}|3([0-5]\d|6[1-6])))([T\s]((([01]\d|2[0-4])((:?)[0-5]\d)?|24\:?00)([\.,]\d+(?!:))?)?(\17[0-5]\d([\.,]\d+)?)?\s?([zZ]|([\+-])([01]\d|2[0-3]):?([0-5]\d)?)?)?)?$/, parse : function (s) { var time, data = s.match(this.regex); if (!data || !data.length) { return null; } time = utils.buildTimeObjectFromData(data); if (!time.year || (!time.year && (!time.month && !time.day) && (!time.week && !time.dayOfYear)) ) { return null; } return $P.processTimeObject(time); } }; $P.Numeric = { isNumeric: function (e){return!isNaN(parseFloat(e))&&isFinite(e);}, regex: /\b([0-1]?[0-9])([0-3]?[0-9])([0-2]?[0-9]?[0-9][0-9])\b/i, parse: function (s) { var data, i, time = {}, order = Date.CultureInfo.dateElementOrder.split(""); if (!(this.isNumeric(s)) || // if it's non-numeric OR (s[0] === "+" && s[0] === "-")) { // It's an arithmatic string (eg +/-1000) return null; } if (s.length < 5 && s.indexOf(".") < 0 && s.indexOf("/") < 0) { // assume it's just a year. time.year = s; return $P.processTimeObject(time); } data = s.match(this.regex); if (!data || !data.length) { return null; } for (i=0; i < order.length; i++) { switch(order[i]) { case "d": time.day = data[i+1]; break; case "m": time.month = (data[i+1]-1); break; case "y": time.year = data[i+1]; break; } } return $P.processTimeObject(time); } }; $P.Normalizer = { regexData: function () { var $R = Date.CultureInfo.regexPatterns; return utils.buildRegexData([ $R.tomorrow, $R.yesterday, [$R.past, $R.mon], [$R.past, $R.tue], [$R.past, $R.wed], [$R.past, $R.thu], [$R.past, $R.fri], [$R.past, $R.sat], [$R.past, $R.sun] ]); }, basicReplaceHash : function() { var $R = Date.CultureInfo.regexPatterns; return { "January": $R.jan.source, "February": $R.feb, "March": $R.mar, "April": $R.apr, "May": $R.may, "June": $R.jun, "July": $R.jul, "August": $R.aug, "September": $R.sep, "October": $R.oct, "November": $R.nov, "December": $R.dec, "": /\bat\b/gi, " ": /\s{2,}/, "am": $R.inTheMorning, "9am": $R.thisMorning, "pm": $R.inTheEvening, "7pm":$R.thisEvening }; }, keys : function(){ return [ utils.getDateNthString(true, false, 1), // tomorrow utils.getDateNthString(true, false, -1), // yesterday utils.getDateNthString(false, true, "monday"), //last mon utils.getDateNthString(false, true, "tuesday"), //last tues utils.getDateNthString(false, true, "wednesday"), //last wed utils.getDateNthString(false, true, "thursday"), //last thurs utils.getDateNthString(false, true, "friday"), //last fri utils.getDateNthString(false, true, "saturday"), //last sat utils.getDateNthString(false, true, "sunday") //last sun ]; }, buildRegexFunctions: function () { var $R = Date.CultureInfo.regexPatterns; var __ = Date.i18n.__; var tomorrowRE = new RegExp("(\\b\\d\\d?("+__("AM")+"|"+__("PM")+")? )("+$R.tomorrow.source.slice(1)+")", "i"); // adapted tomorrow regex for AM PM relative dates var todayRE = new RegExp($R.today.source + "(?!\\s*([+-]))\\b"); // today, but excludes the math operators (eg "today + 2h") this.replaceFuncs = [ [todayRE, function (full) { return (full.length > 1) ? Date.today().toString("d") : full; }], [tomorrowRE, function(full, m1) { var t = Date.today().addDays(1).toString("d"); return (t + " " + m1); }], [$R.amThisMorning, function(str, am){return am;}], [$R.pmThisEvening, function(str, pm){return pm;}] ]; }, buildReplaceData: function () { this.buildRegexFunctions(); this.replaceHash = utils.addToHash(this.basicReplaceHash(), this.keys(), this.regexData()); }, stringReplaceFuncs: function (s) { for (var i=0; i < this.replaceFuncs.length; i++) { s = s.replace(this.replaceFuncs[i][0], this.replaceFuncs[i][1]); } return s; }, parse: function (s) { s = this.stringReplaceFuncs(s); s = utils.multiReplace(s, this.replaceHash); try { var n = s.split(/([\s\-\.\,\/\x27]+)/); if (n.length === 3 && $P.Numeric.isNumeric(n[0]) && $P.Numeric.isNumeric(n[2]) && (n[2].length >= 4)) { // ok, so we're dealing with x/year. But that's not a full date. // This fixes wonky dateElementOrder parsing when set to dmy order. if (Date.CultureInfo.dateElementOrder[0] === "d") { s = "1/" + n[0] + "/" + n[2]; // set to 1st of month and normalize the seperator } } } catch (e) {} return s; } }; $P.Normalizer.buildReplaceData(); }()); (function () { var $P = Date.Parsing; var _ = $P.Operators = { // // Tokenizers // rtoken: function (r) { // regex token return function (s) { var mx = s.match(r); if (mx) { return ([ mx[0], s.substring(mx[0].length) ]); } else { throw new $P.Exception(s); } }; }, token: function () { // whitespace-eating token return function (s) { return _.rtoken(new RegExp("^\\s*" + s + "\\s*"))(s); }; }, stoken: function (s) { // string token return _.rtoken(new RegExp("^" + s)); }, // Atomic Operators until: function (p) { return function (s) { var qx = [], rx = null; while (s.length) { try { rx = p.call(this, s); } catch (e) { qx.push(rx[0]); s = rx[1]; continue; } break; } return [ qx, s ]; }; }, many: function (p) { return function (s) { var rx = [], r = null; while (s.length) { try { r = p.call(this, s); } catch (e) { return [ rx, s ]; } rx.push(r[0]); s = r[1]; } return [ rx, s ]; }; }, // generator operators -- see below optional: function (p) { return function (s) { var r = null; try { r = p.call(this, s); } catch (e) { return [ null, s ]; } return [ r[0], r[1] ]; }; }, not: function (p) { return function (s) { try { p.call(this, s); } catch (e) { return [null, s]; } throw new $P.Exception(s); }; }, ignore: function (p) { return p ? function (s) { var r = null; r = p.call(this, s); return [null, r[1]]; } : null; }, product: function () { var px = arguments[0], qx = Array.prototype.slice.call(arguments, 1), rx = []; for (var i = 0 ; i < px.length ; i++) { rx.push(_.each(px[i], qx)); } return rx; }, cache: function (rule) { var cache = {}, cache_length = 0, cache_keys = [], CACHE_MAX = Date.Config.CACHE_MAX || 100000, r = null; var cacheCheck = function () { if (cache_length === CACHE_MAX) { // kill several keys, don't want to have to do this all the time... for (var i=0; i < 10; i++) { var key = cache_keys.shift(); if (key) { delete cache[key]; cache_length--; } } } }; return function (s) { cacheCheck(); try { r = cache[s] = (cache[s] || rule.call(this, s)); } catch (e) { r = cache[s] = e; } cache_length++; cache_keys.push(s); if (r instanceof $P.Exception) { throw r; } else { return r; } }; }, // vector operators -- see below any: function () { var px = arguments; return function (s) { var r = null; for (var i = 0; i < px.length; i++) { if (px[i] == null) { continue; } try { r = (px[i].call(this, s)); } catch (e) { r = null; } if (r) { return r; } } throw new $P.Exception(s); }; }, each: function () { var px = arguments; return function (s) { var rx = [], r = null; for (var i = 0; i < px.length ; i++) { if (px[i] == null) { continue; } try { r = (px[i].call(this, s)); } catch (e) { throw new $P.Exception(s); } rx.push(r[0]); s = r[1]; } return [ rx, s]; }; }, all: function () { var px = arguments, _ = _; return _.each(_.optional(px)); }, // delimited operators sequence: function (px, d, c) { d = d || _.rtoken(/^\s*/); c = c || null; if (px.length === 1) { return px[0]; } return function (s) { var r = null, q = null; var rx = []; for (var i = 0; i < px.length ; i++) { try { r = px[i].call(this, s); } catch (e) { break; } rx.push(r[0]); try { q = d.call(this, r[1]); } catch (ex) { q = null; break; } s = q[1]; } if (!r) { throw new $P.Exception(s); } if (q) { throw new $P.Exception(q[1]); } if (c) { try { r = c.call(this, r[1]); } catch (ey) { throw new $P.Exception(r[1]); } } return [ rx, (r?r[1]:s) ]; }; }, // // Composite Operators // between: function (d1, p, d2) { d2 = d2 || d1; var _fn = _.each(_.ignore(d1), p, _.ignore(d2)); return function (s) { var rx = _fn.call(this, s); return [[rx[0][0], r[0][2]], rx[1]]; }; }, list: function (p, d, c) { d = d || _.rtoken(/^\s*/); c = c || null; return (p instanceof Array ? _.each(_.product(p.slice(0, -1), _.ignore(d)), p.slice(-1), _.ignore(c)) : _.each(_.many(_.each(p, _.ignore(d))), px, _.ignore(c))); }, set: function (px, d, c) { d = d || _.rtoken(/^\s*/); c = c || null; return function (s) { // r is the current match, best the current 'best' match // which means it parsed the most amount of input var r = null, p = null, q = null, rx = null, best = [[], s], last = false; // go through the rules in the given set for (var i = 0; i < px.length ; i++) { // last is a flag indicating whether this must be the last element // if there is only 1 element, then it MUST be the last one q = null; p = null; r = null; last = (px.length === 1); // first, we try simply to match the current pattern // if not, try the next pattern try { r = px[i].call(this, s); } catch (e) { continue; } // since we are matching against a set of elements, the first // thing to do is to add r[0] to matched elements rx = [[r[0]], r[1]]; // if we matched and there is still input to parse and // we don't already know this is the last element, // we're going to next check for the delimiter ... // if there's none, or if there's no input left to parse // than this must be the last element after all ... if (r[1].length > 0 && ! last) { try { q = d.call(this, r[1]); } catch (ex) { last = true; } } else { last = true; } // if we parsed the delimiter and now there's no more input, // that means we shouldn't have parsed the delimiter at all // so don't update r and mark this as the last element ... if (!last && q[1].length === 0) { last = true; } // so, if this isn't the last element, we're going to see if // we can get any more matches from the remaining (unmatched) // elements ... if (!last) { // build a list of the remaining rules we can match against, // i.e., all but the one we just matched against var qx = []; for (var j = 0; j < px.length ; j++) { if (i !== j) { qx.push(px[j]); } } // now invoke recursively set with the remaining input // note that we don't include the closing delimiter ... // we'll check for that ourselves at the end p = _.set(qx, d).call(this, q[1]); // if we got a non-empty set as a result ... // (otw rx already contains everything we want to match) if (p[0].length > 0) { // update current result, which is stored in rx ... // basically, pick up the remaining text from p[1] // and concat the result from p[0] so that we don't // get endless nesting ... rx[0] = rx[0].concat(p[0]); rx[1] = p[1]; } } // at this point, rx either contains the last matched element // or the entire matched set that starts with this element. // now we just check to see if this variation is better than // our best so far, in terms of how much of the input is parsed if (rx[1].length < best[1].length) { best = rx; } // if we've parsed all the input, then we're finished if (best[1].length === 0) { break; } } // so now we've either gone through all the patterns trying them // as the initial match; or we found one that parsed the entire // input string ... // if best has no matches, just return empty set ... if (best[0].length === 0) { return best; } // if a closing delimiter is provided, then we have to check it also if (c) { // we try this even if there is no remaining input because the pattern // may well be optional or match empty input ... try { q = c.call(this, best[1]); } catch (ey) { throw new $P.Exception(best[1]); } // it parsed ... be sure to update the best match remaining input best[1] = q[1]; } // if we're here, either there was no closing delimiter or we parsed it // so now we have the best match; just return it! return best; }; }, forward: function (gr, fname) { return function (s) { return gr[fname].call(this, s); }; }, // // Translation Operators // replace: function (rule, repl) { return function (s) { var r = rule.call(this, s); return [repl, r[1]]; }; }, process: function (rule, fn) { return function (s) { var r = rule.call(this, s); return [fn.call(this, r[0]), r[1]]; }; }, min: function (min, rule) { return function (s) { var rx = rule.call(this, s); if (rx[0].length < min) { throw new $P.Exception(s); } return rx; }; } }; // Generator Operators And Vector Operators // Generators are operators that have a signature of F(R) => R, // taking a given rule and returning another rule, such as // ignore, which parses a given rule and throws away the result. // Vector operators are those that have a signature of F(R1,R2,...) => R, // take a list of rules and returning a new rule, such as each. // Generator operators are converted (via the following _generator // function) into functions that can also take a list or array of rules // and return an array of new rules as though the function had been // called on each rule in turn (which is what actually happens). // This allows generators to be used with vector operators more easily. // Example: // each(ignore(foo, bar)) instead of each(ignore(foo), ignore(bar)) // This also turns generators into vector operators, which allows // constructs like: // not(cache(foo, bar)) var _generator = function (op) { function gen() { var args = null, rx = [], px, i; if (arguments.length > 1) { args = Array.prototype.slice.call(arguments); } else if (arguments[0] instanceof Array) { args = arguments[0]; } if (args) { px = args.shift(); if (px.length > 0) { args.unshift(px[i]); rx.push(op.apply(null, args)); args.shift(); return rx; } } else { return op.apply(null, arguments); } } return gen; }; var gx = "optional not ignore cache".split(/\s/); for (var i = 0 ; i < gx.length ; i++) { _[gx[i]] = _generator(_[gx[i]]); } var _vector = function (op) { return function () { if (arguments[0] instanceof Array) { return op.apply(null, arguments[0]); } else { return op.apply(null, arguments); } }; }; var vx = "each any all".split(/\s/); for (var j = 0 ; j < vx.length ; j++) { _[vx[j]] = _vector(_[vx[j]]); } }()); (function () { var $D = Date; var flattenAndCompact = function (ax) { var rx = []; for (var i = 0; i < ax.length; i++) { if (ax[i] instanceof Array) { rx = rx.concat(flattenAndCompact(ax[i])); } else { if (ax[i]) { rx.push(ax[i]); } } } return rx; }; var parseMeridian = function () { if (this.meridian && (this.hour || this.hour === 0)) { if (this.meridian === "a" && this.hour > 11 && Date.Config.strict24hr){ throw "Invalid hour and meridian combination"; } else if (this.meridian === "p" && this.hour < 12 && Date.Config.strict24hr){ throw "Invalid hour and meridian combination"; } else if (this.meridian === "p" && this.hour < 12) { this.hour = this.hour + 12; } else if (this.meridian === "a" && this.hour === 12) { this.hour = 0; } } }; var setDefaults = function () { var now = new Date(); if ((this.hour || this.minute) && (!this.month && !this.year && !this.day)) { this.day = now.getDate(); } if (!this.year) { this.year = now.getFullYear(); } if (!this.month && this.month !== 0) { this.month = now.getMonth(); } if (!this.day) { this.day = 1; } if (!this.hour) { this.hour = 0; } if (!this.minute) { this.minute = 0; } if (!this.second) { this.second = 0; } if (!this.millisecond) { this.millisecond = 0; } }; var finishUtils = { getToday: function () { if (this.now || "hour minute second".indexOf(this.unit) !== -1) { return new Date(); } else { return $D.today(); } }, setDaysFromWeekday: function (today, orient){ var gap; orient = orient || 1; this.unit = "day"; gap = ($D.getDayNumberFromName(this.weekday) - today.getDay()); this.days = gap ? ((gap + (orient * 7)) % 7) : (orient * 7); return this; }, setMonthsFromMonth: function (today, orient) { var gap; orient = orient || 1; this.unit = "month"; gap = (this.month - today.getMonth()); this.months = gap ? ((gap + (orient * 12)) % 12) : (orient * 12); this.month = null; return this; }, setDMYFromWeekday: function () { var d = Date[this.weekday](); this.day = d.getDate(); if (!this.month) { this.month = d.getMonth(); } this.year = d.getFullYear(); return this; }, setUnitValue: function (orient) { if (!this.value && this.operator && this.operator !== null && this[this.unit + "s"] && this[this.unit + "s"] !== null) { this[this.unit + "s"] = this[this.unit + "s"] + ((this.operator === "add") ? 1 : -1) + (this.value||0) * orient; } else if (this[this.unit + "s"] == null || this.operator != null) { if (!this.value) { this.value = 1; } this[this.unit + "s"] = this.value * orient; } }, generateDateFromWeeks: function () { var weekday = (this.weekday !== undefined) ? this.weekday : "today"; var d = Date[weekday]().addWeeks(this.weeks); if (this.now) { d.setTimeToNow(); } return d; } }; $D.Translator = { hour: function (s) { return function () { this.hour = Number(s); }; }, minute: function (s) { return function () { this.minute = Number(s); }; }, second: function (s) { return function () { this.second = Number(s); }; }, /* for ss.s format */ secondAndMillisecond: function (s) { return function () { var mx = s.match(/^([0-5][0-9])\.([0-9]{1,3})/); this.second = Number(mx[1]); this.millisecond = Number(mx[2]); }; }, meridian: function (s) { return function () { this.meridian = s.slice(0, 1).toLowerCase(); }; }, timezone: function (s) { return function () { var n = s.replace(/[^\d\+\-]/g, ""); if (n.length) { this.timezoneOffset = Number(n); } else { this.timezone = s.toLowerCase(); } }; }, day: function (x) { var s = x[0]; return function () { this.day = Number(s.match(/\d+/)[0]); if (this.day < 1) { throw "invalid day"; } }; }, month: function (s) { return function () { this.month = (s.length === 3) ? "jan feb mar apr may jun jul aug sep oct nov dec".indexOf(s)/4 : Number(s) - 1; if (this.month < 0) { throw "invalid month"; } }; }, year: function (s) { return function () { var n = Number(s); this.year = ((s.length > 2) ? n : (n + (((n + 2000) < Date.CultureInfo.twoDigitYearMax) ? 2000 : 1900))); }; }, rday: function (s) { return function () { switch (s) { case "yesterday": this.days = -1; break; case "tomorrow": this.days = 1; break; case "today": this.days = 0; break; case "now": this.days = 0; this.now = true; break; } }; }, finishExact: function (x) { var d; x = (x instanceof Array) ? x : [x]; for (var i = 0 ; i < x.length ; i++) { if (x[i]) { x[i].call(this); } } setDefaults.call(this); parseMeridian.call(this); if (this.day > $D.getDaysInMonth(this.year, this.month)) { throw new RangeError(this.day + " is not a valid value for days."); } d = new Date(this.year, this.month, this.day, this.hour, this.minute, this.second, this.millisecond); if (this.year < 100) { d.setFullYear(this.year); // means years less that 100 are process correctly. JS will parse it otherwise as 1900-1999. } if (this.timezone) { d.set({ timezone: this.timezone }); } else if (this.timezoneOffset) { d.set({ timezoneOffset: this.timezoneOffset }); } return d; }, finish: function (x) { var today, expression, orient, temp; x = (x instanceof Array) ? flattenAndCompact(x) : [ x ]; if (x.length === 0) { return null; } for (var i = 0 ; i < x.length ; i++) { if (typeof x[i] === "function") { x[i].call(this); } } if (this.now && !this.unit && !this.operator) { return new Date(); } else { today = finishUtils.getToday.call(this); } expression = !!(this.days && this.days !== null || this.orient || this.operator); orient = ((this.orient === "past" || this.operator === "subtract") ? -1 : 1); if (this.month && this.unit === "week") { this.value = this.month + 1; delete this.month; delete this.day; } if ((this.month || this.month === 0) && "year day hour minute second".indexOf(this.unit) !== -1) { if (!this.value) { this.value = this.month + 1; } this.month = null; expression = true; } if (!expression && this.weekday && !this.day && !this.days) { finishUtils.setDMYFromWeekday.call(this); } if (expression && this.weekday && this.unit !== "month" && this.unit !== "week") { finishUtils.setDaysFromWeekday.call(this, today, orient); } if (this.weekday && this.unit !== "week" && !this.day && !this.days) { temp = Date[this.weekday](); this.day = temp.getDate(); if (temp.getMonth() !== today.getMonth()) { this.month = temp.getMonth(); } } if (this.month && this.unit === "day" && this.operator) { if (!this.value) { this.value = (this.month + 1); } this.month = null; } if (this.value != null && this.month != null && this.year != null) { this.day = this.value * 1; } if (this.month && !this.day && this.value) { today.set({ day: this.value * 1 }); if (!expression) { this.day = this.value * 1; } } if (!this.month && this.value && this.unit === "month" && !this.now) { this.month = this.value; expression = true; } if (expression && (this.month || this.month === 0) && this.unit !== "year") { finishUtils.setMonthsFromMonth.call(this, today, orient); } if (!this.unit) { this.unit = "day"; } finishUtils.setUnitValue.call(this, orient); parseMeridian.call(this); if ((this.month || this.month === 0) && !this.day) { this.day = 1; } if (!this.orient && !this.operator && this.unit === "week" && this.value && !this.day && !this.month) { return Date.today().setWeek(this.value); } if (this.unit === "week" && this.weeks && !this.day && !this.month) { return finishUtils.generateDateFromWeeks.call(this); } if (expression && this.timezone && this.day && this.days) { this.day = this.days; } if (expression){ today.add(this); } else { today.set(this); } if (this.timezone) { this.timezone = this.timezone.toUpperCase(); var offset = $D.getTimezoneOffset(this.timezone); var timezone; if (today.hasDaylightSavingTime()) { // lets check that we're being sane with timezone setting timezone = $D.getTimezoneAbbreviation(offset, today.isDaylightSavingTime()); if (timezone !== this.timezone) { // bugger, we're in a place where things like EST vs EDT matters. if (today.isDaylightSavingTime()) { today.addHours(-1); } else { today.addHours(1); } } } today.setTimezoneOffset(offset); } return today; } }; }()); (function () { var $D = Date; $D.Grammar = {}; var _ = $D.Parsing.Operators, g = $D.Grammar, t = $D.Translator, _fn; // Allow rolling up into general purpose rules _fn = function () { return _.each(_.any.apply(null, arguments), _.not(g.ctoken2("timeContext"))); }; g.datePartDelimiter = _.rtoken(/^([\s\-\.\,\/\x27]+)/); g.timePartDelimiter = _.stoken(":"); g.whiteSpace = _.rtoken(/^\s*/); g.generalDelimiter = _.rtoken(/^(([\s\,]|at|@|on)+)/); var _C = {}; g.ctoken = function (keys) { var fn = _C[keys]; if (! fn) { var c = Date.CultureInfo.regexPatterns; var kx = keys.split(/\s+/), px = []; for (var i = 0; i < kx.length ; i++) { px.push(_.replace(_.rtoken(c[kx[i]]), kx[i])); } fn = _C[keys] = _.any.apply(null, px); } return fn; }; g.ctoken2 = function (key) { return _.rtoken(Date.CultureInfo.regexPatterns[key]); }; var cacheProcessRtoken = function (key, token, type, eachToken) { if (eachToken) { g[key] = _.cache(_.process(_.each(_.rtoken(token),_.optional(g.ctoken2(eachToken))), type)); } else { g[key] = _.cache(_.process(_.rtoken(token), type)); } }; var cacheProcessCtoken = function (token, type) { return _.cache(_.process(g.ctoken2(token), type)); }; var _F = {}; //function cache var _get = function (f) { _F[f] = (_F[f] || g.format(f)[0]); return _F[f]; }; g.allformats = function (fx) { var rx = []; if (fx instanceof Array) { for (var i = 0; i < fx.length; i++) { rx.push(_get(fx[i])); } } else { rx.push(_get(fx)); } return rx; }; g.formats = function (fx) { if (fx instanceof Array) { var rx = []; for (var i = 0 ; i < fx.length ; i++) { rx.push(_get(fx[i])); } return _.any.apply(null, rx); } else { return _get(fx); } }; var grammarFormats = { timeFormats: function(){ var i, RTokenKeys = [ "h", "hh", "H", "HH", "m", "mm", "s", "ss", "ss.s", "z", "zz" ], RToken = [ /^(0[0-9]|1[0-2]|[1-9])/, /^(0[0-9]|1[0-2])/, /^([0-1][0-9]|2[0-3]|[0-9])/, /^([0-1][0-9]|2[0-3])/, /^([0-5][0-9]|[0-9])/, /^[0-5][0-9]/, /^([0-5][0-9]|[0-9])/, /^[0-5][0-9]/, /^[0-5][0-9]\.[0-9]{1,3}/, /^((\+|\-)\s*\d\d\d\d)|((\+|\-)\d\d\:?\d\d)/, /^((\+|\-)\s*\d\d\d\d)|((\+|\-)\d\d\:?\d\d)/ ], tokens = [ t.hour, t.hour, t.hour, t.hour, t.minute, t.minute, t.second, t.second, t.secondAndMillisecond, t.timezone, t.timezone ]; for (i=0; i < RTokenKeys.length; i++) { cacheProcessRtoken(RTokenKeys[i], RToken[i], tokens[i]); } g.hms = _.cache(_.sequence([g.H, g.m, g.s], g.timePartDelimiter)); g.t = cacheProcessCtoken("shortMeridian", t.meridian); g.tt = cacheProcessCtoken("longMeridian", t.meridian); g.zzz = cacheProcessCtoken("timezone", t.timezone); g.timeSuffix = _.each(_.ignore(g.whiteSpace), _.set([ g.tt, g.zzz ])); g.time = _.each(_.optional(_.ignore(_.stoken("T"))), g.hms, g.timeSuffix); }, dateFormats: function () { // pre-loaded rules for different date part order preferences var _setfn = function () { return _.set(arguments, g.datePartDelimiter); }; var i, RTokenKeys = [ "d", "dd", "M", "MM", "y", "yy", "yyy", "yyyy" ], RToken = [ /^([0-2]\d|3[0-1]|\d)/, /^([0-2]\d|3[0-1])/, /^(1[0-2]|0\d|\d)/, /^(1[0-2]|0\d)/, /^(\d+)/, /^(\d\d)/, /^(\d\d?\d?\d?)/, /^(\d\d\d\d)/ ], tokens = [ t.day, t.day, t.month, t.month, t.year, t.year, t.year, t.year ], eachToken = [ "ordinalSuffix", "ordinalSuffix" ]; for (i=0; i < RTokenKeys.length; i++) { cacheProcessRtoken(RTokenKeys[i], RToken[i], tokens[i], eachToken[i]); } g.MMM = g.MMMM = _.cache(_.process(g.ctoken("jan feb mar apr may jun jul aug sep oct nov dec"), t.month)); g.ddd = g.dddd = _.cache(_.process(g.ctoken("sun mon tue wed thu fri sat"), function (s) { return function () { this.weekday = s; }; } )); g.day = _fn(g.d, g.dd); g.month = _fn(g.M, g.MMM); g.year = _fn(g.yyyy, g.yy); g.mdy = _setfn(g.ddd, g.month, g.day, g.year); g.ymd = _setfn(g.ddd, g.year, g.month, g.day); g.dmy = _setfn(g.ddd, g.day, g.month, g.year); g.date = function (s) { return ((g[Date.CultureInfo.dateElementOrder] || g.mdy).call(this, s)); }; }, relative: function () { // relative date / time expressions g.orientation = _.process(g.ctoken("past future"), function (s) { return function () { this.orient = s; }; } ); g.operator = _.process(g.ctoken("add subtract"), function (s) { return function () { this.operator = s; }; } ); g.rday = _.process(g.ctoken("yesterday tomorrow today now"), t.rday); g.unit = _.process(g.ctoken("second minute hour day week month year"), function (s) { return function () { this.unit = s; }; } ); } }; g.buildGrammarFormats = function () { // these need to be rebuilt every time the language changes. _C = {}; grammarFormats.timeFormats(); grammarFormats.dateFormats(); grammarFormats.relative(); g.value = _.process(_.rtoken(/^([-+]?\d+)?(st|nd|rd|th)?/), function (s) { return function () { this.value = s.replace(/\D/g, ""); }; } ); g.expression = _.set([g.rday, g.operator, g.value, g.unit, g.orientation, g.ddd, g.MMM ]); g.format = _.process(_.many( _.any( // translate format specifiers into grammar rules _.process( _.rtoken(/^(dd?d?d?(?!e)|MM?M?M?|yy?y?y?|hh?|HH?|mm?|ss?|tt?|zz?z?)/), function (fmt) { if (g[fmt]) { return g[fmt]; } else { throw $D.Parsing.Exception(fmt); } } ), // translate separator tokens into token rules _.process(_.rtoken(/^[^dMyhHmstz]+/), // all legal separators function (s) { return _.ignore(_.stoken(s)); } ) ) ), // construct the parser ... function (rules) { return _.process(_.each.apply(null, rules), t.finishExact); } ); // starting rule for general purpose grammar g._start = _.process(_.set([ g.date, g.time, g.expression ], g.generalDelimiter, g.whiteSpace), t.finish); }; g.buildGrammarFormats(); // parsing date format specifiers - ex: "h:m:s tt" // this little guy will generate a custom parser based // on the format string, ex: g.format("h:m:s tt") // check for these formats first g._formats = g.formats([ "\"yyyy-MM-ddTHH:mm:ssZ\"", "yyyy-MM-ddTHH:mm:ss.sz", "yyyy-MM-ddTHH:mm:ssZ", "yyyy-MM-ddTHH:mm:ssz", "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-ddTHH:mmZ", "yyyy-MM-ddTHH:mmz", "yyyy-MM-ddTHH:mm", "ddd, MMM dd, yyyy H:mm:ss tt", "ddd MMM d yyyy HH:mm:ss zzz", "MMddyyyy", "ddMMyyyy", "Mddyyyy", "ddMyyyy", "Mdyyyy", "dMyyyy", "yyyy", "Mdyy", "dMyy", "d" ]); // real starting rule: tries selected formats first, // then general purpose rule g.start = function (s) { try { var r = g._formats.call({}, s); if (r[1].length === 0) { return r; } } catch (e) {} return g._start.call({}, s); }; }()); (function () { var $D = Date; /** * @desc Converts the specified string value into its JavaScript Date equivalent using CultureInfo specific format information. * * Example

	///////////
	// Dates //
	///////////

	// 15-Oct-2004
	var d1 = Date.parse("10/15/2004");

	// 15-Oct-2004
	var d1 = Date.parse("15-Oct-2004");

	// 15-Oct-2004
	var d1 = Date.parse("2004.10.15");

	//Fri Oct 15, 2004
	var d1 = Date.parse("Fri Oct 15, 2004");

	///////////
	// Times //
	///////////

	// Today at 10 PM.
	var d1 = Date.parse("10 PM");

	// Today at 10:30 PM.
	var d1 = Date.parse("10:30 P.M.");

	// Today at 6 AM.
	var d1 = Date.parse("06am");

	/////////////////////
	// Dates and Times //
	/////////////////////

	// 8-July-2004 @ 10:30 PM
	var d1 = Date.parse("July 8th, 2004, 10:30 PM");

	// 1-July-2004 @ 10:30 PM
	var d1 = Date.parse("2004-07-01T22:30:00");

	////////////////////
	// Relative Dates //
	////////////////////

	// Returns today's date. The string "today" is culture specific.
	var d1 = Date.parse("today");

	// Returns yesterday's date. The string "yesterday" is culture specific.
	var d1 = Date.parse("yesterday");

	// Returns the date of the next thursday.
	var d1 = Date.parse("Next thursday");

	// Returns the date of the most previous monday.
	var d1 = Date.parse("last monday");

	// Returns today's day + one year.
	var d1 = Date.parse("next year");

	///////////////
	// Date Math //
	///////////////

	// Today + 2 days
	var d1 = Date.parse("t+2");

	// Today + 2 days
	var d1 = Date.parse("today + 2 days");

	// Today + 3 months
	var d1 = Date.parse("t+3m");

	// Today - 1 year
	var d1 = Date.parse("today - 1 year");

	// Today - 1 year
	var d1 = Date.parse("t-1y"); 


	/////////////////////////////
	// Partial Dates and Times //
	/////////////////////////////

	// July 15th of this year.
	var d1 = Date.parse("July 15");

	// 15th day of current day and year.
	var d1 = Date.parse("15");

	// July 1st of current year at 10pm.
	var d1 = Date.parse("7/1 10pm");
	
* * @param {String} The string value to convert into a Date object [Required] * @return {Date} A Date object or null if the string cannot be converted into a Date. */ var parseUtils = { removeOrds: function (s) { ords = s.match(/\b(\d+)(?:st|nd|rd|th)\b/); // find ordinal matches s = ((ords && ords.length === 2) ? s.replace(ords[0], ords[1]) : s); return s; }, grammarParser: function (s) { var r = null; try { r = $D.Grammar.start.call({}, s.replace(/^\s*(\S*(\s+\S+)*)\s*$/, "$1")); } catch (e) { return null; } return ((r[1].length === 0) ? r[0] : null); }, nativeFallback: function(s) { var t; try { // ok we haven't parsed it, last ditch attempt with the built-in parser. t = Date._parse(s); return (t || t === 0) ? new Date(t) : null; } catch (e) { return null; } } }; function parse (s) { var d; if (!s) { return null; } if (s instanceof Date) { return s.clone(); } if (s.length >= 4 && s.charAt(0) !== "0" && s.charAt(0) !== "+"&& s.charAt(0) !== "-") { // ie: 2004 will pass, 0800 won't. // Start with specific formats d = $D.Parsing.ISO.parse(s) || $D.Parsing.Numeric.parse(s); } if (d instanceof Date && !isNaN(d.getTime())) { return d; } else { // find ordinal dates (1st, 3rd, 8th, etc and remove them as they cause parsing issues) s = $D.Parsing.Normalizer.parse(parseUtils.removeOrds(s)); d = parseUtils.grammarParser(s); if (d !== null) { return d; } else { return parseUtils.nativeFallback(s); } } } if (!$D._parse) { $D._parse = $D.parse; } $D.parse = parse; Date.getParseFunction = function (fx) { var fns = Date.Grammar.allformats(fx); return function (s) { var r = null; for (var i = 0; i < fns.length; i++) { try { r = fns[i].call({}, s); } catch (e) { continue; } if (r[1].length === 0) { return r[0]; } } return null; }; }; /** * Converts the specified string value into its JavaScript Date equivalent using the specified format {String} or formats {Array} and the CultureInfo specific format information. * The format of the string value must match one of the supplied formats exactly. * * Example

	// 15-Oct-2004
	var d1 = Date.parseExact("10/15/2004", "M/d/yyyy");

	// 15-Oct-2004
	var d1 = Date.parse("15-Oct-2004", "M-ddd-yyyy");

	// 15-Oct-2004
	var d1 = Date.parse("2004.10.15", "yyyy.MM.dd");

	// Multiple formats
	var d1 = Date.parseExact("10/15/2004", ["M/d/yyyy", "MMMM d, yyyy"]);
	
* * @param {String} The string value to convert into a Date object [Required]. * @param {Object} The expected format {String} or an array of expected formats {Array} of the date string [Required]. * @return {Date} A Date object or null if the string cannot be converted into a Date. */ $D.parseExact = function (s, fx) { return $D.getParseFunction(fx)(s); }; }()); (function () { var $D = Date, $P = $D.prototype, // $C = $D.CultureInfo, // not used atm p = function (s, l) { if (!l) { l = 2; } return ("000" + s).slice(l * -1); }; /** * Converts a PHP format string to Java/.NET format string. * A PHP format string can be used with ._format or .format. * A Java/.NET format string can be used with .toString(). * The .parseExact function will only accept a Java/.NET format string * * Example * var f1 = "%m/%d/%y" * var f2 = Date.normalizeFormat(f1); // "MM/dd/yy" * * new Date().format(f1); // "04/13/08" * new Date()._format(f1); // "04/13/08" * new Date().toString(f2); // "04/13/08" * * var date = Date.parseExact("04/13/08", f2); // Sun Apr 13 2008 * * @param {String} A PHP format string consisting of one or more format spcifiers. * @return {String} The PHP format converted to a Java/.NET format string. */ var normalizerSubstitutions = { "d" : "dd", "%d": "dd", "D" : "ddd", "%a": "ddd", "j" : "dddd", "l" : "dddd", "%A": "dddd", "S" : "S", "F" : "MMMM", "%B": "MMMM", "m" : "MM", "%m": "MM", "M" : "MMM", "%b": "MMM", "%h": "MMM", "n" : "M", "Y" : "yyyy", "%Y": "yyyy", "y" : "yy", "%y": "yy", "g" : "h", "%I": "h", "G" : "H", "h" : "hh", "H" : "HH", "%H": "HH", "i" : "mm", "%M": "mm", "s" : "ss", "%S": "ss", "%r": "hh:mm tt", "%R": "H:mm", "%T": "H:mm:ss", "%X": "t", "%x": "d", "%e": "d", "%D": "MM/dd/yy", "%n": "\\n", "%t": "\\t", "e" : "z", "T" : "z", "%z": "z", "%Z": "z", "Z" : "ZZ", "N" : "u", "w" : "u", "%w": "u", "W" : "W", "%V": "W" }; var normalizer = { substitutes: function (m) { return normalizerSubstitutions[m]; }, interpreted: function (m, x) { var y; switch (m) { case "%u": return x.getDay() + 1; case "z": return x.getOrdinalNumber(); case "%j": return p(x.getOrdinalNumber(), 3); case "%U": var d1 = x.clone().set({month: 0, day: 1}).addDays(-1).moveToDayOfWeek(0), d2 = x.clone().addDays(1).moveToDayOfWeek(0, -1); return (d2 < d1) ? "00" : p((d2.getOrdinalNumber() - d1.getOrdinalNumber()) / 7 + 1); case "%W": return p(x.getWeek()); case "t": return $D.getDaysInMonth(x.getFullYear(), x.getMonth()); case "o": case "%G": return x.setWeek(x.getISOWeek()).toString("yyyy"); case "%g": return x._format("%G").slice(-2); case "a": case "%p": return t("tt").toLowerCase(); case "A": return t("tt").toUpperCase(); case "u": return p(x.getMilliseconds(), 3); case "I": return (x.isDaylightSavingTime()) ? 1 : 0; case "O": return x.getUTCOffset(); case "P": y = x.getUTCOffset(); return y.substring(0, y.length - 2) + ":" + y.substring(y.length - 2); case "B": var now = new Date(); return Math.floor(((now.getHours() * 3600) + (now.getMinutes() * 60) + now.getSeconds() + (now.getTimezoneOffset() + 60) * 60) / 86.4); case "c": return x.toISOString().replace(/\"/g, ""); case "U": return $D.strtotime("now"); case "%c": return t("d") + " " + t("t"); case "%C": return Math.floor(x.getFullYear() / 100 + 1); } }, shouldOverrideDefaults: function (m) { switch (m) { case "%e": return true; default: return false; } }, parse: function (m, context) { var formatString, c = context || new Date(); formatString = normalizer.substitutes(m); if (formatString) { return formatString; } formatString = normalizer.interpreted(m, c); if (formatString) { return formatString; } else { return m; } } }; $D.normalizeFormat = function (format, context) { return format.replace(/(%|\\)?.|%%/g, function(t){ return normalizer.parse(t, context); }); }; /** * Format a local Unix timestamp according to locale settings * * Example: * Date.strftime("%m/%d/%y", new Date()); // "04/13/08" * Date.strftime("c", "2008-04-13T17:52:03Z"); // "04/13/08" * * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @param {Number|String} The number representing the number of seconds that have elapsed since January 1, 1970 (local time). * @return {String} A string representation of the current Date object. */ $D.strftime = function (format, time) { var d = Date.parse(time); return d._format(format); }; /** * Parse any textual datetime description into a Unix timestamp. * A Unix timestamp is the number of seconds that have elapsed since January 1, 1970 (midnight UTC/GMT). * * Example: * Date.strtotime("04/13/08"); // 1208044800 * Date.strtotime("1970-01-01T00:00:00Z"); // 0 * * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @param {Object} A string or date object. * @return {String} A string representation of the current Date object. */ $D.strtotime = function (time) { var d = $D.parse(time); return Math.round($D.UTC(d.getUTCFullYear(), d.getUTCMonth(), d.getUTCDate(), d.getUTCHours(), d.getUTCMinutes(), d.getUTCSeconds(), d.getUTCMilliseconds()) / 1000); }; /** * Converts the value of the current Date object to its equivalent string representation using a PHP/Unix style of date format specifiers. * Format Specifiers * Format Description Example * ------ --------------------------------------------------------------------------- ----------------------- * %a abbreviated weekday name according to the current localed "Mon" through "Sun" * %A full weekday name according to the current localed "Sunday" through "Saturday" * %b abbreviated month name according to the current localed "Jan" through "Dec" * %B full month name according to the current locale "January" through "December" * %c preferred date and time representation for the current locale "4/13/2008 12:33 PM" * %C century number (the year divided by 100 and truncated to an integer) "00" to "99" * %d day of the month as a decimal number "01" to "31" * %D same as %m/%d/%y "04/13/08" * %e day of the month as a decimal number, a single digit is preceded by a space "1" to "31" * %g like %G, but without the century "08" * %G The 4-digit year corresponding to the ISO week number (see %V). "2008" * This has the same format and value as %Y, except that if the ISO week number * belongs to the previous or next year, that year is used instead. * %h same as %b "Jan" through "Dec" * %H hour as a decimal number using a 24-hour clock. "00" to "23" * %I hour as a decimal number using a 12-hour clock. "01" to "12" * %j day of the year as a decimal number. "001" to "366" * %m month as a decimal number. "01" to "12" * %M minute as a decimal number. "00" to "59" * %n newline character "\n" * %p either "am" or "pm" according to the given time value, or the "am" or "pm" * corresponding strings for the current locale. * %r time in a.m. and p.m. notation "8:44 PM" * %R time in 24 hour notation "20:44" * %S second as a decimal number "00" to "59" * %t tab character "\t" * %T current time, equal to %H:%M:%S "12:49:11" * %u weekday as a decimal number ["1", "7"], with "1" representing Monday "1" to "7" * %U week number of the current year as a decimal number, starting with the "0" to ("52" or "53") * first Sunday as the first day of the first week * %V The ISO 8601:1988 week number of the current year as a decimal number, "00" to ("52" or "53") * range 01 to 53, where week 1 is the first week that has at least 4 days * in the current year, and with Monday as the first day of the week. * (Use %G or %g for the year component that corresponds to the week number * for the specified timestamp.) * %W week number of the current year as a decimal number, starting with the "00" to ("52" or "53") * first Monday as the first day of the first week * %w day of the week as a decimal, Sunday being "0" "0" to "6" * %x preferred date representation for the current locale without the time "4/13/2008" * %X preferred time representation for the current locale without the date "12:53:05" * %y year as a decimal number without a century "00" "99" * %Y year as a decimal number including the century "2008" * %Z time zone or name or abbreviation "UTC", "EST", "PST" * %z same as %Z * %% a literal "%" characters "%" * d Day of the month, 2 digits with leading zeros "01" to "31" * D A textual representation of a day, three letters "Mon" through "Sun" * j Day of the month without leading zeros "1" to "31" * l A full textual representation of the day of the week (lowercase "L") "Sunday" through "Saturday" * N ISO-8601 numeric representation of the day of the week (added in PHP 5.1.0) "1" (for Monday) through "7" (for Sunday) * S English ordinal suffix for the day of the month, 2 characters "st", "nd", "rd" or "th". Works well with j * w Numeric representation of the day of the week "0" (for Sunday) through "6" (for Saturday) * z The day of the year (starting from "0") "0" through "365" * W ISO-8601 week number of year, weeks starting on Monday "00" to ("52" or "53") * F A full textual representation of a month, such as January or March "January" through "December" * m Numeric representation of a month, with leading zeros "01" through "12" * M A short textual representation of a month, three letters "Jan" through "Dec" * n Numeric representation of a month, without leading zeros "1" through "12" * t Number of days in the given month "28" through "31" * L Whether it's a leap year "1" if it is a leap year, "0" otherwise * o ISO-8601 year number. This has the same value as Y, except that if the "2008" * ISO week number (W) belongs to the previous or next year, that year * is used instead. * Y A full numeric representation of a year, 4 digits "2008" * y A two digit representation of a year "08" * a Lowercase Ante meridiem and Post meridiem "am" or "pm" * A Uppercase Ante meridiem and Post meridiem "AM" or "PM" * B Swatch Internet time "000" through "999" * g 12-hour format of an hour without leading zeros "1" through "12" * G 24-hour format of an hour without leading zeros "0" through "23" * h 12-hour format of an hour with leading zeros "01" through "12" * H 24-hour format of an hour with leading zeros "00" through "23" * i Minutes with leading zeros "00" to "59" * s Seconds, with leading zeros "00" through "59" * u Milliseconds "54321" * e Timezone identifier "UTC", "EST", "PST" * I Whether or not the date is in daylight saving time (uppercase i) "1" if Daylight Saving Time, "0" otherwise * O Difference to Greenwich time (GMT) in hours "+0200", "-0600" * P Difference to Greenwich time (GMT) with colon between hours and minutes "+02:00", "-06:00" * T Timezone abbreviation "UTC", "EST", "PST" * Z Timezone offset in seconds. The offset for timezones west of UTC is "-43200" through "50400" * always negative, and for those east of UTC is always positive. * c ISO 8601 date "2004-02-12T15:19:21+00:00" * r RFC 2822 formatted date "Thu, 21 Dec 2000 16:01:07 +0200" * U Seconds since the Unix Epoch (January 1 1970 00:00:00 GMT) "0" * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @return {String} A string representation of the current Date object. */ var formatReplace = function (context) { return function (m) { var formatString, override = false; if (m.charAt(0) === "\\" || m.substring(0, 2) === "%%") { return m.replace("\\", "").replace("%%", "%"); } override = normalizer.shouldOverrideDefaults(m); formatString = $D.normalizeFormat(m, context); if (formatString) { return context.toString(formatString, override); } }; }; $P._format = function (format) { var formatter = formatReplace(this); if (!format) { return this._toString(); } else { return format.replace(/(%|\\)?.|%%/g, formatter); } }; if (!$P.format) { $P.format = $P._format; } }()); (function () { "use strict"; var gFn = function (attr) { return function () { return this[attr]; }; }; var sFn = function (attr) { return function (val) { this[attr] = val; return this; }; }; var attrs = ["years", "months", "days", "hours", "minutes", "seconds", "milliseconds"]; var addSetFuncs = function (context, attrs) { for (var i = 0; i < attrs.length ; i++) { var $a = attrs[i], $b = $a.slice(0, 1).toUpperCase() + $a.slice(1); context.prototype[$a] = 0; context.prototype["get" + $b] = gFn($a); context.prototype["set" + $b] = sFn($a); } }; /** * new TimeSpan(milliseconds); * new TimeSpan(days, hours, minutes, seconds); * new TimeSpan(days, hours, minutes, seconds, milliseconds); */ var TimeSpan = function (days, hours, minutes, seconds, milliseconds) { if (arguments.length === 1 && typeof days === "number") { var orient = (days < 0) ? -1 : +1; var millsLeft = Math.abs(days); this.setDays(Math.floor(millsLeft / 86400000) * orient); millsLeft = millsLeft % 86400000; this.setHours(Math.floor(millsLeft / 3600000) * orient); millsLeft = millsLeft % 3600000; this.setMinutes(Math.floor(millsLeft / 60000) * orient); millsLeft = millsLeft % 60000; this.setSeconds(Math.floor(millsLeft / 1000) * orient); millsLeft = millsLeft % 1000; this.setMilliseconds(millsLeft * orient); } else { this.set(days, hours, minutes, seconds, milliseconds); } this.getTotalMilliseconds = function () { return (this.getDays() * 86400000) + (this.getHours() * 3600000) + (this.getMinutes() * 60000) + (this.getSeconds() * 1000); }; this.compareTo = function (time) { var t1 = new Date(1970, 1, 1, this.getHours(), this.getMinutes(), this.getSeconds()), t2; if (time === null) { t2 = new Date(1970, 1, 1, 0, 0, 0); } else { t2 = new Date(1970, 1, 1, time.getHours(), time.getMinutes(), time.getSeconds()); } return (t1 < t2) ? -1 : (t1 > t2) ? 1 : 0; }; this.equals = function (time) { return (this.compareTo(time) === 0); }; this.add = function (time) { return (time === null) ? this : this.addSeconds(time.getTotalMilliseconds() / 1000); }; this.subtract = function (time) { return (time === null) ? this : this.addSeconds(-time.getTotalMilliseconds() / 1000); }; this.addDays = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 86400000)); }; this.addHours = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 3600000)); }; this.addMinutes = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 60000)); }; this.addSeconds = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 1000)); }; this.addMilliseconds = function (n) { return new TimeSpan(this.getTotalMilliseconds() + n); }; this.get12HourHour = function () { return (this.getHours() > 12) ? this.getHours() - 12 : (this.getHours() === 0) ? 12 : this.getHours(); }; this.getDesignator = function () { return (this.getHours() < 12) ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator; }; this.toString = function (format) { this._toString = function () { if (this.getDays() !== null && this.getDays() > 0) { return this.getDays() + "." + this.getHours() + ":" + this.p(this.getMinutes()) + ":" + this.p(this.getSeconds()); } else { return this.getHours() + ":" + this.p(this.getMinutes()) + ":" + this.p(this.getSeconds()); } }; this.p = function (s) { return (s.toString().length < 2) ? "0" + s : s; }; var me = this; return format ? format.replace(/dd?|HH?|hh?|mm?|ss?|tt?/g, function (format) { switch (format) { case "d": return me.getDays(); case "dd": return me.p(me.getDays()); case "H": return me.getHours(); case "HH": return me.p(me.getHours()); case "h": return me.get12HourHour(); case "hh": return me.p(me.get12HourHour()); case "m": return me.getMinutes(); case "mm": return me.p(me.getMinutes()); case "s": return me.getSeconds(); case "ss": return me.p(me.getSeconds()); case "t": return ((me.getHours() < 12) ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator).substring(0, 1); case "tt": return (me.getHours() < 12) ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator; } } ) : this._toString(); }; return this; }; addSetFuncs(TimeSpan, attrs.slice(2)); TimeSpan.prototype.set = function (days, hours, minutes, seconds, milliseconds){ this.setDays(days || this.getDays()); this.setHours(hours || this.getHours()); this.setMinutes(minutes || this.getMinutes()); this.setSeconds(seconds || this.getSeconds()); this.setMilliseconds(milliseconds || this.getMilliseconds()); }; /** * Gets the time of day for this date instances. * @return {TimeSpan} TimeSpan */ Date.prototype.getTimeOfDay = function () { return new TimeSpan(0, this.getHours(), this.getMinutes(), this.getSeconds(), this.getMilliseconds()); }; Date.TimeSpan = TimeSpan; if (typeof window !== "undefined" ) { // keeping API compatible for v1.x window.TimeSpan = TimeSpan; } }()); (function () { "use strict"; var attrs = ["years", "months", "days", "hours", "minutes", "seconds", "milliseconds"]; var gFn = function (attr) { return function () { return this[attr]; }; }; var sFn = function (attr) { return function (val) { this[attr] = val; return this; }; }; var addSetFuncs = function (context, attrs) { for (var i = 0; i < attrs.length ; i++) { var $a = attrs[i], $b = $a.slice(0, 1).toUpperCase() + $a.slice(1); context.prototype[$a] = 0; context.prototype["get" + $b] = gFn($a); context.prototype["set" + $b] = sFn($a); } }; var setMonthsAndYears = function (orient, d1, d2, context) { function inc() { d1.addMonths(-orient); context.months++; if (context.months === 12) { context.years++; context.months = 0; } } if (orient === +1) { while (d1 > d2) { inc(); } } else { while (d1 < d2) { inc(); } } context.months--; context.months *= orient; context.years *= orient; }; var adjustForDST = function(orient, startDate, endDate) { var hasDSTMismatch = (false === (startDate.isDaylightSavingTime() === endDate.isDaylightSavingTime())); if (hasDSTMismatch && orient === 1) { startDate.addHours(-1); } else if (hasDSTMismatch) { startDate.addHours(1); } }; /** * TimePeriod(startDate, endDate); * TimePeriod(years, months, days, hours, minutes, seconds, milliseconds); */ var TimePeriod = function (years, months, days, hours, minutes, seconds, milliseconds) { if (arguments.length === 7) { this.set(years, months, days, hours, minutes, seconds, milliseconds); } else if (arguments.length === 2 && arguments[0] instanceof Date && arguments[1] instanceof Date) { var startDate = arguments[0].clone(); var endDate = arguments[1].clone(); var orient = (startDate > endDate) ? +1 : -1; this.dates = { start: arguments[0].clone(), end: arguments[1].clone() }; setMonthsAndYears(orient, startDate, endDate, this); adjustForDST(orient, startDate, endDate); // // TODO - adjust for DST var diff = endDate - startDate; if (diff !== 0) { var ts = new TimeSpan(diff); this.set(this.years, this.months, ts.getDays(), ts.getHours(), ts.getMinutes(), ts.getSeconds(), ts.getMilliseconds()); } } return this; }; // create all the set functions. addSetFuncs(TimePeriod, attrs); TimePeriod.prototype.set = function (years, months, days, hours, minutes, seconds, milliseconds){ this.setYears(years || this.getYears()); this.setMonths(months || this.getMonths()); this.setDays(days || this.getDays()); this.setHours(hours || this.getHours()); this.setMinutes(minutes || this.getMinutes()); this.setSeconds(seconds || this.getSeconds()); this.setMilliseconds(milliseconds || this.getMilliseconds()); }; Date.TimePeriod = TimePeriod; if (typeof window !== "undefined") { // keeping API compatible for v1.x window.TimePeriod = TimePeriod; } }()); ================================================ FILE: build/date-ky-KG.js ================================================ /** * @overview datejs * @version 1.0.0-rc3 * @author Gregory Wild-Smith * @copyright 2015 Gregory Wild-Smith * @license MIT * @homepage https://github.com/abritinthebay/datejs */ /* * DateJS Culture String File * Country Code: ky-KG * Name: Kyrgyz (Kyrgyzstan) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["ky-KG"] = { "name": "ky-KG", "englishName": "Kyrgyz (Kyrgyzstan)", "nativeName": "Кыргыз (Кыргызстан)", "Sunday": "Жекшемби", "Monday": "Дүйшөмбү", "Tuesday": "Шейшемби", "Wednesday": "Шаршемби", "Thursday": "Бейшемби", "Friday": "Жума", "Saturday": "Ишемби", "Sun": "Жш", "Mon": "Дш", "Tue": "Шш", "Wed": "Шр", "Thu": "Бш", "Fri": "Жм", "Sat": "Иш", "Su": "Жш", "Mo": "Дш", "Tu": "Шш", "We": "Шр", "Th": "Бш", "Fr": "Жм", "Sa": "Иш", "S_Sun_Initial": "Ж", "M_Mon_Initial": "Д", "T_Tue_Initial": "Ш", "W_Wed_Initial": "Ш", "T_Thu_Initial": "Б", "F_Fri_Initial": "Ж", "S_Sat_Initial": "И", "January": "Январь", "February": "Февраль", "March": "Март", "April": "Апрель", "May": "Май", "June": "Июнь", "July": "Июль", "August": "Август", "September": "Сентябрь", "October": "Октябрь", "November": "Ноябрь", "December": "Декабрь", "Jan_Abbr": "Янв", "Feb_Abbr": "Фев", "Mar_Abbr": "Мар", "Apr_Abbr": "Апр", "May_Abbr": "Май", "Jun_Abbr": "Июн", "Jul_Abbr": "Июл", "Aug_Abbr": "Авг", "Sep_Abbr": "Сен", "Oct_Abbr": "Окт", "Nov_Abbr": "Ноя", "Dec_Abbr": "Дек", "AM": "", "PM": "", "firstDayOfWeek": 1, "twoDigitYearMax": 2029, "mdy": "dmy", "M/d/yyyy": "dd.MM.yy", "dddd, MMMM dd, yyyy": "d'-'MMMM yyyy'-ж.'", "h:mm tt": "H:mm", "h:mm:ss tt": "H:mm:ss", "dddd, MMMM dd, yyyy h:mm:ss tt": "d'-'MMMM yyyy'-ж.' H:mm:ss", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "d MMMM", "MMMM, yyyy": "MMMM yyyy'-ж.'", "/jan(uary)?/": "янв(арь)?", "/feb(ruary)?/": "фев(раль)?", "/mar(ch)?/": "мар(т)?", "/apr(il)?/": "апр(ель)?", "/may/": "май", "/jun(e)?/": "июн(ь)?", "/jul(y)?/": "июл(ь)?", "/aug(ust)?/": "авг(уст)?", "/sep(t(ember)?)?/": "сен(тябрь)?", "/oct(ober)?/": "окт(ябрь)?", "/nov(ember)?/": "ноя(брь)?", "/dec(ember)?/": "дек(абрь)?", "/^su(n(day)?)?/": "^жекшемби", "/^mo(n(day)?)?/": "^дүйшөмбү", "/^tu(e(s(day)?)?)?/": "^шейшемби", "/^we(d(nesday)?)?/": "^шаршемби", "/^th(u(r(s(day)?)?)?)?/": "^бейшемби", "/^fr(i(day)?)?/": "^жума", "/^sa(t(urday)?)?/": "^ишемби", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "ky-KG"; /** * @overview datejs * @version 1.0.0-rc3 * @author Gregory Wild-Smith * @copyright 2015 Gregory Wild-Smith * @license MIT * @homepage https://github.com/abritinthebay/datejs */(function () { var $D = Date; var lang = Date.CultureStrings ? Date.CultureStrings.lang : null; var loggedKeys = {}; // for debug purposes. var getText = { getFromKey: function (key, countryCode) { var output; if (Date.CultureStrings && Date.CultureStrings[countryCode] && Date.CultureStrings[countryCode][key]) { output = Date.CultureStrings[countryCode][key]; } else { output = getText.buildFromDefault(key); } if (key.charAt(0) === "/") { // Assume it's a regex output = getText.buildFromRegex(key, countryCode); } return output; }, getFromObjectValues: function (obj, countryCode) { var key, output = {}; for(key in obj) { if (obj.hasOwnProperty(key)) { output[key] = getText.getFromKey(obj[key], countryCode); } } return output; }, getFromObjectKeys: function (obj, countryCode) { var key, output = {}; for(key in obj) { if (obj.hasOwnProperty(key)) { output[getText.getFromKey(key, countryCode)] = obj[key]; } } return output; }, getFromArray: function (arr, countryCode) { var output = []; for (var i=0; i < arr.length; i++){ if (i in arr) { output[i] = getText.getFromKey(arr[i], countryCode); } } return output; }, buildFromDefault: function (key) { var output, length, split, last; switch(key) { case "name": output = "en-US"; break; case "englishName": output = "English (United States)"; break; case "nativeName": output = "English (United States)"; break; case "twoDigitYearMax": output = 2049; break; case "firstDayOfWeek": output = 0; break; default: output = key; split = key.split("_"); length = split.length; if (length > 1 && key.charAt(0) !== "/") { // if the key isn't a regex and it has a split. last = split[(length - 1)].toLowerCase(); if (last === "initial" || last === "abbr") { output = split[0]; } } break; } return output; }, buildFromRegex: function (key, countryCode) { var output; if (Date.CultureStrings && Date.CultureStrings[countryCode] && Date.CultureStrings[countryCode][key]) { output = new RegExp(Date.CultureStrings[countryCode][key], "i"); } else { output = new RegExp(key.replace(new RegExp("/", "g"),""), "i"); } return output; } }; var shallowMerge = function (obj1, obj2) { for (var attrname in obj2) { if (obj2.hasOwnProperty(attrname)) { obj1[attrname] = obj2[attrname]; } } }; var __ = function (key, language) { var countryCode = (language) ? language : lang; loggedKeys[key] = key; if (typeof key === "object") { if (key instanceof Array) { return getText.getFromArray(key, countryCode); } else { return getText.getFromObjectKeys(key, countryCode); } } else { return getText.getFromKey(key, countryCode); } }; var loadI18nScript = function (code) { // paatterned after jQuery's getScript. var url = Date.Config.i18n + code + ".js"; var head = document.getElementsByTagName("head")[0] || document.documentElement; var script = document.createElement("script"); script.src = url; var completed = false; var events = { done: function (){} // placeholder function }; // Attach handlers for all browsers script.onload = script.onreadystatechange = function() { if ( !completed && (!this.readyState || this.readyState === "loaded" || this.readyState === "complete") ) { events.done(); head.removeChild(script); } }; setTimeout(function() { head.insertBefore(script, head.firstChild); }, 0); // allows return to execute first return { done: function (cb) { events.done = function() { if (cb) { setTimeout(cb,0); } }; } }; }; var buildInfo = { buildFromMethodHash: function (obj) { var key; for(key in obj) { if (obj.hasOwnProperty(key)) { obj[key] = buildInfo[obj[key]](); } } return obj; }, timeZoneDST: function () { var DST = { "CHADT": "+1345", "NZDT": "+1300", "AEDT": "+1100", "ACDT": "+1030", "AZST": "+0500", "IRDT": "+0430", "EEST": "+0300", "CEST": "+0200", "BST": "+0100", "PMDT": "-0200", "ADT": "-0300", "NDT": "-0230", "EDT": "-0400", "CDT": "-0500", "MDT": "-0600", "PDT": "-0700", "AKDT": "-0800", "HADT": "-0900" }; return __(DST); }, timeZoneStandard: function () { var standard = { "LINT": "+1400", "TOT": "+1300", "CHAST": "+1245", "NZST": "+1200", "NFT": "+1130", "SBT": "+1100", "AEST": "+1000", "ACST": "+0930", "JST": "+0900", "CWST": "+0845", "CT": "+0800", "ICT": "+0700", "MMT": "+0630", "BST": "+0600", "NPT": "+0545", "IST": "+0530", "PKT": "+0500", "AFT": "+0430", "MSK": "+0400", "IRST": "+0330", "FET": "+0300", "EET": "+0200", "CET": "+0100", "GMT": "+0000", "UTC": "+0000", "CVT": "-0100", "GST": "-0200", "BRT": "-0300", "NST": "-0330", "AST": "-0400", "EST": "-0500", "CST": "-0600", "MST": "-0700", "PST": "-0800", "AKST": "-0900", "MIT": "-0930", "HST": "-1000", "SST": "-1100", "BIT": "-1200" }; return __(standard); }, timeZones: function (data) { var zone; data.timezones = []; for (zone in data.abbreviatedTimeZoneStandard) { if (data.abbreviatedTimeZoneStandard.hasOwnProperty(zone)) { data.timezones.push({ name: zone, offset: data.abbreviatedTimeZoneStandard[zone]}); } } for (zone in data.abbreviatedTimeZoneDST) { if (data.abbreviatedTimeZoneDST.hasOwnProperty(zone)) { data.timezones.push({ name: zone, offset: data.abbreviatedTimeZoneDST[zone], dst: true}); } } return data.timezones; }, days: function () { return __(["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"]); }, dayAbbr: function () { return __(["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"]); }, dayShortNames: function () { return __(["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"]); }, dayFirstLetters: function () { return __(["S_Sun_Initial", "M_Mon_Initial", "T_Tues_Initial", "W_Wed_Initial", "T_Thu_Initial", "F_Fri_Initial", "S_Sat_Initial"]); }, months: function () { return __(["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"]); }, monthAbbr: function () { return __(["Jan_Abbr", "Feb_Abbr", "Mar_Abbr", "Apr_Abbr", "May_Abbr", "Jun_Abbr", "Jul_Abbr", "Aug_Abbr", "Sep_Abbr", "Oct_Abbr", "Nov_Abbr", "Dec_Abbr"]); }, formatPatterns: function () { return getText.getFromObjectValues({ shortDate: "M/d/yyyy", longDate: "dddd, MMMM dd, yyyy", shortTime: "h:mm tt", longTime: "h:mm:ss tt", fullDateTime: "dddd, MMMM dd, yyyy h:mm:ss tt", sortableDateTime: "yyyy-MM-ddTHH:mm:ss", universalSortableDateTime: "yyyy-MM-dd HH:mm:ssZ", rfc1123: "ddd, dd MMM yyyy HH:mm:ss", monthDay: "MMMM dd", yearMonth: "MMMM, yyyy" }, Date.i18n.currentLanguage()); }, regex: function () { return getText.getFromObjectValues({ inTheMorning: "/( in the )(morn(ing)?)\\b/", thisMorning: "/(this )(morn(ing)?)\\b/", amThisMorning: "/(\b\\d(am)? )(this )(morn(ing)?)/", inTheEvening: "/( in the )(even(ing)?)\\b/", thisEvening: "/(this )(even(ing)?)\\b/", pmThisEvening: "/(\b\\d(pm)? )(this )(even(ing)?)/", jan: "/jan(uary)?/", feb: "/feb(ruary)?/", mar: "/mar(ch)?/", apr: "/apr(il)?/", may: "/may/", jun: "/jun(e)?/", jul: "/jul(y)?/", aug: "/aug(ust)?/", sep: "/sep(t(ember)?)?/", oct: "/oct(ober)?/", nov: "/nov(ember)?/", dec: "/dec(ember)?/", sun: "/^su(n(day)?)?/", mon: "/^mo(n(day)?)?/", tue: "/^tu(e(s(day)?)?)?/", wed: "/^we(d(nesday)?)?/", thu: "/^th(u(r(s(day)?)?)?)?/", fri: "/fr(i(day)?)?/", sat: "/^sa(t(urday)?)?/", future: "/^next/", past: "/^last|past|prev(ious)?/", add: "/^(\\+|aft(er)?|from|hence)/", subtract: "/^(\\-|bef(ore)?|ago)/", yesterday: "/^yes(terday)?/", today: "/^t(od(ay)?)?/", tomorrow: "/^tom(orrow)?/", now: "/^n(ow)?/", millisecond: "/^ms|milli(second)?s?/", second: "/^sec(ond)?s?/", minute: "/^mn|min(ute)?s?/", hour: "/^h(our)?s?/", week: "/^w(eek)?s?/", month: "/^m(onth)?s?/", day: "/^d(ay)?s?/", year: "/^y(ear)?s?/", shortMeridian: "/^(a|p)/", longMeridian: "/^(a\\.?m?\\.?|p\\.?m?\\.?)/", timezone: "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/", ordinalSuffix: "/^\\s*(st|nd|rd|th)/", timeContext: "/^\\s*(\\:|a(?!u|p)|p)/" }, Date.i18n.currentLanguage()); } }; var CultureInfo = function () { var info = getText.getFromObjectValues({ name: "name", englishName: "englishName", nativeName: "nativeName", amDesignator: "AM", pmDesignator: "PM", firstDayOfWeek: "firstDayOfWeek", twoDigitYearMax: "twoDigitYearMax", dateElementOrder: "mdy" }, Date.i18n.currentLanguage()); var constructedInfo = buildInfo.buildFromMethodHash({ dayNames: "days", abbreviatedDayNames: "dayAbbr", shortestDayNames: "dayShortNames", firstLetterDayNames: "dayFirstLetters", monthNames: "months", abbreviatedMonthNames: "monthAbbr", formatPatterns: "formatPatterns", regexPatterns: "regex", abbreviatedTimeZoneDST: "timeZoneDST", abbreviatedTimeZoneStandard: "timeZoneStandard" }); shallowMerge(info, constructedInfo); buildInfo.timeZones(info); return info; }; $D.i18n = { __: function (key, lang) { return __(key, lang); }, currentLanguage: function () { return lang || "en-US"; }, setLanguage: function (code, force, cb) { var async = false; if (force || code === "en-US" || (!!Date.CultureStrings && !!Date.CultureStrings[code])) { lang = code; Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings.lang = code; Date.CultureInfo = new CultureInfo(); } else { if (!(!!Date.CultureStrings && !!Date.CultureStrings[code])) { if (typeof exports !== "undefined" && this.exports !== exports) { // we're in a Node enviroment, load it using require try { require("../i18n/" + code + ".js"); lang = code; Date.CultureStrings.lang = code; Date.CultureInfo = new CultureInfo(); } catch (e) { // var str = "The language for '" + code + "' could not be loaded by Node. It likely does not exist."; throw new Error("The DateJS IETF language tag '" + code + "' could not be loaded by Node. It likely does not exist."); } } else if (Date.Config && Date.Config.i18n) { // we know the location of the files, so lets load them async = true; loadI18nScript(code).done(function(){ lang = code; Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings.lang = code; Date.CultureInfo = new CultureInfo(); $D.Parsing.Normalizer.buildReplaceData(); // because this is async if ($D.Grammar) { $D.Grammar.buildGrammarFormats(); // so we can parse those strings... } if (cb) { setTimeout(cb,0); } }); } else { Date.console.error("The DateJS IETF language tag '" + code + "' is not available and has not been loaded."); return false; } } } $D.Parsing.Normalizer.buildReplaceData(); // rebuild normalizer strings if ($D.Grammar) { $D.Grammar.buildGrammarFormats(); // so we can parse those strings... } if (!async && cb) { setTimeout(cb,0); } }, getLoggedKeys: function () { return loggedKeys; }, updateCultureInfo: function () { Date.CultureInfo = new CultureInfo(); } }; $D.i18n.updateCultureInfo(); // run automatically }()); (function () { var $D = Date, $P = $D.prototype, p = function (s, l) { if (!l) { l = 2; } return ("000" + s).slice(l * -1); }; if (typeof window !== "undefined" && typeof window.console !== "undefined" && typeof window.console.log !== "undefined") { $D.console = console; // used only to raise non-critical errors if available } else { // set mock so we don't give errors. $D.console = { log: function(){}, error: function(){} }; } $D.Config = $D.Config || {}; $D.initOverloads = function() { /** * Overload of Date.now. Allows an alternate call for Date.now where it returns the * current Date as an object rather than just milliseconds since the Unix Epoch. * * Also provides an implementation of now() for browsers (IE<9) that don't have it. * * Backwards compatible so with work with either: * Date.now() [returns ms] * or * Date.now(true) [returns Date] */ if (!$D.now) { $D._now = function now() { return new Date().getTime(); }; } else if (!$D._now) { $D._now = $D.now; } $D.now = function (returnObj) { if (returnObj) { return $D.present(); } else { return $D._now(); } }; if ( !$P.toISOString ) { $P.toISOString = function() { return this.getUTCFullYear() + "-" + p(this.getUTCMonth() + 1) + "-" + p(this.getUTCDate()) + "T" + p(this.getUTCHours()) + ":" + p(this.getUTCMinutes()) + ":" + p(this.getUTCSeconds()) + "." + String( (this.getUTCMilliseconds()/1000).toFixed(3)).slice(2, 5) + "Z"; }; } // private if ( $P._toString === undefined ){ $P._toString = $P.toString; } }; $D.initOverloads(); /** * Gets a date that is set to the current date. The time is set to the start of the day (00:00 or 12:00 AM). * @return {Date} The current date. */ $D.today = function () { return new Date().clearTime(); }; /** * Gets a date that is set to the current date and time (same as new Date, but chainable) * @return {Date} The current date. */ $D.present = function () { return new Date(); }; /** * Compares the first date to the second date and returns an number indication of their relative values. * @param {Date} First Date object to compare [Required]. * @param {Date} Second Date object to compare to [Required]. * @return {Number} -1 = date1 is lessthan date2. 0 = values are equal. 1 = date1 is greaterthan date2. */ $D.compare = function (date1, date2) { if (isNaN(date1) || isNaN(date2)) { throw new Error(date1 + " - " + date2); } else if (date1 instanceof Date && date2 instanceof Date) { return (date1 < date2) ? -1 : (date1 > date2) ? 1 : 0; } else { throw new TypeError(date1 + " - " + date2); } }; /** * Compares the first Date object to the second Date object and returns true if they are equal. * @param {Date} First Date object to compare [Required] * @param {Date} Second Date object to compare to [Required] * @return {Boolean} true if dates are equal. false if they are not equal. */ $D.equals = function (date1, date2) { return (date1.compareTo(date2) === 0); }; /** * Gets the language appropriate day name when given the day number(0-6) * eg - 0 == Sunday * @return {String} The day name */ $D.getDayName = function (n) { return Date.CultureInfo.dayNames[n]; }; /** * Gets the day number (0-6) if given a CultureInfo specific string which is a valid dayName, abbreviatedDayName or shortestDayName (two char). * @param {String} The name of the day (eg. "Monday, "Mon", "tuesday", "tue", "We", "we"). * @return {Number} The day number */ $D.getDayNumberFromName = function (name) { var n = Date.CultureInfo.dayNames, m = Date.CultureInfo.abbreviatedDayNames, o = Date.CultureInfo.shortestDayNames, s = name.toLowerCase(); for (var i = 0; i < n.length; i++) { if (n[i].toLowerCase() === s || m[i].toLowerCase() === s || o[i].toLowerCase() === s) { return i; } } return -1; }; /** * Gets the month number (0-11) if given a Culture Info specific string which is a valid monthName or abbreviatedMonthName. * @param {String} The name of the month (eg. "February, "Feb", "october", "oct"). * @return {Number} The day number */ $D.getMonthNumberFromName = function (name) { var n = Date.CultureInfo.monthNames, m = Date.CultureInfo.abbreviatedMonthNames, s = name.toLowerCase(); for (var i = 0; i < n.length; i++) { if (n[i].toLowerCase() === s || m[i].toLowerCase() === s) { return i; } } return -1; }; /** * Gets the language appropriate month name when given the month number(0-11) * eg - 0 == January * @return {String} The month name */ $D.getMonthName = function (n) { return Date.CultureInfo.monthNames[n]; }; /** * Determines if the current date instance is within a LeapYear. * @param {Number} The year. * @return {Boolean} true if date is within a LeapYear, otherwise false. */ $D.isLeapYear = function (year) { return ((year % 4 === 0 && year % 100 !== 0) || year % 400 === 0); }; /** * Gets the number of days in the month, given a year and month value. Automatically corrects for LeapYear. * @param {Number} The year. * @param {Number} The month (0-11). * @return {Number} The number of days in the month. */ $D.getDaysInMonth = function (year, month) { if (!month && $D.validateMonth(year)) { month = year; year = Date.today().getFullYear(); } return [31, ($D.isLeapYear(year) ? 29 : 28), 31, 30, 31, 30, 31, 31, 30, 31, 30, 31][month]; }; $P.getDaysInMonth = function () { return $D.getDaysInMonth(this.getFullYear(), this.getMonth()); }; $D.getTimezoneAbbreviation = function (offset, dst) { var p, n = (dst || false) ? Date.CultureInfo.abbreviatedTimeZoneDST : Date.CultureInfo.abbreviatedTimeZoneStandard; for (p in n) { if (n.hasOwnProperty(p)) { if (n[p] === offset) { return p; } } } return null; }; $D.getTimezoneOffset = function (name, dst) { var i, a =[], z = Date.CultureInfo.timezones; if (!name) { name = (new Date()).getTimezone();} for (i = 0; i < z.length; i++) { if (z[i].name === name.toUpperCase()) { a.push(i); } } if (!z[a[0]]) { return null; } if (a.length === 1 || !dst) { return z[a[0]].offset; } else { for (i=0; i < a.length; i++) { if (z[a[i]].dst) { return z[a[i]].offset; } } } }; $D.getQuarter = function (d) { d = d || new Date(); // If no date supplied, use today var q = [1,2,3,4]; return q[Math.floor(d.getMonth() / 3)]; // ~~~ is a bitwise op. Faster than Math.floor }; $D.getDaysLeftInQuarter = function (d) { d = d || new Date(); var qEnd = new Date(d); qEnd.setMonth(qEnd.getMonth() + 3 - qEnd.getMonth() % 3, 0); return Math.floor((qEnd - d) / 8.64e7); }; // private var validate = function (n, min, max, name) { name = name ? name : "Object"; if (typeof n === "undefined") { return false; } else if (typeof n !== "number") { throw new TypeError(n + " is not a Number."); } else if (n < min || n > max) { // As failing validation is *not* an exceptional circumstance // lets not throw a RangeError Exception here. // It's semantically correct but it's not sensible. return false; } return true; }; /** * Validates the number is within an acceptable range for milliseconds [0-999]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateMillisecond = function (value) { return validate(value, 0, 999, "millisecond"); }; /** * Validates the number is within an acceptable range for seconds [0-59]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateSecond = function (value) { return validate(value, 0, 59, "second"); }; /** * Validates the number is within an acceptable range for minutes [0-59]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateMinute = function (value) { return validate(value, 0, 59, "minute"); }; /** * Validates the number is within an acceptable range for hours [0-23]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateHour = function (value) { return validate(value, 0, 23, "hour"); }; /** * Validates the number is within an acceptable range for the days in a month [0-MaxDaysInMonth]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateDay = function (value, year, month) { if (year === undefined || year === null || month === undefined || month === null) { return false;} return validate(value, 1, $D.getDaysInMonth(year, month), "day"); }; /** * Validates the number is within an acceptable range for months [0-11]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateWeek = function (value) { return validate(value, 0, 53, "week"); }; /** * Validates the number is within an acceptable range for months [0-11]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateMonth = function (value) { return validate(value, 0, 11, "month"); }; /** * Validates the number is within an acceptable range for years. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateYear = function (value) { /** * Per ECMAScript spec the range of times supported by Date objects is * exactly -100,000,000 days to +100,000,000 days measured relative to * midnight at the beginning of 01 January, 1970 UTC. * This gives a range of 8,640,000,000,000,000 milliseconds to either * side of 01 January, 1970 UTC. * * Earliest possible date: Tue, 20 Apr 271,822 B.C. 00:00:00 UTC * Latest possible date: Sat, 13 Sep 275,760 00:00:00 UTC */ return validate(value, -271822, 275760, "year"); }; $D.validateTimezone = function(value) { var timezones = {"ACDT":1,"ACST":1,"ACT":1,"ADT":1,"AEDT":1,"AEST":1,"AFT":1,"AKDT":1,"AKST":1,"AMST":1,"AMT":1,"ART":1,"AST":1,"AWDT":1,"AWST":1,"AZOST":1,"AZT":1,"BDT":1,"BIOT":1,"BIT":1,"BOT":1,"BRT":1,"BST":1,"BTT":1,"CAT":1,"CCT":1,"CDT":1,"CEDT":1,"CEST":1,"CET":1,"CHADT":1,"CHAST":1,"CHOT":1,"ChST":1,"CHUT":1,"CIST":1,"CIT":1,"CKT":1,"CLST":1,"CLT":1,"COST":1,"COT":1,"CST":1,"CT":1,"CVT":1,"CWST":1,"CXT":1,"DAVT":1,"DDUT":1,"DFT":1,"EASST":1,"EAST":1,"EAT":1,"ECT":1,"EDT":1,"EEDT":1,"EEST":1,"EET":1,"EGST":1,"EGT":1,"EIT":1,"EST":1,"FET":1,"FJT":1,"FKST":1,"FKT":1,"FNT":1,"GALT":1,"GAMT":1,"GET":1,"GFT":1,"GILT":1,"GIT":1,"GMT":1,"GST":1,"GYT":1,"HADT":1,"HAEC":1,"HAST":1,"HKT":1,"HMT":1,"HOVT":1,"HST":1,"ICT":1,"IDT":1,"IOT":1,"IRDT":1,"IRKT":1,"IRST":1,"IST":1,"JST":1,"KGT":1,"KOST":1,"KRAT":1,"KST":1,"LHST":1,"LINT":1,"MAGT":1,"MART":1,"MAWT":1,"MDT":1,"MET":1,"MEST":1,"MHT":1,"MIST":1,"MIT":1,"MMT":1,"MSK":1,"MST":1,"MUT":1,"MVT":1,"MYT":1,"NCT":1,"NDT":1,"NFT":1,"NPT":1,"NST":1,"NT":1,"NUT":1,"NZDT":1,"NZST":1,"OMST":1,"ORAT":1,"PDT":1,"PET":1,"PETT":1,"PGT":1,"PHOT":1,"PHT":1,"PKT":1,"PMDT":1,"PMST":1,"PONT":1,"PST":1,"PYST":1,"PYT":1,"RET":1,"ROTT":1,"SAKT":1,"SAMT":1,"SAST":1,"SBT":1,"SCT":1,"SGT":1,"SLST":1,"SRT":1,"SST":1,"SYOT":1,"TAHT":1,"THA":1,"TFT":1,"TJT":1,"TKT":1,"TLT":1,"TMT":1,"TOT":1,"TVT":1,"UCT":1,"ULAT":1,"UTC":1,"UYST":1,"UYT":1,"UZT":1,"VET":1,"VLAT":1,"VOLT":1,"VOST":1,"VUT":1,"WAKT":1,"WAST":1,"WAT":1,"WEDT":1,"WEST":1,"WET":1,"WST":1,"YAKT":1,"YEKT":1,"Z":1}; return (timezones[value] === 1); }; $D.validateTimezoneOffset= function(value) { // timezones go from +14hrs to -12hrs, the +X hours are negative offsets. return (value > -841 && value < 721); }; }()); (function () { var $D = Date, $P = $D.prototype, p = function (s, l) { if (!l) { l = 2; } return ("000" + s).slice(l * -1); }; var validateConfigObject = function (obj) { var result = {}, self = this, prop, testFunc; testFunc = function (prop, func, value) { if (prop === "day") { var month = (obj.month !== undefined) ? obj.month : self.getMonth(); var year = (obj.year !== undefined) ? obj.year : self.getFullYear(); return $D[func](value, year, month); } else { return $D[func](value); } }; for (prop in obj) { if (Object.prototype.hasOwnProperty.call(obj, prop)) { var func = "validate" + prop.charAt(0).toUpperCase() + prop.slice(1); if ($D[func] && obj[prop] !== null && testFunc(prop, func, obj[prop])) { result[prop] = obj[prop]; } } } return result; }; /** * Resets the time of this Date object to 12:00 AM (00:00), which is the start of the day. * @param {Boolean} .clone() this date instance before clearing Time * @return {Date} this */ $P.clearTime = function () { this.setHours(0); this.setMinutes(0); this.setSeconds(0); this.setMilliseconds(0); return this; }; /** * Resets the time of this Date object to the current time ('now'). * @return {Date} this */ $P.setTimeToNow = function () { var n = new Date(); this.setHours(n.getHours()); this.setMinutes(n.getMinutes()); this.setSeconds(n.getSeconds()); this.setMilliseconds(n.getMilliseconds()); return this; }; /** * Returns a new Date object that is an exact date and time copy of the original instance. * @return {Date} A new Date instance */ $P.clone = function () { return new Date(this.getTime()); }; /** * Compares this instance to a Date object and returns an number indication of their relative values. * @param {Date} Date object to compare [Required] * @return {Number} -1 = this is lessthan date. 0 = values are equal. 1 = this is greaterthan date. */ $P.compareTo = function (date) { return Date.compare(this, date); }; /** * Compares this instance to another Date object and returns true if they are equal. * @param {Date} Date object to compare. If no date to compare, new Date() [now] is used. * @return {Boolean} true if dates are equal. false if they are not equal. */ $P.equals = function (date) { return Date.equals(this, (date !== undefined ? date : new Date())); }; /** * Determines if this instance is between a range of two dates or equal to either the start or end dates. * @param {Date} Start of range [Required] * @param {Date} End of range [Required] * @return {Boolean} true is this is between or equal to the start and end dates, else false */ $P.between = function (start, end) { return this.getTime() >= start.getTime() && this.getTime() <= end.getTime(); }; /** * Determines if this date occurs after the date to compare to. * @param {Date} Date object to compare. If no date to compare, new Date() ("now") is used. * @return {Boolean} true if this date instance is greater than the date to compare to (or "now"), otherwise false. */ $P.isAfter = function (date) { return this.compareTo(date || new Date()) === 1; }; /** * Determines if this date occurs before the date to compare to. * @param {Date} Date object to compare. If no date to compare, new Date() ("now") is used. * @return {Boolean} true if this date instance is less than the date to compare to (or "now"). */ $P.isBefore = function (date) { return (this.compareTo(date || new Date()) === -1); }; /** * Determines if the current Date instance occurs today. * @return {Boolean} true if this date instance is 'today', otherwise false. */ /** * Determines if the current Date instance occurs on the same Date as the supplied 'date'. * If no 'date' to compare to is provided, the current Date instance is compared to 'today'. * @param {date} Date object to compare. If no date to compare, the current Date ("now") is used. * @return {Boolean} true if this Date instance occurs on the same Day as the supplied 'date'. */ $P.isToday = $P.isSameDay = function (date) { return this.clone().clearTime().equals((date || new Date()).clone().clearTime()); }; /** * Adds the specified number of milliseconds to this instance. * @param {Number} The number of milliseconds to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addMilliseconds = function (value) { if (!value) { return this; } this.setTime(this.getTime() + value * 1); return this; }; /** * Adds the specified number of seconds to this instance. * @param {Number} The number of seconds to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addSeconds = function (value) { if (!value) { return this; } return this.addMilliseconds(value * 1000); }; /** * Adds the specified number of seconds to this instance. * @param {Number} The number of seconds to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addMinutes = function (value) { if (!value) { return this; } return this.addMilliseconds(value * 60000); // 60*1000 }; /** * Adds the specified number of hours to this instance. * @param {Number} The number of hours to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addHours = function (value) { if (!value) { return this; } return this.addMilliseconds(value * 3600000); // 60*60*1000 }; /** * Adds the specified number of days to this instance. * @param {Number} The number of days to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addDays = function (value) { if (!value) { return this; } this.setDate(this.getDate() + value * 1); return this; }; /** * Adds the specified number of weekdays (ie - not sat or sun) to this instance. * @param {Number} The number of days to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addWeekdays = function (value) { if (!value) { return this; } var day = this.getDay(); var weeks = (Math.ceil(Math.abs(value)/7)); if (day === 0 || day === 6) { if (value > 0) { this.next().monday(); this.addDays(-1); day = this.getDay(); } } if (value < 0) { while (value < 0) { this.addDays(-1); day = this.getDay(); if (day !== 0 && day !== 6) { value++; } } return this; } else if (value > 5 || (6-day) <= value) { value = value + (weeks * 2); } return this.addDays(value); }; /** * Adds the specified number of weeks to this instance. * @param {Number} The number of weeks to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addWeeks = function (value) { if (!value) { return this; } return this.addDays(value * 7); }; /** * Adds the specified number of months to this instance. * @param {Number} The number of months to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addMonths = function (value) { if (!value) { return this; } var n = this.getDate(); this.setDate(1); this.setMonth(this.getMonth() + value * 1); this.setDate(Math.min(n, $D.getDaysInMonth(this.getFullYear(), this.getMonth()))); return this; }; $P.addQuarters = function (value) { if (!value) { return this; } // note this will take you to the same point in the quarter as you are now. // i.e. - if you are 15 days into the quarter you'll be 15 days into the resulting one. // bonus: this allows adding fractional quarters return this.addMonths(value * 3); }; /** * Adds the specified number of years to this instance. * @param {Number} The number of years to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addYears = function (value) { if (!value) { return this; } return this.addMonths(value * 12); }; /** * Adds (or subtracts) to the value of the years, months, weeks, days, hours, minutes, seconds, milliseconds of the date instance using given configuration object. Positive and Negative values allowed. * Example

	Date.today().add( { days: 1, months: 1 } )

	new Date().add( { years: -1 } )
	
* @param {Object} Configuration object containing attributes (months, days, etc.) * @return {Date} this */ $P.add = function (config) { if (typeof config === "number") { this._orient = config; return this; } var x = config; if (x.day) { // If we should be a different date than today (eg: for 'tomorrow -1d', etc). // Should only effect parsing, not direct usage (eg, Finish and FinishExact) if ((x.day - this.getDate()) !== 0) { this.setDate(x.day); } } if (x.milliseconds) { this.addMilliseconds(x.milliseconds); } if (x.seconds) { this.addSeconds(x.seconds); } if (x.minutes) { this.addMinutes(x.minutes); } if (x.hours) { this.addHours(x.hours); } if (x.weeks) { this.addWeeks(x.weeks); } if (x.months) { this.addMonths(x.months); } if (x.years) { this.addYears(x.years); } if (x.days) { this.addDays(x.days); } return this; }; /** * Get the week number. Week one (1) is the week which contains the first Thursday of the year. Monday is considered the first day of the week. * The .getWeek() function does NOT convert the date to UTC. The local datetime is used. * Please use .getISOWeek() to get the week of the UTC converted date. * @return {Number} 1 to 53 */ $P.getWeek = function (utc) { // Create a copy of this date object var self, target = new Date(this.valueOf()); if (utc) { target.addMinutes(target.getTimezoneOffset()); self = target.clone(); } else { self = this; } // ISO week date weeks start on monday // so correct the day number var dayNr = (self.getDay() + 6) % 7; // ISO 8601 states that week 1 is the week // with the first thursday of that year. // Set the target date to the thursday in the target week target.setDate(target.getDate() - dayNr + 3); // Store the millisecond value of the target date var firstThursday = target.valueOf(); // Set the target to the first thursday of the year // First set the target to january first target.setMonth(0, 1); // Not a thursday? Correct the date to the next thursday if (target.getDay() !== 4) { target.setMonth(0, 1 + ((4 - target.getDay()) + 7) % 7); } // The weeknumber is the number of weeks between the // first thursday of the year and the thursday in the target week return 1 + Math.ceil((firstThursday - target) / 604800000); // 604800000 = 7 * 24 * 3600 * 1000 }; /** * Get the ISO 8601 week number. Week one ("01") is the week which contains the first Thursday of the year. Monday is considered the first day of the week. * The .getISOWeek() function does convert the date to it's UTC value. Please use .getWeek() to get the week of the local date. * @return {String} "01" to "53" */ $P.getISOWeek = function () { return p(this.getWeek(true)); }; /** * Moves the date to Monday of the week set. Week one (1) is the week which contains the first Thursday of the year. * @param {Number} A Number (1 to 53) that represents the week of the year. * @return {Date} this */ $P.setWeek = function (n) { if ((n - this.getWeek()) === 0) { if (this.getDay() !== 1) { return this.moveToDayOfWeek(1, (this.getDay() > 1 ? -1 : 1)); } else { return this; } } else { return this.moveToDayOfWeek(1, (this.getDay() > 1 ? -1 : 1)).addWeeks(n - this.getWeek()); } }; $P.setQuarter = function (qtr) { var month = Math.abs(((qtr-1) * 3) + 1); return this.setMonth(month, 1); }; $P.getQuarter = function () { return Date.getQuarter(this); }; $P.getDaysLeftInQuarter = function () { return Date.getDaysLeftInQuarter(this); }; /** * Moves the date to the next n'th occurrence of the dayOfWeek starting from the beginning of the month. The number (-1) is a magic number and will return the last occurrence of the dayOfWeek in the month. * @param {Number} The dayOfWeek to move to * @param {Number} The n'th occurrence to move to. Use (-1) to return the last occurrence in the month * @return {Date} this */ $P.moveToNthOccurrence = function (dayOfWeek, occurrence) { if (dayOfWeek === "Weekday") { if (occurrence > 0) { this.moveToFirstDayOfMonth(); if (this.is().weekday()) { occurrence -= 1; } } else if (occurrence < 0) { this.moveToLastDayOfMonth(); if (this.is().weekday()) { occurrence += 1; } } else { return this; } return this.addWeekdays(occurrence); } var shift = 0; if (occurrence > 0) { shift = occurrence - 1; } else if (occurrence === -1) { this.moveToLastDayOfMonth(); if (this.getDay() !== dayOfWeek) { this.moveToDayOfWeek(dayOfWeek, -1); } return this; } return this.moveToFirstDayOfMonth().addDays(-1).moveToDayOfWeek(dayOfWeek, +1).addWeeks(shift); }; var moveToN = function (getFunc, addFunc, nVal) { return function (value, orient) { var diff = (value - this[getFunc]() + nVal * (orient || +1)) % nVal; return this[addFunc]((diff === 0) ? diff += nVal * (orient || +1) : diff); }; }; /** * Move to the next or last dayOfWeek based on the orient value. * @param {Number} The dayOfWeek to move to * @param {Number} Forward (+1) or Back (-1). Defaults to +1. [Optional] * @return {Date} this */ $P.moveToDayOfWeek = moveToN("getDay", "addDays", 7); /** * Move to the next or last month based on the orient value. * @param {Number} The month to move to. 0 = January, 11 = December * @param {Number} Forward (+1) or Back (-1). Defaults to +1. [Optional] * @return {Date} this */ $P.moveToMonth = moveToN("getMonth", "addMonths", 12); /** * Get the Ordinate of the current day ("th", "st", "rd"). * @return {String} */ $P.getOrdinate = function () { var num = this.getDate(); return ord(num); }; /** * Get the Ordinal day (numeric day number) of the year, adjusted for leap year. * @return {Number} 1 through 365 (366 in leap years) */ $P.getOrdinalNumber = function () { return Math.ceil((this.clone().clearTime() - new Date(this.getFullYear(), 0, 1)) / 86400000) + 1; }; /** * Get the time zone abbreviation of the current date. * @return {String} The abbreviated time zone name (e.g. "EST") */ $P.getTimezone = function () { return $D.getTimezoneAbbreviation(this.getUTCOffset(), this.isDaylightSavingTime()); }; $P.setTimezoneOffset = function (offset) { var here = this.getTimezoneOffset(), there = Number(offset) * -6 / 10; return (there || there === 0) ? this.addMinutes(there - here) : this; }; $P.setTimezone = function (offset) { return this.setTimezoneOffset($D.getTimezoneOffset(offset)); }; /** * Indicates whether Daylight Saving Time is observed in the current time zone. * @return {Boolean} true|false */ $P.hasDaylightSavingTime = function () { return (Date.today().set({month: 0, day: 1}).getTimezoneOffset() !== Date.today().set({month: 6, day: 1}).getTimezoneOffset()); }; /** * Indicates whether this Date instance is within the Daylight Saving Time range for the current time zone. * @return {Boolean} true|false */ $P.isDaylightSavingTime = function () { return Date.today().set({month: 0, day: 1}).getTimezoneOffset() !== this.getTimezoneOffset(); }; /** * Get the offset from UTC of the current date. * @return {String} The 4-character offset string prefixed with + or - (e.g. "-0500") */ $P.getUTCOffset = function (offset) { var n = (offset || this.getTimezoneOffset()) * -10 / 6, r; if (n < 0) { r = (n - 10000).toString(); return r.charAt(0) + r.substr(2); } else { r = (n + 10000).toString(); return "+" + r.substr(1); } }; /** * Returns the number of milliseconds between this date and date. * @param {Date} Defaults to now * @return {Number} The diff in milliseconds */ $P.getElapsed = function (date) { return (date || new Date()) - this; }; /** * Set the value of year, month, day, hour, minute, second, millisecond of date instance using given configuration object. * Example

	Date.today().set( { day: 20, month: 1 } )

	new Date().set( { millisecond: 0 } )
	
* * @param {Object} Configuration object containing attributes (month, day, etc.) * @return {Date} this */ $P.set = function (config) { config = validateConfigObject.call(this, config); var key; for (key in config) { if (Object.prototype.hasOwnProperty.call(config, key)) { var name = key.charAt(0).toUpperCase() + key.slice(1); var addFunc, getFunc; if (key !== "week" && key !== "month" && key !== "timezone" && key !== "timezoneOffset") { name += "s"; } addFunc = "add" + name; getFunc = "get" + name; if (key === "month") { addFunc = addFunc + "s"; } else if (key === "year"){ getFunc = "getFullYear"; } if (key !== "day" && key !== "timezone" && key !== "timezoneOffset" && key !== "week" && key !== "hour") { this[addFunc](config[key] - this[getFunc]()); } else if ( key === "timezone"|| key === "timezoneOffset" || key === "week" || key === "hour") { this["set"+name](config[key]); } } } // day has to go last because you can't validate the day without first knowing the month if (config.day) { this.addDays(config.day - this.getDate()); } return this; }; /** * Moves the date to the first day of the month. * @return {Date} this */ $P.moveToFirstDayOfMonth = function () { return this.set({ day: 1 }); }; /** * Moves the date to the last day of the month. * @return {Date} this */ $P.moveToLastDayOfMonth = function () { return this.set({ day: $D.getDaysInMonth(this.getFullYear(), this.getMonth())}); }; /** * Converts the value of the current Date object to its equivalent string representation. * Format Specifiers * CUSTOM DATE AND TIME FORMAT STRINGS * Format Description Example * ------ --------------------------------------------------------------------------- ----------------------- * s The seconds of the minute between 0-59. "0" to "59" * ss The seconds of the minute with leading zero if required. "00" to "59" * * m The minute of the hour between 0-59. "0" or "59" * mm The minute of the hour with leading zero if required. "00" or "59" * * h The hour of the day between 1-12. "1" to "12" * hh The hour of the day with leading zero if required. "01" to "12" * * H The hour of the day between 0-23. "0" to "23" * HH The hour of the day with leading zero if required. "00" to "23" * * d The day of the month between 1 and 31. "1" to "31" * dd The day of the month with leading zero if required. "01" to "31" * ddd Abbreviated day name. Date.CultureInfo.abbreviatedDayNames. "Mon" to "Sun" * dddd The full day name. Date.CultureInfo.dayNames. "Monday" to "Sunday" * * M The month of the year between 1-12. "1" to "12" * MM The month of the year with leading zero if required. "01" to "12" * MMM Abbreviated month name. Date.CultureInfo.abbreviatedMonthNames. "Jan" to "Dec" * MMMM The full month name. Date.CultureInfo.monthNames. "January" to "December" * * yy The year as a two-digit number. "99" or "08" * yyyy The full four digit year. "1999" or "2008" * * t Displays the first character of the A.M./P.M. designator. "A" or "P" * Date.CultureInfo.amDesignator or Date.CultureInfo.pmDesignator * tt Displays the A.M./P.M. designator. "AM" or "PM" * Date.CultureInfo.amDesignator or Date.CultureInfo.pmDesignator * * S The ordinal suffix ("st, "nd", "rd" or "th") of the current day. "st, "nd", "rd" or "th" * * STANDARD DATE AND TIME FORMAT STRINGS * Format Description Example *------ --------------------------------------------------------------------------- ----------------------- * d The CultureInfo shortDate Format Pattern "M/d/yyyy" * D The CultureInfo longDate Format Pattern "dddd, MMMM dd, yyyy" * F The CultureInfo fullDateTime Format Pattern "dddd, MMMM dd, yyyy h:mm:ss tt" * m The CultureInfo monthDay Format Pattern "MMMM dd" * r The CultureInfo rfc1123 Format Pattern "ddd, dd MMM yyyy HH:mm:ss GMT" * s The CultureInfo sortableDateTime Format Pattern "yyyy-MM-ddTHH:mm:ss" * t The CultureInfo shortTime Format Pattern "h:mm tt" * T The CultureInfo longTime Format Pattern "h:mm:ss tt" * u The CultureInfo universalSortableDateTime Format Pattern "yyyy-MM-dd HH:mm:ssZ" * y The CultureInfo yearMonth Format Pattern "MMMM, yyyy" * * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @return {String} A string representation of the current Date object. */ var ord = function (n) { switch (n * 1) { case 1: case 21: case 31: return "st"; case 2: case 22: return "nd"; case 3: case 23: return "rd"; default: return "th"; } }; var parseStandardFormats = function (format) { var y, c = Date.CultureInfo.formatPatterns; switch (format) { case "d": return this.toString(c.shortDate); case "D": return this.toString(c.longDate); case "F": return this.toString(c.fullDateTime); case "m": return this.toString(c.monthDay); case "r": case "R": y = this.clone().addMinutes(this.getTimezoneOffset()); return y.toString(c.rfc1123) + " GMT"; case "s": return this.toString(c.sortableDateTime); case "t": return this.toString(c.shortTime); case "T": return this.toString(c.longTime); case "u": y = this.clone().addMinutes(this.getTimezoneOffset()); return y.toString(c.universalSortableDateTime); case "y": return this.toString(c.yearMonth); default: return false; } }; var parseFormatStringsClosure = function (context) { return function (m) { if (m.charAt(0) === "\\") { return m.replace("\\", ""); } switch (m) { case "hh": return p(context.getHours() < 13 ? (context.getHours() === 0 ? 12 : context.getHours()) : (context.getHours() - 12)); case "h": return context.getHours() < 13 ? (context.getHours() === 0 ? 12 : context.getHours()) : (context.getHours() - 12); case "HH": return p(context.getHours()); case "H": return context.getHours(); case "mm": return p(context.getMinutes()); case "m": return context.getMinutes(); case "ss": return p(context.getSeconds()); case "s": return context.getSeconds(); case "yyyy": return p(context.getFullYear(), 4); case "yy": return p(context.getFullYear()); case "y": return context.getFullYear(); case "E": case "dddd": return Date.CultureInfo.dayNames[context.getDay()]; case "ddd": return Date.CultureInfo.abbreviatedDayNames[context.getDay()]; case "dd": return p(context.getDate()); case "d": return context.getDate(); case "MMMM": return Date.CultureInfo.monthNames[context.getMonth()]; case "MMM": return Date.CultureInfo.abbreviatedMonthNames[context.getMonth()]; case "MM": return p((context.getMonth() + 1)); case "M": return context.getMonth() + 1; case "t": return context.getHours() < 12 ? Date.CultureInfo.amDesignator.substring(0, 1) : Date.CultureInfo.pmDesignator.substring(0, 1); case "tt": return context.getHours() < 12 ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator; case "S": return ord(context.getDate()); case "W": return context.getWeek(); case "WW": return context.getISOWeek(); case "Q": return "Q" + context.getQuarter(); case "q": return String(context.getQuarter()); case "z": return context.getTimezone(); case "Z": case "X": return Date.getTimezoneOffset(context.getTimezone()); case "ZZ": // Timezone offset in seconds return context.getTimezoneOffset() * -60; case "u": return context.getDay(); case "L": return ($D.isLeapYear(context.getFullYear())) ? 1 : 0; case "B": // Swatch Internet Time (.beats) return "@"+((context.getUTCSeconds() + (context.getUTCMinutes()*60) + ((context.getUTCHours()+1)*3600))/86.4); default: return m; } }; }; $P.toString = function (format, ignoreStandards) { // Standard Date and Time Format Strings. Formats pulled from CultureInfo file and // may vary by culture. if (!ignoreStandards && format && format.length === 1) { output = parseStandardFormats.call(this, format); if (output) { return output; } } var parseFormatStrings = parseFormatStringsClosure(this); return format ? format.replace(/((\\)?(dd?d?d?|MM?M?M?|yy?y?y?|hh?|HH?|mm?|ss?|tt?|S|q|Q|WW?W?W?)(?![^\[]*\]))/g, parseFormatStrings).replace(/\[|\]/g, "") : this._toString(); }; }()); /************************************************************* * SugarPak - Domain Specific Language - Syntactical Sugar * *************************************************************/ (function () { var $D = Date, $P = $D.prototype, $N = Number.prototype; // private $P._orient = +1; // private $P._nth = null; // private $P._is = false; // private $P._same = false; // private $P._isSecond = false; // private $N._dateElement = "days"; /** * Moves the date to the next instance of a date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.today().next().friday();
	Date.today().next().fri();
	Date.today().next().march();
	Date.today().next().mar();
	Date.today().next().week();
	
* * @return {Date} date */ $P.next = function () { this._move = true; this._orient = +1; return this; }; /** * Creates a new Date (Date.today()) and moves the date to the next instance of the date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.next().friday();
	Date.next().fri();
	Date.next().march();
	Date.next().mar();
	Date.next().week();
	
* * @return {Date} date */ $D.next = function () { return $D.today().next(); }; /** * Moves the date to the previous instance of a date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.today().last().friday();
	Date.today().last().fri();
	Date.today().last().march();
	Date.today().last().mar();
	Date.today().last().week();
	
* * @return {Date} date */ $P.last = $P.prev = $P.previous = function () { this._move = true; this._orient = -1; return this; }; /** * Creates a new Date (Date.today()) and moves the date to the previous instance of the date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.last().friday();
	Date.last().fri();
	Date.previous().march();
	Date.prev().mar();
	Date.last().week();
	
* * @return {Date} date */ $D.last = $D.prev = $D.previous = function () { return $D.today().last(); }; /** * Performs a equality check when followed by either a month name, day name or .weekday() function. * Example

	Date.today().is().friday(); // true|false
	Date.today().is().fri();
	Date.today().is().march();
	Date.today().is().mar();
	
* * @return {Boolean} true|false */ $P.is = function () { this._is = true; return this; }; /** * Determines if two date objects occur on/in exactly the same instance of the subsequent date part function. * The function .same() must be followed by a date part function (example: .day(), .month(), .year(), etc). * * An optional Date can be passed in the date part function. If now date is passed as a parameter, 'Now' is used. * * The following example demonstrates how to determine if two dates fall on the exact same day. * * Example

	var d1 = Date.today(); // today at 00:00
	var d2 = new Date();   // exactly now.

	// Do they occur on the same day?
	d1.same().day(d2); // true
	
	// Do they occur on the same hour?
	d1.same().hour(d2); // false, unless d2 hour is '00' (midnight).
	
	// What if it's the same day, but one year apart?
	var nextYear = Date.today().add(1).year();

	d1.same().day(nextYear); // false, because the dates must occur on the exact same day. 
	
* * Scenario: Determine if a given date occurs during some week period 2 months from now. * * Example

	var future = Date.today().add(2).months();
	return someDate.same().week(future); // true|false;
	
* * @return {Boolean} true|false */ $P.same = function () { this._same = true; this._isSecond = false; return this; }; /** * Determines if the current date/time occurs during Today. Must be preceded by the .is() function. * Example

	someDate.is().today();    // true|false
	new Date().is().today();  // true
	Date.today().is().today();// true
	Date.today().add(-1).day().is().today(); // false
	
* * @return {Boolean} true|false */ $P.today = function () { return this.same().day(); }; /** * Determines if the current date is a weekday. This function must be preceded by the .is() function. * Example

	Date.today().is().weekday(); // true|false
	
* * @return {Boolean} true|false */ $P.weekday = function () { if (this._nth) { return df("Weekday").call(this); } if (this._move) { return this.addWeekdays(this._orient); } if (this._is) { this._is = false; return (!this.is().sat() && !this.is().sun()); } return false; }; /** * Determines if the current date is on the weekend. This function must be preceded by the .is() function. * Example

	Date.today().is().weekend(); // true|false
	
* * @return {Boolean} true|false */ $P.weekend = function () { if (this._is) { this._is = false; return (this.is().sat() || this.is().sun()); } return false; }; /** * Sets the Time of the current Date instance. A string "6:15 pm" or config object {hour:18, minute:15} are accepted. * Example

	// Set time to 6:15pm with a String
	Date.today().at("6:15pm");

	// Set time to 6:15pm with a config object
	Date.today().at({hour:18, minute:15});
	
* * @return {Date} date */ $P.at = function (time) { return (typeof time === "string") ? $D.parse(this.toString("d") + " " + time) : this.set(time); }; /** * Creates a new Date() and adds this (Number) to the date based on the preceding date element function (eg. second|minute|hour|day|month|year). * Example

	// Undeclared Numbers must be wrapped with parentheses. Requirment of JavaScript.
	(3).days().fromNow();
	(6).months().fromNow();

	// Declared Number variables do not require parentheses. 
	var n = 6;
	n.months().fromNow();
	
* * @return {Date} A new Date instance */ $N.fromNow = $N.after = function (date) { var c = {}; c[this._dateElement] = this; return ((!date) ? new Date() : date.clone()).add(c); }; /** * Creates a new Date() and subtract this (Number) from the date based on the preceding date element function (eg. second|minute|hour|day|month|year). * Example

	// Undeclared Numbers must be wrapped with parentheses. Requirment of JavaScript.
	(3).days().ago();
	(6).months().ago();

	// Declared Number variables do not require parentheses. 
	var n = 6;
	n.months().ago();
	
* * @return {Date} A new Date instance */ $N.ago = $N.before = function (date) { var c = {}, s = (this._dateElement[this._dateElement.length-1] !== "s") ? this._dateElement + "s" : this._dateElement; c[s] = this * -1; return ((!date) ? new Date() : date.clone()).add(c); }; // Do NOT modify the following string tokens. These tokens are used to build dynamic functions. // All culture-specific strings can be found in the CultureInfo files. var dx = ("sunday monday tuesday wednesday thursday friday saturday").split(/\s/), mx = ("january february march april may june july august september october november december").split(/\s/), px = ("Millisecond Second Minute Hour Day Week Month Year Quarter Weekday").split(/\s/), pxf = ("Milliseconds Seconds Minutes Hours Date Week Month FullYear Quarter").split(/\s/), nth = ("final first second third fourth fifth").split(/\s/), de; /** * Returns an object literal of all the date parts. * Example

	var o = new Date().toObject();
	
	// { year: 2008, month: 4, week: 20, day: 13, hour: 18, minute: 9, second: 32, millisecond: 812 }
	
	// The object properties can be referenced directly from the object.
	
	alert(o.day);  // alerts "13"
	alert(o.year); // alerts "2008"
	
* * @return {Date} An object literal representing the original date object. */ $P.toObject = function () { var o = {}; for (var i = 0; i < px.length; i++) { if (this["get" + pxf[i]]) { o[px[i].toLowerCase()] = this["get" + pxf[i]](); } } return o; }; /** * Returns a date created from an object literal. Ignores the .week property if set in the config. * Example

	var o = new Date().toObject();
	
	return Date.fromObject(o); // will return the same date. 

	var o2 = {month: 1, day: 20, hour: 18}; // birthday party!
	Date.fromObject(o2);
	
* * @return {Date} An object literal representing the original date object. */ $D.fromObject = function(config) { config.week = null; return Date.today().set(config); }; // Create day name functions and abbreviated day name functions (eg. monday(), friday(), fri()). var df = function (n) { return function () { if (this._is) { this._is = false; return this.getDay() === n; } if (this._move) { this._move = null; } if (this._nth !== null) { // If the .second() function was called earlier, remove the _orient // from the date, and then continue. // This is required because 'second' can be used in two different context. // // Example // // Date.today().add(1).second(); // Date.march().second().monday(); // // Things get crazy with the following... // Date.march().add(1).second().second().monday(); // but it works!! // if (this._isSecond) { this.addSeconds(this._orient * -1); } // make sure we reset _isSecond this._isSecond = false; var ntemp = this._nth; this._nth = null; var temp = this.clone().moveToLastDayOfMonth(); this.moveToNthOccurrence(n, ntemp); if (this > temp) { throw new RangeError($D.getDayName(n) + " does not occur " + ntemp + " times in the month of " + $D.getMonthName(temp.getMonth()) + " " + temp.getFullYear() + "."); } return this; } return this.moveToDayOfWeek(n, this._orient); }; }; var sdf = function (n) { return function () { var t = $D.today(), shift = n - t.getDay(); if (n === 0 && Date.CultureInfo.firstDayOfWeek === 1 && t.getDay() !== 0) { shift = shift + 7; } return t.addDays(shift); }; }; // Create month name functions and abbreviated month name functions (eg. january(), march(), mar()). var month_instance_functions = function (n) { return function () { if (this._is) { this._is = false; return this.getMonth() === n; } return this.moveToMonth(n, this._orient); }; }; var month_static_functions = function (n) { return function () { return $D.today().set({ month: n, day: 1 }); }; }; var processTerms = function (names, staticFunc, instanceFunc) { for (var i = 0; i < names.length; i++) { // Create constant static Name variables. $D[names[i].toUpperCase()] = $D[names[i].toUpperCase().substring(0, 3)] = i; // Create Name functions. $D[names[i]] = $D[names[i].substring(0, 3)] = staticFunc(i); // Create Name instance functions. $P[names[i]] = $P[names[i].substring(0, 3)] = instanceFunc(i); } }; processTerms(dx, sdf, df); processTerms(mx, month_static_functions, month_instance_functions); // Create date element functions and plural date element functions used with Date (eg. day(), days(), months()). var ef = function (j) { return function () { // if the .second() function was called earlier, the _orient // has alread been added. Just return this and reset _isSecond. if (this._isSecond) { this._isSecond = false; return this; } if (this._same) { this._same = this._is = false; var o1 = this.toObject(), o2 = (arguments[0] || new Date()).toObject(), v = "", k = j.toLowerCase(); // the substr trick with -1 doesn't work in IE8 or less k = (k[k.length-1] === "s") ? k.substring(0,k.length-1) : k; for (var m = (px.length - 1); m > -1; m--) { v = px[m].toLowerCase(); if (o1[v] !== o2[v]) { return false; } if (k === v) { break; } } return true; } if (j.substring(j.length - 1) !== "s") { j += "s"; } if (this._move) { this._move = null; } return this["add" + j](this._orient); }; }; var nf = function (n) { return function () { this._dateElement = n; return this; }; }; for (var k = 0; k < px.length; k++) { de = px[k].toLowerCase(); if(de !== "weekday") { // Create date element functions and plural date element functions used with Date (eg. day(), days(), months()). $P[de] = $P[de + "s"] = ef(px[k]); // Create date element functions and plural date element functions used with Number (eg. day(), days(), months()). $N[de] = $N[de + "s"] = nf(de + "s"); } } $P._ss = ef("Second"); var nthfn = function (n) { return function (dayOfWeek) { if (this._same) { return this._ss(arguments[0]); } if (dayOfWeek || dayOfWeek === 0) { return this.moveToNthOccurrence(dayOfWeek, n); } this._nth = n; // if the operator is 'second' add the _orient, then deal with it later... if (n === 2 && (dayOfWeek === undefined || dayOfWeek === null)) { this._isSecond = true; return this.addSeconds(this._orient); } return this; }; }; for (var l = 0; l < nth.length; l++) { $P[nth[l]] = (l === 0) ? nthfn(-1) : nthfn(l); } }()); (function () { "use strict"; Date.Parsing = { Exception: function (s) { this.message = "Parse error at '" + s.substring(0, 10) + " ...'"; } }; var $P = Date.Parsing; var dayOffsets = { standard: [0,31,59,90,120,151,181,212,243,273,304,334], leap: [0,31,60,91,121,152,182,213,244,274,305,335] }; $P.isLeapYear = function(year) { return ((year % 4 === 0) && (year % 100 !== 0)) || (year % 400 === 0); }; var utils = { multiReplace : function (str, hash ) { var key; for (key in hash) { if (Object.prototype.hasOwnProperty.call(hash, key)) { var regex; if (typeof hash[key] === "function") { } else { regex = (hash[key] instanceof RegExp) ? hash[key] : new RegExp(hash[key], "g"); } str = str.replace(regex, key); } } return str; }, getDayOfYearFromWeek : function (obj) { var d, jan4, offset; obj.weekDay = (!obj.weekDay && obj.weekDay !== 0) ? 1 : obj.weekDay; d = new Date(obj.year, 0, 4); jan4 = d.getDay() === 0 ? 7 : d.getDay(); // JS is 0 indexed on Sunday. offset = jan4+3; obj.dayOfYear = ((obj.week * 7) + (obj.weekDay === 0 ? 7 : obj.weekDay))-offset; return obj; }, getDayOfYear : function (obj, dayOffset) { if (!obj.dayOfYear) { obj = utils.getDayOfYearFromWeek(obj); } for (var i=0;i <= dayOffset.length;i++) { if (obj.dayOfYear < dayOffset[i] || i === dayOffset.length) { obj.day = obj.day ? obj.day : (obj.dayOfYear - dayOffset[i-1]); break; } else { obj.month = i; } } return obj; }, adjustForTimeZone : function (obj, date) { var offset; if (obj.zone.toUpperCase() === "Z" || (obj.zone_hours === 0 && obj.zone_minutes === 0)) { // it's UTC/GML so work out the current timeszone offset offset = -date.getTimezoneOffset(); } else { offset = (obj.zone_hours*60) + (obj.zone_minutes || 0); if (obj.zone_sign === "+") { offset *= -1; } offset -= date.getTimezoneOffset(); } date.setMinutes(date.getMinutes()+offset); return date; }, setDefaults : function (obj) { obj.year = obj.year || Date.today().getFullYear(); obj.hours = obj.hours || 0; obj.minutes = obj.minutes || 0; obj.seconds = obj.seconds || 0; obj.milliseconds = obj.milliseconds || 0; if (!(!obj.month && (obj.week || obj.dayOfYear))) { // if we have a month, or if we don't but don't have the day calculation data obj.month = obj.month || 0; obj.day = obj.day || 1; } return obj; }, dataNum: function (data, mod, explict, postProcess) { var dataNum = data*1; if (mod) { if (postProcess) { return data ? mod(data)*1 : data; } else { return data ? mod(dataNum) : data; } } else if (!explict){ return data ? dataNum : data; } else { return (data && typeof data !== "undefined") ? dataNum : data; } }, timeDataProcess: function (obj) { var timeObj = {}; for (var x in obj.data) { if (obj.data.hasOwnProperty(x)) { timeObj[x] = obj.ignore[x] ? obj.data[x] : utils.dataNum(obj.data[x], obj.mods[x], obj.explict[x], obj.postProcess[x]); } } if (obj.data.secmins) { obj.data.secmins = obj.data.secmins.replace(",", ".") * 60; if (!timeObj.minutes) { timeObj.minutes = obj.data.secmins; } else if (!timeObj.seconds) { timeObj.seconds = obj.data.secmins; } delete obj.secmins; } return timeObj; }, buildTimeObjectFromData: function (data) { var time = utils.timeDataProcess({ data: { year : data[1], month : data[5], day : data[7], week : data[8], dayOfYear : data[10], hours : data[15], zone_hours : data[23], zone_minutes : data[24], zone : data[21], zone_sign : data[22], weekDay : data[9], minutes: data[16], seconds: data[19], milliseconds: data[20], secmins: data[18] }, mods: { month: function(data) { return data-1; }, weekDay: function (data) { data = Math.abs(data); return (data === 7 ? 0 : data); }, minutes: function (data) { return data.replace(":",""); }, seconds: function (data) { return Math.floor( (data.replace(":","").replace(",","."))*1 ); }, milliseconds: function (data) { return (data.replace(",",".")*1000); } }, postProcess: { minutes: true, seconds: true, milliseconds: true }, explict: { zone_hours: true, zone_minutes: true }, ignore: { zone: true, zone_sign: true, secmins: true } }); return time; }, addToHash: function (hash, keys, data) { keys = keys; data = data; var len = keys.length; for (var i = 0; i < len; i++) { hash[keys[i]] = data[i]; } return hash; }, combineRegex: function (r1, r2) { return new RegExp("(("+r1.source+")\\s("+r2.source+"))"); }, getDateNthString: function(add, last, inc){ if (add) { return Date.today().addDays(inc).toString("d"); } else if (last) { return Date.today().last()[inc]().toString("d"); } }, buildRegexData: function (array) { var arr = []; var len = array.length; for (var i=0; i < len; i++) { if (Object.prototype.toString.call(array[i]) === '[object Array]') { // oldIE compat version of Array.isArray arr.push(this.combineRegex(array[i][0], array[i][1])); } else { arr.push(array[i]); } } return arr; } }; $P.processTimeObject = function (obj) { var date, dayOffset; utils.setDefaults(obj); dayOffset = ($P.isLeapYear(obj.year)) ? dayOffsets.leap : dayOffsets.standard; if (!obj.month && (obj.week || obj.dayOfYear)) { utils.getDayOfYear(obj, dayOffset); } else { obj.dayOfYear = dayOffset[obj.month] + obj.day; } date = new Date(obj.year, obj.month, obj.day, obj.hours, obj.minutes, obj.seconds, obj.milliseconds); if (obj.zone) { utils.adjustForTimeZone(obj, date); // adjust (and calculate) for timezone } return date; }; $P.ISO = { regex : /^([\+-]?\d{4}(?!\d{2}\b))((-?)((0[1-9]|1[0-2])(\3([12]\d|0[1-9]|3[01]))?|W([0-4]\d|5[0-3])(-?[1-7])?|(00[1-9]|0[1-9]\d|[12]\d{2}|3([0-5]\d|6[1-6])))([T\s]((([01]\d|2[0-4])((:?)[0-5]\d)?|24\:?00)([\.,]\d+(?!:))?)?(\17[0-5]\d([\.,]\d+)?)?\s?([zZ]|([\+-])([01]\d|2[0-3]):?([0-5]\d)?)?)?)?$/, parse : function (s) { var time, data = s.match(this.regex); if (!data || !data.length) { return null; } time = utils.buildTimeObjectFromData(data); if (!time.year || (!time.year && (!time.month && !time.day) && (!time.week && !time.dayOfYear)) ) { return null; } return $P.processTimeObject(time); } }; $P.Numeric = { isNumeric: function (e){return!isNaN(parseFloat(e))&&isFinite(e);}, regex: /\b([0-1]?[0-9])([0-3]?[0-9])([0-2]?[0-9]?[0-9][0-9])\b/i, parse: function (s) { var data, i, time = {}, order = Date.CultureInfo.dateElementOrder.split(""); if (!(this.isNumeric(s)) || // if it's non-numeric OR (s[0] === "+" && s[0] === "-")) { // It's an arithmatic string (eg +/-1000) return null; } if (s.length < 5 && s.indexOf(".") < 0 && s.indexOf("/") < 0) { // assume it's just a year. time.year = s; return $P.processTimeObject(time); } data = s.match(this.regex); if (!data || !data.length) { return null; } for (i=0; i < order.length; i++) { switch(order[i]) { case "d": time.day = data[i+1]; break; case "m": time.month = (data[i+1]-1); break; case "y": time.year = data[i+1]; break; } } return $P.processTimeObject(time); } }; $P.Normalizer = { regexData: function () { var $R = Date.CultureInfo.regexPatterns; return utils.buildRegexData([ $R.tomorrow, $R.yesterday, [$R.past, $R.mon], [$R.past, $R.tue], [$R.past, $R.wed], [$R.past, $R.thu], [$R.past, $R.fri], [$R.past, $R.sat], [$R.past, $R.sun] ]); }, basicReplaceHash : function() { var $R = Date.CultureInfo.regexPatterns; return { "January": $R.jan.source, "February": $R.feb, "March": $R.mar, "April": $R.apr, "May": $R.may, "June": $R.jun, "July": $R.jul, "August": $R.aug, "September": $R.sep, "October": $R.oct, "November": $R.nov, "December": $R.dec, "": /\bat\b/gi, " ": /\s{2,}/, "am": $R.inTheMorning, "9am": $R.thisMorning, "pm": $R.inTheEvening, "7pm":$R.thisEvening }; }, keys : function(){ return [ utils.getDateNthString(true, false, 1), // tomorrow utils.getDateNthString(true, false, -1), // yesterday utils.getDateNthString(false, true, "monday"), //last mon utils.getDateNthString(false, true, "tuesday"), //last tues utils.getDateNthString(false, true, "wednesday"), //last wed utils.getDateNthString(false, true, "thursday"), //last thurs utils.getDateNthString(false, true, "friday"), //last fri utils.getDateNthString(false, true, "saturday"), //last sat utils.getDateNthString(false, true, "sunday") //last sun ]; }, buildRegexFunctions: function () { var $R = Date.CultureInfo.regexPatterns; var __ = Date.i18n.__; var tomorrowRE = new RegExp("(\\b\\d\\d?("+__("AM")+"|"+__("PM")+")? )("+$R.tomorrow.source.slice(1)+")", "i"); // adapted tomorrow regex for AM PM relative dates var todayRE = new RegExp($R.today.source + "(?!\\s*([+-]))\\b"); // today, but excludes the math operators (eg "today + 2h") this.replaceFuncs = [ [todayRE, function (full) { return (full.length > 1) ? Date.today().toString("d") : full; }], [tomorrowRE, function(full, m1) { var t = Date.today().addDays(1).toString("d"); return (t + " " + m1); }], [$R.amThisMorning, function(str, am){return am;}], [$R.pmThisEvening, function(str, pm){return pm;}] ]; }, buildReplaceData: function () { this.buildRegexFunctions(); this.replaceHash = utils.addToHash(this.basicReplaceHash(), this.keys(), this.regexData()); }, stringReplaceFuncs: function (s) { for (var i=0; i < this.replaceFuncs.length; i++) { s = s.replace(this.replaceFuncs[i][0], this.replaceFuncs[i][1]); } return s; }, parse: function (s) { s = this.stringReplaceFuncs(s); s = utils.multiReplace(s, this.replaceHash); try { var n = s.split(/([\s\-\.\,\/\x27]+)/); if (n.length === 3 && $P.Numeric.isNumeric(n[0]) && $P.Numeric.isNumeric(n[2]) && (n[2].length >= 4)) { // ok, so we're dealing with x/year. But that's not a full date. // This fixes wonky dateElementOrder parsing when set to dmy order. if (Date.CultureInfo.dateElementOrder[0] === "d") { s = "1/" + n[0] + "/" + n[2]; // set to 1st of month and normalize the seperator } } } catch (e) {} return s; } }; $P.Normalizer.buildReplaceData(); }()); (function () { var $P = Date.Parsing; var _ = $P.Operators = { // // Tokenizers // rtoken: function (r) { // regex token return function (s) { var mx = s.match(r); if (mx) { return ([ mx[0], s.substring(mx[0].length) ]); } else { throw new $P.Exception(s); } }; }, token: function () { // whitespace-eating token return function (s) { return _.rtoken(new RegExp("^\\s*" + s + "\\s*"))(s); }; }, stoken: function (s) { // string token return _.rtoken(new RegExp("^" + s)); }, // Atomic Operators until: function (p) { return function (s) { var qx = [], rx = null; while (s.length) { try { rx = p.call(this, s); } catch (e) { qx.push(rx[0]); s = rx[1]; continue; } break; } return [ qx, s ]; }; }, many: function (p) { return function (s) { var rx = [], r = null; while (s.length) { try { r = p.call(this, s); } catch (e) { return [ rx, s ]; } rx.push(r[0]); s = r[1]; } return [ rx, s ]; }; }, // generator operators -- see below optional: function (p) { return function (s) { var r = null; try { r = p.call(this, s); } catch (e) { return [ null, s ]; } return [ r[0], r[1] ]; }; }, not: function (p) { return function (s) { try { p.call(this, s); } catch (e) { return [null, s]; } throw new $P.Exception(s); }; }, ignore: function (p) { return p ? function (s) { var r = null; r = p.call(this, s); return [null, r[1]]; } : null; }, product: function () { var px = arguments[0], qx = Array.prototype.slice.call(arguments, 1), rx = []; for (var i = 0 ; i < px.length ; i++) { rx.push(_.each(px[i], qx)); } return rx; }, cache: function (rule) { var cache = {}, cache_length = 0, cache_keys = [], CACHE_MAX = Date.Config.CACHE_MAX || 100000, r = null; var cacheCheck = function () { if (cache_length === CACHE_MAX) { // kill several keys, don't want to have to do this all the time... for (var i=0; i < 10; i++) { var key = cache_keys.shift(); if (key) { delete cache[key]; cache_length--; } } } }; return function (s) { cacheCheck(); try { r = cache[s] = (cache[s] || rule.call(this, s)); } catch (e) { r = cache[s] = e; } cache_length++; cache_keys.push(s); if (r instanceof $P.Exception) { throw r; } else { return r; } }; }, // vector operators -- see below any: function () { var px = arguments; return function (s) { var r = null; for (var i = 0; i < px.length; i++) { if (px[i] == null) { continue; } try { r = (px[i].call(this, s)); } catch (e) { r = null; } if (r) { return r; } } throw new $P.Exception(s); }; }, each: function () { var px = arguments; return function (s) { var rx = [], r = null; for (var i = 0; i < px.length ; i++) { if (px[i] == null) { continue; } try { r = (px[i].call(this, s)); } catch (e) { throw new $P.Exception(s); } rx.push(r[0]); s = r[1]; } return [ rx, s]; }; }, all: function () { var px = arguments, _ = _; return _.each(_.optional(px)); }, // delimited operators sequence: function (px, d, c) { d = d || _.rtoken(/^\s*/); c = c || null; if (px.length === 1) { return px[0]; } return function (s) { var r = null, q = null; var rx = []; for (var i = 0; i < px.length ; i++) { try { r = px[i].call(this, s); } catch (e) { break; } rx.push(r[0]); try { q = d.call(this, r[1]); } catch (ex) { q = null; break; } s = q[1]; } if (!r) { throw new $P.Exception(s); } if (q) { throw new $P.Exception(q[1]); } if (c) { try { r = c.call(this, r[1]); } catch (ey) { throw new $P.Exception(r[1]); } } return [ rx, (r?r[1]:s) ]; }; }, // // Composite Operators // between: function (d1, p, d2) { d2 = d2 || d1; var _fn = _.each(_.ignore(d1), p, _.ignore(d2)); return function (s) { var rx = _fn.call(this, s); return [[rx[0][0], r[0][2]], rx[1]]; }; }, list: function (p, d, c) { d = d || _.rtoken(/^\s*/); c = c || null; return (p instanceof Array ? _.each(_.product(p.slice(0, -1), _.ignore(d)), p.slice(-1), _.ignore(c)) : _.each(_.many(_.each(p, _.ignore(d))), px, _.ignore(c))); }, set: function (px, d, c) { d = d || _.rtoken(/^\s*/); c = c || null; return function (s) { // r is the current match, best the current 'best' match // which means it parsed the most amount of input var r = null, p = null, q = null, rx = null, best = [[], s], last = false; // go through the rules in the given set for (var i = 0; i < px.length ; i++) { // last is a flag indicating whether this must be the last element // if there is only 1 element, then it MUST be the last one q = null; p = null; r = null; last = (px.length === 1); // first, we try simply to match the current pattern // if not, try the next pattern try { r = px[i].call(this, s); } catch (e) { continue; } // since we are matching against a set of elements, the first // thing to do is to add r[0] to matched elements rx = [[r[0]], r[1]]; // if we matched and there is still input to parse and // we don't already know this is the last element, // we're going to next check for the delimiter ... // if there's none, or if there's no input left to parse // than this must be the last element after all ... if (r[1].length > 0 && ! last) { try { q = d.call(this, r[1]); } catch (ex) { last = true; } } else { last = true; } // if we parsed the delimiter and now there's no more input, // that means we shouldn't have parsed the delimiter at all // so don't update r and mark this as the last element ... if (!last && q[1].length === 0) { last = true; } // so, if this isn't the last element, we're going to see if // we can get any more matches from the remaining (unmatched) // elements ... if (!last) { // build a list of the remaining rules we can match against, // i.e., all but the one we just matched against var qx = []; for (var j = 0; j < px.length ; j++) { if (i !== j) { qx.push(px[j]); } } // now invoke recursively set with the remaining input // note that we don't include the closing delimiter ... // we'll check for that ourselves at the end p = _.set(qx, d).call(this, q[1]); // if we got a non-empty set as a result ... // (otw rx already contains everything we want to match) if (p[0].length > 0) { // update current result, which is stored in rx ... // basically, pick up the remaining text from p[1] // and concat the result from p[0] so that we don't // get endless nesting ... rx[0] = rx[0].concat(p[0]); rx[1] = p[1]; } } // at this point, rx either contains the last matched element // or the entire matched set that starts with this element. // now we just check to see if this variation is better than // our best so far, in terms of how much of the input is parsed if (rx[1].length < best[1].length) { best = rx; } // if we've parsed all the input, then we're finished if (best[1].length === 0) { break; } } // so now we've either gone through all the patterns trying them // as the initial match; or we found one that parsed the entire // input string ... // if best has no matches, just return empty set ... if (best[0].length === 0) { return best; } // if a closing delimiter is provided, then we have to check it also if (c) { // we try this even if there is no remaining input because the pattern // may well be optional or match empty input ... try { q = c.call(this, best[1]); } catch (ey) { throw new $P.Exception(best[1]); } // it parsed ... be sure to update the best match remaining input best[1] = q[1]; } // if we're here, either there was no closing delimiter or we parsed it // so now we have the best match; just return it! return best; }; }, forward: function (gr, fname) { return function (s) { return gr[fname].call(this, s); }; }, // // Translation Operators // replace: function (rule, repl) { return function (s) { var r = rule.call(this, s); return [repl, r[1]]; }; }, process: function (rule, fn) { return function (s) { var r = rule.call(this, s); return [fn.call(this, r[0]), r[1]]; }; }, min: function (min, rule) { return function (s) { var rx = rule.call(this, s); if (rx[0].length < min) { throw new $P.Exception(s); } return rx; }; } }; // Generator Operators And Vector Operators // Generators are operators that have a signature of F(R) => R, // taking a given rule and returning another rule, such as // ignore, which parses a given rule and throws away the result. // Vector operators are those that have a signature of F(R1,R2,...) => R, // take a list of rules and returning a new rule, such as each. // Generator operators are converted (via the following _generator // function) into functions that can also take a list or array of rules // and return an array of new rules as though the function had been // called on each rule in turn (which is what actually happens). // This allows generators to be used with vector operators more easily. // Example: // each(ignore(foo, bar)) instead of each(ignore(foo), ignore(bar)) // This also turns generators into vector operators, which allows // constructs like: // not(cache(foo, bar)) var _generator = function (op) { function gen() { var args = null, rx = [], px, i; if (arguments.length > 1) { args = Array.prototype.slice.call(arguments); } else if (arguments[0] instanceof Array) { args = arguments[0]; } if (args) { px = args.shift(); if (px.length > 0) { args.unshift(px[i]); rx.push(op.apply(null, args)); args.shift(); return rx; } } else { return op.apply(null, arguments); } } return gen; }; var gx = "optional not ignore cache".split(/\s/); for (var i = 0 ; i < gx.length ; i++) { _[gx[i]] = _generator(_[gx[i]]); } var _vector = function (op) { return function () { if (arguments[0] instanceof Array) { return op.apply(null, arguments[0]); } else { return op.apply(null, arguments); } }; }; var vx = "each any all".split(/\s/); for (var j = 0 ; j < vx.length ; j++) { _[vx[j]] = _vector(_[vx[j]]); } }()); (function () { var $D = Date; var flattenAndCompact = function (ax) { var rx = []; for (var i = 0; i < ax.length; i++) { if (ax[i] instanceof Array) { rx = rx.concat(flattenAndCompact(ax[i])); } else { if (ax[i]) { rx.push(ax[i]); } } } return rx; }; var parseMeridian = function () { if (this.meridian && (this.hour || this.hour === 0)) { if (this.meridian === "a" && this.hour > 11 && Date.Config.strict24hr){ throw "Invalid hour and meridian combination"; } else if (this.meridian === "p" && this.hour < 12 && Date.Config.strict24hr){ throw "Invalid hour and meridian combination"; } else if (this.meridian === "p" && this.hour < 12) { this.hour = this.hour + 12; } else if (this.meridian === "a" && this.hour === 12) { this.hour = 0; } } }; var setDefaults = function () { var now = new Date(); if ((this.hour || this.minute) && (!this.month && !this.year && !this.day)) { this.day = now.getDate(); } if (!this.year) { this.year = now.getFullYear(); } if (!this.month && this.month !== 0) { this.month = now.getMonth(); } if (!this.day) { this.day = 1; } if (!this.hour) { this.hour = 0; } if (!this.minute) { this.minute = 0; } if (!this.second) { this.second = 0; } if (!this.millisecond) { this.millisecond = 0; } }; var finishUtils = { getToday: function () { if (this.now || "hour minute second".indexOf(this.unit) !== -1) { return new Date(); } else { return $D.today(); } }, setDaysFromWeekday: function (today, orient){ var gap; orient = orient || 1; this.unit = "day"; gap = ($D.getDayNumberFromName(this.weekday) - today.getDay()); this.days = gap ? ((gap + (orient * 7)) % 7) : (orient * 7); return this; }, setMonthsFromMonth: function (today, orient) { var gap; orient = orient || 1; this.unit = "month"; gap = (this.month - today.getMonth()); this.months = gap ? ((gap + (orient * 12)) % 12) : (orient * 12); this.month = null; return this; }, setDMYFromWeekday: function () { var d = Date[this.weekday](); this.day = d.getDate(); if (!this.month) { this.month = d.getMonth(); } this.year = d.getFullYear(); return this; }, setUnitValue: function (orient) { if (!this.value && this.operator && this.operator !== null && this[this.unit + "s"] && this[this.unit + "s"] !== null) { this[this.unit + "s"] = this[this.unit + "s"] + ((this.operator === "add") ? 1 : -1) + (this.value||0) * orient; } else if (this[this.unit + "s"] == null || this.operator != null) { if (!this.value) { this.value = 1; } this[this.unit + "s"] = this.value * orient; } }, generateDateFromWeeks: function () { var weekday = (this.weekday !== undefined) ? this.weekday : "today"; var d = Date[weekday]().addWeeks(this.weeks); if (this.now) { d.setTimeToNow(); } return d; } }; $D.Translator = { hour: function (s) { return function () { this.hour = Number(s); }; }, minute: function (s) { return function () { this.minute = Number(s); }; }, second: function (s) { return function () { this.second = Number(s); }; }, /* for ss.s format */ secondAndMillisecond: function (s) { return function () { var mx = s.match(/^([0-5][0-9])\.([0-9]{1,3})/); this.second = Number(mx[1]); this.millisecond = Number(mx[2]); }; }, meridian: function (s) { return function () { this.meridian = s.slice(0, 1).toLowerCase(); }; }, timezone: function (s) { return function () { var n = s.replace(/[^\d\+\-]/g, ""); if (n.length) { this.timezoneOffset = Number(n); } else { this.timezone = s.toLowerCase(); } }; }, day: function (x) { var s = x[0]; return function () { this.day = Number(s.match(/\d+/)[0]); if (this.day < 1) { throw "invalid day"; } }; }, month: function (s) { return function () { this.month = (s.length === 3) ? "jan feb mar apr may jun jul aug sep oct nov dec".indexOf(s)/4 : Number(s) - 1; if (this.month < 0) { throw "invalid month"; } }; }, year: function (s) { return function () { var n = Number(s); this.year = ((s.length > 2) ? n : (n + (((n + 2000) < Date.CultureInfo.twoDigitYearMax) ? 2000 : 1900))); }; }, rday: function (s) { return function () { switch (s) { case "yesterday": this.days = -1; break; case "tomorrow": this.days = 1; break; case "today": this.days = 0; break; case "now": this.days = 0; this.now = true; break; } }; }, finishExact: function (x) { var d; x = (x instanceof Array) ? x : [x]; for (var i = 0 ; i < x.length ; i++) { if (x[i]) { x[i].call(this); } } setDefaults.call(this); parseMeridian.call(this); if (this.day > $D.getDaysInMonth(this.year, this.month)) { throw new RangeError(this.day + " is not a valid value for days."); } d = new Date(this.year, this.month, this.day, this.hour, this.minute, this.second, this.millisecond); if (this.year < 100) { d.setFullYear(this.year); // means years less that 100 are process correctly. JS will parse it otherwise as 1900-1999. } if (this.timezone) { d.set({ timezone: this.timezone }); } else if (this.timezoneOffset) { d.set({ timezoneOffset: this.timezoneOffset }); } return d; }, finish: function (x) { var today, expression, orient, temp; x = (x instanceof Array) ? flattenAndCompact(x) : [ x ]; if (x.length === 0) { return null; } for (var i = 0 ; i < x.length ; i++) { if (typeof x[i] === "function") { x[i].call(this); } } if (this.now && !this.unit && !this.operator) { return new Date(); } else { today = finishUtils.getToday.call(this); } expression = !!(this.days && this.days !== null || this.orient || this.operator); orient = ((this.orient === "past" || this.operator === "subtract") ? -1 : 1); if (this.month && this.unit === "week") { this.value = this.month + 1; delete this.month; delete this.day; } if ((this.month || this.month === 0) && "year day hour minute second".indexOf(this.unit) !== -1) { if (!this.value) { this.value = this.month + 1; } this.month = null; expression = true; } if (!expression && this.weekday && !this.day && !this.days) { finishUtils.setDMYFromWeekday.call(this); } if (expression && this.weekday && this.unit !== "month" && this.unit !== "week") { finishUtils.setDaysFromWeekday.call(this, today, orient); } if (this.weekday && this.unit !== "week" && !this.day && !this.days) { temp = Date[this.weekday](); this.day = temp.getDate(); if (temp.getMonth() !== today.getMonth()) { this.month = temp.getMonth(); } } if (this.month && this.unit === "day" && this.operator) { if (!this.value) { this.value = (this.month + 1); } this.month = null; } if (this.value != null && this.month != null && this.year != null) { this.day = this.value * 1; } if (this.month && !this.day && this.value) { today.set({ day: this.value * 1 }); if (!expression) { this.day = this.value * 1; } } if (!this.month && this.value && this.unit === "month" && !this.now) { this.month = this.value; expression = true; } if (expression && (this.month || this.month === 0) && this.unit !== "year") { finishUtils.setMonthsFromMonth.call(this, today, orient); } if (!this.unit) { this.unit = "day"; } finishUtils.setUnitValue.call(this, orient); parseMeridian.call(this); if ((this.month || this.month === 0) && !this.day) { this.day = 1; } if (!this.orient && !this.operator && this.unit === "week" && this.value && !this.day && !this.month) { return Date.today().setWeek(this.value); } if (this.unit === "week" && this.weeks && !this.day && !this.month) { return finishUtils.generateDateFromWeeks.call(this); } if (expression && this.timezone && this.day && this.days) { this.day = this.days; } if (expression){ today.add(this); } else { today.set(this); } if (this.timezone) { this.timezone = this.timezone.toUpperCase(); var offset = $D.getTimezoneOffset(this.timezone); var timezone; if (today.hasDaylightSavingTime()) { // lets check that we're being sane with timezone setting timezone = $D.getTimezoneAbbreviation(offset, today.isDaylightSavingTime()); if (timezone !== this.timezone) { // bugger, we're in a place where things like EST vs EDT matters. if (today.isDaylightSavingTime()) { today.addHours(-1); } else { today.addHours(1); } } } today.setTimezoneOffset(offset); } return today; } }; }()); (function () { var $D = Date; $D.Grammar = {}; var _ = $D.Parsing.Operators, g = $D.Grammar, t = $D.Translator, _fn; // Allow rolling up into general purpose rules _fn = function () { return _.each(_.any.apply(null, arguments), _.not(g.ctoken2("timeContext"))); }; g.datePartDelimiter = _.rtoken(/^([\s\-\.\,\/\x27]+)/); g.timePartDelimiter = _.stoken(":"); g.whiteSpace = _.rtoken(/^\s*/); g.generalDelimiter = _.rtoken(/^(([\s\,]|at|@|on)+)/); var _C = {}; g.ctoken = function (keys) { var fn = _C[keys]; if (! fn) { var c = Date.CultureInfo.regexPatterns; var kx = keys.split(/\s+/), px = []; for (var i = 0; i < kx.length ; i++) { px.push(_.replace(_.rtoken(c[kx[i]]), kx[i])); } fn = _C[keys] = _.any.apply(null, px); } return fn; }; g.ctoken2 = function (key) { return _.rtoken(Date.CultureInfo.regexPatterns[key]); }; var cacheProcessRtoken = function (key, token, type, eachToken) { if (eachToken) { g[key] = _.cache(_.process(_.each(_.rtoken(token),_.optional(g.ctoken2(eachToken))), type)); } else { g[key] = _.cache(_.process(_.rtoken(token), type)); } }; var cacheProcessCtoken = function (token, type) { return _.cache(_.process(g.ctoken2(token), type)); }; var _F = {}; //function cache var _get = function (f) { _F[f] = (_F[f] || g.format(f)[0]); return _F[f]; }; g.allformats = function (fx) { var rx = []; if (fx instanceof Array) { for (var i = 0; i < fx.length; i++) { rx.push(_get(fx[i])); } } else { rx.push(_get(fx)); } return rx; }; g.formats = function (fx) { if (fx instanceof Array) { var rx = []; for (var i = 0 ; i < fx.length ; i++) { rx.push(_get(fx[i])); } return _.any.apply(null, rx); } else { return _get(fx); } }; var grammarFormats = { timeFormats: function(){ var i, RTokenKeys = [ "h", "hh", "H", "HH", "m", "mm", "s", "ss", "ss.s", "z", "zz" ], RToken = [ /^(0[0-9]|1[0-2]|[1-9])/, /^(0[0-9]|1[0-2])/, /^([0-1][0-9]|2[0-3]|[0-9])/, /^([0-1][0-9]|2[0-3])/, /^([0-5][0-9]|[0-9])/, /^[0-5][0-9]/, /^([0-5][0-9]|[0-9])/, /^[0-5][0-9]/, /^[0-5][0-9]\.[0-9]{1,3}/, /^((\+|\-)\s*\d\d\d\d)|((\+|\-)\d\d\:?\d\d)/, /^((\+|\-)\s*\d\d\d\d)|((\+|\-)\d\d\:?\d\d)/ ], tokens = [ t.hour, t.hour, t.hour, t.hour, t.minute, t.minute, t.second, t.second, t.secondAndMillisecond, t.timezone, t.timezone ]; for (i=0; i < RTokenKeys.length; i++) { cacheProcessRtoken(RTokenKeys[i], RToken[i], tokens[i]); } g.hms = _.cache(_.sequence([g.H, g.m, g.s], g.timePartDelimiter)); g.t = cacheProcessCtoken("shortMeridian", t.meridian); g.tt = cacheProcessCtoken("longMeridian", t.meridian); g.zzz = cacheProcessCtoken("timezone", t.timezone); g.timeSuffix = _.each(_.ignore(g.whiteSpace), _.set([ g.tt, g.zzz ])); g.time = _.each(_.optional(_.ignore(_.stoken("T"))), g.hms, g.timeSuffix); }, dateFormats: function () { // pre-loaded rules for different date part order preferences var _setfn = function () { return _.set(arguments, g.datePartDelimiter); }; var i, RTokenKeys = [ "d", "dd", "M", "MM", "y", "yy", "yyy", "yyyy" ], RToken = [ /^([0-2]\d|3[0-1]|\d)/, /^([0-2]\d|3[0-1])/, /^(1[0-2]|0\d|\d)/, /^(1[0-2]|0\d)/, /^(\d+)/, /^(\d\d)/, /^(\d\d?\d?\d?)/, /^(\d\d\d\d)/ ], tokens = [ t.day, t.day, t.month, t.month, t.year, t.year, t.year, t.year ], eachToken = [ "ordinalSuffix", "ordinalSuffix" ]; for (i=0; i < RTokenKeys.length; i++) { cacheProcessRtoken(RTokenKeys[i], RToken[i], tokens[i], eachToken[i]); } g.MMM = g.MMMM = _.cache(_.process(g.ctoken("jan feb mar apr may jun jul aug sep oct nov dec"), t.month)); g.ddd = g.dddd = _.cache(_.process(g.ctoken("sun mon tue wed thu fri sat"), function (s) { return function () { this.weekday = s; }; } )); g.day = _fn(g.d, g.dd); g.month = _fn(g.M, g.MMM); g.year = _fn(g.yyyy, g.yy); g.mdy = _setfn(g.ddd, g.month, g.day, g.year); g.ymd = _setfn(g.ddd, g.year, g.month, g.day); g.dmy = _setfn(g.ddd, g.day, g.month, g.year); g.date = function (s) { return ((g[Date.CultureInfo.dateElementOrder] || g.mdy).call(this, s)); }; }, relative: function () { // relative date / time expressions g.orientation = _.process(g.ctoken("past future"), function (s) { return function () { this.orient = s; }; } ); g.operator = _.process(g.ctoken("add subtract"), function (s) { return function () { this.operator = s; }; } ); g.rday = _.process(g.ctoken("yesterday tomorrow today now"), t.rday); g.unit = _.process(g.ctoken("second minute hour day week month year"), function (s) { return function () { this.unit = s; }; } ); } }; g.buildGrammarFormats = function () { // these need to be rebuilt every time the language changes. _C = {}; grammarFormats.timeFormats(); grammarFormats.dateFormats(); grammarFormats.relative(); g.value = _.process(_.rtoken(/^([-+]?\d+)?(st|nd|rd|th)?/), function (s) { return function () { this.value = s.replace(/\D/g, ""); }; } ); g.expression = _.set([g.rday, g.operator, g.value, g.unit, g.orientation, g.ddd, g.MMM ]); g.format = _.process(_.many( _.any( // translate format specifiers into grammar rules _.process( _.rtoken(/^(dd?d?d?(?!e)|MM?M?M?|yy?y?y?|hh?|HH?|mm?|ss?|tt?|zz?z?)/), function (fmt) { if (g[fmt]) { return g[fmt]; } else { throw $D.Parsing.Exception(fmt); } } ), // translate separator tokens into token rules _.process(_.rtoken(/^[^dMyhHmstz]+/), // all legal separators function (s) { return _.ignore(_.stoken(s)); } ) ) ), // construct the parser ... function (rules) { return _.process(_.each.apply(null, rules), t.finishExact); } ); // starting rule for general purpose grammar g._start = _.process(_.set([ g.date, g.time, g.expression ], g.generalDelimiter, g.whiteSpace), t.finish); }; g.buildGrammarFormats(); // parsing date format specifiers - ex: "h:m:s tt" // this little guy will generate a custom parser based // on the format string, ex: g.format("h:m:s tt") // check for these formats first g._formats = g.formats([ "\"yyyy-MM-ddTHH:mm:ssZ\"", "yyyy-MM-ddTHH:mm:ss.sz", "yyyy-MM-ddTHH:mm:ssZ", "yyyy-MM-ddTHH:mm:ssz", "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-ddTHH:mmZ", "yyyy-MM-ddTHH:mmz", "yyyy-MM-ddTHH:mm", "ddd, MMM dd, yyyy H:mm:ss tt", "ddd MMM d yyyy HH:mm:ss zzz", "MMddyyyy", "ddMMyyyy", "Mddyyyy", "ddMyyyy", "Mdyyyy", "dMyyyy", "yyyy", "Mdyy", "dMyy", "d" ]); // real starting rule: tries selected formats first, // then general purpose rule g.start = function (s) { try { var r = g._formats.call({}, s); if (r[1].length === 0) { return r; } } catch (e) {} return g._start.call({}, s); }; }()); (function () { var $D = Date; /** * @desc Converts the specified string value into its JavaScript Date equivalent using CultureInfo specific format information. * * Example

	///////////
	// Dates //
	///////////

	// 15-Oct-2004
	var d1 = Date.parse("10/15/2004");

	// 15-Oct-2004
	var d1 = Date.parse("15-Oct-2004");

	// 15-Oct-2004
	var d1 = Date.parse("2004.10.15");

	//Fri Oct 15, 2004
	var d1 = Date.parse("Fri Oct 15, 2004");

	///////////
	// Times //
	///////////

	// Today at 10 PM.
	var d1 = Date.parse("10 PM");

	// Today at 10:30 PM.
	var d1 = Date.parse("10:30 P.M.");

	// Today at 6 AM.
	var d1 = Date.parse("06am");

	/////////////////////
	// Dates and Times //
	/////////////////////

	// 8-July-2004 @ 10:30 PM
	var d1 = Date.parse("July 8th, 2004, 10:30 PM");

	// 1-July-2004 @ 10:30 PM
	var d1 = Date.parse("2004-07-01T22:30:00");

	////////////////////
	// Relative Dates //
	////////////////////

	// Returns today's date. The string "today" is culture specific.
	var d1 = Date.parse("today");

	// Returns yesterday's date. The string "yesterday" is culture specific.
	var d1 = Date.parse("yesterday");

	// Returns the date of the next thursday.
	var d1 = Date.parse("Next thursday");

	// Returns the date of the most previous monday.
	var d1 = Date.parse("last monday");

	// Returns today's day + one year.
	var d1 = Date.parse("next year");

	///////////////
	// Date Math //
	///////////////

	// Today + 2 days
	var d1 = Date.parse("t+2");

	// Today + 2 days
	var d1 = Date.parse("today + 2 days");

	// Today + 3 months
	var d1 = Date.parse("t+3m");

	// Today - 1 year
	var d1 = Date.parse("today - 1 year");

	// Today - 1 year
	var d1 = Date.parse("t-1y"); 


	/////////////////////////////
	// Partial Dates and Times //
	/////////////////////////////

	// July 15th of this year.
	var d1 = Date.parse("July 15");

	// 15th day of current day and year.
	var d1 = Date.parse("15");

	// July 1st of current year at 10pm.
	var d1 = Date.parse("7/1 10pm");
	
* * @param {String} The string value to convert into a Date object [Required] * @return {Date} A Date object or null if the string cannot be converted into a Date. */ var parseUtils = { removeOrds: function (s) { ords = s.match(/\b(\d+)(?:st|nd|rd|th)\b/); // find ordinal matches s = ((ords && ords.length === 2) ? s.replace(ords[0], ords[1]) : s); return s; }, grammarParser: function (s) { var r = null; try { r = $D.Grammar.start.call({}, s.replace(/^\s*(\S*(\s+\S+)*)\s*$/, "$1")); } catch (e) { return null; } return ((r[1].length === 0) ? r[0] : null); }, nativeFallback: function(s) { var t; try { // ok we haven't parsed it, last ditch attempt with the built-in parser. t = Date._parse(s); return (t || t === 0) ? new Date(t) : null; } catch (e) { return null; } } }; function parse (s) { var d; if (!s) { return null; } if (s instanceof Date) { return s.clone(); } if (s.length >= 4 && s.charAt(0) !== "0" && s.charAt(0) !== "+"&& s.charAt(0) !== "-") { // ie: 2004 will pass, 0800 won't. // Start with specific formats d = $D.Parsing.ISO.parse(s) || $D.Parsing.Numeric.parse(s); } if (d instanceof Date && !isNaN(d.getTime())) { return d; } else { // find ordinal dates (1st, 3rd, 8th, etc and remove them as they cause parsing issues) s = $D.Parsing.Normalizer.parse(parseUtils.removeOrds(s)); d = parseUtils.grammarParser(s); if (d !== null) { return d; } else { return parseUtils.nativeFallback(s); } } } if (!$D._parse) { $D._parse = $D.parse; } $D.parse = parse; Date.getParseFunction = function (fx) { var fns = Date.Grammar.allformats(fx); return function (s) { var r = null; for (var i = 0; i < fns.length; i++) { try { r = fns[i].call({}, s); } catch (e) { continue; } if (r[1].length === 0) { return r[0]; } } return null; }; }; /** * Converts the specified string value into its JavaScript Date equivalent using the specified format {String} or formats {Array} and the CultureInfo specific format information. * The format of the string value must match one of the supplied formats exactly. * * Example

	// 15-Oct-2004
	var d1 = Date.parseExact("10/15/2004", "M/d/yyyy");

	// 15-Oct-2004
	var d1 = Date.parse("15-Oct-2004", "M-ddd-yyyy");

	// 15-Oct-2004
	var d1 = Date.parse("2004.10.15", "yyyy.MM.dd");

	// Multiple formats
	var d1 = Date.parseExact("10/15/2004", ["M/d/yyyy", "MMMM d, yyyy"]);
	
* * @param {String} The string value to convert into a Date object [Required]. * @param {Object} The expected format {String} or an array of expected formats {Array} of the date string [Required]. * @return {Date} A Date object or null if the string cannot be converted into a Date. */ $D.parseExact = function (s, fx) { return $D.getParseFunction(fx)(s); }; }()); (function () { var $D = Date, $P = $D.prototype, // $C = $D.CultureInfo, // not used atm p = function (s, l) { if (!l) { l = 2; } return ("000" + s).slice(l * -1); }; /** * Converts a PHP format string to Java/.NET format string. * A PHP format string can be used with ._format or .format. * A Java/.NET format string can be used with .toString(). * The .parseExact function will only accept a Java/.NET format string * * Example * var f1 = "%m/%d/%y" * var f2 = Date.normalizeFormat(f1); // "MM/dd/yy" * * new Date().format(f1); // "04/13/08" * new Date()._format(f1); // "04/13/08" * new Date().toString(f2); // "04/13/08" * * var date = Date.parseExact("04/13/08", f2); // Sun Apr 13 2008 * * @param {String} A PHP format string consisting of one or more format spcifiers. * @return {String} The PHP format converted to a Java/.NET format string. */ var normalizerSubstitutions = { "d" : "dd", "%d": "dd", "D" : "ddd", "%a": "ddd", "j" : "dddd", "l" : "dddd", "%A": "dddd", "S" : "S", "F" : "MMMM", "%B": "MMMM", "m" : "MM", "%m": "MM", "M" : "MMM", "%b": "MMM", "%h": "MMM", "n" : "M", "Y" : "yyyy", "%Y": "yyyy", "y" : "yy", "%y": "yy", "g" : "h", "%I": "h", "G" : "H", "h" : "hh", "H" : "HH", "%H": "HH", "i" : "mm", "%M": "mm", "s" : "ss", "%S": "ss", "%r": "hh:mm tt", "%R": "H:mm", "%T": "H:mm:ss", "%X": "t", "%x": "d", "%e": "d", "%D": "MM/dd/yy", "%n": "\\n", "%t": "\\t", "e" : "z", "T" : "z", "%z": "z", "%Z": "z", "Z" : "ZZ", "N" : "u", "w" : "u", "%w": "u", "W" : "W", "%V": "W" }; var normalizer = { substitutes: function (m) { return normalizerSubstitutions[m]; }, interpreted: function (m, x) { var y; switch (m) { case "%u": return x.getDay() + 1; case "z": return x.getOrdinalNumber(); case "%j": return p(x.getOrdinalNumber(), 3); case "%U": var d1 = x.clone().set({month: 0, day: 1}).addDays(-1).moveToDayOfWeek(0), d2 = x.clone().addDays(1).moveToDayOfWeek(0, -1); return (d2 < d1) ? "00" : p((d2.getOrdinalNumber() - d1.getOrdinalNumber()) / 7 + 1); case "%W": return p(x.getWeek()); case "t": return $D.getDaysInMonth(x.getFullYear(), x.getMonth()); case "o": case "%G": return x.setWeek(x.getISOWeek()).toString("yyyy"); case "%g": return x._format("%G").slice(-2); case "a": case "%p": return t("tt").toLowerCase(); case "A": return t("tt").toUpperCase(); case "u": return p(x.getMilliseconds(), 3); case "I": return (x.isDaylightSavingTime()) ? 1 : 0; case "O": return x.getUTCOffset(); case "P": y = x.getUTCOffset(); return y.substring(0, y.length - 2) + ":" + y.substring(y.length - 2); case "B": var now = new Date(); return Math.floor(((now.getHours() * 3600) + (now.getMinutes() * 60) + now.getSeconds() + (now.getTimezoneOffset() + 60) * 60) / 86.4); case "c": return x.toISOString().replace(/\"/g, ""); case "U": return $D.strtotime("now"); case "%c": return t("d") + " " + t("t"); case "%C": return Math.floor(x.getFullYear() / 100 + 1); } }, shouldOverrideDefaults: function (m) { switch (m) { case "%e": return true; default: return false; } }, parse: function (m, context) { var formatString, c = context || new Date(); formatString = normalizer.substitutes(m); if (formatString) { return formatString; } formatString = normalizer.interpreted(m, c); if (formatString) { return formatString; } else { return m; } } }; $D.normalizeFormat = function (format, context) { return format.replace(/(%|\\)?.|%%/g, function(t){ return normalizer.parse(t, context); }); }; /** * Format a local Unix timestamp according to locale settings * * Example: * Date.strftime("%m/%d/%y", new Date()); // "04/13/08" * Date.strftime("c", "2008-04-13T17:52:03Z"); // "04/13/08" * * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @param {Number|String} The number representing the number of seconds that have elapsed since January 1, 1970 (local time). * @return {String} A string representation of the current Date object. */ $D.strftime = function (format, time) { var d = Date.parse(time); return d._format(format); }; /** * Parse any textual datetime description into a Unix timestamp. * A Unix timestamp is the number of seconds that have elapsed since January 1, 1970 (midnight UTC/GMT). * * Example: * Date.strtotime("04/13/08"); // 1208044800 * Date.strtotime("1970-01-01T00:00:00Z"); // 0 * * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @param {Object} A string or date object. * @return {String} A string representation of the current Date object. */ $D.strtotime = function (time) { var d = $D.parse(time); return Math.round($D.UTC(d.getUTCFullYear(), d.getUTCMonth(), d.getUTCDate(), d.getUTCHours(), d.getUTCMinutes(), d.getUTCSeconds(), d.getUTCMilliseconds()) / 1000); }; /** * Converts the value of the current Date object to its equivalent string representation using a PHP/Unix style of date format specifiers. * Format Specifiers * Format Description Example * ------ --------------------------------------------------------------------------- ----------------------- * %a abbreviated weekday name according to the current localed "Mon" through "Sun" * %A full weekday name according to the current localed "Sunday" through "Saturday" * %b abbreviated month name according to the current localed "Jan" through "Dec" * %B full month name according to the current locale "January" through "December" * %c preferred date and time representation for the current locale "4/13/2008 12:33 PM" * %C century number (the year divided by 100 and truncated to an integer) "00" to "99" * %d day of the month as a decimal number "01" to "31" * %D same as %m/%d/%y "04/13/08" * %e day of the month as a decimal number, a single digit is preceded by a space "1" to "31" * %g like %G, but without the century "08" * %G The 4-digit year corresponding to the ISO week number (see %V). "2008" * This has the same format and value as %Y, except that if the ISO week number * belongs to the previous or next year, that year is used instead. * %h same as %b "Jan" through "Dec" * %H hour as a decimal number using a 24-hour clock. "00" to "23" * %I hour as a decimal number using a 12-hour clock. "01" to "12" * %j day of the year as a decimal number. "001" to "366" * %m month as a decimal number. "01" to "12" * %M minute as a decimal number. "00" to "59" * %n newline character "\n" * %p either "am" or "pm" according to the given time value, or the "am" or "pm" * corresponding strings for the current locale. * %r time in a.m. and p.m. notation "8:44 PM" * %R time in 24 hour notation "20:44" * %S second as a decimal number "00" to "59" * %t tab character "\t" * %T current time, equal to %H:%M:%S "12:49:11" * %u weekday as a decimal number ["1", "7"], with "1" representing Monday "1" to "7" * %U week number of the current year as a decimal number, starting with the "0" to ("52" or "53") * first Sunday as the first day of the first week * %V The ISO 8601:1988 week number of the current year as a decimal number, "00" to ("52" or "53") * range 01 to 53, where week 1 is the first week that has at least 4 days * in the current year, and with Monday as the first day of the week. * (Use %G or %g for the year component that corresponds to the week number * for the specified timestamp.) * %W week number of the current year as a decimal number, starting with the "00" to ("52" or "53") * first Monday as the first day of the first week * %w day of the week as a decimal, Sunday being "0" "0" to "6" * %x preferred date representation for the current locale without the time "4/13/2008" * %X preferred time representation for the current locale without the date "12:53:05" * %y year as a decimal number without a century "00" "99" * %Y year as a decimal number including the century "2008" * %Z time zone or name or abbreviation "UTC", "EST", "PST" * %z same as %Z * %% a literal "%" characters "%" * d Day of the month, 2 digits with leading zeros "01" to "31" * D A textual representation of a day, three letters "Mon" through "Sun" * j Day of the month without leading zeros "1" to "31" * l A full textual representation of the day of the week (lowercase "L") "Sunday" through "Saturday" * N ISO-8601 numeric representation of the day of the week (added in PHP 5.1.0) "1" (for Monday) through "7" (for Sunday) * S English ordinal suffix for the day of the month, 2 characters "st", "nd", "rd" or "th". Works well with j * w Numeric representation of the day of the week "0" (for Sunday) through "6" (for Saturday) * z The day of the year (starting from "0") "0" through "365" * W ISO-8601 week number of year, weeks starting on Monday "00" to ("52" or "53") * F A full textual representation of a month, such as January or March "January" through "December" * m Numeric representation of a month, with leading zeros "01" through "12" * M A short textual representation of a month, three letters "Jan" through "Dec" * n Numeric representation of a month, without leading zeros "1" through "12" * t Number of days in the given month "28" through "31" * L Whether it's a leap year "1" if it is a leap year, "0" otherwise * o ISO-8601 year number. This has the same value as Y, except that if the "2008" * ISO week number (W) belongs to the previous or next year, that year * is used instead. * Y A full numeric representation of a year, 4 digits "2008" * y A two digit representation of a year "08" * a Lowercase Ante meridiem and Post meridiem "am" or "pm" * A Uppercase Ante meridiem and Post meridiem "AM" or "PM" * B Swatch Internet time "000" through "999" * g 12-hour format of an hour without leading zeros "1" through "12" * G 24-hour format of an hour without leading zeros "0" through "23" * h 12-hour format of an hour with leading zeros "01" through "12" * H 24-hour format of an hour with leading zeros "00" through "23" * i Minutes with leading zeros "00" to "59" * s Seconds, with leading zeros "00" through "59" * u Milliseconds "54321" * e Timezone identifier "UTC", "EST", "PST" * I Whether or not the date is in daylight saving time (uppercase i) "1" if Daylight Saving Time, "0" otherwise * O Difference to Greenwich time (GMT) in hours "+0200", "-0600" * P Difference to Greenwich time (GMT) with colon between hours and minutes "+02:00", "-06:00" * T Timezone abbreviation "UTC", "EST", "PST" * Z Timezone offset in seconds. The offset for timezones west of UTC is "-43200" through "50400" * always negative, and for those east of UTC is always positive. * c ISO 8601 date "2004-02-12T15:19:21+00:00" * r RFC 2822 formatted date "Thu, 21 Dec 2000 16:01:07 +0200" * U Seconds since the Unix Epoch (January 1 1970 00:00:00 GMT) "0" * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @return {String} A string representation of the current Date object. */ var formatReplace = function (context) { return function (m) { var formatString, override = false; if (m.charAt(0) === "\\" || m.substring(0, 2) === "%%") { return m.replace("\\", "").replace("%%", "%"); } override = normalizer.shouldOverrideDefaults(m); formatString = $D.normalizeFormat(m, context); if (formatString) { return context.toString(formatString, override); } }; }; $P._format = function (format) { var formatter = formatReplace(this); if (!format) { return this._toString(); } else { return format.replace(/(%|\\)?.|%%/g, formatter); } }; if (!$P.format) { $P.format = $P._format; } }()); (function () { "use strict"; var gFn = function (attr) { return function () { return this[attr]; }; }; var sFn = function (attr) { return function (val) { this[attr] = val; return this; }; }; var attrs = ["years", "months", "days", "hours", "minutes", "seconds", "milliseconds"]; var addSetFuncs = function (context, attrs) { for (var i = 0; i < attrs.length ; i++) { var $a = attrs[i], $b = $a.slice(0, 1).toUpperCase() + $a.slice(1); context.prototype[$a] = 0; context.prototype["get" + $b] = gFn($a); context.prototype["set" + $b] = sFn($a); } }; /** * new TimeSpan(milliseconds); * new TimeSpan(days, hours, minutes, seconds); * new TimeSpan(days, hours, minutes, seconds, milliseconds); */ var TimeSpan = function (days, hours, minutes, seconds, milliseconds) { if (arguments.length === 1 && typeof days === "number") { var orient = (days < 0) ? -1 : +1; var millsLeft = Math.abs(days); this.setDays(Math.floor(millsLeft / 86400000) * orient); millsLeft = millsLeft % 86400000; this.setHours(Math.floor(millsLeft / 3600000) * orient); millsLeft = millsLeft % 3600000; this.setMinutes(Math.floor(millsLeft / 60000) * orient); millsLeft = millsLeft % 60000; this.setSeconds(Math.floor(millsLeft / 1000) * orient); millsLeft = millsLeft % 1000; this.setMilliseconds(millsLeft * orient); } else { this.set(days, hours, minutes, seconds, milliseconds); } this.getTotalMilliseconds = function () { return (this.getDays() * 86400000) + (this.getHours() * 3600000) + (this.getMinutes() * 60000) + (this.getSeconds() * 1000); }; this.compareTo = function (time) { var t1 = new Date(1970, 1, 1, this.getHours(), this.getMinutes(), this.getSeconds()), t2; if (time === null) { t2 = new Date(1970, 1, 1, 0, 0, 0); } else { t2 = new Date(1970, 1, 1, time.getHours(), time.getMinutes(), time.getSeconds()); } return (t1 < t2) ? -1 : (t1 > t2) ? 1 : 0; }; this.equals = function (time) { return (this.compareTo(time) === 0); }; this.add = function (time) { return (time === null) ? this : this.addSeconds(time.getTotalMilliseconds() / 1000); }; this.subtract = function (time) { return (time === null) ? this : this.addSeconds(-time.getTotalMilliseconds() / 1000); }; this.addDays = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 86400000)); }; this.addHours = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 3600000)); }; this.addMinutes = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 60000)); }; this.addSeconds = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 1000)); }; this.addMilliseconds = function (n) { return new TimeSpan(this.getTotalMilliseconds() + n); }; this.get12HourHour = function () { return (this.getHours() > 12) ? this.getHours() - 12 : (this.getHours() === 0) ? 12 : this.getHours(); }; this.getDesignator = function () { return (this.getHours() < 12) ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator; }; this.toString = function (format) { this._toString = function () { if (this.getDays() !== null && this.getDays() > 0) { return this.getDays() + "." + this.getHours() + ":" + this.p(this.getMinutes()) + ":" + this.p(this.getSeconds()); } else { return this.getHours() + ":" + this.p(this.getMinutes()) + ":" + this.p(this.getSeconds()); } }; this.p = function (s) { return (s.toString().length < 2) ? "0" + s : s; }; var me = this; return format ? format.replace(/dd?|HH?|hh?|mm?|ss?|tt?/g, function (format) { switch (format) { case "d": return me.getDays(); case "dd": return me.p(me.getDays()); case "H": return me.getHours(); case "HH": return me.p(me.getHours()); case "h": return me.get12HourHour(); case "hh": return me.p(me.get12HourHour()); case "m": return me.getMinutes(); case "mm": return me.p(me.getMinutes()); case "s": return me.getSeconds(); case "ss": return me.p(me.getSeconds()); case "t": return ((me.getHours() < 12) ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator).substring(0, 1); case "tt": return (me.getHours() < 12) ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator; } } ) : this._toString(); }; return this; }; addSetFuncs(TimeSpan, attrs.slice(2)); TimeSpan.prototype.set = function (days, hours, minutes, seconds, milliseconds){ this.setDays(days || this.getDays()); this.setHours(hours || this.getHours()); this.setMinutes(minutes || this.getMinutes()); this.setSeconds(seconds || this.getSeconds()); this.setMilliseconds(milliseconds || this.getMilliseconds()); }; /** * Gets the time of day for this date instances. * @return {TimeSpan} TimeSpan */ Date.prototype.getTimeOfDay = function () { return new TimeSpan(0, this.getHours(), this.getMinutes(), this.getSeconds(), this.getMilliseconds()); }; Date.TimeSpan = TimeSpan; if (typeof window !== "undefined" ) { // keeping API compatible for v1.x window.TimeSpan = TimeSpan; } }()); (function () { "use strict"; var attrs = ["years", "months", "days", "hours", "minutes", "seconds", "milliseconds"]; var gFn = function (attr) { return function () { return this[attr]; }; }; var sFn = function (attr) { return function (val) { this[attr] = val; return this; }; }; var addSetFuncs = function (context, attrs) { for (var i = 0; i < attrs.length ; i++) { var $a = attrs[i], $b = $a.slice(0, 1).toUpperCase() + $a.slice(1); context.prototype[$a] = 0; context.prototype["get" + $b] = gFn($a); context.prototype["set" + $b] = sFn($a); } }; var setMonthsAndYears = function (orient, d1, d2, context) { function inc() { d1.addMonths(-orient); context.months++; if (context.months === 12) { context.years++; context.months = 0; } } if (orient === +1) { while (d1 > d2) { inc(); } } else { while (d1 < d2) { inc(); } } context.months--; context.months *= orient; context.years *= orient; }; var adjustForDST = function(orient, startDate, endDate) { var hasDSTMismatch = (false === (startDate.isDaylightSavingTime() === endDate.isDaylightSavingTime())); if (hasDSTMismatch && orient === 1) { startDate.addHours(-1); } else if (hasDSTMismatch) { startDate.addHours(1); } }; /** * TimePeriod(startDate, endDate); * TimePeriod(years, months, days, hours, minutes, seconds, milliseconds); */ var TimePeriod = function (years, months, days, hours, minutes, seconds, milliseconds) { if (arguments.length === 7) { this.set(years, months, days, hours, minutes, seconds, milliseconds); } else if (arguments.length === 2 && arguments[0] instanceof Date && arguments[1] instanceof Date) { var startDate = arguments[0].clone(); var endDate = arguments[1].clone(); var orient = (startDate > endDate) ? +1 : -1; this.dates = { start: arguments[0].clone(), end: arguments[1].clone() }; setMonthsAndYears(orient, startDate, endDate, this); adjustForDST(orient, startDate, endDate); // // TODO - adjust for DST var diff = endDate - startDate; if (diff !== 0) { var ts = new TimeSpan(diff); this.set(this.years, this.months, ts.getDays(), ts.getHours(), ts.getMinutes(), ts.getSeconds(), ts.getMilliseconds()); } } return this; }; // create all the set functions. addSetFuncs(TimePeriod, attrs); TimePeriod.prototype.set = function (years, months, days, hours, minutes, seconds, milliseconds){ this.setYears(years || this.getYears()); this.setMonths(months || this.getMonths()); this.setDays(days || this.getDays()); this.setHours(hours || this.getHours()); this.setMinutes(minutes || this.getMinutes()); this.setSeconds(seconds || this.getSeconds()); this.setMilliseconds(milliseconds || this.getMilliseconds()); }; Date.TimePeriod = TimePeriod; if (typeof window !== "undefined") { // keeping API compatible for v1.x window.TimePeriod = TimePeriod; } }()); ================================================ FILE: build/date-lt-LT.js ================================================ /** * @overview datejs * @version 1.0.0-rc3 * @author Gregory Wild-Smith * @copyright 2015 Gregory Wild-Smith * @license MIT * @homepage https://github.com/abritinthebay/datejs */ /* * DateJS Culture String File * Country Code: lt-LT * Name: Lithuanian (Lithuania) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["lt-LT"] = { "name": "lt-LT", "englishName": "Lithuanian (Lithuania)", "nativeName": "lietuvių (Lietuva)", "Sunday": "sekmadienis", "Monday": "pirmadienis", "Tuesday": "antradienis", "Wednesday": "trečiadienis", "Thursday": "ketvirtadienis", "Friday": "penktadienis", "Saturday": "šeštadienis", "Sun": "Sk", "Mon": "Pr", "Tue": "An", "Wed": "Tr", "Thu": "Kt", "Fri": "Pn", "Sat": "Št", "Su": "S", "Mo": "P", "Tu": "A", "We": "T", "Th": "K", "Fr": "Pn", "Sa": "Š", "S_Sun_Initial": "S", "M_Mon_Initial": "P", "T_Tue_Initial": "A", "W_Wed_Initial": "T", "T_Thu_Initial": "K", "F_Fri_Initial": "P", "S_Sat_Initial": "Š", "January": "sausis", "February": "vasaris", "March": "kovas", "April": "balandis", "May": "gegužė", "June": "birželis", "July": "liepa", "August": "rugpjūtis", "September": "rugsėjis", "October": "spalis", "November": "lapkritis", "December": "gruodis", "Jan_Abbr": "Sau", "Feb_Abbr": "Vas", "Mar_Abbr": "Kov", "Apr_Abbr": "Bal", "May_Abbr": "Geg", "Jun_Abbr": "Bir", "Jul_Abbr": "Lie", "Aug_Abbr": "Rgp", "Sep_Abbr": "Rgs", "Oct_Abbr": "Spl", "Nov_Abbr": "Lap", "Dec_Abbr": "Grd", "AM": "", "PM": "", "firstDayOfWeek": 1, "twoDigitYearMax": 2029, "mdy": "ymd", "M/d/yyyy": "yyyy.MM.dd", "dddd, MMMM dd, yyyy": "yyyy 'm.' MMMM d 'd.'", "h:mm tt": "HH:mm", "h:mm:ss tt": "HH:mm:ss", "dddd, MMMM dd, yyyy h:mm:ss tt": "yyyy 'm.' MMMM d 'd.' HH:mm:ss", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "MMMM d 'd.'", "MMMM, yyyy": "yyyy 'm.' MMMM", "/jan(uary)?/": "sau(sis)?", "/feb(ruary)?/": "vas(aris)?", "/mar(ch)?/": "kov(as)?", "/apr(il)?/": "bal(andis)?", "/may/": "geg(užė)?", "/jun(e)?/": "bir(želis)?", "/jul(y)?/": "lie(pa)?", "/aug(ust)?/": "rugpjūtis", "/sep(t(ember)?)?/": "rugsėjis", "/oct(ober)?/": "spalis", "/nov(ember)?/": "lap(kritis)?", "/dec(ember)?/": "gruodis", "/^su(n(day)?)?/": "^s(k(kmadienis)?)?", "/^mo(n(day)?)?/": "^p(r(rmadienis)?)?", "/^tu(e(s(day)?)?)?/": "^a(n(tradienis)?)?", "/^we(d(nesday)?)?/": "^t(r(ečiadienis)?)?", "/^th(u(r(s(day)?)?)?)?/": "^k(t(tvirtadienis)?)?", "/^fr(i(day)?)?/": "^penktadienis", "/^sa(t(urday)?)?/": "^š(t(štadienis)?)?", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "lt-LT"; /** * @overview datejs * @version 1.0.0-rc3 * @author Gregory Wild-Smith * @copyright 2015 Gregory Wild-Smith * @license MIT * @homepage https://github.com/abritinthebay/datejs */(function () { var $D = Date; var lang = Date.CultureStrings ? Date.CultureStrings.lang : null; var loggedKeys = {}; // for debug purposes. var getText = { getFromKey: function (key, countryCode) { var output; if (Date.CultureStrings && Date.CultureStrings[countryCode] && Date.CultureStrings[countryCode][key]) { output = Date.CultureStrings[countryCode][key]; } else { output = getText.buildFromDefault(key); } if (key.charAt(0) === "/") { // Assume it's a regex output = getText.buildFromRegex(key, countryCode); } return output; }, getFromObjectValues: function (obj, countryCode) { var key, output = {}; for(key in obj) { if (obj.hasOwnProperty(key)) { output[key] = getText.getFromKey(obj[key], countryCode); } } return output; }, getFromObjectKeys: function (obj, countryCode) { var key, output = {}; for(key in obj) { if (obj.hasOwnProperty(key)) { output[getText.getFromKey(key, countryCode)] = obj[key]; } } return output; }, getFromArray: function (arr, countryCode) { var output = []; for (var i=0; i < arr.length; i++){ if (i in arr) { output[i] = getText.getFromKey(arr[i], countryCode); } } return output; }, buildFromDefault: function (key) { var output, length, split, last; switch(key) { case "name": output = "en-US"; break; case "englishName": output = "English (United States)"; break; case "nativeName": output = "English (United States)"; break; case "twoDigitYearMax": output = 2049; break; case "firstDayOfWeek": output = 0; break; default: output = key; split = key.split("_"); length = split.length; if (length > 1 && key.charAt(0) !== "/") { // if the key isn't a regex and it has a split. last = split[(length - 1)].toLowerCase(); if (last === "initial" || last === "abbr") { output = split[0]; } } break; } return output; }, buildFromRegex: function (key, countryCode) { var output; if (Date.CultureStrings && Date.CultureStrings[countryCode] && Date.CultureStrings[countryCode][key]) { output = new RegExp(Date.CultureStrings[countryCode][key], "i"); } else { output = new RegExp(key.replace(new RegExp("/", "g"),""), "i"); } return output; } }; var shallowMerge = function (obj1, obj2) { for (var attrname in obj2) { if (obj2.hasOwnProperty(attrname)) { obj1[attrname] = obj2[attrname]; } } }; var __ = function (key, language) { var countryCode = (language) ? language : lang; loggedKeys[key] = key; if (typeof key === "object") { if (key instanceof Array) { return getText.getFromArray(key, countryCode); } else { return getText.getFromObjectKeys(key, countryCode); } } else { return getText.getFromKey(key, countryCode); } }; var loadI18nScript = function (code) { // paatterned after jQuery's getScript. var url = Date.Config.i18n + code + ".js"; var head = document.getElementsByTagName("head")[0] || document.documentElement; var script = document.createElement("script"); script.src = url; var completed = false; var events = { done: function (){} // placeholder function }; // Attach handlers for all browsers script.onload = script.onreadystatechange = function() { if ( !completed && (!this.readyState || this.readyState === "loaded" || this.readyState === "complete") ) { events.done(); head.removeChild(script); } }; setTimeout(function() { head.insertBefore(script, head.firstChild); }, 0); // allows return to execute first return { done: function (cb) { events.done = function() { if (cb) { setTimeout(cb,0); } }; } }; }; var buildInfo = { buildFromMethodHash: function (obj) { var key; for(key in obj) { if (obj.hasOwnProperty(key)) { obj[key] = buildInfo[obj[key]](); } } return obj; }, timeZoneDST: function () { var DST = { "CHADT": "+1345", "NZDT": "+1300", "AEDT": "+1100", "ACDT": "+1030", "AZST": "+0500", "IRDT": "+0430", "EEST": "+0300", "CEST": "+0200", "BST": "+0100", "PMDT": "-0200", "ADT": "-0300", "NDT": "-0230", "EDT": "-0400", "CDT": "-0500", "MDT": "-0600", "PDT": "-0700", "AKDT": "-0800", "HADT": "-0900" }; return __(DST); }, timeZoneStandard: function () { var standard = { "LINT": "+1400", "TOT": "+1300", "CHAST": "+1245", "NZST": "+1200", "NFT": "+1130", "SBT": "+1100", "AEST": "+1000", "ACST": "+0930", "JST": "+0900", "CWST": "+0845", "CT": "+0800", "ICT": "+0700", "MMT": "+0630", "BST": "+0600", "NPT": "+0545", "IST": "+0530", "PKT": "+0500", "AFT": "+0430", "MSK": "+0400", "IRST": "+0330", "FET": "+0300", "EET": "+0200", "CET": "+0100", "GMT": "+0000", "UTC": "+0000", "CVT": "-0100", "GST": "-0200", "BRT": "-0300", "NST": "-0330", "AST": "-0400", "EST": "-0500", "CST": "-0600", "MST": "-0700", "PST": "-0800", "AKST": "-0900", "MIT": "-0930", "HST": "-1000", "SST": "-1100", "BIT": "-1200" }; return __(standard); }, timeZones: function (data) { var zone; data.timezones = []; for (zone in data.abbreviatedTimeZoneStandard) { if (data.abbreviatedTimeZoneStandard.hasOwnProperty(zone)) { data.timezones.push({ name: zone, offset: data.abbreviatedTimeZoneStandard[zone]}); } } for (zone in data.abbreviatedTimeZoneDST) { if (data.abbreviatedTimeZoneDST.hasOwnProperty(zone)) { data.timezones.push({ name: zone, offset: data.abbreviatedTimeZoneDST[zone], dst: true}); } } return data.timezones; }, days: function () { return __(["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"]); }, dayAbbr: function () { return __(["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"]); }, dayShortNames: function () { return __(["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"]); }, dayFirstLetters: function () { return __(["S_Sun_Initial", "M_Mon_Initial", "T_Tues_Initial", "W_Wed_Initial", "T_Thu_Initial", "F_Fri_Initial", "S_Sat_Initial"]); }, months: function () { return __(["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"]); }, monthAbbr: function () { return __(["Jan_Abbr", "Feb_Abbr", "Mar_Abbr", "Apr_Abbr", "May_Abbr", "Jun_Abbr", "Jul_Abbr", "Aug_Abbr", "Sep_Abbr", "Oct_Abbr", "Nov_Abbr", "Dec_Abbr"]); }, formatPatterns: function () { return getText.getFromObjectValues({ shortDate: "M/d/yyyy", longDate: "dddd, MMMM dd, yyyy", shortTime: "h:mm tt", longTime: "h:mm:ss tt", fullDateTime: "dddd, MMMM dd, yyyy h:mm:ss tt", sortableDateTime: "yyyy-MM-ddTHH:mm:ss", universalSortableDateTime: "yyyy-MM-dd HH:mm:ssZ", rfc1123: "ddd, dd MMM yyyy HH:mm:ss", monthDay: "MMMM dd", yearMonth: "MMMM, yyyy" }, Date.i18n.currentLanguage()); }, regex: function () { return getText.getFromObjectValues({ inTheMorning: "/( in the )(morn(ing)?)\\b/", thisMorning: "/(this )(morn(ing)?)\\b/", amThisMorning: "/(\b\\d(am)? )(this )(morn(ing)?)/", inTheEvening: "/( in the )(even(ing)?)\\b/", thisEvening: "/(this )(even(ing)?)\\b/", pmThisEvening: "/(\b\\d(pm)? )(this )(even(ing)?)/", jan: "/jan(uary)?/", feb: "/feb(ruary)?/", mar: "/mar(ch)?/", apr: "/apr(il)?/", may: "/may/", jun: "/jun(e)?/", jul: "/jul(y)?/", aug: "/aug(ust)?/", sep: "/sep(t(ember)?)?/", oct: "/oct(ober)?/", nov: "/nov(ember)?/", dec: "/dec(ember)?/", sun: "/^su(n(day)?)?/", mon: "/^mo(n(day)?)?/", tue: "/^tu(e(s(day)?)?)?/", wed: "/^we(d(nesday)?)?/", thu: "/^th(u(r(s(day)?)?)?)?/", fri: "/fr(i(day)?)?/", sat: "/^sa(t(urday)?)?/", future: "/^next/", past: "/^last|past|prev(ious)?/", add: "/^(\\+|aft(er)?|from|hence)/", subtract: "/^(\\-|bef(ore)?|ago)/", yesterday: "/^yes(terday)?/", today: "/^t(od(ay)?)?/", tomorrow: "/^tom(orrow)?/", now: "/^n(ow)?/", millisecond: "/^ms|milli(second)?s?/", second: "/^sec(ond)?s?/", minute: "/^mn|min(ute)?s?/", hour: "/^h(our)?s?/", week: "/^w(eek)?s?/", month: "/^m(onth)?s?/", day: "/^d(ay)?s?/", year: "/^y(ear)?s?/", shortMeridian: "/^(a|p)/", longMeridian: "/^(a\\.?m?\\.?|p\\.?m?\\.?)/", timezone: "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/", ordinalSuffix: "/^\\s*(st|nd|rd|th)/", timeContext: "/^\\s*(\\:|a(?!u|p)|p)/" }, Date.i18n.currentLanguage()); } }; var CultureInfo = function () { var info = getText.getFromObjectValues({ name: "name", englishName: "englishName", nativeName: "nativeName", amDesignator: "AM", pmDesignator: "PM", firstDayOfWeek: "firstDayOfWeek", twoDigitYearMax: "twoDigitYearMax", dateElementOrder: "mdy" }, Date.i18n.currentLanguage()); var constructedInfo = buildInfo.buildFromMethodHash({ dayNames: "days", abbreviatedDayNames: "dayAbbr", shortestDayNames: "dayShortNames", firstLetterDayNames: "dayFirstLetters", monthNames: "months", abbreviatedMonthNames: "monthAbbr", formatPatterns: "formatPatterns", regexPatterns: "regex", abbreviatedTimeZoneDST: "timeZoneDST", abbreviatedTimeZoneStandard: "timeZoneStandard" }); shallowMerge(info, constructedInfo); buildInfo.timeZones(info); return info; }; $D.i18n = { __: function (key, lang) { return __(key, lang); }, currentLanguage: function () { return lang || "en-US"; }, setLanguage: function (code, force, cb) { var async = false; if (force || code === "en-US" || (!!Date.CultureStrings && !!Date.CultureStrings[code])) { lang = code; Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings.lang = code; Date.CultureInfo = new CultureInfo(); } else { if (!(!!Date.CultureStrings && !!Date.CultureStrings[code])) { if (typeof exports !== "undefined" && this.exports !== exports) { // we're in a Node enviroment, load it using require try { require("../i18n/" + code + ".js"); lang = code; Date.CultureStrings.lang = code; Date.CultureInfo = new CultureInfo(); } catch (e) { // var str = "The language for '" + code + "' could not be loaded by Node. It likely does not exist."; throw new Error("The DateJS IETF language tag '" + code + "' could not be loaded by Node. It likely does not exist."); } } else if (Date.Config && Date.Config.i18n) { // we know the location of the files, so lets load them async = true; loadI18nScript(code).done(function(){ lang = code; Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings.lang = code; Date.CultureInfo = new CultureInfo(); $D.Parsing.Normalizer.buildReplaceData(); // because this is async if ($D.Grammar) { $D.Grammar.buildGrammarFormats(); // so we can parse those strings... } if (cb) { setTimeout(cb,0); } }); } else { Date.console.error("The DateJS IETF language tag '" + code + "' is not available and has not been loaded."); return false; } } } $D.Parsing.Normalizer.buildReplaceData(); // rebuild normalizer strings if ($D.Grammar) { $D.Grammar.buildGrammarFormats(); // so we can parse those strings... } if (!async && cb) { setTimeout(cb,0); } }, getLoggedKeys: function () { return loggedKeys; }, updateCultureInfo: function () { Date.CultureInfo = new CultureInfo(); } }; $D.i18n.updateCultureInfo(); // run automatically }()); (function () { var $D = Date, $P = $D.prototype, p = function (s, l) { if (!l) { l = 2; } return ("000" + s).slice(l * -1); }; if (typeof window !== "undefined" && typeof window.console !== "undefined" && typeof window.console.log !== "undefined") { $D.console = console; // used only to raise non-critical errors if available } else { // set mock so we don't give errors. $D.console = { log: function(){}, error: function(){} }; } $D.Config = $D.Config || {}; $D.initOverloads = function() { /** * Overload of Date.now. Allows an alternate call for Date.now where it returns the * current Date as an object rather than just milliseconds since the Unix Epoch. * * Also provides an implementation of now() for browsers (IE<9) that don't have it. * * Backwards compatible so with work with either: * Date.now() [returns ms] * or * Date.now(true) [returns Date] */ if (!$D.now) { $D._now = function now() { return new Date().getTime(); }; } else if (!$D._now) { $D._now = $D.now; } $D.now = function (returnObj) { if (returnObj) { return $D.present(); } else { return $D._now(); } }; if ( !$P.toISOString ) { $P.toISOString = function() { return this.getUTCFullYear() + "-" + p(this.getUTCMonth() + 1) + "-" + p(this.getUTCDate()) + "T" + p(this.getUTCHours()) + ":" + p(this.getUTCMinutes()) + ":" + p(this.getUTCSeconds()) + "." + String( (this.getUTCMilliseconds()/1000).toFixed(3)).slice(2, 5) + "Z"; }; } // private if ( $P._toString === undefined ){ $P._toString = $P.toString; } }; $D.initOverloads(); /** * Gets a date that is set to the current date. The time is set to the start of the day (00:00 or 12:00 AM). * @return {Date} The current date. */ $D.today = function () { return new Date().clearTime(); }; /** * Gets a date that is set to the current date and time (same as new Date, but chainable) * @return {Date} The current date. */ $D.present = function () { return new Date(); }; /** * Compares the first date to the second date and returns an number indication of their relative values. * @param {Date} First Date object to compare [Required]. * @param {Date} Second Date object to compare to [Required]. * @return {Number} -1 = date1 is lessthan date2. 0 = values are equal. 1 = date1 is greaterthan date2. */ $D.compare = function (date1, date2) { if (isNaN(date1) || isNaN(date2)) { throw new Error(date1 + " - " + date2); } else if (date1 instanceof Date && date2 instanceof Date) { return (date1 < date2) ? -1 : (date1 > date2) ? 1 : 0; } else { throw new TypeError(date1 + " - " + date2); } }; /** * Compares the first Date object to the second Date object and returns true if they are equal. * @param {Date} First Date object to compare [Required] * @param {Date} Second Date object to compare to [Required] * @return {Boolean} true if dates are equal. false if they are not equal. */ $D.equals = function (date1, date2) { return (date1.compareTo(date2) === 0); }; /** * Gets the language appropriate day name when given the day number(0-6) * eg - 0 == Sunday * @return {String} The day name */ $D.getDayName = function (n) { return Date.CultureInfo.dayNames[n]; }; /** * Gets the day number (0-6) if given a CultureInfo specific string which is a valid dayName, abbreviatedDayName or shortestDayName (two char). * @param {String} The name of the day (eg. "Monday, "Mon", "tuesday", "tue", "We", "we"). * @return {Number} The day number */ $D.getDayNumberFromName = function (name) { var n = Date.CultureInfo.dayNames, m = Date.CultureInfo.abbreviatedDayNames, o = Date.CultureInfo.shortestDayNames, s = name.toLowerCase(); for (var i = 0; i < n.length; i++) { if (n[i].toLowerCase() === s || m[i].toLowerCase() === s || o[i].toLowerCase() === s) { return i; } } return -1; }; /** * Gets the month number (0-11) if given a Culture Info specific string which is a valid monthName or abbreviatedMonthName. * @param {String} The name of the month (eg. "February, "Feb", "october", "oct"). * @return {Number} The day number */ $D.getMonthNumberFromName = function (name) { var n = Date.CultureInfo.monthNames, m = Date.CultureInfo.abbreviatedMonthNames, s = name.toLowerCase(); for (var i = 0; i < n.length; i++) { if (n[i].toLowerCase() === s || m[i].toLowerCase() === s) { return i; } } return -1; }; /** * Gets the language appropriate month name when given the month number(0-11) * eg - 0 == January * @return {String} The month name */ $D.getMonthName = function (n) { return Date.CultureInfo.monthNames[n]; }; /** * Determines if the current date instance is within a LeapYear. * @param {Number} The year. * @return {Boolean} true if date is within a LeapYear, otherwise false. */ $D.isLeapYear = function (year) { return ((year % 4 === 0 && year % 100 !== 0) || year % 400 === 0); }; /** * Gets the number of days in the month, given a year and month value. Automatically corrects for LeapYear. * @param {Number} The year. * @param {Number} The month (0-11). * @return {Number} The number of days in the month. */ $D.getDaysInMonth = function (year, month) { if (!month && $D.validateMonth(year)) { month = year; year = Date.today().getFullYear(); } return [31, ($D.isLeapYear(year) ? 29 : 28), 31, 30, 31, 30, 31, 31, 30, 31, 30, 31][month]; }; $P.getDaysInMonth = function () { return $D.getDaysInMonth(this.getFullYear(), this.getMonth()); }; $D.getTimezoneAbbreviation = function (offset, dst) { var p, n = (dst || false) ? Date.CultureInfo.abbreviatedTimeZoneDST : Date.CultureInfo.abbreviatedTimeZoneStandard; for (p in n) { if (n.hasOwnProperty(p)) { if (n[p] === offset) { return p; } } } return null; }; $D.getTimezoneOffset = function (name, dst) { var i, a =[], z = Date.CultureInfo.timezones; if (!name) { name = (new Date()).getTimezone();} for (i = 0; i < z.length; i++) { if (z[i].name === name.toUpperCase()) { a.push(i); } } if (!z[a[0]]) { return null; } if (a.length === 1 || !dst) { return z[a[0]].offset; } else { for (i=0; i < a.length; i++) { if (z[a[i]].dst) { return z[a[i]].offset; } } } }; $D.getQuarter = function (d) { d = d || new Date(); // If no date supplied, use today var q = [1,2,3,4]; return q[Math.floor(d.getMonth() / 3)]; // ~~~ is a bitwise op. Faster than Math.floor }; $D.getDaysLeftInQuarter = function (d) { d = d || new Date(); var qEnd = new Date(d); qEnd.setMonth(qEnd.getMonth() + 3 - qEnd.getMonth() % 3, 0); return Math.floor((qEnd - d) / 8.64e7); }; // private var validate = function (n, min, max, name) { name = name ? name : "Object"; if (typeof n === "undefined") { return false; } else if (typeof n !== "number") { throw new TypeError(n + " is not a Number."); } else if (n < min || n > max) { // As failing validation is *not* an exceptional circumstance // lets not throw a RangeError Exception here. // It's semantically correct but it's not sensible. return false; } return true; }; /** * Validates the number is within an acceptable range for milliseconds [0-999]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateMillisecond = function (value) { return validate(value, 0, 999, "millisecond"); }; /** * Validates the number is within an acceptable range for seconds [0-59]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateSecond = function (value) { return validate(value, 0, 59, "second"); }; /** * Validates the number is within an acceptable range for minutes [0-59]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateMinute = function (value) { return validate(value, 0, 59, "minute"); }; /** * Validates the number is within an acceptable range for hours [0-23]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateHour = function (value) { return validate(value, 0, 23, "hour"); }; /** * Validates the number is within an acceptable range for the days in a month [0-MaxDaysInMonth]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateDay = function (value, year, month) { if (year === undefined || year === null || month === undefined || month === null) { return false;} return validate(value, 1, $D.getDaysInMonth(year, month), "day"); }; /** * Validates the number is within an acceptable range for months [0-11]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateWeek = function (value) { return validate(value, 0, 53, "week"); }; /** * Validates the number is within an acceptable range for months [0-11]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateMonth = function (value) { return validate(value, 0, 11, "month"); }; /** * Validates the number is within an acceptable range for years. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateYear = function (value) { /** * Per ECMAScript spec the range of times supported by Date objects is * exactly -100,000,000 days to +100,000,000 days measured relative to * midnight at the beginning of 01 January, 1970 UTC. * This gives a range of 8,640,000,000,000,000 milliseconds to either * side of 01 January, 1970 UTC. * * Earliest possible date: Tue, 20 Apr 271,822 B.C. 00:00:00 UTC * Latest possible date: Sat, 13 Sep 275,760 00:00:00 UTC */ return validate(value, -271822, 275760, "year"); }; $D.validateTimezone = function(value) { var timezones = {"ACDT":1,"ACST":1,"ACT":1,"ADT":1,"AEDT":1,"AEST":1,"AFT":1,"AKDT":1,"AKST":1,"AMST":1,"AMT":1,"ART":1,"AST":1,"AWDT":1,"AWST":1,"AZOST":1,"AZT":1,"BDT":1,"BIOT":1,"BIT":1,"BOT":1,"BRT":1,"BST":1,"BTT":1,"CAT":1,"CCT":1,"CDT":1,"CEDT":1,"CEST":1,"CET":1,"CHADT":1,"CHAST":1,"CHOT":1,"ChST":1,"CHUT":1,"CIST":1,"CIT":1,"CKT":1,"CLST":1,"CLT":1,"COST":1,"COT":1,"CST":1,"CT":1,"CVT":1,"CWST":1,"CXT":1,"DAVT":1,"DDUT":1,"DFT":1,"EASST":1,"EAST":1,"EAT":1,"ECT":1,"EDT":1,"EEDT":1,"EEST":1,"EET":1,"EGST":1,"EGT":1,"EIT":1,"EST":1,"FET":1,"FJT":1,"FKST":1,"FKT":1,"FNT":1,"GALT":1,"GAMT":1,"GET":1,"GFT":1,"GILT":1,"GIT":1,"GMT":1,"GST":1,"GYT":1,"HADT":1,"HAEC":1,"HAST":1,"HKT":1,"HMT":1,"HOVT":1,"HST":1,"ICT":1,"IDT":1,"IOT":1,"IRDT":1,"IRKT":1,"IRST":1,"IST":1,"JST":1,"KGT":1,"KOST":1,"KRAT":1,"KST":1,"LHST":1,"LINT":1,"MAGT":1,"MART":1,"MAWT":1,"MDT":1,"MET":1,"MEST":1,"MHT":1,"MIST":1,"MIT":1,"MMT":1,"MSK":1,"MST":1,"MUT":1,"MVT":1,"MYT":1,"NCT":1,"NDT":1,"NFT":1,"NPT":1,"NST":1,"NT":1,"NUT":1,"NZDT":1,"NZST":1,"OMST":1,"ORAT":1,"PDT":1,"PET":1,"PETT":1,"PGT":1,"PHOT":1,"PHT":1,"PKT":1,"PMDT":1,"PMST":1,"PONT":1,"PST":1,"PYST":1,"PYT":1,"RET":1,"ROTT":1,"SAKT":1,"SAMT":1,"SAST":1,"SBT":1,"SCT":1,"SGT":1,"SLST":1,"SRT":1,"SST":1,"SYOT":1,"TAHT":1,"THA":1,"TFT":1,"TJT":1,"TKT":1,"TLT":1,"TMT":1,"TOT":1,"TVT":1,"UCT":1,"ULAT":1,"UTC":1,"UYST":1,"UYT":1,"UZT":1,"VET":1,"VLAT":1,"VOLT":1,"VOST":1,"VUT":1,"WAKT":1,"WAST":1,"WAT":1,"WEDT":1,"WEST":1,"WET":1,"WST":1,"YAKT":1,"YEKT":1,"Z":1}; return (timezones[value] === 1); }; $D.validateTimezoneOffset= function(value) { // timezones go from +14hrs to -12hrs, the +X hours are negative offsets. return (value > -841 && value < 721); }; }()); (function () { var $D = Date, $P = $D.prototype, p = function (s, l) { if (!l) { l = 2; } return ("000" + s).slice(l * -1); }; var validateConfigObject = function (obj) { var result = {}, self = this, prop, testFunc; testFunc = function (prop, func, value) { if (prop === "day") { var month = (obj.month !== undefined) ? obj.month : self.getMonth(); var year = (obj.year !== undefined) ? obj.year : self.getFullYear(); return $D[func](value, year, month); } else { return $D[func](value); } }; for (prop in obj) { if (Object.prototype.hasOwnProperty.call(obj, prop)) { var func = "validate" + prop.charAt(0).toUpperCase() + prop.slice(1); if ($D[func] && obj[prop] !== null && testFunc(prop, func, obj[prop])) { result[prop] = obj[prop]; } } } return result; }; /** * Resets the time of this Date object to 12:00 AM (00:00), which is the start of the day. * @param {Boolean} .clone() this date instance before clearing Time * @return {Date} this */ $P.clearTime = function () { this.setHours(0); this.setMinutes(0); this.setSeconds(0); this.setMilliseconds(0); return this; }; /** * Resets the time of this Date object to the current time ('now'). * @return {Date} this */ $P.setTimeToNow = function () { var n = new Date(); this.setHours(n.getHours()); this.setMinutes(n.getMinutes()); this.setSeconds(n.getSeconds()); this.setMilliseconds(n.getMilliseconds()); return this; }; /** * Returns a new Date object that is an exact date and time copy of the original instance. * @return {Date} A new Date instance */ $P.clone = function () { return new Date(this.getTime()); }; /** * Compares this instance to a Date object and returns an number indication of their relative values. * @param {Date} Date object to compare [Required] * @return {Number} -1 = this is lessthan date. 0 = values are equal. 1 = this is greaterthan date. */ $P.compareTo = function (date) { return Date.compare(this, date); }; /** * Compares this instance to another Date object and returns true if they are equal. * @param {Date} Date object to compare. If no date to compare, new Date() [now] is used. * @return {Boolean} true if dates are equal. false if they are not equal. */ $P.equals = function (date) { return Date.equals(this, (date !== undefined ? date : new Date())); }; /** * Determines if this instance is between a range of two dates or equal to either the start or end dates. * @param {Date} Start of range [Required] * @param {Date} End of range [Required] * @return {Boolean} true is this is between or equal to the start and end dates, else false */ $P.between = function (start, end) { return this.getTime() >= start.getTime() && this.getTime() <= end.getTime(); }; /** * Determines if this date occurs after the date to compare to. * @param {Date} Date object to compare. If no date to compare, new Date() ("now") is used. * @return {Boolean} true if this date instance is greater than the date to compare to (or "now"), otherwise false. */ $P.isAfter = function (date) { return this.compareTo(date || new Date()) === 1; }; /** * Determines if this date occurs before the date to compare to. * @param {Date} Date object to compare. If no date to compare, new Date() ("now") is used. * @return {Boolean} true if this date instance is less than the date to compare to (or "now"). */ $P.isBefore = function (date) { return (this.compareTo(date || new Date()) === -1); }; /** * Determines if the current Date instance occurs today. * @return {Boolean} true if this date instance is 'today', otherwise false. */ /** * Determines if the current Date instance occurs on the same Date as the supplied 'date'. * If no 'date' to compare to is provided, the current Date instance is compared to 'today'. * @param {date} Date object to compare. If no date to compare, the current Date ("now") is used. * @return {Boolean} true if this Date instance occurs on the same Day as the supplied 'date'. */ $P.isToday = $P.isSameDay = function (date) { return this.clone().clearTime().equals((date || new Date()).clone().clearTime()); }; /** * Adds the specified number of milliseconds to this instance. * @param {Number} The number of milliseconds to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addMilliseconds = function (value) { if (!value) { return this; } this.setTime(this.getTime() + value * 1); return this; }; /** * Adds the specified number of seconds to this instance. * @param {Number} The number of seconds to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addSeconds = function (value) { if (!value) { return this; } return this.addMilliseconds(value * 1000); }; /** * Adds the specified number of seconds to this instance. * @param {Number} The number of seconds to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addMinutes = function (value) { if (!value) { return this; } return this.addMilliseconds(value * 60000); // 60*1000 }; /** * Adds the specified number of hours to this instance. * @param {Number} The number of hours to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addHours = function (value) { if (!value) { return this; } return this.addMilliseconds(value * 3600000); // 60*60*1000 }; /** * Adds the specified number of days to this instance. * @param {Number} The number of days to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addDays = function (value) { if (!value) { return this; } this.setDate(this.getDate() + value * 1); return this; }; /** * Adds the specified number of weekdays (ie - not sat or sun) to this instance. * @param {Number} The number of days to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addWeekdays = function (value) { if (!value) { return this; } var day = this.getDay(); var weeks = (Math.ceil(Math.abs(value)/7)); if (day === 0 || day === 6) { if (value > 0) { this.next().monday(); this.addDays(-1); day = this.getDay(); } } if (value < 0) { while (value < 0) { this.addDays(-1); day = this.getDay(); if (day !== 0 && day !== 6) { value++; } } return this; } else if (value > 5 || (6-day) <= value) { value = value + (weeks * 2); } return this.addDays(value); }; /** * Adds the specified number of weeks to this instance. * @param {Number} The number of weeks to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addWeeks = function (value) { if (!value) { return this; } return this.addDays(value * 7); }; /** * Adds the specified number of months to this instance. * @param {Number} The number of months to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addMonths = function (value) { if (!value) { return this; } var n = this.getDate(); this.setDate(1); this.setMonth(this.getMonth() + value * 1); this.setDate(Math.min(n, $D.getDaysInMonth(this.getFullYear(), this.getMonth()))); return this; }; $P.addQuarters = function (value) { if (!value) { return this; } // note this will take you to the same point in the quarter as you are now. // i.e. - if you are 15 days into the quarter you'll be 15 days into the resulting one. // bonus: this allows adding fractional quarters return this.addMonths(value * 3); }; /** * Adds the specified number of years to this instance. * @param {Number} The number of years to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addYears = function (value) { if (!value) { return this; } return this.addMonths(value * 12); }; /** * Adds (or subtracts) to the value of the years, months, weeks, days, hours, minutes, seconds, milliseconds of the date instance using given configuration object. Positive and Negative values allowed. * Example

	Date.today().add( { days: 1, months: 1 } )

	new Date().add( { years: -1 } )
	
* @param {Object} Configuration object containing attributes (months, days, etc.) * @return {Date} this */ $P.add = function (config) { if (typeof config === "number") { this._orient = config; return this; } var x = config; if (x.day) { // If we should be a different date than today (eg: for 'tomorrow -1d', etc). // Should only effect parsing, not direct usage (eg, Finish and FinishExact) if ((x.day - this.getDate()) !== 0) { this.setDate(x.day); } } if (x.milliseconds) { this.addMilliseconds(x.milliseconds); } if (x.seconds) { this.addSeconds(x.seconds); } if (x.minutes) { this.addMinutes(x.minutes); } if (x.hours) { this.addHours(x.hours); } if (x.weeks) { this.addWeeks(x.weeks); } if (x.months) { this.addMonths(x.months); } if (x.years) { this.addYears(x.years); } if (x.days) { this.addDays(x.days); } return this; }; /** * Get the week number. Week one (1) is the week which contains the first Thursday of the year. Monday is considered the first day of the week. * The .getWeek() function does NOT convert the date to UTC. The local datetime is used. * Please use .getISOWeek() to get the week of the UTC converted date. * @return {Number} 1 to 53 */ $P.getWeek = function (utc) { // Create a copy of this date object var self, target = new Date(this.valueOf()); if (utc) { target.addMinutes(target.getTimezoneOffset()); self = target.clone(); } else { self = this; } // ISO week date weeks start on monday // so correct the day number var dayNr = (self.getDay() + 6) % 7; // ISO 8601 states that week 1 is the week // with the first thursday of that year. // Set the target date to the thursday in the target week target.setDate(target.getDate() - dayNr + 3); // Store the millisecond value of the target date var firstThursday = target.valueOf(); // Set the target to the first thursday of the year // First set the target to january first target.setMonth(0, 1); // Not a thursday? Correct the date to the next thursday if (target.getDay() !== 4) { target.setMonth(0, 1 + ((4 - target.getDay()) + 7) % 7); } // The weeknumber is the number of weeks between the // first thursday of the year and the thursday in the target week return 1 + Math.ceil((firstThursday - target) / 604800000); // 604800000 = 7 * 24 * 3600 * 1000 }; /** * Get the ISO 8601 week number. Week one ("01") is the week which contains the first Thursday of the year. Monday is considered the first day of the week. * The .getISOWeek() function does convert the date to it's UTC value. Please use .getWeek() to get the week of the local date. * @return {String} "01" to "53" */ $P.getISOWeek = function () { return p(this.getWeek(true)); }; /** * Moves the date to Monday of the week set. Week one (1) is the week which contains the first Thursday of the year. * @param {Number} A Number (1 to 53) that represents the week of the year. * @return {Date} this */ $P.setWeek = function (n) { if ((n - this.getWeek()) === 0) { if (this.getDay() !== 1) { return this.moveToDayOfWeek(1, (this.getDay() > 1 ? -1 : 1)); } else { return this; } } else { return this.moveToDayOfWeek(1, (this.getDay() > 1 ? -1 : 1)).addWeeks(n - this.getWeek()); } }; $P.setQuarter = function (qtr) { var month = Math.abs(((qtr-1) * 3) + 1); return this.setMonth(month, 1); }; $P.getQuarter = function () { return Date.getQuarter(this); }; $P.getDaysLeftInQuarter = function () { return Date.getDaysLeftInQuarter(this); }; /** * Moves the date to the next n'th occurrence of the dayOfWeek starting from the beginning of the month. The number (-1) is a magic number and will return the last occurrence of the dayOfWeek in the month. * @param {Number} The dayOfWeek to move to * @param {Number} The n'th occurrence to move to. Use (-1) to return the last occurrence in the month * @return {Date} this */ $P.moveToNthOccurrence = function (dayOfWeek, occurrence) { if (dayOfWeek === "Weekday") { if (occurrence > 0) { this.moveToFirstDayOfMonth(); if (this.is().weekday()) { occurrence -= 1; } } else if (occurrence < 0) { this.moveToLastDayOfMonth(); if (this.is().weekday()) { occurrence += 1; } } else { return this; } return this.addWeekdays(occurrence); } var shift = 0; if (occurrence > 0) { shift = occurrence - 1; } else if (occurrence === -1) { this.moveToLastDayOfMonth(); if (this.getDay() !== dayOfWeek) { this.moveToDayOfWeek(dayOfWeek, -1); } return this; } return this.moveToFirstDayOfMonth().addDays(-1).moveToDayOfWeek(dayOfWeek, +1).addWeeks(shift); }; var moveToN = function (getFunc, addFunc, nVal) { return function (value, orient) { var diff = (value - this[getFunc]() + nVal * (orient || +1)) % nVal; return this[addFunc]((diff === 0) ? diff += nVal * (orient || +1) : diff); }; }; /** * Move to the next or last dayOfWeek based on the orient value. * @param {Number} The dayOfWeek to move to * @param {Number} Forward (+1) or Back (-1). Defaults to +1. [Optional] * @return {Date} this */ $P.moveToDayOfWeek = moveToN("getDay", "addDays", 7); /** * Move to the next or last month based on the orient value. * @param {Number} The month to move to. 0 = January, 11 = December * @param {Number} Forward (+1) or Back (-1). Defaults to +1. [Optional] * @return {Date} this */ $P.moveToMonth = moveToN("getMonth", "addMonths", 12); /** * Get the Ordinate of the current day ("th", "st", "rd"). * @return {String} */ $P.getOrdinate = function () { var num = this.getDate(); return ord(num); }; /** * Get the Ordinal day (numeric day number) of the year, adjusted for leap year. * @return {Number} 1 through 365 (366 in leap years) */ $P.getOrdinalNumber = function () { return Math.ceil((this.clone().clearTime() - new Date(this.getFullYear(), 0, 1)) / 86400000) + 1; }; /** * Get the time zone abbreviation of the current date. * @return {String} The abbreviated time zone name (e.g. "EST") */ $P.getTimezone = function () { return $D.getTimezoneAbbreviation(this.getUTCOffset(), this.isDaylightSavingTime()); }; $P.setTimezoneOffset = function (offset) { var here = this.getTimezoneOffset(), there = Number(offset) * -6 / 10; return (there || there === 0) ? this.addMinutes(there - here) : this; }; $P.setTimezone = function (offset) { return this.setTimezoneOffset($D.getTimezoneOffset(offset)); }; /** * Indicates whether Daylight Saving Time is observed in the current time zone. * @return {Boolean} true|false */ $P.hasDaylightSavingTime = function () { return (Date.today().set({month: 0, day: 1}).getTimezoneOffset() !== Date.today().set({month: 6, day: 1}).getTimezoneOffset()); }; /** * Indicates whether this Date instance is within the Daylight Saving Time range for the current time zone. * @return {Boolean} true|false */ $P.isDaylightSavingTime = function () { return Date.today().set({month: 0, day: 1}).getTimezoneOffset() !== this.getTimezoneOffset(); }; /** * Get the offset from UTC of the current date. * @return {String} The 4-character offset string prefixed with + or - (e.g. "-0500") */ $P.getUTCOffset = function (offset) { var n = (offset || this.getTimezoneOffset()) * -10 / 6, r; if (n < 0) { r = (n - 10000).toString(); return r.charAt(0) + r.substr(2); } else { r = (n + 10000).toString(); return "+" + r.substr(1); } }; /** * Returns the number of milliseconds between this date and date. * @param {Date} Defaults to now * @return {Number} The diff in milliseconds */ $P.getElapsed = function (date) { return (date || new Date()) - this; }; /** * Set the value of year, month, day, hour, minute, second, millisecond of date instance using given configuration object. * Example

	Date.today().set( { day: 20, month: 1 } )

	new Date().set( { millisecond: 0 } )
	
* * @param {Object} Configuration object containing attributes (month, day, etc.) * @return {Date} this */ $P.set = function (config) { config = validateConfigObject.call(this, config); var key; for (key in config) { if (Object.prototype.hasOwnProperty.call(config, key)) { var name = key.charAt(0).toUpperCase() + key.slice(1); var addFunc, getFunc; if (key !== "week" && key !== "month" && key !== "timezone" && key !== "timezoneOffset") { name += "s"; } addFunc = "add" + name; getFunc = "get" + name; if (key === "month") { addFunc = addFunc + "s"; } else if (key === "year"){ getFunc = "getFullYear"; } if (key !== "day" && key !== "timezone" && key !== "timezoneOffset" && key !== "week" && key !== "hour") { this[addFunc](config[key] - this[getFunc]()); } else if ( key === "timezone"|| key === "timezoneOffset" || key === "week" || key === "hour") { this["set"+name](config[key]); } } } // day has to go last because you can't validate the day without first knowing the month if (config.day) { this.addDays(config.day - this.getDate()); } return this; }; /** * Moves the date to the first day of the month. * @return {Date} this */ $P.moveToFirstDayOfMonth = function () { return this.set({ day: 1 }); }; /** * Moves the date to the last day of the month. * @return {Date} this */ $P.moveToLastDayOfMonth = function () { return this.set({ day: $D.getDaysInMonth(this.getFullYear(), this.getMonth())}); }; /** * Converts the value of the current Date object to its equivalent string representation. * Format Specifiers * CUSTOM DATE AND TIME FORMAT STRINGS * Format Description Example * ------ --------------------------------------------------------------------------- ----------------------- * s The seconds of the minute between 0-59. "0" to "59" * ss The seconds of the minute with leading zero if required. "00" to "59" * * m The minute of the hour between 0-59. "0" or "59" * mm The minute of the hour with leading zero if required. "00" or "59" * * h The hour of the day between 1-12. "1" to "12" * hh The hour of the day with leading zero if required. "01" to "12" * * H The hour of the day between 0-23. "0" to "23" * HH The hour of the day with leading zero if required. "00" to "23" * * d The day of the month between 1 and 31. "1" to "31" * dd The day of the month with leading zero if required. "01" to "31" * ddd Abbreviated day name. Date.CultureInfo.abbreviatedDayNames. "Mon" to "Sun" * dddd The full day name. Date.CultureInfo.dayNames. "Monday" to "Sunday" * * M The month of the year between 1-12. "1" to "12" * MM The month of the year with leading zero if required. "01" to "12" * MMM Abbreviated month name. Date.CultureInfo.abbreviatedMonthNames. "Jan" to "Dec" * MMMM The full month name. Date.CultureInfo.monthNames. "January" to "December" * * yy The year as a two-digit number. "99" or "08" * yyyy The full four digit year. "1999" or "2008" * * t Displays the first character of the A.M./P.M. designator. "A" or "P" * Date.CultureInfo.amDesignator or Date.CultureInfo.pmDesignator * tt Displays the A.M./P.M. designator. "AM" or "PM" * Date.CultureInfo.amDesignator or Date.CultureInfo.pmDesignator * * S The ordinal suffix ("st, "nd", "rd" or "th") of the current day. "st, "nd", "rd" or "th" * * STANDARD DATE AND TIME FORMAT STRINGS * Format Description Example *------ --------------------------------------------------------------------------- ----------------------- * d The CultureInfo shortDate Format Pattern "M/d/yyyy" * D The CultureInfo longDate Format Pattern "dddd, MMMM dd, yyyy" * F The CultureInfo fullDateTime Format Pattern "dddd, MMMM dd, yyyy h:mm:ss tt" * m The CultureInfo monthDay Format Pattern "MMMM dd" * r The CultureInfo rfc1123 Format Pattern "ddd, dd MMM yyyy HH:mm:ss GMT" * s The CultureInfo sortableDateTime Format Pattern "yyyy-MM-ddTHH:mm:ss" * t The CultureInfo shortTime Format Pattern "h:mm tt" * T The CultureInfo longTime Format Pattern "h:mm:ss tt" * u The CultureInfo universalSortableDateTime Format Pattern "yyyy-MM-dd HH:mm:ssZ" * y The CultureInfo yearMonth Format Pattern "MMMM, yyyy" * * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @return {String} A string representation of the current Date object. */ var ord = function (n) { switch (n * 1) { case 1: case 21: case 31: return "st"; case 2: case 22: return "nd"; case 3: case 23: return "rd"; default: return "th"; } }; var parseStandardFormats = function (format) { var y, c = Date.CultureInfo.formatPatterns; switch (format) { case "d": return this.toString(c.shortDate); case "D": return this.toString(c.longDate); case "F": return this.toString(c.fullDateTime); case "m": return this.toString(c.monthDay); case "r": case "R": y = this.clone().addMinutes(this.getTimezoneOffset()); return y.toString(c.rfc1123) + " GMT"; case "s": return this.toString(c.sortableDateTime); case "t": return this.toString(c.shortTime); case "T": return this.toString(c.longTime); case "u": y = this.clone().addMinutes(this.getTimezoneOffset()); return y.toString(c.universalSortableDateTime); case "y": return this.toString(c.yearMonth); default: return false; } }; var parseFormatStringsClosure = function (context) { return function (m) { if (m.charAt(0) === "\\") { return m.replace("\\", ""); } switch (m) { case "hh": return p(context.getHours() < 13 ? (context.getHours() === 0 ? 12 : context.getHours()) : (context.getHours() - 12)); case "h": return context.getHours() < 13 ? (context.getHours() === 0 ? 12 : context.getHours()) : (context.getHours() - 12); case "HH": return p(context.getHours()); case "H": return context.getHours(); case "mm": return p(context.getMinutes()); case "m": return context.getMinutes(); case "ss": return p(context.getSeconds()); case "s": return context.getSeconds(); case "yyyy": return p(context.getFullYear(), 4); case "yy": return p(context.getFullYear()); case "y": return context.getFullYear(); case "E": case "dddd": return Date.CultureInfo.dayNames[context.getDay()]; case "ddd": return Date.CultureInfo.abbreviatedDayNames[context.getDay()]; case "dd": return p(context.getDate()); case "d": return context.getDate(); case "MMMM": return Date.CultureInfo.monthNames[context.getMonth()]; case "MMM": return Date.CultureInfo.abbreviatedMonthNames[context.getMonth()]; case "MM": return p((context.getMonth() + 1)); case "M": return context.getMonth() + 1; case "t": return context.getHours() < 12 ? Date.CultureInfo.amDesignator.substring(0, 1) : Date.CultureInfo.pmDesignator.substring(0, 1); case "tt": return context.getHours() < 12 ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator; case "S": return ord(context.getDate()); case "W": return context.getWeek(); case "WW": return context.getISOWeek(); case "Q": return "Q" + context.getQuarter(); case "q": return String(context.getQuarter()); case "z": return context.getTimezone(); case "Z": case "X": return Date.getTimezoneOffset(context.getTimezone()); case "ZZ": // Timezone offset in seconds return context.getTimezoneOffset() * -60; case "u": return context.getDay(); case "L": return ($D.isLeapYear(context.getFullYear())) ? 1 : 0; case "B": // Swatch Internet Time (.beats) return "@"+((context.getUTCSeconds() + (context.getUTCMinutes()*60) + ((context.getUTCHours()+1)*3600))/86.4); default: return m; } }; }; $P.toString = function (format, ignoreStandards) { // Standard Date and Time Format Strings. Formats pulled from CultureInfo file and // may vary by culture. if (!ignoreStandards && format && format.length === 1) { output = parseStandardFormats.call(this, format); if (output) { return output; } } var parseFormatStrings = parseFormatStringsClosure(this); return format ? format.replace(/((\\)?(dd?d?d?|MM?M?M?|yy?y?y?|hh?|HH?|mm?|ss?|tt?|S|q|Q|WW?W?W?)(?![^\[]*\]))/g, parseFormatStrings).replace(/\[|\]/g, "") : this._toString(); }; }()); /************************************************************* * SugarPak - Domain Specific Language - Syntactical Sugar * *************************************************************/ (function () { var $D = Date, $P = $D.prototype, $N = Number.prototype; // private $P._orient = +1; // private $P._nth = null; // private $P._is = false; // private $P._same = false; // private $P._isSecond = false; // private $N._dateElement = "days"; /** * Moves the date to the next instance of a date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.today().next().friday();
	Date.today().next().fri();
	Date.today().next().march();
	Date.today().next().mar();
	Date.today().next().week();
	
* * @return {Date} date */ $P.next = function () { this._move = true; this._orient = +1; return this; }; /** * Creates a new Date (Date.today()) and moves the date to the next instance of the date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.next().friday();
	Date.next().fri();
	Date.next().march();
	Date.next().mar();
	Date.next().week();
	
* * @return {Date} date */ $D.next = function () { return $D.today().next(); }; /** * Moves the date to the previous instance of a date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.today().last().friday();
	Date.today().last().fri();
	Date.today().last().march();
	Date.today().last().mar();
	Date.today().last().week();
	
* * @return {Date} date */ $P.last = $P.prev = $P.previous = function () { this._move = true; this._orient = -1; return this; }; /** * Creates a new Date (Date.today()) and moves the date to the previous instance of the date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.last().friday();
	Date.last().fri();
	Date.previous().march();
	Date.prev().mar();
	Date.last().week();
	
* * @return {Date} date */ $D.last = $D.prev = $D.previous = function () { return $D.today().last(); }; /** * Performs a equality check when followed by either a month name, day name or .weekday() function. * Example

	Date.today().is().friday(); // true|false
	Date.today().is().fri();
	Date.today().is().march();
	Date.today().is().mar();
	
* * @return {Boolean} true|false */ $P.is = function () { this._is = true; return this; }; /** * Determines if two date objects occur on/in exactly the same instance of the subsequent date part function. * The function .same() must be followed by a date part function (example: .day(), .month(), .year(), etc). * * An optional Date can be passed in the date part function. If now date is passed as a parameter, 'Now' is used. * * The following example demonstrates how to determine if two dates fall on the exact same day. * * Example

	var d1 = Date.today(); // today at 00:00
	var d2 = new Date();   // exactly now.

	// Do they occur on the same day?
	d1.same().day(d2); // true
	
	// Do they occur on the same hour?
	d1.same().hour(d2); // false, unless d2 hour is '00' (midnight).
	
	// What if it's the same day, but one year apart?
	var nextYear = Date.today().add(1).year();

	d1.same().day(nextYear); // false, because the dates must occur on the exact same day. 
	
* * Scenario: Determine if a given date occurs during some week period 2 months from now. * * Example

	var future = Date.today().add(2).months();
	return someDate.same().week(future); // true|false;
	
* * @return {Boolean} true|false */ $P.same = function () { this._same = true; this._isSecond = false; return this; }; /** * Determines if the current date/time occurs during Today. Must be preceded by the .is() function. * Example

	someDate.is().today();    // true|false
	new Date().is().today();  // true
	Date.today().is().today();// true
	Date.today().add(-1).day().is().today(); // false
	
* * @return {Boolean} true|false */ $P.today = function () { return this.same().day(); }; /** * Determines if the current date is a weekday. This function must be preceded by the .is() function. * Example

	Date.today().is().weekday(); // true|false
	
* * @return {Boolean} true|false */ $P.weekday = function () { if (this._nth) { return df("Weekday").call(this); } if (this._move) { return this.addWeekdays(this._orient); } if (this._is) { this._is = false; return (!this.is().sat() && !this.is().sun()); } return false; }; /** * Determines if the current date is on the weekend. This function must be preceded by the .is() function. * Example

	Date.today().is().weekend(); // true|false
	
* * @return {Boolean} true|false */ $P.weekend = function () { if (this._is) { this._is = false; return (this.is().sat() || this.is().sun()); } return false; }; /** * Sets the Time of the current Date instance. A string "6:15 pm" or config object {hour:18, minute:15} are accepted. * Example

	// Set time to 6:15pm with a String
	Date.today().at("6:15pm");

	// Set time to 6:15pm with a config object
	Date.today().at({hour:18, minute:15});
	
* * @return {Date} date */ $P.at = function (time) { return (typeof time === "string") ? $D.parse(this.toString("d") + " " + time) : this.set(time); }; /** * Creates a new Date() and adds this (Number) to the date based on the preceding date element function (eg. second|minute|hour|day|month|year). * Example

	// Undeclared Numbers must be wrapped with parentheses. Requirment of JavaScript.
	(3).days().fromNow();
	(6).months().fromNow();

	// Declared Number variables do not require parentheses. 
	var n = 6;
	n.months().fromNow();
	
* * @return {Date} A new Date instance */ $N.fromNow = $N.after = function (date) { var c = {}; c[this._dateElement] = this; return ((!date) ? new Date() : date.clone()).add(c); }; /** * Creates a new Date() and subtract this (Number) from the date based on the preceding date element function (eg. second|minute|hour|day|month|year). * Example

	// Undeclared Numbers must be wrapped with parentheses. Requirment of JavaScript.
	(3).days().ago();
	(6).months().ago();

	// Declared Number variables do not require parentheses. 
	var n = 6;
	n.months().ago();
	
* * @return {Date} A new Date instance */ $N.ago = $N.before = function (date) { var c = {}, s = (this._dateElement[this._dateElement.length-1] !== "s") ? this._dateElement + "s" : this._dateElement; c[s] = this * -1; return ((!date) ? new Date() : date.clone()).add(c); }; // Do NOT modify the following string tokens. These tokens are used to build dynamic functions. // All culture-specific strings can be found in the CultureInfo files. var dx = ("sunday monday tuesday wednesday thursday friday saturday").split(/\s/), mx = ("january february march april may june july august september october november december").split(/\s/), px = ("Millisecond Second Minute Hour Day Week Month Year Quarter Weekday").split(/\s/), pxf = ("Milliseconds Seconds Minutes Hours Date Week Month FullYear Quarter").split(/\s/), nth = ("final first second third fourth fifth").split(/\s/), de; /** * Returns an object literal of all the date parts. * Example

	var o = new Date().toObject();
	
	// { year: 2008, month: 4, week: 20, day: 13, hour: 18, minute: 9, second: 32, millisecond: 812 }
	
	// The object properties can be referenced directly from the object.
	
	alert(o.day);  // alerts "13"
	alert(o.year); // alerts "2008"
	
* * @return {Date} An object literal representing the original date object. */ $P.toObject = function () { var o = {}; for (var i = 0; i < px.length; i++) { if (this["get" + pxf[i]]) { o[px[i].toLowerCase()] = this["get" + pxf[i]](); } } return o; }; /** * Returns a date created from an object literal. Ignores the .week property if set in the config. * Example

	var o = new Date().toObject();
	
	return Date.fromObject(o); // will return the same date. 

	var o2 = {month: 1, day: 20, hour: 18}; // birthday party!
	Date.fromObject(o2);
	
* * @return {Date} An object literal representing the original date object. */ $D.fromObject = function(config) { config.week = null; return Date.today().set(config); }; // Create day name functions and abbreviated day name functions (eg. monday(), friday(), fri()). var df = function (n) { return function () { if (this._is) { this._is = false; return this.getDay() === n; } if (this._move) { this._move = null; } if (this._nth !== null) { // If the .second() function was called earlier, remove the _orient // from the date, and then continue. // This is required because 'second' can be used in two different context. // // Example // // Date.today().add(1).second(); // Date.march().second().monday(); // // Things get crazy with the following... // Date.march().add(1).second().second().monday(); // but it works!! // if (this._isSecond) { this.addSeconds(this._orient * -1); } // make sure we reset _isSecond this._isSecond = false; var ntemp = this._nth; this._nth = null; var temp = this.clone().moveToLastDayOfMonth(); this.moveToNthOccurrence(n, ntemp); if (this > temp) { throw new RangeError($D.getDayName(n) + " does not occur " + ntemp + " times in the month of " + $D.getMonthName(temp.getMonth()) + " " + temp.getFullYear() + "."); } return this; } return this.moveToDayOfWeek(n, this._orient); }; }; var sdf = function (n) { return function () { var t = $D.today(), shift = n - t.getDay(); if (n === 0 && Date.CultureInfo.firstDayOfWeek === 1 && t.getDay() !== 0) { shift = shift + 7; } return t.addDays(shift); }; }; // Create month name functions and abbreviated month name functions (eg. january(), march(), mar()). var month_instance_functions = function (n) { return function () { if (this._is) { this._is = false; return this.getMonth() === n; } return this.moveToMonth(n, this._orient); }; }; var month_static_functions = function (n) { return function () { return $D.today().set({ month: n, day: 1 }); }; }; var processTerms = function (names, staticFunc, instanceFunc) { for (var i = 0; i < names.length; i++) { // Create constant static Name variables. $D[names[i].toUpperCase()] = $D[names[i].toUpperCase().substring(0, 3)] = i; // Create Name functions. $D[names[i]] = $D[names[i].substring(0, 3)] = staticFunc(i); // Create Name instance functions. $P[names[i]] = $P[names[i].substring(0, 3)] = instanceFunc(i); } }; processTerms(dx, sdf, df); processTerms(mx, month_static_functions, month_instance_functions); // Create date element functions and plural date element functions used with Date (eg. day(), days(), months()). var ef = function (j) { return function () { // if the .second() function was called earlier, the _orient // has alread been added. Just return this and reset _isSecond. if (this._isSecond) { this._isSecond = false; return this; } if (this._same) { this._same = this._is = false; var o1 = this.toObject(), o2 = (arguments[0] || new Date()).toObject(), v = "", k = j.toLowerCase(); // the substr trick with -1 doesn't work in IE8 or less k = (k[k.length-1] === "s") ? k.substring(0,k.length-1) : k; for (var m = (px.length - 1); m > -1; m--) { v = px[m].toLowerCase(); if (o1[v] !== o2[v]) { return false; } if (k === v) { break; } } return true; } if (j.substring(j.length - 1) !== "s") { j += "s"; } if (this._move) { this._move = null; } return this["add" + j](this._orient); }; }; var nf = function (n) { return function () { this._dateElement = n; return this; }; }; for (var k = 0; k < px.length; k++) { de = px[k].toLowerCase(); if(de !== "weekday") { // Create date element functions and plural date element functions used with Date (eg. day(), days(), months()). $P[de] = $P[de + "s"] = ef(px[k]); // Create date element functions and plural date element functions used with Number (eg. day(), days(), months()). $N[de] = $N[de + "s"] = nf(de + "s"); } } $P._ss = ef("Second"); var nthfn = function (n) { return function (dayOfWeek) { if (this._same) { return this._ss(arguments[0]); } if (dayOfWeek || dayOfWeek === 0) { return this.moveToNthOccurrence(dayOfWeek, n); } this._nth = n; // if the operator is 'second' add the _orient, then deal with it later... if (n === 2 && (dayOfWeek === undefined || dayOfWeek === null)) { this._isSecond = true; return this.addSeconds(this._orient); } return this; }; }; for (var l = 0; l < nth.length; l++) { $P[nth[l]] = (l === 0) ? nthfn(-1) : nthfn(l); } }()); (function () { "use strict"; Date.Parsing = { Exception: function (s) { this.message = "Parse error at '" + s.substring(0, 10) + " ...'"; } }; var $P = Date.Parsing; var dayOffsets = { standard: [0,31,59,90,120,151,181,212,243,273,304,334], leap: [0,31,60,91,121,152,182,213,244,274,305,335] }; $P.isLeapYear = function(year) { return ((year % 4 === 0) && (year % 100 !== 0)) || (year % 400 === 0); }; var utils = { multiReplace : function (str, hash ) { var key; for (key in hash) { if (Object.prototype.hasOwnProperty.call(hash, key)) { var regex; if (typeof hash[key] === "function") { } else { regex = (hash[key] instanceof RegExp) ? hash[key] : new RegExp(hash[key], "g"); } str = str.replace(regex, key); } } return str; }, getDayOfYearFromWeek : function (obj) { var d, jan4, offset; obj.weekDay = (!obj.weekDay && obj.weekDay !== 0) ? 1 : obj.weekDay; d = new Date(obj.year, 0, 4); jan4 = d.getDay() === 0 ? 7 : d.getDay(); // JS is 0 indexed on Sunday. offset = jan4+3; obj.dayOfYear = ((obj.week * 7) + (obj.weekDay === 0 ? 7 : obj.weekDay))-offset; return obj; }, getDayOfYear : function (obj, dayOffset) { if (!obj.dayOfYear) { obj = utils.getDayOfYearFromWeek(obj); } for (var i=0;i <= dayOffset.length;i++) { if (obj.dayOfYear < dayOffset[i] || i === dayOffset.length) { obj.day = obj.day ? obj.day : (obj.dayOfYear - dayOffset[i-1]); break; } else { obj.month = i; } } return obj; }, adjustForTimeZone : function (obj, date) { var offset; if (obj.zone.toUpperCase() === "Z" || (obj.zone_hours === 0 && obj.zone_minutes === 0)) { // it's UTC/GML so work out the current timeszone offset offset = -date.getTimezoneOffset(); } else { offset = (obj.zone_hours*60) + (obj.zone_minutes || 0); if (obj.zone_sign === "+") { offset *= -1; } offset -= date.getTimezoneOffset(); } date.setMinutes(date.getMinutes()+offset); return date; }, setDefaults : function (obj) { obj.year = obj.year || Date.today().getFullYear(); obj.hours = obj.hours || 0; obj.minutes = obj.minutes || 0; obj.seconds = obj.seconds || 0; obj.milliseconds = obj.milliseconds || 0; if (!(!obj.month && (obj.week || obj.dayOfYear))) { // if we have a month, or if we don't but don't have the day calculation data obj.month = obj.month || 0; obj.day = obj.day || 1; } return obj; }, dataNum: function (data, mod, explict, postProcess) { var dataNum = data*1; if (mod) { if (postProcess) { return data ? mod(data)*1 : data; } else { return data ? mod(dataNum) : data; } } else if (!explict){ return data ? dataNum : data; } else { return (data && typeof data !== "undefined") ? dataNum : data; } }, timeDataProcess: function (obj) { var timeObj = {}; for (var x in obj.data) { if (obj.data.hasOwnProperty(x)) { timeObj[x] = obj.ignore[x] ? obj.data[x] : utils.dataNum(obj.data[x], obj.mods[x], obj.explict[x], obj.postProcess[x]); } } if (obj.data.secmins) { obj.data.secmins = obj.data.secmins.replace(",", ".") * 60; if (!timeObj.minutes) { timeObj.minutes = obj.data.secmins; } else if (!timeObj.seconds) { timeObj.seconds = obj.data.secmins; } delete obj.secmins; } return timeObj; }, buildTimeObjectFromData: function (data) { var time = utils.timeDataProcess({ data: { year : data[1], month : data[5], day : data[7], week : data[8], dayOfYear : data[10], hours : data[15], zone_hours : data[23], zone_minutes : data[24], zone : data[21], zone_sign : data[22], weekDay : data[9], minutes: data[16], seconds: data[19], milliseconds: data[20], secmins: data[18] }, mods: { month: function(data) { return data-1; }, weekDay: function (data) { data = Math.abs(data); return (data === 7 ? 0 : data); }, minutes: function (data) { return data.replace(":",""); }, seconds: function (data) { return Math.floor( (data.replace(":","").replace(",","."))*1 ); }, milliseconds: function (data) { return (data.replace(",",".")*1000); } }, postProcess: { minutes: true, seconds: true, milliseconds: true }, explict: { zone_hours: true, zone_minutes: true }, ignore: { zone: true, zone_sign: true, secmins: true } }); return time; }, addToHash: function (hash, keys, data) { keys = keys; data = data; var len = keys.length; for (var i = 0; i < len; i++) { hash[keys[i]] = data[i]; } return hash; }, combineRegex: function (r1, r2) { return new RegExp("(("+r1.source+")\\s("+r2.source+"))"); }, getDateNthString: function(add, last, inc){ if (add) { return Date.today().addDays(inc).toString("d"); } else if (last) { return Date.today().last()[inc]().toString("d"); } }, buildRegexData: function (array) { var arr = []; var len = array.length; for (var i=0; i < len; i++) { if (Object.prototype.toString.call(array[i]) === '[object Array]') { // oldIE compat version of Array.isArray arr.push(this.combineRegex(array[i][0], array[i][1])); } else { arr.push(array[i]); } } return arr; } }; $P.processTimeObject = function (obj) { var date, dayOffset; utils.setDefaults(obj); dayOffset = ($P.isLeapYear(obj.year)) ? dayOffsets.leap : dayOffsets.standard; if (!obj.month && (obj.week || obj.dayOfYear)) { utils.getDayOfYear(obj, dayOffset); } else { obj.dayOfYear = dayOffset[obj.month] + obj.day; } date = new Date(obj.year, obj.month, obj.day, obj.hours, obj.minutes, obj.seconds, obj.milliseconds); if (obj.zone) { utils.adjustForTimeZone(obj, date); // adjust (and calculate) for timezone } return date; }; $P.ISO = { regex : /^([\+-]?\d{4}(?!\d{2}\b))((-?)((0[1-9]|1[0-2])(\3([12]\d|0[1-9]|3[01]))?|W([0-4]\d|5[0-3])(-?[1-7])?|(00[1-9]|0[1-9]\d|[12]\d{2}|3([0-5]\d|6[1-6])))([T\s]((([01]\d|2[0-4])((:?)[0-5]\d)?|24\:?00)([\.,]\d+(?!:))?)?(\17[0-5]\d([\.,]\d+)?)?\s?([zZ]|([\+-])([01]\d|2[0-3]):?([0-5]\d)?)?)?)?$/, parse : function (s) { var time, data = s.match(this.regex); if (!data || !data.length) { return null; } time = utils.buildTimeObjectFromData(data); if (!time.year || (!time.year && (!time.month && !time.day) && (!time.week && !time.dayOfYear)) ) { return null; } return $P.processTimeObject(time); } }; $P.Numeric = { isNumeric: function (e){return!isNaN(parseFloat(e))&&isFinite(e);}, regex: /\b([0-1]?[0-9])([0-3]?[0-9])([0-2]?[0-9]?[0-9][0-9])\b/i, parse: function (s) { var data, i, time = {}, order = Date.CultureInfo.dateElementOrder.split(""); if (!(this.isNumeric(s)) || // if it's non-numeric OR (s[0] === "+" && s[0] === "-")) { // It's an arithmatic string (eg +/-1000) return null; } if (s.length < 5 && s.indexOf(".") < 0 && s.indexOf("/") < 0) { // assume it's just a year. time.year = s; return $P.processTimeObject(time); } data = s.match(this.regex); if (!data || !data.length) { return null; } for (i=0; i < order.length; i++) { switch(order[i]) { case "d": time.day = data[i+1]; break; case "m": time.month = (data[i+1]-1); break; case "y": time.year = data[i+1]; break; } } return $P.processTimeObject(time); } }; $P.Normalizer = { regexData: function () { var $R = Date.CultureInfo.regexPatterns; return utils.buildRegexData([ $R.tomorrow, $R.yesterday, [$R.past, $R.mon], [$R.past, $R.tue], [$R.past, $R.wed], [$R.past, $R.thu], [$R.past, $R.fri], [$R.past, $R.sat], [$R.past, $R.sun] ]); }, basicReplaceHash : function() { var $R = Date.CultureInfo.regexPatterns; return { "January": $R.jan.source, "February": $R.feb, "March": $R.mar, "April": $R.apr, "May": $R.may, "June": $R.jun, "July": $R.jul, "August": $R.aug, "September": $R.sep, "October": $R.oct, "November": $R.nov, "December": $R.dec, "": /\bat\b/gi, " ": /\s{2,}/, "am": $R.inTheMorning, "9am": $R.thisMorning, "pm": $R.inTheEvening, "7pm":$R.thisEvening }; }, keys : function(){ return [ utils.getDateNthString(true, false, 1), // tomorrow utils.getDateNthString(true, false, -1), // yesterday utils.getDateNthString(false, true, "monday"), //last mon utils.getDateNthString(false, true, "tuesday"), //last tues utils.getDateNthString(false, true, "wednesday"), //last wed utils.getDateNthString(false, true, "thursday"), //last thurs utils.getDateNthString(false, true, "friday"), //last fri utils.getDateNthString(false, true, "saturday"), //last sat utils.getDateNthString(false, true, "sunday") //last sun ]; }, buildRegexFunctions: function () { var $R = Date.CultureInfo.regexPatterns; var __ = Date.i18n.__; var tomorrowRE = new RegExp("(\\b\\d\\d?("+__("AM")+"|"+__("PM")+")? )("+$R.tomorrow.source.slice(1)+")", "i"); // adapted tomorrow regex for AM PM relative dates var todayRE = new RegExp($R.today.source + "(?!\\s*([+-]))\\b"); // today, but excludes the math operators (eg "today + 2h") this.replaceFuncs = [ [todayRE, function (full) { return (full.length > 1) ? Date.today().toString("d") : full; }], [tomorrowRE, function(full, m1) { var t = Date.today().addDays(1).toString("d"); return (t + " " + m1); }], [$R.amThisMorning, function(str, am){return am;}], [$R.pmThisEvening, function(str, pm){return pm;}] ]; }, buildReplaceData: function () { this.buildRegexFunctions(); this.replaceHash = utils.addToHash(this.basicReplaceHash(), this.keys(), this.regexData()); }, stringReplaceFuncs: function (s) { for (var i=0; i < this.replaceFuncs.length; i++) { s = s.replace(this.replaceFuncs[i][0], this.replaceFuncs[i][1]); } return s; }, parse: function (s) { s = this.stringReplaceFuncs(s); s = utils.multiReplace(s, this.replaceHash); try { var n = s.split(/([\s\-\.\,\/\x27]+)/); if (n.length === 3 && $P.Numeric.isNumeric(n[0]) && $P.Numeric.isNumeric(n[2]) && (n[2].length >= 4)) { // ok, so we're dealing with x/year. But that's not a full date. // This fixes wonky dateElementOrder parsing when set to dmy order. if (Date.CultureInfo.dateElementOrder[0] === "d") { s = "1/" + n[0] + "/" + n[2]; // set to 1st of month and normalize the seperator } } } catch (e) {} return s; } }; $P.Normalizer.buildReplaceData(); }()); (function () { var $P = Date.Parsing; var _ = $P.Operators = { // // Tokenizers // rtoken: function (r) { // regex token return function (s) { var mx = s.match(r); if (mx) { return ([ mx[0], s.substring(mx[0].length) ]); } else { throw new $P.Exception(s); } }; }, token: function () { // whitespace-eating token return function (s) { return _.rtoken(new RegExp("^\\s*" + s + "\\s*"))(s); }; }, stoken: function (s) { // string token return _.rtoken(new RegExp("^" + s)); }, // Atomic Operators until: function (p) { return function (s) { var qx = [], rx = null; while (s.length) { try { rx = p.call(this, s); } catch (e) { qx.push(rx[0]); s = rx[1]; continue; } break; } return [ qx, s ]; }; }, many: function (p) { return function (s) { var rx = [], r = null; while (s.length) { try { r = p.call(this, s); } catch (e) { return [ rx, s ]; } rx.push(r[0]); s = r[1]; } return [ rx, s ]; }; }, // generator operators -- see below optional: function (p) { return function (s) { var r = null; try { r = p.call(this, s); } catch (e) { return [ null, s ]; } return [ r[0], r[1] ]; }; }, not: function (p) { return function (s) { try { p.call(this, s); } catch (e) { return [null, s]; } throw new $P.Exception(s); }; }, ignore: function (p) { return p ? function (s) { var r = null; r = p.call(this, s); return [null, r[1]]; } : null; }, product: function () { var px = arguments[0], qx = Array.prototype.slice.call(arguments, 1), rx = []; for (var i = 0 ; i < px.length ; i++) { rx.push(_.each(px[i], qx)); } return rx; }, cache: function (rule) { var cache = {}, cache_length = 0, cache_keys = [], CACHE_MAX = Date.Config.CACHE_MAX || 100000, r = null; var cacheCheck = function () { if (cache_length === CACHE_MAX) { // kill several keys, don't want to have to do this all the time... for (var i=0; i < 10; i++) { var key = cache_keys.shift(); if (key) { delete cache[key]; cache_length--; } } } }; return function (s) { cacheCheck(); try { r = cache[s] = (cache[s] || rule.call(this, s)); } catch (e) { r = cache[s] = e; } cache_length++; cache_keys.push(s); if (r instanceof $P.Exception) { throw r; } else { return r; } }; }, // vector operators -- see below any: function () { var px = arguments; return function (s) { var r = null; for (var i = 0; i < px.length; i++) { if (px[i] == null) { continue; } try { r = (px[i].call(this, s)); } catch (e) { r = null; } if (r) { return r; } } throw new $P.Exception(s); }; }, each: function () { var px = arguments; return function (s) { var rx = [], r = null; for (var i = 0; i < px.length ; i++) { if (px[i] == null) { continue; } try { r = (px[i].call(this, s)); } catch (e) { throw new $P.Exception(s); } rx.push(r[0]); s = r[1]; } return [ rx, s]; }; }, all: function () { var px = arguments, _ = _; return _.each(_.optional(px)); }, // delimited operators sequence: function (px, d, c) { d = d || _.rtoken(/^\s*/); c = c || null; if (px.length === 1) { return px[0]; } return function (s) { var r = null, q = null; var rx = []; for (var i = 0; i < px.length ; i++) { try { r = px[i].call(this, s); } catch (e) { break; } rx.push(r[0]); try { q = d.call(this, r[1]); } catch (ex) { q = null; break; } s = q[1]; } if (!r) { throw new $P.Exception(s); } if (q) { throw new $P.Exception(q[1]); } if (c) { try { r = c.call(this, r[1]); } catch (ey) { throw new $P.Exception(r[1]); } } return [ rx, (r?r[1]:s) ]; }; }, // // Composite Operators // between: function (d1, p, d2) { d2 = d2 || d1; var _fn = _.each(_.ignore(d1), p, _.ignore(d2)); return function (s) { var rx = _fn.call(this, s); return [[rx[0][0], r[0][2]], rx[1]]; }; }, list: function (p, d, c) { d = d || _.rtoken(/^\s*/); c = c || null; return (p instanceof Array ? _.each(_.product(p.slice(0, -1), _.ignore(d)), p.slice(-1), _.ignore(c)) : _.each(_.many(_.each(p, _.ignore(d))), px, _.ignore(c))); }, set: function (px, d, c) { d = d || _.rtoken(/^\s*/); c = c || null; return function (s) { // r is the current match, best the current 'best' match // which means it parsed the most amount of input var r = null, p = null, q = null, rx = null, best = [[], s], last = false; // go through the rules in the given set for (var i = 0; i < px.length ; i++) { // last is a flag indicating whether this must be the last element // if there is only 1 element, then it MUST be the last one q = null; p = null; r = null; last = (px.length === 1); // first, we try simply to match the current pattern // if not, try the next pattern try { r = px[i].call(this, s); } catch (e) { continue; } // since we are matching against a set of elements, the first // thing to do is to add r[0] to matched elements rx = [[r[0]], r[1]]; // if we matched and there is still input to parse and // we don't already know this is the last element, // we're going to next check for the delimiter ... // if there's none, or if there's no input left to parse // than this must be the last element after all ... if (r[1].length > 0 && ! last) { try { q = d.call(this, r[1]); } catch (ex) { last = true; } } else { last = true; } // if we parsed the delimiter and now there's no more input, // that means we shouldn't have parsed the delimiter at all // so don't update r and mark this as the last element ... if (!last && q[1].length === 0) { last = true; } // so, if this isn't the last element, we're going to see if // we can get any more matches from the remaining (unmatched) // elements ... if (!last) { // build a list of the remaining rules we can match against, // i.e., all but the one we just matched against var qx = []; for (var j = 0; j < px.length ; j++) { if (i !== j) { qx.push(px[j]); } } // now invoke recursively set with the remaining input // note that we don't include the closing delimiter ... // we'll check for that ourselves at the end p = _.set(qx, d).call(this, q[1]); // if we got a non-empty set as a result ... // (otw rx already contains everything we want to match) if (p[0].length > 0) { // update current result, which is stored in rx ... // basically, pick up the remaining text from p[1] // and concat the result from p[0] so that we don't // get endless nesting ... rx[0] = rx[0].concat(p[0]); rx[1] = p[1]; } } // at this point, rx either contains the last matched element // or the entire matched set that starts with this element. // now we just check to see if this variation is better than // our best so far, in terms of how much of the input is parsed if (rx[1].length < best[1].length) { best = rx; } // if we've parsed all the input, then we're finished if (best[1].length === 0) { break; } } // so now we've either gone through all the patterns trying them // as the initial match; or we found one that parsed the entire // input string ... // if best has no matches, just return empty set ... if (best[0].length === 0) { return best; } // if a closing delimiter is provided, then we have to check it also if (c) { // we try this even if there is no remaining input because the pattern // may well be optional or match empty input ... try { q = c.call(this, best[1]); } catch (ey) { throw new $P.Exception(best[1]); } // it parsed ... be sure to update the best match remaining input best[1] = q[1]; } // if we're here, either there was no closing delimiter or we parsed it // so now we have the best match; just return it! return best; }; }, forward: function (gr, fname) { return function (s) { return gr[fname].call(this, s); }; }, // // Translation Operators // replace: function (rule, repl) { return function (s) { var r = rule.call(this, s); return [repl, r[1]]; }; }, process: function (rule, fn) { return function (s) { var r = rule.call(this, s); return [fn.call(this, r[0]), r[1]]; }; }, min: function (min, rule) { return function (s) { var rx = rule.call(this, s); if (rx[0].length < min) { throw new $P.Exception(s); } return rx; }; } }; // Generator Operators And Vector Operators // Generators are operators that have a signature of F(R) => R, // taking a given rule and returning another rule, such as // ignore, which parses a given rule and throws away the result. // Vector operators are those that have a signature of F(R1,R2,...) => R, // take a list of rules and returning a new rule, such as each. // Generator operators are converted (via the following _generator // function) into functions that can also take a list or array of rules // and return an array of new rules as though the function had been // called on each rule in turn (which is what actually happens). // This allows generators to be used with vector operators more easily. // Example: // each(ignore(foo, bar)) instead of each(ignore(foo), ignore(bar)) // This also turns generators into vector operators, which allows // constructs like: // not(cache(foo, bar)) var _generator = function (op) { function gen() { var args = null, rx = [], px, i; if (arguments.length > 1) { args = Array.prototype.slice.call(arguments); } else if (arguments[0] instanceof Array) { args = arguments[0]; } if (args) { px = args.shift(); if (px.length > 0) { args.unshift(px[i]); rx.push(op.apply(null, args)); args.shift(); return rx; } } else { return op.apply(null, arguments); } } return gen; }; var gx = "optional not ignore cache".split(/\s/); for (var i = 0 ; i < gx.length ; i++) { _[gx[i]] = _generator(_[gx[i]]); } var _vector = function (op) { return function () { if (arguments[0] instanceof Array) { return op.apply(null, arguments[0]); } else { return op.apply(null, arguments); } }; }; var vx = "each any all".split(/\s/); for (var j = 0 ; j < vx.length ; j++) { _[vx[j]] = _vector(_[vx[j]]); } }()); (function () { var $D = Date; var flattenAndCompact = function (ax) { var rx = []; for (var i = 0; i < ax.length; i++) { if (ax[i] instanceof Array) { rx = rx.concat(flattenAndCompact(ax[i])); } else { if (ax[i]) { rx.push(ax[i]); } } } return rx; }; var parseMeridian = function () { if (this.meridian && (this.hour || this.hour === 0)) { if (this.meridian === "a" && this.hour > 11 && Date.Config.strict24hr){ throw "Invalid hour and meridian combination"; } else if (this.meridian === "p" && this.hour < 12 && Date.Config.strict24hr){ throw "Invalid hour and meridian combination"; } else if (this.meridian === "p" && this.hour < 12) { this.hour = this.hour + 12; } else if (this.meridian === "a" && this.hour === 12) { this.hour = 0; } } }; var setDefaults = function () { var now = new Date(); if ((this.hour || this.minute) && (!this.month && !this.year && !this.day)) { this.day = now.getDate(); } if (!this.year) { this.year = now.getFullYear(); } if (!this.month && this.month !== 0) { this.month = now.getMonth(); } if (!this.day) { this.day = 1; } if (!this.hour) { this.hour = 0; } if (!this.minute) { this.minute = 0; } if (!this.second) { this.second = 0; } if (!this.millisecond) { this.millisecond = 0; } }; var finishUtils = { getToday: function () { if (this.now || "hour minute second".indexOf(this.unit) !== -1) { return new Date(); } else { return $D.today(); } }, setDaysFromWeekday: function (today, orient){ var gap; orient = orient || 1; this.unit = "day"; gap = ($D.getDayNumberFromName(this.weekday) - today.getDay()); this.days = gap ? ((gap + (orient * 7)) % 7) : (orient * 7); return this; }, setMonthsFromMonth: function (today, orient) { var gap; orient = orient || 1; this.unit = "month"; gap = (this.month - today.getMonth()); this.months = gap ? ((gap + (orient * 12)) % 12) : (orient * 12); this.month = null; return this; }, setDMYFromWeekday: function () { var d = Date[this.weekday](); this.day = d.getDate(); if (!this.month) { this.month = d.getMonth(); } this.year = d.getFullYear(); return this; }, setUnitValue: function (orient) { if (!this.value && this.operator && this.operator !== null && this[this.unit + "s"] && this[this.unit + "s"] !== null) { this[this.unit + "s"] = this[this.unit + "s"] + ((this.operator === "add") ? 1 : -1) + (this.value||0) * orient; } else if (this[this.unit + "s"] == null || this.operator != null) { if (!this.value) { this.value = 1; } this[this.unit + "s"] = this.value * orient; } }, generateDateFromWeeks: function () { var weekday = (this.weekday !== undefined) ? this.weekday : "today"; var d = Date[weekday]().addWeeks(this.weeks); if (this.now) { d.setTimeToNow(); } return d; } }; $D.Translator = { hour: function (s) { return function () { this.hour = Number(s); }; }, minute: function (s) { return function () { this.minute = Number(s); }; }, second: function (s) { return function () { this.second = Number(s); }; }, /* for ss.s format */ secondAndMillisecond: function (s) { return function () { var mx = s.match(/^([0-5][0-9])\.([0-9]{1,3})/); this.second = Number(mx[1]); this.millisecond = Number(mx[2]); }; }, meridian: function (s) { return function () { this.meridian = s.slice(0, 1).toLowerCase(); }; }, timezone: function (s) { return function () { var n = s.replace(/[^\d\+\-]/g, ""); if (n.length) { this.timezoneOffset = Number(n); } else { this.timezone = s.toLowerCase(); } }; }, day: function (x) { var s = x[0]; return function () { this.day = Number(s.match(/\d+/)[0]); if (this.day < 1) { throw "invalid day"; } }; }, month: function (s) { return function () { this.month = (s.length === 3) ? "jan feb mar apr may jun jul aug sep oct nov dec".indexOf(s)/4 : Number(s) - 1; if (this.month < 0) { throw "invalid month"; } }; }, year: function (s) { return function () { var n = Number(s); this.year = ((s.length > 2) ? n : (n + (((n + 2000) < Date.CultureInfo.twoDigitYearMax) ? 2000 : 1900))); }; }, rday: function (s) { return function () { switch (s) { case "yesterday": this.days = -1; break; case "tomorrow": this.days = 1; break; case "today": this.days = 0; break; case "now": this.days = 0; this.now = true; break; } }; }, finishExact: function (x) { var d; x = (x instanceof Array) ? x : [x]; for (var i = 0 ; i < x.length ; i++) { if (x[i]) { x[i].call(this); } } setDefaults.call(this); parseMeridian.call(this); if (this.day > $D.getDaysInMonth(this.year, this.month)) { throw new RangeError(this.day + " is not a valid value for days."); } d = new Date(this.year, this.month, this.day, this.hour, this.minute, this.second, this.millisecond); if (this.year < 100) { d.setFullYear(this.year); // means years less that 100 are process correctly. JS will parse it otherwise as 1900-1999. } if (this.timezone) { d.set({ timezone: this.timezone }); } else if (this.timezoneOffset) { d.set({ timezoneOffset: this.timezoneOffset }); } return d; }, finish: function (x) { var today, expression, orient, temp; x = (x instanceof Array) ? flattenAndCompact(x) : [ x ]; if (x.length === 0) { return null; } for (var i = 0 ; i < x.length ; i++) { if (typeof x[i] === "function") { x[i].call(this); } } if (this.now && !this.unit && !this.operator) { return new Date(); } else { today = finishUtils.getToday.call(this); } expression = !!(this.days && this.days !== null || this.orient || this.operator); orient = ((this.orient === "past" || this.operator === "subtract") ? -1 : 1); if (this.month && this.unit === "week") { this.value = this.month + 1; delete this.month; delete this.day; } if ((this.month || this.month === 0) && "year day hour minute second".indexOf(this.unit) !== -1) { if (!this.value) { this.value = this.month + 1; } this.month = null; expression = true; } if (!expression && this.weekday && !this.day && !this.days) { finishUtils.setDMYFromWeekday.call(this); } if (expression && this.weekday && this.unit !== "month" && this.unit !== "week") { finishUtils.setDaysFromWeekday.call(this, today, orient); } if (this.weekday && this.unit !== "week" && !this.day && !this.days) { temp = Date[this.weekday](); this.day = temp.getDate(); if (temp.getMonth() !== today.getMonth()) { this.month = temp.getMonth(); } } if (this.month && this.unit === "day" && this.operator) { if (!this.value) { this.value = (this.month + 1); } this.month = null; } if (this.value != null && this.month != null && this.year != null) { this.day = this.value * 1; } if (this.month && !this.day && this.value) { today.set({ day: this.value * 1 }); if (!expression) { this.day = this.value * 1; } } if (!this.month && this.value && this.unit === "month" && !this.now) { this.month = this.value; expression = true; } if (expression && (this.month || this.month === 0) && this.unit !== "year") { finishUtils.setMonthsFromMonth.call(this, today, orient); } if (!this.unit) { this.unit = "day"; } finishUtils.setUnitValue.call(this, orient); parseMeridian.call(this); if ((this.month || this.month === 0) && !this.day) { this.day = 1; } if (!this.orient && !this.operator && this.unit === "week" && this.value && !this.day && !this.month) { return Date.today().setWeek(this.value); } if (this.unit === "week" && this.weeks && !this.day && !this.month) { return finishUtils.generateDateFromWeeks.call(this); } if (expression && this.timezone && this.day && this.days) { this.day = this.days; } if (expression){ today.add(this); } else { today.set(this); } if (this.timezone) { this.timezone = this.timezone.toUpperCase(); var offset = $D.getTimezoneOffset(this.timezone); var timezone; if (today.hasDaylightSavingTime()) { // lets check that we're being sane with timezone setting timezone = $D.getTimezoneAbbreviation(offset, today.isDaylightSavingTime()); if (timezone !== this.timezone) { // bugger, we're in a place where things like EST vs EDT matters. if (today.isDaylightSavingTime()) { today.addHours(-1); } else { today.addHours(1); } } } today.setTimezoneOffset(offset); } return today; } }; }()); (function () { var $D = Date; $D.Grammar = {}; var _ = $D.Parsing.Operators, g = $D.Grammar, t = $D.Translator, _fn; // Allow rolling up into general purpose rules _fn = function () { return _.each(_.any.apply(null, arguments), _.not(g.ctoken2("timeContext"))); }; g.datePartDelimiter = _.rtoken(/^([\s\-\.\,\/\x27]+)/); g.timePartDelimiter = _.stoken(":"); g.whiteSpace = _.rtoken(/^\s*/); g.generalDelimiter = _.rtoken(/^(([\s\,]|at|@|on)+)/); var _C = {}; g.ctoken = function (keys) { var fn = _C[keys]; if (! fn) { var c = Date.CultureInfo.regexPatterns; var kx = keys.split(/\s+/), px = []; for (var i = 0; i < kx.length ; i++) { px.push(_.replace(_.rtoken(c[kx[i]]), kx[i])); } fn = _C[keys] = _.any.apply(null, px); } return fn; }; g.ctoken2 = function (key) { return _.rtoken(Date.CultureInfo.regexPatterns[key]); }; var cacheProcessRtoken = function (key, token, type, eachToken) { if (eachToken) { g[key] = _.cache(_.process(_.each(_.rtoken(token),_.optional(g.ctoken2(eachToken))), type)); } else { g[key] = _.cache(_.process(_.rtoken(token), type)); } }; var cacheProcessCtoken = function (token, type) { return _.cache(_.process(g.ctoken2(token), type)); }; var _F = {}; //function cache var _get = function (f) { _F[f] = (_F[f] || g.format(f)[0]); return _F[f]; }; g.allformats = function (fx) { var rx = []; if (fx instanceof Array) { for (var i = 0; i < fx.length; i++) { rx.push(_get(fx[i])); } } else { rx.push(_get(fx)); } return rx; }; g.formats = function (fx) { if (fx instanceof Array) { var rx = []; for (var i = 0 ; i < fx.length ; i++) { rx.push(_get(fx[i])); } return _.any.apply(null, rx); } else { return _get(fx); } }; var grammarFormats = { timeFormats: function(){ var i, RTokenKeys = [ "h", "hh", "H", "HH", "m", "mm", "s", "ss", "ss.s", "z", "zz" ], RToken = [ /^(0[0-9]|1[0-2]|[1-9])/, /^(0[0-9]|1[0-2])/, /^([0-1][0-9]|2[0-3]|[0-9])/, /^([0-1][0-9]|2[0-3])/, /^([0-5][0-9]|[0-9])/, /^[0-5][0-9]/, /^([0-5][0-9]|[0-9])/, /^[0-5][0-9]/, /^[0-5][0-9]\.[0-9]{1,3}/, /^((\+|\-)\s*\d\d\d\d)|((\+|\-)\d\d\:?\d\d)/, /^((\+|\-)\s*\d\d\d\d)|((\+|\-)\d\d\:?\d\d)/ ], tokens = [ t.hour, t.hour, t.hour, t.hour, t.minute, t.minute, t.second, t.second, t.secondAndMillisecond, t.timezone, t.timezone ]; for (i=0; i < RTokenKeys.length; i++) { cacheProcessRtoken(RTokenKeys[i], RToken[i], tokens[i]); } g.hms = _.cache(_.sequence([g.H, g.m, g.s], g.timePartDelimiter)); g.t = cacheProcessCtoken("shortMeridian", t.meridian); g.tt = cacheProcessCtoken("longMeridian", t.meridian); g.zzz = cacheProcessCtoken("timezone", t.timezone); g.timeSuffix = _.each(_.ignore(g.whiteSpace), _.set([ g.tt, g.zzz ])); g.time = _.each(_.optional(_.ignore(_.stoken("T"))), g.hms, g.timeSuffix); }, dateFormats: function () { // pre-loaded rules for different date part order preferences var _setfn = function () { return _.set(arguments, g.datePartDelimiter); }; var i, RTokenKeys = [ "d", "dd", "M", "MM", "y", "yy", "yyy", "yyyy" ], RToken = [ /^([0-2]\d|3[0-1]|\d)/, /^([0-2]\d|3[0-1])/, /^(1[0-2]|0\d|\d)/, /^(1[0-2]|0\d)/, /^(\d+)/, /^(\d\d)/, /^(\d\d?\d?\d?)/, /^(\d\d\d\d)/ ], tokens = [ t.day, t.day, t.month, t.month, t.year, t.year, t.year, t.year ], eachToken = [ "ordinalSuffix", "ordinalSuffix" ]; for (i=0; i < RTokenKeys.length; i++) { cacheProcessRtoken(RTokenKeys[i], RToken[i], tokens[i], eachToken[i]); } g.MMM = g.MMMM = _.cache(_.process(g.ctoken("jan feb mar apr may jun jul aug sep oct nov dec"), t.month)); g.ddd = g.dddd = _.cache(_.process(g.ctoken("sun mon tue wed thu fri sat"), function (s) { return function () { this.weekday = s; }; } )); g.day = _fn(g.d, g.dd); g.month = _fn(g.M, g.MMM); g.year = _fn(g.yyyy, g.yy); g.mdy = _setfn(g.ddd, g.month, g.day, g.year); g.ymd = _setfn(g.ddd, g.year, g.month, g.day); g.dmy = _setfn(g.ddd, g.day, g.month, g.year); g.date = function (s) { return ((g[Date.CultureInfo.dateElementOrder] || g.mdy).call(this, s)); }; }, relative: function () { // relative date / time expressions g.orientation = _.process(g.ctoken("past future"), function (s) { return function () { this.orient = s; }; } ); g.operator = _.process(g.ctoken("add subtract"), function (s) { return function () { this.operator = s; }; } ); g.rday = _.process(g.ctoken("yesterday tomorrow today now"), t.rday); g.unit = _.process(g.ctoken("second minute hour day week month year"), function (s) { return function () { this.unit = s; }; } ); } }; g.buildGrammarFormats = function () { // these need to be rebuilt every time the language changes. _C = {}; grammarFormats.timeFormats(); grammarFormats.dateFormats(); grammarFormats.relative(); g.value = _.process(_.rtoken(/^([-+]?\d+)?(st|nd|rd|th)?/), function (s) { return function () { this.value = s.replace(/\D/g, ""); }; } ); g.expression = _.set([g.rday, g.operator, g.value, g.unit, g.orientation, g.ddd, g.MMM ]); g.format = _.process(_.many( _.any( // translate format specifiers into grammar rules _.process( _.rtoken(/^(dd?d?d?(?!e)|MM?M?M?|yy?y?y?|hh?|HH?|mm?|ss?|tt?|zz?z?)/), function (fmt) { if (g[fmt]) { return g[fmt]; } else { throw $D.Parsing.Exception(fmt); } } ), // translate separator tokens into token rules _.process(_.rtoken(/^[^dMyhHmstz]+/), // all legal separators function (s) { return _.ignore(_.stoken(s)); } ) ) ), // construct the parser ... function (rules) { return _.process(_.each.apply(null, rules), t.finishExact); } ); // starting rule for general purpose grammar g._start = _.process(_.set([ g.date, g.time, g.expression ], g.generalDelimiter, g.whiteSpace), t.finish); }; g.buildGrammarFormats(); // parsing date format specifiers - ex: "h:m:s tt" // this little guy will generate a custom parser based // on the format string, ex: g.format("h:m:s tt") // check for these formats first g._formats = g.formats([ "\"yyyy-MM-ddTHH:mm:ssZ\"", "yyyy-MM-ddTHH:mm:ss.sz", "yyyy-MM-ddTHH:mm:ssZ", "yyyy-MM-ddTHH:mm:ssz", "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-ddTHH:mmZ", "yyyy-MM-ddTHH:mmz", "yyyy-MM-ddTHH:mm", "ddd, MMM dd, yyyy H:mm:ss tt", "ddd MMM d yyyy HH:mm:ss zzz", "MMddyyyy", "ddMMyyyy", "Mddyyyy", "ddMyyyy", "Mdyyyy", "dMyyyy", "yyyy", "Mdyy", "dMyy", "d" ]); // real starting rule: tries selected formats first, // then general purpose rule g.start = function (s) { try { var r = g._formats.call({}, s); if (r[1].length === 0) { return r; } } catch (e) {} return g._start.call({}, s); }; }()); (function () { var $D = Date; /** * @desc Converts the specified string value into its JavaScript Date equivalent using CultureInfo specific format information. * * Example

	///////////
	// Dates //
	///////////

	// 15-Oct-2004
	var d1 = Date.parse("10/15/2004");

	// 15-Oct-2004
	var d1 = Date.parse("15-Oct-2004");

	// 15-Oct-2004
	var d1 = Date.parse("2004.10.15");

	//Fri Oct 15, 2004
	var d1 = Date.parse("Fri Oct 15, 2004");

	///////////
	// Times //
	///////////

	// Today at 10 PM.
	var d1 = Date.parse("10 PM");

	// Today at 10:30 PM.
	var d1 = Date.parse("10:30 P.M.");

	// Today at 6 AM.
	var d1 = Date.parse("06am");

	/////////////////////
	// Dates and Times //
	/////////////////////

	// 8-July-2004 @ 10:30 PM
	var d1 = Date.parse("July 8th, 2004, 10:30 PM");

	// 1-July-2004 @ 10:30 PM
	var d1 = Date.parse("2004-07-01T22:30:00");

	////////////////////
	// Relative Dates //
	////////////////////

	// Returns today's date. The string "today" is culture specific.
	var d1 = Date.parse("today");

	// Returns yesterday's date. The string "yesterday" is culture specific.
	var d1 = Date.parse("yesterday");

	// Returns the date of the next thursday.
	var d1 = Date.parse("Next thursday");

	// Returns the date of the most previous monday.
	var d1 = Date.parse("last monday");

	// Returns today's day + one year.
	var d1 = Date.parse("next year");

	///////////////
	// Date Math //
	///////////////

	// Today + 2 days
	var d1 = Date.parse("t+2");

	// Today + 2 days
	var d1 = Date.parse("today + 2 days");

	// Today + 3 months
	var d1 = Date.parse("t+3m");

	// Today - 1 year
	var d1 = Date.parse("today - 1 year");

	// Today - 1 year
	var d1 = Date.parse("t-1y"); 


	/////////////////////////////
	// Partial Dates and Times //
	/////////////////////////////

	// July 15th of this year.
	var d1 = Date.parse("July 15");

	// 15th day of current day and year.
	var d1 = Date.parse("15");

	// July 1st of current year at 10pm.
	var d1 = Date.parse("7/1 10pm");
	
* * @param {String} The string value to convert into a Date object [Required] * @return {Date} A Date object or null if the string cannot be converted into a Date. */ var parseUtils = { removeOrds: function (s) { ords = s.match(/\b(\d+)(?:st|nd|rd|th)\b/); // find ordinal matches s = ((ords && ords.length === 2) ? s.replace(ords[0], ords[1]) : s); return s; }, grammarParser: function (s) { var r = null; try { r = $D.Grammar.start.call({}, s.replace(/^\s*(\S*(\s+\S+)*)\s*$/, "$1")); } catch (e) { return null; } return ((r[1].length === 0) ? r[0] : null); }, nativeFallback: function(s) { var t; try { // ok we haven't parsed it, last ditch attempt with the built-in parser. t = Date._parse(s); return (t || t === 0) ? new Date(t) : null; } catch (e) { return null; } } }; function parse (s) { var d; if (!s) { return null; } if (s instanceof Date) { return s.clone(); } if (s.length >= 4 && s.charAt(0) !== "0" && s.charAt(0) !== "+"&& s.charAt(0) !== "-") { // ie: 2004 will pass, 0800 won't. // Start with specific formats d = $D.Parsing.ISO.parse(s) || $D.Parsing.Numeric.parse(s); } if (d instanceof Date && !isNaN(d.getTime())) { return d; } else { // find ordinal dates (1st, 3rd, 8th, etc and remove them as they cause parsing issues) s = $D.Parsing.Normalizer.parse(parseUtils.removeOrds(s)); d = parseUtils.grammarParser(s); if (d !== null) { return d; } else { return parseUtils.nativeFallback(s); } } } if (!$D._parse) { $D._parse = $D.parse; } $D.parse = parse; Date.getParseFunction = function (fx) { var fns = Date.Grammar.allformats(fx); return function (s) { var r = null; for (var i = 0; i < fns.length; i++) { try { r = fns[i].call({}, s); } catch (e) { continue; } if (r[1].length === 0) { return r[0]; } } return null; }; }; /** * Converts the specified string value into its JavaScript Date equivalent using the specified format {String} or formats {Array} and the CultureInfo specific format information. * The format of the string value must match one of the supplied formats exactly. * * Example

	// 15-Oct-2004
	var d1 = Date.parseExact("10/15/2004", "M/d/yyyy");

	// 15-Oct-2004
	var d1 = Date.parse("15-Oct-2004", "M-ddd-yyyy");

	// 15-Oct-2004
	var d1 = Date.parse("2004.10.15", "yyyy.MM.dd");

	// Multiple formats
	var d1 = Date.parseExact("10/15/2004", ["M/d/yyyy", "MMMM d, yyyy"]);
	
* * @param {String} The string value to convert into a Date object [Required]. * @param {Object} The expected format {String} or an array of expected formats {Array} of the date string [Required]. * @return {Date} A Date object or null if the string cannot be converted into a Date. */ $D.parseExact = function (s, fx) { return $D.getParseFunction(fx)(s); }; }()); (function () { var $D = Date, $P = $D.prototype, // $C = $D.CultureInfo, // not used atm p = function (s, l) { if (!l) { l = 2; } return ("000" + s).slice(l * -1); }; /** * Converts a PHP format string to Java/.NET format string. * A PHP format string can be used with ._format or .format. * A Java/.NET format string can be used with .toString(). * The .parseExact function will only accept a Java/.NET format string * * Example * var f1 = "%m/%d/%y" * var f2 = Date.normalizeFormat(f1); // "MM/dd/yy" * * new Date().format(f1); // "04/13/08" * new Date()._format(f1); // "04/13/08" * new Date().toString(f2); // "04/13/08" * * var date = Date.parseExact("04/13/08", f2); // Sun Apr 13 2008 * * @param {String} A PHP format string consisting of one or more format spcifiers. * @return {String} The PHP format converted to a Java/.NET format string. */ var normalizerSubstitutions = { "d" : "dd", "%d": "dd", "D" : "ddd", "%a": "ddd", "j" : "dddd", "l" : "dddd", "%A": "dddd", "S" : "S", "F" : "MMMM", "%B": "MMMM", "m" : "MM", "%m": "MM", "M" : "MMM", "%b": "MMM", "%h": "MMM", "n" : "M", "Y" : "yyyy", "%Y": "yyyy", "y" : "yy", "%y": "yy", "g" : "h", "%I": "h", "G" : "H", "h" : "hh", "H" : "HH", "%H": "HH", "i" : "mm", "%M": "mm", "s" : "ss", "%S": "ss", "%r": "hh:mm tt", "%R": "H:mm", "%T": "H:mm:ss", "%X": "t", "%x": "d", "%e": "d", "%D": "MM/dd/yy", "%n": "\\n", "%t": "\\t", "e" : "z", "T" : "z", "%z": "z", "%Z": "z", "Z" : "ZZ", "N" : "u", "w" : "u", "%w": "u", "W" : "W", "%V": "W" }; var normalizer = { substitutes: function (m) { return normalizerSubstitutions[m]; }, interpreted: function (m, x) { var y; switch (m) { case "%u": return x.getDay() + 1; case "z": return x.getOrdinalNumber(); case "%j": return p(x.getOrdinalNumber(), 3); case "%U": var d1 = x.clone().set({month: 0, day: 1}).addDays(-1).moveToDayOfWeek(0), d2 = x.clone().addDays(1).moveToDayOfWeek(0, -1); return (d2 < d1) ? "00" : p((d2.getOrdinalNumber() - d1.getOrdinalNumber()) / 7 + 1); case "%W": return p(x.getWeek()); case "t": return $D.getDaysInMonth(x.getFullYear(), x.getMonth()); case "o": case "%G": return x.setWeek(x.getISOWeek()).toString("yyyy"); case "%g": return x._format("%G").slice(-2); case "a": case "%p": return t("tt").toLowerCase(); case "A": return t("tt").toUpperCase(); case "u": return p(x.getMilliseconds(), 3); case "I": return (x.isDaylightSavingTime()) ? 1 : 0; case "O": return x.getUTCOffset(); case "P": y = x.getUTCOffset(); return y.substring(0, y.length - 2) + ":" + y.substring(y.length - 2); case "B": var now = new Date(); return Math.floor(((now.getHours() * 3600) + (now.getMinutes() * 60) + now.getSeconds() + (now.getTimezoneOffset() + 60) * 60) / 86.4); case "c": return x.toISOString().replace(/\"/g, ""); case "U": return $D.strtotime("now"); case "%c": return t("d") + " " + t("t"); case "%C": return Math.floor(x.getFullYear() / 100 + 1); } }, shouldOverrideDefaults: function (m) { switch (m) { case "%e": return true; default: return false; } }, parse: function (m, context) { var formatString, c = context || new Date(); formatString = normalizer.substitutes(m); if (formatString) { return formatString; } formatString = normalizer.interpreted(m, c); if (formatString) { return formatString; } else { return m; } } }; $D.normalizeFormat = function (format, context) { return format.replace(/(%|\\)?.|%%/g, function(t){ return normalizer.parse(t, context); }); }; /** * Format a local Unix timestamp according to locale settings * * Example: * Date.strftime("%m/%d/%y", new Date()); // "04/13/08" * Date.strftime("c", "2008-04-13T17:52:03Z"); // "04/13/08" * * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @param {Number|String} The number representing the number of seconds that have elapsed since January 1, 1970 (local time). * @return {String} A string representation of the current Date object. */ $D.strftime = function (format, time) { var d = Date.parse(time); return d._format(format); }; /** * Parse any textual datetime description into a Unix timestamp. * A Unix timestamp is the number of seconds that have elapsed since January 1, 1970 (midnight UTC/GMT). * * Example: * Date.strtotime("04/13/08"); // 1208044800 * Date.strtotime("1970-01-01T00:00:00Z"); // 0 * * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @param {Object} A string or date object. * @return {String} A string representation of the current Date object. */ $D.strtotime = function (time) { var d = $D.parse(time); return Math.round($D.UTC(d.getUTCFullYear(), d.getUTCMonth(), d.getUTCDate(), d.getUTCHours(), d.getUTCMinutes(), d.getUTCSeconds(), d.getUTCMilliseconds()) / 1000); }; /** * Converts the value of the current Date object to its equivalent string representation using a PHP/Unix style of date format specifiers. * Format Specifiers * Format Description Example * ------ --------------------------------------------------------------------------- ----------------------- * %a abbreviated weekday name according to the current localed "Mon" through "Sun" * %A full weekday name according to the current localed "Sunday" through "Saturday" * %b abbreviated month name according to the current localed "Jan" through "Dec" * %B full month name according to the current locale "January" through "December" * %c preferred date and time representation for the current locale "4/13/2008 12:33 PM" * %C century number (the year divided by 100 and truncated to an integer) "00" to "99" * %d day of the month as a decimal number "01" to "31" * %D same as %m/%d/%y "04/13/08" * %e day of the month as a decimal number, a single digit is preceded by a space "1" to "31" * %g like %G, but without the century "08" * %G The 4-digit year corresponding to the ISO week number (see %V). "2008" * This has the same format and value as %Y, except that if the ISO week number * belongs to the previous or next year, that year is used instead. * %h same as %b "Jan" through "Dec" * %H hour as a decimal number using a 24-hour clock. "00" to "23" * %I hour as a decimal number using a 12-hour clock. "01" to "12" * %j day of the year as a decimal number. "001" to "366" * %m month as a decimal number. "01" to "12" * %M minute as a decimal number. "00" to "59" * %n newline character "\n" * %p either "am" or "pm" according to the given time value, or the "am" or "pm" * corresponding strings for the current locale. * %r time in a.m. and p.m. notation "8:44 PM" * %R time in 24 hour notation "20:44" * %S second as a decimal number "00" to "59" * %t tab character "\t" * %T current time, equal to %H:%M:%S "12:49:11" * %u weekday as a decimal number ["1", "7"], with "1" representing Monday "1" to "7" * %U week number of the current year as a decimal number, starting with the "0" to ("52" or "53") * first Sunday as the first day of the first week * %V The ISO 8601:1988 week number of the current year as a decimal number, "00" to ("52" or "53") * range 01 to 53, where week 1 is the first week that has at least 4 days * in the current year, and with Monday as the first day of the week. * (Use %G or %g for the year component that corresponds to the week number * for the specified timestamp.) * %W week number of the current year as a decimal number, starting with the "00" to ("52" or "53") * first Monday as the first day of the first week * %w day of the week as a decimal, Sunday being "0" "0" to "6" * %x preferred date representation for the current locale without the time "4/13/2008" * %X preferred time representation for the current locale without the date "12:53:05" * %y year as a decimal number without a century "00" "99" * %Y year as a decimal number including the century "2008" * %Z time zone or name or abbreviation "UTC", "EST", "PST" * %z same as %Z * %% a literal "%" characters "%" * d Day of the month, 2 digits with leading zeros "01" to "31" * D A textual representation of a day, three letters "Mon" through "Sun" * j Day of the month without leading zeros "1" to "31" * l A full textual representation of the day of the week (lowercase "L") "Sunday" through "Saturday" * N ISO-8601 numeric representation of the day of the week (added in PHP 5.1.0) "1" (for Monday) through "7" (for Sunday) * S English ordinal suffix for the day of the month, 2 characters "st", "nd", "rd" or "th". Works well with j * w Numeric representation of the day of the week "0" (for Sunday) through "6" (for Saturday) * z The day of the year (starting from "0") "0" through "365" * W ISO-8601 week number of year, weeks starting on Monday "00" to ("52" or "53") * F A full textual representation of a month, such as January or March "January" through "December" * m Numeric representation of a month, with leading zeros "01" through "12" * M A short textual representation of a month, three letters "Jan" through "Dec" * n Numeric representation of a month, without leading zeros "1" through "12" * t Number of days in the given month "28" through "31" * L Whether it's a leap year "1" if it is a leap year, "0" otherwise * o ISO-8601 year number. This has the same value as Y, except that if the "2008" * ISO week number (W) belongs to the previous or next year, that year * is used instead. * Y A full numeric representation of a year, 4 digits "2008" * y A two digit representation of a year "08" * a Lowercase Ante meridiem and Post meridiem "am" or "pm" * A Uppercase Ante meridiem and Post meridiem "AM" or "PM" * B Swatch Internet time "000" through "999" * g 12-hour format of an hour without leading zeros "1" through "12" * G 24-hour format of an hour without leading zeros "0" through "23" * h 12-hour format of an hour with leading zeros "01" through "12" * H 24-hour format of an hour with leading zeros "00" through "23" * i Minutes with leading zeros "00" to "59" * s Seconds, with leading zeros "00" through "59" * u Milliseconds "54321" * e Timezone identifier "UTC", "EST", "PST" * I Whether or not the date is in daylight saving time (uppercase i) "1" if Daylight Saving Time, "0" otherwise * O Difference to Greenwich time (GMT) in hours "+0200", "-0600" * P Difference to Greenwich time (GMT) with colon between hours and minutes "+02:00", "-06:00" * T Timezone abbreviation "UTC", "EST", "PST" * Z Timezone offset in seconds. The offset for timezones west of UTC is "-43200" through "50400" * always negative, and for those east of UTC is always positive. * c ISO 8601 date "2004-02-12T15:19:21+00:00" * r RFC 2822 formatted date "Thu, 21 Dec 2000 16:01:07 +0200" * U Seconds since the Unix Epoch (January 1 1970 00:00:00 GMT) "0" * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @return {String} A string representation of the current Date object. */ var formatReplace = function (context) { return function (m) { var formatString, override = false; if (m.charAt(0) === "\\" || m.substring(0, 2) === "%%") { return m.replace("\\", "").replace("%%", "%"); } override = normalizer.shouldOverrideDefaults(m); formatString = $D.normalizeFormat(m, context); if (formatString) { return context.toString(formatString, override); } }; }; $P._format = function (format) { var formatter = formatReplace(this); if (!format) { return this._toString(); } else { return format.replace(/(%|\\)?.|%%/g, formatter); } }; if (!$P.format) { $P.format = $P._format; } }()); (function () { "use strict"; var gFn = function (attr) { return function () { return this[attr]; }; }; var sFn = function (attr) { return function (val) { this[attr] = val; return this; }; }; var attrs = ["years", "months", "days", "hours", "minutes", "seconds", "milliseconds"]; var addSetFuncs = function (context, attrs) { for (var i = 0; i < attrs.length ; i++) { var $a = attrs[i], $b = $a.slice(0, 1).toUpperCase() + $a.slice(1); context.prototype[$a] = 0; context.prototype["get" + $b] = gFn($a); context.prototype["set" + $b] = sFn($a); } }; /** * new TimeSpan(milliseconds); * new TimeSpan(days, hours, minutes, seconds); * new TimeSpan(days, hours, minutes, seconds, milliseconds); */ var TimeSpan = function (days, hours, minutes, seconds, milliseconds) { if (arguments.length === 1 && typeof days === "number") { var orient = (days < 0) ? -1 : +1; var millsLeft = Math.abs(days); this.setDays(Math.floor(millsLeft / 86400000) * orient); millsLeft = millsLeft % 86400000; this.setHours(Math.floor(millsLeft / 3600000) * orient); millsLeft = millsLeft % 3600000; this.setMinutes(Math.floor(millsLeft / 60000) * orient); millsLeft = millsLeft % 60000; this.setSeconds(Math.floor(millsLeft / 1000) * orient); millsLeft = millsLeft % 1000; this.setMilliseconds(millsLeft * orient); } else { this.set(days, hours, minutes, seconds, milliseconds); } this.getTotalMilliseconds = function () { return (this.getDays() * 86400000) + (this.getHours() * 3600000) + (this.getMinutes() * 60000) + (this.getSeconds() * 1000); }; this.compareTo = function (time) { var t1 = new Date(1970, 1, 1, this.getHours(), this.getMinutes(), this.getSeconds()), t2; if (time === null) { t2 = new Date(1970, 1, 1, 0, 0, 0); } else { t2 = new Date(1970, 1, 1, time.getHours(), time.getMinutes(), time.getSeconds()); } return (t1 < t2) ? -1 : (t1 > t2) ? 1 : 0; }; this.equals = function (time) { return (this.compareTo(time) === 0); }; this.add = function (time) { return (time === null) ? this : this.addSeconds(time.getTotalMilliseconds() / 1000); }; this.subtract = function (time) { return (time === null) ? this : this.addSeconds(-time.getTotalMilliseconds() / 1000); }; this.addDays = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 86400000)); }; this.addHours = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 3600000)); }; this.addMinutes = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 60000)); }; this.addSeconds = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 1000)); }; this.addMilliseconds = function (n) { return new TimeSpan(this.getTotalMilliseconds() + n); }; this.get12HourHour = function () { return (this.getHours() > 12) ? this.getHours() - 12 : (this.getHours() === 0) ? 12 : this.getHours(); }; this.getDesignator = function () { return (this.getHours() < 12) ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator; }; this.toString = function (format) { this._toString = function () { if (this.getDays() !== null && this.getDays() > 0) { return this.getDays() + "." + this.getHours() + ":" + this.p(this.getMinutes()) + ":" + this.p(this.getSeconds()); } else { return this.getHours() + ":" + this.p(this.getMinutes()) + ":" + this.p(this.getSeconds()); } }; this.p = function (s) { return (s.toString().length < 2) ? "0" + s : s; }; var me = this; return format ? format.replace(/dd?|HH?|hh?|mm?|ss?|tt?/g, function (format) { switch (format) { case "d": return me.getDays(); case "dd": return me.p(me.getDays()); case "H": return me.getHours(); case "HH": return me.p(me.getHours()); case "h": return me.get12HourHour(); case "hh": return me.p(me.get12HourHour()); case "m": return me.getMinutes(); case "mm": return me.p(me.getMinutes()); case "s": return me.getSeconds(); case "ss": return me.p(me.getSeconds()); case "t": return ((me.getHours() < 12) ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator).substring(0, 1); case "tt": return (me.getHours() < 12) ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator; } } ) : this._toString(); }; return this; }; addSetFuncs(TimeSpan, attrs.slice(2)); TimeSpan.prototype.set = function (days, hours, minutes, seconds, milliseconds){ this.setDays(days || this.getDays()); this.setHours(hours || this.getHours()); this.setMinutes(minutes || this.getMinutes()); this.setSeconds(seconds || this.getSeconds()); this.setMilliseconds(milliseconds || this.getMilliseconds()); }; /** * Gets the time of day for this date instances. * @return {TimeSpan} TimeSpan */ Date.prototype.getTimeOfDay = function () { return new TimeSpan(0, this.getHours(), this.getMinutes(), this.getSeconds(), this.getMilliseconds()); }; Date.TimeSpan = TimeSpan; if (typeof window !== "undefined" ) { // keeping API compatible for v1.x window.TimeSpan = TimeSpan; } }()); (function () { "use strict"; var attrs = ["years", "months", "days", "hours", "minutes", "seconds", "milliseconds"]; var gFn = function (attr) { return function () { return this[attr]; }; }; var sFn = function (attr) { return function (val) { this[attr] = val; return this; }; }; var addSetFuncs = function (context, attrs) { for (var i = 0; i < attrs.length ; i++) { var $a = attrs[i], $b = $a.slice(0, 1).toUpperCase() + $a.slice(1); context.prototype[$a] = 0; context.prototype["get" + $b] = gFn($a); context.prototype["set" + $b] = sFn($a); } }; var setMonthsAndYears = function (orient, d1, d2, context) { function inc() { d1.addMonths(-orient); context.months++; if (context.months === 12) { context.years++; context.months = 0; } } if (orient === +1) { while (d1 > d2) { inc(); } } else { while (d1 < d2) { inc(); } } context.months--; context.months *= orient; context.years *= orient; }; var adjustForDST = function(orient, startDate, endDate) { var hasDSTMismatch = (false === (startDate.isDaylightSavingTime() === endDate.isDaylightSavingTime())); if (hasDSTMismatch && orient === 1) { startDate.addHours(-1); } else if (hasDSTMismatch) { startDate.addHours(1); } }; /** * TimePeriod(startDate, endDate); * TimePeriod(years, months, days, hours, minutes, seconds, milliseconds); */ var TimePeriod = function (years, months, days, hours, minutes, seconds, milliseconds) { if (arguments.length === 7) { this.set(years, months, days, hours, minutes, seconds, milliseconds); } else if (arguments.length === 2 && arguments[0] instanceof Date && arguments[1] instanceof Date) { var startDate = arguments[0].clone(); var endDate = arguments[1].clone(); var orient = (startDate > endDate) ? +1 : -1; this.dates = { start: arguments[0].clone(), end: arguments[1].clone() }; setMonthsAndYears(orient, startDate, endDate, this); adjustForDST(orient, startDate, endDate); // // TODO - adjust for DST var diff = endDate - startDate; if (diff !== 0) { var ts = new TimeSpan(diff); this.set(this.years, this.months, ts.getDays(), ts.getHours(), ts.getMinutes(), ts.getSeconds(), ts.getMilliseconds()); } } return this; }; // create all the set functions. addSetFuncs(TimePeriod, attrs); TimePeriod.prototype.set = function (years, months, days, hours, minutes, seconds, milliseconds){ this.setYears(years || this.getYears()); this.setMonths(months || this.getMonths()); this.setDays(days || this.getDays()); this.setHours(hours || this.getHours()); this.setMinutes(minutes || this.getMinutes()); this.setSeconds(seconds || this.getSeconds()); this.setMilliseconds(milliseconds || this.getMilliseconds()); }; Date.TimePeriod = TimePeriod; if (typeof window !== "undefined") { // keeping API compatible for v1.x window.TimePeriod = TimePeriod; } }()); ================================================ FILE: build/date-lv-LV.js ================================================ /** * @overview datejs * @version 1.0.0-rc3 * @author Gregory Wild-Smith * @copyright 2015 Gregory Wild-Smith * @license MIT * @homepage https://github.com/abritinthebay/datejs */ /* * DateJS Culture String File * Country Code: lv-LV * Name: Latvian (Latvia) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["lv-LV"] = { "name": "lv-LV", "englishName": "Latvian (Latvia)", "nativeName": "latviešu (Latvija)", "Sunday": "svētdiena", "Monday": "pirmdiena", "Tuesday": "otrdiena", "Wednesday": "trešdiena", "Thursday": "ceturtdiena", "Friday": "piektdiena", "Saturday": "sestdiena", "Sun": "Sv", "Mon": "Pr", "Tue": "Ot", "Wed": "Tr", "Thu": "Ce", "Fri": "Pk", "Sat": "Se", "Su": "Sv", "Mo": "Pr", "Tu": "Ot", "We": "Tr", "Th": "Ce", "Fr": "Pk", "Sa": "Se", "S_Sun_Initial": "S", "M_Mon_Initial": "P", "T_Tue_Initial": "O", "W_Wed_Initial": "T", "T_Thu_Initial": "C", "F_Fri_Initial": "P", "S_Sat_Initial": "S", "January": "janvāris", "February": "februāris", "March": "marts", "April": "aprīlis", "May": "maijs", "June": "jūnijs", "July": "jūlijs", "August": "augusts", "September": "septembris", "October": "oktobris", "November": "novembris", "December": "decembris", "Jan_Abbr": "Jan", "Feb_Abbr": "Feb", "Mar_Abbr": "Mar", "Apr_Abbr": "Apr", "May_Abbr": "Mai", "Jun_Abbr": "Jūn", "Jul_Abbr": "Jūl", "Aug_Abbr": "Aug", "Sep_Abbr": "Sep", "Oct_Abbr": "Okt", "Nov_Abbr": "Nov", "Dec_Abbr": "Dec", "AM": "", "PM": "", "firstDayOfWeek": 1, "twoDigitYearMax": 2029, "mdy": "ymd", "M/d/yyyy": "yyyy.MM.dd.", "dddd, MMMM dd, yyyy": "dddd, yyyy'. gada 'd. MMMM", "h:mm tt": "H:mm", "h:mm:ss tt": "H:mm:ss", "dddd, MMMM dd, yyyy h:mm:ss tt": "dddd, yyyy'. gada 'd. MMMM H:mm:ss", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "d. MMMM", "MMMM, yyyy": "yyyy. MMMM", "/jan(uary)?/": "jan(vāris)?", "/feb(ruary)?/": "feb(ruāris)?", "/mar(ch)?/": "mar(ts)?", "/apr(il)?/": "apr(īlis)?", "/may/": "mai(js)?", "/jun(e)?/": "jūn(ijs)?", "/jul(y)?/": "jūl(ijs)?", "/aug(ust)?/": "aug(usts)?", "/sep(t(ember)?)?/": "sep(tembris)?", "/oct(ober)?/": "okt(obris)?", "/nov(ember)?/": "nov(embris)?", "/dec(ember)?/": "dec(embris)?", "/^su(n(day)?)?/": "^svētdiena", "/^mo(n(day)?)?/": "^pirmdiena", "/^tu(e(s(day)?)?)?/": "^otrdiena", "/^we(d(nesday)?)?/": "^trešdiena", "/^th(u(r(s(day)?)?)?)?/": "^ceturtdiena", "/^fr(i(day)?)?/": "^piektdiena", "/^sa(t(urday)?)?/": "^sestdiena", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "lv-LV"; /** * @overview datejs * @version 1.0.0-rc3 * @author Gregory Wild-Smith * @copyright 2015 Gregory Wild-Smith * @license MIT * @homepage https://github.com/abritinthebay/datejs */(function () { var $D = Date; var lang = Date.CultureStrings ? Date.CultureStrings.lang : null; var loggedKeys = {}; // for debug purposes. var getText = { getFromKey: function (key, countryCode) { var output; if (Date.CultureStrings && Date.CultureStrings[countryCode] && Date.CultureStrings[countryCode][key]) { output = Date.CultureStrings[countryCode][key]; } else { output = getText.buildFromDefault(key); } if (key.charAt(0) === "/") { // Assume it's a regex output = getText.buildFromRegex(key, countryCode); } return output; }, getFromObjectValues: function (obj, countryCode) { var key, output = {}; for(key in obj) { if (obj.hasOwnProperty(key)) { output[key] = getText.getFromKey(obj[key], countryCode); } } return output; }, getFromObjectKeys: function (obj, countryCode) { var key, output = {}; for(key in obj) { if (obj.hasOwnProperty(key)) { output[getText.getFromKey(key, countryCode)] = obj[key]; } } return output; }, getFromArray: function (arr, countryCode) { var output = []; for (var i=0; i < arr.length; i++){ if (i in arr) { output[i] = getText.getFromKey(arr[i], countryCode); } } return output; }, buildFromDefault: function (key) { var output, length, split, last; switch(key) { case "name": output = "en-US"; break; case "englishName": output = "English (United States)"; break; case "nativeName": output = "English (United States)"; break; case "twoDigitYearMax": output = 2049; break; case "firstDayOfWeek": output = 0; break; default: output = key; split = key.split("_"); length = split.length; if (length > 1 && key.charAt(0) !== "/") { // if the key isn't a regex and it has a split. last = split[(length - 1)].toLowerCase(); if (last === "initial" || last === "abbr") { output = split[0]; } } break; } return output; }, buildFromRegex: function (key, countryCode) { var output; if (Date.CultureStrings && Date.CultureStrings[countryCode] && Date.CultureStrings[countryCode][key]) { output = new RegExp(Date.CultureStrings[countryCode][key], "i"); } else { output = new RegExp(key.replace(new RegExp("/", "g"),""), "i"); } return output; } }; var shallowMerge = function (obj1, obj2) { for (var attrname in obj2) { if (obj2.hasOwnProperty(attrname)) { obj1[attrname] = obj2[attrname]; } } }; var __ = function (key, language) { var countryCode = (language) ? language : lang; loggedKeys[key] = key; if (typeof key === "object") { if (key instanceof Array) { return getText.getFromArray(key, countryCode); } else { return getText.getFromObjectKeys(key, countryCode); } } else { return getText.getFromKey(key, countryCode); } }; var loadI18nScript = function (code) { // paatterned after jQuery's getScript. var url = Date.Config.i18n + code + ".js"; var head = document.getElementsByTagName("head")[0] || document.documentElement; var script = document.createElement("script"); script.src = url; var completed = false; var events = { done: function (){} // placeholder function }; // Attach handlers for all browsers script.onload = script.onreadystatechange = function() { if ( !completed && (!this.readyState || this.readyState === "loaded" || this.readyState === "complete") ) { events.done(); head.removeChild(script); } }; setTimeout(function() { head.insertBefore(script, head.firstChild); }, 0); // allows return to execute first return { done: function (cb) { events.done = function() { if (cb) { setTimeout(cb,0); } }; } }; }; var buildInfo = { buildFromMethodHash: function (obj) { var key; for(key in obj) { if (obj.hasOwnProperty(key)) { obj[key] = buildInfo[obj[key]](); } } return obj; }, timeZoneDST: function () { var DST = { "CHADT": "+1345", "NZDT": "+1300", "AEDT": "+1100", "ACDT": "+1030", "AZST": "+0500", "IRDT": "+0430", "EEST": "+0300", "CEST": "+0200", "BST": "+0100", "PMDT": "-0200", "ADT": "-0300", "NDT": "-0230", "EDT": "-0400", "CDT": "-0500", "MDT": "-0600", "PDT": "-0700", "AKDT": "-0800", "HADT": "-0900" }; return __(DST); }, timeZoneStandard: function () { var standard = { "LINT": "+1400", "TOT": "+1300", "CHAST": "+1245", "NZST": "+1200", "NFT": "+1130", "SBT": "+1100", "AEST": "+1000", "ACST": "+0930", "JST": "+0900", "CWST": "+0845", "CT": "+0800", "ICT": "+0700", "MMT": "+0630", "BST": "+0600", "NPT": "+0545", "IST": "+0530", "PKT": "+0500", "AFT": "+0430", "MSK": "+0400", "IRST": "+0330", "FET": "+0300", "EET": "+0200", "CET": "+0100", "GMT": "+0000", "UTC": "+0000", "CVT": "-0100", "GST": "-0200", "BRT": "-0300", "NST": "-0330", "AST": "-0400", "EST": "-0500", "CST": "-0600", "MST": "-0700", "PST": "-0800", "AKST": "-0900", "MIT": "-0930", "HST": "-1000", "SST": "-1100", "BIT": "-1200" }; return __(standard); }, timeZones: function (data) { var zone; data.timezones = []; for (zone in data.abbreviatedTimeZoneStandard) { if (data.abbreviatedTimeZoneStandard.hasOwnProperty(zone)) { data.timezones.push({ name: zone, offset: data.abbreviatedTimeZoneStandard[zone]}); } } for (zone in data.abbreviatedTimeZoneDST) { if (data.abbreviatedTimeZoneDST.hasOwnProperty(zone)) { data.timezones.push({ name: zone, offset: data.abbreviatedTimeZoneDST[zone], dst: true}); } } return data.timezones; }, days: function () { return __(["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"]); }, dayAbbr: function () { return __(["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"]); }, dayShortNames: function () { return __(["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"]); }, dayFirstLetters: function () { return __(["S_Sun_Initial", "M_Mon_Initial", "T_Tues_Initial", "W_Wed_Initial", "T_Thu_Initial", "F_Fri_Initial", "S_Sat_Initial"]); }, months: function () { return __(["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"]); }, monthAbbr: function () { return __(["Jan_Abbr", "Feb_Abbr", "Mar_Abbr", "Apr_Abbr", "May_Abbr", "Jun_Abbr", "Jul_Abbr", "Aug_Abbr", "Sep_Abbr", "Oct_Abbr", "Nov_Abbr", "Dec_Abbr"]); }, formatPatterns: function () { return getText.getFromObjectValues({ shortDate: "M/d/yyyy", longDate: "dddd, MMMM dd, yyyy", shortTime: "h:mm tt", longTime: "h:mm:ss tt", fullDateTime: "dddd, MMMM dd, yyyy h:mm:ss tt", sortableDateTime: "yyyy-MM-ddTHH:mm:ss", universalSortableDateTime: "yyyy-MM-dd HH:mm:ssZ", rfc1123: "ddd, dd MMM yyyy HH:mm:ss", monthDay: "MMMM dd", yearMonth: "MMMM, yyyy" }, Date.i18n.currentLanguage()); }, regex: function () { return getText.getFromObjectValues({ inTheMorning: "/( in the )(morn(ing)?)\\b/", thisMorning: "/(this )(morn(ing)?)\\b/", amThisMorning: "/(\b\\d(am)? )(this )(morn(ing)?)/", inTheEvening: "/( in the )(even(ing)?)\\b/", thisEvening: "/(this )(even(ing)?)\\b/", pmThisEvening: "/(\b\\d(pm)? )(this )(even(ing)?)/", jan: "/jan(uary)?/", feb: "/feb(ruary)?/", mar: "/mar(ch)?/", apr: "/apr(il)?/", may: "/may/", jun: "/jun(e)?/", jul: "/jul(y)?/", aug: "/aug(ust)?/", sep: "/sep(t(ember)?)?/", oct: "/oct(ober)?/", nov: "/nov(ember)?/", dec: "/dec(ember)?/", sun: "/^su(n(day)?)?/", mon: "/^mo(n(day)?)?/", tue: "/^tu(e(s(day)?)?)?/", wed: "/^we(d(nesday)?)?/", thu: "/^th(u(r(s(day)?)?)?)?/", fri: "/fr(i(day)?)?/", sat: "/^sa(t(urday)?)?/", future: "/^next/", past: "/^last|past|prev(ious)?/", add: "/^(\\+|aft(er)?|from|hence)/", subtract: "/^(\\-|bef(ore)?|ago)/", yesterday: "/^yes(terday)?/", today: "/^t(od(ay)?)?/", tomorrow: "/^tom(orrow)?/", now: "/^n(ow)?/", millisecond: "/^ms|milli(second)?s?/", second: "/^sec(ond)?s?/", minute: "/^mn|min(ute)?s?/", hour: "/^h(our)?s?/", week: "/^w(eek)?s?/", month: "/^m(onth)?s?/", day: "/^d(ay)?s?/", year: "/^y(ear)?s?/", shortMeridian: "/^(a|p)/", longMeridian: "/^(a\\.?m?\\.?|p\\.?m?\\.?)/", timezone: "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/", ordinalSuffix: "/^\\s*(st|nd|rd|th)/", timeContext: "/^\\s*(\\:|a(?!u|p)|p)/" }, Date.i18n.currentLanguage()); } }; var CultureInfo = function () { var info = getText.getFromObjectValues({ name: "name", englishName: "englishName", nativeName: "nativeName", amDesignator: "AM", pmDesignator: "PM", firstDayOfWeek: "firstDayOfWeek", twoDigitYearMax: "twoDigitYearMax", dateElementOrder: "mdy" }, Date.i18n.currentLanguage()); var constructedInfo = buildInfo.buildFromMethodHash({ dayNames: "days", abbreviatedDayNames: "dayAbbr", shortestDayNames: "dayShortNames", firstLetterDayNames: "dayFirstLetters", monthNames: "months", abbreviatedMonthNames: "monthAbbr", formatPatterns: "formatPatterns", regexPatterns: "regex", abbreviatedTimeZoneDST: "timeZoneDST", abbreviatedTimeZoneStandard: "timeZoneStandard" }); shallowMerge(info, constructedInfo); buildInfo.timeZones(info); return info; }; $D.i18n = { __: function (key, lang) { return __(key, lang); }, currentLanguage: function () { return lang || "en-US"; }, setLanguage: function (code, force, cb) { var async = false; if (force || code === "en-US" || (!!Date.CultureStrings && !!Date.CultureStrings[code])) { lang = code; Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings.lang = code; Date.CultureInfo = new CultureInfo(); } else { if (!(!!Date.CultureStrings && !!Date.CultureStrings[code])) { if (typeof exports !== "undefined" && this.exports !== exports) { // we're in a Node enviroment, load it using require try { require("../i18n/" + code + ".js"); lang = code; Date.CultureStrings.lang = code; Date.CultureInfo = new CultureInfo(); } catch (e) { // var str = "The language for '" + code + "' could not be loaded by Node. It likely does not exist."; throw new Error("The DateJS IETF language tag '" + code + "' could not be loaded by Node. It likely does not exist."); } } else if (Date.Config && Date.Config.i18n) { // we know the location of the files, so lets load them async = true; loadI18nScript(code).done(function(){ lang = code; Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings.lang = code; Date.CultureInfo = new CultureInfo(); $D.Parsing.Normalizer.buildReplaceData(); // because this is async if ($D.Grammar) { $D.Grammar.buildGrammarFormats(); // so we can parse those strings... } if (cb) { setTimeout(cb,0); } }); } else { Date.console.error("The DateJS IETF language tag '" + code + "' is not available and has not been loaded."); return false; } } } $D.Parsing.Normalizer.buildReplaceData(); // rebuild normalizer strings if ($D.Grammar) { $D.Grammar.buildGrammarFormats(); // so we can parse those strings... } if (!async && cb) { setTimeout(cb,0); } }, getLoggedKeys: function () { return loggedKeys; }, updateCultureInfo: function () { Date.CultureInfo = new CultureInfo(); } }; $D.i18n.updateCultureInfo(); // run automatically }()); (function () { var $D = Date, $P = $D.prototype, p = function (s, l) { if (!l) { l = 2; } return ("000" + s).slice(l * -1); }; if (typeof window !== "undefined" && typeof window.console !== "undefined" && typeof window.console.log !== "undefined") { $D.console = console; // used only to raise non-critical errors if available } else { // set mock so we don't give errors. $D.console = { log: function(){}, error: function(){} }; } $D.Config = $D.Config || {}; $D.initOverloads = function() { /** * Overload of Date.now. Allows an alternate call for Date.now where it returns the * current Date as an object rather than just milliseconds since the Unix Epoch. * * Also provides an implementation of now() for browsers (IE<9) that don't have it. * * Backwards compatible so with work with either: * Date.now() [returns ms] * or * Date.now(true) [returns Date] */ if (!$D.now) { $D._now = function now() { return new Date().getTime(); }; } else if (!$D._now) { $D._now = $D.now; } $D.now = function (returnObj) { if (returnObj) { return $D.present(); } else { return $D._now(); } }; if ( !$P.toISOString ) { $P.toISOString = function() { return this.getUTCFullYear() + "-" + p(this.getUTCMonth() + 1) + "-" + p(this.getUTCDate()) + "T" + p(this.getUTCHours()) + ":" + p(this.getUTCMinutes()) + ":" + p(this.getUTCSeconds()) + "." + String( (this.getUTCMilliseconds()/1000).toFixed(3)).slice(2, 5) + "Z"; }; } // private if ( $P._toString === undefined ){ $P._toString = $P.toString; } }; $D.initOverloads(); /** * Gets a date that is set to the current date. The time is set to the start of the day (00:00 or 12:00 AM). * @return {Date} The current date. */ $D.today = function () { return new Date().clearTime(); }; /** * Gets a date that is set to the current date and time (same as new Date, but chainable) * @return {Date} The current date. */ $D.present = function () { return new Date(); }; /** * Compares the first date to the second date and returns an number indication of their relative values. * @param {Date} First Date object to compare [Required]. * @param {Date} Second Date object to compare to [Required]. * @return {Number} -1 = date1 is lessthan date2. 0 = values are equal. 1 = date1 is greaterthan date2. */ $D.compare = function (date1, date2) { if (isNaN(date1) || isNaN(date2)) { throw new Error(date1 + " - " + date2); } else if (date1 instanceof Date && date2 instanceof Date) { return (date1 < date2) ? -1 : (date1 > date2) ? 1 : 0; } else { throw new TypeError(date1 + " - " + date2); } }; /** * Compares the first Date object to the second Date object and returns true if they are equal. * @param {Date} First Date object to compare [Required] * @param {Date} Second Date object to compare to [Required] * @return {Boolean} true if dates are equal. false if they are not equal. */ $D.equals = function (date1, date2) { return (date1.compareTo(date2) === 0); }; /** * Gets the language appropriate day name when given the day number(0-6) * eg - 0 == Sunday * @return {String} The day name */ $D.getDayName = function (n) { return Date.CultureInfo.dayNames[n]; }; /** * Gets the day number (0-6) if given a CultureInfo specific string which is a valid dayName, abbreviatedDayName or shortestDayName (two char). * @param {String} The name of the day (eg. "Monday, "Mon", "tuesday", "tue", "We", "we"). * @return {Number} The day number */ $D.getDayNumberFromName = function (name) { var n = Date.CultureInfo.dayNames, m = Date.CultureInfo.abbreviatedDayNames, o = Date.CultureInfo.shortestDayNames, s = name.toLowerCase(); for (var i = 0; i < n.length; i++) { if (n[i].toLowerCase() === s || m[i].toLowerCase() === s || o[i].toLowerCase() === s) { return i; } } return -1; }; /** * Gets the month number (0-11) if given a Culture Info specific string which is a valid monthName or abbreviatedMonthName. * @param {String} The name of the month (eg. "February, "Feb", "october", "oct"). * @return {Number} The day number */ $D.getMonthNumberFromName = function (name) { var n = Date.CultureInfo.monthNames, m = Date.CultureInfo.abbreviatedMonthNames, s = name.toLowerCase(); for (var i = 0; i < n.length; i++) { if (n[i].toLowerCase() === s || m[i].toLowerCase() === s) { return i; } } return -1; }; /** * Gets the language appropriate month name when given the month number(0-11) * eg - 0 == January * @return {String} The month name */ $D.getMonthName = function (n) { return Date.CultureInfo.monthNames[n]; }; /** * Determines if the current date instance is within a LeapYear. * @param {Number} The year. * @return {Boolean} true if date is within a LeapYear, otherwise false. */ $D.isLeapYear = function (year) { return ((year % 4 === 0 && year % 100 !== 0) || year % 400 === 0); }; /** * Gets the number of days in the month, given a year and month value. Automatically corrects for LeapYear. * @param {Number} The year. * @param {Number} The month (0-11). * @return {Number} The number of days in the month. */ $D.getDaysInMonth = function (year, month) { if (!month && $D.validateMonth(year)) { month = year; year = Date.today().getFullYear(); } return [31, ($D.isLeapYear(year) ? 29 : 28), 31, 30, 31, 30, 31, 31, 30, 31, 30, 31][month]; }; $P.getDaysInMonth = function () { return $D.getDaysInMonth(this.getFullYear(), this.getMonth()); }; $D.getTimezoneAbbreviation = function (offset, dst) { var p, n = (dst || false) ? Date.CultureInfo.abbreviatedTimeZoneDST : Date.CultureInfo.abbreviatedTimeZoneStandard; for (p in n) { if (n.hasOwnProperty(p)) { if (n[p] === offset) { return p; } } } return null; }; $D.getTimezoneOffset = function (name, dst) { var i, a =[], z = Date.CultureInfo.timezones; if (!name) { name = (new Date()).getTimezone();} for (i = 0; i < z.length; i++) { if (z[i].name === name.toUpperCase()) { a.push(i); } } if (!z[a[0]]) { return null; } if (a.length === 1 || !dst) { return z[a[0]].offset; } else { for (i=0; i < a.length; i++) { if (z[a[i]].dst) { return z[a[i]].offset; } } } }; $D.getQuarter = function (d) { d = d || new Date(); // If no date supplied, use today var q = [1,2,3,4]; return q[Math.floor(d.getMonth() / 3)]; // ~~~ is a bitwise op. Faster than Math.floor }; $D.getDaysLeftInQuarter = function (d) { d = d || new Date(); var qEnd = new Date(d); qEnd.setMonth(qEnd.getMonth() + 3 - qEnd.getMonth() % 3, 0); return Math.floor((qEnd - d) / 8.64e7); }; // private var validate = function (n, min, max, name) { name = name ? name : "Object"; if (typeof n === "undefined") { return false; } else if (typeof n !== "number") { throw new TypeError(n + " is not a Number."); } else if (n < min || n > max) { // As failing validation is *not* an exceptional circumstance // lets not throw a RangeError Exception here. // It's semantically correct but it's not sensible. return false; } return true; }; /** * Validates the number is within an acceptable range for milliseconds [0-999]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateMillisecond = function (value) { return validate(value, 0, 999, "millisecond"); }; /** * Validates the number is within an acceptable range for seconds [0-59]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateSecond = function (value) { return validate(value, 0, 59, "second"); }; /** * Validates the number is within an acceptable range for minutes [0-59]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateMinute = function (value) { return validate(value, 0, 59, "minute"); }; /** * Validates the number is within an acceptable range for hours [0-23]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateHour = function (value) { return validate(value, 0, 23, "hour"); }; /** * Validates the number is within an acceptable range for the days in a month [0-MaxDaysInMonth]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateDay = function (value, year, month) { if (year === undefined || year === null || month === undefined || month === null) { return false;} return validate(value, 1, $D.getDaysInMonth(year, month), "day"); }; /** * Validates the number is within an acceptable range for months [0-11]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateWeek = function (value) { return validate(value, 0, 53, "week"); }; /** * Validates the number is within an acceptable range for months [0-11]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateMonth = function (value) { return validate(value, 0, 11, "month"); }; /** * Validates the number is within an acceptable range for years. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateYear = function (value) { /** * Per ECMAScript spec the range of times supported by Date objects is * exactly -100,000,000 days to +100,000,000 days measured relative to * midnight at the beginning of 01 January, 1970 UTC. * This gives a range of 8,640,000,000,000,000 milliseconds to either * side of 01 January, 1970 UTC. * * Earliest possible date: Tue, 20 Apr 271,822 B.C. 00:00:00 UTC * Latest possible date: Sat, 13 Sep 275,760 00:00:00 UTC */ return validate(value, -271822, 275760, "year"); }; $D.validateTimezone = function(value) { var timezones = {"ACDT":1,"ACST":1,"ACT":1,"ADT":1,"AEDT":1,"AEST":1,"AFT":1,"AKDT":1,"AKST":1,"AMST":1,"AMT":1,"ART":1,"AST":1,"AWDT":1,"AWST":1,"AZOST":1,"AZT":1,"BDT":1,"BIOT":1,"BIT":1,"BOT":1,"BRT":1,"BST":1,"BTT":1,"CAT":1,"CCT":1,"CDT":1,"CEDT":1,"CEST":1,"CET":1,"CHADT":1,"CHAST":1,"CHOT":1,"ChST":1,"CHUT":1,"CIST":1,"CIT":1,"CKT":1,"CLST":1,"CLT":1,"COST":1,"COT":1,"CST":1,"CT":1,"CVT":1,"CWST":1,"CXT":1,"DAVT":1,"DDUT":1,"DFT":1,"EASST":1,"EAST":1,"EAT":1,"ECT":1,"EDT":1,"EEDT":1,"EEST":1,"EET":1,"EGST":1,"EGT":1,"EIT":1,"EST":1,"FET":1,"FJT":1,"FKST":1,"FKT":1,"FNT":1,"GALT":1,"GAMT":1,"GET":1,"GFT":1,"GILT":1,"GIT":1,"GMT":1,"GST":1,"GYT":1,"HADT":1,"HAEC":1,"HAST":1,"HKT":1,"HMT":1,"HOVT":1,"HST":1,"ICT":1,"IDT":1,"IOT":1,"IRDT":1,"IRKT":1,"IRST":1,"IST":1,"JST":1,"KGT":1,"KOST":1,"KRAT":1,"KST":1,"LHST":1,"LINT":1,"MAGT":1,"MART":1,"MAWT":1,"MDT":1,"MET":1,"MEST":1,"MHT":1,"MIST":1,"MIT":1,"MMT":1,"MSK":1,"MST":1,"MUT":1,"MVT":1,"MYT":1,"NCT":1,"NDT":1,"NFT":1,"NPT":1,"NST":1,"NT":1,"NUT":1,"NZDT":1,"NZST":1,"OMST":1,"ORAT":1,"PDT":1,"PET":1,"PETT":1,"PGT":1,"PHOT":1,"PHT":1,"PKT":1,"PMDT":1,"PMST":1,"PONT":1,"PST":1,"PYST":1,"PYT":1,"RET":1,"ROTT":1,"SAKT":1,"SAMT":1,"SAST":1,"SBT":1,"SCT":1,"SGT":1,"SLST":1,"SRT":1,"SST":1,"SYOT":1,"TAHT":1,"THA":1,"TFT":1,"TJT":1,"TKT":1,"TLT":1,"TMT":1,"TOT":1,"TVT":1,"UCT":1,"ULAT":1,"UTC":1,"UYST":1,"UYT":1,"UZT":1,"VET":1,"VLAT":1,"VOLT":1,"VOST":1,"VUT":1,"WAKT":1,"WAST":1,"WAT":1,"WEDT":1,"WEST":1,"WET":1,"WST":1,"YAKT":1,"YEKT":1,"Z":1}; return (timezones[value] === 1); }; $D.validateTimezoneOffset= function(value) { // timezones go from +14hrs to -12hrs, the +X hours are negative offsets. return (value > -841 && value < 721); }; }()); (function () { var $D = Date, $P = $D.prototype, p = function (s, l) { if (!l) { l = 2; } return ("000" + s).slice(l * -1); }; var validateConfigObject = function (obj) { var result = {}, self = this, prop, testFunc; testFunc = function (prop, func, value) { if (prop === "day") { var month = (obj.month !== undefined) ? obj.month : self.getMonth(); var year = (obj.year !== undefined) ? obj.year : self.getFullYear(); return $D[func](value, year, month); } else { return $D[func](value); } }; for (prop in obj) { if (Object.prototype.hasOwnProperty.call(obj, prop)) { var func = "validate" + prop.charAt(0).toUpperCase() + prop.slice(1); if ($D[func] && obj[prop] !== null && testFunc(prop, func, obj[prop])) { result[prop] = obj[prop]; } } } return result; }; /** * Resets the time of this Date object to 12:00 AM (00:00), which is the start of the day. * @param {Boolean} .clone() this date instance before clearing Time * @return {Date} this */ $P.clearTime = function () { this.setHours(0); this.setMinutes(0); this.setSeconds(0); this.setMilliseconds(0); return this; }; /** * Resets the time of this Date object to the current time ('now'). * @return {Date} this */ $P.setTimeToNow = function () { var n = new Date(); this.setHours(n.getHours()); this.setMinutes(n.getMinutes()); this.setSeconds(n.getSeconds()); this.setMilliseconds(n.getMilliseconds()); return this; }; /** * Returns a new Date object that is an exact date and time copy of the original instance. * @return {Date} A new Date instance */ $P.clone = function () { return new Date(this.getTime()); }; /** * Compares this instance to a Date object and returns an number indication of their relative values. * @param {Date} Date object to compare [Required] * @return {Number} -1 = this is lessthan date. 0 = values are equal. 1 = this is greaterthan date. */ $P.compareTo = function (date) { return Date.compare(this, date); }; /** * Compares this instance to another Date object and returns true if they are equal. * @param {Date} Date object to compare. If no date to compare, new Date() [now] is used. * @return {Boolean} true if dates are equal. false if they are not equal. */ $P.equals = function (date) { return Date.equals(this, (date !== undefined ? date : new Date())); }; /** * Determines if this instance is between a range of two dates or equal to either the start or end dates. * @param {Date} Start of range [Required] * @param {Date} End of range [Required] * @return {Boolean} true is this is between or equal to the start and end dates, else false */ $P.between = function (start, end) { return this.getTime() >= start.getTime() && this.getTime() <= end.getTime(); }; /** * Determines if this date occurs after the date to compare to. * @param {Date} Date object to compare. If no date to compare, new Date() ("now") is used. * @return {Boolean} true if this date instance is greater than the date to compare to (or "now"), otherwise false. */ $P.isAfter = function (date) { return this.compareTo(date || new Date()) === 1; }; /** * Determines if this date occurs before the date to compare to. * @param {Date} Date object to compare. If no date to compare, new Date() ("now") is used. * @return {Boolean} true if this date instance is less than the date to compare to (or "now"). */ $P.isBefore = function (date) { return (this.compareTo(date || new Date()) === -1); }; /** * Determines if the current Date instance occurs today. * @return {Boolean} true if this date instance is 'today', otherwise false. */ /** * Determines if the current Date instance occurs on the same Date as the supplied 'date'. * If no 'date' to compare to is provided, the current Date instance is compared to 'today'. * @param {date} Date object to compare. If no date to compare, the current Date ("now") is used. * @return {Boolean} true if this Date instance occurs on the same Day as the supplied 'date'. */ $P.isToday = $P.isSameDay = function (date) { return this.clone().clearTime().equals((date || new Date()).clone().clearTime()); }; /** * Adds the specified number of milliseconds to this instance. * @param {Number} The number of milliseconds to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addMilliseconds = function (value) { if (!value) { return this; } this.setTime(this.getTime() + value * 1); return this; }; /** * Adds the specified number of seconds to this instance. * @param {Number} The number of seconds to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addSeconds = function (value) { if (!value) { return this; } return this.addMilliseconds(value * 1000); }; /** * Adds the specified number of seconds to this instance. * @param {Number} The number of seconds to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addMinutes = function (value) { if (!value) { return this; } return this.addMilliseconds(value * 60000); // 60*1000 }; /** * Adds the specified number of hours to this instance. * @param {Number} The number of hours to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addHours = function (value) { if (!value) { return this; } return this.addMilliseconds(value * 3600000); // 60*60*1000 }; /** * Adds the specified number of days to this instance. * @param {Number} The number of days to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addDays = function (value) { if (!value) { return this; } this.setDate(this.getDate() + value * 1); return this; }; /** * Adds the specified number of weekdays (ie - not sat or sun) to this instance. * @param {Number} The number of days to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addWeekdays = function (value) { if (!value) { return this; } var day = this.getDay(); var weeks = (Math.ceil(Math.abs(value)/7)); if (day === 0 || day === 6) { if (value > 0) { this.next().monday(); this.addDays(-1); day = this.getDay(); } } if (value < 0) { while (value < 0) { this.addDays(-1); day = this.getDay(); if (day !== 0 && day !== 6) { value++; } } return this; } else if (value > 5 || (6-day) <= value) { value = value + (weeks * 2); } return this.addDays(value); }; /** * Adds the specified number of weeks to this instance. * @param {Number} The number of weeks to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addWeeks = function (value) { if (!value) { return this; } return this.addDays(value * 7); }; /** * Adds the specified number of months to this instance. * @param {Number} The number of months to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addMonths = function (value) { if (!value) { return this; } var n = this.getDate(); this.setDate(1); this.setMonth(this.getMonth() + value * 1); this.setDate(Math.min(n, $D.getDaysInMonth(this.getFullYear(), this.getMonth()))); return this; }; $P.addQuarters = function (value) { if (!value) { return this; } // note this will take you to the same point in the quarter as you are now. // i.e. - if you are 15 days into the quarter you'll be 15 days into the resulting one. // bonus: this allows adding fractional quarters return this.addMonths(value * 3); }; /** * Adds the specified number of years to this instance. * @param {Number} The number of years to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addYears = function (value) { if (!value) { return this; } return this.addMonths(value * 12); }; /** * Adds (or subtracts) to the value of the years, months, weeks, days, hours, minutes, seconds, milliseconds of the date instance using given configuration object. Positive and Negative values allowed. * Example

	Date.today().add( { days: 1, months: 1 } )

	new Date().add( { years: -1 } )
	
* @param {Object} Configuration object containing attributes (months, days, etc.) * @return {Date} this */ $P.add = function (config) { if (typeof config === "number") { this._orient = config; return this; } var x = config; if (x.day) { // If we should be a different date than today (eg: for 'tomorrow -1d', etc). // Should only effect parsing, not direct usage (eg, Finish and FinishExact) if ((x.day - this.getDate()) !== 0) { this.setDate(x.day); } } if (x.milliseconds) { this.addMilliseconds(x.milliseconds); } if (x.seconds) { this.addSeconds(x.seconds); } if (x.minutes) { this.addMinutes(x.minutes); } if (x.hours) { this.addHours(x.hours); } if (x.weeks) { this.addWeeks(x.weeks); } if (x.months) { this.addMonths(x.months); } if (x.years) { this.addYears(x.years); } if (x.days) { this.addDays(x.days); } return this; }; /** * Get the week number. Week one (1) is the week which contains the first Thursday of the year. Monday is considered the first day of the week. * The .getWeek() function does NOT convert the date to UTC. The local datetime is used. * Please use .getISOWeek() to get the week of the UTC converted date. * @return {Number} 1 to 53 */ $P.getWeek = function (utc) { // Create a copy of this date object var self, target = new Date(this.valueOf()); if (utc) { target.addMinutes(target.getTimezoneOffset()); self = target.clone(); } else { self = this; } // ISO week date weeks start on monday // so correct the day number var dayNr = (self.getDay() + 6) % 7; // ISO 8601 states that week 1 is the week // with the first thursday of that year. // Set the target date to the thursday in the target week target.setDate(target.getDate() - dayNr + 3); // Store the millisecond value of the target date var firstThursday = target.valueOf(); // Set the target to the first thursday of the year // First set the target to january first target.setMonth(0, 1); // Not a thursday? Correct the date to the next thursday if (target.getDay() !== 4) { target.setMonth(0, 1 + ((4 - target.getDay()) + 7) % 7); } // The weeknumber is the number of weeks between the // first thursday of the year and the thursday in the target week return 1 + Math.ceil((firstThursday - target) / 604800000); // 604800000 = 7 * 24 * 3600 * 1000 }; /** * Get the ISO 8601 week number. Week one ("01") is the week which contains the first Thursday of the year. Monday is considered the first day of the week. * The .getISOWeek() function does convert the date to it's UTC value. Please use .getWeek() to get the week of the local date. * @return {String} "01" to "53" */ $P.getISOWeek = function () { return p(this.getWeek(true)); }; /** * Moves the date to Monday of the week set. Week one (1) is the week which contains the first Thursday of the year. * @param {Number} A Number (1 to 53) that represents the week of the year. * @return {Date} this */ $P.setWeek = function (n) { if ((n - this.getWeek()) === 0) { if (this.getDay() !== 1) { return this.moveToDayOfWeek(1, (this.getDay() > 1 ? -1 : 1)); } else { return this; } } else { return this.moveToDayOfWeek(1, (this.getDay() > 1 ? -1 : 1)).addWeeks(n - this.getWeek()); } }; $P.setQuarter = function (qtr) { var month = Math.abs(((qtr-1) * 3) + 1); return this.setMonth(month, 1); }; $P.getQuarter = function () { return Date.getQuarter(this); }; $P.getDaysLeftInQuarter = function () { return Date.getDaysLeftInQuarter(this); }; /** * Moves the date to the next n'th occurrence of the dayOfWeek starting from the beginning of the month. The number (-1) is a magic number and will return the last occurrence of the dayOfWeek in the month. * @param {Number} The dayOfWeek to move to * @param {Number} The n'th occurrence to move to. Use (-1) to return the last occurrence in the month * @return {Date} this */ $P.moveToNthOccurrence = function (dayOfWeek, occurrence) { if (dayOfWeek === "Weekday") { if (occurrence > 0) { this.moveToFirstDayOfMonth(); if (this.is().weekday()) { occurrence -= 1; } } else if (occurrence < 0) { this.moveToLastDayOfMonth(); if (this.is().weekday()) { occurrence += 1; } } else { return this; } return this.addWeekdays(occurrence); } var shift = 0; if (occurrence > 0) { shift = occurrence - 1; } else if (occurrence === -1) { this.moveToLastDayOfMonth(); if (this.getDay() !== dayOfWeek) { this.moveToDayOfWeek(dayOfWeek, -1); } return this; } return this.moveToFirstDayOfMonth().addDays(-1).moveToDayOfWeek(dayOfWeek, +1).addWeeks(shift); }; var moveToN = function (getFunc, addFunc, nVal) { return function (value, orient) { var diff = (value - this[getFunc]() + nVal * (orient || +1)) % nVal; return this[addFunc]((diff === 0) ? diff += nVal * (orient || +1) : diff); }; }; /** * Move to the next or last dayOfWeek based on the orient value. * @param {Number} The dayOfWeek to move to * @param {Number} Forward (+1) or Back (-1). Defaults to +1. [Optional] * @return {Date} this */ $P.moveToDayOfWeek = moveToN("getDay", "addDays", 7); /** * Move to the next or last month based on the orient value. * @param {Number} The month to move to. 0 = January, 11 = December * @param {Number} Forward (+1) or Back (-1). Defaults to +1. [Optional] * @return {Date} this */ $P.moveToMonth = moveToN("getMonth", "addMonths", 12); /** * Get the Ordinate of the current day ("th", "st", "rd"). * @return {String} */ $P.getOrdinate = function () { var num = this.getDate(); return ord(num); }; /** * Get the Ordinal day (numeric day number) of the year, adjusted for leap year. * @return {Number} 1 through 365 (366 in leap years) */ $P.getOrdinalNumber = function () { return Math.ceil((this.clone().clearTime() - new Date(this.getFullYear(), 0, 1)) / 86400000) + 1; }; /** * Get the time zone abbreviation of the current date. * @return {String} The abbreviated time zone name (e.g. "EST") */ $P.getTimezone = function () { return $D.getTimezoneAbbreviation(this.getUTCOffset(), this.isDaylightSavingTime()); }; $P.setTimezoneOffset = function (offset) { var here = this.getTimezoneOffset(), there = Number(offset) * -6 / 10; return (there || there === 0) ? this.addMinutes(there - here) : this; }; $P.setTimezone = function (offset) { return this.setTimezoneOffset($D.getTimezoneOffset(offset)); }; /** * Indicates whether Daylight Saving Time is observed in the current time zone. * @return {Boolean} true|false */ $P.hasDaylightSavingTime = function () { return (Date.today().set({month: 0, day: 1}).getTimezoneOffset() !== Date.today().set({month: 6, day: 1}).getTimezoneOffset()); }; /** * Indicates whether this Date instance is within the Daylight Saving Time range for the current time zone. * @return {Boolean} true|false */ $P.isDaylightSavingTime = function () { return Date.today().set({month: 0, day: 1}).getTimezoneOffset() !== this.getTimezoneOffset(); }; /** * Get the offset from UTC of the current date. * @return {String} The 4-character offset string prefixed with + or - (e.g. "-0500") */ $P.getUTCOffset = function (offset) { var n = (offset || this.getTimezoneOffset()) * -10 / 6, r; if (n < 0) { r = (n - 10000).toString(); return r.charAt(0) + r.substr(2); } else { r = (n + 10000).toString(); return "+" + r.substr(1); } }; /** * Returns the number of milliseconds between this date and date. * @param {Date} Defaults to now * @return {Number} The diff in milliseconds */ $P.getElapsed = function (date) { return (date || new Date()) - this; }; /** * Set the value of year, month, day, hour, minute, second, millisecond of date instance using given configuration object. * Example

	Date.today().set( { day: 20, month: 1 } )

	new Date().set( { millisecond: 0 } )
	
* * @param {Object} Configuration object containing attributes (month, day, etc.) * @return {Date} this */ $P.set = function (config) { config = validateConfigObject.call(this, config); var key; for (key in config) { if (Object.prototype.hasOwnProperty.call(config, key)) { var name = key.charAt(0).toUpperCase() + key.slice(1); var addFunc, getFunc; if (key !== "week" && key !== "month" && key !== "timezone" && key !== "timezoneOffset") { name += "s"; } addFunc = "add" + name; getFunc = "get" + name; if (key === "month") { addFunc = addFunc + "s"; } else if (key === "year"){ getFunc = "getFullYear"; } if (key !== "day" && key !== "timezone" && key !== "timezoneOffset" && key !== "week" && key !== "hour") { this[addFunc](config[key] - this[getFunc]()); } else if ( key === "timezone"|| key === "timezoneOffset" || key === "week" || key === "hour") { this["set"+name](config[key]); } } } // day has to go last because you can't validate the day without first knowing the month if (config.day) { this.addDays(config.day - this.getDate()); } return this; }; /** * Moves the date to the first day of the month. * @return {Date} this */ $P.moveToFirstDayOfMonth = function () { return this.set({ day: 1 }); }; /** * Moves the date to the last day of the month. * @return {Date} this */ $P.moveToLastDayOfMonth = function () { return this.set({ day: $D.getDaysInMonth(this.getFullYear(), this.getMonth())}); }; /** * Converts the value of the current Date object to its equivalent string representation. * Format Specifiers * CUSTOM DATE AND TIME FORMAT STRINGS * Format Description Example * ------ --------------------------------------------------------------------------- ----------------------- * s The seconds of the minute between 0-59. "0" to "59" * ss The seconds of the minute with leading zero if required. "00" to "59" * * m The minute of the hour between 0-59. "0" or "59" * mm The minute of the hour with leading zero if required. "00" or "59" * * h The hour of the day between 1-12. "1" to "12" * hh The hour of the day with leading zero if required. "01" to "12" * * H The hour of the day between 0-23. "0" to "23" * HH The hour of the day with leading zero if required. "00" to "23" * * d The day of the month between 1 and 31. "1" to "31" * dd The day of the month with leading zero if required. "01" to "31" * ddd Abbreviated day name. Date.CultureInfo.abbreviatedDayNames. "Mon" to "Sun" * dddd The full day name. Date.CultureInfo.dayNames. "Monday" to "Sunday" * * M The month of the year between 1-12. "1" to "12" * MM The month of the year with leading zero if required. "01" to "12" * MMM Abbreviated month name. Date.CultureInfo.abbreviatedMonthNames. "Jan" to "Dec" * MMMM The full month name. Date.CultureInfo.monthNames. "January" to "December" * * yy The year as a two-digit number. "99" or "08" * yyyy The full four digit year. "1999" or "2008" * * t Displays the first character of the A.M./P.M. designator. "A" or "P" * Date.CultureInfo.amDesignator or Date.CultureInfo.pmDesignator * tt Displays the A.M./P.M. designator. "AM" or "PM" * Date.CultureInfo.amDesignator or Date.CultureInfo.pmDesignator * * S The ordinal suffix ("st, "nd", "rd" or "th") of the current day. "st, "nd", "rd" or "th" * * STANDARD DATE AND TIME FORMAT STRINGS * Format Description Example *------ --------------------------------------------------------------------------- ----------------------- * d The CultureInfo shortDate Format Pattern "M/d/yyyy" * D The CultureInfo longDate Format Pattern "dddd, MMMM dd, yyyy" * F The CultureInfo fullDateTime Format Pattern "dddd, MMMM dd, yyyy h:mm:ss tt" * m The CultureInfo monthDay Format Pattern "MMMM dd" * r The CultureInfo rfc1123 Format Pattern "ddd, dd MMM yyyy HH:mm:ss GMT" * s The CultureInfo sortableDateTime Format Pattern "yyyy-MM-ddTHH:mm:ss" * t The CultureInfo shortTime Format Pattern "h:mm tt" * T The CultureInfo longTime Format Pattern "h:mm:ss tt" * u The CultureInfo universalSortableDateTime Format Pattern "yyyy-MM-dd HH:mm:ssZ" * y The CultureInfo yearMonth Format Pattern "MMMM, yyyy" * * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @return {String} A string representation of the current Date object. */ var ord = function (n) { switch (n * 1) { case 1: case 21: case 31: return "st"; case 2: case 22: return "nd"; case 3: case 23: return "rd"; default: return "th"; } }; var parseStandardFormats = function (format) { var y, c = Date.CultureInfo.formatPatterns; switch (format) { case "d": return this.toString(c.shortDate); case "D": return this.toString(c.longDate); case "F": return this.toString(c.fullDateTime); case "m": return this.toString(c.monthDay); case "r": case "R": y = this.clone().addMinutes(this.getTimezoneOffset()); return y.toString(c.rfc1123) + " GMT"; case "s": return this.toString(c.sortableDateTime); case "t": return this.toString(c.shortTime); case "T": return this.toString(c.longTime); case "u": y = this.clone().addMinutes(this.getTimezoneOffset()); return y.toString(c.universalSortableDateTime); case "y": return this.toString(c.yearMonth); default: return false; } }; var parseFormatStringsClosure = function (context) { return function (m) { if (m.charAt(0) === "\\") { return m.replace("\\", ""); } switch (m) { case "hh": return p(context.getHours() < 13 ? (context.getHours() === 0 ? 12 : context.getHours()) : (context.getHours() - 12)); case "h": return context.getHours() < 13 ? (context.getHours() === 0 ? 12 : context.getHours()) : (context.getHours() - 12); case "HH": return p(context.getHours()); case "H": return context.getHours(); case "mm": return p(context.getMinutes()); case "m": return context.getMinutes(); case "ss": return p(context.getSeconds()); case "s": return context.getSeconds(); case "yyyy": return p(context.getFullYear(), 4); case "yy": return p(context.getFullYear()); case "y": return context.getFullYear(); case "E": case "dddd": return Date.CultureInfo.dayNames[context.getDay()]; case "ddd": return Date.CultureInfo.abbreviatedDayNames[context.getDay()]; case "dd": return p(context.getDate()); case "d": return context.getDate(); case "MMMM": return Date.CultureInfo.monthNames[context.getMonth()]; case "MMM": return Date.CultureInfo.abbreviatedMonthNames[context.getMonth()]; case "MM": return p((context.getMonth() + 1)); case "M": return context.getMonth() + 1; case "t": return context.getHours() < 12 ? Date.CultureInfo.amDesignator.substring(0, 1) : Date.CultureInfo.pmDesignator.substring(0, 1); case "tt": return context.getHours() < 12 ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator; case "S": return ord(context.getDate()); case "W": return context.getWeek(); case "WW": return context.getISOWeek(); case "Q": return "Q" + context.getQuarter(); case "q": return String(context.getQuarter()); case "z": return context.getTimezone(); case "Z": case "X": return Date.getTimezoneOffset(context.getTimezone()); case "ZZ": // Timezone offset in seconds return context.getTimezoneOffset() * -60; case "u": return context.getDay(); case "L": return ($D.isLeapYear(context.getFullYear())) ? 1 : 0; case "B": // Swatch Internet Time (.beats) return "@"+((context.getUTCSeconds() + (context.getUTCMinutes()*60) + ((context.getUTCHours()+1)*3600))/86.4); default: return m; } }; }; $P.toString = function (format, ignoreStandards) { // Standard Date and Time Format Strings. Formats pulled from CultureInfo file and // may vary by culture. if (!ignoreStandards && format && format.length === 1) { output = parseStandardFormats.call(this, format); if (output) { return output; } } var parseFormatStrings = parseFormatStringsClosure(this); return format ? format.replace(/((\\)?(dd?d?d?|MM?M?M?|yy?y?y?|hh?|HH?|mm?|ss?|tt?|S|q|Q|WW?W?W?)(?![^\[]*\]))/g, parseFormatStrings).replace(/\[|\]/g, "") : this._toString(); }; }()); /************************************************************* * SugarPak - Domain Specific Language - Syntactical Sugar * *************************************************************/ (function () { var $D = Date, $P = $D.prototype, $N = Number.prototype; // private $P._orient = +1; // private $P._nth = null; // private $P._is = false; // private $P._same = false; // private $P._isSecond = false; // private $N._dateElement = "days"; /** * Moves the date to the next instance of a date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.today().next().friday();
	Date.today().next().fri();
	Date.today().next().march();
	Date.today().next().mar();
	Date.today().next().week();
	
* * @return {Date} date */ $P.next = function () { this._move = true; this._orient = +1; return this; }; /** * Creates a new Date (Date.today()) and moves the date to the next instance of the date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.next().friday();
	Date.next().fri();
	Date.next().march();
	Date.next().mar();
	Date.next().week();
	
* * @return {Date} date */ $D.next = function () { return $D.today().next(); }; /** * Moves the date to the previous instance of a date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.today().last().friday();
	Date.today().last().fri();
	Date.today().last().march();
	Date.today().last().mar();
	Date.today().last().week();
	
* * @return {Date} date */ $P.last = $P.prev = $P.previous = function () { this._move = true; this._orient = -1; return this; }; /** * Creates a new Date (Date.today()) and moves the date to the previous instance of the date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.last().friday();
	Date.last().fri();
	Date.previous().march();
	Date.prev().mar();
	Date.last().week();
	
* * @return {Date} date */ $D.last = $D.prev = $D.previous = function () { return $D.today().last(); }; /** * Performs a equality check when followed by either a month name, day name or .weekday() function. * Example

	Date.today().is().friday(); // true|false
	Date.today().is().fri();
	Date.today().is().march();
	Date.today().is().mar();
	
* * @return {Boolean} true|false */ $P.is = function () { this._is = true; return this; }; /** * Determines if two date objects occur on/in exactly the same instance of the subsequent date part function. * The function .same() must be followed by a date part function (example: .day(), .month(), .year(), etc). * * An optional Date can be passed in the date part function. If now date is passed as a parameter, 'Now' is used. * * The following example demonstrates how to determine if two dates fall on the exact same day. * * Example

	var d1 = Date.today(); // today at 00:00
	var d2 = new Date();   // exactly now.

	// Do they occur on the same day?
	d1.same().day(d2); // true
	
	// Do they occur on the same hour?
	d1.same().hour(d2); // false, unless d2 hour is '00' (midnight).
	
	// What if it's the same day, but one year apart?
	var nextYear = Date.today().add(1).year();

	d1.same().day(nextYear); // false, because the dates must occur on the exact same day. 
	
* * Scenario: Determine if a given date occurs during some week period 2 months from now. * * Example

	var future = Date.today().add(2).months();
	return someDate.same().week(future); // true|false;
	
* * @return {Boolean} true|false */ $P.same = function () { this._same = true; this._isSecond = false; return this; }; /** * Determines if the current date/time occurs during Today. Must be preceded by the .is() function. * Example

	someDate.is().today();    // true|false
	new Date().is().today();  // true
	Date.today().is().today();// true
	Date.today().add(-1).day().is().today(); // false
	
* * @return {Boolean} true|false */ $P.today = function () { return this.same().day(); }; /** * Determines if the current date is a weekday. This function must be preceded by the .is() function. * Example

	Date.today().is().weekday(); // true|false
	
* * @return {Boolean} true|false */ $P.weekday = function () { if (this._nth) { return df("Weekday").call(this); } if (this._move) { return this.addWeekdays(this._orient); } if (this._is) { this._is = false; return (!this.is().sat() && !this.is().sun()); } return false; }; /** * Determines if the current date is on the weekend. This function must be preceded by the .is() function. * Example

	Date.today().is().weekend(); // true|false
	
* * @return {Boolean} true|false */ $P.weekend = function () { if (this._is) { this._is = false; return (this.is().sat() || this.is().sun()); } return false; }; /** * Sets the Time of the current Date instance. A string "6:15 pm" or config object {hour:18, minute:15} are accepted. * Example

	// Set time to 6:15pm with a String
	Date.today().at("6:15pm");

	// Set time to 6:15pm with a config object
	Date.today().at({hour:18, minute:15});
	
* * @return {Date} date */ $P.at = function (time) { return (typeof time === "string") ? $D.parse(this.toString("d") + " " + time) : this.set(time); }; /** * Creates a new Date() and adds this (Number) to the date based on the preceding date element function (eg. second|minute|hour|day|month|year). * Example

	// Undeclared Numbers must be wrapped with parentheses. Requirment of JavaScript.
	(3).days().fromNow();
	(6).months().fromNow();

	// Declared Number variables do not require parentheses. 
	var n = 6;
	n.months().fromNow();
	
* * @return {Date} A new Date instance */ $N.fromNow = $N.after = function (date) { var c = {}; c[this._dateElement] = this; return ((!date) ? new Date() : date.clone()).add(c); }; /** * Creates a new Date() and subtract this (Number) from the date based on the preceding date element function (eg. second|minute|hour|day|month|year). * Example

	// Undeclared Numbers must be wrapped with parentheses. Requirment of JavaScript.
	(3).days().ago();
	(6).months().ago();

	// Declared Number variables do not require parentheses. 
	var n = 6;
	n.months().ago();
	
* * @return {Date} A new Date instance */ $N.ago = $N.before = function (date) { var c = {}, s = (this._dateElement[this._dateElement.length-1] !== "s") ? this._dateElement + "s" : this._dateElement; c[s] = this * -1; return ((!date) ? new Date() : date.clone()).add(c); }; // Do NOT modify the following string tokens. These tokens are used to build dynamic functions. // All culture-specific strings can be found in the CultureInfo files. var dx = ("sunday monday tuesday wednesday thursday friday saturday").split(/\s/), mx = ("january february march april may june july august september october november december").split(/\s/), px = ("Millisecond Second Minute Hour Day Week Month Year Quarter Weekday").split(/\s/), pxf = ("Milliseconds Seconds Minutes Hours Date Week Month FullYear Quarter").split(/\s/), nth = ("final first second third fourth fifth").split(/\s/), de; /** * Returns an object literal of all the date parts. * Example

	var o = new Date().toObject();
	
	// { year: 2008, month: 4, week: 20, day: 13, hour: 18, minute: 9, second: 32, millisecond: 812 }
	
	// The object properties can be referenced directly from the object.
	
	alert(o.day);  // alerts "13"
	alert(o.year); // alerts "2008"
	
* * @return {Date} An object literal representing the original date object. */ $P.toObject = function () { var o = {}; for (var i = 0; i < px.length; i++) { if (this["get" + pxf[i]]) { o[px[i].toLowerCase()] = this["get" + pxf[i]](); } } return o; }; /** * Returns a date created from an object literal. Ignores the .week property if set in the config. * Example

	var o = new Date().toObject();
	
	return Date.fromObject(o); // will return the same date. 

	var o2 = {month: 1, day: 20, hour: 18}; // birthday party!
	Date.fromObject(o2);
	
* * @return {Date} An object literal representing the original date object. */ $D.fromObject = function(config) { config.week = null; return Date.today().set(config); }; // Create day name functions and abbreviated day name functions (eg. monday(), friday(), fri()). var df = function (n) { return function () { if (this._is) { this._is = false; return this.getDay() === n; } if (this._move) { this._move = null; } if (this._nth !== null) { // If the .second() function was called earlier, remove the _orient // from the date, and then continue. // This is required because 'second' can be used in two different context. // // Example // // Date.today().add(1).second(); // Date.march().second().monday(); // // Things get crazy with the following... // Date.march().add(1).second().second().monday(); // but it works!! // if (this._isSecond) { this.addSeconds(this._orient * -1); } // make sure we reset _isSecond this._isSecond = false; var ntemp = this._nth; this._nth = null; var temp = this.clone().moveToLastDayOfMonth(); this.moveToNthOccurrence(n, ntemp); if (this > temp) { throw new RangeError($D.getDayName(n) + " does not occur " + ntemp + " times in the month of " + $D.getMonthName(temp.getMonth()) + " " + temp.getFullYear() + "."); } return this; } return this.moveToDayOfWeek(n, this._orient); }; }; var sdf = function (n) { return function () { var t = $D.today(), shift = n - t.getDay(); if (n === 0 && Date.CultureInfo.firstDayOfWeek === 1 && t.getDay() !== 0) { shift = shift + 7; } return t.addDays(shift); }; }; // Create month name functions and abbreviated month name functions (eg. january(), march(), mar()). var month_instance_functions = function (n) { return function () { if (this._is) { this._is = false; return this.getMonth() === n; } return this.moveToMonth(n, this._orient); }; }; var month_static_functions = function (n) { return function () { return $D.today().set({ month: n, day: 1 }); }; }; var processTerms = function (names, staticFunc, instanceFunc) { for (var i = 0; i < names.length; i++) { // Create constant static Name variables. $D[names[i].toUpperCase()] = $D[names[i].toUpperCase().substring(0, 3)] = i; // Create Name functions. $D[names[i]] = $D[names[i].substring(0, 3)] = staticFunc(i); // Create Name instance functions. $P[names[i]] = $P[names[i].substring(0, 3)] = instanceFunc(i); } }; processTerms(dx, sdf, df); processTerms(mx, month_static_functions, month_instance_functions); // Create date element functions and plural date element functions used with Date (eg. day(), days(), months()). var ef = function (j) { return function () { // if the .second() function was called earlier, the _orient // has alread been added. Just return this and reset _isSecond. if (this._isSecond) { this._isSecond = false; return this; } if (this._same) { this._same = this._is = false; var o1 = this.toObject(), o2 = (arguments[0] || new Date()).toObject(), v = "", k = j.toLowerCase(); // the substr trick with -1 doesn't work in IE8 or less k = (k[k.length-1] === "s") ? k.substring(0,k.length-1) : k; for (var m = (px.length - 1); m > -1; m--) { v = px[m].toLowerCase(); if (o1[v] !== o2[v]) { return false; } if (k === v) { break; } } return true; } if (j.substring(j.length - 1) !== "s") { j += "s"; } if (this._move) { this._move = null; } return this["add" + j](this._orient); }; }; var nf = function (n) { return function () { this._dateElement = n; return this; }; }; for (var k = 0; k < px.length; k++) { de = px[k].toLowerCase(); if(de !== "weekday") { // Create date element functions and plural date element functions used with Date (eg. day(), days(), months()). $P[de] = $P[de + "s"] = ef(px[k]); // Create date element functions and plural date element functions used with Number (eg. day(), days(), months()). $N[de] = $N[de + "s"] = nf(de + "s"); } } $P._ss = ef("Second"); var nthfn = function (n) { return function (dayOfWeek) { if (this._same) { return this._ss(arguments[0]); } if (dayOfWeek || dayOfWeek === 0) { return this.moveToNthOccurrence(dayOfWeek, n); } this._nth = n; // if the operator is 'second' add the _orient, then deal with it later... if (n === 2 && (dayOfWeek === undefined || dayOfWeek === null)) { this._isSecond = true; return this.addSeconds(this._orient); } return this; }; }; for (var l = 0; l < nth.length; l++) { $P[nth[l]] = (l === 0) ? nthfn(-1) : nthfn(l); } }()); (function () { "use strict"; Date.Parsing = { Exception: function (s) { this.message = "Parse error at '" + s.substring(0, 10) + " ...'"; } }; var $P = Date.Parsing; var dayOffsets = { standard: [0,31,59,90,120,151,181,212,243,273,304,334], leap: [0,31,60,91,121,152,182,213,244,274,305,335] }; $P.isLeapYear = function(year) { return ((year % 4 === 0) && (year % 100 !== 0)) || (year % 400 === 0); }; var utils = { multiReplace : function (str, hash ) { var key; for (key in hash) { if (Object.prototype.hasOwnProperty.call(hash, key)) { var regex; if (typeof hash[key] === "function") { } else { regex = (hash[key] instanceof RegExp) ? hash[key] : new RegExp(hash[key], "g"); } str = str.replace(regex, key); } } return str; }, getDayOfYearFromWeek : function (obj) { var d, jan4, offset; obj.weekDay = (!obj.weekDay && obj.weekDay !== 0) ? 1 : obj.weekDay; d = new Date(obj.year, 0, 4); jan4 = d.getDay() === 0 ? 7 : d.getDay(); // JS is 0 indexed on Sunday. offset = jan4+3; obj.dayOfYear = ((obj.week * 7) + (obj.weekDay === 0 ? 7 : obj.weekDay))-offset; return obj; }, getDayOfYear : function (obj, dayOffset) { if (!obj.dayOfYear) { obj = utils.getDayOfYearFromWeek(obj); } for (var i=0;i <= dayOffset.length;i++) { if (obj.dayOfYear < dayOffset[i] || i === dayOffset.length) { obj.day = obj.day ? obj.day : (obj.dayOfYear - dayOffset[i-1]); break; } else { obj.month = i; } } return obj; }, adjustForTimeZone : function (obj, date) { var offset; if (obj.zone.toUpperCase() === "Z" || (obj.zone_hours === 0 && obj.zone_minutes === 0)) { // it's UTC/GML so work out the current timeszone offset offset = -date.getTimezoneOffset(); } else { offset = (obj.zone_hours*60) + (obj.zone_minutes || 0); if (obj.zone_sign === "+") { offset *= -1; } offset -= date.getTimezoneOffset(); } date.setMinutes(date.getMinutes()+offset); return date; }, setDefaults : function (obj) { obj.year = obj.year || Date.today().getFullYear(); obj.hours = obj.hours || 0; obj.minutes = obj.minutes || 0; obj.seconds = obj.seconds || 0; obj.milliseconds = obj.milliseconds || 0; if (!(!obj.month && (obj.week || obj.dayOfYear))) { // if we have a month, or if we don't but don't have the day calculation data obj.month = obj.month || 0; obj.day = obj.day || 1; } return obj; }, dataNum: function (data, mod, explict, postProcess) { var dataNum = data*1; if (mod) { if (postProcess) { return data ? mod(data)*1 : data; } else { return data ? mod(dataNum) : data; } } else if (!explict){ return data ? dataNum : data; } else { return (data && typeof data !== "undefined") ? dataNum : data; } }, timeDataProcess: function (obj) { var timeObj = {}; for (var x in obj.data) { if (obj.data.hasOwnProperty(x)) { timeObj[x] = obj.ignore[x] ? obj.data[x] : utils.dataNum(obj.data[x], obj.mods[x], obj.explict[x], obj.postProcess[x]); } } if (obj.data.secmins) { obj.data.secmins = obj.data.secmins.replace(",", ".") * 60; if (!timeObj.minutes) { timeObj.minutes = obj.data.secmins; } else if (!timeObj.seconds) { timeObj.seconds = obj.data.secmins; } delete obj.secmins; } return timeObj; }, buildTimeObjectFromData: function (data) { var time = utils.timeDataProcess({ data: { year : data[1], month : data[5], day : data[7], week : data[8], dayOfYear : data[10], hours : data[15], zone_hours : data[23], zone_minutes : data[24], zone : data[21], zone_sign : data[22], weekDay : data[9], minutes: data[16], seconds: data[19], milliseconds: data[20], secmins: data[18] }, mods: { month: function(data) { return data-1; }, weekDay: function (data) { data = Math.abs(data); return (data === 7 ? 0 : data); }, minutes: function (data) { return data.replace(":",""); }, seconds: function (data) { return Math.floor( (data.replace(":","").replace(",","."))*1 ); }, milliseconds: function (data) { return (data.replace(",",".")*1000); } }, postProcess: { minutes: true, seconds: true, milliseconds: true }, explict: { zone_hours: true, zone_minutes: true }, ignore: { zone: true, zone_sign: true, secmins: true } }); return time; }, addToHash: function (hash, keys, data) { keys = keys; data = data; var len = keys.length; for (var i = 0; i < len; i++) { hash[keys[i]] = data[i]; } return hash; }, combineRegex: function (r1, r2) { return new RegExp("(("+r1.source+")\\s("+r2.source+"))"); }, getDateNthString: function(add, last, inc){ if (add) { return Date.today().addDays(inc).toString("d"); } else if (last) { return Date.today().last()[inc]().toString("d"); } }, buildRegexData: function (array) { var arr = []; var len = array.length; for (var i=0; i < len; i++) { if (Object.prototype.toString.call(array[i]) === '[object Array]') { // oldIE compat version of Array.isArray arr.push(this.combineRegex(array[i][0], array[i][1])); } else { arr.push(array[i]); } } return arr; } }; $P.processTimeObject = function (obj) { var date, dayOffset; utils.setDefaults(obj); dayOffset = ($P.isLeapYear(obj.year)) ? dayOffsets.leap : dayOffsets.standard; if (!obj.month && (obj.week || obj.dayOfYear)) { utils.getDayOfYear(obj, dayOffset); } else { obj.dayOfYear = dayOffset[obj.month] + obj.day; } date = new Date(obj.year, obj.month, obj.day, obj.hours, obj.minutes, obj.seconds, obj.milliseconds); if (obj.zone) { utils.adjustForTimeZone(obj, date); // adjust (and calculate) for timezone } return date; }; $P.ISO = { regex : /^([\+-]?\d{4}(?!\d{2}\b))((-?)((0[1-9]|1[0-2])(\3([12]\d|0[1-9]|3[01]))?|W([0-4]\d|5[0-3])(-?[1-7])?|(00[1-9]|0[1-9]\d|[12]\d{2}|3([0-5]\d|6[1-6])))([T\s]((([01]\d|2[0-4])((:?)[0-5]\d)?|24\:?00)([\.,]\d+(?!:))?)?(\17[0-5]\d([\.,]\d+)?)?\s?([zZ]|([\+-])([01]\d|2[0-3]):?([0-5]\d)?)?)?)?$/, parse : function (s) { var time, data = s.match(this.regex); if (!data || !data.length) { return null; } time = utils.buildTimeObjectFromData(data); if (!time.year || (!time.year && (!time.month && !time.day) && (!time.week && !time.dayOfYear)) ) { return null; } return $P.processTimeObject(time); } }; $P.Numeric = { isNumeric: function (e){return!isNaN(parseFloat(e))&&isFinite(e);}, regex: /\b([0-1]?[0-9])([0-3]?[0-9])([0-2]?[0-9]?[0-9][0-9])\b/i, parse: function (s) { var data, i, time = {}, order = Date.CultureInfo.dateElementOrder.split(""); if (!(this.isNumeric(s)) || // if it's non-numeric OR (s[0] === "+" && s[0] === "-")) { // It's an arithmatic string (eg +/-1000) return null; } if (s.length < 5 && s.indexOf(".") < 0 && s.indexOf("/") < 0) { // assume it's just a year. time.year = s; return $P.processTimeObject(time); } data = s.match(this.regex); if (!data || !data.length) { return null; } for (i=0; i < order.length; i++) { switch(order[i]) { case "d": time.day = data[i+1]; break; case "m": time.month = (data[i+1]-1); break; case "y": time.year = data[i+1]; break; } } return $P.processTimeObject(time); } }; $P.Normalizer = { regexData: function () { var $R = Date.CultureInfo.regexPatterns; return utils.buildRegexData([ $R.tomorrow, $R.yesterday, [$R.past, $R.mon], [$R.past, $R.tue], [$R.past, $R.wed], [$R.past, $R.thu], [$R.past, $R.fri], [$R.past, $R.sat], [$R.past, $R.sun] ]); }, basicReplaceHash : function() { var $R = Date.CultureInfo.regexPatterns; return { "January": $R.jan.source, "February": $R.feb, "March": $R.mar, "April": $R.apr, "May": $R.may, "June": $R.jun, "July": $R.jul, "August": $R.aug, "September": $R.sep, "October": $R.oct, "November": $R.nov, "December": $R.dec, "": /\bat\b/gi, " ": /\s{2,}/, "am": $R.inTheMorning, "9am": $R.thisMorning, "pm": $R.inTheEvening, "7pm":$R.thisEvening }; }, keys : function(){ return [ utils.getDateNthString(true, false, 1), // tomorrow utils.getDateNthString(true, false, -1), // yesterday utils.getDateNthString(false, true, "monday"), //last mon utils.getDateNthString(false, true, "tuesday"), //last tues utils.getDateNthString(false, true, "wednesday"), //last wed utils.getDateNthString(false, true, "thursday"), //last thurs utils.getDateNthString(false, true, "friday"), //last fri utils.getDateNthString(false, true, "saturday"), //last sat utils.getDateNthString(false, true, "sunday") //last sun ]; }, buildRegexFunctions: function () { var $R = Date.CultureInfo.regexPatterns; var __ = Date.i18n.__; var tomorrowRE = new RegExp("(\\b\\d\\d?("+__("AM")+"|"+__("PM")+")? )("+$R.tomorrow.source.slice(1)+")", "i"); // adapted tomorrow regex for AM PM relative dates var todayRE = new RegExp($R.today.source + "(?!\\s*([+-]))\\b"); // today, but excludes the math operators (eg "today + 2h") this.replaceFuncs = [ [todayRE, function (full) { return (full.length > 1) ? Date.today().toString("d") : full; }], [tomorrowRE, function(full, m1) { var t = Date.today().addDays(1).toString("d"); return (t + " " + m1); }], [$R.amThisMorning, function(str, am){return am;}], [$R.pmThisEvening, function(str, pm){return pm;}] ]; }, buildReplaceData: function () { this.buildRegexFunctions(); this.replaceHash = utils.addToHash(this.basicReplaceHash(), this.keys(), this.regexData()); }, stringReplaceFuncs: function (s) { for (var i=0; i < this.replaceFuncs.length; i++) { s = s.replace(this.replaceFuncs[i][0], this.replaceFuncs[i][1]); } return s; }, parse: function (s) { s = this.stringReplaceFuncs(s); s = utils.multiReplace(s, this.replaceHash); try { var n = s.split(/([\s\-\.\,\/\x27]+)/); if (n.length === 3 && $P.Numeric.isNumeric(n[0]) && $P.Numeric.isNumeric(n[2]) && (n[2].length >= 4)) { // ok, so we're dealing with x/year. But that's not a full date. // This fixes wonky dateElementOrder parsing when set to dmy order. if (Date.CultureInfo.dateElementOrder[0] === "d") { s = "1/" + n[0] + "/" + n[2]; // set to 1st of month and normalize the seperator } } } catch (e) {} return s; } }; $P.Normalizer.buildReplaceData(); }()); (function () { var $P = Date.Parsing; var _ = $P.Operators = { // // Tokenizers // rtoken: function (r) { // regex token return function (s) { var mx = s.match(r); if (mx) { return ([ mx[0], s.substring(mx[0].length) ]); } else { throw new $P.Exception(s); } }; }, token: function () { // whitespace-eating token return function (s) { return _.rtoken(new RegExp("^\\s*" + s + "\\s*"))(s); }; }, stoken: function (s) { // string token return _.rtoken(new RegExp("^" + s)); }, // Atomic Operators until: function (p) { return function (s) { var qx = [], rx = null; while (s.length) { try { rx = p.call(this, s); } catch (e) { qx.push(rx[0]); s = rx[1]; continue; } break; } return [ qx, s ]; }; }, many: function (p) { return function (s) { var rx = [], r = null; while (s.length) { try { r = p.call(this, s); } catch (e) { return [ rx, s ]; } rx.push(r[0]); s = r[1]; } return [ rx, s ]; }; }, // generator operators -- see below optional: function (p) { return function (s) { var r = null; try { r = p.call(this, s); } catch (e) { return [ null, s ]; } return [ r[0], r[1] ]; }; }, not: function (p) { return function (s) { try { p.call(this, s); } catch (e) { return [null, s]; } throw new $P.Exception(s); }; }, ignore: function (p) { return p ? function (s) { var r = null; r = p.call(this, s); return [null, r[1]]; } : null; }, product: function () { var px = arguments[0], qx = Array.prototype.slice.call(arguments, 1), rx = []; for (var i = 0 ; i < px.length ; i++) { rx.push(_.each(px[i], qx)); } return rx; }, cache: function (rule) { var cache = {}, cache_length = 0, cache_keys = [], CACHE_MAX = Date.Config.CACHE_MAX || 100000, r = null; var cacheCheck = function () { if (cache_length === CACHE_MAX) { // kill several keys, don't want to have to do this all the time... for (var i=0; i < 10; i++) { var key = cache_keys.shift(); if (key) { delete cache[key]; cache_length--; } } } }; return function (s) { cacheCheck(); try { r = cache[s] = (cache[s] || rule.call(this, s)); } catch (e) { r = cache[s] = e; } cache_length++; cache_keys.push(s); if (r instanceof $P.Exception) { throw r; } else { return r; } }; }, // vector operators -- see below any: function () { var px = arguments; return function (s) { var r = null; for (var i = 0; i < px.length; i++) { if (px[i] == null) { continue; } try { r = (px[i].call(this, s)); } catch (e) { r = null; } if (r) { return r; } } throw new $P.Exception(s); }; }, each: function () { var px = arguments; return function (s) { var rx = [], r = null; for (var i = 0; i < px.length ; i++) { if (px[i] == null) { continue; } try { r = (px[i].call(this, s)); } catch (e) { throw new $P.Exception(s); } rx.push(r[0]); s = r[1]; } return [ rx, s]; }; }, all: function () { var px = arguments, _ = _; return _.each(_.optional(px)); }, // delimited operators sequence: function (px, d, c) { d = d || _.rtoken(/^\s*/); c = c || null; if (px.length === 1) { return px[0]; } return function (s) { var r = null, q = null; var rx = []; for (var i = 0; i < px.length ; i++) { try { r = px[i].call(this, s); } catch (e) { break; } rx.push(r[0]); try { q = d.call(this, r[1]); } catch (ex) { q = null; break; } s = q[1]; } if (!r) { throw new $P.Exception(s); } if (q) { throw new $P.Exception(q[1]); } if (c) { try { r = c.call(this, r[1]); } catch (ey) { throw new $P.Exception(r[1]); } } return [ rx, (r?r[1]:s) ]; }; }, // // Composite Operators // between: function (d1, p, d2) { d2 = d2 || d1; var _fn = _.each(_.ignore(d1), p, _.ignore(d2)); return function (s) { var rx = _fn.call(this, s); return [[rx[0][0], r[0][2]], rx[1]]; }; }, list: function (p, d, c) { d = d || _.rtoken(/^\s*/); c = c || null; return (p instanceof Array ? _.each(_.product(p.slice(0, -1), _.ignore(d)), p.slice(-1), _.ignore(c)) : _.each(_.many(_.each(p, _.ignore(d))), px, _.ignore(c))); }, set: function (px, d, c) { d = d || _.rtoken(/^\s*/); c = c || null; return function (s) { // r is the current match, best the current 'best' match // which means it parsed the most amount of input var r = null, p = null, q = null, rx = null, best = [[], s], last = false; // go through the rules in the given set for (var i = 0; i < px.length ; i++) { // last is a flag indicating whether this must be the last element // if there is only 1 element, then it MUST be the last one q = null; p = null; r = null; last = (px.length === 1); // first, we try simply to match the current pattern // if not, try the next pattern try { r = px[i].call(this, s); } catch (e) { continue; } // since we are matching against a set of elements, the first // thing to do is to add r[0] to matched elements rx = [[r[0]], r[1]]; // if we matched and there is still input to parse and // we don't already know this is the last element, // we're going to next check for the delimiter ... // if there's none, or if there's no input left to parse // than this must be the last element after all ... if (r[1].length > 0 && ! last) { try { q = d.call(this, r[1]); } catch (ex) { last = true; } } else { last = true; } // if we parsed the delimiter and now there's no more input, // that means we shouldn't have parsed the delimiter at all // so don't update r and mark this as the last element ... if (!last && q[1].length === 0) { last = true; } // so, if this isn't the last element, we're going to see if // we can get any more matches from the remaining (unmatched) // elements ... if (!last) { // build a list of the remaining rules we can match against, // i.e., all but the one we just matched against var qx = []; for (var j = 0; j < px.length ; j++) { if (i !== j) { qx.push(px[j]); } } // now invoke recursively set with the remaining input // note that we don't include the closing delimiter ... // we'll check for that ourselves at the end p = _.set(qx, d).call(this, q[1]); // if we got a non-empty set as a result ... // (otw rx already contains everything we want to match) if (p[0].length > 0) { // update current result, which is stored in rx ... // basically, pick up the remaining text from p[1] // and concat the result from p[0] so that we don't // get endless nesting ... rx[0] = rx[0].concat(p[0]); rx[1] = p[1]; } } // at this point, rx either contains the last matched element // or the entire matched set that starts with this element. // now we just check to see if this variation is better than // our best so far, in terms of how much of the input is parsed if (rx[1].length < best[1].length) { best = rx; } // if we've parsed all the input, then we're finished if (best[1].length === 0) { break; } } // so now we've either gone through all the patterns trying them // as the initial match; or we found one that parsed the entire // input string ... // if best has no matches, just return empty set ... if (best[0].length === 0) { return best; } // if a closing delimiter is provided, then we have to check it also if (c) { // we try this even if there is no remaining input because the pattern // may well be optional or match empty input ... try { q = c.call(this, best[1]); } catch (ey) { throw new $P.Exception(best[1]); } // it parsed ... be sure to update the best match remaining input best[1] = q[1]; } // if we're here, either there was no closing delimiter or we parsed it // so now we have the best match; just return it! return best; }; }, forward: function (gr, fname) { return function (s) { return gr[fname].call(this, s); }; }, // // Translation Operators // replace: function (rule, repl) { return function (s) { var r = rule.call(this, s); return [repl, r[1]]; }; }, process: function (rule, fn) { return function (s) { var r = rule.call(this, s); return [fn.call(this, r[0]), r[1]]; }; }, min: function (min, rule) { return function (s) { var rx = rule.call(this, s); if (rx[0].length < min) { throw new $P.Exception(s); } return rx; }; } }; // Generator Operators And Vector Operators // Generators are operators that have a signature of F(R) => R, // taking a given rule and returning another rule, such as // ignore, which parses a given rule and throws away the result. // Vector operators are those that have a signature of F(R1,R2,...) => R, // take a list of rules and returning a new rule, such as each. // Generator operators are converted (via the following _generator // function) into functions that can also take a list or array of rules // and return an array of new rules as though the function had been // called on each rule in turn (which is what actually happens). // This allows generators to be used with vector operators more easily. // Example: // each(ignore(foo, bar)) instead of each(ignore(foo), ignore(bar)) // This also turns generators into vector operators, which allows // constructs like: // not(cache(foo, bar)) var _generator = function (op) { function gen() { var args = null, rx = [], px, i; if (arguments.length > 1) { args = Array.prototype.slice.call(arguments); } else if (arguments[0] instanceof Array) { args = arguments[0]; } if (args) { px = args.shift(); if (px.length > 0) { args.unshift(px[i]); rx.push(op.apply(null, args)); args.shift(); return rx; } } else { return op.apply(null, arguments); } } return gen; }; var gx = "optional not ignore cache".split(/\s/); for (var i = 0 ; i < gx.length ; i++) { _[gx[i]] = _generator(_[gx[i]]); } var _vector = function (op) { return function () { if (arguments[0] instanceof Array) { return op.apply(null, arguments[0]); } else { return op.apply(null, arguments); } }; }; var vx = "each any all".split(/\s/); for (var j = 0 ; j < vx.length ; j++) { _[vx[j]] = _vector(_[vx[j]]); } }()); (function () { var $D = Date; var flattenAndCompact = function (ax) { var rx = []; for (var i = 0; i < ax.length; i++) { if (ax[i] instanceof Array) { rx = rx.concat(flattenAndCompact(ax[i])); } else { if (ax[i]) { rx.push(ax[i]); } } } return rx; }; var parseMeridian = function () { if (this.meridian && (this.hour || this.hour === 0)) { if (this.meridian === "a" && this.hour > 11 && Date.Config.strict24hr){ throw "Invalid hour and meridian combination"; } else if (this.meridian === "p" && this.hour < 12 && Date.Config.strict24hr){ throw "Invalid hour and meridian combination"; } else if (this.meridian === "p" && this.hour < 12) { this.hour = this.hour + 12; } else if (this.meridian === "a" && this.hour === 12) { this.hour = 0; } } }; var setDefaults = function () { var now = new Date(); if ((this.hour || this.minute) && (!this.month && !this.year && !this.day)) { this.day = now.getDate(); } if (!this.year) { this.year = now.getFullYear(); } if (!this.month && this.month !== 0) { this.month = now.getMonth(); } if (!this.day) { this.day = 1; } if (!this.hour) { this.hour = 0; } if (!this.minute) { this.minute = 0; } if (!this.second) { this.second = 0; } if (!this.millisecond) { this.millisecond = 0; } }; var finishUtils = { getToday: function () { if (this.now || "hour minute second".indexOf(this.unit) !== -1) { return new Date(); } else { return $D.today(); } }, setDaysFromWeekday: function (today, orient){ var gap; orient = orient || 1; this.unit = "day"; gap = ($D.getDayNumberFromName(this.weekday) - today.getDay()); this.days = gap ? ((gap + (orient * 7)) % 7) : (orient * 7); return this; }, setMonthsFromMonth: function (today, orient) { var gap; orient = orient || 1; this.unit = "month"; gap = (this.month - today.getMonth()); this.months = gap ? ((gap + (orient * 12)) % 12) : (orient * 12); this.month = null; return this; }, setDMYFromWeekday: function () { var d = Date[this.weekday](); this.day = d.getDate(); if (!this.month) { this.month = d.getMonth(); } this.year = d.getFullYear(); return this; }, setUnitValue: function (orient) { if (!this.value && this.operator && this.operator !== null && this[this.unit + "s"] && this[this.unit + "s"] !== null) { this[this.unit + "s"] = this[this.unit + "s"] + ((this.operator === "add") ? 1 : -1) + (this.value||0) * orient; } else if (this[this.unit + "s"] == null || this.operator != null) { if (!this.value) { this.value = 1; } this[this.unit + "s"] = this.value * orient; } }, generateDateFromWeeks: function () { var weekday = (this.weekday !== undefined) ? this.weekday : "today"; var d = Date[weekday]().addWeeks(this.weeks); if (this.now) { d.setTimeToNow(); } return d; } }; $D.Translator = { hour: function (s) { return function () { this.hour = Number(s); }; }, minute: function (s) { return function () { this.minute = Number(s); }; }, second: function (s) { return function () { this.second = Number(s); }; }, /* for ss.s format */ secondAndMillisecond: function (s) { return function () { var mx = s.match(/^([0-5][0-9])\.([0-9]{1,3})/); this.second = Number(mx[1]); this.millisecond = Number(mx[2]); }; }, meridian: function (s) { return function () { this.meridian = s.slice(0, 1).toLowerCase(); }; }, timezone: function (s) { return function () { var n = s.replace(/[^\d\+\-]/g, ""); if (n.length) { this.timezoneOffset = Number(n); } else { this.timezone = s.toLowerCase(); } }; }, day: function (x) { var s = x[0]; return function () { this.day = Number(s.match(/\d+/)[0]); if (this.day < 1) { throw "invalid day"; } }; }, month: function (s) { return function () { this.month = (s.length === 3) ? "jan feb mar apr may jun jul aug sep oct nov dec".indexOf(s)/4 : Number(s) - 1; if (this.month < 0) { throw "invalid month"; } }; }, year: function (s) { return function () { var n = Number(s); this.year = ((s.length > 2) ? n : (n + (((n + 2000) < Date.CultureInfo.twoDigitYearMax) ? 2000 : 1900))); }; }, rday: function (s) { return function () { switch (s) { case "yesterday": this.days = -1; break; case "tomorrow": this.days = 1; break; case "today": this.days = 0; break; case "now": this.days = 0; this.now = true; break; } }; }, finishExact: function (x) { var d; x = (x instanceof Array) ? x : [x]; for (var i = 0 ; i < x.length ; i++) { if (x[i]) { x[i].call(this); } } setDefaults.call(this); parseMeridian.call(this); if (this.day > $D.getDaysInMonth(this.year, this.month)) { throw new RangeError(this.day + " is not a valid value for days."); } d = new Date(this.year, this.month, this.day, this.hour, this.minute, this.second, this.millisecond); if (this.year < 100) { d.setFullYear(this.year); // means years less that 100 are process correctly. JS will parse it otherwise as 1900-1999. } if (this.timezone) { d.set({ timezone: this.timezone }); } else if (this.timezoneOffset) { d.set({ timezoneOffset: this.timezoneOffset }); } return d; }, finish: function (x) { var today, expression, orient, temp; x = (x instanceof Array) ? flattenAndCompact(x) : [ x ]; if (x.length === 0) { return null; } for (var i = 0 ; i < x.length ; i++) { if (typeof x[i] === "function") { x[i].call(this); } } if (this.now && !this.unit && !this.operator) { return new Date(); } else { today = finishUtils.getToday.call(this); } expression = !!(this.days && this.days !== null || this.orient || this.operator); orient = ((this.orient === "past" || this.operator === "subtract") ? -1 : 1); if (this.month && this.unit === "week") { this.value = this.month + 1; delete this.month; delete this.day; } if ((this.month || this.month === 0) && "year day hour minute second".indexOf(this.unit) !== -1) { if (!this.value) { this.value = this.month + 1; } this.month = null; expression = true; } if (!expression && this.weekday && !this.day && !this.days) { finishUtils.setDMYFromWeekday.call(this); } if (expression && this.weekday && this.unit !== "month" && this.unit !== "week") { finishUtils.setDaysFromWeekday.call(this, today, orient); } if (this.weekday && this.unit !== "week" && !this.day && !this.days) { temp = Date[this.weekday](); this.day = temp.getDate(); if (temp.getMonth() !== today.getMonth()) { this.month = temp.getMonth(); } } if (this.month && this.unit === "day" && this.operator) { if (!this.value) { this.value = (this.month + 1); } this.month = null; } if (this.value != null && this.month != null && this.year != null) { this.day = this.value * 1; } if (this.month && !this.day && this.value) { today.set({ day: this.value * 1 }); if (!expression) { this.day = this.value * 1; } } if (!this.month && this.value && this.unit === "month" && !this.now) { this.month = this.value; expression = true; } if (expression && (this.month || this.month === 0) && this.unit !== "year") { finishUtils.setMonthsFromMonth.call(this, today, orient); } if (!this.unit) { this.unit = "day"; } finishUtils.setUnitValue.call(this, orient); parseMeridian.call(this); if ((this.month || this.month === 0) && !this.day) { this.day = 1; } if (!this.orient && !this.operator && this.unit === "week" && this.value && !this.day && !this.month) { return Date.today().setWeek(this.value); } if (this.unit === "week" && this.weeks && !this.day && !this.month) { return finishUtils.generateDateFromWeeks.call(this); } if (expression && this.timezone && this.day && this.days) { this.day = this.days; } if (expression){ today.add(this); } else { today.set(this); } if (this.timezone) { this.timezone = this.timezone.toUpperCase(); var offset = $D.getTimezoneOffset(this.timezone); var timezone; if (today.hasDaylightSavingTime()) { // lets check that we're being sane with timezone setting timezone = $D.getTimezoneAbbreviation(offset, today.isDaylightSavingTime()); if (timezone !== this.timezone) { // bugger, we're in a place where things like EST vs EDT matters. if (today.isDaylightSavingTime()) { today.addHours(-1); } else { today.addHours(1); } } } today.setTimezoneOffset(offset); } return today; } }; }()); (function () { var $D = Date; $D.Grammar = {}; var _ = $D.Parsing.Operators, g = $D.Grammar, t = $D.Translator, _fn; // Allow rolling up into general purpose rules _fn = function () { return _.each(_.any.apply(null, arguments), _.not(g.ctoken2("timeContext"))); }; g.datePartDelimiter = _.rtoken(/^([\s\-\.\,\/\x27]+)/); g.timePartDelimiter = _.stoken(":"); g.whiteSpace = _.rtoken(/^\s*/); g.generalDelimiter = _.rtoken(/^(([\s\,]|at|@|on)+)/); var _C = {}; g.ctoken = function (keys) { var fn = _C[keys]; if (! fn) { var c = Date.CultureInfo.regexPatterns; var kx = keys.split(/\s+/), px = []; for (var i = 0; i < kx.length ; i++) { px.push(_.replace(_.rtoken(c[kx[i]]), kx[i])); } fn = _C[keys] = _.any.apply(null, px); } return fn; }; g.ctoken2 = function (key) { return _.rtoken(Date.CultureInfo.regexPatterns[key]); }; var cacheProcessRtoken = function (key, token, type, eachToken) { if (eachToken) { g[key] = _.cache(_.process(_.each(_.rtoken(token),_.optional(g.ctoken2(eachToken))), type)); } else { g[key] = _.cache(_.process(_.rtoken(token), type)); } }; var cacheProcessCtoken = function (token, type) { return _.cache(_.process(g.ctoken2(token), type)); }; var _F = {}; //function cache var _get = function (f) { _F[f] = (_F[f] || g.format(f)[0]); return _F[f]; }; g.allformats = function (fx) { var rx = []; if (fx instanceof Array) { for (var i = 0; i < fx.length; i++) { rx.push(_get(fx[i])); } } else { rx.push(_get(fx)); } return rx; }; g.formats = function (fx) { if (fx instanceof Array) { var rx = []; for (var i = 0 ; i < fx.length ; i++) { rx.push(_get(fx[i])); } return _.any.apply(null, rx); } else { return _get(fx); } }; var grammarFormats = { timeFormats: function(){ var i, RTokenKeys = [ "h", "hh", "H", "HH", "m", "mm", "s", "ss", "ss.s", "z", "zz" ], RToken = [ /^(0[0-9]|1[0-2]|[1-9])/, /^(0[0-9]|1[0-2])/, /^([0-1][0-9]|2[0-3]|[0-9])/, /^([0-1][0-9]|2[0-3])/, /^([0-5][0-9]|[0-9])/, /^[0-5][0-9]/, /^([0-5][0-9]|[0-9])/, /^[0-5][0-9]/, /^[0-5][0-9]\.[0-9]{1,3}/, /^((\+|\-)\s*\d\d\d\d)|((\+|\-)\d\d\:?\d\d)/, /^((\+|\-)\s*\d\d\d\d)|((\+|\-)\d\d\:?\d\d)/ ], tokens = [ t.hour, t.hour, t.hour, t.hour, t.minute, t.minute, t.second, t.second, t.secondAndMillisecond, t.timezone, t.timezone ]; for (i=0; i < RTokenKeys.length; i++) { cacheProcessRtoken(RTokenKeys[i], RToken[i], tokens[i]); } g.hms = _.cache(_.sequence([g.H, g.m, g.s], g.timePartDelimiter)); g.t = cacheProcessCtoken("shortMeridian", t.meridian); g.tt = cacheProcessCtoken("longMeridian", t.meridian); g.zzz = cacheProcessCtoken("timezone", t.timezone); g.timeSuffix = _.each(_.ignore(g.whiteSpace), _.set([ g.tt, g.zzz ])); g.time = _.each(_.optional(_.ignore(_.stoken("T"))), g.hms, g.timeSuffix); }, dateFormats: function () { // pre-loaded rules for different date part order preferences var _setfn = function () { return _.set(arguments, g.datePartDelimiter); }; var i, RTokenKeys = [ "d", "dd", "M", "MM", "y", "yy", "yyy", "yyyy" ], RToken = [ /^([0-2]\d|3[0-1]|\d)/, /^([0-2]\d|3[0-1])/, /^(1[0-2]|0\d|\d)/, /^(1[0-2]|0\d)/, /^(\d+)/, /^(\d\d)/, /^(\d\d?\d?\d?)/, /^(\d\d\d\d)/ ], tokens = [ t.day, t.day, t.month, t.month, t.year, t.year, t.year, t.year ], eachToken = [ "ordinalSuffix", "ordinalSuffix" ]; for (i=0; i < RTokenKeys.length; i++) { cacheProcessRtoken(RTokenKeys[i], RToken[i], tokens[i], eachToken[i]); } g.MMM = g.MMMM = _.cache(_.process(g.ctoken("jan feb mar apr may jun jul aug sep oct nov dec"), t.month)); g.ddd = g.dddd = _.cache(_.process(g.ctoken("sun mon tue wed thu fri sat"), function (s) { return function () { this.weekday = s; }; } )); g.day = _fn(g.d, g.dd); g.month = _fn(g.M, g.MMM); g.year = _fn(g.yyyy, g.yy); g.mdy = _setfn(g.ddd, g.month, g.day, g.year); g.ymd = _setfn(g.ddd, g.year, g.month, g.day); g.dmy = _setfn(g.ddd, g.day, g.month, g.year); g.date = function (s) { return ((g[Date.CultureInfo.dateElementOrder] || g.mdy).call(this, s)); }; }, relative: function () { // relative date / time expressions g.orientation = _.process(g.ctoken("past future"), function (s) { return function () { this.orient = s; }; } ); g.operator = _.process(g.ctoken("add subtract"), function (s) { return function () { this.operator = s; }; } ); g.rday = _.process(g.ctoken("yesterday tomorrow today now"), t.rday); g.unit = _.process(g.ctoken("second minute hour day week month year"), function (s) { return function () { this.unit = s; }; } ); } }; g.buildGrammarFormats = function () { // these need to be rebuilt every time the language changes. _C = {}; grammarFormats.timeFormats(); grammarFormats.dateFormats(); grammarFormats.relative(); g.value = _.process(_.rtoken(/^([-+]?\d+)?(st|nd|rd|th)?/), function (s) { return function () { this.value = s.replace(/\D/g, ""); }; } ); g.expression = _.set([g.rday, g.operator, g.value, g.unit, g.orientation, g.ddd, g.MMM ]); g.format = _.process(_.many( _.any( // translate format specifiers into grammar rules _.process( _.rtoken(/^(dd?d?d?(?!e)|MM?M?M?|yy?y?y?|hh?|HH?|mm?|ss?|tt?|zz?z?)/), function (fmt) { if (g[fmt]) { return g[fmt]; } else { throw $D.Parsing.Exception(fmt); } } ), // translate separator tokens into token rules _.process(_.rtoken(/^[^dMyhHmstz]+/), // all legal separators function (s) { return _.ignore(_.stoken(s)); } ) ) ), // construct the parser ... function (rules) { return _.process(_.each.apply(null, rules), t.finishExact); } ); // starting rule for general purpose grammar g._start = _.process(_.set([ g.date, g.time, g.expression ], g.generalDelimiter, g.whiteSpace), t.finish); }; g.buildGrammarFormats(); // parsing date format specifiers - ex: "h:m:s tt" // this little guy will generate a custom parser based // on the format string, ex: g.format("h:m:s tt") // check for these formats first g._formats = g.formats([ "\"yyyy-MM-ddTHH:mm:ssZ\"", "yyyy-MM-ddTHH:mm:ss.sz", "yyyy-MM-ddTHH:mm:ssZ", "yyyy-MM-ddTHH:mm:ssz", "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-ddTHH:mmZ", "yyyy-MM-ddTHH:mmz", "yyyy-MM-ddTHH:mm", "ddd, MMM dd, yyyy H:mm:ss tt", "ddd MMM d yyyy HH:mm:ss zzz", "MMddyyyy", "ddMMyyyy", "Mddyyyy", "ddMyyyy", "Mdyyyy", "dMyyyy", "yyyy", "Mdyy", "dMyy", "d" ]); // real starting rule: tries selected formats first, // then general purpose rule g.start = function (s) { try { var r = g._formats.call({}, s); if (r[1].length === 0) { return r; } } catch (e) {} return g._start.call({}, s); }; }()); (function () { var $D = Date; /** * @desc Converts the specified string value into its JavaScript Date equivalent using CultureInfo specific format information. * * Example

	///////////
	// Dates //
	///////////

	// 15-Oct-2004
	var d1 = Date.parse("10/15/2004");

	// 15-Oct-2004
	var d1 = Date.parse("15-Oct-2004");

	// 15-Oct-2004
	var d1 = Date.parse("2004.10.15");

	//Fri Oct 15, 2004
	var d1 = Date.parse("Fri Oct 15, 2004");

	///////////
	// Times //
	///////////

	// Today at 10 PM.
	var d1 = Date.parse("10 PM");

	// Today at 10:30 PM.
	var d1 = Date.parse("10:30 P.M.");

	// Today at 6 AM.
	var d1 = Date.parse("06am");

	/////////////////////
	// Dates and Times //
	/////////////////////

	// 8-July-2004 @ 10:30 PM
	var d1 = Date.parse("July 8th, 2004, 10:30 PM");

	// 1-July-2004 @ 10:30 PM
	var d1 = Date.parse("2004-07-01T22:30:00");

	////////////////////
	// Relative Dates //
	////////////////////

	// Returns today's date. The string "today" is culture specific.
	var d1 = Date.parse("today");

	// Returns yesterday's date. The string "yesterday" is culture specific.
	var d1 = Date.parse("yesterday");

	// Returns the date of the next thursday.
	var d1 = Date.parse("Next thursday");

	// Returns the date of the most previous monday.
	var d1 = Date.parse("last monday");

	// Returns today's day + one year.
	var d1 = Date.parse("next year");

	///////////////
	// Date Math //
	///////////////

	// Today + 2 days
	var d1 = Date.parse("t+2");

	// Today + 2 days
	var d1 = Date.parse("today + 2 days");

	// Today + 3 months
	var d1 = Date.parse("t+3m");

	// Today - 1 year
	var d1 = Date.parse("today - 1 year");

	// Today - 1 year
	var d1 = Date.parse("t-1y"); 


	/////////////////////////////
	// Partial Dates and Times //
	/////////////////////////////

	// July 15th of this year.
	var d1 = Date.parse("July 15");

	// 15th day of current day and year.
	var d1 = Date.parse("15");

	// July 1st of current year at 10pm.
	var d1 = Date.parse("7/1 10pm");
	
* * @param {String} The string value to convert into a Date object [Required] * @return {Date} A Date object or null if the string cannot be converted into a Date. */ var parseUtils = { removeOrds: function (s) { ords = s.match(/\b(\d+)(?:st|nd|rd|th)\b/); // find ordinal matches s = ((ords && ords.length === 2) ? s.replace(ords[0], ords[1]) : s); return s; }, grammarParser: function (s) { var r = null; try { r = $D.Grammar.start.call({}, s.replace(/^\s*(\S*(\s+\S+)*)\s*$/, "$1")); } catch (e) { return null; } return ((r[1].length === 0) ? r[0] : null); }, nativeFallback: function(s) { var t; try { // ok we haven't parsed it, last ditch attempt with the built-in parser. t = Date._parse(s); return (t || t === 0) ? new Date(t) : null; } catch (e) { return null; } } }; function parse (s) { var d; if (!s) { return null; } if (s instanceof Date) { return s.clone(); } if (s.length >= 4 && s.charAt(0) !== "0" && s.charAt(0) !== "+"&& s.charAt(0) !== "-") { // ie: 2004 will pass, 0800 won't. // Start with specific formats d = $D.Parsing.ISO.parse(s) || $D.Parsing.Numeric.parse(s); } if (d instanceof Date && !isNaN(d.getTime())) { return d; } else { // find ordinal dates (1st, 3rd, 8th, etc and remove them as they cause parsing issues) s = $D.Parsing.Normalizer.parse(parseUtils.removeOrds(s)); d = parseUtils.grammarParser(s); if (d !== null) { return d; } else { return parseUtils.nativeFallback(s); } } } if (!$D._parse) { $D._parse = $D.parse; } $D.parse = parse; Date.getParseFunction = function (fx) { var fns = Date.Grammar.allformats(fx); return function (s) { var r = null; for (var i = 0; i < fns.length; i++) { try { r = fns[i].call({}, s); } catch (e) { continue; } if (r[1].length === 0) { return r[0]; } } return null; }; }; /** * Converts the specified string value into its JavaScript Date equivalent using the specified format {String} or formats {Array} and the CultureInfo specific format information. * The format of the string value must match one of the supplied formats exactly. * * Example

	// 15-Oct-2004
	var d1 = Date.parseExact("10/15/2004", "M/d/yyyy");

	// 15-Oct-2004
	var d1 = Date.parse("15-Oct-2004", "M-ddd-yyyy");

	// 15-Oct-2004
	var d1 = Date.parse("2004.10.15", "yyyy.MM.dd");

	// Multiple formats
	var d1 = Date.parseExact("10/15/2004", ["M/d/yyyy", "MMMM d, yyyy"]);
	
* * @param {String} The string value to convert into a Date object [Required]. * @param {Object} The expected format {String} or an array of expected formats {Array} of the date string [Required]. * @return {Date} A Date object or null if the string cannot be converted into a Date. */ $D.parseExact = function (s, fx) { return $D.getParseFunction(fx)(s); }; }()); (function () { var $D = Date, $P = $D.prototype, // $C = $D.CultureInfo, // not used atm p = function (s, l) { if (!l) { l = 2; } return ("000" + s).slice(l * -1); }; /** * Converts a PHP format string to Java/.NET format string. * A PHP format string can be used with ._format or .format. * A Java/.NET format string can be used with .toString(). * The .parseExact function will only accept a Java/.NET format string * * Example * var f1 = "%m/%d/%y" * var f2 = Date.normalizeFormat(f1); // "MM/dd/yy" * * new Date().format(f1); // "04/13/08" * new Date()._format(f1); // "04/13/08" * new Date().toString(f2); // "04/13/08" * * var date = Date.parseExact("04/13/08", f2); // Sun Apr 13 2008 * * @param {String} A PHP format string consisting of one or more format spcifiers. * @return {String} The PHP format converted to a Java/.NET format string. */ var normalizerSubstitutions = { "d" : "dd", "%d": "dd", "D" : "ddd", "%a": "ddd", "j" : "dddd", "l" : "dddd", "%A": "dddd", "S" : "S", "F" : "MMMM", "%B": "MMMM", "m" : "MM", "%m": "MM", "M" : "MMM", "%b": "MMM", "%h": "MMM", "n" : "M", "Y" : "yyyy", "%Y": "yyyy", "y" : "yy", "%y": "yy", "g" : "h", "%I": "h", "G" : "H", "h" : "hh", "H" : "HH", "%H": "HH", "i" : "mm", "%M": "mm", "s" : "ss", "%S": "ss", "%r": "hh:mm tt", "%R": "H:mm", "%T": "H:mm:ss", "%X": "t", "%x": "d", "%e": "d", "%D": "MM/dd/yy", "%n": "\\n", "%t": "\\t", "e" : "z", "T" : "z", "%z": "z", "%Z": "z", "Z" : "ZZ", "N" : "u", "w" : "u", "%w": "u", "W" : "W", "%V": "W" }; var normalizer = { substitutes: function (m) { return normalizerSubstitutions[m]; }, interpreted: function (m, x) { var y; switch (m) { case "%u": return x.getDay() + 1; case "z": return x.getOrdinalNumber(); case "%j": return p(x.getOrdinalNumber(), 3); case "%U": var d1 = x.clone().set({month: 0, day: 1}).addDays(-1).moveToDayOfWeek(0), d2 = x.clone().addDays(1).moveToDayOfWeek(0, -1); return (d2 < d1) ? "00" : p((d2.getOrdinalNumber() - d1.getOrdinalNumber()) / 7 + 1); case "%W": return p(x.getWeek()); case "t": return $D.getDaysInMonth(x.getFullYear(), x.getMonth()); case "o": case "%G": return x.setWeek(x.getISOWeek()).toString("yyyy"); case "%g": return x._format("%G").slice(-2); case "a": case "%p": return t("tt").toLowerCase(); case "A": return t("tt").toUpperCase(); case "u": return p(x.getMilliseconds(), 3); case "I": return (x.isDaylightSavingTime()) ? 1 : 0; case "O": return x.getUTCOffset(); case "P": y = x.getUTCOffset(); return y.substring(0, y.length - 2) + ":" + y.substring(y.length - 2); case "B": var now = new Date(); return Math.floor(((now.getHours() * 3600) + (now.getMinutes() * 60) + now.getSeconds() + (now.getTimezoneOffset() + 60) * 60) / 86.4); case "c": return x.toISOString().replace(/\"/g, ""); case "U": return $D.strtotime("now"); case "%c": return t("d") + " " + t("t"); case "%C": return Math.floor(x.getFullYear() / 100 + 1); } }, shouldOverrideDefaults: function (m) { switch (m) { case "%e": return true; default: return false; } }, parse: function (m, context) { var formatString, c = context || new Date(); formatString = normalizer.substitutes(m); if (formatString) { return formatString; } formatString = normalizer.interpreted(m, c); if (formatString) { return formatString; } else { return m; } } }; $D.normalizeFormat = function (format, context) { return format.replace(/(%|\\)?.|%%/g, function(t){ return normalizer.parse(t, context); }); }; /** * Format a local Unix timestamp according to locale settings * * Example: * Date.strftime("%m/%d/%y", new Date()); // "04/13/08" * Date.strftime("c", "2008-04-13T17:52:03Z"); // "04/13/08" * * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @param {Number|String} The number representing the number of seconds that have elapsed since January 1, 1970 (local time). * @return {String} A string representation of the current Date object. */ $D.strftime = function (format, time) { var d = Date.parse(time); return d._format(format); }; /** * Parse any textual datetime description into a Unix timestamp. * A Unix timestamp is the number of seconds that have elapsed since January 1, 1970 (midnight UTC/GMT). * * Example: * Date.strtotime("04/13/08"); // 1208044800 * Date.strtotime("1970-01-01T00:00:00Z"); // 0 * * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @param {Object} A string or date object. * @return {String} A string representation of the current Date object. */ $D.strtotime = function (time) { var d = $D.parse(time); return Math.round($D.UTC(d.getUTCFullYear(), d.getUTCMonth(), d.getUTCDate(), d.getUTCHours(), d.getUTCMinutes(), d.getUTCSeconds(), d.getUTCMilliseconds()) / 1000); }; /** * Converts the value of the current Date object to its equivalent string representation using a PHP/Unix style of date format specifiers. * Format Specifiers * Format Description Example * ------ --------------------------------------------------------------------------- ----------------------- * %a abbreviated weekday name according to the current localed "Mon" through "Sun" * %A full weekday name according to the current localed "Sunday" through "Saturday" * %b abbreviated month name according to the current localed "Jan" through "Dec" * %B full month name according to the current locale "January" through "December" * %c preferred date and time representation for the current locale "4/13/2008 12:33 PM" * %C century number (the year divided by 100 and truncated to an integer) "00" to "99" * %d day of the month as a decimal number "01" to "31" * %D same as %m/%d/%y "04/13/08" * %e day of the month as a decimal number, a single digit is preceded by a space "1" to "31" * %g like %G, but without the century "08" * %G The 4-digit year corresponding to the ISO week number (see %V). "2008" * This has the same format and value as %Y, except that if the ISO week number * belongs to the previous or next year, that year is used instead. * %h same as %b "Jan" through "Dec" * %H hour as a decimal number using a 24-hour clock. "00" to "23" * %I hour as a decimal number using a 12-hour clock. "01" to "12" * %j day of the year as a decimal number. "001" to "366" * %m month as a decimal number. "01" to "12" * %M minute as a decimal number. "00" to "59" * %n newline character "\n" * %p either "am" or "pm" according to the given time value, or the "am" or "pm" * corresponding strings for the current locale. * %r time in a.m. and p.m. notation "8:44 PM" * %R time in 24 hour notation "20:44" * %S second as a decimal number "00" to "59" * %t tab character "\t" * %T current time, equal to %H:%M:%S "12:49:11" * %u weekday as a decimal number ["1", "7"], with "1" representing Monday "1" to "7" * %U week number of the current year as a decimal number, starting with the "0" to ("52" or "53") * first Sunday as the first day of the first week * %V The ISO 8601:1988 week number of the current year as a decimal number, "00" to ("52" or "53") * range 01 to 53, where week 1 is the first week that has at least 4 days * in the current year, and with Monday as the first day of the week. * (Use %G or %g for the year component that corresponds to the week number * for the specified timestamp.) * %W week number of the current year as a decimal number, starting with the "00" to ("52" or "53") * first Monday as the first day of the first week * %w day of the week as a decimal, Sunday being "0" "0" to "6" * %x preferred date representation for the current locale without the time "4/13/2008" * %X preferred time representation for the current locale without the date "12:53:05" * %y year as a decimal number without a century "00" "99" * %Y year as a decimal number including the century "2008" * %Z time zone or name or abbreviation "UTC", "EST", "PST" * %z same as %Z * %% a literal "%" characters "%" * d Day of the month, 2 digits with leading zeros "01" to "31" * D A textual representation of a day, three letters "Mon" through "Sun" * j Day of the month without leading zeros "1" to "31" * l A full textual representation of the day of the week (lowercase "L") "Sunday" through "Saturday" * N ISO-8601 numeric representation of the day of the week (added in PHP 5.1.0) "1" (for Monday) through "7" (for Sunday) * S English ordinal suffix for the day of the month, 2 characters "st", "nd", "rd" or "th". Works well with j * w Numeric representation of the day of the week "0" (for Sunday) through "6" (for Saturday) * z The day of the year (starting from "0") "0" through "365" * W ISO-8601 week number of year, weeks starting on Monday "00" to ("52" or "53") * F A full textual representation of a month, such as January or March "January" through "December" * m Numeric representation of a month, with leading zeros "01" through "12" * M A short textual representation of a month, three letters "Jan" through "Dec" * n Numeric representation of a month, without leading zeros "1" through "12" * t Number of days in the given month "28" through "31" * L Whether it's a leap year "1" if it is a leap year, "0" otherwise * o ISO-8601 year number. This has the same value as Y, except that if the "2008" * ISO week number (W) belongs to the previous or next year, that year * is used instead. * Y A full numeric representation of a year, 4 digits "2008" * y A two digit representation of a year "08" * a Lowercase Ante meridiem and Post meridiem "am" or "pm" * A Uppercase Ante meridiem and Post meridiem "AM" or "PM" * B Swatch Internet time "000" through "999" * g 12-hour format of an hour without leading zeros "1" through "12" * G 24-hour format of an hour without leading zeros "0" through "23" * h 12-hour format of an hour with leading zeros "01" through "12" * H 24-hour format of an hour with leading zeros "00" through "23" * i Minutes with leading zeros "00" to "59" * s Seconds, with leading zeros "00" through "59" * u Milliseconds "54321" * e Timezone identifier "UTC", "EST", "PST" * I Whether or not the date is in daylight saving time (uppercase i) "1" if Daylight Saving Time, "0" otherwise * O Difference to Greenwich time (GMT) in hours "+0200", "-0600" * P Difference to Greenwich time (GMT) with colon between hours and minutes "+02:00", "-06:00" * T Timezone abbreviation "UTC", "EST", "PST" * Z Timezone offset in seconds. The offset for timezones west of UTC is "-43200" through "50400" * always negative, and for those east of UTC is always positive. * c ISO 8601 date "2004-02-12T15:19:21+00:00" * r RFC 2822 formatted date "Thu, 21 Dec 2000 16:01:07 +0200" * U Seconds since the Unix Epoch (January 1 1970 00:00:00 GMT) "0" * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @return {String} A string representation of the current Date object. */ var formatReplace = function (context) { return function (m) { var formatString, override = false; if (m.charAt(0) === "\\" || m.substring(0, 2) === "%%") { return m.replace("\\", "").replace("%%", "%"); } override = normalizer.shouldOverrideDefaults(m); formatString = $D.normalizeFormat(m, context); if (formatString) { return context.toString(formatString, override); } }; }; $P._format = function (format) { var formatter = formatReplace(this); if (!format) { return this._toString(); } else { return format.replace(/(%|\\)?.|%%/g, formatter); } }; if (!$P.format) { $P.format = $P._format; } }()); (function () { "use strict"; var gFn = function (attr) { return function () { return this[attr]; }; }; var sFn = function (attr) { return function (val) { this[attr] = val; return this; }; }; var attrs = ["years", "months", "days", "hours", "minutes", "seconds", "milliseconds"]; var addSetFuncs = function (context, attrs) { for (var i = 0; i < attrs.length ; i++) { var $a = attrs[i], $b = $a.slice(0, 1).toUpperCase() + $a.slice(1); context.prototype[$a] = 0; context.prototype["get" + $b] = gFn($a); context.prototype["set" + $b] = sFn($a); } }; /** * new TimeSpan(milliseconds); * new TimeSpan(days, hours, minutes, seconds); * new TimeSpan(days, hours, minutes, seconds, milliseconds); */ var TimeSpan = function (days, hours, minutes, seconds, milliseconds) { if (arguments.length === 1 && typeof days === "number") { var orient = (days < 0) ? -1 : +1; var millsLeft = Math.abs(days); this.setDays(Math.floor(millsLeft / 86400000) * orient); millsLeft = millsLeft % 86400000; this.setHours(Math.floor(millsLeft / 3600000) * orient); millsLeft = millsLeft % 3600000; this.setMinutes(Math.floor(millsLeft / 60000) * orient); millsLeft = millsLeft % 60000; this.setSeconds(Math.floor(millsLeft / 1000) * orient); millsLeft = millsLeft % 1000; this.setMilliseconds(millsLeft * orient); } else { this.set(days, hours, minutes, seconds, milliseconds); } this.getTotalMilliseconds = function () { return (this.getDays() * 86400000) + (this.getHours() * 3600000) + (this.getMinutes() * 60000) + (this.getSeconds() * 1000); }; this.compareTo = function (time) { var t1 = new Date(1970, 1, 1, this.getHours(), this.getMinutes(), this.getSeconds()), t2; if (time === null) { t2 = new Date(1970, 1, 1, 0, 0, 0); } else { t2 = new Date(1970, 1, 1, time.getHours(), time.getMinutes(), time.getSeconds()); } return (t1 < t2) ? -1 : (t1 > t2) ? 1 : 0; }; this.equals = function (time) { return (this.compareTo(time) === 0); }; this.add = function (time) { return (time === null) ? this : this.addSeconds(time.getTotalMilliseconds() / 1000); }; this.subtract = function (time) { return (time === null) ? this : this.addSeconds(-time.getTotalMilliseconds() / 1000); }; this.addDays = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 86400000)); }; this.addHours = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 3600000)); }; this.addMinutes = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 60000)); }; this.addSeconds = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 1000)); }; this.addMilliseconds = function (n) { return new TimeSpan(this.getTotalMilliseconds() + n); }; this.get12HourHour = function () { return (this.getHours() > 12) ? this.getHours() - 12 : (this.getHours() === 0) ? 12 : this.getHours(); }; this.getDesignator = function () { return (this.getHours() < 12) ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator; }; this.toString = function (format) { this._toString = function () { if (this.getDays() !== null && this.getDays() > 0) { return this.getDays() + "." + this.getHours() + ":" + this.p(this.getMinutes()) + ":" + this.p(this.getSeconds()); } else { return this.getHours() + ":" + this.p(this.getMinutes()) + ":" + this.p(this.getSeconds()); } }; this.p = function (s) { return (s.toString().length < 2) ? "0" + s : s; }; var me = this; return format ? format.replace(/dd?|HH?|hh?|mm?|ss?|tt?/g, function (format) { switch (format) { case "d": return me.getDays(); case "dd": return me.p(me.getDays()); case "H": return me.getHours(); case "HH": return me.p(me.getHours()); case "h": return me.get12HourHour(); case "hh": return me.p(me.get12HourHour()); case "m": return me.getMinutes(); case "mm": return me.p(me.getMinutes()); case "s": return me.getSeconds(); case "ss": return me.p(me.getSeconds()); case "t": return ((me.getHours() < 12) ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator).substring(0, 1); case "tt": return (me.getHours() < 12) ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator; } } ) : this._toString(); }; return this; }; addSetFuncs(TimeSpan, attrs.slice(2)); TimeSpan.prototype.set = function (days, hours, minutes, seconds, milliseconds){ this.setDays(days || this.getDays()); this.setHours(hours || this.getHours()); this.setMinutes(minutes || this.getMinutes()); this.setSeconds(seconds || this.getSeconds()); this.setMilliseconds(milliseconds || this.getMilliseconds()); }; /** * Gets the time of day for this date instances. * @return {TimeSpan} TimeSpan */ Date.prototype.getTimeOfDay = function () { return new TimeSpan(0, this.getHours(), this.getMinutes(), this.getSeconds(), this.getMilliseconds()); }; Date.TimeSpan = TimeSpan; if (typeof window !== "undefined" ) { // keeping API compatible for v1.x window.TimeSpan = TimeSpan; } }()); (function () { "use strict"; var attrs = ["years", "months", "days", "hours", "minutes", "seconds", "milliseconds"]; var gFn = function (attr) { return function () { return this[attr]; }; }; var sFn = function (attr) { return function (val) { this[attr] = val; return this; }; }; var addSetFuncs = function (context, attrs) { for (var i = 0; i < attrs.length ; i++) { var $a = attrs[i], $b = $a.slice(0, 1).toUpperCase() + $a.slice(1); context.prototype[$a] = 0; context.prototype["get" + $b] = gFn($a); context.prototype["set" + $b] = sFn($a); } }; var setMonthsAndYears = function (orient, d1, d2, context) { function inc() { d1.addMonths(-orient); context.months++; if (context.months === 12) { context.years++; context.months = 0; } } if (orient === +1) { while (d1 > d2) { inc(); } } else { while (d1 < d2) { inc(); } } context.months--; context.months *= orient; context.years *= orient; }; var adjustForDST = function(orient, startDate, endDate) { var hasDSTMismatch = (false === (startDate.isDaylightSavingTime() === endDate.isDaylightSavingTime())); if (hasDSTMismatch && orient === 1) { startDate.addHours(-1); } else if (hasDSTMismatch) { startDate.addHours(1); } }; /** * TimePeriod(startDate, endDate); * TimePeriod(years, months, days, hours, minutes, seconds, milliseconds); */ var TimePeriod = function (years, months, days, hours, minutes, seconds, milliseconds) { if (arguments.length === 7) { this.set(years, months, days, hours, minutes, seconds, milliseconds); } else if (arguments.length === 2 && arguments[0] instanceof Date && arguments[1] instanceof Date) { var startDate = arguments[0].clone(); var endDate = arguments[1].clone(); var orient = (startDate > endDate) ? +1 : -1; this.dates = { start: arguments[0].clone(), end: arguments[1].clone() }; setMonthsAndYears(orient, startDate, endDate, this); adjustForDST(orient, startDate, endDate); // // TODO - adjust for DST var diff = endDate - startDate; if (diff !== 0) { var ts = new TimeSpan(diff); this.set(this.years, this.months, ts.getDays(), ts.getHours(), ts.getMinutes(), ts.getSeconds(), ts.getMilliseconds()); } } return this; }; // create all the set functions. addSetFuncs(TimePeriod, attrs); TimePeriod.prototype.set = function (years, months, days, hours, minutes, seconds, milliseconds){ this.setYears(years || this.getYears()); this.setMonths(months || this.getMonths()); this.setDays(days || this.getDays()); this.setHours(hours || this.getHours()); this.setMinutes(minutes || this.getMinutes()); this.setSeconds(seconds || this.getSeconds()); this.setMilliseconds(milliseconds || this.getMilliseconds()); }; Date.TimePeriod = TimePeriod; if (typeof window !== "undefined") { // keeping API compatible for v1.x window.TimePeriod = TimePeriod; } }()); ================================================ FILE: build/date-mi-NZ.js ================================================ /** * @overview datejs * @version 1.0.0-rc3 * @author Gregory Wild-Smith * @copyright 2015 Gregory Wild-Smith * @license MIT * @homepage https://github.com/abritinthebay/datejs */ /* * DateJS Culture String File * Country Code: mi-NZ * Name: Maori (New Zealand) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["mi-NZ"] = { "name": "mi-NZ", "englishName": "Maori (New Zealand)", "nativeName": "Reo Māori (Aotearoa)", "Sunday": "Rātapu", "Monday": "Mane", "Tuesday": "Tūrei", "Wednesday": "Wenerei", "Thursday": "Tāite", "Friday": "Paraire", "Saturday": "Hātarei", "Sun": "Ta", "Mon": "Ma", "Tue": "Tū", "Wed": "We", "Thu": "Tāi", "Fri": "Pa", "Sat": "Hā", "Su": "Ta", "Mo": "Ma", "Tu": "Tū", "We": "We", "Th": "Tāi", "Fr": "Pa", "Sa": "Hā", "S_Sun_Initial": "T", "M_Mon_Initial": "M", "T_Tue_Initial": "T", "W_Wed_Initial": "W", "T_Thu_Initial": "T", "F_Fri_Initial": "P", "S_Sat_Initial": "H", "January": "Kohi-tātea", "February": "Hui-tanguru", "March": "Poutū-te-rangi", "April": "Paenga-whāwhā", "May": "Haratua", "June": "Pipiri", "July": "Hōngoingoi", "August": "Here-turi-kōkā", "September": "Mahuru", "October": "Whiringa-ā-nuku", "November": "Whiringa-ā-rangi", "December": "Hakihea", "Jan_Abbr": "Kohi", "Feb_Abbr": "Hui", "Mar_Abbr": "Pou", "Apr_Abbr": "Pae", "May_Abbr": "Hara", "Jun_Abbr": "Pipi", "Jul_Abbr": "Hōngoi", "Aug_Abbr": "Here", "Sep_Abbr": "Mahu", "Oct_Abbr": "Whi-nu", "Nov_Abbr": "Whi-ra", "Dec_Abbr": "Haki", "AM": "a.m.", "PM": "p.m.", "firstDayOfWeek": 1, "twoDigitYearMax": 2029, "mdy": "dmy", "M/d/yyyy": "d/MM/yyyy", "dddd, MMMM dd, yyyy": "dddd, d MMMM yyyy", "h:mm tt": "h:mm:ss tt", "h:mm:ss tt": "h:mm:ss tt", "dddd, MMMM dd, yyyy h:mm:ss tt": "dddd, d MMMM yyyy h:mm:ss tt", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "MMMM dd", "MMMM, yyyy": "MMMM yyyy", "/jan(uary)?/": "kohi(-tātea)?", "/feb(ruary)?/": "hui(-tanguru)?", "/mar(ch)?/": "pou(tū-te-rangi)?", "/apr(il)?/": "pae(nga-whāwhā)?", "/may/": "hara(tua)?", "/jun(e)?/": "pipi(ri)?", "/jul(y)?/": "hōngoi(ngoi)?", "/aug(ust)?/": "here(-turi-kōkā)?", "/sep(t(ember)?)?/": "mahu(ru)?", "/oct(ober)?/": "whiringa-ā-nuku", "/nov(ember)?/": "whiringa-ā-rangi", "/dec(ember)?/": "haki(hea)?", "/^su(n(day)?)?/": "^rātapu", "/^mo(n(day)?)?/": "^mane", "/^tu(e(s(day)?)?)?/": "^tūrei", "/^we(d(nesday)?)?/": "^wenerei", "/^th(u(r(s(day)?)?)?)?/": "^tāite", "/^fr(i(day)?)?/": "^paraire", "/^sa(t(urday)?)?/": "^hātarei", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "mi-NZ"; /** * @overview datejs * @version 1.0.0-rc3 * @author Gregory Wild-Smith * @copyright 2015 Gregory Wild-Smith * @license MIT * @homepage https://github.com/abritinthebay/datejs */(function () { var $D = Date; var lang = Date.CultureStrings ? Date.CultureStrings.lang : null; var loggedKeys = {}; // for debug purposes. var getText = { getFromKey: function (key, countryCode) { var output; if (Date.CultureStrings && Date.CultureStrings[countryCode] && Date.CultureStrings[countryCode][key]) { output = Date.CultureStrings[countryCode][key]; } else { output = getText.buildFromDefault(key); } if (key.charAt(0) === "/") { // Assume it's a regex output = getText.buildFromRegex(key, countryCode); } return output; }, getFromObjectValues: function (obj, countryCode) { var key, output = {}; for(key in obj) { if (obj.hasOwnProperty(key)) { output[key] = getText.getFromKey(obj[key], countryCode); } } return output; }, getFromObjectKeys: function (obj, countryCode) { var key, output = {}; for(key in obj) { if (obj.hasOwnProperty(key)) { output[getText.getFromKey(key, countryCode)] = obj[key]; } } return output; }, getFromArray: function (arr, countryCode) { var output = []; for (var i=0; i < arr.length; i++){ if (i in arr) { output[i] = getText.getFromKey(arr[i], countryCode); } } return output; }, buildFromDefault: function (key) { var output, length, split, last; switch(key) { case "name": output = "en-US"; break; case "englishName": output = "English (United States)"; break; case "nativeName": output = "English (United States)"; break; case "twoDigitYearMax": output = 2049; break; case "firstDayOfWeek": output = 0; break; default: output = key; split = key.split("_"); length = split.length; if (length > 1 && key.charAt(0) !== "/") { // if the key isn't a regex and it has a split. last = split[(length - 1)].toLowerCase(); if (last === "initial" || last === "abbr") { output = split[0]; } } break; } return output; }, buildFromRegex: function (key, countryCode) { var output; if (Date.CultureStrings && Date.CultureStrings[countryCode] && Date.CultureStrings[countryCode][key]) { output = new RegExp(Date.CultureStrings[countryCode][key], "i"); } else { output = new RegExp(key.replace(new RegExp("/", "g"),""), "i"); } return output; } }; var shallowMerge = function (obj1, obj2) { for (var attrname in obj2) { if (obj2.hasOwnProperty(attrname)) { obj1[attrname] = obj2[attrname]; } } }; var __ = function (key, language) { var countryCode = (language) ? language : lang; loggedKeys[key] = key; if (typeof key === "object") { if (key instanceof Array) { return getText.getFromArray(key, countryCode); } else { return getText.getFromObjectKeys(key, countryCode); } } else { return getText.getFromKey(key, countryCode); } }; var loadI18nScript = function (code) { // paatterned after jQuery's getScript. var url = Date.Config.i18n + code + ".js"; var head = document.getElementsByTagName("head")[0] || document.documentElement; var script = document.createElement("script"); script.src = url; var completed = false; var events = { done: function (){} // placeholder function }; // Attach handlers for all browsers script.onload = script.onreadystatechange = function() { if ( !completed && (!this.readyState || this.readyState === "loaded" || this.readyState === "complete") ) { events.done(); head.removeChild(script); } }; setTimeout(function() { head.insertBefore(script, head.firstChild); }, 0); // allows return to execute first return { done: function (cb) { events.done = function() { if (cb) { setTimeout(cb,0); } }; } }; }; var buildInfo = { buildFromMethodHash: function (obj) { var key; for(key in obj) { if (obj.hasOwnProperty(key)) { obj[key] = buildInfo[obj[key]](); } } return obj; }, timeZoneDST: function () { var DST = { "CHADT": "+1345", "NZDT": "+1300", "AEDT": "+1100", "ACDT": "+1030", "AZST": "+0500", "IRDT": "+0430", "EEST": "+0300", "CEST": "+0200", "BST": "+0100", "PMDT": "-0200", "ADT": "-0300", "NDT": "-0230", "EDT": "-0400", "CDT": "-0500", "MDT": "-0600", "PDT": "-0700", "AKDT": "-0800", "HADT": "-0900" }; return __(DST); }, timeZoneStandard: function () { var standard = { "LINT": "+1400", "TOT": "+1300", "CHAST": "+1245", "NZST": "+1200", "NFT": "+1130", "SBT": "+1100", "AEST": "+1000", "ACST": "+0930", "JST": "+0900", "CWST": "+0845", "CT": "+0800", "ICT": "+0700", "MMT": "+0630", "BST": "+0600", "NPT": "+0545", "IST": "+0530", "PKT": "+0500", "AFT": "+0430", "MSK": "+0400", "IRST": "+0330", "FET": "+0300", "EET": "+0200", "CET": "+0100", "GMT": "+0000", "UTC": "+0000", "CVT": "-0100", "GST": "-0200", "BRT": "-0300", "NST": "-0330", "AST": "-0400", "EST": "-0500", "CST": "-0600", "MST": "-0700", "PST": "-0800", "AKST": "-0900", "MIT": "-0930", "HST": "-1000", "SST": "-1100", "BIT": "-1200" }; return __(standard); }, timeZones: function (data) { var zone; data.timezones = []; for (zone in data.abbreviatedTimeZoneStandard) { if (data.abbreviatedTimeZoneStandard.hasOwnProperty(zone)) { data.timezones.push({ name: zone, offset: data.abbreviatedTimeZoneStandard[zone]}); } } for (zone in data.abbreviatedTimeZoneDST) { if (data.abbreviatedTimeZoneDST.hasOwnProperty(zone)) { data.timezones.push({ name: zone, offset: data.abbreviatedTimeZoneDST[zone], dst: true}); } } return data.timezones; }, days: function () { return __(["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"]); }, dayAbbr: function () { return __(["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"]); }, dayShortNames: function () { return __(["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"]); }, dayFirstLetters: function () { return __(["S_Sun_Initial", "M_Mon_Initial", "T_Tues_Initial", "W_Wed_Initial", "T_Thu_Initial", "F_Fri_Initial", "S_Sat_Initial"]); }, months: function () { return __(["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"]); }, monthAbbr: function () { return __(["Jan_Abbr", "Feb_Abbr", "Mar_Abbr", "Apr_Abbr", "May_Abbr", "Jun_Abbr", "Jul_Abbr", "Aug_Abbr", "Sep_Abbr", "Oct_Abbr", "Nov_Abbr", "Dec_Abbr"]); }, formatPatterns: function () { return getText.getFromObjectValues({ shortDate: "M/d/yyyy", longDate: "dddd, MMMM dd, yyyy", shortTime: "h:mm tt", longTime: "h:mm:ss tt", fullDateTime: "dddd, MMMM dd, yyyy h:mm:ss tt", sortableDateTime: "yyyy-MM-ddTHH:mm:ss", universalSortableDateTime: "yyyy-MM-dd HH:mm:ssZ", rfc1123: "ddd, dd MMM yyyy HH:mm:ss", monthDay: "MMMM dd", yearMonth: "MMMM, yyyy" }, Date.i18n.currentLanguage()); }, regex: function () { return getText.getFromObjectValues({ inTheMorning: "/( in the )(morn(ing)?)\\b/", thisMorning: "/(this )(morn(ing)?)\\b/", amThisMorning: "/(\b\\d(am)? )(this )(morn(ing)?)/", inTheEvening: "/( in the )(even(ing)?)\\b/", thisEvening: "/(this )(even(ing)?)\\b/", pmThisEvening: "/(\b\\d(pm)? )(this )(even(ing)?)/", jan: "/jan(uary)?/", feb: "/feb(ruary)?/", mar: "/mar(ch)?/", apr: "/apr(il)?/", may: "/may/", jun: "/jun(e)?/", jul: "/jul(y)?/", aug: "/aug(ust)?/", sep: "/sep(t(ember)?)?/", oct: "/oct(ober)?/", nov: "/nov(ember)?/", dec: "/dec(ember)?/", sun: "/^su(n(day)?)?/", mon: "/^mo(n(day)?)?/", tue: "/^tu(e(s(day)?)?)?/", wed: "/^we(d(nesday)?)?/", thu: "/^th(u(r(s(day)?)?)?)?/", fri: "/fr(i(day)?)?/", sat: "/^sa(t(urday)?)?/", future: "/^next/", past: "/^last|past|prev(ious)?/", add: "/^(\\+|aft(er)?|from|hence)/", subtract: "/^(\\-|bef(ore)?|ago)/", yesterday: "/^yes(terday)?/", today: "/^t(od(ay)?)?/", tomorrow: "/^tom(orrow)?/", now: "/^n(ow)?/", millisecond: "/^ms|milli(second)?s?/", second: "/^sec(ond)?s?/", minute: "/^mn|min(ute)?s?/", hour: "/^h(our)?s?/", week: "/^w(eek)?s?/", month: "/^m(onth)?s?/", day: "/^d(ay)?s?/", year: "/^y(ear)?s?/", shortMeridian: "/^(a|p)/", longMeridian: "/^(a\\.?m?\\.?|p\\.?m?\\.?)/", timezone: "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/", ordinalSuffix: "/^\\s*(st|nd|rd|th)/", timeContext: "/^\\s*(\\:|a(?!u|p)|p)/" }, Date.i18n.currentLanguage()); } }; var CultureInfo = function () { var info = getText.getFromObjectValues({ name: "name", englishName: "englishName", nativeName: "nativeName", amDesignator: "AM", pmDesignator: "PM", firstDayOfWeek: "firstDayOfWeek", twoDigitYearMax: "twoDigitYearMax", dateElementOrder: "mdy" }, Date.i18n.currentLanguage()); var constructedInfo = buildInfo.buildFromMethodHash({ dayNames: "days", abbreviatedDayNames: "dayAbbr", shortestDayNames: "dayShortNames", firstLetterDayNames: "dayFirstLetters", monthNames: "months", abbreviatedMonthNames: "monthAbbr", formatPatterns: "formatPatterns", regexPatterns: "regex", abbreviatedTimeZoneDST: "timeZoneDST", abbreviatedTimeZoneStandard: "timeZoneStandard" }); shallowMerge(info, constructedInfo); buildInfo.timeZones(info); return info; }; $D.i18n = { __: function (key, lang) { return __(key, lang); }, currentLanguage: function () { return lang || "en-US"; }, setLanguage: function (code, force, cb) { var async = false; if (force || code === "en-US" || (!!Date.CultureStrings && !!Date.CultureStrings[code])) { lang = code; Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings.lang = code; Date.CultureInfo = new CultureInfo(); } else { if (!(!!Date.CultureStrings && !!Date.CultureStrings[code])) { if (typeof exports !== "undefined" && this.exports !== exports) { // we're in a Node enviroment, load it using require try { require("../i18n/" + code + ".js"); lang = code; Date.CultureStrings.lang = code; Date.CultureInfo = new CultureInfo(); } catch (e) { // var str = "The language for '" + code + "' could not be loaded by Node. It likely does not exist."; throw new Error("The DateJS IETF language tag '" + code + "' could not be loaded by Node. It likely does not exist."); } } else if (Date.Config && Date.Config.i18n) { // we know the location of the files, so lets load them async = true; loadI18nScript(code).done(function(){ lang = code; Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings.lang = code; Date.CultureInfo = new CultureInfo(); $D.Parsing.Normalizer.buildReplaceData(); // because this is async if ($D.Grammar) { $D.Grammar.buildGrammarFormats(); // so we can parse those strings... } if (cb) { setTimeout(cb,0); } }); } else { Date.console.error("The DateJS IETF language tag '" + code + "' is not available and has not been loaded."); return false; } } } $D.Parsing.Normalizer.buildReplaceData(); // rebuild normalizer strings if ($D.Grammar) { $D.Grammar.buildGrammarFormats(); // so we can parse those strings... } if (!async && cb) { setTimeout(cb,0); } }, getLoggedKeys: function () { return loggedKeys; }, updateCultureInfo: function () { Date.CultureInfo = new CultureInfo(); } }; $D.i18n.updateCultureInfo(); // run automatically }()); (function () { var $D = Date, $P = $D.prototype, p = function (s, l) { if (!l) { l = 2; } return ("000" + s).slice(l * -1); }; if (typeof window !== "undefined" && typeof window.console !== "undefined" && typeof window.console.log !== "undefined") { $D.console = console; // used only to raise non-critical errors if available } else { // set mock so we don't give errors. $D.console = { log: function(){}, error: function(){} }; } $D.Config = $D.Config || {}; $D.initOverloads = function() { /** * Overload of Date.now. Allows an alternate call for Date.now where it returns the * current Date as an object rather than just milliseconds since the Unix Epoch. * * Also provides an implementation of now() for browsers (IE<9) that don't have it. * * Backwards compatible so with work with either: * Date.now() [returns ms] * or * Date.now(true) [returns Date] */ if (!$D.now) { $D._now = function now() { return new Date().getTime(); }; } else if (!$D._now) { $D._now = $D.now; } $D.now = function (returnObj) { if (returnObj) { return $D.present(); } else { return $D._now(); } }; if ( !$P.toISOString ) { $P.toISOString = function() { return this.getUTCFullYear() + "-" + p(this.getUTCMonth() + 1) + "-" + p(this.getUTCDate()) + "T" + p(this.getUTCHours()) + ":" + p(this.getUTCMinutes()) + ":" + p(this.getUTCSeconds()) + "." + String( (this.getUTCMilliseconds()/1000).toFixed(3)).slice(2, 5) + "Z"; }; } // private if ( $P._toString === undefined ){ $P._toString = $P.toString; } }; $D.initOverloads(); /** * Gets a date that is set to the current date. The time is set to the start of the day (00:00 or 12:00 AM). * @return {Date} The current date. */ $D.today = function () { return new Date().clearTime(); }; /** * Gets a date that is set to the current date and time (same as new Date, but chainable) * @return {Date} The current date. */ $D.present = function () { return new Date(); }; /** * Compares the first date to the second date and returns an number indication of their relative values. * @param {Date} First Date object to compare [Required]. * @param {Date} Second Date object to compare to [Required]. * @return {Number} -1 = date1 is lessthan date2. 0 = values are equal. 1 = date1 is greaterthan date2. */ $D.compare = function (date1, date2) { if (isNaN(date1) || isNaN(date2)) { throw new Error(date1 + " - " + date2); } else if (date1 instanceof Date && date2 instanceof Date) { return (date1 < date2) ? -1 : (date1 > date2) ? 1 : 0; } else { throw new TypeError(date1 + " - " + date2); } }; /** * Compares the first Date object to the second Date object and returns true if they are equal. * @param {Date} First Date object to compare [Required] * @param {Date} Second Date object to compare to [Required] * @return {Boolean} true if dates are equal. false if they are not equal. */ $D.equals = function (date1, date2) { return (date1.compareTo(date2) === 0); }; /** * Gets the language appropriate day name when given the day number(0-6) * eg - 0 == Sunday * @return {String} The day name */ $D.getDayName = function (n) { return Date.CultureInfo.dayNames[n]; }; /** * Gets the day number (0-6) if given a CultureInfo specific string which is a valid dayName, abbreviatedDayName or shortestDayName (two char). * @param {String} The name of the day (eg. "Monday, "Mon", "tuesday", "tue", "We", "we"). * @return {Number} The day number */ $D.getDayNumberFromName = function (name) { var n = Date.CultureInfo.dayNames, m = Date.CultureInfo.abbreviatedDayNames, o = Date.CultureInfo.shortestDayNames, s = name.toLowerCase(); for (var i = 0; i < n.length; i++) { if (n[i].toLowerCase() === s || m[i].toLowerCase() === s || o[i].toLowerCase() === s) { return i; } } return -1; }; /** * Gets the month number (0-11) if given a Culture Info specific string which is a valid monthName or abbreviatedMonthName. * @param {String} The name of the month (eg. "February, "Feb", "october", "oct"). * @return {Number} The day number */ $D.getMonthNumberFromName = function (name) { var n = Date.CultureInfo.monthNames, m = Date.CultureInfo.abbreviatedMonthNames, s = name.toLowerCase(); for (var i = 0; i < n.length; i++) { if (n[i].toLowerCase() === s || m[i].toLowerCase() === s) { return i; } } return -1; }; /** * Gets the language appropriate month name when given the month number(0-11) * eg - 0 == January * @return {String} The month name */ $D.getMonthName = function (n) { return Date.CultureInfo.monthNames[n]; }; /** * Determines if the current date instance is within a LeapYear. * @param {Number} The year. * @return {Boolean} true if date is within a LeapYear, otherwise false. */ $D.isLeapYear = function (year) { return ((year % 4 === 0 && year % 100 !== 0) || year % 400 === 0); }; /** * Gets the number of days in the month, given a year and month value. Automatically corrects for LeapYear. * @param {Number} The year. * @param {Number} The month (0-11). * @return {Number} The number of days in the month. */ $D.getDaysInMonth = function (year, month) { if (!month && $D.validateMonth(year)) { month = year; year = Date.today().getFullYear(); } return [31, ($D.isLeapYear(year) ? 29 : 28), 31, 30, 31, 30, 31, 31, 30, 31, 30, 31][month]; }; $P.getDaysInMonth = function () { return $D.getDaysInMonth(this.getFullYear(), this.getMonth()); }; $D.getTimezoneAbbreviation = function (offset, dst) { var p, n = (dst || false) ? Date.CultureInfo.abbreviatedTimeZoneDST : Date.CultureInfo.abbreviatedTimeZoneStandard; for (p in n) { if (n.hasOwnProperty(p)) { if (n[p] === offset) { return p; } } } return null; }; $D.getTimezoneOffset = function (name, dst) { var i, a =[], z = Date.CultureInfo.timezones; if (!name) { name = (new Date()).getTimezone();} for (i = 0; i < z.length; i++) { if (z[i].name === name.toUpperCase()) { a.push(i); } } if (!z[a[0]]) { return null; } if (a.length === 1 || !dst) { return z[a[0]].offset; } else { for (i=0; i < a.length; i++) { if (z[a[i]].dst) { return z[a[i]].offset; } } } }; $D.getQuarter = function (d) { d = d || new Date(); // If no date supplied, use today var q = [1,2,3,4]; return q[Math.floor(d.getMonth() / 3)]; // ~~~ is a bitwise op. Faster than Math.floor }; $D.getDaysLeftInQuarter = function (d) { d = d || new Date(); var qEnd = new Date(d); qEnd.setMonth(qEnd.getMonth() + 3 - qEnd.getMonth() % 3, 0); return Math.floor((qEnd - d) / 8.64e7); }; // private var validate = function (n, min, max, name) { name = name ? name : "Object"; if (typeof n === "undefined") { return false; } else if (typeof n !== "number") { throw new TypeError(n + " is not a Number."); } else if (n < min || n > max) { // As failing validation is *not* an exceptional circumstance // lets not throw a RangeError Exception here. // It's semantically correct but it's not sensible. return false; } return true; }; /** * Validates the number is within an acceptable range for milliseconds [0-999]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateMillisecond = function (value) { return validate(value, 0, 999, "millisecond"); }; /** * Validates the number is within an acceptable range for seconds [0-59]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateSecond = function (value) { return validate(value, 0, 59, "second"); }; /** * Validates the number is within an acceptable range for minutes [0-59]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateMinute = function (value) { return validate(value, 0, 59, "minute"); }; /** * Validates the number is within an acceptable range for hours [0-23]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateHour = function (value) { return validate(value, 0, 23, "hour"); }; /** * Validates the number is within an acceptable range for the days in a month [0-MaxDaysInMonth]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateDay = function (value, year, month) { if (year === undefined || year === null || month === undefined || month === null) { return false;} return validate(value, 1, $D.getDaysInMonth(year, month), "day"); }; /** * Validates the number is within an acceptable range for months [0-11]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateWeek = function (value) { return validate(value, 0, 53, "week"); }; /** * Validates the number is within an acceptable range for months [0-11]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateMonth = function (value) { return validate(value, 0, 11, "month"); }; /** * Validates the number is within an acceptable range for years. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateYear = function (value) { /** * Per ECMAScript spec the range of times supported by Date objects is * exactly -100,000,000 days to +100,000,000 days measured relative to * midnight at the beginning of 01 January, 1970 UTC. * This gives a range of 8,640,000,000,000,000 milliseconds to either * side of 01 January, 1970 UTC. * * Earliest possible date: Tue, 20 Apr 271,822 B.C. 00:00:00 UTC * Latest possible date: Sat, 13 Sep 275,760 00:00:00 UTC */ return validate(value, -271822, 275760, "year"); }; $D.validateTimezone = function(value) { var timezones = {"ACDT":1,"ACST":1,"ACT":1,"ADT":1,"AEDT":1,"AEST":1,"AFT":1,"AKDT":1,"AKST":1,"AMST":1,"AMT":1,"ART":1,"AST":1,"AWDT":1,"AWST":1,"AZOST":1,"AZT":1,"BDT":1,"BIOT":1,"BIT":1,"BOT":1,"BRT":1,"BST":1,"BTT":1,"CAT":1,"CCT":1,"CDT":1,"CEDT":1,"CEST":1,"CET":1,"CHADT":1,"CHAST":1,"CHOT":1,"ChST":1,"CHUT":1,"CIST":1,"CIT":1,"CKT":1,"CLST":1,"CLT":1,"COST":1,"COT":1,"CST":1,"CT":1,"CVT":1,"CWST":1,"CXT":1,"DAVT":1,"DDUT":1,"DFT":1,"EASST":1,"EAST":1,"EAT":1,"ECT":1,"EDT":1,"EEDT":1,"EEST":1,"EET":1,"EGST":1,"EGT":1,"EIT":1,"EST":1,"FET":1,"FJT":1,"FKST":1,"FKT":1,"FNT":1,"GALT":1,"GAMT":1,"GET":1,"GFT":1,"GILT":1,"GIT":1,"GMT":1,"GST":1,"GYT":1,"HADT":1,"HAEC":1,"HAST":1,"HKT":1,"HMT":1,"HOVT":1,"HST":1,"ICT":1,"IDT":1,"IOT":1,"IRDT":1,"IRKT":1,"IRST":1,"IST":1,"JST":1,"KGT":1,"KOST":1,"KRAT":1,"KST":1,"LHST":1,"LINT":1,"MAGT":1,"MART":1,"MAWT":1,"MDT":1,"MET":1,"MEST":1,"MHT":1,"MIST":1,"MIT":1,"MMT":1,"MSK":1,"MST":1,"MUT":1,"MVT":1,"MYT":1,"NCT":1,"NDT":1,"NFT":1,"NPT":1,"NST":1,"NT":1,"NUT":1,"NZDT":1,"NZST":1,"OMST":1,"ORAT":1,"PDT":1,"PET":1,"PETT":1,"PGT":1,"PHOT":1,"PHT":1,"PKT":1,"PMDT":1,"PMST":1,"PONT":1,"PST":1,"PYST":1,"PYT":1,"RET":1,"ROTT":1,"SAKT":1,"SAMT":1,"SAST":1,"SBT":1,"SCT":1,"SGT":1,"SLST":1,"SRT":1,"SST":1,"SYOT":1,"TAHT":1,"THA":1,"TFT":1,"TJT":1,"TKT":1,"TLT":1,"TMT":1,"TOT":1,"TVT":1,"UCT":1,"ULAT":1,"UTC":1,"UYST":1,"UYT":1,"UZT":1,"VET":1,"VLAT":1,"VOLT":1,"VOST":1,"VUT":1,"WAKT":1,"WAST":1,"WAT":1,"WEDT":1,"WEST":1,"WET":1,"WST":1,"YAKT":1,"YEKT":1,"Z":1}; return (timezones[value] === 1); }; $D.validateTimezoneOffset= function(value) { // timezones go from +14hrs to -12hrs, the +X hours are negative offsets. return (value > -841 && value < 721); }; }()); (function () { var $D = Date, $P = $D.prototype, p = function (s, l) { if (!l) { l = 2; } return ("000" + s).slice(l * -1); }; var validateConfigObject = function (obj) { var result = {}, self = this, prop, testFunc; testFunc = function (prop, func, value) { if (prop === "day") { var month = (obj.month !== undefined) ? obj.month : self.getMonth(); var year = (obj.year !== undefined) ? obj.year : self.getFullYear(); return $D[func](value, year, month); } else { return $D[func](value); } }; for (prop in obj) { if (Object.prototype.hasOwnProperty.call(obj, prop)) { var func = "validate" + prop.charAt(0).toUpperCase() + prop.slice(1); if ($D[func] && obj[prop] !== null && testFunc(prop, func, obj[prop])) { result[prop] = obj[prop]; } } } return result; }; /** * Resets the time of this Date object to 12:00 AM (00:00), which is the start of the day. * @param {Boolean} .clone() this date instance before clearing Time * @return {Date} this */ $P.clearTime = function () { this.setHours(0); this.setMinutes(0); this.setSeconds(0); this.setMilliseconds(0); return this; }; /** * Resets the time of this Date object to the current time ('now'). * @return {Date} this */ $P.setTimeToNow = function () { var n = new Date(); this.setHours(n.getHours()); this.setMinutes(n.getMinutes()); this.setSeconds(n.getSeconds()); this.setMilliseconds(n.getMilliseconds()); return this; }; /** * Returns a new Date object that is an exact date and time copy of the original instance. * @return {Date} A new Date instance */ $P.clone = function () { return new Date(this.getTime()); }; /** * Compares this instance to a Date object and returns an number indication of their relative values. * @param {Date} Date object to compare [Required] * @return {Number} -1 = this is lessthan date. 0 = values are equal. 1 = this is greaterthan date. */ $P.compareTo = function (date) { return Date.compare(this, date); }; /** * Compares this instance to another Date object and returns true if they are equal. * @param {Date} Date object to compare. If no date to compare, new Date() [now] is used. * @return {Boolean} true if dates are equal. false if they are not equal. */ $P.equals = function (date) { return Date.equals(this, (date !== undefined ? date : new Date())); }; /** * Determines if this instance is between a range of two dates or equal to either the start or end dates. * @param {Date} Start of range [Required] * @param {Date} End of range [Required] * @return {Boolean} true is this is between or equal to the start and end dates, else false */ $P.between = function (start, end) { return this.getTime() >= start.getTime() && this.getTime() <= end.getTime(); }; /** * Determines if this date occurs after the date to compare to. * @param {Date} Date object to compare. If no date to compare, new Date() ("now") is used. * @return {Boolean} true if this date instance is greater than the date to compare to (or "now"), otherwise false. */ $P.isAfter = function (date) { return this.compareTo(date || new Date()) === 1; }; /** * Determines if this date occurs before the date to compare to. * @param {Date} Date object to compare. If no date to compare, new Date() ("now") is used. * @return {Boolean} true if this date instance is less than the date to compare to (or "now"). */ $P.isBefore = function (date) { return (this.compareTo(date || new Date()) === -1); }; /** * Determines if the current Date instance occurs today. * @return {Boolean} true if this date instance is 'today', otherwise false. */ /** * Determines if the current Date instance occurs on the same Date as the supplied 'date'. * If no 'date' to compare to is provided, the current Date instance is compared to 'today'. * @param {date} Date object to compare. If no date to compare, the current Date ("now") is used. * @return {Boolean} true if this Date instance occurs on the same Day as the supplied 'date'. */ $P.isToday = $P.isSameDay = function (date) { return this.clone().clearTime().equals((date || new Date()).clone().clearTime()); }; /** * Adds the specified number of milliseconds to this instance. * @param {Number} The number of milliseconds to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addMilliseconds = function (value) { if (!value) { return this; } this.setTime(this.getTime() + value * 1); return this; }; /** * Adds the specified number of seconds to this instance. * @param {Number} The number of seconds to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addSeconds = function (value) { if (!value) { return this; } return this.addMilliseconds(value * 1000); }; /** * Adds the specified number of seconds to this instance. * @param {Number} The number of seconds to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addMinutes = function (value) { if (!value) { return this; } return this.addMilliseconds(value * 60000); // 60*1000 }; /** * Adds the specified number of hours to this instance. * @param {Number} The number of hours to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addHours = function (value) { if (!value) { return this; } return this.addMilliseconds(value * 3600000); // 60*60*1000 }; /** * Adds the specified number of days to this instance. * @param {Number} The number of days to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addDays = function (value) { if (!value) { return this; } this.setDate(this.getDate() + value * 1); return this; }; /** * Adds the specified number of weekdays (ie - not sat or sun) to this instance. * @param {Number} The number of days to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addWeekdays = function (value) { if (!value) { return this; } var day = this.getDay(); var weeks = (Math.ceil(Math.abs(value)/7)); if (day === 0 || day === 6) { if (value > 0) { this.next().monday(); this.addDays(-1); day = this.getDay(); } } if (value < 0) { while (value < 0) { this.addDays(-1); day = this.getDay(); if (day !== 0 && day !== 6) { value++; } } return this; } else if (value > 5 || (6-day) <= value) { value = value + (weeks * 2); } return this.addDays(value); }; /** * Adds the specified number of weeks to this instance. * @param {Number} The number of weeks to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addWeeks = function (value) { if (!value) { return this; } return this.addDays(value * 7); }; /** * Adds the specified number of months to this instance. * @param {Number} The number of months to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addMonths = function (value) { if (!value) { return this; } var n = this.getDate(); this.setDate(1); this.setMonth(this.getMonth() + value * 1); this.setDate(Math.min(n, $D.getDaysInMonth(this.getFullYear(), this.getMonth()))); return this; }; $P.addQuarters = function (value) { if (!value) { return this; } // note this will take you to the same point in the quarter as you are now. // i.e. - if you are 15 days into the quarter you'll be 15 days into the resulting one. // bonus: this allows adding fractional quarters return this.addMonths(value * 3); }; /** * Adds the specified number of years to this instance. * @param {Number} The number of years to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addYears = function (value) { if (!value) { return this; } return this.addMonths(value * 12); }; /** * Adds (or subtracts) to the value of the years, months, weeks, days, hours, minutes, seconds, milliseconds of the date instance using given configuration object. Positive and Negative values allowed. * Example

	Date.today().add( { days: 1, months: 1 } )

	new Date().add( { years: -1 } )
	
* @param {Object} Configuration object containing attributes (months, days, etc.) * @return {Date} this */ $P.add = function (config) { if (typeof config === "number") { this._orient = config; return this; } var x = config; if (x.day) { // If we should be a different date than today (eg: for 'tomorrow -1d', etc). // Should only effect parsing, not direct usage (eg, Finish and FinishExact) if ((x.day - this.getDate()) !== 0) { this.setDate(x.day); } } if (x.milliseconds) { this.addMilliseconds(x.milliseconds); } if (x.seconds) { this.addSeconds(x.seconds); } if (x.minutes) { this.addMinutes(x.minutes); } if (x.hours) { this.addHours(x.hours); } if (x.weeks) { this.addWeeks(x.weeks); } if (x.months) { this.addMonths(x.months); } if (x.years) { this.addYears(x.years); } if (x.days) { this.addDays(x.days); } return this; }; /** * Get the week number. Week one (1) is the week which contains the first Thursday of the year. Monday is considered the first day of the week. * The .getWeek() function does NOT convert the date to UTC. The local datetime is used. * Please use .getISOWeek() to get the week of the UTC converted date. * @return {Number} 1 to 53 */ $P.getWeek = function (utc) { // Create a copy of this date object var self, target = new Date(this.valueOf()); if (utc) { target.addMinutes(target.getTimezoneOffset()); self = target.clone(); } else { self = this; } // ISO week date weeks start on monday // so correct the day number var dayNr = (self.getDay() + 6) % 7; // ISO 8601 states that week 1 is the week // with the first thursday of that year. // Set the target date to the thursday in the target week target.setDate(target.getDate() - dayNr + 3); // Store the millisecond value of the target date var firstThursday = target.valueOf(); // Set the target to the first thursday of the year // First set the target to january first target.setMonth(0, 1); // Not a thursday? Correct the date to the next thursday if (target.getDay() !== 4) { target.setMonth(0, 1 + ((4 - target.getDay()) + 7) % 7); } // The weeknumber is the number of weeks between the // first thursday of the year and the thursday in the target week return 1 + Math.ceil((firstThursday - target) / 604800000); // 604800000 = 7 * 24 * 3600 * 1000 }; /** * Get the ISO 8601 week number. Week one ("01") is the week which contains the first Thursday of the year. Monday is considered the first day of the week. * The .getISOWeek() function does convert the date to it's UTC value. Please use .getWeek() to get the week of the local date. * @return {String} "01" to "53" */ $P.getISOWeek = function () { return p(this.getWeek(true)); }; /** * Moves the date to Monday of the week set. Week one (1) is the week which contains the first Thursday of the year. * @param {Number} A Number (1 to 53) that represents the week of the year. * @return {Date} this */ $P.setWeek = function (n) { if ((n - this.getWeek()) === 0) { if (this.getDay() !== 1) { return this.moveToDayOfWeek(1, (this.getDay() > 1 ? -1 : 1)); } else { return this; } } else { return this.moveToDayOfWeek(1, (this.getDay() > 1 ? -1 : 1)).addWeeks(n - this.getWeek()); } }; $P.setQuarter = function (qtr) { var month = Math.abs(((qtr-1) * 3) + 1); return this.setMonth(month, 1); }; $P.getQuarter = function () { return Date.getQuarter(this); }; $P.getDaysLeftInQuarter = function () { return Date.getDaysLeftInQuarter(this); }; /** * Moves the date to the next n'th occurrence of the dayOfWeek starting from the beginning of the month. The number (-1) is a magic number and will return the last occurrence of the dayOfWeek in the month. * @param {Number} The dayOfWeek to move to * @param {Number} The n'th occurrence to move to. Use (-1) to return the last occurrence in the month * @return {Date} this */ $P.moveToNthOccurrence = function (dayOfWeek, occurrence) { if (dayOfWeek === "Weekday") { if (occurrence > 0) { this.moveToFirstDayOfMonth(); if (this.is().weekday()) { occurrence -= 1; } } else if (occurrence < 0) { this.moveToLastDayOfMonth(); if (this.is().weekday()) { occurrence += 1; } } else { return this; } return this.addWeekdays(occurrence); } var shift = 0; if (occurrence > 0) { shift = occurrence - 1; } else if (occurrence === -1) { this.moveToLastDayOfMonth(); if (this.getDay() !== dayOfWeek) { this.moveToDayOfWeek(dayOfWeek, -1); } return this; } return this.moveToFirstDayOfMonth().addDays(-1).moveToDayOfWeek(dayOfWeek, +1).addWeeks(shift); }; var moveToN = function (getFunc, addFunc, nVal) { return function (value, orient) { var diff = (value - this[getFunc]() + nVal * (orient || +1)) % nVal; return this[addFunc]((diff === 0) ? diff += nVal * (orient || +1) : diff); }; }; /** * Move to the next or last dayOfWeek based on the orient value. * @param {Number} The dayOfWeek to move to * @param {Number} Forward (+1) or Back (-1). Defaults to +1. [Optional] * @return {Date} this */ $P.moveToDayOfWeek = moveToN("getDay", "addDays", 7); /** * Move to the next or last month based on the orient value. * @param {Number} The month to move to. 0 = January, 11 = December * @param {Number} Forward (+1) or Back (-1). Defaults to +1. [Optional] * @return {Date} this */ $P.moveToMonth = moveToN("getMonth", "addMonths", 12); /** * Get the Ordinate of the current day ("th", "st", "rd"). * @return {String} */ $P.getOrdinate = function () { var num = this.getDate(); return ord(num); }; /** * Get the Ordinal day (numeric day number) of the year, adjusted for leap year. * @return {Number} 1 through 365 (366 in leap years) */ $P.getOrdinalNumber = function () { return Math.ceil((this.clone().clearTime() - new Date(this.getFullYear(), 0, 1)) / 86400000) + 1; }; /** * Get the time zone abbreviation of the current date. * @return {String} The abbreviated time zone name (e.g. "EST") */ $P.getTimezone = function () { return $D.getTimezoneAbbreviation(this.getUTCOffset(), this.isDaylightSavingTime()); }; $P.setTimezoneOffset = function (offset) { var here = this.getTimezoneOffset(), there = Number(offset) * -6 / 10; return (there || there === 0) ? this.addMinutes(there - here) : this; }; $P.setTimezone = function (offset) { return this.setTimezoneOffset($D.getTimezoneOffset(offset)); }; /** * Indicates whether Daylight Saving Time is observed in the current time zone. * @return {Boolean} true|false */ $P.hasDaylightSavingTime = function () { return (Date.today().set({month: 0, day: 1}).getTimezoneOffset() !== Date.today().set({month: 6, day: 1}).getTimezoneOffset()); }; /** * Indicates whether this Date instance is within the Daylight Saving Time range for the current time zone. * @return {Boolean} true|false */ $P.isDaylightSavingTime = function () { return Date.today().set({month: 0, day: 1}).getTimezoneOffset() !== this.getTimezoneOffset(); }; /** * Get the offset from UTC of the current date. * @return {String} The 4-character offset string prefixed with + or - (e.g. "-0500") */ $P.getUTCOffset = function (offset) { var n = (offset || this.getTimezoneOffset()) * -10 / 6, r; if (n < 0) { r = (n - 10000).toString(); return r.charAt(0) + r.substr(2); } else { r = (n + 10000).toString(); return "+" + r.substr(1); } }; /** * Returns the number of milliseconds between this date and date. * @param {Date} Defaults to now * @return {Number} The diff in milliseconds */ $P.getElapsed = function (date) { return (date || new Date()) - this; }; /** * Set the value of year, month, day, hour, minute, second, millisecond of date instance using given configuration object. * Example

	Date.today().set( { day: 20, month: 1 } )

	new Date().set( { millisecond: 0 } )
	
* * @param {Object} Configuration object containing attributes (month, day, etc.) * @return {Date} this */ $P.set = function (config) { config = validateConfigObject.call(this, config); var key; for (key in config) { if (Object.prototype.hasOwnProperty.call(config, key)) { var name = key.charAt(0).toUpperCase() + key.slice(1); var addFunc, getFunc; if (key !== "week" && key !== "month" && key !== "timezone" && key !== "timezoneOffset") { name += "s"; } addFunc = "add" + name; getFunc = "get" + name; if (key === "month") { addFunc = addFunc + "s"; } else if (key === "year"){ getFunc = "getFullYear"; } if (key !== "day" && key !== "timezone" && key !== "timezoneOffset" && key !== "week" && key !== "hour") { this[addFunc](config[key] - this[getFunc]()); } else if ( key === "timezone"|| key === "timezoneOffset" || key === "week" || key === "hour") { this["set"+name](config[key]); } } } // day has to go last because you can't validate the day without first knowing the month if (config.day) { this.addDays(config.day - this.getDate()); } return this; }; /** * Moves the date to the first day of the month. * @return {Date} this */ $P.moveToFirstDayOfMonth = function () { return this.set({ day: 1 }); }; /** * Moves the date to the last day of the month. * @return {Date} this */ $P.moveToLastDayOfMonth = function () { return this.set({ day: $D.getDaysInMonth(this.getFullYear(), this.getMonth())}); }; /** * Converts the value of the current Date object to its equivalent string representation. * Format Specifiers * CUSTOM DATE AND TIME FORMAT STRINGS * Format Description Example * ------ --------------------------------------------------------------------------- ----------------------- * s The seconds of the minute between 0-59. "0" to "59" * ss The seconds of the minute with leading zero if required. "00" to "59" * * m The minute of the hour between 0-59. "0" or "59" * mm The minute of the hour with leading zero if required. "00" or "59" * * h The hour of the day between 1-12. "1" to "12" * hh The hour of the day with leading zero if required. "01" to "12" * * H The hour of the day between 0-23. "0" to "23" * HH The hour of the day with leading zero if required. "00" to "23" * * d The day of the month between 1 and 31. "1" to "31" * dd The day of the month with leading zero if required. "01" to "31" * ddd Abbreviated day name. Date.CultureInfo.abbreviatedDayNames. "Mon" to "Sun" * dddd The full day name. Date.CultureInfo.dayNames. "Monday" to "Sunday" * * M The month of the year between 1-12. "1" to "12" * MM The month of the year with leading zero if required. "01" to "12" * MMM Abbreviated month name. Date.CultureInfo.abbreviatedMonthNames. "Jan" to "Dec" * MMMM The full month name. Date.CultureInfo.monthNames. "January" to "December" * * yy The year as a two-digit number. "99" or "08" * yyyy The full four digit year. "1999" or "2008" * * t Displays the first character of the A.M./P.M. designator. "A" or "P" * Date.CultureInfo.amDesignator or Date.CultureInfo.pmDesignator * tt Displays the A.M./P.M. designator. "AM" or "PM" * Date.CultureInfo.amDesignator or Date.CultureInfo.pmDesignator * * S The ordinal suffix ("st, "nd", "rd" or "th") of the current day. "st, "nd", "rd" or "th" * * STANDARD DATE AND TIME FORMAT STRINGS * Format Description Example *------ --------------------------------------------------------------------------- ----------------------- * d The CultureInfo shortDate Format Pattern "M/d/yyyy" * D The CultureInfo longDate Format Pattern "dddd, MMMM dd, yyyy" * F The CultureInfo fullDateTime Format Pattern "dddd, MMMM dd, yyyy h:mm:ss tt" * m The CultureInfo monthDay Format Pattern "MMMM dd" * r The CultureInfo rfc1123 Format Pattern "ddd, dd MMM yyyy HH:mm:ss GMT" * s The CultureInfo sortableDateTime Format Pattern "yyyy-MM-ddTHH:mm:ss" * t The CultureInfo shortTime Format Pattern "h:mm tt" * T The CultureInfo longTime Format Pattern "h:mm:ss tt" * u The CultureInfo universalSortableDateTime Format Pattern "yyyy-MM-dd HH:mm:ssZ" * y The CultureInfo yearMonth Format Pattern "MMMM, yyyy" * * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @return {String} A string representation of the current Date object. */ var ord = function (n) { switch (n * 1) { case 1: case 21: case 31: return "st"; case 2: case 22: return "nd"; case 3: case 23: return "rd"; default: return "th"; } }; var parseStandardFormats = function (format) { var y, c = Date.CultureInfo.formatPatterns; switch (format) { case "d": return this.toString(c.shortDate); case "D": return this.toString(c.longDate); case "F": return this.toString(c.fullDateTime); case "m": return this.toString(c.monthDay); case "r": case "R": y = this.clone().addMinutes(this.getTimezoneOffset()); return y.toString(c.rfc1123) + " GMT"; case "s": return this.toString(c.sortableDateTime); case "t": return this.toString(c.shortTime); case "T": return this.toString(c.longTime); case "u": y = this.clone().addMinutes(this.getTimezoneOffset()); return y.toString(c.universalSortableDateTime); case "y": return this.toString(c.yearMonth); default: return false; } }; var parseFormatStringsClosure = function (context) { return function (m) { if (m.charAt(0) === "\\") { return m.replace("\\", ""); } switch (m) { case "hh": return p(context.getHours() < 13 ? (context.getHours() === 0 ? 12 : context.getHours()) : (context.getHours() - 12)); case "h": return context.getHours() < 13 ? (context.getHours() === 0 ? 12 : context.getHours()) : (context.getHours() - 12); case "HH": return p(context.getHours()); case "H": return context.getHours(); case "mm": return p(context.getMinutes()); case "m": return context.getMinutes(); case "ss": return p(context.getSeconds()); case "s": return context.getSeconds(); case "yyyy": return p(context.getFullYear(), 4); case "yy": return p(context.getFullYear()); case "y": return context.getFullYear(); case "E": case "dddd": return Date.CultureInfo.dayNames[context.getDay()]; case "ddd": return Date.CultureInfo.abbreviatedDayNames[context.getDay()]; case "dd": return p(context.getDate()); case "d": return context.getDate(); case "MMMM": return Date.CultureInfo.monthNames[context.getMonth()]; case "MMM": return Date.CultureInfo.abbreviatedMonthNames[context.getMonth()]; case "MM": return p((context.getMonth() + 1)); case "M": return context.getMonth() + 1; case "t": return context.getHours() < 12 ? Date.CultureInfo.amDesignator.substring(0, 1) : Date.CultureInfo.pmDesignator.substring(0, 1); case "tt": return context.getHours() < 12 ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator; case "S": return ord(context.getDate()); case "W": return context.getWeek(); case "WW": return context.getISOWeek(); case "Q": return "Q" + context.getQuarter(); case "q": return String(context.getQuarter()); case "z": return context.getTimezone(); case "Z": case "X": return Date.getTimezoneOffset(context.getTimezone()); case "ZZ": // Timezone offset in seconds return context.getTimezoneOffset() * -60; case "u": return context.getDay(); case "L": return ($D.isLeapYear(context.getFullYear())) ? 1 : 0; case "B": // Swatch Internet Time (.beats) return "@"+((context.getUTCSeconds() + (context.getUTCMinutes()*60) + ((context.getUTCHours()+1)*3600))/86.4); default: return m; } }; }; $P.toString = function (format, ignoreStandards) { // Standard Date and Time Format Strings. Formats pulled from CultureInfo file and // may vary by culture. if (!ignoreStandards && format && format.length === 1) { output = parseStandardFormats.call(this, format); if (output) { return output; } } var parseFormatStrings = parseFormatStringsClosure(this); return format ? format.replace(/((\\)?(dd?d?d?|MM?M?M?|yy?y?y?|hh?|HH?|mm?|ss?|tt?|S|q|Q|WW?W?W?)(?![^\[]*\]))/g, parseFormatStrings).replace(/\[|\]/g, "") : this._toString(); }; }()); /************************************************************* * SugarPak - Domain Specific Language - Syntactical Sugar * *************************************************************/ (function () { var $D = Date, $P = $D.prototype, $N = Number.prototype; // private $P._orient = +1; // private $P._nth = null; // private $P._is = false; // private $P._same = false; // private $P._isSecond = false; // private $N._dateElement = "days"; /** * Moves the date to the next instance of a date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.today().next().friday();
	Date.today().next().fri();
	Date.today().next().march();
	Date.today().next().mar();
	Date.today().next().week();
	
* * @return {Date} date */ $P.next = function () { this._move = true; this._orient = +1; return this; }; /** * Creates a new Date (Date.today()) and moves the date to the next instance of the date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.next().friday();
	Date.next().fri();
	Date.next().march();
	Date.next().mar();
	Date.next().week();
	
* * @return {Date} date */ $D.next = function () { return $D.today().next(); }; /** * Moves the date to the previous instance of a date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.today().last().friday();
	Date.today().last().fri();
	Date.today().last().march();
	Date.today().last().mar();
	Date.today().last().week();
	
* * @return {Date} date */ $P.last = $P.prev = $P.previous = function () { this._move = true; this._orient = -1; return this; }; /** * Creates a new Date (Date.today()) and moves the date to the previous instance of the date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.last().friday();
	Date.last().fri();
	Date.previous().march();
	Date.prev().mar();
	Date.last().week();
	
* * @return {Date} date */ $D.last = $D.prev = $D.previous = function () { return $D.today().last(); }; /** * Performs a equality check when followed by either a month name, day name or .weekday() function. * Example

	Date.today().is().friday(); // true|false
	Date.today().is().fri();
	Date.today().is().march();
	Date.today().is().mar();
	
* * @return {Boolean} true|false */ $P.is = function () { this._is = true; return this; }; /** * Determines if two date objects occur on/in exactly the same instance of the subsequent date part function. * The function .same() must be followed by a date part function (example: .day(), .month(), .year(), etc). * * An optional Date can be passed in the date part function. If now date is passed as a parameter, 'Now' is used. * * The following example demonstrates how to determine if two dates fall on the exact same day. * * Example

	var d1 = Date.today(); // today at 00:00
	var d2 = new Date();   // exactly now.

	// Do they occur on the same day?
	d1.same().day(d2); // true
	
	// Do they occur on the same hour?
	d1.same().hour(d2); // false, unless d2 hour is '00' (midnight).
	
	// What if it's the same day, but one year apart?
	var nextYear = Date.today().add(1).year();

	d1.same().day(nextYear); // false, because the dates must occur on the exact same day. 
	
* * Scenario: Determine if a given date occurs during some week period 2 months from now. * * Example

	var future = Date.today().add(2).months();
	return someDate.same().week(future); // true|false;
	
* * @return {Boolean} true|false */ $P.same = function () { this._same = true; this._isSecond = false; return this; }; /** * Determines if the current date/time occurs during Today. Must be preceded by the .is() function. * Example

	someDate.is().today();    // true|false
	new Date().is().today();  // true
	Date.today().is().today();// true
	Date.today().add(-1).day().is().today(); // false
	
* * @return {Boolean} true|false */ $P.today = function () { return this.same().day(); }; /** * Determines if the current date is a weekday. This function must be preceded by the .is() function. * Example

	Date.today().is().weekday(); // true|false
	
* * @return {Boolean} true|false */ $P.weekday = function () { if (this._nth) { return df("Weekday").call(this); } if (this._move) { return this.addWeekdays(this._orient); } if (this._is) { this._is = false; return (!this.is().sat() && !this.is().sun()); } return false; }; /** * Determines if the current date is on the weekend. This function must be preceded by the .is() function. * Example

	Date.today().is().weekend(); // true|false
	
* * @return {Boolean} true|false */ $P.weekend = function () { if (this._is) { this._is = false; return (this.is().sat() || this.is().sun()); } return false; }; /** * Sets the Time of the current Date instance. A string "6:15 pm" or config object {hour:18, minute:15} are accepted. * Example

	// Set time to 6:15pm with a String
	Date.today().at("6:15pm");

	// Set time to 6:15pm with a config object
	Date.today().at({hour:18, minute:15});
	
* * @return {Date} date */ $P.at = function (time) { return (typeof time === "string") ? $D.parse(this.toString("d") + " " + time) : this.set(time); }; /** * Creates a new Date() and adds this (Number) to the date based on the preceding date element function (eg. second|minute|hour|day|month|year). * Example

	// Undeclared Numbers must be wrapped with parentheses. Requirment of JavaScript.
	(3).days().fromNow();
	(6).months().fromNow();

	// Declared Number variables do not require parentheses. 
	var n = 6;
	n.months().fromNow();
	
* * @return {Date} A new Date instance */ $N.fromNow = $N.after = function (date) { var c = {}; c[this._dateElement] = this; return ((!date) ? new Date() : date.clone()).add(c); }; /** * Creates a new Date() and subtract this (Number) from the date based on the preceding date element function (eg. second|minute|hour|day|month|year). * Example

	// Undeclared Numbers must be wrapped with parentheses. Requirment of JavaScript.
	(3).days().ago();
	(6).months().ago();

	// Declared Number variables do not require parentheses. 
	var n = 6;
	n.months().ago();
	
* * @return {Date} A new Date instance */ $N.ago = $N.before = function (date) { var c = {}, s = (this._dateElement[this._dateElement.length-1] !== "s") ? this._dateElement + "s" : this._dateElement; c[s] = this * -1; return ((!date) ? new Date() : date.clone()).add(c); }; // Do NOT modify the following string tokens. These tokens are used to build dynamic functions. // All culture-specific strings can be found in the CultureInfo files. var dx = ("sunday monday tuesday wednesday thursday friday saturday").split(/\s/), mx = ("january february march april may june july august september october november december").split(/\s/), px = ("Millisecond Second Minute Hour Day Week Month Year Quarter Weekday").split(/\s/), pxf = ("Milliseconds Seconds Minutes Hours Date Week Month FullYear Quarter").split(/\s/), nth = ("final first second third fourth fifth").split(/\s/), de; /** * Returns an object literal of all the date parts. * Example

	var o = new Date().toObject();
	
	// { year: 2008, month: 4, week: 20, day: 13, hour: 18, minute: 9, second: 32, millisecond: 812 }
	
	// The object properties can be referenced directly from the object.
	
	alert(o.day);  // alerts "13"
	alert(o.year); // alerts "2008"
	
* * @return {Date} An object literal representing the original date object. */ $P.toObject = function () { var o = {}; for (var i = 0; i < px.length; i++) { if (this["get" + pxf[i]]) { o[px[i].toLowerCase()] = this["get" + pxf[i]](); } } return o; }; /** * Returns a date created from an object literal. Ignores the .week property if set in the config. * Example

	var o = new Date().toObject();
	
	return Date.fromObject(o); // will return the same date. 

	var o2 = {month: 1, day: 20, hour: 18}; // birthday party!
	Date.fromObject(o2);
	
* * @return {Date} An object literal representing the original date object. */ $D.fromObject = function(config) { config.week = null; return Date.today().set(config); }; // Create day name functions and abbreviated day name functions (eg. monday(), friday(), fri()). var df = function (n) { return function () { if (this._is) { this._is = false; return this.getDay() === n; } if (this._move) { this._move = null; } if (this._nth !== null) { // If the .second() function was called earlier, remove the _orient // from the date, and then continue. // This is required because 'second' can be used in two different context. // // Example // // Date.today().add(1).second(); // Date.march().second().monday(); // // Things get crazy with the following... // Date.march().add(1).second().second().monday(); // but it works!! // if (this._isSecond) { this.addSeconds(this._orient * -1); } // make sure we reset _isSecond this._isSecond = false; var ntemp = this._nth; this._nth = null; var temp = this.clone().moveToLastDayOfMonth(); this.moveToNthOccurrence(n, ntemp); if (this > temp) { throw new RangeError($D.getDayName(n) + " does not occur " + ntemp + " times in the month of " + $D.getMonthName(temp.getMonth()) + " " + temp.getFullYear() + "."); } return this; } return this.moveToDayOfWeek(n, this._orient); }; }; var sdf = function (n) { return function () { var t = $D.today(), shift = n - t.getDay(); if (n === 0 && Date.CultureInfo.firstDayOfWeek === 1 && t.getDay() !== 0) { shift = shift + 7; } return t.addDays(shift); }; }; // Create month name functions and abbreviated month name functions (eg. january(), march(), mar()). var month_instance_functions = function (n) { return function () { if (this._is) { this._is = false; return this.getMonth() === n; } return this.moveToMonth(n, this._orient); }; }; var month_static_functions = function (n) { return function () { return $D.today().set({ month: n, day: 1 }); }; }; var processTerms = function (names, staticFunc, instanceFunc) { for (var i = 0; i < names.length; i++) { // Create constant static Name variables. $D[names[i].toUpperCase()] = $D[names[i].toUpperCase().substring(0, 3)] = i; // Create Name functions. $D[names[i]] = $D[names[i].substring(0, 3)] = staticFunc(i); // Create Name instance functions. $P[names[i]] = $P[names[i].substring(0, 3)] = instanceFunc(i); } }; processTerms(dx, sdf, df); processTerms(mx, month_static_functions, month_instance_functions); // Create date element functions and plural date element functions used with Date (eg. day(), days(), months()). var ef = function (j) { return function () { // if the .second() function was called earlier, the _orient // has alread been added. Just return this and reset _isSecond. if (this._isSecond) { this._isSecond = false; return this; } if (this._same) { this._same = this._is = false; var o1 = this.toObject(), o2 = (arguments[0] || new Date()).toObject(), v = "", k = j.toLowerCase(); // the substr trick with -1 doesn't work in IE8 or less k = (k[k.length-1] === "s") ? k.substring(0,k.length-1) : k; for (var m = (px.length - 1); m > -1; m--) { v = px[m].toLowerCase(); if (o1[v] !== o2[v]) { return false; } if (k === v) { break; } } return true; } if (j.substring(j.length - 1) !== "s") { j += "s"; } if (this._move) { this._move = null; } return this["add" + j](this._orient); }; }; var nf = function (n) { return function () { this._dateElement = n; return this; }; }; for (var k = 0; k < px.length; k++) { de = px[k].toLowerCase(); if(de !== "weekday") { // Create date element functions and plural date element functions used with Date (eg. day(), days(), months()). $P[de] = $P[de + "s"] = ef(px[k]); // Create date element functions and plural date element functions used with Number (eg. day(), days(), months()). $N[de] = $N[de + "s"] = nf(de + "s"); } } $P._ss = ef("Second"); var nthfn = function (n) { return function (dayOfWeek) { if (this._same) { return this._ss(arguments[0]); } if (dayOfWeek || dayOfWeek === 0) { return this.moveToNthOccurrence(dayOfWeek, n); } this._nth = n; // if the operator is 'second' add the _orient, then deal with it later... if (n === 2 && (dayOfWeek === undefined || dayOfWeek === null)) { this._isSecond = true; return this.addSeconds(this._orient); } return this; }; }; for (var l = 0; l < nth.length; l++) { $P[nth[l]] = (l === 0) ? nthfn(-1) : nthfn(l); } }()); (function () { "use strict"; Date.Parsing = { Exception: function (s) { this.message = "Parse error at '" + s.substring(0, 10) + " ...'"; } }; var $P = Date.Parsing; var dayOffsets = { standard: [0,31,59,90,120,151,181,212,243,273,304,334], leap: [0,31,60,91,121,152,182,213,244,274,305,335] }; $P.isLeapYear = function(year) { return ((year % 4 === 0) && (year % 100 !== 0)) || (year % 400 === 0); }; var utils = { multiReplace : function (str, hash ) { var key; for (key in hash) { if (Object.prototype.hasOwnProperty.call(hash, key)) { var regex; if (typeof hash[key] === "function") { } else { regex = (hash[key] instanceof RegExp) ? hash[key] : new RegExp(hash[key], "g"); } str = str.replace(regex, key); } } return str; }, getDayOfYearFromWeek : function (obj) { var d, jan4, offset; obj.weekDay = (!obj.weekDay && obj.weekDay !== 0) ? 1 : obj.weekDay; d = new Date(obj.year, 0, 4); jan4 = d.getDay() === 0 ? 7 : d.getDay(); // JS is 0 indexed on Sunday. offset = jan4+3; obj.dayOfYear = ((obj.week * 7) + (obj.weekDay === 0 ? 7 : obj.weekDay))-offset; return obj; }, getDayOfYear : function (obj, dayOffset) { if (!obj.dayOfYear) { obj = utils.getDayOfYearFromWeek(obj); } for (var i=0;i <= dayOffset.length;i++) { if (obj.dayOfYear < dayOffset[i] || i === dayOffset.length) { obj.day = obj.day ? obj.day : (obj.dayOfYear - dayOffset[i-1]); break; } else { obj.month = i; } } return obj; }, adjustForTimeZone : function (obj, date) { var offset; if (obj.zone.toUpperCase() === "Z" || (obj.zone_hours === 0 && obj.zone_minutes === 0)) { // it's UTC/GML so work out the current timeszone offset offset = -date.getTimezoneOffset(); } else { offset = (obj.zone_hours*60) + (obj.zone_minutes || 0); if (obj.zone_sign === "+") { offset *= -1; } offset -= date.getTimezoneOffset(); } date.setMinutes(date.getMinutes()+offset); return date; }, setDefaults : function (obj) { obj.year = obj.year || Date.today().getFullYear(); obj.hours = obj.hours || 0; obj.minutes = obj.minutes || 0; obj.seconds = obj.seconds || 0; obj.milliseconds = obj.milliseconds || 0; if (!(!obj.month && (obj.week || obj.dayOfYear))) { // if we have a month, or if we don't but don't have the day calculation data obj.month = obj.month || 0; obj.day = obj.day || 1; } return obj; }, dataNum: function (data, mod, explict, postProcess) { var dataNum = data*1; if (mod) { if (postProcess) { return data ? mod(data)*1 : data; } else { return data ? mod(dataNum) : data; } } else if (!explict){ return data ? dataNum : data; } else { return (data && typeof data !== "undefined") ? dataNum : data; } }, timeDataProcess: function (obj) { var timeObj = {}; for (var x in obj.data) { if (obj.data.hasOwnProperty(x)) { timeObj[x] = obj.ignore[x] ? obj.data[x] : utils.dataNum(obj.data[x], obj.mods[x], obj.explict[x], obj.postProcess[x]); } } if (obj.data.secmins) { obj.data.secmins = obj.data.secmins.replace(",", ".") * 60; if (!timeObj.minutes) { timeObj.minutes = obj.data.secmins; } else if (!timeObj.seconds) { timeObj.seconds = obj.data.secmins; } delete obj.secmins; } return timeObj; }, buildTimeObjectFromData: function (data) { var time = utils.timeDataProcess({ data: { year : data[1], month : data[5], day : data[7], week : data[8], dayOfYear : data[10], hours : data[15], zone_hours : data[23], zone_minutes : data[24], zone : data[21], zone_sign : data[22], weekDay : data[9], minutes: data[16], seconds: data[19], milliseconds: data[20], secmins: data[18] }, mods: { month: function(data) { return data-1; }, weekDay: function (data) { data = Math.abs(data); return (data === 7 ? 0 : data); }, minutes: function (data) { return data.replace(":",""); }, seconds: function (data) { return Math.floor( (data.replace(":","").replace(",","."))*1 ); }, milliseconds: function (data) { return (data.replace(",",".")*1000); } }, postProcess: { minutes: true, seconds: true, milliseconds: true }, explict: { zone_hours: true, zone_minutes: true }, ignore: { zone: true, zone_sign: true, secmins: true } }); return time; }, addToHash: function (hash, keys, data) { keys = keys; data = data; var len = keys.length; for (var i = 0; i < len; i++) { hash[keys[i]] = data[i]; } return hash; }, combineRegex: function (r1, r2) { return new RegExp("(("+r1.source+")\\s("+r2.source+"))"); }, getDateNthString: function(add, last, inc){ if (add) { return Date.today().addDays(inc).toString("d"); } else if (last) { return Date.today().last()[inc]().toString("d"); } }, buildRegexData: function (array) { var arr = []; var len = array.length; for (var i=0; i < len; i++) { if (Object.prototype.toString.call(array[i]) === '[object Array]') { // oldIE compat version of Array.isArray arr.push(this.combineRegex(array[i][0], array[i][1])); } else { arr.push(array[i]); } } return arr; } }; $P.processTimeObject = function (obj) { var date, dayOffset; utils.setDefaults(obj); dayOffset = ($P.isLeapYear(obj.year)) ? dayOffsets.leap : dayOffsets.standard; if (!obj.month && (obj.week || obj.dayOfYear)) { utils.getDayOfYear(obj, dayOffset); } else { obj.dayOfYear = dayOffset[obj.month] + obj.day; } date = new Date(obj.year, obj.month, obj.day, obj.hours, obj.minutes, obj.seconds, obj.milliseconds); if (obj.zone) { utils.adjustForTimeZone(obj, date); // adjust (and calculate) for timezone } return date; }; $P.ISO = { regex : /^([\+-]?\d{4}(?!\d{2}\b))((-?)((0[1-9]|1[0-2])(\3([12]\d|0[1-9]|3[01]))?|W([0-4]\d|5[0-3])(-?[1-7])?|(00[1-9]|0[1-9]\d|[12]\d{2}|3([0-5]\d|6[1-6])))([T\s]((([01]\d|2[0-4])((:?)[0-5]\d)?|24\:?00)([\.,]\d+(?!:))?)?(\17[0-5]\d([\.,]\d+)?)?\s?([zZ]|([\+-])([01]\d|2[0-3]):?([0-5]\d)?)?)?)?$/, parse : function (s) { var time, data = s.match(this.regex); if (!data || !data.length) { return null; } time = utils.buildTimeObjectFromData(data); if (!time.year || (!time.year && (!time.month && !time.day) && (!time.week && !time.dayOfYear)) ) { return null; } return $P.processTimeObject(time); } }; $P.Numeric = { isNumeric: function (e){return!isNaN(parseFloat(e))&&isFinite(e);}, regex: /\b([0-1]?[0-9])([0-3]?[0-9])([0-2]?[0-9]?[0-9][0-9])\b/i, parse: function (s) { var data, i, time = {}, order = Date.CultureInfo.dateElementOrder.split(""); if (!(this.isNumeric(s)) || // if it's non-numeric OR (s[0] === "+" && s[0] === "-")) { // It's an arithmatic string (eg +/-1000) return null; } if (s.length < 5 && s.indexOf(".") < 0 && s.indexOf("/") < 0) { // assume it's just a year. time.year = s; return $P.processTimeObject(time); } data = s.match(this.regex); if (!data || !data.length) { return null; } for (i=0; i < order.length; i++) { switch(order[i]) { case "d": time.day = data[i+1]; break; case "m": time.month = (data[i+1]-1); break; case "y": time.year = data[i+1]; break; } } return $P.processTimeObject(time); } }; $P.Normalizer = { regexData: function () { var $R = Date.CultureInfo.regexPatterns; return utils.buildRegexData([ $R.tomorrow, $R.yesterday, [$R.past, $R.mon], [$R.past, $R.tue], [$R.past, $R.wed], [$R.past, $R.thu], [$R.past, $R.fri], [$R.past, $R.sat], [$R.past, $R.sun] ]); }, basicReplaceHash : function() { var $R = Date.CultureInfo.regexPatterns; return { "January": $R.jan.source, "February": $R.feb, "March": $R.mar, "April": $R.apr, "May": $R.may, "June": $R.jun, "July": $R.jul, "August": $R.aug, "September": $R.sep, "October": $R.oct, "November": $R.nov, "December": $R.dec, "": /\bat\b/gi, " ": /\s{2,}/, "am": $R.inTheMorning, "9am": $R.thisMorning, "pm": $R.inTheEvening, "7pm":$R.thisEvening }; }, keys : function(){ return [ utils.getDateNthString(true, false, 1), // tomorrow utils.getDateNthString(true, false, -1), // yesterday utils.getDateNthString(false, true, "monday"), //last mon utils.getDateNthString(false, true, "tuesday"), //last tues utils.getDateNthString(false, true, "wednesday"), //last wed utils.getDateNthString(false, true, "thursday"), //last thurs utils.getDateNthString(false, true, "friday"), //last fri utils.getDateNthString(false, true, "saturday"), //last sat utils.getDateNthString(false, true, "sunday") //last sun ]; }, buildRegexFunctions: function () { var $R = Date.CultureInfo.regexPatterns; var __ = Date.i18n.__; var tomorrowRE = new RegExp("(\\b\\d\\d?("+__("AM")+"|"+__("PM")+")? )("+$R.tomorrow.source.slice(1)+")", "i"); // adapted tomorrow regex for AM PM relative dates var todayRE = new RegExp($R.today.source + "(?!\\s*([+-]))\\b"); // today, but excludes the math operators (eg "today + 2h") this.replaceFuncs = [ [todayRE, function (full) { return (full.length > 1) ? Date.today().toString("d") : full; }], [tomorrowRE, function(full, m1) { var t = Date.today().addDays(1).toString("d"); return (t + " " + m1); }], [$R.amThisMorning, function(str, am){return am;}], [$R.pmThisEvening, function(str, pm){return pm;}] ]; }, buildReplaceData: function () { this.buildRegexFunctions(); this.replaceHash = utils.addToHash(this.basicReplaceHash(), this.keys(), this.regexData()); }, stringReplaceFuncs: function (s) { for (var i=0; i < this.replaceFuncs.length; i++) { s = s.replace(this.replaceFuncs[i][0], this.replaceFuncs[i][1]); } return s; }, parse: function (s) { s = this.stringReplaceFuncs(s); s = utils.multiReplace(s, this.replaceHash); try { var n = s.split(/([\s\-\.\,\/\x27]+)/); if (n.length === 3 && $P.Numeric.isNumeric(n[0]) && $P.Numeric.isNumeric(n[2]) && (n[2].length >= 4)) { // ok, so we're dealing with x/year. But that's not a full date. // This fixes wonky dateElementOrder parsing when set to dmy order. if (Date.CultureInfo.dateElementOrder[0] === "d") { s = "1/" + n[0] + "/" + n[2]; // set to 1st of month and normalize the seperator } } } catch (e) {} return s; } }; $P.Normalizer.buildReplaceData(); }()); (function () { var $P = Date.Parsing; var _ = $P.Operators = { // // Tokenizers // rtoken: function (r) { // regex token return function (s) { var mx = s.match(r); if (mx) { return ([ mx[0], s.substring(mx[0].length) ]); } else { throw new $P.Exception(s); } }; }, token: function () { // whitespace-eating token return function (s) { return _.rtoken(new RegExp("^\\s*" + s + "\\s*"))(s); }; }, stoken: function (s) { // string token return _.rtoken(new RegExp("^" + s)); }, // Atomic Operators until: function (p) { return function (s) { var qx = [], rx = null; while (s.length) { try { rx = p.call(this, s); } catch (e) { qx.push(rx[0]); s = rx[1]; continue; } break; } return [ qx, s ]; }; }, many: function (p) { return function (s) { var rx = [], r = null; while (s.length) { try { r = p.call(this, s); } catch (e) { return [ rx, s ]; } rx.push(r[0]); s = r[1]; } return [ rx, s ]; }; }, // generator operators -- see below optional: function (p) { return function (s) { var r = null; try { r = p.call(this, s); } catch (e) { return [ null, s ]; } return [ r[0], r[1] ]; }; }, not: function (p) { return function (s) { try { p.call(this, s); } catch (e) { return [null, s]; } throw new $P.Exception(s); }; }, ignore: function (p) { return p ? function (s) { var r = null; r = p.call(this, s); return [null, r[1]]; } : null; }, product: function () { var px = arguments[0], qx = Array.prototype.slice.call(arguments, 1), rx = []; for (var i = 0 ; i < px.length ; i++) { rx.push(_.each(px[i], qx)); } return rx; }, cache: function (rule) { var cache = {}, cache_length = 0, cache_keys = [], CACHE_MAX = Date.Config.CACHE_MAX || 100000, r = null; var cacheCheck = function () { if (cache_length === CACHE_MAX) { // kill several keys, don't want to have to do this all the time... for (var i=0; i < 10; i++) { var key = cache_keys.shift(); if (key) { delete cache[key]; cache_length--; } } } }; return function (s) { cacheCheck(); try { r = cache[s] = (cache[s] || rule.call(this, s)); } catch (e) { r = cache[s] = e; } cache_length++; cache_keys.push(s); if (r instanceof $P.Exception) { throw r; } else { return r; } }; }, // vector operators -- see below any: function () { var px = arguments; return function (s) { var r = null; for (var i = 0; i < px.length; i++) { if (px[i] == null) { continue; } try { r = (px[i].call(this, s)); } catch (e) { r = null; } if (r) { return r; } } throw new $P.Exception(s); }; }, each: function () { var px = arguments; return function (s) { var rx = [], r = null; for (var i = 0; i < px.length ; i++) { if (px[i] == null) { continue; } try { r = (px[i].call(this, s)); } catch (e) { throw new $P.Exception(s); } rx.push(r[0]); s = r[1]; } return [ rx, s]; }; }, all: function () { var px = arguments, _ = _; return _.each(_.optional(px)); }, // delimited operators sequence: function (px, d, c) { d = d || _.rtoken(/^\s*/); c = c || null; if (px.length === 1) { return px[0]; } return function (s) { var r = null, q = null; var rx = []; for (var i = 0; i < px.length ; i++) { try { r = px[i].call(this, s); } catch (e) { break; } rx.push(r[0]); try { q = d.call(this, r[1]); } catch (ex) { q = null; break; } s = q[1]; } if (!r) { throw new $P.Exception(s); } if (q) { throw new $P.Exception(q[1]); } if (c) { try { r = c.call(this, r[1]); } catch (ey) { throw new $P.Exception(r[1]); } } return [ rx, (r?r[1]:s) ]; }; }, // // Composite Operators // between: function (d1, p, d2) { d2 = d2 || d1; var _fn = _.each(_.ignore(d1), p, _.ignore(d2)); return function (s) { var rx = _fn.call(this, s); return [[rx[0][0], r[0][2]], rx[1]]; }; }, list: function (p, d, c) { d = d || _.rtoken(/^\s*/); c = c || null; return (p instanceof Array ? _.each(_.product(p.slice(0, -1), _.ignore(d)), p.slice(-1), _.ignore(c)) : _.each(_.many(_.each(p, _.ignore(d))), px, _.ignore(c))); }, set: function (px, d, c) { d = d || _.rtoken(/^\s*/); c = c || null; return function (s) { // r is the current match, best the current 'best' match // which means it parsed the most amount of input var r = null, p = null, q = null, rx = null, best = [[], s], last = false; // go through the rules in the given set for (var i = 0; i < px.length ; i++) { // last is a flag indicating whether this must be the last element // if there is only 1 element, then it MUST be the last one q = null; p = null; r = null; last = (px.length === 1); // first, we try simply to match the current pattern // if not, try the next pattern try { r = px[i].call(this, s); } catch (e) { continue; } // since we are matching against a set of elements, the first // thing to do is to add r[0] to matched elements rx = [[r[0]], r[1]]; // if we matched and there is still input to parse and // we don't already know this is the last element, // we're going to next check for the delimiter ... // if there's none, or if there's no input left to parse // than this must be the last element after all ... if (r[1].length > 0 && ! last) { try { q = d.call(this, r[1]); } catch (ex) { last = true; } } else { last = true; } // if we parsed the delimiter and now there's no more input, // that means we shouldn't have parsed the delimiter at all // so don't update r and mark this as the last element ... if (!last && q[1].length === 0) { last = true; } // so, if this isn't the last element, we're going to see if // we can get any more matches from the remaining (unmatched) // elements ... if (!last) { // build a list of the remaining rules we can match against, // i.e., all but the one we just matched against var qx = []; for (var j = 0; j < px.length ; j++) { if (i !== j) { qx.push(px[j]); } } // now invoke recursively set with the remaining input // note that we don't include the closing delimiter ... // we'll check for that ourselves at the end p = _.set(qx, d).call(this, q[1]); // if we got a non-empty set as a result ... // (otw rx already contains everything we want to match) if (p[0].length > 0) { // update current result, which is stored in rx ... // basically, pick up the remaining text from p[1] // and concat the result from p[0] so that we don't // get endless nesting ... rx[0] = rx[0].concat(p[0]); rx[1] = p[1]; } } // at this point, rx either contains the last matched element // or the entire matched set that starts with this element. // now we just check to see if this variation is better than // our best so far, in terms of how much of the input is parsed if (rx[1].length < best[1].length) { best = rx; } // if we've parsed all the input, then we're finished if (best[1].length === 0) { break; } } // so now we've either gone through all the patterns trying them // as the initial match; or we found one that parsed the entire // input string ... // if best has no matches, just return empty set ... if (best[0].length === 0) { return best; } // if a closing delimiter is provided, then we have to check it also if (c) { // we try this even if there is no remaining input because the pattern // may well be optional or match empty input ... try { q = c.call(this, best[1]); } catch (ey) { throw new $P.Exception(best[1]); } // it parsed ... be sure to update the best match remaining input best[1] = q[1]; } // if we're here, either there was no closing delimiter or we parsed it // so now we have the best match; just return it! return best; }; }, forward: function (gr, fname) { return function (s) { return gr[fname].call(this, s); }; }, // // Translation Operators // replace: function (rule, repl) { return function (s) { var r = rule.call(this, s); return [repl, r[1]]; }; }, process: function (rule, fn) { return function (s) { var r = rule.call(this, s); return [fn.call(this, r[0]), r[1]]; }; }, min: function (min, rule) { return function (s) { var rx = rule.call(this, s); if (rx[0].length < min) { throw new $P.Exception(s); } return rx; }; } }; // Generator Operators And Vector Operators // Generators are operators that have a signature of F(R) => R, // taking a given rule and returning another rule, such as // ignore, which parses a given rule and throws away the result. // Vector operators are those that have a signature of F(R1,R2,...) => R, // take a list of rules and returning a new rule, such as each. // Generator operators are converted (via the following _generator // function) into functions that can also take a list or array of rules // and return an array of new rules as though the function had been // called on each rule in turn (which is what actually happens). // This allows generators to be used with vector operators more easily. // Example: // each(ignore(foo, bar)) instead of each(ignore(foo), ignore(bar)) // This also turns generators into vector operators, which allows // constructs like: // not(cache(foo, bar)) var _generator = function (op) { function gen() { var args = null, rx = [], px, i; if (arguments.length > 1) { args = Array.prototype.slice.call(arguments); } else if (arguments[0] instanceof Array) { args = arguments[0]; } if (args) { px = args.shift(); if (px.length > 0) { args.unshift(px[i]); rx.push(op.apply(null, args)); args.shift(); return rx; } } else { return op.apply(null, arguments); } } return gen; }; var gx = "optional not ignore cache".split(/\s/); for (var i = 0 ; i < gx.length ; i++) { _[gx[i]] = _generator(_[gx[i]]); } var _vector = function (op) { return function () { if (arguments[0] instanceof Array) { return op.apply(null, arguments[0]); } else { return op.apply(null, arguments); } }; }; var vx = "each any all".split(/\s/); for (var j = 0 ; j < vx.length ; j++) { _[vx[j]] = _vector(_[vx[j]]); } }()); (function () { var $D = Date; var flattenAndCompact = function (ax) { var rx = []; for (var i = 0; i < ax.length; i++) { if (ax[i] instanceof Array) { rx = rx.concat(flattenAndCompact(ax[i])); } else { if (ax[i]) { rx.push(ax[i]); } } } return rx; }; var parseMeridian = function () { if (this.meridian && (this.hour || this.hour === 0)) { if (this.meridian === "a" && this.hour > 11 && Date.Config.strict24hr){ throw "Invalid hour and meridian combination"; } else if (this.meridian === "p" && this.hour < 12 && Date.Config.strict24hr){ throw "Invalid hour and meridian combination"; } else if (this.meridian === "p" && this.hour < 12) { this.hour = this.hour + 12; } else if (this.meridian === "a" && this.hour === 12) { this.hour = 0; } } }; var setDefaults = function () { var now = new Date(); if ((this.hour || this.minute) && (!this.month && !this.year && !this.day)) { this.day = now.getDate(); } if (!this.year) { this.year = now.getFullYear(); } if (!this.month && this.month !== 0) { this.month = now.getMonth(); } if (!this.day) { this.day = 1; } if (!this.hour) { this.hour = 0; } if (!this.minute) { this.minute = 0; } if (!this.second) { this.second = 0; } if (!this.millisecond) { this.millisecond = 0; } }; var finishUtils = { getToday: function () { if (this.now || "hour minute second".indexOf(this.unit) !== -1) { return new Date(); } else { return $D.today(); } }, setDaysFromWeekday: function (today, orient){ var gap; orient = orient || 1; this.unit = "day"; gap = ($D.getDayNumberFromName(this.weekday) - today.getDay()); this.days = gap ? ((gap + (orient * 7)) % 7) : (orient * 7); return this; }, setMonthsFromMonth: function (today, orient) { var gap; orient = orient || 1; this.unit = "month"; gap = (this.month - today.getMonth()); this.months = gap ? ((gap + (orient * 12)) % 12) : (orient * 12); this.month = null; return this; }, setDMYFromWeekday: function () { var d = Date[this.weekday](); this.day = d.getDate(); if (!this.month) { this.month = d.getMonth(); } this.year = d.getFullYear(); return this; }, setUnitValue: function (orient) { if (!this.value && this.operator && this.operator !== null && this[this.unit + "s"] && this[this.unit + "s"] !== null) { this[this.unit + "s"] = this[this.unit + "s"] + ((this.operator === "add") ? 1 : -1) + (this.value||0) * orient; } else if (this[this.unit + "s"] == null || this.operator != null) { if (!this.value) { this.value = 1; } this[this.unit + "s"] = this.value * orient; } }, generateDateFromWeeks: function () { var weekday = (this.weekday !== undefined) ? this.weekday : "today"; var d = Date[weekday]().addWeeks(this.weeks); if (this.now) { d.setTimeToNow(); } return d; } }; $D.Translator = { hour: function (s) { return function () { this.hour = Number(s); }; }, minute: function (s) { return function () { this.minute = Number(s); }; }, second: function (s) { return function () { this.second = Number(s); }; }, /* for ss.s format */ secondAndMillisecond: function (s) { return function () { var mx = s.match(/^([0-5][0-9])\.([0-9]{1,3})/); this.second = Number(mx[1]); this.millisecond = Number(mx[2]); }; }, meridian: function (s) { return function () { this.meridian = s.slice(0, 1).toLowerCase(); }; }, timezone: function (s) { return function () { var n = s.replace(/[^\d\+\-]/g, ""); if (n.length) { this.timezoneOffset = Number(n); } else { this.timezone = s.toLowerCase(); } }; }, day: function (x) { var s = x[0]; return function () { this.day = Number(s.match(/\d+/)[0]); if (this.day < 1) { throw "invalid day"; } }; }, month: function (s) { return function () { this.month = (s.length === 3) ? "jan feb mar apr may jun jul aug sep oct nov dec".indexOf(s)/4 : Number(s) - 1; if (this.month < 0) { throw "invalid month"; } }; }, year: function (s) { return function () { var n = Number(s); this.year = ((s.length > 2) ? n : (n + (((n + 2000) < Date.CultureInfo.twoDigitYearMax) ? 2000 : 1900))); }; }, rday: function (s) { return function () { switch (s) { case "yesterday": this.days = -1; break; case "tomorrow": this.days = 1; break; case "today": this.days = 0; break; case "now": this.days = 0; this.now = true; break; } }; }, finishExact: function (x) { var d; x = (x instanceof Array) ? x : [x]; for (var i = 0 ; i < x.length ; i++) { if (x[i]) { x[i].call(this); } } setDefaults.call(this); parseMeridian.call(this); if (this.day > $D.getDaysInMonth(this.year, this.month)) { throw new RangeError(this.day + " is not a valid value for days."); } d = new Date(this.year, this.month, this.day, this.hour, this.minute, this.second, this.millisecond); if (this.year < 100) { d.setFullYear(this.year); // means years less that 100 are process correctly. JS will parse it otherwise as 1900-1999. } if (this.timezone) { d.set({ timezone: this.timezone }); } else if (this.timezoneOffset) { d.set({ timezoneOffset: this.timezoneOffset }); } return d; }, finish: function (x) { var today, expression, orient, temp; x = (x instanceof Array) ? flattenAndCompact(x) : [ x ]; if (x.length === 0) { return null; } for (var i = 0 ; i < x.length ; i++) { if (typeof x[i] === "function") { x[i].call(this); } } if (this.now && !this.unit && !this.operator) { return new Date(); } else { today = finishUtils.getToday.call(this); } expression = !!(this.days && this.days !== null || this.orient || this.operator); orient = ((this.orient === "past" || this.operator === "subtract") ? -1 : 1); if (this.month && this.unit === "week") { this.value = this.month + 1; delete this.month; delete this.day; } if ((this.month || this.month === 0) && "year day hour minute second".indexOf(this.unit) !== -1) { if (!this.value) { this.value = this.month + 1; } this.month = null; expression = true; } if (!expression && this.weekday && !this.day && !this.days) { finishUtils.setDMYFromWeekday.call(this); } if (expression && this.weekday && this.unit !== "month" && this.unit !== "week") { finishUtils.setDaysFromWeekday.call(this, today, orient); } if (this.weekday && this.unit !== "week" && !this.day && !this.days) { temp = Date[this.weekday](); this.day = temp.getDate(); if (temp.getMonth() !== today.getMonth()) { this.month = temp.getMonth(); } } if (this.month && this.unit === "day" && this.operator) { if (!this.value) { this.value = (this.month + 1); } this.month = null; } if (this.value != null && this.month != null && this.year != null) { this.day = this.value * 1; } if (this.month && !this.day && this.value) { today.set({ day: this.value * 1 }); if (!expression) { this.day = this.value * 1; } } if (!this.month && this.value && this.unit === "month" && !this.now) { this.month = this.value; expression = true; } if (expression && (this.month || this.month === 0) && this.unit !== "year") { finishUtils.setMonthsFromMonth.call(this, today, orient); } if (!this.unit) { this.unit = "day"; } finishUtils.setUnitValue.call(this, orient); parseMeridian.call(this); if ((this.month || this.month === 0) && !this.day) { this.day = 1; } if (!this.orient && !this.operator && this.unit === "week" && this.value && !this.day && !this.month) { return Date.today().setWeek(this.value); } if (this.unit === "week" && this.weeks && !this.day && !this.month) { return finishUtils.generateDateFromWeeks.call(this); } if (expression && this.timezone && this.day && this.days) { this.day = this.days; } if (expression){ today.add(this); } else { today.set(this); } if (this.timezone) { this.timezone = this.timezone.toUpperCase(); var offset = $D.getTimezoneOffset(this.timezone); var timezone; if (today.hasDaylightSavingTime()) { // lets check that we're being sane with timezone setting timezone = $D.getTimezoneAbbreviation(offset, today.isDaylightSavingTime()); if (timezone !== this.timezone) { // bugger, we're in a place where things like EST vs EDT matters. if (today.isDaylightSavingTime()) { today.addHours(-1); } else { today.addHours(1); } } } today.setTimezoneOffset(offset); } return today; } }; }()); (function () { var $D = Date; $D.Grammar = {}; var _ = $D.Parsing.Operators, g = $D.Grammar, t = $D.Translator, _fn; // Allow rolling up into general purpose rules _fn = function () { return _.each(_.any.apply(null, arguments), _.not(g.ctoken2("timeContext"))); }; g.datePartDelimiter = _.rtoken(/^([\s\-\.\,\/\x27]+)/); g.timePartDelimiter = _.stoken(":"); g.whiteSpace = _.rtoken(/^\s*/); g.generalDelimiter = _.rtoken(/^(([\s\,]|at|@|on)+)/); var _C = {}; g.ctoken = function (keys) { var fn = _C[keys]; if (! fn) { var c = Date.CultureInfo.regexPatterns; var kx = keys.split(/\s+/), px = []; for (var i = 0; i < kx.length ; i++) { px.push(_.replace(_.rtoken(c[kx[i]]), kx[i])); } fn = _C[keys] = _.any.apply(null, px); } return fn; }; g.ctoken2 = function (key) { return _.rtoken(Date.CultureInfo.regexPatterns[key]); }; var cacheProcessRtoken = function (key, token, type, eachToken) { if (eachToken) { g[key] = _.cache(_.process(_.each(_.rtoken(token),_.optional(g.ctoken2(eachToken))), type)); } else { g[key] = _.cache(_.process(_.rtoken(token), type)); } }; var cacheProcessCtoken = function (token, type) { return _.cache(_.process(g.ctoken2(token), type)); }; var _F = {}; //function cache var _get = function (f) { _F[f] = (_F[f] || g.format(f)[0]); return _F[f]; }; g.allformats = function (fx) { var rx = []; if (fx instanceof Array) { for (var i = 0; i < fx.length; i++) { rx.push(_get(fx[i])); } } else { rx.push(_get(fx)); } return rx; }; g.formats = function (fx) { if (fx instanceof Array) { var rx = []; for (var i = 0 ; i < fx.length ; i++) { rx.push(_get(fx[i])); } return _.any.apply(null, rx); } else { return _get(fx); } }; var grammarFormats = { timeFormats: function(){ var i, RTokenKeys = [ "h", "hh", "H", "HH", "m", "mm", "s", "ss", "ss.s", "z", "zz" ], RToken = [ /^(0[0-9]|1[0-2]|[1-9])/, /^(0[0-9]|1[0-2])/, /^([0-1][0-9]|2[0-3]|[0-9])/, /^([0-1][0-9]|2[0-3])/, /^([0-5][0-9]|[0-9])/, /^[0-5][0-9]/, /^([0-5][0-9]|[0-9])/, /^[0-5][0-9]/, /^[0-5][0-9]\.[0-9]{1,3}/, /^((\+|\-)\s*\d\d\d\d)|((\+|\-)\d\d\:?\d\d)/, /^((\+|\-)\s*\d\d\d\d)|((\+|\-)\d\d\:?\d\d)/ ], tokens = [ t.hour, t.hour, t.hour, t.hour, t.minute, t.minute, t.second, t.second, t.secondAndMillisecond, t.timezone, t.timezone ]; for (i=0; i < RTokenKeys.length; i++) { cacheProcessRtoken(RTokenKeys[i], RToken[i], tokens[i]); } g.hms = _.cache(_.sequence([g.H, g.m, g.s], g.timePartDelimiter)); g.t = cacheProcessCtoken("shortMeridian", t.meridian); g.tt = cacheProcessCtoken("longMeridian", t.meridian); g.zzz = cacheProcessCtoken("timezone", t.timezone); g.timeSuffix = _.each(_.ignore(g.whiteSpace), _.set([ g.tt, g.zzz ])); g.time = _.each(_.optional(_.ignore(_.stoken("T"))), g.hms, g.timeSuffix); }, dateFormats: function () { // pre-loaded rules for different date part order preferences var _setfn = function () { return _.set(arguments, g.datePartDelimiter); }; var i, RTokenKeys = [ "d", "dd", "M", "MM", "y", "yy", "yyy", "yyyy" ], RToken = [ /^([0-2]\d|3[0-1]|\d)/, /^([0-2]\d|3[0-1])/, /^(1[0-2]|0\d|\d)/, /^(1[0-2]|0\d)/, /^(\d+)/, /^(\d\d)/, /^(\d\d?\d?\d?)/, /^(\d\d\d\d)/ ], tokens = [ t.day, t.day, t.month, t.month, t.year, t.year, t.year, t.year ], eachToken = [ "ordinalSuffix", "ordinalSuffix" ]; for (i=0; i < RTokenKeys.length; i++) { cacheProcessRtoken(RTokenKeys[i], RToken[i], tokens[i], eachToken[i]); } g.MMM = g.MMMM = _.cache(_.process(g.ctoken("jan feb mar apr may jun jul aug sep oct nov dec"), t.month)); g.ddd = g.dddd = _.cache(_.process(g.ctoken("sun mon tue wed thu fri sat"), function (s) { return function () { this.weekday = s; }; } )); g.day = _fn(g.d, g.dd); g.month = _fn(g.M, g.MMM); g.year = _fn(g.yyyy, g.yy); g.mdy = _setfn(g.ddd, g.month, g.day, g.year); g.ymd = _setfn(g.ddd, g.year, g.month, g.day); g.dmy = _setfn(g.ddd, g.day, g.month, g.year); g.date = function (s) { return ((g[Date.CultureInfo.dateElementOrder] || g.mdy).call(this, s)); }; }, relative: function () { // relative date / time expressions g.orientation = _.process(g.ctoken("past future"), function (s) { return function () { this.orient = s; }; } ); g.operator = _.process(g.ctoken("add subtract"), function (s) { return function () { this.operator = s; }; } ); g.rday = _.process(g.ctoken("yesterday tomorrow today now"), t.rday); g.unit = _.process(g.ctoken("second minute hour day week month year"), function (s) { return function () { this.unit = s; }; } ); } }; g.buildGrammarFormats = function () { // these need to be rebuilt every time the language changes. _C = {}; grammarFormats.timeFormats(); grammarFormats.dateFormats(); grammarFormats.relative(); g.value = _.process(_.rtoken(/^([-+]?\d+)?(st|nd|rd|th)?/), function (s) { return function () { this.value = s.replace(/\D/g, ""); }; } ); g.expression = _.set([g.rday, g.operator, g.value, g.unit, g.orientation, g.ddd, g.MMM ]); g.format = _.process(_.many( _.any( // translate format specifiers into grammar rules _.process( _.rtoken(/^(dd?d?d?(?!e)|MM?M?M?|yy?y?y?|hh?|HH?|mm?|ss?|tt?|zz?z?)/), function (fmt) { if (g[fmt]) { return g[fmt]; } else { throw $D.Parsing.Exception(fmt); } } ), // translate separator tokens into token rules _.process(_.rtoken(/^[^dMyhHmstz]+/), // all legal separators function (s) { return _.ignore(_.stoken(s)); } ) ) ), // construct the parser ... function (rules) { return _.process(_.each.apply(null, rules), t.finishExact); } ); // starting rule for general purpose grammar g._start = _.process(_.set([ g.date, g.time, g.expression ], g.generalDelimiter, g.whiteSpace), t.finish); }; g.buildGrammarFormats(); // parsing date format specifiers - ex: "h:m:s tt" // this little guy will generate a custom parser based // on the format string, ex: g.format("h:m:s tt") // check for these formats first g._formats = g.formats([ "\"yyyy-MM-ddTHH:mm:ssZ\"", "yyyy-MM-ddTHH:mm:ss.sz", "yyyy-MM-ddTHH:mm:ssZ", "yyyy-MM-ddTHH:mm:ssz", "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-ddTHH:mmZ", "yyyy-MM-ddTHH:mmz", "yyyy-MM-ddTHH:mm", "ddd, MMM dd, yyyy H:mm:ss tt", "ddd MMM d yyyy HH:mm:ss zzz", "MMddyyyy", "ddMMyyyy", "Mddyyyy", "ddMyyyy", "Mdyyyy", "dMyyyy", "yyyy", "Mdyy", "dMyy", "d" ]); // real starting rule: tries selected formats first, // then general purpose rule g.start = function (s) { try { var r = g._formats.call({}, s); if (r[1].length === 0) { return r; } } catch (e) {} return g._start.call({}, s); }; }()); (function () { var $D = Date; /** * @desc Converts the specified string value into its JavaScript Date equivalent using CultureInfo specific format information. * * Example

	///////////
	// Dates //
	///////////

	// 15-Oct-2004
	var d1 = Date.parse("10/15/2004");

	// 15-Oct-2004
	var d1 = Date.parse("15-Oct-2004");

	// 15-Oct-2004
	var d1 = Date.parse("2004.10.15");

	//Fri Oct 15, 2004
	var d1 = Date.parse("Fri Oct 15, 2004");

	///////////
	// Times //
	///////////

	// Today at 10 PM.
	var d1 = Date.parse("10 PM");

	// Today at 10:30 PM.
	var d1 = Date.parse("10:30 P.M.");

	// Today at 6 AM.
	var d1 = Date.parse("06am");

	/////////////////////
	// Dates and Times //
	/////////////////////

	// 8-July-2004 @ 10:30 PM
	var d1 = Date.parse("July 8th, 2004, 10:30 PM");

	// 1-July-2004 @ 10:30 PM
	var d1 = Date.parse("2004-07-01T22:30:00");

	////////////////////
	// Relative Dates //
	////////////////////

	// Returns today's date. The string "today" is culture specific.
	var d1 = Date.parse("today");

	// Returns yesterday's date. The string "yesterday" is culture specific.
	var d1 = Date.parse("yesterday");

	// Returns the date of the next thursday.
	var d1 = Date.parse("Next thursday");

	// Returns the date of the most previous monday.
	var d1 = Date.parse("last monday");

	// Returns today's day + one year.
	var d1 = Date.parse("next year");

	///////////////
	// Date Math //
	///////////////

	// Today + 2 days
	var d1 = Date.parse("t+2");

	// Today + 2 days
	var d1 = Date.parse("today + 2 days");

	// Today + 3 months
	var d1 = Date.parse("t+3m");

	// Today - 1 year
	var d1 = Date.parse("today - 1 year");

	// Today - 1 year
	var d1 = Date.parse("t-1y"); 


	/////////////////////////////
	// Partial Dates and Times //
	/////////////////////////////

	// July 15th of this year.
	var d1 = Date.parse("July 15");

	// 15th day of current day and year.
	var d1 = Date.parse("15");

	// July 1st of current year at 10pm.
	var d1 = Date.parse("7/1 10pm");
	
* * @param {String} The string value to convert into a Date object [Required] * @return {Date} A Date object or null if the string cannot be converted into a Date. */ var parseUtils = { removeOrds: function (s) { ords = s.match(/\b(\d+)(?:st|nd|rd|th)\b/); // find ordinal matches s = ((ords && ords.length === 2) ? s.replace(ords[0], ords[1]) : s); return s; }, grammarParser: function (s) { var r = null; try { r = $D.Grammar.start.call({}, s.replace(/^\s*(\S*(\s+\S+)*)\s*$/, "$1")); } catch (e) { return null; } return ((r[1].length === 0) ? r[0] : null); }, nativeFallback: function(s) { var t; try { // ok we haven't parsed it, last ditch attempt with the built-in parser. t = Date._parse(s); return (t || t === 0) ? new Date(t) : null; } catch (e) { return null; } } }; function parse (s) { var d; if (!s) { return null; } if (s instanceof Date) { return s.clone(); } if (s.length >= 4 && s.charAt(0) !== "0" && s.charAt(0) !== "+"&& s.charAt(0) !== "-") { // ie: 2004 will pass, 0800 won't. // Start with specific formats d = $D.Parsing.ISO.parse(s) || $D.Parsing.Numeric.parse(s); } if (d instanceof Date && !isNaN(d.getTime())) { return d; } else { // find ordinal dates (1st, 3rd, 8th, etc and remove them as they cause parsing issues) s = $D.Parsing.Normalizer.parse(parseUtils.removeOrds(s)); d = parseUtils.grammarParser(s); if (d !== null) { return d; } else { return parseUtils.nativeFallback(s); } } } if (!$D._parse) { $D._parse = $D.parse; } $D.parse = parse; Date.getParseFunction = function (fx) { var fns = Date.Grammar.allformats(fx); return function (s) { var r = null; for (var i = 0; i < fns.length; i++) { try { r = fns[i].call({}, s); } catch (e) { continue; } if (r[1].length === 0) { return r[0]; } } return null; }; }; /** * Converts the specified string value into its JavaScript Date equivalent using the specified format {String} or formats {Array} and the CultureInfo specific format information. * The format of the string value must match one of the supplied formats exactly. * * Example

	// 15-Oct-2004
	var d1 = Date.parseExact("10/15/2004", "M/d/yyyy");

	// 15-Oct-2004
	var d1 = Date.parse("15-Oct-2004", "M-ddd-yyyy");

	// 15-Oct-2004
	var d1 = Date.parse("2004.10.15", "yyyy.MM.dd");

	// Multiple formats
	var d1 = Date.parseExact("10/15/2004", ["M/d/yyyy", "MMMM d, yyyy"]);
	
* * @param {String} The string value to convert into a Date object [Required]. * @param {Object} The expected format {String} or an array of expected formats {Array} of the date string [Required]. * @return {Date} A Date object or null if the string cannot be converted into a Date. */ $D.parseExact = function (s, fx) { return $D.getParseFunction(fx)(s); }; }()); (function () { var $D = Date, $P = $D.prototype, // $C = $D.CultureInfo, // not used atm p = function (s, l) { if (!l) { l = 2; } return ("000" + s).slice(l * -1); }; /** * Converts a PHP format string to Java/.NET format string. * A PHP format string can be used with ._format or .format. * A Java/.NET format string can be used with .toString(). * The .parseExact function will only accept a Java/.NET format string * * Example * var f1 = "%m/%d/%y" * var f2 = Date.normalizeFormat(f1); // "MM/dd/yy" * * new Date().format(f1); // "04/13/08" * new Date()._format(f1); // "04/13/08" * new Date().toString(f2); // "04/13/08" * * var date = Date.parseExact("04/13/08", f2); // Sun Apr 13 2008 * * @param {String} A PHP format string consisting of one or more format spcifiers. * @return {String} The PHP format converted to a Java/.NET format string. */ var normalizerSubstitutions = { "d" : "dd", "%d": "dd", "D" : "ddd", "%a": "ddd", "j" : "dddd", "l" : "dddd", "%A": "dddd", "S" : "S", "F" : "MMMM", "%B": "MMMM", "m" : "MM", "%m": "MM", "M" : "MMM", "%b": "MMM", "%h": "MMM", "n" : "M", "Y" : "yyyy", "%Y": "yyyy", "y" : "yy", "%y": "yy", "g" : "h", "%I": "h", "G" : "H", "h" : "hh", "H" : "HH", "%H": "HH", "i" : "mm", "%M": "mm", "s" : "ss", "%S": "ss", "%r": "hh:mm tt", "%R": "H:mm", "%T": "H:mm:ss", "%X": "t", "%x": "d", "%e": "d", "%D": "MM/dd/yy", "%n": "\\n", "%t": "\\t", "e" : "z", "T" : "z", "%z": "z", "%Z": "z", "Z" : "ZZ", "N" : "u", "w" : "u", "%w": "u", "W" : "W", "%V": "W" }; var normalizer = { substitutes: function (m) { return normalizerSubstitutions[m]; }, interpreted: function (m, x) { var y; switch (m) { case "%u": return x.getDay() + 1; case "z": return x.getOrdinalNumber(); case "%j": return p(x.getOrdinalNumber(), 3); case "%U": var d1 = x.clone().set({month: 0, day: 1}).addDays(-1).moveToDayOfWeek(0), d2 = x.clone().addDays(1).moveToDayOfWeek(0, -1); return (d2 < d1) ? "00" : p((d2.getOrdinalNumber() - d1.getOrdinalNumber()) / 7 + 1); case "%W": return p(x.getWeek()); case "t": return $D.getDaysInMonth(x.getFullYear(), x.getMonth()); case "o": case "%G": return x.setWeek(x.getISOWeek()).toString("yyyy"); case "%g": return x._format("%G").slice(-2); case "a": case "%p": return t("tt").toLowerCase(); case "A": return t("tt").toUpperCase(); case "u": return p(x.getMilliseconds(), 3); case "I": return (x.isDaylightSavingTime()) ? 1 : 0; case "O": return x.getUTCOffset(); case "P": y = x.getUTCOffset(); return y.substring(0, y.length - 2) + ":" + y.substring(y.length - 2); case "B": var now = new Date(); return Math.floor(((now.getHours() * 3600) + (now.getMinutes() * 60) + now.getSeconds() + (now.getTimezoneOffset() + 60) * 60) / 86.4); case "c": return x.toISOString().replace(/\"/g, ""); case "U": return $D.strtotime("now"); case "%c": return t("d") + " " + t("t"); case "%C": return Math.floor(x.getFullYear() / 100 + 1); } }, shouldOverrideDefaults: function (m) { switch (m) { case "%e": return true; default: return false; } }, parse: function (m, context) { var formatString, c = context || new Date(); formatString = normalizer.substitutes(m); if (formatString) { return formatString; } formatString = normalizer.interpreted(m, c); if (formatString) { return formatString; } else { return m; } } }; $D.normalizeFormat = function (format, context) { return format.replace(/(%|\\)?.|%%/g, function(t){ return normalizer.parse(t, context); }); }; /** * Format a local Unix timestamp according to locale settings * * Example: * Date.strftime("%m/%d/%y", new Date()); // "04/13/08" * Date.strftime("c", "2008-04-13T17:52:03Z"); // "04/13/08" * * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @param {Number|String} The number representing the number of seconds that have elapsed since January 1, 1970 (local time). * @return {String} A string representation of the current Date object. */ $D.strftime = function (format, time) { var d = Date.parse(time); return d._format(format); }; /** * Parse any textual datetime description into a Unix timestamp. * A Unix timestamp is the number of seconds that have elapsed since January 1, 1970 (midnight UTC/GMT). * * Example: * Date.strtotime("04/13/08"); // 1208044800 * Date.strtotime("1970-01-01T00:00:00Z"); // 0 * * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @param {Object} A string or date object. * @return {String} A string representation of the current Date object. */ $D.strtotime = function (time) { var d = $D.parse(time); return Math.round($D.UTC(d.getUTCFullYear(), d.getUTCMonth(), d.getUTCDate(), d.getUTCHours(), d.getUTCMinutes(), d.getUTCSeconds(), d.getUTCMilliseconds()) / 1000); }; /** * Converts the value of the current Date object to its equivalent string representation using a PHP/Unix style of date format specifiers. * Format Specifiers * Format Description Example * ------ --------------------------------------------------------------------------- ----------------------- * %a abbreviated weekday name according to the current localed "Mon" through "Sun" * %A full weekday name according to the current localed "Sunday" through "Saturday" * %b abbreviated month name according to the current localed "Jan" through "Dec" * %B full month name according to the current locale "January" through "December" * %c preferred date and time representation for the current locale "4/13/2008 12:33 PM" * %C century number (the year divided by 100 and truncated to an integer) "00" to "99" * %d day of the month as a decimal number "01" to "31" * %D same as %m/%d/%y "04/13/08" * %e day of the month as a decimal number, a single digit is preceded by a space "1" to "31" * %g like %G, but without the century "08" * %G The 4-digit year corresponding to the ISO week number (see %V). "2008" * This has the same format and value as %Y, except that if the ISO week number * belongs to the previous or next year, that year is used instead. * %h same as %b "Jan" through "Dec" * %H hour as a decimal number using a 24-hour clock. "00" to "23" * %I hour as a decimal number using a 12-hour clock. "01" to "12" * %j day of the year as a decimal number. "001" to "366" * %m month as a decimal number. "01" to "12" * %M minute as a decimal number. "00" to "59" * %n newline character "\n" * %p either "am" or "pm" according to the given time value, or the "am" or "pm" * corresponding strings for the current locale. * %r time in a.m. and p.m. notation "8:44 PM" * %R time in 24 hour notation "20:44" * %S second as a decimal number "00" to "59" * %t tab character "\t" * %T current time, equal to %H:%M:%S "12:49:11" * %u weekday as a decimal number ["1", "7"], with "1" representing Monday "1" to "7" * %U week number of the current year as a decimal number, starting with the "0" to ("52" or "53") * first Sunday as the first day of the first week * %V The ISO 8601:1988 week number of the current year as a decimal number, "00" to ("52" or "53") * range 01 to 53, where week 1 is the first week that has at least 4 days * in the current year, and with Monday as the first day of the week. * (Use %G or %g for the year component that corresponds to the week number * for the specified timestamp.) * %W week number of the current year as a decimal number, starting with the "00" to ("52" or "53") * first Monday as the first day of the first week * %w day of the week as a decimal, Sunday being "0" "0" to "6" * %x preferred date representation for the current locale without the time "4/13/2008" * %X preferred time representation for the current locale without the date "12:53:05" * %y year as a decimal number without a century "00" "99" * %Y year as a decimal number including the century "2008" * %Z time zone or name or abbreviation "UTC", "EST", "PST" * %z same as %Z * %% a literal "%" characters "%" * d Day of the month, 2 digits with leading zeros "01" to "31" * D A textual representation of a day, three letters "Mon" through "Sun" * j Day of the month without leading zeros "1" to "31" * l A full textual representation of the day of the week (lowercase "L") "Sunday" through "Saturday" * N ISO-8601 numeric representation of the day of the week (added in PHP 5.1.0) "1" (for Monday) through "7" (for Sunday) * S English ordinal suffix for the day of the month, 2 characters "st", "nd", "rd" or "th". Works well with j * w Numeric representation of the day of the week "0" (for Sunday) through "6" (for Saturday) * z The day of the year (starting from "0") "0" through "365" * W ISO-8601 week number of year, weeks starting on Monday "00" to ("52" or "53") * F A full textual representation of a month, such as January or March "January" through "December" * m Numeric representation of a month, with leading zeros "01" through "12" * M A short textual representation of a month, three letters "Jan" through "Dec" * n Numeric representation of a month, without leading zeros "1" through "12" * t Number of days in the given month "28" through "31" * L Whether it's a leap year "1" if it is a leap year, "0" otherwise * o ISO-8601 year number. This has the same value as Y, except that if the "2008" * ISO week number (W) belongs to the previous or next year, that year * is used instead. * Y A full numeric representation of a year, 4 digits "2008" * y A two digit representation of a year "08" * a Lowercase Ante meridiem and Post meridiem "am" or "pm" * A Uppercase Ante meridiem and Post meridiem "AM" or "PM" * B Swatch Internet time "000" through "999" * g 12-hour format of an hour without leading zeros "1" through "12" * G 24-hour format of an hour without leading zeros "0" through "23" * h 12-hour format of an hour with leading zeros "01" through "12" * H 24-hour format of an hour with leading zeros "00" through "23" * i Minutes with leading zeros "00" to "59" * s Seconds, with leading zeros "00" through "59" * u Milliseconds "54321" * e Timezone identifier "UTC", "EST", "PST" * I Whether or not the date is in daylight saving time (uppercase i) "1" if Daylight Saving Time, "0" otherwise * O Difference to Greenwich time (GMT) in hours "+0200", "-0600" * P Difference to Greenwich time (GMT) with colon between hours and minutes "+02:00", "-06:00" * T Timezone abbreviation "UTC", "EST", "PST" * Z Timezone offset in seconds. The offset for timezones west of UTC is "-43200" through "50400" * always negative, and for those east of UTC is always positive. * c ISO 8601 date "2004-02-12T15:19:21+00:00" * r RFC 2822 formatted date "Thu, 21 Dec 2000 16:01:07 +0200" * U Seconds since the Unix Epoch (January 1 1970 00:00:00 GMT) "0" * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @return {String} A string representation of the current Date object. */ var formatReplace = function (context) { return function (m) { var formatString, override = false; if (m.charAt(0) === "\\" || m.substring(0, 2) === "%%") { return m.replace("\\", "").replace("%%", "%"); } override = normalizer.shouldOverrideDefaults(m); formatString = $D.normalizeFormat(m, context); if (formatString) { return context.toString(formatString, override); } }; }; $P._format = function (format) { var formatter = formatReplace(this); if (!format) { return this._toString(); } else { return format.replace(/(%|\\)?.|%%/g, formatter); } }; if (!$P.format) { $P.format = $P._format; } }()); (function () { "use strict"; var gFn = function (attr) { return function () { return this[attr]; }; }; var sFn = function (attr) { return function (val) { this[attr] = val; return this; }; }; var attrs = ["years", "months", "days", "hours", "minutes", "seconds", "milliseconds"]; var addSetFuncs = function (context, attrs) { for (var i = 0; i < attrs.length ; i++) { var $a = attrs[i], $b = $a.slice(0, 1).toUpperCase() + $a.slice(1); context.prototype[$a] = 0; context.prototype["get" + $b] = gFn($a); context.prototype["set" + $b] = sFn($a); } }; /** * new TimeSpan(milliseconds); * new TimeSpan(days, hours, minutes, seconds); * new TimeSpan(days, hours, minutes, seconds, milliseconds); */ var TimeSpan = function (days, hours, minutes, seconds, milliseconds) { if (arguments.length === 1 && typeof days === "number") { var orient = (days < 0) ? -1 : +1; var millsLeft = Math.abs(days); this.setDays(Math.floor(millsLeft / 86400000) * orient); millsLeft = millsLeft % 86400000; this.setHours(Math.floor(millsLeft / 3600000) * orient); millsLeft = millsLeft % 3600000; this.setMinutes(Math.floor(millsLeft / 60000) * orient); millsLeft = millsLeft % 60000; this.setSeconds(Math.floor(millsLeft / 1000) * orient); millsLeft = millsLeft % 1000; this.setMilliseconds(millsLeft * orient); } else { this.set(days, hours, minutes, seconds, milliseconds); } this.getTotalMilliseconds = function () { return (this.getDays() * 86400000) + (this.getHours() * 3600000) + (this.getMinutes() * 60000) + (this.getSeconds() * 1000); }; this.compareTo = function (time) { var t1 = new Date(1970, 1, 1, this.getHours(), this.getMinutes(), this.getSeconds()), t2; if (time === null) { t2 = new Date(1970, 1, 1, 0, 0, 0); } else { t2 = new Date(1970, 1, 1, time.getHours(), time.getMinutes(), time.getSeconds()); } return (t1 < t2) ? -1 : (t1 > t2) ? 1 : 0; }; this.equals = function (time) { return (this.compareTo(time) === 0); }; this.add = function (time) { return (time === null) ? this : this.addSeconds(time.getTotalMilliseconds() / 1000); }; this.subtract = function (time) { return (time === null) ? this : this.addSeconds(-time.getTotalMilliseconds() / 1000); }; this.addDays = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 86400000)); }; this.addHours = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 3600000)); }; this.addMinutes = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 60000)); }; this.addSeconds = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 1000)); }; this.addMilliseconds = function (n) { return new TimeSpan(this.getTotalMilliseconds() + n); }; this.get12HourHour = function () { return (this.getHours() > 12) ? this.getHours() - 12 : (this.getHours() === 0) ? 12 : this.getHours(); }; this.getDesignator = function () { return (this.getHours() < 12) ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator; }; this.toString = function (format) { this._toString = function () { if (this.getDays() !== null && this.getDays() > 0) { return this.getDays() + "." + this.getHours() + ":" + this.p(this.getMinutes()) + ":" + this.p(this.getSeconds()); } else { return this.getHours() + ":" + this.p(this.getMinutes()) + ":" + this.p(this.getSeconds()); } }; this.p = function (s) { return (s.toString().length < 2) ? "0" + s : s; }; var me = this; return format ? format.replace(/dd?|HH?|hh?|mm?|ss?|tt?/g, function (format) { switch (format) { case "d": return me.getDays(); case "dd": return me.p(me.getDays()); case "H": return me.getHours(); case "HH": return me.p(me.getHours()); case "h": return me.get12HourHour(); case "hh": return me.p(me.get12HourHour()); case "m": return me.getMinutes(); case "mm": return me.p(me.getMinutes()); case "s": return me.getSeconds(); case "ss": return me.p(me.getSeconds()); case "t": return ((me.getHours() < 12) ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator).substring(0, 1); case "tt": return (me.getHours() < 12) ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator; } } ) : this._toString(); }; return this; }; addSetFuncs(TimeSpan, attrs.slice(2)); TimeSpan.prototype.set = function (days, hours, minutes, seconds, milliseconds){ this.setDays(days || this.getDays()); this.setHours(hours || this.getHours()); this.setMinutes(minutes || this.getMinutes()); this.setSeconds(seconds || this.getSeconds()); this.setMilliseconds(milliseconds || this.getMilliseconds()); }; /** * Gets the time of day for this date instances. * @return {TimeSpan} TimeSpan */ Date.prototype.getTimeOfDay = function () { return new TimeSpan(0, this.getHours(), this.getMinutes(), this.getSeconds(), this.getMilliseconds()); }; Date.TimeSpan = TimeSpan; if (typeof window !== "undefined" ) { // keeping API compatible for v1.x window.TimeSpan = TimeSpan; } }()); (function () { "use strict"; var attrs = ["years", "months", "days", "hours", "minutes", "seconds", "milliseconds"]; var gFn = function (attr) { return function () { return this[attr]; }; }; var sFn = function (attr) { return function (val) { this[attr] = val; return this; }; }; var addSetFuncs = function (context, attrs) { for (var i = 0; i < attrs.length ; i++) { var $a = attrs[i], $b = $a.slice(0, 1).toUpperCase() + $a.slice(1); context.prototype[$a] = 0; context.prototype["get" + $b] = gFn($a); context.prototype["set" + $b] = sFn($a); } }; var setMonthsAndYears = function (orient, d1, d2, context) { function inc() { d1.addMonths(-orient); context.months++; if (context.months === 12) { context.years++; context.months = 0; } } if (orient === +1) { while (d1 > d2) { inc(); } } else { while (d1 < d2) { inc(); } } context.months--; context.months *= orient; context.years *= orient; }; var adjustForDST = function(orient, startDate, endDate) { var hasDSTMismatch = (false === (startDate.isDaylightSavingTime() === endDate.isDaylightSavingTime())); if (hasDSTMismatch && orient === 1) { startDate.addHours(-1); } else if (hasDSTMismatch) { startDate.addHours(1); } }; /** * TimePeriod(startDate, endDate); * TimePeriod(years, months, days, hours, minutes, seconds, milliseconds); */ var TimePeriod = function (years, months, days, hours, minutes, seconds, milliseconds) { if (arguments.length === 7) { this.set(years, months, days, hours, minutes, seconds, milliseconds); } else if (arguments.length === 2 && arguments[0] instanceof Date && arguments[1] instanceof Date) { var startDate = arguments[0].clone(); var endDate = arguments[1].clone(); var orient = (startDate > endDate) ? +1 : -1; this.dates = { start: arguments[0].clone(), end: arguments[1].clone() }; setMonthsAndYears(orient, startDate, endDate, this); adjustForDST(orient, startDate, endDate); // // TODO - adjust for DST var diff = endDate - startDate; if (diff !== 0) { var ts = new TimeSpan(diff); this.set(this.years, this.months, ts.getDays(), ts.getHours(), ts.getMinutes(), ts.getSeconds(), ts.getMilliseconds()); } } return this; }; // create all the set functions. addSetFuncs(TimePeriod, attrs); TimePeriod.prototype.set = function (years, months, days, hours, minutes, seconds, milliseconds){ this.setYears(years || this.getYears()); this.setMonths(months || this.getMonths()); this.setDays(days || this.getDays()); this.setHours(hours || this.getHours()); this.setMinutes(minutes || this.getMinutes()); this.setSeconds(seconds || this.getSeconds()); this.setMilliseconds(milliseconds || this.getMilliseconds()); }; Date.TimePeriod = TimePeriod; if (typeof window !== "undefined") { // keeping API compatible for v1.x window.TimePeriod = TimePeriod; } }()); ================================================ FILE: build/date-mk-MK.js ================================================ /** * @overview datejs * @version 1.0.0-rc3 * @author Gregory Wild-Smith * @copyright 2015 Gregory Wild-Smith * @license MIT * @homepage https://github.com/abritinthebay/datejs */ /* * DateJS Culture String File * Country Code: mk-MK * Name: Macedonian (Former Yugoslav Republic of Macedonia) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["mk-MK"] = { "name": "mk-MK", "englishName": "Macedonian (Former Yugoslav Republic of Macedonia)", "nativeName": "македонски јазик (Македонија)", "Sunday": "недела", "Monday": "понеделник", "Tuesday": "вторник", "Wednesday": "среда", "Thursday": "четврток", "Friday": "петок", "Saturday": "сабота", "Sun": "нед", "Mon": "пон", "Tue": "втр", "Wed": "срд", "Thu": "чет", "Fri": "пет", "Sat": "саб", "Su": "не", "Mo": "по", "Tu": "вт", "We": "ср", "Th": "че", "Fr": "пе", "Sa": "са", "S_Sun_Initial": "н", "M_Mon_Initial": "п", "T_Tue_Initial": "в", "W_Wed_Initial": "с", "T_Thu_Initial": "ч", "F_Fri_Initial": "п", "S_Sat_Initial": "с", "January": "јануари", "February": "февруари", "March": "март", "April": "април", "May": "мај", "June": "јуни", "July": "јули", "August": "август", "September": "септември", "October": "октомври", "November": "ноември", "December": "декември", "Jan_Abbr": "јан", "Feb_Abbr": "фев", "Mar_Abbr": "мар", "Apr_Abbr": "апр", "May_Abbr": "мај", "Jun_Abbr": "јун", "Jul_Abbr": "јул", "Aug_Abbr": "авг", "Sep_Abbr": "сеп", "Oct_Abbr": "окт", "Nov_Abbr": "ное", "Dec_Abbr": "дек", "AM": "", "PM": "", "firstDayOfWeek": 1, "twoDigitYearMax": 2029, "mdy": "dmy", "M/d/yyyy": "dd.MM.yyyy", "dddd, MMMM dd, yyyy": "dddd, dd MMMM yyyy", "h:mm tt": "HH:mm", "h:mm:ss tt": "HH:mm:ss", "dddd, MMMM dd, yyyy h:mm:ss tt": "dddd, dd MMMM yyyy HH:mm:ss", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "dd MMMM", "MMMM, yyyy": "MMMM yyyy", "/jan(uary)?/": "јан(уари)?", "/feb(ruary)?/": "фев(руари)?", "/mar(ch)?/": "мар(т)?", "/apr(il)?/": "апр(ил)?", "/may/": "мај", "/jun(e)?/": "јун(и)?", "/jul(y)?/": "јул(и)?", "/aug(ust)?/": "авг(уст)?", "/sep(t(ember)?)?/": "сеп(тември)?", "/oct(ober)?/": "окт(омври)?", "/nov(ember)?/": "ное(мври)?", "/dec(ember)?/": "дек(ември)?", "/^su(n(day)?)?/": "^не(д(ела)?)?", "/^mo(n(day)?)?/": "^по(н(еделник)?)?", "/^tu(e(s(day)?)?)?/": "^вт(р(рник)?)?", "/^we(d(nesday)?)?/": "^ср(д(да)?)?", "/^th(u(r(s(day)?)?)?)?/": "^че(т(врток)?)?", "/^fr(i(day)?)?/": "^пе(т(ок)?)?", "/^sa(t(urday)?)?/": "^са(б(ота)?)?", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "mk-MK"; /** * @overview datejs * @version 1.0.0-rc3 * @author Gregory Wild-Smith * @copyright 2015 Gregory Wild-Smith * @license MIT * @homepage https://github.com/abritinthebay/datejs */(function () { var $D = Date; var lang = Date.CultureStrings ? Date.CultureStrings.lang : null; var loggedKeys = {}; // for debug purposes. var getText = { getFromKey: function (key, countryCode) { var output; if (Date.CultureStrings && Date.CultureStrings[countryCode] && Date.CultureStrings[countryCode][key]) { output = Date.CultureStrings[countryCode][key]; } else { output = getText.buildFromDefault(key); } if (key.charAt(0) === "/") { // Assume it's a regex output = getText.buildFromRegex(key, countryCode); } return output; }, getFromObjectValues: function (obj, countryCode) { var key, output = {}; for(key in obj) { if (obj.hasOwnProperty(key)) { output[key] = getText.getFromKey(obj[key], countryCode); } } return output; }, getFromObjectKeys: function (obj, countryCode) { var key, output = {}; for(key in obj) { if (obj.hasOwnProperty(key)) { output[getText.getFromKey(key, countryCode)] = obj[key]; } } return output; }, getFromArray: function (arr, countryCode) { var output = []; for (var i=0; i < arr.length; i++){ if (i in arr) { output[i] = getText.getFromKey(arr[i], countryCode); } } return output; }, buildFromDefault: function (key) { var output, length, split, last; switch(key) { case "name": output = "en-US"; break; case "englishName": output = "English (United States)"; break; case "nativeName": output = "English (United States)"; break; case "twoDigitYearMax": output = 2049; break; case "firstDayOfWeek": output = 0; break; default: output = key; split = key.split("_"); length = split.length; if (length > 1 && key.charAt(0) !== "/") { // if the key isn't a regex and it has a split. last = split[(length - 1)].toLowerCase(); if (last === "initial" || last === "abbr") { output = split[0]; } } break; } return output; }, buildFromRegex: function (key, countryCode) { var output; if (Date.CultureStrings && Date.CultureStrings[countryCode] && Date.CultureStrings[countryCode][key]) { output = new RegExp(Date.CultureStrings[countryCode][key], "i"); } else { output = new RegExp(key.replace(new RegExp("/", "g"),""), "i"); } return output; } }; var shallowMerge = function (obj1, obj2) { for (var attrname in obj2) { if (obj2.hasOwnProperty(attrname)) { obj1[attrname] = obj2[attrname]; } } }; var __ = function (key, language) { var countryCode = (language) ? language : lang; loggedKeys[key] = key; if (typeof key === "object") { if (key instanceof Array) { return getText.getFromArray(key, countryCode); } else { return getText.getFromObjectKeys(key, countryCode); } } else { return getText.getFromKey(key, countryCode); } }; var loadI18nScript = function (code) { // paatterned after jQuery's getScript. var url = Date.Config.i18n + code + ".js"; var head = document.getElementsByTagName("head")[0] || document.documentElement; var script = document.createElement("script"); script.src = url; var completed = false; var events = { done: function (){} // placeholder function }; // Attach handlers for all browsers script.onload = script.onreadystatechange = function() { if ( !completed && (!this.readyState || this.readyState === "loaded" || this.readyState === "complete") ) { events.done(); head.removeChild(script); } }; setTimeout(function() { head.insertBefore(script, head.firstChild); }, 0); // allows return to execute first return { done: function (cb) { events.done = function() { if (cb) { setTimeout(cb,0); } }; } }; }; var buildInfo = { buildFromMethodHash: function (obj) { var key; for(key in obj) { if (obj.hasOwnProperty(key)) { obj[key] = buildInfo[obj[key]](); } } return obj; }, timeZoneDST: function () { var DST = { "CHADT": "+1345", "NZDT": "+1300", "AEDT": "+1100", "ACDT": "+1030", "AZST": "+0500", "IRDT": "+0430", "EEST": "+0300", "CEST": "+0200", "BST": "+0100", "PMDT": "-0200", "ADT": "-0300", "NDT": "-0230", "EDT": "-0400", "CDT": "-0500", "MDT": "-0600", "PDT": "-0700", "AKDT": "-0800", "HADT": "-0900" }; return __(DST); }, timeZoneStandard: function () { var standard = { "LINT": "+1400", "TOT": "+1300", "CHAST": "+1245", "NZST": "+1200", "NFT": "+1130", "SBT": "+1100", "AEST": "+1000", "ACST": "+0930", "JST": "+0900", "CWST": "+0845", "CT": "+0800", "ICT": "+0700", "MMT": "+0630", "BST": "+0600", "NPT": "+0545", "IST": "+0530", "PKT": "+0500", "AFT": "+0430", "MSK": "+0400", "IRST": "+0330", "FET": "+0300", "EET": "+0200", "CET": "+0100", "GMT": "+0000", "UTC": "+0000", "CVT": "-0100", "GST": "-0200", "BRT": "-0300", "NST": "-0330", "AST": "-0400", "EST": "-0500", "CST": "-0600", "MST": "-0700", "PST": "-0800", "AKST": "-0900", "MIT": "-0930", "HST": "-1000", "SST": "-1100", "BIT": "-1200" }; return __(standard); }, timeZones: function (data) { var zone; data.timezones = []; for (zone in data.abbreviatedTimeZoneStandard) { if (data.abbreviatedTimeZoneStandard.hasOwnProperty(zone)) { data.timezones.push({ name: zone, offset: data.abbreviatedTimeZoneStandard[zone]}); } } for (zone in data.abbreviatedTimeZoneDST) { if (data.abbreviatedTimeZoneDST.hasOwnProperty(zone)) { data.timezones.push({ name: zone, offset: data.abbreviatedTimeZoneDST[zone], dst: true}); } } return data.timezones; }, days: function () { return __(["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"]); }, dayAbbr: function () { return __(["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"]); }, dayShortNames: function () { return __(["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"]); }, dayFirstLetters: function () { return __(["S_Sun_Initial", "M_Mon_Initial", "T_Tues_Initial", "W_Wed_Initial", "T_Thu_Initial", "F_Fri_Initial", "S_Sat_Initial"]); }, months: function () { return __(["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"]); }, monthAbbr: function () { return __(["Jan_Abbr", "Feb_Abbr", "Mar_Abbr", "Apr_Abbr", "May_Abbr", "Jun_Abbr", "Jul_Abbr", "Aug_Abbr", "Sep_Abbr", "Oct_Abbr", "Nov_Abbr", "Dec_Abbr"]); }, formatPatterns: function () { return getText.getFromObjectValues({ shortDate: "M/d/yyyy", longDate: "dddd, MMMM dd, yyyy", shortTime: "h:mm tt", longTime: "h:mm:ss tt", fullDateTime: "dddd, MMMM dd, yyyy h:mm:ss tt", sortableDateTime: "yyyy-MM-ddTHH:mm:ss", universalSortableDateTime: "yyyy-MM-dd HH:mm:ssZ", rfc1123: "ddd, dd MMM yyyy HH:mm:ss", monthDay: "MMMM dd", yearMonth: "MMMM, yyyy" }, Date.i18n.currentLanguage()); }, regex: function () { return getText.getFromObjectValues({ inTheMorning: "/( in the )(morn(ing)?)\\b/", thisMorning: "/(this )(morn(ing)?)\\b/", amThisMorning: "/(\b\\d(am)? )(this )(morn(ing)?)/", inTheEvening: "/( in the )(even(ing)?)\\b/", thisEvening: "/(this )(even(ing)?)\\b/", pmThisEvening: "/(\b\\d(pm)? )(this )(even(ing)?)/", jan: "/jan(uary)?/", feb: "/feb(ruary)?/", mar: "/mar(ch)?/", apr: "/apr(il)?/", may: "/may/", jun: "/jun(e)?/", jul: "/jul(y)?/", aug: "/aug(ust)?/", sep: "/sep(t(ember)?)?/", oct: "/oct(ober)?/", nov: "/nov(ember)?/", dec: "/dec(ember)?/", sun: "/^su(n(day)?)?/", mon: "/^mo(n(day)?)?/", tue: "/^tu(e(s(day)?)?)?/", wed: "/^we(d(nesday)?)?/", thu: "/^th(u(r(s(day)?)?)?)?/", fri: "/fr(i(day)?)?/", sat: "/^sa(t(urday)?)?/", future: "/^next/", past: "/^last|past|prev(ious)?/", add: "/^(\\+|aft(er)?|from|hence)/", subtract: "/^(\\-|bef(ore)?|ago)/", yesterday: "/^yes(terday)?/", today: "/^t(od(ay)?)?/", tomorrow: "/^tom(orrow)?/", now: "/^n(ow)?/", millisecond: "/^ms|milli(second)?s?/", second: "/^sec(ond)?s?/", minute: "/^mn|min(ute)?s?/", hour: "/^h(our)?s?/", week: "/^w(eek)?s?/", month: "/^m(onth)?s?/", day: "/^d(ay)?s?/", year: "/^y(ear)?s?/", shortMeridian: "/^(a|p)/", longMeridian: "/^(a\\.?m?\\.?|p\\.?m?\\.?)/", timezone: "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/", ordinalSuffix: "/^\\s*(st|nd|rd|th)/", timeContext: "/^\\s*(\\:|a(?!u|p)|p)/" }, Date.i18n.currentLanguage()); } }; var CultureInfo = function () { var info = getText.getFromObjectValues({ name: "name", englishName: "englishName", nativeName: "nativeName", amDesignator: "AM", pmDesignator: "PM", firstDayOfWeek: "firstDayOfWeek", twoDigitYearMax: "twoDigitYearMax", dateElementOrder: "mdy" }, Date.i18n.currentLanguage()); var constructedInfo = buildInfo.buildFromMethodHash({ dayNames: "days", abbreviatedDayNames: "dayAbbr", shortestDayNames: "dayShortNames", firstLetterDayNames: "dayFirstLetters", monthNames: "months", abbreviatedMonthNames: "monthAbbr", formatPatterns: "formatPatterns", regexPatterns: "regex", abbreviatedTimeZoneDST: "timeZoneDST", abbreviatedTimeZoneStandard: "timeZoneStandard" }); shallowMerge(info, constructedInfo); buildInfo.timeZones(info); return info; }; $D.i18n = { __: function (key, lang) { return __(key, lang); }, currentLanguage: function () { return lang || "en-US"; }, setLanguage: function (code, force, cb) { var async = false; if (force || code === "en-US" || (!!Date.CultureStrings && !!Date.CultureStrings[code])) { lang = code; Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings.lang = code; Date.CultureInfo = new CultureInfo(); } else { if (!(!!Date.CultureStrings && !!Date.CultureStrings[code])) { if (typeof exports !== "undefined" && this.exports !== exports) { // we're in a Node enviroment, load it using require try { require("../i18n/" + code + ".js"); lang = code; Date.CultureStrings.lang = code; Date.CultureInfo = new CultureInfo(); } catch (e) { // var str = "The language for '" + code + "' could not be loaded by Node. It likely does not exist."; throw new Error("The DateJS IETF language tag '" + code + "' could not be loaded by Node. It likely does not exist."); } } else if (Date.Config && Date.Config.i18n) { // we know the location of the files, so lets load them async = true; loadI18nScript(code).done(function(){ lang = code; Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings.lang = code; Date.CultureInfo = new CultureInfo(); $D.Parsing.Normalizer.buildReplaceData(); // because this is async if ($D.Grammar) { $D.Grammar.buildGrammarFormats(); // so we can parse those strings... } if (cb) { setTimeout(cb,0); } }); } else { Date.console.error("The DateJS IETF language tag '" + code + "' is not available and has not been loaded."); return false; } } } $D.Parsing.Normalizer.buildReplaceData(); // rebuild normalizer strings if ($D.Grammar) { $D.Grammar.buildGrammarFormats(); // so we can parse those strings... } if (!async && cb) { setTimeout(cb,0); } }, getLoggedKeys: function () { return loggedKeys; }, updateCultureInfo: function () { Date.CultureInfo = new CultureInfo(); } }; $D.i18n.updateCultureInfo(); // run automatically }()); (function () { var $D = Date, $P = $D.prototype, p = function (s, l) { if (!l) { l = 2; } return ("000" + s).slice(l * -1); }; if (typeof window !== "undefined" && typeof window.console !== "undefined" && typeof window.console.log !== "undefined") { $D.console = console; // used only to raise non-critical errors if available } else { // set mock so we don't give errors. $D.console = { log: function(){}, error: function(){} }; } $D.Config = $D.Config || {}; $D.initOverloads = function() { /** * Overload of Date.now. Allows an alternate call for Date.now where it returns the * current Date as an object rather than just milliseconds since the Unix Epoch. * * Also provides an implementation of now() for browsers (IE<9) that don't have it. * * Backwards compatible so with work with either: * Date.now() [returns ms] * or * Date.now(true) [returns Date] */ if (!$D.now) { $D._now = function now() { return new Date().getTime(); }; } else if (!$D._now) { $D._now = $D.now; } $D.now = function (returnObj) { if (returnObj) { return $D.present(); } else { return $D._now(); } }; if ( !$P.toISOString ) { $P.toISOString = function() { return this.getUTCFullYear() + "-" + p(this.getUTCMonth() + 1) + "-" + p(this.getUTCDate()) + "T" + p(this.getUTCHours()) + ":" + p(this.getUTCMinutes()) + ":" + p(this.getUTCSeconds()) + "." + String( (this.getUTCMilliseconds()/1000).toFixed(3)).slice(2, 5) + "Z"; }; } // private if ( $P._toString === undefined ){ $P._toString = $P.toString; } }; $D.initOverloads(); /** * Gets a date that is set to the current date. The time is set to the start of the day (00:00 or 12:00 AM). * @return {Date} The current date. */ $D.today = function () { return new Date().clearTime(); }; /** * Gets a date that is set to the current date and time (same as new Date, but chainable) * @return {Date} The current date. */ $D.present = function () { return new Date(); }; /** * Compares the first date to the second date and returns an number indication of their relative values. * @param {Date} First Date object to compare [Required]. * @param {Date} Second Date object to compare to [Required]. * @return {Number} -1 = date1 is lessthan date2. 0 = values are equal. 1 = date1 is greaterthan date2. */ $D.compare = function (date1, date2) { if (isNaN(date1) || isNaN(date2)) { throw new Error(date1 + " - " + date2); } else if (date1 instanceof Date && date2 instanceof Date) { return (date1 < date2) ? -1 : (date1 > date2) ? 1 : 0; } else { throw new TypeError(date1 + " - " + date2); } }; /** * Compares the first Date object to the second Date object and returns true if they are equal. * @param {Date} First Date object to compare [Required] * @param {Date} Second Date object to compare to [Required] * @return {Boolean} true if dates are equal. false if they are not equal. */ $D.equals = function (date1, date2) { return (date1.compareTo(date2) === 0); }; /** * Gets the language appropriate day name when given the day number(0-6) * eg - 0 == Sunday * @return {String} The day name */ $D.getDayName = function (n) { return Date.CultureInfo.dayNames[n]; }; /** * Gets the day number (0-6) if given a CultureInfo specific string which is a valid dayName, abbreviatedDayName or shortestDayName (two char). * @param {String} The name of the day (eg. "Monday, "Mon", "tuesday", "tue", "We", "we"). * @return {Number} The day number */ $D.getDayNumberFromName = function (name) { var n = Date.CultureInfo.dayNames, m = Date.CultureInfo.abbreviatedDayNames, o = Date.CultureInfo.shortestDayNames, s = name.toLowerCase(); for (var i = 0; i < n.length; i++) { if (n[i].toLowerCase() === s || m[i].toLowerCase() === s || o[i].toLowerCase() === s) { return i; } } return -1; }; /** * Gets the month number (0-11) if given a Culture Info specific string which is a valid monthName or abbreviatedMonthName. * @param {String} The name of the month (eg. "February, "Feb", "october", "oct"). * @return {Number} The day number */ $D.getMonthNumberFromName = function (name) { var n = Date.CultureInfo.monthNames, m = Date.CultureInfo.abbreviatedMonthNames, s = name.toLowerCase(); for (var i = 0; i < n.length; i++) { if (n[i].toLowerCase() === s || m[i].toLowerCase() === s) { return i; } } return -1; }; /** * Gets the language appropriate month name when given the month number(0-11) * eg - 0 == January * @return {String} The month name */ $D.getMonthName = function (n) { return Date.CultureInfo.monthNames[n]; }; /** * Determines if the current date instance is within a LeapYear. * @param {Number} The year. * @return {Boolean} true if date is within a LeapYear, otherwise false. */ $D.isLeapYear = function (year) { return ((year % 4 === 0 && year % 100 !== 0) || year % 400 === 0); }; /** * Gets the number of days in the month, given a year and month value. Automatically corrects for LeapYear. * @param {Number} The year. * @param {Number} The month (0-11). * @return {Number} The number of days in the month. */ $D.getDaysInMonth = function (year, month) { if (!month && $D.validateMonth(year)) { month = year; year = Date.today().getFullYear(); } return [31, ($D.isLeapYear(year) ? 29 : 28), 31, 30, 31, 30, 31, 31, 30, 31, 30, 31][month]; }; $P.getDaysInMonth = function () { return $D.getDaysInMonth(this.getFullYear(), this.getMonth()); }; $D.getTimezoneAbbreviation = function (offset, dst) { var p, n = (dst || false) ? Date.CultureInfo.abbreviatedTimeZoneDST : Date.CultureInfo.abbreviatedTimeZoneStandard; for (p in n) { if (n.hasOwnProperty(p)) { if (n[p] === offset) { return p; } } } return null; }; $D.getTimezoneOffset = function (name, dst) { var i, a =[], z = Date.CultureInfo.timezones; if (!name) { name = (new Date()).getTimezone();} for (i = 0; i < z.length; i++) { if (z[i].name === name.toUpperCase()) { a.push(i); } } if (!z[a[0]]) { return null; } if (a.length === 1 || !dst) { return z[a[0]].offset; } else { for (i=0; i < a.length; i++) { if (z[a[i]].dst) { return z[a[i]].offset; } } } }; $D.getQuarter = function (d) { d = d || new Date(); // If no date supplied, use today var q = [1,2,3,4]; return q[Math.floor(d.getMonth() / 3)]; // ~~~ is a bitwise op. Faster than Math.floor }; $D.getDaysLeftInQuarter = function (d) { d = d || new Date(); var qEnd = new Date(d); qEnd.setMonth(qEnd.getMonth() + 3 - qEnd.getMonth() % 3, 0); return Math.floor((qEnd - d) / 8.64e7); }; // private var validate = function (n, min, max, name) { name = name ? name : "Object"; if (typeof n === "undefined") { return false; } else if (typeof n !== "number") { throw new TypeError(n + " is not a Number."); } else if (n < min || n > max) { // As failing validation is *not* an exceptional circumstance // lets not throw a RangeError Exception here. // It's semantically correct but it's not sensible. return false; } return true; }; /** * Validates the number is within an acceptable range for milliseconds [0-999]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateMillisecond = function (value) { return validate(value, 0, 999, "millisecond"); }; /** * Validates the number is within an acceptable range for seconds [0-59]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateSecond = function (value) { return validate(value, 0, 59, "second"); }; /** * Validates the number is within an acceptable range for minutes [0-59]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateMinute = function (value) { return validate(value, 0, 59, "minute"); }; /** * Validates the number is within an acceptable range for hours [0-23]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateHour = function (value) { return validate(value, 0, 23, "hour"); }; /** * Validates the number is within an acceptable range for the days in a month [0-MaxDaysInMonth]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateDay = function (value, year, month) { if (year === undefined || year === null || month === undefined || month === null) { return false;} return validate(value, 1, $D.getDaysInMonth(year, month), "day"); }; /** * Validates the number is within an acceptable range for months [0-11]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateWeek = function (value) { return validate(value, 0, 53, "week"); }; /** * Validates the number is within an acceptable range for months [0-11]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateMonth = function (value) { return validate(value, 0, 11, "month"); }; /** * Validates the number is within an acceptable range for years. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateYear = function (value) { /** * Per ECMAScript spec the range of times supported by Date objects is * exactly -100,000,000 days to +100,000,000 days measured relative to * midnight at the beginning of 01 January, 1970 UTC. * This gives a range of 8,640,000,000,000,000 milliseconds to either * side of 01 January, 1970 UTC. * * Earliest possible date: Tue, 20 Apr 271,822 B.C. 00:00:00 UTC * Latest possible date: Sat, 13 Sep 275,760 00:00:00 UTC */ return validate(value, -271822, 275760, "year"); }; $D.validateTimezone = function(value) { var timezones = {"ACDT":1,"ACST":1,"ACT":1,"ADT":1,"AEDT":1,"AEST":1,"AFT":1,"AKDT":1,"AKST":1,"AMST":1,"AMT":1,"ART":1,"AST":1,"AWDT":1,"AWST":1,"AZOST":1,"AZT":1,"BDT":1,"BIOT":1,"BIT":1,"BOT":1,"BRT":1,"BST":1,"BTT":1,"CAT":1,"CCT":1,"CDT":1,"CEDT":1,"CEST":1,"CET":1,"CHADT":1,"CHAST":1,"CHOT":1,"ChST":1,"CHUT":1,"CIST":1,"CIT":1,"CKT":1,"CLST":1,"CLT":1,"COST":1,"COT":1,"CST":1,"CT":1,"CVT":1,"CWST":1,"CXT":1,"DAVT":1,"DDUT":1,"DFT":1,"EASST":1,"EAST":1,"EAT":1,"ECT":1,"EDT":1,"EEDT":1,"EEST":1,"EET":1,"EGST":1,"EGT":1,"EIT":1,"EST":1,"FET":1,"FJT":1,"FKST":1,"FKT":1,"FNT":1,"GALT":1,"GAMT":1,"GET":1,"GFT":1,"GILT":1,"GIT":1,"GMT":1,"GST":1,"GYT":1,"HADT":1,"HAEC":1,"HAST":1,"HKT":1,"HMT":1,"HOVT":1,"HST":1,"ICT":1,"IDT":1,"IOT":1,"IRDT":1,"IRKT":1,"IRST":1,"IST":1,"JST":1,"KGT":1,"KOST":1,"KRAT":1,"KST":1,"LHST":1,"LINT":1,"MAGT":1,"MART":1,"MAWT":1,"MDT":1,"MET":1,"MEST":1,"MHT":1,"MIST":1,"MIT":1,"MMT":1,"MSK":1,"MST":1,"MUT":1,"MVT":1,"MYT":1,"NCT":1,"NDT":1,"NFT":1,"NPT":1,"NST":1,"NT":1,"NUT":1,"NZDT":1,"NZST":1,"OMST":1,"ORAT":1,"PDT":1,"PET":1,"PETT":1,"PGT":1,"PHOT":1,"PHT":1,"PKT":1,"PMDT":1,"PMST":1,"PONT":1,"PST":1,"PYST":1,"PYT":1,"RET":1,"ROTT":1,"SAKT":1,"SAMT":1,"SAST":1,"SBT":1,"SCT":1,"SGT":1,"SLST":1,"SRT":1,"SST":1,"SYOT":1,"TAHT":1,"THA":1,"TFT":1,"TJT":1,"TKT":1,"TLT":1,"TMT":1,"TOT":1,"TVT":1,"UCT":1,"ULAT":1,"UTC":1,"UYST":1,"UYT":1,"UZT":1,"VET":1,"VLAT":1,"VOLT":1,"VOST":1,"VUT":1,"WAKT":1,"WAST":1,"WAT":1,"WEDT":1,"WEST":1,"WET":1,"WST":1,"YAKT":1,"YEKT":1,"Z":1}; return (timezones[value] === 1); }; $D.validateTimezoneOffset= function(value) { // timezones go from +14hrs to -12hrs, the +X hours are negative offsets. return (value > -841 && value < 721); }; }()); (function () { var $D = Date, $P = $D.prototype, p = function (s, l) { if (!l) { l = 2; } return ("000" + s).slice(l * -1); }; var validateConfigObject = function (obj) { var result = {}, self = this, prop, testFunc; testFunc = function (prop, func, value) { if (prop === "day") { var month = (obj.month !== undefined) ? obj.month : self.getMonth(); var year = (obj.year !== undefined) ? obj.year : self.getFullYear(); return $D[func](value, year, month); } else { return $D[func](value); } }; for (prop in obj) { if (Object.prototype.hasOwnProperty.call(obj, prop)) { var func = "validate" + prop.charAt(0).toUpperCase() + prop.slice(1); if ($D[func] && obj[prop] !== null && testFunc(prop, func, obj[prop])) { result[prop] = obj[prop]; } } } return result; }; /** * Resets the time of this Date object to 12:00 AM (00:00), which is the start of the day. * @param {Boolean} .clone() this date instance before clearing Time * @return {Date} this */ $P.clearTime = function () { this.setHours(0); this.setMinutes(0); this.setSeconds(0); this.setMilliseconds(0); return this; }; /** * Resets the time of this Date object to the current time ('now'). * @return {Date} this */ $P.setTimeToNow = function () { var n = new Date(); this.setHours(n.getHours()); this.setMinutes(n.getMinutes()); this.setSeconds(n.getSeconds()); this.setMilliseconds(n.getMilliseconds()); return this; }; /** * Returns a new Date object that is an exact date and time copy of the original instance. * @return {Date} A new Date instance */ $P.clone = function () { return new Date(this.getTime()); }; /** * Compares this instance to a Date object and returns an number indication of their relative values. * @param {Date} Date object to compare [Required] * @return {Number} -1 = this is lessthan date. 0 = values are equal. 1 = this is greaterthan date. */ $P.compareTo = function (date) { return Date.compare(this, date); }; /** * Compares this instance to another Date object and returns true if they are equal. * @param {Date} Date object to compare. If no date to compare, new Date() [now] is used. * @return {Boolean} true if dates are equal. false if they are not equal. */ $P.equals = function (date) { return Date.equals(this, (date !== undefined ? date : new Date())); }; /** * Determines if this instance is between a range of two dates or equal to either the start or end dates. * @param {Date} Start of range [Required] * @param {Date} End of range [Required] * @return {Boolean} true is this is between or equal to the start and end dates, else false */ $P.between = function (start, end) { return this.getTime() >= start.getTime() && this.getTime() <= end.getTime(); }; /** * Determines if this date occurs after the date to compare to. * @param {Date} Date object to compare. If no date to compare, new Date() ("now") is used. * @return {Boolean} true if this date instance is greater than the date to compare to (or "now"), otherwise false. */ $P.isAfter = function (date) { return this.compareTo(date || new Date()) === 1; }; /** * Determines if this date occurs before the date to compare to. * @param {Date} Date object to compare. If no date to compare, new Date() ("now") is used. * @return {Boolean} true if this date instance is less than the date to compare to (or "now"). */ $P.isBefore = function (date) { return (this.compareTo(date || new Date()) === -1); }; /** * Determines if the current Date instance occurs today. * @return {Boolean} true if this date instance is 'today', otherwise false. */ /** * Determines if the current Date instance occurs on the same Date as the supplied 'date'. * If no 'date' to compare to is provided, the current Date instance is compared to 'today'. * @param {date} Date object to compare. If no date to compare, the current Date ("now") is used. * @return {Boolean} true if this Date instance occurs on the same Day as the supplied 'date'. */ $P.isToday = $P.isSameDay = function (date) { return this.clone().clearTime().equals((date || new Date()).clone().clearTime()); }; /** * Adds the specified number of milliseconds to this instance. * @param {Number} The number of milliseconds to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addMilliseconds = function (value) { if (!value) { return this; } this.setTime(this.getTime() + value * 1); return this; }; /** * Adds the specified number of seconds to this instance. * @param {Number} The number of seconds to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addSeconds = function (value) { if (!value) { return this; } return this.addMilliseconds(value * 1000); }; /** * Adds the specified number of seconds to this instance. * @param {Number} The number of seconds to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addMinutes = function (value) { if (!value) { return this; } return this.addMilliseconds(value * 60000); // 60*1000 }; /** * Adds the specified number of hours to this instance. * @param {Number} The number of hours to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addHours = function (value) { if (!value) { return this; } return this.addMilliseconds(value * 3600000); // 60*60*1000 }; /** * Adds the specified number of days to this instance. * @param {Number} The number of days to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addDays = function (value) { if (!value) { return this; } this.setDate(this.getDate() + value * 1); return this; }; /** * Adds the specified number of weekdays (ie - not sat or sun) to this instance. * @param {Number} The number of days to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addWeekdays = function (value) { if (!value) { return this; } var day = this.getDay(); var weeks = (Math.ceil(Math.abs(value)/7)); if (day === 0 || day === 6) { if (value > 0) { this.next().monday(); this.addDays(-1); day = this.getDay(); } } if (value < 0) { while (value < 0) { this.addDays(-1); day = this.getDay(); if (day !== 0 && day !== 6) { value++; } } return this; } else if (value > 5 || (6-day) <= value) { value = value + (weeks * 2); } return this.addDays(value); }; /** * Adds the specified number of weeks to this instance. * @param {Number} The number of weeks to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addWeeks = function (value) { if (!value) { return this; } return this.addDays(value * 7); }; /** * Adds the specified number of months to this instance. * @param {Number} The number of months to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addMonths = function (value) { if (!value) { return this; } var n = this.getDate(); this.setDate(1); this.setMonth(this.getMonth() + value * 1); this.setDate(Math.min(n, $D.getDaysInMonth(this.getFullYear(), this.getMonth()))); return this; }; $P.addQuarters = function (value) { if (!value) { return this; } // note this will take you to the same point in the quarter as you are now. // i.e. - if you are 15 days into the quarter you'll be 15 days into the resulting one. // bonus: this allows adding fractional quarters return this.addMonths(value * 3); }; /** * Adds the specified number of years to this instance. * @param {Number} The number of years to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addYears = function (value) { if (!value) { return this; } return this.addMonths(value * 12); }; /** * Adds (or subtracts) to the value of the years, months, weeks, days, hours, minutes, seconds, milliseconds of the date instance using given configuration object. Positive and Negative values allowed. * Example

	Date.today().add( { days: 1, months: 1 } )

	new Date().add( { years: -1 } )
	
* @param {Object} Configuration object containing attributes (months, days, etc.) * @return {Date} this */ $P.add = function (config) { if (typeof config === "number") { this._orient = config; return this; } var x = config; if (x.day) { // If we should be a different date than today (eg: for 'tomorrow -1d', etc). // Should only effect parsing, not direct usage (eg, Finish and FinishExact) if ((x.day - this.getDate()) !== 0) { this.setDate(x.day); } } if (x.milliseconds) { this.addMilliseconds(x.milliseconds); } if (x.seconds) { this.addSeconds(x.seconds); } if (x.minutes) { this.addMinutes(x.minutes); } if (x.hours) { this.addHours(x.hours); } if (x.weeks) { this.addWeeks(x.weeks); } if (x.months) { this.addMonths(x.months); } if (x.years) { this.addYears(x.years); } if (x.days) { this.addDays(x.days); } return this; }; /** * Get the week number. Week one (1) is the week which contains the first Thursday of the year. Monday is considered the first day of the week. * The .getWeek() function does NOT convert the date to UTC. The local datetime is used. * Please use .getISOWeek() to get the week of the UTC converted date. * @return {Number} 1 to 53 */ $P.getWeek = function (utc) { // Create a copy of this date object var self, target = new Date(this.valueOf()); if (utc) { target.addMinutes(target.getTimezoneOffset()); self = target.clone(); } else { self = this; } // ISO week date weeks start on monday // so correct the day number var dayNr = (self.getDay() + 6) % 7; // ISO 8601 states that week 1 is the week // with the first thursday of that year. // Set the target date to the thursday in the target week target.setDate(target.getDate() - dayNr + 3); // Store the millisecond value of the target date var firstThursday = target.valueOf(); // Set the target to the first thursday of the year // First set the target to january first target.setMonth(0, 1); // Not a thursday? Correct the date to the next thursday if (target.getDay() !== 4) { target.setMonth(0, 1 + ((4 - target.getDay()) + 7) % 7); } // The weeknumber is the number of weeks between the // first thursday of the year and the thursday in the target week return 1 + Math.ceil((firstThursday - target) / 604800000); // 604800000 = 7 * 24 * 3600 * 1000 }; /** * Get the ISO 8601 week number. Week one ("01") is the week which contains the first Thursday of the year. Monday is considered the first day of the week. * The .getISOWeek() function does convert the date to it's UTC value. Please use .getWeek() to get the week of the local date. * @return {String} "01" to "53" */ $P.getISOWeek = function () { return p(this.getWeek(true)); }; /** * Moves the date to Monday of the week set. Week one (1) is the week which contains the first Thursday of the year. * @param {Number} A Number (1 to 53) that represents the week of the year. * @return {Date} this */ $P.setWeek = function (n) { if ((n - this.getWeek()) === 0) { if (this.getDay() !== 1) { return this.moveToDayOfWeek(1, (this.getDay() > 1 ? -1 : 1)); } else { return this; } } else { return this.moveToDayOfWeek(1, (this.getDay() > 1 ? -1 : 1)).addWeeks(n - this.getWeek()); } }; $P.setQuarter = function (qtr) { var month = Math.abs(((qtr-1) * 3) + 1); return this.setMonth(month, 1); }; $P.getQuarter = function () { return Date.getQuarter(this); }; $P.getDaysLeftInQuarter = function () { return Date.getDaysLeftInQuarter(this); }; /** * Moves the date to the next n'th occurrence of the dayOfWeek starting from the beginning of the month. The number (-1) is a magic number and will return the last occurrence of the dayOfWeek in the month. * @param {Number} The dayOfWeek to move to * @param {Number} The n'th occurrence to move to. Use (-1) to return the last occurrence in the month * @return {Date} this */ $P.moveToNthOccurrence = function (dayOfWeek, occurrence) { if (dayOfWeek === "Weekday") { if (occurrence > 0) { this.moveToFirstDayOfMonth(); if (this.is().weekday()) { occurrence -= 1; } } else if (occurrence < 0) { this.moveToLastDayOfMonth(); if (this.is().weekday()) { occurrence += 1; } } else { return this; } return this.addWeekdays(occurrence); } var shift = 0; if (occurrence > 0) { shift = occurrence - 1; } else if (occurrence === -1) { this.moveToLastDayOfMonth(); if (this.getDay() !== dayOfWeek) { this.moveToDayOfWeek(dayOfWeek, -1); } return this; } return this.moveToFirstDayOfMonth().addDays(-1).moveToDayOfWeek(dayOfWeek, +1).addWeeks(shift); }; var moveToN = function (getFunc, addFunc, nVal) { return function (value, orient) { var diff = (value - this[getFunc]() + nVal * (orient || +1)) % nVal; return this[addFunc]((diff === 0) ? diff += nVal * (orient || +1) : diff); }; }; /** * Move to the next or last dayOfWeek based on the orient value. * @param {Number} The dayOfWeek to move to * @param {Number} Forward (+1) or Back (-1). Defaults to +1. [Optional] * @return {Date} this */ $P.moveToDayOfWeek = moveToN("getDay", "addDays", 7); /** * Move to the next or last month based on the orient value. * @param {Number} The month to move to. 0 = January, 11 = December * @param {Number} Forward (+1) or Back (-1). Defaults to +1. [Optional] * @return {Date} this */ $P.moveToMonth = moveToN("getMonth", "addMonths", 12); /** * Get the Ordinate of the current day ("th", "st", "rd"). * @return {String} */ $P.getOrdinate = function () { var num = this.getDate(); return ord(num); }; /** * Get the Ordinal day (numeric day number) of the year, adjusted for leap year. * @return {Number} 1 through 365 (366 in leap years) */ $P.getOrdinalNumber = function () { return Math.ceil((this.clone().clearTime() - new Date(this.getFullYear(), 0, 1)) / 86400000) + 1; }; /** * Get the time zone abbreviation of the current date. * @return {String} The abbreviated time zone name (e.g. "EST") */ $P.getTimezone = function () { return $D.getTimezoneAbbreviation(this.getUTCOffset(), this.isDaylightSavingTime()); }; $P.setTimezoneOffset = function (offset) { var here = this.getTimezoneOffset(), there = Number(offset) * -6 / 10; return (there || there === 0) ? this.addMinutes(there - here) : this; }; $P.setTimezone = function (offset) { return this.setTimezoneOffset($D.getTimezoneOffset(offset)); }; /** * Indicates whether Daylight Saving Time is observed in the current time zone. * @return {Boolean} true|false */ $P.hasDaylightSavingTime = function () { return (Date.today().set({month: 0, day: 1}).getTimezoneOffset() !== Date.today().set({month: 6, day: 1}).getTimezoneOffset()); }; /** * Indicates whether this Date instance is within the Daylight Saving Time range for the current time zone. * @return {Boolean} true|false */ $P.isDaylightSavingTime = function () { return Date.today().set({month: 0, day: 1}).getTimezoneOffset() !== this.getTimezoneOffset(); }; /** * Get the offset from UTC of the current date. * @return {String} The 4-character offset string prefixed with + or - (e.g. "-0500") */ $P.getUTCOffset = function (offset) { var n = (offset || this.getTimezoneOffset()) * -10 / 6, r; if (n < 0) { r = (n - 10000).toString(); return r.charAt(0) + r.substr(2); } else { r = (n + 10000).toString(); return "+" + r.substr(1); } }; /** * Returns the number of milliseconds between this date and date. * @param {Date} Defaults to now * @return {Number} The diff in milliseconds */ $P.getElapsed = function (date) { return (date || new Date()) - this; }; /** * Set the value of year, month, day, hour, minute, second, millisecond of date instance using given configuration object. * Example

	Date.today().set( { day: 20, month: 1 } )

	new Date().set( { millisecond: 0 } )
	
* * @param {Object} Configuration object containing attributes (month, day, etc.) * @return {Date} this */ $P.set = function (config) { config = validateConfigObject.call(this, config); var key; for (key in config) { if (Object.prototype.hasOwnProperty.call(config, key)) { var name = key.charAt(0).toUpperCase() + key.slice(1); var addFunc, getFunc; if (key !== "week" && key !== "month" && key !== "timezone" && key !== "timezoneOffset") { name += "s"; } addFunc = "add" + name; getFunc = "get" + name; if (key === "month") { addFunc = addFunc + "s"; } else if (key === "year"){ getFunc = "getFullYear"; } if (key !== "day" && key !== "timezone" && key !== "timezoneOffset" && key !== "week" && key !== "hour") { this[addFunc](config[key] - this[getFunc]()); } else if ( key === "timezone"|| key === "timezoneOffset" || key === "week" || key === "hour") { this["set"+name](config[key]); } } } // day has to go last because you can't validate the day without first knowing the month if (config.day) { this.addDays(config.day - this.getDate()); } return this; }; /** * Moves the date to the first day of the month. * @return {Date} this */ $P.moveToFirstDayOfMonth = function () { return this.set({ day: 1 }); }; /** * Moves the date to the last day of the month. * @return {Date} this */ $P.moveToLastDayOfMonth = function () { return this.set({ day: $D.getDaysInMonth(this.getFullYear(), this.getMonth())}); }; /** * Converts the value of the current Date object to its equivalent string representation. * Format Specifiers * CUSTOM DATE AND TIME FORMAT STRINGS * Format Description Example * ------ --------------------------------------------------------------------------- ----------------------- * s The seconds of the minute between 0-59. "0" to "59" * ss The seconds of the minute with leading zero if required. "00" to "59" * * m The minute of the hour between 0-59. "0" or "59" * mm The minute of the hour with leading zero if required. "00" or "59" * * h The hour of the day between 1-12. "1" to "12" * hh The hour of the day with leading zero if required. "01" to "12" * * H The hour of the day between 0-23. "0" to "23" * HH The hour of the day with leading zero if required. "00" to "23" * * d The day of the month between 1 and 31. "1" to "31" * dd The day of the month with leading zero if required. "01" to "31" * ddd Abbreviated day name. Date.CultureInfo.abbreviatedDayNames. "Mon" to "Sun" * dddd The full day name. Date.CultureInfo.dayNames. "Monday" to "Sunday" * * M The month of the year between 1-12. "1" to "12" * MM The month of the year with leading zero if required. "01" to "12" * MMM Abbreviated month name. Date.CultureInfo.abbreviatedMonthNames. "Jan" to "Dec" * MMMM The full month name. Date.CultureInfo.monthNames. "January" to "December" * * yy The year as a two-digit number. "99" or "08" * yyyy The full four digit year. "1999" or "2008" * * t Displays the first character of the A.M./P.M. designator. "A" or "P" * Date.CultureInfo.amDesignator or Date.CultureInfo.pmDesignator * tt Displays the A.M./P.M. designator. "AM" or "PM" * Date.CultureInfo.amDesignator or Date.CultureInfo.pmDesignator * * S The ordinal suffix ("st, "nd", "rd" or "th") of the current day. "st, "nd", "rd" or "th" * * STANDARD DATE AND TIME FORMAT STRINGS * Format Description Example *------ --------------------------------------------------------------------------- ----------------------- * d The CultureInfo shortDate Format Pattern "M/d/yyyy" * D The CultureInfo longDate Format Pattern "dddd, MMMM dd, yyyy" * F The CultureInfo fullDateTime Format Pattern "dddd, MMMM dd, yyyy h:mm:ss tt" * m The CultureInfo monthDay Format Pattern "MMMM dd" * r The CultureInfo rfc1123 Format Pattern "ddd, dd MMM yyyy HH:mm:ss GMT" * s The CultureInfo sortableDateTime Format Pattern "yyyy-MM-ddTHH:mm:ss" * t The CultureInfo shortTime Format Pattern "h:mm tt" * T The CultureInfo longTime Format Pattern "h:mm:ss tt" * u The CultureInfo universalSortableDateTime Format Pattern "yyyy-MM-dd HH:mm:ssZ" * y The CultureInfo yearMonth Format Pattern "MMMM, yyyy" * * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @return {String} A string representation of the current Date object. */ var ord = function (n) { switch (n * 1) { case 1: case 21: case 31: return "st"; case 2: case 22: return "nd"; case 3: case 23: return "rd"; default: return "th"; } }; var parseStandardFormats = function (format) { var y, c = Date.CultureInfo.formatPatterns; switch (format) { case "d": return this.toString(c.shortDate); case "D": return this.toString(c.longDate); case "F": return this.toString(c.fullDateTime); case "m": return this.toString(c.monthDay); case "r": case "R": y = this.clone().addMinutes(this.getTimezoneOffset()); return y.toString(c.rfc1123) + " GMT"; case "s": return this.toString(c.sortableDateTime); case "t": return this.toString(c.shortTime); case "T": return this.toString(c.longTime); case "u": y = this.clone().addMinutes(this.getTimezoneOffset()); return y.toString(c.universalSortableDateTime); case "y": return this.toString(c.yearMonth); default: return false; } }; var parseFormatStringsClosure = function (context) { return function (m) { if (m.charAt(0) === "\\") { return m.replace("\\", ""); } switch (m) { case "hh": return p(context.getHours() < 13 ? (context.getHours() === 0 ? 12 : context.getHours()) : (context.getHours() - 12)); case "h": return context.getHours() < 13 ? (context.getHours() === 0 ? 12 : context.getHours()) : (context.getHours() - 12); case "HH": return p(context.getHours()); case "H": return context.getHours(); case "mm": return p(context.getMinutes()); case "m": return context.getMinutes(); case "ss": return p(context.getSeconds()); case "s": return context.getSeconds(); case "yyyy": return p(context.getFullYear(), 4); case "yy": return p(context.getFullYear()); case "y": return context.getFullYear(); case "E": case "dddd": return Date.CultureInfo.dayNames[context.getDay()]; case "ddd": return Date.CultureInfo.abbreviatedDayNames[context.getDay()]; case "dd": return p(context.getDate()); case "d": return context.getDate(); case "MMMM": return Date.CultureInfo.monthNames[context.getMonth()]; case "MMM": return Date.CultureInfo.abbreviatedMonthNames[context.getMonth()]; case "MM": return p((context.getMonth() + 1)); case "M": return context.getMonth() + 1; case "t": return context.getHours() < 12 ? Date.CultureInfo.amDesignator.substring(0, 1) : Date.CultureInfo.pmDesignator.substring(0, 1); case "tt": return context.getHours() < 12 ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator; case "S": return ord(context.getDate()); case "W": return context.getWeek(); case "WW": return context.getISOWeek(); case "Q": return "Q" + context.getQuarter(); case "q": return String(context.getQuarter()); case "z": return context.getTimezone(); case "Z": case "X": return Date.getTimezoneOffset(context.getTimezone()); case "ZZ": // Timezone offset in seconds return context.getTimezoneOffset() * -60; case "u": return context.getDay(); case "L": return ($D.isLeapYear(context.getFullYear())) ? 1 : 0; case "B": // Swatch Internet Time (.beats) return "@"+((context.getUTCSeconds() + (context.getUTCMinutes()*60) + ((context.getUTCHours()+1)*3600))/86.4); default: return m; } }; }; $P.toString = function (format, ignoreStandards) { // Standard Date and Time Format Strings. Formats pulled from CultureInfo file and // may vary by culture. if (!ignoreStandards && format && format.length === 1) { output = parseStandardFormats.call(this, format); if (output) { return output; } } var parseFormatStrings = parseFormatStringsClosure(this); return format ? format.replace(/((\\)?(dd?d?d?|MM?M?M?|yy?y?y?|hh?|HH?|mm?|ss?|tt?|S|q|Q|WW?W?W?)(?![^\[]*\]))/g, parseFormatStrings).replace(/\[|\]/g, "") : this._toString(); }; }()); /************************************************************* * SugarPak - Domain Specific Language - Syntactical Sugar * *************************************************************/ (function () { var $D = Date, $P = $D.prototype, $N = Number.prototype; // private $P._orient = +1; // private $P._nth = null; // private $P._is = false; // private $P._same = false; // private $P._isSecond = false; // private $N._dateElement = "days"; /** * Moves the date to the next instance of a date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.today().next().friday();
	Date.today().next().fri();
	Date.today().next().march();
	Date.today().next().mar();
	Date.today().next().week();
	
* * @return {Date} date */ $P.next = function () { this._move = true; this._orient = +1; return this; }; /** * Creates a new Date (Date.today()) and moves the date to the next instance of the date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.next().friday();
	Date.next().fri();
	Date.next().march();
	Date.next().mar();
	Date.next().week();
	
* * @return {Date} date */ $D.next = function () { return $D.today().next(); }; /** * Moves the date to the previous instance of a date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.today().last().friday();
	Date.today().last().fri();
	Date.today().last().march();
	Date.today().last().mar();
	Date.today().last().week();
	
* * @return {Date} date */ $P.last = $P.prev = $P.previous = function () { this._move = true; this._orient = -1; return this; }; /** * Creates a new Date (Date.today()) and moves the date to the previous instance of the date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.last().friday();
	Date.last().fri();
	Date.previous().march();
	Date.prev().mar();
	Date.last().week();
	
* * @return {Date} date */ $D.last = $D.prev = $D.previous = function () { return $D.today().last(); }; /** * Performs a equality check when followed by either a month name, day name or .weekday() function. * Example

	Date.today().is().friday(); // true|false
	Date.today().is().fri();
	Date.today().is().march();
	Date.today().is().mar();
	
* * @return {Boolean} true|false */ $P.is = function () { this._is = true; return this; }; /** * Determines if two date objects occur on/in exactly the same instance of the subsequent date part function. * The function .same() must be followed by a date part function (example: .day(), .month(), .year(), etc). * * An optional Date can be passed in the date part function. If now date is passed as a parameter, 'Now' is used. * * The following example demonstrates how to determine if two dates fall on the exact same day. * * Example

	var d1 = Date.today(); // today at 00:00
	var d2 = new Date();   // exactly now.

	// Do they occur on the same day?
	d1.same().day(d2); // true
	
	// Do they occur on the same hour?
	d1.same().hour(d2); // false, unless d2 hour is '00' (midnight).
	
	// What if it's the same day, but one year apart?
	var nextYear = Date.today().add(1).year();

	d1.same().day(nextYear); // false, because the dates must occur on the exact same day. 
	
* * Scenario: Determine if a given date occurs during some week period 2 months from now. * * Example

	var future = Date.today().add(2).months();
	return someDate.same().week(future); // true|false;
	
* * @return {Boolean} true|false */ $P.same = function () { this._same = true; this._isSecond = false; return this; }; /** * Determines if the current date/time occurs during Today. Must be preceded by the .is() function. * Example

	someDate.is().today();    // true|false
	new Date().is().today();  // true
	Date.today().is().today();// true
	Date.today().add(-1).day().is().today(); // false
	
* * @return {Boolean} true|false */ $P.today = function () { return this.same().day(); }; /** * Determines if the current date is a weekday. This function must be preceded by the .is() function. * Example

	Date.today().is().weekday(); // true|false
	
* * @return {Boolean} true|false */ $P.weekday = function () { if (this._nth) { return df("Weekday").call(this); } if (this._move) { return this.addWeekdays(this._orient); } if (this._is) { this._is = false; return (!this.is().sat() && !this.is().sun()); } return false; }; /** * Determines if the current date is on the weekend. This function must be preceded by the .is() function. * Example

	Date.today().is().weekend(); // true|false
	
* * @return {Boolean} true|false */ $P.weekend = function () { if (this._is) { this._is = false; return (this.is().sat() || this.is().sun()); } return false; }; /** * Sets the Time of the current Date instance. A string "6:15 pm" or config object {hour:18, minute:15} are accepted. * Example

	// Set time to 6:15pm with a String
	Date.today().at("6:15pm");

	// Set time to 6:15pm with a config object
	Date.today().at({hour:18, minute:15});
	
* * @return {Date} date */ $P.at = function (time) { return (typeof time === "string") ? $D.parse(this.toString("d") + " " + time) : this.set(time); }; /** * Creates a new Date() and adds this (Number) to the date based on the preceding date element function (eg. second|minute|hour|day|month|year). * Example

	// Undeclared Numbers must be wrapped with parentheses. Requirment of JavaScript.
	(3).days().fromNow();
	(6).months().fromNow();

	// Declared Number variables do not require parentheses. 
	var n = 6;
	n.months().fromNow();
	
* * @return {Date} A new Date instance */ $N.fromNow = $N.after = function (date) { var c = {}; c[this._dateElement] = this; return ((!date) ? new Date() : date.clone()).add(c); }; /** * Creates a new Date() and subtract this (Number) from the date based on the preceding date element function (eg. second|minute|hour|day|month|year). * Example

	// Undeclared Numbers must be wrapped with parentheses. Requirment of JavaScript.
	(3).days().ago();
	(6).months().ago();

	// Declared Number variables do not require parentheses. 
	var n = 6;
	n.months().ago();
	
* * @return {Date} A new Date instance */ $N.ago = $N.before = function (date) { var c = {}, s = (this._dateElement[this._dateElement.length-1] !== "s") ? this._dateElement + "s" : this._dateElement; c[s] = this * -1; return ((!date) ? new Date() : date.clone()).add(c); }; // Do NOT modify the following string tokens. These tokens are used to build dynamic functions. // All culture-specific strings can be found in the CultureInfo files. var dx = ("sunday monday tuesday wednesday thursday friday saturday").split(/\s/), mx = ("january february march april may june july august september october november december").split(/\s/), px = ("Millisecond Second Minute Hour Day Week Month Year Quarter Weekday").split(/\s/), pxf = ("Milliseconds Seconds Minutes Hours Date Week Month FullYear Quarter").split(/\s/), nth = ("final first second third fourth fifth").split(/\s/), de; /** * Returns an object literal of all the date parts. * Example

	var o = new Date().toObject();
	
	// { year: 2008, month: 4, week: 20, day: 13, hour: 18, minute: 9, second: 32, millisecond: 812 }
	
	// The object properties can be referenced directly from the object.
	
	alert(o.day);  // alerts "13"
	alert(o.year); // alerts "2008"
	
* * @return {Date} An object literal representing the original date object. */ $P.toObject = function () { var o = {}; for (var i = 0; i < px.length; i++) { if (this["get" + pxf[i]]) { o[px[i].toLowerCase()] = this["get" + pxf[i]](); } } return o; }; /** * Returns a date created from an object literal. Ignores the .week property if set in the config. * Example

	var o = new Date().toObject();
	
	return Date.fromObject(o); // will return the same date. 

	var o2 = {month: 1, day: 20, hour: 18}; // birthday party!
	Date.fromObject(o2);
	
* * @return {Date} An object literal representing the original date object. */ $D.fromObject = function(config) { config.week = null; return Date.today().set(config); }; // Create day name functions and abbreviated day name functions (eg. monday(), friday(), fri()). var df = function (n) { return function () { if (this._is) { this._is = false; return this.getDay() === n; } if (this._move) { this._move = null; } if (this._nth !== null) { // If the .second() function was called earlier, remove the _orient // from the date, and then continue. // This is required because 'second' can be used in two different context. // // Example // // Date.today().add(1).second(); // Date.march().second().monday(); // // Things get crazy with the following... // Date.march().add(1).second().second().monday(); // but it works!! // if (this._isSecond) { this.addSeconds(this._orient * -1); } // make sure we reset _isSecond this._isSecond = false; var ntemp = this._nth; this._nth = null; var temp = this.clone().moveToLastDayOfMonth(); this.moveToNthOccurrence(n, ntemp); if (this > temp) { throw new RangeError($D.getDayName(n) + " does not occur " + ntemp + " times in the month of " + $D.getMonthName(temp.getMonth()) + " " + temp.getFullYear() + "."); } return this; } return this.moveToDayOfWeek(n, this._orient); }; }; var sdf = function (n) { return function () { var t = $D.today(), shift = n - t.getDay(); if (n === 0 && Date.CultureInfo.firstDayOfWeek === 1 && t.getDay() !== 0) { shift = shift + 7; } return t.addDays(shift); }; }; // Create month name functions and abbreviated month name functions (eg. january(), march(), mar()). var month_instance_functions = function (n) { return function () { if (this._is) { this._is = false; return this.getMonth() === n; } return this.moveToMonth(n, this._orient); }; }; var month_static_functions = function (n) { return function () { return $D.today().set({ month: n, day: 1 }); }; }; var processTerms = function (names, staticFunc, instanceFunc) { for (var i = 0; i < names.length; i++) { // Create constant static Name variables. $D[names[i].toUpperCase()] = $D[names[i].toUpperCase().substring(0, 3)] = i; // Create Name functions. $D[names[i]] = $D[names[i].substring(0, 3)] = staticFunc(i); // Create Name instance functions. $P[names[i]] = $P[names[i].substring(0, 3)] = instanceFunc(i); } }; processTerms(dx, sdf, df); processTerms(mx, month_static_functions, month_instance_functions); // Create date element functions and plural date element functions used with Date (eg. day(), days(), months()). var ef = function (j) { return function () { // if the .second() function was called earlier, the _orient // has alread been added. Just return this and reset _isSecond. if (this._isSecond) { this._isSecond = false; return this; } if (this._same) { this._same = this._is = false; var o1 = this.toObject(), o2 = (arguments[0] || new Date()).toObject(), v = "", k = j.toLowerCase(); // the substr trick with -1 doesn't work in IE8 or less k = (k[k.length-1] === "s") ? k.substring(0,k.length-1) : k; for (var m = (px.length - 1); m > -1; m--) { v = px[m].toLowerCase(); if (o1[v] !== o2[v]) { return false; } if (k === v) { break; } } return true; } if (j.substring(j.length - 1) !== "s") { j += "s"; } if (this._move) { this._move = null; } return this["add" + j](this._orient); }; }; var nf = function (n) { return function () { this._dateElement = n; return this; }; }; for (var k = 0; k < px.length; k++) { de = px[k].toLowerCase(); if(de !== "weekday") { // Create date element functions and plural date element functions used with Date (eg. day(), days(), months()). $P[de] = $P[de + "s"] = ef(px[k]); // Create date element functions and plural date element functions used with Number (eg. day(), days(), months()). $N[de] = $N[de + "s"] = nf(de + "s"); } } $P._ss = ef("Second"); var nthfn = function (n) { return function (dayOfWeek) { if (this._same) { return this._ss(arguments[0]); } if (dayOfWeek || dayOfWeek === 0) { return this.moveToNthOccurrence(dayOfWeek, n); } this._nth = n; // if the operator is 'second' add the _orient, then deal with it later... if (n === 2 && (dayOfWeek === undefined || dayOfWeek === null)) { this._isSecond = true; return this.addSeconds(this._orient); } return this; }; }; for (var l = 0; l < nth.length; l++) { $P[nth[l]] = (l === 0) ? nthfn(-1) : nthfn(l); } }()); (function () { "use strict"; Date.Parsing = { Exception: function (s) { this.message = "Parse error at '" + s.substring(0, 10) + " ...'"; } }; var $P = Date.Parsing; var dayOffsets = { standard: [0,31,59,90,120,151,181,212,243,273,304,334], leap: [0,31,60,91,121,152,182,213,244,274,305,335] }; $P.isLeapYear = function(year) { return ((year % 4 === 0) && (year % 100 !== 0)) || (year % 400 === 0); }; var utils = { multiReplace : function (str, hash ) { var key; for (key in hash) { if (Object.prototype.hasOwnProperty.call(hash, key)) { var regex; if (typeof hash[key] === "function") { } else { regex = (hash[key] instanceof RegExp) ? hash[key] : new RegExp(hash[key], "g"); } str = str.replace(regex, key); } } return str; }, getDayOfYearFromWeek : function (obj) { var d, jan4, offset; obj.weekDay = (!obj.weekDay && obj.weekDay !== 0) ? 1 : obj.weekDay; d = new Date(obj.year, 0, 4); jan4 = d.getDay() === 0 ? 7 : d.getDay(); // JS is 0 indexed on Sunday. offset = jan4+3; obj.dayOfYear = ((obj.week * 7) + (obj.weekDay === 0 ? 7 : obj.weekDay))-offset; return obj; }, getDayOfYear : function (obj, dayOffset) { if (!obj.dayOfYear) { obj = utils.getDayOfYearFromWeek(obj); } for (var i=0;i <= dayOffset.length;i++) { if (obj.dayOfYear < dayOffset[i] || i === dayOffset.length) { obj.day = obj.day ? obj.day : (obj.dayOfYear - dayOffset[i-1]); break; } else { obj.month = i; } } return obj; }, adjustForTimeZone : function (obj, date) { var offset; if (obj.zone.toUpperCase() === "Z" || (obj.zone_hours === 0 && obj.zone_minutes === 0)) { // it's UTC/GML so work out the current timeszone offset offset = -date.getTimezoneOffset(); } else { offset = (obj.zone_hours*60) + (obj.zone_minutes || 0); if (obj.zone_sign === "+") { offset *= -1; } offset -= date.getTimezoneOffset(); } date.setMinutes(date.getMinutes()+offset); return date; }, setDefaults : function (obj) { obj.year = obj.year || Date.today().getFullYear(); obj.hours = obj.hours || 0; obj.minutes = obj.minutes || 0; obj.seconds = obj.seconds || 0; obj.milliseconds = obj.milliseconds || 0; if (!(!obj.month && (obj.week || obj.dayOfYear))) { // if we have a month, or if we don't but don't have the day calculation data obj.month = obj.month || 0; obj.day = obj.day || 1; } return obj; }, dataNum: function (data, mod, explict, postProcess) { var dataNum = data*1; if (mod) { if (postProcess) { return data ? mod(data)*1 : data; } else { return data ? mod(dataNum) : data; } } else if (!explict){ return data ? dataNum : data; } else { return (data && typeof data !== "undefined") ? dataNum : data; } }, timeDataProcess: function (obj) { var timeObj = {}; for (var x in obj.data) { if (obj.data.hasOwnProperty(x)) { timeObj[x] = obj.ignore[x] ? obj.data[x] : utils.dataNum(obj.data[x], obj.mods[x], obj.explict[x], obj.postProcess[x]); } } if (obj.data.secmins) { obj.data.secmins = obj.data.secmins.replace(",", ".") * 60; if (!timeObj.minutes) { timeObj.minutes = obj.data.secmins; } else if (!timeObj.seconds) { timeObj.seconds = obj.data.secmins; } delete obj.secmins; } return timeObj; }, buildTimeObjectFromData: function (data) { var time = utils.timeDataProcess({ data: { year : data[1], month : data[5], day : data[7], week : data[8], dayOfYear : data[10], hours : data[15], zone_hours : data[23], zone_minutes : data[24], zone : data[21], zone_sign : data[22], weekDay : data[9], minutes: data[16], seconds: data[19], milliseconds: data[20], secmins: data[18] }, mods: { month: function(data) { return data-1; }, weekDay: function (data) { data = Math.abs(data); return (data === 7 ? 0 : data); }, minutes: function (data) { return data.replace(":",""); }, seconds: function (data) { return Math.floor( (data.replace(":","").replace(",","."))*1 ); }, milliseconds: function (data) { return (data.replace(",",".")*1000); } }, postProcess: { minutes: true, seconds: true, milliseconds: true }, explict: { zone_hours: true, zone_minutes: true }, ignore: { zone: true, zone_sign: true, secmins: true } }); return time; }, addToHash: function (hash, keys, data) { keys = keys; data = data; var len = keys.length; for (var i = 0; i < len; i++) { hash[keys[i]] = data[i]; } return hash; }, combineRegex: function (r1, r2) { return new RegExp("(("+r1.source+")\\s("+r2.source+"))"); }, getDateNthString: function(add, last, inc){ if (add) { return Date.today().addDays(inc).toString("d"); } else if (last) { return Date.today().last()[inc]().toString("d"); } }, buildRegexData: function (array) { var arr = []; var len = array.length; for (var i=0; i < len; i++) { if (Object.prototype.toString.call(array[i]) === '[object Array]') { // oldIE compat version of Array.isArray arr.push(this.combineRegex(array[i][0], array[i][1])); } else { arr.push(array[i]); } } return arr; } }; $P.processTimeObject = function (obj) { var date, dayOffset; utils.setDefaults(obj); dayOffset = ($P.isLeapYear(obj.year)) ? dayOffsets.leap : dayOffsets.standard; if (!obj.month && (obj.week || obj.dayOfYear)) { utils.getDayOfYear(obj, dayOffset); } else { obj.dayOfYear = dayOffset[obj.month] + obj.day; } date = new Date(obj.year, obj.month, obj.day, obj.hours, obj.minutes, obj.seconds, obj.milliseconds); if (obj.zone) { utils.adjustForTimeZone(obj, date); // adjust (and calculate) for timezone } return date; }; $P.ISO = { regex : /^([\+-]?\d{4}(?!\d{2}\b))((-?)((0[1-9]|1[0-2])(\3([12]\d|0[1-9]|3[01]))?|W([0-4]\d|5[0-3])(-?[1-7])?|(00[1-9]|0[1-9]\d|[12]\d{2}|3([0-5]\d|6[1-6])))([T\s]((([01]\d|2[0-4])((:?)[0-5]\d)?|24\:?00)([\.,]\d+(?!:))?)?(\17[0-5]\d([\.,]\d+)?)?\s?([zZ]|([\+-])([01]\d|2[0-3]):?([0-5]\d)?)?)?)?$/, parse : function (s) { var time, data = s.match(this.regex); if (!data || !data.length) { return null; } time = utils.buildTimeObjectFromData(data); if (!time.year || (!time.year && (!time.month && !time.day) && (!time.week && !time.dayOfYear)) ) { return null; } return $P.processTimeObject(time); } }; $P.Numeric = { isNumeric: function (e){return!isNaN(parseFloat(e))&&isFinite(e);}, regex: /\b([0-1]?[0-9])([0-3]?[0-9])([0-2]?[0-9]?[0-9][0-9])\b/i, parse: function (s) { var data, i, time = {}, order = Date.CultureInfo.dateElementOrder.split(""); if (!(this.isNumeric(s)) || // if it's non-numeric OR (s[0] === "+" && s[0] === "-")) { // It's an arithmatic string (eg +/-1000) return null; } if (s.length < 5 && s.indexOf(".") < 0 && s.indexOf("/") < 0) { // assume it's just a year. time.year = s; return $P.processTimeObject(time); } data = s.match(this.regex); if (!data || !data.length) { return null; } for (i=0; i < order.length; i++) { switch(order[i]) { case "d": time.day = data[i+1]; break; case "m": time.month = (data[i+1]-1); break; case "y": time.year = data[i+1]; break; } } return $P.processTimeObject(time); } }; $P.Normalizer = { regexData: function () { var $R = Date.CultureInfo.regexPatterns; return utils.buildRegexData([ $R.tomorrow, $R.yesterday, [$R.past, $R.mon], [$R.past, $R.tue], [$R.past, $R.wed], [$R.past, $R.thu], [$R.past, $R.fri], [$R.past, $R.sat], [$R.past, $R.sun] ]); }, basicReplaceHash : function() { var $R = Date.CultureInfo.regexPatterns; return { "January": $R.jan.source, "February": $R.feb, "March": $R.mar, "April": $R.apr, "May": $R.may, "June": $R.jun, "July": $R.jul, "August": $R.aug, "September": $R.sep, "October": $R.oct, "November": $R.nov, "December": $R.dec, "": /\bat\b/gi, " ": /\s{2,}/, "am": $R.inTheMorning, "9am": $R.thisMorning, "pm": $R.inTheEvening, "7pm":$R.thisEvening }; }, keys : function(){ return [ utils.getDateNthString(true, false, 1), // tomorrow utils.getDateNthString(true, false, -1), // yesterday utils.getDateNthString(false, true, "monday"), //last mon utils.getDateNthString(false, true, "tuesday"), //last tues utils.getDateNthString(false, true, "wednesday"), //last wed utils.getDateNthString(false, true, "thursday"), //last thurs utils.getDateNthString(false, true, "friday"), //last fri utils.getDateNthString(false, true, "saturday"), //last sat utils.getDateNthString(false, true, "sunday") //last sun ]; }, buildRegexFunctions: function () { var $R = Date.CultureInfo.regexPatterns; var __ = Date.i18n.__; var tomorrowRE = new RegExp("(\\b\\d\\d?("+__("AM")+"|"+__("PM")+")? )("+$R.tomorrow.source.slice(1)+")", "i"); // adapted tomorrow regex for AM PM relative dates var todayRE = new RegExp($R.today.source + "(?!\\s*([+-]))\\b"); // today, but excludes the math operators (eg "today + 2h") this.replaceFuncs = [ [todayRE, function (full) { return (full.length > 1) ? Date.today().toString("d") : full; }], [tomorrowRE, function(full, m1) { var t = Date.today().addDays(1).toString("d"); return (t + " " + m1); }], [$R.amThisMorning, function(str, am){return am;}], [$R.pmThisEvening, function(str, pm){return pm;}] ]; }, buildReplaceData: function () { this.buildRegexFunctions(); this.replaceHash = utils.addToHash(this.basicReplaceHash(), this.keys(), this.regexData()); }, stringReplaceFuncs: function (s) { for (var i=0; i < this.replaceFuncs.length; i++) { s = s.replace(this.replaceFuncs[i][0], this.replaceFuncs[i][1]); } return s; }, parse: function (s) { s = this.stringReplaceFuncs(s); s = utils.multiReplace(s, this.replaceHash); try { var n = s.split(/([\s\-\.\,\/\x27]+)/); if (n.length === 3 && $P.Numeric.isNumeric(n[0]) && $P.Numeric.isNumeric(n[2]) && (n[2].length >= 4)) { // ok, so we're dealing with x/year. But that's not a full date. // This fixes wonky dateElementOrder parsing when set to dmy order. if (Date.CultureInfo.dateElementOrder[0] === "d") { s = "1/" + n[0] + "/" + n[2]; // set to 1st of month and normalize the seperator } } } catch (e) {} return s; } }; $P.Normalizer.buildReplaceData(); }()); (function () { var $P = Date.Parsing; var _ = $P.Operators = { // // Tokenizers // rtoken: function (r) { // regex token return function (s) { var mx = s.match(r); if (mx) { return ([ mx[0], s.substring(mx[0].length) ]); } else { throw new $P.Exception(s); } }; }, token: function () { // whitespace-eating token return function (s) { return _.rtoken(new RegExp("^\\s*" + s + "\\s*"))(s); }; }, stoken: function (s) { // string token return _.rtoken(new RegExp("^" + s)); }, // Atomic Operators until: function (p) { return function (s) { var qx = [], rx = null; while (s.length) { try { rx = p.call(this, s); } catch (e) { qx.push(rx[0]); s = rx[1]; continue; } break; } return [ qx, s ]; }; }, many: function (p) { return function (s) { var rx = [], r = null; while (s.length) { try { r = p.call(this, s); } catch (e) { return [ rx, s ]; } rx.push(r[0]); s = r[1]; } return [ rx, s ]; }; }, // generator operators -- see below optional: function (p) { return function (s) { var r = null; try { r = p.call(this, s); } catch (e) { return [ null, s ]; } return [ r[0], r[1] ]; }; }, not: function (p) { return function (s) { try { p.call(this, s); } catch (e) { return [null, s]; } throw new $P.Exception(s); }; }, ignore: function (p) { return p ? function (s) { var r = null; r = p.call(this, s); return [null, r[1]]; } : null; }, product: function () { var px = arguments[0], qx = Array.prototype.slice.call(arguments, 1), rx = []; for (var i = 0 ; i < px.length ; i++) { rx.push(_.each(px[i], qx)); } return rx; }, cache: function (rule) { var cache = {}, cache_length = 0, cache_keys = [], CACHE_MAX = Date.Config.CACHE_MAX || 100000, r = null; var cacheCheck = function () { if (cache_length === CACHE_MAX) { // kill several keys, don't want to have to do this all the time... for (var i=0; i < 10; i++) { var key = cache_keys.shift(); if (key) { delete cache[key]; cache_length--; } } } }; return function (s) { cacheCheck(); try { r = cache[s] = (cache[s] || rule.call(this, s)); } catch (e) { r = cache[s] = e; } cache_length++; cache_keys.push(s); if (r instanceof $P.Exception) { throw r; } else { return r; } }; }, // vector operators -- see below any: function () { var px = arguments; return function (s) { var r = null; for (var i = 0; i < px.length; i++) { if (px[i] == null) { continue; } try { r = (px[i].call(this, s)); } catch (e) { r = null; } if (r) { return r; } } throw new $P.Exception(s); }; }, each: function () { var px = arguments; return function (s) { var rx = [], r = null; for (var i = 0; i < px.length ; i++) { if (px[i] == null) { continue; } try { r = (px[i].call(this, s)); } catch (e) { throw new $P.Exception(s); } rx.push(r[0]); s = r[1]; } return [ rx, s]; }; }, all: function () { var px = arguments, _ = _; return _.each(_.optional(px)); }, // delimited operators sequence: function (px, d, c) { d = d || _.rtoken(/^\s*/); c = c || null; if (px.length === 1) { return px[0]; } return function (s) { var r = null, q = null; var rx = []; for (var i = 0; i < px.length ; i++) { try { r = px[i].call(this, s); } catch (e) { break; } rx.push(r[0]); try { q = d.call(this, r[1]); } catch (ex) { q = null; break; } s = q[1]; } if (!r) { throw new $P.Exception(s); } if (q) { throw new $P.Exception(q[1]); } if (c) { try { r = c.call(this, r[1]); } catch (ey) { throw new $P.Exception(r[1]); } } return [ rx, (r?r[1]:s) ]; }; }, // // Composite Operators // between: function (d1, p, d2) { d2 = d2 || d1; var _fn = _.each(_.ignore(d1), p, _.ignore(d2)); return function (s) { var rx = _fn.call(this, s); return [[rx[0][0], r[0][2]], rx[1]]; }; }, list: function (p, d, c) { d = d || _.rtoken(/^\s*/); c = c || null; return (p instanceof Array ? _.each(_.product(p.slice(0, -1), _.ignore(d)), p.slice(-1), _.ignore(c)) : _.each(_.many(_.each(p, _.ignore(d))), px, _.ignore(c))); }, set: function (px, d, c) { d = d || _.rtoken(/^\s*/); c = c || null; return function (s) { // r is the current match, best the current 'best' match // which means it parsed the most amount of input var r = null, p = null, q = null, rx = null, best = [[], s], last = false; // go through the rules in the given set for (var i = 0; i < px.length ; i++) { // last is a flag indicating whether this must be the last element // if there is only 1 element, then it MUST be the last one q = null; p = null; r = null; last = (px.length === 1); // first, we try simply to match the current pattern // if not, try the next pattern try { r = px[i].call(this, s); } catch (e) { continue; } // since we are matching against a set of elements, the first // thing to do is to add r[0] to matched elements rx = [[r[0]], r[1]]; // if we matched and there is still input to parse and // we don't already know this is the last element, // we're going to next check for the delimiter ... // if there's none, or if there's no input left to parse // than this must be the last element after all ... if (r[1].length > 0 && ! last) { try { q = d.call(this, r[1]); } catch (ex) { last = true; } } else { last = true; } // if we parsed the delimiter and now there's no more input, // that means we shouldn't have parsed the delimiter at all // so don't update r and mark this as the last element ... if (!last && q[1].length === 0) { last = true; } // so, if this isn't the last element, we're going to see if // we can get any more matches from the remaining (unmatched) // elements ... if (!last) { // build a list of the remaining rules we can match against, // i.e., all but the one we just matched against var qx = []; for (var j = 0; j < px.length ; j++) { if (i !== j) { qx.push(px[j]); } } // now invoke recursively set with the remaining input // note that we don't include the closing delimiter ... // we'll check for that ourselves at the end p = _.set(qx, d).call(this, q[1]); // if we got a non-empty set as a result ... // (otw rx already contains everything we want to match) if (p[0].length > 0) { // update current result, which is stored in rx ... // basically, pick up the remaining text from p[1] // and concat the result from p[0] so that we don't // get endless nesting ... rx[0] = rx[0].concat(p[0]); rx[1] = p[1]; } } // at this point, rx either contains the last matched element // or the entire matched set that starts with this element. // now we just check to see if this variation is better than // our best so far, in terms of how much of the input is parsed if (rx[1].length < best[1].length) { best = rx; } // if we've parsed all the input, then we're finished if (best[1].length === 0) { break; } } // so now we've either gone through all the patterns trying them // as the initial match; or we found one that parsed the entire // input string ... // if best has no matches, just return empty set ... if (best[0].length === 0) { return best; } // if a closing delimiter is provided, then we have to check it also if (c) { // we try this even if there is no remaining input because the pattern // may well be optional or match empty input ... try { q = c.call(this, best[1]); } catch (ey) { throw new $P.Exception(best[1]); } // it parsed ... be sure to update the best match remaining input best[1] = q[1]; } // if we're here, either there was no closing delimiter or we parsed it // so now we have the best match; just return it! return best; }; }, forward: function (gr, fname) { return function (s) { return gr[fname].call(this, s); }; }, // // Translation Operators // replace: function (rule, repl) { return function (s) { var r = rule.call(this, s); return [repl, r[1]]; }; }, process: function (rule, fn) { return function (s) { var r = rule.call(this, s); return [fn.call(this, r[0]), r[1]]; }; }, min: function (min, rule) { return function (s) { var rx = rule.call(this, s); if (rx[0].length < min) { throw new $P.Exception(s); } return rx; }; } }; // Generator Operators And Vector Operators // Generators are operators that have a signature of F(R) => R, // taking a given rule and returning another rule, such as // ignore, which parses a given rule and throws away the result. // Vector operators are those that have a signature of F(R1,R2,...) => R, // take a list of rules and returning a new rule, such as each. // Generator operators are converted (via the following _generator // function) into functions that can also take a list or array of rules // and return an array of new rules as though the function had been // called on each rule in turn (which is what actually happens). // This allows generators to be used with vector operators more easily. // Example: // each(ignore(foo, bar)) instead of each(ignore(foo), ignore(bar)) // This also turns generators into vector operators, which allows // constructs like: // not(cache(foo, bar)) var _generator = function (op) { function gen() { var args = null, rx = [], px, i; if (arguments.length > 1) { args = Array.prototype.slice.call(arguments); } else if (arguments[0] instanceof Array) { args = arguments[0]; } if (args) { px = args.shift(); if (px.length > 0) { args.unshift(px[i]); rx.push(op.apply(null, args)); args.shift(); return rx; } } else { return op.apply(null, arguments); } } return gen; }; var gx = "optional not ignore cache".split(/\s/); for (var i = 0 ; i < gx.length ; i++) { _[gx[i]] = _generator(_[gx[i]]); } var _vector = function (op) { return function () { if (arguments[0] instanceof Array) { return op.apply(null, arguments[0]); } else { return op.apply(null, arguments); } }; }; var vx = "each any all".split(/\s/); for (var j = 0 ; j < vx.length ; j++) { _[vx[j]] = _vector(_[vx[j]]); } }()); (function () { var $D = Date; var flattenAndCompact = function (ax) { var rx = []; for (var i = 0; i < ax.length; i++) { if (ax[i] instanceof Array) { rx = rx.concat(flattenAndCompact(ax[i])); } else { if (ax[i]) { rx.push(ax[i]); } } } return rx; }; var parseMeridian = function () { if (this.meridian && (this.hour || this.hour === 0)) { if (this.meridian === "a" && this.hour > 11 && Date.Config.strict24hr){ throw "Invalid hour and meridian combination"; } else if (this.meridian === "p" && this.hour < 12 && Date.Config.strict24hr){ throw "Invalid hour and meridian combination"; } else if (this.meridian === "p" && this.hour < 12) { this.hour = this.hour + 12; } else if (this.meridian === "a" && this.hour === 12) { this.hour = 0; } } }; var setDefaults = function () { var now = new Date(); if ((this.hour || this.minute) && (!this.month && !this.year && !this.day)) { this.day = now.getDate(); } if (!this.year) { this.year = now.getFullYear(); } if (!this.month && this.month !== 0) { this.month = now.getMonth(); } if (!this.day) { this.day = 1; } if (!this.hour) { this.hour = 0; } if (!this.minute) { this.minute = 0; } if (!this.second) { this.second = 0; } if (!this.millisecond) { this.millisecond = 0; } }; var finishUtils = { getToday: function () { if (this.now || "hour minute second".indexOf(this.unit) !== -1) { return new Date(); } else { return $D.today(); } }, setDaysFromWeekday: function (today, orient){ var gap; orient = orient || 1; this.unit = "day"; gap = ($D.getDayNumberFromName(this.weekday) - today.getDay()); this.days = gap ? ((gap + (orient * 7)) % 7) : (orient * 7); return this; }, setMonthsFromMonth: function (today, orient) { var gap; orient = orient || 1; this.unit = "month"; gap = (this.month - today.getMonth()); this.months = gap ? ((gap + (orient * 12)) % 12) : (orient * 12); this.month = null; return this; }, setDMYFromWeekday: function () { var d = Date[this.weekday](); this.day = d.getDate(); if (!this.month) { this.month = d.getMonth(); } this.year = d.getFullYear(); return this; }, setUnitValue: function (orient) { if (!this.value && this.operator && this.operator !== null && this[this.unit + "s"] && this[this.unit + "s"] !== null) { this[this.unit + "s"] = this[this.unit + "s"] + ((this.operator === "add") ? 1 : -1) + (this.value||0) * orient; } else if (this[this.unit + "s"] == null || this.operator != null) { if (!this.value) { this.value = 1; } this[this.unit + "s"] = this.value * orient; } }, generateDateFromWeeks: function () { var weekday = (this.weekday !== undefined) ? this.weekday : "today"; var d = Date[weekday]().addWeeks(this.weeks); if (this.now) { d.setTimeToNow(); } return d; } }; $D.Translator = { hour: function (s) { return function () { this.hour = Number(s); }; }, minute: function (s) { return function () { this.minute = Number(s); }; }, second: function (s) { return function () { this.second = Number(s); }; }, /* for ss.s format */ secondAndMillisecond: function (s) { return function () { var mx = s.match(/^([0-5][0-9])\.([0-9]{1,3})/); this.second = Number(mx[1]); this.millisecond = Number(mx[2]); }; }, meridian: function (s) { return function () { this.meridian = s.slice(0, 1).toLowerCase(); }; }, timezone: function (s) { return function () { var n = s.replace(/[^\d\+\-]/g, ""); if (n.length) { this.timezoneOffset = Number(n); } else { this.timezone = s.toLowerCase(); } }; }, day: function (x) { var s = x[0]; return function () { this.day = Number(s.match(/\d+/)[0]); if (this.day < 1) { throw "invalid day"; } }; }, month: function (s) { return function () { this.month = (s.length === 3) ? "jan feb mar apr may jun jul aug sep oct nov dec".indexOf(s)/4 : Number(s) - 1; if (this.month < 0) { throw "invalid month"; } }; }, year: function (s) { return function () { var n = Number(s); this.year = ((s.length > 2) ? n : (n + (((n + 2000) < Date.CultureInfo.twoDigitYearMax) ? 2000 : 1900))); }; }, rday: function (s) { return function () { switch (s) { case "yesterday": this.days = -1; break; case "tomorrow": this.days = 1; break; case "today": this.days = 0; break; case "now": this.days = 0; this.now = true; break; } }; }, finishExact: function (x) { var d; x = (x instanceof Array) ? x : [x]; for (var i = 0 ; i < x.length ; i++) { if (x[i]) { x[i].call(this); } } setDefaults.call(this); parseMeridian.call(this); if (this.day > $D.getDaysInMonth(this.year, this.month)) { throw new RangeError(this.day + " is not a valid value for days."); } d = new Date(this.year, this.month, this.day, this.hour, this.minute, this.second, this.millisecond); if (this.year < 100) { d.setFullYear(this.year); // means years less that 100 are process correctly. JS will parse it otherwise as 1900-1999. } if (this.timezone) { d.set({ timezone: this.timezone }); } else if (this.timezoneOffset) { d.set({ timezoneOffset: this.timezoneOffset }); } return d; }, finish: function (x) { var today, expression, orient, temp; x = (x instanceof Array) ? flattenAndCompact(x) : [ x ]; if (x.length === 0) { return null; } for (var i = 0 ; i < x.length ; i++) { if (typeof x[i] === "function") { x[i].call(this); } } if (this.now && !this.unit && !this.operator) { return new Date(); } else { today = finishUtils.getToday.call(this); } expression = !!(this.days && this.days !== null || this.orient || this.operator); orient = ((this.orient === "past" || this.operator === "subtract") ? -1 : 1); if (this.month && this.unit === "week") { this.value = this.month + 1; delete this.month; delete this.day; } if ((this.month || this.month === 0) && "year day hour minute second".indexOf(this.unit) !== -1) { if (!this.value) { this.value = this.month + 1; } this.month = null; expression = true; } if (!expression && this.weekday && !this.day && !this.days) { finishUtils.setDMYFromWeekday.call(this); } if (expression && this.weekday && this.unit !== "month" && this.unit !== "week") { finishUtils.setDaysFromWeekday.call(this, today, orient); } if (this.weekday && this.unit !== "week" && !this.day && !this.days) { temp = Date[this.weekday](); this.day = temp.getDate(); if (temp.getMonth() !== today.getMonth()) { this.month = temp.getMonth(); } } if (this.month && this.unit === "day" && this.operator) { if (!this.value) { this.value = (this.month + 1); } this.month = null; } if (this.value != null && this.month != null && this.year != null) { this.day = this.value * 1; } if (this.month && !this.day && this.value) { today.set({ day: this.value * 1 }); if (!expression) { this.day = this.value * 1; } } if (!this.month && this.value && this.unit === "month" && !this.now) { this.month = this.value; expression = true; } if (expression && (this.month || this.month === 0) && this.unit !== "year") { finishUtils.setMonthsFromMonth.call(this, today, orient); } if (!this.unit) { this.unit = "day"; } finishUtils.setUnitValue.call(this, orient); parseMeridian.call(this); if ((this.month || this.month === 0) && !this.day) { this.day = 1; } if (!this.orient && !this.operator && this.unit === "week" && this.value && !this.day && !this.month) { return Date.today().setWeek(this.value); } if (this.unit === "week" && this.weeks && !this.day && !this.month) { return finishUtils.generateDateFromWeeks.call(this); } if (expression && this.timezone && this.day && this.days) { this.day = this.days; } if (expression){ today.add(this); } else { today.set(this); } if (this.timezone) { this.timezone = this.timezone.toUpperCase(); var offset = $D.getTimezoneOffset(this.timezone); var timezone; if (today.hasDaylightSavingTime()) { // lets check that we're being sane with timezone setting timezone = $D.getTimezoneAbbreviation(offset, today.isDaylightSavingTime()); if (timezone !== this.timezone) { // bugger, we're in a place where things like EST vs EDT matters. if (today.isDaylightSavingTime()) { today.addHours(-1); } else { today.addHours(1); } } } today.setTimezoneOffset(offset); } return today; } }; }()); (function () { var $D = Date; $D.Grammar = {}; var _ = $D.Parsing.Operators, g = $D.Grammar, t = $D.Translator, _fn; // Allow rolling up into general purpose rules _fn = function () { return _.each(_.any.apply(null, arguments), _.not(g.ctoken2("timeContext"))); }; g.datePartDelimiter = _.rtoken(/^([\s\-\.\,\/\x27]+)/); g.timePartDelimiter = _.stoken(":"); g.whiteSpace = _.rtoken(/^\s*/); g.generalDelimiter = _.rtoken(/^(([\s\,]|at|@|on)+)/); var _C = {}; g.ctoken = function (keys) { var fn = _C[keys]; if (! fn) { var c = Date.CultureInfo.regexPatterns; var kx = keys.split(/\s+/), px = []; for (var i = 0; i < kx.length ; i++) { px.push(_.replace(_.rtoken(c[kx[i]]), kx[i])); } fn = _C[keys] = _.any.apply(null, px); } return fn; }; g.ctoken2 = function (key) { return _.rtoken(Date.CultureInfo.regexPatterns[key]); }; var cacheProcessRtoken = function (key, token, type, eachToken) { if (eachToken) { g[key] = _.cache(_.process(_.each(_.rtoken(token),_.optional(g.ctoken2(eachToken))), type)); } else { g[key] = _.cache(_.process(_.rtoken(token), type)); } }; var cacheProcessCtoken = function (token, type) { return _.cache(_.process(g.ctoken2(token), type)); }; var _F = {}; //function cache var _get = function (f) { _F[f] = (_F[f] || g.format(f)[0]); return _F[f]; }; g.allformats = function (fx) { var rx = []; if (fx instanceof Array) { for (var i = 0; i < fx.length; i++) { rx.push(_get(fx[i])); } } else { rx.push(_get(fx)); } return rx; }; g.formats = function (fx) { if (fx instanceof Array) { var rx = []; for (var i = 0 ; i < fx.length ; i++) { rx.push(_get(fx[i])); } return _.any.apply(null, rx); } else { return _get(fx); } }; var grammarFormats = { timeFormats: function(){ var i, RTokenKeys = [ "h", "hh", "H", "HH", "m", "mm", "s", "ss", "ss.s", "z", "zz" ], RToken = [ /^(0[0-9]|1[0-2]|[1-9])/, /^(0[0-9]|1[0-2])/, /^([0-1][0-9]|2[0-3]|[0-9])/, /^([0-1][0-9]|2[0-3])/, /^([0-5][0-9]|[0-9])/, /^[0-5][0-9]/, /^([0-5][0-9]|[0-9])/, /^[0-5][0-9]/, /^[0-5][0-9]\.[0-9]{1,3}/, /^((\+|\-)\s*\d\d\d\d)|((\+|\-)\d\d\:?\d\d)/, /^((\+|\-)\s*\d\d\d\d)|((\+|\-)\d\d\:?\d\d)/ ], tokens = [ t.hour, t.hour, t.hour, t.hour, t.minute, t.minute, t.second, t.second, t.secondAndMillisecond, t.timezone, t.timezone ]; for (i=0; i < RTokenKeys.length; i++) { cacheProcessRtoken(RTokenKeys[i], RToken[i], tokens[i]); } g.hms = _.cache(_.sequence([g.H, g.m, g.s], g.timePartDelimiter)); g.t = cacheProcessCtoken("shortMeridian", t.meridian); g.tt = cacheProcessCtoken("longMeridian", t.meridian); g.zzz = cacheProcessCtoken("timezone", t.timezone); g.timeSuffix = _.each(_.ignore(g.whiteSpace), _.set([ g.tt, g.zzz ])); g.time = _.each(_.optional(_.ignore(_.stoken("T"))), g.hms, g.timeSuffix); }, dateFormats: function () { // pre-loaded rules for different date part order preferences var _setfn = function () { return _.set(arguments, g.datePartDelimiter); }; var i, RTokenKeys = [ "d", "dd", "M", "MM", "y", "yy", "yyy", "yyyy" ], RToken = [ /^([0-2]\d|3[0-1]|\d)/, /^([0-2]\d|3[0-1])/, /^(1[0-2]|0\d|\d)/, /^(1[0-2]|0\d)/, /^(\d+)/, /^(\d\d)/, /^(\d\d?\d?\d?)/, /^(\d\d\d\d)/ ], tokens = [ t.day, t.day, t.month, t.month, t.year, t.year, t.year, t.year ], eachToken = [ "ordinalSuffix", "ordinalSuffix" ]; for (i=0; i < RTokenKeys.length; i++) { cacheProcessRtoken(RTokenKeys[i], RToken[i], tokens[i], eachToken[i]); } g.MMM = g.MMMM = _.cache(_.process(g.ctoken("jan feb mar apr may jun jul aug sep oct nov dec"), t.month)); g.ddd = g.dddd = _.cache(_.process(g.ctoken("sun mon tue wed thu fri sat"), function (s) { return function () { this.weekday = s; }; } )); g.day = _fn(g.d, g.dd); g.month = _fn(g.M, g.MMM); g.year = _fn(g.yyyy, g.yy); g.mdy = _setfn(g.ddd, g.month, g.day, g.year); g.ymd = _setfn(g.ddd, g.year, g.month, g.day); g.dmy = _setfn(g.ddd, g.day, g.month, g.year); g.date = function (s) { return ((g[Date.CultureInfo.dateElementOrder] || g.mdy).call(this, s)); }; }, relative: function () { // relative date / time expressions g.orientation = _.process(g.ctoken("past future"), function (s) { return function () { this.orient = s; }; } ); g.operator = _.process(g.ctoken("add subtract"), function (s) { return function () { this.operator = s; }; } ); g.rday = _.process(g.ctoken("yesterday tomorrow today now"), t.rday); g.unit = _.process(g.ctoken("second minute hour day week month year"), function (s) { return function () { this.unit = s; }; } ); } }; g.buildGrammarFormats = function () { // these need to be rebuilt every time the language changes. _C = {}; grammarFormats.timeFormats(); grammarFormats.dateFormats(); grammarFormats.relative(); g.value = _.process(_.rtoken(/^([-+]?\d+)?(st|nd|rd|th)?/), function (s) { return function () { this.value = s.replace(/\D/g, ""); }; } ); g.expression = _.set([g.rday, g.operator, g.value, g.unit, g.orientation, g.ddd, g.MMM ]); g.format = _.process(_.many( _.any( // translate format specifiers into grammar rules _.process( _.rtoken(/^(dd?d?d?(?!e)|MM?M?M?|yy?y?y?|hh?|HH?|mm?|ss?|tt?|zz?z?)/), function (fmt) { if (g[fmt]) { return g[fmt]; } else { throw $D.Parsing.Exception(fmt); } } ), // translate separator tokens into token rules _.process(_.rtoken(/^[^dMyhHmstz]+/), // all legal separators function (s) { return _.ignore(_.stoken(s)); } ) ) ), // construct the parser ... function (rules) { return _.process(_.each.apply(null, rules), t.finishExact); } ); // starting rule for general purpose grammar g._start = _.process(_.set([ g.date, g.time, g.expression ], g.generalDelimiter, g.whiteSpace), t.finish); }; g.buildGrammarFormats(); // parsing date format specifiers - ex: "h:m:s tt" // this little guy will generate a custom parser based // on the format string, ex: g.format("h:m:s tt") // check for these formats first g._formats = g.formats([ "\"yyyy-MM-ddTHH:mm:ssZ\"", "yyyy-MM-ddTHH:mm:ss.sz", "yyyy-MM-ddTHH:mm:ssZ", "yyyy-MM-ddTHH:mm:ssz", "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-ddTHH:mmZ", "yyyy-MM-ddTHH:mmz", "yyyy-MM-ddTHH:mm", "ddd, MMM dd, yyyy H:mm:ss tt", "ddd MMM d yyyy HH:mm:ss zzz", "MMddyyyy", "ddMMyyyy", "Mddyyyy", "ddMyyyy", "Mdyyyy", "dMyyyy", "yyyy", "Mdyy", "dMyy", "d" ]); // real starting rule: tries selected formats first, // then general purpose rule g.start = function (s) { try { var r = g._formats.call({}, s); if (r[1].length === 0) { return r; } } catch (e) {} return g._start.call({}, s); }; }()); (function () { var $D = Date; /** * @desc Converts the specified string value into its JavaScript Date equivalent using CultureInfo specific format information. * * Example

	///////////
	// Dates //
	///////////

	// 15-Oct-2004
	var d1 = Date.parse("10/15/2004");

	// 15-Oct-2004
	var d1 = Date.parse("15-Oct-2004");

	// 15-Oct-2004
	var d1 = Date.parse("2004.10.15");

	//Fri Oct 15, 2004
	var d1 = Date.parse("Fri Oct 15, 2004");

	///////////
	// Times //
	///////////

	// Today at 10 PM.
	var d1 = Date.parse("10 PM");

	// Today at 10:30 PM.
	var d1 = Date.parse("10:30 P.M.");

	// Today at 6 AM.
	var d1 = Date.parse("06am");

	/////////////////////
	// Dates and Times //
	/////////////////////

	// 8-July-2004 @ 10:30 PM
	var d1 = Date.parse("July 8th, 2004, 10:30 PM");

	// 1-July-2004 @ 10:30 PM
	var d1 = Date.parse("2004-07-01T22:30:00");

	////////////////////
	// Relative Dates //
	////////////////////

	// Returns today's date. The string "today" is culture specific.
	var d1 = Date.parse("today");

	// Returns yesterday's date. The string "yesterday" is culture specific.
	var d1 = Date.parse("yesterday");

	// Returns the date of the next thursday.
	var d1 = Date.parse("Next thursday");

	// Returns the date of the most previous monday.
	var d1 = Date.parse("last monday");

	// Returns today's day + one year.
	var d1 = Date.parse("next year");

	///////////////
	// Date Math //
	///////////////

	// Today + 2 days
	var d1 = Date.parse("t+2");

	// Today + 2 days
	var d1 = Date.parse("today + 2 days");

	// Today + 3 months
	var d1 = Date.parse("t+3m");

	// Today - 1 year
	var d1 = Date.parse("today - 1 year");

	// Today - 1 year
	var d1 = Date.parse("t-1y"); 


	/////////////////////////////
	// Partial Dates and Times //
	/////////////////////////////

	// July 15th of this year.
	var d1 = Date.parse("July 15");

	// 15th day of current day and year.
	var d1 = Date.parse("15");

	// July 1st of current year at 10pm.
	var d1 = Date.parse("7/1 10pm");
	
* * @param {String} The string value to convert into a Date object [Required] * @return {Date} A Date object or null if the string cannot be converted into a Date. */ var parseUtils = { removeOrds: function (s) { ords = s.match(/\b(\d+)(?:st|nd|rd|th)\b/); // find ordinal matches s = ((ords && ords.length === 2) ? s.replace(ords[0], ords[1]) : s); return s; }, grammarParser: function (s) { var r = null; try { r = $D.Grammar.start.call({}, s.replace(/^\s*(\S*(\s+\S+)*)\s*$/, "$1")); } catch (e) { return null; } return ((r[1].length === 0) ? r[0] : null); }, nativeFallback: function(s) { var t; try { // ok we haven't parsed it, last ditch attempt with the built-in parser. t = Date._parse(s); return (t || t === 0) ? new Date(t) : null; } catch (e) { return null; } } }; function parse (s) { var d; if (!s) { return null; } if (s instanceof Date) { return s.clone(); } if (s.length >= 4 && s.charAt(0) !== "0" && s.charAt(0) !== "+"&& s.charAt(0) !== "-") { // ie: 2004 will pass, 0800 won't. // Start with specific formats d = $D.Parsing.ISO.parse(s) || $D.Parsing.Numeric.parse(s); } if (d instanceof Date && !isNaN(d.getTime())) { return d; } else { // find ordinal dates (1st, 3rd, 8th, etc and remove them as they cause parsing issues) s = $D.Parsing.Normalizer.parse(parseUtils.removeOrds(s)); d = parseUtils.grammarParser(s); if (d !== null) { return d; } else { return parseUtils.nativeFallback(s); } } } if (!$D._parse) { $D._parse = $D.parse; } $D.parse = parse; Date.getParseFunction = function (fx) { var fns = Date.Grammar.allformats(fx); return function (s) { var r = null; for (var i = 0; i < fns.length; i++) { try { r = fns[i].call({}, s); } catch (e) { continue; } if (r[1].length === 0) { return r[0]; } } return null; }; }; /** * Converts the specified string value into its JavaScript Date equivalent using the specified format {String} or formats {Array} and the CultureInfo specific format information. * The format of the string value must match one of the supplied formats exactly. * * Example

	// 15-Oct-2004
	var d1 = Date.parseExact("10/15/2004", "M/d/yyyy");

	// 15-Oct-2004
	var d1 = Date.parse("15-Oct-2004", "M-ddd-yyyy");

	// 15-Oct-2004
	var d1 = Date.parse("2004.10.15", "yyyy.MM.dd");

	// Multiple formats
	var d1 = Date.parseExact("10/15/2004", ["M/d/yyyy", "MMMM d, yyyy"]);
	
* * @param {String} The string value to convert into a Date object [Required]. * @param {Object} The expected format {String} or an array of expected formats {Array} of the date string [Required]. * @return {Date} A Date object or null if the string cannot be converted into a Date. */ $D.parseExact = function (s, fx) { return $D.getParseFunction(fx)(s); }; }()); (function () { var $D = Date, $P = $D.prototype, // $C = $D.CultureInfo, // not used atm p = function (s, l) { if (!l) { l = 2; } return ("000" + s).slice(l * -1); }; /** * Converts a PHP format string to Java/.NET format string. * A PHP format string can be used with ._format or .format. * A Java/.NET format string can be used with .toString(). * The .parseExact function will only accept a Java/.NET format string * * Example * var f1 = "%m/%d/%y" * var f2 = Date.normalizeFormat(f1); // "MM/dd/yy" * * new Date().format(f1); // "04/13/08" * new Date()._format(f1); // "04/13/08" * new Date().toString(f2); // "04/13/08" * * var date = Date.parseExact("04/13/08", f2); // Sun Apr 13 2008 * * @param {String} A PHP format string consisting of one or more format spcifiers. * @return {String} The PHP format converted to a Java/.NET format string. */ var normalizerSubstitutions = { "d" : "dd", "%d": "dd", "D" : "ddd", "%a": "ddd", "j" : "dddd", "l" : "dddd", "%A": "dddd", "S" : "S", "F" : "MMMM", "%B": "MMMM", "m" : "MM", "%m": "MM", "M" : "MMM", "%b": "MMM", "%h": "MMM", "n" : "M", "Y" : "yyyy", "%Y": "yyyy", "y" : "yy", "%y": "yy", "g" : "h", "%I": "h", "G" : "H", "h" : "hh", "H" : "HH", "%H": "HH", "i" : "mm", "%M": "mm", "s" : "ss", "%S": "ss", "%r": "hh:mm tt", "%R": "H:mm", "%T": "H:mm:ss", "%X": "t", "%x": "d", "%e": "d", "%D": "MM/dd/yy", "%n": "\\n", "%t": "\\t", "e" : "z", "T" : "z", "%z": "z", "%Z": "z", "Z" : "ZZ", "N" : "u", "w" : "u", "%w": "u", "W" : "W", "%V": "W" }; var normalizer = { substitutes: function (m) { return normalizerSubstitutions[m]; }, interpreted: function (m, x) { var y; switch (m) { case "%u": return x.getDay() + 1; case "z": return x.getOrdinalNumber(); case "%j": return p(x.getOrdinalNumber(), 3); case "%U": var d1 = x.clone().set({month: 0, day: 1}).addDays(-1).moveToDayOfWeek(0), d2 = x.clone().addDays(1).moveToDayOfWeek(0, -1); return (d2 < d1) ? "00" : p((d2.getOrdinalNumber() - d1.getOrdinalNumber()) / 7 + 1); case "%W": return p(x.getWeek()); case "t": return $D.getDaysInMonth(x.getFullYear(), x.getMonth()); case "o": case "%G": return x.setWeek(x.getISOWeek()).toString("yyyy"); case "%g": return x._format("%G").slice(-2); case "a": case "%p": return t("tt").toLowerCase(); case "A": return t("tt").toUpperCase(); case "u": return p(x.getMilliseconds(), 3); case "I": return (x.isDaylightSavingTime()) ? 1 : 0; case "O": return x.getUTCOffset(); case "P": y = x.getUTCOffset(); return y.substring(0, y.length - 2) + ":" + y.substring(y.length - 2); case "B": var now = new Date(); return Math.floor(((now.getHours() * 3600) + (now.getMinutes() * 60) + now.getSeconds() + (now.getTimezoneOffset() + 60) * 60) / 86.4); case "c": return x.toISOString().replace(/\"/g, ""); case "U": return $D.strtotime("now"); case "%c": return t("d") + " " + t("t"); case "%C": return Math.floor(x.getFullYear() / 100 + 1); } }, shouldOverrideDefaults: function (m) { switch (m) { case "%e": return true; default: return false; } }, parse: function (m, context) { var formatString, c = context || new Date(); formatString = normalizer.substitutes(m); if (formatString) { return formatString; } formatString = normalizer.interpreted(m, c); if (formatString) { return formatString; } else { return m; } } }; $D.normalizeFormat = function (format, context) { return format.replace(/(%|\\)?.|%%/g, function(t){ return normalizer.parse(t, context); }); }; /** * Format a local Unix timestamp according to locale settings * * Example: * Date.strftime("%m/%d/%y", new Date()); // "04/13/08" * Date.strftime("c", "2008-04-13T17:52:03Z"); // "04/13/08" * * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @param {Number|String} The number representing the number of seconds that have elapsed since January 1, 1970 (local time). * @return {String} A string representation of the current Date object. */ $D.strftime = function (format, time) { var d = Date.parse(time); return d._format(format); }; /** * Parse any textual datetime description into a Unix timestamp. * A Unix timestamp is the number of seconds that have elapsed since January 1, 1970 (midnight UTC/GMT). * * Example: * Date.strtotime("04/13/08"); // 1208044800 * Date.strtotime("1970-01-01T00:00:00Z"); // 0 * * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @param {Object} A string or date object. * @return {String} A string representation of the current Date object. */ $D.strtotime = function (time) { var d = $D.parse(time); return Math.round($D.UTC(d.getUTCFullYear(), d.getUTCMonth(), d.getUTCDate(), d.getUTCHours(), d.getUTCMinutes(), d.getUTCSeconds(), d.getUTCMilliseconds()) / 1000); }; /** * Converts the value of the current Date object to its equivalent string representation using a PHP/Unix style of date format specifiers. * Format Specifiers * Format Description Example * ------ --------------------------------------------------------------------------- ----------------------- * %a abbreviated weekday name according to the current localed "Mon" through "Sun" * %A full weekday name according to the current localed "Sunday" through "Saturday" * %b abbreviated month name according to the current localed "Jan" through "Dec" * %B full month name according to the current locale "January" through "December" * %c preferred date and time representation for the current locale "4/13/2008 12:33 PM" * %C century number (the year divided by 100 and truncated to an integer) "00" to "99" * %d day of the month as a decimal number "01" to "31" * %D same as %m/%d/%y "04/13/08" * %e day of the month as a decimal number, a single digit is preceded by a space "1" to "31" * %g like %G, but without the century "08" * %G The 4-digit year corresponding to the ISO week number (see %V). "2008" * This has the same format and value as %Y, except that if the ISO week number * belongs to the previous or next year, that year is used instead. * %h same as %b "Jan" through "Dec" * %H hour as a decimal number using a 24-hour clock. "00" to "23" * %I hour as a decimal number using a 12-hour clock. "01" to "12" * %j day of the year as a decimal number. "001" to "366" * %m month as a decimal number. "01" to "12" * %M minute as a decimal number. "00" to "59" * %n newline character "\n" * %p either "am" or "pm" according to the given time value, or the "am" or "pm" * corresponding strings for the current locale. * %r time in a.m. and p.m. notation "8:44 PM" * %R time in 24 hour notation "20:44" * %S second as a decimal number "00" to "59" * %t tab character "\t" * %T current time, equal to %H:%M:%S "12:49:11" * %u weekday as a decimal number ["1", "7"], with "1" representing Monday "1" to "7" * %U week number of the current year as a decimal number, starting with the "0" to ("52" or "53") * first Sunday as the first day of the first week * %V The ISO 8601:1988 week number of the current year as a decimal number, "00" to ("52" or "53") * range 01 to 53, where week 1 is the first week that has at least 4 days * in the current year, and with Monday as the first day of the week. * (Use %G or %g for the year component that corresponds to the week number * for the specified timestamp.) * %W week number of the current year as a decimal number, starting with the "00" to ("52" or "53") * first Monday as the first day of the first week * %w day of the week as a decimal, Sunday being "0" "0" to "6" * %x preferred date representation for the current locale without the time "4/13/2008" * %X preferred time representation for the current locale without the date "12:53:05" * %y year as a decimal number without a century "00" "99" * %Y year as a decimal number including the century "2008" * %Z time zone or name or abbreviation "UTC", "EST", "PST" * %z same as %Z * %% a literal "%" characters "%" * d Day of the month, 2 digits with leading zeros "01" to "31" * D A textual representation of a day, three letters "Mon" through "Sun" * j Day of the month without leading zeros "1" to "31" * l A full textual representation of the day of the week (lowercase "L") "Sunday" through "Saturday" * N ISO-8601 numeric representation of the day of the week (added in PHP 5.1.0) "1" (for Monday) through "7" (for Sunday) * S English ordinal suffix for the day of the month, 2 characters "st", "nd", "rd" or "th". Works well with j * w Numeric representation of the day of the week "0" (for Sunday) through "6" (for Saturday) * z The day of the year (starting from "0") "0" through "365" * W ISO-8601 week number of year, weeks starting on Monday "00" to ("52" or "53") * F A full textual representation of a month, such as January or March "January" through "December" * m Numeric representation of a month, with leading zeros "01" through "12" * M A short textual representation of a month, three letters "Jan" through "Dec" * n Numeric representation of a month, without leading zeros "1" through "12" * t Number of days in the given month "28" through "31" * L Whether it's a leap year "1" if it is a leap year, "0" otherwise * o ISO-8601 year number. This has the same value as Y, except that if the "2008" * ISO week number (W) belongs to the previous or next year, that year * is used instead. * Y A full numeric representation of a year, 4 digits "2008" * y A two digit representation of a year "08" * a Lowercase Ante meridiem and Post meridiem "am" or "pm" * A Uppercase Ante meridiem and Post meridiem "AM" or "PM" * B Swatch Internet time "000" through "999" * g 12-hour format of an hour without leading zeros "1" through "12" * G 24-hour format of an hour without leading zeros "0" through "23" * h 12-hour format of an hour with leading zeros "01" through "12" * H 24-hour format of an hour with leading zeros "00" through "23" * i Minutes with leading zeros "00" to "59" * s Seconds, with leading zeros "00" through "59" * u Milliseconds "54321" * e Timezone identifier "UTC", "EST", "PST" * I Whether or not the date is in daylight saving time (uppercase i) "1" if Daylight Saving Time, "0" otherwise * O Difference to Greenwich time (GMT) in hours "+0200", "-0600" * P Difference to Greenwich time (GMT) with colon between hours and minutes "+02:00", "-06:00" * T Timezone abbreviation "UTC", "EST", "PST" * Z Timezone offset in seconds. The offset for timezones west of UTC is "-43200" through "50400" * always negative, and for those east of UTC is always positive. * c ISO 8601 date "2004-02-12T15:19:21+00:00" * r RFC 2822 formatted date "Thu, 21 Dec 2000 16:01:07 +0200" * U Seconds since the Unix Epoch (January 1 1970 00:00:00 GMT) "0" * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @return {String} A string representation of the current Date object. */ var formatReplace = function (context) { return function (m) { var formatString, override = false; if (m.charAt(0) === "\\" || m.substring(0, 2) === "%%") { return m.replace("\\", "").replace("%%", "%"); } override = normalizer.shouldOverrideDefaults(m); formatString = $D.normalizeFormat(m, context); if (formatString) { return context.toString(formatString, override); } }; }; $P._format = function (format) { var formatter = formatReplace(this); if (!format) { return this._toString(); } else { return format.replace(/(%|\\)?.|%%/g, formatter); } }; if (!$P.format) { $P.format = $P._format; } }()); (function () { "use strict"; var gFn = function (attr) { return function () { return this[attr]; }; }; var sFn = function (attr) { return function (val) { this[attr] = val; return this; }; }; var attrs = ["years", "months", "days", "hours", "minutes", "seconds", "milliseconds"]; var addSetFuncs = function (context, attrs) { for (var i = 0; i < attrs.length ; i++) { var $a = attrs[i], $b = $a.slice(0, 1).toUpperCase() + $a.slice(1); context.prototype[$a] = 0; context.prototype["get" + $b] = gFn($a); context.prototype["set" + $b] = sFn($a); } }; /** * new TimeSpan(milliseconds); * new TimeSpan(days, hours, minutes, seconds); * new TimeSpan(days, hours, minutes, seconds, milliseconds); */ var TimeSpan = function (days, hours, minutes, seconds, milliseconds) { if (arguments.length === 1 && typeof days === "number") { var orient = (days < 0) ? -1 : +1; var millsLeft = Math.abs(days); this.setDays(Math.floor(millsLeft / 86400000) * orient); millsLeft = millsLeft % 86400000; this.setHours(Math.floor(millsLeft / 3600000) * orient); millsLeft = millsLeft % 3600000; this.setMinutes(Math.floor(millsLeft / 60000) * orient); millsLeft = millsLeft % 60000; this.setSeconds(Math.floor(millsLeft / 1000) * orient); millsLeft = millsLeft % 1000; this.setMilliseconds(millsLeft * orient); } else { this.set(days, hours, minutes, seconds, milliseconds); } this.getTotalMilliseconds = function () { return (this.getDays() * 86400000) + (this.getHours() * 3600000) + (this.getMinutes() * 60000) + (this.getSeconds() * 1000); }; this.compareTo = function (time) { var t1 = new Date(1970, 1, 1, this.getHours(), this.getMinutes(), this.getSeconds()), t2; if (time === null) { t2 = new Date(1970, 1, 1, 0, 0, 0); } else { t2 = new Date(1970, 1, 1, time.getHours(), time.getMinutes(), time.getSeconds()); } return (t1 < t2) ? -1 : (t1 > t2) ? 1 : 0; }; this.equals = function (time) { return (this.compareTo(time) === 0); }; this.add = function (time) { return (time === null) ? this : this.addSeconds(time.getTotalMilliseconds() / 1000); }; this.subtract = function (time) { return (time === null) ? this : this.addSeconds(-time.getTotalMilliseconds() / 1000); }; this.addDays = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 86400000)); }; this.addHours = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 3600000)); }; this.addMinutes = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 60000)); }; this.addSeconds = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 1000)); }; this.addMilliseconds = function (n) { return new TimeSpan(this.getTotalMilliseconds() + n); }; this.get12HourHour = function () { return (this.getHours() > 12) ? this.getHours() - 12 : (this.getHours() === 0) ? 12 : this.getHours(); }; this.getDesignator = function () { return (this.getHours() < 12) ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator; }; this.toString = function (format) { this._toString = function () { if (this.getDays() !== null && this.getDays() > 0) { return this.getDays() + "." + this.getHours() + ":" + this.p(this.getMinutes()) + ":" + this.p(this.getSeconds()); } else { return this.getHours() + ":" + this.p(this.getMinutes()) + ":" + this.p(this.getSeconds()); } }; this.p = function (s) { return (s.toString().length < 2) ? "0" + s : s; }; var me = this; return format ? format.replace(/dd?|HH?|hh?|mm?|ss?|tt?/g, function (format) { switch (format) { case "d": return me.getDays(); case "dd": return me.p(me.getDays()); case "H": return me.getHours(); case "HH": return me.p(me.getHours()); case "h": return me.get12HourHour(); case "hh": return me.p(me.get12HourHour()); case "m": return me.getMinutes(); case "mm": return me.p(me.getMinutes()); case "s": return me.getSeconds(); case "ss": return me.p(me.getSeconds()); case "t": return ((me.getHours() < 12) ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator).substring(0, 1); case "tt": return (me.getHours() < 12) ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator; } } ) : this._toString(); }; return this; }; addSetFuncs(TimeSpan, attrs.slice(2)); TimeSpan.prototype.set = function (days, hours, minutes, seconds, milliseconds){ this.setDays(days || this.getDays()); this.setHours(hours || this.getHours()); this.setMinutes(minutes || this.getMinutes()); this.setSeconds(seconds || this.getSeconds()); this.setMilliseconds(milliseconds || this.getMilliseconds()); }; /** * Gets the time of day for this date instances. * @return {TimeSpan} TimeSpan */ Date.prototype.getTimeOfDay = function () { return new TimeSpan(0, this.getHours(), this.getMinutes(), this.getSeconds(), this.getMilliseconds()); }; Date.TimeSpan = TimeSpan; if (typeof window !== "undefined" ) { // keeping API compatible for v1.x window.TimeSpan = TimeSpan; } }()); (function () { "use strict"; var attrs = ["years", "months", "days", "hours", "minutes", "seconds", "milliseconds"]; var gFn = function (attr) { return function () { return this[attr]; }; }; var sFn = function (attr) { return function (val) { this[attr] = val; return this; }; }; var addSetFuncs = function (context, attrs) { for (var i = 0; i < attrs.length ; i++) { var $a = attrs[i], $b = $a.slice(0, 1).toUpperCase() + $a.slice(1); context.prototype[$a] = 0; context.prototype["get" + $b] = gFn($a); context.prototype["set" + $b] = sFn($a); } }; var setMonthsAndYears = function (orient, d1, d2, context) { function inc() { d1.addMonths(-orient); context.months++; if (context.months === 12) { context.years++; context.months = 0; } } if (orient === +1) { while (d1 > d2) { inc(); } } else { while (d1 < d2) { inc(); } } context.months--; context.months *= orient; context.years *= orient; }; var adjustForDST = function(orient, startDate, endDate) { var hasDSTMismatch = (false === (startDate.isDaylightSavingTime() === endDate.isDaylightSavingTime())); if (hasDSTMismatch && orient === 1) { startDate.addHours(-1); } else if (hasDSTMismatch) { startDate.addHours(1); } }; /** * TimePeriod(startDate, endDate); * TimePeriod(years, months, days, hours, minutes, seconds, milliseconds); */ var TimePeriod = function (years, months, days, hours, minutes, seconds, milliseconds) { if (arguments.length === 7) { this.set(years, months, days, hours, minutes, seconds, milliseconds); } else if (arguments.length === 2 && arguments[0] instanceof Date && arguments[1] instanceof Date) { var startDate = arguments[0].clone(); var endDate = arguments[1].clone(); var orient = (startDate > endDate) ? +1 : -1; this.dates = { start: arguments[0].clone(), end: arguments[1].clone() }; setMonthsAndYears(orient, startDate, endDate, this); adjustForDST(orient, startDate, endDate); // // TODO - adjust for DST var diff = endDate - startDate; if (diff !== 0) { var ts = new TimeSpan(diff); this.set(this.years, this.months, ts.getDays(), ts.getHours(), ts.getMinutes(), ts.getSeconds(), ts.getMilliseconds()); } } return this; }; // create all the set functions. addSetFuncs(TimePeriod, attrs); TimePeriod.prototype.set = function (years, months, days, hours, minutes, seconds, milliseconds){ this.setYears(years || this.getYears()); this.setMonths(months || this.getMonths()); this.setDays(days || this.getDays()); this.setHours(hours || this.getHours()); this.setMinutes(minutes || this.getMinutes()); this.setSeconds(seconds || this.getSeconds()); this.setMilliseconds(milliseconds || this.getMilliseconds()); }; Date.TimePeriod = TimePeriod; if (typeof window !== "undefined") { // keeping API compatible for v1.x window.TimePeriod = TimePeriod; } }()); ================================================ FILE: build/date-mn-MN.js ================================================ /** * @overview datejs * @version 1.0.0-rc3 * @author Gregory Wild-Smith * @copyright 2015 Gregory Wild-Smith * @license MIT * @homepage https://github.com/abritinthebay/datejs */ /* * DateJS Culture String File * Country Code: mn-MN * Name: Mongolian (Cyrillic, Mongolia) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["mn-MN"] = { "name": "mn-MN", "englishName": "Mongolian (Cyrillic, Mongolia)", "nativeName": "Монгол хэл (Монгол улс)", "Sunday": "Ням", "Monday": "Даваа", "Tuesday": "Мягмар", "Wednesday": "Лхагва", "Thursday": "Пүрэв", "Friday": "Баасан", "Saturday": "Бямба", "Sun": "Ня", "Mon": "Да", "Tue": "Мя", "Wed": "Лх", "Thu": "Пү", "Fri": "Ба", "Sat": "Бя", "Su": "Ня", "Mo": "Да", "Tu": "Мя", "We": "Лх", "Th": "Пү", "Fr": "Ба", "Sa": "Бя", "S_Sun_Initial": "Н", "M_Mon_Initial": "Д", "T_Tue_Initial": "М", "W_Wed_Initial": "Л", "T_Thu_Initial": "П", "F_Fri_Initial": "Б", "S_Sat_Initial": "Б", "January": "1 дүгээр сар", "February": "2 дугаар сар", "March": "3 дугаар сар", "April": "4 дүгээр сар", "May": "5 дугаар сар", "June": "6 дугаар сар", "July": "7 дугаар сар", "August": "8 дугаар сар", "September": "9 дүгээр сар", "October": "10 дугаар сар", "November": "11 дүгээр сар", "December": "12 дугаар сар", "Jan_Abbr": "I", "Feb_Abbr": "II", "Mar_Abbr": "III", "Apr_Abbr": "IV", "May_Abbr": "V", "Jun_Abbr": "VI", "Jul_Abbr": "VII", "Aug_Abbr": "VШ", "Sep_Abbr": "IX", "Oct_Abbr": "X", "Nov_Abbr": "XI", "Dec_Abbr": "XII", "AM": "", "PM": "", "firstDayOfWeek": 1, "twoDigitYearMax": 2029, "mdy": "ymd", "M/d/yyyy": "yy.MM.dd", "dddd, MMMM dd, yyyy": "yyyy 'оны' MMMM d", "h:mm tt": "H:mm", "h:mm:ss tt": "H:mm:ss", "dddd, MMMM dd, yyyy h:mm:ss tt": "yyyy 'оны' MMMM d H:mm:ss", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "d MMMM", "MMMM, yyyy": "yyyy 'он' MMMM", "/jan(uary)?/": "1 дүгээр сар", "/feb(ruary)?/": "2 дугаар сар", "/mar(ch)?/": "3 дугаар сар", "/apr(il)?/": "4 дүгээр сар", "/may/": "5 дугаар сар", "/jun(e)?/": "6 дугаар сар", "/jul(y)?/": "7 дугаар сар", "/aug(ust)?/": "8 дугаар сар", "/sep(t(ember)?)?/": "9 дүгээр сар", "/oct(ober)?/": "10 дугаар сар", "/nov(ember)?/": "11 дүгээр сар", "/dec(ember)?/": "12 дугаар сар", "/^su(n(day)?)?/": "^ням", "/^mo(n(day)?)?/": "^даваа", "/^tu(e(s(day)?)?)?/": "^мягмар", "/^we(d(nesday)?)?/": "^лхагва", "/^th(u(r(s(day)?)?)?)?/": "^пүрэв", "/^fr(i(day)?)?/": "^баасан", "/^sa(t(urday)?)?/": "^бямба", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "mn-MN"; /** * @overview datejs * @version 1.0.0-rc3 * @author Gregory Wild-Smith * @copyright 2015 Gregory Wild-Smith * @license MIT * @homepage https://github.com/abritinthebay/datejs */(function () { var $D = Date; var lang = Date.CultureStrings ? Date.CultureStrings.lang : null; var loggedKeys = {}; // for debug purposes. var getText = { getFromKey: function (key, countryCode) { var output; if (Date.CultureStrings && Date.CultureStrings[countryCode] && Date.CultureStrings[countryCode][key]) { output = Date.CultureStrings[countryCode][key]; } else { output = getText.buildFromDefault(key); } if (key.charAt(0) === "/") { // Assume it's a regex output = getText.buildFromRegex(key, countryCode); } return output; }, getFromObjectValues: function (obj, countryCode) { var key, output = {}; for(key in obj) { if (obj.hasOwnProperty(key)) { output[key] = getText.getFromKey(obj[key], countryCode); } } return output; }, getFromObjectKeys: function (obj, countryCode) { var key, output = {}; for(key in obj) { if (obj.hasOwnProperty(key)) { output[getText.getFromKey(key, countryCode)] = obj[key]; } } return output; }, getFromArray: function (arr, countryCode) { var output = []; for (var i=0; i < arr.length; i++){ if (i in arr) { output[i] = getText.getFromKey(arr[i], countryCode); } } return output; }, buildFromDefault: function (key) { var output, length, split, last; switch(key) { case "name": output = "en-US"; break; case "englishName": output = "English (United States)"; break; case "nativeName": output = "English (United States)"; break; case "twoDigitYearMax": output = 2049; break; case "firstDayOfWeek": output = 0; break; default: output = key; split = key.split("_"); length = split.length; if (length > 1 && key.charAt(0) !== "/") { // if the key isn't a regex and it has a split. last = split[(length - 1)].toLowerCase(); if (last === "initial" || last === "abbr") { output = split[0]; } } break; } return output; }, buildFromRegex: function (key, countryCode) { var output; if (Date.CultureStrings && Date.CultureStrings[countryCode] && Date.CultureStrings[countryCode][key]) { output = new RegExp(Date.CultureStrings[countryCode][key], "i"); } else { output = new RegExp(key.replace(new RegExp("/", "g"),""), "i"); } return output; } }; var shallowMerge = function (obj1, obj2) { for (var attrname in obj2) { if (obj2.hasOwnProperty(attrname)) { obj1[attrname] = obj2[attrname]; } } }; var __ = function (key, language) { var countryCode = (language) ? language : lang; loggedKeys[key] = key; if (typeof key === "object") { if (key instanceof Array) { return getText.getFromArray(key, countryCode); } else { return getText.getFromObjectKeys(key, countryCode); } } else { return getText.getFromKey(key, countryCode); } }; var loadI18nScript = function (code) { // paatterned after jQuery's getScript. var url = Date.Config.i18n + code + ".js"; var head = document.getElementsByTagName("head")[0] || document.documentElement; var script = document.createElement("script"); script.src = url; var completed = false; var events = { done: function (){} // placeholder function }; // Attach handlers for all browsers script.onload = script.onreadystatechange = function() { if ( !completed && (!this.readyState || this.readyState === "loaded" || this.readyState === "complete") ) { events.done(); head.removeChild(script); } }; setTimeout(function() { head.insertBefore(script, head.firstChild); }, 0); // allows return to execute first return { done: function (cb) { events.done = function() { if (cb) { setTimeout(cb,0); } }; } }; }; var buildInfo = { buildFromMethodHash: function (obj) { var key; for(key in obj) { if (obj.hasOwnProperty(key)) { obj[key] = buildInfo[obj[key]](); } } return obj; }, timeZoneDST: function () { var DST = { "CHADT": "+1345", "NZDT": "+1300", "AEDT": "+1100", "ACDT": "+1030", "AZST": "+0500", "IRDT": "+0430", "EEST": "+0300", "CEST": "+0200", "BST": "+0100", "PMDT": "-0200", "ADT": "-0300", "NDT": "-0230", "EDT": "-0400", "CDT": "-0500", "MDT": "-0600", "PDT": "-0700", "AKDT": "-0800", "HADT": "-0900" }; return __(DST); }, timeZoneStandard: function () { var standard = { "LINT": "+1400", "TOT": "+1300", "CHAST": "+1245", "NZST": "+1200", "NFT": "+1130", "SBT": "+1100", "AEST": "+1000", "ACST": "+0930", "JST": "+0900", "CWST": "+0845", "CT": "+0800", "ICT": "+0700", "MMT": "+0630", "BST": "+0600", "NPT": "+0545", "IST": "+0530", "PKT": "+0500", "AFT": "+0430", "MSK": "+0400", "IRST": "+0330", "FET": "+0300", "EET": "+0200", "CET": "+0100", "GMT": "+0000", "UTC": "+0000", "CVT": "-0100", "GST": "-0200", "BRT": "-0300", "NST": "-0330", "AST": "-0400", "EST": "-0500", "CST": "-0600", "MST": "-0700", "PST": "-0800", "AKST": "-0900", "MIT": "-0930", "HST": "-1000", "SST": "-1100", "BIT": "-1200" }; return __(standard); }, timeZones: function (data) { var zone; data.timezones = []; for (zone in data.abbreviatedTimeZoneStandard) { if (data.abbreviatedTimeZoneStandard.hasOwnProperty(zone)) { data.timezones.push({ name: zone, offset: data.abbreviatedTimeZoneStandard[zone]}); } } for (zone in data.abbreviatedTimeZoneDST) { if (data.abbreviatedTimeZoneDST.hasOwnProperty(zone)) { data.timezones.push({ name: zone, offset: data.abbreviatedTimeZoneDST[zone], dst: true}); } } return data.timezones; }, days: function () { return __(["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"]); }, dayAbbr: function () { return __(["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"]); }, dayShortNames: function () { return __(["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"]); }, dayFirstLetters: function () { return __(["S_Sun_Initial", "M_Mon_Initial", "T_Tues_Initial", "W_Wed_Initial", "T_Thu_Initial", "F_Fri_Initial", "S_Sat_Initial"]); }, months: function () { return __(["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"]); }, monthAbbr: function () { return __(["Jan_Abbr", "Feb_Abbr", "Mar_Abbr", "Apr_Abbr", "May_Abbr", "Jun_Abbr", "Jul_Abbr", "Aug_Abbr", "Sep_Abbr", "Oct_Abbr", "Nov_Abbr", "Dec_Abbr"]); }, formatPatterns: function () { return getText.getFromObjectValues({ shortDate: "M/d/yyyy", longDate: "dddd, MMMM dd, yyyy", shortTime: "h:mm tt", longTime: "h:mm:ss tt", fullDateTime: "dddd, MMMM dd, yyyy h:mm:ss tt", sortableDateTime: "yyyy-MM-ddTHH:mm:ss", universalSortableDateTime: "yyyy-MM-dd HH:mm:ssZ", rfc1123: "ddd, dd MMM yyyy HH:mm:ss", monthDay: "MMMM dd", yearMonth: "MMMM, yyyy" }, Date.i18n.currentLanguage()); }, regex: function () { return getText.getFromObjectValues({ inTheMorning: "/( in the )(morn(ing)?)\\b/", thisMorning: "/(this )(morn(ing)?)\\b/", amThisMorning: "/(\b\\d(am)? )(this )(morn(ing)?)/", inTheEvening: "/( in the )(even(ing)?)\\b/", thisEvening: "/(this )(even(ing)?)\\b/", pmThisEvening: "/(\b\\d(pm)? )(this )(even(ing)?)/", jan: "/jan(uary)?/", feb: "/feb(ruary)?/", mar: "/mar(ch)?/", apr: "/apr(il)?/", may: "/may/", jun: "/jun(e)?/", jul: "/jul(y)?/", aug: "/aug(ust)?/", sep: "/sep(t(ember)?)?/", oct: "/oct(ober)?/", nov: "/nov(ember)?/", dec: "/dec(ember)?/", sun: "/^su(n(day)?)?/", mon: "/^mo(n(day)?)?/", tue: "/^tu(e(s(day)?)?)?/", wed: "/^we(d(nesday)?)?/", thu: "/^th(u(r(s(day)?)?)?)?/", fri: "/fr(i(day)?)?/", sat: "/^sa(t(urday)?)?/", future: "/^next/", past: "/^last|past|prev(ious)?/", add: "/^(\\+|aft(er)?|from|hence)/", subtract: "/^(\\-|bef(ore)?|ago)/", yesterday: "/^yes(terday)?/", today: "/^t(od(ay)?)?/", tomorrow: "/^tom(orrow)?/", now: "/^n(ow)?/", millisecond: "/^ms|milli(second)?s?/", second: "/^sec(ond)?s?/", minute: "/^mn|min(ute)?s?/", hour: "/^h(our)?s?/", week: "/^w(eek)?s?/", month: "/^m(onth)?s?/", day: "/^d(ay)?s?/", year: "/^y(ear)?s?/", shortMeridian: "/^(a|p)/", longMeridian: "/^(a\\.?m?\\.?|p\\.?m?\\.?)/", timezone: "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/", ordinalSuffix: "/^\\s*(st|nd|rd|th)/", timeContext: "/^\\s*(\\:|a(?!u|p)|p)/" }, Date.i18n.currentLanguage()); } }; var CultureInfo = function () { var info = getText.getFromObjectValues({ name: "name", englishName: "englishName", nativeName: "nativeName", amDesignator: "AM", pmDesignator: "PM", firstDayOfWeek: "firstDayOfWeek", twoDigitYearMax: "twoDigitYearMax", dateElementOrder: "mdy" }, Date.i18n.currentLanguage()); var constructedInfo = buildInfo.buildFromMethodHash({ dayNames: "days", abbreviatedDayNames: "dayAbbr", shortestDayNames: "dayShortNames", firstLetterDayNames: "dayFirstLetters", monthNames: "months", abbreviatedMonthNames: "monthAbbr", formatPatterns: "formatPatterns", regexPatterns: "regex", abbreviatedTimeZoneDST: "timeZoneDST", abbreviatedTimeZoneStandard: "timeZoneStandard" }); shallowMerge(info, constructedInfo); buildInfo.timeZones(info); return info; }; $D.i18n = { __: function (key, lang) { return __(key, lang); }, currentLanguage: function () { return lang || "en-US"; }, setLanguage: function (code, force, cb) { var async = false; if (force || code === "en-US" || (!!Date.CultureStrings && !!Date.CultureStrings[code])) { lang = code; Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings.lang = code; Date.CultureInfo = new CultureInfo(); } else { if (!(!!Date.CultureStrings && !!Date.CultureStrings[code])) { if (typeof exports !== "undefined" && this.exports !== exports) { // we're in a Node enviroment, load it using require try { require("../i18n/" + code + ".js"); lang = code; Date.CultureStrings.lang = code; Date.CultureInfo = new CultureInfo(); } catch (e) { // var str = "The language for '" + code + "' could not be loaded by Node. It likely does not exist."; throw new Error("The DateJS IETF language tag '" + code + "' could not be loaded by Node. It likely does not exist."); } } else if (Date.Config && Date.Config.i18n) { // we know the location of the files, so lets load them async = true; loadI18nScript(code).done(function(){ lang = code; Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings.lang = code; Date.CultureInfo = new CultureInfo(); $D.Parsing.Normalizer.buildReplaceData(); // because this is async if ($D.Grammar) { $D.Grammar.buildGrammarFormats(); // so we can parse those strings... } if (cb) { setTimeout(cb,0); } }); } else { Date.console.error("The DateJS IETF language tag '" + code + "' is not available and has not been loaded."); return false; } } } $D.Parsing.Normalizer.buildReplaceData(); // rebuild normalizer strings if ($D.Grammar) { $D.Grammar.buildGrammarFormats(); // so we can parse those strings... } if (!async && cb) { setTimeout(cb,0); } }, getLoggedKeys: function () { return loggedKeys; }, updateCultureInfo: function () { Date.CultureInfo = new CultureInfo(); } }; $D.i18n.updateCultureInfo(); // run automatically }()); (function () { var $D = Date, $P = $D.prototype, p = function (s, l) { if (!l) { l = 2; } return ("000" + s).slice(l * -1); }; if (typeof window !== "undefined" && typeof window.console !== "undefined" && typeof window.console.log !== "undefined") { $D.console = console; // used only to raise non-critical errors if available } else { // set mock so we don't give errors. $D.console = { log: function(){}, error: function(){} }; } $D.Config = $D.Config || {}; $D.initOverloads = function() { /** * Overload of Date.now. Allows an alternate call for Date.now where it returns the * current Date as an object rather than just milliseconds since the Unix Epoch. * * Also provides an implementation of now() for browsers (IE<9) that don't have it. * * Backwards compatible so with work with either: * Date.now() [returns ms] * or * Date.now(true) [returns Date] */ if (!$D.now) { $D._now = function now() { return new Date().getTime(); }; } else if (!$D._now) { $D._now = $D.now; } $D.now = function (returnObj) { if (returnObj) { return $D.present(); } else { return $D._now(); } }; if ( !$P.toISOString ) { $P.toISOString = function() { return this.getUTCFullYear() + "-" + p(this.getUTCMonth() + 1) + "-" + p(this.getUTCDate()) + "T" + p(this.getUTCHours()) + ":" + p(this.getUTCMinutes()) + ":" + p(this.getUTCSeconds()) + "." + String( (this.getUTCMilliseconds()/1000).toFixed(3)).slice(2, 5) + "Z"; }; } // private if ( $P._toString === undefined ){ $P._toString = $P.toString; } }; $D.initOverloads(); /** * Gets a date that is set to the current date. The time is set to the start of the day (00:00 or 12:00 AM). * @return {Date} The current date. */ $D.today = function () { return new Date().clearTime(); }; /** * Gets a date that is set to the current date and time (same as new Date, but chainable) * @return {Date} The current date. */ $D.present = function () { return new Date(); }; /** * Compares the first date to the second date and returns an number indication of their relative values. * @param {Date} First Date object to compare [Required]. * @param {Date} Second Date object to compare to [Required]. * @return {Number} -1 = date1 is lessthan date2. 0 = values are equal. 1 = date1 is greaterthan date2. */ $D.compare = function (date1, date2) { if (isNaN(date1) || isNaN(date2)) { throw new Error(date1 + " - " + date2); } else if (date1 instanceof Date && date2 instanceof Date) { return (date1 < date2) ? -1 : (date1 > date2) ? 1 : 0; } else { throw new TypeError(date1 + " - " + date2); } }; /** * Compares the first Date object to the second Date object and returns true if they are equal. * @param {Date} First Date object to compare [Required] * @param {Date} Second Date object to compare to [Required] * @return {Boolean} true if dates are equal. false if they are not equal. */ $D.equals = function (date1, date2) { return (date1.compareTo(date2) === 0); }; /** * Gets the language appropriate day name when given the day number(0-6) * eg - 0 == Sunday * @return {String} The day name */ $D.getDayName = function (n) { return Date.CultureInfo.dayNames[n]; }; /** * Gets the day number (0-6) if given a CultureInfo specific string which is a valid dayName, abbreviatedDayName or shortestDayName (two char). * @param {String} The name of the day (eg. "Monday, "Mon", "tuesday", "tue", "We", "we"). * @return {Number} The day number */ $D.getDayNumberFromName = function (name) { var n = Date.CultureInfo.dayNames, m = Date.CultureInfo.abbreviatedDayNames, o = Date.CultureInfo.shortestDayNames, s = name.toLowerCase(); for (var i = 0; i < n.length; i++) { if (n[i].toLowerCase() === s || m[i].toLowerCase() === s || o[i].toLowerCase() === s) { return i; } } return -1; }; /** * Gets the month number (0-11) if given a Culture Info specific string which is a valid monthName or abbreviatedMonthName. * @param {String} The name of the month (eg. "February, "Feb", "october", "oct"). * @return {Number} The day number */ $D.getMonthNumberFromName = function (name) { var n = Date.CultureInfo.monthNames, m = Date.CultureInfo.abbreviatedMonthNames, s = name.toLowerCase(); for (var i = 0; i < n.length; i++) { if (n[i].toLowerCase() === s || m[i].toLowerCase() === s) { return i; } } return -1; }; /** * Gets the language appropriate month name when given the month number(0-11) * eg - 0 == January * @return {String} The month name */ $D.getMonthName = function (n) { return Date.CultureInfo.monthNames[n]; }; /** * Determines if the current date instance is within a LeapYear. * @param {Number} The year. * @return {Boolean} true if date is within a LeapYear, otherwise false. */ $D.isLeapYear = function (year) { return ((year % 4 === 0 && year % 100 !== 0) || year % 400 === 0); }; /** * Gets the number of days in the month, given a year and month value. Automatically corrects for LeapYear. * @param {Number} The year. * @param {Number} The month (0-11). * @return {Number} The number of days in the month. */ $D.getDaysInMonth = function (year, month) { if (!month && $D.validateMonth(year)) { month = year; year = Date.today().getFullYear(); } return [31, ($D.isLeapYear(year) ? 29 : 28), 31, 30, 31, 30, 31, 31, 30, 31, 30, 31][month]; }; $P.getDaysInMonth = function () { return $D.getDaysInMonth(this.getFullYear(), this.getMonth()); }; $D.getTimezoneAbbreviation = function (offset, dst) { var p, n = (dst || false) ? Date.CultureInfo.abbreviatedTimeZoneDST : Date.CultureInfo.abbreviatedTimeZoneStandard; for (p in n) { if (n.hasOwnProperty(p)) { if (n[p] === offset) { return p; } } } return null; }; $D.getTimezoneOffset = function (name, dst) { var i, a =[], z = Date.CultureInfo.timezones; if (!name) { name = (new Date()).getTimezone();} for (i = 0; i < z.length; i++) { if (z[i].name === name.toUpperCase()) { a.push(i); } } if (!z[a[0]]) { return null; } if (a.length === 1 || !dst) { return z[a[0]].offset; } else { for (i=0; i < a.length; i++) { if (z[a[i]].dst) { return z[a[i]].offset; } } } }; $D.getQuarter = function (d) { d = d || new Date(); // If no date supplied, use today var q = [1,2,3,4]; return q[Math.floor(d.getMonth() / 3)]; // ~~~ is a bitwise op. Faster than Math.floor }; $D.getDaysLeftInQuarter = function (d) { d = d || new Date(); var qEnd = new Date(d); qEnd.setMonth(qEnd.getMonth() + 3 - qEnd.getMonth() % 3, 0); return Math.floor((qEnd - d) / 8.64e7); }; // private var validate = function (n, min, max, name) { name = name ? name : "Object"; if (typeof n === "undefined") { return false; } else if (typeof n !== "number") { throw new TypeError(n + " is not a Number."); } else if (n < min || n > max) { // As failing validation is *not* an exceptional circumstance // lets not throw a RangeError Exception here. // It's semantically correct but it's not sensible. return false; } return true; }; /** * Validates the number is within an acceptable range for milliseconds [0-999]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateMillisecond = function (value) { return validate(value, 0, 999, "millisecond"); }; /** * Validates the number is within an acceptable range for seconds [0-59]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateSecond = function (value) { return validate(value, 0, 59, "second"); }; /** * Validates the number is within an acceptable range for minutes [0-59]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateMinute = function (value) { return validate(value, 0, 59, "minute"); }; /** * Validates the number is within an acceptable range for hours [0-23]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateHour = function (value) { return validate(value, 0, 23, "hour"); }; /** * Validates the number is within an acceptable range for the days in a month [0-MaxDaysInMonth]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateDay = function (value, year, month) { if (year === undefined || year === null || month === undefined || month === null) { return false;} return validate(value, 1, $D.getDaysInMonth(year, month), "day"); }; /** * Validates the number is within an acceptable range for months [0-11]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateWeek = function (value) { return validate(value, 0, 53, "week"); }; /** * Validates the number is within an acceptable range for months [0-11]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateMonth = function (value) { return validate(value, 0, 11, "month"); }; /** * Validates the number is within an acceptable range for years. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateYear = function (value) { /** * Per ECMAScript spec the range of times supported by Date objects is * exactly -100,000,000 days to +100,000,000 days measured relative to * midnight at the beginning of 01 January, 1970 UTC. * This gives a range of 8,640,000,000,000,000 milliseconds to either * side of 01 January, 1970 UTC. * * Earliest possible date: Tue, 20 Apr 271,822 B.C. 00:00:00 UTC * Latest possible date: Sat, 13 Sep 275,760 00:00:00 UTC */ return validate(value, -271822, 275760, "year"); }; $D.validateTimezone = function(value) { var timezones = {"ACDT":1,"ACST":1,"ACT":1,"ADT":1,"AEDT":1,"AEST":1,"AFT":1,"AKDT":1,"AKST":1,"AMST":1,"AMT":1,"ART":1,"AST":1,"AWDT":1,"AWST":1,"AZOST":1,"AZT":1,"BDT":1,"BIOT":1,"BIT":1,"BOT":1,"BRT":1,"BST":1,"BTT":1,"CAT":1,"CCT":1,"CDT":1,"CEDT":1,"CEST":1,"CET":1,"CHADT":1,"CHAST":1,"CHOT":1,"ChST":1,"CHUT":1,"CIST":1,"CIT":1,"CKT":1,"CLST":1,"CLT":1,"COST":1,"COT":1,"CST":1,"CT":1,"CVT":1,"CWST":1,"CXT":1,"DAVT":1,"DDUT":1,"DFT":1,"EASST":1,"EAST":1,"EAT":1,"ECT":1,"EDT":1,"EEDT":1,"EEST":1,"EET":1,"EGST":1,"EGT":1,"EIT":1,"EST":1,"FET":1,"FJT":1,"FKST":1,"FKT":1,"FNT":1,"GALT":1,"GAMT":1,"GET":1,"GFT":1,"GILT":1,"GIT":1,"GMT":1,"GST":1,"GYT":1,"HADT":1,"HAEC":1,"HAST":1,"HKT":1,"HMT":1,"HOVT":1,"HST":1,"ICT":1,"IDT":1,"IOT":1,"IRDT":1,"IRKT":1,"IRST":1,"IST":1,"JST":1,"KGT":1,"KOST":1,"KRAT":1,"KST":1,"LHST":1,"LINT":1,"MAGT":1,"MART":1,"MAWT":1,"MDT":1,"MET":1,"MEST":1,"MHT":1,"MIST":1,"MIT":1,"MMT":1,"MSK":1,"MST":1,"MUT":1,"MVT":1,"MYT":1,"NCT":1,"NDT":1,"NFT":1,"NPT":1,"NST":1,"NT":1,"NUT":1,"NZDT":1,"NZST":1,"OMST":1,"ORAT":1,"PDT":1,"PET":1,"PETT":1,"PGT":1,"PHOT":1,"PHT":1,"PKT":1,"PMDT":1,"PMST":1,"PONT":1,"PST":1,"PYST":1,"PYT":1,"RET":1,"ROTT":1,"SAKT":1,"SAMT":1,"SAST":1,"SBT":1,"SCT":1,"SGT":1,"SLST":1,"SRT":1,"SST":1,"SYOT":1,"TAHT":1,"THA":1,"TFT":1,"TJT":1,"TKT":1,"TLT":1,"TMT":1,"TOT":1,"TVT":1,"UCT":1,"ULAT":1,"UTC":1,"UYST":1,"UYT":1,"UZT":1,"VET":1,"VLAT":1,"VOLT":1,"VOST":1,"VUT":1,"WAKT":1,"WAST":1,"WAT":1,"WEDT":1,"WEST":1,"WET":1,"WST":1,"YAKT":1,"YEKT":1,"Z":1}; return (timezones[value] === 1); }; $D.validateTimezoneOffset= function(value) { // timezones go from +14hrs to -12hrs, the +X hours are negative offsets. return (value > -841 && value < 721); }; }()); (function () { var $D = Date, $P = $D.prototype, p = function (s, l) { if (!l) { l = 2; } return ("000" + s).slice(l * -1); }; var validateConfigObject = function (obj) { var result = {}, self = this, prop, testFunc; testFunc = function (prop, func, value) { if (prop === "day") { var month = (obj.month !== undefined) ? obj.month : self.getMonth(); var year = (obj.year !== undefined) ? obj.year : self.getFullYear(); return $D[func](value, year, month); } else { return $D[func](value); } }; for (prop in obj) { if (Object.prototype.hasOwnProperty.call(obj, prop)) { var func = "validate" + prop.charAt(0).toUpperCase() + prop.slice(1); if ($D[func] && obj[prop] !== null && testFunc(prop, func, obj[prop])) { result[prop] = obj[prop]; } } } return result; }; /** * Resets the time of this Date object to 12:00 AM (00:00), which is the start of the day. * @param {Boolean} .clone() this date instance before clearing Time * @return {Date} this */ $P.clearTime = function () { this.setHours(0); this.setMinutes(0); this.setSeconds(0); this.setMilliseconds(0); return this; }; /** * Resets the time of this Date object to the current time ('now'). * @return {Date} this */ $P.setTimeToNow = function () { var n = new Date(); this.setHours(n.getHours()); this.setMinutes(n.getMinutes()); this.setSeconds(n.getSeconds()); this.setMilliseconds(n.getMilliseconds()); return this; }; /** * Returns a new Date object that is an exact date and time copy of the original instance. * @return {Date} A new Date instance */ $P.clone = function () { return new Date(this.getTime()); }; /** * Compares this instance to a Date object and returns an number indication of their relative values. * @param {Date} Date object to compare [Required] * @return {Number} -1 = this is lessthan date. 0 = values are equal. 1 = this is greaterthan date. */ $P.compareTo = function (date) { return Date.compare(this, date); }; /** * Compares this instance to another Date object and returns true if they are equal. * @param {Date} Date object to compare. If no date to compare, new Date() [now] is used. * @return {Boolean} true if dates are equal. false if they are not equal. */ $P.equals = function (date) { return Date.equals(this, (date !== undefined ? date : new Date())); }; /** * Determines if this instance is between a range of two dates or equal to either the start or end dates. * @param {Date} Start of range [Required] * @param {Date} End of range [Required] * @return {Boolean} true is this is between or equal to the start and end dates, else false */ $P.between = function (start, end) { return this.getTime() >= start.getTime() && this.getTime() <= end.getTime(); }; /** * Determines if this date occurs after the date to compare to. * @param {Date} Date object to compare. If no date to compare, new Date() ("now") is used. * @return {Boolean} true if this date instance is greater than the date to compare to (or "now"), otherwise false. */ $P.isAfter = function (date) { return this.compareTo(date || new Date()) === 1; }; /** * Determines if this date occurs before the date to compare to. * @param {Date} Date object to compare. If no date to compare, new Date() ("now") is used. * @return {Boolean} true if this date instance is less than the date to compare to (or "now"). */ $P.isBefore = function (date) { return (this.compareTo(date || new Date()) === -1); }; /** * Determines if the current Date instance occurs today. * @return {Boolean} true if this date instance is 'today', otherwise false. */ /** * Determines if the current Date instance occurs on the same Date as the supplied 'date'. * If no 'date' to compare to is provided, the current Date instance is compared to 'today'. * @param {date} Date object to compare. If no date to compare, the current Date ("now") is used. * @return {Boolean} true if this Date instance occurs on the same Day as the supplied 'date'. */ $P.isToday = $P.isSameDay = function (date) { return this.clone().clearTime().equals((date || new Date()).clone().clearTime()); }; /** * Adds the specified number of milliseconds to this instance. * @param {Number} The number of milliseconds to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addMilliseconds = function (value) { if (!value) { return this; } this.setTime(this.getTime() + value * 1); return this; }; /** * Adds the specified number of seconds to this instance. * @param {Number} The number of seconds to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addSeconds = function (value) { if (!value) { return this; } return this.addMilliseconds(value * 1000); }; /** * Adds the specified number of seconds to this instance. * @param {Number} The number of seconds to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addMinutes = function (value) { if (!value) { return this; } return this.addMilliseconds(value * 60000); // 60*1000 }; /** * Adds the specified number of hours to this instance. * @param {Number} The number of hours to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addHours = function (value) { if (!value) { return this; } return this.addMilliseconds(value * 3600000); // 60*60*1000 }; /** * Adds the specified number of days to this instance. * @param {Number} The number of days to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addDays = function (value) { if (!value) { return this; } this.setDate(this.getDate() + value * 1); return this; }; /** * Adds the specified number of weekdays (ie - not sat or sun) to this instance. * @param {Number} The number of days to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addWeekdays = function (value) { if (!value) { return this; } var day = this.getDay(); var weeks = (Math.ceil(Math.abs(value)/7)); if (day === 0 || day === 6) { if (value > 0) { this.next().monday(); this.addDays(-1); day = this.getDay(); } } if (value < 0) { while (value < 0) { this.addDays(-1); day = this.getDay(); if (day !== 0 && day !== 6) { value++; } } return this; } else if (value > 5 || (6-day) <= value) { value = value + (weeks * 2); } return this.addDays(value); }; /** * Adds the specified number of weeks to this instance. * @param {Number} The number of weeks to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addWeeks = function (value) { if (!value) { return this; } return this.addDays(value * 7); }; /** * Adds the specified number of months to this instance. * @param {Number} The number of months to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addMonths = function (value) { if (!value) { return this; } var n = this.getDate(); this.setDate(1); this.setMonth(this.getMonth() + value * 1); this.setDate(Math.min(n, $D.getDaysInMonth(this.getFullYear(), this.getMonth()))); return this; }; $P.addQuarters = function (value) { if (!value) { return this; } // note this will take you to the same point in the quarter as you are now. // i.e. - if you are 15 days into the quarter you'll be 15 days into the resulting one. // bonus: this allows adding fractional quarters return this.addMonths(value * 3); }; /** * Adds the specified number of years to this instance. * @param {Number} The number of years to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addYears = function (value) { if (!value) { return this; } return this.addMonths(value * 12); }; /** * Adds (or subtracts) to the value of the years, months, weeks, days, hours, minutes, seconds, milliseconds of the date instance using given configuration object. Positive and Negative values allowed. * Example

	Date.today().add( { days: 1, months: 1 } )

	new Date().add( { years: -1 } )
	
* @param {Object} Configuration object containing attributes (months, days, etc.) * @return {Date} this */ $P.add = function (config) { if (typeof config === "number") { this._orient = config; return this; } var x = config; if (x.day) { // If we should be a different date than today (eg: for 'tomorrow -1d', etc). // Should only effect parsing, not direct usage (eg, Finish and FinishExact) if ((x.day - this.getDate()) !== 0) { this.setDate(x.day); } } if (x.milliseconds) { this.addMilliseconds(x.milliseconds); } if (x.seconds) { this.addSeconds(x.seconds); } if (x.minutes) { this.addMinutes(x.minutes); } if (x.hours) { this.addHours(x.hours); } if (x.weeks) { this.addWeeks(x.weeks); } if (x.months) { this.addMonths(x.months); } if (x.years) { this.addYears(x.years); } if (x.days) { this.addDays(x.days); } return this; }; /** * Get the week number. Week one (1) is the week which contains the first Thursday of the year. Monday is considered the first day of the week. * The .getWeek() function does NOT convert the date to UTC. The local datetime is used. * Please use .getISOWeek() to get the week of the UTC converted date. * @return {Number} 1 to 53 */ $P.getWeek = function (utc) { // Create a copy of this date object var self, target = new Date(this.valueOf()); if (utc) { target.addMinutes(target.getTimezoneOffset()); self = target.clone(); } else { self = this; } // ISO week date weeks start on monday // so correct the day number var dayNr = (self.getDay() + 6) % 7; // ISO 8601 states that week 1 is the week // with the first thursday of that year. // Set the target date to the thursday in the target week target.setDate(target.getDate() - dayNr + 3); // Store the millisecond value of the target date var firstThursday = target.valueOf(); // Set the target to the first thursday of the year // First set the target to january first target.setMonth(0, 1); // Not a thursday? Correct the date to the next thursday if (target.getDay() !== 4) { target.setMonth(0, 1 + ((4 - target.getDay()) + 7) % 7); } // The weeknumber is the number of weeks between the // first thursday of the year and the thursday in the target week return 1 + Math.ceil((firstThursday - target) / 604800000); // 604800000 = 7 * 24 * 3600 * 1000 }; /** * Get the ISO 8601 week number. Week one ("01") is the week which contains the first Thursday of the year. Monday is considered the first day of the week. * The .getISOWeek() function does convert the date to it's UTC value. Please use .getWeek() to get the week of the local date. * @return {String} "01" to "53" */ $P.getISOWeek = function () { return p(this.getWeek(true)); }; /** * Moves the date to Monday of the week set. Week one (1) is the week which contains the first Thursday of the year. * @param {Number} A Number (1 to 53) that represents the week of the year. * @return {Date} this */ $P.setWeek = function (n) { if ((n - this.getWeek()) === 0) { if (this.getDay() !== 1) { return this.moveToDayOfWeek(1, (this.getDay() > 1 ? -1 : 1)); } else { return this; } } else { return this.moveToDayOfWeek(1, (this.getDay() > 1 ? -1 : 1)).addWeeks(n - this.getWeek()); } }; $P.setQuarter = function (qtr) { var month = Math.abs(((qtr-1) * 3) + 1); return this.setMonth(month, 1); }; $P.getQuarter = function () { return Date.getQuarter(this); }; $P.getDaysLeftInQuarter = function () { return Date.getDaysLeftInQuarter(this); }; /** * Moves the date to the next n'th occurrence of the dayOfWeek starting from the beginning of the month. The number (-1) is a magic number and will return the last occurrence of the dayOfWeek in the month. * @param {Number} The dayOfWeek to move to * @param {Number} The n'th occurrence to move to. Use (-1) to return the last occurrence in the month * @return {Date} this */ $P.moveToNthOccurrence = function (dayOfWeek, occurrence) { if (dayOfWeek === "Weekday") { if (occurrence > 0) { this.moveToFirstDayOfMonth(); if (this.is().weekday()) { occurrence -= 1; } } else if (occurrence < 0) { this.moveToLastDayOfMonth(); if (this.is().weekday()) { occurrence += 1; } } else { return this; } return this.addWeekdays(occurrence); } var shift = 0; if (occurrence > 0) { shift = occurrence - 1; } else if (occurrence === -1) { this.moveToLastDayOfMonth(); if (this.getDay() !== dayOfWeek) { this.moveToDayOfWeek(dayOfWeek, -1); } return this; } return this.moveToFirstDayOfMonth().addDays(-1).moveToDayOfWeek(dayOfWeek, +1).addWeeks(shift); }; var moveToN = function (getFunc, addFunc, nVal) { return function (value, orient) { var diff = (value - this[getFunc]() + nVal * (orient || +1)) % nVal; return this[addFunc]((diff === 0) ? diff += nVal * (orient || +1) : diff); }; }; /** * Move to the next or last dayOfWeek based on the orient value. * @param {Number} The dayOfWeek to move to * @param {Number} Forward (+1) or Back (-1). Defaults to +1. [Optional] * @return {Date} this */ $P.moveToDayOfWeek = moveToN("getDay", "addDays", 7); /** * Move to the next or last month based on the orient value. * @param {Number} The month to move to. 0 = January, 11 = December * @param {Number} Forward (+1) or Back (-1). Defaults to +1. [Optional] * @return {Date} this */ $P.moveToMonth = moveToN("getMonth", "addMonths", 12); /** * Get the Ordinate of the current day ("th", "st", "rd"). * @return {String} */ $P.getOrdinate = function () { var num = this.getDate(); return ord(num); }; /** * Get the Ordinal day (numeric day number) of the year, adjusted for leap year. * @return {Number} 1 through 365 (366 in leap years) */ $P.getOrdinalNumber = function () { return Math.ceil((this.clone().clearTime() - new Date(this.getFullYear(), 0, 1)) / 86400000) + 1; }; /** * Get the time zone abbreviation of the current date. * @return {String} The abbreviated time zone name (e.g. "EST") */ $P.getTimezone = function () { return $D.getTimezoneAbbreviation(this.getUTCOffset(), this.isDaylightSavingTime()); }; $P.setTimezoneOffset = function (offset) { var here = this.getTimezoneOffset(), there = Number(offset) * -6 / 10; return (there || there === 0) ? this.addMinutes(there - here) : this; }; $P.setTimezone = function (offset) { return this.setTimezoneOffset($D.getTimezoneOffset(offset)); }; /** * Indicates whether Daylight Saving Time is observed in the current time zone. * @return {Boolean} true|false */ $P.hasDaylightSavingTime = function () { return (Date.today().set({month: 0, day: 1}).getTimezoneOffset() !== Date.today().set({month: 6, day: 1}).getTimezoneOffset()); }; /** * Indicates whether this Date instance is within the Daylight Saving Time range for the current time zone. * @return {Boolean} true|false */ $P.isDaylightSavingTime = function () { return Date.today().set({month: 0, day: 1}).getTimezoneOffset() !== this.getTimezoneOffset(); }; /** * Get the offset from UTC of the current date. * @return {String} The 4-character offset string prefixed with + or - (e.g. "-0500") */ $P.getUTCOffset = function (offset) { var n = (offset || this.getTimezoneOffset()) * -10 / 6, r; if (n < 0) { r = (n - 10000).toString(); return r.charAt(0) + r.substr(2); } else { r = (n + 10000).toString(); return "+" + r.substr(1); } }; /** * Returns the number of milliseconds between this date and date. * @param {Date} Defaults to now * @return {Number} The diff in milliseconds */ $P.getElapsed = function (date) { return (date || new Date()) - this; }; /** * Set the value of year, month, day, hour, minute, second, millisecond of date instance using given configuration object. * Example

	Date.today().set( { day: 20, month: 1 } )

	new Date().set( { millisecond: 0 } )
	
* * @param {Object} Configuration object containing attributes (month, day, etc.) * @return {Date} this */ $P.set = function (config) { config = validateConfigObject.call(this, config); var key; for (key in config) { if (Object.prototype.hasOwnProperty.call(config, key)) { var name = key.charAt(0).toUpperCase() + key.slice(1); var addFunc, getFunc; if (key !== "week" && key !== "month" && key !== "timezone" && key !== "timezoneOffset") { name += "s"; } addFunc = "add" + name; getFunc = "get" + name; if (key === "month") { addFunc = addFunc + "s"; } else if (key === "year"){ getFunc = "getFullYear"; } if (key !== "day" && key !== "timezone" && key !== "timezoneOffset" && key !== "week" && key !== "hour") { this[addFunc](config[key] - this[getFunc]()); } else if ( key === "timezone"|| key === "timezoneOffset" || key === "week" || key === "hour") { this["set"+name](config[key]); } } } // day has to go last because you can't validate the day without first knowing the month if (config.day) { this.addDays(config.day - this.getDate()); } return this; }; /** * Moves the date to the first day of the month. * @return {Date} this */ $P.moveToFirstDayOfMonth = function () { return this.set({ day: 1 }); }; /** * Moves the date to the last day of the month. * @return {Date} this */ $P.moveToLastDayOfMonth = function () { return this.set({ day: $D.getDaysInMonth(this.getFullYear(), this.getMonth())}); }; /** * Converts the value of the current Date object to its equivalent string representation. * Format Specifiers * CUSTOM DATE AND TIME FORMAT STRINGS * Format Description Example * ------ --------------------------------------------------------------------------- ----------------------- * s The seconds of the minute between 0-59. "0" to "59" * ss The seconds of the minute with leading zero if required. "00" to "59" * * m The minute of the hour between 0-59. "0" or "59" * mm The minute of the hour with leading zero if required. "00" or "59" * * h The hour of the day between 1-12. "1" to "12" * hh The hour of the day with leading zero if required. "01" to "12" * * H The hour of the day between 0-23. "0" to "23" * HH The hour of the day with leading zero if required. "00" to "23" * * d The day of the month between 1 and 31. "1" to "31" * dd The day of the month with leading zero if required. "01" to "31" * ddd Abbreviated day name. Date.CultureInfo.abbreviatedDayNames. "Mon" to "Sun" * dddd The full day name. Date.CultureInfo.dayNames. "Monday" to "Sunday" * * M The month of the year between 1-12. "1" to "12" * MM The month of the year with leading zero if required. "01" to "12" * MMM Abbreviated month name. Date.CultureInfo.abbreviatedMonthNames. "Jan" to "Dec" * MMMM The full month name. Date.CultureInfo.monthNames. "January" to "December" * * yy The year as a two-digit number. "99" or "08" * yyyy The full four digit year. "1999" or "2008" * * t Displays the first character of the A.M./P.M. designator. "A" or "P" * Date.CultureInfo.amDesignator or Date.CultureInfo.pmDesignator * tt Displays the A.M./P.M. designator. "AM" or "PM" * Date.CultureInfo.amDesignator or Date.CultureInfo.pmDesignator * * S The ordinal suffix ("st, "nd", "rd" or "th") of the current day. "st, "nd", "rd" or "th" * * STANDARD DATE AND TIME FORMAT STRINGS * Format Description Example *------ --------------------------------------------------------------------------- ----------------------- * d The CultureInfo shortDate Format Pattern "M/d/yyyy" * D The CultureInfo longDate Format Pattern "dddd, MMMM dd, yyyy" * F The CultureInfo fullDateTime Format Pattern "dddd, MMMM dd, yyyy h:mm:ss tt" * m The CultureInfo monthDay Format Pattern "MMMM dd" * r The CultureInfo rfc1123 Format Pattern "ddd, dd MMM yyyy HH:mm:ss GMT" * s The CultureInfo sortableDateTime Format Pattern "yyyy-MM-ddTHH:mm:ss" * t The CultureInfo shortTime Format Pattern "h:mm tt" * T The CultureInfo longTime Format Pattern "h:mm:ss tt" * u The CultureInfo universalSortableDateTime Format Pattern "yyyy-MM-dd HH:mm:ssZ" * y The CultureInfo yearMonth Format Pattern "MMMM, yyyy" * * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @return {String} A string representation of the current Date object. */ var ord = function (n) { switch (n * 1) { case 1: case 21: case 31: return "st"; case 2: case 22: return "nd"; case 3: case 23: return "rd"; default: return "th"; } }; var parseStandardFormats = function (format) { var y, c = Date.CultureInfo.formatPatterns; switch (format) { case "d": return this.toString(c.shortDate); case "D": return this.toString(c.longDate); case "F": return this.toString(c.fullDateTime); case "m": return this.toString(c.monthDay); case "r": case "R": y = this.clone().addMinutes(this.getTimezoneOffset()); return y.toString(c.rfc1123) + " GMT"; case "s": return this.toString(c.sortableDateTime); case "t": return this.toString(c.shortTime); case "T": return this.toString(c.longTime); case "u": y = this.clone().addMinutes(this.getTimezoneOffset()); return y.toString(c.universalSortableDateTime); case "y": return this.toString(c.yearMonth); default: return false; } }; var parseFormatStringsClosure = function (context) { return function (m) { if (m.charAt(0) === "\\") { return m.replace("\\", ""); } switch (m) { case "hh": return p(context.getHours() < 13 ? (context.getHours() === 0 ? 12 : context.getHours()) : (context.getHours() - 12)); case "h": return context.getHours() < 13 ? (context.getHours() === 0 ? 12 : context.getHours()) : (context.getHours() - 12); case "HH": return p(context.getHours()); case "H": return context.getHours(); case "mm": return p(context.getMinutes()); case "m": return context.getMinutes(); case "ss": return p(context.getSeconds()); case "s": return context.getSeconds(); case "yyyy": return p(context.getFullYear(), 4); case "yy": return p(context.getFullYear()); case "y": return context.getFullYear(); case "E": case "dddd": return Date.CultureInfo.dayNames[context.getDay()]; case "ddd": return Date.CultureInfo.abbreviatedDayNames[context.getDay()]; case "dd": return p(context.getDate()); case "d": return context.getDate(); case "MMMM": return Date.CultureInfo.monthNames[context.getMonth()]; case "MMM": return Date.CultureInfo.abbreviatedMonthNames[context.getMonth()]; case "MM": return p((context.getMonth() + 1)); case "M": return context.getMonth() + 1; case "t": return context.getHours() < 12 ? Date.CultureInfo.amDesignator.substring(0, 1) : Date.CultureInfo.pmDesignator.substring(0, 1); case "tt": return context.getHours() < 12 ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator; case "S": return ord(context.getDate()); case "W": return context.getWeek(); case "WW": return context.getISOWeek(); case "Q": return "Q" + context.getQuarter(); case "q": return String(context.getQuarter()); case "z": return context.getTimezone(); case "Z": case "X": return Date.getTimezoneOffset(context.getTimezone()); case "ZZ": // Timezone offset in seconds return context.getTimezoneOffset() * -60; case "u": return context.getDay(); case "L": return ($D.isLeapYear(context.getFullYear())) ? 1 : 0; case "B": // Swatch Internet Time (.beats) return "@"+((context.getUTCSeconds() + (context.getUTCMinutes()*60) + ((context.getUTCHours()+1)*3600))/86.4); default: return m; } }; }; $P.toString = function (format, ignoreStandards) { // Standard Date and Time Format Strings. Formats pulled from CultureInfo file and // may vary by culture. if (!ignoreStandards && format && format.length === 1) { output = parseStandardFormats.call(this, format); if (output) { return output; } } var parseFormatStrings = parseFormatStringsClosure(this); return format ? format.replace(/((\\)?(dd?d?d?|MM?M?M?|yy?y?y?|hh?|HH?|mm?|ss?|tt?|S|q|Q|WW?W?W?)(?![^\[]*\]))/g, parseFormatStrings).replace(/\[|\]/g, "") : this._toString(); }; }()); /************************************************************* * SugarPak - Domain Specific Language - Syntactical Sugar * *************************************************************/ (function () { var $D = Date, $P = $D.prototype, $N = Number.prototype; // private $P._orient = +1; // private $P._nth = null; // private $P._is = false; // private $P._same = false; // private $P._isSecond = false; // private $N._dateElement = "days"; /** * Moves the date to the next instance of a date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.today().next().friday();
	Date.today().next().fri();
	Date.today().next().march();
	Date.today().next().mar();
	Date.today().next().week();
	
* * @return {Date} date */ $P.next = function () { this._move = true; this._orient = +1; return this; }; /** * Creates a new Date (Date.today()) and moves the date to the next instance of the date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.next().friday();
	Date.next().fri();
	Date.next().march();
	Date.next().mar();
	Date.next().week();
	
* * @return {Date} date */ $D.next = function () { return $D.today().next(); }; /** * Moves the date to the previous instance of a date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.today().last().friday();
	Date.today().last().fri();
	Date.today().last().march();
	Date.today().last().mar();
	Date.today().last().week();
	
* * @return {Date} date */ $P.last = $P.prev = $P.previous = function () { this._move = true; this._orient = -1; return this; }; /** * Creates a new Date (Date.today()) and moves the date to the previous instance of the date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.last().friday();
	Date.last().fri();
	Date.previous().march();
	Date.prev().mar();
	Date.last().week();
	
* * @return {Date} date */ $D.last = $D.prev = $D.previous = function () { return $D.today().last(); }; /** * Performs a equality check when followed by either a month name, day name or .weekday() function. * Example

	Date.today().is().friday(); // true|false
	Date.today().is().fri();
	Date.today().is().march();
	Date.today().is().mar();
	
* * @return {Boolean} true|false */ $P.is = function () { this._is = true; return this; }; /** * Determines if two date objects occur on/in exactly the same instance of the subsequent date part function. * The function .same() must be followed by a date part function (example: .day(), .month(), .year(), etc). * * An optional Date can be passed in the date part function. If now date is passed as a parameter, 'Now' is used. * * The following example demonstrates how to determine if two dates fall on the exact same day. * * Example

	var d1 = Date.today(); // today at 00:00
	var d2 = new Date();   // exactly now.

	// Do they occur on the same day?
	d1.same().day(d2); // true
	
	// Do they occur on the same hour?
	d1.same().hour(d2); // false, unless d2 hour is '00' (midnight).
	
	// What if it's the same day, but one year apart?
	var nextYear = Date.today().add(1).year();

	d1.same().day(nextYear); // false, because the dates must occur on the exact same day. 
	
* * Scenario: Determine if a given date occurs during some week period 2 months from now. * * Example

	var future = Date.today().add(2).months();
	return someDate.same().week(future); // true|false;
	
* * @return {Boolean} true|false */ $P.same = function () { this._same = true; this._isSecond = false; return this; }; /** * Determines if the current date/time occurs during Today. Must be preceded by the .is() function. * Example

	someDate.is().today();    // true|false
	new Date().is().today();  // true
	Date.today().is().today();// true
	Date.today().add(-1).day().is().today(); // false
	
* * @return {Boolean} true|false */ $P.today = function () { return this.same().day(); }; /** * Determines if the current date is a weekday. This function must be preceded by the .is() function. * Example

	Date.today().is().weekday(); // true|false
	
* * @return {Boolean} true|false */ $P.weekday = function () { if (this._nth) { return df("Weekday").call(this); } if (this._move) { return this.addWeekdays(this._orient); } if (this._is) { this._is = false; return (!this.is().sat() && !this.is().sun()); } return false; }; /** * Determines if the current date is on the weekend. This function must be preceded by the .is() function. * Example

	Date.today().is().weekend(); // true|false
	
* * @return {Boolean} true|false */ $P.weekend = function () { if (this._is) { this._is = false; return (this.is().sat() || this.is().sun()); } return false; }; /** * Sets the Time of the current Date instance. A string "6:15 pm" or config object {hour:18, minute:15} are accepted. * Example

	// Set time to 6:15pm with a String
	Date.today().at("6:15pm");

	// Set time to 6:15pm with a config object
	Date.today().at({hour:18, minute:15});
	
* * @return {Date} date */ $P.at = function (time) { return (typeof time === "string") ? $D.parse(this.toString("d") + " " + time) : this.set(time); }; /** * Creates a new Date() and adds this (Number) to the date based on the preceding date element function (eg. second|minute|hour|day|month|year). * Example

	// Undeclared Numbers must be wrapped with parentheses. Requirment of JavaScript.
	(3).days().fromNow();
	(6).months().fromNow();

	// Declared Number variables do not require parentheses. 
	var n = 6;
	n.months().fromNow();
	
* * @return {Date} A new Date instance */ $N.fromNow = $N.after = function (date) { var c = {}; c[this._dateElement] = this; return ((!date) ? new Date() : date.clone()).add(c); }; /** * Creates a new Date() and subtract this (Number) from the date based on the preceding date element function (eg. second|minute|hour|day|month|year). * Example

	// Undeclared Numbers must be wrapped with parentheses. Requirment of JavaScript.
	(3).days().ago();
	(6).months().ago();

	// Declared Number variables do not require parentheses. 
	var n = 6;
	n.months().ago();
	
* * @return {Date} A new Date instance */ $N.ago = $N.before = function (date) { var c = {}, s = (this._dateElement[this._dateElement.length-1] !== "s") ? this._dateElement + "s" : this._dateElement; c[s] = this * -1; return ((!date) ? new Date() : date.clone()).add(c); }; // Do NOT modify the following string tokens. These tokens are used to build dynamic functions. // All culture-specific strings can be found in the CultureInfo files. var dx = ("sunday monday tuesday wednesday thursday friday saturday").split(/\s/), mx = ("january february march april may june july august september october november december").split(/\s/), px = ("Millisecond Second Minute Hour Day Week Month Year Quarter Weekday").split(/\s/), pxf = ("Milliseconds Seconds Minutes Hours Date Week Month FullYear Quarter").split(/\s/), nth = ("final first second third fourth fifth").split(/\s/), de; /** * Returns an object literal of all the date parts. * Example

	var o = new Date().toObject();
	
	// { year: 2008, month: 4, week: 20, day: 13, hour: 18, minute: 9, second: 32, millisecond: 812 }
	
	// The object properties can be referenced directly from the object.
	
	alert(o.day);  // alerts "13"
	alert(o.year); // alerts "2008"
	
* * @return {Date} An object literal representing the original date object. */ $P.toObject = function () { var o = {}; for (var i = 0; i < px.length; i++) { if (this["get" + pxf[i]]) { o[px[i].toLowerCase()] = this["get" + pxf[i]](); } } return o; }; /** * Returns a date created from an object literal. Ignores the .week property if set in the config. * Example

	var o = new Date().toObject();
	
	return Date.fromObject(o); // will return the same date. 

	var o2 = {month: 1, day: 20, hour: 18}; // birthday party!
	Date.fromObject(o2);
	
* * @return {Date} An object literal representing the original date object. */ $D.fromObject = function(config) { config.week = null; return Date.today().set(config); }; // Create day name functions and abbreviated day name functions (eg. monday(), friday(), fri()). var df = function (n) { return function () { if (this._is) { this._is = false; return this.getDay() === n; } if (this._move) { this._move = null; } if (this._nth !== null) { // If the .second() function was called earlier, remove the _orient // from the date, and then continue. // This is required because 'second' can be used in two different context. // // Example // // Date.today().add(1).second(); // Date.march().second().monday(); // // Things get crazy with the following... // Date.march().add(1).second().second().monday(); // but it works!! // if (this._isSecond) { this.addSeconds(this._orient * -1); } // make sure we reset _isSecond this._isSecond = false; var ntemp = this._nth; this._nth = null; var temp = this.clone().moveToLastDayOfMonth(); this.moveToNthOccurrence(n, ntemp); if (this > temp) { throw new RangeError($D.getDayName(n) + " does not occur " + ntemp + " times in the month of " + $D.getMonthName(temp.getMonth()) + " " + temp.getFullYear() + "."); } return this; } return this.moveToDayOfWeek(n, this._orient); }; }; var sdf = function (n) { return function () { var t = $D.today(), shift = n - t.getDay(); if (n === 0 && Date.CultureInfo.firstDayOfWeek === 1 && t.getDay() !== 0) { shift = shift + 7; } return t.addDays(shift); }; }; // Create month name functions and abbreviated month name functions (eg. january(), march(), mar()). var month_instance_functions = function (n) { return function () { if (this._is) { this._is = false; return this.getMonth() === n; } return this.moveToMonth(n, this._orient); }; }; var month_static_functions = function (n) { return function () { return $D.today().set({ month: n, day: 1 }); }; }; var processTerms = function (names, staticFunc, instanceFunc) { for (var i = 0; i < names.length; i++) { // Create constant static Name variables. $D[names[i].toUpperCase()] = $D[names[i].toUpperCase().substring(0, 3)] = i; // Create Name functions. $D[names[i]] = $D[names[i].substring(0, 3)] = staticFunc(i); // Create Name instance functions. $P[names[i]] = $P[names[i].substring(0, 3)] = instanceFunc(i); } }; processTerms(dx, sdf, df); processTerms(mx, month_static_functions, month_instance_functions); // Create date element functions and plural date element functions used with Date (eg. day(), days(), months()). var ef = function (j) { return function () { // if the .second() function was called earlier, the _orient // has alread been added. Just return this and reset _isSecond. if (this._isSecond) { this._isSecond = false; return this; } if (this._same) { this._same = this._is = false; var o1 = this.toObject(), o2 = (arguments[0] || new Date()).toObject(), v = "", k = j.toLowerCase(); // the substr trick with -1 doesn't work in IE8 or less k = (k[k.length-1] === "s") ? k.substring(0,k.length-1) : k; for (var m = (px.length - 1); m > -1; m--) { v = px[m].toLowerCase(); if (o1[v] !== o2[v]) { return false; } if (k === v) { break; } } return true; } if (j.substring(j.length - 1) !== "s") { j += "s"; } if (this._move) { this._move = null; } return this["add" + j](this._orient); }; }; var nf = function (n) { return function () { this._dateElement = n; return this; }; }; for (var k = 0; k < px.length; k++) { de = px[k].toLowerCase(); if(de !== "weekday") { // Create date element functions and plural date element functions used with Date (eg. day(), days(), months()). $P[de] = $P[de + "s"] = ef(px[k]); // Create date element functions and plural date element functions used with Number (eg. day(), days(), months()). $N[de] = $N[de + "s"] = nf(de + "s"); } } $P._ss = ef("Second"); var nthfn = function (n) { return function (dayOfWeek) { if (this._same) { return this._ss(arguments[0]); } if (dayOfWeek || dayOfWeek === 0) { return this.moveToNthOccurrence(dayOfWeek, n); } this._nth = n; // if the operator is 'second' add the _orient, then deal with it later... if (n === 2 && (dayOfWeek === undefined || dayOfWeek === null)) { this._isSecond = true; return this.addSeconds(this._orient); } return this; }; }; for (var l = 0; l < nth.length; l++) { $P[nth[l]] = (l === 0) ? nthfn(-1) : nthfn(l); } }()); (function () { "use strict"; Date.Parsing = { Exception: function (s) { this.message = "Parse error at '" + s.substring(0, 10) + " ...'"; } }; var $P = Date.Parsing; var dayOffsets = { standard: [0,31,59,90,120,151,181,212,243,273,304,334], leap: [0,31,60,91,121,152,182,213,244,274,305,335] }; $P.isLeapYear = function(year) { return ((year % 4 === 0) && (year % 100 !== 0)) || (year % 400 === 0); }; var utils = { multiReplace : function (str, hash ) { var key; for (key in hash) { if (Object.prototype.hasOwnProperty.call(hash, key)) { var regex; if (typeof hash[key] === "function") { } else { regex = (hash[key] instanceof RegExp) ? hash[key] : new RegExp(hash[key], "g"); } str = str.replace(regex, key); } } return str; }, getDayOfYearFromWeek : function (obj) { var d, jan4, offset; obj.weekDay = (!obj.weekDay && obj.weekDay !== 0) ? 1 : obj.weekDay; d = new Date(obj.year, 0, 4); jan4 = d.getDay() === 0 ? 7 : d.getDay(); // JS is 0 indexed on Sunday. offset = jan4+3; obj.dayOfYear = ((obj.week * 7) + (obj.weekDay === 0 ? 7 : obj.weekDay))-offset; return obj; }, getDayOfYear : function (obj, dayOffset) { if (!obj.dayOfYear) { obj = utils.getDayOfYearFromWeek(obj); } for (var i=0;i <= dayOffset.length;i++) { if (obj.dayOfYear < dayOffset[i] || i === dayOffset.length) { obj.day = obj.day ? obj.day : (obj.dayOfYear - dayOffset[i-1]); break; } else { obj.month = i; } } return obj; }, adjustForTimeZone : function (obj, date) { var offset; if (obj.zone.toUpperCase() === "Z" || (obj.zone_hours === 0 && obj.zone_minutes === 0)) { // it's UTC/GML so work out the current timeszone offset offset = -date.getTimezoneOffset(); } else { offset = (obj.zone_hours*60) + (obj.zone_minutes || 0); if (obj.zone_sign === "+") { offset *= -1; } offset -= date.getTimezoneOffset(); } date.setMinutes(date.getMinutes()+offset); return date; }, setDefaults : function (obj) { obj.year = obj.year || Date.today().getFullYear(); obj.hours = obj.hours || 0; obj.minutes = obj.minutes || 0; obj.seconds = obj.seconds || 0; obj.milliseconds = obj.milliseconds || 0; if (!(!obj.month && (obj.week || obj.dayOfYear))) { // if we have a month, or if we don't but don't have the day calculation data obj.month = obj.month || 0; obj.day = obj.day || 1; } return obj; }, dataNum: function (data, mod, explict, postProcess) { var dataNum = data*1; if (mod) { if (postProcess) { return data ? mod(data)*1 : data; } else { return data ? mod(dataNum) : data; } } else if (!explict){ return data ? dataNum : data; } else { return (data && typeof data !== "undefined") ? dataNum : data; } }, timeDataProcess: function (obj) { var timeObj = {}; for (var x in obj.data) { if (obj.data.hasOwnProperty(x)) { timeObj[x] = obj.ignore[x] ? obj.data[x] : utils.dataNum(obj.data[x], obj.mods[x], obj.explict[x], obj.postProcess[x]); } } if (obj.data.secmins) { obj.data.secmins = obj.data.secmins.replace(",", ".") * 60; if (!timeObj.minutes) { timeObj.minutes = obj.data.secmins; } else if (!timeObj.seconds) { timeObj.seconds = obj.data.secmins; } delete obj.secmins; } return timeObj; }, buildTimeObjectFromData: function (data) { var time = utils.timeDataProcess({ data: { year : data[1], month : data[5], day : data[7], week : data[8], dayOfYear : data[10], hours : data[15], zone_hours : data[23], zone_minutes : data[24], zone : data[21], zone_sign : data[22], weekDay : data[9], minutes: data[16], seconds: data[19], milliseconds: data[20], secmins: data[18] }, mods: { month: function(data) { return data-1; }, weekDay: function (data) { data = Math.abs(data); return (data === 7 ? 0 : data); }, minutes: function (data) { return data.replace(":",""); }, seconds: function (data) { return Math.floor( (data.replace(":","").replace(",","."))*1 ); }, milliseconds: function (data) { return (data.replace(",",".")*1000); } }, postProcess: { minutes: true, seconds: true, milliseconds: true }, explict: { zone_hours: true, zone_minutes: true }, ignore: { zone: true, zone_sign: true, secmins: true } }); return time; }, addToHash: function (hash, keys, data) { keys = keys; data = data; var len = keys.length; for (var i = 0; i < len; i++) { hash[keys[i]] = data[i]; } return hash; }, combineRegex: function (r1, r2) { return new RegExp("(("+r1.source+")\\s("+r2.source+"))"); }, getDateNthString: function(add, last, inc){ if (add) { return Date.today().addDays(inc).toString("d"); } else if (last) { return Date.today().last()[inc]().toString("d"); } }, buildRegexData: function (array) { var arr = []; var len = array.length; for (var i=0; i < len; i++) { if (Object.prototype.toString.call(array[i]) === '[object Array]') { // oldIE compat version of Array.isArray arr.push(this.combineRegex(array[i][0], array[i][1])); } else { arr.push(array[i]); } } return arr; } }; $P.processTimeObject = function (obj) { var date, dayOffset; utils.setDefaults(obj); dayOffset = ($P.isLeapYear(obj.year)) ? dayOffsets.leap : dayOffsets.standard; if (!obj.month && (obj.week || obj.dayOfYear)) { utils.getDayOfYear(obj, dayOffset); } else { obj.dayOfYear = dayOffset[obj.month] + obj.day; } date = new Date(obj.year, obj.month, obj.day, obj.hours, obj.minutes, obj.seconds, obj.milliseconds); if (obj.zone) { utils.adjustForTimeZone(obj, date); // adjust (and calculate) for timezone } return date; }; $P.ISO = { regex : /^([\+-]?\d{4}(?!\d{2}\b))((-?)((0[1-9]|1[0-2])(\3([12]\d|0[1-9]|3[01]))?|W([0-4]\d|5[0-3])(-?[1-7])?|(00[1-9]|0[1-9]\d|[12]\d{2}|3([0-5]\d|6[1-6])))([T\s]((([01]\d|2[0-4])((:?)[0-5]\d)?|24\:?00)([\.,]\d+(?!:))?)?(\17[0-5]\d([\.,]\d+)?)?\s?([zZ]|([\+-])([01]\d|2[0-3]):?([0-5]\d)?)?)?)?$/, parse : function (s) { var time, data = s.match(this.regex); if (!data || !data.length) { return null; } time = utils.buildTimeObjectFromData(data); if (!time.year || (!time.year && (!time.month && !time.day) && (!time.week && !time.dayOfYear)) ) { return null; } return $P.processTimeObject(time); } }; $P.Numeric = { isNumeric: function (e){return!isNaN(parseFloat(e))&&isFinite(e);}, regex: /\b([0-1]?[0-9])([0-3]?[0-9])([0-2]?[0-9]?[0-9][0-9])\b/i, parse: function (s) { var data, i, time = {}, order = Date.CultureInfo.dateElementOrder.split(""); if (!(this.isNumeric(s)) || // if it's non-numeric OR (s[0] === "+" && s[0] === "-")) { // It's an arithmatic string (eg +/-1000) return null; } if (s.length < 5 && s.indexOf(".") < 0 && s.indexOf("/") < 0) { // assume it's just a year. time.year = s; return $P.processTimeObject(time); } data = s.match(this.regex); if (!data || !data.length) { return null; } for (i=0; i < order.length; i++) { switch(order[i]) { case "d": time.day = data[i+1]; break; case "m": time.month = (data[i+1]-1); break; case "y": time.year = data[i+1]; break; } } return $P.processTimeObject(time); } }; $P.Normalizer = { regexData: function () { var $R = Date.CultureInfo.regexPatterns; return utils.buildRegexData([ $R.tomorrow, $R.yesterday, [$R.past, $R.mon], [$R.past, $R.tue], [$R.past, $R.wed], [$R.past, $R.thu], [$R.past, $R.fri], [$R.past, $R.sat], [$R.past, $R.sun] ]); }, basicReplaceHash : function() { var $R = Date.CultureInfo.regexPatterns; return { "January": $R.jan.source, "February": $R.feb, "March": $R.mar, "April": $R.apr, "May": $R.may, "June": $R.jun, "July": $R.jul, "August": $R.aug, "September": $R.sep, "October": $R.oct, "November": $R.nov, "December": $R.dec, "": /\bat\b/gi, " ": /\s{2,}/, "am": $R.inTheMorning, "9am": $R.thisMorning, "pm": $R.inTheEvening, "7pm":$R.thisEvening }; }, keys : function(){ return [ utils.getDateNthString(true, false, 1), // tomorrow utils.getDateNthString(true, false, -1), // yesterday utils.getDateNthString(false, true, "monday"), //last mon utils.getDateNthString(false, true, "tuesday"), //last tues utils.getDateNthString(false, true, "wednesday"), //last wed utils.getDateNthString(false, true, "thursday"), //last thurs utils.getDateNthString(false, true, "friday"), //last fri utils.getDateNthString(false, true, "saturday"), //last sat utils.getDateNthString(false, true, "sunday") //last sun ]; }, buildRegexFunctions: function () { var $R = Date.CultureInfo.regexPatterns; var __ = Date.i18n.__; var tomorrowRE = new RegExp("(\\b\\d\\d?("+__("AM")+"|"+__("PM")+")? )("+$R.tomorrow.source.slice(1)+")", "i"); // adapted tomorrow regex for AM PM relative dates var todayRE = new RegExp($R.today.source + "(?!\\s*([+-]))\\b"); // today, but excludes the math operators (eg "today + 2h") this.replaceFuncs = [ [todayRE, function (full) { return (full.length > 1) ? Date.today().toString("d") : full; }], [tomorrowRE, function(full, m1) { var t = Date.today().addDays(1).toString("d"); return (t + " " + m1); }], [$R.amThisMorning, function(str, am){return am;}], [$R.pmThisEvening, function(str, pm){return pm;}] ]; }, buildReplaceData: function () { this.buildRegexFunctions(); this.replaceHash = utils.addToHash(this.basicReplaceHash(), this.keys(), this.regexData()); }, stringReplaceFuncs: function (s) { for (var i=0; i < this.replaceFuncs.length; i++) { s = s.replace(this.replaceFuncs[i][0], this.replaceFuncs[i][1]); } return s; }, parse: function (s) { s = this.stringReplaceFuncs(s); s = utils.multiReplace(s, this.replaceHash); try { var n = s.split(/([\s\-\.\,\/\x27]+)/); if (n.length === 3 && $P.Numeric.isNumeric(n[0]) && $P.Numeric.isNumeric(n[2]) && (n[2].length >= 4)) { // ok, so we're dealing with x/year. But that's not a full date. // This fixes wonky dateElementOrder parsing when set to dmy order. if (Date.CultureInfo.dateElementOrder[0] === "d") { s = "1/" + n[0] + "/" + n[2]; // set to 1st of month and normalize the seperator } } } catch (e) {} return s; } }; $P.Normalizer.buildReplaceData(); }()); (function () { var $P = Date.Parsing; var _ = $P.Operators = { // // Tokenizers // rtoken: function (r) { // regex token return function (s) { var mx = s.match(r); if (mx) { return ([ mx[0], s.substring(mx[0].length) ]); } else { throw new $P.Exception(s); } }; }, token: function () { // whitespace-eating token return function (s) { return _.rtoken(new RegExp("^\\s*" + s + "\\s*"))(s); }; }, stoken: function (s) { // string token return _.rtoken(new RegExp("^" + s)); }, // Atomic Operators until: function (p) { return function (s) { var qx = [], rx = null; while (s.length) { try { rx = p.call(this, s); } catch (e) { qx.push(rx[0]); s = rx[1]; continue; } break; } return [ qx, s ]; }; }, many: function (p) { return function (s) { var rx = [], r = null; while (s.length) { try { r = p.call(this, s); } catch (e) { return [ rx, s ]; } rx.push(r[0]); s = r[1]; } return [ rx, s ]; }; }, // generator operators -- see below optional: function (p) { return function (s) { var r = null; try { r = p.call(this, s); } catch (e) { return [ null, s ]; } return [ r[0], r[1] ]; }; }, not: function (p) { return function (s) { try { p.call(this, s); } catch (e) { return [null, s]; } throw new $P.Exception(s); }; }, ignore: function (p) { return p ? function (s) { var r = null; r = p.call(this, s); return [null, r[1]]; } : null; }, product: function () { var px = arguments[0], qx = Array.prototype.slice.call(arguments, 1), rx = []; for (var i = 0 ; i < px.length ; i++) { rx.push(_.each(px[i], qx)); } return rx; }, cache: function (rule) { var cache = {}, cache_length = 0, cache_keys = [], CACHE_MAX = Date.Config.CACHE_MAX || 100000, r = null; var cacheCheck = function () { if (cache_length === CACHE_MAX) { // kill several keys, don't want to have to do this all the time... for (var i=0; i < 10; i++) { var key = cache_keys.shift(); if (key) { delete cache[key]; cache_length--; } } } }; return function (s) { cacheCheck(); try { r = cache[s] = (cache[s] || rule.call(this, s)); } catch (e) { r = cache[s] = e; } cache_length++; cache_keys.push(s); if (r instanceof $P.Exception) { throw r; } else { return r; } }; }, // vector operators -- see below any: function () { var px = arguments; return function (s) { var r = null; for (var i = 0; i < px.length; i++) { if (px[i] == null) { continue; } try { r = (px[i].call(this, s)); } catch (e) { r = null; } if (r) { return r; } } throw new $P.Exception(s); }; }, each: function () { var px = arguments; return function (s) { var rx = [], r = null; for (var i = 0; i < px.length ; i++) { if (px[i] == null) { continue; } try { r = (px[i].call(this, s)); } catch (e) { throw new $P.Exception(s); } rx.push(r[0]); s = r[1]; } return [ rx, s]; }; }, all: function () { var px = arguments, _ = _; return _.each(_.optional(px)); }, // delimited operators sequence: function (px, d, c) { d = d || _.rtoken(/^\s*/); c = c || null; if (px.length === 1) { return px[0]; } return function (s) { var r = null, q = null; var rx = []; for (var i = 0; i < px.length ; i++) { try { r = px[i].call(this, s); } catch (e) { break; } rx.push(r[0]); try { q = d.call(this, r[1]); } catch (ex) { q = null; break; } s = q[1]; } if (!r) { throw new $P.Exception(s); } if (q) { throw new $P.Exception(q[1]); } if (c) { try { r = c.call(this, r[1]); } catch (ey) { throw new $P.Exception(r[1]); } } return [ rx, (r?r[1]:s) ]; }; }, // // Composite Operators // between: function (d1, p, d2) { d2 = d2 || d1; var _fn = _.each(_.ignore(d1), p, _.ignore(d2)); return function (s) { var rx = _fn.call(this, s); return [[rx[0][0], r[0][2]], rx[1]]; }; }, list: function (p, d, c) { d = d || _.rtoken(/^\s*/); c = c || null; return (p instanceof Array ? _.each(_.product(p.slice(0, -1), _.ignore(d)), p.slice(-1), _.ignore(c)) : _.each(_.many(_.each(p, _.ignore(d))), px, _.ignore(c))); }, set: function (px, d, c) { d = d || _.rtoken(/^\s*/); c = c || null; return function (s) { // r is the current match, best the current 'best' match // which means it parsed the most amount of input var r = null, p = null, q = null, rx = null, best = [[], s], last = false; // go through the rules in the given set for (var i = 0; i < px.length ; i++) { // last is a flag indicating whether this must be the last element // if there is only 1 element, then it MUST be the last one q = null; p = null; r = null; last = (px.length === 1); // first, we try simply to match the current pattern // if not, try the next pattern try { r = px[i].call(this, s); } catch (e) { continue; } // since we are matching against a set of elements, the first // thing to do is to add r[0] to matched elements rx = [[r[0]], r[1]]; // if we matched and there is still input to parse and // we don't already know this is the last element, // we're going to next check for the delimiter ... // if there's none, or if there's no input left to parse // than this must be the last element after all ... if (r[1].length > 0 && ! last) { try { q = d.call(this, r[1]); } catch (ex) { last = true; } } else { last = true; } // if we parsed the delimiter and now there's no more input, // that means we shouldn't have parsed the delimiter at all // so don't update r and mark this as the last element ... if (!last && q[1].length === 0) { last = true; } // so, if this isn't the last element, we're going to see if // we can get any more matches from the remaining (unmatched) // elements ... if (!last) { // build a list of the remaining rules we can match against, // i.e., all but the one we just matched against var qx = []; for (var j = 0; j < px.length ; j++) { if (i !== j) { qx.push(px[j]); } } // now invoke recursively set with the remaining input // note that we don't include the closing delimiter ... // we'll check for that ourselves at the end p = _.set(qx, d).call(this, q[1]); // if we got a non-empty set as a result ... // (otw rx already contains everything we want to match) if (p[0].length > 0) { // update current result, which is stored in rx ... // basically, pick up the remaining text from p[1] // and concat the result from p[0] so that we don't // get endless nesting ... rx[0] = rx[0].concat(p[0]); rx[1] = p[1]; } } // at this point, rx either contains the last matched element // or the entire matched set that starts with this element. // now we just check to see if this variation is better than // our best so far, in terms of how much of the input is parsed if (rx[1].length < best[1].length) { best = rx; } // if we've parsed all the input, then we're finished if (best[1].length === 0) { break; } } // so now we've either gone through all the patterns trying them // as the initial match; or we found one that parsed the entire // input string ... // if best has no matches, just return empty set ... if (best[0].length === 0) { return best; } // if a closing delimiter is provided, then we have to check it also if (c) { // we try this even if there is no remaining input because the pattern // may well be optional or match empty input ... try { q = c.call(this, best[1]); } catch (ey) { throw new $P.Exception(best[1]); } // it parsed ... be sure to update the best match remaining input best[1] = q[1]; } // if we're here, either there was no closing delimiter or we parsed it // so now we have the best match; just return it! return best; }; }, forward: function (gr, fname) { return function (s) { return gr[fname].call(this, s); }; }, // // Translation Operators // replace: function (rule, repl) { return function (s) { var r = rule.call(this, s); return [repl, r[1]]; }; }, process: function (rule, fn) { return function (s) { var r = rule.call(this, s); return [fn.call(this, r[0]), r[1]]; }; }, min: function (min, rule) { return function (s) { var rx = rule.call(this, s); if (rx[0].length < min) { throw new $P.Exception(s); } return rx; }; } }; // Generator Operators And Vector Operators // Generators are operators that have a signature of F(R) => R, // taking a given rule and returning another rule, such as // ignore, which parses a given rule and throws away the result. // Vector operators are those that have a signature of F(R1,R2,...) => R, // take a list of rules and returning a new rule, such as each. // Generator operators are converted (via the following _generator // function) into functions that can also take a list or array of rules // and return an array of new rules as though the function had been // called on each rule in turn (which is what actually happens). // This allows generators to be used with vector operators more easily. // Example: // each(ignore(foo, bar)) instead of each(ignore(foo), ignore(bar)) // This also turns generators into vector operators, which allows // constructs like: // not(cache(foo, bar)) var _generator = function (op) { function gen() { var args = null, rx = [], px, i; if (arguments.length > 1) { args = Array.prototype.slice.call(arguments); } else if (arguments[0] instanceof Array) { args = arguments[0]; } if (args) { px = args.shift(); if (px.length > 0) { args.unshift(px[i]); rx.push(op.apply(null, args)); args.shift(); return rx; } } else { return op.apply(null, arguments); } } return gen; }; var gx = "optional not ignore cache".split(/\s/); for (var i = 0 ; i < gx.length ; i++) { _[gx[i]] = _generator(_[gx[i]]); } var _vector = function (op) { return function () { if (arguments[0] instanceof Array) { return op.apply(null, arguments[0]); } else { return op.apply(null, arguments); } }; }; var vx = "each any all".split(/\s/); for (var j = 0 ; j < vx.length ; j++) { _[vx[j]] = _vector(_[vx[j]]); } }()); (function () { var $D = Date; var flattenAndCompact = function (ax) { var rx = []; for (var i = 0; i < ax.length; i++) { if (ax[i] instanceof Array) { rx = rx.concat(flattenAndCompact(ax[i])); } else { if (ax[i]) { rx.push(ax[i]); } } } return rx; }; var parseMeridian = function () { if (this.meridian && (this.hour || this.hour === 0)) { if (this.meridian === "a" && this.hour > 11 && Date.Config.strict24hr){ throw "Invalid hour and meridian combination"; } else if (this.meridian === "p" && this.hour < 12 && Date.Config.strict24hr){ throw "Invalid hour and meridian combination"; } else if (this.meridian === "p" && this.hour < 12) { this.hour = this.hour + 12; } else if (this.meridian === "a" && this.hour === 12) { this.hour = 0; } } }; var setDefaults = function () { var now = new Date(); if ((this.hour || this.minute) && (!this.month && !this.year && !this.day)) { this.day = now.getDate(); } if (!this.year) { this.year = now.getFullYear(); } if (!this.month && this.month !== 0) { this.month = now.getMonth(); } if (!this.day) { this.day = 1; } if (!this.hour) { this.hour = 0; } if (!this.minute) { this.minute = 0; } if (!this.second) { this.second = 0; } if (!this.millisecond) { this.millisecond = 0; } }; var finishUtils = { getToday: function () { if (this.now || "hour minute second".indexOf(this.unit) !== -1) { return new Date(); } else { return $D.today(); } }, setDaysFromWeekday: function (today, orient){ var gap; orient = orient || 1; this.unit = "day"; gap = ($D.getDayNumberFromName(this.weekday) - today.getDay()); this.days = gap ? ((gap + (orient * 7)) % 7) : (orient * 7); return this; }, setMonthsFromMonth: function (today, orient) { var gap; orient = orient || 1; this.unit = "month"; gap = (this.month - today.getMonth()); this.months = gap ? ((gap + (orient * 12)) % 12) : (orient * 12); this.month = null; return this; }, setDMYFromWeekday: function () { var d = Date[this.weekday](); this.day = d.getDate(); if (!this.month) { this.month = d.getMonth(); } this.year = d.getFullYear(); return this; }, setUnitValue: function (orient) { if (!this.value && this.operator && this.operator !== null && this[this.unit + "s"] && this[this.unit + "s"] !== null) { this[this.unit + "s"] = this[this.unit + "s"] + ((this.operator === "add") ? 1 : -1) + (this.value||0) * orient; } else if (this[this.unit + "s"] == null || this.operator != null) { if (!this.value) { this.value = 1; } this[this.unit + "s"] = this.value * orient; } }, generateDateFromWeeks: function () { var weekday = (this.weekday !== undefined) ? this.weekday : "today"; var d = Date[weekday]().addWeeks(this.weeks); if (this.now) { d.setTimeToNow(); } return d; } }; $D.Translator = { hour: function (s) { return function () { this.hour = Number(s); }; }, minute: function (s) { return function () { this.minute = Number(s); }; }, second: function (s) { return function () { this.second = Number(s); }; }, /* for ss.s format */ secondAndMillisecond: function (s) { return function () { var mx = s.match(/^([0-5][0-9])\.([0-9]{1,3})/); this.second = Number(mx[1]); this.millisecond = Number(mx[2]); }; }, meridian: function (s) { return function () { this.meridian = s.slice(0, 1).toLowerCase(); }; }, timezone: function (s) { return function () { var n = s.replace(/[^\d\+\-]/g, ""); if (n.length) { this.timezoneOffset = Number(n); } else { this.timezone = s.toLowerCase(); } }; }, day: function (x) { var s = x[0]; return function () { this.day = Number(s.match(/\d+/)[0]); if (this.day < 1) { throw "invalid day"; } }; }, month: function (s) { return function () { this.month = (s.length === 3) ? "jan feb mar apr may jun jul aug sep oct nov dec".indexOf(s)/4 : Number(s) - 1; if (this.month < 0) { throw "invalid month"; } }; }, year: function (s) { return function () { var n = Number(s); this.year = ((s.length > 2) ? n : (n + (((n + 2000) < Date.CultureInfo.twoDigitYearMax) ? 2000 : 1900))); }; }, rday: function (s) { return function () { switch (s) { case "yesterday": this.days = -1; break; case "tomorrow": this.days = 1; break; case "today": this.days = 0; break; case "now": this.days = 0; this.now = true; break; } }; }, finishExact: function (x) { var d; x = (x instanceof Array) ? x : [x]; for (var i = 0 ; i < x.length ; i++) { if (x[i]) { x[i].call(this); } } setDefaults.call(this); parseMeridian.call(this); if (this.day > $D.getDaysInMonth(this.year, this.month)) { throw new RangeError(this.day + " is not a valid value for days."); } d = new Date(this.year, this.month, this.day, this.hour, this.minute, this.second, this.millisecond); if (this.year < 100) { d.setFullYear(this.year); // means years less that 100 are process correctly. JS will parse it otherwise as 1900-1999. } if (this.timezone) { d.set({ timezone: this.timezone }); } else if (this.timezoneOffset) { d.set({ timezoneOffset: this.timezoneOffset }); } return d; }, finish: function (x) { var today, expression, orient, temp; x = (x instanceof Array) ? flattenAndCompact(x) : [ x ]; if (x.length === 0) { return null; } for (var i = 0 ; i < x.length ; i++) { if (typeof x[i] === "function") { x[i].call(this); } } if (this.now && !this.unit && !this.operator) { return new Date(); } else { today = finishUtils.getToday.call(this); } expression = !!(this.days && this.days !== null || this.orient || this.operator); orient = ((this.orient === "past" || this.operator === "subtract") ? -1 : 1); if (this.month && this.unit === "week") { this.value = this.month + 1; delete this.month; delete this.day; } if ((this.month || this.month === 0) && "year day hour minute second".indexOf(this.unit) !== -1) { if (!this.value) { this.value = this.month + 1; } this.month = null; expression = true; } if (!expression && this.weekday && !this.day && !this.days) { finishUtils.setDMYFromWeekday.call(this); } if (expression && this.weekday && this.unit !== "month" && this.unit !== "week") { finishUtils.setDaysFromWeekday.call(this, today, orient); } if (this.weekday && this.unit !== "week" && !this.day && !this.days) { temp = Date[this.weekday](); this.day = temp.getDate(); if (temp.getMonth() !== today.getMonth()) { this.month = temp.getMonth(); } } if (this.month && this.unit === "day" && this.operator) { if (!this.value) { this.value = (this.month + 1); } this.month = null; } if (this.value != null && this.month != null && this.year != null) { this.day = this.value * 1; } if (this.month && !this.day && this.value) { today.set({ day: this.value * 1 }); if (!expression) { this.day = this.value * 1; } } if (!this.month && this.value && this.unit === "month" && !this.now) { this.month = this.value; expression = true; } if (expression && (this.month || this.month === 0) && this.unit !== "year") { finishUtils.setMonthsFromMonth.call(this, today, orient); } if (!this.unit) { this.unit = "day"; } finishUtils.setUnitValue.call(this, orient); parseMeridian.call(this); if ((this.month || this.month === 0) && !this.day) { this.day = 1; } if (!this.orient && !this.operator && this.unit === "week" && this.value && !this.day && !this.month) { return Date.today().setWeek(this.value); } if (this.unit === "week" && this.weeks && !this.day && !this.month) { return finishUtils.generateDateFromWeeks.call(this); } if (expression && this.timezone && this.day && this.days) { this.day = this.days; } if (expression){ today.add(this); } else { today.set(this); } if (this.timezone) { this.timezone = this.timezone.toUpperCase(); var offset = $D.getTimezoneOffset(this.timezone); var timezone; if (today.hasDaylightSavingTime()) { // lets check that we're being sane with timezone setting timezone = $D.getTimezoneAbbreviation(offset, today.isDaylightSavingTime()); if (timezone !== this.timezone) { // bugger, we're in a place where things like EST vs EDT matters. if (today.isDaylightSavingTime()) { today.addHours(-1); } else { today.addHours(1); } } } today.setTimezoneOffset(offset); } return today; } }; }()); (function () { var $D = Date; $D.Grammar = {}; var _ = $D.Parsing.Operators, g = $D.Grammar, t = $D.Translator, _fn; // Allow rolling up into general purpose rules _fn = function () { return _.each(_.any.apply(null, arguments), _.not(g.ctoken2("timeContext"))); }; g.datePartDelimiter = _.rtoken(/^([\s\-\.\,\/\x27]+)/); g.timePartDelimiter = _.stoken(":"); g.whiteSpace = _.rtoken(/^\s*/); g.generalDelimiter = _.rtoken(/^(([\s\,]|at|@|on)+)/); var _C = {}; g.ctoken = function (keys) { var fn = _C[keys]; if (! fn) { var c = Date.CultureInfo.regexPatterns; var kx = keys.split(/\s+/), px = []; for (var i = 0; i < kx.length ; i++) { px.push(_.replace(_.rtoken(c[kx[i]]), kx[i])); } fn = _C[keys] = _.any.apply(null, px); } return fn; }; g.ctoken2 = function (key) { return _.rtoken(Date.CultureInfo.regexPatterns[key]); }; var cacheProcessRtoken = function (key, token, type, eachToken) { if (eachToken) { g[key] = _.cache(_.process(_.each(_.rtoken(token),_.optional(g.ctoken2(eachToken))), type)); } else { g[key] = _.cache(_.process(_.rtoken(token), type)); } }; var cacheProcessCtoken = function (token, type) { return _.cache(_.process(g.ctoken2(token), type)); }; var _F = {}; //function cache var _get = function (f) { _F[f] = (_F[f] || g.format(f)[0]); return _F[f]; }; g.allformats = function (fx) { var rx = []; if (fx instanceof Array) { for (var i = 0; i < fx.length; i++) { rx.push(_get(fx[i])); } } else { rx.push(_get(fx)); } return rx; }; g.formats = function (fx) { if (fx instanceof Array) { var rx = []; for (var i = 0 ; i < fx.length ; i++) { rx.push(_get(fx[i])); } return _.any.apply(null, rx); } else { return _get(fx); } }; var grammarFormats = { timeFormats: function(){ var i, RTokenKeys = [ "h", "hh", "H", "HH", "m", "mm", "s", "ss", "ss.s", "z", "zz" ], RToken = [ /^(0[0-9]|1[0-2]|[1-9])/, /^(0[0-9]|1[0-2])/, /^([0-1][0-9]|2[0-3]|[0-9])/, /^([0-1][0-9]|2[0-3])/, /^([0-5][0-9]|[0-9])/, /^[0-5][0-9]/, /^([0-5][0-9]|[0-9])/, /^[0-5][0-9]/, /^[0-5][0-9]\.[0-9]{1,3}/, /^((\+|\-)\s*\d\d\d\d)|((\+|\-)\d\d\:?\d\d)/, /^((\+|\-)\s*\d\d\d\d)|((\+|\-)\d\d\:?\d\d)/ ], tokens = [ t.hour, t.hour, t.hour, t.hour, t.minute, t.minute, t.second, t.second, t.secondAndMillisecond, t.timezone, t.timezone ]; for (i=0; i < RTokenKeys.length; i++) { cacheProcessRtoken(RTokenKeys[i], RToken[i], tokens[i]); } g.hms = _.cache(_.sequence([g.H, g.m, g.s], g.timePartDelimiter)); g.t = cacheProcessCtoken("shortMeridian", t.meridian); g.tt = cacheProcessCtoken("longMeridian", t.meridian); g.zzz = cacheProcessCtoken("timezone", t.timezone); g.timeSuffix = _.each(_.ignore(g.whiteSpace), _.set([ g.tt, g.zzz ])); g.time = _.each(_.optional(_.ignore(_.stoken("T"))), g.hms, g.timeSuffix); }, dateFormats: function () { // pre-loaded rules for different date part order preferences var _setfn = function () { return _.set(arguments, g.datePartDelimiter); }; var i, RTokenKeys = [ "d", "dd", "M", "MM", "y", "yy", "yyy", "yyyy" ], RToken = [ /^([0-2]\d|3[0-1]|\d)/, /^([0-2]\d|3[0-1])/, /^(1[0-2]|0\d|\d)/, /^(1[0-2]|0\d)/, /^(\d+)/, /^(\d\d)/, /^(\d\d?\d?\d?)/, /^(\d\d\d\d)/ ], tokens = [ t.day, t.day, t.month, t.month, t.year, t.year, t.year, t.year ], eachToken = [ "ordinalSuffix", "ordinalSuffix" ]; for (i=0; i < RTokenKeys.length; i++) { cacheProcessRtoken(RTokenKeys[i], RToken[i], tokens[i], eachToken[i]); } g.MMM = g.MMMM = _.cache(_.process(g.ctoken("jan feb mar apr may jun jul aug sep oct nov dec"), t.month)); g.ddd = g.dddd = _.cache(_.process(g.ctoken("sun mon tue wed thu fri sat"), function (s) { return function () { this.weekday = s; }; } )); g.day = _fn(g.d, g.dd); g.month = _fn(g.M, g.MMM); g.year = _fn(g.yyyy, g.yy); g.mdy = _setfn(g.ddd, g.month, g.day, g.year); g.ymd = _setfn(g.ddd, g.year, g.month, g.day); g.dmy = _setfn(g.ddd, g.day, g.month, g.year); g.date = function (s) { return ((g[Date.CultureInfo.dateElementOrder] || g.mdy).call(this, s)); }; }, relative: function () { // relative date / time expressions g.orientation = _.process(g.ctoken("past future"), function (s) { return function () { this.orient = s; }; } ); g.operator = _.process(g.ctoken("add subtract"), function (s) { return function () { this.operator = s; }; } ); g.rday = _.process(g.ctoken("yesterday tomorrow today now"), t.rday); g.unit = _.process(g.ctoken("second minute hour day week month year"), function (s) { return function () { this.unit = s; }; } ); } }; g.buildGrammarFormats = function () { // these need to be rebuilt every time the language changes. _C = {}; grammarFormats.timeFormats(); grammarFormats.dateFormats(); grammarFormats.relative(); g.value = _.process(_.rtoken(/^([-+]?\d+)?(st|nd|rd|th)?/), function (s) { return function () { this.value = s.replace(/\D/g, ""); }; } ); g.expression = _.set([g.rday, g.operator, g.value, g.unit, g.orientation, g.ddd, g.MMM ]); g.format = _.process(_.many( _.any( // translate format specifiers into grammar rules _.process( _.rtoken(/^(dd?d?d?(?!e)|MM?M?M?|yy?y?y?|hh?|HH?|mm?|ss?|tt?|zz?z?)/), function (fmt) { if (g[fmt]) { return g[fmt]; } else { throw $D.Parsing.Exception(fmt); } } ), // translate separator tokens into token rules _.process(_.rtoken(/^[^dMyhHmstz]+/), // all legal separators function (s) { return _.ignore(_.stoken(s)); } ) ) ), // construct the parser ... function (rules) { return _.process(_.each.apply(null, rules), t.finishExact); } ); // starting rule for general purpose grammar g._start = _.process(_.set([ g.date, g.time, g.expression ], g.generalDelimiter, g.whiteSpace), t.finish); }; g.buildGrammarFormats(); // parsing date format specifiers - ex: "h:m:s tt" // this little guy will generate a custom parser based // on the format string, ex: g.format("h:m:s tt") // check for these formats first g._formats = g.formats([ "\"yyyy-MM-ddTHH:mm:ssZ\"", "yyyy-MM-ddTHH:mm:ss.sz", "yyyy-MM-ddTHH:mm:ssZ", "yyyy-MM-ddTHH:mm:ssz", "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-ddTHH:mmZ", "yyyy-MM-ddTHH:mmz", "yyyy-MM-ddTHH:mm", "ddd, MMM dd, yyyy H:mm:ss tt", "ddd MMM d yyyy HH:mm:ss zzz", "MMddyyyy", "ddMMyyyy", "Mddyyyy", "ddMyyyy", "Mdyyyy", "dMyyyy", "yyyy", "Mdyy", "dMyy", "d" ]); // real starting rule: tries selected formats first, // then general purpose rule g.start = function (s) { try { var r = g._formats.call({}, s); if (r[1].length === 0) { return r; } } catch (e) {} return g._start.call({}, s); }; }()); (function () { var $D = Date; /** * @desc Converts the specified string value into its JavaScript Date equivalent using CultureInfo specific format information. * * Example

	///////////
	// Dates //
	///////////

	// 15-Oct-2004
	var d1 = Date.parse("10/15/2004");

	// 15-Oct-2004
	var d1 = Date.parse("15-Oct-2004");

	// 15-Oct-2004
	var d1 = Date.parse("2004.10.15");

	//Fri Oct 15, 2004
	var d1 = Date.parse("Fri Oct 15, 2004");

	///////////
	// Times //
	///////////

	// Today at 10 PM.
	var d1 = Date.parse("10 PM");

	// Today at 10:30 PM.
	var d1 = Date.parse("10:30 P.M.");

	// Today at 6 AM.
	var d1 = Date.parse("06am");

	/////////////////////
	// Dates and Times //
	/////////////////////

	// 8-July-2004 @ 10:30 PM
	var d1 = Date.parse("July 8th, 2004, 10:30 PM");

	// 1-July-2004 @ 10:30 PM
	var d1 = Date.parse("2004-07-01T22:30:00");

	////////////////////
	// Relative Dates //
	////////////////////

	// Returns today's date. The string "today" is culture specific.
	var d1 = Date.parse("today");

	// Returns yesterday's date. The string "yesterday" is culture specific.
	var d1 = Date.parse("yesterday");

	// Returns the date of the next thursday.
	var d1 = Date.parse("Next thursday");

	// Returns the date of the most previous monday.
	var d1 = Date.parse("last monday");

	// Returns today's day + one year.
	var d1 = Date.parse("next year");

	///////////////
	// Date Math //
	///////////////

	// Today + 2 days
	var d1 = Date.parse("t+2");

	// Today + 2 days
	var d1 = Date.parse("today + 2 days");

	// Today + 3 months
	var d1 = Date.parse("t+3m");

	// Today - 1 year
	var d1 = Date.parse("today - 1 year");

	// Today - 1 year
	var d1 = Date.parse("t-1y"); 


	/////////////////////////////
	// Partial Dates and Times //
	/////////////////////////////

	// July 15th of this year.
	var d1 = Date.parse("July 15");

	// 15th day of current day and year.
	var d1 = Date.parse("15");

	// July 1st of current year at 10pm.
	var d1 = Date.parse("7/1 10pm");
	
* * @param {String} The string value to convert into a Date object [Required] * @return {Date} A Date object or null if the string cannot be converted into a Date. */ var parseUtils = { removeOrds: function (s) { ords = s.match(/\b(\d+)(?:st|nd|rd|th)\b/); // find ordinal matches s = ((ords && ords.length === 2) ? s.replace(ords[0], ords[1]) : s); return s; }, grammarParser: function (s) { var r = null; try { r = $D.Grammar.start.call({}, s.replace(/^\s*(\S*(\s+\S+)*)\s*$/, "$1")); } catch (e) { return null; } return ((r[1].length === 0) ? r[0] : null); }, nativeFallback: function(s) { var t; try { // ok we haven't parsed it, last ditch attempt with the built-in parser. t = Date._parse(s); return (t || t === 0) ? new Date(t) : null; } catch (e) { return null; } } }; function parse (s) { var d; if (!s) { return null; } if (s instanceof Date) { return s.clone(); } if (s.length >= 4 && s.charAt(0) !== "0" && s.charAt(0) !== "+"&& s.charAt(0) !== "-") { // ie: 2004 will pass, 0800 won't. // Start with specific formats d = $D.Parsing.ISO.parse(s) || $D.Parsing.Numeric.parse(s); } if (d instanceof Date && !isNaN(d.getTime())) { return d; } else { // find ordinal dates (1st, 3rd, 8th, etc and remove them as they cause parsing issues) s = $D.Parsing.Normalizer.parse(parseUtils.removeOrds(s)); d = parseUtils.grammarParser(s); if (d !== null) { return d; } else { return parseUtils.nativeFallback(s); } } } if (!$D._parse) { $D._parse = $D.parse; } $D.parse = parse; Date.getParseFunction = function (fx) { var fns = Date.Grammar.allformats(fx); return function (s) { var r = null; for (var i = 0; i < fns.length; i++) { try { r = fns[i].call({}, s); } catch (e) { continue; } if (r[1].length === 0) { return r[0]; } } return null; }; }; /** * Converts the specified string value into its JavaScript Date equivalent using the specified format {String} or formats {Array} and the CultureInfo specific format information. * The format of the string value must match one of the supplied formats exactly. * * Example

	// 15-Oct-2004
	var d1 = Date.parseExact("10/15/2004", "M/d/yyyy");

	// 15-Oct-2004
	var d1 = Date.parse("15-Oct-2004", "M-ddd-yyyy");

	// 15-Oct-2004
	var d1 = Date.parse("2004.10.15", "yyyy.MM.dd");

	// Multiple formats
	var d1 = Date.parseExact("10/15/2004", ["M/d/yyyy", "MMMM d, yyyy"]);
	
* * @param {String} The string value to convert into a Date object [Required]. * @param {Object} The expected format {String} or an array of expected formats {Array} of the date string [Required]. * @return {Date} A Date object or null if the string cannot be converted into a Date. */ $D.parseExact = function (s, fx) { return $D.getParseFunction(fx)(s); }; }()); (function () { var $D = Date, $P = $D.prototype, // $C = $D.CultureInfo, // not used atm p = function (s, l) { if (!l) { l = 2; } return ("000" + s).slice(l * -1); }; /** * Converts a PHP format string to Java/.NET format string. * A PHP format string can be used with ._format or .format. * A Java/.NET format string can be used with .toString(). * The .parseExact function will only accept a Java/.NET format string * * Example * var f1 = "%m/%d/%y" * var f2 = Date.normalizeFormat(f1); // "MM/dd/yy" * * new Date().format(f1); // "04/13/08" * new Date()._format(f1); // "04/13/08" * new Date().toString(f2); // "04/13/08" * * var date = Date.parseExact("04/13/08", f2); // Sun Apr 13 2008 * * @param {String} A PHP format string consisting of one or more format spcifiers. * @return {String} The PHP format converted to a Java/.NET format string. */ var normalizerSubstitutions = { "d" : "dd", "%d": "dd", "D" : "ddd", "%a": "ddd", "j" : "dddd", "l" : "dddd", "%A": "dddd", "S" : "S", "F" : "MMMM", "%B": "MMMM", "m" : "MM", "%m": "MM", "M" : "MMM", "%b": "MMM", "%h": "MMM", "n" : "M", "Y" : "yyyy", "%Y": "yyyy", "y" : "yy", "%y": "yy", "g" : "h", "%I": "h", "G" : "H", "h" : "hh", "H" : "HH", "%H": "HH", "i" : "mm", "%M": "mm", "s" : "ss", "%S": "ss", "%r": "hh:mm tt", "%R": "H:mm", "%T": "H:mm:ss", "%X": "t", "%x": "d", "%e": "d", "%D": "MM/dd/yy", "%n": "\\n", "%t": "\\t", "e" : "z", "T" : "z", "%z": "z", "%Z": "z", "Z" : "ZZ", "N" : "u", "w" : "u", "%w": "u", "W" : "W", "%V": "W" }; var normalizer = { substitutes: function (m) { return normalizerSubstitutions[m]; }, interpreted: function (m, x) { var y; switch (m) { case "%u": return x.getDay() + 1; case "z": return x.getOrdinalNumber(); case "%j": return p(x.getOrdinalNumber(), 3); case "%U": var d1 = x.clone().set({month: 0, day: 1}).addDays(-1).moveToDayOfWeek(0), d2 = x.clone().addDays(1).moveToDayOfWeek(0, -1); return (d2 < d1) ? "00" : p((d2.getOrdinalNumber() - d1.getOrdinalNumber()) / 7 + 1); case "%W": return p(x.getWeek()); case "t": return $D.getDaysInMonth(x.getFullYear(), x.getMonth()); case "o": case "%G": return x.setWeek(x.getISOWeek()).toString("yyyy"); case "%g": return x._format("%G").slice(-2); case "a": case "%p": return t("tt").toLowerCase(); case "A": return t("tt").toUpperCase(); case "u": return p(x.getMilliseconds(), 3); case "I": return (x.isDaylightSavingTime()) ? 1 : 0; case "O": return x.getUTCOffset(); case "P": y = x.getUTCOffset(); return y.substring(0, y.length - 2) + ":" + y.substring(y.length - 2); case "B": var now = new Date(); return Math.floor(((now.getHours() * 3600) + (now.getMinutes() * 60) + now.getSeconds() + (now.getTimezoneOffset() + 60) * 60) / 86.4); case "c": return x.toISOString().replace(/\"/g, ""); case "U": return $D.strtotime("now"); case "%c": return t("d") + " " + t("t"); case "%C": return Math.floor(x.getFullYear() / 100 + 1); } }, shouldOverrideDefaults: function (m) { switch (m) { case "%e": return true; default: return false; } }, parse: function (m, context) { var formatString, c = context || new Date(); formatString = normalizer.substitutes(m); if (formatString) { return formatString; } formatString = normalizer.interpreted(m, c); if (formatString) { return formatString; } else { return m; } } }; $D.normalizeFormat = function (format, context) { return format.replace(/(%|\\)?.|%%/g, function(t){ return normalizer.parse(t, context); }); }; /** * Format a local Unix timestamp according to locale settings * * Example: * Date.strftime("%m/%d/%y", new Date()); // "04/13/08" * Date.strftime("c", "2008-04-13T17:52:03Z"); // "04/13/08" * * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @param {Number|String} The number representing the number of seconds that have elapsed since January 1, 1970 (local time). * @return {String} A string representation of the current Date object. */ $D.strftime = function (format, time) { var d = Date.parse(time); return d._format(format); }; /** * Parse any textual datetime description into a Unix timestamp. * A Unix timestamp is the number of seconds that have elapsed since January 1, 1970 (midnight UTC/GMT). * * Example: * Date.strtotime("04/13/08"); // 1208044800 * Date.strtotime("1970-01-01T00:00:00Z"); // 0 * * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @param {Object} A string or date object. * @return {String} A string representation of the current Date object. */ $D.strtotime = function (time) { var d = $D.parse(time); return Math.round($D.UTC(d.getUTCFullYear(), d.getUTCMonth(), d.getUTCDate(), d.getUTCHours(), d.getUTCMinutes(), d.getUTCSeconds(), d.getUTCMilliseconds()) / 1000); }; /** * Converts the value of the current Date object to its equivalent string representation using a PHP/Unix style of date format specifiers. * Format Specifiers * Format Description Example * ------ --------------------------------------------------------------------------- ----------------------- * %a abbreviated weekday name according to the current localed "Mon" through "Sun" * %A full weekday name according to the current localed "Sunday" through "Saturday" * %b abbreviated month name according to the current localed "Jan" through "Dec" * %B full month name according to the current locale "January" through "December" * %c preferred date and time representation for the current locale "4/13/2008 12:33 PM" * %C century number (the year divided by 100 and truncated to an integer) "00" to "99" * %d day of the month as a decimal number "01" to "31" * %D same as %m/%d/%y "04/13/08" * %e day of the month as a decimal number, a single digit is preceded by a space "1" to "31" * %g like %G, but without the century "08" * %G The 4-digit year corresponding to the ISO week number (see %V). "2008" * This has the same format and value as %Y, except that if the ISO week number * belongs to the previous or next year, that year is used instead. * %h same as %b "Jan" through "Dec" * %H hour as a decimal number using a 24-hour clock. "00" to "23" * %I hour as a decimal number using a 12-hour clock. "01" to "12" * %j day of the year as a decimal number. "001" to "366" * %m month as a decimal number. "01" to "12" * %M minute as a decimal number. "00" to "59" * %n newline character "\n" * %p either "am" or "pm" according to the given time value, or the "am" or "pm" * corresponding strings for the current locale. * %r time in a.m. and p.m. notation "8:44 PM" * %R time in 24 hour notation "20:44" * %S second as a decimal number "00" to "59" * %t tab character "\t" * %T current time, equal to %H:%M:%S "12:49:11" * %u weekday as a decimal number ["1", "7"], with "1" representing Monday "1" to "7" * %U week number of the current year as a decimal number, starting with the "0" to ("52" or "53") * first Sunday as the first day of the first week * %V The ISO 8601:1988 week number of the current year as a decimal number, "00" to ("52" or "53") * range 01 to 53, where week 1 is the first week that has at least 4 days * in the current year, and with Monday as the first day of the week. * (Use %G or %g for the year component that corresponds to the week number * for the specified timestamp.) * %W week number of the current year as a decimal number, starting with the "00" to ("52" or "53") * first Monday as the first day of the first week * %w day of the week as a decimal, Sunday being "0" "0" to "6" * %x preferred date representation for the current locale without the time "4/13/2008" * %X preferred time representation for the current locale without the date "12:53:05" * %y year as a decimal number without a century "00" "99" * %Y year as a decimal number including the century "2008" * %Z time zone or name or abbreviation "UTC", "EST", "PST" * %z same as %Z * %% a literal "%" characters "%" * d Day of the month, 2 digits with leading zeros "01" to "31" * D A textual representation of a day, three letters "Mon" through "Sun" * j Day of the month without leading zeros "1" to "31" * l A full textual representation of the day of the week (lowercase "L") "Sunday" through "Saturday" * N ISO-8601 numeric representation of the day of the week (added in PHP 5.1.0) "1" (for Monday) through "7" (for Sunday) * S English ordinal suffix for the day of the month, 2 characters "st", "nd", "rd" or "th". Works well with j * w Numeric representation of the day of the week "0" (for Sunday) through "6" (for Saturday) * z The day of the year (starting from "0") "0" through "365" * W ISO-8601 week number of year, weeks starting on Monday "00" to ("52" or "53") * F A full textual representation of a month, such as January or March "January" through "December" * m Numeric representation of a month, with leading zeros "01" through "12" * M A short textual representation of a month, three letters "Jan" through "Dec" * n Numeric representation of a month, without leading zeros "1" through "12" * t Number of days in the given month "28" through "31" * L Whether it's a leap year "1" if it is a leap year, "0" otherwise * o ISO-8601 year number. This has the same value as Y, except that if the "2008" * ISO week number (W) belongs to the previous or next year, that year * is used instead. * Y A full numeric representation of a year, 4 digits "2008" * y A two digit representation of a year "08" * a Lowercase Ante meridiem and Post meridiem "am" or "pm" * A Uppercase Ante meridiem and Post meridiem "AM" or "PM" * B Swatch Internet time "000" through "999" * g 12-hour format of an hour without leading zeros "1" through "12" * G 24-hour format of an hour without leading zeros "0" through "23" * h 12-hour format of an hour with leading zeros "01" through "12" * H 24-hour format of an hour with leading zeros "00" through "23" * i Minutes with leading zeros "00" to "59" * s Seconds, with leading zeros "00" through "59" * u Milliseconds "54321" * e Timezone identifier "UTC", "EST", "PST" * I Whether or not the date is in daylight saving time (uppercase i) "1" if Daylight Saving Time, "0" otherwise * O Difference to Greenwich time (GMT) in hours "+0200", "-0600" * P Difference to Greenwich time (GMT) with colon between hours and minutes "+02:00", "-06:00" * T Timezone abbreviation "UTC", "EST", "PST" * Z Timezone offset in seconds. The offset for timezones west of UTC is "-43200" through "50400" * always negative, and for those east of UTC is always positive. * c ISO 8601 date "2004-02-12T15:19:21+00:00" * r RFC 2822 formatted date "Thu, 21 Dec 2000 16:01:07 +0200" * U Seconds since the Unix Epoch (January 1 1970 00:00:00 GMT) "0" * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @return {String} A string representation of the current Date object. */ var formatReplace = function (context) { return function (m) { var formatString, override = false; if (m.charAt(0) === "\\" || m.substring(0, 2) === "%%") { return m.replace("\\", "").replace("%%", "%"); } override = normalizer.shouldOverrideDefaults(m); formatString = $D.normalizeFormat(m, context); if (formatString) { return context.toString(formatString, override); } }; }; $P._format = function (format) { var formatter = formatReplace(this); if (!format) { return this._toString(); } else { return format.replace(/(%|\\)?.|%%/g, formatter); } }; if (!$P.format) { $P.format = $P._format; } }()); (function () { "use strict"; var gFn = function (attr) { return function () { return this[attr]; }; }; var sFn = function (attr) { return function (val) { this[attr] = val; return this; }; }; var attrs = ["years", "months", "days", "hours", "minutes", "seconds", "milliseconds"]; var addSetFuncs = function (context, attrs) { for (var i = 0; i < attrs.length ; i++) { var $a = attrs[i], $b = $a.slice(0, 1).toUpperCase() + $a.slice(1); context.prototype[$a] = 0; context.prototype["get" + $b] = gFn($a); context.prototype["set" + $b] = sFn($a); } }; /** * new TimeSpan(milliseconds); * new TimeSpan(days, hours, minutes, seconds); * new TimeSpan(days, hours, minutes, seconds, milliseconds); */ var TimeSpan = function (days, hours, minutes, seconds, milliseconds) { if (arguments.length === 1 && typeof days === "number") { var orient = (days < 0) ? -1 : +1; var millsLeft = Math.abs(days); this.setDays(Math.floor(millsLeft / 86400000) * orient); millsLeft = millsLeft % 86400000; this.setHours(Math.floor(millsLeft / 3600000) * orient); millsLeft = millsLeft % 3600000; this.setMinutes(Math.floor(millsLeft / 60000) * orient); millsLeft = millsLeft % 60000; this.setSeconds(Math.floor(millsLeft / 1000) * orient); millsLeft = millsLeft % 1000; this.setMilliseconds(millsLeft * orient); } else { this.set(days, hours, minutes, seconds, milliseconds); } this.getTotalMilliseconds = function () { return (this.getDays() * 86400000) + (this.getHours() * 3600000) + (this.getMinutes() * 60000) + (this.getSeconds() * 1000); }; this.compareTo = function (time) { var t1 = new Date(1970, 1, 1, this.getHours(), this.getMinutes(), this.getSeconds()), t2; if (time === null) { t2 = new Date(1970, 1, 1, 0, 0, 0); } else { t2 = new Date(1970, 1, 1, time.getHours(), time.getMinutes(), time.getSeconds()); } return (t1 < t2) ? -1 : (t1 > t2) ? 1 : 0; }; this.equals = function (time) { return (this.compareTo(time) === 0); }; this.add = function (time) { return (time === null) ? this : this.addSeconds(time.getTotalMilliseconds() / 1000); }; this.subtract = function (time) { return (time === null) ? this : this.addSeconds(-time.getTotalMilliseconds() / 1000); }; this.addDays = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 86400000)); }; this.addHours = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 3600000)); }; this.addMinutes = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 60000)); }; this.addSeconds = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 1000)); }; this.addMilliseconds = function (n) { return new TimeSpan(this.getTotalMilliseconds() + n); }; this.get12HourHour = function () { return (this.getHours() > 12) ? this.getHours() - 12 : (this.getHours() === 0) ? 12 : this.getHours(); }; this.getDesignator = function () { return (this.getHours() < 12) ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator; }; this.toString = function (format) { this._toString = function () { if (this.getDays() !== null && this.getDays() > 0) { return this.getDays() + "." + this.getHours() + ":" + this.p(this.getMinutes()) + ":" + this.p(this.getSeconds()); } else { return this.getHours() + ":" + this.p(this.getMinutes()) + ":" + this.p(this.getSeconds()); } }; this.p = function (s) { return (s.toString().length < 2) ? "0" + s : s; }; var me = this; return format ? format.replace(/dd?|HH?|hh?|mm?|ss?|tt?/g, function (format) { switch (format) { case "d": return me.getDays(); case "dd": return me.p(me.getDays()); case "H": return me.getHours(); case "HH": return me.p(me.getHours()); case "h": return me.get12HourHour(); case "hh": return me.p(me.get12HourHour()); case "m": return me.getMinutes(); case "mm": return me.p(me.getMinutes()); case "s": return me.getSeconds(); case "ss": return me.p(me.getSeconds()); case "t": return ((me.getHours() < 12) ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator).substring(0, 1); case "tt": return (me.getHours() < 12) ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator; } } ) : this._toString(); }; return this; }; addSetFuncs(TimeSpan, attrs.slice(2)); TimeSpan.prototype.set = function (days, hours, minutes, seconds, milliseconds){ this.setDays(days || this.getDays()); this.setHours(hours || this.getHours()); this.setMinutes(minutes || this.getMinutes()); this.setSeconds(seconds || this.getSeconds()); this.setMilliseconds(milliseconds || this.getMilliseconds()); }; /** * Gets the time of day for this date instances. * @return {TimeSpan} TimeSpan */ Date.prototype.getTimeOfDay = function () { return new TimeSpan(0, this.getHours(), this.getMinutes(), this.getSeconds(), this.getMilliseconds()); }; Date.TimeSpan = TimeSpan; if (typeof window !== "undefined" ) { // keeping API compatible for v1.x window.TimeSpan = TimeSpan; } }()); (function () { "use strict"; var attrs = ["years", "months", "days", "hours", "minutes", "seconds", "milliseconds"]; var gFn = function (attr) { return function () { return this[attr]; }; }; var sFn = function (attr) { return function (val) { this[attr] = val; return this; }; }; var addSetFuncs = function (context, attrs) { for (var i = 0; i < attrs.length ; i++) { var $a = attrs[i], $b = $a.slice(0, 1).toUpperCase() + $a.slice(1); context.prototype[$a] = 0; context.prototype["get" + $b] = gFn($a); context.prototype["set" + $b] = sFn($a); } }; var setMonthsAndYears = function (orient, d1, d2, context) { function inc() { d1.addMonths(-orient); context.months++; if (context.months === 12) { context.years++; context.months = 0; } } if (orient === +1) { while (d1 > d2) { inc(); } } else { while (d1 < d2) { inc(); } } context.months--; context.months *= orient; context.years *= orient; }; var adjustForDST = function(orient, startDate, endDate) { var hasDSTMismatch = (false === (startDate.isDaylightSavingTime() === endDate.isDaylightSavingTime())); if (hasDSTMismatch && orient === 1) { startDate.addHours(-1); } else if (hasDSTMismatch) { startDate.addHours(1); } }; /** * TimePeriod(startDate, endDate); * TimePeriod(years, months, days, hours, minutes, seconds, milliseconds); */ var TimePeriod = function (years, months, days, hours, minutes, seconds, milliseconds) { if (arguments.length === 7) { this.set(years, months, days, hours, minutes, seconds, milliseconds); } else if (arguments.length === 2 && arguments[0] instanceof Date && arguments[1] instanceof Date) { var startDate = arguments[0].clone(); var endDate = arguments[1].clone(); var orient = (startDate > endDate) ? +1 : -1; this.dates = { start: arguments[0].clone(), end: arguments[1].clone() }; setMonthsAndYears(orient, startDate, endDate, this); adjustForDST(orient, startDate, endDate); // // TODO - adjust for DST var diff = endDate - startDate; if (diff !== 0) { var ts = new TimeSpan(diff); this.set(this.years, this.months, ts.getDays(), ts.getHours(), ts.getMinutes(), ts.getSeconds(), ts.getMilliseconds()); } } return this; }; // create all the set functions. addSetFuncs(TimePeriod, attrs); TimePeriod.prototype.set = function (years, months, days, hours, minutes, seconds, milliseconds){ this.setYears(years || this.getYears()); this.setMonths(months || this.getMonths()); this.setDays(days || this.getDays()); this.setHours(hours || this.getHours()); this.setMinutes(minutes || this.getMinutes()); this.setSeconds(seconds || this.getSeconds()); this.setMilliseconds(milliseconds || this.getMilliseconds()); }; Date.TimePeriod = TimePeriod; if (typeof window !== "undefined") { // keeping API compatible for v1.x window.TimePeriod = TimePeriod; } }()); ================================================ FILE: build/date-mr-IN.js ================================================ /** * @overview datejs * @version 1.0.0-rc3 * @author Gregory Wild-Smith * @copyright 2015 Gregory Wild-Smith * @license MIT * @homepage https://github.com/abritinthebay/datejs */ /* * DateJS Culture String File * Country Code: mr-IN * Name: Marathi (India) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["mr-IN"] = { "name": "mr-IN", "englishName": "Marathi (India)", "nativeName": "मराठी (भारत)", "Sunday": "रविवार", "Monday": "सोमवार", "Tuesday": "मंगळवार", "Wednesday": "बुधवार", "Thursday": "गुरुवार", "Friday": "शुक्रवार", "Saturday": "शनिवार", "Sun": "रवि.", "Mon": "सोम.", "Tue": "मंगळ.", "Wed": "बुध.", "Thu": "गुरु.", "Fri": "शुक्र.", "Sat": "शनि.", "Su": "र", "Mo": "स", "Tu": "म", "We": "ब", "Th": "ग", "Fr": "श", "Sa": "श", "S_Sun_Initial": "र", "M_Mon_Initial": "स", "T_Tue_Initial": "म", "W_Wed_Initial": "ब", "T_Thu_Initial": "ग", "F_Fri_Initial": "श", "S_Sat_Initial": "श", "January": "जानेवारी", "February": "फेब्रुवारी", "March": "मार्च", "April": "एप्रिल", "May": "मे", "June": "जून", "July": "जुलै", "August": "ऑगस्ट", "September": "सप्टेंबर", "October": "ऑक्टोबर", "November": "नोव्हेंबर", "December": "डिसेंबर", "Jan_Abbr": "जाने.", "Feb_Abbr": "फेब्रु.", "Mar_Abbr": "मार्च", "Apr_Abbr": "एप्रिल", "May_Abbr": "मे", "Jun_Abbr": "जून", "Jul_Abbr": "जुलै", "Aug_Abbr": "ऑगस्ट", "Sep_Abbr": "सप्टें.", "Oct_Abbr": "ऑक्टो.", "Nov_Abbr": "नोव्हें.", "Dec_Abbr": "डिसें.", "AM": "म.पू.", "PM": "म.नं.", "firstDayOfWeek": 1, "twoDigitYearMax": 2029, "mdy": "dmy", "M/d/yyyy": "dd-MM-yyyy", "dddd, MMMM dd, yyyy": "dd MMMM yyyy", "h:mm tt": "HH:mm", "h:mm:ss tt": "HH:mm:ss", "dddd, MMMM dd, yyyy h:mm:ss tt": "dd MMMM yyyy HH:mm:ss", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "dd MMMM", "MMMM, yyyy": "MMMM, yyyy", "/jan(uary)?/": "जाने(.(वारी)?)?", "/feb(ruary)?/": "फेब्रु(.(वारी)?)?", "/mar(ch)?/": "मार्च", "/apr(il)?/": "एप्रिल", "/may/": "मे", "/jun(e)?/": "जून", "/jul(y)?/": "जुलै", "/aug(ust)?/": "ऑगस्ट", "/sep(t(ember)?)?/": "सप्टें(.(बर)?)?", "/oct(ober)?/": "ऑक्टो(.(बर)?)?", "/nov(ember)?/": "नोव्हें(.(बर)?)?", "/dec(ember)?/": "डिसें(.(बर)?)?", "/^su(n(day)?)?/": "^र(वि(.(वार)?)?)?", "/^mo(n(day)?)?/": "^स(ोम(.(वार)?)?)?", "/^tu(e(s(day)?)?)?/": "^म(ंगळ(.(वार)?)?)?", "/^we(d(nesday)?)?/": "^ब(ुध(.(वार)?)?)?", "/^th(u(r(s(day)?)?)?)?/": "^ग(ुरु(.(वार)?)?)?", "/^fr(i(day)?)?/": "^श(ुक्र(.(वार)?)?)?", "/^sa(t(urday)?)?/": "^श(नि(.(वार)?)?)?", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "mr-IN"; /** * @overview datejs * @version 1.0.0-rc3 * @author Gregory Wild-Smith * @copyright 2015 Gregory Wild-Smith * @license MIT * @homepage https://github.com/abritinthebay/datejs */(function () { var $D = Date; var lang = Date.CultureStrings ? Date.CultureStrings.lang : null; var loggedKeys = {}; // for debug purposes. var getText = { getFromKey: function (key, countryCode) { var output; if (Date.CultureStrings && Date.CultureStrings[countryCode] && Date.CultureStrings[countryCode][key]) { output = Date.CultureStrings[countryCode][key]; } else { output = getText.buildFromDefault(key); } if (key.charAt(0) === "/") { // Assume it's a regex output = getText.buildFromRegex(key, countryCode); } return output; }, getFromObjectValues: function (obj, countryCode) { var key, output = {}; for(key in obj) { if (obj.hasOwnProperty(key)) { output[key] = getText.getFromKey(obj[key], countryCode); } } return output; }, getFromObjectKeys: function (obj, countryCode) { var key, output = {}; for(key in obj) { if (obj.hasOwnProperty(key)) { output[getText.getFromKey(key, countryCode)] = obj[key]; } } return output; }, getFromArray: function (arr, countryCode) { var output = []; for (var i=0; i < arr.length; i++){ if (i in arr) { output[i] = getText.getFromKey(arr[i], countryCode); } } return output; }, buildFromDefault: function (key) { var output, length, split, last; switch(key) { case "name": output = "en-US"; break; case "englishName": output = "English (United States)"; break; case "nativeName": output = "English (United States)"; break; case "twoDigitYearMax": output = 2049; break; case "firstDayOfWeek": output = 0; break; default: output = key; split = key.split("_"); length = split.length; if (length > 1 && key.charAt(0) !== "/") { // if the key isn't a regex and it has a split. last = split[(length - 1)].toLowerCase(); if (last === "initial" || last === "abbr") { output = split[0]; } } break; } return output; }, buildFromRegex: function (key, countryCode) { var output; if (Date.CultureStrings && Date.CultureStrings[countryCode] && Date.CultureStrings[countryCode][key]) { output = new RegExp(Date.CultureStrings[countryCode][key], "i"); } else { output = new RegExp(key.replace(new RegExp("/", "g"),""), "i"); } return output; } }; var shallowMerge = function (obj1, obj2) { for (var attrname in obj2) { if (obj2.hasOwnProperty(attrname)) { obj1[attrname] = obj2[attrname]; } } }; var __ = function (key, language) { var countryCode = (language) ? language : lang; loggedKeys[key] = key; if (typeof key === "object") { if (key instanceof Array) { return getText.getFromArray(key, countryCode); } else { return getText.getFromObjectKeys(key, countryCode); } } else { return getText.getFromKey(key, countryCode); } }; var loadI18nScript = function (code) { // paatterned after jQuery's getScript. var url = Date.Config.i18n + code + ".js"; var head = document.getElementsByTagName("head")[0] || document.documentElement; var script = document.createElement("script"); script.src = url; var completed = false; var events = { done: function (){} // placeholder function }; // Attach handlers for all browsers script.onload = script.onreadystatechange = function() { if ( !completed && (!this.readyState || this.readyState === "loaded" || this.readyState === "complete") ) { events.done(); head.removeChild(script); } }; setTimeout(function() { head.insertBefore(script, head.firstChild); }, 0); // allows return to execute first return { done: function (cb) { events.done = function() { if (cb) { setTimeout(cb,0); } }; } }; }; var buildInfo = { buildFromMethodHash: function (obj) { var key; for(key in obj) { if (obj.hasOwnProperty(key)) { obj[key] = buildInfo[obj[key]](); } } return obj; }, timeZoneDST: function () { var DST = { "CHADT": "+1345", "NZDT": "+1300", "AEDT": "+1100", "ACDT": "+1030", "AZST": "+0500", "IRDT": "+0430", "EEST": "+0300", "CEST": "+0200", "BST": "+0100", "PMDT": "-0200", "ADT": "-0300", "NDT": "-0230", "EDT": "-0400", "CDT": "-0500", "MDT": "-0600", "PDT": "-0700", "AKDT": "-0800", "HADT": "-0900" }; return __(DST); }, timeZoneStandard: function () { var standard = { "LINT": "+1400", "TOT": "+1300", "CHAST": "+1245", "NZST": "+1200", "NFT": "+1130", "SBT": "+1100", "AEST": "+1000", "ACST": "+0930", "JST": "+0900", "CWST": "+0845", "CT": "+0800", "ICT": "+0700", "MMT": "+0630", "BST": "+0600", "NPT": "+0545", "IST": "+0530", "PKT": "+0500", "AFT": "+0430", "MSK": "+0400", "IRST": "+0330", "FET": "+0300", "EET": "+0200", "CET": "+0100", "GMT": "+0000", "UTC": "+0000", "CVT": "-0100", "GST": "-0200", "BRT": "-0300", "NST": "-0330", "AST": "-0400", "EST": "-0500", "CST": "-0600", "MST": "-0700", "PST": "-0800", "AKST": "-0900", "MIT": "-0930", "HST": "-1000", "SST": "-1100", "BIT": "-1200" }; return __(standard); }, timeZones: function (data) { var zone; data.timezones = []; for (zone in data.abbreviatedTimeZoneStandard) { if (data.abbreviatedTimeZoneStandard.hasOwnProperty(zone)) { data.timezones.push({ name: zone, offset: data.abbreviatedTimeZoneStandard[zone]}); } } for (zone in data.abbreviatedTimeZoneDST) { if (data.abbreviatedTimeZoneDST.hasOwnProperty(zone)) { data.timezones.push({ name: zone, offset: data.abbreviatedTimeZoneDST[zone], dst: true}); } } return data.timezones; }, days: function () { return __(["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"]); }, dayAbbr: function () { return __(["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"]); }, dayShortNames: function () { return __(["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"]); }, dayFirstLetters: function () { return __(["S_Sun_Initial", "M_Mon_Initial", "T_Tues_Initial", "W_Wed_Initial", "T_Thu_Initial", "F_Fri_Initial", "S_Sat_Initial"]); }, months: function () { return __(["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"]); }, monthAbbr: function () { return __(["Jan_Abbr", "Feb_Abbr", "Mar_Abbr", "Apr_Abbr", "May_Abbr", "Jun_Abbr", "Jul_Abbr", "Aug_Abbr", "Sep_Abbr", "Oct_Abbr", "Nov_Abbr", "Dec_Abbr"]); }, formatPatterns: function () { return getText.getFromObjectValues({ shortDate: "M/d/yyyy", longDate: "dddd, MMMM dd, yyyy", shortTime: "h:mm tt", longTime: "h:mm:ss tt", fullDateTime: "dddd, MMMM dd, yyyy h:mm:ss tt", sortableDateTime: "yyyy-MM-ddTHH:mm:ss", universalSortableDateTime: "yyyy-MM-dd HH:mm:ssZ", rfc1123: "ddd, dd MMM yyyy HH:mm:ss", monthDay: "MMMM dd", yearMonth: "MMMM, yyyy" }, Date.i18n.currentLanguage()); }, regex: function () { return getText.getFromObjectValues({ inTheMorning: "/( in the )(morn(ing)?)\\b/", thisMorning: "/(this )(morn(ing)?)\\b/", amThisMorning: "/(\b\\d(am)? )(this )(morn(ing)?)/", inTheEvening: "/( in the )(even(ing)?)\\b/", thisEvening: "/(this )(even(ing)?)\\b/", pmThisEvening: "/(\b\\d(pm)? )(this )(even(ing)?)/", jan: "/jan(uary)?/", feb: "/feb(ruary)?/", mar: "/mar(ch)?/", apr: "/apr(il)?/", may: "/may/", jun: "/jun(e)?/", jul: "/jul(y)?/", aug: "/aug(ust)?/", sep: "/sep(t(ember)?)?/", oct: "/oct(ober)?/", nov: "/nov(ember)?/", dec: "/dec(ember)?/", sun: "/^su(n(day)?)?/", mon: "/^mo(n(day)?)?/", tue: "/^tu(e(s(day)?)?)?/", wed: "/^we(d(nesday)?)?/", thu: "/^th(u(r(s(day)?)?)?)?/", fri: "/fr(i(day)?)?/", sat: "/^sa(t(urday)?)?/", future: "/^next/", past: "/^last|past|prev(ious)?/", add: "/^(\\+|aft(er)?|from|hence)/", subtract: "/^(\\-|bef(ore)?|ago)/", yesterday: "/^yes(terday)?/", today: "/^t(od(ay)?)?/", tomorrow: "/^tom(orrow)?/", now: "/^n(ow)?/", millisecond: "/^ms|milli(second)?s?/", second: "/^sec(ond)?s?/", minute: "/^mn|min(ute)?s?/", hour: "/^h(our)?s?/", week: "/^w(eek)?s?/", month: "/^m(onth)?s?/", day: "/^d(ay)?s?/", year: "/^y(ear)?s?/", shortMeridian: "/^(a|p)/", longMeridian: "/^(a\\.?m?\\.?|p\\.?m?\\.?)/", timezone: "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/", ordinalSuffix: "/^\\s*(st|nd|rd|th)/", timeContext: "/^\\s*(\\:|a(?!u|p)|p)/" }, Date.i18n.currentLanguage()); } }; var CultureInfo = function () { var info = getText.getFromObjectValues({ name: "name", englishName: "englishName", nativeName: "nativeName", amDesignator: "AM", pmDesignator: "PM", firstDayOfWeek: "firstDayOfWeek", twoDigitYearMax: "twoDigitYearMax", dateElementOrder: "mdy" }, Date.i18n.currentLanguage()); var constructedInfo = buildInfo.buildFromMethodHash({ dayNames: "days", abbreviatedDayNames: "dayAbbr", shortestDayNames: "dayShortNames", firstLetterDayNames: "dayFirstLetters", monthNames: "months", abbreviatedMonthNames: "monthAbbr", formatPatterns: "formatPatterns", regexPatterns: "regex", abbreviatedTimeZoneDST: "timeZoneDST", abbreviatedTimeZoneStandard: "timeZoneStandard" }); shallowMerge(info, constructedInfo); buildInfo.timeZones(info); return info; }; $D.i18n = { __: function (key, lang) { return __(key, lang); }, currentLanguage: function () { return lang || "en-US"; }, setLanguage: function (code, force, cb) { var async = false; if (force || code === "en-US" || (!!Date.CultureStrings && !!Date.CultureStrings[code])) { lang = code; Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings.lang = code; Date.CultureInfo = new CultureInfo(); } else { if (!(!!Date.CultureStrings && !!Date.CultureStrings[code])) { if (typeof exports !== "undefined" && this.exports !== exports) { // we're in a Node enviroment, load it using require try { require("../i18n/" + code + ".js"); lang = code; Date.CultureStrings.lang = code; Date.CultureInfo = new CultureInfo(); } catch (e) { // var str = "The language for '" + code + "' could not be loaded by Node. It likely does not exist."; throw new Error("The DateJS IETF language tag '" + code + "' could not be loaded by Node. It likely does not exist."); } } else if (Date.Config && Date.Config.i18n) { // we know the location of the files, so lets load them async = true; loadI18nScript(code).done(function(){ lang = code; Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings.lang = code; Date.CultureInfo = new CultureInfo(); $D.Parsing.Normalizer.buildReplaceData(); // because this is async if ($D.Grammar) { $D.Grammar.buildGrammarFormats(); // so we can parse those strings... } if (cb) { setTimeout(cb,0); } }); } else { Date.console.error("The DateJS IETF language tag '" + code + "' is not available and has not been loaded."); return false; } } } $D.Parsing.Normalizer.buildReplaceData(); // rebuild normalizer strings if ($D.Grammar) { $D.Grammar.buildGrammarFormats(); // so we can parse those strings... } if (!async && cb) { setTimeout(cb,0); } }, getLoggedKeys: function () { return loggedKeys; }, updateCultureInfo: function () { Date.CultureInfo = new CultureInfo(); } }; $D.i18n.updateCultureInfo(); // run automatically }()); (function () { var $D = Date, $P = $D.prototype, p = function (s, l) { if (!l) { l = 2; } return ("000" + s).slice(l * -1); }; if (typeof window !== "undefined" && typeof window.console !== "undefined" && typeof window.console.log !== "undefined") { $D.console = console; // used only to raise non-critical errors if available } else { // set mock so we don't give errors. $D.console = { log: function(){}, error: function(){} }; } $D.Config = $D.Config || {}; $D.initOverloads = function() { /** * Overload of Date.now. Allows an alternate call for Date.now where it returns the * current Date as an object rather than just milliseconds since the Unix Epoch. * * Also provides an implementation of now() for browsers (IE<9) that don't have it. * * Backwards compatible so with work with either: * Date.now() [returns ms] * or * Date.now(true) [returns Date] */ if (!$D.now) { $D._now = function now() { return new Date().getTime(); }; } else if (!$D._now) { $D._now = $D.now; } $D.now = function (returnObj) { if (returnObj) { return $D.present(); } else { return $D._now(); } }; if ( !$P.toISOString ) { $P.toISOString = function() { return this.getUTCFullYear() + "-" + p(this.getUTCMonth() + 1) + "-" + p(this.getUTCDate()) + "T" + p(this.getUTCHours()) + ":" + p(this.getUTCMinutes()) + ":" + p(this.getUTCSeconds()) + "." + String( (this.getUTCMilliseconds()/1000).toFixed(3)).slice(2, 5) + "Z"; }; } // private if ( $P._toString === undefined ){ $P._toString = $P.toString; } }; $D.initOverloads(); /** * Gets a date that is set to the current date. The time is set to the start of the day (00:00 or 12:00 AM). * @return {Date} The current date. */ $D.today = function () { return new Date().clearTime(); }; /** * Gets a date that is set to the current date and time (same as new Date, but chainable) * @return {Date} The current date. */ $D.present = function () { return new Date(); }; /** * Compares the first date to the second date and returns an number indication of their relative values. * @param {Date} First Date object to compare [Required]. * @param {Date} Second Date object to compare to [Required]. * @return {Number} -1 = date1 is lessthan date2. 0 = values are equal. 1 = date1 is greaterthan date2. */ $D.compare = function (date1, date2) { if (isNaN(date1) || isNaN(date2)) { throw new Error(date1 + " - " + date2); } else if (date1 instanceof Date && date2 instanceof Date) { return (date1 < date2) ? -1 : (date1 > date2) ? 1 : 0; } else { throw new TypeError(date1 + " - " + date2); } }; /** * Compares the first Date object to the second Date object and returns true if they are equal. * @param {Date} First Date object to compare [Required] * @param {Date} Second Date object to compare to [Required] * @return {Boolean} true if dates are equal. false if they are not equal. */ $D.equals = function (date1, date2) { return (date1.compareTo(date2) === 0); }; /** * Gets the language appropriate day name when given the day number(0-6) * eg - 0 == Sunday * @return {String} The day name */ $D.getDayName = function (n) { return Date.CultureInfo.dayNames[n]; }; /** * Gets the day number (0-6) if given a CultureInfo specific string which is a valid dayName, abbreviatedDayName or shortestDayName (two char). * @param {String} The name of the day (eg. "Monday, "Mon", "tuesday", "tue", "We", "we"). * @return {Number} The day number */ $D.getDayNumberFromName = function (name) { var n = Date.CultureInfo.dayNames, m = Date.CultureInfo.abbreviatedDayNames, o = Date.CultureInfo.shortestDayNames, s = name.toLowerCase(); for (var i = 0; i < n.length; i++) { if (n[i].toLowerCase() === s || m[i].toLowerCase() === s || o[i].toLowerCase() === s) { return i; } } return -1; }; /** * Gets the month number (0-11) if given a Culture Info specific string which is a valid monthName or abbreviatedMonthName. * @param {String} The name of the month (eg. "February, "Feb", "october", "oct"). * @return {Number} The day number */ $D.getMonthNumberFromName = function (name) { var n = Date.CultureInfo.monthNames, m = Date.CultureInfo.abbreviatedMonthNames, s = name.toLowerCase(); for (var i = 0; i < n.length; i++) { if (n[i].toLowerCase() === s || m[i].toLowerCase() === s) { return i; } } return -1; }; /** * Gets the language appropriate month name when given the month number(0-11) * eg - 0 == January * @return {String} The month name */ $D.getMonthName = function (n) { return Date.CultureInfo.monthNames[n]; }; /** * Determines if the current date instance is within a LeapYear. * @param {Number} The year. * @return {Boolean} true if date is within a LeapYear, otherwise false. */ $D.isLeapYear = function (year) { return ((year % 4 === 0 && year % 100 !== 0) || year % 400 === 0); }; /** * Gets the number of days in the month, given a year and month value. Automatically corrects for LeapYear. * @param {Number} The year. * @param {Number} The month (0-11). * @return {Number} The number of days in the month. */ $D.getDaysInMonth = function (year, month) { if (!month && $D.validateMonth(year)) { month = year; year = Date.today().getFullYear(); } return [31, ($D.isLeapYear(year) ? 29 : 28), 31, 30, 31, 30, 31, 31, 30, 31, 30, 31][month]; }; $P.getDaysInMonth = function () { return $D.getDaysInMonth(this.getFullYear(), this.getMonth()); }; $D.getTimezoneAbbreviation = function (offset, dst) { var p, n = (dst || false) ? Date.CultureInfo.abbreviatedTimeZoneDST : Date.CultureInfo.abbreviatedTimeZoneStandard; for (p in n) { if (n.hasOwnProperty(p)) { if (n[p] === offset) { return p; } } } return null; }; $D.getTimezoneOffset = function (name, dst) { var i, a =[], z = Date.CultureInfo.timezones; if (!name) { name = (new Date()).getTimezone();} for (i = 0; i < z.length; i++) { if (z[i].name === name.toUpperCase()) { a.push(i); } } if (!z[a[0]]) { return null; } if (a.length === 1 || !dst) { return z[a[0]].offset; } else { for (i=0; i < a.length; i++) { if (z[a[i]].dst) { return z[a[i]].offset; } } } }; $D.getQuarter = function (d) { d = d || new Date(); // If no date supplied, use today var q = [1,2,3,4]; return q[Math.floor(d.getMonth() / 3)]; // ~~~ is a bitwise op. Faster than Math.floor }; $D.getDaysLeftInQuarter = function (d) { d = d || new Date(); var qEnd = new Date(d); qEnd.setMonth(qEnd.getMonth() + 3 - qEnd.getMonth() % 3, 0); return Math.floor((qEnd - d) / 8.64e7); }; // private var validate = function (n, min, max, name) { name = name ? name : "Object"; if (typeof n === "undefined") { return false; } else if (typeof n !== "number") { throw new TypeError(n + " is not a Number."); } else if (n < min || n > max) { // As failing validation is *not* an exceptional circumstance // lets not throw a RangeError Exception here. // It's semantically correct but it's not sensible. return false; } return true; }; /** * Validates the number is within an acceptable range for milliseconds [0-999]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateMillisecond = function (value) { return validate(value, 0, 999, "millisecond"); }; /** * Validates the number is within an acceptable range for seconds [0-59]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateSecond = function (value) { return validate(value, 0, 59, "second"); }; /** * Validates the number is within an acceptable range for minutes [0-59]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateMinute = function (value) { return validate(value, 0, 59, "minute"); }; /** * Validates the number is within an acceptable range for hours [0-23]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateHour = function (value) { return validate(value, 0, 23, "hour"); }; /** * Validates the number is within an acceptable range for the days in a month [0-MaxDaysInMonth]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateDay = function (value, year, month) { if (year === undefined || year === null || month === undefined || month === null) { return false;} return validate(value, 1, $D.getDaysInMonth(year, month), "day"); }; /** * Validates the number is within an acceptable range for months [0-11]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateWeek = function (value) { return validate(value, 0, 53, "week"); }; /** * Validates the number is within an acceptable range for months [0-11]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateMonth = function (value) { return validate(value, 0, 11, "month"); }; /** * Validates the number is within an acceptable range for years. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateYear = function (value) { /** * Per ECMAScript spec the range of times supported by Date objects is * exactly -100,000,000 days to +100,000,000 days measured relative to * midnight at the beginning of 01 January, 1970 UTC. * This gives a range of 8,640,000,000,000,000 milliseconds to either * side of 01 January, 1970 UTC. * * Earliest possible date: Tue, 20 Apr 271,822 B.C. 00:00:00 UTC * Latest possible date: Sat, 13 Sep 275,760 00:00:00 UTC */ return validate(value, -271822, 275760, "year"); }; $D.validateTimezone = function(value) { var timezones = {"ACDT":1,"ACST":1,"ACT":1,"ADT":1,"AEDT":1,"AEST":1,"AFT":1,"AKDT":1,"AKST":1,"AMST":1,"AMT":1,"ART":1,"AST":1,"AWDT":1,"AWST":1,"AZOST":1,"AZT":1,"BDT":1,"BIOT":1,"BIT":1,"BOT":1,"BRT":1,"BST":1,"BTT":1,"CAT":1,"CCT":1,"CDT":1,"CEDT":1,"CEST":1,"CET":1,"CHADT":1,"CHAST":1,"CHOT":1,"ChST":1,"CHUT":1,"CIST":1,"CIT":1,"CKT":1,"CLST":1,"CLT":1,"COST":1,"COT":1,"CST":1,"CT":1,"CVT":1,"CWST":1,"CXT":1,"DAVT":1,"DDUT":1,"DFT":1,"EASST":1,"EAST":1,"EAT":1,"ECT":1,"EDT":1,"EEDT":1,"EEST":1,"EET":1,"EGST":1,"EGT":1,"EIT":1,"EST":1,"FET":1,"FJT":1,"FKST":1,"FKT":1,"FNT":1,"GALT":1,"GAMT":1,"GET":1,"GFT":1,"GILT":1,"GIT":1,"GMT":1,"GST":1,"GYT":1,"HADT":1,"HAEC":1,"HAST":1,"HKT":1,"HMT":1,"HOVT":1,"HST":1,"ICT":1,"IDT":1,"IOT":1,"IRDT":1,"IRKT":1,"IRST":1,"IST":1,"JST":1,"KGT":1,"KOST":1,"KRAT":1,"KST":1,"LHST":1,"LINT":1,"MAGT":1,"MART":1,"MAWT":1,"MDT":1,"MET":1,"MEST":1,"MHT":1,"MIST":1,"MIT":1,"MMT":1,"MSK":1,"MST":1,"MUT":1,"MVT":1,"MYT":1,"NCT":1,"NDT":1,"NFT":1,"NPT":1,"NST":1,"NT":1,"NUT":1,"NZDT":1,"NZST":1,"OMST":1,"ORAT":1,"PDT":1,"PET":1,"PETT":1,"PGT":1,"PHOT":1,"PHT":1,"PKT":1,"PMDT":1,"PMST":1,"PONT":1,"PST":1,"PYST":1,"PYT":1,"RET":1,"ROTT":1,"SAKT":1,"SAMT":1,"SAST":1,"SBT":1,"SCT":1,"SGT":1,"SLST":1,"SRT":1,"SST":1,"SYOT":1,"TAHT":1,"THA":1,"TFT":1,"TJT":1,"TKT":1,"TLT":1,"TMT":1,"TOT":1,"TVT":1,"UCT":1,"ULAT":1,"UTC":1,"UYST":1,"UYT":1,"UZT":1,"VET":1,"VLAT":1,"VOLT":1,"VOST":1,"VUT":1,"WAKT":1,"WAST":1,"WAT":1,"WEDT":1,"WEST":1,"WET":1,"WST":1,"YAKT":1,"YEKT":1,"Z":1}; return (timezones[value] === 1); }; $D.validateTimezoneOffset= function(value) { // timezones go from +14hrs to -12hrs, the +X hours are negative offsets. return (value > -841 && value < 721); }; }()); (function () { var $D = Date, $P = $D.prototype, p = function (s, l) { if (!l) { l = 2; } return ("000" + s).slice(l * -1); }; var validateConfigObject = function (obj) { var result = {}, self = this, prop, testFunc; testFunc = function (prop, func, value) { if (prop === "day") { var month = (obj.month !== undefined) ? obj.month : self.getMonth(); var year = (obj.year !== undefined) ? obj.year : self.getFullYear(); return $D[func](value, year, month); } else { return $D[func](value); } }; for (prop in obj) { if (Object.prototype.hasOwnProperty.call(obj, prop)) { var func = "validate" + prop.charAt(0).toUpperCase() + prop.slice(1); if ($D[func] && obj[prop] !== null && testFunc(prop, func, obj[prop])) { result[prop] = obj[prop]; } } } return result; }; /** * Resets the time of this Date object to 12:00 AM (00:00), which is the start of the day. * @param {Boolean} .clone() this date instance before clearing Time * @return {Date} this */ $P.clearTime = function () { this.setHours(0); this.setMinutes(0); this.setSeconds(0); this.setMilliseconds(0); return this; }; /** * Resets the time of this Date object to the current time ('now'). * @return {Date} this */ $P.setTimeToNow = function () { var n = new Date(); this.setHours(n.getHours()); this.setMinutes(n.getMinutes()); this.setSeconds(n.getSeconds()); this.setMilliseconds(n.getMilliseconds()); return this; }; /** * Returns a new Date object that is an exact date and time copy of the original instance. * @return {Date} A new Date instance */ $P.clone = function () { return new Date(this.getTime()); }; /** * Compares this instance to a Date object and returns an number indication of their relative values. * @param {Date} Date object to compare [Required] * @return {Number} -1 = this is lessthan date. 0 = values are equal. 1 = this is greaterthan date. */ $P.compareTo = function (date) { return Date.compare(this, date); }; /** * Compares this instance to another Date object and returns true if they are equal. * @param {Date} Date object to compare. If no date to compare, new Date() [now] is used. * @return {Boolean} true if dates are equal. false if they are not equal. */ $P.equals = function (date) { return Date.equals(this, (date !== undefined ? date : new Date())); }; /** * Determines if this instance is between a range of two dates or equal to either the start or end dates. * @param {Date} Start of range [Required] * @param {Date} End of range [Required] * @return {Boolean} true is this is between or equal to the start and end dates, else false */ $P.between = function (start, end) { return this.getTime() >= start.getTime() && this.getTime() <= end.getTime(); }; /** * Determines if this date occurs after the date to compare to. * @param {Date} Date object to compare. If no date to compare, new Date() ("now") is used. * @return {Boolean} true if this date instance is greater than the date to compare to (or "now"), otherwise false. */ $P.isAfter = function (date) { return this.compareTo(date || new Date()) === 1; }; /** * Determines if this date occurs before the date to compare to. * @param {Date} Date object to compare. If no date to compare, new Date() ("now") is used. * @return {Boolean} true if this date instance is less than the date to compare to (or "now"). */ $P.isBefore = function (date) { return (this.compareTo(date || new Date()) === -1); }; /** * Determines if the current Date instance occurs today. * @return {Boolean} true if this date instance is 'today', otherwise false. */ /** * Determines if the current Date instance occurs on the same Date as the supplied 'date'. * If no 'date' to compare to is provided, the current Date instance is compared to 'today'. * @param {date} Date object to compare. If no date to compare, the current Date ("now") is used. * @return {Boolean} true if this Date instance occurs on the same Day as the supplied 'date'. */ $P.isToday = $P.isSameDay = function (date) { return this.clone().clearTime().equals((date || new Date()).clone().clearTime()); }; /** * Adds the specified number of milliseconds to this instance. * @param {Number} The number of milliseconds to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addMilliseconds = function (value) { if (!value) { return this; } this.setTime(this.getTime() + value * 1); return this; }; /** * Adds the specified number of seconds to this instance. * @param {Number} The number of seconds to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addSeconds = function (value) { if (!value) { return this; } return this.addMilliseconds(value * 1000); }; /** * Adds the specified number of seconds to this instance. * @param {Number} The number of seconds to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addMinutes = function (value) { if (!value) { return this; } return this.addMilliseconds(value * 60000); // 60*1000 }; /** * Adds the specified number of hours to this instance. * @param {Number} The number of hours to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addHours = function (value) { if (!value) { return this; } return this.addMilliseconds(value * 3600000); // 60*60*1000 }; /** * Adds the specified number of days to this instance. * @param {Number} The number of days to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addDays = function (value) { if (!value) { return this; } this.setDate(this.getDate() + value * 1); return this; }; /** * Adds the specified number of weekdays (ie - not sat or sun) to this instance. * @param {Number} The number of days to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addWeekdays = function (value) { if (!value) { return this; } var day = this.getDay(); var weeks = (Math.ceil(Math.abs(value)/7)); if (day === 0 || day === 6) { if (value > 0) { this.next().monday(); this.addDays(-1); day = this.getDay(); } } if (value < 0) { while (value < 0) { this.addDays(-1); day = this.getDay(); if (day !== 0 && day !== 6) { value++; } } return this; } else if (value > 5 || (6-day) <= value) { value = value + (weeks * 2); } return this.addDays(value); }; /** * Adds the specified number of weeks to this instance. * @param {Number} The number of weeks to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addWeeks = function (value) { if (!value) { return this; } return this.addDays(value * 7); }; /** * Adds the specified number of months to this instance. * @param {Number} The number of months to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addMonths = function (value) { if (!value) { return this; } var n = this.getDate(); this.setDate(1); this.setMonth(this.getMonth() + value * 1); this.setDate(Math.min(n, $D.getDaysInMonth(this.getFullYear(), this.getMonth()))); return this; }; $P.addQuarters = function (value) { if (!value) { return this; } // note this will take you to the same point in the quarter as you are now. // i.e. - if you are 15 days into the quarter you'll be 15 days into the resulting one. // bonus: this allows adding fractional quarters return this.addMonths(value * 3); }; /** * Adds the specified number of years to this instance. * @param {Number} The number of years to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addYears = function (value) { if (!value) { return this; } return this.addMonths(value * 12); }; /** * Adds (or subtracts) to the value of the years, months, weeks, days, hours, minutes, seconds, milliseconds of the date instance using given configuration object. Positive and Negative values allowed. * Example

	Date.today().add( { days: 1, months: 1 } )

	new Date().add( { years: -1 } )
	
* @param {Object} Configuration object containing attributes (months, days, etc.) * @return {Date} this */ $P.add = function (config) { if (typeof config === "number") { this._orient = config; return this; } var x = config; if (x.day) { // If we should be a different date than today (eg: for 'tomorrow -1d', etc). // Should only effect parsing, not direct usage (eg, Finish and FinishExact) if ((x.day - this.getDate()) !== 0) { this.setDate(x.day); } } if (x.milliseconds) { this.addMilliseconds(x.milliseconds); } if (x.seconds) { this.addSeconds(x.seconds); } if (x.minutes) { this.addMinutes(x.minutes); } if (x.hours) { this.addHours(x.hours); } if (x.weeks) { this.addWeeks(x.weeks); } if (x.months) { this.addMonths(x.months); } if (x.years) { this.addYears(x.years); } if (x.days) { this.addDays(x.days); } return this; }; /** * Get the week number. Week one (1) is the week which contains the first Thursday of the year. Monday is considered the first day of the week. * The .getWeek() function does NOT convert the date to UTC. The local datetime is used. * Please use .getISOWeek() to get the week of the UTC converted date. * @return {Number} 1 to 53 */ $P.getWeek = function (utc) { // Create a copy of this date object var self, target = new Date(this.valueOf()); if (utc) { target.addMinutes(target.getTimezoneOffset()); self = target.clone(); } else { self = this; } // ISO week date weeks start on monday // so correct the day number var dayNr = (self.getDay() + 6) % 7; // ISO 8601 states that week 1 is the week // with the first thursday of that year. // Set the target date to the thursday in the target week target.setDate(target.getDate() - dayNr + 3); // Store the millisecond value of the target date var firstThursday = target.valueOf(); // Set the target to the first thursday of the year // First set the target to january first target.setMonth(0, 1); // Not a thursday? Correct the date to the next thursday if (target.getDay() !== 4) { target.setMonth(0, 1 + ((4 - target.getDay()) + 7) % 7); } // The weeknumber is the number of weeks between the // first thursday of the year and the thursday in the target week return 1 + Math.ceil((firstThursday - target) / 604800000); // 604800000 = 7 * 24 * 3600 * 1000 }; /** * Get the ISO 8601 week number. Week one ("01") is the week which contains the first Thursday of the year. Monday is considered the first day of the week. * The .getISOWeek() function does convert the date to it's UTC value. Please use .getWeek() to get the week of the local date. * @return {String} "01" to "53" */ $P.getISOWeek = function () { return p(this.getWeek(true)); }; /** * Moves the date to Monday of the week set. Week one (1) is the week which contains the first Thursday of the year. * @param {Number} A Number (1 to 53) that represents the week of the year. * @return {Date} this */ $P.setWeek = function (n) { if ((n - this.getWeek()) === 0) { if (this.getDay() !== 1) { return this.moveToDayOfWeek(1, (this.getDay() > 1 ? -1 : 1)); } else { return this; } } else { return this.moveToDayOfWeek(1, (this.getDay() > 1 ? -1 : 1)).addWeeks(n - this.getWeek()); } }; $P.setQuarter = function (qtr) { var month = Math.abs(((qtr-1) * 3) + 1); return this.setMonth(month, 1); }; $P.getQuarter = function () { return Date.getQuarter(this); }; $P.getDaysLeftInQuarter = function () { return Date.getDaysLeftInQuarter(this); }; /** * Moves the date to the next n'th occurrence of the dayOfWeek starting from the beginning of the month. The number (-1) is a magic number and will return the last occurrence of the dayOfWeek in the month. * @param {Number} The dayOfWeek to move to * @param {Number} The n'th occurrence to move to. Use (-1) to return the last occurrence in the month * @return {Date} this */ $P.moveToNthOccurrence = function (dayOfWeek, occurrence) { if (dayOfWeek === "Weekday") { if (occurrence > 0) { this.moveToFirstDayOfMonth(); if (this.is().weekday()) { occurrence -= 1; } } else if (occurrence < 0) { this.moveToLastDayOfMonth(); if (this.is().weekday()) { occurrence += 1; } } else { return this; } return this.addWeekdays(occurrence); } var shift = 0; if (occurrence > 0) { shift = occurrence - 1; } else if (occurrence === -1) { this.moveToLastDayOfMonth(); if (this.getDay() !== dayOfWeek) { this.moveToDayOfWeek(dayOfWeek, -1); } return this; } return this.moveToFirstDayOfMonth().addDays(-1).moveToDayOfWeek(dayOfWeek, +1).addWeeks(shift); }; var moveToN = function (getFunc, addFunc, nVal) { return function (value, orient) { var diff = (value - this[getFunc]() + nVal * (orient || +1)) % nVal; return this[addFunc]((diff === 0) ? diff += nVal * (orient || +1) : diff); }; }; /** * Move to the next or last dayOfWeek based on the orient value. * @param {Number} The dayOfWeek to move to * @param {Number} Forward (+1) or Back (-1). Defaults to +1. [Optional] * @return {Date} this */ $P.moveToDayOfWeek = moveToN("getDay", "addDays", 7); /** * Move to the next or last month based on the orient value. * @param {Number} The month to move to. 0 = January, 11 = December * @param {Number} Forward (+1) or Back (-1). Defaults to +1. [Optional] * @return {Date} this */ $P.moveToMonth = moveToN("getMonth", "addMonths", 12); /** * Get the Ordinate of the current day ("th", "st", "rd"). * @return {String} */ $P.getOrdinate = function () { var num = this.getDate(); return ord(num); }; /** * Get the Ordinal day (numeric day number) of the year, adjusted for leap year. * @return {Number} 1 through 365 (366 in leap years) */ $P.getOrdinalNumber = function () { return Math.ceil((this.clone().clearTime() - new Date(this.getFullYear(), 0, 1)) / 86400000) + 1; }; /** * Get the time zone abbreviation of the current date. * @return {String} The abbreviated time zone name (e.g. "EST") */ $P.getTimezone = function () { return $D.getTimezoneAbbreviation(this.getUTCOffset(), this.isDaylightSavingTime()); }; $P.setTimezoneOffset = function (offset) { var here = this.getTimezoneOffset(), there = Number(offset) * -6 / 10; return (there || there === 0) ? this.addMinutes(there - here) : this; }; $P.setTimezone = function (offset) { return this.setTimezoneOffset($D.getTimezoneOffset(offset)); }; /** * Indicates whether Daylight Saving Time is observed in the current time zone. * @return {Boolean} true|false */ $P.hasDaylightSavingTime = function () { return (Date.today().set({month: 0, day: 1}).getTimezoneOffset() !== Date.today().set({month: 6, day: 1}).getTimezoneOffset()); }; /** * Indicates whether this Date instance is within the Daylight Saving Time range for the current time zone. * @return {Boolean} true|false */ $P.isDaylightSavingTime = function () { return Date.today().set({month: 0, day: 1}).getTimezoneOffset() !== this.getTimezoneOffset(); }; /** * Get the offset from UTC of the current date. * @return {String} The 4-character offset string prefixed with + or - (e.g. "-0500") */ $P.getUTCOffset = function (offset) { var n = (offset || this.getTimezoneOffset()) * -10 / 6, r; if (n < 0) { r = (n - 10000).toString(); return r.charAt(0) + r.substr(2); } else { r = (n + 10000).toString(); return "+" + r.substr(1); } }; /** * Returns the number of milliseconds between this date and date. * @param {Date} Defaults to now * @return {Number} The diff in milliseconds */ $P.getElapsed = function (date) { return (date || new Date()) - this; }; /** * Set the value of year, month, day, hour, minute, second, millisecond of date instance using given configuration object. * Example

	Date.today().set( { day: 20, month: 1 } )

	new Date().set( { millisecond: 0 } )
	
* * @param {Object} Configuration object containing attributes (month, day, etc.) * @return {Date} this */ $P.set = function (config) { config = validateConfigObject.call(this, config); var key; for (key in config) { if (Object.prototype.hasOwnProperty.call(config, key)) { var name = key.charAt(0).toUpperCase() + key.slice(1); var addFunc, getFunc; if (key !== "week" && key !== "month" && key !== "timezone" && key !== "timezoneOffset") { name += "s"; } addFunc = "add" + name; getFunc = "get" + name; if (key === "month") { addFunc = addFunc + "s"; } else if (key === "year"){ getFunc = "getFullYear"; } if (key !== "day" && key !== "timezone" && key !== "timezoneOffset" && key !== "week" && key !== "hour") { this[addFunc](config[key] - this[getFunc]()); } else if ( key === "timezone"|| key === "timezoneOffset" || key === "week" || key === "hour") { this["set"+name](config[key]); } } } // day has to go last because you can't validate the day without first knowing the month if (config.day) { this.addDays(config.day - this.getDate()); } return this; }; /** * Moves the date to the first day of the month. * @return {Date} this */ $P.moveToFirstDayOfMonth = function () { return this.set({ day: 1 }); }; /** * Moves the date to the last day of the month. * @return {Date} this */ $P.moveToLastDayOfMonth = function () { return this.set({ day: $D.getDaysInMonth(this.getFullYear(), this.getMonth())}); }; /** * Converts the value of the current Date object to its equivalent string representation. * Format Specifiers * CUSTOM DATE AND TIME FORMAT STRINGS * Format Description Example * ------ --------------------------------------------------------------------------- ----------------------- * s The seconds of the minute between 0-59. "0" to "59" * ss The seconds of the minute with leading zero if required. "00" to "59" * * m The minute of the hour between 0-59. "0" or "59" * mm The minute of the hour with leading zero if required. "00" or "59" * * h The hour of the day between 1-12. "1" to "12" * hh The hour of the day with leading zero if required. "01" to "12" * * H The hour of the day between 0-23. "0" to "23" * HH The hour of the day with leading zero if required. "00" to "23" * * d The day of the month between 1 and 31. "1" to "31" * dd The day of the month with leading zero if required. "01" to "31" * ddd Abbreviated day name. Date.CultureInfo.abbreviatedDayNames. "Mon" to "Sun" * dddd The full day name. Date.CultureInfo.dayNames. "Monday" to "Sunday" * * M The month of the year between 1-12. "1" to "12" * MM The month of the year with leading zero if required. "01" to "12" * MMM Abbreviated month name. Date.CultureInfo.abbreviatedMonthNames. "Jan" to "Dec" * MMMM The full month name. Date.CultureInfo.monthNames. "January" to "December" * * yy The year as a two-digit number. "99" or "08" * yyyy The full four digit year. "1999" or "2008" * * t Displays the first character of the A.M./P.M. designator. "A" or "P" * Date.CultureInfo.amDesignator or Date.CultureInfo.pmDesignator * tt Displays the A.M./P.M. designator. "AM" or "PM" * Date.CultureInfo.amDesignator or Date.CultureInfo.pmDesignator * * S The ordinal suffix ("st, "nd", "rd" or "th") of the current day. "st, "nd", "rd" or "th" * * STANDARD DATE AND TIME FORMAT STRINGS * Format Description Example *------ --------------------------------------------------------------------------- ----------------------- * d The CultureInfo shortDate Format Pattern "M/d/yyyy" * D The CultureInfo longDate Format Pattern "dddd, MMMM dd, yyyy" * F The CultureInfo fullDateTime Format Pattern "dddd, MMMM dd, yyyy h:mm:ss tt" * m The CultureInfo monthDay Format Pattern "MMMM dd" * r The CultureInfo rfc1123 Format Pattern "ddd, dd MMM yyyy HH:mm:ss GMT" * s The CultureInfo sortableDateTime Format Pattern "yyyy-MM-ddTHH:mm:ss" * t The CultureInfo shortTime Format Pattern "h:mm tt" * T The CultureInfo longTime Format Pattern "h:mm:ss tt" * u The CultureInfo universalSortableDateTime Format Pattern "yyyy-MM-dd HH:mm:ssZ" * y The CultureInfo yearMonth Format Pattern "MMMM, yyyy" * * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @return {String} A string representation of the current Date object. */ var ord = function (n) { switch (n * 1) { case 1: case 21: case 31: return "st"; case 2: case 22: return "nd"; case 3: case 23: return "rd"; default: return "th"; } }; var parseStandardFormats = function (format) { var y, c = Date.CultureInfo.formatPatterns; switch (format) { case "d": return this.toString(c.shortDate); case "D": return this.toString(c.longDate); case "F": return this.toString(c.fullDateTime); case "m": return this.toString(c.monthDay); case "r": case "R": y = this.clone().addMinutes(this.getTimezoneOffset()); return y.toString(c.rfc1123) + " GMT"; case "s": return this.toString(c.sortableDateTime); case "t": return this.toString(c.shortTime); case "T": return this.toString(c.longTime); case "u": y = this.clone().addMinutes(this.getTimezoneOffset()); return y.toString(c.universalSortableDateTime); case "y": return this.toString(c.yearMonth); default: return false; } }; var parseFormatStringsClosure = function (context) { return function (m) { if (m.charAt(0) === "\\") { return m.replace("\\", ""); } switch (m) { case "hh": return p(context.getHours() < 13 ? (context.getHours() === 0 ? 12 : context.getHours()) : (context.getHours() - 12)); case "h": return context.getHours() < 13 ? (context.getHours() === 0 ? 12 : context.getHours()) : (context.getHours() - 12); case "HH": return p(context.getHours()); case "H": return context.getHours(); case "mm": return p(context.getMinutes()); case "m": return context.getMinutes(); case "ss": return p(context.getSeconds()); case "s": return context.getSeconds(); case "yyyy": return p(context.getFullYear(), 4); case "yy": return p(context.getFullYear()); case "y": return context.getFullYear(); case "E": case "dddd": return Date.CultureInfo.dayNames[context.getDay()]; case "ddd": return Date.CultureInfo.abbreviatedDayNames[context.getDay()]; case "dd": return p(context.getDate()); case "d": return context.getDate(); case "MMMM": return Date.CultureInfo.monthNames[context.getMonth()]; case "MMM": return Date.CultureInfo.abbreviatedMonthNames[context.getMonth()]; case "MM": return p((context.getMonth() + 1)); case "M": return context.getMonth() + 1; case "t": return context.getHours() < 12 ? Date.CultureInfo.amDesignator.substring(0, 1) : Date.CultureInfo.pmDesignator.substring(0, 1); case "tt": return context.getHours() < 12 ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator; case "S": return ord(context.getDate()); case "W": return context.getWeek(); case "WW": return context.getISOWeek(); case "Q": return "Q" + context.getQuarter(); case "q": return String(context.getQuarter()); case "z": return context.getTimezone(); case "Z": case "X": return Date.getTimezoneOffset(context.getTimezone()); case "ZZ": // Timezone offset in seconds return context.getTimezoneOffset() * -60; case "u": return context.getDay(); case "L": return ($D.isLeapYear(context.getFullYear())) ? 1 : 0; case "B": // Swatch Internet Time (.beats) return "@"+((context.getUTCSeconds() + (context.getUTCMinutes()*60) + ((context.getUTCHours()+1)*3600))/86.4); default: return m; } }; }; $P.toString = function (format, ignoreStandards) { // Standard Date and Time Format Strings. Formats pulled from CultureInfo file and // may vary by culture. if (!ignoreStandards && format && format.length === 1) { output = parseStandardFormats.call(this, format); if (output) { return output; } } var parseFormatStrings = parseFormatStringsClosure(this); return format ? format.replace(/((\\)?(dd?d?d?|MM?M?M?|yy?y?y?|hh?|HH?|mm?|ss?|tt?|S|q|Q|WW?W?W?)(?![^\[]*\]))/g, parseFormatStrings).replace(/\[|\]/g, "") : this._toString(); }; }()); /************************************************************* * SugarPak - Domain Specific Language - Syntactical Sugar * *************************************************************/ (function () { var $D = Date, $P = $D.prototype, $N = Number.prototype; // private $P._orient = +1; // private $P._nth = null; // private $P._is = false; // private $P._same = false; // private $P._isSecond = false; // private $N._dateElement = "days"; /** * Moves the date to the next instance of a date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.today().next().friday();
	Date.today().next().fri();
	Date.today().next().march();
	Date.today().next().mar();
	Date.today().next().week();
	
* * @return {Date} date */ $P.next = function () { this._move = true; this._orient = +1; return this; }; /** * Creates a new Date (Date.today()) and moves the date to the next instance of the date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.next().friday();
	Date.next().fri();
	Date.next().march();
	Date.next().mar();
	Date.next().week();
	
* * @return {Date} date */ $D.next = function () { return $D.today().next(); }; /** * Moves the date to the previous instance of a date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.today().last().friday();
	Date.today().last().fri();
	Date.today().last().march();
	Date.today().last().mar();
	Date.today().last().week();
	
* * @return {Date} date */ $P.last = $P.prev = $P.previous = function () { this._move = true; this._orient = -1; return this; }; /** * Creates a new Date (Date.today()) and moves the date to the previous instance of the date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.last().friday();
	Date.last().fri();
	Date.previous().march();
	Date.prev().mar();
	Date.last().week();
	
* * @return {Date} date */ $D.last = $D.prev = $D.previous = function () { return $D.today().last(); }; /** * Performs a equality check when followed by either a month name, day name or .weekday() function. * Example

	Date.today().is().friday(); // true|false
	Date.today().is().fri();
	Date.today().is().march();
	Date.today().is().mar();
	
* * @return {Boolean} true|false */ $P.is = function () { this._is = true; return this; }; /** * Determines if two date objects occur on/in exactly the same instance of the subsequent date part function. * The function .same() must be followed by a date part function (example: .day(), .month(), .year(), etc). * * An optional Date can be passed in the date part function. If now date is passed as a parameter, 'Now' is used. * * The following example demonstrates how to determine if two dates fall on the exact same day. * * Example

	var d1 = Date.today(); // today at 00:00
	var d2 = new Date();   // exactly now.

	// Do they occur on the same day?
	d1.same().day(d2); // true
	
	// Do they occur on the same hour?
	d1.same().hour(d2); // false, unless d2 hour is '00' (midnight).
	
	// What if it's the same day, but one year apart?
	var nextYear = Date.today().add(1).year();

	d1.same().day(nextYear); // false, because the dates must occur on the exact same day. 
	
* * Scenario: Determine if a given date occurs during some week period 2 months from now. * * Example

	var future = Date.today().add(2).months();
	return someDate.same().week(future); // true|false;
	
* * @return {Boolean} true|false */ $P.same = function () { this._same = true; this._isSecond = false; return this; }; /** * Determines if the current date/time occurs during Today. Must be preceded by the .is() function. * Example

	someDate.is().today();    // true|false
	new Date().is().today();  // true
	Date.today().is().today();// true
	Date.today().add(-1).day().is().today(); // false
	
* * @return {Boolean} true|false */ $P.today = function () { return this.same().day(); }; /** * Determines if the current date is a weekday. This function must be preceded by the .is() function. * Example

	Date.today().is().weekday(); // true|false
	
* * @return {Boolean} true|false */ $P.weekday = function () { if (this._nth) { return df("Weekday").call(this); } if (this._move) { return this.addWeekdays(this._orient); } if (this._is) { this._is = false; return (!this.is().sat() && !this.is().sun()); } return false; }; /** * Determines if the current date is on the weekend. This function must be preceded by the .is() function. * Example

	Date.today().is().weekend(); // true|false
	
* * @return {Boolean} true|false */ $P.weekend = function () { if (this._is) { this._is = false; return (this.is().sat() || this.is().sun()); } return false; }; /** * Sets the Time of the current Date instance. A string "6:15 pm" or config object {hour:18, minute:15} are accepted. * Example

	// Set time to 6:15pm with a String
	Date.today().at("6:15pm");

	// Set time to 6:15pm with a config object
	Date.today().at({hour:18, minute:15});
	
* * @return {Date} date */ $P.at = function (time) { return (typeof time === "string") ? $D.parse(this.toString("d") + " " + time) : this.set(time); }; /** * Creates a new Date() and adds this (Number) to the date based on the preceding date element function (eg. second|minute|hour|day|month|year). * Example

	// Undeclared Numbers must be wrapped with parentheses. Requirment of JavaScript.
	(3).days().fromNow();
	(6).months().fromNow();

	// Declared Number variables do not require parentheses. 
	var n = 6;
	n.months().fromNow();
	
* * @return {Date} A new Date instance */ $N.fromNow = $N.after = function (date) { var c = {}; c[this._dateElement] = this; return ((!date) ? new Date() : date.clone()).add(c); }; /** * Creates a new Date() and subtract this (Number) from the date based on the preceding date element function (eg. second|minute|hour|day|month|year). * Example

	// Undeclared Numbers must be wrapped with parentheses. Requirment of JavaScript.
	(3).days().ago();
	(6).months().ago();

	// Declared Number variables do not require parentheses. 
	var n = 6;
	n.months().ago();
	
* * @return {Date} A new Date instance */ $N.ago = $N.before = function (date) { var c = {}, s = (this._dateElement[this._dateElement.length-1] !== "s") ? this._dateElement + "s" : this._dateElement; c[s] = this * -1; return ((!date) ? new Date() : date.clone()).add(c); }; // Do NOT modify the following string tokens. These tokens are used to build dynamic functions. // All culture-specific strings can be found in the CultureInfo files. var dx = ("sunday monday tuesday wednesday thursday friday saturday").split(/\s/), mx = ("january february march april may june july august september october november december").split(/\s/), px = ("Millisecond Second Minute Hour Day Week Month Year Quarter Weekday").split(/\s/), pxf = ("Milliseconds Seconds Minutes Hours Date Week Month FullYear Quarter").split(/\s/), nth = ("final first second third fourth fifth").split(/\s/), de; /** * Returns an object literal of all the date parts. * Example

	var o = new Date().toObject();
	
	// { year: 2008, month: 4, week: 20, day: 13, hour: 18, minute: 9, second: 32, millisecond: 812 }
	
	// The object properties can be referenced directly from the object.
	
	alert(o.day);  // alerts "13"
	alert(o.year); // alerts "2008"
	
* * @return {Date} An object literal representing the original date object. */ $P.toObject = function () { var o = {}; for (var i = 0; i < px.length; i++) { if (this["get" + pxf[i]]) { o[px[i].toLowerCase()] = this["get" + pxf[i]](); } } return o; }; /** * Returns a date created from an object literal. Ignores the .week property if set in the config. * Example

	var o = new Date().toObject();
	
	return Date.fromObject(o); // will return the same date. 

	var o2 = {month: 1, day: 20, hour: 18}; // birthday party!
	Date.fromObject(o2);
	
* * @return {Date} An object literal representing the original date object. */ $D.fromObject = function(config) { config.week = null; return Date.today().set(config); }; // Create day name functions and abbreviated day name functions (eg. monday(), friday(), fri()). var df = function (n) { return function () { if (this._is) { this._is = false; return this.getDay() === n; } if (this._move) { this._move = null; } if (this._nth !== null) { // If the .second() function was called earlier, remove the _orient // from the date, and then continue. // This is required because 'second' can be used in two different context. // // Example // // Date.today().add(1).second(); // Date.march().second().monday(); // // Things get crazy with the following... // Date.march().add(1).second().second().monday(); // but it works!! // if (this._isSecond) { this.addSeconds(this._orient * -1); } // make sure we reset _isSecond this._isSecond = false; var ntemp = this._nth; this._nth = null; var temp = this.clone().moveToLastDayOfMonth(); this.moveToNthOccurrence(n, ntemp); if (this > temp) { throw new RangeError($D.getDayName(n) + " does not occur " + ntemp + " times in the month of " + $D.getMonthName(temp.getMonth()) + " " + temp.getFullYear() + "."); } return this; } return this.moveToDayOfWeek(n, this._orient); }; }; var sdf = function (n) { return function () { var t = $D.today(), shift = n - t.getDay(); if (n === 0 && Date.CultureInfo.firstDayOfWeek === 1 && t.getDay() !== 0) { shift = shift + 7; } return t.addDays(shift); }; }; // Create month name functions and abbreviated month name functions (eg. january(), march(), mar()). var month_instance_functions = function (n) { return function () { if (this._is) { this._is = false; return this.getMonth() === n; } return this.moveToMonth(n, this._orient); }; }; var month_static_functions = function (n) { return function () { return $D.today().set({ month: n, day: 1 }); }; }; var processTerms = function (names, staticFunc, instanceFunc) { for (var i = 0; i < names.length; i++) { // Create constant static Name variables. $D[names[i].toUpperCase()] = $D[names[i].toUpperCase().substring(0, 3)] = i; // Create Name functions. $D[names[i]] = $D[names[i].substring(0, 3)] = staticFunc(i); // Create Name instance functions. $P[names[i]] = $P[names[i].substring(0, 3)] = instanceFunc(i); } }; processTerms(dx, sdf, df); processTerms(mx, month_static_functions, month_instance_functions); // Create date element functions and plural date element functions used with Date (eg. day(), days(), months()). var ef = function (j) { return function () { // if the .second() function was called earlier, the _orient // has alread been added. Just return this and reset _isSecond. if (this._isSecond) { this._isSecond = false; return this; } if (this._same) { this._same = this._is = false; var o1 = this.toObject(), o2 = (arguments[0] || new Date()).toObject(), v = "", k = j.toLowerCase(); // the substr trick with -1 doesn't work in IE8 or less k = (k[k.length-1] === "s") ? k.substring(0,k.length-1) : k; for (var m = (px.length - 1); m > -1; m--) { v = px[m].toLowerCase(); if (o1[v] !== o2[v]) { return false; } if (k === v) { break; } } return true; } if (j.substring(j.length - 1) !== "s") { j += "s"; } if (this._move) { this._move = null; } return this["add" + j](this._orient); }; }; var nf = function (n) { return function () { this._dateElement = n; return this; }; }; for (var k = 0; k < px.length; k++) { de = px[k].toLowerCase(); if(de !== "weekday") { // Create date element functions and plural date element functions used with Date (eg. day(), days(), months()). $P[de] = $P[de + "s"] = ef(px[k]); // Create date element functions and plural date element functions used with Number (eg. day(), days(), months()). $N[de] = $N[de + "s"] = nf(de + "s"); } } $P._ss = ef("Second"); var nthfn = function (n) { return function (dayOfWeek) { if (this._same) { return this._ss(arguments[0]); } if (dayOfWeek || dayOfWeek === 0) { return this.moveToNthOccurrence(dayOfWeek, n); } this._nth = n; // if the operator is 'second' add the _orient, then deal with it later... if (n === 2 && (dayOfWeek === undefined || dayOfWeek === null)) { this._isSecond = true; return this.addSeconds(this._orient); } return this; }; }; for (var l = 0; l < nth.length; l++) { $P[nth[l]] = (l === 0) ? nthfn(-1) : nthfn(l); } }()); (function () { "use strict"; Date.Parsing = { Exception: function (s) { this.message = "Parse error at '" + s.substring(0, 10) + " ...'"; } }; var $P = Date.Parsing; var dayOffsets = { standard: [0,31,59,90,120,151,181,212,243,273,304,334], leap: [0,31,60,91,121,152,182,213,244,274,305,335] }; $P.isLeapYear = function(year) { return ((year % 4 === 0) && (year % 100 !== 0)) || (year % 400 === 0); }; var utils = { multiReplace : function (str, hash ) { var key; for (key in hash) { if (Object.prototype.hasOwnProperty.call(hash, key)) { var regex; if (typeof hash[key] === "function") { } else { regex = (hash[key] instanceof RegExp) ? hash[key] : new RegExp(hash[key], "g"); } str = str.replace(regex, key); } } return str; }, getDayOfYearFromWeek : function (obj) { var d, jan4, offset; obj.weekDay = (!obj.weekDay && obj.weekDay !== 0) ? 1 : obj.weekDay; d = new Date(obj.year, 0, 4); jan4 = d.getDay() === 0 ? 7 : d.getDay(); // JS is 0 indexed on Sunday. offset = jan4+3; obj.dayOfYear = ((obj.week * 7) + (obj.weekDay === 0 ? 7 : obj.weekDay))-offset; return obj; }, getDayOfYear : function (obj, dayOffset) { if (!obj.dayOfYear) { obj = utils.getDayOfYearFromWeek(obj); } for (var i=0;i <= dayOffset.length;i++) { if (obj.dayOfYear < dayOffset[i] || i === dayOffset.length) { obj.day = obj.day ? obj.day : (obj.dayOfYear - dayOffset[i-1]); break; } else { obj.month = i; } } return obj; }, adjustForTimeZone : function (obj, date) { var offset; if (obj.zone.toUpperCase() === "Z" || (obj.zone_hours === 0 && obj.zone_minutes === 0)) { // it's UTC/GML so work out the current timeszone offset offset = -date.getTimezoneOffset(); } else { offset = (obj.zone_hours*60) + (obj.zone_minutes || 0); if (obj.zone_sign === "+") { offset *= -1; } offset -= date.getTimezoneOffset(); } date.setMinutes(date.getMinutes()+offset); return date; }, setDefaults : function (obj) { obj.year = obj.year || Date.today().getFullYear(); obj.hours = obj.hours || 0; obj.minutes = obj.minutes || 0; obj.seconds = obj.seconds || 0; obj.milliseconds = obj.milliseconds || 0; if (!(!obj.month && (obj.week || obj.dayOfYear))) { // if we have a month, or if we don't but don't have the day calculation data obj.month = obj.month || 0; obj.day = obj.day || 1; } return obj; }, dataNum: function (data, mod, explict, postProcess) { var dataNum = data*1; if (mod) { if (postProcess) { return data ? mod(data)*1 : data; } else { return data ? mod(dataNum) : data; } } else if (!explict){ return data ? dataNum : data; } else { return (data && typeof data !== "undefined") ? dataNum : data; } }, timeDataProcess: function (obj) { var timeObj = {}; for (var x in obj.data) { if (obj.data.hasOwnProperty(x)) { timeObj[x] = obj.ignore[x] ? obj.data[x] : utils.dataNum(obj.data[x], obj.mods[x], obj.explict[x], obj.postProcess[x]); } } if (obj.data.secmins) { obj.data.secmins = obj.data.secmins.replace(",", ".") * 60; if (!timeObj.minutes) { timeObj.minutes = obj.data.secmins; } else if (!timeObj.seconds) { timeObj.seconds = obj.data.secmins; } delete obj.secmins; } return timeObj; }, buildTimeObjectFromData: function (data) { var time = utils.timeDataProcess({ data: { year : data[1], month : data[5], day : data[7], week : data[8], dayOfYear : data[10], hours : data[15], zone_hours : data[23], zone_minutes : data[24], zone : data[21], zone_sign : data[22], weekDay : data[9], minutes: data[16], seconds: data[19], milliseconds: data[20], secmins: data[18] }, mods: { month: function(data) { return data-1; }, weekDay: function (data) { data = Math.abs(data); return (data === 7 ? 0 : data); }, minutes: function (data) { return data.replace(":",""); }, seconds: function (data) { return Math.floor( (data.replace(":","").replace(",","."))*1 ); }, milliseconds: function (data) { return (data.replace(",",".")*1000); } }, postProcess: { minutes: true, seconds: true, milliseconds: true }, explict: { zone_hours: true, zone_minutes: true }, ignore: { zone: true, zone_sign: true, secmins: true } }); return time; }, addToHash: function (hash, keys, data) { keys = keys; data = data; var len = keys.length; for (var i = 0; i < len; i++) { hash[keys[i]] = data[i]; } return hash; }, combineRegex: function (r1, r2) { return new RegExp("(("+r1.source+")\\s("+r2.source+"))"); }, getDateNthString: function(add, last, inc){ if (add) { return Date.today().addDays(inc).toString("d"); } else if (last) { return Date.today().last()[inc]().toString("d"); } }, buildRegexData: function (array) { var arr = []; var len = array.length; for (var i=0; i < len; i++) { if (Object.prototype.toString.call(array[i]) === '[object Array]') { // oldIE compat version of Array.isArray arr.push(this.combineRegex(array[i][0], array[i][1])); } else { arr.push(array[i]); } } return arr; } }; $P.processTimeObject = function (obj) { var date, dayOffset; utils.setDefaults(obj); dayOffset = ($P.isLeapYear(obj.year)) ? dayOffsets.leap : dayOffsets.standard; if (!obj.month && (obj.week || obj.dayOfYear)) { utils.getDayOfYear(obj, dayOffset); } else { obj.dayOfYear = dayOffset[obj.month] + obj.day; } date = new Date(obj.year, obj.month, obj.day, obj.hours, obj.minutes, obj.seconds, obj.milliseconds); if (obj.zone) { utils.adjustForTimeZone(obj, date); // adjust (and calculate) for timezone } return date; }; $P.ISO = { regex : /^([\+-]?\d{4}(?!\d{2}\b))((-?)((0[1-9]|1[0-2])(\3([12]\d|0[1-9]|3[01]))?|W([0-4]\d|5[0-3])(-?[1-7])?|(00[1-9]|0[1-9]\d|[12]\d{2}|3([0-5]\d|6[1-6])))([T\s]((([01]\d|2[0-4])((:?)[0-5]\d)?|24\:?00)([\.,]\d+(?!:))?)?(\17[0-5]\d([\.,]\d+)?)?\s?([zZ]|([\+-])([01]\d|2[0-3]):?([0-5]\d)?)?)?)?$/, parse : function (s) { var time, data = s.match(this.regex); if (!data || !data.length) { return null; } time = utils.buildTimeObjectFromData(data); if (!time.year || (!time.year && (!time.month && !time.day) && (!time.week && !time.dayOfYear)) ) { return null; } return $P.processTimeObject(time); } }; $P.Numeric = { isNumeric: function (e){return!isNaN(parseFloat(e))&&isFinite(e);}, regex: /\b([0-1]?[0-9])([0-3]?[0-9])([0-2]?[0-9]?[0-9][0-9])\b/i, parse: function (s) { var data, i, time = {}, order = Date.CultureInfo.dateElementOrder.split(""); if (!(this.isNumeric(s)) || // if it's non-numeric OR (s[0] === "+" && s[0] === "-")) { // It's an arithmatic string (eg +/-1000) return null; } if (s.length < 5 && s.indexOf(".") < 0 && s.indexOf("/") < 0) { // assume it's just a year. time.year = s; return $P.processTimeObject(time); } data = s.match(this.regex); if (!data || !data.length) { return null; } for (i=0; i < order.length; i++) { switch(order[i]) { case "d": time.day = data[i+1]; break; case "m": time.month = (data[i+1]-1); break; case "y": time.year = data[i+1]; break; } } return $P.processTimeObject(time); } }; $P.Normalizer = { regexData: function () { var $R = Date.CultureInfo.regexPatterns; return utils.buildRegexData([ $R.tomorrow, $R.yesterday, [$R.past, $R.mon], [$R.past, $R.tue], [$R.past, $R.wed], [$R.past, $R.thu], [$R.past, $R.fri], [$R.past, $R.sat], [$R.past, $R.sun] ]); }, basicReplaceHash : function() { var $R = Date.CultureInfo.regexPatterns; return { "January": $R.jan.source, "February": $R.feb, "March": $R.mar, "April": $R.apr, "May": $R.may, "June": $R.jun, "July": $R.jul, "August": $R.aug, "September": $R.sep, "October": $R.oct, "November": $R.nov, "December": $R.dec, "": /\bat\b/gi, " ": /\s{2,}/, "am": $R.inTheMorning, "9am": $R.thisMorning, "pm": $R.inTheEvening, "7pm":$R.thisEvening }; }, keys : function(){ return [ utils.getDateNthString(true, false, 1), // tomorrow utils.getDateNthString(true, false, -1), // yesterday utils.getDateNthString(false, true, "monday"), //last mon utils.getDateNthString(false, true, "tuesday"), //last tues utils.getDateNthString(false, true, "wednesday"), //last wed utils.getDateNthString(false, true, "thursday"), //last thurs utils.getDateNthString(false, true, "friday"), //last fri utils.getDateNthString(false, true, "saturday"), //last sat utils.getDateNthString(false, true, "sunday") //last sun ]; }, buildRegexFunctions: function () { var $R = Date.CultureInfo.regexPatterns; var __ = Date.i18n.__; var tomorrowRE = new RegExp("(\\b\\d\\d?("+__("AM")+"|"+__("PM")+")? )("+$R.tomorrow.source.slice(1)+")", "i"); // adapted tomorrow regex for AM PM relative dates var todayRE = new RegExp($R.today.source + "(?!\\s*([+-]))\\b"); // today, but excludes the math operators (eg "today + 2h") this.replaceFuncs = [ [todayRE, function (full) { return (full.length > 1) ? Date.today().toString("d") : full; }], [tomorrowRE, function(full, m1) { var t = Date.today().addDays(1).toString("d"); return (t + " " + m1); }], [$R.amThisMorning, function(str, am){return am;}], [$R.pmThisEvening, function(str, pm){return pm;}] ]; }, buildReplaceData: function () { this.buildRegexFunctions(); this.replaceHash = utils.addToHash(this.basicReplaceHash(), this.keys(), this.regexData()); }, stringReplaceFuncs: function (s) { for (var i=0; i < this.replaceFuncs.length; i++) { s = s.replace(this.replaceFuncs[i][0], this.replaceFuncs[i][1]); } return s; }, parse: function (s) { s = this.stringReplaceFuncs(s); s = utils.multiReplace(s, this.replaceHash); try { var n = s.split(/([\s\-\.\,\/\x27]+)/); if (n.length === 3 && $P.Numeric.isNumeric(n[0]) && $P.Numeric.isNumeric(n[2]) && (n[2].length >= 4)) { // ok, so we're dealing with x/year. But that's not a full date. // This fixes wonky dateElementOrder parsing when set to dmy order. if (Date.CultureInfo.dateElementOrder[0] === "d") { s = "1/" + n[0] + "/" + n[2]; // set to 1st of month and normalize the seperator } } } catch (e) {} return s; } }; $P.Normalizer.buildReplaceData(); }()); (function () { var $P = Date.Parsing; var _ = $P.Operators = { // // Tokenizers // rtoken: function (r) { // regex token return function (s) { var mx = s.match(r); if (mx) { return ([ mx[0], s.substring(mx[0].length) ]); } else { throw new $P.Exception(s); } }; }, token: function () { // whitespace-eating token return function (s) { return _.rtoken(new RegExp("^\\s*" + s + "\\s*"))(s); }; }, stoken: function (s) { // string token return _.rtoken(new RegExp("^" + s)); }, // Atomic Operators until: function (p) { return function (s) { var qx = [], rx = null; while (s.length) { try { rx = p.call(this, s); } catch (e) { qx.push(rx[0]); s = rx[1]; continue; } break; } return [ qx, s ]; }; }, many: function (p) { return function (s) { var rx = [], r = null; while (s.length) { try { r = p.call(this, s); } catch (e) { return [ rx, s ]; } rx.push(r[0]); s = r[1]; } return [ rx, s ]; }; }, // generator operators -- see below optional: function (p) { return function (s) { var r = null; try { r = p.call(this, s); } catch (e) { return [ null, s ]; } return [ r[0], r[1] ]; }; }, not: function (p) { return function (s) { try { p.call(this, s); } catch (e) { return [null, s]; } throw new $P.Exception(s); }; }, ignore: function (p) { return p ? function (s) { var r = null; r = p.call(this, s); return [null, r[1]]; } : null; }, product: function () { var px = arguments[0], qx = Array.prototype.slice.call(arguments, 1), rx = []; for (var i = 0 ; i < px.length ; i++) { rx.push(_.each(px[i], qx)); } return rx; }, cache: function (rule) { var cache = {}, cache_length = 0, cache_keys = [], CACHE_MAX = Date.Config.CACHE_MAX || 100000, r = null; var cacheCheck = function () { if (cache_length === CACHE_MAX) { // kill several keys, don't want to have to do this all the time... for (var i=0; i < 10; i++) { var key = cache_keys.shift(); if (key) { delete cache[key]; cache_length--; } } } }; return function (s) { cacheCheck(); try { r = cache[s] = (cache[s] || rule.call(this, s)); } catch (e) { r = cache[s] = e; } cache_length++; cache_keys.push(s); if (r instanceof $P.Exception) { throw r; } else { return r; } }; }, // vector operators -- see below any: function () { var px = arguments; return function (s) { var r = null; for (var i = 0; i < px.length; i++) { if (px[i] == null) { continue; } try { r = (px[i].call(this, s)); } catch (e) { r = null; } if (r) { return r; } } throw new $P.Exception(s); }; }, each: function () { var px = arguments; return function (s) { var rx = [], r = null; for (var i = 0; i < px.length ; i++) { if (px[i] == null) { continue; } try { r = (px[i].call(this, s)); } catch (e) { throw new $P.Exception(s); } rx.push(r[0]); s = r[1]; } return [ rx, s]; }; }, all: function () { var px = arguments, _ = _; return _.each(_.optional(px)); }, // delimited operators sequence: function (px, d, c) { d = d || _.rtoken(/^\s*/); c = c || null; if (px.length === 1) { return px[0]; } return function (s) { var r = null, q = null; var rx = []; for (var i = 0; i < px.length ; i++) { try { r = px[i].call(this, s); } catch (e) { break; } rx.push(r[0]); try { q = d.call(this, r[1]); } catch (ex) { q = null; break; } s = q[1]; } if (!r) { throw new $P.Exception(s); } if (q) { throw new $P.Exception(q[1]); } if (c) { try { r = c.call(this, r[1]); } catch (ey) { throw new $P.Exception(r[1]); } } return [ rx, (r?r[1]:s) ]; }; }, // // Composite Operators // between: function (d1, p, d2) { d2 = d2 || d1; var _fn = _.each(_.ignore(d1), p, _.ignore(d2)); return function (s) { var rx = _fn.call(this, s); return [[rx[0][0], r[0][2]], rx[1]]; }; }, list: function (p, d, c) { d = d || _.rtoken(/^\s*/); c = c || null; return (p instanceof Array ? _.each(_.product(p.slice(0, -1), _.ignore(d)), p.slice(-1), _.ignore(c)) : _.each(_.many(_.each(p, _.ignore(d))), px, _.ignore(c))); }, set: function (px, d, c) { d = d || _.rtoken(/^\s*/); c = c || null; return function (s) { // r is the current match, best the current 'best' match // which means it parsed the most amount of input var r = null, p = null, q = null, rx = null, best = [[], s], last = false; // go through the rules in the given set for (var i = 0; i < px.length ; i++) { // last is a flag indicating whether this must be the last element // if there is only 1 element, then it MUST be the last one q = null; p = null; r = null; last = (px.length === 1); // first, we try simply to match the current pattern // if not, try the next pattern try { r = px[i].call(this, s); } catch (e) { continue; } // since we are matching against a set of elements, the first // thing to do is to add r[0] to matched elements rx = [[r[0]], r[1]]; // if we matched and there is still input to parse and // we don't already know this is the last element, // we're going to next check for the delimiter ... // if there's none, or if there's no input left to parse // than this must be the last element after all ... if (r[1].length > 0 && ! last) { try { q = d.call(this, r[1]); } catch (ex) { last = true; } } else { last = true; } // if we parsed the delimiter and now there's no more input, // that means we shouldn't have parsed the delimiter at all // so don't update r and mark this as the last element ... if (!last && q[1].length === 0) { last = true; } // so, if this isn't the last element, we're going to see if // we can get any more matches from the remaining (unmatched) // elements ... if (!last) { // build a list of the remaining rules we can match against, // i.e., all but the one we just matched against var qx = []; for (var j = 0; j < px.length ; j++) { if (i !== j) { qx.push(px[j]); } } // now invoke recursively set with the remaining input // note that we don't include the closing delimiter ... // we'll check for that ourselves at the end p = _.set(qx, d).call(this, q[1]); // if we got a non-empty set as a result ... // (otw rx already contains everything we want to match) if (p[0].length > 0) { // update current result, which is stored in rx ... // basically, pick up the remaining text from p[1] // and concat the result from p[0] so that we don't // get endless nesting ... rx[0] = rx[0].concat(p[0]); rx[1] = p[1]; } } // at this point, rx either contains the last matched element // or the entire matched set that starts with this element. // now we just check to see if this variation is better than // our best so far, in terms of how much of the input is parsed if (rx[1].length < best[1].length) { best = rx; } // if we've parsed all the input, then we're finished if (best[1].length === 0) { break; } } // so now we've either gone through all the patterns trying them // as the initial match; or we found one that parsed the entire // input string ... // if best has no matches, just return empty set ... if (best[0].length === 0) { return best; } // if a closing delimiter is provided, then we have to check it also if (c) { // we try this even if there is no remaining input because the pattern // may well be optional or match empty input ... try { q = c.call(this, best[1]); } catch (ey) { throw new $P.Exception(best[1]); } // it parsed ... be sure to update the best match remaining input best[1] = q[1]; } // if we're here, either there was no closing delimiter or we parsed it // so now we have the best match; just return it! return best; }; }, forward: function (gr, fname) { return function (s) { return gr[fname].call(this, s); }; }, // // Translation Operators // replace: function (rule, repl) { return function (s) { var r = rule.call(this, s); return [repl, r[1]]; }; }, process: function (rule, fn) { return function (s) { var r = rule.call(this, s); return [fn.call(this, r[0]), r[1]]; }; }, min: function (min, rule) { return function (s) { var rx = rule.call(this, s); if (rx[0].length < min) { throw new $P.Exception(s); } return rx; }; } }; // Generator Operators And Vector Operators // Generators are operators that have a signature of F(R) => R, // taking a given rule and returning another rule, such as // ignore, which parses a given rule and throws away the result. // Vector operators are those that have a signature of F(R1,R2,...) => R, // take a list of rules and returning a new rule, such as each. // Generator operators are converted (via the following _generator // function) into functions that can also take a list or array of rules // and return an array of new rules as though the function had been // called on each rule in turn (which is what actually happens). // This allows generators to be used with vector operators more easily. // Example: // each(ignore(foo, bar)) instead of each(ignore(foo), ignore(bar)) // This also turns generators into vector operators, which allows // constructs like: // not(cache(foo, bar)) var _generator = function (op) { function gen() { var args = null, rx = [], px, i; if (arguments.length > 1) { args = Array.prototype.slice.call(arguments); } else if (arguments[0] instanceof Array) { args = arguments[0]; } if (args) { px = args.shift(); if (px.length > 0) { args.unshift(px[i]); rx.push(op.apply(null, args)); args.shift(); return rx; } } else { return op.apply(null, arguments); } } return gen; }; var gx = "optional not ignore cache".split(/\s/); for (var i = 0 ; i < gx.length ; i++) { _[gx[i]] = _generator(_[gx[i]]); } var _vector = function (op) { return function () { if (arguments[0] instanceof Array) { return op.apply(null, arguments[0]); } else { return op.apply(null, arguments); } }; }; var vx = "each any all".split(/\s/); for (var j = 0 ; j < vx.length ; j++) { _[vx[j]] = _vector(_[vx[j]]); } }()); (function () { var $D = Date; var flattenAndCompact = function (ax) { var rx = []; for (var i = 0; i < ax.length; i++) { if (ax[i] instanceof Array) { rx = rx.concat(flattenAndCompact(ax[i])); } else { if (ax[i]) { rx.push(ax[i]); } } } return rx; }; var parseMeridian = function () { if (this.meridian && (this.hour || this.hour === 0)) { if (this.meridian === "a" && this.hour > 11 && Date.Config.strict24hr){ throw "Invalid hour and meridian combination"; } else if (this.meridian === "p" && this.hour < 12 && Date.Config.strict24hr){ throw "Invalid hour and meridian combination"; } else if (this.meridian === "p" && this.hour < 12) { this.hour = this.hour + 12; } else if (this.meridian === "a" && this.hour === 12) { this.hour = 0; } } }; var setDefaults = function () { var now = new Date(); if ((this.hour || this.minute) && (!this.month && !this.year && !this.day)) { this.day = now.getDate(); } if (!this.year) { this.year = now.getFullYear(); } if (!this.month && this.month !== 0) { this.month = now.getMonth(); } if (!this.day) { this.day = 1; } if (!this.hour) { this.hour = 0; } if (!this.minute) { this.minute = 0; } if (!this.second) { this.second = 0; } if (!this.millisecond) { this.millisecond = 0; } }; var finishUtils = { getToday: function () { if (this.now || "hour minute second".indexOf(this.unit) !== -1) { return new Date(); } else { return $D.today(); } }, setDaysFromWeekday: function (today, orient){ var gap; orient = orient || 1; this.unit = "day"; gap = ($D.getDayNumberFromName(this.weekday) - today.getDay()); this.days = gap ? ((gap + (orient * 7)) % 7) : (orient * 7); return this; }, setMonthsFromMonth: function (today, orient) { var gap; orient = orient || 1; this.unit = "month"; gap = (this.month - today.getMonth()); this.months = gap ? ((gap + (orient * 12)) % 12) : (orient * 12); this.month = null; return this; }, setDMYFromWeekday: function () { var d = Date[this.weekday](); this.day = d.getDate(); if (!this.month) { this.month = d.getMonth(); } this.year = d.getFullYear(); return this; }, setUnitValue: function (orient) { if (!this.value && this.operator && this.operator !== null && this[this.unit + "s"] && this[this.unit + "s"] !== null) { this[this.unit + "s"] = this[this.unit + "s"] + ((this.operator === "add") ? 1 : -1) + (this.value||0) * orient; } else if (this[this.unit + "s"] == null || this.operator != null) { if (!this.value) { this.value = 1; } this[this.unit + "s"] = this.value * orient; } }, generateDateFromWeeks: function () { var weekday = (this.weekday !== undefined) ? this.weekday : "today"; var d = Date[weekday]().addWeeks(this.weeks); if (this.now) { d.setTimeToNow(); } return d; } }; $D.Translator = { hour: function (s) { return function () { this.hour = Number(s); }; }, minute: function (s) { return function () { this.minute = Number(s); }; }, second: function (s) { return function () { this.second = Number(s); }; }, /* for ss.s format */ secondAndMillisecond: function (s) { return function () { var mx = s.match(/^([0-5][0-9])\.([0-9]{1,3})/); this.second = Number(mx[1]); this.millisecond = Number(mx[2]); }; }, meridian: function (s) { return function () { this.meridian = s.slice(0, 1).toLowerCase(); }; }, timezone: function (s) { return function () { var n = s.replace(/[^\d\+\-]/g, ""); if (n.length) { this.timezoneOffset = Number(n); } else { this.timezone = s.toLowerCase(); } }; }, day: function (x) { var s = x[0]; return function () { this.day = Number(s.match(/\d+/)[0]); if (this.day < 1) { throw "invalid day"; } }; }, month: function (s) { return function () { this.month = (s.length === 3) ? "jan feb mar apr may jun jul aug sep oct nov dec".indexOf(s)/4 : Number(s) - 1; if (this.month < 0) { throw "invalid month"; } }; }, year: function (s) { return function () { var n = Number(s); this.year = ((s.length > 2) ? n : (n + (((n + 2000) < Date.CultureInfo.twoDigitYearMax) ? 2000 : 1900))); }; }, rday: function (s) { return function () { switch (s) { case "yesterday": this.days = -1; break; case "tomorrow": this.days = 1; break; case "today": this.days = 0; break; case "now": this.days = 0; this.now = true; break; } }; }, finishExact: function (x) { var d; x = (x instanceof Array) ? x : [x]; for (var i = 0 ; i < x.length ; i++) { if (x[i]) { x[i].call(this); } } setDefaults.call(this); parseMeridian.call(this); if (this.day > $D.getDaysInMonth(this.year, this.month)) { throw new RangeError(this.day + " is not a valid value for days."); } d = new Date(this.year, this.month, this.day, this.hour, this.minute, this.second, this.millisecond); if (this.year < 100) { d.setFullYear(this.year); // means years less that 100 are process correctly. JS will parse it otherwise as 1900-1999. } if (this.timezone) { d.set({ timezone: this.timezone }); } else if (this.timezoneOffset) { d.set({ timezoneOffset: this.timezoneOffset }); } return d; }, finish: function (x) { var today, expression, orient, temp; x = (x instanceof Array) ? flattenAndCompact(x) : [ x ]; if (x.length === 0) { return null; } for (var i = 0 ; i < x.length ; i++) { if (typeof x[i] === "function") { x[i].call(this); } } if (this.now && !this.unit && !this.operator) { return new Date(); } else { today = finishUtils.getToday.call(this); } expression = !!(this.days && this.days !== null || this.orient || this.operator); orient = ((this.orient === "past" || this.operator === "subtract") ? -1 : 1); if (this.month && this.unit === "week") { this.value = this.month + 1; delete this.month; delete this.day; } if ((this.month || this.month === 0) && "year day hour minute second".indexOf(this.unit) !== -1) { if (!this.value) { this.value = this.month + 1; } this.month = null; expression = true; } if (!expression && this.weekday && !this.day && !this.days) { finishUtils.setDMYFromWeekday.call(this); } if (expression && this.weekday && this.unit !== "month" && this.unit !== "week") { finishUtils.setDaysFromWeekday.call(this, today, orient); } if (this.weekday && this.unit !== "week" && !this.day && !this.days) { temp = Date[this.weekday](); this.day = temp.getDate(); if (temp.getMonth() !== today.getMonth()) { this.month = temp.getMonth(); } } if (this.month && this.unit === "day" && this.operator) { if (!this.value) { this.value = (this.month + 1); } this.month = null; } if (this.value != null && this.month != null && this.year != null) { this.day = this.value * 1; } if (this.month && !this.day && this.value) { today.set({ day: this.value * 1 }); if (!expression) { this.day = this.value * 1; } } if (!this.month && this.value && this.unit === "month" && !this.now) { this.month = this.value; expression = true; } if (expression && (this.month || this.month === 0) && this.unit !== "year") { finishUtils.setMonthsFromMonth.call(this, today, orient); } if (!this.unit) { this.unit = "day"; } finishUtils.setUnitValue.call(this, orient); parseMeridian.call(this); if ((this.month || this.month === 0) && !this.day) { this.day = 1; } if (!this.orient && !this.operator && this.unit === "week" && this.value && !this.day && !this.month) { return Date.today().setWeek(this.value); } if (this.unit === "week" && this.weeks && !this.day && !this.month) { return finishUtils.generateDateFromWeeks.call(this); } if (expression && this.timezone && this.day && this.days) { this.day = this.days; } if (expression){ today.add(this); } else { today.set(this); } if (this.timezone) { this.timezone = this.timezone.toUpperCase(); var offset = $D.getTimezoneOffset(this.timezone); var timezone; if (today.hasDaylightSavingTime()) { // lets check that we're being sane with timezone setting timezone = $D.getTimezoneAbbreviation(offset, today.isDaylightSavingTime()); if (timezone !== this.timezone) { // bugger, we're in a place where things like EST vs EDT matters. if (today.isDaylightSavingTime()) { today.addHours(-1); } else { today.addHours(1); } } } today.setTimezoneOffset(offset); } return today; } }; }()); (function () { var $D = Date; $D.Grammar = {}; var _ = $D.Parsing.Operators, g = $D.Grammar, t = $D.Translator, _fn; // Allow rolling up into general purpose rules _fn = function () { return _.each(_.any.apply(null, arguments), _.not(g.ctoken2("timeContext"))); }; g.datePartDelimiter = _.rtoken(/^([\s\-\.\,\/\x27]+)/); g.timePartDelimiter = _.stoken(":"); g.whiteSpace = _.rtoken(/^\s*/); g.generalDelimiter = _.rtoken(/^(([\s\,]|at|@|on)+)/); var _C = {}; g.ctoken = function (keys) { var fn = _C[keys]; if (! fn) { var c = Date.CultureInfo.regexPatterns; var kx = keys.split(/\s+/), px = []; for (var i = 0; i < kx.length ; i++) { px.push(_.replace(_.rtoken(c[kx[i]]), kx[i])); } fn = _C[keys] = _.any.apply(null, px); } return fn; }; g.ctoken2 = function (key) { return _.rtoken(Date.CultureInfo.regexPatterns[key]); }; var cacheProcessRtoken = function (key, token, type, eachToken) { if (eachToken) { g[key] = _.cache(_.process(_.each(_.rtoken(token),_.optional(g.ctoken2(eachToken))), type)); } else { g[key] = _.cache(_.process(_.rtoken(token), type)); } }; var cacheProcessCtoken = function (token, type) { return _.cache(_.process(g.ctoken2(token), type)); }; var _F = {}; //function cache var _get = function (f) { _F[f] = (_F[f] || g.format(f)[0]); return _F[f]; }; g.allformats = function (fx) { var rx = []; if (fx instanceof Array) { for (var i = 0; i < fx.length; i++) { rx.push(_get(fx[i])); } } else { rx.push(_get(fx)); } return rx; }; g.formats = function (fx) { if (fx instanceof Array) { var rx = []; for (var i = 0 ; i < fx.length ; i++) { rx.push(_get(fx[i])); } return _.any.apply(null, rx); } else { return _get(fx); } }; var grammarFormats = { timeFormats: function(){ var i, RTokenKeys = [ "h", "hh", "H", "HH", "m", "mm", "s", "ss", "ss.s", "z", "zz" ], RToken = [ /^(0[0-9]|1[0-2]|[1-9])/, /^(0[0-9]|1[0-2])/, /^([0-1][0-9]|2[0-3]|[0-9])/, /^([0-1][0-9]|2[0-3])/, /^([0-5][0-9]|[0-9])/, /^[0-5][0-9]/, /^([0-5][0-9]|[0-9])/, /^[0-5][0-9]/, /^[0-5][0-9]\.[0-9]{1,3}/, /^((\+|\-)\s*\d\d\d\d)|((\+|\-)\d\d\:?\d\d)/, /^((\+|\-)\s*\d\d\d\d)|((\+|\-)\d\d\:?\d\d)/ ], tokens = [ t.hour, t.hour, t.hour, t.hour, t.minute, t.minute, t.second, t.second, t.secondAndMillisecond, t.timezone, t.timezone ]; for (i=0; i < RTokenKeys.length; i++) { cacheProcessRtoken(RTokenKeys[i], RToken[i], tokens[i]); } g.hms = _.cache(_.sequence([g.H, g.m, g.s], g.timePartDelimiter)); g.t = cacheProcessCtoken("shortMeridian", t.meridian); g.tt = cacheProcessCtoken("longMeridian", t.meridian); g.zzz = cacheProcessCtoken("timezone", t.timezone); g.timeSuffix = _.each(_.ignore(g.whiteSpace), _.set([ g.tt, g.zzz ])); g.time = _.each(_.optional(_.ignore(_.stoken("T"))), g.hms, g.timeSuffix); }, dateFormats: function () { // pre-loaded rules for different date part order preferences var _setfn = function () { return _.set(arguments, g.datePartDelimiter); }; var i, RTokenKeys = [ "d", "dd", "M", "MM", "y", "yy", "yyy", "yyyy" ], RToken = [ /^([0-2]\d|3[0-1]|\d)/, /^([0-2]\d|3[0-1])/, /^(1[0-2]|0\d|\d)/, /^(1[0-2]|0\d)/, /^(\d+)/, /^(\d\d)/, /^(\d\d?\d?\d?)/, /^(\d\d\d\d)/ ], tokens = [ t.day, t.day, t.month, t.month, t.year, t.year, t.year, t.year ], eachToken = [ "ordinalSuffix", "ordinalSuffix" ]; for (i=0; i < RTokenKeys.length; i++) { cacheProcessRtoken(RTokenKeys[i], RToken[i], tokens[i], eachToken[i]); } g.MMM = g.MMMM = _.cache(_.process(g.ctoken("jan feb mar apr may jun jul aug sep oct nov dec"), t.month)); g.ddd = g.dddd = _.cache(_.process(g.ctoken("sun mon tue wed thu fri sat"), function (s) { return function () { this.weekday = s; }; } )); g.day = _fn(g.d, g.dd); g.month = _fn(g.M, g.MMM); g.year = _fn(g.yyyy, g.yy); g.mdy = _setfn(g.ddd, g.month, g.day, g.year); g.ymd = _setfn(g.ddd, g.year, g.month, g.day); g.dmy = _setfn(g.ddd, g.day, g.month, g.year); g.date = function (s) { return ((g[Date.CultureInfo.dateElementOrder] || g.mdy).call(this, s)); }; }, relative: function () { // relative date / time expressions g.orientation = _.process(g.ctoken("past future"), function (s) { return function () { this.orient = s; }; } ); g.operator = _.process(g.ctoken("add subtract"), function (s) { return function () { this.operator = s; }; } ); g.rday = _.process(g.ctoken("yesterday tomorrow today now"), t.rday); g.unit = _.process(g.ctoken("second minute hour day week month year"), function (s) { return function () { this.unit = s; }; } ); } }; g.buildGrammarFormats = function () { // these need to be rebuilt every time the language changes. _C = {}; grammarFormats.timeFormats(); grammarFormats.dateFormats(); grammarFormats.relative(); g.value = _.process(_.rtoken(/^([-+]?\d+)?(st|nd|rd|th)?/), function (s) { return function () { this.value = s.replace(/\D/g, ""); }; } ); g.expression = _.set([g.rday, g.operator, g.value, g.unit, g.orientation, g.ddd, g.MMM ]); g.format = _.process(_.many( _.any( // translate format specifiers into grammar rules _.process( _.rtoken(/^(dd?d?d?(?!e)|MM?M?M?|yy?y?y?|hh?|HH?|mm?|ss?|tt?|zz?z?)/), function (fmt) { if (g[fmt]) { return g[fmt]; } else { throw $D.Parsing.Exception(fmt); } } ), // translate separator tokens into token rules _.process(_.rtoken(/^[^dMyhHmstz]+/), // all legal separators function (s) { return _.ignore(_.stoken(s)); } ) ) ), // construct the parser ... function (rules) { return _.process(_.each.apply(null, rules), t.finishExact); } ); // starting rule for general purpose grammar g._start = _.process(_.set([ g.date, g.time, g.expression ], g.generalDelimiter, g.whiteSpace), t.finish); }; g.buildGrammarFormats(); // parsing date format specifiers - ex: "h:m:s tt" // this little guy will generate a custom parser based // on the format string, ex: g.format("h:m:s tt") // check for these formats first g._formats = g.formats([ "\"yyyy-MM-ddTHH:mm:ssZ\"", "yyyy-MM-ddTHH:mm:ss.sz", "yyyy-MM-ddTHH:mm:ssZ", "yyyy-MM-ddTHH:mm:ssz", "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-ddTHH:mmZ", "yyyy-MM-ddTHH:mmz", "yyyy-MM-ddTHH:mm", "ddd, MMM dd, yyyy H:mm:ss tt", "ddd MMM d yyyy HH:mm:ss zzz", "MMddyyyy", "ddMMyyyy", "Mddyyyy", "ddMyyyy", "Mdyyyy", "dMyyyy", "yyyy", "Mdyy", "dMyy", "d" ]); // real starting rule: tries selected formats first, // then general purpose rule g.start = function (s) { try { var r = g._formats.call({}, s); if (r[1].length === 0) { return r; } } catch (e) {} return g._start.call({}, s); }; }()); (function () { var $D = Date; /** * @desc Converts the specified string value into its JavaScript Date equivalent using CultureInfo specific format information. * * Example

	///////////
	// Dates //
	///////////

	// 15-Oct-2004
	var d1 = Date.parse("10/15/2004");

	// 15-Oct-2004
	var d1 = Date.parse("15-Oct-2004");

	// 15-Oct-2004
	var d1 = Date.parse("2004.10.15");

	//Fri Oct 15, 2004
	var d1 = Date.parse("Fri Oct 15, 2004");

	///////////
	// Times //
	///////////

	// Today at 10 PM.
	var d1 = Date.parse("10 PM");

	// Today at 10:30 PM.
	var d1 = Date.parse("10:30 P.M.");

	// Today at 6 AM.
	var d1 = Date.parse("06am");

	/////////////////////
	// Dates and Times //
	/////////////////////

	// 8-July-2004 @ 10:30 PM
	var d1 = Date.parse("July 8th, 2004, 10:30 PM");

	// 1-July-2004 @ 10:30 PM
	var d1 = Date.parse("2004-07-01T22:30:00");

	////////////////////
	// Relative Dates //
	////////////////////

	// Returns today's date. The string "today" is culture specific.
	var d1 = Date.parse("today");

	// Returns yesterday's date. The string "yesterday" is culture specific.
	var d1 = Date.parse("yesterday");

	// Returns the date of the next thursday.
	var d1 = Date.parse("Next thursday");

	// Returns the date of the most previous monday.
	var d1 = Date.parse("last monday");

	// Returns today's day + one year.
	var d1 = Date.parse("next year");

	///////////////
	// Date Math //
	///////////////

	// Today + 2 days
	var d1 = Date.parse("t+2");

	// Today + 2 days
	var d1 = Date.parse("today + 2 days");

	// Today + 3 months
	var d1 = Date.parse("t+3m");

	// Today - 1 year
	var d1 = Date.parse("today - 1 year");

	// Today - 1 year
	var d1 = Date.parse("t-1y"); 


	/////////////////////////////
	// Partial Dates and Times //
	/////////////////////////////

	// July 15th of this year.
	var d1 = Date.parse("July 15");

	// 15th day of current day and year.
	var d1 = Date.parse("15");

	// July 1st of current year at 10pm.
	var d1 = Date.parse("7/1 10pm");
	
* * @param {String} The string value to convert into a Date object [Required] * @return {Date} A Date object or null if the string cannot be converted into a Date. */ var parseUtils = { removeOrds: function (s) { ords = s.match(/\b(\d+)(?:st|nd|rd|th)\b/); // find ordinal matches s = ((ords && ords.length === 2) ? s.replace(ords[0], ords[1]) : s); return s; }, grammarParser: function (s) { var r = null; try { r = $D.Grammar.start.call({}, s.replace(/^\s*(\S*(\s+\S+)*)\s*$/, "$1")); } catch (e) { return null; } return ((r[1].length === 0) ? r[0] : null); }, nativeFallback: function(s) { var t; try { // ok we haven't parsed it, last ditch attempt with the built-in parser. t = Date._parse(s); return (t || t === 0) ? new Date(t) : null; } catch (e) { return null; } } }; function parse (s) { var d; if (!s) { return null; } if (s instanceof Date) { return s.clone(); } if (s.length >= 4 && s.charAt(0) !== "0" && s.charAt(0) !== "+"&& s.charAt(0) !== "-") { // ie: 2004 will pass, 0800 won't. // Start with specific formats d = $D.Parsing.ISO.parse(s) || $D.Parsing.Numeric.parse(s); } if (d instanceof Date && !isNaN(d.getTime())) { return d; } else { // find ordinal dates (1st, 3rd, 8th, etc and remove them as they cause parsing issues) s = $D.Parsing.Normalizer.parse(parseUtils.removeOrds(s)); d = parseUtils.grammarParser(s); if (d !== null) { return d; } else { return parseUtils.nativeFallback(s); } } } if (!$D._parse) { $D._parse = $D.parse; } $D.parse = parse; Date.getParseFunction = function (fx) { var fns = Date.Grammar.allformats(fx); return function (s) { var r = null; for (var i = 0; i < fns.length; i++) { try { r = fns[i].call({}, s); } catch (e) { continue; } if (r[1].length === 0) { return r[0]; } } return null; }; }; /** * Converts the specified string value into its JavaScript Date equivalent using the specified format {String} or formats {Array} and the CultureInfo specific format information. * The format of the string value must match one of the supplied formats exactly. * * Example

	// 15-Oct-2004
	var d1 = Date.parseExact("10/15/2004", "M/d/yyyy");

	// 15-Oct-2004
	var d1 = Date.parse("15-Oct-2004", "M-ddd-yyyy");

	// 15-Oct-2004
	var d1 = Date.parse("2004.10.15", "yyyy.MM.dd");

	// Multiple formats
	var d1 = Date.parseExact("10/15/2004", ["M/d/yyyy", "MMMM d, yyyy"]);
	
* * @param {String} The string value to convert into a Date object [Required]. * @param {Object} The expected format {String} or an array of expected formats {Array} of the date string [Required]. * @return {Date} A Date object or null if the string cannot be converted into a Date. */ $D.parseExact = function (s, fx) { return $D.getParseFunction(fx)(s); }; }()); (function () { var $D = Date, $P = $D.prototype, // $C = $D.CultureInfo, // not used atm p = function (s, l) { if (!l) { l = 2; } return ("000" + s).slice(l * -1); }; /** * Converts a PHP format string to Java/.NET format string. * A PHP format string can be used with ._format or .format. * A Java/.NET format string can be used with .toString(). * The .parseExact function will only accept a Java/.NET format string * * Example * var f1 = "%m/%d/%y" * var f2 = Date.normalizeFormat(f1); // "MM/dd/yy" * * new Date().format(f1); // "04/13/08" * new Date()._format(f1); // "04/13/08" * new Date().toString(f2); // "04/13/08" * * var date = Date.parseExact("04/13/08", f2); // Sun Apr 13 2008 * * @param {String} A PHP format string consisting of one or more format spcifiers. * @return {String} The PHP format converted to a Java/.NET format string. */ var normalizerSubstitutions = { "d" : "dd", "%d": "dd", "D" : "ddd", "%a": "ddd", "j" : "dddd", "l" : "dddd", "%A": "dddd", "S" : "S", "F" : "MMMM", "%B": "MMMM", "m" : "MM", "%m": "MM", "M" : "MMM", "%b": "MMM", "%h": "MMM", "n" : "M", "Y" : "yyyy", "%Y": "yyyy", "y" : "yy", "%y": "yy", "g" : "h", "%I": "h", "G" : "H", "h" : "hh", "H" : "HH", "%H": "HH", "i" : "mm", "%M": "mm", "s" : "ss", "%S": "ss", "%r": "hh:mm tt", "%R": "H:mm", "%T": "H:mm:ss", "%X": "t", "%x": "d", "%e": "d", "%D": "MM/dd/yy", "%n": "\\n", "%t": "\\t", "e" : "z", "T" : "z", "%z": "z", "%Z": "z", "Z" : "ZZ", "N" : "u", "w" : "u", "%w": "u", "W" : "W", "%V": "W" }; var normalizer = { substitutes: function (m) { return normalizerSubstitutions[m]; }, interpreted: function (m, x) { var y; switch (m) { case "%u": return x.getDay() + 1; case "z": return x.getOrdinalNumber(); case "%j": return p(x.getOrdinalNumber(), 3); case "%U": var d1 = x.clone().set({month: 0, day: 1}).addDays(-1).moveToDayOfWeek(0), d2 = x.clone().addDays(1).moveToDayOfWeek(0, -1); return (d2 < d1) ? "00" : p((d2.getOrdinalNumber() - d1.getOrdinalNumber()) / 7 + 1); case "%W": return p(x.getWeek()); case "t": return $D.getDaysInMonth(x.getFullYear(), x.getMonth()); case "o": case "%G": return x.setWeek(x.getISOWeek()).toString("yyyy"); case "%g": return x._format("%G").slice(-2); case "a": case "%p": return t("tt").toLowerCase(); case "A": return t("tt").toUpperCase(); case "u": return p(x.getMilliseconds(), 3); case "I": return (x.isDaylightSavingTime()) ? 1 : 0; case "O": return x.getUTCOffset(); case "P": y = x.getUTCOffset(); return y.substring(0, y.length - 2) + ":" + y.substring(y.length - 2); case "B": var now = new Date(); return Math.floor(((now.getHours() * 3600) + (now.getMinutes() * 60) + now.getSeconds() + (now.getTimezoneOffset() + 60) * 60) / 86.4); case "c": return x.toISOString().replace(/\"/g, ""); case "U": return $D.strtotime("now"); case "%c": return t("d") + " " + t("t"); case "%C": return Math.floor(x.getFullYear() / 100 + 1); } }, shouldOverrideDefaults: function (m) { switch (m) { case "%e": return true; default: return false; } }, parse: function (m, context) { var formatString, c = context || new Date(); formatString = normalizer.substitutes(m); if (formatString) { return formatString; } formatString = normalizer.interpreted(m, c); if (formatString) { return formatString; } else { return m; } } }; $D.normalizeFormat = function (format, context) { return format.replace(/(%|\\)?.|%%/g, function(t){ return normalizer.parse(t, context); }); }; /** * Format a local Unix timestamp according to locale settings * * Example: * Date.strftime("%m/%d/%y", new Date()); // "04/13/08" * Date.strftime("c", "2008-04-13T17:52:03Z"); // "04/13/08" * * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @param {Number|String} The number representing the number of seconds that have elapsed since January 1, 1970 (local time). * @return {String} A string representation of the current Date object. */ $D.strftime = function (format, time) { var d = Date.parse(time); return d._format(format); }; /** * Parse any textual datetime description into a Unix timestamp. * A Unix timestamp is the number of seconds that have elapsed since January 1, 1970 (midnight UTC/GMT). * * Example: * Date.strtotime("04/13/08"); // 1208044800 * Date.strtotime("1970-01-01T00:00:00Z"); // 0 * * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @param {Object} A string or date object. * @return {String} A string representation of the current Date object. */ $D.strtotime = function (time) { var d = $D.parse(time); return Math.round($D.UTC(d.getUTCFullYear(), d.getUTCMonth(), d.getUTCDate(), d.getUTCHours(), d.getUTCMinutes(), d.getUTCSeconds(), d.getUTCMilliseconds()) / 1000); }; /** * Converts the value of the current Date object to its equivalent string representation using a PHP/Unix style of date format specifiers. * Format Specifiers * Format Description Example * ------ --------------------------------------------------------------------------- ----------------------- * %a abbreviated weekday name according to the current localed "Mon" through "Sun" * %A full weekday name according to the current localed "Sunday" through "Saturday" * %b abbreviated month name according to the current localed "Jan" through "Dec" * %B full month name according to the current locale "January" through "December" * %c preferred date and time representation for the current locale "4/13/2008 12:33 PM" * %C century number (the year divided by 100 and truncated to an integer) "00" to "99" * %d day of the month as a decimal number "01" to "31" * %D same as %m/%d/%y "04/13/08" * %e day of the month as a decimal number, a single digit is preceded by a space "1" to "31" * %g like %G, but without the century "08" * %G The 4-digit year corresponding to the ISO week number (see %V). "2008" * This has the same format and value as %Y, except that if the ISO week number * belongs to the previous or next year, that year is used instead. * %h same as %b "Jan" through "Dec" * %H hour as a decimal number using a 24-hour clock. "00" to "23" * %I hour as a decimal number using a 12-hour clock. "01" to "12" * %j day of the year as a decimal number. "001" to "366" * %m month as a decimal number. "01" to "12" * %M minute as a decimal number. "00" to "59" * %n newline character "\n" * %p either "am" or "pm" according to the given time value, or the "am" or "pm" * corresponding strings for the current locale. * %r time in a.m. and p.m. notation "8:44 PM" * %R time in 24 hour notation "20:44" * %S second as a decimal number "00" to "59" * %t tab character "\t" * %T current time, equal to %H:%M:%S "12:49:11" * %u weekday as a decimal number ["1", "7"], with "1" representing Monday "1" to "7" * %U week number of the current year as a decimal number, starting with the "0" to ("52" or "53") * first Sunday as the first day of the first week * %V The ISO 8601:1988 week number of the current year as a decimal number, "00" to ("52" or "53") * range 01 to 53, where week 1 is the first week that has at least 4 days * in the current year, and with Monday as the first day of the week. * (Use %G or %g for the year component that corresponds to the week number * for the specified timestamp.) * %W week number of the current year as a decimal number, starting with the "00" to ("52" or "53") * first Monday as the first day of the first week * %w day of the week as a decimal, Sunday being "0" "0" to "6" * %x preferred date representation for the current locale without the time "4/13/2008" * %X preferred time representation for the current locale without the date "12:53:05" * %y year as a decimal number without a century "00" "99" * %Y year as a decimal number including the century "2008" * %Z time zone or name or abbreviation "UTC", "EST", "PST" * %z same as %Z * %% a literal "%" characters "%" * d Day of the month, 2 digits with leading zeros "01" to "31" * D A textual representation of a day, three letters "Mon" through "Sun" * j Day of the month without leading zeros "1" to "31" * l A full textual representation of the day of the week (lowercase "L") "Sunday" through "Saturday" * N ISO-8601 numeric representation of the day of the week (added in PHP 5.1.0) "1" (for Monday) through "7" (for Sunday) * S English ordinal suffix for the day of the month, 2 characters "st", "nd", "rd" or "th". Works well with j * w Numeric representation of the day of the week "0" (for Sunday) through "6" (for Saturday) * z The day of the year (starting from "0") "0" through "365" * W ISO-8601 week number of year, weeks starting on Monday "00" to ("52" or "53") * F A full textual representation of a month, such as January or March "January" through "December" * m Numeric representation of a month, with leading zeros "01" through "12" * M A short textual representation of a month, three letters "Jan" through "Dec" * n Numeric representation of a month, without leading zeros "1" through "12" * t Number of days in the given month "28" through "31" * L Whether it's a leap year "1" if it is a leap year, "0" otherwise * o ISO-8601 year number. This has the same value as Y, except that if the "2008" * ISO week number (W) belongs to the previous or next year, that year * is used instead. * Y A full numeric representation of a year, 4 digits "2008" * y A two digit representation of a year "08" * a Lowercase Ante meridiem and Post meridiem "am" or "pm" * A Uppercase Ante meridiem and Post meridiem "AM" or "PM" * B Swatch Internet time "000" through "999" * g 12-hour format of an hour without leading zeros "1" through "12" * G 24-hour format of an hour without leading zeros "0" through "23" * h 12-hour format of an hour with leading zeros "01" through "12" * H 24-hour format of an hour with leading zeros "00" through "23" * i Minutes with leading zeros "00" to "59" * s Seconds, with leading zeros "00" through "59" * u Milliseconds "54321" * e Timezone identifier "UTC", "EST", "PST" * I Whether or not the date is in daylight saving time (uppercase i) "1" if Daylight Saving Time, "0" otherwise * O Difference to Greenwich time (GMT) in hours "+0200", "-0600" * P Difference to Greenwich time (GMT) with colon between hours and minutes "+02:00", "-06:00" * T Timezone abbreviation "UTC", "EST", "PST" * Z Timezone offset in seconds. The offset for timezones west of UTC is "-43200" through "50400" * always negative, and for those east of UTC is always positive. * c ISO 8601 date "2004-02-12T15:19:21+00:00" * r RFC 2822 formatted date "Thu, 21 Dec 2000 16:01:07 +0200" * U Seconds since the Unix Epoch (January 1 1970 00:00:00 GMT) "0" * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @return {String} A string representation of the current Date object. */ var formatReplace = function (context) { return function (m) { var formatString, override = false; if (m.charAt(0) === "\\" || m.substring(0, 2) === "%%") { return m.replace("\\", "").replace("%%", "%"); } override = normalizer.shouldOverrideDefaults(m); formatString = $D.normalizeFormat(m, context); if (formatString) { return context.toString(formatString, override); } }; }; $P._format = function (format) { var formatter = formatReplace(this); if (!format) { return this._toString(); } else { return format.replace(/(%|\\)?.|%%/g, formatter); } }; if (!$P.format) { $P.format = $P._format; } }()); (function () { "use strict"; var gFn = function (attr) { return function () { return this[attr]; }; }; var sFn = function (attr) { return function (val) { this[attr] = val; return this; }; }; var attrs = ["years", "months", "days", "hours", "minutes", "seconds", "milliseconds"]; var addSetFuncs = function (context, attrs) { for (var i = 0; i < attrs.length ; i++) { var $a = attrs[i], $b = $a.slice(0, 1).toUpperCase() + $a.slice(1); context.prototype[$a] = 0; context.prototype["get" + $b] = gFn($a); context.prototype["set" + $b] = sFn($a); } }; /** * new TimeSpan(milliseconds); * new TimeSpan(days, hours, minutes, seconds); * new TimeSpan(days, hours, minutes, seconds, milliseconds); */ var TimeSpan = function (days, hours, minutes, seconds, milliseconds) { if (arguments.length === 1 && typeof days === "number") { var orient = (days < 0) ? -1 : +1; var millsLeft = Math.abs(days); this.setDays(Math.floor(millsLeft / 86400000) * orient); millsLeft = millsLeft % 86400000; this.setHours(Math.floor(millsLeft / 3600000) * orient); millsLeft = millsLeft % 3600000; this.setMinutes(Math.floor(millsLeft / 60000) * orient); millsLeft = millsLeft % 60000; this.setSeconds(Math.floor(millsLeft / 1000) * orient); millsLeft = millsLeft % 1000; this.setMilliseconds(millsLeft * orient); } else { this.set(days, hours, minutes, seconds, milliseconds); } this.getTotalMilliseconds = function () { return (this.getDays() * 86400000) + (this.getHours() * 3600000) + (this.getMinutes() * 60000) + (this.getSeconds() * 1000); }; this.compareTo = function (time) { var t1 = new Date(1970, 1, 1, this.getHours(), this.getMinutes(), this.getSeconds()), t2; if (time === null) { t2 = new Date(1970, 1, 1, 0, 0, 0); } else { t2 = new Date(1970, 1, 1, time.getHours(), time.getMinutes(), time.getSeconds()); } return (t1 < t2) ? -1 : (t1 > t2) ? 1 : 0; }; this.equals = function (time) { return (this.compareTo(time) === 0); }; this.add = function (time) { return (time === null) ? this : this.addSeconds(time.getTotalMilliseconds() / 1000); }; this.subtract = function (time) { return (time === null) ? this : this.addSeconds(-time.getTotalMilliseconds() / 1000); }; this.addDays = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 86400000)); }; this.addHours = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 3600000)); }; this.addMinutes = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 60000)); }; this.addSeconds = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 1000)); }; this.addMilliseconds = function (n) { return new TimeSpan(this.getTotalMilliseconds() + n); }; this.get12HourHour = function () { return (this.getHours() > 12) ? this.getHours() - 12 : (this.getHours() === 0) ? 12 : this.getHours(); }; this.getDesignator = function () { return (this.getHours() < 12) ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator; }; this.toString = function (format) { this._toString = function () { if (this.getDays() !== null && this.getDays() > 0) { return this.getDays() + "." + this.getHours() + ":" + this.p(this.getMinutes()) + ":" + this.p(this.getSeconds()); } else { return this.getHours() + ":" + this.p(this.getMinutes()) + ":" + this.p(this.getSeconds()); } }; this.p = function (s) { return (s.toString().length < 2) ? "0" + s : s; }; var me = this; return format ? format.replace(/dd?|HH?|hh?|mm?|ss?|tt?/g, function (format) { switch (format) { case "d": return me.getDays(); case "dd": return me.p(me.getDays()); case "H": return me.getHours(); case "HH": return me.p(me.getHours()); case "h": return me.get12HourHour(); case "hh": return me.p(me.get12HourHour()); case "m": return me.getMinutes(); case "mm": return me.p(me.getMinutes()); case "s": return me.getSeconds(); case "ss": return me.p(me.getSeconds()); case "t": return ((me.getHours() < 12) ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator).substring(0, 1); case "tt": return (me.getHours() < 12) ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator; } } ) : this._toString(); }; return this; }; addSetFuncs(TimeSpan, attrs.slice(2)); TimeSpan.prototype.set = function (days, hours, minutes, seconds, milliseconds){ this.setDays(days || this.getDays()); this.setHours(hours || this.getHours()); this.setMinutes(minutes || this.getMinutes()); this.setSeconds(seconds || this.getSeconds()); this.setMilliseconds(milliseconds || this.getMilliseconds()); }; /** * Gets the time of day for this date instances. * @return {TimeSpan} TimeSpan */ Date.prototype.getTimeOfDay = function () { return new TimeSpan(0, this.getHours(), this.getMinutes(), this.getSeconds(), this.getMilliseconds()); }; Date.TimeSpan = TimeSpan; if (typeof window !== "undefined" ) { // keeping API compatible for v1.x window.TimeSpan = TimeSpan; } }()); (function () { "use strict"; var attrs = ["years", "months", "days", "hours", "minutes", "seconds", "milliseconds"]; var gFn = function (attr) { return function () { return this[attr]; }; }; var sFn = function (attr) { return function (val) { this[attr] = val; return this; }; }; var addSetFuncs = function (context, attrs) { for (var i = 0; i < attrs.length ; i++) { var $a = attrs[i], $b = $a.slice(0, 1).toUpperCase() + $a.slice(1); context.prototype[$a] = 0; context.prototype["get" + $b] = gFn($a); context.prototype["set" + $b] = sFn($a); } }; var setMonthsAndYears = function (orient, d1, d2, context) { function inc() { d1.addMonths(-orient); context.months++; if (context.months === 12) { context.years++; context.months = 0; } } if (orient === +1) { while (d1 > d2) { inc(); } } else { while (d1 < d2) { inc(); } } context.months--; context.months *= orient; context.years *= orient; }; var adjustForDST = function(orient, startDate, endDate) { var hasDSTMismatch = (false === (startDate.isDaylightSavingTime() === endDate.isDaylightSavingTime())); if (hasDSTMismatch && orient === 1) { startDate.addHours(-1); } else if (hasDSTMismatch) { startDate.addHours(1); } }; /** * TimePeriod(startDate, endDate); * TimePeriod(years, months, days, hours, minutes, seconds, milliseconds); */ var TimePeriod = function (years, months, days, hours, minutes, seconds, milliseconds) { if (arguments.length === 7) { this.set(years, months, days, hours, minutes, seconds, milliseconds); } else if (arguments.length === 2 && arguments[0] instanceof Date && arguments[1] instanceof Date) { var startDate = arguments[0].clone(); var endDate = arguments[1].clone(); var orient = (startDate > endDate) ? +1 : -1; this.dates = { start: arguments[0].clone(), end: arguments[1].clone() }; setMonthsAndYears(orient, startDate, endDate, this); adjustForDST(orient, startDate, endDate); // // TODO - adjust for DST var diff = endDate - startDate; if (diff !== 0) { var ts = new TimeSpan(diff); this.set(this.years, this.months, ts.getDays(), ts.getHours(), ts.getMinutes(), ts.getSeconds(), ts.getMilliseconds()); } } return this; }; // create all the set functions. addSetFuncs(TimePeriod, attrs); TimePeriod.prototype.set = function (years, months, days, hours, minutes, seconds, milliseconds){ this.setYears(years || this.getYears()); this.setMonths(months || this.getMonths()); this.setDays(days || this.getDays()); this.setHours(hours || this.getHours()); this.setMinutes(minutes || this.getMinutes()); this.setSeconds(seconds || this.getSeconds()); this.setMilliseconds(milliseconds || this.getMilliseconds()); }; Date.TimePeriod = TimePeriod; if (typeof window !== "undefined") { // keeping API compatible for v1.x window.TimePeriod = TimePeriod; } }()); ================================================ FILE: build/date-ms-BN.js ================================================ /** * @overview datejs * @version 1.0.0-rc3 * @author Gregory Wild-Smith * @copyright 2015 Gregory Wild-Smith * @license MIT * @homepage https://github.com/abritinthebay/datejs */ /* * DateJS Culture String File * Country Code: ms-BN * Name: Malay (Brunei Darussalam) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["ms-BN"] = { "name": "ms-BN", "englishName": "Malay (Brunei Darussalam)", "nativeName": "Bahasa Malaysia (Brunei Darussalam)", "Sunday": "Ahad", "Monday": "Isnin", "Tuesday": "Selasa", "Wednesday": "Rabu", "Thursday": "Khamis", "Friday": "Jumaat", "Saturday": "Sabtu", "Sun": "Ahad", "Mon": "Isnin", "Tue": "Sel", "Wed": "Rabu", "Thu": "Khamis", "Fri": "Jumaat", "Sat": "Sabtu", "Su": "A", "Mo": "I", "Tu": "S", "We": "R", "Th": "K", "Fr": "J", "Sa": "S", "S_Sun_Initial": "A", "M_Mon_Initial": "I", "T_Tue_Initial": "S", "W_Wed_Initial": "R", "T_Thu_Initial": "K", "F_Fri_Initial": "J", "S_Sat_Initial": "S", "January": "Januari", "February": "Februari", "March": "Mac", "April": "April", "May": "Mei", "June": "Jun", "July": "Julai", "August": "Ogos", "September": "September", "October": "Oktober", "November": "November", "December": "Disember", "Jan_Abbr": "Jan", "Feb_Abbr": "Feb", "Mar_Abbr": "Mac", "Apr_Abbr": "Apr", "May_Abbr": "Mei", "Jun_Abbr": "Jun", "Jul_Abbr": "Jul", "Aug_Abbr": "Ogos", "Sep_Abbr": "Sept", "Oct_Abbr": "Okt", "Nov_Abbr": "Nov", "Dec_Abbr": "Dis", "AM": "", "PM": "", "firstDayOfWeek": 1, "twoDigitYearMax": 2029, "mdy": "dmy", "M/d/yyyy": "dd/MM/yyyy", "dddd, MMMM dd, yyyy": "dd MMMM yyyy", "h:mm tt": "H:mm", "h:mm:ss tt": "H:mm:ss", "dddd, MMMM dd, yyyy h:mm:ss tt": "dd MMMM yyyy H:mm:ss", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "dd MMMM", "MMMM, yyyy": "MMMM yyyy", "/jan(uary)?/": "jan(uari)?", "/feb(ruary)?/": "feb(ruari)?", "/mar(ch)?/": "mac", "/apr(il)?/": "apr(il)?", "/may/": "mei", "/jun(e)?/": "jun", "/jul(y)?/": "jul(ai)?", "/aug(ust)?/": "ogos", "/sep(t(ember)?)?/": "sep(t(ember)?)?", "/oct(ober)?/": "okt(ober)?", "/nov(ember)?/": "nov(ember)?", "/dec(ember)?/": "dis(ember)?", "/^su(n(day)?)?/": "^a(1)?", "/^mo(n(day)?)?/": "^i(1)?", "/^tu(e(s(day)?)?)?/": "^s(el(asa)?)?", "/^we(d(nesday)?)?/": "^r(1)?", "/^th(u(r(s(day)?)?)?)?/": "^k(1)?", "/^fr(i(day)?)?/": "^j(1)?", "/^sa(t(urday)?)?/": "^s(1)?", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "ms-BN"; /** * @overview datejs * @version 1.0.0-rc3 * @author Gregory Wild-Smith * @copyright 2015 Gregory Wild-Smith * @license MIT * @homepage https://github.com/abritinthebay/datejs */(function () { var $D = Date; var lang = Date.CultureStrings ? Date.CultureStrings.lang : null; var loggedKeys = {}; // for debug purposes. var getText = { getFromKey: function (key, countryCode) { var output; if (Date.CultureStrings && Date.CultureStrings[countryCode] && Date.CultureStrings[countryCode][key]) { output = Date.CultureStrings[countryCode][key]; } else { output = getText.buildFromDefault(key); } if (key.charAt(0) === "/") { // Assume it's a regex output = getText.buildFromRegex(key, countryCode); } return output; }, getFromObjectValues: function (obj, countryCode) { var key, output = {}; for(key in obj) { if (obj.hasOwnProperty(key)) { output[key] = getText.getFromKey(obj[key], countryCode); } } return output; }, getFromObjectKeys: function (obj, countryCode) { var key, output = {}; for(key in obj) { if (obj.hasOwnProperty(key)) { output[getText.getFromKey(key, countryCode)] = obj[key]; } } return output; }, getFromArray: function (arr, countryCode) { var output = []; for (var i=0; i < arr.length; i++){ if (i in arr) { output[i] = getText.getFromKey(arr[i], countryCode); } } return output; }, buildFromDefault: function (key) { var output, length, split, last; switch(key) { case "name": output = "en-US"; break; case "englishName": output = "English (United States)"; break; case "nativeName": output = "English (United States)"; break; case "twoDigitYearMax": output = 2049; break; case "firstDayOfWeek": output = 0; break; default: output = key; split = key.split("_"); length = split.length; if (length > 1 && key.charAt(0) !== "/") { // if the key isn't a regex and it has a split. last = split[(length - 1)].toLowerCase(); if (last === "initial" || last === "abbr") { output = split[0]; } } break; } return output; }, buildFromRegex: function (key, countryCode) { var output; if (Date.CultureStrings && Date.CultureStrings[countryCode] && Date.CultureStrings[countryCode][key]) { output = new RegExp(Date.CultureStrings[countryCode][key], "i"); } else { output = new RegExp(key.replace(new RegExp("/", "g"),""), "i"); } return output; } }; var shallowMerge = function (obj1, obj2) { for (var attrname in obj2) { if (obj2.hasOwnProperty(attrname)) { obj1[attrname] = obj2[attrname]; } } }; var __ = function (key, language) { var countryCode = (language) ? language : lang; loggedKeys[key] = key; if (typeof key === "object") { if (key instanceof Array) { return getText.getFromArray(key, countryCode); } else { return getText.getFromObjectKeys(key, countryCode); } } else { return getText.getFromKey(key, countryCode); } }; var loadI18nScript = function (code) { // paatterned after jQuery's getScript. var url = Date.Config.i18n + code + ".js"; var head = document.getElementsByTagName("head")[0] || document.documentElement; var script = document.createElement("script"); script.src = url; var completed = false; var events = { done: function (){} // placeholder function }; // Attach handlers for all browsers script.onload = script.onreadystatechange = function() { if ( !completed && (!this.readyState || this.readyState === "loaded" || this.readyState === "complete") ) { events.done(); head.removeChild(script); } }; setTimeout(function() { head.insertBefore(script, head.firstChild); }, 0); // allows return to execute first return { done: function (cb) { events.done = function() { if (cb) { setTimeout(cb,0); } }; } }; }; var buildInfo = { buildFromMethodHash: function (obj) { var key; for(key in obj) { if (obj.hasOwnProperty(key)) { obj[key] = buildInfo[obj[key]](); } } return obj; }, timeZoneDST: function () { var DST = { "CHADT": "+1345", "NZDT": "+1300", "AEDT": "+1100", "ACDT": "+1030", "AZST": "+0500", "IRDT": "+0430", "EEST": "+0300", "CEST": "+0200", "BST": "+0100", "PMDT": "-0200", "ADT": "-0300", "NDT": "-0230", "EDT": "-0400", "CDT": "-0500", "MDT": "-0600", "PDT": "-0700", "AKDT": "-0800", "HADT": "-0900" }; return __(DST); }, timeZoneStandard: function () { var standard = { "LINT": "+1400", "TOT": "+1300", "CHAST": "+1245", "NZST": "+1200", "NFT": "+1130", "SBT": "+1100", "AEST": "+1000", "ACST": "+0930", "JST": "+0900", "CWST": "+0845", "CT": "+0800", "ICT": "+0700", "MMT": "+0630", "BST": "+0600", "NPT": "+0545", "IST": "+0530", "PKT": "+0500", "AFT": "+0430", "MSK": "+0400", "IRST": "+0330", "FET": "+0300", "EET": "+0200", "CET": "+0100", "GMT": "+0000", "UTC": "+0000", "CVT": "-0100", "GST": "-0200", "BRT": "-0300", "NST": "-0330", "AST": "-0400", "EST": "-0500", "CST": "-0600", "MST": "-0700", "PST": "-0800", "AKST": "-0900", "MIT": "-0930", "HST": "-1000", "SST": "-1100", "BIT": "-1200" }; return __(standard); }, timeZones: function (data) { var zone; data.timezones = []; for (zone in data.abbreviatedTimeZoneStandard) { if (data.abbreviatedTimeZoneStandard.hasOwnProperty(zone)) { data.timezones.push({ name: zone, offset: data.abbreviatedTimeZoneStandard[zone]}); } } for (zone in data.abbreviatedTimeZoneDST) { if (data.abbreviatedTimeZoneDST.hasOwnProperty(zone)) { data.timezones.push({ name: zone, offset: data.abbreviatedTimeZoneDST[zone], dst: true}); } } return data.timezones; }, days: function () { return __(["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"]); }, dayAbbr: function () { return __(["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"]); }, dayShortNames: function () { return __(["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"]); }, dayFirstLetters: function () { return __(["S_Sun_Initial", "M_Mon_Initial", "T_Tues_Initial", "W_Wed_Initial", "T_Thu_Initial", "F_Fri_Initial", "S_Sat_Initial"]); }, months: function () { return __(["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"]); }, monthAbbr: function () { return __(["Jan_Abbr", "Feb_Abbr", "Mar_Abbr", "Apr_Abbr", "May_Abbr", "Jun_Abbr", "Jul_Abbr", "Aug_Abbr", "Sep_Abbr", "Oct_Abbr", "Nov_Abbr", "Dec_Abbr"]); }, formatPatterns: function () { return getText.getFromObjectValues({ shortDate: "M/d/yyyy", longDate: "dddd, MMMM dd, yyyy", shortTime: "h:mm tt", longTime: "h:mm:ss tt", fullDateTime: "dddd, MMMM dd, yyyy h:mm:ss tt", sortableDateTime: "yyyy-MM-ddTHH:mm:ss", universalSortableDateTime: "yyyy-MM-dd HH:mm:ssZ", rfc1123: "ddd, dd MMM yyyy HH:mm:ss", monthDay: "MMMM dd", yearMonth: "MMMM, yyyy" }, Date.i18n.currentLanguage()); }, regex: function () { return getText.getFromObjectValues({ inTheMorning: "/( in the )(morn(ing)?)\\b/", thisMorning: "/(this )(morn(ing)?)\\b/", amThisMorning: "/(\b\\d(am)? )(this )(morn(ing)?)/", inTheEvening: "/( in the )(even(ing)?)\\b/", thisEvening: "/(this )(even(ing)?)\\b/", pmThisEvening: "/(\b\\d(pm)? )(this )(even(ing)?)/", jan: "/jan(uary)?/", feb: "/feb(ruary)?/", mar: "/mar(ch)?/", apr: "/apr(il)?/", may: "/may/", jun: "/jun(e)?/", jul: "/jul(y)?/", aug: "/aug(ust)?/", sep: "/sep(t(ember)?)?/", oct: "/oct(ober)?/", nov: "/nov(ember)?/", dec: "/dec(ember)?/", sun: "/^su(n(day)?)?/", mon: "/^mo(n(day)?)?/", tue: "/^tu(e(s(day)?)?)?/", wed: "/^we(d(nesday)?)?/", thu: "/^th(u(r(s(day)?)?)?)?/", fri: "/fr(i(day)?)?/", sat: "/^sa(t(urday)?)?/", future: "/^next/", past: "/^last|past|prev(ious)?/", add: "/^(\\+|aft(er)?|from|hence)/", subtract: "/^(\\-|bef(ore)?|ago)/", yesterday: "/^yes(terday)?/", today: "/^t(od(ay)?)?/", tomorrow: "/^tom(orrow)?/", now: "/^n(ow)?/", millisecond: "/^ms|milli(second)?s?/", second: "/^sec(ond)?s?/", minute: "/^mn|min(ute)?s?/", hour: "/^h(our)?s?/", week: "/^w(eek)?s?/", month: "/^m(onth)?s?/", day: "/^d(ay)?s?/", year: "/^y(ear)?s?/", shortMeridian: "/^(a|p)/", longMeridian: "/^(a\\.?m?\\.?|p\\.?m?\\.?)/", timezone: "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/", ordinalSuffix: "/^\\s*(st|nd|rd|th)/", timeContext: "/^\\s*(\\:|a(?!u|p)|p)/" }, Date.i18n.currentLanguage()); } }; var CultureInfo = function () { var info = getText.getFromObjectValues({ name: "name", englishName: "englishName", nativeName: "nativeName", amDesignator: "AM", pmDesignator: "PM", firstDayOfWeek: "firstDayOfWeek", twoDigitYearMax: "twoDigitYearMax", dateElementOrder: "mdy" }, Date.i18n.currentLanguage()); var constructedInfo = buildInfo.buildFromMethodHash({ dayNames: "days", abbreviatedDayNames: "dayAbbr", shortestDayNames: "dayShortNames", firstLetterDayNames: "dayFirstLetters", monthNames: "months", abbreviatedMonthNames: "monthAbbr", formatPatterns: "formatPatterns", regexPatterns: "regex", abbreviatedTimeZoneDST: "timeZoneDST", abbreviatedTimeZoneStandard: "timeZoneStandard" }); shallowMerge(info, constructedInfo); buildInfo.timeZones(info); return info; }; $D.i18n = { __: function (key, lang) { return __(key, lang); }, currentLanguage: function () { return lang || "en-US"; }, setLanguage: function (code, force, cb) { var async = false; if (force || code === "en-US" || (!!Date.CultureStrings && !!Date.CultureStrings[code])) { lang = code; Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings.lang = code; Date.CultureInfo = new CultureInfo(); } else { if (!(!!Date.CultureStrings && !!Date.CultureStrings[code])) { if (typeof exports !== "undefined" && this.exports !== exports) { // we're in a Node enviroment, load it using require try { require("../i18n/" + code + ".js"); lang = code; Date.CultureStrings.lang = code; Date.CultureInfo = new CultureInfo(); } catch (e) { // var str = "The language for '" + code + "' could not be loaded by Node. It likely does not exist."; throw new Error("The DateJS IETF language tag '" + code + "' could not be loaded by Node. It likely does not exist."); } } else if (Date.Config && Date.Config.i18n) { // we know the location of the files, so lets load them async = true; loadI18nScript(code).done(function(){ lang = code; Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings.lang = code; Date.CultureInfo = new CultureInfo(); $D.Parsing.Normalizer.buildReplaceData(); // because this is async if ($D.Grammar) { $D.Grammar.buildGrammarFormats(); // so we can parse those strings... } if (cb) { setTimeout(cb,0); } }); } else { Date.console.error("The DateJS IETF language tag '" + code + "' is not available and has not been loaded."); return false; } } } $D.Parsing.Normalizer.buildReplaceData(); // rebuild normalizer strings if ($D.Grammar) { $D.Grammar.buildGrammarFormats(); // so we can parse those strings... } if (!async && cb) { setTimeout(cb,0); } }, getLoggedKeys: function () { return loggedKeys; }, updateCultureInfo: function () { Date.CultureInfo = new CultureInfo(); } }; $D.i18n.updateCultureInfo(); // run automatically }()); (function () { var $D = Date, $P = $D.prototype, p = function (s, l) { if (!l) { l = 2; } return ("000" + s).slice(l * -1); }; if (typeof window !== "undefined" && typeof window.console !== "undefined" && typeof window.console.log !== "undefined") { $D.console = console; // used only to raise non-critical errors if available } else { // set mock so we don't give errors. $D.console = { log: function(){}, error: function(){} }; } $D.Config = $D.Config || {}; $D.initOverloads = function() { /** * Overload of Date.now. Allows an alternate call for Date.now where it returns the * current Date as an object rather than just milliseconds since the Unix Epoch. * * Also provides an implementation of now() for browsers (IE<9) that don't have it. * * Backwards compatible so with work with either: * Date.now() [returns ms] * or * Date.now(true) [returns Date] */ if (!$D.now) { $D._now = function now() { return new Date().getTime(); }; } else if (!$D._now) { $D._now = $D.now; } $D.now = function (returnObj) { if (returnObj) { return $D.present(); } else { return $D._now(); } }; if ( !$P.toISOString ) { $P.toISOString = function() { return this.getUTCFullYear() + "-" + p(this.getUTCMonth() + 1) + "-" + p(this.getUTCDate()) + "T" + p(this.getUTCHours()) + ":" + p(this.getUTCMinutes()) + ":" + p(this.getUTCSeconds()) + "." + String( (this.getUTCMilliseconds()/1000).toFixed(3)).slice(2, 5) + "Z"; }; } // private if ( $P._toString === undefined ){ $P._toString = $P.toString; } }; $D.initOverloads(); /** * Gets a date that is set to the current date. The time is set to the start of the day (00:00 or 12:00 AM). * @return {Date} The current date. */ $D.today = function () { return new Date().clearTime(); }; /** * Gets a date that is set to the current date and time (same as new Date, but chainable) * @return {Date} The current date. */ $D.present = function () { return new Date(); }; /** * Compares the first date to the second date and returns an number indication of their relative values. * @param {Date} First Date object to compare [Required]. * @param {Date} Second Date object to compare to [Required]. * @return {Number} -1 = date1 is lessthan date2. 0 = values are equal. 1 = date1 is greaterthan date2. */ $D.compare = function (date1, date2) { if (isNaN(date1) || isNaN(date2)) { throw new Error(date1 + " - " + date2); } else if (date1 instanceof Date && date2 instanceof Date) { return (date1 < date2) ? -1 : (date1 > date2) ? 1 : 0; } else { throw new TypeError(date1 + " - " + date2); } }; /** * Compares the first Date object to the second Date object and returns true if they are equal. * @param {Date} First Date object to compare [Required] * @param {Date} Second Date object to compare to [Required] * @return {Boolean} true if dates are equal. false if they are not equal. */ $D.equals = function (date1, date2) { return (date1.compareTo(date2) === 0); }; /** * Gets the language appropriate day name when given the day number(0-6) * eg - 0 == Sunday * @return {String} The day name */ $D.getDayName = function (n) { return Date.CultureInfo.dayNames[n]; }; /** * Gets the day number (0-6) if given a CultureInfo specific string which is a valid dayName, abbreviatedDayName or shortestDayName (two char). * @param {String} The name of the day (eg. "Monday, "Mon", "tuesday", "tue", "We", "we"). * @return {Number} The day number */ $D.getDayNumberFromName = function (name) { var n = Date.CultureInfo.dayNames, m = Date.CultureInfo.abbreviatedDayNames, o = Date.CultureInfo.shortestDayNames, s = name.toLowerCase(); for (var i = 0; i < n.length; i++) { if (n[i].toLowerCase() === s || m[i].toLowerCase() === s || o[i].toLowerCase() === s) { return i; } } return -1; }; /** * Gets the month number (0-11) if given a Culture Info specific string which is a valid monthName or abbreviatedMonthName. * @param {String} The name of the month (eg. "February, "Feb", "october", "oct"). * @return {Number} The day number */ $D.getMonthNumberFromName = function (name) { var n = Date.CultureInfo.monthNames, m = Date.CultureInfo.abbreviatedMonthNames, s = name.toLowerCase(); for (var i = 0; i < n.length; i++) { if (n[i].toLowerCase() === s || m[i].toLowerCase() === s) { return i; } } return -1; }; /** * Gets the language appropriate month name when given the month number(0-11) * eg - 0 == January * @return {String} The month name */ $D.getMonthName = function (n) { return Date.CultureInfo.monthNames[n]; }; /** * Determines if the current date instance is within a LeapYear. * @param {Number} The year. * @return {Boolean} true if date is within a LeapYear, otherwise false. */ $D.isLeapYear = function (year) { return ((year % 4 === 0 && year % 100 !== 0) || year % 400 === 0); }; /** * Gets the number of days in the month, given a year and month value. Automatically corrects for LeapYear. * @param {Number} The year. * @param {Number} The month (0-11). * @return {Number} The number of days in the month. */ $D.getDaysInMonth = function (year, month) { if (!month && $D.validateMonth(year)) { month = year; year = Date.today().getFullYear(); } return [31, ($D.isLeapYear(year) ? 29 : 28), 31, 30, 31, 30, 31, 31, 30, 31, 30, 31][month]; }; $P.getDaysInMonth = function () { return $D.getDaysInMonth(this.getFullYear(), this.getMonth()); }; $D.getTimezoneAbbreviation = function (offset, dst) { var p, n = (dst || false) ? Date.CultureInfo.abbreviatedTimeZoneDST : Date.CultureInfo.abbreviatedTimeZoneStandard; for (p in n) { if (n.hasOwnProperty(p)) { if (n[p] === offset) { return p; } } } return null; }; $D.getTimezoneOffset = function (name, dst) { var i, a =[], z = Date.CultureInfo.timezones; if (!name) { name = (new Date()).getTimezone();} for (i = 0; i < z.length; i++) { if (z[i].name === name.toUpperCase()) { a.push(i); } } if (!z[a[0]]) { return null; } if (a.length === 1 || !dst) { return z[a[0]].offset; } else { for (i=0; i < a.length; i++) { if (z[a[i]].dst) { return z[a[i]].offset; } } } }; $D.getQuarter = function (d) { d = d || new Date(); // If no date supplied, use today var q = [1,2,3,4]; return q[Math.floor(d.getMonth() / 3)]; // ~~~ is a bitwise op. Faster than Math.floor }; $D.getDaysLeftInQuarter = function (d) { d = d || new Date(); var qEnd = new Date(d); qEnd.setMonth(qEnd.getMonth() + 3 - qEnd.getMonth() % 3, 0); return Math.floor((qEnd - d) / 8.64e7); }; // private var validate = function (n, min, max, name) { name = name ? name : "Object"; if (typeof n === "undefined") { return false; } else if (typeof n !== "number") { throw new TypeError(n + " is not a Number."); } else if (n < min || n > max) { // As failing validation is *not* an exceptional circumstance // lets not throw a RangeError Exception here. // It's semantically correct but it's not sensible. return false; } return true; }; /** * Validates the number is within an acceptable range for milliseconds [0-999]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateMillisecond = function (value) { return validate(value, 0, 999, "millisecond"); }; /** * Validates the number is within an acceptable range for seconds [0-59]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateSecond = function (value) { return validate(value, 0, 59, "second"); }; /** * Validates the number is within an acceptable range for minutes [0-59]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateMinute = function (value) { return validate(value, 0, 59, "minute"); }; /** * Validates the number is within an acceptable range for hours [0-23]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateHour = function (value) { return validate(value, 0, 23, "hour"); }; /** * Validates the number is within an acceptable range for the days in a month [0-MaxDaysInMonth]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateDay = function (value, year, month) { if (year === undefined || year === null || month === undefined || month === null) { return false;} return validate(value, 1, $D.getDaysInMonth(year, month), "day"); }; /** * Validates the number is within an acceptable range for months [0-11]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateWeek = function (value) { return validate(value, 0, 53, "week"); }; /** * Validates the number is within an acceptable range for months [0-11]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateMonth = function (value) { return validate(value, 0, 11, "month"); }; /** * Validates the number is within an acceptable range for years. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateYear = function (value) { /** * Per ECMAScript spec the range of times supported by Date objects is * exactly -100,000,000 days to +100,000,000 days measured relative to * midnight at the beginning of 01 January, 1970 UTC. * This gives a range of 8,640,000,000,000,000 milliseconds to either * side of 01 January, 1970 UTC. * * Earliest possible date: Tue, 20 Apr 271,822 B.C. 00:00:00 UTC * Latest possible date: Sat, 13 Sep 275,760 00:00:00 UTC */ return validate(value, -271822, 275760, "year"); }; $D.validateTimezone = function(value) { var timezones = {"ACDT":1,"ACST":1,"ACT":1,"ADT":1,"AEDT":1,"AEST":1,"AFT":1,"AKDT":1,"AKST":1,"AMST":1,"AMT":1,"ART":1,"AST":1,"AWDT":1,"AWST":1,"AZOST":1,"AZT":1,"BDT":1,"BIOT":1,"BIT":1,"BOT":1,"BRT":1,"BST":1,"BTT":1,"CAT":1,"CCT":1,"CDT":1,"CEDT":1,"CEST":1,"CET":1,"CHADT":1,"CHAST":1,"CHOT":1,"ChST":1,"CHUT":1,"CIST":1,"CIT":1,"CKT":1,"CLST":1,"CLT":1,"COST":1,"COT":1,"CST":1,"CT":1,"CVT":1,"CWST":1,"CXT":1,"DAVT":1,"DDUT":1,"DFT":1,"EASST":1,"EAST":1,"EAT":1,"ECT":1,"EDT":1,"EEDT":1,"EEST":1,"EET":1,"EGST":1,"EGT":1,"EIT":1,"EST":1,"FET":1,"FJT":1,"FKST":1,"FKT":1,"FNT":1,"GALT":1,"GAMT":1,"GET":1,"GFT":1,"GILT":1,"GIT":1,"GMT":1,"GST":1,"GYT":1,"HADT":1,"HAEC":1,"HAST":1,"HKT":1,"HMT":1,"HOVT":1,"HST":1,"ICT":1,"IDT":1,"IOT":1,"IRDT":1,"IRKT":1,"IRST":1,"IST":1,"JST":1,"KGT":1,"KOST":1,"KRAT":1,"KST":1,"LHST":1,"LINT":1,"MAGT":1,"MART":1,"MAWT":1,"MDT":1,"MET":1,"MEST":1,"MHT":1,"MIST":1,"MIT":1,"MMT":1,"MSK":1,"MST":1,"MUT":1,"MVT":1,"MYT":1,"NCT":1,"NDT":1,"NFT":1,"NPT":1,"NST":1,"NT":1,"NUT":1,"NZDT":1,"NZST":1,"OMST":1,"ORAT":1,"PDT":1,"PET":1,"PETT":1,"PGT":1,"PHOT":1,"PHT":1,"PKT":1,"PMDT":1,"PMST":1,"PONT":1,"PST":1,"PYST":1,"PYT":1,"RET":1,"ROTT":1,"SAKT":1,"SAMT":1,"SAST":1,"SBT":1,"SCT":1,"SGT":1,"SLST":1,"SRT":1,"SST":1,"SYOT":1,"TAHT":1,"THA":1,"TFT":1,"TJT":1,"TKT":1,"TLT":1,"TMT":1,"TOT":1,"TVT":1,"UCT":1,"ULAT":1,"UTC":1,"UYST":1,"UYT":1,"UZT":1,"VET":1,"VLAT":1,"VOLT":1,"VOST":1,"VUT":1,"WAKT":1,"WAST":1,"WAT":1,"WEDT":1,"WEST":1,"WET":1,"WST":1,"YAKT":1,"YEKT":1,"Z":1}; return (timezones[value] === 1); }; $D.validateTimezoneOffset= function(value) { // timezones go from +14hrs to -12hrs, the +X hours are negative offsets. return (value > -841 && value < 721); }; }()); (function () { var $D = Date, $P = $D.prototype, p = function (s, l) { if (!l) { l = 2; } return ("000" + s).slice(l * -1); }; var validateConfigObject = function (obj) { var result = {}, self = this, prop, testFunc; testFunc = function (prop, func, value) { if (prop === "day") { var month = (obj.month !== undefined) ? obj.month : self.getMonth(); var year = (obj.year !== undefined) ? obj.year : self.getFullYear(); return $D[func](value, year, month); } else { return $D[func](value); } }; for (prop in obj) { if (Object.prototype.hasOwnProperty.call(obj, prop)) { var func = "validate" + prop.charAt(0).toUpperCase() + prop.slice(1); if ($D[func] && obj[prop] !== null && testFunc(prop, func, obj[prop])) { result[prop] = obj[prop]; } } } return result; }; /** * Resets the time of this Date object to 12:00 AM (00:00), which is the start of the day. * @param {Boolean} .clone() this date instance before clearing Time * @return {Date} this */ $P.clearTime = function () { this.setHours(0); this.setMinutes(0); this.setSeconds(0); this.setMilliseconds(0); return this; }; /** * Resets the time of this Date object to the current time ('now'). * @return {Date} this */ $P.setTimeToNow = function () { var n = new Date(); this.setHours(n.getHours()); this.setMinutes(n.getMinutes()); this.setSeconds(n.getSeconds()); this.setMilliseconds(n.getMilliseconds()); return this; }; /** * Returns a new Date object that is an exact date and time copy of the original instance. * @return {Date} A new Date instance */ $P.clone = function () { return new Date(this.getTime()); }; /** * Compares this instance to a Date object and returns an number indication of their relative values. * @param {Date} Date object to compare [Required] * @return {Number} -1 = this is lessthan date. 0 = values are equal. 1 = this is greaterthan date. */ $P.compareTo = function (date) { return Date.compare(this, date); }; /** * Compares this instance to another Date object and returns true if they are equal. * @param {Date} Date object to compare. If no date to compare, new Date() [now] is used. * @return {Boolean} true if dates are equal. false if they are not equal. */ $P.equals = function (date) { return Date.equals(this, (date !== undefined ? date : new Date())); }; /** * Determines if this instance is between a range of two dates or equal to either the start or end dates. * @param {Date} Start of range [Required] * @param {Date} End of range [Required] * @return {Boolean} true is this is between or equal to the start and end dates, else false */ $P.between = function (start, end) { return this.getTime() >= start.getTime() && this.getTime() <= end.getTime(); }; /** * Determines if this date occurs after the date to compare to. * @param {Date} Date object to compare. If no date to compare, new Date() ("now") is used. * @return {Boolean} true if this date instance is greater than the date to compare to (or "now"), otherwise false. */ $P.isAfter = function (date) { return this.compareTo(date || new Date()) === 1; }; /** * Determines if this date occurs before the date to compare to. * @param {Date} Date object to compare. If no date to compare, new Date() ("now") is used. * @return {Boolean} true if this date instance is less than the date to compare to (or "now"). */ $P.isBefore = function (date) { return (this.compareTo(date || new Date()) === -1); }; /** * Determines if the current Date instance occurs today. * @return {Boolean} true if this date instance is 'today', otherwise false. */ /** * Determines if the current Date instance occurs on the same Date as the supplied 'date'. * If no 'date' to compare to is provided, the current Date instance is compared to 'today'. * @param {date} Date object to compare. If no date to compare, the current Date ("now") is used. * @return {Boolean} true if this Date instance occurs on the same Day as the supplied 'date'. */ $P.isToday = $P.isSameDay = function (date) { return this.clone().clearTime().equals((date || new Date()).clone().clearTime()); }; /** * Adds the specified number of milliseconds to this instance. * @param {Number} The number of milliseconds to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addMilliseconds = function (value) { if (!value) { return this; } this.setTime(this.getTime() + value * 1); return this; }; /** * Adds the specified number of seconds to this instance. * @param {Number} The number of seconds to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addSeconds = function (value) { if (!value) { return this; } return this.addMilliseconds(value * 1000); }; /** * Adds the specified number of seconds to this instance. * @param {Number} The number of seconds to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addMinutes = function (value) { if (!value) { return this; } return this.addMilliseconds(value * 60000); // 60*1000 }; /** * Adds the specified number of hours to this instance. * @param {Number} The number of hours to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addHours = function (value) { if (!value) { return this; } return this.addMilliseconds(value * 3600000); // 60*60*1000 }; /** * Adds the specified number of days to this instance. * @param {Number} The number of days to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addDays = function (value) { if (!value) { return this; } this.setDate(this.getDate() + value * 1); return this; }; /** * Adds the specified number of weekdays (ie - not sat or sun) to this instance. * @param {Number} The number of days to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addWeekdays = function (value) { if (!value) { return this; } var day = this.getDay(); var weeks = (Math.ceil(Math.abs(value)/7)); if (day === 0 || day === 6) { if (value > 0) { this.next().monday(); this.addDays(-1); day = this.getDay(); } } if (value < 0) { while (value < 0) { this.addDays(-1); day = this.getDay(); if (day !== 0 && day !== 6) { value++; } } return this; } else if (value > 5 || (6-day) <= value) { value = value + (weeks * 2); } return this.addDays(value); }; /** * Adds the specified number of weeks to this instance. * @param {Number} The number of weeks to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addWeeks = function (value) { if (!value) { return this; } return this.addDays(value * 7); }; /** * Adds the specified number of months to this instance. * @param {Number} The number of months to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addMonths = function (value) { if (!value) { return this; } var n = this.getDate(); this.setDate(1); this.setMonth(this.getMonth() + value * 1); this.setDate(Math.min(n, $D.getDaysInMonth(this.getFullYear(), this.getMonth()))); return this; }; $P.addQuarters = function (value) { if (!value) { return this; } // note this will take you to the same point in the quarter as you are now. // i.e. - if you are 15 days into the quarter you'll be 15 days into the resulting one. // bonus: this allows adding fractional quarters return this.addMonths(value * 3); }; /** * Adds the specified number of years to this instance. * @param {Number} The number of years to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addYears = function (value) { if (!value) { return this; } return this.addMonths(value * 12); }; /** * Adds (or subtracts) to the value of the years, months, weeks, days, hours, minutes, seconds, milliseconds of the date instance using given configuration object. Positive and Negative values allowed. * Example

	Date.today().add( { days: 1, months: 1 } )

	new Date().add( { years: -1 } )
	
* @param {Object} Configuration object containing attributes (months, days, etc.) * @return {Date} this */ $P.add = function (config) { if (typeof config === "number") { this._orient = config; return this; } var x = config; if (x.day) { // If we should be a different date than today (eg: for 'tomorrow -1d', etc). // Should only effect parsing, not direct usage (eg, Finish and FinishExact) if ((x.day - this.getDate()) !== 0) { this.setDate(x.day); } } if (x.milliseconds) { this.addMilliseconds(x.milliseconds); } if (x.seconds) { this.addSeconds(x.seconds); } if (x.minutes) { this.addMinutes(x.minutes); } if (x.hours) { this.addHours(x.hours); } if (x.weeks) { this.addWeeks(x.weeks); } if (x.months) { this.addMonths(x.months); } if (x.years) { this.addYears(x.years); } if (x.days) { this.addDays(x.days); } return this; }; /** * Get the week number. Week one (1) is the week which contains the first Thursday of the year. Monday is considered the first day of the week. * The .getWeek() function does NOT convert the date to UTC. The local datetime is used. * Please use .getISOWeek() to get the week of the UTC converted date. * @return {Number} 1 to 53 */ $P.getWeek = function (utc) { // Create a copy of this date object var self, target = new Date(this.valueOf()); if (utc) { target.addMinutes(target.getTimezoneOffset()); self = target.clone(); } else { self = this; } // ISO week date weeks start on monday // so correct the day number var dayNr = (self.getDay() + 6) % 7; // ISO 8601 states that week 1 is the week // with the first thursday of that year. // Set the target date to the thursday in the target week target.setDate(target.getDate() - dayNr + 3); // Store the millisecond value of the target date var firstThursday = target.valueOf(); // Set the target to the first thursday of the year // First set the target to january first target.setMonth(0, 1); // Not a thursday? Correct the date to the next thursday if (target.getDay() !== 4) { target.setMonth(0, 1 + ((4 - target.getDay()) + 7) % 7); } // The weeknumber is the number of weeks between the // first thursday of the year and the thursday in the target week return 1 + Math.ceil((firstThursday - target) / 604800000); // 604800000 = 7 * 24 * 3600 * 1000 }; /** * Get the ISO 8601 week number. Week one ("01") is the week which contains the first Thursday of the year. Monday is considered the first day of the week. * The .getISOWeek() function does convert the date to it's UTC value. Please use .getWeek() to get the week of the local date. * @return {String} "01" to "53" */ $P.getISOWeek = function () { return p(this.getWeek(true)); }; /** * Moves the date to Monday of the week set. Week one (1) is the week which contains the first Thursday of the year. * @param {Number} A Number (1 to 53) that represents the week of the year. * @return {Date} this */ $P.setWeek = function (n) { if ((n - this.getWeek()) === 0) { if (this.getDay() !== 1) { return this.moveToDayOfWeek(1, (this.getDay() > 1 ? -1 : 1)); } else { return this; } } else { return this.moveToDayOfWeek(1, (this.getDay() > 1 ? -1 : 1)).addWeeks(n - this.getWeek()); } }; $P.setQuarter = function (qtr) { var month = Math.abs(((qtr-1) * 3) + 1); return this.setMonth(month, 1); }; $P.getQuarter = function () { return Date.getQuarter(this); }; $P.getDaysLeftInQuarter = function () { return Date.getDaysLeftInQuarter(this); }; /** * Moves the date to the next n'th occurrence of the dayOfWeek starting from the beginning of the month. The number (-1) is a magic number and will return the last occurrence of the dayOfWeek in the month. * @param {Number} The dayOfWeek to move to * @param {Number} The n'th occurrence to move to. Use (-1) to return the last occurrence in the month * @return {Date} this */ $P.moveToNthOccurrence = function (dayOfWeek, occurrence) { if (dayOfWeek === "Weekday") { if (occurrence > 0) { this.moveToFirstDayOfMonth(); if (this.is().weekday()) { occurrence -= 1; } } else if (occurrence < 0) { this.moveToLastDayOfMonth(); if (this.is().weekday()) { occurrence += 1; } } else { return this; } return this.addWeekdays(occurrence); } var shift = 0; if (occurrence > 0) { shift = occurrence - 1; } else if (occurrence === -1) { this.moveToLastDayOfMonth(); if (this.getDay() !== dayOfWeek) { this.moveToDayOfWeek(dayOfWeek, -1); } return this; } return this.moveToFirstDayOfMonth().addDays(-1).moveToDayOfWeek(dayOfWeek, +1).addWeeks(shift); }; var moveToN = function (getFunc, addFunc, nVal) { return function (value, orient) { var diff = (value - this[getFunc]() + nVal * (orient || +1)) % nVal; return this[addFunc]((diff === 0) ? diff += nVal * (orient || +1) : diff); }; }; /** * Move to the next or last dayOfWeek based on the orient value. * @param {Number} The dayOfWeek to move to * @param {Number} Forward (+1) or Back (-1). Defaults to +1. [Optional] * @return {Date} this */ $P.moveToDayOfWeek = moveToN("getDay", "addDays", 7); /** * Move to the next or last month based on the orient value. * @param {Number} The month to move to. 0 = January, 11 = December * @param {Number} Forward (+1) or Back (-1). Defaults to +1. [Optional] * @return {Date} this */ $P.moveToMonth = moveToN("getMonth", "addMonths", 12); /** * Get the Ordinate of the current day ("th", "st", "rd"). * @return {String} */ $P.getOrdinate = function () { var num = this.getDate(); return ord(num); }; /** * Get the Ordinal day (numeric day number) of the year, adjusted for leap year. * @return {Number} 1 through 365 (366 in leap years) */ $P.getOrdinalNumber = function () { return Math.ceil((this.clone().clearTime() - new Date(this.getFullYear(), 0, 1)) / 86400000) + 1; }; /** * Get the time zone abbreviation of the current date. * @return {String} The abbreviated time zone name (e.g. "EST") */ $P.getTimezone = function () { return $D.getTimezoneAbbreviation(this.getUTCOffset(), this.isDaylightSavingTime()); }; $P.setTimezoneOffset = function (offset) { var here = this.getTimezoneOffset(), there = Number(offset) * -6 / 10; return (there || there === 0) ? this.addMinutes(there - here) : this; }; $P.setTimezone = function (offset) { return this.setTimezoneOffset($D.getTimezoneOffset(offset)); }; /** * Indicates whether Daylight Saving Time is observed in the current time zone. * @return {Boolean} true|false */ $P.hasDaylightSavingTime = function () { return (Date.today().set({month: 0, day: 1}).getTimezoneOffset() !== Date.today().set({month: 6, day: 1}).getTimezoneOffset()); }; /** * Indicates whether this Date instance is within the Daylight Saving Time range for the current time zone. * @return {Boolean} true|false */ $P.isDaylightSavingTime = function () { return Date.today().set({month: 0, day: 1}).getTimezoneOffset() !== this.getTimezoneOffset(); }; /** * Get the offset from UTC of the current date. * @return {String} The 4-character offset string prefixed with + or - (e.g. "-0500") */ $P.getUTCOffset = function (offset) { var n = (offset || this.getTimezoneOffset()) * -10 / 6, r; if (n < 0) { r = (n - 10000).toString(); return r.charAt(0) + r.substr(2); } else { r = (n + 10000).toString(); return "+" + r.substr(1); } }; /** * Returns the number of milliseconds between this date and date. * @param {Date} Defaults to now * @return {Number} The diff in milliseconds */ $P.getElapsed = function (date) { return (date || new Date()) - this; }; /** * Set the value of year, month, day, hour, minute, second, millisecond of date instance using given configuration object. * Example

	Date.today().set( { day: 20, month: 1 } )

	new Date().set( { millisecond: 0 } )
	
* * @param {Object} Configuration object containing attributes (month, day, etc.) * @return {Date} this */ $P.set = function (config) { config = validateConfigObject.call(this, config); var key; for (key in config) { if (Object.prototype.hasOwnProperty.call(config, key)) { var name = key.charAt(0).toUpperCase() + key.slice(1); var addFunc, getFunc; if (key !== "week" && key !== "month" && key !== "timezone" && key !== "timezoneOffset") { name += "s"; } addFunc = "add" + name; getFunc = "get" + name; if (key === "month") { addFunc = addFunc + "s"; } else if (key === "year"){ getFunc = "getFullYear"; } if (key !== "day" && key !== "timezone" && key !== "timezoneOffset" && key !== "week" && key !== "hour") { this[addFunc](config[key] - this[getFunc]()); } else if ( key === "timezone"|| key === "timezoneOffset" || key === "week" || key === "hour") { this["set"+name](config[key]); } } } // day has to go last because you can't validate the day without first knowing the month if (config.day) { this.addDays(config.day - this.getDate()); } return this; }; /** * Moves the date to the first day of the month. * @return {Date} this */ $P.moveToFirstDayOfMonth = function () { return this.set({ day: 1 }); }; /** * Moves the date to the last day of the month. * @return {Date} this */ $P.moveToLastDayOfMonth = function () { return this.set({ day: $D.getDaysInMonth(this.getFullYear(), this.getMonth())}); }; /** * Converts the value of the current Date object to its equivalent string representation. * Format Specifiers * CUSTOM DATE AND TIME FORMAT STRINGS * Format Description Example * ------ --------------------------------------------------------------------------- ----------------------- * s The seconds of the minute between 0-59. "0" to "59" * ss The seconds of the minute with leading zero if required. "00" to "59" * * m The minute of the hour between 0-59. "0" or "59" * mm The minute of the hour with leading zero if required. "00" or "59" * * h The hour of the day between 1-12. "1" to "12" * hh The hour of the day with leading zero if required. "01" to "12" * * H The hour of the day between 0-23. "0" to "23" * HH The hour of the day with leading zero if required. "00" to "23" * * d The day of the month between 1 and 31. "1" to "31" * dd The day of the month with leading zero if required. "01" to "31" * ddd Abbreviated day name. Date.CultureInfo.abbreviatedDayNames. "Mon" to "Sun" * dddd The full day name. Date.CultureInfo.dayNames. "Monday" to "Sunday" * * M The month of the year between 1-12. "1" to "12" * MM The month of the year with leading zero if required. "01" to "12" * MMM Abbreviated month name. Date.CultureInfo.abbreviatedMonthNames. "Jan" to "Dec" * MMMM The full month name. Date.CultureInfo.monthNames. "January" to "December" * * yy The year as a two-digit number. "99" or "08" * yyyy The full four digit year. "1999" or "2008" * * t Displays the first character of the A.M./P.M. designator. "A" or "P" * Date.CultureInfo.amDesignator or Date.CultureInfo.pmDesignator * tt Displays the A.M./P.M. designator. "AM" or "PM" * Date.CultureInfo.amDesignator or Date.CultureInfo.pmDesignator * * S The ordinal suffix ("st, "nd", "rd" or "th") of the current day. "st, "nd", "rd" or "th" * * STANDARD DATE AND TIME FORMAT STRINGS * Format Description Example *------ --------------------------------------------------------------------------- ----------------------- * d The CultureInfo shortDate Format Pattern "M/d/yyyy" * D The CultureInfo longDate Format Pattern "dddd, MMMM dd, yyyy" * F The CultureInfo fullDateTime Format Pattern "dddd, MMMM dd, yyyy h:mm:ss tt" * m The CultureInfo monthDay Format Pattern "MMMM dd" * r The CultureInfo rfc1123 Format Pattern "ddd, dd MMM yyyy HH:mm:ss GMT" * s The CultureInfo sortableDateTime Format Pattern "yyyy-MM-ddTHH:mm:ss" * t The CultureInfo shortTime Format Pattern "h:mm tt" * T The CultureInfo longTime Format Pattern "h:mm:ss tt" * u The CultureInfo universalSortableDateTime Format Pattern "yyyy-MM-dd HH:mm:ssZ" * y The CultureInfo yearMonth Format Pattern "MMMM, yyyy" * * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @return {String} A string representation of the current Date object. */ var ord = function (n) { switch (n * 1) { case 1: case 21: case 31: return "st"; case 2: case 22: return "nd"; case 3: case 23: return "rd"; default: return "th"; } }; var parseStandardFormats = function (format) { var y, c = Date.CultureInfo.formatPatterns; switch (format) { case "d": return this.toString(c.shortDate); case "D": return this.toString(c.longDate); case "F": return this.toString(c.fullDateTime); case "m": return this.toString(c.monthDay); case "r": case "R": y = this.clone().addMinutes(this.getTimezoneOffset()); return y.toString(c.rfc1123) + " GMT"; case "s": return this.toString(c.sortableDateTime); case "t": return this.toString(c.shortTime); case "T": return this.toString(c.longTime); case "u": y = this.clone().addMinutes(this.getTimezoneOffset()); return y.toString(c.universalSortableDateTime); case "y": return this.toString(c.yearMonth); default: return false; } }; var parseFormatStringsClosure = function (context) { return function (m) { if (m.charAt(0) === "\\") { return m.replace("\\", ""); } switch (m) { case "hh": return p(context.getHours() < 13 ? (context.getHours() === 0 ? 12 : context.getHours()) : (context.getHours() - 12)); case "h": return context.getHours() < 13 ? (context.getHours() === 0 ? 12 : context.getHours()) : (context.getHours() - 12); case "HH": return p(context.getHours()); case "H": return context.getHours(); case "mm": return p(context.getMinutes()); case "m": return context.getMinutes(); case "ss": return p(context.getSeconds()); case "s": return context.getSeconds(); case "yyyy": return p(context.getFullYear(), 4); case "yy": return p(context.getFullYear()); case "y": return context.getFullYear(); case "E": case "dddd": return Date.CultureInfo.dayNames[context.getDay()]; case "ddd": return Date.CultureInfo.abbreviatedDayNames[context.getDay()]; case "dd": return p(context.getDate()); case "d": return context.getDate(); case "MMMM": return Date.CultureInfo.monthNames[context.getMonth()]; case "MMM": return Date.CultureInfo.abbreviatedMonthNames[context.getMonth()]; case "MM": return p((context.getMonth() + 1)); case "M": return context.getMonth() + 1; case "t": return context.getHours() < 12 ? Date.CultureInfo.amDesignator.substring(0, 1) : Date.CultureInfo.pmDesignator.substring(0, 1); case "tt": return context.getHours() < 12 ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator; case "S": return ord(context.getDate()); case "W": return context.getWeek(); case "WW": return context.getISOWeek(); case "Q": return "Q" + context.getQuarter(); case "q": return String(context.getQuarter()); case "z": return context.getTimezone(); case "Z": case "X": return Date.getTimezoneOffset(context.getTimezone()); case "ZZ": // Timezone offset in seconds return context.getTimezoneOffset() * -60; case "u": return context.getDay(); case "L": return ($D.isLeapYear(context.getFullYear())) ? 1 : 0; case "B": // Swatch Internet Time (.beats) return "@"+((context.getUTCSeconds() + (context.getUTCMinutes()*60) + ((context.getUTCHours()+1)*3600))/86.4); default: return m; } }; }; $P.toString = function (format, ignoreStandards) { // Standard Date and Time Format Strings. Formats pulled from CultureInfo file and // may vary by culture. if (!ignoreStandards && format && format.length === 1) { output = parseStandardFormats.call(this, format); if (output) { return output; } } var parseFormatStrings = parseFormatStringsClosure(this); return format ? format.replace(/((\\)?(dd?d?d?|MM?M?M?|yy?y?y?|hh?|HH?|mm?|ss?|tt?|S|q|Q|WW?W?W?)(?![^\[]*\]))/g, parseFormatStrings).replace(/\[|\]/g, "") : this._toString(); }; }()); /************************************************************* * SugarPak - Domain Specific Language - Syntactical Sugar * *************************************************************/ (function () { var $D = Date, $P = $D.prototype, $N = Number.prototype; // private $P._orient = +1; // private $P._nth = null; // private $P._is = false; // private $P._same = false; // private $P._isSecond = false; // private $N._dateElement = "days"; /** * Moves the date to the next instance of a date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.today().next().friday();
	Date.today().next().fri();
	Date.today().next().march();
	Date.today().next().mar();
	Date.today().next().week();
	
* * @return {Date} date */ $P.next = function () { this._move = true; this._orient = +1; return this; }; /** * Creates a new Date (Date.today()) and moves the date to the next instance of the date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.next().friday();
	Date.next().fri();
	Date.next().march();
	Date.next().mar();
	Date.next().week();
	
* * @return {Date} date */ $D.next = function () { return $D.today().next(); }; /** * Moves the date to the previous instance of a date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.today().last().friday();
	Date.today().last().fri();
	Date.today().last().march();
	Date.today().last().mar();
	Date.today().last().week();
	
* * @return {Date} date */ $P.last = $P.prev = $P.previous = function () { this._move = true; this._orient = -1; return this; }; /** * Creates a new Date (Date.today()) and moves the date to the previous instance of the date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.last().friday();
	Date.last().fri();
	Date.previous().march();
	Date.prev().mar();
	Date.last().week();
	
* * @return {Date} date */ $D.last = $D.prev = $D.previous = function () { return $D.today().last(); }; /** * Performs a equality check when followed by either a month name, day name or .weekday() function. * Example

	Date.today().is().friday(); // true|false
	Date.today().is().fri();
	Date.today().is().march();
	Date.today().is().mar();
	
* * @return {Boolean} true|false */ $P.is = function () { this._is = true; return this; }; /** * Determines if two date objects occur on/in exactly the same instance of the subsequent date part function. * The function .same() must be followed by a date part function (example: .day(), .month(), .year(), etc). * * An optional Date can be passed in the date part function. If now date is passed as a parameter, 'Now' is used. * * The following example demonstrates how to determine if two dates fall on the exact same day. * * Example

	var d1 = Date.today(); // today at 00:00
	var d2 = new Date();   // exactly now.

	// Do they occur on the same day?
	d1.same().day(d2); // true
	
	// Do they occur on the same hour?
	d1.same().hour(d2); // false, unless d2 hour is '00' (midnight).
	
	// What if it's the same day, but one year apart?
	var nextYear = Date.today().add(1).year();

	d1.same().day(nextYear); // false, because the dates must occur on the exact same day. 
	
* * Scenario: Determine if a given date occurs during some week period 2 months from now. * * Example

	var future = Date.today().add(2).months();
	return someDate.same().week(future); // true|false;
	
* * @return {Boolean} true|false */ $P.same = function () { this._same = true; this._isSecond = false; return this; }; /** * Determines if the current date/time occurs during Today. Must be preceded by the .is() function. * Example

	someDate.is().today();    // true|false
	new Date().is().today();  // true
	Date.today().is().today();// true
	Date.today().add(-1).day().is().today(); // false
	
* * @return {Boolean} true|false */ $P.today = function () { return this.same().day(); }; /** * Determines if the current date is a weekday. This function must be preceded by the .is() function. * Example

	Date.today().is().weekday(); // true|false
	
* * @return {Boolean} true|false */ $P.weekday = function () { if (this._nth) { return df("Weekday").call(this); } if (this._move) { return this.addWeekdays(this._orient); } if (this._is) { this._is = false; return (!this.is().sat() && !this.is().sun()); } return false; }; /** * Determines if the current date is on the weekend. This function must be preceded by the .is() function. * Example

	Date.today().is().weekend(); // true|false
	
* * @return {Boolean} true|false */ $P.weekend = function () { if (this._is) { this._is = false; return (this.is().sat() || this.is().sun()); } return false; }; /** * Sets the Time of the current Date instance. A string "6:15 pm" or config object {hour:18, minute:15} are accepted. * Example

	// Set time to 6:15pm with a String
	Date.today().at("6:15pm");

	// Set time to 6:15pm with a config object
	Date.today().at({hour:18, minute:15});
	
* * @return {Date} date */ $P.at = function (time) { return (typeof time === "string") ? $D.parse(this.toString("d") + " " + time) : this.set(time); }; /** * Creates a new Date() and adds this (Number) to the date based on the preceding date element function (eg. second|minute|hour|day|month|year). * Example

	// Undeclared Numbers must be wrapped with parentheses. Requirment of JavaScript.
	(3).days().fromNow();
	(6).months().fromNow();

	// Declared Number variables do not require parentheses. 
	var n = 6;
	n.months().fromNow();
	
* * @return {Date} A new Date instance */ $N.fromNow = $N.after = function (date) { var c = {}; c[this._dateElement] = this; return ((!date) ? new Date() : date.clone()).add(c); }; /** * Creates a new Date() and subtract this (Number) from the date based on the preceding date element function (eg. second|minute|hour|day|month|year). * Example

	// Undeclared Numbers must be wrapped with parentheses. Requirment of JavaScript.
	(3).days().ago();
	(6).months().ago();

	// Declared Number variables do not require parentheses. 
	var n = 6;
	n.months().ago();
	
* * @return {Date} A new Date instance */ $N.ago = $N.before = function (date) { var c = {}, s = (this._dateElement[this._dateElement.length-1] !== "s") ? this._dateElement + "s" : this._dateElement; c[s] = this * -1; return ((!date) ? new Date() : date.clone()).add(c); }; // Do NOT modify the following string tokens. These tokens are used to build dynamic functions. // All culture-specific strings can be found in the CultureInfo files. var dx = ("sunday monday tuesday wednesday thursday friday saturday").split(/\s/), mx = ("january february march april may june july august september october november december").split(/\s/), px = ("Millisecond Second Minute Hour Day Week Month Year Quarter Weekday").split(/\s/), pxf = ("Milliseconds Seconds Minutes Hours Date Week Month FullYear Quarter").split(/\s/), nth = ("final first second third fourth fifth").split(/\s/), de; /** * Returns an object literal of all the date parts. * Example

	var o = new Date().toObject();
	
	// { year: 2008, month: 4, week: 20, day: 13, hour: 18, minute: 9, second: 32, millisecond: 812 }
	
	// The object properties can be referenced directly from the object.
	
	alert(o.day);  // alerts "13"
	alert(o.year); // alerts "2008"
	
* * @return {Date} An object literal representing the original date object. */ $P.toObject = function () { var o = {}; for (var i = 0; i < px.length; i++) { if (this["get" + pxf[i]]) { o[px[i].toLowerCase()] = this["get" + pxf[i]](); } } return o; }; /** * Returns a date created from an object literal. Ignores the .week property if set in the config. * Example

	var o = new Date().toObject();
	
	return Date.fromObject(o); // will return the same date. 

	var o2 = {month: 1, day: 20, hour: 18}; // birthday party!
	Date.fromObject(o2);
	
* * @return {Date} An object literal representing the original date object. */ $D.fromObject = function(config) { config.week = null; return Date.today().set(config); }; // Create day name functions and abbreviated day name functions (eg. monday(), friday(), fri()). var df = function (n) { return function () { if (this._is) { this._is = false; return this.getDay() === n; } if (this._move) { this._move = null; } if (this._nth !== null) { // If the .second() function was called earlier, remove the _orient // from the date, and then continue. // This is required because 'second' can be used in two different context. // // Example // // Date.today().add(1).second(); // Date.march().second().monday(); // // Things get crazy with the following... // Date.march().add(1).second().second().monday(); // but it works!! // if (this._isSecond) { this.addSeconds(this._orient * -1); } // make sure we reset _isSecond this._isSecond = false; var ntemp = this._nth; this._nth = null; var temp = this.clone().moveToLastDayOfMonth(); this.moveToNthOccurrence(n, ntemp); if (this > temp) { throw new RangeError($D.getDayName(n) + " does not occur " + ntemp + " times in the month of " + $D.getMonthName(temp.getMonth()) + " " + temp.getFullYear() + "."); } return this; } return this.moveToDayOfWeek(n, this._orient); }; }; var sdf = function (n) { return function () { var t = $D.today(), shift = n - t.getDay(); if (n === 0 && Date.CultureInfo.firstDayOfWeek === 1 && t.getDay() !== 0) { shift = shift + 7; } return t.addDays(shift); }; }; // Create month name functions and abbreviated month name functions (eg. january(), march(), mar()). var month_instance_functions = function (n) { return function () { if (this._is) { this._is = false; return this.getMonth() === n; } return this.moveToMonth(n, this._orient); }; }; var month_static_functions = function (n) { return function () { return $D.today().set({ month: n, day: 1 }); }; }; var processTerms = function (names, staticFunc, instanceFunc) { for (var i = 0; i < names.length; i++) { // Create constant static Name variables. $D[names[i].toUpperCase()] = $D[names[i].toUpperCase().substring(0, 3)] = i; // Create Name functions. $D[names[i]] = $D[names[i].substring(0, 3)] = staticFunc(i); // Create Name instance functions. $P[names[i]] = $P[names[i].substring(0, 3)] = instanceFunc(i); } }; processTerms(dx, sdf, df); processTerms(mx, month_static_functions, month_instance_functions); // Create date element functions and plural date element functions used with Date (eg. day(), days(), months()). var ef = function (j) { return function () { // if the .second() function was called earlier, the _orient // has alread been added. Just return this and reset _isSecond. if (this._isSecond) { this._isSecond = false; return this; } if (this._same) { this._same = this._is = false; var o1 = this.toObject(), o2 = (arguments[0] || new Date()).toObject(), v = "", k = j.toLowerCase(); // the substr trick with -1 doesn't work in IE8 or less k = (k[k.length-1] === "s") ? k.substring(0,k.length-1) : k; for (var m = (px.length - 1); m > -1; m--) { v = px[m].toLowerCase(); if (o1[v] !== o2[v]) { return false; } if (k === v) { break; } } return true; } if (j.substring(j.length - 1) !== "s") { j += "s"; } if (this._move) { this._move = null; } return this["add" + j](this._orient); }; }; var nf = function (n) { return function () { this._dateElement = n; return this; }; }; for (var k = 0; k < px.length; k++) { de = px[k].toLowerCase(); if(de !== "weekday") { // Create date element functions and plural date element functions used with Date (eg. day(), days(), months()). $P[de] = $P[de + "s"] = ef(px[k]); // Create date element functions and plural date element functions used with Number (eg. day(), days(), months()). $N[de] = $N[de + "s"] = nf(de + "s"); } } $P._ss = ef("Second"); var nthfn = function (n) { return function (dayOfWeek) { if (this._same) { return this._ss(arguments[0]); } if (dayOfWeek || dayOfWeek === 0) { return this.moveToNthOccurrence(dayOfWeek, n); } this._nth = n; // if the operator is 'second' add the _orient, then deal with it later... if (n === 2 && (dayOfWeek === undefined || dayOfWeek === null)) { this._isSecond = true; return this.addSeconds(this._orient); } return this; }; }; for (var l = 0; l < nth.length; l++) { $P[nth[l]] = (l === 0) ? nthfn(-1) : nthfn(l); } }()); (function () { "use strict"; Date.Parsing = { Exception: function (s) { this.message = "Parse error at '" + s.substring(0, 10) + " ...'"; } }; var $P = Date.Parsing; var dayOffsets = { standard: [0,31,59,90,120,151,181,212,243,273,304,334], leap: [0,31,60,91,121,152,182,213,244,274,305,335] }; $P.isLeapYear = function(year) { return ((year % 4 === 0) && (year % 100 !== 0)) || (year % 400 === 0); }; var utils = { multiReplace : function (str, hash ) { var key; for (key in hash) { if (Object.prototype.hasOwnProperty.call(hash, key)) { var regex; if (typeof hash[key] === "function") { } else { regex = (hash[key] instanceof RegExp) ? hash[key] : new RegExp(hash[key], "g"); } str = str.replace(regex, key); } } return str; }, getDayOfYearFromWeek : function (obj) { var d, jan4, offset; obj.weekDay = (!obj.weekDay && obj.weekDay !== 0) ? 1 : obj.weekDay; d = new Date(obj.year, 0, 4); jan4 = d.getDay() === 0 ? 7 : d.getDay(); // JS is 0 indexed on Sunday. offset = jan4+3; obj.dayOfYear = ((obj.week * 7) + (obj.weekDay === 0 ? 7 : obj.weekDay))-offset; return obj; }, getDayOfYear : function (obj, dayOffset) { if (!obj.dayOfYear) { obj = utils.getDayOfYearFromWeek(obj); } for (var i=0;i <= dayOffset.length;i++) { if (obj.dayOfYear < dayOffset[i] || i === dayOffset.length) { obj.day = obj.day ? obj.day : (obj.dayOfYear - dayOffset[i-1]); break; } else { obj.month = i; } } return obj; }, adjustForTimeZone : function (obj, date) { var offset; if (obj.zone.toUpperCase() === "Z" || (obj.zone_hours === 0 && obj.zone_minutes === 0)) { // it's UTC/GML so work out the current timeszone offset offset = -date.getTimezoneOffset(); } else { offset = (obj.zone_hours*60) + (obj.zone_minutes || 0); if (obj.zone_sign === "+") { offset *= -1; } offset -= date.getTimezoneOffset(); } date.setMinutes(date.getMinutes()+offset); return date; }, setDefaults : function (obj) { obj.year = obj.year || Date.today().getFullYear(); obj.hours = obj.hours || 0; obj.minutes = obj.minutes || 0; obj.seconds = obj.seconds || 0; obj.milliseconds = obj.milliseconds || 0; if (!(!obj.month && (obj.week || obj.dayOfYear))) { // if we have a month, or if we don't but don't have the day calculation data obj.month = obj.month || 0; obj.day = obj.day || 1; } return obj; }, dataNum: function (data, mod, explict, postProcess) { var dataNum = data*1; if (mod) { if (postProcess) { return data ? mod(data)*1 : data; } else { return data ? mod(dataNum) : data; } } else if (!explict){ return data ? dataNum : data; } else { return (data && typeof data !== "undefined") ? dataNum : data; } }, timeDataProcess: function (obj) { var timeObj = {}; for (var x in obj.data) { if (obj.data.hasOwnProperty(x)) { timeObj[x] = obj.ignore[x] ? obj.data[x] : utils.dataNum(obj.data[x], obj.mods[x], obj.explict[x], obj.postProcess[x]); } } if (obj.data.secmins) { obj.data.secmins = obj.data.secmins.replace(",", ".") * 60; if (!timeObj.minutes) { timeObj.minutes = obj.data.secmins; } else if (!timeObj.seconds) { timeObj.seconds = obj.data.secmins; } delete obj.secmins; } return timeObj; }, buildTimeObjectFromData: function (data) { var time = utils.timeDataProcess({ data: { year : data[1], month : data[5], day : data[7], week : data[8], dayOfYear : data[10], hours : data[15], zone_hours : data[23], zone_minutes : data[24], zone : data[21], zone_sign : data[22], weekDay : data[9], minutes: data[16], seconds: data[19], milliseconds: data[20], secmins: data[18] }, mods: { month: function(data) { return data-1; }, weekDay: function (data) { data = Math.abs(data); return (data === 7 ? 0 : data); }, minutes: function (data) { return data.replace(":",""); }, seconds: function (data) { return Math.floor( (data.replace(":","").replace(",","."))*1 ); }, milliseconds: function (data) { return (data.replace(",",".")*1000); } }, postProcess: { minutes: true, seconds: true, milliseconds: true }, explict: { zone_hours: true, zone_minutes: true }, ignore: { zone: true, zone_sign: true, secmins: true } }); return time; }, addToHash: function (hash, keys, data) { keys = keys; data = data; var len = keys.length; for (var i = 0; i < len; i++) { hash[keys[i]] = data[i]; } return hash; }, combineRegex: function (r1, r2) { return new RegExp("(("+r1.source+")\\s("+r2.source+"))"); }, getDateNthString: function(add, last, inc){ if (add) { return Date.today().addDays(inc).toString("d"); } else if (last) { return Date.today().last()[inc]().toString("d"); } }, buildRegexData: function (array) { var arr = []; var len = array.length; for (var i=0; i < len; i++) { if (Object.prototype.toString.call(array[i]) === '[object Array]') { // oldIE compat version of Array.isArray arr.push(this.combineRegex(array[i][0], array[i][1])); } else { arr.push(array[i]); } } return arr; } }; $P.processTimeObject = function (obj) { var date, dayOffset; utils.setDefaults(obj); dayOffset = ($P.isLeapYear(obj.year)) ? dayOffsets.leap : dayOffsets.standard; if (!obj.month && (obj.week || obj.dayOfYear)) { utils.getDayOfYear(obj, dayOffset); } else { obj.dayOfYear = dayOffset[obj.month] + obj.day; } date = new Date(obj.year, obj.month, obj.day, obj.hours, obj.minutes, obj.seconds, obj.milliseconds); if (obj.zone) { utils.adjustForTimeZone(obj, date); // adjust (and calculate) for timezone } return date; }; $P.ISO = { regex : /^([\+-]?\d{4}(?!\d{2}\b))((-?)((0[1-9]|1[0-2])(\3([12]\d|0[1-9]|3[01]))?|W([0-4]\d|5[0-3])(-?[1-7])?|(00[1-9]|0[1-9]\d|[12]\d{2}|3([0-5]\d|6[1-6])))([T\s]((([01]\d|2[0-4])((:?)[0-5]\d)?|24\:?00)([\.,]\d+(?!:))?)?(\17[0-5]\d([\.,]\d+)?)?\s?([zZ]|([\+-])([01]\d|2[0-3]):?([0-5]\d)?)?)?)?$/, parse : function (s) { var time, data = s.match(this.regex); if (!data || !data.length) { return null; } time = utils.buildTimeObjectFromData(data); if (!time.year || (!time.year && (!time.month && !time.day) && (!time.week && !time.dayOfYear)) ) { return null; } return $P.processTimeObject(time); } }; $P.Numeric = { isNumeric: function (e){return!isNaN(parseFloat(e))&&isFinite(e);}, regex: /\b([0-1]?[0-9])([0-3]?[0-9])([0-2]?[0-9]?[0-9][0-9])\b/i, parse: function (s) { var data, i, time = {}, order = Date.CultureInfo.dateElementOrder.split(""); if (!(this.isNumeric(s)) || // if it's non-numeric OR (s[0] === "+" && s[0] === "-")) { // It's an arithmatic string (eg +/-1000) return null; } if (s.length < 5 && s.indexOf(".") < 0 && s.indexOf("/") < 0) { // assume it's just a year. time.year = s; return $P.processTimeObject(time); } data = s.match(this.regex); if (!data || !data.length) { return null; } for (i=0; i < order.length; i++) { switch(order[i]) { case "d": time.day = data[i+1]; break; case "m": time.month = (data[i+1]-1); break; case "y": time.year = data[i+1]; break; } } return $P.processTimeObject(time); } }; $P.Normalizer = { regexData: function () { var $R = Date.CultureInfo.regexPatterns; return utils.buildRegexData([ $R.tomorrow, $R.yesterday, [$R.past, $R.mon], [$R.past, $R.tue], [$R.past, $R.wed], [$R.past, $R.thu], [$R.past, $R.fri], [$R.past, $R.sat], [$R.past, $R.sun] ]); }, basicReplaceHash : function() { var $R = Date.CultureInfo.regexPatterns; return { "January": $R.jan.source, "February": $R.feb, "March": $R.mar, "April": $R.apr, "May": $R.may, "June": $R.jun, "July": $R.jul, "August": $R.aug, "September": $R.sep, "October": $R.oct, "November": $R.nov, "December": $R.dec, "": /\bat\b/gi, " ": /\s{2,}/, "am": $R.inTheMorning, "9am": $R.thisMorning, "pm": $R.inTheEvening, "7pm":$R.thisEvening }; }, keys : function(){ return [ utils.getDateNthString(true, false, 1), // tomorrow utils.getDateNthString(true, false, -1), // yesterday utils.getDateNthString(false, true, "monday"), //last mon utils.getDateNthString(false, true, "tuesday"), //last tues utils.getDateNthString(false, true, "wednesday"), //last wed utils.getDateNthString(false, true, "thursday"), //last thurs utils.getDateNthString(false, true, "friday"), //last fri utils.getDateNthString(false, true, "saturday"), //last sat utils.getDateNthString(false, true, "sunday") //last sun ]; }, buildRegexFunctions: function () { var $R = Date.CultureInfo.regexPatterns; var __ = Date.i18n.__; var tomorrowRE = new RegExp("(\\b\\d\\d?("+__("AM")+"|"+__("PM")+")? )("+$R.tomorrow.source.slice(1)+")", "i"); // adapted tomorrow regex for AM PM relative dates var todayRE = new RegExp($R.today.source + "(?!\\s*([+-]))\\b"); // today, but excludes the math operators (eg "today + 2h") this.replaceFuncs = [ [todayRE, function (full) { return (full.length > 1) ? Date.today().toString("d") : full; }], [tomorrowRE, function(full, m1) { var t = Date.today().addDays(1).toString("d"); return (t + " " + m1); }], [$R.amThisMorning, function(str, am){return am;}], [$R.pmThisEvening, function(str, pm){return pm;}] ]; }, buildReplaceData: function () { this.buildRegexFunctions(); this.replaceHash = utils.addToHash(this.basicReplaceHash(), this.keys(), this.regexData()); }, stringReplaceFuncs: function (s) { for (var i=0; i < this.replaceFuncs.length; i++) { s = s.replace(this.replaceFuncs[i][0], this.replaceFuncs[i][1]); } return s; }, parse: function (s) { s = this.stringReplaceFuncs(s); s = utils.multiReplace(s, this.replaceHash); try { var n = s.split(/([\s\-\.\,\/\x27]+)/); if (n.length === 3 && $P.Numeric.isNumeric(n[0]) && $P.Numeric.isNumeric(n[2]) && (n[2].length >= 4)) { // ok, so we're dealing with x/year. But that's not a full date. // This fixes wonky dateElementOrder parsing when set to dmy order. if (Date.CultureInfo.dateElementOrder[0] === "d") { s = "1/" + n[0] + "/" + n[2]; // set to 1st of month and normalize the seperator } } } catch (e) {} return s; } }; $P.Normalizer.buildReplaceData(); }()); (function () { var $P = Date.Parsing; var _ = $P.Operators = { // // Tokenizers // rtoken: function (r) { // regex token return function (s) { var mx = s.match(r); if (mx) { return ([ mx[0], s.substring(mx[0].length) ]); } else { throw new $P.Exception(s); } }; }, token: function () { // whitespace-eating token return function (s) { return _.rtoken(new RegExp("^\\s*" + s + "\\s*"))(s); }; }, stoken: function (s) { // string token return _.rtoken(new RegExp("^" + s)); }, // Atomic Operators until: function (p) { return function (s) { var qx = [], rx = null; while (s.length) { try { rx = p.call(this, s); } catch (e) { qx.push(rx[0]); s = rx[1]; continue; } break; } return [ qx, s ]; }; }, many: function (p) { return function (s) { var rx = [], r = null; while (s.length) { try { r = p.call(this, s); } catch (e) { return [ rx, s ]; } rx.push(r[0]); s = r[1]; } return [ rx, s ]; }; }, // generator operators -- see below optional: function (p) { return function (s) { var r = null; try { r = p.call(this, s); } catch (e) { return [ null, s ]; } return [ r[0], r[1] ]; }; }, not: function (p) { return function (s) { try { p.call(this, s); } catch (e) { return [null, s]; } throw new $P.Exception(s); }; }, ignore: function (p) { return p ? function (s) { var r = null; r = p.call(this, s); return [null, r[1]]; } : null; }, product: function () { var px = arguments[0], qx = Array.prototype.slice.call(arguments, 1), rx = []; for (var i = 0 ; i < px.length ; i++) { rx.push(_.each(px[i], qx)); } return rx; }, cache: function (rule) { var cache = {}, cache_length = 0, cache_keys = [], CACHE_MAX = Date.Config.CACHE_MAX || 100000, r = null; var cacheCheck = function () { if (cache_length === CACHE_MAX) { // kill several keys, don't want to have to do this all the time... for (var i=0; i < 10; i++) { var key = cache_keys.shift(); if (key) { delete cache[key]; cache_length--; } } } }; return function (s) { cacheCheck(); try { r = cache[s] = (cache[s] || rule.call(this, s)); } catch (e) { r = cache[s] = e; } cache_length++; cache_keys.push(s); if (r instanceof $P.Exception) { throw r; } else { return r; } }; }, // vector operators -- see below any: function () { var px = arguments; return function (s) { var r = null; for (var i = 0; i < px.length; i++) { if (px[i] == null) { continue; } try { r = (px[i].call(this, s)); } catch (e) { r = null; } if (r) { return r; } } throw new $P.Exception(s); }; }, each: function () { var px = arguments; return function (s) { var rx = [], r = null; for (var i = 0; i < px.length ; i++) { if (px[i] == null) { continue; } try { r = (px[i].call(this, s)); } catch (e) { throw new $P.Exception(s); } rx.push(r[0]); s = r[1]; } return [ rx, s]; }; }, all: function () { var px = arguments, _ = _; return _.each(_.optional(px)); }, // delimited operators sequence: function (px, d, c) { d = d || _.rtoken(/^\s*/); c = c || null; if (px.length === 1) { return px[0]; } return function (s) { var r = null, q = null; var rx = []; for (var i = 0; i < px.length ; i++) { try { r = px[i].call(this, s); } catch (e) { break; } rx.push(r[0]); try { q = d.call(this, r[1]); } catch (ex) { q = null; break; } s = q[1]; } if (!r) { throw new $P.Exception(s); } if (q) { throw new $P.Exception(q[1]); } if (c) { try { r = c.call(this, r[1]); } catch (ey) { throw new $P.Exception(r[1]); } } return [ rx, (r?r[1]:s) ]; }; }, // // Composite Operators // between: function (d1, p, d2) { d2 = d2 || d1; var _fn = _.each(_.ignore(d1), p, _.ignore(d2)); return function (s) { var rx = _fn.call(this, s); return [[rx[0][0], r[0][2]], rx[1]]; }; }, list: function (p, d, c) { d = d || _.rtoken(/^\s*/); c = c || null; return (p instanceof Array ? _.each(_.product(p.slice(0, -1), _.ignore(d)), p.slice(-1), _.ignore(c)) : _.each(_.many(_.each(p, _.ignore(d))), px, _.ignore(c))); }, set: function (px, d, c) { d = d || _.rtoken(/^\s*/); c = c || null; return function (s) { // r is the current match, best the current 'best' match // which means it parsed the most amount of input var r = null, p = null, q = null, rx = null, best = [[], s], last = false; // go through the rules in the given set for (var i = 0; i < px.length ; i++) { // last is a flag indicating whether this must be the last element // if there is only 1 element, then it MUST be the last one q = null; p = null; r = null; last = (px.length === 1); // first, we try simply to match the current pattern // if not, try the next pattern try { r = px[i].call(this, s); } catch (e) { continue; } // since we are matching against a set of elements, the first // thing to do is to add r[0] to matched elements rx = [[r[0]], r[1]]; // if we matched and there is still input to parse and // we don't already know this is the last element, // we're going to next check for the delimiter ... // if there's none, or if there's no input left to parse // than this must be the last element after all ... if (r[1].length > 0 && ! last) { try { q = d.call(this, r[1]); } catch (ex) { last = true; } } else { last = true; } // if we parsed the delimiter and now there's no more input, // that means we shouldn't have parsed the delimiter at all // so don't update r and mark this as the last element ... if (!last && q[1].length === 0) { last = true; } // so, if this isn't the last element, we're going to see if // we can get any more matches from the remaining (unmatched) // elements ... if (!last) { // build a list of the remaining rules we can match against, // i.e., all but the one we just matched against var qx = []; for (var j = 0; j < px.length ; j++) { if (i !== j) { qx.push(px[j]); } } // now invoke recursively set with the remaining input // note that we don't include the closing delimiter ... // we'll check for that ourselves at the end p = _.set(qx, d).call(this, q[1]); // if we got a non-empty set as a result ... // (otw rx already contains everything we want to match) if (p[0].length > 0) { // update current result, which is stored in rx ... // basically, pick up the remaining text from p[1] // and concat the result from p[0] so that we don't // get endless nesting ... rx[0] = rx[0].concat(p[0]); rx[1] = p[1]; } } // at this point, rx either contains the last matched element // or the entire matched set that starts with this element. // now we just check to see if this variation is better than // our best so far, in terms of how much of the input is parsed if (rx[1].length < best[1].length) { best = rx; } // if we've parsed all the input, then we're finished if (best[1].length === 0) { break; } } // so now we've either gone through all the patterns trying them // as the initial match; or we found one that parsed the entire // input string ... // if best has no matches, just return empty set ... if (best[0].length === 0) { return best; } // if a closing delimiter is provided, then we have to check it also if (c) { // we try this even if there is no remaining input because the pattern // may well be optional or match empty input ... try { q = c.call(this, best[1]); } catch (ey) { throw new $P.Exception(best[1]); } // it parsed ... be sure to update the best match remaining input best[1] = q[1]; } // if we're here, either there was no closing delimiter or we parsed it // so now we have the best match; just return it! return best; }; }, forward: function (gr, fname) { return function (s) { return gr[fname].call(this, s); }; }, // // Translation Operators // replace: function (rule, repl) { return function (s) { var r = rule.call(this, s); return [repl, r[1]]; }; }, process: function (rule, fn) { return function (s) { var r = rule.call(this, s); return [fn.call(this, r[0]), r[1]]; }; }, min: function (min, rule) { return function (s) { var rx = rule.call(this, s); if (rx[0].length < min) { throw new $P.Exception(s); } return rx; }; } }; // Generator Operators And Vector Operators // Generators are operators that have a signature of F(R) => R, // taking a given rule and returning another rule, such as // ignore, which parses a given rule and throws away the result. // Vector operators are those that have a signature of F(R1,R2,...) => R, // take a list of rules and returning a new rule, such as each. // Generator operators are converted (via the following _generator // function) into functions that can also take a list or array of rules // and return an array of new rules as though the function had been // called on each rule in turn (which is what actually happens). // This allows generators to be used with vector operators more easily. // Example: // each(ignore(foo, bar)) instead of each(ignore(foo), ignore(bar)) // This also turns generators into vector operators, which allows // constructs like: // not(cache(foo, bar)) var _generator = function (op) { function gen() { var args = null, rx = [], px, i; if (arguments.length > 1) { args = Array.prototype.slice.call(arguments); } else if (arguments[0] instanceof Array) { args = arguments[0]; } if (args) { px = args.shift(); if (px.length > 0) { args.unshift(px[i]); rx.push(op.apply(null, args)); args.shift(); return rx; } } else { return op.apply(null, arguments); } } return gen; }; var gx = "optional not ignore cache".split(/\s/); for (var i = 0 ; i < gx.length ; i++) { _[gx[i]] = _generator(_[gx[i]]); } var _vector = function (op) { return function () { if (arguments[0] instanceof Array) { return op.apply(null, arguments[0]); } else { return op.apply(null, arguments); } }; }; var vx = "each any all".split(/\s/); for (var j = 0 ; j < vx.length ; j++) { _[vx[j]] = _vector(_[vx[j]]); } }()); (function () { var $D = Date; var flattenAndCompact = function (ax) { var rx = []; for (var i = 0; i < ax.length; i++) { if (ax[i] instanceof Array) { rx = rx.concat(flattenAndCompact(ax[i])); } else { if (ax[i]) { rx.push(ax[i]); } } } return rx; }; var parseMeridian = function () { if (this.meridian && (this.hour || this.hour === 0)) { if (this.meridian === "a" && this.hour > 11 && Date.Config.strict24hr){ throw "Invalid hour and meridian combination"; } else if (this.meridian === "p" && this.hour < 12 && Date.Config.strict24hr){ throw "Invalid hour and meridian combination"; } else if (this.meridian === "p" && this.hour < 12) { this.hour = this.hour + 12; } else if (this.meridian === "a" && this.hour === 12) { this.hour = 0; } } }; var setDefaults = function () { var now = new Date(); if ((this.hour || this.minute) && (!this.month && !this.year && !this.day)) { this.day = now.getDate(); } if (!this.year) { this.year = now.getFullYear(); } if (!this.month && this.month !== 0) { this.month = now.getMonth(); } if (!this.day) { this.day = 1; } if (!this.hour) { this.hour = 0; } if (!this.minute) { this.minute = 0; } if (!this.second) { this.second = 0; } if (!this.millisecond) { this.millisecond = 0; } }; var finishUtils = { getToday: function () { if (this.now || "hour minute second".indexOf(this.unit) !== -1) { return new Date(); } else { return $D.today(); } }, setDaysFromWeekday: function (today, orient){ var gap; orient = orient || 1; this.unit = "day"; gap = ($D.getDayNumberFromName(this.weekday) - today.getDay()); this.days = gap ? ((gap + (orient * 7)) % 7) : (orient * 7); return this; }, setMonthsFromMonth: function (today, orient) { var gap; orient = orient || 1; this.unit = "month"; gap = (this.month - today.getMonth()); this.months = gap ? ((gap + (orient * 12)) % 12) : (orient * 12); this.month = null; return this; }, setDMYFromWeekday: function () { var d = Date[this.weekday](); this.day = d.getDate(); if (!this.month) { this.month = d.getMonth(); } this.year = d.getFullYear(); return this; }, setUnitValue: function (orient) { if (!this.value && this.operator && this.operator !== null && this[this.unit + "s"] && this[this.unit + "s"] !== null) { this[this.unit + "s"] = this[this.unit + "s"] + ((this.operator === "add") ? 1 : -1) + (this.value||0) * orient; } else if (this[this.unit + "s"] == null || this.operator != null) { if (!this.value) { this.value = 1; } this[this.unit + "s"] = this.value * orient; } }, generateDateFromWeeks: function () { var weekday = (this.weekday !== undefined) ? this.weekday : "today"; var d = Date[weekday]().addWeeks(this.weeks); if (this.now) { d.setTimeToNow(); } return d; } }; $D.Translator = { hour: function (s) { return function () { this.hour = Number(s); }; }, minute: function (s) { return function () { this.minute = Number(s); }; }, second: function (s) { return function () { this.second = Number(s); }; }, /* for ss.s format */ secondAndMillisecond: function (s) { return function () { var mx = s.match(/^([0-5][0-9])\.([0-9]{1,3})/); this.second = Number(mx[1]); this.millisecond = Number(mx[2]); }; }, meridian: function (s) { return function () { this.meridian = s.slice(0, 1).toLowerCase(); }; }, timezone: function (s) { return function () { var n = s.replace(/[^\d\+\-]/g, ""); if (n.length) { this.timezoneOffset = Number(n); } else { this.timezone = s.toLowerCase(); } }; }, day: function (x) { var s = x[0]; return function () { this.day = Number(s.match(/\d+/)[0]); if (this.day < 1) { throw "invalid day"; } }; }, month: function (s) { return function () { this.month = (s.length === 3) ? "jan feb mar apr may jun jul aug sep oct nov dec".indexOf(s)/4 : Number(s) - 1; if (this.month < 0) { throw "invalid month"; } }; }, year: function (s) { return function () { var n = Number(s); this.year = ((s.length > 2) ? n : (n + (((n + 2000) < Date.CultureInfo.twoDigitYearMax) ? 2000 : 1900))); }; }, rday: function (s) { return function () { switch (s) { case "yesterday": this.days = -1; break; case "tomorrow": this.days = 1; break; case "today": this.days = 0; break; case "now": this.days = 0; this.now = true; break; } }; }, finishExact: function (x) { var d; x = (x instanceof Array) ? x : [x]; for (var i = 0 ; i < x.length ; i++) { if (x[i]) { x[i].call(this); } } setDefaults.call(this); parseMeridian.call(this); if (this.day > $D.getDaysInMonth(this.year, this.month)) { throw new RangeError(this.day + " is not a valid value for days."); } d = new Date(this.year, this.month, this.day, this.hour, this.minute, this.second, this.millisecond); if (this.year < 100) { d.setFullYear(this.year); // means years less that 100 are process correctly. JS will parse it otherwise as 1900-1999. } if (this.timezone) { d.set({ timezone: this.timezone }); } else if (this.timezoneOffset) { d.set({ timezoneOffset: this.timezoneOffset }); } return d; }, finish: function (x) { var today, expression, orient, temp; x = (x instanceof Array) ? flattenAndCompact(x) : [ x ]; if (x.length === 0) { return null; } for (var i = 0 ; i < x.length ; i++) { if (typeof x[i] === "function") { x[i].call(this); } } if (this.now && !this.unit && !this.operator) { return new Date(); } else { today = finishUtils.getToday.call(this); } expression = !!(this.days && this.days !== null || this.orient || this.operator); orient = ((this.orient === "past" || this.operator === "subtract") ? -1 : 1); if (this.month && this.unit === "week") { this.value = this.month + 1; delete this.month; delete this.day; } if ((this.month || this.month === 0) && "year day hour minute second".indexOf(this.unit) !== -1) { if (!this.value) { this.value = this.month + 1; } this.month = null; expression = true; } if (!expression && this.weekday && !this.day && !this.days) { finishUtils.setDMYFromWeekday.call(this); } if (expression && this.weekday && this.unit !== "month" && this.unit !== "week") { finishUtils.setDaysFromWeekday.call(this, today, orient); } if (this.weekday && this.unit !== "week" && !this.day && !this.days) { temp = Date[this.weekday](); this.day = temp.getDate(); if (temp.getMonth() !== today.getMonth()) { this.month = temp.getMonth(); } } if (this.month && this.unit === "day" && this.operator) { if (!this.value) { this.value = (this.month + 1); } this.month = null; } if (this.value != null && this.month != null && this.year != null) { this.day = this.value * 1; } if (this.month && !this.day && this.value) { today.set({ day: this.value * 1 }); if (!expression) { this.day = this.value * 1; } } if (!this.month && this.value && this.unit === "month" && !this.now) { this.month = this.value; expression = true; } if (expression && (this.month || this.month === 0) && this.unit !== "year") { finishUtils.setMonthsFromMonth.call(this, today, orient); } if (!this.unit) { this.unit = "day"; } finishUtils.setUnitValue.call(this, orient); parseMeridian.call(this); if ((this.month || this.month === 0) && !this.day) { this.day = 1; } if (!this.orient && !this.operator && this.unit === "week" && this.value && !this.day && !this.month) { return Date.today().setWeek(this.value); } if (this.unit === "week" && this.weeks && !this.day && !this.month) { return finishUtils.generateDateFromWeeks.call(this); } if (expression && this.timezone && this.day && this.days) { this.day = this.days; } if (expression){ today.add(this); } else { today.set(this); } if (this.timezone) { this.timezone = this.timezone.toUpperCase(); var offset = $D.getTimezoneOffset(this.timezone); var timezone; if (today.hasDaylightSavingTime()) { // lets check that we're being sane with timezone setting timezone = $D.getTimezoneAbbreviation(offset, today.isDaylightSavingTime()); if (timezone !== this.timezone) { // bugger, we're in a place where things like EST vs EDT matters. if (today.isDaylightSavingTime()) { today.addHours(-1); } else { today.addHours(1); } } } today.setTimezoneOffset(offset); } return today; } }; }()); (function () { var $D = Date; $D.Grammar = {}; var _ = $D.Parsing.Operators, g = $D.Grammar, t = $D.Translator, _fn; // Allow rolling up into general purpose rules _fn = function () { return _.each(_.any.apply(null, arguments), _.not(g.ctoken2("timeContext"))); }; g.datePartDelimiter = _.rtoken(/^([\s\-\.\,\/\x27]+)/); g.timePartDelimiter = _.stoken(":"); g.whiteSpace = _.rtoken(/^\s*/); g.generalDelimiter = _.rtoken(/^(([\s\,]|at|@|on)+)/); var _C = {}; g.ctoken = function (keys) { var fn = _C[keys]; if (! fn) { var c = Date.CultureInfo.regexPatterns; var kx = keys.split(/\s+/), px = []; for (var i = 0; i < kx.length ; i++) { px.push(_.replace(_.rtoken(c[kx[i]]), kx[i])); } fn = _C[keys] = _.any.apply(null, px); } return fn; }; g.ctoken2 = function (key) { return _.rtoken(Date.CultureInfo.regexPatterns[key]); }; var cacheProcessRtoken = function (key, token, type, eachToken) { if (eachToken) { g[key] = _.cache(_.process(_.each(_.rtoken(token),_.optional(g.ctoken2(eachToken))), type)); } else { g[key] = _.cache(_.process(_.rtoken(token), type)); } }; var cacheProcessCtoken = function (token, type) { return _.cache(_.process(g.ctoken2(token), type)); }; var _F = {}; //function cache var _get = function (f) { _F[f] = (_F[f] || g.format(f)[0]); return _F[f]; }; g.allformats = function (fx) { var rx = []; if (fx instanceof Array) { for (var i = 0; i < fx.length; i++) { rx.push(_get(fx[i])); } } else { rx.push(_get(fx)); } return rx; }; g.formats = function (fx) { if (fx instanceof Array) { var rx = []; for (var i = 0 ; i < fx.length ; i++) { rx.push(_get(fx[i])); } return _.any.apply(null, rx); } else { return _get(fx); } }; var grammarFormats = { timeFormats: function(){ var i, RTokenKeys = [ "h", "hh", "H", "HH", "m", "mm", "s", "ss", "ss.s", "z", "zz" ], RToken = [ /^(0[0-9]|1[0-2]|[1-9])/, /^(0[0-9]|1[0-2])/, /^([0-1][0-9]|2[0-3]|[0-9])/, /^([0-1][0-9]|2[0-3])/, /^([0-5][0-9]|[0-9])/, /^[0-5][0-9]/, /^([0-5][0-9]|[0-9])/, /^[0-5][0-9]/, /^[0-5][0-9]\.[0-9]{1,3}/, /^((\+|\-)\s*\d\d\d\d)|((\+|\-)\d\d\:?\d\d)/, /^((\+|\-)\s*\d\d\d\d)|((\+|\-)\d\d\:?\d\d)/ ], tokens = [ t.hour, t.hour, t.hour, t.hour, t.minute, t.minute, t.second, t.second, t.secondAndMillisecond, t.timezone, t.timezone ]; for (i=0; i < RTokenKeys.length; i++) { cacheProcessRtoken(RTokenKeys[i], RToken[i], tokens[i]); } g.hms = _.cache(_.sequence([g.H, g.m, g.s], g.timePartDelimiter)); g.t = cacheProcessCtoken("shortMeridian", t.meridian); g.tt = cacheProcessCtoken("longMeridian", t.meridian); g.zzz = cacheProcessCtoken("timezone", t.timezone); g.timeSuffix = _.each(_.ignore(g.whiteSpace), _.set([ g.tt, g.zzz ])); g.time = _.each(_.optional(_.ignore(_.stoken("T"))), g.hms, g.timeSuffix); }, dateFormats: function () { // pre-loaded rules for different date part order preferences var _setfn = function () { return _.set(arguments, g.datePartDelimiter); }; var i, RTokenKeys = [ "d", "dd", "M", "MM", "y", "yy", "yyy", "yyyy" ], RToken = [ /^([0-2]\d|3[0-1]|\d)/, /^([0-2]\d|3[0-1])/, /^(1[0-2]|0\d|\d)/, /^(1[0-2]|0\d)/, /^(\d+)/, /^(\d\d)/, /^(\d\d?\d?\d?)/, /^(\d\d\d\d)/ ], tokens = [ t.day, t.day, t.month, t.month, t.year, t.year, t.year, t.year ], eachToken = [ "ordinalSuffix", "ordinalSuffix" ]; for (i=0; i < RTokenKeys.length; i++) { cacheProcessRtoken(RTokenKeys[i], RToken[i], tokens[i], eachToken[i]); } g.MMM = g.MMMM = _.cache(_.process(g.ctoken("jan feb mar apr may jun jul aug sep oct nov dec"), t.month)); g.ddd = g.dddd = _.cache(_.process(g.ctoken("sun mon tue wed thu fri sat"), function (s) { return function () { this.weekday = s; }; } )); g.day = _fn(g.d, g.dd); g.month = _fn(g.M, g.MMM); g.year = _fn(g.yyyy, g.yy); g.mdy = _setfn(g.ddd, g.month, g.day, g.year); g.ymd = _setfn(g.ddd, g.year, g.month, g.day); g.dmy = _setfn(g.ddd, g.day, g.month, g.year); g.date = function (s) { return ((g[Date.CultureInfo.dateElementOrder] || g.mdy).call(this, s)); }; }, relative: function () { // relative date / time expressions g.orientation = _.process(g.ctoken("past future"), function (s) { return function () { this.orient = s; }; } ); g.operator = _.process(g.ctoken("add subtract"), function (s) { return function () { this.operator = s; }; } ); g.rday = _.process(g.ctoken("yesterday tomorrow today now"), t.rday); g.unit = _.process(g.ctoken("second minute hour day week month year"), function (s) { return function () { this.unit = s; }; } ); } }; g.buildGrammarFormats = function () { // these need to be rebuilt every time the language changes. _C = {}; grammarFormats.timeFormats(); grammarFormats.dateFormats(); grammarFormats.relative(); g.value = _.process(_.rtoken(/^([-+]?\d+)?(st|nd|rd|th)?/), function (s) { return function () { this.value = s.replace(/\D/g, ""); }; } ); g.expression = _.set([g.rday, g.operator, g.value, g.unit, g.orientation, g.ddd, g.MMM ]); g.format = _.process(_.many( _.any( // translate format specifiers into grammar rules _.process( _.rtoken(/^(dd?d?d?(?!e)|MM?M?M?|yy?y?y?|hh?|HH?|mm?|ss?|tt?|zz?z?)/), function (fmt) { if (g[fmt]) { return g[fmt]; } else { throw $D.Parsing.Exception(fmt); } } ), // translate separator tokens into token rules _.process(_.rtoken(/^[^dMyhHmstz]+/), // all legal separators function (s) { return _.ignore(_.stoken(s)); } ) ) ), // construct the parser ... function (rules) { return _.process(_.each.apply(null, rules), t.finishExact); } ); // starting rule for general purpose grammar g._start = _.process(_.set([ g.date, g.time, g.expression ], g.generalDelimiter, g.whiteSpace), t.finish); }; g.buildGrammarFormats(); // parsing date format specifiers - ex: "h:m:s tt" // this little guy will generate a custom parser based // on the format string, ex: g.format("h:m:s tt") // check for these formats first g._formats = g.formats([ "\"yyyy-MM-ddTHH:mm:ssZ\"", "yyyy-MM-ddTHH:mm:ss.sz", "yyyy-MM-ddTHH:mm:ssZ", "yyyy-MM-ddTHH:mm:ssz", "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-ddTHH:mmZ", "yyyy-MM-ddTHH:mmz", "yyyy-MM-ddTHH:mm", "ddd, MMM dd, yyyy H:mm:ss tt", "ddd MMM d yyyy HH:mm:ss zzz", "MMddyyyy", "ddMMyyyy", "Mddyyyy", "ddMyyyy", "Mdyyyy", "dMyyyy", "yyyy", "Mdyy", "dMyy", "d" ]); // real starting rule: tries selected formats first, // then general purpose rule g.start = function (s) { try { var r = g._formats.call({}, s); if (r[1].length === 0) { return r; } } catch (e) {} return g._start.call({}, s); }; }()); (function () { var $D = Date; /** * @desc Converts the specified string value into its JavaScript Date equivalent using CultureInfo specific format information. * * Example

	///////////
	// Dates //
	///////////

	// 15-Oct-2004
	var d1 = Date.parse("10/15/2004");

	// 15-Oct-2004
	var d1 = Date.parse("15-Oct-2004");

	// 15-Oct-2004
	var d1 = Date.parse("2004.10.15");

	//Fri Oct 15, 2004
	var d1 = Date.parse("Fri Oct 15, 2004");

	///////////
	// Times //
	///////////

	// Today at 10 PM.
	var d1 = Date.parse("10 PM");

	// Today at 10:30 PM.
	var d1 = Date.parse("10:30 P.M.");

	// Today at 6 AM.
	var d1 = Date.parse("06am");

	/////////////////////
	// Dates and Times //
	/////////////////////

	// 8-July-2004 @ 10:30 PM
	var d1 = Date.parse("July 8th, 2004, 10:30 PM");

	// 1-July-2004 @ 10:30 PM
	var d1 = Date.parse("2004-07-01T22:30:00");

	////////////////////
	// Relative Dates //
	////////////////////

	// Returns today's date. The string "today" is culture specific.
	var d1 = Date.parse("today");

	// Returns yesterday's date. The string "yesterday" is culture specific.
	var d1 = Date.parse("yesterday");

	// Returns the date of the next thursday.
	var d1 = Date.parse("Next thursday");

	// Returns the date of the most previous monday.
	var d1 = Date.parse("last monday");

	// Returns today's day + one year.
	var d1 = Date.parse("next year");

	///////////////
	// Date Math //
	///////////////

	// Today + 2 days
	var d1 = Date.parse("t+2");

	// Today + 2 days
	var d1 = Date.parse("today + 2 days");

	// Today + 3 months
	var d1 = Date.parse("t+3m");

	// Today - 1 year
	var d1 = Date.parse("today - 1 year");

	// Today - 1 year
	var d1 = Date.parse("t-1y"); 


	/////////////////////////////
	// Partial Dates and Times //
	/////////////////////////////

	// July 15th of this year.
	var d1 = Date.parse("July 15");

	// 15th day of current day and year.
	var d1 = Date.parse("15");

	// July 1st of current year at 10pm.
	var d1 = Date.parse("7/1 10pm");
	
* * @param {String} The string value to convert into a Date object [Required] * @return {Date} A Date object or null if the string cannot be converted into a Date. */ var parseUtils = { removeOrds: function (s) { ords = s.match(/\b(\d+)(?:st|nd|rd|th)\b/); // find ordinal matches s = ((ords && ords.length === 2) ? s.replace(ords[0], ords[1]) : s); return s; }, grammarParser: function (s) { var r = null; try { r = $D.Grammar.start.call({}, s.replace(/^\s*(\S*(\s+\S+)*)\s*$/, "$1")); } catch (e) { return null; } return ((r[1].length === 0) ? r[0] : null); }, nativeFallback: function(s) { var t; try { // ok we haven't parsed it, last ditch attempt with the built-in parser. t = Date._parse(s); return (t || t === 0) ? new Date(t) : null; } catch (e) { return null; } } }; function parse (s) { var d; if (!s) { return null; } if (s instanceof Date) { return s.clone(); } if (s.length >= 4 && s.charAt(0) !== "0" && s.charAt(0) !== "+"&& s.charAt(0) !== "-") { // ie: 2004 will pass, 0800 won't. // Start with specific formats d = $D.Parsing.ISO.parse(s) || $D.Parsing.Numeric.parse(s); } if (d instanceof Date && !isNaN(d.getTime())) { return d; } else { // find ordinal dates (1st, 3rd, 8th, etc and remove them as they cause parsing issues) s = $D.Parsing.Normalizer.parse(parseUtils.removeOrds(s)); d = parseUtils.grammarParser(s); if (d !== null) { return d; } else { return parseUtils.nativeFallback(s); } } } if (!$D._parse) { $D._parse = $D.parse; } $D.parse = parse; Date.getParseFunction = function (fx) { var fns = Date.Grammar.allformats(fx); return function (s) { var r = null; for (var i = 0; i < fns.length; i++) { try { r = fns[i].call({}, s); } catch (e) { continue; } if (r[1].length === 0) { return r[0]; } } return null; }; }; /** * Converts the specified string value into its JavaScript Date equivalent using the specified format {String} or formats {Array} and the CultureInfo specific format information. * The format of the string value must match one of the supplied formats exactly. * * Example

	// 15-Oct-2004
	var d1 = Date.parseExact("10/15/2004", "M/d/yyyy");

	// 15-Oct-2004
	var d1 = Date.parse("15-Oct-2004", "M-ddd-yyyy");

	// 15-Oct-2004
	var d1 = Date.parse("2004.10.15", "yyyy.MM.dd");

	// Multiple formats
	var d1 = Date.parseExact("10/15/2004", ["M/d/yyyy", "MMMM d, yyyy"]);
	
* * @param {String} The string value to convert into a Date object [Required]. * @param {Object} The expected format {String} or an array of expected formats {Array} of the date string [Required]. * @return {Date} A Date object or null if the string cannot be converted into a Date. */ $D.parseExact = function (s, fx) { return $D.getParseFunction(fx)(s); }; }()); (function () { var $D = Date, $P = $D.prototype, // $C = $D.CultureInfo, // not used atm p = function (s, l) { if (!l) { l = 2; } return ("000" + s).slice(l * -1); }; /** * Converts a PHP format string to Java/.NET format string. * A PHP format string can be used with ._format or .format. * A Java/.NET format string can be used with .toString(). * The .parseExact function will only accept a Java/.NET format string * * Example * var f1 = "%m/%d/%y" * var f2 = Date.normalizeFormat(f1); // "MM/dd/yy" * * new Date().format(f1); // "04/13/08" * new Date()._format(f1); // "04/13/08" * new Date().toString(f2); // "04/13/08" * * var date = Date.parseExact("04/13/08", f2); // Sun Apr 13 2008 * * @param {String} A PHP format string consisting of one or more format spcifiers. * @return {String} The PHP format converted to a Java/.NET format string. */ var normalizerSubstitutions = { "d" : "dd", "%d": "dd", "D" : "ddd", "%a": "ddd", "j" : "dddd", "l" : "dddd", "%A": "dddd", "S" : "S", "F" : "MMMM", "%B": "MMMM", "m" : "MM", "%m": "MM", "M" : "MMM", "%b": "MMM", "%h": "MMM", "n" : "M", "Y" : "yyyy", "%Y": "yyyy", "y" : "yy", "%y": "yy", "g" : "h", "%I": "h", "G" : "H", "h" : "hh", "H" : "HH", "%H": "HH", "i" : "mm", "%M": "mm", "s" : "ss", "%S": "ss", "%r": "hh:mm tt", "%R": "H:mm", "%T": "H:mm:ss", "%X": "t", "%x": "d", "%e": "d", "%D": "MM/dd/yy", "%n": "\\n", "%t": "\\t", "e" : "z", "T" : "z", "%z": "z", "%Z": "z", "Z" : "ZZ", "N" : "u", "w" : "u", "%w": "u", "W" : "W", "%V": "W" }; var normalizer = { substitutes: function (m) { return normalizerSubstitutions[m]; }, interpreted: function (m, x) { var y; switch (m) { case "%u": return x.getDay() + 1; case "z": return x.getOrdinalNumber(); case "%j": return p(x.getOrdinalNumber(), 3); case "%U": var d1 = x.clone().set({month: 0, day: 1}).addDays(-1).moveToDayOfWeek(0), d2 = x.clone().addDays(1).moveToDayOfWeek(0, -1); return (d2 < d1) ? "00" : p((d2.getOrdinalNumber() - d1.getOrdinalNumber()) / 7 + 1); case "%W": return p(x.getWeek()); case "t": return $D.getDaysInMonth(x.getFullYear(), x.getMonth()); case "o": case "%G": return x.setWeek(x.getISOWeek()).toString("yyyy"); case "%g": return x._format("%G").slice(-2); case "a": case "%p": return t("tt").toLowerCase(); case "A": return t("tt").toUpperCase(); case "u": return p(x.getMilliseconds(), 3); case "I": return (x.isDaylightSavingTime()) ? 1 : 0; case "O": return x.getUTCOffset(); case "P": y = x.getUTCOffset(); return y.substring(0, y.length - 2) + ":" + y.substring(y.length - 2); case "B": var now = new Date(); return Math.floor(((now.getHours() * 3600) + (now.getMinutes() * 60) + now.getSeconds() + (now.getTimezoneOffset() + 60) * 60) / 86.4); case "c": return x.toISOString().replace(/\"/g, ""); case "U": return $D.strtotime("now"); case "%c": return t("d") + " " + t("t"); case "%C": return Math.floor(x.getFullYear() / 100 + 1); } }, shouldOverrideDefaults: function (m) { switch (m) { case "%e": return true; default: return false; } }, parse: function (m, context) { var formatString, c = context || new Date(); formatString = normalizer.substitutes(m); if (formatString) { return formatString; } formatString = normalizer.interpreted(m, c); if (formatString) { return formatString; } else { return m; } } }; $D.normalizeFormat = function (format, context) { return format.replace(/(%|\\)?.|%%/g, function(t){ return normalizer.parse(t, context); }); }; /** * Format a local Unix timestamp according to locale settings * * Example: * Date.strftime("%m/%d/%y", new Date()); // "04/13/08" * Date.strftime("c", "2008-04-13T17:52:03Z"); // "04/13/08" * * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @param {Number|String} The number representing the number of seconds that have elapsed since January 1, 1970 (local time). * @return {String} A string representation of the current Date object. */ $D.strftime = function (format, time) { var d = Date.parse(time); return d._format(format); }; /** * Parse any textual datetime description into a Unix timestamp. * A Unix timestamp is the number of seconds that have elapsed since January 1, 1970 (midnight UTC/GMT). * * Example: * Date.strtotime("04/13/08"); // 1208044800 * Date.strtotime("1970-01-01T00:00:00Z"); // 0 * * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @param {Object} A string or date object. * @return {String} A string representation of the current Date object. */ $D.strtotime = function (time) { var d = $D.parse(time); return Math.round($D.UTC(d.getUTCFullYear(), d.getUTCMonth(), d.getUTCDate(), d.getUTCHours(), d.getUTCMinutes(), d.getUTCSeconds(), d.getUTCMilliseconds()) / 1000); }; /** * Converts the value of the current Date object to its equivalent string representation using a PHP/Unix style of date format specifiers. * Format Specifiers * Format Description Example * ------ --------------------------------------------------------------------------- ----------------------- * %a abbreviated weekday name according to the current localed "Mon" through "Sun" * %A full weekday name according to the current localed "Sunday" through "Saturday" * %b abbreviated month name according to the current localed "Jan" through "Dec" * %B full month name according to the current locale "January" through "December" * %c preferred date and time representation for the current locale "4/13/2008 12:33 PM" * %C century number (the year divided by 100 and truncated to an integer) "00" to "99" * %d day of the month as a decimal number "01" to "31" * %D same as %m/%d/%y "04/13/08" * %e day of the month as a decimal number, a single digit is preceded by a space "1" to "31" * %g like %G, but without the century "08" * %G The 4-digit year corresponding to the ISO week number (see %V). "2008" * This has the same format and value as %Y, except that if the ISO week number * belongs to the previous or next year, that year is used instead. * %h same as %b "Jan" through "Dec" * %H hour as a decimal number using a 24-hour clock. "00" to "23" * %I hour as a decimal number using a 12-hour clock. "01" to "12" * %j day of the year as a decimal number. "001" to "366" * %m month as a decimal number. "01" to "12" * %M minute as a decimal number. "00" to "59" * %n newline character "\n" * %p either "am" or "pm" according to the given time value, or the "am" or "pm" * corresponding strings for the current locale. * %r time in a.m. and p.m. notation "8:44 PM" * %R time in 24 hour notation "20:44" * %S second as a decimal number "00" to "59" * %t tab character "\t" * %T current time, equal to %H:%M:%S "12:49:11" * %u weekday as a decimal number ["1", "7"], with "1" representing Monday "1" to "7" * %U week number of the current year as a decimal number, starting with the "0" to ("52" or "53") * first Sunday as the first day of the first week * %V The ISO 8601:1988 week number of the current year as a decimal number, "00" to ("52" or "53") * range 01 to 53, where week 1 is the first week that has at least 4 days * in the current year, and with Monday as the first day of the week. * (Use %G or %g for the year component that corresponds to the week number * for the specified timestamp.) * %W week number of the current year as a decimal number, starting with the "00" to ("52" or "53") * first Monday as the first day of the first week * %w day of the week as a decimal, Sunday being "0" "0" to "6" * %x preferred date representation for the current locale without the time "4/13/2008" * %X preferred time representation for the current locale without the date "12:53:05" * %y year as a decimal number without a century "00" "99" * %Y year as a decimal number including the century "2008" * %Z time zone or name or abbreviation "UTC", "EST", "PST" * %z same as %Z * %% a literal "%" characters "%" * d Day of the month, 2 digits with leading zeros "01" to "31" * D A textual representation of a day, three letters "Mon" through "Sun" * j Day of the month without leading zeros "1" to "31" * l A full textual representation of the day of the week (lowercase "L") "Sunday" through "Saturday" * N ISO-8601 numeric representation of the day of the week (added in PHP 5.1.0) "1" (for Monday) through "7" (for Sunday) * S English ordinal suffix for the day of the month, 2 characters "st", "nd", "rd" or "th". Works well with j * w Numeric representation of the day of the week "0" (for Sunday) through "6" (for Saturday) * z The day of the year (starting from "0") "0" through "365" * W ISO-8601 week number of year, weeks starting on Monday "00" to ("52" or "53") * F A full textual representation of a month, such as January or March "January" through "December" * m Numeric representation of a month, with leading zeros "01" through "12" * M A short textual representation of a month, three letters "Jan" through "Dec" * n Numeric representation of a month, without leading zeros "1" through "12" * t Number of days in the given month "28" through "31" * L Whether it's a leap year "1" if it is a leap year, "0" otherwise * o ISO-8601 year number. This has the same value as Y, except that if the "2008" * ISO week number (W) belongs to the previous or next year, that year * is used instead. * Y A full numeric representation of a year, 4 digits "2008" * y A two digit representation of a year "08" * a Lowercase Ante meridiem and Post meridiem "am" or "pm" * A Uppercase Ante meridiem and Post meridiem "AM" or "PM" * B Swatch Internet time "000" through "999" * g 12-hour format of an hour without leading zeros "1" through "12" * G 24-hour format of an hour without leading zeros "0" through "23" * h 12-hour format of an hour with leading zeros "01" through "12" * H 24-hour format of an hour with leading zeros "00" through "23" * i Minutes with leading zeros "00" to "59" * s Seconds, with leading zeros "00" through "59" * u Milliseconds "54321" * e Timezone identifier "UTC", "EST", "PST" * I Whether or not the date is in daylight saving time (uppercase i) "1" if Daylight Saving Time, "0" otherwise * O Difference to Greenwich time (GMT) in hours "+0200", "-0600" * P Difference to Greenwich time (GMT) with colon between hours and minutes "+02:00", "-06:00" * T Timezone abbreviation "UTC", "EST", "PST" * Z Timezone offset in seconds. The offset for timezones west of UTC is "-43200" through "50400" * always negative, and for those east of UTC is always positive. * c ISO 8601 date "2004-02-12T15:19:21+00:00" * r RFC 2822 formatted date "Thu, 21 Dec 2000 16:01:07 +0200" * U Seconds since the Unix Epoch (January 1 1970 00:00:00 GMT) "0" * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @return {String} A string representation of the current Date object. */ var formatReplace = function (context) { return function (m) { var formatString, override = false; if (m.charAt(0) === "\\" || m.substring(0, 2) === "%%") { return m.replace("\\", "").replace("%%", "%"); } override = normalizer.shouldOverrideDefaults(m); formatString = $D.normalizeFormat(m, context); if (formatString) { return context.toString(formatString, override); } }; }; $P._format = function (format) { var formatter = formatReplace(this); if (!format) { return this._toString(); } else { return format.replace(/(%|\\)?.|%%/g, formatter); } }; if (!$P.format) { $P.format = $P._format; } }()); (function () { "use strict"; var gFn = function (attr) { return function () { return this[attr]; }; }; var sFn = function (attr) { return function (val) { this[attr] = val; return this; }; }; var attrs = ["years", "months", "days", "hours", "minutes", "seconds", "milliseconds"]; var addSetFuncs = function (context, attrs) { for (var i = 0; i < attrs.length ; i++) { var $a = attrs[i], $b = $a.slice(0, 1).toUpperCase() + $a.slice(1); context.prototype[$a] = 0; context.prototype["get" + $b] = gFn($a); context.prototype["set" + $b] = sFn($a); } }; /** * new TimeSpan(milliseconds); * new TimeSpan(days, hours, minutes, seconds); * new TimeSpan(days, hours, minutes, seconds, milliseconds); */ var TimeSpan = function (days, hours, minutes, seconds, milliseconds) { if (arguments.length === 1 && typeof days === "number") { var orient = (days < 0) ? -1 : +1; var millsLeft = Math.abs(days); this.setDays(Math.floor(millsLeft / 86400000) * orient); millsLeft = millsLeft % 86400000; this.setHours(Math.floor(millsLeft / 3600000) * orient); millsLeft = millsLeft % 3600000; this.setMinutes(Math.floor(millsLeft / 60000) * orient); millsLeft = millsLeft % 60000; this.setSeconds(Math.floor(millsLeft / 1000) * orient); millsLeft = millsLeft % 1000; this.setMilliseconds(millsLeft * orient); } else { this.set(days, hours, minutes, seconds, milliseconds); } this.getTotalMilliseconds = function () { return (this.getDays() * 86400000) + (this.getHours() * 3600000) + (this.getMinutes() * 60000) + (this.getSeconds() * 1000); }; this.compareTo = function (time) { var t1 = new Date(1970, 1, 1, this.getHours(), this.getMinutes(), this.getSeconds()), t2; if (time === null) { t2 = new Date(1970, 1, 1, 0, 0, 0); } else { t2 = new Date(1970, 1, 1, time.getHours(), time.getMinutes(), time.getSeconds()); } return (t1 < t2) ? -1 : (t1 > t2) ? 1 : 0; }; this.equals = function (time) { return (this.compareTo(time) === 0); }; this.add = function (time) { return (time === null) ? this : this.addSeconds(time.getTotalMilliseconds() / 1000); }; this.subtract = function (time) { return (time === null) ? this : this.addSeconds(-time.getTotalMilliseconds() / 1000); }; this.addDays = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 86400000)); }; this.addHours = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 3600000)); }; this.addMinutes = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 60000)); }; this.addSeconds = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 1000)); }; this.addMilliseconds = function (n) { return new TimeSpan(this.getTotalMilliseconds() + n); }; this.get12HourHour = function () { return (this.getHours() > 12) ? this.getHours() - 12 : (this.getHours() === 0) ? 12 : this.getHours(); }; this.getDesignator = function () { return (this.getHours() < 12) ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator; }; this.toString = function (format) { this._toString = function () { if (this.getDays() !== null && this.getDays() > 0) { return this.getDays() + "." + this.getHours() + ":" + this.p(this.getMinutes()) + ":" + this.p(this.getSeconds()); } else { return this.getHours() + ":" + this.p(this.getMinutes()) + ":" + this.p(this.getSeconds()); } }; this.p = function (s) { return (s.toString().length < 2) ? "0" + s : s; }; var me = this; return format ? format.replace(/dd?|HH?|hh?|mm?|ss?|tt?/g, function (format) { switch (format) { case "d": return me.getDays(); case "dd": return me.p(me.getDays()); case "H": return me.getHours(); case "HH": return me.p(me.getHours()); case "h": return me.get12HourHour(); case "hh": return me.p(me.get12HourHour()); case "m": return me.getMinutes(); case "mm": return me.p(me.getMinutes()); case "s": return me.getSeconds(); case "ss": return me.p(me.getSeconds()); case "t": return ((me.getHours() < 12) ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator).substring(0, 1); case "tt": return (me.getHours() < 12) ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator; } } ) : this._toString(); }; return this; }; addSetFuncs(TimeSpan, attrs.slice(2)); TimeSpan.prototype.set = function (days, hours, minutes, seconds, milliseconds){ this.setDays(days || this.getDays()); this.setHours(hours || this.getHours()); this.setMinutes(minutes || this.getMinutes()); this.setSeconds(seconds || this.getSeconds()); this.setMilliseconds(milliseconds || this.getMilliseconds()); }; /** * Gets the time of day for this date instances. * @return {TimeSpan} TimeSpan */ Date.prototype.getTimeOfDay = function () { return new TimeSpan(0, this.getHours(), this.getMinutes(), this.getSeconds(), this.getMilliseconds()); }; Date.TimeSpan = TimeSpan; if (typeof window !== "undefined" ) { // keeping API compatible for v1.x window.TimeSpan = TimeSpan; } }()); (function () { "use strict"; var attrs = ["years", "months", "days", "hours", "minutes", "seconds", "milliseconds"]; var gFn = function (attr) { return function () { return this[attr]; }; }; var sFn = function (attr) { return function (val) { this[attr] = val; return this; }; }; var addSetFuncs = function (context, attrs) { for (var i = 0; i < attrs.length ; i++) { var $a = attrs[i], $b = $a.slice(0, 1).toUpperCase() + $a.slice(1); context.prototype[$a] = 0; context.prototype["get" + $b] = gFn($a); context.prototype["set" + $b] = sFn($a); } }; var setMonthsAndYears = function (orient, d1, d2, context) { function inc() { d1.addMonths(-orient); context.months++; if (context.months === 12) { context.years++; context.months = 0; } } if (orient === +1) { while (d1 > d2) { inc(); } } else { while (d1 < d2) { inc(); } } context.months--; context.months *= orient; context.years *= orient; }; var adjustForDST = function(orient, startDate, endDate) { var hasDSTMismatch = (false === (startDate.isDaylightSavingTime() === endDate.isDaylightSavingTime())); if (hasDSTMismatch && orient === 1) { startDate.addHours(-1); } else if (hasDSTMismatch) { startDate.addHours(1); } }; /** * TimePeriod(startDate, endDate); * TimePeriod(years, months, days, hours, minutes, seconds, milliseconds); */ var TimePeriod = function (years, months, days, hours, minutes, seconds, milliseconds) { if (arguments.length === 7) { this.set(years, months, days, hours, minutes, seconds, milliseconds); } else if (arguments.length === 2 && arguments[0] instanceof Date && arguments[1] instanceof Date) { var startDate = arguments[0].clone(); var endDate = arguments[1].clone(); var orient = (startDate > endDate) ? +1 : -1; this.dates = { start: arguments[0].clone(), end: arguments[1].clone() }; setMonthsAndYears(orient, startDate, endDate, this); adjustForDST(orient, startDate, endDate); // // TODO - adjust for DST var diff = endDate - startDate; if (diff !== 0) { var ts = new TimeSpan(diff); this.set(this.years, this.months, ts.getDays(), ts.getHours(), ts.getMinutes(), ts.getSeconds(), ts.getMilliseconds()); } } return this; }; // create all the set functions. addSetFuncs(TimePeriod, attrs); TimePeriod.prototype.set = function (years, months, days, hours, minutes, seconds, milliseconds){ this.setYears(years || this.getYears()); this.setMonths(months || this.getMonths()); this.setDays(days || this.getDays()); this.setHours(hours || this.getHours()); this.setMinutes(minutes || this.getMinutes()); this.setSeconds(seconds || this.getSeconds()); this.setMilliseconds(milliseconds || this.getMilliseconds()); }; Date.TimePeriod = TimePeriod; if (typeof window !== "undefined") { // keeping API compatible for v1.x window.TimePeriod = TimePeriod; } }()); ================================================ FILE: build/date-ms-MY.js ================================================ /** * @overview datejs * @version 1.0.0-rc3 * @author Gregory Wild-Smith * @copyright 2015 Gregory Wild-Smith * @license MIT * @homepage https://github.com/abritinthebay/datejs */ /* * DateJS Culture String File * Country Code: ms-MY * Name: Malay (Malaysia) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["ms-MY"] = { "name": "ms-MY", "englishName": "Malay (Malaysia)", "nativeName": "Bahasa Malaysia (Malaysia)", "Sunday": "Ahad", "Monday": "Isnin", "Tuesday": "Selasa", "Wednesday": "Rabu", "Thursday": "Khamis", "Friday": "Jumaat", "Saturday": "Sabtu", "Sun": "Ahad", "Mon": "Isnin", "Tue": "Sel", "Wed": "Rabu", "Thu": "Khamis", "Fri": "Jumaat", "Sat": "Sabtu", "Su": "A", "Mo": "I", "Tu": "S", "We": "R", "Th": "K", "Fr": "J", "Sa": "S", "S_Sun_Initial": "A", "M_Mon_Initial": "I", "T_Tue_Initial": "S", "W_Wed_Initial": "R", "T_Thu_Initial": "K", "F_Fri_Initial": "J", "S_Sat_Initial": "S", "January": "Januari", "February": "Februari", "March": "Mac", "April": "April", "May": "Mei", "June": "Jun", "July": "Julai", "August": "Ogos", "September": "September", "October": "Oktober", "November": "November", "December": "Disember", "Jan_Abbr": "Jan", "Feb_Abbr": "Feb", "Mar_Abbr": "Mac", "Apr_Abbr": "Apr", "May_Abbr": "Mei", "Jun_Abbr": "Jun", "Jul_Abbr": "Jul", "Aug_Abbr": "Ogos", "Sep_Abbr": "Sept", "Oct_Abbr": "Okt", "Nov_Abbr": "Nov", "Dec_Abbr": "Dis", "AM": "", "PM": "", "firstDayOfWeek": 1, "twoDigitYearMax": 2029, "mdy": "dmy", "M/d/yyyy": "dd/MM/yyyy", "dddd, MMMM dd, yyyy": "dd MMMM yyyy", "h:mm tt": "H:mm", "h:mm:ss tt": "H:mm:ss", "dddd, MMMM dd, yyyy h:mm:ss tt": "dd MMMM yyyy H:mm:ss", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "dd MMMM", "MMMM, yyyy": "MMMM yyyy", "/jan(uary)?/": "jan(uari)?", "/feb(ruary)?/": "feb(ruari)?", "/mar(ch)?/": "mac", "/apr(il)?/": "apr(il)?", "/may/": "mei", "/jun(e)?/": "jun", "/jul(y)?/": "jul(ai)?", "/aug(ust)?/": "ogos", "/sep(t(ember)?)?/": "sep(t(ember)?)?", "/oct(ober)?/": "okt(ober)?", "/nov(ember)?/": "nov(ember)?", "/dec(ember)?/": "dis(ember)?", "/^su(n(day)?)?/": "^a(1)?", "/^mo(n(day)?)?/": "^i(1)?", "/^tu(e(s(day)?)?)?/": "^s(el(asa)?)?", "/^we(d(nesday)?)?/": "^r(1)?", "/^th(u(r(s(day)?)?)?)?/": "^k(1)?", "/^fr(i(day)?)?/": "^j(1)?", "/^sa(t(urday)?)?/": "^s(1)?", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "ms-MY"; /** * @overview datejs * @version 1.0.0-rc3 * @author Gregory Wild-Smith * @copyright 2015 Gregory Wild-Smith * @license MIT * @homepage https://github.com/abritinthebay/datejs */(function () { var $D = Date; var lang = Date.CultureStrings ? Date.CultureStrings.lang : null; var loggedKeys = {}; // for debug purposes. var getText = { getFromKey: function (key, countryCode) { var output; if (Date.CultureStrings && Date.CultureStrings[countryCode] && Date.CultureStrings[countryCode][key]) { output = Date.CultureStrings[countryCode][key]; } else { output = getText.buildFromDefault(key); } if (key.charAt(0) === "/") { // Assume it's a regex output = getText.buildFromRegex(key, countryCode); } return output; }, getFromObjectValues: function (obj, countryCode) { var key, output = {}; for(key in obj) { if (obj.hasOwnProperty(key)) { output[key] = getText.getFromKey(obj[key], countryCode); } } return output; }, getFromObjectKeys: function (obj, countryCode) { var key, output = {}; for(key in obj) { if (obj.hasOwnProperty(key)) { output[getText.getFromKey(key, countryCode)] = obj[key]; } } return output; }, getFromArray: function (arr, countryCode) { var output = []; for (var i=0; i < arr.length; i++){ if (i in arr) { output[i] = getText.getFromKey(arr[i], countryCode); } } return output; }, buildFromDefault: function (key) { var output, length, split, last; switch(key) { case "name": output = "en-US"; break; case "englishName": output = "English (United States)"; break; case "nativeName": output = "English (United States)"; break; case "twoDigitYearMax": output = 2049; break; case "firstDayOfWeek": output = 0; break; default: output = key; split = key.split("_"); length = split.length; if (length > 1 && key.charAt(0) !== "/") { // if the key isn't a regex and it has a split. last = split[(length - 1)].toLowerCase(); if (last === "initial" || last === "abbr") { output = split[0]; } } break; } return output; }, buildFromRegex: function (key, countryCode) { var output; if (Date.CultureStrings && Date.CultureStrings[countryCode] && Date.CultureStrings[countryCode][key]) { output = new RegExp(Date.CultureStrings[countryCode][key], "i"); } else { output = new RegExp(key.replace(new RegExp("/", "g"),""), "i"); } return output; } }; var shallowMerge = function (obj1, obj2) { for (var attrname in obj2) { if (obj2.hasOwnProperty(attrname)) { obj1[attrname] = obj2[attrname]; } } }; var __ = function (key, language) { var countryCode = (language) ? language : lang; loggedKeys[key] = key; if (typeof key === "object") { if (key instanceof Array) { return getText.getFromArray(key, countryCode); } else { return getText.getFromObjectKeys(key, countryCode); } } else { return getText.getFromKey(key, countryCode); } }; var loadI18nScript = function (code) { // paatterned after jQuery's getScript. var url = Date.Config.i18n + code + ".js"; var head = document.getElementsByTagName("head")[0] || document.documentElement; var script = document.createElement("script"); script.src = url; var completed = false; var events = { done: function (){} // placeholder function }; // Attach handlers for all browsers script.onload = script.onreadystatechange = function() { if ( !completed && (!this.readyState || this.readyState === "loaded" || this.readyState === "complete") ) { events.done(); head.removeChild(script); } }; setTimeout(function() { head.insertBefore(script, head.firstChild); }, 0); // allows return to execute first return { done: function (cb) { events.done = function() { if (cb) { setTimeout(cb,0); } }; } }; }; var buildInfo = { buildFromMethodHash: function (obj) { var key; for(key in obj) { if (obj.hasOwnProperty(key)) { obj[key] = buildInfo[obj[key]](); } } return obj; }, timeZoneDST: function () { var DST = { "CHADT": "+1345", "NZDT": "+1300", "AEDT": "+1100", "ACDT": "+1030", "AZST": "+0500", "IRDT": "+0430", "EEST": "+0300", "CEST": "+0200", "BST": "+0100", "PMDT": "-0200", "ADT": "-0300", "NDT": "-0230", "EDT": "-0400", "CDT": "-0500", "MDT": "-0600", "PDT": "-0700", "AKDT": "-0800", "HADT": "-0900" }; return __(DST); }, timeZoneStandard: function () { var standard = { "LINT": "+1400", "TOT": "+1300", "CHAST": "+1245", "NZST": "+1200", "NFT": "+1130", "SBT": "+1100", "AEST": "+1000", "ACST": "+0930", "JST": "+0900", "CWST": "+0845", "CT": "+0800", "ICT": "+0700", "MMT": "+0630", "BST": "+0600", "NPT": "+0545", "IST": "+0530", "PKT": "+0500", "AFT": "+0430", "MSK": "+0400", "IRST": "+0330", "FET": "+0300", "EET": "+0200", "CET": "+0100", "GMT": "+0000", "UTC": "+0000", "CVT": "-0100", "GST": "-0200", "BRT": "-0300", "NST": "-0330", "AST": "-0400", "EST": "-0500", "CST": "-0600", "MST": "-0700", "PST": "-0800", "AKST": "-0900", "MIT": "-0930", "HST": "-1000", "SST": "-1100", "BIT": "-1200" }; return __(standard); }, timeZones: function (data) { var zone; data.timezones = []; for (zone in data.abbreviatedTimeZoneStandard) { if (data.abbreviatedTimeZoneStandard.hasOwnProperty(zone)) { data.timezones.push({ name: zone, offset: data.abbreviatedTimeZoneStandard[zone]}); } } for (zone in data.abbreviatedTimeZoneDST) { if (data.abbreviatedTimeZoneDST.hasOwnProperty(zone)) { data.timezones.push({ name: zone, offset: data.abbreviatedTimeZoneDST[zone], dst: true}); } } return data.timezones; }, days: function () { return __(["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"]); }, dayAbbr: function () { return __(["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"]); }, dayShortNames: function () { return __(["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"]); }, dayFirstLetters: function () { return __(["S_Sun_Initial", "M_Mon_Initial", "T_Tues_Initial", "W_Wed_Initial", "T_Thu_Initial", "F_Fri_Initial", "S_Sat_Initial"]); }, months: function () { return __(["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"]); }, monthAbbr: function () { return __(["Jan_Abbr", "Feb_Abbr", "Mar_Abbr", "Apr_Abbr", "May_Abbr", "Jun_Abbr", "Jul_Abbr", "Aug_Abbr", "Sep_Abbr", "Oct_Abbr", "Nov_Abbr", "Dec_Abbr"]); }, formatPatterns: function () { return getText.getFromObjectValues({ shortDate: "M/d/yyyy", longDate: "dddd, MMMM dd, yyyy", shortTime: "h:mm tt", longTime: "h:mm:ss tt", fullDateTime: "dddd, MMMM dd, yyyy h:mm:ss tt", sortableDateTime: "yyyy-MM-ddTHH:mm:ss", universalSortableDateTime: "yyyy-MM-dd HH:mm:ssZ", rfc1123: "ddd, dd MMM yyyy HH:mm:ss", monthDay: "MMMM dd", yearMonth: "MMMM, yyyy" }, Date.i18n.currentLanguage()); }, regex: function () { return getText.getFromObjectValues({ inTheMorning: "/( in the )(morn(ing)?)\\b/", thisMorning: "/(this )(morn(ing)?)\\b/", amThisMorning: "/(\b\\d(am)? )(this )(morn(ing)?)/", inTheEvening: "/( in the )(even(ing)?)\\b/", thisEvening: "/(this )(even(ing)?)\\b/", pmThisEvening: "/(\b\\d(pm)? )(this )(even(ing)?)/", jan: "/jan(uary)?/", feb: "/feb(ruary)?/", mar: "/mar(ch)?/", apr: "/apr(il)?/", may: "/may/", jun: "/jun(e)?/", jul: "/jul(y)?/", aug: "/aug(ust)?/", sep: "/sep(t(ember)?)?/", oct: "/oct(ober)?/", nov: "/nov(ember)?/", dec: "/dec(ember)?/", sun: "/^su(n(day)?)?/", mon: "/^mo(n(day)?)?/", tue: "/^tu(e(s(day)?)?)?/", wed: "/^we(d(nesday)?)?/", thu: "/^th(u(r(s(day)?)?)?)?/", fri: "/fr(i(day)?)?/", sat: "/^sa(t(urday)?)?/", future: "/^next/", past: "/^last|past|prev(ious)?/", add: "/^(\\+|aft(er)?|from|hence)/", subtract: "/^(\\-|bef(ore)?|ago)/", yesterday: "/^yes(terday)?/", today: "/^t(od(ay)?)?/", tomorrow: "/^tom(orrow)?/", now: "/^n(ow)?/", millisecond: "/^ms|milli(second)?s?/", second: "/^sec(ond)?s?/", minute: "/^mn|min(ute)?s?/", hour: "/^h(our)?s?/", week: "/^w(eek)?s?/", month: "/^m(onth)?s?/", day: "/^d(ay)?s?/", year: "/^y(ear)?s?/", shortMeridian: "/^(a|p)/", longMeridian: "/^(a\\.?m?\\.?|p\\.?m?\\.?)/", timezone: "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/", ordinalSuffix: "/^\\s*(st|nd|rd|th)/", timeContext: "/^\\s*(\\:|a(?!u|p)|p)/" }, Date.i18n.currentLanguage()); } }; var CultureInfo = function () { var info = getText.getFromObjectValues({ name: "name", englishName: "englishName", nativeName: "nativeName", amDesignator: "AM", pmDesignator: "PM", firstDayOfWeek: "firstDayOfWeek", twoDigitYearMax: "twoDigitYearMax", dateElementOrder: "mdy" }, Date.i18n.currentLanguage()); var constructedInfo = buildInfo.buildFromMethodHash({ dayNames: "days", abbreviatedDayNames: "dayAbbr", shortestDayNames: "dayShortNames", firstLetterDayNames: "dayFirstLetters", monthNames: "months", abbreviatedMonthNames: "monthAbbr", formatPatterns: "formatPatterns", regexPatterns: "regex", abbreviatedTimeZoneDST: "timeZoneDST", abbreviatedTimeZoneStandard: "timeZoneStandard" }); shallowMerge(info, constructedInfo); buildInfo.timeZones(info); return info; }; $D.i18n = { __: function (key, lang) { return __(key, lang); }, currentLanguage: function () { return lang || "en-US"; }, setLanguage: function (code, force, cb) { var async = false; if (force || code === "en-US" || (!!Date.CultureStrings && !!Date.CultureStrings[code])) { lang = code; Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings.lang = code; Date.CultureInfo = new CultureInfo(); } else { if (!(!!Date.CultureStrings && !!Date.CultureStrings[code])) { if (typeof exports !== "undefined" && this.exports !== exports) { // we're in a Node enviroment, load it using require try { require("../i18n/" + code + ".js"); lang = code; Date.CultureStrings.lang = code; Date.CultureInfo = new CultureInfo(); } catch (e) { // var str = "The language for '" + code + "' could not be loaded by Node. It likely does not exist."; throw new Error("The DateJS IETF language tag '" + code + "' could not be loaded by Node. It likely does not exist."); } } else if (Date.Config && Date.Config.i18n) { // we know the location of the files, so lets load them async = true; loadI18nScript(code).done(function(){ lang = code; Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings.lang = code; Date.CultureInfo = new CultureInfo(); $D.Parsing.Normalizer.buildReplaceData(); // because this is async if ($D.Grammar) { $D.Grammar.buildGrammarFormats(); // so we can parse those strings... } if (cb) { setTimeout(cb,0); } }); } else { Date.console.error("The DateJS IETF language tag '" + code + "' is not available and has not been loaded."); return false; } } } $D.Parsing.Normalizer.buildReplaceData(); // rebuild normalizer strings if ($D.Grammar) { $D.Grammar.buildGrammarFormats(); // so we can parse those strings... } if (!async && cb) { setTimeout(cb,0); } }, getLoggedKeys: function () { return loggedKeys; }, updateCultureInfo: function () { Date.CultureInfo = new CultureInfo(); } }; $D.i18n.updateCultureInfo(); // run automatically }()); (function () { var $D = Date, $P = $D.prototype, p = function (s, l) { if (!l) { l = 2; } return ("000" + s).slice(l * -1); }; if (typeof window !== "undefined" && typeof window.console !== "undefined" && typeof window.console.log !== "undefined") { $D.console = console; // used only to raise non-critical errors if available } else { // set mock so we don't give errors. $D.console = { log: function(){}, error: function(){} }; } $D.Config = $D.Config || {}; $D.initOverloads = function() { /** * Overload of Date.now. Allows an alternate call for Date.now where it returns the * current Date as an object rather than just milliseconds since the Unix Epoch. * * Also provides an implementation of now() for browsers (IE<9) that don't have it. * * Backwards compatible so with work with either: * Date.now() [returns ms] * or * Date.now(true) [returns Date] */ if (!$D.now) { $D._now = function now() { return new Date().getTime(); }; } else if (!$D._now) { $D._now = $D.now; } $D.now = function (returnObj) { if (returnObj) { return $D.present(); } else { return $D._now(); } }; if ( !$P.toISOString ) { $P.toISOString = function() { return this.getUTCFullYear() + "-" + p(this.getUTCMonth() + 1) + "-" + p(this.getUTCDate()) + "T" + p(this.getUTCHours()) + ":" + p(this.getUTCMinutes()) + ":" + p(this.getUTCSeconds()) + "." + String( (this.getUTCMilliseconds()/1000).toFixed(3)).slice(2, 5) + "Z"; }; } // private if ( $P._toString === undefined ){ $P._toString = $P.toString; } }; $D.initOverloads(); /** * Gets a date that is set to the current date. The time is set to the start of the day (00:00 or 12:00 AM). * @return {Date} The current date. */ $D.today = function () { return new Date().clearTime(); }; /** * Gets a date that is set to the current date and time (same as new Date, but chainable) * @return {Date} The current date. */ $D.present = function () { return new Date(); }; /** * Compares the first date to the second date and returns an number indication of their relative values. * @param {Date} First Date object to compare [Required]. * @param {Date} Second Date object to compare to [Required]. * @return {Number} -1 = date1 is lessthan date2. 0 = values are equal. 1 = date1 is greaterthan date2. */ $D.compare = function (date1, date2) { if (isNaN(date1) || isNaN(date2)) { throw new Error(date1 + " - " + date2); } else if (date1 instanceof Date && date2 instanceof Date) { return (date1 < date2) ? -1 : (date1 > date2) ? 1 : 0; } else { throw new TypeError(date1 + " - " + date2); } }; /** * Compares the first Date object to the second Date object and returns true if they are equal. * @param {Date} First Date object to compare [Required] * @param {Date} Second Date object to compare to [Required] * @return {Boolean} true if dates are equal. false if they are not equal. */ $D.equals = function (date1, date2) { return (date1.compareTo(date2) === 0); }; /** * Gets the language appropriate day name when given the day number(0-6) * eg - 0 == Sunday * @return {String} The day name */ $D.getDayName = function (n) { return Date.CultureInfo.dayNames[n]; }; /** * Gets the day number (0-6) if given a CultureInfo specific string which is a valid dayName, abbreviatedDayName or shortestDayName (two char). * @param {String} The name of the day (eg. "Monday, "Mon", "tuesday", "tue", "We", "we"). * @return {Number} The day number */ $D.getDayNumberFromName = function (name) { var n = Date.CultureInfo.dayNames, m = Date.CultureInfo.abbreviatedDayNames, o = Date.CultureInfo.shortestDayNames, s = name.toLowerCase(); for (var i = 0; i < n.length; i++) { if (n[i].toLowerCase() === s || m[i].toLowerCase() === s || o[i].toLowerCase() === s) { return i; } } return -1; }; /** * Gets the month number (0-11) if given a Culture Info specific string which is a valid monthName or abbreviatedMonthName. * @param {String} The name of the month (eg. "February, "Feb", "october", "oct"). * @return {Number} The day number */ $D.getMonthNumberFromName = function (name) { var n = Date.CultureInfo.monthNames, m = Date.CultureInfo.abbreviatedMonthNames, s = name.toLowerCase(); for (var i = 0; i < n.length; i++) { if (n[i].toLowerCase() === s || m[i].toLowerCase() === s) { return i; } } return -1; }; /** * Gets the language appropriate month name when given the month number(0-11) * eg - 0 == January * @return {String} The month name */ $D.getMonthName = function (n) { return Date.CultureInfo.monthNames[n]; }; /** * Determines if the current date instance is within a LeapYear. * @param {Number} The year. * @return {Boolean} true if date is within a LeapYear, otherwise false. */ $D.isLeapYear = function (year) { return ((year % 4 === 0 && year % 100 !== 0) || year % 400 === 0); }; /** * Gets the number of days in the month, given a year and month value. Automatically corrects for LeapYear. * @param {Number} The year. * @param {Number} The month (0-11). * @return {Number} The number of days in the month. */ $D.getDaysInMonth = function (year, month) { if (!month && $D.validateMonth(year)) { month = year; year = Date.today().getFullYear(); } return [31, ($D.isLeapYear(year) ? 29 : 28), 31, 30, 31, 30, 31, 31, 30, 31, 30, 31][month]; }; $P.getDaysInMonth = function () { return $D.getDaysInMonth(this.getFullYear(), this.getMonth()); }; $D.getTimezoneAbbreviation = function (offset, dst) { var p, n = (dst || false) ? Date.CultureInfo.abbreviatedTimeZoneDST : Date.CultureInfo.abbreviatedTimeZoneStandard; for (p in n) { if (n.hasOwnProperty(p)) { if (n[p] === offset) { return p; } } } return null; }; $D.getTimezoneOffset = function (name, dst) { var i, a =[], z = Date.CultureInfo.timezones; if (!name) { name = (new Date()).getTimezone();} for (i = 0; i < z.length; i++) { if (z[i].name === name.toUpperCase()) { a.push(i); } } if (!z[a[0]]) { return null; } if (a.length === 1 || !dst) { return z[a[0]].offset; } else { for (i=0; i < a.length; i++) { if (z[a[i]].dst) { return z[a[i]].offset; } } } }; $D.getQuarter = function (d) { d = d || new Date(); // If no date supplied, use today var q = [1,2,3,4]; return q[Math.floor(d.getMonth() / 3)]; // ~~~ is a bitwise op. Faster than Math.floor }; $D.getDaysLeftInQuarter = function (d) { d = d || new Date(); var qEnd = new Date(d); qEnd.setMonth(qEnd.getMonth() + 3 - qEnd.getMonth() % 3, 0); return Math.floor((qEnd - d) / 8.64e7); }; // private var validate = function (n, min, max, name) { name = name ? name : "Object"; if (typeof n === "undefined") { return false; } else if (typeof n !== "number") { throw new TypeError(n + " is not a Number."); } else if (n < min || n > max) { // As failing validation is *not* an exceptional circumstance // lets not throw a RangeError Exception here. // It's semantically correct but it's not sensible. return false; } return true; }; /** * Validates the number is within an acceptable range for milliseconds [0-999]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateMillisecond = function (value) { return validate(value, 0, 999, "millisecond"); }; /** * Validates the number is within an acceptable range for seconds [0-59]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateSecond = function (value) { return validate(value, 0, 59, "second"); }; /** * Validates the number is within an acceptable range for minutes [0-59]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateMinute = function (value) { return validate(value, 0, 59, "minute"); }; /** * Validates the number is within an acceptable range for hours [0-23]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateHour = function (value) { return validate(value, 0, 23, "hour"); }; /** * Validates the number is within an acceptable range for the days in a month [0-MaxDaysInMonth]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateDay = function (value, year, month) { if (year === undefined || year === null || month === undefined || month === null) { return false;} return validate(value, 1, $D.getDaysInMonth(year, month), "day"); }; /** * Validates the number is within an acceptable range for months [0-11]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateWeek = function (value) { return validate(value, 0, 53, "week"); }; /** * Validates the number is within an acceptable range for months [0-11]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateMonth = function (value) { return validate(value, 0, 11, "month"); }; /** * Validates the number is within an acceptable range for years. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateYear = function (value) { /** * Per ECMAScript spec the range of times supported by Date objects is * exactly -100,000,000 days to +100,000,000 days measured relative to * midnight at the beginning of 01 January, 1970 UTC. * This gives a range of 8,640,000,000,000,000 milliseconds to either * side of 01 January, 1970 UTC. * * Earliest possible date: Tue, 20 Apr 271,822 B.C. 00:00:00 UTC * Latest possible date: Sat, 13 Sep 275,760 00:00:00 UTC */ return validate(value, -271822, 275760, "year"); }; $D.validateTimezone = function(value) { var timezones = {"ACDT":1,"ACST":1,"ACT":1,"ADT":1,"AEDT":1,"AEST":1,"AFT":1,"AKDT":1,"AKST":1,"AMST":1,"AMT":1,"ART":1,"AST":1,"AWDT":1,"AWST":1,"AZOST":1,"AZT":1,"BDT":1,"BIOT":1,"BIT":1,"BOT":1,"BRT":1,"BST":1,"BTT":1,"CAT":1,"CCT":1,"CDT":1,"CEDT":1,"CEST":1,"CET":1,"CHADT":1,"CHAST":1,"CHOT":1,"ChST":1,"CHUT":1,"CIST":1,"CIT":1,"CKT":1,"CLST":1,"CLT":1,"COST":1,"COT":1,"CST":1,"CT":1,"CVT":1,"CWST":1,"CXT":1,"DAVT":1,"DDUT":1,"DFT":1,"EASST":1,"EAST":1,"EAT":1,"ECT":1,"EDT":1,"EEDT":1,"EEST":1,"EET":1,"EGST":1,"EGT":1,"EIT":1,"EST":1,"FET":1,"FJT":1,"FKST":1,"FKT":1,"FNT":1,"GALT":1,"GAMT":1,"GET":1,"GFT":1,"GILT":1,"GIT":1,"GMT":1,"GST":1,"GYT":1,"HADT":1,"HAEC":1,"HAST":1,"HKT":1,"HMT":1,"HOVT":1,"HST":1,"ICT":1,"IDT":1,"IOT":1,"IRDT":1,"IRKT":1,"IRST":1,"IST":1,"JST":1,"KGT":1,"KOST":1,"KRAT":1,"KST":1,"LHST":1,"LINT":1,"MAGT":1,"MART":1,"MAWT":1,"MDT":1,"MET":1,"MEST":1,"MHT":1,"MIST":1,"MIT":1,"MMT":1,"MSK":1,"MST":1,"MUT":1,"MVT":1,"MYT":1,"NCT":1,"NDT":1,"NFT":1,"NPT":1,"NST":1,"NT":1,"NUT":1,"NZDT":1,"NZST":1,"OMST":1,"ORAT":1,"PDT":1,"PET":1,"PETT":1,"PGT":1,"PHOT":1,"PHT":1,"PKT":1,"PMDT":1,"PMST":1,"PONT":1,"PST":1,"PYST":1,"PYT":1,"RET":1,"ROTT":1,"SAKT":1,"SAMT":1,"SAST":1,"SBT":1,"SCT":1,"SGT":1,"SLST":1,"SRT":1,"SST":1,"SYOT":1,"TAHT":1,"THA":1,"TFT":1,"TJT":1,"TKT":1,"TLT":1,"TMT":1,"TOT":1,"TVT":1,"UCT":1,"ULAT":1,"UTC":1,"UYST":1,"UYT":1,"UZT":1,"VET":1,"VLAT":1,"VOLT":1,"VOST":1,"VUT":1,"WAKT":1,"WAST":1,"WAT":1,"WEDT":1,"WEST":1,"WET":1,"WST":1,"YAKT":1,"YEKT":1,"Z":1}; return (timezones[value] === 1); }; $D.validateTimezoneOffset= function(value) { // timezones go from +14hrs to -12hrs, the +X hours are negative offsets. return (value > -841 && value < 721); }; }()); (function () { var $D = Date, $P = $D.prototype, p = function (s, l) { if (!l) { l = 2; } return ("000" + s).slice(l * -1); }; var validateConfigObject = function (obj) { var result = {}, self = this, prop, testFunc; testFunc = function (prop, func, value) { if (prop === "day") { var month = (obj.month !== undefined) ? obj.month : self.getMonth(); var year = (obj.year !== undefined) ? obj.year : self.getFullYear(); return $D[func](value, year, month); } else { return $D[func](value); } }; for (prop in obj) { if (Object.prototype.hasOwnProperty.call(obj, prop)) { var func = "validate" + prop.charAt(0).toUpperCase() + prop.slice(1); if ($D[func] && obj[prop] !== null && testFunc(prop, func, obj[prop])) { result[prop] = obj[prop]; } } } return result; }; /** * Resets the time of this Date object to 12:00 AM (00:00), which is the start of the day. * @param {Boolean} .clone() this date instance before clearing Time * @return {Date} this */ $P.clearTime = function () { this.setHours(0); this.setMinutes(0); this.setSeconds(0); this.setMilliseconds(0); return this; }; /** * Resets the time of this Date object to the current time ('now'). * @return {Date} this */ $P.setTimeToNow = function () { var n = new Date(); this.setHours(n.getHours()); this.setMinutes(n.getMinutes()); this.setSeconds(n.getSeconds()); this.setMilliseconds(n.getMilliseconds()); return this; }; /** * Returns a new Date object that is an exact date and time copy of the original instance. * @return {Date} A new Date instance */ $P.clone = function () { return new Date(this.getTime()); }; /** * Compares this instance to a Date object and returns an number indication of their relative values. * @param {Date} Date object to compare [Required] * @return {Number} -1 = this is lessthan date. 0 = values are equal. 1 = this is greaterthan date. */ $P.compareTo = function (date) { return Date.compare(this, date); }; /** * Compares this instance to another Date object and returns true if they are equal. * @param {Date} Date object to compare. If no date to compare, new Date() [now] is used. * @return {Boolean} true if dates are equal. false if they are not equal. */ $P.equals = function (date) { return Date.equals(this, (date !== undefined ? date : new Date())); }; /** * Determines if this instance is between a range of two dates or equal to either the start or end dates. * @param {Date} Start of range [Required] * @param {Date} End of range [Required] * @return {Boolean} true is this is between or equal to the start and end dates, else false */ $P.between = function (start, end) { return this.getTime() >= start.getTime() && this.getTime() <= end.getTime(); }; /** * Determines if this date occurs after the date to compare to. * @param {Date} Date object to compare. If no date to compare, new Date() ("now") is used. * @return {Boolean} true if this date instance is greater than the date to compare to (or "now"), otherwise false. */ $P.isAfter = function (date) { return this.compareTo(date || new Date()) === 1; }; /** * Determines if this date occurs before the date to compare to. * @param {Date} Date object to compare. If no date to compare, new Date() ("now") is used. * @return {Boolean} true if this date instance is less than the date to compare to (or "now"). */ $P.isBefore = function (date) { return (this.compareTo(date || new Date()) === -1); }; /** * Determines if the current Date instance occurs today. * @return {Boolean} true if this date instance is 'today', otherwise false. */ /** * Determines if the current Date instance occurs on the same Date as the supplied 'date'. * If no 'date' to compare to is provided, the current Date instance is compared to 'today'. * @param {date} Date object to compare. If no date to compare, the current Date ("now") is used. * @return {Boolean} true if this Date instance occurs on the same Day as the supplied 'date'. */ $P.isToday = $P.isSameDay = function (date) { return this.clone().clearTime().equals((date || new Date()).clone().clearTime()); }; /** * Adds the specified number of milliseconds to this instance. * @param {Number} The number of milliseconds to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addMilliseconds = function (value) { if (!value) { return this; } this.setTime(this.getTime() + value * 1); return this; }; /** * Adds the specified number of seconds to this instance. * @param {Number} The number of seconds to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addSeconds = function (value) { if (!value) { return this; } return this.addMilliseconds(value * 1000); }; /** * Adds the specified number of seconds to this instance. * @param {Number} The number of seconds to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addMinutes = function (value) { if (!value) { return this; } return this.addMilliseconds(value * 60000); // 60*1000 }; /** * Adds the specified number of hours to this instance. * @param {Number} The number of hours to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addHours = function (value) { if (!value) { return this; } return this.addMilliseconds(value * 3600000); // 60*60*1000 }; /** * Adds the specified number of days to this instance. * @param {Number} The number of days to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addDays = function (value) { if (!value) { return this; } this.setDate(this.getDate() + value * 1); return this; }; /** * Adds the specified number of weekdays (ie - not sat or sun) to this instance. * @param {Number} The number of days to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addWeekdays = function (value) { if (!value) { return this; } var day = this.getDay(); var weeks = (Math.ceil(Math.abs(value)/7)); if (day === 0 || day === 6) { if (value > 0) { this.next().monday(); this.addDays(-1); day = this.getDay(); } } if (value < 0) { while (value < 0) { this.addDays(-1); day = this.getDay(); if (day !== 0 && day !== 6) { value++; } } return this; } else if (value > 5 || (6-day) <= value) { value = value + (weeks * 2); } return this.addDays(value); }; /** * Adds the specified number of weeks to this instance. * @param {Number} The number of weeks to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addWeeks = function (value) { if (!value) { return this; } return this.addDays(value * 7); }; /** * Adds the specified number of months to this instance. * @param {Number} The number of months to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addMonths = function (value) { if (!value) { return this; } var n = this.getDate(); this.setDate(1); this.setMonth(this.getMonth() + value * 1); this.setDate(Math.min(n, $D.getDaysInMonth(this.getFullYear(), this.getMonth()))); return this; }; $P.addQuarters = function (value) { if (!value) { return this; } // note this will take you to the same point in the quarter as you are now. // i.e. - if you are 15 days into the quarter you'll be 15 days into the resulting one. // bonus: this allows adding fractional quarters return this.addMonths(value * 3); }; /** * Adds the specified number of years to this instance. * @param {Number} The number of years to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addYears = function (value) { if (!value) { return this; } return this.addMonths(value * 12); }; /** * Adds (or subtracts) to the value of the years, months, weeks, days, hours, minutes, seconds, milliseconds of the date instance using given configuration object. Positive and Negative values allowed. * Example

	Date.today().add( { days: 1, months: 1 } )

	new Date().add( { years: -1 } )
	
* @param {Object} Configuration object containing attributes (months, days, etc.) * @return {Date} this */ $P.add = function (config) { if (typeof config === "number") { this._orient = config; return this; } var x = config; if (x.day) { // If we should be a different date than today (eg: for 'tomorrow -1d', etc). // Should only effect parsing, not direct usage (eg, Finish and FinishExact) if ((x.day - this.getDate()) !== 0) { this.setDate(x.day); } } if (x.milliseconds) { this.addMilliseconds(x.milliseconds); } if (x.seconds) { this.addSeconds(x.seconds); } if (x.minutes) { this.addMinutes(x.minutes); } if (x.hours) { this.addHours(x.hours); } if (x.weeks) { this.addWeeks(x.weeks); } if (x.months) { this.addMonths(x.months); } if (x.years) { this.addYears(x.years); } if (x.days) { this.addDays(x.days); } return this; }; /** * Get the week number. Week one (1) is the week which contains the first Thursday of the year. Monday is considered the first day of the week. * The .getWeek() function does NOT convert the date to UTC. The local datetime is used. * Please use .getISOWeek() to get the week of the UTC converted date. * @return {Number} 1 to 53 */ $P.getWeek = function (utc) { // Create a copy of this date object var self, target = new Date(this.valueOf()); if (utc) { target.addMinutes(target.getTimezoneOffset()); self = target.clone(); } else { self = this; } // ISO week date weeks start on monday // so correct the day number var dayNr = (self.getDay() + 6) % 7; // ISO 8601 states that week 1 is the week // with the first thursday of that year. // Set the target date to the thursday in the target week target.setDate(target.getDate() - dayNr + 3); // Store the millisecond value of the target date var firstThursday = target.valueOf(); // Set the target to the first thursday of the year // First set the target to january first target.setMonth(0, 1); // Not a thursday? Correct the date to the next thursday if (target.getDay() !== 4) { target.setMonth(0, 1 + ((4 - target.getDay()) + 7) % 7); } // The weeknumber is the number of weeks between the // first thursday of the year and the thursday in the target week return 1 + Math.ceil((firstThursday - target) / 604800000); // 604800000 = 7 * 24 * 3600 * 1000 }; /** * Get the ISO 8601 week number. Week one ("01") is the week which contains the first Thursday of the year. Monday is considered the first day of the week. * The .getISOWeek() function does convert the date to it's UTC value. Please use .getWeek() to get the week of the local date. * @return {String} "01" to "53" */ $P.getISOWeek = function () { return p(this.getWeek(true)); }; /** * Moves the date to Monday of the week set. Week one (1) is the week which contains the first Thursday of the year. * @param {Number} A Number (1 to 53) that represents the week of the year. * @return {Date} this */ $P.setWeek = function (n) { if ((n - this.getWeek()) === 0) { if (this.getDay() !== 1) { return this.moveToDayOfWeek(1, (this.getDay() > 1 ? -1 : 1)); } else { return this; } } else { return this.moveToDayOfWeek(1, (this.getDay() > 1 ? -1 : 1)).addWeeks(n - this.getWeek()); } }; $P.setQuarter = function (qtr) { var month = Math.abs(((qtr-1) * 3) + 1); return this.setMonth(month, 1); }; $P.getQuarter = function () { return Date.getQuarter(this); }; $P.getDaysLeftInQuarter = function () { return Date.getDaysLeftInQuarter(this); }; /** * Moves the date to the next n'th occurrence of the dayOfWeek starting from the beginning of the month. The number (-1) is a magic number and will return the last occurrence of the dayOfWeek in the month. * @param {Number} The dayOfWeek to move to * @param {Number} The n'th occurrence to move to. Use (-1) to return the last occurrence in the month * @return {Date} this */ $P.moveToNthOccurrence = function (dayOfWeek, occurrence) { if (dayOfWeek === "Weekday") { if (occurrence > 0) { this.moveToFirstDayOfMonth(); if (this.is().weekday()) { occurrence -= 1; } } else if (occurrence < 0) { this.moveToLastDayOfMonth(); if (this.is().weekday()) { occurrence += 1; } } else { return this; } return this.addWeekdays(occurrence); } var shift = 0; if (occurrence > 0) { shift = occurrence - 1; } else if (occurrence === -1) { this.moveToLastDayOfMonth(); if (this.getDay() !== dayOfWeek) { this.moveToDayOfWeek(dayOfWeek, -1); } return this; } return this.moveToFirstDayOfMonth().addDays(-1).moveToDayOfWeek(dayOfWeek, +1).addWeeks(shift); }; var moveToN = function (getFunc, addFunc, nVal) { return function (value, orient) { var diff = (value - this[getFunc]() + nVal * (orient || +1)) % nVal; return this[addFunc]((diff === 0) ? diff += nVal * (orient || +1) : diff); }; }; /** * Move to the next or last dayOfWeek based on the orient value. * @param {Number} The dayOfWeek to move to * @param {Number} Forward (+1) or Back (-1). Defaults to +1. [Optional] * @return {Date} this */ $P.moveToDayOfWeek = moveToN("getDay", "addDays", 7); /** * Move to the next or last month based on the orient value. * @param {Number} The month to move to. 0 = January, 11 = December * @param {Number} Forward (+1) or Back (-1). Defaults to +1. [Optional] * @return {Date} this */ $P.moveToMonth = moveToN("getMonth", "addMonths", 12); /** * Get the Ordinate of the current day ("th", "st", "rd"). * @return {String} */ $P.getOrdinate = function () { var num = this.getDate(); return ord(num); }; /** * Get the Ordinal day (numeric day number) of the year, adjusted for leap year. * @return {Number} 1 through 365 (366 in leap years) */ $P.getOrdinalNumber = function () { return Math.ceil((this.clone().clearTime() - new Date(this.getFullYear(), 0, 1)) / 86400000) + 1; }; /** * Get the time zone abbreviation of the current date. * @return {String} The abbreviated time zone name (e.g. "EST") */ $P.getTimezone = function () { return $D.getTimezoneAbbreviation(this.getUTCOffset(), this.isDaylightSavingTime()); }; $P.setTimezoneOffset = function (offset) { var here = this.getTimezoneOffset(), there = Number(offset) * -6 / 10; return (there || there === 0) ? this.addMinutes(there - here) : this; }; $P.setTimezone = function (offset) { return this.setTimezoneOffset($D.getTimezoneOffset(offset)); }; /** * Indicates whether Daylight Saving Time is observed in the current time zone. * @return {Boolean} true|false */ $P.hasDaylightSavingTime = function () { return (Date.today().set({month: 0, day: 1}).getTimezoneOffset() !== Date.today().set({month: 6, day: 1}).getTimezoneOffset()); }; /** * Indicates whether this Date instance is within the Daylight Saving Time range for the current time zone. * @return {Boolean} true|false */ $P.isDaylightSavingTime = function () { return Date.today().set({month: 0, day: 1}).getTimezoneOffset() !== this.getTimezoneOffset(); }; /** * Get the offset from UTC of the current date. * @return {String} The 4-character offset string prefixed with + or - (e.g. "-0500") */ $P.getUTCOffset = function (offset) { var n = (offset || this.getTimezoneOffset()) * -10 / 6, r; if (n < 0) { r = (n - 10000).toString(); return r.charAt(0) + r.substr(2); } else { r = (n + 10000).toString(); return "+" + r.substr(1); } }; /** * Returns the number of milliseconds between this date and date. * @param {Date} Defaults to now * @return {Number} The diff in milliseconds */ $P.getElapsed = function (date) { return (date || new Date()) - this; }; /** * Set the value of year, month, day, hour, minute, second, millisecond of date instance using given configuration object. * Example

	Date.today().set( { day: 20, month: 1 } )

	new Date().set( { millisecond: 0 } )
	
* * @param {Object} Configuration object containing attributes (month, day, etc.) * @return {Date} this */ $P.set = function (config) { config = validateConfigObject.call(this, config); var key; for (key in config) { if (Object.prototype.hasOwnProperty.call(config, key)) { var name = key.charAt(0).toUpperCase() + key.slice(1); var addFunc, getFunc; if (key !== "week" && key !== "month" && key !== "timezone" && key !== "timezoneOffset") { name += "s"; } addFunc = "add" + name; getFunc = "get" + name; if (key === "month") { addFunc = addFunc + "s"; } else if (key === "year"){ getFunc = "getFullYear"; } if (key !== "day" && key !== "timezone" && key !== "timezoneOffset" && key !== "week" && key !== "hour") { this[addFunc](config[key] - this[getFunc]()); } else if ( key === "timezone"|| key === "timezoneOffset" || key === "week" || key === "hour") { this["set"+name](config[key]); } } } // day has to go last because you can't validate the day without first knowing the month if (config.day) { this.addDays(config.day - this.getDate()); } return this; }; /** * Moves the date to the first day of the month. * @return {Date} this */ $P.moveToFirstDayOfMonth = function () { return this.set({ day: 1 }); }; /** * Moves the date to the last day of the month. * @return {Date} this */ $P.moveToLastDayOfMonth = function () { return this.set({ day: $D.getDaysInMonth(this.getFullYear(), this.getMonth())}); }; /** * Converts the value of the current Date object to its equivalent string representation. * Format Specifiers * CUSTOM DATE AND TIME FORMAT STRINGS * Format Description Example * ------ --------------------------------------------------------------------------- ----------------------- * s The seconds of the minute between 0-59. "0" to "59" * ss The seconds of the minute with leading zero if required. "00" to "59" * * m The minute of the hour between 0-59. "0" or "59" * mm The minute of the hour with leading zero if required. "00" or "59" * * h The hour of the day between 1-12. "1" to "12" * hh The hour of the day with leading zero if required. "01" to "12" * * H The hour of the day between 0-23. "0" to "23" * HH The hour of the day with leading zero if required. "00" to "23" * * d The day of the month between 1 and 31. "1" to "31" * dd The day of the month with leading zero if required. "01" to "31" * ddd Abbreviated day name. Date.CultureInfo.abbreviatedDayNames. "Mon" to "Sun" * dddd The full day name. Date.CultureInfo.dayNames. "Monday" to "Sunday" * * M The month of the year between 1-12. "1" to "12" * MM The month of the year with leading zero if required. "01" to "12" * MMM Abbreviated month name. Date.CultureInfo.abbreviatedMonthNames. "Jan" to "Dec" * MMMM The full month name. Date.CultureInfo.monthNames. "January" to "December" * * yy The year as a two-digit number. "99" or "08" * yyyy The full four digit year. "1999" or "2008" * * t Displays the first character of the A.M./P.M. designator. "A" or "P" * Date.CultureInfo.amDesignator or Date.CultureInfo.pmDesignator * tt Displays the A.M./P.M. designator. "AM" or "PM" * Date.CultureInfo.amDesignator or Date.CultureInfo.pmDesignator * * S The ordinal suffix ("st, "nd", "rd" or "th") of the current day. "st, "nd", "rd" or "th" * * STANDARD DATE AND TIME FORMAT STRINGS * Format Description Example *------ --------------------------------------------------------------------------- ----------------------- * d The CultureInfo shortDate Format Pattern "M/d/yyyy" * D The CultureInfo longDate Format Pattern "dddd, MMMM dd, yyyy" * F The CultureInfo fullDateTime Format Pattern "dddd, MMMM dd, yyyy h:mm:ss tt" * m The CultureInfo monthDay Format Pattern "MMMM dd" * r The CultureInfo rfc1123 Format Pattern "ddd, dd MMM yyyy HH:mm:ss GMT" * s The CultureInfo sortableDateTime Format Pattern "yyyy-MM-ddTHH:mm:ss" * t The CultureInfo shortTime Format Pattern "h:mm tt" * T The CultureInfo longTime Format Pattern "h:mm:ss tt" * u The CultureInfo universalSortableDateTime Format Pattern "yyyy-MM-dd HH:mm:ssZ" * y The CultureInfo yearMonth Format Pattern "MMMM, yyyy" * * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @return {String} A string representation of the current Date object. */ var ord = function (n) { switch (n * 1) { case 1: case 21: case 31: return "st"; case 2: case 22: return "nd"; case 3: case 23: return "rd"; default: return "th"; } }; var parseStandardFormats = function (format) { var y, c = Date.CultureInfo.formatPatterns; switch (format) { case "d": return this.toString(c.shortDate); case "D": return this.toString(c.longDate); case "F": return this.toString(c.fullDateTime); case "m": return this.toString(c.monthDay); case "r": case "R": y = this.clone().addMinutes(this.getTimezoneOffset()); return y.toString(c.rfc1123) + " GMT"; case "s": return this.toString(c.sortableDateTime); case "t": return this.toString(c.shortTime); case "T": return this.toString(c.longTime); case "u": y = this.clone().addMinutes(this.getTimezoneOffset()); return y.toString(c.universalSortableDateTime); case "y": return this.toString(c.yearMonth); default: return false; } }; var parseFormatStringsClosure = function (context) { return function (m) { if (m.charAt(0) === "\\") { return m.replace("\\", ""); } switch (m) { case "hh": return p(context.getHours() < 13 ? (context.getHours() === 0 ? 12 : context.getHours()) : (context.getHours() - 12)); case "h": return context.getHours() < 13 ? (context.getHours() === 0 ? 12 : context.getHours()) : (context.getHours() - 12); case "HH": return p(context.getHours()); case "H": return context.getHours(); case "mm": return p(context.getMinutes()); case "m": return context.getMinutes(); case "ss": return p(context.getSeconds()); case "s": return context.getSeconds(); case "yyyy": return p(context.getFullYear(), 4); case "yy": return p(context.getFullYear()); case "y": return context.getFullYear(); case "E": case "dddd": return Date.CultureInfo.dayNames[context.getDay()]; case "ddd": return Date.CultureInfo.abbreviatedDayNames[context.getDay()]; case "dd": return p(context.getDate()); case "d": return context.getDate(); case "MMMM": return Date.CultureInfo.monthNames[context.getMonth()]; case "MMM": return Date.CultureInfo.abbreviatedMonthNames[context.getMonth()]; case "MM": return p((context.getMonth() + 1)); case "M": return context.getMonth() + 1; case "t": return context.getHours() < 12 ? Date.CultureInfo.amDesignator.substring(0, 1) : Date.CultureInfo.pmDesignator.substring(0, 1); case "tt": return context.getHours() < 12 ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator; case "S": return ord(context.getDate()); case "W": return context.getWeek(); case "WW": return context.getISOWeek(); case "Q": return "Q" + context.getQuarter(); case "q": return String(context.getQuarter()); case "z": return context.getTimezone(); case "Z": case "X": return Date.getTimezoneOffset(context.getTimezone()); case "ZZ": // Timezone offset in seconds return context.getTimezoneOffset() * -60; case "u": return context.getDay(); case "L": return ($D.isLeapYear(context.getFullYear())) ? 1 : 0; case "B": // Swatch Internet Time (.beats) return "@"+((context.getUTCSeconds() + (context.getUTCMinutes()*60) + ((context.getUTCHours()+1)*3600))/86.4); default: return m; } }; }; $P.toString = function (format, ignoreStandards) { // Standard Date and Time Format Strings. Formats pulled from CultureInfo file and // may vary by culture. if (!ignoreStandards && format && format.length === 1) { output = parseStandardFormats.call(this, format); if (output) { return output; } } var parseFormatStrings = parseFormatStringsClosure(this); return format ? format.replace(/((\\)?(dd?d?d?|MM?M?M?|yy?y?y?|hh?|HH?|mm?|ss?|tt?|S|q|Q|WW?W?W?)(?![^\[]*\]))/g, parseFormatStrings).replace(/\[|\]/g, "") : this._toString(); }; }()); /************************************************************* * SugarPak - Domain Specific Language - Syntactical Sugar * *************************************************************/ (function () { var $D = Date, $P = $D.prototype, $N = Number.prototype; // private $P._orient = +1; // private $P._nth = null; // private $P._is = false; // private $P._same = false; // private $P._isSecond = false; // private $N._dateElement = "days"; /** * Moves the date to the next instance of a date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.today().next().friday();
	Date.today().next().fri();
	Date.today().next().march();
	Date.today().next().mar();
	Date.today().next().week();
	
* * @return {Date} date */ $P.next = function () { this._move = true; this._orient = +1; return this; }; /** * Creates a new Date (Date.today()) and moves the date to the next instance of the date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.next().friday();
	Date.next().fri();
	Date.next().march();
	Date.next().mar();
	Date.next().week();
	
* * @return {Date} date */ $D.next = function () { return $D.today().next(); }; /** * Moves the date to the previous instance of a date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.today().last().friday();
	Date.today().last().fri();
	Date.today().last().march();
	Date.today().last().mar();
	Date.today().last().week();
	
* * @return {Date} date */ $P.last = $P.prev = $P.previous = function () { this._move = true; this._orient = -1; return this; }; /** * Creates a new Date (Date.today()) and moves the date to the previous instance of the date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.last().friday();
	Date.last().fri();
	Date.previous().march();
	Date.prev().mar();
	Date.last().week();
	
* * @return {Date} date */ $D.last = $D.prev = $D.previous = function () { return $D.today().last(); }; /** * Performs a equality check when followed by either a month name, day name or .weekday() function. * Example

	Date.today().is().friday(); // true|false
	Date.today().is().fri();
	Date.today().is().march();
	Date.today().is().mar();
	
* * @return {Boolean} true|false */ $P.is = function () { this._is = true; return this; }; /** * Determines if two date objects occur on/in exactly the same instance of the subsequent date part function. * The function .same() must be followed by a date part function (example: .day(), .month(), .year(), etc). * * An optional Date can be passed in the date part function. If now date is passed as a parameter, 'Now' is used. * * The following example demonstrates how to determine if two dates fall on the exact same day. * * Example

	var d1 = Date.today(); // today at 00:00
	var d2 = new Date();   // exactly now.

	// Do they occur on the same day?
	d1.same().day(d2); // true
	
	// Do they occur on the same hour?
	d1.same().hour(d2); // false, unless d2 hour is '00' (midnight).
	
	// What if it's the same day, but one year apart?
	var nextYear = Date.today().add(1).year();

	d1.same().day(nextYear); // false, because the dates must occur on the exact same day. 
	
* * Scenario: Determine if a given date occurs during some week period 2 months from now. * * Example

	var future = Date.today().add(2).months();
	return someDate.same().week(future); // true|false;
	
* * @return {Boolean} true|false */ $P.same = function () { this._same = true; this._isSecond = false; return this; }; /** * Determines if the current date/time occurs during Today. Must be preceded by the .is() function. * Example

	someDate.is().today();    // true|false
	new Date().is().today();  // true
	Date.today().is().today();// true
	Date.today().add(-1).day().is().today(); // false
	
* * @return {Boolean} true|false */ $P.today = function () { return this.same().day(); }; /** * Determines if the current date is a weekday. This function must be preceded by the .is() function. * Example

	Date.today().is().weekday(); // true|false
	
* * @return {Boolean} true|false */ $P.weekday = function () { if (this._nth) { return df("Weekday").call(this); } if (this._move) { return this.addWeekdays(this._orient); } if (this._is) { this._is = false; return (!this.is().sat() && !this.is().sun()); } return false; }; /** * Determines if the current date is on the weekend. This function must be preceded by the .is() function. * Example

	Date.today().is().weekend(); // true|false
	
* * @return {Boolean} true|false */ $P.weekend = function () { if (this._is) { this._is = false; return (this.is().sat() || this.is().sun()); } return false; }; /** * Sets the Time of the current Date instance. A string "6:15 pm" or config object {hour:18, minute:15} are accepted. * Example

	// Set time to 6:15pm with a String
	Date.today().at("6:15pm");

	// Set time to 6:15pm with a config object
	Date.today().at({hour:18, minute:15});
	
* * @return {Date} date */ $P.at = function (time) { return (typeof time === "string") ? $D.parse(this.toString("d") + " " + time) : this.set(time); }; /** * Creates a new Date() and adds this (Number) to the date based on the preceding date element function (eg. second|minute|hour|day|month|year). * Example

	// Undeclared Numbers must be wrapped with parentheses. Requirment of JavaScript.
	(3).days().fromNow();
	(6).months().fromNow();

	// Declared Number variables do not require parentheses. 
	var n = 6;
	n.months().fromNow();
	
* * @return {Date} A new Date instance */ $N.fromNow = $N.after = function (date) { var c = {}; c[this._dateElement] = this; return ((!date) ? new Date() : date.clone()).add(c); }; /** * Creates a new Date() and subtract this (Number) from the date based on the preceding date element function (eg. second|minute|hour|day|month|year). * Example

	// Undeclared Numbers must be wrapped with parentheses. Requirment of JavaScript.
	(3).days().ago();
	(6).months().ago();

	// Declared Number variables do not require parentheses. 
	var n = 6;
	n.months().ago();
	
* * @return {Date} A new Date instance */ $N.ago = $N.before = function (date) { var c = {}, s = (this._dateElement[this._dateElement.length-1] !== "s") ? this._dateElement + "s" : this._dateElement; c[s] = this * -1; return ((!date) ? new Date() : date.clone()).add(c); }; // Do NOT modify the following string tokens. These tokens are used to build dynamic functions. // All culture-specific strings can be found in the CultureInfo files. var dx = ("sunday monday tuesday wednesday thursday friday saturday").split(/\s/), mx = ("january february march april may june july august september october november december").split(/\s/), px = ("Millisecond Second Minute Hour Day Week Month Year Quarter Weekday").split(/\s/), pxf = ("Milliseconds Seconds Minutes Hours Date Week Month FullYear Quarter").split(/\s/), nth = ("final first second third fourth fifth").split(/\s/), de; /** * Returns an object literal of all the date parts. * Example

	var o = new Date().toObject();
	
	// { year: 2008, month: 4, week: 20, day: 13, hour: 18, minute: 9, second: 32, millisecond: 812 }
	
	// The object properties can be referenced directly from the object.
	
	alert(o.day);  // alerts "13"
	alert(o.year); // alerts "2008"
	
* * @return {Date} An object literal representing the original date object. */ $P.toObject = function () { var o = {}; for (var i = 0; i < px.length; i++) { if (this["get" + pxf[i]]) { o[px[i].toLowerCase()] = this["get" + pxf[i]](); } } return o; }; /** * Returns a date created from an object literal. Ignores the .week property if set in the config. * Example

	var o = new Date().toObject();
	
	return Date.fromObject(o); // will return the same date. 

	var o2 = {month: 1, day: 20, hour: 18}; // birthday party!
	Date.fromObject(o2);
	
* * @return {Date} An object literal representing the original date object. */ $D.fromObject = function(config) { config.week = null; return Date.today().set(config); }; // Create day name functions and abbreviated day name functions (eg. monday(), friday(), fri()). var df = function (n) { return function () { if (this._is) { this._is = false; return this.getDay() === n; } if (this._move) { this._move = null; } if (this._nth !== null) { // If the .second() function was called earlier, remove the _orient // from the date, and then continue. // This is required because 'second' can be used in two different context. // // Example // // Date.today().add(1).second(); // Date.march().second().monday(); // // Things get crazy with the following... // Date.march().add(1).second().second().monday(); // but it works!! // if (this._isSecond) { this.addSeconds(this._orient * -1); } // make sure we reset _isSecond this._isSecond = false; var ntemp = this._nth; this._nth = null; var temp = this.clone().moveToLastDayOfMonth(); this.moveToNthOccurrence(n, ntemp); if (this > temp) { throw new RangeError($D.getDayName(n) + " does not occur " + ntemp + " times in the month of " + $D.getMonthName(temp.getMonth()) + " " + temp.getFullYear() + "."); } return this; } return this.moveToDayOfWeek(n, this._orient); }; }; var sdf = function (n) { return function () { var t = $D.today(), shift = n - t.getDay(); if (n === 0 && Date.CultureInfo.firstDayOfWeek === 1 && t.getDay() !== 0) { shift = shift + 7; } return t.addDays(shift); }; }; // Create month name functions and abbreviated month name functions (eg. january(), march(), mar()). var month_instance_functions = function (n) { return function () { if (this._is) { this._is = false; return this.getMonth() === n; } return this.moveToMonth(n, this._orient); }; }; var month_static_functions = function (n) { return function () { return $D.today().set({ month: n, day: 1 }); }; }; var processTerms = function (names, staticFunc, instanceFunc) { for (var i = 0; i < names.length; i++) { // Create constant static Name variables. $D[names[i].toUpperCase()] = $D[names[i].toUpperCase().substring(0, 3)] = i; // Create Name functions. $D[names[i]] = $D[names[i].substring(0, 3)] = staticFunc(i); // Create Name instance functions. $P[names[i]] = $P[names[i].substring(0, 3)] = instanceFunc(i); } }; processTerms(dx, sdf, df); processTerms(mx, month_static_functions, month_instance_functions); // Create date element functions and plural date element functions used with Date (eg. day(), days(), months()). var ef = function (j) { return function () { // if the .second() function was called earlier, the _orient // has alread been added. Just return this and reset _isSecond. if (this._isSecond) { this._isSecond = false; return this; } if (this._same) { this._same = this._is = false; var o1 = this.toObject(), o2 = (arguments[0] || new Date()).toObject(), v = "", k = j.toLowerCase(); // the substr trick with -1 doesn't work in IE8 or less k = (k[k.length-1] === "s") ? k.substring(0,k.length-1) : k; for (var m = (px.length - 1); m > -1; m--) { v = px[m].toLowerCase(); if (o1[v] !== o2[v]) { return false; } if (k === v) { break; } } return true; } if (j.substring(j.length - 1) !== "s") { j += "s"; } if (this._move) { this._move = null; } return this["add" + j](this._orient); }; }; var nf = function (n) { return function () { this._dateElement = n; return this; }; }; for (var k = 0; k < px.length; k++) { de = px[k].toLowerCase(); if(de !== "weekday") { // Create date element functions and plural date element functions used with Date (eg. day(), days(), months()). $P[de] = $P[de + "s"] = ef(px[k]); // Create date element functions and plural date element functions used with Number (eg. day(), days(), months()). $N[de] = $N[de + "s"] = nf(de + "s"); } } $P._ss = ef("Second"); var nthfn = function (n) { return function (dayOfWeek) { if (this._same) { return this._ss(arguments[0]); } if (dayOfWeek || dayOfWeek === 0) { return this.moveToNthOccurrence(dayOfWeek, n); } this._nth = n; // if the operator is 'second' add the _orient, then deal with it later... if (n === 2 && (dayOfWeek === undefined || dayOfWeek === null)) { this._isSecond = true; return this.addSeconds(this._orient); } return this; }; }; for (var l = 0; l < nth.length; l++) { $P[nth[l]] = (l === 0) ? nthfn(-1) : nthfn(l); } }()); (function () { "use strict"; Date.Parsing = { Exception: function (s) { this.message = "Parse error at '" + s.substring(0, 10) + " ...'"; } }; var $P = Date.Parsing; var dayOffsets = { standard: [0,31,59,90,120,151,181,212,243,273,304,334], leap: [0,31,60,91,121,152,182,213,244,274,305,335] }; $P.isLeapYear = function(year) { return ((year % 4 === 0) && (year % 100 !== 0)) || (year % 400 === 0); }; var utils = { multiReplace : function (str, hash ) { var key; for (key in hash) { if (Object.prototype.hasOwnProperty.call(hash, key)) { var regex; if (typeof hash[key] === "function") { } else { regex = (hash[key] instanceof RegExp) ? hash[key] : new RegExp(hash[key], "g"); } str = str.replace(regex, key); } } return str; }, getDayOfYearFromWeek : function (obj) { var d, jan4, offset; obj.weekDay = (!obj.weekDay && obj.weekDay !== 0) ? 1 : obj.weekDay; d = new Date(obj.year, 0, 4); jan4 = d.getDay() === 0 ? 7 : d.getDay(); // JS is 0 indexed on Sunday. offset = jan4+3; obj.dayOfYear = ((obj.week * 7) + (obj.weekDay === 0 ? 7 : obj.weekDay))-offset; return obj; }, getDayOfYear : function (obj, dayOffset) { if (!obj.dayOfYear) { obj = utils.getDayOfYearFromWeek(obj); } for (var i=0;i <= dayOffset.length;i++) { if (obj.dayOfYear < dayOffset[i] || i === dayOffset.length) { obj.day = obj.day ? obj.day : (obj.dayOfYear - dayOffset[i-1]); break; } else { obj.month = i; } } return obj; }, adjustForTimeZone : function (obj, date) { var offset; if (obj.zone.toUpperCase() === "Z" || (obj.zone_hours === 0 && obj.zone_minutes === 0)) { // it's UTC/GML so work out the current timeszone offset offset = -date.getTimezoneOffset(); } else { offset = (obj.zone_hours*60) + (obj.zone_minutes || 0); if (obj.zone_sign === "+") { offset *= -1; } offset -= date.getTimezoneOffset(); } date.setMinutes(date.getMinutes()+offset); return date; }, setDefaults : function (obj) { obj.year = obj.year || Date.today().getFullYear(); obj.hours = obj.hours || 0; obj.minutes = obj.minutes || 0; obj.seconds = obj.seconds || 0; obj.milliseconds = obj.milliseconds || 0; if (!(!obj.month && (obj.week || obj.dayOfYear))) { // if we have a month, or if we don't but don't have the day calculation data obj.month = obj.month || 0; obj.day = obj.day || 1; } return obj; }, dataNum: function (data, mod, explict, postProcess) { var dataNum = data*1; if (mod) { if (postProcess) { return data ? mod(data)*1 : data; } else { return data ? mod(dataNum) : data; } } else if (!explict){ return data ? dataNum : data; } else { return (data && typeof data !== "undefined") ? dataNum : data; } }, timeDataProcess: function (obj) { var timeObj = {}; for (var x in obj.data) { if (obj.data.hasOwnProperty(x)) { timeObj[x] = obj.ignore[x] ? obj.data[x] : utils.dataNum(obj.data[x], obj.mods[x], obj.explict[x], obj.postProcess[x]); } } if (obj.data.secmins) { obj.data.secmins = obj.data.secmins.replace(",", ".") * 60; if (!timeObj.minutes) { timeObj.minutes = obj.data.secmins; } else if (!timeObj.seconds) { timeObj.seconds = obj.data.secmins; } delete obj.secmins; } return timeObj; }, buildTimeObjectFromData: function (data) { var time = utils.timeDataProcess({ data: { year : data[1], month : data[5], day : data[7], week : data[8], dayOfYear : data[10], hours : data[15], zone_hours : data[23], zone_minutes : data[24], zone : data[21], zone_sign : data[22], weekDay : data[9], minutes: data[16], seconds: data[19], milliseconds: data[20], secmins: data[18] }, mods: { month: function(data) { return data-1; }, weekDay: function (data) { data = Math.abs(data); return (data === 7 ? 0 : data); }, minutes: function (data) { return data.replace(":",""); }, seconds: function (data) { return Math.floor( (data.replace(":","").replace(",","."))*1 ); }, milliseconds: function (data) { return (data.replace(",",".")*1000); } }, postProcess: { minutes: true, seconds: true, milliseconds: true }, explict: { zone_hours: true, zone_minutes: true }, ignore: { zone: true, zone_sign: true, secmins: true } }); return time; }, addToHash: function (hash, keys, data) { keys = keys; data = data; var len = keys.length; for (var i = 0; i < len; i++) { hash[keys[i]] = data[i]; } return hash; }, combineRegex: function (r1, r2) { return new RegExp("(("+r1.source+")\\s("+r2.source+"))"); }, getDateNthString: function(add, last, inc){ if (add) { return Date.today().addDays(inc).toString("d"); } else if (last) { return Date.today().last()[inc]().toString("d"); } }, buildRegexData: function (array) { var arr = []; var len = array.length; for (var i=0; i < len; i++) { if (Object.prototype.toString.call(array[i]) === '[object Array]') { // oldIE compat version of Array.isArray arr.push(this.combineRegex(array[i][0], array[i][1])); } else { arr.push(array[i]); } } return arr; } }; $P.processTimeObject = function (obj) { var date, dayOffset; utils.setDefaults(obj); dayOffset = ($P.isLeapYear(obj.year)) ? dayOffsets.leap : dayOffsets.standard; if (!obj.month && (obj.week || obj.dayOfYear)) { utils.getDayOfYear(obj, dayOffset); } else { obj.dayOfYear = dayOffset[obj.month] + obj.day; } date = new Date(obj.year, obj.month, obj.day, obj.hours, obj.minutes, obj.seconds, obj.milliseconds); if (obj.zone) { utils.adjustForTimeZone(obj, date); // adjust (and calculate) for timezone } return date; }; $P.ISO = { regex : /^([\+-]?\d{4}(?!\d{2}\b))((-?)((0[1-9]|1[0-2])(\3([12]\d|0[1-9]|3[01]))?|W([0-4]\d|5[0-3])(-?[1-7])?|(00[1-9]|0[1-9]\d|[12]\d{2}|3([0-5]\d|6[1-6])))([T\s]((([01]\d|2[0-4])((:?)[0-5]\d)?|24\:?00)([\.,]\d+(?!:))?)?(\17[0-5]\d([\.,]\d+)?)?\s?([zZ]|([\+-])([01]\d|2[0-3]):?([0-5]\d)?)?)?)?$/, parse : function (s) { var time, data = s.match(this.regex); if (!data || !data.length) { return null; } time = utils.buildTimeObjectFromData(data); if (!time.year || (!time.year && (!time.month && !time.day) && (!time.week && !time.dayOfYear)) ) { return null; } return $P.processTimeObject(time); } }; $P.Numeric = { isNumeric: function (e){return!isNaN(parseFloat(e))&&isFinite(e);}, regex: /\b([0-1]?[0-9])([0-3]?[0-9])([0-2]?[0-9]?[0-9][0-9])\b/i, parse: function (s) { var data, i, time = {}, order = Date.CultureInfo.dateElementOrder.split(""); if (!(this.isNumeric(s)) || // if it's non-numeric OR (s[0] === "+" && s[0] === "-")) { // It's an arithmatic string (eg +/-1000) return null; } if (s.length < 5 && s.indexOf(".") < 0 && s.indexOf("/") < 0) { // assume it's just a year. time.year = s; return $P.processTimeObject(time); } data = s.match(this.regex); if (!data || !data.length) { return null; } for (i=0; i < order.length; i++) { switch(order[i]) { case "d": time.day = data[i+1]; break; case "m": time.month = (data[i+1]-1); break; case "y": time.year = data[i+1]; break; } } return $P.processTimeObject(time); } }; $P.Normalizer = { regexData: function () { var $R = Date.CultureInfo.regexPatterns; return utils.buildRegexData([ $R.tomorrow, $R.yesterday, [$R.past, $R.mon], [$R.past, $R.tue], [$R.past, $R.wed], [$R.past, $R.thu], [$R.past, $R.fri], [$R.past, $R.sat], [$R.past, $R.sun] ]); }, basicReplaceHash : function() { var $R = Date.CultureInfo.regexPatterns; return { "January": $R.jan.source, "February": $R.feb, "March": $R.mar, "April": $R.apr, "May": $R.may, "June": $R.jun, "July": $R.jul, "August": $R.aug, "September": $R.sep, "October": $R.oct, "November": $R.nov, "December": $R.dec, "": /\bat\b/gi, " ": /\s{2,}/, "am": $R.inTheMorning, "9am": $R.thisMorning, "pm": $R.inTheEvening, "7pm":$R.thisEvening }; }, keys : function(){ return [ utils.getDateNthString(true, false, 1), // tomorrow utils.getDateNthString(true, false, -1), // yesterday utils.getDateNthString(false, true, "monday"), //last mon utils.getDateNthString(false, true, "tuesday"), //last tues utils.getDateNthString(false, true, "wednesday"), //last wed utils.getDateNthString(false, true, "thursday"), //last thurs utils.getDateNthString(false, true, "friday"), //last fri utils.getDateNthString(false, true, "saturday"), //last sat utils.getDateNthString(false, true, "sunday") //last sun ]; }, buildRegexFunctions: function () { var $R = Date.CultureInfo.regexPatterns; var __ = Date.i18n.__; var tomorrowRE = new RegExp("(\\b\\d\\d?("+__("AM")+"|"+__("PM")+")? )("+$R.tomorrow.source.slice(1)+")", "i"); // adapted tomorrow regex for AM PM relative dates var todayRE = new RegExp($R.today.source + "(?!\\s*([+-]))\\b"); // today, but excludes the math operators (eg "today + 2h") this.replaceFuncs = [ [todayRE, function (full) { return (full.length > 1) ? Date.today().toString("d") : full; }], [tomorrowRE, function(full, m1) { var t = Date.today().addDays(1).toString("d"); return (t + " " + m1); }], [$R.amThisMorning, function(str, am){return am;}], [$R.pmThisEvening, function(str, pm){return pm;}] ]; }, buildReplaceData: function () { this.buildRegexFunctions(); this.replaceHash = utils.addToHash(this.basicReplaceHash(), this.keys(), this.regexData()); }, stringReplaceFuncs: function (s) { for (var i=0; i < this.replaceFuncs.length; i++) { s = s.replace(this.replaceFuncs[i][0], this.replaceFuncs[i][1]); } return s; }, parse: function (s) { s = this.stringReplaceFuncs(s); s = utils.multiReplace(s, this.replaceHash); try { var n = s.split(/([\s\-\.\,\/\x27]+)/); if (n.length === 3 && $P.Numeric.isNumeric(n[0]) && $P.Numeric.isNumeric(n[2]) && (n[2].length >= 4)) { // ok, so we're dealing with x/year. But that's not a full date. // This fixes wonky dateElementOrder parsing when set to dmy order. if (Date.CultureInfo.dateElementOrder[0] === "d") { s = "1/" + n[0] + "/" + n[2]; // set to 1st of month and normalize the seperator } } } catch (e) {} return s; } }; $P.Normalizer.buildReplaceData(); }()); (function () { var $P = Date.Parsing; var _ = $P.Operators = { // // Tokenizers // rtoken: function (r) { // regex token return function (s) { var mx = s.match(r); if (mx) { return ([ mx[0], s.substring(mx[0].length) ]); } else { throw new $P.Exception(s); } }; }, token: function () { // whitespace-eating token return function (s) { return _.rtoken(new RegExp("^\\s*" + s + "\\s*"))(s); }; }, stoken: function (s) { // string token return _.rtoken(new RegExp("^" + s)); }, // Atomic Operators until: function (p) { return function (s) { var qx = [], rx = null; while (s.length) { try { rx = p.call(this, s); } catch (e) { qx.push(rx[0]); s = rx[1]; continue; } break; } return [ qx, s ]; }; }, many: function (p) { return function (s) { var rx = [], r = null; while (s.length) { try { r = p.call(this, s); } catch (e) { return [ rx, s ]; } rx.push(r[0]); s = r[1]; } return [ rx, s ]; }; }, // generator operators -- see below optional: function (p) { return function (s) { var r = null; try { r = p.call(this, s); } catch (e) { return [ null, s ]; } return [ r[0], r[1] ]; }; }, not: function (p) { return function (s) { try { p.call(this, s); } catch (e) { return [null, s]; } throw new $P.Exception(s); }; }, ignore: function (p) { return p ? function (s) { var r = null; r = p.call(this, s); return [null, r[1]]; } : null; }, product: function () { var px = arguments[0], qx = Array.prototype.slice.call(arguments, 1), rx = []; for (var i = 0 ; i < px.length ; i++) { rx.push(_.each(px[i], qx)); } return rx; }, cache: function (rule) { var cache = {}, cache_length = 0, cache_keys = [], CACHE_MAX = Date.Config.CACHE_MAX || 100000, r = null; var cacheCheck = function () { if (cache_length === CACHE_MAX) { // kill several keys, don't want to have to do this all the time... for (var i=0; i < 10; i++) { var key = cache_keys.shift(); if (key) { delete cache[key]; cache_length--; } } } }; return function (s) { cacheCheck(); try { r = cache[s] = (cache[s] || rule.call(this, s)); } catch (e) { r = cache[s] = e; } cache_length++; cache_keys.push(s); if (r instanceof $P.Exception) { throw r; } else { return r; } }; }, // vector operators -- see below any: function () { var px = arguments; return function (s) { var r = null; for (var i = 0; i < px.length; i++) { if (px[i] == null) { continue; } try { r = (px[i].call(this, s)); } catch (e) { r = null; } if (r) { return r; } } throw new $P.Exception(s); }; }, each: function () { var px = arguments; return function (s) { var rx = [], r = null; for (var i = 0; i < px.length ; i++) { if (px[i] == null) { continue; } try { r = (px[i].call(this, s)); } catch (e) { throw new $P.Exception(s); } rx.push(r[0]); s = r[1]; } return [ rx, s]; }; }, all: function () { var px = arguments, _ = _; return _.each(_.optional(px)); }, // delimited operators sequence: function (px, d, c) { d = d || _.rtoken(/^\s*/); c = c || null; if (px.length === 1) { return px[0]; } return function (s) { var r = null, q = null; var rx = []; for (var i = 0; i < px.length ; i++) { try { r = px[i].call(this, s); } catch (e) { break; } rx.push(r[0]); try { q = d.call(this, r[1]); } catch (ex) { q = null; break; } s = q[1]; } if (!r) { throw new $P.Exception(s); } if (q) { throw new $P.Exception(q[1]); } if (c) { try { r = c.call(this, r[1]); } catch (ey) { throw new $P.Exception(r[1]); } } return [ rx, (r?r[1]:s) ]; }; }, // // Composite Operators // between: function (d1, p, d2) { d2 = d2 || d1; var _fn = _.each(_.ignore(d1), p, _.ignore(d2)); return function (s) { var rx = _fn.call(this, s); return [[rx[0][0], r[0][2]], rx[1]]; }; }, list: function (p, d, c) { d = d || _.rtoken(/^\s*/); c = c || null; return (p instanceof Array ? _.each(_.product(p.slice(0, -1), _.ignore(d)), p.slice(-1), _.ignore(c)) : _.each(_.many(_.each(p, _.ignore(d))), px, _.ignore(c))); }, set: function (px, d, c) { d = d || _.rtoken(/^\s*/); c = c || null; return function (s) { // r is the current match, best the current 'best' match // which means it parsed the most amount of input var r = null, p = null, q = null, rx = null, best = [[], s], last = false; // go through the rules in the given set for (var i = 0; i < px.length ; i++) { // last is a flag indicating whether this must be the last element // if there is only 1 element, then it MUST be the last one q = null; p = null; r = null; last = (px.length === 1); // first, we try simply to match the current pattern // if not, try the next pattern try { r = px[i].call(this, s); } catch (e) { continue; } // since we are matching against a set of elements, the first // thing to do is to add r[0] to matched elements rx = [[r[0]], r[1]]; // if we matched and there is still input to parse and // we don't already know this is the last element, // we're going to next check for the delimiter ... // if there's none, or if there's no input left to parse // than this must be the last element after all ... if (r[1].length > 0 && ! last) { try { q = d.call(this, r[1]); } catch (ex) { last = true; } } else { last = true; } // if we parsed the delimiter and now there's no more input, // that means we shouldn't have parsed the delimiter at all // so don't update r and mark this as the last element ... if (!last && q[1].length === 0) { last = true; } // so, if this isn't the last element, we're going to see if // we can get any more matches from the remaining (unmatched) // elements ... if (!last) { // build a list of the remaining rules we can match against, // i.e., all but the one we just matched against var qx = []; for (var j = 0; j < px.length ; j++) { if (i !== j) { qx.push(px[j]); } } // now invoke recursively set with the remaining input // note that we don't include the closing delimiter ... // we'll check for that ourselves at the end p = _.set(qx, d).call(this, q[1]); // if we got a non-empty set as a result ... // (otw rx already contains everything we want to match) if (p[0].length > 0) { // update current result, which is stored in rx ... // basically, pick up the remaining text from p[1] // and concat the result from p[0] so that we don't // get endless nesting ... rx[0] = rx[0].concat(p[0]); rx[1] = p[1]; } } // at this point, rx either contains the last matched element // or the entire matched set that starts with this element. // now we just check to see if this variation is better than // our best so far, in terms of how much of the input is parsed if (rx[1].length < best[1].length) { best = rx; } // if we've parsed all the input, then we're finished if (best[1].length === 0) { break; } } // so now we've either gone through all the patterns trying them // as the initial match; or we found one that parsed the entire // input string ... // if best has no matches, just return empty set ... if (best[0].length === 0) { return best; } // if a closing delimiter is provided, then we have to check it also if (c) { // we try this even if there is no remaining input because the pattern // may well be optional or match empty input ... try { q = c.call(this, best[1]); } catch (ey) { throw new $P.Exception(best[1]); } // it parsed ... be sure to update the best match remaining input best[1] = q[1]; } // if we're here, either there was no closing delimiter or we parsed it // so now we have the best match; just return it! return best; }; }, forward: function (gr, fname) { return function (s) { return gr[fname].call(this, s); }; }, // // Translation Operators // replace: function (rule, repl) { return function (s) { var r = rule.call(this, s); return [repl, r[1]]; }; }, process: function (rule, fn) { return function (s) { var r = rule.call(this, s); return [fn.call(this, r[0]), r[1]]; }; }, min: function (min, rule) { return function (s) { var rx = rule.call(this, s); if (rx[0].length < min) { throw new $P.Exception(s); } return rx; }; } }; // Generator Operators And Vector Operators // Generators are operators that have a signature of F(R) => R, // taking a given rule and returning another rule, such as // ignore, which parses a given rule and throws away the result. // Vector operators are those that have a signature of F(R1,R2,...) => R, // take a list of rules and returning a new rule, such as each. // Generator operators are converted (via the following _generator // function) into functions that can also take a list or array of rules // and return an array of new rules as though the function had been // called on each rule in turn (which is what actually happens). // This allows generators to be used with vector operators more easily. // Example: // each(ignore(foo, bar)) instead of each(ignore(foo), ignore(bar)) // This also turns generators into vector operators, which allows // constructs like: // not(cache(foo, bar)) var _generator = function (op) { function gen() { var args = null, rx = [], px, i; if (arguments.length > 1) { args = Array.prototype.slice.call(arguments); } else if (arguments[0] instanceof Array) { args = arguments[0]; } if (args) { px = args.shift(); if (px.length > 0) { args.unshift(px[i]); rx.push(op.apply(null, args)); args.shift(); return rx; } } else { return op.apply(null, arguments); } } return gen; }; var gx = "optional not ignore cache".split(/\s/); for (var i = 0 ; i < gx.length ; i++) { _[gx[i]] = _generator(_[gx[i]]); } var _vector = function (op) { return function () { if (arguments[0] instanceof Array) { return op.apply(null, arguments[0]); } else { return op.apply(null, arguments); } }; }; var vx = "each any all".split(/\s/); for (var j = 0 ; j < vx.length ; j++) { _[vx[j]] = _vector(_[vx[j]]); } }()); (function () { var $D = Date; var flattenAndCompact = function (ax) { var rx = []; for (var i = 0; i < ax.length; i++) { if (ax[i] instanceof Array) { rx = rx.concat(flattenAndCompact(ax[i])); } else { if (ax[i]) { rx.push(ax[i]); } } } return rx; }; var parseMeridian = function () { if (this.meridian && (this.hour || this.hour === 0)) { if (this.meridian === "a" && this.hour > 11 && Date.Config.strict24hr){ throw "Invalid hour and meridian combination"; } else if (this.meridian === "p" && this.hour < 12 && Date.Config.strict24hr){ throw "Invalid hour and meridian combination"; } else if (this.meridian === "p" && this.hour < 12) { this.hour = this.hour + 12; } else if (this.meridian === "a" && this.hour === 12) { this.hour = 0; } } }; var setDefaults = function () { var now = new Date(); if ((this.hour || this.minute) && (!this.month && !this.year && !this.day)) { this.day = now.getDate(); } if (!this.year) { this.year = now.getFullYear(); } if (!this.month && this.month !== 0) { this.month = now.getMonth(); } if (!this.day) { this.day = 1; } if (!this.hour) { this.hour = 0; } if (!this.minute) { this.minute = 0; } if (!this.second) { this.second = 0; } if (!this.millisecond) { this.millisecond = 0; } }; var finishUtils = { getToday: function () { if (this.now || "hour minute second".indexOf(this.unit) !== -1) { return new Date(); } else { return $D.today(); } }, setDaysFromWeekday: function (today, orient){ var gap; orient = orient || 1; this.unit = "day"; gap = ($D.getDayNumberFromName(this.weekday) - today.getDay()); this.days = gap ? ((gap + (orient * 7)) % 7) : (orient * 7); return this; }, setMonthsFromMonth: function (today, orient) { var gap; orient = orient || 1; this.unit = "month"; gap = (this.month - today.getMonth()); this.months = gap ? ((gap + (orient * 12)) % 12) : (orient * 12); this.month = null; return this; }, setDMYFromWeekday: function () { var d = Date[this.weekday](); this.day = d.getDate(); if (!this.month) { this.month = d.getMonth(); } this.year = d.getFullYear(); return this; }, setUnitValue: function (orient) { if (!this.value && this.operator && this.operator !== null && this[this.unit + "s"] && this[this.unit + "s"] !== null) { this[this.unit + "s"] = this[this.unit + "s"] + ((this.operator === "add") ? 1 : -1) + (this.value||0) * orient; } else if (this[this.unit + "s"] == null || this.operator != null) { if (!this.value) { this.value = 1; } this[this.unit + "s"] = this.value * orient; } }, generateDateFromWeeks: function () { var weekday = (this.weekday !== undefined) ? this.weekday : "today"; var d = Date[weekday]().addWeeks(this.weeks); if (this.now) { d.setTimeToNow(); } return d; } }; $D.Translator = { hour: function (s) { return function () { this.hour = Number(s); }; }, minute: function (s) { return function () { this.minute = Number(s); }; }, second: function (s) { return function () { this.second = Number(s); }; }, /* for ss.s format */ secondAndMillisecond: function (s) { return function () { var mx = s.match(/^([0-5][0-9])\.([0-9]{1,3})/); this.second = Number(mx[1]); this.millisecond = Number(mx[2]); }; }, meridian: function (s) { return function () { this.meridian = s.slice(0, 1).toLowerCase(); }; }, timezone: function (s) { return function () { var n = s.replace(/[^\d\+\-]/g, ""); if (n.length) { this.timezoneOffset = Number(n); } else { this.timezone = s.toLowerCase(); } }; }, day: function (x) { var s = x[0]; return function () { this.day = Number(s.match(/\d+/)[0]); if (this.day < 1) { throw "invalid day"; } }; }, month: function (s) { return function () { this.month = (s.length === 3) ? "jan feb mar apr may jun jul aug sep oct nov dec".indexOf(s)/4 : Number(s) - 1; if (this.month < 0) { throw "invalid month"; } }; }, year: function (s) { return function () { var n = Number(s); this.year = ((s.length > 2) ? n : (n + (((n + 2000) < Date.CultureInfo.twoDigitYearMax) ? 2000 : 1900))); }; }, rday: function (s) { return function () { switch (s) { case "yesterday": this.days = -1; break; case "tomorrow": this.days = 1; break; case "today": this.days = 0; break; case "now": this.days = 0; this.now = true; break; } }; }, finishExact: function (x) { var d; x = (x instanceof Array) ? x : [x]; for (var i = 0 ; i < x.length ; i++) { if (x[i]) { x[i].call(this); } } setDefaults.call(this); parseMeridian.call(this); if (this.day > $D.getDaysInMonth(this.year, this.month)) { throw new RangeError(this.day + " is not a valid value for days."); } d = new Date(this.year, this.month, this.day, this.hour, this.minute, this.second, this.millisecond); if (this.year < 100) { d.setFullYear(this.year); // means years less that 100 are process correctly. JS will parse it otherwise as 1900-1999. } if (this.timezone) { d.set({ timezone: this.timezone }); } else if (this.timezoneOffset) { d.set({ timezoneOffset: this.timezoneOffset }); } return d; }, finish: function (x) { var today, expression, orient, temp; x = (x instanceof Array) ? flattenAndCompact(x) : [ x ]; if (x.length === 0) { return null; } for (var i = 0 ; i < x.length ; i++) { if (typeof x[i] === "function") { x[i].call(this); } } if (this.now && !this.unit && !this.operator) { return new Date(); } else { today = finishUtils.getToday.call(this); } expression = !!(this.days && this.days !== null || this.orient || this.operator); orient = ((this.orient === "past" || this.operator === "subtract") ? -1 : 1); if (this.month && this.unit === "week") { this.value = this.month + 1; delete this.month; delete this.day; } if ((this.month || this.month === 0) && "year day hour minute second".indexOf(this.unit) !== -1) { if (!this.value) { this.value = this.month + 1; } this.month = null; expression = true; } if (!expression && this.weekday && !this.day && !this.days) { finishUtils.setDMYFromWeekday.call(this); } if (expression && this.weekday && this.unit !== "month" && this.unit !== "week") { finishUtils.setDaysFromWeekday.call(this, today, orient); } if (this.weekday && this.unit !== "week" && !this.day && !this.days) { temp = Date[this.weekday](); this.day = temp.getDate(); if (temp.getMonth() !== today.getMonth()) { this.month = temp.getMonth(); } } if (this.month && this.unit === "day" && this.operator) { if (!this.value) { this.value = (this.month + 1); } this.month = null; } if (this.value != null && this.month != null && this.year != null) { this.day = this.value * 1; } if (this.month && !this.day && this.value) { today.set({ day: this.value * 1 }); if (!expression) { this.day = this.value * 1; } } if (!this.month && this.value && this.unit === "month" && !this.now) { this.month = this.value; expression = true; } if (expression && (this.month || this.month === 0) && this.unit !== "year") { finishUtils.setMonthsFromMonth.call(this, today, orient); } if (!this.unit) { this.unit = "day"; } finishUtils.setUnitValue.call(this, orient); parseMeridian.call(this); if ((this.month || this.month === 0) && !this.day) { this.day = 1; } if (!this.orient && !this.operator && this.unit === "week" && this.value && !this.day && !this.month) { return Date.today().setWeek(this.value); } if (this.unit === "week" && this.weeks && !this.day && !this.month) { return finishUtils.generateDateFromWeeks.call(this); } if (expression && this.timezone && this.day && this.days) { this.day = this.days; } if (expression){ today.add(this); } else { today.set(this); } if (this.timezone) { this.timezone = this.timezone.toUpperCase(); var offset = $D.getTimezoneOffset(this.timezone); var timezone; if (today.hasDaylightSavingTime()) { // lets check that we're being sane with timezone setting timezone = $D.getTimezoneAbbreviation(offset, today.isDaylightSavingTime()); if (timezone !== this.timezone) { // bugger, we're in a place where things like EST vs EDT matters. if (today.isDaylightSavingTime()) { today.addHours(-1); } else { today.addHours(1); } } } today.setTimezoneOffset(offset); } return today; } }; }()); (function () { var $D = Date; $D.Grammar = {}; var _ = $D.Parsing.Operators, g = $D.Grammar, t = $D.Translator, _fn; // Allow rolling up into general purpose rules _fn = function () { return _.each(_.any.apply(null, arguments), _.not(g.ctoken2("timeContext"))); }; g.datePartDelimiter = _.rtoken(/^([\s\-\.\,\/\x27]+)/); g.timePartDelimiter = _.stoken(":"); g.whiteSpace = _.rtoken(/^\s*/); g.generalDelimiter = _.rtoken(/^(([\s\,]|at|@|on)+)/); var _C = {}; g.ctoken = function (keys) { var fn = _C[keys]; if (! fn) { var c = Date.CultureInfo.regexPatterns; var kx = keys.split(/\s+/), px = []; for (var i = 0; i < kx.length ; i++) { px.push(_.replace(_.rtoken(c[kx[i]]), kx[i])); } fn = _C[keys] = _.any.apply(null, px); } return fn; }; g.ctoken2 = function (key) { return _.rtoken(Date.CultureInfo.regexPatterns[key]); }; var cacheProcessRtoken = function (key, token, type, eachToken) { if (eachToken) { g[key] = _.cache(_.process(_.each(_.rtoken(token),_.optional(g.ctoken2(eachToken))), type)); } else { g[key] = _.cache(_.process(_.rtoken(token), type)); } }; var cacheProcessCtoken = function (token, type) { return _.cache(_.process(g.ctoken2(token), type)); }; var _F = {}; //function cache var _get = function (f) { _F[f] = (_F[f] || g.format(f)[0]); return _F[f]; }; g.allformats = function (fx) { var rx = []; if (fx instanceof Array) { for (var i = 0; i < fx.length; i++) { rx.push(_get(fx[i])); } } else { rx.push(_get(fx)); } return rx; }; g.formats = function (fx) { if (fx instanceof Array) { var rx = []; for (var i = 0 ; i < fx.length ; i++) { rx.push(_get(fx[i])); } return _.any.apply(null, rx); } else { return _get(fx); } }; var grammarFormats = { timeFormats: function(){ var i, RTokenKeys = [ "h", "hh", "H", "HH", "m", "mm", "s", "ss", "ss.s", "z", "zz" ], RToken = [ /^(0[0-9]|1[0-2]|[1-9])/, /^(0[0-9]|1[0-2])/, /^([0-1][0-9]|2[0-3]|[0-9])/, /^([0-1][0-9]|2[0-3])/, /^([0-5][0-9]|[0-9])/, /^[0-5][0-9]/, /^([0-5][0-9]|[0-9])/, /^[0-5][0-9]/, /^[0-5][0-9]\.[0-9]{1,3}/, /^((\+|\-)\s*\d\d\d\d)|((\+|\-)\d\d\:?\d\d)/, /^((\+|\-)\s*\d\d\d\d)|((\+|\-)\d\d\:?\d\d)/ ], tokens = [ t.hour, t.hour, t.hour, t.hour, t.minute, t.minute, t.second, t.second, t.secondAndMillisecond, t.timezone, t.timezone ]; for (i=0; i < RTokenKeys.length; i++) { cacheProcessRtoken(RTokenKeys[i], RToken[i], tokens[i]); } g.hms = _.cache(_.sequence([g.H, g.m, g.s], g.timePartDelimiter)); g.t = cacheProcessCtoken("shortMeridian", t.meridian); g.tt = cacheProcessCtoken("longMeridian", t.meridian); g.zzz = cacheProcessCtoken("timezone", t.timezone); g.timeSuffix = _.each(_.ignore(g.whiteSpace), _.set([ g.tt, g.zzz ])); g.time = _.each(_.optional(_.ignore(_.stoken("T"))), g.hms, g.timeSuffix); }, dateFormats: function () { // pre-loaded rules for different date part order preferences var _setfn = function () { return _.set(arguments, g.datePartDelimiter); }; var i, RTokenKeys = [ "d", "dd", "M", "MM", "y", "yy", "yyy", "yyyy" ], RToken = [ /^([0-2]\d|3[0-1]|\d)/, /^([0-2]\d|3[0-1])/, /^(1[0-2]|0\d|\d)/, /^(1[0-2]|0\d)/, /^(\d+)/, /^(\d\d)/, /^(\d\d?\d?\d?)/, /^(\d\d\d\d)/ ], tokens = [ t.day, t.day, t.month, t.month, t.year, t.year, t.year, t.year ], eachToken = [ "ordinalSuffix", "ordinalSuffix" ]; for (i=0; i < RTokenKeys.length; i++) { cacheProcessRtoken(RTokenKeys[i], RToken[i], tokens[i], eachToken[i]); } g.MMM = g.MMMM = _.cache(_.process(g.ctoken("jan feb mar apr may jun jul aug sep oct nov dec"), t.month)); g.ddd = g.dddd = _.cache(_.process(g.ctoken("sun mon tue wed thu fri sat"), function (s) { return function () { this.weekday = s; }; } )); g.day = _fn(g.d, g.dd); g.month = _fn(g.M, g.MMM); g.year = _fn(g.yyyy, g.yy); g.mdy = _setfn(g.ddd, g.month, g.day, g.year); g.ymd = _setfn(g.ddd, g.year, g.month, g.day); g.dmy = _setfn(g.ddd, g.day, g.month, g.year); g.date = function (s) { return ((g[Date.CultureInfo.dateElementOrder] || g.mdy).call(this, s)); }; }, relative: function () { // relative date / time expressions g.orientation = _.process(g.ctoken("past future"), function (s) { return function () { this.orient = s; }; } ); g.operator = _.process(g.ctoken("add subtract"), function (s) { return function () { this.operator = s; }; } ); g.rday = _.process(g.ctoken("yesterday tomorrow today now"), t.rday); g.unit = _.process(g.ctoken("second minute hour day week month year"), function (s) { return function () { this.unit = s; }; } ); } }; g.buildGrammarFormats = function () { // these need to be rebuilt every time the language changes. _C = {}; grammarFormats.timeFormats(); grammarFormats.dateFormats(); grammarFormats.relative(); g.value = _.process(_.rtoken(/^([-+]?\d+)?(st|nd|rd|th)?/), function (s) { return function () { this.value = s.replace(/\D/g, ""); }; } ); g.expression = _.set([g.rday, g.operator, g.value, g.unit, g.orientation, g.ddd, g.MMM ]); g.format = _.process(_.many( _.any( // translate format specifiers into grammar rules _.process( _.rtoken(/^(dd?d?d?(?!e)|MM?M?M?|yy?y?y?|hh?|HH?|mm?|ss?|tt?|zz?z?)/), function (fmt) { if (g[fmt]) { return g[fmt]; } else { throw $D.Parsing.Exception(fmt); } } ), // translate separator tokens into token rules _.process(_.rtoken(/^[^dMyhHmstz]+/), // all legal separators function (s) { return _.ignore(_.stoken(s)); } ) ) ), // construct the parser ... function (rules) { return _.process(_.each.apply(null, rules), t.finishExact); } ); // starting rule for general purpose grammar g._start = _.process(_.set([ g.date, g.time, g.expression ], g.generalDelimiter, g.whiteSpace), t.finish); }; g.buildGrammarFormats(); // parsing date format specifiers - ex: "h:m:s tt" // this little guy will generate a custom parser based // on the format string, ex: g.format("h:m:s tt") // check for these formats first g._formats = g.formats([ "\"yyyy-MM-ddTHH:mm:ssZ\"", "yyyy-MM-ddTHH:mm:ss.sz", "yyyy-MM-ddTHH:mm:ssZ", "yyyy-MM-ddTHH:mm:ssz", "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-ddTHH:mmZ", "yyyy-MM-ddTHH:mmz", "yyyy-MM-ddTHH:mm", "ddd, MMM dd, yyyy H:mm:ss tt", "ddd MMM d yyyy HH:mm:ss zzz", "MMddyyyy", "ddMMyyyy", "Mddyyyy", "ddMyyyy", "Mdyyyy", "dMyyyy", "yyyy", "Mdyy", "dMyy", "d" ]); // real starting rule: tries selected formats first, // then general purpose rule g.start = function (s) { try { var r = g._formats.call({}, s); if (r[1].length === 0) { return r; } } catch (e) {} return g._start.call({}, s); }; }()); (function () { var $D = Date; /** * @desc Converts the specified string value into its JavaScript Date equivalent using CultureInfo specific format information. * * Example

	///////////
	// Dates //
	///////////

	// 15-Oct-2004
	var d1 = Date.parse("10/15/2004");

	// 15-Oct-2004
	var d1 = Date.parse("15-Oct-2004");

	// 15-Oct-2004
	var d1 = Date.parse("2004.10.15");

	//Fri Oct 15, 2004
	var d1 = Date.parse("Fri Oct 15, 2004");

	///////////
	// Times //
	///////////

	// Today at 10 PM.
	var d1 = Date.parse("10 PM");

	// Today at 10:30 PM.
	var d1 = Date.parse("10:30 P.M.");

	// Today at 6 AM.
	var d1 = Date.parse("06am");

	/////////////////////
	// Dates and Times //
	/////////////////////

	// 8-July-2004 @ 10:30 PM
	var d1 = Date.parse("July 8th, 2004, 10:30 PM");

	// 1-July-2004 @ 10:30 PM
	var d1 = Date.parse("2004-07-01T22:30:00");

	////////////////////
	// Relative Dates //
	////////////////////

	// Returns today's date. The string "today" is culture specific.
	var d1 = Date.parse("today");

	// Returns yesterday's date. The string "yesterday" is culture specific.
	var d1 = Date.parse("yesterday");

	// Returns the date of the next thursday.
	var d1 = Date.parse("Next thursday");

	// Returns the date of the most previous monday.
	var d1 = Date.parse("last monday");

	// Returns today's day + one year.
	var d1 = Date.parse("next year");

	///////////////
	// Date Math //
	///////////////

	// Today + 2 days
	var d1 = Date.parse("t+2");

	// Today + 2 days
	var d1 = Date.parse("today + 2 days");

	// Today + 3 months
	var d1 = Date.parse("t+3m");

	// Today - 1 year
	var d1 = Date.parse("today - 1 year");

	// Today - 1 year
	var d1 = Date.parse("t-1y"); 


	/////////////////////////////
	// Partial Dates and Times //
	/////////////////////////////

	// July 15th of this year.
	var d1 = Date.parse("July 15");

	// 15th day of current day and year.
	var d1 = Date.parse("15");

	// July 1st of current year at 10pm.
	var d1 = Date.parse("7/1 10pm");
	
* * @param {String} The string value to convert into a Date object [Required] * @return {Date} A Date object or null if the string cannot be converted into a Date. */ var parseUtils = { removeOrds: function (s) { ords = s.match(/\b(\d+)(?:st|nd|rd|th)\b/); // find ordinal matches s = ((ords && ords.length === 2) ? s.replace(ords[0], ords[1]) : s); return s; }, grammarParser: function (s) { var r = null; try { r = $D.Grammar.start.call({}, s.replace(/^\s*(\S*(\s+\S+)*)\s*$/, "$1")); } catch (e) { return null; } return ((r[1].length === 0) ? r[0] : null); }, nativeFallback: function(s) { var t; try { // ok we haven't parsed it, last ditch attempt with the built-in parser. t = Date._parse(s); return (t || t === 0) ? new Date(t) : null; } catch (e) { return null; } } }; function parse (s) { var d; if (!s) { return null; } if (s instanceof Date) { return s.clone(); } if (s.length >= 4 && s.charAt(0) !== "0" && s.charAt(0) !== "+"&& s.charAt(0) !== "-") { // ie: 2004 will pass, 0800 won't. // Start with specific formats d = $D.Parsing.ISO.parse(s) || $D.Parsing.Numeric.parse(s); } if (d instanceof Date && !isNaN(d.getTime())) { return d; } else { // find ordinal dates (1st, 3rd, 8th, etc and remove them as they cause parsing issues) s = $D.Parsing.Normalizer.parse(parseUtils.removeOrds(s)); d = parseUtils.grammarParser(s); if (d !== null) { return d; } else { return parseUtils.nativeFallback(s); } } } if (!$D._parse) { $D._parse = $D.parse; } $D.parse = parse; Date.getParseFunction = function (fx) { var fns = Date.Grammar.allformats(fx); return function (s) { var r = null; for (var i = 0; i < fns.length; i++) { try { r = fns[i].call({}, s); } catch (e) { continue; } if (r[1].length === 0) { return r[0]; } } return null; }; }; /** * Converts the specified string value into its JavaScript Date equivalent using the specified format {String} or formats {Array} and the CultureInfo specific format information. * The format of the string value must match one of the supplied formats exactly. * * Example

	// 15-Oct-2004
	var d1 = Date.parseExact("10/15/2004", "M/d/yyyy");

	// 15-Oct-2004
	var d1 = Date.parse("15-Oct-2004", "M-ddd-yyyy");

	// 15-Oct-2004
	var d1 = Date.parse("2004.10.15", "yyyy.MM.dd");

	// Multiple formats
	var d1 = Date.parseExact("10/15/2004", ["M/d/yyyy", "MMMM d, yyyy"]);
	
* * @param {String} The string value to convert into a Date object [Required]. * @param {Object} The expected format {String} or an array of expected formats {Array} of the date string [Required]. * @return {Date} A Date object or null if the string cannot be converted into a Date. */ $D.parseExact = function (s, fx) { return $D.getParseFunction(fx)(s); }; }()); (function () { var $D = Date, $P = $D.prototype, // $C = $D.CultureInfo, // not used atm p = function (s, l) { if (!l) { l = 2; } return ("000" + s).slice(l * -1); }; /** * Converts a PHP format string to Java/.NET format string. * A PHP format string can be used with ._format or .format. * A Java/.NET format string can be used with .toString(). * The .parseExact function will only accept a Java/.NET format string * * Example * var f1 = "%m/%d/%y" * var f2 = Date.normalizeFormat(f1); // "MM/dd/yy" * * new Date().format(f1); // "04/13/08" * new Date()._format(f1); // "04/13/08" * new Date().toString(f2); // "04/13/08" * * var date = Date.parseExact("04/13/08", f2); // Sun Apr 13 2008 * * @param {String} A PHP format string consisting of one or more format spcifiers. * @return {String} The PHP format converted to a Java/.NET format string. */ var normalizerSubstitutions = { "d" : "dd", "%d": "dd", "D" : "ddd", "%a": "ddd", "j" : "dddd", "l" : "dddd", "%A": "dddd", "S" : "S", "F" : "MMMM", "%B": "MMMM", "m" : "MM", "%m": "MM", "M" : "MMM", "%b": "MMM", "%h": "MMM", "n" : "M", "Y" : "yyyy", "%Y": "yyyy", "y" : "yy", "%y": "yy", "g" : "h", "%I": "h", "G" : "H", "h" : "hh", "H" : "HH", "%H": "HH", "i" : "mm", "%M": "mm", "s" : "ss", "%S": "ss", "%r": "hh:mm tt", "%R": "H:mm", "%T": "H:mm:ss", "%X": "t", "%x": "d", "%e": "d", "%D": "MM/dd/yy", "%n": "\\n", "%t": "\\t", "e" : "z", "T" : "z", "%z": "z", "%Z": "z", "Z" : "ZZ", "N" : "u", "w" : "u", "%w": "u", "W" : "W", "%V": "W" }; var normalizer = { substitutes: function (m) { return normalizerSubstitutions[m]; }, interpreted: function (m, x) { var y; switch (m) { case "%u": return x.getDay() + 1; case "z": return x.getOrdinalNumber(); case "%j": return p(x.getOrdinalNumber(), 3); case "%U": var d1 = x.clone().set({month: 0, day: 1}).addDays(-1).moveToDayOfWeek(0), d2 = x.clone().addDays(1).moveToDayOfWeek(0, -1); return (d2 < d1) ? "00" : p((d2.getOrdinalNumber() - d1.getOrdinalNumber()) / 7 + 1); case "%W": return p(x.getWeek()); case "t": return $D.getDaysInMonth(x.getFullYear(), x.getMonth()); case "o": case "%G": return x.setWeek(x.getISOWeek()).toString("yyyy"); case "%g": return x._format("%G").slice(-2); case "a": case "%p": return t("tt").toLowerCase(); case "A": return t("tt").toUpperCase(); case "u": return p(x.getMilliseconds(), 3); case "I": return (x.isDaylightSavingTime()) ? 1 : 0; case "O": return x.getUTCOffset(); case "P": y = x.getUTCOffset(); return y.substring(0, y.length - 2) + ":" + y.substring(y.length - 2); case "B": var now = new Date(); return Math.floor(((now.getHours() * 3600) + (now.getMinutes() * 60) + now.getSeconds() + (now.getTimezoneOffset() + 60) * 60) / 86.4); case "c": return x.toISOString().replace(/\"/g, ""); case "U": return $D.strtotime("now"); case "%c": return t("d") + " " + t("t"); case "%C": return Math.floor(x.getFullYear() / 100 + 1); } }, shouldOverrideDefaults: function (m) { switch (m) { case "%e": return true; default: return false; } }, parse: function (m, context) { var formatString, c = context || new Date(); formatString = normalizer.substitutes(m); if (formatString) { return formatString; } formatString = normalizer.interpreted(m, c); if (formatString) { return formatString; } else { return m; } } }; $D.normalizeFormat = function (format, context) { return format.replace(/(%|\\)?.|%%/g, function(t){ return normalizer.parse(t, context); }); }; /** * Format a local Unix timestamp according to locale settings * * Example: * Date.strftime("%m/%d/%y", new Date()); // "04/13/08" * Date.strftime("c", "2008-04-13T17:52:03Z"); // "04/13/08" * * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @param {Number|String} The number representing the number of seconds that have elapsed since January 1, 1970 (local time). * @return {String} A string representation of the current Date object. */ $D.strftime = function (format, time) { var d = Date.parse(time); return d._format(format); }; /** * Parse any textual datetime description into a Unix timestamp. * A Unix timestamp is the number of seconds that have elapsed since January 1, 1970 (midnight UTC/GMT). * * Example: * Date.strtotime("04/13/08"); // 1208044800 * Date.strtotime("1970-01-01T00:00:00Z"); // 0 * * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @param {Object} A string or date object. * @return {String} A string representation of the current Date object. */ $D.strtotime = function (time) { var d = $D.parse(time); return Math.round($D.UTC(d.getUTCFullYear(), d.getUTCMonth(), d.getUTCDate(), d.getUTCHours(), d.getUTCMinutes(), d.getUTCSeconds(), d.getUTCMilliseconds()) / 1000); }; /** * Converts the value of the current Date object to its equivalent string representation using a PHP/Unix style of date format specifiers. * Format Specifiers * Format Description Example * ------ --------------------------------------------------------------------------- ----------------------- * %a abbreviated weekday name according to the current localed "Mon" through "Sun" * %A full weekday name according to the current localed "Sunday" through "Saturday" * %b abbreviated month name according to the current localed "Jan" through "Dec" * %B full month name according to the current locale "January" through "December" * %c preferred date and time representation for the current locale "4/13/2008 12:33 PM" * %C century number (the year divided by 100 and truncated to an integer) "00" to "99" * %d day of the month as a decimal number "01" to "31" * %D same as %m/%d/%y "04/13/08" * %e day of the month as a decimal number, a single digit is preceded by a space "1" to "31" * %g like %G, but without the century "08" * %G The 4-digit year corresponding to the ISO week number (see %V). "2008" * This has the same format and value as %Y, except that if the ISO week number * belongs to the previous or next year, that year is used instead. * %h same as %b "Jan" through "Dec" * %H hour as a decimal number using a 24-hour clock. "00" to "23" * %I hour as a decimal number using a 12-hour clock. "01" to "12" * %j day of the year as a decimal number. "001" to "366" * %m month as a decimal number. "01" to "12" * %M minute as a decimal number. "00" to "59" * %n newline character "\n" * %p either "am" or "pm" according to the given time value, or the "am" or "pm" * corresponding strings for the current locale. * %r time in a.m. and p.m. notation "8:44 PM" * %R time in 24 hour notation "20:44" * %S second as a decimal number "00" to "59" * %t tab character "\t" * %T current time, equal to %H:%M:%S "12:49:11" * %u weekday as a decimal number ["1", "7"], with "1" representing Monday "1" to "7" * %U week number of the current year as a decimal number, starting with the "0" to ("52" or "53") * first Sunday as the first day of the first week * %V The ISO 8601:1988 week number of the current year as a decimal number, "00" to ("52" or "53") * range 01 to 53, where week 1 is the first week that has at least 4 days * in the current year, and with Monday as the first day of the week. * (Use %G or %g for the year component that corresponds to the week number * for the specified timestamp.) * %W week number of the current year as a decimal number, starting with the "00" to ("52" or "53") * first Monday as the first day of the first week * %w day of the week as a decimal, Sunday being "0" "0" to "6" * %x preferred date representation for the current locale without the time "4/13/2008" * %X preferred time representation for the current locale without the date "12:53:05" * %y year as a decimal number without a century "00" "99" * %Y year as a decimal number including the century "2008" * %Z time zone or name or abbreviation "UTC", "EST", "PST" * %z same as %Z * %% a literal "%" characters "%" * d Day of the month, 2 digits with leading zeros "01" to "31" * D A textual representation of a day, three letters "Mon" through "Sun" * j Day of the month without leading zeros "1" to "31" * l A full textual representation of the day of the week (lowercase "L") "Sunday" through "Saturday" * N ISO-8601 numeric representation of the day of the week (added in PHP 5.1.0) "1" (for Monday) through "7" (for Sunday) * S English ordinal suffix for the day of the month, 2 characters "st", "nd", "rd" or "th". Works well with j * w Numeric representation of the day of the week "0" (for Sunday) through "6" (for Saturday) * z The day of the year (starting from "0") "0" through "365" * W ISO-8601 week number of year, weeks starting on Monday "00" to ("52" or "53") * F A full textual representation of a month, such as January or March "January" through "December" * m Numeric representation of a month, with leading zeros "01" through "12" * M A short textual representation of a month, three letters "Jan" through "Dec" * n Numeric representation of a month, without leading zeros "1" through "12" * t Number of days in the given month "28" through "31" * L Whether it's a leap year "1" if it is a leap year, "0" otherwise * o ISO-8601 year number. This has the same value as Y, except that if the "2008" * ISO week number (W) belongs to the previous or next year, that year * is used instead. * Y A full numeric representation of a year, 4 digits "2008" * y A two digit representation of a year "08" * a Lowercase Ante meridiem and Post meridiem "am" or "pm" * A Uppercase Ante meridiem and Post meridiem "AM" or "PM" * B Swatch Internet time "000" through "999" * g 12-hour format of an hour without leading zeros "1" through "12" * G 24-hour format of an hour without leading zeros "0" through "23" * h 12-hour format of an hour with leading zeros "01" through "12" * H 24-hour format of an hour with leading zeros "00" through "23" * i Minutes with leading zeros "00" to "59" * s Seconds, with leading zeros "00" through "59" * u Milliseconds "54321" * e Timezone identifier "UTC", "EST", "PST" * I Whether or not the date is in daylight saving time (uppercase i) "1" if Daylight Saving Time, "0" otherwise * O Difference to Greenwich time (GMT) in hours "+0200", "-0600" * P Difference to Greenwich time (GMT) with colon between hours and minutes "+02:00", "-06:00" * T Timezone abbreviation "UTC", "EST", "PST" * Z Timezone offset in seconds. The offset for timezones west of UTC is "-43200" through "50400" * always negative, and for those east of UTC is always positive. * c ISO 8601 date "2004-02-12T15:19:21+00:00" * r RFC 2822 formatted date "Thu, 21 Dec 2000 16:01:07 +0200" * U Seconds since the Unix Epoch (January 1 1970 00:00:00 GMT) "0" * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @return {String} A string representation of the current Date object. */ var formatReplace = function (context) { return function (m) { var formatString, override = false; if (m.charAt(0) === "\\" || m.substring(0, 2) === "%%") { return m.replace("\\", "").replace("%%", "%"); } override = normalizer.shouldOverrideDefaults(m); formatString = $D.normalizeFormat(m, context); if (formatString) { return context.toString(formatString, override); } }; }; $P._format = function (format) { var formatter = formatReplace(this); if (!format) { return this._toString(); } else { return format.replace(/(%|\\)?.|%%/g, formatter); } }; if (!$P.format) { $P.format = $P._format; } }()); (function () { "use strict"; var gFn = function (attr) { return function () { return this[attr]; }; }; var sFn = function (attr) { return function (val) { this[attr] = val; return this; }; }; var attrs = ["years", "months", "days", "hours", "minutes", "seconds", "milliseconds"]; var addSetFuncs = function (context, attrs) { for (var i = 0; i < attrs.length ; i++) { var $a = attrs[i], $b = $a.slice(0, 1).toUpperCase() + $a.slice(1); context.prototype[$a] = 0; context.prototype["get" + $b] = gFn($a); context.prototype["set" + $b] = sFn($a); } }; /** * new TimeSpan(milliseconds); * new TimeSpan(days, hours, minutes, seconds); * new TimeSpan(days, hours, minutes, seconds, milliseconds); */ var TimeSpan = function (days, hours, minutes, seconds, milliseconds) { if (arguments.length === 1 && typeof days === "number") { var orient = (days < 0) ? -1 : +1; var millsLeft = Math.abs(days); this.setDays(Math.floor(millsLeft / 86400000) * orient); millsLeft = millsLeft % 86400000; this.setHours(Math.floor(millsLeft / 3600000) * orient); millsLeft = millsLeft % 3600000; this.setMinutes(Math.floor(millsLeft / 60000) * orient); millsLeft = millsLeft % 60000; this.setSeconds(Math.floor(millsLeft / 1000) * orient); millsLeft = millsLeft % 1000; this.setMilliseconds(millsLeft * orient); } else { this.set(days, hours, minutes, seconds, milliseconds); } this.getTotalMilliseconds = function () { return (this.getDays() * 86400000) + (this.getHours() * 3600000) + (this.getMinutes() * 60000) + (this.getSeconds() * 1000); }; this.compareTo = function (time) { var t1 = new Date(1970, 1, 1, this.getHours(), this.getMinutes(), this.getSeconds()), t2; if (time === null) { t2 = new Date(1970, 1, 1, 0, 0, 0); } else { t2 = new Date(1970, 1, 1, time.getHours(), time.getMinutes(), time.getSeconds()); } return (t1 < t2) ? -1 : (t1 > t2) ? 1 : 0; }; this.equals = function (time) { return (this.compareTo(time) === 0); }; this.add = function (time) { return (time === null) ? this : this.addSeconds(time.getTotalMilliseconds() / 1000); }; this.subtract = function (time) { return (time === null) ? this : this.addSeconds(-time.getTotalMilliseconds() / 1000); }; this.addDays = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 86400000)); }; this.addHours = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 3600000)); }; this.addMinutes = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 60000)); }; this.addSeconds = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 1000)); }; this.addMilliseconds = function (n) { return new TimeSpan(this.getTotalMilliseconds() + n); }; this.get12HourHour = function () { return (this.getHours() > 12) ? this.getHours() - 12 : (this.getHours() === 0) ? 12 : this.getHours(); }; this.getDesignator = function () { return (this.getHours() < 12) ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator; }; this.toString = function (format) { this._toString = function () { if (this.getDays() !== null && this.getDays() > 0) { return this.getDays() + "." + this.getHours() + ":" + this.p(this.getMinutes()) + ":" + this.p(this.getSeconds()); } else { return this.getHours() + ":" + this.p(this.getMinutes()) + ":" + this.p(this.getSeconds()); } }; this.p = function (s) { return (s.toString().length < 2) ? "0" + s : s; }; var me = this; return format ? format.replace(/dd?|HH?|hh?|mm?|ss?|tt?/g, function (format) { switch (format) { case "d": return me.getDays(); case "dd": return me.p(me.getDays()); case "H": return me.getHours(); case "HH": return me.p(me.getHours()); case "h": return me.get12HourHour(); case "hh": return me.p(me.get12HourHour()); case "m": return me.getMinutes(); case "mm": return me.p(me.getMinutes()); case "s": return me.getSeconds(); case "ss": return me.p(me.getSeconds()); case "t": return ((me.getHours() < 12) ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator).substring(0, 1); case "tt": return (me.getHours() < 12) ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator; } } ) : this._toString(); }; return this; }; addSetFuncs(TimeSpan, attrs.slice(2)); TimeSpan.prototype.set = function (days, hours, minutes, seconds, milliseconds){ this.setDays(days || this.getDays()); this.setHours(hours || this.getHours()); this.setMinutes(minutes || this.getMinutes()); this.setSeconds(seconds || this.getSeconds()); this.setMilliseconds(milliseconds || this.getMilliseconds()); }; /** * Gets the time of day for this date instances. * @return {TimeSpan} TimeSpan */ Date.prototype.getTimeOfDay = function () { return new TimeSpan(0, this.getHours(), this.getMinutes(), this.getSeconds(), this.getMilliseconds()); }; Date.TimeSpan = TimeSpan; if (typeof window !== "undefined" ) { // keeping API compatible for v1.x window.TimeSpan = TimeSpan; } }()); (function () { "use strict"; var attrs = ["years", "months", "days", "hours", "minutes", "seconds", "milliseconds"]; var gFn = function (attr) { return function () { return this[attr]; }; }; var sFn = function (attr) { return function (val) { this[attr] = val; return this; }; }; var addSetFuncs = function (context, attrs) { for (var i = 0; i < attrs.length ; i++) { var $a = attrs[i], $b = $a.slice(0, 1).toUpperCase() + $a.slice(1); context.prototype[$a] = 0; context.prototype["get" + $b] = gFn($a); context.prototype["set" + $b] = sFn($a); } }; var setMonthsAndYears = function (orient, d1, d2, context) { function inc() { d1.addMonths(-orient); context.months++; if (context.months === 12) { context.years++; context.months = 0; } } if (orient === +1) { while (d1 > d2) { inc(); } } else { while (d1 < d2) { inc(); } } context.months--; context.months *= orient; context.years *= orient; }; var adjustForDST = function(orient, startDate, endDate) { var hasDSTMismatch = (false === (startDate.isDaylightSavingTime() === endDate.isDaylightSavingTime())); if (hasDSTMismatch && orient === 1) { startDate.addHours(-1); } else if (hasDSTMismatch) { startDate.addHours(1); } }; /** * TimePeriod(startDate, endDate); * TimePeriod(years, months, days, hours, minutes, seconds, milliseconds); */ var TimePeriod = function (years, months, days, hours, minutes, seconds, milliseconds) { if (arguments.length === 7) { this.set(years, months, days, hours, minutes, seconds, milliseconds); } else if (arguments.length === 2 && arguments[0] instanceof Date && arguments[1] instanceof Date) { var startDate = arguments[0].clone(); var endDate = arguments[1].clone(); var orient = (startDate > endDate) ? +1 : -1; this.dates = { start: arguments[0].clone(), end: arguments[1].clone() }; setMonthsAndYears(orient, startDate, endDate, this); adjustForDST(orient, startDate, endDate); // // TODO - adjust for DST var diff = endDate - startDate; if (diff !== 0) { var ts = new TimeSpan(diff); this.set(this.years, this.months, ts.getDays(), ts.getHours(), ts.getMinutes(), ts.getSeconds(), ts.getMilliseconds()); } } return this; }; // create all the set functions. addSetFuncs(TimePeriod, attrs); TimePeriod.prototype.set = function (years, months, days, hours, minutes, seconds, milliseconds){ this.setYears(years || this.getYears()); this.setMonths(months || this.getMonths()); this.setDays(days || this.getDays()); this.setHours(hours || this.getHours()); this.setMinutes(minutes || this.getMinutes()); this.setSeconds(seconds || this.getSeconds()); this.setMilliseconds(milliseconds || this.getMilliseconds()); }; Date.TimePeriod = TimePeriod; if (typeof window !== "undefined") { // keeping API compatible for v1.x window.TimePeriod = TimePeriod; } }()); ================================================ FILE: build/date-mt-MT.js ================================================ /** * @overview datejs * @version 1.0.0-rc3 * @author Gregory Wild-Smith * @copyright 2015 Gregory Wild-Smith * @license MIT * @homepage https://github.com/abritinthebay/datejs */ /* * DateJS Culture String File * Country Code: mt-MT * Name: Maltese (Malta) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["mt-MT"] = { "name": "mt-MT", "englishName": "Maltese (Malta)", "nativeName": "Malti (Malta)", "Sunday": "Il-Ħadd", "Monday": "It-Tnejn", "Tuesday": "It-Tlieta", "Wednesday": "L-Erbgħa", "Thursday": "Il-Ħamis", "Friday": "Il-Ġimgħa", "Saturday": "Is-Sibt", "Sun": "Ħad", "Mon": "Tne", "Tue": "Tli", "Wed": "Erb", "Thu": "Ħam", "Fri": "Ġim", "Sat": "Sib", "Su": "Ħad", "Mo": "Tne", "Tu": "Tli", "We": "Erb", "Th": "Ħam", "Fr": "Ġim", "Sa": "Sib", "S_Sun_Initial": "Ħ", "M_Mon_Initial": "T", "T_Tue_Initial": "T", "W_Wed_Initial": "E", "T_Thu_Initial": "Ħ", "F_Fri_Initial": "Ġ", "S_Sat_Initial": "S", "January": "Jannar", "February": "Frar", "March": "Marzu", "April": "April", "May": "Mejju", "June": "Ġunju", "July": "Lulju", "August": "Awissu", "September": "Settembru", "October": "Ottubru", "November": "Novembru", "December": "Diċembru", "Jan_Abbr": "Jan", "Feb_Abbr": "Fra", "Mar_Abbr": "Mar", "Apr_Abbr": "Apr", "May_Abbr": "Mej", "Jun_Abbr": "Ġun", "Jul_Abbr": "Lul", "Aug_Abbr": "Awi", "Sep_Abbr": "Set", "Oct_Abbr": "Ott", "Nov_Abbr": "Nov", "Dec_Abbr": "Diċ", "AM": "AM", "PM": "PM", "firstDayOfWeek": 1, "twoDigitYearMax": 2029, "mdy": "dmy", "M/d/yyyy": "dd/MM/yyyy", "dddd, MMMM dd, yyyy": "dddd, d' ta' 'MMMM yyyy", "h:mm tt": "HH:mm:ss", "h:mm:ss tt": "HH:mm:ss", "dddd, MMMM dd, yyyy h:mm:ss tt": "dddd, d' ta' 'MMMM yyyy HH:mm:ss", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "MMMM dd", "MMMM, yyyy": "MMMM yyyy", "/jan(uary)?/": "jan(nar)?", "/feb(ruary)?/": "fra(r)?", "/mar(ch)?/": "mar(zu)?", "/apr(il)?/": "apr(il)?", "/may/": "mej(ju)?", "/jun(e)?/": "ġun(ju)?", "/jul(y)?/": "lul(ju)?", "/aug(ust)?/": "awi(ssu)?", "/sep(t(ember)?)?/": "set(tembru)?", "/oct(ober)?/": "ott(ubru)?", "/nov(ember)?/": "nov(embru)?", "/dec(ember)?/": "diċ(embru)?", "/^su(n(day)?)?/": "^il-ħadd", "/^mo(n(day)?)?/": "^it-tnejn", "/^tu(e(s(day)?)?)?/": "^it-tlieta", "/^we(d(nesday)?)?/": "^l-erbgħa", "/^th(u(r(s(day)?)?)?)?/": "^il-ħamis", "/^fr(i(day)?)?/": "^il-ġimgħa", "/^sa(t(urday)?)?/": "^is-sibt", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "mt-MT"; /** * @overview datejs * @version 1.0.0-rc3 * @author Gregory Wild-Smith * @copyright 2015 Gregory Wild-Smith * @license MIT * @homepage https://github.com/abritinthebay/datejs */(function () { var $D = Date; var lang = Date.CultureStrings ? Date.CultureStrings.lang : null; var loggedKeys = {}; // for debug purposes. var getText = { getFromKey: function (key, countryCode) { var output; if (Date.CultureStrings && Date.CultureStrings[countryCode] && Date.CultureStrings[countryCode][key]) { output = Date.CultureStrings[countryCode][key]; } else { output = getText.buildFromDefault(key); } if (key.charAt(0) === "/") { // Assume it's a regex output = getText.buildFromRegex(key, countryCode); } return output; }, getFromObjectValues: function (obj, countryCode) { var key, output = {}; for(key in obj) { if (obj.hasOwnProperty(key)) { output[key] = getText.getFromKey(obj[key], countryCode); } } return output; }, getFromObjectKeys: function (obj, countryCode) { var key, output = {}; for(key in obj) { if (obj.hasOwnProperty(key)) { output[getText.getFromKey(key, countryCode)] = obj[key]; } } return output; }, getFromArray: function (arr, countryCode) { var output = []; for (var i=0; i < arr.length; i++){ if (i in arr) { output[i] = getText.getFromKey(arr[i], countryCode); } } return output; }, buildFromDefault: function (key) { var output, length, split, last; switch(key) { case "name": output = "en-US"; break; case "englishName": output = "English (United States)"; break; case "nativeName": output = "English (United States)"; break; case "twoDigitYearMax": output = 2049; break; case "firstDayOfWeek": output = 0; break; default: output = key; split = key.split("_"); length = split.length; if (length > 1 && key.charAt(0) !== "/") { // if the key isn't a regex and it has a split. last = split[(length - 1)].toLowerCase(); if (last === "initial" || last === "abbr") { output = split[0]; } } break; } return output; }, buildFromRegex: function (key, countryCode) { var output; if (Date.CultureStrings && Date.CultureStrings[countryCode] && Date.CultureStrings[countryCode][key]) { output = new RegExp(Date.CultureStrings[countryCode][key], "i"); } else { output = new RegExp(key.replace(new RegExp("/", "g"),""), "i"); } return output; } }; var shallowMerge = function (obj1, obj2) { for (var attrname in obj2) { if (obj2.hasOwnProperty(attrname)) { obj1[attrname] = obj2[attrname]; } } }; var __ = function (key, language) { var countryCode = (language) ? language : lang; loggedKeys[key] = key; if (typeof key === "object") { if (key instanceof Array) { return getText.getFromArray(key, countryCode); } else { return getText.getFromObjectKeys(key, countryCode); } } else { return getText.getFromKey(key, countryCode); } }; var loadI18nScript = function (code) { // paatterned after jQuery's getScript. var url = Date.Config.i18n + code + ".js"; var head = document.getElementsByTagName("head")[0] || document.documentElement; var script = document.createElement("script"); script.src = url; var completed = false; var events = { done: function (){} // placeholder function }; // Attach handlers for all browsers script.onload = script.onreadystatechange = function() { if ( !completed && (!this.readyState || this.readyState === "loaded" || this.readyState === "complete") ) { events.done(); head.removeChild(script); } }; setTimeout(function() { head.insertBefore(script, head.firstChild); }, 0); // allows return to execute first return { done: function (cb) { events.done = function() { if (cb) { setTimeout(cb,0); } }; } }; }; var buildInfo = { buildFromMethodHash: function (obj) { var key; for(key in obj) { if (obj.hasOwnProperty(key)) { obj[key] = buildInfo[obj[key]](); } } return obj; }, timeZoneDST: function () { var DST = { "CHADT": "+1345", "NZDT": "+1300", "AEDT": "+1100", "ACDT": "+1030", "AZST": "+0500", "IRDT": "+0430", "EEST": "+0300", "CEST": "+0200", "BST": "+0100", "PMDT": "-0200", "ADT": "-0300", "NDT": "-0230", "EDT": "-0400", "CDT": "-0500", "MDT": "-0600", "PDT": "-0700", "AKDT": "-0800", "HADT": "-0900" }; return __(DST); }, timeZoneStandard: function () { var standard = { "LINT": "+1400", "TOT": "+1300", "CHAST": "+1245", "NZST": "+1200", "NFT": "+1130", "SBT": "+1100", "AEST": "+1000", "ACST": "+0930", "JST": "+0900", "CWST": "+0845", "CT": "+0800", "ICT": "+0700", "MMT": "+0630", "BST": "+0600", "NPT": "+0545", "IST": "+0530", "PKT": "+0500", "AFT": "+0430", "MSK": "+0400", "IRST": "+0330", "FET": "+0300", "EET": "+0200", "CET": "+0100", "GMT": "+0000", "UTC": "+0000", "CVT": "-0100", "GST": "-0200", "BRT": "-0300", "NST": "-0330", "AST": "-0400", "EST": "-0500", "CST": "-0600", "MST": "-0700", "PST": "-0800", "AKST": "-0900", "MIT": "-0930", "HST": "-1000", "SST": "-1100", "BIT": "-1200" }; return __(standard); }, timeZones: function (data) { var zone; data.timezones = []; for (zone in data.abbreviatedTimeZoneStandard) { if (data.abbreviatedTimeZoneStandard.hasOwnProperty(zone)) { data.timezones.push({ name: zone, offset: data.abbreviatedTimeZoneStandard[zone]}); } } for (zone in data.abbreviatedTimeZoneDST) { if (data.abbreviatedTimeZoneDST.hasOwnProperty(zone)) { data.timezones.push({ name: zone, offset: data.abbreviatedTimeZoneDST[zone], dst: true}); } } return data.timezones; }, days: function () { return __(["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"]); }, dayAbbr: function () { return __(["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"]); }, dayShortNames: function () { return __(["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"]); }, dayFirstLetters: function () { return __(["S_Sun_Initial", "M_Mon_Initial", "T_Tues_Initial", "W_Wed_Initial", "T_Thu_Initial", "F_Fri_Initial", "S_Sat_Initial"]); }, months: function () { return __(["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"]); }, monthAbbr: function () { return __(["Jan_Abbr", "Feb_Abbr", "Mar_Abbr", "Apr_Abbr", "May_Abbr", "Jun_Abbr", "Jul_Abbr", "Aug_Abbr", "Sep_Abbr", "Oct_Abbr", "Nov_Abbr", "Dec_Abbr"]); }, formatPatterns: function () { return getText.getFromObjectValues({ shortDate: "M/d/yyyy", longDate: "dddd, MMMM dd, yyyy", shortTime: "h:mm tt", longTime: "h:mm:ss tt", fullDateTime: "dddd, MMMM dd, yyyy h:mm:ss tt", sortableDateTime: "yyyy-MM-ddTHH:mm:ss", universalSortableDateTime: "yyyy-MM-dd HH:mm:ssZ", rfc1123: "ddd, dd MMM yyyy HH:mm:ss", monthDay: "MMMM dd", yearMonth: "MMMM, yyyy" }, Date.i18n.currentLanguage()); }, regex: function () { return getText.getFromObjectValues({ inTheMorning: "/( in the )(morn(ing)?)\\b/", thisMorning: "/(this )(morn(ing)?)\\b/", amThisMorning: "/(\b\\d(am)? )(this )(morn(ing)?)/", inTheEvening: "/( in the )(even(ing)?)\\b/", thisEvening: "/(this )(even(ing)?)\\b/", pmThisEvening: "/(\b\\d(pm)? )(this )(even(ing)?)/", jan: "/jan(uary)?/", feb: "/feb(ruary)?/", mar: "/mar(ch)?/", apr: "/apr(il)?/", may: "/may/", jun: "/jun(e)?/", jul: "/jul(y)?/", aug: "/aug(ust)?/", sep: "/sep(t(ember)?)?/", oct: "/oct(ober)?/", nov: "/nov(ember)?/", dec: "/dec(ember)?/", sun: "/^su(n(day)?)?/", mon: "/^mo(n(day)?)?/", tue: "/^tu(e(s(day)?)?)?/", wed: "/^we(d(nesday)?)?/", thu: "/^th(u(r(s(day)?)?)?)?/", fri: "/fr(i(day)?)?/", sat: "/^sa(t(urday)?)?/", future: "/^next/", past: "/^last|past|prev(ious)?/", add: "/^(\\+|aft(er)?|from|hence)/", subtract: "/^(\\-|bef(ore)?|ago)/", yesterday: "/^yes(terday)?/", today: "/^t(od(ay)?)?/", tomorrow: "/^tom(orrow)?/", now: "/^n(ow)?/", millisecond: "/^ms|milli(second)?s?/", second: "/^sec(ond)?s?/", minute: "/^mn|min(ute)?s?/", hour: "/^h(our)?s?/", week: "/^w(eek)?s?/", month: "/^m(onth)?s?/", day: "/^d(ay)?s?/", year: "/^y(ear)?s?/", shortMeridian: "/^(a|p)/", longMeridian: "/^(a\\.?m?\\.?|p\\.?m?\\.?)/", timezone: "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/", ordinalSuffix: "/^\\s*(st|nd|rd|th)/", timeContext: "/^\\s*(\\:|a(?!u|p)|p)/" }, Date.i18n.currentLanguage()); } }; var CultureInfo = function () { var info = getText.getFromObjectValues({ name: "name", englishName: "englishName", nativeName: "nativeName", amDesignator: "AM", pmDesignator: "PM", firstDayOfWeek: "firstDayOfWeek", twoDigitYearMax: "twoDigitYearMax", dateElementOrder: "mdy" }, Date.i18n.currentLanguage()); var constructedInfo = buildInfo.buildFromMethodHash({ dayNames: "days", abbreviatedDayNames: "dayAbbr", shortestDayNames: "dayShortNames", firstLetterDayNames: "dayFirstLetters", monthNames: "months", abbreviatedMonthNames: "monthAbbr", formatPatterns: "formatPatterns", regexPatterns: "regex", abbreviatedTimeZoneDST: "timeZoneDST", abbreviatedTimeZoneStandard: "timeZoneStandard" }); shallowMerge(info, constructedInfo); buildInfo.timeZones(info); return info; }; $D.i18n = { __: function (key, lang) { return __(key, lang); }, currentLanguage: function () { return lang || "en-US"; }, setLanguage: function (code, force, cb) { var async = false; if (force || code === "en-US" || (!!Date.CultureStrings && !!Date.CultureStrings[code])) { lang = code; Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings.lang = code; Date.CultureInfo = new CultureInfo(); } else { if (!(!!Date.CultureStrings && !!Date.CultureStrings[code])) { if (typeof exports !== "undefined" && this.exports !== exports) { // we're in a Node enviroment, load it using require try { require("../i18n/" + code + ".js"); lang = code; Date.CultureStrings.lang = code; Date.CultureInfo = new CultureInfo(); } catch (e) { // var str = "The language for '" + code + "' could not be loaded by Node. It likely does not exist."; throw new Error("The DateJS IETF language tag '" + code + "' could not be loaded by Node. It likely does not exist."); } } else if (Date.Config && Date.Config.i18n) { // we know the location of the files, so lets load them async = true; loadI18nScript(code).done(function(){ lang = code; Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings.lang = code; Date.CultureInfo = new CultureInfo(); $D.Parsing.Normalizer.buildReplaceData(); // because this is async if ($D.Grammar) { $D.Grammar.buildGrammarFormats(); // so we can parse those strings... } if (cb) { setTimeout(cb,0); } }); } else { Date.console.error("The DateJS IETF language tag '" + code + "' is not available and has not been loaded."); return false; } } } $D.Parsing.Normalizer.buildReplaceData(); // rebuild normalizer strings if ($D.Grammar) { $D.Grammar.buildGrammarFormats(); // so we can parse those strings... } if (!async && cb) { setTimeout(cb,0); } }, getLoggedKeys: function () { return loggedKeys; }, updateCultureInfo: function () { Date.CultureInfo = new CultureInfo(); } }; $D.i18n.updateCultureInfo(); // run automatically }()); (function () { var $D = Date, $P = $D.prototype, p = function (s, l) { if (!l) { l = 2; } return ("000" + s).slice(l * -1); }; if (typeof window !== "undefined" && typeof window.console !== "undefined" && typeof window.console.log !== "undefined") { $D.console = console; // used only to raise non-critical errors if available } else { // set mock so we don't give errors. $D.console = { log: function(){}, error: function(){} }; } $D.Config = $D.Config || {}; $D.initOverloads = function() { /** * Overload of Date.now. Allows an alternate call for Date.now where it returns the * current Date as an object rather than just milliseconds since the Unix Epoch. * * Also provides an implementation of now() for browsers (IE<9) that don't have it. * * Backwards compatible so with work with either: * Date.now() [returns ms] * or * Date.now(true) [returns Date] */ if (!$D.now) { $D._now = function now() { return new Date().getTime(); }; } else if (!$D._now) { $D._now = $D.now; } $D.now = function (returnObj) { if (returnObj) { return $D.present(); } else { return $D._now(); } }; if ( !$P.toISOString ) { $P.toISOString = function() { return this.getUTCFullYear() + "-" + p(this.getUTCMonth() + 1) + "-" + p(this.getUTCDate()) + "T" + p(this.getUTCHours()) + ":" + p(this.getUTCMinutes()) + ":" + p(this.getUTCSeconds()) + "." + String( (this.getUTCMilliseconds()/1000).toFixed(3)).slice(2, 5) + "Z"; }; } // private if ( $P._toString === undefined ){ $P._toString = $P.toString; } }; $D.initOverloads(); /** * Gets a date that is set to the current date. The time is set to the start of the day (00:00 or 12:00 AM). * @return {Date} The current date. */ $D.today = function () { return new Date().clearTime(); }; /** * Gets a date that is set to the current date and time (same as new Date, but chainable) * @return {Date} The current date. */ $D.present = function () { return new Date(); }; /** * Compares the first date to the second date and returns an number indication of their relative values. * @param {Date} First Date object to compare [Required]. * @param {Date} Second Date object to compare to [Required]. * @return {Number} -1 = date1 is lessthan date2. 0 = values are equal. 1 = date1 is greaterthan date2. */ $D.compare = function (date1, date2) { if (isNaN(date1) || isNaN(date2)) { throw new Error(date1 + " - " + date2); } else if (date1 instanceof Date && date2 instanceof Date) { return (date1 < date2) ? -1 : (date1 > date2) ? 1 : 0; } else { throw new TypeError(date1 + " - " + date2); } }; /** * Compares the first Date object to the second Date object and returns true if they are equal. * @param {Date} First Date object to compare [Required] * @param {Date} Second Date object to compare to [Required] * @return {Boolean} true if dates are equal. false if they are not equal. */ $D.equals = function (date1, date2) { return (date1.compareTo(date2) === 0); }; /** * Gets the language appropriate day name when given the day number(0-6) * eg - 0 == Sunday * @return {String} The day name */ $D.getDayName = function (n) { return Date.CultureInfo.dayNames[n]; }; /** * Gets the day number (0-6) if given a CultureInfo specific string which is a valid dayName, abbreviatedDayName or shortestDayName (two char). * @param {String} The name of the day (eg. "Monday, "Mon", "tuesday", "tue", "We", "we"). * @return {Number} The day number */ $D.getDayNumberFromName = function (name) { var n = Date.CultureInfo.dayNames, m = Date.CultureInfo.abbreviatedDayNames, o = Date.CultureInfo.shortestDayNames, s = name.toLowerCase(); for (var i = 0; i < n.length; i++) { if (n[i].toLowerCase() === s || m[i].toLowerCase() === s || o[i].toLowerCase() === s) { return i; } } return -1; }; /** * Gets the month number (0-11) if given a Culture Info specific string which is a valid monthName or abbreviatedMonthName. * @param {String} The name of the month (eg. "February, "Feb", "october", "oct"). * @return {Number} The day number */ $D.getMonthNumberFromName = function (name) { var n = Date.CultureInfo.monthNames, m = Date.CultureInfo.abbreviatedMonthNames, s = name.toLowerCase(); for (var i = 0; i < n.length; i++) { if (n[i].toLowerCase() === s || m[i].toLowerCase() === s) { return i; } } return -1; }; /** * Gets the language appropriate month name when given the month number(0-11) * eg - 0 == January * @return {String} The month name */ $D.getMonthName = function (n) { return Date.CultureInfo.monthNames[n]; }; /** * Determines if the current date instance is within a LeapYear. * @param {Number} The year. * @return {Boolean} true if date is within a LeapYear, otherwise false. */ $D.isLeapYear = function (year) { return ((year % 4 === 0 && year % 100 !== 0) || year % 400 === 0); }; /** * Gets the number of days in the month, given a year and month value. Automatically corrects for LeapYear. * @param {Number} The year. * @param {Number} The month (0-11). * @return {Number} The number of days in the month. */ $D.getDaysInMonth = function (year, month) { if (!month && $D.validateMonth(year)) { month = year; year = Date.today().getFullYear(); } return [31, ($D.isLeapYear(year) ? 29 : 28), 31, 30, 31, 30, 31, 31, 30, 31, 30, 31][month]; }; $P.getDaysInMonth = function () { return $D.getDaysInMonth(this.getFullYear(), this.getMonth()); }; $D.getTimezoneAbbreviation = function (offset, dst) { var p, n = (dst || false) ? Date.CultureInfo.abbreviatedTimeZoneDST : Date.CultureInfo.abbreviatedTimeZoneStandard; for (p in n) { if (n.hasOwnProperty(p)) { if (n[p] === offset) { return p; } } } return null; }; $D.getTimezoneOffset = function (name, dst) { var i, a =[], z = Date.CultureInfo.timezones; if (!name) { name = (new Date()).getTimezone();} for (i = 0; i < z.length; i++) { if (z[i].name === name.toUpperCase()) { a.push(i); } } if (!z[a[0]]) { return null; } if (a.length === 1 || !dst) { return z[a[0]].offset; } else { for (i=0; i < a.length; i++) { if (z[a[i]].dst) { return z[a[i]].offset; } } } }; $D.getQuarter = function (d) { d = d || new Date(); // If no date supplied, use today var q = [1,2,3,4]; return q[Math.floor(d.getMonth() / 3)]; // ~~~ is a bitwise op. Faster than Math.floor }; $D.getDaysLeftInQuarter = function (d) { d = d || new Date(); var qEnd = new Date(d); qEnd.setMonth(qEnd.getMonth() + 3 - qEnd.getMonth() % 3, 0); return Math.floor((qEnd - d) / 8.64e7); }; // private var validate = function (n, min, max, name) { name = name ? name : "Object"; if (typeof n === "undefined") { return false; } else if (typeof n !== "number") { throw new TypeError(n + " is not a Number."); } else if (n < min || n > max) { // As failing validation is *not* an exceptional circumstance // lets not throw a RangeError Exception here. // It's semantically correct but it's not sensible. return false; } return true; }; /** * Validates the number is within an acceptable range for milliseconds [0-999]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateMillisecond = function (value) { return validate(value, 0, 999, "millisecond"); }; /** * Validates the number is within an acceptable range for seconds [0-59]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateSecond = function (value) { return validate(value, 0, 59, "second"); }; /** * Validates the number is within an acceptable range for minutes [0-59]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateMinute = function (value) { return validate(value, 0, 59, "minute"); }; /** * Validates the number is within an acceptable range for hours [0-23]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateHour = function (value) { return validate(value, 0, 23, "hour"); }; /** * Validates the number is within an acceptable range for the days in a month [0-MaxDaysInMonth]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateDay = function (value, year, month) { if (year === undefined || year === null || month === undefined || month === null) { return false;} return validate(value, 1, $D.getDaysInMonth(year, month), "day"); }; /** * Validates the number is within an acceptable range for months [0-11]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateWeek = function (value) { return validate(value, 0, 53, "week"); }; /** * Validates the number is within an acceptable range for months [0-11]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateMonth = function (value) { return validate(value, 0, 11, "month"); }; /** * Validates the number is within an acceptable range for years. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateYear = function (value) { /** * Per ECMAScript spec the range of times supported by Date objects is * exactly -100,000,000 days to +100,000,000 days measured relative to * midnight at the beginning of 01 January, 1970 UTC. * This gives a range of 8,640,000,000,000,000 milliseconds to either * side of 01 January, 1970 UTC. * * Earliest possible date: Tue, 20 Apr 271,822 B.C. 00:00:00 UTC * Latest possible date: Sat, 13 Sep 275,760 00:00:00 UTC */ return validate(value, -271822, 275760, "year"); }; $D.validateTimezone = function(value) { var timezones = {"ACDT":1,"ACST":1,"ACT":1,"ADT":1,"AEDT":1,"AEST":1,"AFT":1,"AKDT":1,"AKST":1,"AMST":1,"AMT":1,"ART":1,"AST":1,"AWDT":1,"AWST":1,"AZOST":1,"AZT":1,"BDT":1,"BIOT":1,"BIT":1,"BOT":1,"BRT":1,"BST":1,"BTT":1,"CAT":1,"CCT":1,"CDT":1,"CEDT":1,"CEST":1,"CET":1,"CHADT":1,"CHAST":1,"CHOT":1,"ChST":1,"CHUT":1,"CIST":1,"CIT":1,"CKT":1,"CLST":1,"CLT":1,"COST":1,"COT":1,"CST":1,"CT":1,"CVT":1,"CWST":1,"CXT":1,"DAVT":1,"DDUT":1,"DFT":1,"EASST":1,"EAST":1,"EAT":1,"ECT":1,"EDT":1,"EEDT":1,"EEST":1,"EET":1,"EGST":1,"EGT":1,"EIT":1,"EST":1,"FET":1,"FJT":1,"FKST":1,"FKT":1,"FNT":1,"GALT":1,"GAMT":1,"GET":1,"GFT":1,"GILT":1,"GIT":1,"GMT":1,"GST":1,"GYT":1,"HADT":1,"HAEC":1,"HAST":1,"HKT":1,"HMT":1,"HOVT":1,"HST":1,"ICT":1,"IDT":1,"IOT":1,"IRDT":1,"IRKT":1,"IRST":1,"IST":1,"JST":1,"KGT":1,"KOST":1,"KRAT":1,"KST":1,"LHST":1,"LINT":1,"MAGT":1,"MART":1,"MAWT":1,"MDT":1,"MET":1,"MEST":1,"MHT":1,"MIST":1,"MIT":1,"MMT":1,"MSK":1,"MST":1,"MUT":1,"MVT":1,"MYT":1,"NCT":1,"NDT":1,"NFT":1,"NPT":1,"NST":1,"NT":1,"NUT":1,"NZDT":1,"NZST":1,"OMST":1,"ORAT":1,"PDT":1,"PET":1,"PETT":1,"PGT":1,"PHOT":1,"PHT":1,"PKT":1,"PMDT":1,"PMST":1,"PONT":1,"PST":1,"PYST":1,"PYT":1,"RET":1,"ROTT":1,"SAKT":1,"SAMT":1,"SAST":1,"SBT":1,"SCT":1,"SGT":1,"SLST":1,"SRT":1,"SST":1,"SYOT":1,"TAHT":1,"THA":1,"TFT":1,"TJT":1,"TKT":1,"TLT":1,"TMT":1,"TOT":1,"TVT":1,"UCT":1,"ULAT":1,"UTC":1,"UYST":1,"UYT":1,"UZT":1,"VET":1,"VLAT":1,"VOLT":1,"VOST":1,"VUT":1,"WAKT":1,"WAST":1,"WAT":1,"WEDT":1,"WEST":1,"WET":1,"WST":1,"YAKT":1,"YEKT":1,"Z":1}; return (timezones[value] === 1); }; $D.validateTimezoneOffset= function(value) { // timezones go from +14hrs to -12hrs, the +X hours are negative offsets. return (value > -841 && value < 721); }; }()); (function () { var $D = Date, $P = $D.prototype, p = function (s, l) { if (!l) { l = 2; } return ("000" + s).slice(l * -1); }; var validateConfigObject = function (obj) { var result = {}, self = this, prop, testFunc; testFunc = function (prop, func, value) { if (prop === "day") { var month = (obj.month !== undefined) ? obj.month : self.getMonth(); var year = (obj.year !== undefined) ? obj.year : self.getFullYear(); return $D[func](value, year, month); } else { return $D[func](value); } }; for (prop in obj) { if (Object.prototype.hasOwnProperty.call(obj, prop)) { var func = "validate" + prop.charAt(0).toUpperCase() + prop.slice(1); if ($D[func] && obj[prop] !== null && testFunc(prop, func, obj[prop])) { result[prop] = obj[prop]; } } } return result; }; /** * Resets the time of this Date object to 12:00 AM (00:00), which is the start of the day. * @param {Boolean} .clone() this date instance before clearing Time * @return {Date} this */ $P.clearTime = function () { this.setHours(0); this.setMinutes(0); this.setSeconds(0); this.setMilliseconds(0); return this; }; /** * Resets the time of this Date object to the current time ('now'). * @return {Date} this */ $P.setTimeToNow = function () { var n = new Date(); this.setHours(n.getHours()); this.setMinutes(n.getMinutes()); this.setSeconds(n.getSeconds()); this.setMilliseconds(n.getMilliseconds()); return this; }; /** * Returns a new Date object that is an exact date and time copy of the original instance. * @return {Date} A new Date instance */ $P.clone = function () { return new Date(this.getTime()); }; /** * Compares this instance to a Date object and returns an number indication of their relative values. * @param {Date} Date object to compare [Required] * @return {Number} -1 = this is lessthan date. 0 = values are equal. 1 = this is greaterthan date. */ $P.compareTo = function (date) { return Date.compare(this, date); }; /** * Compares this instance to another Date object and returns true if they are equal. * @param {Date} Date object to compare. If no date to compare, new Date() [now] is used. * @return {Boolean} true if dates are equal. false if they are not equal. */ $P.equals = function (date) { return Date.equals(this, (date !== undefined ? date : new Date())); }; /** * Determines if this instance is between a range of two dates or equal to either the start or end dates. * @param {Date} Start of range [Required] * @param {Date} End of range [Required] * @return {Boolean} true is this is between or equal to the start and end dates, else false */ $P.between = function (start, end) { return this.getTime() >= start.getTime() && this.getTime() <= end.getTime(); }; /** * Determines if this date occurs after the date to compare to. * @param {Date} Date object to compare. If no date to compare, new Date() ("now") is used. * @return {Boolean} true if this date instance is greater than the date to compare to (or "now"), otherwise false. */ $P.isAfter = function (date) { return this.compareTo(date || new Date()) === 1; }; /** * Determines if this date occurs before the date to compare to. * @param {Date} Date object to compare. If no date to compare, new Date() ("now") is used. * @return {Boolean} true if this date instance is less than the date to compare to (or "now"). */ $P.isBefore = function (date) { return (this.compareTo(date || new Date()) === -1); }; /** * Determines if the current Date instance occurs today. * @return {Boolean} true if this date instance is 'today', otherwise false. */ /** * Determines if the current Date instance occurs on the same Date as the supplied 'date'. * If no 'date' to compare to is provided, the current Date instance is compared to 'today'. * @param {date} Date object to compare. If no date to compare, the current Date ("now") is used. * @return {Boolean} true if this Date instance occurs on the same Day as the supplied 'date'. */ $P.isToday = $P.isSameDay = function (date) { return this.clone().clearTime().equals((date || new Date()).clone().clearTime()); }; /** * Adds the specified number of milliseconds to this instance. * @param {Number} The number of milliseconds to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addMilliseconds = function (value) { if (!value) { return this; } this.setTime(this.getTime() + value * 1); return this; }; /** * Adds the specified number of seconds to this instance. * @param {Number} The number of seconds to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addSeconds = function (value) { if (!value) { return this; } return this.addMilliseconds(value * 1000); }; /** * Adds the specified number of seconds to this instance. * @param {Number} The number of seconds to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addMinutes = function (value) { if (!value) { return this; } return this.addMilliseconds(value * 60000); // 60*1000 }; /** * Adds the specified number of hours to this instance. * @param {Number} The number of hours to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addHours = function (value) { if (!value) { return this; } return this.addMilliseconds(value * 3600000); // 60*60*1000 }; /** * Adds the specified number of days to this instance. * @param {Number} The number of days to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addDays = function (value) { if (!value) { return this; } this.setDate(this.getDate() + value * 1); return this; }; /** * Adds the specified number of weekdays (ie - not sat or sun) to this instance. * @param {Number} The number of days to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addWeekdays = function (value) { if (!value) { return this; } var day = this.getDay(); var weeks = (Math.ceil(Math.abs(value)/7)); if (day === 0 || day === 6) { if (value > 0) { this.next().monday(); this.addDays(-1); day = this.getDay(); } } if (value < 0) { while (value < 0) { this.addDays(-1); day = this.getDay(); if (day !== 0 && day !== 6) { value++; } } return this; } else if (value > 5 || (6-day) <= value) { value = value + (weeks * 2); } return this.addDays(value); }; /** * Adds the specified number of weeks to this instance. * @param {Number} The number of weeks to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addWeeks = function (value) { if (!value) { return this; } return this.addDays(value * 7); }; /** * Adds the specified number of months to this instance. * @param {Number} The number of months to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addMonths = function (value) { if (!value) { return this; } var n = this.getDate(); this.setDate(1); this.setMonth(this.getMonth() + value * 1); this.setDate(Math.min(n, $D.getDaysInMonth(this.getFullYear(), this.getMonth()))); return this; }; $P.addQuarters = function (value) { if (!value) { return this; } // note this will take you to the same point in the quarter as you are now. // i.e. - if you are 15 days into the quarter you'll be 15 days into the resulting one. // bonus: this allows adding fractional quarters return this.addMonths(value * 3); }; /** * Adds the specified number of years to this instance. * @param {Number} The number of years to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addYears = function (value) { if (!value) { return this; } return this.addMonths(value * 12); }; /** * Adds (or subtracts) to the value of the years, months, weeks, days, hours, minutes, seconds, milliseconds of the date instance using given configuration object. Positive and Negative values allowed. * Example

	Date.today().add( { days: 1, months: 1 } )

	new Date().add( { years: -1 } )
	
* @param {Object} Configuration object containing attributes (months, days, etc.) * @return {Date} this */ $P.add = function (config) { if (typeof config === "number") { this._orient = config; return this; } var x = config; if (x.day) { // If we should be a different date than today (eg: for 'tomorrow -1d', etc). // Should only effect parsing, not direct usage (eg, Finish and FinishExact) if ((x.day - this.getDate()) !== 0) { this.setDate(x.day); } } if (x.milliseconds) { this.addMilliseconds(x.milliseconds); } if (x.seconds) { this.addSeconds(x.seconds); } if (x.minutes) { this.addMinutes(x.minutes); } if (x.hours) { this.addHours(x.hours); } if (x.weeks) { this.addWeeks(x.weeks); } if (x.months) { this.addMonths(x.months); } if (x.years) { this.addYears(x.years); } if (x.days) { this.addDays(x.days); } return this; }; /** * Get the week number. Week one (1) is the week which contains the first Thursday of the year. Monday is considered the first day of the week. * The .getWeek() function does NOT convert the date to UTC. The local datetime is used. * Please use .getISOWeek() to get the week of the UTC converted date. * @return {Number} 1 to 53 */ $P.getWeek = function (utc) { // Create a copy of this date object var self, target = new Date(this.valueOf()); if (utc) { target.addMinutes(target.getTimezoneOffset()); self = target.clone(); } else { self = this; } // ISO week date weeks start on monday // so correct the day number var dayNr = (self.getDay() + 6) % 7; // ISO 8601 states that week 1 is the week // with the first thursday of that year. // Set the target date to the thursday in the target week target.setDate(target.getDate() - dayNr + 3); // Store the millisecond value of the target date var firstThursday = target.valueOf(); // Set the target to the first thursday of the year // First set the target to january first target.setMonth(0, 1); // Not a thursday? Correct the date to the next thursday if (target.getDay() !== 4) { target.setMonth(0, 1 + ((4 - target.getDay()) + 7) % 7); } // The weeknumber is the number of weeks between the // first thursday of the year and the thursday in the target week return 1 + Math.ceil((firstThursday - target) / 604800000); // 604800000 = 7 * 24 * 3600 * 1000 }; /** * Get the ISO 8601 week number. Week one ("01") is the week which contains the first Thursday of the year. Monday is considered the first day of the week. * The .getISOWeek() function does convert the date to it's UTC value. Please use .getWeek() to get the week of the local date. * @return {String} "01" to "53" */ $P.getISOWeek = function () { return p(this.getWeek(true)); }; /** * Moves the date to Monday of the week set. Week one (1) is the week which contains the first Thursday of the year. * @param {Number} A Number (1 to 53) that represents the week of the year. * @return {Date} this */ $P.setWeek = function (n) { if ((n - this.getWeek()) === 0) { if (this.getDay() !== 1) { return this.moveToDayOfWeek(1, (this.getDay() > 1 ? -1 : 1)); } else { return this; } } else { return this.moveToDayOfWeek(1, (this.getDay() > 1 ? -1 : 1)).addWeeks(n - this.getWeek()); } }; $P.setQuarter = function (qtr) { var month = Math.abs(((qtr-1) * 3) + 1); return this.setMonth(month, 1); }; $P.getQuarter = function () { return Date.getQuarter(this); }; $P.getDaysLeftInQuarter = function () { return Date.getDaysLeftInQuarter(this); }; /** * Moves the date to the next n'th occurrence of the dayOfWeek starting from the beginning of the month. The number (-1) is a magic number and will return the last occurrence of the dayOfWeek in the month. * @param {Number} The dayOfWeek to move to * @param {Number} The n'th occurrence to move to. Use (-1) to return the last occurrence in the month * @return {Date} this */ $P.moveToNthOccurrence = function (dayOfWeek, occurrence) { if (dayOfWeek === "Weekday") { if (occurrence > 0) { this.moveToFirstDayOfMonth(); if (this.is().weekday()) { occurrence -= 1; } } else if (occurrence < 0) { this.moveToLastDayOfMonth(); if (this.is().weekday()) { occurrence += 1; } } else { return this; } return this.addWeekdays(occurrence); } var shift = 0; if (occurrence > 0) { shift = occurrence - 1; } else if (occurrence === -1) { this.moveToLastDayOfMonth(); if (this.getDay() !== dayOfWeek) { this.moveToDayOfWeek(dayOfWeek, -1); } return this; } return this.moveToFirstDayOfMonth().addDays(-1).moveToDayOfWeek(dayOfWeek, +1).addWeeks(shift); }; var moveToN = function (getFunc, addFunc, nVal) { return function (value, orient) { var diff = (value - this[getFunc]() + nVal * (orient || +1)) % nVal; return this[addFunc]((diff === 0) ? diff += nVal * (orient || +1) : diff); }; }; /** * Move to the next or last dayOfWeek based on the orient value. * @param {Number} The dayOfWeek to move to * @param {Number} Forward (+1) or Back (-1). Defaults to +1. [Optional] * @return {Date} this */ $P.moveToDayOfWeek = moveToN("getDay", "addDays", 7); /** * Move to the next or last month based on the orient value. * @param {Number} The month to move to. 0 = January, 11 = December * @param {Number} Forward (+1) or Back (-1). Defaults to +1. [Optional] * @return {Date} this */ $P.moveToMonth = moveToN("getMonth", "addMonths", 12); /** * Get the Ordinate of the current day ("th", "st", "rd"). * @return {String} */ $P.getOrdinate = function () { var num = this.getDate(); return ord(num); }; /** * Get the Ordinal day (numeric day number) of the year, adjusted for leap year. * @return {Number} 1 through 365 (366 in leap years) */ $P.getOrdinalNumber = function () { return Math.ceil((this.clone().clearTime() - new Date(this.getFullYear(), 0, 1)) / 86400000) + 1; }; /** * Get the time zone abbreviation of the current date. * @return {String} The abbreviated time zone name (e.g. "EST") */ $P.getTimezone = function () { return $D.getTimezoneAbbreviation(this.getUTCOffset(), this.isDaylightSavingTime()); }; $P.setTimezoneOffset = function (offset) { var here = this.getTimezoneOffset(), there = Number(offset) * -6 / 10; return (there || there === 0) ? this.addMinutes(there - here) : this; }; $P.setTimezone = function (offset) { return this.setTimezoneOffset($D.getTimezoneOffset(offset)); }; /** * Indicates whether Daylight Saving Time is observed in the current time zone. * @return {Boolean} true|false */ $P.hasDaylightSavingTime = function () { return (Date.today().set({month: 0, day: 1}).getTimezoneOffset() !== Date.today().set({month: 6, day: 1}).getTimezoneOffset()); }; /** * Indicates whether this Date instance is within the Daylight Saving Time range for the current time zone. * @return {Boolean} true|false */ $P.isDaylightSavingTime = function () { return Date.today().set({month: 0, day: 1}).getTimezoneOffset() !== this.getTimezoneOffset(); }; /** * Get the offset from UTC of the current date. * @return {String} The 4-character offset string prefixed with + or - (e.g. "-0500") */ $P.getUTCOffset = function (offset) { var n = (offset || this.getTimezoneOffset()) * -10 / 6, r; if (n < 0) { r = (n - 10000).toString(); return r.charAt(0) + r.substr(2); } else { r = (n + 10000).toString(); return "+" + r.substr(1); } }; /** * Returns the number of milliseconds between this date and date. * @param {Date} Defaults to now * @return {Number} The diff in milliseconds */ $P.getElapsed = function (date) { return (date || new Date()) - this; }; /** * Set the value of year, month, day, hour, minute, second, millisecond of date instance using given configuration object. * Example

	Date.today().set( { day: 20, month: 1 } )

	new Date().set( { millisecond: 0 } )
	
* * @param {Object} Configuration object containing attributes (month, day, etc.) * @return {Date} this */ $P.set = function (config) { config = validateConfigObject.call(this, config); var key; for (key in config) { if (Object.prototype.hasOwnProperty.call(config, key)) { var name = key.charAt(0).toUpperCase() + key.slice(1); var addFunc, getFunc; if (key !== "week" && key !== "month" && key !== "timezone" && key !== "timezoneOffset") { name += "s"; } addFunc = "add" + name; getFunc = "get" + name; if (key === "month") { addFunc = addFunc + "s"; } else if (key === "year"){ getFunc = "getFullYear"; } if (key !== "day" && key !== "timezone" && key !== "timezoneOffset" && key !== "week" && key !== "hour") { this[addFunc](config[key] - this[getFunc]()); } else if ( key === "timezone"|| key === "timezoneOffset" || key === "week" || key === "hour") { this["set"+name](config[key]); } } } // day has to go last because you can't validate the day without first knowing the month if (config.day) { this.addDays(config.day - this.getDate()); } return this; }; /** * Moves the date to the first day of the month. * @return {Date} this */ $P.moveToFirstDayOfMonth = function () { return this.set({ day: 1 }); }; /** * Moves the date to the last day of the month. * @return {Date} this */ $P.moveToLastDayOfMonth = function () { return this.set({ day: $D.getDaysInMonth(this.getFullYear(), this.getMonth())}); }; /** * Converts the value of the current Date object to its equivalent string representation. * Format Specifiers * CUSTOM DATE AND TIME FORMAT STRINGS * Format Description Example * ------ --------------------------------------------------------------------------- ----------------------- * s The seconds of the minute between 0-59. "0" to "59" * ss The seconds of the minute with leading zero if required. "00" to "59" * * m The minute of the hour between 0-59. "0" or "59" * mm The minute of the hour with leading zero if required. "00" or "59" * * h The hour of the day between 1-12. "1" to "12" * hh The hour of the day with leading zero if required. "01" to "12" * * H The hour of the day between 0-23. "0" to "23" * HH The hour of the day with leading zero if required. "00" to "23" * * d The day of the month between 1 and 31. "1" to "31" * dd The day of the month with leading zero if required. "01" to "31" * ddd Abbreviated day name. Date.CultureInfo.abbreviatedDayNames. "Mon" to "Sun" * dddd The full day name. Date.CultureInfo.dayNames. "Monday" to "Sunday" * * M The month of the year between 1-12. "1" to "12" * MM The month of the year with leading zero if required. "01" to "12" * MMM Abbreviated month name. Date.CultureInfo.abbreviatedMonthNames. "Jan" to "Dec" * MMMM The full month name. Date.CultureInfo.monthNames. "January" to "December" * * yy The year as a two-digit number. "99" or "08" * yyyy The full four digit year. "1999" or "2008" * * t Displays the first character of the A.M./P.M. designator. "A" or "P" * Date.CultureInfo.amDesignator or Date.CultureInfo.pmDesignator * tt Displays the A.M./P.M. designator. "AM" or "PM" * Date.CultureInfo.amDesignator or Date.CultureInfo.pmDesignator * * S The ordinal suffix ("st, "nd", "rd" or "th") of the current day. "st, "nd", "rd" or "th" * * STANDARD DATE AND TIME FORMAT STRINGS * Format Description Example *------ --------------------------------------------------------------------------- ----------------------- * d The CultureInfo shortDate Format Pattern "M/d/yyyy" * D The CultureInfo longDate Format Pattern "dddd, MMMM dd, yyyy" * F The CultureInfo fullDateTime Format Pattern "dddd, MMMM dd, yyyy h:mm:ss tt" * m The CultureInfo monthDay Format Pattern "MMMM dd" * r The CultureInfo rfc1123 Format Pattern "ddd, dd MMM yyyy HH:mm:ss GMT" * s The CultureInfo sortableDateTime Format Pattern "yyyy-MM-ddTHH:mm:ss" * t The CultureInfo shortTime Format Pattern "h:mm tt" * T The CultureInfo longTime Format Pattern "h:mm:ss tt" * u The CultureInfo universalSortableDateTime Format Pattern "yyyy-MM-dd HH:mm:ssZ" * y The CultureInfo yearMonth Format Pattern "MMMM, yyyy" * * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @return {String} A string representation of the current Date object. */ var ord = function (n) { switch (n * 1) { case 1: case 21: case 31: return "st"; case 2: case 22: return "nd"; case 3: case 23: return "rd"; default: return "th"; } }; var parseStandardFormats = function (format) { var y, c = Date.CultureInfo.formatPatterns; switch (format) { case "d": return this.toString(c.shortDate); case "D": return this.toString(c.longDate); case "F": return this.toString(c.fullDateTime); case "m": return this.toString(c.monthDay); case "r": case "R": y = this.clone().addMinutes(this.getTimezoneOffset()); return y.toString(c.rfc1123) + " GMT"; case "s": return this.toString(c.sortableDateTime); case "t": return this.toString(c.shortTime); case "T": return this.toString(c.longTime); case "u": y = this.clone().addMinutes(this.getTimezoneOffset()); return y.toString(c.universalSortableDateTime); case "y": return this.toString(c.yearMonth); default: return false; } }; var parseFormatStringsClosure = function (context) { return function (m) { if (m.charAt(0) === "\\") { return m.replace("\\", ""); } switch (m) { case "hh": return p(context.getHours() < 13 ? (context.getHours() === 0 ? 12 : context.getHours()) : (context.getHours() - 12)); case "h": return context.getHours() < 13 ? (context.getHours() === 0 ? 12 : context.getHours()) : (context.getHours() - 12); case "HH": return p(context.getHours()); case "H": return context.getHours(); case "mm": return p(context.getMinutes()); case "m": return context.getMinutes(); case "ss": return p(context.getSeconds()); case "s": return context.getSeconds(); case "yyyy": return p(context.getFullYear(), 4); case "yy": return p(context.getFullYear()); case "y": return context.getFullYear(); case "E": case "dddd": return Date.CultureInfo.dayNames[context.getDay()]; case "ddd": return Date.CultureInfo.abbreviatedDayNames[context.getDay()]; case "dd": return p(context.getDate()); case "d": return context.getDate(); case "MMMM": return Date.CultureInfo.monthNames[context.getMonth()]; case "MMM": return Date.CultureInfo.abbreviatedMonthNames[context.getMonth()]; case "MM": return p((context.getMonth() + 1)); case "M": return context.getMonth() + 1; case "t": return context.getHours() < 12 ? Date.CultureInfo.amDesignator.substring(0, 1) : Date.CultureInfo.pmDesignator.substring(0, 1); case "tt": return context.getHours() < 12 ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator; case "S": return ord(context.getDate()); case "W": return context.getWeek(); case "WW": return context.getISOWeek(); case "Q": return "Q" + context.getQuarter(); case "q": return String(context.getQuarter()); case "z": return context.getTimezone(); case "Z": case "X": return Date.getTimezoneOffset(context.getTimezone()); case "ZZ": // Timezone offset in seconds return context.getTimezoneOffset() * -60; case "u": return context.getDay(); case "L": return ($D.isLeapYear(context.getFullYear())) ? 1 : 0; case "B": // Swatch Internet Time (.beats) return "@"+((context.getUTCSeconds() + (context.getUTCMinutes()*60) + ((context.getUTCHours()+1)*3600))/86.4); default: return m; } }; }; $P.toString = function (format, ignoreStandards) { // Standard Date and Time Format Strings. Formats pulled from CultureInfo file and // may vary by culture. if (!ignoreStandards && format && format.length === 1) { output = parseStandardFormats.call(this, format); if (output) { return output; } } var parseFormatStrings = parseFormatStringsClosure(this); return format ? format.replace(/((\\)?(dd?d?d?|MM?M?M?|yy?y?y?|hh?|HH?|mm?|ss?|tt?|S|q|Q|WW?W?W?)(?![^\[]*\]))/g, parseFormatStrings).replace(/\[|\]/g, "") : this._toString(); }; }()); /************************************************************* * SugarPak - Domain Specific Language - Syntactical Sugar * *************************************************************/ (function () { var $D = Date, $P = $D.prototype, $N = Number.prototype; // private $P._orient = +1; // private $P._nth = null; // private $P._is = false; // private $P._same = false; // private $P._isSecond = false; // private $N._dateElement = "days"; /** * Moves the date to the next instance of a date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.today().next().friday();
	Date.today().next().fri();
	Date.today().next().march();
	Date.today().next().mar();
	Date.today().next().week();
	
* * @return {Date} date */ $P.next = function () { this._move = true; this._orient = +1; return this; }; /** * Creates a new Date (Date.today()) and moves the date to the next instance of the date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.next().friday();
	Date.next().fri();
	Date.next().march();
	Date.next().mar();
	Date.next().week();
	
* * @return {Date} date */ $D.next = function () { return $D.today().next(); }; /** * Moves the date to the previous instance of a date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.today().last().friday();
	Date.today().last().fri();
	Date.today().last().march();
	Date.today().last().mar();
	Date.today().last().week();
	
* * @return {Date} date */ $P.last = $P.prev = $P.previous = function () { this._move = true; this._orient = -1; return this; }; /** * Creates a new Date (Date.today()) and moves the date to the previous instance of the date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.last().friday();
	Date.last().fri();
	Date.previous().march();
	Date.prev().mar();
	Date.last().week();
	
* * @return {Date} date */ $D.last = $D.prev = $D.previous = function () { return $D.today().last(); }; /** * Performs a equality check when followed by either a month name, day name or .weekday() function. * Example

	Date.today().is().friday(); // true|false
	Date.today().is().fri();
	Date.today().is().march();
	Date.today().is().mar();
	
* * @return {Boolean} true|false */ $P.is = function () { this._is = true; return this; }; /** * Determines if two date objects occur on/in exactly the same instance of the subsequent date part function. * The function .same() must be followed by a date part function (example: .day(), .month(), .year(), etc). * * An optional Date can be passed in the date part function. If now date is passed as a parameter, 'Now' is used. * * The following example demonstrates how to determine if two dates fall on the exact same day. * * Example

	var d1 = Date.today(); // today at 00:00
	var d2 = new Date();   // exactly now.

	// Do they occur on the same day?
	d1.same().day(d2); // true
	
	// Do they occur on the same hour?
	d1.same().hour(d2); // false, unless d2 hour is '00' (midnight).
	
	// What if it's the same day, but one year apart?
	var nextYear = Date.today().add(1).year();

	d1.same().day(nextYear); // false, because the dates must occur on the exact same day. 
	
* * Scenario: Determine if a given date occurs during some week period 2 months from now. * * Example

	var future = Date.today().add(2).months();
	return someDate.same().week(future); // true|false;
	
* * @return {Boolean} true|false */ $P.same = function () { this._same = true; this._isSecond = false; return this; }; /** * Determines if the current date/time occurs during Today. Must be preceded by the .is() function. * Example

	someDate.is().today();    // true|false
	new Date().is().today();  // true
	Date.today().is().today();// true
	Date.today().add(-1).day().is().today(); // false
	
* * @return {Boolean} true|false */ $P.today = function () { return this.same().day(); }; /** * Determines if the current date is a weekday. This function must be preceded by the .is() function. * Example

	Date.today().is().weekday(); // true|false
	
* * @return {Boolean} true|false */ $P.weekday = function () { if (this._nth) { return df("Weekday").call(this); } if (this._move) { return this.addWeekdays(this._orient); } if (this._is) { this._is = false; return (!this.is().sat() && !this.is().sun()); } return false; }; /** * Determines if the current date is on the weekend. This function must be preceded by the .is() function. * Example

	Date.today().is().weekend(); // true|false
	
* * @return {Boolean} true|false */ $P.weekend = function () { if (this._is) { this._is = false; return (this.is().sat() || this.is().sun()); } return false; }; /** * Sets the Time of the current Date instance. A string "6:15 pm" or config object {hour:18, minute:15} are accepted. * Example

	// Set time to 6:15pm with a String
	Date.today().at("6:15pm");

	// Set time to 6:15pm with a config object
	Date.today().at({hour:18, minute:15});
	
* * @return {Date} date */ $P.at = function (time) { return (typeof time === "string") ? $D.parse(this.toString("d") + " " + time) : this.set(time); }; /** * Creates a new Date() and adds this (Number) to the date based on the preceding date element function (eg. second|minute|hour|day|month|year). * Example

	// Undeclared Numbers must be wrapped with parentheses. Requirment of JavaScript.
	(3).days().fromNow();
	(6).months().fromNow();

	// Declared Number variables do not require parentheses. 
	var n = 6;
	n.months().fromNow();
	
* * @return {Date} A new Date instance */ $N.fromNow = $N.after = function (date) { var c = {}; c[this._dateElement] = this; return ((!date) ? new Date() : date.clone()).add(c); }; /** * Creates a new Date() and subtract this (Number) from the date based on the preceding date element function (eg. second|minute|hour|day|month|year). * Example

	// Undeclared Numbers must be wrapped with parentheses. Requirment of JavaScript.
	(3).days().ago();
	(6).months().ago();

	// Declared Number variables do not require parentheses. 
	var n = 6;
	n.months().ago();
	
* * @return {Date} A new Date instance */ $N.ago = $N.before = function (date) { var c = {}, s = (this._dateElement[this._dateElement.length-1] !== "s") ? this._dateElement + "s" : this._dateElement; c[s] = this * -1; return ((!date) ? new Date() : date.clone()).add(c); }; // Do NOT modify the following string tokens. These tokens are used to build dynamic functions. // All culture-specific strings can be found in the CultureInfo files. var dx = ("sunday monday tuesday wednesday thursday friday saturday").split(/\s/), mx = ("january february march april may june july august september october november december").split(/\s/), px = ("Millisecond Second Minute Hour Day Week Month Year Quarter Weekday").split(/\s/), pxf = ("Milliseconds Seconds Minutes Hours Date Week Month FullYear Quarter").split(/\s/), nth = ("final first second third fourth fifth").split(/\s/), de; /** * Returns an object literal of all the date parts. * Example

	var o = new Date().toObject();
	
	// { year: 2008, month: 4, week: 20, day: 13, hour: 18, minute: 9, second: 32, millisecond: 812 }
	
	// The object properties can be referenced directly from the object.
	
	alert(o.day);  // alerts "13"
	alert(o.year); // alerts "2008"
	
* * @return {Date} An object literal representing the original date object. */ $P.toObject = function () { var o = {}; for (var i = 0; i < px.length; i++) { if (this["get" + pxf[i]]) { o[px[i].toLowerCase()] = this["get" + pxf[i]](); } } return o; }; /** * Returns a date created from an object literal. Ignores the .week property if set in the config. * Example

	var o = new Date().toObject();
	
	return Date.fromObject(o); // will return the same date. 

	var o2 = {month: 1, day: 20, hour: 18}; // birthday party!
	Date.fromObject(o2);
	
* * @return {Date} An object literal representing the original date object. */ $D.fromObject = function(config) { config.week = null; return Date.today().set(config); }; // Create day name functions and abbreviated day name functions (eg. monday(), friday(), fri()). var df = function (n) { return function () { if (this._is) { this._is = false; return this.getDay() === n; } if (this._move) { this._move = null; } if (this._nth !== null) { // If the .second() function was called earlier, remove the _orient // from the date, and then continue. // This is required because 'second' can be used in two different context. // // Example // // Date.today().add(1).second(); // Date.march().second().monday(); // // Things get crazy with the following... // Date.march().add(1).second().second().monday(); // but it works!! // if (this._isSecond) { this.addSeconds(this._orient * -1); } // make sure we reset _isSecond this._isSecond = false; var ntemp = this._nth; this._nth = null; var temp = this.clone().moveToLastDayOfMonth(); this.moveToNthOccurrence(n, ntemp); if (this > temp) { throw new RangeError($D.getDayName(n) + " does not occur " + ntemp + " times in the month of " + $D.getMonthName(temp.getMonth()) + " " + temp.getFullYear() + "."); } return this; } return this.moveToDayOfWeek(n, this._orient); }; }; var sdf = function (n) { return function () { var t = $D.today(), shift = n - t.getDay(); if (n === 0 && Date.CultureInfo.firstDayOfWeek === 1 && t.getDay() !== 0) { shift = shift + 7; } return t.addDays(shift); }; }; // Create month name functions and abbreviated month name functions (eg. january(), march(), mar()). var month_instance_functions = function (n) { return function () { if (this._is) { this._is = false; return this.getMonth() === n; } return this.moveToMonth(n, this._orient); }; }; var month_static_functions = function (n) { return function () { return $D.today().set({ month: n, day: 1 }); }; }; var processTerms = function (names, staticFunc, instanceFunc) { for (var i = 0; i < names.length; i++) { // Create constant static Name variables. $D[names[i].toUpperCase()] = $D[names[i].toUpperCase().substring(0, 3)] = i; // Create Name functions. $D[names[i]] = $D[names[i].substring(0, 3)] = staticFunc(i); // Create Name instance functions. $P[names[i]] = $P[names[i].substring(0, 3)] = instanceFunc(i); } }; processTerms(dx, sdf, df); processTerms(mx, month_static_functions, month_instance_functions); // Create date element functions and plural date element functions used with Date (eg. day(), days(), months()). var ef = function (j) { return function () { // if the .second() function was called earlier, the _orient // has alread been added. Just return this and reset _isSecond. if (this._isSecond) { this._isSecond = false; return this; } if (this._same) { this._same = this._is = false; var o1 = this.toObject(), o2 = (arguments[0] || new Date()).toObject(), v = "", k = j.toLowerCase(); // the substr trick with -1 doesn't work in IE8 or less k = (k[k.length-1] === "s") ? k.substring(0,k.length-1) : k; for (var m = (px.length - 1); m > -1; m--) { v = px[m].toLowerCase(); if (o1[v] !== o2[v]) { return false; } if (k === v) { break; } } return true; } if (j.substring(j.length - 1) !== "s") { j += "s"; } if (this._move) { this._move = null; } return this["add" + j](this._orient); }; }; var nf = function (n) { return function () { this._dateElement = n; return this; }; }; for (var k = 0; k < px.length; k++) { de = px[k].toLowerCase(); if(de !== "weekday") { // Create date element functions and plural date element functions used with Date (eg. day(), days(), months()). $P[de] = $P[de + "s"] = ef(px[k]); // Create date element functions and plural date element functions used with Number (eg. day(), days(), months()). $N[de] = $N[de + "s"] = nf(de + "s"); } } $P._ss = ef("Second"); var nthfn = function (n) { return function (dayOfWeek) { if (this._same) { return this._ss(arguments[0]); } if (dayOfWeek || dayOfWeek === 0) { return this.moveToNthOccurrence(dayOfWeek, n); } this._nth = n; // if the operator is 'second' add the _orient, then deal with it later... if (n === 2 && (dayOfWeek === undefined || dayOfWeek === null)) { this._isSecond = true; return this.addSeconds(this._orient); } return this; }; }; for (var l = 0; l < nth.length; l++) { $P[nth[l]] = (l === 0) ? nthfn(-1) : nthfn(l); } }()); (function () { "use strict"; Date.Parsing = { Exception: function (s) { this.message = "Parse error at '" + s.substring(0, 10) + " ...'"; } }; var $P = Date.Parsing; var dayOffsets = { standard: [0,31,59,90,120,151,181,212,243,273,304,334], leap: [0,31,60,91,121,152,182,213,244,274,305,335] }; $P.isLeapYear = function(year) { return ((year % 4 === 0) && (year % 100 !== 0)) || (year % 400 === 0); }; var utils = { multiReplace : function (str, hash ) { var key; for (key in hash) { if (Object.prototype.hasOwnProperty.call(hash, key)) { var regex; if (typeof hash[key] === "function") { } else { regex = (hash[key] instanceof RegExp) ? hash[key] : new RegExp(hash[key], "g"); } str = str.replace(regex, key); } } return str; }, getDayOfYearFromWeek : function (obj) { var d, jan4, offset; obj.weekDay = (!obj.weekDay && obj.weekDay !== 0) ? 1 : obj.weekDay; d = new Date(obj.year, 0, 4); jan4 = d.getDay() === 0 ? 7 : d.getDay(); // JS is 0 indexed on Sunday. offset = jan4+3; obj.dayOfYear = ((obj.week * 7) + (obj.weekDay === 0 ? 7 : obj.weekDay))-offset; return obj; }, getDayOfYear : function (obj, dayOffset) { if (!obj.dayOfYear) { obj = utils.getDayOfYearFromWeek(obj); } for (var i=0;i <= dayOffset.length;i++) { if (obj.dayOfYear < dayOffset[i] || i === dayOffset.length) { obj.day = obj.day ? obj.day : (obj.dayOfYear - dayOffset[i-1]); break; } else { obj.month = i; } } return obj; }, adjustForTimeZone : function (obj, date) { var offset; if (obj.zone.toUpperCase() === "Z" || (obj.zone_hours === 0 && obj.zone_minutes === 0)) { // it's UTC/GML so work out the current timeszone offset offset = -date.getTimezoneOffset(); } else { offset = (obj.zone_hours*60) + (obj.zone_minutes || 0); if (obj.zone_sign === "+") { offset *= -1; } offset -= date.getTimezoneOffset(); } date.setMinutes(date.getMinutes()+offset); return date; }, setDefaults : function (obj) { obj.year = obj.year || Date.today().getFullYear(); obj.hours = obj.hours || 0; obj.minutes = obj.minutes || 0; obj.seconds = obj.seconds || 0; obj.milliseconds = obj.milliseconds || 0; if (!(!obj.month && (obj.week || obj.dayOfYear))) { // if we have a month, or if we don't but don't have the day calculation data obj.month = obj.month || 0; obj.day = obj.day || 1; } return obj; }, dataNum: function (data, mod, explict, postProcess) { var dataNum = data*1; if (mod) { if (postProcess) { return data ? mod(data)*1 : data; } else { return data ? mod(dataNum) : data; } } else if (!explict){ return data ? dataNum : data; } else { return (data && typeof data !== "undefined") ? dataNum : data; } }, timeDataProcess: function (obj) { var timeObj = {}; for (var x in obj.data) { if (obj.data.hasOwnProperty(x)) { timeObj[x] = obj.ignore[x] ? obj.data[x] : utils.dataNum(obj.data[x], obj.mods[x], obj.explict[x], obj.postProcess[x]); } } if (obj.data.secmins) { obj.data.secmins = obj.data.secmins.replace(",", ".") * 60; if (!timeObj.minutes) { timeObj.minutes = obj.data.secmins; } else if (!timeObj.seconds) { timeObj.seconds = obj.data.secmins; } delete obj.secmins; } return timeObj; }, buildTimeObjectFromData: function (data) { var time = utils.timeDataProcess({ data: { year : data[1], month : data[5], day : data[7], week : data[8], dayOfYear : data[10], hours : data[15], zone_hours : data[23], zone_minutes : data[24], zone : data[21], zone_sign : data[22], weekDay : data[9], minutes: data[16], seconds: data[19], milliseconds: data[20], secmins: data[18] }, mods: { month: function(data) { return data-1; }, weekDay: function (data) { data = Math.abs(data); return (data === 7 ? 0 : data); }, minutes: function (data) { return data.replace(":",""); }, seconds: function (data) { return Math.floor( (data.replace(":","").replace(",","."))*1 ); }, milliseconds: function (data) { return (data.replace(",",".")*1000); } }, postProcess: { minutes: true, seconds: true, milliseconds: true }, explict: { zone_hours: true, zone_minutes: true }, ignore: { zone: true, zone_sign: true, secmins: true } }); return time; }, addToHash: function (hash, keys, data) { keys = keys; data = data; var len = keys.length; for (var i = 0; i < len; i++) { hash[keys[i]] = data[i]; } return hash; }, combineRegex: function (r1, r2) { return new RegExp("(("+r1.source+")\\s("+r2.source+"))"); }, getDateNthString: function(add, last, inc){ if (add) { return Date.today().addDays(inc).toString("d"); } else if (last) { return Date.today().last()[inc]().toString("d"); } }, buildRegexData: function (array) { var arr = []; var len = array.length; for (var i=0; i < len; i++) { if (Object.prototype.toString.call(array[i]) === '[object Array]') { // oldIE compat version of Array.isArray arr.push(this.combineRegex(array[i][0], array[i][1])); } else { arr.push(array[i]); } } return arr; } }; $P.processTimeObject = function (obj) { var date, dayOffset; utils.setDefaults(obj); dayOffset = ($P.isLeapYear(obj.year)) ? dayOffsets.leap : dayOffsets.standard; if (!obj.month && (obj.week || obj.dayOfYear)) { utils.getDayOfYear(obj, dayOffset); } else { obj.dayOfYear = dayOffset[obj.month] + obj.day; } date = new Date(obj.year, obj.month, obj.day, obj.hours, obj.minutes, obj.seconds, obj.milliseconds); if (obj.zone) { utils.adjustForTimeZone(obj, date); // adjust (and calculate) for timezone } return date; }; $P.ISO = { regex : /^([\+-]?\d{4}(?!\d{2}\b))((-?)((0[1-9]|1[0-2])(\3([12]\d|0[1-9]|3[01]))?|W([0-4]\d|5[0-3])(-?[1-7])?|(00[1-9]|0[1-9]\d|[12]\d{2}|3([0-5]\d|6[1-6])))([T\s]((([01]\d|2[0-4])((:?)[0-5]\d)?|24\:?00)([\.,]\d+(?!:))?)?(\17[0-5]\d([\.,]\d+)?)?\s?([zZ]|([\+-])([01]\d|2[0-3]):?([0-5]\d)?)?)?)?$/, parse : function (s) { var time, data = s.match(this.regex); if (!data || !data.length) { return null; } time = utils.buildTimeObjectFromData(data); if (!time.year || (!time.year && (!time.month && !time.day) && (!time.week && !time.dayOfYear)) ) { return null; } return $P.processTimeObject(time); } }; $P.Numeric = { isNumeric: function (e){return!isNaN(parseFloat(e))&&isFinite(e);}, regex: /\b([0-1]?[0-9])([0-3]?[0-9])([0-2]?[0-9]?[0-9][0-9])\b/i, parse: function (s) { var data, i, time = {}, order = Date.CultureInfo.dateElementOrder.split(""); if (!(this.isNumeric(s)) || // if it's non-numeric OR (s[0] === "+" && s[0] === "-")) { // It's an arithmatic string (eg +/-1000) return null; } if (s.length < 5 && s.indexOf(".") < 0 && s.indexOf("/") < 0) { // assume it's just a year. time.year = s; return $P.processTimeObject(time); } data = s.match(this.regex); if (!data || !data.length) { return null; } for (i=0; i < order.length; i++) { switch(order[i]) { case "d": time.day = data[i+1]; break; case "m": time.month = (data[i+1]-1); break; case "y": time.year = data[i+1]; break; } } return $P.processTimeObject(time); } }; $P.Normalizer = { regexData: function () { var $R = Date.CultureInfo.regexPatterns; return utils.buildRegexData([ $R.tomorrow, $R.yesterday, [$R.past, $R.mon], [$R.past, $R.tue], [$R.past, $R.wed], [$R.past, $R.thu], [$R.past, $R.fri], [$R.past, $R.sat], [$R.past, $R.sun] ]); }, basicReplaceHash : function() { var $R = Date.CultureInfo.regexPatterns; return { "January": $R.jan.source, "February": $R.feb, "March": $R.mar, "April": $R.apr, "May": $R.may, "June": $R.jun, "July": $R.jul, "August": $R.aug, "September": $R.sep, "October": $R.oct, "November": $R.nov, "December": $R.dec, "": /\bat\b/gi, " ": /\s{2,}/, "am": $R.inTheMorning, "9am": $R.thisMorning, "pm": $R.inTheEvening, "7pm":$R.thisEvening }; }, keys : function(){ return [ utils.getDateNthString(true, false, 1), // tomorrow utils.getDateNthString(true, false, -1), // yesterday utils.getDateNthString(false, true, "monday"), //last mon utils.getDateNthString(false, true, "tuesday"), //last tues utils.getDateNthString(false, true, "wednesday"), //last wed utils.getDateNthString(false, true, "thursday"), //last thurs utils.getDateNthString(false, true, "friday"), //last fri utils.getDateNthString(false, true, "saturday"), //last sat utils.getDateNthString(false, true, "sunday") //last sun ]; }, buildRegexFunctions: function () { var $R = Date.CultureInfo.regexPatterns; var __ = Date.i18n.__; var tomorrowRE = new RegExp("(\\b\\d\\d?("+__("AM")+"|"+__("PM")+")? )("+$R.tomorrow.source.slice(1)+")", "i"); // adapted tomorrow regex for AM PM relative dates var todayRE = new RegExp($R.today.source + "(?!\\s*([+-]))\\b"); // today, but excludes the math operators (eg "today + 2h") this.replaceFuncs = [ [todayRE, function (full) { return (full.length > 1) ? Date.today().toString("d") : full; }], [tomorrowRE, function(full, m1) { var t = Date.today().addDays(1).toString("d"); return (t + " " + m1); }], [$R.amThisMorning, function(str, am){return am;}], [$R.pmThisEvening, function(str, pm){return pm;}] ]; }, buildReplaceData: function () { this.buildRegexFunctions(); this.replaceHash = utils.addToHash(this.basicReplaceHash(), this.keys(), this.regexData()); }, stringReplaceFuncs: function (s) { for (var i=0; i < this.replaceFuncs.length; i++) { s = s.replace(this.replaceFuncs[i][0], this.replaceFuncs[i][1]); } return s; }, parse: function (s) { s = this.stringReplaceFuncs(s); s = utils.multiReplace(s, this.replaceHash); try { var n = s.split(/([\s\-\.\,\/\x27]+)/); if (n.length === 3 && $P.Numeric.isNumeric(n[0]) && $P.Numeric.isNumeric(n[2]) && (n[2].length >= 4)) { // ok, so we're dealing with x/year. But that's not a full date. // This fixes wonky dateElementOrder parsing when set to dmy order. if (Date.CultureInfo.dateElementOrder[0] === "d") { s = "1/" + n[0] + "/" + n[2]; // set to 1st of month and normalize the seperator } } } catch (e) {} return s; } }; $P.Normalizer.buildReplaceData(); }()); (function () { var $P = Date.Parsing; var _ = $P.Operators = { // // Tokenizers // rtoken: function (r) { // regex token return function (s) { var mx = s.match(r); if (mx) { return ([ mx[0], s.substring(mx[0].length) ]); } else { throw new $P.Exception(s); } }; }, token: function () { // whitespace-eating token return function (s) { return _.rtoken(new RegExp("^\\s*" + s + "\\s*"))(s); }; }, stoken: function (s) { // string token return _.rtoken(new RegExp("^" + s)); }, // Atomic Operators until: function (p) { return function (s) { var qx = [], rx = null; while (s.length) { try { rx = p.call(this, s); } catch (e) { qx.push(rx[0]); s = rx[1]; continue; } break; } return [ qx, s ]; }; }, many: function (p) { return function (s) { var rx = [], r = null; while (s.length) { try { r = p.call(this, s); } catch (e) { return [ rx, s ]; } rx.push(r[0]); s = r[1]; } return [ rx, s ]; }; }, // generator operators -- see below optional: function (p) { return function (s) { var r = null; try { r = p.call(this, s); } catch (e) { return [ null, s ]; } return [ r[0], r[1] ]; }; }, not: function (p) { return function (s) { try { p.call(this, s); } catch (e) { return [null, s]; } throw new $P.Exception(s); }; }, ignore: function (p) { return p ? function (s) { var r = null; r = p.call(this, s); return [null, r[1]]; } : null; }, product: function () { var px = arguments[0], qx = Array.prototype.slice.call(arguments, 1), rx = []; for (var i = 0 ; i < px.length ; i++) { rx.push(_.each(px[i], qx)); } return rx; }, cache: function (rule) { var cache = {}, cache_length = 0, cache_keys = [], CACHE_MAX = Date.Config.CACHE_MAX || 100000, r = null; var cacheCheck = function () { if (cache_length === CACHE_MAX) { // kill several keys, don't want to have to do this all the time... for (var i=0; i < 10; i++) { var key = cache_keys.shift(); if (key) { delete cache[key]; cache_length--; } } } }; return function (s) { cacheCheck(); try { r = cache[s] = (cache[s] || rule.call(this, s)); } catch (e) { r = cache[s] = e; } cache_length++; cache_keys.push(s); if (r instanceof $P.Exception) { throw r; } else { return r; } }; }, // vector operators -- see below any: function () { var px = arguments; return function (s) { var r = null; for (var i = 0; i < px.length; i++) { if (px[i] == null) { continue; } try { r = (px[i].call(this, s)); } catch (e) { r = null; } if (r) { return r; } } throw new $P.Exception(s); }; }, each: function () { var px = arguments; return function (s) { var rx = [], r = null; for (var i = 0; i < px.length ; i++) { if (px[i] == null) { continue; } try { r = (px[i].call(this, s)); } catch (e) { throw new $P.Exception(s); } rx.push(r[0]); s = r[1]; } return [ rx, s]; }; }, all: function () { var px = arguments, _ = _; return _.each(_.optional(px)); }, // delimited operators sequence: function (px, d, c) { d = d || _.rtoken(/^\s*/); c = c || null; if (px.length === 1) { return px[0]; } return function (s) { var r = null, q = null; var rx = []; for (var i = 0; i < px.length ; i++) { try { r = px[i].call(this, s); } catch (e) { break; } rx.push(r[0]); try { q = d.call(this, r[1]); } catch (ex) { q = null; break; } s = q[1]; } if (!r) { throw new $P.Exception(s); } if (q) { throw new $P.Exception(q[1]); } if (c) { try { r = c.call(this, r[1]); } catch (ey) { throw new $P.Exception(r[1]); } } return [ rx, (r?r[1]:s) ]; }; }, // // Composite Operators // between: function (d1, p, d2) { d2 = d2 || d1; var _fn = _.each(_.ignore(d1), p, _.ignore(d2)); return function (s) { var rx = _fn.call(this, s); return [[rx[0][0], r[0][2]], rx[1]]; }; }, list: function (p, d, c) { d = d || _.rtoken(/^\s*/); c = c || null; return (p instanceof Array ? _.each(_.product(p.slice(0, -1), _.ignore(d)), p.slice(-1), _.ignore(c)) : _.each(_.many(_.each(p, _.ignore(d))), px, _.ignore(c))); }, set: function (px, d, c) { d = d || _.rtoken(/^\s*/); c = c || null; return function (s) { // r is the current match, best the current 'best' match // which means it parsed the most amount of input var r = null, p = null, q = null, rx = null, best = [[], s], last = false; // go through the rules in the given set for (var i = 0; i < px.length ; i++) { // last is a flag indicating whether this must be the last element // if there is only 1 element, then it MUST be the last one q = null; p = null; r = null; last = (px.length === 1); // first, we try simply to match the current pattern // if not, try the next pattern try { r = px[i].call(this, s); } catch (e) { continue; } // since we are matching against a set of elements, the first // thing to do is to add r[0] to matched elements rx = [[r[0]], r[1]]; // if we matched and there is still input to parse and // we don't already know this is the last element, // we're going to next check for the delimiter ... // if there's none, or if there's no input left to parse // than this must be the last element after all ... if (r[1].length > 0 && ! last) { try { q = d.call(this, r[1]); } catch (ex) { last = true; } } else { last = true; } // if we parsed the delimiter and now there's no more input, // that means we shouldn't have parsed the delimiter at all // so don't update r and mark this as the last element ... if (!last && q[1].length === 0) { last = true; } // so, if this isn't the last element, we're going to see if // we can get any more matches from the remaining (unmatched) // elements ... if (!last) { // build a list of the remaining rules we can match against, // i.e., all but the one we just matched against var qx = []; for (var j = 0; j < px.length ; j++) { if (i !== j) { qx.push(px[j]); } } // now invoke recursively set with the remaining input // note that we don't include the closing delimiter ... // we'll check for that ourselves at the end p = _.set(qx, d).call(this, q[1]); // if we got a non-empty set as a result ... // (otw rx already contains everything we want to match) if (p[0].length > 0) { // update current result, which is stored in rx ... // basically, pick up the remaining text from p[1] // and concat the result from p[0] so that we don't // get endless nesting ... rx[0] = rx[0].concat(p[0]); rx[1] = p[1]; } } // at this point, rx either contains the last matched element // or the entire matched set that starts with this element. // now we just check to see if this variation is better than // our best so far, in terms of how much of the input is parsed if (rx[1].length < best[1].length) { best = rx; } // if we've parsed all the input, then we're finished if (best[1].length === 0) { break; } } // so now we've either gone through all the patterns trying them // as the initial match; or we found one that parsed the entire // input string ... // if best has no matches, just return empty set ... if (best[0].length === 0) { return best; } // if a closing delimiter is provided, then we have to check it also if (c) { // we try this even if there is no remaining input because the pattern // may well be optional or match empty input ... try { q = c.call(this, best[1]); } catch (ey) { throw new $P.Exception(best[1]); } // it parsed ... be sure to update the best match remaining input best[1] = q[1]; } // if we're here, either there was no closing delimiter or we parsed it // so now we have the best match; just return it! return best; }; }, forward: function (gr, fname) { return function (s) { return gr[fname].call(this, s); }; }, // // Translation Operators // replace: function (rule, repl) { return function (s) { var r = rule.call(this, s); return [repl, r[1]]; }; }, process: function (rule, fn) { return function (s) { var r = rule.call(this, s); return [fn.call(this, r[0]), r[1]]; }; }, min: function (min, rule) { return function (s) { var rx = rule.call(this, s); if (rx[0].length < min) { throw new $P.Exception(s); } return rx; }; } }; // Generator Operators And Vector Operators // Generators are operators that have a signature of F(R) => R, // taking a given rule and returning another rule, such as // ignore, which parses a given rule and throws away the result. // Vector operators are those that have a signature of F(R1,R2,...) => R, // take a list of rules and returning a new rule, such as each. // Generator operators are converted (via the following _generator // function) into functions that can also take a list or array of rules // and return an array of new rules as though the function had been // called on each rule in turn (which is what actually happens). // This allows generators to be used with vector operators more easily. // Example: // each(ignore(foo, bar)) instead of each(ignore(foo), ignore(bar)) // This also turns generators into vector operators, which allows // constructs like: // not(cache(foo, bar)) var _generator = function (op) { function gen() { var args = null, rx = [], px, i; if (arguments.length > 1) { args = Array.prototype.slice.call(arguments); } else if (arguments[0] instanceof Array) { args = arguments[0]; } if (args) { px = args.shift(); if (px.length > 0) { args.unshift(px[i]); rx.push(op.apply(null, args)); args.shift(); return rx; } } else { return op.apply(null, arguments); } } return gen; }; var gx = "optional not ignore cache".split(/\s/); for (var i = 0 ; i < gx.length ; i++) { _[gx[i]] = _generator(_[gx[i]]); } var _vector = function (op) { return function () { if (arguments[0] instanceof Array) { return op.apply(null, arguments[0]); } else { return op.apply(null, arguments); } }; }; var vx = "each any all".split(/\s/); for (var j = 0 ; j < vx.length ; j++) { _[vx[j]] = _vector(_[vx[j]]); } }()); (function () { var $D = Date; var flattenAndCompact = function (ax) { var rx = []; for (var i = 0; i < ax.length; i++) { if (ax[i] instanceof Array) { rx = rx.concat(flattenAndCompact(ax[i])); } else { if (ax[i]) { rx.push(ax[i]); } } } return rx; }; var parseMeridian = function () { if (this.meridian && (this.hour || this.hour === 0)) { if (this.meridian === "a" && this.hour > 11 && Date.Config.strict24hr){ throw "Invalid hour and meridian combination"; } else if (this.meridian === "p" && this.hour < 12 && Date.Config.strict24hr){ throw "Invalid hour and meridian combination"; } else if (this.meridian === "p" && this.hour < 12) { this.hour = this.hour + 12; } else if (this.meridian === "a" && this.hour === 12) { this.hour = 0; } } }; var setDefaults = function () { var now = new Date(); if ((this.hour || this.minute) && (!this.month && !this.year && !this.day)) { this.day = now.getDate(); } if (!this.year) { this.year = now.getFullYear(); } if (!this.month && this.month !== 0) { this.month = now.getMonth(); } if (!this.day) { this.day = 1; } if (!this.hour) { this.hour = 0; } if (!this.minute) { this.minute = 0; } if (!this.second) { this.second = 0; } if (!this.millisecond) { this.millisecond = 0; } }; var finishUtils = { getToday: function () { if (this.now || "hour minute second".indexOf(this.unit) !== -1) { return new Date(); } else { return $D.today(); } }, setDaysFromWeekday: function (today, orient){ var gap; orient = orient || 1; this.unit = "day"; gap = ($D.getDayNumberFromName(this.weekday) - today.getDay()); this.days = gap ? ((gap + (orient * 7)) % 7) : (orient * 7); return this; }, setMonthsFromMonth: function (today, orient) { var gap; orient = orient || 1; this.unit = "month"; gap = (this.month - today.getMonth()); this.months = gap ? ((gap + (orient * 12)) % 12) : (orient * 12); this.month = null; return this; }, setDMYFromWeekday: function () { var d = Date[this.weekday](); this.day = d.getDate(); if (!this.month) { this.month = d.getMonth(); } this.year = d.getFullYear(); return this; }, setUnitValue: function (orient) { if (!this.value && this.operator && this.operator !== null && this[this.unit + "s"] && this[this.unit + "s"] !== null) { this[this.unit + "s"] = this[this.unit + "s"] + ((this.operator === "add") ? 1 : -1) + (this.value||0) * orient; } else if (this[this.unit + "s"] == null || this.operator != null) { if (!this.value) { this.value = 1; } this[this.unit + "s"] = this.value * orient; } }, generateDateFromWeeks: function () { var weekday = (this.weekday !== undefined) ? this.weekday : "today"; var d = Date[weekday]().addWeeks(this.weeks); if (this.now) { d.setTimeToNow(); } return d; } }; $D.Translator = { hour: function (s) { return function () { this.hour = Number(s); }; }, minute: function (s) { return function () { this.minute = Number(s); }; }, second: function (s) { return function () { this.second = Number(s); }; }, /* for ss.s format */ secondAndMillisecond: function (s) { return function () { var mx = s.match(/^([0-5][0-9])\.([0-9]{1,3})/); this.second = Number(mx[1]); this.millisecond = Number(mx[2]); }; }, meridian: function (s) { return function () { this.meridian = s.slice(0, 1).toLowerCase(); }; }, timezone: function (s) { return function () { var n = s.replace(/[^\d\+\-]/g, ""); if (n.length) { this.timezoneOffset = Number(n); } else { this.timezone = s.toLowerCase(); } }; }, day: function (x) { var s = x[0]; return function () { this.day = Number(s.match(/\d+/)[0]); if (this.day < 1) { throw "invalid day"; } }; }, month: function (s) { return function () { this.month = (s.length === 3) ? "jan feb mar apr may jun jul aug sep oct nov dec".indexOf(s)/4 : Number(s) - 1; if (this.month < 0) { throw "invalid month"; } }; }, year: function (s) { return function () { var n = Number(s); this.year = ((s.length > 2) ? n : (n + (((n + 2000) < Date.CultureInfo.twoDigitYearMax) ? 2000 : 1900))); }; }, rday: function (s) { return function () { switch (s) { case "yesterday": this.days = -1; break; case "tomorrow": this.days = 1; break; case "today": this.days = 0; break; case "now": this.days = 0; this.now = true; break; } }; }, finishExact: function (x) { var d; x = (x instanceof Array) ? x : [x]; for (var i = 0 ; i < x.length ; i++) { if (x[i]) { x[i].call(this); } } setDefaults.call(this); parseMeridian.call(this); if (this.day > $D.getDaysInMonth(this.year, this.month)) { throw new RangeError(this.day + " is not a valid value for days."); } d = new Date(this.year, this.month, this.day, this.hour, this.minute, this.second, this.millisecond); if (this.year < 100) { d.setFullYear(this.year); // means years less that 100 are process correctly. JS will parse it otherwise as 1900-1999. } if (this.timezone) { d.set({ timezone: this.timezone }); } else if (this.timezoneOffset) { d.set({ timezoneOffset: this.timezoneOffset }); } return d; }, finish: function (x) { var today, expression, orient, temp; x = (x instanceof Array) ? flattenAndCompact(x) : [ x ]; if (x.length === 0) { return null; } for (var i = 0 ; i < x.length ; i++) { if (typeof x[i] === "function") { x[i].call(this); } } if (this.now && !this.unit && !this.operator) { return new Date(); } else { today = finishUtils.getToday.call(this); } expression = !!(this.days && this.days !== null || this.orient || this.operator); orient = ((this.orient === "past" || this.operator === "subtract") ? -1 : 1); if (this.month && this.unit === "week") { this.value = this.month + 1; delete this.month; delete this.day; } if ((this.month || this.month === 0) && "year day hour minute second".indexOf(this.unit) !== -1) { if (!this.value) { this.value = this.month + 1; } this.month = null; expression = true; } if (!expression && this.weekday && !this.day && !this.days) { finishUtils.setDMYFromWeekday.call(this); } if (expression && this.weekday && this.unit !== "month" && this.unit !== "week") { finishUtils.setDaysFromWeekday.call(this, today, orient); } if (this.weekday && this.unit !== "week" && !this.day && !this.days) { temp = Date[this.weekday](); this.day = temp.getDate(); if (temp.getMonth() !== today.getMonth()) { this.month = temp.getMonth(); } } if (this.month && this.unit === "day" && this.operator) { if (!this.value) { this.value = (this.month + 1); } this.month = null; } if (this.value != null && this.month != null && this.year != null) { this.day = this.value * 1; } if (this.month && !this.day && this.value) { today.set({ day: this.value * 1 }); if (!expression) { this.day = this.value * 1; } } if (!this.month && this.value && this.unit === "month" && !this.now) { this.month = this.value; expression = true; } if (expression && (this.month || this.month === 0) && this.unit !== "year") { finishUtils.setMonthsFromMonth.call(this, today, orient); } if (!this.unit) { this.unit = "day"; } finishUtils.setUnitValue.call(this, orient); parseMeridian.call(this); if ((this.month || this.month === 0) && !this.day) { this.day = 1; } if (!this.orient && !this.operator && this.unit === "week" && this.value && !this.day && !this.month) { return Date.today().setWeek(this.value); } if (this.unit === "week" && this.weeks && !this.day && !this.month) { return finishUtils.generateDateFromWeeks.call(this); } if (expression && this.timezone && this.day && this.days) { this.day = this.days; } if (expression){ today.add(this); } else { today.set(this); } if (this.timezone) { this.timezone = this.timezone.toUpperCase(); var offset = $D.getTimezoneOffset(this.timezone); var timezone; if (today.hasDaylightSavingTime()) { // lets check that we're being sane with timezone setting timezone = $D.getTimezoneAbbreviation(offset, today.isDaylightSavingTime()); if (timezone !== this.timezone) { // bugger, we're in a place where things like EST vs EDT matters. if (today.isDaylightSavingTime()) { today.addHours(-1); } else { today.addHours(1); } } } today.setTimezoneOffset(offset); } return today; } }; }()); (function () { var $D = Date; $D.Grammar = {}; var _ = $D.Parsing.Operators, g = $D.Grammar, t = $D.Translator, _fn; // Allow rolling up into general purpose rules _fn = function () { return _.each(_.any.apply(null, arguments), _.not(g.ctoken2("timeContext"))); }; g.datePartDelimiter = _.rtoken(/^([\s\-\.\,\/\x27]+)/); g.timePartDelimiter = _.stoken(":"); g.whiteSpace = _.rtoken(/^\s*/); g.generalDelimiter = _.rtoken(/^(([\s\,]|at|@|on)+)/); var _C = {}; g.ctoken = function (keys) { var fn = _C[keys]; if (! fn) { var c = Date.CultureInfo.regexPatterns; var kx = keys.split(/\s+/), px = []; for (var i = 0; i < kx.length ; i++) { px.push(_.replace(_.rtoken(c[kx[i]]), kx[i])); } fn = _C[keys] = _.any.apply(null, px); } return fn; }; g.ctoken2 = function (key) { return _.rtoken(Date.CultureInfo.regexPatterns[key]); }; var cacheProcessRtoken = function (key, token, type, eachToken) { if (eachToken) { g[key] = _.cache(_.process(_.each(_.rtoken(token),_.optional(g.ctoken2(eachToken))), type)); } else { g[key] = _.cache(_.process(_.rtoken(token), type)); } }; var cacheProcessCtoken = function (token, type) { return _.cache(_.process(g.ctoken2(token), type)); }; var _F = {}; //function cache var _get = function (f) { _F[f] = (_F[f] || g.format(f)[0]); return _F[f]; }; g.allformats = function (fx) { var rx = []; if (fx instanceof Array) { for (var i = 0; i < fx.length; i++) { rx.push(_get(fx[i])); } } else { rx.push(_get(fx)); } return rx; }; g.formats = function (fx) { if (fx instanceof Array) { var rx = []; for (var i = 0 ; i < fx.length ; i++) { rx.push(_get(fx[i])); } return _.any.apply(null, rx); } else { return _get(fx); } }; var grammarFormats = { timeFormats: function(){ var i, RTokenKeys = [ "h", "hh", "H", "HH", "m", "mm", "s", "ss", "ss.s", "z", "zz" ], RToken = [ /^(0[0-9]|1[0-2]|[1-9])/, /^(0[0-9]|1[0-2])/, /^([0-1][0-9]|2[0-3]|[0-9])/, /^([0-1][0-9]|2[0-3])/, /^([0-5][0-9]|[0-9])/, /^[0-5][0-9]/, /^([0-5][0-9]|[0-9])/, /^[0-5][0-9]/, /^[0-5][0-9]\.[0-9]{1,3}/, /^((\+|\-)\s*\d\d\d\d)|((\+|\-)\d\d\:?\d\d)/, /^((\+|\-)\s*\d\d\d\d)|((\+|\-)\d\d\:?\d\d)/ ], tokens = [ t.hour, t.hour, t.hour, t.hour, t.minute, t.minute, t.second, t.second, t.secondAndMillisecond, t.timezone, t.timezone ]; for (i=0; i < RTokenKeys.length; i++) { cacheProcessRtoken(RTokenKeys[i], RToken[i], tokens[i]); } g.hms = _.cache(_.sequence([g.H, g.m, g.s], g.timePartDelimiter)); g.t = cacheProcessCtoken("shortMeridian", t.meridian); g.tt = cacheProcessCtoken("longMeridian", t.meridian); g.zzz = cacheProcessCtoken("timezone", t.timezone); g.timeSuffix = _.each(_.ignore(g.whiteSpace), _.set([ g.tt, g.zzz ])); g.time = _.each(_.optional(_.ignore(_.stoken("T"))), g.hms, g.timeSuffix); }, dateFormats: function () { // pre-loaded rules for different date part order preferences var _setfn = function () { return _.set(arguments, g.datePartDelimiter); }; var i, RTokenKeys = [ "d", "dd", "M", "MM", "y", "yy", "yyy", "yyyy" ], RToken = [ /^([0-2]\d|3[0-1]|\d)/, /^([0-2]\d|3[0-1])/, /^(1[0-2]|0\d|\d)/, /^(1[0-2]|0\d)/, /^(\d+)/, /^(\d\d)/, /^(\d\d?\d?\d?)/, /^(\d\d\d\d)/ ], tokens = [ t.day, t.day, t.month, t.month, t.year, t.year, t.year, t.year ], eachToken = [ "ordinalSuffix", "ordinalSuffix" ]; for (i=0; i < RTokenKeys.length; i++) { cacheProcessRtoken(RTokenKeys[i], RToken[i], tokens[i], eachToken[i]); } g.MMM = g.MMMM = _.cache(_.process(g.ctoken("jan feb mar apr may jun jul aug sep oct nov dec"), t.month)); g.ddd = g.dddd = _.cache(_.process(g.ctoken("sun mon tue wed thu fri sat"), function (s) { return function () { this.weekday = s; }; } )); g.day = _fn(g.d, g.dd); g.month = _fn(g.M, g.MMM); g.year = _fn(g.yyyy, g.yy); g.mdy = _setfn(g.ddd, g.month, g.day, g.year); g.ymd = _setfn(g.ddd, g.year, g.month, g.day); g.dmy = _setfn(g.ddd, g.day, g.month, g.year); g.date = function (s) { return ((g[Date.CultureInfo.dateElementOrder] || g.mdy).call(this, s)); }; }, relative: function () { // relative date / time expressions g.orientation = _.process(g.ctoken("past future"), function (s) { return function () { this.orient = s; }; } ); g.operator = _.process(g.ctoken("add subtract"), function (s) { return function () { this.operator = s; }; } ); g.rday = _.process(g.ctoken("yesterday tomorrow today now"), t.rday); g.unit = _.process(g.ctoken("second minute hour day week month year"), function (s) { return function () { this.unit = s; }; } ); } }; g.buildGrammarFormats = function () { // these need to be rebuilt every time the language changes. _C = {}; grammarFormats.timeFormats(); grammarFormats.dateFormats(); grammarFormats.relative(); g.value = _.process(_.rtoken(/^([-+]?\d+)?(st|nd|rd|th)?/), function (s) { return function () { this.value = s.replace(/\D/g, ""); }; } ); g.expression = _.set([g.rday, g.operator, g.value, g.unit, g.orientation, g.ddd, g.MMM ]); g.format = _.process(_.many( _.any( // translate format specifiers into grammar rules _.process( _.rtoken(/^(dd?d?d?(?!e)|MM?M?M?|yy?y?y?|hh?|HH?|mm?|ss?|tt?|zz?z?)/), function (fmt) { if (g[fmt]) { return g[fmt]; } else { throw $D.Parsing.Exception(fmt); } } ), // translate separator tokens into token rules _.process(_.rtoken(/^[^dMyhHmstz]+/), // all legal separators function (s) { return _.ignore(_.stoken(s)); } ) ) ), // construct the parser ... function (rules) { return _.process(_.each.apply(null, rules), t.finishExact); } ); // starting rule for general purpose grammar g._start = _.process(_.set([ g.date, g.time, g.expression ], g.generalDelimiter, g.whiteSpace), t.finish); }; g.buildGrammarFormats(); // parsing date format specifiers - ex: "h:m:s tt" // this little guy will generate a custom parser based // on the format string, ex: g.format("h:m:s tt") // check for these formats first g._formats = g.formats([ "\"yyyy-MM-ddTHH:mm:ssZ\"", "yyyy-MM-ddTHH:mm:ss.sz", "yyyy-MM-ddTHH:mm:ssZ", "yyyy-MM-ddTHH:mm:ssz", "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-ddTHH:mmZ", "yyyy-MM-ddTHH:mmz", "yyyy-MM-ddTHH:mm", "ddd, MMM dd, yyyy H:mm:ss tt", "ddd MMM d yyyy HH:mm:ss zzz", "MMddyyyy", "ddMMyyyy", "Mddyyyy", "ddMyyyy", "Mdyyyy", "dMyyyy", "yyyy", "Mdyy", "dMyy", "d" ]); // real starting rule: tries selected formats first, // then general purpose rule g.start = function (s) { try { var r = g._formats.call({}, s); if (r[1].length === 0) { return r; } } catch (e) {} return g._start.call({}, s); }; }()); (function () { var $D = Date; /** * @desc Converts the specified string value into its JavaScript Date equivalent using CultureInfo specific format information. * * Example

	///////////
	// Dates //
	///////////

	// 15-Oct-2004
	var d1 = Date.parse("10/15/2004");

	// 15-Oct-2004
	var d1 = Date.parse("15-Oct-2004");

	// 15-Oct-2004
	var d1 = Date.parse("2004.10.15");

	//Fri Oct 15, 2004
	var d1 = Date.parse("Fri Oct 15, 2004");

	///////////
	// Times //
	///////////

	// Today at 10 PM.
	var d1 = Date.parse("10 PM");

	// Today at 10:30 PM.
	var d1 = Date.parse("10:30 P.M.");

	// Today at 6 AM.
	var d1 = Date.parse("06am");

	/////////////////////
	// Dates and Times //
	/////////////////////

	// 8-July-2004 @ 10:30 PM
	var d1 = Date.parse("July 8th, 2004, 10:30 PM");

	// 1-July-2004 @ 10:30 PM
	var d1 = Date.parse("2004-07-01T22:30:00");

	////////////////////
	// Relative Dates //
	////////////////////

	// Returns today's date. The string "today" is culture specific.
	var d1 = Date.parse("today");

	// Returns yesterday's date. The string "yesterday" is culture specific.
	var d1 = Date.parse("yesterday");

	// Returns the date of the next thursday.
	var d1 = Date.parse("Next thursday");

	// Returns the date of the most previous monday.
	var d1 = Date.parse("last monday");

	// Returns today's day + one year.
	var d1 = Date.parse("next year");

	///////////////
	// Date Math //
	///////////////

	// Today + 2 days
	var d1 = Date.parse("t+2");

	// Today + 2 days
	var d1 = Date.parse("today + 2 days");

	// Today + 3 months
	var d1 = Date.parse("t+3m");

	// Today - 1 year
	var d1 = Date.parse("today - 1 year");

	// Today - 1 year
	var d1 = Date.parse("t-1y"); 


	/////////////////////////////
	// Partial Dates and Times //
	/////////////////////////////

	// July 15th of this year.
	var d1 = Date.parse("July 15");

	// 15th day of current day and year.
	var d1 = Date.parse("15");

	// July 1st of current year at 10pm.
	var d1 = Date.parse("7/1 10pm");
	
* * @param {String} The string value to convert into a Date object [Required] * @return {Date} A Date object or null if the string cannot be converted into a Date. */ var parseUtils = { removeOrds: function (s) { ords = s.match(/\b(\d+)(?:st|nd|rd|th)\b/); // find ordinal matches s = ((ords && ords.length === 2) ? s.replace(ords[0], ords[1]) : s); return s; }, grammarParser: function (s) { var r = null; try { r = $D.Grammar.start.call({}, s.replace(/^\s*(\S*(\s+\S+)*)\s*$/, "$1")); } catch (e) { return null; } return ((r[1].length === 0) ? r[0] : null); }, nativeFallback: function(s) { var t; try { // ok we haven't parsed it, last ditch attempt with the built-in parser. t = Date._parse(s); return (t || t === 0) ? new Date(t) : null; } catch (e) { return null; } } }; function parse (s) { var d; if (!s) { return null; } if (s instanceof Date) { return s.clone(); } if (s.length >= 4 && s.charAt(0) !== "0" && s.charAt(0) !== "+"&& s.charAt(0) !== "-") { // ie: 2004 will pass, 0800 won't. // Start with specific formats d = $D.Parsing.ISO.parse(s) || $D.Parsing.Numeric.parse(s); } if (d instanceof Date && !isNaN(d.getTime())) { return d; } else { // find ordinal dates (1st, 3rd, 8th, etc and remove them as they cause parsing issues) s = $D.Parsing.Normalizer.parse(parseUtils.removeOrds(s)); d = parseUtils.grammarParser(s); if (d !== null) { return d; } else { return parseUtils.nativeFallback(s); } } } if (!$D._parse) { $D._parse = $D.parse; } $D.parse = parse; Date.getParseFunction = function (fx) { var fns = Date.Grammar.allformats(fx); return function (s) { var r = null; for (var i = 0; i < fns.length; i++) { try { r = fns[i].call({}, s); } catch (e) { continue; } if (r[1].length === 0) { return r[0]; } } return null; }; }; /** * Converts the specified string value into its JavaScript Date equivalent using the specified format {String} or formats {Array} and the CultureInfo specific format information. * The format of the string value must match one of the supplied formats exactly. * * Example

	// 15-Oct-2004
	var d1 = Date.parseExact("10/15/2004", "M/d/yyyy");

	// 15-Oct-2004
	var d1 = Date.parse("15-Oct-2004", "M-ddd-yyyy");

	// 15-Oct-2004
	var d1 = Date.parse("2004.10.15", "yyyy.MM.dd");

	// Multiple formats
	var d1 = Date.parseExact("10/15/2004", ["M/d/yyyy", "MMMM d, yyyy"]);
	
* * @param {String} The string value to convert into a Date object [Required]. * @param {Object} The expected format {String} or an array of expected formats {Array} of the date string [Required]. * @return {Date} A Date object or null if the string cannot be converted into a Date. */ $D.parseExact = function (s, fx) { return $D.getParseFunction(fx)(s); }; }()); (function () { var $D = Date, $P = $D.prototype, // $C = $D.CultureInfo, // not used atm p = function (s, l) { if (!l) { l = 2; } return ("000" + s).slice(l * -1); }; /** * Converts a PHP format string to Java/.NET format string. * A PHP format string can be used with ._format or .format. * A Java/.NET format string can be used with .toString(). * The .parseExact function will only accept a Java/.NET format string * * Example * var f1 = "%m/%d/%y" * var f2 = Date.normalizeFormat(f1); // "MM/dd/yy" * * new Date().format(f1); // "04/13/08" * new Date()._format(f1); // "04/13/08" * new Date().toString(f2); // "04/13/08" * * var date = Date.parseExact("04/13/08", f2); // Sun Apr 13 2008 * * @param {String} A PHP format string consisting of one or more format spcifiers. * @return {String} The PHP format converted to a Java/.NET format string. */ var normalizerSubstitutions = { "d" : "dd", "%d": "dd", "D" : "ddd", "%a": "ddd", "j" : "dddd", "l" : "dddd", "%A": "dddd", "S" : "S", "F" : "MMMM", "%B": "MMMM", "m" : "MM", "%m": "MM", "M" : "MMM", "%b": "MMM", "%h": "MMM", "n" : "M", "Y" : "yyyy", "%Y": "yyyy", "y" : "yy", "%y": "yy", "g" : "h", "%I": "h", "G" : "H", "h" : "hh", "H" : "HH", "%H": "HH", "i" : "mm", "%M": "mm", "s" : "ss", "%S": "ss", "%r": "hh:mm tt", "%R": "H:mm", "%T": "H:mm:ss", "%X": "t", "%x": "d", "%e": "d", "%D": "MM/dd/yy", "%n": "\\n", "%t": "\\t", "e" : "z", "T" : "z", "%z": "z", "%Z": "z", "Z" : "ZZ", "N" : "u", "w" : "u", "%w": "u", "W" : "W", "%V": "W" }; var normalizer = { substitutes: function (m) { return normalizerSubstitutions[m]; }, interpreted: function (m, x) { var y; switch (m) { case "%u": return x.getDay() + 1; case "z": return x.getOrdinalNumber(); case "%j": return p(x.getOrdinalNumber(), 3); case "%U": var d1 = x.clone().set({month: 0, day: 1}).addDays(-1).moveToDayOfWeek(0), d2 = x.clone().addDays(1).moveToDayOfWeek(0, -1); return (d2 < d1) ? "00" : p((d2.getOrdinalNumber() - d1.getOrdinalNumber()) / 7 + 1); case "%W": return p(x.getWeek()); case "t": return $D.getDaysInMonth(x.getFullYear(), x.getMonth()); case "o": case "%G": return x.setWeek(x.getISOWeek()).toString("yyyy"); case "%g": return x._format("%G").slice(-2); case "a": case "%p": return t("tt").toLowerCase(); case "A": return t("tt").toUpperCase(); case "u": return p(x.getMilliseconds(), 3); case "I": return (x.isDaylightSavingTime()) ? 1 : 0; case "O": return x.getUTCOffset(); case "P": y = x.getUTCOffset(); return y.substring(0, y.length - 2) + ":" + y.substring(y.length - 2); case "B": var now = new Date(); return Math.floor(((now.getHours() * 3600) + (now.getMinutes() * 60) + now.getSeconds() + (now.getTimezoneOffset() + 60) * 60) / 86.4); case "c": return x.toISOString().replace(/\"/g, ""); case "U": return $D.strtotime("now"); case "%c": return t("d") + " " + t("t"); case "%C": return Math.floor(x.getFullYear() / 100 + 1); } }, shouldOverrideDefaults: function (m) { switch (m) { case "%e": return true; default: return false; } }, parse: function (m, context) { var formatString, c = context || new Date(); formatString = normalizer.substitutes(m); if (formatString) { return formatString; } formatString = normalizer.interpreted(m, c); if (formatString) { return formatString; } else { return m; } } }; $D.normalizeFormat = function (format, context) { return format.replace(/(%|\\)?.|%%/g, function(t){ return normalizer.parse(t, context); }); }; /** * Format a local Unix timestamp according to locale settings * * Example: * Date.strftime("%m/%d/%y", new Date()); // "04/13/08" * Date.strftime("c", "2008-04-13T17:52:03Z"); // "04/13/08" * * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @param {Number|String} The number representing the number of seconds that have elapsed since January 1, 1970 (local time). * @return {String} A string representation of the current Date object. */ $D.strftime = function (format, time) { var d = Date.parse(time); return d._format(format); }; /** * Parse any textual datetime description into a Unix timestamp. * A Unix timestamp is the number of seconds that have elapsed since January 1, 1970 (midnight UTC/GMT). * * Example: * Date.strtotime("04/13/08"); // 1208044800 * Date.strtotime("1970-01-01T00:00:00Z"); // 0 * * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @param {Object} A string or date object. * @return {String} A string representation of the current Date object. */ $D.strtotime = function (time) { var d = $D.parse(time); return Math.round($D.UTC(d.getUTCFullYear(), d.getUTCMonth(), d.getUTCDate(), d.getUTCHours(), d.getUTCMinutes(), d.getUTCSeconds(), d.getUTCMilliseconds()) / 1000); }; /** * Converts the value of the current Date object to its equivalent string representation using a PHP/Unix style of date format specifiers. * Format Specifiers * Format Description Example * ------ --------------------------------------------------------------------------- ----------------------- * %a abbreviated weekday name according to the current localed "Mon" through "Sun" * %A full weekday name according to the current localed "Sunday" through "Saturday" * %b abbreviated month name according to the current localed "Jan" through "Dec" * %B full month name according to the current locale "January" through "December" * %c preferred date and time representation for the current locale "4/13/2008 12:33 PM" * %C century number (the year divided by 100 and truncated to an integer) "00" to "99" * %d day of the month as a decimal number "01" to "31" * %D same as %m/%d/%y "04/13/08" * %e day of the month as a decimal number, a single digit is preceded by a space "1" to "31" * %g like %G, but without the century "08" * %G The 4-digit year corresponding to the ISO week number (see %V). "2008" * This has the same format and value as %Y, except that if the ISO week number * belongs to the previous or next year, that year is used instead. * %h same as %b "Jan" through "Dec" * %H hour as a decimal number using a 24-hour clock. "00" to "23" * %I hour as a decimal number using a 12-hour clock. "01" to "12" * %j day of the year as a decimal number. "001" to "366" * %m month as a decimal number. "01" to "12" * %M minute as a decimal number. "00" to "59" * %n newline character "\n" * %p either "am" or "pm" according to the given time value, or the "am" or "pm" * corresponding strings for the current locale. * %r time in a.m. and p.m. notation "8:44 PM" * %R time in 24 hour notation "20:44" * %S second as a decimal number "00" to "59" * %t tab character "\t" * %T current time, equal to %H:%M:%S "12:49:11" * %u weekday as a decimal number ["1", "7"], with "1" representing Monday "1" to "7" * %U week number of the current year as a decimal number, starting with the "0" to ("52" or "53") * first Sunday as the first day of the first week * %V The ISO 8601:1988 week number of the current year as a decimal number, "00" to ("52" or "53") * range 01 to 53, where week 1 is the first week that has at least 4 days * in the current year, and with Monday as the first day of the week. * (Use %G or %g for the year component that corresponds to the week number * for the specified timestamp.) * %W week number of the current year as a decimal number, starting with the "00" to ("52" or "53") * first Monday as the first day of the first week * %w day of the week as a decimal, Sunday being "0" "0" to "6" * %x preferred date representation for the current locale without the time "4/13/2008" * %X preferred time representation for the current locale without the date "12:53:05" * %y year as a decimal number without a century "00" "99" * %Y year as a decimal number including the century "2008" * %Z time zone or name or abbreviation "UTC", "EST", "PST" * %z same as %Z * %% a literal "%" characters "%" * d Day of the month, 2 digits with leading zeros "01" to "31" * D A textual representation of a day, three letters "Mon" through "Sun" * j Day of the month without leading zeros "1" to "31" * l A full textual representation of the day of the week (lowercase "L") "Sunday" through "Saturday" * N ISO-8601 numeric representation of the day of the week (added in PHP 5.1.0) "1" (for Monday) through "7" (for Sunday) * S English ordinal suffix for the day of the month, 2 characters "st", "nd", "rd" or "th". Works well with j * w Numeric representation of the day of the week "0" (for Sunday) through "6" (for Saturday) * z The day of the year (starting from "0") "0" through "365" * W ISO-8601 week number of year, weeks starting on Monday "00" to ("52" or "53") * F A full textual representation of a month, such as January or March "January" through "December" * m Numeric representation of a month, with leading zeros "01" through "12" * M A short textual representation of a month, three letters "Jan" through "Dec" * n Numeric representation of a month, without leading zeros "1" through "12" * t Number of days in the given month "28" through "31" * L Whether it's a leap year "1" if it is a leap year, "0" otherwise * o ISO-8601 year number. This has the same value as Y, except that if the "2008" * ISO week number (W) belongs to the previous or next year, that year * is used instead. * Y A full numeric representation of a year, 4 digits "2008" * y A two digit representation of a year "08" * a Lowercase Ante meridiem and Post meridiem "am" or "pm" * A Uppercase Ante meridiem and Post meridiem "AM" or "PM" * B Swatch Internet time "000" through "999" * g 12-hour format of an hour without leading zeros "1" through "12" * G 24-hour format of an hour without leading zeros "0" through "23" * h 12-hour format of an hour with leading zeros "01" through "12" * H 24-hour format of an hour with leading zeros "00" through "23" * i Minutes with leading zeros "00" to "59" * s Seconds, with leading zeros "00" through "59" * u Milliseconds "54321" * e Timezone identifier "UTC", "EST", "PST" * I Whether or not the date is in daylight saving time (uppercase i) "1" if Daylight Saving Time, "0" otherwise * O Difference to Greenwich time (GMT) in hours "+0200", "-0600" * P Difference to Greenwich time (GMT) with colon between hours and minutes "+02:00", "-06:00" * T Timezone abbreviation "UTC", "EST", "PST" * Z Timezone offset in seconds. The offset for timezones west of UTC is "-43200" through "50400" * always negative, and for those east of UTC is always positive. * c ISO 8601 date "2004-02-12T15:19:21+00:00" * r RFC 2822 formatted date "Thu, 21 Dec 2000 16:01:07 +0200" * U Seconds since the Unix Epoch (January 1 1970 00:00:00 GMT) "0" * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @return {String} A string representation of the current Date object. */ var formatReplace = function (context) { return function (m) { var formatString, override = false; if (m.charAt(0) === "\\" || m.substring(0, 2) === "%%") { return m.replace("\\", "").replace("%%", "%"); } override = normalizer.shouldOverrideDefaults(m); formatString = $D.normalizeFormat(m, context); if (formatString) { return context.toString(formatString, override); } }; }; $P._format = function (format) { var formatter = formatReplace(this); if (!format) { return this._toString(); } else { return format.replace(/(%|\\)?.|%%/g, formatter); } }; if (!$P.format) { $P.format = $P._format; } }()); (function () { "use strict"; var gFn = function (attr) { return function () { return this[attr]; }; }; var sFn = function (attr) { return function (val) { this[attr] = val; return this; }; }; var attrs = ["years", "months", "days", "hours", "minutes", "seconds", "milliseconds"]; var addSetFuncs = function (context, attrs) { for (var i = 0; i < attrs.length ; i++) { var $a = attrs[i], $b = $a.slice(0, 1).toUpperCase() + $a.slice(1); context.prototype[$a] = 0; context.prototype["get" + $b] = gFn($a); context.prototype["set" + $b] = sFn($a); } }; /** * new TimeSpan(milliseconds); * new TimeSpan(days, hours, minutes, seconds); * new TimeSpan(days, hours, minutes, seconds, milliseconds); */ var TimeSpan = function (days, hours, minutes, seconds, milliseconds) { if (arguments.length === 1 && typeof days === "number") { var orient = (days < 0) ? -1 : +1; var millsLeft = Math.abs(days); this.setDays(Math.floor(millsLeft / 86400000) * orient); millsLeft = millsLeft % 86400000; this.setHours(Math.floor(millsLeft / 3600000) * orient); millsLeft = millsLeft % 3600000; this.setMinutes(Math.floor(millsLeft / 60000) * orient); millsLeft = millsLeft % 60000; this.setSeconds(Math.floor(millsLeft / 1000) * orient); millsLeft = millsLeft % 1000; this.setMilliseconds(millsLeft * orient); } else { this.set(days, hours, minutes, seconds, milliseconds); } this.getTotalMilliseconds = function () { return (this.getDays() * 86400000) + (this.getHours() * 3600000) + (this.getMinutes() * 60000) + (this.getSeconds() * 1000); }; this.compareTo = function (time) { var t1 = new Date(1970, 1, 1, this.getHours(), this.getMinutes(), this.getSeconds()), t2; if (time === null) { t2 = new Date(1970, 1, 1, 0, 0, 0); } else { t2 = new Date(1970, 1, 1, time.getHours(), time.getMinutes(), time.getSeconds()); } return (t1 < t2) ? -1 : (t1 > t2) ? 1 : 0; }; this.equals = function (time) { return (this.compareTo(time) === 0); }; this.add = function (time) { return (time === null) ? this : this.addSeconds(time.getTotalMilliseconds() / 1000); }; this.subtract = function (time) { return (time === null) ? this : this.addSeconds(-time.getTotalMilliseconds() / 1000); }; this.addDays = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 86400000)); }; this.addHours = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 3600000)); }; this.addMinutes = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 60000)); }; this.addSeconds = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 1000)); }; this.addMilliseconds = function (n) { return new TimeSpan(this.getTotalMilliseconds() + n); }; this.get12HourHour = function () { return (this.getHours() > 12) ? this.getHours() - 12 : (this.getHours() === 0) ? 12 : this.getHours(); }; this.getDesignator = function () { return (this.getHours() < 12) ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator; }; this.toString = function (format) { this._toString = function () { if (this.getDays() !== null && this.getDays() > 0) { return this.getDays() + "." + this.getHours() + ":" + this.p(this.getMinutes()) + ":" + this.p(this.getSeconds()); } else { return this.getHours() + ":" + this.p(this.getMinutes()) + ":" + this.p(this.getSeconds()); } }; this.p = function (s) { return (s.toString().length < 2) ? "0" + s : s; }; var me = this; return format ? format.replace(/dd?|HH?|hh?|mm?|ss?|tt?/g, function (format) { switch (format) { case "d": return me.getDays(); case "dd": return me.p(me.getDays()); case "H": return me.getHours(); case "HH": return me.p(me.getHours()); case "h": return me.get12HourHour(); case "hh": return me.p(me.get12HourHour()); case "m": return me.getMinutes(); case "mm": return me.p(me.getMinutes()); case "s": return me.getSeconds(); case "ss": return me.p(me.getSeconds()); case "t": return ((me.getHours() < 12) ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator).substring(0, 1); case "tt": return (me.getHours() < 12) ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator; } } ) : this._toString(); }; return this; }; addSetFuncs(TimeSpan, attrs.slice(2)); TimeSpan.prototype.set = function (days, hours, minutes, seconds, milliseconds){ this.setDays(days || this.getDays()); this.setHours(hours || this.getHours()); this.setMinutes(minutes || this.getMinutes()); this.setSeconds(seconds || this.getSeconds()); this.setMilliseconds(milliseconds || this.getMilliseconds()); }; /** * Gets the time of day for this date instances. * @return {TimeSpan} TimeSpan */ Date.prototype.getTimeOfDay = function () { return new TimeSpan(0, this.getHours(), this.getMinutes(), this.getSeconds(), this.getMilliseconds()); }; Date.TimeSpan = TimeSpan; if (typeof window !== "undefined" ) { // keeping API compatible for v1.x window.TimeSpan = TimeSpan; } }()); (function () { "use strict"; var attrs = ["years", "months", "days", "hours", "minutes", "seconds", "milliseconds"]; var gFn = function (attr) { return function () { return this[attr]; }; }; var sFn = function (attr) { return function (val) { this[attr] = val; return this; }; }; var addSetFuncs = function (context, attrs) { for (var i = 0; i < attrs.length ; i++) { var $a = attrs[i], $b = $a.slice(0, 1).toUpperCase() + $a.slice(1); context.prototype[$a] = 0; context.prototype["get" + $b] = gFn($a); context.prototype["set" + $b] = sFn($a); } }; var setMonthsAndYears = function (orient, d1, d2, context) { function inc() { d1.addMonths(-orient); context.months++; if (context.months === 12) { context.years++; context.months = 0; } } if (orient === +1) { while (d1 > d2) { inc(); } } else { while (d1 < d2) { inc(); } } context.months--; context.months *= orient; context.years *= orient; }; var adjustForDST = function(orient, startDate, endDate) { var hasDSTMismatch = (false === (startDate.isDaylightSavingTime() === endDate.isDaylightSavingTime())); if (hasDSTMismatch && orient === 1) { startDate.addHours(-1); } else if (hasDSTMismatch) { startDate.addHours(1); } }; /** * TimePeriod(startDate, endDate); * TimePeriod(years, months, days, hours, minutes, seconds, milliseconds); */ var TimePeriod = function (years, months, days, hours, minutes, seconds, milliseconds) { if (arguments.length === 7) { this.set(years, months, days, hours, minutes, seconds, milliseconds); } else if (arguments.length === 2 && arguments[0] instanceof Date && arguments[1] instanceof Date) { var startDate = arguments[0].clone(); var endDate = arguments[1].clone(); var orient = (startDate > endDate) ? +1 : -1; this.dates = { start: arguments[0].clone(), end: arguments[1].clone() }; setMonthsAndYears(orient, startDate, endDate, this); adjustForDST(orient, startDate, endDate); // // TODO - adjust for DST var diff = endDate - startDate; if (diff !== 0) { var ts = new TimeSpan(diff); this.set(this.years, this.months, ts.getDays(), ts.getHours(), ts.getMinutes(), ts.getSeconds(), ts.getMilliseconds()); } } return this; }; // create all the set functions. addSetFuncs(TimePeriod, attrs); TimePeriod.prototype.set = function (years, months, days, hours, minutes, seconds, milliseconds){ this.setYears(years || this.getYears()); this.setMonths(months || this.getMonths()); this.setDays(days || this.getDays()); this.setHours(hours || this.getHours()); this.setMinutes(minutes || this.getMinutes()); this.setSeconds(seconds || this.getSeconds()); this.setMilliseconds(milliseconds || this.getMilliseconds()); }; Date.TimePeriod = TimePeriod; if (typeof window !== "undefined") { // keeping API compatible for v1.x window.TimePeriod = TimePeriod; } }()); ================================================ FILE: build/date-nb-NO.js ================================================ /** * @overview datejs * @version 1.0.0-rc3 * @author Gregory Wild-Smith * @copyright 2015 Gregory Wild-Smith * @license MIT * @homepage https://github.com/abritinthebay/datejs */ /* * DateJS Culture String File * Country Code: nb-NO * Name: Norwegian, Bokmål (Norway) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["nb-NO"] = { "name": "nb-NO", "englishName": "Norwegian, Bokmål (Norway)", "nativeName": "norsk, bokmål (Norge)", "Sunday": "søndag", "Monday": "mandag", "Tuesday": "tirsdag", "Wednesday": "onsdag", "Thursday": "torsdag", "Friday": "fredag", "Saturday": "lørdag", "Sun": "sø", "Mon": "ma", "Tue": "ti", "Wed": "on", "Thu": "to", "Fri": "fr", "Sat": "lø", "Su": "sø", "Mo": "ma", "Tu": "ti", "We": "on", "Th": "to", "Fr": "fr", "Sa": "lø", "S_Sun_Initial": "s", "M_Mon_Initial": "m", "T_Tue_Initial": "t", "W_Wed_Initial": "o", "T_Thu_Initial": "t", "F_Fri_Initial": "f", "S_Sat_Initial": "l", "January": "januar", "February": "februar", "March": "mars", "April": "april", "May": "mai", "June": "juni", "July": "juli", "August": "august", "September": "september", "October": "oktober", "November": "november", "December": "desember", "Jan_Abbr": "jan", "Feb_Abbr": "feb", "Mar_Abbr": "mar", "Apr_Abbr": "apr", "May_Abbr": "mai", "Jun_Abbr": "jun", "Jul_Abbr": "jul", "Aug_Abbr": "aug", "Sep_Abbr": "sep", "Oct_Abbr": "okt", "Nov_Abbr": "nov", "Dec_Abbr": "des", "AM": "", "PM": "", "firstDayOfWeek": 1, "twoDigitYearMax": 2029, "mdy": "dmy", "M/d/yyyy": "dd.MM.yyyy", "dddd, MMMM dd, yyyy": "d. MMMM yyyy", "h:mm tt": "HH:mm", "h:mm:ss tt": "HH:mm:ss", "dddd, MMMM dd, yyyy h:mm:ss tt": "d. MMMM yyyy HH:mm:ss", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "d. MMMM", "MMMM, yyyy": "MMMM yyyy", "/jan(uary)?/": "jan(uar)?", "/feb(ruary)?/": "feb(ruar)?", "/mar(ch)?/": "mar(s)?", "/apr(il)?/": "apr(il)?", "/may/": "mai", "/jun(e)?/": "jun(i)?", "/jul(y)?/": "jul(i)?", "/aug(ust)?/": "aug(ust)?", "/sep(t(ember)?)?/": "sep(t(ember)?)?", "/oct(ober)?/": "okt(ober)?", "/nov(ember)?/": "nov(ember)?", "/dec(ember)?/": "des(ember)?", "/^su(n(day)?)?/": "^søndag", "/^mo(n(day)?)?/": "^mandag", "/^tu(e(s(day)?)?)?/": "^tirsdag", "/^we(d(nesday)?)?/": "^onsdag", "/^th(u(r(s(day)?)?)?)?/": "^torsdag", "/^fr(i(day)?)?/": "^fredag", "/^sa(t(urday)?)?/": "^lørdag", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "nb-NO"; /** * @overview datejs * @version 1.0.0-rc3 * @author Gregory Wild-Smith * @copyright 2015 Gregory Wild-Smith * @license MIT * @homepage https://github.com/abritinthebay/datejs */(function () { var $D = Date; var lang = Date.CultureStrings ? Date.CultureStrings.lang : null; var loggedKeys = {}; // for debug purposes. var getText = { getFromKey: function (key, countryCode) { var output; if (Date.CultureStrings && Date.CultureStrings[countryCode] && Date.CultureStrings[countryCode][key]) { output = Date.CultureStrings[countryCode][key]; } else { output = getText.buildFromDefault(key); } if (key.charAt(0) === "/") { // Assume it's a regex output = getText.buildFromRegex(key, countryCode); } return output; }, getFromObjectValues: function (obj, countryCode) { var key, output = {}; for(key in obj) { if (obj.hasOwnProperty(key)) { output[key] = getText.getFromKey(obj[key], countryCode); } } return output; }, getFromObjectKeys: function (obj, countryCode) { var key, output = {}; for(key in obj) { if (obj.hasOwnProperty(key)) { output[getText.getFromKey(key, countryCode)] = obj[key]; } } return output; }, getFromArray: function (arr, countryCode) { var output = []; for (var i=0; i < arr.length; i++){ if (i in arr) { output[i] = getText.getFromKey(arr[i], countryCode); } } return output; }, buildFromDefault: function (key) { var output, length, split, last; switch(key) { case "name": output = "en-US"; break; case "englishName": output = "English (United States)"; break; case "nativeName": output = "English (United States)"; break; case "twoDigitYearMax": output = 2049; break; case "firstDayOfWeek": output = 0; break; default: output = key; split = key.split("_"); length = split.length; if (length > 1 && key.charAt(0) !== "/") { // if the key isn't a regex and it has a split. last = split[(length - 1)].toLowerCase(); if (last === "initial" || last === "abbr") { output = split[0]; } } break; } return output; }, buildFromRegex: function (key, countryCode) { var output; if (Date.CultureStrings && Date.CultureStrings[countryCode] && Date.CultureStrings[countryCode][key]) { output = new RegExp(Date.CultureStrings[countryCode][key], "i"); } else { output = new RegExp(key.replace(new RegExp("/", "g"),""), "i"); } return output; } }; var shallowMerge = function (obj1, obj2) { for (var attrname in obj2) { if (obj2.hasOwnProperty(attrname)) { obj1[attrname] = obj2[attrname]; } } }; var __ = function (key, language) { var countryCode = (language) ? language : lang; loggedKeys[key] = key; if (typeof key === "object") { if (key instanceof Array) { return getText.getFromArray(key, countryCode); } else { return getText.getFromObjectKeys(key, countryCode); } } else { return getText.getFromKey(key, countryCode); } }; var loadI18nScript = function (code) { // paatterned after jQuery's getScript. var url = Date.Config.i18n + code + ".js"; var head = document.getElementsByTagName("head")[0] || document.documentElement; var script = document.createElement("script"); script.src = url; var completed = false; var events = { done: function (){} // placeholder function }; // Attach handlers for all browsers script.onload = script.onreadystatechange = function() { if ( !completed && (!this.readyState || this.readyState === "loaded" || this.readyState === "complete") ) { events.done(); head.removeChild(script); } }; setTimeout(function() { head.insertBefore(script, head.firstChild); }, 0); // allows return to execute first return { done: function (cb) { events.done = function() { if (cb) { setTimeout(cb,0); } }; } }; }; var buildInfo = { buildFromMethodHash: function (obj) { var key; for(key in obj) { if (obj.hasOwnProperty(key)) { obj[key] = buildInfo[obj[key]](); } } return obj; }, timeZoneDST: function () { var DST = { "CHADT": "+1345", "NZDT": "+1300", "AEDT": "+1100", "ACDT": "+1030", "AZST": "+0500", "IRDT": "+0430", "EEST": "+0300", "CEST": "+0200", "BST": "+0100", "PMDT": "-0200", "ADT": "-0300", "NDT": "-0230", "EDT": "-0400", "CDT": "-0500", "MDT": "-0600", "PDT": "-0700", "AKDT": "-0800", "HADT": "-0900" }; return __(DST); }, timeZoneStandard: function () { var standard = { "LINT": "+1400", "TOT": "+1300", "CHAST": "+1245", "NZST": "+1200", "NFT": "+1130", "SBT": "+1100", "AEST": "+1000", "ACST": "+0930", "JST": "+0900", "CWST": "+0845", "CT": "+0800", "ICT": "+0700", "MMT": "+0630", "BST": "+0600", "NPT": "+0545", "IST": "+0530", "PKT": "+0500", "AFT": "+0430", "MSK": "+0400", "IRST": "+0330", "FET": "+0300", "EET": "+0200", "CET": "+0100", "GMT": "+0000", "UTC": "+0000", "CVT": "-0100", "GST": "-0200", "BRT": "-0300", "NST": "-0330", "AST": "-0400", "EST": "-0500", "CST": "-0600", "MST": "-0700", "PST": "-0800", "AKST": "-0900", "MIT": "-0930", "HST": "-1000", "SST": "-1100", "BIT": "-1200" }; return __(standard); }, timeZones: function (data) { var zone; data.timezones = []; for (zone in data.abbreviatedTimeZoneStandard) { if (data.abbreviatedTimeZoneStandard.hasOwnProperty(zone)) { data.timezones.push({ name: zone, offset: data.abbreviatedTimeZoneStandard[zone]}); } } for (zone in data.abbreviatedTimeZoneDST) { if (data.abbreviatedTimeZoneDST.hasOwnProperty(zone)) { data.timezones.push({ name: zone, offset: data.abbreviatedTimeZoneDST[zone], dst: true}); } } return data.timezones; }, days: function () { return __(["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"]); }, dayAbbr: function () { return __(["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"]); }, dayShortNames: function () { return __(["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"]); }, dayFirstLetters: function () { return __(["S_Sun_Initial", "M_Mon_Initial", "T_Tues_Initial", "W_Wed_Initial", "T_Thu_Initial", "F_Fri_Initial", "S_Sat_Initial"]); }, months: function () { return __(["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"]); }, monthAbbr: function () { return __(["Jan_Abbr", "Feb_Abbr", "Mar_Abbr", "Apr_Abbr", "May_Abbr", "Jun_Abbr", "Jul_Abbr", "Aug_Abbr", "Sep_Abbr", "Oct_Abbr", "Nov_Abbr", "Dec_Abbr"]); }, formatPatterns: function () { return getText.getFromObjectValues({ shortDate: "M/d/yyyy", longDate: "dddd, MMMM dd, yyyy", shortTime: "h:mm tt", longTime: "h:mm:ss tt", fullDateTime: "dddd, MMMM dd, yyyy h:mm:ss tt", sortableDateTime: "yyyy-MM-ddTHH:mm:ss", universalSortableDateTime: "yyyy-MM-dd HH:mm:ssZ", rfc1123: "ddd, dd MMM yyyy HH:mm:ss", monthDay: "MMMM dd", yearMonth: "MMMM, yyyy" }, Date.i18n.currentLanguage()); }, regex: function () { return getText.getFromObjectValues({ inTheMorning: "/( in the )(morn(ing)?)\\b/", thisMorning: "/(this )(morn(ing)?)\\b/", amThisMorning: "/(\b\\d(am)? )(this )(morn(ing)?)/", inTheEvening: "/( in the )(even(ing)?)\\b/", thisEvening: "/(this )(even(ing)?)\\b/", pmThisEvening: "/(\b\\d(pm)? )(this )(even(ing)?)/", jan: "/jan(uary)?/", feb: "/feb(ruary)?/", mar: "/mar(ch)?/", apr: "/apr(il)?/", may: "/may/", jun: "/jun(e)?/", jul: "/jul(y)?/", aug: "/aug(ust)?/", sep: "/sep(t(ember)?)?/", oct: "/oct(ober)?/", nov: "/nov(ember)?/", dec: "/dec(ember)?/", sun: "/^su(n(day)?)?/", mon: "/^mo(n(day)?)?/", tue: "/^tu(e(s(day)?)?)?/", wed: "/^we(d(nesday)?)?/", thu: "/^th(u(r(s(day)?)?)?)?/", fri: "/fr(i(day)?)?/", sat: "/^sa(t(urday)?)?/", future: "/^next/", past: "/^last|past|prev(ious)?/", add: "/^(\\+|aft(er)?|from|hence)/", subtract: "/^(\\-|bef(ore)?|ago)/", yesterday: "/^yes(terday)?/", today: "/^t(od(ay)?)?/", tomorrow: "/^tom(orrow)?/", now: "/^n(ow)?/", millisecond: "/^ms|milli(second)?s?/", second: "/^sec(ond)?s?/", minute: "/^mn|min(ute)?s?/", hour: "/^h(our)?s?/", week: "/^w(eek)?s?/", month: "/^m(onth)?s?/", day: "/^d(ay)?s?/", year: "/^y(ear)?s?/", shortMeridian: "/^(a|p)/", longMeridian: "/^(a\\.?m?\\.?|p\\.?m?\\.?)/", timezone: "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/", ordinalSuffix: "/^\\s*(st|nd|rd|th)/", timeContext: "/^\\s*(\\:|a(?!u|p)|p)/" }, Date.i18n.currentLanguage()); } }; var CultureInfo = function () { var info = getText.getFromObjectValues({ name: "name", englishName: "englishName", nativeName: "nativeName", amDesignator: "AM", pmDesignator: "PM", firstDayOfWeek: "firstDayOfWeek", twoDigitYearMax: "twoDigitYearMax", dateElementOrder: "mdy" }, Date.i18n.currentLanguage()); var constructedInfo = buildInfo.buildFromMethodHash({ dayNames: "days", abbreviatedDayNames: "dayAbbr", shortestDayNames: "dayShortNames", firstLetterDayNames: "dayFirstLetters", monthNames: "months", abbreviatedMonthNames: "monthAbbr", formatPatterns: "formatPatterns", regexPatterns: "regex", abbreviatedTimeZoneDST: "timeZoneDST", abbreviatedTimeZoneStandard: "timeZoneStandard" }); shallowMerge(info, constructedInfo); buildInfo.timeZones(info); return info; }; $D.i18n = { __: function (key, lang) { return __(key, lang); }, currentLanguage: function () { return lang || "en-US"; }, setLanguage: function (code, force, cb) { var async = false; if (force || code === "en-US" || (!!Date.CultureStrings && !!Date.CultureStrings[code])) { lang = code; Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings.lang = code; Date.CultureInfo = new CultureInfo(); } else { if (!(!!Date.CultureStrings && !!Date.CultureStrings[code])) { if (typeof exports !== "undefined" && this.exports !== exports) { // we're in a Node enviroment, load it using require try { require("../i18n/" + code + ".js"); lang = code; Date.CultureStrings.lang = code; Date.CultureInfo = new CultureInfo(); } catch (e) { // var str = "The language for '" + code + "' could not be loaded by Node. It likely does not exist."; throw new Error("The DateJS IETF language tag '" + code + "' could not be loaded by Node. It likely does not exist."); } } else if (Date.Config && Date.Config.i18n) { // we know the location of the files, so lets load them async = true; loadI18nScript(code).done(function(){ lang = code; Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings.lang = code; Date.CultureInfo = new CultureInfo(); $D.Parsing.Normalizer.buildReplaceData(); // because this is async if ($D.Grammar) { $D.Grammar.buildGrammarFormats(); // so we can parse those strings... } if (cb) { setTimeout(cb,0); } }); } else { Date.console.error("The DateJS IETF language tag '" + code + "' is not available and has not been loaded."); return false; } } } $D.Parsing.Normalizer.buildReplaceData(); // rebuild normalizer strings if ($D.Grammar) { $D.Grammar.buildGrammarFormats(); // so we can parse those strings... } if (!async && cb) { setTimeout(cb,0); } }, getLoggedKeys: function () { return loggedKeys; }, updateCultureInfo: function () { Date.CultureInfo = new CultureInfo(); } }; $D.i18n.updateCultureInfo(); // run automatically }()); (function () { var $D = Date, $P = $D.prototype, p = function (s, l) { if (!l) { l = 2; } return ("000" + s).slice(l * -1); }; if (typeof window !== "undefined" && typeof window.console !== "undefined" && typeof window.console.log !== "undefined") { $D.console = console; // used only to raise non-critical errors if available } else { // set mock so we don't give errors. $D.console = { log: function(){}, error: function(){} }; } $D.Config = $D.Config || {}; $D.initOverloads = function() { /** * Overload of Date.now. Allows an alternate call for Date.now where it returns the * current Date as an object rather than just milliseconds since the Unix Epoch. * * Also provides an implementation of now() for browsers (IE<9) that don't have it. * * Backwards compatible so with work with either: * Date.now() [returns ms] * or * Date.now(true) [returns Date] */ if (!$D.now) { $D._now = function now() { return new Date().getTime(); }; } else if (!$D._now) { $D._now = $D.now; } $D.now = function (returnObj) { if (returnObj) { return $D.present(); } else { return $D._now(); } }; if ( !$P.toISOString ) { $P.toISOString = function() { return this.getUTCFullYear() + "-" + p(this.getUTCMonth() + 1) + "-" + p(this.getUTCDate()) + "T" + p(this.getUTCHours()) + ":" + p(this.getUTCMinutes()) + ":" + p(this.getUTCSeconds()) + "." + String( (this.getUTCMilliseconds()/1000).toFixed(3)).slice(2, 5) + "Z"; }; } // private if ( $P._toString === undefined ){ $P._toString = $P.toString; } }; $D.initOverloads(); /** * Gets a date that is set to the current date. The time is set to the start of the day (00:00 or 12:00 AM). * @return {Date} The current date. */ $D.today = function () { return new Date().clearTime(); }; /** * Gets a date that is set to the current date and time (same as new Date, but chainable) * @return {Date} The current date. */ $D.present = function () { return new Date(); }; /** * Compares the first date to the second date and returns an number indication of their relative values. * @param {Date} First Date object to compare [Required]. * @param {Date} Second Date object to compare to [Required]. * @return {Number} -1 = date1 is lessthan date2. 0 = values are equal. 1 = date1 is greaterthan date2. */ $D.compare = function (date1, date2) { if (isNaN(date1) || isNaN(date2)) { throw new Error(date1 + " - " + date2); } else if (date1 instanceof Date && date2 instanceof Date) { return (date1 < date2) ? -1 : (date1 > date2) ? 1 : 0; } else { throw new TypeError(date1 + " - " + date2); } }; /** * Compares the first Date object to the second Date object and returns true if they are equal. * @param {Date} First Date object to compare [Required] * @param {Date} Second Date object to compare to [Required] * @return {Boolean} true if dates are equal. false if they are not equal. */ $D.equals = function (date1, date2) { return (date1.compareTo(date2) === 0); }; /** * Gets the language appropriate day name when given the day number(0-6) * eg - 0 == Sunday * @return {String} The day name */ $D.getDayName = function (n) { return Date.CultureInfo.dayNames[n]; }; /** * Gets the day number (0-6) if given a CultureInfo specific string which is a valid dayName, abbreviatedDayName or shortestDayName (two char). * @param {String} The name of the day (eg. "Monday, "Mon", "tuesday", "tue", "We", "we"). * @return {Number} The day number */ $D.getDayNumberFromName = function (name) { var n = Date.CultureInfo.dayNames, m = Date.CultureInfo.abbreviatedDayNames, o = Date.CultureInfo.shortestDayNames, s = name.toLowerCase(); for (var i = 0; i < n.length; i++) { if (n[i].toLowerCase() === s || m[i].toLowerCase() === s || o[i].toLowerCase() === s) { return i; } } return -1; }; /** * Gets the month number (0-11) if given a Culture Info specific string which is a valid monthName or abbreviatedMonthName. * @param {String} The name of the month (eg. "February, "Feb", "october", "oct"). * @return {Number} The day number */ $D.getMonthNumberFromName = function (name) { var n = Date.CultureInfo.monthNames, m = Date.CultureInfo.abbreviatedMonthNames, s = name.toLowerCase(); for (var i = 0; i < n.length; i++) { if (n[i].toLowerCase() === s || m[i].toLowerCase() === s) { return i; } } return -1; }; /** * Gets the language appropriate month name when given the month number(0-11) * eg - 0 == January * @return {String} The month name */ $D.getMonthName = function (n) { return Date.CultureInfo.monthNames[n]; }; /** * Determines if the current date instance is within a LeapYear. * @param {Number} The year. * @return {Boolean} true if date is within a LeapYear, otherwise false. */ $D.isLeapYear = function (year) { return ((year % 4 === 0 && year % 100 !== 0) || year % 400 === 0); }; /** * Gets the number of days in the month, given a year and month value. Automatically corrects for LeapYear. * @param {Number} The year. * @param {Number} The month (0-11). * @return {Number} The number of days in the month. */ $D.getDaysInMonth = function (year, month) { if (!month && $D.validateMonth(year)) { month = year; year = Date.today().getFullYear(); } return [31, ($D.isLeapYear(year) ? 29 : 28), 31, 30, 31, 30, 31, 31, 30, 31, 30, 31][month]; }; $P.getDaysInMonth = function () { return $D.getDaysInMonth(this.getFullYear(), this.getMonth()); }; $D.getTimezoneAbbreviation = function (offset, dst) { var p, n = (dst || false) ? Date.CultureInfo.abbreviatedTimeZoneDST : Date.CultureInfo.abbreviatedTimeZoneStandard; for (p in n) { if (n.hasOwnProperty(p)) { if (n[p] === offset) { return p; } } } return null; }; $D.getTimezoneOffset = function (name, dst) { var i, a =[], z = Date.CultureInfo.timezones; if (!name) { name = (new Date()).getTimezone();} for (i = 0; i < z.length; i++) { if (z[i].name === name.toUpperCase()) { a.push(i); } } if (!z[a[0]]) { return null; } if (a.length === 1 || !dst) { return z[a[0]].offset; } else { for (i=0; i < a.length; i++) { if (z[a[i]].dst) { return z[a[i]].offset; } } } }; $D.getQuarter = function (d) { d = d || new Date(); // If no date supplied, use today var q = [1,2,3,4]; return q[Math.floor(d.getMonth() / 3)]; // ~~~ is a bitwise op. Faster than Math.floor }; $D.getDaysLeftInQuarter = function (d) { d = d || new Date(); var qEnd = new Date(d); qEnd.setMonth(qEnd.getMonth() + 3 - qEnd.getMonth() % 3, 0); return Math.floor((qEnd - d) / 8.64e7); }; // private var validate = function (n, min, max, name) { name = name ? name : "Object"; if (typeof n === "undefined") { return false; } else if (typeof n !== "number") { throw new TypeError(n + " is not a Number."); } else if (n < min || n > max) { // As failing validation is *not* an exceptional circumstance // lets not throw a RangeError Exception here. // It's semantically correct but it's not sensible. return false; } return true; }; /** * Validates the number is within an acceptable range for milliseconds [0-999]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateMillisecond = function (value) { return validate(value, 0, 999, "millisecond"); }; /** * Validates the number is within an acceptable range for seconds [0-59]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateSecond = function (value) { return validate(value, 0, 59, "second"); }; /** * Validates the number is within an acceptable range for minutes [0-59]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateMinute = function (value) { return validate(value, 0, 59, "minute"); }; /** * Validates the number is within an acceptable range for hours [0-23]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateHour = function (value) { return validate(value, 0, 23, "hour"); }; /** * Validates the number is within an acceptable range for the days in a month [0-MaxDaysInMonth]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateDay = function (value, year, month) { if (year === undefined || year === null || month === undefined || month === null) { return false;} return validate(value, 1, $D.getDaysInMonth(year, month), "day"); }; /** * Validates the number is within an acceptable range for months [0-11]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateWeek = function (value) { return validate(value, 0, 53, "week"); }; /** * Validates the number is within an acceptable range for months [0-11]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateMonth = function (value) { return validate(value, 0, 11, "month"); }; /** * Validates the number is within an acceptable range for years. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateYear = function (value) { /** * Per ECMAScript spec the range of times supported by Date objects is * exactly -100,000,000 days to +100,000,000 days measured relative to * midnight at the beginning of 01 January, 1970 UTC. * This gives a range of 8,640,000,000,000,000 milliseconds to either * side of 01 January, 1970 UTC. * * Earliest possible date: Tue, 20 Apr 271,822 B.C. 00:00:00 UTC * Latest possible date: Sat, 13 Sep 275,760 00:00:00 UTC */ return validate(value, -271822, 275760, "year"); }; $D.validateTimezone = function(value) { var timezones = {"ACDT":1,"ACST":1,"ACT":1,"ADT":1,"AEDT":1,"AEST":1,"AFT":1,"AKDT":1,"AKST":1,"AMST":1,"AMT":1,"ART":1,"AST":1,"AWDT":1,"AWST":1,"AZOST":1,"AZT":1,"BDT":1,"BIOT":1,"BIT":1,"BOT":1,"BRT":1,"BST":1,"BTT":1,"CAT":1,"CCT":1,"CDT":1,"CEDT":1,"CEST":1,"CET":1,"CHADT":1,"CHAST":1,"CHOT":1,"ChST":1,"CHUT":1,"CIST":1,"CIT":1,"CKT":1,"CLST":1,"CLT":1,"COST":1,"COT":1,"CST":1,"CT":1,"CVT":1,"CWST":1,"CXT":1,"DAVT":1,"DDUT":1,"DFT":1,"EASST":1,"EAST":1,"EAT":1,"ECT":1,"EDT":1,"EEDT":1,"EEST":1,"EET":1,"EGST":1,"EGT":1,"EIT":1,"EST":1,"FET":1,"FJT":1,"FKST":1,"FKT":1,"FNT":1,"GALT":1,"GAMT":1,"GET":1,"GFT":1,"GILT":1,"GIT":1,"GMT":1,"GST":1,"GYT":1,"HADT":1,"HAEC":1,"HAST":1,"HKT":1,"HMT":1,"HOVT":1,"HST":1,"ICT":1,"IDT":1,"IOT":1,"IRDT":1,"IRKT":1,"IRST":1,"IST":1,"JST":1,"KGT":1,"KOST":1,"KRAT":1,"KST":1,"LHST":1,"LINT":1,"MAGT":1,"MART":1,"MAWT":1,"MDT":1,"MET":1,"MEST":1,"MHT":1,"MIST":1,"MIT":1,"MMT":1,"MSK":1,"MST":1,"MUT":1,"MVT":1,"MYT":1,"NCT":1,"NDT":1,"NFT":1,"NPT":1,"NST":1,"NT":1,"NUT":1,"NZDT":1,"NZST":1,"OMST":1,"ORAT":1,"PDT":1,"PET":1,"PETT":1,"PGT":1,"PHOT":1,"PHT":1,"PKT":1,"PMDT":1,"PMST":1,"PONT":1,"PST":1,"PYST":1,"PYT":1,"RET":1,"ROTT":1,"SAKT":1,"SAMT":1,"SAST":1,"SBT":1,"SCT":1,"SGT":1,"SLST":1,"SRT":1,"SST":1,"SYOT":1,"TAHT":1,"THA":1,"TFT":1,"TJT":1,"TKT":1,"TLT":1,"TMT":1,"TOT":1,"TVT":1,"UCT":1,"ULAT":1,"UTC":1,"UYST":1,"UYT":1,"UZT":1,"VET":1,"VLAT":1,"VOLT":1,"VOST":1,"VUT":1,"WAKT":1,"WAST":1,"WAT":1,"WEDT":1,"WEST":1,"WET":1,"WST":1,"YAKT":1,"YEKT":1,"Z":1}; return (timezones[value] === 1); }; $D.validateTimezoneOffset= function(value) { // timezones go from +14hrs to -12hrs, the +X hours are negative offsets. return (value > -841 && value < 721); }; }()); (function () { var $D = Date, $P = $D.prototype, p = function (s, l) { if (!l) { l = 2; } return ("000" + s).slice(l * -1); }; var validateConfigObject = function (obj) { var result = {}, self = this, prop, testFunc; testFunc = function (prop, func, value) { if (prop === "day") { var month = (obj.month !== undefined) ? obj.month : self.getMonth(); var year = (obj.year !== undefined) ? obj.year : self.getFullYear(); return $D[func](value, year, month); } else { return $D[func](value); } }; for (prop in obj) { if (Object.prototype.hasOwnProperty.call(obj, prop)) { var func = "validate" + prop.charAt(0).toUpperCase() + prop.slice(1); if ($D[func] && obj[prop] !== null && testFunc(prop, func, obj[prop])) { result[prop] = obj[prop]; } } } return result; }; /** * Resets the time of this Date object to 12:00 AM (00:00), which is the start of the day. * @param {Boolean} .clone() this date instance before clearing Time * @return {Date} this */ $P.clearTime = function () { this.setHours(0); this.setMinutes(0); this.setSeconds(0); this.setMilliseconds(0); return this; }; /** * Resets the time of this Date object to the current time ('now'). * @return {Date} this */ $P.setTimeToNow = function () { var n = new Date(); this.setHours(n.getHours()); this.setMinutes(n.getMinutes()); this.setSeconds(n.getSeconds()); this.setMilliseconds(n.getMilliseconds()); return this; }; /** * Returns a new Date object that is an exact date and time copy of the original instance. * @return {Date} A new Date instance */ $P.clone = function () { return new Date(this.getTime()); }; /** * Compares this instance to a Date object and returns an number indication of their relative values. * @param {Date} Date object to compare [Required] * @return {Number} -1 = this is lessthan date. 0 = values are equal. 1 = this is greaterthan date. */ $P.compareTo = function (date) { return Date.compare(this, date); }; /** * Compares this instance to another Date object and returns true if they are equal. * @param {Date} Date object to compare. If no date to compare, new Date() [now] is used. * @return {Boolean} true if dates are equal. false if they are not equal. */ $P.equals = function (date) { return Date.equals(this, (date !== undefined ? date : new Date())); }; /** * Determines if this instance is between a range of two dates or equal to either the start or end dates. * @param {Date} Start of range [Required] * @param {Date} End of range [Required] * @return {Boolean} true is this is between or equal to the start and end dates, else false */ $P.between = function (start, end) { return this.getTime() >= start.getTime() && this.getTime() <= end.getTime(); }; /** * Determines if this date occurs after the date to compare to. * @param {Date} Date object to compare. If no date to compare, new Date() ("now") is used. * @return {Boolean} true if this date instance is greater than the date to compare to (or "now"), otherwise false. */ $P.isAfter = function (date) { return this.compareTo(date || new Date()) === 1; }; /** * Determines if this date occurs before the date to compare to. * @param {Date} Date object to compare. If no date to compare, new Date() ("now") is used. * @return {Boolean} true if this date instance is less than the date to compare to (or "now"). */ $P.isBefore = function (date) { return (this.compareTo(date || new Date()) === -1); }; /** * Determines if the current Date instance occurs today. * @return {Boolean} true if this date instance is 'today', otherwise false. */ /** * Determines if the current Date instance occurs on the same Date as the supplied 'date'. * If no 'date' to compare to is provided, the current Date instance is compared to 'today'. * @param {date} Date object to compare. If no date to compare, the current Date ("now") is used. * @return {Boolean} true if this Date instance occurs on the same Day as the supplied 'date'. */ $P.isToday = $P.isSameDay = function (date) { return this.clone().clearTime().equals((date || new Date()).clone().clearTime()); }; /** * Adds the specified number of milliseconds to this instance. * @param {Number} The number of milliseconds to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addMilliseconds = function (value) { if (!value) { return this; } this.setTime(this.getTime() + value * 1); return this; }; /** * Adds the specified number of seconds to this instance. * @param {Number} The number of seconds to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addSeconds = function (value) { if (!value) { return this; } return this.addMilliseconds(value * 1000); }; /** * Adds the specified number of seconds to this instance. * @param {Number} The number of seconds to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addMinutes = function (value) { if (!value) { return this; } return this.addMilliseconds(value * 60000); // 60*1000 }; /** * Adds the specified number of hours to this instance. * @param {Number} The number of hours to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addHours = function (value) { if (!value) { return this; } return this.addMilliseconds(value * 3600000); // 60*60*1000 }; /** * Adds the specified number of days to this instance. * @param {Number} The number of days to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addDays = function (value) { if (!value) { return this; } this.setDate(this.getDate() + value * 1); return this; }; /** * Adds the specified number of weekdays (ie - not sat or sun) to this instance. * @param {Number} The number of days to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addWeekdays = function (value) { if (!value) { return this; } var day = this.getDay(); var weeks = (Math.ceil(Math.abs(value)/7)); if (day === 0 || day === 6) { if (value > 0) { this.next().monday(); this.addDays(-1); day = this.getDay(); } } if (value < 0) { while (value < 0) { this.addDays(-1); day = this.getDay(); if (day !== 0 && day !== 6) { value++; } } return this; } else if (value > 5 || (6-day) <= value) { value = value + (weeks * 2); } return this.addDays(value); }; /** * Adds the specified number of weeks to this instance. * @param {Number} The number of weeks to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addWeeks = function (value) { if (!value) { return this; } return this.addDays(value * 7); }; /** * Adds the specified number of months to this instance. * @param {Number} The number of months to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addMonths = function (value) { if (!value) { return this; } var n = this.getDate(); this.setDate(1); this.setMonth(this.getMonth() + value * 1); this.setDate(Math.min(n, $D.getDaysInMonth(this.getFullYear(), this.getMonth()))); return this; }; $P.addQuarters = function (value) { if (!value) { return this; } // note this will take you to the same point in the quarter as you are now. // i.e. - if you are 15 days into the quarter you'll be 15 days into the resulting one. // bonus: this allows adding fractional quarters return this.addMonths(value * 3); }; /** * Adds the specified number of years to this instance. * @param {Number} The number of years to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addYears = function (value) { if (!value) { return this; } return this.addMonths(value * 12); }; /** * Adds (or subtracts) to the value of the years, months, weeks, days, hours, minutes, seconds, milliseconds of the date instance using given configuration object. Positive and Negative values allowed. * Example

	Date.today().add( { days: 1, months: 1 } )

	new Date().add( { years: -1 } )
	
* @param {Object} Configuration object containing attributes (months, days, etc.) * @return {Date} this */ $P.add = function (config) { if (typeof config === "number") { this._orient = config; return this; } var x = config; if (x.day) { // If we should be a different date than today (eg: for 'tomorrow -1d', etc). // Should only effect parsing, not direct usage (eg, Finish and FinishExact) if ((x.day - this.getDate()) !== 0) { this.setDate(x.day); } } if (x.milliseconds) { this.addMilliseconds(x.milliseconds); } if (x.seconds) { this.addSeconds(x.seconds); } if (x.minutes) { this.addMinutes(x.minutes); } if (x.hours) { this.addHours(x.hours); } if (x.weeks) { this.addWeeks(x.weeks); } if (x.months) { this.addMonths(x.months); } if (x.years) { this.addYears(x.years); } if (x.days) { this.addDays(x.days); } return this; }; /** * Get the week number. Week one (1) is the week which contains the first Thursday of the year. Monday is considered the first day of the week. * The .getWeek() function does NOT convert the date to UTC. The local datetime is used. * Please use .getISOWeek() to get the week of the UTC converted date. * @return {Number} 1 to 53 */ $P.getWeek = function (utc) { // Create a copy of this date object var self, target = new Date(this.valueOf()); if (utc) { target.addMinutes(target.getTimezoneOffset()); self = target.clone(); } else { self = this; } // ISO week date weeks start on monday // so correct the day number var dayNr = (self.getDay() + 6) % 7; // ISO 8601 states that week 1 is the week // with the first thursday of that year. // Set the target date to the thursday in the target week target.setDate(target.getDate() - dayNr + 3); // Store the millisecond value of the target date var firstThursday = target.valueOf(); // Set the target to the first thursday of the year // First set the target to january first target.setMonth(0, 1); // Not a thursday? Correct the date to the next thursday if (target.getDay() !== 4) { target.setMonth(0, 1 + ((4 - target.getDay()) + 7) % 7); } // The weeknumber is the number of weeks between the // first thursday of the year and the thursday in the target week return 1 + Math.ceil((firstThursday - target) / 604800000); // 604800000 = 7 * 24 * 3600 * 1000 }; /** * Get the ISO 8601 week number. Week one ("01") is the week which contains the first Thursday of the year. Monday is considered the first day of the week. * The .getISOWeek() function does convert the date to it's UTC value. Please use .getWeek() to get the week of the local date. * @return {String} "01" to "53" */ $P.getISOWeek = function () { return p(this.getWeek(true)); }; /** * Moves the date to Monday of the week set. Week one (1) is the week which contains the first Thursday of the year. * @param {Number} A Number (1 to 53) that represents the week of the year. * @return {Date} this */ $P.setWeek = function (n) { if ((n - this.getWeek()) === 0) { if (this.getDay() !== 1) { return this.moveToDayOfWeek(1, (this.getDay() > 1 ? -1 : 1)); } else { return this; } } else { return this.moveToDayOfWeek(1, (this.getDay() > 1 ? -1 : 1)).addWeeks(n - this.getWeek()); } }; $P.setQuarter = function (qtr) { var month = Math.abs(((qtr-1) * 3) + 1); return this.setMonth(month, 1); }; $P.getQuarter = function () { return Date.getQuarter(this); }; $P.getDaysLeftInQuarter = function () { return Date.getDaysLeftInQuarter(this); }; /** * Moves the date to the next n'th occurrence of the dayOfWeek starting from the beginning of the month. The number (-1) is a magic number and will return the last occurrence of the dayOfWeek in the month. * @param {Number} The dayOfWeek to move to * @param {Number} The n'th occurrence to move to. Use (-1) to return the last occurrence in the month * @return {Date} this */ $P.moveToNthOccurrence = function (dayOfWeek, occurrence) { if (dayOfWeek === "Weekday") { if (occurrence > 0) { this.moveToFirstDayOfMonth(); if (this.is().weekday()) { occurrence -= 1; } } else if (occurrence < 0) { this.moveToLastDayOfMonth(); if (this.is().weekday()) { occurrence += 1; } } else { return this; } return this.addWeekdays(occurrence); } var shift = 0; if (occurrence > 0) { shift = occurrence - 1; } else if (occurrence === -1) { this.moveToLastDayOfMonth(); if (this.getDay() !== dayOfWeek) { this.moveToDayOfWeek(dayOfWeek, -1); } return this; } return this.moveToFirstDayOfMonth().addDays(-1).moveToDayOfWeek(dayOfWeek, +1).addWeeks(shift); }; var moveToN = function (getFunc, addFunc, nVal) { return function (value, orient) { var diff = (value - this[getFunc]() + nVal * (orient || +1)) % nVal; return this[addFunc]((diff === 0) ? diff += nVal * (orient || +1) : diff); }; }; /** * Move to the next or last dayOfWeek based on the orient value. * @param {Number} The dayOfWeek to move to * @param {Number} Forward (+1) or Back (-1). Defaults to +1. [Optional] * @return {Date} this */ $P.moveToDayOfWeek = moveToN("getDay", "addDays", 7); /** * Move to the next or last month based on the orient value. * @param {Number} The month to move to. 0 = January, 11 = December * @param {Number} Forward (+1) or Back (-1). Defaults to +1. [Optional] * @return {Date} this */ $P.moveToMonth = moveToN("getMonth", "addMonths", 12); /** * Get the Ordinate of the current day ("th", "st", "rd"). * @return {String} */ $P.getOrdinate = function () { var num = this.getDate(); return ord(num); }; /** * Get the Ordinal day (numeric day number) of the year, adjusted for leap year. * @return {Number} 1 through 365 (366 in leap years) */ $P.getOrdinalNumber = function () { return Math.ceil((this.clone().clearTime() - new Date(this.getFullYear(), 0, 1)) / 86400000) + 1; }; /** * Get the time zone abbreviation of the current date. * @return {String} The abbreviated time zone name (e.g. "EST") */ $P.getTimezone = function () { return $D.getTimezoneAbbreviation(this.getUTCOffset(), this.isDaylightSavingTime()); }; $P.setTimezoneOffset = function (offset) { var here = this.getTimezoneOffset(), there = Number(offset) * -6 / 10; return (there || there === 0) ? this.addMinutes(there - here) : this; }; $P.setTimezone = function (offset) { return this.setTimezoneOffset($D.getTimezoneOffset(offset)); }; /** * Indicates whether Daylight Saving Time is observed in the current time zone. * @return {Boolean} true|false */ $P.hasDaylightSavingTime = function () { return (Date.today().set({month: 0, day: 1}).getTimezoneOffset() !== Date.today().set({month: 6, day: 1}).getTimezoneOffset()); }; /** * Indicates whether this Date instance is within the Daylight Saving Time range for the current time zone. * @return {Boolean} true|false */ $P.isDaylightSavingTime = function () { return Date.today().set({month: 0, day: 1}).getTimezoneOffset() !== this.getTimezoneOffset(); }; /** * Get the offset from UTC of the current date. * @return {String} The 4-character offset string prefixed with + or - (e.g. "-0500") */ $P.getUTCOffset = function (offset) { var n = (offset || this.getTimezoneOffset()) * -10 / 6, r; if (n < 0) { r = (n - 10000).toString(); return r.charAt(0) + r.substr(2); } else { r = (n + 10000).toString(); return "+" + r.substr(1); } }; /** * Returns the number of milliseconds between this date and date. * @param {Date} Defaults to now * @return {Number} The diff in milliseconds */ $P.getElapsed = function (date) { return (date || new Date()) - this; }; /** * Set the value of year, month, day, hour, minute, second, millisecond of date instance using given configuration object. * Example

	Date.today().set( { day: 20, month: 1 } )

	new Date().set( { millisecond: 0 } )
	
* * @param {Object} Configuration object containing attributes (month, day, etc.) * @return {Date} this */ $P.set = function (config) { config = validateConfigObject.call(this, config); var key; for (key in config) { if (Object.prototype.hasOwnProperty.call(config, key)) { var name = key.charAt(0).toUpperCase() + key.slice(1); var addFunc, getFunc; if (key !== "week" && key !== "month" && key !== "timezone" && key !== "timezoneOffset") { name += "s"; } addFunc = "add" + name; getFunc = "get" + name; if (key === "month") { addFunc = addFunc + "s"; } else if (key === "year"){ getFunc = "getFullYear"; } if (key !== "day" && key !== "timezone" && key !== "timezoneOffset" && key !== "week" && key !== "hour") { this[addFunc](config[key] - this[getFunc]()); } else if ( key === "timezone"|| key === "timezoneOffset" || key === "week" || key === "hour") { this["set"+name](config[key]); } } } // day has to go last because you can't validate the day without first knowing the month if (config.day) { this.addDays(config.day - this.getDate()); } return this; }; /** * Moves the date to the first day of the month. * @return {Date} this */ $P.moveToFirstDayOfMonth = function () { return this.set({ day: 1 }); }; /** * Moves the date to the last day of the month. * @return {Date} this */ $P.moveToLastDayOfMonth = function () { return this.set({ day: $D.getDaysInMonth(this.getFullYear(), this.getMonth())}); }; /** * Converts the value of the current Date object to its equivalent string representation. * Format Specifiers * CUSTOM DATE AND TIME FORMAT STRINGS * Format Description Example * ------ --------------------------------------------------------------------------- ----------------------- * s The seconds of the minute between 0-59. "0" to "59" * ss The seconds of the minute with leading zero if required. "00" to "59" * * m The minute of the hour between 0-59. "0" or "59" * mm The minute of the hour with leading zero if required. "00" or "59" * * h The hour of the day between 1-12. "1" to "12" * hh The hour of the day with leading zero if required. "01" to "12" * * H The hour of the day between 0-23. "0" to "23" * HH The hour of the day with leading zero if required. "00" to "23" * * d The day of the month between 1 and 31. "1" to "31" * dd The day of the month with leading zero if required. "01" to "31" * ddd Abbreviated day name. Date.CultureInfo.abbreviatedDayNames. "Mon" to "Sun" * dddd The full day name. Date.CultureInfo.dayNames. "Monday" to "Sunday" * * M The month of the year between 1-12. "1" to "12" * MM The month of the year with leading zero if required. "01" to "12" * MMM Abbreviated month name. Date.CultureInfo.abbreviatedMonthNames. "Jan" to "Dec" * MMMM The full month name. Date.CultureInfo.monthNames. "January" to "December" * * yy The year as a two-digit number. "99" or "08" * yyyy The full four digit year. "1999" or "2008" * * t Displays the first character of the A.M./P.M. designator. "A" or "P" * Date.CultureInfo.amDesignator or Date.CultureInfo.pmDesignator * tt Displays the A.M./P.M. designator. "AM" or "PM" * Date.CultureInfo.amDesignator or Date.CultureInfo.pmDesignator * * S The ordinal suffix ("st, "nd", "rd" or "th") of the current day. "st, "nd", "rd" or "th" * * STANDARD DATE AND TIME FORMAT STRINGS * Format Description Example *------ --------------------------------------------------------------------------- ----------------------- * d The CultureInfo shortDate Format Pattern "M/d/yyyy" * D The CultureInfo longDate Format Pattern "dddd, MMMM dd, yyyy" * F The CultureInfo fullDateTime Format Pattern "dddd, MMMM dd, yyyy h:mm:ss tt" * m The CultureInfo monthDay Format Pattern "MMMM dd" * r The CultureInfo rfc1123 Format Pattern "ddd, dd MMM yyyy HH:mm:ss GMT" * s The CultureInfo sortableDateTime Format Pattern "yyyy-MM-ddTHH:mm:ss" * t The CultureInfo shortTime Format Pattern "h:mm tt" * T The CultureInfo longTime Format Pattern "h:mm:ss tt" * u The CultureInfo universalSortableDateTime Format Pattern "yyyy-MM-dd HH:mm:ssZ" * y The CultureInfo yearMonth Format Pattern "MMMM, yyyy" * * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @return {String} A string representation of the current Date object. */ var ord = function (n) { switch (n * 1) { case 1: case 21: case 31: return "st"; case 2: case 22: return "nd"; case 3: case 23: return "rd"; default: return "th"; } }; var parseStandardFormats = function (format) { var y, c = Date.CultureInfo.formatPatterns; switch (format) { case "d": return this.toString(c.shortDate); case "D": return this.toString(c.longDate); case "F": return this.toString(c.fullDateTime); case "m": return this.toString(c.monthDay); case "r": case "R": y = this.clone().addMinutes(this.getTimezoneOffset()); return y.toString(c.rfc1123) + " GMT"; case "s": return this.toString(c.sortableDateTime); case "t": return this.toString(c.shortTime); case "T": return this.toString(c.longTime); case "u": y = this.clone().addMinutes(this.getTimezoneOffset()); return y.toString(c.universalSortableDateTime); case "y": return this.toString(c.yearMonth); default: return false; } }; var parseFormatStringsClosure = function (context) { return function (m) { if (m.charAt(0) === "\\") { return m.replace("\\", ""); } switch (m) { case "hh": return p(context.getHours() < 13 ? (context.getHours() === 0 ? 12 : context.getHours()) : (context.getHours() - 12)); case "h": return context.getHours() < 13 ? (context.getHours() === 0 ? 12 : context.getHours()) : (context.getHours() - 12); case "HH": return p(context.getHours()); case "H": return context.getHours(); case "mm": return p(context.getMinutes()); case "m": return context.getMinutes(); case "ss": return p(context.getSeconds()); case "s": return context.getSeconds(); case "yyyy": return p(context.getFullYear(), 4); case "yy": return p(context.getFullYear()); case "y": return context.getFullYear(); case "E": case "dddd": return Date.CultureInfo.dayNames[context.getDay()]; case "ddd": return Date.CultureInfo.abbreviatedDayNames[context.getDay()]; case "dd": return p(context.getDate()); case "d": return context.getDate(); case "MMMM": return Date.CultureInfo.monthNames[context.getMonth()]; case "MMM": return Date.CultureInfo.abbreviatedMonthNames[context.getMonth()]; case "MM": return p((context.getMonth() + 1)); case "M": return context.getMonth() + 1; case "t": return context.getHours() < 12 ? Date.CultureInfo.amDesignator.substring(0, 1) : Date.CultureInfo.pmDesignator.substring(0, 1); case "tt": return context.getHours() < 12 ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator; case "S": return ord(context.getDate()); case "W": return context.getWeek(); case "WW": return context.getISOWeek(); case "Q": return "Q" + context.getQuarter(); case "q": return String(context.getQuarter()); case "z": return context.getTimezone(); case "Z": case "X": return Date.getTimezoneOffset(context.getTimezone()); case "ZZ": // Timezone offset in seconds return context.getTimezoneOffset() * -60; case "u": return context.getDay(); case "L": return ($D.isLeapYear(context.getFullYear())) ? 1 : 0; case "B": // Swatch Internet Time (.beats) return "@"+((context.getUTCSeconds() + (context.getUTCMinutes()*60) + ((context.getUTCHours()+1)*3600))/86.4); default: return m; } }; }; $P.toString = function (format, ignoreStandards) { // Standard Date and Time Format Strings. Formats pulled from CultureInfo file and // may vary by culture. if (!ignoreStandards && format && format.length === 1) { output = parseStandardFormats.call(this, format); if (output) { return output; } } var parseFormatStrings = parseFormatStringsClosure(this); return format ? format.replace(/((\\)?(dd?d?d?|MM?M?M?|yy?y?y?|hh?|HH?|mm?|ss?|tt?|S|q|Q|WW?W?W?)(?![^\[]*\]))/g, parseFormatStrings).replace(/\[|\]/g, "") : this._toString(); }; }()); /************************************************************* * SugarPak - Domain Specific Language - Syntactical Sugar * *************************************************************/ (function () { var $D = Date, $P = $D.prototype, $N = Number.prototype; // private $P._orient = +1; // private $P._nth = null; // private $P._is = false; // private $P._same = false; // private $P._isSecond = false; // private $N._dateElement = "days"; /** * Moves the date to the next instance of a date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.today().next().friday();
	Date.today().next().fri();
	Date.today().next().march();
	Date.today().next().mar();
	Date.today().next().week();
	
* * @return {Date} date */ $P.next = function () { this._move = true; this._orient = +1; return this; }; /** * Creates a new Date (Date.today()) and moves the date to the next instance of the date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.next().friday();
	Date.next().fri();
	Date.next().march();
	Date.next().mar();
	Date.next().week();
	
* * @return {Date} date */ $D.next = function () { return $D.today().next(); }; /** * Moves the date to the previous instance of a date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.today().last().friday();
	Date.today().last().fri();
	Date.today().last().march();
	Date.today().last().mar();
	Date.today().last().week();
	
* * @return {Date} date */ $P.last = $P.prev = $P.previous = function () { this._move = true; this._orient = -1; return this; }; /** * Creates a new Date (Date.today()) and moves the date to the previous instance of the date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.last().friday();
	Date.last().fri();
	Date.previous().march();
	Date.prev().mar();
	Date.last().week();
	
* * @return {Date} date */ $D.last = $D.prev = $D.previous = function () { return $D.today().last(); }; /** * Performs a equality check when followed by either a month name, day name or .weekday() function. * Example

	Date.today().is().friday(); // true|false
	Date.today().is().fri();
	Date.today().is().march();
	Date.today().is().mar();
	
* * @return {Boolean} true|false */ $P.is = function () { this._is = true; return this; }; /** * Determines if two date objects occur on/in exactly the same instance of the subsequent date part function. * The function .same() must be followed by a date part function (example: .day(), .month(), .year(), etc). * * An optional Date can be passed in the date part function. If now date is passed as a parameter, 'Now' is used. * * The following example demonstrates how to determine if two dates fall on the exact same day. * * Example

	var d1 = Date.today(); // today at 00:00
	var d2 = new Date();   // exactly now.

	// Do they occur on the same day?
	d1.same().day(d2); // true
	
	// Do they occur on the same hour?
	d1.same().hour(d2); // false, unless d2 hour is '00' (midnight).
	
	// What if it's the same day, but one year apart?
	var nextYear = Date.today().add(1).year();

	d1.same().day(nextYear); // false, because the dates must occur on the exact same day. 
	
* * Scenario: Determine if a given date occurs during some week period 2 months from now. * * Example

	var future = Date.today().add(2).months();
	return someDate.same().week(future); // true|false;
	
* * @return {Boolean} true|false */ $P.same = function () { this._same = true; this._isSecond = false; return this; }; /** * Determines if the current date/time occurs during Today. Must be preceded by the .is() function. * Example

	someDate.is().today();    // true|false
	new Date().is().today();  // true
	Date.today().is().today();// true
	Date.today().add(-1).day().is().today(); // false
	
* * @return {Boolean} true|false */ $P.today = function () { return this.same().day(); }; /** * Determines if the current date is a weekday. This function must be preceded by the .is() function. * Example

	Date.today().is().weekday(); // true|false
	
* * @return {Boolean} true|false */ $P.weekday = function () { if (this._nth) { return df("Weekday").call(this); } if (this._move) { return this.addWeekdays(this._orient); } if (this._is) { this._is = false; return (!this.is().sat() && !this.is().sun()); } return false; }; /** * Determines if the current date is on the weekend. This function must be preceded by the .is() function. * Example

	Date.today().is().weekend(); // true|false
	
* * @return {Boolean} true|false */ $P.weekend = function () { if (this._is) { this._is = false; return (this.is().sat() || this.is().sun()); } return false; }; /** * Sets the Time of the current Date instance. A string "6:15 pm" or config object {hour:18, minute:15} are accepted. * Example

	// Set time to 6:15pm with a String
	Date.today().at("6:15pm");

	// Set time to 6:15pm with a config object
	Date.today().at({hour:18, minute:15});
	
* * @return {Date} date */ $P.at = function (time) { return (typeof time === "string") ? $D.parse(this.toString("d") + " " + time) : this.set(time); }; /** * Creates a new Date() and adds this (Number) to the date based on the preceding date element function (eg. second|minute|hour|day|month|year). * Example

	// Undeclared Numbers must be wrapped with parentheses. Requirment of JavaScript.
	(3).days().fromNow();
	(6).months().fromNow();

	// Declared Number variables do not require parentheses. 
	var n = 6;
	n.months().fromNow();
	
* * @return {Date} A new Date instance */ $N.fromNow = $N.after = function (date) { var c = {}; c[this._dateElement] = this; return ((!date) ? new Date() : date.clone()).add(c); }; /** * Creates a new Date() and subtract this (Number) from the date based on the preceding date element function (eg. second|minute|hour|day|month|year). * Example

	// Undeclared Numbers must be wrapped with parentheses. Requirment of JavaScript.
	(3).days().ago();
	(6).months().ago();

	// Declared Number variables do not require parentheses. 
	var n = 6;
	n.months().ago();
	
* * @return {Date} A new Date instance */ $N.ago = $N.before = function (date) { var c = {}, s = (this._dateElement[this._dateElement.length-1] !== "s") ? this._dateElement + "s" : this._dateElement; c[s] = this * -1; return ((!date) ? new Date() : date.clone()).add(c); }; // Do NOT modify the following string tokens. These tokens are used to build dynamic functions. // All culture-specific strings can be found in the CultureInfo files. var dx = ("sunday monday tuesday wednesday thursday friday saturday").split(/\s/), mx = ("january february march april may june july august september october november december").split(/\s/), px = ("Millisecond Second Minute Hour Day Week Month Year Quarter Weekday").split(/\s/), pxf = ("Milliseconds Seconds Minutes Hours Date Week Month FullYear Quarter").split(/\s/), nth = ("final first second third fourth fifth").split(/\s/), de; /** * Returns an object literal of all the date parts. * Example

	var o = new Date().toObject();
	
	// { year: 2008, month: 4, week: 20, day: 13, hour: 18, minute: 9, second: 32, millisecond: 812 }
	
	// The object properties can be referenced directly from the object.
	
	alert(o.day);  // alerts "13"
	alert(o.year); // alerts "2008"
	
* * @return {Date} An object literal representing the original date object. */ $P.toObject = function () { var o = {}; for (var i = 0; i < px.length; i++) { if (this["get" + pxf[i]]) { o[px[i].toLowerCase()] = this["get" + pxf[i]](); } } return o; }; /** * Returns a date created from an object literal. Ignores the .week property if set in the config. * Example

	var o = new Date().toObject();
	
	return Date.fromObject(o); // will return the same date. 

	var o2 = {month: 1, day: 20, hour: 18}; // birthday party!
	Date.fromObject(o2);
	
* * @return {Date} An object literal representing the original date object. */ $D.fromObject = function(config) { config.week = null; return Date.today().set(config); }; // Create day name functions and abbreviated day name functions (eg. monday(), friday(), fri()). var df = function (n) { return function () { if (this._is) { this._is = false; return this.getDay() === n; } if (this._move) { this._move = null; } if (this._nth !== null) { // If the .second() function was called earlier, remove the _orient // from the date, and then continue. // This is required because 'second' can be used in two different context. // // Example // // Date.today().add(1).second(); // Date.march().second().monday(); // // Things get crazy with the following... // Date.march().add(1).second().second().monday(); // but it works!! // if (this._isSecond) { this.addSeconds(this._orient * -1); } // make sure we reset _isSecond this._isSecond = false; var ntemp = this._nth; this._nth = null; var temp = this.clone().moveToLastDayOfMonth(); this.moveToNthOccurrence(n, ntemp); if (this > temp) { throw new RangeError($D.getDayName(n) + " does not occur " + ntemp + " times in the month of " + $D.getMonthName(temp.getMonth()) + " " + temp.getFullYear() + "."); } return this; } return this.moveToDayOfWeek(n, this._orient); }; }; var sdf = function (n) { return function () { var t = $D.today(), shift = n - t.getDay(); if (n === 0 && Date.CultureInfo.firstDayOfWeek === 1 && t.getDay() !== 0) { shift = shift + 7; } return t.addDays(shift); }; }; // Create month name functions and abbreviated month name functions (eg. january(), march(), mar()). var month_instance_functions = function (n) { return function () { if (this._is) { this._is = false; return this.getMonth() === n; } return this.moveToMonth(n, this._orient); }; }; var month_static_functions = function (n) { return function () { return $D.today().set({ month: n, day: 1 }); }; }; var processTerms = function (names, staticFunc, instanceFunc) { for (var i = 0; i < names.length; i++) { // Create constant static Name variables. $D[names[i].toUpperCase()] = $D[names[i].toUpperCase().substring(0, 3)] = i; // Create Name functions. $D[names[i]] = $D[names[i].substring(0, 3)] = staticFunc(i); // Create Name instance functions. $P[names[i]] = $P[names[i].substring(0, 3)] = instanceFunc(i); } }; processTerms(dx, sdf, df); processTerms(mx, month_static_functions, month_instance_functions); // Create date element functions and plural date element functions used with Date (eg. day(), days(), months()). var ef = function (j) { return function () { // if the .second() function was called earlier, the _orient // has alread been added. Just return this and reset _isSecond. if (this._isSecond) { this._isSecond = false; return this; } if (this._same) { this._same = this._is = false; var o1 = this.toObject(), o2 = (arguments[0] || new Date()).toObject(), v = "", k = j.toLowerCase(); // the substr trick with -1 doesn't work in IE8 or less k = (k[k.length-1] === "s") ? k.substring(0,k.length-1) : k; for (var m = (px.length - 1); m > -1; m--) { v = px[m].toLowerCase(); if (o1[v] !== o2[v]) { return false; } if (k === v) { break; } } return true; } if (j.substring(j.length - 1) !== "s") { j += "s"; } if (this._move) { this._move = null; } return this["add" + j](this._orient); }; }; var nf = function (n) { return function () { this._dateElement = n; return this; }; }; for (var k = 0; k < px.length; k++) { de = px[k].toLowerCase(); if(de !== "weekday") { // Create date element functions and plural date element functions used with Date (eg. day(), days(), months()). $P[de] = $P[de + "s"] = ef(px[k]); // Create date element functions and plural date element functions used with Number (eg. day(), days(), months()). $N[de] = $N[de + "s"] = nf(de + "s"); } } $P._ss = ef("Second"); var nthfn = function (n) { return function (dayOfWeek) { if (this._same) { return this._ss(arguments[0]); } if (dayOfWeek || dayOfWeek === 0) { return this.moveToNthOccurrence(dayOfWeek, n); } this._nth = n; // if the operator is 'second' add the _orient, then deal with it later... if (n === 2 && (dayOfWeek === undefined || dayOfWeek === null)) { this._isSecond = true; return this.addSeconds(this._orient); } return this; }; }; for (var l = 0; l < nth.length; l++) { $P[nth[l]] = (l === 0) ? nthfn(-1) : nthfn(l); } }()); (function () { "use strict"; Date.Parsing = { Exception: function (s) { this.message = "Parse error at '" + s.substring(0, 10) + " ...'"; } }; var $P = Date.Parsing; var dayOffsets = { standard: [0,31,59,90,120,151,181,212,243,273,304,334], leap: [0,31,60,91,121,152,182,213,244,274,305,335] }; $P.isLeapYear = function(year) { return ((year % 4 === 0) && (year % 100 !== 0)) || (year % 400 === 0); }; var utils = { multiReplace : function (str, hash ) { var key; for (key in hash) { if (Object.prototype.hasOwnProperty.call(hash, key)) { var regex; if (typeof hash[key] === "function") { } else { regex = (hash[key] instanceof RegExp) ? hash[key] : new RegExp(hash[key], "g"); } str = str.replace(regex, key); } } return str; }, getDayOfYearFromWeek : function (obj) { var d, jan4, offset; obj.weekDay = (!obj.weekDay && obj.weekDay !== 0) ? 1 : obj.weekDay; d = new Date(obj.year, 0, 4); jan4 = d.getDay() === 0 ? 7 : d.getDay(); // JS is 0 indexed on Sunday. offset = jan4+3; obj.dayOfYear = ((obj.week * 7) + (obj.weekDay === 0 ? 7 : obj.weekDay))-offset; return obj; }, getDayOfYear : function (obj, dayOffset) { if (!obj.dayOfYear) { obj = utils.getDayOfYearFromWeek(obj); } for (var i=0;i <= dayOffset.length;i++) { if (obj.dayOfYear < dayOffset[i] || i === dayOffset.length) { obj.day = obj.day ? obj.day : (obj.dayOfYear - dayOffset[i-1]); break; } else { obj.month = i; } } return obj; }, adjustForTimeZone : function (obj, date) { var offset; if (obj.zone.toUpperCase() === "Z" || (obj.zone_hours === 0 && obj.zone_minutes === 0)) { // it's UTC/GML so work out the current timeszone offset offset = -date.getTimezoneOffset(); } else { offset = (obj.zone_hours*60) + (obj.zone_minutes || 0); if (obj.zone_sign === "+") { offset *= -1; } offset -= date.getTimezoneOffset(); } date.setMinutes(date.getMinutes()+offset); return date; }, setDefaults : function (obj) { obj.year = obj.year || Date.today().getFullYear(); obj.hours = obj.hours || 0; obj.minutes = obj.minutes || 0; obj.seconds = obj.seconds || 0; obj.milliseconds = obj.milliseconds || 0; if (!(!obj.month && (obj.week || obj.dayOfYear))) { // if we have a month, or if we don't but don't have the day calculation data obj.month = obj.month || 0; obj.day = obj.day || 1; } return obj; }, dataNum: function (data, mod, explict, postProcess) { var dataNum = data*1; if (mod) { if (postProcess) { return data ? mod(data)*1 : data; } else { return data ? mod(dataNum) : data; } } else if (!explict){ return data ? dataNum : data; } else { return (data && typeof data !== "undefined") ? dataNum : data; } }, timeDataProcess: function (obj) { var timeObj = {}; for (var x in obj.data) { if (obj.data.hasOwnProperty(x)) { timeObj[x] = obj.ignore[x] ? obj.data[x] : utils.dataNum(obj.data[x], obj.mods[x], obj.explict[x], obj.postProcess[x]); } } if (obj.data.secmins) { obj.data.secmins = obj.data.secmins.replace(",", ".") * 60; if (!timeObj.minutes) { timeObj.minutes = obj.data.secmins; } else if (!timeObj.seconds) { timeObj.seconds = obj.data.secmins; } delete obj.secmins; } return timeObj; }, buildTimeObjectFromData: function (data) { var time = utils.timeDataProcess({ data: { year : data[1], month : data[5], day : data[7], week : data[8], dayOfYear : data[10], hours : data[15], zone_hours : data[23], zone_minutes : data[24], zone : data[21], zone_sign : data[22], weekDay : data[9], minutes: data[16], seconds: data[19], milliseconds: data[20], secmins: data[18] }, mods: { month: function(data) { return data-1; }, weekDay: function (data) { data = Math.abs(data); return (data === 7 ? 0 : data); }, minutes: function (data) { return data.replace(":",""); }, seconds: function (data) { return Math.floor( (data.replace(":","").replace(",","."))*1 ); }, milliseconds: function (data) { return (data.replace(",",".")*1000); } }, postProcess: { minutes: true, seconds: true, milliseconds: true }, explict: { zone_hours: true, zone_minutes: true }, ignore: { zone: true, zone_sign: true, secmins: true } }); return time; }, addToHash: function (hash, keys, data) { keys = keys; data = data; var len = keys.length; for (var i = 0; i < len; i++) { hash[keys[i]] = data[i]; } return hash; }, combineRegex: function (r1, r2) { return new RegExp("(("+r1.source+")\\s("+r2.source+"))"); }, getDateNthString: function(add, last, inc){ if (add) { return Date.today().addDays(inc).toString("d"); } else if (last) { return Date.today().last()[inc]().toString("d"); } }, buildRegexData: function (array) { var arr = []; var len = array.length; for (var i=0; i < len; i++) { if (Object.prototype.toString.call(array[i]) === '[object Array]') { // oldIE compat version of Array.isArray arr.push(this.combineRegex(array[i][0], array[i][1])); } else { arr.push(array[i]); } } return arr; } }; $P.processTimeObject = function (obj) { var date, dayOffset; utils.setDefaults(obj); dayOffset = ($P.isLeapYear(obj.year)) ? dayOffsets.leap : dayOffsets.standard; if (!obj.month && (obj.week || obj.dayOfYear)) { utils.getDayOfYear(obj, dayOffset); } else { obj.dayOfYear = dayOffset[obj.month] + obj.day; } date = new Date(obj.year, obj.month, obj.day, obj.hours, obj.minutes, obj.seconds, obj.milliseconds); if (obj.zone) { utils.adjustForTimeZone(obj, date); // adjust (and calculate) for timezone } return date; }; $P.ISO = { regex : /^([\+-]?\d{4}(?!\d{2}\b))((-?)((0[1-9]|1[0-2])(\3([12]\d|0[1-9]|3[01]))?|W([0-4]\d|5[0-3])(-?[1-7])?|(00[1-9]|0[1-9]\d|[12]\d{2}|3([0-5]\d|6[1-6])))([T\s]((([01]\d|2[0-4])((:?)[0-5]\d)?|24\:?00)([\.,]\d+(?!:))?)?(\17[0-5]\d([\.,]\d+)?)?\s?([zZ]|([\+-])([01]\d|2[0-3]):?([0-5]\d)?)?)?)?$/, parse : function (s) { var time, data = s.match(this.regex); if (!data || !data.length) { return null; } time = utils.buildTimeObjectFromData(data); if (!time.year || (!time.year && (!time.month && !time.day) && (!time.week && !time.dayOfYear)) ) { return null; } return $P.processTimeObject(time); } }; $P.Numeric = { isNumeric: function (e){return!isNaN(parseFloat(e))&&isFinite(e);}, regex: /\b([0-1]?[0-9])([0-3]?[0-9])([0-2]?[0-9]?[0-9][0-9])\b/i, parse: function (s) { var data, i, time = {}, order = Date.CultureInfo.dateElementOrder.split(""); if (!(this.isNumeric(s)) || // if it's non-numeric OR (s[0] === "+" && s[0] === "-")) { // It's an arithmatic string (eg +/-1000) return null; } if (s.length < 5 && s.indexOf(".") < 0 && s.indexOf("/") < 0) { // assume it's just a year. time.year = s; return $P.processTimeObject(time); } data = s.match(this.regex); if (!data || !data.length) { return null; } for (i=0; i < order.length; i++) { switch(order[i]) { case "d": time.day = data[i+1]; break; case "m": time.month = (data[i+1]-1); break; case "y": time.year = data[i+1]; break; } } return $P.processTimeObject(time); } }; $P.Normalizer = { regexData: function () { var $R = Date.CultureInfo.regexPatterns; return utils.buildRegexData([ $R.tomorrow, $R.yesterday, [$R.past, $R.mon], [$R.past, $R.tue], [$R.past, $R.wed], [$R.past, $R.thu], [$R.past, $R.fri], [$R.past, $R.sat], [$R.past, $R.sun] ]); }, basicReplaceHash : function() { var $R = Date.CultureInfo.regexPatterns; return { "January": $R.jan.source, "February": $R.feb, "March": $R.mar, "April": $R.apr, "May": $R.may, "June": $R.jun, "July": $R.jul, "August": $R.aug, "September": $R.sep, "October": $R.oct, "November": $R.nov, "December": $R.dec, "": /\bat\b/gi, " ": /\s{2,}/, "am": $R.inTheMorning, "9am": $R.thisMorning, "pm": $R.inTheEvening, "7pm":$R.thisEvening }; }, keys : function(){ return [ utils.getDateNthString(true, false, 1), // tomorrow utils.getDateNthString(true, false, -1), // yesterday utils.getDateNthString(false, true, "monday"), //last mon utils.getDateNthString(false, true, "tuesday"), //last tues utils.getDateNthString(false, true, "wednesday"), //last wed utils.getDateNthString(false, true, "thursday"), //last thurs utils.getDateNthString(false, true, "friday"), //last fri utils.getDateNthString(false, true, "saturday"), //last sat utils.getDateNthString(false, true, "sunday") //last sun ]; }, buildRegexFunctions: function () { var $R = Date.CultureInfo.regexPatterns; var __ = Date.i18n.__; var tomorrowRE = new RegExp("(\\b\\d\\d?("+__("AM")+"|"+__("PM")+")? )("+$R.tomorrow.source.slice(1)+")", "i"); // adapted tomorrow regex for AM PM relative dates var todayRE = new RegExp($R.today.source + "(?!\\s*([+-]))\\b"); // today, but excludes the math operators (eg "today + 2h") this.replaceFuncs = [ [todayRE, function (full) { return (full.length > 1) ? Date.today().toString("d") : full; }], [tomorrowRE, function(full, m1) { var t = Date.today().addDays(1).toString("d"); return (t + " " + m1); }], [$R.amThisMorning, function(str, am){return am;}], [$R.pmThisEvening, function(str, pm){return pm;}] ]; }, buildReplaceData: function () { this.buildRegexFunctions(); this.replaceHash = utils.addToHash(this.basicReplaceHash(), this.keys(), this.regexData()); }, stringReplaceFuncs: function (s) { for (var i=0; i < this.replaceFuncs.length; i++) { s = s.replace(this.replaceFuncs[i][0], this.replaceFuncs[i][1]); } return s; }, parse: function (s) { s = this.stringReplaceFuncs(s); s = utils.multiReplace(s, this.replaceHash); try { var n = s.split(/([\s\-\.\,\/\x27]+)/); if (n.length === 3 && $P.Numeric.isNumeric(n[0]) && $P.Numeric.isNumeric(n[2]) && (n[2].length >= 4)) { // ok, so we're dealing with x/year. But that's not a full date. // This fixes wonky dateElementOrder parsing when set to dmy order. if (Date.CultureInfo.dateElementOrder[0] === "d") { s = "1/" + n[0] + "/" + n[2]; // set to 1st of month and normalize the seperator } } } catch (e) {} return s; } }; $P.Normalizer.buildReplaceData(); }()); (function () { var $P = Date.Parsing; var _ = $P.Operators = { // // Tokenizers // rtoken: function (r) { // regex token return function (s) { var mx = s.match(r); if (mx) { return ([ mx[0], s.substring(mx[0].length) ]); } else { throw new $P.Exception(s); } }; }, token: function () { // whitespace-eating token return function (s) { return _.rtoken(new RegExp("^\\s*" + s + "\\s*"))(s); }; }, stoken: function (s) { // string token return _.rtoken(new RegExp("^" + s)); }, // Atomic Operators until: function (p) { return function (s) { var qx = [], rx = null; while (s.length) { try { rx = p.call(this, s); } catch (e) { qx.push(rx[0]); s = rx[1]; continue; } break; } return [ qx, s ]; }; }, many: function (p) { return function (s) { var rx = [], r = null; while (s.length) { try { r = p.call(this, s); } catch (e) { return [ rx, s ]; } rx.push(r[0]); s = r[1]; } return [ rx, s ]; }; }, // generator operators -- see below optional: function (p) { return function (s) { var r = null; try { r = p.call(this, s); } catch (e) { return [ null, s ]; } return [ r[0], r[1] ]; }; }, not: function (p) { return function (s) { try { p.call(this, s); } catch (e) { return [null, s]; } throw new $P.Exception(s); }; }, ignore: function (p) { return p ? function (s) { var r = null; r = p.call(this, s); return [null, r[1]]; } : null; }, product: function () { var px = arguments[0], qx = Array.prototype.slice.call(arguments, 1), rx = []; for (var i = 0 ; i < px.length ; i++) { rx.push(_.each(px[i], qx)); } return rx; }, cache: function (rule) { var cache = {}, cache_length = 0, cache_keys = [], CACHE_MAX = Date.Config.CACHE_MAX || 100000, r = null; var cacheCheck = function () { if (cache_length === CACHE_MAX) { // kill several keys, don't want to have to do this all the time... for (var i=0; i < 10; i++) { var key = cache_keys.shift(); if (key) { delete cache[key]; cache_length--; } } } }; return function (s) { cacheCheck(); try { r = cache[s] = (cache[s] || rule.call(this, s)); } catch (e) { r = cache[s] = e; } cache_length++; cache_keys.push(s); if (r instanceof $P.Exception) { throw r; } else { return r; } }; }, // vector operators -- see below any: function () { var px = arguments; return function (s) { var r = null; for (var i = 0; i < px.length; i++) { if (px[i] == null) { continue; } try { r = (px[i].call(this, s)); } catch (e) { r = null; } if (r) { return r; } } throw new $P.Exception(s); }; }, each: function () { var px = arguments; return function (s) { var rx = [], r = null; for (var i = 0; i < px.length ; i++) { if (px[i] == null) { continue; } try { r = (px[i].call(this, s)); } catch (e) { throw new $P.Exception(s); } rx.push(r[0]); s = r[1]; } return [ rx, s]; }; }, all: function () { var px = arguments, _ = _; return _.each(_.optional(px)); }, // delimited operators sequence: function (px, d, c) { d = d || _.rtoken(/^\s*/); c = c || null; if (px.length === 1) { return px[0]; } return function (s) { var r = null, q = null; var rx = []; for (var i = 0; i < px.length ; i++) { try { r = px[i].call(this, s); } catch (e) { break; } rx.push(r[0]); try { q = d.call(this, r[1]); } catch (ex) { q = null; break; } s = q[1]; } if (!r) { throw new $P.Exception(s); } if (q) { throw new $P.Exception(q[1]); } if (c) { try { r = c.call(this, r[1]); } catch (ey) { throw new $P.Exception(r[1]); } } return [ rx, (r?r[1]:s) ]; }; }, // // Composite Operators // between: function (d1, p, d2) { d2 = d2 || d1; var _fn = _.each(_.ignore(d1), p, _.ignore(d2)); return function (s) { var rx = _fn.call(this, s); return [[rx[0][0], r[0][2]], rx[1]]; }; }, list: function (p, d, c) { d = d || _.rtoken(/^\s*/); c = c || null; return (p instanceof Array ? _.each(_.product(p.slice(0, -1), _.ignore(d)), p.slice(-1), _.ignore(c)) : _.each(_.many(_.each(p, _.ignore(d))), px, _.ignore(c))); }, set: function (px, d, c) { d = d || _.rtoken(/^\s*/); c = c || null; return function (s) { // r is the current match, best the current 'best' match // which means it parsed the most amount of input var r = null, p = null, q = null, rx = null, best = [[], s], last = false; // go through the rules in the given set for (var i = 0; i < px.length ; i++) { // last is a flag indicating whether this must be the last element // if there is only 1 element, then it MUST be the last one q = null; p = null; r = null; last = (px.length === 1); // first, we try simply to match the current pattern // if not, try the next pattern try { r = px[i].call(this, s); } catch (e) { continue; } // since we are matching against a set of elements, the first // thing to do is to add r[0] to matched elements rx = [[r[0]], r[1]]; // if we matched and there is still input to parse and // we don't already know this is the last element, // we're going to next check for the delimiter ... // if there's none, or if there's no input left to parse // than this must be the last element after all ... if (r[1].length > 0 && ! last) { try { q = d.call(this, r[1]); } catch (ex) { last = true; } } else { last = true; } // if we parsed the delimiter and now there's no more input, // that means we shouldn't have parsed the delimiter at all // so don't update r and mark this as the last element ... if (!last && q[1].length === 0) { last = true; } // so, if this isn't the last element, we're going to see if // we can get any more matches from the remaining (unmatched) // elements ... if (!last) { // build a list of the remaining rules we can match against, // i.e., all but the one we just matched against var qx = []; for (var j = 0; j < px.length ; j++) { if (i !== j) { qx.push(px[j]); } } // now invoke recursively set with the remaining input // note that we don't include the closing delimiter ... // we'll check for that ourselves at the end p = _.set(qx, d).call(this, q[1]); // if we got a non-empty set as a result ... // (otw rx already contains everything we want to match) if (p[0].length > 0) { // update current result, which is stored in rx ... // basically, pick up the remaining text from p[1] // and concat the result from p[0] so that we don't // get endless nesting ... rx[0] = rx[0].concat(p[0]); rx[1] = p[1]; } } // at this point, rx either contains the last matched element // or the entire matched set that starts with this element. // now we just check to see if this variation is better than // our best so far, in terms of how much of the input is parsed if (rx[1].length < best[1].length) { best = rx; } // if we've parsed all the input, then we're finished if (best[1].length === 0) { break; } } // so now we've either gone through all the patterns trying them // as the initial match; or we found one that parsed the entire // input string ... // if best has no matches, just return empty set ... if (best[0].length === 0) { return best; } // if a closing delimiter is provided, then we have to check it also if (c) { // we try this even if there is no remaining input because the pattern // may well be optional or match empty input ... try { q = c.call(this, best[1]); } catch (ey) { throw new $P.Exception(best[1]); } // it parsed ... be sure to update the best match remaining input best[1] = q[1]; } // if we're here, either there was no closing delimiter or we parsed it // so now we have the best match; just return it! return best; }; }, forward: function (gr, fname) { return function (s) { return gr[fname].call(this, s); }; }, // // Translation Operators // replace: function (rule, repl) { return function (s) { var r = rule.call(this, s); return [repl, r[1]]; }; }, process: function (rule, fn) { return function (s) { var r = rule.call(this, s); return [fn.call(this, r[0]), r[1]]; }; }, min: function (min, rule) { return function (s) { var rx = rule.call(this, s); if (rx[0].length < min) { throw new $P.Exception(s); } return rx; }; } }; // Generator Operators And Vector Operators // Generators are operators that have a signature of F(R) => R, // taking a given rule and returning another rule, such as // ignore, which parses a given rule and throws away the result. // Vector operators are those that have a signature of F(R1,R2,...) => R, // take a list of rules and returning a new rule, such as each. // Generator operators are converted (via the following _generator // function) into functions that can also take a list or array of rules // and return an array of new rules as though the function had been // called on each rule in turn (which is what actually happens). // This allows generators to be used with vector operators more easily. // Example: // each(ignore(foo, bar)) instead of each(ignore(foo), ignore(bar)) // This also turns generators into vector operators, which allows // constructs like: // not(cache(foo, bar)) var _generator = function (op) { function gen() { var args = null, rx = [], px, i; if (arguments.length > 1) { args = Array.prototype.slice.call(arguments); } else if (arguments[0] instanceof Array) { args = arguments[0]; } if (args) { px = args.shift(); if (px.length > 0) { args.unshift(px[i]); rx.push(op.apply(null, args)); args.shift(); return rx; } } else { return op.apply(null, arguments); } } return gen; }; var gx = "optional not ignore cache".split(/\s/); for (var i = 0 ; i < gx.length ; i++) { _[gx[i]] = _generator(_[gx[i]]); } var _vector = function (op) { return function () { if (arguments[0] instanceof Array) { return op.apply(null, arguments[0]); } else { return op.apply(null, arguments); } }; }; var vx = "each any all".split(/\s/); for (var j = 0 ; j < vx.length ; j++) { _[vx[j]] = _vector(_[vx[j]]); } }()); (function () { var $D = Date; var flattenAndCompact = function (ax) { var rx = []; for (var i = 0; i < ax.length; i++) { if (ax[i] instanceof Array) { rx = rx.concat(flattenAndCompact(ax[i])); } else { if (ax[i]) { rx.push(ax[i]); } } } return rx; }; var parseMeridian = function () { if (this.meridian && (this.hour || this.hour === 0)) { if (this.meridian === "a" && this.hour > 11 && Date.Config.strict24hr){ throw "Invalid hour and meridian combination"; } else if (this.meridian === "p" && this.hour < 12 && Date.Config.strict24hr){ throw "Invalid hour and meridian combination"; } else if (this.meridian === "p" && this.hour < 12) { this.hour = this.hour + 12; } else if (this.meridian === "a" && this.hour === 12) { this.hour = 0; } } }; var setDefaults = function () { var now = new Date(); if ((this.hour || this.minute) && (!this.month && !this.year && !this.day)) { this.day = now.getDate(); } if (!this.year) { this.year = now.getFullYear(); } if (!this.month && this.month !== 0) { this.month = now.getMonth(); } if (!this.day) { this.day = 1; } if (!this.hour) { this.hour = 0; } if (!this.minute) { this.minute = 0; } if (!this.second) { this.second = 0; } if (!this.millisecond) { this.millisecond = 0; } }; var finishUtils = { getToday: function () { if (this.now || "hour minute second".indexOf(this.unit) !== -1) { return new Date(); } else { return $D.today(); } }, setDaysFromWeekday: function (today, orient){ var gap; orient = orient || 1; this.unit = "day"; gap = ($D.getDayNumberFromName(this.weekday) - today.getDay()); this.days = gap ? ((gap + (orient * 7)) % 7) : (orient * 7); return this; }, setMonthsFromMonth: function (today, orient) { var gap; orient = orient || 1; this.unit = "month"; gap = (this.month - today.getMonth()); this.months = gap ? ((gap + (orient * 12)) % 12) : (orient * 12); this.month = null; return this; }, setDMYFromWeekday: function () { var d = Date[this.weekday](); this.day = d.getDate(); if (!this.month) { this.month = d.getMonth(); } this.year = d.getFullYear(); return this; }, setUnitValue: function (orient) { if (!this.value && this.operator && this.operator !== null && this[this.unit + "s"] && this[this.unit + "s"] !== null) { this[this.unit + "s"] = this[this.unit + "s"] + ((this.operator === "add") ? 1 : -1) + (this.value||0) * orient; } else if (this[this.unit + "s"] == null || this.operator != null) { if (!this.value) { this.value = 1; } this[this.unit + "s"] = this.value * orient; } }, generateDateFromWeeks: function () { var weekday = (this.weekday !== undefined) ? this.weekday : "today"; var d = Date[weekday]().addWeeks(this.weeks); if (this.now) { d.setTimeToNow(); } return d; } }; $D.Translator = { hour: function (s) { return function () { this.hour = Number(s); }; }, minute: function (s) { return function () { this.minute = Number(s); }; }, second: function (s) { return function () { this.second = Number(s); }; }, /* for ss.s format */ secondAndMillisecond: function (s) { return function () { var mx = s.match(/^([0-5][0-9])\.([0-9]{1,3})/); this.second = Number(mx[1]); this.millisecond = Number(mx[2]); }; }, meridian: function (s) { return function () { this.meridian = s.slice(0, 1).toLowerCase(); }; }, timezone: function (s) { return function () { var n = s.replace(/[^\d\+\-]/g, ""); if (n.length) { this.timezoneOffset = Number(n); } else { this.timezone = s.toLowerCase(); } }; }, day: function (x) { var s = x[0]; return function () { this.day = Number(s.match(/\d+/)[0]); if (this.day < 1) { throw "invalid day"; } }; }, month: function (s) { return function () { this.month = (s.length === 3) ? "jan feb mar apr may jun jul aug sep oct nov dec".indexOf(s)/4 : Number(s) - 1; if (this.month < 0) { throw "invalid month"; } }; }, year: function (s) { return function () { var n = Number(s); this.year = ((s.length > 2) ? n : (n + (((n + 2000) < Date.CultureInfo.twoDigitYearMax) ? 2000 : 1900))); }; }, rday: function (s) { return function () { switch (s) { case "yesterday": this.days = -1; break; case "tomorrow": this.days = 1; break; case "today": this.days = 0; break; case "now": this.days = 0; this.now = true; break; } }; }, finishExact: function (x) { var d; x = (x instanceof Array) ? x : [x]; for (var i = 0 ; i < x.length ; i++) { if (x[i]) { x[i].call(this); } } setDefaults.call(this); parseMeridian.call(this); if (this.day > $D.getDaysInMonth(this.year, this.month)) { throw new RangeError(this.day + " is not a valid value for days."); } d = new Date(this.year, this.month, this.day, this.hour, this.minute, this.second, this.millisecond); if (this.year < 100) { d.setFullYear(this.year); // means years less that 100 are process correctly. JS will parse it otherwise as 1900-1999. } if (this.timezone) { d.set({ timezone: this.timezone }); } else if (this.timezoneOffset) { d.set({ timezoneOffset: this.timezoneOffset }); } return d; }, finish: function (x) { var today, expression, orient, temp; x = (x instanceof Array) ? flattenAndCompact(x) : [ x ]; if (x.length === 0) { return null; } for (var i = 0 ; i < x.length ; i++) { if (typeof x[i] === "function") { x[i].call(this); } } if (this.now && !this.unit && !this.operator) { return new Date(); } else { today = finishUtils.getToday.call(this); } expression = !!(this.days && this.days !== null || this.orient || this.operator); orient = ((this.orient === "past" || this.operator === "subtract") ? -1 : 1); if (this.month && this.unit === "week") { this.value = this.month + 1; delete this.month; delete this.day; } if ((this.month || this.month === 0) && "year day hour minute second".indexOf(this.unit) !== -1) { if (!this.value) { this.value = this.month + 1; } this.month = null; expression = true; } if (!expression && this.weekday && !this.day && !this.days) { finishUtils.setDMYFromWeekday.call(this); } if (expression && this.weekday && this.unit !== "month" && this.unit !== "week") { finishUtils.setDaysFromWeekday.call(this, today, orient); } if (this.weekday && this.unit !== "week" && !this.day && !this.days) { temp = Date[this.weekday](); this.day = temp.getDate(); if (temp.getMonth() !== today.getMonth()) { this.month = temp.getMonth(); } } if (this.month && this.unit === "day" && this.operator) { if (!this.value) { this.value = (this.month + 1); } this.month = null; } if (this.value != null && this.month != null && this.year != null) { this.day = this.value * 1; } if (this.month && !this.day && this.value) { today.set({ day: this.value * 1 }); if (!expression) { this.day = this.value * 1; } } if (!this.month && this.value && this.unit === "month" && !this.now) { this.month = this.value; expression = true; } if (expression && (this.month || this.month === 0) && this.unit !== "year") { finishUtils.setMonthsFromMonth.call(this, today, orient); } if (!this.unit) { this.unit = "day"; } finishUtils.setUnitValue.call(this, orient); parseMeridian.call(this); if ((this.month || this.month === 0) && !this.day) { this.day = 1; } if (!this.orient && !this.operator && this.unit === "week" && this.value && !this.day && !this.month) { return Date.today().setWeek(this.value); } if (this.unit === "week" && this.weeks && !this.day && !this.month) { return finishUtils.generateDateFromWeeks.call(this); } if (expression && this.timezone && this.day && this.days) { this.day = this.days; } if (expression){ today.add(this); } else { today.set(this); } if (this.timezone) { this.timezone = this.timezone.toUpperCase(); var offset = $D.getTimezoneOffset(this.timezone); var timezone; if (today.hasDaylightSavingTime()) { // lets check that we're being sane with timezone setting timezone = $D.getTimezoneAbbreviation(offset, today.isDaylightSavingTime()); if (timezone !== this.timezone) { // bugger, we're in a place where things like EST vs EDT matters. if (today.isDaylightSavingTime()) { today.addHours(-1); } else { today.addHours(1); } } } today.setTimezoneOffset(offset); } return today; } }; }()); (function () { var $D = Date; $D.Grammar = {}; var _ = $D.Parsing.Operators, g = $D.Grammar, t = $D.Translator, _fn; // Allow rolling up into general purpose rules _fn = function () { return _.each(_.any.apply(null, arguments), _.not(g.ctoken2("timeContext"))); }; g.datePartDelimiter = _.rtoken(/^([\s\-\.\,\/\x27]+)/); g.timePartDelimiter = _.stoken(":"); g.whiteSpace = _.rtoken(/^\s*/); g.generalDelimiter = _.rtoken(/^(([\s\,]|at|@|on)+)/); var _C = {}; g.ctoken = function (keys) { var fn = _C[keys]; if (! fn) { var c = Date.CultureInfo.regexPatterns; var kx = keys.split(/\s+/), px = []; for (var i = 0; i < kx.length ; i++) { px.push(_.replace(_.rtoken(c[kx[i]]), kx[i])); } fn = _C[keys] = _.any.apply(null, px); } return fn; }; g.ctoken2 = function (key) { return _.rtoken(Date.CultureInfo.regexPatterns[key]); }; var cacheProcessRtoken = function (key, token, type, eachToken) { if (eachToken) { g[key] = _.cache(_.process(_.each(_.rtoken(token),_.optional(g.ctoken2(eachToken))), type)); } else { g[key] = _.cache(_.process(_.rtoken(token), type)); } }; var cacheProcessCtoken = function (token, type) { return _.cache(_.process(g.ctoken2(token), type)); }; var _F = {}; //function cache var _get = function (f) { _F[f] = (_F[f] || g.format(f)[0]); return _F[f]; }; g.allformats = function (fx) { var rx = []; if (fx instanceof Array) { for (var i = 0; i < fx.length; i++) { rx.push(_get(fx[i])); } } else { rx.push(_get(fx)); } return rx; }; g.formats = function (fx) { if (fx instanceof Array) { var rx = []; for (var i = 0 ; i < fx.length ; i++) { rx.push(_get(fx[i])); } return _.any.apply(null, rx); } else { return _get(fx); } }; var grammarFormats = { timeFormats: function(){ var i, RTokenKeys = [ "h", "hh", "H", "HH", "m", "mm", "s", "ss", "ss.s", "z", "zz" ], RToken = [ /^(0[0-9]|1[0-2]|[1-9])/, /^(0[0-9]|1[0-2])/, /^([0-1][0-9]|2[0-3]|[0-9])/, /^([0-1][0-9]|2[0-3])/, /^([0-5][0-9]|[0-9])/, /^[0-5][0-9]/, /^([0-5][0-9]|[0-9])/, /^[0-5][0-9]/, /^[0-5][0-9]\.[0-9]{1,3}/, /^((\+|\-)\s*\d\d\d\d)|((\+|\-)\d\d\:?\d\d)/, /^((\+|\-)\s*\d\d\d\d)|((\+|\-)\d\d\:?\d\d)/ ], tokens = [ t.hour, t.hour, t.hour, t.hour, t.minute, t.minute, t.second, t.second, t.secondAndMillisecond, t.timezone, t.timezone ]; for (i=0; i < RTokenKeys.length; i++) { cacheProcessRtoken(RTokenKeys[i], RToken[i], tokens[i]); } g.hms = _.cache(_.sequence([g.H, g.m, g.s], g.timePartDelimiter)); g.t = cacheProcessCtoken("shortMeridian", t.meridian); g.tt = cacheProcessCtoken("longMeridian", t.meridian); g.zzz = cacheProcessCtoken("timezone", t.timezone); g.timeSuffix = _.each(_.ignore(g.whiteSpace), _.set([ g.tt, g.zzz ])); g.time = _.each(_.optional(_.ignore(_.stoken("T"))), g.hms, g.timeSuffix); }, dateFormats: function () { // pre-loaded rules for different date part order preferences var _setfn = function () { return _.set(arguments, g.datePartDelimiter); }; var i, RTokenKeys = [ "d", "dd", "M", "MM", "y", "yy", "yyy", "yyyy" ], RToken = [ /^([0-2]\d|3[0-1]|\d)/, /^([0-2]\d|3[0-1])/, /^(1[0-2]|0\d|\d)/, /^(1[0-2]|0\d)/, /^(\d+)/, /^(\d\d)/, /^(\d\d?\d?\d?)/, /^(\d\d\d\d)/ ], tokens = [ t.day, t.day, t.month, t.month, t.year, t.year, t.year, t.year ], eachToken = [ "ordinalSuffix", "ordinalSuffix" ]; for (i=0; i < RTokenKeys.length; i++) { cacheProcessRtoken(RTokenKeys[i], RToken[i], tokens[i], eachToken[i]); } g.MMM = g.MMMM = _.cache(_.process(g.ctoken("jan feb mar apr may jun jul aug sep oct nov dec"), t.month)); g.ddd = g.dddd = _.cache(_.process(g.ctoken("sun mon tue wed thu fri sat"), function (s) { return function () { this.weekday = s; }; } )); g.day = _fn(g.d, g.dd); g.month = _fn(g.M, g.MMM); g.year = _fn(g.yyyy, g.yy); g.mdy = _setfn(g.ddd, g.month, g.day, g.year); g.ymd = _setfn(g.ddd, g.year, g.month, g.day); g.dmy = _setfn(g.ddd, g.day, g.month, g.year); g.date = function (s) { return ((g[Date.CultureInfo.dateElementOrder] || g.mdy).call(this, s)); }; }, relative: function () { // relative date / time expressions g.orientation = _.process(g.ctoken("past future"), function (s) { return function () { this.orient = s; }; } ); g.operator = _.process(g.ctoken("add subtract"), function (s) { return function () { this.operator = s; }; } ); g.rday = _.process(g.ctoken("yesterday tomorrow today now"), t.rday); g.unit = _.process(g.ctoken("second minute hour day week month year"), function (s) { return function () { this.unit = s; }; } ); } }; g.buildGrammarFormats = function () { // these need to be rebuilt every time the language changes. _C = {}; grammarFormats.timeFormats(); grammarFormats.dateFormats(); grammarFormats.relative(); g.value = _.process(_.rtoken(/^([-+]?\d+)?(st|nd|rd|th)?/), function (s) { return function () { this.value = s.replace(/\D/g, ""); }; } ); g.expression = _.set([g.rday, g.operator, g.value, g.unit, g.orientation, g.ddd, g.MMM ]); g.format = _.process(_.many( _.any( // translate format specifiers into grammar rules _.process( _.rtoken(/^(dd?d?d?(?!e)|MM?M?M?|yy?y?y?|hh?|HH?|mm?|ss?|tt?|zz?z?)/), function (fmt) { if (g[fmt]) { return g[fmt]; } else { throw $D.Parsing.Exception(fmt); } } ), // translate separator tokens into token rules _.process(_.rtoken(/^[^dMyhHmstz]+/), // all legal separators function (s) { return _.ignore(_.stoken(s)); } ) ) ), // construct the parser ... function (rules) { return _.process(_.each.apply(null, rules), t.finishExact); } ); // starting rule for general purpose grammar g._start = _.process(_.set([ g.date, g.time, g.expression ], g.generalDelimiter, g.whiteSpace), t.finish); }; g.buildGrammarFormats(); // parsing date format specifiers - ex: "h:m:s tt" // this little guy will generate a custom parser based // on the format string, ex: g.format("h:m:s tt") // check for these formats first g._formats = g.formats([ "\"yyyy-MM-ddTHH:mm:ssZ\"", "yyyy-MM-ddTHH:mm:ss.sz", "yyyy-MM-ddTHH:mm:ssZ", "yyyy-MM-ddTHH:mm:ssz", "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-ddTHH:mmZ", "yyyy-MM-ddTHH:mmz", "yyyy-MM-ddTHH:mm", "ddd, MMM dd, yyyy H:mm:ss tt", "ddd MMM d yyyy HH:mm:ss zzz", "MMddyyyy", "ddMMyyyy", "Mddyyyy", "ddMyyyy", "Mdyyyy", "dMyyyy", "yyyy", "Mdyy", "dMyy", "d" ]); // real starting rule: tries selected formats first, // then general purpose rule g.start = function (s) { try { var r = g._formats.call({}, s); if (r[1].length === 0) { return r; } } catch (e) {} return g._start.call({}, s); }; }()); (function () { var $D = Date; /** * @desc Converts the specified string value into its JavaScript Date equivalent using CultureInfo specific format information. * * Example

	///////////
	// Dates //
	///////////

	// 15-Oct-2004
	var d1 = Date.parse("10/15/2004");

	// 15-Oct-2004
	var d1 = Date.parse("15-Oct-2004");

	// 15-Oct-2004
	var d1 = Date.parse("2004.10.15");

	//Fri Oct 15, 2004
	var d1 = Date.parse("Fri Oct 15, 2004");

	///////////
	// Times //
	///////////

	// Today at 10 PM.
	var d1 = Date.parse("10 PM");

	// Today at 10:30 PM.
	var d1 = Date.parse("10:30 P.M.");

	// Today at 6 AM.
	var d1 = Date.parse("06am");

	/////////////////////
	// Dates and Times //
	/////////////////////

	// 8-July-2004 @ 10:30 PM
	var d1 = Date.parse("July 8th, 2004, 10:30 PM");

	// 1-July-2004 @ 10:30 PM
	var d1 = Date.parse("2004-07-01T22:30:00");

	////////////////////
	// Relative Dates //
	////////////////////

	// Returns today's date. The string "today" is culture specific.
	var d1 = Date.parse("today");

	// Returns yesterday's date. The string "yesterday" is culture specific.
	var d1 = Date.parse("yesterday");

	// Returns the date of the next thursday.
	var d1 = Date.parse("Next thursday");

	// Returns the date of the most previous monday.
	var d1 = Date.parse("last monday");

	// Returns today's day + one year.
	var d1 = Date.parse("next year");

	///////////////
	// Date Math //
	///////////////

	// Today + 2 days
	var d1 = Date.parse("t+2");

	// Today + 2 days
	var d1 = Date.parse("today + 2 days");

	// Today + 3 months
	var d1 = Date.parse("t+3m");

	// Today - 1 year
	var d1 = Date.parse("today - 1 year");

	// Today - 1 year
	var d1 = Date.parse("t-1y"); 


	/////////////////////////////
	// Partial Dates and Times //
	/////////////////////////////

	// July 15th of this year.
	var d1 = Date.parse("July 15");

	// 15th day of current day and year.
	var d1 = Date.parse("15");

	// July 1st of current year at 10pm.
	var d1 = Date.parse("7/1 10pm");
	
* * @param {String} The string value to convert into a Date object [Required] * @return {Date} A Date object or null if the string cannot be converted into a Date. */ var parseUtils = { removeOrds: function (s) { ords = s.match(/\b(\d+)(?:st|nd|rd|th)\b/); // find ordinal matches s = ((ords && ords.length === 2) ? s.replace(ords[0], ords[1]) : s); return s; }, grammarParser: function (s) { var r = null; try { r = $D.Grammar.start.call({}, s.replace(/^\s*(\S*(\s+\S+)*)\s*$/, "$1")); } catch (e) { return null; } return ((r[1].length === 0) ? r[0] : null); }, nativeFallback: function(s) { var t; try { // ok we haven't parsed it, last ditch attempt with the built-in parser. t = Date._parse(s); return (t || t === 0) ? new Date(t) : null; } catch (e) { return null; } } }; function parse (s) { var d; if (!s) { return null; } if (s instanceof Date) { return s.clone(); } if (s.length >= 4 && s.charAt(0) !== "0" && s.charAt(0) !== "+"&& s.charAt(0) !== "-") { // ie: 2004 will pass, 0800 won't. // Start with specific formats d = $D.Parsing.ISO.parse(s) || $D.Parsing.Numeric.parse(s); } if (d instanceof Date && !isNaN(d.getTime())) { return d; } else { // find ordinal dates (1st, 3rd, 8th, etc and remove them as they cause parsing issues) s = $D.Parsing.Normalizer.parse(parseUtils.removeOrds(s)); d = parseUtils.grammarParser(s); if (d !== null) { return d; } else { return parseUtils.nativeFallback(s); } } } if (!$D._parse) { $D._parse = $D.parse; } $D.parse = parse; Date.getParseFunction = function (fx) { var fns = Date.Grammar.allformats(fx); return function (s) { var r = null; for (var i = 0; i < fns.length; i++) { try { r = fns[i].call({}, s); } catch (e) { continue; } if (r[1].length === 0) { return r[0]; } } return null; }; }; /** * Converts the specified string value into its JavaScript Date equivalent using the specified format {String} or formats {Array} and the CultureInfo specific format information. * The format of the string value must match one of the supplied formats exactly. * * Example

	// 15-Oct-2004
	var d1 = Date.parseExact("10/15/2004", "M/d/yyyy");

	// 15-Oct-2004
	var d1 = Date.parse("15-Oct-2004", "M-ddd-yyyy");

	// 15-Oct-2004
	var d1 = Date.parse("2004.10.15", "yyyy.MM.dd");

	// Multiple formats
	var d1 = Date.parseExact("10/15/2004", ["M/d/yyyy", "MMMM d, yyyy"]);
	
* * @param {String} The string value to convert into a Date object [Required]. * @param {Object} The expected format {String} or an array of expected formats {Array} of the date string [Required]. * @return {Date} A Date object or null if the string cannot be converted into a Date. */ $D.parseExact = function (s, fx) { return $D.getParseFunction(fx)(s); }; }()); (function () { var $D = Date, $P = $D.prototype, // $C = $D.CultureInfo, // not used atm p = function (s, l) { if (!l) { l = 2; } return ("000" + s).slice(l * -1); }; /** * Converts a PHP format string to Java/.NET format string. * A PHP format string can be used with ._format or .format. * A Java/.NET format string can be used with .toString(). * The .parseExact function will only accept a Java/.NET format string * * Example * var f1 = "%m/%d/%y" * var f2 = Date.normalizeFormat(f1); // "MM/dd/yy" * * new Date().format(f1); // "04/13/08" * new Date()._format(f1); // "04/13/08" * new Date().toString(f2); // "04/13/08" * * var date = Date.parseExact("04/13/08", f2); // Sun Apr 13 2008 * * @param {String} A PHP format string consisting of one or more format spcifiers. * @return {String} The PHP format converted to a Java/.NET format string. */ var normalizerSubstitutions = { "d" : "dd", "%d": "dd", "D" : "ddd", "%a": "ddd", "j" : "dddd", "l" : "dddd", "%A": "dddd", "S" : "S", "F" : "MMMM", "%B": "MMMM", "m" : "MM", "%m": "MM", "M" : "MMM", "%b": "MMM", "%h": "MMM", "n" : "M", "Y" : "yyyy", "%Y": "yyyy", "y" : "yy", "%y": "yy", "g" : "h", "%I": "h", "G" : "H", "h" : "hh", "H" : "HH", "%H": "HH", "i" : "mm", "%M": "mm", "s" : "ss", "%S": "ss", "%r": "hh:mm tt", "%R": "H:mm", "%T": "H:mm:ss", "%X": "t", "%x": "d", "%e": "d", "%D": "MM/dd/yy", "%n": "\\n", "%t": "\\t", "e" : "z", "T" : "z", "%z": "z", "%Z": "z", "Z" : "ZZ", "N" : "u", "w" : "u", "%w": "u", "W" : "W", "%V": "W" }; var normalizer = { substitutes: function (m) { return normalizerSubstitutions[m]; }, interpreted: function (m, x) { var y; switch (m) { case "%u": return x.getDay() + 1; case "z": return x.getOrdinalNumber(); case "%j": return p(x.getOrdinalNumber(), 3); case "%U": var d1 = x.clone().set({month: 0, day: 1}).addDays(-1).moveToDayOfWeek(0), d2 = x.clone().addDays(1).moveToDayOfWeek(0, -1); return (d2 < d1) ? "00" : p((d2.getOrdinalNumber() - d1.getOrdinalNumber()) / 7 + 1); case "%W": return p(x.getWeek()); case "t": return $D.getDaysInMonth(x.getFullYear(), x.getMonth()); case "o": case "%G": return x.setWeek(x.getISOWeek()).toString("yyyy"); case "%g": return x._format("%G").slice(-2); case "a": case "%p": return t("tt").toLowerCase(); case "A": return t("tt").toUpperCase(); case "u": return p(x.getMilliseconds(), 3); case "I": return (x.isDaylightSavingTime()) ? 1 : 0; case "O": return x.getUTCOffset(); case "P": y = x.getUTCOffset(); return y.substring(0, y.length - 2) + ":" + y.substring(y.length - 2); case "B": var now = new Date(); return Math.floor(((now.getHours() * 3600) + (now.getMinutes() * 60) + now.getSeconds() + (now.getTimezoneOffset() + 60) * 60) / 86.4); case "c": return x.toISOString().replace(/\"/g, ""); case "U": return $D.strtotime("now"); case "%c": return t("d") + " " + t("t"); case "%C": return Math.floor(x.getFullYear() / 100 + 1); } }, shouldOverrideDefaults: function (m) { switch (m) { case "%e": return true; default: return false; } }, parse: function (m, context) { var formatString, c = context || new Date(); formatString = normalizer.substitutes(m); if (formatString) { return formatString; } formatString = normalizer.interpreted(m, c); if (formatString) { return formatString; } else { return m; } } }; $D.normalizeFormat = function (format, context) { return format.replace(/(%|\\)?.|%%/g, function(t){ return normalizer.parse(t, context); }); }; /** * Format a local Unix timestamp according to locale settings * * Example: * Date.strftime("%m/%d/%y", new Date()); // "04/13/08" * Date.strftime("c", "2008-04-13T17:52:03Z"); // "04/13/08" * * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @param {Number|String} The number representing the number of seconds that have elapsed since January 1, 1970 (local time). * @return {String} A string representation of the current Date object. */ $D.strftime = function (format, time) { var d = Date.parse(time); return d._format(format); }; /** * Parse any textual datetime description into a Unix timestamp. * A Unix timestamp is the number of seconds that have elapsed since January 1, 1970 (midnight UTC/GMT). * * Example: * Date.strtotime("04/13/08"); // 1208044800 * Date.strtotime("1970-01-01T00:00:00Z"); // 0 * * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @param {Object} A string or date object. * @return {String} A string representation of the current Date object. */ $D.strtotime = function (time) { var d = $D.parse(time); return Math.round($D.UTC(d.getUTCFullYear(), d.getUTCMonth(), d.getUTCDate(), d.getUTCHours(), d.getUTCMinutes(), d.getUTCSeconds(), d.getUTCMilliseconds()) / 1000); }; /** * Converts the value of the current Date object to its equivalent string representation using a PHP/Unix style of date format specifiers. * Format Specifiers * Format Description Example * ------ --------------------------------------------------------------------------- ----------------------- * %a abbreviated weekday name according to the current localed "Mon" through "Sun" * %A full weekday name according to the current localed "Sunday" through "Saturday" * %b abbreviated month name according to the current localed "Jan" through "Dec" * %B full month name according to the current locale "January" through "December" * %c preferred date and time representation for the current locale "4/13/2008 12:33 PM" * %C century number (the year divided by 100 and truncated to an integer) "00" to "99" * %d day of the month as a decimal number "01" to "31" * %D same as %m/%d/%y "04/13/08" * %e day of the month as a decimal number, a single digit is preceded by a space "1" to "31" * %g like %G, but without the century "08" * %G The 4-digit year corresponding to the ISO week number (see %V). "2008" * This has the same format and value as %Y, except that if the ISO week number * belongs to the previous or next year, that year is used instead. * %h same as %b "Jan" through "Dec" * %H hour as a decimal number using a 24-hour clock. "00" to "23" * %I hour as a decimal number using a 12-hour clock. "01" to "12" * %j day of the year as a decimal number. "001" to "366" * %m month as a decimal number. "01" to "12" * %M minute as a decimal number. "00" to "59" * %n newline character "\n" * %p either "am" or "pm" according to the given time value, or the "am" or "pm" * corresponding strings for the current locale. * %r time in a.m. and p.m. notation "8:44 PM" * %R time in 24 hour notation "20:44" * %S second as a decimal number "00" to "59" * %t tab character "\t" * %T current time, equal to %H:%M:%S "12:49:11" * %u weekday as a decimal number ["1", "7"], with "1" representing Monday "1" to "7" * %U week number of the current year as a decimal number, starting with the "0" to ("52" or "53") * first Sunday as the first day of the first week * %V The ISO 8601:1988 week number of the current year as a decimal number, "00" to ("52" or "53") * range 01 to 53, where week 1 is the first week that has at least 4 days * in the current year, and with Monday as the first day of the week. * (Use %G or %g for the year component that corresponds to the week number * for the specified timestamp.) * %W week number of the current year as a decimal number, starting with the "00" to ("52" or "53") * first Monday as the first day of the first week * %w day of the week as a decimal, Sunday being "0" "0" to "6" * %x preferred date representation for the current locale without the time "4/13/2008" * %X preferred time representation for the current locale without the date "12:53:05" * %y year as a decimal number without a century "00" "99" * %Y year as a decimal number including the century "2008" * %Z time zone or name or abbreviation "UTC", "EST", "PST" * %z same as %Z * %% a literal "%" characters "%" * d Day of the month, 2 digits with leading zeros "01" to "31" * D A textual representation of a day, three letters "Mon" through "Sun" * j Day of the month without leading zeros "1" to "31" * l A full textual representation of the day of the week (lowercase "L") "Sunday" through "Saturday" * N ISO-8601 numeric representation of the day of the week (added in PHP 5.1.0) "1" (for Monday) through "7" (for Sunday) * S English ordinal suffix for the day of the month, 2 characters "st", "nd", "rd" or "th". Works well with j * w Numeric representation of the day of the week "0" (for Sunday) through "6" (for Saturday) * z The day of the year (starting from "0") "0" through "365" * W ISO-8601 week number of year, weeks starting on Monday "00" to ("52" or "53") * F A full textual representation of a month, such as January or March "January" through "December" * m Numeric representation of a month, with leading zeros "01" through "12" * M A short textual representation of a month, three letters "Jan" through "Dec" * n Numeric representation of a month, without leading zeros "1" through "12" * t Number of days in the given month "28" through "31" * L Whether it's a leap year "1" if it is a leap year, "0" otherwise * o ISO-8601 year number. This has the same value as Y, except that if the "2008" * ISO week number (W) belongs to the previous or next year, that year * is used instead. * Y A full numeric representation of a year, 4 digits "2008" * y A two digit representation of a year "08" * a Lowercase Ante meridiem and Post meridiem "am" or "pm" * A Uppercase Ante meridiem and Post meridiem "AM" or "PM" * B Swatch Internet time "000" through "999" * g 12-hour format of an hour without leading zeros "1" through "12" * G 24-hour format of an hour without leading zeros "0" through "23" * h 12-hour format of an hour with leading zeros "01" through "12" * H 24-hour format of an hour with leading zeros "00" through "23" * i Minutes with leading zeros "00" to "59" * s Seconds, with leading zeros "00" through "59" * u Milliseconds "54321" * e Timezone identifier "UTC", "EST", "PST" * I Whether or not the date is in daylight saving time (uppercase i) "1" if Daylight Saving Time, "0" otherwise * O Difference to Greenwich time (GMT) in hours "+0200", "-0600" * P Difference to Greenwich time (GMT) with colon between hours and minutes "+02:00", "-06:00" * T Timezone abbreviation "UTC", "EST", "PST" * Z Timezone offset in seconds. The offset for timezones west of UTC is "-43200" through "50400" * always negative, and for those east of UTC is always positive. * c ISO 8601 date "2004-02-12T15:19:21+00:00" * r RFC 2822 formatted date "Thu, 21 Dec 2000 16:01:07 +0200" * U Seconds since the Unix Epoch (January 1 1970 00:00:00 GMT) "0" * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @return {String} A string representation of the current Date object. */ var formatReplace = function (context) { return function (m) { var formatString, override = false; if (m.charAt(0) === "\\" || m.substring(0, 2) === "%%") { return m.replace("\\", "").replace("%%", "%"); } override = normalizer.shouldOverrideDefaults(m); formatString = $D.normalizeFormat(m, context); if (formatString) { return context.toString(formatString, override); } }; }; $P._format = function (format) { var formatter = formatReplace(this); if (!format) { return this._toString(); } else { return format.replace(/(%|\\)?.|%%/g, formatter); } }; if (!$P.format) { $P.format = $P._format; } }()); (function () { "use strict"; var gFn = function (attr) { return function () { return this[attr]; }; }; var sFn = function (attr) { return function (val) { this[attr] = val; return this; }; }; var attrs = ["years", "months", "days", "hours", "minutes", "seconds", "milliseconds"]; var addSetFuncs = function (context, attrs) { for (var i = 0; i < attrs.length ; i++) { var $a = attrs[i], $b = $a.slice(0, 1).toUpperCase() + $a.slice(1); context.prototype[$a] = 0; context.prototype["get" + $b] = gFn($a); context.prototype["set" + $b] = sFn($a); } }; /** * new TimeSpan(milliseconds); * new TimeSpan(days, hours, minutes, seconds); * new TimeSpan(days, hours, minutes, seconds, milliseconds); */ var TimeSpan = function (days, hours, minutes, seconds, milliseconds) { if (arguments.length === 1 && typeof days === "number") { var orient = (days < 0) ? -1 : +1; var millsLeft = Math.abs(days); this.setDays(Math.floor(millsLeft / 86400000) * orient); millsLeft = millsLeft % 86400000; this.setHours(Math.floor(millsLeft / 3600000) * orient); millsLeft = millsLeft % 3600000; this.setMinutes(Math.floor(millsLeft / 60000) * orient); millsLeft = millsLeft % 60000; this.setSeconds(Math.floor(millsLeft / 1000) * orient); millsLeft = millsLeft % 1000; this.setMilliseconds(millsLeft * orient); } else { this.set(days, hours, minutes, seconds, milliseconds); } this.getTotalMilliseconds = function () { return (this.getDays() * 86400000) + (this.getHours() * 3600000) + (this.getMinutes() * 60000) + (this.getSeconds() * 1000); }; this.compareTo = function (time) { var t1 = new Date(1970, 1, 1, this.getHours(), this.getMinutes(), this.getSeconds()), t2; if (time === null) { t2 = new Date(1970, 1, 1, 0, 0, 0); } else { t2 = new Date(1970, 1, 1, time.getHours(), time.getMinutes(), time.getSeconds()); } return (t1 < t2) ? -1 : (t1 > t2) ? 1 : 0; }; this.equals = function (time) { return (this.compareTo(time) === 0); }; this.add = function (time) { return (time === null) ? this : this.addSeconds(time.getTotalMilliseconds() / 1000); }; this.subtract = function (time) { return (time === null) ? this : this.addSeconds(-time.getTotalMilliseconds() / 1000); }; this.addDays = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 86400000)); }; this.addHours = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 3600000)); }; this.addMinutes = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 60000)); }; this.addSeconds = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 1000)); }; this.addMilliseconds = function (n) { return new TimeSpan(this.getTotalMilliseconds() + n); }; this.get12HourHour = function () { return (this.getHours() > 12) ? this.getHours() - 12 : (this.getHours() === 0) ? 12 : this.getHours(); }; this.getDesignator = function () { return (this.getHours() < 12) ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator; }; this.toString = function (format) { this._toString = function () { if (this.getDays() !== null && this.getDays() > 0) { return this.getDays() + "." + this.getHours() + ":" + this.p(this.getMinutes()) + ":" + this.p(this.getSeconds()); } else { return this.getHours() + ":" + this.p(this.getMinutes()) + ":" + this.p(this.getSeconds()); } }; this.p = function (s) { return (s.toString().length < 2) ? "0" + s : s; }; var me = this; return format ? format.replace(/dd?|HH?|hh?|mm?|ss?|tt?/g, function (format) { switch (format) { case "d": return me.getDays(); case "dd": return me.p(me.getDays()); case "H": return me.getHours(); case "HH": return me.p(me.getHours()); case "h": return me.get12HourHour(); case "hh": return me.p(me.get12HourHour()); case "m": return me.getMinutes(); case "mm": return me.p(me.getMinutes()); case "s": return me.getSeconds(); case "ss": return me.p(me.getSeconds()); case "t": return ((me.getHours() < 12) ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator).substring(0, 1); case "tt": return (me.getHours() < 12) ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator; } } ) : this._toString(); }; return this; }; addSetFuncs(TimeSpan, attrs.slice(2)); TimeSpan.prototype.set = function (days, hours, minutes, seconds, milliseconds){ this.setDays(days || this.getDays()); this.setHours(hours || this.getHours()); this.setMinutes(minutes || this.getMinutes()); this.setSeconds(seconds || this.getSeconds()); this.setMilliseconds(milliseconds || this.getMilliseconds()); }; /** * Gets the time of day for this date instances. * @return {TimeSpan} TimeSpan */ Date.prototype.getTimeOfDay = function () { return new TimeSpan(0, this.getHours(), this.getMinutes(), this.getSeconds(), this.getMilliseconds()); }; Date.TimeSpan = TimeSpan; if (typeof window !== "undefined" ) { // keeping API compatible for v1.x window.TimeSpan = TimeSpan; } }()); (function () { "use strict"; var attrs = ["years", "months", "days", "hours", "minutes", "seconds", "milliseconds"]; var gFn = function (attr) { return function () { return this[attr]; }; }; var sFn = function (attr) { return function (val) { this[attr] = val; return this; }; }; var addSetFuncs = function (context, attrs) { for (var i = 0; i < attrs.length ; i++) { var $a = attrs[i], $b = $a.slice(0, 1).toUpperCase() + $a.slice(1); context.prototype[$a] = 0; context.prototype["get" + $b] = gFn($a); context.prototype["set" + $b] = sFn($a); } }; var setMonthsAndYears = function (orient, d1, d2, context) { function inc() { d1.addMonths(-orient); context.months++; if (context.months === 12) { context.years++; context.months = 0; } } if (orient === +1) { while (d1 > d2) { inc(); } } else { while (d1 < d2) { inc(); } } context.months--; context.months *= orient; context.years *= orient; }; var adjustForDST = function(orient, startDate, endDate) { var hasDSTMismatch = (false === (startDate.isDaylightSavingTime() === endDate.isDaylightSavingTime())); if (hasDSTMismatch && orient === 1) { startDate.addHours(-1); } else if (hasDSTMismatch) { startDate.addHours(1); } }; /** * TimePeriod(startDate, endDate); * TimePeriod(years, months, days, hours, minutes, seconds, milliseconds); */ var TimePeriod = function (years, months, days, hours, minutes, seconds, milliseconds) { if (arguments.length === 7) { this.set(years, months, days, hours, minutes, seconds, milliseconds); } else if (arguments.length === 2 && arguments[0] instanceof Date && arguments[1] instanceof Date) { var startDate = arguments[0].clone(); var endDate = arguments[1].clone(); var orient = (startDate > endDate) ? +1 : -1; this.dates = { start: arguments[0].clone(), end: arguments[1].clone() }; setMonthsAndYears(orient, startDate, endDate, this); adjustForDST(orient, startDate, endDate); // // TODO - adjust for DST var diff = endDate - startDate; if (diff !== 0) { var ts = new TimeSpan(diff); this.set(this.years, this.months, ts.getDays(), ts.getHours(), ts.getMinutes(), ts.getSeconds(), ts.getMilliseconds()); } } return this; }; // create all the set functions. addSetFuncs(TimePeriod, attrs); TimePeriod.prototype.set = function (years, months, days, hours, minutes, seconds, milliseconds){ this.setYears(years || this.getYears()); this.setMonths(months || this.getMonths()); this.setDays(days || this.getDays()); this.setHours(hours || this.getHours()); this.setMinutes(minutes || this.getMinutes()); this.setSeconds(seconds || this.getSeconds()); this.setMilliseconds(milliseconds || this.getMilliseconds()); }; Date.TimePeriod = TimePeriod; if (typeof window !== "undefined") { // keeping API compatible for v1.x window.TimePeriod = TimePeriod; } }()); ================================================ FILE: build/date-nl-BE.js ================================================ /** * @overview datejs * @version 1.0.0-rc3 * @author Gregory Wild-Smith * @copyright 2015 Gregory Wild-Smith * @license MIT * @homepage https://github.com/abritinthebay/datejs */ /* * DateJS Culture String File * Country Code: nl-BE * Name: Dutch (Belgium) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["nl-BE"] = { "name": "nl-BE", "englishName": "Dutch (Belgium)", "nativeName": "Nederlands (België)", "Sunday": "zondag", "Monday": "maandag", "Tuesday": "dinsdag", "Wednesday": "woensdag", "Thursday": "donderdag", "Friday": "vrijdag", "Saturday": "zaterdag", "Sun": "zo", "Mon": "ma", "Tue": "di", "Wed": "wo", "Thu": "do", "Fri": "vr", "Sat": "za", "Su": "zo", "Mo": "ma", "Tu": "di", "We": "wo", "Th": "do", "Fr": "vr", "Sa": "za", "S_Sun_Initial": "z", "M_Mon_Initial": "m", "T_Tue_Initial": "d", "W_Wed_Initial": "w", "T_Thu_Initial": "d", "F_Fri_Initial": "v", "S_Sat_Initial": "z", "January": "januari", "February": "februari", "March": "maart", "April": "april", "May": "mei", "June": "juni", "July": "juli", "August": "augustus", "September": "september", "October": "oktober", "November": "november", "December": "december", "Jan_Abbr": "jan", "Feb_Abbr": "feb", "Mar_Abbr": "mrt", "Apr_Abbr": "apr", "May_Abbr": "mei", "Jun_Abbr": "jun", "Jul_Abbr": "jul", "Aug_Abbr": "aug", "Sep_Abbr": "sep", "Oct_Abbr": "okt", "Nov_Abbr": "nov", "Dec_Abbr": "dec", "AM": "", "PM": "", "firstDayOfWeek": 1, "twoDigitYearMax": 2029, "mdy": "dmy", "M/d/yyyy": "d/MM/yyyy", "dddd, MMMM dd, yyyy": "dddd d MMMM yyyy", "h:mm tt": "H:mm", "h:mm:ss tt": "H:mm:ss", "dddd, MMMM dd, yyyy h:mm:ss tt": "dddd d MMMM yyyy H:mm:ss", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "dd MMMM", "MMMM, yyyy": "MMMM yyyy", "/jan(uary)?/": "jan(uari)?", "/feb(ruary)?/": "feb(ruari)?", "/mar(ch)?/": "maart", "/apr(il)?/": "apr(il)?", "/may/": "mei", "/jun(e)?/": "jun(i)?", "/jul(y)?/": "jul(i)?", "/aug(ust)?/": "aug(ustus)?", "/sep(t(ember)?)?/": "sep(t(ember)?)?", "/oct(ober)?/": "okt(ober)?", "/nov(ember)?/": "nov(ember)?", "/dec(ember)?/": "dec(ember)?", "/^su(n(day)?)?/": "^zondag", "/^mo(n(day)?)?/": "^maandag", "/^tu(e(s(day)?)?)?/": "^dinsdag", "/^we(d(nesday)?)?/": "^woensdag", "/^th(u(r(s(day)?)?)?)?/": "^donderdag", "/^fr(i(day)?)?/": "^vrijdag", "/^sa(t(urday)?)?/": "^zaterdag", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "nl-BE"; /** * @overview datejs * @version 1.0.0-rc3 * @author Gregory Wild-Smith * @copyright 2015 Gregory Wild-Smith * @license MIT * @homepage https://github.com/abritinthebay/datejs */(function () { var $D = Date; var lang = Date.CultureStrings ? Date.CultureStrings.lang : null; var loggedKeys = {}; // for debug purposes. var getText = { getFromKey: function (key, countryCode) { var output; if (Date.CultureStrings && Date.CultureStrings[countryCode] && Date.CultureStrings[countryCode][key]) { output = Date.CultureStrings[countryCode][key]; } else { output = getText.buildFromDefault(key); } if (key.charAt(0) === "/") { // Assume it's a regex output = getText.buildFromRegex(key, countryCode); } return output; }, getFromObjectValues: function (obj, countryCode) { var key, output = {}; for(key in obj) { if (obj.hasOwnProperty(key)) { output[key] = getText.getFromKey(obj[key], countryCode); } } return output; }, getFromObjectKeys: function (obj, countryCode) { var key, output = {}; for(key in obj) { if (obj.hasOwnProperty(key)) { output[getText.getFromKey(key, countryCode)] = obj[key]; } } return output; }, getFromArray: function (arr, countryCode) { var output = []; for (var i=0; i < arr.length; i++){ if (i in arr) { output[i] = getText.getFromKey(arr[i], countryCode); } } return output; }, buildFromDefault: function (key) { var output, length, split, last; switch(key) { case "name": output = "en-US"; break; case "englishName": output = "English (United States)"; break; case "nativeName": output = "English (United States)"; break; case "twoDigitYearMax": output = 2049; break; case "firstDayOfWeek": output = 0; break; default: output = key; split = key.split("_"); length = split.length; if (length > 1 && key.charAt(0) !== "/") { // if the key isn't a regex and it has a split. last = split[(length - 1)].toLowerCase(); if (last === "initial" || last === "abbr") { output = split[0]; } } break; } return output; }, buildFromRegex: function (key, countryCode) { var output; if (Date.CultureStrings && Date.CultureStrings[countryCode] && Date.CultureStrings[countryCode][key]) { output = new RegExp(Date.CultureStrings[countryCode][key], "i"); } else { output = new RegExp(key.replace(new RegExp("/", "g"),""), "i"); } return output; } }; var shallowMerge = function (obj1, obj2) { for (var attrname in obj2) { if (obj2.hasOwnProperty(attrname)) { obj1[attrname] = obj2[attrname]; } } }; var __ = function (key, language) { var countryCode = (language) ? language : lang; loggedKeys[key] = key; if (typeof key === "object") { if (key instanceof Array) { return getText.getFromArray(key, countryCode); } else { return getText.getFromObjectKeys(key, countryCode); } } else { return getText.getFromKey(key, countryCode); } }; var loadI18nScript = function (code) { // paatterned after jQuery's getScript. var url = Date.Config.i18n + code + ".js"; var head = document.getElementsByTagName("head")[0] || document.documentElement; var script = document.createElement("script"); script.src = url; var completed = false; var events = { done: function (){} // placeholder function }; // Attach handlers for all browsers script.onload = script.onreadystatechange = function() { if ( !completed && (!this.readyState || this.readyState === "loaded" || this.readyState === "complete") ) { events.done(); head.removeChild(script); } }; setTimeout(function() { head.insertBefore(script, head.firstChild); }, 0); // allows return to execute first return { done: function (cb) { events.done = function() { if (cb) { setTimeout(cb,0); } }; } }; }; var buildInfo = { buildFromMethodHash: function (obj) { var key; for(key in obj) { if (obj.hasOwnProperty(key)) { obj[key] = buildInfo[obj[key]](); } } return obj; }, timeZoneDST: function () { var DST = { "CHADT": "+1345", "NZDT": "+1300", "AEDT": "+1100", "ACDT": "+1030", "AZST": "+0500", "IRDT": "+0430", "EEST": "+0300", "CEST": "+0200", "BST": "+0100", "PMDT": "-0200", "ADT": "-0300", "NDT": "-0230", "EDT": "-0400", "CDT": "-0500", "MDT": "-0600", "PDT": "-0700", "AKDT": "-0800", "HADT": "-0900" }; return __(DST); }, timeZoneStandard: function () { var standard = { "LINT": "+1400", "TOT": "+1300", "CHAST": "+1245", "NZST": "+1200", "NFT": "+1130", "SBT": "+1100", "AEST": "+1000", "ACST": "+0930", "JST": "+0900", "CWST": "+0845", "CT": "+0800", "ICT": "+0700", "MMT": "+0630", "BST": "+0600", "NPT": "+0545", "IST": "+0530", "PKT": "+0500", "AFT": "+0430", "MSK": "+0400", "IRST": "+0330", "FET": "+0300", "EET": "+0200", "CET": "+0100", "GMT": "+0000", "UTC": "+0000", "CVT": "-0100", "GST": "-0200", "BRT": "-0300", "NST": "-0330", "AST": "-0400", "EST": "-0500", "CST": "-0600", "MST": "-0700", "PST": "-0800", "AKST": "-0900", "MIT": "-0930", "HST": "-1000", "SST": "-1100", "BIT": "-1200" }; return __(standard); }, timeZones: function (data) { var zone; data.timezones = []; for (zone in data.abbreviatedTimeZoneStandard) { if (data.abbreviatedTimeZoneStandard.hasOwnProperty(zone)) { data.timezones.push({ name: zone, offset: data.abbreviatedTimeZoneStandard[zone]}); } } for (zone in data.abbreviatedTimeZoneDST) { if (data.abbreviatedTimeZoneDST.hasOwnProperty(zone)) { data.timezones.push({ name: zone, offset: data.abbreviatedTimeZoneDST[zone], dst: true}); } } return data.timezones; }, days: function () { return __(["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"]); }, dayAbbr: function () { return __(["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"]); }, dayShortNames: function () { return __(["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"]); }, dayFirstLetters: function () { return __(["S_Sun_Initial", "M_Mon_Initial", "T_Tues_Initial", "W_Wed_Initial", "T_Thu_Initial", "F_Fri_Initial", "S_Sat_Initial"]); }, months: function () { return __(["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"]); }, monthAbbr: function () { return __(["Jan_Abbr", "Feb_Abbr", "Mar_Abbr", "Apr_Abbr", "May_Abbr", "Jun_Abbr", "Jul_Abbr", "Aug_Abbr", "Sep_Abbr", "Oct_Abbr", "Nov_Abbr", "Dec_Abbr"]); }, formatPatterns: function () { return getText.getFromObjectValues({ shortDate: "M/d/yyyy", longDate: "dddd, MMMM dd, yyyy", shortTime: "h:mm tt", longTime: "h:mm:ss tt", fullDateTime: "dddd, MMMM dd, yyyy h:mm:ss tt", sortableDateTime: "yyyy-MM-ddTHH:mm:ss", universalSortableDateTime: "yyyy-MM-dd HH:mm:ssZ", rfc1123: "ddd, dd MMM yyyy HH:mm:ss", monthDay: "MMMM dd", yearMonth: "MMMM, yyyy" }, Date.i18n.currentLanguage()); }, regex: function () { return getText.getFromObjectValues({ inTheMorning: "/( in the )(morn(ing)?)\\b/", thisMorning: "/(this )(morn(ing)?)\\b/", amThisMorning: "/(\b\\d(am)? )(this )(morn(ing)?)/", inTheEvening: "/( in the )(even(ing)?)\\b/", thisEvening: "/(this )(even(ing)?)\\b/", pmThisEvening: "/(\b\\d(pm)? )(this )(even(ing)?)/", jan: "/jan(uary)?/", feb: "/feb(ruary)?/", mar: "/mar(ch)?/", apr: "/apr(il)?/", may: "/may/", jun: "/jun(e)?/", jul: "/jul(y)?/", aug: "/aug(ust)?/", sep: "/sep(t(ember)?)?/", oct: "/oct(ober)?/", nov: "/nov(ember)?/", dec: "/dec(ember)?/", sun: "/^su(n(day)?)?/", mon: "/^mo(n(day)?)?/", tue: "/^tu(e(s(day)?)?)?/", wed: "/^we(d(nesday)?)?/", thu: "/^th(u(r(s(day)?)?)?)?/", fri: "/fr(i(day)?)?/", sat: "/^sa(t(urday)?)?/", future: "/^next/", past: "/^last|past|prev(ious)?/", add: "/^(\\+|aft(er)?|from|hence)/", subtract: "/^(\\-|bef(ore)?|ago)/", yesterday: "/^yes(terday)?/", today: "/^t(od(ay)?)?/", tomorrow: "/^tom(orrow)?/", now: "/^n(ow)?/", millisecond: "/^ms|milli(second)?s?/", second: "/^sec(ond)?s?/", minute: "/^mn|min(ute)?s?/", hour: "/^h(our)?s?/", week: "/^w(eek)?s?/", month: "/^m(onth)?s?/", day: "/^d(ay)?s?/", year: "/^y(ear)?s?/", shortMeridian: "/^(a|p)/", longMeridian: "/^(a\\.?m?\\.?|p\\.?m?\\.?)/", timezone: "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/", ordinalSuffix: "/^\\s*(st|nd|rd|th)/", timeContext: "/^\\s*(\\:|a(?!u|p)|p)/" }, Date.i18n.currentLanguage()); } }; var CultureInfo = function () { var info = getText.getFromObjectValues({ name: "name", englishName: "englishName", nativeName: "nativeName", amDesignator: "AM", pmDesignator: "PM", firstDayOfWeek: "firstDayOfWeek", twoDigitYearMax: "twoDigitYearMax", dateElementOrder: "mdy" }, Date.i18n.currentLanguage()); var constructedInfo = buildInfo.buildFromMethodHash({ dayNames: "days", abbreviatedDayNames: "dayAbbr", shortestDayNames: "dayShortNames", firstLetterDayNames: "dayFirstLetters", monthNames: "months", abbreviatedMonthNames: "monthAbbr", formatPatterns: "formatPatterns", regexPatterns: "regex", abbreviatedTimeZoneDST: "timeZoneDST", abbreviatedTimeZoneStandard: "timeZoneStandard" }); shallowMerge(info, constructedInfo); buildInfo.timeZones(info); return info; }; $D.i18n = { __: function (key, lang) { return __(key, lang); }, currentLanguage: function () { return lang || "en-US"; }, setLanguage: function (code, force, cb) { var async = false; if (force || code === "en-US" || (!!Date.CultureStrings && !!Date.CultureStrings[code])) { lang = code; Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings.lang = code; Date.CultureInfo = new CultureInfo(); } else { if (!(!!Date.CultureStrings && !!Date.CultureStrings[code])) { if (typeof exports !== "undefined" && this.exports !== exports) { // we're in a Node enviroment, load it using require try { require("../i18n/" + code + ".js"); lang = code; Date.CultureStrings.lang = code; Date.CultureInfo = new CultureInfo(); } catch (e) { // var str = "The language for '" + code + "' could not be loaded by Node. It likely does not exist."; throw new Error("The DateJS IETF language tag '" + code + "' could not be loaded by Node. It likely does not exist."); } } else if (Date.Config && Date.Config.i18n) { // we know the location of the files, so lets load them async = true; loadI18nScript(code).done(function(){ lang = code; Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings.lang = code; Date.CultureInfo = new CultureInfo(); $D.Parsing.Normalizer.buildReplaceData(); // because this is async if ($D.Grammar) { $D.Grammar.buildGrammarFormats(); // so we can parse those strings... } if (cb) { setTimeout(cb,0); } }); } else { Date.console.error("The DateJS IETF language tag '" + code + "' is not available and has not been loaded."); return false; } } } $D.Parsing.Normalizer.buildReplaceData(); // rebuild normalizer strings if ($D.Grammar) { $D.Grammar.buildGrammarFormats(); // so we can parse those strings... } if (!async && cb) { setTimeout(cb,0); } }, getLoggedKeys: function () { return loggedKeys; }, updateCultureInfo: function () { Date.CultureInfo = new CultureInfo(); } }; $D.i18n.updateCultureInfo(); // run automatically }()); (function () { var $D = Date, $P = $D.prototype, p = function (s, l) { if (!l) { l = 2; } return ("000" + s).slice(l * -1); }; if (typeof window !== "undefined" && typeof window.console !== "undefined" && typeof window.console.log !== "undefined") { $D.console = console; // used only to raise non-critical errors if available } else { // set mock so we don't give errors. $D.console = { log: function(){}, error: function(){} }; } $D.Config = $D.Config || {}; $D.initOverloads = function() { /** * Overload of Date.now. Allows an alternate call for Date.now where it returns the * current Date as an object rather than just milliseconds since the Unix Epoch. * * Also provides an implementation of now() for browsers (IE<9) that don't have it. * * Backwards compatible so with work with either: * Date.now() [returns ms] * or * Date.now(true) [returns Date] */ if (!$D.now) { $D._now = function now() { return new Date().getTime(); }; } else if (!$D._now) { $D._now = $D.now; } $D.now = function (returnObj) { if (returnObj) { return $D.present(); } else { return $D._now(); } }; if ( !$P.toISOString ) { $P.toISOString = function() { return this.getUTCFullYear() + "-" + p(this.getUTCMonth() + 1) + "-" + p(this.getUTCDate()) + "T" + p(this.getUTCHours()) + ":" + p(this.getUTCMinutes()) + ":" + p(this.getUTCSeconds()) + "." + String( (this.getUTCMilliseconds()/1000).toFixed(3)).slice(2, 5) + "Z"; }; } // private if ( $P._toString === undefined ){ $P._toString = $P.toString; } }; $D.initOverloads(); /** * Gets a date that is set to the current date. The time is set to the start of the day (00:00 or 12:00 AM). * @return {Date} The current date. */ $D.today = function () { return new Date().clearTime(); }; /** * Gets a date that is set to the current date and time (same as new Date, but chainable) * @return {Date} The current date. */ $D.present = function () { return new Date(); }; /** * Compares the first date to the second date and returns an number indication of their relative values. * @param {Date} First Date object to compare [Required]. * @param {Date} Second Date object to compare to [Required]. * @return {Number} -1 = date1 is lessthan date2. 0 = values are equal. 1 = date1 is greaterthan date2. */ $D.compare = function (date1, date2) { if (isNaN(date1) || isNaN(date2)) { throw new Error(date1 + " - " + date2); } else if (date1 instanceof Date && date2 instanceof Date) { return (date1 < date2) ? -1 : (date1 > date2) ? 1 : 0; } else { throw new TypeError(date1 + " - " + date2); } }; /** * Compares the first Date object to the second Date object and returns true if they are equal. * @param {Date} First Date object to compare [Required] * @param {Date} Second Date object to compare to [Required] * @return {Boolean} true if dates are equal. false if they are not equal. */ $D.equals = function (date1, date2) { return (date1.compareTo(date2) === 0); }; /** * Gets the language appropriate day name when given the day number(0-6) * eg - 0 == Sunday * @return {String} The day name */ $D.getDayName = function (n) { return Date.CultureInfo.dayNames[n]; }; /** * Gets the day number (0-6) if given a CultureInfo specific string which is a valid dayName, abbreviatedDayName or shortestDayName (two char). * @param {String} The name of the day (eg. "Monday, "Mon", "tuesday", "tue", "We", "we"). * @return {Number} The day number */ $D.getDayNumberFromName = function (name) { var n = Date.CultureInfo.dayNames, m = Date.CultureInfo.abbreviatedDayNames, o = Date.CultureInfo.shortestDayNames, s = name.toLowerCase(); for (var i = 0; i < n.length; i++) { if (n[i].toLowerCase() === s || m[i].toLowerCase() === s || o[i].toLowerCase() === s) { return i; } } return -1; }; /** * Gets the month number (0-11) if given a Culture Info specific string which is a valid monthName or abbreviatedMonthName. * @param {String} The name of the month (eg. "February, "Feb", "october", "oct"). * @return {Number} The day number */ $D.getMonthNumberFromName = function (name) { var n = Date.CultureInfo.monthNames, m = Date.CultureInfo.abbreviatedMonthNames, s = name.toLowerCase(); for (var i = 0; i < n.length; i++) { if (n[i].toLowerCase() === s || m[i].toLowerCase() === s) { return i; } } return -1; }; /** * Gets the language appropriate month name when given the month number(0-11) * eg - 0 == January * @return {String} The month name */ $D.getMonthName = function (n) { return Date.CultureInfo.monthNames[n]; }; /** * Determines if the current date instance is within a LeapYear. * @param {Number} The year. * @return {Boolean} true if date is within a LeapYear, otherwise false. */ $D.isLeapYear = function (year) { return ((year % 4 === 0 && year % 100 !== 0) || year % 400 === 0); }; /** * Gets the number of days in the month, given a year and month value. Automatically corrects for LeapYear. * @param {Number} The year. * @param {Number} The month (0-11). * @return {Number} The number of days in the month. */ $D.getDaysInMonth = function (year, month) { if (!month && $D.validateMonth(year)) { month = year; year = Date.today().getFullYear(); } return [31, ($D.isLeapYear(year) ? 29 : 28), 31, 30, 31, 30, 31, 31, 30, 31, 30, 31][month]; }; $P.getDaysInMonth = function () { return $D.getDaysInMonth(this.getFullYear(), this.getMonth()); }; $D.getTimezoneAbbreviation = function (offset, dst) { var p, n = (dst || false) ? Date.CultureInfo.abbreviatedTimeZoneDST : Date.CultureInfo.abbreviatedTimeZoneStandard; for (p in n) { if (n.hasOwnProperty(p)) { if (n[p] === offset) { return p; } } } return null; }; $D.getTimezoneOffset = function (name, dst) { var i, a =[], z = Date.CultureInfo.timezones; if (!name) { name = (new Date()).getTimezone();} for (i = 0; i < z.length; i++) { if (z[i].name === name.toUpperCase()) { a.push(i); } } if (!z[a[0]]) { return null; } if (a.length === 1 || !dst) { return z[a[0]].offset; } else { for (i=0; i < a.length; i++) { if (z[a[i]].dst) { return z[a[i]].offset; } } } }; $D.getQuarter = function (d) { d = d || new Date(); // If no date supplied, use today var q = [1,2,3,4]; return q[Math.floor(d.getMonth() / 3)]; // ~~~ is a bitwise op. Faster than Math.floor }; $D.getDaysLeftInQuarter = function (d) { d = d || new Date(); var qEnd = new Date(d); qEnd.setMonth(qEnd.getMonth() + 3 - qEnd.getMonth() % 3, 0); return Math.floor((qEnd - d) / 8.64e7); }; // private var validate = function (n, min, max, name) { name = name ? name : "Object"; if (typeof n === "undefined") { return false; } else if (typeof n !== "number") { throw new TypeError(n + " is not a Number."); } else if (n < min || n > max) { // As failing validation is *not* an exceptional circumstance // lets not throw a RangeError Exception here. // It's semantically correct but it's not sensible. return false; } return true; }; /** * Validates the number is within an acceptable range for milliseconds [0-999]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateMillisecond = function (value) { return validate(value, 0, 999, "millisecond"); }; /** * Validates the number is within an acceptable range for seconds [0-59]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateSecond = function (value) { return validate(value, 0, 59, "second"); }; /** * Validates the number is within an acceptable range for minutes [0-59]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateMinute = function (value) { return validate(value, 0, 59, "minute"); }; /** * Validates the number is within an acceptable range for hours [0-23]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateHour = function (value) { return validate(value, 0, 23, "hour"); }; /** * Validates the number is within an acceptable range for the days in a month [0-MaxDaysInMonth]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateDay = function (value, year, month) { if (year === undefined || year === null || month === undefined || month === null) { return false;} return validate(value, 1, $D.getDaysInMonth(year, month), "day"); }; /** * Validates the number is within an acceptable range for months [0-11]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateWeek = function (value) { return validate(value, 0, 53, "week"); }; /** * Validates the number is within an acceptable range for months [0-11]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateMonth = function (value) { return validate(value, 0, 11, "month"); }; /** * Validates the number is within an acceptable range for years. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateYear = function (value) { /** * Per ECMAScript spec the range of times supported by Date objects is * exactly -100,000,000 days to +100,000,000 days measured relative to * midnight at the beginning of 01 January, 1970 UTC. * This gives a range of 8,640,000,000,000,000 milliseconds to either * side of 01 January, 1970 UTC. * * Earliest possible date: Tue, 20 Apr 271,822 B.C. 00:00:00 UTC * Latest possible date: Sat, 13 Sep 275,760 00:00:00 UTC */ return validate(value, -271822, 275760, "year"); }; $D.validateTimezone = function(value) { var timezones = {"ACDT":1,"ACST":1,"ACT":1,"ADT":1,"AEDT":1,"AEST":1,"AFT":1,"AKDT":1,"AKST":1,"AMST":1,"AMT":1,"ART":1,"AST":1,"AWDT":1,"AWST":1,"AZOST":1,"AZT":1,"BDT":1,"BIOT":1,"BIT":1,"BOT":1,"BRT":1,"BST":1,"BTT":1,"CAT":1,"CCT":1,"CDT":1,"CEDT":1,"CEST":1,"CET":1,"CHADT":1,"CHAST":1,"CHOT":1,"ChST":1,"CHUT":1,"CIST":1,"CIT":1,"CKT":1,"CLST":1,"CLT":1,"COST":1,"COT":1,"CST":1,"CT":1,"CVT":1,"CWST":1,"CXT":1,"DAVT":1,"DDUT":1,"DFT":1,"EASST":1,"EAST":1,"EAT":1,"ECT":1,"EDT":1,"EEDT":1,"EEST":1,"EET":1,"EGST":1,"EGT":1,"EIT":1,"EST":1,"FET":1,"FJT":1,"FKST":1,"FKT":1,"FNT":1,"GALT":1,"GAMT":1,"GET":1,"GFT":1,"GILT":1,"GIT":1,"GMT":1,"GST":1,"GYT":1,"HADT":1,"HAEC":1,"HAST":1,"HKT":1,"HMT":1,"HOVT":1,"HST":1,"ICT":1,"IDT":1,"IOT":1,"IRDT":1,"IRKT":1,"IRST":1,"IST":1,"JST":1,"KGT":1,"KOST":1,"KRAT":1,"KST":1,"LHST":1,"LINT":1,"MAGT":1,"MART":1,"MAWT":1,"MDT":1,"MET":1,"MEST":1,"MHT":1,"MIST":1,"MIT":1,"MMT":1,"MSK":1,"MST":1,"MUT":1,"MVT":1,"MYT":1,"NCT":1,"NDT":1,"NFT":1,"NPT":1,"NST":1,"NT":1,"NUT":1,"NZDT":1,"NZST":1,"OMST":1,"ORAT":1,"PDT":1,"PET":1,"PETT":1,"PGT":1,"PHOT":1,"PHT":1,"PKT":1,"PMDT":1,"PMST":1,"PONT":1,"PST":1,"PYST":1,"PYT":1,"RET":1,"ROTT":1,"SAKT":1,"SAMT":1,"SAST":1,"SBT":1,"SCT":1,"SGT":1,"SLST":1,"SRT":1,"SST":1,"SYOT":1,"TAHT":1,"THA":1,"TFT":1,"TJT":1,"TKT":1,"TLT":1,"TMT":1,"TOT":1,"TVT":1,"UCT":1,"ULAT":1,"UTC":1,"UYST":1,"UYT":1,"UZT":1,"VET":1,"VLAT":1,"VOLT":1,"VOST":1,"VUT":1,"WAKT":1,"WAST":1,"WAT":1,"WEDT":1,"WEST":1,"WET":1,"WST":1,"YAKT":1,"YEKT":1,"Z":1}; return (timezones[value] === 1); }; $D.validateTimezoneOffset= function(value) { // timezones go from +14hrs to -12hrs, the +X hours are negative offsets. return (value > -841 && value < 721); }; }()); (function () { var $D = Date, $P = $D.prototype, p = function (s, l) { if (!l) { l = 2; } return ("000" + s).slice(l * -1); }; var validateConfigObject = function (obj) { var result = {}, self = this, prop, testFunc; testFunc = function (prop, func, value) { if (prop === "day") { var month = (obj.month !== undefined) ? obj.month : self.getMonth(); var year = (obj.year !== undefined) ? obj.year : self.getFullYear(); return $D[func](value, year, month); } else { return $D[func](value); } }; for (prop in obj) { if (Object.prototype.hasOwnProperty.call(obj, prop)) { var func = "validate" + prop.charAt(0).toUpperCase() + prop.slice(1); if ($D[func] && obj[prop] !== null && testFunc(prop, func, obj[prop])) { result[prop] = obj[prop]; } } } return result; }; /** * Resets the time of this Date object to 12:00 AM (00:00), which is the start of the day. * @param {Boolean} .clone() this date instance before clearing Time * @return {Date} this */ $P.clearTime = function () { this.setHours(0); this.setMinutes(0); this.setSeconds(0); this.setMilliseconds(0); return this; }; /** * Resets the time of this Date object to the current time ('now'). * @return {Date} this */ $P.setTimeToNow = function () { var n = new Date(); this.setHours(n.getHours()); this.setMinutes(n.getMinutes()); this.setSeconds(n.getSeconds()); this.setMilliseconds(n.getMilliseconds()); return this; }; /** * Returns a new Date object that is an exact date and time copy of the original instance. * @return {Date} A new Date instance */ $P.clone = function () { return new Date(this.getTime()); }; /** * Compares this instance to a Date object and returns an number indication of their relative values. * @param {Date} Date object to compare [Required] * @return {Number} -1 = this is lessthan date. 0 = values are equal. 1 = this is greaterthan date. */ $P.compareTo = function (date) { return Date.compare(this, date); }; /** * Compares this instance to another Date object and returns true if they are equal. * @param {Date} Date object to compare. If no date to compare, new Date() [now] is used. * @return {Boolean} true if dates are equal. false if they are not equal. */ $P.equals = function (date) { return Date.equals(this, (date !== undefined ? date : new Date())); }; /** * Determines if this instance is between a range of two dates or equal to either the start or end dates. * @param {Date} Start of range [Required] * @param {Date} End of range [Required] * @return {Boolean} true is this is between or equal to the start and end dates, else false */ $P.between = function (start, end) { return this.getTime() >= start.getTime() && this.getTime() <= end.getTime(); }; /** * Determines if this date occurs after the date to compare to. * @param {Date} Date object to compare. If no date to compare, new Date() ("now") is used. * @return {Boolean} true if this date instance is greater than the date to compare to (or "now"), otherwise false. */ $P.isAfter = function (date) { return this.compareTo(date || new Date()) === 1; }; /** * Determines if this date occurs before the date to compare to. * @param {Date} Date object to compare. If no date to compare, new Date() ("now") is used. * @return {Boolean} true if this date instance is less than the date to compare to (or "now"). */ $P.isBefore = function (date) { return (this.compareTo(date || new Date()) === -1); }; /** * Determines if the current Date instance occurs today. * @return {Boolean} true if this date instance is 'today', otherwise false. */ /** * Determines if the current Date instance occurs on the same Date as the supplied 'date'. * If no 'date' to compare to is provided, the current Date instance is compared to 'today'. * @param {date} Date object to compare. If no date to compare, the current Date ("now") is used. * @return {Boolean} true if this Date instance occurs on the same Day as the supplied 'date'. */ $P.isToday = $P.isSameDay = function (date) { return this.clone().clearTime().equals((date || new Date()).clone().clearTime()); }; /** * Adds the specified number of milliseconds to this instance. * @param {Number} The number of milliseconds to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addMilliseconds = function (value) { if (!value) { return this; } this.setTime(this.getTime() + value * 1); return this; }; /** * Adds the specified number of seconds to this instance. * @param {Number} The number of seconds to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addSeconds = function (value) { if (!value) { return this; } return this.addMilliseconds(value * 1000); }; /** * Adds the specified number of seconds to this instance. * @param {Number} The number of seconds to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addMinutes = function (value) { if (!value) { return this; } return this.addMilliseconds(value * 60000); // 60*1000 }; /** * Adds the specified number of hours to this instance. * @param {Number} The number of hours to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addHours = function (value) { if (!value) { return this; } return this.addMilliseconds(value * 3600000); // 60*60*1000 }; /** * Adds the specified number of days to this instance. * @param {Number} The number of days to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addDays = function (value) { if (!value) { return this; } this.setDate(this.getDate() + value * 1); return this; }; /** * Adds the specified number of weekdays (ie - not sat or sun) to this instance. * @param {Number} The number of days to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addWeekdays = function (value) { if (!value) { return this; } var day = this.getDay(); var weeks = (Math.ceil(Math.abs(value)/7)); if (day === 0 || day === 6) { if (value > 0) { this.next().monday(); this.addDays(-1); day = this.getDay(); } } if (value < 0) { while (value < 0) { this.addDays(-1); day = this.getDay(); if (day !== 0 && day !== 6) { value++; } } return this; } else if (value > 5 || (6-day) <= value) { value = value + (weeks * 2); } return this.addDays(value); }; /** * Adds the specified number of weeks to this instance. * @param {Number} The number of weeks to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addWeeks = function (value) { if (!value) { return this; } return this.addDays(value * 7); }; /** * Adds the specified number of months to this instance. * @param {Number} The number of months to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addMonths = function (value) { if (!value) { return this; } var n = this.getDate(); this.setDate(1); this.setMonth(this.getMonth() + value * 1); this.setDate(Math.min(n, $D.getDaysInMonth(this.getFullYear(), this.getMonth()))); return this; }; $P.addQuarters = function (value) { if (!value) { return this; } // note this will take you to the same point in the quarter as you are now. // i.e. - if you are 15 days into the quarter you'll be 15 days into the resulting one. // bonus: this allows adding fractional quarters return this.addMonths(value * 3); }; /** * Adds the specified number of years to this instance. * @param {Number} The number of years to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addYears = function (value) { if (!value) { return this; } return this.addMonths(value * 12); }; /** * Adds (or subtracts) to the value of the years, months, weeks, days, hours, minutes, seconds, milliseconds of the date instance using given configuration object. Positive and Negative values allowed. * Example

	Date.today().add( { days: 1, months: 1 } )

	new Date().add( { years: -1 } )
	
* @param {Object} Configuration object containing attributes (months, days, etc.) * @return {Date} this */ $P.add = function (config) { if (typeof config === "number") { this._orient = config; return this; } var x = config; if (x.day) { // If we should be a different date than today (eg: for 'tomorrow -1d', etc). // Should only effect parsing, not direct usage (eg, Finish and FinishExact) if ((x.day - this.getDate()) !== 0) { this.setDate(x.day); } } if (x.milliseconds) { this.addMilliseconds(x.milliseconds); } if (x.seconds) { this.addSeconds(x.seconds); } if (x.minutes) { this.addMinutes(x.minutes); } if (x.hours) { this.addHours(x.hours); } if (x.weeks) { this.addWeeks(x.weeks); } if (x.months) { this.addMonths(x.months); } if (x.years) { this.addYears(x.years); } if (x.days) { this.addDays(x.days); } return this; }; /** * Get the week number. Week one (1) is the week which contains the first Thursday of the year. Monday is considered the first day of the week. * The .getWeek() function does NOT convert the date to UTC. The local datetime is used. * Please use .getISOWeek() to get the week of the UTC converted date. * @return {Number} 1 to 53 */ $P.getWeek = function (utc) { // Create a copy of this date object var self, target = new Date(this.valueOf()); if (utc) { target.addMinutes(target.getTimezoneOffset()); self = target.clone(); } else { self = this; } // ISO week date weeks start on monday // so correct the day number var dayNr = (self.getDay() + 6) % 7; // ISO 8601 states that week 1 is the week // with the first thursday of that year. // Set the target date to the thursday in the target week target.setDate(target.getDate() - dayNr + 3); // Store the millisecond value of the target date var firstThursday = target.valueOf(); // Set the target to the first thursday of the year // First set the target to january first target.setMonth(0, 1); // Not a thursday? Correct the date to the next thursday if (target.getDay() !== 4) { target.setMonth(0, 1 + ((4 - target.getDay()) + 7) % 7); } // The weeknumber is the number of weeks between the // first thursday of the year and the thursday in the target week return 1 + Math.ceil((firstThursday - target) / 604800000); // 604800000 = 7 * 24 * 3600 * 1000 }; /** * Get the ISO 8601 week number. Week one ("01") is the week which contains the first Thursday of the year. Monday is considered the first day of the week. * The .getISOWeek() function does convert the date to it's UTC value. Please use .getWeek() to get the week of the local date. * @return {String} "01" to "53" */ $P.getISOWeek = function () { return p(this.getWeek(true)); }; /** * Moves the date to Monday of the week set. Week one (1) is the week which contains the first Thursday of the year. * @param {Number} A Number (1 to 53) that represents the week of the year. * @return {Date} this */ $P.setWeek = function (n) { if ((n - this.getWeek()) === 0) { if (this.getDay() !== 1) { return this.moveToDayOfWeek(1, (this.getDay() > 1 ? -1 : 1)); } else { return this; } } else { return this.moveToDayOfWeek(1, (this.getDay() > 1 ? -1 : 1)).addWeeks(n - this.getWeek()); } }; $P.setQuarter = function (qtr) { var month = Math.abs(((qtr-1) * 3) + 1); return this.setMonth(month, 1); }; $P.getQuarter = function () { return Date.getQuarter(this); }; $P.getDaysLeftInQuarter = function () { return Date.getDaysLeftInQuarter(this); }; /** * Moves the date to the next n'th occurrence of the dayOfWeek starting from the beginning of the month. The number (-1) is a magic number and will return the last occurrence of the dayOfWeek in the month. * @param {Number} The dayOfWeek to move to * @param {Number} The n'th occurrence to move to. Use (-1) to return the last occurrence in the month * @return {Date} this */ $P.moveToNthOccurrence = function (dayOfWeek, occurrence) { if (dayOfWeek === "Weekday") { if (occurrence > 0) { this.moveToFirstDayOfMonth(); if (this.is().weekday()) { occurrence -= 1; } } else if (occurrence < 0) { this.moveToLastDayOfMonth(); if (this.is().weekday()) { occurrence += 1; } } else { return this; } return this.addWeekdays(occurrence); } var shift = 0; if (occurrence > 0) { shift = occurrence - 1; } else if (occurrence === -1) { this.moveToLastDayOfMonth(); if (this.getDay() !== dayOfWeek) { this.moveToDayOfWeek(dayOfWeek, -1); } return this; } return this.moveToFirstDayOfMonth().addDays(-1).moveToDayOfWeek(dayOfWeek, +1).addWeeks(shift); }; var moveToN = function (getFunc, addFunc, nVal) { return function (value, orient) { var diff = (value - this[getFunc]() + nVal * (orient || +1)) % nVal; return this[addFunc]((diff === 0) ? diff += nVal * (orient || +1) : diff); }; }; /** * Move to the next or last dayOfWeek based on the orient value. * @param {Number} The dayOfWeek to move to * @param {Number} Forward (+1) or Back (-1). Defaults to +1. [Optional] * @return {Date} this */ $P.moveToDayOfWeek = moveToN("getDay", "addDays", 7); /** * Move to the next or last month based on the orient value. * @param {Number} The month to move to. 0 = January, 11 = December * @param {Number} Forward (+1) or Back (-1). Defaults to +1. [Optional] * @return {Date} this */ $P.moveToMonth = moveToN("getMonth", "addMonths", 12); /** * Get the Ordinate of the current day ("th", "st", "rd"). * @return {String} */ $P.getOrdinate = function () { var num = this.getDate(); return ord(num); }; /** * Get the Ordinal day (numeric day number) of the year, adjusted for leap year. * @return {Number} 1 through 365 (366 in leap years) */ $P.getOrdinalNumber = function () { return Math.ceil((this.clone().clearTime() - new Date(this.getFullYear(), 0, 1)) / 86400000) + 1; }; /** * Get the time zone abbreviation of the current date. * @return {String} The abbreviated time zone name (e.g. "EST") */ $P.getTimezone = function () { return $D.getTimezoneAbbreviation(this.getUTCOffset(), this.isDaylightSavingTime()); }; $P.setTimezoneOffset = function (offset) { var here = this.getTimezoneOffset(), there = Number(offset) * -6 / 10; return (there || there === 0) ? this.addMinutes(there - here) : this; }; $P.setTimezone = function (offset) { return this.setTimezoneOffset($D.getTimezoneOffset(offset)); }; /** * Indicates whether Daylight Saving Time is observed in the current time zone. * @return {Boolean} true|false */ $P.hasDaylightSavingTime = function () { return (Date.today().set({month: 0, day: 1}).getTimezoneOffset() !== Date.today().set({month: 6, day: 1}).getTimezoneOffset()); }; /** * Indicates whether this Date instance is within the Daylight Saving Time range for the current time zone. * @return {Boolean} true|false */ $P.isDaylightSavingTime = function () { return Date.today().set({month: 0, day: 1}).getTimezoneOffset() !== this.getTimezoneOffset(); }; /** * Get the offset from UTC of the current date. * @return {String} The 4-character offset string prefixed with + or - (e.g. "-0500") */ $P.getUTCOffset = function (offset) { var n = (offset || this.getTimezoneOffset()) * -10 / 6, r; if (n < 0) { r = (n - 10000).toString(); return r.charAt(0) + r.substr(2); } else { r = (n + 10000).toString(); return "+" + r.substr(1); } }; /** * Returns the number of milliseconds between this date and date. * @param {Date} Defaults to now * @return {Number} The diff in milliseconds */ $P.getElapsed = function (date) { return (date || new Date()) - this; }; /** * Set the value of year, month, day, hour, minute, second, millisecond of date instance using given configuration object. * Example

	Date.today().set( { day: 20, month: 1 } )

	new Date().set( { millisecond: 0 } )
	
* * @param {Object} Configuration object containing attributes (month, day, etc.) * @return {Date} this */ $P.set = function (config) { config = validateConfigObject.call(this, config); var key; for (key in config) { if (Object.prototype.hasOwnProperty.call(config, key)) { var name = key.charAt(0).toUpperCase() + key.slice(1); var addFunc, getFunc; if (key !== "week" && key !== "month" && key !== "timezone" && key !== "timezoneOffset") { name += "s"; } addFunc = "add" + name; getFunc = "get" + name; if (key === "month") { addFunc = addFunc + "s"; } else if (key === "year"){ getFunc = "getFullYear"; } if (key !== "day" && key !== "timezone" && key !== "timezoneOffset" && key !== "week" && key !== "hour") { this[addFunc](config[key] - this[getFunc]()); } else if ( key === "timezone"|| key === "timezoneOffset" || key === "week" || key === "hour") { this["set"+name](config[key]); } } } // day has to go last because you can't validate the day without first knowing the month if (config.day) { this.addDays(config.day - this.getDate()); } return this; }; /** * Moves the date to the first day of the month. * @return {Date} this */ $P.moveToFirstDayOfMonth = function () { return this.set({ day: 1 }); }; /** * Moves the date to the last day of the month. * @return {Date} this */ $P.moveToLastDayOfMonth = function () { return this.set({ day: $D.getDaysInMonth(this.getFullYear(), this.getMonth())}); }; /** * Converts the value of the current Date object to its equivalent string representation. * Format Specifiers * CUSTOM DATE AND TIME FORMAT STRINGS * Format Description Example * ------ --------------------------------------------------------------------------- ----------------------- * s The seconds of the minute between 0-59. "0" to "59" * ss The seconds of the minute with leading zero if required. "00" to "59" * * m The minute of the hour between 0-59. "0" or "59" * mm The minute of the hour with leading zero if required. "00" or "59" * * h The hour of the day between 1-12. "1" to "12" * hh The hour of the day with leading zero if required. "01" to "12" * * H The hour of the day between 0-23. "0" to "23" * HH The hour of the day with leading zero if required. "00" to "23" * * d The day of the month between 1 and 31. "1" to "31" * dd The day of the month with leading zero if required. "01" to "31" * ddd Abbreviated day name. Date.CultureInfo.abbreviatedDayNames. "Mon" to "Sun" * dddd The full day name. Date.CultureInfo.dayNames. "Monday" to "Sunday" * * M The month of the year between 1-12. "1" to "12" * MM The month of the year with leading zero if required. "01" to "12" * MMM Abbreviated month name. Date.CultureInfo.abbreviatedMonthNames. "Jan" to "Dec" * MMMM The full month name. Date.CultureInfo.monthNames. "January" to "December" * * yy The year as a two-digit number. "99" or "08" * yyyy The full four digit year. "1999" or "2008" * * t Displays the first character of the A.M./P.M. designator. "A" or "P" * Date.CultureInfo.amDesignator or Date.CultureInfo.pmDesignator * tt Displays the A.M./P.M. designator. "AM" or "PM" * Date.CultureInfo.amDesignator or Date.CultureInfo.pmDesignator * * S The ordinal suffix ("st, "nd", "rd" or "th") of the current day. "st, "nd", "rd" or "th" * * STANDARD DATE AND TIME FORMAT STRINGS * Format Description Example *------ --------------------------------------------------------------------------- ----------------------- * d The CultureInfo shortDate Format Pattern "M/d/yyyy" * D The CultureInfo longDate Format Pattern "dddd, MMMM dd, yyyy" * F The CultureInfo fullDateTime Format Pattern "dddd, MMMM dd, yyyy h:mm:ss tt" * m The CultureInfo monthDay Format Pattern "MMMM dd" * r The CultureInfo rfc1123 Format Pattern "ddd, dd MMM yyyy HH:mm:ss GMT" * s The CultureInfo sortableDateTime Format Pattern "yyyy-MM-ddTHH:mm:ss" * t The CultureInfo shortTime Format Pattern "h:mm tt" * T The CultureInfo longTime Format Pattern "h:mm:ss tt" * u The CultureInfo universalSortableDateTime Format Pattern "yyyy-MM-dd HH:mm:ssZ" * y The CultureInfo yearMonth Format Pattern "MMMM, yyyy" * * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @return {String} A string representation of the current Date object. */ var ord = function (n) { switch (n * 1) { case 1: case 21: case 31: return "st"; case 2: case 22: return "nd"; case 3: case 23: return "rd"; default: return "th"; } }; var parseStandardFormats = function (format) { var y, c = Date.CultureInfo.formatPatterns; switch (format) { case "d": return this.toString(c.shortDate); case "D": return this.toString(c.longDate); case "F": return this.toString(c.fullDateTime); case "m": return this.toString(c.monthDay); case "r": case "R": y = this.clone().addMinutes(this.getTimezoneOffset()); return y.toString(c.rfc1123) + " GMT"; case "s": return this.toString(c.sortableDateTime); case "t": return this.toString(c.shortTime); case "T": return this.toString(c.longTime); case "u": y = this.clone().addMinutes(this.getTimezoneOffset()); return y.toString(c.universalSortableDateTime); case "y": return this.toString(c.yearMonth); default: return false; } }; var parseFormatStringsClosure = function (context) { return function (m) { if (m.charAt(0) === "\\") { return m.replace("\\", ""); } switch (m) { case "hh": return p(context.getHours() < 13 ? (context.getHours() === 0 ? 12 : context.getHours()) : (context.getHours() - 12)); case "h": return context.getHours() < 13 ? (context.getHours() === 0 ? 12 : context.getHours()) : (context.getHours() - 12); case "HH": return p(context.getHours()); case "H": return context.getHours(); case "mm": return p(context.getMinutes()); case "m": return context.getMinutes(); case "ss": return p(context.getSeconds()); case "s": return context.getSeconds(); case "yyyy": return p(context.getFullYear(), 4); case "yy": return p(context.getFullYear()); case "y": return context.getFullYear(); case "E": case "dddd": return Date.CultureInfo.dayNames[context.getDay()]; case "ddd": return Date.CultureInfo.abbreviatedDayNames[context.getDay()]; case "dd": return p(context.getDate()); case "d": return context.getDate(); case "MMMM": return Date.CultureInfo.monthNames[context.getMonth()]; case "MMM": return Date.CultureInfo.abbreviatedMonthNames[context.getMonth()]; case "MM": return p((context.getMonth() + 1)); case "M": return context.getMonth() + 1; case "t": return context.getHours() < 12 ? Date.CultureInfo.amDesignator.substring(0, 1) : Date.CultureInfo.pmDesignator.substring(0, 1); case "tt": return context.getHours() < 12 ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator; case "S": return ord(context.getDate()); case "W": return context.getWeek(); case "WW": return context.getISOWeek(); case "Q": return "Q" + context.getQuarter(); case "q": return String(context.getQuarter()); case "z": return context.getTimezone(); case "Z": case "X": return Date.getTimezoneOffset(context.getTimezone()); case "ZZ": // Timezone offset in seconds return context.getTimezoneOffset() * -60; case "u": return context.getDay(); case "L": return ($D.isLeapYear(context.getFullYear())) ? 1 : 0; case "B": // Swatch Internet Time (.beats) return "@"+((context.getUTCSeconds() + (context.getUTCMinutes()*60) + ((context.getUTCHours()+1)*3600))/86.4); default: return m; } }; }; $P.toString = function (format, ignoreStandards) { // Standard Date and Time Format Strings. Formats pulled from CultureInfo file and // may vary by culture. if (!ignoreStandards && format && format.length === 1) { output = parseStandardFormats.call(this, format); if (output) { return output; } } var parseFormatStrings = parseFormatStringsClosure(this); return format ? format.replace(/((\\)?(dd?d?d?|MM?M?M?|yy?y?y?|hh?|HH?|mm?|ss?|tt?|S|q|Q|WW?W?W?)(?![^\[]*\]))/g, parseFormatStrings).replace(/\[|\]/g, "") : this._toString(); }; }()); /************************************************************* * SugarPak - Domain Specific Language - Syntactical Sugar * *************************************************************/ (function () { var $D = Date, $P = $D.prototype, $N = Number.prototype; // private $P._orient = +1; // private $P._nth = null; // private $P._is = false; // private $P._same = false; // private $P._isSecond = false; // private $N._dateElement = "days"; /** * Moves the date to the next instance of a date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.today().next().friday();
	Date.today().next().fri();
	Date.today().next().march();
	Date.today().next().mar();
	Date.today().next().week();
	
* * @return {Date} date */ $P.next = function () { this._move = true; this._orient = +1; return this; }; /** * Creates a new Date (Date.today()) and moves the date to the next instance of the date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.next().friday();
	Date.next().fri();
	Date.next().march();
	Date.next().mar();
	Date.next().week();
	
* * @return {Date} date */ $D.next = function () { return $D.today().next(); }; /** * Moves the date to the previous instance of a date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.today().last().friday();
	Date.today().last().fri();
	Date.today().last().march();
	Date.today().last().mar();
	Date.today().last().week();
	
* * @return {Date} date */ $P.last = $P.prev = $P.previous = function () { this._move = true; this._orient = -1; return this; }; /** * Creates a new Date (Date.today()) and moves the date to the previous instance of the date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.last().friday();
	Date.last().fri();
	Date.previous().march();
	Date.prev().mar();
	Date.last().week();
	
* * @return {Date} date */ $D.last = $D.prev = $D.previous = function () { return $D.today().last(); }; /** * Performs a equality check when followed by either a month name, day name or .weekday() function. * Example

	Date.today().is().friday(); // true|false
	Date.today().is().fri();
	Date.today().is().march();
	Date.today().is().mar();
	
* * @return {Boolean} true|false */ $P.is = function () { this._is = true; return this; }; /** * Determines if two date objects occur on/in exactly the same instance of the subsequent date part function. * The function .same() must be followed by a date part function (example: .day(), .month(), .year(), etc). * * An optional Date can be passed in the date part function. If now date is passed as a parameter, 'Now' is used. * * The following example demonstrates how to determine if two dates fall on the exact same day. * * Example

	var d1 = Date.today(); // today at 00:00
	var d2 = new Date();   // exactly now.

	// Do they occur on the same day?
	d1.same().day(d2); // true
	
	// Do they occur on the same hour?
	d1.same().hour(d2); // false, unless d2 hour is '00' (midnight).
	
	// What if it's the same day, but one year apart?
	var nextYear = Date.today().add(1).year();

	d1.same().day(nextYear); // false, because the dates must occur on the exact same day. 
	
* * Scenario: Determine if a given date occurs during some week period 2 months from now. * * Example

	var future = Date.today().add(2).months();
	return someDate.same().week(future); // true|false;
	
* * @return {Boolean} true|false */ $P.same = function () { this._same = true; this._isSecond = false; return this; }; /** * Determines if the current date/time occurs during Today. Must be preceded by the .is() function. * Example

	someDate.is().today();    // true|false
	new Date().is().today();  // true
	Date.today().is().today();// true
	Date.today().add(-1).day().is().today(); // false
	
* * @return {Boolean} true|false */ $P.today = function () { return this.same().day(); }; /** * Determines if the current date is a weekday. This function must be preceded by the .is() function. * Example

	Date.today().is().weekday(); // true|false
	
* * @return {Boolean} true|false */ $P.weekday = function () { if (this._nth) { return df("Weekday").call(this); } if (this._move) { return this.addWeekdays(this._orient); } if (this._is) { this._is = false; return (!this.is().sat() && !this.is().sun()); } return false; }; /** * Determines if the current date is on the weekend. This function must be preceded by the .is() function. * Example

	Date.today().is().weekend(); // true|false
	
* * @return {Boolean} true|false */ $P.weekend = function () { if (this._is) { this._is = false; return (this.is().sat() || this.is().sun()); } return false; }; /** * Sets the Time of the current Date instance. A string "6:15 pm" or config object {hour:18, minute:15} are accepted. * Example

	// Set time to 6:15pm with a String
	Date.today().at("6:15pm");

	// Set time to 6:15pm with a config object
	Date.today().at({hour:18, minute:15});
	
* * @return {Date} date */ $P.at = function (time) { return (typeof time === "string") ? $D.parse(this.toString("d") + " " + time) : this.set(time); }; /** * Creates a new Date() and adds this (Number) to the date based on the preceding date element function (eg. second|minute|hour|day|month|year). * Example

	// Undeclared Numbers must be wrapped with parentheses. Requirment of JavaScript.
	(3).days().fromNow();
	(6).months().fromNow();

	// Declared Number variables do not require parentheses. 
	var n = 6;
	n.months().fromNow();
	
* * @return {Date} A new Date instance */ $N.fromNow = $N.after = function (date) { var c = {}; c[this._dateElement] = this; return ((!date) ? new Date() : date.clone()).add(c); }; /** * Creates a new Date() and subtract this (Number) from the date based on the preceding date element function (eg. second|minute|hour|day|month|year). * Example

	// Undeclared Numbers must be wrapped with parentheses. Requirment of JavaScript.
	(3).days().ago();
	(6).months().ago();

	// Declared Number variables do not require parentheses. 
	var n = 6;
	n.months().ago();
	
* * @return {Date} A new Date instance */ $N.ago = $N.before = function (date) { var c = {}, s = (this._dateElement[this._dateElement.length-1] !== "s") ? this._dateElement + "s" : this._dateElement; c[s] = this * -1; return ((!date) ? new Date() : date.clone()).add(c); }; // Do NOT modify the following string tokens. These tokens are used to build dynamic functions. // All culture-specific strings can be found in the CultureInfo files. var dx = ("sunday monday tuesday wednesday thursday friday saturday").split(/\s/), mx = ("january february march april may june july august september october november december").split(/\s/), px = ("Millisecond Second Minute Hour Day Week Month Year Quarter Weekday").split(/\s/), pxf = ("Milliseconds Seconds Minutes Hours Date Week Month FullYear Quarter").split(/\s/), nth = ("final first second third fourth fifth").split(/\s/), de; /** * Returns an object literal of all the date parts. * Example

	var o = new Date().toObject();
	
	// { year: 2008, month: 4, week: 20, day: 13, hour: 18, minute: 9, second: 32, millisecond: 812 }
	
	// The object properties can be referenced directly from the object.
	
	alert(o.day);  // alerts "13"
	alert(o.year); // alerts "2008"
	
* * @return {Date} An object literal representing the original date object. */ $P.toObject = function () { var o = {}; for (var i = 0; i < px.length; i++) { if (this["get" + pxf[i]]) { o[px[i].toLowerCase()] = this["get" + pxf[i]](); } } return o; }; /** * Returns a date created from an object literal. Ignores the .week property if set in the config. * Example

	var o = new Date().toObject();
	
	return Date.fromObject(o); // will return the same date. 

	var o2 = {month: 1, day: 20, hour: 18}; // birthday party!
	Date.fromObject(o2);
	
* * @return {Date} An object literal representing the original date object. */ $D.fromObject = function(config) { config.week = null; return Date.today().set(config); }; // Create day name functions and abbreviated day name functions (eg. monday(), friday(), fri()). var df = function (n) { return function () { if (this._is) { this._is = false; return this.getDay() === n; } if (this._move) { this._move = null; } if (this._nth !== null) { // If the .second() function was called earlier, remove the _orient // from the date, and then continue. // This is required because 'second' can be used in two different context. // // Example // // Date.today().add(1).second(); // Date.march().second().monday(); // // Things get crazy with the following... // Date.march().add(1).second().second().monday(); // but it works!! // if (this._isSecond) { this.addSeconds(this._orient * -1); } // make sure we reset _isSecond this._isSecond = false; var ntemp = this._nth; this._nth = null; var temp = this.clone().moveToLastDayOfMonth(); this.moveToNthOccurrence(n, ntemp); if (this > temp) { throw new RangeError($D.getDayName(n) + " does not occur " + ntemp + " times in the month of " + $D.getMonthName(temp.getMonth()) + " " + temp.getFullYear() + "."); } return this; } return this.moveToDayOfWeek(n, this._orient); }; }; var sdf = function (n) { return function () { var t = $D.today(), shift = n - t.getDay(); if (n === 0 && Date.CultureInfo.firstDayOfWeek === 1 && t.getDay() !== 0) { shift = shift + 7; } return t.addDays(shift); }; }; // Create month name functions and abbreviated month name functions (eg. january(), march(), mar()). var month_instance_functions = function (n) { return function () { if (this._is) { this._is = false; return this.getMonth() === n; } return this.moveToMonth(n, this._orient); }; }; var month_static_functions = function (n) { return function () { return $D.today().set({ month: n, day: 1 }); }; }; var processTerms = function (names, staticFunc, instanceFunc) { for (var i = 0; i < names.length; i++) { // Create constant static Name variables. $D[names[i].toUpperCase()] = $D[names[i].toUpperCase().substring(0, 3)] = i; // Create Name functions. $D[names[i]] = $D[names[i].substring(0, 3)] = staticFunc(i); // Create Name instance functions. $P[names[i]] = $P[names[i].substring(0, 3)] = instanceFunc(i); } }; processTerms(dx, sdf, df); processTerms(mx, month_static_functions, month_instance_functions); // Create date element functions and plural date element functions used with Date (eg. day(), days(), months()). var ef = function (j) { return function () { // if the .second() function was called earlier, the _orient // has alread been added. Just return this and reset _isSecond. if (this._isSecond) { this._isSecond = false; return this; } if (this._same) { this._same = this._is = false; var o1 = this.toObject(), o2 = (arguments[0] || new Date()).toObject(), v = "", k = j.toLowerCase(); // the substr trick with -1 doesn't work in IE8 or less k = (k[k.length-1] === "s") ? k.substring(0,k.length-1) : k; for (var m = (px.length - 1); m > -1; m--) { v = px[m].toLowerCase(); if (o1[v] !== o2[v]) { return false; } if (k === v) { break; } } return true; } if (j.substring(j.length - 1) !== "s") { j += "s"; } if (this._move) { this._move = null; } return this["add" + j](this._orient); }; }; var nf = function (n) { return function () { this._dateElement = n; return this; }; }; for (var k = 0; k < px.length; k++) { de = px[k].toLowerCase(); if(de !== "weekday") { // Create date element functions and plural date element functions used with Date (eg. day(), days(), months()). $P[de] = $P[de + "s"] = ef(px[k]); // Create date element functions and plural date element functions used with Number (eg. day(), days(), months()). $N[de] = $N[de + "s"] = nf(de + "s"); } } $P._ss = ef("Second"); var nthfn = function (n) { return function (dayOfWeek) { if (this._same) { return this._ss(arguments[0]); } if (dayOfWeek || dayOfWeek === 0) { return this.moveToNthOccurrence(dayOfWeek, n); } this._nth = n; // if the operator is 'second' add the _orient, then deal with it later... if (n === 2 && (dayOfWeek === undefined || dayOfWeek === null)) { this._isSecond = true; return this.addSeconds(this._orient); } return this; }; }; for (var l = 0; l < nth.length; l++) { $P[nth[l]] = (l === 0) ? nthfn(-1) : nthfn(l); } }()); (function () { "use strict"; Date.Parsing = { Exception: function (s) { this.message = "Parse error at '" + s.substring(0, 10) + " ...'"; } }; var $P = Date.Parsing; var dayOffsets = { standard: [0,31,59,90,120,151,181,212,243,273,304,334], leap: [0,31,60,91,121,152,182,213,244,274,305,335] }; $P.isLeapYear = function(year) { return ((year % 4 === 0) && (year % 100 !== 0)) || (year % 400 === 0); }; var utils = { multiReplace : function (str, hash ) { var key; for (key in hash) { if (Object.prototype.hasOwnProperty.call(hash, key)) { var regex; if (typeof hash[key] === "function") { } else { regex = (hash[key] instanceof RegExp) ? hash[key] : new RegExp(hash[key], "g"); } str = str.replace(regex, key); } } return str; }, getDayOfYearFromWeek : function (obj) { var d, jan4, offset; obj.weekDay = (!obj.weekDay && obj.weekDay !== 0) ? 1 : obj.weekDay; d = new Date(obj.year, 0, 4); jan4 = d.getDay() === 0 ? 7 : d.getDay(); // JS is 0 indexed on Sunday. offset = jan4+3; obj.dayOfYear = ((obj.week * 7) + (obj.weekDay === 0 ? 7 : obj.weekDay))-offset; return obj; }, getDayOfYear : function (obj, dayOffset) { if (!obj.dayOfYear) { obj = utils.getDayOfYearFromWeek(obj); } for (var i=0;i <= dayOffset.length;i++) { if (obj.dayOfYear < dayOffset[i] || i === dayOffset.length) { obj.day = obj.day ? obj.day : (obj.dayOfYear - dayOffset[i-1]); break; } else { obj.month = i; } } return obj; }, adjustForTimeZone : function (obj, date) { var offset; if (obj.zone.toUpperCase() === "Z" || (obj.zone_hours === 0 && obj.zone_minutes === 0)) { // it's UTC/GML so work out the current timeszone offset offset = -date.getTimezoneOffset(); } else { offset = (obj.zone_hours*60) + (obj.zone_minutes || 0); if (obj.zone_sign === "+") { offset *= -1; } offset -= date.getTimezoneOffset(); } date.setMinutes(date.getMinutes()+offset); return date; }, setDefaults : function (obj) { obj.year = obj.year || Date.today().getFullYear(); obj.hours = obj.hours || 0; obj.minutes = obj.minutes || 0; obj.seconds = obj.seconds || 0; obj.milliseconds = obj.milliseconds || 0; if (!(!obj.month && (obj.week || obj.dayOfYear))) { // if we have a month, or if we don't but don't have the day calculation data obj.month = obj.month || 0; obj.day = obj.day || 1; } return obj; }, dataNum: function (data, mod, explict, postProcess) { var dataNum = data*1; if (mod) { if (postProcess) { return data ? mod(data)*1 : data; } else { return data ? mod(dataNum) : data; } } else if (!explict){ return data ? dataNum : data; } else { return (data && typeof data !== "undefined") ? dataNum : data; } }, timeDataProcess: function (obj) { var timeObj = {}; for (var x in obj.data) { if (obj.data.hasOwnProperty(x)) { timeObj[x] = obj.ignore[x] ? obj.data[x] : utils.dataNum(obj.data[x], obj.mods[x], obj.explict[x], obj.postProcess[x]); } } if (obj.data.secmins) { obj.data.secmins = obj.data.secmins.replace(",", ".") * 60; if (!timeObj.minutes) { timeObj.minutes = obj.data.secmins; } else if (!timeObj.seconds) { timeObj.seconds = obj.data.secmins; } delete obj.secmins; } return timeObj; }, buildTimeObjectFromData: function (data) { var time = utils.timeDataProcess({ data: { year : data[1], month : data[5], day : data[7], week : data[8], dayOfYear : data[10], hours : data[15], zone_hours : data[23], zone_minutes : data[24], zone : data[21], zone_sign : data[22], weekDay : data[9], minutes: data[16], seconds: data[19], milliseconds: data[20], secmins: data[18] }, mods: { month: function(data) { return data-1; }, weekDay: function (data) { data = Math.abs(data); return (data === 7 ? 0 : data); }, minutes: function (data) { return data.replace(":",""); }, seconds: function (data) { return Math.floor( (data.replace(":","").replace(",","."))*1 ); }, milliseconds: function (data) { return (data.replace(",",".")*1000); } }, postProcess: { minutes: true, seconds: true, milliseconds: true }, explict: { zone_hours: true, zone_minutes: true }, ignore: { zone: true, zone_sign: true, secmins: true } }); return time; }, addToHash: function (hash, keys, data) { keys = keys; data = data; var len = keys.length; for (var i = 0; i < len; i++) { hash[keys[i]] = data[i]; } return hash; }, combineRegex: function (r1, r2) { return new RegExp("(("+r1.source+")\\s("+r2.source+"))"); }, getDateNthString: function(add, last, inc){ if (add) { return Date.today().addDays(inc).toString("d"); } else if (last) { return Date.today().last()[inc]().toString("d"); } }, buildRegexData: function (array) { var arr = []; var len = array.length; for (var i=0; i < len; i++) { if (Object.prototype.toString.call(array[i]) === '[object Array]') { // oldIE compat version of Array.isArray arr.push(this.combineRegex(array[i][0], array[i][1])); } else { arr.push(array[i]); } } return arr; } }; $P.processTimeObject = function (obj) { var date, dayOffset; utils.setDefaults(obj); dayOffset = ($P.isLeapYear(obj.year)) ? dayOffsets.leap : dayOffsets.standard; if (!obj.month && (obj.week || obj.dayOfYear)) { utils.getDayOfYear(obj, dayOffset); } else { obj.dayOfYear = dayOffset[obj.month] + obj.day; } date = new Date(obj.year, obj.month, obj.day, obj.hours, obj.minutes, obj.seconds, obj.milliseconds); if (obj.zone) { utils.adjustForTimeZone(obj, date); // adjust (and calculate) for timezone } return date; }; $P.ISO = { regex : /^([\+-]?\d{4}(?!\d{2}\b))((-?)((0[1-9]|1[0-2])(\3([12]\d|0[1-9]|3[01]))?|W([0-4]\d|5[0-3])(-?[1-7])?|(00[1-9]|0[1-9]\d|[12]\d{2}|3([0-5]\d|6[1-6])))([T\s]((([01]\d|2[0-4])((:?)[0-5]\d)?|24\:?00)([\.,]\d+(?!:))?)?(\17[0-5]\d([\.,]\d+)?)?\s?([zZ]|([\+-])([01]\d|2[0-3]):?([0-5]\d)?)?)?)?$/, parse : function (s) { var time, data = s.match(this.regex); if (!data || !data.length) { return null; } time = utils.buildTimeObjectFromData(data); if (!time.year || (!time.year && (!time.month && !time.day) && (!time.week && !time.dayOfYear)) ) { return null; } return $P.processTimeObject(time); } }; $P.Numeric = { isNumeric: function (e){return!isNaN(parseFloat(e))&&isFinite(e);}, regex: /\b([0-1]?[0-9])([0-3]?[0-9])([0-2]?[0-9]?[0-9][0-9])\b/i, parse: function (s) { var data, i, time = {}, order = Date.CultureInfo.dateElementOrder.split(""); if (!(this.isNumeric(s)) || // if it's non-numeric OR (s[0] === "+" && s[0] === "-")) { // It's an arithmatic string (eg +/-1000) return null; } if (s.length < 5 && s.indexOf(".") < 0 && s.indexOf("/") < 0) { // assume it's just a year. time.year = s; return $P.processTimeObject(time); } data = s.match(this.regex); if (!data || !data.length) { return null; } for (i=0; i < order.length; i++) { switch(order[i]) { case "d": time.day = data[i+1]; break; case "m": time.month = (data[i+1]-1); break; case "y": time.year = data[i+1]; break; } } return $P.processTimeObject(time); } }; $P.Normalizer = { regexData: function () { var $R = Date.CultureInfo.regexPatterns; return utils.buildRegexData([ $R.tomorrow, $R.yesterday, [$R.past, $R.mon], [$R.past, $R.tue], [$R.past, $R.wed], [$R.past, $R.thu], [$R.past, $R.fri], [$R.past, $R.sat], [$R.past, $R.sun] ]); }, basicReplaceHash : function() { var $R = Date.CultureInfo.regexPatterns; return { "January": $R.jan.source, "February": $R.feb, "March": $R.mar, "April": $R.apr, "May": $R.may, "June": $R.jun, "July": $R.jul, "August": $R.aug, "September": $R.sep, "October": $R.oct, "November": $R.nov, "December": $R.dec, "": /\bat\b/gi, " ": /\s{2,}/, "am": $R.inTheMorning, "9am": $R.thisMorning, "pm": $R.inTheEvening, "7pm":$R.thisEvening }; }, keys : function(){ return [ utils.getDateNthString(true, false, 1), // tomorrow utils.getDateNthString(true, false, -1), // yesterday utils.getDateNthString(false, true, "monday"), //last mon utils.getDateNthString(false, true, "tuesday"), //last tues utils.getDateNthString(false, true, "wednesday"), //last wed utils.getDateNthString(false, true, "thursday"), //last thurs utils.getDateNthString(false, true, "friday"), //last fri utils.getDateNthString(false, true, "saturday"), //last sat utils.getDateNthString(false, true, "sunday") //last sun ]; }, buildRegexFunctions: function () { var $R = Date.CultureInfo.regexPatterns; var __ = Date.i18n.__; var tomorrowRE = new RegExp("(\\b\\d\\d?("+__("AM")+"|"+__("PM")+")? )("+$R.tomorrow.source.slice(1)+")", "i"); // adapted tomorrow regex for AM PM relative dates var todayRE = new RegExp($R.today.source + "(?!\\s*([+-]))\\b"); // today, but excludes the math operators (eg "today + 2h") this.replaceFuncs = [ [todayRE, function (full) { return (full.length > 1) ? Date.today().toString("d") : full; }], [tomorrowRE, function(full, m1) { var t = Date.today().addDays(1).toString("d"); return (t + " " + m1); }], [$R.amThisMorning, function(str, am){return am;}], [$R.pmThisEvening, function(str, pm){return pm;}] ]; }, buildReplaceData: function () { this.buildRegexFunctions(); this.replaceHash = utils.addToHash(this.basicReplaceHash(), this.keys(), this.regexData()); }, stringReplaceFuncs: function (s) { for (var i=0; i < this.replaceFuncs.length; i++) { s = s.replace(this.replaceFuncs[i][0], this.replaceFuncs[i][1]); } return s; }, parse: function (s) { s = this.stringReplaceFuncs(s); s = utils.multiReplace(s, this.replaceHash); try { var n = s.split(/([\s\-\.\,\/\x27]+)/); if (n.length === 3 && $P.Numeric.isNumeric(n[0]) && $P.Numeric.isNumeric(n[2]) && (n[2].length >= 4)) { // ok, so we're dealing with x/year. But that's not a full date. // This fixes wonky dateElementOrder parsing when set to dmy order. if (Date.CultureInfo.dateElementOrder[0] === "d") { s = "1/" + n[0] + "/" + n[2]; // set to 1st of month and normalize the seperator } } } catch (e) {} return s; } }; $P.Normalizer.buildReplaceData(); }()); (function () { var $P = Date.Parsing; var _ = $P.Operators = { // // Tokenizers // rtoken: function (r) { // regex token return function (s) { var mx = s.match(r); if (mx) { return ([ mx[0], s.substring(mx[0].length) ]); } else { throw new $P.Exception(s); } }; }, token: function () { // whitespace-eating token return function (s) { return _.rtoken(new RegExp("^\\s*" + s + "\\s*"))(s); }; }, stoken: function (s) { // string token return _.rtoken(new RegExp("^" + s)); }, // Atomic Operators until: function (p) { return function (s) { var qx = [], rx = null; while (s.length) { try { rx = p.call(this, s); } catch (e) { qx.push(rx[0]); s = rx[1]; continue; } break; } return [ qx, s ]; }; }, many: function (p) { return function (s) { var rx = [], r = null; while (s.length) { try { r = p.call(this, s); } catch (e) { return [ rx, s ]; } rx.push(r[0]); s = r[1]; } return [ rx, s ]; }; }, // generator operators -- see below optional: function (p) { return function (s) { var r = null; try { r = p.call(this, s); } catch (e) { return [ null, s ]; } return [ r[0], r[1] ]; }; }, not: function (p) { return function (s) { try { p.call(this, s); } catch (e) { return [null, s]; } throw new $P.Exception(s); }; }, ignore: function (p) { return p ? function (s) { var r = null; r = p.call(this, s); return [null, r[1]]; } : null; }, product: function () { var px = arguments[0], qx = Array.prototype.slice.call(arguments, 1), rx = []; for (var i = 0 ; i < px.length ; i++) { rx.push(_.each(px[i], qx)); } return rx; }, cache: function (rule) { var cache = {}, cache_length = 0, cache_keys = [], CACHE_MAX = Date.Config.CACHE_MAX || 100000, r = null; var cacheCheck = function () { if (cache_length === CACHE_MAX) { // kill several keys, don't want to have to do this all the time... for (var i=0; i < 10; i++) { var key = cache_keys.shift(); if (key) { delete cache[key]; cache_length--; } } } }; return function (s) { cacheCheck(); try { r = cache[s] = (cache[s] || rule.call(this, s)); } catch (e) { r = cache[s] = e; } cache_length++; cache_keys.push(s); if (r instanceof $P.Exception) { throw r; } else { return r; } }; }, // vector operators -- see below any: function () { var px = arguments; return function (s) { var r = null; for (var i = 0; i < px.length; i++) { if (px[i] == null) { continue; } try { r = (px[i].call(this, s)); } catch (e) { r = null; } if (r) { return r; } } throw new $P.Exception(s); }; }, each: function () { var px = arguments; return function (s) { var rx = [], r = null; for (var i = 0; i < px.length ; i++) { if (px[i] == null) { continue; } try { r = (px[i].call(this, s)); } catch (e) { throw new $P.Exception(s); } rx.push(r[0]); s = r[1]; } return [ rx, s]; }; }, all: function () { var px = arguments, _ = _; return _.each(_.optional(px)); }, // delimited operators sequence: function (px, d, c) { d = d || _.rtoken(/^\s*/); c = c || null; if (px.length === 1) { return px[0]; } return function (s) { var r = null, q = null; var rx = []; for (var i = 0; i < px.length ; i++) { try { r = px[i].call(this, s); } catch (e) { break; } rx.push(r[0]); try { q = d.call(this, r[1]); } catch (ex) { q = null; break; } s = q[1]; } if (!r) { throw new $P.Exception(s); } if (q) { throw new $P.Exception(q[1]); } if (c) { try { r = c.call(this, r[1]); } catch (ey) { throw new $P.Exception(r[1]); } } return [ rx, (r?r[1]:s) ]; }; }, // // Composite Operators // between: function (d1, p, d2) { d2 = d2 || d1; var _fn = _.each(_.ignore(d1), p, _.ignore(d2)); return function (s) { var rx = _fn.call(this, s); return [[rx[0][0], r[0][2]], rx[1]]; }; }, list: function (p, d, c) { d = d || _.rtoken(/^\s*/); c = c || null; return (p instanceof Array ? _.each(_.product(p.slice(0, -1), _.ignore(d)), p.slice(-1), _.ignore(c)) : _.each(_.many(_.each(p, _.ignore(d))), px, _.ignore(c))); }, set: function (px, d, c) { d = d || _.rtoken(/^\s*/); c = c || null; return function (s) { // r is the current match, best the current 'best' match // which means it parsed the most amount of input var r = null, p = null, q = null, rx = null, best = [[], s], last = false; // go through the rules in the given set for (var i = 0; i < px.length ; i++) { // last is a flag indicating whether this must be the last element // if there is only 1 element, then it MUST be the last one q = null; p = null; r = null; last = (px.length === 1); // first, we try simply to match the current pattern // if not, try the next pattern try { r = px[i].call(this, s); } catch (e) { continue; } // since we are matching against a set of elements, the first // thing to do is to add r[0] to matched elements rx = [[r[0]], r[1]]; // if we matched and there is still input to parse and // we don't already know this is the last element, // we're going to next check for the delimiter ... // if there's none, or if there's no input left to parse // than this must be the last element after all ... if (r[1].length > 0 && ! last) { try { q = d.call(this, r[1]); } catch (ex) { last = true; } } else { last = true; } // if we parsed the delimiter and now there's no more input, // that means we shouldn't have parsed the delimiter at all // so don't update r and mark this as the last element ... if (!last && q[1].length === 0) { last = true; } // so, if this isn't the last element, we're going to see if // we can get any more matches from the remaining (unmatched) // elements ... if (!last) { // build a list of the remaining rules we can match against, // i.e., all but the one we just matched against var qx = []; for (var j = 0; j < px.length ; j++) { if (i !== j) { qx.push(px[j]); } } // now invoke recursively set with the remaining input // note that we don't include the closing delimiter ... // we'll check for that ourselves at the end p = _.set(qx, d).call(this, q[1]); // if we got a non-empty set as a result ... // (otw rx already contains everything we want to match) if (p[0].length > 0) { // update current result, which is stored in rx ... // basically, pick up the remaining text from p[1] // and concat the result from p[0] so that we don't // get endless nesting ... rx[0] = rx[0].concat(p[0]); rx[1] = p[1]; } } // at this point, rx either contains the last matched element // or the entire matched set that starts with this element. // now we just check to see if this variation is better than // our best so far, in terms of how much of the input is parsed if (rx[1].length < best[1].length) { best = rx; } // if we've parsed all the input, then we're finished if (best[1].length === 0) { break; } } // so now we've either gone through all the patterns trying them // as the initial match; or we found one that parsed the entire // input string ... // if best has no matches, just return empty set ... if (best[0].length === 0) { return best; } // if a closing delimiter is provided, then we have to check it also if (c) { // we try this even if there is no remaining input because the pattern // may well be optional or match empty input ... try { q = c.call(this, best[1]); } catch (ey) { throw new $P.Exception(best[1]); } // it parsed ... be sure to update the best match remaining input best[1] = q[1]; } // if we're here, either there was no closing delimiter or we parsed it // so now we have the best match; just return it! return best; }; }, forward: function (gr, fname) { return function (s) { return gr[fname].call(this, s); }; }, // // Translation Operators // replace: function (rule, repl) { return function (s) { var r = rule.call(this, s); return [repl, r[1]]; }; }, process: function (rule, fn) { return function (s) { var r = rule.call(this, s); return [fn.call(this, r[0]), r[1]]; }; }, min: function (min, rule) { return function (s) { var rx = rule.call(this, s); if (rx[0].length < min) { throw new $P.Exception(s); } return rx; }; } }; // Generator Operators And Vector Operators // Generators are operators that have a signature of F(R) => R, // taking a given rule and returning another rule, such as // ignore, which parses a given rule and throws away the result. // Vector operators are those that have a signature of F(R1,R2,...) => R, // take a list of rules and returning a new rule, such as each. // Generator operators are converted (via the following _generator // function) into functions that can also take a list or array of rules // and return an array of new rules as though the function had been // called on each rule in turn (which is what actually happens). // This allows generators to be used with vector operators more easily. // Example: // each(ignore(foo, bar)) instead of each(ignore(foo), ignore(bar)) // This also turns generators into vector operators, which allows // constructs like: // not(cache(foo, bar)) var _generator = function (op) { function gen() { var args = null, rx = [], px, i; if (arguments.length > 1) { args = Array.prototype.slice.call(arguments); } else if (arguments[0] instanceof Array) { args = arguments[0]; } if (args) { px = args.shift(); if (px.length > 0) { args.unshift(px[i]); rx.push(op.apply(null, args)); args.shift(); return rx; } } else { return op.apply(null, arguments); } } return gen; }; var gx = "optional not ignore cache".split(/\s/); for (var i = 0 ; i < gx.length ; i++) { _[gx[i]] = _generator(_[gx[i]]); } var _vector = function (op) { return function () { if (arguments[0] instanceof Array) { return op.apply(null, arguments[0]); } else { return op.apply(null, arguments); } }; }; var vx = "each any all".split(/\s/); for (var j = 0 ; j < vx.length ; j++) { _[vx[j]] = _vector(_[vx[j]]); } }()); (function () { var $D = Date; var flattenAndCompact = function (ax) { var rx = []; for (var i = 0; i < ax.length; i++) { if (ax[i] instanceof Array) { rx = rx.concat(flattenAndCompact(ax[i])); } else { if (ax[i]) { rx.push(ax[i]); } } } return rx; }; var parseMeridian = function () { if (this.meridian && (this.hour || this.hour === 0)) { if (this.meridian === "a" && this.hour > 11 && Date.Config.strict24hr){ throw "Invalid hour and meridian combination"; } else if (this.meridian === "p" && this.hour < 12 && Date.Config.strict24hr){ throw "Invalid hour and meridian combination"; } else if (this.meridian === "p" && this.hour < 12) { this.hour = this.hour + 12; } else if (this.meridian === "a" && this.hour === 12) { this.hour = 0; } } }; var setDefaults = function () { var now = new Date(); if ((this.hour || this.minute) && (!this.month && !this.year && !this.day)) { this.day = now.getDate(); } if (!this.year) { this.year = now.getFullYear(); } if (!this.month && this.month !== 0) { this.month = now.getMonth(); } if (!this.day) { this.day = 1; } if (!this.hour) { this.hour = 0; } if (!this.minute) { this.minute = 0; } if (!this.second) { this.second = 0; } if (!this.millisecond) { this.millisecond = 0; } }; var finishUtils = { getToday: function () { if (this.now || "hour minute second".indexOf(this.unit) !== -1) { return new Date(); } else { return $D.today(); } }, setDaysFromWeekday: function (today, orient){ var gap; orient = orient || 1; this.unit = "day"; gap = ($D.getDayNumberFromName(this.weekday) - today.getDay()); this.days = gap ? ((gap + (orient * 7)) % 7) : (orient * 7); return this; }, setMonthsFromMonth: function (today, orient) { var gap; orient = orient || 1; this.unit = "month"; gap = (this.month - today.getMonth()); this.months = gap ? ((gap + (orient * 12)) % 12) : (orient * 12); this.month = null; return this; }, setDMYFromWeekday: function () { var d = Date[this.weekday](); this.day = d.getDate(); if (!this.month) { this.month = d.getMonth(); } this.year = d.getFullYear(); return this; }, setUnitValue: function (orient) { if (!this.value && this.operator && this.operator !== null && this[this.unit + "s"] && this[this.unit + "s"] !== null) { this[this.unit + "s"] = this[this.unit + "s"] + ((this.operator === "add") ? 1 : -1) + (this.value||0) * orient; } else if (this[this.unit + "s"] == null || this.operator != null) { if (!this.value) { this.value = 1; } this[this.unit + "s"] = this.value * orient; } }, generateDateFromWeeks: function () { var weekday = (this.weekday !== undefined) ? this.weekday : "today"; var d = Date[weekday]().addWeeks(this.weeks); if (this.now) { d.setTimeToNow(); } return d; } }; $D.Translator = { hour: function (s) { return function () { this.hour = Number(s); }; }, minute: function (s) { return function () { this.minute = Number(s); }; }, second: function (s) { return function () { this.second = Number(s); }; }, /* for ss.s format */ secondAndMillisecond: function (s) { return function () { var mx = s.match(/^([0-5][0-9])\.([0-9]{1,3})/); this.second = Number(mx[1]); this.millisecond = Number(mx[2]); }; }, meridian: function (s) { return function () { this.meridian = s.slice(0, 1).toLowerCase(); }; }, timezone: function (s) { return function () { var n = s.replace(/[^\d\+\-]/g, ""); if (n.length) { this.timezoneOffset = Number(n); } else { this.timezone = s.toLowerCase(); } }; }, day: function (x) { var s = x[0]; return function () { this.day = Number(s.match(/\d+/)[0]); if (this.day < 1) { throw "invalid day"; } }; }, month: function (s) { return function () { this.month = (s.length === 3) ? "jan feb mar apr may jun jul aug sep oct nov dec".indexOf(s)/4 : Number(s) - 1; if (this.month < 0) { throw "invalid month"; } }; }, year: function (s) { return function () { var n = Number(s); this.year = ((s.length > 2) ? n : (n + (((n + 2000) < Date.CultureInfo.twoDigitYearMax) ? 2000 : 1900))); }; }, rday: function (s) { return function () { switch (s) { case "yesterday": this.days = -1; break; case "tomorrow": this.days = 1; break; case "today": this.days = 0; break; case "now": this.days = 0; this.now = true; break; } }; }, finishExact: function (x) { var d; x = (x instanceof Array) ? x : [x]; for (var i = 0 ; i < x.length ; i++) { if (x[i]) { x[i].call(this); } } setDefaults.call(this); parseMeridian.call(this); if (this.day > $D.getDaysInMonth(this.year, this.month)) { throw new RangeError(this.day + " is not a valid value for days."); } d = new Date(this.year, this.month, this.day, this.hour, this.minute, this.second, this.millisecond); if (this.year < 100) { d.setFullYear(this.year); // means years less that 100 are process correctly. JS will parse it otherwise as 1900-1999. } if (this.timezone) { d.set({ timezone: this.timezone }); } else if (this.timezoneOffset) { d.set({ timezoneOffset: this.timezoneOffset }); } return d; }, finish: function (x) { var today, expression, orient, temp; x = (x instanceof Array) ? flattenAndCompact(x) : [ x ]; if (x.length === 0) { return null; } for (var i = 0 ; i < x.length ; i++) { if (typeof x[i] === "function") { x[i].call(this); } } if (this.now && !this.unit && !this.operator) { return new Date(); } else { today = finishUtils.getToday.call(this); } expression = !!(this.days && this.days !== null || this.orient || this.operator); orient = ((this.orient === "past" || this.operator === "subtract") ? -1 : 1); if (this.month && this.unit === "week") { this.value = this.month + 1; delete this.month; delete this.day; } if ((this.month || this.month === 0) && "year day hour minute second".indexOf(this.unit) !== -1) { if (!this.value) { this.value = this.month + 1; } this.month = null; expression = true; } if (!expression && this.weekday && !this.day && !this.days) { finishUtils.setDMYFromWeekday.call(this); } if (expression && this.weekday && this.unit !== "month" && this.unit !== "week") { finishUtils.setDaysFromWeekday.call(this, today, orient); } if (this.weekday && this.unit !== "week" && !this.day && !this.days) { temp = Date[this.weekday](); this.day = temp.getDate(); if (temp.getMonth() !== today.getMonth()) { this.month = temp.getMonth(); } } if (this.month && this.unit === "day" && this.operator) { if (!this.value) { this.value = (this.month + 1); } this.month = null; } if (this.value != null && this.month != null && this.year != null) { this.day = this.value * 1; } if (this.month && !this.day && this.value) { today.set({ day: this.value * 1 }); if (!expression) { this.day = this.value * 1; } } if (!this.month && this.value && this.unit === "month" && !this.now) { this.month = this.value; expression = true; } if (expression && (this.month || this.month === 0) && this.unit !== "year") { finishUtils.setMonthsFromMonth.call(this, today, orient); } if (!this.unit) { this.unit = "day"; } finishUtils.setUnitValue.call(this, orient); parseMeridian.call(this); if ((this.month || this.month === 0) && !this.day) { this.day = 1; } if (!this.orient && !this.operator && this.unit === "week" && this.value && !this.day && !this.month) { return Date.today().setWeek(this.value); } if (this.unit === "week" && this.weeks && !this.day && !this.month) { return finishUtils.generateDateFromWeeks.call(this); } if (expression && this.timezone && this.day && this.days) { this.day = this.days; } if (expression){ today.add(this); } else { today.set(this); } if (this.timezone) { this.timezone = this.timezone.toUpperCase(); var offset = $D.getTimezoneOffset(this.timezone); var timezone; if (today.hasDaylightSavingTime()) { // lets check that we're being sane with timezone setting timezone = $D.getTimezoneAbbreviation(offset, today.isDaylightSavingTime()); if (timezone !== this.timezone) { // bugger, we're in a place where things like EST vs EDT matters. if (today.isDaylightSavingTime()) { today.addHours(-1); } else { today.addHours(1); } } } today.setTimezoneOffset(offset); } return today; } }; }()); (function () { var $D = Date; $D.Grammar = {}; var _ = $D.Parsing.Operators, g = $D.Grammar, t = $D.Translator, _fn; // Allow rolling up into general purpose rules _fn = function () { return _.each(_.any.apply(null, arguments), _.not(g.ctoken2("timeContext"))); }; g.datePartDelimiter = _.rtoken(/^([\s\-\.\,\/\x27]+)/); g.timePartDelimiter = _.stoken(":"); g.whiteSpace = _.rtoken(/^\s*/); g.generalDelimiter = _.rtoken(/^(([\s\,]|at|@|on)+)/); var _C = {}; g.ctoken = function (keys) { var fn = _C[keys]; if (! fn) { var c = Date.CultureInfo.regexPatterns; var kx = keys.split(/\s+/), px = []; for (var i = 0; i < kx.length ; i++) { px.push(_.replace(_.rtoken(c[kx[i]]), kx[i])); } fn = _C[keys] = _.any.apply(null, px); } return fn; }; g.ctoken2 = function (key) { return _.rtoken(Date.CultureInfo.regexPatterns[key]); }; var cacheProcessRtoken = function (key, token, type, eachToken) { if (eachToken) { g[key] = _.cache(_.process(_.each(_.rtoken(token),_.optional(g.ctoken2(eachToken))), type)); } else { g[key] = _.cache(_.process(_.rtoken(token), type)); } }; var cacheProcessCtoken = function (token, type) { return _.cache(_.process(g.ctoken2(token), type)); }; var _F = {}; //function cache var _get = function (f) { _F[f] = (_F[f] || g.format(f)[0]); return _F[f]; }; g.allformats = function (fx) { var rx = []; if (fx instanceof Array) { for (var i = 0; i < fx.length; i++) { rx.push(_get(fx[i])); } } else { rx.push(_get(fx)); } return rx; }; g.formats = function (fx) { if (fx instanceof Array) { var rx = []; for (var i = 0 ; i < fx.length ; i++) { rx.push(_get(fx[i])); } return _.any.apply(null, rx); } else { return _get(fx); } }; var grammarFormats = { timeFormats: function(){ var i, RTokenKeys = [ "h", "hh", "H", "HH", "m", "mm", "s", "ss", "ss.s", "z", "zz" ], RToken = [ /^(0[0-9]|1[0-2]|[1-9])/, /^(0[0-9]|1[0-2])/, /^([0-1][0-9]|2[0-3]|[0-9])/, /^([0-1][0-9]|2[0-3])/, /^([0-5][0-9]|[0-9])/, /^[0-5][0-9]/, /^([0-5][0-9]|[0-9])/, /^[0-5][0-9]/, /^[0-5][0-9]\.[0-9]{1,3}/, /^((\+|\-)\s*\d\d\d\d)|((\+|\-)\d\d\:?\d\d)/, /^((\+|\-)\s*\d\d\d\d)|((\+|\-)\d\d\:?\d\d)/ ], tokens = [ t.hour, t.hour, t.hour, t.hour, t.minute, t.minute, t.second, t.second, t.secondAndMillisecond, t.timezone, t.timezone ]; for (i=0; i < RTokenKeys.length; i++) { cacheProcessRtoken(RTokenKeys[i], RToken[i], tokens[i]); } g.hms = _.cache(_.sequence([g.H, g.m, g.s], g.timePartDelimiter)); g.t = cacheProcessCtoken("shortMeridian", t.meridian); g.tt = cacheProcessCtoken("longMeridian", t.meridian); g.zzz = cacheProcessCtoken("timezone", t.timezone); g.timeSuffix = _.each(_.ignore(g.whiteSpace), _.set([ g.tt, g.zzz ])); g.time = _.each(_.optional(_.ignore(_.stoken("T"))), g.hms, g.timeSuffix); }, dateFormats: function () { // pre-loaded rules for different date part order preferences var _setfn = function () { return _.set(arguments, g.datePartDelimiter); }; var i, RTokenKeys = [ "d", "dd", "M", "MM", "y", "yy", "yyy", "yyyy" ], RToken = [ /^([0-2]\d|3[0-1]|\d)/, /^([0-2]\d|3[0-1])/, /^(1[0-2]|0\d|\d)/, /^(1[0-2]|0\d)/, /^(\d+)/, /^(\d\d)/, /^(\d\d?\d?\d?)/, /^(\d\d\d\d)/ ], tokens = [ t.day, t.day, t.month, t.month, t.year, t.year, t.year, t.year ], eachToken = [ "ordinalSuffix", "ordinalSuffix" ]; for (i=0; i < RTokenKeys.length; i++) { cacheProcessRtoken(RTokenKeys[i], RToken[i], tokens[i], eachToken[i]); } g.MMM = g.MMMM = _.cache(_.process(g.ctoken("jan feb mar apr may jun jul aug sep oct nov dec"), t.month)); g.ddd = g.dddd = _.cache(_.process(g.ctoken("sun mon tue wed thu fri sat"), function (s) { return function () { this.weekday = s; }; } )); g.day = _fn(g.d, g.dd); g.month = _fn(g.M, g.MMM); g.year = _fn(g.yyyy, g.yy); g.mdy = _setfn(g.ddd, g.month, g.day, g.year); g.ymd = _setfn(g.ddd, g.year, g.month, g.day); g.dmy = _setfn(g.ddd, g.day, g.month, g.year); g.date = function (s) { return ((g[Date.CultureInfo.dateElementOrder] || g.mdy).call(this, s)); }; }, relative: function () { // relative date / time expressions g.orientation = _.process(g.ctoken("past future"), function (s) { return function () { this.orient = s; }; } ); g.operator = _.process(g.ctoken("add subtract"), function (s) { return function () { this.operator = s; }; } ); g.rday = _.process(g.ctoken("yesterday tomorrow today now"), t.rday); g.unit = _.process(g.ctoken("second minute hour day week month year"), function (s) { return function () { this.unit = s; }; } ); } }; g.buildGrammarFormats = function () { // these need to be rebuilt every time the language changes. _C = {}; grammarFormats.timeFormats(); grammarFormats.dateFormats(); grammarFormats.relative(); g.value = _.process(_.rtoken(/^([-+]?\d+)?(st|nd|rd|th)?/), function (s) { return function () { this.value = s.replace(/\D/g, ""); }; } ); g.expression = _.set([g.rday, g.operator, g.value, g.unit, g.orientation, g.ddd, g.MMM ]); g.format = _.process(_.many( _.any( // translate format specifiers into grammar rules _.process( _.rtoken(/^(dd?d?d?(?!e)|MM?M?M?|yy?y?y?|hh?|HH?|mm?|ss?|tt?|zz?z?)/), function (fmt) { if (g[fmt]) { return g[fmt]; } else { throw $D.Parsing.Exception(fmt); } } ), // translate separator tokens into token rules _.process(_.rtoken(/^[^dMyhHmstz]+/), // all legal separators function (s) { return _.ignore(_.stoken(s)); } ) ) ), // construct the parser ... function (rules) { return _.process(_.each.apply(null, rules), t.finishExact); } ); // starting rule for general purpose grammar g._start = _.process(_.set([ g.date, g.time, g.expression ], g.generalDelimiter, g.whiteSpace), t.finish); }; g.buildGrammarFormats(); // parsing date format specifiers - ex: "h:m:s tt" // this little guy will generate a custom parser based // on the format string, ex: g.format("h:m:s tt") // check for these formats first g._formats = g.formats([ "\"yyyy-MM-ddTHH:mm:ssZ\"", "yyyy-MM-ddTHH:mm:ss.sz", "yyyy-MM-ddTHH:mm:ssZ", "yyyy-MM-ddTHH:mm:ssz", "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-ddTHH:mmZ", "yyyy-MM-ddTHH:mmz", "yyyy-MM-ddTHH:mm", "ddd, MMM dd, yyyy H:mm:ss tt", "ddd MMM d yyyy HH:mm:ss zzz", "MMddyyyy", "ddMMyyyy", "Mddyyyy", "ddMyyyy", "Mdyyyy", "dMyyyy", "yyyy", "Mdyy", "dMyy", "d" ]); // real starting rule: tries selected formats first, // then general purpose rule g.start = function (s) { try { var r = g._formats.call({}, s); if (r[1].length === 0) { return r; } } catch (e) {} return g._start.call({}, s); }; }()); (function () { var $D = Date; /** * @desc Converts the specified string value into its JavaScript Date equivalent using CultureInfo specific format information. * * Example

	///////////
	// Dates //
	///////////

	// 15-Oct-2004
	var d1 = Date.parse("10/15/2004");

	// 15-Oct-2004
	var d1 = Date.parse("15-Oct-2004");

	// 15-Oct-2004
	var d1 = Date.parse("2004.10.15");

	//Fri Oct 15, 2004
	var d1 = Date.parse("Fri Oct 15, 2004");

	///////////
	// Times //
	///////////

	// Today at 10 PM.
	var d1 = Date.parse("10 PM");

	// Today at 10:30 PM.
	var d1 = Date.parse("10:30 P.M.");

	// Today at 6 AM.
	var d1 = Date.parse("06am");

	/////////////////////
	// Dates and Times //
	/////////////////////

	// 8-July-2004 @ 10:30 PM
	var d1 = Date.parse("July 8th, 2004, 10:30 PM");

	// 1-July-2004 @ 10:30 PM
	var d1 = Date.parse("2004-07-01T22:30:00");

	////////////////////
	// Relative Dates //
	////////////////////

	// Returns today's date. The string "today" is culture specific.
	var d1 = Date.parse("today");

	// Returns yesterday's date. The string "yesterday" is culture specific.
	var d1 = Date.parse("yesterday");

	// Returns the date of the next thursday.
	var d1 = Date.parse("Next thursday");

	// Returns the date of the most previous monday.
	var d1 = Date.parse("last monday");

	// Returns today's day + one year.
	var d1 = Date.parse("next year");

	///////////////
	// Date Math //
	///////////////

	// Today + 2 days
	var d1 = Date.parse("t+2");

	// Today + 2 days
	var d1 = Date.parse("today + 2 days");

	// Today + 3 months
	var d1 = Date.parse("t+3m");

	// Today - 1 year
	var d1 = Date.parse("today - 1 year");

	// Today - 1 year
	var d1 = Date.parse("t-1y"); 


	/////////////////////////////
	// Partial Dates and Times //
	/////////////////////////////

	// July 15th of this year.
	var d1 = Date.parse("July 15");

	// 15th day of current day and year.
	var d1 = Date.parse("15");

	// July 1st of current year at 10pm.
	var d1 = Date.parse("7/1 10pm");
	
* * @param {String} The string value to convert into a Date object [Required] * @return {Date} A Date object or null if the string cannot be converted into a Date. */ var parseUtils = { removeOrds: function (s) { ords = s.match(/\b(\d+)(?:st|nd|rd|th)\b/); // find ordinal matches s = ((ords && ords.length === 2) ? s.replace(ords[0], ords[1]) : s); return s; }, grammarParser: function (s) { var r = null; try { r = $D.Grammar.start.call({}, s.replace(/^\s*(\S*(\s+\S+)*)\s*$/, "$1")); } catch (e) { return null; } return ((r[1].length === 0) ? r[0] : null); }, nativeFallback: function(s) { var t; try { // ok we haven't parsed it, last ditch attempt with the built-in parser. t = Date._parse(s); return (t || t === 0) ? new Date(t) : null; } catch (e) { return null; } } }; function parse (s) { var d; if (!s) { return null; } if (s instanceof Date) { return s.clone(); } if (s.length >= 4 && s.charAt(0) !== "0" && s.charAt(0) !== "+"&& s.charAt(0) !== "-") { // ie: 2004 will pass, 0800 won't. // Start with specific formats d = $D.Parsing.ISO.parse(s) || $D.Parsing.Numeric.parse(s); } if (d instanceof Date && !isNaN(d.getTime())) { return d; } else { // find ordinal dates (1st, 3rd, 8th, etc and remove them as they cause parsing issues) s = $D.Parsing.Normalizer.parse(parseUtils.removeOrds(s)); d = parseUtils.grammarParser(s); if (d !== null) { return d; } else { return parseUtils.nativeFallback(s); } } } if (!$D._parse) { $D._parse = $D.parse; } $D.parse = parse; Date.getParseFunction = function (fx) { var fns = Date.Grammar.allformats(fx); return function (s) { var r = null; for (var i = 0; i < fns.length; i++) { try { r = fns[i].call({}, s); } catch (e) { continue; } if (r[1].length === 0) { return r[0]; } } return null; }; }; /** * Converts the specified string value into its JavaScript Date equivalent using the specified format {String} or formats {Array} and the CultureInfo specific format information. * The format of the string value must match one of the supplied formats exactly. * * Example

	// 15-Oct-2004
	var d1 = Date.parseExact("10/15/2004", "M/d/yyyy");

	// 15-Oct-2004
	var d1 = Date.parse("15-Oct-2004", "M-ddd-yyyy");

	// 15-Oct-2004
	var d1 = Date.parse("2004.10.15", "yyyy.MM.dd");

	// Multiple formats
	var d1 = Date.parseExact("10/15/2004", ["M/d/yyyy", "MMMM d, yyyy"]);
	
* * @param {String} The string value to convert into a Date object [Required]. * @param {Object} The expected format {String} or an array of expected formats {Array} of the date string [Required]. * @return {Date} A Date object or null if the string cannot be converted into a Date. */ $D.parseExact = function (s, fx) { return $D.getParseFunction(fx)(s); }; }()); (function () { var $D = Date, $P = $D.prototype, // $C = $D.CultureInfo, // not used atm p = function (s, l) { if (!l) { l = 2; } return ("000" + s).slice(l * -1); }; /** * Converts a PHP format string to Java/.NET format string. * A PHP format string can be used with ._format or .format. * A Java/.NET format string can be used with .toString(). * The .parseExact function will only accept a Java/.NET format string * * Example * var f1 = "%m/%d/%y" * var f2 = Date.normalizeFormat(f1); // "MM/dd/yy" * * new Date().format(f1); // "04/13/08" * new Date()._format(f1); // "04/13/08" * new Date().toString(f2); // "04/13/08" * * var date = Date.parseExact("04/13/08", f2); // Sun Apr 13 2008 * * @param {String} A PHP format string consisting of one or more format spcifiers. * @return {String} The PHP format converted to a Java/.NET format string. */ var normalizerSubstitutions = { "d" : "dd", "%d": "dd", "D" : "ddd", "%a": "ddd", "j" : "dddd", "l" : "dddd", "%A": "dddd", "S" : "S", "F" : "MMMM", "%B": "MMMM", "m" : "MM", "%m": "MM", "M" : "MMM", "%b": "MMM", "%h": "MMM", "n" : "M", "Y" : "yyyy", "%Y": "yyyy", "y" : "yy", "%y": "yy", "g" : "h", "%I": "h", "G" : "H", "h" : "hh", "H" : "HH", "%H": "HH", "i" : "mm", "%M": "mm", "s" : "ss", "%S": "ss", "%r": "hh:mm tt", "%R": "H:mm", "%T": "H:mm:ss", "%X": "t", "%x": "d", "%e": "d", "%D": "MM/dd/yy", "%n": "\\n", "%t": "\\t", "e" : "z", "T" : "z", "%z": "z", "%Z": "z", "Z" : "ZZ", "N" : "u", "w" : "u", "%w": "u", "W" : "W", "%V": "W" }; var normalizer = { substitutes: function (m) { return normalizerSubstitutions[m]; }, interpreted: function (m, x) { var y; switch (m) { case "%u": return x.getDay() + 1; case "z": return x.getOrdinalNumber(); case "%j": return p(x.getOrdinalNumber(), 3); case "%U": var d1 = x.clone().set({month: 0, day: 1}).addDays(-1).moveToDayOfWeek(0), d2 = x.clone().addDays(1).moveToDayOfWeek(0, -1); return (d2 < d1) ? "00" : p((d2.getOrdinalNumber() - d1.getOrdinalNumber()) / 7 + 1); case "%W": return p(x.getWeek()); case "t": return $D.getDaysInMonth(x.getFullYear(), x.getMonth()); case "o": case "%G": return x.setWeek(x.getISOWeek()).toString("yyyy"); case "%g": return x._format("%G").slice(-2); case "a": case "%p": return t("tt").toLowerCase(); case "A": return t("tt").toUpperCase(); case "u": return p(x.getMilliseconds(), 3); case "I": return (x.isDaylightSavingTime()) ? 1 : 0; case "O": return x.getUTCOffset(); case "P": y = x.getUTCOffset(); return y.substring(0, y.length - 2) + ":" + y.substring(y.length - 2); case "B": var now = new Date(); return Math.floor(((now.getHours() * 3600) + (now.getMinutes() * 60) + now.getSeconds() + (now.getTimezoneOffset() + 60) * 60) / 86.4); case "c": return x.toISOString().replace(/\"/g, ""); case "U": return $D.strtotime("now"); case "%c": return t("d") + " " + t("t"); case "%C": return Math.floor(x.getFullYear() / 100 + 1); } }, shouldOverrideDefaults: function (m) { switch (m) { case "%e": return true; default: return false; } }, parse: function (m, context) { var formatString, c = context || new Date(); formatString = normalizer.substitutes(m); if (formatString) { return formatString; } formatString = normalizer.interpreted(m, c); if (formatString) { return formatString; } else { return m; } } }; $D.normalizeFormat = function (format, context) { return format.replace(/(%|\\)?.|%%/g, function(t){ return normalizer.parse(t, context); }); }; /** * Format a local Unix timestamp according to locale settings * * Example: * Date.strftime("%m/%d/%y", new Date()); // "04/13/08" * Date.strftime("c", "2008-04-13T17:52:03Z"); // "04/13/08" * * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @param {Number|String} The number representing the number of seconds that have elapsed since January 1, 1970 (local time). * @return {String} A string representation of the current Date object. */ $D.strftime = function (format, time) { var d = Date.parse(time); return d._format(format); }; /** * Parse any textual datetime description into a Unix timestamp. * A Unix timestamp is the number of seconds that have elapsed since January 1, 1970 (midnight UTC/GMT). * * Example: * Date.strtotime("04/13/08"); // 1208044800 * Date.strtotime("1970-01-01T00:00:00Z"); // 0 * * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @param {Object} A string or date object. * @return {String} A string representation of the current Date object. */ $D.strtotime = function (time) { var d = $D.parse(time); return Math.round($D.UTC(d.getUTCFullYear(), d.getUTCMonth(), d.getUTCDate(), d.getUTCHours(), d.getUTCMinutes(), d.getUTCSeconds(), d.getUTCMilliseconds()) / 1000); }; /** * Converts the value of the current Date object to its equivalent string representation using a PHP/Unix style of date format specifiers. * Format Specifiers * Format Description Example * ------ --------------------------------------------------------------------------- ----------------------- * %a abbreviated weekday name according to the current localed "Mon" through "Sun" * %A full weekday name according to the current localed "Sunday" through "Saturday" * %b abbreviated month name according to the current localed "Jan" through "Dec" * %B full month name according to the current locale "January" through "December" * %c preferred date and time representation for the current locale "4/13/2008 12:33 PM" * %C century number (the year divided by 100 and truncated to an integer) "00" to "99" * %d day of the month as a decimal number "01" to "31" * %D same as %m/%d/%y "04/13/08" * %e day of the month as a decimal number, a single digit is preceded by a space "1" to "31" * %g like %G, but without the century "08" * %G The 4-digit year corresponding to the ISO week number (see %V). "2008" * This has the same format and value as %Y, except that if the ISO week number * belongs to the previous or next year, that year is used instead. * %h same as %b "Jan" through "Dec" * %H hour as a decimal number using a 24-hour clock. "00" to "23" * %I hour as a decimal number using a 12-hour clock. "01" to "12" * %j day of the year as a decimal number. "001" to "366" * %m month as a decimal number. "01" to "12" * %M minute as a decimal number. "00" to "59" * %n newline character "\n" * %p either "am" or "pm" according to the given time value, or the "am" or "pm" * corresponding strings for the current locale. * %r time in a.m. and p.m. notation "8:44 PM" * %R time in 24 hour notation "20:44" * %S second as a decimal number "00" to "59" * %t tab character "\t" * %T current time, equal to %H:%M:%S "12:49:11" * %u weekday as a decimal number ["1", "7"], with "1" representing Monday "1" to "7" * %U week number of the current year as a decimal number, starting with the "0" to ("52" or "53") * first Sunday as the first day of the first week * %V The ISO 8601:1988 week number of the current year as a decimal number, "00" to ("52" or "53") * range 01 to 53, where week 1 is the first week that has at least 4 days * in the current year, and with Monday as the first day of the week. * (Use %G or %g for the year component that corresponds to the week number * for the specified timestamp.) * %W week number of the current year as a decimal number, starting with the "00" to ("52" or "53") * first Monday as the first day of the first week * %w day of the week as a decimal, Sunday being "0" "0" to "6" * %x preferred date representation for the current locale without the time "4/13/2008" * %X preferred time representation for the current locale without the date "12:53:05" * %y year as a decimal number without a century "00" "99" * %Y year as a decimal number including the century "2008" * %Z time zone or name or abbreviation "UTC", "EST", "PST" * %z same as %Z * %% a literal "%" characters "%" * d Day of the month, 2 digits with leading zeros "01" to "31" * D A textual representation of a day, three letters "Mon" through "Sun" * j Day of the month without leading zeros "1" to "31" * l A full textual representation of the day of the week (lowercase "L") "Sunday" through "Saturday" * N ISO-8601 numeric representation of the day of the week (added in PHP 5.1.0) "1" (for Monday) through "7" (for Sunday) * S English ordinal suffix for the day of the month, 2 characters "st", "nd", "rd" or "th". Works well with j * w Numeric representation of the day of the week "0" (for Sunday) through "6" (for Saturday) * z The day of the year (starting from "0") "0" through "365" * W ISO-8601 week number of year, weeks starting on Monday "00" to ("52" or "53") * F A full textual representation of a month, such as January or March "January" through "December" * m Numeric representation of a month, with leading zeros "01" through "12" * M A short textual representation of a month, three letters "Jan" through "Dec" * n Numeric representation of a month, without leading zeros "1" through "12" * t Number of days in the given month "28" through "31" * L Whether it's a leap year "1" if it is a leap year, "0" otherwise * o ISO-8601 year number. This has the same value as Y, except that if the "2008" * ISO week number (W) belongs to the previous or next year, that year * is used instead. * Y A full numeric representation of a year, 4 digits "2008" * y A two digit representation of a year "08" * a Lowercase Ante meridiem and Post meridiem "am" or "pm" * A Uppercase Ante meridiem and Post meridiem "AM" or "PM" * B Swatch Internet time "000" through "999" * g 12-hour format of an hour without leading zeros "1" through "12" * G 24-hour format of an hour without leading zeros "0" through "23" * h 12-hour format of an hour with leading zeros "01" through "12" * H 24-hour format of an hour with leading zeros "00" through "23" * i Minutes with leading zeros "00" to "59" * s Seconds, with leading zeros "00" through "59" * u Milliseconds "54321" * e Timezone identifier "UTC", "EST", "PST" * I Whether or not the date is in daylight saving time (uppercase i) "1" if Daylight Saving Time, "0" otherwise * O Difference to Greenwich time (GMT) in hours "+0200", "-0600" * P Difference to Greenwich time (GMT) with colon between hours and minutes "+02:00", "-06:00" * T Timezone abbreviation "UTC", "EST", "PST" * Z Timezone offset in seconds. The offset for timezones west of UTC is "-43200" through "50400" * always negative, and for those east of UTC is always positive. * c ISO 8601 date "2004-02-12T15:19:21+00:00" * r RFC 2822 formatted date "Thu, 21 Dec 2000 16:01:07 +0200" * U Seconds since the Unix Epoch (January 1 1970 00:00:00 GMT) "0" * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @return {String} A string representation of the current Date object. */ var formatReplace = function (context) { return function (m) { var formatString, override = false; if (m.charAt(0) === "\\" || m.substring(0, 2) === "%%") { return m.replace("\\", "").replace("%%", "%"); } override = normalizer.shouldOverrideDefaults(m); formatString = $D.normalizeFormat(m, context); if (formatString) { return context.toString(formatString, override); } }; }; $P._format = function (format) { var formatter = formatReplace(this); if (!format) { return this._toString(); } else { return format.replace(/(%|\\)?.|%%/g, formatter); } }; if (!$P.format) { $P.format = $P._format; } }()); (function () { "use strict"; var gFn = function (attr) { return function () { return this[attr]; }; }; var sFn = function (attr) { return function (val) { this[attr] = val; return this; }; }; var attrs = ["years", "months", "days", "hours", "minutes", "seconds", "milliseconds"]; var addSetFuncs = function (context, attrs) { for (var i = 0; i < attrs.length ; i++) { var $a = attrs[i], $b = $a.slice(0, 1).toUpperCase() + $a.slice(1); context.prototype[$a] = 0; context.prototype["get" + $b] = gFn($a); context.prototype["set" + $b] = sFn($a); } }; /** * new TimeSpan(milliseconds); * new TimeSpan(days, hours, minutes, seconds); * new TimeSpan(days, hours, minutes, seconds, milliseconds); */ var TimeSpan = function (days, hours, minutes, seconds, milliseconds) { if (arguments.length === 1 && typeof days === "number") { var orient = (days < 0) ? -1 : +1; var millsLeft = Math.abs(days); this.setDays(Math.floor(millsLeft / 86400000) * orient); millsLeft = millsLeft % 86400000; this.setHours(Math.floor(millsLeft / 3600000) * orient); millsLeft = millsLeft % 3600000; this.setMinutes(Math.floor(millsLeft / 60000) * orient); millsLeft = millsLeft % 60000; this.setSeconds(Math.floor(millsLeft / 1000) * orient); millsLeft = millsLeft % 1000; this.setMilliseconds(millsLeft * orient); } else { this.set(days, hours, minutes, seconds, milliseconds); } this.getTotalMilliseconds = function () { return (this.getDays() * 86400000) + (this.getHours() * 3600000) + (this.getMinutes() * 60000) + (this.getSeconds() * 1000); }; this.compareTo = function (time) { var t1 = new Date(1970, 1, 1, this.getHours(), this.getMinutes(), this.getSeconds()), t2; if (time === null) { t2 = new Date(1970, 1, 1, 0, 0, 0); } else { t2 = new Date(1970, 1, 1, time.getHours(), time.getMinutes(), time.getSeconds()); } return (t1 < t2) ? -1 : (t1 > t2) ? 1 : 0; }; this.equals = function (time) { return (this.compareTo(time) === 0); }; this.add = function (time) { return (time === null) ? this : this.addSeconds(time.getTotalMilliseconds() / 1000); }; this.subtract = function (time) { return (time === null) ? this : this.addSeconds(-time.getTotalMilliseconds() / 1000); }; this.addDays = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 86400000)); }; this.addHours = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 3600000)); }; this.addMinutes = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 60000)); }; this.addSeconds = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 1000)); }; this.addMilliseconds = function (n) { return new TimeSpan(this.getTotalMilliseconds() + n); }; this.get12HourHour = function () { return (this.getHours() > 12) ? this.getHours() - 12 : (this.getHours() === 0) ? 12 : this.getHours(); }; this.getDesignator = function () { return (this.getHours() < 12) ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator; }; this.toString = function (format) { this._toString = function () { if (this.getDays() !== null && this.getDays() > 0) { return this.getDays() + "." + this.getHours() + ":" + this.p(this.getMinutes()) + ":" + this.p(this.getSeconds()); } else { return this.getHours() + ":" + this.p(this.getMinutes()) + ":" + this.p(this.getSeconds()); } }; this.p = function (s) { return (s.toString().length < 2) ? "0" + s : s; }; var me = this; return format ? format.replace(/dd?|HH?|hh?|mm?|ss?|tt?/g, function (format) { switch (format) { case "d": return me.getDays(); case "dd": return me.p(me.getDays()); case "H": return me.getHours(); case "HH": return me.p(me.getHours()); case "h": return me.get12HourHour(); case "hh": return me.p(me.get12HourHour()); case "m": return me.getMinutes(); case "mm": return me.p(me.getMinutes()); case "s": return me.getSeconds(); case "ss": return me.p(me.getSeconds()); case "t": return ((me.getHours() < 12) ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator).substring(0, 1); case "tt": return (me.getHours() < 12) ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator; } } ) : this._toString(); }; return this; }; addSetFuncs(TimeSpan, attrs.slice(2)); TimeSpan.prototype.set = function (days, hours, minutes, seconds, milliseconds){ this.setDays(days || this.getDays()); this.setHours(hours || this.getHours()); this.setMinutes(minutes || this.getMinutes()); this.setSeconds(seconds || this.getSeconds()); this.setMilliseconds(milliseconds || this.getMilliseconds()); }; /** * Gets the time of day for this date instances. * @return {TimeSpan} TimeSpan */ Date.prototype.getTimeOfDay = function () { return new TimeSpan(0, this.getHours(), this.getMinutes(), this.getSeconds(), this.getMilliseconds()); }; Date.TimeSpan = TimeSpan; if (typeof window !== "undefined" ) { // keeping API compatible for v1.x window.TimeSpan = TimeSpan; } }()); (function () { "use strict"; var attrs = ["years", "months", "days", "hours", "minutes", "seconds", "milliseconds"]; var gFn = function (attr) { return function () { return this[attr]; }; }; var sFn = function (attr) { return function (val) { this[attr] = val; return this; }; }; var addSetFuncs = function (context, attrs) { for (var i = 0; i < attrs.length ; i++) { var $a = attrs[i], $b = $a.slice(0, 1).toUpperCase() + $a.slice(1); context.prototype[$a] = 0; context.prototype["get" + $b] = gFn($a); context.prototype["set" + $b] = sFn($a); } }; var setMonthsAndYears = function (orient, d1, d2, context) { function inc() { d1.addMonths(-orient); context.months++; if (context.months === 12) { context.years++; context.months = 0; } } if (orient === +1) { while (d1 > d2) { inc(); } } else { while (d1 < d2) { inc(); } } context.months--; context.months *= orient; context.years *= orient; }; var adjustForDST = function(orient, startDate, endDate) { var hasDSTMismatch = (false === (startDate.isDaylightSavingTime() === endDate.isDaylightSavingTime())); if (hasDSTMismatch && orient === 1) { startDate.addHours(-1); } else if (hasDSTMismatch) { startDate.addHours(1); } }; /** * TimePeriod(startDate, endDate); * TimePeriod(years, months, days, hours, minutes, seconds, milliseconds); */ var TimePeriod = function (years, months, days, hours, minutes, seconds, milliseconds) { if (arguments.length === 7) { this.set(years, months, days, hours, minutes, seconds, milliseconds); } else if (arguments.length === 2 && arguments[0] instanceof Date && arguments[1] instanceof Date) { var startDate = arguments[0].clone(); var endDate = arguments[1].clone(); var orient = (startDate > endDate) ? +1 : -1; this.dates = { start: arguments[0].clone(), end: arguments[1].clone() }; setMonthsAndYears(orient, startDate, endDate, this); adjustForDST(orient, startDate, endDate); // // TODO - adjust for DST var diff = endDate - startDate; if (diff !== 0) { var ts = new TimeSpan(diff); this.set(this.years, this.months, ts.getDays(), ts.getHours(), ts.getMinutes(), ts.getSeconds(), ts.getMilliseconds()); } } return this; }; // create all the set functions. addSetFuncs(TimePeriod, attrs); TimePeriod.prototype.set = function (years, months, days, hours, minutes, seconds, milliseconds){ this.setYears(years || this.getYears()); this.setMonths(months || this.getMonths()); this.setDays(days || this.getDays()); this.setHours(hours || this.getHours()); this.setMinutes(minutes || this.getMinutes()); this.setSeconds(seconds || this.getSeconds()); this.setMilliseconds(milliseconds || this.getMilliseconds()); }; Date.TimePeriod = TimePeriod; if (typeof window !== "undefined") { // keeping API compatible for v1.x window.TimePeriod = TimePeriod; } }()); ================================================ FILE: build/date-nl-NL.js ================================================ /** * @overview datejs * @version 1.0.0-rc3 * @author Gregory Wild-Smith * @copyright 2015 Gregory Wild-Smith * @license MIT * @homepage https://github.com/abritinthebay/datejs */ /* * DateJS Culture String File * Country Code: nl-NL * Name: Dutch (Netherlands) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["nl-NL"] = { "name": "nl-NL", "englishName": "Dutch (Netherlands)", "nativeName": "Nederlands (Nederland)", "Sunday": "zondag", "Monday": "maandag", "Tuesday": "dinsdag", "Wednesday": "woensdag", "Thursday": "donderdag", "Friday": "vrijdag", "Saturday": "zaterdag", "Sun": "zo", "Mon": "ma", "Tue": "di", "Wed": "wo", "Thu": "do", "Fri": "vr", "Sat": "za", "Su": "zo", "Mo": "ma", "Tu": "di", "We": "wo", "Th": "do", "Fr": "vr", "Sa": "za", "S_Sun_Initial": "z", "M_Mon_Initial": "m", "T_Tue_Initial": "d", "W_Wed_Initial": "w", "T_Thu_Initial": "d", "F_Fri_Initial": "v", "S_Sat_Initial": "z", "January": "januari", "February": "februari", "March": "maart", "April": "april", "May": "mei", "June": "juni", "July": "juli", "August": "augustus", "September": "september", "October": "oktober", "November": "november", "December": "december", "Jan_Abbr": "jan", "Feb_Abbr": "feb", "Mar_Abbr": "mrt", "Apr_Abbr": "apr", "May_Abbr": "mei", "Jun_Abbr": "jun", "Jul_Abbr": "jul", "Aug_Abbr": "aug", "Sep_Abbr": "sep", "Oct_Abbr": "okt", "Nov_Abbr": "nov", "Dec_Abbr": "dec", "AM": "", "PM": "", "firstDayOfWeek": 1, "twoDigitYearMax": 2029, "mdy": "dmy", "M/d/yyyy": "d-M-yyyy", "dddd, MMMM dd, yyyy": "dddd d MMMM yyyy", "h:mm tt": "H:mm", "h:mm:ss tt": "H:mm:ss", "dddd, MMMM dd, yyyy h:mm:ss tt": "dddd d MMMM yyyy H:mm:ss", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "dd MMMM", "MMMM, yyyy": "MMMM yyyy", "/jan(uary)?/": "jan(uari)?", "/feb(ruary)?/": "feb(ruari)?", "/mar(ch)?/": "maart", "/apr(il)?/": "apr(il)?", "/may/": "mei", "/jun(e)?/": "jun(i)?", "/jul(y)?/": "jul(i)?", "/aug(ust)?/": "aug(ustus)?", "/sep(t(ember)?)?/": "sep(t(ember)?)?", "/oct(ober)?/": "okt(ober)?", "/nov(ember)?/": "nov(ember)?", "/dec(ember)?/": "dec(ember)?", "/^su(n(day)?)?/": "^zondag", "/^mo(n(day)?)?/": "^maandag", "/^tu(e(s(day)?)?)?/": "^dinsdag", "/^we(d(nesday)?)?/": "^woensdag", "/^th(u(r(s(day)?)?)?)?/": "^donderdag", "/^fr(i(day)?)?/": "^vrijdag", "/^sa(t(urday)?)?/": "^zaterdag", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "nl-NL"; /** * @overview datejs * @version 1.0.0-rc3 * @author Gregory Wild-Smith * @copyright 2015 Gregory Wild-Smith * @license MIT * @homepage https://github.com/abritinthebay/datejs */(function () { var $D = Date; var lang = Date.CultureStrings ? Date.CultureStrings.lang : null; var loggedKeys = {}; // for debug purposes. var getText = { getFromKey: function (key, countryCode) { var output; if (Date.CultureStrings && Date.CultureStrings[countryCode] && Date.CultureStrings[countryCode][key]) { output = Date.CultureStrings[countryCode][key]; } else { output = getText.buildFromDefault(key); } if (key.charAt(0) === "/") { // Assume it's a regex output = getText.buildFromRegex(key, countryCode); } return output; }, getFromObjectValues: function (obj, countryCode) { var key, output = {}; for(key in obj) { if (obj.hasOwnProperty(key)) { output[key] = getText.getFromKey(obj[key], countryCode); } } return output; }, getFromObjectKeys: function (obj, countryCode) { var key, output = {}; for(key in obj) { if (obj.hasOwnProperty(key)) { output[getText.getFromKey(key, countryCode)] = obj[key]; } } return output; }, getFromArray: function (arr, countryCode) { var output = []; for (var i=0; i < arr.length; i++){ if (i in arr) { output[i] = getText.getFromKey(arr[i], countryCode); } } return output; }, buildFromDefault: function (key) { var output, length, split, last; switch(key) { case "name": output = "en-US"; break; case "englishName": output = "English (United States)"; break; case "nativeName": output = "English (United States)"; break; case "twoDigitYearMax": output = 2049; break; case "firstDayOfWeek": output = 0; break; default: output = key; split = key.split("_"); length = split.length; if (length > 1 && key.charAt(0) !== "/") { // if the key isn't a regex and it has a split. last = split[(length - 1)].toLowerCase(); if (last === "initial" || last === "abbr") { output = split[0]; } } break; } return output; }, buildFromRegex: function (key, countryCode) { var output; if (Date.CultureStrings && Date.CultureStrings[countryCode] && Date.CultureStrings[countryCode][key]) { output = new RegExp(Date.CultureStrings[countryCode][key], "i"); } else { output = new RegExp(key.replace(new RegExp("/", "g"),""), "i"); } return output; } }; var shallowMerge = function (obj1, obj2) { for (var attrname in obj2) { if (obj2.hasOwnProperty(attrname)) { obj1[attrname] = obj2[attrname]; } } }; var __ = function (key, language) { var countryCode = (language) ? language : lang; loggedKeys[key] = key; if (typeof key === "object") { if (key instanceof Array) { return getText.getFromArray(key, countryCode); } else { return getText.getFromObjectKeys(key, countryCode); } } else { return getText.getFromKey(key, countryCode); } }; var loadI18nScript = function (code) { // paatterned after jQuery's getScript. var url = Date.Config.i18n + code + ".js"; var head = document.getElementsByTagName("head")[0] || document.documentElement; var script = document.createElement("script"); script.src = url; var completed = false; var events = { done: function (){} // placeholder function }; // Attach handlers for all browsers script.onload = script.onreadystatechange = function() { if ( !completed && (!this.readyState || this.readyState === "loaded" || this.readyState === "complete") ) { events.done(); head.removeChild(script); } }; setTimeout(function() { head.insertBefore(script, head.firstChild); }, 0); // allows return to execute first return { done: function (cb) { events.done = function() { if (cb) { setTimeout(cb,0); } }; } }; }; var buildInfo = { buildFromMethodHash: function (obj) { var key; for(key in obj) { if (obj.hasOwnProperty(key)) { obj[key] = buildInfo[obj[key]](); } } return obj; }, timeZoneDST: function () { var DST = { "CHADT": "+1345", "NZDT": "+1300", "AEDT": "+1100", "ACDT": "+1030", "AZST": "+0500", "IRDT": "+0430", "EEST": "+0300", "CEST": "+0200", "BST": "+0100", "PMDT": "-0200", "ADT": "-0300", "NDT": "-0230", "EDT": "-0400", "CDT": "-0500", "MDT": "-0600", "PDT": "-0700", "AKDT": "-0800", "HADT": "-0900" }; return __(DST); }, timeZoneStandard: function () { var standard = { "LINT": "+1400", "TOT": "+1300", "CHAST": "+1245", "NZST": "+1200", "NFT": "+1130", "SBT": "+1100", "AEST": "+1000", "ACST": "+0930", "JST": "+0900", "CWST": "+0845", "CT": "+0800", "ICT": "+0700", "MMT": "+0630", "BST": "+0600", "NPT": "+0545", "IST": "+0530", "PKT": "+0500", "AFT": "+0430", "MSK": "+0400", "IRST": "+0330", "FET": "+0300", "EET": "+0200", "CET": "+0100", "GMT": "+0000", "UTC": "+0000", "CVT": "-0100", "GST": "-0200", "BRT": "-0300", "NST": "-0330", "AST": "-0400", "EST": "-0500", "CST": "-0600", "MST": "-0700", "PST": "-0800", "AKST": "-0900", "MIT": "-0930", "HST": "-1000", "SST": "-1100", "BIT": "-1200" }; return __(standard); }, timeZones: function (data) { var zone; data.timezones = []; for (zone in data.abbreviatedTimeZoneStandard) { if (data.abbreviatedTimeZoneStandard.hasOwnProperty(zone)) { data.timezones.push({ name: zone, offset: data.abbreviatedTimeZoneStandard[zone]}); } } for (zone in data.abbreviatedTimeZoneDST) { if (data.abbreviatedTimeZoneDST.hasOwnProperty(zone)) { data.timezones.push({ name: zone, offset: data.abbreviatedTimeZoneDST[zone], dst: true}); } } return data.timezones; }, days: function () { return __(["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"]); }, dayAbbr: function () { return __(["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"]); }, dayShortNames: function () { return __(["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"]); }, dayFirstLetters: function () { return __(["S_Sun_Initial", "M_Mon_Initial", "T_Tues_Initial", "W_Wed_Initial", "T_Thu_Initial", "F_Fri_Initial", "S_Sat_Initial"]); }, months: function () { return __(["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"]); }, monthAbbr: function () { return __(["Jan_Abbr", "Feb_Abbr", "Mar_Abbr", "Apr_Abbr", "May_Abbr", "Jun_Abbr", "Jul_Abbr", "Aug_Abbr", "Sep_Abbr", "Oct_Abbr", "Nov_Abbr", "Dec_Abbr"]); }, formatPatterns: function () { return getText.getFromObjectValues({ shortDate: "M/d/yyyy", longDate: "dddd, MMMM dd, yyyy", shortTime: "h:mm tt", longTime: "h:mm:ss tt", fullDateTime: "dddd, MMMM dd, yyyy h:mm:ss tt", sortableDateTime: "yyyy-MM-ddTHH:mm:ss", universalSortableDateTime: "yyyy-MM-dd HH:mm:ssZ", rfc1123: "ddd, dd MMM yyyy HH:mm:ss", monthDay: "MMMM dd", yearMonth: "MMMM, yyyy" }, Date.i18n.currentLanguage()); }, regex: function () { return getText.getFromObjectValues({ inTheMorning: "/( in the )(morn(ing)?)\\b/", thisMorning: "/(this )(morn(ing)?)\\b/", amThisMorning: "/(\b\\d(am)? )(this )(morn(ing)?)/", inTheEvening: "/( in the )(even(ing)?)\\b/", thisEvening: "/(this )(even(ing)?)\\b/", pmThisEvening: "/(\b\\d(pm)? )(this )(even(ing)?)/", jan: "/jan(uary)?/", feb: "/feb(ruary)?/", mar: "/mar(ch)?/", apr: "/apr(il)?/", may: "/may/", jun: "/jun(e)?/", jul: "/jul(y)?/", aug: "/aug(ust)?/", sep: "/sep(t(ember)?)?/", oct: "/oct(ober)?/", nov: "/nov(ember)?/", dec: "/dec(ember)?/", sun: "/^su(n(day)?)?/", mon: "/^mo(n(day)?)?/", tue: "/^tu(e(s(day)?)?)?/", wed: "/^we(d(nesday)?)?/", thu: "/^th(u(r(s(day)?)?)?)?/", fri: "/fr(i(day)?)?/", sat: "/^sa(t(urday)?)?/", future: "/^next/", past: "/^last|past|prev(ious)?/", add: "/^(\\+|aft(er)?|from|hence)/", subtract: "/^(\\-|bef(ore)?|ago)/", yesterday: "/^yes(terday)?/", today: "/^t(od(ay)?)?/", tomorrow: "/^tom(orrow)?/", now: "/^n(ow)?/", millisecond: "/^ms|milli(second)?s?/", second: "/^sec(ond)?s?/", minute: "/^mn|min(ute)?s?/", hour: "/^h(our)?s?/", week: "/^w(eek)?s?/", month: "/^m(onth)?s?/", day: "/^d(ay)?s?/", year: "/^y(ear)?s?/", shortMeridian: "/^(a|p)/", longMeridian: "/^(a\\.?m?\\.?|p\\.?m?\\.?)/", timezone: "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/", ordinalSuffix: "/^\\s*(st|nd|rd|th)/", timeContext: "/^\\s*(\\:|a(?!u|p)|p)/" }, Date.i18n.currentLanguage()); } }; var CultureInfo = function () { var info = getText.getFromObjectValues({ name: "name", englishName: "englishName", nativeName: "nativeName", amDesignator: "AM", pmDesignator: "PM", firstDayOfWeek: "firstDayOfWeek", twoDigitYearMax: "twoDigitYearMax", dateElementOrder: "mdy" }, Date.i18n.currentLanguage()); var constructedInfo = buildInfo.buildFromMethodHash({ dayNames: "days", abbreviatedDayNames: "dayAbbr", shortestDayNames: "dayShortNames", firstLetterDayNames: "dayFirstLetters", monthNames: "months", abbreviatedMonthNames: "monthAbbr", formatPatterns: "formatPatterns", regexPatterns: "regex", abbreviatedTimeZoneDST: "timeZoneDST", abbreviatedTimeZoneStandard: "timeZoneStandard" }); shallowMerge(info, constructedInfo); buildInfo.timeZones(info); return info; }; $D.i18n = { __: function (key, lang) { return __(key, lang); }, currentLanguage: function () { return lang || "en-US"; }, setLanguage: function (code, force, cb) { var async = false; if (force || code === "en-US" || (!!Date.CultureStrings && !!Date.CultureStrings[code])) { lang = code; Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings.lang = code; Date.CultureInfo = new CultureInfo(); } else { if (!(!!Date.CultureStrings && !!Date.CultureStrings[code])) { if (typeof exports !== "undefined" && this.exports !== exports) { // we're in a Node enviroment, load it using require try { require("../i18n/" + code + ".js"); lang = code; Date.CultureStrings.lang = code; Date.CultureInfo = new CultureInfo(); } catch (e) { // var str = "The language for '" + code + "' could not be loaded by Node. It likely does not exist."; throw new Error("The DateJS IETF language tag '" + code + "' could not be loaded by Node. It likely does not exist."); } } else if (Date.Config && Date.Config.i18n) { // we know the location of the files, so lets load them async = true; loadI18nScript(code).done(function(){ lang = code; Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings.lang = code; Date.CultureInfo = new CultureInfo(); $D.Parsing.Normalizer.buildReplaceData(); // because this is async if ($D.Grammar) { $D.Grammar.buildGrammarFormats(); // so we can parse those strings... } if (cb) { setTimeout(cb,0); } }); } else { Date.console.error("The DateJS IETF language tag '" + code + "' is not available and has not been loaded."); return false; } } } $D.Parsing.Normalizer.buildReplaceData(); // rebuild normalizer strings if ($D.Grammar) { $D.Grammar.buildGrammarFormats(); // so we can parse those strings... } if (!async && cb) { setTimeout(cb,0); } }, getLoggedKeys: function () { return loggedKeys; }, updateCultureInfo: function () { Date.CultureInfo = new CultureInfo(); } }; $D.i18n.updateCultureInfo(); // run automatically }()); (function () { var $D = Date, $P = $D.prototype, p = function (s, l) { if (!l) { l = 2; } return ("000" + s).slice(l * -1); }; if (typeof window !== "undefined" && typeof window.console !== "undefined" && typeof window.console.log !== "undefined") { $D.console = console; // used only to raise non-critical errors if available } else { // set mock so we don't give errors. $D.console = { log: function(){}, error: function(){} }; } $D.Config = $D.Config || {}; $D.initOverloads = function() { /** * Overload of Date.now. Allows an alternate call for Date.now where it returns the * current Date as an object rather than just milliseconds since the Unix Epoch. * * Also provides an implementation of now() for browsers (IE<9) that don't have it. * * Backwards compatible so with work with either: * Date.now() [returns ms] * or * Date.now(true) [returns Date] */ if (!$D.now) { $D._now = function now() { return new Date().getTime(); }; } else if (!$D._now) { $D._now = $D.now; } $D.now = function (returnObj) { if (returnObj) { return $D.present(); } else { return $D._now(); } }; if ( !$P.toISOString ) { $P.toISOString = function() { return this.getUTCFullYear() + "-" + p(this.getUTCMonth() + 1) + "-" + p(this.getUTCDate()) + "T" + p(this.getUTCHours()) + ":" + p(this.getUTCMinutes()) + ":" + p(this.getUTCSeconds()) + "." + String( (this.getUTCMilliseconds()/1000).toFixed(3)).slice(2, 5) + "Z"; }; } // private if ( $P._toString === undefined ){ $P._toString = $P.toString; } }; $D.initOverloads(); /** * Gets a date that is set to the current date. The time is set to the start of the day (00:00 or 12:00 AM). * @return {Date} The current date. */ $D.today = function () { return new Date().clearTime(); }; /** * Gets a date that is set to the current date and time (same as new Date, but chainable) * @return {Date} The current date. */ $D.present = function () { return new Date(); }; /** * Compares the first date to the second date and returns an number indication of their relative values. * @param {Date} First Date object to compare [Required]. * @param {Date} Second Date object to compare to [Required]. * @return {Number} -1 = date1 is lessthan date2. 0 = values are equal. 1 = date1 is greaterthan date2. */ $D.compare = function (date1, date2) { if (isNaN(date1) || isNaN(date2)) { throw new Error(date1 + " - " + date2); } else if (date1 instanceof Date && date2 instanceof Date) { return (date1 < date2) ? -1 : (date1 > date2) ? 1 : 0; } else { throw new TypeError(date1 + " - " + date2); } }; /** * Compares the first Date object to the second Date object and returns true if they are equal. * @param {Date} First Date object to compare [Required] * @param {Date} Second Date object to compare to [Required] * @return {Boolean} true if dates are equal. false if they are not equal. */ $D.equals = function (date1, date2) { return (date1.compareTo(date2) === 0); }; /** * Gets the language appropriate day name when given the day number(0-6) * eg - 0 == Sunday * @return {String} The day name */ $D.getDayName = function (n) { return Date.CultureInfo.dayNames[n]; }; /** * Gets the day number (0-6) if given a CultureInfo specific string which is a valid dayName, abbreviatedDayName or shortestDayName (two char). * @param {String} The name of the day (eg. "Monday, "Mon", "tuesday", "tue", "We", "we"). * @return {Number} The day number */ $D.getDayNumberFromName = function (name) { var n = Date.CultureInfo.dayNames, m = Date.CultureInfo.abbreviatedDayNames, o = Date.CultureInfo.shortestDayNames, s = name.toLowerCase(); for (var i = 0; i < n.length; i++) { if (n[i].toLowerCase() === s || m[i].toLowerCase() === s || o[i].toLowerCase() === s) { return i; } } return -1; }; /** * Gets the month number (0-11) if given a Culture Info specific string which is a valid monthName or abbreviatedMonthName. * @param {String} The name of the month (eg. "February, "Feb", "october", "oct"). * @return {Number} The day number */ $D.getMonthNumberFromName = function (name) { var n = Date.CultureInfo.monthNames, m = Date.CultureInfo.abbreviatedMonthNames, s = name.toLowerCase(); for (var i = 0; i < n.length; i++) { if (n[i].toLowerCase() === s || m[i].toLowerCase() === s) { return i; } } return -1; }; /** * Gets the language appropriate month name when given the month number(0-11) * eg - 0 == January * @return {String} The month name */ $D.getMonthName = function (n) { return Date.CultureInfo.monthNames[n]; }; /** * Determines if the current date instance is within a LeapYear. * @param {Number} The year. * @return {Boolean} true if date is within a LeapYear, otherwise false. */ $D.isLeapYear = function (year) { return ((year % 4 === 0 && year % 100 !== 0) || year % 400 === 0); }; /** * Gets the number of days in the month, given a year and month value. Automatically corrects for LeapYear. * @param {Number} The year. * @param {Number} The month (0-11). * @return {Number} The number of days in the month. */ $D.getDaysInMonth = function (year, month) { if (!month && $D.validateMonth(year)) { month = year; year = Date.today().getFullYear(); } return [31, ($D.isLeapYear(year) ? 29 : 28), 31, 30, 31, 30, 31, 31, 30, 31, 30, 31][month]; }; $P.getDaysInMonth = function () { return $D.getDaysInMonth(this.getFullYear(), this.getMonth()); }; $D.getTimezoneAbbreviation = function (offset, dst) { var p, n = (dst || false) ? Date.CultureInfo.abbreviatedTimeZoneDST : Date.CultureInfo.abbreviatedTimeZoneStandard; for (p in n) { if (n.hasOwnProperty(p)) { if (n[p] === offset) { return p; } } } return null; }; $D.getTimezoneOffset = function (name, dst) { var i, a =[], z = Date.CultureInfo.timezones; if (!name) { name = (new Date()).getTimezone();} for (i = 0; i < z.length; i++) { if (z[i].name === name.toUpperCase()) { a.push(i); } } if (!z[a[0]]) { return null; } if (a.length === 1 || !dst) { return z[a[0]].offset; } else { for (i=0; i < a.length; i++) { if (z[a[i]].dst) { return z[a[i]].offset; } } } }; $D.getQuarter = function (d) { d = d || new Date(); // If no date supplied, use today var q = [1,2,3,4]; return q[Math.floor(d.getMonth() / 3)]; // ~~~ is a bitwise op. Faster than Math.floor }; $D.getDaysLeftInQuarter = function (d) { d = d || new Date(); var qEnd = new Date(d); qEnd.setMonth(qEnd.getMonth() + 3 - qEnd.getMonth() % 3, 0); return Math.floor((qEnd - d) / 8.64e7); }; // private var validate = function (n, min, max, name) { name = name ? name : "Object"; if (typeof n === "undefined") { return false; } else if (typeof n !== "number") { throw new TypeError(n + " is not a Number."); } else if (n < min || n > max) { // As failing validation is *not* an exceptional circumstance // lets not throw a RangeError Exception here. // It's semantically correct but it's not sensible. return false; } return true; }; /** * Validates the number is within an acceptable range for milliseconds [0-999]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateMillisecond = function (value) { return validate(value, 0, 999, "millisecond"); }; /** * Validates the number is within an acceptable range for seconds [0-59]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateSecond = function (value) { return validate(value, 0, 59, "second"); }; /** * Validates the number is within an acceptable range for minutes [0-59]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateMinute = function (value) { return validate(value, 0, 59, "minute"); }; /** * Validates the number is within an acceptable range for hours [0-23]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateHour = function (value) { return validate(value, 0, 23, "hour"); }; /** * Validates the number is within an acceptable range for the days in a month [0-MaxDaysInMonth]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateDay = function (value, year, month) { if (year === undefined || year === null || month === undefined || month === null) { return false;} return validate(value, 1, $D.getDaysInMonth(year, month), "day"); }; /** * Validates the number is within an acceptable range for months [0-11]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateWeek = function (value) { return validate(value, 0, 53, "week"); }; /** * Validates the number is within an acceptable range for months [0-11]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateMonth = function (value) { return validate(value, 0, 11, "month"); }; /** * Validates the number is within an acceptable range for years. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateYear = function (value) { /** * Per ECMAScript spec the range of times supported by Date objects is * exactly -100,000,000 days to +100,000,000 days measured relative to * midnight at the beginning of 01 January, 1970 UTC. * This gives a range of 8,640,000,000,000,000 milliseconds to either * side of 01 January, 1970 UTC. * * Earliest possible date: Tue, 20 Apr 271,822 B.C. 00:00:00 UTC * Latest possible date: Sat, 13 Sep 275,760 00:00:00 UTC */ return validate(value, -271822, 275760, "year"); }; $D.validateTimezone = function(value) { var timezones = {"ACDT":1,"ACST":1,"ACT":1,"ADT":1,"AEDT":1,"AEST":1,"AFT":1,"AKDT":1,"AKST":1,"AMST":1,"AMT":1,"ART":1,"AST":1,"AWDT":1,"AWST":1,"AZOST":1,"AZT":1,"BDT":1,"BIOT":1,"BIT":1,"BOT":1,"BRT":1,"BST":1,"BTT":1,"CAT":1,"CCT":1,"CDT":1,"CEDT":1,"CEST":1,"CET":1,"CHADT":1,"CHAST":1,"CHOT":1,"ChST":1,"CHUT":1,"CIST":1,"CIT":1,"CKT":1,"CLST":1,"CLT":1,"COST":1,"COT":1,"CST":1,"CT":1,"CVT":1,"CWST":1,"CXT":1,"DAVT":1,"DDUT":1,"DFT":1,"EASST":1,"EAST":1,"EAT":1,"ECT":1,"EDT":1,"EEDT":1,"EEST":1,"EET":1,"EGST":1,"EGT":1,"EIT":1,"EST":1,"FET":1,"FJT":1,"FKST":1,"FKT":1,"FNT":1,"GALT":1,"GAMT":1,"GET":1,"GFT":1,"GILT":1,"GIT":1,"GMT":1,"GST":1,"GYT":1,"HADT":1,"HAEC":1,"HAST":1,"HKT":1,"HMT":1,"HOVT":1,"HST":1,"ICT":1,"IDT":1,"IOT":1,"IRDT":1,"IRKT":1,"IRST":1,"IST":1,"JST":1,"KGT":1,"KOST":1,"KRAT":1,"KST":1,"LHST":1,"LINT":1,"MAGT":1,"MART":1,"MAWT":1,"MDT":1,"MET":1,"MEST":1,"MHT":1,"MIST":1,"MIT":1,"MMT":1,"MSK":1,"MST":1,"MUT":1,"MVT":1,"MYT":1,"NCT":1,"NDT":1,"NFT":1,"NPT":1,"NST":1,"NT":1,"NUT":1,"NZDT":1,"NZST":1,"OMST":1,"ORAT":1,"PDT":1,"PET":1,"PETT":1,"PGT":1,"PHOT":1,"PHT":1,"PKT":1,"PMDT":1,"PMST":1,"PONT":1,"PST":1,"PYST":1,"PYT":1,"RET":1,"ROTT":1,"SAKT":1,"SAMT":1,"SAST":1,"SBT":1,"SCT":1,"SGT":1,"SLST":1,"SRT":1,"SST":1,"SYOT":1,"TAHT":1,"THA":1,"TFT":1,"TJT":1,"TKT":1,"TLT":1,"TMT":1,"TOT":1,"TVT":1,"UCT":1,"ULAT":1,"UTC":1,"UYST":1,"UYT":1,"UZT":1,"VET":1,"VLAT":1,"VOLT":1,"VOST":1,"VUT":1,"WAKT":1,"WAST":1,"WAT":1,"WEDT":1,"WEST":1,"WET":1,"WST":1,"YAKT":1,"YEKT":1,"Z":1}; return (timezones[value] === 1); }; $D.validateTimezoneOffset= function(value) { // timezones go from +14hrs to -12hrs, the +X hours are negative offsets. return (value > -841 && value < 721); }; }()); (function () { var $D = Date, $P = $D.prototype, p = function (s, l) { if (!l) { l = 2; } return ("000" + s).slice(l * -1); }; var validateConfigObject = function (obj) { var result = {}, self = this, prop, testFunc; testFunc = function (prop, func, value) { if (prop === "day") { var month = (obj.month !== undefined) ? obj.month : self.getMonth(); var year = (obj.year !== undefined) ? obj.year : self.getFullYear(); return $D[func](value, year, month); } else { return $D[func](value); } }; for (prop in obj) { if (Object.prototype.hasOwnProperty.call(obj, prop)) { var func = "validate" + prop.charAt(0).toUpperCase() + prop.slice(1); if ($D[func] && obj[prop] !== null && testFunc(prop, func, obj[prop])) { result[prop] = obj[prop]; } } } return result; }; /** * Resets the time of this Date object to 12:00 AM (00:00), which is the start of the day. * @param {Boolean} .clone() this date instance before clearing Time * @return {Date} this */ $P.clearTime = function () { this.setHours(0); this.setMinutes(0); this.setSeconds(0); this.setMilliseconds(0); return this; }; /** * Resets the time of this Date object to the current time ('now'). * @return {Date} this */ $P.setTimeToNow = function () { var n = new Date(); this.setHours(n.getHours()); this.setMinutes(n.getMinutes()); this.setSeconds(n.getSeconds()); this.setMilliseconds(n.getMilliseconds()); return this; }; /** * Returns a new Date object that is an exact date and time copy of the original instance. * @return {Date} A new Date instance */ $P.clone = function () { return new Date(this.getTime()); }; /** * Compares this instance to a Date object and returns an number indication of their relative values. * @param {Date} Date object to compare [Required] * @return {Number} -1 = this is lessthan date. 0 = values are equal. 1 = this is greaterthan date. */ $P.compareTo = function (date) { return Date.compare(this, date); }; /** * Compares this instance to another Date object and returns true if they are equal. * @param {Date} Date object to compare. If no date to compare, new Date() [now] is used. * @return {Boolean} true if dates are equal. false if they are not equal. */ $P.equals = function (date) { return Date.equals(this, (date !== undefined ? date : new Date())); }; /** * Determines if this instance is between a range of two dates or equal to either the start or end dates. * @param {Date} Start of range [Required] * @param {Date} End of range [Required] * @return {Boolean} true is this is between or equal to the start and end dates, else false */ $P.between = function (start, end) { return this.getTime() >= start.getTime() && this.getTime() <= end.getTime(); }; /** * Determines if this date occurs after the date to compare to. * @param {Date} Date object to compare. If no date to compare, new Date() ("now") is used. * @return {Boolean} true if this date instance is greater than the date to compare to (or "now"), otherwise false. */ $P.isAfter = function (date) { return this.compareTo(date || new Date()) === 1; }; /** * Determines if this date occurs before the date to compare to. * @param {Date} Date object to compare. If no date to compare, new Date() ("now") is used. * @return {Boolean} true if this date instance is less than the date to compare to (or "now"). */ $P.isBefore = function (date) { return (this.compareTo(date || new Date()) === -1); }; /** * Determines if the current Date instance occurs today. * @return {Boolean} true if this date instance is 'today', otherwise false. */ /** * Determines if the current Date instance occurs on the same Date as the supplied 'date'. * If no 'date' to compare to is provided, the current Date instance is compared to 'today'. * @param {date} Date object to compare. If no date to compare, the current Date ("now") is used. * @return {Boolean} true if this Date instance occurs on the same Day as the supplied 'date'. */ $P.isToday = $P.isSameDay = function (date) { return this.clone().clearTime().equals((date || new Date()).clone().clearTime()); }; /** * Adds the specified number of milliseconds to this instance. * @param {Number} The number of milliseconds to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addMilliseconds = function (value) { if (!value) { return this; } this.setTime(this.getTime() + value * 1); return this; }; /** * Adds the specified number of seconds to this instance. * @param {Number} The number of seconds to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addSeconds = function (value) { if (!value) { return this; } return this.addMilliseconds(value * 1000); }; /** * Adds the specified number of seconds to this instance. * @param {Number} The number of seconds to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addMinutes = function (value) { if (!value) { return this; } return this.addMilliseconds(value * 60000); // 60*1000 }; /** * Adds the specified number of hours to this instance. * @param {Number} The number of hours to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addHours = function (value) { if (!value) { return this; } return this.addMilliseconds(value * 3600000); // 60*60*1000 }; /** * Adds the specified number of days to this instance. * @param {Number} The number of days to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addDays = function (value) { if (!value) { return this; } this.setDate(this.getDate() + value * 1); return this; }; /** * Adds the specified number of weekdays (ie - not sat or sun) to this instance. * @param {Number} The number of days to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addWeekdays = function (value) { if (!value) { return this; } var day = this.getDay(); var weeks = (Math.ceil(Math.abs(value)/7)); if (day === 0 || day === 6) { if (value > 0) { this.next().monday(); this.addDays(-1); day = this.getDay(); } } if (value < 0) { while (value < 0) { this.addDays(-1); day = this.getDay(); if (day !== 0 && day !== 6) { value++; } } return this; } else if (value > 5 || (6-day) <= value) { value = value + (weeks * 2); } return this.addDays(value); }; /** * Adds the specified number of weeks to this instance. * @param {Number} The number of weeks to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addWeeks = function (value) { if (!value) { return this; } return this.addDays(value * 7); }; /** * Adds the specified number of months to this instance. * @param {Number} The number of months to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addMonths = function (value) { if (!value) { return this; } var n = this.getDate(); this.setDate(1); this.setMonth(this.getMonth() + value * 1); this.setDate(Math.min(n, $D.getDaysInMonth(this.getFullYear(), this.getMonth()))); return this; }; $P.addQuarters = function (value) { if (!value) { return this; } // note this will take you to the same point in the quarter as you are now. // i.e. - if you are 15 days into the quarter you'll be 15 days into the resulting one. // bonus: this allows adding fractional quarters return this.addMonths(value * 3); }; /** * Adds the specified number of years to this instance. * @param {Number} The number of years to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addYears = function (value) { if (!value) { return this; } return this.addMonths(value * 12); }; /** * Adds (or subtracts) to the value of the years, months, weeks, days, hours, minutes, seconds, milliseconds of the date instance using given configuration object. Positive and Negative values allowed. * Example

	Date.today().add( { days: 1, months: 1 } )

	new Date().add( { years: -1 } )
	
* @param {Object} Configuration object containing attributes (months, days, etc.) * @return {Date} this */ $P.add = function (config) { if (typeof config === "number") { this._orient = config; return this; } var x = config; if (x.day) { // If we should be a different date than today (eg: for 'tomorrow -1d', etc). // Should only effect parsing, not direct usage (eg, Finish and FinishExact) if ((x.day - this.getDate()) !== 0) { this.setDate(x.day); } } if (x.milliseconds) { this.addMilliseconds(x.milliseconds); } if (x.seconds) { this.addSeconds(x.seconds); } if (x.minutes) { this.addMinutes(x.minutes); } if (x.hours) { this.addHours(x.hours); } if (x.weeks) { this.addWeeks(x.weeks); } if (x.months) { this.addMonths(x.months); } if (x.years) { this.addYears(x.years); } if (x.days) { this.addDays(x.days); } return this; }; /** * Get the week number. Week one (1) is the week which contains the first Thursday of the year. Monday is considered the first day of the week. * The .getWeek() function does NOT convert the date to UTC. The local datetime is used. * Please use .getISOWeek() to get the week of the UTC converted date. * @return {Number} 1 to 53 */ $P.getWeek = function (utc) { // Create a copy of this date object var self, target = new Date(this.valueOf()); if (utc) { target.addMinutes(target.getTimezoneOffset()); self = target.clone(); } else { self = this; } // ISO week date weeks start on monday // so correct the day number var dayNr = (self.getDay() + 6) % 7; // ISO 8601 states that week 1 is the week // with the first thursday of that year. // Set the target date to the thursday in the target week target.setDate(target.getDate() - dayNr + 3); // Store the millisecond value of the target date var firstThursday = target.valueOf(); // Set the target to the first thursday of the year // First set the target to january first target.setMonth(0, 1); // Not a thursday? Correct the date to the next thursday if (target.getDay() !== 4) { target.setMonth(0, 1 + ((4 - target.getDay()) + 7) % 7); } // The weeknumber is the number of weeks between the // first thursday of the year and the thursday in the target week return 1 + Math.ceil((firstThursday - target) / 604800000); // 604800000 = 7 * 24 * 3600 * 1000 }; /** * Get the ISO 8601 week number. Week one ("01") is the week which contains the first Thursday of the year. Monday is considered the first day of the week. * The .getISOWeek() function does convert the date to it's UTC value. Please use .getWeek() to get the week of the local date. * @return {String} "01" to "53" */ $P.getISOWeek = function () { return p(this.getWeek(true)); }; /** * Moves the date to Monday of the week set. Week one (1) is the week which contains the first Thursday of the year. * @param {Number} A Number (1 to 53) that represents the week of the year. * @return {Date} this */ $P.setWeek = function (n) { if ((n - this.getWeek()) === 0) { if (this.getDay() !== 1) { return this.moveToDayOfWeek(1, (this.getDay() > 1 ? -1 : 1)); } else { return this; } } else { return this.moveToDayOfWeek(1, (this.getDay() > 1 ? -1 : 1)).addWeeks(n - this.getWeek()); } }; $P.setQuarter = function (qtr) { var month = Math.abs(((qtr-1) * 3) + 1); return this.setMonth(month, 1); }; $P.getQuarter = function () { return Date.getQuarter(this); }; $P.getDaysLeftInQuarter = function () { return Date.getDaysLeftInQuarter(this); }; /** * Moves the date to the next n'th occurrence of the dayOfWeek starting from the beginning of the month. The number (-1) is a magic number and will return the last occurrence of the dayOfWeek in the month. * @param {Number} The dayOfWeek to move to * @param {Number} The n'th occurrence to move to. Use (-1) to return the last occurrence in the month * @return {Date} this */ $P.moveToNthOccurrence = function (dayOfWeek, occurrence) { if (dayOfWeek === "Weekday") { if (occurrence > 0) { this.moveToFirstDayOfMonth(); if (this.is().weekday()) { occurrence -= 1; } } else if (occurrence < 0) { this.moveToLastDayOfMonth(); if (this.is().weekday()) { occurrence += 1; } } else { return this; } return this.addWeekdays(occurrence); } var shift = 0; if (occurrence > 0) { shift = occurrence - 1; } else if (occurrence === -1) { this.moveToLastDayOfMonth(); if (this.getDay() !== dayOfWeek) { this.moveToDayOfWeek(dayOfWeek, -1); } return this; } return this.moveToFirstDayOfMonth().addDays(-1).moveToDayOfWeek(dayOfWeek, +1).addWeeks(shift); }; var moveToN = function (getFunc, addFunc, nVal) { return function (value, orient) { var diff = (value - this[getFunc]() + nVal * (orient || +1)) % nVal; return this[addFunc]((diff === 0) ? diff += nVal * (orient || +1) : diff); }; }; /** * Move to the next or last dayOfWeek based on the orient value. * @param {Number} The dayOfWeek to move to * @param {Number} Forward (+1) or Back (-1). Defaults to +1. [Optional] * @return {Date} this */ $P.moveToDayOfWeek = moveToN("getDay", "addDays", 7); /** * Move to the next or last month based on the orient value. * @param {Number} The month to move to. 0 = January, 11 = December * @param {Number} Forward (+1) or Back (-1). Defaults to +1. [Optional] * @return {Date} this */ $P.moveToMonth = moveToN("getMonth", "addMonths", 12); /** * Get the Ordinate of the current day ("th", "st", "rd"). * @return {String} */ $P.getOrdinate = function () { var num = this.getDate(); return ord(num); }; /** * Get the Ordinal day (numeric day number) of the year, adjusted for leap year. * @return {Number} 1 through 365 (366 in leap years) */ $P.getOrdinalNumber = function () { return Math.ceil((this.clone().clearTime() - new Date(this.getFullYear(), 0, 1)) / 86400000) + 1; }; /** * Get the time zone abbreviation of the current date. * @return {String} The abbreviated time zone name (e.g. "EST") */ $P.getTimezone = function () { return $D.getTimezoneAbbreviation(this.getUTCOffset(), this.isDaylightSavingTime()); }; $P.setTimezoneOffset = function (offset) { var here = this.getTimezoneOffset(), there = Number(offset) * -6 / 10; return (there || there === 0) ? this.addMinutes(there - here) : this; }; $P.setTimezone = function (offset) { return this.setTimezoneOffset($D.getTimezoneOffset(offset)); }; /** * Indicates whether Daylight Saving Time is observed in the current time zone. * @return {Boolean} true|false */ $P.hasDaylightSavingTime = function () { return (Date.today().set({month: 0, day: 1}).getTimezoneOffset() !== Date.today().set({month: 6, day: 1}).getTimezoneOffset()); }; /** * Indicates whether this Date instance is within the Daylight Saving Time range for the current time zone. * @return {Boolean} true|false */ $P.isDaylightSavingTime = function () { return Date.today().set({month: 0, day: 1}).getTimezoneOffset() !== this.getTimezoneOffset(); }; /** * Get the offset from UTC of the current date. * @return {String} The 4-character offset string prefixed with + or - (e.g. "-0500") */ $P.getUTCOffset = function (offset) { var n = (offset || this.getTimezoneOffset()) * -10 / 6, r; if (n < 0) { r = (n - 10000).toString(); return r.charAt(0) + r.substr(2); } else { r = (n + 10000).toString(); return "+" + r.substr(1); } }; /** * Returns the number of milliseconds between this date and date. * @param {Date} Defaults to now * @return {Number} The diff in milliseconds */ $P.getElapsed = function (date) { return (date || new Date()) - this; }; /** * Set the value of year, month, day, hour, minute, second, millisecond of date instance using given configuration object. * Example

	Date.today().set( { day: 20, month: 1 } )

	new Date().set( { millisecond: 0 } )
	
* * @param {Object} Configuration object containing attributes (month, day, etc.) * @return {Date} this */ $P.set = function (config) { config = validateConfigObject.call(this, config); var key; for (key in config) { if (Object.prototype.hasOwnProperty.call(config, key)) { var name = key.charAt(0).toUpperCase() + key.slice(1); var addFunc, getFunc; if (key !== "week" && key !== "month" && key !== "timezone" && key !== "timezoneOffset") { name += "s"; } addFunc = "add" + name; getFunc = "get" + name; if (key === "month") { addFunc = addFunc + "s"; } else if (key === "year"){ getFunc = "getFullYear"; } if (key !== "day" && key !== "timezone" && key !== "timezoneOffset" && key !== "week" && key !== "hour") { this[addFunc](config[key] - this[getFunc]()); } else if ( key === "timezone"|| key === "timezoneOffset" || key === "week" || key === "hour") { this["set"+name](config[key]); } } } // day has to go last because you can't validate the day without first knowing the month if (config.day) { this.addDays(config.day - this.getDate()); } return this; }; /** * Moves the date to the first day of the month. * @return {Date} this */ $P.moveToFirstDayOfMonth = function () { return this.set({ day: 1 }); }; /** * Moves the date to the last day of the month. * @return {Date} this */ $P.moveToLastDayOfMonth = function () { return this.set({ day: $D.getDaysInMonth(this.getFullYear(), this.getMonth())}); }; /** * Converts the value of the current Date object to its equivalent string representation. * Format Specifiers * CUSTOM DATE AND TIME FORMAT STRINGS * Format Description Example * ------ --------------------------------------------------------------------------- ----------------------- * s The seconds of the minute between 0-59. "0" to "59" * ss The seconds of the minute with leading zero if required. "00" to "59" * * m The minute of the hour between 0-59. "0" or "59" * mm The minute of the hour with leading zero if required. "00" or "59" * * h The hour of the day between 1-12. "1" to "12" * hh The hour of the day with leading zero if required. "01" to "12" * * H The hour of the day between 0-23. "0" to "23" * HH The hour of the day with leading zero if required. "00" to "23" * * d The day of the month between 1 and 31. "1" to "31" * dd The day of the month with leading zero if required. "01" to "31" * ddd Abbreviated day name. Date.CultureInfo.abbreviatedDayNames. "Mon" to "Sun" * dddd The full day name. Date.CultureInfo.dayNames. "Monday" to "Sunday" * * M The month of the year between 1-12. "1" to "12" * MM The month of the year with leading zero if required. "01" to "12" * MMM Abbreviated month name. Date.CultureInfo.abbreviatedMonthNames. "Jan" to "Dec" * MMMM The full month name. Date.CultureInfo.monthNames. "January" to "December" * * yy The year as a two-digit number. "99" or "08" * yyyy The full four digit year. "1999" or "2008" * * t Displays the first character of the A.M./P.M. designator. "A" or "P" * Date.CultureInfo.amDesignator or Date.CultureInfo.pmDesignator * tt Displays the A.M./P.M. designator. "AM" or "PM" * Date.CultureInfo.amDesignator or Date.CultureInfo.pmDesignator * * S The ordinal suffix ("st, "nd", "rd" or "th") of the current day. "st, "nd", "rd" or "th" * * STANDARD DATE AND TIME FORMAT STRINGS * Format Description Example *------ --------------------------------------------------------------------------- ----------------------- * d The CultureInfo shortDate Format Pattern "M/d/yyyy" * D The CultureInfo longDate Format Pattern "dddd, MMMM dd, yyyy" * F The CultureInfo fullDateTime Format Pattern "dddd, MMMM dd, yyyy h:mm:ss tt" * m The CultureInfo monthDay Format Pattern "MMMM dd" * r The CultureInfo rfc1123 Format Pattern "ddd, dd MMM yyyy HH:mm:ss GMT" * s The CultureInfo sortableDateTime Format Pattern "yyyy-MM-ddTHH:mm:ss" * t The CultureInfo shortTime Format Pattern "h:mm tt" * T The CultureInfo longTime Format Pattern "h:mm:ss tt" * u The CultureInfo universalSortableDateTime Format Pattern "yyyy-MM-dd HH:mm:ssZ" * y The CultureInfo yearMonth Format Pattern "MMMM, yyyy" * * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @return {String} A string representation of the current Date object. */ var ord = function (n) { switch (n * 1) { case 1: case 21: case 31: return "st"; case 2: case 22: return "nd"; case 3: case 23: return "rd"; default: return "th"; } }; var parseStandardFormats = function (format) { var y, c = Date.CultureInfo.formatPatterns; switch (format) { case "d": return this.toString(c.shortDate); case "D": return this.toString(c.longDate); case "F": return this.toString(c.fullDateTime); case "m": return this.toString(c.monthDay); case "r": case "R": y = this.clone().addMinutes(this.getTimezoneOffset()); return y.toString(c.rfc1123) + " GMT"; case "s": return this.toString(c.sortableDateTime); case "t": return this.toString(c.shortTime); case "T": return this.toString(c.longTime); case "u": y = this.clone().addMinutes(this.getTimezoneOffset()); return y.toString(c.universalSortableDateTime); case "y": return this.toString(c.yearMonth); default: return false; } }; var parseFormatStringsClosure = function (context) { return function (m) { if (m.charAt(0) === "\\") { return m.replace("\\", ""); } switch (m) { case "hh": return p(context.getHours() < 13 ? (context.getHours() === 0 ? 12 : context.getHours()) : (context.getHours() - 12)); case "h": return context.getHours() < 13 ? (context.getHours() === 0 ? 12 : context.getHours()) : (context.getHours() - 12); case "HH": return p(context.getHours()); case "H": return context.getHours(); case "mm": return p(context.getMinutes()); case "m": return context.getMinutes(); case "ss": return p(context.getSeconds()); case "s": return context.getSeconds(); case "yyyy": return p(context.getFullYear(), 4); case "yy": return p(context.getFullYear()); case "y": return context.getFullYear(); case "E": case "dddd": return Date.CultureInfo.dayNames[context.getDay()]; case "ddd": return Date.CultureInfo.abbreviatedDayNames[context.getDay()]; case "dd": return p(context.getDate()); case "d": return context.getDate(); case "MMMM": return Date.CultureInfo.monthNames[context.getMonth()]; case "MMM": return Date.CultureInfo.abbreviatedMonthNames[context.getMonth()]; case "MM": return p((context.getMonth() + 1)); case "M": return context.getMonth() + 1; case "t": return context.getHours() < 12 ? Date.CultureInfo.amDesignator.substring(0, 1) : Date.CultureInfo.pmDesignator.substring(0, 1); case "tt": return context.getHours() < 12 ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator; case "S": return ord(context.getDate()); case "W": return context.getWeek(); case "WW": return context.getISOWeek(); case "Q": return "Q" + context.getQuarter(); case "q": return String(context.getQuarter()); case "z": return context.getTimezone(); case "Z": case "X": return Date.getTimezoneOffset(context.getTimezone()); case "ZZ": // Timezone offset in seconds return context.getTimezoneOffset() * -60; case "u": return context.getDay(); case "L": return ($D.isLeapYear(context.getFullYear())) ? 1 : 0; case "B": // Swatch Internet Time (.beats) return "@"+((context.getUTCSeconds() + (context.getUTCMinutes()*60) + ((context.getUTCHours()+1)*3600))/86.4); default: return m; } }; }; $P.toString = function (format, ignoreStandards) { // Standard Date and Time Format Strings. Formats pulled from CultureInfo file and // may vary by culture. if (!ignoreStandards && format && format.length === 1) { output = parseStandardFormats.call(this, format); if (output) { return output; } } var parseFormatStrings = parseFormatStringsClosure(this); return format ? format.replace(/((\\)?(dd?d?d?|MM?M?M?|yy?y?y?|hh?|HH?|mm?|ss?|tt?|S|q|Q|WW?W?W?)(?![^\[]*\]))/g, parseFormatStrings).replace(/\[|\]/g, "") : this._toString(); }; }()); /************************************************************* * SugarPak - Domain Specific Language - Syntactical Sugar * *************************************************************/ (function () { var $D = Date, $P = $D.prototype, $N = Number.prototype; // private $P._orient = +1; // private $P._nth = null; // private $P._is = false; // private $P._same = false; // private $P._isSecond = false; // private $N._dateElement = "days"; /** * Moves the date to the next instance of a date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.today().next().friday();
	Date.today().next().fri();
	Date.today().next().march();
	Date.today().next().mar();
	Date.today().next().week();
	
* * @return {Date} date */ $P.next = function () { this._move = true; this._orient = +1; return this; }; /** * Creates a new Date (Date.today()) and moves the date to the next instance of the date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.next().friday();
	Date.next().fri();
	Date.next().march();
	Date.next().mar();
	Date.next().week();
	
* * @return {Date} date */ $D.next = function () { return $D.today().next(); }; /** * Moves the date to the previous instance of a date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.today().last().friday();
	Date.today().last().fri();
	Date.today().last().march();
	Date.today().last().mar();
	Date.today().last().week();
	
* * @return {Date} date */ $P.last = $P.prev = $P.previous = function () { this._move = true; this._orient = -1; return this; }; /** * Creates a new Date (Date.today()) and moves the date to the previous instance of the date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.last().friday();
	Date.last().fri();
	Date.previous().march();
	Date.prev().mar();
	Date.last().week();
	
* * @return {Date} date */ $D.last = $D.prev = $D.previous = function () { return $D.today().last(); }; /** * Performs a equality check when followed by either a month name, day name or .weekday() function. * Example

	Date.today().is().friday(); // true|false
	Date.today().is().fri();
	Date.today().is().march();
	Date.today().is().mar();
	
* * @return {Boolean} true|false */ $P.is = function () { this._is = true; return this; }; /** * Determines if two date objects occur on/in exactly the same instance of the subsequent date part function. * The function .same() must be followed by a date part function (example: .day(), .month(), .year(), etc). * * An optional Date can be passed in the date part function. If now date is passed as a parameter, 'Now' is used. * * The following example demonstrates how to determine if two dates fall on the exact same day. * * Example

	var d1 = Date.today(); // today at 00:00
	var d2 = new Date();   // exactly now.

	// Do they occur on the same day?
	d1.same().day(d2); // true
	
	// Do they occur on the same hour?
	d1.same().hour(d2); // false, unless d2 hour is '00' (midnight).
	
	// What if it's the same day, but one year apart?
	var nextYear = Date.today().add(1).year();

	d1.same().day(nextYear); // false, because the dates must occur on the exact same day. 
	
* * Scenario: Determine if a given date occurs during some week period 2 months from now. * * Example

	var future = Date.today().add(2).months();
	return someDate.same().week(future); // true|false;
	
* * @return {Boolean} true|false */ $P.same = function () { this._same = true; this._isSecond = false; return this; }; /** * Determines if the current date/time occurs during Today. Must be preceded by the .is() function. * Example

	someDate.is().today();    // true|false
	new Date().is().today();  // true
	Date.today().is().today();// true
	Date.today().add(-1).day().is().today(); // false
	
* * @return {Boolean} true|false */ $P.today = function () { return this.same().day(); }; /** * Determines if the current date is a weekday. This function must be preceded by the .is() function. * Example

	Date.today().is().weekday(); // true|false
	
* * @return {Boolean} true|false */ $P.weekday = function () { if (this._nth) { return df("Weekday").call(this); } if (this._move) { return this.addWeekdays(this._orient); } if (this._is) { this._is = false; return (!this.is().sat() && !this.is().sun()); } return false; }; /** * Determines if the current date is on the weekend. This function must be preceded by the .is() function. * Example

	Date.today().is().weekend(); // true|false
	
* * @return {Boolean} true|false */ $P.weekend = function () { if (this._is) { this._is = false; return (this.is().sat() || this.is().sun()); } return false; }; /** * Sets the Time of the current Date instance. A string "6:15 pm" or config object {hour:18, minute:15} are accepted. * Example

	// Set time to 6:15pm with a String
	Date.today().at("6:15pm");

	// Set time to 6:15pm with a config object
	Date.today().at({hour:18, minute:15});
	
* * @return {Date} date */ $P.at = function (time) { return (typeof time === "string") ? $D.parse(this.toString("d") + " " + time) : this.set(time); }; /** * Creates a new Date() and adds this (Number) to the date based on the preceding date element function (eg. second|minute|hour|day|month|year). * Example

	// Undeclared Numbers must be wrapped with parentheses. Requirment of JavaScript.
	(3).days().fromNow();
	(6).months().fromNow();

	// Declared Number variables do not require parentheses. 
	var n = 6;
	n.months().fromNow();
	
* * @return {Date} A new Date instance */ $N.fromNow = $N.after = function (date) { var c = {}; c[this._dateElement] = this; return ((!date) ? new Date() : date.clone()).add(c); }; /** * Creates a new Date() and subtract this (Number) from the date based on the preceding date element function (eg. second|minute|hour|day|month|year). * Example

	// Undeclared Numbers must be wrapped with parentheses. Requirment of JavaScript.
	(3).days().ago();
	(6).months().ago();

	// Declared Number variables do not require parentheses. 
	var n = 6;
	n.months().ago();
	
* * @return {Date} A new Date instance */ $N.ago = $N.before = function (date) { var c = {}, s = (this._dateElement[this._dateElement.length-1] !== "s") ? this._dateElement + "s" : this._dateElement; c[s] = this * -1; return ((!date) ? new Date() : date.clone()).add(c); }; // Do NOT modify the following string tokens. These tokens are used to build dynamic functions. // All culture-specific strings can be found in the CultureInfo files. var dx = ("sunday monday tuesday wednesday thursday friday saturday").split(/\s/), mx = ("january february march april may june july august september october november december").split(/\s/), px = ("Millisecond Second Minute Hour Day Week Month Year Quarter Weekday").split(/\s/), pxf = ("Milliseconds Seconds Minutes Hours Date Week Month FullYear Quarter").split(/\s/), nth = ("final first second third fourth fifth").split(/\s/), de; /** * Returns an object literal of all the date parts. * Example

	var o = new Date().toObject();
	
	// { year: 2008, month: 4, week: 20, day: 13, hour: 18, minute: 9, second: 32, millisecond: 812 }
	
	// The object properties can be referenced directly from the object.
	
	alert(o.day);  // alerts "13"
	alert(o.year); // alerts "2008"
	
* * @return {Date} An object literal representing the original date object. */ $P.toObject = function () { var o = {}; for (var i = 0; i < px.length; i++) { if (this["get" + pxf[i]]) { o[px[i].toLowerCase()] = this["get" + pxf[i]](); } } return o; }; /** * Returns a date created from an object literal. Ignores the .week property if set in the config. * Example

	var o = new Date().toObject();
	
	return Date.fromObject(o); // will return the same date. 

	var o2 = {month: 1, day: 20, hour: 18}; // birthday party!
	Date.fromObject(o2);
	
* * @return {Date} An object literal representing the original date object. */ $D.fromObject = function(config) { config.week = null; return Date.today().set(config); }; // Create day name functions and abbreviated day name functions (eg. monday(), friday(), fri()). var df = function (n) { return function () { if (this._is) { this._is = false; return this.getDay() === n; } if (this._move) { this._move = null; } if (this._nth !== null) { // If the .second() function was called earlier, remove the _orient // from the date, and then continue. // This is required because 'second' can be used in two different context. // // Example // // Date.today().add(1).second(); // Date.march().second().monday(); // // Things get crazy with the following... // Date.march().add(1).second().second().monday(); // but it works!! // if (this._isSecond) { this.addSeconds(this._orient * -1); } // make sure we reset _isSecond this._isSecond = false; var ntemp = this._nth; this._nth = null; var temp = this.clone().moveToLastDayOfMonth(); this.moveToNthOccurrence(n, ntemp); if (this > temp) { throw new RangeError($D.getDayName(n) + " does not occur " + ntemp + " times in the month of " + $D.getMonthName(temp.getMonth()) + " " + temp.getFullYear() + "."); } return this; } return this.moveToDayOfWeek(n, this._orient); }; }; var sdf = function (n) { return function () { var t = $D.today(), shift = n - t.getDay(); if (n === 0 && Date.CultureInfo.firstDayOfWeek === 1 && t.getDay() !== 0) { shift = shift + 7; } return t.addDays(shift); }; }; // Create month name functions and abbreviated month name functions (eg. january(), march(), mar()). var month_instance_functions = function (n) { return function () { if (this._is) { this._is = false; return this.getMonth() === n; } return this.moveToMonth(n, this._orient); }; }; var month_static_functions = function (n) { return function () { return $D.today().set({ month: n, day: 1 }); }; }; var processTerms = function (names, staticFunc, instanceFunc) { for (var i = 0; i < names.length; i++) { // Create constant static Name variables. $D[names[i].toUpperCase()] = $D[names[i].toUpperCase().substring(0, 3)] = i; // Create Name functions. $D[names[i]] = $D[names[i].substring(0, 3)] = staticFunc(i); // Create Name instance functions. $P[names[i]] = $P[names[i].substring(0, 3)] = instanceFunc(i); } }; processTerms(dx, sdf, df); processTerms(mx, month_static_functions, month_instance_functions); // Create date element functions and plural date element functions used with Date (eg. day(), days(), months()). var ef = function (j) { return function () { // if the .second() function was called earlier, the _orient // has alread been added. Just return this and reset _isSecond. if (this._isSecond) { this._isSecond = false; return this; } if (this._same) { this._same = this._is = false; var o1 = this.toObject(), o2 = (arguments[0] || new Date()).toObject(), v = "", k = j.toLowerCase(); // the substr trick with -1 doesn't work in IE8 or less k = (k[k.length-1] === "s") ? k.substring(0,k.length-1) : k; for (var m = (px.length - 1); m > -1; m--) { v = px[m].toLowerCase(); if (o1[v] !== o2[v]) { return false; } if (k === v) { break; } } return true; } if (j.substring(j.length - 1) !== "s") { j += "s"; } if (this._move) { this._move = null; } return this["add" + j](this._orient); }; }; var nf = function (n) { return function () { this._dateElement = n; return this; }; }; for (var k = 0; k < px.length; k++) { de = px[k].toLowerCase(); if(de !== "weekday") { // Create date element functions and plural date element functions used with Date (eg. day(), days(), months()). $P[de] = $P[de + "s"] = ef(px[k]); // Create date element functions and plural date element functions used with Number (eg. day(), days(), months()). $N[de] = $N[de + "s"] = nf(de + "s"); } } $P._ss = ef("Second"); var nthfn = function (n) { return function (dayOfWeek) { if (this._same) { return this._ss(arguments[0]); } if (dayOfWeek || dayOfWeek === 0) { return this.moveToNthOccurrence(dayOfWeek, n); } this._nth = n; // if the operator is 'second' add the _orient, then deal with it later... if (n === 2 && (dayOfWeek === undefined || dayOfWeek === null)) { this._isSecond = true; return this.addSeconds(this._orient); } return this; }; }; for (var l = 0; l < nth.length; l++) { $P[nth[l]] = (l === 0) ? nthfn(-1) : nthfn(l); } }()); (function () { "use strict"; Date.Parsing = { Exception: function (s) { this.message = "Parse error at '" + s.substring(0, 10) + " ...'"; } }; var $P = Date.Parsing; var dayOffsets = { standard: [0,31,59,90,120,151,181,212,243,273,304,334], leap: [0,31,60,91,121,152,182,213,244,274,305,335] }; $P.isLeapYear = function(year) { return ((year % 4 === 0) && (year % 100 !== 0)) || (year % 400 === 0); }; var utils = { multiReplace : function (str, hash ) { var key; for (key in hash) { if (Object.prototype.hasOwnProperty.call(hash, key)) { var regex; if (typeof hash[key] === "function") { } else { regex = (hash[key] instanceof RegExp) ? hash[key] : new RegExp(hash[key], "g"); } str = str.replace(regex, key); } } return str; }, getDayOfYearFromWeek : function (obj) { var d, jan4, offset; obj.weekDay = (!obj.weekDay && obj.weekDay !== 0) ? 1 : obj.weekDay; d = new Date(obj.year, 0, 4); jan4 = d.getDay() === 0 ? 7 : d.getDay(); // JS is 0 indexed on Sunday. offset = jan4+3; obj.dayOfYear = ((obj.week * 7) + (obj.weekDay === 0 ? 7 : obj.weekDay))-offset; return obj; }, getDayOfYear : function (obj, dayOffset) { if (!obj.dayOfYear) { obj = utils.getDayOfYearFromWeek(obj); } for (var i=0;i <= dayOffset.length;i++) { if (obj.dayOfYear < dayOffset[i] || i === dayOffset.length) { obj.day = obj.day ? obj.day : (obj.dayOfYear - dayOffset[i-1]); break; } else { obj.month = i; } } return obj; }, adjustForTimeZone : function (obj, date) { var offset; if (obj.zone.toUpperCase() === "Z" || (obj.zone_hours === 0 && obj.zone_minutes === 0)) { // it's UTC/GML so work out the current timeszone offset offset = -date.getTimezoneOffset(); } else { offset = (obj.zone_hours*60) + (obj.zone_minutes || 0); if (obj.zone_sign === "+") { offset *= -1; } offset -= date.getTimezoneOffset(); } date.setMinutes(date.getMinutes()+offset); return date; }, setDefaults : function (obj) { obj.year = obj.year || Date.today().getFullYear(); obj.hours = obj.hours || 0; obj.minutes = obj.minutes || 0; obj.seconds = obj.seconds || 0; obj.milliseconds = obj.milliseconds || 0; if (!(!obj.month && (obj.week || obj.dayOfYear))) { // if we have a month, or if we don't but don't have the day calculation data obj.month = obj.month || 0; obj.day = obj.day || 1; } return obj; }, dataNum: function (data, mod, explict, postProcess) { var dataNum = data*1; if (mod) { if (postProcess) { return data ? mod(data)*1 : data; } else { return data ? mod(dataNum) : data; } } else if (!explict){ return data ? dataNum : data; } else { return (data && typeof data !== "undefined") ? dataNum : data; } }, timeDataProcess: function (obj) { var timeObj = {}; for (var x in obj.data) { if (obj.data.hasOwnProperty(x)) { timeObj[x] = obj.ignore[x] ? obj.data[x] : utils.dataNum(obj.data[x], obj.mods[x], obj.explict[x], obj.postProcess[x]); } } if (obj.data.secmins) { obj.data.secmins = obj.data.secmins.replace(",", ".") * 60; if (!timeObj.minutes) { timeObj.minutes = obj.data.secmins; } else if (!timeObj.seconds) { timeObj.seconds = obj.data.secmins; } delete obj.secmins; } return timeObj; }, buildTimeObjectFromData: function (data) { var time = utils.timeDataProcess({ data: { year : data[1], month : data[5], day : data[7], week : data[8], dayOfYear : data[10], hours : data[15], zone_hours : data[23], zone_minutes : data[24], zone : data[21], zone_sign : data[22], weekDay : data[9], minutes: data[16], seconds: data[19], milliseconds: data[20], secmins: data[18] }, mods: { month: function(data) { return data-1; }, weekDay: function (data) { data = Math.abs(data); return (data === 7 ? 0 : data); }, minutes: function (data) { return data.replace(":",""); }, seconds: function (data) { return Math.floor( (data.replace(":","").replace(",","."))*1 ); }, milliseconds: function (data) { return (data.replace(",",".")*1000); } }, postProcess: { minutes: true, seconds: true, milliseconds: true }, explict: { zone_hours: true, zone_minutes: true }, ignore: { zone: true, zone_sign: true, secmins: true } }); return time; }, addToHash: function (hash, keys, data) { keys = keys; data = data; var len = keys.length; for (var i = 0; i < len; i++) { hash[keys[i]] = data[i]; } return hash; }, combineRegex: function (r1, r2) { return new RegExp("(("+r1.source+")\\s("+r2.source+"))"); }, getDateNthString: function(add, last, inc){ if (add) { return Date.today().addDays(inc).toString("d"); } else if (last) { return Date.today().last()[inc]().toString("d"); } }, buildRegexData: function (array) { var arr = []; var len = array.length; for (var i=0; i < len; i++) { if (Object.prototype.toString.call(array[i]) === '[object Array]') { // oldIE compat version of Array.isArray arr.push(this.combineRegex(array[i][0], array[i][1])); } else { arr.push(array[i]); } } return arr; } }; $P.processTimeObject = function (obj) { var date, dayOffset; utils.setDefaults(obj); dayOffset = ($P.isLeapYear(obj.year)) ? dayOffsets.leap : dayOffsets.standard; if (!obj.month && (obj.week || obj.dayOfYear)) { utils.getDayOfYear(obj, dayOffset); } else { obj.dayOfYear = dayOffset[obj.month] + obj.day; } date = new Date(obj.year, obj.month, obj.day, obj.hours, obj.minutes, obj.seconds, obj.milliseconds); if (obj.zone) { utils.adjustForTimeZone(obj, date); // adjust (and calculate) for timezone } return date; }; $P.ISO = { regex : /^([\+-]?\d{4}(?!\d{2}\b))((-?)((0[1-9]|1[0-2])(\3([12]\d|0[1-9]|3[01]))?|W([0-4]\d|5[0-3])(-?[1-7])?|(00[1-9]|0[1-9]\d|[12]\d{2}|3([0-5]\d|6[1-6])))([T\s]((([01]\d|2[0-4])((:?)[0-5]\d)?|24\:?00)([\.,]\d+(?!:))?)?(\17[0-5]\d([\.,]\d+)?)?\s?([zZ]|([\+-])([01]\d|2[0-3]):?([0-5]\d)?)?)?)?$/, parse : function (s) { var time, data = s.match(this.regex); if (!data || !data.length) { return null; } time = utils.buildTimeObjectFromData(data); if (!time.year || (!time.year && (!time.month && !time.day) && (!time.week && !time.dayOfYear)) ) { return null; } return $P.processTimeObject(time); } }; $P.Numeric = { isNumeric: function (e){return!isNaN(parseFloat(e))&&isFinite(e);}, regex: /\b([0-1]?[0-9])([0-3]?[0-9])([0-2]?[0-9]?[0-9][0-9])\b/i, parse: function (s) { var data, i, time = {}, order = Date.CultureInfo.dateElementOrder.split(""); if (!(this.isNumeric(s)) || // if it's non-numeric OR (s[0] === "+" && s[0] === "-")) { // It's an arithmatic string (eg +/-1000) return null; } if (s.length < 5 && s.indexOf(".") < 0 && s.indexOf("/") < 0) { // assume it's just a year. time.year = s; return $P.processTimeObject(time); } data = s.match(this.regex); if (!data || !data.length) { return null; } for (i=0; i < order.length; i++) { switch(order[i]) { case "d": time.day = data[i+1]; break; case "m": time.month = (data[i+1]-1); break; case "y": time.year = data[i+1]; break; } } return $P.processTimeObject(time); } }; $P.Normalizer = { regexData: function () { var $R = Date.CultureInfo.regexPatterns; return utils.buildRegexData([ $R.tomorrow, $R.yesterday, [$R.past, $R.mon], [$R.past, $R.tue], [$R.past, $R.wed], [$R.past, $R.thu], [$R.past, $R.fri], [$R.past, $R.sat], [$R.past, $R.sun] ]); }, basicReplaceHash : function() { var $R = Date.CultureInfo.regexPatterns; return { "January": $R.jan.source, "February": $R.feb, "March": $R.mar, "April": $R.apr, "May": $R.may, "June": $R.jun, "July": $R.jul, "August": $R.aug, "September": $R.sep, "October": $R.oct, "November": $R.nov, "December": $R.dec, "": /\bat\b/gi, " ": /\s{2,}/, "am": $R.inTheMorning, "9am": $R.thisMorning, "pm": $R.inTheEvening, "7pm":$R.thisEvening }; }, keys : function(){ return [ utils.getDateNthString(true, false, 1), // tomorrow utils.getDateNthString(true, false, -1), // yesterday utils.getDateNthString(false, true, "monday"), //last mon utils.getDateNthString(false, true, "tuesday"), //last tues utils.getDateNthString(false, true, "wednesday"), //last wed utils.getDateNthString(false, true, "thursday"), //last thurs utils.getDateNthString(false, true, "friday"), //last fri utils.getDateNthString(false, true, "saturday"), //last sat utils.getDateNthString(false, true, "sunday") //last sun ]; }, buildRegexFunctions: function () { var $R = Date.CultureInfo.regexPatterns; var __ = Date.i18n.__; var tomorrowRE = new RegExp("(\\b\\d\\d?("+__("AM")+"|"+__("PM")+")? )("+$R.tomorrow.source.slice(1)+")", "i"); // adapted tomorrow regex for AM PM relative dates var todayRE = new RegExp($R.today.source + "(?!\\s*([+-]))\\b"); // today, but excludes the math operators (eg "today + 2h") this.replaceFuncs = [ [todayRE, function (full) { return (full.length > 1) ? Date.today().toString("d") : full; }], [tomorrowRE, function(full, m1) { var t = Date.today().addDays(1).toString("d"); return (t + " " + m1); }], [$R.amThisMorning, function(str, am){return am;}], [$R.pmThisEvening, function(str, pm){return pm;}] ]; }, buildReplaceData: function () { this.buildRegexFunctions(); this.replaceHash = utils.addToHash(this.basicReplaceHash(), this.keys(), this.regexData()); }, stringReplaceFuncs: function (s) { for (var i=0; i < this.replaceFuncs.length; i++) { s = s.replace(this.replaceFuncs[i][0], this.replaceFuncs[i][1]); } return s; }, parse: function (s) { s = this.stringReplaceFuncs(s); s = utils.multiReplace(s, this.replaceHash); try { var n = s.split(/([\s\-\.\,\/\x27]+)/); if (n.length === 3 && $P.Numeric.isNumeric(n[0]) && $P.Numeric.isNumeric(n[2]) && (n[2].length >= 4)) { // ok, so we're dealing with x/year. But that's not a full date. // This fixes wonky dateElementOrder parsing when set to dmy order. if (Date.CultureInfo.dateElementOrder[0] === "d") { s = "1/" + n[0] + "/" + n[2]; // set to 1st of month and normalize the seperator } } } catch (e) {} return s; } }; $P.Normalizer.buildReplaceData(); }()); (function () { var $P = Date.Parsing; var _ = $P.Operators = { // // Tokenizers // rtoken: function (r) { // regex token return function (s) { var mx = s.match(r); if (mx) { return ([ mx[0], s.substring(mx[0].length) ]); } else { throw new $P.Exception(s); } }; }, token: function () { // whitespace-eating token return function (s) { return _.rtoken(new RegExp("^\\s*" + s + "\\s*"))(s); }; }, stoken: function (s) { // string token return _.rtoken(new RegExp("^" + s)); }, // Atomic Operators until: function (p) { return function (s) { var qx = [], rx = null; while (s.length) { try { rx = p.call(this, s); } catch (e) { qx.push(rx[0]); s = rx[1]; continue; } break; } return [ qx, s ]; }; }, many: function (p) { return function (s) { var rx = [], r = null; while (s.length) { try { r = p.call(this, s); } catch (e) { return [ rx, s ]; } rx.push(r[0]); s = r[1]; } return [ rx, s ]; }; }, // generator operators -- see below optional: function (p) { return function (s) { var r = null; try { r = p.call(this, s); } catch (e) { return [ null, s ]; } return [ r[0], r[1] ]; }; }, not: function (p) { return function (s) { try { p.call(this, s); } catch (e) { return [null, s]; } throw new $P.Exception(s); }; }, ignore: function (p) { return p ? function (s) { var r = null; r = p.call(this, s); return [null, r[1]]; } : null; }, product: function () { var px = arguments[0], qx = Array.prototype.slice.call(arguments, 1), rx = []; for (var i = 0 ; i < px.length ; i++) { rx.push(_.each(px[i], qx)); } return rx; }, cache: function (rule) { var cache = {}, cache_length = 0, cache_keys = [], CACHE_MAX = Date.Config.CACHE_MAX || 100000, r = null; var cacheCheck = function () { if (cache_length === CACHE_MAX) { // kill several keys, don't want to have to do this all the time... for (var i=0; i < 10; i++) { var key = cache_keys.shift(); if (key) { delete cache[key]; cache_length--; } } } }; return function (s) { cacheCheck(); try { r = cache[s] = (cache[s] || rule.call(this, s)); } catch (e) { r = cache[s] = e; } cache_length++; cache_keys.push(s); if (r instanceof $P.Exception) { throw r; } else { return r; } }; }, // vector operators -- see below any: function () { var px = arguments; return function (s) { var r = null; for (var i = 0; i < px.length; i++) { if (px[i] == null) { continue; } try { r = (px[i].call(this, s)); } catch (e) { r = null; } if (r) { return r; } } throw new $P.Exception(s); }; }, each: function () { var px = arguments; return function (s) { var rx = [], r = null; for (var i = 0; i < px.length ; i++) { if (px[i] == null) { continue; } try { r = (px[i].call(this, s)); } catch (e) { throw new $P.Exception(s); } rx.push(r[0]); s = r[1]; } return [ rx, s]; }; }, all: function () { var px = arguments, _ = _; return _.each(_.optional(px)); }, // delimited operators sequence: function (px, d, c) { d = d || _.rtoken(/^\s*/); c = c || null; if (px.length === 1) { return px[0]; } return function (s) { var r = null, q = null; var rx = []; for (var i = 0; i < px.length ; i++) { try { r = px[i].call(this, s); } catch (e) { break; } rx.push(r[0]); try { q = d.call(this, r[1]); } catch (ex) { q = null; break; } s = q[1]; } if (!r) { throw new $P.Exception(s); } if (q) { throw new $P.Exception(q[1]); } if (c) { try { r = c.call(this, r[1]); } catch (ey) { throw new $P.Exception(r[1]); } } return [ rx, (r?r[1]:s) ]; }; }, // // Composite Operators // between: function (d1, p, d2) { d2 = d2 || d1; var _fn = _.each(_.ignore(d1), p, _.ignore(d2)); return function (s) { var rx = _fn.call(this, s); return [[rx[0][0], r[0][2]], rx[1]]; }; }, list: function (p, d, c) { d = d || _.rtoken(/^\s*/); c = c || null; return (p instanceof Array ? _.each(_.product(p.slice(0, -1), _.ignore(d)), p.slice(-1), _.ignore(c)) : _.each(_.many(_.each(p, _.ignore(d))), px, _.ignore(c))); }, set: function (px, d, c) { d = d || _.rtoken(/^\s*/); c = c || null; return function (s) { // r is the current match, best the current 'best' match // which means it parsed the most amount of input var r = null, p = null, q = null, rx = null, best = [[], s], last = false; // go through the rules in the given set for (var i = 0; i < px.length ; i++) { // last is a flag indicating whether this must be the last element // if there is only 1 element, then it MUST be the last one q = null; p = null; r = null; last = (px.length === 1); // first, we try simply to match the current pattern // if not, try the next pattern try { r = px[i].call(this, s); } catch (e) { continue; } // since we are matching against a set of elements, the first // thing to do is to add r[0] to matched elements rx = [[r[0]], r[1]]; // if we matched and there is still input to parse and // we don't already know this is the last element, // we're going to next check for the delimiter ... // if there's none, or if there's no input left to parse // than this must be the last element after all ... if (r[1].length > 0 && ! last) { try { q = d.call(this, r[1]); } catch (ex) { last = true; } } else { last = true; } // if we parsed the delimiter and now there's no more input, // that means we shouldn't have parsed the delimiter at all // so don't update r and mark this as the last element ... if (!last && q[1].length === 0) { last = true; } // so, if this isn't the last element, we're going to see if // we can get any more matches from the remaining (unmatched) // elements ... if (!last) { // build a list of the remaining rules we can match against, // i.e., all but the one we just matched against var qx = []; for (var j = 0; j < px.length ; j++) { if (i !== j) { qx.push(px[j]); } } // now invoke recursively set with the remaining input // note that we don't include the closing delimiter ... // we'll check for that ourselves at the end p = _.set(qx, d).call(this, q[1]); // if we got a non-empty set as a result ... // (otw rx already contains everything we want to match) if (p[0].length > 0) { // update current result, which is stored in rx ... // basically, pick up the remaining text from p[1] // and concat the result from p[0] so that we don't // get endless nesting ... rx[0] = rx[0].concat(p[0]); rx[1] = p[1]; } } // at this point, rx either contains the last matched element // or the entire matched set that starts with this element. // now we just check to see if this variation is better than // our best so far, in terms of how much of the input is parsed if (rx[1].length < best[1].length) { best = rx; } // if we've parsed all the input, then we're finished if (best[1].length === 0) { break; } } // so now we've either gone through all the patterns trying them // as the initial match; or we found one that parsed the entire // input string ... // if best has no matches, just return empty set ... if (best[0].length === 0) { return best; } // if a closing delimiter is provided, then we have to check it also if (c) { // we try this even if there is no remaining input because the pattern // may well be optional or match empty input ... try { q = c.call(this, best[1]); } catch (ey) { throw new $P.Exception(best[1]); } // it parsed ... be sure to update the best match remaining input best[1] = q[1]; } // if we're here, either there was no closing delimiter or we parsed it // so now we have the best match; just return it! return best; }; }, forward: function (gr, fname) { return function (s) { return gr[fname].call(this, s); }; }, // // Translation Operators // replace: function (rule, repl) { return function (s) { var r = rule.call(this, s); return [repl, r[1]]; }; }, process: function (rule, fn) { return function (s) { var r = rule.call(this, s); return [fn.call(this, r[0]), r[1]]; }; }, min: function (min, rule) { return function (s) { var rx = rule.call(this, s); if (rx[0].length < min) { throw new $P.Exception(s); } return rx; }; } }; // Generator Operators And Vector Operators // Generators are operators that have a signature of F(R) => R, // taking a given rule and returning another rule, such as // ignore, which parses a given rule and throws away the result. // Vector operators are those that have a signature of F(R1,R2,...) => R, // take a list of rules and returning a new rule, such as each. // Generator operators are converted (via the following _generator // function) into functions that can also take a list or array of rules // and return an array of new rules as though the function had been // called on each rule in turn (which is what actually happens). // This allows generators to be used with vector operators more easily. // Example: // each(ignore(foo, bar)) instead of each(ignore(foo), ignore(bar)) // This also turns generators into vector operators, which allows // constructs like: // not(cache(foo, bar)) var _generator = function (op) { function gen() { var args = null, rx = [], px, i; if (arguments.length > 1) { args = Array.prototype.slice.call(arguments); } else if (arguments[0] instanceof Array) { args = arguments[0]; } if (args) { px = args.shift(); if (px.length > 0) { args.unshift(px[i]); rx.push(op.apply(null, args)); args.shift(); return rx; } } else { return op.apply(null, arguments); } } return gen; }; var gx = "optional not ignore cache".split(/\s/); for (var i = 0 ; i < gx.length ; i++) { _[gx[i]] = _generator(_[gx[i]]); } var _vector = function (op) { return function () { if (arguments[0] instanceof Array) { return op.apply(null, arguments[0]); } else { return op.apply(null, arguments); } }; }; var vx = "each any all".split(/\s/); for (var j = 0 ; j < vx.length ; j++) { _[vx[j]] = _vector(_[vx[j]]); } }()); (function () { var $D = Date; var flattenAndCompact = function (ax) { var rx = []; for (var i = 0; i < ax.length; i++) { if (ax[i] instanceof Array) { rx = rx.concat(flattenAndCompact(ax[i])); } else { if (ax[i]) { rx.push(ax[i]); } } } return rx; }; var parseMeridian = function () { if (this.meridian && (this.hour || this.hour === 0)) { if (this.meridian === "a" && this.hour > 11 && Date.Config.strict24hr){ throw "Invalid hour and meridian combination"; } else if (this.meridian === "p" && this.hour < 12 && Date.Config.strict24hr){ throw "Invalid hour and meridian combination"; } else if (this.meridian === "p" && this.hour < 12) { this.hour = this.hour + 12; } else if (this.meridian === "a" && this.hour === 12) { this.hour = 0; } } }; var setDefaults = function () { var now = new Date(); if ((this.hour || this.minute) && (!this.month && !this.year && !this.day)) { this.day = now.getDate(); } if (!this.year) { this.year = now.getFullYear(); } if (!this.month && this.month !== 0) { this.month = now.getMonth(); } if (!this.day) { this.day = 1; } if (!this.hour) { this.hour = 0; } if (!this.minute) { this.minute = 0; } if (!this.second) { this.second = 0; } if (!this.millisecond) { this.millisecond = 0; } }; var finishUtils = { getToday: function () { if (this.now || "hour minute second".indexOf(this.unit) !== -1) { return new Date(); } else { return $D.today(); } }, setDaysFromWeekday: function (today, orient){ var gap; orient = orient || 1; this.unit = "day"; gap = ($D.getDayNumberFromName(this.weekday) - today.getDay()); this.days = gap ? ((gap + (orient * 7)) % 7) : (orient * 7); return this; }, setMonthsFromMonth: function (today, orient) { var gap; orient = orient || 1; this.unit = "month"; gap = (this.month - today.getMonth()); this.months = gap ? ((gap + (orient * 12)) % 12) : (orient * 12); this.month = null; return this; }, setDMYFromWeekday: function () { var d = Date[this.weekday](); this.day = d.getDate(); if (!this.month) { this.month = d.getMonth(); } this.year = d.getFullYear(); return this; }, setUnitValue: function (orient) { if (!this.value && this.operator && this.operator !== null && this[this.unit + "s"] && this[this.unit + "s"] !== null) { this[this.unit + "s"] = this[this.unit + "s"] + ((this.operator === "add") ? 1 : -1) + (this.value||0) * orient; } else if (this[this.unit + "s"] == null || this.operator != null) { if (!this.value) { this.value = 1; } this[this.unit + "s"] = this.value * orient; } }, generateDateFromWeeks: function () { var weekday = (this.weekday !== undefined) ? this.weekday : "today"; var d = Date[weekday]().addWeeks(this.weeks); if (this.now) { d.setTimeToNow(); } return d; } }; $D.Translator = { hour: function (s) { return function () { this.hour = Number(s); }; }, minute: function (s) { return function () { this.minute = Number(s); }; }, second: function (s) { return function () { this.second = Number(s); }; }, /* for ss.s format */ secondAndMillisecond: function (s) { return function () { var mx = s.match(/^([0-5][0-9])\.([0-9]{1,3})/); this.second = Number(mx[1]); this.millisecond = Number(mx[2]); }; }, meridian: function (s) { return function () { this.meridian = s.slice(0, 1).toLowerCase(); }; }, timezone: function (s) { return function () { var n = s.replace(/[^\d\+\-]/g, ""); if (n.length) { this.timezoneOffset = Number(n); } else { this.timezone = s.toLowerCase(); } }; }, day: function (x) { var s = x[0]; return function () { this.day = Number(s.match(/\d+/)[0]); if (this.day < 1) { throw "invalid day"; } }; }, month: function (s) { return function () { this.month = (s.length === 3) ? "jan feb mar apr may jun jul aug sep oct nov dec".indexOf(s)/4 : Number(s) - 1; if (this.month < 0) { throw "invalid month"; } }; }, year: function (s) { return function () { var n = Number(s); this.year = ((s.length > 2) ? n : (n + (((n + 2000) < Date.CultureInfo.twoDigitYearMax) ? 2000 : 1900))); }; }, rday: function (s) { return function () { switch (s) { case "yesterday": this.days = -1; break; case "tomorrow": this.days = 1; break; case "today": this.days = 0; break; case "now": this.days = 0; this.now = true; break; } }; }, finishExact: function (x) { var d; x = (x instanceof Array) ? x : [x]; for (var i = 0 ; i < x.length ; i++) { if (x[i]) { x[i].call(this); } } setDefaults.call(this); parseMeridian.call(this); if (this.day > $D.getDaysInMonth(this.year, this.month)) { throw new RangeError(this.day + " is not a valid value for days."); } d = new Date(this.year, this.month, this.day, this.hour, this.minute, this.second, this.millisecond); if (this.year < 100) { d.setFullYear(this.year); // means years less that 100 are process correctly. JS will parse it otherwise as 1900-1999. } if (this.timezone) { d.set({ timezone: this.timezone }); } else if (this.timezoneOffset) { d.set({ timezoneOffset: this.timezoneOffset }); } return d; }, finish: function (x) { var today, expression, orient, temp; x = (x instanceof Array) ? flattenAndCompact(x) : [ x ]; if (x.length === 0) { return null; } for (var i = 0 ; i < x.length ; i++) { if (typeof x[i] === "function") { x[i].call(this); } } if (this.now && !this.unit && !this.operator) { return new Date(); } else { today = finishUtils.getToday.call(this); } expression = !!(this.days && this.days !== null || this.orient || this.operator); orient = ((this.orient === "past" || this.operator === "subtract") ? -1 : 1); if (this.month && this.unit === "week") { this.value = this.month + 1; delete this.month; delete this.day; } if ((this.month || this.month === 0) && "year day hour minute second".indexOf(this.unit) !== -1) { if (!this.value) { this.value = this.month + 1; } this.month = null; expression = true; } if (!expression && this.weekday && !this.day && !this.days) { finishUtils.setDMYFromWeekday.call(this); } if (expression && this.weekday && this.unit !== "month" && this.unit !== "week") { finishUtils.setDaysFromWeekday.call(this, today, orient); } if (this.weekday && this.unit !== "week" && !this.day && !this.days) { temp = Date[this.weekday](); this.day = temp.getDate(); if (temp.getMonth() !== today.getMonth()) { this.month = temp.getMonth(); } } if (this.month && this.unit === "day" && this.operator) { if (!this.value) { this.value = (this.month + 1); } this.month = null; } if (this.value != null && this.month != null && this.year != null) { this.day = this.value * 1; } if (this.month && !this.day && this.value) { today.set({ day: this.value * 1 }); if (!expression) { this.day = this.value * 1; } } if (!this.month && this.value && this.unit === "month" && !this.now) { this.month = this.value; expression = true; } if (expression && (this.month || this.month === 0) && this.unit !== "year") { finishUtils.setMonthsFromMonth.call(this, today, orient); } if (!this.unit) { this.unit = "day"; } finishUtils.setUnitValue.call(this, orient); parseMeridian.call(this); if ((this.month || this.month === 0) && !this.day) { this.day = 1; } if (!this.orient && !this.operator && this.unit === "week" && this.value && !this.day && !this.month) { return Date.today().setWeek(this.value); } if (this.unit === "week" && this.weeks && !this.day && !this.month) { return finishUtils.generateDateFromWeeks.call(this); } if (expression && this.timezone && this.day && this.days) { this.day = this.days; } if (expression){ today.add(this); } else { today.set(this); } if (this.timezone) { this.timezone = this.timezone.toUpperCase(); var offset = $D.getTimezoneOffset(this.timezone); var timezone; if (today.hasDaylightSavingTime()) { // lets check that we're being sane with timezone setting timezone = $D.getTimezoneAbbreviation(offset, today.isDaylightSavingTime()); if (timezone !== this.timezone) { // bugger, we're in a place where things like EST vs EDT matters. if (today.isDaylightSavingTime()) { today.addHours(-1); } else { today.addHours(1); } } } today.setTimezoneOffset(offset); } return today; } }; }()); (function () { var $D = Date; $D.Grammar = {}; var _ = $D.Parsing.Operators, g = $D.Grammar, t = $D.Translator, _fn; // Allow rolling up into general purpose rules _fn = function () { return _.each(_.any.apply(null, arguments), _.not(g.ctoken2("timeContext"))); }; g.datePartDelimiter = _.rtoken(/^([\s\-\.\,\/\x27]+)/); g.timePartDelimiter = _.stoken(":"); g.whiteSpace = _.rtoken(/^\s*/); g.generalDelimiter = _.rtoken(/^(([\s\,]|at|@|on)+)/); var _C = {}; g.ctoken = function (keys) { var fn = _C[keys]; if (! fn) { var c = Date.CultureInfo.regexPatterns; var kx = keys.split(/\s+/), px = []; for (var i = 0; i < kx.length ; i++) { px.push(_.replace(_.rtoken(c[kx[i]]), kx[i])); } fn = _C[keys] = _.any.apply(null, px); } return fn; }; g.ctoken2 = function (key) { return _.rtoken(Date.CultureInfo.regexPatterns[key]); }; var cacheProcessRtoken = function (key, token, type, eachToken) { if (eachToken) { g[key] = _.cache(_.process(_.each(_.rtoken(token),_.optional(g.ctoken2(eachToken))), type)); } else { g[key] = _.cache(_.process(_.rtoken(token), type)); } }; var cacheProcessCtoken = function (token, type) { return _.cache(_.process(g.ctoken2(token), type)); }; var _F = {}; //function cache var _get = function (f) { _F[f] = (_F[f] || g.format(f)[0]); return _F[f]; }; g.allformats = function (fx) { var rx = []; if (fx instanceof Array) { for (var i = 0; i < fx.length; i++) { rx.push(_get(fx[i])); } } else { rx.push(_get(fx)); } return rx; }; g.formats = function (fx) { if (fx instanceof Array) { var rx = []; for (var i = 0 ; i < fx.length ; i++) { rx.push(_get(fx[i])); } return _.any.apply(null, rx); } else { return _get(fx); } }; var grammarFormats = { timeFormats: function(){ var i, RTokenKeys = [ "h", "hh", "H", "HH", "m", "mm", "s", "ss", "ss.s", "z", "zz" ], RToken = [ /^(0[0-9]|1[0-2]|[1-9])/, /^(0[0-9]|1[0-2])/, /^([0-1][0-9]|2[0-3]|[0-9])/, /^([0-1][0-9]|2[0-3])/, /^([0-5][0-9]|[0-9])/, /^[0-5][0-9]/, /^([0-5][0-9]|[0-9])/, /^[0-5][0-9]/, /^[0-5][0-9]\.[0-9]{1,3}/, /^((\+|\-)\s*\d\d\d\d)|((\+|\-)\d\d\:?\d\d)/, /^((\+|\-)\s*\d\d\d\d)|((\+|\-)\d\d\:?\d\d)/ ], tokens = [ t.hour, t.hour, t.hour, t.hour, t.minute, t.minute, t.second, t.second, t.secondAndMillisecond, t.timezone, t.timezone ]; for (i=0; i < RTokenKeys.length; i++) { cacheProcessRtoken(RTokenKeys[i], RToken[i], tokens[i]); } g.hms = _.cache(_.sequence([g.H, g.m, g.s], g.timePartDelimiter)); g.t = cacheProcessCtoken("shortMeridian", t.meridian); g.tt = cacheProcessCtoken("longMeridian", t.meridian); g.zzz = cacheProcessCtoken("timezone", t.timezone); g.timeSuffix = _.each(_.ignore(g.whiteSpace), _.set([ g.tt, g.zzz ])); g.time = _.each(_.optional(_.ignore(_.stoken("T"))), g.hms, g.timeSuffix); }, dateFormats: function () { // pre-loaded rules for different date part order preferences var _setfn = function () { return _.set(arguments, g.datePartDelimiter); }; var i, RTokenKeys = [ "d", "dd", "M", "MM", "y", "yy", "yyy", "yyyy" ], RToken = [ /^([0-2]\d|3[0-1]|\d)/, /^([0-2]\d|3[0-1])/, /^(1[0-2]|0\d|\d)/, /^(1[0-2]|0\d)/, /^(\d+)/, /^(\d\d)/, /^(\d\d?\d?\d?)/, /^(\d\d\d\d)/ ], tokens = [ t.day, t.day, t.month, t.month, t.year, t.year, t.year, t.year ], eachToken = [ "ordinalSuffix", "ordinalSuffix" ]; for (i=0; i < RTokenKeys.length; i++) { cacheProcessRtoken(RTokenKeys[i], RToken[i], tokens[i], eachToken[i]); } g.MMM = g.MMMM = _.cache(_.process(g.ctoken("jan feb mar apr may jun jul aug sep oct nov dec"), t.month)); g.ddd = g.dddd = _.cache(_.process(g.ctoken("sun mon tue wed thu fri sat"), function (s) { return function () { this.weekday = s; }; } )); g.day = _fn(g.d, g.dd); g.month = _fn(g.M, g.MMM); g.year = _fn(g.yyyy, g.yy); g.mdy = _setfn(g.ddd, g.month, g.day, g.year); g.ymd = _setfn(g.ddd, g.year, g.month, g.day); g.dmy = _setfn(g.ddd, g.day, g.month, g.year); g.date = function (s) { return ((g[Date.CultureInfo.dateElementOrder] || g.mdy).call(this, s)); }; }, relative: function () { // relative date / time expressions g.orientation = _.process(g.ctoken("past future"), function (s) { return function () { this.orient = s; }; } ); g.operator = _.process(g.ctoken("add subtract"), function (s) { return function () { this.operator = s; }; } ); g.rday = _.process(g.ctoken("yesterday tomorrow today now"), t.rday); g.unit = _.process(g.ctoken("second minute hour day week month year"), function (s) { return function () { this.unit = s; }; } ); } }; g.buildGrammarFormats = function () { // these need to be rebuilt every time the language changes. _C = {}; grammarFormats.timeFormats(); grammarFormats.dateFormats(); grammarFormats.relative(); g.value = _.process(_.rtoken(/^([-+]?\d+)?(st|nd|rd|th)?/), function (s) { return function () { this.value = s.replace(/\D/g, ""); }; } ); g.expression = _.set([g.rday, g.operator, g.value, g.unit, g.orientation, g.ddd, g.MMM ]); g.format = _.process(_.many( _.any( // translate format specifiers into grammar rules _.process( _.rtoken(/^(dd?d?d?(?!e)|MM?M?M?|yy?y?y?|hh?|HH?|mm?|ss?|tt?|zz?z?)/), function (fmt) { if (g[fmt]) { return g[fmt]; } else { throw $D.Parsing.Exception(fmt); } } ), // translate separator tokens into token rules _.process(_.rtoken(/^[^dMyhHmstz]+/), // all legal separators function (s) { return _.ignore(_.stoken(s)); } ) ) ), // construct the parser ... function (rules) { return _.process(_.each.apply(null, rules), t.finishExact); } ); // starting rule for general purpose grammar g._start = _.process(_.set([ g.date, g.time, g.expression ], g.generalDelimiter, g.whiteSpace), t.finish); }; g.buildGrammarFormats(); // parsing date format specifiers - ex: "h:m:s tt" // this little guy will generate a custom parser based // on the format string, ex: g.format("h:m:s tt") // check for these formats first g._formats = g.formats([ "\"yyyy-MM-ddTHH:mm:ssZ\"", "yyyy-MM-ddTHH:mm:ss.sz", "yyyy-MM-ddTHH:mm:ssZ", "yyyy-MM-ddTHH:mm:ssz", "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-ddTHH:mmZ", "yyyy-MM-ddTHH:mmz", "yyyy-MM-ddTHH:mm", "ddd, MMM dd, yyyy H:mm:ss tt", "ddd MMM d yyyy HH:mm:ss zzz", "MMddyyyy", "ddMMyyyy", "Mddyyyy", "ddMyyyy", "Mdyyyy", "dMyyyy", "yyyy", "Mdyy", "dMyy", "d" ]); // real starting rule: tries selected formats first, // then general purpose rule g.start = function (s) { try { var r = g._formats.call({}, s); if (r[1].length === 0) { return r; } } catch (e) {} return g._start.call({}, s); }; }()); (function () { var $D = Date; /** * @desc Converts the specified string value into its JavaScript Date equivalent using CultureInfo specific format information. * * Example

	///////////
	// Dates //
	///////////

	// 15-Oct-2004
	var d1 = Date.parse("10/15/2004");

	// 15-Oct-2004
	var d1 = Date.parse("15-Oct-2004");

	// 15-Oct-2004
	var d1 = Date.parse("2004.10.15");

	//Fri Oct 15, 2004
	var d1 = Date.parse("Fri Oct 15, 2004");

	///////////
	// Times //
	///////////

	// Today at 10 PM.
	var d1 = Date.parse("10 PM");

	// Today at 10:30 PM.
	var d1 = Date.parse("10:30 P.M.");

	// Today at 6 AM.
	var d1 = Date.parse("06am");

	/////////////////////
	// Dates and Times //
	/////////////////////

	// 8-July-2004 @ 10:30 PM
	var d1 = Date.parse("July 8th, 2004, 10:30 PM");

	// 1-July-2004 @ 10:30 PM
	var d1 = Date.parse("2004-07-01T22:30:00");

	////////////////////
	// Relative Dates //
	////////////////////

	// Returns today's date. The string "today" is culture specific.
	var d1 = Date.parse("today");

	// Returns yesterday's date. The string "yesterday" is culture specific.
	var d1 = Date.parse("yesterday");

	// Returns the date of the next thursday.
	var d1 = Date.parse("Next thursday");

	// Returns the date of the most previous monday.
	var d1 = Date.parse("last monday");

	// Returns today's day + one year.
	var d1 = Date.parse("next year");

	///////////////
	// Date Math //
	///////////////

	// Today + 2 days
	var d1 = Date.parse("t+2");

	// Today + 2 days
	var d1 = Date.parse("today + 2 days");

	// Today + 3 months
	var d1 = Date.parse("t+3m");

	// Today - 1 year
	var d1 = Date.parse("today - 1 year");

	// Today - 1 year
	var d1 = Date.parse("t-1y"); 


	/////////////////////////////
	// Partial Dates and Times //
	/////////////////////////////

	// July 15th of this year.
	var d1 = Date.parse("July 15");

	// 15th day of current day and year.
	var d1 = Date.parse("15");

	// July 1st of current year at 10pm.
	var d1 = Date.parse("7/1 10pm");
	
* * @param {String} The string value to convert into a Date object [Required] * @return {Date} A Date object or null if the string cannot be converted into a Date. */ var parseUtils = { removeOrds: function (s) { ords = s.match(/\b(\d+)(?:st|nd|rd|th)\b/); // find ordinal matches s = ((ords && ords.length === 2) ? s.replace(ords[0], ords[1]) : s); return s; }, grammarParser: function (s) { var r = null; try { r = $D.Grammar.start.call({}, s.replace(/^\s*(\S*(\s+\S+)*)\s*$/, "$1")); } catch (e) { return null; } return ((r[1].length === 0) ? r[0] : null); }, nativeFallback: function(s) { var t; try { // ok we haven't parsed it, last ditch attempt with the built-in parser. t = Date._parse(s); return (t || t === 0) ? new Date(t) : null; } catch (e) { return null; } } }; function parse (s) { var d; if (!s) { return null; } if (s instanceof Date) { return s.clone(); } if (s.length >= 4 && s.charAt(0) !== "0" && s.charAt(0) !== "+"&& s.charAt(0) !== "-") { // ie: 2004 will pass, 0800 won't. // Start with specific formats d = $D.Parsing.ISO.parse(s) || $D.Parsing.Numeric.parse(s); } if (d instanceof Date && !isNaN(d.getTime())) { return d; } else { // find ordinal dates (1st, 3rd, 8th, etc and remove them as they cause parsing issues) s = $D.Parsing.Normalizer.parse(parseUtils.removeOrds(s)); d = parseUtils.grammarParser(s); if (d !== null) { return d; } else { return parseUtils.nativeFallback(s); } } } if (!$D._parse) { $D._parse = $D.parse; } $D.parse = parse; Date.getParseFunction = function (fx) { var fns = Date.Grammar.allformats(fx); return function (s) { var r = null; for (var i = 0; i < fns.length; i++) { try { r = fns[i].call({}, s); } catch (e) { continue; } if (r[1].length === 0) { return r[0]; } } return null; }; }; /** * Converts the specified string value into its JavaScript Date equivalent using the specified format {String} or formats {Array} and the CultureInfo specific format information. * The format of the string value must match one of the supplied formats exactly. * * Example

	// 15-Oct-2004
	var d1 = Date.parseExact("10/15/2004", "M/d/yyyy");

	// 15-Oct-2004
	var d1 = Date.parse("15-Oct-2004", "M-ddd-yyyy");

	// 15-Oct-2004
	var d1 = Date.parse("2004.10.15", "yyyy.MM.dd");

	// Multiple formats
	var d1 = Date.parseExact("10/15/2004", ["M/d/yyyy", "MMMM d, yyyy"]);
	
* * @param {String} The string value to convert into a Date object [Required]. * @param {Object} The expected format {String} or an array of expected formats {Array} of the date string [Required]. * @return {Date} A Date object or null if the string cannot be converted into a Date. */ $D.parseExact = function (s, fx) { return $D.getParseFunction(fx)(s); }; }()); (function () { var $D = Date, $P = $D.prototype, // $C = $D.CultureInfo, // not used atm p = function (s, l) { if (!l) { l = 2; } return ("000" + s).slice(l * -1); }; /** * Converts a PHP format string to Java/.NET format string. * A PHP format string can be used with ._format or .format. * A Java/.NET format string can be used with .toString(). * The .parseExact function will only accept a Java/.NET format string * * Example * var f1 = "%m/%d/%y" * var f2 = Date.normalizeFormat(f1); // "MM/dd/yy" * * new Date().format(f1); // "04/13/08" * new Date()._format(f1); // "04/13/08" * new Date().toString(f2); // "04/13/08" * * var date = Date.parseExact("04/13/08", f2); // Sun Apr 13 2008 * * @param {String} A PHP format string consisting of one or more format spcifiers. * @return {String} The PHP format converted to a Java/.NET format string. */ var normalizerSubstitutions = { "d" : "dd", "%d": "dd", "D" : "ddd", "%a": "ddd", "j" : "dddd", "l" : "dddd", "%A": "dddd", "S" : "S", "F" : "MMMM", "%B": "MMMM", "m" : "MM", "%m": "MM", "M" : "MMM", "%b": "MMM", "%h": "MMM", "n" : "M", "Y" : "yyyy", "%Y": "yyyy", "y" : "yy", "%y": "yy", "g" : "h", "%I": "h", "G" : "H", "h" : "hh", "H" : "HH", "%H": "HH", "i" : "mm", "%M": "mm", "s" : "ss", "%S": "ss", "%r": "hh:mm tt", "%R": "H:mm", "%T": "H:mm:ss", "%X": "t", "%x": "d", "%e": "d", "%D": "MM/dd/yy", "%n": "\\n", "%t": "\\t", "e" : "z", "T" : "z", "%z": "z", "%Z": "z", "Z" : "ZZ", "N" : "u", "w" : "u", "%w": "u", "W" : "W", "%V": "W" }; var normalizer = { substitutes: function (m) { return normalizerSubstitutions[m]; }, interpreted: function (m, x) { var y; switch (m) { case "%u": return x.getDay() + 1; case "z": return x.getOrdinalNumber(); case "%j": return p(x.getOrdinalNumber(), 3); case "%U": var d1 = x.clone().set({month: 0, day: 1}).addDays(-1).moveToDayOfWeek(0), d2 = x.clone().addDays(1).moveToDayOfWeek(0, -1); return (d2 < d1) ? "00" : p((d2.getOrdinalNumber() - d1.getOrdinalNumber()) / 7 + 1); case "%W": return p(x.getWeek()); case "t": return $D.getDaysInMonth(x.getFullYear(), x.getMonth()); case "o": case "%G": return x.setWeek(x.getISOWeek()).toString("yyyy"); case "%g": return x._format("%G").slice(-2); case "a": case "%p": return t("tt").toLowerCase(); case "A": return t("tt").toUpperCase(); case "u": return p(x.getMilliseconds(), 3); case "I": return (x.isDaylightSavingTime()) ? 1 : 0; case "O": return x.getUTCOffset(); case "P": y = x.getUTCOffset(); return y.substring(0, y.length - 2) + ":" + y.substring(y.length - 2); case "B": var now = new Date(); return Math.floor(((now.getHours() * 3600) + (now.getMinutes() * 60) + now.getSeconds() + (now.getTimezoneOffset() + 60) * 60) / 86.4); case "c": return x.toISOString().replace(/\"/g, ""); case "U": return $D.strtotime("now"); case "%c": return t("d") + " " + t("t"); case "%C": return Math.floor(x.getFullYear() / 100 + 1); } }, shouldOverrideDefaults: function (m) { switch (m) { case "%e": return true; default: return false; } }, parse: function (m, context) { var formatString, c = context || new Date(); formatString = normalizer.substitutes(m); if (formatString) { return formatString; } formatString = normalizer.interpreted(m, c); if (formatString) { return formatString; } else { return m; } } }; $D.normalizeFormat = function (format, context) { return format.replace(/(%|\\)?.|%%/g, function(t){ return normalizer.parse(t, context); }); }; /** * Format a local Unix timestamp according to locale settings * * Example: * Date.strftime("%m/%d/%y", new Date()); // "04/13/08" * Date.strftime("c", "2008-04-13T17:52:03Z"); // "04/13/08" * * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @param {Number|String} The number representing the number of seconds that have elapsed since January 1, 1970 (local time). * @return {String} A string representation of the current Date object. */ $D.strftime = function (format, time) { var d = Date.parse(time); return d._format(format); }; /** * Parse any textual datetime description into a Unix timestamp. * A Unix timestamp is the number of seconds that have elapsed since January 1, 1970 (midnight UTC/GMT). * * Example: * Date.strtotime("04/13/08"); // 1208044800 * Date.strtotime("1970-01-01T00:00:00Z"); // 0 * * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @param {Object} A string or date object. * @return {String} A string representation of the current Date object. */ $D.strtotime = function (time) { var d = $D.parse(time); return Math.round($D.UTC(d.getUTCFullYear(), d.getUTCMonth(), d.getUTCDate(), d.getUTCHours(), d.getUTCMinutes(), d.getUTCSeconds(), d.getUTCMilliseconds()) / 1000); }; /** * Converts the value of the current Date object to its equivalent string representation using a PHP/Unix style of date format specifiers. * Format Specifiers * Format Description Example * ------ --------------------------------------------------------------------------- ----------------------- * %a abbreviated weekday name according to the current localed "Mon" through "Sun" * %A full weekday name according to the current localed "Sunday" through "Saturday" * %b abbreviated month name according to the current localed "Jan" through "Dec" * %B full month name according to the current locale "January" through "December" * %c preferred date and time representation for the current locale "4/13/2008 12:33 PM" * %C century number (the year divided by 100 and truncated to an integer) "00" to "99" * %d day of the month as a decimal number "01" to "31" * %D same as %m/%d/%y "04/13/08" * %e day of the month as a decimal number, a single digit is preceded by a space "1" to "31" * %g like %G, but without the century "08" * %G The 4-digit year corresponding to the ISO week number (see %V). "2008" * This has the same format and value as %Y, except that if the ISO week number * belongs to the previous or next year, that year is used instead. * %h same as %b "Jan" through "Dec" * %H hour as a decimal number using a 24-hour clock. "00" to "23" * %I hour as a decimal number using a 12-hour clock. "01" to "12" * %j day of the year as a decimal number. "001" to "366" * %m month as a decimal number. "01" to "12" * %M minute as a decimal number. "00" to "59" * %n newline character "\n" * %p either "am" or "pm" according to the given time value, or the "am" or "pm" * corresponding strings for the current locale. * %r time in a.m. and p.m. notation "8:44 PM" * %R time in 24 hour notation "20:44" * %S second as a decimal number "00" to "59" * %t tab character "\t" * %T current time, equal to %H:%M:%S "12:49:11" * %u weekday as a decimal number ["1", "7"], with "1" representing Monday "1" to "7" * %U week number of the current year as a decimal number, starting with the "0" to ("52" or "53") * first Sunday as the first day of the first week * %V The ISO 8601:1988 week number of the current year as a decimal number, "00" to ("52" or "53") * range 01 to 53, where week 1 is the first week that has at least 4 days * in the current year, and with Monday as the first day of the week. * (Use %G or %g for the year component that corresponds to the week number * for the specified timestamp.) * %W week number of the current year as a decimal number, starting with the "00" to ("52" or "53") * first Monday as the first day of the first week * %w day of the week as a decimal, Sunday being "0" "0" to "6" * %x preferred date representation for the current locale without the time "4/13/2008" * %X preferred time representation for the current locale without the date "12:53:05" * %y year as a decimal number without a century "00" "99" * %Y year as a decimal number including the century "2008" * %Z time zone or name or abbreviation "UTC", "EST", "PST" * %z same as %Z * %% a literal "%" characters "%" * d Day of the month, 2 digits with leading zeros "01" to "31" * D A textual representation of a day, three letters "Mon" through "Sun" * j Day of the month without leading zeros "1" to "31" * l A full textual representation of the day of the week (lowercase "L") "Sunday" through "Saturday" * N ISO-8601 numeric representation of the day of the week (added in PHP 5.1.0) "1" (for Monday) through "7" (for Sunday) * S English ordinal suffix for the day of the month, 2 characters "st", "nd", "rd" or "th". Works well with j * w Numeric representation of the day of the week "0" (for Sunday) through "6" (for Saturday) * z The day of the year (starting from "0") "0" through "365" * W ISO-8601 week number of year, weeks starting on Monday "00" to ("52" or "53") * F A full textual representation of a month, such as January or March "January" through "December" * m Numeric representation of a month, with leading zeros "01" through "12" * M A short textual representation of a month, three letters "Jan" through "Dec" * n Numeric representation of a month, without leading zeros "1" through "12" * t Number of days in the given month "28" through "31" * L Whether it's a leap year "1" if it is a leap year, "0" otherwise * o ISO-8601 year number. This has the same value as Y, except that if the "2008" * ISO week number (W) belongs to the previous or next year, that year * is used instead. * Y A full numeric representation of a year, 4 digits "2008" * y A two digit representation of a year "08" * a Lowercase Ante meridiem and Post meridiem "am" or "pm" * A Uppercase Ante meridiem and Post meridiem "AM" or "PM" * B Swatch Internet time "000" through "999" * g 12-hour format of an hour without leading zeros "1" through "12" * G 24-hour format of an hour without leading zeros "0" through "23" * h 12-hour format of an hour with leading zeros "01" through "12" * H 24-hour format of an hour with leading zeros "00" through "23" * i Minutes with leading zeros "00" to "59" * s Seconds, with leading zeros "00" through "59" * u Milliseconds "54321" * e Timezone identifier "UTC", "EST", "PST" * I Whether or not the date is in daylight saving time (uppercase i) "1" if Daylight Saving Time, "0" otherwise * O Difference to Greenwich time (GMT) in hours "+0200", "-0600" * P Difference to Greenwich time (GMT) with colon between hours and minutes "+02:00", "-06:00" * T Timezone abbreviation "UTC", "EST", "PST" * Z Timezone offset in seconds. The offset for timezones west of UTC is "-43200" through "50400" * always negative, and for those east of UTC is always positive. * c ISO 8601 date "2004-02-12T15:19:21+00:00" * r RFC 2822 formatted date "Thu, 21 Dec 2000 16:01:07 +0200" * U Seconds since the Unix Epoch (January 1 1970 00:00:00 GMT) "0" * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @return {String} A string representation of the current Date object. */ var formatReplace = function (context) { return function (m) { var formatString, override = false; if (m.charAt(0) === "\\" || m.substring(0, 2) === "%%") { return m.replace("\\", "").replace("%%", "%"); } override = normalizer.shouldOverrideDefaults(m); formatString = $D.normalizeFormat(m, context); if (formatString) { return context.toString(formatString, override); } }; }; $P._format = function (format) { var formatter = formatReplace(this); if (!format) { return this._toString(); } else { return format.replace(/(%|\\)?.|%%/g, formatter); } }; if (!$P.format) { $P.format = $P._format; } }()); (function () { "use strict"; var gFn = function (attr) { return function () { return this[attr]; }; }; var sFn = function (attr) { return function (val) { this[attr] = val; return this; }; }; var attrs = ["years", "months", "days", "hours", "minutes", "seconds", "milliseconds"]; var addSetFuncs = function (context, attrs) { for (var i = 0; i < attrs.length ; i++) { var $a = attrs[i], $b = $a.slice(0, 1).toUpperCase() + $a.slice(1); context.prototype[$a] = 0; context.prototype["get" + $b] = gFn($a); context.prototype["set" + $b] = sFn($a); } }; /** * new TimeSpan(milliseconds); * new TimeSpan(days, hours, minutes, seconds); * new TimeSpan(days, hours, minutes, seconds, milliseconds); */ var TimeSpan = function (days, hours, minutes, seconds, milliseconds) { if (arguments.length === 1 && typeof days === "number") { var orient = (days < 0) ? -1 : +1; var millsLeft = Math.abs(days); this.setDays(Math.floor(millsLeft / 86400000) * orient); millsLeft = millsLeft % 86400000; this.setHours(Math.floor(millsLeft / 3600000) * orient); millsLeft = millsLeft % 3600000; this.setMinutes(Math.floor(millsLeft / 60000) * orient); millsLeft = millsLeft % 60000; this.setSeconds(Math.floor(millsLeft / 1000) * orient); millsLeft = millsLeft % 1000; this.setMilliseconds(millsLeft * orient); } else { this.set(days, hours, minutes, seconds, milliseconds); } this.getTotalMilliseconds = function () { return (this.getDays() * 86400000) + (this.getHours() * 3600000) + (this.getMinutes() * 60000) + (this.getSeconds() * 1000); }; this.compareTo = function (time) { var t1 = new Date(1970, 1, 1, this.getHours(), this.getMinutes(), this.getSeconds()), t2; if (time === null) { t2 = new Date(1970, 1, 1, 0, 0, 0); } else { t2 = new Date(1970, 1, 1, time.getHours(), time.getMinutes(), time.getSeconds()); } return (t1 < t2) ? -1 : (t1 > t2) ? 1 : 0; }; this.equals = function (time) { return (this.compareTo(time) === 0); }; this.add = function (time) { return (time === null) ? this : this.addSeconds(time.getTotalMilliseconds() / 1000); }; this.subtract = function (time) { return (time === null) ? this : this.addSeconds(-time.getTotalMilliseconds() / 1000); }; this.addDays = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 86400000)); }; this.addHours = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 3600000)); }; this.addMinutes = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 60000)); }; this.addSeconds = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 1000)); }; this.addMilliseconds = function (n) { return new TimeSpan(this.getTotalMilliseconds() + n); }; this.get12HourHour = function () { return (this.getHours() > 12) ? this.getHours() - 12 : (this.getHours() === 0) ? 12 : this.getHours(); }; this.getDesignator = function () { return (this.getHours() < 12) ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator; }; this.toString = function (format) { this._toString = function () { if (this.getDays() !== null && this.getDays() > 0) { return this.getDays() + "." + this.getHours() + ":" + this.p(this.getMinutes()) + ":" + this.p(this.getSeconds()); } else { return this.getHours() + ":" + this.p(this.getMinutes()) + ":" + this.p(this.getSeconds()); } }; this.p = function (s) { return (s.toString().length < 2) ? "0" + s : s; }; var me = this; return format ? format.replace(/dd?|HH?|hh?|mm?|ss?|tt?/g, function (format) { switch (format) { case "d": return me.getDays(); case "dd": return me.p(me.getDays()); case "H": return me.getHours(); case "HH": return me.p(me.getHours()); case "h": return me.get12HourHour(); case "hh": return me.p(me.get12HourHour()); case "m": return me.getMinutes(); case "mm": return me.p(me.getMinutes()); case "s": return me.getSeconds(); case "ss": return me.p(me.getSeconds()); case "t": return ((me.getHours() < 12) ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator).substring(0, 1); case "tt": return (me.getHours() < 12) ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator; } } ) : this._toString(); }; return this; }; addSetFuncs(TimeSpan, attrs.slice(2)); TimeSpan.prototype.set = function (days, hours, minutes, seconds, milliseconds){ this.setDays(days || this.getDays()); this.setHours(hours || this.getHours()); this.setMinutes(minutes || this.getMinutes()); this.setSeconds(seconds || this.getSeconds()); this.setMilliseconds(milliseconds || this.getMilliseconds()); }; /** * Gets the time of day for this date instances. * @return {TimeSpan} TimeSpan */ Date.prototype.getTimeOfDay = function () { return new TimeSpan(0, this.getHours(), this.getMinutes(), this.getSeconds(), this.getMilliseconds()); }; Date.TimeSpan = TimeSpan; if (typeof window !== "undefined" ) { // keeping API compatible for v1.x window.TimeSpan = TimeSpan; } }()); (function () { "use strict"; var attrs = ["years", "months", "days", "hours", "minutes", "seconds", "milliseconds"]; var gFn = function (attr) { return function () { return this[attr]; }; }; var sFn = function (attr) { return function (val) { this[attr] = val; return this; }; }; var addSetFuncs = function (context, attrs) { for (var i = 0; i < attrs.length ; i++) { var $a = attrs[i], $b = $a.slice(0, 1).toUpperCase() + $a.slice(1); context.prototype[$a] = 0; context.prototype["get" + $b] = gFn($a); context.prototype["set" + $b] = sFn($a); } }; var setMonthsAndYears = function (orient, d1, d2, context) { function inc() { d1.addMonths(-orient); context.months++; if (context.months === 12) { context.years++; context.months = 0; } } if (orient === +1) { while (d1 > d2) { inc(); } } else { while (d1 < d2) { inc(); } } context.months--; context.months *= orient; context.years *= orient; }; var adjustForDST = function(orient, startDate, endDate) { var hasDSTMismatch = (false === (startDate.isDaylightSavingTime() === endDate.isDaylightSavingTime())); if (hasDSTMismatch && orient === 1) { startDate.addHours(-1); } else if (hasDSTMismatch) { startDate.addHours(1); } }; /** * TimePeriod(startDate, endDate); * TimePeriod(years, months, days, hours, minutes, seconds, milliseconds); */ var TimePeriod = function (years, months, days, hours, minutes, seconds, milliseconds) { if (arguments.length === 7) { this.set(years, months, days, hours, minutes, seconds, milliseconds); } else if (arguments.length === 2 && arguments[0] instanceof Date && arguments[1] instanceof Date) { var startDate = arguments[0].clone(); var endDate = arguments[1].clone(); var orient = (startDate > endDate) ? +1 : -1; this.dates = { start: arguments[0].clone(), end: arguments[1].clone() }; setMonthsAndYears(orient, startDate, endDate, this); adjustForDST(orient, startDate, endDate); // // TODO - adjust for DST var diff = endDate - startDate; if (diff !== 0) { var ts = new TimeSpan(diff); this.set(this.years, this.months, ts.getDays(), ts.getHours(), ts.getMinutes(), ts.getSeconds(), ts.getMilliseconds()); } } return this; }; // create all the set functions. addSetFuncs(TimePeriod, attrs); TimePeriod.prototype.set = function (years, months, days, hours, minutes, seconds, milliseconds){ this.setYears(years || this.getYears()); this.setMonths(months || this.getMonths()); this.setDays(days || this.getDays()); this.setHours(hours || this.getHours()); this.setMinutes(minutes || this.getMinutes()); this.setSeconds(seconds || this.getSeconds()); this.setMilliseconds(milliseconds || this.getMilliseconds()); }; Date.TimePeriod = TimePeriod; if (typeof window !== "undefined") { // keeping API compatible for v1.x window.TimePeriod = TimePeriod; } }()); ================================================ FILE: build/date-nn-NO.js ================================================ /** * @overview datejs * @version 1.0.0-rc3 * @author Gregory Wild-Smith * @copyright 2015 Gregory Wild-Smith * @license MIT * @homepage https://github.com/abritinthebay/datejs */ /* * DateJS Culture String File * Country Code: nn-NO * Name: Norwegian, Nynorsk (Norway) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["nn-NO"] = { "name": "nn-NO", "englishName": "Norwegian, Nynorsk (Norway)", "nativeName": "norsk, nynorsk (Noreg)", "Sunday": "søndag", "Monday": "måndag", "Tuesday": "tysdag", "Wednesday": "onsdag", "Thursday": "torsdag", "Friday": "fredag", "Saturday": "laurdag", "Sun": "sø", "Mon": "må", "Tue": "ty", "Wed": "on", "Thu": "to", "Fri": "fr", "Sat": "la", "Su": "sø", "Mo": "må", "Tu": "ty", "We": "on", "Th": "to", "Fr": "fr", "Sa": "la", "S_Sun_Initial": "s", "M_Mon_Initial": "m", "T_Tue_Initial": "t", "W_Wed_Initial": "o", "T_Thu_Initial": "t", "F_Fri_Initial": "f", "S_Sat_Initial": "l", "January": "januar", "February": "februar", "March": "mars", "April": "april", "May": "mai", "June": "juni", "July": "juli", "August": "august", "September": "september", "October": "oktober", "November": "november", "December": "desember", "Jan_Abbr": "jan", "Feb_Abbr": "feb", "Mar_Abbr": "mar", "Apr_Abbr": "apr", "May_Abbr": "mai", "Jun_Abbr": "jun", "Jul_Abbr": "jul", "Aug_Abbr": "aug", "Sep_Abbr": "sep", "Oct_Abbr": "okt", "Nov_Abbr": "nov", "Dec_Abbr": "des", "AM": "", "PM": "", "firstDayOfWeek": 1, "twoDigitYearMax": 2029, "mdy": "dmy", "M/d/yyyy": "dd.MM.yyyy", "dddd, MMMM dd, yyyy": "d. MMMM yyyy", "h:mm tt": "HH:mm", "h:mm:ss tt": "HH:mm:ss", "dddd, MMMM dd, yyyy h:mm:ss tt": "d. MMMM yyyy HH:mm:ss", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "d. MMMM", "MMMM, yyyy": "MMMM yyyy", "/jan(uary)?/": "jan(uar)?", "/feb(ruary)?/": "feb(ruar)?", "/mar(ch)?/": "mar(s)?", "/apr(il)?/": "apr(il)?", "/may/": "mai", "/jun(e)?/": "jun(i)?", "/jul(y)?/": "jul(i)?", "/aug(ust)?/": "aug(ust)?", "/sep(t(ember)?)?/": "sep(t(ember)?)?", "/oct(ober)?/": "okt(ober)?", "/nov(ember)?/": "nov(ember)?", "/dec(ember)?/": "des(ember)?", "/^su(n(day)?)?/": "^søndag", "/^mo(n(day)?)?/": "^måndag", "/^tu(e(s(day)?)?)?/": "^tysdag", "/^we(d(nesday)?)?/": "^onsdag", "/^th(u(r(s(day)?)?)?)?/": "^torsdag", "/^fr(i(day)?)?/": "^fredag", "/^sa(t(urday)?)?/": "^laurdag", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "nn-NO"; /** * @overview datejs * @version 1.0.0-rc3 * @author Gregory Wild-Smith * @copyright 2015 Gregory Wild-Smith * @license MIT * @homepage https://github.com/abritinthebay/datejs */(function () { var $D = Date; var lang = Date.CultureStrings ? Date.CultureStrings.lang : null; var loggedKeys = {}; // for debug purposes. var getText = { getFromKey: function (key, countryCode) { var output; if (Date.CultureStrings && Date.CultureStrings[countryCode] && Date.CultureStrings[countryCode][key]) { output = Date.CultureStrings[countryCode][key]; } else { output = getText.buildFromDefault(key); } if (key.charAt(0) === "/") { // Assume it's a regex output = getText.buildFromRegex(key, countryCode); } return output; }, getFromObjectValues: function (obj, countryCode) { var key, output = {}; for(key in obj) { if (obj.hasOwnProperty(key)) { output[key] = getText.getFromKey(obj[key], countryCode); } } return output; }, getFromObjectKeys: function (obj, countryCode) { var key, output = {}; for(key in obj) { if (obj.hasOwnProperty(key)) { output[getText.getFromKey(key, countryCode)] = obj[key]; } } return output; }, getFromArray: function (arr, countryCode) { var output = []; for (var i=0; i < arr.length; i++){ if (i in arr) { output[i] = getText.getFromKey(arr[i], countryCode); } } return output; }, buildFromDefault: function (key) { var output, length, split, last; switch(key) { case "name": output = "en-US"; break; case "englishName": output = "English (United States)"; break; case "nativeName": output = "English (United States)"; break; case "twoDigitYearMax": output = 2049; break; case "firstDayOfWeek": output = 0; break; default: output = key; split = key.split("_"); length = split.length; if (length > 1 && key.charAt(0) !== "/") { // if the key isn't a regex and it has a split. last = split[(length - 1)].toLowerCase(); if (last === "initial" || last === "abbr") { output = split[0]; } } break; } return output; }, buildFromRegex: function (key, countryCode) { var output; if (Date.CultureStrings && Date.CultureStrings[countryCode] && Date.CultureStrings[countryCode][key]) { output = new RegExp(Date.CultureStrings[countryCode][key], "i"); } else { output = new RegExp(key.replace(new RegExp("/", "g"),""), "i"); } return output; } }; var shallowMerge = function (obj1, obj2) { for (var attrname in obj2) { if (obj2.hasOwnProperty(attrname)) { obj1[attrname] = obj2[attrname]; } } }; var __ = function (key, language) { var countryCode = (language) ? language : lang; loggedKeys[key] = key; if (typeof key === "object") { if (key instanceof Array) { return getText.getFromArray(key, countryCode); } else { return getText.getFromObjectKeys(key, countryCode); } } else { return getText.getFromKey(key, countryCode); } }; var loadI18nScript = function (code) { // paatterned after jQuery's getScript. var url = Date.Config.i18n + code + ".js"; var head = document.getElementsByTagName("head")[0] || document.documentElement; var script = document.createElement("script"); script.src = url; var completed = false; var events = { done: function (){} // placeholder function }; // Attach handlers for all browsers script.onload = script.onreadystatechange = function() { if ( !completed && (!this.readyState || this.readyState === "loaded" || this.readyState === "complete") ) { events.done(); head.removeChild(script); } }; setTimeout(function() { head.insertBefore(script, head.firstChild); }, 0); // allows return to execute first return { done: function (cb) { events.done = function() { if (cb) { setTimeout(cb,0); } }; } }; }; var buildInfo = { buildFromMethodHash: function (obj) { var key; for(key in obj) { if (obj.hasOwnProperty(key)) { obj[key] = buildInfo[obj[key]](); } } return obj; }, timeZoneDST: function () { var DST = { "CHADT": "+1345", "NZDT": "+1300", "AEDT": "+1100", "ACDT": "+1030", "AZST": "+0500", "IRDT": "+0430", "EEST": "+0300", "CEST": "+0200", "BST": "+0100", "PMDT": "-0200", "ADT": "-0300", "NDT": "-0230", "EDT": "-0400", "CDT": "-0500", "MDT": "-0600", "PDT": "-0700", "AKDT": "-0800", "HADT": "-0900" }; return __(DST); }, timeZoneStandard: function () { var standard = { "LINT": "+1400", "TOT": "+1300", "CHAST": "+1245", "NZST": "+1200", "NFT": "+1130", "SBT": "+1100", "AEST": "+1000", "ACST": "+0930", "JST": "+0900", "CWST": "+0845", "CT": "+0800", "ICT": "+0700", "MMT": "+0630", "BST": "+0600", "NPT": "+0545", "IST": "+0530", "PKT": "+0500", "AFT": "+0430", "MSK": "+0400", "IRST": "+0330", "FET": "+0300", "EET": "+0200", "CET": "+0100", "GMT": "+0000", "UTC": "+0000", "CVT": "-0100", "GST": "-0200", "BRT": "-0300", "NST": "-0330", "AST": "-0400", "EST": "-0500", "CST": "-0600", "MST": "-0700", "PST": "-0800", "AKST": "-0900", "MIT": "-0930", "HST": "-1000", "SST": "-1100", "BIT": "-1200" }; return __(standard); }, timeZones: function (data) { var zone; data.timezones = []; for (zone in data.abbreviatedTimeZoneStandard) { if (data.abbreviatedTimeZoneStandard.hasOwnProperty(zone)) { data.timezones.push({ name: zone, offset: data.abbreviatedTimeZoneStandard[zone]}); } } for (zone in data.abbreviatedTimeZoneDST) { if (data.abbreviatedTimeZoneDST.hasOwnProperty(zone)) { data.timezones.push({ name: zone, offset: data.abbreviatedTimeZoneDST[zone], dst: true}); } } return data.timezones; }, days: function () { return __(["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"]); }, dayAbbr: function () { return __(["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"]); }, dayShortNames: function () { return __(["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"]); }, dayFirstLetters: function () { return __(["S_Sun_Initial", "M_Mon_Initial", "T_Tues_Initial", "W_Wed_Initial", "T_Thu_Initial", "F_Fri_Initial", "S_Sat_Initial"]); }, months: function () { return __(["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"]); }, monthAbbr: function () { return __(["Jan_Abbr", "Feb_Abbr", "Mar_Abbr", "Apr_Abbr", "May_Abbr", "Jun_Abbr", "Jul_Abbr", "Aug_Abbr", "Sep_Abbr", "Oct_Abbr", "Nov_Abbr", "Dec_Abbr"]); }, formatPatterns: function () { return getText.getFromObjectValues({ shortDate: "M/d/yyyy", longDate: "dddd, MMMM dd, yyyy", shortTime: "h:mm tt", longTime: "h:mm:ss tt", fullDateTime: "dddd, MMMM dd, yyyy h:mm:ss tt", sortableDateTime: "yyyy-MM-ddTHH:mm:ss", universalSortableDateTime: "yyyy-MM-dd HH:mm:ssZ", rfc1123: "ddd, dd MMM yyyy HH:mm:ss", monthDay: "MMMM dd", yearMonth: "MMMM, yyyy" }, Date.i18n.currentLanguage()); }, regex: function () { return getText.getFromObjectValues({ inTheMorning: "/( in the )(morn(ing)?)\\b/", thisMorning: "/(this )(morn(ing)?)\\b/", amThisMorning: "/(\b\\d(am)? )(this )(morn(ing)?)/", inTheEvening: "/( in the )(even(ing)?)\\b/", thisEvening: "/(this )(even(ing)?)\\b/", pmThisEvening: "/(\b\\d(pm)? )(this )(even(ing)?)/", jan: "/jan(uary)?/", feb: "/feb(ruary)?/", mar: "/mar(ch)?/", apr: "/apr(il)?/", may: "/may/", jun: "/jun(e)?/", jul: "/jul(y)?/", aug: "/aug(ust)?/", sep: "/sep(t(ember)?)?/", oct: "/oct(ober)?/", nov: "/nov(ember)?/", dec: "/dec(ember)?/", sun: "/^su(n(day)?)?/", mon: "/^mo(n(day)?)?/", tue: "/^tu(e(s(day)?)?)?/", wed: "/^we(d(nesday)?)?/", thu: "/^th(u(r(s(day)?)?)?)?/", fri: "/fr(i(day)?)?/", sat: "/^sa(t(urday)?)?/", future: "/^next/", past: "/^last|past|prev(ious)?/", add: "/^(\\+|aft(er)?|from|hence)/", subtract: "/^(\\-|bef(ore)?|ago)/", yesterday: "/^yes(terday)?/", today: "/^t(od(ay)?)?/", tomorrow: "/^tom(orrow)?/", now: "/^n(ow)?/", millisecond: "/^ms|milli(second)?s?/", second: "/^sec(ond)?s?/", minute: "/^mn|min(ute)?s?/", hour: "/^h(our)?s?/", week: "/^w(eek)?s?/", month: "/^m(onth)?s?/", day: "/^d(ay)?s?/", year: "/^y(ear)?s?/", shortMeridian: "/^(a|p)/", longMeridian: "/^(a\\.?m?\\.?|p\\.?m?\\.?)/", timezone: "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/", ordinalSuffix: "/^\\s*(st|nd|rd|th)/", timeContext: "/^\\s*(\\:|a(?!u|p)|p)/" }, Date.i18n.currentLanguage()); } }; var CultureInfo = function () { var info = getText.getFromObjectValues({ name: "name", englishName: "englishName", nativeName: "nativeName", amDesignator: "AM", pmDesignator: "PM", firstDayOfWeek: "firstDayOfWeek", twoDigitYearMax: "twoDigitYearMax", dateElementOrder: "mdy" }, Date.i18n.currentLanguage()); var constructedInfo = buildInfo.buildFromMethodHash({ dayNames: "days", abbreviatedDayNames: "dayAbbr", shortestDayNames: "dayShortNames", firstLetterDayNames: "dayFirstLetters", monthNames: "months", abbreviatedMonthNames: "monthAbbr", formatPatterns: "formatPatterns", regexPatterns: "regex", abbreviatedTimeZoneDST: "timeZoneDST", abbreviatedTimeZoneStandard: "timeZoneStandard" }); shallowMerge(info, constructedInfo); buildInfo.timeZones(info); return info; }; $D.i18n = { __: function (key, lang) { return __(key, lang); }, currentLanguage: function () { return lang || "en-US"; }, setLanguage: function (code, force, cb) { var async = false; if (force || code === "en-US" || (!!Date.CultureStrings && !!Date.CultureStrings[code])) { lang = code; Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings.lang = code; Date.CultureInfo = new CultureInfo(); } else { if (!(!!Date.CultureStrings && !!Date.CultureStrings[code])) { if (typeof exports !== "undefined" && this.exports !== exports) { // we're in a Node enviroment, load it using require try { require("../i18n/" + code + ".js"); lang = code; Date.CultureStrings.lang = code; Date.CultureInfo = new CultureInfo(); } catch (e) { // var str = "The language for '" + code + "' could not be loaded by Node. It likely does not exist."; throw new Error("The DateJS IETF language tag '" + code + "' could not be loaded by Node. It likely does not exist."); } } else if (Date.Config && Date.Config.i18n) { // we know the location of the files, so lets load them async = true; loadI18nScript(code).done(function(){ lang = code; Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings.lang = code; Date.CultureInfo = new CultureInfo(); $D.Parsing.Normalizer.buildReplaceData(); // because this is async if ($D.Grammar) { $D.Grammar.buildGrammarFormats(); // so we can parse those strings... } if (cb) { setTimeout(cb,0); } }); } else { Date.console.error("The DateJS IETF language tag '" + code + "' is not available and has not been loaded."); return false; } } } $D.Parsing.Normalizer.buildReplaceData(); // rebuild normalizer strings if ($D.Grammar) { $D.Grammar.buildGrammarFormats(); // so we can parse those strings... } if (!async && cb) { setTimeout(cb,0); } }, getLoggedKeys: function () { return loggedKeys; }, updateCultureInfo: function () { Date.CultureInfo = new CultureInfo(); } }; $D.i18n.updateCultureInfo(); // run automatically }()); (function () { var $D = Date, $P = $D.prototype, p = function (s, l) { if (!l) { l = 2; } return ("000" + s).slice(l * -1); }; if (typeof window !== "undefined" && typeof window.console !== "undefined" && typeof window.console.log !== "undefined") { $D.console = console; // used only to raise non-critical errors if available } else { // set mock so we don't give errors. $D.console = { log: function(){}, error: function(){} }; } $D.Config = $D.Config || {}; $D.initOverloads = function() { /** * Overload of Date.now. Allows an alternate call for Date.now where it returns the * current Date as an object rather than just milliseconds since the Unix Epoch. * * Also provides an implementation of now() for browsers (IE<9) that don't have it. * * Backwards compatible so with work with either: * Date.now() [returns ms] * or * Date.now(true) [returns Date] */ if (!$D.now) { $D._now = function now() { return new Date().getTime(); }; } else if (!$D._now) { $D._now = $D.now; } $D.now = function (returnObj) { if (returnObj) { return $D.present(); } else { return $D._now(); } }; if ( !$P.toISOString ) { $P.toISOString = function() { return this.getUTCFullYear() + "-" + p(this.getUTCMonth() + 1) + "-" + p(this.getUTCDate()) + "T" + p(this.getUTCHours()) + ":" + p(this.getUTCMinutes()) + ":" + p(this.getUTCSeconds()) + "." + String( (this.getUTCMilliseconds()/1000).toFixed(3)).slice(2, 5) + "Z"; }; } // private if ( $P._toString === undefined ){ $P._toString = $P.toString; } }; $D.initOverloads(); /** * Gets a date that is set to the current date. The time is set to the start of the day (00:00 or 12:00 AM). * @return {Date} The current date. */ $D.today = function () { return new Date().clearTime(); }; /** * Gets a date that is set to the current date and time (same as new Date, but chainable) * @return {Date} The current date. */ $D.present = function () { return new Date(); }; /** * Compares the first date to the second date and returns an number indication of their relative values. * @param {Date} First Date object to compare [Required]. * @param {Date} Second Date object to compare to [Required]. * @return {Number} -1 = date1 is lessthan date2. 0 = values are equal. 1 = date1 is greaterthan date2. */ $D.compare = function (date1, date2) { if (isNaN(date1) || isNaN(date2)) { throw new Error(date1 + " - " + date2); } else if (date1 instanceof Date && date2 instanceof Date) { return (date1 < date2) ? -1 : (date1 > date2) ? 1 : 0; } else { throw new TypeError(date1 + " - " + date2); } }; /** * Compares the first Date object to the second Date object and returns true if they are equal. * @param {Date} First Date object to compare [Required] * @param {Date} Second Date object to compare to [Required] * @return {Boolean} true if dates are equal. false if they are not equal. */ $D.equals = function (date1, date2) { return (date1.compareTo(date2) === 0); }; /** * Gets the language appropriate day name when given the day number(0-6) * eg - 0 == Sunday * @return {String} The day name */ $D.getDayName = function (n) { return Date.CultureInfo.dayNames[n]; }; /** * Gets the day number (0-6) if given a CultureInfo specific string which is a valid dayName, abbreviatedDayName or shortestDayName (two char). * @param {String} The name of the day (eg. "Monday, "Mon", "tuesday", "tue", "We", "we"). * @return {Number} The day number */ $D.getDayNumberFromName = function (name) { var n = Date.CultureInfo.dayNames, m = Date.CultureInfo.abbreviatedDayNames, o = Date.CultureInfo.shortestDayNames, s = name.toLowerCase(); for (var i = 0; i < n.length; i++) { if (n[i].toLowerCase() === s || m[i].toLowerCase() === s || o[i].toLowerCase() === s) { return i; } } return -1; }; /** * Gets the month number (0-11) if given a Culture Info specific string which is a valid monthName or abbreviatedMonthName. * @param {String} The name of the month (eg. "February, "Feb", "october", "oct"). * @return {Number} The day number */ $D.getMonthNumberFromName = function (name) { var n = Date.CultureInfo.monthNames, m = Date.CultureInfo.abbreviatedMonthNames, s = name.toLowerCase(); for (var i = 0; i < n.length; i++) { if (n[i].toLowerCase() === s || m[i].toLowerCase() === s) { return i; } } return -1; }; /** * Gets the language appropriate month name when given the month number(0-11) * eg - 0 == January * @return {String} The month name */ $D.getMonthName = function (n) { return Date.CultureInfo.monthNames[n]; }; /** * Determines if the current date instance is within a LeapYear. * @param {Number} The year. * @return {Boolean} true if date is within a LeapYear, otherwise false. */ $D.isLeapYear = function (year) { return ((year % 4 === 0 && year % 100 !== 0) || year % 400 === 0); }; /** * Gets the number of days in the month, given a year and month value. Automatically corrects for LeapYear. * @param {Number} The year. * @param {Number} The month (0-11). * @return {Number} The number of days in the month. */ $D.getDaysInMonth = function (year, month) { if (!month && $D.validateMonth(year)) { month = year; year = Date.today().getFullYear(); } return [31, ($D.isLeapYear(year) ? 29 : 28), 31, 30, 31, 30, 31, 31, 30, 31, 30, 31][month]; }; $P.getDaysInMonth = function () { return $D.getDaysInMonth(this.getFullYear(), this.getMonth()); }; $D.getTimezoneAbbreviation = function (offset, dst) { var p, n = (dst || false) ? Date.CultureInfo.abbreviatedTimeZoneDST : Date.CultureInfo.abbreviatedTimeZoneStandard; for (p in n) { if (n.hasOwnProperty(p)) { if (n[p] === offset) { return p; } } } return null; }; $D.getTimezoneOffset = function (name, dst) { var i, a =[], z = Date.CultureInfo.timezones; if (!name) { name = (new Date()).getTimezone();} for (i = 0; i < z.length; i++) { if (z[i].name === name.toUpperCase()) { a.push(i); } } if (!z[a[0]]) { return null; } if (a.length === 1 || !dst) { return z[a[0]].offset; } else { for (i=0; i < a.length; i++) { if (z[a[i]].dst) { return z[a[i]].offset; } } } }; $D.getQuarter = function (d) { d = d || new Date(); // If no date supplied, use today var q = [1,2,3,4]; return q[Math.floor(d.getMonth() / 3)]; // ~~~ is a bitwise op. Faster than Math.floor }; $D.getDaysLeftInQuarter = function (d) { d = d || new Date(); var qEnd = new Date(d); qEnd.setMonth(qEnd.getMonth() + 3 - qEnd.getMonth() % 3, 0); return Math.floor((qEnd - d) / 8.64e7); }; // private var validate = function (n, min, max, name) { name = name ? name : "Object"; if (typeof n === "undefined") { return false; } else if (typeof n !== "number") { throw new TypeError(n + " is not a Number."); } else if (n < min || n > max) { // As failing validation is *not* an exceptional circumstance // lets not throw a RangeError Exception here. // It's semantically correct but it's not sensible. return false; } return true; }; /** * Validates the number is within an acceptable range for milliseconds [0-999]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateMillisecond = function (value) { return validate(value, 0, 999, "millisecond"); }; /** * Validates the number is within an acceptable range for seconds [0-59]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateSecond = function (value) { return validate(value, 0, 59, "second"); }; /** * Validates the number is within an acceptable range for minutes [0-59]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateMinute = function (value) { return validate(value, 0, 59, "minute"); }; /** * Validates the number is within an acceptable range for hours [0-23]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateHour = function (value) { return validate(value, 0, 23, "hour"); }; /** * Validates the number is within an acceptable range for the days in a month [0-MaxDaysInMonth]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateDay = function (value, year, month) { if (year === undefined || year === null || month === undefined || month === null) { return false;} return validate(value, 1, $D.getDaysInMonth(year, month), "day"); }; /** * Validates the number is within an acceptable range for months [0-11]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateWeek = function (value) { return validate(value, 0, 53, "week"); }; /** * Validates the number is within an acceptable range for months [0-11]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateMonth = function (value) { return validate(value, 0, 11, "month"); }; /** * Validates the number is within an acceptable range for years. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateYear = function (value) { /** * Per ECMAScript spec the range of times supported by Date objects is * exactly -100,000,000 days to +100,000,000 days measured relative to * midnight at the beginning of 01 January, 1970 UTC. * This gives a range of 8,640,000,000,000,000 milliseconds to either * side of 01 January, 1970 UTC. * * Earliest possible date: Tue, 20 Apr 271,822 B.C. 00:00:00 UTC * Latest possible date: Sat, 13 Sep 275,760 00:00:00 UTC */ return validate(value, -271822, 275760, "year"); }; $D.validateTimezone = function(value) { var timezones = {"ACDT":1,"ACST":1,"ACT":1,"ADT":1,"AEDT":1,"AEST":1,"AFT":1,"AKDT":1,"AKST":1,"AMST":1,"AMT":1,"ART":1,"AST":1,"AWDT":1,"AWST":1,"AZOST":1,"AZT":1,"BDT":1,"BIOT":1,"BIT":1,"BOT":1,"BRT":1,"BST":1,"BTT":1,"CAT":1,"CCT":1,"CDT":1,"CEDT":1,"CEST":1,"CET":1,"CHADT":1,"CHAST":1,"CHOT":1,"ChST":1,"CHUT":1,"CIST":1,"CIT":1,"CKT":1,"CLST":1,"CLT":1,"COST":1,"COT":1,"CST":1,"CT":1,"CVT":1,"CWST":1,"CXT":1,"DAVT":1,"DDUT":1,"DFT":1,"EASST":1,"EAST":1,"EAT":1,"ECT":1,"EDT":1,"EEDT":1,"EEST":1,"EET":1,"EGST":1,"EGT":1,"EIT":1,"EST":1,"FET":1,"FJT":1,"FKST":1,"FKT":1,"FNT":1,"GALT":1,"GAMT":1,"GET":1,"GFT":1,"GILT":1,"GIT":1,"GMT":1,"GST":1,"GYT":1,"HADT":1,"HAEC":1,"HAST":1,"HKT":1,"HMT":1,"HOVT":1,"HST":1,"ICT":1,"IDT":1,"IOT":1,"IRDT":1,"IRKT":1,"IRST":1,"IST":1,"JST":1,"KGT":1,"KOST":1,"KRAT":1,"KST":1,"LHST":1,"LINT":1,"MAGT":1,"MART":1,"MAWT":1,"MDT":1,"MET":1,"MEST":1,"MHT":1,"MIST":1,"MIT":1,"MMT":1,"MSK":1,"MST":1,"MUT":1,"MVT":1,"MYT":1,"NCT":1,"NDT":1,"NFT":1,"NPT":1,"NST":1,"NT":1,"NUT":1,"NZDT":1,"NZST":1,"OMST":1,"ORAT":1,"PDT":1,"PET":1,"PETT":1,"PGT":1,"PHOT":1,"PHT":1,"PKT":1,"PMDT":1,"PMST":1,"PONT":1,"PST":1,"PYST":1,"PYT":1,"RET":1,"ROTT":1,"SAKT":1,"SAMT":1,"SAST":1,"SBT":1,"SCT":1,"SGT":1,"SLST":1,"SRT":1,"SST":1,"SYOT":1,"TAHT":1,"THA":1,"TFT":1,"TJT":1,"TKT":1,"TLT":1,"TMT":1,"TOT":1,"TVT":1,"UCT":1,"ULAT":1,"UTC":1,"UYST":1,"UYT":1,"UZT":1,"VET":1,"VLAT":1,"VOLT":1,"VOST":1,"VUT":1,"WAKT":1,"WAST":1,"WAT":1,"WEDT":1,"WEST":1,"WET":1,"WST":1,"YAKT":1,"YEKT":1,"Z":1}; return (timezones[value] === 1); }; $D.validateTimezoneOffset= function(value) { // timezones go from +14hrs to -12hrs, the +X hours are negative offsets. return (value > -841 && value < 721); }; }()); (function () { var $D = Date, $P = $D.prototype, p = function (s, l) { if (!l) { l = 2; } return ("000" + s).slice(l * -1); }; var validateConfigObject = function (obj) { var result = {}, self = this, prop, testFunc; testFunc = function (prop, func, value) { if (prop === "day") { var month = (obj.month !== undefined) ? obj.month : self.getMonth(); var year = (obj.year !== undefined) ? obj.year : self.getFullYear(); return $D[func](value, year, month); } else { return $D[func](value); } }; for (prop in obj) { if (Object.prototype.hasOwnProperty.call(obj, prop)) { var func = "validate" + prop.charAt(0).toUpperCase() + prop.slice(1); if ($D[func] && obj[prop] !== null && testFunc(prop, func, obj[prop])) { result[prop] = obj[prop]; } } } return result; }; /** * Resets the time of this Date object to 12:00 AM (00:00), which is the start of the day. * @param {Boolean} .clone() this date instance before clearing Time * @return {Date} this */ $P.clearTime = function () { this.setHours(0); this.setMinutes(0); this.setSeconds(0); this.setMilliseconds(0); return this; }; /** * Resets the time of this Date object to the current time ('now'). * @return {Date} this */ $P.setTimeToNow = function () { var n = new Date(); this.setHours(n.getHours()); this.setMinutes(n.getMinutes()); this.setSeconds(n.getSeconds()); this.setMilliseconds(n.getMilliseconds()); return this; }; /** * Returns a new Date object that is an exact date and time copy of the original instance. * @return {Date} A new Date instance */ $P.clone = function () { return new Date(this.getTime()); }; /** * Compares this instance to a Date object and returns an number indication of their relative values. * @param {Date} Date object to compare [Required] * @return {Number} -1 = this is lessthan date. 0 = values are equal. 1 = this is greaterthan date. */ $P.compareTo = function (date) { return Date.compare(this, date); }; /** * Compares this instance to another Date object and returns true if they are equal. * @param {Date} Date object to compare. If no date to compare, new Date() [now] is used. * @return {Boolean} true if dates are equal. false if they are not equal. */ $P.equals = function (date) { return Date.equals(this, (date !== undefined ? date : new Date())); }; /** * Determines if this instance is between a range of two dates or equal to either the start or end dates. * @param {Date} Start of range [Required] * @param {Date} End of range [Required] * @return {Boolean} true is this is between or equal to the start and end dates, else false */ $P.between = function (start, end) { return this.getTime() >= start.getTime() && this.getTime() <= end.getTime(); }; /** * Determines if this date occurs after the date to compare to. * @param {Date} Date object to compare. If no date to compare, new Date() ("now") is used. * @return {Boolean} true if this date instance is greater than the date to compare to (or "now"), otherwise false. */ $P.isAfter = function (date) { return this.compareTo(date || new Date()) === 1; }; /** * Determines if this date occurs before the date to compare to. * @param {Date} Date object to compare. If no date to compare, new Date() ("now") is used. * @return {Boolean} true if this date instance is less than the date to compare to (or "now"). */ $P.isBefore = function (date) { return (this.compareTo(date || new Date()) === -1); }; /** * Determines if the current Date instance occurs today. * @return {Boolean} true if this date instance is 'today', otherwise false. */ /** * Determines if the current Date instance occurs on the same Date as the supplied 'date'. * If no 'date' to compare to is provided, the current Date instance is compared to 'today'. * @param {date} Date object to compare. If no date to compare, the current Date ("now") is used. * @return {Boolean} true if this Date instance occurs on the same Day as the supplied 'date'. */ $P.isToday = $P.isSameDay = function (date) { return this.clone().clearTime().equals((date || new Date()).clone().clearTime()); }; /** * Adds the specified number of milliseconds to this instance. * @param {Number} The number of milliseconds to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addMilliseconds = function (value) { if (!value) { return this; } this.setTime(this.getTime() + value * 1); return this; }; /** * Adds the specified number of seconds to this instance. * @param {Number} The number of seconds to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addSeconds = function (value) { if (!value) { return this; } return this.addMilliseconds(value * 1000); }; /** * Adds the specified number of seconds to this instance. * @param {Number} The number of seconds to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addMinutes = function (value) { if (!value) { return this; } return this.addMilliseconds(value * 60000); // 60*1000 }; /** * Adds the specified number of hours to this instance. * @param {Number} The number of hours to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addHours = function (value) { if (!value) { return this; } return this.addMilliseconds(value * 3600000); // 60*60*1000 }; /** * Adds the specified number of days to this instance. * @param {Number} The number of days to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addDays = function (value) { if (!value) { return this; } this.setDate(this.getDate() + value * 1); return this; }; /** * Adds the specified number of weekdays (ie - not sat or sun) to this instance. * @param {Number} The number of days to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addWeekdays = function (value) { if (!value) { return this; } var day = this.getDay(); var weeks = (Math.ceil(Math.abs(value)/7)); if (day === 0 || day === 6) { if (value > 0) { this.next().monday(); this.addDays(-1); day = this.getDay(); } } if (value < 0) { while (value < 0) { this.addDays(-1); day = this.getDay(); if (day !== 0 && day !== 6) { value++; } } return this; } else if (value > 5 || (6-day) <= value) { value = value + (weeks * 2); } return this.addDays(value); }; /** * Adds the specified number of weeks to this instance. * @param {Number} The number of weeks to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addWeeks = function (value) { if (!value) { return this; } return this.addDays(value * 7); }; /** * Adds the specified number of months to this instance. * @param {Number} The number of months to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addMonths = function (value) { if (!value) { return this; } var n = this.getDate(); this.setDate(1); this.setMonth(this.getMonth() + value * 1); this.setDate(Math.min(n, $D.getDaysInMonth(this.getFullYear(), this.getMonth()))); return this; }; $P.addQuarters = function (value) { if (!value) { return this; } // note this will take you to the same point in the quarter as you are now. // i.e. - if you are 15 days into the quarter you'll be 15 days into the resulting one. // bonus: this allows adding fractional quarters return this.addMonths(value * 3); }; /** * Adds the specified number of years to this instance. * @param {Number} The number of years to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addYears = function (value) { if (!value) { return this; } return this.addMonths(value * 12); }; /** * Adds (or subtracts) to the value of the years, months, weeks, days, hours, minutes, seconds, milliseconds of the date instance using given configuration object. Positive and Negative values allowed. * Example

	Date.today().add( { days: 1, months: 1 } )

	new Date().add( { years: -1 } )
	
* @param {Object} Configuration object containing attributes (months, days, etc.) * @return {Date} this */ $P.add = function (config) { if (typeof config === "number") { this._orient = config; return this; } var x = config; if (x.day) { // If we should be a different date than today (eg: for 'tomorrow -1d', etc). // Should only effect parsing, not direct usage (eg, Finish and FinishExact) if ((x.day - this.getDate()) !== 0) { this.setDate(x.day); } } if (x.milliseconds) { this.addMilliseconds(x.milliseconds); } if (x.seconds) { this.addSeconds(x.seconds); } if (x.minutes) { this.addMinutes(x.minutes); } if (x.hours) { this.addHours(x.hours); } if (x.weeks) { this.addWeeks(x.weeks); } if (x.months) { this.addMonths(x.months); } if (x.years) { this.addYears(x.years); } if (x.days) { this.addDays(x.days); } return this; }; /** * Get the week number. Week one (1) is the week which contains the first Thursday of the year. Monday is considered the first day of the week. * The .getWeek() function does NOT convert the date to UTC. The local datetime is used. * Please use .getISOWeek() to get the week of the UTC converted date. * @return {Number} 1 to 53 */ $P.getWeek = function (utc) { // Create a copy of this date object var self, target = new Date(this.valueOf()); if (utc) { target.addMinutes(target.getTimezoneOffset()); self = target.clone(); } else { self = this; } // ISO week date weeks start on monday // so correct the day number var dayNr = (self.getDay() + 6) % 7; // ISO 8601 states that week 1 is the week // with the first thursday of that year. // Set the target date to the thursday in the target week target.setDate(target.getDate() - dayNr + 3); // Store the millisecond value of the target date var firstThursday = target.valueOf(); // Set the target to the first thursday of the year // First set the target to january first target.setMonth(0, 1); // Not a thursday? Correct the date to the next thursday if (target.getDay() !== 4) { target.setMonth(0, 1 + ((4 - target.getDay()) + 7) % 7); } // The weeknumber is the number of weeks between the // first thursday of the year and the thursday in the target week return 1 + Math.ceil((firstThursday - target) / 604800000); // 604800000 = 7 * 24 * 3600 * 1000 }; /** * Get the ISO 8601 week number. Week one ("01") is the week which contains the first Thursday of the year. Monday is considered the first day of the week. * The .getISOWeek() function does convert the date to it's UTC value. Please use .getWeek() to get the week of the local date. * @return {String} "01" to "53" */ $P.getISOWeek = function () { return p(this.getWeek(true)); }; /** * Moves the date to Monday of the week set. Week one (1) is the week which contains the first Thursday of the year. * @param {Number} A Number (1 to 53) that represents the week of the year. * @return {Date} this */ $P.setWeek = function (n) { if ((n - this.getWeek()) === 0) { if (this.getDay() !== 1) { return this.moveToDayOfWeek(1, (this.getDay() > 1 ? -1 : 1)); } else { return this; } } else { return this.moveToDayOfWeek(1, (this.getDay() > 1 ? -1 : 1)).addWeeks(n - this.getWeek()); } }; $P.setQuarter = function (qtr) { var month = Math.abs(((qtr-1) * 3) + 1); return this.setMonth(month, 1); }; $P.getQuarter = function () { return Date.getQuarter(this); }; $P.getDaysLeftInQuarter = function () { return Date.getDaysLeftInQuarter(this); }; /** * Moves the date to the next n'th occurrence of the dayOfWeek starting from the beginning of the month. The number (-1) is a magic number and will return the last occurrence of the dayOfWeek in the month. * @param {Number} The dayOfWeek to move to * @param {Number} The n'th occurrence to move to. Use (-1) to return the last occurrence in the month * @return {Date} this */ $P.moveToNthOccurrence = function (dayOfWeek, occurrence) { if (dayOfWeek === "Weekday") { if (occurrence > 0) { this.moveToFirstDayOfMonth(); if (this.is().weekday()) { occurrence -= 1; } } else if (occurrence < 0) { this.moveToLastDayOfMonth(); if (this.is().weekday()) { occurrence += 1; } } else { return this; } return this.addWeekdays(occurrence); } var shift = 0; if (occurrence > 0) { shift = occurrence - 1; } else if (occurrence === -1) { this.moveToLastDayOfMonth(); if (this.getDay() !== dayOfWeek) { this.moveToDayOfWeek(dayOfWeek, -1); } return this; } return this.moveToFirstDayOfMonth().addDays(-1).moveToDayOfWeek(dayOfWeek, +1).addWeeks(shift); }; var moveToN = function (getFunc, addFunc, nVal) { return function (value, orient) { var diff = (value - this[getFunc]() + nVal * (orient || +1)) % nVal; return this[addFunc]((diff === 0) ? diff += nVal * (orient || +1) : diff); }; }; /** * Move to the next or last dayOfWeek based on the orient value. * @param {Number} The dayOfWeek to move to * @param {Number} Forward (+1) or Back (-1). Defaults to +1. [Optional] * @return {Date} this */ $P.moveToDayOfWeek = moveToN("getDay", "addDays", 7); /** * Move to the next or last month based on the orient value. * @param {Number} The month to move to. 0 = January, 11 = December * @param {Number} Forward (+1) or Back (-1). Defaults to +1. [Optional] * @return {Date} this */ $P.moveToMonth = moveToN("getMonth", "addMonths", 12); /** * Get the Ordinate of the current day ("th", "st", "rd"). * @return {String} */ $P.getOrdinate = function () { var num = this.getDate(); return ord(num); }; /** * Get the Ordinal day (numeric day number) of the year, adjusted for leap year. * @return {Number} 1 through 365 (366 in leap years) */ $P.getOrdinalNumber = function () { return Math.ceil((this.clone().clearTime() - new Date(this.getFullYear(), 0, 1)) / 86400000) + 1; }; /** * Get the time zone abbreviation of the current date. * @return {String} The abbreviated time zone name (e.g. "EST") */ $P.getTimezone = function () { return $D.getTimezoneAbbreviation(this.getUTCOffset(), this.isDaylightSavingTime()); }; $P.setTimezoneOffset = function (offset) { var here = this.getTimezoneOffset(), there = Number(offset) * -6 / 10; return (there || there === 0) ? this.addMinutes(there - here) : this; }; $P.setTimezone = function (offset) { return this.setTimezoneOffset($D.getTimezoneOffset(offset)); }; /** * Indicates whether Daylight Saving Time is observed in the current time zone. * @return {Boolean} true|false */ $P.hasDaylightSavingTime = function () { return (Date.today().set({month: 0, day: 1}).getTimezoneOffset() !== Date.today().set({month: 6, day: 1}).getTimezoneOffset()); }; /** * Indicates whether this Date instance is within the Daylight Saving Time range for the current time zone. * @return {Boolean} true|false */ $P.isDaylightSavingTime = function () { return Date.today().set({month: 0, day: 1}).getTimezoneOffset() !== this.getTimezoneOffset(); }; /** * Get the offset from UTC of the current date. * @return {String} The 4-character offset string prefixed with + or - (e.g. "-0500") */ $P.getUTCOffset = function (offset) { var n = (offset || this.getTimezoneOffset()) * -10 / 6, r; if (n < 0) { r = (n - 10000).toString(); return r.charAt(0) + r.substr(2); } else { r = (n + 10000).toString(); return "+" + r.substr(1); } }; /** * Returns the number of milliseconds between this date and date. * @param {Date} Defaults to now * @return {Number} The diff in milliseconds */ $P.getElapsed = function (date) { return (date || new Date()) - this; }; /** * Set the value of year, month, day, hour, minute, second, millisecond of date instance using given configuration object. * Example

	Date.today().set( { day: 20, month: 1 } )

	new Date().set( { millisecond: 0 } )
	
* * @param {Object} Configuration object containing attributes (month, day, etc.) * @return {Date} this */ $P.set = function (config) { config = validateConfigObject.call(this, config); var key; for (key in config) { if (Object.prototype.hasOwnProperty.call(config, key)) { var name = key.charAt(0).toUpperCase() + key.slice(1); var addFunc, getFunc; if (key !== "week" && key !== "month" && key !== "timezone" && key !== "timezoneOffset") { name += "s"; } addFunc = "add" + name; getFunc = "get" + name; if (key === "month") { addFunc = addFunc + "s"; } else if (key === "year"){ getFunc = "getFullYear"; } if (key !== "day" && key !== "timezone" && key !== "timezoneOffset" && key !== "week" && key !== "hour") { this[addFunc](config[key] - this[getFunc]()); } else if ( key === "timezone"|| key === "timezoneOffset" || key === "week" || key === "hour") { this["set"+name](config[key]); } } } // day has to go last because you can't validate the day without first knowing the month if (config.day) { this.addDays(config.day - this.getDate()); } return this; }; /** * Moves the date to the first day of the month. * @return {Date} this */ $P.moveToFirstDayOfMonth = function () { return this.set({ day: 1 }); }; /** * Moves the date to the last day of the month. * @return {Date} this */ $P.moveToLastDayOfMonth = function () { return this.set({ day: $D.getDaysInMonth(this.getFullYear(), this.getMonth())}); }; /** * Converts the value of the current Date object to its equivalent string representation. * Format Specifiers * CUSTOM DATE AND TIME FORMAT STRINGS * Format Description Example * ------ --------------------------------------------------------------------------- ----------------------- * s The seconds of the minute between 0-59. "0" to "59" * ss The seconds of the minute with leading zero if required. "00" to "59" * * m The minute of the hour between 0-59. "0" or "59" * mm The minute of the hour with leading zero if required. "00" or "59" * * h The hour of the day between 1-12. "1" to "12" * hh The hour of the day with leading zero if required. "01" to "12" * * H The hour of the day between 0-23. "0" to "23" * HH The hour of the day with leading zero if required. "00" to "23" * * d The day of the month between 1 and 31. "1" to "31" * dd The day of the month with leading zero if required. "01" to "31" * ddd Abbreviated day name. Date.CultureInfo.abbreviatedDayNames. "Mon" to "Sun" * dddd The full day name. Date.CultureInfo.dayNames. "Monday" to "Sunday" * * M The month of the year between 1-12. "1" to "12" * MM The month of the year with leading zero if required. "01" to "12" * MMM Abbreviated month name. Date.CultureInfo.abbreviatedMonthNames. "Jan" to "Dec" * MMMM The full month name. Date.CultureInfo.monthNames. "January" to "December" * * yy The year as a two-digit number. "99" or "08" * yyyy The full four digit year. "1999" or "2008" * * t Displays the first character of the A.M./P.M. designator. "A" or "P" * Date.CultureInfo.amDesignator or Date.CultureInfo.pmDesignator * tt Displays the A.M./P.M. designator. "AM" or "PM" * Date.CultureInfo.amDesignator or Date.CultureInfo.pmDesignator * * S The ordinal suffix ("st, "nd", "rd" or "th") of the current day. "st, "nd", "rd" or "th" * * STANDARD DATE AND TIME FORMAT STRINGS * Format Description Example *------ --------------------------------------------------------------------------- ----------------------- * d The CultureInfo shortDate Format Pattern "M/d/yyyy" * D The CultureInfo longDate Format Pattern "dddd, MMMM dd, yyyy" * F The CultureInfo fullDateTime Format Pattern "dddd, MMMM dd, yyyy h:mm:ss tt" * m The CultureInfo monthDay Format Pattern "MMMM dd" * r The CultureInfo rfc1123 Format Pattern "ddd, dd MMM yyyy HH:mm:ss GMT" * s The CultureInfo sortableDateTime Format Pattern "yyyy-MM-ddTHH:mm:ss" * t The CultureInfo shortTime Format Pattern "h:mm tt" * T The CultureInfo longTime Format Pattern "h:mm:ss tt" * u The CultureInfo universalSortableDateTime Format Pattern "yyyy-MM-dd HH:mm:ssZ" * y The CultureInfo yearMonth Format Pattern "MMMM, yyyy" * * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @return {String} A string representation of the current Date object. */ var ord = function (n) { switch (n * 1) { case 1: case 21: case 31: return "st"; case 2: case 22: return "nd"; case 3: case 23: return "rd"; default: return "th"; } }; var parseStandardFormats = function (format) { var y, c = Date.CultureInfo.formatPatterns; switch (format) { case "d": return this.toString(c.shortDate); case "D": return this.toString(c.longDate); case "F": return this.toString(c.fullDateTime); case "m": return this.toString(c.monthDay); case "r": case "R": y = this.clone().addMinutes(this.getTimezoneOffset()); return y.toString(c.rfc1123) + " GMT"; case "s": return this.toString(c.sortableDateTime); case "t": return this.toString(c.shortTime); case "T": return this.toString(c.longTime); case "u": y = this.clone().addMinutes(this.getTimezoneOffset()); return y.toString(c.universalSortableDateTime); case "y": return this.toString(c.yearMonth); default: return false; } }; var parseFormatStringsClosure = function (context) { return function (m) { if (m.charAt(0) === "\\") { return m.replace("\\", ""); } switch (m) { case "hh": return p(context.getHours() < 13 ? (context.getHours() === 0 ? 12 : context.getHours()) : (context.getHours() - 12)); case "h": return context.getHours() < 13 ? (context.getHours() === 0 ? 12 : context.getHours()) : (context.getHours() - 12); case "HH": return p(context.getHours()); case "H": return context.getHours(); case "mm": return p(context.getMinutes()); case "m": return context.getMinutes(); case "ss": return p(context.getSeconds()); case "s": return context.getSeconds(); case "yyyy": return p(context.getFullYear(), 4); case "yy": return p(context.getFullYear()); case "y": return context.getFullYear(); case "E": case "dddd": return Date.CultureInfo.dayNames[context.getDay()]; case "ddd": return Date.CultureInfo.abbreviatedDayNames[context.getDay()]; case "dd": return p(context.getDate()); case "d": return context.getDate(); case "MMMM": return Date.CultureInfo.monthNames[context.getMonth()]; case "MMM": return Date.CultureInfo.abbreviatedMonthNames[context.getMonth()]; case "MM": return p((context.getMonth() + 1)); case "M": return context.getMonth() + 1; case "t": return context.getHours() < 12 ? Date.CultureInfo.amDesignator.substring(0, 1) : Date.CultureInfo.pmDesignator.substring(0, 1); case "tt": return context.getHours() < 12 ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator; case "S": return ord(context.getDate()); case "W": return context.getWeek(); case "WW": return context.getISOWeek(); case "Q": return "Q" + context.getQuarter(); case "q": return String(context.getQuarter()); case "z": return context.getTimezone(); case "Z": case "X": return Date.getTimezoneOffset(context.getTimezone()); case "ZZ": // Timezone offset in seconds return context.getTimezoneOffset() * -60; case "u": return context.getDay(); case "L": return ($D.isLeapYear(context.getFullYear())) ? 1 : 0; case "B": // Swatch Internet Time (.beats) return "@"+((context.getUTCSeconds() + (context.getUTCMinutes()*60) + ((context.getUTCHours()+1)*3600))/86.4); default: return m; } }; }; $P.toString = function (format, ignoreStandards) { // Standard Date and Time Format Strings. Formats pulled from CultureInfo file and // may vary by culture. if (!ignoreStandards && format && format.length === 1) { output = parseStandardFormats.call(this, format); if (output) { return output; } } var parseFormatStrings = parseFormatStringsClosure(this); return format ? format.replace(/((\\)?(dd?d?d?|MM?M?M?|yy?y?y?|hh?|HH?|mm?|ss?|tt?|S|q|Q|WW?W?W?)(?![^\[]*\]))/g, parseFormatStrings).replace(/\[|\]/g, "") : this._toString(); }; }()); /************************************************************* * SugarPak - Domain Specific Language - Syntactical Sugar * *************************************************************/ (function () { var $D = Date, $P = $D.prototype, $N = Number.prototype; // private $P._orient = +1; // private $P._nth = null; // private $P._is = false; // private $P._same = false; // private $P._isSecond = false; // private $N._dateElement = "days"; /** * Moves the date to the next instance of a date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.today().next().friday();
	Date.today().next().fri();
	Date.today().next().march();
	Date.today().next().mar();
	Date.today().next().week();
	
* * @return {Date} date */ $P.next = function () { this._move = true; this._orient = +1; return this; }; /** * Creates a new Date (Date.today()) and moves the date to the next instance of the date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.next().friday();
	Date.next().fri();
	Date.next().march();
	Date.next().mar();
	Date.next().week();
	
* * @return {Date} date */ $D.next = function () { return $D.today().next(); }; /** * Moves the date to the previous instance of a date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.today().last().friday();
	Date.today().last().fri();
	Date.today().last().march();
	Date.today().last().mar();
	Date.today().last().week();
	
* * @return {Date} date */ $P.last = $P.prev = $P.previous = function () { this._move = true; this._orient = -1; return this; }; /** * Creates a new Date (Date.today()) and moves the date to the previous instance of the date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.last().friday();
	Date.last().fri();
	Date.previous().march();
	Date.prev().mar();
	Date.last().week();
	
* * @return {Date} date */ $D.last = $D.prev = $D.previous = function () { return $D.today().last(); }; /** * Performs a equality check when followed by either a month name, day name or .weekday() function. * Example

	Date.today().is().friday(); // true|false
	Date.today().is().fri();
	Date.today().is().march();
	Date.today().is().mar();
	
* * @return {Boolean} true|false */ $P.is = function () { this._is = true; return this; }; /** * Determines if two date objects occur on/in exactly the same instance of the subsequent date part function. * The function .same() must be followed by a date part function (example: .day(), .month(), .year(), etc). * * An optional Date can be passed in the date part function. If now date is passed as a parameter, 'Now' is used. * * The following example demonstrates how to determine if two dates fall on the exact same day. * * Example

	var d1 = Date.today(); // today at 00:00
	var d2 = new Date();   // exactly now.

	// Do they occur on the same day?
	d1.same().day(d2); // true
	
	// Do they occur on the same hour?
	d1.same().hour(d2); // false, unless d2 hour is '00' (midnight).
	
	// What if it's the same day, but one year apart?
	var nextYear = Date.today().add(1).year();

	d1.same().day(nextYear); // false, because the dates must occur on the exact same day. 
	
* * Scenario: Determine if a given date occurs during some week period 2 months from now. * * Example

	var future = Date.today().add(2).months();
	return someDate.same().week(future); // true|false;
	
* * @return {Boolean} true|false */ $P.same = function () { this._same = true; this._isSecond = false; return this; }; /** * Determines if the current date/time occurs during Today. Must be preceded by the .is() function. * Example

	someDate.is().today();    // true|false
	new Date().is().today();  // true
	Date.today().is().today();// true
	Date.today().add(-1).day().is().today(); // false
	
* * @return {Boolean} true|false */ $P.today = function () { return this.same().day(); }; /** * Determines if the current date is a weekday. This function must be preceded by the .is() function. * Example

	Date.today().is().weekday(); // true|false
	
* * @return {Boolean} true|false */ $P.weekday = function () { if (this._nth) { return df("Weekday").call(this); } if (this._move) { return this.addWeekdays(this._orient); } if (this._is) { this._is = false; return (!this.is().sat() && !this.is().sun()); } return false; }; /** * Determines if the current date is on the weekend. This function must be preceded by the .is() function. * Example

	Date.today().is().weekend(); // true|false
	
* * @return {Boolean} true|false */ $P.weekend = function () { if (this._is) { this._is = false; return (this.is().sat() || this.is().sun()); } return false; }; /** * Sets the Time of the current Date instance. A string "6:15 pm" or config object {hour:18, minute:15} are accepted. * Example

	// Set time to 6:15pm with a String
	Date.today().at("6:15pm");

	// Set time to 6:15pm with a config object
	Date.today().at({hour:18, minute:15});
	
* * @return {Date} date */ $P.at = function (time) { return (typeof time === "string") ? $D.parse(this.toString("d") + " " + time) : this.set(time); }; /** * Creates a new Date() and adds this (Number) to the date based on the preceding date element function (eg. second|minute|hour|day|month|year). * Example

	// Undeclared Numbers must be wrapped with parentheses. Requirment of JavaScript.
	(3).days().fromNow();
	(6).months().fromNow();

	// Declared Number variables do not require parentheses. 
	var n = 6;
	n.months().fromNow();
	
* * @return {Date} A new Date instance */ $N.fromNow = $N.after = function (date) { var c = {}; c[this._dateElement] = this; return ((!date) ? new Date() : date.clone()).add(c); }; /** * Creates a new Date() and subtract this (Number) from the date based on the preceding date element function (eg. second|minute|hour|day|month|year). * Example

	// Undeclared Numbers must be wrapped with parentheses. Requirment of JavaScript.
	(3).days().ago();
	(6).months().ago();

	// Declared Number variables do not require parentheses. 
	var n = 6;
	n.months().ago();
	
* * @return {Date} A new Date instance */ $N.ago = $N.before = function (date) { var c = {}, s = (this._dateElement[this._dateElement.length-1] !== "s") ? this._dateElement + "s" : this._dateElement; c[s] = this * -1; return ((!date) ? new Date() : date.clone()).add(c); }; // Do NOT modify the following string tokens. These tokens are used to build dynamic functions. // All culture-specific strings can be found in the CultureInfo files. var dx = ("sunday monday tuesday wednesday thursday friday saturday").split(/\s/), mx = ("january february march april may june july august september october november december").split(/\s/), px = ("Millisecond Second Minute Hour Day Week Month Year Quarter Weekday").split(/\s/), pxf = ("Milliseconds Seconds Minutes Hours Date Week Month FullYear Quarter").split(/\s/), nth = ("final first second third fourth fifth").split(/\s/), de; /** * Returns an object literal of all the date parts. * Example

	var o = new Date().toObject();
	
	// { year: 2008, month: 4, week: 20, day: 13, hour: 18, minute: 9, second: 32, millisecond: 812 }
	
	// The object properties can be referenced directly from the object.
	
	alert(o.day);  // alerts "13"
	alert(o.year); // alerts "2008"
	
* * @return {Date} An object literal representing the original date object. */ $P.toObject = function () { var o = {}; for (var i = 0; i < px.length; i++) { if (this["get" + pxf[i]]) { o[px[i].toLowerCase()] = this["get" + pxf[i]](); } } return o; }; /** * Returns a date created from an object literal. Ignores the .week property if set in the config. * Example

	var o = new Date().toObject();
	
	return Date.fromObject(o); // will return the same date. 

	var o2 = {month: 1, day: 20, hour: 18}; // birthday party!
	Date.fromObject(o2);
	
* * @return {Date} An object literal representing the original date object. */ $D.fromObject = function(config) { config.week = null; return Date.today().set(config); }; // Create day name functions and abbreviated day name functions (eg. monday(), friday(), fri()). var df = function (n) { return function () { if (this._is) { this._is = false; return this.getDay() === n; } if (this._move) { this._move = null; } if (this._nth !== null) { // If the .second() function was called earlier, remove the _orient // from the date, and then continue. // This is required because 'second' can be used in two different context. // // Example // // Date.today().add(1).second(); // Date.march().second().monday(); // // Things get crazy with the following... // Date.march().add(1).second().second().monday(); // but it works!! // if (this._isSecond) { this.addSeconds(this._orient * -1); } // make sure we reset _isSecond this._isSecond = false; var ntemp = this._nth; this._nth = null; var temp = this.clone().moveToLastDayOfMonth(); this.moveToNthOccurrence(n, ntemp); if (this > temp) { throw new RangeError($D.getDayName(n) + " does not occur " + ntemp + " times in the month of " + $D.getMonthName(temp.getMonth()) + " " + temp.getFullYear() + "."); } return this; } return this.moveToDayOfWeek(n, this._orient); }; }; var sdf = function (n) { return function () { var t = $D.today(), shift = n - t.getDay(); if (n === 0 && Date.CultureInfo.firstDayOfWeek === 1 && t.getDay() !== 0) { shift = shift + 7; } return t.addDays(shift); }; }; // Create month name functions and abbreviated month name functions (eg. january(), march(), mar()). var month_instance_functions = function (n) { return function () { if (this._is) { this._is = false; return this.getMonth() === n; } return this.moveToMonth(n, this._orient); }; }; var month_static_functions = function (n) { return function () { return $D.today().set({ month: n, day: 1 }); }; }; var processTerms = function (names, staticFunc, instanceFunc) { for (var i = 0; i < names.length; i++) { // Create constant static Name variables. $D[names[i].toUpperCase()] = $D[names[i].toUpperCase().substring(0, 3)] = i; // Create Name functions. $D[names[i]] = $D[names[i].substring(0, 3)] = staticFunc(i); // Create Name instance functions. $P[names[i]] = $P[names[i].substring(0, 3)] = instanceFunc(i); } }; processTerms(dx, sdf, df); processTerms(mx, month_static_functions, month_instance_functions); // Create date element functions and plural date element functions used with Date (eg. day(), days(), months()). var ef = function (j) { return function () { // if the .second() function was called earlier, the _orient // has alread been added. Just return this and reset _isSecond. if (this._isSecond) { this._isSecond = false; return this; } if (this._same) { this._same = this._is = false; var o1 = this.toObject(), o2 = (arguments[0] || new Date()).toObject(), v = "", k = j.toLowerCase(); // the substr trick with -1 doesn't work in IE8 or less k = (k[k.length-1] === "s") ? k.substring(0,k.length-1) : k; for (var m = (px.length - 1); m > -1; m--) { v = px[m].toLowerCase(); if (o1[v] !== o2[v]) { return false; } if (k === v) { break; } } return true; } if (j.substring(j.length - 1) !== "s") { j += "s"; } if (this._move) { this._move = null; } return this["add" + j](this._orient); }; }; var nf = function (n) { return function () { this._dateElement = n; return this; }; }; for (var k = 0; k < px.length; k++) { de = px[k].toLowerCase(); if(de !== "weekday") { // Create date element functions and plural date element functions used with Date (eg. day(), days(), months()). $P[de] = $P[de + "s"] = ef(px[k]); // Create date element functions and plural date element functions used with Number (eg. day(), days(), months()). $N[de] = $N[de + "s"] = nf(de + "s"); } } $P._ss = ef("Second"); var nthfn = function (n) { return function (dayOfWeek) { if (this._same) { return this._ss(arguments[0]); } if (dayOfWeek || dayOfWeek === 0) { return this.moveToNthOccurrence(dayOfWeek, n); } this._nth = n; // if the operator is 'second' add the _orient, then deal with it later... if (n === 2 && (dayOfWeek === undefined || dayOfWeek === null)) { this._isSecond = true; return this.addSeconds(this._orient); } return this; }; }; for (var l = 0; l < nth.length; l++) { $P[nth[l]] = (l === 0) ? nthfn(-1) : nthfn(l); } }()); (function () { "use strict"; Date.Parsing = { Exception: function (s) { this.message = "Parse error at '" + s.substring(0, 10) + " ...'"; } }; var $P = Date.Parsing; var dayOffsets = { standard: [0,31,59,90,120,151,181,212,243,273,304,334], leap: [0,31,60,91,121,152,182,213,244,274,305,335] }; $P.isLeapYear = function(year) { return ((year % 4 === 0) && (year % 100 !== 0)) || (year % 400 === 0); }; var utils = { multiReplace : function (str, hash ) { var key; for (key in hash) { if (Object.prototype.hasOwnProperty.call(hash, key)) { var regex; if (typeof hash[key] === "function") { } else { regex = (hash[key] instanceof RegExp) ? hash[key] : new RegExp(hash[key], "g"); } str = str.replace(regex, key); } } return str; }, getDayOfYearFromWeek : function (obj) { var d, jan4, offset; obj.weekDay = (!obj.weekDay && obj.weekDay !== 0) ? 1 : obj.weekDay; d = new Date(obj.year, 0, 4); jan4 = d.getDay() === 0 ? 7 : d.getDay(); // JS is 0 indexed on Sunday. offset = jan4+3; obj.dayOfYear = ((obj.week * 7) + (obj.weekDay === 0 ? 7 : obj.weekDay))-offset; return obj; }, getDayOfYear : function (obj, dayOffset) { if (!obj.dayOfYear) { obj = utils.getDayOfYearFromWeek(obj); } for (var i=0;i <= dayOffset.length;i++) { if (obj.dayOfYear < dayOffset[i] || i === dayOffset.length) { obj.day = obj.day ? obj.day : (obj.dayOfYear - dayOffset[i-1]); break; } else { obj.month = i; } } return obj; }, adjustForTimeZone : function (obj, date) { var offset; if (obj.zone.toUpperCase() === "Z" || (obj.zone_hours === 0 && obj.zone_minutes === 0)) { // it's UTC/GML so work out the current timeszone offset offset = -date.getTimezoneOffset(); } else { offset = (obj.zone_hours*60) + (obj.zone_minutes || 0); if (obj.zone_sign === "+") { offset *= -1; } offset -= date.getTimezoneOffset(); } date.setMinutes(date.getMinutes()+offset); return date; }, setDefaults : function (obj) { obj.year = obj.year || Date.today().getFullYear(); obj.hours = obj.hours || 0; obj.minutes = obj.minutes || 0; obj.seconds = obj.seconds || 0; obj.milliseconds = obj.milliseconds || 0; if (!(!obj.month && (obj.week || obj.dayOfYear))) { // if we have a month, or if we don't but don't have the day calculation data obj.month = obj.month || 0; obj.day = obj.day || 1; } return obj; }, dataNum: function (data, mod, explict, postProcess) { var dataNum = data*1; if (mod) { if (postProcess) { return data ? mod(data)*1 : data; } else { return data ? mod(dataNum) : data; } } else if (!explict){ return data ? dataNum : data; } else { return (data && typeof data !== "undefined") ? dataNum : data; } }, timeDataProcess: function (obj) { var timeObj = {}; for (var x in obj.data) { if (obj.data.hasOwnProperty(x)) { timeObj[x] = obj.ignore[x] ? obj.data[x] : utils.dataNum(obj.data[x], obj.mods[x], obj.explict[x], obj.postProcess[x]); } } if (obj.data.secmins) { obj.data.secmins = obj.data.secmins.replace(",", ".") * 60; if (!timeObj.minutes) { timeObj.minutes = obj.data.secmins; } else if (!timeObj.seconds) { timeObj.seconds = obj.data.secmins; } delete obj.secmins; } return timeObj; }, buildTimeObjectFromData: function (data) { var time = utils.timeDataProcess({ data: { year : data[1], month : data[5], day : data[7], week : data[8], dayOfYear : data[10], hours : data[15], zone_hours : data[23], zone_minutes : data[24], zone : data[21], zone_sign : data[22], weekDay : data[9], minutes: data[16], seconds: data[19], milliseconds: data[20], secmins: data[18] }, mods: { month: function(data) { return data-1; }, weekDay: function (data) { data = Math.abs(data); return (data === 7 ? 0 : data); }, minutes: function (data) { return data.replace(":",""); }, seconds: function (data) { return Math.floor( (data.replace(":","").replace(",","."))*1 ); }, milliseconds: function (data) { return (data.replace(",",".")*1000); } }, postProcess: { minutes: true, seconds: true, milliseconds: true }, explict: { zone_hours: true, zone_minutes: true }, ignore: { zone: true, zone_sign: true, secmins: true } }); return time; }, addToHash: function (hash, keys, data) { keys = keys; data = data; var len = keys.length; for (var i = 0; i < len; i++) { hash[keys[i]] = data[i]; } return hash; }, combineRegex: function (r1, r2) { return new RegExp("(("+r1.source+")\\s("+r2.source+"))"); }, getDateNthString: function(add, last, inc){ if (add) { return Date.today().addDays(inc).toString("d"); } else if (last) { return Date.today().last()[inc]().toString("d"); } }, buildRegexData: function (array) { var arr = []; var len = array.length; for (var i=0; i < len; i++) { if (Object.prototype.toString.call(array[i]) === '[object Array]') { // oldIE compat version of Array.isArray arr.push(this.combineRegex(array[i][0], array[i][1])); } else { arr.push(array[i]); } } return arr; } }; $P.processTimeObject = function (obj) { var date, dayOffset; utils.setDefaults(obj); dayOffset = ($P.isLeapYear(obj.year)) ? dayOffsets.leap : dayOffsets.standard; if (!obj.month && (obj.week || obj.dayOfYear)) { utils.getDayOfYear(obj, dayOffset); } else { obj.dayOfYear = dayOffset[obj.month] + obj.day; } date = new Date(obj.year, obj.month, obj.day, obj.hours, obj.minutes, obj.seconds, obj.milliseconds); if (obj.zone) { utils.adjustForTimeZone(obj, date); // adjust (and calculate) for timezone } return date; }; $P.ISO = { regex : /^([\+-]?\d{4}(?!\d{2}\b))((-?)((0[1-9]|1[0-2])(\3([12]\d|0[1-9]|3[01]))?|W([0-4]\d|5[0-3])(-?[1-7])?|(00[1-9]|0[1-9]\d|[12]\d{2}|3([0-5]\d|6[1-6])))([T\s]((([01]\d|2[0-4])((:?)[0-5]\d)?|24\:?00)([\.,]\d+(?!:))?)?(\17[0-5]\d([\.,]\d+)?)?\s?([zZ]|([\+-])([01]\d|2[0-3]):?([0-5]\d)?)?)?)?$/, parse : function (s) { var time, data = s.match(this.regex); if (!data || !data.length) { return null; } time = utils.buildTimeObjectFromData(data); if (!time.year || (!time.year && (!time.month && !time.day) && (!time.week && !time.dayOfYear)) ) { return null; } return $P.processTimeObject(time); } }; $P.Numeric = { isNumeric: function (e){return!isNaN(parseFloat(e))&&isFinite(e);}, regex: /\b([0-1]?[0-9])([0-3]?[0-9])([0-2]?[0-9]?[0-9][0-9])\b/i, parse: function (s) { var data, i, time = {}, order = Date.CultureInfo.dateElementOrder.split(""); if (!(this.isNumeric(s)) || // if it's non-numeric OR (s[0] === "+" && s[0] === "-")) { // It's an arithmatic string (eg +/-1000) return null; } if (s.length < 5 && s.indexOf(".") < 0 && s.indexOf("/") < 0) { // assume it's just a year. time.year = s; return $P.processTimeObject(time); } data = s.match(this.regex); if (!data || !data.length) { return null; } for (i=0; i < order.length; i++) { switch(order[i]) { case "d": time.day = data[i+1]; break; case "m": time.month = (data[i+1]-1); break; case "y": time.year = data[i+1]; break; } } return $P.processTimeObject(time); } }; $P.Normalizer = { regexData: function () { var $R = Date.CultureInfo.regexPatterns; return utils.buildRegexData([ $R.tomorrow, $R.yesterday, [$R.past, $R.mon], [$R.past, $R.tue], [$R.past, $R.wed], [$R.past, $R.thu], [$R.past, $R.fri], [$R.past, $R.sat], [$R.past, $R.sun] ]); }, basicReplaceHash : function() { var $R = Date.CultureInfo.regexPatterns; return { "January": $R.jan.source, "February": $R.feb, "March": $R.mar, "April": $R.apr, "May": $R.may, "June": $R.jun, "July": $R.jul, "August": $R.aug, "September": $R.sep, "October": $R.oct, "November": $R.nov, "December": $R.dec, "": /\bat\b/gi, " ": /\s{2,}/, "am": $R.inTheMorning, "9am": $R.thisMorning, "pm": $R.inTheEvening, "7pm":$R.thisEvening }; }, keys : function(){ return [ utils.getDateNthString(true, false, 1), // tomorrow utils.getDateNthString(true, false, -1), // yesterday utils.getDateNthString(false, true, "monday"), //last mon utils.getDateNthString(false, true, "tuesday"), //last tues utils.getDateNthString(false, true, "wednesday"), //last wed utils.getDateNthString(false, true, "thursday"), //last thurs utils.getDateNthString(false, true, "friday"), //last fri utils.getDateNthString(false, true, "saturday"), //last sat utils.getDateNthString(false, true, "sunday") //last sun ]; }, buildRegexFunctions: function () { var $R = Date.CultureInfo.regexPatterns; var __ = Date.i18n.__; var tomorrowRE = new RegExp("(\\b\\d\\d?("+__("AM")+"|"+__("PM")+")? )("+$R.tomorrow.source.slice(1)+")", "i"); // adapted tomorrow regex for AM PM relative dates var todayRE = new RegExp($R.today.source + "(?!\\s*([+-]))\\b"); // today, but excludes the math operators (eg "today + 2h") this.replaceFuncs = [ [todayRE, function (full) { return (full.length > 1) ? Date.today().toString("d") : full; }], [tomorrowRE, function(full, m1) { var t = Date.today().addDays(1).toString("d"); return (t + " " + m1); }], [$R.amThisMorning, function(str, am){return am;}], [$R.pmThisEvening, function(str, pm){return pm;}] ]; }, buildReplaceData: function () { this.buildRegexFunctions(); this.replaceHash = utils.addToHash(this.basicReplaceHash(), this.keys(), this.regexData()); }, stringReplaceFuncs: function (s) { for (var i=0; i < this.replaceFuncs.length; i++) { s = s.replace(this.replaceFuncs[i][0], this.replaceFuncs[i][1]); } return s; }, parse: function (s) { s = this.stringReplaceFuncs(s); s = utils.multiReplace(s, this.replaceHash); try { var n = s.split(/([\s\-\.\,\/\x27]+)/); if (n.length === 3 && $P.Numeric.isNumeric(n[0]) && $P.Numeric.isNumeric(n[2]) && (n[2].length >= 4)) { // ok, so we're dealing with x/year. But that's not a full date. // This fixes wonky dateElementOrder parsing when set to dmy order. if (Date.CultureInfo.dateElementOrder[0] === "d") { s = "1/" + n[0] + "/" + n[2]; // set to 1st of month and normalize the seperator } } } catch (e) {} return s; } }; $P.Normalizer.buildReplaceData(); }()); (function () { var $P = Date.Parsing; var _ = $P.Operators = { // // Tokenizers // rtoken: function (r) { // regex token return function (s) { var mx = s.match(r); if (mx) { return ([ mx[0], s.substring(mx[0].length) ]); } else { throw new $P.Exception(s); } }; }, token: function () { // whitespace-eating token return function (s) { return _.rtoken(new RegExp("^\\s*" + s + "\\s*"))(s); }; }, stoken: function (s) { // string token return _.rtoken(new RegExp("^" + s)); }, // Atomic Operators until: function (p) { return function (s) { var qx = [], rx = null; while (s.length) { try { rx = p.call(this, s); } catch (e) { qx.push(rx[0]); s = rx[1]; continue; } break; } return [ qx, s ]; }; }, many: function (p) { return function (s) { var rx = [], r = null; while (s.length) { try { r = p.call(this, s); } catch (e) { return [ rx, s ]; } rx.push(r[0]); s = r[1]; } return [ rx, s ]; }; }, // generator operators -- see below optional: function (p) { return function (s) { var r = null; try { r = p.call(this, s); } catch (e) { return [ null, s ]; } return [ r[0], r[1] ]; }; }, not: function (p) { return function (s) { try { p.call(this, s); } catch (e) { return [null, s]; } throw new $P.Exception(s); }; }, ignore: function (p) { return p ? function (s) { var r = null; r = p.call(this, s); return [null, r[1]]; } : null; }, product: function () { var px = arguments[0], qx = Array.prototype.slice.call(arguments, 1), rx = []; for (var i = 0 ; i < px.length ; i++) { rx.push(_.each(px[i], qx)); } return rx; }, cache: function (rule) { var cache = {}, cache_length = 0, cache_keys = [], CACHE_MAX = Date.Config.CACHE_MAX || 100000, r = null; var cacheCheck = function () { if (cache_length === CACHE_MAX) { // kill several keys, don't want to have to do this all the time... for (var i=0; i < 10; i++) { var key = cache_keys.shift(); if (key) { delete cache[key]; cache_length--; } } } }; return function (s) { cacheCheck(); try { r = cache[s] = (cache[s] || rule.call(this, s)); } catch (e) { r = cache[s] = e; } cache_length++; cache_keys.push(s); if (r instanceof $P.Exception) { throw r; } else { return r; } }; }, // vector operators -- see below any: function () { var px = arguments; return function (s) { var r = null; for (var i = 0; i < px.length; i++) { if (px[i] == null) { continue; } try { r = (px[i].call(this, s)); } catch (e) { r = null; } if (r) { return r; } } throw new $P.Exception(s); }; }, each: function () { var px = arguments; return function (s) { var rx = [], r = null; for (var i = 0; i < px.length ; i++) { if (px[i] == null) { continue; } try { r = (px[i].call(this, s)); } catch (e) { throw new $P.Exception(s); } rx.push(r[0]); s = r[1]; } return [ rx, s]; }; }, all: function () { var px = arguments, _ = _; return _.each(_.optional(px)); }, // delimited operators sequence: function (px, d, c) { d = d || _.rtoken(/^\s*/); c = c || null; if (px.length === 1) { return px[0]; } return function (s) { var r = null, q = null; var rx = []; for (var i = 0; i < px.length ; i++) { try { r = px[i].call(this, s); } catch (e) { break; } rx.push(r[0]); try { q = d.call(this, r[1]); } catch (ex) { q = null; break; } s = q[1]; } if (!r) { throw new $P.Exception(s); } if (q) { throw new $P.Exception(q[1]); } if (c) { try { r = c.call(this, r[1]); } catch (ey) { throw new $P.Exception(r[1]); } } return [ rx, (r?r[1]:s) ]; }; }, // // Composite Operators // between: function (d1, p, d2) { d2 = d2 || d1; var _fn = _.each(_.ignore(d1), p, _.ignore(d2)); return function (s) { var rx = _fn.call(this, s); return [[rx[0][0], r[0][2]], rx[1]]; }; }, list: function (p, d, c) { d = d || _.rtoken(/^\s*/); c = c || null; return (p instanceof Array ? _.each(_.product(p.slice(0, -1), _.ignore(d)), p.slice(-1), _.ignore(c)) : _.each(_.many(_.each(p, _.ignore(d))), px, _.ignore(c))); }, set: function (px, d, c) { d = d || _.rtoken(/^\s*/); c = c || null; return function (s) { // r is the current match, best the current 'best' match // which means it parsed the most amount of input var r = null, p = null, q = null, rx = null, best = [[], s], last = false; // go through the rules in the given set for (var i = 0; i < px.length ; i++) { // last is a flag indicating whether this must be the last element // if there is only 1 element, then it MUST be the last one q = null; p = null; r = null; last = (px.length === 1); // first, we try simply to match the current pattern // if not, try the next pattern try { r = px[i].call(this, s); } catch (e) { continue; } // since we are matching against a set of elements, the first // thing to do is to add r[0] to matched elements rx = [[r[0]], r[1]]; // if we matched and there is still input to parse and // we don't already know this is the last element, // we're going to next check for the delimiter ... // if there's none, or if there's no input left to parse // than this must be the last element after all ... if (r[1].length > 0 && ! last) { try { q = d.call(this, r[1]); } catch (ex) { last = true; } } else { last = true; } // if we parsed the delimiter and now there's no more input, // that means we shouldn't have parsed the delimiter at all // so don't update r and mark this as the last element ... if (!last && q[1].length === 0) { last = true; } // so, if this isn't the last element, we're going to see if // we can get any more matches from the remaining (unmatched) // elements ... if (!last) { // build a list of the remaining rules we can match against, // i.e., all but the one we just matched against var qx = []; for (var j = 0; j < px.length ; j++) { if (i !== j) { qx.push(px[j]); } } // now invoke recursively set with the remaining input // note that we don't include the closing delimiter ... // we'll check for that ourselves at the end p = _.set(qx, d).call(this, q[1]); // if we got a non-empty set as a result ... // (otw rx already contains everything we want to match) if (p[0].length > 0) { // update current result, which is stored in rx ... // basically, pick up the remaining text from p[1] // and concat the result from p[0] so that we don't // get endless nesting ... rx[0] = rx[0].concat(p[0]); rx[1] = p[1]; } } // at this point, rx either contains the last matched element // or the entire matched set that starts with this element. // now we just check to see if this variation is better than // our best so far, in terms of how much of the input is parsed if (rx[1].length < best[1].length) { best = rx; } // if we've parsed all the input, then we're finished if (best[1].length === 0) { break; } } // so now we've either gone through all the patterns trying them // as the initial match; or we found one that parsed the entire // input string ... // if best has no matches, just return empty set ... if (best[0].length === 0) { return best; } // if a closing delimiter is provided, then we have to check it also if (c) { // we try this even if there is no remaining input because the pattern // may well be optional or match empty input ... try { q = c.call(this, best[1]); } catch (ey) { throw new $P.Exception(best[1]); } // it parsed ... be sure to update the best match remaining input best[1] = q[1]; } // if we're here, either there was no closing delimiter or we parsed it // so now we have the best match; just return it! return best; }; }, forward: function (gr, fname) { return function (s) { return gr[fname].call(this, s); }; }, // // Translation Operators // replace: function (rule, repl) { return function (s) { var r = rule.call(this, s); return [repl, r[1]]; }; }, process: function (rule, fn) { return function (s) { var r = rule.call(this, s); return [fn.call(this, r[0]), r[1]]; }; }, min: function (min, rule) { return function (s) { var rx = rule.call(this, s); if (rx[0].length < min) { throw new $P.Exception(s); } return rx; }; } }; // Generator Operators And Vector Operators // Generators are operators that have a signature of F(R) => R, // taking a given rule and returning another rule, such as // ignore, which parses a given rule and throws away the result. // Vector operators are those that have a signature of F(R1,R2,...) => R, // take a list of rules and returning a new rule, such as each. // Generator operators are converted (via the following _generator // function) into functions that can also take a list or array of rules // and return an array of new rules as though the function had been // called on each rule in turn (which is what actually happens). // This allows generators to be used with vector operators more easily. // Example: // each(ignore(foo, bar)) instead of each(ignore(foo), ignore(bar)) // This also turns generators into vector operators, which allows // constructs like: // not(cache(foo, bar)) var _generator = function (op) { function gen() { var args = null, rx = [], px, i; if (arguments.length > 1) { args = Array.prototype.slice.call(arguments); } else if (arguments[0] instanceof Array) { args = arguments[0]; } if (args) { px = args.shift(); if (px.length > 0) { args.unshift(px[i]); rx.push(op.apply(null, args)); args.shift(); return rx; } } else { return op.apply(null, arguments); } } return gen; }; var gx = "optional not ignore cache".split(/\s/); for (var i = 0 ; i < gx.length ; i++) { _[gx[i]] = _generator(_[gx[i]]); } var _vector = function (op) { return function () { if (arguments[0] instanceof Array) { return op.apply(null, arguments[0]); } else { return op.apply(null, arguments); } }; }; var vx = "each any all".split(/\s/); for (var j = 0 ; j < vx.length ; j++) { _[vx[j]] = _vector(_[vx[j]]); } }()); (function () { var $D = Date; var flattenAndCompact = function (ax) { var rx = []; for (var i = 0; i < ax.length; i++) { if (ax[i] instanceof Array) { rx = rx.concat(flattenAndCompact(ax[i])); } else { if (ax[i]) { rx.push(ax[i]); } } } return rx; }; var parseMeridian = function () { if (this.meridian && (this.hour || this.hour === 0)) { if (this.meridian === "a" && this.hour > 11 && Date.Config.strict24hr){ throw "Invalid hour and meridian combination"; } else if (this.meridian === "p" && this.hour < 12 && Date.Config.strict24hr){ throw "Invalid hour and meridian combination"; } else if (this.meridian === "p" && this.hour < 12) { this.hour = this.hour + 12; } else if (this.meridian === "a" && this.hour === 12) { this.hour = 0; } } }; var setDefaults = function () { var now = new Date(); if ((this.hour || this.minute) && (!this.month && !this.year && !this.day)) { this.day = now.getDate(); } if (!this.year) { this.year = now.getFullYear(); } if (!this.month && this.month !== 0) { this.month = now.getMonth(); } if (!this.day) { this.day = 1; } if (!this.hour) { this.hour = 0; } if (!this.minute) { this.minute = 0; } if (!this.second) { this.second = 0; } if (!this.millisecond) { this.millisecond = 0; } }; var finishUtils = { getToday: function () { if (this.now || "hour minute second".indexOf(this.unit) !== -1) { return new Date(); } else { return $D.today(); } }, setDaysFromWeekday: function (today, orient){ var gap; orient = orient || 1; this.unit = "day"; gap = ($D.getDayNumberFromName(this.weekday) - today.getDay()); this.days = gap ? ((gap + (orient * 7)) % 7) : (orient * 7); return this; }, setMonthsFromMonth: function (today, orient) { var gap; orient = orient || 1; this.unit = "month"; gap = (this.month - today.getMonth()); this.months = gap ? ((gap + (orient * 12)) % 12) : (orient * 12); this.month = null; return this; }, setDMYFromWeekday: function () { var d = Date[this.weekday](); this.day = d.getDate(); if (!this.month) { this.month = d.getMonth(); } this.year = d.getFullYear(); return this; }, setUnitValue: function (orient) { if (!this.value && this.operator && this.operator !== null && this[this.unit + "s"] && this[this.unit + "s"] !== null) { this[this.unit + "s"] = this[this.unit + "s"] + ((this.operator === "add") ? 1 : -1) + (this.value||0) * orient; } else if (this[this.unit + "s"] == null || this.operator != null) { if (!this.value) { this.value = 1; } this[this.unit + "s"] = this.value * orient; } }, generateDateFromWeeks: function () { var weekday = (this.weekday !== undefined) ? this.weekday : "today"; var d = Date[weekday]().addWeeks(this.weeks); if (this.now) { d.setTimeToNow(); } return d; } }; $D.Translator = { hour: function (s) { return function () { this.hour = Number(s); }; }, minute: function (s) { return function () { this.minute = Number(s); }; }, second: function (s) { return function () { this.second = Number(s); }; }, /* for ss.s format */ secondAndMillisecond: function (s) { return function () { var mx = s.match(/^([0-5][0-9])\.([0-9]{1,3})/); this.second = Number(mx[1]); this.millisecond = Number(mx[2]); }; }, meridian: function (s) { return function () { this.meridian = s.slice(0, 1).toLowerCase(); }; }, timezone: function (s) { return function () { var n = s.replace(/[^\d\+\-]/g, ""); if (n.length) { this.timezoneOffset = Number(n); } else { this.timezone = s.toLowerCase(); } }; }, day: function (x) { var s = x[0]; return function () { this.day = Number(s.match(/\d+/)[0]); if (this.day < 1) { throw "invalid day"; } }; }, month: function (s) { return function () { this.month = (s.length === 3) ? "jan feb mar apr may jun jul aug sep oct nov dec".indexOf(s)/4 : Number(s) - 1; if (this.month < 0) { throw "invalid month"; } }; }, year: function (s) { return function () { var n = Number(s); this.year = ((s.length > 2) ? n : (n + (((n + 2000) < Date.CultureInfo.twoDigitYearMax) ? 2000 : 1900))); }; }, rday: function (s) { return function () { switch (s) { case "yesterday": this.days = -1; break; case "tomorrow": this.days = 1; break; case "today": this.days = 0; break; case "now": this.days = 0; this.now = true; break; } }; }, finishExact: function (x) { var d; x = (x instanceof Array) ? x : [x]; for (var i = 0 ; i < x.length ; i++) { if (x[i]) { x[i].call(this); } } setDefaults.call(this); parseMeridian.call(this); if (this.day > $D.getDaysInMonth(this.year, this.month)) { throw new RangeError(this.day + " is not a valid value for days."); } d = new Date(this.year, this.month, this.day, this.hour, this.minute, this.second, this.millisecond); if (this.year < 100) { d.setFullYear(this.year); // means years less that 100 are process correctly. JS will parse it otherwise as 1900-1999. } if (this.timezone) { d.set({ timezone: this.timezone }); } else if (this.timezoneOffset) { d.set({ timezoneOffset: this.timezoneOffset }); } return d; }, finish: function (x) { var today, expression, orient, temp; x = (x instanceof Array) ? flattenAndCompact(x) : [ x ]; if (x.length === 0) { return null; } for (var i = 0 ; i < x.length ; i++) { if (typeof x[i] === "function") { x[i].call(this); } } if (this.now && !this.unit && !this.operator) { return new Date(); } else { today = finishUtils.getToday.call(this); } expression = !!(this.days && this.days !== null || this.orient || this.operator); orient = ((this.orient === "past" || this.operator === "subtract") ? -1 : 1); if (this.month && this.unit === "week") { this.value = this.month + 1; delete this.month; delete this.day; } if ((this.month || this.month === 0) && "year day hour minute second".indexOf(this.unit) !== -1) { if (!this.value) { this.value = this.month + 1; } this.month = null; expression = true; } if (!expression && this.weekday && !this.day && !this.days) { finishUtils.setDMYFromWeekday.call(this); } if (expression && this.weekday && this.unit !== "month" && this.unit !== "week") { finishUtils.setDaysFromWeekday.call(this, today, orient); } if (this.weekday && this.unit !== "week" && !this.day && !this.days) { temp = Date[this.weekday](); this.day = temp.getDate(); if (temp.getMonth() !== today.getMonth()) { this.month = temp.getMonth(); } } if (this.month && this.unit === "day" && this.operator) { if (!this.value) { this.value = (this.month + 1); } this.month = null; } if (this.value != null && this.month != null && this.year != null) { this.day = this.value * 1; } if (this.month && !this.day && this.value) { today.set({ day: this.value * 1 }); if (!expression) { this.day = this.value * 1; } } if (!this.month && this.value && this.unit === "month" && !this.now) { this.month = this.value; expression = true; } if (expression && (this.month || this.month === 0) && this.unit !== "year") { finishUtils.setMonthsFromMonth.call(this, today, orient); } if (!this.unit) { this.unit = "day"; } finishUtils.setUnitValue.call(this, orient); parseMeridian.call(this); if ((this.month || this.month === 0) && !this.day) { this.day = 1; } if (!this.orient && !this.operator && this.unit === "week" && this.value && !this.day && !this.month) { return Date.today().setWeek(this.value); } if (this.unit === "week" && this.weeks && !this.day && !this.month) { return finishUtils.generateDateFromWeeks.call(this); } if (expression && this.timezone && this.day && this.days) { this.day = this.days; } if (expression){ today.add(this); } else { today.set(this); } if (this.timezone) { this.timezone = this.timezone.toUpperCase(); var offset = $D.getTimezoneOffset(this.timezone); var timezone; if (today.hasDaylightSavingTime()) { // lets check that we're being sane with timezone setting timezone = $D.getTimezoneAbbreviation(offset, today.isDaylightSavingTime()); if (timezone !== this.timezone) { // bugger, we're in a place where things like EST vs EDT matters. if (today.isDaylightSavingTime()) { today.addHours(-1); } else { today.addHours(1); } } } today.setTimezoneOffset(offset); } return today; } }; }()); (function () { var $D = Date; $D.Grammar = {}; var _ = $D.Parsing.Operators, g = $D.Grammar, t = $D.Translator, _fn; // Allow rolling up into general purpose rules _fn = function () { return _.each(_.any.apply(null, arguments), _.not(g.ctoken2("timeContext"))); }; g.datePartDelimiter = _.rtoken(/^([\s\-\.\,\/\x27]+)/); g.timePartDelimiter = _.stoken(":"); g.whiteSpace = _.rtoken(/^\s*/); g.generalDelimiter = _.rtoken(/^(([\s\,]|at|@|on)+)/); var _C = {}; g.ctoken = function (keys) { var fn = _C[keys]; if (! fn) { var c = Date.CultureInfo.regexPatterns; var kx = keys.split(/\s+/), px = []; for (var i = 0; i < kx.length ; i++) { px.push(_.replace(_.rtoken(c[kx[i]]), kx[i])); } fn = _C[keys] = _.any.apply(null, px); } return fn; }; g.ctoken2 = function (key) { return _.rtoken(Date.CultureInfo.regexPatterns[key]); }; var cacheProcessRtoken = function (key, token, type, eachToken) { if (eachToken) { g[key] = _.cache(_.process(_.each(_.rtoken(token),_.optional(g.ctoken2(eachToken))), type)); } else { g[key] = _.cache(_.process(_.rtoken(token), type)); } }; var cacheProcessCtoken = function (token, type) { return _.cache(_.process(g.ctoken2(token), type)); }; var _F = {}; //function cache var _get = function (f) { _F[f] = (_F[f] || g.format(f)[0]); return _F[f]; }; g.allformats = function (fx) { var rx = []; if (fx instanceof Array) { for (var i = 0; i < fx.length; i++) { rx.push(_get(fx[i])); } } else { rx.push(_get(fx)); } return rx; }; g.formats = function (fx) { if (fx instanceof Array) { var rx = []; for (var i = 0 ; i < fx.length ; i++) { rx.push(_get(fx[i])); } return _.any.apply(null, rx); } else { return _get(fx); } }; var grammarFormats = { timeFormats: function(){ var i, RTokenKeys = [ "h", "hh", "H", "HH", "m", "mm", "s", "ss", "ss.s", "z", "zz" ], RToken = [ /^(0[0-9]|1[0-2]|[1-9])/, /^(0[0-9]|1[0-2])/, /^([0-1][0-9]|2[0-3]|[0-9])/, /^([0-1][0-9]|2[0-3])/, /^([0-5][0-9]|[0-9])/, /^[0-5][0-9]/, /^([0-5][0-9]|[0-9])/, /^[0-5][0-9]/, /^[0-5][0-9]\.[0-9]{1,3}/, /^((\+|\-)\s*\d\d\d\d)|((\+|\-)\d\d\:?\d\d)/, /^((\+|\-)\s*\d\d\d\d)|((\+|\-)\d\d\:?\d\d)/ ], tokens = [ t.hour, t.hour, t.hour, t.hour, t.minute, t.minute, t.second, t.second, t.secondAndMillisecond, t.timezone, t.timezone ]; for (i=0; i < RTokenKeys.length; i++) { cacheProcessRtoken(RTokenKeys[i], RToken[i], tokens[i]); } g.hms = _.cache(_.sequence([g.H, g.m, g.s], g.timePartDelimiter)); g.t = cacheProcessCtoken("shortMeridian", t.meridian); g.tt = cacheProcessCtoken("longMeridian", t.meridian); g.zzz = cacheProcessCtoken("timezone", t.timezone); g.timeSuffix = _.each(_.ignore(g.whiteSpace), _.set([ g.tt, g.zzz ])); g.time = _.each(_.optional(_.ignore(_.stoken("T"))), g.hms, g.timeSuffix); }, dateFormats: function () { // pre-loaded rules for different date part order preferences var _setfn = function () { return _.set(arguments, g.datePartDelimiter); }; var i, RTokenKeys = [ "d", "dd", "M", "MM", "y", "yy", "yyy", "yyyy" ], RToken = [ /^([0-2]\d|3[0-1]|\d)/, /^([0-2]\d|3[0-1])/, /^(1[0-2]|0\d|\d)/, /^(1[0-2]|0\d)/, /^(\d+)/, /^(\d\d)/, /^(\d\d?\d?\d?)/, /^(\d\d\d\d)/ ], tokens = [ t.day, t.day, t.month, t.month, t.year, t.year, t.year, t.year ], eachToken = [ "ordinalSuffix", "ordinalSuffix" ]; for (i=0; i < RTokenKeys.length; i++) { cacheProcessRtoken(RTokenKeys[i], RToken[i], tokens[i], eachToken[i]); } g.MMM = g.MMMM = _.cache(_.process(g.ctoken("jan feb mar apr may jun jul aug sep oct nov dec"), t.month)); g.ddd = g.dddd = _.cache(_.process(g.ctoken("sun mon tue wed thu fri sat"), function (s) { return function () { this.weekday = s; }; } )); g.day = _fn(g.d, g.dd); g.month = _fn(g.M, g.MMM); g.year = _fn(g.yyyy, g.yy); g.mdy = _setfn(g.ddd, g.month, g.day, g.year); g.ymd = _setfn(g.ddd, g.year, g.month, g.day); g.dmy = _setfn(g.ddd, g.day, g.month, g.year); g.date = function (s) { return ((g[Date.CultureInfo.dateElementOrder] || g.mdy).call(this, s)); }; }, relative: function () { // relative date / time expressions g.orientation = _.process(g.ctoken("past future"), function (s) { return function () { this.orient = s; }; } ); g.operator = _.process(g.ctoken("add subtract"), function (s) { return function () { this.operator = s; }; } ); g.rday = _.process(g.ctoken("yesterday tomorrow today now"), t.rday); g.unit = _.process(g.ctoken("second minute hour day week month year"), function (s) { return function () { this.unit = s; }; } ); } }; g.buildGrammarFormats = function () { // these need to be rebuilt every time the language changes. _C = {}; grammarFormats.timeFormats(); grammarFormats.dateFormats(); grammarFormats.relative(); g.value = _.process(_.rtoken(/^([-+]?\d+)?(st|nd|rd|th)?/), function (s) { return function () { this.value = s.replace(/\D/g, ""); }; } ); g.expression = _.set([g.rday, g.operator, g.value, g.unit, g.orientation, g.ddd, g.MMM ]); g.format = _.process(_.many( _.any( // translate format specifiers into grammar rules _.process( _.rtoken(/^(dd?d?d?(?!e)|MM?M?M?|yy?y?y?|hh?|HH?|mm?|ss?|tt?|zz?z?)/), function (fmt) { if (g[fmt]) { return g[fmt]; } else { throw $D.Parsing.Exception(fmt); } } ), // translate separator tokens into token rules _.process(_.rtoken(/^[^dMyhHmstz]+/), // all legal separators function (s) { return _.ignore(_.stoken(s)); } ) ) ), // construct the parser ... function (rules) { return _.process(_.each.apply(null, rules), t.finishExact); } ); // starting rule for general purpose grammar g._start = _.process(_.set([ g.date, g.time, g.expression ], g.generalDelimiter, g.whiteSpace), t.finish); }; g.buildGrammarFormats(); // parsing date format specifiers - ex: "h:m:s tt" // this little guy will generate a custom parser based // on the format string, ex: g.format("h:m:s tt") // check for these formats first g._formats = g.formats([ "\"yyyy-MM-ddTHH:mm:ssZ\"", "yyyy-MM-ddTHH:mm:ss.sz", "yyyy-MM-ddTHH:mm:ssZ", "yyyy-MM-ddTHH:mm:ssz", "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-ddTHH:mmZ", "yyyy-MM-ddTHH:mmz", "yyyy-MM-ddTHH:mm", "ddd, MMM dd, yyyy H:mm:ss tt", "ddd MMM d yyyy HH:mm:ss zzz", "MMddyyyy", "ddMMyyyy", "Mddyyyy", "ddMyyyy", "Mdyyyy", "dMyyyy", "yyyy", "Mdyy", "dMyy", "d" ]); // real starting rule: tries selected formats first, // then general purpose rule g.start = function (s) { try { var r = g._formats.call({}, s); if (r[1].length === 0) { return r; } } catch (e) {} return g._start.call({}, s); }; }()); (function () { var $D = Date; /** * @desc Converts the specified string value into its JavaScript Date equivalent using CultureInfo specific format information. * * Example

	///////////
	// Dates //
	///////////

	// 15-Oct-2004
	var d1 = Date.parse("10/15/2004");

	// 15-Oct-2004
	var d1 = Date.parse("15-Oct-2004");

	// 15-Oct-2004
	var d1 = Date.parse("2004.10.15");

	//Fri Oct 15, 2004
	var d1 = Date.parse("Fri Oct 15, 2004");

	///////////
	// Times //
	///////////

	// Today at 10 PM.
	var d1 = Date.parse("10 PM");

	// Today at 10:30 PM.
	var d1 = Date.parse("10:30 P.M.");

	// Today at 6 AM.
	var d1 = Date.parse("06am");

	/////////////////////
	// Dates and Times //
	/////////////////////

	// 8-July-2004 @ 10:30 PM
	var d1 = Date.parse("July 8th, 2004, 10:30 PM");

	// 1-July-2004 @ 10:30 PM
	var d1 = Date.parse("2004-07-01T22:30:00");

	////////////////////
	// Relative Dates //
	////////////////////

	// Returns today's date. The string "today" is culture specific.
	var d1 = Date.parse("today");

	// Returns yesterday's date. The string "yesterday" is culture specific.
	var d1 = Date.parse("yesterday");

	// Returns the date of the next thursday.
	var d1 = Date.parse("Next thursday");

	// Returns the date of the most previous monday.
	var d1 = Date.parse("last monday");

	// Returns today's day + one year.
	var d1 = Date.parse("next year");

	///////////////
	// Date Math //
	///////////////

	// Today + 2 days
	var d1 = Date.parse("t+2");

	// Today + 2 days
	var d1 = Date.parse("today + 2 days");

	// Today + 3 months
	var d1 = Date.parse("t+3m");

	// Today - 1 year
	var d1 = Date.parse("today - 1 year");

	// Today - 1 year
	var d1 = Date.parse("t-1y"); 


	/////////////////////////////
	// Partial Dates and Times //
	/////////////////////////////

	// July 15th of this year.
	var d1 = Date.parse("July 15");

	// 15th day of current day and year.
	var d1 = Date.parse("15");

	// July 1st of current year at 10pm.
	var d1 = Date.parse("7/1 10pm");
	
* * @param {String} The string value to convert into a Date object [Required] * @return {Date} A Date object or null if the string cannot be converted into a Date. */ var parseUtils = { removeOrds: function (s) { ords = s.match(/\b(\d+)(?:st|nd|rd|th)\b/); // find ordinal matches s = ((ords && ords.length === 2) ? s.replace(ords[0], ords[1]) : s); return s; }, grammarParser: function (s) { var r = null; try { r = $D.Grammar.start.call({}, s.replace(/^\s*(\S*(\s+\S+)*)\s*$/, "$1")); } catch (e) { return null; } return ((r[1].length === 0) ? r[0] : null); }, nativeFallback: function(s) { var t; try { // ok we haven't parsed it, last ditch attempt with the built-in parser. t = Date._parse(s); return (t || t === 0) ? new Date(t) : null; } catch (e) { return null; } } }; function parse (s) { var d; if (!s) { return null; } if (s instanceof Date) { return s.clone(); } if (s.length >= 4 && s.charAt(0) !== "0" && s.charAt(0) !== "+"&& s.charAt(0) !== "-") { // ie: 2004 will pass, 0800 won't. // Start with specific formats d = $D.Parsing.ISO.parse(s) || $D.Parsing.Numeric.parse(s); } if (d instanceof Date && !isNaN(d.getTime())) { return d; } else { // find ordinal dates (1st, 3rd, 8th, etc and remove them as they cause parsing issues) s = $D.Parsing.Normalizer.parse(parseUtils.removeOrds(s)); d = parseUtils.grammarParser(s); if (d !== null) { return d; } else { return parseUtils.nativeFallback(s); } } } if (!$D._parse) { $D._parse = $D.parse; } $D.parse = parse; Date.getParseFunction = function (fx) { var fns = Date.Grammar.allformats(fx); return function (s) { var r = null; for (var i = 0; i < fns.length; i++) { try { r = fns[i].call({}, s); } catch (e) { continue; } if (r[1].length === 0) { return r[0]; } } return null; }; }; /** * Converts the specified string value into its JavaScript Date equivalent using the specified format {String} or formats {Array} and the CultureInfo specific format information. * The format of the string value must match one of the supplied formats exactly. * * Example

	// 15-Oct-2004
	var d1 = Date.parseExact("10/15/2004", "M/d/yyyy");

	// 15-Oct-2004
	var d1 = Date.parse("15-Oct-2004", "M-ddd-yyyy");

	// 15-Oct-2004
	var d1 = Date.parse("2004.10.15", "yyyy.MM.dd");

	// Multiple formats
	var d1 = Date.parseExact("10/15/2004", ["M/d/yyyy", "MMMM d, yyyy"]);
	
* * @param {String} The string value to convert into a Date object [Required]. * @param {Object} The expected format {String} or an array of expected formats {Array} of the date string [Required]. * @return {Date} A Date object or null if the string cannot be converted into a Date. */ $D.parseExact = function (s, fx) { return $D.getParseFunction(fx)(s); }; }()); (function () { var $D = Date, $P = $D.prototype, // $C = $D.CultureInfo, // not used atm p = function (s, l) { if (!l) { l = 2; } return ("000" + s).slice(l * -1); }; /** * Converts a PHP format string to Java/.NET format string. * A PHP format string can be used with ._format or .format. * A Java/.NET format string can be used with .toString(). * The .parseExact function will only accept a Java/.NET format string * * Example * var f1 = "%m/%d/%y" * var f2 = Date.normalizeFormat(f1); // "MM/dd/yy" * * new Date().format(f1); // "04/13/08" * new Date()._format(f1); // "04/13/08" * new Date().toString(f2); // "04/13/08" * * var date = Date.parseExact("04/13/08", f2); // Sun Apr 13 2008 * * @param {String} A PHP format string consisting of one or more format spcifiers. * @return {String} The PHP format converted to a Java/.NET format string. */ var normalizerSubstitutions = { "d" : "dd", "%d": "dd", "D" : "ddd", "%a": "ddd", "j" : "dddd", "l" : "dddd", "%A": "dddd", "S" : "S", "F" : "MMMM", "%B": "MMMM", "m" : "MM", "%m": "MM", "M" : "MMM", "%b": "MMM", "%h": "MMM", "n" : "M", "Y" : "yyyy", "%Y": "yyyy", "y" : "yy", "%y": "yy", "g" : "h", "%I": "h", "G" : "H", "h" : "hh", "H" : "HH", "%H": "HH", "i" : "mm", "%M": "mm", "s" : "ss", "%S": "ss", "%r": "hh:mm tt", "%R": "H:mm", "%T": "H:mm:ss", "%X": "t", "%x": "d", "%e": "d", "%D": "MM/dd/yy", "%n": "\\n", "%t": "\\t", "e" : "z", "T" : "z", "%z": "z", "%Z": "z", "Z" : "ZZ", "N" : "u", "w" : "u", "%w": "u", "W" : "W", "%V": "W" }; var normalizer = { substitutes: function (m) { return normalizerSubstitutions[m]; }, interpreted: function (m, x) { var y; switch (m) { case "%u": return x.getDay() + 1; case "z": return x.getOrdinalNumber(); case "%j": return p(x.getOrdinalNumber(), 3); case "%U": var d1 = x.clone().set({month: 0, day: 1}).addDays(-1).moveToDayOfWeek(0), d2 = x.clone().addDays(1).moveToDayOfWeek(0, -1); return (d2 < d1) ? "00" : p((d2.getOrdinalNumber() - d1.getOrdinalNumber()) / 7 + 1); case "%W": return p(x.getWeek()); case "t": return $D.getDaysInMonth(x.getFullYear(), x.getMonth()); case "o": case "%G": return x.setWeek(x.getISOWeek()).toString("yyyy"); case "%g": return x._format("%G").slice(-2); case "a": case "%p": return t("tt").toLowerCase(); case "A": return t("tt").toUpperCase(); case "u": return p(x.getMilliseconds(), 3); case "I": return (x.isDaylightSavingTime()) ? 1 : 0; case "O": return x.getUTCOffset(); case "P": y = x.getUTCOffset(); return y.substring(0, y.length - 2) + ":" + y.substring(y.length - 2); case "B": var now = new Date(); return Math.floor(((now.getHours() * 3600) + (now.getMinutes() * 60) + now.getSeconds() + (now.getTimezoneOffset() + 60) * 60) / 86.4); case "c": return x.toISOString().replace(/\"/g, ""); case "U": return $D.strtotime("now"); case "%c": return t("d") + " " + t("t"); case "%C": return Math.floor(x.getFullYear() / 100 + 1); } }, shouldOverrideDefaults: function (m) { switch (m) { case "%e": return true; default: return false; } }, parse: function (m, context) { var formatString, c = context || new Date(); formatString = normalizer.substitutes(m); if (formatString) { return formatString; } formatString = normalizer.interpreted(m, c); if (formatString) { return formatString; } else { return m; } } }; $D.normalizeFormat = function (format, context) { return format.replace(/(%|\\)?.|%%/g, function(t){ return normalizer.parse(t, context); }); }; /** * Format a local Unix timestamp according to locale settings * * Example: * Date.strftime("%m/%d/%y", new Date()); // "04/13/08" * Date.strftime("c", "2008-04-13T17:52:03Z"); // "04/13/08" * * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @param {Number|String} The number representing the number of seconds that have elapsed since January 1, 1970 (local time). * @return {String} A string representation of the current Date object. */ $D.strftime = function (format, time) { var d = Date.parse(time); return d._format(format); }; /** * Parse any textual datetime description into a Unix timestamp. * A Unix timestamp is the number of seconds that have elapsed since January 1, 1970 (midnight UTC/GMT). * * Example: * Date.strtotime("04/13/08"); // 1208044800 * Date.strtotime("1970-01-01T00:00:00Z"); // 0 * * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @param {Object} A string or date object. * @return {String} A string representation of the current Date object. */ $D.strtotime = function (time) { var d = $D.parse(time); return Math.round($D.UTC(d.getUTCFullYear(), d.getUTCMonth(), d.getUTCDate(), d.getUTCHours(), d.getUTCMinutes(), d.getUTCSeconds(), d.getUTCMilliseconds()) / 1000); }; /** * Converts the value of the current Date object to its equivalent string representation using a PHP/Unix style of date format specifiers. * Format Specifiers * Format Description Example * ------ --------------------------------------------------------------------------- ----------------------- * %a abbreviated weekday name according to the current localed "Mon" through "Sun" * %A full weekday name according to the current localed "Sunday" through "Saturday" * %b abbreviated month name according to the current localed "Jan" through "Dec" * %B full month name according to the current locale "January" through "December" * %c preferred date and time representation for the current locale "4/13/2008 12:33 PM" * %C century number (the year divided by 100 and truncated to an integer) "00" to "99" * %d day of the month as a decimal number "01" to "31" * %D same as %m/%d/%y "04/13/08" * %e day of the month as a decimal number, a single digit is preceded by a space "1" to "31" * %g like %G, but without the century "08" * %G The 4-digit year corresponding to the ISO week number (see %V). "2008" * This has the same format and value as %Y, except that if the ISO week number * belongs to the previous or next year, that year is used instead. * %h same as %b "Jan" through "Dec" * %H hour as a decimal number using a 24-hour clock. "00" to "23" * %I hour as a decimal number using a 12-hour clock. "01" to "12" * %j day of the year as a decimal number. "001" to "366" * %m month as a decimal number. "01" to "12" * %M minute as a decimal number. "00" to "59" * %n newline character "\n" * %p either "am" or "pm" according to the given time value, or the "am" or "pm" * corresponding strings for the current locale. * %r time in a.m. and p.m. notation "8:44 PM" * %R time in 24 hour notation "20:44" * %S second as a decimal number "00" to "59" * %t tab character "\t" * %T current time, equal to %H:%M:%S "12:49:11" * %u weekday as a decimal number ["1", "7"], with "1" representing Monday "1" to "7" * %U week number of the current year as a decimal number, starting with the "0" to ("52" or "53") * first Sunday as the first day of the first week * %V The ISO 8601:1988 week number of the current year as a decimal number, "00" to ("52" or "53") * range 01 to 53, where week 1 is the first week that has at least 4 days * in the current year, and with Monday as the first day of the week. * (Use %G or %g for the year component that corresponds to the week number * for the specified timestamp.) * %W week number of the current year as a decimal number, starting with the "00" to ("52" or "53") * first Monday as the first day of the first week * %w day of the week as a decimal, Sunday being "0" "0" to "6" * %x preferred date representation for the current locale without the time "4/13/2008" * %X preferred time representation for the current locale without the date "12:53:05" * %y year as a decimal number without a century "00" "99" * %Y year as a decimal number including the century "2008" * %Z time zone or name or abbreviation "UTC", "EST", "PST" * %z same as %Z * %% a literal "%" characters "%" * d Day of the month, 2 digits with leading zeros "01" to "31" * D A textual representation of a day, three letters "Mon" through "Sun" * j Day of the month without leading zeros "1" to "31" * l A full textual representation of the day of the week (lowercase "L") "Sunday" through "Saturday" * N ISO-8601 numeric representation of the day of the week (added in PHP 5.1.0) "1" (for Monday) through "7" (for Sunday) * S English ordinal suffix for the day of the month, 2 characters "st", "nd", "rd" or "th". Works well with j * w Numeric representation of the day of the week "0" (for Sunday) through "6" (for Saturday) * z The day of the year (starting from "0") "0" through "365" * W ISO-8601 week number of year, weeks starting on Monday "00" to ("52" or "53") * F A full textual representation of a month, such as January or March "January" through "December" * m Numeric representation of a month, with leading zeros "01" through "12" * M A short textual representation of a month, three letters "Jan" through "Dec" * n Numeric representation of a month, without leading zeros "1" through "12" * t Number of days in the given month "28" through "31" * L Whether it's a leap year "1" if it is a leap year, "0" otherwise * o ISO-8601 year number. This has the same value as Y, except that if the "2008" * ISO week number (W) belongs to the previous or next year, that year * is used instead. * Y A full numeric representation of a year, 4 digits "2008" * y A two digit representation of a year "08" * a Lowercase Ante meridiem and Post meridiem "am" or "pm" * A Uppercase Ante meridiem and Post meridiem "AM" or "PM" * B Swatch Internet time "000" through "999" * g 12-hour format of an hour without leading zeros "1" through "12" * G 24-hour format of an hour without leading zeros "0" through "23" * h 12-hour format of an hour with leading zeros "01" through "12" * H 24-hour format of an hour with leading zeros "00" through "23" * i Minutes with leading zeros "00" to "59" * s Seconds, with leading zeros "00" through "59" * u Milliseconds "54321" * e Timezone identifier "UTC", "EST", "PST" * I Whether or not the date is in daylight saving time (uppercase i) "1" if Daylight Saving Time, "0" otherwise * O Difference to Greenwich time (GMT) in hours "+0200", "-0600" * P Difference to Greenwich time (GMT) with colon between hours and minutes "+02:00", "-06:00" * T Timezone abbreviation "UTC", "EST", "PST" * Z Timezone offset in seconds. The offset for timezones west of UTC is "-43200" through "50400" * always negative, and for those east of UTC is always positive. * c ISO 8601 date "2004-02-12T15:19:21+00:00" * r RFC 2822 formatted date "Thu, 21 Dec 2000 16:01:07 +0200" * U Seconds since the Unix Epoch (January 1 1970 00:00:00 GMT) "0" * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @return {String} A string representation of the current Date object. */ var formatReplace = function (context) { return function (m) { var formatString, override = false; if (m.charAt(0) === "\\" || m.substring(0, 2) === "%%") { return m.replace("\\", "").replace("%%", "%"); } override = normalizer.shouldOverrideDefaults(m); formatString = $D.normalizeFormat(m, context); if (formatString) { return context.toString(formatString, override); } }; }; $P._format = function (format) { var formatter = formatReplace(this); if (!format) { return this._toString(); } else { return format.replace(/(%|\\)?.|%%/g, formatter); } }; if (!$P.format) { $P.format = $P._format; } }()); (function () { "use strict"; var gFn = function (attr) { return function () { return this[attr]; }; }; var sFn = function (attr) { return function (val) { this[attr] = val; return this; }; }; var attrs = ["years", "months", "days", "hours", "minutes", "seconds", "milliseconds"]; var addSetFuncs = function (context, attrs) { for (var i = 0; i < attrs.length ; i++) { var $a = attrs[i], $b = $a.slice(0, 1).toUpperCase() + $a.slice(1); context.prototype[$a] = 0; context.prototype["get" + $b] = gFn($a); context.prototype["set" + $b] = sFn($a); } }; /** * new TimeSpan(milliseconds); * new TimeSpan(days, hours, minutes, seconds); * new TimeSpan(days, hours, minutes, seconds, milliseconds); */ var TimeSpan = function (days, hours, minutes, seconds, milliseconds) { if (arguments.length === 1 && typeof days === "number") { var orient = (days < 0) ? -1 : +1; var millsLeft = Math.abs(days); this.setDays(Math.floor(millsLeft / 86400000) * orient); millsLeft = millsLeft % 86400000; this.setHours(Math.floor(millsLeft / 3600000) * orient); millsLeft = millsLeft % 3600000; this.setMinutes(Math.floor(millsLeft / 60000) * orient); millsLeft = millsLeft % 60000; this.setSeconds(Math.floor(millsLeft / 1000) * orient); millsLeft = millsLeft % 1000; this.setMilliseconds(millsLeft * orient); } else { this.set(days, hours, minutes, seconds, milliseconds); } this.getTotalMilliseconds = function () { return (this.getDays() * 86400000) + (this.getHours() * 3600000) + (this.getMinutes() * 60000) + (this.getSeconds() * 1000); }; this.compareTo = function (time) { var t1 = new Date(1970, 1, 1, this.getHours(), this.getMinutes(), this.getSeconds()), t2; if (time === null) { t2 = new Date(1970, 1, 1, 0, 0, 0); } else { t2 = new Date(1970, 1, 1, time.getHours(), time.getMinutes(), time.getSeconds()); } return (t1 < t2) ? -1 : (t1 > t2) ? 1 : 0; }; this.equals = function (time) { return (this.compareTo(time) === 0); }; this.add = function (time) { return (time === null) ? this : this.addSeconds(time.getTotalMilliseconds() / 1000); }; this.subtract = function (time) { return (time === null) ? this : this.addSeconds(-time.getTotalMilliseconds() / 1000); }; this.addDays = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 86400000)); }; this.addHours = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 3600000)); }; this.addMinutes = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 60000)); }; this.addSeconds = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 1000)); }; this.addMilliseconds = function (n) { return new TimeSpan(this.getTotalMilliseconds() + n); }; this.get12HourHour = function () { return (this.getHours() > 12) ? this.getHours() - 12 : (this.getHours() === 0) ? 12 : this.getHours(); }; this.getDesignator = function () { return (this.getHours() < 12) ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator; }; this.toString = function (format) { this._toString = function () { if (this.getDays() !== null && this.getDays() > 0) { return this.getDays() + "." + this.getHours() + ":" + this.p(this.getMinutes()) + ":" + this.p(this.getSeconds()); } else { return this.getHours() + ":" + this.p(this.getMinutes()) + ":" + this.p(this.getSeconds()); } }; this.p = function (s) { return (s.toString().length < 2) ? "0" + s : s; }; var me = this; return format ? format.replace(/dd?|HH?|hh?|mm?|ss?|tt?/g, function (format) { switch (format) { case "d": return me.getDays(); case "dd": return me.p(me.getDays()); case "H": return me.getHours(); case "HH": return me.p(me.getHours()); case "h": return me.get12HourHour(); case "hh": return me.p(me.get12HourHour()); case "m": return me.getMinutes(); case "mm": return me.p(me.getMinutes()); case "s": return me.getSeconds(); case "ss": return me.p(me.getSeconds()); case "t": return ((me.getHours() < 12) ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator).substring(0, 1); case "tt": return (me.getHours() < 12) ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator; } } ) : this._toString(); }; return this; }; addSetFuncs(TimeSpan, attrs.slice(2)); TimeSpan.prototype.set = function (days, hours, minutes, seconds, milliseconds){ this.setDays(days || this.getDays()); this.setHours(hours || this.getHours()); this.setMinutes(minutes || this.getMinutes()); this.setSeconds(seconds || this.getSeconds()); this.setMilliseconds(milliseconds || this.getMilliseconds()); }; /** * Gets the time of day for this date instances. * @return {TimeSpan} TimeSpan */ Date.prototype.getTimeOfDay = function () { return new TimeSpan(0, this.getHours(), this.getMinutes(), this.getSeconds(), this.getMilliseconds()); }; Date.TimeSpan = TimeSpan; if (typeof window !== "undefined" ) { // keeping API compatible for v1.x window.TimeSpan = TimeSpan; } }()); (function () { "use strict"; var attrs = ["years", "months", "days", "hours", "minutes", "seconds", "milliseconds"]; var gFn = function (attr) { return function () { return this[attr]; }; }; var sFn = function (attr) { return function (val) { this[attr] = val; return this; }; }; var addSetFuncs = function (context, attrs) { for (var i = 0; i < attrs.length ; i++) { var $a = attrs[i], $b = $a.slice(0, 1).toUpperCase() + $a.slice(1); context.prototype[$a] = 0; context.prototype["get" + $b] = gFn($a); context.prototype["set" + $b] = sFn($a); } }; var setMonthsAndYears = function (orient, d1, d2, context) { function inc() { d1.addMonths(-orient); context.months++; if (context.months === 12) { context.years++; context.months = 0; } } if (orient === +1) { while (d1 > d2) { inc(); } } else { while (d1 < d2) { inc(); } } context.months--; context.months *= orient; context.years *= orient; }; var adjustForDST = function(orient, startDate, endDate) { var hasDSTMismatch = (false === (startDate.isDaylightSavingTime() === endDate.isDaylightSavingTime())); if (hasDSTMismatch && orient === 1) { startDate.addHours(-1); } else if (hasDSTMismatch) { startDate.addHours(1); } }; /** * TimePeriod(startDate, endDate); * TimePeriod(years, months, days, hours, minutes, seconds, milliseconds); */ var TimePeriod = function (years, months, days, hours, minutes, seconds, milliseconds) { if (arguments.length === 7) { this.set(years, months, days, hours, minutes, seconds, milliseconds); } else if (arguments.length === 2 && arguments[0] instanceof Date && arguments[1] instanceof Date) { var startDate = arguments[0].clone(); var endDate = arguments[1].clone(); var orient = (startDate > endDate) ? +1 : -1; this.dates = { start: arguments[0].clone(), end: arguments[1].clone() }; setMonthsAndYears(orient, startDate, endDate, this); adjustForDST(orient, startDate, endDate); // // TODO - adjust for DST var diff = endDate - startDate; if (diff !== 0) { var ts = new TimeSpan(diff); this.set(this.years, this.months, ts.getDays(), ts.getHours(), ts.getMinutes(), ts.getSeconds(), ts.getMilliseconds()); } } return this; }; // create all the set functions. addSetFuncs(TimePeriod, attrs); TimePeriod.prototype.set = function (years, months, days, hours, minutes, seconds, milliseconds){ this.setYears(years || this.getYears()); this.setMonths(months || this.getMonths()); this.setDays(days || this.getDays()); this.setHours(hours || this.getHours()); this.setMinutes(minutes || this.getMinutes()); this.setSeconds(seconds || this.getSeconds()); this.setMilliseconds(milliseconds || this.getMilliseconds()); }; Date.TimePeriod = TimePeriod; if (typeof window !== "undefined") { // keeping API compatible for v1.x window.TimePeriod = TimePeriod; } }()); ================================================ FILE: build/date-ns-ZA.js ================================================ /** * @overview datejs * @version 1.0.0-rc3 * @author Gregory Wild-Smith * @copyright 2015 Gregory Wild-Smith * @license MIT * @homepage https://github.com/abritinthebay/datejs */ /* * DateJS Culture String File * Country Code: ns-ZA * Name: Northern Sotho (South Africa) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["ns-ZA"] = { "name": "ns-ZA", "englishName": "Northern Sotho (South Africa)", "nativeName": "Sesotho sa Leboa (Afrika Borwa)", "Sunday": "Lamorena", "Monday": "Mošupologo", "Tuesday": "Labobedi", "Wednesday": "Laboraro", "Thursday": "Labone", "Friday": "Labohlano", "Saturday": "Mokibelo", "Sun": "Sun", "Mon": "Mon", "Tue": "Tue", "Wed": "Wed", "Thu": "Thu", "Fri": "Fri", "Sat": "Sat", "Su": "Sun", "Mo": "Mon", "Tu": "Tue", "We": "Wed", "Th": "Thu", "Fr": "Fri", "Sa": "Sat", "S_Sun_Initial": "S", "M_Mon_Initial": "M", "T_Tue_Initial": "T", "W_Wed_Initial": "W", "T_Thu_Initial": "T", "F_Fri_Initial": "F", "S_Sat_Initial": "S", "January": "Pherekgong", "February": "Hlakola", "March": "Mopitlo", "April": "Moranang", "May": "Mosegamanye", "June": "Ngoatobošego", "July": "Phuphu", "August": "Phato", "September": "Lewedi", "October": "Diphalana", "November": "Dibatsela", "December": "Manthole", "Jan_Abbr": "Jan", "Feb_Abbr": "Feb", "Mar_Abbr": "Mar", "Apr_Abbr": "Apr", "May_Abbr": "May", "Jun_Abbr": "Jun", "Jul_Abbr": "Jul", "Aug_Abbr": "Aug", "Sep_Abbr": "Sep", "Oct_Abbr": "Oct", "Nov_Abbr": "Nov", "Dec_Abbr": "Dec", "AM": "AM", "PM": "PM", "firstDayOfWeek": 0, "twoDigitYearMax": 2029, "mdy": "ymd", "M/d/yyyy": "yyyy/MM/dd", "dddd, MMMM dd, yyyy": "dd MMMM yyyy", "h:mm tt": "hh:mm:ss tt", "h:mm:ss tt": "hh:mm:ss tt", "dddd, MMMM dd, yyyy h:mm:ss tt": "dd MMMM yyyy hh:mm:ss tt", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "MMMM dd", "MMMM, yyyy": "MMMM yyyy", "/jan(uary)?/": "pherekgong", "/feb(ruary)?/": "hlakola", "/mar(ch)?/": "mopitlo", "/apr(il)?/": "moranang", "/may/": "mosegamanye", "/jun(e)?/": "ngoatobošego", "/jul(y)?/": "phuphu", "/aug(ust)?/": "phato", "/sep(t(ember)?)?/": "lewedi", "/oct(ober)?/": "diphalana", "/nov(ember)?/": "dibatsela", "/dec(ember)?/": "manthole", "/^su(n(day)?)?/": "^lamorena", "/^mo(n(day)?)?/": "^mošupologo", "/^tu(e(s(day)?)?)?/": "^labobedi", "/^we(d(nesday)?)?/": "^laboraro", "/^th(u(r(s(day)?)?)?)?/": "^labone", "/^fr(i(day)?)?/": "^labohlano", "/^sa(t(urday)?)?/": "^mokibelo", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "ns-ZA"; /** * @overview datejs * @version 1.0.0-rc3 * @author Gregory Wild-Smith * @copyright 2015 Gregory Wild-Smith * @license MIT * @homepage https://github.com/abritinthebay/datejs */(function () { var $D = Date; var lang = Date.CultureStrings ? Date.CultureStrings.lang : null; var loggedKeys = {}; // for debug purposes. var getText = { getFromKey: function (key, countryCode) { var output; if (Date.CultureStrings && Date.CultureStrings[countryCode] && Date.CultureStrings[countryCode][key]) { output = Date.CultureStrings[countryCode][key]; } else { output = getText.buildFromDefault(key); } if (key.charAt(0) === "/") { // Assume it's a regex output = getText.buildFromRegex(key, countryCode); } return output; }, getFromObjectValues: function (obj, countryCode) { var key, output = {}; for(key in obj) { if (obj.hasOwnProperty(key)) { output[key] = getText.getFromKey(obj[key], countryCode); } } return output; }, getFromObjectKeys: function (obj, countryCode) { var key, output = {}; for(key in obj) { if (obj.hasOwnProperty(key)) { output[getText.getFromKey(key, countryCode)] = obj[key]; } } return output; }, getFromArray: function (arr, countryCode) { var output = []; for (var i=0; i < arr.length; i++){ if (i in arr) { output[i] = getText.getFromKey(arr[i], countryCode); } } return output; }, buildFromDefault: function (key) { var output, length, split, last; switch(key) { case "name": output = "en-US"; break; case "englishName": output = "English (United States)"; break; case "nativeName": output = "English (United States)"; break; case "twoDigitYearMax": output = 2049; break; case "firstDayOfWeek": output = 0; break; default: output = key; split = key.split("_"); length = split.length; if (length > 1 && key.charAt(0) !== "/") { // if the key isn't a regex and it has a split. last = split[(length - 1)].toLowerCase(); if (last === "initial" || last === "abbr") { output = split[0]; } } break; } return output; }, buildFromRegex: function (key, countryCode) { var output; if (Date.CultureStrings && Date.CultureStrings[countryCode] && Date.CultureStrings[countryCode][key]) { output = new RegExp(Date.CultureStrings[countryCode][key], "i"); } else { output = new RegExp(key.replace(new RegExp("/", "g"),""), "i"); } return output; } }; var shallowMerge = function (obj1, obj2) { for (var attrname in obj2) { if (obj2.hasOwnProperty(attrname)) { obj1[attrname] = obj2[attrname]; } } }; var __ = function (key, language) { var countryCode = (language) ? language : lang; loggedKeys[key] = key; if (typeof key === "object") { if (key instanceof Array) { return getText.getFromArray(key, countryCode); } else { return getText.getFromObjectKeys(key, countryCode); } } else { return getText.getFromKey(key, countryCode); } }; var loadI18nScript = function (code) { // paatterned after jQuery's getScript. var url = Date.Config.i18n + code + ".js"; var head = document.getElementsByTagName("head")[0] || document.documentElement; var script = document.createElement("script"); script.src = url; var completed = false; var events = { done: function (){} // placeholder function }; // Attach handlers for all browsers script.onload = script.onreadystatechange = function() { if ( !completed && (!this.readyState || this.readyState === "loaded" || this.readyState === "complete") ) { events.done(); head.removeChild(script); } }; setTimeout(function() { head.insertBefore(script, head.firstChild); }, 0); // allows return to execute first return { done: function (cb) { events.done = function() { if (cb) { setTimeout(cb,0); } }; } }; }; var buildInfo = { buildFromMethodHash: function (obj) { var key; for(key in obj) { if (obj.hasOwnProperty(key)) { obj[key] = buildInfo[obj[key]](); } } return obj; }, timeZoneDST: function () { var DST = { "CHADT": "+1345", "NZDT": "+1300", "AEDT": "+1100", "ACDT": "+1030", "AZST": "+0500", "IRDT": "+0430", "EEST": "+0300", "CEST": "+0200", "BST": "+0100", "PMDT": "-0200", "ADT": "-0300", "NDT": "-0230", "EDT": "-0400", "CDT": "-0500", "MDT": "-0600", "PDT": "-0700", "AKDT": "-0800", "HADT": "-0900" }; return __(DST); }, timeZoneStandard: function () { var standard = { "LINT": "+1400", "TOT": "+1300", "CHAST": "+1245", "NZST": "+1200", "NFT": "+1130", "SBT": "+1100", "AEST": "+1000", "ACST": "+0930", "JST": "+0900", "CWST": "+0845", "CT": "+0800", "ICT": "+0700", "MMT": "+0630", "BST": "+0600", "NPT": "+0545", "IST": "+0530", "PKT": "+0500", "AFT": "+0430", "MSK": "+0400", "IRST": "+0330", "FET": "+0300", "EET": "+0200", "CET": "+0100", "GMT": "+0000", "UTC": "+0000", "CVT": "-0100", "GST": "-0200", "BRT": "-0300", "NST": "-0330", "AST": "-0400", "EST": "-0500", "CST": "-0600", "MST": "-0700", "PST": "-0800", "AKST": "-0900", "MIT": "-0930", "HST": "-1000", "SST": "-1100", "BIT": "-1200" }; return __(standard); }, timeZones: function (data) { var zone; data.timezones = []; for (zone in data.abbreviatedTimeZoneStandard) { if (data.abbreviatedTimeZoneStandard.hasOwnProperty(zone)) { data.timezones.push({ name: zone, offset: data.abbreviatedTimeZoneStandard[zone]}); } } for (zone in data.abbreviatedTimeZoneDST) { if (data.abbreviatedTimeZoneDST.hasOwnProperty(zone)) { data.timezones.push({ name: zone, offset: data.abbreviatedTimeZoneDST[zone], dst: true}); } } return data.timezones; }, days: function () { return __(["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"]); }, dayAbbr: function () { return __(["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"]); }, dayShortNames: function () { return __(["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"]); }, dayFirstLetters: function () { return __(["S_Sun_Initial", "M_Mon_Initial", "T_Tues_Initial", "W_Wed_Initial", "T_Thu_Initial", "F_Fri_Initial", "S_Sat_Initial"]); }, months: function () { return __(["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"]); }, monthAbbr: function () { return __(["Jan_Abbr", "Feb_Abbr", "Mar_Abbr", "Apr_Abbr", "May_Abbr", "Jun_Abbr", "Jul_Abbr", "Aug_Abbr", "Sep_Abbr", "Oct_Abbr", "Nov_Abbr", "Dec_Abbr"]); }, formatPatterns: function () { return getText.getFromObjectValues({ shortDate: "M/d/yyyy", longDate: "dddd, MMMM dd, yyyy", shortTime: "h:mm tt", longTime: "h:mm:ss tt", fullDateTime: "dddd, MMMM dd, yyyy h:mm:ss tt", sortableDateTime: "yyyy-MM-ddTHH:mm:ss", universalSortableDateTime: "yyyy-MM-dd HH:mm:ssZ", rfc1123: "ddd, dd MMM yyyy HH:mm:ss", monthDay: "MMMM dd", yearMonth: "MMMM, yyyy" }, Date.i18n.currentLanguage()); }, regex: function () { return getText.getFromObjectValues({ inTheMorning: "/( in the )(morn(ing)?)\\b/", thisMorning: "/(this )(morn(ing)?)\\b/", amThisMorning: "/(\b\\d(am)? )(this )(morn(ing)?)/", inTheEvening: "/( in the )(even(ing)?)\\b/", thisEvening: "/(this )(even(ing)?)\\b/", pmThisEvening: "/(\b\\d(pm)? )(this )(even(ing)?)/", jan: "/jan(uary)?/", feb: "/feb(ruary)?/", mar: "/mar(ch)?/", apr: "/apr(il)?/", may: "/may/", jun: "/jun(e)?/", jul: "/jul(y)?/", aug: "/aug(ust)?/", sep: "/sep(t(ember)?)?/", oct: "/oct(ober)?/", nov: "/nov(ember)?/", dec: "/dec(ember)?/", sun: "/^su(n(day)?)?/", mon: "/^mo(n(day)?)?/", tue: "/^tu(e(s(day)?)?)?/", wed: "/^we(d(nesday)?)?/", thu: "/^th(u(r(s(day)?)?)?)?/", fri: "/fr(i(day)?)?/", sat: "/^sa(t(urday)?)?/", future: "/^next/", past: "/^last|past|prev(ious)?/", add: "/^(\\+|aft(er)?|from|hence)/", subtract: "/^(\\-|bef(ore)?|ago)/", yesterday: "/^yes(terday)?/", today: "/^t(od(ay)?)?/", tomorrow: "/^tom(orrow)?/", now: "/^n(ow)?/", millisecond: "/^ms|milli(second)?s?/", second: "/^sec(ond)?s?/", minute: "/^mn|min(ute)?s?/", hour: "/^h(our)?s?/", week: "/^w(eek)?s?/", month: "/^m(onth)?s?/", day: "/^d(ay)?s?/", year: "/^y(ear)?s?/", shortMeridian: "/^(a|p)/", longMeridian: "/^(a\\.?m?\\.?|p\\.?m?\\.?)/", timezone: "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/", ordinalSuffix: "/^\\s*(st|nd|rd|th)/", timeContext: "/^\\s*(\\:|a(?!u|p)|p)/" }, Date.i18n.currentLanguage()); } }; var CultureInfo = function () { var info = getText.getFromObjectValues({ name: "name", englishName: "englishName", nativeName: "nativeName", amDesignator: "AM", pmDesignator: "PM", firstDayOfWeek: "firstDayOfWeek", twoDigitYearMax: "twoDigitYearMax", dateElementOrder: "mdy" }, Date.i18n.currentLanguage()); var constructedInfo = buildInfo.buildFromMethodHash({ dayNames: "days", abbreviatedDayNames: "dayAbbr", shortestDayNames: "dayShortNames", firstLetterDayNames: "dayFirstLetters", monthNames: "months", abbreviatedMonthNames: "monthAbbr", formatPatterns: "formatPatterns", regexPatterns: "regex", abbreviatedTimeZoneDST: "timeZoneDST", abbreviatedTimeZoneStandard: "timeZoneStandard" }); shallowMerge(info, constructedInfo); buildInfo.timeZones(info); return info; }; $D.i18n = { __: function (key, lang) { return __(key, lang); }, currentLanguage: function () { return lang || "en-US"; }, setLanguage: function (code, force, cb) { var async = false; if (force || code === "en-US" || (!!Date.CultureStrings && !!Date.CultureStrings[code])) { lang = code; Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings.lang = code; Date.CultureInfo = new CultureInfo(); } else { if (!(!!Date.CultureStrings && !!Date.CultureStrings[code])) { if (typeof exports !== "undefined" && this.exports !== exports) { // we're in a Node enviroment, load it using require try { require("../i18n/" + code + ".js"); lang = code; Date.CultureStrings.lang = code; Date.CultureInfo = new CultureInfo(); } catch (e) { // var str = "The language for '" + code + "' could not be loaded by Node. It likely does not exist."; throw new Error("The DateJS IETF language tag '" + code + "' could not be loaded by Node. It likely does not exist."); } } else if (Date.Config && Date.Config.i18n) { // we know the location of the files, so lets load them async = true; loadI18nScript(code).done(function(){ lang = code; Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings.lang = code; Date.CultureInfo = new CultureInfo(); $D.Parsing.Normalizer.buildReplaceData(); // because this is async if ($D.Grammar) { $D.Grammar.buildGrammarFormats(); // so we can parse those strings... } if (cb) { setTimeout(cb,0); } }); } else { Date.console.error("The DateJS IETF language tag '" + code + "' is not available and has not been loaded."); return false; } } } $D.Parsing.Normalizer.buildReplaceData(); // rebuild normalizer strings if ($D.Grammar) { $D.Grammar.buildGrammarFormats(); // so we can parse those strings... } if (!async && cb) { setTimeout(cb,0); } }, getLoggedKeys: function () { return loggedKeys; }, updateCultureInfo: function () { Date.CultureInfo = new CultureInfo(); } }; $D.i18n.updateCultureInfo(); // run automatically }()); (function () { var $D = Date, $P = $D.prototype, p = function (s, l) { if (!l) { l = 2; } return ("000" + s).slice(l * -1); }; if (typeof window !== "undefined" && typeof window.console !== "undefined" && typeof window.console.log !== "undefined") { $D.console = console; // used only to raise non-critical errors if available } else { // set mock so we don't give errors. $D.console = { log: function(){}, error: function(){} }; } $D.Config = $D.Config || {}; $D.initOverloads = function() { /** * Overload of Date.now. Allows an alternate call for Date.now where it returns the * current Date as an object rather than just milliseconds since the Unix Epoch. * * Also provides an implementation of now() for browsers (IE<9) that don't have it. * * Backwards compatible so with work with either: * Date.now() [returns ms] * or * Date.now(true) [returns Date] */ if (!$D.now) { $D._now = function now() { return new Date().getTime(); }; } else if (!$D._now) { $D._now = $D.now; } $D.now = function (returnObj) { if (returnObj) { return $D.present(); } else { return $D._now(); } }; if ( !$P.toISOString ) { $P.toISOString = function() { return this.getUTCFullYear() + "-" + p(this.getUTCMonth() + 1) + "-" + p(this.getUTCDate()) + "T" + p(this.getUTCHours()) + ":" + p(this.getUTCMinutes()) + ":" + p(this.getUTCSeconds()) + "." + String( (this.getUTCMilliseconds()/1000).toFixed(3)).slice(2, 5) + "Z"; }; } // private if ( $P._toString === undefined ){ $P._toString = $P.toString; } }; $D.initOverloads(); /** * Gets a date that is set to the current date. The time is set to the start of the day (00:00 or 12:00 AM). * @return {Date} The current date. */ $D.today = function () { return new Date().clearTime(); }; /** * Gets a date that is set to the current date and time (same as new Date, but chainable) * @return {Date} The current date. */ $D.present = function () { return new Date(); }; /** * Compares the first date to the second date and returns an number indication of their relative values. * @param {Date} First Date object to compare [Required]. * @param {Date} Second Date object to compare to [Required]. * @return {Number} -1 = date1 is lessthan date2. 0 = values are equal. 1 = date1 is greaterthan date2. */ $D.compare = function (date1, date2) { if (isNaN(date1) || isNaN(date2)) { throw new Error(date1 + " - " + date2); } else if (date1 instanceof Date && date2 instanceof Date) { return (date1 < date2) ? -1 : (date1 > date2) ? 1 : 0; } else { throw new TypeError(date1 + " - " + date2); } }; /** * Compares the first Date object to the second Date object and returns true if they are equal. * @param {Date} First Date object to compare [Required] * @param {Date} Second Date object to compare to [Required] * @return {Boolean} true if dates are equal. false if they are not equal. */ $D.equals = function (date1, date2) { return (date1.compareTo(date2) === 0); }; /** * Gets the language appropriate day name when given the day number(0-6) * eg - 0 == Sunday * @return {String} The day name */ $D.getDayName = function (n) { return Date.CultureInfo.dayNames[n]; }; /** * Gets the day number (0-6) if given a CultureInfo specific string which is a valid dayName, abbreviatedDayName or shortestDayName (two char). * @param {String} The name of the day (eg. "Monday, "Mon", "tuesday", "tue", "We", "we"). * @return {Number} The day number */ $D.getDayNumberFromName = function (name) { var n = Date.CultureInfo.dayNames, m = Date.CultureInfo.abbreviatedDayNames, o = Date.CultureInfo.shortestDayNames, s = name.toLowerCase(); for (var i = 0; i < n.length; i++) { if (n[i].toLowerCase() === s || m[i].toLowerCase() === s || o[i].toLowerCase() === s) { return i; } } return -1; }; /** * Gets the month number (0-11) if given a Culture Info specific string which is a valid monthName or abbreviatedMonthName. * @param {String} The name of the month (eg. "February, "Feb", "october", "oct"). * @return {Number} The day number */ $D.getMonthNumberFromName = function (name) { var n = Date.CultureInfo.monthNames, m = Date.CultureInfo.abbreviatedMonthNames, s = name.toLowerCase(); for (var i = 0; i < n.length; i++) { if (n[i].toLowerCase() === s || m[i].toLowerCase() === s) { return i; } } return -1; }; /** * Gets the language appropriate month name when given the month number(0-11) * eg - 0 == January * @return {String} The month name */ $D.getMonthName = function (n) { return Date.CultureInfo.monthNames[n]; }; /** * Determines if the current date instance is within a LeapYear. * @param {Number} The year. * @return {Boolean} true if date is within a LeapYear, otherwise false. */ $D.isLeapYear = function (year) { return ((year % 4 === 0 && year % 100 !== 0) || year % 400 === 0); }; /** * Gets the number of days in the month, given a year and month value. Automatically corrects for LeapYear. * @param {Number} The year. * @param {Number} The month (0-11). * @return {Number} The number of days in the month. */ $D.getDaysInMonth = function (year, month) { if (!month && $D.validateMonth(year)) { month = year; year = Date.today().getFullYear(); } return [31, ($D.isLeapYear(year) ? 29 : 28), 31, 30, 31, 30, 31, 31, 30, 31, 30, 31][month]; }; $P.getDaysInMonth = function () { return $D.getDaysInMonth(this.getFullYear(), this.getMonth()); }; $D.getTimezoneAbbreviation = function (offset, dst) { var p, n = (dst || false) ? Date.CultureInfo.abbreviatedTimeZoneDST : Date.CultureInfo.abbreviatedTimeZoneStandard; for (p in n) { if (n.hasOwnProperty(p)) { if (n[p] === offset) { return p; } } } return null; }; $D.getTimezoneOffset = function (name, dst) { var i, a =[], z = Date.CultureInfo.timezones; if (!name) { name = (new Date()).getTimezone();} for (i = 0; i < z.length; i++) { if (z[i].name === name.toUpperCase()) { a.push(i); } } if (!z[a[0]]) { return null; } if (a.length === 1 || !dst) { return z[a[0]].offset; } else { for (i=0; i < a.length; i++) { if (z[a[i]].dst) { return z[a[i]].offset; } } } }; $D.getQuarter = function (d) { d = d || new Date(); // If no date supplied, use today var q = [1,2,3,4]; return q[Math.floor(d.getMonth() / 3)]; // ~~~ is a bitwise op. Faster than Math.floor }; $D.getDaysLeftInQuarter = function (d) { d = d || new Date(); var qEnd = new Date(d); qEnd.setMonth(qEnd.getMonth() + 3 - qEnd.getMonth() % 3, 0); return Math.floor((qEnd - d) / 8.64e7); }; // private var validate = function (n, min, max, name) { name = name ? name : "Object"; if (typeof n === "undefined") { return false; } else if (typeof n !== "number") { throw new TypeError(n + " is not a Number."); } else if (n < min || n > max) { // As failing validation is *not* an exceptional circumstance // lets not throw a RangeError Exception here. // It's semantically correct but it's not sensible. return false; } return true; }; /** * Validates the number is within an acceptable range for milliseconds [0-999]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateMillisecond = function (value) { return validate(value, 0, 999, "millisecond"); }; /** * Validates the number is within an acceptable range for seconds [0-59]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateSecond = function (value) { return validate(value, 0, 59, "second"); }; /** * Validates the number is within an acceptable range for minutes [0-59]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateMinute = function (value) { return validate(value, 0, 59, "minute"); }; /** * Validates the number is within an acceptable range for hours [0-23]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateHour = function (value) { return validate(value, 0, 23, "hour"); }; /** * Validates the number is within an acceptable range for the days in a month [0-MaxDaysInMonth]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateDay = function (value, year, month) { if (year === undefined || year === null || month === undefined || month === null) { return false;} return validate(value, 1, $D.getDaysInMonth(year, month), "day"); }; /** * Validates the number is within an acceptable range for months [0-11]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateWeek = function (value) { return validate(value, 0, 53, "week"); }; /** * Validates the number is within an acceptable range for months [0-11]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateMonth = function (value) { return validate(value, 0, 11, "month"); }; /** * Validates the number is within an acceptable range for years. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateYear = function (value) { /** * Per ECMAScript spec the range of times supported by Date objects is * exactly -100,000,000 days to +100,000,000 days measured relative to * midnight at the beginning of 01 January, 1970 UTC. * This gives a range of 8,640,000,000,000,000 milliseconds to either * side of 01 January, 1970 UTC. * * Earliest possible date: Tue, 20 Apr 271,822 B.C. 00:00:00 UTC * Latest possible date: Sat, 13 Sep 275,760 00:00:00 UTC */ return validate(value, -271822, 275760, "year"); }; $D.validateTimezone = function(value) { var timezones = {"ACDT":1,"ACST":1,"ACT":1,"ADT":1,"AEDT":1,"AEST":1,"AFT":1,"AKDT":1,"AKST":1,"AMST":1,"AMT":1,"ART":1,"AST":1,"AWDT":1,"AWST":1,"AZOST":1,"AZT":1,"BDT":1,"BIOT":1,"BIT":1,"BOT":1,"BRT":1,"BST":1,"BTT":1,"CAT":1,"CCT":1,"CDT":1,"CEDT":1,"CEST":1,"CET":1,"CHADT":1,"CHAST":1,"CHOT":1,"ChST":1,"CHUT":1,"CIST":1,"CIT":1,"CKT":1,"CLST":1,"CLT":1,"COST":1,"COT":1,"CST":1,"CT":1,"CVT":1,"CWST":1,"CXT":1,"DAVT":1,"DDUT":1,"DFT":1,"EASST":1,"EAST":1,"EAT":1,"ECT":1,"EDT":1,"EEDT":1,"EEST":1,"EET":1,"EGST":1,"EGT":1,"EIT":1,"EST":1,"FET":1,"FJT":1,"FKST":1,"FKT":1,"FNT":1,"GALT":1,"GAMT":1,"GET":1,"GFT":1,"GILT":1,"GIT":1,"GMT":1,"GST":1,"GYT":1,"HADT":1,"HAEC":1,"HAST":1,"HKT":1,"HMT":1,"HOVT":1,"HST":1,"ICT":1,"IDT":1,"IOT":1,"IRDT":1,"IRKT":1,"IRST":1,"IST":1,"JST":1,"KGT":1,"KOST":1,"KRAT":1,"KST":1,"LHST":1,"LINT":1,"MAGT":1,"MART":1,"MAWT":1,"MDT":1,"MET":1,"MEST":1,"MHT":1,"MIST":1,"MIT":1,"MMT":1,"MSK":1,"MST":1,"MUT":1,"MVT":1,"MYT":1,"NCT":1,"NDT":1,"NFT":1,"NPT":1,"NST":1,"NT":1,"NUT":1,"NZDT":1,"NZST":1,"OMST":1,"ORAT":1,"PDT":1,"PET":1,"PETT":1,"PGT":1,"PHOT":1,"PHT":1,"PKT":1,"PMDT":1,"PMST":1,"PONT":1,"PST":1,"PYST":1,"PYT":1,"RET":1,"ROTT":1,"SAKT":1,"SAMT":1,"SAST":1,"SBT":1,"SCT":1,"SGT":1,"SLST":1,"SRT":1,"SST":1,"SYOT":1,"TAHT":1,"THA":1,"TFT":1,"TJT":1,"TKT":1,"TLT":1,"TMT":1,"TOT":1,"TVT":1,"UCT":1,"ULAT":1,"UTC":1,"UYST":1,"UYT":1,"UZT":1,"VET":1,"VLAT":1,"VOLT":1,"VOST":1,"VUT":1,"WAKT":1,"WAST":1,"WAT":1,"WEDT":1,"WEST":1,"WET":1,"WST":1,"YAKT":1,"YEKT":1,"Z":1}; return (timezones[value] === 1); }; $D.validateTimezoneOffset= function(value) { // timezones go from +14hrs to -12hrs, the +X hours are negative offsets. return (value > -841 && value < 721); }; }()); (function () { var $D = Date, $P = $D.prototype, p = function (s, l) { if (!l) { l = 2; } return ("000" + s).slice(l * -1); }; var validateConfigObject = function (obj) { var result = {}, self = this, prop, testFunc; testFunc = function (prop, func, value) { if (prop === "day") { var month = (obj.month !== undefined) ? obj.month : self.getMonth(); var year = (obj.year !== undefined) ? obj.year : self.getFullYear(); return $D[func](value, year, month); } else { return $D[func](value); } }; for (prop in obj) { if (Object.prototype.hasOwnProperty.call(obj, prop)) { var func = "validate" + prop.charAt(0).toUpperCase() + prop.slice(1); if ($D[func] && obj[prop] !== null && testFunc(prop, func, obj[prop])) { result[prop] = obj[prop]; } } } return result; }; /** * Resets the time of this Date object to 12:00 AM (00:00), which is the start of the day. * @param {Boolean} .clone() this date instance before clearing Time * @return {Date} this */ $P.clearTime = function () { this.setHours(0); this.setMinutes(0); this.setSeconds(0); this.setMilliseconds(0); return this; }; /** * Resets the time of this Date object to the current time ('now'). * @return {Date} this */ $P.setTimeToNow = function () { var n = new Date(); this.setHours(n.getHours()); this.setMinutes(n.getMinutes()); this.setSeconds(n.getSeconds()); this.setMilliseconds(n.getMilliseconds()); return this; }; /** * Returns a new Date object that is an exact date and time copy of the original instance. * @return {Date} A new Date instance */ $P.clone = function () { return new Date(this.getTime()); }; /** * Compares this instance to a Date object and returns an number indication of their relative values. * @param {Date} Date object to compare [Required] * @return {Number} -1 = this is lessthan date. 0 = values are equal. 1 = this is greaterthan date. */ $P.compareTo = function (date) { return Date.compare(this, date); }; /** * Compares this instance to another Date object and returns true if they are equal. * @param {Date} Date object to compare. If no date to compare, new Date() [now] is used. * @return {Boolean} true if dates are equal. false if they are not equal. */ $P.equals = function (date) { return Date.equals(this, (date !== undefined ? date : new Date())); }; /** * Determines if this instance is between a range of two dates or equal to either the start or end dates. * @param {Date} Start of range [Required] * @param {Date} End of range [Required] * @return {Boolean} true is this is between or equal to the start and end dates, else false */ $P.between = function (start, end) { return this.getTime() >= start.getTime() && this.getTime() <= end.getTime(); }; /** * Determines if this date occurs after the date to compare to. * @param {Date} Date object to compare. If no date to compare, new Date() ("now") is used. * @return {Boolean} true if this date instance is greater than the date to compare to (or "now"), otherwise false. */ $P.isAfter = function (date) { return this.compareTo(date || new Date()) === 1; }; /** * Determines if this date occurs before the date to compare to. * @param {Date} Date object to compare. If no date to compare, new Date() ("now") is used. * @return {Boolean} true if this date instance is less than the date to compare to (or "now"). */ $P.isBefore = function (date) { return (this.compareTo(date || new Date()) === -1); }; /** * Determines if the current Date instance occurs today. * @return {Boolean} true if this date instance is 'today', otherwise false. */ /** * Determines if the current Date instance occurs on the same Date as the supplied 'date'. * If no 'date' to compare to is provided, the current Date instance is compared to 'today'. * @param {date} Date object to compare. If no date to compare, the current Date ("now") is used. * @return {Boolean} true if this Date instance occurs on the same Day as the supplied 'date'. */ $P.isToday = $P.isSameDay = function (date) { return this.clone().clearTime().equals((date || new Date()).clone().clearTime()); }; /** * Adds the specified number of milliseconds to this instance. * @param {Number} The number of milliseconds to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addMilliseconds = function (value) { if (!value) { return this; } this.setTime(this.getTime() + value * 1); return this; }; /** * Adds the specified number of seconds to this instance. * @param {Number} The number of seconds to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addSeconds = function (value) { if (!value) { return this; } return this.addMilliseconds(value * 1000); }; /** * Adds the specified number of seconds to this instance. * @param {Number} The number of seconds to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addMinutes = function (value) { if (!value) { return this; } return this.addMilliseconds(value * 60000); // 60*1000 }; /** * Adds the specified number of hours to this instance. * @param {Number} The number of hours to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addHours = function (value) { if (!value) { return this; } return this.addMilliseconds(value * 3600000); // 60*60*1000 }; /** * Adds the specified number of days to this instance. * @param {Number} The number of days to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addDays = function (value) { if (!value) { return this; } this.setDate(this.getDate() + value * 1); return this; }; /** * Adds the specified number of weekdays (ie - not sat or sun) to this instance. * @param {Number} The number of days to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addWeekdays = function (value) { if (!value) { return this; } var day = this.getDay(); var weeks = (Math.ceil(Math.abs(value)/7)); if (day === 0 || day === 6) { if (value > 0) { this.next().monday(); this.addDays(-1); day = this.getDay(); } } if (value < 0) { while (value < 0) { this.addDays(-1); day = this.getDay(); if (day !== 0 && day !== 6) { value++; } } return this; } else if (value > 5 || (6-day) <= value) { value = value + (weeks * 2); } return this.addDays(value); }; /** * Adds the specified number of weeks to this instance. * @param {Number} The number of weeks to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addWeeks = function (value) { if (!value) { return this; } return this.addDays(value * 7); }; /** * Adds the specified number of months to this instance. * @param {Number} The number of months to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addMonths = function (value) { if (!value) { return this; } var n = this.getDate(); this.setDate(1); this.setMonth(this.getMonth() + value * 1); this.setDate(Math.min(n, $D.getDaysInMonth(this.getFullYear(), this.getMonth()))); return this; }; $P.addQuarters = function (value) { if (!value) { return this; } // note this will take you to the same point in the quarter as you are now. // i.e. - if you are 15 days into the quarter you'll be 15 days into the resulting one. // bonus: this allows adding fractional quarters return this.addMonths(value * 3); }; /** * Adds the specified number of years to this instance. * @param {Number} The number of years to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addYears = function (value) { if (!value) { return this; } return this.addMonths(value * 12); }; /** * Adds (or subtracts) to the value of the years, months, weeks, days, hours, minutes, seconds, milliseconds of the date instance using given configuration object. Positive and Negative values allowed. * Example

	Date.today().add( { days: 1, months: 1 } )

	new Date().add( { years: -1 } )
	
* @param {Object} Configuration object containing attributes (months, days, etc.) * @return {Date} this */ $P.add = function (config) { if (typeof config === "number") { this._orient = config; return this; } var x = config; if (x.day) { // If we should be a different date than today (eg: for 'tomorrow -1d', etc). // Should only effect parsing, not direct usage (eg, Finish and FinishExact) if ((x.day - this.getDate()) !== 0) { this.setDate(x.day); } } if (x.milliseconds) { this.addMilliseconds(x.milliseconds); } if (x.seconds) { this.addSeconds(x.seconds); } if (x.minutes) { this.addMinutes(x.minutes); } if (x.hours) { this.addHours(x.hours); } if (x.weeks) { this.addWeeks(x.weeks); } if (x.months) { this.addMonths(x.months); } if (x.years) { this.addYears(x.years); } if (x.days) { this.addDays(x.days); } return this; }; /** * Get the week number. Week one (1) is the week which contains the first Thursday of the year. Monday is considered the first day of the week. * The .getWeek() function does NOT convert the date to UTC. The local datetime is used. * Please use .getISOWeek() to get the week of the UTC converted date. * @return {Number} 1 to 53 */ $P.getWeek = function (utc) { // Create a copy of this date object var self, target = new Date(this.valueOf()); if (utc) { target.addMinutes(target.getTimezoneOffset()); self = target.clone(); } else { self = this; } // ISO week date weeks start on monday // so correct the day number var dayNr = (self.getDay() + 6) % 7; // ISO 8601 states that week 1 is the week // with the first thursday of that year. // Set the target date to the thursday in the target week target.setDate(target.getDate() - dayNr + 3); // Store the millisecond value of the target date var firstThursday = target.valueOf(); // Set the target to the first thursday of the year // First set the target to january first target.setMonth(0, 1); // Not a thursday? Correct the date to the next thursday if (target.getDay() !== 4) { target.setMonth(0, 1 + ((4 - target.getDay()) + 7) % 7); } // The weeknumber is the number of weeks between the // first thursday of the year and the thursday in the target week return 1 + Math.ceil((firstThursday - target) / 604800000); // 604800000 = 7 * 24 * 3600 * 1000 }; /** * Get the ISO 8601 week number. Week one ("01") is the week which contains the first Thursday of the year. Monday is considered the first day of the week. * The .getISOWeek() function does convert the date to it's UTC value. Please use .getWeek() to get the week of the local date. * @return {String} "01" to "53" */ $P.getISOWeek = function () { return p(this.getWeek(true)); }; /** * Moves the date to Monday of the week set. Week one (1) is the week which contains the first Thursday of the year. * @param {Number} A Number (1 to 53) that represents the week of the year. * @return {Date} this */ $P.setWeek = function (n) { if ((n - this.getWeek()) === 0) { if (this.getDay() !== 1) { return this.moveToDayOfWeek(1, (this.getDay() > 1 ? -1 : 1)); } else { return this; } } else { return this.moveToDayOfWeek(1, (this.getDay() > 1 ? -1 : 1)).addWeeks(n - this.getWeek()); } }; $P.setQuarter = function (qtr) { var month = Math.abs(((qtr-1) * 3) + 1); return this.setMonth(month, 1); }; $P.getQuarter = function () { return Date.getQuarter(this); }; $P.getDaysLeftInQuarter = function () { return Date.getDaysLeftInQuarter(this); }; /** * Moves the date to the next n'th occurrence of the dayOfWeek starting from the beginning of the month. The number (-1) is a magic number and will return the last occurrence of the dayOfWeek in the month. * @param {Number} The dayOfWeek to move to * @param {Number} The n'th occurrence to move to. Use (-1) to return the last occurrence in the month * @return {Date} this */ $P.moveToNthOccurrence = function (dayOfWeek, occurrence) { if (dayOfWeek === "Weekday") { if (occurrence > 0) { this.moveToFirstDayOfMonth(); if (this.is().weekday()) { occurrence -= 1; } } else if (occurrence < 0) { this.moveToLastDayOfMonth(); if (this.is().weekday()) { occurrence += 1; } } else { return this; } return this.addWeekdays(occurrence); } var shift = 0; if (occurrence > 0) { shift = occurrence - 1; } else if (occurrence === -1) { this.moveToLastDayOfMonth(); if (this.getDay() !== dayOfWeek) { this.moveToDayOfWeek(dayOfWeek, -1); } return this; } return this.moveToFirstDayOfMonth().addDays(-1).moveToDayOfWeek(dayOfWeek, +1).addWeeks(shift); }; var moveToN = function (getFunc, addFunc, nVal) { return function (value, orient) { var diff = (value - this[getFunc]() + nVal * (orient || +1)) % nVal; return this[addFunc]((diff === 0) ? diff += nVal * (orient || +1) : diff); }; }; /** * Move to the next or last dayOfWeek based on the orient value. * @param {Number} The dayOfWeek to move to * @param {Number} Forward (+1) or Back (-1). Defaults to +1. [Optional] * @return {Date} this */ $P.moveToDayOfWeek = moveToN("getDay", "addDays", 7); /** * Move to the next or last month based on the orient value. * @param {Number} The month to move to. 0 = January, 11 = December * @param {Number} Forward (+1) or Back (-1). Defaults to +1. [Optional] * @return {Date} this */ $P.moveToMonth = moveToN("getMonth", "addMonths", 12); /** * Get the Ordinate of the current day ("th", "st", "rd"). * @return {String} */ $P.getOrdinate = function () { var num = this.getDate(); return ord(num); }; /** * Get the Ordinal day (numeric day number) of the year, adjusted for leap year. * @return {Number} 1 through 365 (366 in leap years) */ $P.getOrdinalNumber = function () { return Math.ceil((this.clone().clearTime() - new Date(this.getFullYear(), 0, 1)) / 86400000) + 1; }; /** * Get the time zone abbreviation of the current date. * @return {String} The abbreviated time zone name (e.g. "EST") */ $P.getTimezone = function () { return $D.getTimezoneAbbreviation(this.getUTCOffset(), this.isDaylightSavingTime()); }; $P.setTimezoneOffset = function (offset) { var here = this.getTimezoneOffset(), there = Number(offset) * -6 / 10; return (there || there === 0) ? this.addMinutes(there - here) : this; }; $P.setTimezone = function (offset) { return this.setTimezoneOffset($D.getTimezoneOffset(offset)); }; /** * Indicates whether Daylight Saving Time is observed in the current time zone. * @return {Boolean} true|false */ $P.hasDaylightSavingTime = function () { return (Date.today().set({month: 0, day: 1}).getTimezoneOffset() !== Date.today().set({month: 6, day: 1}).getTimezoneOffset()); }; /** * Indicates whether this Date instance is within the Daylight Saving Time range for the current time zone. * @return {Boolean} true|false */ $P.isDaylightSavingTime = function () { return Date.today().set({month: 0, day: 1}).getTimezoneOffset() !== this.getTimezoneOffset(); }; /** * Get the offset from UTC of the current date. * @return {String} The 4-character offset string prefixed with + or - (e.g. "-0500") */ $P.getUTCOffset = function (offset) { var n = (offset || this.getTimezoneOffset()) * -10 / 6, r; if (n < 0) { r = (n - 10000).toString(); return r.charAt(0) + r.substr(2); } else { r = (n + 10000).toString(); return "+" + r.substr(1); } }; /** * Returns the number of milliseconds between this date and date. * @param {Date} Defaults to now * @return {Number} The diff in milliseconds */ $P.getElapsed = function (date) { return (date || new Date()) - this; }; /** * Set the value of year, month, day, hour, minute, second, millisecond of date instance using given configuration object. * Example

	Date.today().set( { day: 20, month: 1 } )

	new Date().set( { millisecond: 0 } )
	
* * @param {Object} Configuration object containing attributes (month, day, etc.) * @return {Date} this */ $P.set = function (config) { config = validateConfigObject.call(this, config); var key; for (key in config) { if (Object.prototype.hasOwnProperty.call(config, key)) { var name = key.charAt(0).toUpperCase() + key.slice(1); var addFunc, getFunc; if (key !== "week" && key !== "month" && key !== "timezone" && key !== "timezoneOffset") { name += "s"; } addFunc = "add" + name; getFunc = "get" + name; if (key === "month") { addFunc = addFunc + "s"; } else if (key === "year"){ getFunc = "getFullYear"; } if (key !== "day" && key !== "timezone" && key !== "timezoneOffset" && key !== "week" && key !== "hour") { this[addFunc](config[key] - this[getFunc]()); } else if ( key === "timezone"|| key === "timezoneOffset" || key === "week" || key === "hour") { this["set"+name](config[key]); } } } // day has to go last because you can't validate the day without first knowing the month if (config.day) { this.addDays(config.day - this.getDate()); } return this; }; /** * Moves the date to the first day of the month. * @return {Date} this */ $P.moveToFirstDayOfMonth = function () { return this.set({ day: 1 }); }; /** * Moves the date to the last day of the month. * @return {Date} this */ $P.moveToLastDayOfMonth = function () { return this.set({ day: $D.getDaysInMonth(this.getFullYear(), this.getMonth())}); }; /** * Converts the value of the current Date object to its equivalent string representation. * Format Specifiers * CUSTOM DATE AND TIME FORMAT STRINGS * Format Description Example * ------ --------------------------------------------------------------------------- ----------------------- * s The seconds of the minute between 0-59. "0" to "59" * ss The seconds of the minute with leading zero if required. "00" to "59" * * m The minute of the hour between 0-59. "0" or "59" * mm The minute of the hour with leading zero if required. "00" or "59" * * h The hour of the day between 1-12. "1" to "12" * hh The hour of the day with leading zero if required. "01" to "12" * * H The hour of the day between 0-23. "0" to "23" * HH The hour of the day with leading zero if required. "00" to "23" * * d The day of the month between 1 and 31. "1" to "31" * dd The day of the month with leading zero if required. "01" to "31" * ddd Abbreviated day name. Date.CultureInfo.abbreviatedDayNames. "Mon" to "Sun" * dddd The full day name. Date.CultureInfo.dayNames. "Monday" to "Sunday" * * M The month of the year between 1-12. "1" to "12" * MM The month of the year with leading zero if required. "01" to "12" * MMM Abbreviated month name. Date.CultureInfo.abbreviatedMonthNames. "Jan" to "Dec" * MMMM The full month name. Date.CultureInfo.monthNames. "January" to "December" * * yy The year as a two-digit number. "99" or "08" * yyyy The full four digit year. "1999" or "2008" * * t Displays the first character of the A.M./P.M. designator. "A" or "P" * Date.CultureInfo.amDesignator or Date.CultureInfo.pmDesignator * tt Displays the A.M./P.M. designator. "AM" or "PM" * Date.CultureInfo.amDesignator or Date.CultureInfo.pmDesignator * * S The ordinal suffix ("st, "nd", "rd" or "th") of the current day. "st, "nd", "rd" or "th" * * STANDARD DATE AND TIME FORMAT STRINGS * Format Description Example *------ --------------------------------------------------------------------------- ----------------------- * d The CultureInfo shortDate Format Pattern "M/d/yyyy" * D The CultureInfo longDate Format Pattern "dddd, MMMM dd, yyyy" * F The CultureInfo fullDateTime Format Pattern "dddd, MMMM dd, yyyy h:mm:ss tt" * m The CultureInfo monthDay Format Pattern "MMMM dd" * r The CultureInfo rfc1123 Format Pattern "ddd, dd MMM yyyy HH:mm:ss GMT" * s The CultureInfo sortableDateTime Format Pattern "yyyy-MM-ddTHH:mm:ss" * t The CultureInfo shortTime Format Pattern "h:mm tt" * T The CultureInfo longTime Format Pattern "h:mm:ss tt" * u The CultureInfo universalSortableDateTime Format Pattern "yyyy-MM-dd HH:mm:ssZ" * y The CultureInfo yearMonth Format Pattern "MMMM, yyyy" * * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @return {String} A string representation of the current Date object. */ var ord = function (n) { switch (n * 1) { case 1: case 21: case 31: return "st"; case 2: case 22: return "nd"; case 3: case 23: return "rd"; default: return "th"; } }; var parseStandardFormats = function (format) { var y, c = Date.CultureInfo.formatPatterns; switch (format) { case "d": return this.toString(c.shortDate); case "D": return this.toString(c.longDate); case "F": return this.toString(c.fullDateTime); case "m": return this.toString(c.monthDay); case "r": case "R": y = this.clone().addMinutes(this.getTimezoneOffset()); return y.toString(c.rfc1123) + " GMT"; case "s": return this.toString(c.sortableDateTime); case "t": return this.toString(c.shortTime); case "T": return this.toString(c.longTime); case "u": y = this.clone().addMinutes(this.getTimezoneOffset()); return y.toString(c.universalSortableDateTime); case "y": return this.toString(c.yearMonth); default: return false; } }; var parseFormatStringsClosure = function (context) { return function (m) { if (m.charAt(0) === "\\") { return m.replace("\\", ""); } switch (m) { case "hh": return p(context.getHours() < 13 ? (context.getHours() === 0 ? 12 : context.getHours()) : (context.getHours() - 12)); case "h": return context.getHours() < 13 ? (context.getHours() === 0 ? 12 : context.getHours()) : (context.getHours() - 12); case "HH": return p(context.getHours()); case "H": return context.getHours(); case "mm": return p(context.getMinutes()); case "m": return context.getMinutes(); case "ss": return p(context.getSeconds()); case "s": return context.getSeconds(); case "yyyy": return p(context.getFullYear(), 4); case "yy": return p(context.getFullYear()); case "y": return context.getFullYear(); case "E": case "dddd": return Date.CultureInfo.dayNames[context.getDay()]; case "ddd": return Date.CultureInfo.abbreviatedDayNames[context.getDay()]; case "dd": return p(context.getDate()); case "d": return context.getDate(); case "MMMM": return Date.CultureInfo.monthNames[context.getMonth()]; case "MMM": return Date.CultureInfo.abbreviatedMonthNames[context.getMonth()]; case "MM": return p((context.getMonth() + 1)); case "M": return context.getMonth() + 1; case "t": return context.getHours() < 12 ? Date.CultureInfo.amDesignator.substring(0, 1) : Date.CultureInfo.pmDesignator.substring(0, 1); case "tt": return context.getHours() < 12 ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator; case "S": return ord(context.getDate()); case "W": return context.getWeek(); case "WW": return context.getISOWeek(); case "Q": return "Q" + context.getQuarter(); case "q": return String(context.getQuarter()); case "z": return context.getTimezone(); case "Z": case "X": return Date.getTimezoneOffset(context.getTimezone()); case "ZZ": // Timezone offset in seconds return context.getTimezoneOffset() * -60; case "u": return context.getDay(); case "L": return ($D.isLeapYear(context.getFullYear())) ? 1 : 0; case "B": // Swatch Internet Time (.beats) return "@"+((context.getUTCSeconds() + (context.getUTCMinutes()*60) + ((context.getUTCHours()+1)*3600))/86.4); default: return m; } }; }; $P.toString = function (format, ignoreStandards) { // Standard Date and Time Format Strings. Formats pulled from CultureInfo file and // may vary by culture. if (!ignoreStandards && format && format.length === 1) { output = parseStandardFormats.call(this, format); if (output) { return output; } } var parseFormatStrings = parseFormatStringsClosure(this); return format ? format.replace(/((\\)?(dd?d?d?|MM?M?M?|yy?y?y?|hh?|HH?|mm?|ss?|tt?|S|q|Q|WW?W?W?)(?![^\[]*\]))/g, parseFormatStrings).replace(/\[|\]/g, "") : this._toString(); }; }()); /************************************************************* * SugarPak - Domain Specific Language - Syntactical Sugar * *************************************************************/ (function () { var $D = Date, $P = $D.prototype, $N = Number.prototype; // private $P._orient = +1; // private $P._nth = null; // private $P._is = false; // private $P._same = false; // private $P._isSecond = false; // private $N._dateElement = "days"; /** * Moves the date to the next instance of a date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.today().next().friday();
	Date.today().next().fri();
	Date.today().next().march();
	Date.today().next().mar();
	Date.today().next().week();
	
* * @return {Date} date */ $P.next = function () { this._move = true; this._orient = +1; return this; }; /** * Creates a new Date (Date.today()) and moves the date to the next instance of the date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.next().friday();
	Date.next().fri();
	Date.next().march();
	Date.next().mar();
	Date.next().week();
	
* * @return {Date} date */ $D.next = function () { return $D.today().next(); }; /** * Moves the date to the previous instance of a date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.today().last().friday();
	Date.today().last().fri();
	Date.today().last().march();
	Date.today().last().mar();
	Date.today().last().week();
	
* * @return {Date} date */ $P.last = $P.prev = $P.previous = function () { this._move = true; this._orient = -1; return this; }; /** * Creates a new Date (Date.today()) and moves the date to the previous instance of the date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.last().friday();
	Date.last().fri();
	Date.previous().march();
	Date.prev().mar();
	Date.last().week();
	
* * @return {Date} date */ $D.last = $D.prev = $D.previous = function () { return $D.today().last(); }; /** * Performs a equality check when followed by either a month name, day name or .weekday() function. * Example

	Date.today().is().friday(); // true|false
	Date.today().is().fri();
	Date.today().is().march();
	Date.today().is().mar();
	
* * @return {Boolean} true|false */ $P.is = function () { this._is = true; return this; }; /** * Determines if two date objects occur on/in exactly the same instance of the subsequent date part function. * The function .same() must be followed by a date part function (example: .day(), .month(), .year(), etc). * * An optional Date can be passed in the date part function. If now date is passed as a parameter, 'Now' is used. * * The following example demonstrates how to determine if two dates fall on the exact same day. * * Example

	var d1 = Date.today(); // today at 00:00
	var d2 = new Date();   // exactly now.

	// Do they occur on the same day?
	d1.same().day(d2); // true
	
	// Do they occur on the same hour?
	d1.same().hour(d2); // false, unless d2 hour is '00' (midnight).
	
	// What if it's the same day, but one year apart?
	var nextYear = Date.today().add(1).year();

	d1.same().day(nextYear); // false, because the dates must occur on the exact same day. 
	
* * Scenario: Determine if a given date occurs during some week period 2 months from now. * * Example

	var future = Date.today().add(2).months();
	return someDate.same().week(future); // true|false;
	
* * @return {Boolean} true|false */ $P.same = function () { this._same = true; this._isSecond = false; return this; }; /** * Determines if the current date/time occurs during Today. Must be preceded by the .is() function. * Example

	someDate.is().today();    // true|false
	new Date().is().today();  // true
	Date.today().is().today();// true
	Date.today().add(-1).day().is().today(); // false
	
* * @return {Boolean} true|false */ $P.today = function () { return this.same().day(); }; /** * Determines if the current date is a weekday. This function must be preceded by the .is() function. * Example

	Date.today().is().weekday(); // true|false
	
* * @return {Boolean} true|false */ $P.weekday = function () { if (this._nth) { return df("Weekday").call(this); } if (this._move) { return this.addWeekdays(this._orient); } if (this._is) { this._is = false; return (!this.is().sat() && !this.is().sun()); } return false; }; /** * Determines if the current date is on the weekend. This function must be preceded by the .is() function. * Example

	Date.today().is().weekend(); // true|false
	
* * @return {Boolean} true|false */ $P.weekend = function () { if (this._is) { this._is = false; return (this.is().sat() || this.is().sun()); } return false; }; /** * Sets the Time of the current Date instance. A string "6:15 pm" or config object {hour:18, minute:15} are accepted. * Example

	// Set time to 6:15pm with a String
	Date.today().at("6:15pm");

	// Set time to 6:15pm with a config object
	Date.today().at({hour:18, minute:15});
	
* * @return {Date} date */ $P.at = function (time) { return (typeof time === "string") ? $D.parse(this.toString("d") + " " + time) : this.set(time); }; /** * Creates a new Date() and adds this (Number) to the date based on the preceding date element function (eg. second|minute|hour|day|month|year). * Example

	// Undeclared Numbers must be wrapped with parentheses. Requirment of JavaScript.
	(3).days().fromNow();
	(6).months().fromNow();

	// Declared Number variables do not require parentheses. 
	var n = 6;
	n.months().fromNow();
	
* * @return {Date} A new Date instance */ $N.fromNow = $N.after = function (date) { var c = {}; c[this._dateElement] = this; return ((!date) ? new Date() : date.clone()).add(c); }; /** * Creates a new Date() and subtract this (Number) from the date based on the preceding date element function (eg. second|minute|hour|day|month|year). * Example

	// Undeclared Numbers must be wrapped with parentheses. Requirment of JavaScript.
	(3).days().ago();
	(6).months().ago();

	// Declared Number variables do not require parentheses. 
	var n = 6;
	n.months().ago();
	
* * @return {Date} A new Date instance */ $N.ago = $N.before = function (date) { var c = {}, s = (this._dateElement[this._dateElement.length-1] !== "s") ? this._dateElement + "s" : this._dateElement; c[s] = this * -1; return ((!date) ? new Date() : date.clone()).add(c); }; // Do NOT modify the following string tokens. These tokens are used to build dynamic functions. // All culture-specific strings can be found in the CultureInfo files. var dx = ("sunday monday tuesday wednesday thursday friday saturday").split(/\s/), mx = ("january february march april may june july august september october november december").split(/\s/), px = ("Millisecond Second Minute Hour Day Week Month Year Quarter Weekday").split(/\s/), pxf = ("Milliseconds Seconds Minutes Hours Date Week Month FullYear Quarter").split(/\s/), nth = ("final first second third fourth fifth").split(/\s/), de; /** * Returns an object literal of all the date parts. * Example

	var o = new Date().toObject();
	
	// { year: 2008, month: 4, week: 20, day: 13, hour: 18, minute: 9, second: 32, millisecond: 812 }
	
	// The object properties can be referenced directly from the object.
	
	alert(o.day);  // alerts "13"
	alert(o.year); // alerts "2008"
	
* * @return {Date} An object literal representing the original date object. */ $P.toObject = function () { var o = {}; for (var i = 0; i < px.length; i++) { if (this["get" + pxf[i]]) { o[px[i].toLowerCase()] = this["get" + pxf[i]](); } } return o; }; /** * Returns a date created from an object literal. Ignores the .week property if set in the config. * Example

	var o = new Date().toObject();
	
	return Date.fromObject(o); // will return the same date. 

	var o2 = {month: 1, day: 20, hour: 18}; // birthday party!
	Date.fromObject(o2);
	
* * @return {Date} An object literal representing the original date object. */ $D.fromObject = function(config) { config.week = null; return Date.today().set(config); }; // Create day name functions and abbreviated day name functions (eg. monday(), friday(), fri()). var df = function (n) { return function () { if (this._is) { this._is = false; return this.getDay() === n; } if (this._move) { this._move = null; } if (this._nth !== null) { // If the .second() function was called earlier, remove the _orient // from the date, and then continue. // This is required because 'second' can be used in two different context. // // Example // // Date.today().add(1).second(); // Date.march().second().monday(); // // Things get crazy with the following... // Date.march().add(1).second().second().monday(); // but it works!! // if (this._isSecond) { this.addSeconds(this._orient * -1); } // make sure we reset _isSecond this._isSecond = false; var ntemp = this._nth; this._nth = null; var temp = this.clone().moveToLastDayOfMonth(); this.moveToNthOccurrence(n, ntemp); if (this > temp) { throw new RangeError($D.getDayName(n) + " does not occur " + ntemp + " times in the month of " + $D.getMonthName(temp.getMonth()) + " " + temp.getFullYear() + "."); } return this; } return this.moveToDayOfWeek(n, this._orient); }; }; var sdf = function (n) { return function () { var t = $D.today(), shift = n - t.getDay(); if (n === 0 && Date.CultureInfo.firstDayOfWeek === 1 && t.getDay() !== 0) { shift = shift + 7; } return t.addDays(shift); }; }; // Create month name functions and abbreviated month name functions (eg. january(), march(), mar()). var month_instance_functions = function (n) { return function () { if (this._is) { this._is = false; return this.getMonth() === n; } return this.moveToMonth(n, this._orient); }; }; var month_static_functions = function (n) { return function () { return $D.today().set({ month: n, day: 1 }); }; }; var processTerms = function (names, staticFunc, instanceFunc) { for (var i = 0; i < names.length; i++) { // Create constant static Name variables. $D[names[i].toUpperCase()] = $D[names[i].toUpperCase().substring(0, 3)] = i; // Create Name functions. $D[names[i]] = $D[names[i].substring(0, 3)] = staticFunc(i); // Create Name instance functions. $P[names[i]] = $P[names[i].substring(0, 3)] = instanceFunc(i); } }; processTerms(dx, sdf, df); processTerms(mx, month_static_functions, month_instance_functions); // Create date element functions and plural date element functions used with Date (eg. day(), days(), months()). var ef = function (j) { return function () { // if the .second() function was called earlier, the _orient // has alread been added. Just return this and reset _isSecond. if (this._isSecond) { this._isSecond = false; return this; } if (this._same) { this._same = this._is = false; var o1 = this.toObject(), o2 = (arguments[0] || new Date()).toObject(), v = "", k = j.toLowerCase(); // the substr trick with -1 doesn't work in IE8 or less k = (k[k.length-1] === "s") ? k.substring(0,k.length-1) : k; for (var m = (px.length - 1); m > -1; m--) { v = px[m].toLowerCase(); if (o1[v] !== o2[v]) { return false; } if (k === v) { break; } } return true; } if (j.substring(j.length - 1) !== "s") { j += "s"; } if (this._move) { this._move = null; } return this["add" + j](this._orient); }; }; var nf = function (n) { return function () { this._dateElement = n; return this; }; }; for (var k = 0; k < px.length; k++) { de = px[k].toLowerCase(); if(de !== "weekday") { // Create date element functions and plural date element functions used with Date (eg. day(), days(), months()). $P[de] = $P[de + "s"] = ef(px[k]); // Create date element functions and plural date element functions used with Number (eg. day(), days(), months()). $N[de] = $N[de + "s"] = nf(de + "s"); } } $P._ss = ef("Second"); var nthfn = function (n) { return function (dayOfWeek) { if (this._same) { return this._ss(arguments[0]); } if (dayOfWeek || dayOfWeek === 0) { return this.moveToNthOccurrence(dayOfWeek, n); } this._nth = n; // if the operator is 'second' add the _orient, then deal with it later... if (n === 2 && (dayOfWeek === undefined || dayOfWeek === null)) { this._isSecond = true; return this.addSeconds(this._orient); } return this; }; }; for (var l = 0; l < nth.length; l++) { $P[nth[l]] = (l === 0) ? nthfn(-1) : nthfn(l); } }()); (function () { "use strict"; Date.Parsing = { Exception: function (s) { this.message = "Parse error at '" + s.substring(0, 10) + " ...'"; } }; var $P = Date.Parsing; var dayOffsets = { standard: [0,31,59,90,120,151,181,212,243,273,304,334], leap: [0,31,60,91,121,152,182,213,244,274,305,335] }; $P.isLeapYear = function(year) { return ((year % 4 === 0) && (year % 100 !== 0)) || (year % 400 === 0); }; var utils = { multiReplace : function (str, hash ) { var key; for (key in hash) { if (Object.prototype.hasOwnProperty.call(hash, key)) { var regex; if (typeof hash[key] === "function") { } else { regex = (hash[key] instanceof RegExp) ? hash[key] : new RegExp(hash[key], "g"); } str = str.replace(regex, key); } } return str; }, getDayOfYearFromWeek : function (obj) { var d, jan4, offset; obj.weekDay = (!obj.weekDay && obj.weekDay !== 0) ? 1 : obj.weekDay; d = new Date(obj.year, 0, 4); jan4 = d.getDay() === 0 ? 7 : d.getDay(); // JS is 0 indexed on Sunday. offset = jan4+3; obj.dayOfYear = ((obj.week * 7) + (obj.weekDay === 0 ? 7 : obj.weekDay))-offset; return obj; }, getDayOfYear : function (obj, dayOffset) { if (!obj.dayOfYear) { obj = utils.getDayOfYearFromWeek(obj); } for (var i=0;i <= dayOffset.length;i++) { if (obj.dayOfYear < dayOffset[i] || i === dayOffset.length) { obj.day = obj.day ? obj.day : (obj.dayOfYear - dayOffset[i-1]); break; } else { obj.month = i; } } return obj; }, adjustForTimeZone : function (obj, date) { var offset; if (obj.zone.toUpperCase() === "Z" || (obj.zone_hours === 0 && obj.zone_minutes === 0)) { // it's UTC/GML so work out the current timeszone offset offset = -date.getTimezoneOffset(); } else { offset = (obj.zone_hours*60) + (obj.zone_minutes || 0); if (obj.zone_sign === "+") { offset *= -1; } offset -= date.getTimezoneOffset(); } date.setMinutes(date.getMinutes()+offset); return date; }, setDefaults : function (obj) { obj.year = obj.year || Date.today().getFullYear(); obj.hours = obj.hours || 0; obj.minutes = obj.minutes || 0; obj.seconds = obj.seconds || 0; obj.milliseconds = obj.milliseconds || 0; if (!(!obj.month && (obj.week || obj.dayOfYear))) { // if we have a month, or if we don't but don't have the day calculation data obj.month = obj.month || 0; obj.day = obj.day || 1; } return obj; }, dataNum: function (data, mod, explict, postProcess) { var dataNum = data*1; if (mod) { if (postProcess) { return data ? mod(data)*1 : data; } else { return data ? mod(dataNum) : data; } } else if (!explict){ return data ? dataNum : data; } else { return (data && typeof data !== "undefined") ? dataNum : data; } }, timeDataProcess: function (obj) { var timeObj = {}; for (var x in obj.data) { if (obj.data.hasOwnProperty(x)) { timeObj[x] = obj.ignore[x] ? obj.data[x] : utils.dataNum(obj.data[x], obj.mods[x], obj.explict[x], obj.postProcess[x]); } } if (obj.data.secmins) { obj.data.secmins = obj.data.secmins.replace(",", ".") * 60; if (!timeObj.minutes) { timeObj.minutes = obj.data.secmins; } else if (!timeObj.seconds) { timeObj.seconds = obj.data.secmins; } delete obj.secmins; } return timeObj; }, buildTimeObjectFromData: function (data) { var time = utils.timeDataProcess({ data: { year : data[1], month : data[5], day : data[7], week : data[8], dayOfYear : data[10], hours : data[15], zone_hours : data[23], zone_minutes : data[24], zone : data[21], zone_sign : data[22], weekDay : data[9], minutes: data[16], seconds: data[19], milliseconds: data[20], secmins: data[18] }, mods: { month: function(data) { return data-1; }, weekDay: function (data) { data = Math.abs(data); return (data === 7 ? 0 : data); }, minutes: function (data) { return data.replace(":",""); }, seconds: function (data) { return Math.floor( (data.replace(":","").replace(",","."))*1 ); }, milliseconds: function (data) { return (data.replace(",",".")*1000); } }, postProcess: { minutes: true, seconds: true, milliseconds: true }, explict: { zone_hours: true, zone_minutes: true }, ignore: { zone: true, zone_sign: true, secmins: true } }); return time; }, addToHash: function (hash, keys, data) { keys = keys; data = data; var len = keys.length; for (var i = 0; i < len; i++) { hash[keys[i]] = data[i]; } return hash; }, combineRegex: function (r1, r2) { return new RegExp("(("+r1.source+")\\s("+r2.source+"))"); }, getDateNthString: function(add, last, inc){ if (add) { return Date.today().addDays(inc).toString("d"); } else if (last) { return Date.today().last()[inc]().toString("d"); } }, buildRegexData: function (array) { var arr = []; var len = array.length; for (var i=0; i < len; i++) { if (Object.prototype.toString.call(array[i]) === '[object Array]') { // oldIE compat version of Array.isArray arr.push(this.combineRegex(array[i][0], array[i][1])); } else { arr.push(array[i]); } } return arr; } }; $P.processTimeObject = function (obj) { var date, dayOffset; utils.setDefaults(obj); dayOffset = ($P.isLeapYear(obj.year)) ? dayOffsets.leap : dayOffsets.standard; if (!obj.month && (obj.week || obj.dayOfYear)) { utils.getDayOfYear(obj, dayOffset); } else { obj.dayOfYear = dayOffset[obj.month] + obj.day; } date = new Date(obj.year, obj.month, obj.day, obj.hours, obj.minutes, obj.seconds, obj.milliseconds); if (obj.zone) { utils.adjustForTimeZone(obj, date); // adjust (and calculate) for timezone } return date; }; $P.ISO = { regex : /^([\+-]?\d{4}(?!\d{2}\b))((-?)((0[1-9]|1[0-2])(\3([12]\d|0[1-9]|3[01]))?|W([0-4]\d|5[0-3])(-?[1-7])?|(00[1-9]|0[1-9]\d|[12]\d{2}|3([0-5]\d|6[1-6])))([T\s]((([01]\d|2[0-4])((:?)[0-5]\d)?|24\:?00)([\.,]\d+(?!:))?)?(\17[0-5]\d([\.,]\d+)?)?\s?([zZ]|([\+-])([01]\d|2[0-3]):?([0-5]\d)?)?)?)?$/, parse : function (s) { var time, data = s.match(this.regex); if (!data || !data.length) { return null; } time = utils.buildTimeObjectFromData(data); if (!time.year || (!time.year && (!time.month && !time.day) && (!time.week && !time.dayOfYear)) ) { return null; } return $P.processTimeObject(time); } }; $P.Numeric = { isNumeric: function (e){return!isNaN(parseFloat(e))&&isFinite(e);}, regex: /\b([0-1]?[0-9])([0-3]?[0-9])([0-2]?[0-9]?[0-9][0-9])\b/i, parse: function (s) { var data, i, time = {}, order = Date.CultureInfo.dateElementOrder.split(""); if (!(this.isNumeric(s)) || // if it's non-numeric OR (s[0] === "+" && s[0] === "-")) { // It's an arithmatic string (eg +/-1000) return null; } if (s.length < 5 && s.indexOf(".") < 0 && s.indexOf("/") < 0) { // assume it's just a year. time.year = s; return $P.processTimeObject(time); } data = s.match(this.regex); if (!data || !data.length) { return null; } for (i=0; i < order.length; i++) { switch(order[i]) { case "d": time.day = data[i+1]; break; case "m": time.month = (data[i+1]-1); break; case "y": time.year = data[i+1]; break; } } return $P.processTimeObject(time); } }; $P.Normalizer = { regexData: function () { var $R = Date.CultureInfo.regexPatterns; return utils.buildRegexData([ $R.tomorrow, $R.yesterday, [$R.past, $R.mon], [$R.past, $R.tue], [$R.past, $R.wed], [$R.past, $R.thu], [$R.past, $R.fri], [$R.past, $R.sat], [$R.past, $R.sun] ]); }, basicReplaceHash : function() { var $R = Date.CultureInfo.regexPatterns; return { "January": $R.jan.source, "February": $R.feb, "March": $R.mar, "April": $R.apr, "May": $R.may, "June": $R.jun, "July": $R.jul, "August": $R.aug, "September": $R.sep, "October": $R.oct, "November": $R.nov, "December": $R.dec, "": /\bat\b/gi, " ": /\s{2,}/, "am": $R.inTheMorning, "9am": $R.thisMorning, "pm": $R.inTheEvening, "7pm":$R.thisEvening }; }, keys : function(){ return [ utils.getDateNthString(true, false, 1), // tomorrow utils.getDateNthString(true, false, -1), // yesterday utils.getDateNthString(false, true, "monday"), //last mon utils.getDateNthString(false, true, "tuesday"), //last tues utils.getDateNthString(false, true, "wednesday"), //last wed utils.getDateNthString(false, true, "thursday"), //last thurs utils.getDateNthString(false, true, "friday"), //last fri utils.getDateNthString(false, true, "saturday"), //last sat utils.getDateNthString(false, true, "sunday") //last sun ]; }, buildRegexFunctions: function () { var $R = Date.CultureInfo.regexPatterns; var __ = Date.i18n.__; var tomorrowRE = new RegExp("(\\b\\d\\d?("+__("AM")+"|"+__("PM")+")? )("+$R.tomorrow.source.slice(1)+")", "i"); // adapted tomorrow regex for AM PM relative dates var todayRE = new RegExp($R.today.source + "(?!\\s*([+-]))\\b"); // today, but excludes the math operators (eg "today + 2h") this.replaceFuncs = [ [todayRE, function (full) { return (full.length > 1) ? Date.today().toString("d") : full; }], [tomorrowRE, function(full, m1) { var t = Date.today().addDays(1).toString("d"); return (t + " " + m1); }], [$R.amThisMorning, function(str, am){return am;}], [$R.pmThisEvening, function(str, pm){return pm;}] ]; }, buildReplaceData: function () { this.buildRegexFunctions(); this.replaceHash = utils.addToHash(this.basicReplaceHash(), this.keys(), this.regexData()); }, stringReplaceFuncs: function (s) { for (var i=0; i < this.replaceFuncs.length; i++) { s = s.replace(this.replaceFuncs[i][0], this.replaceFuncs[i][1]); } return s; }, parse: function (s) { s = this.stringReplaceFuncs(s); s = utils.multiReplace(s, this.replaceHash); try { var n = s.split(/([\s\-\.\,\/\x27]+)/); if (n.length === 3 && $P.Numeric.isNumeric(n[0]) && $P.Numeric.isNumeric(n[2]) && (n[2].length >= 4)) { // ok, so we're dealing with x/year. But that's not a full date. // This fixes wonky dateElementOrder parsing when set to dmy order. if (Date.CultureInfo.dateElementOrder[0] === "d") { s = "1/" + n[0] + "/" + n[2]; // set to 1st of month and normalize the seperator } } } catch (e) {} return s; } }; $P.Normalizer.buildReplaceData(); }()); (function () { var $P = Date.Parsing; var _ = $P.Operators = { // // Tokenizers // rtoken: function (r) { // regex token return function (s) { var mx = s.match(r); if (mx) { return ([ mx[0], s.substring(mx[0].length) ]); } else { throw new $P.Exception(s); } }; }, token: function () { // whitespace-eating token return function (s) { return _.rtoken(new RegExp("^\\s*" + s + "\\s*"))(s); }; }, stoken: function (s) { // string token return _.rtoken(new RegExp("^" + s)); }, // Atomic Operators until: function (p) { return function (s) { var qx = [], rx = null; while (s.length) { try { rx = p.call(this, s); } catch (e) { qx.push(rx[0]); s = rx[1]; continue; } break; } return [ qx, s ]; }; }, many: function (p) { return function (s) { var rx = [], r = null; while (s.length) { try { r = p.call(this, s); } catch (e) { return [ rx, s ]; } rx.push(r[0]); s = r[1]; } return [ rx, s ]; }; }, // generator operators -- see below optional: function (p) { return function (s) { var r = null; try { r = p.call(this, s); } catch (e) { return [ null, s ]; } return [ r[0], r[1] ]; }; }, not: function (p) { return function (s) { try { p.call(this, s); } catch (e) { return [null, s]; } throw new $P.Exception(s); }; }, ignore: function (p) { return p ? function (s) { var r = null; r = p.call(this, s); return [null, r[1]]; } : null; }, product: function () { var px = arguments[0], qx = Array.prototype.slice.call(arguments, 1), rx = []; for (var i = 0 ; i < px.length ; i++) { rx.push(_.each(px[i], qx)); } return rx; }, cache: function (rule) { var cache = {}, cache_length = 0, cache_keys = [], CACHE_MAX = Date.Config.CACHE_MAX || 100000, r = null; var cacheCheck = function () { if (cache_length === CACHE_MAX) { // kill several keys, don't want to have to do this all the time... for (var i=0; i < 10; i++) { var key = cache_keys.shift(); if (key) { delete cache[key]; cache_length--; } } } }; return function (s) { cacheCheck(); try { r = cache[s] = (cache[s] || rule.call(this, s)); } catch (e) { r = cache[s] = e; } cache_length++; cache_keys.push(s); if (r instanceof $P.Exception) { throw r; } else { return r; } }; }, // vector operators -- see below any: function () { var px = arguments; return function (s) { var r = null; for (var i = 0; i < px.length; i++) { if (px[i] == null) { continue; } try { r = (px[i].call(this, s)); } catch (e) { r = null; } if (r) { return r; } } throw new $P.Exception(s); }; }, each: function () { var px = arguments; return function (s) { var rx = [], r = null; for (var i = 0; i < px.length ; i++) { if (px[i] == null) { continue; } try { r = (px[i].call(this, s)); } catch (e) { throw new $P.Exception(s); } rx.push(r[0]); s = r[1]; } return [ rx, s]; }; }, all: function () { var px = arguments, _ = _; return _.each(_.optional(px)); }, // delimited operators sequence: function (px, d, c) { d = d || _.rtoken(/^\s*/); c = c || null; if (px.length === 1) { return px[0]; } return function (s) { var r = null, q = null; var rx = []; for (var i = 0; i < px.length ; i++) { try { r = px[i].call(this, s); } catch (e) { break; } rx.push(r[0]); try { q = d.call(this, r[1]); } catch (ex) { q = null; break; } s = q[1]; } if (!r) { throw new $P.Exception(s); } if (q) { throw new $P.Exception(q[1]); } if (c) { try { r = c.call(this, r[1]); } catch (ey) { throw new $P.Exception(r[1]); } } return [ rx, (r?r[1]:s) ]; }; }, // // Composite Operators // between: function (d1, p, d2) { d2 = d2 || d1; var _fn = _.each(_.ignore(d1), p, _.ignore(d2)); return function (s) { var rx = _fn.call(this, s); return [[rx[0][0], r[0][2]], rx[1]]; }; }, list: function (p, d, c) { d = d || _.rtoken(/^\s*/); c = c || null; return (p instanceof Array ? _.each(_.product(p.slice(0, -1), _.ignore(d)), p.slice(-1), _.ignore(c)) : _.each(_.many(_.each(p, _.ignore(d))), px, _.ignore(c))); }, set: function (px, d, c) { d = d || _.rtoken(/^\s*/); c = c || null; return function (s) { // r is the current match, best the current 'best' match // which means it parsed the most amount of input var r = null, p = null, q = null, rx = null, best = [[], s], last = false; // go through the rules in the given set for (var i = 0; i < px.length ; i++) { // last is a flag indicating whether this must be the last element // if there is only 1 element, then it MUST be the last one q = null; p = null; r = null; last = (px.length === 1); // first, we try simply to match the current pattern // if not, try the next pattern try { r = px[i].call(this, s); } catch (e) { continue; } // since we are matching against a set of elements, the first // thing to do is to add r[0] to matched elements rx = [[r[0]], r[1]]; // if we matched and there is still input to parse and // we don't already know this is the last element, // we're going to next check for the delimiter ... // if there's none, or if there's no input left to parse // than this must be the last element after all ... if (r[1].length > 0 && ! last) { try { q = d.call(this, r[1]); } catch (ex) { last = true; } } else { last = true; } // if we parsed the delimiter and now there's no more input, // that means we shouldn't have parsed the delimiter at all // so don't update r and mark this as the last element ... if (!last && q[1].length === 0) { last = true; } // so, if this isn't the last element, we're going to see if // we can get any more matches from the remaining (unmatched) // elements ... if (!last) { // build a list of the remaining rules we can match against, // i.e., all but the one we just matched against var qx = []; for (var j = 0; j < px.length ; j++) { if (i !== j) { qx.push(px[j]); } } // now invoke recursively set with the remaining input // note that we don't include the closing delimiter ... // we'll check for that ourselves at the end p = _.set(qx, d).call(this, q[1]); // if we got a non-empty set as a result ... // (otw rx already contains everything we want to match) if (p[0].length > 0) { // update current result, which is stored in rx ... // basically, pick up the remaining text from p[1] // and concat the result from p[0] so that we don't // get endless nesting ... rx[0] = rx[0].concat(p[0]); rx[1] = p[1]; } } // at this point, rx either contains the last matched element // or the entire matched set that starts with this element. // now we just check to see if this variation is better than // our best so far, in terms of how much of the input is parsed if (rx[1].length < best[1].length) { best = rx; } // if we've parsed all the input, then we're finished if (best[1].length === 0) { break; } } // so now we've either gone through all the patterns trying them // as the initial match; or we found one that parsed the entire // input string ... // if best has no matches, just return empty set ... if (best[0].length === 0) { return best; } // if a closing delimiter is provided, then we have to check it also if (c) { // we try this even if there is no remaining input because the pattern // may well be optional or match empty input ... try { q = c.call(this, best[1]); } catch (ey) { throw new $P.Exception(best[1]); } // it parsed ... be sure to update the best match remaining input best[1] = q[1]; } // if we're here, either there was no closing delimiter or we parsed it // so now we have the best match; just return it! return best; }; }, forward: function (gr, fname) { return function (s) { return gr[fname].call(this, s); }; }, // // Translation Operators // replace: function (rule, repl) { return function (s) { var r = rule.call(this, s); return [repl, r[1]]; }; }, process: function (rule, fn) { return function (s) { var r = rule.call(this, s); return [fn.call(this, r[0]), r[1]]; }; }, min: function (min, rule) { return function (s) { var rx = rule.call(this, s); if (rx[0].length < min) { throw new $P.Exception(s); } return rx; }; } }; // Generator Operators And Vector Operators // Generators are operators that have a signature of F(R) => R, // taking a given rule and returning another rule, such as // ignore, which parses a given rule and throws away the result. // Vector operators are those that have a signature of F(R1,R2,...) => R, // take a list of rules and returning a new rule, such as each. // Generator operators are converted (via the following _generator // function) into functions that can also take a list or array of rules // and return an array of new rules as though the function had been // called on each rule in turn (which is what actually happens). // This allows generators to be used with vector operators more easily. // Example: // each(ignore(foo, bar)) instead of each(ignore(foo), ignore(bar)) // This also turns generators into vector operators, which allows // constructs like: // not(cache(foo, bar)) var _generator = function (op) { function gen() { var args = null, rx = [], px, i; if (arguments.length > 1) { args = Array.prototype.slice.call(arguments); } else if (arguments[0] instanceof Array) { args = arguments[0]; } if (args) { px = args.shift(); if (px.length > 0) { args.unshift(px[i]); rx.push(op.apply(null, args)); args.shift(); return rx; } } else { return op.apply(null, arguments); } } return gen; }; var gx = "optional not ignore cache".split(/\s/); for (var i = 0 ; i < gx.length ; i++) { _[gx[i]] = _generator(_[gx[i]]); } var _vector = function (op) { return function () { if (arguments[0] instanceof Array) { return op.apply(null, arguments[0]); } else { return op.apply(null, arguments); } }; }; var vx = "each any all".split(/\s/); for (var j = 0 ; j < vx.length ; j++) { _[vx[j]] = _vector(_[vx[j]]); } }()); (function () { var $D = Date; var flattenAndCompact = function (ax) { var rx = []; for (var i = 0; i < ax.length; i++) { if (ax[i] instanceof Array) { rx = rx.concat(flattenAndCompact(ax[i])); } else { if (ax[i]) { rx.push(ax[i]); } } } return rx; }; var parseMeridian = function () { if (this.meridian && (this.hour || this.hour === 0)) { if (this.meridian === "a" && this.hour > 11 && Date.Config.strict24hr){ throw "Invalid hour and meridian combination"; } else if (this.meridian === "p" && this.hour < 12 && Date.Config.strict24hr){ throw "Invalid hour and meridian combination"; } else if (this.meridian === "p" && this.hour < 12) { this.hour = this.hour + 12; } else if (this.meridian === "a" && this.hour === 12) { this.hour = 0; } } }; var setDefaults = function () { var now = new Date(); if ((this.hour || this.minute) && (!this.month && !this.year && !this.day)) { this.day = now.getDate(); } if (!this.year) { this.year = now.getFullYear(); } if (!this.month && this.month !== 0) { this.month = now.getMonth(); } if (!this.day) { this.day = 1; } if (!this.hour) { this.hour = 0; } if (!this.minute) { this.minute = 0; } if (!this.second) { this.second = 0; } if (!this.millisecond) { this.millisecond = 0; } }; var finishUtils = { getToday: function () { if (this.now || "hour minute second".indexOf(this.unit) !== -1) { return new Date(); } else { return $D.today(); } }, setDaysFromWeekday: function (today, orient){ var gap; orient = orient || 1; this.unit = "day"; gap = ($D.getDayNumberFromName(this.weekday) - today.getDay()); this.days = gap ? ((gap + (orient * 7)) % 7) : (orient * 7); return this; }, setMonthsFromMonth: function (today, orient) { var gap; orient = orient || 1; this.unit = "month"; gap = (this.month - today.getMonth()); this.months = gap ? ((gap + (orient * 12)) % 12) : (orient * 12); this.month = null; return this; }, setDMYFromWeekday: function () { var d = Date[this.weekday](); this.day = d.getDate(); if (!this.month) { this.month = d.getMonth(); } this.year = d.getFullYear(); return this; }, setUnitValue: function (orient) { if (!this.value && this.operator && this.operator !== null && this[this.unit + "s"] && this[this.unit + "s"] !== null) { this[this.unit + "s"] = this[this.unit + "s"] + ((this.operator === "add") ? 1 : -1) + (this.value||0) * orient; } else if (this[this.unit + "s"] == null || this.operator != null) { if (!this.value) { this.value = 1; } this[this.unit + "s"] = this.value * orient; } }, generateDateFromWeeks: function () { var weekday = (this.weekday !== undefined) ? this.weekday : "today"; var d = Date[weekday]().addWeeks(this.weeks); if (this.now) { d.setTimeToNow(); } return d; } }; $D.Translator = { hour: function (s) { return function () { this.hour = Number(s); }; }, minute: function (s) { return function () { this.minute = Number(s); }; }, second: function (s) { return function () { this.second = Number(s); }; }, /* for ss.s format */ secondAndMillisecond: function (s) { return function () { var mx = s.match(/^([0-5][0-9])\.([0-9]{1,3})/); this.second = Number(mx[1]); this.millisecond = Number(mx[2]); }; }, meridian: function (s) { return function () { this.meridian = s.slice(0, 1).toLowerCase(); }; }, timezone: function (s) { return function () { var n = s.replace(/[^\d\+\-]/g, ""); if (n.length) { this.timezoneOffset = Number(n); } else { this.timezone = s.toLowerCase(); } }; }, day: function (x) { var s = x[0]; return function () { this.day = Number(s.match(/\d+/)[0]); if (this.day < 1) { throw "invalid day"; } }; }, month: function (s) { return function () { this.month = (s.length === 3) ? "jan feb mar apr may jun jul aug sep oct nov dec".indexOf(s)/4 : Number(s) - 1; if (this.month < 0) { throw "invalid month"; } }; }, year: function (s) { return function () { var n = Number(s); this.year = ((s.length > 2) ? n : (n + (((n + 2000) < Date.CultureInfo.twoDigitYearMax) ? 2000 : 1900))); }; }, rday: function (s) { return function () { switch (s) { case "yesterday": this.days = -1; break; case "tomorrow": this.days = 1; break; case "today": this.days = 0; break; case "now": this.days = 0; this.now = true; break; } }; }, finishExact: function (x) { var d; x = (x instanceof Array) ? x : [x]; for (var i = 0 ; i < x.length ; i++) { if (x[i]) { x[i].call(this); } } setDefaults.call(this); parseMeridian.call(this); if (this.day > $D.getDaysInMonth(this.year, this.month)) { throw new RangeError(this.day + " is not a valid value for days."); } d = new Date(this.year, this.month, this.day, this.hour, this.minute, this.second, this.millisecond); if (this.year < 100) { d.setFullYear(this.year); // means years less that 100 are process correctly. JS will parse it otherwise as 1900-1999. } if (this.timezone) { d.set({ timezone: this.timezone }); } else if (this.timezoneOffset) { d.set({ timezoneOffset: this.timezoneOffset }); } return d; }, finish: function (x) { var today, expression, orient, temp; x = (x instanceof Array) ? flattenAndCompact(x) : [ x ]; if (x.length === 0) { return null; } for (var i = 0 ; i < x.length ; i++) { if (typeof x[i] === "function") { x[i].call(this); } } if (this.now && !this.unit && !this.operator) { return new Date(); } else { today = finishUtils.getToday.call(this); } expression = !!(this.days && this.days !== null || this.orient || this.operator); orient = ((this.orient === "past" || this.operator === "subtract") ? -1 : 1); if (this.month && this.unit === "week") { this.value = this.month + 1; delete this.month; delete this.day; } if ((this.month || this.month === 0) && "year day hour minute second".indexOf(this.unit) !== -1) { if (!this.value) { this.value = this.month + 1; } this.month = null; expression = true; } if (!expression && this.weekday && !this.day && !this.days) { finishUtils.setDMYFromWeekday.call(this); } if (expression && this.weekday && this.unit !== "month" && this.unit !== "week") { finishUtils.setDaysFromWeekday.call(this, today, orient); } if (this.weekday && this.unit !== "week" && !this.day && !this.days) { temp = Date[this.weekday](); this.day = temp.getDate(); if (temp.getMonth() !== today.getMonth()) { this.month = temp.getMonth(); } } if (this.month && this.unit === "day" && this.operator) { if (!this.value) { this.value = (this.month + 1); } this.month = null; } if (this.value != null && this.month != null && this.year != null) { this.day = this.value * 1; } if (this.month && !this.day && this.value) { today.set({ day: this.value * 1 }); if (!expression) { this.day = this.value * 1; } } if (!this.month && this.value && this.unit === "month" && !this.now) { this.month = this.value; expression = true; } if (expression && (this.month || this.month === 0) && this.unit !== "year") { finishUtils.setMonthsFromMonth.call(this, today, orient); } if (!this.unit) { this.unit = "day"; } finishUtils.setUnitValue.call(this, orient); parseMeridian.call(this); if ((this.month || this.month === 0) && !this.day) { this.day = 1; } if (!this.orient && !this.operator && this.unit === "week" && this.value && !this.day && !this.month) { return Date.today().setWeek(this.value); } if (this.unit === "week" && this.weeks && !this.day && !this.month) { return finishUtils.generateDateFromWeeks.call(this); } if (expression && this.timezone && this.day && this.days) { this.day = this.days; } if (expression){ today.add(this); } else { today.set(this); } if (this.timezone) { this.timezone = this.timezone.toUpperCase(); var offset = $D.getTimezoneOffset(this.timezone); var timezone; if (today.hasDaylightSavingTime()) { // lets check that we're being sane with timezone setting timezone = $D.getTimezoneAbbreviation(offset, today.isDaylightSavingTime()); if (timezone !== this.timezone) { // bugger, we're in a place where things like EST vs EDT matters. if (today.isDaylightSavingTime()) { today.addHours(-1); } else { today.addHours(1); } } } today.setTimezoneOffset(offset); } return today; } }; }()); (function () { var $D = Date; $D.Grammar = {}; var _ = $D.Parsing.Operators, g = $D.Grammar, t = $D.Translator, _fn; // Allow rolling up into general purpose rules _fn = function () { return _.each(_.any.apply(null, arguments), _.not(g.ctoken2("timeContext"))); }; g.datePartDelimiter = _.rtoken(/^([\s\-\.\,\/\x27]+)/); g.timePartDelimiter = _.stoken(":"); g.whiteSpace = _.rtoken(/^\s*/); g.generalDelimiter = _.rtoken(/^(([\s\,]|at|@|on)+)/); var _C = {}; g.ctoken = function (keys) { var fn = _C[keys]; if (! fn) { var c = Date.CultureInfo.regexPatterns; var kx = keys.split(/\s+/), px = []; for (var i = 0; i < kx.length ; i++) { px.push(_.replace(_.rtoken(c[kx[i]]), kx[i])); } fn = _C[keys] = _.any.apply(null, px); } return fn; }; g.ctoken2 = function (key) { return _.rtoken(Date.CultureInfo.regexPatterns[key]); }; var cacheProcessRtoken = function (key, token, type, eachToken) { if (eachToken) { g[key] = _.cache(_.process(_.each(_.rtoken(token),_.optional(g.ctoken2(eachToken))), type)); } else { g[key] = _.cache(_.process(_.rtoken(token), type)); } }; var cacheProcessCtoken = function (token, type) { return _.cache(_.process(g.ctoken2(token), type)); }; var _F = {}; //function cache var _get = function (f) { _F[f] = (_F[f] || g.format(f)[0]); return _F[f]; }; g.allformats = function (fx) { var rx = []; if (fx instanceof Array) { for (var i = 0; i < fx.length; i++) { rx.push(_get(fx[i])); } } else { rx.push(_get(fx)); } return rx; }; g.formats = function (fx) { if (fx instanceof Array) { var rx = []; for (var i = 0 ; i < fx.length ; i++) { rx.push(_get(fx[i])); } return _.any.apply(null, rx); } else { return _get(fx); } }; var grammarFormats = { timeFormats: function(){ var i, RTokenKeys = [ "h", "hh", "H", "HH", "m", "mm", "s", "ss", "ss.s", "z", "zz" ], RToken = [ /^(0[0-9]|1[0-2]|[1-9])/, /^(0[0-9]|1[0-2])/, /^([0-1][0-9]|2[0-3]|[0-9])/, /^([0-1][0-9]|2[0-3])/, /^([0-5][0-9]|[0-9])/, /^[0-5][0-9]/, /^([0-5][0-9]|[0-9])/, /^[0-5][0-9]/, /^[0-5][0-9]\.[0-9]{1,3}/, /^((\+|\-)\s*\d\d\d\d)|((\+|\-)\d\d\:?\d\d)/, /^((\+|\-)\s*\d\d\d\d)|((\+|\-)\d\d\:?\d\d)/ ], tokens = [ t.hour, t.hour, t.hour, t.hour, t.minute, t.minute, t.second, t.second, t.secondAndMillisecond, t.timezone, t.timezone ]; for (i=0; i < RTokenKeys.length; i++) { cacheProcessRtoken(RTokenKeys[i], RToken[i], tokens[i]); } g.hms = _.cache(_.sequence([g.H, g.m, g.s], g.timePartDelimiter)); g.t = cacheProcessCtoken("shortMeridian", t.meridian); g.tt = cacheProcessCtoken("longMeridian", t.meridian); g.zzz = cacheProcessCtoken("timezone", t.timezone); g.timeSuffix = _.each(_.ignore(g.whiteSpace), _.set([ g.tt, g.zzz ])); g.time = _.each(_.optional(_.ignore(_.stoken("T"))), g.hms, g.timeSuffix); }, dateFormats: function () { // pre-loaded rules for different date part order preferences var _setfn = function () { return _.set(arguments, g.datePartDelimiter); }; var i, RTokenKeys = [ "d", "dd", "M", "MM", "y", "yy", "yyy", "yyyy" ], RToken = [ /^([0-2]\d|3[0-1]|\d)/, /^([0-2]\d|3[0-1])/, /^(1[0-2]|0\d|\d)/, /^(1[0-2]|0\d)/, /^(\d+)/, /^(\d\d)/, /^(\d\d?\d?\d?)/, /^(\d\d\d\d)/ ], tokens = [ t.day, t.day, t.month, t.month, t.year, t.year, t.year, t.year ], eachToken = [ "ordinalSuffix", "ordinalSuffix" ]; for (i=0; i < RTokenKeys.length; i++) { cacheProcessRtoken(RTokenKeys[i], RToken[i], tokens[i], eachToken[i]); } g.MMM = g.MMMM = _.cache(_.process(g.ctoken("jan feb mar apr may jun jul aug sep oct nov dec"), t.month)); g.ddd = g.dddd = _.cache(_.process(g.ctoken("sun mon tue wed thu fri sat"), function (s) { return function () { this.weekday = s; }; } )); g.day = _fn(g.d, g.dd); g.month = _fn(g.M, g.MMM); g.year = _fn(g.yyyy, g.yy); g.mdy = _setfn(g.ddd, g.month, g.day, g.year); g.ymd = _setfn(g.ddd, g.year, g.month, g.day); g.dmy = _setfn(g.ddd, g.day, g.month, g.year); g.date = function (s) { return ((g[Date.CultureInfo.dateElementOrder] || g.mdy).call(this, s)); }; }, relative: function () { // relative date / time expressions g.orientation = _.process(g.ctoken("past future"), function (s) { return function () { this.orient = s; }; } ); g.operator = _.process(g.ctoken("add subtract"), function (s) { return function () { this.operator = s; }; } ); g.rday = _.process(g.ctoken("yesterday tomorrow today now"), t.rday); g.unit = _.process(g.ctoken("second minute hour day week month year"), function (s) { return function () { this.unit = s; }; } ); } }; g.buildGrammarFormats = function () { // these need to be rebuilt every time the language changes. _C = {}; grammarFormats.timeFormats(); grammarFormats.dateFormats(); grammarFormats.relative(); g.value = _.process(_.rtoken(/^([-+]?\d+)?(st|nd|rd|th)?/), function (s) { return function () { this.value = s.replace(/\D/g, ""); }; } ); g.expression = _.set([g.rday, g.operator, g.value, g.unit, g.orientation, g.ddd, g.MMM ]); g.format = _.process(_.many( _.any( // translate format specifiers into grammar rules _.process( _.rtoken(/^(dd?d?d?(?!e)|MM?M?M?|yy?y?y?|hh?|HH?|mm?|ss?|tt?|zz?z?)/), function (fmt) { if (g[fmt]) { return g[fmt]; } else { throw $D.Parsing.Exception(fmt); } } ), // translate separator tokens into token rules _.process(_.rtoken(/^[^dMyhHmstz]+/), // all legal separators function (s) { return _.ignore(_.stoken(s)); } ) ) ), // construct the parser ... function (rules) { return _.process(_.each.apply(null, rules), t.finishExact); } ); // starting rule for general purpose grammar g._start = _.process(_.set([ g.date, g.time, g.expression ], g.generalDelimiter, g.whiteSpace), t.finish); }; g.buildGrammarFormats(); // parsing date format specifiers - ex: "h:m:s tt" // this little guy will generate a custom parser based // on the format string, ex: g.format("h:m:s tt") // check for these formats first g._formats = g.formats([ "\"yyyy-MM-ddTHH:mm:ssZ\"", "yyyy-MM-ddTHH:mm:ss.sz", "yyyy-MM-ddTHH:mm:ssZ", "yyyy-MM-ddTHH:mm:ssz", "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-ddTHH:mmZ", "yyyy-MM-ddTHH:mmz", "yyyy-MM-ddTHH:mm", "ddd, MMM dd, yyyy H:mm:ss tt", "ddd MMM d yyyy HH:mm:ss zzz", "MMddyyyy", "ddMMyyyy", "Mddyyyy", "ddMyyyy", "Mdyyyy", "dMyyyy", "yyyy", "Mdyy", "dMyy", "d" ]); // real starting rule: tries selected formats first, // then general purpose rule g.start = function (s) { try { var r = g._formats.call({}, s); if (r[1].length === 0) { return r; } } catch (e) {} return g._start.call({}, s); }; }()); (function () { var $D = Date; /** * @desc Converts the specified string value into its JavaScript Date equivalent using CultureInfo specific format information. * * Example

	///////////
	// Dates //
	///////////

	// 15-Oct-2004
	var d1 = Date.parse("10/15/2004");

	// 15-Oct-2004
	var d1 = Date.parse("15-Oct-2004");

	// 15-Oct-2004
	var d1 = Date.parse("2004.10.15");

	//Fri Oct 15, 2004
	var d1 = Date.parse("Fri Oct 15, 2004");

	///////////
	// Times //
	///////////

	// Today at 10 PM.
	var d1 = Date.parse("10 PM");

	// Today at 10:30 PM.
	var d1 = Date.parse("10:30 P.M.");

	// Today at 6 AM.
	var d1 = Date.parse("06am");

	/////////////////////
	// Dates and Times //
	/////////////////////

	// 8-July-2004 @ 10:30 PM
	var d1 = Date.parse("July 8th, 2004, 10:30 PM");

	// 1-July-2004 @ 10:30 PM
	var d1 = Date.parse("2004-07-01T22:30:00");

	////////////////////
	// Relative Dates //
	////////////////////

	// Returns today's date. The string "today" is culture specific.
	var d1 = Date.parse("today");

	// Returns yesterday's date. The string "yesterday" is culture specific.
	var d1 = Date.parse("yesterday");

	// Returns the date of the next thursday.
	var d1 = Date.parse("Next thursday");

	// Returns the date of the most previous monday.
	var d1 = Date.parse("last monday");

	// Returns today's day + one year.
	var d1 = Date.parse("next year");

	///////////////
	// Date Math //
	///////////////

	// Today + 2 days
	var d1 = Date.parse("t+2");

	// Today + 2 days
	var d1 = Date.parse("today + 2 days");

	// Today + 3 months
	var d1 = Date.parse("t+3m");

	// Today - 1 year
	var d1 = Date.parse("today - 1 year");

	// Today - 1 year
	var d1 = Date.parse("t-1y"); 


	/////////////////////////////
	// Partial Dates and Times //
	/////////////////////////////

	// July 15th of this year.
	var d1 = Date.parse("July 15");

	// 15th day of current day and year.
	var d1 = Date.parse("15");

	// July 1st of current year at 10pm.
	var d1 = Date.parse("7/1 10pm");
	
* * @param {String} The string value to convert into a Date object [Required] * @return {Date} A Date object or null if the string cannot be converted into a Date. */ var parseUtils = { removeOrds: function (s) { ords = s.match(/\b(\d+)(?:st|nd|rd|th)\b/); // find ordinal matches s = ((ords && ords.length === 2) ? s.replace(ords[0], ords[1]) : s); return s; }, grammarParser: function (s) { var r = null; try { r = $D.Grammar.start.call({}, s.replace(/^\s*(\S*(\s+\S+)*)\s*$/, "$1")); } catch (e) { return null; } return ((r[1].length === 0) ? r[0] : null); }, nativeFallback: function(s) { var t; try { // ok we haven't parsed it, last ditch attempt with the built-in parser. t = Date._parse(s); return (t || t === 0) ? new Date(t) : null; } catch (e) { return null; } } }; function parse (s) { var d; if (!s) { return null; } if (s instanceof Date) { return s.clone(); } if (s.length >= 4 && s.charAt(0) !== "0" && s.charAt(0) !== "+"&& s.charAt(0) !== "-") { // ie: 2004 will pass, 0800 won't. // Start with specific formats d = $D.Parsing.ISO.parse(s) || $D.Parsing.Numeric.parse(s); } if (d instanceof Date && !isNaN(d.getTime())) { return d; } else { // find ordinal dates (1st, 3rd, 8th, etc and remove them as they cause parsing issues) s = $D.Parsing.Normalizer.parse(parseUtils.removeOrds(s)); d = parseUtils.grammarParser(s); if (d !== null) { return d; } else { return parseUtils.nativeFallback(s); } } } if (!$D._parse) { $D._parse = $D.parse; } $D.parse = parse; Date.getParseFunction = function (fx) { var fns = Date.Grammar.allformats(fx); return function (s) { var r = null; for (var i = 0; i < fns.length; i++) { try { r = fns[i].call({}, s); } catch (e) { continue; } if (r[1].length === 0) { return r[0]; } } return null; }; }; /** * Converts the specified string value into its JavaScript Date equivalent using the specified format {String} or formats {Array} and the CultureInfo specific format information. * The format of the string value must match one of the supplied formats exactly. * * Example

	// 15-Oct-2004
	var d1 = Date.parseExact("10/15/2004", "M/d/yyyy");

	// 15-Oct-2004
	var d1 = Date.parse("15-Oct-2004", "M-ddd-yyyy");

	// 15-Oct-2004
	var d1 = Date.parse("2004.10.15", "yyyy.MM.dd");

	// Multiple formats
	var d1 = Date.parseExact("10/15/2004", ["M/d/yyyy", "MMMM d, yyyy"]);
	
* * @param {String} The string value to convert into a Date object [Required]. * @param {Object} The expected format {String} or an array of expected formats {Array} of the date string [Required]. * @return {Date} A Date object or null if the string cannot be converted into a Date. */ $D.parseExact = function (s, fx) { return $D.getParseFunction(fx)(s); }; }()); (function () { var $D = Date, $P = $D.prototype, // $C = $D.CultureInfo, // not used atm p = function (s, l) { if (!l) { l = 2; } return ("000" + s).slice(l * -1); }; /** * Converts a PHP format string to Java/.NET format string. * A PHP format string can be used with ._format or .format. * A Java/.NET format string can be used with .toString(). * The .parseExact function will only accept a Java/.NET format string * * Example * var f1 = "%m/%d/%y" * var f2 = Date.normalizeFormat(f1); // "MM/dd/yy" * * new Date().format(f1); // "04/13/08" * new Date()._format(f1); // "04/13/08" * new Date().toString(f2); // "04/13/08" * * var date = Date.parseExact("04/13/08", f2); // Sun Apr 13 2008 * * @param {String} A PHP format string consisting of one or more format spcifiers. * @return {String} The PHP format converted to a Java/.NET format string. */ var normalizerSubstitutions = { "d" : "dd", "%d": "dd", "D" : "ddd", "%a": "ddd", "j" : "dddd", "l" : "dddd", "%A": "dddd", "S" : "S", "F" : "MMMM", "%B": "MMMM", "m" : "MM", "%m": "MM", "M" : "MMM", "%b": "MMM", "%h": "MMM", "n" : "M", "Y" : "yyyy", "%Y": "yyyy", "y" : "yy", "%y": "yy", "g" : "h", "%I": "h", "G" : "H", "h" : "hh", "H" : "HH", "%H": "HH", "i" : "mm", "%M": "mm", "s" : "ss", "%S": "ss", "%r": "hh:mm tt", "%R": "H:mm", "%T": "H:mm:ss", "%X": "t", "%x": "d", "%e": "d", "%D": "MM/dd/yy", "%n": "\\n", "%t": "\\t", "e" : "z", "T" : "z", "%z": "z", "%Z": "z", "Z" : "ZZ", "N" : "u", "w" : "u", "%w": "u", "W" : "W", "%V": "W" }; var normalizer = { substitutes: function (m) { return normalizerSubstitutions[m]; }, interpreted: function (m, x) { var y; switch (m) { case "%u": return x.getDay() + 1; case "z": return x.getOrdinalNumber(); case "%j": return p(x.getOrdinalNumber(), 3); case "%U": var d1 = x.clone().set({month: 0, day: 1}).addDays(-1).moveToDayOfWeek(0), d2 = x.clone().addDays(1).moveToDayOfWeek(0, -1); return (d2 < d1) ? "00" : p((d2.getOrdinalNumber() - d1.getOrdinalNumber()) / 7 + 1); case "%W": return p(x.getWeek()); case "t": return $D.getDaysInMonth(x.getFullYear(), x.getMonth()); case "o": case "%G": return x.setWeek(x.getISOWeek()).toString("yyyy"); case "%g": return x._format("%G").slice(-2); case "a": case "%p": return t("tt").toLowerCase(); case "A": return t("tt").toUpperCase(); case "u": return p(x.getMilliseconds(), 3); case "I": return (x.isDaylightSavingTime()) ? 1 : 0; case "O": return x.getUTCOffset(); case "P": y = x.getUTCOffset(); return y.substring(0, y.length - 2) + ":" + y.substring(y.length - 2); case "B": var now = new Date(); return Math.floor(((now.getHours() * 3600) + (now.getMinutes() * 60) + now.getSeconds() + (now.getTimezoneOffset() + 60) * 60) / 86.4); case "c": return x.toISOString().replace(/\"/g, ""); case "U": return $D.strtotime("now"); case "%c": return t("d") + " " + t("t"); case "%C": return Math.floor(x.getFullYear() / 100 + 1); } }, shouldOverrideDefaults: function (m) { switch (m) { case "%e": return true; default: return false; } }, parse: function (m, context) { var formatString, c = context || new Date(); formatString = normalizer.substitutes(m); if (formatString) { return formatString; } formatString = normalizer.interpreted(m, c); if (formatString) { return formatString; } else { return m; } } }; $D.normalizeFormat = function (format, context) { return format.replace(/(%|\\)?.|%%/g, function(t){ return normalizer.parse(t, context); }); }; /** * Format a local Unix timestamp according to locale settings * * Example: * Date.strftime("%m/%d/%y", new Date()); // "04/13/08" * Date.strftime("c", "2008-04-13T17:52:03Z"); // "04/13/08" * * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @param {Number|String} The number representing the number of seconds that have elapsed since January 1, 1970 (local time). * @return {String} A string representation of the current Date object. */ $D.strftime = function (format, time) { var d = Date.parse(time); return d._format(format); }; /** * Parse any textual datetime description into a Unix timestamp. * A Unix timestamp is the number of seconds that have elapsed since January 1, 1970 (midnight UTC/GMT). * * Example: * Date.strtotime("04/13/08"); // 1208044800 * Date.strtotime("1970-01-01T00:00:00Z"); // 0 * * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @param {Object} A string or date object. * @return {String} A string representation of the current Date object. */ $D.strtotime = function (time) { var d = $D.parse(time); return Math.round($D.UTC(d.getUTCFullYear(), d.getUTCMonth(), d.getUTCDate(), d.getUTCHours(), d.getUTCMinutes(), d.getUTCSeconds(), d.getUTCMilliseconds()) / 1000); }; /** * Converts the value of the current Date object to its equivalent string representation using a PHP/Unix style of date format specifiers. * Format Specifiers * Format Description Example * ------ --------------------------------------------------------------------------- ----------------------- * %a abbreviated weekday name according to the current localed "Mon" through "Sun" * %A full weekday name according to the current localed "Sunday" through "Saturday" * %b abbreviated month name according to the current localed "Jan" through "Dec" * %B full month name according to the current locale "January" through "December" * %c preferred date and time representation for the current locale "4/13/2008 12:33 PM" * %C century number (the year divided by 100 and truncated to an integer) "00" to "99" * %d day of the month as a decimal number "01" to "31" * %D same as %m/%d/%y "04/13/08" * %e day of the month as a decimal number, a single digit is preceded by a space "1" to "31" * %g like %G, but without the century "08" * %G The 4-digit year corresponding to the ISO week number (see %V). "2008" * This has the same format and value as %Y, except that if the ISO week number * belongs to the previous or next year, that year is used instead. * %h same as %b "Jan" through "Dec" * %H hour as a decimal number using a 24-hour clock. "00" to "23" * %I hour as a decimal number using a 12-hour clock. "01" to "12" * %j day of the year as a decimal number. "001" to "366" * %m month as a decimal number. "01" to "12" * %M minute as a decimal number. "00" to "59" * %n newline character "\n" * %p either "am" or "pm" according to the given time value, or the "am" or "pm" * corresponding strings for the current locale. * %r time in a.m. and p.m. notation "8:44 PM" * %R time in 24 hour notation "20:44" * %S second as a decimal number "00" to "59" * %t tab character "\t" * %T current time, equal to %H:%M:%S "12:49:11" * %u weekday as a decimal number ["1", "7"], with "1" representing Monday "1" to "7" * %U week number of the current year as a decimal number, starting with the "0" to ("52" or "53") * first Sunday as the first day of the first week * %V The ISO 8601:1988 week number of the current year as a decimal number, "00" to ("52" or "53") * range 01 to 53, where week 1 is the first week that has at least 4 days * in the current year, and with Monday as the first day of the week. * (Use %G or %g for the year component that corresponds to the week number * for the specified timestamp.) * %W week number of the current year as a decimal number, starting with the "00" to ("52" or "53") * first Monday as the first day of the first week * %w day of the week as a decimal, Sunday being "0" "0" to "6" * %x preferred date representation for the current locale without the time "4/13/2008" * %X preferred time representation for the current locale without the date "12:53:05" * %y year as a decimal number without a century "00" "99" * %Y year as a decimal number including the century "2008" * %Z time zone or name or abbreviation "UTC", "EST", "PST" * %z same as %Z * %% a literal "%" characters "%" * d Day of the month, 2 digits with leading zeros "01" to "31" * D A textual representation of a day, three letters "Mon" through "Sun" * j Day of the month without leading zeros "1" to "31" * l A full textual representation of the day of the week (lowercase "L") "Sunday" through "Saturday" * N ISO-8601 numeric representation of the day of the week (added in PHP 5.1.0) "1" (for Monday) through "7" (for Sunday) * S English ordinal suffix for the day of the month, 2 characters "st", "nd", "rd" or "th". Works well with j * w Numeric representation of the day of the week "0" (for Sunday) through "6" (for Saturday) * z The day of the year (starting from "0") "0" through "365" * W ISO-8601 week number of year, weeks starting on Monday "00" to ("52" or "53") * F A full textual representation of a month, such as January or March "January" through "December" * m Numeric representation of a month, with leading zeros "01" through "12" * M A short textual representation of a month, three letters "Jan" through "Dec" * n Numeric representation of a month, without leading zeros "1" through "12" * t Number of days in the given month "28" through "31" * L Whether it's a leap year "1" if it is a leap year, "0" otherwise * o ISO-8601 year number. This has the same value as Y, except that if the "2008" * ISO week number (W) belongs to the previous or next year, that year * is used instead. * Y A full numeric representation of a year, 4 digits "2008" * y A two digit representation of a year "08" * a Lowercase Ante meridiem and Post meridiem "am" or "pm" * A Uppercase Ante meridiem and Post meridiem "AM" or "PM" * B Swatch Internet time "000" through "999" * g 12-hour format of an hour without leading zeros "1" through "12" * G 24-hour format of an hour without leading zeros "0" through "23" * h 12-hour format of an hour with leading zeros "01" through "12" * H 24-hour format of an hour with leading zeros "00" through "23" * i Minutes with leading zeros "00" to "59" * s Seconds, with leading zeros "00" through "59" * u Milliseconds "54321" * e Timezone identifier "UTC", "EST", "PST" * I Whether or not the date is in daylight saving time (uppercase i) "1" if Daylight Saving Time, "0" otherwise * O Difference to Greenwich time (GMT) in hours "+0200", "-0600" * P Difference to Greenwich time (GMT) with colon between hours and minutes "+02:00", "-06:00" * T Timezone abbreviation "UTC", "EST", "PST" * Z Timezone offset in seconds. The offset for timezones west of UTC is "-43200" through "50400" * always negative, and for those east of UTC is always positive. * c ISO 8601 date "2004-02-12T15:19:21+00:00" * r RFC 2822 formatted date "Thu, 21 Dec 2000 16:01:07 +0200" * U Seconds since the Unix Epoch (January 1 1970 00:00:00 GMT) "0" * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @return {String} A string representation of the current Date object. */ var formatReplace = function (context) { return function (m) { var formatString, override = false; if (m.charAt(0) === "\\" || m.substring(0, 2) === "%%") { return m.replace("\\", "").replace("%%", "%"); } override = normalizer.shouldOverrideDefaults(m); formatString = $D.normalizeFormat(m, context); if (formatString) { return context.toString(formatString, override); } }; }; $P._format = function (format) { var formatter = formatReplace(this); if (!format) { return this._toString(); } else { return format.replace(/(%|\\)?.|%%/g, formatter); } }; if (!$P.format) { $P.format = $P._format; } }()); (function () { "use strict"; var gFn = function (attr) { return function () { return this[attr]; }; }; var sFn = function (attr) { return function (val) { this[attr] = val; return this; }; }; var attrs = ["years", "months", "days", "hours", "minutes", "seconds", "milliseconds"]; var addSetFuncs = function (context, attrs) { for (var i = 0; i < attrs.length ; i++) { var $a = attrs[i], $b = $a.slice(0, 1).toUpperCase() + $a.slice(1); context.prototype[$a] = 0; context.prototype["get" + $b] = gFn($a); context.prototype["set" + $b] = sFn($a); } }; /** * new TimeSpan(milliseconds); * new TimeSpan(days, hours, minutes, seconds); * new TimeSpan(days, hours, minutes, seconds, milliseconds); */ var TimeSpan = function (days, hours, minutes, seconds, milliseconds) { if (arguments.length === 1 && typeof days === "number") { var orient = (days < 0) ? -1 : +1; var millsLeft = Math.abs(days); this.setDays(Math.floor(millsLeft / 86400000) * orient); millsLeft = millsLeft % 86400000; this.setHours(Math.floor(millsLeft / 3600000) * orient); millsLeft = millsLeft % 3600000; this.setMinutes(Math.floor(millsLeft / 60000) * orient); millsLeft = millsLeft % 60000; this.setSeconds(Math.floor(millsLeft / 1000) * orient); millsLeft = millsLeft % 1000; this.setMilliseconds(millsLeft * orient); } else { this.set(days, hours, minutes, seconds, milliseconds); } this.getTotalMilliseconds = function () { return (this.getDays() * 86400000) + (this.getHours() * 3600000) + (this.getMinutes() * 60000) + (this.getSeconds() * 1000); }; this.compareTo = function (time) { var t1 = new Date(1970, 1, 1, this.getHours(), this.getMinutes(), this.getSeconds()), t2; if (time === null) { t2 = new Date(1970, 1, 1, 0, 0, 0); } else { t2 = new Date(1970, 1, 1, time.getHours(), time.getMinutes(), time.getSeconds()); } return (t1 < t2) ? -1 : (t1 > t2) ? 1 : 0; }; this.equals = function (time) { return (this.compareTo(time) === 0); }; this.add = function (time) { return (time === null) ? this : this.addSeconds(time.getTotalMilliseconds() / 1000); }; this.subtract = function (time) { return (time === null) ? this : this.addSeconds(-time.getTotalMilliseconds() / 1000); }; this.addDays = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 86400000)); }; this.addHours = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 3600000)); }; this.addMinutes = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 60000)); }; this.addSeconds = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 1000)); }; this.addMilliseconds = function (n) { return new TimeSpan(this.getTotalMilliseconds() + n); }; this.get12HourHour = function () { return (this.getHours() > 12) ? this.getHours() - 12 : (this.getHours() === 0) ? 12 : this.getHours(); }; this.getDesignator = function () { return (this.getHours() < 12) ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator; }; this.toString = function (format) { this._toString = function () { if (this.getDays() !== null && this.getDays() > 0) { return this.getDays() + "." + this.getHours() + ":" + this.p(this.getMinutes()) + ":" + this.p(this.getSeconds()); } else { return this.getHours() + ":" + this.p(this.getMinutes()) + ":" + this.p(this.getSeconds()); } }; this.p = function (s) { return (s.toString().length < 2) ? "0" + s : s; }; var me = this; return format ? format.replace(/dd?|HH?|hh?|mm?|ss?|tt?/g, function (format) { switch (format) { case "d": return me.getDays(); case "dd": return me.p(me.getDays()); case "H": return me.getHours(); case "HH": return me.p(me.getHours()); case "h": return me.get12HourHour(); case "hh": return me.p(me.get12HourHour()); case "m": return me.getMinutes(); case "mm": return me.p(me.getMinutes()); case "s": return me.getSeconds(); case "ss": return me.p(me.getSeconds()); case "t": return ((me.getHours() < 12) ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator).substring(0, 1); case "tt": return (me.getHours() < 12) ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator; } } ) : this._toString(); }; return this; }; addSetFuncs(TimeSpan, attrs.slice(2)); TimeSpan.prototype.set = function (days, hours, minutes, seconds, milliseconds){ this.setDays(days || this.getDays()); this.setHours(hours || this.getHours()); this.setMinutes(minutes || this.getMinutes()); this.setSeconds(seconds || this.getSeconds()); this.setMilliseconds(milliseconds || this.getMilliseconds()); }; /** * Gets the time of day for this date instances. * @return {TimeSpan} TimeSpan */ Date.prototype.getTimeOfDay = function () { return new TimeSpan(0, this.getHours(), this.getMinutes(), this.getSeconds(), this.getMilliseconds()); }; Date.TimeSpan = TimeSpan; if (typeof window !== "undefined" ) { // keeping API compatible for v1.x window.TimeSpan = TimeSpan; } }()); (function () { "use strict"; var attrs = ["years", "months", "days", "hours", "minutes", "seconds", "milliseconds"]; var gFn = function (attr) { return function () { return this[attr]; }; }; var sFn = function (attr) { return function (val) { this[attr] = val; return this; }; }; var addSetFuncs = function (context, attrs) { for (var i = 0; i < attrs.length ; i++) { var $a = attrs[i], $b = $a.slice(0, 1).toUpperCase() + $a.slice(1); context.prototype[$a] = 0; context.prototype["get" + $b] = gFn($a); context.prototype["set" + $b] = sFn($a); } }; var setMonthsAndYears = function (orient, d1, d2, context) { function inc() { d1.addMonths(-orient); context.months++; if (context.months === 12) { context.years++; context.months = 0; } } if (orient === +1) { while (d1 > d2) { inc(); } } else { while (d1 < d2) { inc(); } } context.months--; context.months *= orient; context.years *= orient; }; var adjustForDST = function(orient, startDate, endDate) { var hasDSTMismatch = (false === (startDate.isDaylightSavingTime() === endDate.isDaylightSavingTime())); if (hasDSTMismatch && orient === 1) { startDate.addHours(-1); } else if (hasDSTMismatch) { startDate.addHours(1); } }; /** * TimePeriod(startDate, endDate); * TimePeriod(years, months, days, hours, minutes, seconds, milliseconds); */ var TimePeriod = function (years, months, days, hours, minutes, seconds, milliseconds) { if (arguments.length === 7) { this.set(years, months, days, hours, minutes, seconds, milliseconds); } else if (arguments.length === 2 && arguments[0] instanceof Date && arguments[1] instanceof Date) { var startDate = arguments[0].clone(); var endDate = arguments[1].clone(); var orient = (startDate > endDate) ? +1 : -1; this.dates = { start: arguments[0].clone(), end: arguments[1].clone() }; setMonthsAndYears(orient, startDate, endDate, this); adjustForDST(orient, startDate, endDate); // // TODO - adjust for DST var diff = endDate - startDate; if (diff !== 0) { var ts = new TimeSpan(diff); this.set(this.years, this.months, ts.getDays(), ts.getHours(), ts.getMinutes(), ts.getSeconds(), ts.getMilliseconds()); } } return this; }; // create all the set functions. addSetFuncs(TimePeriod, attrs); TimePeriod.prototype.set = function (years, months, days, hours, minutes, seconds, milliseconds){ this.setYears(years || this.getYears()); this.setMonths(months || this.getMonths()); this.setDays(days || this.getDays()); this.setHours(hours || this.getHours()); this.setMinutes(minutes || this.getMinutes()); this.setSeconds(seconds || this.getSeconds()); this.setMilliseconds(milliseconds || this.getMilliseconds()); }; Date.TimePeriod = TimePeriod; if (typeof window !== "undefined") { // keeping API compatible for v1.x window.TimePeriod = TimePeriod; } }()); ================================================ FILE: build/date-pa-IN.js ================================================ /** * @overview datejs * @version 1.0.0-rc3 * @author Gregory Wild-Smith * @copyright 2015 Gregory Wild-Smith * @license MIT * @homepage https://github.com/abritinthebay/datejs */ /* * DateJS Culture String File * Country Code: pa-IN * Name: Punjabi (India) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["pa-IN"] = { "name": "pa-IN", "englishName": "Punjabi (India)", "nativeName": "ਪੰਜਾਬੀ (ਭਾਰਤ)", "Sunday": "ਐਤਵਾਰ", "Monday": "ਸੋਮਵਾਰ", "Tuesday": "ਮੰਗਲਵਾਰ", "Wednesday": "ਬੁਧਵਾਰ", "Thursday": "ਵੀਰਵਾਰ", "Friday": "ਸ਼ੁੱਕਰਵਾਰ", "Saturday": "ਸ਼ਨੀਚਰਵਾਰ", "Sun": "ਐਤ.", "Mon": "ਸੋਮ.", "Tue": "ਮੰਗਲ.", "Wed": "ਬੁਧ.", "Thu": "ਵੀਰ.", "Fri": "ਸ਼ੁਕਰ.", "Sat": "ਸ਼ਨੀ.", "Su": "ਐ", "Mo": "ਸ", "Tu": "ਮ", "We": "ਬ", "Th": "ਵ", "Fr": "ਸ਼", "Sa": "ਸ਼", "S_Sun_Initial": "ਐ", "M_Mon_Initial": "ਸ", "T_Tue_Initial": "ਮ", "W_Wed_Initial": "ਬ", "T_Thu_Initial": "ਵ", "F_Fri_Initial": "ਸ਼", "S_Sat_Initial": "ਸ਼", "January": "ਜਨਵਰੀ", "February": "ਫ਼ਰਵਰੀ", "March": "ਮਾਰਚ", "April": "ਅਪ੍ਰੈਲ", "May": "ਮਈ", "June": "ਜੂਨ", "July": "ਜੁਲਾਈ", "August": "ਅਗਸਤ", "September": "ਸਤੰਬਰ", "October": "ਅਕਤੂਬਰ", "November": "ਨਵੰਬਰ", "December": "ਦਸੰਬਰ", "Jan_Abbr": "ਜਨਵਰੀ", "Feb_Abbr": "ਫ਼ਰਵਰੀ", "Mar_Abbr": "ਮਾਰਚ", "Apr_Abbr": "ਅਪ੍ਰੈਲ", "May_Abbr": "ਮਈ", "Jun_Abbr": "ਜੂਨ", "Jul_Abbr": "ਜੁਲਾਈ", "Aug_Abbr": "ਅਗਸਤ", "Sep_Abbr": "ਸਤੰਬਰ", "Oct_Abbr": "ਅਕਤੂਬਰ", "Nov_Abbr": "ਨਵੰਬਰ", "Dec_Abbr": "ਦਸੰਬਰ", "AM": "ਸਵੇਰੇ", "PM": "ਸ਼ਾਮ", "firstDayOfWeek": 1, "twoDigitYearMax": 2029, "mdy": "dmy", "M/d/yyyy": "dd-MM-yy", "dddd, MMMM dd, yyyy": "dd MMMM yyyy dddd", "h:mm tt": "tt hh:mm", "h:mm:ss tt": "tt hh:mm:ss", "dddd, MMMM dd, yyyy h:mm:ss tt": "dd MMMM yyyy dddd tt hh:mm:ss", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "dd MMMM", "MMMM, yyyy": "MMMM, yyyy", "/jan(uary)?/": "ਜਨਵਰੀ", "/feb(ruary)?/": "ਫ਼ਰਵਰੀ", "/mar(ch)?/": "ਮਾਰਚ", "/apr(il)?/": "ਅਪ੍ਰੈਲ", "/may/": "ਮਈ", "/jun(e)?/": "ਜੂਨ", "/jul(y)?/": "ਜੁਲਾਈ", "/aug(ust)?/": "ਅਗਸਤ", "/sep(t(ember)?)?/": "ਸਤੰਬਰ", "/oct(ober)?/": "ਅਕਤੂਬਰ", "/nov(ember)?/": "ਨਵੰਬਰ", "/dec(ember)?/": "ਦਸੰਬਰ", "/^su(n(day)?)?/": "^ਐ(ਤ(.(ਵਾਰ)?)?)?", "/^mo(n(day)?)?/": "^ਸ(ੋਮ(.(ਵਾਰ)?)?)?", "/^tu(e(s(day)?)?)?/": "^ਮ(ੰਗਲ(.(ਵਾਰ)?)?)?", "/^we(d(nesday)?)?/": "^ਬ(ੁਧ(.(ਵਾਰ)?)?)?", "/^th(u(r(s(day)?)?)?)?/": "^ਵ(ੀਰ(.(ਵਾਰ)?)?)?", "/^fr(i(day)?)?/": "^ਸ਼(ੁਕਰ(.(ਰਵਾਰ)?)?)?", "/^sa(t(urday)?)?/": "^ਸ਼(ਨੀ(.(ਚਰਵਾਰ)?)?)?", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "pa-IN"; /** * @overview datejs * @version 1.0.0-rc3 * @author Gregory Wild-Smith * @copyright 2015 Gregory Wild-Smith * @license MIT * @homepage https://github.com/abritinthebay/datejs */(function () { var $D = Date; var lang = Date.CultureStrings ? Date.CultureStrings.lang : null; var loggedKeys = {}; // for debug purposes. var getText = { getFromKey: function (key, countryCode) { var output; if (Date.CultureStrings && Date.CultureStrings[countryCode] && Date.CultureStrings[countryCode][key]) { output = Date.CultureStrings[countryCode][key]; } else { output = getText.buildFromDefault(key); } if (key.charAt(0) === "/") { // Assume it's a regex output = getText.buildFromRegex(key, countryCode); } return output; }, getFromObjectValues: function (obj, countryCode) { var key, output = {}; for(key in obj) { if (obj.hasOwnProperty(key)) { output[key] = getText.getFromKey(obj[key], countryCode); } } return output; }, getFromObjectKeys: function (obj, countryCode) { var key, output = {}; for(key in obj) { if (obj.hasOwnProperty(key)) { output[getText.getFromKey(key, countryCode)] = obj[key]; } } return output; }, getFromArray: function (arr, countryCode) { var output = []; for (var i=0; i < arr.length; i++){ if (i in arr) { output[i] = getText.getFromKey(arr[i], countryCode); } } return output; }, buildFromDefault: function (key) { var output, length, split, last; switch(key) { case "name": output = "en-US"; break; case "englishName": output = "English (United States)"; break; case "nativeName": output = "English (United States)"; break; case "twoDigitYearMax": output = 2049; break; case "firstDayOfWeek": output = 0; break; default: output = key; split = key.split("_"); length = split.length; if (length > 1 && key.charAt(0) !== "/") { // if the key isn't a regex and it has a split. last = split[(length - 1)].toLowerCase(); if (last === "initial" || last === "abbr") { output = split[0]; } } break; } return output; }, buildFromRegex: function (key, countryCode) { var output; if (Date.CultureStrings && Date.CultureStrings[countryCode] && Date.CultureStrings[countryCode][key]) { output = new RegExp(Date.CultureStrings[countryCode][key], "i"); } else { output = new RegExp(key.replace(new RegExp("/", "g"),""), "i"); } return output; } }; var shallowMerge = function (obj1, obj2) { for (var attrname in obj2) { if (obj2.hasOwnProperty(attrname)) { obj1[attrname] = obj2[attrname]; } } }; var __ = function (key, language) { var countryCode = (language) ? language : lang; loggedKeys[key] = key; if (typeof key === "object") { if (key instanceof Array) { return getText.getFromArray(key, countryCode); } else { return getText.getFromObjectKeys(key, countryCode); } } else { return getText.getFromKey(key, countryCode); } }; var loadI18nScript = function (code) { // paatterned after jQuery's getScript. var url = Date.Config.i18n + code + ".js"; var head = document.getElementsByTagName("head")[0] || document.documentElement; var script = document.createElement("script"); script.src = url; var completed = false; var events = { done: function (){} // placeholder function }; // Attach handlers for all browsers script.onload = script.onreadystatechange = function() { if ( !completed && (!this.readyState || this.readyState === "loaded" || this.readyState === "complete") ) { events.done(); head.removeChild(script); } }; setTimeout(function() { head.insertBefore(script, head.firstChild); }, 0); // allows return to execute first return { done: function (cb) { events.done = function() { if (cb) { setTimeout(cb,0); } }; } }; }; var buildInfo = { buildFromMethodHash: function (obj) { var key; for(key in obj) { if (obj.hasOwnProperty(key)) { obj[key] = buildInfo[obj[key]](); } } return obj; }, timeZoneDST: function () { var DST = { "CHADT": "+1345", "NZDT": "+1300", "AEDT": "+1100", "ACDT": "+1030", "AZST": "+0500", "IRDT": "+0430", "EEST": "+0300", "CEST": "+0200", "BST": "+0100", "PMDT": "-0200", "ADT": "-0300", "NDT": "-0230", "EDT": "-0400", "CDT": "-0500", "MDT": "-0600", "PDT": "-0700", "AKDT": "-0800", "HADT": "-0900" }; return __(DST); }, timeZoneStandard: function () { var standard = { "LINT": "+1400", "TOT": "+1300", "CHAST": "+1245", "NZST": "+1200", "NFT": "+1130", "SBT": "+1100", "AEST": "+1000", "ACST": "+0930", "JST": "+0900", "CWST": "+0845", "CT": "+0800", "ICT": "+0700", "MMT": "+0630", "BST": "+0600", "NPT": "+0545", "IST": "+0530", "PKT": "+0500", "AFT": "+0430", "MSK": "+0400", "IRST": "+0330", "FET": "+0300", "EET": "+0200", "CET": "+0100", "GMT": "+0000", "UTC": "+0000", "CVT": "-0100", "GST": "-0200", "BRT": "-0300", "NST": "-0330", "AST": "-0400", "EST": "-0500", "CST": "-0600", "MST": "-0700", "PST": "-0800", "AKST": "-0900", "MIT": "-0930", "HST": "-1000", "SST": "-1100", "BIT": "-1200" }; return __(standard); }, timeZones: function (data) { var zone; data.timezones = []; for (zone in data.abbreviatedTimeZoneStandard) { if (data.abbreviatedTimeZoneStandard.hasOwnProperty(zone)) { data.timezones.push({ name: zone, offset: data.abbreviatedTimeZoneStandard[zone]}); } } for (zone in data.abbreviatedTimeZoneDST) { if (data.abbreviatedTimeZoneDST.hasOwnProperty(zone)) { data.timezones.push({ name: zone, offset: data.abbreviatedTimeZoneDST[zone], dst: true}); } } return data.timezones; }, days: function () { return __(["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"]); }, dayAbbr: function () { return __(["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"]); }, dayShortNames: function () { return __(["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"]); }, dayFirstLetters: function () { return __(["S_Sun_Initial", "M_Mon_Initial", "T_Tues_Initial", "W_Wed_Initial", "T_Thu_Initial", "F_Fri_Initial", "S_Sat_Initial"]); }, months: function () { return __(["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"]); }, monthAbbr: function () { return __(["Jan_Abbr", "Feb_Abbr", "Mar_Abbr", "Apr_Abbr", "May_Abbr", "Jun_Abbr", "Jul_Abbr", "Aug_Abbr", "Sep_Abbr", "Oct_Abbr", "Nov_Abbr", "Dec_Abbr"]); }, formatPatterns: function () { return getText.getFromObjectValues({ shortDate: "M/d/yyyy", longDate: "dddd, MMMM dd, yyyy", shortTime: "h:mm tt", longTime: "h:mm:ss tt", fullDateTime: "dddd, MMMM dd, yyyy h:mm:ss tt", sortableDateTime: "yyyy-MM-ddTHH:mm:ss", universalSortableDateTime: "yyyy-MM-dd HH:mm:ssZ", rfc1123: "ddd, dd MMM yyyy HH:mm:ss", monthDay: "MMMM dd", yearMonth: "MMMM, yyyy" }, Date.i18n.currentLanguage()); }, regex: function () { return getText.getFromObjectValues({ inTheMorning: "/( in the )(morn(ing)?)\\b/", thisMorning: "/(this )(morn(ing)?)\\b/", amThisMorning: "/(\b\\d(am)? )(this )(morn(ing)?)/", inTheEvening: "/( in the )(even(ing)?)\\b/", thisEvening: "/(this )(even(ing)?)\\b/", pmThisEvening: "/(\b\\d(pm)? )(this )(even(ing)?)/", jan: "/jan(uary)?/", feb: "/feb(ruary)?/", mar: "/mar(ch)?/", apr: "/apr(il)?/", may: "/may/", jun: "/jun(e)?/", jul: "/jul(y)?/", aug: "/aug(ust)?/", sep: "/sep(t(ember)?)?/", oct: "/oct(ober)?/", nov: "/nov(ember)?/", dec: "/dec(ember)?/", sun: "/^su(n(day)?)?/", mon: "/^mo(n(day)?)?/", tue: "/^tu(e(s(day)?)?)?/", wed: "/^we(d(nesday)?)?/", thu: "/^th(u(r(s(day)?)?)?)?/", fri: "/fr(i(day)?)?/", sat: "/^sa(t(urday)?)?/", future: "/^next/", past: "/^last|past|prev(ious)?/", add: "/^(\\+|aft(er)?|from|hence)/", subtract: "/^(\\-|bef(ore)?|ago)/", yesterday: "/^yes(terday)?/", today: "/^t(od(ay)?)?/", tomorrow: "/^tom(orrow)?/", now: "/^n(ow)?/", millisecond: "/^ms|milli(second)?s?/", second: "/^sec(ond)?s?/", minute: "/^mn|min(ute)?s?/", hour: "/^h(our)?s?/", week: "/^w(eek)?s?/", month: "/^m(onth)?s?/", day: "/^d(ay)?s?/", year: "/^y(ear)?s?/", shortMeridian: "/^(a|p)/", longMeridian: "/^(a\\.?m?\\.?|p\\.?m?\\.?)/", timezone: "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/", ordinalSuffix: "/^\\s*(st|nd|rd|th)/", timeContext: "/^\\s*(\\:|a(?!u|p)|p)/" }, Date.i18n.currentLanguage()); } }; var CultureInfo = function () { var info = getText.getFromObjectValues({ name: "name", englishName: "englishName", nativeName: "nativeName", amDesignator: "AM", pmDesignator: "PM", firstDayOfWeek: "firstDayOfWeek", twoDigitYearMax: "twoDigitYearMax", dateElementOrder: "mdy" }, Date.i18n.currentLanguage()); var constructedInfo = buildInfo.buildFromMethodHash({ dayNames: "days", abbreviatedDayNames: "dayAbbr", shortestDayNames: "dayShortNames", firstLetterDayNames: "dayFirstLetters", monthNames: "months", abbreviatedMonthNames: "monthAbbr", formatPatterns: "formatPatterns", regexPatterns: "regex", abbreviatedTimeZoneDST: "timeZoneDST", abbreviatedTimeZoneStandard: "timeZoneStandard" }); shallowMerge(info, constructedInfo); buildInfo.timeZones(info); return info; }; $D.i18n = { __: function (key, lang) { return __(key, lang); }, currentLanguage: function () { return lang || "en-US"; }, setLanguage: function (code, force, cb) { var async = false; if (force || code === "en-US" || (!!Date.CultureStrings && !!Date.CultureStrings[code])) { lang = code; Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings.lang = code; Date.CultureInfo = new CultureInfo(); } else { if (!(!!Date.CultureStrings && !!Date.CultureStrings[code])) { if (typeof exports !== "undefined" && this.exports !== exports) { // we're in a Node enviroment, load it using require try { require("../i18n/" + code + ".js"); lang = code; Date.CultureStrings.lang = code; Date.CultureInfo = new CultureInfo(); } catch (e) { // var str = "The language for '" + code + "' could not be loaded by Node. It likely does not exist."; throw new Error("The DateJS IETF language tag '" + code + "' could not be loaded by Node. It likely does not exist."); } } else if (Date.Config && Date.Config.i18n) { // we know the location of the files, so lets load them async = true; loadI18nScript(code).done(function(){ lang = code; Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings.lang = code; Date.CultureInfo = new CultureInfo(); $D.Parsing.Normalizer.buildReplaceData(); // because this is async if ($D.Grammar) { $D.Grammar.buildGrammarFormats(); // so we can parse those strings... } if (cb) { setTimeout(cb,0); } }); } else { Date.console.error("The DateJS IETF language tag '" + code + "' is not available and has not been loaded."); return false; } } } $D.Parsing.Normalizer.buildReplaceData(); // rebuild normalizer strings if ($D.Grammar) { $D.Grammar.buildGrammarFormats(); // so we can parse those strings... } if (!async && cb) { setTimeout(cb,0); } }, getLoggedKeys: function () { return loggedKeys; }, updateCultureInfo: function () { Date.CultureInfo = new CultureInfo(); } }; $D.i18n.updateCultureInfo(); // run automatically }()); (function () { var $D = Date, $P = $D.prototype, p = function (s, l) { if (!l) { l = 2; } return ("000" + s).slice(l * -1); }; if (typeof window !== "undefined" && typeof window.console !== "undefined" && typeof window.console.log !== "undefined") { $D.console = console; // used only to raise non-critical errors if available } else { // set mock so we don't give errors. $D.console = { log: function(){}, error: function(){} }; } $D.Config = $D.Config || {}; $D.initOverloads = function() { /** * Overload of Date.now. Allows an alternate call for Date.now where it returns the * current Date as an object rather than just milliseconds since the Unix Epoch. * * Also provides an implementation of now() for browsers (IE<9) that don't have it. * * Backwards compatible so with work with either: * Date.now() [returns ms] * or * Date.now(true) [returns Date] */ if (!$D.now) { $D._now = function now() { return new Date().getTime(); }; } else if (!$D._now) { $D._now = $D.now; } $D.now = function (returnObj) { if (returnObj) { return $D.present(); } else { return $D._now(); } }; if ( !$P.toISOString ) { $P.toISOString = function() { return this.getUTCFullYear() + "-" + p(this.getUTCMonth() + 1) + "-" + p(this.getUTCDate()) + "T" + p(this.getUTCHours()) + ":" + p(this.getUTCMinutes()) + ":" + p(this.getUTCSeconds()) + "." + String( (this.getUTCMilliseconds()/1000).toFixed(3)).slice(2, 5) + "Z"; }; } // private if ( $P._toString === undefined ){ $P._toString = $P.toString; } }; $D.initOverloads(); /** * Gets a date that is set to the current date. The time is set to the start of the day (00:00 or 12:00 AM). * @return {Date} The current date. */ $D.today = function () { return new Date().clearTime(); }; /** * Gets a date that is set to the current date and time (same as new Date, but chainable) * @return {Date} The current date. */ $D.present = function () { return new Date(); }; /** * Compares the first date to the second date and returns an number indication of their relative values. * @param {Date} First Date object to compare [Required]. * @param {Date} Second Date object to compare to [Required]. * @return {Number} -1 = date1 is lessthan date2. 0 = values are equal. 1 = date1 is greaterthan date2. */ $D.compare = function (date1, date2) { if (isNaN(date1) || isNaN(date2)) { throw new Error(date1 + " - " + date2); } else if (date1 instanceof Date && date2 instanceof Date) { return (date1 < date2) ? -1 : (date1 > date2) ? 1 : 0; } else { throw new TypeError(date1 + " - " + date2); } }; /** * Compares the first Date object to the second Date object and returns true if they are equal. * @param {Date} First Date object to compare [Required] * @param {Date} Second Date object to compare to [Required] * @return {Boolean} true if dates are equal. false if they are not equal. */ $D.equals = function (date1, date2) { return (date1.compareTo(date2) === 0); }; /** * Gets the language appropriate day name when given the day number(0-6) * eg - 0 == Sunday * @return {String} The day name */ $D.getDayName = function (n) { return Date.CultureInfo.dayNames[n]; }; /** * Gets the day number (0-6) if given a CultureInfo specific string which is a valid dayName, abbreviatedDayName or shortestDayName (two char). * @param {String} The name of the day (eg. "Monday, "Mon", "tuesday", "tue", "We", "we"). * @return {Number} The day number */ $D.getDayNumberFromName = function (name) { var n = Date.CultureInfo.dayNames, m = Date.CultureInfo.abbreviatedDayNames, o = Date.CultureInfo.shortestDayNames, s = name.toLowerCase(); for (var i = 0; i < n.length; i++) { if (n[i].toLowerCase() === s || m[i].toLowerCase() === s || o[i].toLowerCase() === s) { return i; } } return -1; }; /** * Gets the month number (0-11) if given a Culture Info specific string which is a valid monthName or abbreviatedMonthName. * @param {String} The name of the month (eg. "February, "Feb", "october", "oct"). * @return {Number} The day number */ $D.getMonthNumberFromName = function (name) { var n = Date.CultureInfo.monthNames, m = Date.CultureInfo.abbreviatedMonthNames, s = name.toLowerCase(); for (var i = 0; i < n.length; i++) { if (n[i].toLowerCase() === s || m[i].toLowerCase() === s) { return i; } } return -1; }; /** * Gets the language appropriate month name when given the month number(0-11) * eg - 0 == January * @return {String} The month name */ $D.getMonthName = function (n) { return Date.CultureInfo.monthNames[n]; }; /** * Determines if the current date instance is within a LeapYear. * @param {Number} The year. * @return {Boolean} true if date is within a LeapYear, otherwise false. */ $D.isLeapYear = function (year) { return ((year % 4 === 0 && year % 100 !== 0) || year % 400 === 0); }; /** * Gets the number of days in the month, given a year and month value. Automatically corrects for LeapYear. * @param {Number} The year. * @param {Number} The month (0-11). * @return {Number} The number of days in the month. */ $D.getDaysInMonth = function (year, month) { if (!month && $D.validateMonth(year)) { month = year; year = Date.today().getFullYear(); } return [31, ($D.isLeapYear(year) ? 29 : 28), 31, 30, 31, 30, 31, 31, 30, 31, 30, 31][month]; }; $P.getDaysInMonth = function () { return $D.getDaysInMonth(this.getFullYear(), this.getMonth()); }; $D.getTimezoneAbbreviation = function (offset, dst) { var p, n = (dst || false) ? Date.CultureInfo.abbreviatedTimeZoneDST : Date.CultureInfo.abbreviatedTimeZoneStandard; for (p in n) { if (n.hasOwnProperty(p)) { if (n[p] === offset) { return p; } } } return null; }; $D.getTimezoneOffset = function (name, dst) { var i, a =[], z = Date.CultureInfo.timezones; if (!name) { name = (new Date()).getTimezone();} for (i = 0; i < z.length; i++) { if (z[i].name === name.toUpperCase()) { a.push(i); } } if (!z[a[0]]) { return null; } if (a.length === 1 || !dst) { return z[a[0]].offset; } else { for (i=0; i < a.length; i++) { if (z[a[i]].dst) { return z[a[i]].offset; } } } }; $D.getQuarter = function (d) { d = d || new Date(); // If no date supplied, use today var q = [1,2,3,4]; return q[Math.floor(d.getMonth() / 3)]; // ~~~ is a bitwise op. Faster than Math.floor }; $D.getDaysLeftInQuarter = function (d) { d = d || new Date(); var qEnd = new Date(d); qEnd.setMonth(qEnd.getMonth() + 3 - qEnd.getMonth() % 3, 0); return Math.floor((qEnd - d) / 8.64e7); }; // private var validate = function (n, min, max, name) { name = name ? name : "Object"; if (typeof n === "undefined") { return false; } else if (typeof n !== "number") { throw new TypeError(n + " is not a Number."); } else if (n < min || n > max) { // As failing validation is *not* an exceptional circumstance // lets not throw a RangeError Exception here. // It's semantically correct but it's not sensible. return false; } return true; }; /** * Validates the number is within an acceptable range for milliseconds [0-999]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateMillisecond = function (value) { return validate(value, 0, 999, "millisecond"); }; /** * Validates the number is within an acceptable range for seconds [0-59]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateSecond = function (value) { return validate(value, 0, 59, "second"); }; /** * Validates the number is within an acceptable range for minutes [0-59]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateMinute = function (value) { return validate(value, 0, 59, "minute"); }; /** * Validates the number is within an acceptable range for hours [0-23]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateHour = function (value) { return validate(value, 0, 23, "hour"); }; /** * Validates the number is within an acceptable range for the days in a month [0-MaxDaysInMonth]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateDay = function (value, year, month) { if (year === undefined || year === null || month === undefined || month === null) { return false;} return validate(value, 1, $D.getDaysInMonth(year, month), "day"); }; /** * Validates the number is within an acceptable range for months [0-11]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateWeek = function (value) { return validate(value, 0, 53, "week"); }; /** * Validates the number is within an acceptable range for months [0-11]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateMonth = function (value) { return validate(value, 0, 11, "month"); }; /** * Validates the number is within an acceptable range for years. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateYear = function (value) { /** * Per ECMAScript spec the range of times supported by Date objects is * exactly -100,000,000 days to +100,000,000 days measured relative to * midnight at the beginning of 01 January, 1970 UTC. * This gives a range of 8,640,000,000,000,000 milliseconds to either * side of 01 January, 1970 UTC. * * Earliest possible date: Tue, 20 Apr 271,822 B.C. 00:00:00 UTC * Latest possible date: Sat, 13 Sep 275,760 00:00:00 UTC */ return validate(value, -271822, 275760, "year"); }; $D.validateTimezone = function(value) { var timezones = {"ACDT":1,"ACST":1,"ACT":1,"ADT":1,"AEDT":1,"AEST":1,"AFT":1,"AKDT":1,"AKST":1,"AMST":1,"AMT":1,"ART":1,"AST":1,"AWDT":1,"AWST":1,"AZOST":1,"AZT":1,"BDT":1,"BIOT":1,"BIT":1,"BOT":1,"BRT":1,"BST":1,"BTT":1,"CAT":1,"CCT":1,"CDT":1,"CEDT":1,"CEST":1,"CET":1,"CHADT":1,"CHAST":1,"CHOT":1,"ChST":1,"CHUT":1,"CIST":1,"CIT":1,"CKT":1,"CLST":1,"CLT":1,"COST":1,"COT":1,"CST":1,"CT":1,"CVT":1,"CWST":1,"CXT":1,"DAVT":1,"DDUT":1,"DFT":1,"EASST":1,"EAST":1,"EAT":1,"ECT":1,"EDT":1,"EEDT":1,"EEST":1,"EET":1,"EGST":1,"EGT":1,"EIT":1,"EST":1,"FET":1,"FJT":1,"FKST":1,"FKT":1,"FNT":1,"GALT":1,"GAMT":1,"GET":1,"GFT":1,"GILT":1,"GIT":1,"GMT":1,"GST":1,"GYT":1,"HADT":1,"HAEC":1,"HAST":1,"HKT":1,"HMT":1,"HOVT":1,"HST":1,"ICT":1,"IDT":1,"IOT":1,"IRDT":1,"IRKT":1,"IRST":1,"IST":1,"JST":1,"KGT":1,"KOST":1,"KRAT":1,"KST":1,"LHST":1,"LINT":1,"MAGT":1,"MART":1,"MAWT":1,"MDT":1,"MET":1,"MEST":1,"MHT":1,"MIST":1,"MIT":1,"MMT":1,"MSK":1,"MST":1,"MUT":1,"MVT":1,"MYT":1,"NCT":1,"NDT":1,"NFT":1,"NPT":1,"NST":1,"NT":1,"NUT":1,"NZDT":1,"NZST":1,"OMST":1,"ORAT":1,"PDT":1,"PET":1,"PETT":1,"PGT":1,"PHOT":1,"PHT":1,"PKT":1,"PMDT":1,"PMST":1,"PONT":1,"PST":1,"PYST":1,"PYT":1,"RET":1,"ROTT":1,"SAKT":1,"SAMT":1,"SAST":1,"SBT":1,"SCT":1,"SGT":1,"SLST":1,"SRT":1,"SST":1,"SYOT":1,"TAHT":1,"THA":1,"TFT":1,"TJT":1,"TKT":1,"TLT":1,"TMT":1,"TOT":1,"TVT":1,"UCT":1,"ULAT":1,"UTC":1,"UYST":1,"UYT":1,"UZT":1,"VET":1,"VLAT":1,"VOLT":1,"VOST":1,"VUT":1,"WAKT":1,"WAST":1,"WAT":1,"WEDT":1,"WEST":1,"WET":1,"WST":1,"YAKT":1,"YEKT":1,"Z":1}; return (timezones[value] === 1); }; $D.validateTimezoneOffset= function(value) { // timezones go from +14hrs to -12hrs, the +X hours are negative offsets. return (value > -841 && value < 721); }; }()); (function () { var $D = Date, $P = $D.prototype, p = function (s, l) { if (!l) { l = 2; } return ("000" + s).slice(l * -1); }; var validateConfigObject = function (obj) { var result = {}, self = this, prop, testFunc; testFunc = function (prop, func, value) { if (prop === "day") { var month = (obj.month !== undefined) ? obj.month : self.getMonth(); var year = (obj.year !== undefined) ? obj.year : self.getFullYear(); return $D[func](value, year, month); } else { return $D[func](value); } }; for (prop in obj) { if (Object.prototype.hasOwnProperty.call(obj, prop)) { var func = "validate" + prop.charAt(0).toUpperCase() + prop.slice(1); if ($D[func] && obj[prop] !== null && testFunc(prop, func, obj[prop])) { result[prop] = obj[prop]; } } } return result; }; /** * Resets the time of this Date object to 12:00 AM (00:00), which is the start of the day. * @param {Boolean} .clone() this date instance before clearing Time * @return {Date} this */ $P.clearTime = function () { this.setHours(0); this.setMinutes(0); this.setSeconds(0); this.setMilliseconds(0); return this; }; /** * Resets the time of this Date object to the current time ('now'). * @return {Date} this */ $P.setTimeToNow = function () { var n = new Date(); this.setHours(n.getHours()); this.setMinutes(n.getMinutes()); this.setSeconds(n.getSeconds()); this.setMilliseconds(n.getMilliseconds()); return this; }; /** * Returns a new Date object that is an exact date and time copy of the original instance. * @return {Date} A new Date instance */ $P.clone = function () { return new Date(this.getTime()); }; /** * Compares this instance to a Date object and returns an number indication of their relative values. * @param {Date} Date object to compare [Required] * @return {Number} -1 = this is lessthan date. 0 = values are equal. 1 = this is greaterthan date. */ $P.compareTo = function (date) { return Date.compare(this, date); }; /** * Compares this instance to another Date object and returns true if they are equal. * @param {Date} Date object to compare. If no date to compare, new Date() [now] is used. * @return {Boolean} true if dates are equal. false if they are not equal. */ $P.equals = function (date) { return Date.equals(this, (date !== undefined ? date : new Date())); }; /** * Determines if this instance is between a range of two dates or equal to either the start or end dates. * @param {Date} Start of range [Required] * @param {Date} End of range [Required] * @return {Boolean} true is this is between or equal to the start and end dates, else false */ $P.between = function (start, end) { return this.getTime() >= start.getTime() && this.getTime() <= end.getTime(); }; /** * Determines if this date occurs after the date to compare to. * @param {Date} Date object to compare. If no date to compare, new Date() ("now") is used. * @return {Boolean} true if this date instance is greater than the date to compare to (or "now"), otherwise false. */ $P.isAfter = function (date) { return this.compareTo(date || new Date()) === 1; }; /** * Determines if this date occurs before the date to compare to. * @param {Date} Date object to compare. If no date to compare, new Date() ("now") is used. * @return {Boolean} true if this date instance is less than the date to compare to (or "now"). */ $P.isBefore = function (date) { return (this.compareTo(date || new Date()) === -1); }; /** * Determines if the current Date instance occurs today. * @return {Boolean} true if this date instance is 'today', otherwise false. */ /** * Determines if the current Date instance occurs on the same Date as the supplied 'date'. * If no 'date' to compare to is provided, the current Date instance is compared to 'today'. * @param {date} Date object to compare. If no date to compare, the current Date ("now") is used. * @return {Boolean} true if this Date instance occurs on the same Day as the supplied 'date'. */ $P.isToday = $P.isSameDay = function (date) { return this.clone().clearTime().equals((date || new Date()).clone().clearTime()); }; /** * Adds the specified number of milliseconds to this instance. * @param {Number} The number of milliseconds to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addMilliseconds = function (value) { if (!value) { return this; } this.setTime(this.getTime() + value * 1); return this; }; /** * Adds the specified number of seconds to this instance. * @param {Number} The number of seconds to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addSeconds = function (value) { if (!value) { return this; } return this.addMilliseconds(value * 1000); }; /** * Adds the specified number of seconds to this instance. * @param {Number} The number of seconds to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addMinutes = function (value) { if (!value) { return this; } return this.addMilliseconds(value * 60000); // 60*1000 }; /** * Adds the specified number of hours to this instance. * @param {Number} The number of hours to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addHours = function (value) { if (!value) { return this; } return this.addMilliseconds(value * 3600000); // 60*60*1000 }; /** * Adds the specified number of days to this instance. * @param {Number} The number of days to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addDays = function (value) { if (!value) { return this; } this.setDate(this.getDate() + value * 1); return this; }; /** * Adds the specified number of weekdays (ie - not sat or sun) to this instance. * @param {Number} The number of days to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addWeekdays = function (value) { if (!value) { return this; } var day = this.getDay(); var weeks = (Math.ceil(Math.abs(value)/7)); if (day === 0 || day === 6) { if (value > 0) { this.next().monday(); this.addDays(-1); day = this.getDay(); } } if (value < 0) { while (value < 0) { this.addDays(-1); day = this.getDay(); if (day !== 0 && day !== 6) { value++; } } return this; } else if (value > 5 || (6-day) <= value) { value = value + (weeks * 2); } return this.addDays(value); }; /** * Adds the specified number of weeks to this instance. * @param {Number} The number of weeks to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addWeeks = function (value) { if (!value) { return this; } return this.addDays(value * 7); }; /** * Adds the specified number of months to this instance. * @param {Number} The number of months to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addMonths = function (value) { if (!value) { return this; } var n = this.getDate(); this.setDate(1); this.setMonth(this.getMonth() + value * 1); this.setDate(Math.min(n, $D.getDaysInMonth(this.getFullYear(), this.getMonth()))); return this; }; $P.addQuarters = function (value) { if (!value) { return this; } // note this will take you to the same point in the quarter as you are now. // i.e. - if you are 15 days into the quarter you'll be 15 days into the resulting one. // bonus: this allows adding fractional quarters return this.addMonths(value * 3); }; /** * Adds the specified number of years to this instance. * @param {Number} The number of years to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addYears = function (value) { if (!value) { return this; } return this.addMonths(value * 12); }; /** * Adds (or subtracts) to the value of the years, months, weeks, days, hours, minutes, seconds, milliseconds of the date instance using given configuration object. Positive and Negative values allowed. * Example

	Date.today().add( { days: 1, months: 1 } )

	new Date().add( { years: -1 } )
	
* @param {Object} Configuration object containing attributes (months, days, etc.) * @return {Date} this */ $P.add = function (config) { if (typeof config === "number") { this._orient = config; return this; } var x = config; if (x.day) { // If we should be a different date than today (eg: for 'tomorrow -1d', etc). // Should only effect parsing, not direct usage (eg, Finish and FinishExact) if ((x.day - this.getDate()) !== 0) { this.setDate(x.day); } } if (x.milliseconds) { this.addMilliseconds(x.milliseconds); } if (x.seconds) { this.addSeconds(x.seconds); } if (x.minutes) { this.addMinutes(x.minutes); } if (x.hours) { this.addHours(x.hours); } if (x.weeks) { this.addWeeks(x.weeks); } if (x.months) { this.addMonths(x.months); } if (x.years) { this.addYears(x.years); } if (x.days) { this.addDays(x.days); } return this; }; /** * Get the week number. Week one (1) is the week which contains the first Thursday of the year. Monday is considered the first day of the week. * The .getWeek() function does NOT convert the date to UTC. The local datetime is used. * Please use .getISOWeek() to get the week of the UTC converted date. * @return {Number} 1 to 53 */ $P.getWeek = function (utc) { // Create a copy of this date object var self, target = new Date(this.valueOf()); if (utc) { target.addMinutes(target.getTimezoneOffset()); self = target.clone(); } else { self = this; } // ISO week date weeks start on monday // so correct the day number var dayNr = (self.getDay() + 6) % 7; // ISO 8601 states that week 1 is the week // with the first thursday of that year. // Set the target date to the thursday in the target week target.setDate(target.getDate() - dayNr + 3); // Store the millisecond value of the target date var firstThursday = target.valueOf(); // Set the target to the first thursday of the year // First set the target to january first target.setMonth(0, 1); // Not a thursday? Correct the date to the next thursday if (target.getDay() !== 4) { target.setMonth(0, 1 + ((4 - target.getDay()) + 7) % 7); } // The weeknumber is the number of weeks between the // first thursday of the year and the thursday in the target week return 1 + Math.ceil((firstThursday - target) / 604800000); // 604800000 = 7 * 24 * 3600 * 1000 }; /** * Get the ISO 8601 week number. Week one ("01") is the week which contains the first Thursday of the year. Monday is considered the first day of the week. * The .getISOWeek() function does convert the date to it's UTC value. Please use .getWeek() to get the week of the local date. * @return {String} "01" to "53" */ $P.getISOWeek = function () { return p(this.getWeek(true)); }; /** * Moves the date to Monday of the week set. Week one (1) is the week which contains the first Thursday of the year. * @param {Number} A Number (1 to 53) that represents the week of the year. * @return {Date} this */ $P.setWeek = function (n) { if ((n - this.getWeek()) === 0) { if (this.getDay() !== 1) { return this.moveToDayOfWeek(1, (this.getDay() > 1 ? -1 : 1)); } else { return this; } } else { return this.moveToDayOfWeek(1, (this.getDay() > 1 ? -1 : 1)).addWeeks(n - this.getWeek()); } }; $P.setQuarter = function (qtr) { var month = Math.abs(((qtr-1) * 3) + 1); return this.setMonth(month, 1); }; $P.getQuarter = function () { return Date.getQuarter(this); }; $P.getDaysLeftInQuarter = function () { return Date.getDaysLeftInQuarter(this); }; /** * Moves the date to the next n'th occurrence of the dayOfWeek starting from the beginning of the month. The number (-1) is a magic number and will return the last occurrence of the dayOfWeek in the month. * @param {Number} The dayOfWeek to move to * @param {Number} The n'th occurrence to move to. Use (-1) to return the last occurrence in the month * @return {Date} this */ $P.moveToNthOccurrence = function (dayOfWeek, occurrence) { if (dayOfWeek === "Weekday") { if (occurrence > 0) { this.moveToFirstDayOfMonth(); if (this.is().weekday()) { occurrence -= 1; } } else if (occurrence < 0) { this.moveToLastDayOfMonth(); if (this.is().weekday()) { occurrence += 1; } } else { return this; } return this.addWeekdays(occurrence); } var shift = 0; if (occurrence > 0) { shift = occurrence - 1; } else if (occurrence === -1) { this.moveToLastDayOfMonth(); if (this.getDay() !== dayOfWeek) { this.moveToDayOfWeek(dayOfWeek, -1); } return this; } return this.moveToFirstDayOfMonth().addDays(-1).moveToDayOfWeek(dayOfWeek, +1).addWeeks(shift); }; var moveToN = function (getFunc, addFunc, nVal) { return function (value, orient) { var diff = (value - this[getFunc]() + nVal * (orient || +1)) % nVal; return this[addFunc]((diff === 0) ? diff += nVal * (orient || +1) : diff); }; }; /** * Move to the next or last dayOfWeek based on the orient value. * @param {Number} The dayOfWeek to move to * @param {Number} Forward (+1) or Back (-1). Defaults to +1. [Optional] * @return {Date} this */ $P.moveToDayOfWeek = moveToN("getDay", "addDays", 7); /** * Move to the next or last month based on the orient value. * @param {Number} The month to move to. 0 = January, 11 = December * @param {Number} Forward (+1) or Back (-1). Defaults to +1. [Optional] * @return {Date} this */ $P.moveToMonth = moveToN("getMonth", "addMonths", 12); /** * Get the Ordinate of the current day ("th", "st", "rd"). * @return {String} */ $P.getOrdinate = function () { var num = this.getDate(); return ord(num); }; /** * Get the Ordinal day (numeric day number) of the year, adjusted for leap year. * @return {Number} 1 through 365 (366 in leap years) */ $P.getOrdinalNumber = function () { return Math.ceil((this.clone().clearTime() - new Date(this.getFullYear(), 0, 1)) / 86400000) + 1; }; /** * Get the time zone abbreviation of the current date. * @return {String} The abbreviated time zone name (e.g. "EST") */ $P.getTimezone = function () { return $D.getTimezoneAbbreviation(this.getUTCOffset(), this.isDaylightSavingTime()); }; $P.setTimezoneOffset = function (offset) { var here = this.getTimezoneOffset(), there = Number(offset) * -6 / 10; return (there || there === 0) ? this.addMinutes(there - here) : this; }; $P.setTimezone = function (offset) { return this.setTimezoneOffset($D.getTimezoneOffset(offset)); }; /** * Indicates whether Daylight Saving Time is observed in the current time zone. * @return {Boolean} true|false */ $P.hasDaylightSavingTime = function () { return (Date.today().set({month: 0, day: 1}).getTimezoneOffset() !== Date.today().set({month: 6, day: 1}).getTimezoneOffset()); }; /** * Indicates whether this Date instance is within the Daylight Saving Time range for the current time zone. * @return {Boolean} true|false */ $P.isDaylightSavingTime = function () { return Date.today().set({month: 0, day: 1}).getTimezoneOffset() !== this.getTimezoneOffset(); }; /** * Get the offset from UTC of the current date. * @return {String} The 4-character offset string prefixed with + or - (e.g. "-0500") */ $P.getUTCOffset = function (offset) { var n = (offset || this.getTimezoneOffset()) * -10 / 6, r; if (n < 0) { r = (n - 10000).toString(); return r.charAt(0) + r.substr(2); } else { r = (n + 10000).toString(); return "+" + r.substr(1); } }; /** * Returns the number of milliseconds between this date and date. * @param {Date} Defaults to now * @return {Number} The diff in milliseconds */ $P.getElapsed = function (date) { return (date || new Date()) - this; }; /** * Set the value of year, month, day, hour, minute, second, millisecond of date instance using given configuration object. * Example

	Date.today().set( { day: 20, month: 1 } )

	new Date().set( { millisecond: 0 } )
	
* * @param {Object} Configuration object containing attributes (month, day, etc.) * @return {Date} this */ $P.set = function (config) { config = validateConfigObject.call(this, config); var key; for (key in config) { if (Object.prototype.hasOwnProperty.call(config, key)) { var name = key.charAt(0).toUpperCase() + key.slice(1); var addFunc, getFunc; if (key !== "week" && key !== "month" && key !== "timezone" && key !== "timezoneOffset") { name += "s"; } addFunc = "add" + name; getFunc = "get" + name; if (key === "month") { addFunc = addFunc + "s"; } else if (key === "year"){ getFunc = "getFullYear"; } if (key !== "day" && key !== "timezone" && key !== "timezoneOffset" && key !== "week" && key !== "hour") { this[addFunc](config[key] - this[getFunc]()); } else if ( key === "timezone"|| key === "timezoneOffset" || key === "week" || key === "hour") { this["set"+name](config[key]); } } } // day has to go last because you can't validate the day without first knowing the month if (config.day) { this.addDays(config.day - this.getDate()); } return this; }; /** * Moves the date to the first day of the month. * @return {Date} this */ $P.moveToFirstDayOfMonth = function () { return this.set({ day: 1 }); }; /** * Moves the date to the last day of the month. * @return {Date} this */ $P.moveToLastDayOfMonth = function () { return this.set({ day: $D.getDaysInMonth(this.getFullYear(), this.getMonth())}); }; /** * Converts the value of the current Date object to its equivalent string representation. * Format Specifiers * CUSTOM DATE AND TIME FORMAT STRINGS * Format Description Example * ------ --------------------------------------------------------------------------- ----------------------- * s The seconds of the minute between 0-59. "0" to "59" * ss The seconds of the minute with leading zero if required. "00" to "59" * * m The minute of the hour between 0-59. "0" or "59" * mm The minute of the hour with leading zero if required. "00" or "59" * * h The hour of the day between 1-12. "1" to "12" * hh The hour of the day with leading zero if required. "01" to "12" * * H The hour of the day between 0-23. "0" to "23" * HH The hour of the day with leading zero if required. "00" to "23" * * d The day of the month between 1 and 31. "1" to "31" * dd The day of the month with leading zero if required. "01" to "31" * ddd Abbreviated day name. Date.CultureInfo.abbreviatedDayNames. "Mon" to "Sun" * dddd The full day name. Date.CultureInfo.dayNames. "Monday" to "Sunday" * * M The month of the year between 1-12. "1" to "12" * MM The month of the year with leading zero if required. "01" to "12" * MMM Abbreviated month name. Date.CultureInfo.abbreviatedMonthNames. "Jan" to "Dec" * MMMM The full month name. Date.CultureInfo.monthNames. "January" to "December" * * yy The year as a two-digit number. "99" or "08" * yyyy The full four digit year. "1999" or "2008" * * t Displays the first character of the A.M./P.M. designator. "A" or "P" * Date.CultureInfo.amDesignator or Date.CultureInfo.pmDesignator * tt Displays the A.M./P.M. designator. "AM" or "PM" * Date.CultureInfo.amDesignator or Date.CultureInfo.pmDesignator * * S The ordinal suffix ("st, "nd", "rd" or "th") of the current day. "st, "nd", "rd" or "th" * * STANDARD DATE AND TIME FORMAT STRINGS * Format Description Example *------ --------------------------------------------------------------------------- ----------------------- * d The CultureInfo shortDate Format Pattern "M/d/yyyy" * D The CultureInfo longDate Format Pattern "dddd, MMMM dd, yyyy" * F The CultureInfo fullDateTime Format Pattern "dddd, MMMM dd, yyyy h:mm:ss tt" * m The CultureInfo monthDay Format Pattern "MMMM dd" * r The CultureInfo rfc1123 Format Pattern "ddd, dd MMM yyyy HH:mm:ss GMT" * s The CultureInfo sortableDateTime Format Pattern "yyyy-MM-ddTHH:mm:ss" * t The CultureInfo shortTime Format Pattern "h:mm tt" * T The CultureInfo longTime Format Pattern "h:mm:ss tt" * u The CultureInfo universalSortableDateTime Format Pattern "yyyy-MM-dd HH:mm:ssZ" * y The CultureInfo yearMonth Format Pattern "MMMM, yyyy" * * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @return {String} A string representation of the current Date object. */ var ord = function (n) { switch (n * 1) { case 1: case 21: case 31: return "st"; case 2: case 22: return "nd"; case 3: case 23: return "rd"; default: return "th"; } }; var parseStandardFormats = function (format) { var y, c = Date.CultureInfo.formatPatterns; switch (format) { case "d": return this.toString(c.shortDate); case "D": return this.toString(c.longDate); case "F": return this.toString(c.fullDateTime); case "m": return this.toString(c.monthDay); case "r": case "R": y = this.clone().addMinutes(this.getTimezoneOffset()); return y.toString(c.rfc1123) + " GMT"; case "s": return this.toString(c.sortableDateTime); case "t": return this.toString(c.shortTime); case "T": return this.toString(c.longTime); case "u": y = this.clone().addMinutes(this.getTimezoneOffset()); return y.toString(c.universalSortableDateTime); case "y": return this.toString(c.yearMonth); default: return false; } }; var parseFormatStringsClosure = function (context) { return function (m) { if (m.charAt(0) === "\\") { return m.replace("\\", ""); } switch (m) { case "hh": return p(context.getHours() < 13 ? (context.getHours() === 0 ? 12 : context.getHours()) : (context.getHours() - 12)); case "h": return context.getHours() < 13 ? (context.getHours() === 0 ? 12 : context.getHours()) : (context.getHours() - 12); case "HH": return p(context.getHours()); case "H": return context.getHours(); case "mm": return p(context.getMinutes()); case "m": return context.getMinutes(); case "ss": return p(context.getSeconds()); case "s": return context.getSeconds(); case "yyyy": return p(context.getFullYear(), 4); case "yy": return p(context.getFullYear()); case "y": return context.getFullYear(); case "E": case "dddd": return Date.CultureInfo.dayNames[context.getDay()]; case "ddd": return Date.CultureInfo.abbreviatedDayNames[context.getDay()]; case "dd": return p(context.getDate()); case "d": return context.getDate(); case "MMMM": return Date.CultureInfo.monthNames[context.getMonth()]; case "MMM": return Date.CultureInfo.abbreviatedMonthNames[context.getMonth()]; case "MM": return p((context.getMonth() + 1)); case "M": return context.getMonth() + 1; case "t": return context.getHours() < 12 ? Date.CultureInfo.amDesignator.substring(0, 1) : Date.CultureInfo.pmDesignator.substring(0, 1); case "tt": return context.getHours() < 12 ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator; case "S": return ord(context.getDate()); case "W": return context.getWeek(); case "WW": return context.getISOWeek(); case "Q": return "Q" + context.getQuarter(); case "q": return String(context.getQuarter()); case "z": return context.getTimezone(); case "Z": case "X": return Date.getTimezoneOffset(context.getTimezone()); case "ZZ": // Timezone offset in seconds return context.getTimezoneOffset() * -60; case "u": return context.getDay(); case "L": return ($D.isLeapYear(context.getFullYear())) ? 1 : 0; case "B": // Swatch Internet Time (.beats) return "@"+((context.getUTCSeconds() + (context.getUTCMinutes()*60) + ((context.getUTCHours()+1)*3600))/86.4); default: return m; } }; }; $P.toString = function (format, ignoreStandards) { // Standard Date and Time Format Strings. Formats pulled from CultureInfo file and // may vary by culture. if (!ignoreStandards && format && format.length === 1) { output = parseStandardFormats.call(this, format); if (output) { return output; } } var parseFormatStrings = parseFormatStringsClosure(this); return format ? format.replace(/((\\)?(dd?d?d?|MM?M?M?|yy?y?y?|hh?|HH?|mm?|ss?|tt?|S|q|Q|WW?W?W?)(?![^\[]*\]))/g, parseFormatStrings).replace(/\[|\]/g, "") : this._toString(); }; }()); /************************************************************* * SugarPak - Domain Specific Language - Syntactical Sugar * *************************************************************/ (function () { var $D = Date, $P = $D.prototype, $N = Number.prototype; // private $P._orient = +1; // private $P._nth = null; // private $P._is = false; // private $P._same = false; // private $P._isSecond = false; // private $N._dateElement = "days"; /** * Moves the date to the next instance of a date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.today().next().friday();
	Date.today().next().fri();
	Date.today().next().march();
	Date.today().next().mar();
	Date.today().next().week();
	
* * @return {Date} date */ $P.next = function () { this._move = true; this._orient = +1; return this; }; /** * Creates a new Date (Date.today()) and moves the date to the next instance of the date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.next().friday();
	Date.next().fri();
	Date.next().march();
	Date.next().mar();
	Date.next().week();
	
* * @return {Date} date */ $D.next = function () { return $D.today().next(); }; /** * Moves the date to the previous instance of a date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.today().last().friday();
	Date.today().last().fri();
	Date.today().last().march();
	Date.today().last().mar();
	Date.today().last().week();
	
* * @return {Date} date */ $P.last = $P.prev = $P.previous = function () { this._move = true; this._orient = -1; return this; }; /** * Creates a new Date (Date.today()) and moves the date to the previous instance of the date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.last().friday();
	Date.last().fri();
	Date.previous().march();
	Date.prev().mar();
	Date.last().week();
	
* * @return {Date} date */ $D.last = $D.prev = $D.previous = function () { return $D.today().last(); }; /** * Performs a equality check when followed by either a month name, day name or .weekday() function. * Example

	Date.today().is().friday(); // true|false
	Date.today().is().fri();
	Date.today().is().march();
	Date.today().is().mar();
	
* * @return {Boolean} true|false */ $P.is = function () { this._is = true; return this; }; /** * Determines if two date objects occur on/in exactly the same instance of the subsequent date part function. * The function .same() must be followed by a date part function (example: .day(), .month(), .year(), etc). * * An optional Date can be passed in the date part function. If now date is passed as a parameter, 'Now' is used. * * The following example demonstrates how to determine if two dates fall on the exact same day. * * Example

	var d1 = Date.today(); // today at 00:00
	var d2 = new Date();   // exactly now.

	// Do they occur on the same day?
	d1.same().day(d2); // true
	
	// Do they occur on the same hour?
	d1.same().hour(d2); // false, unless d2 hour is '00' (midnight).
	
	// What if it's the same day, but one year apart?
	var nextYear = Date.today().add(1).year();

	d1.same().day(nextYear); // false, because the dates must occur on the exact same day. 
	
* * Scenario: Determine if a given date occurs during some week period 2 months from now. * * Example

	var future = Date.today().add(2).months();
	return someDate.same().week(future); // true|false;
	
* * @return {Boolean} true|false */ $P.same = function () { this._same = true; this._isSecond = false; return this; }; /** * Determines if the current date/time occurs during Today. Must be preceded by the .is() function. * Example

	someDate.is().today();    // true|false
	new Date().is().today();  // true
	Date.today().is().today();// true
	Date.today().add(-1).day().is().today(); // false
	
* * @return {Boolean} true|false */ $P.today = function () { return this.same().day(); }; /** * Determines if the current date is a weekday. This function must be preceded by the .is() function. * Example

	Date.today().is().weekday(); // true|false
	
* * @return {Boolean} true|false */ $P.weekday = function () { if (this._nth) { return df("Weekday").call(this); } if (this._move) { return this.addWeekdays(this._orient); } if (this._is) { this._is = false; return (!this.is().sat() && !this.is().sun()); } return false; }; /** * Determines if the current date is on the weekend. This function must be preceded by the .is() function. * Example

	Date.today().is().weekend(); // true|false
	
* * @return {Boolean} true|false */ $P.weekend = function () { if (this._is) { this._is = false; return (this.is().sat() || this.is().sun()); } return false; }; /** * Sets the Time of the current Date instance. A string "6:15 pm" or config object {hour:18, minute:15} are accepted. * Example

	// Set time to 6:15pm with a String
	Date.today().at("6:15pm");

	// Set time to 6:15pm with a config object
	Date.today().at({hour:18, minute:15});
	
* * @return {Date} date */ $P.at = function (time) { return (typeof time === "string") ? $D.parse(this.toString("d") + " " + time) : this.set(time); }; /** * Creates a new Date() and adds this (Number) to the date based on the preceding date element function (eg. second|minute|hour|day|month|year). * Example

	// Undeclared Numbers must be wrapped with parentheses. Requirment of JavaScript.
	(3).days().fromNow();
	(6).months().fromNow();

	// Declared Number variables do not require parentheses. 
	var n = 6;
	n.months().fromNow();
	
* * @return {Date} A new Date instance */ $N.fromNow = $N.after = function (date) { var c = {}; c[this._dateElement] = this; return ((!date) ? new Date() : date.clone()).add(c); }; /** * Creates a new Date() and subtract this (Number) from the date based on the preceding date element function (eg. second|minute|hour|day|month|year). * Example

	// Undeclared Numbers must be wrapped with parentheses. Requirment of JavaScript.
	(3).days().ago();
	(6).months().ago();

	// Declared Number variables do not require parentheses. 
	var n = 6;
	n.months().ago();
	
* * @return {Date} A new Date instance */ $N.ago = $N.before = function (date) { var c = {}, s = (this._dateElement[this._dateElement.length-1] !== "s") ? this._dateElement + "s" : this._dateElement; c[s] = this * -1; return ((!date) ? new Date() : date.clone()).add(c); }; // Do NOT modify the following string tokens. These tokens are used to build dynamic functions. // All culture-specific strings can be found in the CultureInfo files. var dx = ("sunday monday tuesday wednesday thursday friday saturday").split(/\s/), mx = ("january february march april may june july august september october november december").split(/\s/), px = ("Millisecond Second Minute Hour Day Week Month Year Quarter Weekday").split(/\s/), pxf = ("Milliseconds Seconds Minutes Hours Date Week Month FullYear Quarter").split(/\s/), nth = ("final first second third fourth fifth").split(/\s/), de; /** * Returns an object literal of all the date parts. * Example

	var o = new Date().toObject();
	
	// { year: 2008, month: 4, week: 20, day: 13, hour: 18, minute: 9, second: 32, millisecond: 812 }
	
	// The object properties can be referenced directly from the object.
	
	alert(o.day);  // alerts "13"
	alert(o.year); // alerts "2008"
	
* * @return {Date} An object literal representing the original date object. */ $P.toObject = function () { var o = {}; for (var i = 0; i < px.length; i++) { if (this["get" + pxf[i]]) { o[px[i].toLowerCase()] = this["get" + pxf[i]](); } } return o; }; /** * Returns a date created from an object literal. Ignores the .week property if set in the config. * Example

	var o = new Date().toObject();
	
	return Date.fromObject(o); // will return the same date. 

	var o2 = {month: 1, day: 20, hour: 18}; // birthday party!
	Date.fromObject(o2);
	
* * @return {Date} An object literal representing the original date object. */ $D.fromObject = function(config) { config.week = null; return Date.today().set(config); }; // Create day name functions and abbreviated day name functions (eg. monday(), friday(), fri()). var df = function (n) { return function () { if (this._is) { this._is = false; return this.getDay() === n; } if (this._move) { this._move = null; } if (this._nth !== null) { // If the .second() function was called earlier, remove the _orient // from the date, and then continue. // This is required because 'second' can be used in two different context. // // Example // // Date.today().add(1).second(); // Date.march().second().monday(); // // Things get crazy with the following... // Date.march().add(1).second().second().monday(); // but it works!! // if (this._isSecond) { this.addSeconds(this._orient * -1); } // make sure we reset _isSecond this._isSecond = false; var ntemp = this._nth; this._nth = null; var temp = this.clone().moveToLastDayOfMonth(); this.moveToNthOccurrence(n, ntemp); if (this > temp) { throw new RangeError($D.getDayName(n) + " does not occur " + ntemp + " times in the month of " + $D.getMonthName(temp.getMonth()) + " " + temp.getFullYear() + "."); } return this; } return this.moveToDayOfWeek(n, this._orient); }; }; var sdf = function (n) { return function () { var t = $D.today(), shift = n - t.getDay(); if (n === 0 && Date.CultureInfo.firstDayOfWeek === 1 && t.getDay() !== 0) { shift = shift + 7; } return t.addDays(shift); }; }; // Create month name functions and abbreviated month name functions (eg. january(), march(), mar()). var month_instance_functions = function (n) { return function () { if (this._is) { this._is = false; return this.getMonth() === n; } return this.moveToMonth(n, this._orient); }; }; var month_static_functions = function (n) { return function () { return $D.today().set({ month: n, day: 1 }); }; }; var processTerms = function (names, staticFunc, instanceFunc) { for (var i = 0; i < names.length; i++) { // Create constant static Name variables. $D[names[i].toUpperCase()] = $D[names[i].toUpperCase().substring(0, 3)] = i; // Create Name functions. $D[names[i]] = $D[names[i].substring(0, 3)] = staticFunc(i); // Create Name instance functions. $P[names[i]] = $P[names[i].substring(0, 3)] = instanceFunc(i); } }; processTerms(dx, sdf, df); processTerms(mx, month_static_functions, month_instance_functions); // Create date element functions and plural date element functions used with Date (eg. day(), days(), months()). var ef = function (j) { return function () { // if the .second() function was called earlier, the _orient // has alread been added. Just return this and reset _isSecond. if (this._isSecond) { this._isSecond = false; return this; } if (this._same) { this._same = this._is = false; var o1 = this.toObject(), o2 = (arguments[0] || new Date()).toObject(), v = "", k = j.toLowerCase(); // the substr trick with -1 doesn't work in IE8 or less k = (k[k.length-1] === "s") ? k.substring(0,k.length-1) : k; for (var m = (px.length - 1); m > -1; m--) { v = px[m].toLowerCase(); if (o1[v] !== o2[v]) { return false; } if (k === v) { break; } } return true; } if (j.substring(j.length - 1) !== "s") { j += "s"; } if (this._move) { this._move = null; } return this["add" + j](this._orient); }; }; var nf = function (n) { return function () { this._dateElement = n; return this; }; }; for (var k = 0; k < px.length; k++) { de = px[k].toLowerCase(); if(de !== "weekday") { // Create date element functions and plural date element functions used with Date (eg. day(), days(), months()). $P[de] = $P[de + "s"] = ef(px[k]); // Create date element functions and plural date element functions used with Number (eg. day(), days(), months()). $N[de] = $N[de + "s"] = nf(de + "s"); } } $P._ss = ef("Second"); var nthfn = function (n) { return function (dayOfWeek) { if (this._same) { return this._ss(arguments[0]); } if (dayOfWeek || dayOfWeek === 0) { return this.moveToNthOccurrence(dayOfWeek, n); } this._nth = n; // if the operator is 'second' add the _orient, then deal with it later... if (n === 2 && (dayOfWeek === undefined || dayOfWeek === null)) { this._isSecond = true; return this.addSeconds(this._orient); } return this; }; }; for (var l = 0; l < nth.length; l++) { $P[nth[l]] = (l === 0) ? nthfn(-1) : nthfn(l); } }()); (function () { "use strict"; Date.Parsing = { Exception: function (s) { this.message = "Parse error at '" + s.substring(0, 10) + " ...'"; } }; var $P = Date.Parsing; var dayOffsets = { standard: [0,31,59,90,120,151,181,212,243,273,304,334], leap: [0,31,60,91,121,152,182,213,244,274,305,335] }; $P.isLeapYear = function(year) { return ((year % 4 === 0) && (year % 100 !== 0)) || (year % 400 === 0); }; var utils = { multiReplace : function (str, hash ) { var key; for (key in hash) { if (Object.prototype.hasOwnProperty.call(hash, key)) { var regex; if (typeof hash[key] === "function") { } else { regex = (hash[key] instanceof RegExp) ? hash[key] : new RegExp(hash[key], "g"); } str = str.replace(regex, key); } } return str; }, getDayOfYearFromWeek : function (obj) { var d, jan4, offset; obj.weekDay = (!obj.weekDay && obj.weekDay !== 0) ? 1 : obj.weekDay; d = new Date(obj.year, 0, 4); jan4 = d.getDay() === 0 ? 7 : d.getDay(); // JS is 0 indexed on Sunday. offset = jan4+3; obj.dayOfYear = ((obj.week * 7) + (obj.weekDay === 0 ? 7 : obj.weekDay))-offset; return obj; }, getDayOfYear : function (obj, dayOffset) { if (!obj.dayOfYear) { obj = utils.getDayOfYearFromWeek(obj); } for (var i=0;i <= dayOffset.length;i++) { if (obj.dayOfYear < dayOffset[i] || i === dayOffset.length) { obj.day = obj.day ? obj.day : (obj.dayOfYear - dayOffset[i-1]); break; } else { obj.month = i; } } return obj; }, adjustForTimeZone : function (obj, date) { var offset; if (obj.zone.toUpperCase() === "Z" || (obj.zone_hours === 0 && obj.zone_minutes === 0)) { // it's UTC/GML so work out the current timeszone offset offset = -date.getTimezoneOffset(); } else { offset = (obj.zone_hours*60) + (obj.zone_minutes || 0); if (obj.zone_sign === "+") { offset *= -1; } offset -= date.getTimezoneOffset(); } date.setMinutes(date.getMinutes()+offset); return date; }, setDefaults : function (obj) { obj.year = obj.year || Date.today().getFullYear(); obj.hours = obj.hours || 0; obj.minutes = obj.minutes || 0; obj.seconds = obj.seconds || 0; obj.milliseconds = obj.milliseconds || 0; if (!(!obj.month && (obj.week || obj.dayOfYear))) { // if we have a month, or if we don't but don't have the day calculation data obj.month = obj.month || 0; obj.day = obj.day || 1; } return obj; }, dataNum: function (data, mod, explict, postProcess) { var dataNum = data*1; if (mod) { if (postProcess) { return data ? mod(data)*1 : data; } else { return data ? mod(dataNum) : data; } } else if (!explict){ return data ? dataNum : data; } else { return (data && typeof data !== "undefined") ? dataNum : data; } }, timeDataProcess: function (obj) { var timeObj = {}; for (var x in obj.data) { if (obj.data.hasOwnProperty(x)) { timeObj[x] = obj.ignore[x] ? obj.data[x] : utils.dataNum(obj.data[x], obj.mods[x], obj.explict[x], obj.postProcess[x]); } } if (obj.data.secmins) { obj.data.secmins = obj.data.secmins.replace(",", ".") * 60; if (!timeObj.minutes) { timeObj.minutes = obj.data.secmins; } else if (!timeObj.seconds) { timeObj.seconds = obj.data.secmins; } delete obj.secmins; } return timeObj; }, buildTimeObjectFromData: function (data) { var time = utils.timeDataProcess({ data: { year : data[1], month : data[5], day : data[7], week : data[8], dayOfYear : data[10], hours : data[15], zone_hours : data[23], zone_minutes : data[24], zone : data[21], zone_sign : data[22], weekDay : data[9], minutes: data[16], seconds: data[19], milliseconds: data[20], secmins: data[18] }, mods: { month: function(data) { return data-1; }, weekDay: function (data) { data = Math.abs(data); return (data === 7 ? 0 : data); }, minutes: function (data) { return data.replace(":",""); }, seconds: function (data) { return Math.floor( (data.replace(":","").replace(",","."))*1 ); }, milliseconds: function (data) { return (data.replace(",",".")*1000); } }, postProcess: { minutes: true, seconds: true, milliseconds: true }, explict: { zone_hours: true, zone_minutes: true }, ignore: { zone: true, zone_sign: true, secmins: true } }); return time; }, addToHash: function (hash, keys, data) { keys = keys; data = data; var len = keys.length; for (var i = 0; i < len; i++) { hash[keys[i]] = data[i]; } return hash; }, combineRegex: function (r1, r2) { return new RegExp("(("+r1.source+")\\s("+r2.source+"))"); }, getDateNthString: function(add, last, inc){ if (add) { return Date.today().addDays(inc).toString("d"); } else if (last) { return Date.today().last()[inc]().toString("d"); } }, buildRegexData: function (array) { var arr = []; var len = array.length; for (var i=0; i < len; i++) { if (Object.prototype.toString.call(array[i]) === '[object Array]') { // oldIE compat version of Array.isArray arr.push(this.combineRegex(array[i][0], array[i][1])); } else { arr.push(array[i]); } } return arr; } }; $P.processTimeObject = function (obj) { var date, dayOffset; utils.setDefaults(obj); dayOffset = ($P.isLeapYear(obj.year)) ? dayOffsets.leap : dayOffsets.standard; if (!obj.month && (obj.week || obj.dayOfYear)) { utils.getDayOfYear(obj, dayOffset); } else { obj.dayOfYear = dayOffset[obj.month] + obj.day; } date = new Date(obj.year, obj.month, obj.day, obj.hours, obj.minutes, obj.seconds, obj.milliseconds); if (obj.zone) { utils.adjustForTimeZone(obj, date); // adjust (and calculate) for timezone } return date; }; $P.ISO = { regex : /^([\+-]?\d{4}(?!\d{2}\b))((-?)((0[1-9]|1[0-2])(\3([12]\d|0[1-9]|3[01]))?|W([0-4]\d|5[0-3])(-?[1-7])?|(00[1-9]|0[1-9]\d|[12]\d{2}|3([0-5]\d|6[1-6])))([T\s]((([01]\d|2[0-4])((:?)[0-5]\d)?|24\:?00)([\.,]\d+(?!:))?)?(\17[0-5]\d([\.,]\d+)?)?\s?([zZ]|([\+-])([01]\d|2[0-3]):?([0-5]\d)?)?)?)?$/, parse : function (s) { var time, data = s.match(this.regex); if (!data || !data.length) { return null; } time = utils.buildTimeObjectFromData(data); if (!time.year || (!time.year && (!time.month && !time.day) && (!time.week && !time.dayOfYear)) ) { return null; } return $P.processTimeObject(time); } }; $P.Numeric = { isNumeric: function (e){return!isNaN(parseFloat(e))&&isFinite(e);}, regex: /\b([0-1]?[0-9])([0-3]?[0-9])([0-2]?[0-9]?[0-9][0-9])\b/i, parse: function (s) { var data, i, time = {}, order = Date.CultureInfo.dateElementOrder.split(""); if (!(this.isNumeric(s)) || // if it's non-numeric OR (s[0] === "+" && s[0] === "-")) { // It's an arithmatic string (eg +/-1000) return null; } if (s.length < 5 && s.indexOf(".") < 0 && s.indexOf("/") < 0) { // assume it's just a year. time.year = s; return $P.processTimeObject(time); } data = s.match(this.regex); if (!data || !data.length) { return null; } for (i=0; i < order.length; i++) { switch(order[i]) { case "d": time.day = data[i+1]; break; case "m": time.month = (data[i+1]-1); break; case "y": time.year = data[i+1]; break; } } return $P.processTimeObject(time); } }; $P.Normalizer = { regexData: function () { var $R = Date.CultureInfo.regexPatterns; return utils.buildRegexData([ $R.tomorrow, $R.yesterday, [$R.past, $R.mon], [$R.past, $R.tue], [$R.past, $R.wed], [$R.past, $R.thu], [$R.past, $R.fri], [$R.past, $R.sat], [$R.past, $R.sun] ]); }, basicReplaceHash : function() { var $R = Date.CultureInfo.regexPatterns; return { "January": $R.jan.source, "February": $R.feb, "March": $R.mar, "April": $R.apr, "May": $R.may, "June": $R.jun, "July": $R.jul, "August": $R.aug, "September": $R.sep, "October": $R.oct, "November": $R.nov, "December": $R.dec, "": /\bat\b/gi, " ": /\s{2,}/, "am": $R.inTheMorning, "9am": $R.thisMorning, "pm": $R.inTheEvening, "7pm":$R.thisEvening }; }, keys : function(){ return [ utils.getDateNthString(true, false, 1), // tomorrow utils.getDateNthString(true, false, -1), // yesterday utils.getDateNthString(false, true, "monday"), //last mon utils.getDateNthString(false, true, "tuesday"), //last tues utils.getDateNthString(false, true, "wednesday"), //last wed utils.getDateNthString(false, true, "thursday"), //last thurs utils.getDateNthString(false, true, "friday"), //last fri utils.getDateNthString(false, true, "saturday"), //last sat utils.getDateNthString(false, true, "sunday") //last sun ]; }, buildRegexFunctions: function () { var $R = Date.CultureInfo.regexPatterns; var __ = Date.i18n.__; var tomorrowRE = new RegExp("(\\b\\d\\d?("+__("AM")+"|"+__("PM")+")? )("+$R.tomorrow.source.slice(1)+")", "i"); // adapted tomorrow regex for AM PM relative dates var todayRE = new RegExp($R.today.source + "(?!\\s*([+-]))\\b"); // today, but excludes the math operators (eg "today + 2h") this.replaceFuncs = [ [todayRE, function (full) { return (full.length > 1) ? Date.today().toString("d") : full; }], [tomorrowRE, function(full, m1) { var t = Date.today().addDays(1).toString("d"); return (t + " " + m1); }], [$R.amThisMorning, function(str, am){return am;}], [$R.pmThisEvening, function(str, pm){return pm;}] ]; }, buildReplaceData: function () { this.buildRegexFunctions(); this.replaceHash = utils.addToHash(this.basicReplaceHash(), this.keys(), this.regexData()); }, stringReplaceFuncs: function (s) { for (var i=0; i < this.replaceFuncs.length; i++) { s = s.replace(this.replaceFuncs[i][0], this.replaceFuncs[i][1]); } return s; }, parse: function (s) { s = this.stringReplaceFuncs(s); s = utils.multiReplace(s, this.replaceHash); try { var n = s.split(/([\s\-\.\,\/\x27]+)/); if (n.length === 3 && $P.Numeric.isNumeric(n[0]) && $P.Numeric.isNumeric(n[2]) && (n[2].length >= 4)) { // ok, so we're dealing with x/year. But that's not a full date. // This fixes wonky dateElementOrder parsing when set to dmy order. if (Date.CultureInfo.dateElementOrder[0] === "d") { s = "1/" + n[0] + "/" + n[2]; // set to 1st of month and normalize the seperator } } } catch (e) {} return s; } }; $P.Normalizer.buildReplaceData(); }()); (function () { var $P = Date.Parsing; var _ = $P.Operators = { // // Tokenizers // rtoken: function (r) { // regex token return function (s) { var mx = s.match(r); if (mx) { return ([ mx[0], s.substring(mx[0].length) ]); } else { throw new $P.Exception(s); } }; }, token: function () { // whitespace-eating token return function (s) { return _.rtoken(new RegExp("^\\s*" + s + "\\s*"))(s); }; }, stoken: function (s) { // string token return _.rtoken(new RegExp("^" + s)); }, // Atomic Operators until: function (p) { return function (s) { var qx = [], rx = null; while (s.length) { try { rx = p.call(this, s); } catch (e) { qx.push(rx[0]); s = rx[1]; continue; } break; } return [ qx, s ]; }; }, many: function (p) { return function (s) { var rx = [], r = null; while (s.length) { try { r = p.call(this, s); } catch (e) { return [ rx, s ]; } rx.push(r[0]); s = r[1]; } return [ rx, s ]; }; }, // generator operators -- see below optional: function (p) { return function (s) { var r = null; try { r = p.call(this, s); } catch (e) { return [ null, s ]; } return [ r[0], r[1] ]; }; }, not: function (p) { return function (s) { try { p.call(this, s); } catch (e) { return [null, s]; } throw new $P.Exception(s); }; }, ignore: function (p) { return p ? function (s) { var r = null; r = p.call(this, s); return [null, r[1]]; } : null; }, product: function () { var px = arguments[0], qx = Array.prototype.slice.call(arguments, 1), rx = []; for (var i = 0 ; i < px.length ; i++) { rx.push(_.each(px[i], qx)); } return rx; }, cache: function (rule) { var cache = {}, cache_length = 0, cache_keys = [], CACHE_MAX = Date.Config.CACHE_MAX || 100000, r = null; var cacheCheck = function () { if (cache_length === CACHE_MAX) { // kill several keys, don't want to have to do this all the time... for (var i=0; i < 10; i++) { var key = cache_keys.shift(); if (key) { delete cache[key]; cache_length--; } } } }; return function (s) { cacheCheck(); try { r = cache[s] = (cache[s] || rule.call(this, s)); } catch (e) { r = cache[s] = e; } cache_length++; cache_keys.push(s); if (r instanceof $P.Exception) { throw r; } else { return r; } }; }, // vector operators -- see below any: function () { var px = arguments; return function (s) { var r = null; for (var i = 0; i < px.length; i++) { if (px[i] == null) { continue; } try { r = (px[i].call(this, s)); } catch (e) { r = null; } if (r) { return r; } } throw new $P.Exception(s); }; }, each: function () { var px = arguments; return function (s) { var rx = [], r = null; for (var i = 0; i < px.length ; i++) { if (px[i] == null) { continue; } try { r = (px[i].call(this, s)); } catch (e) { throw new $P.Exception(s); } rx.push(r[0]); s = r[1]; } return [ rx, s]; }; }, all: function () { var px = arguments, _ = _; return _.each(_.optional(px)); }, // delimited operators sequence: function (px, d, c) { d = d || _.rtoken(/^\s*/); c = c || null; if (px.length === 1) { return px[0]; } return function (s) { var r = null, q = null; var rx = []; for (var i = 0; i < px.length ; i++) { try { r = px[i].call(this, s); } catch (e) { break; } rx.push(r[0]); try { q = d.call(this, r[1]); } catch (ex) { q = null; break; } s = q[1]; } if (!r) { throw new $P.Exception(s); } if (q) { throw new $P.Exception(q[1]); } if (c) { try { r = c.call(this, r[1]); } catch (ey) { throw new $P.Exception(r[1]); } } return [ rx, (r?r[1]:s) ]; }; }, // // Composite Operators // between: function (d1, p, d2) { d2 = d2 || d1; var _fn = _.each(_.ignore(d1), p, _.ignore(d2)); return function (s) { var rx = _fn.call(this, s); return [[rx[0][0], r[0][2]], rx[1]]; }; }, list: function (p, d, c) { d = d || _.rtoken(/^\s*/); c = c || null; return (p instanceof Array ? _.each(_.product(p.slice(0, -1), _.ignore(d)), p.slice(-1), _.ignore(c)) : _.each(_.many(_.each(p, _.ignore(d))), px, _.ignore(c))); }, set: function (px, d, c) { d = d || _.rtoken(/^\s*/); c = c || null; return function (s) { // r is the current match, best the current 'best' match // which means it parsed the most amount of input var r = null, p = null, q = null, rx = null, best = [[], s], last = false; // go through the rules in the given set for (var i = 0; i < px.length ; i++) { // last is a flag indicating whether this must be the last element // if there is only 1 element, then it MUST be the last one q = null; p = null; r = null; last = (px.length === 1); // first, we try simply to match the current pattern // if not, try the next pattern try { r = px[i].call(this, s); } catch (e) { continue; } // since we are matching against a set of elements, the first // thing to do is to add r[0] to matched elements rx = [[r[0]], r[1]]; // if we matched and there is still input to parse and // we don't already know this is the last element, // we're going to next check for the delimiter ... // if there's none, or if there's no input left to parse // than this must be the last element after all ... if (r[1].length > 0 && ! last) { try { q = d.call(this, r[1]); } catch (ex) { last = true; } } else { last = true; } // if we parsed the delimiter and now there's no more input, // that means we shouldn't have parsed the delimiter at all // so don't update r and mark this as the last element ... if (!last && q[1].length === 0) { last = true; } // so, if this isn't the last element, we're going to see if // we can get any more matches from the remaining (unmatched) // elements ... if (!last) { // build a list of the remaining rules we can match against, // i.e., all but the one we just matched against var qx = []; for (var j = 0; j < px.length ; j++) { if (i !== j) { qx.push(px[j]); } } // now invoke recursively set with the remaining input // note that we don't include the closing delimiter ... // we'll check for that ourselves at the end p = _.set(qx, d).call(this, q[1]); // if we got a non-empty set as a result ... // (otw rx already contains everything we want to match) if (p[0].length > 0) { // update current result, which is stored in rx ... // basically, pick up the remaining text from p[1] // and concat the result from p[0] so that we don't // get endless nesting ... rx[0] = rx[0].concat(p[0]); rx[1] = p[1]; } } // at this point, rx either contains the last matched element // or the entire matched set that starts with this element. // now we just check to see if this variation is better than // our best so far, in terms of how much of the input is parsed if (rx[1].length < best[1].length) { best = rx; } // if we've parsed all the input, then we're finished if (best[1].length === 0) { break; } } // so now we've either gone through all the patterns trying them // as the initial match; or we found one that parsed the entire // input string ... // if best has no matches, just return empty set ... if (best[0].length === 0) { return best; } // if a closing delimiter is provided, then we have to check it also if (c) { // we try this even if there is no remaining input because the pattern // may well be optional or match empty input ... try { q = c.call(this, best[1]); } catch (ey) { throw new $P.Exception(best[1]); } // it parsed ... be sure to update the best match remaining input best[1] = q[1]; } // if we're here, either there was no closing delimiter or we parsed it // so now we have the best match; just return it! return best; }; }, forward: function (gr, fname) { return function (s) { return gr[fname].call(this, s); }; }, // // Translation Operators // replace: function (rule, repl) { return function (s) { var r = rule.call(this, s); return [repl, r[1]]; }; }, process: function (rule, fn) { return function (s) { var r = rule.call(this, s); return [fn.call(this, r[0]), r[1]]; }; }, min: function (min, rule) { return function (s) { var rx = rule.call(this, s); if (rx[0].length < min) { throw new $P.Exception(s); } return rx; }; } }; // Generator Operators And Vector Operators // Generators are operators that have a signature of F(R) => R, // taking a given rule and returning another rule, such as // ignore, which parses a given rule and throws away the result. // Vector operators are those that have a signature of F(R1,R2,...) => R, // take a list of rules and returning a new rule, such as each. // Generator operators are converted (via the following _generator // function) into functions that can also take a list or array of rules // and return an array of new rules as though the function had been // called on each rule in turn (which is what actually happens). // This allows generators to be used with vector operators more easily. // Example: // each(ignore(foo, bar)) instead of each(ignore(foo), ignore(bar)) // This also turns generators into vector operators, which allows // constructs like: // not(cache(foo, bar)) var _generator = function (op) { function gen() { var args = null, rx = [], px, i; if (arguments.length > 1) { args = Array.prototype.slice.call(arguments); } else if (arguments[0] instanceof Array) { args = arguments[0]; } if (args) { px = args.shift(); if (px.length > 0) { args.unshift(px[i]); rx.push(op.apply(null, args)); args.shift(); return rx; } } else { return op.apply(null, arguments); } } return gen; }; var gx = "optional not ignore cache".split(/\s/); for (var i = 0 ; i < gx.length ; i++) { _[gx[i]] = _generator(_[gx[i]]); } var _vector = function (op) { return function () { if (arguments[0] instanceof Array) { return op.apply(null, arguments[0]); } else { return op.apply(null, arguments); } }; }; var vx = "each any all".split(/\s/); for (var j = 0 ; j < vx.length ; j++) { _[vx[j]] = _vector(_[vx[j]]); } }()); (function () { var $D = Date; var flattenAndCompact = function (ax) { var rx = []; for (var i = 0; i < ax.length; i++) { if (ax[i] instanceof Array) { rx = rx.concat(flattenAndCompact(ax[i])); } else { if (ax[i]) { rx.push(ax[i]); } } } return rx; }; var parseMeridian = function () { if (this.meridian && (this.hour || this.hour === 0)) { if (this.meridian === "a" && this.hour > 11 && Date.Config.strict24hr){ throw "Invalid hour and meridian combination"; } else if (this.meridian === "p" && this.hour < 12 && Date.Config.strict24hr){ throw "Invalid hour and meridian combination"; } else if (this.meridian === "p" && this.hour < 12) { this.hour = this.hour + 12; } else if (this.meridian === "a" && this.hour === 12) { this.hour = 0; } } }; var setDefaults = function () { var now = new Date(); if ((this.hour || this.minute) && (!this.month && !this.year && !this.day)) { this.day = now.getDate(); } if (!this.year) { this.year = now.getFullYear(); } if (!this.month && this.month !== 0) { this.month = now.getMonth(); } if (!this.day) { this.day = 1; } if (!this.hour) { this.hour = 0; } if (!this.minute) { this.minute = 0; } if (!this.second) { this.second = 0; } if (!this.millisecond) { this.millisecond = 0; } }; var finishUtils = { getToday: function () { if (this.now || "hour minute second".indexOf(this.unit) !== -1) { return new Date(); } else { return $D.today(); } }, setDaysFromWeekday: function (today, orient){ var gap; orient = orient || 1; this.unit = "day"; gap = ($D.getDayNumberFromName(this.weekday) - today.getDay()); this.days = gap ? ((gap + (orient * 7)) % 7) : (orient * 7); return this; }, setMonthsFromMonth: function (today, orient) { var gap; orient = orient || 1; this.unit = "month"; gap = (this.month - today.getMonth()); this.months = gap ? ((gap + (orient * 12)) % 12) : (orient * 12); this.month = null; return this; }, setDMYFromWeekday: function () { var d = Date[this.weekday](); this.day = d.getDate(); if (!this.month) { this.month = d.getMonth(); } this.year = d.getFullYear(); return this; }, setUnitValue: function (orient) { if (!this.value && this.operator && this.operator !== null && this[this.unit + "s"] && this[this.unit + "s"] !== null) { this[this.unit + "s"] = this[this.unit + "s"] + ((this.operator === "add") ? 1 : -1) + (this.value||0) * orient; } else if (this[this.unit + "s"] == null || this.operator != null) { if (!this.value) { this.value = 1; } this[this.unit + "s"] = this.value * orient; } }, generateDateFromWeeks: function () { var weekday = (this.weekday !== undefined) ? this.weekday : "today"; var d = Date[weekday]().addWeeks(this.weeks); if (this.now) { d.setTimeToNow(); } return d; } }; $D.Translator = { hour: function (s) { return function () { this.hour = Number(s); }; }, minute: function (s) { return function () { this.minute = Number(s); }; }, second: function (s) { return function () { this.second = Number(s); }; }, /* for ss.s format */ secondAndMillisecond: function (s) { return function () { var mx = s.match(/^([0-5][0-9])\.([0-9]{1,3})/); this.second = Number(mx[1]); this.millisecond = Number(mx[2]); }; }, meridian: function (s) { return function () { this.meridian = s.slice(0, 1).toLowerCase(); }; }, timezone: function (s) { return function () { var n = s.replace(/[^\d\+\-]/g, ""); if (n.length) { this.timezoneOffset = Number(n); } else { this.timezone = s.toLowerCase(); } }; }, day: function (x) { var s = x[0]; return function () { this.day = Number(s.match(/\d+/)[0]); if (this.day < 1) { throw "invalid day"; } }; }, month: function (s) { return function () { this.month = (s.length === 3) ? "jan feb mar apr may jun jul aug sep oct nov dec".indexOf(s)/4 : Number(s) - 1; if (this.month < 0) { throw "invalid month"; } }; }, year: function (s) { return function () { var n = Number(s); this.year = ((s.length > 2) ? n : (n + (((n + 2000) < Date.CultureInfo.twoDigitYearMax) ? 2000 : 1900))); }; }, rday: function (s) { return function () { switch (s) { case "yesterday": this.days = -1; break; case "tomorrow": this.days = 1; break; case "today": this.days = 0; break; case "now": this.days = 0; this.now = true; break; } }; }, finishExact: function (x) { var d; x = (x instanceof Array) ? x : [x]; for (var i = 0 ; i < x.length ; i++) { if (x[i]) { x[i].call(this); } } setDefaults.call(this); parseMeridian.call(this); if (this.day > $D.getDaysInMonth(this.year, this.month)) { throw new RangeError(this.day + " is not a valid value for days."); } d = new Date(this.year, this.month, this.day, this.hour, this.minute, this.second, this.millisecond); if (this.year < 100) { d.setFullYear(this.year); // means years less that 100 are process correctly. JS will parse it otherwise as 1900-1999. } if (this.timezone) { d.set({ timezone: this.timezone }); } else if (this.timezoneOffset) { d.set({ timezoneOffset: this.timezoneOffset }); } return d; }, finish: function (x) { var today, expression, orient, temp; x = (x instanceof Array) ? flattenAndCompact(x) : [ x ]; if (x.length === 0) { return null; } for (var i = 0 ; i < x.length ; i++) { if (typeof x[i] === "function") { x[i].call(this); } } if (this.now && !this.unit && !this.operator) { return new Date(); } else { today = finishUtils.getToday.call(this); } expression = !!(this.days && this.days !== null || this.orient || this.operator); orient = ((this.orient === "past" || this.operator === "subtract") ? -1 : 1); if (this.month && this.unit === "week") { this.value = this.month + 1; delete this.month; delete this.day; } if ((this.month || this.month === 0) && "year day hour minute second".indexOf(this.unit) !== -1) { if (!this.value) { this.value = this.month + 1; } this.month = null; expression = true; } if (!expression && this.weekday && !this.day && !this.days) { finishUtils.setDMYFromWeekday.call(this); } if (expression && this.weekday && this.unit !== "month" && this.unit !== "week") { finishUtils.setDaysFromWeekday.call(this, today, orient); } if (this.weekday && this.unit !== "week" && !this.day && !this.days) { temp = Date[this.weekday](); this.day = temp.getDate(); if (temp.getMonth() !== today.getMonth()) { this.month = temp.getMonth(); } } if (this.month && this.unit === "day" && this.operator) { if (!this.value) { this.value = (this.month + 1); } this.month = null; } if (this.value != null && this.month != null && this.year != null) { this.day = this.value * 1; } if (this.month && !this.day && this.value) { today.set({ day: this.value * 1 }); if (!expression) { this.day = this.value * 1; } } if (!this.month && this.value && this.unit === "month" && !this.now) { this.month = this.value; expression = true; } if (expression && (this.month || this.month === 0) && this.unit !== "year") { finishUtils.setMonthsFromMonth.call(this, today, orient); } if (!this.unit) { this.unit = "day"; } finishUtils.setUnitValue.call(this, orient); parseMeridian.call(this); if ((this.month || this.month === 0) && !this.day) { this.day = 1; } if (!this.orient && !this.operator && this.unit === "week" && this.value && !this.day && !this.month) { return Date.today().setWeek(this.value); } if (this.unit === "week" && this.weeks && !this.day && !this.month) { return finishUtils.generateDateFromWeeks.call(this); } if (expression && this.timezone && this.day && this.days) { this.day = this.days; } if (expression){ today.add(this); } else { today.set(this); } if (this.timezone) { this.timezone = this.timezone.toUpperCase(); var offset = $D.getTimezoneOffset(this.timezone); var timezone; if (today.hasDaylightSavingTime()) { // lets check that we're being sane with timezone setting timezone = $D.getTimezoneAbbreviation(offset, today.isDaylightSavingTime()); if (timezone !== this.timezone) { // bugger, we're in a place where things like EST vs EDT matters. if (today.isDaylightSavingTime()) { today.addHours(-1); } else { today.addHours(1); } } } today.setTimezoneOffset(offset); } return today; } }; }()); (function () { var $D = Date; $D.Grammar = {}; var _ = $D.Parsing.Operators, g = $D.Grammar, t = $D.Translator, _fn; // Allow rolling up into general purpose rules _fn = function () { return _.each(_.any.apply(null, arguments), _.not(g.ctoken2("timeContext"))); }; g.datePartDelimiter = _.rtoken(/^([\s\-\.\,\/\x27]+)/); g.timePartDelimiter = _.stoken(":"); g.whiteSpace = _.rtoken(/^\s*/); g.generalDelimiter = _.rtoken(/^(([\s\,]|at|@|on)+)/); var _C = {}; g.ctoken = function (keys) { var fn = _C[keys]; if (! fn) { var c = Date.CultureInfo.regexPatterns; var kx = keys.split(/\s+/), px = []; for (var i = 0; i < kx.length ; i++) { px.push(_.replace(_.rtoken(c[kx[i]]), kx[i])); } fn = _C[keys] = _.any.apply(null, px); } return fn; }; g.ctoken2 = function (key) { return _.rtoken(Date.CultureInfo.regexPatterns[key]); }; var cacheProcessRtoken = function (key, token, type, eachToken) { if (eachToken) { g[key] = _.cache(_.process(_.each(_.rtoken(token),_.optional(g.ctoken2(eachToken))), type)); } else { g[key] = _.cache(_.process(_.rtoken(token), type)); } }; var cacheProcessCtoken = function (token, type) { return _.cache(_.process(g.ctoken2(token), type)); }; var _F = {}; //function cache var _get = function (f) { _F[f] = (_F[f] || g.format(f)[0]); return _F[f]; }; g.allformats = function (fx) { var rx = []; if (fx instanceof Array) { for (var i = 0; i < fx.length; i++) { rx.push(_get(fx[i])); } } else { rx.push(_get(fx)); } return rx; }; g.formats = function (fx) { if (fx instanceof Array) { var rx = []; for (var i = 0 ; i < fx.length ; i++) { rx.push(_get(fx[i])); } return _.any.apply(null, rx); } else { return _get(fx); } }; var grammarFormats = { timeFormats: function(){ var i, RTokenKeys = [ "h", "hh", "H", "HH", "m", "mm", "s", "ss", "ss.s", "z", "zz" ], RToken = [ /^(0[0-9]|1[0-2]|[1-9])/, /^(0[0-9]|1[0-2])/, /^([0-1][0-9]|2[0-3]|[0-9])/, /^([0-1][0-9]|2[0-3])/, /^([0-5][0-9]|[0-9])/, /^[0-5][0-9]/, /^([0-5][0-9]|[0-9])/, /^[0-5][0-9]/, /^[0-5][0-9]\.[0-9]{1,3}/, /^((\+|\-)\s*\d\d\d\d)|((\+|\-)\d\d\:?\d\d)/, /^((\+|\-)\s*\d\d\d\d)|((\+|\-)\d\d\:?\d\d)/ ], tokens = [ t.hour, t.hour, t.hour, t.hour, t.minute, t.minute, t.second, t.second, t.secondAndMillisecond, t.timezone, t.timezone ]; for (i=0; i < RTokenKeys.length; i++) { cacheProcessRtoken(RTokenKeys[i], RToken[i], tokens[i]); } g.hms = _.cache(_.sequence([g.H, g.m, g.s], g.timePartDelimiter)); g.t = cacheProcessCtoken("shortMeridian", t.meridian); g.tt = cacheProcessCtoken("longMeridian", t.meridian); g.zzz = cacheProcessCtoken("timezone", t.timezone); g.timeSuffix = _.each(_.ignore(g.whiteSpace), _.set([ g.tt, g.zzz ])); g.time = _.each(_.optional(_.ignore(_.stoken("T"))), g.hms, g.timeSuffix); }, dateFormats: function () { // pre-loaded rules for different date part order preferences var _setfn = function () { return _.set(arguments, g.datePartDelimiter); }; var i, RTokenKeys = [ "d", "dd", "M", "MM", "y", "yy", "yyy", "yyyy" ], RToken = [ /^([0-2]\d|3[0-1]|\d)/, /^([0-2]\d|3[0-1])/, /^(1[0-2]|0\d|\d)/, /^(1[0-2]|0\d)/, /^(\d+)/, /^(\d\d)/, /^(\d\d?\d?\d?)/, /^(\d\d\d\d)/ ], tokens = [ t.day, t.day, t.month, t.month, t.year, t.year, t.year, t.year ], eachToken = [ "ordinalSuffix", "ordinalSuffix" ]; for (i=0; i < RTokenKeys.length; i++) { cacheProcessRtoken(RTokenKeys[i], RToken[i], tokens[i], eachToken[i]); } g.MMM = g.MMMM = _.cache(_.process(g.ctoken("jan feb mar apr may jun jul aug sep oct nov dec"), t.month)); g.ddd = g.dddd = _.cache(_.process(g.ctoken("sun mon tue wed thu fri sat"), function (s) { return function () { this.weekday = s; }; } )); g.day = _fn(g.d, g.dd); g.month = _fn(g.M, g.MMM); g.year = _fn(g.yyyy, g.yy); g.mdy = _setfn(g.ddd, g.month, g.day, g.year); g.ymd = _setfn(g.ddd, g.year, g.month, g.day); g.dmy = _setfn(g.ddd, g.day, g.month, g.year); g.date = function (s) { return ((g[Date.CultureInfo.dateElementOrder] || g.mdy).call(this, s)); }; }, relative: function () { // relative date / time expressions g.orientation = _.process(g.ctoken("past future"), function (s) { return function () { this.orient = s; }; } ); g.operator = _.process(g.ctoken("add subtract"), function (s) { return function () { this.operator = s; }; } ); g.rday = _.process(g.ctoken("yesterday tomorrow today now"), t.rday); g.unit = _.process(g.ctoken("second minute hour day week month year"), function (s) { return function () { this.unit = s; }; } ); } }; g.buildGrammarFormats = function () { // these need to be rebuilt every time the language changes. _C = {}; grammarFormats.timeFormats(); grammarFormats.dateFormats(); grammarFormats.relative(); g.value = _.process(_.rtoken(/^([-+]?\d+)?(st|nd|rd|th)?/), function (s) { return function () { this.value = s.replace(/\D/g, ""); }; } ); g.expression = _.set([g.rday, g.operator, g.value, g.unit, g.orientation, g.ddd, g.MMM ]); g.format = _.process(_.many( _.any( // translate format specifiers into grammar rules _.process( _.rtoken(/^(dd?d?d?(?!e)|MM?M?M?|yy?y?y?|hh?|HH?|mm?|ss?|tt?|zz?z?)/), function (fmt) { if (g[fmt]) { return g[fmt]; } else { throw $D.Parsing.Exception(fmt); } } ), // translate separator tokens into token rules _.process(_.rtoken(/^[^dMyhHmstz]+/), // all legal separators function (s) { return _.ignore(_.stoken(s)); } ) ) ), // construct the parser ... function (rules) { return _.process(_.each.apply(null, rules), t.finishExact); } ); // starting rule for general purpose grammar g._start = _.process(_.set([ g.date, g.time, g.expression ], g.generalDelimiter, g.whiteSpace), t.finish); }; g.buildGrammarFormats(); // parsing date format specifiers - ex: "h:m:s tt" // this little guy will generate a custom parser based // on the format string, ex: g.format("h:m:s tt") // check for these formats first g._formats = g.formats([ "\"yyyy-MM-ddTHH:mm:ssZ\"", "yyyy-MM-ddTHH:mm:ss.sz", "yyyy-MM-ddTHH:mm:ssZ", "yyyy-MM-ddTHH:mm:ssz", "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-ddTHH:mmZ", "yyyy-MM-ddTHH:mmz", "yyyy-MM-ddTHH:mm", "ddd, MMM dd, yyyy H:mm:ss tt", "ddd MMM d yyyy HH:mm:ss zzz", "MMddyyyy", "ddMMyyyy", "Mddyyyy", "ddMyyyy", "Mdyyyy", "dMyyyy", "yyyy", "Mdyy", "dMyy", "d" ]); // real starting rule: tries selected formats first, // then general purpose rule g.start = function (s) { try { var r = g._formats.call({}, s); if (r[1].length === 0) { return r; } } catch (e) {} return g._start.call({}, s); }; }()); (function () { var $D = Date; /** * @desc Converts the specified string value into its JavaScript Date equivalent using CultureInfo specific format information. * * Example

	///////////
	// Dates //
	///////////

	// 15-Oct-2004
	var d1 = Date.parse("10/15/2004");

	// 15-Oct-2004
	var d1 = Date.parse("15-Oct-2004");

	// 15-Oct-2004
	var d1 = Date.parse("2004.10.15");

	//Fri Oct 15, 2004
	var d1 = Date.parse("Fri Oct 15, 2004");

	///////////
	// Times //
	///////////

	// Today at 10 PM.
	var d1 = Date.parse("10 PM");

	// Today at 10:30 PM.
	var d1 = Date.parse("10:30 P.M.");

	// Today at 6 AM.
	var d1 = Date.parse("06am");

	/////////////////////
	// Dates and Times //
	/////////////////////

	// 8-July-2004 @ 10:30 PM
	var d1 = Date.parse("July 8th, 2004, 10:30 PM");

	// 1-July-2004 @ 10:30 PM
	var d1 = Date.parse("2004-07-01T22:30:00");

	////////////////////
	// Relative Dates //
	////////////////////

	// Returns today's date. The string "today" is culture specific.
	var d1 = Date.parse("today");

	// Returns yesterday's date. The string "yesterday" is culture specific.
	var d1 = Date.parse("yesterday");

	// Returns the date of the next thursday.
	var d1 = Date.parse("Next thursday");

	// Returns the date of the most previous monday.
	var d1 = Date.parse("last monday");

	// Returns today's day + one year.
	var d1 = Date.parse("next year");

	///////////////
	// Date Math //
	///////////////

	// Today + 2 days
	var d1 = Date.parse("t+2");

	// Today + 2 days
	var d1 = Date.parse("today + 2 days");

	// Today + 3 months
	var d1 = Date.parse("t+3m");

	// Today - 1 year
	var d1 = Date.parse("today - 1 year");

	// Today - 1 year
	var d1 = Date.parse("t-1y"); 


	/////////////////////////////
	// Partial Dates and Times //
	/////////////////////////////

	// July 15th of this year.
	var d1 = Date.parse("July 15");

	// 15th day of current day and year.
	var d1 = Date.parse("15");

	// July 1st of current year at 10pm.
	var d1 = Date.parse("7/1 10pm");
	
* * @param {String} The string value to convert into a Date object [Required] * @return {Date} A Date object or null if the string cannot be converted into a Date. */ var parseUtils = { removeOrds: function (s) { ords = s.match(/\b(\d+)(?:st|nd|rd|th)\b/); // find ordinal matches s = ((ords && ords.length === 2) ? s.replace(ords[0], ords[1]) : s); return s; }, grammarParser: function (s) { var r = null; try { r = $D.Grammar.start.call({}, s.replace(/^\s*(\S*(\s+\S+)*)\s*$/, "$1")); } catch (e) { return null; } return ((r[1].length === 0) ? r[0] : null); }, nativeFallback: function(s) { var t; try { // ok we haven't parsed it, last ditch attempt with the built-in parser. t = Date._parse(s); return (t || t === 0) ? new Date(t) : null; } catch (e) { return null; } } }; function parse (s) { var d; if (!s) { return null; } if (s instanceof Date) { return s.clone(); } if (s.length >= 4 && s.charAt(0) !== "0" && s.charAt(0) !== "+"&& s.charAt(0) !== "-") { // ie: 2004 will pass, 0800 won't. // Start with specific formats d = $D.Parsing.ISO.parse(s) || $D.Parsing.Numeric.parse(s); } if (d instanceof Date && !isNaN(d.getTime())) { return d; } else { // find ordinal dates (1st, 3rd, 8th, etc and remove them as they cause parsing issues) s = $D.Parsing.Normalizer.parse(parseUtils.removeOrds(s)); d = parseUtils.grammarParser(s); if (d !== null) { return d; } else { return parseUtils.nativeFallback(s); } } } if (!$D._parse) { $D._parse = $D.parse; } $D.parse = parse; Date.getParseFunction = function (fx) { var fns = Date.Grammar.allformats(fx); return function (s) { var r = null; for (var i = 0; i < fns.length; i++) { try { r = fns[i].call({}, s); } catch (e) { continue; } if (r[1].length === 0) { return r[0]; } } return null; }; }; /** * Converts the specified string value into its JavaScript Date equivalent using the specified format {String} or formats {Array} and the CultureInfo specific format information. * The format of the string value must match one of the supplied formats exactly. * * Example

	// 15-Oct-2004
	var d1 = Date.parseExact("10/15/2004", "M/d/yyyy");

	// 15-Oct-2004
	var d1 = Date.parse("15-Oct-2004", "M-ddd-yyyy");

	// 15-Oct-2004
	var d1 = Date.parse("2004.10.15", "yyyy.MM.dd");

	// Multiple formats
	var d1 = Date.parseExact("10/15/2004", ["M/d/yyyy", "MMMM d, yyyy"]);
	
* * @param {String} The string value to convert into a Date object [Required]. * @param {Object} The expected format {String} or an array of expected formats {Array} of the date string [Required]. * @return {Date} A Date object or null if the string cannot be converted into a Date. */ $D.parseExact = function (s, fx) { return $D.getParseFunction(fx)(s); }; }()); (function () { var $D = Date, $P = $D.prototype, // $C = $D.CultureInfo, // not used atm p = function (s, l) { if (!l) { l = 2; } return ("000" + s).slice(l * -1); }; /** * Converts a PHP format string to Java/.NET format string. * A PHP format string can be used with ._format or .format. * A Java/.NET format string can be used with .toString(). * The .parseExact function will only accept a Java/.NET format string * * Example * var f1 = "%m/%d/%y" * var f2 = Date.normalizeFormat(f1); // "MM/dd/yy" * * new Date().format(f1); // "04/13/08" * new Date()._format(f1); // "04/13/08" * new Date().toString(f2); // "04/13/08" * * var date = Date.parseExact("04/13/08", f2); // Sun Apr 13 2008 * * @param {String} A PHP format string consisting of one or more format spcifiers. * @return {String} The PHP format converted to a Java/.NET format string. */ var normalizerSubstitutions = { "d" : "dd", "%d": "dd", "D" : "ddd", "%a": "ddd", "j" : "dddd", "l" : "dddd", "%A": "dddd", "S" : "S", "F" : "MMMM", "%B": "MMMM", "m" : "MM", "%m": "MM", "M" : "MMM", "%b": "MMM", "%h": "MMM", "n" : "M", "Y" : "yyyy", "%Y": "yyyy", "y" : "yy", "%y": "yy", "g" : "h", "%I": "h", "G" : "H", "h" : "hh", "H" : "HH", "%H": "HH", "i" : "mm", "%M": "mm", "s" : "ss", "%S": "ss", "%r": "hh:mm tt", "%R": "H:mm", "%T": "H:mm:ss", "%X": "t", "%x": "d", "%e": "d", "%D": "MM/dd/yy", "%n": "\\n", "%t": "\\t", "e" : "z", "T" : "z", "%z": "z", "%Z": "z", "Z" : "ZZ", "N" : "u", "w" : "u", "%w": "u", "W" : "W", "%V": "W" }; var normalizer = { substitutes: function (m) { return normalizerSubstitutions[m]; }, interpreted: function (m, x) { var y; switch (m) { case "%u": return x.getDay() + 1; case "z": return x.getOrdinalNumber(); case "%j": return p(x.getOrdinalNumber(), 3); case "%U": var d1 = x.clone().set({month: 0, day: 1}).addDays(-1).moveToDayOfWeek(0), d2 = x.clone().addDays(1).moveToDayOfWeek(0, -1); return (d2 < d1) ? "00" : p((d2.getOrdinalNumber() - d1.getOrdinalNumber()) / 7 + 1); case "%W": return p(x.getWeek()); case "t": return $D.getDaysInMonth(x.getFullYear(), x.getMonth()); case "o": case "%G": return x.setWeek(x.getISOWeek()).toString("yyyy"); case "%g": return x._format("%G").slice(-2); case "a": case "%p": return t("tt").toLowerCase(); case "A": return t("tt").toUpperCase(); case "u": return p(x.getMilliseconds(), 3); case "I": return (x.isDaylightSavingTime()) ? 1 : 0; case "O": return x.getUTCOffset(); case "P": y = x.getUTCOffset(); return y.substring(0, y.length - 2) + ":" + y.substring(y.length - 2); case "B": var now = new Date(); return Math.floor(((now.getHours() * 3600) + (now.getMinutes() * 60) + now.getSeconds() + (now.getTimezoneOffset() + 60) * 60) / 86.4); case "c": return x.toISOString().replace(/\"/g, ""); case "U": return $D.strtotime("now"); case "%c": return t("d") + " " + t("t"); case "%C": return Math.floor(x.getFullYear() / 100 + 1); } }, shouldOverrideDefaults: function (m) { switch (m) { case "%e": return true; default: return false; } }, parse: function (m, context) { var formatString, c = context || new Date(); formatString = normalizer.substitutes(m); if (formatString) { return formatString; } formatString = normalizer.interpreted(m, c); if (formatString) { return formatString; } else { return m; } } }; $D.normalizeFormat = function (format, context) { return format.replace(/(%|\\)?.|%%/g, function(t){ return normalizer.parse(t, context); }); }; /** * Format a local Unix timestamp according to locale settings * * Example: * Date.strftime("%m/%d/%y", new Date()); // "04/13/08" * Date.strftime("c", "2008-04-13T17:52:03Z"); // "04/13/08" * * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @param {Number|String} The number representing the number of seconds that have elapsed since January 1, 1970 (local time). * @return {String} A string representation of the current Date object. */ $D.strftime = function (format, time) { var d = Date.parse(time); return d._format(format); }; /** * Parse any textual datetime description into a Unix timestamp. * A Unix timestamp is the number of seconds that have elapsed since January 1, 1970 (midnight UTC/GMT). * * Example: * Date.strtotime("04/13/08"); // 1208044800 * Date.strtotime("1970-01-01T00:00:00Z"); // 0 * * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @param {Object} A string or date object. * @return {String} A string representation of the current Date object. */ $D.strtotime = function (time) { var d = $D.parse(time); return Math.round($D.UTC(d.getUTCFullYear(), d.getUTCMonth(), d.getUTCDate(), d.getUTCHours(), d.getUTCMinutes(), d.getUTCSeconds(), d.getUTCMilliseconds()) / 1000); }; /** * Converts the value of the current Date object to its equivalent string representation using a PHP/Unix style of date format specifiers. * Format Specifiers * Format Description Example * ------ --------------------------------------------------------------------------- ----------------------- * %a abbreviated weekday name according to the current localed "Mon" through "Sun" * %A full weekday name according to the current localed "Sunday" through "Saturday" * %b abbreviated month name according to the current localed "Jan" through "Dec" * %B full month name according to the current locale "January" through "December" * %c preferred date and time representation for the current locale "4/13/2008 12:33 PM" * %C century number (the year divided by 100 and truncated to an integer) "00" to "99" * %d day of the month as a decimal number "01" to "31" * %D same as %m/%d/%y "04/13/08" * %e day of the month as a decimal number, a single digit is preceded by a space "1" to "31" * %g like %G, but without the century "08" * %G The 4-digit year corresponding to the ISO week number (see %V). "2008" * This has the same format and value as %Y, except that if the ISO week number * belongs to the previous or next year, that year is used instead. * %h same as %b "Jan" through "Dec" * %H hour as a decimal number using a 24-hour clock. "00" to "23" * %I hour as a decimal number using a 12-hour clock. "01" to "12" * %j day of the year as a decimal number. "001" to "366" * %m month as a decimal number. "01" to "12" * %M minute as a decimal number. "00" to "59" * %n newline character "\n" * %p either "am" or "pm" according to the given time value, or the "am" or "pm" * corresponding strings for the current locale. * %r time in a.m. and p.m. notation "8:44 PM" * %R time in 24 hour notation "20:44" * %S second as a decimal number "00" to "59" * %t tab character "\t" * %T current time, equal to %H:%M:%S "12:49:11" * %u weekday as a decimal number ["1", "7"], with "1" representing Monday "1" to "7" * %U week number of the current year as a decimal number, starting with the "0" to ("52" or "53") * first Sunday as the first day of the first week * %V The ISO 8601:1988 week number of the current year as a decimal number, "00" to ("52" or "53") * range 01 to 53, where week 1 is the first week that has at least 4 days * in the current year, and with Monday as the first day of the week. * (Use %G or %g for the year component that corresponds to the week number * for the specified timestamp.) * %W week number of the current year as a decimal number, starting with the "00" to ("52" or "53") * first Monday as the first day of the first week * %w day of the week as a decimal, Sunday being "0" "0" to "6" * %x preferred date representation for the current locale without the time "4/13/2008" * %X preferred time representation for the current locale without the date "12:53:05" * %y year as a decimal number without a century "00" "99" * %Y year as a decimal number including the century "2008" * %Z time zone or name or abbreviation "UTC", "EST", "PST" * %z same as %Z * %% a literal "%" characters "%" * d Day of the month, 2 digits with leading zeros "01" to "31" * D A textual representation of a day, three letters "Mon" through "Sun" * j Day of the month without leading zeros "1" to "31" * l A full textual representation of the day of the week (lowercase "L") "Sunday" through "Saturday" * N ISO-8601 numeric representation of the day of the week (added in PHP 5.1.0) "1" (for Monday) through "7" (for Sunday) * S English ordinal suffix for the day of the month, 2 characters "st", "nd", "rd" or "th". Works well with j * w Numeric representation of the day of the week "0" (for Sunday) through "6" (for Saturday) * z The day of the year (starting from "0") "0" through "365" * W ISO-8601 week number of year, weeks starting on Monday "00" to ("52" or "53") * F A full textual representation of a month, such as January or March "January" through "December" * m Numeric representation of a month, with leading zeros "01" through "12" * M A short textual representation of a month, three letters "Jan" through "Dec" * n Numeric representation of a month, without leading zeros "1" through "12" * t Number of days in the given month "28" through "31" * L Whether it's a leap year "1" if it is a leap year, "0" otherwise * o ISO-8601 year number. This has the same value as Y, except that if the "2008" * ISO week number (W) belongs to the previous or next year, that year * is used instead. * Y A full numeric representation of a year, 4 digits "2008" * y A two digit representation of a year "08" * a Lowercase Ante meridiem and Post meridiem "am" or "pm" * A Uppercase Ante meridiem and Post meridiem "AM" or "PM" * B Swatch Internet time "000" through "999" * g 12-hour format of an hour without leading zeros "1" through "12" * G 24-hour format of an hour without leading zeros "0" through "23" * h 12-hour format of an hour with leading zeros "01" through "12" * H 24-hour format of an hour with leading zeros "00" through "23" * i Minutes with leading zeros "00" to "59" * s Seconds, with leading zeros "00" through "59" * u Milliseconds "54321" * e Timezone identifier "UTC", "EST", "PST" * I Whether or not the date is in daylight saving time (uppercase i) "1" if Daylight Saving Time, "0" otherwise * O Difference to Greenwich time (GMT) in hours "+0200", "-0600" * P Difference to Greenwich time (GMT) with colon between hours and minutes "+02:00", "-06:00" * T Timezone abbreviation "UTC", "EST", "PST" * Z Timezone offset in seconds. The offset for timezones west of UTC is "-43200" through "50400" * always negative, and for those east of UTC is always positive. * c ISO 8601 date "2004-02-12T15:19:21+00:00" * r RFC 2822 formatted date "Thu, 21 Dec 2000 16:01:07 +0200" * U Seconds since the Unix Epoch (January 1 1970 00:00:00 GMT) "0" * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @return {String} A string representation of the current Date object. */ var formatReplace = function (context) { return function (m) { var formatString, override = false; if (m.charAt(0) === "\\" || m.substring(0, 2) === "%%") { return m.replace("\\", "").replace("%%", "%"); } override = normalizer.shouldOverrideDefaults(m); formatString = $D.normalizeFormat(m, context); if (formatString) { return context.toString(formatString, override); } }; }; $P._format = function (format) { var formatter = formatReplace(this); if (!format) { return this._toString(); } else { return format.replace(/(%|\\)?.|%%/g, formatter); } }; if (!$P.format) { $P.format = $P._format; } }()); (function () { "use strict"; var gFn = function (attr) { return function () { return this[attr]; }; }; var sFn = function (attr) { return function (val) { this[attr] = val; return this; }; }; var attrs = ["years", "months", "days", "hours", "minutes", "seconds", "milliseconds"]; var addSetFuncs = function (context, attrs) { for (var i = 0; i < attrs.length ; i++) { var $a = attrs[i], $b = $a.slice(0, 1).toUpperCase() + $a.slice(1); context.prototype[$a] = 0; context.prototype["get" + $b] = gFn($a); context.prototype["set" + $b] = sFn($a); } }; /** * new TimeSpan(milliseconds); * new TimeSpan(days, hours, minutes, seconds); * new TimeSpan(days, hours, minutes, seconds, milliseconds); */ var TimeSpan = function (days, hours, minutes, seconds, milliseconds) { if (arguments.length === 1 && typeof days === "number") { var orient = (days < 0) ? -1 : +1; var millsLeft = Math.abs(days); this.setDays(Math.floor(millsLeft / 86400000) * orient); millsLeft = millsLeft % 86400000; this.setHours(Math.floor(millsLeft / 3600000) * orient); millsLeft = millsLeft % 3600000; this.setMinutes(Math.floor(millsLeft / 60000) * orient); millsLeft = millsLeft % 60000; this.setSeconds(Math.floor(millsLeft / 1000) * orient); millsLeft = millsLeft % 1000; this.setMilliseconds(millsLeft * orient); } else { this.set(days, hours, minutes, seconds, milliseconds); } this.getTotalMilliseconds = function () { return (this.getDays() * 86400000) + (this.getHours() * 3600000) + (this.getMinutes() * 60000) + (this.getSeconds() * 1000); }; this.compareTo = function (time) { var t1 = new Date(1970, 1, 1, this.getHours(), this.getMinutes(), this.getSeconds()), t2; if (time === null) { t2 = new Date(1970, 1, 1, 0, 0, 0); } else { t2 = new Date(1970, 1, 1, time.getHours(), time.getMinutes(), time.getSeconds()); } return (t1 < t2) ? -1 : (t1 > t2) ? 1 : 0; }; this.equals = function (time) { return (this.compareTo(time) === 0); }; this.add = function (time) { return (time === null) ? this : this.addSeconds(time.getTotalMilliseconds() / 1000); }; this.subtract = function (time) { return (time === null) ? this : this.addSeconds(-time.getTotalMilliseconds() / 1000); }; this.addDays = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 86400000)); }; this.addHours = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 3600000)); }; this.addMinutes = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 60000)); }; this.addSeconds = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 1000)); }; this.addMilliseconds = function (n) { return new TimeSpan(this.getTotalMilliseconds() + n); }; this.get12HourHour = function () { return (this.getHours() > 12) ? this.getHours() - 12 : (this.getHours() === 0) ? 12 : this.getHours(); }; this.getDesignator = function () { return (this.getHours() < 12) ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator; }; this.toString = function (format) { this._toString = function () { if (this.getDays() !== null && this.getDays() > 0) { return this.getDays() + "." + this.getHours() + ":" + this.p(this.getMinutes()) + ":" + this.p(this.getSeconds()); } else { return this.getHours() + ":" + this.p(this.getMinutes()) + ":" + this.p(this.getSeconds()); } }; this.p = function (s) { return (s.toString().length < 2) ? "0" + s : s; }; var me = this; return format ? format.replace(/dd?|HH?|hh?|mm?|ss?|tt?/g, function (format) { switch (format) { case "d": return me.getDays(); case "dd": return me.p(me.getDays()); case "H": return me.getHours(); case "HH": return me.p(me.getHours()); case "h": return me.get12HourHour(); case "hh": return me.p(me.get12HourHour()); case "m": return me.getMinutes(); case "mm": return me.p(me.getMinutes()); case "s": return me.getSeconds(); case "ss": return me.p(me.getSeconds()); case "t": return ((me.getHours() < 12) ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator).substring(0, 1); case "tt": return (me.getHours() < 12) ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator; } } ) : this._toString(); }; return this; }; addSetFuncs(TimeSpan, attrs.slice(2)); TimeSpan.prototype.set = function (days, hours, minutes, seconds, milliseconds){ this.setDays(days || this.getDays()); this.setHours(hours || this.getHours()); this.setMinutes(minutes || this.getMinutes()); this.setSeconds(seconds || this.getSeconds()); this.setMilliseconds(milliseconds || this.getMilliseconds()); }; /** * Gets the time of day for this date instances. * @return {TimeSpan} TimeSpan */ Date.prototype.getTimeOfDay = function () { return new TimeSpan(0, this.getHours(), this.getMinutes(), this.getSeconds(), this.getMilliseconds()); }; Date.TimeSpan = TimeSpan; if (typeof window !== "undefined" ) { // keeping API compatible for v1.x window.TimeSpan = TimeSpan; } }()); (function () { "use strict"; var attrs = ["years", "months", "days", "hours", "minutes", "seconds", "milliseconds"]; var gFn = function (attr) { return function () { return this[attr]; }; }; var sFn = function (attr) { return function (val) { this[attr] = val; return this; }; }; var addSetFuncs = function (context, attrs) { for (var i = 0; i < attrs.length ; i++) { var $a = attrs[i], $b = $a.slice(0, 1).toUpperCase() + $a.slice(1); context.prototype[$a] = 0; context.prototype["get" + $b] = gFn($a); context.prototype["set" + $b] = sFn($a); } }; var setMonthsAndYears = function (orient, d1, d2, context) { function inc() { d1.addMonths(-orient); context.months++; if (context.months === 12) { context.years++; context.months = 0; } } if (orient === +1) { while (d1 > d2) { inc(); } } else { while (d1 < d2) { inc(); } } context.months--; context.months *= orient; context.years *= orient; }; var adjustForDST = function(orient, startDate, endDate) { var hasDSTMismatch = (false === (startDate.isDaylightSavingTime() === endDate.isDaylightSavingTime())); if (hasDSTMismatch && orient === 1) { startDate.addHours(-1); } else if (hasDSTMismatch) { startDate.addHours(1); } }; /** * TimePeriod(startDate, endDate); * TimePeriod(years, months, days, hours, minutes, seconds, milliseconds); */ var TimePeriod = function (years, months, days, hours, minutes, seconds, milliseconds) { if (arguments.length === 7) { this.set(years, months, days, hours, minutes, seconds, milliseconds); } else if (arguments.length === 2 && arguments[0] instanceof Date && arguments[1] instanceof Date) { var startDate = arguments[0].clone(); var endDate = arguments[1].clone(); var orient = (startDate > endDate) ? +1 : -1; this.dates = { start: arguments[0].clone(), end: arguments[1].clone() }; setMonthsAndYears(orient, startDate, endDate, this); adjustForDST(orient, startDate, endDate); // // TODO - adjust for DST var diff = endDate - startDate; if (diff !== 0) { var ts = new TimeSpan(diff); this.set(this.years, this.months, ts.getDays(), ts.getHours(), ts.getMinutes(), ts.getSeconds(), ts.getMilliseconds()); } } return this; }; // create all the set functions. addSetFuncs(TimePeriod, attrs); TimePeriod.prototype.set = function (years, months, days, hours, minutes, seconds, milliseconds){ this.setYears(years || this.getYears()); this.setMonths(months || this.getMonths()); this.setDays(days || this.getDays()); this.setHours(hours || this.getHours()); this.setMinutes(minutes || this.getMinutes()); this.setSeconds(seconds || this.getSeconds()); this.setMilliseconds(milliseconds || this.getMilliseconds()); }; Date.TimePeriod = TimePeriod; if (typeof window !== "undefined") { // keeping API compatible for v1.x window.TimePeriod = TimePeriod; } }()); ================================================ FILE: build/date-pl-PL.js ================================================ /** * @overview datejs * @version 1.0.0-rc3 * @author Gregory Wild-Smith * @copyright 2015 Gregory Wild-Smith * @license MIT * @homepage https://github.com/abritinthebay/datejs */ /* * DateJS Culture String File * Country Code: pl-PL * Name: Polish (Poland) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["pl-PL"] = { "name": "pl-PL", "englishName": "Polish (Poland)", "nativeName": "polski (Polska)", "Sunday": "niedziela", "Monday": "poniedziałek", "Tuesday": "wtorek", "Wednesday": "środa", "Thursday": "czwartek", "Friday": "piątek", "Saturday": "sobota", "Sun": "N", "Mon": "Pn", "Tue": "Wt", "Wed": "Śr", "Thu": "Cz", "Fri": "Pt", "Sat": "So", "Su": "N", "Mo": "Pn", "Tu": "Wt", "We": "Śr", "Th": "Cz", "Fr": "Pt", "Sa": "So", "S_Sun_Initial": "N", "M_Mon_Initial": "P", "T_Tue_Initial": "W", "W_Wed_Initial": "Ś", "T_Thu_Initial": "C", "F_Fri_Initial": "P", "S_Sat_Initial": "S", "January": "styczeń", "February": "luty", "March": "marzec", "April": "kwiecień", "May": "maj", "June": "czerwiec", "July": "lipiec", "August": "sierpień", "September": "wrzesień", "October": "październik", "November": "listopad", "December": "grudzień", "Jan_Abbr": "sty", "Feb_Abbr": "lut", "Mar_Abbr": "mar", "Apr_Abbr": "kwi", "May_Abbr": "maj", "Jun_Abbr": "cze", "Jul_Abbr": "lip", "Aug_Abbr": "sie", "Sep_Abbr": "wrz", "Oct_Abbr": "paź", "Nov_Abbr": "lis", "Dec_Abbr": "gru", "AM": "", "PM": "", "firstDayOfWeek": 1, "twoDigitYearMax": 2029, "mdy": "ymd", "M/d/yyyy": "yyyy-MM-dd", "dddd, MMMM dd, yyyy": "d MMMM yyyy", "h:mm tt": "HH:mm", "h:mm:ss tt": "HH:mm:ss", "dddd, MMMM dd, yyyy h:mm:ss tt": "d MMMM yyyy HH:mm:ss", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "d MMMM", "MMMM, yyyy": "MMMM yyyy", "/jan(uary)?/": "sty(czeń)?", "/feb(ruary)?/": "lut(y)?", "/mar(ch)?/": "mar(zec)?", "/apr(il)?/": "kwi(ecień)?", "/may/": "maj", "/jun(e)?/": "cze(rwiec)?", "/jul(y)?/": "lip(iec)?", "/aug(ust)?/": "sie(rpień)?", "/sep(t(ember)?)?/": "wrz(esień)?", "/oct(ober)?/": "paź(dziernik)?", "/nov(ember)?/": "lis(topad)?", "/dec(ember)?/": "gru(dzień)?", "/^su(n(day)?)?/": "^niedziela", "/^mo(n(day)?)?/": "^poniedziałek", "/^tu(e(s(day)?)?)?/": "^wtorek", "/^we(d(nesday)?)?/": "^środa", "/^th(u(r(s(day)?)?)?)?/": "^czwartek", "/^fr(i(day)?)?/": "^piątek", "/^sa(t(urday)?)?/": "^sobota", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "pl-PL"; /** * @overview datejs * @version 1.0.0-rc3 * @author Gregory Wild-Smith * @copyright 2015 Gregory Wild-Smith * @license MIT * @homepage https://github.com/abritinthebay/datejs */(function () { var $D = Date; var lang = Date.CultureStrings ? Date.CultureStrings.lang : null; var loggedKeys = {}; // for debug purposes. var getText = { getFromKey: function (key, countryCode) { var output; if (Date.CultureStrings && Date.CultureStrings[countryCode] && Date.CultureStrings[countryCode][key]) { output = Date.CultureStrings[countryCode][key]; } else { output = getText.buildFromDefault(key); } if (key.charAt(0) === "/") { // Assume it's a regex output = getText.buildFromRegex(key, countryCode); } return output; }, getFromObjectValues: function (obj, countryCode) { var key, output = {}; for(key in obj) { if (obj.hasOwnProperty(key)) { output[key] = getText.getFromKey(obj[key], countryCode); } } return output; }, getFromObjectKeys: function (obj, countryCode) { var key, output = {}; for(key in obj) { if (obj.hasOwnProperty(key)) { output[getText.getFromKey(key, countryCode)] = obj[key]; } } return output; }, getFromArray: function (arr, countryCode) { var output = []; for (var i=0; i < arr.length; i++){ if (i in arr) { output[i] = getText.getFromKey(arr[i], countryCode); } } return output; }, buildFromDefault: function (key) { var output, length, split, last; switch(key) { case "name": output = "en-US"; break; case "englishName": output = "English (United States)"; break; case "nativeName": output = "English (United States)"; break; case "twoDigitYearMax": output = 2049; break; case "firstDayOfWeek": output = 0; break; default: output = key; split = key.split("_"); length = split.length; if (length > 1 && key.charAt(0) !== "/") { // if the key isn't a regex and it has a split. last = split[(length - 1)].toLowerCase(); if (last === "initial" || last === "abbr") { output = split[0]; } } break; } return output; }, buildFromRegex: function (key, countryCode) { var output; if (Date.CultureStrings && Date.CultureStrings[countryCode] && Date.CultureStrings[countryCode][key]) { output = new RegExp(Date.CultureStrings[countryCode][key], "i"); } else { output = new RegExp(key.replace(new RegExp("/", "g"),""), "i"); } return output; } }; var shallowMerge = function (obj1, obj2) { for (var attrname in obj2) { if (obj2.hasOwnProperty(attrname)) { obj1[attrname] = obj2[attrname]; } } }; var __ = function (key, language) { var countryCode = (language) ? language : lang; loggedKeys[key] = key; if (typeof key === "object") { if (key instanceof Array) { return getText.getFromArray(key, countryCode); } else { return getText.getFromObjectKeys(key, countryCode); } } else { return getText.getFromKey(key, countryCode); } }; var loadI18nScript = function (code) { // paatterned after jQuery's getScript. var url = Date.Config.i18n + code + ".js"; var head = document.getElementsByTagName("head")[0] || document.documentElement; var script = document.createElement("script"); script.src = url; var completed = false; var events = { done: function (){} // placeholder function }; // Attach handlers for all browsers script.onload = script.onreadystatechange = function() { if ( !completed && (!this.readyState || this.readyState === "loaded" || this.readyState === "complete") ) { events.done(); head.removeChild(script); } }; setTimeout(function() { head.insertBefore(script, head.firstChild); }, 0); // allows return to execute first return { done: function (cb) { events.done = function() { if (cb) { setTimeout(cb,0); } }; } }; }; var buildInfo = { buildFromMethodHash: function (obj) { var key; for(key in obj) { if (obj.hasOwnProperty(key)) { obj[key] = buildInfo[obj[key]](); } } return obj; }, timeZoneDST: function () { var DST = { "CHADT": "+1345", "NZDT": "+1300", "AEDT": "+1100", "ACDT": "+1030", "AZST": "+0500", "IRDT": "+0430", "EEST": "+0300", "CEST": "+0200", "BST": "+0100", "PMDT": "-0200", "ADT": "-0300", "NDT": "-0230", "EDT": "-0400", "CDT": "-0500", "MDT": "-0600", "PDT": "-0700", "AKDT": "-0800", "HADT": "-0900" }; return __(DST); }, timeZoneStandard: function () { var standard = { "LINT": "+1400", "TOT": "+1300", "CHAST": "+1245", "NZST": "+1200", "NFT": "+1130", "SBT": "+1100", "AEST": "+1000", "ACST": "+0930", "JST": "+0900", "CWST": "+0845", "CT": "+0800", "ICT": "+0700", "MMT": "+0630", "BST": "+0600", "NPT": "+0545", "IST": "+0530", "PKT": "+0500", "AFT": "+0430", "MSK": "+0400", "IRST": "+0330", "FET": "+0300", "EET": "+0200", "CET": "+0100", "GMT": "+0000", "UTC": "+0000", "CVT": "-0100", "GST": "-0200", "BRT": "-0300", "NST": "-0330", "AST": "-0400", "EST": "-0500", "CST": "-0600", "MST": "-0700", "PST": "-0800", "AKST": "-0900", "MIT": "-0930", "HST": "-1000", "SST": "-1100", "BIT": "-1200" }; return __(standard); }, timeZones: function (data) { var zone; data.timezones = []; for (zone in data.abbreviatedTimeZoneStandard) { if (data.abbreviatedTimeZoneStandard.hasOwnProperty(zone)) { data.timezones.push({ name: zone, offset: data.abbreviatedTimeZoneStandard[zone]}); } } for (zone in data.abbreviatedTimeZoneDST) { if (data.abbreviatedTimeZoneDST.hasOwnProperty(zone)) { data.timezones.push({ name: zone, offset: data.abbreviatedTimeZoneDST[zone], dst: true}); } } return data.timezones; }, days: function () { return __(["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"]); }, dayAbbr: function () { return __(["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"]); }, dayShortNames: function () { return __(["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"]); }, dayFirstLetters: function () { return __(["S_Sun_Initial", "M_Mon_Initial", "T_Tues_Initial", "W_Wed_Initial", "T_Thu_Initial", "F_Fri_Initial", "S_Sat_Initial"]); }, months: function () { return __(["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"]); }, monthAbbr: function () { return __(["Jan_Abbr", "Feb_Abbr", "Mar_Abbr", "Apr_Abbr", "May_Abbr", "Jun_Abbr", "Jul_Abbr", "Aug_Abbr", "Sep_Abbr", "Oct_Abbr", "Nov_Abbr", "Dec_Abbr"]); }, formatPatterns: function () { return getText.getFromObjectValues({ shortDate: "M/d/yyyy", longDate: "dddd, MMMM dd, yyyy", shortTime: "h:mm tt", longTime: "h:mm:ss tt", fullDateTime: "dddd, MMMM dd, yyyy h:mm:ss tt", sortableDateTime: "yyyy-MM-ddTHH:mm:ss", universalSortableDateTime: "yyyy-MM-dd HH:mm:ssZ", rfc1123: "ddd, dd MMM yyyy HH:mm:ss", monthDay: "MMMM dd", yearMonth: "MMMM, yyyy" }, Date.i18n.currentLanguage()); }, regex: function () { return getText.getFromObjectValues({ inTheMorning: "/( in the )(morn(ing)?)\\b/", thisMorning: "/(this )(morn(ing)?)\\b/", amThisMorning: "/(\b\\d(am)? )(this )(morn(ing)?)/", inTheEvening: "/( in the )(even(ing)?)\\b/", thisEvening: "/(this )(even(ing)?)\\b/", pmThisEvening: "/(\b\\d(pm)? )(this )(even(ing)?)/", jan: "/jan(uary)?/", feb: "/feb(ruary)?/", mar: "/mar(ch)?/", apr: "/apr(il)?/", may: "/may/", jun: "/jun(e)?/", jul: "/jul(y)?/", aug: "/aug(ust)?/", sep: "/sep(t(ember)?)?/", oct: "/oct(ober)?/", nov: "/nov(ember)?/", dec: "/dec(ember)?/", sun: "/^su(n(day)?)?/", mon: "/^mo(n(day)?)?/", tue: "/^tu(e(s(day)?)?)?/", wed: "/^we(d(nesday)?)?/", thu: "/^th(u(r(s(day)?)?)?)?/", fri: "/fr(i(day)?)?/", sat: "/^sa(t(urday)?)?/", future: "/^next/", past: "/^last|past|prev(ious)?/", add: "/^(\\+|aft(er)?|from|hence)/", subtract: "/^(\\-|bef(ore)?|ago)/", yesterday: "/^yes(terday)?/", today: "/^t(od(ay)?)?/", tomorrow: "/^tom(orrow)?/", now: "/^n(ow)?/", millisecond: "/^ms|milli(second)?s?/", second: "/^sec(ond)?s?/", minute: "/^mn|min(ute)?s?/", hour: "/^h(our)?s?/", week: "/^w(eek)?s?/", month: "/^m(onth)?s?/", day: "/^d(ay)?s?/", year: "/^y(ear)?s?/", shortMeridian: "/^(a|p)/", longMeridian: "/^(a\\.?m?\\.?|p\\.?m?\\.?)/", timezone: "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/", ordinalSuffix: "/^\\s*(st|nd|rd|th)/", timeContext: "/^\\s*(\\:|a(?!u|p)|p)/" }, Date.i18n.currentLanguage()); } }; var CultureInfo = function () { var info = getText.getFromObjectValues({ name: "name", englishName: "englishName", nativeName: "nativeName", amDesignator: "AM", pmDesignator: "PM", firstDayOfWeek: "firstDayOfWeek", twoDigitYearMax: "twoDigitYearMax", dateElementOrder: "mdy" }, Date.i18n.currentLanguage()); var constructedInfo = buildInfo.buildFromMethodHash({ dayNames: "days", abbreviatedDayNames: "dayAbbr", shortestDayNames: "dayShortNames", firstLetterDayNames: "dayFirstLetters", monthNames: "months", abbreviatedMonthNames: "monthAbbr", formatPatterns: "formatPatterns", regexPatterns: "regex", abbreviatedTimeZoneDST: "timeZoneDST", abbreviatedTimeZoneStandard: "timeZoneStandard" }); shallowMerge(info, constructedInfo); buildInfo.timeZones(info); return info; }; $D.i18n = { __: function (key, lang) { return __(key, lang); }, currentLanguage: function () { return lang || "en-US"; }, setLanguage: function (code, force, cb) { var async = false; if (force || code === "en-US" || (!!Date.CultureStrings && !!Date.CultureStrings[code])) { lang = code; Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings.lang = code; Date.CultureInfo = new CultureInfo(); } else { if (!(!!Date.CultureStrings && !!Date.CultureStrings[code])) { if (typeof exports !== "undefined" && this.exports !== exports) { // we're in a Node enviroment, load it using require try { require("../i18n/" + code + ".js"); lang = code; Date.CultureStrings.lang = code; Date.CultureInfo = new CultureInfo(); } catch (e) { // var str = "The language for '" + code + "' could not be loaded by Node. It likely does not exist."; throw new Error("The DateJS IETF language tag '" + code + "' could not be loaded by Node. It likely does not exist."); } } else if (Date.Config && Date.Config.i18n) { // we know the location of the files, so lets load them async = true; loadI18nScript(code).done(function(){ lang = code; Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings.lang = code; Date.CultureInfo = new CultureInfo(); $D.Parsing.Normalizer.buildReplaceData(); // because this is async if ($D.Grammar) { $D.Grammar.buildGrammarFormats(); // so we can parse those strings... } if (cb) { setTimeout(cb,0); } }); } else { Date.console.error("The DateJS IETF language tag '" + code + "' is not available and has not been loaded."); return false; } } } $D.Parsing.Normalizer.buildReplaceData(); // rebuild normalizer strings if ($D.Grammar) { $D.Grammar.buildGrammarFormats(); // so we can parse those strings... } if (!async && cb) { setTimeout(cb,0); } }, getLoggedKeys: function () { return loggedKeys; }, updateCultureInfo: function () { Date.CultureInfo = new CultureInfo(); } }; $D.i18n.updateCultureInfo(); // run automatically }()); (function () { var $D = Date, $P = $D.prototype, p = function (s, l) { if (!l) { l = 2; } return ("000" + s).slice(l * -1); }; if (typeof window !== "undefined" && typeof window.console !== "undefined" && typeof window.console.log !== "undefined") { $D.console = console; // used only to raise non-critical errors if available } else { // set mock so we don't give errors. $D.console = { log: function(){}, error: function(){} }; } $D.Config = $D.Config || {}; $D.initOverloads = function() { /** * Overload of Date.now. Allows an alternate call for Date.now where it returns the * current Date as an object rather than just milliseconds since the Unix Epoch. * * Also provides an implementation of now() for browsers (IE<9) that don't have it. * * Backwards compatible so with work with either: * Date.now() [returns ms] * or * Date.now(true) [returns Date] */ if (!$D.now) { $D._now = function now() { return new Date().getTime(); }; } else if (!$D._now) { $D._now = $D.now; } $D.now = function (returnObj) { if (returnObj) { return $D.present(); } else { return $D._now(); } }; if ( !$P.toISOString ) { $P.toISOString = function() { return this.getUTCFullYear() + "-" + p(this.getUTCMonth() + 1) + "-" + p(this.getUTCDate()) + "T" + p(this.getUTCHours()) + ":" + p(this.getUTCMinutes()) + ":" + p(this.getUTCSeconds()) + "." + String( (this.getUTCMilliseconds()/1000).toFixed(3)).slice(2, 5) + "Z"; }; } // private if ( $P._toString === undefined ){ $P._toString = $P.toString; } }; $D.initOverloads(); /** * Gets a date that is set to the current date. The time is set to the start of the day (00:00 or 12:00 AM). * @return {Date} The current date. */ $D.today = function () { return new Date().clearTime(); }; /** * Gets a date that is set to the current date and time (same as new Date, but chainable) * @return {Date} The current date. */ $D.present = function () { return new Date(); }; /** * Compares the first date to the second date and returns an number indication of their relative values. * @param {Date} First Date object to compare [Required]. * @param {Date} Second Date object to compare to [Required]. * @return {Number} -1 = date1 is lessthan date2. 0 = values are equal. 1 = date1 is greaterthan date2. */ $D.compare = function (date1, date2) { if (isNaN(date1) || isNaN(date2)) { throw new Error(date1 + " - " + date2); } else if (date1 instanceof Date && date2 instanceof Date) { return (date1 < date2) ? -1 : (date1 > date2) ? 1 : 0; } else { throw new TypeError(date1 + " - " + date2); } }; /** * Compares the first Date object to the second Date object and returns true if they are equal. * @param {Date} First Date object to compare [Required] * @param {Date} Second Date object to compare to [Required] * @return {Boolean} true if dates are equal. false if they are not equal. */ $D.equals = function (date1, date2) { return (date1.compareTo(date2) === 0); }; /** * Gets the language appropriate day name when given the day number(0-6) * eg - 0 == Sunday * @return {String} The day name */ $D.getDayName = function (n) { return Date.CultureInfo.dayNames[n]; }; /** * Gets the day number (0-6) if given a CultureInfo specific string which is a valid dayName, abbreviatedDayName or shortestDayName (two char). * @param {String} The name of the day (eg. "Monday, "Mon", "tuesday", "tue", "We", "we"). * @return {Number} The day number */ $D.getDayNumberFromName = function (name) { var n = Date.CultureInfo.dayNames, m = Date.CultureInfo.abbreviatedDayNames, o = Date.CultureInfo.shortestDayNames, s = name.toLowerCase(); for (var i = 0; i < n.length; i++) { if (n[i].toLowerCase() === s || m[i].toLowerCase() === s || o[i].toLowerCase() === s) { return i; } } return -1; }; /** * Gets the month number (0-11) if given a Culture Info specific string which is a valid monthName or abbreviatedMonthName. * @param {String} The name of the month (eg. "February, "Feb", "october", "oct"). * @return {Number} The day number */ $D.getMonthNumberFromName = function (name) { var n = Date.CultureInfo.monthNames, m = Date.CultureInfo.abbreviatedMonthNames, s = name.toLowerCase(); for (var i = 0; i < n.length; i++) { if (n[i].toLowerCase() === s || m[i].toLowerCase() === s) { return i; } } return -1; }; /** * Gets the language appropriate month name when given the month number(0-11) * eg - 0 == January * @return {String} The month name */ $D.getMonthName = function (n) { return Date.CultureInfo.monthNames[n]; }; /** * Determines if the current date instance is within a LeapYear. * @param {Number} The year. * @return {Boolean} true if date is within a LeapYear, otherwise false. */ $D.isLeapYear = function (year) { return ((year % 4 === 0 && year % 100 !== 0) || year % 400 === 0); }; /** * Gets the number of days in the month, given a year and month value. Automatically corrects for LeapYear. * @param {Number} The year. * @param {Number} The month (0-11). * @return {Number} The number of days in the month. */ $D.getDaysInMonth = function (year, month) { if (!month && $D.validateMonth(year)) { month = year; year = Date.today().getFullYear(); } return [31, ($D.isLeapYear(year) ? 29 : 28), 31, 30, 31, 30, 31, 31, 30, 31, 30, 31][month]; }; $P.getDaysInMonth = function () { return $D.getDaysInMonth(this.getFullYear(), this.getMonth()); }; $D.getTimezoneAbbreviation = function (offset, dst) { var p, n = (dst || false) ? Date.CultureInfo.abbreviatedTimeZoneDST : Date.CultureInfo.abbreviatedTimeZoneStandard; for (p in n) { if (n.hasOwnProperty(p)) { if (n[p] === offset) { return p; } } } return null; }; $D.getTimezoneOffset = function (name, dst) { var i, a =[], z = Date.CultureInfo.timezones; if (!name) { name = (new Date()).getTimezone();} for (i = 0; i < z.length; i++) { if (z[i].name === name.toUpperCase()) { a.push(i); } } if (!z[a[0]]) { return null; } if (a.length === 1 || !dst) { return z[a[0]].offset; } else { for (i=0; i < a.length; i++) { if (z[a[i]].dst) { return z[a[i]].offset; } } } }; $D.getQuarter = function (d) { d = d || new Date(); // If no date supplied, use today var q = [1,2,3,4]; return q[Math.floor(d.getMonth() / 3)]; // ~~~ is a bitwise op. Faster than Math.floor }; $D.getDaysLeftInQuarter = function (d) { d = d || new Date(); var qEnd = new Date(d); qEnd.setMonth(qEnd.getMonth() + 3 - qEnd.getMonth() % 3, 0); return Math.floor((qEnd - d) / 8.64e7); }; // private var validate = function (n, min, max, name) { name = name ? name : "Object"; if (typeof n === "undefined") { return false; } else if (typeof n !== "number") { throw new TypeError(n + " is not a Number."); } else if (n < min || n > max) { // As failing validation is *not* an exceptional circumstance // lets not throw a RangeError Exception here. // It's semantically correct but it's not sensible. return false; } return true; }; /** * Validates the number is within an acceptable range for milliseconds [0-999]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateMillisecond = function (value) { return validate(value, 0, 999, "millisecond"); }; /** * Validates the number is within an acceptable range for seconds [0-59]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateSecond = function (value) { return validate(value, 0, 59, "second"); }; /** * Validates the number is within an acceptable range for minutes [0-59]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateMinute = function (value) { return validate(value, 0, 59, "minute"); }; /** * Validates the number is within an acceptable range for hours [0-23]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateHour = function (value) { return validate(value, 0, 23, "hour"); }; /** * Validates the number is within an acceptable range for the days in a month [0-MaxDaysInMonth]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateDay = function (value, year, month) { if (year === undefined || year === null || month === undefined || month === null) { return false;} return validate(value, 1, $D.getDaysInMonth(year, month), "day"); }; /** * Validates the number is within an acceptable range for months [0-11]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateWeek = function (value) { return validate(value, 0, 53, "week"); }; /** * Validates the number is within an acceptable range for months [0-11]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateMonth = function (value) { return validate(value, 0, 11, "month"); }; /** * Validates the number is within an acceptable range for years. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateYear = function (value) { /** * Per ECMAScript spec the range of times supported by Date objects is * exactly -100,000,000 days to +100,000,000 days measured relative to * midnight at the beginning of 01 January, 1970 UTC. * This gives a range of 8,640,000,000,000,000 milliseconds to either * side of 01 January, 1970 UTC. * * Earliest possible date: Tue, 20 Apr 271,822 B.C. 00:00:00 UTC * Latest possible date: Sat, 13 Sep 275,760 00:00:00 UTC */ return validate(value, -271822, 275760, "year"); }; $D.validateTimezone = function(value) { var timezones = {"ACDT":1,"ACST":1,"ACT":1,"ADT":1,"AEDT":1,"AEST":1,"AFT":1,"AKDT":1,"AKST":1,"AMST":1,"AMT":1,"ART":1,"AST":1,"AWDT":1,"AWST":1,"AZOST":1,"AZT":1,"BDT":1,"BIOT":1,"BIT":1,"BOT":1,"BRT":1,"BST":1,"BTT":1,"CAT":1,"CCT":1,"CDT":1,"CEDT":1,"CEST":1,"CET":1,"CHADT":1,"CHAST":1,"CHOT":1,"ChST":1,"CHUT":1,"CIST":1,"CIT":1,"CKT":1,"CLST":1,"CLT":1,"COST":1,"COT":1,"CST":1,"CT":1,"CVT":1,"CWST":1,"CXT":1,"DAVT":1,"DDUT":1,"DFT":1,"EASST":1,"EAST":1,"EAT":1,"ECT":1,"EDT":1,"EEDT":1,"EEST":1,"EET":1,"EGST":1,"EGT":1,"EIT":1,"EST":1,"FET":1,"FJT":1,"FKST":1,"FKT":1,"FNT":1,"GALT":1,"GAMT":1,"GET":1,"GFT":1,"GILT":1,"GIT":1,"GMT":1,"GST":1,"GYT":1,"HADT":1,"HAEC":1,"HAST":1,"HKT":1,"HMT":1,"HOVT":1,"HST":1,"ICT":1,"IDT":1,"IOT":1,"IRDT":1,"IRKT":1,"IRST":1,"IST":1,"JST":1,"KGT":1,"KOST":1,"KRAT":1,"KST":1,"LHST":1,"LINT":1,"MAGT":1,"MART":1,"MAWT":1,"MDT":1,"MET":1,"MEST":1,"MHT":1,"MIST":1,"MIT":1,"MMT":1,"MSK":1,"MST":1,"MUT":1,"MVT":1,"MYT":1,"NCT":1,"NDT":1,"NFT":1,"NPT":1,"NST":1,"NT":1,"NUT":1,"NZDT":1,"NZST":1,"OMST":1,"ORAT":1,"PDT":1,"PET":1,"PETT":1,"PGT":1,"PHOT":1,"PHT":1,"PKT":1,"PMDT":1,"PMST":1,"PONT":1,"PST":1,"PYST":1,"PYT":1,"RET":1,"ROTT":1,"SAKT":1,"SAMT":1,"SAST":1,"SBT":1,"SCT":1,"SGT":1,"SLST":1,"SRT":1,"SST":1,"SYOT":1,"TAHT":1,"THA":1,"TFT":1,"TJT":1,"TKT":1,"TLT":1,"TMT":1,"TOT":1,"TVT":1,"UCT":1,"ULAT":1,"UTC":1,"UYST":1,"UYT":1,"UZT":1,"VET":1,"VLAT":1,"VOLT":1,"VOST":1,"VUT":1,"WAKT":1,"WAST":1,"WAT":1,"WEDT":1,"WEST":1,"WET":1,"WST":1,"YAKT":1,"YEKT":1,"Z":1}; return (timezones[value] === 1); }; $D.validateTimezoneOffset= function(value) { // timezones go from +14hrs to -12hrs, the +X hours are negative offsets. return (value > -841 && value < 721); }; }()); (function () { var $D = Date, $P = $D.prototype, p = function (s, l) { if (!l) { l = 2; } return ("000" + s).slice(l * -1); }; var validateConfigObject = function (obj) { var result = {}, self = this, prop, testFunc; testFunc = function (prop, func, value) { if (prop === "day") { var month = (obj.month !== undefined) ? obj.month : self.getMonth(); var year = (obj.year !== undefined) ? obj.year : self.getFullYear(); return $D[func](value, year, month); } else { return $D[func](value); } }; for (prop in obj) { if (Object.prototype.hasOwnProperty.call(obj, prop)) { var func = "validate" + prop.charAt(0).toUpperCase() + prop.slice(1); if ($D[func] && obj[prop] !== null && testFunc(prop, func, obj[prop])) { result[prop] = obj[prop]; } } } return result; }; /** * Resets the time of this Date object to 12:00 AM (00:00), which is the start of the day. * @param {Boolean} .clone() this date instance before clearing Time * @return {Date} this */ $P.clearTime = function () { this.setHours(0); this.setMinutes(0); this.setSeconds(0); this.setMilliseconds(0); return this; }; /** * Resets the time of this Date object to the current time ('now'). * @return {Date} this */ $P.setTimeToNow = function () { var n = new Date(); this.setHours(n.getHours()); this.setMinutes(n.getMinutes()); this.setSeconds(n.getSeconds()); this.setMilliseconds(n.getMilliseconds()); return this; }; /** * Returns a new Date object that is an exact date and time copy of the original instance. * @return {Date} A new Date instance */ $P.clone = function () { return new Date(this.getTime()); }; /** * Compares this instance to a Date object and returns an number indication of their relative values. * @param {Date} Date object to compare [Required] * @return {Number} -1 = this is lessthan date. 0 = values are equal. 1 = this is greaterthan date. */ $P.compareTo = function (date) { return Date.compare(this, date); }; /** * Compares this instance to another Date object and returns true if they are equal. * @param {Date} Date object to compare. If no date to compare, new Date() [now] is used. * @return {Boolean} true if dates are equal. false if they are not equal. */ $P.equals = function (date) { return Date.equals(this, (date !== undefined ? date : new Date())); }; /** * Determines if this instance is between a range of two dates or equal to either the start or end dates. * @param {Date} Start of range [Required] * @param {Date} End of range [Required] * @return {Boolean} true is this is between or equal to the start and end dates, else false */ $P.between = function (start, end) { return this.getTime() >= start.getTime() && this.getTime() <= end.getTime(); }; /** * Determines if this date occurs after the date to compare to. * @param {Date} Date object to compare. If no date to compare, new Date() ("now") is used. * @return {Boolean} true if this date instance is greater than the date to compare to (or "now"), otherwise false. */ $P.isAfter = function (date) { return this.compareTo(date || new Date()) === 1; }; /** * Determines if this date occurs before the date to compare to. * @param {Date} Date object to compare. If no date to compare, new Date() ("now") is used. * @return {Boolean} true if this date instance is less than the date to compare to (or "now"). */ $P.isBefore = function (date) { return (this.compareTo(date || new Date()) === -1); }; /** * Determines if the current Date instance occurs today. * @return {Boolean} true if this date instance is 'today', otherwise false. */ /** * Determines if the current Date instance occurs on the same Date as the supplied 'date'. * If no 'date' to compare to is provided, the current Date instance is compared to 'today'. * @param {date} Date object to compare. If no date to compare, the current Date ("now") is used. * @return {Boolean} true if this Date instance occurs on the same Day as the supplied 'date'. */ $P.isToday = $P.isSameDay = function (date) { return this.clone().clearTime().equals((date || new Date()).clone().clearTime()); }; /** * Adds the specified number of milliseconds to this instance. * @param {Number} The number of milliseconds to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addMilliseconds = function (value) { if (!value) { return this; } this.setTime(this.getTime() + value * 1); return this; }; /** * Adds the specified number of seconds to this instance. * @param {Number} The number of seconds to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addSeconds = function (value) { if (!value) { return this; } return this.addMilliseconds(value * 1000); }; /** * Adds the specified number of seconds to this instance. * @param {Number} The number of seconds to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addMinutes = function (value) { if (!value) { return this; } return this.addMilliseconds(value * 60000); // 60*1000 }; /** * Adds the specified number of hours to this instance. * @param {Number} The number of hours to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addHours = function (value) { if (!value) { return this; } return this.addMilliseconds(value * 3600000); // 60*60*1000 }; /** * Adds the specified number of days to this instance. * @param {Number} The number of days to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addDays = function (value) { if (!value) { return this; } this.setDate(this.getDate() + value * 1); return this; }; /** * Adds the specified number of weekdays (ie - not sat or sun) to this instance. * @param {Number} The number of days to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addWeekdays = function (value) { if (!value) { return this; } var day = this.getDay(); var weeks = (Math.ceil(Math.abs(value)/7)); if (day === 0 || day === 6) { if (value > 0) { this.next().monday(); this.addDays(-1); day = this.getDay(); } } if (value < 0) { while (value < 0) { this.addDays(-1); day = this.getDay(); if (day !== 0 && day !== 6) { value++; } } return this; } else if (value > 5 || (6-day) <= value) { value = value + (weeks * 2); } return this.addDays(value); }; /** * Adds the specified number of weeks to this instance. * @param {Number} The number of weeks to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addWeeks = function (value) { if (!value) { return this; } return this.addDays(value * 7); }; /** * Adds the specified number of months to this instance. * @param {Number} The number of months to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addMonths = function (value) { if (!value) { return this; } var n = this.getDate(); this.setDate(1); this.setMonth(this.getMonth() + value * 1); this.setDate(Math.min(n, $D.getDaysInMonth(this.getFullYear(), this.getMonth()))); return this; }; $P.addQuarters = function (value) { if (!value) { return this; } // note this will take you to the same point in the quarter as you are now. // i.e. - if you are 15 days into the quarter you'll be 15 days into the resulting one. // bonus: this allows adding fractional quarters return this.addMonths(value * 3); }; /** * Adds the specified number of years to this instance. * @param {Number} The number of years to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addYears = function (value) { if (!value) { return this; } return this.addMonths(value * 12); }; /** * Adds (or subtracts) to the value of the years, months, weeks, days, hours, minutes, seconds, milliseconds of the date instance using given configuration object. Positive and Negative values allowed. * Example

	Date.today().add( { days: 1, months: 1 } )

	new Date().add( { years: -1 } )
	
* @param {Object} Configuration object containing attributes (months, days, etc.) * @return {Date} this */ $P.add = function (config) { if (typeof config === "number") { this._orient = config; return this; } var x = config; if (x.day) { // If we should be a different date than today (eg: for 'tomorrow -1d', etc). // Should only effect parsing, not direct usage (eg, Finish and FinishExact) if ((x.day - this.getDate()) !== 0) { this.setDate(x.day); } } if (x.milliseconds) { this.addMilliseconds(x.milliseconds); } if (x.seconds) { this.addSeconds(x.seconds); } if (x.minutes) { this.addMinutes(x.minutes); } if (x.hours) { this.addHours(x.hours); } if (x.weeks) { this.addWeeks(x.weeks); } if (x.months) { this.addMonths(x.months); } if (x.years) { this.addYears(x.years); } if (x.days) { this.addDays(x.days); } return this; }; /** * Get the week number. Week one (1) is the week which contains the first Thursday of the year. Monday is considered the first day of the week. * The .getWeek() function does NOT convert the date to UTC. The local datetime is used. * Please use .getISOWeek() to get the week of the UTC converted date. * @return {Number} 1 to 53 */ $P.getWeek = function (utc) { // Create a copy of this date object var self, target = new Date(this.valueOf()); if (utc) { target.addMinutes(target.getTimezoneOffset()); self = target.clone(); } else { self = this; } // ISO week date weeks start on monday // so correct the day number var dayNr = (self.getDay() + 6) % 7; // ISO 8601 states that week 1 is the week // with the first thursday of that year. // Set the target date to the thursday in the target week target.setDate(target.getDate() - dayNr + 3); // Store the millisecond value of the target date var firstThursday = target.valueOf(); // Set the target to the first thursday of the year // First set the target to january first target.setMonth(0, 1); // Not a thursday? Correct the date to the next thursday if (target.getDay() !== 4) { target.setMonth(0, 1 + ((4 - target.getDay()) + 7) % 7); } // The weeknumber is the number of weeks between the // first thursday of the year and the thursday in the target week return 1 + Math.ceil((firstThursday - target) / 604800000); // 604800000 = 7 * 24 * 3600 * 1000 }; /** * Get the ISO 8601 week number. Week one ("01") is the week which contains the first Thursday of the year. Monday is considered the first day of the week. * The .getISOWeek() function does convert the date to it's UTC value. Please use .getWeek() to get the week of the local date. * @return {String} "01" to "53" */ $P.getISOWeek = function () { return p(this.getWeek(true)); }; /** * Moves the date to Monday of the week set. Week one (1) is the week which contains the first Thursday of the year. * @param {Number} A Number (1 to 53) that represents the week of the year. * @return {Date} this */ $P.setWeek = function (n) { if ((n - this.getWeek()) === 0) { if (this.getDay() !== 1) { return this.moveToDayOfWeek(1, (this.getDay() > 1 ? -1 : 1)); } else { return this; } } else { return this.moveToDayOfWeek(1, (this.getDay() > 1 ? -1 : 1)).addWeeks(n - this.getWeek()); } }; $P.setQuarter = function (qtr) { var month = Math.abs(((qtr-1) * 3) + 1); return this.setMonth(month, 1); }; $P.getQuarter = function () { return Date.getQuarter(this); }; $P.getDaysLeftInQuarter = function () { return Date.getDaysLeftInQuarter(this); }; /** * Moves the date to the next n'th occurrence of the dayOfWeek starting from the beginning of the month. The number (-1) is a magic number and will return the last occurrence of the dayOfWeek in the month. * @param {Number} The dayOfWeek to move to * @param {Number} The n'th occurrence to move to. Use (-1) to return the last occurrence in the month * @return {Date} this */ $P.moveToNthOccurrence = function (dayOfWeek, occurrence) { if (dayOfWeek === "Weekday") { if (occurrence > 0) { this.moveToFirstDayOfMonth(); if (this.is().weekday()) { occurrence -= 1; } } else if (occurrence < 0) { this.moveToLastDayOfMonth(); if (this.is().weekday()) { occurrence += 1; } } else { return this; } return this.addWeekdays(occurrence); } var shift = 0; if (occurrence > 0) { shift = occurrence - 1; } else if (occurrence === -1) { this.moveToLastDayOfMonth(); if (this.getDay() !== dayOfWeek) { this.moveToDayOfWeek(dayOfWeek, -1); } return this; } return this.moveToFirstDayOfMonth().addDays(-1).moveToDayOfWeek(dayOfWeek, +1).addWeeks(shift); }; var moveToN = function (getFunc, addFunc, nVal) { return function (value, orient) { var diff = (value - this[getFunc]() + nVal * (orient || +1)) % nVal; return this[addFunc]((diff === 0) ? diff += nVal * (orient || +1) : diff); }; }; /** * Move to the next or last dayOfWeek based on the orient value. * @param {Number} The dayOfWeek to move to * @param {Number} Forward (+1) or Back (-1). Defaults to +1. [Optional] * @return {Date} this */ $P.moveToDayOfWeek = moveToN("getDay", "addDays", 7); /** * Move to the next or last month based on the orient value. * @param {Number} The month to move to. 0 = January, 11 = December * @param {Number} Forward (+1) or Back (-1). Defaults to +1. [Optional] * @return {Date} this */ $P.moveToMonth = moveToN("getMonth", "addMonths", 12); /** * Get the Ordinate of the current day ("th", "st", "rd"). * @return {String} */ $P.getOrdinate = function () { var num = this.getDate(); return ord(num); }; /** * Get the Ordinal day (numeric day number) of the year, adjusted for leap year. * @return {Number} 1 through 365 (366 in leap years) */ $P.getOrdinalNumber = function () { return Math.ceil((this.clone().clearTime() - new Date(this.getFullYear(), 0, 1)) / 86400000) + 1; }; /** * Get the time zone abbreviation of the current date. * @return {String} The abbreviated time zone name (e.g. "EST") */ $P.getTimezone = function () { return $D.getTimezoneAbbreviation(this.getUTCOffset(), this.isDaylightSavingTime()); }; $P.setTimezoneOffset = function (offset) { var here = this.getTimezoneOffset(), there = Number(offset) * -6 / 10; return (there || there === 0) ? this.addMinutes(there - here) : this; }; $P.setTimezone = function (offset) { return this.setTimezoneOffset($D.getTimezoneOffset(offset)); }; /** * Indicates whether Daylight Saving Time is observed in the current time zone. * @return {Boolean} true|false */ $P.hasDaylightSavingTime = function () { return (Date.today().set({month: 0, day: 1}).getTimezoneOffset() !== Date.today().set({month: 6, day: 1}).getTimezoneOffset()); }; /** * Indicates whether this Date instance is within the Daylight Saving Time range for the current time zone. * @return {Boolean} true|false */ $P.isDaylightSavingTime = function () { return Date.today().set({month: 0, day: 1}).getTimezoneOffset() !== this.getTimezoneOffset(); }; /** * Get the offset from UTC of the current date. * @return {String} The 4-character offset string prefixed with + or - (e.g. "-0500") */ $P.getUTCOffset = function (offset) { var n = (offset || this.getTimezoneOffset()) * -10 / 6, r; if (n < 0) { r = (n - 10000).toString(); return r.charAt(0) + r.substr(2); } else { r = (n + 10000).toString(); return "+" + r.substr(1); } }; /** * Returns the number of milliseconds between this date and date. * @param {Date} Defaults to now * @return {Number} The diff in milliseconds */ $P.getElapsed = function (date) { return (date || new Date()) - this; }; /** * Set the value of year, month, day, hour, minute, second, millisecond of date instance using given configuration object. * Example

	Date.today().set( { day: 20, month: 1 } )

	new Date().set( { millisecond: 0 } )
	
* * @param {Object} Configuration object containing attributes (month, day, etc.) * @return {Date} this */ $P.set = function (config) { config = validateConfigObject.call(this, config); var key; for (key in config) { if (Object.prototype.hasOwnProperty.call(config, key)) { var name = key.charAt(0).toUpperCase() + key.slice(1); var addFunc, getFunc; if (key !== "week" && key !== "month" && key !== "timezone" && key !== "timezoneOffset") { name += "s"; } addFunc = "add" + name; getFunc = "get" + name; if (key === "month") { addFunc = addFunc + "s"; } else if (key === "year"){ getFunc = "getFullYear"; } if (key !== "day" && key !== "timezone" && key !== "timezoneOffset" && key !== "week" && key !== "hour") { this[addFunc](config[key] - this[getFunc]()); } else if ( key === "timezone"|| key === "timezoneOffset" || key === "week" || key === "hour") { this["set"+name](config[key]); } } } // day has to go last because you can't validate the day without first knowing the month if (config.day) { this.addDays(config.day - this.getDate()); } return this; }; /** * Moves the date to the first day of the month. * @return {Date} this */ $P.moveToFirstDayOfMonth = function () { return this.set({ day: 1 }); }; /** * Moves the date to the last day of the month. * @return {Date} this */ $P.moveToLastDayOfMonth = function () { return this.set({ day: $D.getDaysInMonth(this.getFullYear(), this.getMonth())}); }; /** * Converts the value of the current Date object to its equivalent string representation. * Format Specifiers * CUSTOM DATE AND TIME FORMAT STRINGS * Format Description Example * ------ --------------------------------------------------------------------------- ----------------------- * s The seconds of the minute between 0-59. "0" to "59" * ss The seconds of the minute with leading zero if required. "00" to "59" * * m The minute of the hour between 0-59. "0" or "59" * mm The minute of the hour with leading zero if required. "00" or "59" * * h The hour of the day between 1-12. "1" to "12" * hh The hour of the day with leading zero if required. "01" to "12" * * H The hour of the day between 0-23. "0" to "23" * HH The hour of the day with leading zero if required. "00" to "23" * * d The day of the month between 1 and 31. "1" to "31" * dd The day of the month with leading zero if required. "01" to "31" * ddd Abbreviated day name. Date.CultureInfo.abbreviatedDayNames. "Mon" to "Sun" * dddd The full day name. Date.CultureInfo.dayNames. "Monday" to "Sunday" * * M The month of the year between 1-12. "1" to "12" * MM The month of the year with leading zero if required. "01" to "12" * MMM Abbreviated month name. Date.CultureInfo.abbreviatedMonthNames. "Jan" to "Dec" * MMMM The full month name. Date.CultureInfo.monthNames. "January" to "December" * * yy The year as a two-digit number. "99" or "08" * yyyy The full four digit year. "1999" or "2008" * * t Displays the first character of the A.M./P.M. designator. "A" or "P" * Date.CultureInfo.amDesignator or Date.CultureInfo.pmDesignator * tt Displays the A.M./P.M. designator. "AM" or "PM" * Date.CultureInfo.amDesignator or Date.CultureInfo.pmDesignator * * S The ordinal suffix ("st, "nd", "rd" or "th") of the current day. "st, "nd", "rd" or "th" * * STANDARD DATE AND TIME FORMAT STRINGS * Format Description Example *------ --------------------------------------------------------------------------- ----------------------- * d The CultureInfo shortDate Format Pattern "M/d/yyyy" * D The CultureInfo longDate Format Pattern "dddd, MMMM dd, yyyy" * F The CultureInfo fullDateTime Format Pattern "dddd, MMMM dd, yyyy h:mm:ss tt" * m The CultureInfo monthDay Format Pattern "MMMM dd" * r The CultureInfo rfc1123 Format Pattern "ddd, dd MMM yyyy HH:mm:ss GMT" * s The CultureInfo sortableDateTime Format Pattern "yyyy-MM-ddTHH:mm:ss" * t The CultureInfo shortTime Format Pattern "h:mm tt" * T The CultureInfo longTime Format Pattern "h:mm:ss tt" * u The CultureInfo universalSortableDateTime Format Pattern "yyyy-MM-dd HH:mm:ssZ" * y The CultureInfo yearMonth Format Pattern "MMMM, yyyy" * * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @return {String} A string representation of the current Date object. */ var ord = function (n) { switch (n * 1) { case 1: case 21: case 31: return "st"; case 2: case 22: return "nd"; case 3: case 23: return "rd"; default: return "th"; } }; var parseStandardFormats = function (format) { var y, c = Date.CultureInfo.formatPatterns; switch (format) { case "d": return this.toString(c.shortDate); case "D": return this.toString(c.longDate); case "F": return this.toString(c.fullDateTime); case "m": return this.toString(c.monthDay); case "r": case "R": y = this.clone().addMinutes(this.getTimezoneOffset()); return y.toString(c.rfc1123) + " GMT"; case "s": return this.toString(c.sortableDateTime); case "t": return this.toString(c.shortTime); case "T": return this.toString(c.longTime); case "u": y = this.clone().addMinutes(this.getTimezoneOffset()); return y.toString(c.universalSortableDateTime); case "y": return this.toString(c.yearMonth); default: return false; } }; var parseFormatStringsClosure = function (context) { return function (m) { if (m.charAt(0) === "\\") { return m.replace("\\", ""); } switch (m) { case "hh": return p(context.getHours() < 13 ? (context.getHours() === 0 ? 12 : context.getHours()) : (context.getHours() - 12)); case "h": return context.getHours() < 13 ? (context.getHours() === 0 ? 12 : context.getHours()) : (context.getHours() - 12); case "HH": return p(context.getHours()); case "H": return context.getHours(); case "mm": return p(context.getMinutes()); case "m": return context.getMinutes(); case "ss": return p(context.getSeconds()); case "s": return context.getSeconds(); case "yyyy": return p(context.getFullYear(), 4); case "yy": return p(context.getFullYear()); case "y": return context.getFullYear(); case "E": case "dddd": return Date.CultureInfo.dayNames[context.getDay()]; case "ddd": return Date.CultureInfo.abbreviatedDayNames[context.getDay()]; case "dd": return p(context.getDate()); case "d": return context.getDate(); case "MMMM": return Date.CultureInfo.monthNames[context.getMonth()]; case "MMM": return Date.CultureInfo.abbreviatedMonthNames[context.getMonth()]; case "MM": return p((context.getMonth() + 1)); case "M": return context.getMonth() + 1; case "t": return context.getHours() < 12 ? Date.CultureInfo.amDesignator.substring(0, 1) : Date.CultureInfo.pmDesignator.substring(0, 1); case "tt": return context.getHours() < 12 ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator; case "S": return ord(context.getDate()); case "W": return context.getWeek(); case "WW": return context.getISOWeek(); case "Q": return "Q" + context.getQuarter(); case "q": return String(context.getQuarter()); case "z": return context.getTimezone(); case "Z": case "X": return Date.getTimezoneOffset(context.getTimezone()); case "ZZ": // Timezone offset in seconds return context.getTimezoneOffset() * -60; case "u": return context.getDay(); case "L": return ($D.isLeapYear(context.getFullYear())) ? 1 : 0; case "B": // Swatch Internet Time (.beats) return "@"+((context.getUTCSeconds() + (context.getUTCMinutes()*60) + ((context.getUTCHours()+1)*3600))/86.4); default: return m; } }; }; $P.toString = function (format, ignoreStandards) { // Standard Date and Time Format Strings. Formats pulled from CultureInfo file and // may vary by culture. if (!ignoreStandards && format && format.length === 1) { output = parseStandardFormats.call(this, format); if (output) { return output; } } var parseFormatStrings = parseFormatStringsClosure(this); return format ? format.replace(/((\\)?(dd?d?d?|MM?M?M?|yy?y?y?|hh?|HH?|mm?|ss?|tt?|S|q|Q|WW?W?W?)(?![^\[]*\]))/g, parseFormatStrings).replace(/\[|\]/g, "") : this._toString(); }; }()); /************************************************************* * SugarPak - Domain Specific Language - Syntactical Sugar * *************************************************************/ (function () { var $D = Date, $P = $D.prototype, $N = Number.prototype; // private $P._orient = +1; // private $P._nth = null; // private $P._is = false; // private $P._same = false; // private $P._isSecond = false; // private $N._dateElement = "days"; /** * Moves the date to the next instance of a date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.today().next().friday();
	Date.today().next().fri();
	Date.today().next().march();
	Date.today().next().mar();
	Date.today().next().week();
	
* * @return {Date} date */ $P.next = function () { this._move = true; this._orient = +1; return this; }; /** * Creates a new Date (Date.today()) and moves the date to the next instance of the date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.next().friday();
	Date.next().fri();
	Date.next().march();
	Date.next().mar();
	Date.next().week();
	
* * @return {Date} date */ $D.next = function () { return $D.today().next(); }; /** * Moves the date to the previous instance of a date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.today().last().friday();
	Date.today().last().fri();
	Date.today().last().march();
	Date.today().last().mar();
	Date.today().last().week();
	
* * @return {Date} date */ $P.last = $P.prev = $P.previous = function () { this._move = true; this._orient = -1; return this; }; /** * Creates a new Date (Date.today()) and moves the date to the previous instance of the date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.last().friday();
	Date.last().fri();
	Date.previous().march();
	Date.prev().mar();
	Date.last().week();
	
* * @return {Date} date */ $D.last = $D.prev = $D.previous = function () { return $D.today().last(); }; /** * Performs a equality check when followed by either a month name, day name or .weekday() function. * Example

	Date.today().is().friday(); // true|false
	Date.today().is().fri();
	Date.today().is().march();
	Date.today().is().mar();
	
* * @return {Boolean} true|false */ $P.is = function () { this._is = true; return this; }; /** * Determines if two date objects occur on/in exactly the same instance of the subsequent date part function. * The function .same() must be followed by a date part function (example: .day(), .month(), .year(), etc). * * An optional Date can be passed in the date part function. If now date is passed as a parameter, 'Now' is used. * * The following example demonstrates how to determine if two dates fall on the exact same day. * * Example

	var d1 = Date.today(); // today at 00:00
	var d2 = new Date();   // exactly now.

	// Do they occur on the same day?
	d1.same().day(d2); // true
	
	// Do they occur on the same hour?
	d1.same().hour(d2); // false, unless d2 hour is '00' (midnight).
	
	// What if it's the same day, but one year apart?
	var nextYear = Date.today().add(1).year();

	d1.same().day(nextYear); // false, because the dates must occur on the exact same day. 
	
* * Scenario: Determine if a given date occurs during some week period 2 months from now. * * Example

	var future = Date.today().add(2).months();
	return someDate.same().week(future); // true|false;
	
* * @return {Boolean} true|false */ $P.same = function () { this._same = true; this._isSecond = false; return this; }; /** * Determines if the current date/time occurs during Today. Must be preceded by the .is() function. * Example

	someDate.is().today();    // true|false
	new Date().is().today();  // true
	Date.today().is().today();// true
	Date.today().add(-1).day().is().today(); // false
	
* * @return {Boolean} true|false */ $P.today = function () { return this.same().day(); }; /** * Determines if the current date is a weekday. This function must be preceded by the .is() function. * Example

	Date.today().is().weekday(); // true|false
	
* * @return {Boolean} true|false */ $P.weekday = function () { if (this._nth) { return df("Weekday").call(this); } if (this._move) { return this.addWeekdays(this._orient); } if (this._is) { this._is = false; return (!this.is().sat() && !this.is().sun()); } return false; }; /** * Determines if the current date is on the weekend. This function must be preceded by the .is() function. * Example

	Date.today().is().weekend(); // true|false
	
* * @return {Boolean} true|false */ $P.weekend = function () { if (this._is) { this._is = false; return (this.is().sat() || this.is().sun()); } return false; }; /** * Sets the Time of the current Date instance. A string "6:15 pm" or config object {hour:18, minute:15} are accepted. * Example

	// Set time to 6:15pm with a String
	Date.today().at("6:15pm");

	// Set time to 6:15pm with a config object
	Date.today().at({hour:18, minute:15});
	
* * @return {Date} date */ $P.at = function (time) { return (typeof time === "string") ? $D.parse(this.toString("d") + " " + time) : this.set(time); }; /** * Creates a new Date() and adds this (Number) to the date based on the preceding date element function (eg. second|minute|hour|day|month|year). * Example

	// Undeclared Numbers must be wrapped with parentheses. Requirment of JavaScript.
	(3).days().fromNow();
	(6).months().fromNow();

	// Declared Number variables do not require parentheses. 
	var n = 6;
	n.months().fromNow();
	
* * @return {Date} A new Date instance */ $N.fromNow = $N.after = function (date) { var c = {}; c[this._dateElement] = this; return ((!date) ? new Date() : date.clone()).add(c); }; /** * Creates a new Date() and subtract this (Number) from the date based on the preceding date element function (eg. second|minute|hour|day|month|year). * Example

	// Undeclared Numbers must be wrapped with parentheses. Requirment of JavaScript.
	(3).days().ago();
	(6).months().ago();

	// Declared Number variables do not require parentheses. 
	var n = 6;
	n.months().ago();
	
* * @return {Date} A new Date instance */ $N.ago = $N.before = function (date) { var c = {}, s = (this._dateElement[this._dateElement.length-1] !== "s") ? this._dateElement + "s" : this._dateElement; c[s] = this * -1; return ((!date) ? new Date() : date.clone()).add(c); }; // Do NOT modify the following string tokens. These tokens are used to build dynamic functions. // All culture-specific strings can be found in the CultureInfo files. var dx = ("sunday monday tuesday wednesday thursday friday saturday").split(/\s/), mx = ("january february march april may june july august september october november december").split(/\s/), px = ("Millisecond Second Minute Hour Day Week Month Year Quarter Weekday").split(/\s/), pxf = ("Milliseconds Seconds Minutes Hours Date Week Month FullYear Quarter").split(/\s/), nth = ("final first second third fourth fifth").split(/\s/), de; /** * Returns an object literal of all the date parts. * Example

	var o = new Date().toObject();
	
	// { year: 2008, month: 4, week: 20, day: 13, hour: 18, minute: 9, second: 32, millisecond: 812 }
	
	// The object properties can be referenced directly from the object.
	
	alert(o.day);  // alerts "13"
	alert(o.year); // alerts "2008"
	
* * @return {Date} An object literal representing the original date object. */ $P.toObject = function () { var o = {}; for (var i = 0; i < px.length; i++) { if (this["get" + pxf[i]]) { o[px[i].toLowerCase()] = this["get" + pxf[i]](); } } return o; }; /** * Returns a date created from an object literal. Ignores the .week property if set in the config. * Example

	var o = new Date().toObject();
	
	return Date.fromObject(o); // will return the same date. 

	var o2 = {month: 1, day: 20, hour: 18}; // birthday party!
	Date.fromObject(o2);
	
* * @return {Date} An object literal representing the original date object. */ $D.fromObject = function(config) { config.week = null; return Date.today().set(config); }; // Create day name functions and abbreviated day name functions (eg. monday(), friday(), fri()). var df = function (n) { return function () { if (this._is) { this._is = false; return this.getDay() === n; } if (this._move) { this._move = null; } if (this._nth !== null) { // If the .second() function was called earlier, remove the _orient // from the date, and then continue. // This is required because 'second' can be used in two different context. // // Example // // Date.today().add(1).second(); // Date.march().second().monday(); // // Things get crazy with the following... // Date.march().add(1).second().second().monday(); // but it works!! // if (this._isSecond) { this.addSeconds(this._orient * -1); } // make sure we reset _isSecond this._isSecond = false; var ntemp = this._nth; this._nth = null; var temp = this.clone().moveToLastDayOfMonth(); this.moveToNthOccurrence(n, ntemp); if (this > temp) { throw new RangeError($D.getDayName(n) + " does not occur " + ntemp + " times in the month of " + $D.getMonthName(temp.getMonth()) + " " + temp.getFullYear() + "."); } return this; } return this.moveToDayOfWeek(n, this._orient); }; }; var sdf = function (n) { return function () { var t = $D.today(), shift = n - t.getDay(); if (n === 0 && Date.CultureInfo.firstDayOfWeek === 1 && t.getDay() !== 0) { shift = shift + 7; } return t.addDays(shift); }; }; // Create month name functions and abbreviated month name functions (eg. january(), march(), mar()). var month_instance_functions = function (n) { return function () { if (this._is) { this._is = false; return this.getMonth() === n; } return this.moveToMonth(n, this._orient); }; }; var month_static_functions = function (n) { return function () { return $D.today().set({ month: n, day: 1 }); }; }; var processTerms = function (names, staticFunc, instanceFunc) { for (var i = 0; i < names.length; i++) { // Create constant static Name variables. $D[names[i].toUpperCase()] = $D[names[i].toUpperCase().substring(0, 3)] = i; // Create Name functions. $D[names[i]] = $D[names[i].substring(0, 3)] = staticFunc(i); // Create Name instance functions. $P[names[i]] = $P[names[i].substring(0, 3)] = instanceFunc(i); } }; processTerms(dx, sdf, df); processTerms(mx, month_static_functions, month_instance_functions); // Create date element functions and plural date element functions used with Date (eg. day(), days(), months()). var ef = function (j) { return function () { // if the .second() function was called earlier, the _orient // has alread been added. Just return this and reset _isSecond. if (this._isSecond) { this._isSecond = false; return this; } if (this._same) { this._same = this._is = false; var o1 = this.toObject(), o2 = (arguments[0] || new Date()).toObject(), v = "", k = j.toLowerCase(); // the substr trick with -1 doesn't work in IE8 or less k = (k[k.length-1] === "s") ? k.substring(0,k.length-1) : k; for (var m = (px.length - 1); m > -1; m--) { v = px[m].toLowerCase(); if (o1[v] !== o2[v]) { return false; } if (k === v) { break; } } return true; } if (j.substring(j.length - 1) !== "s") { j += "s"; } if (this._move) { this._move = null; } return this["add" + j](this._orient); }; }; var nf = function (n) { return function () { this._dateElement = n; return this; }; }; for (var k = 0; k < px.length; k++) { de = px[k].toLowerCase(); if(de !== "weekday") { // Create date element functions and plural date element functions used with Date (eg. day(), days(), months()). $P[de] = $P[de + "s"] = ef(px[k]); // Create date element functions and plural date element functions used with Number (eg. day(), days(), months()). $N[de] = $N[de + "s"] = nf(de + "s"); } } $P._ss = ef("Second"); var nthfn = function (n) { return function (dayOfWeek) { if (this._same) { return this._ss(arguments[0]); } if (dayOfWeek || dayOfWeek === 0) { return this.moveToNthOccurrence(dayOfWeek, n); } this._nth = n; // if the operator is 'second' add the _orient, then deal with it later... if (n === 2 && (dayOfWeek === undefined || dayOfWeek === null)) { this._isSecond = true; return this.addSeconds(this._orient); } return this; }; }; for (var l = 0; l < nth.length; l++) { $P[nth[l]] = (l === 0) ? nthfn(-1) : nthfn(l); } }()); (function () { "use strict"; Date.Parsing = { Exception: function (s) { this.message = "Parse error at '" + s.substring(0, 10) + " ...'"; } }; var $P = Date.Parsing; var dayOffsets = { standard: [0,31,59,90,120,151,181,212,243,273,304,334], leap: [0,31,60,91,121,152,182,213,244,274,305,335] }; $P.isLeapYear = function(year) { return ((year % 4 === 0) && (year % 100 !== 0)) || (year % 400 === 0); }; var utils = { multiReplace : function (str, hash ) { var key; for (key in hash) { if (Object.prototype.hasOwnProperty.call(hash, key)) { var regex; if (typeof hash[key] === "function") { } else { regex = (hash[key] instanceof RegExp) ? hash[key] : new RegExp(hash[key], "g"); } str = str.replace(regex, key); } } return str; }, getDayOfYearFromWeek : function (obj) { var d, jan4, offset; obj.weekDay = (!obj.weekDay && obj.weekDay !== 0) ? 1 : obj.weekDay; d = new Date(obj.year, 0, 4); jan4 = d.getDay() === 0 ? 7 : d.getDay(); // JS is 0 indexed on Sunday. offset = jan4+3; obj.dayOfYear = ((obj.week * 7) + (obj.weekDay === 0 ? 7 : obj.weekDay))-offset; return obj; }, getDayOfYear : function (obj, dayOffset) { if (!obj.dayOfYear) { obj = utils.getDayOfYearFromWeek(obj); } for (var i=0;i <= dayOffset.length;i++) { if (obj.dayOfYear < dayOffset[i] || i === dayOffset.length) { obj.day = obj.day ? obj.day : (obj.dayOfYear - dayOffset[i-1]); break; } else { obj.month = i; } } return obj; }, adjustForTimeZone : function (obj, date) { var offset; if (obj.zone.toUpperCase() === "Z" || (obj.zone_hours === 0 && obj.zone_minutes === 0)) { // it's UTC/GML so work out the current timeszone offset offset = -date.getTimezoneOffset(); } else { offset = (obj.zone_hours*60) + (obj.zone_minutes || 0); if (obj.zone_sign === "+") { offset *= -1; } offset -= date.getTimezoneOffset(); } date.setMinutes(date.getMinutes()+offset); return date; }, setDefaults : function (obj) { obj.year = obj.year || Date.today().getFullYear(); obj.hours = obj.hours || 0; obj.minutes = obj.minutes || 0; obj.seconds = obj.seconds || 0; obj.milliseconds = obj.milliseconds || 0; if (!(!obj.month && (obj.week || obj.dayOfYear))) { // if we have a month, or if we don't but don't have the day calculation data obj.month = obj.month || 0; obj.day = obj.day || 1; } return obj; }, dataNum: function (data, mod, explict, postProcess) { var dataNum = data*1; if (mod) { if (postProcess) { return data ? mod(data)*1 : data; } else { return data ? mod(dataNum) : data; } } else if (!explict){ return data ? dataNum : data; } else { return (data && typeof data !== "undefined") ? dataNum : data; } }, timeDataProcess: function (obj) { var timeObj = {}; for (var x in obj.data) { if (obj.data.hasOwnProperty(x)) { timeObj[x] = obj.ignore[x] ? obj.data[x] : utils.dataNum(obj.data[x], obj.mods[x], obj.explict[x], obj.postProcess[x]); } } if (obj.data.secmins) { obj.data.secmins = obj.data.secmins.replace(",", ".") * 60; if (!timeObj.minutes) { timeObj.minutes = obj.data.secmins; } else if (!timeObj.seconds) { timeObj.seconds = obj.data.secmins; } delete obj.secmins; } return timeObj; }, buildTimeObjectFromData: function (data) { var time = utils.timeDataProcess({ data: { year : data[1], month : data[5], day : data[7], week : data[8], dayOfYear : data[10], hours : data[15], zone_hours : data[23], zone_minutes : data[24], zone : data[21], zone_sign : data[22], weekDay : data[9], minutes: data[16], seconds: data[19], milliseconds: data[20], secmins: data[18] }, mods: { month: function(data) { return data-1; }, weekDay: function (data) { data = Math.abs(data); return (data === 7 ? 0 : data); }, minutes: function (data) { return data.replace(":",""); }, seconds: function (data) { return Math.floor( (data.replace(":","").replace(",","."))*1 ); }, milliseconds: function (data) { return (data.replace(",",".")*1000); } }, postProcess: { minutes: true, seconds: true, milliseconds: true }, explict: { zone_hours: true, zone_minutes: true }, ignore: { zone: true, zone_sign: true, secmins: true } }); return time; }, addToHash: function (hash, keys, data) { keys = keys; data = data; var len = keys.length; for (var i = 0; i < len; i++) { hash[keys[i]] = data[i]; } return hash; }, combineRegex: function (r1, r2) { return new RegExp("(("+r1.source+")\\s("+r2.source+"))"); }, getDateNthString: function(add, last, inc){ if (add) { return Date.today().addDays(inc).toString("d"); } else if (last) { return Date.today().last()[inc]().toString("d"); } }, buildRegexData: function (array) { var arr = []; var len = array.length; for (var i=0; i < len; i++) { if (Object.prototype.toString.call(array[i]) === '[object Array]') { // oldIE compat version of Array.isArray arr.push(this.combineRegex(array[i][0], array[i][1])); } else { arr.push(array[i]); } } return arr; } }; $P.processTimeObject = function (obj) { var date, dayOffset; utils.setDefaults(obj); dayOffset = ($P.isLeapYear(obj.year)) ? dayOffsets.leap : dayOffsets.standard; if (!obj.month && (obj.week || obj.dayOfYear)) { utils.getDayOfYear(obj, dayOffset); } else { obj.dayOfYear = dayOffset[obj.month] + obj.day; } date = new Date(obj.year, obj.month, obj.day, obj.hours, obj.minutes, obj.seconds, obj.milliseconds); if (obj.zone) { utils.adjustForTimeZone(obj, date); // adjust (and calculate) for timezone } return date; }; $P.ISO = { regex : /^([\+-]?\d{4}(?!\d{2}\b))((-?)((0[1-9]|1[0-2])(\3([12]\d|0[1-9]|3[01]))?|W([0-4]\d|5[0-3])(-?[1-7])?|(00[1-9]|0[1-9]\d|[12]\d{2}|3([0-5]\d|6[1-6])))([T\s]((([01]\d|2[0-4])((:?)[0-5]\d)?|24\:?00)([\.,]\d+(?!:))?)?(\17[0-5]\d([\.,]\d+)?)?\s?([zZ]|([\+-])([01]\d|2[0-3]):?([0-5]\d)?)?)?)?$/, parse : function (s) { var time, data = s.match(this.regex); if (!data || !data.length) { return null; } time = utils.buildTimeObjectFromData(data); if (!time.year || (!time.year && (!time.month && !time.day) && (!time.week && !time.dayOfYear)) ) { return null; } return $P.processTimeObject(time); } }; $P.Numeric = { isNumeric: function (e){return!isNaN(parseFloat(e))&&isFinite(e);}, regex: /\b([0-1]?[0-9])([0-3]?[0-9])([0-2]?[0-9]?[0-9][0-9])\b/i, parse: function (s) { var data, i, time = {}, order = Date.CultureInfo.dateElementOrder.split(""); if (!(this.isNumeric(s)) || // if it's non-numeric OR (s[0] === "+" && s[0] === "-")) { // It's an arithmatic string (eg +/-1000) return null; } if (s.length < 5 && s.indexOf(".") < 0 && s.indexOf("/") < 0) { // assume it's just a year. time.year = s; return $P.processTimeObject(time); } data = s.match(this.regex); if (!data || !data.length) { return null; } for (i=0; i < order.length; i++) { switch(order[i]) { case "d": time.day = data[i+1]; break; case "m": time.month = (data[i+1]-1); break; case "y": time.year = data[i+1]; break; } } return $P.processTimeObject(time); } }; $P.Normalizer = { regexData: function () { var $R = Date.CultureInfo.regexPatterns; return utils.buildRegexData([ $R.tomorrow, $R.yesterday, [$R.past, $R.mon], [$R.past, $R.tue], [$R.past, $R.wed], [$R.past, $R.thu], [$R.past, $R.fri], [$R.past, $R.sat], [$R.past, $R.sun] ]); }, basicReplaceHash : function() { var $R = Date.CultureInfo.regexPatterns; return { "January": $R.jan.source, "February": $R.feb, "March": $R.mar, "April": $R.apr, "May": $R.may, "June": $R.jun, "July": $R.jul, "August": $R.aug, "September": $R.sep, "October": $R.oct, "November": $R.nov, "December": $R.dec, "": /\bat\b/gi, " ": /\s{2,}/, "am": $R.inTheMorning, "9am": $R.thisMorning, "pm": $R.inTheEvening, "7pm":$R.thisEvening }; }, keys : function(){ return [ utils.getDateNthString(true, false, 1), // tomorrow utils.getDateNthString(true, false, -1), // yesterday utils.getDateNthString(false, true, "monday"), //last mon utils.getDateNthString(false, true, "tuesday"), //last tues utils.getDateNthString(false, true, "wednesday"), //last wed utils.getDateNthString(false, true, "thursday"), //last thurs utils.getDateNthString(false, true, "friday"), //last fri utils.getDateNthString(false, true, "saturday"), //last sat utils.getDateNthString(false, true, "sunday") //last sun ]; }, buildRegexFunctions: function () { var $R = Date.CultureInfo.regexPatterns; var __ = Date.i18n.__; var tomorrowRE = new RegExp("(\\b\\d\\d?("+__("AM")+"|"+__("PM")+")? )("+$R.tomorrow.source.slice(1)+")", "i"); // adapted tomorrow regex for AM PM relative dates var todayRE = new RegExp($R.today.source + "(?!\\s*([+-]))\\b"); // today, but excludes the math operators (eg "today + 2h") this.replaceFuncs = [ [todayRE, function (full) { return (full.length > 1) ? Date.today().toString("d") : full; }], [tomorrowRE, function(full, m1) { var t = Date.today().addDays(1).toString("d"); return (t + " " + m1); }], [$R.amThisMorning, function(str, am){return am;}], [$R.pmThisEvening, function(str, pm){return pm;}] ]; }, buildReplaceData: function () { this.buildRegexFunctions(); this.replaceHash = utils.addToHash(this.basicReplaceHash(), this.keys(), this.regexData()); }, stringReplaceFuncs: function (s) { for (var i=0; i < this.replaceFuncs.length; i++) { s = s.replace(this.replaceFuncs[i][0], this.replaceFuncs[i][1]); } return s; }, parse: function (s) { s = this.stringReplaceFuncs(s); s = utils.multiReplace(s, this.replaceHash); try { var n = s.split(/([\s\-\.\,\/\x27]+)/); if (n.length === 3 && $P.Numeric.isNumeric(n[0]) && $P.Numeric.isNumeric(n[2]) && (n[2].length >= 4)) { // ok, so we're dealing with x/year. But that's not a full date. // This fixes wonky dateElementOrder parsing when set to dmy order. if (Date.CultureInfo.dateElementOrder[0] === "d") { s = "1/" + n[0] + "/" + n[2]; // set to 1st of month and normalize the seperator } } } catch (e) {} return s; } }; $P.Normalizer.buildReplaceData(); }()); (function () { var $P = Date.Parsing; var _ = $P.Operators = { // // Tokenizers // rtoken: function (r) { // regex token return function (s) { var mx = s.match(r); if (mx) { return ([ mx[0], s.substring(mx[0].length) ]); } else { throw new $P.Exception(s); } }; }, token: function () { // whitespace-eating token return function (s) { return _.rtoken(new RegExp("^\\s*" + s + "\\s*"))(s); }; }, stoken: function (s) { // string token return _.rtoken(new RegExp("^" + s)); }, // Atomic Operators until: function (p) { return function (s) { var qx = [], rx = null; while (s.length) { try { rx = p.call(this, s); } catch (e) { qx.push(rx[0]); s = rx[1]; continue; } break; } return [ qx, s ]; }; }, many: function (p) { return function (s) { var rx = [], r = null; while (s.length) { try { r = p.call(this, s); } catch (e) { return [ rx, s ]; } rx.push(r[0]); s = r[1]; } return [ rx, s ]; }; }, // generator operators -- see below optional: function (p) { return function (s) { var r = null; try { r = p.call(this, s); } catch (e) { return [ null, s ]; } return [ r[0], r[1] ]; }; }, not: function (p) { return function (s) { try { p.call(this, s); } catch (e) { return [null, s]; } throw new $P.Exception(s); }; }, ignore: function (p) { return p ? function (s) { var r = null; r = p.call(this, s); return [null, r[1]]; } : null; }, product: function () { var px = arguments[0], qx = Array.prototype.slice.call(arguments, 1), rx = []; for (var i = 0 ; i < px.length ; i++) { rx.push(_.each(px[i], qx)); } return rx; }, cache: function (rule) { var cache = {}, cache_length = 0, cache_keys = [], CACHE_MAX = Date.Config.CACHE_MAX || 100000, r = null; var cacheCheck = function () { if (cache_length === CACHE_MAX) { // kill several keys, don't want to have to do this all the time... for (var i=0; i < 10; i++) { var key = cache_keys.shift(); if (key) { delete cache[key]; cache_length--; } } } }; return function (s) { cacheCheck(); try { r = cache[s] = (cache[s] || rule.call(this, s)); } catch (e) { r = cache[s] = e; } cache_length++; cache_keys.push(s); if (r instanceof $P.Exception) { throw r; } else { return r; } }; }, // vector operators -- see below any: function () { var px = arguments; return function (s) { var r = null; for (var i = 0; i < px.length; i++) { if (px[i] == null) { continue; } try { r = (px[i].call(this, s)); } catch (e) { r = null; } if (r) { return r; } } throw new $P.Exception(s); }; }, each: function () { var px = arguments; return function (s) { var rx = [], r = null; for (var i = 0; i < px.length ; i++) { if (px[i] == null) { continue; } try { r = (px[i].call(this, s)); } catch (e) { throw new $P.Exception(s); } rx.push(r[0]); s = r[1]; } return [ rx, s]; }; }, all: function () { var px = arguments, _ = _; return _.each(_.optional(px)); }, // delimited operators sequence: function (px, d, c) { d = d || _.rtoken(/^\s*/); c = c || null; if (px.length === 1) { return px[0]; } return function (s) { var r = null, q = null; var rx = []; for (var i = 0; i < px.length ; i++) { try { r = px[i].call(this, s); } catch (e) { break; } rx.push(r[0]); try { q = d.call(this, r[1]); } catch (ex) { q = null; break; } s = q[1]; } if (!r) { throw new $P.Exception(s); } if (q) { throw new $P.Exception(q[1]); } if (c) { try { r = c.call(this, r[1]); } catch (ey) { throw new $P.Exception(r[1]); } } return [ rx, (r?r[1]:s) ]; }; }, // // Composite Operators // between: function (d1, p, d2) { d2 = d2 || d1; var _fn = _.each(_.ignore(d1), p, _.ignore(d2)); return function (s) { var rx = _fn.call(this, s); return [[rx[0][0], r[0][2]], rx[1]]; }; }, list: function (p, d, c) { d = d || _.rtoken(/^\s*/); c = c || null; return (p instanceof Array ? _.each(_.product(p.slice(0, -1), _.ignore(d)), p.slice(-1), _.ignore(c)) : _.each(_.many(_.each(p, _.ignore(d))), px, _.ignore(c))); }, set: function (px, d, c) { d = d || _.rtoken(/^\s*/); c = c || null; return function (s) { // r is the current match, best the current 'best' match // which means it parsed the most amount of input var r = null, p = null, q = null, rx = null, best = [[], s], last = false; // go through the rules in the given set for (var i = 0; i < px.length ; i++) { // last is a flag indicating whether this must be the last element // if there is only 1 element, then it MUST be the last one q = null; p = null; r = null; last = (px.length === 1); // first, we try simply to match the current pattern // if not, try the next pattern try { r = px[i].call(this, s); } catch (e) { continue; } // since we are matching against a set of elements, the first // thing to do is to add r[0] to matched elements rx = [[r[0]], r[1]]; // if we matched and there is still input to parse and // we don't already know this is the last element, // we're going to next check for the delimiter ... // if there's none, or if there's no input left to parse // than this must be the last element after all ... if (r[1].length > 0 && ! last) { try { q = d.call(this, r[1]); } catch (ex) { last = true; } } else { last = true; } // if we parsed the delimiter and now there's no more input, // that means we shouldn't have parsed the delimiter at all // so don't update r and mark this as the last element ... if (!last && q[1].length === 0) { last = true; } // so, if this isn't the last element, we're going to see if // we can get any more matches from the remaining (unmatched) // elements ... if (!last) { // build a list of the remaining rules we can match against, // i.e., all but the one we just matched against var qx = []; for (var j = 0; j < px.length ; j++) { if (i !== j) { qx.push(px[j]); } } // now invoke recursively set with the remaining input // note that we don't include the closing delimiter ... // we'll check for that ourselves at the end p = _.set(qx, d).call(this, q[1]); // if we got a non-empty set as a result ... // (otw rx already contains everything we want to match) if (p[0].length > 0) { // update current result, which is stored in rx ... // basically, pick up the remaining text from p[1] // and concat the result from p[0] so that we don't // get endless nesting ... rx[0] = rx[0].concat(p[0]); rx[1] = p[1]; } } // at this point, rx either contains the last matched element // or the entire matched set that starts with this element. // now we just check to see if this variation is better than // our best so far, in terms of how much of the input is parsed if (rx[1].length < best[1].length) { best = rx; } // if we've parsed all the input, then we're finished if (best[1].length === 0) { break; } } // so now we've either gone through all the patterns trying them // as the initial match; or we found one that parsed the entire // input string ... // if best has no matches, just return empty set ... if (best[0].length === 0) { return best; } // if a closing delimiter is provided, then we have to check it also if (c) { // we try this even if there is no remaining input because the pattern // may well be optional or match empty input ... try { q = c.call(this, best[1]); } catch (ey) { throw new $P.Exception(best[1]); } // it parsed ... be sure to update the best match remaining input best[1] = q[1]; } // if we're here, either there was no closing delimiter or we parsed it // so now we have the best match; just return it! return best; }; }, forward: function (gr, fname) { return function (s) { return gr[fname].call(this, s); }; }, // // Translation Operators // replace: function (rule, repl) { return function (s) { var r = rule.call(this, s); return [repl, r[1]]; }; }, process: function (rule, fn) { return function (s) { var r = rule.call(this, s); return [fn.call(this, r[0]), r[1]]; }; }, min: function (min, rule) { return function (s) { var rx = rule.call(this, s); if (rx[0].length < min) { throw new $P.Exception(s); } return rx; }; } }; // Generator Operators And Vector Operators // Generators are operators that have a signature of F(R) => R, // taking a given rule and returning another rule, such as // ignore, which parses a given rule and throws away the result. // Vector operators are those that have a signature of F(R1,R2,...) => R, // take a list of rules and returning a new rule, such as each. // Generator operators are converted (via the following _generator // function) into functions that can also take a list or array of rules // and return an array of new rules as though the function had been // called on each rule in turn (which is what actually happens). // This allows generators to be used with vector operators more easily. // Example: // each(ignore(foo, bar)) instead of each(ignore(foo), ignore(bar)) // This also turns generators into vector operators, which allows // constructs like: // not(cache(foo, bar)) var _generator = function (op) { function gen() { var args = null, rx = [], px, i; if (arguments.length > 1) { args = Array.prototype.slice.call(arguments); } else if (arguments[0] instanceof Array) { args = arguments[0]; } if (args) { px = args.shift(); if (px.length > 0) { args.unshift(px[i]); rx.push(op.apply(null, args)); args.shift(); return rx; } } else { return op.apply(null, arguments); } } return gen; }; var gx = "optional not ignore cache".split(/\s/); for (var i = 0 ; i < gx.length ; i++) { _[gx[i]] = _generator(_[gx[i]]); } var _vector = function (op) { return function () { if (arguments[0] instanceof Array) { return op.apply(null, arguments[0]); } else { return op.apply(null, arguments); } }; }; var vx = "each any all".split(/\s/); for (var j = 0 ; j < vx.length ; j++) { _[vx[j]] = _vector(_[vx[j]]); } }()); (function () { var $D = Date; var flattenAndCompact = function (ax) { var rx = []; for (var i = 0; i < ax.length; i++) { if (ax[i] instanceof Array) { rx = rx.concat(flattenAndCompact(ax[i])); } else { if (ax[i]) { rx.push(ax[i]); } } } return rx; }; var parseMeridian = function () { if (this.meridian && (this.hour || this.hour === 0)) { if (this.meridian === "a" && this.hour > 11 && Date.Config.strict24hr){ throw "Invalid hour and meridian combination"; } else if (this.meridian === "p" && this.hour < 12 && Date.Config.strict24hr){ throw "Invalid hour and meridian combination"; } else if (this.meridian === "p" && this.hour < 12) { this.hour = this.hour + 12; } else if (this.meridian === "a" && this.hour === 12) { this.hour = 0; } } }; var setDefaults = function () { var now = new Date(); if ((this.hour || this.minute) && (!this.month && !this.year && !this.day)) { this.day = now.getDate(); } if (!this.year) { this.year = now.getFullYear(); } if (!this.month && this.month !== 0) { this.month = now.getMonth(); } if (!this.day) { this.day = 1; } if (!this.hour) { this.hour = 0; } if (!this.minute) { this.minute = 0; } if (!this.second) { this.second = 0; } if (!this.millisecond) { this.millisecond = 0; } }; var finishUtils = { getToday: function () { if (this.now || "hour minute second".indexOf(this.unit) !== -1) { return new Date(); } else { return $D.today(); } }, setDaysFromWeekday: function (today, orient){ var gap; orient = orient || 1; this.unit = "day"; gap = ($D.getDayNumberFromName(this.weekday) - today.getDay()); this.days = gap ? ((gap + (orient * 7)) % 7) : (orient * 7); return this; }, setMonthsFromMonth: function (today, orient) { var gap; orient = orient || 1; this.unit = "month"; gap = (this.month - today.getMonth()); this.months = gap ? ((gap + (orient * 12)) % 12) : (orient * 12); this.month = null; return this; }, setDMYFromWeekday: function () { var d = Date[this.weekday](); this.day = d.getDate(); if (!this.month) { this.month = d.getMonth(); } this.year = d.getFullYear(); return this; }, setUnitValue: function (orient) { if (!this.value && this.operator && this.operator !== null && this[this.unit + "s"] && this[this.unit + "s"] !== null) { this[this.unit + "s"] = this[this.unit + "s"] + ((this.operator === "add") ? 1 : -1) + (this.value||0) * orient; } else if (this[this.unit + "s"] == null || this.operator != null) { if (!this.value) { this.value = 1; } this[this.unit + "s"] = this.value * orient; } }, generateDateFromWeeks: function () { var weekday = (this.weekday !== undefined) ? this.weekday : "today"; var d = Date[weekday]().addWeeks(this.weeks); if (this.now) { d.setTimeToNow(); } return d; } }; $D.Translator = { hour: function (s) { return function () { this.hour = Number(s); }; }, minute: function (s) { return function () { this.minute = Number(s); }; }, second: function (s) { return function () { this.second = Number(s); }; }, /* for ss.s format */ secondAndMillisecond: function (s) { return function () { var mx = s.match(/^([0-5][0-9])\.([0-9]{1,3})/); this.second = Number(mx[1]); this.millisecond = Number(mx[2]); }; }, meridian: function (s) { return function () { this.meridian = s.slice(0, 1).toLowerCase(); }; }, timezone: function (s) { return function () { var n = s.replace(/[^\d\+\-]/g, ""); if (n.length) { this.timezoneOffset = Number(n); } else { this.timezone = s.toLowerCase(); } }; }, day: function (x) { var s = x[0]; return function () { this.day = Number(s.match(/\d+/)[0]); if (this.day < 1) { throw "invalid day"; } }; }, month: function (s) { return function () { this.month = (s.length === 3) ? "jan feb mar apr may jun jul aug sep oct nov dec".indexOf(s)/4 : Number(s) - 1; if (this.month < 0) { throw "invalid month"; } }; }, year: function (s) { return function () { var n = Number(s); this.year = ((s.length > 2) ? n : (n + (((n + 2000) < Date.CultureInfo.twoDigitYearMax) ? 2000 : 1900))); }; }, rday: function (s) { return function () { switch (s) { case "yesterday": this.days = -1; break; case "tomorrow": this.days = 1; break; case "today": this.days = 0; break; case "now": this.days = 0; this.now = true; break; } }; }, finishExact: function (x) { var d; x = (x instanceof Array) ? x : [x]; for (var i = 0 ; i < x.length ; i++) { if (x[i]) { x[i].call(this); } } setDefaults.call(this); parseMeridian.call(this); if (this.day > $D.getDaysInMonth(this.year, this.month)) { throw new RangeError(this.day + " is not a valid value for days."); } d = new Date(this.year, this.month, this.day, this.hour, this.minute, this.second, this.millisecond); if (this.year < 100) { d.setFullYear(this.year); // means years less that 100 are process correctly. JS will parse it otherwise as 1900-1999. } if (this.timezone) { d.set({ timezone: this.timezone }); } else if (this.timezoneOffset) { d.set({ timezoneOffset: this.timezoneOffset }); } return d; }, finish: function (x) { var today, expression, orient, temp; x = (x instanceof Array) ? flattenAndCompact(x) : [ x ]; if (x.length === 0) { return null; } for (var i = 0 ; i < x.length ; i++) { if (typeof x[i] === "function") { x[i].call(this); } } if (this.now && !this.unit && !this.operator) { return new Date(); } else { today = finishUtils.getToday.call(this); } expression = !!(this.days && this.days !== null || this.orient || this.operator); orient = ((this.orient === "past" || this.operator === "subtract") ? -1 : 1); if (this.month && this.unit === "week") { this.value = this.month + 1; delete this.month; delete this.day; } if ((this.month || this.month === 0) && "year day hour minute second".indexOf(this.unit) !== -1) { if (!this.value) { this.value = this.month + 1; } this.month = null; expression = true; } if (!expression && this.weekday && !this.day && !this.days) { finishUtils.setDMYFromWeekday.call(this); } if (expression && this.weekday && this.unit !== "month" && this.unit !== "week") { finishUtils.setDaysFromWeekday.call(this, today, orient); } if (this.weekday && this.unit !== "week" && !this.day && !this.days) { temp = Date[this.weekday](); this.day = temp.getDate(); if (temp.getMonth() !== today.getMonth()) { this.month = temp.getMonth(); } } if (this.month && this.unit === "day" && this.operator) { if (!this.value) { this.value = (this.month + 1); } this.month = null; } if (this.value != null && this.month != null && this.year != null) { this.day = this.value * 1; } if (this.month && !this.day && this.value) { today.set({ day: this.value * 1 }); if (!expression) { this.day = this.value * 1; } } if (!this.month && this.value && this.unit === "month" && !this.now) { this.month = this.value; expression = true; } if (expression && (this.month || this.month === 0) && this.unit !== "year") { finishUtils.setMonthsFromMonth.call(this, today, orient); } if (!this.unit) { this.unit = "day"; } finishUtils.setUnitValue.call(this, orient); parseMeridian.call(this); if ((this.month || this.month === 0) && !this.day) { this.day = 1; } if (!this.orient && !this.operator && this.unit === "week" && this.value && !this.day && !this.month) { return Date.today().setWeek(this.value); } if (this.unit === "week" && this.weeks && !this.day && !this.month) { return finishUtils.generateDateFromWeeks.call(this); } if (expression && this.timezone && this.day && this.days) { this.day = this.days; } if (expression){ today.add(this); } else { today.set(this); } if (this.timezone) { this.timezone = this.timezone.toUpperCase(); var offset = $D.getTimezoneOffset(this.timezone); var timezone; if (today.hasDaylightSavingTime()) { // lets check that we're being sane with timezone setting timezone = $D.getTimezoneAbbreviation(offset, today.isDaylightSavingTime()); if (timezone !== this.timezone) { // bugger, we're in a place where things like EST vs EDT matters. if (today.isDaylightSavingTime()) { today.addHours(-1); } else { today.addHours(1); } } } today.setTimezoneOffset(offset); } return today; } }; }()); (function () { var $D = Date; $D.Grammar = {}; var _ = $D.Parsing.Operators, g = $D.Grammar, t = $D.Translator, _fn; // Allow rolling up into general purpose rules _fn = function () { return _.each(_.any.apply(null, arguments), _.not(g.ctoken2("timeContext"))); }; g.datePartDelimiter = _.rtoken(/^([\s\-\.\,\/\x27]+)/); g.timePartDelimiter = _.stoken(":"); g.whiteSpace = _.rtoken(/^\s*/); g.generalDelimiter = _.rtoken(/^(([\s\,]|at|@|on)+)/); var _C = {}; g.ctoken = function (keys) { var fn = _C[keys]; if (! fn) { var c = Date.CultureInfo.regexPatterns; var kx = keys.split(/\s+/), px = []; for (var i = 0; i < kx.length ; i++) { px.push(_.replace(_.rtoken(c[kx[i]]), kx[i])); } fn = _C[keys] = _.any.apply(null, px); } return fn; }; g.ctoken2 = function (key) { return _.rtoken(Date.CultureInfo.regexPatterns[key]); }; var cacheProcessRtoken = function (key, token, type, eachToken) { if (eachToken) { g[key] = _.cache(_.process(_.each(_.rtoken(token),_.optional(g.ctoken2(eachToken))), type)); } else { g[key] = _.cache(_.process(_.rtoken(token), type)); } }; var cacheProcessCtoken = function (token, type) { return _.cache(_.process(g.ctoken2(token), type)); }; var _F = {}; //function cache var _get = function (f) { _F[f] = (_F[f] || g.format(f)[0]); return _F[f]; }; g.allformats = function (fx) { var rx = []; if (fx instanceof Array) { for (var i = 0; i < fx.length; i++) { rx.push(_get(fx[i])); } } else { rx.push(_get(fx)); } return rx; }; g.formats = function (fx) { if (fx instanceof Array) { var rx = []; for (var i = 0 ; i < fx.length ; i++) { rx.push(_get(fx[i])); } return _.any.apply(null, rx); } else { return _get(fx); } }; var grammarFormats = { timeFormats: function(){ var i, RTokenKeys = [ "h", "hh", "H", "HH", "m", "mm", "s", "ss", "ss.s", "z", "zz" ], RToken = [ /^(0[0-9]|1[0-2]|[1-9])/, /^(0[0-9]|1[0-2])/, /^([0-1][0-9]|2[0-3]|[0-9])/, /^([0-1][0-9]|2[0-3])/, /^([0-5][0-9]|[0-9])/, /^[0-5][0-9]/, /^([0-5][0-9]|[0-9])/, /^[0-5][0-9]/, /^[0-5][0-9]\.[0-9]{1,3}/, /^((\+|\-)\s*\d\d\d\d)|((\+|\-)\d\d\:?\d\d)/, /^((\+|\-)\s*\d\d\d\d)|((\+|\-)\d\d\:?\d\d)/ ], tokens = [ t.hour, t.hour, t.hour, t.hour, t.minute, t.minute, t.second, t.second, t.secondAndMillisecond, t.timezone, t.timezone ]; for (i=0; i < RTokenKeys.length; i++) { cacheProcessRtoken(RTokenKeys[i], RToken[i], tokens[i]); } g.hms = _.cache(_.sequence([g.H, g.m, g.s], g.timePartDelimiter)); g.t = cacheProcessCtoken("shortMeridian", t.meridian); g.tt = cacheProcessCtoken("longMeridian", t.meridian); g.zzz = cacheProcessCtoken("timezone", t.timezone); g.timeSuffix = _.each(_.ignore(g.whiteSpace), _.set([ g.tt, g.zzz ])); g.time = _.each(_.optional(_.ignore(_.stoken("T"))), g.hms, g.timeSuffix); }, dateFormats: function () { // pre-loaded rules for different date part order preferences var _setfn = function () { return _.set(arguments, g.datePartDelimiter); }; var i, RTokenKeys = [ "d", "dd", "M", "MM", "y", "yy", "yyy", "yyyy" ], RToken = [ /^([0-2]\d|3[0-1]|\d)/, /^([0-2]\d|3[0-1])/, /^(1[0-2]|0\d|\d)/, /^(1[0-2]|0\d)/, /^(\d+)/, /^(\d\d)/, /^(\d\d?\d?\d?)/, /^(\d\d\d\d)/ ], tokens = [ t.day, t.day, t.month, t.month, t.year, t.year, t.year, t.year ], eachToken = [ "ordinalSuffix", "ordinalSuffix" ]; for (i=0; i < RTokenKeys.length; i++) { cacheProcessRtoken(RTokenKeys[i], RToken[i], tokens[i], eachToken[i]); } g.MMM = g.MMMM = _.cache(_.process(g.ctoken("jan feb mar apr may jun jul aug sep oct nov dec"), t.month)); g.ddd = g.dddd = _.cache(_.process(g.ctoken("sun mon tue wed thu fri sat"), function (s) { return function () { this.weekday = s; }; } )); g.day = _fn(g.d, g.dd); g.month = _fn(g.M, g.MMM); g.year = _fn(g.yyyy, g.yy); g.mdy = _setfn(g.ddd, g.month, g.day, g.year); g.ymd = _setfn(g.ddd, g.year, g.month, g.day); g.dmy = _setfn(g.ddd, g.day, g.month, g.year); g.date = function (s) { return ((g[Date.CultureInfo.dateElementOrder] || g.mdy).call(this, s)); }; }, relative: function () { // relative date / time expressions g.orientation = _.process(g.ctoken("past future"), function (s) { return function () { this.orient = s; }; } ); g.operator = _.process(g.ctoken("add subtract"), function (s) { return function () { this.operator = s; }; } ); g.rday = _.process(g.ctoken("yesterday tomorrow today now"), t.rday); g.unit = _.process(g.ctoken("second minute hour day week month year"), function (s) { return function () { this.unit = s; }; } ); } }; g.buildGrammarFormats = function () { // these need to be rebuilt every time the language changes. _C = {}; grammarFormats.timeFormats(); grammarFormats.dateFormats(); grammarFormats.relative(); g.value = _.process(_.rtoken(/^([-+]?\d+)?(st|nd|rd|th)?/), function (s) { return function () { this.value = s.replace(/\D/g, ""); }; } ); g.expression = _.set([g.rday, g.operator, g.value, g.unit, g.orientation, g.ddd, g.MMM ]); g.format = _.process(_.many( _.any( // translate format specifiers into grammar rules _.process( _.rtoken(/^(dd?d?d?(?!e)|MM?M?M?|yy?y?y?|hh?|HH?|mm?|ss?|tt?|zz?z?)/), function (fmt) { if (g[fmt]) { return g[fmt]; } else { throw $D.Parsing.Exception(fmt); } } ), // translate separator tokens into token rules _.process(_.rtoken(/^[^dMyhHmstz]+/), // all legal separators function (s) { return _.ignore(_.stoken(s)); } ) ) ), // construct the parser ... function (rules) { return _.process(_.each.apply(null, rules), t.finishExact); } ); // starting rule for general purpose grammar g._start = _.process(_.set([ g.date, g.time, g.expression ], g.generalDelimiter, g.whiteSpace), t.finish); }; g.buildGrammarFormats(); // parsing date format specifiers - ex: "h:m:s tt" // this little guy will generate a custom parser based // on the format string, ex: g.format("h:m:s tt") // check for these formats first g._formats = g.formats([ "\"yyyy-MM-ddTHH:mm:ssZ\"", "yyyy-MM-ddTHH:mm:ss.sz", "yyyy-MM-ddTHH:mm:ssZ", "yyyy-MM-ddTHH:mm:ssz", "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-ddTHH:mmZ", "yyyy-MM-ddTHH:mmz", "yyyy-MM-ddTHH:mm", "ddd, MMM dd, yyyy H:mm:ss tt", "ddd MMM d yyyy HH:mm:ss zzz", "MMddyyyy", "ddMMyyyy", "Mddyyyy", "ddMyyyy", "Mdyyyy", "dMyyyy", "yyyy", "Mdyy", "dMyy", "d" ]); // real starting rule: tries selected formats first, // then general purpose rule g.start = function (s) { try { var r = g._formats.call({}, s); if (r[1].length === 0) { return r; } } catch (e) {} return g._start.call({}, s); }; }()); (function () { var $D = Date; /** * @desc Converts the specified string value into its JavaScript Date equivalent using CultureInfo specific format information. * * Example

	///////////
	// Dates //
	///////////

	// 15-Oct-2004
	var d1 = Date.parse("10/15/2004");

	// 15-Oct-2004
	var d1 = Date.parse("15-Oct-2004");

	// 15-Oct-2004
	var d1 = Date.parse("2004.10.15");

	//Fri Oct 15, 2004
	var d1 = Date.parse("Fri Oct 15, 2004");

	///////////
	// Times //
	///////////

	// Today at 10 PM.
	var d1 = Date.parse("10 PM");

	// Today at 10:30 PM.
	var d1 = Date.parse("10:30 P.M.");

	// Today at 6 AM.
	var d1 = Date.parse("06am");

	/////////////////////
	// Dates and Times //
	/////////////////////

	// 8-July-2004 @ 10:30 PM
	var d1 = Date.parse("July 8th, 2004, 10:30 PM");

	// 1-July-2004 @ 10:30 PM
	var d1 = Date.parse("2004-07-01T22:30:00");

	////////////////////
	// Relative Dates //
	////////////////////

	// Returns today's date. The string "today" is culture specific.
	var d1 = Date.parse("today");

	// Returns yesterday's date. The string "yesterday" is culture specific.
	var d1 = Date.parse("yesterday");

	// Returns the date of the next thursday.
	var d1 = Date.parse("Next thursday");

	// Returns the date of the most previous monday.
	var d1 = Date.parse("last monday");

	// Returns today's day + one year.
	var d1 = Date.parse("next year");

	///////////////
	// Date Math //
	///////////////

	// Today + 2 days
	var d1 = Date.parse("t+2");

	// Today + 2 days
	var d1 = Date.parse("today + 2 days");

	// Today + 3 months
	var d1 = Date.parse("t+3m");

	// Today - 1 year
	var d1 = Date.parse("today - 1 year");

	// Today - 1 year
	var d1 = Date.parse("t-1y"); 


	/////////////////////////////
	// Partial Dates and Times //
	/////////////////////////////

	// July 15th of this year.
	var d1 = Date.parse("July 15");

	// 15th day of current day and year.
	var d1 = Date.parse("15");

	// July 1st of current year at 10pm.
	var d1 = Date.parse("7/1 10pm");
	
* * @param {String} The string value to convert into a Date object [Required] * @return {Date} A Date object or null if the string cannot be converted into a Date. */ var parseUtils = { removeOrds: function (s) { ords = s.match(/\b(\d+)(?:st|nd|rd|th)\b/); // find ordinal matches s = ((ords && ords.length === 2) ? s.replace(ords[0], ords[1]) : s); return s; }, grammarParser: function (s) { var r = null; try { r = $D.Grammar.start.call({}, s.replace(/^\s*(\S*(\s+\S+)*)\s*$/, "$1")); } catch (e) { return null; } return ((r[1].length === 0) ? r[0] : null); }, nativeFallback: function(s) { var t; try { // ok we haven't parsed it, last ditch attempt with the built-in parser. t = Date._parse(s); return (t || t === 0) ? new Date(t) : null; } catch (e) { return null; } } }; function parse (s) { var d; if (!s) { return null; } if (s instanceof Date) { return s.clone(); } if (s.length >= 4 && s.charAt(0) !== "0" && s.charAt(0) !== "+"&& s.charAt(0) !== "-") { // ie: 2004 will pass, 0800 won't. // Start with specific formats d = $D.Parsing.ISO.parse(s) || $D.Parsing.Numeric.parse(s); } if (d instanceof Date && !isNaN(d.getTime())) { return d; } else { // find ordinal dates (1st, 3rd, 8th, etc and remove them as they cause parsing issues) s = $D.Parsing.Normalizer.parse(parseUtils.removeOrds(s)); d = parseUtils.grammarParser(s); if (d !== null) { return d; } else { return parseUtils.nativeFallback(s); } } } if (!$D._parse) { $D._parse = $D.parse; } $D.parse = parse; Date.getParseFunction = function (fx) { var fns = Date.Grammar.allformats(fx); return function (s) { var r = null; for (var i = 0; i < fns.length; i++) { try { r = fns[i].call({}, s); } catch (e) { continue; } if (r[1].length === 0) { return r[0]; } } return null; }; }; /** * Converts the specified string value into its JavaScript Date equivalent using the specified format {String} or formats {Array} and the CultureInfo specific format information. * The format of the string value must match one of the supplied formats exactly. * * Example

	// 15-Oct-2004
	var d1 = Date.parseExact("10/15/2004", "M/d/yyyy");

	// 15-Oct-2004
	var d1 = Date.parse("15-Oct-2004", "M-ddd-yyyy");

	// 15-Oct-2004
	var d1 = Date.parse("2004.10.15", "yyyy.MM.dd");

	// Multiple formats
	var d1 = Date.parseExact("10/15/2004", ["M/d/yyyy", "MMMM d, yyyy"]);
	
* * @param {String} The string value to convert into a Date object [Required]. * @param {Object} The expected format {String} or an array of expected formats {Array} of the date string [Required]. * @return {Date} A Date object or null if the string cannot be converted into a Date. */ $D.parseExact = function (s, fx) { return $D.getParseFunction(fx)(s); }; }()); (function () { var $D = Date, $P = $D.prototype, // $C = $D.CultureInfo, // not used atm p = function (s, l) { if (!l) { l = 2; } return ("000" + s).slice(l * -1); }; /** * Converts a PHP format string to Java/.NET format string. * A PHP format string can be used with ._format or .format. * A Java/.NET format string can be used with .toString(). * The .parseExact function will only accept a Java/.NET format string * * Example * var f1 = "%m/%d/%y" * var f2 = Date.normalizeFormat(f1); // "MM/dd/yy" * * new Date().format(f1); // "04/13/08" * new Date()._format(f1); // "04/13/08" * new Date().toString(f2); // "04/13/08" * * var date = Date.parseExact("04/13/08", f2); // Sun Apr 13 2008 * * @param {String} A PHP format string consisting of one or more format spcifiers. * @return {String} The PHP format converted to a Java/.NET format string. */ var normalizerSubstitutions = { "d" : "dd", "%d": "dd", "D" : "ddd", "%a": "ddd", "j" : "dddd", "l" : "dddd", "%A": "dddd", "S" : "S", "F" : "MMMM", "%B": "MMMM", "m" : "MM", "%m": "MM", "M" : "MMM", "%b": "MMM", "%h": "MMM", "n" : "M", "Y" : "yyyy", "%Y": "yyyy", "y" : "yy", "%y": "yy", "g" : "h", "%I": "h", "G" : "H", "h" : "hh", "H" : "HH", "%H": "HH", "i" : "mm", "%M": "mm", "s" : "ss", "%S": "ss", "%r": "hh:mm tt", "%R": "H:mm", "%T": "H:mm:ss", "%X": "t", "%x": "d", "%e": "d", "%D": "MM/dd/yy", "%n": "\\n", "%t": "\\t", "e" : "z", "T" : "z", "%z": "z", "%Z": "z", "Z" : "ZZ", "N" : "u", "w" : "u", "%w": "u", "W" : "W", "%V": "W" }; var normalizer = { substitutes: function (m) { return normalizerSubstitutions[m]; }, interpreted: function (m, x) { var y; switch (m) { case "%u": return x.getDay() + 1; case "z": return x.getOrdinalNumber(); case "%j": return p(x.getOrdinalNumber(), 3); case "%U": var d1 = x.clone().set({month: 0, day: 1}).addDays(-1).moveToDayOfWeek(0), d2 = x.clone().addDays(1).moveToDayOfWeek(0, -1); return (d2 < d1) ? "00" : p((d2.getOrdinalNumber() - d1.getOrdinalNumber()) / 7 + 1); case "%W": return p(x.getWeek()); case "t": return $D.getDaysInMonth(x.getFullYear(), x.getMonth()); case "o": case "%G": return x.setWeek(x.getISOWeek()).toString("yyyy"); case "%g": return x._format("%G").slice(-2); case "a": case "%p": return t("tt").toLowerCase(); case "A": return t("tt").toUpperCase(); case "u": return p(x.getMilliseconds(), 3); case "I": return (x.isDaylightSavingTime()) ? 1 : 0; case "O": return x.getUTCOffset(); case "P": y = x.getUTCOffset(); return y.substring(0, y.length - 2) + ":" + y.substring(y.length - 2); case "B": var now = new Date(); return Math.floor(((now.getHours() * 3600) + (now.getMinutes() * 60) + now.getSeconds() + (now.getTimezoneOffset() + 60) * 60) / 86.4); case "c": return x.toISOString().replace(/\"/g, ""); case "U": return $D.strtotime("now"); case "%c": return t("d") + " " + t("t"); case "%C": return Math.floor(x.getFullYear() / 100 + 1); } }, shouldOverrideDefaults: function (m) { switch (m) { case "%e": return true; default: return false; } }, parse: function (m, context) { var formatString, c = context || new Date(); formatString = normalizer.substitutes(m); if (formatString) { return formatString; } formatString = normalizer.interpreted(m, c); if (formatString) { return formatString; } else { return m; } } }; $D.normalizeFormat = function (format, context) { return format.replace(/(%|\\)?.|%%/g, function(t){ return normalizer.parse(t, context); }); }; /** * Format a local Unix timestamp according to locale settings * * Example: * Date.strftime("%m/%d/%y", new Date()); // "04/13/08" * Date.strftime("c", "2008-04-13T17:52:03Z"); // "04/13/08" * * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @param {Number|String} The number representing the number of seconds that have elapsed since January 1, 1970 (local time). * @return {String} A string representation of the current Date object. */ $D.strftime = function (format, time) { var d = Date.parse(time); return d._format(format); }; /** * Parse any textual datetime description into a Unix timestamp. * A Unix timestamp is the number of seconds that have elapsed since January 1, 1970 (midnight UTC/GMT). * * Example: * Date.strtotime("04/13/08"); // 1208044800 * Date.strtotime("1970-01-01T00:00:00Z"); // 0 * * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @param {Object} A string or date object. * @return {String} A string representation of the current Date object. */ $D.strtotime = function (time) { var d = $D.parse(time); return Math.round($D.UTC(d.getUTCFullYear(), d.getUTCMonth(), d.getUTCDate(), d.getUTCHours(), d.getUTCMinutes(), d.getUTCSeconds(), d.getUTCMilliseconds()) / 1000); }; /** * Converts the value of the current Date object to its equivalent string representation using a PHP/Unix style of date format specifiers. * Format Specifiers * Format Description Example * ------ --------------------------------------------------------------------------- ----------------------- * %a abbreviated weekday name according to the current localed "Mon" through "Sun" * %A full weekday name according to the current localed "Sunday" through "Saturday" * %b abbreviated month name according to the current localed "Jan" through "Dec" * %B full month name according to the current locale "January" through "December" * %c preferred date and time representation for the current locale "4/13/2008 12:33 PM" * %C century number (the year divided by 100 and truncated to an integer) "00" to "99" * %d day of the month as a decimal number "01" to "31" * %D same as %m/%d/%y "04/13/08" * %e day of the month as a decimal number, a single digit is preceded by a space "1" to "31" * %g like %G, but without the century "08" * %G The 4-digit year corresponding to the ISO week number (see %V). "2008" * This has the same format and value as %Y, except that if the ISO week number * belongs to the previous or next year, that year is used instead. * %h same as %b "Jan" through "Dec" * %H hour as a decimal number using a 24-hour clock. "00" to "23" * %I hour as a decimal number using a 12-hour clock. "01" to "12" * %j day of the year as a decimal number. "001" to "366" * %m month as a decimal number. "01" to "12" * %M minute as a decimal number. "00" to "59" * %n newline character "\n" * %p either "am" or "pm" according to the given time value, or the "am" or "pm" * corresponding strings for the current locale. * %r time in a.m. and p.m. notation "8:44 PM" * %R time in 24 hour notation "20:44" * %S second as a decimal number "00" to "59" * %t tab character "\t" * %T current time, equal to %H:%M:%S "12:49:11" * %u weekday as a decimal number ["1", "7"], with "1" representing Monday "1" to "7" * %U week number of the current year as a decimal number, starting with the "0" to ("52" or "53") * first Sunday as the first day of the first week * %V The ISO 8601:1988 week number of the current year as a decimal number, "00" to ("52" or "53") * range 01 to 53, where week 1 is the first week that has at least 4 days * in the current year, and with Monday as the first day of the week. * (Use %G or %g for the year component that corresponds to the week number * for the specified timestamp.) * %W week number of the current year as a decimal number, starting with the "00" to ("52" or "53") * first Monday as the first day of the first week * %w day of the week as a decimal, Sunday being "0" "0" to "6" * %x preferred date representation for the current locale without the time "4/13/2008" * %X preferred time representation for the current locale without the date "12:53:05" * %y year as a decimal number without a century "00" "99" * %Y year as a decimal number including the century "2008" * %Z time zone or name or abbreviation "UTC", "EST", "PST" * %z same as %Z * %% a literal "%" characters "%" * d Day of the month, 2 digits with leading zeros "01" to "31" * D A textual representation of a day, three letters "Mon" through "Sun" * j Day of the month without leading zeros "1" to "31" * l A full textual representation of the day of the week (lowercase "L") "Sunday" through "Saturday" * N ISO-8601 numeric representation of the day of the week (added in PHP 5.1.0) "1" (for Monday) through "7" (for Sunday) * S English ordinal suffix for the day of the month, 2 characters "st", "nd", "rd" or "th". Works well with j * w Numeric representation of the day of the week "0" (for Sunday) through "6" (for Saturday) * z The day of the year (starting from "0") "0" through "365" * W ISO-8601 week number of year, weeks starting on Monday "00" to ("52" or "53") * F A full textual representation of a month, such as January or March "January" through "December" * m Numeric representation of a month, with leading zeros "01" through "12" * M A short textual representation of a month, three letters "Jan" through "Dec" * n Numeric representation of a month, without leading zeros "1" through "12" * t Number of days in the given month "28" through "31" * L Whether it's a leap year "1" if it is a leap year, "0" otherwise * o ISO-8601 year number. This has the same value as Y, except that if the "2008" * ISO week number (W) belongs to the previous or next year, that year * is used instead. * Y A full numeric representation of a year, 4 digits "2008" * y A two digit representation of a year "08" * a Lowercase Ante meridiem and Post meridiem "am" or "pm" * A Uppercase Ante meridiem and Post meridiem "AM" or "PM" * B Swatch Internet time "000" through "999" * g 12-hour format of an hour without leading zeros "1" through "12" * G 24-hour format of an hour without leading zeros "0" through "23" * h 12-hour format of an hour with leading zeros "01" through "12" * H 24-hour format of an hour with leading zeros "00" through "23" * i Minutes with leading zeros "00" to "59" * s Seconds, with leading zeros "00" through "59" * u Milliseconds "54321" * e Timezone identifier "UTC", "EST", "PST" * I Whether or not the date is in daylight saving time (uppercase i) "1" if Daylight Saving Time, "0" otherwise * O Difference to Greenwich time (GMT) in hours "+0200", "-0600" * P Difference to Greenwich time (GMT) with colon between hours and minutes "+02:00", "-06:00" * T Timezone abbreviation "UTC", "EST", "PST" * Z Timezone offset in seconds. The offset for timezones west of UTC is "-43200" through "50400" * always negative, and for those east of UTC is always positive. * c ISO 8601 date "2004-02-12T15:19:21+00:00" * r RFC 2822 formatted date "Thu, 21 Dec 2000 16:01:07 +0200" * U Seconds since the Unix Epoch (January 1 1970 00:00:00 GMT) "0" * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @return {String} A string representation of the current Date object. */ var formatReplace = function (context) { return function (m) { var formatString, override = false; if (m.charAt(0) === "\\" || m.substring(0, 2) === "%%") { return m.replace("\\", "").replace("%%", "%"); } override = normalizer.shouldOverrideDefaults(m); formatString = $D.normalizeFormat(m, context); if (formatString) { return context.toString(formatString, override); } }; }; $P._format = function (format) { var formatter = formatReplace(this); if (!format) { return this._toString(); } else { return format.replace(/(%|\\)?.|%%/g, formatter); } }; if (!$P.format) { $P.format = $P._format; } }()); (function () { "use strict"; var gFn = function (attr) { return function () { return this[attr]; }; }; var sFn = function (attr) { return function (val) { this[attr] = val; return this; }; }; var attrs = ["years", "months", "days", "hours", "minutes", "seconds", "milliseconds"]; var addSetFuncs = function (context, attrs) { for (var i = 0; i < attrs.length ; i++) { var $a = attrs[i], $b = $a.slice(0, 1).toUpperCase() + $a.slice(1); context.prototype[$a] = 0; context.prototype["get" + $b] = gFn($a); context.prototype["set" + $b] = sFn($a); } }; /** * new TimeSpan(milliseconds); * new TimeSpan(days, hours, minutes, seconds); * new TimeSpan(days, hours, minutes, seconds, milliseconds); */ var TimeSpan = function (days, hours, minutes, seconds, milliseconds) { if (arguments.length === 1 && typeof days === "number") { var orient = (days < 0) ? -1 : +1; var millsLeft = Math.abs(days); this.setDays(Math.floor(millsLeft / 86400000) * orient); millsLeft = millsLeft % 86400000; this.setHours(Math.floor(millsLeft / 3600000) * orient); millsLeft = millsLeft % 3600000; this.setMinutes(Math.floor(millsLeft / 60000) * orient); millsLeft = millsLeft % 60000; this.setSeconds(Math.floor(millsLeft / 1000) * orient); millsLeft = millsLeft % 1000; this.setMilliseconds(millsLeft * orient); } else { this.set(days, hours, minutes, seconds, milliseconds); } this.getTotalMilliseconds = function () { return (this.getDays() * 86400000) + (this.getHours() * 3600000) + (this.getMinutes() * 60000) + (this.getSeconds() * 1000); }; this.compareTo = function (time) { var t1 = new Date(1970, 1, 1, this.getHours(), this.getMinutes(), this.getSeconds()), t2; if (time === null) { t2 = new Date(1970, 1, 1, 0, 0, 0); } else { t2 = new Date(1970, 1, 1, time.getHours(), time.getMinutes(), time.getSeconds()); } return (t1 < t2) ? -1 : (t1 > t2) ? 1 : 0; }; this.equals = function (time) { return (this.compareTo(time) === 0); }; this.add = function (time) { return (time === null) ? this : this.addSeconds(time.getTotalMilliseconds() / 1000); }; this.subtract = function (time) { return (time === null) ? this : this.addSeconds(-time.getTotalMilliseconds() / 1000); }; this.addDays = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 86400000)); }; this.addHours = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 3600000)); }; this.addMinutes = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 60000)); }; this.addSeconds = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 1000)); }; this.addMilliseconds = function (n) { return new TimeSpan(this.getTotalMilliseconds() + n); }; this.get12HourHour = function () { return (this.getHours() > 12) ? this.getHours() - 12 : (this.getHours() === 0) ? 12 : this.getHours(); }; this.getDesignator = function () { return (this.getHours() < 12) ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator; }; this.toString = function (format) { this._toString = function () { if (this.getDays() !== null && this.getDays() > 0) { return this.getDays() + "." + this.getHours() + ":" + this.p(this.getMinutes()) + ":" + this.p(this.getSeconds()); } else { return this.getHours() + ":" + this.p(this.getMinutes()) + ":" + this.p(this.getSeconds()); } }; this.p = function (s) { return (s.toString().length < 2) ? "0" + s : s; }; var me = this; return format ? format.replace(/dd?|HH?|hh?|mm?|ss?|tt?/g, function (format) { switch (format) { case "d": return me.getDays(); case "dd": return me.p(me.getDays()); case "H": return me.getHours(); case "HH": return me.p(me.getHours()); case "h": return me.get12HourHour(); case "hh": return me.p(me.get12HourHour()); case "m": return me.getMinutes(); case "mm": return me.p(me.getMinutes()); case "s": return me.getSeconds(); case "ss": return me.p(me.getSeconds()); case "t": return ((me.getHours() < 12) ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator).substring(0, 1); case "tt": return (me.getHours() < 12) ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator; } } ) : this._toString(); }; return this; }; addSetFuncs(TimeSpan, attrs.slice(2)); TimeSpan.prototype.set = function (days, hours, minutes, seconds, milliseconds){ this.setDays(days || this.getDays()); this.setHours(hours || this.getHours()); this.setMinutes(minutes || this.getMinutes()); this.setSeconds(seconds || this.getSeconds()); this.setMilliseconds(milliseconds || this.getMilliseconds()); }; /** * Gets the time of day for this date instances. * @return {TimeSpan} TimeSpan */ Date.prototype.getTimeOfDay = function () { return new TimeSpan(0, this.getHours(), this.getMinutes(), this.getSeconds(), this.getMilliseconds()); }; Date.TimeSpan = TimeSpan; if (typeof window !== "undefined" ) { // keeping API compatible for v1.x window.TimeSpan = TimeSpan; } }()); (function () { "use strict"; var attrs = ["years", "months", "days", "hours", "minutes", "seconds", "milliseconds"]; var gFn = function (attr) { return function () { return this[attr]; }; }; var sFn = function (attr) { return function (val) { this[attr] = val; return this; }; }; var addSetFuncs = function (context, attrs) { for (var i = 0; i < attrs.length ; i++) { var $a = attrs[i], $b = $a.slice(0, 1).toUpperCase() + $a.slice(1); context.prototype[$a] = 0; context.prototype["get" + $b] = gFn($a); context.prototype["set" + $b] = sFn($a); } }; var setMonthsAndYears = function (orient, d1, d2, context) { function inc() { d1.addMonths(-orient); context.months++; if (context.months === 12) { context.years++; context.months = 0; } } if (orient === +1) { while (d1 > d2) { inc(); } } else { while (d1 < d2) { inc(); } } context.months--; context.months *= orient; context.years *= orient; }; var adjustForDST = function(orient, startDate, endDate) { var hasDSTMismatch = (false === (startDate.isDaylightSavingTime() === endDate.isDaylightSavingTime())); if (hasDSTMismatch && orient === 1) { startDate.addHours(-1); } else if (hasDSTMismatch) { startDate.addHours(1); } }; /** * TimePeriod(startDate, endDate); * TimePeriod(years, months, days, hours, minutes, seconds, milliseconds); */ var TimePeriod = function (years, months, days, hours, minutes, seconds, milliseconds) { if (arguments.length === 7) { this.set(years, months, days, hours, minutes, seconds, milliseconds); } else if (arguments.length === 2 && arguments[0] instanceof Date && arguments[1] instanceof Date) { var startDate = arguments[0].clone(); var endDate = arguments[1].clone(); var orient = (startDate > endDate) ? +1 : -1; this.dates = { start: arguments[0].clone(), end: arguments[1].clone() }; setMonthsAndYears(orient, startDate, endDate, this); adjustForDST(orient, startDate, endDate); // // TODO - adjust for DST var diff = endDate - startDate; if (diff !== 0) { var ts = new TimeSpan(diff); this.set(this.years, this.months, ts.getDays(), ts.getHours(), ts.getMinutes(), ts.getSeconds(), ts.getMilliseconds()); } } return this; }; // create all the set functions. addSetFuncs(TimePeriod, attrs); TimePeriod.prototype.set = function (years, months, days, hours, minutes, seconds, milliseconds){ this.setYears(years || this.getYears()); this.setMonths(months || this.getMonths()); this.setDays(days || this.getDays()); this.setHours(hours || this.getHours()); this.setMinutes(minutes || this.getMinutes()); this.setSeconds(seconds || this.getSeconds()); this.setMilliseconds(milliseconds || this.getMilliseconds()); }; Date.TimePeriod = TimePeriod; if (typeof window !== "undefined") { // keeping API compatible for v1.x window.TimePeriod = TimePeriod; } }()); ================================================ FILE: build/date-pt-BR.js ================================================ /** * @overview datejs * @version 1.0.0-rc3 * @author Gregory Wild-Smith * @copyright 2015 Gregory Wild-Smith * @license MIT * @homepage https://github.com/abritinthebay/datejs */ /* * DateJS Culture String File * Country Code: pt-BR * Name: Portuguese (Brazil) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["pt-BR"] = { "name": "pt-BR", "englishName": "Portuguese (Brazil)", "nativeName": "Português (Brasil)", "Sunday": "domingo", "Monday": "segunda-feira", "Tuesday": "terça-feira", "Wednesday": "quarta-feira", "Thursday": "quinta-feira", "Friday": "sexta-feira", "Saturday": "sábado", "Sun": "dom", "Mon": "seg", "Tue": "ter", "Wed": "qua", "Thu": "qui", "Fri": "sex", "Sat": "sáb", "Su": "dom", "Mo": "seg", "Tu": "ter", "We": "qua", "Th": "qui", "Fr": "sex", "Sa": "sáb", "S_Sun_Initial": "d", "M_Mon_Initial": "s", "T_Tue_Initial": "t", "W_Wed_Initial": "q", "T_Thu_Initial": "q", "F_Fri_Initial": "s", "S_Sat_Initial": "s", "January": "janeiro", "February": "fevereiro", "March": "março", "April": "abril", "May": "maio", "June": "junho", "July": "julho", "August": "agosto", "September": "setembro", "October": "outubro", "November": "novembro", "December": "dezembro", "Jan_Abbr": "jan", "Feb_Abbr": "fev", "Mar_Abbr": "mar", "Apr_Abbr": "abr", "May_Abbr": "mai", "Jun_Abbr": "jun", "Jul_Abbr": "jul", "Aug_Abbr": "ago", "Sep_Abbr": "set", "Oct_Abbr": "out", "Nov_Abbr": "nov", "Dec_Abbr": "dez", "AM": "", "PM": "", "firstDayOfWeek": 0, "twoDigitYearMax": 2029, "mdy": "dmy", "M/d/yyyy": "d/M/yyyy", "dddd, MMMM dd, yyyy": "dddd, d' de 'MMMM' de 'yyyy", "h:mm tt": "H:mm", "h:mm:ss tt": "H:mm:ss", "dddd, MMMM dd, yyyy h:mm:ss tt": "dddd, d' de 'MMMM' de 'yyyy H:mm:ss", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "dd' de 'MMMM", "MMMM, yyyy": "MMMM' de 'yyyy", "/jan(uary)?/": "jan(eiro)?", "/feb(ruary)?/": "fev(ereiro)?", "/mar(ch)?/": "mar(ço)?", "/apr(il)?/": "abr(il)?", "/may/": "mai(o)?", "/jun(e)?/": "jun(ho)?", "/jul(y)?/": "jul(ho)?", "/aug(ust)?/": "ago(sto)?", "/sep(t(ember)?)?/": "set(embro)?", "/oct(ober)?/": "out(ubro)?", "/nov(ember)?/": "nov(embro)?", "/dec(ember)?/": "dez(embro)?", "/^su(n(day)?)?/": "^domingo", "/^mo(n(day)?)?/": "^segunda-feira", "/^tu(e(s(day)?)?)?/": "^terça-feira", "/^we(d(nesday)?)?/": "^quarta-feira", "/^th(u(r(s(day)?)?)?)?/": "^quinta-feira", "/^fr(i(day)?)?/": "^sexta-feira", "/^sa(t(urday)?)?/": "^sábado", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "pt-BR"; /** * @overview datejs * @version 1.0.0-rc3 * @author Gregory Wild-Smith * @copyright 2015 Gregory Wild-Smith * @license MIT * @homepage https://github.com/abritinthebay/datejs */(function () { var $D = Date; var lang = Date.CultureStrings ? Date.CultureStrings.lang : null; var loggedKeys = {}; // for debug purposes. var getText = { getFromKey: function (key, countryCode) { var output; if (Date.CultureStrings && Date.CultureStrings[countryCode] && Date.CultureStrings[countryCode][key]) { output = Date.CultureStrings[countryCode][key]; } else { output = getText.buildFromDefault(key); } if (key.charAt(0) === "/") { // Assume it's a regex output = getText.buildFromRegex(key, countryCode); } return output; }, getFromObjectValues: function (obj, countryCode) { var key, output = {}; for(key in obj) { if (obj.hasOwnProperty(key)) { output[key] = getText.getFromKey(obj[key], countryCode); } } return output; }, getFromObjectKeys: function (obj, countryCode) { var key, output = {}; for(key in obj) { if (obj.hasOwnProperty(key)) { output[getText.getFromKey(key, countryCode)] = obj[key]; } } return output; }, getFromArray: function (arr, countryCode) { var output = []; for (var i=0; i < arr.length; i++){ if (i in arr) { output[i] = getText.getFromKey(arr[i], countryCode); } } return output; }, buildFromDefault: function (key) { var output, length, split, last; switch(key) { case "name": output = "en-US"; break; case "englishName": output = "English (United States)"; break; case "nativeName": output = "English (United States)"; break; case "twoDigitYearMax": output = 2049; break; case "firstDayOfWeek": output = 0; break; default: output = key; split = key.split("_"); length = split.length; if (length > 1 && key.charAt(0) !== "/") { // if the key isn't a regex and it has a split. last = split[(length - 1)].toLowerCase(); if (last === "initial" || last === "abbr") { output = split[0]; } } break; } return output; }, buildFromRegex: function (key, countryCode) { var output; if (Date.CultureStrings && Date.CultureStrings[countryCode] && Date.CultureStrings[countryCode][key]) { output = new RegExp(Date.CultureStrings[countryCode][key], "i"); } else { output = new RegExp(key.replace(new RegExp("/", "g"),""), "i"); } return output; } }; var shallowMerge = function (obj1, obj2) { for (var attrname in obj2) { if (obj2.hasOwnProperty(attrname)) { obj1[attrname] = obj2[attrname]; } } }; var __ = function (key, language) { var countryCode = (language) ? language : lang; loggedKeys[key] = key; if (typeof key === "object") { if (key instanceof Array) { return getText.getFromArray(key, countryCode); } else { return getText.getFromObjectKeys(key, countryCode); } } else { return getText.getFromKey(key, countryCode); } }; var loadI18nScript = function (code) { // paatterned after jQuery's getScript. var url = Date.Config.i18n + code + ".js"; var head = document.getElementsByTagName("head")[0] || document.documentElement; var script = document.createElement("script"); script.src = url; var completed = false; var events = { done: function (){} // placeholder function }; // Attach handlers for all browsers script.onload = script.onreadystatechange = function() { if ( !completed && (!this.readyState || this.readyState === "loaded" || this.readyState === "complete") ) { events.done(); head.removeChild(script); } }; setTimeout(function() { head.insertBefore(script, head.firstChild); }, 0); // allows return to execute first return { done: function (cb) { events.done = function() { if (cb) { setTimeout(cb,0); } }; } }; }; var buildInfo = { buildFromMethodHash: function (obj) { var key; for(key in obj) { if (obj.hasOwnProperty(key)) { obj[key] = buildInfo[obj[key]](); } } return obj; }, timeZoneDST: function () { var DST = { "CHADT": "+1345", "NZDT": "+1300", "AEDT": "+1100", "ACDT": "+1030", "AZST": "+0500", "IRDT": "+0430", "EEST": "+0300", "CEST": "+0200", "BST": "+0100", "PMDT": "-0200", "ADT": "-0300", "NDT": "-0230", "EDT": "-0400", "CDT": "-0500", "MDT": "-0600", "PDT": "-0700", "AKDT": "-0800", "HADT": "-0900" }; return __(DST); }, timeZoneStandard: function () { var standard = { "LINT": "+1400", "TOT": "+1300", "CHAST": "+1245", "NZST": "+1200", "NFT": "+1130", "SBT": "+1100", "AEST": "+1000", "ACST": "+0930", "JST": "+0900", "CWST": "+0845", "CT": "+0800", "ICT": "+0700", "MMT": "+0630", "BST": "+0600", "NPT": "+0545", "IST": "+0530", "PKT": "+0500", "AFT": "+0430", "MSK": "+0400", "IRST": "+0330", "FET": "+0300", "EET": "+0200", "CET": "+0100", "GMT": "+0000", "UTC": "+0000", "CVT": "-0100", "GST": "-0200", "BRT": "-0300", "NST": "-0330", "AST": "-0400", "EST": "-0500", "CST": "-0600", "MST": "-0700", "PST": "-0800", "AKST": "-0900", "MIT": "-0930", "HST": "-1000", "SST": "-1100", "BIT": "-1200" }; return __(standard); }, timeZones: function (data) { var zone; data.timezones = []; for (zone in data.abbreviatedTimeZoneStandard) { if (data.abbreviatedTimeZoneStandard.hasOwnProperty(zone)) { data.timezones.push({ name: zone, offset: data.abbreviatedTimeZoneStandard[zone]}); } } for (zone in data.abbreviatedTimeZoneDST) { if (data.abbreviatedTimeZoneDST.hasOwnProperty(zone)) { data.timezones.push({ name: zone, offset: data.abbreviatedTimeZoneDST[zone], dst: true}); } } return data.timezones; }, days: function () { return __(["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"]); }, dayAbbr: function () { return __(["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"]); }, dayShortNames: function () { return __(["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"]); }, dayFirstLetters: function () { return __(["S_Sun_Initial", "M_Mon_Initial", "T_Tues_Initial", "W_Wed_Initial", "T_Thu_Initial", "F_Fri_Initial", "S_Sat_Initial"]); }, months: function () { return __(["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"]); }, monthAbbr: function () { return __(["Jan_Abbr", "Feb_Abbr", "Mar_Abbr", "Apr_Abbr", "May_Abbr", "Jun_Abbr", "Jul_Abbr", "Aug_Abbr", "Sep_Abbr", "Oct_Abbr", "Nov_Abbr", "Dec_Abbr"]); }, formatPatterns: function () { return getText.getFromObjectValues({ shortDate: "M/d/yyyy", longDate: "dddd, MMMM dd, yyyy", shortTime: "h:mm tt", longTime: "h:mm:ss tt", fullDateTime: "dddd, MMMM dd, yyyy h:mm:ss tt", sortableDateTime: "yyyy-MM-ddTHH:mm:ss", universalSortableDateTime: "yyyy-MM-dd HH:mm:ssZ", rfc1123: "ddd, dd MMM yyyy HH:mm:ss", monthDay: "MMMM dd", yearMonth: "MMMM, yyyy" }, Date.i18n.currentLanguage()); }, regex: function () { return getText.getFromObjectValues({ inTheMorning: "/( in the )(morn(ing)?)\\b/", thisMorning: "/(this )(morn(ing)?)\\b/", amThisMorning: "/(\b\\d(am)? )(this )(morn(ing)?)/", inTheEvening: "/( in the )(even(ing)?)\\b/", thisEvening: "/(this )(even(ing)?)\\b/", pmThisEvening: "/(\b\\d(pm)? )(this )(even(ing)?)/", jan: "/jan(uary)?/", feb: "/feb(ruary)?/", mar: "/mar(ch)?/", apr: "/apr(il)?/", may: "/may/", jun: "/jun(e)?/", jul: "/jul(y)?/", aug: "/aug(ust)?/", sep: "/sep(t(ember)?)?/", oct: "/oct(ober)?/", nov: "/nov(ember)?/", dec: "/dec(ember)?/", sun: "/^su(n(day)?)?/", mon: "/^mo(n(day)?)?/", tue: "/^tu(e(s(day)?)?)?/", wed: "/^we(d(nesday)?)?/", thu: "/^th(u(r(s(day)?)?)?)?/", fri: "/fr(i(day)?)?/", sat: "/^sa(t(urday)?)?/", future: "/^next/", past: "/^last|past|prev(ious)?/", add: "/^(\\+|aft(er)?|from|hence)/", subtract: "/^(\\-|bef(ore)?|ago)/", yesterday: "/^yes(terday)?/", today: "/^t(od(ay)?)?/", tomorrow: "/^tom(orrow)?/", now: "/^n(ow)?/", millisecond: "/^ms|milli(second)?s?/", second: "/^sec(ond)?s?/", minute: "/^mn|min(ute)?s?/", hour: "/^h(our)?s?/", week: "/^w(eek)?s?/", month: "/^m(onth)?s?/", day: "/^d(ay)?s?/", year: "/^y(ear)?s?/", shortMeridian: "/^(a|p)/", longMeridian: "/^(a\\.?m?\\.?|p\\.?m?\\.?)/", timezone: "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/", ordinalSuffix: "/^\\s*(st|nd|rd|th)/", timeContext: "/^\\s*(\\:|a(?!u|p)|p)/" }, Date.i18n.currentLanguage()); } }; var CultureInfo = function () { var info = getText.getFromObjectValues({ name: "name", englishName: "englishName", nativeName: "nativeName", amDesignator: "AM", pmDesignator: "PM", firstDayOfWeek: "firstDayOfWeek", twoDigitYearMax: "twoDigitYearMax", dateElementOrder: "mdy" }, Date.i18n.currentLanguage()); var constructedInfo = buildInfo.buildFromMethodHash({ dayNames: "days", abbreviatedDayNames: "dayAbbr", shortestDayNames: "dayShortNames", firstLetterDayNames: "dayFirstLetters", monthNames: "months", abbreviatedMonthNames: "monthAbbr", formatPatterns: "formatPatterns", regexPatterns: "regex", abbreviatedTimeZoneDST: "timeZoneDST", abbreviatedTimeZoneStandard: "timeZoneStandard" }); shallowMerge(info, constructedInfo); buildInfo.timeZones(info); return info; }; $D.i18n = { __: function (key, lang) { return __(key, lang); }, currentLanguage: function () { return lang || "en-US"; }, setLanguage: function (code, force, cb) { var async = false; if (force || code === "en-US" || (!!Date.CultureStrings && !!Date.CultureStrings[code])) { lang = code; Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings.lang = code; Date.CultureInfo = new CultureInfo(); } else { if (!(!!Date.CultureStrings && !!Date.CultureStrings[code])) { if (typeof exports !== "undefined" && this.exports !== exports) { // we're in a Node enviroment, load it using require try { require("../i18n/" + code + ".js"); lang = code; Date.CultureStrings.lang = code; Date.CultureInfo = new CultureInfo(); } catch (e) { // var str = "The language for '" + code + "' could not be loaded by Node. It likely does not exist."; throw new Error("The DateJS IETF language tag '" + code + "' could not be loaded by Node. It likely does not exist."); } } else if (Date.Config && Date.Config.i18n) { // we know the location of the files, so lets load them async = true; loadI18nScript(code).done(function(){ lang = code; Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings.lang = code; Date.CultureInfo = new CultureInfo(); $D.Parsing.Normalizer.buildReplaceData(); // because this is async if ($D.Grammar) { $D.Grammar.buildGrammarFormats(); // so we can parse those strings... } if (cb) { setTimeout(cb,0); } }); } else { Date.console.error("The DateJS IETF language tag '" + code + "' is not available and has not been loaded."); return false; } } } $D.Parsing.Normalizer.buildReplaceData(); // rebuild normalizer strings if ($D.Grammar) { $D.Grammar.buildGrammarFormats(); // so we can parse those strings... } if (!async && cb) { setTimeout(cb,0); } }, getLoggedKeys: function () { return loggedKeys; }, updateCultureInfo: function () { Date.CultureInfo = new CultureInfo(); } }; $D.i18n.updateCultureInfo(); // run automatically }()); (function () { var $D = Date, $P = $D.prototype, p = function (s, l) { if (!l) { l = 2; } return ("000" + s).slice(l * -1); }; if (typeof window !== "undefined" && typeof window.console !== "undefined" && typeof window.console.log !== "undefined") { $D.console = console; // used only to raise non-critical errors if available } else { // set mock so we don't give errors. $D.console = { log: function(){}, error: function(){} }; } $D.Config = $D.Config || {}; $D.initOverloads = function() { /** * Overload of Date.now. Allows an alternate call for Date.now where it returns the * current Date as an object rather than just milliseconds since the Unix Epoch. * * Also provides an implementation of now() for browsers (IE<9) that don't have it. * * Backwards compatible so with work with either: * Date.now() [returns ms] * or * Date.now(true) [returns Date] */ if (!$D.now) { $D._now = function now() { return new Date().getTime(); }; } else if (!$D._now) { $D._now = $D.now; } $D.now = function (returnObj) { if (returnObj) { return $D.present(); } else { return $D._now(); } }; if ( !$P.toISOString ) { $P.toISOString = function() { return this.getUTCFullYear() + "-" + p(this.getUTCMonth() + 1) + "-" + p(this.getUTCDate()) + "T" + p(this.getUTCHours()) + ":" + p(this.getUTCMinutes()) + ":" + p(this.getUTCSeconds()) + "." + String( (this.getUTCMilliseconds()/1000).toFixed(3)).slice(2, 5) + "Z"; }; } // private if ( $P._toString === undefined ){ $P._toString = $P.toString; } }; $D.initOverloads(); /** * Gets a date that is set to the current date. The time is set to the start of the day (00:00 or 12:00 AM). * @return {Date} The current date. */ $D.today = function () { return new Date().clearTime(); }; /** * Gets a date that is set to the current date and time (same as new Date, but chainable) * @return {Date} The current date. */ $D.present = function () { return new Date(); }; /** * Compares the first date to the second date and returns an number indication of their relative values. * @param {Date} First Date object to compare [Required]. * @param {Date} Second Date object to compare to [Required]. * @return {Number} -1 = date1 is lessthan date2. 0 = values are equal. 1 = date1 is greaterthan date2. */ $D.compare = function (date1, date2) { if (isNaN(date1) || isNaN(date2)) { throw new Error(date1 + " - " + date2); } else if (date1 instanceof Date && date2 instanceof Date) { return (date1 < date2) ? -1 : (date1 > date2) ? 1 : 0; } else { throw new TypeError(date1 + " - " + date2); } }; /** * Compares the first Date object to the second Date object and returns true if they are equal. * @param {Date} First Date object to compare [Required] * @param {Date} Second Date object to compare to [Required] * @return {Boolean} true if dates are equal. false if they are not equal. */ $D.equals = function (date1, date2) { return (date1.compareTo(date2) === 0); }; /** * Gets the language appropriate day name when given the day number(0-6) * eg - 0 == Sunday * @return {String} The day name */ $D.getDayName = function (n) { return Date.CultureInfo.dayNames[n]; }; /** * Gets the day number (0-6) if given a CultureInfo specific string which is a valid dayName, abbreviatedDayName or shortestDayName (two char). * @param {String} The name of the day (eg. "Monday, "Mon", "tuesday", "tue", "We", "we"). * @return {Number} The day number */ $D.getDayNumberFromName = function (name) { var n = Date.CultureInfo.dayNames, m = Date.CultureInfo.abbreviatedDayNames, o = Date.CultureInfo.shortestDayNames, s = name.toLowerCase(); for (var i = 0; i < n.length; i++) { if (n[i].toLowerCase() === s || m[i].toLowerCase() === s || o[i].toLowerCase() === s) { return i; } } return -1; }; /** * Gets the month number (0-11) if given a Culture Info specific string which is a valid monthName or abbreviatedMonthName. * @param {String} The name of the month (eg. "February, "Feb", "october", "oct"). * @return {Number} The day number */ $D.getMonthNumberFromName = function (name) { var n = Date.CultureInfo.monthNames, m = Date.CultureInfo.abbreviatedMonthNames, s = name.toLowerCase(); for (var i = 0; i < n.length; i++) { if (n[i].toLowerCase() === s || m[i].toLowerCase() === s) { return i; } } return -1; }; /** * Gets the language appropriate month name when given the month number(0-11) * eg - 0 == January * @return {String} The month name */ $D.getMonthName = function (n) { return Date.CultureInfo.monthNames[n]; }; /** * Determines if the current date instance is within a LeapYear. * @param {Number} The year. * @return {Boolean} true if date is within a LeapYear, otherwise false. */ $D.isLeapYear = function (year) { return ((year % 4 === 0 && year % 100 !== 0) || year % 400 === 0); }; /** * Gets the number of days in the month, given a year and month value. Automatically corrects for LeapYear. * @param {Number} The year. * @param {Number} The month (0-11). * @return {Number} The number of days in the month. */ $D.getDaysInMonth = function (year, month) { if (!month && $D.validateMonth(year)) { month = year; year = Date.today().getFullYear(); } return [31, ($D.isLeapYear(year) ? 29 : 28), 31, 30, 31, 30, 31, 31, 30, 31, 30, 31][month]; }; $P.getDaysInMonth = function () { return $D.getDaysInMonth(this.getFullYear(), this.getMonth()); }; $D.getTimezoneAbbreviation = function (offset, dst) { var p, n = (dst || false) ? Date.CultureInfo.abbreviatedTimeZoneDST : Date.CultureInfo.abbreviatedTimeZoneStandard; for (p in n) { if (n.hasOwnProperty(p)) { if (n[p] === offset) { return p; } } } return null; }; $D.getTimezoneOffset = function (name, dst) { var i, a =[], z = Date.CultureInfo.timezones; if (!name) { name = (new Date()).getTimezone();} for (i = 0; i < z.length; i++) { if (z[i].name === name.toUpperCase()) { a.push(i); } } if (!z[a[0]]) { return null; } if (a.length === 1 || !dst) { return z[a[0]].offset; } else { for (i=0; i < a.length; i++) { if (z[a[i]].dst) { return z[a[i]].offset; } } } }; $D.getQuarter = function (d) { d = d || new Date(); // If no date supplied, use today var q = [1,2,3,4]; return q[Math.floor(d.getMonth() / 3)]; // ~~~ is a bitwise op. Faster than Math.floor }; $D.getDaysLeftInQuarter = function (d) { d = d || new Date(); var qEnd = new Date(d); qEnd.setMonth(qEnd.getMonth() + 3 - qEnd.getMonth() % 3, 0); return Math.floor((qEnd - d) / 8.64e7); }; // private var validate = function (n, min, max, name) { name = name ? name : "Object"; if (typeof n === "undefined") { return false; } else if (typeof n !== "number") { throw new TypeError(n + " is not a Number."); } else if (n < min || n > max) { // As failing validation is *not* an exceptional circumstance // lets not throw a RangeError Exception here. // It's semantically correct but it's not sensible. return false; } return true; }; /** * Validates the number is within an acceptable range for milliseconds [0-999]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateMillisecond = function (value) { return validate(value, 0, 999, "millisecond"); }; /** * Validates the number is within an acceptable range for seconds [0-59]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateSecond = function (value) { return validate(value, 0, 59, "second"); }; /** * Validates the number is within an acceptable range for minutes [0-59]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateMinute = function (value) { return validate(value, 0, 59, "minute"); }; /** * Validates the number is within an acceptable range for hours [0-23]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateHour = function (value) { return validate(value, 0, 23, "hour"); }; /** * Validates the number is within an acceptable range for the days in a month [0-MaxDaysInMonth]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateDay = function (value, year, month) { if (year === undefined || year === null || month === undefined || month === null) { return false;} return validate(value, 1, $D.getDaysInMonth(year, month), "day"); }; /** * Validates the number is within an acceptable range for months [0-11]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateWeek = function (value) { return validate(value, 0, 53, "week"); }; /** * Validates the number is within an acceptable range for months [0-11]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateMonth = function (value) { return validate(value, 0, 11, "month"); }; /** * Validates the number is within an acceptable range for years. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateYear = function (value) { /** * Per ECMAScript spec the range of times supported by Date objects is * exactly -100,000,000 days to +100,000,000 days measured relative to * midnight at the beginning of 01 January, 1970 UTC. * This gives a range of 8,640,000,000,000,000 milliseconds to either * side of 01 January, 1970 UTC. * * Earliest possible date: Tue, 20 Apr 271,822 B.C. 00:00:00 UTC * Latest possible date: Sat, 13 Sep 275,760 00:00:00 UTC */ return validate(value, -271822, 275760, "year"); }; $D.validateTimezone = function(value) { var timezones = {"ACDT":1,"ACST":1,"ACT":1,"ADT":1,"AEDT":1,"AEST":1,"AFT":1,"AKDT":1,"AKST":1,"AMST":1,"AMT":1,"ART":1,"AST":1,"AWDT":1,"AWST":1,"AZOST":1,"AZT":1,"BDT":1,"BIOT":1,"BIT":1,"BOT":1,"BRT":1,"BST":1,"BTT":1,"CAT":1,"CCT":1,"CDT":1,"CEDT":1,"CEST":1,"CET":1,"CHADT":1,"CHAST":1,"CHOT":1,"ChST":1,"CHUT":1,"CIST":1,"CIT":1,"CKT":1,"CLST":1,"CLT":1,"COST":1,"COT":1,"CST":1,"CT":1,"CVT":1,"CWST":1,"CXT":1,"DAVT":1,"DDUT":1,"DFT":1,"EASST":1,"EAST":1,"EAT":1,"ECT":1,"EDT":1,"EEDT":1,"EEST":1,"EET":1,"EGST":1,"EGT":1,"EIT":1,"EST":1,"FET":1,"FJT":1,"FKST":1,"FKT":1,"FNT":1,"GALT":1,"GAMT":1,"GET":1,"GFT":1,"GILT":1,"GIT":1,"GMT":1,"GST":1,"GYT":1,"HADT":1,"HAEC":1,"HAST":1,"HKT":1,"HMT":1,"HOVT":1,"HST":1,"ICT":1,"IDT":1,"IOT":1,"IRDT":1,"IRKT":1,"IRST":1,"IST":1,"JST":1,"KGT":1,"KOST":1,"KRAT":1,"KST":1,"LHST":1,"LINT":1,"MAGT":1,"MART":1,"MAWT":1,"MDT":1,"MET":1,"MEST":1,"MHT":1,"MIST":1,"MIT":1,"MMT":1,"MSK":1,"MST":1,"MUT":1,"MVT":1,"MYT":1,"NCT":1,"NDT":1,"NFT":1,"NPT":1,"NST":1,"NT":1,"NUT":1,"NZDT":1,"NZST":1,"OMST":1,"ORAT":1,"PDT":1,"PET":1,"PETT":1,"PGT":1,"PHOT":1,"PHT":1,"PKT":1,"PMDT":1,"PMST":1,"PONT":1,"PST":1,"PYST":1,"PYT":1,"RET":1,"ROTT":1,"SAKT":1,"SAMT":1,"SAST":1,"SBT":1,"SCT":1,"SGT":1,"SLST":1,"SRT":1,"SST":1,"SYOT":1,"TAHT":1,"THA":1,"TFT":1,"TJT":1,"TKT":1,"TLT":1,"TMT":1,"TOT":1,"TVT":1,"UCT":1,"ULAT":1,"UTC":1,"UYST":1,"UYT":1,"UZT":1,"VET":1,"VLAT":1,"VOLT":1,"VOST":1,"VUT":1,"WAKT":1,"WAST":1,"WAT":1,"WEDT":1,"WEST":1,"WET":1,"WST":1,"YAKT":1,"YEKT":1,"Z":1}; return (timezones[value] === 1); }; $D.validateTimezoneOffset= function(value) { // timezones go from +14hrs to -12hrs, the +X hours are negative offsets. return (value > -841 && value < 721); }; }()); (function () { var $D = Date, $P = $D.prototype, p = function (s, l) { if (!l) { l = 2; } return ("000" + s).slice(l * -1); }; var validateConfigObject = function (obj) { var result = {}, self = this, prop, testFunc; testFunc = function (prop, func, value) { if (prop === "day") { var month = (obj.month !== undefined) ? obj.month : self.getMonth(); var year = (obj.year !== undefined) ? obj.year : self.getFullYear(); return $D[func](value, year, month); } else { return $D[func](value); } }; for (prop in obj) { if (Object.prototype.hasOwnProperty.call(obj, prop)) { var func = "validate" + prop.charAt(0).toUpperCase() + prop.slice(1); if ($D[func] && obj[prop] !== null && testFunc(prop, func, obj[prop])) { result[prop] = obj[prop]; } } } return result; }; /** * Resets the time of this Date object to 12:00 AM (00:00), which is the start of the day. * @param {Boolean} .clone() this date instance before clearing Time * @return {Date} this */ $P.clearTime = function () { this.setHours(0); this.setMinutes(0); this.setSeconds(0); this.setMilliseconds(0); return this; }; /** * Resets the time of this Date object to the current time ('now'). * @return {Date} this */ $P.setTimeToNow = function () { var n = new Date(); this.setHours(n.getHours()); this.setMinutes(n.getMinutes()); this.setSeconds(n.getSeconds()); this.setMilliseconds(n.getMilliseconds()); return this; }; /** * Returns a new Date object that is an exact date and time copy of the original instance. * @return {Date} A new Date instance */ $P.clone = function () { return new Date(this.getTime()); }; /** * Compares this instance to a Date object and returns an number indication of their relative values. * @param {Date} Date object to compare [Required] * @return {Number} -1 = this is lessthan date. 0 = values are equal. 1 = this is greaterthan date. */ $P.compareTo = function (date) { return Date.compare(this, date); }; /** * Compares this instance to another Date object and returns true if they are equal. * @param {Date} Date object to compare. If no date to compare, new Date() [now] is used. * @return {Boolean} true if dates are equal. false if they are not equal. */ $P.equals = function (date) { return Date.equals(this, (date !== undefined ? date : new Date())); }; /** * Determines if this instance is between a range of two dates or equal to either the start or end dates. * @param {Date} Start of range [Required] * @param {Date} End of range [Required] * @return {Boolean} true is this is between or equal to the start and end dates, else false */ $P.between = function (start, end) { return this.getTime() >= start.getTime() && this.getTime() <= end.getTime(); }; /** * Determines if this date occurs after the date to compare to. * @param {Date} Date object to compare. If no date to compare, new Date() ("now") is used. * @return {Boolean} true if this date instance is greater than the date to compare to (or "now"), otherwise false. */ $P.isAfter = function (date) { return this.compareTo(date || new Date()) === 1; }; /** * Determines if this date occurs before the date to compare to. * @param {Date} Date object to compare. If no date to compare, new Date() ("now") is used. * @return {Boolean} true if this date instance is less than the date to compare to (or "now"). */ $P.isBefore = function (date) { return (this.compareTo(date || new Date()) === -1); }; /** * Determines if the current Date instance occurs today. * @return {Boolean} true if this date instance is 'today', otherwise false. */ /** * Determines if the current Date instance occurs on the same Date as the supplied 'date'. * If no 'date' to compare to is provided, the current Date instance is compared to 'today'. * @param {date} Date object to compare. If no date to compare, the current Date ("now") is used. * @return {Boolean} true if this Date instance occurs on the same Day as the supplied 'date'. */ $P.isToday = $P.isSameDay = function (date) { return this.clone().clearTime().equals((date || new Date()).clone().clearTime()); }; /** * Adds the specified number of milliseconds to this instance. * @param {Number} The number of milliseconds to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addMilliseconds = function (value) { if (!value) { return this; } this.setTime(this.getTime() + value * 1); return this; }; /** * Adds the specified number of seconds to this instance. * @param {Number} The number of seconds to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addSeconds = function (value) { if (!value) { return this; } return this.addMilliseconds(value * 1000); }; /** * Adds the specified number of seconds to this instance. * @param {Number} The number of seconds to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addMinutes = function (value) { if (!value) { return this; } return this.addMilliseconds(value * 60000); // 60*1000 }; /** * Adds the specified number of hours to this instance. * @param {Number} The number of hours to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addHours = function (value) { if (!value) { return this; } return this.addMilliseconds(value * 3600000); // 60*60*1000 }; /** * Adds the specified number of days to this instance. * @param {Number} The number of days to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addDays = function (value) { if (!value) { return this; } this.setDate(this.getDate() + value * 1); return this; }; /** * Adds the specified number of weekdays (ie - not sat or sun) to this instance. * @param {Number} The number of days to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addWeekdays = function (value) { if (!value) { return this; } var day = this.getDay(); var weeks = (Math.ceil(Math.abs(value)/7)); if (day === 0 || day === 6) { if (value > 0) { this.next().monday(); this.addDays(-1); day = this.getDay(); } } if (value < 0) { while (value < 0) { this.addDays(-1); day = this.getDay(); if (day !== 0 && day !== 6) { value++; } } return this; } else if (value > 5 || (6-day) <= value) { value = value + (weeks * 2); } return this.addDays(value); }; /** * Adds the specified number of weeks to this instance. * @param {Number} The number of weeks to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addWeeks = function (value) { if (!value) { return this; } return this.addDays(value * 7); }; /** * Adds the specified number of months to this instance. * @param {Number} The number of months to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addMonths = function (value) { if (!value) { return this; } var n = this.getDate(); this.setDate(1); this.setMonth(this.getMonth() + value * 1); this.setDate(Math.min(n, $D.getDaysInMonth(this.getFullYear(), this.getMonth()))); return this; }; $P.addQuarters = function (value) { if (!value) { return this; } // note this will take you to the same point in the quarter as you are now. // i.e. - if you are 15 days into the quarter you'll be 15 days into the resulting one. // bonus: this allows adding fractional quarters return this.addMonths(value * 3); }; /** * Adds the specified number of years to this instance. * @param {Number} The number of years to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addYears = function (value) { if (!value) { return this; } return this.addMonths(value * 12); }; /** * Adds (or subtracts) to the value of the years, months, weeks, days, hours, minutes, seconds, milliseconds of the date instance using given configuration object. Positive and Negative values allowed. * Example

	Date.today().add( { days: 1, months: 1 } )

	new Date().add( { years: -1 } )
	
* @param {Object} Configuration object containing attributes (months, days, etc.) * @return {Date} this */ $P.add = function (config) { if (typeof config === "number") { this._orient = config; return this; } var x = config; if (x.day) { // If we should be a different date than today (eg: for 'tomorrow -1d', etc). // Should only effect parsing, not direct usage (eg, Finish and FinishExact) if ((x.day - this.getDate()) !== 0) { this.setDate(x.day); } } if (x.milliseconds) { this.addMilliseconds(x.milliseconds); } if (x.seconds) { this.addSeconds(x.seconds); } if (x.minutes) { this.addMinutes(x.minutes); } if (x.hours) { this.addHours(x.hours); } if (x.weeks) { this.addWeeks(x.weeks); } if (x.months) { this.addMonths(x.months); } if (x.years) { this.addYears(x.years); } if (x.days) { this.addDays(x.days); } return this; }; /** * Get the week number. Week one (1) is the week which contains the first Thursday of the year. Monday is considered the first day of the week. * The .getWeek() function does NOT convert the date to UTC. The local datetime is used. * Please use .getISOWeek() to get the week of the UTC converted date. * @return {Number} 1 to 53 */ $P.getWeek = function (utc) { // Create a copy of this date object var self, target = new Date(this.valueOf()); if (utc) { target.addMinutes(target.getTimezoneOffset()); self = target.clone(); } else { self = this; } // ISO week date weeks start on monday // so correct the day number var dayNr = (self.getDay() + 6) % 7; // ISO 8601 states that week 1 is the week // with the first thursday of that year. // Set the target date to the thursday in the target week target.setDate(target.getDate() - dayNr + 3); // Store the millisecond value of the target date var firstThursday = target.valueOf(); // Set the target to the first thursday of the year // First set the target to january first target.setMonth(0, 1); // Not a thursday? Correct the date to the next thursday if (target.getDay() !== 4) { target.setMonth(0, 1 + ((4 - target.getDay()) + 7) % 7); } // The weeknumber is the number of weeks between the // first thursday of the year and the thursday in the target week return 1 + Math.ceil((firstThursday - target) / 604800000); // 604800000 = 7 * 24 * 3600 * 1000 }; /** * Get the ISO 8601 week number. Week one ("01") is the week which contains the first Thursday of the year. Monday is considered the first day of the week. * The .getISOWeek() function does convert the date to it's UTC value. Please use .getWeek() to get the week of the local date. * @return {String} "01" to "53" */ $P.getISOWeek = function () { return p(this.getWeek(true)); }; /** * Moves the date to Monday of the week set. Week one (1) is the week which contains the first Thursday of the year. * @param {Number} A Number (1 to 53) that represents the week of the year. * @return {Date} this */ $P.setWeek = function (n) { if ((n - this.getWeek()) === 0) { if (this.getDay() !== 1) { return this.moveToDayOfWeek(1, (this.getDay() > 1 ? -1 : 1)); } else { return this; } } else { return this.moveToDayOfWeek(1, (this.getDay() > 1 ? -1 : 1)).addWeeks(n - this.getWeek()); } }; $P.setQuarter = function (qtr) { var month = Math.abs(((qtr-1) * 3) + 1); return this.setMonth(month, 1); }; $P.getQuarter = function () { return Date.getQuarter(this); }; $P.getDaysLeftInQuarter = function () { return Date.getDaysLeftInQuarter(this); }; /** * Moves the date to the next n'th occurrence of the dayOfWeek starting from the beginning of the month. The number (-1) is a magic number and will return the last occurrence of the dayOfWeek in the month. * @param {Number} The dayOfWeek to move to * @param {Number} The n'th occurrence to move to. Use (-1) to return the last occurrence in the month * @return {Date} this */ $P.moveToNthOccurrence = function (dayOfWeek, occurrence) { if (dayOfWeek === "Weekday") { if (occurrence > 0) { this.moveToFirstDayOfMonth(); if (this.is().weekday()) { occurrence -= 1; } } else if (occurrence < 0) { this.moveToLastDayOfMonth(); if (this.is().weekday()) { occurrence += 1; } } else { return this; } return this.addWeekdays(occurrence); } var shift = 0; if (occurrence > 0) { shift = occurrence - 1; } else if (occurrence === -1) { this.moveToLastDayOfMonth(); if (this.getDay() !== dayOfWeek) { this.moveToDayOfWeek(dayOfWeek, -1); } return this; } return this.moveToFirstDayOfMonth().addDays(-1).moveToDayOfWeek(dayOfWeek, +1).addWeeks(shift); }; var moveToN = function (getFunc, addFunc, nVal) { return function (value, orient) { var diff = (value - this[getFunc]() + nVal * (orient || +1)) % nVal; return this[addFunc]((diff === 0) ? diff += nVal * (orient || +1) : diff); }; }; /** * Move to the next or last dayOfWeek based on the orient value. * @param {Number} The dayOfWeek to move to * @param {Number} Forward (+1) or Back (-1). Defaults to +1. [Optional] * @return {Date} this */ $P.moveToDayOfWeek = moveToN("getDay", "addDays", 7); /** * Move to the next or last month based on the orient value. * @param {Number} The month to move to. 0 = January, 11 = December * @param {Number} Forward (+1) or Back (-1). Defaults to +1. [Optional] * @return {Date} this */ $P.moveToMonth = moveToN("getMonth", "addMonths", 12); /** * Get the Ordinate of the current day ("th", "st", "rd"). * @return {String} */ $P.getOrdinate = function () { var num = this.getDate(); return ord(num); }; /** * Get the Ordinal day (numeric day number) of the year, adjusted for leap year. * @return {Number} 1 through 365 (366 in leap years) */ $P.getOrdinalNumber = function () { return Math.ceil((this.clone().clearTime() - new Date(this.getFullYear(), 0, 1)) / 86400000) + 1; }; /** * Get the time zone abbreviation of the current date. * @return {String} The abbreviated time zone name (e.g. "EST") */ $P.getTimezone = function () { return $D.getTimezoneAbbreviation(this.getUTCOffset(), this.isDaylightSavingTime()); }; $P.setTimezoneOffset = function (offset) { var here = this.getTimezoneOffset(), there = Number(offset) * -6 / 10; return (there || there === 0) ? this.addMinutes(there - here) : this; }; $P.setTimezone = function (offset) { return this.setTimezoneOffset($D.getTimezoneOffset(offset)); }; /** * Indicates whether Daylight Saving Time is observed in the current time zone. * @return {Boolean} true|false */ $P.hasDaylightSavingTime = function () { return (Date.today().set({month: 0, day: 1}).getTimezoneOffset() !== Date.today().set({month: 6, day: 1}).getTimezoneOffset()); }; /** * Indicates whether this Date instance is within the Daylight Saving Time range for the current time zone. * @return {Boolean} true|false */ $P.isDaylightSavingTime = function () { return Date.today().set({month: 0, day: 1}).getTimezoneOffset() !== this.getTimezoneOffset(); }; /** * Get the offset from UTC of the current date. * @return {String} The 4-character offset string prefixed with + or - (e.g. "-0500") */ $P.getUTCOffset = function (offset) { var n = (offset || this.getTimezoneOffset()) * -10 / 6, r; if (n < 0) { r = (n - 10000).toString(); return r.charAt(0) + r.substr(2); } else { r = (n + 10000).toString(); return "+" + r.substr(1); } }; /** * Returns the number of milliseconds between this date and date. * @param {Date} Defaults to now * @return {Number} The diff in milliseconds */ $P.getElapsed = function (date) { return (date || new Date()) - this; }; /** * Set the value of year, month, day, hour, minute, second, millisecond of date instance using given configuration object. * Example

	Date.today().set( { day: 20, month: 1 } )

	new Date().set( { millisecond: 0 } )
	
* * @param {Object} Configuration object containing attributes (month, day, etc.) * @return {Date} this */ $P.set = function (config) { config = validateConfigObject.call(this, config); var key; for (key in config) { if (Object.prototype.hasOwnProperty.call(config, key)) { var name = key.charAt(0).toUpperCase() + key.slice(1); var addFunc, getFunc; if (key !== "week" && key !== "month" && key !== "timezone" && key !== "timezoneOffset") { name += "s"; } addFunc = "add" + name; getFunc = "get" + name; if (key === "month") { addFunc = addFunc + "s"; } else if (key === "year"){ getFunc = "getFullYear"; } if (key !== "day" && key !== "timezone" && key !== "timezoneOffset" && key !== "week" && key !== "hour") { this[addFunc](config[key] - this[getFunc]()); } else if ( key === "timezone"|| key === "timezoneOffset" || key === "week" || key === "hour") { this["set"+name](config[key]); } } } // day has to go last because you can't validate the day without first knowing the month if (config.day) { this.addDays(config.day - this.getDate()); } return this; }; /** * Moves the date to the first day of the month. * @return {Date} this */ $P.moveToFirstDayOfMonth = function () { return this.set({ day: 1 }); }; /** * Moves the date to the last day of the month. * @return {Date} this */ $P.moveToLastDayOfMonth = function () { return this.set({ day: $D.getDaysInMonth(this.getFullYear(), this.getMonth())}); }; /** * Converts the value of the current Date object to its equivalent string representation. * Format Specifiers * CUSTOM DATE AND TIME FORMAT STRINGS * Format Description Example * ------ --------------------------------------------------------------------------- ----------------------- * s The seconds of the minute between 0-59. "0" to "59" * ss The seconds of the minute with leading zero if required. "00" to "59" * * m The minute of the hour between 0-59. "0" or "59" * mm The minute of the hour with leading zero if required. "00" or "59" * * h The hour of the day between 1-12. "1" to "12" * hh The hour of the day with leading zero if required. "01" to "12" * * H The hour of the day between 0-23. "0" to "23" * HH The hour of the day with leading zero if required. "00" to "23" * * d The day of the month between 1 and 31. "1" to "31" * dd The day of the month with leading zero if required. "01" to "31" * ddd Abbreviated day name. Date.CultureInfo.abbreviatedDayNames. "Mon" to "Sun" * dddd The full day name. Date.CultureInfo.dayNames. "Monday" to "Sunday" * * M The month of the year between 1-12. "1" to "12" * MM The month of the year with leading zero if required. "01" to "12" * MMM Abbreviated month name. Date.CultureInfo.abbreviatedMonthNames. "Jan" to "Dec" * MMMM The full month name. Date.CultureInfo.monthNames. "January" to "December" * * yy The year as a two-digit number. "99" or "08" * yyyy The full four digit year. "1999" or "2008" * * t Displays the first character of the A.M./P.M. designator. "A" or "P" * Date.CultureInfo.amDesignator or Date.CultureInfo.pmDesignator * tt Displays the A.M./P.M. designator. "AM" or "PM" * Date.CultureInfo.amDesignator or Date.CultureInfo.pmDesignator * * S The ordinal suffix ("st, "nd", "rd" or "th") of the current day. "st, "nd", "rd" or "th" * * STANDARD DATE AND TIME FORMAT STRINGS * Format Description Example *------ --------------------------------------------------------------------------- ----------------------- * d The CultureInfo shortDate Format Pattern "M/d/yyyy" * D The CultureInfo longDate Format Pattern "dddd, MMMM dd, yyyy" * F The CultureInfo fullDateTime Format Pattern "dddd, MMMM dd, yyyy h:mm:ss tt" * m The CultureInfo monthDay Format Pattern "MMMM dd" * r The CultureInfo rfc1123 Format Pattern "ddd, dd MMM yyyy HH:mm:ss GMT" * s The CultureInfo sortableDateTime Format Pattern "yyyy-MM-ddTHH:mm:ss" * t The CultureInfo shortTime Format Pattern "h:mm tt" * T The CultureInfo longTime Format Pattern "h:mm:ss tt" * u The CultureInfo universalSortableDateTime Format Pattern "yyyy-MM-dd HH:mm:ssZ" * y The CultureInfo yearMonth Format Pattern "MMMM, yyyy" * * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @return {String} A string representation of the current Date object. */ var ord = function (n) { switch (n * 1) { case 1: case 21: case 31: return "st"; case 2: case 22: return "nd"; case 3: case 23: return "rd"; default: return "th"; } }; var parseStandardFormats = function (format) { var y, c = Date.CultureInfo.formatPatterns; switch (format) { case "d": return this.toString(c.shortDate); case "D": return this.toString(c.longDate); case "F": return this.toString(c.fullDateTime); case "m": return this.toString(c.monthDay); case "r": case "R": y = this.clone().addMinutes(this.getTimezoneOffset()); return y.toString(c.rfc1123) + " GMT"; case "s": return this.toString(c.sortableDateTime); case "t": return this.toString(c.shortTime); case "T": return this.toString(c.longTime); case "u": y = this.clone().addMinutes(this.getTimezoneOffset()); return y.toString(c.universalSortableDateTime); case "y": return this.toString(c.yearMonth); default: return false; } }; var parseFormatStringsClosure = function (context) { return function (m) { if (m.charAt(0) === "\\") { return m.replace("\\", ""); } switch (m) { case "hh": return p(context.getHours() < 13 ? (context.getHours() === 0 ? 12 : context.getHours()) : (context.getHours() - 12)); case "h": return context.getHours() < 13 ? (context.getHours() === 0 ? 12 : context.getHours()) : (context.getHours() - 12); case "HH": return p(context.getHours()); case "H": return context.getHours(); case "mm": return p(context.getMinutes()); case "m": return context.getMinutes(); case "ss": return p(context.getSeconds()); case "s": return context.getSeconds(); case "yyyy": return p(context.getFullYear(), 4); case "yy": return p(context.getFullYear()); case "y": return context.getFullYear(); case "E": case "dddd": return Date.CultureInfo.dayNames[context.getDay()]; case "ddd": return Date.CultureInfo.abbreviatedDayNames[context.getDay()]; case "dd": return p(context.getDate()); case "d": return context.getDate(); case "MMMM": return Date.CultureInfo.monthNames[context.getMonth()]; case "MMM": return Date.CultureInfo.abbreviatedMonthNames[context.getMonth()]; case "MM": return p((context.getMonth() + 1)); case "M": return context.getMonth() + 1; case "t": return context.getHours() < 12 ? Date.CultureInfo.amDesignator.substring(0, 1) : Date.CultureInfo.pmDesignator.substring(0, 1); case "tt": return context.getHours() < 12 ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator; case "S": return ord(context.getDate()); case "W": return context.getWeek(); case "WW": return context.getISOWeek(); case "Q": return "Q" + context.getQuarter(); case "q": return String(context.getQuarter()); case "z": return context.getTimezone(); case "Z": case "X": return Date.getTimezoneOffset(context.getTimezone()); case "ZZ": // Timezone offset in seconds return context.getTimezoneOffset() * -60; case "u": return context.getDay(); case "L": return ($D.isLeapYear(context.getFullYear())) ? 1 : 0; case "B": // Swatch Internet Time (.beats) return "@"+((context.getUTCSeconds() + (context.getUTCMinutes()*60) + ((context.getUTCHours()+1)*3600))/86.4); default: return m; } }; }; $P.toString = function (format, ignoreStandards) { // Standard Date and Time Format Strings. Formats pulled from CultureInfo file and // may vary by culture. if (!ignoreStandards && format && format.length === 1) { output = parseStandardFormats.call(this, format); if (output) { return output; } } var parseFormatStrings = parseFormatStringsClosure(this); return format ? format.replace(/((\\)?(dd?d?d?|MM?M?M?|yy?y?y?|hh?|HH?|mm?|ss?|tt?|S|q|Q|WW?W?W?)(?![^\[]*\]))/g, parseFormatStrings).replace(/\[|\]/g, "") : this._toString(); }; }()); /************************************************************* * SugarPak - Domain Specific Language - Syntactical Sugar * *************************************************************/ (function () { var $D = Date, $P = $D.prototype, $N = Number.prototype; // private $P._orient = +1; // private $P._nth = null; // private $P._is = false; // private $P._same = false; // private $P._isSecond = false; // private $N._dateElement = "days"; /** * Moves the date to the next instance of a date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.today().next().friday();
	Date.today().next().fri();
	Date.today().next().march();
	Date.today().next().mar();
	Date.today().next().week();
	
* * @return {Date} date */ $P.next = function () { this._move = true; this._orient = +1; return this; }; /** * Creates a new Date (Date.today()) and moves the date to the next instance of the date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.next().friday();
	Date.next().fri();
	Date.next().march();
	Date.next().mar();
	Date.next().week();
	
* * @return {Date} date */ $D.next = function () { return $D.today().next(); }; /** * Moves the date to the previous instance of a date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.today().last().friday();
	Date.today().last().fri();
	Date.today().last().march();
	Date.today().last().mar();
	Date.today().last().week();
	
* * @return {Date} date */ $P.last = $P.prev = $P.previous = function () { this._move = true; this._orient = -1; return this; }; /** * Creates a new Date (Date.today()) and moves the date to the previous instance of the date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.last().friday();
	Date.last().fri();
	Date.previous().march();
	Date.prev().mar();
	Date.last().week();
	
* * @return {Date} date */ $D.last = $D.prev = $D.previous = function () { return $D.today().last(); }; /** * Performs a equality check when followed by either a month name, day name or .weekday() function. * Example

	Date.today().is().friday(); // true|false
	Date.today().is().fri();
	Date.today().is().march();
	Date.today().is().mar();
	
* * @return {Boolean} true|false */ $P.is = function () { this._is = true; return this; }; /** * Determines if two date objects occur on/in exactly the same instance of the subsequent date part function. * The function .same() must be followed by a date part function (example: .day(), .month(), .year(), etc). * * An optional Date can be passed in the date part function. If now date is passed as a parameter, 'Now' is used. * * The following example demonstrates how to determine if two dates fall on the exact same day. * * Example

	var d1 = Date.today(); // today at 00:00
	var d2 = new Date();   // exactly now.

	// Do they occur on the same day?
	d1.same().day(d2); // true
	
	// Do they occur on the same hour?
	d1.same().hour(d2); // false, unless d2 hour is '00' (midnight).
	
	// What if it's the same day, but one year apart?
	var nextYear = Date.today().add(1).year();

	d1.same().day(nextYear); // false, because the dates must occur on the exact same day. 
	
* * Scenario: Determine if a given date occurs during some week period 2 months from now. * * Example

	var future = Date.today().add(2).months();
	return someDate.same().week(future); // true|false;
	
* * @return {Boolean} true|false */ $P.same = function () { this._same = true; this._isSecond = false; return this; }; /** * Determines if the current date/time occurs during Today. Must be preceded by the .is() function. * Example

	someDate.is().today();    // true|false
	new Date().is().today();  // true
	Date.today().is().today();// true
	Date.today().add(-1).day().is().today(); // false
	
* * @return {Boolean} true|false */ $P.today = function () { return this.same().day(); }; /** * Determines if the current date is a weekday. This function must be preceded by the .is() function. * Example

	Date.today().is().weekday(); // true|false
	
* * @return {Boolean} true|false */ $P.weekday = function () { if (this._nth) { return df("Weekday").call(this); } if (this._move) { return this.addWeekdays(this._orient); } if (this._is) { this._is = false; return (!this.is().sat() && !this.is().sun()); } return false; }; /** * Determines if the current date is on the weekend. This function must be preceded by the .is() function. * Example

	Date.today().is().weekend(); // true|false
	
* * @return {Boolean} true|false */ $P.weekend = function () { if (this._is) { this._is = false; return (this.is().sat() || this.is().sun()); } return false; }; /** * Sets the Time of the current Date instance. A string "6:15 pm" or config object {hour:18, minute:15} are accepted. * Example

	// Set time to 6:15pm with a String
	Date.today().at("6:15pm");

	// Set time to 6:15pm with a config object
	Date.today().at({hour:18, minute:15});
	
* * @return {Date} date */ $P.at = function (time) { return (typeof time === "string") ? $D.parse(this.toString("d") + " " + time) : this.set(time); }; /** * Creates a new Date() and adds this (Number) to the date based on the preceding date element function (eg. second|minute|hour|day|month|year). * Example

	// Undeclared Numbers must be wrapped with parentheses. Requirment of JavaScript.
	(3).days().fromNow();
	(6).months().fromNow();

	// Declared Number variables do not require parentheses. 
	var n = 6;
	n.months().fromNow();
	
* * @return {Date} A new Date instance */ $N.fromNow = $N.after = function (date) { var c = {}; c[this._dateElement] = this; return ((!date) ? new Date() : date.clone()).add(c); }; /** * Creates a new Date() and subtract this (Number) from the date based on the preceding date element function (eg. second|minute|hour|day|month|year). * Example

	// Undeclared Numbers must be wrapped with parentheses. Requirment of JavaScript.
	(3).days().ago();
	(6).months().ago();

	// Declared Number variables do not require parentheses. 
	var n = 6;
	n.months().ago();
	
* * @return {Date} A new Date instance */ $N.ago = $N.before = function (date) { var c = {}, s = (this._dateElement[this._dateElement.length-1] !== "s") ? this._dateElement + "s" : this._dateElement; c[s] = this * -1; return ((!date) ? new Date() : date.clone()).add(c); }; // Do NOT modify the following string tokens. These tokens are used to build dynamic functions. // All culture-specific strings can be found in the CultureInfo files. var dx = ("sunday monday tuesday wednesday thursday friday saturday").split(/\s/), mx = ("january february march april may june july august september october november december").split(/\s/), px = ("Millisecond Second Minute Hour Day Week Month Year Quarter Weekday").split(/\s/), pxf = ("Milliseconds Seconds Minutes Hours Date Week Month FullYear Quarter").split(/\s/), nth = ("final first second third fourth fifth").split(/\s/), de; /** * Returns an object literal of all the date parts. * Example

	var o = new Date().toObject();
	
	// { year: 2008, month: 4, week: 20, day: 13, hour: 18, minute: 9, second: 32, millisecond: 812 }
	
	// The object properties can be referenced directly from the object.
	
	alert(o.day);  // alerts "13"
	alert(o.year); // alerts "2008"
	
* * @return {Date} An object literal representing the original date object. */ $P.toObject = function () { var o = {}; for (var i = 0; i < px.length; i++) { if (this["get" + pxf[i]]) { o[px[i].toLowerCase()] = this["get" + pxf[i]](); } } return o; }; /** * Returns a date created from an object literal. Ignores the .week property if set in the config. * Example

	var o = new Date().toObject();
	
	return Date.fromObject(o); // will return the same date. 

	var o2 = {month: 1, day: 20, hour: 18}; // birthday party!
	Date.fromObject(o2);
	
* * @return {Date} An object literal representing the original date object. */ $D.fromObject = function(config) { config.week = null; return Date.today().set(config); }; // Create day name functions and abbreviated day name functions (eg. monday(), friday(), fri()). var df = function (n) { return function () { if (this._is) { this._is = false; return this.getDay() === n; } if (this._move) { this._move = null; } if (this._nth !== null) { // If the .second() function was called earlier, remove the _orient // from the date, and then continue. // This is required because 'second' can be used in two different context. // // Example // // Date.today().add(1).second(); // Date.march().second().monday(); // // Things get crazy with the following... // Date.march().add(1).second().second().monday(); // but it works!! // if (this._isSecond) { this.addSeconds(this._orient * -1); } // make sure we reset _isSecond this._isSecond = false; var ntemp = this._nth; this._nth = null; var temp = this.clone().moveToLastDayOfMonth(); this.moveToNthOccurrence(n, ntemp); if (this > temp) { throw new RangeError($D.getDayName(n) + " does not occur " + ntemp + " times in the month of " + $D.getMonthName(temp.getMonth()) + " " + temp.getFullYear() + "."); } return this; } return this.moveToDayOfWeek(n, this._orient); }; }; var sdf = function (n) { return function () { var t = $D.today(), shift = n - t.getDay(); if (n === 0 && Date.CultureInfo.firstDayOfWeek === 1 && t.getDay() !== 0) { shift = shift + 7; } return t.addDays(shift); }; }; // Create month name functions and abbreviated month name functions (eg. january(), march(), mar()). var month_instance_functions = function (n) { return function () { if (this._is) { this._is = false; return this.getMonth() === n; } return this.moveToMonth(n, this._orient); }; }; var month_static_functions = function (n) { return function () { return $D.today().set({ month: n, day: 1 }); }; }; var processTerms = function (names, staticFunc, instanceFunc) { for (var i = 0; i < names.length; i++) { // Create constant static Name variables. $D[names[i].toUpperCase()] = $D[names[i].toUpperCase().substring(0, 3)] = i; // Create Name functions. $D[names[i]] = $D[names[i].substring(0, 3)] = staticFunc(i); // Create Name instance functions. $P[names[i]] = $P[names[i].substring(0, 3)] = instanceFunc(i); } }; processTerms(dx, sdf, df); processTerms(mx, month_static_functions, month_instance_functions); // Create date element functions and plural date element functions used with Date (eg. day(), days(), months()). var ef = function (j) { return function () { // if the .second() function was called earlier, the _orient // has alread been added. Just return this and reset _isSecond. if (this._isSecond) { this._isSecond = false; return this; } if (this._same) { this._same = this._is = false; var o1 = this.toObject(), o2 = (arguments[0] || new Date()).toObject(), v = "", k = j.toLowerCase(); // the substr trick with -1 doesn't work in IE8 or less k = (k[k.length-1] === "s") ? k.substring(0,k.length-1) : k; for (var m = (px.length - 1); m > -1; m--) { v = px[m].toLowerCase(); if (o1[v] !== o2[v]) { return false; } if (k === v) { break; } } return true; } if (j.substring(j.length - 1) !== "s") { j += "s"; } if (this._move) { this._move = null; } return this["add" + j](this._orient); }; }; var nf = function (n) { return function () { this._dateElement = n; return this; }; }; for (var k = 0; k < px.length; k++) { de = px[k].toLowerCase(); if(de !== "weekday") { // Create date element functions and plural date element functions used with Date (eg. day(), days(), months()). $P[de] = $P[de + "s"] = ef(px[k]); // Create date element functions and plural date element functions used with Number (eg. day(), days(), months()). $N[de] = $N[de + "s"] = nf(de + "s"); } } $P._ss = ef("Second"); var nthfn = function (n) { return function (dayOfWeek) { if (this._same) { return this._ss(arguments[0]); } if (dayOfWeek || dayOfWeek === 0) { return this.moveToNthOccurrence(dayOfWeek, n); } this._nth = n; // if the operator is 'second' add the _orient, then deal with it later... if (n === 2 && (dayOfWeek === undefined || dayOfWeek === null)) { this._isSecond = true; return this.addSeconds(this._orient); } return this; }; }; for (var l = 0; l < nth.length; l++) { $P[nth[l]] = (l === 0) ? nthfn(-1) : nthfn(l); } }()); (function () { "use strict"; Date.Parsing = { Exception: function (s) { this.message = "Parse error at '" + s.substring(0, 10) + " ...'"; } }; var $P = Date.Parsing; var dayOffsets = { standard: [0,31,59,90,120,151,181,212,243,273,304,334], leap: [0,31,60,91,121,152,182,213,244,274,305,335] }; $P.isLeapYear = function(year) { return ((year % 4 === 0) && (year % 100 !== 0)) || (year % 400 === 0); }; var utils = { multiReplace : function (str, hash ) { var key; for (key in hash) { if (Object.prototype.hasOwnProperty.call(hash, key)) { var regex; if (typeof hash[key] === "function") { } else { regex = (hash[key] instanceof RegExp) ? hash[key] : new RegExp(hash[key], "g"); } str = str.replace(regex, key); } } return str; }, getDayOfYearFromWeek : function (obj) { var d, jan4, offset; obj.weekDay = (!obj.weekDay && obj.weekDay !== 0) ? 1 : obj.weekDay; d = new Date(obj.year, 0, 4); jan4 = d.getDay() === 0 ? 7 : d.getDay(); // JS is 0 indexed on Sunday. offset = jan4+3; obj.dayOfYear = ((obj.week * 7) + (obj.weekDay === 0 ? 7 : obj.weekDay))-offset; return obj; }, getDayOfYear : function (obj, dayOffset) { if (!obj.dayOfYear) { obj = utils.getDayOfYearFromWeek(obj); } for (var i=0;i <= dayOffset.length;i++) { if (obj.dayOfYear < dayOffset[i] || i === dayOffset.length) { obj.day = obj.day ? obj.day : (obj.dayOfYear - dayOffset[i-1]); break; } else { obj.month = i; } } return obj; }, adjustForTimeZone : function (obj, date) { var offset; if (obj.zone.toUpperCase() === "Z" || (obj.zone_hours === 0 && obj.zone_minutes === 0)) { // it's UTC/GML so work out the current timeszone offset offset = -date.getTimezoneOffset(); } else { offset = (obj.zone_hours*60) + (obj.zone_minutes || 0); if (obj.zone_sign === "+") { offset *= -1; } offset -= date.getTimezoneOffset(); } date.setMinutes(date.getMinutes()+offset); return date; }, setDefaults : function (obj) { obj.year = obj.year || Date.today().getFullYear(); obj.hours = obj.hours || 0; obj.minutes = obj.minutes || 0; obj.seconds = obj.seconds || 0; obj.milliseconds = obj.milliseconds || 0; if (!(!obj.month && (obj.week || obj.dayOfYear))) { // if we have a month, or if we don't but don't have the day calculation data obj.month = obj.month || 0; obj.day = obj.day || 1; } return obj; }, dataNum: function (data, mod, explict, postProcess) { var dataNum = data*1; if (mod) { if (postProcess) { return data ? mod(data)*1 : data; } else { return data ? mod(dataNum) : data; } } else if (!explict){ return data ? dataNum : data; } else { return (data && typeof data !== "undefined") ? dataNum : data; } }, timeDataProcess: function (obj) { var timeObj = {}; for (var x in obj.data) { if (obj.data.hasOwnProperty(x)) { timeObj[x] = obj.ignore[x] ? obj.data[x] : utils.dataNum(obj.data[x], obj.mods[x], obj.explict[x], obj.postProcess[x]); } } if (obj.data.secmins) { obj.data.secmins = obj.data.secmins.replace(",", ".") * 60; if (!timeObj.minutes) { timeObj.minutes = obj.data.secmins; } else if (!timeObj.seconds) { timeObj.seconds = obj.data.secmins; } delete obj.secmins; } return timeObj; }, buildTimeObjectFromData: function (data) { var time = utils.timeDataProcess({ data: { year : data[1], month : data[5], day : data[7], week : data[8], dayOfYear : data[10], hours : data[15], zone_hours : data[23], zone_minutes : data[24], zone : data[21], zone_sign : data[22], weekDay : data[9], minutes: data[16], seconds: data[19], milliseconds: data[20], secmins: data[18] }, mods: { month: function(data) { return data-1; }, weekDay: function (data) { data = Math.abs(data); return (data === 7 ? 0 : data); }, minutes: function (data) { return data.replace(":",""); }, seconds: function (data) { return Math.floor( (data.replace(":","").replace(",","."))*1 ); }, milliseconds: function (data) { return (data.replace(",",".")*1000); } }, postProcess: { minutes: true, seconds: true, milliseconds: true }, explict: { zone_hours: true, zone_minutes: true }, ignore: { zone: true, zone_sign: true, secmins: true } }); return time; }, addToHash: function (hash, keys, data) { keys = keys; data = data; var len = keys.length; for (var i = 0; i < len; i++) { hash[keys[i]] = data[i]; } return hash; }, combineRegex: function (r1, r2) { return new RegExp("(("+r1.source+")\\s("+r2.source+"))"); }, getDateNthString: function(add, last, inc){ if (add) { return Date.today().addDays(inc).toString("d"); } else if (last) { return Date.today().last()[inc]().toString("d"); } }, buildRegexData: function (array) { var arr = []; var len = array.length; for (var i=0; i < len; i++) { if (Object.prototype.toString.call(array[i]) === '[object Array]') { // oldIE compat version of Array.isArray arr.push(this.combineRegex(array[i][0], array[i][1])); } else { arr.push(array[i]); } } return arr; } }; $P.processTimeObject = function (obj) { var date, dayOffset; utils.setDefaults(obj); dayOffset = ($P.isLeapYear(obj.year)) ? dayOffsets.leap : dayOffsets.standard; if (!obj.month && (obj.week || obj.dayOfYear)) { utils.getDayOfYear(obj, dayOffset); } else { obj.dayOfYear = dayOffset[obj.month] + obj.day; } date = new Date(obj.year, obj.month, obj.day, obj.hours, obj.minutes, obj.seconds, obj.milliseconds); if (obj.zone) { utils.adjustForTimeZone(obj, date); // adjust (and calculate) for timezone } return date; }; $P.ISO = { regex : /^([\+-]?\d{4}(?!\d{2}\b))((-?)((0[1-9]|1[0-2])(\3([12]\d|0[1-9]|3[01]))?|W([0-4]\d|5[0-3])(-?[1-7])?|(00[1-9]|0[1-9]\d|[12]\d{2}|3([0-5]\d|6[1-6])))([T\s]((([01]\d|2[0-4])((:?)[0-5]\d)?|24\:?00)([\.,]\d+(?!:))?)?(\17[0-5]\d([\.,]\d+)?)?\s?([zZ]|([\+-])([01]\d|2[0-3]):?([0-5]\d)?)?)?)?$/, parse : function (s) { var time, data = s.match(this.regex); if (!data || !data.length) { return null; } time = utils.buildTimeObjectFromData(data); if (!time.year || (!time.year && (!time.month && !time.day) && (!time.week && !time.dayOfYear)) ) { return null; } return $P.processTimeObject(time); } }; $P.Numeric = { isNumeric: function (e){return!isNaN(parseFloat(e))&&isFinite(e);}, regex: /\b([0-1]?[0-9])([0-3]?[0-9])([0-2]?[0-9]?[0-9][0-9])\b/i, parse: function (s) { var data, i, time = {}, order = Date.CultureInfo.dateElementOrder.split(""); if (!(this.isNumeric(s)) || // if it's non-numeric OR (s[0] === "+" && s[0] === "-")) { // It's an arithmatic string (eg +/-1000) return null; } if (s.length < 5 && s.indexOf(".") < 0 && s.indexOf("/") < 0) { // assume it's just a year. time.year = s; return $P.processTimeObject(time); } data = s.match(this.regex); if (!data || !data.length) { return null; } for (i=0; i < order.length; i++) { switch(order[i]) { case "d": time.day = data[i+1]; break; case "m": time.month = (data[i+1]-1); break; case "y": time.year = data[i+1]; break; } } return $P.processTimeObject(time); } }; $P.Normalizer = { regexData: function () { var $R = Date.CultureInfo.regexPatterns; return utils.buildRegexData([ $R.tomorrow, $R.yesterday, [$R.past, $R.mon], [$R.past, $R.tue], [$R.past, $R.wed], [$R.past, $R.thu], [$R.past, $R.fri], [$R.past, $R.sat], [$R.past, $R.sun] ]); }, basicReplaceHash : function() { var $R = Date.CultureInfo.regexPatterns; return { "January": $R.jan.source, "February": $R.feb, "March": $R.mar, "April": $R.apr, "May": $R.may, "June": $R.jun, "July": $R.jul, "August": $R.aug, "September": $R.sep, "October": $R.oct, "November": $R.nov, "December": $R.dec, "": /\bat\b/gi, " ": /\s{2,}/, "am": $R.inTheMorning, "9am": $R.thisMorning, "pm": $R.inTheEvening, "7pm":$R.thisEvening }; }, keys : function(){ return [ utils.getDateNthString(true, false, 1), // tomorrow utils.getDateNthString(true, false, -1), // yesterday utils.getDateNthString(false, true, "monday"), //last mon utils.getDateNthString(false, true, "tuesday"), //last tues utils.getDateNthString(false, true, "wednesday"), //last wed utils.getDateNthString(false, true, "thursday"), //last thurs utils.getDateNthString(false, true, "friday"), //last fri utils.getDateNthString(false, true, "saturday"), //last sat utils.getDateNthString(false, true, "sunday") //last sun ]; }, buildRegexFunctions: function () { var $R = Date.CultureInfo.regexPatterns; var __ = Date.i18n.__; var tomorrowRE = new RegExp("(\\b\\d\\d?("+__("AM")+"|"+__("PM")+")? )("+$R.tomorrow.source.slice(1)+")", "i"); // adapted tomorrow regex for AM PM relative dates var todayRE = new RegExp($R.today.source + "(?!\\s*([+-]))\\b"); // today, but excludes the math operators (eg "today + 2h") this.replaceFuncs = [ [todayRE, function (full) { return (full.length > 1) ? Date.today().toString("d") : full; }], [tomorrowRE, function(full, m1) { var t = Date.today().addDays(1).toString("d"); return (t + " " + m1); }], [$R.amThisMorning, function(str, am){return am;}], [$R.pmThisEvening, function(str, pm){return pm;}] ]; }, buildReplaceData: function () { this.buildRegexFunctions(); this.replaceHash = utils.addToHash(this.basicReplaceHash(), this.keys(), this.regexData()); }, stringReplaceFuncs: function (s) { for (var i=0; i < this.replaceFuncs.length; i++) { s = s.replace(this.replaceFuncs[i][0], this.replaceFuncs[i][1]); } return s; }, parse: function (s) { s = this.stringReplaceFuncs(s); s = utils.multiReplace(s, this.replaceHash); try { var n = s.split(/([\s\-\.\,\/\x27]+)/); if (n.length === 3 && $P.Numeric.isNumeric(n[0]) && $P.Numeric.isNumeric(n[2]) && (n[2].length >= 4)) { // ok, so we're dealing with x/year. But that's not a full date. // This fixes wonky dateElementOrder parsing when set to dmy order. if (Date.CultureInfo.dateElementOrder[0] === "d") { s = "1/" + n[0] + "/" + n[2]; // set to 1st of month and normalize the seperator } } } catch (e) {} return s; } }; $P.Normalizer.buildReplaceData(); }()); (function () { var $P = Date.Parsing; var _ = $P.Operators = { // // Tokenizers // rtoken: function (r) { // regex token return function (s) { var mx = s.match(r); if (mx) { return ([ mx[0], s.substring(mx[0].length) ]); } else { throw new $P.Exception(s); } }; }, token: function () { // whitespace-eating token return function (s) { return _.rtoken(new RegExp("^\\s*" + s + "\\s*"))(s); }; }, stoken: function (s) { // string token return _.rtoken(new RegExp("^" + s)); }, // Atomic Operators until: function (p) { return function (s) { var qx = [], rx = null; while (s.length) { try { rx = p.call(this, s); } catch (e) { qx.push(rx[0]); s = rx[1]; continue; } break; } return [ qx, s ]; }; }, many: function (p) { return function (s) { var rx = [], r = null; while (s.length) { try { r = p.call(this, s); } catch (e) { return [ rx, s ]; } rx.push(r[0]); s = r[1]; } return [ rx, s ]; }; }, // generator operators -- see below optional: function (p) { return function (s) { var r = null; try { r = p.call(this, s); } catch (e) { return [ null, s ]; } return [ r[0], r[1] ]; }; }, not: function (p) { return function (s) { try { p.call(this, s); } catch (e) { return [null, s]; } throw new $P.Exception(s); }; }, ignore: function (p) { return p ? function (s) { var r = null; r = p.call(this, s); return [null, r[1]]; } : null; }, product: function () { var px = arguments[0], qx = Array.prototype.slice.call(arguments, 1), rx = []; for (var i = 0 ; i < px.length ; i++) { rx.push(_.each(px[i], qx)); } return rx; }, cache: function (rule) { var cache = {}, cache_length = 0, cache_keys = [], CACHE_MAX = Date.Config.CACHE_MAX || 100000, r = null; var cacheCheck = function () { if (cache_length === CACHE_MAX) { // kill several keys, don't want to have to do this all the time... for (var i=0; i < 10; i++) { var key = cache_keys.shift(); if (key) { delete cache[key]; cache_length--; } } } }; return function (s) { cacheCheck(); try { r = cache[s] = (cache[s] || rule.call(this, s)); } catch (e) { r = cache[s] = e; } cache_length++; cache_keys.push(s); if (r instanceof $P.Exception) { throw r; } else { return r; } }; }, // vector operators -- see below any: function () { var px = arguments; return function (s) { var r = null; for (var i = 0; i < px.length; i++) { if (px[i] == null) { continue; } try { r = (px[i].call(this, s)); } catch (e) { r = null; } if (r) { return r; } } throw new $P.Exception(s); }; }, each: function () { var px = arguments; return function (s) { var rx = [], r = null; for (var i = 0; i < px.length ; i++) { if (px[i] == null) { continue; } try { r = (px[i].call(this, s)); } catch (e) { throw new $P.Exception(s); } rx.push(r[0]); s = r[1]; } return [ rx, s]; }; }, all: function () { var px = arguments, _ = _; return _.each(_.optional(px)); }, // delimited operators sequence: function (px, d, c) { d = d || _.rtoken(/^\s*/); c = c || null; if (px.length === 1) { return px[0]; } return function (s) { var r = null, q = null; var rx = []; for (var i = 0; i < px.length ; i++) { try { r = px[i].call(this, s); } catch (e) { break; } rx.push(r[0]); try { q = d.call(this, r[1]); } catch (ex) { q = null; break; } s = q[1]; } if (!r) { throw new $P.Exception(s); } if (q) { throw new $P.Exception(q[1]); } if (c) { try { r = c.call(this, r[1]); } catch (ey) { throw new $P.Exception(r[1]); } } return [ rx, (r?r[1]:s) ]; }; }, // // Composite Operators // between: function (d1, p, d2) { d2 = d2 || d1; var _fn = _.each(_.ignore(d1), p, _.ignore(d2)); return function (s) { var rx = _fn.call(this, s); return [[rx[0][0], r[0][2]], rx[1]]; }; }, list: function (p, d, c) { d = d || _.rtoken(/^\s*/); c = c || null; return (p instanceof Array ? _.each(_.product(p.slice(0, -1), _.ignore(d)), p.slice(-1), _.ignore(c)) : _.each(_.many(_.each(p, _.ignore(d))), px, _.ignore(c))); }, set: function (px, d, c) { d = d || _.rtoken(/^\s*/); c = c || null; return function (s) { // r is the current match, best the current 'best' match // which means it parsed the most amount of input var r = null, p = null, q = null, rx = null, best = [[], s], last = false; // go through the rules in the given set for (var i = 0; i < px.length ; i++) { // last is a flag indicating whether this must be the last element // if there is only 1 element, then it MUST be the last one q = null; p = null; r = null; last = (px.length === 1); // first, we try simply to match the current pattern // if not, try the next pattern try { r = px[i].call(this, s); } catch (e) { continue; } // since we are matching against a set of elements, the first // thing to do is to add r[0] to matched elements rx = [[r[0]], r[1]]; // if we matched and there is still input to parse and // we don't already know this is the last element, // we're going to next check for the delimiter ... // if there's none, or if there's no input left to parse // than this must be the last element after all ... if (r[1].length > 0 && ! last) { try { q = d.call(this, r[1]); } catch (ex) { last = true; } } else { last = true; } // if we parsed the delimiter and now there's no more input, // that means we shouldn't have parsed the delimiter at all // so don't update r and mark this as the last element ... if (!last && q[1].length === 0) { last = true; } // so, if this isn't the last element, we're going to see if // we can get any more matches from the remaining (unmatched) // elements ... if (!last) { // build a list of the remaining rules we can match against, // i.e., all but the one we just matched against var qx = []; for (var j = 0; j < px.length ; j++) { if (i !== j) { qx.push(px[j]); } } // now invoke recursively set with the remaining input // note that we don't include the closing delimiter ... // we'll check for that ourselves at the end p = _.set(qx, d).call(this, q[1]); // if we got a non-empty set as a result ... // (otw rx already contains everything we want to match) if (p[0].length > 0) { // update current result, which is stored in rx ... // basically, pick up the remaining text from p[1] // and concat the result from p[0] so that we don't // get endless nesting ... rx[0] = rx[0].concat(p[0]); rx[1] = p[1]; } } // at this point, rx either contains the last matched element // or the entire matched set that starts with this element. // now we just check to see if this variation is better than // our best so far, in terms of how much of the input is parsed if (rx[1].length < best[1].length) { best = rx; } // if we've parsed all the input, then we're finished if (best[1].length === 0) { break; } } // so now we've either gone through all the patterns trying them // as the initial match; or we found one that parsed the entire // input string ... // if best has no matches, just return empty set ... if (best[0].length === 0) { return best; } // if a closing delimiter is provided, then we have to check it also if (c) { // we try this even if there is no remaining input because the pattern // may well be optional or match empty input ... try { q = c.call(this, best[1]); } catch (ey) { throw new $P.Exception(best[1]); } // it parsed ... be sure to update the best match remaining input best[1] = q[1]; } // if we're here, either there was no closing delimiter or we parsed it // so now we have the best match; just return it! return best; }; }, forward: function (gr, fname) { return function (s) { return gr[fname].call(this, s); }; }, // // Translation Operators // replace: function (rule, repl) { return function (s) { var r = rule.call(this, s); return [repl, r[1]]; }; }, process: function (rule, fn) { return function (s) { var r = rule.call(this, s); return [fn.call(this, r[0]), r[1]]; }; }, min: function (min, rule) { return function (s) { var rx = rule.call(this, s); if (rx[0].length < min) { throw new $P.Exception(s); } return rx; }; } }; // Generator Operators And Vector Operators // Generators are operators that have a signature of F(R) => R, // taking a given rule and returning another rule, such as // ignore, which parses a given rule and throws away the result. // Vector operators are those that have a signature of F(R1,R2,...) => R, // take a list of rules and returning a new rule, such as each. // Generator operators are converted (via the following _generator // function) into functions that can also take a list or array of rules // and return an array of new rules as though the function had been // called on each rule in turn (which is what actually happens). // This allows generators to be used with vector operators more easily. // Example: // each(ignore(foo, bar)) instead of each(ignore(foo), ignore(bar)) // This also turns generators into vector operators, which allows // constructs like: // not(cache(foo, bar)) var _generator = function (op) { function gen() { var args = null, rx = [], px, i; if (arguments.length > 1) { args = Array.prototype.slice.call(arguments); } else if (arguments[0] instanceof Array) { args = arguments[0]; } if (args) { px = args.shift(); if (px.length > 0) { args.unshift(px[i]); rx.push(op.apply(null, args)); args.shift(); return rx; } } else { return op.apply(null, arguments); } } return gen; }; var gx = "optional not ignore cache".split(/\s/); for (var i = 0 ; i < gx.length ; i++) { _[gx[i]] = _generator(_[gx[i]]); } var _vector = function (op) { return function () { if (arguments[0] instanceof Array) { return op.apply(null, arguments[0]); } else { return op.apply(null, arguments); } }; }; var vx = "each any all".split(/\s/); for (var j = 0 ; j < vx.length ; j++) { _[vx[j]] = _vector(_[vx[j]]); } }()); (function () { var $D = Date; var flattenAndCompact = function (ax) { var rx = []; for (var i = 0; i < ax.length; i++) { if (ax[i] instanceof Array) { rx = rx.concat(flattenAndCompact(ax[i])); } else { if (ax[i]) { rx.push(ax[i]); } } } return rx; }; var parseMeridian = function () { if (this.meridian && (this.hour || this.hour === 0)) { if (this.meridian === "a" && this.hour > 11 && Date.Config.strict24hr){ throw "Invalid hour and meridian combination"; } else if (this.meridian === "p" && this.hour < 12 && Date.Config.strict24hr){ throw "Invalid hour and meridian combination"; } else if (this.meridian === "p" && this.hour < 12) { this.hour = this.hour + 12; } else if (this.meridian === "a" && this.hour === 12) { this.hour = 0; } } }; var setDefaults = function () { var now = new Date(); if ((this.hour || this.minute) && (!this.month && !this.year && !this.day)) { this.day = now.getDate(); } if (!this.year) { this.year = now.getFullYear(); } if (!this.month && this.month !== 0) { this.month = now.getMonth(); } if (!this.day) { this.day = 1; } if (!this.hour) { this.hour = 0; } if (!this.minute) { this.minute = 0; } if (!this.second) { this.second = 0; } if (!this.millisecond) { this.millisecond = 0; } }; var finishUtils = { getToday: function () { if (this.now || "hour minute second".indexOf(this.unit) !== -1) { return new Date(); } else { return $D.today(); } }, setDaysFromWeekday: function (today, orient){ var gap; orient = orient || 1; this.unit = "day"; gap = ($D.getDayNumberFromName(this.weekday) - today.getDay()); this.days = gap ? ((gap + (orient * 7)) % 7) : (orient * 7); return this; }, setMonthsFromMonth: function (today, orient) { var gap; orient = orient || 1; this.unit = "month"; gap = (this.month - today.getMonth()); this.months = gap ? ((gap + (orient * 12)) % 12) : (orient * 12); this.month = null; return this; }, setDMYFromWeekday: function () { var d = Date[this.weekday](); this.day = d.getDate(); if (!this.month) { this.month = d.getMonth(); } this.year = d.getFullYear(); return this; }, setUnitValue: function (orient) { if (!this.value && this.operator && this.operator !== null && this[this.unit + "s"] && this[this.unit + "s"] !== null) { this[this.unit + "s"] = this[this.unit + "s"] + ((this.operator === "add") ? 1 : -1) + (this.value||0) * orient; } else if (this[this.unit + "s"] == null || this.operator != null) { if (!this.value) { this.value = 1; } this[this.unit + "s"] = this.value * orient; } }, generateDateFromWeeks: function () { var weekday = (this.weekday !== undefined) ? this.weekday : "today"; var d = Date[weekday]().addWeeks(this.weeks); if (this.now) { d.setTimeToNow(); } return d; } }; $D.Translator = { hour: function (s) { return function () { this.hour = Number(s); }; }, minute: function (s) { return function () { this.minute = Number(s); }; }, second: function (s) { return function () { this.second = Number(s); }; }, /* for ss.s format */ secondAndMillisecond: function (s) { return function () { var mx = s.match(/^([0-5][0-9])\.([0-9]{1,3})/); this.second = Number(mx[1]); this.millisecond = Number(mx[2]); }; }, meridian: function (s) { return function () { this.meridian = s.slice(0, 1).toLowerCase(); }; }, timezone: function (s) { return function () { var n = s.replace(/[^\d\+\-]/g, ""); if (n.length) { this.timezoneOffset = Number(n); } else { this.timezone = s.toLowerCase(); } }; }, day: function (x) { var s = x[0]; return function () { this.day = Number(s.match(/\d+/)[0]); if (this.day < 1) { throw "invalid day"; } }; }, month: function (s) { return function () { this.month = (s.length === 3) ? "jan feb mar apr may jun jul aug sep oct nov dec".indexOf(s)/4 : Number(s) - 1; if (this.month < 0) { throw "invalid month"; } }; }, year: function (s) { return function () { var n = Number(s); this.year = ((s.length > 2) ? n : (n + (((n + 2000) < Date.CultureInfo.twoDigitYearMax) ? 2000 : 1900))); }; }, rday: function (s) { return function () { switch (s) { case "yesterday": this.days = -1; break; case "tomorrow": this.days = 1; break; case "today": this.days = 0; break; case "now": this.days = 0; this.now = true; break; } }; }, finishExact: function (x) { var d; x = (x instanceof Array) ? x : [x]; for (var i = 0 ; i < x.length ; i++) { if (x[i]) { x[i].call(this); } } setDefaults.call(this); parseMeridian.call(this); if (this.day > $D.getDaysInMonth(this.year, this.month)) { throw new RangeError(this.day + " is not a valid value for days."); } d = new Date(this.year, this.month, this.day, this.hour, this.minute, this.second, this.millisecond); if (this.year < 100) { d.setFullYear(this.year); // means years less that 100 are process correctly. JS will parse it otherwise as 1900-1999. } if (this.timezone) { d.set({ timezone: this.timezone }); } else if (this.timezoneOffset) { d.set({ timezoneOffset: this.timezoneOffset }); } return d; }, finish: function (x) { var today, expression, orient, temp; x = (x instanceof Array) ? flattenAndCompact(x) : [ x ]; if (x.length === 0) { return null; } for (var i = 0 ; i < x.length ; i++) { if (typeof x[i] === "function") { x[i].call(this); } } if (this.now && !this.unit && !this.operator) { return new Date(); } else { today = finishUtils.getToday.call(this); } expression = !!(this.days && this.days !== null || this.orient || this.operator); orient = ((this.orient === "past" || this.operator === "subtract") ? -1 : 1); if (this.month && this.unit === "week") { this.value = this.month + 1; delete this.month; delete this.day; } if ((this.month || this.month === 0) && "year day hour minute second".indexOf(this.unit) !== -1) { if (!this.value) { this.value = this.month + 1; } this.month = null; expression = true; } if (!expression && this.weekday && !this.day && !this.days) { finishUtils.setDMYFromWeekday.call(this); } if (expression && this.weekday && this.unit !== "month" && this.unit !== "week") { finishUtils.setDaysFromWeekday.call(this, today, orient); } if (this.weekday && this.unit !== "week" && !this.day && !this.days) { temp = Date[this.weekday](); this.day = temp.getDate(); if (temp.getMonth() !== today.getMonth()) { this.month = temp.getMonth(); } } if (this.month && this.unit === "day" && this.operator) { if (!this.value) { this.value = (this.month + 1); } this.month = null; } if (this.value != null && this.month != null && this.year != null) { this.day = this.value * 1; } if (this.month && !this.day && this.value) { today.set({ day: this.value * 1 }); if (!expression) { this.day = this.value * 1; } } if (!this.month && this.value && this.unit === "month" && !this.now) { this.month = this.value; expression = true; } if (expression && (this.month || this.month === 0) && this.unit !== "year") { finishUtils.setMonthsFromMonth.call(this, today, orient); } if (!this.unit) { this.unit = "day"; } finishUtils.setUnitValue.call(this, orient); parseMeridian.call(this); if ((this.month || this.month === 0) && !this.day) { this.day = 1; } if (!this.orient && !this.operator && this.unit === "week" && this.value && !this.day && !this.month) { return Date.today().setWeek(this.value); } if (this.unit === "week" && this.weeks && !this.day && !this.month) { return finishUtils.generateDateFromWeeks.call(this); } if (expression && this.timezone && this.day && this.days) { this.day = this.days; } if (expression){ today.add(this); } else { today.set(this); } if (this.timezone) { this.timezone = this.timezone.toUpperCase(); var offset = $D.getTimezoneOffset(this.timezone); var timezone; if (today.hasDaylightSavingTime()) { // lets check that we're being sane with timezone setting timezone = $D.getTimezoneAbbreviation(offset, today.isDaylightSavingTime()); if (timezone !== this.timezone) { // bugger, we're in a place where things like EST vs EDT matters. if (today.isDaylightSavingTime()) { today.addHours(-1); } else { today.addHours(1); } } } today.setTimezoneOffset(offset); } return today; } }; }()); (function () { var $D = Date; $D.Grammar = {}; var _ = $D.Parsing.Operators, g = $D.Grammar, t = $D.Translator, _fn; // Allow rolling up into general purpose rules _fn = function () { return _.each(_.any.apply(null, arguments), _.not(g.ctoken2("timeContext"))); }; g.datePartDelimiter = _.rtoken(/^([\s\-\.\,\/\x27]+)/); g.timePartDelimiter = _.stoken(":"); g.whiteSpace = _.rtoken(/^\s*/); g.generalDelimiter = _.rtoken(/^(([\s\,]|at|@|on)+)/); var _C = {}; g.ctoken = function (keys) { var fn = _C[keys]; if (! fn) { var c = Date.CultureInfo.regexPatterns; var kx = keys.split(/\s+/), px = []; for (var i = 0; i < kx.length ; i++) { px.push(_.replace(_.rtoken(c[kx[i]]), kx[i])); } fn = _C[keys] = _.any.apply(null, px); } return fn; }; g.ctoken2 = function (key) { return _.rtoken(Date.CultureInfo.regexPatterns[key]); }; var cacheProcessRtoken = function (key, token, type, eachToken) { if (eachToken) { g[key] = _.cache(_.process(_.each(_.rtoken(token),_.optional(g.ctoken2(eachToken))), type)); } else { g[key] = _.cache(_.process(_.rtoken(token), type)); } }; var cacheProcessCtoken = function (token, type) { return _.cache(_.process(g.ctoken2(token), type)); }; var _F = {}; //function cache var _get = function (f) { _F[f] = (_F[f] || g.format(f)[0]); return _F[f]; }; g.allformats = function (fx) { var rx = []; if (fx instanceof Array) { for (var i = 0; i < fx.length; i++) { rx.push(_get(fx[i])); } } else { rx.push(_get(fx)); } return rx; }; g.formats = function (fx) { if (fx instanceof Array) { var rx = []; for (var i = 0 ; i < fx.length ; i++) { rx.push(_get(fx[i])); } return _.any.apply(null, rx); } else { return _get(fx); } }; var grammarFormats = { timeFormats: function(){ var i, RTokenKeys = [ "h", "hh", "H", "HH", "m", "mm", "s", "ss", "ss.s", "z", "zz" ], RToken = [ /^(0[0-9]|1[0-2]|[1-9])/, /^(0[0-9]|1[0-2])/, /^([0-1][0-9]|2[0-3]|[0-9])/, /^([0-1][0-9]|2[0-3])/, /^([0-5][0-9]|[0-9])/, /^[0-5][0-9]/, /^([0-5][0-9]|[0-9])/, /^[0-5][0-9]/, /^[0-5][0-9]\.[0-9]{1,3}/, /^((\+|\-)\s*\d\d\d\d)|((\+|\-)\d\d\:?\d\d)/, /^((\+|\-)\s*\d\d\d\d)|((\+|\-)\d\d\:?\d\d)/ ], tokens = [ t.hour, t.hour, t.hour, t.hour, t.minute, t.minute, t.second, t.second, t.secondAndMillisecond, t.timezone, t.timezone ]; for (i=0; i < RTokenKeys.length; i++) { cacheProcessRtoken(RTokenKeys[i], RToken[i], tokens[i]); } g.hms = _.cache(_.sequence([g.H, g.m, g.s], g.timePartDelimiter)); g.t = cacheProcessCtoken("shortMeridian", t.meridian); g.tt = cacheProcessCtoken("longMeridian", t.meridian); g.zzz = cacheProcessCtoken("timezone", t.timezone); g.timeSuffix = _.each(_.ignore(g.whiteSpace), _.set([ g.tt, g.zzz ])); g.time = _.each(_.optional(_.ignore(_.stoken("T"))), g.hms, g.timeSuffix); }, dateFormats: function () { // pre-loaded rules for different date part order preferences var _setfn = function () { return _.set(arguments, g.datePartDelimiter); }; var i, RTokenKeys = [ "d", "dd", "M", "MM", "y", "yy", "yyy", "yyyy" ], RToken = [ /^([0-2]\d|3[0-1]|\d)/, /^([0-2]\d|3[0-1])/, /^(1[0-2]|0\d|\d)/, /^(1[0-2]|0\d)/, /^(\d+)/, /^(\d\d)/, /^(\d\d?\d?\d?)/, /^(\d\d\d\d)/ ], tokens = [ t.day, t.day, t.month, t.month, t.year, t.year, t.year, t.year ], eachToken = [ "ordinalSuffix", "ordinalSuffix" ]; for (i=0; i < RTokenKeys.length; i++) { cacheProcessRtoken(RTokenKeys[i], RToken[i], tokens[i], eachToken[i]); } g.MMM = g.MMMM = _.cache(_.process(g.ctoken("jan feb mar apr may jun jul aug sep oct nov dec"), t.month)); g.ddd = g.dddd = _.cache(_.process(g.ctoken("sun mon tue wed thu fri sat"), function (s) { return function () { this.weekday = s; }; } )); g.day = _fn(g.d, g.dd); g.month = _fn(g.M, g.MMM); g.year = _fn(g.yyyy, g.yy); g.mdy = _setfn(g.ddd, g.month, g.day, g.year); g.ymd = _setfn(g.ddd, g.year, g.month, g.day); g.dmy = _setfn(g.ddd, g.day, g.month, g.year); g.date = function (s) { return ((g[Date.CultureInfo.dateElementOrder] || g.mdy).call(this, s)); }; }, relative: function () { // relative date / time expressions g.orientation = _.process(g.ctoken("past future"), function (s) { return function () { this.orient = s; }; } ); g.operator = _.process(g.ctoken("add subtract"), function (s) { return function () { this.operator = s; }; } ); g.rday = _.process(g.ctoken("yesterday tomorrow today now"), t.rday); g.unit = _.process(g.ctoken("second minute hour day week month year"), function (s) { return function () { this.unit = s; }; } ); } }; g.buildGrammarFormats = function () { // these need to be rebuilt every time the language changes. _C = {}; grammarFormats.timeFormats(); grammarFormats.dateFormats(); grammarFormats.relative(); g.value = _.process(_.rtoken(/^([-+]?\d+)?(st|nd|rd|th)?/), function (s) { return function () { this.value = s.replace(/\D/g, ""); }; } ); g.expression = _.set([g.rday, g.operator, g.value, g.unit, g.orientation, g.ddd, g.MMM ]); g.format = _.process(_.many( _.any( // translate format specifiers into grammar rules _.process( _.rtoken(/^(dd?d?d?(?!e)|MM?M?M?|yy?y?y?|hh?|HH?|mm?|ss?|tt?|zz?z?)/), function (fmt) { if (g[fmt]) { return g[fmt]; } else { throw $D.Parsing.Exception(fmt); } } ), // translate separator tokens into token rules _.process(_.rtoken(/^[^dMyhHmstz]+/), // all legal separators function (s) { return _.ignore(_.stoken(s)); } ) ) ), // construct the parser ... function (rules) { return _.process(_.each.apply(null, rules), t.finishExact); } ); // starting rule for general purpose grammar g._start = _.process(_.set([ g.date, g.time, g.expression ], g.generalDelimiter, g.whiteSpace), t.finish); }; g.buildGrammarFormats(); // parsing date format specifiers - ex: "h:m:s tt" // this little guy will generate a custom parser based // on the format string, ex: g.format("h:m:s tt") // check for these formats first g._formats = g.formats([ "\"yyyy-MM-ddTHH:mm:ssZ\"", "yyyy-MM-ddTHH:mm:ss.sz", "yyyy-MM-ddTHH:mm:ssZ", "yyyy-MM-ddTHH:mm:ssz", "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-ddTHH:mmZ", "yyyy-MM-ddTHH:mmz", "yyyy-MM-ddTHH:mm", "ddd, MMM dd, yyyy H:mm:ss tt", "ddd MMM d yyyy HH:mm:ss zzz", "MMddyyyy", "ddMMyyyy", "Mddyyyy", "ddMyyyy", "Mdyyyy", "dMyyyy", "yyyy", "Mdyy", "dMyy", "d" ]); // real starting rule: tries selected formats first, // then general purpose rule g.start = function (s) { try { var r = g._formats.call({}, s); if (r[1].length === 0) { return r; } } catch (e) {} return g._start.call({}, s); }; }()); (function () { var $D = Date; /** * @desc Converts the specified string value into its JavaScript Date equivalent using CultureInfo specific format information. * * Example

	///////////
	// Dates //
	///////////

	// 15-Oct-2004
	var d1 = Date.parse("10/15/2004");

	// 15-Oct-2004
	var d1 = Date.parse("15-Oct-2004");

	// 15-Oct-2004
	var d1 = Date.parse("2004.10.15");

	//Fri Oct 15, 2004
	var d1 = Date.parse("Fri Oct 15, 2004");

	///////////
	// Times //
	///////////

	// Today at 10 PM.
	var d1 = Date.parse("10 PM");

	// Today at 10:30 PM.
	var d1 = Date.parse("10:30 P.M.");

	// Today at 6 AM.
	var d1 = Date.parse("06am");

	/////////////////////
	// Dates and Times //
	/////////////////////

	// 8-July-2004 @ 10:30 PM
	var d1 = Date.parse("July 8th, 2004, 10:30 PM");

	// 1-July-2004 @ 10:30 PM
	var d1 = Date.parse("2004-07-01T22:30:00");

	////////////////////
	// Relative Dates //
	////////////////////

	// Returns today's date. The string "today" is culture specific.
	var d1 = Date.parse("today");

	// Returns yesterday's date. The string "yesterday" is culture specific.
	var d1 = Date.parse("yesterday");

	// Returns the date of the next thursday.
	var d1 = Date.parse("Next thursday");

	// Returns the date of the most previous monday.
	var d1 = Date.parse("last monday");

	// Returns today's day + one year.
	var d1 = Date.parse("next year");

	///////////////
	// Date Math //
	///////////////

	// Today + 2 days
	var d1 = Date.parse("t+2");

	// Today + 2 days
	var d1 = Date.parse("today + 2 days");

	// Today + 3 months
	var d1 = Date.parse("t+3m");

	// Today - 1 year
	var d1 = Date.parse("today - 1 year");

	// Today - 1 year
	var d1 = Date.parse("t-1y"); 


	/////////////////////////////
	// Partial Dates and Times //
	/////////////////////////////

	// July 15th of this year.
	var d1 = Date.parse("July 15");

	// 15th day of current day and year.
	var d1 = Date.parse("15");

	// July 1st of current year at 10pm.
	var d1 = Date.parse("7/1 10pm");
	
* * @param {String} The string value to convert into a Date object [Required] * @return {Date} A Date object or null if the string cannot be converted into a Date. */ var parseUtils = { removeOrds: function (s) { ords = s.match(/\b(\d+)(?:st|nd|rd|th)\b/); // find ordinal matches s = ((ords && ords.length === 2) ? s.replace(ords[0], ords[1]) : s); return s; }, grammarParser: function (s) { var r = null; try { r = $D.Grammar.start.call({}, s.replace(/^\s*(\S*(\s+\S+)*)\s*$/, "$1")); } catch (e) { return null; } return ((r[1].length === 0) ? r[0] : null); }, nativeFallback: function(s) { var t; try { // ok we haven't parsed it, last ditch attempt with the built-in parser. t = Date._parse(s); return (t || t === 0) ? new Date(t) : null; } catch (e) { return null; } } }; function parse (s) { var d; if (!s) { return null; } if (s instanceof Date) { return s.clone(); } if (s.length >= 4 && s.charAt(0) !== "0" && s.charAt(0) !== "+"&& s.charAt(0) !== "-") { // ie: 2004 will pass, 0800 won't. // Start with specific formats d = $D.Parsing.ISO.parse(s) || $D.Parsing.Numeric.parse(s); } if (d instanceof Date && !isNaN(d.getTime())) { return d; } else { // find ordinal dates (1st, 3rd, 8th, etc and remove them as they cause parsing issues) s = $D.Parsing.Normalizer.parse(parseUtils.removeOrds(s)); d = parseUtils.grammarParser(s); if (d !== null) { return d; } else { return parseUtils.nativeFallback(s); } } } if (!$D._parse) { $D._parse = $D.parse; } $D.parse = parse; Date.getParseFunction = function (fx) { var fns = Date.Grammar.allformats(fx); return function (s) { var r = null; for (var i = 0; i < fns.length; i++) { try { r = fns[i].call({}, s); } catch (e) { continue; } if (r[1].length === 0) { return r[0]; } } return null; }; }; /** * Converts the specified string value into its JavaScript Date equivalent using the specified format {String} or formats {Array} and the CultureInfo specific format information. * The format of the string value must match one of the supplied formats exactly. * * Example

	// 15-Oct-2004
	var d1 = Date.parseExact("10/15/2004", "M/d/yyyy");

	// 15-Oct-2004
	var d1 = Date.parse("15-Oct-2004", "M-ddd-yyyy");

	// 15-Oct-2004
	var d1 = Date.parse("2004.10.15", "yyyy.MM.dd");

	// Multiple formats
	var d1 = Date.parseExact("10/15/2004", ["M/d/yyyy", "MMMM d, yyyy"]);
	
* * @param {String} The string value to convert into a Date object [Required]. * @param {Object} The expected format {String} or an array of expected formats {Array} of the date string [Required]. * @return {Date} A Date object or null if the string cannot be converted into a Date. */ $D.parseExact = function (s, fx) { return $D.getParseFunction(fx)(s); }; }()); (function () { var $D = Date, $P = $D.prototype, // $C = $D.CultureInfo, // not used atm p = function (s, l) { if (!l) { l = 2; } return ("000" + s).slice(l * -1); }; /** * Converts a PHP format string to Java/.NET format string. * A PHP format string can be used with ._format or .format. * A Java/.NET format string can be used with .toString(). * The .parseExact function will only accept a Java/.NET format string * * Example * var f1 = "%m/%d/%y" * var f2 = Date.normalizeFormat(f1); // "MM/dd/yy" * * new Date().format(f1); // "04/13/08" * new Date()._format(f1); // "04/13/08" * new Date().toString(f2); // "04/13/08" * * var date = Date.parseExact("04/13/08", f2); // Sun Apr 13 2008 * * @param {String} A PHP format string consisting of one or more format spcifiers. * @return {String} The PHP format converted to a Java/.NET format string. */ var normalizerSubstitutions = { "d" : "dd", "%d": "dd", "D" : "ddd", "%a": "ddd", "j" : "dddd", "l" : "dddd", "%A": "dddd", "S" : "S", "F" : "MMMM", "%B": "MMMM", "m" : "MM", "%m": "MM", "M" : "MMM", "%b": "MMM", "%h": "MMM", "n" : "M", "Y" : "yyyy", "%Y": "yyyy", "y" : "yy", "%y": "yy", "g" : "h", "%I": "h", "G" : "H", "h" : "hh", "H" : "HH", "%H": "HH", "i" : "mm", "%M": "mm", "s" : "ss", "%S": "ss", "%r": "hh:mm tt", "%R": "H:mm", "%T": "H:mm:ss", "%X": "t", "%x": "d", "%e": "d", "%D": "MM/dd/yy", "%n": "\\n", "%t": "\\t", "e" : "z", "T" : "z", "%z": "z", "%Z": "z", "Z" : "ZZ", "N" : "u", "w" : "u", "%w": "u", "W" : "W", "%V": "W" }; var normalizer = { substitutes: function (m) { return normalizerSubstitutions[m]; }, interpreted: function (m, x) { var y; switch (m) { case "%u": return x.getDay() + 1; case "z": return x.getOrdinalNumber(); case "%j": return p(x.getOrdinalNumber(), 3); case "%U": var d1 = x.clone().set({month: 0, day: 1}).addDays(-1).moveToDayOfWeek(0), d2 = x.clone().addDays(1).moveToDayOfWeek(0, -1); return (d2 < d1) ? "00" : p((d2.getOrdinalNumber() - d1.getOrdinalNumber()) / 7 + 1); case "%W": return p(x.getWeek()); case "t": return $D.getDaysInMonth(x.getFullYear(), x.getMonth()); case "o": case "%G": return x.setWeek(x.getISOWeek()).toString("yyyy"); case "%g": return x._format("%G").slice(-2); case "a": case "%p": return t("tt").toLowerCase(); case "A": return t("tt").toUpperCase(); case "u": return p(x.getMilliseconds(), 3); case "I": return (x.isDaylightSavingTime()) ? 1 : 0; case "O": return x.getUTCOffset(); case "P": y = x.getUTCOffset(); return y.substring(0, y.length - 2) + ":" + y.substring(y.length - 2); case "B": var now = new Date(); return Math.floor(((now.getHours() * 3600) + (now.getMinutes() * 60) + now.getSeconds() + (now.getTimezoneOffset() + 60) * 60) / 86.4); case "c": return x.toISOString().replace(/\"/g, ""); case "U": return $D.strtotime("now"); case "%c": return t("d") + " " + t("t"); case "%C": return Math.floor(x.getFullYear() / 100 + 1); } }, shouldOverrideDefaults: function (m) { switch (m) { case "%e": return true; default: return false; } }, parse: function (m, context) { var formatString, c = context || new Date(); formatString = normalizer.substitutes(m); if (formatString) { return formatString; } formatString = normalizer.interpreted(m, c); if (formatString) { return formatString; } else { return m; } } }; $D.normalizeFormat = function (format, context) { return format.replace(/(%|\\)?.|%%/g, function(t){ return normalizer.parse(t, context); }); }; /** * Format a local Unix timestamp according to locale settings * * Example: * Date.strftime("%m/%d/%y", new Date()); // "04/13/08" * Date.strftime("c", "2008-04-13T17:52:03Z"); // "04/13/08" * * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @param {Number|String} The number representing the number of seconds that have elapsed since January 1, 1970 (local time). * @return {String} A string representation of the current Date object. */ $D.strftime = function (format, time) { var d = Date.parse(time); return d._format(format); }; /** * Parse any textual datetime description into a Unix timestamp. * A Unix timestamp is the number of seconds that have elapsed since January 1, 1970 (midnight UTC/GMT). * * Example: * Date.strtotime("04/13/08"); // 1208044800 * Date.strtotime("1970-01-01T00:00:00Z"); // 0 * * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @param {Object} A string or date object. * @return {String} A string representation of the current Date object. */ $D.strtotime = function (time) { var d = $D.parse(time); return Math.round($D.UTC(d.getUTCFullYear(), d.getUTCMonth(), d.getUTCDate(), d.getUTCHours(), d.getUTCMinutes(), d.getUTCSeconds(), d.getUTCMilliseconds()) / 1000); }; /** * Converts the value of the current Date object to its equivalent string representation using a PHP/Unix style of date format specifiers. * Format Specifiers * Format Description Example * ------ --------------------------------------------------------------------------- ----------------------- * %a abbreviated weekday name according to the current localed "Mon" through "Sun" * %A full weekday name according to the current localed "Sunday" through "Saturday" * %b abbreviated month name according to the current localed "Jan" through "Dec" * %B full month name according to the current locale "January" through "December" * %c preferred date and time representation for the current locale "4/13/2008 12:33 PM" * %C century number (the year divided by 100 and truncated to an integer) "00" to "99" * %d day of the month as a decimal number "01" to "31" * %D same as %m/%d/%y "04/13/08" * %e day of the month as a decimal number, a single digit is preceded by a space "1" to "31" * %g like %G, but without the century "08" * %G The 4-digit year corresponding to the ISO week number (see %V). "2008" * This has the same format and value as %Y, except that if the ISO week number * belongs to the previous or next year, that year is used instead. * %h same as %b "Jan" through "Dec" * %H hour as a decimal number using a 24-hour clock. "00" to "23" * %I hour as a decimal number using a 12-hour clock. "01" to "12" * %j day of the year as a decimal number. "001" to "366" * %m month as a decimal number. "01" to "12" * %M minute as a decimal number. "00" to "59" * %n newline character "\n" * %p either "am" or "pm" according to the given time value, or the "am" or "pm" * corresponding strings for the current locale. * %r time in a.m. and p.m. notation "8:44 PM" * %R time in 24 hour notation "20:44" * %S second as a decimal number "00" to "59" * %t tab character "\t" * %T current time, equal to %H:%M:%S "12:49:11" * %u weekday as a decimal number ["1", "7"], with "1" representing Monday "1" to "7" * %U week number of the current year as a decimal number, starting with the "0" to ("52" or "53") * first Sunday as the first day of the first week * %V The ISO 8601:1988 week number of the current year as a decimal number, "00" to ("52" or "53") * range 01 to 53, where week 1 is the first week that has at least 4 days * in the current year, and with Monday as the first day of the week. * (Use %G or %g for the year component that corresponds to the week number * for the specified timestamp.) * %W week number of the current year as a decimal number, starting with the "00" to ("52" or "53") * first Monday as the first day of the first week * %w day of the week as a decimal, Sunday being "0" "0" to "6" * %x preferred date representation for the current locale without the time "4/13/2008" * %X preferred time representation for the current locale without the date "12:53:05" * %y year as a decimal number without a century "00" "99" * %Y year as a decimal number including the century "2008" * %Z time zone or name or abbreviation "UTC", "EST", "PST" * %z same as %Z * %% a literal "%" characters "%" * d Day of the month, 2 digits with leading zeros "01" to "31" * D A textual representation of a day, three letters "Mon" through "Sun" * j Day of the month without leading zeros "1" to "31" * l A full textual representation of the day of the week (lowercase "L") "Sunday" through "Saturday" * N ISO-8601 numeric representation of the day of the week (added in PHP 5.1.0) "1" (for Monday) through "7" (for Sunday) * S English ordinal suffix for the day of the month, 2 characters "st", "nd", "rd" or "th". Works well with j * w Numeric representation of the day of the week "0" (for Sunday) through "6" (for Saturday) * z The day of the year (starting from "0") "0" through "365" * W ISO-8601 week number of year, weeks starting on Monday "00" to ("52" or "53") * F A full textual representation of a month, such as January or March "January" through "December" * m Numeric representation of a month, with leading zeros "01" through "12" * M A short textual representation of a month, three letters "Jan" through "Dec" * n Numeric representation of a month, without leading zeros "1" through "12" * t Number of days in the given month "28" through "31" * L Whether it's a leap year "1" if it is a leap year, "0" otherwise * o ISO-8601 year number. This has the same value as Y, except that if the "2008" * ISO week number (W) belongs to the previous or next year, that year * is used instead. * Y A full numeric representation of a year, 4 digits "2008" * y A two digit representation of a year "08" * a Lowercase Ante meridiem and Post meridiem "am" or "pm" * A Uppercase Ante meridiem and Post meridiem "AM" or "PM" * B Swatch Internet time "000" through "999" * g 12-hour format of an hour without leading zeros "1" through "12" * G 24-hour format of an hour without leading zeros "0" through "23" * h 12-hour format of an hour with leading zeros "01" through "12" * H 24-hour format of an hour with leading zeros "00" through "23" * i Minutes with leading zeros "00" to "59" * s Seconds, with leading zeros "00" through "59" * u Milliseconds "54321" * e Timezone identifier "UTC", "EST", "PST" * I Whether or not the date is in daylight saving time (uppercase i) "1" if Daylight Saving Time, "0" otherwise * O Difference to Greenwich time (GMT) in hours "+0200", "-0600" * P Difference to Greenwich time (GMT) with colon between hours and minutes "+02:00", "-06:00" * T Timezone abbreviation "UTC", "EST", "PST" * Z Timezone offset in seconds. The offset for timezones west of UTC is "-43200" through "50400" * always negative, and for those east of UTC is always positive. * c ISO 8601 date "2004-02-12T15:19:21+00:00" * r RFC 2822 formatted date "Thu, 21 Dec 2000 16:01:07 +0200" * U Seconds since the Unix Epoch (January 1 1970 00:00:00 GMT) "0" * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @return {String} A string representation of the current Date object. */ var formatReplace = function (context) { return function (m) { var formatString, override = false; if (m.charAt(0) === "\\" || m.substring(0, 2) === "%%") { return m.replace("\\", "").replace("%%", "%"); } override = normalizer.shouldOverrideDefaults(m); formatString = $D.normalizeFormat(m, context); if (formatString) { return context.toString(formatString, override); } }; }; $P._format = function (format) { var formatter = formatReplace(this); if (!format) { return this._toString(); } else { return format.replace(/(%|\\)?.|%%/g, formatter); } }; if (!$P.format) { $P.format = $P._format; } }()); (function () { "use strict"; var gFn = function (attr) { return function () { return this[attr]; }; }; var sFn = function (attr) { return function (val) { this[attr] = val; return this; }; }; var attrs = ["years", "months", "days", "hours", "minutes", "seconds", "milliseconds"]; var addSetFuncs = function (context, attrs) { for (var i = 0; i < attrs.length ; i++) { var $a = attrs[i], $b = $a.slice(0, 1).toUpperCase() + $a.slice(1); context.prototype[$a] = 0; context.prototype["get" + $b] = gFn($a); context.prototype["set" + $b] = sFn($a); } }; /** * new TimeSpan(milliseconds); * new TimeSpan(days, hours, minutes, seconds); * new TimeSpan(days, hours, minutes, seconds, milliseconds); */ var TimeSpan = function (days, hours, minutes, seconds, milliseconds) { if (arguments.length === 1 && typeof days === "number") { var orient = (days < 0) ? -1 : +1; var millsLeft = Math.abs(days); this.setDays(Math.floor(millsLeft / 86400000) * orient); millsLeft = millsLeft % 86400000; this.setHours(Math.floor(millsLeft / 3600000) * orient); millsLeft = millsLeft % 3600000; this.setMinutes(Math.floor(millsLeft / 60000) * orient); millsLeft = millsLeft % 60000; this.setSeconds(Math.floor(millsLeft / 1000) * orient); millsLeft = millsLeft % 1000; this.setMilliseconds(millsLeft * orient); } else { this.set(days, hours, minutes, seconds, milliseconds); } this.getTotalMilliseconds = function () { return (this.getDays() * 86400000) + (this.getHours() * 3600000) + (this.getMinutes() * 60000) + (this.getSeconds() * 1000); }; this.compareTo = function (time) { var t1 = new Date(1970, 1, 1, this.getHours(), this.getMinutes(), this.getSeconds()), t2; if (time === null) { t2 = new Date(1970, 1, 1, 0, 0, 0); } else { t2 = new Date(1970, 1, 1, time.getHours(), time.getMinutes(), time.getSeconds()); } return (t1 < t2) ? -1 : (t1 > t2) ? 1 : 0; }; this.equals = function (time) { return (this.compareTo(time) === 0); }; this.add = function (time) { return (time === null) ? this : this.addSeconds(time.getTotalMilliseconds() / 1000); }; this.subtract = function (time) { return (time === null) ? this : this.addSeconds(-time.getTotalMilliseconds() / 1000); }; this.addDays = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 86400000)); }; this.addHours = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 3600000)); }; this.addMinutes = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 60000)); }; this.addSeconds = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 1000)); }; this.addMilliseconds = function (n) { return new TimeSpan(this.getTotalMilliseconds() + n); }; this.get12HourHour = function () { return (this.getHours() > 12) ? this.getHours() - 12 : (this.getHours() === 0) ? 12 : this.getHours(); }; this.getDesignator = function () { return (this.getHours() < 12) ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator; }; this.toString = function (format) { this._toString = function () { if (this.getDays() !== null && this.getDays() > 0) { return this.getDays() + "." + this.getHours() + ":" + this.p(this.getMinutes()) + ":" + this.p(this.getSeconds()); } else { return this.getHours() + ":" + this.p(this.getMinutes()) + ":" + this.p(this.getSeconds()); } }; this.p = function (s) { return (s.toString().length < 2) ? "0" + s : s; }; var me = this; return format ? format.replace(/dd?|HH?|hh?|mm?|ss?|tt?/g, function (format) { switch (format) { case "d": return me.getDays(); case "dd": return me.p(me.getDays()); case "H": return me.getHours(); case "HH": return me.p(me.getHours()); case "h": return me.get12HourHour(); case "hh": return me.p(me.get12HourHour()); case "m": return me.getMinutes(); case "mm": return me.p(me.getMinutes()); case "s": return me.getSeconds(); case "ss": return me.p(me.getSeconds()); case "t": return ((me.getHours() < 12) ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator).substring(0, 1); case "tt": return (me.getHours() < 12) ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator; } } ) : this._toString(); }; return this; }; addSetFuncs(TimeSpan, attrs.slice(2)); TimeSpan.prototype.set = function (days, hours, minutes, seconds, milliseconds){ this.setDays(days || this.getDays()); this.setHours(hours || this.getHours()); this.setMinutes(minutes || this.getMinutes()); this.setSeconds(seconds || this.getSeconds()); this.setMilliseconds(milliseconds || this.getMilliseconds()); }; /** * Gets the time of day for this date instances. * @return {TimeSpan} TimeSpan */ Date.prototype.getTimeOfDay = function () { return new TimeSpan(0, this.getHours(), this.getMinutes(), this.getSeconds(), this.getMilliseconds()); }; Date.TimeSpan = TimeSpan; if (typeof window !== "undefined" ) { // keeping API compatible for v1.x window.TimeSpan = TimeSpan; } }()); (function () { "use strict"; var attrs = ["years", "months", "days", "hours", "minutes", "seconds", "milliseconds"]; var gFn = function (attr) { return function () { return this[attr]; }; }; var sFn = function (attr) { return function (val) { this[attr] = val; return this; }; }; var addSetFuncs = function (context, attrs) { for (var i = 0; i < attrs.length ; i++) { var $a = attrs[i], $b = $a.slice(0, 1).toUpperCase() + $a.slice(1); context.prototype[$a] = 0; context.prototype["get" + $b] = gFn($a); context.prototype["set" + $b] = sFn($a); } }; var setMonthsAndYears = function (orient, d1, d2, context) { function inc() { d1.addMonths(-orient); context.months++; if (context.months === 12) { context.years++; context.months = 0; } } if (orient === +1) { while (d1 > d2) { inc(); } } else { while (d1 < d2) { inc(); } } context.months--; context.months *= orient; context.years *= orient; }; var adjustForDST = function(orient, startDate, endDate) { var hasDSTMismatch = (false === (startDate.isDaylightSavingTime() === endDate.isDaylightSavingTime())); if (hasDSTMismatch && orient === 1) { startDate.addHours(-1); } else if (hasDSTMismatch) { startDate.addHours(1); } }; /** * TimePeriod(startDate, endDate); * TimePeriod(years, months, days, hours, minutes, seconds, milliseconds); */ var TimePeriod = function (years, months, days, hours, minutes, seconds, milliseconds) { if (arguments.length === 7) { this.set(years, months, days, hours, minutes, seconds, milliseconds); } else if (arguments.length === 2 && arguments[0] instanceof Date && arguments[1] instanceof Date) { var startDate = arguments[0].clone(); var endDate = arguments[1].clone(); var orient = (startDate > endDate) ? +1 : -1; this.dates = { start: arguments[0].clone(), end: arguments[1].clone() }; setMonthsAndYears(orient, startDate, endDate, this); adjustForDST(orient, startDate, endDate); // // TODO - adjust for DST var diff = endDate - startDate; if (diff !== 0) { var ts = new TimeSpan(diff); this.set(this.years, this.months, ts.getDays(), ts.getHours(), ts.getMinutes(), ts.getSeconds(), ts.getMilliseconds()); } } return this; }; // create all the set functions. addSetFuncs(TimePeriod, attrs); TimePeriod.prototype.set = function (years, months, days, hours, minutes, seconds, milliseconds){ this.setYears(years || this.getYears()); this.setMonths(months || this.getMonths()); this.setDays(days || this.getDays()); this.setHours(hours || this.getHours()); this.setMinutes(minutes || this.getMinutes()); this.setSeconds(seconds || this.getSeconds()); this.setMilliseconds(milliseconds || this.getMilliseconds()); }; Date.TimePeriod = TimePeriod; if (typeof window !== "undefined") { // keeping API compatible for v1.x window.TimePeriod = TimePeriod; } }()); ================================================ FILE: build/date-pt-PT.js ================================================ /** * @overview datejs * @version 1.0.0-rc3 * @author Gregory Wild-Smith * @copyright 2015 Gregory Wild-Smith * @license MIT * @homepage https://github.com/abritinthebay/datejs */ /* * DateJS Culture String File * Country Code: pt-PT * Name: Portuguese (Portugal) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["pt-PT"] = { "name": "pt-PT", "englishName": "Portuguese (Portugal)", "nativeName": "Português (Portugal)", "Sunday": "domingo", "Monday": "segunda-feira", "Tuesday": "terça-feira", "Wednesday": "quarta-feira", "Thursday": "quinta-feira", "Friday": "sexta-feira", "Saturday": "sábado", "Sun": "dom", "Mon": "seg", "Tue": "ter", "Wed": "qua", "Thu": "qui", "Fri": "sex", "Sat": "sáb", "Su": "dom", "Mo": "seg", "Tu": "ter", "We": "qua", "Th": "qui", "Fr": "sex", "Sa": "sáb", "S_Sun_Initial": "d", "M_Mon_Initial": "s", "T_Tue_Initial": "t", "W_Wed_Initial": "q", "T_Thu_Initial": "q", "F_Fri_Initial": "s", "S_Sat_Initial": "s", "January": "Janeiro", "February": "Fevereiro", "March": "Março", "April": "Abril", "May": "Maio", "June": "Junho", "July": "Julho", "August": "Agosto", "September": "Setembro", "October": "Outubro", "November": "Novembro", "December": "Dezembro", "Jan_Abbr": "Jan", "Feb_Abbr": "Fev", "Mar_Abbr": "Mar", "Apr_Abbr": "Abr", "May_Abbr": "Mai", "Jun_Abbr": "Jun", "Jul_Abbr": "Jul", "Aug_Abbr": "Ago", "Sep_Abbr": "Set", "Oct_Abbr": "Out", "Nov_Abbr": "Nov", "Dec_Abbr": "Dez", "AM": "", "PM": "", "firstDayOfWeek": 1, "twoDigitYearMax": 2029, "mdy": "dmy", "M/d/yyyy": "dd-MM-yyyy", "dddd, MMMM dd, yyyy": "dddd, d' de 'MMMM' de 'yyyy", "h:mm tt": "H:mm", "h:mm:ss tt": "H:mm:ss", "dddd, MMMM dd, yyyy h:mm:ss tt": "dddd, d' de 'MMMM' de 'yyyy H:mm:ss", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "d/M", "MMMM, yyyy": "MMMM' de 'yyyy", "/jan(uary)?/": "jan(eiro)?", "/feb(ruary)?/": "fev(ereiro)?", "/mar(ch)?/": "mar(ço)?", "/apr(il)?/": "abr(il)?", "/may/": "mai(o)?", "/jun(e)?/": "jun(ho)?", "/jul(y)?/": "jul(ho)?", "/aug(ust)?/": "ago(sto)?", "/sep(t(ember)?)?/": "set(embro)?", "/oct(ober)?/": "out(ubro)?", "/nov(ember)?/": "nov(embro)?", "/dec(ember)?/": "dez(embro)?", "/^su(n(day)?)?/": "^domingo", "/^mo(n(day)?)?/": "^segunda-feira", "/^tu(e(s(day)?)?)?/": "^terça-feira", "/^we(d(nesday)?)?/": "^quarta-feira", "/^th(u(r(s(day)?)?)?)?/": "^quinta-feira", "/^fr(i(day)?)?/": "^sexta-feira", "/^sa(t(urday)?)?/": "^sábado", "/^next/": "^prox(im(o(s)?|a(s)?))?", "/^last|past|prev(ious)?/": "^ant(erior(es)?)?|ult(im(o(s)?|a(s)?))?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|depois)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|antes)", "/^yes(terday)?/": "^ontem", "/^t(od(ay)?)?/": "^h(oje)?", "/^tom(orrow)?/": "^amanha", "/^n(ow)?/": "^a(gora)?", "/^ms|milli(second)?s?/": "^ms|milli(segundo)?s?", "/^sec(ond)?s?/": "^s(egundo)?s?", "/^mn|min(ute)?s?/": "^mn|min(uto)?s?", "/^h(our)?s?/": "^h(ora)?s?", "/^w(eek)?s?/": "^sem(ana)?s?", "/^m(onth)?s?/": "^m(e(se)?s?)?", "/^d(ay)?s?/": "^d(ia(s)?s?)?", "/^y(ear)?s?/": "^an((o)?s?)?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "pt-PT"; /** * @overview datejs * @version 1.0.0-rc3 * @author Gregory Wild-Smith * @copyright 2015 Gregory Wild-Smith * @license MIT * @homepage https://github.com/abritinthebay/datejs */(function () { var $D = Date; var lang = Date.CultureStrings ? Date.CultureStrings.lang : null; var loggedKeys = {}; // for debug purposes. var getText = { getFromKey: function (key, countryCode) { var output; if (Date.CultureStrings && Date.CultureStrings[countryCode] && Date.CultureStrings[countryCode][key]) { output = Date.CultureStrings[countryCode][key]; } else { output = getText.buildFromDefault(key); } if (key.charAt(0) === "/") { // Assume it's a regex output = getText.buildFromRegex(key, countryCode); } return output; }, getFromObjectValues: function (obj, countryCode) { var key, output = {}; for(key in obj) { if (obj.hasOwnProperty(key)) { output[key] = getText.getFromKey(obj[key], countryCode); } } return output; }, getFromObjectKeys: function (obj, countryCode) { var key, output = {}; for(key in obj) { if (obj.hasOwnProperty(key)) { output[getText.getFromKey(key, countryCode)] = obj[key]; } } return output; }, getFromArray: function (arr, countryCode) { var output = []; for (var i=0; i < arr.length; i++){ if (i in arr) { output[i] = getText.getFromKey(arr[i], countryCode); } } return output; }, buildFromDefault: function (key) { var output, length, split, last; switch(key) { case "name": output = "en-US"; break; case "englishName": output = "English (United States)"; break; case "nativeName": output = "English (United States)"; break; case "twoDigitYearMax": output = 2049; break; case "firstDayOfWeek": output = 0; break; default: output = key; split = key.split("_"); length = split.length; if (length > 1 && key.charAt(0) !== "/") { // if the key isn't a regex and it has a split. last = split[(length - 1)].toLowerCase(); if (last === "initial" || last === "abbr") { output = split[0]; } } break; } return output; }, buildFromRegex: function (key, countryCode) { var output; if (Date.CultureStrings && Date.CultureStrings[countryCode] && Date.CultureStrings[countryCode][key]) { output = new RegExp(Date.CultureStrings[countryCode][key], "i"); } else { output = new RegExp(key.replace(new RegExp("/", "g"),""), "i"); } return output; } }; var shallowMerge = function (obj1, obj2) { for (var attrname in obj2) { if (obj2.hasOwnProperty(attrname)) { obj1[attrname] = obj2[attrname]; } } }; var __ = function (key, language) { var countryCode = (language) ? language : lang; loggedKeys[key] = key; if (typeof key === "object") { if (key instanceof Array) { return getText.getFromArray(key, countryCode); } else { return getText.getFromObjectKeys(key, countryCode); } } else { return getText.getFromKey(key, countryCode); } }; var loadI18nScript = function (code) { // paatterned after jQuery's getScript. var url = Date.Config.i18n + code + ".js"; var head = document.getElementsByTagName("head")[0] || document.documentElement; var script = document.createElement("script"); script.src = url; var completed = false; var events = { done: function (){} // placeholder function }; // Attach handlers for all browsers script.onload = script.onreadystatechange = function() { if ( !completed && (!this.readyState || this.readyState === "loaded" || this.readyState === "complete") ) { events.done(); head.removeChild(script); } }; setTimeout(function() { head.insertBefore(script, head.firstChild); }, 0); // allows return to execute first return { done: function (cb) { events.done = function() { if (cb) { setTimeout(cb,0); } }; } }; }; var buildInfo = { buildFromMethodHash: function (obj) { var key; for(key in obj) { if (obj.hasOwnProperty(key)) { obj[key] = buildInfo[obj[key]](); } } return obj; }, timeZoneDST: function () { var DST = { "CHADT": "+1345", "NZDT": "+1300", "AEDT": "+1100", "ACDT": "+1030", "AZST": "+0500", "IRDT": "+0430", "EEST": "+0300", "CEST": "+0200", "BST": "+0100", "PMDT": "-0200", "ADT": "-0300", "NDT": "-0230", "EDT": "-0400", "CDT": "-0500", "MDT": "-0600", "PDT": "-0700", "AKDT": "-0800", "HADT": "-0900" }; return __(DST); }, timeZoneStandard: function () { var standard = { "LINT": "+1400", "TOT": "+1300", "CHAST": "+1245", "NZST": "+1200", "NFT": "+1130", "SBT": "+1100", "AEST": "+1000", "ACST": "+0930", "JST": "+0900", "CWST": "+0845", "CT": "+0800", "ICT": "+0700", "MMT": "+0630", "BST": "+0600", "NPT": "+0545", "IST": "+0530", "PKT": "+0500", "AFT": "+0430", "MSK": "+0400", "IRST": "+0330", "FET": "+0300", "EET": "+0200", "CET": "+0100", "GMT": "+0000", "UTC": "+0000", "CVT": "-0100", "GST": "-0200", "BRT": "-0300", "NST": "-0330", "AST": "-0400", "EST": "-0500", "CST": "-0600", "MST": "-0700", "PST": "-0800", "AKST": "-0900", "MIT": "-0930", "HST": "-1000", "SST": "-1100", "BIT": "-1200" }; return __(standard); }, timeZones: function (data) { var zone; data.timezones = []; for (zone in data.abbreviatedTimeZoneStandard) { if (data.abbreviatedTimeZoneStandard.hasOwnProperty(zone)) { data.timezones.push({ name: zone, offset: data.abbreviatedTimeZoneStandard[zone]}); } } for (zone in data.abbreviatedTimeZoneDST) { if (data.abbreviatedTimeZoneDST.hasOwnProperty(zone)) { data.timezones.push({ name: zone, offset: data.abbreviatedTimeZoneDST[zone], dst: true}); } } return data.timezones; }, days: function () { return __(["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"]); }, dayAbbr: function () { return __(["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"]); }, dayShortNames: function () { return __(["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"]); }, dayFirstLetters: function () { return __(["S_Sun_Initial", "M_Mon_Initial", "T_Tues_Initial", "W_Wed_Initial", "T_Thu_Initial", "F_Fri_Initial", "S_Sat_Initial"]); }, months: function () { return __(["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"]); }, monthAbbr: function () { return __(["Jan_Abbr", "Feb_Abbr", "Mar_Abbr", "Apr_Abbr", "May_Abbr", "Jun_Abbr", "Jul_Abbr", "Aug_Abbr", "Sep_Abbr", "Oct_Abbr", "Nov_Abbr", "Dec_Abbr"]); }, formatPatterns: function () { return getText.getFromObjectValues({ shortDate: "M/d/yyyy", longDate: "dddd, MMMM dd, yyyy", shortTime: "h:mm tt", longTime: "h:mm:ss tt", fullDateTime: "dddd, MMMM dd, yyyy h:mm:ss tt", sortableDateTime: "yyyy-MM-ddTHH:mm:ss", universalSortableDateTime: "yyyy-MM-dd HH:mm:ssZ", rfc1123: "ddd, dd MMM yyyy HH:mm:ss", monthDay: "MMMM dd", yearMonth: "MMMM, yyyy" }, Date.i18n.currentLanguage()); }, regex: function () { return getText.getFromObjectValues({ inTheMorning: "/( in the )(morn(ing)?)\\b/", thisMorning: "/(this )(morn(ing)?)\\b/", amThisMorning: "/(\b\\d(am)? )(this )(morn(ing)?)/", inTheEvening: "/( in the )(even(ing)?)\\b/", thisEvening: "/(this )(even(ing)?)\\b/", pmThisEvening: "/(\b\\d(pm)? )(this )(even(ing)?)/", jan: "/jan(uary)?/", feb: "/feb(ruary)?/", mar: "/mar(ch)?/", apr: "/apr(il)?/", may: "/may/", jun: "/jun(e)?/", jul: "/jul(y)?/", aug: "/aug(ust)?/", sep: "/sep(t(ember)?)?/", oct: "/oct(ober)?/", nov: "/nov(ember)?/", dec: "/dec(ember)?/", sun: "/^su(n(day)?)?/", mon: "/^mo(n(day)?)?/", tue: "/^tu(e(s(day)?)?)?/", wed: "/^we(d(nesday)?)?/", thu: "/^th(u(r(s(day)?)?)?)?/", fri: "/fr(i(day)?)?/", sat: "/^sa(t(urday)?)?/", future: "/^next/", past: "/^last|past|prev(ious)?/", add: "/^(\\+|aft(er)?|from|hence)/", subtract: "/^(\\-|bef(ore)?|ago)/", yesterday: "/^yes(terday)?/", today: "/^t(od(ay)?)?/", tomorrow: "/^tom(orrow)?/", now: "/^n(ow)?/", millisecond: "/^ms|milli(second)?s?/", second: "/^sec(ond)?s?/", minute: "/^mn|min(ute)?s?/", hour: "/^h(our)?s?/", week: "/^w(eek)?s?/", month: "/^m(onth)?s?/", day: "/^d(ay)?s?/", year: "/^y(ear)?s?/", shortMeridian: "/^(a|p)/", longMeridian: "/^(a\\.?m?\\.?|p\\.?m?\\.?)/", timezone: "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/", ordinalSuffix: "/^\\s*(st|nd|rd|th)/", timeContext: "/^\\s*(\\:|a(?!u|p)|p)/" }, Date.i18n.currentLanguage()); } }; var CultureInfo = function () { var info = getText.getFromObjectValues({ name: "name", englishName: "englishName", nativeName: "nativeName", amDesignator: "AM", pmDesignator: "PM", firstDayOfWeek: "firstDayOfWeek", twoDigitYearMax: "twoDigitYearMax", dateElementOrder: "mdy" }, Date.i18n.currentLanguage()); var constructedInfo = buildInfo.buildFromMethodHash({ dayNames: "days", abbreviatedDayNames: "dayAbbr", shortestDayNames: "dayShortNames", firstLetterDayNames: "dayFirstLetters", monthNames: "months", abbreviatedMonthNames: "monthAbbr", formatPatterns: "formatPatterns", regexPatterns: "regex", abbreviatedTimeZoneDST: "timeZoneDST", abbreviatedTimeZoneStandard: "timeZoneStandard" }); shallowMerge(info, constructedInfo); buildInfo.timeZones(info); return info; }; $D.i18n = { __: function (key, lang) { return __(key, lang); }, currentLanguage: function () { return lang || "en-US"; }, setLanguage: function (code, force, cb) { var async = false; if (force || code === "en-US" || (!!Date.CultureStrings && !!Date.CultureStrings[code])) { lang = code; Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings.lang = code; Date.CultureInfo = new CultureInfo(); } else { if (!(!!Date.CultureStrings && !!Date.CultureStrings[code])) { if (typeof exports !== "undefined" && this.exports !== exports) { // we're in a Node enviroment, load it using require try { require("../i18n/" + code + ".js"); lang = code; Date.CultureStrings.lang = code; Date.CultureInfo = new CultureInfo(); } catch (e) { // var str = "The language for '" + code + "' could not be loaded by Node. It likely does not exist."; throw new Error("The DateJS IETF language tag '" + code + "' could not be loaded by Node. It likely does not exist."); } } else if (Date.Config && Date.Config.i18n) { // we know the location of the files, so lets load them async = true; loadI18nScript(code).done(function(){ lang = code; Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings.lang = code; Date.CultureInfo = new CultureInfo(); $D.Parsing.Normalizer.buildReplaceData(); // because this is async if ($D.Grammar) { $D.Grammar.buildGrammarFormats(); // so we can parse those strings... } if (cb) { setTimeout(cb,0); } }); } else { Date.console.error("The DateJS IETF language tag '" + code + "' is not available and has not been loaded."); return false; } } } $D.Parsing.Normalizer.buildReplaceData(); // rebuild normalizer strings if ($D.Grammar) { $D.Grammar.buildGrammarFormats(); // so we can parse those strings... } if (!async && cb) { setTimeout(cb,0); } }, getLoggedKeys: function () { return loggedKeys; }, updateCultureInfo: function () { Date.CultureInfo = new CultureInfo(); } }; $D.i18n.updateCultureInfo(); // run automatically }()); (function () { var $D = Date, $P = $D.prototype, p = function (s, l) { if (!l) { l = 2; } return ("000" + s).slice(l * -1); }; if (typeof window !== "undefined" && typeof window.console !== "undefined" && typeof window.console.log !== "undefined") { $D.console = console; // used only to raise non-critical errors if available } else { // set mock so we don't give errors. $D.console = { log: function(){}, error: function(){} }; } $D.Config = $D.Config || {}; $D.initOverloads = function() { /** * Overload of Date.now. Allows an alternate call for Date.now where it returns the * current Date as an object rather than just milliseconds since the Unix Epoch. * * Also provides an implementation of now() for browsers (IE<9) that don't have it. * * Backwards compatible so with work with either: * Date.now() [returns ms] * or * Date.now(true) [returns Date] */ if (!$D.now) { $D._now = function now() { return new Date().getTime(); }; } else if (!$D._now) { $D._now = $D.now; } $D.now = function (returnObj) { if (returnObj) { return $D.present(); } else { return $D._now(); } }; if ( !$P.toISOString ) { $P.toISOString = function() { return this.getUTCFullYear() + "-" + p(this.getUTCMonth() + 1) + "-" + p(this.getUTCDate()) + "T" + p(this.getUTCHours()) + ":" + p(this.getUTCMinutes()) + ":" + p(this.getUTCSeconds()) + "." + String( (this.getUTCMilliseconds()/1000).toFixed(3)).slice(2, 5) + "Z"; }; } // private if ( $P._toString === undefined ){ $P._toString = $P.toString; } }; $D.initOverloads(); /** * Gets a date that is set to the current date. The time is set to the start of the day (00:00 or 12:00 AM). * @return {Date} The current date. */ $D.today = function () { return new Date().clearTime(); }; /** * Gets a date that is set to the current date and time (same as new Date, but chainable) * @return {Date} The current date. */ $D.present = function () { return new Date(); }; /** * Compares the first date to the second date and returns an number indication of their relative values. * @param {Date} First Date object to compare [Required]. * @param {Date} Second Date object to compare to [Required]. * @return {Number} -1 = date1 is lessthan date2. 0 = values are equal. 1 = date1 is greaterthan date2. */ $D.compare = function (date1, date2) { if (isNaN(date1) || isNaN(date2)) { throw new Error(date1 + " - " + date2); } else if (date1 instanceof Date && date2 instanceof Date) { return (date1 < date2) ? -1 : (date1 > date2) ? 1 : 0; } else { throw new TypeError(date1 + " - " + date2); } }; /** * Compares the first Date object to the second Date object and returns true if they are equal. * @param {Date} First Date object to compare [Required] * @param {Date} Second Date object to compare to [Required] * @return {Boolean} true if dates are equal. false if they are not equal. */ $D.equals = function (date1, date2) { return (date1.compareTo(date2) === 0); }; /** * Gets the language appropriate day name when given the day number(0-6) * eg - 0 == Sunday * @return {String} The day name */ $D.getDayName = function (n) { return Date.CultureInfo.dayNames[n]; }; /** * Gets the day number (0-6) if given a CultureInfo specific string which is a valid dayName, abbreviatedDayName or shortestDayName (two char). * @param {String} The name of the day (eg. "Monday, "Mon", "tuesday", "tue", "We", "we"). * @return {Number} The day number */ $D.getDayNumberFromName = function (name) { var n = Date.CultureInfo.dayNames, m = Date.CultureInfo.abbreviatedDayNames, o = Date.CultureInfo.shortestDayNames, s = name.toLowerCase(); for (var i = 0; i < n.length; i++) { if (n[i].toLowerCase() === s || m[i].toLowerCase() === s || o[i].toLowerCase() === s) { return i; } } return -1; }; /** * Gets the month number (0-11) if given a Culture Info specific string which is a valid monthName or abbreviatedMonthName. * @param {String} The name of the month (eg. "February, "Feb", "october", "oct"). * @return {Number} The day number */ $D.getMonthNumberFromName = function (name) { var n = Date.CultureInfo.monthNames, m = Date.CultureInfo.abbreviatedMonthNames, s = name.toLowerCase(); for (var i = 0; i < n.length; i++) { if (n[i].toLowerCase() === s || m[i].toLowerCase() === s) { return i; } } return -1; }; /** * Gets the language appropriate month name when given the month number(0-11) * eg - 0 == January * @return {String} The month name */ $D.getMonthName = function (n) { return Date.CultureInfo.monthNames[n]; }; /** * Determines if the current date instance is within a LeapYear. * @param {Number} The year. * @return {Boolean} true if date is within a LeapYear, otherwise false. */ $D.isLeapYear = function (year) { return ((year % 4 === 0 && year % 100 !== 0) || year % 400 === 0); }; /** * Gets the number of days in the month, given a year and month value. Automatically corrects for LeapYear. * @param {Number} The year. * @param {Number} The month (0-11). * @return {Number} The number of days in the month. */ $D.getDaysInMonth = function (year, month) { if (!month && $D.validateMonth(year)) { month = year; year = Date.today().getFullYear(); } return [31, ($D.isLeapYear(year) ? 29 : 28), 31, 30, 31, 30, 31, 31, 30, 31, 30, 31][month]; }; $P.getDaysInMonth = function () { return $D.getDaysInMonth(this.getFullYear(), this.getMonth()); }; $D.getTimezoneAbbreviation = function (offset, dst) { var p, n = (dst || false) ? Date.CultureInfo.abbreviatedTimeZoneDST : Date.CultureInfo.abbreviatedTimeZoneStandard; for (p in n) { if (n.hasOwnProperty(p)) { if (n[p] === offset) { return p; } } } return null; }; $D.getTimezoneOffset = function (name, dst) { var i, a =[], z = Date.CultureInfo.timezones; if (!name) { name = (new Date()).getTimezone();} for (i = 0; i < z.length; i++) { if (z[i].name === name.toUpperCase()) { a.push(i); } } if (!z[a[0]]) { return null; } if (a.length === 1 || !dst) { return z[a[0]].offset; } else { for (i=0; i < a.length; i++) { if (z[a[i]].dst) { return z[a[i]].offset; } } } }; $D.getQuarter = function (d) { d = d || new Date(); // If no date supplied, use today var q = [1,2,3,4]; return q[Math.floor(d.getMonth() / 3)]; // ~~~ is a bitwise op. Faster than Math.floor }; $D.getDaysLeftInQuarter = function (d) { d = d || new Date(); var qEnd = new Date(d); qEnd.setMonth(qEnd.getMonth() + 3 - qEnd.getMonth() % 3, 0); return Math.floor((qEnd - d) / 8.64e7); }; // private var validate = function (n, min, max, name) { name = name ? name : "Object"; if (typeof n === "undefined") { return false; } else if (typeof n !== "number") { throw new TypeError(n + " is not a Number."); } else if (n < min || n > max) { // As failing validation is *not* an exceptional circumstance // lets not throw a RangeError Exception here. // It's semantically correct but it's not sensible. return false; } return true; }; /** * Validates the number is within an acceptable range for milliseconds [0-999]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateMillisecond = function (value) { return validate(value, 0, 999, "millisecond"); }; /** * Validates the number is within an acceptable range for seconds [0-59]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateSecond = function (value) { return validate(value, 0, 59, "second"); }; /** * Validates the number is within an acceptable range for minutes [0-59]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateMinute = function (value) { return validate(value, 0, 59, "minute"); }; /** * Validates the number is within an acceptable range for hours [0-23]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateHour = function (value) { return validate(value, 0, 23, "hour"); }; /** * Validates the number is within an acceptable range for the days in a month [0-MaxDaysInMonth]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateDay = function (value, year, month) { if (year === undefined || year === null || month === undefined || month === null) { return false;} return validate(value, 1, $D.getDaysInMonth(year, month), "day"); }; /** * Validates the number is within an acceptable range for months [0-11]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateWeek = function (value) { return validate(value, 0, 53, "week"); }; /** * Validates the number is within an acceptable range for months [0-11]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateMonth = function (value) { return validate(value, 0, 11, "month"); }; /** * Validates the number is within an acceptable range for years. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateYear = function (value) { /** * Per ECMAScript spec the range of times supported by Date objects is * exactly -100,000,000 days to +100,000,000 days measured relative to * midnight at the beginning of 01 January, 1970 UTC. * This gives a range of 8,640,000,000,000,000 milliseconds to either * side of 01 January, 1970 UTC. * * Earliest possible date: Tue, 20 Apr 271,822 B.C. 00:00:00 UTC * Latest possible date: Sat, 13 Sep 275,760 00:00:00 UTC */ return validate(value, -271822, 275760, "year"); }; $D.validateTimezone = function(value) { var timezones = {"ACDT":1,"ACST":1,"ACT":1,"ADT":1,"AEDT":1,"AEST":1,"AFT":1,"AKDT":1,"AKST":1,"AMST":1,"AMT":1,"ART":1,"AST":1,"AWDT":1,"AWST":1,"AZOST":1,"AZT":1,"BDT":1,"BIOT":1,"BIT":1,"BOT":1,"BRT":1,"BST":1,"BTT":1,"CAT":1,"CCT":1,"CDT":1,"CEDT":1,"CEST":1,"CET":1,"CHADT":1,"CHAST":1,"CHOT":1,"ChST":1,"CHUT":1,"CIST":1,"CIT":1,"CKT":1,"CLST":1,"CLT":1,"COST":1,"COT":1,"CST":1,"CT":1,"CVT":1,"CWST":1,"CXT":1,"DAVT":1,"DDUT":1,"DFT":1,"EASST":1,"EAST":1,"EAT":1,"ECT":1,"EDT":1,"EEDT":1,"EEST":1,"EET":1,"EGST":1,"EGT":1,"EIT":1,"EST":1,"FET":1,"FJT":1,"FKST":1,"FKT":1,"FNT":1,"GALT":1,"GAMT":1,"GET":1,"GFT":1,"GILT":1,"GIT":1,"GMT":1,"GST":1,"GYT":1,"HADT":1,"HAEC":1,"HAST":1,"HKT":1,"HMT":1,"HOVT":1,"HST":1,"ICT":1,"IDT":1,"IOT":1,"IRDT":1,"IRKT":1,"IRST":1,"IST":1,"JST":1,"KGT":1,"KOST":1,"KRAT":1,"KST":1,"LHST":1,"LINT":1,"MAGT":1,"MART":1,"MAWT":1,"MDT":1,"MET":1,"MEST":1,"MHT":1,"MIST":1,"MIT":1,"MMT":1,"MSK":1,"MST":1,"MUT":1,"MVT":1,"MYT":1,"NCT":1,"NDT":1,"NFT":1,"NPT":1,"NST":1,"NT":1,"NUT":1,"NZDT":1,"NZST":1,"OMST":1,"ORAT":1,"PDT":1,"PET":1,"PETT":1,"PGT":1,"PHOT":1,"PHT":1,"PKT":1,"PMDT":1,"PMST":1,"PONT":1,"PST":1,"PYST":1,"PYT":1,"RET":1,"ROTT":1,"SAKT":1,"SAMT":1,"SAST":1,"SBT":1,"SCT":1,"SGT":1,"SLST":1,"SRT":1,"SST":1,"SYOT":1,"TAHT":1,"THA":1,"TFT":1,"TJT":1,"TKT":1,"TLT":1,"TMT":1,"TOT":1,"TVT":1,"UCT":1,"ULAT":1,"UTC":1,"UYST":1,"UYT":1,"UZT":1,"VET":1,"VLAT":1,"VOLT":1,"VOST":1,"VUT":1,"WAKT":1,"WAST":1,"WAT":1,"WEDT":1,"WEST":1,"WET":1,"WST":1,"YAKT":1,"YEKT":1,"Z":1}; return (timezones[value] === 1); }; $D.validateTimezoneOffset= function(value) { // timezones go from +14hrs to -12hrs, the +X hours are negative offsets. return (value > -841 && value < 721); }; }()); (function () { var $D = Date, $P = $D.prototype, p = function (s, l) { if (!l) { l = 2; } return ("000" + s).slice(l * -1); }; var validateConfigObject = function (obj) { var result = {}, self = this, prop, testFunc; testFunc = function (prop, func, value) { if (prop === "day") { var month = (obj.month !== undefined) ? obj.month : self.getMonth(); var year = (obj.year !== undefined) ? obj.year : self.getFullYear(); return $D[func](value, year, month); } else { return $D[func](value); } }; for (prop in obj) { if (Object.prototype.hasOwnProperty.call(obj, prop)) { var func = "validate" + prop.charAt(0).toUpperCase() + prop.slice(1); if ($D[func] && obj[prop] !== null && testFunc(prop, func, obj[prop])) { result[prop] = obj[prop]; } } } return result; }; /** * Resets the time of this Date object to 12:00 AM (00:00), which is the start of the day. * @param {Boolean} .clone() this date instance before clearing Time * @return {Date} this */ $P.clearTime = function () { this.setHours(0); this.setMinutes(0); this.setSeconds(0); this.setMilliseconds(0); return this; }; /** * Resets the time of this Date object to the current time ('now'). * @return {Date} this */ $P.setTimeToNow = function () { var n = new Date(); this.setHours(n.getHours()); this.setMinutes(n.getMinutes()); this.setSeconds(n.getSeconds()); this.setMilliseconds(n.getMilliseconds()); return this; }; /** * Returns a new Date object that is an exact date and time copy of the original instance. * @return {Date} A new Date instance */ $P.clone = function () { return new Date(this.getTime()); }; /** * Compares this instance to a Date object and returns an number indication of their relative values. * @param {Date} Date object to compare [Required] * @return {Number} -1 = this is lessthan date. 0 = values are equal. 1 = this is greaterthan date. */ $P.compareTo = function (date) { return Date.compare(this, date); }; /** * Compares this instance to another Date object and returns true if they are equal. * @param {Date} Date object to compare. If no date to compare, new Date() [now] is used. * @return {Boolean} true if dates are equal. false if they are not equal. */ $P.equals = function (date) { return Date.equals(this, (date !== undefined ? date : new Date())); }; /** * Determines if this instance is between a range of two dates or equal to either the start or end dates. * @param {Date} Start of range [Required] * @param {Date} End of range [Required] * @return {Boolean} true is this is between or equal to the start and end dates, else false */ $P.between = function (start, end) { return this.getTime() >= start.getTime() && this.getTime() <= end.getTime(); }; /** * Determines if this date occurs after the date to compare to. * @param {Date} Date object to compare. If no date to compare, new Date() ("now") is used. * @return {Boolean} true if this date instance is greater than the date to compare to (or "now"), otherwise false. */ $P.isAfter = function (date) { return this.compareTo(date || new Date()) === 1; }; /** * Determines if this date occurs before the date to compare to. * @param {Date} Date object to compare. If no date to compare, new Date() ("now") is used. * @return {Boolean} true if this date instance is less than the date to compare to (or "now"). */ $P.isBefore = function (date) { return (this.compareTo(date || new Date()) === -1); }; /** * Determines if the current Date instance occurs today. * @return {Boolean} true if this date instance is 'today', otherwise false. */ /** * Determines if the current Date instance occurs on the same Date as the supplied 'date'. * If no 'date' to compare to is provided, the current Date instance is compared to 'today'. * @param {date} Date object to compare. If no date to compare, the current Date ("now") is used. * @return {Boolean} true if this Date instance occurs on the same Day as the supplied 'date'. */ $P.isToday = $P.isSameDay = function (date) { return this.clone().clearTime().equals((date || new Date()).clone().clearTime()); }; /** * Adds the specified number of milliseconds to this instance. * @param {Number} The number of milliseconds to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addMilliseconds = function (value) { if (!value) { return this; } this.setTime(this.getTime() + value * 1); return this; }; /** * Adds the specified number of seconds to this instance. * @param {Number} The number of seconds to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addSeconds = function (value) { if (!value) { return this; } return this.addMilliseconds(value * 1000); }; /** * Adds the specified number of seconds to this instance. * @param {Number} The number of seconds to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addMinutes = function (value) { if (!value) { return this; } return this.addMilliseconds(value * 60000); // 60*1000 }; /** * Adds the specified number of hours to this instance. * @param {Number} The number of hours to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addHours = function (value) { if (!value) { return this; } return this.addMilliseconds(value * 3600000); // 60*60*1000 }; /** * Adds the specified number of days to this instance. * @param {Number} The number of days to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addDays = function (value) { if (!value) { return this; } this.setDate(this.getDate() + value * 1); return this; }; /** * Adds the specified number of weekdays (ie - not sat or sun) to this instance. * @param {Number} The number of days to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addWeekdays = function (value) { if (!value) { return this; } var day = this.getDay(); var weeks = (Math.ceil(Math.abs(value)/7)); if (day === 0 || day === 6) { if (value > 0) { this.next().monday(); this.addDays(-1); day = this.getDay(); } } if (value < 0) { while (value < 0) { this.addDays(-1); day = this.getDay(); if (day !== 0 && day !== 6) { value++; } } return this; } else if (value > 5 || (6-day) <= value) { value = value + (weeks * 2); } return this.addDays(value); }; /** * Adds the specified number of weeks to this instance. * @param {Number} The number of weeks to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addWeeks = function (value) { if (!value) { return this; } return this.addDays(value * 7); }; /** * Adds the specified number of months to this instance. * @param {Number} The number of months to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addMonths = function (value) { if (!value) { return this; } var n = this.getDate(); this.setDate(1); this.setMonth(this.getMonth() + value * 1); this.setDate(Math.min(n, $D.getDaysInMonth(this.getFullYear(), this.getMonth()))); return this; }; $P.addQuarters = function (value) { if (!value) { return this; } // note this will take you to the same point in the quarter as you are now. // i.e. - if you are 15 days into the quarter you'll be 15 days into the resulting one. // bonus: this allows adding fractional quarters return this.addMonths(value * 3); }; /** * Adds the specified number of years to this instance. * @param {Number} The number of years to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addYears = function (value) { if (!value) { return this; } return this.addMonths(value * 12); }; /** * Adds (or subtracts) to the value of the years, months, weeks, days, hours, minutes, seconds, milliseconds of the date instance using given configuration object. Positive and Negative values allowed. * Example

	Date.today().add( { days: 1, months: 1 } )

	new Date().add( { years: -1 } )
	
* @param {Object} Configuration object containing attributes (months, days, etc.) * @return {Date} this */ $P.add = function (config) { if (typeof config === "number") { this._orient = config; return this; } var x = config; if (x.day) { // If we should be a different date than today (eg: for 'tomorrow -1d', etc). // Should only effect parsing, not direct usage (eg, Finish and FinishExact) if ((x.day - this.getDate()) !== 0) { this.setDate(x.day); } } if (x.milliseconds) { this.addMilliseconds(x.milliseconds); } if (x.seconds) { this.addSeconds(x.seconds); } if (x.minutes) { this.addMinutes(x.minutes); } if (x.hours) { this.addHours(x.hours); } if (x.weeks) { this.addWeeks(x.weeks); } if (x.months) { this.addMonths(x.months); } if (x.years) { this.addYears(x.years); } if (x.days) { this.addDays(x.days); } return this; }; /** * Get the week number. Week one (1) is the week which contains the first Thursday of the year. Monday is considered the first day of the week. * The .getWeek() function does NOT convert the date to UTC. The local datetime is used. * Please use .getISOWeek() to get the week of the UTC converted date. * @return {Number} 1 to 53 */ $P.getWeek = function (utc) { // Create a copy of this date object var self, target = new Date(this.valueOf()); if (utc) { target.addMinutes(target.getTimezoneOffset()); self = target.clone(); } else { self = this; } // ISO week date weeks start on monday // so correct the day number var dayNr = (self.getDay() + 6) % 7; // ISO 8601 states that week 1 is the week // with the first thursday of that year. // Set the target date to the thursday in the target week target.setDate(target.getDate() - dayNr + 3); // Store the millisecond value of the target date var firstThursday = target.valueOf(); // Set the target to the first thursday of the year // First set the target to january first target.setMonth(0, 1); // Not a thursday? Correct the date to the next thursday if (target.getDay() !== 4) { target.setMonth(0, 1 + ((4 - target.getDay()) + 7) % 7); } // The weeknumber is the number of weeks between the // first thursday of the year and the thursday in the target week return 1 + Math.ceil((firstThursday - target) / 604800000); // 604800000 = 7 * 24 * 3600 * 1000 }; /** * Get the ISO 8601 week number. Week one ("01") is the week which contains the first Thursday of the year. Monday is considered the first day of the week. * The .getISOWeek() function does convert the date to it's UTC value. Please use .getWeek() to get the week of the local date. * @return {String} "01" to "53" */ $P.getISOWeek = function () { return p(this.getWeek(true)); }; /** * Moves the date to Monday of the week set. Week one (1) is the week which contains the first Thursday of the year. * @param {Number} A Number (1 to 53) that represents the week of the year. * @return {Date} this */ $P.setWeek = function (n) { if ((n - this.getWeek()) === 0) { if (this.getDay() !== 1) { return this.moveToDayOfWeek(1, (this.getDay() > 1 ? -1 : 1)); } else { return this; } } else { return this.moveToDayOfWeek(1, (this.getDay() > 1 ? -1 : 1)).addWeeks(n - this.getWeek()); } }; $P.setQuarter = function (qtr) { var month = Math.abs(((qtr-1) * 3) + 1); return this.setMonth(month, 1); }; $P.getQuarter = function () { return Date.getQuarter(this); }; $P.getDaysLeftInQuarter = function () { return Date.getDaysLeftInQuarter(this); }; /** * Moves the date to the next n'th occurrence of the dayOfWeek starting from the beginning of the month. The number (-1) is a magic number and will return the last occurrence of the dayOfWeek in the month. * @param {Number} The dayOfWeek to move to * @param {Number} The n'th occurrence to move to. Use (-1) to return the last occurrence in the month * @return {Date} this */ $P.moveToNthOccurrence = function (dayOfWeek, occurrence) { if (dayOfWeek === "Weekday") { if (occurrence > 0) { this.moveToFirstDayOfMonth(); if (this.is().weekday()) { occurrence -= 1; } } else if (occurrence < 0) { this.moveToLastDayOfMonth(); if (this.is().weekday()) { occurrence += 1; } } else { return this; } return this.addWeekdays(occurrence); } var shift = 0; if (occurrence > 0) { shift = occurrence - 1; } else if (occurrence === -1) { this.moveToLastDayOfMonth(); if (this.getDay() !== dayOfWeek) { this.moveToDayOfWeek(dayOfWeek, -1); } return this; } return this.moveToFirstDayOfMonth().addDays(-1).moveToDayOfWeek(dayOfWeek, +1).addWeeks(shift); }; var moveToN = function (getFunc, addFunc, nVal) { return function (value, orient) { var diff = (value - this[getFunc]() + nVal * (orient || +1)) % nVal; return this[addFunc]((diff === 0) ? diff += nVal * (orient || +1) : diff); }; }; /** * Move to the next or last dayOfWeek based on the orient value. * @param {Number} The dayOfWeek to move to * @param {Number} Forward (+1) or Back (-1). Defaults to +1. [Optional] * @return {Date} this */ $P.moveToDayOfWeek = moveToN("getDay", "addDays", 7); /** * Move to the next or last month based on the orient value. * @param {Number} The month to move to. 0 = January, 11 = December * @param {Number} Forward (+1) or Back (-1). Defaults to +1. [Optional] * @return {Date} this */ $P.moveToMonth = moveToN("getMonth", "addMonths", 12); /** * Get the Ordinate of the current day ("th", "st", "rd"). * @return {String} */ $P.getOrdinate = function () { var num = this.getDate(); return ord(num); }; /** * Get the Ordinal day (numeric day number) of the year, adjusted for leap year. * @return {Number} 1 through 365 (366 in leap years) */ $P.getOrdinalNumber = function () { return Math.ceil((this.clone().clearTime() - new Date(this.getFullYear(), 0, 1)) / 86400000) + 1; }; /** * Get the time zone abbreviation of the current date. * @return {String} The abbreviated time zone name (e.g. "EST") */ $P.getTimezone = function () { return $D.getTimezoneAbbreviation(this.getUTCOffset(), this.isDaylightSavingTime()); }; $P.setTimezoneOffset = function (offset) { var here = this.getTimezoneOffset(), there = Number(offset) * -6 / 10; return (there || there === 0) ? this.addMinutes(there - here) : this; }; $P.setTimezone = function (offset) { return this.setTimezoneOffset($D.getTimezoneOffset(offset)); }; /** * Indicates whether Daylight Saving Time is observed in the current time zone. * @return {Boolean} true|false */ $P.hasDaylightSavingTime = function () { return (Date.today().set({month: 0, day: 1}).getTimezoneOffset() !== Date.today().set({month: 6, day: 1}).getTimezoneOffset()); }; /** * Indicates whether this Date instance is within the Daylight Saving Time range for the current time zone. * @return {Boolean} true|false */ $P.isDaylightSavingTime = function () { return Date.today().set({month: 0, day: 1}).getTimezoneOffset() !== this.getTimezoneOffset(); }; /** * Get the offset from UTC of the current date. * @return {String} The 4-character offset string prefixed with + or - (e.g. "-0500") */ $P.getUTCOffset = function (offset) { var n = (offset || this.getTimezoneOffset()) * -10 / 6, r; if (n < 0) { r = (n - 10000).toString(); return r.charAt(0) + r.substr(2); } else { r = (n + 10000).toString(); return "+" + r.substr(1); } }; /** * Returns the number of milliseconds between this date and date. * @param {Date} Defaults to now * @return {Number} The diff in milliseconds */ $P.getElapsed = function (date) { return (date || new Date()) - this; }; /** * Set the value of year, month, day, hour, minute, second, millisecond of date instance using given configuration object. * Example

	Date.today().set( { day: 20, month: 1 } )

	new Date().set( { millisecond: 0 } )
	
* * @param {Object} Configuration object containing attributes (month, day, etc.) * @return {Date} this */ $P.set = function (config) { config = validateConfigObject.call(this, config); var key; for (key in config) { if (Object.prototype.hasOwnProperty.call(config, key)) { var name = key.charAt(0).toUpperCase() + key.slice(1); var addFunc, getFunc; if (key !== "week" && key !== "month" && key !== "timezone" && key !== "timezoneOffset") { name += "s"; } addFunc = "add" + name; getFunc = "get" + name; if (key === "month") { addFunc = addFunc + "s"; } else if (key === "year"){ getFunc = "getFullYear"; } if (key !== "day" && key !== "timezone" && key !== "timezoneOffset" && key !== "week" && key !== "hour") { this[addFunc](config[key] - this[getFunc]()); } else if ( key === "timezone"|| key === "timezoneOffset" || key === "week" || key === "hour") { this["set"+name](config[key]); } } } // day has to go last because you can't validate the day without first knowing the month if (config.day) { this.addDays(config.day - this.getDate()); } return this; }; /** * Moves the date to the first day of the month. * @return {Date} this */ $P.moveToFirstDayOfMonth = function () { return this.set({ day: 1 }); }; /** * Moves the date to the last day of the month. * @return {Date} this */ $P.moveToLastDayOfMonth = function () { return this.set({ day: $D.getDaysInMonth(this.getFullYear(), this.getMonth())}); }; /** * Converts the value of the current Date object to its equivalent string representation. * Format Specifiers * CUSTOM DATE AND TIME FORMAT STRINGS * Format Description Example * ------ --------------------------------------------------------------------------- ----------------------- * s The seconds of the minute between 0-59. "0" to "59" * ss The seconds of the minute with leading zero if required. "00" to "59" * * m The minute of the hour between 0-59. "0" or "59" * mm The minute of the hour with leading zero if required. "00" or "59" * * h The hour of the day between 1-12. "1" to "12" * hh The hour of the day with leading zero if required. "01" to "12" * * H The hour of the day between 0-23. "0" to "23" * HH The hour of the day with leading zero if required. "00" to "23" * * d The day of the month between 1 and 31. "1" to "31" * dd The day of the month with leading zero if required. "01" to "31" * ddd Abbreviated day name. Date.CultureInfo.abbreviatedDayNames. "Mon" to "Sun" * dddd The full day name. Date.CultureInfo.dayNames. "Monday" to "Sunday" * * M The month of the year between 1-12. "1" to "12" * MM The month of the year with leading zero if required. "01" to "12" * MMM Abbreviated month name. Date.CultureInfo.abbreviatedMonthNames. "Jan" to "Dec" * MMMM The full month name. Date.CultureInfo.monthNames. "January" to "December" * * yy The year as a two-digit number. "99" or "08" * yyyy The full four digit year. "1999" or "2008" * * t Displays the first character of the A.M./P.M. designator. "A" or "P" * Date.CultureInfo.amDesignator or Date.CultureInfo.pmDesignator * tt Displays the A.M./P.M. designator. "AM" or "PM" * Date.CultureInfo.amDesignator or Date.CultureInfo.pmDesignator * * S The ordinal suffix ("st, "nd", "rd" or "th") of the current day. "st, "nd", "rd" or "th" * * STANDARD DATE AND TIME FORMAT STRINGS * Format Description Example *------ --------------------------------------------------------------------------- ----------------------- * d The CultureInfo shortDate Format Pattern "M/d/yyyy" * D The CultureInfo longDate Format Pattern "dddd, MMMM dd, yyyy" * F The CultureInfo fullDateTime Format Pattern "dddd, MMMM dd, yyyy h:mm:ss tt" * m The CultureInfo monthDay Format Pattern "MMMM dd" * r The CultureInfo rfc1123 Format Pattern "ddd, dd MMM yyyy HH:mm:ss GMT" * s The CultureInfo sortableDateTime Format Pattern "yyyy-MM-ddTHH:mm:ss" * t The CultureInfo shortTime Format Pattern "h:mm tt" * T The CultureInfo longTime Format Pattern "h:mm:ss tt" * u The CultureInfo universalSortableDateTime Format Pattern "yyyy-MM-dd HH:mm:ssZ" * y The CultureInfo yearMonth Format Pattern "MMMM, yyyy" * * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @return {String} A string representation of the current Date object. */ var ord = function (n) { switch (n * 1) { case 1: case 21: case 31: return "st"; case 2: case 22: return "nd"; case 3: case 23: return "rd"; default: return "th"; } }; var parseStandardFormats = function (format) { var y, c = Date.CultureInfo.formatPatterns; switch (format) { case "d": return this.toString(c.shortDate); case "D": return this.toString(c.longDate); case "F": return this.toString(c.fullDateTime); case "m": return this.toString(c.monthDay); case "r": case "R": y = this.clone().addMinutes(this.getTimezoneOffset()); return y.toString(c.rfc1123) + " GMT"; case "s": return this.toString(c.sortableDateTime); case "t": return this.toString(c.shortTime); case "T": return this.toString(c.longTime); case "u": y = this.clone().addMinutes(this.getTimezoneOffset()); return y.toString(c.universalSortableDateTime); case "y": return this.toString(c.yearMonth); default: return false; } }; var parseFormatStringsClosure = function (context) { return function (m) { if (m.charAt(0) === "\\") { return m.replace("\\", ""); } switch (m) { case "hh": return p(context.getHours() < 13 ? (context.getHours() === 0 ? 12 : context.getHours()) : (context.getHours() - 12)); case "h": return context.getHours() < 13 ? (context.getHours() === 0 ? 12 : context.getHours()) : (context.getHours() - 12); case "HH": return p(context.getHours()); case "H": return context.getHours(); case "mm": return p(context.getMinutes()); case "m": return context.getMinutes(); case "ss": return p(context.getSeconds()); case "s": return context.getSeconds(); case "yyyy": return p(context.getFullYear(), 4); case "yy": return p(context.getFullYear()); case "y": return context.getFullYear(); case "E": case "dddd": return Date.CultureInfo.dayNames[context.getDay()]; case "ddd": return Date.CultureInfo.abbreviatedDayNames[context.getDay()]; case "dd": return p(context.getDate()); case "d": return context.getDate(); case "MMMM": return Date.CultureInfo.monthNames[context.getMonth()]; case "MMM": return Date.CultureInfo.abbreviatedMonthNames[context.getMonth()]; case "MM": return p((context.getMonth() + 1)); case "M": return context.getMonth() + 1; case "t": return context.getHours() < 12 ? Date.CultureInfo.amDesignator.substring(0, 1) : Date.CultureInfo.pmDesignator.substring(0, 1); case "tt": return context.getHours() < 12 ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator; case "S": return ord(context.getDate()); case "W": return context.getWeek(); case "WW": return context.getISOWeek(); case "Q": return "Q" + context.getQuarter(); case "q": return String(context.getQuarter()); case "z": return context.getTimezone(); case "Z": case "X": return Date.getTimezoneOffset(context.getTimezone()); case "ZZ": // Timezone offset in seconds return context.getTimezoneOffset() * -60; case "u": return context.getDay(); case "L": return ($D.isLeapYear(context.getFullYear())) ? 1 : 0; case "B": // Swatch Internet Time (.beats) return "@"+((context.getUTCSeconds() + (context.getUTCMinutes()*60) + ((context.getUTCHours()+1)*3600))/86.4); default: return m; } }; }; $P.toString = function (format, ignoreStandards) { // Standard Date and Time Format Strings. Formats pulled from CultureInfo file and // may vary by culture. if (!ignoreStandards && format && format.length === 1) { output = parseStandardFormats.call(this, format); if (output) { return output; } } var parseFormatStrings = parseFormatStringsClosure(this); return format ? format.replace(/((\\)?(dd?d?d?|MM?M?M?|yy?y?y?|hh?|HH?|mm?|ss?|tt?|S|q|Q|WW?W?W?)(?![^\[]*\]))/g, parseFormatStrings).replace(/\[|\]/g, "") : this._toString(); }; }()); /************************************************************* * SugarPak - Domain Specific Language - Syntactical Sugar * *************************************************************/ (function () { var $D = Date, $P = $D.prototype, $N = Number.prototype; // private $P._orient = +1; // private $P._nth = null; // private $P._is = false; // private $P._same = false; // private $P._isSecond = false; // private $N._dateElement = "days"; /** * Moves the date to the next instance of a date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.today().next().friday();
	Date.today().next().fri();
	Date.today().next().march();
	Date.today().next().mar();
	Date.today().next().week();
	
* * @return {Date} date */ $P.next = function () { this._move = true; this._orient = +1; return this; }; /** * Creates a new Date (Date.today()) and moves the date to the next instance of the date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.next().friday();
	Date.next().fri();
	Date.next().march();
	Date.next().mar();
	Date.next().week();
	
* * @return {Date} date */ $D.next = function () { return $D.today().next(); }; /** * Moves the date to the previous instance of a date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.today().last().friday();
	Date.today().last().fri();
	Date.today().last().march();
	Date.today().last().mar();
	Date.today().last().week();
	
* * @return {Date} date */ $P.last = $P.prev = $P.previous = function () { this._move = true; this._orient = -1; return this; }; /** * Creates a new Date (Date.today()) and moves the date to the previous instance of the date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.last().friday();
	Date.last().fri();
	Date.previous().march();
	Date.prev().mar();
	Date.last().week();
	
* * @return {Date} date */ $D.last = $D.prev = $D.previous = function () { return $D.today().last(); }; /** * Performs a equality check when followed by either a month name, day name or .weekday() function. * Example

	Date.today().is().friday(); // true|false
	Date.today().is().fri();
	Date.today().is().march();
	Date.today().is().mar();
	
* * @return {Boolean} true|false */ $P.is = function () { this._is = true; return this; }; /** * Determines if two date objects occur on/in exactly the same instance of the subsequent date part function. * The function .same() must be followed by a date part function (example: .day(), .month(), .year(), etc). * * An optional Date can be passed in the date part function. If now date is passed as a parameter, 'Now' is used. * * The following example demonstrates how to determine if two dates fall on the exact same day. * * Example

	var d1 = Date.today(); // today at 00:00
	var d2 = new Date();   // exactly now.

	// Do they occur on the same day?
	d1.same().day(d2); // true
	
	// Do they occur on the same hour?
	d1.same().hour(d2); // false, unless d2 hour is '00' (midnight).
	
	// What if it's the same day, but one year apart?
	var nextYear = Date.today().add(1).year();

	d1.same().day(nextYear); // false, because the dates must occur on the exact same day. 
	
* * Scenario: Determine if a given date occurs during some week period 2 months from now. * * Example

	var future = Date.today().add(2).months();
	return someDate.same().week(future); // true|false;
	
* * @return {Boolean} true|false */ $P.same = function () { this._same = true; this._isSecond = false; return this; }; /** * Determines if the current date/time occurs during Today. Must be preceded by the .is() function. * Example

	someDate.is().today();    // true|false
	new Date().is().today();  // true
	Date.today().is().today();// true
	Date.today().add(-1).day().is().today(); // false
	
* * @return {Boolean} true|false */ $P.today = function () { return this.same().day(); }; /** * Determines if the current date is a weekday. This function must be preceded by the .is() function. * Example

	Date.today().is().weekday(); // true|false
	
* * @return {Boolean} true|false */ $P.weekday = function () { if (this._nth) { return df("Weekday").call(this); } if (this._move) { return this.addWeekdays(this._orient); } if (this._is) { this._is = false; return (!this.is().sat() && !this.is().sun()); } return false; }; /** * Determines if the current date is on the weekend. This function must be preceded by the .is() function. * Example

	Date.today().is().weekend(); // true|false
	
* * @return {Boolean} true|false */ $P.weekend = function () { if (this._is) { this._is = false; return (this.is().sat() || this.is().sun()); } return false; }; /** * Sets the Time of the current Date instance. A string "6:15 pm" or config object {hour:18, minute:15} are accepted. * Example

	// Set time to 6:15pm with a String
	Date.today().at("6:15pm");

	// Set time to 6:15pm with a config object
	Date.today().at({hour:18, minute:15});
	
* * @return {Date} date */ $P.at = function (time) { return (typeof time === "string") ? $D.parse(this.toString("d") + " " + time) : this.set(time); }; /** * Creates a new Date() and adds this (Number) to the date based on the preceding date element function (eg. second|minute|hour|day|month|year). * Example

	// Undeclared Numbers must be wrapped with parentheses. Requirment of JavaScript.
	(3).days().fromNow();
	(6).months().fromNow();

	// Declared Number variables do not require parentheses. 
	var n = 6;
	n.months().fromNow();
	
* * @return {Date} A new Date instance */ $N.fromNow = $N.after = function (date) { var c = {}; c[this._dateElement] = this; return ((!date) ? new Date() : date.clone()).add(c); }; /** * Creates a new Date() and subtract this (Number) from the date based on the preceding date element function (eg. second|minute|hour|day|month|year). * Example

	// Undeclared Numbers must be wrapped with parentheses. Requirment of JavaScript.
	(3).days().ago();
	(6).months().ago();

	// Declared Number variables do not require parentheses. 
	var n = 6;
	n.months().ago();
	
* * @return {Date} A new Date instance */ $N.ago = $N.before = function (date) { var c = {}, s = (this._dateElement[this._dateElement.length-1] !== "s") ? this._dateElement + "s" : this._dateElement; c[s] = this * -1; return ((!date) ? new Date() : date.clone()).add(c); }; // Do NOT modify the following string tokens. These tokens are used to build dynamic functions. // All culture-specific strings can be found in the CultureInfo files. var dx = ("sunday monday tuesday wednesday thursday friday saturday").split(/\s/), mx = ("january february march april may june july august september october november december").split(/\s/), px = ("Millisecond Second Minute Hour Day Week Month Year Quarter Weekday").split(/\s/), pxf = ("Milliseconds Seconds Minutes Hours Date Week Month FullYear Quarter").split(/\s/), nth = ("final first second third fourth fifth").split(/\s/), de; /** * Returns an object literal of all the date parts. * Example

	var o = new Date().toObject();
	
	// { year: 2008, month: 4, week: 20, day: 13, hour: 18, minute: 9, second: 32, millisecond: 812 }
	
	// The object properties can be referenced directly from the object.
	
	alert(o.day);  // alerts "13"
	alert(o.year); // alerts "2008"
	
* * @return {Date} An object literal representing the original date object. */ $P.toObject = function () { var o = {}; for (var i = 0; i < px.length; i++) { if (this["get" + pxf[i]]) { o[px[i].toLowerCase()] = this["get" + pxf[i]](); } } return o; }; /** * Returns a date created from an object literal. Ignores the .week property if set in the config. * Example

	var o = new Date().toObject();
	
	return Date.fromObject(o); // will return the same date. 

	var o2 = {month: 1, day: 20, hour: 18}; // birthday party!
	Date.fromObject(o2);
	
* * @return {Date} An object literal representing the original date object. */ $D.fromObject = function(config) { config.week = null; return Date.today().set(config); }; // Create day name functions and abbreviated day name functions (eg. monday(), friday(), fri()). var df = function (n) { return function () { if (this._is) { this._is = false; return this.getDay() === n; } if (this._move) { this._move = null; } if (this._nth !== null) { // If the .second() function was called earlier, remove the _orient // from the date, and then continue. // This is required because 'second' can be used in two different context. // // Example // // Date.today().add(1).second(); // Date.march().second().monday(); // // Things get crazy with the following... // Date.march().add(1).second().second().monday(); // but it works!! // if (this._isSecond) { this.addSeconds(this._orient * -1); } // make sure we reset _isSecond this._isSecond = false; var ntemp = this._nth; this._nth = null; var temp = this.clone().moveToLastDayOfMonth(); this.moveToNthOccurrence(n, ntemp); if (this > temp) { throw new RangeError($D.getDayName(n) + " does not occur " + ntemp + " times in the month of " + $D.getMonthName(temp.getMonth()) + " " + temp.getFullYear() + "."); } return this; } return this.moveToDayOfWeek(n, this._orient); }; }; var sdf = function (n) { return function () { var t = $D.today(), shift = n - t.getDay(); if (n === 0 && Date.CultureInfo.firstDayOfWeek === 1 && t.getDay() !== 0) { shift = shift + 7; } return t.addDays(shift); }; }; // Create month name functions and abbreviated month name functions (eg. january(), march(), mar()). var month_instance_functions = function (n) { return function () { if (this._is) { this._is = false; return this.getMonth() === n; } return this.moveToMonth(n, this._orient); }; }; var month_static_functions = function (n) { return function () { return $D.today().set({ month: n, day: 1 }); }; }; var processTerms = function (names, staticFunc, instanceFunc) { for (var i = 0; i < names.length; i++) { // Create constant static Name variables. $D[names[i].toUpperCase()] = $D[names[i].toUpperCase().substring(0, 3)] = i; // Create Name functions. $D[names[i]] = $D[names[i].substring(0, 3)] = staticFunc(i); // Create Name instance functions. $P[names[i]] = $P[names[i].substring(0, 3)] = instanceFunc(i); } }; processTerms(dx, sdf, df); processTerms(mx, month_static_functions, month_instance_functions); // Create date element functions and plural date element functions used with Date (eg. day(), days(), months()). var ef = function (j) { return function () { // if the .second() function was called earlier, the _orient // has alread been added. Just return this and reset _isSecond. if (this._isSecond) { this._isSecond = false; return this; } if (this._same) { this._same = this._is = false; var o1 = this.toObject(), o2 = (arguments[0] || new Date()).toObject(), v = "", k = j.toLowerCase(); // the substr trick with -1 doesn't work in IE8 or less k = (k[k.length-1] === "s") ? k.substring(0,k.length-1) : k; for (var m = (px.length - 1); m > -1; m--) { v = px[m].toLowerCase(); if (o1[v] !== o2[v]) { return false; } if (k === v) { break; } } return true; } if (j.substring(j.length - 1) !== "s") { j += "s"; } if (this._move) { this._move = null; } return this["add" + j](this._orient); }; }; var nf = function (n) { return function () { this._dateElement = n; return this; }; }; for (var k = 0; k < px.length; k++) { de = px[k].toLowerCase(); if(de !== "weekday") { // Create date element functions and plural date element functions used with Date (eg. day(), days(), months()). $P[de] = $P[de + "s"] = ef(px[k]); // Create date element functions and plural date element functions used with Number (eg. day(), days(), months()). $N[de] = $N[de + "s"] = nf(de + "s"); } } $P._ss = ef("Second"); var nthfn = function (n) { return function (dayOfWeek) { if (this._same) { return this._ss(arguments[0]); } if (dayOfWeek || dayOfWeek === 0) { return this.moveToNthOccurrence(dayOfWeek, n); } this._nth = n; // if the operator is 'second' add the _orient, then deal with it later... if (n === 2 && (dayOfWeek === undefined || dayOfWeek === null)) { this._isSecond = true; return this.addSeconds(this._orient); } return this; }; }; for (var l = 0; l < nth.length; l++) { $P[nth[l]] = (l === 0) ? nthfn(-1) : nthfn(l); } }()); (function () { "use strict"; Date.Parsing = { Exception: function (s) { this.message = "Parse error at '" + s.substring(0, 10) + " ...'"; } }; var $P = Date.Parsing; var dayOffsets = { standard: [0,31,59,90,120,151,181,212,243,273,304,334], leap: [0,31,60,91,121,152,182,213,244,274,305,335] }; $P.isLeapYear = function(year) { return ((year % 4 === 0) && (year % 100 !== 0)) || (year % 400 === 0); }; var utils = { multiReplace : function (str, hash ) { var key; for (key in hash) { if (Object.prototype.hasOwnProperty.call(hash, key)) { var regex; if (typeof hash[key] === "function") { } else { regex = (hash[key] instanceof RegExp) ? hash[key] : new RegExp(hash[key], "g"); } str = str.replace(regex, key); } } return str; }, getDayOfYearFromWeek : function (obj) { var d, jan4, offset; obj.weekDay = (!obj.weekDay && obj.weekDay !== 0) ? 1 : obj.weekDay; d = new Date(obj.year, 0, 4); jan4 = d.getDay() === 0 ? 7 : d.getDay(); // JS is 0 indexed on Sunday. offset = jan4+3; obj.dayOfYear = ((obj.week * 7) + (obj.weekDay === 0 ? 7 : obj.weekDay))-offset; return obj; }, getDayOfYear : function (obj, dayOffset) { if (!obj.dayOfYear) { obj = utils.getDayOfYearFromWeek(obj); } for (var i=0;i <= dayOffset.length;i++) { if (obj.dayOfYear < dayOffset[i] || i === dayOffset.length) { obj.day = obj.day ? obj.day : (obj.dayOfYear - dayOffset[i-1]); break; } else { obj.month = i; } } return obj; }, adjustForTimeZone : function (obj, date) { var offset; if (obj.zone.toUpperCase() === "Z" || (obj.zone_hours === 0 && obj.zone_minutes === 0)) { // it's UTC/GML so work out the current timeszone offset offset = -date.getTimezoneOffset(); } else { offset = (obj.zone_hours*60) + (obj.zone_minutes || 0); if (obj.zone_sign === "+") { offset *= -1; } offset -= date.getTimezoneOffset(); } date.setMinutes(date.getMinutes()+offset); return date; }, setDefaults : function (obj) { obj.year = obj.year || Date.today().getFullYear(); obj.hours = obj.hours || 0; obj.minutes = obj.minutes || 0; obj.seconds = obj.seconds || 0; obj.milliseconds = obj.milliseconds || 0; if (!(!obj.month && (obj.week || obj.dayOfYear))) { // if we have a month, or if we don't but don't have the day calculation data obj.month = obj.month || 0; obj.day = obj.day || 1; } return obj; }, dataNum: function (data, mod, explict, postProcess) { var dataNum = data*1; if (mod) { if (postProcess) { return data ? mod(data)*1 : data; } else { return data ? mod(dataNum) : data; } } else if (!explict){ return data ? dataNum : data; } else { return (data && typeof data !== "undefined") ? dataNum : data; } }, timeDataProcess: function (obj) { var timeObj = {}; for (var x in obj.data) { if (obj.data.hasOwnProperty(x)) { timeObj[x] = obj.ignore[x] ? obj.data[x] : utils.dataNum(obj.data[x], obj.mods[x], obj.explict[x], obj.postProcess[x]); } } if (obj.data.secmins) { obj.data.secmins = obj.data.secmins.replace(",", ".") * 60; if (!timeObj.minutes) { timeObj.minutes = obj.data.secmins; } else if (!timeObj.seconds) { timeObj.seconds = obj.data.secmins; } delete obj.secmins; } return timeObj; }, buildTimeObjectFromData: function (data) { var time = utils.timeDataProcess({ data: { year : data[1], month : data[5], day : data[7], week : data[8], dayOfYear : data[10], hours : data[15], zone_hours : data[23], zone_minutes : data[24], zone : data[21], zone_sign : data[22], weekDay : data[9], minutes: data[16], seconds: data[19], milliseconds: data[20], secmins: data[18] }, mods: { month: function(data) { return data-1; }, weekDay: function (data) { data = Math.abs(data); return (data === 7 ? 0 : data); }, minutes: function (data) { return data.replace(":",""); }, seconds: function (data) { return Math.floor( (data.replace(":","").replace(",","."))*1 ); }, milliseconds: function (data) { return (data.replace(",",".")*1000); } }, postProcess: { minutes: true, seconds: true, milliseconds: true }, explict: { zone_hours: true, zone_minutes: true }, ignore: { zone: true, zone_sign: true, secmins: true } }); return time; }, addToHash: function (hash, keys, data) { keys = keys; data = data; var len = keys.length; for (var i = 0; i < len; i++) { hash[keys[i]] = data[i]; } return hash; }, combineRegex: function (r1, r2) { return new RegExp("(("+r1.source+")\\s("+r2.source+"))"); }, getDateNthString: function(add, last, inc){ if (add) { return Date.today().addDays(inc).toString("d"); } else if (last) { return Date.today().last()[inc]().toString("d"); } }, buildRegexData: function (array) { var arr = []; var len = array.length; for (var i=0; i < len; i++) { if (Object.prototype.toString.call(array[i]) === '[object Array]') { // oldIE compat version of Array.isArray arr.push(this.combineRegex(array[i][0], array[i][1])); } else { arr.push(array[i]); } } return arr; } }; $P.processTimeObject = function (obj) { var date, dayOffset; utils.setDefaults(obj); dayOffset = ($P.isLeapYear(obj.year)) ? dayOffsets.leap : dayOffsets.standard; if (!obj.month && (obj.week || obj.dayOfYear)) { utils.getDayOfYear(obj, dayOffset); } else { obj.dayOfYear = dayOffset[obj.month] + obj.day; } date = new Date(obj.year, obj.month, obj.day, obj.hours, obj.minutes, obj.seconds, obj.milliseconds); if (obj.zone) { utils.adjustForTimeZone(obj, date); // adjust (and calculate) for timezone } return date; }; $P.ISO = { regex : /^([\+-]?\d{4}(?!\d{2}\b))((-?)((0[1-9]|1[0-2])(\3([12]\d|0[1-9]|3[01]))?|W([0-4]\d|5[0-3])(-?[1-7])?|(00[1-9]|0[1-9]\d|[12]\d{2}|3([0-5]\d|6[1-6])))([T\s]((([01]\d|2[0-4])((:?)[0-5]\d)?|24\:?00)([\.,]\d+(?!:))?)?(\17[0-5]\d([\.,]\d+)?)?\s?([zZ]|([\+-])([01]\d|2[0-3]):?([0-5]\d)?)?)?)?$/, parse : function (s) { var time, data = s.match(this.regex); if (!data || !data.length) { return null; } time = utils.buildTimeObjectFromData(data); if (!time.year || (!time.year && (!time.month && !time.day) && (!time.week && !time.dayOfYear)) ) { return null; } return $P.processTimeObject(time); } }; $P.Numeric = { isNumeric: function (e){return!isNaN(parseFloat(e))&&isFinite(e);}, regex: /\b([0-1]?[0-9])([0-3]?[0-9])([0-2]?[0-9]?[0-9][0-9])\b/i, parse: function (s) { var data, i, time = {}, order = Date.CultureInfo.dateElementOrder.split(""); if (!(this.isNumeric(s)) || // if it's non-numeric OR (s[0] === "+" && s[0] === "-")) { // It's an arithmatic string (eg +/-1000) return null; } if (s.length < 5 && s.indexOf(".") < 0 && s.indexOf("/") < 0) { // assume it's just a year. time.year = s; return $P.processTimeObject(time); } data = s.match(this.regex); if (!data || !data.length) { return null; } for (i=0; i < order.length; i++) { switch(order[i]) { case "d": time.day = data[i+1]; break; case "m": time.month = (data[i+1]-1); break; case "y": time.year = data[i+1]; break; } } return $P.processTimeObject(time); } }; $P.Normalizer = { regexData: function () { var $R = Date.CultureInfo.regexPatterns; return utils.buildRegexData([ $R.tomorrow, $R.yesterday, [$R.past, $R.mon], [$R.past, $R.tue], [$R.past, $R.wed], [$R.past, $R.thu], [$R.past, $R.fri], [$R.past, $R.sat], [$R.past, $R.sun] ]); }, basicReplaceHash : function() { var $R = Date.CultureInfo.regexPatterns; return { "January": $R.jan.source, "February": $R.feb, "March": $R.mar, "April": $R.apr, "May": $R.may, "June": $R.jun, "July": $R.jul, "August": $R.aug, "September": $R.sep, "October": $R.oct, "November": $R.nov, "December": $R.dec, "": /\bat\b/gi, " ": /\s{2,}/, "am": $R.inTheMorning, "9am": $R.thisMorning, "pm": $R.inTheEvening, "7pm":$R.thisEvening }; }, keys : function(){ return [ utils.getDateNthString(true, false, 1), // tomorrow utils.getDateNthString(true, false, -1), // yesterday utils.getDateNthString(false, true, "monday"), //last mon utils.getDateNthString(false, true, "tuesday"), //last tues utils.getDateNthString(false, true, "wednesday"), //last wed utils.getDateNthString(false, true, "thursday"), //last thurs utils.getDateNthString(false, true, "friday"), //last fri utils.getDateNthString(false, true, "saturday"), //last sat utils.getDateNthString(false, true, "sunday") //last sun ]; }, buildRegexFunctions: function () { var $R = Date.CultureInfo.regexPatterns; var __ = Date.i18n.__; var tomorrowRE = new RegExp("(\\b\\d\\d?("+__("AM")+"|"+__("PM")+")? )("+$R.tomorrow.source.slice(1)+")", "i"); // adapted tomorrow regex for AM PM relative dates var todayRE = new RegExp($R.today.source + "(?!\\s*([+-]))\\b"); // today, but excludes the math operators (eg "today + 2h") this.replaceFuncs = [ [todayRE, function (full) { return (full.length > 1) ? Date.today().toString("d") : full; }], [tomorrowRE, function(full, m1) { var t = Date.today().addDays(1).toString("d"); return (t + " " + m1); }], [$R.amThisMorning, function(str, am){return am;}], [$R.pmThisEvening, function(str, pm){return pm;}] ]; }, buildReplaceData: function () { this.buildRegexFunctions(); this.replaceHash = utils.addToHash(this.basicReplaceHash(), this.keys(), this.regexData()); }, stringReplaceFuncs: function (s) { for (var i=0; i < this.replaceFuncs.length; i++) { s = s.replace(this.replaceFuncs[i][0], this.replaceFuncs[i][1]); } return s; }, parse: function (s) { s = this.stringReplaceFuncs(s); s = utils.multiReplace(s, this.replaceHash); try { var n = s.split(/([\s\-\.\,\/\x27]+)/); if (n.length === 3 && $P.Numeric.isNumeric(n[0]) && $P.Numeric.isNumeric(n[2]) && (n[2].length >= 4)) { // ok, so we're dealing with x/year. But that's not a full date. // This fixes wonky dateElementOrder parsing when set to dmy order. if (Date.CultureInfo.dateElementOrder[0] === "d") { s = "1/" + n[0] + "/" + n[2]; // set to 1st of month and normalize the seperator } } } catch (e) {} return s; } }; $P.Normalizer.buildReplaceData(); }()); (function () { var $P = Date.Parsing; var _ = $P.Operators = { // // Tokenizers // rtoken: function (r) { // regex token return function (s) { var mx = s.match(r); if (mx) { return ([ mx[0], s.substring(mx[0].length) ]); } else { throw new $P.Exception(s); } }; }, token: function () { // whitespace-eating token return function (s) { return _.rtoken(new RegExp("^\\s*" + s + "\\s*"))(s); }; }, stoken: function (s) { // string token return _.rtoken(new RegExp("^" + s)); }, // Atomic Operators until: function (p) { return function (s) { var qx = [], rx = null; while (s.length) { try { rx = p.call(this, s); } catch (e) { qx.push(rx[0]); s = rx[1]; continue; } break; } return [ qx, s ]; }; }, many: function (p) { return function (s) { var rx = [], r = null; while (s.length) { try { r = p.call(this, s); } catch (e) { return [ rx, s ]; } rx.push(r[0]); s = r[1]; } return [ rx, s ]; }; }, // generator operators -- see below optional: function (p) { return function (s) { var r = null; try { r = p.call(this, s); } catch (e) { return [ null, s ]; } return [ r[0], r[1] ]; }; }, not: function (p) { return function (s) { try { p.call(this, s); } catch (e) { return [null, s]; } throw new $P.Exception(s); }; }, ignore: function (p) { return p ? function (s) { var r = null; r = p.call(this, s); return [null, r[1]]; } : null; }, product: function () { var px = arguments[0], qx = Array.prototype.slice.call(arguments, 1), rx = []; for (var i = 0 ; i < px.length ; i++) { rx.push(_.each(px[i], qx)); } return rx; }, cache: function (rule) { var cache = {}, cache_length = 0, cache_keys = [], CACHE_MAX = Date.Config.CACHE_MAX || 100000, r = null; var cacheCheck = function () { if (cache_length === CACHE_MAX) { // kill several keys, don't want to have to do this all the time... for (var i=0; i < 10; i++) { var key = cache_keys.shift(); if (key) { delete cache[key]; cache_length--; } } } }; return function (s) { cacheCheck(); try { r = cache[s] = (cache[s] || rule.call(this, s)); } catch (e) { r = cache[s] = e; } cache_length++; cache_keys.push(s); if (r instanceof $P.Exception) { throw r; } else { return r; } }; }, // vector operators -- see below any: function () { var px = arguments; return function (s) { var r = null; for (var i = 0; i < px.length; i++) { if (px[i] == null) { continue; } try { r = (px[i].call(this, s)); } catch (e) { r = null; } if (r) { return r; } } throw new $P.Exception(s); }; }, each: function () { var px = arguments; return function (s) { var rx = [], r = null; for (var i = 0; i < px.length ; i++) { if (px[i] == null) { continue; } try { r = (px[i].call(this, s)); } catch (e) { throw new $P.Exception(s); } rx.push(r[0]); s = r[1]; } return [ rx, s]; }; }, all: function () { var px = arguments, _ = _; return _.each(_.optional(px)); }, // delimited operators sequence: function (px, d, c) { d = d || _.rtoken(/^\s*/); c = c || null; if (px.length === 1) { return px[0]; } return function (s) { var r = null, q = null; var rx = []; for (var i = 0; i < px.length ; i++) { try { r = px[i].call(this, s); } catch (e) { break; } rx.push(r[0]); try { q = d.call(this, r[1]); } catch (ex) { q = null; break; } s = q[1]; } if (!r) { throw new $P.Exception(s); } if (q) { throw new $P.Exception(q[1]); } if (c) { try { r = c.call(this, r[1]); } catch (ey) { throw new $P.Exception(r[1]); } } return [ rx, (r?r[1]:s) ]; }; }, // // Composite Operators // between: function (d1, p, d2) { d2 = d2 || d1; var _fn = _.each(_.ignore(d1), p, _.ignore(d2)); return function (s) { var rx = _fn.call(this, s); return [[rx[0][0], r[0][2]], rx[1]]; }; }, list: function (p, d, c) { d = d || _.rtoken(/^\s*/); c = c || null; return (p instanceof Array ? _.each(_.product(p.slice(0, -1), _.ignore(d)), p.slice(-1), _.ignore(c)) : _.each(_.many(_.each(p, _.ignore(d))), px, _.ignore(c))); }, set: function (px, d, c) { d = d || _.rtoken(/^\s*/); c = c || null; return function (s) { // r is the current match, best the current 'best' match // which means it parsed the most amount of input var r = null, p = null, q = null, rx = null, best = [[], s], last = false; // go through the rules in the given set for (var i = 0; i < px.length ; i++) { // last is a flag indicating whether this must be the last element // if there is only 1 element, then it MUST be the last one q = null; p = null; r = null; last = (px.length === 1); // first, we try simply to match the current pattern // if not, try the next pattern try { r = px[i].call(this, s); } catch (e) { continue; } // since we are matching against a set of elements, the first // thing to do is to add r[0] to matched elements rx = [[r[0]], r[1]]; // if we matched and there is still input to parse and // we don't already know this is the last element, // we're going to next check for the delimiter ... // if there's none, or if there's no input left to parse // than this must be the last element after all ... if (r[1].length > 0 && ! last) { try { q = d.call(this, r[1]); } catch (ex) { last = true; } } else { last = true; } // if we parsed the delimiter and now there's no more input, // that means we shouldn't have parsed the delimiter at all // so don't update r and mark this as the last element ... if (!last && q[1].length === 0) { last = true; } // so, if this isn't the last element, we're going to see if // we can get any more matches from the remaining (unmatched) // elements ... if (!last) { // build a list of the remaining rules we can match against, // i.e., all but the one we just matched against var qx = []; for (var j = 0; j < px.length ; j++) { if (i !== j) { qx.push(px[j]); } } // now invoke recursively set with the remaining input // note that we don't include the closing delimiter ... // we'll check for that ourselves at the end p = _.set(qx, d).call(this, q[1]); // if we got a non-empty set as a result ... // (otw rx already contains everything we want to match) if (p[0].length > 0) { // update current result, which is stored in rx ... // basically, pick up the remaining text from p[1] // and concat the result from p[0] so that we don't // get endless nesting ... rx[0] = rx[0].concat(p[0]); rx[1] = p[1]; } } // at this point, rx either contains the last matched element // or the entire matched set that starts with this element. // now we just check to see if this variation is better than // our best so far, in terms of how much of the input is parsed if (rx[1].length < best[1].length) { best = rx; } // if we've parsed all the input, then we're finished if (best[1].length === 0) { break; } } // so now we've either gone through all the patterns trying them // as the initial match; or we found one that parsed the entire // input string ... // if best has no matches, just return empty set ... if (best[0].length === 0) { return best; } // if a closing delimiter is provided, then we have to check it also if (c) { // we try this even if there is no remaining input because the pattern // may well be optional or match empty input ... try { q = c.call(this, best[1]); } catch (ey) { throw new $P.Exception(best[1]); } // it parsed ... be sure to update the best match remaining input best[1] = q[1]; } // if we're here, either there was no closing delimiter or we parsed it // so now we have the best match; just return it! return best; }; }, forward: function (gr, fname) { return function (s) { return gr[fname].call(this, s); }; }, // // Translation Operators // replace: function (rule, repl) { return function (s) { var r = rule.call(this, s); return [repl, r[1]]; }; }, process: function (rule, fn) { return function (s) { var r = rule.call(this, s); return [fn.call(this, r[0]), r[1]]; }; }, min: function (min, rule) { return function (s) { var rx = rule.call(this, s); if (rx[0].length < min) { throw new $P.Exception(s); } return rx; }; } }; // Generator Operators And Vector Operators // Generators are operators that have a signature of F(R) => R, // taking a given rule and returning another rule, such as // ignore, which parses a given rule and throws away the result. // Vector operators are those that have a signature of F(R1,R2,...) => R, // take a list of rules and returning a new rule, such as each. // Generator operators are converted (via the following _generator // function) into functions that can also take a list or array of rules // and return an array of new rules as though the function had been // called on each rule in turn (which is what actually happens). // This allows generators to be used with vector operators more easily. // Example: // each(ignore(foo, bar)) instead of each(ignore(foo), ignore(bar)) // This also turns generators into vector operators, which allows // constructs like: // not(cache(foo, bar)) var _generator = function (op) { function gen() { var args = null, rx = [], px, i; if (arguments.length > 1) { args = Array.prototype.slice.call(arguments); } else if (arguments[0] instanceof Array) { args = arguments[0]; } if (args) { px = args.shift(); if (px.length > 0) { args.unshift(px[i]); rx.push(op.apply(null, args)); args.shift(); return rx; } } else { return op.apply(null, arguments); } } return gen; }; var gx = "optional not ignore cache".split(/\s/); for (var i = 0 ; i < gx.length ; i++) { _[gx[i]] = _generator(_[gx[i]]); } var _vector = function (op) { return function () { if (arguments[0] instanceof Array) { return op.apply(null, arguments[0]); } else { return op.apply(null, arguments); } }; }; var vx = "each any all".split(/\s/); for (var j = 0 ; j < vx.length ; j++) { _[vx[j]] = _vector(_[vx[j]]); } }()); (function () { var $D = Date; var flattenAndCompact = function (ax) { var rx = []; for (var i = 0; i < ax.length; i++) { if (ax[i] instanceof Array) { rx = rx.concat(flattenAndCompact(ax[i])); } else { if (ax[i]) { rx.push(ax[i]); } } } return rx; }; var parseMeridian = function () { if (this.meridian && (this.hour || this.hour === 0)) { if (this.meridian === "a" && this.hour > 11 && Date.Config.strict24hr){ throw "Invalid hour and meridian combination"; } else if (this.meridian === "p" && this.hour < 12 && Date.Config.strict24hr){ throw "Invalid hour and meridian combination"; } else if (this.meridian === "p" && this.hour < 12) { this.hour = this.hour + 12; } else if (this.meridian === "a" && this.hour === 12) { this.hour = 0; } } }; var setDefaults = function () { var now = new Date(); if ((this.hour || this.minute) && (!this.month && !this.year && !this.day)) { this.day = now.getDate(); } if (!this.year) { this.year = now.getFullYear(); } if (!this.month && this.month !== 0) { this.month = now.getMonth(); } if (!this.day) { this.day = 1; } if (!this.hour) { this.hour = 0; } if (!this.minute) { this.minute = 0; } if (!this.second) { this.second = 0; } if (!this.millisecond) { this.millisecond = 0; } }; var finishUtils = { getToday: function () { if (this.now || "hour minute second".indexOf(this.unit) !== -1) { return new Date(); } else { return $D.today(); } }, setDaysFromWeekday: function (today, orient){ var gap; orient = orient || 1; this.unit = "day"; gap = ($D.getDayNumberFromName(this.weekday) - today.getDay()); this.days = gap ? ((gap + (orient * 7)) % 7) : (orient * 7); return this; }, setMonthsFromMonth: function (today, orient) { var gap; orient = orient || 1; this.unit = "month"; gap = (this.month - today.getMonth()); this.months = gap ? ((gap + (orient * 12)) % 12) : (orient * 12); this.month = null; return this; }, setDMYFromWeekday: function () { var d = Date[this.weekday](); this.day = d.getDate(); if (!this.month) { this.month = d.getMonth(); } this.year = d.getFullYear(); return this; }, setUnitValue: function (orient) { if (!this.value && this.operator && this.operator !== null && this[this.unit + "s"] && this[this.unit + "s"] !== null) { this[this.unit + "s"] = this[this.unit + "s"] + ((this.operator === "add") ? 1 : -1) + (this.value||0) * orient; } else if (this[this.unit + "s"] == null || this.operator != null) { if (!this.value) { this.value = 1; } this[this.unit + "s"] = this.value * orient; } }, generateDateFromWeeks: function () { var weekday = (this.weekday !== undefined) ? this.weekday : "today"; var d = Date[weekday]().addWeeks(this.weeks); if (this.now) { d.setTimeToNow(); } return d; } }; $D.Translator = { hour: function (s) { return function () { this.hour = Number(s); }; }, minute: function (s) { return function () { this.minute = Number(s); }; }, second: function (s) { return function () { this.second = Number(s); }; }, /* for ss.s format */ secondAndMillisecond: function (s) { return function () { var mx = s.match(/^([0-5][0-9])\.([0-9]{1,3})/); this.second = Number(mx[1]); this.millisecond = Number(mx[2]); }; }, meridian: function (s) { return function () { this.meridian = s.slice(0, 1).toLowerCase(); }; }, timezone: function (s) { return function () { var n = s.replace(/[^\d\+\-]/g, ""); if (n.length) { this.timezoneOffset = Number(n); } else { this.timezone = s.toLowerCase(); } }; }, day: function (x) { var s = x[0]; return function () { this.day = Number(s.match(/\d+/)[0]); if (this.day < 1) { throw "invalid day"; } }; }, month: function (s) { return function () { this.month = (s.length === 3) ? "jan feb mar apr may jun jul aug sep oct nov dec".indexOf(s)/4 : Number(s) - 1; if (this.month < 0) { throw "invalid month"; } }; }, year: function (s) { return function () { var n = Number(s); this.year = ((s.length > 2) ? n : (n + (((n + 2000) < Date.CultureInfo.twoDigitYearMax) ? 2000 : 1900))); }; }, rday: function (s) { return function () { switch (s) { case "yesterday": this.days = -1; break; case "tomorrow": this.days = 1; break; case "today": this.days = 0; break; case "now": this.days = 0; this.now = true; break; } }; }, finishExact: function (x) { var d; x = (x instanceof Array) ? x : [x]; for (var i = 0 ; i < x.length ; i++) { if (x[i]) { x[i].call(this); } } setDefaults.call(this); parseMeridian.call(this); if (this.day > $D.getDaysInMonth(this.year, this.month)) { throw new RangeError(this.day + " is not a valid value for days."); } d = new Date(this.year, this.month, this.day, this.hour, this.minute, this.second, this.millisecond); if (this.year < 100) { d.setFullYear(this.year); // means years less that 100 are process correctly. JS will parse it otherwise as 1900-1999. } if (this.timezone) { d.set({ timezone: this.timezone }); } else if (this.timezoneOffset) { d.set({ timezoneOffset: this.timezoneOffset }); } return d; }, finish: function (x) { var today, expression, orient, temp; x = (x instanceof Array) ? flattenAndCompact(x) : [ x ]; if (x.length === 0) { return null; } for (var i = 0 ; i < x.length ; i++) { if (typeof x[i] === "function") { x[i].call(this); } } if (this.now && !this.unit && !this.operator) { return new Date(); } else { today = finishUtils.getToday.call(this); } expression = !!(this.days && this.days !== null || this.orient || this.operator); orient = ((this.orient === "past" || this.operator === "subtract") ? -1 : 1); if (this.month && this.unit === "week") { this.value = this.month + 1; delete this.month; delete this.day; } if ((this.month || this.month === 0) && "year day hour minute second".indexOf(this.unit) !== -1) { if (!this.value) { this.value = this.month + 1; } this.month = null; expression = true; } if (!expression && this.weekday && !this.day && !this.days) { finishUtils.setDMYFromWeekday.call(this); } if (expression && this.weekday && this.unit !== "month" && this.unit !== "week") { finishUtils.setDaysFromWeekday.call(this, today, orient); } if (this.weekday && this.unit !== "week" && !this.day && !this.days) { temp = Date[this.weekday](); this.day = temp.getDate(); if (temp.getMonth() !== today.getMonth()) { this.month = temp.getMonth(); } } if (this.month && this.unit === "day" && this.operator) { if (!this.value) { this.value = (this.month + 1); } this.month = null; } if (this.value != null && this.month != null && this.year != null) { this.day = this.value * 1; } if (this.month && !this.day && this.value) { today.set({ day: this.value * 1 }); if (!expression) { this.day = this.value * 1; } } if (!this.month && this.value && this.unit === "month" && !this.now) { this.month = this.value; expression = true; } if (expression && (this.month || this.month === 0) && this.unit !== "year") { finishUtils.setMonthsFromMonth.call(this, today, orient); } if (!this.unit) { this.unit = "day"; } finishUtils.setUnitValue.call(this, orient); parseMeridian.call(this); if ((this.month || this.month === 0) && !this.day) { this.day = 1; } if (!this.orient && !this.operator && this.unit === "week" && this.value && !this.day && !this.month) { return Date.today().setWeek(this.value); } if (this.unit === "week" && this.weeks && !this.day && !this.month) { return finishUtils.generateDateFromWeeks.call(this); } if (expression && this.timezone && this.day && this.days) { this.day = this.days; } if (expression){ today.add(this); } else { today.set(this); } if (this.timezone) { this.timezone = this.timezone.toUpperCase(); var offset = $D.getTimezoneOffset(this.timezone); var timezone; if (today.hasDaylightSavingTime()) { // lets check that we're being sane with timezone setting timezone = $D.getTimezoneAbbreviation(offset, today.isDaylightSavingTime()); if (timezone !== this.timezone) { // bugger, we're in a place where things like EST vs EDT matters. if (today.isDaylightSavingTime()) { today.addHours(-1); } else { today.addHours(1); } } } today.setTimezoneOffset(offset); } return today; } }; }()); (function () { var $D = Date; $D.Grammar = {}; var _ = $D.Parsing.Operators, g = $D.Grammar, t = $D.Translator, _fn; // Allow rolling up into general purpose rules _fn = function () { return _.each(_.any.apply(null, arguments), _.not(g.ctoken2("timeContext"))); }; g.datePartDelimiter = _.rtoken(/^([\s\-\.\,\/\x27]+)/); g.timePartDelimiter = _.stoken(":"); g.whiteSpace = _.rtoken(/^\s*/); g.generalDelimiter = _.rtoken(/^(([\s\,]|at|@|on)+)/); var _C = {}; g.ctoken = function (keys) { var fn = _C[keys]; if (! fn) { var c = Date.CultureInfo.regexPatterns; var kx = keys.split(/\s+/), px = []; for (var i = 0; i < kx.length ; i++) { px.push(_.replace(_.rtoken(c[kx[i]]), kx[i])); } fn = _C[keys] = _.any.apply(null, px); } return fn; }; g.ctoken2 = function (key) { return _.rtoken(Date.CultureInfo.regexPatterns[key]); }; var cacheProcessRtoken = function (key, token, type, eachToken) { if (eachToken) { g[key] = _.cache(_.process(_.each(_.rtoken(token),_.optional(g.ctoken2(eachToken))), type)); } else { g[key] = _.cache(_.process(_.rtoken(token), type)); } }; var cacheProcessCtoken = function (token, type) { return _.cache(_.process(g.ctoken2(token), type)); }; var _F = {}; //function cache var _get = function (f) { _F[f] = (_F[f] || g.format(f)[0]); return _F[f]; }; g.allformats = function (fx) { var rx = []; if (fx instanceof Array) { for (var i = 0; i < fx.length; i++) { rx.push(_get(fx[i])); } } else { rx.push(_get(fx)); } return rx; }; g.formats = function (fx) { if (fx instanceof Array) { var rx = []; for (var i = 0 ; i < fx.length ; i++) { rx.push(_get(fx[i])); } return _.any.apply(null, rx); } else { return _get(fx); } }; var grammarFormats = { timeFormats: function(){ var i, RTokenKeys = [ "h", "hh", "H", "HH", "m", "mm", "s", "ss", "ss.s", "z", "zz" ], RToken = [ /^(0[0-9]|1[0-2]|[1-9])/, /^(0[0-9]|1[0-2])/, /^([0-1][0-9]|2[0-3]|[0-9])/, /^([0-1][0-9]|2[0-3])/, /^([0-5][0-9]|[0-9])/, /^[0-5][0-9]/, /^([0-5][0-9]|[0-9])/, /^[0-5][0-9]/, /^[0-5][0-9]\.[0-9]{1,3}/, /^((\+|\-)\s*\d\d\d\d)|((\+|\-)\d\d\:?\d\d)/, /^((\+|\-)\s*\d\d\d\d)|((\+|\-)\d\d\:?\d\d)/ ], tokens = [ t.hour, t.hour, t.hour, t.hour, t.minute, t.minute, t.second, t.second, t.secondAndMillisecond, t.timezone, t.timezone ]; for (i=0; i < RTokenKeys.length; i++) { cacheProcessRtoken(RTokenKeys[i], RToken[i], tokens[i]); } g.hms = _.cache(_.sequence([g.H, g.m, g.s], g.timePartDelimiter)); g.t = cacheProcessCtoken("shortMeridian", t.meridian); g.tt = cacheProcessCtoken("longMeridian", t.meridian); g.zzz = cacheProcessCtoken("timezone", t.timezone); g.timeSuffix = _.each(_.ignore(g.whiteSpace), _.set([ g.tt, g.zzz ])); g.time = _.each(_.optional(_.ignore(_.stoken("T"))), g.hms, g.timeSuffix); }, dateFormats: function () { // pre-loaded rules for different date part order preferences var _setfn = function () { return _.set(arguments, g.datePartDelimiter); }; var i, RTokenKeys = [ "d", "dd", "M", "MM", "y", "yy", "yyy", "yyyy" ], RToken = [ /^([0-2]\d|3[0-1]|\d)/, /^([0-2]\d|3[0-1])/, /^(1[0-2]|0\d|\d)/, /^(1[0-2]|0\d)/, /^(\d+)/, /^(\d\d)/, /^(\d\d?\d?\d?)/, /^(\d\d\d\d)/ ], tokens = [ t.day, t.day, t.month, t.month, t.year, t.year, t.year, t.year ], eachToken = [ "ordinalSuffix", "ordinalSuffix" ]; for (i=0; i < RTokenKeys.length; i++) { cacheProcessRtoken(RTokenKeys[i], RToken[i], tokens[i], eachToken[i]); } g.MMM = g.MMMM = _.cache(_.process(g.ctoken("jan feb mar apr may jun jul aug sep oct nov dec"), t.month)); g.ddd = g.dddd = _.cache(_.process(g.ctoken("sun mon tue wed thu fri sat"), function (s) { return function () { this.weekday = s; }; } )); g.day = _fn(g.d, g.dd); g.month = _fn(g.M, g.MMM); g.year = _fn(g.yyyy, g.yy); g.mdy = _setfn(g.ddd, g.month, g.day, g.year); g.ymd = _setfn(g.ddd, g.year, g.month, g.day); g.dmy = _setfn(g.ddd, g.day, g.month, g.year); g.date = function (s) { return ((g[Date.CultureInfo.dateElementOrder] || g.mdy).call(this, s)); }; }, relative: function () { // relative date / time expressions g.orientation = _.process(g.ctoken("past future"), function (s) { return function () { this.orient = s; }; } ); g.operator = _.process(g.ctoken("add subtract"), function (s) { return function () { this.operator = s; }; } ); g.rday = _.process(g.ctoken("yesterday tomorrow today now"), t.rday); g.unit = _.process(g.ctoken("second minute hour day week month year"), function (s) { return function () { this.unit = s; }; } ); } }; g.buildGrammarFormats = function () { // these need to be rebuilt every time the language changes. _C = {}; grammarFormats.timeFormats(); grammarFormats.dateFormats(); grammarFormats.relative(); g.value = _.process(_.rtoken(/^([-+]?\d+)?(st|nd|rd|th)?/), function (s) { return function () { this.value = s.replace(/\D/g, ""); }; } ); g.expression = _.set([g.rday, g.operator, g.value, g.unit, g.orientation, g.ddd, g.MMM ]); g.format = _.process(_.many( _.any( // translate format specifiers into grammar rules _.process( _.rtoken(/^(dd?d?d?(?!e)|MM?M?M?|yy?y?y?|hh?|HH?|mm?|ss?|tt?|zz?z?)/), function (fmt) { if (g[fmt]) { return g[fmt]; } else { throw $D.Parsing.Exception(fmt); } } ), // translate separator tokens into token rules _.process(_.rtoken(/^[^dMyhHmstz]+/), // all legal separators function (s) { return _.ignore(_.stoken(s)); } ) ) ), // construct the parser ... function (rules) { return _.process(_.each.apply(null, rules), t.finishExact); } ); // starting rule for general purpose grammar g._start = _.process(_.set([ g.date, g.time, g.expression ], g.generalDelimiter, g.whiteSpace), t.finish); }; g.buildGrammarFormats(); // parsing date format specifiers - ex: "h:m:s tt" // this little guy will generate a custom parser based // on the format string, ex: g.format("h:m:s tt") // check for these formats first g._formats = g.formats([ "\"yyyy-MM-ddTHH:mm:ssZ\"", "yyyy-MM-ddTHH:mm:ss.sz", "yyyy-MM-ddTHH:mm:ssZ", "yyyy-MM-ddTHH:mm:ssz", "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-ddTHH:mmZ", "yyyy-MM-ddTHH:mmz", "yyyy-MM-ddTHH:mm", "ddd, MMM dd, yyyy H:mm:ss tt", "ddd MMM d yyyy HH:mm:ss zzz", "MMddyyyy", "ddMMyyyy", "Mddyyyy", "ddMyyyy", "Mdyyyy", "dMyyyy", "yyyy", "Mdyy", "dMyy", "d" ]); // real starting rule: tries selected formats first, // then general purpose rule g.start = function (s) { try { var r = g._formats.call({}, s); if (r[1].length === 0) { return r; } } catch (e) {} return g._start.call({}, s); }; }()); (function () { var $D = Date; /** * @desc Converts the specified string value into its JavaScript Date equivalent using CultureInfo specific format information. * * Example

	///////////
	// Dates //
	///////////

	// 15-Oct-2004
	var d1 = Date.parse("10/15/2004");

	// 15-Oct-2004
	var d1 = Date.parse("15-Oct-2004");

	// 15-Oct-2004
	var d1 = Date.parse("2004.10.15");

	//Fri Oct 15, 2004
	var d1 = Date.parse("Fri Oct 15, 2004");

	///////////
	// Times //
	///////////

	// Today at 10 PM.
	var d1 = Date.parse("10 PM");

	// Today at 10:30 PM.
	var d1 = Date.parse("10:30 P.M.");

	// Today at 6 AM.
	var d1 = Date.parse("06am");

	/////////////////////
	// Dates and Times //
	/////////////////////

	// 8-July-2004 @ 10:30 PM
	var d1 = Date.parse("July 8th, 2004, 10:30 PM");

	// 1-July-2004 @ 10:30 PM
	var d1 = Date.parse("2004-07-01T22:30:00");

	////////////////////
	// Relative Dates //
	////////////////////

	// Returns today's date. The string "today" is culture specific.
	var d1 = Date.parse("today");

	// Returns yesterday's date. The string "yesterday" is culture specific.
	var d1 = Date.parse("yesterday");

	// Returns the date of the next thursday.
	var d1 = Date.parse("Next thursday");

	// Returns the date of the most previous monday.
	var d1 = Date.parse("last monday");

	// Returns today's day + one year.
	var d1 = Date.parse("next year");

	///////////////
	// Date Math //
	///////////////

	// Today + 2 days
	var d1 = Date.parse("t+2");

	// Today + 2 days
	var d1 = Date.parse("today + 2 days");

	// Today + 3 months
	var d1 = Date.parse("t+3m");

	// Today - 1 year
	var d1 = Date.parse("today - 1 year");

	// Today - 1 year
	var d1 = Date.parse("t-1y"); 


	/////////////////////////////
	// Partial Dates and Times //
	/////////////////////////////

	// July 15th of this year.
	var d1 = Date.parse("July 15");

	// 15th day of current day and year.
	var d1 = Date.parse("15");

	// July 1st of current year at 10pm.
	var d1 = Date.parse("7/1 10pm");
	
* * @param {String} The string value to convert into a Date object [Required] * @return {Date} A Date object or null if the string cannot be converted into a Date. */ var parseUtils = { removeOrds: function (s) { ords = s.match(/\b(\d+)(?:st|nd|rd|th)\b/); // find ordinal matches s = ((ords && ords.length === 2) ? s.replace(ords[0], ords[1]) : s); return s; }, grammarParser: function (s) { var r = null; try { r = $D.Grammar.start.call({}, s.replace(/^\s*(\S*(\s+\S+)*)\s*$/, "$1")); } catch (e) { return null; } return ((r[1].length === 0) ? r[0] : null); }, nativeFallback: function(s) { var t; try { // ok we haven't parsed it, last ditch attempt with the built-in parser. t = Date._parse(s); return (t || t === 0) ? new Date(t) : null; } catch (e) { return null; } } }; function parse (s) { var d; if (!s) { return null; } if (s instanceof Date) { return s.clone(); } if (s.length >= 4 && s.charAt(0) !== "0" && s.charAt(0) !== "+"&& s.charAt(0) !== "-") { // ie: 2004 will pass, 0800 won't. // Start with specific formats d = $D.Parsing.ISO.parse(s) || $D.Parsing.Numeric.parse(s); } if (d instanceof Date && !isNaN(d.getTime())) { return d; } else { // find ordinal dates (1st, 3rd, 8th, etc and remove them as they cause parsing issues) s = $D.Parsing.Normalizer.parse(parseUtils.removeOrds(s)); d = parseUtils.grammarParser(s); if (d !== null) { return d; } else { return parseUtils.nativeFallback(s); } } } if (!$D._parse) { $D._parse = $D.parse; } $D.parse = parse; Date.getParseFunction = function (fx) { var fns = Date.Grammar.allformats(fx); return function (s) { var r = null; for (var i = 0; i < fns.length; i++) { try { r = fns[i].call({}, s); } catch (e) { continue; } if (r[1].length === 0) { return r[0]; } } return null; }; }; /** * Converts the specified string value into its JavaScript Date equivalent using the specified format {String} or formats {Array} and the CultureInfo specific format information. * The format of the string value must match one of the supplied formats exactly. * * Example

	// 15-Oct-2004
	var d1 = Date.parseExact("10/15/2004", "M/d/yyyy");

	// 15-Oct-2004
	var d1 = Date.parse("15-Oct-2004", "M-ddd-yyyy");

	// 15-Oct-2004
	var d1 = Date.parse("2004.10.15", "yyyy.MM.dd");

	// Multiple formats
	var d1 = Date.parseExact("10/15/2004", ["M/d/yyyy", "MMMM d, yyyy"]);
	
* * @param {String} The string value to convert into a Date object [Required]. * @param {Object} The expected format {String} or an array of expected formats {Array} of the date string [Required]. * @return {Date} A Date object or null if the string cannot be converted into a Date. */ $D.parseExact = function (s, fx) { return $D.getParseFunction(fx)(s); }; }()); (function () { var $D = Date, $P = $D.prototype, // $C = $D.CultureInfo, // not used atm p = function (s, l) { if (!l) { l = 2; } return ("000" + s).slice(l * -1); }; /** * Converts a PHP format string to Java/.NET format string. * A PHP format string can be used with ._format or .format. * A Java/.NET format string can be used with .toString(). * The .parseExact function will only accept a Java/.NET format string * * Example * var f1 = "%m/%d/%y" * var f2 = Date.normalizeFormat(f1); // "MM/dd/yy" * * new Date().format(f1); // "04/13/08" * new Date()._format(f1); // "04/13/08" * new Date().toString(f2); // "04/13/08" * * var date = Date.parseExact("04/13/08", f2); // Sun Apr 13 2008 * * @param {String} A PHP format string consisting of one or more format spcifiers. * @return {String} The PHP format converted to a Java/.NET format string. */ var normalizerSubstitutions = { "d" : "dd", "%d": "dd", "D" : "ddd", "%a": "ddd", "j" : "dddd", "l" : "dddd", "%A": "dddd", "S" : "S", "F" : "MMMM", "%B": "MMMM", "m" : "MM", "%m": "MM", "M" : "MMM", "%b": "MMM", "%h": "MMM", "n" : "M", "Y" : "yyyy", "%Y": "yyyy", "y" : "yy", "%y": "yy", "g" : "h", "%I": "h", "G" : "H", "h" : "hh", "H" : "HH", "%H": "HH", "i" : "mm", "%M": "mm", "s" : "ss", "%S": "ss", "%r": "hh:mm tt", "%R": "H:mm", "%T": "H:mm:ss", "%X": "t", "%x": "d", "%e": "d", "%D": "MM/dd/yy", "%n": "\\n", "%t": "\\t", "e" : "z", "T" : "z", "%z": "z", "%Z": "z", "Z" : "ZZ", "N" : "u", "w" : "u", "%w": "u", "W" : "W", "%V": "W" }; var normalizer = { substitutes: function (m) { return normalizerSubstitutions[m]; }, interpreted: function (m, x) { var y; switch (m) { case "%u": return x.getDay() + 1; case "z": return x.getOrdinalNumber(); case "%j": return p(x.getOrdinalNumber(), 3); case "%U": var d1 = x.clone().set({month: 0, day: 1}).addDays(-1).moveToDayOfWeek(0), d2 = x.clone().addDays(1).moveToDayOfWeek(0, -1); return (d2 < d1) ? "00" : p((d2.getOrdinalNumber() - d1.getOrdinalNumber()) / 7 + 1); case "%W": return p(x.getWeek()); case "t": return $D.getDaysInMonth(x.getFullYear(), x.getMonth()); case "o": case "%G": return x.setWeek(x.getISOWeek()).toString("yyyy"); case "%g": return x._format("%G").slice(-2); case "a": case "%p": return t("tt").toLowerCase(); case "A": return t("tt").toUpperCase(); case "u": return p(x.getMilliseconds(), 3); case "I": return (x.isDaylightSavingTime()) ? 1 : 0; case "O": return x.getUTCOffset(); case "P": y = x.getUTCOffset(); return y.substring(0, y.length - 2) + ":" + y.substring(y.length - 2); case "B": var now = new Date(); return Math.floor(((now.getHours() * 3600) + (now.getMinutes() * 60) + now.getSeconds() + (now.getTimezoneOffset() + 60) * 60) / 86.4); case "c": return x.toISOString().replace(/\"/g, ""); case "U": return $D.strtotime("now"); case "%c": return t("d") + " " + t("t"); case "%C": return Math.floor(x.getFullYear() / 100 + 1); } }, shouldOverrideDefaults: function (m) { switch (m) { case "%e": return true; default: return false; } }, parse: function (m, context) { var formatString, c = context || new Date(); formatString = normalizer.substitutes(m); if (formatString) { return formatString; } formatString = normalizer.interpreted(m, c); if (formatString) { return formatString; } else { return m; } } }; $D.normalizeFormat = function (format, context) { return format.replace(/(%|\\)?.|%%/g, function(t){ return normalizer.parse(t, context); }); }; /** * Format a local Unix timestamp according to locale settings * * Example: * Date.strftime("%m/%d/%y", new Date()); // "04/13/08" * Date.strftime("c", "2008-04-13T17:52:03Z"); // "04/13/08" * * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @param {Number|String} The number representing the number of seconds that have elapsed since January 1, 1970 (local time). * @return {String} A string representation of the current Date object. */ $D.strftime = function (format, time) { var d = Date.parse(time); return d._format(format); }; /** * Parse any textual datetime description into a Unix timestamp. * A Unix timestamp is the number of seconds that have elapsed since January 1, 1970 (midnight UTC/GMT). * * Example: * Date.strtotime("04/13/08"); // 1208044800 * Date.strtotime("1970-01-01T00:00:00Z"); // 0 * * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @param {Object} A string or date object. * @return {String} A string representation of the current Date object. */ $D.strtotime = function (time) { var d = $D.parse(time); return Math.round($D.UTC(d.getUTCFullYear(), d.getUTCMonth(), d.getUTCDate(), d.getUTCHours(), d.getUTCMinutes(), d.getUTCSeconds(), d.getUTCMilliseconds()) / 1000); }; /** * Converts the value of the current Date object to its equivalent string representation using a PHP/Unix style of date format specifiers. * Format Specifiers * Format Description Example * ------ --------------------------------------------------------------------------- ----------------------- * %a abbreviated weekday name according to the current localed "Mon" through "Sun" * %A full weekday name according to the current localed "Sunday" through "Saturday" * %b abbreviated month name according to the current localed "Jan" through "Dec" * %B full month name according to the current locale "January" through "December" * %c preferred date and time representation for the current locale "4/13/2008 12:33 PM" * %C century number (the year divided by 100 and truncated to an integer) "00" to "99" * %d day of the month as a decimal number "01" to "31" * %D same as %m/%d/%y "04/13/08" * %e day of the month as a decimal number, a single digit is preceded by a space "1" to "31" * %g like %G, but without the century "08" * %G The 4-digit year corresponding to the ISO week number (see %V). "2008" * This has the same format and value as %Y, except that if the ISO week number * belongs to the previous or next year, that year is used instead. * %h same as %b "Jan" through "Dec" * %H hour as a decimal number using a 24-hour clock. "00" to "23" * %I hour as a decimal number using a 12-hour clock. "01" to "12" * %j day of the year as a decimal number. "001" to "366" * %m month as a decimal number. "01" to "12" * %M minute as a decimal number. "00" to "59" * %n newline character "\n" * %p either "am" or "pm" according to the given time value, or the "am" or "pm" * corresponding strings for the current locale. * %r time in a.m. and p.m. notation "8:44 PM" * %R time in 24 hour notation "20:44" * %S second as a decimal number "00" to "59" * %t tab character "\t" * %T current time, equal to %H:%M:%S "12:49:11" * %u weekday as a decimal number ["1", "7"], with "1" representing Monday "1" to "7" * %U week number of the current year as a decimal number, starting with the "0" to ("52" or "53") * first Sunday as the first day of the first week * %V The ISO 8601:1988 week number of the current year as a decimal number, "00" to ("52" or "53") * range 01 to 53, where week 1 is the first week that has at least 4 days * in the current year, and with Monday as the first day of the week. * (Use %G or %g for the year component that corresponds to the week number * for the specified timestamp.) * %W week number of the current year as a decimal number, starting with the "00" to ("52" or "53") * first Monday as the first day of the first week * %w day of the week as a decimal, Sunday being "0" "0" to "6" * %x preferred date representation for the current locale without the time "4/13/2008" * %X preferred time representation for the current locale without the date "12:53:05" * %y year as a decimal number without a century "00" "99" * %Y year as a decimal number including the century "2008" * %Z time zone or name or abbreviation "UTC", "EST", "PST" * %z same as %Z * %% a literal "%" characters "%" * d Day of the month, 2 digits with leading zeros "01" to "31" * D A textual representation of a day, three letters "Mon" through "Sun" * j Day of the month without leading zeros "1" to "31" * l A full textual representation of the day of the week (lowercase "L") "Sunday" through "Saturday" * N ISO-8601 numeric representation of the day of the week (added in PHP 5.1.0) "1" (for Monday) through "7" (for Sunday) * S English ordinal suffix for the day of the month, 2 characters "st", "nd", "rd" or "th". Works well with j * w Numeric representation of the day of the week "0" (for Sunday) through "6" (for Saturday) * z The day of the year (starting from "0") "0" through "365" * W ISO-8601 week number of year, weeks starting on Monday "00" to ("52" or "53") * F A full textual representation of a month, such as January or March "January" through "December" * m Numeric representation of a month, with leading zeros "01" through "12" * M A short textual representation of a month, three letters "Jan" through "Dec" * n Numeric representation of a month, without leading zeros "1" through "12" * t Number of days in the given month "28" through "31" * L Whether it's a leap year "1" if it is a leap year, "0" otherwise * o ISO-8601 year number. This has the same value as Y, except that if the "2008" * ISO week number (W) belongs to the previous or next year, that year * is used instead. * Y A full numeric representation of a year, 4 digits "2008" * y A two digit representation of a year "08" * a Lowercase Ante meridiem and Post meridiem "am" or "pm" * A Uppercase Ante meridiem and Post meridiem "AM" or "PM" * B Swatch Internet time "000" through "999" * g 12-hour format of an hour without leading zeros "1" through "12" * G 24-hour format of an hour without leading zeros "0" through "23" * h 12-hour format of an hour with leading zeros "01" through "12" * H 24-hour format of an hour with leading zeros "00" through "23" * i Minutes with leading zeros "00" to "59" * s Seconds, with leading zeros "00" through "59" * u Milliseconds "54321" * e Timezone identifier "UTC", "EST", "PST" * I Whether or not the date is in daylight saving time (uppercase i) "1" if Daylight Saving Time, "0" otherwise * O Difference to Greenwich time (GMT) in hours "+0200", "-0600" * P Difference to Greenwich time (GMT) with colon between hours and minutes "+02:00", "-06:00" * T Timezone abbreviation "UTC", "EST", "PST" * Z Timezone offset in seconds. The offset for timezones west of UTC is "-43200" through "50400" * always negative, and for those east of UTC is always positive. * c ISO 8601 date "2004-02-12T15:19:21+00:00" * r RFC 2822 formatted date "Thu, 21 Dec 2000 16:01:07 +0200" * U Seconds since the Unix Epoch (January 1 1970 00:00:00 GMT) "0" * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @return {String} A string representation of the current Date object. */ var formatReplace = function (context) { return function (m) { var formatString, override = false; if (m.charAt(0) === "\\" || m.substring(0, 2) === "%%") { return m.replace("\\", "").replace("%%", "%"); } override = normalizer.shouldOverrideDefaults(m); formatString = $D.normalizeFormat(m, context); if (formatString) { return context.toString(formatString, override); } }; }; $P._format = function (format) { var formatter = formatReplace(this); if (!format) { return this._toString(); } else { return format.replace(/(%|\\)?.|%%/g, formatter); } }; if (!$P.format) { $P.format = $P._format; } }()); (function () { "use strict"; var gFn = function (attr) { return function () { return this[attr]; }; }; var sFn = function (attr) { return function (val) { this[attr] = val; return this; }; }; var attrs = ["years", "months", "days", "hours", "minutes", "seconds", "milliseconds"]; var addSetFuncs = function (context, attrs) { for (var i = 0; i < attrs.length ; i++) { var $a = attrs[i], $b = $a.slice(0, 1).toUpperCase() + $a.slice(1); context.prototype[$a] = 0; context.prototype["get" + $b] = gFn($a); context.prototype["set" + $b] = sFn($a); } }; /** * new TimeSpan(milliseconds); * new TimeSpan(days, hours, minutes, seconds); * new TimeSpan(days, hours, minutes, seconds, milliseconds); */ var TimeSpan = function (days, hours, minutes, seconds, milliseconds) { if (arguments.length === 1 && typeof days === "number") { var orient = (days < 0) ? -1 : +1; var millsLeft = Math.abs(days); this.setDays(Math.floor(millsLeft / 86400000) * orient); millsLeft = millsLeft % 86400000; this.setHours(Math.floor(millsLeft / 3600000) * orient); millsLeft = millsLeft % 3600000; this.setMinutes(Math.floor(millsLeft / 60000) * orient); millsLeft = millsLeft % 60000; this.setSeconds(Math.floor(millsLeft / 1000) * orient); millsLeft = millsLeft % 1000; this.setMilliseconds(millsLeft * orient); } else { this.set(days, hours, minutes, seconds, milliseconds); } this.getTotalMilliseconds = function () { return (this.getDays() * 86400000) + (this.getHours() * 3600000) + (this.getMinutes() * 60000) + (this.getSeconds() * 1000); }; this.compareTo = function (time) { var t1 = new Date(1970, 1, 1, this.getHours(), this.getMinutes(), this.getSeconds()), t2; if (time === null) { t2 = new Date(1970, 1, 1, 0, 0, 0); } else { t2 = new Date(1970, 1, 1, time.getHours(), time.getMinutes(), time.getSeconds()); } return (t1 < t2) ? -1 : (t1 > t2) ? 1 : 0; }; this.equals = function (time) { return (this.compareTo(time) === 0); }; this.add = function (time) { return (time === null) ? this : this.addSeconds(time.getTotalMilliseconds() / 1000); }; this.subtract = function (time) { return (time === null) ? this : this.addSeconds(-time.getTotalMilliseconds() / 1000); }; this.addDays = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 86400000)); }; this.addHours = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 3600000)); }; this.addMinutes = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 60000)); }; this.addSeconds = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 1000)); }; this.addMilliseconds = function (n) { return new TimeSpan(this.getTotalMilliseconds() + n); }; this.get12HourHour = function () { return (this.getHours() > 12) ? this.getHours() - 12 : (this.getHours() === 0) ? 12 : this.getHours(); }; this.getDesignator = function () { return (this.getHours() < 12) ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator; }; this.toString = function (format) { this._toString = function () { if (this.getDays() !== null && this.getDays() > 0) { return this.getDays() + "." + this.getHours() + ":" + this.p(this.getMinutes()) + ":" + this.p(this.getSeconds()); } else { return this.getHours() + ":" + this.p(this.getMinutes()) + ":" + this.p(this.getSeconds()); } }; this.p = function (s) { return (s.toString().length < 2) ? "0" + s : s; }; var me = this; return format ? format.replace(/dd?|HH?|hh?|mm?|ss?|tt?/g, function (format) { switch (format) { case "d": return me.getDays(); case "dd": return me.p(me.getDays()); case "H": return me.getHours(); case "HH": return me.p(me.getHours()); case "h": return me.get12HourHour(); case "hh": return me.p(me.get12HourHour()); case "m": return me.getMinutes(); case "mm": return me.p(me.getMinutes()); case "s": return me.getSeconds(); case "ss": return me.p(me.getSeconds()); case "t": return ((me.getHours() < 12) ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator).substring(0, 1); case "tt": return (me.getHours() < 12) ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator; } } ) : this._toString(); }; return this; }; addSetFuncs(TimeSpan, attrs.slice(2)); TimeSpan.prototype.set = function (days, hours, minutes, seconds, milliseconds){ this.setDays(days || this.getDays()); this.setHours(hours || this.getHours()); this.setMinutes(minutes || this.getMinutes()); this.setSeconds(seconds || this.getSeconds()); this.setMilliseconds(milliseconds || this.getMilliseconds()); }; /** * Gets the time of day for this date instances. * @return {TimeSpan} TimeSpan */ Date.prototype.getTimeOfDay = function () { return new TimeSpan(0, this.getHours(), this.getMinutes(), this.getSeconds(), this.getMilliseconds()); }; Date.TimeSpan = TimeSpan; if (typeof window !== "undefined" ) { // keeping API compatible for v1.x window.TimeSpan = TimeSpan; } }()); (function () { "use strict"; var attrs = ["years", "months", "days", "hours", "minutes", "seconds", "milliseconds"]; var gFn = function (attr) { return function () { return this[attr]; }; }; var sFn = function (attr) { return function (val) { this[attr] = val; return this; }; }; var addSetFuncs = function (context, attrs) { for (var i = 0; i < attrs.length ; i++) { var $a = attrs[i], $b = $a.slice(0, 1).toUpperCase() + $a.slice(1); context.prototype[$a] = 0; context.prototype["get" + $b] = gFn($a); context.prototype["set" + $b] = sFn($a); } }; var setMonthsAndYears = function (orient, d1, d2, context) { function inc() { d1.addMonths(-orient); context.months++; if (context.months === 12) { context.years++; context.months = 0; } } if (orient === +1) { while (d1 > d2) { inc(); } } else { while (d1 < d2) { inc(); } } context.months--; context.months *= orient; context.years *= orient; }; var adjustForDST = function(orient, startDate, endDate) { var hasDSTMismatch = (false === (startDate.isDaylightSavingTime() === endDate.isDaylightSavingTime())); if (hasDSTMismatch && orient === 1) { startDate.addHours(-1); } else if (hasDSTMismatch) { startDate.addHours(1); } }; /** * TimePeriod(startDate, endDate); * TimePeriod(years, months, days, hours, minutes, seconds, milliseconds); */ var TimePeriod = function (years, months, days, hours, minutes, seconds, milliseconds) { if (arguments.length === 7) { this.set(years, months, days, hours, minutes, seconds, milliseconds); } else if (arguments.length === 2 && arguments[0] instanceof Date && arguments[1] instanceof Date) { var startDate = arguments[0].clone(); var endDate = arguments[1].clone(); var orient = (startDate > endDate) ? +1 : -1; this.dates = { start: arguments[0].clone(), end: arguments[1].clone() }; setMonthsAndYears(orient, startDate, endDate, this); adjustForDST(orient, startDate, endDate); // // TODO - adjust for DST var diff = endDate - startDate; if (diff !== 0) { var ts = new TimeSpan(diff); this.set(this.years, this.months, ts.getDays(), ts.getHours(), ts.getMinutes(), ts.getSeconds(), ts.getMilliseconds()); } } return this; }; // create all the set functions. addSetFuncs(TimePeriod, attrs); TimePeriod.prototype.set = function (years, months, days, hours, minutes, seconds, milliseconds){ this.setYears(years || this.getYears()); this.setMonths(months || this.getMonths()); this.setDays(days || this.getDays()); this.setHours(hours || this.getHours()); this.setMinutes(minutes || this.getMinutes()); this.setSeconds(seconds || this.getSeconds()); this.setMilliseconds(milliseconds || this.getMilliseconds()); }; Date.TimePeriod = TimePeriod; if (typeof window !== "undefined") { // keeping API compatible for v1.x window.TimePeriod = TimePeriod; } }()); ================================================ FILE: build/date-quz-BO.js ================================================ /** * @overview datejs * @version 1.0.0-rc3 * @author Gregory Wild-Smith * @copyright 2015 Gregory Wild-Smith * @license MIT * @homepage https://github.com/abritinthebay/datejs */ /* * DateJS Culture String File * Country Code: quz-BO * Name: Quechua (Bolivia) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["quz-BO"] = { "name": "quz-BO", "englishName": "Quechua (Bolivia)", "nativeName": "runasimi (Bolivia Suyu)", "Sunday": "intichaw", "Monday": "killachaw", "Tuesday": "atipachaw", "Wednesday": "quyllurchaw", "Thursday": "Ch' askachaw", "Friday": "Illapachaw", "Saturday": "k'uychichaw", "Sun": "int", "Mon": "kil", "Tue": "ati", "Wed": "quy", "Thu": "Ch’", "Fri": "Ill", "Sat": "k'u", "Su": "int", "Mo": "kil", "Tu": "ati", "We": "quy", "Th": "Ch’", "Fr": "Ill", "Sa": "k'u", "S_Sun_Initial": "i", "M_Mon_Initial": "k", "T_Tue_Initial": "a", "W_Wed_Initial": "q", "T_Thu_Initial": "C", "F_Fri_Initial": "I", "S_Sat_Initial": "k", "January": "Qulla puquy", "February": "Hatun puquy", "March": "Pauqar waray", "April": "ayriwa", "May": "Aymuray", "June": "Inti raymi", "July": "Anta Sitwa", "August": "Qhapaq Sitwa", "September": "Uma raymi", "October": "Kantaray", "November": "Ayamarq'a", "December": "Kapaq Raymi", "Jan_Abbr": "Qul", "Feb_Abbr": "Hat", "Mar_Abbr": "Pau", "Apr_Abbr": "ayr", "May_Abbr": "Aym", "Jun_Abbr": "Int", "Jul_Abbr": "Ant", "Aug_Abbr": "Qha", "Sep_Abbr": "Uma", "Oct_Abbr": "Kan", "Nov_Abbr": "Aya", "Dec_Abbr": "Kap", "AM": "a.m.", "PM": "p.m.", "firstDayOfWeek": 0, "twoDigitYearMax": 2029, "mdy": "dmy", "M/d/yyyy": "dd/MM/yyyy", "dddd, MMMM dd, yyyy": "dddd, dd' de 'MMMM' de 'yyyy", "h:mm tt": "hh:mm:ss tt", "h:mm:ss tt": "hh:mm:ss tt", "dddd, MMMM dd, yyyy h:mm:ss tt": "dddd, dd' de 'MMMM' de 'yyyy hh:mm:ss tt", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "MMMM dd", "MMMM, yyyy": "MMMM' de 'yyyy", "/jan(uary)?/": "qul(la puquy)?", "/feb(ruary)?/": "hat(un puquy)?", "/mar(ch)?/": "pau(qar waray)?", "/apr(il)?/": "ayr(iwa)?", "/may/": "aym(uray)?", "/jun(e)?/": "int(i raymi)?", "/jul(y)?/": "ant(a sitwa)?", "/aug(ust)?/": "qha(paq sitwa)?", "/sep(t(ember)?)?/": "uma( raymi)?", "/oct(ober)?/": "kan(taray)?", "/nov(ember)?/": "aya(marq'a)?", "/dec(ember)?/": "kap(aq raymi)?", "/^su(n(day)?)?/": "^intichaw", "/^mo(n(day)?)?/": "^killachaw", "/^tu(e(s(day)?)?)?/": "^atipachaw", "/^we(d(nesday)?)?/": "^quyllurchaw", "/^th(u(r(s(day)?)?)?)?/": "^ch' askachaw", "/^fr(i(day)?)?/": "^illapachaw", "/^sa(t(urday)?)?/": "^k'uychichaw", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "quz-BO"; /** * @overview datejs * @version 1.0.0-rc3 * @author Gregory Wild-Smith * @copyright 2015 Gregory Wild-Smith * @license MIT * @homepage https://github.com/abritinthebay/datejs */(function () { var $D = Date; var lang = Date.CultureStrings ? Date.CultureStrings.lang : null; var loggedKeys = {}; // for debug purposes. var getText = { getFromKey: function (key, countryCode) { var output; if (Date.CultureStrings && Date.CultureStrings[countryCode] && Date.CultureStrings[countryCode][key]) { output = Date.CultureStrings[countryCode][key]; } else { output = getText.buildFromDefault(key); } if (key.charAt(0) === "/") { // Assume it's a regex output = getText.buildFromRegex(key, countryCode); } return output; }, getFromObjectValues: function (obj, countryCode) { var key, output = {}; for(key in obj) { if (obj.hasOwnProperty(key)) { output[key] = getText.getFromKey(obj[key], countryCode); } } return output; }, getFromObjectKeys: function (obj, countryCode) { var key, output = {}; for(key in obj) { if (obj.hasOwnProperty(key)) { output[getText.getFromKey(key, countryCode)] = obj[key]; } } return output; }, getFromArray: function (arr, countryCode) { var output = []; for (var i=0; i < arr.length; i++){ if (i in arr) { output[i] = getText.getFromKey(arr[i], countryCode); } } return output; }, buildFromDefault: function (key) { var output, length, split, last; switch(key) { case "name": output = "en-US"; break; case "englishName": output = "English (United States)"; break; case "nativeName": output = "English (United States)"; break; case "twoDigitYearMax": output = 2049; break; case "firstDayOfWeek": output = 0; break; default: output = key; split = key.split("_"); length = split.length; if (length > 1 && key.charAt(0) !== "/") { // if the key isn't a regex and it has a split. last = split[(length - 1)].toLowerCase(); if (last === "initial" || last === "abbr") { output = split[0]; } } break; } return output; }, buildFromRegex: function (key, countryCode) { var output; if (Date.CultureStrings && Date.CultureStrings[countryCode] && Date.CultureStrings[countryCode][key]) { output = new RegExp(Date.CultureStrings[countryCode][key], "i"); } else { output = new RegExp(key.replace(new RegExp("/", "g"),""), "i"); } return output; } }; var shallowMerge = function (obj1, obj2) { for (var attrname in obj2) { if (obj2.hasOwnProperty(attrname)) { obj1[attrname] = obj2[attrname]; } } }; var __ = function (key, language) { var countryCode = (language) ? language : lang; loggedKeys[key] = key; if (typeof key === "object") { if (key instanceof Array) { return getText.getFromArray(key, countryCode); } else { return getText.getFromObjectKeys(key, countryCode); } } else { return getText.getFromKey(key, countryCode); } }; var loadI18nScript = function (code) { // paatterned after jQuery's getScript. var url = Date.Config.i18n + code + ".js"; var head = document.getElementsByTagName("head")[0] || document.documentElement; var script = document.createElement("script"); script.src = url; var completed = false; var events = { done: function (){} // placeholder function }; // Attach handlers for all browsers script.onload = script.onreadystatechange = function() { if ( !completed && (!this.readyState || this.readyState === "loaded" || this.readyState === "complete") ) { events.done(); head.removeChild(script); } }; setTimeout(function() { head.insertBefore(script, head.firstChild); }, 0); // allows return to execute first return { done: function (cb) { events.done = function() { if (cb) { setTimeout(cb,0); } }; } }; }; var buildInfo = { buildFromMethodHash: function (obj) { var key; for(key in obj) { if (obj.hasOwnProperty(key)) { obj[key] = buildInfo[obj[key]](); } } return obj; }, timeZoneDST: function () { var DST = { "CHADT": "+1345", "NZDT": "+1300", "AEDT": "+1100", "ACDT": "+1030", "AZST": "+0500", "IRDT": "+0430", "EEST": "+0300", "CEST": "+0200", "BST": "+0100", "PMDT": "-0200", "ADT": "-0300", "NDT": "-0230", "EDT": "-0400", "CDT": "-0500", "MDT": "-0600", "PDT": "-0700", "AKDT": "-0800", "HADT": "-0900" }; return __(DST); }, timeZoneStandard: function () { var standard = { "LINT": "+1400", "TOT": "+1300", "CHAST": "+1245", "NZST": "+1200", "NFT": "+1130", "SBT": "+1100", "AEST": "+1000", "ACST": "+0930", "JST": "+0900", "CWST": "+0845", "CT": "+0800", "ICT": "+0700", "MMT": "+0630", "BST": "+0600", "NPT": "+0545", "IST": "+0530", "PKT": "+0500", "AFT": "+0430", "MSK": "+0400", "IRST": "+0330", "FET": "+0300", "EET": "+0200", "CET": "+0100", "GMT": "+0000", "UTC": "+0000", "CVT": "-0100", "GST": "-0200", "BRT": "-0300", "NST": "-0330", "AST": "-0400", "EST": "-0500", "CST": "-0600", "MST": "-0700", "PST": "-0800", "AKST": "-0900", "MIT": "-0930", "HST": "-1000", "SST": "-1100", "BIT": "-1200" }; return __(standard); }, timeZones: function (data) { var zone; data.timezones = []; for (zone in data.abbreviatedTimeZoneStandard) { if (data.abbreviatedTimeZoneStandard.hasOwnProperty(zone)) { data.timezones.push({ name: zone, offset: data.abbreviatedTimeZoneStandard[zone]}); } } for (zone in data.abbreviatedTimeZoneDST) { if (data.abbreviatedTimeZoneDST.hasOwnProperty(zone)) { data.timezones.push({ name: zone, offset: data.abbreviatedTimeZoneDST[zone], dst: true}); } } return data.timezones; }, days: function () { return __(["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"]); }, dayAbbr: function () { return __(["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"]); }, dayShortNames: function () { return __(["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"]); }, dayFirstLetters: function () { return __(["S_Sun_Initial", "M_Mon_Initial", "T_Tues_Initial", "W_Wed_Initial", "T_Thu_Initial", "F_Fri_Initial", "S_Sat_Initial"]); }, months: function () { return __(["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"]); }, monthAbbr: function () { return __(["Jan_Abbr", "Feb_Abbr", "Mar_Abbr", "Apr_Abbr", "May_Abbr", "Jun_Abbr", "Jul_Abbr", "Aug_Abbr", "Sep_Abbr", "Oct_Abbr", "Nov_Abbr", "Dec_Abbr"]); }, formatPatterns: function () { return getText.getFromObjectValues({ shortDate: "M/d/yyyy", longDate: "dddd, MMMM dd, yyyy", shortTime: "h:mm tt", longTime: "h:mm:ss tt", fullDateTime: "dddd, MMMM dd, yyyy h:mm:ss tt", sortableDateTime: "yyyy-MM-ddTHH:mm:ss", universalSortableDateTime: "yyyy-MM-dd HH:mm:ssZ", rfc1123: "ddd, dd MMM yyyy HH:mm:ss", monthDay: "MMMM dd", yearMonth: "MMMM, yyyy" }, Date.i18n.currentLanguage()); }, regex: function () { return getText.getFromObjectValues({ inTheMorning: "/( in the )(morn(ing)?)\\b/", thisMorning: "/(this )(morn(ing)?)\\b/", amThisMorning: "/(\b\\d(am)? )(this )(morn(ing)?)/", inTheEvening: "/( in the )(even(ing)?)\\b/", thisEvening: "/(this )(even(ing)?)\\b/", pmThisEvening: "/(\b\\d(pm)? )(this )(even(ing)?)/", jan: "/jan(uary)?/", feb: "/feb(ruary)?/", mar: "/mar(ch)?/", apr: "/apr(il)?/", may: "/may/", jun: "/jun(e)?/", jul: "/jul(y)?/", aug: "/aug(ust)?/", sep: "/sep(t(ember)?)?/", oct: "/oct(ober)?/", nov: "/nov(ember)?/", dec: "/dec(ember)?/", sun: "/^su(n(day)?)?/", mon: "/^mo(n(day)?)?/", tue: "/^tu(e(s(day)?)?)?/", wed: "/^we(d(nesday)?)?/", thu: "/^th(u(r(s(day)?)?)?)?/", fri: "/fr(i(day)?)?/", sat: "/^sa(t(urday)?)?/", future: "/^next/", past: "/^last|past|prev(ious)?/", add: "/^(\\+|aft(er)?|from|hence)/", subtract: "/^(\\-|bef(ore)?|ago)/", yesterday: "/^yes(terday)?/", today: "/^t(od(ay)?)?/", tomorrow: "/^tom(orrow)?/", now: "/^n(ow)?/", millisecond: "/^ms|milli(second)?s?/", second: "/^sec(ond)?s?/", minute: "/^mn|min(ute)?s?/", hour: "/^h(our)?s?/", week: "/^w(eek)?s?/", month: "/^m(onth)?s?/", day: "/^d(ay)?s?/", year: "/^y(ear)?s?/", shortMeridian: "/^(a|p)/", longMeridian: "/^(a\\.?m?\\.?|p\\.?m?\\.?)/", timezone: "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/", ordinalSuffix: "/^\\s*(st|nd|rd|th)/", timeContext: "/^\\s*(\\:|a(?!u|p)|p)/" }, Date.i18n.currentLanguage()); } }; var CultureInfo = function () { var info = getText.getFromObjectValues({ name: "name", englishName: "englishName", nativeName: "nativeName", amDesignator: "AM", pmDesignator: "PM", firstDayOfWeek: "firstDayOfWeek", twoDigitYearMax: "twoDigitYearMax", dateElementOrder: "mdy" }, Date.i18n.currentLanguage()); var constructedInfo = buildInfo.buildFromMethodHash({ dayNames: "days", abbreviatedDayNames: "dayAbbr", shortestDayNames: "dayShortNames", firstLetterDayNames: "dayFirstLetters", monthNames: "months", abbreviatedMonthNames: "monthAbbr", formatPatterns: "formatPatterns", regexPatterns: "regex", abbreviatedTimeZoneDST: "timeZoneDST", abbreviatedTimeZoneStandard: "timeZoneStandard" }); shallowMerge(info, constructedInfo); buildInfo.timeZones(info); return info; }; $D.i18n = { __: function (key, lang) { return __(key, lang); }, currentLanguage: function () { return lang || "en-US"; }, setLanguage: function (code, force, cb) { var async = false; if (force || code === "en-US" || (!!Date.CultureStrings && !!Date.CultureStrings[code])) { lang = code; Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings.lang = code; Date.CultureInfo = new CultureInfo(); } else { if (!(!!Date.CultureStrings && !!Date.CultureStrings[code])) { if (typeof exports !== "undefined" && this.exports !== exports) { // we're in a Node enviroment, load it using require try { require("../i18n/" + code + ".js"); lang = code; Date.CultureStrings.lang = code; Date.CultureInfo = new CultureInfo(); } catch (e) { // var str = "The language for '" + code + "' could not be loaded by Node. It likely does not exist."; throw new Error("The DateJS IETF language tag '" + code + "' could not be loaded by Node. It likely does not exist."); } } else if (Date.Config && Date.Config.i18n) { // we know the location of the files, so lets load them async = true; loadI18nScript(code).done(function(){ lang = code; Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings.lang = code; Date.CultureInfo = new CultureInfo(); $D.Parsing.Normalizer.buildReplaceData(); // because this is async if ($D.Grammar) { $D.Grammar.buildGrammarFormats(); // so we can parse those strings... } if (cb) { setTimeout(cb,0); } }); } else { Date.console.error("The DateJS IETF language tag '" + code + "' is not available and has not been loaded."); return false; } } } $D.Parsing.Normalizer.buildReplaceData(); // rebuild normalizer strings if ($D.Grammar) { $D.Grammar.buildGrammarFormats(); // so we can parse those strings... } if (!async && cb) { setTimeout(cb,0); } }, getLoggedKeys: function () { return loggedKeys; }, updateCultureInfo: function () { Date.CultureInfo = new CultureInfo(); } }; $D.i18n.updateCultureInfo(); // run automatically }()); (function () { var $D = Date, $P = $D.prototype, p = function (s, l) { if (!l) { l = 2; } return ("000" + s).slice(l * -1); }; if (typeof window !== "undefined" && typeof window.console !== "undefined" && typeof window.console.log !== "undefined") { $D.console = console; // used only to raise non-critical errors if available } else { // set mock so we don't give errors. $D.console = { log: function(){}, error: function(){} }; } $D.Config = $D.Config || {}; $D.initOverloads = function() { /** * Overload of Date.now. Allows an alternate call for Date.now where it returns the * current Date as an object rather than just milliseconds since the Unix Epoch. * * Also provides an implementation of now() for browsers (IE<9) that don't have it. * * Backwards compatible so with work with either: * Date.now() [returns ms] * or * Date.now(true) [returns Date] */ if (!$D.now) { $D._now = function now() { return new Date().getTime(); }; } else if (!$D._now) { $D._now = $D.now; } $D.now = function (returnObj) { if (returnObj) { return $D.present(); } else { return $D._now(); } }; if ( !$P.toISOString ) { $P.toISOString = function() { return this.getUTCFullYear() + "-" + p(this.getUTCMonth() + 1) + "-" + p(this.getUTCDate()) + "T" + p(this.getUTCHours()) + ":" + p(this.getUTCMinutes()) + ":" + p(this.getUTCSeconds()) + "." + String( (this.getUTCMilliseconds()/1000).toFixed(3)).slice(2, 5) + "Z"; }; } // private if ( $P._toString === undefined ){ $P._toString = $P.toString; } }; $D.initOverloads(); /** * Gets a date that is set to the current date. The time is set to the start of the day (00:00 or 12:00 AM). * @return {Date} The current date. */ $D.today = function () { return new Date().clearTime(); }; /** * Gets a date that is set to the current date and time (same as new Date, but chainable) * @return {Date} The current date. */ $D.present = function () { return new Date(); }; /** * Compares the first date to the second date and returns an number indication of their relative values. * @param {Date} First Date object to compare [Required]. * @param {Date} Second Date object to compare to [Required]. * @return {Number} -1 = date1 is lessthan date2. 0 = values are equal. 1 = date1 is greaterthan date2. */ $D.compare = function (date1, date2) { if (isNaN(date1) || isNaN(date2)) { throw new Error(date1 + " - " + date2); } else if (date1 instanceof Date && date2 instanceof Date) { return (date1 < date2) ? -1 : (date1 > date2) ? 1 : 0; } else { throw new TypeError(date1 + " - " + date2); } }; /** * Compares the first Date object to the second Date object and returns true if they are equal. * @param {Date} First Date object to compare [Required] * @param {Date} Second Date object to compare to [Required] * @return {Boolean} true if dates are equal. false if they are not equal. */ $D.equals = function (date1, date2) { return (date1.compareTo(date2) === 0); }; /** * Gets the language appropriate day name when given the day number(0-6) * eg - 0 == Sunday * @return {String} The day name */ $D.getDayName = function (n) { return Date.CultureInfo.dayNames[n]; }; /** * Gets the day number (0-6) if given a CultureInfo specific string which is a valid dayName, abbreviatedDayName or shortestDayName (two char). * @param {String} The name of the day (eg. "Monday, "Mon", "tuesday", "tue", "We", "we"). * @return {Number} The day number */ $D.getDayNumberFromName = function (name) { var n = Date.CultureInfo.dayNames, m = Date.CultureInfo.abbreviatedDayNames, o = Date.CultureInfo.shortestDayNames, s = name.toLowerCase(); for (var i = 0; i < n.length; i++) { if (n[i].toLowerCase() === s || m[i].toLowerCase() === s || o[i].toLowerCase() === s) { return i; } } return -1; }; /** * Gets the month number (0-11) if given a Culture Info specific string which is a valid monthName or abbreviatedMonthName. * @param {String} The name of the month (eg. "February, "Feb", "october", "oct"). * @return {Number} The day number */ $D.getMonthNumberFromName = function (name) { var n = Date.CultureInfo.monthNames, m = Date.CultureInfo.abbreviatedMonthNames, s = name.toLowerCase(); for (var i = 0; i < n.length; i++) { if (n[i].toLowerCase() === s || m[i].toLowerCase() === s) { return i; } } return -1; }; /** * Gets the language appropriate month name when given the month number(0-11) * eg - 0 == January * @return {String} The month name */ $D.getMonthName = function (n) { return Date.CultureInfo.monthNames[n]; }; /** * Determines if the current date instance is within a LeapYear. * @param {Number} The year. * @return {Boolean} true if date is within a LeapYear, otherwise false. */ $D.isLeapYear = function (year) { return ((year % 4 === 0 && year % 100 !== 0) || year % 400 === 0); }; /** * Gets the number of days in the month, given a year and month value. Automatically corrects for LeapYear. * @param {Number} The year. * @param {Number} The month (0-11). * @return {Number} The number of days in the month. */ $D.getDaysInMonth = function (year, month) { if (!month && $D.validateMonth(year)) { month = year; year = Date.today().getFullYear(); } return [31, ($D.isLeapYear(year) ? 29 : 28), 31, 30, 31, 30, 31, 31, 30, 31, 30, 31][month]; }; $P.getDaysInMonth = function () { return $D.getDaysInMonth(this.getFullYear(), this.getMonth()); }; $D.getTimezoneAbbreviation = function (offset, dst) { var p, n = (dst || false) ? Date.CultureInfo.abbreviatedTimeZoneDST : Date.CultureInfo.abbreviatedTimeZoneStandard; for (p in n) { if (n.hasOwnProperty(p)) { if (n[p] === offset) { return p; } } } return null; }; $D.getTimezoneOffset = function (name, dst) { var i, a =[], z = Date.CultureInfo.timezones; if (!name) { name = (new Date()).getTimezone();} for (i = 0; i < z.length; i++) { if (z[i].name === name.toUpperCase()) { a.push(i); } } if (!z[a[0]]) { return null; } if (a.length === 1 || !dst) { return z[a[0]].offset; } else { for (i=0; i < a.length; i++) { if (z[a[i]].dst) { return z[a[i]].offset; } } } }; $D.getQuarter = function (d) { d = d || new Date(); // If no date supplied, use today var q = [1,2,3,4]; return q[Math.floor(d.getMonth() / 3)]; // ~~~ is a bitwise op. Faster than Math.floor }; $D.getDaysLeftInQuarter = function (d) { d = d || new Date(); var qEnd = new Date(d); qEnd.setMonth(qEnd.getMonth() + 3 - qEnd.getMonth() % 3, 0); return Math.floor((qEnd - d) / 8.64e7); }; // private var validate = function (n, min, max, name) { name = name ? name : "Object"; if (typeof n === "undefined") { return false; } else if (typeof n !== "number") { throw new TypeError(n + " is not a Number."); } else if (n < min || n > max) { // As failing validation is *not* an exceptional circumstance // lets not throw a RangeError Exception here. // It's semantically correct but it's not sensible. return false; } return true; }; /** * Validates the number is within an acceptable range for milliseconds [0-999]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateMillisecond = function (value) { return validate(value, 0, 999, "millisecond"); }; /** * Validates the number is within an acceptable range for seconds [0-59]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateSecond = function (value) { return validate(value, 0, 59, "second"); }; /** * Validates the number is within an acceptable range for minutes [0-59]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateMinute = function (value) { return validate(value, 0, 59, "minute"); }; /** * Validates the number is within an acceptable range for hours [0-23]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateHour = function (value) { return validate(value, 0, 23, "hour"); }; /** * Validates the number is within an acceptable range for the days in a month [0-MaxDaysInMonth]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateDay = function (value, year, month) { if (year === undefined || year === null || month === undefined || month === null) { return false;} return validate(value, 1, $D.getDaysInMonth(year, month), "day"); }; /** * Validates the number is within an acceptable range for months [0-11]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateWeek = function (value) { return validate(value, 0, 53, "week"); }; /** * Validates the number is within an acceptable range for months [0-11]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateMonth = function (value) { return validate(value, 0, 11, "month"); }; /** * Validates the number is within an acceptable range for years. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateYear = function (value) { /** * Per ECMAScript spec the range of times supported by Date objects is * exactly -100,000,000 days to +100,000,000 days measured relative to * midnight at the beginning of 01 January, 1970 UTC. * This gives a range of 8,640,000,000,000,000 milliseconds to either * side of 01 January, 1970 UTC. * * Earliest possible date: Tue, 20 Apr 271,822 B.C. 00:00:00 UTC * Latest possible date: Sat, 13 Sep 275,760 00:00:00 UTC */ return validate(value, -271822, 275760, "year"); }; $D.validateTimezone = function(value) { var timezones = {"ACDT":1,"ACST":1,"ACT":1,"ADT":1,"AEDT":1,"AEST":1,"AFT":1,"AKDT":1,"AKST":1,"AMST":1,"AMT":1,"ART":1,"AST":1,"AWDT":1,"AWST":1,"AZOST":1,"AZT":1,"BDT":1,"BIOT":1,"BIT":1,"BOT":1,"BRT":1,"BST":1,"BTT":1,"CAT":1,"CCT":1,"CDT":1,"CEDT":1,"CEST":1,"CET":1,"CHADT":1,"CHAST":1,"CHOT":1,"ChST":1,"CHUT":1,"CIST":1,"CIT":1,"CKT":1,"CLST":1,"CLT":1,"COST":1,"COT":1,"CST":1,"CT":1,"CVT":1,"CWST":1,"CXT":1,"DAVT":1,"DDUT":1,"DFT":1,"EASST":1,"EAST":1,"EAT":1,"ECT":1,"EDT":1,"EEDT":1,"EEST":1,"EET":1,"EGST":1,"EGT":1,"EIT":1,"EST":1,"FET":1,"FJT":1,"FKST":1,"FKT":1,"FNT":1,"GALT":1,"GAMT":1,"GET":1,"GFT":1,"GILT":1,"GIT":1,"GMT":1,"GST":1,"GYT":1,"HADT":1,"HAEC":1,"HAST":1,"HKT":1,"HMT":1,"HOVT":1,"HST":1,"ICT":1,"IDT":1,"IOT":1,"IRDT":1,"IRKT":1,"IRST":1,"IST":1,"JST":1,"KGT":1,"KOST":1,"KRAT":1,"KST":1,"LHST":1,"LINT":1,"MAGT":1,"MART":1,"MAWT":1,"MDT":1,"MET":1,"MEST":1,"MHT":1,"MIST":1,"MIT":1,"MMT":1,"MSK":1,"MST":1,"MUT":1,"MVT":1,"MYT":1,"NCT":1,"NDT":1,"NFT":1,"NPT":1,"NST":1,"NT":1,"NUT":1,"NZDT":1,"NZST":1,"OMST":1,"ORAT":1,"PDT":1,"PET":1,"PETT":1,"PGT":1,"PHOT":1,"PHT":1,"PKT":1,"PMDT":1,"PMST":1,"PONT":1,"PST":1,"PYST":1,"PYT":1,"RET":1,"ROTT":1,"SAKT":1,"SAMT":1,"SAST":1,"SBT":1,"SCT":1,"SGT":1,"SLST":1,"SRT":1,"SST":1,"SYOT":1,"TAHT":1,"THA":1,"TFT":1,"TJT":1,"TKT":1,"TLT":1,"TMT":1,"TOT":1,"TVT":1,"UCT":1,"ULAT":1,"UTC":1,"UYST":1,"UYT":1,"UZT":1,"VET":1,"VLAT":1,"VOLT":1,"VOST":1,"VUT":1,"WAKT":1,"WAST":1,"WAT":1,"WEDT":1,"WEST":1,"WET":1,"WST":1,"YAKT":1,"YEKT":1,"Z":1}; return (timezones[value] === 1); }; $D.validateTimezoneOffset= function(value) { // timezones go from +14hrs to -12hrs, the +X hours are negative offsets. return (value > -841 && value < 721); }; }()); (function () { var $D = Date, $P = $D.prototype, p = function (s, l) { if (!l) { l = 2; } return ("000" + s).slice(l * -1); }; var validateConfigObject = function (obj) { var result = {}, self = this, prop, testFunc; testFunc = function (prop, func, value) { if (prop === "day") { var month = (obj.month !== undefined) ? obj.month : self.getMonth(); var year = (obj.year !== undefined) ? obj.year : self.getFullYear(); return $D[func](value, year, month); } else { return $D[func](value); } }; for (prop in obj) { if (Object.prototype.hasOwnProperty.call(obj, prop)) { var func = "validate" + prop.charAt(0).toUpperCase() + prop.slice(1); if ($D[func] && obj[prop] !== null && testFunc(prop, func, obj[prop])) { result[prop] = obj[prop]; } } } return result; }; /** * Resets the time of this Date object to 12:00 AM (00:00), which is the start of the day. * @param {Boolean} .clone() this date instance before clearing Time * @return {Date} this */ $P.clearTime = function () { this.setHours(0); this.setMinutes(0); this.setSeconds(0); this.setMilliseconds(0); return this; }; /** * Resets the time of this Date object to the current time ('now'). * @return {Date} this */ $P.setTimeToNow = function () { var n = new Date(); this.setHours(n.getHours()); this.setMinutes(n.getMinutes()); this.setSeconds(n.getSeconds()); this.setMilliseconds(n.getMilliseconds()); return this; }; /** * Returns a new Date object that is an exact date and time copy of the original instance. * @return {Date} A new Date instance */ $P.clone = function () { return new Date(this.getTime()); }; /** * Compares this instance to a Date object and returns an number indication of their relative values. * @param {Date} Date object to compare [Required] * @return {Number} -1 = this is lessthan date. 0 = values are equal. 1 = this is greaterthan date. */ $P.compareTo = function (date) { return Date.compare(this, date); }; /** * Compares this instance to another Date object and returns true if they are equal. * @param {Date} Date object to compare. If no date to compare, new Date() [now] is used. * @return {Boolean} true if dates are equal. false if they are not equal. */ $P.equals = function (date) { return Date.equals(this, (date !== undefined ? date : new Date())); }; /** * Determines if this instance is between a range of two dates or equal to either the start or end dates. * @param {Date} Start of range [Required] * @param {Date} End of range [Required] * @return {Boolean} true is this is between or equal to the start and end dates, else false */ $P.between = function (start, end) { return this.getTime() >= start.getTime() && this.getTime() <= end.getTime(); }; /** * Determines if this date occurs after the date to compare to. * @param {Date} Date object to compare. If no date to compare, new Date() ("now") is used. * @return {Boolean} true if this date instance is greater than the date to compare to (or "now"), otherwise false. */ $P.isAfter = function (date) { return this.compareTo(date || new Date()) === 1; }; /** * Determines if this date occurs before the date to compare to. * @param {Date} Date object to compare. If no date to compare, new Date() ("now") is used. * @return {Boolean} true if this date instance is less than the date to compare to (or "now"). */ $P.isBefore = function (date) { return (this.compareTo(date || new Date()) === -1); }; /** * Determines if the current Date instance occurs today. * @return {Boolean} true if this date instance is 'today', otherwise false. */ /** * Determines if the current Date instance occurs on the same Date as the supplied 'date'. * If no 'date' to compare to is provided, the current Date instance is compared to 'today'. * @param {date} Date object to compare. If no date to compare, the current Date ("now") is used. * @return {Boolean} true if this Date instance occurs on the same Day as the supplied 'date'. */ $P.isToday = $P.isSameDay = function (date) { return this.clone().clearTime().equals((date || new Date()).clone().clearTime()); }; /** * Adds the specified number of milliseconds to this instance. * @param {Number} The number of milliseconds to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addMilliseconds = function (value) { if (!value) { return this; } this.setTime(this.getTime() + value * 1); return this; }; /** * Adds the specified number of seconds to this instance. * @param {Number} The number of seconds to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addSeconds = function (value) { if (!value) { return this; } return this.addMilliseconds(value * 1000); }; /** * Adds the specified number of seconds to this instance. * @param {Number} The number of seconds to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addMinutes = function (value) { if (!value) { return this; } return this.addMilliseconds(value * 60000); // 60*1000 }; /** * Adds the specified number of hours to this instance. * @param {Number} The number of hours to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addHours = function (value) { if (!value) { return this; } return this.addMilliseconds(value * 3600000); // 60*60*1000 }; /** * Adds the specified number of days to this instance. * @param {Number} The number of days to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addDays = function (value) { if (!value) { return this; } this.setDate(this.getDate() + value * 1); return this; }; /** * Adds the specified number of weekdays (ie - not sat or sun) to this instance. * @param {Number} The number of days to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addWeekdays = function (value) { if (!value) { return this; } var day = this.getDay(); var weeks = (Math.ceil(Math.abs(value)/7)); if (day === 0 || day === 6) { if (value > 0) { this.next().monday(); this.addDays(-1); day = this.getDay(); } } if (value < 0) { while (value < 0) { this.addDays(-1); day = this.getDay(); if (day !== 0 && day !== 6) { value++; } } return this; } else if (value > 5 || (6-day) <= value) { value = value + (weeks * 2); } return this.addDays(value); }; /** * Adds the specified number of weeks to this instance. * @param {Number} The number of weeks to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addWeeks = function (value) { if (!value) { return this; } return this.addDays(value * 7); }; /** * Adds the specified number of months to this instance. * @param {Number} The number of months to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addMonths = function (value) { if (!value) { return this; } var n = this.getDate(); this.setDate(1); this.setMonth(this.getMonth() + value * 1); this.setDate(Math.min(n, $D.getDaysInMonth(this.getFullYear(), this.getMonth()))); return this; }; $P.addQuarters = function (value) { if (!value) { return this; } // note this will take you to the same point in the quarter as you are now. // i.e. - if you are 15 days into the quarter you'll be 15 days into the resulting one. // bonus: this allows adding fractional quarters return this.addMonths(value * 3); }; /** * Adds the specified number of years to this instance. * @param {Number} The number of years to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addYears = function (value) { if (!value) { return this; } return this.addMonths(value * 12); }; /** * Adds (or subtracts) to the value of the years, months, weeks, days, hours, minutes, seconds, milliseconds of the date instance using given configuration object. Positive and Negative values allowed. * Example

	Date.today().add( { days: 1, months: 1 } )

	new Date().add( { years: -1 } )
	
* @param {Object} Configuration object containing attributes (months, days, etc.) * @return {Date} this */ $P.add = function (config) { if (typeof config === "number") { this._orient = config; return this; } var x = config; if (x.day) { // If we should be a different date than today (eg: for 'tomorrow -1d', etc). // Should only effect parsing, not direct usage (eg, Finish and FinishExact) if ((x.day - this.getDate()) !== 0) { this.setDate(x.day); } } if (x.milliseconds) { this.addMilliseconds(x.milliseconds); } if (x.seconds) { this.addSeconds(x.seconds); } if (x.minutes) { this.addMinutes(x.minutes); } if (x.hours) { this.addHours(x.hours); } if (x.weeks) { this.addWeeks(x.weeks); } if (x.months) { this.addMonths(x.months); } if (x.years) { this.addYears(x.years); } if (x.days) { this.addDays(x.days); } return this; }; /** * Get the week number. Week one (1) is the week which contains the first Thursday of the year. Monday is considered the first day of the week. * The .getWeek() function does NOT convert the date to UTC. The local datetime is used. * Please use .getISOWeek() to get the week of the UTC converted date. * @return {Number} 1 to 53 */ $P.getWeek = function (utc) { // Create a copy of this date object var self, target = new Date(this.valueOf()); if (utc) { target.addMinutes(target.getTimezoneOffset()); self = target.clone(); } else { self = this; } // ISO week date weeks start on monday // so correct the day number var dayNr = (self.getDay() + 6) % 7; // ISO 8601 states that week 1 is the week // with the first thursday of that year. // Set the target date to the thursday in the target week target.setDate(target.getDate() - dayNr + 3); // Store the millisecond value of the target date var firstThursday = target.valueOf(); // Set the target to the first thursday of the year // First set the target to january first target.setMonth(0, 1); // Not a thursday? Correct the date to the next thursday if (target.getDay() !== 4) { target.setMonth(0, 1 + ((4 - target.getDay()) + 7) % 7); } // The weeknumber is the number of weeks between the // first thursday of the year and the thursday in the target week return 1 + Math.ceil((firstThursday - target) / 604800000); // 604800000 = 7 * 24 * 3600 * 1000 }; /** * Get the ISO 8601 week number. Week one ("01") is the week which contains the first Thursday of the year. Monday is considered the first day of the week. * The .getISOWeek() function does convert the date to it's UTC value. Please use .getWeek() to get the week of the local date. * @return {String} "01" to "53" */ $P.getISOWeek = function () { return p(this.getWeek(true)); }; /** * Moves the date to Monday of the week set. Week one (1) is the week which contains the first Thursday of the year. * @param {Number} A Number (1 to 53) that represents the week of the year. * @return {Date} this */ $P.setWeek = function (n) { if ((n - this.getWeek()) === 0) { if (this.getDay() !== 1) { return this.moveToDayOfWeek(1, (this.getDay() > 1 ? -1 : 1)); } else { return this; } } else { return this.moveToDayOfWeek(1, (this.getDay() > 1 ? -1 : 1)).addWeeks(n - this.getWeek()); } }; $P.setQuarter = function (qtr) { var month = Math.abs(((qtr-1) * 3) + 1); return this.setMonth(month, 1); }; $P.getQuarter = function () { return Date.getQuarter(this); }; $P.getDaysLeftInQuarter = function () { return Date.getDaysLeftInQuarter(this); }; /** * Moves the date to the next n'th occurrence of the dayOfWeek starting from the beginning of the month. The number (-1) is a magic number and will return the last occurrence of the dayOfWeek in the month. * @param {Number} The dayOfWeek to move to * @param {Number} The n'th occurrence to move to. Use (-1) to return the last occurrence in the month * @return {Date} this */ $P.moveToNthOccurrence = function (dayOfWeek, occurrence) { if (dayOfWeek === "Weekday") { if (occurrence > 0) { this.moveToFirstDayOfMonth(); if (this.is().weekday()) { occurrence -= 1; } } else if (occurrence < 0) { this.moveToLastDayOfMonth(); if (this.is().weekday()) { occurrence += 1; } } else { return this; } return this.addWeekdays(occurrence); } var shift = 0; if (occurrence > 0) { shift = occurrence - 1; } else if (occurrence === -1) { this.moveToLastDayOfMonth(); if (this.getDay() !== dayOfWeek) { this.moveToDayOfWeek(dayOfWeek, -1); } return this; } return this.moveToFirstDayOfMonth().addDays(-1).moveToDayOfWeek(dayOfWeek, +1).addWeeks(shift); }; var moveToN = function (getFunc, addFunc, nVal) { return function (value, orient) { var diff = (value - this[getFunc]() + nVal * (orient || +1)) % nVal; return this[addFunc]((diff === 0) ? diff += nVal * (orient || +1) : diff); }; }; /** * Move to the next or last dayOfWeek based on the orient value. * @param {Number} The dayOfWeek to move to * @param {Number} Forward (+1) or Back (-1). Defaults to +1. [Optional] * @return {Date} this */ $P.moveToDayOfWeek = moveToN("getDay", "addDays", 7); /** * Move to the next or last month based on the orient value. * @param {Number} The month to move to. 0 = January, 11 = December * @param {Number} Forward (+1) or Back (-1). Defaults to +1. [Optional] * @return {Date} this */ $P.moveToMonth = moveToN("getMonth", "addMonths", 12); /** * Get the Ordinate of the current day ("th", "st", "rd"). * @return {String} */ $P.getOrdinate = function () { var num = this.getDate(); return ord(num); }; /** * Get the Ordinal day (numeric day number) of the year, adjusted for leap year. * @return {Number} 1 through 365 (366 in leap years) */ $P.getOrdinalNumber = function () { return Math.ceil((this.clone().clearTime() - new Date(this.getFullYear(), 0, 1)) / 86400000) + 1; }; /** * Get the time zone abbreviation of the current date. * @return {String} The abbreviated time zone name (e.g. "EST") */ $P.getTimezone = function () { return $D.getTimezoneAbbreviation(this.getUTCOffset(), this.isDaylightSavingTime()); }; $P.setTimezoneOffset = function (offset) { var here = this.getTimezoneOffset(), there = Number(offset) * -6 / 10; return (there || there === 0) ? this.addMinutes(there - here) : this; }; $P.setTimezone = function (offset) { return this.setTimezoneOffset($D.getTimezoneOffset(offset)); }; /** * Indicates whether Daylight Saving Time is observed in the current time zone. * @return {Boolean} true|false */ $P.hasDaylightSavingTime = function () { return (Date.today().set({month: 0, day: 1}).getTimezoneOffset() !== Date.today().set({month: 6, day: 1}).getTimezoneOffset()); }; /** * Indicates whether this Date instance is within the Daylight Saving Time range for the current time zone. * @return {Boolean} true|false */ $P.isDaylightSavingTime = function () { return Date.today().set({month: 0, day: 1}).getTimezoneOffset() !== this.getTimezoneOffset(); }; /** * Get the offset from UTC of the current date. * @return {String} The 4-character offset string prefixed with + or - (e.g. "-0500") */ $P.getUTCOffset = function (offset) { var n = (offset || this.getTimezoneOffset()) * -10 / 6, r; if (n < 0) { r = (n - 10000).toString(); return r.charAt(0) + r.substr(2); } else { r = (n + 10000).toString(); return "+" + r.substr(1); } }; /** * Returns the number of milliseconds between this date and date. * @param {Date} Defaults to now * @return {Number} The diff in milliseconds */ $P.getElapsed = function (date) { return (date || new Date()) - this; }; /** * Set the value of year, month, day, hour, minute, second, millisecond of date instance using given configuration object. * Example

	Date.today().set( { day: 20, month: 1 } )

	new Date().set( { millisecond: 0 } )
	
* * @param {Object} Configuration object containing attributes (month, day, etc.) * @return {Date} this */ $P.set = function (config) { config = validateConfigObject.call(this, config); var key; for (key in config) { if (Object.prototype.hasOwnProperty.call(config, key)) { var name = key.charAt(0).toUpperCase() + key.slice(1); var addFunc, getFunc; if (key !== "week" && key !== "month" && key !== "timezone" && key !== "timezoneOffset") { name += "s"; } addFunc = "add" + name; getFunc = "get" + name; if (key === "month") { addFunc = addFunc + "s"; } else if (key === "year"){ getFunc = "getFullYear"; } if (key !== "day" && key !== "timezone" && key !== "timezoneOffset" && key !== "week" && key !== "hour") { this[addFunc](config[key] - this[getFunc]()); } else if ( key === "timezone"|| key === "timezoneOffset" || key === "week" || key === "hour") { this["set"+name](config[key]); } } } // day has to go last because you can't validate the day without first knowing the month if (config.day) { this.addDays(config.day - this.getDate()); } return this; }; /** * Moves the date to the first day of the month. * @return {Date} this */ $P.moveToFirstDayOfMonth = function () { return this.set({ day: 1 }); }; /** * Moves the date to the last day of the month. * @return {Date} this */ $P.moveToLastDayOfMonth = function () { return this.set({ day: $D.getDaysInMonth(this.getFullYear(), this.getMonth())}); }; /** * Converts the value of the current Date object to its equivalent string representation. * Format Specifiers * CUSTOM DATE AND TIME FORMAT STRINGS * Format Description Example * ------ --------------------------------------------------------------------------- ----------------------- * s The seconds of the minute between 0-59. "0" to "59" * ss The seconds of the minute with leading zero if required. "00" to "59" * * m The minute of the hour between 0-59. "0" or "59" * mm The minute of the hour with leading zero if required. "00" or "59" * * h The hour of the day between 1-12. "1" to "12" * hh The hour of the day with leading zero if required. "01" to "12" * * H The hour of the day between 0-23. "0" to "23" * HH The hour of the day with leading zero if required. "00" to "23" * * d The day of the month between 1 and 31. "1" to "31" * dd The day of the month with leading zero if required. "01" to "31" * ddd Abbreviated day name. Date.CultureInfo.abbreviatedDayNames. "Mon" to "Sun" * dddd The full day name. Date.CultureInfo.dayNames. "Monday" to "Sunday" * * M The month of the year between 1-12. "1" to "12" * MM The month of the year with leading zero if required. "01" to "12" * MMM Abbreviated month name. Date.CultureInfo.abbreviatedMonthNames. "Jan" to "Dec" * MMMM The full month name. Date.CultureInfo.monthNames. "January" to "December" * * yy The year as a two-digit number. "99" or "08" * yyyy The full four digit year. "1999" or "2008" * * t Displays the first character of the A.M./P.M. designator. "A" or "P" * Date.CultureInfo.amDesignator or Date.CultureInfo.pmDesignator * tt Displays the A.M./P.M. designator. "AM" or "PM" * Date.CultureInfo.amDesignator or Date.CultureInfo.pmDesignator * * S The ordinal suffix ("st, "nd", "rd" or "th") of the current day. "st, "nd", "rd" or "th" * * STANDARD DATE AND TIME FORMAT STRINGS * Format Description Example *------ --------------------------------------------------------------------------- ----------------------- * d The CultureInfo shortDate Format Pattern "M/d/yyyy" * D The CultureInfo longDate Format Pattern "dddd, MMMM dd, yyyy" * F The CultureInfo fullDateTime Format Pattern "dddd, MMMM dd, yyyy h:mm:ss tt" * m The CultureInfo monthDay Format Pattern "MMMM dd" * r The CultureInfo rfc1123 Format Pattern "ddd, dd MMM yyyy HH:mm:ss GMT" * s The CultureInfo sortableDateTime Format Pattern "yyyy-MM-ddTHH:mm:ss" * t The CultureInfo shortTime Format Pattern "h:mm tt" * T The CultureInfo longTime Format Pattern "h:mm:ss tt" * u The CultureInfo universalSortableDateTime Format Pattern "yyyy-MM-dd HH:mm:ssZ" * y The CultureInfo yearMonth Format Pattern "MMMM, yyyy" * * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @return {String} A string representation of the current Date object. */ var ord = function (n) { switch (n * 1) { case 1: case 21: case 31: return "st"; case 2: case 22: return "nd"; case 3: case 23: return "rd"; default: return "th"; } }; var parseStandardFormats = function (format) { var y, c = Date.CultureInfo.formatPatterns; switch (format) { case "d": return this.toString(c.shortDate); case "D": return this.toString(c.longDate); case "F": return this.toString(c.fullDateTime); case "m": return this.toString(c.monthDay); case "r": case "R": y = this.clone().addMinutes(this.getTimezoneOffset()); return y.toString(c.rfc1123) + " GMT"; case "s": return this.toString(c.sortableDateTime); case "t": return this.toString(c.shortTime); case "T": return this.toString(c.longTime); case "u": y = this.clone().addMinutes(this.getTimezoneOffset()); return y.toString(c.universalSortableDateTime); case "y": return this.toString(c.yearMonth); default: return false; } }; var parseFormatStringsClosure = function (context) { return function (m) { if (m.charAt(0) === "\\") { return m.replace("\\", ""); } switch (m) { case "hh": return p(context.getHours() < 13 ? (context.getHours() === 0 ? 12 : context.getHours()) : (context.getHours() - 12)); case "h": return context.getHours() < 13 ? (context.getHours() === 0 ? 12 : context.getHours()) : (context.getHours() - 12); case "HH": return p(context.getHours()); case "H": return context.getHours(); case "mm": return p(context.getMinutes()); case "m": return context.getMinutes(); case "ss": return p(context.getSeconds()); case "s": return context.getSeconds(); case "yyyy": return p(context.getFullYear(), 4); case "yy": return p(context.getFullYear()); case "y": return context.getFullYear(); case "E": case "dddd": return Date.CultureInfo.dayNames[context.getDay()]; case "ddd": return Date.CultureInfo.abbreviatedDayNames[context.getDay()]; case "dd": return p(context.getDate()); case "d": return context.getDate(); case "MMMM": return Date.CultureInfo.monthNames[context.getMonth()]; case "MMM": return Date.CultureInfo.abbreviatedMonthNames[context.getMonth()]; case "MM": return p((context.getMonth() + 1)); case "M": return context.getMonth() + 1; case "t": return context.getHours() < 12 ? Date.CultureInfo.amDesignator.substring(0, 1) : Date.CultureInfo.pmDesignator.substring(0, 1); case "tt": return context.getHours() < 12 ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator; case "S": return ord(context.getDate()); case "W": return context.getWeek(); case "WW": return context.getISOWeek(); case "Q": return "Q" + context.getQuarter(); case "q": return String(context.getQuarter()); case "z": return context.getTimezone(); case "Z": case "X": return Date.getTimezoneOffset(context.getTimezone()); case "ZZ": // Timezone offset in seconds return context.getTimezoneOffset() * -60; case "u": return context.getDay(); case "L": return ($D.isLeapYear(context.getFullYear())) ? 1 : 0; case "B": // Swatch Internet Time (.beats) return "@"+((context.getUTCSeconds() + (context.getUTCMinutes()*60) + ((context.getUTCHours()+1)*3600))/86.4); default: return m; } }; }; $P.toString = function (format, ignoreStandards) { // Standard Date and Time Format Strings. Formats pulled from CultureInfo file and // may vary by culture. if (!ignoreStandards && format && format.length === 1) { output = parseStandardFormats.call(this, format); if (output) { return output; } } var parseFormatStrings = parseFormatStringsClosure(this); return format ? format.replace(/((\\)?(dd?d?d?|MM?M?M?|yy?y?y?|hh?|HH?|mm?|ss?|tt?|S|q|Q|WW?W?W?)(?![^\[]*\]))/g, parseFormatStrings).replace(/\[|\]/g, "") : this._toString(); }; }()); /************************************************************* * SugarPak - Domain Specific Language - Syntactical Sugar * *************************************************************/ (function () { var $D = Date, $P = $D.prototype, $N = Number.prototype; // private $P._orient = +1; // private $P._nth = null; // private $P._is = false; // private $P._same = false; // private $P._isSecond = false; // private $N._dateElement = "days"; /** * Moves the date to the next instance of a date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.today().next().friday();
	Date.today().next().fri();
	Date.today().next().march();
	Date.today().next().mar();
	Date.today().next().week();
	
* * @return {Date} date */ $P.next = function () { this._move = true; this._orient = +1; return this; }; /** * Creates a new Date (Date.today()) and moves the date to the next instance of the date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.next().friday();
	Date.next().fri();
	Date.next().march();
	Date.next().mar();
	Date.next().week();
	
* * @return {Date} date */ $D.next = function () { return $D.today().next(); }; /** * Moves the date to the previous instance of a date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.today().last().friday();
	Date.today().last().fri();
	Date.today().last().march();
	Date.today().last().mar();
	Date.today().last().week();
	
* * @return {Date} date */ $P.last = $P.prev = $P.previous = function () { this._move = true; this._orient = -1; return this; }; /** * Creates a new Date (Date.today()) and moves the date to the previous instance of the date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.last().friday();
	Date.last().fri();
	Date.previous().march();
	Date.prev().mar();
	Date.last().week();
	
* * @return {Date} date */ $D.last = $D.prev = $D.previous = function () { return $D.today().last(); }; /** * Performs a equality check when followed by either a month name, day name or .weekday() function. * Example

	Date.today().is().friday(); // true|false
	Date.today().is().fri();
	Date.today().is().march();
	Date.today().is().mar();
	
* * @return {Boolean} true|false */ $P.is = function () { this._is = true; return this; }; /** * Determines if two date objects occur on/in exactly the same instance of the subsequent date part function. * The function .same() must be followed by a date part function (example: .day(), .month(), .year(), etc). * * An optional Date can be passed in the date part function. If now date is passed as a parameter, 'Now' is used. * * The following example demonstrates how to determine if two dates fall on the exact same day. * * Example

	var d1 = Date.today(); // today at 00:00
	var d2 = new Date();   // exactly now.

	// Do they occur on the same day?
	d1.same().day(d2); // true
	
	// Do they occur on the same hour?
	d1.same().hour(d2); // false, unless d2 hour is '00' (midnight).
	
	// What if it's the same day, but one year apart?
	var nextYear = Date.today().add(1).year();

	d1.same().day(nextYear); // false, because the dates must occur on the exact same day. 
	
* * Scenario: Determine if a given date occurs during some week period 2 months from now. * * Example

	var future = Date.today().add(2).months();
	return someDate.same().week(future); // true|false;
	
* * @return {Boolean} true|false */ $P.same = function () { this._same = true; this._isSecond = false; return this; }; /** * Determines if the current date/time occurs during Today. Must be preceded by the .is() function. * Example

	someDate.is().today();    // true|false
	new Date().is().today();  // true
	Date.today().is().today();// true
	Date.today().add(-1).day().is().today(); // false
	
* * @return {Boolean} true|false */ $P.today = function () { return this.same().day(); }; /** * Determines if the current date is a weekday. This function must be preceded by the .is() function. * Example

	Date.today().is().weekday(); // true|false
	
* * @return {Boolean} true|false */ $P.weekday = function () { if (this._nth) { return df("Weekday").call(this); } if (this._move) { return this.addWeekdays(this._orient); } if (this._is) { this._is = false; return (!this.is().sat() && !this.is().sun()); } return false; }; /** * Determines if the current date is on the weekend. This function must be preceded by the .is() function. * Example

	Date.today().is().weekend(); // true|false
	
* * @return {Boolean} true|false */ $P.weekend = function () { if (this._is) { this._is = false; return (this.is().sat() || this.is().sun()); } return false; }; /** * Sets the Time of the current Date instance. A string "6:15 pm" or config object {hour:18, minute:15} are accepted. * Example

	// Set time to 6:15pm with a String
	Date.today().at("6:15pm");

	// Set time to 6:15pm with a config object
	Date.today().at({hour:18, minute:15});
	
* * @return {Date} date */ $P.at = function (time) { return (typeof time === "string") ? $D.parse(this.toString("d") + " " + time) : this.set(time); }; /** * Creates a new Date() and adds this (Number) to the date based on the preceding date element function (eg. second|minute|hour|day|month|year). * Example

	// Undeclared Numbers must be wrapped with parentheses. Requirment of JavaScript.
	(3).days().fromNow();
	(6).months().fromNow();

	// Declared Number variables do not require parentheses. 
	var n = 6;
	n.months().fromNow();
	
* * @return {Date} A new Date instance */ $N.fromNow = $N.after = function (date) { var c = {}; c[this._dateElement] = this; return ((!date) ? new Date() : date.clone()).add(c); }; /** * Creates a new Date() and subtract this (Number) from the date based on the preceding date element function (eg. second|minute|hour|day|month|year). * Example

	// Undeclared Numbers must be wrapped with parentheses. Requirment of JavaScript.
	(3).days().ago();
	(6).months().ago();

	// Declared Number variables do not require parentheses. 
	var n = 6;
	n.months().ago();
	
* * @return {Date} A new Date instance */ $N.ago = $N.before = function (date) { var c = {}, s = (this._dateElement[this._dateElement.length-1] !== "s") ? this._dateElement + "s" : this._dateElement; c[s] = this * -1; return ((!date) ? new Date() : date.clone()).add(c); }; // Do NOT modify the following string tokens. These tokens are used to build dynamic functions. // All culture-specific strings can be found in the CultureInfo files. var dx = ("sunday monday tuesday wednesday thursday friday saturday").split(/\s/), mx = ("january february march april may june july august september october november december").split(/\s/), px = ("Millisecond Second Minute Hour Day Week Month Year Quarter Weekday").split(/\s/), pxf = ("Milliseconds Seconds Minutes Hours Date Week Month FullYear Quarter").split(/\s/), nth = ("final first second third fourth fifth").split(/\s/), de; /** * Returns an object literal of all the date parts. * Example

	var o = new Date().toObject();
	
	// { year: 2008, month: 4, week: 20, day: 13, hour: 18, minute: 9, second: 32, millisecond: 812 }
	
	// The object properties can be referenced directly from the object.
	
	alert(o.day);  // alerts "13"
	alert(o.year); // alerts "2008"
	
* * @return {Date} An object literal representing the original date object. */ $P.toObject = function () { var o = {}; for (var i = 0; i < px.length; i++) { if (this["get" + pxf[i]]) { o[px[i].toLowerCase()] = this["get" + pxf[i]](); } } return o; }; /** * Returns a date created from an object literal. Ignores the .week property if set in the config. * Example

	var o = new Date().toObject();
	
	return Date.fromObject(o); // will return the same date. 

	var o2 = {month: 1, day: 20, hour: 18}; // birthday party!
	Date.fromObject(o2);
	
* * @return {Date} An object literal representing the original date object. */ $D.fromObject = function(config) { config.week = null; return Date.today().set(config); }; // Create day name functions and abbreviated day name functions (eg. monday(), friday(), fri()). var df = function (n) { return function () { if (this._is) { this._is = false; return this.getDay() === n; } if (this._move) { this._move = null; } if (this._nth !== null) { // If the .second() function was called earlier, remove the _orient // from the date, and then continue. // This is required because 'second' can be used in two different context. // // Example // // Date.today().add(1).second(); // Date.march().second().monday(); // // Things get crazy with the following... // Date.march().add(1).second().second().monday(); // but it works!! // if (this._isSecond) { this.addSeconds(this._orient * -1); } // make sure we reset _isSecond this._isSecond = false; var ntemp = this._nth; this._nth = null; var temp = this.clone().moveToLastDayOfMonth(); this.moveToNthOccurrence(n, ntemp); if (this > temp) { throw new RangeError($D.getDayName(n) + " does not occur " + ntemp + " times in the month of " + $D.getMonthName(temp.getMonth()) + " " + temp.getFullYear() + "."); } return this; } return this.moveToDayOfWeek(n, this._orient); }; }; var sdf = function (n) { return function () { var t = $D.today(), shift = n - t.getDay(); if (n === 0 && Date.CultureInfo.firstDayOfWeek === 1 && t.getDay() !== 0) { shift = shift + 7; } return t.addDays(shift); }; }; // Create month name functions and abbreviated month name functions (eg. january(), march(), mar()). var month_instance_functions = function (n) { return function () { if (this._is) { this._is = false; return this.getMonth() === n; } return this.moveToMonth(n, this._orient); }; }; var month_static_functions = function (n) { return function () { return $D.today().set({ month: n, day: 1 }); }; }; var processTerms = function (names, staticFunc, instanceFunc) { for (var i = 0; i < names.length; i++) { // Create constant static Name variables. $D[names[i].toUpperCase()] = $D[names[i].toUpperCase().substring(0, 3)] = i; // Create Name functions. $D[names[i]] = $D[names[i].substring(0, 3)] = staticFunc(i); // Create Name instance functions. $P[names[i]] = $P[names[i].substring(0, 3)] = instanceFunc(i); } }; processTerms(dx, sdf, df); processTerms(mx, month_static_functions, month_instance_functions); // Create date element functions and plural date element functions used with Date (eg. day(), days(), months()). var ef = function (j) { return function () { // if the .second() function was called earlier, the _orient // has alread been added. Just return this and reset _isSecond. if (this._isSecond) { this._isSecond = false; return this; } if (this._same) { this._same = this._is = false; var o1 = this.toObject(), o2 = (arguments[0] || new Date()).toObject(), v = "", k = j.toLowerCase(); // the substr trick with -1 doesn't work in IE8 or less k = (k[k.length-1] === "s") ? k.substring(0,k.length-1) : k; for (var m = (px.length - 1); m > -1; m--) { v = px[m].toLowerCase(); if (o1[v] !== o2[v]) { return false; } if (k === v) { break; } } return true; } if (j.substring(j.length - 1) !== "s") { j += "s"; } if (this._move) { this._move = null; } return this["add" + j](this._orient); }; }; var nf = function (n) { return function () { this._dateElement = n; return this; }; }; for (var k = 0; k < px.length; k++) { de = px[k].toLowerCase(); if(de !== "weekday") { // Create date element functions and plural date element functions used with Date (eg. day(), days(), months()). $P[de] = $P[de + "s"] = ef(px[k]); // Create date element functions and plural date element functions used with Number (eg. day(), days(), months()). $N[de] = $N[de + "s"] = nf(de + "s"); } } $P._ss = ef("Second"); var nthfn = function (n) { return function (dayOfWeek) { if (this._same) { return this._ss(arguments[0]); } if (dayOfWeek || dayOfWeek === 0) { return this.moveToNthOccurrence(dayOfWeek, n); } this._nth = n; // if the operator is 'second' add the _orient, then deal with it later... if (n === 2 && (dayOfWeek === undefined || dayOfWeek === null)) { this._isSecond = true; return this.addSeconds(this._orient); } return this; }; }; for (var l = 0; l < nth.length; l++) { $P[nth[l]] = (l === 0) ? nthfn(-1) : nthfn(l); } }()); (function () { "use strict"; Date.Parsing = { Exception: function (s) { this.message = "Parse error at '" + s.substring(0, 10) + " ...'"; } }; var $P = Date.Parsing; var dayOffsets = { standard: [0,31,59,90,120,151,181,212,243,273,304,334], leap: [0,31,60,91,121,152,182,213,244,274,305,335] }; $P.isLeapYear = function(year) { return ((year % 4 === 0) && (year % 100 !== 0)) || (year % 400 === 0); }; var utils = { multiReplace : function (str, hash ) { var key; for (key in hash) { if (Object.prototype.hasOwnProperty.call(hash, key)) { var regex; if (typeof hash[key] === "function") { } else { regex = (hash[key] instanceof RegExp) ? hash[key] : new RegExp(hash[key], "g"); } str = str.replace(regex, key); } } return str; }, getDayOfYearFromWeek : function (obj) { var d, jan4, offset; obj.weekDay = (!obj.weekDay && obj.weekDay !== 0) ? 1 : obj.weekDay; d = new Date(obj.year, 0, 4); jan4 = d.getDay() === 0 ? 7 : d.getDay(); // JS is 0 indexed on Sunday. offset = jan4+3; obj.dayOfYear = ((obj.week * 7) + (obj.weekDay === 0 ? 7 : obj.weekDay))-offset; return obj; }, getDayOfYear : function (obj, dayOffset) { if (!obj.dayOfYear) { obj = utils.getDayOfYearFromWeek(obj); } for (var i=0;i <= dayOffset.length;i++) { if (obj.dayOfYear < dayOffset[i] || i === dayOffset.length) { obj.day = obj.day ? obj.day : (obj.dayOfYear - dayOffset[i-1]); break; } else { obj.month = i; } } return obj; }, adjustForTimeZone : function (obj, date) { var offset; if (obj.zone.toUpperCase() === "Z" || (obj.zone_hours === 0 && obj.zone_minutes === 0)) { // it's UTC/GML so work out the current timeszone offset offset = -date.getTimezoneOffset(); } else { offset = (obj.zone_hours*60) + (obj.zone_minutes || 0); if (obj.zone_sign === "+") { offset *= -1; } offset -= date.getTimezoneOffset(); } date.setMinutes(date.getMinutes()+offset); return date; }, setDefaults : function (obj) { obj.year = obj.year || Date.today().getFullYear(); obj.hours = obj.hours || 0; obj.minutes = obj.minutes || 0; obj.seconds = obj.seconds || 0; obj.milliseconds = obj.milliseconds || 0; if (!(!obj.month && (obj.week || obj.dayOfYear))) { // if we have a month, or if we don't but don't have the day calculation data obj.month = obj.month || 0; obj.day = obj.day || 1; } return obj; }, dataNum: function (data, mod, explict, postProcess) { var dataNum = data*1; if (mod) { if (postProcess) { return data ? mod(data)*1 : data; } else { return data ? mod(dataNum) : data; } } else if (!explict){ return data ? dataNum : data; } else { return (data && typeof data !== "undefined") ? dataNum : data; } }, timeDataProcess: function (obj) { var timeObj = {}; for (var x in obj.data) { if (obj.data.hasOwnProperty(x)) { timeObj[x] = obj.ignore[x] ? obj.data[x] : utils.dataNum(obj.data[x], obj.mods[x], obj.explict[x], obj.postProcess[x]); } } if (obj.data.secmins) { obj.data.secmins = obj.data.secmins.replace(",", ".") * 60; if (!timeObj.minutes) { timeObj.minutes = obj.data.secmins; } else if (!timeObj.seconds) { timeObj.seconds = obj.data.secmins; } delete obj.secmins; } return timeObj; }, buildTimeObjectFromData: function (data) { var time = utils.timeDataProcess({ data: { year : data[1], month : data[5], day : data[7], week : data[8], dayOfYear : data[10], hours : data[15], zone_hours : data[23], zone_minutes : data[24], zone : data[21], zone_sign : data[22], weekDay : data[9], minutes: data[16], seconds: data[19], milliseconds: data[20], secmins: data[18] }, mods: { month: function(data) { return data-1; }, weekDay: function (data) { data = Math.abs(data); return (data === 7 ? 0 : data); }, minutes: function (data) { return data.replace(":",""); }, seconds: function (data) { return Math.floor( (data.replace(":","").replace(",","."))*1 ); }, milliseconds: function (data) { return (data.replace(",",".")*1000); } }, postProcess: { minutes: true, seconds: true, milliseconds: true }, explict: { zone_hours: true, zone_minutes: true }, ignore: { zone: true, zone_sign: true, secmins: true } }); return time; }, addToHash: function (hash, keys, data) { keys = keys; data = data; var len = keys.length; for (var i = 0; i < len; i++) { hash[keys[i]] = data[i]; } return hash; }, combineRegex: function (r1, r2) { return new RegExp("(("+r1.source+")\\s("+r2.source+"))"); }, getDateNthString: function(add, last, inc){ if (add) { return Date.today().addDays(inc).toString("d"); } else if (last) { return Date.today().last()[inc]().toString("d"); } }, buildRegexData: function (array) { var arr = []; var len = array.length; for (var i=0; i < len; i++) { if (Object.prototype.toString.call(array[i]) === '[object Array]') { // oldIE compat version of Array.isArray arr.push(this.combineRegex(array[i][0], array[i][1])); } else { arr.push(array[i]); } } return arr; } }; $P.processTimeObject = function (obj) { var date, dayOffset; utils.setDefaults(obj); dayOffset = ($P.isLeapYear(obj.year)) ? dayOffsets.leap : dayOffsets.standard; if (!obj.month && (obj.week || obj.dayOfYear)) { utils.getDayOfYear(obj, dayOffset); } else { obj.dayOfYear = dayOffset[obj.month] + obj.day; } date = new Date(obj.year, obj.month, obj.day, obj.hours, obj.minutes, obj.seconds, obj.milliseconds); if (obj.zone) { utils.adjustForTimeZone(obj, date); // adjust (and calculate) for timezone } return date; }; $P.ISO = { regex : /^([\+-]?\d{4}(?!\d{2}\b))((-?)((0[1-9]|1[0-2])(\3([12]\d|0[1-9]|3[01]))?|W([0-4]\d|5[0-3])(-?[1-7])?|(00[1-9]|0[1-9]\d|[12]\d{2}|3([0-5]\d|6[1-6])))([T\s]((([01]\d|2[0-4])((:?)[0-5]\d)?|24\:?00)([\.,]\d+(?!:))?)?(\17[0-5]\d([\.,]\d+)?)?\s?([zZ]|([\+-])([01]\d|2[0-3]):?([0-5]\d)?)?)?)?$/, parse : function (s) { var time, data = s.match(this.regex); if (!data || !data.length) { return null; } time = utils.buildTimeObjectFromData(data); if (!time.year || (!time.year && (!time.month && !time.day) && (!time.week && !time.dayOfYear)) ) { return null; } return $P.processTimeObject(time); } }; $P.Numeric = { isNumeric: function (e){return!isNaN(parseFloat(e))&&isFinite(e);}, regex: /\b([0-1]?[0-9])([0-3]?[0-9])([0-2]?[0-9]?[0-9][0-9])\b/i, parse: function (s) { var data, i, time = {}, order = Date.CultureInfo.dateElementOrder.split(""); if (!(this.isNumeric(s)) || // if it's non-numeric OR (s[0] === "+" && s[0] === "-")) { // It's an arithmatic string (eg +/-1000) return null; } if (s.length < 5 && s.indexOf(".") < 0 && s.indexOf("/") < 0) { // assume it's just a year. time.year = s; return $P.processTimeObject(time); } data = s.match(this.regex); if (!data || !data.length) { return null; } for (i=0; i < order.length; i++) { switch(order[i]) { case "d": time.day = data[i+1]; break; case "m": time.month = (data[i+1]-1); break; case "y": time.year = data[i+1]; break; } } return $P.processTimeObject(time); } }; $P.Normalizer = { regexData: function () { var $R = Date.CultureInfo.regexPatterns; return utils.buildRegexData([ $R.tomorrow, $R.yesterday, [$R.past, $R.mon], [$R.past, $R.tue], [$R.past, $R.wed], [$R.past, $R.thu], [$R.past, $R.fri], [$R.past, $R.sat], [$R.past, $R.sun] ]); }, basicReplaceHash : function() { var $R = Date.CultureInfo.regexPatterns; return { "January": $R.jan.source, "February": $R.feb, "March": $R.mar, "April": $R.apr, "May": $R.may, "June": $R.jun, "July": $R.jul, "August": $R.aug, "September": $R.sep, "October": $R.oct, "November": $R.nov, "December": $R.dec, "": /\bat\b/gi, " ": /\s{2,}/, "am": $R.inTheMorning, "9am": $R.thisMorning, "pm": $R.inTheEvening, "7pm":$R.thisEvening }; }, keys : function(){ return [ utils.getDateNthString(true, false, 1), // tomorrow utils.getDateNthString(true, false, -1), // yesterday utils.getDateNthString(false, true, "monday"), //last mon utils.getDateNthString(false, true, "tuesday"), //last tues utils.getDateNthString(false, true, "wednesday"), //last wed utils.getDateNthString(false, true, "thursday"), //last thurs utils.getDateNthString(false, true, "friday"), //last fri utils.getDateNthString(false, true, "saturday"), //last sat utils.getDateNthString(false, true, "sunday") //last sun ]; }, buildRegexFunctions: function () { var $R = Date.CultureInfo.regexPatterns; var __ = Date.i18n.__; var tomorrowRE = new RegExp("(\\b\\d\\d?("+__("AM")+"|"+__("PM")+")? )("+$R.tomorrow.source.slice(1)+")", "i"); // adapted tomorrow regex for AM PM relative dates var todayRE = new RegExp($R.today.source + "(?!\\s*([+-]))\\b"); // today, but excludes the math operators (eg "today + 2h") this.replaceFuncs = [ [todayRE, function (full) { return (full.length > 1) ? Date.today().toString("d") : full; }], [tomorrowRE, function(full, m1) { var t = Date.today().addDays(1).toString("d"); return (t + " " + m1); }], [$R.amThisMorning, function(str, am){return am;}], [$R.pmThisEvening, function(str, pm){return pm;}] ]; }, buildReplaceData: function () { this.buildRegexFunctions(); this.replaceHash = utils.addToHash(this.basicReplaceHash(), this.keys(), this.regexData()); }, stringReplaceFuncs: function (s) { for (var i=0; i < this.replaceFuncs.length; i++) { s = s.replace(this.replaceFuncs[i][0], this.replaceFuncs[i][1]); } return s; }, parse: function (s) { s = this.stringReplaceFuncs(s); s = utils.multiReplace(s, this.replaceHash); try { var n = s.split(/([\s\-\.\,\/\x27]+)/); if (n.length === 3 && $P.Numeric.isNumeric(n[0]) && $P.Numeric.isNumeric(n[2]) && (n[2].length >= 4)) { // ok, so we're dealing with x/year. But that's not a full date. // This fixes wonky dateElementOrder parsing when set to dmy order. if (Date.CultureInfo.dateElementOrder[0] === "d") { s = "1/" + n[0] + "/" + n[2]; // set to 1st of month and normalize the seperator } } } catch (e) {} return s; } }; $P.Normalizer.buildReplaceData(); }()); (function () { var $P = Date.Parsing; var _ = $P.Operators = { // // Tokenizers // rtoken: function (r) { // regex token return function (s) { var mx = s.match(r); if (mx) { return ([ mx[0], s.substring(mx[0].length) ]); } else { throw new $P.Exception(s); } }; }, token: function () { // whitespace-eating token return function (s) { return _.rtoken(new RegExp("^\\s*" + s + "\\s*"))(s); }; }, stoken: function (s) { // string token return _.rtoken(new RegExp("^" + s)); }, // Atomic Operators until: function (p) { return function (s) { var qx = [], rx = null; while (s.length) { try { rx = p.call(this, s); } catch (e) { qx.push(rx[0]); s = rx[1]; continue; } break; } return [ qx, s ]; }; }, many: function (p) { return function (s) { var rx = [], r = null; while (s.length) { try { r = p.call(this, s); } catch (e) { return [ rx, s ]; } rx.push(r[0]); s = r[1]; } return [ rx, s ]; }; }, // generator operators -- see below optional: function (p) { return function (s) { var r = null; try { r = p.call(this, s); } catch (e) { return [ null, s ]; } return [ r[0], r[1] ]; }; }, not: function (p) { return function (s) { try { p.call(this, s); } catch (e) { return [null, s]; } throw new $P.Exception(s); }; }, ignore: function (p) { return p ? function (s) { var r = null; r = p.call(this, s); return [null, r[1]]; } : null; }, product: function () { var px = arguments[0], qx = Array.prototype.slice.call(arguments, 1), rx = []; for (var i = 0 ; i < px.length ; i++) { rx.push(_.each(px[i], qx)); } return rx; }, cache: function (rule) { var cache = {}, cache_length = 0, cache_keys = [], CACHE_MAX = Date.Config.CACHE_MAX || 100000, r = null; var cacheCheck = function () { if (cache_length === CACHE_MAX) { // kill several keys, don't want to have to do this all the time... for (var i=0; i < 10; i++) { var key = cache_keys.shift(); if (key) { delete cache[key]; cache_length--; } } } }; return function (s) { cacheCheck(); try { r = cache[s] = (cache[s] || rule.call(this, s)); } catch (e) { r = cache[s] = e; } cache_length++; cache_keys.push(s); if (r instanceof $P.Exception) { throw r; } else { return r; } }; }, // vector operators -- see below any: function () { var px = arguments; return function (s) { var r = null; for (var i = 0; i < px.length; i++) { if (px[i] == null) { continue; } try { r = (px[i].call(this, s)); } catch (e) { r = null; } if (r) { return r; } } throw new $P.Exception(s); }; }, each: function () { var px = arguments; return function (s) { var rx = [], r = null; for (var i = 0; i < px.length ; i++) { if (px[i] == null) { continue; } try { r = (px[i].call(this, s)); } catch (e) { throw new $P.Exception(s); } rx.push(r[0]); s = r[1]; } return [ rx, s]; }; }, all: function () { var px = arguments, _ = _; return _.each(_.optional(px)); }, // delimited operators sequence: function (px, d, c) { d = d || _.rtoken(/^\s*/); c = c || null; if (px.length === 1) { return px[0]; } return function (s) { var r = null, q = null; var rx = []; for (var i = 0; i < px.length ; i++) { try { r = px[i].call(this, s); } catch (e) { break; } rx.push(r[0]); try { q = d.call(this, r[1]); } catch (ex) { q = null; break; } s = q[1]; } if (!r) { throw new $P.Exception(s); } if (q) { throw new $P.Exception(q[1]); } if (c) { try { r = c.call(this, r[1]); } catch (ey) { throw new $P.Exception(r[1]); } } return [ rx, (r?r[1]:s) ]; }; }, // // Composite Operators // between: function (d1, p, d2) { d2 = d2 || d1; var _fn = _.each(_.ignore(d1), p, _.ignore(d2)); return function (s) { var rx = _fn.call(this, s); return [[rx[0][0], r[0][2]], rx[1]]; }; }, list: function (p, d, c) { d = d || _.rtoken(/^\s*/); c = c || null; return (p instanceof Array ? _.each(_.product(p.slice(0, -1), _.ignore(d)), p.slice(-1), _.ignore(c)) : _.each(_.many(_.each(p, _.ignore(d))), px, _.ignore(c))); }, set: function (px, d, c) { d = d || _.rtoken(/^\s*/); c = c || null; return function (s) { // r is the current match, best the current 'best' match // which means it parsed the most amount of input var r = null, p = null, q = null, rx = null, best = [[], s], last = false; // go through the rules in the given set for (var i = 0; i < px.length ; i++) { // last is a flag indicating whether this must be the last element // if there is only 1 element, then it MUST be the last one q = null; p = null; r = null; last = (px.length === 1); // first, we try simply to match the current pattern // if not, try the next pattern try { r = px[i].call(this, s); } catch (e) { continue; } // since we are matching against a set of elements, the first // thing to do is to add r[0] to matched elements rx = [[r[0]], r[1]]; // if we matched and there is still input to parse and // we don't already know this is the last element, // we're going to next check for the delimiter ... // if there's none, or if there's no input left to parse // than this must be the last element after all ... if (r[1].length > 0 && ! last) { try { q = d.call(this, r[1]); } catch (ex) { last = true; } } else { last = true; } // if we parsed the delimiter and now there's no more input, // that means we shouldn't have parsed the delimiter at all // so don't update r and mark this as the last element ... if (!last && q[1].length === 0) { last = true; } // so, if this isn't the last element, we're going to see if // we can get any more matches from the remaining (unmatched) // elements ... if (!last) { // build a list of the remaining rules we can match against, // i.e., all but the one we just matched against var qx = []; for (var j = 0; j < px.length ; j++) { if (i !== j) { qx.push(px[j]); } } // now invoke recursively set with the remaining input // note that we don't include the closing delimiter ... // we'll check for that ourselves at the end p = _.set(qx, d).call(this, q[1]); // if we got a non-empty set as a result ... // (otw rx already contains everything we want to match) if (p[0].length > 0) { // update current result, which is stored in rx ... // basically, pick up the remaining text from p[1] // and concat the result from p[0] so that we don't // get endless nesting ... rx[0] = rx[0].concat(p[0]); rx[1] = p[1]; } } // at this point, rx either contains the last matched element // or the entire matched set that starts with this element. // now we just check to see if this variation is better than // our best so far, in terms of how much of the input is parsed if (rx[1].length < best[1].length) { best = rx; } // if we've parsed all the input, then we're finished if (best[1].length === 0) { break; } } // so now we've either gone through all the patterns trying them // as the initial match; or we found one that parsed the entire // input string ... // if best has no matches, just return empty set ... if (best[0].length === 0) { return best; } // if a closing delimiter is provided, then we have to check it also if (c) { // we try this even if there is no remaining input because the pattern // may well be optional or match empty input ... try { q = c.call(this, best[1]); } catch (ey) { throw new $P.Exception(best[1]); } // it parsed ... be sure to update the best match remaining input best[1] = q[1]; } // if we're here, either there was no closing delimiter or we parsed it // so now we have the best match; just return it! return best; }; }, forward: function (gr, fname) { return function (s) { return gr[fname].call(this, s); }; }, // // Translation Operators // replace: function (rule, repl) { return function (s) { var r = rule.call(this, s); return [repl, r[1]]; }; }, process: function (rule, fn) { return function (s) { var r = rule.call(this, s); return [fn.call(this, r[0]), r[1]]; }; }, min: function (min, rule) { return function (s) { var rx = rule.call(this, s); if (rx[0].length < min) { throw new $P.Exception(s); } return rx; }; } }; // Generator Operators And Vector Operators // Generators are operators that have a signature of F(R) => R, // taking a given rule and returning another rule, such as // ignore, which parses a given rule and throws away the result. // Vector operators are those that have a signature of F(R1,R2,...) => R, // take a list of rules and returning a new rule, such as each. // Generator operators are converted (via the following _generator // function) into functions that can also take a list or array of rules // and return an array of new rules as though the function had been // called on each rule in turn (which is what actually happens). // This allows generators to be used with vector operators more easily. // Example: // each(ignore(foo, bar)) instead of each(ignore(foo), ignore(bar)) // This also turns generators into vector operators, which allows // constructs like: // not(cache(foo, bar)) var _generator = function (op) { function gen() { var args = null, rx = [], px, i; if (arguments.length > 1) { args = Array.prototype.slice.call(arguments); } else if (arguments[0] instanceof Array) { args = arguments[0]; } if (args) { px = args.shift(); if (px.length > 0) { args.unshift(px[i]); rx.push(op.apply(null, args)); args.shift(); return rx; } } else { return op.apply(null, arguments); } } return gen; }; var gx = "optional not ignore cache".split(/\s/); for (var i = 0 ; i < gx.length ; i++) { _[gx[i]] = _generator(_[gx[i]]); } var _vector = function (op) { return function () { if (arguments[0] instanceof Array) { return op.apply(null, arguments[0]); } else { return op.apply(null, arguments); } }; }; var vx = "each any all".split(/\s/); for (var j = 0 ; j < vx.length ; j++) { _[vx[j]] = _vector(_[vx[j]]); } }()); (function () { var $D = Date; var flattenAndCompact = function (ax) { var rx = []; for (var i = 0; i < ax.length; i++) { if (ax[i] instanceof Array) { rx = rx.concat(flattenAndCompact(ax[i])); } else { if (ax[i]) { rx.push(ax[i]); } } } return rx; }; var parseMeridian = function () { if (this.meridian && (this.hour || this.hour === 0)) { if (this.meridian === "a" && this.hour > 11 && Date.Config.strict24hr){ throw "Invalid hour and meridian combination"; } else if (this.meridian === "p" && this.hour < 12 && Date.Config.strict24hr){ throw "Invalid hour and meridian combination"; } else if (this.meridian === "p" && this.hour < 12) { this.hour = this.hour + 12; } else if (this.meridian === "a" && this.hour === 12) { this.hour = 0; } } }; var setDefaults = function () { var now = new Date(); if ((this.hour || this.minute) && (!this.month && !this.year && !this.day)) { this.day = now.getDate(); } if (!this.year) { this.year = now.getFullYear(); } if (!this.month && this.month !== 0) { this.month = now.getMonth(); } if (!this.day) { this.day = 1; } if (!this.hour) { this.hour = 0; } if (!this.minute) { this.minute = 0; } if (!this.second) { this.second = 0; } if (!this.millisecond) { this.millisecond = 0; } }; var finishUtils = { getToday: function () { if (this.now || "hour minute second".indexOf(this.unit) !== -1) { return new Date(); } else { return $D.today(); } }, setDaysFromWeekday: function (today, orient){ var gap; orient = orient || 1; this.unit = "day"; gap = ($D.getDayNumberFromName(this.weekday) - today.getDay()); this.days = gap ? ((gap + (orient * 7)) % 7) : (orient * 7); return this; }, setMonthsFromMonth: function (today, orient) { var gap; orient = orient || 1; this.unit = "month"; gap = (this.month - today.getMonth()); this.months = gap ? ((gap + (orient * 12)) % 12) : (orient * 12); this.month = null; return this; }, setDMYFromWeekday: function () { var d = Date[this.weekday](); this.day = d.getDate(); if (!this.month) { this.month = d.getMonth(); } this.year = d.getFullYear(); return this; }, setUnitValue: function (orient) { if (!this.value && this.operator && this.operator !== null && this[this.unit + "s"] && this[this.unit + "s"] !== null) { this[this.unit + "s"] = this[this.unit + "s"] + ((this.operator === "add") ? 1 : -1) + (this.value||0) * orient; } else if (this[this.unit + "s"] == null || this.operator != null) { if (!this.value) { this.value = 1; } this[this.unit + "s"] = this.value * orient; } }, generateDateFromWeeks: function () { var weekday = (this.weekday !== undefined) ? this.weekday : "today"; var d = Date[weekday]().addWeeks(this.weeks); if (this.now) { d.setTimeToNow(); } return d; } }; $D.Translator = { hour: function (s) { return function () { this.hour = Number(s); }; }, minute: function (s) { return function () { this.minute = Number(s); }; }, second: function (s) { return function () { this.second = Number(s); }; }, /* for ss.s format */ secondAndMillisecond: function (s) { return function () { var mx = s.match(/^([0-5][0-9])\.([0-9]{1,3})/); this.second = Number(mx[1]); this.millisecond = Number(mx[2]); }; }, meridian: function (s) { return function () { this.meridian = s.slice(0, 1).toLowerCase(); }; }, timezone: function (s) { return function () { var n = s.replace(/[^\d\+\-]/g, ""); if (n.length) { this.timezoneOffset = Number(n); } else { this.timezone = s.toLowerCase(); } }; }, day: function (x) { var s = x[0]; return function () { this.day = Number(s.match(/\d+/)[0]); if (this.day < 1) { throw "invalid day"; } }; }, month: function (s) { return function () { this.month = (s.length === 3) ? "jan feb mar apr may jun jul aug sep oct nov dec".indexOf(s)/4 : Number(s) - 1; if (this.month < 0) { throw "invalid month"; } }; }, year: function (s) { return function () { var n = Number(s); this.year = ((s.length > 2) ? n : (n + (((n + 2000) < Date.CultureInfo.twoDigitYearMax) ? 2000 : 1900))); }; }, rday: function (s) { return function () { switch (s) { case "yesterday": this.days = -1; break; case "tomorrow": this.days = 1; break; case "today": this.days = 0; break; case "now": this.days = 0; this.now = true; break; } }; }, finishExact: function (x) { var d; x = (x instanceof Array) ? x : [x]; for (var i = 0 ; i < x.length ; i++) { if (x[i]) { x[i].call(this); } } setDefaults.call(this); parseMeridian.call(this); if (this.day > $D.getDaysInMonth(this.year, this.month)) { throw new RangeError(this.day + " is not a valid value for days."); } d = new Date(this.year, this.month, this.day, this.hour, this.minute, this.second, this.millisecond); if (this.year < 100) { d.setFullYear(this.year); // means years less that 100 are process correctly. JS will parse it otherwise as 1900-1999. } if (this.timezone) { d.set({ timezone: this.timezone }); } else if (this.timezoneOffset) { d.set({ timezoneOffset: this.timezoneOffset }); } return d; }, finish: function (x) { var today, expression, orient, temp; x = (x instanceof Array) ? flattenAndCompact(x) : [ x ]; if (x.length === 0) { return null; } for (var i = 0 ; i < x.length ; i++) { if (typeof x[i] === "function") { x[i].call(this); } } if (this.now && !this.unit && !this.operator) { return new Date(); } else { today = finishUtils.getToday.call(this); } expression = !!(this.days && this.days !== null || this.orient || this.operator); orient = ((this.orient === "past" || this.operator === "subtract") ? -1 : 1); if (this.month && this.unit === "week") { this.value = this.month + 1; delete this.month; delete this.day; } if ((this.month || this.month === 0) && "year day hour minute second".indexOf(this.unit) !== -1) { if (!this.value) { this.value = this.month + 1; } this.month = null; expression = true; } if (!expression && this.weekday && !this.day && !this.days) { finishUtils.setDMYFromWeekday.call(this); } if (expression && this.weekday && this.unit !== "month" && this.unit !== "week") { finishUtils.setDaysFromWeekday.call(this, today, orient); } if (this.weekday && this.unit !== "week" && !this.day && !this.days) { temp = Date[this.weekday](); this.day = temp.getDate(); if (temp.getMonth() !== today.getMonth()) { this.month = temp.getMonth(); } } if (this.month && this.unit === "day" && this.operator) { if (!this.value) { this.value = (this.month + 1); } this.month = null; } if (this.value != null && this.month != null && this.year != null) { this.day = this.value * 1; } if (this.month && !this.day && this.value) { today.set({ day: this.value * 1 }); if (!expression) { this.day = this.value * 1; } } if (!this.month && this.value && this.unit === "month" && !this.now) { this.month = this.value; expression = true; } if (expression && (this.month || this.month === 0) && this.unit !== "year") { finishUtils.setMonthsFromMonth.call(this, today, orient); } if (!this.unit) { this.unit = "day"; } finishUtils.setUnitValue.call(this, orient); parseMeridian.call(this); if ((this.month || this.month === 0) && !this.day) { this.day = 1; } if (!this.orient && !this.operator && this.unit === "week" && this.value && !this.day && !this.month) { return Date.today().setWeek(this.value); } if (this.unit === "week" && this.weeks && !this.day && !this.month) { return finishUtils.generateDateFromWeeks.call(this); } if (expression && this.timezone && this.day && this.days) { this.day = this.days; } if (expression){ today.add(this); } else { today.set(this); } if (this.timezone) { this.timezone = this.timezone.toUpperCase(); var offset = $D.getTimezoneOffset(this.timezone); var timezone; if (today.hasDaylightSavingTime()) { // lets check that we're being sane with timezone setting timezone = $D.getTimezoneAbbreviation(offset, today.isDaylightSavingTime()); if (timezone !== this.timezone) { // bugger, we're in a place where things like EST vs EDT matters. if (today.isDaylightSavingTime()) { today.addHours(-1); } else { today.addHours(1); } } } today.setTimezoneOffset(offset); } return today; } }; }()); (function () { var $D = Date; $D.Grammar = {}; var _ = $D.Parsing.Operators, g = $D.Grammar, t = $D.Translator, _fn; // Allow rolling up into general purpose rules _fn = function () { return _.each(_.any.apply(null, arguments), _.not(g.ctoken2("timeContext"))); }; g.datePartDelimiter = _.rtoken(/^([\s\-\.\,\/\x27]+)/); g.timePartDelimiter = _.stoken(":"); g.whiteSpace = _.rtoken(/^\s*/); g.generalDelimiter = _.rtoken(/^(([\s\,]|at|@|on)+)/); var _C = {}; g.ctoken = function (keys) { var fn = _C[keys]; if (! fn) { var c = Date.CultureInfo.regexPatterns; var kx = keys.split(/\s+/), px = []; for (var i = 0; i < kx.length ; i++) { px.push(_.replace(_.rtoken(c[kx[i]]), kx[i])); } fn = _C[keys] = _.any.apply(null, px); } return fn; }; g.ctoken2 = function (key) { return _.rtoken(Date.CultureInfo.regexPatterns[key]); }; var cacheProcessRtoken = function (key, token, type, eachToken) { if (eachToken) { g[key] = _.cache(_.process(_.each(_.rtoken(token),_.optional(g.ctoken2(eachToken))), type)); } else { g[key] = _.cache(_.process(_.rtoken(token), type)); } }; var cacheProcessCtoken = function (token, type) { return _.cache(_.process(g.ctoken2(token), type)); }; var _F = {}; //function cache var _get = function (f) { _F[f] = (_F[f] || g.format(f)[0]); return _F[f]; }; g.allformats = function (fx) { var rx = []; if (fx instanceof Array) { for (var i = 0; i < fx.length; i++) { rx.push(_get(fx[i])); } } else { rx.push(_get(fx)); } return rx; }; g.formats = function (fx) { if (fx instanceof Array) { var rx = []; for (var i = 0 ; i < fx.length ; i++) { rx.push(_get(fx[i])); } return _.any.apply(null, rx); } else { return _get(fx); } }; var grammarFormats = { timeFormats: function(){ var i, RTokenKeys = [ "h", "hh", "H", "HH", "m", "mm", "s", "ss", "ss.s", "z", "zz" ], RToken = [ /^(0[0-9]|1[0-2]|[1-9])/, /^(0[0-9]|1[0-2])/, /^([0-1][0-9]|2[0-3]|[0-9])/, /^([0-1][0-9]|2[0-3])/, /^([0-5][0-9]|[0-9])/, /^[0-5][0-9]/, /^([0-5][0-9]|[0-9])/, /^[0-5][0-9]/, /^[0-5][0-9]\.[0-9]{1,3}/, /^((\+|\-)\s*\d\d\d\d)|((\+|\-)\d\d\:?\d\d)/, /^((\+|\-)\s*\d\d\d\d)|((\+|\-)\d\d\:?\d\d)/ ], tokens = [ t.hour, t.hour, t.hour, t.hour, t.minute, t.minute, t.second, t.second, t.secondAndMillisecond, t.timezone, t.timezone ]; for (i=0; i < RTokenKeys.length; i++) { cacheProcessRtoken(RTokenKeys[i], RToken[i], tokens[i]); } g.hms = _.cache(_.sequence([g.H, g.m, g.s], g.timePartDelimiter)); g.t = cacheProcessCtoken("shortMeridian", t.meridian); g.tt = cacheProcessCtoken("longMeridian", t.meridian); g.zzz = cacheProcessCtoken("timezone", t.timezone); g.timeSuffix = _.each(_.ignore(g.whiteSpace), _.set([ g.tt, g.zzz ])); g.time = _.each(_.optional(_.ignore(_.stoken("T"))), g.hms, g.timeSuffix); }, dateFormats: function () { // pre-loaded rules for different date part order preferences var _setfn = function () { return _.set(arguments, g.datePartDelimiter); }; var i, RTokenKeys = [ "d", "dd", "M", "MM", "y", "yy", "yyy", "yyyy" ], RToken = [ /^([0-2]\d|3[0-1]|\d)/, /^([0-2]\d|3[0-1])/, /^(1[0-2]|0\d|\d)/, /^(1[0-2]|0\d)/, /^(\d+)/, /^(\d\d)/, /^(\d\d?\d?\d?)/, /^(\d\d\d\d)/ ], tokens = [ t.day, t.day, t.month, t.month, t.year, t.year, t.year, t.year ], eachToken = [ "ordinalSuffix", "ordinalSuffix" ]; for (i=0; i < RTokenKeys.length; i++) { cacheProcessRtoken(RTokenKeys[i], RToken[i], tokens[i], eachToken[i]); } g.MMM = g.MMMM = _.cache(_.process(g.ctoken("jan feb mar apr may jun jul aug sep oct nov dec"), t.month)); g.ddd = g.dddd = _.cache(_.process(g.ctoken("sun mon tue wed thu fri sat"), function (s) { return function () { this.weekday = s; }; } )); g.day = _fn(g.d, g.dd); g.month = _fn(g.M, g.MMM); g.year = _fn(g.yyyy, g.yy); g.mdy = _setfn(g.ddd, g.month, g.day, g.year); g.ymd = _setfn(g.ddd, g.year, g.month, g.day); g.dmy = _setfn(g.ddd, g.day, g.month, g.year); g.date = function (s) { return ((g[Date.CultureInfo.dateElementOrder] || g.mdy).call(this, s)); }; }, relative: function () { // relative date / time expressions g.orientation = _.process(g.ctoken("past future"), function (s) { return function () { this.orient = s; }; } ); g.operator = _.process(g.ctoken("add subtract"), function (s) { return function () { this.operator = s; }; } ); g.rday = _.process(g.ctoken("yesterday tomorrow today now"), t.rday); g.unit = _.process(g.ctoken("second minute hour day week month year"), function (s) { return function () { this.unit = s; }; } ); } }; g.buildGrammarFormats = function () { // these need to be rebuilt every time the language changes. _C = {}; grammarFormats.timeFormats(); grammarFormats.dateFormats(); grammarFormats.relative(); g.value = _.process(_.rtoken(/^([-+]?\d+)?(st|nd|rd|th)?/), function (s) { return function () { this.value = s.replace(/\D/g, ""); }; } ); g.expression = _.set([g.rday, g.operator, g.value, g.unit, g.orientation, g.ddd, g.MMM ]); g.format = _.process(_.many( _.any( // translate format specifiers into grammar rules _.process( _.rtoken(/^(dd?d?d?(?!e)|MM?M?M?|yy?y?y?|hh?|HH?|mm?|ss?|tt?|zz?z?)/), function (fmt) { if (g[fmt]) { return g[fmt]; } else { throw $D.Parsing.Exception(fmt); } } ), // translate separator tokens into token rules _.process(_.rtoken(/^[^dMyhHmstz]+/), // all legal separators function (s) { return _.ignore(_.stoken(s)); } ) ) ), // construct the parser ... function (rules) { return _.process(_.each.apply(null, rules), t.finishExact); } ); // starting rule for general purpose grammar g._start = _.process(_.set([ g.date, g.time, g.expression ], g.generalDelimiter, g.whiteSpace), t.finish); }; g.buildGrammarFormats(); // parsing date format specifiers - ex: "h:m:s tt" // this little guy will generate a custom parser based // on the format string, ex: g.format("h:m:s tt") // check for these formats first g._formats = g.formats([ "\"yyyy-MM-ddTHH:mm:ssZ\"", "yyyy-MM-ddTHH:mm:ss.sz", "yyyy-MM-ddTHH:mm:ssZ", "yyyy-MM-ddTHH:mm:ssz", "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-ddTHH:mmZ", "yyyy-MM-ddTHH:mmz", "yyyy-MM-ddTHH:mm", "ddd, MMM dd, yyyy H:mm:ss tt", "ddd MMM d yyyy HH:mm:ss zzz", "MMddyyyy", "ddMMyyyy", "Mddyyyy", "ddMyyyy", "Mdyyyy", "dMyyyy", "yyyy", "Mdyy", "dMyy", "d" ]); // real starting rule: tries selected formats first, // then general purpose rule g.start = function (s) { try { var r = g._formats.call({}, s); if (r[1].length === 0) { return r; } } catch (e) {} return g._start.call({}, s); }; }()); (function () { var $D = Date; /** * @desc Converts the specified string value into its JavaScript Date equivalent using CultureInfo specific format information. * * Example

	///////////
	// Dates //
	///////////

	// 15-Oct-2004
	var d1 = Date.parse("10/15/2004");

	// 15-Oct-2004
	var d1 = Date.parse("15-Oct-2004");

	// 15-Oct-2004
	var d1 = Date.parse("2004.10.15");

	//Fri Oct 15, 2004
	var d1 = Date.parse("Fri Oct 15, 2004");

	///////////
	// Times //
	///////////

	// Today at 10 PM.
	var d1 = Date.parse("10 PM");

	// Today at 10:30 PM.
	var d1 = Date.parse("10:30 P.M.");

	// Today at 6 AM.
	var d1 = Date.parse("06am");

	/////////////////////
	// Dates and Times //
	/////////////////////

	// 8-July-2004 @ 10:30 PM
	var d1 = Date.parse("July 8th, 2004, 10:30 PM");

	// 1-July-2004 @ 10:30 PM
	var d1 = Date.parse("2004-07-01T22:30:00");

	////////////////////
	// Relative Dates //
	////////////////////

	// Returns today's date. The string "today" is culture specific.
	var d1 = Date.parse("today");

	// Returns yesterday's date. The string "yesterday" is culture specific.
	var d1 = Date.parse("yesterday");

	// Returns the date of the next thursday.
	var d1 = Date.parse("Next thursday");

	// Returns the date of the most previous monday.
	var d1 = Date.parse("last monday");

	// Returns today's day + one year.
	var d1 = Date.parse("next year");

	///////////////
	// Date Math //
	///////////////

	// Today + 2 days
	var d1 = Date.parse("t+2");

	// Today + 2 days
	var d1 = Date.parse("today + 2 days");

	// Today + 3 months
	var d1 = Date.parse("t+3m");

	// Today - 1 year
	var d1 = Date.parse("today - 1 year");

	// Today - 1 year
	var d1 = Date.parse("t-1y"); 


	/////////////////////////////
	// Partial Dates and Times //
	/////////////////////////////

	// July 15th of this year.
	var d1 = Date.parse("July 15");

	// 15th day of current day and year.
	var d1 = Date.parse("15");

	// July 1st of current year at 10pm.
	var d1 = Date.parse("7/1 10pm");
	
* * @param {String} The string value to convert into a Date object [Required] * @return {Date} A Date object or null if the string cannot be converted into a Date. */ var parseUtils = { removeOrds: function (s) { ords = s.match(/\b(\d+)(?:st|nd|rd|th)\b/); // find ordinal matches s = ((ords && ords.length === 2) ? s.replace(ords[0], ords[1]) : s); return s; }, grammarParser: function (s) { var r = null; try { r = $D.Grammar.start.call({}, s.replace(/^\s*(\S*(\s+\S+)*)\s*$/, "$1")); } catch (e) { return null; } return ((r[1].length === 0) ? r[0] : null); }, nativeFallback: function(s) { var t; try { // ok we haven't parsed it, last ditch attempt with the built-in parser. t = Date._parse(s); return (t || t === 0) ? new Date(t) : null; } catch (e) { return null; } } }; function parse (s) { var d; if (!s) { return null; } if (s instanceof Date) { return s.clone(); } if (s.length >= 4 && s.charAt(0) !== "0" && s.charAt(0) !== "+"&& s.charAt(0) !== "-") { // ie: 2004 will pass, 0800 won't. // Start with specific formats d = $D.Parsing.ISO.parse(s) || $D.Parsing.Numeric.parse(s); } if (d instanceof Date && !isNaN(d.getTime())) { return d; } else { // find ordinal dates (1st, 3rd, 8th, etc and remove them as they cause parsing issues) s = $D.Parsing.Normalizer.parse(parseUtils.removeOrds(s)); d = parseUtils.grammarParser(s); if (d !== null) { return d; } else { return parseUtils.nativeFallback(s); } } } if (!$D._parse) { $D._parse = $D.parse; } $D.parse = parse; Date.getParseFunction = function (fx) { var fns = Date.Grammar.allformats(fx); return function (s) { var r = null; for (var i = 0; i < fns.length; i++) { try { r = fns[i].call({}, s); } catch (e) { continue; } if (r[1].length === 0) { return r[0]; } } return null; }; }; /** * Converts the specified string value into its JavaScript Date equivalent using the specified format {String} or formats {Array} and the CultureInfo specific format information. * The format of the string value must match one of the supplied formats exactly. * * Example

	// 15-Oct-2004
	var d1 = Date.parseExact("10/15/2004", "M/d/yyyy");

	// 15-Oct-2004
	var d1 = Date.parse("15-Oct-2004", "M-ddd-yyyy");

	// 15-Oct-2004
	var d1 = Date.parse("2004.10.15", "yyyy.MM.dd");

	// Multiple formats
	var d1 = Date.parseExact("10/15/2004", ["M/d/yyyy", "MMMM d, yyyy"]);
	
* * @param {String} The string value to convert into a Date object [Required]. * @param {Object} The expected format {String} or an array of expected formats {Array} of the date string [Required]. * @return {Date} A Date object or null if the string cannot be converted into a Date. */ $D.parseExact = function (s, fx) { return $D.getParseFunction(fx)(s); }; }()); (function () { var $D = Date, $P = $D.prototype, // $C = $D.CultureInfo, // not used atm p = function (s, l) { if (!l) { l = 2; } return ("000" + s).slice(l * -1); }; /** * Converts a PHP format string to Java/.NET format string. * A PHP format string can be used with ._format or .format. * A Java/.NET format string can be used with .toString(). * The .parseExact function will only accept a Java/.NET format string * * Example * var f1 = "%m/%d/%y" * var f2 = Date.normalizeFormat(f1); // "MM/dd/yy" * * new Date().format(f1); // "04/13/08" * new Date()._format(f1); // "04/13/08" * new Date().toString(f2); // "04/13/08" * * var date = Date.parseExact("04/13/08", f2); // Sun Apr 13 2008 * * @param {String} A PHP format string consisting of one or more format spcifiers. * @return {String} The PHP format converted to a Java/.NET format string. */ var normalizerSubstitutions = { "d" : "dd", "%d": "dd", "D" : "ddd", "%a": "ddd", "j" : "dddd", "l" : "dddd", "%A": "dddd", "S" : "S", "F" : "MMMM", "%B": "MMMM", "m" : "MM", "%m": "MM", "M" : "MMM", "%b": "MMM", "%h": "MMM", "n" : "M", "Y" : "yyyy", "%Y": "yyyy", "y" : "yy", "%y": "yy", "g" : "h", "%I": "h", "G" : "H", "h" : "hh", "H" : "HH", "%H": "HH", "i" : "mm", "%M": "mm", "s" : "ss", "%S": "ss", "%r": "hh:mm tt", "%R": "H:mm", "%T": "H:mm:ss", "%X": "t", "%x": "d", "%e": "d", "%D": "MM/dd/yy", "%n": "\\n", "%t": "\\t", "e" : "z", "T" : "z", "%z": "z", "%Z": "z", "Z" : "ZZ", "N" : "u", "w" : "u", "%w": "u", "W" : "W", "%V": "W" }; var normalizer = { substitutes: function (m) { return normalizerSubstitutions[m]; }, interpreted: function (m, x) { var y; switch (m) { case "%u": return x.getDay() + 1; case "z": return x.getOrdinalNumber(); case "%j": return p(x.getOrdinalNumber(), 3); case "%U": var d1 = x.clone().set({month: 0, day: 1}).addDays(-1).moveToDayOfWeek(0), d2 = x.clone().addDays(1).moveToDayOfWeek(0, -1); return (d2 < d1) ? "00" : p((d2.getOrdinalNumber() - d1.getOrdinalNumber()) / 7 + 1); case "%W": return p(x.getWeek()); case "t": return $D.getDaysInMonth(x.getFullYear(), x.getMonth()); case "o": case "%G": return x.setWeek(x.getISOWeek()).toString("yyyy"); case "%g": return x._format("%G").slice(-2); case "a": case "%p": return t("tt").toLowerCase(); case "A": return t("tt").toUpperCase(); case "u": return p(x.getMilliseconds(), 3); case "I": return (x.isDaylightSavingTime()) ? 1 : 0; case "O": return x.getUTCOffset(); case "P": y = x.getUTCOffset(); return y.substring(0, y.length - 2) + ":" + y.substring(y.length - 2); case "B": var now = new Date(); return Math.floor(((now.getHours() * 3600) + (now.getMinutes() * 60) + now.getSeconds() + (now.getTimezoneOffset() + 60) * 60) / 86.4); case "c": return x.toISOString().replace(/\"/g, ""); case "U": return $D.strtotime("now"); case "%c": return t("d") + " " + t("t"); case "%C": return Math.floor(x.getFullYear() / 100 + 1); } }, shouldOverrideDefaults: function (m) { switch (m) { case "%e": return true; default: return false; } }, parse: function (m, context) { var formatString, c = context || new Date(); formatString = normalizer.substitutes(m); if (formatString) { return formatString; } formatString = normalizer.interpreted(m, c); if (formatString) { return formatString; } else { return m; } } }; $D.normalizeFormat = function (format, context) { return format.replace(/(%|\\)?.|%%/g, function(t){ return normalizer.parse(t, context); }); }; /** * Format a local Unix timestamp according to locale settings * * Example: * Date.strftime("%m/%d/%y", new Date()); // "04/13/08" * Date.strftime("c", "2008-04-13T17:52:03Z"); // "04/13/08" * * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @param {Number|String} The number representing the number of seconds that have elapsed since January 1, 1970 (local time). * @return {String} A string representation of the current Date object. */ $D.strftime = function (format, time) { var d = Date.parse(time); return d._format(format); }; /** * Parse any textual datetime description into a Unix timestamp. * A Unix timestamp is the number of seconds that have elapsed since January 1, 1970 (midnight UTC/GMT). * * Example: * Date.strtotime("04/13/08"); // 1208044800 * Date.strtotime("1970-01-01T00:00:00Z"); // 0 * * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @param {Object} A string or date object. * @return {String} A string representation of the current Date object. */ $D.strtotime = function (time) { var d = $D.parse(time); return Math.round($D.UTC(d.getUTCFullYear(), d.getUTCMonth(), d.getUTCDate(), d.getUTCHours(), d.getUTCMinutes(), d.getUTCSeconds(), d.getUTCMilliseconds()) / 1000); }; /** * Converts the value of the current Date object to its equivalent string representation using a PHP/Unix style of date format specifiers. * Format Specifiers * Format Description Example * ------ --------------------------------------------------------------------------- ----------------------- * %a abbreviated weekday name according to the current localed "Mon" through "Sun" * %A full weekday name according to the current localed "Sunday" through "Saturday" * %b abbreviated month name according to the current localed "Jan" through "Dec" * %B full month name according to the current locale "January" through "December" * %c preferred date and time representation for the current locale "4/13/2008 12:33 PM" * %C century number (the year divided by 100 and truncated to an integer) "00" to "99" * %d day of the month as a decimal number "01" to "31" * %D same as %m/%d/%y "04/13/08" * %e day of the month as a decimal number, a single digit is preceded by a space "1" to "31" * %g like %G, but without the century "08" * %G The 4-digit year corresponding to the ISO week number (see %V). "2008" * This has the same format and value as %Y, except that if the ISO week number * belongs to the previous or next year, that year is used instead. * %h same as %b "Jan" through "Dec" * %H hour as a decimal number using a 24-hour clock. "00" to "23" * %I hour as a decimal number using a 12-hour clock. "01" to "12" * %j day of the year as a decimal number. "001" to "366" * %m month as a decimal number. "01" to "12" * %M minute as a decimal number. "00" to "59" * %n newline character "\n" * %p either "am" or "pm" according to the given time value, or the "am" or "pm" * corresponding strings for the current locale. * %r time in a.m. and p.m. notation "8:44 PM" * %R time in 24 hour notation "20:44" * %S second as a decimal number "00" to "59" * %t tab character "\t" * %T current time, equal to %H:%M:%S "12:49:11" * %u weekday as a decimal number ["1", "7"], with "1" representing Monday "1" to "7" * %U week number of the current year as a decimal number, starting with the "0" to ("52" or "53") * first Sunday as the first day of the first week * %V The ISO 8601:1988 week number of the current year as a decimal number, "00" to ("52" or "53") * range 01 to 53, where week 1 is the first week that has at least 4 days * in the current year, and with Monday as the first day of the week. * (Use %G or %g for the year component that corresponds to the week number * for the specified timestamp.) * %W week number of the current year as a decimal number, starting with the "00" to ("52" or "53") * first Monday as the first day of the first week * %w day of the week as a decimal, Sunday being "0" "0" to "6" * %x preferred date representation for the current locale without the time "4/13/2008" * %X preferred time representation for the current locale without the date "12:53:05" * %y year as a decimal number without a century "00" "99" * %Y year as a decimal number including the century "2008" * %Z time zone or name or abbreviation "UTC", "EST", "PST" * %z same as %Z * %% a literal "%" characters "%" * d Day of the month, 2 digits with leading zeros "01" to "31" * D A textual representation of a day, three letters "Mon" through "Sun" * j Day of the month without leading zeros "1" to "31" * l A full textual representation of the day of the week (lowercase "L") "Sunday" through "Saturday" * N ISO-8601 numeric representation of the day of the week (added in PHP 5.1.0) "1" (for Monday) through "7" (for Sunday) * S English ordinal suffix for the day of the month, 2 characters "st", "nd", "rd" or "th". Works well with j * w Numeric representation of the day of the week "0" (for Sunday) through "6" (for Saturday) * z The day of the year (starting from "0") "0" through "365" * W ISO-8601 week number of year, weeks starting on Monday "00" to ("52" or "53") * F A full textual representation of a month, such as January or March "January" through "December" * m Numeric representation of a month, with leading zeros "01" through "12" * M A short textual representation of a month, three letters "Jan" through "Dec" * n Numeric representation of a month, without leading zeros "1" through "12" * t Number of days in the given month "28" through "31" * L Whether it's a leap year "1" if it is a leap year, "0" otherwise * o ISO-8601 year number. This has the same value as Y, except that if the "2008" * ISO week number (W) belongs to the previous or next year, that year * is used instead. * Y A full numeric representation of a year, 4 digits "2008" * y A two digit representation of a year "08" * a Lowercase Ante meridiem and Post meridiem "am" or "pm" * A Uppercase Ante meridiem and Post meridiem "AM" or "PM" * B Swatch Internet time "000" through "999" * g 12-hour format of an hour without leading zeros "1" through "12" * G 24-hour format of an hour without leading zeros "0" through "23" * h 12-hour format of an hour with leading zeros "01" through "12" * H 24-hour format of an hour with leading zeros "00" through "23" * i Minutes with leading zeros "00" to "59" * s Seconds, with leading zeros "00" through "59" * u Milliseconds "54321" * e Timezone identifier "UTC", "EST", "PST" * I Whether or not the date is in daylight saving time (uppercase i) "1" if Daylight Saving Time, "0" otherwise * O Difference to Greenwich time (GMT) in hours "+0200", "-0600" * P Difference to Greenwich time (GMT) with colon between hours and minutes "+02:00", "-06:00" * T Timezone abbreviation "UTC", "EST", "PST" * Z Timezone offset in seconds. The offset for timezones west of UTC is "-43200" through "50400" * always negative, and for those east of UTC is always positive. * c ISO 8601 date "2004-02-12T15:19:21+00:00" * r RFC 2822 formatted date "Thu, 21 Dec 2000 16:01:07 +0200" * U Seconds since the Unix Epoch (January 1 1970 00:00:00 GMT) "0" * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @return {String} A string representation of the current Date object. */ var formatReplace = function (context) { return function (m) { var formatString, override = false; if (m.charAt(0) === "\\" || m.substring(0, 2) === "%%") { return m.replace("\\", "").replace("%%", "%"); } override = normalizer.shouldOverrideDefaults(m); formatString = $D.normalizeFormat(m, context); if (formatString) { return context.toString(formatString, override); } }; }; $P._format = function (format) { var formatter = formatReplace(this); if (!format) { return this._toString(); } else { return format.replace(/(%|\\)?.|%%/g, formatter); } }; if (!$P.format) { $P.format = $P._format; } }()); (function () { "use strict"; var gFn = function (attr) { return function () { return this[attr]; }; }; var sFn = function (attr) { return function (val) { this[attr] = val; return this; }; }; var attrs = ["years", "months", "days", "hours", "minutes", "seconds", "milliseconds"]; var addSetFuncs = function (context, attrs) { for (var i = 0; i < attrs.length ; i++) { var $a = attrs[i], $b = $a.slice(0, 1).toUpperCase() + $a.slice(1); context.prototype[$a] = 0; context.prototype["get" + $b] = gFn($a); context.prototype["set" + $b] = sFn($a); } }; /** * new TimeSpan(milliseconds); * new TimeSpan(days, hours, minutes, seconds); * new TimeSpan(days, hours, minutes, seconds, milliseconds); */ var TimeSpan = function (days, hours, minutes, seconds, milliseconds) { if (arguments.length === 1 && typeof days === "number") { var orient = (days < 0) ? -1 : +1; var millsLeft = Math.abs(days); this.setDays(Math.floor(millsLeft / 86400000) * orient); millsLeft = millsLeft % 86400000; this.setHours(Math.floor(millsLeft / 3600000) * orient); millsLeft = millsLeft % 3600000; this.setMinutes(Math.floor(millsLeft / 60000) * orient); millsLeft = millsLeft % 60000; this.setSeconds(Math.floor(millsLeft / 1000) * orient); millsLeft = millsLeft % 1000; this.setMilliseconds(millsLeft * orient); } else { this.set(days, hours, minutes, seconds, milliseconds); } this.getTotalMilliseconds = function () { return (this.getDays() * 86400000) + (this.getHours() * 3600000) + (this.getMinutes() * 60000) + (this.getSeconds() * 1000); }; this.compareTo = function (time) { var t1 = new Date(1970, 1, 1, this.getHours(), this.getMinutes(), this.getSeconds()), t2; if (time === null) { t2 = new Date(1970, 1, 1, 0, 0, 0); } else { t2 = new Date(1970, 1, 1, time.getHours(), time.getMinutes(), time.getSeconds()); } return (t1 < t2) ? -1 : (t1 > t2) ? 1 : 0; }; this.equals = function (time) { return (this.compareTo(time) === 0); }; this.add = function (time) { return (time === null) ? this : this.addSeconds(time.getTotalMilliseconds() / 1000); }; this.subtract = function (time) { return (time === null) ? this : this.addSeconds(-time.getTotalMilliseconds() / 1000); }; this.addDays = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 86400000)); }; this.addHours = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 3600000)); }; this.addMinutes = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 60000)); }; this.addSeconds = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 1000)); }; this.addMilliseconds = function (n) { return new TimeSpan(this.getTotalMilliseconds() + n); }; this.get12HourHour = function () { return (this.getHours() > 12) ? this.getHours() - 12 : (this.getHours() === 0) ? 12 : this.getHours(); }; this.getDesignator = function () { return (this.getHours() < 12) ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator; }; this.toString = function (format) { this._toString = function () { if (this.getDays() !== null && this.getDays() > 0) { return this.getDays() + "." + this.getHours() + ":" + this.p(this.getMinutes()) + ":" + this.p(this.getSeconds()); } else { return this.getHours() + ":" + this.p(this.getMinutes()) + ":" + this.p(this.getSeconds()); } }; this.p = function (s) { return (s.toString().length < 2) ? "0" + s : s; }; var me = this; return format ? format.replace(/dd?|HH?|hh?|mm?|ss?|tt?/g, function (format) { switch (format) { case "d": return me.getDays(); case "dd": return me.p(me.getDays()); case "H": return me.getHours(); case "HH": return me.p(me.getHours()); case "h": return me.get12HourHour(); case "hh": return me.p(me.get12HourHour()); case "m": return me.getMinutes(); case "mm": return me.p(me.getMinutes()); case "s": return me.getSeconds(); case "ss": return me.p(me.getSeconds()); case "t": return ((me.getHours() < 12) ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator).substring(0, 1); case "tt": return (me.getHours() < 12) ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator; } } ) : this._toString(); }; return this; }; addSetFuncs(TimeSpan, attrs.slice(2)); TimeSpan.prototype.set = function (days, hours, minutes, seconds, milliseconds){ this.setDays(days || this.getDays()); this.setHours(hours || this.getHours()); this.setMinutes(minutes || this.getMinutes()); this.setSeconds(seconds || this.getSeconds()); this.setMilliseconds(milliseconds || this.getMilliseconds()); }; /** * Gets the time of day for this date instances. * @return {TimeSpan} TimeSpan */ Date.prototype.getTimeOfDay = function () { return new TimeSpan(0, this.getHours(), this.getMinutes(), this.getSeconds(), this.getMilliseconds()); }; Date.TimeSpan = TimeSpan; if (typeof window !== "undefined" ) { // keeping API compatible for v1.x window.TimeSpan = TimeSpan; } }()); (function () { "use strict"; var attrs = ["years", "months", "days", "hours", "minutes", "seconds", "milliseconds"]; var gFn = function (attr) { return function () { return this[attr]; }; }; var sFn = function (attr) { return function (val) { this[attr] = val; return this; }; }; var addSetFuncs = function (context, attrs) { for (var i = 0; i < attrs.length ; i++) { var $a = attrs[i], $b = $a.slice(0, 1).toUpperCase() + $a.slice(1); context.prototype[$a] = 0; context.prototype["get" + $b] = gFn($a); context.prototype["set" + $b] = sFn($a); } }; var setMonthsAndYears = function (orient, d1, d2, context) { function inc() { d1.addMonths(-orient); context.months++; if (context.months === 12) { context.years++; context.months = 0; } } if (orient === +1) { while (d1 > d2) { inc(); } } else { while (d1 < d2) { inc(); } } context.months--; context.months *= orient; context.years *= orient; }; var adjustForDST = function(orient, startDate, endDate) { var hasDSTMismatch = (false === (startDate.isDaylightSavingTime() === endDate.isDaylightSavingTime())); if (hasDSTMismatch && orient === 1) { startDate.addHours(-1); } else if (hasDSTMismatch) { startDate.addHours(1); } }; /** * TimePeriod(startDate, endDate); * TimePeriod(years, months, days, hours, minutes, seconds, milliseconds); */ var TimePeriod = function (years, months, days, hours, minutes, seconds, milliseconds) { if (arguments.length === 7) { this.set(years, months, days, hours, minutes, seconds, milliseconds); } else if (arguments.length === 2 && arguments[0] instanceof Date && arguments[1] instanceof Date) { var startDate = arguments[0].clone(); var endDate = arguments[1].clone(); var orient = (startDate > endDate) ? +1 : -1; this.dates = { start: arguments[0].clone(), end: arguments[1].clone() }; setMonthsAndYears(orient, startDate, endDate, this); adjustForDST(orient, startDate, endDate); // // TODO - adjust for DST var diff = endDate - startDate; if (diff !== 0) { var ts = new TimeSpan(diff); this.set(this.years, this.months, ts.getDays(), ts.getHours(), ts.getMinutes(), ts.getSeconds(), ts.getMilliseconds()); } } return this; }; // create all the set functions. addSetFuncs(TimePeriod, attrs); TimePeriod.prototype.set = function (years, months, days, hours, minutes, seconds, milliseconds){ this.setYears(years || this.getYears()); this.setMonths(months || this.getMonths()); this.setDays(days || this.getDays()); this.setHours(hours || this.getHours()); this.setMinutes(minutes || this.getMinutes()); this.setSeconds(seconds || this.getSeconds()); this.setMilliseconds(milliseconds || this.getMilliseconds()); }; Date.TimePeriod = TimePeriod; if (typeof window !== "undefined") { // keeping API compatible for v1.x window.TimePeriod = TimePeriod; } }()); ================================================ FILE: build/date-quz-EC.js ================================================ /** * @overview datejs * @version 1.0.0-rc3 * @author Gregory Wild-Smith * @copyright 2015 Gregory Wild-Smith * @license MIT * @homepage https://github.com/abritinthebay/datejs */ /* * DateJS Culture String File * Country Code: quz-EC * Name: Quechua (Ecuador) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["quz-EC"] = { "name": "quz-EC", "englishName": "Quechua (Ecuador)", "nativeName": "runasimi (Ecuador Suyu)", "Sunday": "intichaw", "Monday": "killachaw", "Tuesday": "atipachaw", "Wednesday": "quyllurchaw", "Thursday": "Ch' askachaw", "Friday": "Illapachaw", "Saturday": "k'uychichaw", "Sun": "int", "Mon": "kil", "Tue": "ati", "Wed": "quy", "Thu": "Ch’", "Fri": "Ill", "Sat": "k'u", "Su": "int", "Mo": "kil", "Tu": "ati", "We": "quy", "Th": "Ch’", "Fr": "Ill", "Sa": "k'u", "S_Sun_Initial": "i", "M_Mon_Initial": "k", "T_Tue_Initial": "a", "W_Wed_Initial": "q", "T_Thu_Initial": "C", "F_Fri_Initial": "I", "S_Sat_Initial": "k", "January": "Qulla puquy", "February": "Hatun puquy", "March": "Pauqar waray", "April": "ayriwa", "May": "Aymuray", "June": "Inti raymi", "July": "Anta Sitwa", "August": "Qhapaq Sitwa", "September": "Uma raymi", "October": "Kantaray", "November": "Ayamarq'a", "December": "Kapaq Raymi", "Jan_Abbr": "Qul", "Feb_Abbr": "Hat", "Mar_Abbr": "Pau", "Apr_Abbr": "ayr", "May_Abbr": "Aym", "Jun_Abbr": "Int", "Jul_Abbr": "Ant", "Aug_Abbr": "Qha", "Sep_Abbr": "Uma", "Oct_Abbr": "Kan", "Nov_Abbr": "Aya", "Dec_Abbr": "Kap", "AM": "", "PM": "", "firstDayOfWeek": 0, "twoDigitYearMax": 2029, "mdy": "dmy", "M/d/yyyy": "dd/MM/yyyy", "dddd, MMMM dd, yyyy": "dddd, dd' de 'MMMM' de 'yyyy", "h:mm tt": "H:mm:ss", "h:mm:ss tt": "H:mm:ss", "dddd, MMMM dd, yyyy h:mm:ss tt": "dddd, dd' de 'MMMM' de 'yyyy H:mm:ss", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "MMMM dd", "MMMM, yyyy": "MMMM' de 'yyyy", "/jan(uary)?/": "qul(la puquy)?", "/feb(ruary)?/": "hat(un puquy)?", "/mar(ch)?/": "pau(qar waray)?", "/apr(il)?/": "ayr(iwa)?", "/may/": "aym(uray)?", "/jun(e)?/": "int(i raymi)?", "/jul(y)?/": "ant(a sitwa)?", "/aug(ust)?/": "qha(paq sitwa)?", "/sep(t(ember)?)?/": "uma( raymi)?", "/oct(ober)?/": "kan(taray)?", "/nov(ember)?/": "aya(marq'a)?", "/dec(ember)?/": "kap(aq raymi)?", "/^su(n(day)?)?/": "^intichaw", "/^mo(n(day)?)?/": "^killachaw", "/^tu(e(s(day)?)?)?/": "^atipachaw", "/^we(d(nesday)?)?/": "^quyllurchaw", "/^th(u(r(s(day)?)?)?)?/": "^ch' askachaw", "/^fr(i(day)?)?/": "^illapachaw", "/^sa(t(urday)?)?/": "^k'uychichaw", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "quz-EC"; /** * @overview datejs * @version 1.0.0-rc3 * @author Gregory Wild-Smith * @copyright 2015 Gregory Wild-Smith * @license MIT * @homepage https://github.com/abritinthebay/datejs */(function () { var $D = Date; var lang = Date.CultureStrings ? Date.CultureStrings.lang : null; var loggedKeys = {}; // for debug purposes. var getText = { getFromKey: function (key, countryCode) { var output; if (Date.CultureStrings && Date.CultureStrings[countryCode] && Date.CultureStrings[countryCode][key]) { output = Date.CultureStrings[countryCode][key]; } else { output = getText.buildFromDefault(key); } if (key.charAt(0) === "/") { // Assume it's a regex output = getText.buildFromRegex(key, countryCode); } return output; }, getFromObjectValues: function (obj, countryCode) { var key, output = {}; for(key in obj) { if (obj.hasOwnProperty(key)) { output[key] = getText.getFromKey(obj[key], countryCode); } } return output; }, getFromObjectKeys: function (obj, countryCode) { var key, output = {}; for(key in obj) { if (obj.hasOwnProperty(key)) { output[getText.getFromKey(key, countryCode)] = obj[key]; } } return output; }, getFromArray: function (arr, countryCode) { var output = []; for (var i=0; i < arr.length; i++){ if (i in arr) { output[i] = getText.getFromKey(arr[i], countryCode); } } return output; }, buildFromDefault: function (key) { var output, length, split, last; switch(key) { case "name": output = "en-US"; break; case "englishName": output = "English (United States)"; break; case "nativeName": output = "English (United States)"; break; case "twoDigitYearMax": output = 2049; break; case "firstDayOfWeek": output = 0; break; default: output = key; split = key.split("_"); length = split.length; if (length > 1 && key.charAt(0) !== "/") { // if the key isn't a regex and it has a split. last = split[(length - 1)].toLowerCase(); if (last === "initial" || last === "abbr") { output = split[0]; } } break; } return output; }, buildFromRegex: function (key, countryCode) { var output; if (Date.CultureStrings && Date.CultureStrings[countryCode] && Date.CultureStrings[countryCode][key]) { output = new RegExp(Date.CultureStrings[countryCode][key], "i"); } else { output = new RegExp(key.replace(new RegExp("/", "g"),""), "i"); } return output; } }; var shallowMerge = function (obj1, obj2) { for (var attrname in obj2) { if (obj2.hasOwnProperty(attrname)) { obj1[attrname] = obj2[attrname]; } } }; var __ = function (key, language) { var countryCode = (language) ? language : lang; loggedKeys[key] = key; if (typeof key === "object") { if (key instanceof Array) { return getText.getFromArray(key, countryCode); } else { return getText.getFromObjectKeys(key, countryCode); } } else { return getText.getFromKey(key, countryCode); } }; var loadI18nScript = function (code) { // paatterned after jQuery's getScript. var url = Date.Config.i18n + code + ".js"; var head = document.getElementsByTagName("head")[0] || document.documentElement; var script = document.createElement("script"); script.src = url; var completed = false; var events = { done: function (){} // placeholder function }; // Attach handlers for all browsers script.onload = script.onreadystatechange = function() { if ( !completed && (!this.readyState || this.readyState === "loaded" || this.readyState === "complete") ) { events.done(); head.removeChild(script); } }; setTimeout(function() { head.insertBefore(script, head.firstChild); }, 0); // allows return to execute first return { done: function (cb) { events.done = function() { if (cb) { setTimeout(cb,0); } }; } }; }; var buildInfo = { buildFromMethodHash: function (obj) { var key; for(key in obj) { if (obj.hasOwnProperty(key)) { obj[key] = buildInfo[obj[key]](); } } return obj; }, timeZoneDST: function () { var DST = { "CHADT": "+1345", "NZDT": "+1300", "AEDT": "+1100", "ACDT": "+1030", "AZST": "+0500", "IRDT": "+0430", "EEST": "+0300", "CEST": "+0200", "BST": "+0100", "PMDT": "-0200", "ADT": "-0300", "NDT": "-0230", "EDT": "-0400", "CDT": "-0500", "MDT": "-0600", "PDT": "-0700", "AKDT": "-0800", "HADT": "-0900" }; return __(DST); }, timeZoneStandard: function () { var standard = { "LINT": "+1400", "TOT": "+1300", "CHAST": "+1245", "NZST": "+1200", "NFT": "+1130", "SBT": "+1100", "AEST": "+1000", "ACST": "+0930", "JST": "+0900", "CWST": "+0845", "CT": "+0800", "ICT": "+0700", "MMT": "+0630", "BST": "+0600", "NPT": "+0545", "IST": "+0530", "PKT": "+0500", "AFT": "+0430", "MSK": "+0400", "IRST": "+0330", "FET": "+0300", "EET": "+0200", "CET": "+0100", "GMT": "+0000", "UTC": "+0000", "CVT": "-0100", "GST": "-0200", "BRT": "-0300", "NST": "-0330", "AST": "-0400", "EST": "-0500", "CST": "-0600", "MST": "-0700", "PST": "-0800", "AKST": "-0900", "MIT": "-0930", "HST": "-1000", "SST": "-1100", "BIT": "-1200" }; return __(standard); }, timeZones: function (data) { var zone; data.timezones = []; for (zone in data.abbreviatedTimeZoneStandard) { if (data.abbreviatedTimeZoneStandard.hasOwnProperty(zone)) { data.timezones.push({ name: zone, offset: data.abbreviatedTimeZoneStandard[zone]}); } } for (zone in data.abbreviatedTimeZoneDST) { if (data.abbreviatedTimeZoneDST.hasOwnProperty(zone)) { data.timezones.push({ name: zone, offset: data.abbreviatedTimeZoneDST[zone], dst: true}); } } return data.timezones; }, days: function () { return __(["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"]); }, dayAbbr: function () { return __(["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"]); }, dayShortNames: function () { return __(["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"]); }, dayFirstLetters: function () { return __(["S_Sun_Initial", "M_Mon_Initial", "T_Tues_Initial", "W_Wed_Initial", "T_Thu_Initial", "F_Fri_Initial", "S_Sat_Initial"]); }, months: function () { return __(["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"]); }, monthAbbr: function () { return __(["Jan_Abbr", "Feb_Abbr", "Mar_Abbr", "Apr_Abbr", "May_Abbr", "Jun_Abbr", "Jul_Abbr", "Aug_Abbr", "Sep_Abbr", "Oct_Abbr", "Nov_Abbr", "Dec_Abbr"]); }, formatPatterns: function () { return getText.getFromObjectValues({ shortDate: "M/d/yyyy", longDate: "dddd, MMMM dd, yyyy", shortTime: "h:mm tt", longTime: "h:mm:ss tt", fullDateTime: "dddd, MMMM dd, yyyy h:mm:ss tt", sortableDateTime: "yyyy-MM-ddTHH:mm:ss", universalSortableDateTime: "yyyy-MM-dd HH:mm:ssZ", rfc1123: "ddd, dd MMM yyyy HH:mm:ss", monthDay: "MMMM dd", yearMonth: "MMMM, yyyy" }, Date.i18n.currentLanguage()); }, regex: function () { return getText.getFromObjectValues({ inTheMorning: "/( in the )(morn(ing)?)\\b/", thisMorning: "/(this )(morn(ing)?)\\b/", amThisMorning: "/(\b\\d(am)? )(this )(morn(ing)?)/", inTheEvening: "/( in the )(even(ing)?)\\b/", thisEvening: "/(this )(even(ing)?)\\b/", pmThisEvening: "/(\b\\d(pm)? )(this )(even(ing)?)/", jan: "/jan(uary)?/", feb: "/feb(ruary)?/", mar: "/mar(ch)?/", apr: "/apr(il)?/", may: "/may/", jun: "/jun(e)?/", jul: "/jul(y)?/", aug: "/aug(ust)?/", sep: "/sep(t(ember)?)?/", oct: "/oct(ober)?/", nov: "/nov(ember)?/", dec: "/dec(ember)?/", sun: "/^su(n(day)?)?/", mon: "/^mo(n(day)?)?/", tue: "/^tu(e(s(day)?)?)?/", wed: "/^we(d(nesday)?)?/", thu: "/^th(u(r(s(day)?)?)?)?/", fri: "/fr(i(day)?)?/", sat: "/^sa(t(urday)?)?/", future: "/^next/", past: "/^last|past|prev(ious)?/", add: "/^(\\+|aft(er)?|from|hence)/", subtract: "/^(\\-|bef(ore)?|ago)/", yesterday: "/^yes(terday)?/", today: "/^t(od(ay)?)?/", tomorrow: "/^tom(orrow)?/", now: "/^n(ow)?/", millisecond: "/^ms|milli(second)?s?/", second: "/^sec(ond)?s?/", minute: "/^mn|min(ute)?s?/", hour: "/^h(our)?s?/", week: "/^w(eek)?s?/", month: "/^m(onth)?s?/", day: "/^d(ay)?s?/", year: "/^y(ear)?s?/", shortMeridian: "/^(a|p)/", longMeridian: "/^(a\\.?m?\\.?|p\\.?m?\\.?)/", timezone: "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/", ordinalSuffix: "/^\\s*(st|nd|rd|th)/", timeContext: "/^\\s*(\\:|a(?!u|p)|p)/" }, Date.i18n.currentLanguage()); } }; var CultureInfo = function () { var info = getText.getFromObjectValues({ name: "name", englishName: "englishName", nativeName: "nativeName", amDesignator: "AM", pmDesignator: "PM", firstDayOfWeek: "firstDayOfWeek", twoDigitYearMax: "twoDigitYearMax", dateElementOrder: "mdy" }, Date.i18n.currentLanguage()); var constructedInfo = buildInfo.buildFromMethodHash({ dayNames: "days", abbreviatedDayNames: "dayAbbr", shortestDayNames: "dayShortNames", firstLetterDayNames: "dayFirstLetters", monthNames: "months", abbreviatedMonthNames: "monthAbbr", formatPatterns: "formatPatterns", regexPatterns: "regex", abbreviatedTimeZoneDST: "timeZoneDST", abbreviatedTimeZoneStandard: "timeZoneStandard" }); shallowMerge(info, constructedInfo); buildInfo.timeZones(info); return info; }; $D.i18n = { __: function (key, lang) { return __(key, lang); }, currentLanguage: function () { return lang || "en-US"; }, setLanguage: function (code, force, cb) { var async = false; if (force || code === "en-US" || (!!Date.CultureStrings && !!Date.CultureStrings[code])) { lang = code; Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings.lang = code; Date.CultureInfo = new CultureInfo(); } else { if (!(!!Date.CultureStrings && !!Date.CultureStrings[code])) { if (typeof exports !== "undefined" && this.exports !== exports) { // we're in a Node enviroment, load it using require try { require("../i18n/" + code + ".js"); lang = code; Date.CultureStrings.lang = code; Date.CultureInfo = new CultureInfo(); } catch (e) { // var str = "The language for '" + code + "' could not be loaded by Node. It likely does not exist."; throw new Error("The DateJS IETF language tag '" + code + "' could not be loaded by Node. It likely does not exist."); } } else if (Date.Config && Date.Config.i18n) { // we know the location of the files, so lets load them async = true; loadI18nScript(code).done(function(){ lang = code; Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings.lang = code; Date.CultureInfo = new CultureInfo(); $D.Parsing.Normalizer.buildReplaceData(); // because this is async if ($D.Grammar) { $D.Grammar.buildGrammarFormats(); // so we can parse those strings... } if (cb) { setTimeout(cb,0); } }); } else { Date.console.error("The DateJS IETF language tag '" + code + "' is not available and has not been loaded."); return false; } } } $D.Parsing.Normalizer.buildReplaceData(); // rebuild normalizer strings if ($D.Grammar) { $D.Grammar.buildGrammarFormats(); // so we can parse those strings... } if (!async && cb) { setTimeout(cb,0); } }, getLoggedKeys: function () { return loggedKeys; }, updateCultureInfo: function () { Date.CultureInfo = new CultureInfo(); } }; $D.i18n.updateCultureInfo(); // run automatically }()); (function () { var $D = Date, $P = $D.prototype, p = function (s, l) { if (!l) { l = 2; } return ("000" + s).slice(l * -1); }; if (typeof window !== "undefined" && typeof window.console !== "undefined" && typeof window.console.log !== "undefined") { $D.console = console; // used only to raise non-critical errors if available } else { // set mock so we don't give errors. $D.console = { log: function(){}, error: function(){} }; } $D.Config = $D.Config || {}; $D.initOverloads = function() { /** * Overload of Date.now. Allows an alternate call for Date.now where it returns the * current Date as an object rather than just milliseconds since the Unix Epoch. * * Also provides an implementation of now() for browsers (IE<9) that don't have it. * * Backwards compatible so with work with either: * Date.now() [returns ms] * or * Date.now(true) [returns Date] */ if (!$D.now) { $D._now = function now() { return new Date().getTime(); }; } else if (!$D._now) { $D._now = $D.now; } $D.now = function (returnObj) { if (returnObj) { return $D.present(); } else { return $D._now(); } }; if ( !$P.toISOString ) { $P.toISOString = function() { return this.getUTCFullYear() + "-" + p(this.getUTCMonth() + 1) + "-" + p(this.getUTCDate()) + "T" + p(this.getUTCHours()) + ":" + p(this.getUTCMinutes()) + ":" + p(this.getUTCSeconds()) + "." + String( (this.getUTCMilliseconds()/1000).toFixed(3)).slice(2, 5) + "Z"; }; } // private if ( $P._toString === undefined ){ $P._toString = $P.toString; } }; $D.initOverloads(); /** * Gets a date that is set to the current date. The time is set to the start of the day (00:00 or 12:00 AM). * @return {Date} The current date. */ $D.today = function () { return new Date().clearTime(); }; /** * Gets a date that is set to the current date and time (same as new Date, but chainable) * @return {Date} The current date. */ $D.present = function () { return new Date(); }; /** * Compares the first date to the second date and returns an number indication of their relative values. * @param {Date} First Date object to compare [Required]. * @param {Date} Second Date object to compare to [Required]. * @return {Number} -1 = date1 is lessthan date2. 0 = values are equal. 1 = date1 is greaterthan date2. */ $D.compare = function (date1, date2) { if (isNaN(date1) || isNaN(date2)) { throw new Error(date1 + " - " + date2); } else if (date1 instanceof Date && date2 instanceof Date) { return (date1 < date2) ? -1 : (date1 > date2) ? 1 : 0; } else { throw new TypeError(date1 + " - " + date2); } }; /** * Compares the first Date object to the second Date object and returns true if they are equal. * @param {Date} First Date object to compare [Required] * @param {Date} Second Date object to compare to [Required] * @return {Boolean} true if dates are equal. false if they are not equal. */ $D.equals = function (date1, date2) { return (date1.compareTo(date2) === 0); }; /** * Gets the language appropriate day name when given the day number(0-6) * eg - 0 == Sunday * @return {String} The day name */ $D.getDayName = function (n) { return Date.CultureInfo.dayNames[n]; }; /** * Gets the day number (0-6) if given a CultureInfo specific string which is a valid dayName, abbreviatedDayName or shortestDayName (two char). * @param {String} The name of the day (eg. "Monday, "Mon", "tuesday", "tue", "We", "we"). * @return {Number} The day number */ $D.getDayNumberFromName = function (name) { var n = Date.CultureInfo.dayNames, m = Date.CultureInfo.abbreviatedDayNames, o = Date.CultureInfo.shortestDayNames, s = name.toLowerCase(); for (var i = 0; i < n.length; i++) { if (n[i].toLowerCase() === s || m[i].toLowerCase() === s || o[i].toLowerCase() === s) { return i; } } return -1; }; /** * Gets the month number (0-11) if given a Culture Info specific string which is a valid monthName or abbreviatedMonthName. * @param {String} The name of the month (eg. "February, "Feb", "october", "oct"). * @return {Number} The day number */ $D.getMonthNumberFromName = function (name) { var n = Date.CultureInfo.monthNames, m = Date.CultureInfo.abbreviatedMonthNames, s = name.toLowerCase(); for (var i = 0; i < n.length; i++) { if (n[i].toLowerCase() === s || m[i].toLowerCase() === s) { return i; } } return -1; }; /** * Gets the language appropriate month name when given the month number(0-11) * eg - 0 == January * @return {String} The month name */ $D.getMonthName = function (n) { return Date.CultureInfo.monthNames[n]; }; /** * Determines if the current date instance is within a LeapYear. * @param {Number} The year. * @return {Boolean} true if date is within a LeapYear, otherwise false. */ $D.isLeapYear = function (year) { return ((year % 4 === 0 && year % 100 !== 0) || year % 400 === 0); }; /** * Gets the number of days in the month, given a year and month value. Automatically corrects for LeapYear. * @param {Number} The year. * @param {Number} The month (0-11). * @return {Number} The number of days in the month. */ $D.getDaysInMonth = function (year, month) { if (!month && $D.validateMonth(year)) { month = year; year = Date.today().getFullYear(); } return [31, ($D.isLeapYear(year) ? 29 : 28), 31, 30, 31, 30, 31, 31, 30, 31, 30, 31][month]; }; $P.getDaysInMonth = function () { return $D.getDaysInMonth(this.getFullYear(), this.getMonth()); }; $D.getTimezoneAbbreviation = function (offset, dst) { var p, n = (dst || false) ? Date.CultureInfo.abbreviatedTimeZoneDST : Date.CultureInfo.abbreviatedTimeZoneStandard; for (p in n) { if (n.hasOwnProperty(p)) { if (n[p] === offset) { return p; } } } return null; }; $D.getTimezoneOffset = function (name, dst) { var i, a =[], z = Date.CultureInfo.timezones; if (!name) { name = (new Date()).getTimezone();} for (i = 0; i < z.length; i++) { if (z[i].name === name.toUpperCase()) { a.push(i); } } if (!z[a[0]]) { return null; } if (a.length === 1 || !dst) { return z[a[0]].offset; } else { for (i=0; i < a.length; i++) { if (z[a[i]].dst) { return z[a[i]].offset; } } } }; $D.getQuarter = function (d) { d = d || new Date(); // If no date supplied, use today var q = [1,2,3,4]; return q[Math.floor(d.getMonth() / 3)]; // ~~~ is a bitwise op. Faster than Math.floor }; $D.getDaysLeftInQuarter = function (d) { d = d || new Date(); var qEnd = new Date(d); qEnd.setMonth(qEnd.getMonth() + 3 - qEnd.getMonth() % 3, 0); return Math.floor((qEnd - d) / 8.64e7); }; // private var validate = function (n, min, max, name) { name = name ? name : "Object"; if (typeof n === "undefined") { return false; } else if (typeof n !== "number") { throw new TypeError(n + " is not a Number."); } else if (n < min || n > max) { // As failing validation is *not* an exceptional circumstance // lets not throw a RangeError Exception here. // It's semantically correct but it's not sensible. return false; } return true; }; /** * Validates the number is within an acceptable range for milliseconds [0-999]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateMillisecond = function (value) { return validate(value, 0, 999, "millisecond"); }; /** * Validates the number is within an acceptable range for seconds [0-59]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateSecond = function (value) { return validate(value, 0, 59, "second"); }; /** * Validates the number is within an acceptable range for minutes [0-59]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateMinute = function (value) { return validate(value, 0, 59, "minute"); }; /** * Validates the number is within an acceptable range for hours [0-23]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateHour = function (value) { return validate(value, 0, 23, "hour"); }; /** * Validates the number is within an acceptable range for the days in a month [0-MaxDaysInMonth]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateDay = function (value, year, month) { if (year === undefined || year === null || month === undefined || month === null) { return false;} return validate(value, 1, $D.getDaysInMonth(year, month), "day"); }; /** * Validates the number is within an acceptable range for months [0-11]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateWeek = function (value) { return validate(value, 0, 53, "week"); }; /** * Validates the number is within an acceptable range for months [0-11]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateMonth = function (value) { return validate(value, 0, 11, "month"); }; /** * Validates the number is within an acceptable range for years. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateYear = function (value) { /** * Per ECMAScript spec the range of times supported by Date objects is * exactly -100,000,000 days to +100,000,000 days measured relative to * midnight at the beginning of 01 January, 1970 UTC. * This gives a range of 8,640,000,000,000,000 milliseconds to either * side of 01 January, 1970 UTC. * * Earliest possible date: Tue, 20 Apr 271,822 B.C. 00:00:00 UTC * Latest possible date: Sat, 13 Sep 275,760 00:00:00 UTC */ return validate(value, -271822, 275760, "year"); }; $D.validateTimezone = function(value) { var timezones = {"ACDT":1,"ACST":1,"ACT":1,"ADT":1,"AEDT":1,"AEST":1,"AFT":1,"AKDT":1,"AKST":1,"AMST":1,"AMT":1,"ART":1,"AST":1,"AWDT":1,"AWST":1,"AZOST":1,"AZT":1,"BDT":1,"BIOT":1,"BIT":1,"BOT":1,"BRT":1,"BST":1,"BTT":1,"CAT":1,"CCT":1,"CDT":1,"CEDT":1,"CEST":1,"CET":1,"CHADT":1,"CHAST":1,"CHOT":1,"ChST":1,"CHUT":1,"CIST":1,"CIT":1,"CKT":1,"CLST":1,"CLT":1,"COST":1,"COT":1,"CST":1,"CT":1,"CVT":1,"CWST":1,"CXT":1,"DAVT":1,"DDUT":1,"DFT":1,"EASST":1,"EAST":1,"EAT":1,"ECT":1,"EDT":1,"EEDT":1,"EEST":1,"EET":1,"EGST":1,"EGT":1,"EIT":1,"EST":1,"FET":1,"FJT":1,"FKST":1,"FKT":1,"FNT":1,"GALT":1,"GAMT":1,"GET":1,"GFT":1,"GILT":1,"GIT":1,"GMT":1,"GST":1,"GYT":1,"HADT":1,"HAEC":1,"HAST":1,"HKT":1,"HMT":1,"HOVT":1,"HST":1,"ICT":1,"IDT":1,"IOT":1,"IRDT":1,"IRKT":1,"IRST":1,"IST":1,"JST":1,"KGT":1,"KOST":1,"KRAT":1,"KST":1,"LHST":1,"LINT":1,"MAGT":1,"MART":1,"MAWT":1,"MDT":1,"MET":1,"MEST":1,"MHT":1,"MIST":1,"MIT":1,"MMT":1,"MSK":1,"MST":1,"MUT":1,"MVT":1,"MYT":1,"NCT":1,"NDT":1,"NFT":1,"NPT":1,"NST":1,"NT":1,"NUT":1,"NZDT":1,"NZST":1,"OMST":1,"ORAT":1,"PDT":1,"PET":1,"PETT":1,"PGT":1,"PHOT":1,"PHT":1,"PKT":1,"PMDT":1,"PMST":1,"PONT":1,"PST":1,"PYST":1,"PYT":1,"RET":1,"ROTT":1,"SAKT":1,"SAMT":1,"SAST":1,"SBT":1,"SCT":1,"SGT":1,"SLST":1,"SRT":1,"SST":1,"SYOT":1,"TAHT":1,"THA":1,"TFT":1,"TJT":1,"TKT":1,"TLT":1,"TMT":1,"TOT":1,"TVT":1,"UCT":1,"ULAT":1,"UTC":1,"UYST":1,"UYT":1,"UZT":1,"VET":1,"VLAT":1,"VOLT":1,"VOST":1,"VUT":1,"WAKT":1,"WAST":1,"WAT":1,"WEDT":1,"WEST":1,"WET":1,"WST":1,"YAKT":1,"YEKT":1,"Z":1}; return (timezones[value] === 1); }; $D.validateTimezoneOffset= function(value) { // timezones go from +14hrs to -12hrs, the +X hours are negative offsets. return (value > -841 && value < 721); }; }()); (function () { var $D = Date, $P = $D.prototype, p = function (s, l) { if (!l) { l = 2; } return ("000" + s).slice(l * -1); }; var validateConfigObject = function (obj) { var result = {}, self = this, prop, testFunc; testFunc = function (prop, func, value) { if (prop === "day") { var month = (obj.month !== undefined) ? obj.month : self.getMonth(); var year = (obj.year !== undefined) ? obj.year : self.getFullYear(); return $D[func](value, year, month); } else { return $D[func](value); } }; for (prop in obj) { if (Object.prototype.hasOwnProperty.call(obj, prop)) { var func = "validate" + prop.charAt(0).toUpperCase() + prop.slice(1); if ($D[func] && obj[prop] !== null && testFunc(prop, func, obj[prop])) { result[prop] = obj[prop]; } } } return result; }; /** * Resets the time of this Date object to 12:00 AM (00:00), which is the start of the day. * @param {Boolean} .clone() this date instance before clearing Time * @return {Date} this */ $P.clearTime = function () { this.setHours(0); this.setMinutes(0); this.setSeconds(0); this.setMilliseconds(0); return this; }; /** * Resets the time of this Date object to the current time ('now'). * @return {Date} this */ $P.setTimeToNow = function () { var n = new Date(); this.setHours(n.getHours()); this.setMinutes(n.getMinutes()); this.setSeconds(n.getSeconds()); this.setMilliseconds(n.getMilliseconds()); return this; }; /** * Returns a new Date object that is an exact date and time copy of the original instance. * @return {Date} A new Date instance */ $P.clone = function () { return new Date(this.getTime()); }; /** * Compares this instance to a Date object and returns an number indication of their relative values. * @param {Date} Date object to compare [Required] * @return {Number} -1 = this is lessthan date. 0 = values are equal. 1 = this is greaterthan date. */ $P.compareTo = function (date) { return Date.compare(this, date); }; /** * Compares this instance to another Date object and returns true if they are equal. * @param {Date} Date object to compare. If no date to compare, new Date() [now] is used. * @return {Boolean} true if dates are equal. false if they are not equal. */ $P.equals = function (date) { return Date.equals(this, (date !== undefined ? date : new Date())); }; /** * Determines if this instance is between a range of two dates or equal to either the start or end dates. * @param {Date} Start of range [Required] * @param {Date} End of range [Required] * @return {Boolean} true is this is between or equal to the start and end dates, else false */ $P.between = function (start, end) { return this.getTime() >= start.getTime() && this.getTime() <= end.getTime(); }; /** * Determines if this date occurs after the date to compare to. * @param {Date} Date object to compare. If no date to compare, new Date() ("now") is used. * @return {Boolean} true if this date instance is greater than the date to compare to (or "now"), otherwise false. */ $P.isAfter = function (date) { return this.compareTo(date || new Date()) === 1; }; /** * Determines if this date occurs before the date to compare to. * @param {Date} Date object to compare. If no date to compare, new Date() ("now") is used. * @return {Boolean} true if this date instance is less than the date to compare to (or "now"). */ $P.isBefore = function (date) { return (this.compareTo(date || new Date()) === -1); }; /** * Determines if the current Date instance occurs today. * @return {Boolean} true if this date instance is 'today', otherwise false. */ /** * Determines if the current Date instance occurs on the same Date as the supplied 'date'. * If no 'date' to compare to is provided, the current Date instance is compared to 'today'. * @param {date} Date object to compare. If no date to compare, the current Date ("now") is used. * @return {Boolean} true if this Date instance occurs on the same Day as the supplied 'date'. */ $P.isToday = $P.isSameDay = function (date) { return this.clone().clearTime().equals((date || new Date()).clone().clearTime()); }; /** * Adds the specified number of milliseconds to this instance. * @param {Number} The number of milliseconds to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addMilliseconds = function (value) { if (!value) { return this; } this.setTime(this.getTime() + value * 1); return this; }; /** * Adds the specified number of seconds to this instance. * @param {Number} The number of seconds to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addSeconds = function (value) { if (!value) { return this; } return this.addMilliseconds(value * 1000); }; /** * Adds the specified number of seconds to this instance. * @param {Number} The number of seconds to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addMinutes = function (value) { if (!value) { return this; } return this.addMilliseconds(value * 60000); // 60*1000 }; /** * Adds the specified number of hours to this instance. * @param {Number} The number of hours to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addHours = function (value) { if (!value) { return this; } return this.addMilliseconds(value * 3600000); // 60*60*1000 }; /** * Adds the specified number of days to this instance. * @param {Number} The number of days to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addDays = function (value) { if (!value) { return this; } this.setDate(this.getDate() + value * 1); return this; }; /** * Adds the specified number of weekdays (ie - not sat or sun) to this instance. * @param {Number} The number of days to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addWeekdays = function (value) { if (!value) { return this; } var day = this.getDay(); var weeks = (Math.ceil(Math.abs(value)/7)); if (day === 0 || day === 6) { if (value > 0) { this.next().monday(); this.addDays(-1); day = this.getDay(); } } if (value < 0) { while (value < 0) { this.addDays(-1); day = this.getDay(); if (day !== 0 && day !== 6) { value++; } } return this; } else if (value > 5 || (6-day) <= value) { value = value + (weeks * 2); } return this.addDays(value); }; /** * Adds the specified number of weeks to this instance. * @param {Number} The number of weeks to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addWeeks = function (value) { if (!value) { return this; } return this.addDays(value * 7); }; /** * Adds the specified number of months to this instance. * @param {Number} The number of months to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addMonths = function (value) { if (!value) { return this; } var n = this.getDate(); this.setDate(1); this.setMonth(this.getMonth() + value * 1); this.setDate(Math.min(n, $D.getDaysInMonth(this.getFullYear(), this.getMonth()))); return this; }; $P.addQuarters = function (value) { if (!value) { return this; } // note this will take you to the same point in the quarter as you are now. // i.e. - if you are 15 days into the quarter you'll be 15 days into the resulting one. // bonus: this allows adding fractional quarters return this.addMonths(value * 3); }; /** * Adds the specified number of years to this instance. * @param {Number} The number of years to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addYears = function (value) { if (!value) { return this; } return this.addMonths(value * 12); }; /** * Adds (or subtracts) to the value of the years, months, weeks, days, hours, minutes, seconds, milliseconds of the date instance using given configuration object. Positive and Negative values allowed. * Example

	Date.today().add( { days: 1, months: 1 } )

	new Date().add( { years: -1 } )
	
* @param {Object} Configuration object containing attributes (months, days, etc.) * @return {Date} this */ $P.add = function (config) { if (typeof config === "number") { this._orient = config; return this; } var x = config; if (x.day) { // If we should be a different date than today (eg: for 'tomorrow -1d', etc). // Should only effect parsing, not direct usage (eg, Finish and FinishExact) if ((x.day - this.getDate()) !== 0) { this.setDate(x.day); } } if (x.milliseconds) { this.addMilliseconds(x.milliseconds); } if (x.seconds) { this.addSeconds(x.seconds); } if (x.minutes) { this.addMinutes(x.minutes); } if (x.hours) { this.addHours(x.hours); } if (x.weeks) { this.addWeeks(x.weeks); } if (x.months) { this.addMonths(x.months); } if (x.years) { this.addYears(x.years); } if (x.days) { this.addDays(x.days); } return this; }; /** * Get the week number. Week one (1) is the week which contains the first Thursday of the year. Monday is considered the first day of the week. * The .getWeek() function does NOT convert the date to UTC. The local datetime is used. * Please use .getISOWeek() to get the week of the UTC converted date. * @return {Number} 1 to 53 */ $P.getWeek = function (utc) { // Create a copy of this date object var self, target = new Date(this.valueOf()); if (utc) { target.addMinutes(target.getTimezoneOffset()); self = target.clone(); } else { self = this; } // ISO week date weeks start on monday // so correct the day number var dayNr = (self.getDay() + 6) % 7; // ISO 8601 states that week 1 is the week // with the first thursday of that year. // Set the target date to the thursday in the target week target.setDate(target.getDate() - dayNr + 3); // Store the millisecond value of the target date var firstThursday = target.valueOf(); // Set the target to the first thursday of the year // First set the target to january first target.setMonth(0, 1); // Not a thursday? Correct the date to the next thursday if (target.getDay() !== 4) { target.setMonth(0, 1 + ((4 - target.getDay()) + 7) % 7); } // The weeknumber is the number of weeks between the // first thursday of the year and the thursday in the target week return 1 + Math.ceil((firstThursday - target) / 604800000); // 604800000 = 7 * 24 * 3600 * 1000 }; /** * Get the ISO 8601 week number. Week one ("01") is the week which contains the first Thursday of the year. Monday is considered the first day of the week. * The .getISOWeek() function does convert the date to it's UTC value. Please use .getWeek() to get the week of the local date. * @return {String} "01" to "53" */ $P.getISOWeek = function () { return p(this.getWeek(true)); }; /** * Moves the date to Monday of the week set. Week one (1) is the week which contains the first Thursday of the year. * @param {Number} A Number (1 to 53) that represents the week of the year. * @return {Date} this */ $P.setWeek = function (n) { if ((n - this.getWeek()) === 0) { if (this.getDay() !== 1) { return this.moveToDayOfWeek(1, (this.getDay() > 1 ? -1 : 1)); } else { return this; } } else { return this.moveToDayOfWeek(1, (this.getDay() > 1 ? -1 : 1)).addWeeks(n - this.getWeek()); } }; $P.setQuarter = function (qtr) { var month = Math.abs(((qtr-1) * 3) + 1); return this.setMonth(month, 1); }; $P.getQuarter = function () { return Date.getQuarter(this); }; $P.getDaysLeftInQuarter = function () { return Date.getDaysLeftInQuarter(this); }; /** * Moves the date to the next n'th occurrence of the dayOfWeek starting from the beginning of the month. The number (-1) is a magic number and will return the last occurrence of the dayOfWeek in the month. * @param {Number} The dayOfWeek to move to * @param {Number} The n'th occurrence to move to. Use (-1) to return the last occurrence in the month * @return {Date} this */ $P.moveToNthOccurrence = function (dayOfWeek, occurrence) { if (dayOfWeek === "Weekday") { if (occurrence > 0) { this.moveToFirstDayOfMonth(); if (this.is().weekday()) { occurrence -= 1; } } else if (occurrence < 0) { this.moveToLastDayOfMonth(); if (this.is().weekday()) { occurrence += 1; } } else { return this; } return this.addWeekdays(occurrence); } var shift = 0; if (occurrence > 0) { shift = occurrence - 1; } else if (occurrence === -1) { this.moveToLastDayOfMonth(); if (this.getDay() !== dayOfWeek) { this.moveToDayOfWeek(dayOfWeek, -1); } return this; } return this.moveToFirstDayOfMonth().addDays(-1).moveToDayOfWeek(dayOfWeek, +1).addWeeks(shift); }; var moveToN = function (getFunc, addFunc, nVal) { return function (value, orient) { var diff = (value - this[getFunc]() + nVal * (orient || +1)) % nVal; return this[addFunc]((diff === 0) ? diff += nVal * (orient || +1) : diff); }; }; /** * Move to the next or last dayOfWeek based on the orient value. * @param {Number} The dayOfWeek to move to * @param {Number} Forward (+1) or Back (-1). Defaults to +1. [Optional] * @return {Date} this */ $P.moveToDayOfWeek = moveToN("getDay", "addDays", 7); /** * Move to the next or last month based on the orient value. * @param {Number} The month to move to. 0 = January, 11 = December * @param {Number} Forward (+1) or Back (-1). Defaults to +1. [Optional] * @return {Date} this */ $P.moveToMonth = moveToN("getMonth", "addMonths", 12); /** * Get the Ordinate of the current day ("th", "st", "rd"). * @return {String} */ $P.getOrdinate = function () { var num = this.getDate(); return ord(num); }; /** * Get the Ordinal day (numeric day number) of the year, adjusted for leap year. * @return {Number} 1 through 365 (366 in leap years) */ $P.getOrdinalNumber = function () { return Math.ceil((this.clone().clearTime() - new Date(this.getFullYear(), 0, 1)) / 86400000) + 1; }; /** * Get the time zone abbreviation of the current date. * @return {String} The abbreviated time zone name (e.g. "EST") */ $P.getTimezone = function () { return $D.getTimezoneAbbreviation(this.getUTCOffset(), this.isDaylightSavingTime()); }; $P.setTimezoneOffset = function (offset) { var here = this.getTimezoneOffset(), there = Number(offset) * -6 / 10; return (there || there === 0) ? this.addMinutes(there - here) : this; }; $P.setTimezone = function (offset) { return this.setTimezoneOffset($D.getTimezoneOffset(offset)); }; /** * Indicates whether Daylight Saving Time is observed in the current time zone. * @return {Boolean} true|false */ $P.hasDaylightSavingTime = function () { return (Date.today().set({month: 0, day: 1}).getTimezoneOffset() !== Date.today().set({month: 6, day: 1}).getTimezoneOffset()); }; /** * Indicates whether this Date instance is within the Daylight Saving Time range for the current time zone. * @return {Boolean} true|false */ $P.isDaylightSavingTime = function () { return Date.today().set({month: 0, day: 1}).getTimezoneOffset() !== this.getTimezoneOffset(); }; /** * Get the offset from UTC of the current date. * @return {String} The 4-character offset string prefixed with + or - (e.g. "-0500") */ $P.getUTCOffset = function (offset) { var n = (offset || this.getTimezoneOffset()) * -10 / 6, r; if (n < 0) { r = (n - 10000).toString(); return r.charAt(0) + r.substr(2); } else { r = (n + 10000).toString(); return "+" + r.substr(1); } }; /** * Returns the number of milliseconds between this date and date. * @param {Date} Defaults to now * @return {Number} The diff in milliseconds */ $P.getElapsed = function (date) { return (date || new Date()) - this; }; /** * Set the value of year, month, day, hour, minute, second, millisecond of date instance using given configuration object. * Example

	Date.today().set( { day: 20, month: 1 } )

	new Date().set( { millisecond: 0 } )
	
* * @param {Object} Configuration object containing attributes (month, day, etc.) * @return {Date} this */ $P.set = function (config) { config = validateConfigObject.call(this, config); var key; for (key in config) { if (Object.prototype.hasOwnProperty.call(config, key)) { var name = key.charAt(0).toUpperCase() + key.slice(1); var addFunc, getFunc; if (key !== "week" && key !== "month" && key !== "timezone" && key !== "timezoneOffset") { name += "s"; } addFunc = "add" + name; getFunc = "get" + name; if (key === "month") { addFunc = addFunc + "s"; } else if (key === "year"){ getFunc = "getFullYear"; } if (key !== "day" && key !== "timezone" && key !== "timezoneOffset" && key !== "week" && key !== "hour") { this[addFunc](config[key] - this[getFunc]()); } else if ( key === "timezone"|| key === "timezoneOffset" || key === "week" || key === "hour") { this["set"+name](config[key]); } } } // day has to go last because you can't validate the day without first knowing the month if (config.day) { this.addDays(config.day - this.getDate()); } return this; }; /** * Moves the date to the first day of the month. * @return {Date} this */ $P.moveToFirstDayOfMonth = function () { return this.set({ day: 1 }); }; /** * Moves the date to the last day of the month. * @return {Date} this */ $P.moveToLastDayOfMonth = function () { return this.set({ day: $D.getDaysInMonth(this.getFullYear(), this.getMonth())}); }; /** * Converts the value of the current Date object to its equivalent string representation. * Format Specifiers * CUSTOM DATE AND TIME FORMAT STRINGS * Format Description Example * ------ --------------------------------------------------------------------------- ----------------------- * s The seconds of the minute between 0-59. "0" to "59" * ss The seconds of the minute with leading zero if required. "00" to "59" * * m The minute of the hour between 0-59. "0" or "59" * mm The minute of the hour with leading zero if required. "00" or "59" * * h The hour of the day between 1-12. "1" to "12" * hh The hour of the day with leading zero if required. "01" to "12" * * H The hour of the day between 0-23. "0" to "23" * HH The hour of the day with leading zero if required. "00" to "23" * * d The day of the month between 1 and 31. "1" to "31" * dd The day of the month with leading zero if required. "01" to "31" * ddd Abbreviated day name. Date.CultureInfo.abbreviatedDayNames. "Mon" to "Sun" * dddd The full day name. Date.CultureInfo.dayNames. "Monday" to "Sunday" * * M The month of the year between 1-12. "1" to "12" * MM The month of the year with leading zero if required. "01" to "12" * MMM Abbreviated month name. Date.CultureInfo.abbreviatedMonthNames. "Jan" to "Dec" * MMMM The full month name. Date.CultureInfo.monthNames. "January" to "December" * * yy The year as a two-digit number. "99" or "08" * yyyy The full four digit year. "1999" or "2008" * * t Displays the first character of the A.M./P.M. designator. "A" or "P" * Date.CultureInfo.amDesignator or Date.CultureInfo.pmDesignator * tt Displays the A.M./P.M. designator. "AM" or "PM" * Date.CultureInfo.amDesignator or Date.CultureInfo.pmDesignator * * S The ordinal suffix ("st, "nd", "rd" or "th") of the current day. "st, "nd", "rd" or "th" * * STANDARD DATE AND TIME FORMAT STRINGS * Format Description Example *------ --------------------------------------------------------------------------- ----------------------- * d The CultureInfo shortDate Format Pattern "M/d/yyyy" * D The CultureInfo longDate Format Pattern "dddd, MMMM dd, yyyy" * F The CultureInfo fullDateTime Format Pattern "dddd, MMMM dd, yyyy h:mm:ss tt" * m The CultureInfo monthDay Format Pattern "MMMM dd" * r The CultureInfo rfc1123 Format Pattern "ddd, dd MMM yyyy HH:mm:ss GMT" * s The CultureInfo sortableDateTime Format Pattern "yyyy-MM-ddTHH:mm:ss" * t The CultureInfo shortTime Format Pattern "h:mm tt" * T The CultureInfo longTime Format Pattern "h:mm:ss tt" * u The CultureInfo universalSortableDateTime Format Pattern "yyyy-MM-dd HH:mm:ssZ" * y The CultureInfo yearMonth Format Pattern "MMMM, yyyy" * * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @return {String} A string representation of the current Date object. */ var ord = function (n) { switch (n * 1) { case 1: case 21: case 31: return "st"; case 2: case 22: return "nd"; case 3: case 23: return "rd"; default: return "th"; } }; var parseStandardFormats = function (format) { var y, c = Date.CultureInfo.formatPatterns; switch (format) { case "d": return this.toString(c.shortDate); case "D": return this.toString(c.longDate); case "F": return this.toString(c.fullDateTime); case "m": return this.toString(c.monthDay); case "r": case "R": y = this.clone().addMinutes(this.getTimezoneOffset()); return y.toString(c.rfc1123) + " GMT"; case "s": return this.toString(c.sortableDateTime); case "t": return this.toString(c.shortTime); case "T": return this.toString(c.longTime); case "u": y = this.clone().addMinutes(this.getTimezoneOffset()); return y.toString(c.universalSortableDateTime); case "y": return this.toString(c.yearMonth); default: return false; } }; var parseFormatStringsClosure = function (context) { return function (m) { if (m.charAt(0) === "\\") { return m.replace("\\", ""); } switch (m) { case "hh": return p(context.getHours() < 13 ? (context.getHours() === 0 ? 12 : context.getHours()) : (context.getHours() - 12)); case "h": return context.getHours() < 13 ? (context.getHours() === 0 ? 12 : context.getHours()) : (context.getHours() - 12); case "HH": return p(context.getHours()); case "H": return context.getHours(); case "mm": return p(context.getMinutes()); case "m": return context.getMinutes(); case "ss": return p(context.getSeconds()); case "s": return context.getSeconds(); case "yyyy": return p(context.getFullYear(), 4); case "yy": return p(context.getFullYear()); case "y": return context.getFullYear(); case "E": case "dddd": return Date.CultureInfo.dayNames[context.getDay()]; case "ddd": return Date.CultureInfo.abbreviatedDayNames[context.getDay()]; case "dd": return p(context.getDate()); case "d": return context.getDate(); case "MMMM": return Date.CultureInfo.monthNames[context.getMonth()]; case "MMM": return Date.CultureInfo.abbreviatedMonthNames[context.getMonth()]; case "MM": return p((context.getMonth() + 1)); case "M": return context.getMonth() + 1; case "t": return context.getHours() < 12 ? Date.CultureInfo.amDesignator.substring(0, 1) : Date.CultureInfo.pmDesignator.substring(0, 1); case "tt": return context.getHours() < 12 ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator; case "S": return ord(context.getDate()); case "W": return context.getWeek(); case "WW": return context.getISOWeek(); case "Q": return "Q" + context.getQuarter(); case "q": return String(context.getQuarter()); case "z": return context.getTimezone(); case "Z": case "X": return Date.getTimezoneOffset(context.getTimezone()); case "ZZ": // Timezone offset in seconds return context.getTimezoneOffset() * -60; case "u": return context.getDay(); case "L": return ($D.isLeapYear(context.getFullYear())) ? 1 : 0; case "B": // Swatch Internet Time (.beats) return "@"+((context.getUTCSeconds() + (context.getUTCMinutes()*60) + ((context.getUTCHours()+1)*3600))/86.4); default: return m; } }; }; $P.toString = function (format, ignoreStandards) { // Standard Date and Time Format Strings. Formats pulled from CultureInfo file and // may vary by culture. if (!ignoreStandards && format && format.length === 1) { output = parseStandardFormats.call(this, format); if (output) { return output; } } var parseFormatStrings = parseFormatStringsClosure(this); return format ? format.replace(/((\\)?(dd?d?d?|MM?M?M?|yy?y?y?|hh?|HH?|mm?|ss?|tt?|S|q|Q|WW?W?W?)(?![^\[]*\]))/g, parseFormatStrings).replace(/\[|\]/g, "") : this._toString(); }; }()); /************************************************************* * SugarPak - Domain Specific Language - Syntactical Sugar * *************************************************************/ (function () { var $D = Date, $P = $D.prototype, $N = Number.prototype; // private $P._orient = +1; // private $P._nth = null; // private $P._is = false; // private $P._same = false; // private $P._isSecond = false; // private $N._dateElement = "days"; /** * Moves the date to the next instance of a date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.today().next().friday();
	Date.today().next().fri();
	Date.today().next().march();
	Date.today().next().mar();
	Date.today().next().week();
	
* * @return {Date} date */ $P.next = function () { this._move = true; this._orient = +1; return this; }; /** * Creates a new Date (Date.today()) and moves the date to the next instance of the date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.next().friday();
	Date.next().fri();
	Date.next().march();
	Date.next().mar();
	Date.next().week();
	
* * @return {Date} date */ $D.next = function () { return $D.today().next(); }; /** * Moves the date to the previous instance of a date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.today().last().friday();
	Date.today().last().fri();
	Date.today().last().march();
	Date.today().last().mar();
	Date.today().last().week();
	
* * @return {Date} date */ $P.last = $P.prev = $P.previous = function () { this._move = true; this._orient = -1; return this; }; /** * Creates a new Date (Date.today()) and moves the date to the previous instance of the date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.last().friday();
	Date.last().fri();
	Date.previous().march();
	Date.prev().mar();
	Date.last().week();
	
* * @return {Date} date */ $D.last = $D.prev = $D.previous = function () { return $D.today().last(); }; /** * Performs a equality check when followed by either a month name, day name or .weekday() function. * Example

	Date.today().is().friday(); // true|false
	Date.today().is().fri();
	Date.today().is().march();
	Date.today().is().mar();
	
* * @return {Boolean} true|false */ $P.is = function () { this._is = true; return this; }; /** * Determines if two date objects occur on/in exactly the same instance of the subsequent date part function. * The function .same() must be followed by a date part function (example: .day(), .month(), .year(), etc). * * An optional Date can be passed in the date part function. If now date is passed as a parameter, 'Now' is used. * * The following example demonstrates how to determine if two dates fall on the exact same day. * * Example

	var d1 = Date.today(); // today at 00:00
	var d2 = new Date();   // exactly now.

	// Do they occur on the same day?
	d1.same().day(d2); // true
	
	// Do they occur on the same hour?
	d1.same().hour(d2); // false, unless d2 hour is '00' (midnight).
	
	// What if it's the same day, but one year apart?
	var nextYear = Date.today().add(1).year();

	d1.same().day(nextYear); // false, because the dates must occur on the exact same day. 
	
* * Scenario: Determine if a given date occurs during some week period 2 months from now. * * Example

	var future = Date.today().add(2).months();
	return someDate.same().week(future); // true|false;
	
* * @return {Boolean} true|false */ $P.same = function () { this._same = true; this._isSecond = false; return this; }; /** * Determines if the current date/time occurs during Today. Must be preceded by the .is() function. * Example

	someDate.is().today();    // true|false
	new Date().is().today();  // true
	Date.today().is().today();// true
	Date.today().add(-1).day().is().today(); // false
	
* * @return {Boolean} true|false */ $P.today = function () { return this.same().day(); }; /** * Determines if the current date is a weekday. This function must be preceded by the .is() function. * Example

	Date.today().is().weekday(); // true|false
	
* * @return {Boolean} true|false */ $P.weekday = function () { if (this._nth) { return df("Weekday").call(this); } if (this._move) { return this.addWeekdays(this._orient); } if (this._is) { this._is = false; return (!this.is().sat() && !this.is().sun()); } return false; }; /** * Determines if the current date is on the weekend. This function must be preceded by the .is() function. * Example

	Date.today().is().weekend(); // true|false
	
* * @return {Boolean} true|false */ $P.weekend = function () { if (this._is) { this._is = false; return (this.is().sat() || this.is().sun()); } return false; }; /** * Sets the Time of the current Date instance. A string "6:15 pm" or config object {hour:18, minute:15} are accepted. * Example

	// Set time to 6:15pm with a String
	Date.today().at("6:15pm");

	// Set time to 6:15pm with a config object
	Date.today().at({hour:18, minute:15});
	
* * @return {Date} date */ $P.at = function (time) { return (typeof time === "string") ? $D.parse(this.toString("d") + " " + time) : this.set(time); }; /** * Creates a new Date() and adds this (Number) to the date based on the preceding date element function (eg. second|minute|hour|day|month|year). * Example

	// Undeclared Numbers must be wrapped with parentheses. Requirment of JavaScript.
	(3).days().fromNow();
	(6).months().fromNow();

	// Declared Number variables do not require parentheses. 
	var n = 6;
	n.months().fromNow();
	
* * @return {Date} A new Date instance */ $N.fromNow = $N.after = function (date) { var c = {}; c[this._dateElement] = this; return ((!date) ? new Date() : date.clone()).add(c); }; /** * Creates a new Date() and subtract this (Number) from the date based on the preceding date element function (eg. second|minute|hour|day|month|year). * Example

	// Undeclared Numbers must be wrapped with parentheses. Requirment of JavaScript.
	(3).days().ago();
	(6).months().ago();

	// Declared Number variables do not require parentheses. 
	var n = 6;
	n.months().ago();
	
* * @return {Date} A new Date instance */ $N.ago = $N.before = function (date) { var c = {}, s = (this._dateElement[this._dateElement.length-1] !== "s") ? this._dateElement + "s" : this._dateElement; c[s] = this * -1; return ((!date) ? new Date() : date.clone()).add(c); }; // Do NOT modify the following string tokens. These tokens are used to build dynamic functions. // All culture-specific strings can be found in the CultureInfo files. var dx = ("sunday monday tuesday wednesday thursday friday saturday").split(/\s/), mx = ("january february march april may june july august september october november december").split(/\s/), px = ("Millisecond Second Minute Hour Day Week Month Year Quarter Weekday").split(/\s/), pxf = ("Milliseconds Seconds Minutes Hours Date Week Month FullYear Quarter").split(/\s/), nth = ("final first second third fourth fifth").split(/\s/), de; /** * Returns an object literal of all the date parts. * Example

	var o = new Date().toObject();
	
	// { year: 2008, month: 4, week: 20, day: 13, hour: 18, minute: 9, second: 32, millisecond: 812 }
	
	// The object properties can be referenced directly from the object.
	
	alert(o.day);  // alerts "13"
	alert(o.year); // alerts "2008"
	
* * @return {Date} An object literal representing the original date object. */ $P.toObject = function () { var o = {}; for (var i = 0; i < px.length; i++) { if (this["get" + pxf[i]]) { o[px[i].toLowerCase()] = this["get" + pxf[i]](); } } return o; }; /** * Returns a date created from an object literal. Ignores the .week property if set in the config. * Example

	var o = new Date().toObject();
	
	return Date.fromObject(o); // will return the same date. 

	var o2 = {month: 1, day: 20, hour: 18}; // birthday party!
	Date.fromObject(o2);
	
* * @return {Date} An object literal representing the original date object. */ $D.fromObject = function(config) { config.week = null; return Date.today().set(config); }; // Create day name functions and abbreviated day name functions (eg. monday(), friday(), fri()). var df = function (n) { return function () { if (this._is) { this._is = false; return this.getDay() === n; } if (this._move) { this._move = null; } if (this._nth !== null) { // If the .second() function was called earlier, remove the _orient // from the date, and then continue. // This is required because 'second' can be used in two different context. // // Example // // Date.today().add(1).second(); // Date.march().second().monday(); // // Things get crazy with the following... // Date.march().add(1).second().second().monday(); // but it works!! // if (this._isSecond) { this.addSeconds(this._orient * -1); } // make sure we reset _isSecond this._isSecond = false; var ntemp = this._nth; this._nth = null; var temp = this.clone().moveToLastDayOfMonth(); this.moveToNthOccurrence(n, ntemp); if (this > temp) { throw new RangeError($D.getDayName(n) + " does not occur " + ntemp + " times in the month of " + $D.getMonthName(temp.getMonth()) + " " + temp.getFullYear() + "."); } return this; } return this.moveToDayOfWeek(n, this._orient); }; }; var sdf = function (n) { return function () { var t = $D.today(), shift = n - t.getDay(); if (n === 0 && Date.CultureInfo.firstDayOfWeek === 1 && t.getDay() !== 0) { shift = shift + 7; } return t.addDays(shift); }; }; // Create month name functions and abbreviated month name functions (eg. january(), march(), mar()). var month_instance_functions = function (n) { return function () { if (this._is) { this._is = false; return this.getMonth() === n; } return this.moveToMonth(n, this._orient); }; }; var month_static_functions = function (n) { return function () { return $D.today().set({ month: n, day: 1 }); }; }; var processTerms = function (names, staticFunc, instanceFunc) { for (var i = 0; i < names.length; i++) { // Create constant static Name variables. $D[names[i].toUpperCase()] = $D[names[i].toUpperCase().substring(0, 3)] = i; // Create Name functions. $D[names[i]] = $D[names[i].substring(0, 3)] = staticFunc(i); // Create Name instance functions. $P[names[i]] = $P[names[i].substring(0, 3)] = instanceFunc(i); } }; processTerms(dx, sdf, df); processTerms(mx, month_static_functions, month_instance_functions); // Create date element functions and plural date element functions used with Date (eg. day(), days(), months()). var ef = function (j) { return function () { // if the .second() function was called earlier, the _orient // has alread been added. Just return this and reset _isSecond. if (this._isSecond) { this._isSecond = false; return this; } if (this._same) { this._same = this._is = false; var o1 = this.toObject(), o2 = (arguments[0] || new Date()).toObject(), v = "", k = j.toLowerCase(); // the substr trick with -1 doesn't work in IE8 or less k = (k[k.length-1] === "s") ? k.substring(0,k.length-1) : k; for (var m = (px.length - 1); m > -1; m--) { v = px[m].toLowerCase(); if (o1[v] !== o2[v]) { return false; } if (k === v) { break; } } return true; } if (j.substring(j.length - 1) !== "s") { j += "s"; } if (this._move) { this._move = null; } return this["add" + j](this._orient); }; }; var nf = function (n) { return function () { this._dateElement = n; return this; }; }; for (var k = 0; k < px.length; k++) { de = px[k].toLowerCase(); if(de !== "weekday") { // Create date element functions and plural date element functions used with Date (eg. day(), days(), months()). $P[de] = $P[de + "s"] = ef(px[k]); // Create date element functions and plural date element functions used with Number (eg. day(), days(), months()). $N[de] = $N[de + "s"] = nf(de + "s"); } } $P._ss = ef("Second"); var nthfn = function (n) { return function (dayOfWeek) { if (this._same) { return this._ss(arguments[0]); } if (dayOfWeek || dayOfWeek === 0) { return this.moveToNthOccurrence(dayOfWeek, n); } this._nth = n; // if the operator is 'second' add the _orient, then deal with it later... if (n === 2 && (dayOfWeek === undefined || dayOfWeek === null)) { this._isSecond = true; return this.addSeconds(this._orient); } return this; }; }; for (var l = 0; l < nth.length; l++) { $P[nth[l]] = (l === 0) ? nthfn(-1) : nthfn(l); } }()); (function () { "use strict"; Date.Parsing = { Exception: function (s) { this.message = "Parse error at '" + s.substring(0, 10) + " ...'"; } }; var $P = Date.Parsing; var dayOffsets = { standard: [0,31,59,90,120,151,181,212,243,273,304,334], leap: [0,31,60,91,121,152,182,213,244,274,305,335] }; $P.isLeapYear = function(year) { return ((year % 4 === 0) && (year % 100 !== 0)) || (year % 400 === 0); }; var utils = { multiReplace : function (str, hash ) { var key; for (key in hash) { if (Object.prototype.hasOwnProperty.call(hash, key)) { var regex; if (typeof hash[key] === "function") { } else { regex = (hash[key] instanceof RegExp) ? hash[key] : new RegExp(hash[key], "g"); } str = str.replace(regex, key); } } return str; }, getDayOfYearFromWeek : function (obj) { var d, jan4, offset; obj.weekDay = (!obj.weekDay && obj.weekDay !== 0) ? 1 : obj.weekDay; d = new Date(obj.year, 0, 4); jan4 = d.getDay() === 0 ? 7 : d.getDay(); // JS is 0 indexed on Sunday. offset = jan4+3; obj.dayOfYear = ((obj.week * 7) + (obj.weekDay === 0 ? 7 : obj.weekDay))-offset; return obj; }, getDayOfYear : function (obj, dayOffset) { if (!obj.dayOfYear) { obj = utils.getDayOfYearFromWeek(obj); } for (var i=0;i <= dayOffset.length;i++) { if (obj.dayOfYear < dayOffset[i] || i === dayOffset.length) { obj.day = obj.day ? obj.day : (obj.dayOfYear - dayOffset[i-1]); break; } else { obj.month = i; } } return obj; }, adjustForTimeZone : function (obj, date) { var offset; if (obj.zone.toUpperCase() === "Z" || (obj.zone_hours === 0 && obj.zone_minutes === 0)) { // it's UTC/GML so work out the current timeszone offset offset = -date.getTimezoneOffset(); } else { offset = (obj.zone_hours*60) + (obj.zone_minutes || 0); if (obj.zone_sign === "+") { offset *= -1; } offset -= date.getTimezoneOffset(); } date.setMinutes(date.getMinutes()+offset); return date; }, setDefaults : function (obj) { obj.year = obj.year || Date.today().getFullYear(); obj.hours = obj.hours || 0; obj.minutes = obj.minutes || 0; obj.seconds = obj.seconds || 0; obj.milliseconds = obj.milliseconds || 0; if (!(!obj.month && (obj.week || obj.dayOfYear))) { // if we have a month, or if we don't but don't have the day calculation data obj.month = obj.month || 0; obj.day = obj.day || 1; } return obj; }, dataNum: function (data, mod, explict, postProcess) { var dataNum = data*1; if (mod) { if (postProcess) { return data ? mod(data)*1 : data; } else { return data ? mod(dataNum) : data; } } else if (!explict){ return data ? dataNum : data; } else { return (data && typeof data !== "undefined") ? dataNum : data; } }, timeDataProcess: function (obj) { var timeObj = {}; for (var x in obj.data) { if (obj.data.hasOwnProperty(x)) { timeObj[x] = obj.ignore[x] ? obj.data[x] : utils.dataNum(obj.data[x], obj.mods[x], obj.explict[x], obj.postProcess[x]); } } if (obj.data.secmins) { obj.data.secmins = obj.data.secmins.replace(",", ".") * 60; if (!timeObj.minutes) { timeObj.minutes = obj.data.secmins; } else if (!timeObj.seconds) { timeObj.seconds = obj.data.secmins; } delete obj.secmins; } return timeObj; }, buildTimeObjectFromData: function (data) { var time = utils.timeDataProcess({ data: { year : data[1], month : data[5], day : data[7], week : data[8], dayOfYear : data[10], hours : data[15], zone_hours : data[23], zone_minutes : data[24], zone : data[21], zone_sign : data[22], weekDay : data[9], minutes: data[16], seconds: data[19], milliseconds: data[20], secmins: data[18] }, mods: { month: function(data) { return data-1; }, weekDay: function (data) { data = Math.abs(data); return (data === 7 ? 0 : data); }, minutes: function (data) { return data.replace(":",""); }, seconds: function (data) { return Math.floor( (data.replace(":","").replace(",","."))*1 ); }, milliseconds: function (data) { return (data.replace(",",".")*1000); } }, postProcess: { minutes: true, seconds: true, milliseconds: true }, explict: { zone_hours: true, zone_minutes: true }, ignore: { zone: true, zone_sign: true, secmins: true } }); return time; }, addToHash: function (hash, keys, data) { keys = keys; data = data; var len = keys.length; for (var i = 0; i < len; i++) { hash[keys[i]] = data[i]; } return hash; }, combineRegex: function (r1, r2) { return new RegExp("(("+r1.source+")\\s("+r2.source+"))"); }, getDateNthString: function(add, last, inc){ if (add) { return Date.today().addDays(inc).toString("d"); } else if (last) { return Date.today().last()[inc]().toString("d"); } }, buildRegexData: function (array) { var arr = []; var len = array.length; for (var i=0; i < len; i++) { if (Object.prototype.toString.call(array[i]) === '[object Array]') { // oldIE compat version of Array.isArray arr.push(this.combineRegex(array[i][0], array[i][1])); } else { arr.push(array[i]); } } return arr; } }; $P.processTimeObject = function (obj) { var date, dayOffset; utils.setDefaults(obj); dayOffset = ($P.isLeapYear(obj.year)) ? dayOffsets.leap : dayOffsets.standard; if (!obj.month && (obj.week || obj.dayOfYear)) { utils.getDayOfYear(obj, dayOffset); } else { obj.dayOfYear = dayOffset[obj.month] + obj.day; } date = new Date(obj.year, obj.month, obj.day, obj.hours, obj.minutes, obj.seconds, obj.milliseconds); if (obj.zone) { utils.adjustForTimeZone(obj, date); // adjust (and calculate) for timezone } return date; }; $P.ISO = { regex : /^([\+-]?\d{4}(?!\d{2}\b))((-?)((0[1-9]|1[0-2])(\3([12]\d|0[1-9]|3[01]))?|W([0-4]\d|5[0-3])(-?[1-7])?|(00[1-9]|0[1-9]\d|[12]\d{2}|3([0-5]\d|6[1-6])))([T\s]((([01]\d|2[0-4])((:?)[0-5]\d)?|24\:?00)([\.,]\d+(?!:))?)?(\17[0-5]\d([\.,]\d+)?)?\s?([zZ]|([\+-])([01]\d|2[0-3]):?([0-5]\d)?)?)?)?$/, parse : function (s) { var time, data = s.match(this.regex); if (!data || !data.length) { return null; } time = utils.buildTimeObjectFromData(data); if (!time.year || (!time.year && (!time.month && !time.day) && (!time.week && !time.dayOfYear)) ) { return null; } return $P.processTimeObject(time); } }; $P.Numeric = { isNumeric: function (e){return!isNaN(parseFloat(e))&&isFinite(e);}, regex: /\b([0-1]?[0-9])([0-3]?[0-9])([0-2]?[0-9]?[0-9][0-9])\b/i, parse: function (s) { var data, i, time = {}, order = Date.CultureInfo.dateElementOrder.split(""); if (!(this.isNumeric(s)) || // if it's non-numeric OR (s[0] === "+" && s[0] === "-")) { // It's an arithmatic string (eg +/-1000) return null; } if (s.length < 5 && s.indexOf(".") < 0 && s.indexOf("/") < 0) { // assume it's just a year. time.year = s; return $P.processTimeObject(time); } data = s.match(this.regex); if (!data || !data.length) { return null; } for (i=0; i < order.length; i++) { switch(order[i]) { case "d": time.day = data[i+1]; break; case "m": time.month = (data[i+1]-1); break; case "y": time.year = data[i+1]; break; } } return $P.processTimeObject(time); } }; $P.Normalizer = { regexData: function () { var $R = Date.CultureInfo.regexPatterns; return utils.buildRegexData([ $R.tomorrow, $R.yesterday, [$R.past, $R.mon], [$R.past, $R.tue], [$R.past, $R.wed], [$R.past, $R.thu], [$R.past, $R.fri], [$R.past, $R.sat], [$R.past, $R.sun] ]); }, basicReplaceHash : function() { var $R = Date.CultureInfo.regexPatterns; return { "January": $R.jan.source, "February": $R.feb, "March": $R.mar, "April": $R.apr, "May": $R.may, "June": $R.jun, "July": $R.jul, "August": $R.aug, "September": $R.sep, "October": $R.oct, "November": $R.nov, "December": $R.dec, "": /\bat\b/gi, " ": /\s{2,}/, "am": $R.inTheMorning, "9am": $R.thisMorning, "pm": $R.inTheEvening, "7pm":$R.thisEvening }; }, keys : function(){ return [ utils.getDateNthString(true, false, 1), // tomorrow utils.getDateNthString(true, false, -1), // yesterday utils.getDateNthString(false, true, "monday"), //last mon utils.getDateNthString(false, true, "tuesday"), //last tues utils.getDateNthString(false, true, "wednesday"), //last wed utils.getDateNthString(false, true, "thursday"), //last thurs utils.getDateNthString(false, true, "friday"), //last fri utils.getDateNthString(false, true, "saturday"), //last sat utils.getDateNthString(false, true, "sunday") //last sun ]; }, buildRegexFunctions: function () { var $R = Date.CultureInfo.regexPatterns; var __ = Date.i18n.__; var tomorrowRE = new RegExp("(\\b\\d\\d?("+__("AM")+"|"+__("PM")+")? )("+$R.tomorrow.source.slice(1)+")", "i"); // adapted tomorrow regex for AM PM relative dates var todayRE = new RegExp($R.today.source + "(?!\\s*([+-]))\\b"); // today, but excludes the math operators (eg "today + 2h") this.replaceFuncs = [ [todayRE, function (full) { return (full.length > 1) ? Date.today().toString("d") : full; }], [tomorrowRE, function(full, m1) { var t = Date.today().addDays(1).toString("d"); return (t + " " + m1); }], [$R.amThisMorning, function(str, am){return am;}], [$R.pmThisEvening, function(str, pm){return pm;}] ]; }, buildReplaceData: function () { this.buildRegexFunctions(); this.replaceHash = utils.addToHash(this.basicReplaceHash(), this.keys(), this.regexData()); }, stringReplaceFuncs: function (s) { for (var i=0; i < this.replaceFuncs.length; i++) { s = s.replace(this.replaceFuncs[i][0], this.replaceFuncs[i][1]); } return s; }, parse: function (s) { s = this.stringReplaceFuncs(s); s = utils.multiReplace(s, this.replaceHash); try { var n = s.split(/([\s\-\.\,\/\x27]+)/); if (n.length === 3 && $P.Numeric.isNumeric(n[0]) && $P.Numeric.isNumeric(n[2]) && (n[2].length >= 4)) { // ok, so we're dealing with x/year. But that's not a full date. // This fixes wonky dateElementOrder parsing when set to dmy order. if (Date.CultureInfo.dateElementOrder[0] === "d") { s = "1/" + n[0] + "/" + n[2]; // set to 1st of month and normalize the seperator } } } catch (e) {} return s; } }; $P.Normalizer.buildReplaceData(); }()); (function () { var $P = Date.Parsing; var _ = $P.Operators = { // // Tokenizers // rtoken: function (r) { // regex token return function (s) { var mx = s.match(r); if (mx) { return ([ mx[0], s.substring(mx[0].length) ]); } else { throw new $P.Exception(s); } }; }, token: function () { // whitespace-eating token return function (s) { return _.rtoken(new RegExp("^\\s*" + s + "\\s*"))(s); }; }, stoken: function (s) { // string token return _.rtoken(new RegExp("^" + s)); }, // Atomic Operators until: function (p) { return function (s) { var qx = [], rx = null; while (s.length) { try { rx = p.call(this, s); } catch (e) { qx.push(rx[0]); s = rx[1]; continue; } break; } return [ qx, s ]; }; }, many: function (p) { return function (s) { var rx = [], r = null; while (s.length) { try { r = p.call(this, s); } catch (e) { return [ rx, s ]; } rx.push(r[0]); s = r[1]; } return [ rx, s ]; }; }, // generator operators -- see below optional: function (p) { return function (s) { var r = null; try { r = p.call(this, s); } catch (e) { return [ null, s ]; } return [ r[0], r[1] ]; }; }, not: function (p) { return function (s) { try { p.call(this, s); } catch (e) { return [null, s]; } throw new $P.Exception(s); }; }, ignore: function (p) { return p ? function (s) { var r = null; r = p.call(this, s); return [null, r[1]]; } : null; }, product: function () { var px = arguments[0], qx = Array.prototype.slice.call(arguments, 1), rx = []; for (var i = 0 ; i < px.length ; i++) { rx.push(_.each(px[i], qx)); } return rx; }, cache: function (rule) { var cache = {}, cache_length = 0, cache_keys = [], CACHE_MAX = Date.Config.CACHE_MAX || 100000, r = null; var cacheCheck = function () { if (cache_length === CACHE_MAX) { // kill several keys, don't want to have to do this all the time... for (var i=0; i < 10; i++) { var key = cache_keys.shift(); if (key) { delete cache[key]; cache_length--; } } } }; return function (s) { cacheCheck(); try { r = cache[s] = (cache[s] || rule.call(this, s)); } catch (e) { r = cache[s] = e; } cache_length++; cache_keys.push(s); if (r instanceof $P.Exception) { throw r; } else { return r; } }; }, // vector operators -- see below any: function () { var px = arguments; return function (s) { var r = null; for (var i = 0; i < px.length; i++) { if (px[i] == null) { continue; } try { r = (px[i].call(this, s)); } catch (e) { r = null; } if (r) { return r; } } throw new $P.Exception(s); }; }, each: function () { var px = arguments; return function (s) { var rx = [], r = null; for (var i = 0; i < px.length ; i++) { if (px[i] == null) { continue; } try { r = (px[i].call(this, s)); } catch (e) { throw new $P.Exception(s); } rx.push(r[0]); s = r[1]; } return [ rx, s]; }; }, all: function () { var px = arguments, _ = _; return _.each(_.optional(px)); }, // delimited operators sequence: function (px, d, c) { d = d || _.rtoken(/^\s*/); c = c || null; if (px.length === 1) { return px[0]; } return function (s) { var r = null, q = null; var rx = []; for (var i = 0; i < px.length ; i++) { try { r = px[i].call(this, s); } catch (e) { break; } rx.push(r[0]); try { q = d.call(this, r[1]); } catch (ex) { q = null; break; } s = q[1]; } if (!r) { throw new $P.Exception(s); } if (q) { throw new $P.Exception(q[1]); } if (c) { try { r = c.call(this, r[1]); } catch (ey) { throw new $P.Exception(r[1]); } } return [ rx, (r?r[1]:s) ]; }; }, // // Composite Operators // between: function (d1, p, d2) { d2 = d2 || d1; var _fn = _.each(_.ignore(d1), p, _.ignore(d2)); return function (s) { var rx = _fn.call(this, s); return [[rx[0][0], r[0][2]], rx[1]]; }; }, list: function (p, d, c) { d = d || _.rtoken(/^\s*/); c = c || null; return (p instanceof Array ? _.each(_.product(p.slice(0, -1), _.ignore(d)), p.slice(-1), _.ignore(c)) : _.each(_.many(_.each(p, _.ignore(d))), px, _.ignore(c))); }, set: function (px, d, c) { d = d || _.rtoken(/^\s*/); c = c || null; return function (s) { // r is the current match, best the current 'best' match // which means it parsed the most amount of input var r = null, p = null, q = null, rx = null, best = [[], s], last = false; // go through the rules in the given set for (var i = 0; i < px.length ; i++) { // last is a flag indicating whether this must be the last element // if there is only 1 element, then it MUST be the last one q = null; p = null; r = null; last = (px.length === 1); // first, we try simply to match the current pattern // if not, try the next pattern try { r = px[i].call(this, s); } catch (e) { continue; } // since we are matching against a set of elements, the first // thing to do is to add r[0] to matched elements rx = [[r[0]], r[1]]; // if we matched and there is still input to parse and // we don't already know this is the last element, // we're going to next check for the delimiter ... // if there's none, or if there's no input left to parse // than this must be the last element after all ... if (r[1].length > 0 && ! last) { try { q = d.call(this, r[1]); } catch (ex) { last = true; } } else { last = true; } // if we parsed the delimiter and now there's no more input, // that means we shouldn't have parsed the delimiter at all // so don't update r and mark this as the last element ... if (!last && q[1].length === 0) { last = true; } // so, if this isn't the last element, we're going to see if // we can get any more matches from the remaining (unmatched) // elements ... if (!last) { // build a list of the remaining rules we can match against, // i.e., all but the one we just matched against var qx = []; for (var j = 0; j < px.length ; j++) { if (i !== j) { qx.push(px[j]); } } // now invoke recursively set with the remaining input // note that we don't include the closing delimiter ... // we'll check for that ourselves at the end p = _.set(qx, d).call(this, q[1]); // if we got a non-empty set as a result ... // (otw rx already contains everything we want to match) if (p[0].length > 0) { // update current result, which is stored in rx ... // basically, pick up the remaining text from p[1] // and concat the result from p[0] so that we don't // get endless nesting ... rx[0] = rx[0].concat(p[0]); rx[1] = p[1]; } } // at this point, rx either contains the last matched element // or the entire matched set that starts with this element. // now we just check to see if this variation is better than // our best so far, in terms of how much of the input is parsed if (rx[1].length < best[1].length) { best = rx; } // if we've parsed all the input, then we're finished if (best[1].length === 0) { break; } } // so now we've either gone through all the patterns trying them // as the initial match; or we found one that parsed the entire // input string ... // if best has no matches, just return empty set ... if (best[0].length === 0) { return best; } // if a closing delimiter is provided, then we have to check it also if (c) { // we try this even if there is no remaining input because the pattern // may well be optional or match empty input ... try { q = c.call(this, best[1]); } catch (ey) { throw new $P.Exception(best[1]); } // it parsed ... be sure to update the best match remaining input best[1] = q[1]; } // if we're here, either there was no closing delimiter or we parsed it // so now we have the best match; just return it! return best; }; }, forward: function (gr, fname) { return function (s) { return gr[fname].call(this, s); }; }, // // Translation Operators // replace: function (rule, repl) { return function (s) { var r = rule.call(this, s); return [repl, r[1]]; }; }, process: function (rule, fn) { return function (s) { var r = rule.call(this, s); return [fn.call(this, r[0]), r[1]]; }; }, min: function (min, rule) { return function (s) { var rx = rule.call(this, s); if (rx[0].length < min) { throw new $P.Exception(s); } return rx; }; } }; // Generator Operators And Vector Operators // Generators are operators that have a signature of F(R) => R, // taking a given rule and returning another rule, such as // ignore, which parses a given rule and throws away the result. // Vector operators are those that have a signature of F(R1,R2,...) => R, // take a list of rules and returning a new rule, such as each. // Generator operators are converted (via the following _generator // function) into functions that can also take a list or array of rules // and return an array of new rules as though the function had been // called on each rule in turn (which is what actually happens). // This allows generators to be used with vector operators more easily. // Example: // each(ignore(foo, bar)) instead of each(ignore(foo), ignore(bar)) // This also turns generators into vector operators, which allows // constructs like: // not(cache(foo, bar)) var _generator = function (op) { function gen() { var args = null, rx = [], px, i; if (arguments.length > 1) { args = Array.prototype.slice.call(arguments); } else if (arguments[0] instanceof Array) { args = arguments[0]; } if (args) { px = args.shift(); if (px.length > 0) { args.unshift(px[i]); rx.push(op.apply(null, args)); args.shift(); return rx; } } else { return op.apply(null, arguments); } } return gen; }; var gx = "optional not ignore cache".split(/\s/); for (var i = 0 ; i < gx.length ; i++) { _[gx[i]] = _generator(_[gx[i]]); } var _vector = function (op) { return function () { if (arguments[0] instanceof Array) { return op.apply(null, arguments[0]); } else { return op.apply(null, arguments); } }; }; var vx = "each any all".split(/\s/); for (var j = 0 ; j < vx.length ; j++) { _[vx[j]] = _vector(_[vx[j]]); } }()); (function () { var $D = Date; var flattenAndCompact = function (ax) { var rx = []; for (var i = 0; i < ax.length; i++) { if (ax[i] instanceof Array) { rx = rx.concat(flattenAndCompact(ax[i])); } else { if (ax[i]) { rx.push(ax[i]); } } } return rx; }; var parseMeridian = function () { if (this.meridian && (this.hour || this.hour === 0)) { if (this.meridian === "a" && this.hour > 11 && Date.Config.strict24hr){ throw "Invalid hour and meridian combination"; } else if (this.meridian === "p" && this.hour < 12 && Date.Config.strict24hr){ throw "Invalid hour and meridian combination"; } else if (this.meridian === "p" && this.hour < 12) { this.hour = this.hour + 12; } else if (this.meridian === "a" && this.hour === 12) { this.hour = 0; } } }; var setDefaults = function () { var now = new Date(); if ((this.hour || this.minute) && (!this.month && !this.year && !this.day)) { this.day = now.getDate(); } if (!this.year) { this.year = now.getFullYear(); } if (!this.month && this.month !== 0) { this.month = now.getMonth(); } if (!this.day) { this.day = 1; } if (!this.hour) { this.hour = 0; } if (!this.minute) { this.minute = 0; } if (!this.second) { this.second = 0; } if (!this.millisecond) { this.millisecond = 0; } }; var finishUtils = { getToday: function () { if (this.now || "hour minute second".indexOf(this.unit) !== -1) { return new Date(); } else { return $D.today(); } }, setDaysFromWeekday: function (today, orient){ var gap; orient = orient || 1; this.unit = "day"; gap = ($D.getDayNumberFromName(this.weekday) - today.getDay()); this.days = gap ? ((gap + (orient * 7)) % 7) : (orient * 7); return this; }, setMonthsFromMonth: function (today, orient) { var gap; orient = orient || 1; this.unit = "month"; gap = (this.month - today.getMonth()); this.months = gap ? ((gap + (orient * 12)) % 12) : (orient * 12); this.month = null; return this; }, setDMYFromWeekday: function () { var d = Date[this.weekday](); this.day = d.getDate(); if (!this.month) { this.month = d.getMonth(); } this.year = d.getFullYear(); return this; }, setUnitValue: function (orient) { if (!this.value && this.operator && this.operator !== null && this[this.unit + "s"] && this[this.unit + "s"] !== null) { this[this.unit + "s"] = this[this.unit + "s"] + ((this.operator === "add") ? 1 : -1) + (this.value||0) * orient; } else if (this[this.unit + "s"] == null || this.operator != null) { if (!this.value) { this.value = 1; } this[this.unit + "s"] = this.value * orient; } }, generateDateFromWeeks: function () { var weekday = (this.weekday !== undefined) ? this.weekday : "today"; var d = Date[weekday]().addWeeks(this.weeks); if (this.now) { d.setTimeToNow(); } return d; } }; $D.Translator = { hour: function (s) { return function () { this.hour = Number(s); }; }, minute: function (s) { return function () { this.minute = Number(s); }; }, second: function (s) { return function () { this.second = Number(s); }; }, /* for ss.s format */ secondAndMillisecond: function (s) { return function () { var mx = s.match(/^([0-5][0-9])\.([0-9]{1,3})/); this.second = Number(mx[1]); this.millisecond = Number(mx[2]); }; }, meridian: function (s) { return function () { this.meridian = s.slice(0, 1).toLowerCase(); }; }, timezone: function (s) { return function () { var n = s.replace(/[^\d\+\-]/g, ""); if (n.length) { this.timezoneOffset = Number(n); } else { this.timezone = s.toLowerCase(); } }; }, day: function (x) { var s = x[0]; return function () { this.day = Number(s.match(/\d+/)[0]); if (this.day < 1) { throw "invalid day"; } }; }, month: function (s) { return function () { this.month = (s.length === 3) ? "jan feb mar apr may jun jul aug sep oct nov dec".indexOf(s)/4 : Number(s) - 1; if (this.month < 0) { throw "invalid month"; } }; }, year: function (s) { return function () { var n = Number(s); this.year = ((s.length > 2) ? n : (n + (((n + 2000) < Date.CultureInfo.twoDigitYearMax) ? 2000 : 1900))); }; }, rday: function (s) { return function () { switch (s) { case "yesterday": this.days = -1; break; case "tomorrow": this.days = 1; break; case "today": this.days = 0; break; case "now": this.days = 0; this.now = true; break; } }; }, finishExact: function (x) { var d; x = (x instanceof Array) ? x : [x]; for (var i = 0 ; i < x.length ; i++) { if (x[i]) { x[i].call(this); } } setDefaults.call(this); parseMeridian.call(this); if (this.day > $D.getDaysInMonth(this.year, this.month)) { throw new RangeError(this.day + " is not a valid value for days."); } d = new Date(this.year, this.month, this.day, this.hour, this.minute, this.second, this.millisecond); if (this.year < 100) { d.setFullYear(this.year); // means years less that 100 are process correctly. JS will parse it otherwise as 1900-1999. } if (this.timezone) { d.set({ timezone: this.timezone }); } else if (this.timezoneOffset) { d.set({ timezoneOffset: this.timezoneOffset }); } return d; }, finish: function (x) { var today, expression, orient, temp; x = (x instanceof Array) ? flattenAndCompact(x) : [ x ]; if (x.length === 0) { return null; } for (var i = 0 ; i < x.length ; i++) { if (typeof x[i] === "function") { x[i].call(this); } } if (this.now && !this.unit && !this.operator) { return new Date(); } else { today = finishUtils.getToday.call(this); } expression = !!(this.days && this.days !== null || this.orient || this.operator); orient = ((this.orient === "past" || this.operator === "subtract") ? -1 : 1); if (this.month && this.unit === "week") { this.value = this.month + 1; delete this.month; delete this.day; } if ((this.month || this.month === 0) && "year day hour minute second".indexOf(this.unit) !== -1) { if (!this.value) { this.value = this.month + 1; } this.month = null; expression = true; } if (!expression && this.weekday && !this.day && !this.days) { finishUtils.setDMYFromWeekday.call(this); } if (expression && this.weekday && this.unit !== "month" && this.unit !== "week") { finishUtils.setDaysFromWeekday.call(this, today, orient); } if (this.weekday && this.unit !== "week" && !this.day && !this.days) { temp = Date[this.weekday](); this.day = temp.getDate(); if (temp.getMonth() !== today.getMonth()) { this.month = temp.getMonth(); } } if (this.month && this.unit === "day" && this.operator) { if (!this.value) { this.value = (this.month + 1); } this.month = null; } if (this.value != null && this.month != null && this.year != null) { this.day = this.value * 1; } if (this.month && !this.day && this.value) { today.set({ day: this.value * 1 }); if (!expression) { this.day = this.value * 1; } } if (!this.month && this.value && this.unit === "month" && !this.now) { this.month = this.value; expression = true; } if (expression && (this.month || this.month === 0) && this.unit !== "year") { finishUtils.setMonthsFromMonth.call(this, today, orient); } if (!this.unit) { this.unit = "day"; } finishUtils.setUnitValue.call(this, orient); parseMeridian.call(this); if ((this.month || this.month === 0) && !this.day) { this.day = 1; } if (!this.orient && !this.operator && this.unit === "week" && this.value && !this.day && !this.month) { return Date.today().setWeek(this.value); } if (this.unit === "week" && this.weeks && !this.day && !this.month) { return finishUtils.generateDateFromWeeks.call(this); } if (expression && this.timezone && this.day && this.days) { this.day = this.days; } if (expression){ today.add(this); } else { today.set(this); } if (this.timezone) { this.timezone = this.timezone.toUpperCase(); var offset = $D.getTimezoneOffset(this.timezone); var timezone; if (today.hasDaylightSavingTime()) { // lets check that we're being sane with timezone setting timezone = $D.getTimezoneAbbreviation(offset, today.isDaylightSavingTime()); if (timezone !== this.timezone) { // bugger, we're in a place where things like EST vs EDT matters. if (today.isDaylightSavingTime()) { today.addHours(-1); } else { today.addHours(1); } } } today.setTimezoneOffset(offset); } return today; } }; }()); (function () { var $D = Date; $D.Grammar = {}; var _ = $D.Parsing.Operators, g = $D.Grammar, t = $D.Translator, _fn; // Allow rolling up into general purpose rules _fn = function () { return _.each(_.any.apply(null, arguments), _.not(g.ctoken2("timeContext"))); }; g.datePartDelimiter = _.rtoken(/^([\s\-\.\,\/\x27]+)/); g.timePartDelimiter = _.stoken(":"); g.whiteSpace = _.rtoken(/^\s*/); g.generalDelimiter = _.rtoken(/^(([\s\,]|at|@|on)+)/); var _C = {}; g.ctoken = function (keys) { var fn = _C[keys]; if (! fn) { var c = Date.CultureInfo.regexPatterns; var kx = keys.split(/\s+/), px = []; for (var i = 0; i < kx.length ; i++) { px.push(_.replace(_.rtoken(c[kx[i]]), kx[i])); } fn = _C[keys] = _.any.apply(null, px); } return fn; }; g.ctoken2 = function (key) { return _.rtoken(Date.CultureInfo.regexPatterns[key]); }; var cacheProcessRtoken = function (key, token, type, eachToken) { if (eachToken) { g[key] = _.cache(_.process(_.each(_.rtoken(token),_.optional(g.ctoken2(eachToken))), type)); } else { g[key] = _.cache(_.process(_.rtoken(token), type)); } }; var cacheProcessCtoken = function (token, type) { return _.cache(_.process(g.ctoken2(token), type)); }; var _F = {}; //function cache var _get = function (f) { _F[f] = (_F[f] || g.format(f)[0]); return _F[f]; }; g.allformats = function (fx) { var rx = []; if (fx instanceof Array) { for (var i = 0; i < fx.length; i++) { rx.push(_get(fx[i])); } } else { rx.push(_get(fx)); } return rx; }; g.formats = function (fx) { if (fx instanceof Array) { var rx = []; for (var i = 0 ; i < fx.length ; i++) { rx.push(_get(fx[i])); } return _.any.apply(null, rx); } else { return _get(fx); } }; var grammarFormats = { timeFormats: function(){ var i, RTokenKeys = [ "h", "hh", "H", "HH", "m", "mm", "s", "ss", "ss.s", "z", "zz" ], RToken = [ /^(0[0-9]|1[0-2]|[1-9])/, /^(0[0-9]|1[0-2])/, /^([0-1][0-9]|2[0-3]|[0-9])/, /^([0-1][0-9]|2[0-3])/, /^([0-5][0-9]|[0-9])/, /^[0-5][0-9]/, /^([0-5][0-9]|[0-9])/, /^[0-5][0-9]/, /^[0-5][0-9]\.[0-9]{1,3}/, /^((\+|\-)\s*\d\d\d\d)|((\+|\-)\d\d\:?\d\d)/, /^((\+|\-)\s*\d\d\d\d)|((\+|\-)\d\d\:?\d\d)/ ], tokens = [ t.hour, t.hour, t.hour, t.hour, t.minute, t.minute, t.second, t.second, t.secondAndMillisecond, t.timezone, t.timezone ]; for (i=0; i < RTokenKeys.length; i++) { cacheProcessRtoken(RTokenKeys[i], RToken[i], tokens[i]); } g.hms = _.cache(_.sequence([g.H, g.m, g.s], g.timePartDelimiter)); g.t = cacheProcessCtoken("shortMeridian", t.meridian); g.tt = cacheProcessCtoken("longMeridian", t.meridian); g.zzz = cacheProcessCtoken("timezone", t.timezone); g.timeSuffix = _.each(_.ignore(g.whiteSpace), _.set([ g.tt, g.zzz ])); g.time = _.each(_.optional(_.ignore(_.stoken("T"))), g.hms, g.timeSuffix); }, dateFormats: function () { // pre-loaded rules for different date part order preferences var _setfn = function () { return _.set(arguments, g.datePartDelimiter); }; var i, RTokenKeys = [ "d", "dd", "M", "MM", "y", "yy", "yyy", "yyyy" ], RToken = [ /^([0-2]\d|3[0-1]|\d)/, /^([0-2]\d|3[0-1])/, /^(1[0-2]|0\d|\d)/, /^(1[0-2]|0\d)/, /^(\d+)/, /^(\d\d)/, /^(\d\d?\d?\d?)/, /^(\d\d\d\d)/ ], tokens = [ t.day, t.day, t.month, t.month, t.year, t.year, t.year, t.year ], eachToken = [ "ordinalSuffix", "ordinalSuffix" ]; for (i=0; i < RTokenKeys.length; i++) { cacheProcessRtoken(RTokenKeys[i], RToken[i], tokens[i], eachToken[i]); } g.MMM = g.MMMM = _.cache(_.process(g.ctoken("jan feb mar apr may jun jul aug sep oct nov dec"), t.month)); g.ddd = g.dddd = _.cache(_.process(g.ctoken("sun mon tue wed thu fri sat"), function (s) { return function () { this.weekday = s; }; } )); g.day = _fn(g.d, g.dd); g.month = _fn(g.M, g.MMM); g.year = _fn(g.yyyy, g.yy); g.mdy = _setfn(g.ddd, g.month, g.day, g.year); g.ymd = _setfn(g.ddd, g.year, g.month, g.day); g.dmy = _setfn(g.ddd, g.day, g.month, g.year); g.date = function (s) { return ((g[Date.CultureInfo.dateElementOrder] || g.mdy).call(this, s)); }; }, relative: function () { // relative date / time expressions g.orientation = _.process(g.ctoken("past future"), function (s) { return function () { this.orient = s; }; } ); g.operator = _.process(g.ctoken("add subtract"), function (s) { return function () { this.operator = s; }; } ); g.rday = _.process(g.ctoken("yesterday tomorrow today now"), t.rday); g.unit = _.process(g.ctoken("second minute hour day week month year"), function (s) { return function () { this.unit = s; }; } ); } }; g.buildGrammarFormats = function () { // these need to be rebuilt every time the language changes. _C = {}; grammarFormats.timeFormats(); grammarFormats.dateFormats(); grammarFormats.relative(); g.value = _.process(_.rtoken(/^([-+]?\d+)?(st|nd|rd|th)?/), function (s) { return function () { this.value = s.replace(/\D/g, ""); }; } ); g.expression = _.set([g.rday, g.operator, g.value, g.unit, g.orientation, g.ddd, g.MMM ]); g.format = _.process(_.many( _.any( // translate format specifiers into grammar rules _.process( _.rtoken(/^(dd?d?d?(?!e)|MM?M?M?|yy?y?y?|hh?|HH?|mm?|ss?|tt?|zz?z?)/), function (fmt) { if (g[fmt]) { return g[fmt]; } else { throw $D.Parsing.Exception(fmt); } } ), // translate separator tokens into token rules _.process(_.rtoken(/^[^dMyhHmstz]+/), // all legal separators function (s) { return _.ignore(_.stoken(s)); } ) ) ), // construct the parser ... function (rules) { return _.process(_.each.apply(null, rules), t.finishExact); } ); // starting rule for general purpose grammar g._start = _.process(_.set([ g.date, g.time, g.expression ], g.generalDelimiter, g.whiteSpace), t.finish); }; g.buildGrammarFormats(); // parsing date format specifiers - ex: "h:m:s tt" // this little guy will generate a custom parser based // on the format string, ex: g.format("h:m:s tt") // check for these formats first g._formats = g.formats([ "\"yyyy-MM-ddTHH:mm:ssZ\"", "yyyy-MM-ddTHH:mm:ss.sz", "yyyy-MM-ddTHH:mm:ssZ", "yyyy-MM-ddTHH:mm:ssz", "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-ddTHH:mmZ", "yyyy-MM-ddTHH:mmz", "yyyy-MM-ddTHH:mm", "ddd, MMM dd, yyyy H:mm:ss tt", "ddd MMM d yyyy HH:mm:ss zzz", "MMddyyyy", "ddMMyyyy", "Mddyyyy", "ddMyyyy", "Mdyyyy", "dMyyyy", "yyyy", "Mdyy", "dMyy", "d" ]); // real starting rule: tries selected formats first, // then general purpose rule g.start = function (s) { try { var r = g._formats.call({}, s); if (r[1].length === 0) { return r; } } catch (e) {} return g._start.call({}, s); }; }()); (function () { var $D = Date; /** * @desc Converts the specified string value into its JavaScript Date equivalent using CultureInfo specific format information. * * Example

	///////////
	// Dates //
	///////////

	// 15-Oct-2004
	var d1 = Date.parse("10/15/2004");

	// 15-Oct-2004
	var d1 = Date.parse("15-Oct-2004");

	// 15-Oct-2004
	var d1 = Date.parse("2004.10.15");

	//Fri Oct 15, 2004
	var d1 = Date.parse("Fri Oct 15, 2004");

	///////////
	// Times //
	///////////

	// Today at 10 PM.
	var d1 = Date.parse("10 PM");

	// Today at 10:30 PM.
	var d1 = Date.parse("10:30 P.M.");

	// Today at 6 AM.
	var d1 = Date.parse("06am");

	/////////////////////
	// Dates and Times //
	/////////////////////

	// 8-July-2004 @ 10:30 PM
	var d1 = Date.parse("July 8th, 2004, 10:30 PM");

	// 1-July-2004 @ 10:30 PM
	var d1 = Date.parse("2004-07-01T22:30:00");

	////////////////////
	// Relative Dates //
	////////////////////

	// Returns today's date. The string "today" is culture specific.
	var d1 = Date.parse("today");

	// Returns yesterday's date. The string "yesterday" is culture specific.
	var d1 = Date.parse("yesterday");

	// Returns the date of the next thursday.
	var d1 = Date.parse("Next thursday");

	// Returns the date of the most previous monday.
	var d1 = Date.parse("last monday");

	// Returns today's day + one year.
	var d1 = Date.parse("next year");

	///////////////
	// Date Math //
	///////////////

	// Today + 2 days
	var d1 = Date.parse("t+2");

	// Today + 2 days
	var d1 = Date.parse("today + 2 days");

	// Today + 3 months
	var d1 = Date.parse("t+3m");

	// Today - 1 year
	var d1 = Date.parse("today - 1 year");

	// Today - 1 year
	var d1 = Date.parse("t-1y"); 


	/////////////////////////////
	// Partial Dates and Times //
	/////////////////////////////

	// July 15th of this year.
	var d1 = Date.parse("July 15");

	// 15th day of current day and year.
	var d1 = Date.parse("15");

	// July 1st of current year at 10pm.
	var d1 = Date.parse("7/1 10pm");
	
* * @param {String} The string value to convert into a Date object [Required] * @return {Date} A Date object or null if the string cannot be converted into a Date. */ var parseUtils = { removeOrds: function (s) { ords = s.match(/\b(\d+)(?:st|nd|rd|th)\b/); // find ordinal matches s = ((ords && ords.length === 2) ? s.replace(ords[0], ords[1]) : s); return s; }, grammarParser: function (s) { var r = null; try { r = $D.Grammar.start.call({}, s.replace(/^\s*(\S*(\s+\S+)*)\s*$/, "$1")); } catch (e) { return null; } return ((r[1].length === 0) ? r[0] : null); }, nativeFallback: function(s) { var t; try { // ok we haven't parsed it, last ditch attempt with the built-in parser. t = Date._parse(s); return (t || t === 0) ? new Date(t) : null; } catch (e) { return null; } } }; function parse (s) { var d; if (!s) { return null; } if (s instanceof Date) { return s.clone(); } if (s.length >= 4 && s.charAt(0) !== "0" && s.charAt(0) !== "+"&& s.charAt(0) !== "-") { // ie: 2004 will pass, 0800 won't. // Start with specific formats d = $D.Parsing.ISO.parse(s) || $D.Parsing.Numeric.parse(s); } if (d instanceof Date && !isNaN(d.getTime())) { return d; } else { // find ordinal dates (1st, 3rd, 8th, etc and remove them as they cause parsing issues) s = $D.Parsing.Normalizer.parse(parseUtils.removeOrds(s)); d = parseUtils.grammarParser(s); if (d !== null) { return d; } else { return parseUtils.nativeFallback(s); } } } if (!$D._parse) { $D._parse = $D.parse; } $D.parse = parse; Date.getParseFunction = function (fx) { var fns = Date.Grammar.allformats(fx); return function (s) { var r = null; for (var i = 0; i < fns.length; i++) { try { r = fns[i].call({}, s); } catch (e) { continue; } if (r[1].length === 0) { return r[0]; } } return null; }; }; /** * Converts the specified string value into its JavaScript Date equivalent using the specified format {String} or formats {Array} and the CultureInfo specific format information. * The format of the string value must match one of the supplied formats exactly. * * Example

	// 15-Oct-2004
	var d1 = Date.parseExact("10/15/2004", "M/d/yyyy");

	// 15-Oct-2004
	var d1 = Date.parse("15-Oct-2004", "M-ddd-yyyy");

	// 15-Oct-2004
	var d1 = Date.parse("2004.10.15", "yyyy.MM.dd");

	// Multiple formats
	var d1 = Date.parseExact("10/15/2004", ["M/d/yyyy", "MMMM d, yyyy"]);
	
* * @param {String} The string value to convert into a Date object [Required]. * @param {Object} The expected format {String} or an array of expected formats {Array} of the date string [Required]. * @return {Date} A Date object or null if the string cannot be converted into a Date. */ $D.parseExact = function (s, fx) { return $D.getParseFunction(fx)(s); }; }()); (function () { var $D = Date, $P = $D.prototype, // $C = $D.CultureInfo, // not used atm p = function (s, l) { if (!l) { l = 2; } return ("000" + s).slice(l * -1); }; /** * Converts a PHP format string to Java/.NET format string. * A PHP format string can be used with ._format or .format. * A Java/.NET format string can be used with .toString(). * The .parseExact function will only accept a Java/.NET format string * * Example * var f1 = "%m/%d/%y" * var f2 = Date.normalizeFormat(f1); // "MM/dd/yy" * * new Date().format(f1); // "04/13/08" * new Date()._format(f1); // "04/13/08" * new Date().toString(f2); // "04/13/08" * * var date = Date.parseExact("04/13/08", f2); // Sun Apr 13 2008 * * @param {String} A PHP format string consisting of one or more format spcifiers. * @return {String} The PHP format converted to a Java/.NET format string. */ var normalizerSubstitutions = { "d" : "dd", "%d": "dd", "D" : "ddd", "%a": "ddd", "j" : "dddd", "l" : "dddd", "%A": "dddd", "S" : "S", "F" : "MMMM", "%B": "MMMM", "m" : "MM", "%m": "MM", "M" : "MMM", "%b": "MMM", "%h": "MMM", "n" : "M", "Y" : "yyyy", "%Y": "yyyy", "y" : "yy", "%y": "yy", "g" : "h", "%I": "h", "G" : "H", "h" : "hh", "H" : "HH", "%H": "HH", "i" : "mm", "%M": "mm", "s" : "ss", "%S": "ss", "%r": "hh:mm tt", "%R": "H:mm", "%T": "H:mm:ss", "%X": "t", "%x": "d", "%e": "d", "%D": "MM/dd/yy", "%n": "\\n", "%t": "\\t", "e" : "z", "T" : "z", "%z": "z", "%Z": "z", "Z" : "ZZ", "N" : "u", "w" : "u", "%w": "u", "W" : "W", "%V": "W" }; var normalizer = { substitutes: function (m) { return normalizerSubstitutions[m]; }, interpreted: function (m, x) { var y; switch (m) { case "%u": return x.getDay() + 1; case "z": return x.getOrdinalNumber(); case "%j": return p(x.getOrdinalNumber(), 3); case "%U": var d1 = x.clone().set({month: 0, day: 1}).addDays(-1).moveToDayOfWeek(0), d2 = x.clone().addDays(1).moveToDayOfWeek(0, -1); return (d2 < d1) ? "00" : p((d2.getOrdinalNumber() - d1.getOrdinalNumber()) / 7 + 1); case "%W": return p(x.getWeek()); case "t": return $D.getDaysInMonth(x.getFullYear(), x.getMonth()); case "o": case "%G": return x.setWeek(x.getISOWeek()).toString("yyyy"); case "%g": return x._format("%G").slice(-2); case "a": case "%p": return t("tt").toLowerCase(); case "A": return t("tt").toUpperCase(); case "u": return p(x.getMilliseconds(), 3); case "I": return (x.isDaylightSavingTime()) ? 1 : 0; case "O": return x.getUTCOffset(); case "P": y = x.getUTCOffset(); return y.substring(0, y.length - 2) + ":" + y.substring(y.length - 2); case "B": var now = new Date(); return Math.floor(((now.getHours() * 3600) + (now.getMinutes() * 60) + now.getSeconds() + (now.getTimezoneOffset() + 60) * 60) / 86.4); case "c": return x.toISOString().replace(/\"/g, ""); case "U": return $D.strtotime("now"); case "%c": return t("d") + " " + t("t"); case "%C": return Math.floor(x.getFullYear() / 100 + 1); } }, shouldOverrideDefaults: function (m) { switch (m) { case "%e": return true; default: return false; } }, parse: function (m, context) { var formatString, c = context || new Date(); formatString = normalizer.substitutes(m); if (formatString) { return formatString; } formatString = normalizer.interpreted(m, c); if (formatString) { return formatString; } else { return m; } } }; $D.normalizeFormat = function (format, context) { return format.replace(/(%|\\)?.|%%/g, function(t){ return normalizer.parse(t, context); }); }; /** * Format a local Unix timestamp according to locale settings * * Example: * Date.strftime("%m/%d/%y", new Date()); // "04/13/08" * Date.strftime("c", "2008-04-13T17:52:03Z"); // "04/13/08" * * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @param {Number|String} The number representing the number of seconds that have elapsed since January 1, 1970 (local time). * @return {String} A string representation of the current Date object. */ $D.strftime = function (format, time) { var d = Date.parse(time); return d._format(format); }; /** * Parse any textual datetime description into a Unix timestamp. * A Unix timestamp is the number of seconds that have elapsed since January 1, 1970 (midnight UTC/GMT). * * Example: * Date.strtotime("04/13/08"); // 1208044800 * Date.strtotime("1970-01-01T00:00:00Z"); // 0 * * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @param {Object} A string or date object. * @return {String} A string representation of the current Date object. */ $D.strtotime = function (time) { var d = $D.parse(time); return Math.round($D.UTC(d.getUTCFullYear(), d.getUTCMonth(), d.getUTCDate(), d.getUTCHours(), d.getUTCMinutes(), d.getUTCSeconds(), d.getUTCMilliseconds()) / 1000); }; /** * Converts the value of the current Date object to its equivalent string representation using a PHP/Unix style of date format specifiers. * Format Specifiers * Format Description Example * ------ --------------------------------------------------------------------------- ----------------------- * %a abbreviated weekday name according to the current localed "Mon" through "Sun" * %A full weekday name according to the current localed "Sunday" through "Saturday" * %b abbreviated month name according to the current localed "Jan" through "Dec" * %B full month name according to the current locale "January" through "December" * %c preferred date and time representation for the current locale "4/13/2008 12:33 PM" * %C century number (the year divided by 100 and truncated to an integer) "00" to "99" * %d day of the month as a decimal number "01" to "31" * %D same as %m/%d/%y "04/13/08" * %e day of the month as a decimal number, a single digit is preceded by a space "1" to "31" * %g like %G, but without the century "08" * %G The 4-digit year corresponding to the ISO week number (see %V). "2008" * This has the same format and value as %Y, except that if the ISO week number * belongs to the previous or next year, that year is used instead. * %h same as %b "Jan" through "Dec" * %H hour as a decimal number using a 24-hour clock. "00" to "23" * %I hour as a decimal number using a 12-hour clock. "01" to "12" * %j day of the year as a decimal number. "001" to "366" * %m month as a decimal number. "01" to "12" * %M minute as a decimal number. "00" to "59" * %n newline character "\n" * %p either "am" or "pm" according to the given time value, or the "am" or "pm" * corresponding strings for the current locale. * %r time in a.m. and p.m. notation "8:44 PM" * %R time in 24 hour notation "20:44" * %S second as a decimal number "00" to "59" * %t tab character "\t" * %T current time, equal to %H:%M:%S "12:49:11" * %u weekday as a decimal number ["1", "7"], with "1" representing Monday "1" to "7" * %U week number of the current year as a decimal number, starting with the "0" to ("52" or "53") * first Sunday as the first day of the first week * %V The ISO 8601:1988 week number of the current year as a decimal number, "00" to ("52" or "53") * range 01 to 53, where week 1 is the first week that has at least 4 days * in the current year, and with Monday as the first day of the week. * (Use %G or %g for the year component that corresponds to the week number * for the specified timestamp.) * %W week number of the current year as a decimal number, starting with the "00" to ("52" or "53") * first Monday as the first day of the first week * %w day of the week as a decimal, Sunday being "0" "0" to "6" * %x preferred date representation for the current locale without the time "4/13/2008" * %X preferred time representation for the current locale without the date "12:53:05" * %y year as a decimal number without a century "00" "99" * %Y year as a decimal number including the century "2008" * %Z time zone or name or abbreviation "UTC", "EST", "PST" * %z same as %Z * %% a literal "%" characters "%" * d Day of the month, 2 digits with leading zeros "01" to "31" * D A textual representation of a day, three letters "Mon" through "Sun" * j Day of the month without leading zeros "1" to "31" * l A full textual representation of the day of the week (lowercase "L") "Sunday" through "Saturday" * N ISO-8601 numeric representation of the day of the week (added in PHP 5.1.0) "1" (for Monday) through "7" (for Sunday) * S English ordinal suffix for the day of the month, 2 characters "st", "nd", "rd" or "th". Works well with j * w Numeric representation of the day of the week "0" (for Sunday) through "6" (for Saturday) * z The day of the year (starting from "0") "0" through "365" * W ISO-8601 week number of year, weeks starting on Monday "00" to ("52" or "53") * F A full textual representation of a month, such as January or March "January" through "December" * m Numeric representation of a month, with leading zeros "01" through "12" * M A short textual representation of a month, three letters "Jan" through "Dec" * n Numeric representation of a month, without leading zeros "1" through "12" * t Number of days in the given month "28" through "31" * L Whether it's a leap year "1" if it is a leap year, "0" otherwise * o ISO-8601 year number. This has the same value as Y, except that if the "2008" * ISO week number (W) belongs to the previous or next year, that year * is used instead. * Y A full numeric representation of a year, 4 digits "2008" * y A two digit representation of a year "08" * a Lowercase Ante meridiem and Post meridiem "am" or "pm" * A Uppercase Ante meridiem and Post meridiem "AM" or "PM" * B Swatch Internet time "000" through "999" * g 12-hour format of an hour without leading zeros "1" through "12" * G 24-hour format of an hour without leading zeros "0" through "23" * h 12-hour format of an hour with leading zeros "01" through "12" * H 24-hour format of an hour with leading zeros "00" through "23" * i Minutes with leading zeros "00" to "59" * s Seconds, with leading zeros "00" through "59" * u Milliseconds "54321" * e Timezone identifier "UTC", "EST", "PST" * I Whether or not the date is in daylight saving time (uppercase i) "1" if Daylight Saving Time, "0" otherwise * O Difference to Greenwich time (GMT) in hours "+0200", "-0600" * P Difference to Greenwich time (GMT) with colon between hours and minutes "+02:00", "-06:00" * T Timezone abbreviation "UTC", "EST", "PST" * Z Timezone offset in seconds. The offset for timezones west of UTC is "-43200" through "50400" * always negative, and for those east of UTC is always positive. * c ISO 8601 date "2004-02-12T15:19:21+00:00" * r RFC 2822 formatted date "Thu, 21 Dec 2000 16:01:07 +0200" * U Seconds since the Unix Epoch (January 1 1970 00:00:00 GMT) "0" * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @return {String} A string representation of the current Date object. */ var formatReplace = function (context) { return function (m) { var formatString, override = false; if (m.charAt(0) === "\\" || m.substring(0, 2) === "%%") { return m.replace("\\", "").replace("%%", "%"); } override = normalizer.shouldOverrideDefaults(m); formatString = $D.normalizeFormat(m, context); if (formatString) { return context.toString(formatString, override); } }; }; $P._format = function (format) { var formatter = formatReplace(this); if (!format) { return this._toString(); } else { return format.replace(/(%|\\)?.|%%/g, formatter); } }; if (!$P.format) { $P.format = $P._format; } }()); (function () { "use strict"; var gFn = function (attr) { return function () { return this[attr]; }; }; var sFn = function (attr) { return function (val) { this[attr] = val; return this; }; }; var attrs = ["years", "months", "days", "hours", "minutes", "seconds", "milliseconds"]; var addSetFuncs = function (context, attrs) { for (var i = 0; i < attrs.length ; i++) { var $a = attrs[i], $b = $a.slice(0, 1).toUpperCase() + $a.slice(1); context.prototype[$a] = 0; context.prototype["get" + $b] = gFn($a); context.prototype["set" + $b] = sFn($a); } }; /** * new TimeSpan(milliseconds); * new TimeSpan(days, hours, minutes, seconds); * new TimeSpan(days, hours, minutes, seconds, milliseconds); */ var TimeSpan = function (days, hours, minutes, seconds, milliseconds) { if (arguments.length === 1 && typeof days === "number") { var orient = (days < 0) ? -1 : +1; var millsLeft = Math.abs(days); this.setDays(Math.floor(millsLeft / 86400000) * orient); millsLeft = millsLeft % 86400000; this.setHours(Math.floor(millsLeft / 3600000) * orient); millsLeft = millsLeft % 3600000; this.setMinutes(Math.floor(millsLeft / 60000) * orient); millsLeft = millsLeft % 60000; this.setSeconds(Math.floor(millsLeft / 1000) * orient); millsLeft = millsLeft % 1000; this.setMilliseconds(millsLeft * orient); } else { this.set(days, hours, minutes, seconds, milliseconds); } this.getTotalMilliseconds = function () { return (this.getDays() * 86400000) + (this.getHours() * 3600000) + (this.getMinutes() * 60000) + (this.getSeconds() * 1000); }; this.compareTo = function (time) { var t1 = new Date(1970, 1, 1, this.getHours(), this.getMinutes(), this.getSeconds()), t2; if (time === null) { t2 = new Date(1970, 1, 1, 0, 0, 0); } else { t2 = new Date(1970, 1, 1, time.getHours(), time.getMinutes(), time.getSeconds()); } return (t1 < t2) ? -1 : (t1 > t2) ? 1 : 0; }; this.equals = function (time) { return (this.compareTo(time) === 0); }; this.add = function (time) { return (time === null) ? this : this.addSeconds(time.getTotalMilliseconds() / 1000); }; this.subtract = function (time) { return (time === null) ? this : this.addSeconds(-time.getTotalMilliseconds() / 1000); }; this.addDays = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 86400000)); }; this.addHours = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 3600000)); }; this.addMinutes = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 60000)); }; this.addSeconds = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 1000)); }; this.addMilliseconds = function (n) { return new TimeSpan(this.getTotalMilliseconds() + n); }; this.get12HourHour = function () { return (this.getHours() > 12) ? this.getHours() - 12 : (this.getHours() === 0) ? 12 : this.getHours(); }; this.getDesignator = function () { return (this.getHours() < 12) ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator; }; this.toString = function (format) { this._toString = function () { if (this.getDays() !== null && this.getDays() > 0) { return this.getDays() + "." + this.getHours() + ":" + this.p(this.getMinutes()) + ":" + this.p(this.getSeconds()); } else { return this.getHours() + ":" + this.p(this.getMinutes()) + ":" + this.p(this.getSeconds()); } }; this.p = function (s) { return (s.toString().length < 2) ? "0" + s : s; }; var me = this; return format ? format.replace(/dd?|HH?|hh?|mm?|ss?|tt?/g, function (format) { switch (format) { case "d": return me.getDays(); case "dd": return me.p(me.getDays()); case "H": return me.getHours(); case "HH": return me.p(me.getHours()); case "h": return me.get12HourHour(); case "hh": return me.p(me.get12HourHour()); case "m": return me.getMinutes(); case "mm": return me.p(me.getMinutes()); case "s": return me.getSeconds(); case "ss": return me.p(me.getSeconds()); case "t": return ((me.getHours() < 12) ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator).substring(0, 1); case "tt": return (me.getHours() < 12) ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator; } } ) : this._toString(); }; return this; }; addSetFuncs(TimeSpan, attrs.slice(2)); TimeSpan.prototype.set = function (days, hours, minutes, seconds, milliseconds){ this.setDays(days || this.getDays()); this.setHours(hours || this.getHours()); this.setMinutes(minutes || this.getMinutes()); this.setSeconds(seconds || this.getSeconds()); this.setMilliseconds(milliseconds || this.getMilliseconds()); }; /** * Gets the time of day for this date instances. * @return {TimeSpan} TimeSpan */ Date.prototype.getTimeOfDay = function () { return new TimeSpan(0, this.getHours(), this.getMinutes(), this.getSeconds(), this.getMilliseconds()); }; Date.TimeSpan = TimeSpan; if (typeof window !== "undefined" ) { // keeping API compatible for v1.x window.TimeSpan = TimeSpan; } }()); (function () { "use strict"; var attrs = ["years", "months", "days", "hours", "minutes", "seconds", "milliseconds"]; var gFn = function (attr) { return function () { return this[attr]; }; }; var sFn = function (attr) { return function (val) { this[attr] = val; return this; }; }; var addSetFuncs = function (context, attrs) { for (var i = 0; i < attrs.length ; i++) { var $a = attrs[i], $b = $a.slice(0, 1).toUpperCase() + $a.slice(1); context.prototype[$a] = 0; context.prototype["get" + $b] = gFn($a); context.prototype["set" + $b] = sFn($a); } }; var setMonthsAndYears = function (orient, d1, d2, context) { function inc() { d1.addMonths(-orient); context.months++; if (context.months === 12) { context.years++; context.months = 0; } } if (orient === +1) { while (d1 > d2) { inc(); } } else { while (d1 < d2) { inc(); } } context.months--; context.months *= orient; context.years *= orient; }; var adjustForDST = function(orient, startDate, endDate) { var hasDSTMismatch = (false === (startDate.isDaylightSavingTime() === endDate.isDaylightSavingTime())); if (hasDSTMismatch && orient === 1) { startDate.addHours(-1); } else if (hasDSTMismatch) { startDate.addHours(1); } }; /** * TimePeriod(startDate, endDate); * TimePeriod(years, months, days, hours, minutes, seconds, milliseconds); */ var TimePeriod = function (years, months, days, hours, minutes, seconds, milliseconds) { if (arguments.length === 7) { this.set(years, months, days, hours, minutes, seconds, milliseconds); } else if (arguments.length === 2 && arguments[0] instanceof Date && arguments[1] instanceof Date) { var startDate = arguments[0].clone(); var endDate = arguments[1].clone(); var orient = (startDate > endDate) ? +1 : -1; this.dates = { start: arguments[0].clone(), end: arguments[1].clone() }; setMonthsAndYears(orient, startDate, endDate, this); adjustForDST(orient, startDate, endDate); // // TODO - adjust for DST var diff = endDate - startDate; if (diff !== 0) { var ts = new TimeSpan(diff); this.set(this.years, this.months, ts.getDays(), ts.getHours(), ts.getMinutes(), ts.getSeconds(), ts.getMilliseconds()); } } return this; }; // create all the set functions. addSetFuncs(TimePeriod, attrs); TimePeriod.prototype.set = function (years, months, days, hours, minutes, seconds, milliseconds){ this.setYears(years || this.getYears()); this.setMonths(months || this.getMonths()); this.setDays(days || this.getDays()); this.setHours(hours || this.getHours()); this.setMinutes(minutes || this.getMinutes()); this.setSeconds(seconds || this.getSeconds()); this.setMilliseconds(milliseconds || this.getMilliseconds()); }; Date.TimePeriod = TimePeriod; if (typeof window !== "undefined") { // keeping API compatible for v1.x window.TimePeriod = TimePeriod; } }()); ================================================ FILE: build/date-quz-PE.js ================================================ /** * @overview datejs * @version 1.0.0-rc3 * @author Gregory Wild-Smith * @copyright 2015 Gregory Wild-Smith * @license MIT * @homepage https://github.com/abritinthebay/datejs */ /* * DateJS Culture String File * Country Code: quz-PE * Name: Quechua (Peru) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["quz-PE"] = { "name": "quz-PE", "englishName": "Quechua (Peru)", "nativeName": "runasimi (Peru Suyu)", "Sunday": "intichaw", "Monday": "killachaw", "Tuesday": "atipachaw", "Wednesday": "quyllurchaw", "Thursday": "Ch' askachaw", "Friday": "Illapachaw", "Saturday": "k'uychichaw", "Sun": "int", "Mon": "kil", "Tue": "ati", "Wed": "quy", "Thu": "Ch’", "Fri": "Ill", "Sat": "k'u", "Su": "int", "Mo": "kil", "Tu": "ati", "We": "quy", "Th": "Ch’", "Fr": "Ill", "Sa": "k'u", "S_Sun_Initial": "i", "M_Mon_Initial": "k", "T_Tue_Initial": "a", "W_Wed_Initial": "q", "T_Thu_Initial": "C", "F_Fri_Initial": "I", "S_Sat_Initial": "k", "January": "Qulla puquy", "February": "Hatun puquy", "March": "Pauqar waray", "April": "ayriwa", "May": "Aymuray", "June": "Inti raymi", "July": "Anta Sitwa", "August": "Qhapaq Sitwa", "September": "Uma raymi", "October": "Kantaray", "November": "Ayamarq'a", "December": "Kapaq Raymi", "Jan_Abbr": "Qul", "Feb_Abbr": "Hat", "Mar_Abbr": "Pau", "Apr_Abbr": "ayr", "May_Abbr": "Aym", "Jun_Abbr": "Int", "Jul_Abbr": "Ant", "Aug_Abbr": "Qha", "Sep_Abbr": "Uma", "Oct_Abbr": "Kan", "Nov_Abbr": "Aya", "Dec_Abbr": "Kap", "AM": "a.m.", "PM": "p.m.", "firstDayOfWeek": 0, "twoDigitYearMax": 2029, "mdy": "dmy", "M/d/yyyy": "dd/MM/yyyy", "dddd, MMMM dd, yyyy": "dddd, dd' de 'MMMM' de 'yyyy", "h:mm tt": "hh:mm:ss tt", "h:mm:ss tt": "hh:mm:ss tt", "dddd, MMMM dd, yyyy h:mm:ss tt": "dddd, dd' de 'MMMM' de 'yyyy hh:mm:ss tt", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "MMMM dd", "MMMM, yyyy": "MMMM' de 'yyyy", "/jan(uary)?/": "qul(la puquy)?", "/feb(ruary)?/": "hat(un puquy)?", "/mar(ch)?/": "pau(qar waray)?", "/apr(il)?/": "ayr(iwa)?", "/may/": "aym(uray)?", "/jun(e)?/": "int(i raymi)?", "/jul(y)?/": "ant(a sitwa)?", "/aug(ust)?/": "qha(paq sitwa)?", "/sep(t(ember)?)?/": "uma( raymi)?", "/oct(ober)?/": "kan(taray)?", "/nov(ember)?/": "aya(marq'a)?", "/dec(ember)?/": "kap(aq raymi)?", "/^su(n(day)?)?/": "^intichaw", "/^mo(n(day)?)?/": "^killachaw", "/^tu(e(s(day)?)?)?/": "^atipachaw", "/^we(d(nesday)?)?/": "^quyllurchaw", "/^th(u(r(s(day)?)?)?)?/": "^ch' askachaw", "/^fr(i(day)?)?/": "^illapachaw", "/^sa(t(urday)?)?/": "^k'uychichaw", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "quz-PE"; /** * @overview datejs * @version 1.0.0-rc3 * @author Gregory Wild-Smith * @copyright 2015 Gregory Wild-Smith * @license MIT * @homepage https://github.com/abritinthebay/datejs */(function () { var $D = Date; var lang = Date.CultureStrings ? Date.CultureStrings.lang : null; var loggedKeys = {}; // for debug purposes. var getText = { getFromKey: function (key, countryCode) { var output; if (Date.CultureStrings && Date.CultureStrings[countryCode] && Date.CultureStrings[countryCode][key]) { output = Date.CultureStrings[countryCode][key]; } else { output = getText.buildFromDefault(key); } if (key.charAt(0) === "/") { // Assume it's a regex output = getText.buildFromRegex(key, countryCode); } return output; }, getFromObjectValues: function (obj, countryCode) { var key, output = {}; for(key in obj) { if (obj.hasOwnProperty(key)) { output[key] = getText.getFromKey(obj[key], countryCode); } } return output; }, getFromObjectKeys: function (obj, countryCode) { var key, output = {}; for(key in obj) { if (obj.hasOwnProperty(key)) { output[getText.getFromKey(key, countryCode)] = obj[key]; } } return output; }, getFromArray: function (arr, countryCode) { var output = []; for (var i=0; i < arr.length; i++){ if (i in arr) { output[i] = getText.getFromKey(arr[i], countryCode); } } return output; }, buildFromDefault: function (key) { var output, length, split, last; switch(key) { case "name": output = "en-US"; break; case "englishName": output = "English (United States)"; break; case "nativeName": output = "English (United States)"; break; case "twoDigitYearMax": output = 2049; break; case "firstDayOfWeek": output = 0; break; default: output = key; split = key.split("_"); length = split.length; if (length > 1 && key.charAt(0) !== "/") { // if the key isn't a regex and it has a split. last = split[(length - 1)].toLowerCase(); if (last === "initial" || last === "abbr") { output = split[0]; } } break; } return output; }, buildFromRegex: function (key, countryCode) { var output; if (Date.CultureStrings && Date.CultureStrings[countryCode] && Date.CultureStrings[countryCode][key]) { output = new RegExp(Date.CultureStrings[countryCode][key], "i"); } else { output = new RegExp(key.replace(new RegExp("/", "g"),""), "i"); } return output; } }; var shallowMerge = function (obj1, obj2) { for (var attrname in obj2) { if (obj2.hasOwnProperty(attrname)) { obj1[attrname] = obj2[attrname]; } } }; var __ = function (key, language) { var countryCode = (language) ? language : lang; loggedKeys[key] = key; if (typeof key === "object") { if (key instanceof Array) { return getText.getFromArray(key, countryCode); } else { return getText.getFromObjectKeys(key, countryCode); } } else { return getText.getFromKey(key, countryCode); } }; var loadI18nScript = function (code) { // paatterned after jQuery's getScript. var url = Date.Config.i18n + code + ".js"; var head = document.getElementsByTagName("head")[0] || document.documentElement; var script = document.createElement("script"); script.src = url; var completed = false; var events = { done: function (){} // placeholder function }; // Attach handlers for all browsers script.onload = script.onreadystatechange = function() { if ( !completed && (!this.readyState || this.readyState === "loaded" || this.readyState === "complete") ) { events.done(); head.removeChild(script); } }; setTimeout(function() { head.insertBefore(script, head.firstChild); }, 0); // allows return to execute first return { done: function (cb) { events.done = function() { if (cb) { setTimeout(cb,0); } }; } }; }; var buildInfo = { buildFromMethodHash: function (obj) { var key; for(key in obj) { if (obj.hasOwnProperty(key)) { obj[key] = buildInfo[obj[key]](); } } return obj; }, timeZoneDST: function () { var DST = { "CHADT": "+1345", "NZDT": "+1300", "AEDT": "+1100", "ACDT": "+1030", "AZST": "+0500", "IRDT": "+0430", "EEST": "+0300", "CEST": "+0200", "BST": "+0100", "PMDT": "-0200", "ADT": "-0300", "NDT": "-0230", "EDT": "-0400", "CDT": "-0500", "MDT": "-0600", "PDT": "-0700", "AKDT": "-0800", "HADT": "-0900" }; return __(DST); }, timeZoneStandard: function () { var standard = { "LINT": "+1400", "TOT": "+1300", "CHAST": "+1245", "NZST": "+1200", "NFT": "+1130", "SBT": "+1100", "AEST": "+1000", "ACST": "+0930", "JST": "+0900", "CWST": "+0845", "CT": "+0800", "ICT": "+0700", "MMT": "+0630", "BST": "+0600", "NPT": "+0545", "IST": "+0530", "PKT": "+0500", "AFT": "+0430", "MSK": "+0400", "IRST": "+0330", "FET": "+0300", "EET": "+0200", "CET": "+0100", "GMT": "+0000", "UTC": "+0000", "CVT": "-0100", "GST": "-0200", "BRT": "-0300", "NST": "-0330", "AST": "-0400", "EST": "-0500", "CST": "-0600", "MST": "-0700", "PST": "-0800", "AKST": "-0900", "MIT": "-0930", "HST": "-1000", "SST": "-1100", "BIT": "-1200" }; return __(standard); }, timeZones: function (data) { var zone; data.timezones = []; for (zone in data.abbreviatedTimeZoneStandard) { if (data.abbreviatedTimeZoneStandard.hasOwnProperty(zone)) { data.timezones.push({ name: zone, offset: data.abbreviatedTimeZoneStandard[zone]}); } } for (zone in data.abbreviatedTimeZoneDST) { if (data.abbreviatedTimeZoneDST.hasOwnProperty(zone)) { data.timezones.push({ name: zone, offset: data.abbreviatedTimeZoneDST[zone], dst: true}); } } return data.timezones; }, days: function () { return __(["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"]); }, dayAbbr: function () { return __(["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"]); }, dayShortNames: function () { return __(["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"]); }, dayFirstLetters: function () { return __(["S_Sun_Initial", "M_Mon_Initial", "T_Tues_Initial", "W_Wed_Initial", "T_Thu_Initial", "F_Fri_Initial", "S_Sat_Initial"]); }, months: function () { return __(["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"]); }, monthAbbr: function () { return __(["Jan_Abbr", "Feb_Abbr", "Mar_Abbr", "Apr_Abbr", "May_Abbr", "Jun_Abbr", "Jul_Abbr", "Aug_Abbr", "Sep_Abbr", "Oct_Abbr", "Nov_Abbr", "Dec_Abbr"]); }, formatPatterns: function () { return getText.getFromObjectValues({ shortDate: "M/d/yyyy", longDate: "dddd, MMMM dd, yyyy", shortTime: "h:mm tt", longTime: "h:mm:ss tt", fullDateTime: "dddd, MMMM dd, yyyy h:mm:ss tt", sortableDateTime: "yyyy-MM-ddTHH:mm:ss", universalSortableDateTime: "yyyy-MM-dd HH:mm:ssZ", rfc1123: "ddd, dd MMM yyyy HH:mm:ss", monthDay: "MMMM dd", yearMonth: "MMMM, yyyy" }, Date.i18n.currentLanguage()); }, regex: function () { return getText.getFromObjectValues({ inTheMorning: "/( in the )(morn(ing)?)\\b/", thisMorning: "/(this )(morn(ing)?)\\b/", amThisMorning: "/(\b\\d(am)? )(this )(morn(ing)?)/", inTheEvening: "/( in the )(even(ing)?)\\b/", thisEvening: "/(this )(even(ing)?)\\b/", pmThisEvening: "/(\b\\d(pm)? )(this )(even(ing)?)/", jan: "/jan(uary)?/", feb: "/feb(ruary)?/", mar: "/mar(ch)?/", apr: "/apr(il)?/", may: "/may/", jun: "/jun(e)?/", jul: "/jul(y)?/", aug: "/aug(ust)?/", sep: "/sep(t(ember)?)?/", oct: "/oct(ober)?/", nov: "/nov(ember)?/", dec: "/dec(ember)?/", sun: "/^su(n(day)?)?/", mon: "/^mo(n(day)?)?/", tue: "/^tu(e(s(day)?)?)?/", wed: "/^we(d(nesday)?)?/", thu: "/^th(u(r(s(day)?)?)?)?/", fri: "/fr(i(day)?)?/", sat: "/^sa(t(urday)?)?/", future: "/^next/", past: "/^last|past|prev(ious)?/", add: "/^(\\+|aft(er)?|from|hence)/", subtract: "/^(\\-|bef(ore)?|ago)/", yesterday: "/^yes(terday)?/", today: "/^t(od(ay)?)?/", tomorrow: "/^tom(orrow)?/", now: "/^n(ow)?/", millisecond: "/^ms|milli(second)?s?/", second: "/^sec(ond)?s?/", minute: "/^mn|min(ute)?s?/", hour: "/^h(our)?s?/", week: "/^w(eek)?s?/", month: "/^m(onth)?s?/", day: "/^d(ay)?s?/", year: "/^y(ear)?s?/", shortMeridian: "/^(a|p)/", longMeridian: "/^(a\\.?m?\\.?|p\\.?m?\\.?)/", timezone: "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/", ordinalSuffix: "/^\\s*(st|nd|rd|th)/", timeContext: "/^\\s*(\\:|a(?!u|p)|p)/" }, Date.i18n.currentLanguage()); } }; var CultureInfo = function () { var info = getText.getFromObjectValues({ name: "name", englishName: "englishName", nativeName: "nativeName", amDesignator: "AM", pmDesignator: "PM", firstDayOfWeek: "firstDayOfWeek", twoDigitYearMax: "twoDigitYearMax", dateElementOrder: "mdy" }, Date.i18n.currentLanguage()); var constructedInfo = buildInfo.buildFromMethodHash({ dayNames: "days", abbreviatedDayNames: "dayAbbr", shortestDayNames: "dayShortNames", firstLetterDayNames: "dayFirstLetters", monthNames: "months", abbreviatedMonthNames: "monthAbbr", formatPatterns: "formatPatterns", regexPatterns: "regex", abbreviatedTimeZoneDST: "timeZoneDST", abbreviatedTimeZoneStandard: "timeZoneStandard" }); shallowMerge(info, constructedInfo); buildInfo.timeZones(info); return info; }; $D.i18n = { __: function (key, lang) { return __(key, lang); }, currentLanguage: function () { return lang || "en-US"; }, setLanguage: function (code, force, cb) { var async = false; if (force || code === "en-US" || (!!Date.CultureStrings && !!Date.CultureStrings[code])) { lang = code; Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings.lang = code; Date.CultureInfo = new CultureInfo(); } else { if (!(!!Date.CultureStrings && !!Date.CultureStrings[code])) { if (typeof exports !== "undefined" && this.exports !== exports) { // we're in a Node enviroment, load it using require try { require("../i18n/" + code + ".js"); lang = code; Date.CultureStrings.lang = code; Date.CultureInfo = new CultureInfo(); } catch (e) { // var str = "The language for '" + code + "' could not be loaded by Node. It likely does not exist."; throw new Error("The DateJS IETF language tag '" + code + "' could not be loaded by Node. It likely does not exist."); } } else if (Date.Config && Date.Config.i18n) { // we know the location of the files, so lets load them async = true; loadI18nScript(code).done(function(){ lang = code; Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings.lang = code; Date.CultureInfo = new CultureInfo(); $D.Parsing.Normalizer.buildReplaceData(); // because this is async if ($D.Grammar) { $D.Grammar.buildGrammarFormats(); // so we can parse those strings... } if (cb) { setTimeout(cb,0); } }); } else { Date.console.error("The DateJS IETF language tag '" + code + "' is not available and has not been loaded."); return false; } } } $D.Parsing.Normalizer.buildReplaceData(); // rebuild normalizer strings if ($D.Grammar) { $D.Grammar.buildGrammarFormats(); // so we can parse those strings... } if (!async && cb) { setTimeout(cb,0); } }, getLoggedKeys: function () { return loggedKeys; }, updateCultureInfo: function () { Date.CultureInfo = new CultureInfo(); } }; $D.i18n.updateCultureInfo(); // run automatically }()); (function () { var $D = Date, $P = $D.prototype, p = function (s, l) { if (!l) { l = 2; } return ("000" + s).slice(l * -1); }; if (typeof window !== "undefined" && typeof window.console !== "undefined" && typeof window.console.log !== "undefined") { $D.console = console; // used only to raise non-critical errors if available } else { // set mock so we don't give errors. $D.console = { log: function(){}, error: function(){} }; } $D.Config = $D.Config || {}; $D.initOverloads = function() { /** * Overload of Date.now. Allows an alternate call for Date.now where it returns the * current Date as an object rather than just milliseconds since the Unix Epoch. * * Also provides an implementation of now() for browsers (IE<9) that don't have it. * * Backwards compatible so with work with either: * Date.now() [returns ms] * or * Date.now(true) [returns Date] */ if (!$D.now) { $D._now = function now() { return new Date().getTime(); }; } else if (!$D._now) { $D._now = $D.now; } $D.now = function (returnObj) { if (returnObj) { return $D.present(); } else { return $D._now(); } }; if ( !$P.toISOString ) { $P.toISOString = function() { return this.getUTCFullYear() + "-" + p(this.getUTCMonth() + 1) + "-" + p(this.getUTCDate()) + "T" + p(this.getUTCHours()) + ":" + p(this.getUTCMinutes()) + ":" + p(this.getUTCSeconds()) + "." + String( (this.getUTCMilliseconds()/1000).toFixed(3)).slice(2, 5) + "Z"; }; } // private if ( $P._toString === undefined ){ $P._toString = $P.toString; } }; $D.initOverloads(); /** * Gets a date that is set to the current date. The time is set to the start of the day (00:00 or 12:00 AM). * @return {Date} The current date. */ $D.today = function () { return new Date().clearTime(); }; /** * Gets a date that is set to the current date and time (same as new Date, but chainable) * @return {Date} The current date. */ $D.present = function () { return new Date(); }; /** * Compares the first date to the second date and returns an number indication of their relative values. * @param {Date} First Date object to compare [Required]. * @param {Date} Second Date object to compare to [Required]. * @return {Number} -1 = date1 is lessthan date2. 0 = values are equal. 1 = date1 is greaterthan date2. */ $D.compare = function (date1, date2) { if (isNaN(date1) || isNaN(date2)) { throw new Error(date1 + " - " + date2); } else if (date1 instanceof Date && date2 instanceof Date) { return (date1 < date2) ? -1 : (date1 > date2) ? 1 : 0; } else { throw new TypeError(date1 + " - " + date2); } }; /** * Compares the first Date object to the second Date object and returns true if they are equal. * @param {Date} First Date object to compare [Required] * @param {Date} Second Date object to compare to [Required] * @return {Boolean} true if dates are equal. false if they are not equal. */ $D.equals = function (date1, date2) { return (date1.compareTo(date2) === 0); }; /** * Gets the language appropriate day name when given the day number(0-6) * eg - 0 == Sunday * @return {String} The day name */ $D.getDayName = function (n) { return Date.CultureInfo.dayNames[n]; }; /** * Gets the day number (0-6) if given a CultureInfo specific string which is a valid dayName, abbreviatedDayName or shortestDayName (two char). * @param {String} The name of the day (eg. "Monday, "Mon", "tuesday", "tue", "We", "we"). * @return {Number} The day number */ $D.getDayNumberFromName = function (name) { var n = Date.CultureInfo.dayNames, m = Date.CultureInfo.abbreviatedDayNames, o = Date.CultureInfo.shortestDayNames, s = name.toLowerCase(); for (var i = 0; i < n.length; i++) { if (n[i].toLowerCase() === s || m[i].toLowerCase() === s || o[i].toLowerCase() === s) { return i; } } return -1; }; /** * Gets the month number (0-11) if given a Culture Info specific string which is a valid monthName or abbreviatedMonthName. * @param {String} The name of the month (eg. "February, "Feb", "october", "oct"). * @return {Number} The day number */ $D.getMonthNumberFromName = function (name) { var n = Date.CultureInfo.monthNames, m = Date.CultureInfo.abbreviatedMonthNames, s = name.toLowerCase(); for (var i = 0; i < n.length; i++) { if (n[i].toLowerCase() === s || m[i].toLowerCase() === s) { return i; } } return -1; }; /** * Gets the language appropriate month name when given the month number(0-11) * eg - 0 == January * @return {String} The month name */ $D.getMonthName = function (n) { return Date.CultureInfo.monthNames[n]; }; /** * Determines if the current date instance is within a LeapYear. * @param {Number} The year. * @return {Boolean} true if date is within a LeapYear, otherwise false. */ $D.isLeapYear = function (year) { return ((year % 4 === 0 && year % 100 !== 0) || year % 400 === 0); }; /** * Gets the number of days in the month, given a year and month value. Automatically corrects for LeapYear. * @param {Number} The year. * @param {Number} The month (0-11). * @return {Number} The number of days in the month. */ $D.getDaysInMonth = function (year, month) { if (!month && $D.validateMonth(year)) { month = year; year = Date.today().getFullYear(); } return [31, ($D.isLeapYear(year) ? 29 : 28), 31, 30, 31, 30, 31, 31, 30, 31, 30, 31][month]; }; $P.getDaysInMonth = function () { return $D.getDaysInMonth(this.getFullYear(), this.getMonth()); }; $D.getTimezoneAbbreviation = function (offset, dst) { var p, n = (dst || false) ? Date.CultureInfo.abbreviatedTimeZoneDST : Date.CultureInfo.abbreviatedTimeZoneStandard; for (p in n) { if (n.hasOwnProperty(p)) { if (n[p] === offset) { return p; } } } return null; }; $D.getTimezoneOffset = function (name, dst) { var i, a =[], z = Date.CultureInfo.timezones; if (!name) { name = (new Date()).getTimezone();} for (i = 0; i < z.length; i++) { if (z[i].name === name.toUpperCase()) { a.push(i); } } if (!z[a[0]]) { return null; } if (a.length === 1 || !dst) { return z[a[0]].offset; } else { for (i=0; i < a.length; i++) { if (z[a[i]].dst) { return z[a[i]].offset; } } } }; $D.getQuarter = function (d) { d = d || new Date(); // If no date supplied, use today var q = [1,2,3,4]; return q[Math.floor(d.getMonth() / 3)]; // ~~~ is a bitwise op. Faster than Math.floor }; $D.getDaysLeftInQuarter = function (d) { d = d || new Date(); var qEnd = new Date(d); qEnd.setMonth(qEnd.getMonth() + 3 - qEnd.getMonth() % 3, 0); return Math.floor((qEnd - d) / 8.64e7); }; // private var validate = function (n, min, max, name) { name = name ? name : "Object"; if (typeof n === "undefined") { return false; } else if (typeof n !== "number") { throw new TypeError(n + " is not a Number."); } else if (n < min || n > max) { // As failing validation is *not* an exceptional circumstance // lets not throw a RangeError Exception here. // It's semantically correct but it's not sensible. return false; } return true; }; /** * Validates the number is within an acceptable range for milliseconds [0-999]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateMillisecond = function (value) { return validate(value, 0, 999, "millisecond"); }; /** * Validates the number is within an acceptable range for seconds [0-59]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateSecond = function (value) { return validate(value, 0, 59, "second"); }; /** * Validates the number is within an acceptable range for minutes [0-59]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateMinute = function (value) { return validate(value, 0, 59, "minute"); }; /** * Validates the number is within an acceptable range for hours [0-23]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateHour = function (value) { return validate(value, 0, 23, "hour"); }; /** * Validates the number is within an acceptable range for the days in a month [0-MaxDaysInMonth]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateDay = function (value, year, month) { if (year === undefined || year === null || month === undefined || month === null) { return false;} return validate(value, 1, $D.getDaysInMonth(year, month), "day"); }; /** * Validates the number is within an acceptable range for months [0-11]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateWeek = function (value) { return validate(value, 0, 53, "week"); }; /** * Validates the number is within an acceptable range for months [0-11]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateMonth = function (value) { return validate(value, 0, 11, "month"); }; /** * Validates the number is within an acceptable range for years. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateYear = function (value) { /** * Per ECMAScript spec the range of times supported by Date objects is * exactly -100,000,000 days to +100,000,000 days measured relative to * midnight at the beginning of 01 January, 1970 UTC. * This gives a range of 8,640,000,000,000,000 milliseconds to either * side of 01 January, 1970 UTC. * * Earliest possible date: Tue, 20 Apr 271,822 B.C. 00:00:00 UTC * Latest possible date: Sat, 13 Sep 275,760 00:00:00 UTC */ return validate(value, -271822, 275760, "year"); }; $D.validateTimezone = function(value) { var timezones = {"ACDT":1,"ACST":1,"ACT":1,"ADT":1,"AEDT":1,"AEST":1,"AFT":1,"AKDT":1,"AKST":1,"AMST":1,"AMT":1,"ART":1,"AST":1,"AWDT":1,"AWST":1,"AZOST":1,"AZT":1,"BDT":1,"BIOT":1,"BIT":1,"BOT":1,"BRT":1,"BST":1,"BTT":1,"CAT":1,"CCT":1,"CDT":1,"CEDT":1,"CEST":1,"CET":1,"CHADT":1,"CHAST":1,"CHOT":1,"ChST":1,"CHUT":1,"CIST":1,"CIT":1,"CKT":1,"CLST":1,"CLT":1,"COST":1,"COT":1,"CST":1,"CT":1,"CVT":1,"CWST":1,"CXT":1,"DAVT":1,"DDUT":1,"DFT":1,"EASST":1,"EAST":1,"EAT":1,"ECT":1,"EDT":1,"EEDT":1,"EEST":1,"EET":1,"EGST":1,"EGT":1,"EIT":1,"EST":1,"FET":1,"FJT":1,"FKST":1,"FKT":1,"FNT":1,"GALT":1,"GAMT":1,"GET":1,"GFT":1,"GILT":1,"GIT":1,"GMT":1,"GST":1,"GYT":1,"HADT":1,"HAEC":1,"HAST":1,"HKT":1,"HMT":1,"HOVT":1,"HST":1,"ICT":1,"IDT":1,"IOT":1,"IRDT":1,"IRKT":1,"IRST":1,"IST":1,"JST":1,"KGT":1,"KOST":1,"KRAT":1,"KST":1,"LHST":1,"LINT":1,"MAGT":1,"MART":1,"MAWT":1,"MDT":1,"MET":1,"MEST":1,"MHT":1,"MIST":1,"MIT":1,"MMT":1,"MSK":1,"MST":1,"MUT":1,"MVT":1,"MYT":1,"NCT":1,"NDT":1,"NFT":1,"NPT":1,"NST":1,"NT":1,"NUT":1,"NZDT":1,"NZST":1,"OMST":1,"ORAT":1,"PDT":1,"PET":1,"PETT":1,"PGT":1,"PHOT":1,"PHT":1,"PKT":1,"PMDT":1,"PMST":1,"PONT":1,"PST":1,"PYST":1,"PYT":1,"RET":1,"ROTT":1,"SAKT":1,"SAMT":1,"SAST":1,"SBT":1,"SCT":1,"SGT":1,"SLST":1,"SRT":1,"SST":1,"SYOT":1,"TAHT":1,"THA":1,"TFT":1,"TJT":1,"TKT":1,"TLT":1,"TMT":1,"TOT":1,"TVT":1,"UCT":1,"ULAT":1,"UTC":1,"UYST":1,"UYT":1,"UZT":1,"VET":1,"VLAT":1,"VOLT":1,"VOST":1,"VUT":1,"WAKT":1,"WAST":1,"WAT":1,"WEDT":1,"WEST":1,"WET":1,"WST":1,"YAKT":1,"YEKT":1,"Z":1}; return (timezones[value] === 1); }; $D.validateTimezoneOffset= function(value) { // timezones go from +14hrs to -12hrs, the +X hours are negative offsets. return (value > -841 && value < 721); }; }()); (function () { var $D = Date, $P = $D.prototype, p = function (s, l) { if (!l) { l = 2; } return ("000" + s).slice(l * -1); }; var validateConfigObject = function (obj) { var result = {}, self = this, prop, testFunc; testFunc = function (prop, func, value) { if (prop === "day") { var month = (obj.month !== undefined) ? obj.month : self.getMonth(); var year = (obj.year !== undefined) ? obj.year : self.getFullYear(); return $D[func](value, year, month); } else { return $D[func](value); } }; for (prop in obj) { if (Object.prototype.hasOwnProperty.call(obj, prop)) { var func = "validate" + prop.charAt(0).toUpperCase() + prop.slice(1); if ($D[func] && obj[prop] !== null && testFunc(prop, func, obj[prop])) { result[prop] = obj[prop]; } } } return result; }; /** * Resets the time of this Date object to 12:00 AM (00:00), which is the start of the day. * @param {Boolean} .clone() this date instance before clearing Time * @return {Date} this */ $P.clearTime = function () { this.setHours(0); this.setMinutes(0); this.setSeconds(0); this.setMilliseconds(0); return this; }; /** * Resets the time of this Date object to the current time ('now'). * @return {Date} this */ $P.setTimeToNow = function () { var n = new Date(); this.setHours(n.getHours()); this.setMinutes(n.getMinutes()); this.setSeconds(n.getSeconds()); this.setMilliseconds(n.getMilliseconds()); return this; }; /** * Returns a new Date object that is an exact date and time copy of the original instance. * @return {Date} A new Date instance */ $P.clone = function () { return new Date(this.getTime()); }; /** * Compares this instance to a Date object and returns an number indication of their relative values. * @param {Date} Date object to compare [Required] * @return {Number} -1 = this is lessthan date. 0 = values are equal. 1 = this is greaterthan date. */ $P.compareTo = function (date) { return Date.compare(this, date); }; /** * Compares this instance to another Date object and returns true if they are equal. * @param {Date} Date object to compare. If no date to compare, new Date() [now] is used. * @return {Boolean} true if dates are equal. false if they are not equal. */ $P.equals = function (date) { return Date.equals(this, (date !== undefined ? date : new Date())); }; /** * Determines if this instance is between a range of two dates or equal to either the start or end dates. * @param {Date} Start of range [Required] * @param {Date} End of range [Required] * @return {Boolean} true is this is between or equal to the start and end dates, else false */ $P.between = function (start, end) { return this.getTime() >= start.getTime() && this.getTime() <= end.getTime(); }; /** * Determines if this date occurs after the date to compare to. * @param {Date} Date object to compare. If no date to compare, new Date() ("now") is used. * @return {Boolean} true if this date instance is greater than the date to compare to (or "now"), otherwise false. */ $P.isAfter = function (date) { return this.compareTo(date || new Date()) === 1; }; /** * Determines if this date occurs before the date to compare to. * @param {Date} Date object to compare. If no date to compare, new Date() ("now") is used. * @return {Boolean} true if this date instance is less than the date to compare to (or "now"). */ $P.isBefore = function (date) { return (this.compareTo(date || new Date()) === -1); }; /** * Determines if the current Date instance occurs today. * @return {Boolean} true if this date instance is 'today', otherwise false. */ /** * Determines if the current Date instance occurs on the same Date as the supplied 'date'. * If no 'date' to compare to is provided, the current Date instance is compared to 'today'. * @param {date} Date object to compare. If no date to compare, the current Date ("now") is used. * @return {Boolean} true if this Date instance occurs on the same Day as the supplied 'date'. */ $P.isToday = $P.isSameDay = function (date) { return this.clone().clearTime().equals((date || new Date()).clone().clearTime()); }; /** * Adds the specified number of milliseconds to this instance. * @param {Number} The number of milliseconds to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addMilliseconds = function (value) { if (!value) { return this; } this.setTime(this.getTime() + value * 1); return this; }; /** * Adds the specified number of seconds to this instance. * @param {Number} The number of seconds to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addSeconds = function (value) { if (!value) { return this; } return this.addMilliseconds(value * 1000); }; /** * Adds the specified number of seconds to this instance. * @param {Number} The number of seconds to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addMinutes = function (value) { if (!value) { return this; } return this.addMilliseconds(value * 60000); // 60*1000 }; /** * Adds the specified number of hours to this instance. * @param {Number} The number of hours to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addHours = function (value) { if (!value) { return this; } return this.addMilliseconds(value * 3600000); // 60*60*1000 }; /** * Adds the specified number of days to this instance. * @param {Number} The number of days to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addDays = function (value) { if (!value) { return this; } this.setDate(this.getDate() + value * 1); return this; }; /** * Adds the specified number of weekdays (ie - not sat or sun) to this instance. * @param {Number} The number of days to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addWeekdays = function (value) { if (!value) { return this; } var day = this.getDay(); var weeks = (Math.ceil(Math.abs(value)/7)); if (day === 0 || day === 6) { if (value > 0) { this.next().monday(); this.addDays(-1); day = this.getDay(); } } if (value < 0) { while (value < 0) { this.addDays(-1); day = this.getDay(); if (day !== 0 && day !== 6) { value++; } } return this; } else if (value > 5 || (6-day) <= value) { value = value + (weeks * 2); } return this.addDays(value); }; /** * Adds the specified number of weeks to this instance. * @param {Number} The number of weeks to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addWeeks = function (value) { if (!value) { return this; } return this.addDays(value * 7); }; /** * Adds the specified number of months to this instance. * @param {Number} The number of months to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addMonths = function (value) { if (!value) { return this; } var n = this.getDate(); this.setDate(1); this.setMonth(this.getMonth() + value * 1); this.setDate(Math.min(n, $D.getDaysInMonth(this.getFullYear(), this.getMonth()))); return this; }; $P.addQuarters = function (value) { if (!value) { return this; } // note this will take you to the same point in the quarter as you are now. // i.e. - if you are 15 days into the quarter you'll be 15 days into the resulting one. // bonus: this allows adding fractional quarters return this.addMonths(value * 3); }; /** * Adds the specified number of years to this instance. * @param {Number} The number of years to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addYears = function (value) { if (!value) { return this; } return this.addMonths(value * 12); }; /** * Adds (or subtracts) to the value of the years, months, weeks, days, hours, minutes, seconds, milliseconds of the date instance using given configuration object. Positive and Negative values allowed. * Example

	Date.today().add( { days: 1, months: 1 } )

	new Date().add( { years: -1 } )
	
* @param {Object} Configuration object containing attributes (months, days, etc.) * @return {Date} this */ $P.add = function (config) { if (typeof config === "number") { this._orient = config; return this; } var x = config; if (x.day) { // If we should be a different date than today (eg: for 'tomorrow -1d', etc). // Should only effect parsing, not direct usage (eg, Finish and FinishExact) if ((x.day - this.getDate()) !== 0) { this.setDate(x.day); } } if (x.milliseconds) { this.addMilliseconds(x.milliseconds); } if (x.seconds) { this.addSeconds(x.seconds); } if (x.minutes) { this.addMinutes(x.minutes); } if (x.hours) { this.addHours(x.hours); } if (x.weeks) { this.addWeeks(x.weeks); } if (x.months) { this.addMonths(x.months); } if (x.years) { this.addYears(x.years); } if (x.days) { this.addDays(x.days); } return this; }; /** * Get the week number. Week one (1) is the week which contains the first Thursday of the year. Monday is considered the first day of the week. * The .getWeek() function does NOT convert the date to UTC. The local datetime is used. * Please use .getISOWeek() to get the week of the UTC converted date. * @return {Number} 1 to 53 */ $P.getWeek = function (utc) { // Create a copy of this date object var self, target = new Date(this.valueOf()); if (utc) { target.addMinutes(target.getTimezoneOffset()); self = target.clone(); } else { self = this; } // ISO week date weeks start on monday // so correct the day number var dayNr = (self.getDay() + 6) % 7; // ISO 8601 states that week 1 is the week // with the first thursday of that year. // Set the target date to the thursday in the target week target.setDate(target.getDate() - dayNr + 3); // Store the millisecond value of the target date var firstThursday = target.valueOf(); // Set the target to the first thursday of the year // First set the target to january first target.setMonth(0, 1); // Not a thursday? Correct the date to the next thursday if (target.getDay() !== 4) { target.setMonth(0, 1 + ((4 - target.getDay()) + 7) % 7); } // The weeknumber is the number of weeks between the // first thursday of the year and the thursday in the target week return 1 + Math.ceil((firstThursday - target) / 604800000); // 604800000 = 7 * 24 * 3600 * 1000 }; /** * Get the ISO 8601 week number. Week one ("01") is the week which contains the first Thursday of the year. Monday is considered the first day of the week. * The .getISOWeek() function does convert the date to it's UTC value. Please use .getWeek() to get the week of the local date. * @return {String} "01" to "53" */ $P.getISOWeek = function () { return p(this.getWeek(true)); }; /** * Moves the date to Monday of the week set. Week one (1) is the week which contains the first Thursday of the year. * @param {Number} A Number (1 to 53) that represents the week of the year. * @return {Date} this */ $P.setWeek = function (n) { if ((n - this.getWeek()) === 0) { if (this.getDay() !== 1) { return this.moveToDayOfWeek(1, (this.getDay() > 1 ? -1 : 1)); } else { return this; } } else { return this.moveToDayOfWeek(1, (this.getDay() > 1 ? -1 : 1)).addWeeks(n - this.getWeek()); } }; $P.setQuarter = function (qtr) { var month = Math.abs(((qtr-1) * 3) + 1); return this.setMonth(month, 1); }; $P.getQuarter = function () { return Date.getQuarter(this); }; $P.getDaysLeftInQuarter = function () { return Date.getDaysLeftInQuarter(this); }; /** * Moves the date to the next n'th occurrence of the dayOfWeek starting from the beginning of the month. The number (-1) is a magic number and will return the last occurrence of the dayOfWeek in the month. * @param {Number} The dayOfWeek to move to * @param {Number} The n'th occurrence to move to. Use (-1) to return the last occurrence in the month * @return {Date} this */ $P.moveToNthOccurrence = function (dayOfWeek, occurrence) { if (dayOfWeek === "Weekday") { if (occurrence > 0) { this.moveToFirstDayOfMonth(); if (this.is().weekday()) { occurrence -= 1; } } else if (occurrence < 0) { this.moveToLastDayOfMonth(); if (this.is().weekday()) { occurrence += 1; } } else { return this; } return this.addWeekdays(occurrence); } var shift = 0; if (occurrence > 0) { shift = occurrence - 1; } else if (occurrence === -1) { this.moveToLastDayOfMonth(); if (this.getDay() !== dayOfWeek) { this.moveToDayOfWeek(dayOfWeek, -1); } return this; } return this.moveToFirstDayOfMonth().addDays(-1).moveToDayOfWeek(dayOfWeek, +1).addWeeks(shift); }; var moveToN = function (getFunc, addFunc, nVal) { return function (value, orient) { var diff = (value - this[getFunc]() + nVal * (orient || +1)) % nVal; return this[addFunc]((diff === 0) ? diff += nVal * (orient || +1) : diff); }; }; /** * Move to the next or last dayOfWeek based on the orient value. * @param {Number} The dayOfWeek to move to * @param {Number} Forward (+1) or Back (-1). Defaults to +1. [Optional] * @return {Date} this */ $P.moveToDayOfWeek = moveToN("getDay", "addDays", 7); /** * Move to the next or last month based on the orient value. * @param {Number} The month to move to. 0 = January, 11 = December * @param {Number} Forward (+1) or Back (-1). Defaults to +1. [Optional] * @return {Date} this */ $P.moveToMonth = moveToN("getMonth", "addMonths", 12); /** * Get the Ordinate of the current day ("th", "st", "rd"). * @return {String} */ $P.getOrdinate = function () { var num = this.getDate(); return ord(num); }; /** * Get the Ordinal day (numeric day number) of the year, adjusted for leap year. * @return {Number} 1 through 365 (366 in leap years) */ $P.getOrdinalNumber = function () { return Math.ceil((this.clone().clearTime() - new Date(this.getFullYear(), 0, 1)) / 86400000) + 1; }; /** * Get the time zone abbreviation of the current date. * @return {String} The abbreviated time zone name (e.g. "EST") */ $P.getTimezone = function () { return $D.getTimezoneAbbreviation(this.getUTCOffset(), this.isDaylightSavingTime()); }; $P.setTimezoneOffset = function (offset) { var here = this.getTimezoneOffset(), there = Number(offset) * -6 / 10; return (there || there === 0) ? this.addMinutes(there - here) : this; }; $P.setTimezone = function (offset) { return this.setTimezoneOffset($D.getTimezoneOffset(offset)); }; /** * Indicates whether Daylight Saving Time is observed in the current time zone. * @return {Boolean} true|false */ $P.hasDaylightSavingTime = function () { return (Date.today().set({month: 0, day: 1}).getTimezoneOffset() !== Date.today().set({month: 6, day: 1}).getTimezoneOffset()); }; /** * Indicates whether this Date instance is within the Daylight Saving Time range for the current time zone. * @return {Boolean} true|false */ $P.isDaylightSavingTime = function () { return Date.today().set({month: 0, day: 1}).getTimezoneOffset() !== this.getTimezoneOffset(); }; /** * Get the offset from UTC of the current date. * @return {String} The 4-character offset string prefixed with + or - (e.g. "-0500") */ $P.getUTCOffset = function (offset) { var n = (offset || this.getTimezoneOffset()) * -10 / 6, r; if (n < 0) { r = (n - 10000).toString(); return r.charAt(0) + r.substr(2); } else { r = (n + 10000).toString(); return "+" + r.substr(1); } }; /** * Returns the number of milliseconds between this date and date. * @param {Date} Defaults to now * @return {Number} The diff in milliseconds */ $P.getElapsed = function (date) { return (date || new Date()) - this; }; /** * Set the value of year, month, day, hour, minute, second, millisecond of date instance using given configuration object. * Example

	Date.today().set( { day: 20, month: 1 } )

	new Date().set( { millisecond: 0 } )
	
* * @param {Object} Configuration object containing attributes (month, day, etc.) * @return {Date} this */ $P.set = function (config) { config = validateConfigObject.call(this, config); var key; for (key in config) { if (Object.prototype.hasOwnProperty.call(config, key)) { var name = key.charAt(0).toUpperCase() + key.slice(1); var addFunc, getFunc; if (key !== "week" && key !== "month" && key !== "timezone" && key !== "timezoneOffset") { name += "s"; } addFunc = "add" + name; getFunc = "get" + name; if (key === "month") { addFunc = addFunc + "s"; } else if (key === "year"){ getFunc = "getFullYear"; } if (key !== "day" && key !== "timezone" && key !== "timezoneOffset" && key !== "week" && key !== "hour") { this[addFunc](config[key] - this[getFunc]()); } else if ( key === "timezone"|| key === "timezoneOffset" || key === "week" || key === "hour") { this["set"+name](config[key]); } } } // day has to go last because you can't validate the day without first knowing the month if (config.day) { this.addDays(config.day - this.getDate()); } return this; }; /** * Moves the date to the first day of the month. * @return {Date} this */ $P.moveToFirstDayOfMonth = function () { return this.set({ day: 1 }); }; /** * Moves the date to the last day of the month. * @return {Date} this */ $P.moveToLastDayOfMonth = function () { return this.set({ day: $D.getDaysInMonth(this.getFullYear(), this.getMonth())}); }; /** * Converts the value of the current Date object to its equivalent string representation. * Format Specifiers * CUSTOM DATE AND TIME FORMAT STRINGS * Format Description Example * ------ --------------------------------------------------------------------------- ----------------------- * s The seconds of the minute between 0-59. "0" to "59" * ss The seconds of the minute with leading zero if required. "00" to "59" * * m The minute of the hour between 0-59. "0" or "59" * mm The minute of the hour with leading zero if required. "00" or "59" * * h The hour of the day between 1-12. "1" to "12" * hh The hour of the day with leading zero if required. "01" to "12" * * H The hour of the day between 0-23. "0" to "23" * HH The hour of the day with leading zero if required. "00" to "23" * * d The day of the month between 1 and 31. "1" to "31" * dd The day of the month with leading zero if required. "01" to "31" * ddd Abbreviated day name. Date.CultureInfo.abbreviatedDayNames. "Mon" to "Sun" * dddd The full day name. Date.CultureInfo.dayNames. "Monday" to "Sunday" * * M The month of the year between 1-12. "1" to "12" * MM The month of the year with leading zero if required. "01" to "12" * MMM Abbreviated month name. Date.CultureInfo.abbreviatedMonthNames. "Jan" to "Dec" * MMMM The full month name. Date.CultureInfo.monthNames. "January" to "December" * * yy The year as a two-digit number. "99" or "08" * yyyy The full four digit year. "1999" or "2008" * * t Displays the first character of the A.M./P.M. designator. "A" or "P" * Date.CultureInfo.amDesignator or Date.CultureInfo.pmDesignator * tt Displays the A.M./P.M. designator. "AM" or "PM" * Date.CultureInfo.amDesignator or Date.CultureInfo.pmDesignator * * S The ordinal suffix ("st, "nd", "rd" or "th") of the current day. "st, "nd", "rd" or "th" * * STANDARD DATE AND TIME FORMAT STRINGS * Format Description Example *------ --------------------------------------------------------------------------- ----------------------- * d The CultureInfo shortDate Format Pattern "M/d/yyyy" * D The CultureInfo longDate Format Pattern "dddd, MMMM dd, yyyy" * F The CultureInfo fullDateTime Format Pattern "dddd, MMMM dd, yyyy h:mm:ss tt" * m The CultureInfo monthDay Format Pattern "MMMM dd" * r The CultureInfo rfc1123 Format Pattern "ddd, dd MMM yyyy HH:mm:ss GMT" * s The CultureInfo sortableDateTime Format Pattern "yyyy-MM-ddTHH:mm:ss" * t The CultureInfo shortTime Format Pattern "h:mm tt" * T The CultureInfo longTime Format Pattern "h:mm:ss tt" * u The CultureInfo universalSortableDateTime Format Pattern "yyyy-MM-dd HH:mm:ssZ" * y The CultureInfo yearMonth Format Pattern "MMMM, yyyy" * * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @return {String} A string representation of the current Date object. */ var ord = function (n) { switch (n * 1) { case 1: case 21: case 31: return "st"; case 2: case 22: return "nd"; case 3: case 23: return "rd"; default: return "th"; } }; var parseStandardFormats = function (format) { var y, c = Date.CultureInfo.formatPatterns; switch (format) { case "d": return this.toString(c.shortDate); case "D": return this.toString(c.longDate); case "F": return this.toString(c.fullDateTime); case "m": return this.toString(c.monthDay); case "r": case "R": y = this.clone().addMinutes(this.getTimezoneOffset()); return y.toString(c.rfc1123) + " GMT"; case "s": return this.toString(c.sortableDateTime); case "t": return this.toString(c.shortTime); case "T": return this.toString(c.longTime); case "u": y = this.clone().addMinutes(this.getTimezoneOffset()); return y.toString(c.universalSortableDateTime); case "y": return this.toString(c.yearMonth); default: return false; } }; var parseFormatStringsClosure = function (context) { return function (m) { if (m.charAt(0) === "\\") { return m.replace("\\", ""); } switch (m) { case "hh": return p(context.getHours() < 13 ? (context.getHours() === 0 ? 12 : context.getHours()) : (context.getHours() - 12)); case "h": return context.getHours() < 13 ? (context.getHours() === 0 ? 12 : context.getHours()) : (context.getHours() - 12); case "HH": return p(context.getHours()); case "H": return context.getHours(); case "mm": return p(context.getMinutes()); case "m": return context.getMinutes(); case "ss": return p(context.getSeconds()); case "s": return context.getSeconds(); case "yyyy": return p(context.getFullYear(), 4); case "yy": return p(context.getFullYear()); case "y": return context.getFullYear(); case "E": case "dddd": return Date.CultureInfo.dayNames[context.getDay()]; case "ddd": return Date.CultureInfo.abbreviatedDayNames[context.getDay()]; case "dd": return p(context.getDate()); case "d": return context.getDate(); case "MMMM": return Date.CultureInfo.monthNames[context.getMonth()]; case "MMM": return Date.CultureInfo.abbreviatedMonthNames[context.getMonth()]; case "MM": return p((context.getMonth() + 1)); case "M": return context.getMonth() + 1; case "t": return context.getHours() < 12 ? Date.CultureInfo.amDesignator.substring(0, 1) : Date.CultureInfo.pmDesignator.substring(0, 1); case "tt": return context.getHours() < 12 ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator; case "S": return ord(context.getDate()); case "W": return context.getWeek(); case "WW": return context.getISOWeek(); case "Q": return "Q" + context.getQuarter(); case "q": return String(context.getQuarter()); case "z": return context.getTimezone(); case "Z": case "X": return Date.getTimezoneOffset(context.getTimezone()); case "ZZ": // Timezone offset in seconds return context.getTimezoneOffset() * -60; case "u": return context.getDay(); case "L": return ($D.isLeapYear(context.getFullYear())) ? 1 : 0; case "B": // Swatch Internet Time (.beats) return "@"+((context.getUTCSeconds() + (context.getUTCMinutes()*60) + ((context.getUTCHours()+1)*3600))/86.4); default: return m; } }; }; $P.toString = function (format, ignoreStandards) { // Standard Date and Time Format Strings. Formats pulled from CultureInfo file and // may vary by culture. if (!ignoreStandards && format && format.length === 1) { output = parseStandardFormats.call(this, format); if (output) { return output; } } var parseFormatStrings = parseFormatStringsClosure(this); return format ? format.replace(/((\\)?(dd?d?d?|MM?M?M?|yy?y?y?|hh?|HH?|mm?|ss?|tt?|S|q|Q|WW?W?W?)(?![^\[]*\]))/g, parseFormatStrings).replace(/\[|\]/g, "") : this._toString(); }; }()); /************************************************************* * SugarPak - Domain Specific Language - Syntactical Sugar * *************************************************************/ (function () { var $D = Date, $P = $D.prototype, $N = Number.prototype; // private $P._orient = +1; // private $P._nth = null; // private $P._is = false; // private $P._same = false; // private $P._isSecond = false; // private $N._dateElement = "days"; /** * Moves the date to the next instance of a date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.today().next().friday();
	Date.today().next().fri();
	Date.today().next().march();
	Date.today().next().mar();
	Date.today().next().week();
	
* * @return {Date} date */ $P.next = function () { this._move = true; this._orient = +1; return this; }; /** * Creates a new Date (Date.today()) and moves the date to the next instance of the date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.next().friday();
	Date.next().fri();
	Date.next().march();
	Date.next().mar();
	Date.next().week();
	
* * @return {Date} date */ $D.next = function () { return $D.today().next(); }; /** * Moves the date to the previous instance of a date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.today().last().friday();
	Date.today().last().fri();
	Date.today().last().march();
	Date.today().last().mar();
	Date.today().last().week();
	
* * @return {Date} date */ $P.last = $P.prev = $P.previous = function () { this._move = true; this._orient = -1; return this; }; /** * Creates a new Date (Date.today()) and moves the date to the previous instance of the date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.last().friday();
	Date.last().fri();
	Date.previous().march();
	Date.prev().mar();
	Date.last().week();
	
* * @return {Date} date */ $D.last = $D.prev = $D.previous = function () { return $D.today().last(); }; /** * Performs a equality check when followed by either a month name, day name or .weekday() function. * Example

	Date.today().is().friday(); // true|false
	Date.today().is().fri();
	Date.today().is().march();
	Date.today().is().mar();
	
* * @return {Boolean} true|false */ $P.is = function () { this._is = true; return this; }; /** * Determines if two date objects occur on/in exactly the same instance of the subsequent date part function. * The function .same() must be followed by a date part function (example: .day(), .month(), .year(), etc). * * An optional Date can be passed in the date part function. If now date is passed as a parameter, 'Now' is used. * * The following example demonstrates how to determine if two dates fall on the exact same day. * * Example

	var d1 = Date.today(); // today at 00:00
	var d2 = new Date();   // exactly now.

	// Do they occur on the same day?
	d1.same().day(d2); // true
	
	// Do they occur on the same hour?
	d1.same().hour(d2); // false, unless d2 hour is '00' (midnight).
	
	// What if it's the same day, but one year apart?
	var nextYear = Date.today().add(1).year();

	d1.same().day(nextYear); // false, because the dates must occur on the exact same day. 
	
* * Scenario: Determine if a given date occurs during some week period 2 months from now. * * Example

	var future = Date.today().add(2).months();
	return someDate.same().week(future); // true|false;
	
* * @return {Boolean} true|false */ $P.same = function () { this._same = true; this._isSecond = false; return this; }; /** * Determines if the current date/time occurs during Today. Must be preceded by the .is() function. * Example

	someDate.is().today();    // true|false
	new Date().is().today();  // true
	Date.today().is().today();// true
	Date.today().add(-1).day().is().today(); // false
	
* * @return {Boolean} true|false */ $P.today = function () { return this.same().day(); }; /** * Determines if the current date is a weekday. This function must be preceded by the .is() function. * Example

	Date.today().is().weekday(); // true|false
	
* * @return {Boolean} true|false */ $P.weekday = function () { if (this._nth) { return df("Weekday").call(this); } if (this._move) { return this.addWeekdays(this._orient); } if (this._is) { this._is = false; return (!this.is().sat() && !this.is().sun()); } return false; }; /** * Determines if the current date is on the weekend. This function must be preceded by the .is() function. * Example

	Date.today().is().weekend(); // true|false
	
* * @return {Boolean} true|false */ $P.weekend = function () { if (this._is) { this._is = false; return (this.is().sat() || this.is().sun()); } return false; }; /** * Sets the Time of the current Date instance. A string "6:15 pm" or config object {hour:18, minute:15} are accepted. * Example

	// Set time to 6:15pm with a String
	Date.today().at("6:15pm");

	// Set time to 6:15pm with a config object
	Date.today().at({hour:18, minute:15});
	
* * @return {Date} date */ $P.at = function (time) { return (typeof time === "string") ? $D.parse(this.toString("d") + " " + time) : this.set(time); }; /** * Creates a new Date() and adds this (Number) to the date based on the preceding date element function (eg. second|minute|hour|day|month|year). * Example

	// Undeclared Numbers must be wrapped with parentheses. Requirment of JavaScript.
	(3).days().fromNow();
	(6).months().fromNow();

	// Declared Number variables do not require parentheses. 
	var n = 6;
	n.months().fromNow();
	
* * @return {Date} A new Date instance */ $N.fromNow = $N.after = function (date) { var c = {}; c[this._dateElement] = this; return ((!date) ? new Date() : date.clone()).add(c); }; /** * Creates a new Date() and subtract this (Number) from the date based on the preceding date element function (eg. second|minute|hour|day|month|year). * Example

	// Undeclared Numbers must be wrapped with parentheses. Requirment of JavaScript.
	(3).days().ago();
	(6).months().ago();

	// Declared Number variables do not require parentheses. 
	var n = 6;
	n.months().ago();
	
* * @return {Date} A new Date instance */ $N.ago = $N.before = function (date) { var c = {}, s = (this._dateElement[this._dateElement.length-1] !== "s") ? this._dateElement + "s" : this._dateElement; c[s] = this * -1; return ((!date) ? new Date() : date.clone()).add(c); }; // Do NOT modify the following string tokens. These tokens are used to build dynamic functions. // All culture-specific strings can be found in the CultureInfo files. var dx = ("sunday monday tuesday wednesday thursday friday saturday").split(/\s/), mx = ("january february march april may june july august september october november december").split(/\s/), px = ("Millisecond Second Minute Hour Day Week Month Year Quarter Weekday").split(/\s/), pxf = ("Milliseconds Seconds Minutes Hours Date Week Month FullYear Quarter").split(/\s/), nth = ("final first second third fourth fifth").split(/\s/), de; /** * Returns an object literal of all the date parts. * Example

	var o = new Date().toObject();
	
	// { year: 2008, month: 4, week: 20, day: 13, hour: 18, minute: 9, second: 32, millisecond: 812 }
	
	// The object properties can be referenced directly from the object.
	
	alert(o.day);  // alerts "13"
	alert(o.year); // alerts "2008"
	
* * @return {Date} An object literal representing the original date object. */ $P.toObject = function () { var o = {}; for (var i = 0; i < px.length; i++) { if (this["get" + pxf[i]]) { o[px[i].toLowerCase()] = this["get" + pxf[i]](); } } return o; }; /** * Returns a date created from an object literal. Ignores the .week property if set in the config. * Example

	var o = new Date().toObject();
	
	return Date.fromObject(o); // will return the same date. 

	var o2 = {month: 1, day: 20, hour: 18}; // birthday party!
	Date.fromObject(o2);
	
* * @return {Date} An object literal representing the original date object. */ $D.fromObject = function(config) { config.week = null; return Date.today().set(config); }; // Create day name functions and abbreviated day name functions (eg. monday(), friday(), fri()). var df = function (n) { return function () { if (this._is) { this._is = false; return this.getDay() === n; } if (this._move) { this._move = null; } if (this._nth !== null) { // If the .second() function was called earlier, remove the _orient // from the date, and then continue. // This is required because 'second' can be used in two different context. // // Example // // Date.today().add(1).second(); // Date.march().second().monday(); // // Things get crazy with the following... // Date.march().add(1).second().second().monday(); // but it works!! // if (this._isSecond) { this.addSeconds(this._orient * -1); } // make sure we reset _isSecond this._isSecond = false; var ntemp = this._nth; this._nth = null; var temp = this.clone().moveToLastDayOfMonth(); this.moveToNthOccurrence(n, ntemp); if (this > temp) { throw new RangeError($D.getDayName(n) + " does not occur " + ntemp + " times in the month of " + $D.getMonthName(temp.getMonth()) + " " + temp.getFullYear() + "."); } return this; } return this.moveToDayOfWeek(n, this._orient); }; }; var sdf = function (n) { return function () { var t = $D.today(), shift = n - t.getDay(); if (n === 0 && Date.CultureInfo.firstDayOfWeek === 1 && t.getDay() !== 0) { shift = shift + 7; } return t.addDays(shift); }; }; // Create month name functions and abbreviated month name functions (eg. january(), march(), mar()). var month_instance_functions = function (n) { return function () { if (this._is) { this._is = false; return this.getMonth() === n; } return this.moveToMonth(n, this._orient); }; }; var month_static_functions = function (n) { return function () { return $D.today().set({ month: n, day: 1 }); }; }; var processTerms = function (names, staticFunc, instanceFunc) { for (var i = 0; i < names.length; i++) { // Create constant static Name variables. $D[names[i].toUpperCase()] = $D[names[i].toUpperCase().substring(0, 3)] = i; // Create Name functions. $D[names[i]] = $D[names[i].substring(0, 3)] = staticFunc(i); // Create Name instance functions. $P[names[i]] = $P[names[i].substring(0, 3)] = instanceFunc(i); } }; processTerms(dx, sdf, df); processTerms(mx, month_static_functions, month_instance_functions); // Create date element functions and plural date element functions used with Date (eg. day(), days(), months()). var ef = function (j) { return function () { // if the .second() function was called earlier, the _orient // has alread been added. Just return this and reset _isSecond. if (this._isSecond) { this._isSecond = false; return this; } if (this._same) { this._same = this._is = false; var o1 = this.toObject(), o2 = (arguments[0] || new Date()).toObject(), v = "", k = j.toLowerCase(); // the substr trick with -1 doesn't work in IE8 or less k = (k[k.length-1] === "s") ? k.substring(0,k.length-1) : k; for (var m = (px.length - 1); m > -1; m--) { v = px[m].toLowerCase(); if (o1[v] !== o2[v]) { return false; } if (k === v) { break; } } return true; } if (j.substring(j.length - 1) !== "s") { j += "s"; } if (this._move) { this._move = null; } return this["add" + j](this._orient); }; }; var nf = function (n) { return function () { this._dateElement = n; return this; }; }; for (var k = 0; k < px.length; k++) { de = px[k].toLowerCase(); if(de !== "weekday") { // Create date element functions and plural date element functions used with Date (eg. day(), days(), months()). $P[de] = $P[de + "s"] = ef(px[k]); // Create date element functions and plural date element functions used with Number (eg. day(), days(), months()). $N[de] = $N[de + "s"] = nf(de + "s"); } } $P._ss = ef("Second"); var nthfn = function (n) { return function (dayOfWeek) { if (this._same) { return this._ss(arguments[0]); } if (dayOfWeek || dayOfWeek === 0) { return this.moveToNthOccurrence(dayOfWeek, n); } this._nth = n; // if the operator is 'second' add the _orient, then deal with it later... if (n === 2 && (dayOfWeek === undefined || dayOfWeek === null)) { this._isSecond = true; return this.addSeconds(this._orient); } return this; }; }; for (var l = 0; l < nth.length; l++) { $P[nth[l]] = (l === 0) ? nthfn(-1) : nthfn(l); } }()); (function () { "use strict"; Date.Parsing = { Exception: function (s) { this.message = "Parse error at '" + s.substring(0, 10) + " ...'"; } }; var $P = Date.Parsing; var dayOffsets = { standard: [0,31,59,90,120,151,181,212,243,273,304,334], leap: [0,31,60,91,121,152,182,213,244,274,305,335] }; $P.isLeapYear = function(year) { return ((year % 4 === 0) && (year % 100 !== 0)) || (year % 400 === 0); }; var utils = { multiReplace : function (str, hash ) { var key; for (key in hash) { if (Object.prototype.hasOwnProperty.call(hash, key)) { var regex; if (typeof hash[key] === "function") { } else { regex = (hash[key] instanceof RegExp) ? hash[key] : new RegExp(hash[key], "g"); } str = str.replace(regex, key); } } return str; }, getDayOfYearFromWeek : function (obj) { var d, jan4, offset; obj.weekDay = (!obj.weekDay && obj.weekDay !== 0) ? 1 : obj.weekDay; d = new Date(obj.year, 0, 4); jan4 = d.getDay() === 0 ? 7 : d.getDay(); // JS is 0 indexed on Sunday. offset = jan4+3; obj.dayOfYear = ((obj.week * 7) + (obj.weekDay === 0 ? 7 : obj.weekDay))-offset; return obj; }, getDayOfYear : function (obj, dayOffset) { if (!obj.dayOfYear) { obj = utils.getDayOfYearFromWeek(obj); } for (var i=0;i <= dayOffset.length;i++) { if (obj.dayOfYear < dayOffset[i] || i === dayOffset.length) { obj.day = obj.day ? obj.day : (obj.dayOfYear - dayOffset[i-1]); break; } else { obj.month = i; } } return obj; }, adjustForTimeZone : function (obj, date) { var offset; if (obj.zone.toUpperCase() === "Z" || (obj.zone_hours === 0 && obj.zone_minutes === 0)) { // it's UTC/GML so work out the current timeszone offset offset = -date.getTimezoneOffset(); } else { offset = (obj.zone_hours*60) + (obj.zone_minutes || 0); if (obj.zone_sign === "+") { offset *= -1; } offset -= date.getTimezoneOffset(); } date.setMinutes(date.getMinutes()+offset); return date; }, setDefaults : function (obj) { obj.year = obj.year || Date.today().getFullYear(); obj.hours = obj.hours || 0; obj.minutes = obj.minutes || 0; obj.seconds = obj.seconds || 0; obj.milliseconds = obj.milliseconds || 0; if (!(!obj.month && (obj.week || obj.dayOfYear))) { // if we have a month, or if we don't but don't have the day calculation data obj.month = obj.month || 0; obj.day = obj.day || 1; } return obj; }, dataNum: function (data, mod, explict, postProcess) { var dataNum = data*1; if (mod) { if (postProcess) { return data ? mod(data)*1 : data; } else { return data ? mod(dataNum) : data; } } else if (!explict){ return data ? dataNum : data; } else { return (data && typeof data !== "undefined") ? dataNum : data; } }, timeDataProcess: function (obj) { var timeObj = {}; for (var x in obj.data) { if (obj.data.hasOwnProperty(x)) { timeObj[x] = obj.ignore[x] ? obj.data[x] : utils.dataNum(obj.data[x], obj.mods[x], obj.explict[x], obj.postProcess[x]); } } if (obj.data.secmins) { obj.data.secmins = obj.data.secmins.replace(",", ".") * 60; if (!timeObj.minutes) { timeObj.minutes = obj.data.secmins; } else if (!timeObj.seconds) { timeObj.seconds = obj.data.secmins; } delete obj.secmins; } return timeObj; }, buildTimeObjectFromData: function (data) { var time = utils.timeDataProcess({ data: { year : data[1], month : data[5], day : data[7], week : data[8], dayOfYear : data[10], hours : data[15], zone_hours : data[23], zone_minutes : data[24], zone : data[21], zone_sign : data[22], weekDay : data[9], minutes: data[16], seconds: data[19], milliseconds: data[20], secmins: data[18] }, mods: { month: function(data) { return data-1; }, weekDay: function (data) { data = Math.abs(data); return (data === 7 ? 0 : data); }, minutes: function (data) { return data.replace(":",""); }, seconds: function (data) { return Math.floor( (data.replace(":","").replace(",","."))*1 ); }, milliseconds: function (data) { return (data.replace(",",".")*1000); } }, postProcess: { minutes: true, seconds: true, milliseconds: true }, explict: { zone_hours: true, zone_minutes: true }, ignore: { zone: true, zone_sign: true, secmins: true } }); return time; }, addToHash: function (hash, keys, data) { keys = keys; data = data; var len = keys.length; for (var i = 0; i < len; i++) { hash[keys[i]] = data[i]; } return hash; }, combineRegex: function (r1, r2) { return new RegExp("(("+r1.source+")\\s("+r2.source+"))"); }, getDateNthString: function(add, last, inc){ if (add) { return Date.today().addDays(inc).toString("d"); } else if (last) { return Date.today().last()[inc]().toString("d"); } }, buildRegexData: function (array) { var arr = []; var len = array.length; for (var i=0; i < len; i++) { if (Object.prototype.toString.call(array[i]) === '[object Array]') { // oldIE compat version of Array.isArray arr.push(this.combineRegex(array[i][0], array[i][1])); } else { arr.push(array[i]); } } return arr; } }; $P.processTimeObject = function (obj) { var date, dayOffset; utils.setDefaults(obj); dayOffset = ($P.isLeapYear(obj.year)) ? dayOffsets.leap : dayOffsets.standard; if (!obj.month && (obj.week || obj.dayOfYear)) { utils.getDayOfYear(obj, dayOffset); } else { obj.dayOfYear = dayOffset[obj.month] + obj.day; } date = new Date(obj.year, obj.month, obj.day, obj.hours, obj.minutes, obj.seconds, obj.milliseconds); if (obj.zone) { utils.adjustForTimeZone(obj, date); // adjust (and calculate) for timezone } return date; }; $P.ISO = { regex : /^([\+-]?\d{4}(?!\d{2}\b))((-?)((0[1-9]|1[0-2])(\3([12]\d|0[1-9]|3[01]))?|W([0-4]\d|5[0-3])(-?[1-7])?|(00[1-9]|0[1-9]\d|[12]\d{2}|3([0-5]\d|6[1-6])))([T\s]((([01]\d|2[0-4])((:?)[0-5]\d)?|24\:?00)([\.,]\d+(?!:))?)?(\17[0-5]\d([\.,]\d+)?)?\s?([zZ]|([\+-])([01]\d|2[0-3]):?([0-5]\d)?)?)?)?$/, parse : function (s) { var time, data = s.match(this.regex); if (!data || !data.length) { return null; } time = utils.buildTimeObjectFromData(data); if (!time.year || (!time.year && (!time.month && !time.day) && (!time.week && !time.dayOfYear)) ) { return null; } return $P.processTimeObject(time); } }; $P.Numeric = { isNumeric: function (e){return!isNaN(parseFloat(e))&&isFinite(e);}, regex: /\b([0-1]?[0-9])([0-3]?[0-9])([0-2]?[0-9]?[0-9][0-9])\b/i, parse: function (s) { var data, i, time = {}, order = Date.CultureInfo.dateElementOrder.split(""); if (!(this.isNumeric(s)) || // if it's non-numeric OR (s[0] === "+" && s[0] === "-")) { // It's an arithmatic string (eg +/-1000) return null; } if (s.length < 5 && s.indexOf(".") < 0 && s.indexOf("/") < 0) { // assume it's just a year. time.year = s; return $P.processTimeObject(time); } data = s.match(this.regex); if (!data || !data.length) { return null; } for (i=0; i < order.length; i++) { switch(order[i]) { case "d": time.day = data[i+1]; break; case "m": time.month = (data[i+1]-1); break; case "y": time.year = data[i+1]; break; } } return $P.processTimeObject(time); } }; $P.Normalizer = { regexData: function () { var $R = Date.CultureInfo.regexPatterns; return utils.buildRegexData([ $R.tomorrow, $R.yesterday, [$R.past, $R.mon], [$R.past, $R.tue], [$R.past, $R.wed], [$R.past, $R.thu], [$R.past, $R.fri], [$R.past, $R.sat], [$R.past, $R.sun] ]); }, basicReplaceHash : function() { var $R = Date.CultureInfo.regexPatterns; return { "January": $R.jan.source, "February": $R.feb, "March": $R.mar, "April": $R.apr, "May": $R.may, "June": $R.jun, "July": $R.jul, "August": $R.aug, "September": $R.sep, "October": $R.oct, "November": $R.nov, "December": $R.dec, "": /\bat\b/gi, " ": /\s{2,}/, "am": $R.inTheMorning, "9am": $R.thisMorning, "pm": $R.inTheEvening, "7pm":$R.thisEvening }; }, keys : function(){ return [ utils.getDateNthString(true, false, 1), // tomorrow utils.getDateNthString(true, false, -1), // yesterday utils.getDateNthString(false, true, "monday"), //last mon utils.getDateNthString(false, true, "tuesday"), //last tues utils.getDateNthString(false, true, "wednesday"), //last wed utils.getDateNthString(false, true, "thursday"), //last thurs utils.getDateNthString(false, true, "friday"), //last fri utils.getDateNthString(false, true, "saturday"), //last sat utils.getDateNthString(false, true, "sunday") //last sun ]; }, buildRegexFunctions: function () { var $R = Date.CultureInfo.regexPatterns; var __ = Date.i18n.__; var tomorrowRE = new RegExp("(\\b\\d\\d?("+__("AM")+"|"+__("PM")+")? )("+$R.tomorrow.source.slice(1)+")", "i"); // adapted tomorrow regex for AM PM relative dates var todayRE = new RegExp($R.today.source + "(?!\\s*([+-]))\\b"); // today, but excludes the math operators (eg "today + 2h") this.replaceFuncs = [ [todayRE, function (full) { return (full.length > 1) ? Date.today().toString("d") : full; }], [tomorrowRE, function(full, m1) { var t = Date.today().addDays(1).toString("d"); return (t + " " + m1); }], [$R.amThisMorning, function(str, am){return am;}], [$R.pmThisEvening, function(str, pm){return pm;}] ]; }, buildReplaceData: function () { this.buildRegexFunctions(); this.replaceHash = utils.addToHash(this.basicReplaceHash(), this.keys(), this.regexData()); }, stringReplaceFuncs: function (s) { for (var i=0; i < this.replaceFuncs.length; i++) { s = s.replace(this.replaceFuncs[i][0], this.replaceFuncs[i][1]); } return s; }, parse: function (s) { s = this.stringReplaceFuncs(s); s = utils.multiReplace(s, this.replaceHash); try { var n = s.split(/([\s\-\.\,\/\x27]+)/); if (n.length === 3 && $P.Numeric.isNumeric(n[0]) && $P.Numeric.isNumeric(n[2]) && (n[2].length >= 4)) { // ok, so we're dealing with x/year. But that's not a full date. // This fixes wonky dateElementOrder parsing when set to dmy order. if (Date.CultureInfo.dateElementOrder[0] === "d") { s = "1/" + n[0] + "/" + n[2]; // set to 1st of month and normalize the seperator } } } catch (e) {} return s; } }; $P.Normalizer.buildReplaceData(); }()); (function () { var $P = Date.Parsing; var _ = $P.Operators = { // // Tokenizers // rtoken: function (r) { // regex token return function (s) { var mx = s.match(r); if (mx) { return ([ mx[0], s.substring(mx[0].length) ]); } else { throw new $P.Exception(s); } }; }, token: function () { // whitespace-eating token return function (s) { return _.rtoken(new RegExp("^\\s*" + s + "\\s*"))(s); }; }, stoken: function (s) { // string token return _.rtoken(new RegExp("^" + s)); }, // Atomic Operators until: function (p) { return function (s) { var qx = [], rx = null; while (s.length) { try { rx = p.call(this, s); } catch (e) { qx.push(rx[0]); s = rx[1]; continue; } break; } return [ qx, s ]; }; }, many: function (p) { return function (s) { var rx = [], r = null; while (s.length) { try { r = p.call(this, s); } catch (e) { return [ rx, s ]; } rx.push(r[0]); s = r[1]; } return [ rx, s ]; }; }, // generator operators -- see below optional: function (p) { return function (s) { var r = null; try { r = p.call(this, s); } catch (e) { return [ null, s ]; } return [ r[0], r[1] ]; }; }, not: function (p) { return function (s) { try { p.call(this, s); } catch (e) { return [null, s]; } throw new $P.Exception(s); }; }, ignore: function (p) { return p ? function (s) { var r = null; r = p.call(this, s); return [null, r[1]]; } : null; }, product: function () { var px = arguments[0], qx = Array.prototype.slice.call(arguments, 1), rx = []; for (var i = 0 ; i < px.length ; i++) { rx.push(_.each(px[i], qx)); } return rx; }, cache: function (rule) { var cache = {}, cache_length = 0, cache_keys = [], CACHE_MAX = Date.Config.CACHE_MAX || 100000, r = null; var cacheCheck = function () { if (cache_length === CACHE_MAX) { // kill several keys, don't want to have to do this all the time... for (var i=0; i < 10; i++) { var key = cache_keys.shift(); if (key) { delete cache[key]; cache_length--; } } } }; return function (s) { cacheCheck(); try { r = cache[s] = (cache[s] || rule.call(this, s)); } catch (e) { r = cache[s] = e; } cache_length++; cache_keys.push(s); if (r instanceof $P.Exception) { throw r; } else { return r; } }; }, // vector operators -- see below any: function () { var px = arguments; return function (s) { var r = null; for (var i = 0; i < px.length; i++) { if (px[i] == null) { continue; } try { r = (px[i].call(this, s)); } catch (e) { r = null; } if (r) { return r; } } throw new $P.Exception(s); }; }, each: function () { var px = arguments; return function (s) { var rx = [], r = null; for (var i = 0; i < px.length ; i++) { if (px[i] == null) { continue; } try { r = (px[i].call(this, s)); } catch (e) { throw new $P.Exception(s); } rx.push(r[0]); s = r[1]; } return [ rx, s]; }; }, all: function () { var px = arguments, _ = _; return _.each(_.optional(px)); }, // delimited operators sequence: function (px, d, c) { d = d || _.rtoken(/^\s*/); c = c || null; if (px.length === 1) { return px[0]; } return function (s) { var r = null, q = null; var rx = []; for (var i = 0; i < px.length ; i++) { try { r = px[i].call(this, s); } catch (e) { break; } rx.push(r[0]); try { q = d.call(this, r[1]); } catch (ex) { q = null; break; } s = q[1]; } if (!r) { throw new $P.Exception(s); } if (q) { throw new $P.Exception(q[1]); } if (c) { try { r = c.call(this, r[1]); } catch (ey) { throw new $P.Exception(r[1]); } } return [ rx, (r?r[1]:s) ]; }; }, // // Composite Operators // between: function (d1, p, d2) { d2 = d2 || d1; var _fn = _.each(_.ignore(d1), p, _.ignore(d2)); return function (s) { var rx = _fn.call(this, s); return [[rx[0][0], r[0][2]], rx[1]]; }; }, list: function (p, d, c) { d = d || _.rtoken(/^\s*/); c = c || null; return (p instanceof Array ? _.each(_.product(p.slice(0, -1), _.ignore(d)), p.slice(-1), _.ignore(c)) : _.each(_.many(_.each(p, _.ignore(d))), px, _.ignore(c))); }, set: function (px, d, c) { d = d || _.rtoken(/^\s*/); c = c || null; return function (s) { // r is the current match, best the current 'best' match // which means it parsed the most amount of input var r = null, p = null, q = null, rx = null, best = [[], s], last = false; // go through the rules in the given set for (var i = 0; i < px.length ; i++) { // last is a flag indicating whether this must be the last element // if there is only 1 element, then it MUST be the last one q = null; p = null; r = null; last = (px.length === 1); // first, we try simply to match the current pattern // if not, try the next pattern try { r = px[i].call(this, s); } catch (e) { continue; } // since we are matching against a set of elements, the first // thing to do is to add r[0] to matched elements rx = [[r[0]], r[1]]; // if we matched and there is still input to parse and // we don't already know this is the last element, // we're going to next check for the delimiter ... // if there's none, or if there's no input left to parse // than this must be the last element after all ... if (r[1].length > 0 && ! last) { try { q = d.call(this, r[1]); } catch (ex) { last = true; } } else { last = true; } // if we parsed the delimiter and now there's no more input, // that means we shouldn't have parsed the delimiter at all // so don't update r and mark this as the last element ... if (!last && q[1].length === 0) { last = true; } // so, if this isn't the last element, we're going to see if // we can get any more matches from the remaining (unmatched) // elements ... if (!last) { // build a list of the remaining rules we can match against, // i.e., all but the one we just matched against var qx = []; for (var j = 0; j < px.length ; j++) { if (i !== j) { qx.push(px[j]); } } // now invoke recursively set with the remaining input // note that we don't include the closing delimiter ... // we'll check for that ourselves at the end p = _.set(qx, d).call(this, q[1]); // if we got a non-empty set as a result ... // (otw rx already contains everything we want to match) if (p[0].length > 0) { // update current result, which is stored in rx ... // basically, pick up the remaining text from p[1] // and concat the result from p[0] so that we don't // get endless nesting ... rx[0] = rx[0].concat(p[0]); rx[1] = p[1]; } } // at this point, rx either contains the last matched element // or the entire matched set that starts with this element. // now we just check to see if this variation is better than // our best so far, in terms of how much of the input is parsed if (rx[1].length < best[1].length) { best = rx; } // if we've parsed all the input, then we're finished if (best[1].length === 0) { break; } } // so now we've either gone through all the patterns trying them // as the initial match; or we found one that parsed the entire // input string ... // if best has no matches, just return empty set ... if (best[0].length === 0) { return best; } // if a closing delimiter is provided, then we have to check it also if (c) { // we try this even if there is no remaining input because the pattern // may well be optional or match empty input ... try { q = c.call(this, best[1]); } catch (ey) { throw new $P.Exception(best[1]); } // it parsed ... be sure to update the best match remaining input best[1] = q[1]; } // if we're here, either there was no closing delimiter or we parsed it // so now we have the best match; just return it! return best; }; }, forward: function (gr, fname) { return function (s) { return gr[fname].call(this, s); }; }, // // Translation Operators // replace: function (rule, repl) { return function (s) { var r = rule.call(this, s); return [repl, r[1]]; }; }, process: function (rule, fn) { return function (s) { var r = rule.call(this, s); return [fn.call(this, r[0]), r[1]]; }; }, min: function (min, rule) { return function (s) { var rx = rule.call(this, s); if (rx[0].length < min) { throw new $P.Exception(s); } return rx; }; } }; // Generator Operators And Vector Operators // Generators are operators that have a signature of F(R) => R, // taking a given rule and returning another rule, such as // ignore, which parses a given rule and throws away the result. // Vector operators are those that have a signature of F(R1,R2,...) => R, // take a list of rules and returning a new rule, such as each. // Generator operators are converted (via the following _generator // function) into functions that can also take a list or array of rules // and return an array of new rules as though the function had been // called on each rule in turn (which is what actually happens). // This allows generators to be used with vector operators more easily. // Example: // each(ignore(foo, bar)) instead of each(ignore(foo), ignore(bar)) // This also turns generators into vector operators, which allows // constructs like: // not(cache(foo, bar)) var _generator = function (op) { function gen() { var args = null, rx = [], px, i; if (arguments.length > 1) { args = Array.prototype.slice.call(arguments); } else if (arguments[0] instanceof Array) { args = arguments[0]; } if (args) { px = args.shift(); if (px.length > 0) { args.unshift(px[i]); rx.push(op.apply(null, args)); args.shift(); return rx; } } else { return op.apply(null, arguments); } } return gen; }; var gx = "optional not ignore cache".split(/\s/); for (var i = 0 ; i < gx.length ; i++) { _[gx[i]] = _generator(_[gx[i]]); } var _vector = function (op) { return function () { if (arguments[0] instanceof Array) { return op.apply(null, arguments[0]); } else { return op.apply(null, arguments); } }; }; var vx = "each any all".split(/\s/); for (var j = 0 ; j < vx.length ; j++) { _[vx[j]] = _vector(_[vx[j]]); } }()); (function () { var $D = Date; var flattenAndCompact = function (ax) { var rx = []; for (var i = 0; i < ax.length; i++) { if (ax[i] instanceof Array) { rx = rx.concat(flattenAndCompact(ax[i])); } else { if (ax[i]) { rx.push(ax[i]); } } } return rx; }; var parseMeridian = function () { if (this.meridian && (this.hour || this.hour === 0)) { if (this.meridian === "a" && this.hour > 11 && Date.Config.strict24hr){ throw "Invalid hour and meridian combination"; } else if (this.meridian === "p" && this.hour < 12 && Date.Config.strict24hr){ throw "Invalid hour and meridian combination"; } else if (this.meridian === "p" && this.hour < 12) { this.hour = this.hour + 12; } else if (this.meridian === "a" && this.hour === 12) { this.hour = 0; } } }; var setDefaults = function () { var now = new Date(); if ((this.hour || this.minute) && (!this.month && !this.year && !this.day)) { this.day = now.getDate(); } if (!this.year) { this.year = now.getFullYear(); } if (!this.month && this.month !== 0) { this.month = now.getMonth(); } if (!this.day) { this.day = 1; } if (!this.hour) { this.hour = 0; } if (!this.minute) { this.minute = 0; } if (!this.second) { this.second = 0; } if (!this.millisecond) { this.millisecond = 0; } }; var finishUtils = { getToday: function () { if (this.now || "hour minute second".indexOf(this.unit) !== -1) { return new Date(); } else { return $D.today(); } }, setDaysFromWeekday: function (today, orient){ var gap; orient = orient || 1; this.unit = "day"; gap = ($D.getDayNumberFromName(this.weekday) - today.getDay()); this.days = gap ? ((gap + (orient * 7)) % 7) : (orient * 7); return this; }, setMonthsFromMonth: function (today, orient) { var gap; orient = orient || 1; this.unit = "month"; gap = (this.month - today.getMonth()); this.months = gap ? ((gap + (orient * 12)) % 12) : (orient * 12); this.month = null; return this; }, setDMYFromWeekday: function () { var d = Date[this.weekday](); this.day = d.getDate(); if (!this.month) { this.month = d.getMonth(); } this.year = d.getFullYear(); return this; }, setUnitValue: function (orient) { if (!this.value && this.operator && this.operator !== null && this[this.unit + "s"] && this[this.unit + "s"] !== null) { this[this.unit + "s"] = this[this.unit + "s"] + ((this.operator === "add") ? 1 : -1) + (this.value||0) * orient; } else if (this[this.unit + "s"] == null || this.operator != null) { if (!this.value) { this.value = 1; } this[this.unit + "s"] = this.value * orient; } }, generateDateFromWeeks: function () { var weekday = (this.weekday !== undefined) ? this.weekday : "today"; var d = Date[weekday]().addWeeks(this.weeks); if (this.now) { d.setTimeToNow(); } return d; } }; $D.Translator = { hour: function (s) { return function () { this.hour = Number(s); }; }, minute: function (s) { return function () { this.minute = Number(s); }; }, second: function (s) { return function () { this.second = Number(s); }; }, /* for ss.s format */ secondAndMillisecond: function (s) { return function () { var mx = s.match(/^([0-5][0-9])\.([0-9]{1,3})/); this.second = Number(mx[1]); this.millisecond = Number(mx[2]); }; }, meridian: function (s) { return function () { this.meridian = s.slice(0, 1).toLowerCase(); }; }, timezone: function (s) { return function () { var n = s.replace(/[^\d\+\-]/g, ""); if (n.length) { this.timezoneOffset = Number(n); } else { this.timezone = s.toLowerCase(); } }; }, day: function (x) { var s = x[0]; return function () { this.day = Number(s.match(/\d+/)[0]); if (this.day < 1) { throw "invalid day"; } }; }, month: function (s) { return function () { this.month = (s.length === 3) ? "jan feb mar apr may jun jul aug sep oct nov dec".indexOf(s)/4 : Number(s) - 1; if (this.month < 0) { throw "invalid month"; } }; }, year: function (s) { return function () { var n = Number(s); this.year = ((s.length > 2) ? n : (n + (((n + 2000) < Date.CultureInfo.twoDigitYearMax) ? 2000 : 1900))); }; }, rday: function (s) { return function () { switch (s) { case "yesterday": this.days = -1; break; case "tomorrow": this.days = 1; break; case "today": this.days = 0; break; case "now": this.days = 0; this.now = true; break; } }; }, finishExact: function (x) { var d; x = (x instanceof Array) ? x : [x]; for (var i = 0 ; i < x.length ; i++) { if (x[i]) { x[i].call(this); } } setDefaults.call(this); parseMeridian.call(this); if (this.day > $D.getDaysInMonth(this.year, this.month)) { throw new RangeError(this.day + " is not a valid value for days."); } d = new Date(this.year, this.month, this.day, this.hour, this.minute, this.second, this.millisecond); if (this.year < 100) { d.setFullYear(this.year); // means years less that 100 are process correctly. JS will parse it otherwise as 1900-1999. } if (this.timezone) { d.set({ timezone: this.timezone }); } else if (this.timezoneOffset) { d.set({ timezoneOffset: this.timezoneOffset }); } return d; }, finish: function (x) { var today, expression, orient, temp; x = (x instanceof Array) ? flattenAndCompact(x) : [ x ]; if (x.length === 0) { return null; } for (var i = 0 ; i < x.length ; i++) { if (typeof x[i] === "function") { x[i].call(this); } } if (this.now && !this.unit && !this.operator) { return new Date(); } else { today = finishUtils.getToday.call(this); } expression = !!(this.days && this.days !== null || this.orient || this.operator); orient = ((this.orient === "past" || this.operator === "subtract") ? -1 : 1); if (this.month && this.unit === "week") { this.value = this.month + 1; delete this.month; delete this.day; } if ((this.month || this.month === 0) && "year day hour minute second".indexOf(this.unit) !== -1) { if (!this.value) { this.value = this.month + 1; } this.month = null; expression = true; } if (!expression && this.weekday && !this.day && !this.days) { finishUtils.setDMYFromWeekday.call(this); } if (expression && this.weekday && this.unit !== "month" && this.unit !== "week") { finishUtils.setDaysFromWeekday.call(this, today, orient); } if (this.weekday && this.unit !== "week" && !this.day && !this.days) { temp = Date[this.weekday](); this.day = temp.getDate(); if (temp.getMonth() !== today.getMonth()) { this.month = temp.getMonth(); } } if (this.month && this.unit === "day" && this.operator) { if (!this.value) { this.value = (this.month + 1); } this.month = null; } if (this.value != null && this.month != null && this.year != null) { this.day = this.value * 1; } if (this.month && !this.day && this.value) { today.set({ day: this.value * 1 }); if (!expression) { this.day = this.value * 1; } } if (!this.month && this.value && this.unit === "month" && !this.now) { this.month = this.value; expression = true; } if (expression && (this.month || this.month === 0) && this.unit !== "year") { finishUtils.setMonthsFromMonth.call(this, today, orient); } if (!this.unit) { this.unit = "day"; } finishUtils.setUnitValue.call(this, orient); parseMeridian.call(this); if ((this.month || this.month === 0) && !this.day) { this.day = 1; } if (!this.orient && !this.operator && this.unit === "week" && this.value && !this.day && !this.month) { return Date.today().setWeek(this.value); } if (this.unit === "week" && this.weeks && !this.day && !this.month) { return finishUtils.generateDateFromWeeks.call(this); } if (expression && this.timezone && this.day && this.days) { this.day = this.days; } if (expression){ today.add(this); } else { today.set(this); } if (this.timezone) { this.timezone = this.timezone.toUpperCase(); var offset = $D.getTimezoneOffset(this.timezone); var timezone; if (today.hasDaylightSavingTime()) { // lets check that we're being sane with timezone setting timezone = $D.getTimezoneAbbreviation(offset, today.isDaylightSavingTime()); if (timezone !== this.timezone) { // bugger, we're in a place where things like EST vs EDT matters. if (today.isDaylightSavingTime()) { today.addHours(-1); } else { today.addHours(1); } } } today.setTimezoneOffset(offset); } return today; } }; }()); (function () { var $D = Date; $D.Grammar = {}; var _ = $D.Parsing.Operators, g = $D.Grammar, t = $D.Translator, _fn; // Allow rolling up into general purpose rules _fn = function () { return _.each(_.any.apply(null, arguments), _.not(g.ctoken2("timeContext"))); }; g.datePartDelimiter = _.rtoken(/^([\s\-\.\,\/\x27]+)/); g.timePartDelimiter = _.stoken(":"); g.whiteSpace = _.rtoken(/^\s*/); g.generalDelimiter = _.rtoken(/^(([\s\,]|at|@|on)+)/); var _C = {}; g.ctoken = function (keys) { var fn = _C[keys]; if (! fn) { var c = Date.CultureInfo.regexPatterns; var kx = keys.split(/\s+/), px = []; for (var i = 0; i < kx.length ; i++) { px.push(_.replace(_.rtoken(c[kx[i]]), kx[i])); } fn = _C[keys] = _.any.apply(null, px); } return fn; }; g.ctoken2 = function (key) { return _.rtoken(Date.CultureInfo.regexPatterns[key]); }; var cacheProcessRtoken = function (key, token, type, eachToken) { if (eachToken) { g[key] = _.cache(_.process(_.each(_.rtoken(token),_.optional(g.ctoken2(eachToken))), type)); } else { g[key] = _.cache(_.process(_.rtoken(token), type)); } }; var cacheProcessCtoken = function (token, type) { return _.cache(_.process(g.ctoken2(token), type)); }; var _F = {}; //function cache var _get = function (f) { _F[f] = (_F[f] || g.format(f)[0]); return _F[f]; }; g.allformats = function (fx) { var rx = []; if (fx instanceof Array) { for (var i = 0; i < fx.length; i++) { rx.push(_get(fx[i])); } } else { rx.push(_get(fx)); } return rx; }; g.formats = function (fx) { if (fx instanceof Array) { var rx = []; for (var i = 0 ; i < fx.length ; i++) { rx.push(_get(fx[i])); } return _.any.apply(null, rx); } else { return _get(fx); } }; var grammarFormats = { timeFormats: function(){ var i, RTokenKeys = [ "h", "hh", "H", "HH", "m", "mm", "s", "ss", "ss.s", "z", "zz" ], RToken = [ /^(0[0-9]|1[0-2]|[1-9])/, /^(0[0-9]|1[0-2])/, /^([0-1][0-9]|2[0-3]|[0-9])/, /^([0-1][0-9]|2[0-3])/, /^([0-5][0-9]|[0-9])/, /^[0-5][0-9]/, /^([0-5][0-9]|[0-9])/, /^[0-5][0-9]/, /^[0-5][0-9]\.[0-9]{1,3}/, /^((\+|\-)\s*\d\d\d\d)|((\+|\-)\d\d\:?\d\d)/, /^((\+|\-)\s*\d\d\d\d)|((\+|\-)\d\d\:?\d\d)/ ], tokens = [ t.hour, t.hour, t.hour, t.hour, t.minute, t.minute, t.second, t.second, t.secondAndMillisecond, t.timezone, t.timezone ]; for (i=0; i < RTokenKeys.length; i++) { cacheProcessRtoken(RTokenKeys[i], RToken[i], tokens[i]); } g.hms = _.cache(_.sequence([g.H, g.m, g.s], g.timePartDelimiter)); g.t = cacheProcessCtoken("shortMeridian", t.meridian); g.tt = cacheProcessCtoken("longMeridian", t.meridian); g.zzz = cacheProcessCtoken("timezone", t.timezone); g.timeSuffix = _.each(_.ignore(g.whiteSpace), _.set([ g.tt, g.zzz ])); g.time = _.each(_.optional(_.ignore(_.stoken("T"))), g.hms, g.timeSuffix); }, dateFormats: function () { // pre-loaded rules for different date part order preferences var _setfn = function () { return _.set(arguments, g.datePartDelimiter); }; var i, RTokenKeys = [ "d", "dd", "M", "MM", "y", "yy", "yyy", "yyyy" ], RToken = [ /^([0-2]\d|3[0-1]|\d)/, /^([0-2]\d|3[0-1])/, /^(1[0-2]|0\d|\d)/, /^(1[0-2]|0\d)/, /^(\d+)/, /^(\d\d)/, /^(\d\d?\d?\d?)/, /^(\d\d\d\d)/ ], tokens = [ t.day, t.day, t.month, t.month, t.year, t.year, t.year, t.year ], eachToken = [ "ordinalSuffix", "ordinalSuffix" ]; for (i=0; i < RTokenKeys.length; i++) { cacheProcessRtoken(RTokenKeys[i], RToken[i], tokens[i], eachToken[i]); } g.MMM = g.MMMM = _.cache(_.process(g.ctoken("jan feb mar apr may jun jul aug sep oct nov dec"), t.month)); g.ddd = g.dddd = _.cache(_.process(g.ctoken("sun mon tue wed thu fri sat"), function (s) { return function () { this.weekday = s; }; } )); g.day = _fn(g.d, g.dd); g.month = _fn(g.M, g.MMM); g.year = _fn(g.yyyy, g.yy); g.mdy = _setfn(g.ddd, g.month, g.day, g.year); g.ymd = _setfn(g.ddd, g.year, g.month, g.day); g.dmy = _setfn(g.ddd, g.day, g.month, g.year); g.date = function (s) { return ((g[Date.CultureInfo.dateElementOrder] || g.mdy).call(this, s)); }; }, relative: function () { // relative date / time expressions g.orientation = _.process(g.ctoken("past future"), function (s) { return function () { this.orient = s; }; } ); g.operator = _.process(g.ctoken("add subtract"), function (s) { return function () { this.operator = s; }; } ); g.rday = _.process(g.ctoken("yesterday tomorrow today now"), t.rday); g.unit = _.process(g.ctoken("second minute hour day week month year"), function (s) { return function () { this.unit = s; }; } ); } }; g.buildGrammarFormats = function () { // these need to be rebuilt every time the language changes. _C = {}; grammarFormats.timeFormats(); grammarFormats.dateFormats(); grammarFormats.relative(); g.value = _.process(_.rtoken(/^([-+]?\d+)?(st|nd|rd|th)?/), function (s) { return function () { this.value = s.replace(/\D/g, ""); }; } ); g.expression = _.set([g.rday, g.operator, g.value, g.unit, g.orientation, g.ddd, g.MMM ]); g.format = _.process(_.many( _.any( // translate format specifiers into grammar rules _.process( _.rtoken(/^(dd?d?d?(?!e)|MM?M?M?|yy?y?y?|hh?|HH?|mm?|ss?|tt?|zz?z?)/), function (fmt) { if (g[fmt]) { return g[fmt]; } else { throw $D.Parsing.Exception(fmt); } } ), // translate separator tokens into token rules _.process(_.rtoken(/^[^dMyhHmstz]+/), // all legal separators function (s) { return _.ignore(_.stoken(s)); } ) ) ), // construct the parser ... function (rules) { return _.process(_.each.apply(null, rules), t.finishExact); } ); // starting rule for general purpose grammar g._start = _.process(_.set([ g.date, g.time, g.expression ], g.generalDelimiter, g.whiteSpace), t.finish); }; g.buildGrammarFormats(); // parsing date format specifiers - ex: "h:m:s tt" // this little guy will generate a custom parser based // on the format string, ex: g.format("h:m:s tt") // check for these formats first g._formats = g.formats([ "\"yyyy-MM-ddTHH:mm:ssZ\"", "yyyy-MM-ddTHH:mm:ss.sz", "yyyy-MM-ddTHH:mm:ssZ", "yyyy-MM-ddTHH:mm:ssz", "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-ddTHH:mmZ", "yyyy-MM-ddTHH:mmz", "yyyy-MM-ddTHH:mm", "ddd, MMM dd, yyyy H:mm:ss tt", "ddd MMM d yyyy HH:mm:ss zzz", "MMddyyyy", "ddMMyyyy", "Mddyyyy", "ddMyyyy", "Mdyyyy", "dMyyyy", "yyyy", "Mdyy", "dMyy", "d" ]); // real starting rule: tries selected formats first, // then general purpose rule g.start = function (s) { try { var r = g._formats.call({}, s); if (r[1].length === 0) { return r; } } catch (e) {} return g._start.call({}, s); }; }()); (function () { var $D = Date; /** * @desc Converts the specified string value into its JavaScript Date equivalent using CultureInfo specific format information. * * Example

	///////////
	// Dates //
	///////////

	// 15-Oct-2004
	var d1 = Date.parse("10/15/2004");

	// 15-Oct-2004
	var d1 = Date.parse("15-Oct-2004");

	// 15-Oct-2004
	var d1 = Date.parse("2004.10.15");

	//Fri Oct 15, 2004
	var d1 = Date.parse("Fri Oct 15, 2004");

	///////////
	// Times //
	///////////

	// Today at 10 PM.
	var d1 = Date.parse("10 PM");

	// Today at 10:30 PM.
	var d1 = Date.parse("10:30 P.M.");

	// Today at 6 AM.
	var d1 = Date.parse("06am");

	/////////////////////
	// Dates and Times //
	/////////////////////

	// 8-July-2004 @ 10:30 PM
	var d1 = Date.parse("July 8th, 2004, 10:30 PM");

	// 1-July-2004 @ 10:30 PM
	var d1 = Date.parse("2004-07-01T22:30:00");

	////////////////////
	// Relative Dates //
	////////////////////

	// Returns today's date. The string "today" is culture specific.
	var d1 = Date.parse("today");

	// Returns yesterday's date. The string "yesterday" is culture specific.
	var d1 = Date.parse("yesterday");

	// Returns the date of the next thursday.
	var d1 = Date.parse("Next thursday");

	// Returns the date of the most previous monday.
	var d1 = Date.parse("last monday");

	// Returns today's day + one year.
	var d1 = Date.parse("next year");

	///////////////
	// Date Math //
	///////////////

	// Today + 2 days
	var d1 = Date.parse("t+2");

	// Today + 2 days
	var d1 = Date.parse("today + 2 days");

	// Today + 3 months
	var d1 = Date.parse("t+3m");

	// Today - 1 year
	var d1 = Date.parse("today - 1 year");

	// Today - 1 year
	var d1 = Date.parse("t-1y"); 


	/////////////////////////////
	// Partial Dates and Times //
	/////////////////////////////

	// July 15th of this year.
	var d1 = Date.parse("July 15");

	// 15th day of current day and year.
	var d1 = Date.parse("15");

	// July 1st of current year at 10pm.
	var d1 = Date.parse("7/1 10pm");
	
* * @param {String} The string value to convert into a Date object [Required] * @return {Date} A Date object or null if the string cannot be converted into a Date. */ var parseUtils = { removeOrds: function (s) { ords = s.match(/\b(\d+)(?:st|nd|rd|th)\b/); // find ordinal matches s = ((ords && ords.length === 2) ? s.replace(ords[0], ords[1]) : s); return s; }, grammarParser: function (s) { var r = null; try { r = $D.Grammar.start.call({}, s.replace(/^\s*(\S*(\s+\S+)*)\s*$/, "$1")); } catch (e) { return null; } return ((r[1].length === 0) ? r[0] : null); }, nativeFallback: function(s) { var t; try { // ok we haven't parsed it, last ditch attempt with the built-in parser. t = Date._parse(s); return (t || t === 0) ? new Date(t) : null; } catch (e) { return null; } } }; function parse (s) { var d; if (!s) { return null; } if (s instanceof Date) { return s.clone(); } if (s.length >= 4 && s.charAt(0) !== "0" && s.charAt(0) !== "+"&& s.charAt(0) !== "-") { // ie: 2004 will pass, 0800 won't. // Start with specific formats d = $D.Parsing.ISO.parse(s) || $D.Parsing.Numeric.parse(s); } if (d instanceof Date && !isNaN(d.getTime())) { return d; } else { // find ordinal dates (1st, 3rd, 8th, etc and remove them as they cause parsing issues) s = $D.Parsing.Normalizer.parse(parseUtils.removeOrds(s)); d = parseUtils.grammarParser(s); if (d !== null) { return d; } else { return parseUtils.nativeFallback(s); } } } if (!$D._parse) { $D._parse = $D.parse; } $D.parse = parse; Date.getParseFunction = function (fx) { var fns = Date.Grammar.allformats(fx); return function (s) { var r = null; for (var i = 0; i < fns.length; i++) { try { r = fns[i].call({}, s); } catch (e) { continue; } if (r[1].length === 0) { return r[0]; } } return null; }; }; /** * Converts the specified string value into its JavaScript Date equivalent using the specified format {String} or formats {Array} and the CultureInfo specific format information. * The format of the string value must match one of the supplied formats exactly. * * Example

	// 15-Oct-2004
	var d1 = Date.parseExact("10/15/2004", "M/d/yyyy");

	// 15-Oct-2004
	var d1 = Date.parse("15-Oct-2004", "M-ddd-yyyy");

	// 15-Oct-2004
	var d1 = Date.parse("2004.10.15", "yyyy.MM.dd");

	// Multiple formats
	var d1 = Date.parseExact("10/15/2004", ["M/d/yyyy", "MMMM d, yyyy"]);
	
* * @param {String} The string value to convert into a Date object [Required]. * @param {Object} The expected format {String} or an array of expected formats {Array} of the date string [Required]. * @return {Date} A Date object or null if the string cannot be converted into a Date. */ $D.parseExact = function (s, fx) { return $D.getParseFunction(fx)(s); }; }()); (function () { var $D = Date, $P = $D.prototype, // $C = $D.CultureInfo, // not used atm p = function (s, l) { if (!l) { l = 2; } return ("000" + s).slice(l * -1); }; /** * Converts a PHP format string to Java/.NET format string. * A PHP format string can be used with ._format or .format. * A Java/.NET format string can be used with .toString(). * The .parseExact function will only accept a Java/.NET format string * * Example * var f1 = "%m/%d/%y" * var f2 = Date.normalizeFormat(f1); // "MM/dd/yy" * * new Date().format(f1); // "04/13/08" * new Date()._format(f1); // "04/13/08" * new Date().toString(f2); // "04/13/08" * * var date = Date.parseExact("04/13/08", f2); // Sun Apr 13 2008 * * @param {String} A PHP format string consisting of one or more format spcifiers. * @return {String} The PHP format converted to a Java/.NET format string. */ var normalizerSubstitutions = { "d" : "dd", "%d": "dd", "D" : "ddd", "%a": "ddd", "j" : "dddd", "l" : "dddd", "%A": "dddd", "S" : "S", "F" : "MMMM", "%B": "MMMM", "m" : "MM", "%m": "MM", "M" : "MMM", "%b": "MMM", "%h": "MMM", "n" : "M", "Y" : "yyyy", "%Y": "yyyy", "y" : "yy", "%y": "yy", "g" : "h", "%I": "h", "G" : "H", "h" : "hh", "H" : "HH", "%H": "HH", "i" : "mm", "%M": "mm", "s" : "ss", "%S": "ss", "%r": "hh:mm tt", "%R": "H:mm", "%T": "H:mm:ss", "%X": "t", "%x": "d", "%e": "d", "%D": "MM/dd/yy", "%n": "\\n", "%t": "\\t", "e" : "z", "T" : "z", "%z": "z", "%Z": "z", "Z" : "ZZ", "N" : "u", "w" : "u", "%w": "u", "W" : "W", "%V": "W" }; var normalizer = { substitutes: function (m) { return normalizerSubstitutions[m]; }, interpreted: function (m, x) { var y; switch (m) { case "%u": return x.getDay() + 1; case "z": return x.getOrdinalNumber(); case "%j": return p(x.getOrdinalNumber(), 3); case "%U": var d1 = x.clone().set({month: 0, day: 1}).addDays(-1).moveToDayOfWeek(0), d2 = x.clone().addDays(1).moveToDayOfWeek(0, -1); return (d2 < d1) ? "00" : p((d2.getOrdinalNumber() - d1.getOrdinalNumber()) / 7 + 1); case "%W": return p(x.getWeek()); case "t": return $D.getDaysInMonth(x.getFullYear(), x.getMonth()); case "o": case "%G": return x.setWeek(x.getISOWeek()).toString("yyyy"); case "%g": return x._format("%G").slice(-2); case "a": case "%p": return t("tt").toLowerCase(); case "A": return t("tt").toUpperCase(); case "u": return p(x.getMilliseconds(), 3); case "I": return (x.isDaylightSavingTime()) ? 1 : 0; case "O": return x.getUTCOffset(); case "P": y = x.getUTCOffset(); return y.substring(0, y.length - 2) + ":" + y.substring(y.length - 2); case "B": var now = new Date(); return Math.floor(((now.getHours() * 3600) + (now.getMinutes() * 60) + now.getSeconds() + (now.getTimezoneOffset() + 60) * 60) / 86.4); case "c": return x.toISOString().replace(/\"/g, ""); case "U": return $D.strtotime("now"); case "%c": return t("d") + " " + t("t"); case "%C": return Math.floor(x.getFullYear() / 100 + 1); } }, shouldOverrideDefaults: function (m) { switch (m) { case "%e": return true; default: return false; } }, parse: function (m, context) { var formatString, c = context || new Date(); formatString = normalizer.substitutes(m); if (formatString) { return formatString; } formatString = normalizer.interpreted(m, c); if (formatString) { return formatString; } else { return m; } } }; $D.normalizeFormat = function (format, context) { return format.replace(/(%|\\)?.|%%/g, function(t){ return normalizer.parse(t, context); }); }; /** * Format a local Unix timestamp according to locale settings * * Example: * Date.strftime("%m/%d/%y", new Date()); // "04/13/08" * Date.strftime("c", "2008-04-13T17:52:03Z"); // "04/13/08" * * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @param {Number|String} The number representing the number of seconds that have elapsed since January 1, 1970 (local time). * @return {String} A string representation of the current Date object. */ $D.strftime = function (format, time) { var d = Date.parse(time); return d._format(format); }; /** * Parse any textual datetime description into a Unix timestamp. * A Unix timestamp is the number of seconds that have elapsed since January 1, 1970 (midnight UTC/GMT). * * Example: * Date.strtotime("04/13/08"); // 1208044800 * Date.strtotime("1970-01-01T00:00:00Z"); // 0 * * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @param {Object} A string or date object. * @return {String} A string representation of the current Date object. */ $D.strtotime = function (time) { var d = $D.parse(time); return Math.round($D.UTC(d.getUTCFullYear(), d.getUTCMonth(), d.getUTCDate(), d.getUTCHours(), d.getUTCMinutes(), d.getUTCSeconds(), d.getUTCMilliseconds()) / 1000); }; /** * Converts the value of the current Date object to its equivalent string representation using a PHP/Unix style of date format specifiers. * Format Specifiers * Format Description Example * ------ --------------------------------------------------------------------------- ----------------------- * %a abbreviated weekday name according to the current localed "Mon" through "Sun" * %A full weekday name according to the current localed "Sunday" through "Saturday" * %b abbreviated month name according to the current localed "Jan" through "Dec" * %B full month name according to the current locale "January" through "December" * %c preferred date and time representation for the current locale "4/13/2008 12:33 PM" * %C century number (the year divided by 100 and truncated to an integer) "00" to "99" * %d day of the month as a decimal number "01" to "31" * %D same as %m/%d/%y "04/13/08" * %e day of the month as a decimal number, a single digit is preceded by a space "1" to "31" * %g like %G, but without the century "08" * %G The 4-digit year corresponding to the ISO week number (see %V). "2008" * This has the same format and value as %Y, except that if the ISO week number * belongs to the previous or next year, that year is used instead. * %h same as %b "Jan" through "Dec" * %H hour as a decimal number using a 24-hour clock. "00" to "23" * %I hour as a decimal number using a 12-hour clock. "01" to "12" * %j day of the year as a decimal number. "001" to "366" * %m month as a decimal number. "01" to "12" * %M minute as a decimal number. "00" to "59" * %n newline character "\n" * %p either "am" or "pm" according to the given time value, or the "am" or "pm" * corresponding strings for the current locale. * %r time in a.m. and p.m. notation "8:44 PM" * %R time in 24 hour notation "20:44" * %S second as a decimal number "00" to "59" * %t tab character "\t" * %T current time, equal to %H:%M:%S "12:49:11" * %u weekday as a decimal number ["1", "7"], with "1" representing Monday "1" to "7" * %U week number of the current year as a decimal number, starting with the "0" to ("52" or "53") * first Sunday as the first day of the first week * %V The ISO 8601:1988 week number of the current year as a decimal number, "00" to ("52" or "53") * range 01 to 53, where week 1 is the first week that has at least 4 days * in the current year, and with Monday as the first day of the week. * (Use %G or %g for the year component that corresponds to the week number * for the specified timestamp.) * %W week number of the current year as a decimal number, starting with the "00" to ("52" or "53") * first Monday as the first day of the first week * %w day of the week as a decimal, Sunday being "0" "0" to "6" * %x preferred date representation for the current locale without the time "4/13/2008" * %X preferred time representation for the current locale without the date "12:53:05" * %y year as a decimal number without a century "00" "99" * %Y year as a decimal number including the century "2008" * %Z time zone or name or abbreviation "UTC", "EST", "PST" * %z same as %Z * %% a literal "%" characters "%" * d Day of the month, 2 digits with leading zeros "01" to "31" * D A textual representation of a day, three letters "Mon" through "Sun" * j Day of the month without leading zeros "1" to "31" * l A full textual representation of the day of the week (lowercase "L") "Sunday" through "Saturday" * N ISO-8601 numeric representation of the day of the week (added in PHP 5.1.0) "1" (for Monday) through "7" (for Sunday) * S English ordinal suffix for the day of the month, 2 characters "st", "nd", "rd" or "th". Works well with j * w Numeric representation of the day of the week "0" (for Sunday) through "6" (for Saturday) * z The day of the year (starting from "0") "0" through "365" * W ISO-8601 week number of year, weeks starting on Monday "00" to ("52" or "53") * F A full textual representation of a month, such as January or March "January" through "December" * m Numeric representation of a month, with leading zeros "01" through "12" * M A short textual representation of a month, three letters "Jan" through "Dec" * n Numeric representation of a month, without leading zeros "1" through "12" * t Number of days in the given month "28" through "31" * L Whether it's a leap year "1" if it is a leap year, "0" otherwise * o ISO-8601 year number. This has the same value as Y, except that if the "2008" * ISO week number (W) belongs to the previous or next year, that year * is used instead. * Y A full numeric representation of a year, 4 digits "2008" * y A two digit representation of a year "08" * a Lowercase Ante meridiem and Post meridiem "am" or "pm" * A Uppercase Ante meridiem and Post meridiem "AM" or "PM" * B Swatch Internet time "000" through "999" * g 12-hour format of an hour without leading zeros "1" through "12" * G 24-hour format of an hour without leading zeros "0" through "23" * h 12-hour format of an hour with leading zeros "01" through "12" * H 24-hour format of an hour with leading zeros "00" through "23" * i Minutes with leading zeros "00" to "59" * s Seconds, with leading zeros "00" through "59" * u Milliseconds "54321" * e Timezone identifier "UTC", "EST", "PST" * I Whether or not the date is in daylight saving time (uppercase i) "1" if Daylight Saving Time, "0" otherwise * O Difference to Greenwich time (GMT) in hours "+0200", "-0600" * P Difference to Greenwich time (GMT) with colon between hours and minutes "+02:00", "-06:00" * T Timezone abbreviation "UTC", "EST", "PST" * Z Timezone offset in seconds. The offset for timezones west of UTC is "-43200" through "50400" * always negative, and for those east of UTC is always positive. * c ISO 8601 date "2004-02-12T15:19:21+00:00" * r RFC 2822 formatted date "Thu, 21 Dec 2000 16:01:07 +0200" * U Seconds since the Unix Epoch (January 1 1970 00:00:00 GMT) "0" * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @return {String} A string representation of the current Date object. */ var formatReplace = function (context) { return function (m) { var formatString, override = false; if (m.charAt(0) === "\\" || m.substring(0, 2) === "%%") { return m.replace("\\", "").replace("%%", "%"); } override = normalizer.shouldOverrideDefaults(m); formatString = $D.normalizeFormat(m, context); if (formatString) { return context.toString(formatString, override); } }; }; $P._format = function (format) { var formatter = formatReplace(this); if (!format) { return this._toString(); } else { return format.replace(/(%|\\)?.|%%/g, formatter); } }; if (!$P.format) { $P.format = $P._format; } }()); (function () { "use strict"; var gFn = function (attr) { return function () { return this[attr]; }; }; var sFn = function (attr) { return function (val) { this[attr] = val; return this; }; }; var attrs = ["years", "months", "days", "hours", "minutes", "seconds", "milliseconds"]; var addSetFuncs = function (context, attrs) { for (var i = 0; i < attrs.length ; i++) { var $a = attrs[i], $b = $a.slice(0, 1).toUpperCase() + $a.slice(1); context.prototype[$a] = 0; context.prototype["get" + $b] = gFn($a); context.prototype["set" + $b] = sFn($a); } }; /** * new TimeSpan(milliseconds); * new TimeSpan(days, hours, minutes, seconds); * new TimeSpan(days, hours, minutes, seconds, milliseconds); */ var TimeSpan = function (days, hours, minutes, seconds, milliseconds) { if (arguments.length === 1 && typeof days === "number") { var orient = (days < 0) ? -1 : +1; var millsLeft = Math.abs(days); this.setDays(Math.floor(millsLeft / 86400000) * orient); millsLeft = millsLeft % 86400000; this.setHours(Math.floor(millsLeft / 3600000) * orient); millsLeft = millsLeft % 3600000; this.setMinutes(Math.floor(millsLeft / 60000) * orient); millsLeft = millsLeft % 60000; this.setSeconds(Math.floor(millsLeft / 1000) * orient); millsLeft = millsLeft % 1000; this.setMilliseconds(millsLeft * orient); } else { this.set(days, hours, minutes, seconds, milliseconds); } this.getTotalMilliseconds = function () { return (this.getDays() * 86400000) + (this.getHours() * 3600000) + (this.getMinutes() * 60000) + (this.getSeconds() * 1000); }; this.compareTo = function (time) { var t1 = new Date(1970, 1, 1, this.getHours(), this.getMinutes(), this.getSeconds()), t2; if (time === null) { t2 = new Date(1970, 1, 1, 0, 0, 0); } else { t2 = new Date(1970, 1, 1, time.getHours(), time.getMinutes(), time.getSeconds()); } return (t1 < t2) ? -1 : (t1 > t2) ? 1 : 0; }; this.equals = function (time) { return (this.compareTo(time) === 0); }; this.add = function (time) { return (time === null) ? this : this.addSeconds(time.getTotalMilliseconds() / 1000); }; this.subtract = function (time) { return (time === null) ? this : this.addSeconds(-time.getTotalMilliseconds() / 1000); }; this.addDays = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 86400000)); }; this.addHours = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 3600000)); }; this.addMinutes = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 60000)); }; this.addSeconds = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 1000)); }; this.addMilliseconds = function (n) { return new TimeSpan(this.getTotalMilliseconds() + n); }; this.get12HourHour = function () { return (this.getHours() > 12) ? this.getHours() - 12 : (this.getHours() === 0) ? 12 : this.getHours(); }; this.getDesignator = function () { return (this.getHours() < 12) ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator; }; this.toString = function (format) { this._toString = function () { if (this.getDays() !== null && this.getDays() > 0) { return this.getDays() + "." + this.getHours() + ":" + this.p(this.getMinutes()) + ":" + this.p(this.getSeconds()); } else { return this.getHours() + ":" + this.p(this.getMinutes()) + ":" + this.p(this.getSeconds()); } }; this.p = function (s) { return (s.toString().length < 2) ? "0" + s : s; }; var me = this; return format ? format.replace(/dd?|HH?|hh?|mm?|ss?|tt?/g, function (format) { switch (format) { case "d": return me.getDays(); case "dd": return me.p(me.getDays()); case "H": return me.getHours(); case "HH": return me.p(me.getHours()); case "h": return me.get12HourHour(); case "hh": return me.p(me.get12HourHour()); case "m": return me.getMinutes(); case "mm": return me.p(me.getMinutes()); case "s": return me.getSeconds(); case "ss": return me.p(me.getSeconds()); case "t": return ((me.getHours() < 12) ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator).substring(0, 1); case "tt": return (me.getHours() < 12) ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator; } } ) : this._toString(); }; return this; }; addSetFuncs(TimeSpan, attrs.slice(2)); TimeSpan.prototype.set = function (days, hours, minutes, seconds, milliseconds){ this.setDays(days || this.getDays()); this.setHours(hours || this.getHours()); this.setMinutes(minutes || this.getMinutes()); this.setSeconds(seconds || this.getSeconds()); this.setMilliseconds(milliseconds || this.getMilliseconds()); }; /** * Gets the time of day for this date instances. * @return {TimeSpan} TimeSpan */ Date.prototype.getTimeOfDay = function () { return new TimeSpan(0, this.getHours(), this.getMinutes(), this.getSeconds(), this.getMilliseconds()); }; Date.TimeSpan = TimeSpan; if (typeof window !== "undefined" ) { // keeping API compatible for v1.x window.TimeSpan = TimeSpan; } }()); (function () { "use strict"; var attrs = ["years", "months", "days", "hours", "minutes", "seconds", "milliseconds"]; var gFn = function (attr) { return function () { return this[attr]; }; }; var sFn = function (attr) { return function (val) { this[attr] = val; return this; }; }; var addSetFuncs = function (context, attrs) { for (var i = 0; i < attrs.length ; i++) { var $a = attrs[i], $b = $a.slice(0, 1).toUpperCase() + $a.slice(1); context.prototype[$a] = 0; context.prototype["get" + $b] = gFn($a); context.prototype["set" + $b] = sFn($a); } }; var setMonthsAndYears = function (orient, d1, d2, context) { function inc() { d1.addMonths(-orient); context.months++; if (context.months === 12) { context.years++; context.months = 0; } } if (orient === +1) { while (d1 > d2) { inc(); } } else { while (d1 < d2) { inc(); } } context.months--; context.months *= orient; context.years *= orient; }; var adjustForDST = function(orient, startDate, endDate) { var hasDSTMismatch = (false === (startDate.isDaylightSavingTime() === endDate.isDaylightSavingTime())); if (hasDSTMismatch && orient === 1) { startDate.addHours(-1); } else if (hasDSTMismatch) { startDate.addHours(1); } }; /** * TimePeriod(startDate, endDate); * TimePeriod(years, months, days, hours, minutes, seconds, milliseconds); */ var TimePeriod = function (years, months, days, hours, minutes, seconds, milliseconds) { if (arguments.length === 7) { this.set(years, months, days, hours, minutes, seconds, milliseconds); } else if (arguments.length === 2 && arguments[0] instanceof Date && arguments[1] instanceof Date) { var startDate = arguments[0].clone(); var endDate = arguments[1].clone(); var orient = (startDate > endDate) ? +1 : -1; this.dates = { start: arguments[0].clone(), end: arguments[1].clone() }; setMonthsAndYears(orient, startDate, endDate, this); adjustForDST(orient, startDate, endDate); // // TODO - adjust for DST var diff = endDate - startDate; if (diff !== 0) { var ts = new TimeSpan(diff); this.set(this.years, this.months, ts.getDays(), ts.getHours(), ts.getMinutes(), ts.getSeconds(), ts.getMilliseconds()); } } return this; }; // create all the set functions. addSetFuncs(TimePeriod, attrs); TimePeriod.prototype.set = function (years, months, days, hours, minutes, seconds, milliseconds){ this.setYears(years || this.getYears()); this.setMonths(months || this.getMonths()); this.setDays(days || this.getDays()); this.setHours(hours || this.getHours()); this.setMinutes(minutes || this.getMinutes()); this.setSeconds(seconds || this.getSeconds()); this.setMilliseconds(milliseconds || this.getMilliseconds()); }; Date.TimePeriod = TimePeriod; if (typeof window !== "undefined") { // keeping API compatible for v1.x window.TimePeriod = TimePeriod; } }()); ================================================ FILE: build/date-ro-RO.js ================================================ /** * @overview datejs * @version 1.0.0-rc3 * @author Gregory Wild-Smith * @copyright 2015 Gregory Wild-Smith * @license MIT * @homepage https://github.com/abritinthebay/datejs */ /* * DateJS Culture String File * Country Code: ro-RO * Name: Romanian (Romania) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["ro-RO"] = { "name": "ro-RO", "englishName": "Romanian (Romania)", "nativeName": "română (România)", "Sunday": "duminică", "Monday": "luni", "Tuesday": "marţi", "Wednesday": "miercuri", "Thursday": "joi", "Friday": "vineri", "Saturday": "sâmbătă", "Sun": "D", "Mon": "L", "Tue": "Ma", "Wed": "Mi", "Thu": "J", "Fri": "V", "Sat": "S", "Su": "D", "Mo": "L", "Tu": "Ma", "We": "Mi", "Th": "J", "Fr": "V", "Sa": "S", "S_Sun_Initial": "D", "M_Mon_Initial": "L", "T_Tue_Initial": "M", "W_Wed_Initial": "M", "T_Thu_Initial": "J", "F_Fri_Initial": "V", "S_Sat_Initial": "S", "January": "ianuarie", "February": "februarie", "March": "martie", "April": "aprilie", "May": "mai", "June": "iunie", "July": "iulie", "August": "august", "September": "septembrie", "October": "octombrie", "November": "noiembrie", "December": "decembrie", "Jan_Abbr": "ian.", "Feb_Abbr": "feb.", "Mar_Abbr": "mar.", "Apr_Abbr": "apr.", "May_Abbr": "mai.", "Jun_Abbr": "iun.", "Jul_Abbr": "iul.", "Aug_Abbr": "aug.", "Sep_Abbr": "sep.", "Oct_Abbr": "oct.", "Nov_Abbr": "nov.", "Dec_Abbr": "dec.", "AM": "", "PM": "", "firstDayOfWeek": 1, "twoDigitYearMax": 2029, "mdy": "dmy", "M/d/yyyy": "dd.MM.yyyy", "dddd, MMMM dd, yyyy": "d MMMM yyyy", "h:mm tt": "HH:mm", "h:mm:ss tt": "HH:mm:ss", "dddd, MMMM dd, yyyy h:mm:ss tt": "d MMMM yyyy HH:mm:ss", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "d MMMM", "MMMM, yyyy": "MMMM yyyy", "/jan(uary)?/": "ian(.(uarie)?)?", "/feb(ruary)?/": "feb(.(ruarie)?)?", "/mar(ch)?/": "mar(.(tie)?)?", "/apr(il)?/": "apr(.(ilie)?)?", "/may/": "mai(.()?)?", "/jun(e)?/": "iun(.(ie)?)?", "/jul(y)?/": "iul(.(ie)?)?", "/aug(ust)?/": "aug(.(ust)?)?", "/sep(t(ember)?)?/": "sep(.(tembrie)?)?", "/oct(ober)?/": "oct(.(ombrie)?)?", "/nov(ember)?/": "noiembrie", "/dec(ember)?/": "dec(.(embrie)?)?", "/^su(n(day)?)?/": "^duminică", "/^mo(n(day)?)?/": "^luni", "/^tu(e(s(day)?)?)?/": "^marţi", "/^we(d(nesday)?)?/": "^miercuri", "/^th(u(r(s(day)?)?)?)?/": "^joi", "/^fr(i(day)?)?/": "^vineri", "/^sa(t(urday)?)?/": "^sâmbătă", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "ro-RO"; /** * @overview datejs * @version 1.0.0-rc3 * @author Gregory Wild-Smith * @copyright 2015 Gregory Wild-Smith * @license MIT * @homepage https://github.com/abritinthebay/datejs */(function () { var $D = Date; var lang = Date.CultureStrings ? Date.CultureStrings.lang : null; var loggedKeys = {}; // for debug purposes. var getText = { getFromKey: function (key, countryCode) { var output; if (Date.CultureStrings && Date.CultureStrings[countryCode] && Date.CultureStrings[countryCode][key]) { output = Date.CultureStrings[countryCode][key]; } else { output = getText.buildFromDefault(key); } if (key.charAt(0) === "/") { // Assume it's a regex output = getText.buildFromRegex(key, countryCode); } return output; }, getFromObjectValues: function (obj, countryCode) { var key, output = {}; for(key in obj) { if (obj.hasOwnProperty(key)) { output[key] = getText.getFromKey(obj[key], countryCode); } } return output; }, getFromObjectKeys: function (obj, countryCode) { var key, output = {}; for(key in obj) { if (obj.hasOwnProperty(key)) { output[getText.getFromKey(key, countryCode)] = obj[key]; } } return output; }, getFromArray: function (arr, countryCode) { var output = []; for (var i=0; i < arr.length; i++){ if (i in arr) { output[i] = getText.getFromKey(arr[i], countryCode); } } return output; }, buildFromDefault: function (key) { var output, length, split, last; switch(key) { case "name": output = "en-US"; break; case "englishName": output = "English (United States)"; break; case "nativeName": output = "English (United States)"; break; case "twoDigitYearMax": output = 2049; break; case "firstDayOfWeek": output = 0; break; default: output = key; split = key.split("_"); length = split.length; if (length > 1 && key.charAt(0) !== "/") { // if the key isn't a regex and it has a split. last = split[(length - 1)].toLowerCase(); if (last === "initial" || last === "abbr") { output = split[0]; } } break; } return output; }, buildFromRegex: function (key, countryCode) { var output; if (Date.CultureStrings && Date.CultureStrings[countryCode] && Date.CultureStrings[countryCode][key]) { output = new RegExp(Date.CultureStrings[countryCode][key], "i"); } else { output = new RegExp(key.replace(new RegExp("/", "g"),""), "i"); } return output; } }; var shallowMerge = function (obj1, obj2) { for (var attrname in obj2) { if (obj2.hasOwnProperty(attrname)) { obj1[attrname] = obj2[attrname]; } } }; var __ = function (key, language) { var countryCode = (language) ? language : lang; loggedKeys[key] = key; if (typeof key === "object") { if (key instanceof Array) { return getText.getFromArray(key, countryCode); } else { return getText.getFromObjectKeys(key, countryCode); } } else { return getText.getFromKey(key, countryCode); } }; var loadI18nScript = function (code) { // paatterned after jQuery's getScript. var url = Date.Config.i18n + code + ".js"; var head = document.getElementsByTagName("head")[0] || document.documentElement; var script = document.createElement("script"); script.src = url; var completed = false; var events = { done: function (){} // placeholder function }; // Attach handlers for all browsers script.onload = script.onreadystatechange = function() { if ( !completed && (!this.readyState || this.readyState === "loaded" || this.readyState === "complete") ) { events.done(); head.removeChild(script); } }; setTimeout(function() { head.insertBefore(script, head.firstChild); }, 0); // allows return to execute first return { done: function (cb) { events.done = function() { if (cb) { setTimeout(cb,0); } }; } }; }; var buildInfo = { buildFromMethodHash: function (obj) { var key; for(key in obj) { if (obj.hasOwnProperty(key)) { obj[key] = buildInfo[obj[key]](); } } return obj; }, timeZoneDST: function () { var DST = { "CHADT": "+1345", "NZDT": "+1300", "AEDT": "+1100", "ACDT": "+1030", "AZST": "+0500", "IRDT": "+0430", "EEST": "+0300", "CEST": "+0200", "BST": "+0100", "PMDT": "-0200", "ADT": "-0300", "NDT": "-0230", "EDT": "-0400", "CDT": "-0500", "MDT": "-0600", "PDT": "-0700", "AKDT": "-0800", "HADT": "-0900" }; return __(DST); }, timeZoneStandard: function () { var standard = { "LINT": "+1400", "TOT": "+1300", "CHAST": "+1245", "NZST": "+1200", "NFT": "+1130", "SBT": "+1100", "AEST": "+1000", "ACST": "+0930", "JST": "+0900", "CWST": "+0845", "CT": "+0800", "ICT": "+0700", "MMT": "+0630", "BST": "+0600", "NPT": "+0545", "IST": "+0530", "PKT": "+0500", "AFT": "+0430", "MSK": "+0400", "IRST": "+0330", "FET": "+0300", "EET": "+0200", "CET": "+0100", "GMT": "+0000", "UTC": "+0000", "CVT": "-0100", "GST": "-0200", "BRT": "-0300", "NST": "-0330", "AST": "-0400", "EST": "-0500", "CST": "-0600", "MST": "-0700", "PST": "-0800", "AKST": "-0900", "MIT": "-0930", "HST": "-1000", "SST": "-1100", "BIT": "-1200" }; return __(standard); }, timeZones: function (data) { var zone; data.timezones = []; for (zone in data.abbreviatedTimeZoneStandard) { if (data.abbreviatedTimeZoneStandard.hasOwnProperty(zone)) { data.timezones.push({ name: zone, offset: data.abbreviatedTimeZoneStandard[zone]}); } } for (zone in data.abbreviatedTimeZoneDST) { if (data.abbreviatedTimeZoneDST.hasOwnProperty(zone)) { data.timezones.push({ name: zone, offset: data.abbreviatedTimeZoneDST[zone], dst: true}); } } return data.timezones; }, days: function () { return __(["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"]); }, dayAbbr: function () { return __(["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"]); }, dayShortNames: function () { return __(["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"]); }, dayFirstLetters: function () { return __(["S_Sun_Initial", "M_Mon_Initial", "T_Tues_Initial", "W_Wed_Initial", "T_Thu_Initial", "F_Fri_Initial", "S_Sat_Initial"]); }, months: function () { return __(["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"]); }, monthAbbr: function () { return __(["Jan_Abbr", "Feb_Abbr", "Mar_Abbr", "Apr_Abbr", "May_Abbr", "Jun_Abbr", "Jul_Abbr", "Aug_Abbr", "Sep_Abbr", "Oct_Abbr", "Nov_Abbr", "Dec_Abbr"]); }, formatPatterns: function () { return getText.getFromObjectValues({ shortDate: "M/d/yyyy", longDate: "dddd, MMMM dd, yyyy", shortTime: "h:mm tt", longTime: "h:mm:ss tt", fullDateTime: "dddd, MMMM dd, yyyy h:mm:ss tt", sortableDateTime: "yyyy-MM-ddTHH:mm:ss", universalSortableDateTime: "yyyy-MM-dd HH:mm:ssZ", rfc1123: "ddd, dd MMM yyyy HH:mm:ss", monthDay: "MMMM dd", yearMonth: "MMMM, yyyy" }, Date.i18n.currentLanguage()); }, regex: function () { return getText.getFromObjectValues({ inTheMorning: "/( in the )(morn(ing)?)\\b/", thisMorning: "/(this )(morn(ing)?)\\b/", amThisMorning: "/(\b\\d(am)? )(this )(morn(ing)?)/", inTheEvening: "/( in the )(even(ing)?)\\b/", thisEvening: "/(this )(even(ing)?)\\b/", pmThisEvening: "/(\b\\d(pm)? )(this )(even(ing)?)/", jan: "/jan(uary)?/", feb: "/feb(ruary)?/", mar: "/mar(ch)?/", apr: "/apr(il)?/", may: "/may/", jun: "/jun(e)?/", jul: "/jul(y)?/", aug: "/aug(ust)?/", sep: "/sep(t(ember)?)?/", oct: "/oct(ober)?/", nov: "/nov(ember)?/", dec: "/dec(ember)?/", sun: "/^su(n(day)?)?/", mon: "/^mo(n(day)?)?/", tue: "/^tu(e(s(day)?)?)?/", wed: "/^we(d(nesday)?)?/", thu: "/^th(u(r(s(day)?)?)?)?/", fri: "/fr(i(day)?)?/", sat: "/^sa(t(urday)?)?/", future: "/^next/", past: "/^last|past|prev(ious)?/", add: "/^(\\+|aft(er)?|from|hence)/", subtract: "/^(\\-|bef(ore)?|ago)/", yesterday: "/^yes(terday)?/", today: "/^t(od(ay)?)?/", tomorrow: "/^tom(orrow)?/", now: "/^n(ow)?/", millisecond: "/^ms|milli(second)?s?/", second: "/^sec(ond)?s?/", minute: "/^mn|min(ute)?s?/", hour: "/^h(our)?s?/", week: "/^w(eek)?s?/", month: "/^m(onth)?s?/", day: "/^d(ay)?s?/", year: "/^y(ear)?s?/", shortMeridian: "/^(a|p)/", longMeridian: "/^(a\\.?m?\\.?|p\\.?m?\\.?)/", timezone: "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/", ordinalSuffix: "/^\\s*(st|nd|rd|th)/", timeContext: "/^\\s*(\\:|a(?!u|p)|p)/" }, Date.i18n.currentLanguage()); } }; var CultureInfo = function () { var info = getText.getFromObjectValues({ name: "name", englishName: "englishName", nativeName: "nativeName", amDesignator: "AM", pmDesignator: "PM", firstDayOfWeek: "firstDayOfWeek", twoDigitYearMax: "twoDigitYearMax", dateElementOrder: "mdy" }, Date.i18n.currentLanguage()); var constructedInfo = buildInfo.buildFromMethodHash({ dayNames: "days", abbreviatedDayNames: "dayAbbr", shortestDayNames: "dayShortNames", firstLetterDayNames: "dayFirstLetters", monthNames: "months", abbreviatedMonthNames: "monthAbbr", formatPatterns: "formatPatterns", regexPatterns: "regex", abbreviatedTimeZoneDST: "timeZoneDST", abbreviatedTimeZoneStandard: "timeZoneStandard" }); shallowMerge(info, constructedInfo); buildInfo.timeZones(info); return info; }; $D.i18n = { __: function (key, lang) { return __(key, lang); }, currentLanguage: function () { return lang || "en-US"; }, setLanguage: function (code, force, cb) { var async = false; if (force || code === "en-US" || (!!Date.CultureStrings && !!Date.CultureStrings[code])) { lang = code; Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings.lang = code; Date.CultureInfo = new CultureInfo(); } else { if (!(!!Date.CultureStrings && !!Date.CultureStrings[code])) { if (typeof exports !== "undefined" && this.exports !== exports) { // we're in a Node enviroment, load it using require try { require("../i18n/" + code + ".js"); lang = code; Date.CultureStrings.lang = code; Date.CultureInfo = new CultureInfo(); } catch (e) { // var str = "The language for '" + code + "' could not be loaded by Node. It likely does not exist."; throw new Error("The DateJS IETF language tag '" + code + "' could not be loaded by Node. It likely does not exist."); } } else if (Date.Config && Date.Config.i18n) { // we know the location of the files, so lets load them async = true; loadI18nScript(code).done(function(){ lang = code; Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings.lang = code; Date.CultureInfo = new CultureInfo(); $D.Parsing.Normalizer.buildReplaceData(); // because this is async if ($D.Grammar) { $D.Grammar.buildGrammarFormats(); // so we can parse those strings... } if (cb) { setTimeout(cb,0); } }); } else { Date.console.error("The DateJS IETF language tag '" + code + "' is not available and has not been loaded."); return false; } } } $D.Parsing.Normalizer.buildReplaceData(); // rebuild normalizer strings if ($D.Grammar) { $D.Grammar.buildGrammarFormats(); // so we can parse those strings... } if (!async && cb) { setTimeout(cb,0); } }, getLoggedKeys: function () { return loggedKeys; }, updateCultureInfo: function () { Date.CultureInfo = new CultureInfo(); } }; $D.i18n.updateCultureInfo(); // run automatically }()); (function () { var $D = Date, $P = $D.prototype, p = function (s, l) { if (!l) { l = 2; } return ("000" + s).slice(l * -1); }; if (typeof window !== "undefined" && typeof window.console !== "undefined" && typeof window.console.log !== "undefined") { $D.console = console; // used only to raise non-critical errors if available } else { // set mock so we don't give errors. $D.console = { log: function(){}, error: function(){} }; } $D.Config = $D.Config || {}; $D.initOverloads = function() { /** * Overload of Date.now. Allows an alternate call for Date.now where it returns the * current Date as an object rather than just milliseconds since the Unix Epoch. * * Also provides an implementation of now() for browsers (IE<9) that don't have it. * * Backwards compatible so with work with either: * Date.now() [returns ms] * or * Date.now(true) [returns Date] */ if (!$D.now) { $D._now = function now() { return new Date().getTime(); }; } else if (!$D._now) { $D._now = $D.now; } $D.now = function (returnObj) { if (returnObj) { return $D.present(); } else { return $D._now(); } }; if ( !$P.toISOString ) { $P.toISOString = function() { return this.getUTCFullYear() + "-" + p(this.getUTCMonth() + 1) + "-" + p(this.getUTCDate()) + "T" + p(this.getUTCHours()) + ":" + p(this.getUTCMinutes()) + ":" + p(this.getUTCSeconds()) + "." + String( (this.getUTCMilliseconds()/1000).toFixed(3)).slice(2, 5) + "Z"; }; } // private if ( $P._toString === undefined ){ $P._toString = $P.toString; } }; $D.initOverloads(); /** * Gets a date that is set to the current date. The time is set to the start of the day (00:00 or 12:00 AM). * @return {Date} The current date. */ $D.today = function () { return new Date().clearTime(); }; /** * Gets a date that is set to the current date and time (same as new Date, but chainable) * @return {Date} The current date. */ $D.present = function () { return new Date(); }; /** * Compares the first date to the second date and returns an number indication of their relative values. * @param {Date} First Date object to compare [Required]. * @param {Date} Second Date object to compare to [Required]. * @return {Number} -1 = date1 is lessthan date2. 0 = values are equal. 1 = date1 is greaterthan date2. */ $D.compare = function (date1, date2) { if (isNaN(date1) || isNaN(date2)) { throw new Error(date1 + " - " + date2); } else if (date1 instanceof Date && date2 instanceof Date) { return (date1 < date2) ? -1 : (date1 > date2) ? 1 : 0; } else { throw new TypeError(date1 + " - " + date2); } }; /** * Compares the first Date object to the second Date object and returns true if they are equal. * @param {Date} First Date object to compare [Required] * @param {Date} Second Date object to compare to [Required] * @return {Boolean} true if dates are equal. false if they are not equal. */ $D.equals = function (date1, date2) { return (date1.compareTo(date2) === 0); }; /** * Gets the language appropriate day name when given the day number(0-6) * eg - 0 == Sunday * @return {String} The day name */ $D.getDayName = function (n) { return Date.CultureInfo.dayNames[n]; }; /** * Gets the day number (0-6) if given a CultureInfo specific string which is a valid dayName, abbreviatedDayName or shortestDayName (two char). * @param {String} The name of the day (eg. "Monday, "Mon", "tuesday", "tue", "We", "we"). * @return {Number} The day number */ $D.getDayNumberFromName = function (name) { var n = Date.CultureInfo.dayNames, m = Date.CultureInfo.abbreviatedDayNames, o = Date.CultureInfo.shortestDayNames, s = name.toLowerCase(); for (var i = 0; i < n.length; i++) { if (n[i].toLowerCase() === s || m[i].toLowerCase() === s || o[i].toLowerCase() === s) { return i; } } return -1; }; /** * Gets the month number (0-11) if given a Culture Info specific string which is a valid monthName or abbreviatedMonthName. * @param {String} The name of the month (eg. "February, "Feb", "october", "oct"). * @return {Number} The day number */ $D.getMonthNumberFromName = function (name) { var n = Date.CultureInfo.monthNames, m = Date.CultureInfo.abbreviatedMonthNames, s = name.toLowerCase(); for (var i = 0; i < n.length; i++) { if (n[i].toLowerCase() === s || m[i].toLowerCase() === s) { return i; } } return -1; }; /** * Gets the language appropriate month name when given the month number(0-11) * eg - 0 == January * @return {String} The month name */ $D.getMonthName = function (n) { return Date.CultureInfo.monthNames[n]; }; /** * Determines if the current date instance is within a LeapYear. * @param {Number} The year. * @return {Boolean} true if date is within a LeapYear, otherwise false. */ $D.isLeapYear = function (year) { return ((year % 4 === 0 && year % 100 !== 0) || year % 400 === 0); }; /** * Gets the number of days in the month, given a year and month value. Automatically corrects for LeapYear. * @param {Number} The year. * @param {Number} The month (0-11). * @return {Number} The number of days in the month. */ $D.getDaysInMonth = function (year, month) { if (!month && $D.validateMonth(year)) { month = year; year = Date.today().getFullYear(); } return [31, ($D.isLeapYear(year) ? 29 : 28), 31, 30, 31, 30, 31, 31, 30, 31, 30, 31][month]; }; $P.getDaysInMonth = function () { return $D.getDaysInMonth(this.getFullYear(), this.getMonth()); }; $D.getTimezoneAbbreviation = function (offset, dst) { var p, n = (dst || false) ? Date.CultureInfo.abbreviatedTimeZoneDST : Date.CultureInfo.abbreviatedTimeZoneStandard; for (p in n) { if (n.hasOwnProperty(p)) { if (n[p] === offset) { return p; } } } return null; }; $D.getTimezoneOffset = function (name, dst) { var i, a =[], z = Date.CultureInfo.timezones; if (!name) { name = (new Date()).getTimezone();} for (i = 0; i < z.length; i++) { if (z[i].name === name.toUpperCase()) { a.push(i); } } if (!z[a[0]]) { return null; } if (a.length === 1 || !dst) { return z[a[0]].offset; } else { for (i=0; i < a.length; i++) { if (z[a[i]].dst) { return z[a[i]].offset; } } } }; $D.getQuarter = function (d) { d = d || new Date(); // If no date supplied, use today var q = [1,2,3,4]; return q[Math.floor(d.getMonth() / 3)]; // ~~~ is a bitwise op. Faster than Math.floor }; $D.getDaysLeftInQuarter = function (d) { d = d || new Date(); var qEnd = new Date(d); qEnd.setMonth(qEnd.getMonth() + 3 - qEnd.getMonth() % 3, 0); return Math.floor((qEnd - d) / 8.64e7); }; // private var validate = function (n, min, max, name) { name = name ? name : "Object"; if (typeof n === "undefined") { return false; } else if (typeof n !== "number") { throw new TypeError(n + " is not a Number."); } else if (n < min || n > max) { // As failing validation is *not* an exceptional circumstance // lets not throw a RangeError Exception here. // It's semantically correct but it's not sensible. return false; } return true; }; /** * Validates the number is within an acceptable range for milliseconds [0-999]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateMillisecond = function (value) { return validate(value, 0, 999, "millisecond"); }; /** * Validates the number is within an acceptable range for seconds [0-59]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateSecond = function (value) { return validate(value, 0, 59, "second"); }; /** * Validates the number is within an acceptable range for minutes [0-59]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateMinute = function (value) { return validate(value, 0, 59, "minute"); }; /** * Validates the number is within an acceptable range for hours [0-23]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateHour = function (value) { return validate(value, 0, 23, "hour"); }; /** * Validates the number is within an acceptable range for the days in a month [0-MaxDaysInMonth]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateDay = function (value, year, month) { if (year === undefined || year === null || month === undefined || month === null) { return false;} return validate(value, 1, $D.getDaysInMonth(year, month), "day"); }; /** * Validates the number is within an acceptable range for months [0-11]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateWeek = function (value) { return validate(value, 0, 53, "week"); }; /** * Validates the number is within an acceptable range for months [0-11]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateMonth = function (value) { return validate(value, 0, 11, "month"); }; /** * Validates the number is within an acceptable range for years. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateYear = function (value) { /** * Per ECMAScript spec the range of times supported by Date objects is * exactly -100,000,000 days to +100,000,000 days measured relative to * midnight at the beginning of 01 January, 1970 UTC. * This gives a range of 8,640,000,000,000,000 milliseconds to either * side of 01 January, 1970 UTC. * * Earliest possible date: Tue, 20 Apr 271,822 B.C. 00:00:00 UTC * Latest possible date: Sat, 13 Sep 275,760 00:00:00 UTC */ return validate(value, -271822, 275760, "year"); }; $D.validateTimezone = function(value) { var timezones = {"ACDT":1,"ACST":1,"ACT":1,"ADT":1,"AEDT":1,"AEST":1,"AFT":1,"AKDT":1,"AKST":1,"AMST":1,"AMT":1,"ART":1,"AST":1,"AWDT":1,"AWST":1,"AZOST":1,"AZT":1,"BDT":1,"BIOT":1,"BIT":1,"BOT":1,"BRT":1,"BST":1,"BTT":1,"CAT":1,"CCT":1,"CDT":1,"CEDT":1,"CEST":1,"CET":1,"CHADT":1,"CHAST":1,"CHOT":1,"ChST":1,"CHUT":1,"CIST":1,"CIT":1,"CKT":1,"CLST":1,"CLT":1,"COST":1,"COT":1,"CST":1,"CT":1,"CVT":1,"CWST":1,"CXT":1,"DAVT":1,"DDUT":1,"DFT":1,"EASST":1,"EAST":1,"EAT":1,"ECT":1,"EDT":1,"EEDT":1,"EEST":1,"EET":1,"EGST":1,"EGT":1,"EIT":1,"EST":1,"FET":1,"FJT":1,"FKST":1,"FKT":1,"FNT":1,"GALT":1,"GAMT":1,"GET":1,"GFT":1,"GILT":1,"GIT":1,"GMT":1,"GST":1,"GYT":1,"HADT":1,"HAEC":1,"HAST":1,"HKT":1,"HMT":1,"HOVT":1,"HST":1,"ICT":1,"IDT":1,"IOT":1,"IRDT":1,"IRKT":1,"IRST":1,"IST":1,"JST":1,"KGT":1,"KOST":1,"KRAT":1,"KST":1,"LHST":1,"LINT":1,"MAGT":1,"MART":1,"MAWT":1,"MDT":1,"MET":1,"MEST":1,"MHT":1,"MIST":1,"MIT":1,"MMT":1,"MSK":1,"MST":1,"MUT":1,"MVT":1,"MYT":1,"NCT":1,"NDT":1,"NFT":1,"NPT":1,"NST":1,"NT":1,"NUT":1,"NZDT":1,"NZST":1,"OMST":1,"ORAT":1,"PDT":1,"PET":1,"PETT":1,"PGT":1,"PHOT":1,"PHT":1,"PKT":1,"PMDT":1,"PMST":1,"PONT":1,"PST":1,"PYST":1,"PYT":1,"RET":1,"ROTT":1,"SAKT":1,"SAMT":1,"SAST":1,"SBT":1,"SCT":1,"SGT":1,"SLST":1,"SRT":1,"SST":1,"SYOT":1,"TAHT":1,"THA":1,"TFT":1,"TJT":1,"TKT":1,"TLT":1,"TMT":1,"TOT":1,"TVT":1,"UCT":1,"ULAT":1,"UTC":1,"UYST":1,"UYT":1,"UZT":1,"VET":1,"VLAT":1,"VOLT":1,"VOST":1,"VUT":1,"WAKT":1,"WAST":1,"WAT":1,"WEDT":1,"WEST":1,"WET":1,"WST":1,"YAKT":1,"YEKT":1,"Z":1}; return (timezones[value] === 1); }; $D.validateTimezoneOffset= function(value) { // timezones go from +14hrs to -12hrs, the +X hours are negative offsets. return (value > -841 && value < 721); }; }()); (function () { var $D = Date, $P = $D.prototype, p = function (s, l) { if (!l) { l = 2; } return ("000" + s).slice(l * -1); }; var validateConfigObject = function (obj) { var result = {}, self = this, prop, testFunc; testFunc = function (prop, func, value) { if (prop === "day") { var month = (obj.month !== undefined) ? obj.month : self.getMonth(); var year = (obj.year !== undefined) ? obj.year : self.getFullYear(); return $D[func](value, year, month); } else { return $D[func](value); } }; for (prop in obj) { if (Object.prototype.hasOwnProperty.call(obj, prop)) { var func = "validate" + prop.charAt(0).toUpperCase() + prop.slice(1); if ($D[func] && obj[prop] !== null && testFunc(prop, func, obj[prop])) { result[prop] = obj[prop]; } } } return result; }; /** * Resets the time of this Date object to 12:00 AM (00:00), which is the start of the day. * @param {Boolean} .clone() this date instance before clearing Time * @return {Date} this */ $P.clearTime = function () { this.setHours(0); this.setMinutes(0); this.setSeconds(0); this.setMilliseconds(0); return this; }; /** * Resets the time of this Date object to the current time ('now'). * @return {Date} this */ $P.setTimeToNow = function () { var n = new Date(); this.setHours(n.getHours()); this.setMinutes(n.getMinutes()); this.setSeconds(n.getSeconds()); this.setMilliseconds(n.getMilliseconds()); return this; }; /** * Returns a new Date object that is an exact date and time copy of the original instance. * @return {Date} A new Date instance */ $P.clone = function () { return new Date(this.getTime()); }; /** * Compares this instance to a Date object and returns an number indication of their relative values. * @param {Date} Date object to compare [Required] * @return {Number} -1 = this is lessthan date. 0 = values are equal. 1 = this is greaterthan date. */ $P.compareTo = function (date) { return Date.compare(this, date); }; /** * Compares this instance to another Date object and returns true if they are equal. * @param {Date} Date object to compare. If no date to compare, new Date() [now] is used. * @return {Boolean} true if dates are equal. false if they are not equal. */ $P.equals = function (date) { return Date.equals(this, (date !== undefined ? date : new Date())); }; /** * Determines if this instance is between a range of two dates or equal to either the start or end dates. * @param {Date} Start of range [Required] * @param {Date} End of range [Required] * @return {Boolean} true is this is between or equal to the start and end dates, else false */ $P.between = function (start, end) { return this.getTime() >= start.getTime() && this.getTime() <= end.getTime(); }; /** * Determines if this date occurs after the date to compare to. * @param {Date} Date object to compare. If no date to compare, new Date() ("now") is used. * @return {Boolean} true if this date instance is greater than the date to compare to (or "now"), otherwise false. */ $P.isAfter = function (date) { return this.compareTo(date || new Date()) === 1; }; /** * Determines if this date occurs before the date to compare to. * @param {Date} Date object to compare. If no date to compare, new Date() ("now") is used. * @return {Boolean} true if this date instance is less than the date to compare to (or "now"). */ $P.isBefore = function (date) { return (this.compareTo(date || new Date()) === -1); }; /** * Determines if the current Date instance occurs today. * @return {Boolean} true if this date instance is 'today', otherwise false. */ /** * Determines if the current Date instance occurs on the same Date as the supplied 'date'. * If no 'date' to compare to is provided, the current Date instance is compared to 'today'. * @param {date} Date object to compare. If no date to compare, the current Date ("now") is used. * @return {Boolean} true if this Date instance occurs on the same Day as the supplied 'date'. */ $P.isToday = $P.isSameDay = function (date) { return this.clone().clearTime().equals((date || new Date()).clone().clearTime()); }; /** * Adds the specified number of milliseconds to this instance. * @param {Number} The number of milliseconds to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addMilliseconds = function (value) { if (!value) { return this; } this.setTime(this.getTime() + value * 1); return this; }; /** * Adds the specified number of seconds to this instance. * @param {Number} The number of seconds to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addSeconds = function (value) { if (!value) { return this; } return this.addMilliseconds(value * 1000); }; /** * Adds the specified number of seconds to this instance. * @param {Number} The number of seconds to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addMinutes = function (value) { if (!value) { return this; } return this.addMilliseconds(value * 60000); // 60*1000 }; /** * Adds the specified number of hours to this instance. * @param {Number} The number of hours to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addHours = function (value) { if (!value) { return this; } return this.addMilliseconds(value * 3600000); // 60*60*1000 }; /** * Adds the specified number of days to this instance. * @param {Number} The number of days to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addDays = function (value) { if (!value) { return this; } this.setDate(this.getDate() + value * 1); return this; }; /** * Adds the specified number of weekdays (ie - not sat or sun) to this instance. * @param {Number} The number of days to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addWeekdays = function (value) { if (!value) { return this; } var day = this.getDay(); var weeks = (Math.ceil(Math.abs(value)/7)); if (day === 0 || day === 6) { if (value > 0) { this.next().monday(); this.addDays(-1); day = this.getDay(); } } if (value < 0) { while (value < 0) { this.addDays(-1); day = this.getDay(); if (day !== 0 && day !== 6) { value++; } } return this; } else if (value > 5 || (6-day) <= value) { value = value + (weeks * 2); } return this.addDays(value); }; /** * Adds the specified number of weeks to this instance. * @param {Number} The number of weeks to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addWeeks = function (value) { if (!value) { return this; } return this.addDays(value * 7); }; /** * Adds the specified number of months to this instance. * @param {Number} The number of months to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addMonths = function (value) { if (!value) { return this; } var n = this.getDate(); this.setDate(1); this.setMonth(this.getMonth() + value * 1); this.setDate(Math.min(n, $D.getDaysInMonth(this.getFullYear(), this.getMonth()))); return this; }; $P.addQuarters = function (value) { if (!value) { return this; } // note this will take you to the same point in the quarter as you are now. // i.e. - if you are 15 days into the quarter you'll be 15 days into the resulting one. // bonus: this allows adding fractional quarters return this.addMonths(value * 3); }; /** * Adds the specified number of years to this instance. * @param {Number} The number of years to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addYears = function (value) { if (!value) { return this; } return this.addMonths(value * 12); }; /** * Adds (or subtracts) to the value of the years, months, weeks, days, hours, minutes, seconds, milliseconds of the date instance using given configuration object. Positive and Negative values allowed. * Example

	Date.today().add( { days: 1, months: 1 } )

	new Date().add( { years: -1 } )
	
* @param {Object} Configuration object containing attributes (months, days, etc.) * @return {Date} this */ $P.add = function (config) { if (typeof config === "number") { this._orient = config; return this; } var x = config; if (x.day) { // If we should be a different date than today (eg: for 'tomorrow -1d', etc). // Should only effect parsing, not direct usage (eg, Finish and FinishExact) if ((x.day - this.getDate()) !== 0) { this.setDate(x.day); } } if (x.milliseconds) { this.addMilliseconds(x.milliseconds); } if (x.seconds) { this.addSeconds(x.seconds); } if (x.minutes) { this.addMinutes(x.minutes); } if (x.hours) { this.addHours(x.hours); } if (x.weeks) { this.addWeeks(x.weeks); } if (x.months) { this.addMonths(x.months); } if (x.years) { this.addYears(x.years); } if (x.days) { this.addDays(x.days); } return this; }; /** * Get the week number. Week one (1) is the week which contains the first Thursday of the year. Monday is considered the first day of the week. * The .getWeek() function does NOT convert the date to UTC. The local datetime is used. * Please use .getISOWeek() to get the week of the UTC converted date. * @return {Number} 1 to 53 */ $P.getWeek = function (utc) { // Create a copy of this date object var self, target = new Date(this.valueOf()); if (utc) { target.addMinutes(target.getTimezoneOffset()); self = target.clone(); } else { self = this; } // ISO week date weeks start on monday // so correct the day number var dayNr = (self.getDay() + 6) % 7; // ISO 8601 states that week 1 is the week // with the first thursday of that year. // Set the target date to the thursday in the target week target.setDate(target.getDate() - dayNr + 3); // Store the millisecond value of the target date var firstThursday = target.valueOf(); // Set the target to the first thursday of the year // First set the target to january first target.setMonth(0, 1); // Not a thursday? Correct the date to the next thursday if (target.getDay() !== 4) { target.setMonth(0, 1 + ((4 - target.getDay()) + 7) % 7); } // The weeknumber is the number of weeks between the // first thursday of the year and the thursday in the target week return 1 + Math.ceil((firstThursday - target) / 604800000); // 604800000 = 7 * 24 * 3600 * 1000 }; /** * Get the ISO 8601 week number. Week one ("01") is the week which contains the first Thursday of the year. Monday is considered the first day of the week. * The .getISOWeek() function does convert the date to it's UTC value. Please use .getWeek() to get the week of the local date. * @return {String} "01" to "53" */ $P.getISOWeek = function () { return p(this.getWeek(true)); }; /** * Moves the date to Monday of the week set. Week one (1) is the week which contains the first Thursday of the year. * @param {Number} A Number (1 to 53) that represents the week of the year. * @return {Date} this */ $P.setWeek = function (n) { if ((n - this.getWeek()) === 0) { if (this.getDay() !== 1) { return this.moveToDayOfWeek(1, (this.getDay() > 1 ? -1 : 1)); } else { return this; } } else { return this.moveToDayOfWeek(1, (this.getDay() > 1 ? -1 : 1)).addWeeks(n - this.getWeek()); } }; $P.setQuarter = function (qtr) { var month = Math.abs(((qtr-1) * 3) + 1); return this.setMonth(month, 1); }; $P.getQuarter = function () { return Date.getQuarter(this); }; $P.getDaysLeftInQuarter = function () { return Date.getDaysLeftInQuarter(this); }; /** * Moves the date to the next n'th occurrence of the dayOfWeek starting from the beginning of the month. The number (-1) is a magic number and will return the last occurrence of the dayOfWeek in the month. * @param {Number} The dayOfWeek to move to * @param {Number} The n'th occurrence to move to. Use (-1) to return the last occurrence in the month * @return {Date} this */ $P.moveToNthOccurrence = function (dayOfWeek, occurrence) { if (dayOfWeek === "Weekday") { if (occurrence > 0) { this.moveToFirstDayOfMonth(); if (this.is().weekday()) { occurrence -= 1; } } else if (occurrence < 0) { this.moveToLastDayOfMonth(); if (this.is().weekday()) { occurrence += 1; } } else { return this; } return this.addWeekdays(occurrence); } var shift = 0; if (occurrence > 0) { shift = occurrence - 1; } else if (occurrence === -1) { this.moveToLastDayOfMonth(); if (this.getDay() !== dayOfWeek) { this.moveToDayOfWeek(dayOfWeek, -1); } return this; } return this.moveToFirstDayOfMonth().addDays(-1).moveToDayOfWeek(dayOfWeek, +1).addWeeks(shift); }; var moveToN = function (getFunc, addFunc, nVal) { return function (value, orient) { var diff = (value - this[getFunc]() + nVal * (orient || +1)) % nVal; return this[addFunc]((diff === 0) ? diff += nVal * (orient || +1) : diff); }; }; /** * Move to the next or last dayOfWeek based on the orient value. * @param {Number} The dayOfWeek to move to * @param {Number} Forward (+1) or Back (-1). Defaults to +1. [Optional] * @return {Date} this */ $P.moveToDayOfWeek = moveToN("getDay", "addDays", 7); /** * Move to the next or last month based on the orient value. * @param {Number} The month to move to. 0 = January, 11 = December * @param {Number} Forward (+1) or Back (-1). Defaults to +1. [Optional] * @return {Date} this */ $P.moveToMonth = moveToN("getMonth", "addMonths", 12); /** * Get the Ordinate of the current day ("th", "st", "rd"). * @return {String} */ $P.getOrdinate = function () { var num = this.getDate(); return ord(num); }; /** * Get the Ordinal day (numeric day number) of the year, adjusted for leap year. * @return {Number} 1 through 365 (366 in leap years) */ $P.getOrdinalNumber = function () { return Math.ceil((this.clone().clearTime() - new Date(this.getFullYear(), 0, 1)) / 86400000) + 1; }; /** * Get the time zone abbreviation of the current date. * @return {String} The abbreviated time zone name (e.g. "EST") */ $P.getTimezone = function () { return $D.getTimezoneAbbreviation(this.getUTCOffset(), this.isDaylightSavingTime()); }; $P.setTimezoneOffset = function (offset) { var here = this.getTimezoneOffset(), there = Number(offset) * -6 / 10; return (there || there === 0) ? this.addMinutes(there - here) : this; }; $P.setTimezone = function (offset) { return this.setTimezoneOffset($D.getTimezoneOffset(offset)); }; /** * Indicates whether Daylight Saving Time is observed in the current time zone. * @return {Boolean} true|false */ $P.hasDaylightSavingTime = function () { return (Date.today().set({month: 0, day: 1}).getTimezoneOffset() !== Date.today().set({month: 6, day: 1}).getTimezoneOffset()); }; /** * Indicates whether this Date instance is within the Daylight Saving Time range for the current time zone. * @return {Boolean} true|false */ $P.isDaylightSavingTime = function () { return Date.today().set({month: 0, day: 1}).getTimezoneOffset() !== this.getTimezoneOffset(); }; /** * Get the offset from UTC of the current date. * @return {String} The 4-character offset string prefixed with + or - (e.g. "-0500") */ $P.getUTCOffset = function (offset) { var n = (offset || this.getTimezoneOffset()) * -10 / 6, r; if (n < 0) { r = (n - 10000).toString(); return r.charAt(0) + r.substr(2); } else { r = (n + 10000).toString(); return "+" + r.substr(1); } }; /** * Returns the number of milliseconds between this date and date. * @param {Date} Defaults to now * @return {Number} The diff in milliseconds */ $P.getElapsed = function (date) { return (date || new Date()) - this; }; /** * Set the value of year, month, day, hour, minute, second, millisecond of date instance using given configuration object. * Example

	Date.today().set( { day: 20, month: 1 } )

	new Date().set( { millisecond: 0 } )
	
* * @param {Object} Configuration object containing attributes (month, day, etc.) * @return {Date} this */ $P.set = function (config) { config = validateConfigObject.call(this, config); var key; for (key in config) { if (Object.prototype.hasOwnProperty.call(config, key)) { var name = key.charAt(0).toUpperCase() + key.slice(1); var addFunc, getFunc; if (key !== "week" && key !== "month" && key !== "timezone" && key !== "timezoneOffset") { name += "s"; } addFunc = "add" + name; getFunc = "get" + name; if (key === "month") { addFunc = addFunc + "s"; } else if (key === "year"){ getFunc = "getFullYear"; } if (key !== "day" && key !== "timezone" && key !== "timezoneOffset" && key !== "week" && key !== "hour") { this[addFunc](config[key] - this[getFunc]()); } else if ( key === "timezone"|| key === "timezoneOffset" || key === "week" || key === "hour") { this["set"+name](config[key]); } } } // day has to go last because you can't validate the day without first knowing the month if (config.day) { this.addDays(config.day - this.getDate()); } return this; }; /** * Moves the date to the first day of the month. * @return {Date} this */ $P.moveToFirstDayOfMonth = function () { return this.set({ day: 1 }); }; /** * Moves the date to the last day of the month. * @return {Date} this */ $P.moveToLastDayOfMonth = function () { return this.set({ day: $D.getDaysInMonth(this.getFullYear(), this.getMonth())}); }; /** * Converts the value of the current Date object to its equivalent string representation. * Format Specifiers * CUSTOM DATE AND TIME FORMAT STRINGS * Format Description Example * ------ --------------------------------------------------------------------------- ----------------------- * s The seconds of the minute between 0-59. "0" to "59" * ss The seconds of the minute with leading zero if required. "00" to "59" * * m The minute of the hour between 0-59. "0" or "59" * mm The minute of the hour with leading zero if required. "00" or "59" * * h The hour of the day between 1-12. "1" to "12" * hh The hour of the day with leading zero if required. "01" to "12" * * H The hour of the day between 0-23. "0" to "23" * HH The hour of the day with leading zero if required. "00" to "23" * * d The day of the month between 1 and 31. "1" to "31" * dd The day of the month with leading zero if required. "01" to "31" * ddd Abbreviated day name. Date.CultureInfo.abbreviatedDayNames. "Mon" to "Sun" * dddd The full day name. Date.CultureInfo.dayNames. "Monday" to "Sunday" * * M The month of the year between 1-12. "1" to "12" * MM The month of the year with leading zero if required. "01" to "12" * MMM Abbreviated month name. Date.CultureInfo.abbreviatedMonthNames. "Jan" to "Dec" * MMMM The full month name. Date.CultureInfo.monthNames. "January" to "December" * * yy The year as a two-digit number. "99" or "08" * yyyy The full four digit year. "1999" or "2008" * * t Displays the first character of the A.M./P.M. designator. "A" or "P" * Date.CultureInfo.amDesignator or Date.CultureInfo.pmDesignator * tt Displays the A.M./P.M. designator. "AM" or "PM" * Date.CultureInfo.amDesignator or Date.CultureInfo.pmDesignator * * S The ordinal suffix ("st, "nd", "rd" or "th") of the current day. "st, "nd", "rd" or "th" * * STANDARD DATE AND TIME FORMAT STRINGS * Format Description Example *------ --------------------------------------------------------------------------- ----------------------- * d The CultureInfo shortDate Format Pattern "M/d/yyyy" * D The CultureInfo longDate Format Pattern "dddd, MMMM dd, yyyy" * F The CultureInfo fullDateTime Format Pattern "dddd, MMMM dd, yyyy h:mm:ss tt" * m The CultureInfo monthDay Format Pattern "MMMM dd" * r The CultureInfo rfc1123 Format Pattern "ddd, dd MMM yyyy HH:mm:ss GMT" * s The CultureInfo sortableDateTime Format Pattern "yyyy-MM-ddTHH:mm:ss" * t The CultureInfo shortTime Format Pattern "h:mm tt" * T The CultureInfo longTime Format Pattern "h:mm:ss tt" * u The CultureInfo universalSortableDateTime Format Pattern "yyyy-MM-dd HH:mm:ssZ" * y The CultureInfo yearMonth Format Pattern "MMMM, yyyy" * * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @return {String} A string representation of the current Date object. */ var ord = function (n) { switch (n * 1) { case 1: case 21: case 31: return "st"; case 2: case 22: return "nd"; case 3: case 23: return "rd"; default: return "th"; } }; var parseStandardFormats = function (format) { var y, c = Date.CultureInfo.formatPatterns; switch (format) { case "d": return this.toString(c.shortDate); case "D": return this.toString(c.longDate); case "F": return this.toString(c.fullDateTime); case "m": return this.toString(c.monthDay); case "r": case "R": y = this.clone().addMinutes(this.getTimezoneOffset()); return y.toString(c.rfc1123) + " GMT"; case "s": return this.toString(c.sortableDateTime); case "t": return this.toString(c.shortTime); case "T": return this.toString(c.longTime); case "u": y = this.clone().addMinutes(this.getTimezoneOffset()); return y.toString(c.universalSortableDateTime); case "y": return this.toString(c.yearMonth); default: return false; } }; var parseFormatStringsClosure = function (context) { return function (m) { if (m.charAt(0) === "\\") { return m.replace("\\", ""); } switch (m) { case "hh": return p(context.getHours() < 13 ? (context.getHours() === 0 ? 12 : context.getHours()) : (context.getHours() - 12)); case "h": return context.getHours() < 13 ? (context.getHours() === 0 ? 12 : context.getHours()) : (context.getHours() - 12); case "HH": return p(context.getHours()); case "H": return context.getHours(); case "mm": return p(context.getMinutes()); case "m": return context.getMinutes(); case "ss": return p(context.getSeconds()); case "s": return context.getSeconds(); case "yyyy": return p(context.getFullYear(), 4); case "yy": return p(context.getFullYear()); case "y": return context.getFullYear(); case "E": case "dddd": return Date.CultureInfo.dayNames[context.getDay()]; case "ddd": return Date.CultureInfo.abbreviatedDayNames[context.getDay()]; case "dd": return p(context.getDate()); case "d": return context.getDate(); case "MMMM": return Date.CultureInfo.monthNames[context.getMonth()]; case "MMM": return Date.CultureInfo.abbreviatedMonthNames[context.getMonth()]; case "MM": return p((context.getMonth() + 1)); case "M": return context.getMonth() + 1; case "t": return context.getHours() < 12 ? Date.CultureInfo.amDesignator.substring(0, 1) : Date.CultureInfo.pmDesignator.substring(0, 1); case "tt": return context.getHours() < 12 ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator; case "S": return ord(context.getDate()); case "W": return context.getWeek(); case "WW": return context.getISOWeek(); case "Q": return "Q" + context.getQuarter(); case "q": return String(context.getQuarter()); case "z": return context.getTimezone(); case "Z": case "X": return Date.getTimezoneOffset(context.getTimezone()); case "ZZ": // Timezone offset in seconds return context.getTimezoneOffset() * -60; case "u": return context.getDay(); case "L": return ($D.isLeapYear(context.getFullYear())) ? 1 : 0; case "B": // Swatch Internet Time (.beats) return "@"+((context.getUTCSeconds() + (context.getUTCMinutes()*60) + ((context.getUTCHours()+1)*3600))/86.4); default: return m; } }; }; $P.toString = function (format, ignoreStandards) { // Standard Date and Time Format Strings. Formats pulled from CultureInfo file and // may vary by culture. if (!ignoreStandards && format && format.length === 1) { output = parseStandardFormats.call(this, format); if (output) { return output; } } var parseFormatStrings = parseFormatStringsClosure(this); return format ? format.replace(/((\\)?(dd?d?d?|MM?M?M?|yy?y?y?|hh?|HH?|mm?|ss?|tt?|S|q|Q|WW?W?W?)(?![^\[]*\]))/g, parseFormatStrings).replace(/\[|\]/g, "") : this._toString(); }; }()); /************************************************************* * SugarPak - Domain Specific Language - Syntactical Sugar * *************************************************************/ (function () { var $D = Date, $P = $D.prototype, $N = Number.prototype; // private $P._orient = +1; // private $P._nth = null; // private $P._is = false; // private $P._same = false; // private $P._isSecond = false; // private $N._dateElement = "days"; /** * Moves the date to the next instance of a date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.today().next().friday();
	Date.today().next().fri();
	Date.today().next().march();
	Date.today().next().mar();
	Date.today().next().week();
	
* * @return {Date} date */ $P.next = function () { this._move = true; this._orient = +1; return this; }; /** * Creates a new Date (Date.today()) and moves the date to the next instance of the date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.next().friday();
	Date.next().fri();
	Date.next().march();
	Date.next().mar();
	Date.next().week();
	
* * @return {Date} date */ $D.next = function () { return $D.today().next(); }; /** * Moves the date to the previous instance of a date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.today().last().friday();
	Date.today().last().fri();
	Date.today().last().march();
	Date.today().last().mar();
	Date.today().last().week();
	
* * @return {Date} date */ $P.last = $P.prev = $P.previous = function () { this._move = true; this._orient = -1; return this; }; /** * Creates a new Date (Date.today()) and moves the date to the previous instance of the date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.last().friday();
	Date.last().fri();
	Date.previous().march();
	Date.prev().mar();
	Date.last().week();
	
* * @return {Date} date */ $D.last = $D.prev = $D.previous = function () { return $D.today().last(); }; /** * Performs a equality check when followed by either a month name, day name or .weekday() function. * Example

	Date.today().is().friday(); // true|false
	Date.today().is().fri();
	Date.today().is().march();
	Date.today().is().mar();
	
* * @return {Boolean} true|false */ $P.is = function () { this._is = true; return this; }; /** * Determines if two date objects occur on/in exactly the same instance of the subsequent date part function. * The function .same() must be followed by a date part function (example: .day(), .month(), .year(), etc). * * An optional Date can be passed in the date part function. If now date is passed as a parameter, 'Now' is used. * * The following example demonstrates how to determine if two dates fall on the exact same day. * * Example

	var d1 = Date.today(); // today at 00:00
	var d2 = new Date();   // exactly now.

	// Do they occur on the same day?
	d1.same().day(d2); // true
	
	// Do they occur on the same hour?
	d1.same().hour(d2); // false, unless d2 hour is '00' (midnight).
	
	// What if it's the same day, but one year apart?
	var nextYear = Date.today().add(1).year();

	d1.same().day(nextYear); // false, because the dates must occur on the exact same day. 
	
* * Scenario: Determine if a given date occurs during some week period 2 months from now. * * Example

	var future = Date.today().add(2).months();
	return someDate.same().week(future); // true|false;
	
* * @return {Boolean} true|false */ $P.same = function () { this._same = true; this._isSecond = false; return this; }; /** * Determines if the current date/time occurs during Today. Must be preceded by the .is() function. * Example

	someDate.is().today();    // true|false
	new Date().is().today();  // true
	Date.today().is().today();// true
	Date.today().add(-1).day().is().today(); // false
	
* * @return {Boolean} true|false */ $P.today = function () { return this.same().day(); }; /** * Determines if the current date is a weekday. This function must be preceded by the .is() function. * Example

	Date.today().is().weekday(); // true|false
	
* * @return {Boolean} true|false */ $P.weekday = function () { if (this._nth) { return df("Weekday").call(this); } if (this._move) { return this.addWeekdays(this._orient); } if (this._is) { this._is = false; return (!this.is().sat() && !this.is().sun()); } return false; }; /** * Determines if the current date is on the weekend. This function must be preceded by the .is() function. * Example

	Date.today().is().weekend(); // true|false
	
* * @return {Boolean} true|false */ $P.weekend = function () { if (this._is) { this._is = false; return (this.is().sat() || this.is().sun()); } return false; }; /** * Sets the Time of the current Date instance. A string "6:15 pm" or config object {hour:18, minute:15} are accepted. * Example

	// Set time to 6:15pm with a String
	Date.today().at("6:15pm");

	// Set time to 6:15pm with a config object
	Date.today().at({hour:18, minute:15});
	
* * @return {Date} date */ $P.at = function (time) { return (typeof time === "string") ? $D.parse(this.toString("d") + " " + time) : this.set(time); }; /** * Creates a new Date() and adds this (Number) to the date based on the preceding date element function (eg. second|minute|hour|day|month|year). * Example

	// Undeclared Numbers must be wrapped with parentheses. Requirment of JavaScript.
	(3).days().fromNow();
	(6).months().fromNow();

	// Declared Number variables do not require parentheses. 
	var n = 6;
	n.months().fromNow();
	
* * @return {Date} A new Date instance */ $N.fromNow = $N.after = function (date) { var c = {}; c[this._dateElement] = this; return ((!date) ? new Date() : date.clone()).add(c); }; /** * Creates a new Date() and subtract this (Number) from the date based on the preceding date element function (eg. second|minute|hour|day|month|year). * Example

	// Undeclared Numbers must be wrapped with parentheses. Requirment of JavaScript.
	(3).days().ago();
	(6).months().ago();

	// Declared Number variables do not require parentheses. 
	var n = 6;
	n.months().ago();
	
* * @return {Date} A new Date instance */ $N.ago = $N.before = function (date) { var c = {}, s = (this._dateElement[this._dateElement.length-1] !== "s") ? this._dateElement + "s" : this._dateElement; c[s] = this * -1; return ((!date) ? new Date() : date.clone()).add(c); }; // Do NOT modify the following string tokens. These tokens are used to build dynamic functions. // All culture-specific strings can be found in the CultureInfo files. var dx = ("sunday monday tuesday wednesday thursday friday saturday").split(/\s/), mx = ("january february march april may june july august september october november december").split(/\s/), px = ("Millisecond Second Minute Hour Day Week Month Year Quarter Weekday").split(/\s/), pxf = ("Milliseconds Seconds Minutes Hours Date Week Month FullYear Quarter").split(/\s/), nth = ("final first second third fourth fifth").split(/\s/), de; /** * Returns an object literal of all the date parts. * Example

	var o = new Date().toObject();
	
	// { year: 2008, month: 4, week: 20, day: 13, hour: 18, minute: 9, second: 32, millisecond: 812 }
	
	// The object properties can be referenced directly from the object.
	
	alert(o.day);  // alerts "13"
	alert(o.year); // alerts "2008"
	
* * @return {Date} An object literal representing the original date object. */ $P.toObject = function () { var o = {}; for (var i = 0; i < px.length; i++) { if (this["get" + pxf[i]]) { o[px[i].toLowerCase()] = this["get" + pxf[i]](); } } return o; }; /** * Returns a date created from an object literal. Ignores the .week property if set in the config. * Example

	var o = new Date().toObject();
	
	return Date.fromObject(o); // will return the same date. 

	var o2 = {month: 1, day: 20, hour: 18}; // birthday party!
	Date.fromObject(o2);
	
* * @return {Date} An object literal representing the original date object. */ $D.fromObject = function(config) { config.week = null; return Date.today().set(config); }; // Create day name functions and abbreviated day name functions (eg. monday(), friday(), fri()). var df = function (n) { return function () { if (this._is) { this._is = false; return this.getDay() === n; } if (this._move) { this._move = null; } if (this._nth !== null) { // If the .second() function was called earlier, remove the _orient // from the date, and then continue. // This is required because 'second' can be used in two different context. // // Example // // Date.today().add(1).second(); // Date.march().second().monday(); // // Things get crazy with the following... // Date.march().add(1).second().second().monday(); // but it works!! // if (this._isSecond) { this.addSeconds(this._orient * -1); } // make sure we reset _isSecond this._isSecond = false; var ntemp = this._nth; this._nth = null; var temp = this.clone().moveToLastDayOfMonth(); this.moveToNthOccurrence(n, ntemp); if (this > temp) { throw new RangeError($D.getDayName(n) + " does not occur " + ntemp + " times in the month of " + $D.getMonthName(temp.getMonth()) + " " + temp.getFullYear() + "."); } return this; } return this.moveToDayOfWeek(n, this._orient); }; }; var sdf = function (n) { return function () { var t = $D.today(), shift = n - t.getDay(); if (n === 0 && Date.CultureInfo.firstDayOfWeek === 1 && t.getDay() !== 0) { shift = shift + 7; } return t.addDays(shift); }; }; // Create month name functions and abbreviated month name functions (eg. january(), march(), mar()). var month_instance_functions = function (n) { return function () { if (this._is) { this._is = false; return this.getMonth() === n; } return this.moveToMonth(n, this._orient); }; }; var month_static_functions = function (n) { return function () { return $D.today().set({ month: n, day: 1 }); }; }; var processTerms = function (names, staticFunc, instanceFunc) { for (var i = 0; i < names.length; i++) { // Create constant static Name variables. $D[names[i].toUpperCase()] = $D[names[i].toUpperCase().substring(0, 3)] = i; // Create Name functions. $D[names[i]] = $D[names[i].substring(0, 3)] = staticFunc(i); // Create Name instance functions. $P[names[i]] = $P[names[i].substring(0, 3)] = instanceFunc(i); } }; processTerms(dx, sdf, df); processTerms(mx, month_static_functions, month_instance_functions); // Create date element functions and plural date element functions used with Date (eg. day(), days(), months()). var ef = function (j) { return function () { // if the .second() function was called earlier, the _orient // has alread been added. Just return this and reset _isSecond. if (this._isSecond) { this._isSecond = false; return this; } if (this._same) { this._same = this._is = false; var o1 = this.toObject(), o2 = (arguments[0] || new Date()).toObject(), v = "", k = j.toLowerCase(); // the substr trick with -1 doesn't work in IE8 or less k = (k[k.length-1] === "s") ? k.substring(0,k.length-1) : k; for (var m = (px.length - 1); m > -1; m--) { v = px[m].toLowerCase(); if (o1[v] !== o2[v]) { return false; } if (k === v) { break; } } return true; } if (j.substring(j.length - 1) !== "s") { j += "s"; } if (this._move) { this._move = null; } return this["add" + j](this._orient); }; }; var nf = function (n) { return function () { this._dateElement = n; return this; }; }; for (var k = 0; k < px.length; k++) { de = px[k].toLowerCase(); if(de !== "weekday") { // Create date element functions and plural date element functions used with Date (eg. day(), days(), months()). $P[de] = $P[de + "s"] = ef(px[k]); // Create date element functions and plural date element functions used with Number (eg. day(), days(), months()). $N[de] = $N[de + "s"] = nf(de + "s"); } } $P._ss = ef("Second"); var nthfn = function (n) { return function (dayOfWeek) { if (this._same) { return this._ss(arguments[0]); } if (dayOfWeek || dayOfWeek === 0) { return this.moveToNthOccurrence(dayOfWeek, n); } this._nth = n; // if the operator is 'second' add the _orient, then deal with it later... if (n === 2 && (dayOfWeek === undefined || dayOfWeek === null)) { this._isSecond = true; return this.addSeconds(this._orient); } return this; }; }; for (var l = 0; l < nth.length; l++) { $P[nth[l]] = (l === 0) ? nthfn(-1) : nthfn(l); } }()); (function () { "use strict"; Date.Parsing = { Exception: function (s) { this.message = "Parse error at '" + s.substring(0, 10) + " ...'"; } }; var $P = Date.Parsing; var dayOffsets = { standard: [0,31,59,90,120,151,181,212,243,273,304,334], leap: [0,31,60,91,121,152,182,213,244,274,305,335] }; $P.isLeapYear = function(year) { return ((year % 4 === 0) && (year % 100 !== 0)) || (year % 400 === 0); }; var utils = { multiReplace : function (str, hash ) { var key; for (key in hash) { if (Object.prototype.hasOwnProperty.call(hash, key)) { var regex; if (typeof hash[key] === "function") { } else { regex = (hash[key] instanceof RegExp) ? hash[key] : new RegExp(hash[key], "g"); } str = str.replace(regex, key); } } return str; }, getDayOfYearFromWeek : function (obj) { var d, jan4, offset; obj.weekDay = (!obj.weekDay && obj.weekDay !== 0) ? 1 : obj.weekDay; d = new Date(obj.year, 0, 4); jan4 = d.getDay() === 0 ? 7 : d.getDay(); // JS is 0 indexed on Sunday. offset = jan4+3; obj.dayOfYear = ((obj.week * 7) + (obj.weekDay === 0 ? 7 : obj.weekDay))-offset; return obj; }, getDayOfYear : function (obj, dayOffset) { if (!obj.dayOfYear) { obj = utils.getDayOfYearFromWeek(obj); } for (var i=0;i <= dayOffset.length;i++) { if (obj.dayOfYear < dayOffset[i] || i === dayOffset.length) { obj.day = obj.day ? obj.day : (obj.dayOfYear - dayOffset[i-1]); break; } else { obj.month = i; } } return obj; }, adjustForTimeZone : function (obj, date) { var offset; if (obj.zone.toUpperCase() === "Z" || (obj.zone_hours === 0 && obj.zone_minutes === 0)) { // it's UTC/GML so work out the current timeszone offset offset = -date.getTimezoneOffset(); } else { offset = (obj.zone_hours*60) + (obj.zone_minutes || 0); if (obj.zone_sign === "+") { offset *= -1; } offset -= date.getTimezoneOffset(); } date.setMinutes(date.getMinutes()+offset); return date; }, setDefaults : function (obj) { obj.year = obj.year || Date.today().getFullYear(); obj.hours = obj.hours || 0; obj.minutes = obj.minutes || 0; obj.seconds = obj.seconds || 0; obj.milliseconds = obj.milliseconds || 0; if (!(!obj.month && (obj.week || obj.dayOfYear))) { // if we have a month, or if we don't but don't have the day calculation data obj.month = obj.month || 0; obj.day = obj.day || 1; } return obj; }, dataNum: function (data, mod, explict, postProcess) { var dataNum = data*1; if (mod) { if (postProcess) { return data ? mod(data)*1 : data; } else { return data ? mod(dataNum) : data; } } else if (!explict){ return data ? dataNum : data; } else { return (data && typeof data !== "undefined") ? dataNum : data; } }, timeDataProcess: function (obj) { var timeObj = {}; for (var x in obj.data) { if (obj.data.hasOwnProperty(x)) { timeObj[x] = obj.ignore[x] ? obj.data[x] : utils.dataNum(obj.data[x], obj.mods[x], obj.explict[x], obj.postProcess[x]); } } if (obj.data.secmins) { obj.data.secmins = obj.data.secmins.replace(",", ".") * 60; if (!timeObj.minutes) { timeObj.minutes = obj.data.secmins; } else if (!timeObj.seconds) { timeObj.seconds = obj.data.secmins; } delete obj.secmins; } return timeObj; }, buildTimeObjectFromData: function (data) { var time = utils.timeDataProcess({ data: { year : data[1], month : data[5], day : data[7], week : data[8], dayOfYear : data[10], hours : data[15], zone_hours : data[23], zone_minutes : data[24], zone : data[21], zone_sign : data[22], weekDay : data[9], minutes: data[16], seconds: data[19], milliseconds: data[20], secmins: data[18] }, mods: { month: function(data) { return data-1; }, weekDay: function (data) { data = Math.abs(data); return (data === 7 ? 0 : data); }, minutes: function (data) { return data.replace(":",""); }, seconds: function (data) { return Math.floor( (data.replace(":","").replace(",","."))*1 ); }, milliseconds: function (data) { return (data.replace(",",".")*1000); } }, postProcess: { minutes: true, seconds: true, milliseconds: true }, explict: { zone_hours: true, zone_minutes: true }, ignore: { zone: true, zone_sign: true, secmins: true } }); return time; }, addToHash: function (hash, keys, data) { keys = keys; data = data; var len = keys.length; for (var i = 0; i < len; i++) { hash[keys[i]] = data[i]; } return hash; }, combineRegex: function (r1, r2) { return new RegExp("(("+r1.source+")\\s("+r2.source+"))"); }, getDateNthString: function(add, last, inc){ if (add) { return Date.today().addDays(inc).toString("d"); } else if (last) { return Date.today().last()[inc]().toString("d"); } }, buildRegexData: function (array) { var arr = []; var len = array.length; for (var i=0; i < len; i++) { if (Object.prototype.toString.call(array[i]) === '[object Array]') { // oldIE compat version of Array.isArray arr.push(this.combineRegex(array[i][0], array[i][1])); } else { arr.push(array[i]); } } return arr; } }; $P.processTimeObject = function (obj) { var date, dayOffset; utils.setDefaults(obj); dayOffset = ($P.isLeapYear(obj.year)) ? dayOffsets.leap : dayOffsets.standard; if (!obj.month && (obj.week || obj.dayOfYear)) { utils.getDayOfYear(obj, dayOffset); } else { obj.dayOfYear = dayOffset[obj.month] + obj.day; } date = new Date(obj.year, obj.month, obj.day, obj.hours, obj.minutes, obj.seconds, obj.milliseconds); if (obj.zone) { utils.adjustForTimeZone(obj, date); // adjust (and calculate) for timezone } return date; }; $P.ISO = { regex : /^([\+-]?\d{4}(?!\d{2}\b))((-?)((0[1-9]|1[0-2])(\3([12]\d|0[1-9]|3[01]))?|W([0-4]\d|5[0-3])(-?[1-7])?|(00[1-9]|0[1-9]\d|[12]\d{2}|3([0-5]\d|6[1-6])))([T\s]((([01]\d|2[0-4])((:?)[0-5]\d)?|24\:?00)([\.,]\d+(?!:))?)?(\17[0-5]\d([\.,]\d+)?)?\s?([zZ]|([\+-])([01]\d|2[0-3]):?([0-5]\d)?)?)?)?$/, parse : function (s) { var time, data = s.match(this.regex); if (!data || !data.length) { return null; } time = utils.buildTimeObjectFromData(data); if (!time.year || (!time.year && (!time.month && !time.day) && (!time.week && !time.dayOfYear)) ) { return null; } return $P.processTimeObject(time); } }; $P.Numeric = { isNumeric: function (e){return!isNaN(parseFloat(e))&&isFinite(e);}, regex: /\b([0-1]?[0-9])([0-3]?[0-9])([0-2]?[0-9]?[0-9][0-9])\b/i, parse: function (s) { var data, i, time = {}, order = Date.CultureInfo.dateElementOrder.split(""); if (!(this.isNumeric(s)) || // if it's non-numeric OR (s[0] === "+" && s[0] === "-")) { // It's an arithmatic string (eg +/-1000) return null; } if (s.length < 5 && s.indexOf(".") < 0 && s.indexOf("/") < 0) { // assume it's just a year. time.year = s; return $P.processTimeObject(time); } data = s.match(this.regex); if (!data || !data.length) { return null; } for (i=0; i < order.length; i++) { switch(order[i]) { case "d": time.day = data[i+1]; break; case "m": time.month = (data[i+1]-1); break; case "y": time.year = data[i+1]; break; } } return $P.processTimeObject(time); } }; $P.Normalizer = { regexData: function () { var $R = Date.CultureInfo.regexPatterns; return utils.buildRegexData([ $R.tomorrow, $R.yesterday, [$R.past, $R.mon], [$R.past, $R.tue], [$R.past, $R.wed], [$R.past, $R.thu], [$R.past, $R.fri], [$R.past, $R.sat], [$R.past, $R.sun] ]); }, basicReplaceHash : function() { var $R = Date.CultureInfo.regexPatterns; return { "January": $R.jan.source, "February": $R.feb, "March": $R.mar, "April": $R.apr, "May": $R.may, "June": $R.jun, "July": $R.jul, "August": $R.aug, "September": $R.sep, "October": $R.oct, "November": $R.nov, "December": $R.dec, "": /\bat\b/gi, " ": /\s{2,}/, "am": $R.inTheMorning, "9am": $R.thisMorning, "pm": $R.inTheEvening, "7pm":$R.thisEvening }; }, keys : function(){ return [ utils.getDateNthString(true, false, 1), // tomorrow utils.getDateNthString(true, false, -1), // yesterday utils.getDateNthString(false, true, "monday"), //last mon utils.getDateNthString(false, true, "tuesday"), //last tues utils.getDateNthString(false, true, "wednesday"), //last wed utils.getDateNthString(false, true, "thursday"), //last thurs utils.getDateNthString(false, true, "friday"), //last fri utils.getDateNthString(false, true, "saturday"), //last sat utils.getDateNthString(false, true, "sunday") //last sun ]; }, buildRegexFunctions: function () { var $R = Date.CultureInfo.regexPatterns; var __ = Date.i18n.__; var tomorrowRE = new RegExp("(\\b\\d\\d?("+__("AM")+"|"+__("PM")+")? )("+$R.tomorrow.source.slice(1)+")", "i"); // adapted tomorrow regex for AM PM relative dates var todayRE = new RegExp($R.today.source + "(?!\\s*([+-]))\\b"); // today, but excludes the math operators (eg "today + 2h") this.replaceFuncs = [ [todayRE, function (full) { return (full.length > 1) ? Date.today().toString("d") : full; }], [tomorrowRE, function(full, m1) { var t = Date.today().addDays(1).toString("d"); return (t + " " + m1); }], [$R.amThisMorning, function(str, am){return am;}], [$R.pmThisEvening, function(str, pm){return pm;}] ]; }, buildReplaceData: function () { this.buildRegexFunctions(); this.replaceHash = utils.addToHash(this.basicReplaceHash(), this.keys(), this.regexData()); }, stringReplaceFuncs: function (s) { for (var i=0; i < this.replaceFuncs.length; i++) { s = s.replace(this.replaceFuncs[i][0], this.replaceFuncs[i][1]); } return s; }, parse: function (s) { s = this.stringReplaceFuncs(s); s = utils.multiReplace(s, this.replaceHash); try { var n = s.split(/([\s\-\.\,\/\x27]+)/); if (n.length === 3 && $P.Numeric.isNumeric(n[0]) && $P.Numeric.isNumeric(n[2]) && (n[2].length >= 4)) { // ok, so we're dealing with x/year. But that's not a full date. // This fixes wonky dateElementOrder parsing when set to dmy order. if (Date.CultureInfo.dateElementOrder[0] === "d") { s = "1/" + n[0] + "/" + n[2]; // set to 1st of month and normalize the seperator } } } catch (e) {} return s; } }; $P.Normalizer.buildReplaceData(); }()); (function () { var $P = Date.Parsing; var _ = $P.Operators = { // // Tokenizers // rtoken: function (r) { // regex token return function (s) { var mx = s.match(r); if (mx) { return ([ mx[0], s.substring(mx[0].length) ]); } else { throw new $P.Exception(s); } }; }, token: function () { // whitespace-eating token return function (s) { return _.rtoken(new RegExp("^\\s*" + s + "\\s*"))(s); }; }, stoken: function (s) { // string token return _.rtoken(new RegExp("^" + s)); }, // Atomic Operators until: function (p) { return function (s) { var qx = [], rx = null; while (s.length) { try { rx = p.call(this, s); } catch (e) { qx.push(rx[0]); s = rx[1]; continue; } break; } return [ qx, s ]; }; }, many: function (p) { return function (s) { var rx = [], r = null; while (s.length) { try { r = p.call(this, s); } catch (e) { return [ rx, s ]; } rx.push(r[0]); s = r[1]; } return [ rx, s ]; }; }, // generator operators -- see below optional: function (p) { return function (s) { var r = null; try { r = p.call(this, s); } catch (e) { return [ null, s ]; } return [ r[0], r[1] ]; }; }, not: function (p) { return function (s) { try { p.call(this, s); } catch (e) { return [null, s]; } throw new $P.Exception(s); }; }, ignore: function (p) { return p ? function (s) { var r = null; r = p.call(this, s); return [null, r[1]]; } : null; }, product: function () { var px = arguments[0], qx = Array.prototype.slice.call(arguments, 1), rx = []; for (var i = 0 ; i < px.length ; i++) { rx.push(_.each(px[i], qx)); } return rx; }, cache: function (rule) { var cache = {}, cache_length = 0, cache_keys = [], CACHE_MAX = Date.Config.CACHE_MAX || 100000, r = null; var cacheCheck = function () { if (cache_length === CACHE_MAX) { // kill several keys, don't want to have to do this all the time... for (var i=0; i < 10; i++) { var key = cache_keys.shift(); if (key) { delete cache[key]; cache_length--; } } } }; return function (s) { cacheCheck(); try { r = cache[s] = (cache[s] || rule.call(this, s)); } catch (e) { r = cache[s] = e; } cache_length++; cache_keys.push(s); if (r instanceof $P.Exception) { throw r; } else { return r; } }; }, // vector operators -- see below any: function () { var px = arguments; return function (s) { var r = null; for (var i = 0; i < px.length; i++) { if (px[i] == null) { continue; } try { r = (px[i].call(this, s)); } catch (e) { r = null; } if (r) { return r; } } throw new $P.Exception(s); }; }, each: function () { var px = arguments; return function (s) { var rx = [], r = null; for (var i = 0; i < px.length ; i++) { if (px[i] == null) { continue; } try { r = (px[i].call(this, s)); } catch (e) { throw new $P.Exception(s); } rx.push(r[0]); s = r[1]; } return [ rx, s]; }; }, all: function () { var px = arguments, _ = _; return _.each(_.optional(px)); }, // delimited operators sequence: function (px, d, c) { d = d || _.rtoken(/^\s*/); c = c || null; if (px.length === 1) { return px[0]; } return function (s) { var r = null, q = null; var rx = []; for (var i = 0; i < px.length ; i++) { try { r = px[i].call(this, s); } catch (e) { break; } rx.push(r[0]); try { q = d.call(this, r[1]); } catch (ex) { q = null; break; } s = q[1]; } if (!r) { throw new $P.Exception(s); } if (q) { throw new $P.Exception(q[1]); } if (c) { try { r = c.call(this, r[1]); } catch (ey) { throw new $P.Exception(r[1]); } } return [ rx, (r?r[1]:s) ]; }; }, // // Composite Operators // between: function (d1, p, d2) { d2 = d2 || d1; var _fn = _.each(_.ignore(d1), p, _.ignore(d2)); return function (s) { var rx = _fn.call(this, s); return [[rx[0][0], r[0][2]], rx[1]]; }; }, list: function (p, d, c) { d = d || _.rtoken(/^\s*/); c = c || null; return (p instanceof Array ? _.each(_.product(p.slice(0, -1), _.ignore(d)), p.slice(-1), _.ignore(c)) : _.each(_.many(_.each(p, _.ignore(d))), px, _.ignore(c))); }, set: function (px, d, c) { d = d || _.rtoken(/^\s*/); c = c || null; return function (s) { // r is the current match, best the current 'best' match // which means it parsed the most amount of input var r = null, p = null, q = null, rx = null, best = [[], s], last = false; // go through the rules in the given set for (var i = 0; i < px.length ; i++) { // last is a flag indicating whether this must be the last element // if there is only 1 element, then it MUST be the last one q = null; p = null; r = null; last = (px.length === 1); // first, we try simply to match the current pattern // if not, try the next pattern try { r = px[i].call(this, s); } catch (e) { continue; } // since we are matching against a set of elements, the first // thing to do is to add r[0] to matched elements rx = [[r[0]], r[1]]; // if we matched and there is still input to parse and // we don't already know this is the last element, // we're going to next check for the delimiter ... // if there's none, or if there's no input left to parse // than this must be the last element after all ... if (r[1].length > 0 && ! last) { try { q = d.call(this, r[1]); } catch (ex) { last = true; } } else { last = true; } // if we parsed the delimiter and now there's no more input, // that means we shouldn't have parsed the delimiter at all // so don't update r and mark this as the last element ... if (!last && q[1].length === 0) { last = true; } // so, if this isn't the last element, we're going to see if // we can get any more matches from the remaining (unmatched) // elements ... if (!last) { // build a list of the remaining rules we can match against, // i.e., all but the one we just matched against var qx = []; for (var j = 0; j < px.length ; j++) { if (i !== j) { qx.push(px[j]); } } // now invoke recursively set with the remaining input // note that we don't include the closing delimiter ... // we'll check for that ourselves at the end p = _.set(qx, d).call(this, q[1]); // if we got a non-empty set as a result ... // (otw rx already contains everything we want to match) if (p[0].length > 0) { // update current result, which is stored in rx ... // basically, pick up the remaining text from p[1] // and concat the result from p[0] so that we don't // get endless nesting ... rx[0] = rx[0].concat(p[0]); rx[1] = p[1]; } } // at this point, rx either contains the last matched element // or the entire matched set that starts with this element. // now we just check to see if this variation is better than // our best so far, in terms of how much of the input is parsed if (rx[1].length < best[1].length) { best = rx; } // if we've parsed all the input, then we're finished if (best[1].length === 0) { break; } } // so now we've either gone through all the patterns trying them // as the initial match; or we found one that parsed the entire // input string ... // if best has no matches, just return empty set ... if (best[0].length === 0) { return best; } // if a closing delimiter is provided, then we have to check it also if (c) { // we try this even if there is no remaining input because the pattern // may well be optional or match empty input ... try { q = c.call(this, best[1]); } catch (ey) { throw new $P.Exception(best[1]); } // it parsed ... be sure to update the best match remaining input best[1] = q[1]; } // if we're here, either there was no closing delimiter or we parsed it // so now we have the best match; just return it! return best; }; }, forward: function (gr, fname) { return function (s) { return gr[fname].call(this, s); }; }, // // Translation Operators // replace: function (rule, repl) { return function (s) { var r = rule.call(this, s); return [repl, r[1]]; }; }, process: function (rule, fn) { return function (s) { var r = rule.call(this, s); return [fn.call(this, r[0]), r[1]]; }; }, min: function (min, rule) { return function (s) { var rx = rule.call(this, s); if (rx[0].length < min) { throw new $P.Exception(s); } return rx; }; } }; // Generator Operators And Vector Operators // Generators are operators that have a signature of F(R) => R, // taking a given rule and returning another rule, such as // ignore, which parses a given rule and throws away the result. // Vector operators are those that have a signature of F(R1,R2,...) => R, // take a list of rules and returning a new rule, such as each. // Generator operators are converted (via the following _generator // function) into functions that can also take a list or array of rules // and return an array of new rules as though the function had been // called on each rule in turn (which is what actually happens). // This allows generators to be used with vector operators more easily. // Example: // each(ignore(foo, bar)) instead of each(ignore(foo), ignore(bar)) // This also turns generators into vector operators, which allows // constructs like: // not(cache(foo, bar)) var _generator = function (op) { function gen() { var args = null, rx = [], px, i; if (arguments.length > 1) { args = Array.prototype.slice.call(arguments); } else if (arguments[0] instanceof Array) { args = arguments[0]; } if (args) { px = args.shift(); if (px.length > 0) { args.unshift(px[i]); rx.push(op.apply(null, args)); args.shift(); return rx; } } else { return op.apply(null, arguments); } } return gen; }; var gx = "optional not ignore cache".split(/\s/); for (var i = 0 ; i < gx.length ; i++) { _[gx[i]] = _generator(_[gx[i]]); } var _vector = function (op) { return function () { if (arguments[0] instanceof Array) { return op.apply(null, arguments[0]); } else { return op.apply(null, arguments); } }; }; var vx = "each any all".split(/\s/); for (var j = 0 ; j < vx.length ; j++) { _[vx[j]] = _vector(_[vx[j]]); } }()); (function () { var $D = Date; var flattenAndCompact = function (ax) { var rx = []; for (var i = 0; i < ax.length; i++) { if (ax[i] instanceof Array) { rx = rx.concat(flattenAndCompact(ax[i])); } else { if (ax[i]) { rx.push(ax[i]); } } } return rx; }; var parseMeridian = function () { if (this.meridian && (this.hour || this.hour === 0)) { if (this.meridian === "a" && this.hour > 11 && Date.Config.strict24hr){ throw "Invalid hour and meridian combination"; } else if (this.meridian === "p" && this.hour < 12 && Date.Config.strict24hr){ throw "Invalid hour and meridian combination"; } else if (this.meridian === "p" && this.hour < 12) { this.hour = this.hour + 12; } else if (this.meridian === "a" && this.hour === 12) { this.hour = 0; } } }; var setDefaults = function () { var now = new Date(); if ((this.hour || this.minute) && (!this.month && !this.year && !this.day)) { this.day = now.getDate(); } if (!this.year) { this.year = now.getFullYear(); } if (!this.month && this.month !== 0) { this.month = now.getMonth(); } if (!this.day) { this.day = 1; } if (!this.hour) { this.hour = 0; } if (!this.minute) { this.minute = 0; } if (!this.second) { this.second = 0; } if (!this.millisecond) { this.millisecond = 0; } }; var finishUtils = { getToday: function () { if (this.now || "hour minute second".indexOf(this.unit) !== -1) { return new Date(); } else { return $D.today(); } }, setDaysFromWeekday: function (today, orient){ var gap; orient = orient || 1; this.unit = "day"; gap = ($D.getDayNumberFromName(this.weekday) - today.getDay()); this.days = gap ? ((gap + (orient * 7)) % 7) : (orient * 7); return this; }, setMonthsFromMonth: function (today, orient) { var gap; orient = orient || 1; this.unit = "month"; gap = (this.month - today.getMonth()); this.months = gap ? ((gap + (orient * 12)) % 12) : (orient * 12); this.month = null; return this; }, setDMYFromWeekday: function () { var d = Date[this.weekday](); this.day = d.getDate(); if (!this.month) { this.month = d.getMonth(); } this.year = d.getFullYear(); return this; }, setUnitValue: function (orient) { if (!this.value && this.operator && this.operator !== null && this[this.unit + "s"] && this[this.unit + "s"] !== null) { this[this.unit + "s"] = this[this.unit + "s"] + ((this.operator === "add") ? 1 : -1) + (this.value||0) * orient; } else if (this[this.unit + "s"] == null || this.operator != null) { if (!this.value) { this.value = 1; } this[this.unit + "s"] = this.value * orient; } }, generateDateFromWeeks: function () { var weekday = (this.weekday !== undefined) ? this.weekday : "today"; var d = Date[weekday]().addWeeks(this.weeks); if (this.now) { d.setTimeToNow(); } return d; } }; $D.Translator = { hour: function (s) { return function () { this.hour = Number(s); }; }, minute: function (s) { return function () { this.minute = Number(s); }; }, second: function (s) { return function () { this.second = Number(s); }; }, /* for ss.s format */ secondAndMillisecond: function (s) { return function () { var mx = s.match(/^([0-5][0-9])\.([0-9]{1,3})/); this.second = Number(mx[1]); this.millisecond = Number(mx[2]); }; }, meridian: function (s) { return function () { this.meridian = s.slice(0, 1).toLowerCase(); }; }, timezone: function (s) { return function () { var n = s.replace(/[^\d\+\-]/g, ""); if (n.length) { this.timezoneOffset = Number(n); } else { this.timezone = s.toLowerCase(); } }; }, day: function (x) { var s = x[0]; return function () { this.day = Number(s.match(/\d+/)[0]); if (this.day < 1) { throw "invalid day"; } }; }, month: function (s) { return function () { this.month = (s.length === 3) ? "jan feb mar apr may jun jul aug sep oct nov dec".indexOf(s)/4 : Number(s) - 1; if (this.month < 0) { throw "invalid month"; } }; }, year: function (s) { return function () { var n = Number(s); this.year = ((s.length > 2) ? n : (n + (((n + 2000) < Date.CultureInfo.twoDigitYearMax) ? 2000 : 1900))); }; }, rday: function (s) { return function () { switch (s) { case "yesterday": this.days = -1; break; case "tomorrow": this.days = 1; break; case "today": this.days = 0; break; case "now": this.days = 0; this.now = true; break; } }; }, finishExact: function (x) { var d; x = (x instanceof Array) ? x : [x]; for (var i = 0 ; i < x.length ; i++) { if (x[i]) { x[i].call(this); } } setDefaults.call(this); parseMeridian.call(this); if (this.day > $D.getDaysInMonth(this.year, this.month)) { throw new RangeError(this.day + " is not a valid value for days."); } d = new Date(this.year, this.month, this.day, this.hour, this.minute, this.second, this.millisecond); if (this.year < 100) { d.setFullYear(this.year); // means years less that 100 are process correctly. JS will parse it otherwise as 1900-1999. } if (this.timezone) { d.set({ timezone: this.timezone }); } else if (this.timezoneOffset) { d.set({ timezoneOffset: this.timezoneOffset }); } return d; }, finish: function (x) { var today, expression, orient, temp; x = (x instanceof Array) ? flattenAndCompact(x) : [ x ]; if (x.length === 0) { return null; } for (var i = 0 ; i < x.length ; i++) { if (typeof x[i] === "function") { x[i].call(this); } } if (this.now && !this.unit && !this.operator) { return new Date(); } else { today = finishUtils.getToday.call(this); } expression = !!(this.days && this.days !== null || this.orient || this.operator); orient = ((this.orient === "past" || this.operator === "subtract") ? -1 : 1); if (this.month && this.unit === "week") { this.value = this.month + 1; delete this.month; delete this.day; } if ((this.month || this.month === 0) && "year day hour minute second".indexOf(this.unit) !== -1) { if (!this.value) { this.value = this.month + 1; } this.month = null; expression = true; } if (!expression && this.weekday && !this.day && !this.days) { finishUtils.setDMYFromWeekday.call(this); } if (expression && this.weekday && this.unit !== "month" && this.unit !== "week") { finishUtils.setDaysFromWeekday.call(this, today, orient); } if (this.weekday && this.unit !== "week" && !this.day && !this.days) { temp = Date[this.weekday](); this.day = temp.getDate(); if (temp.getMonth() !== today.getMonth()) { this.month = temp.getMonth(); } } if (this.month && this.unit === "day" && this.operator) { if (!this.value) { this.value = (this.month + 1); } this.month = null; } if (this.value != null && this.month != null && this.year != null) { this.day = this.value * 1; } if (this.month && !this.day && this.value) { today.set({ day: this.value * 1 }); if (!expression) { this.day = this.value * 1; } } if (!this.month && this.value && this.unit === "month" && !this.now) { this.month = this.value; expression = true; } if (expression && (this.month || this.month === 0) && this.unit !== "year") { finishUtils.setMonthsFromMonth.call(this, today, orient); } if (!this.unit) { this.unit = "day"; } finishUtils.setUnitValue.call(this, orient); parseMeridian.call(this); if ((this.month || this.month === 0) && !this.day) { this.day = 1; } if (!this.orient && !this.operator && this.unit === "week" && this.value && !this.day && !this.month) { return Date.today().setWeek(this.value); } if (this.unit === "week" && this.weeks && !this.day && !this.month) { return finishUtils.generateDateFromWeeks.call(this); } if (expression && this.timezone && this.day && this.days) { this.day = this.days; } if (expression){ today.add(this); } else { today.set(this); } if (this.timezone) { this.timezone = this.timezone.toUpperCase(); var offset = $D.getTimezoneOffset(this.timezone); var timezone; if (today.hasDaylightSavingTime()) { // lets check that we're being sane with timezone setting timezone = $D.getTimezoneAbbreviation(offset, today.isDaylightSavingTime()); if (timezone !== this.timezone) { // bugger, we're in a place where things like EST vs EDT matters. if (today.isDaylightSavingTime()) { today.addHours(-1); } else { today.addHours(1); } } } today.setTimezoneOffset(offset); } return today; } }; }()); (function () { var $D = Date; $D.Grammar = {}; var _ = $D.Parsing.Operators, g = $D.Grammar, t = $D.Translator, _fn; // Allow rolling up into general purpose rules _fn = function () { return _.each(_.any.apply(null, arguments), _.not(g.ctoken2("timeContext"))); }; g.datePartDelimiter = _.rtoken(/^([\s\-\.\,\/\x27]+)/); g.timePartDelimiter = _.stoken(":"); g.whiteSpace = _.rtoken(/^\s*/); g.generalDelimiter = _.rtoken(/^(([\s\,]|at|@|on)+)/); var _C = {}; g.ctoken = function (keys) { var fn = _C[keys]; if (! fn) { var c = Date.CultureInfo.regexPatterns; var kx = keys.split(/\s+/), px = []; for (var i = 0; i < kx.length ; i++) { px.push(_.replace(_.rtoken(c[kx[i]]), kx[i])); } fn = _C[keys] = _.any.apply(null, px); } return fn; }; g.ctoken2 = function (key) { return _.rtoken(Date.CultureInfo.regexPatterns[key]); }; var cacheProcessRtoken = function (key, token, type, eachToken) { if (eachToken) { g[key] = _.cache(_.process(_.each(_.rtoken(token),_.optional(g.ctoken2(eachToken))), type)); } else { g[key] = _.cache(_.process(_.rtoken(token), type)); } }; var cacheProcessCtoken = function (token, type) { return _.cache(_.process(g.ctoken2(token), type)); }; var _F = {}; //function cache var _get = function (f) { _F[f] = (_F[f] || g.format(f)[0]); return _F[f]; }; g.allformats = function (fx) { var rx = []; if (fx instanceof Array) { for (var i = 0; i < fx.length; i++) { rx.push(_get(fx[i])); } } else { rx.push(_get(fx)); } return rx; }; g.formats = function (fx) { if (fx instanceof Array) { var rx = []; for (var i = 0 ; i < fx.length ; i++) { rx.push(_get(fx[i])); } return _.any.apply(null, rx); } else { return _get(fx); } }; var grammarFormats = { timeFormats: function(){ var i, RTokenKeys = [ "h", "hh", "H", "HH", "m", "mm", "s", "ss", "ss.s", "z", "zz" ], RToken = [ /^(0[0-9]|1[0-2]|[1-9])/, /^(0[0-9]|1[0-2])/, /^([0-1][0-9]|2[0-3]|[0-9])/, /^([0-1][0-9]|2[0-3])/, /^([0-5][0-9]|[0-9])/, /^[0-5][0-9]/, /^([0-5][0-9]|[0-9])/, /^[0-5][0-9]/, /^[0-5][0-9]\.[0-9]{1,3}/, /^((\+|\-)\s*\d\d\d\d)|((\+|\-)\d\d\:?\d\d)/, /^((\+|\-)\s*\d\d\d\d)|((\+|\-)\d\d\:?\d\d)/ ], tokens = [ t.hour, t.hour, t.hour, t.hour, t.minute, t.minute, t.second, t.second, t.secondAndMillisecond, t.timezone, t.timezone ]; for (i=0; i < RTokenKeys.length; i++) { cacheProcessRtoken(RTokenKeys[i], RToken[i], tokens[i]); } g.hms = _.cache(_.sequence([g.H, g.m, g.s], g.timePartDelimiter)); g.t = cacheProcessCtoken("shortMeridian", t.meridian); g.tt = cacheProcessCtoken("longMeridian", t.meridian); g.zzz = cacheProcessCtoken("timezone", t.timezone); g.timeSuffix = _.each(_.ignore(g.whiteSpace), _.set([ g.tt, g.zzz ])); g.time = _.each(_.optional(_.ignore(_.stoken("T"))), g.hms, g.timeSuffix); }, dateFormats: function () { // pre-loaded rules for different date part order preferences var _setfn = function () { return _.set(arguments, g.datePartDelimiter); }; var i, RTokenKeys = [ "d", "dd", "M", "MM", "y", "yy", "yyy", "yyyy" ], RToken = [ /^([0-2]\d|3[0-1]|\d)/, /^([0-2]\d|3[0-1])/, /^(1[0-2]|0\d|\d)/, /^(1[0-2]|0\d)/, /^(\d+)/, /^(\d\d)/, /^(\d\d?\d?\d?)/, /^(\d\d\d\d)/ ], tokens = [ t.day, t.day, t.month, t.month, t.year, t.year, t.year, t.year ], eachToken = [ "ordinalSuffix", "ordinalSuffix" ]; for (i=0; i < RTokenKeys.length; i++) { cacheProcessRtoken(RTokenKeys[i], RToken[i], tokens[i], eachToken[i]); } g.MMM = g.MMMM = _.cache(_.process(g.ctoken("jan feb mar apr may jun jul aug sep oct nov dec"), t.month)); g.ddd = g.dddd = _.cache(_.process(g.ctoken("sun mon tue wed thu fri sat"), function (s) { return function () { this.weekday = s; }; } )); g.day = _fn(g.d, g.dd); g.month = _fn(g.M, g.MMM); g.year = _fn(g.yyyy, g.yy); g.mdy = _setfn(g.ddd, g.month, g.day, g.year); g.ymd = _setfn(g.ddd, g.year, g.month, g.day); g.dmy = _setfn(g.ddd, g.day, g.month, g.year); g.date = function (s) { return ((g[Date.CultureInfo.dateElementOrder] || g.mdy).call(this, s)); }; }, relative: function () { // relative date / time expressions g.orientation = _.process(g.ctoken("past future"), function (s) { return function () { this.orient = s; }; } ); g.operator = _.process(g.ctoken("add subtract"), function (s) { return function () { this.operator = s; }; } ); g.rday = _.process(g.ctoken("yesterday tomorrow today now"), t.rday); g.unit = _.process(g.ctoken("second minute hour day week month year"), function (s) { return function () { this.unit = s; }; } ); } }; g.buildGrammarFormats = function () { // these need to be rebuilt every time the language changes. _C = {}; grammarFormats.timeFormats(); grammarFormats.dateFormats(); grammarFormats.relative(); g.value = _.process(_.rtoken(/^([-+]?\d+)?(st|nd|rd|th)?/), function (s) { return function () { this.value = s.replace(/\D/g, ""); }; } ); g.expression = _.set([g.rday, g.operator, g.value, g.unit, g.orientation, g.ddd, g.MMM ]); g.format = _.process(_.many( _.any( // translate format specifiers into grammar rules _.process( _.rtoken(/^(dd?d?d?(?!e)|MM?M?M?|yy?y?y?|hh?|HH?|mm?|ss?|tt?|zz?z?)/), function (fmt) { if (g[fmt]) { return g[fmt]; } else { throw $D.Parsing.Exception(fmt); } } ), // translate separator tokens into token rules _.process(_.rtoken(/^[^dMyhHmstz]+/), // all legal separators function (s) { return _.ignore(_.stoken(s)); } ) ) ), // construct the parser ... function (rules) { return _.process(_.each.apply(null, rules), t.finishExact); } ); // starting rule for general purpose grammar g._start = _.process(_.set([ g.date, g.time, g.expression ], g.generalDelimiter, g.whiteSpace), t.finish); }; g.buildGrammarFormats(); // parsing date format specifiers - ex: "h:m:s tt" // this little guy will generate a custom parser based // on the format string, ex: g.format("h:m:s tt") // check for these formats first g._formats = g.formats([ "\"yyyy-MM-ddTHH:mm:ssZ\"", "yyyy-MM-ddTHH:mm:ss.sz", "yyyy-MM-ddTHH:mm:ssZ", "yyyy-MM-ddTHH:mm:ssz", "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-ddTHH:mmZ", "yyyy-MM-ddTHH:mmz", "yyyy-MM-ddTHH:mm", "ddd, MMM dd, yyyy H:mm:ss tt", "ddd MMM d yyyy HH:mm:ss zzz", "MMddyyyy", "ddMMyyyy", "Mddyyyy", "ddMyyyy", "Mdyyyy", "dMyyyy", "yyyy", "Mdyy", "dMyy", "d" ]); // real starting rule: tries selected formats first, // then general purpose rule g.start = function (s) { try { var r = g._formats.call({}, s); if (r[1].length === 0) { return r; } } catch (e) {} return g._start.call({}, s); }; }()); (function () { var $D = Date; /** * @desc Converts the specified string value into its JavaScript Date equivalent using CultureInfo specific format information. * * Example

	///////////
	// Dates //
	///////////

	// 15-Oct-2004
	var d1 = Date.parse("10/15/2004");

	// 15-Oct-2004
	var d1 = Date.parse("15-Oct-2004");

	// 15-Oct-2004
	var d1 = Date.parse("2004.10.15");

	//Fri Oct 15, 2004
	var d1 = Date.parse("Fri Oct 15, 2004");

	///////////
	// Times //
	///////////

	// Today at 10 PM.
	var d1 = Date.parse("10 PM");

	// Today at 10:30 PM.
	var d1 = Date.parse("10:30 P.M.");

	// Today at 6 AM.
	var d1 = Date.parse("06am");

	/////////////////////
	// Dates and Times //
	/////////////////////

	// 8-July-2004 @ 10:30 PM
	var d1 = Date.parse("July 8th, 2004, 10:30 PM");

	// 1-July-2004 @ 10:30 PM
	var d1 = Date.parse("2004-07-01T22:30:00");

	////////////////////
	// Relative Dates //
	////////////////////

	// Returns today's date. The string "today" is culture specific.
	var d1 = Date.parse("today");

	// Returns yesterday's date. The string "yesterday" is culture specific.
	var d1 = Date.parse("yesterday");

	// Returns the date of the next thursday.
	var d1 = Date.parse("Next thursday");

	// Returns the date of the most previous monday.
	var d1 = Date.parse("last monday");

	// Returns today's day + one year.
	var d1 = Date.parse("next year");

	///////////////
	// Date Math //
	///////////////

	// Today + 2 days
	var d1 = Date.parse("t+2");

	// Today + 2 days
	var d1 = Date.parse("today + 2 days");

	// Today + 3 months
	var d1 = Date.parse("t+3m");

	// Today - 1 year
	var d1 = Date.parse("today - 1 year");

	// Today - 1 year
	var d1 = Date.parse("t-1y"); 


	/////////////////////////////
	// Partial Dates and Times //
	/////////////////////////////

	// July 15th of this year.
	var d1 = Date.parse("July 15");

	// 15th day of current day and year.
	var d1 = Date.parse("15");

	// July 1st of current year at 10pm.
	var d1 = Date.parse("7/1 10pm");
	
* * @param {String} The string value to convert into a Date object [Required] * @return {Date} A Date object or null if the string cannot be converted into a Date. */ var parseUtils = { removeOrds: function (s) { ords = s.match(/\b(\d+)(?:st|nd|rd|th)\b/); // find ordinal matches s = ((ords && ords.length === 2) ? s.replace(ords[0], ords[1]) : s); return s; }, grammarParser: function (s) { var r = null; try { r = $D.Grammar.start.call({}, s.replace(/^\s*(\S*(\s+\S+)*)\s*$/, "$1")); } catch (e) { return null; } return ((r[1].length === 0) ? r[0] : null); }, nativeFallback: function(s) { var t; try { // ok we haven't parsed it, last ditch attempt with the built-in parser. t = Date._parse(s); return (t || t === 0) ? new Date(t) : null; } catch (e) { return null; } } }; function parse (s) { var d; if (!s) { return null; } if (s instanceof Date) { return s.clone(); } if (s.length >= 4 && s.charAt(0) !== "0" && s.charAt(0) !== "+"&& s.charAt(0) !== "-") { // ie: 2004 will pass, 0800 won't. // Start with specific formats d = $D.Parsing.ISO.parse(s) || $D.Parsing.Numeric.parse(s); } if (d instanceof Date && !isNaN(d.getTime())) { return d; } else { // find ordinal dates (1st, 3rd, 8th, etc and remove them as they cause parsing issues) s = $D.Parsing.Normalizer.parse(parseUtils.removeOrds(s)); d = parseUtils.grammarParser(s); if (d !== null) { return d; } else { return parseUtils.nativeFallback(s); } } } if (!$D._parse) { $D._parse = $D.parse; } $D.parse = parse; Date.getParseFunction = function (fx) { var fns = Date.Grammar.allformats(fx); return function (s) { var r = null; for (var i = 0; i < fns.length; i++) { try { r = fns[i].call({}, s); } catch (e) { continue; } if (r[1].length === 0) { return r[0]; } } return null; }; }; /** * Converts the specified string value into its JavaScript Date equivalent using the specified format {String} or formats {Array} and the CultureInfo specific format information. * The format of the string value must match one of the supplied formats exactly. * * Example

	// 15-Oct-2004
	var d1 = Date.parseExact("10/15/2004", "M/d/yyyy");

	// 15-Oct-2004
	var d1 = Date.parse("15-Oct-2004", "M-ddd-yyyy");

	// 15-Oct-2004
	var d1 = Date.parse("2004.10.15", "yyyy.MM.dd");

	// Multiple formats
	var d1 = Date.parseExact("10/15/2004", ["M/d/yyyy", "MMMM d, yyyy"]);
	
* * @param {String} The string value to convert into a Date object [Required]. * @param {Object} The expected format {String} or an array of expected formats {Array} of the date string [Required]. * @return {Date} A Date object or null if the string cannot be converted into a Date. */ $D.parseExact = function (s, fx) { return $D.getParseFunction(fx)(s); }; }()); (function () { var $D = Date, $P = $D.prototype, // $C = $D.CultureInfo, // not used atm p = function (s, l) { if (!l) { l = 2; } return ("000" + s).slice(l * -1); }; /** * Converts a PHP format string to Java/.NET format string. * A PHP format string can be used with ._format or .format. * A Java/.NET format string can be used with .toString(). * The .parseExact function will only accept a Java/.NET format string * * Example * var f1 = "%m/%d/%y" * var f2 = Date.normalizeFormat(f1); // "MM/dd/yy" * * new Date().format(f1); // "04/13/08" * new Date()._format(f1); // "04/13/08" * new Date().toString(f2); // "04/13/08" * * var date = Date.parseExact("04/13/08", f2); // Sun Apr 13 2008 * * @param {String} A PHP format string consisting of one or more format spcifiers. * @return {String} The PHP format converted to a Java/.NET format string. */ var normalizerSubstitutions = { "d" : "dd", "%d": "dd", "D" : "ddd", "%a": "ddd", "j" : "dddd", "l" : "dddd", "%A": "dddd", "S" : "S", "F" : "MMMM", "%B": "MMMM", "m" : "MM", "%m": "MM", "M" : "MMM", "%b": "MMM", "%h": "MMM", "n" : "M", "Y" : "yyyy", "%Y": "yyyy", "y" : "yy", "%y": "yy", "g" : "h", "%I": "h", "G" : "H", "h" : "hh", "H" : "HH", "%H": "HH", "i" : "mm", "%M": "mm", "s" : "ss", "%S": "ss", "%r": "hh:mm tt", "%R": "H:mm", "%T": "H:mm:ss", "%X": "t", "%x": "d", "%e": "d", "%D": "MM/dd/yy", "%n": "\\n", "%t": "\\t", "e" : "z", "T" : "z", "%z": "z", "%Z": "z", "Z" : "ZZ", "N" : "u", "w" : "u", "%w": "u", "W" : "W", "%V": "W" }; var normalizer = { substitutes: function (m) { return normalizerSubstitutions[m]; }, interpreted: function (m, x) { var y; switch (m) { case "%u": return x.getDay() + 1; case "z": return x.getOrdinalNumber(); case "%j": return p(x.getOrdinalNumber(), 3); case "%U": var d1 = x.clone().set({month: 0, day: 1}).addDays(-1).moveToDayOfWeek(0), d2 = x.clone().addDays(1).moveToDayOfWeek(0, -1); return (d2 < d1) ? "00" : p((d2.getOrdinalNumber() - d1.getOrdinalNumber()) / 7 + 1); case "%W": return p(x.getWeek()); case "t": return $D.getDaysInMonth(x.getFullYear(), x.getMonth()); case "o": case "%G": return x.setWeek(x.getISOWeek()).toString("yyyy"); case "%g": return x._format("%G").slice(-2); case "a": case "%p": return t("tt").toLowerCase(); case "A": return t("tt").toUpperCase(); case "u": return p(x.getMilliseconds(), 3); case "I": return (x.isDaylightSavingTime()) ? 1 : 0; case "O": return x.getUTCOffset(); case "P": y = x.getUTCOffset(); return y.substring(0, y.length - 2) + ":" + y.substring(y.length - 2); case "B": var now = new Date(); return Math.floor(((now.getHours() * 3600) + (now.getMinutes() * 60) + now.getSeconds() + (now.getTimezoneOffset() + 60) * 60) / 86.4); case "c": return x.toISOString().replace(/\"/g, ""); case "U": return $D.strtotime("now"); case "%c": return t("d") + " " + t("t"); case "%C": return Math.floor(x.getFullYear() / 100 + 1); } }, shouldOverrideDefaults: function (m) { switch (m) { case "%e": return true; default: return false; } }, parse: function (m, context) { var formatString, c = context || new Date(); formatString = normalizer.substitutes(m); if (formatString) { return formatString; } formatString = normalizer.interpreted(m, c); if (formatString) { return formatString; } else { return m; } } }; $D.normalizeFormat = function (format, context) { return format.replace(/(%|\\)?.|%%/g, function(t){ return normalizer.parse(t, context); }); }; /** * Format a local Unix timestamp according to locale settings * * Example: * Date.strftime("%m/%d/%y", new Date()); // "04/13/08" * Date.strftime("c", "2008-04-13T17:52:03Z"); // "04/13/08" * * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @param {Number|String} The number representing the number of seconds that have elapsed since January 1, 1970 (local time). * @return {String} A string representation of the current Date object. */ $D.strftime = function (format, time) { var d = Date.parse(time); return d._format(format); }; /** * Parse any textual datetime description into a Unix timestamp. * A Unix timestamp is the number of seconds that have elapsed since January 1, 1970 (midnight UTC/GMT). * * Example: * Date.strtotime("04/13/08"); // 1208044800 * Date.strtotime("1970-01-01T00:00:00Z"); // 0 * * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @param {Object} A string or date object. * @return {String} A string representation of the current Date object. */ $D.strtotime = function (time) { var d = $D.parse(time); return Math.round($D.UTC(d.getUTCFullYear(), d.getUTCMonth(), d.getUTCDate(), d.getUTCHours(), d.getUTCMinutes(), d.getUTCSeconds(), d.getUTCMilliseconds()) / 1000); }; /** * Converts the value of the current Date object to its equivalent string representation using a PHP/Unix style of date format specifiers. * Format Specifiers * Format Description Example * ------ --------------------------------------------------------------------------- ----------------------- * %a abbreviated weekday name according to the current localed "Mon" through "Sun" * %A full weekday name according to the current localed "Sunday" through "Saturday" * %b abbreviated month name according to the current localed "Jan" through "Dec" * %B full month name according to the current locale "January" through "December" * %c preferred date and time representation for the current locale "4/13/2008 12:33 PM" * %C century number (the year divided by 100 and truncated to an integer) "00" to "99" * %d day of the month as a decimal number "01" to "31" * %D same as %m/%d/%y "04/13/08" * %e day of the month as a decimal number, a single digit is preceded by a space "1" to "31" * %g like %G, but without the century "08" * %G The 4-digit year corresponding to the ISO week number (see %V). "2008" * This has the same format and value as %Y, except that if the ISO week number * belongs to the previous or next year, that year is used instead. * %h same as %b "Jan" through "Dec" * %H hour as a decimal number using a 24-hour clock. "00" to "23" * %I hour as a decimal number using a 12-hour clock. "01" to "12" * %j day of the year as a decimal number. "001" to "366" * %m month as a decimal number. "01" to "12" * %M minute as a decimal number. "00" to "59" * %n newline character "\n" * %p either "am" or "pm" according to the given time value, or the "am" or "pm" * corresponding strings for the current locale. * %r time in a.m. and p.m. notation "8:44 PM" * %R time in 24 hour notation "20:44" * %S second as a decimal number "00" to "59" * %t tab character "\t" * %T current time, equal to %H:%M:%S "12:49:11" * %u weekday as a decimal number ["1", "7"], with "1" representing Monday "1" to "7" * %U week number of the current year as a decimal number, starting with the "0" to ("52" or "53") * first Sunday as the first day of the first week * %V The ISO 8601:1988 week number of the current year as a decimal number, "00" to ("52" or "53") * range 01 to 53, where week 1 is the first week that has at least 4 days * in the current year, and with Monday as the first day of the week. * (Use %G or %g for the year component that corresponds to the week number * for the specified timestamp.) * %W week number of the current year as a decimal number, starting with the "00" to ("52" or "53") * first Monday as the first day of the first week * %w day of the week as a decimal, Sunday being "0" "0" to "6" * %x preferred date representation for the current locale without the time "4/13/2008" * %X preferred time representation for the current locale without the date "12:53:05" * %y year as a decimal number without a century "00" "99" * %Y year as a decimal number including the century "2008" * %Z time zone or name or abbreviation "UTC", "EST", "PST" * %z same as %Z * %% a literal "%" characters "%" * d Day of the month, 2 digits with leading zeros "01" to "31" * D A textual representation of a day, three letters "Mon" through "Sun" * j Day of the month without leading zeros "1" to "31" * l A full textual representation of the day of the week (lowercase "L") "Sunday" through "Saturday" * N ISO-8601 numeric representation of the day of the week (added in PHP 5.1.0) "1" (for Monday) through "7" (for Sunday) * S English ordinal suffix for the day of the month, 2 characters "st", "nd", "rd" or "th". Works well with j * w Numeric representation of the day of the week "0" (for Sunday) through "6" (for Saturday) * z The day of the year (starting from "0") "0" through "365" * W ISO-8601 week number of year, weeks starting on Monday "00" to ("52" or "53") * F A full textual representation of a month, such as January or March "January" through "December" * m Numeric representation of a month, with leading zeros "01" through "12" * M A short textual representation of a month, three letters "Jan" through "Dec" * n Numeric representation of a month, without leading zeros "1" through "12" * t Number of days in the given month "28" through "31" * L Whether it's a leap year "1" if it is a leap year, "0" otherwise * o ISO-8601 year number. This has the same value as Y, except that if the "2008" * ISO week number (W) belongs to the previous or next year, that year * is used instead. * Y A full numeric representation of a year, 4 digits "2008" * y A two digit representation of a year "08" * a Lowercase Ante meridiem and Post meridiem "am" or "pm" * A Uppercase Ante meridiem and Post meridiem "AM" or "PM" * B Swatch Internet time "000" through "999" * g 12-hour format of an hour without leading zeros "1" through "12" * G 24-hour format of an hour without leading zeros "0" through "23" * h 12-hour format of an hour with leading zeros "01" through "12" * H 24-hour format of an hour with leading zeros "00" through "23" * i Minutes with leading zeros "00" to "59" * s Seconds, with leading zeros "00" through "59" * u Milliseconds "54321" * e Timezone identifier "UTC", "EST", "PST" * I Whether or not the date is in daylight saving time (uppercase i) "1" if Daylight Saving Time, "0" otherwise * O Difference to Greenwich time (GMT) in hours "+0200", "-0600" * P Difference to Greenwich time (GMT) with colon between hours and minutes "+02:00", "-06:00" * T Timezone abbreviation "UTC", "EST", "PST" * Z Timezone offset in seconds. The offset for timezones west of UTC is "-43200" through "50400" * always negative, and for those east of UTC is always positive. * c ISO 8601 date "2004-02-12T15:19:21+00:00" * r RFC 2822 formatted date "Thu, 21 Dec 2000 16:01:07 +0200" * U Seconds since the Unix Epoch (January 1 1970 00:00:00 GMT) "0" * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @return {String} A string representation of the current Date object. */ var formatReplace = function (context) { return function (m) { var formatString, override = false; if (m.charAt(0) === "\\" || m.substring(0, 2) === "%%") { return m.replace("\\", "").replace("%%", "%"); } override = normalizer.shouldOverrideDefaults(m); formatString = $D.normalizeFormat(m, context); if (formatString) { return context.toString(formatString, override); } }; }; $P._format = function (format) { var formatter = formatReplace(this); if (!format) { return this._toString(); } else { return format.replace(/(%|\\)?.|%%/g, formatter); } }; if (!$P.format) { $P.format = $P._format; } }()); (function () { "use strict"; var gFn = function (attr) { return function () { return this[attr]; }; }; var sFn = function (attr) { return function (val) { this[attr] = val; return this; }; }; var attrs = ["years", "months", "days", "hours", "minutes", "seconds", "milliseconds"]; var addSetFuncs = function (context, attrs) { for (var i = 0; i < attrs.length ; i++) { var $a = attrs[i], $b = $a.slice(0, 1).toUpperCase() + $a.slice(1); context.prototype[$a] = 0; context.prototype["get" + $b] = gFn($a); context.prototype["set" + $b] = sFn($a); } }; /** * new TimeSpan(milliseconds); * new TimeSpan(days, hours, minutes, seconds); * new TimeSpan(days, hours, minutes, seconds, milliseconds); */ var TimeSpan = function (days, hours, minutes, seconds, milliseconds) { if (arguments.length === 1 && typeof days === "number") { var orient = (days < 0) ? -1 : +1; var millsLeft = Math.abs(days); this.setDays(Math.floor(millsLeft / 86400000) * orient); millsLeft = millsLeft % 86400000; this.setHours(Math.floor(millsLeft / 3600000) * orient); millsLeft = millsLeft % 3600000; this.setMinutes(Math.floor(millsLeft / 60000) * orient); millsLeft = millsLeft % 60000; this.setSeconds(Math.floor(millsLeft / 1000) * orient); millsLeft = millsLeft % 1000; this.setMilliseconds(millsLeft * orient); } else { this.set(days, hours, minutes, seconds, milliseconds); } this.getTotalMilliseconds = function () { return (this.getDays() * 86400000) + (this.getHours() * 3600000) + (this.getMinutes() * 60000) + (this.getSeconds() * 1000); }; this.compareTo = function (time) { var t1 = new Date(1970, 1, 1, this.getHours(), this.getMinutes(), this.getSeconds()), t2; if (time === null) { t2 = new Date(1970, 1, 1, 0, 0, 0); } else { t2 = new Date(1970, 1, 1, time.getHours(), time.getMinutes(), time.getSeconds()); } return (t1 < t2) ? -1 : (t1 > t2) ? 1 : 0; }; this.equals = function (time) { return (this.compareTo(time) === 0); }; this.add = function (time) { return (time === null) ? this : this.addSeconds(time.getTotalMilliseconds() / 1000); }; this.subtract = function (time) { return (time === null) ? this : this.addSeconds(-time.getTotalMilliseconds() / 1000); }; this.addDays = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 86400000)); }; this.addHours = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 3600000)); }; this.addMinutes = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 60000)); }; this.addSeconds = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 1000)); }; this.addMilliseconds = function (n) { return new TimeSpan(this.getTotalMilliseconds() + n); }; this.get12HourHour = function () { return (this.getHours() > 12) ? this.getHours() - 12 : (this.getHours() === 0) ? 12 : this.getHours(); }; this.getDesignator = function () { return (this.getHours() < 12) ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator; }; this.toString = function (format) { this._toString = function () { if (this.getDays() !== null && this.getDays() > 0) { return this.getDays() + "." + this.getHours() + ":" + this.p(this.getMinutes()) + ":" + this.p(this.getSeconds()); } else { return this.getHours() + ":" + this.p(this.getMinutes()) + ":" + this.p(this.getSeconds()); } }; this.p = function (s) { return (s.toString().length < 2) ? "0" + s : s; }; var me = this; return format ? format.replace(/dd?|HH?|hh?|mm?|ss?|tt?/g, function (format) { switch (format) { case "d": return me.getDays(); case "dd": return me.p(me.getDays()); case "H": return me.getHours(); case "HH": return me.p(me.getHours()); case "h": return me.get12HourHour(); case "hh": return me.p(me.get12HourHour()); case "m": return me.getMinutes(); case "mm": return me.p(me.getMinutes()); case "s": return me.getSeconds(); case "ss": return me.p(me.getSeconds()); case "t": return ((me.getHours() < 12) ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator).substring(0, 1); case "tt": return (me.getHours() < 12) ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator; } } ) : this._toString(); }; return this; }; addSetFuncs(TimeSpan, attrs.slice(2)); TimeSpan.prototype.set = function (days, hours, minutes, seconds, milliseconds){ this.setDays(days || this.getDays()); this.setHours(hours || this.getHours()); this.setMinutes(minutes || this.getMinutes()); this.setSeconds(seconds || this.getSeconds()); this.setMilliseconds(milliseconds || this.getMilliseconds()); }; /** * Gets the time of day for this date instances. * @return {TimeSpan} TimeSpan */ Date.prototype.getTimeOfDay = function () { return new TimeSpan(0, this.getHours(), this.getMinutes(), this.getSeconds(), this.getMilliseconds()); }; Date.TimeSpan = TimeSpan; if (typeof window !== "undefined" ) { // keeping API compatible for v1.x window.TimeSpan = TimeSpan; } }()); (function () { "use strict"; var attrs = ["years", "months", "days", "hours", "minutes", "seconds", "milliseconds"]; var gFn = function (attr) { return function () { return this[attr]; }; }; var sFn = function (attr) { return function (val) { this[attr] = val; return this; }; }; var addSetFuncs = function (context, attrs) { for (var i = 0; i < attrs.length ; i++) { var $a = attrs[i], $b = $a.slice(0, 1).toUpperCase() + $a.slice(1); context.prototype[$a] = 0; context.prototype["get" + $b] = gFn($a); context.prototype["set" + $b] = sFn($a); } }; var setMonthsAndYears = function (orient, d1, d2, context) { function inc() { d1.addMonths(-orient); context.months++; if (context.months === 12) { context.years++; context.months = 0; } } if (orient === +1) { while (d1 > d2) { inc(); } } else { while (d1 < d2) { inc(); } } context.months--; context.months *= orient; context.years *= orient; }; var adjustForDST = function(orient, startDate, endDate) { var hasDSTMismatch = (false === (startDate.isDaylightSavingTime() === endDate.isDaylightSavingTime())); if (hasDSTMismatch && orient === 1) { startDate.addHours(-1); } else if (hasDSTMismatch) { startDate.addHours(1); } }; /** * TimePeriod(startDate, endDate); * TimePeriod(years, months, days, hours, minutes, seconds, milliseconds); */ var TimePeriod = function (years, months, days, hours, minutes, seconds, milliseconds) { if (arguments.length === 7) { this.set(years, months, days, hours, minutes, seconds, milliseconds); } else if (arguments.length === 2 && arguments[0] instanceof Date && arguments[1] instanceof Date) { var startDate = arguments[0].clone(); var endDate = arguments[1].clone(); var orient = (startDate > endDate) ? +1 : -1; this.dates = { start: arguments[0].clone(), end: arguments[1].clone() }; setMonthsAndYears(orient, startDate, endDate, this); adjustForDST(orient, startDate, endDate); // // TODO - adjust for DST var diff = endDate - startDate; if (diff !== 0) { var ts = new TimeSpan(diff); this.set(this.years, this.months, ts.getDays(), ts.getHours(), ts.getMinutes(), ts.getSeconds(), ts.getMilliseconds()); } } return this; }; // create all the set functions. addSetFuncs(TimePeriod, attrs); TimePeriod.prototype.set = function (years, months, days, hours, minutes, seconds, milliseconds){ this.setYears(years || this.getYears()); this.setMonths(months || this.getMonths()); this.setDays(days || this.getDays()); this.setHours(hours || this.getHours()); this.setMinutes(minutes || this.getMinutes()); this.setSeconds(seconds || this.getSeconds()); this.setMilliseconds(milliseconds || this.getMilliseconds()); }; Date.TimePeriod = TimePeriod; if (typeof window !== "undefined") { // keeping API compatible for v1.x window.TimePeriod = TimePeriod; } }()); ================================================ FILE: build/date-ru-RU.js ================================================ /** * @overview datejs * @version 1.0.0-rc3 * @author Gregory Wild-Smith * @copyright 2015 Gregory Wild-Smith * @license MIT * @homepage https://github.com/abritinthebay/datejs */ /* * DateJS Culture String File * Country Code: ru-RU * Name: Russian (Russia) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["ru-RU"] = { "name": "ru-RU", "englishName": "Russian (Russia)", "nativeName": "Pусский (Россия)", "Sunday": "воскресенье", "Monday": "понедельник", "Tuesday": "вторник", "Wednesday": "среда", "Thursday": "четверг", "Friday": "пятница", "Saturday": "суббота", "Sun": "Вс", "Mon": "Пн", "Tue": "Вт", "Wed": "Ср", "Thu": "Чт", "Fri": "Пт", "Sat": "Сб", "Su": "Вс", "Mo": "Пн", "Tu": "Вт", "We": "Ср", "Th": "Чт", "Fr": "Пт", "Sa": "Сб", "S_Sun_Initial": "В", "M_Mon_Initial": "П", "T_Tue_Initial": "В", "W_Wed_Initial": "С", "T_Thu_Initial": "Ч", "F_Fri_Initial": "П", "S_Sat_Initial": "С", "January": "Январь", "February": "Февраль", "March": "Март", "April": "Апрель", "May": "Май", "June": "Июнь", "July": "Июль", "August": "Август", "September": "Сентябрь", "October": "Октябрь", "November": "Ноябрь", "December": "Декабрь", "Jan_Abbr": "янв", "Feb_Abbr": "фев", "Mar_Abbr": "мар", "Apr_Abbr": "апр", "May_Abbr": "май", "Jun_Abbr": "июн", "Jul_Abbr": "июл", "Aug_Abbr": "авг", "Sep_Abbr": "сен", "Oct_Abbr": "окт", "Nov_Abbr": "ноя", "Dec_Abbr": "дек", "AM": "", "PM": "", "firstDayOfWeek": 1, "twoDigitYearMax": 2029, "mdy": "dmy", "M/d/yyyy": "dd.MM.yyyy", "dddd, MMMM dd, yyyy": "d MMMM yyyy 'г.'", "h:mm tt": "H:mm", "h:mm:ss tt": "H:mm:ss", "dddd, MMMM dd, yyyy h:mm:ss tt": "d MMMM yyyy 'г.' H:mm:ss", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "MMMM dd", "MMMM, yyyy": "MMMM yyyy 'г.'", "/jan(uary)?/": "янв(арь)?", "/feb(ruary)?/": "фев(раль)?", "/mar(ch)?/": "мар(т)?", "/apr(il)?/": "апр(ель)?", "/may/": "май", "/jun(e)?/": "июн(ь)?", "/jul(y)?/": "июл(ь)?", "/aug(ust)?/": "авг(уст)?", "/sep(t(ember)?)?/": "сен(тябрь)?", "/oct(ober)?/": "окт(ябрь)?", "/nov(ember)?/": "ноя(брь)?", "/dec(ember)?/": "дек(абрь)?", "/^su(n(day)?)?/": "^воскресенье", "/^mo(n(day)?)?/": "^понедельник", "/^tu(e(s(day)?)?)?/": "^вторник", "/^we(d(nesday)?)?/": "^среда", "/^th(u(r(s(day)?)?)?)?/": "^четверг", "/^fr(i(day)?)?/": "^пятница", "/^sa(t(urday)?)?/": "^суббота", "/^next/": "^след|завтра", "/^last|past|prev(ious)?/": "^пред|вчера", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|через|после|вперед|и|следую?щ(ая|ий|ее)?)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|за|до|поза|пе?ред((ыдущ|шев?ствующ)(ая|ий|ее))|назад)", "/^yes(terday)?/": "^вчера", "/^t(od(ay)?)?/": "^сегодня", "/^tom(orrow)?/": "^завтра", "/^n(ow)?/": "^сейчас|сечас|щас", "/^ms|milli(second)?s?/": "^мс|мили(секунд)?s?", "/^sec(ond)?s?/": "^с(ек(унд)?)?", "/^mn|min(ute)?s?/": "^м(ин(ут)?)?", "/^h(our)?s?/": "^ч((ас)?ов)?", "/^w(eek)?s?/": "^н(ед(ель)?)?", "/^m(onth)?s?/": "^мес(яцев)?", "/^d(ay)?s?/": "^д(ень|ней|ня)?", "/^y(ear)?s?/": "^г(ода?)?|л(ет)?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "ru-RU"; /** * @overview datejs * @version 1.0.0-rc3 * @author Gregory Wild-Smith * @copyright 2015 Gregory Wild-Smith * @license MIT * @homepage https://github.com/abritinthebay/datejs */(function () { var $D = Date; var lang = Date.CultureStrings ? Date.CultureStrings.lang : null; var loggedKeys = {}; // for debug purposes. var getText = { getFromKey: function (key, countryCode) { var output; if (Date.CultureStrings && Date.CultureStrings[countryCode] && Date.CultureStrings[countryCode][key]) { output = Date.CultureStrings[countryCode][key]; } else { output = getText.buildFromDefault(key); } if (key.charAt(0) === "/") { // Assume it's a regex output = getText.buildFromRegex(key, countryCode); } return output; }, getFromObjectValues: function (obj, countryCode) { var key, output = {}; for(key in obj) { if (obj.hasOwnProperty(key)) { output[key] = getText.getFromKey(obj[key], countryCode); } } return output; }, getFromObjectKeys: function (obj, countryCode) { var key, output = {}; for(key in obj) { if (obj.hasOwnProperty(key)) { output[getText.getFromKey(key, countryCode)] = obj[key]; } } return output; }, getFromArray: function (arr, countryCode) { var output = []; for (var i=0; i < arr.length; i++){ if (i in arr) { output[i] = getText.getFromKey(arr[i], countryCode); } } return output; }, buildFromDefault: function (key) { var output, length, split, last; switch(key) { case "name": output = "en-US"; break; case "englishName": output = "English (United States)"; break; case "nativeName": output = "English (United States)"; break; case "twoDigitYearMax": output = 2049; break; case "firstDayOfWeek": output = 0; break; default: output = key; split = key.split("_"); length = split.length; if (length > 1 && key.charAt(0) !== "/") { // if the key isn't a regex and it has a split. last = split[(length - 1)].toLowerCase(); if (last === "initial" || last === "abbr") { output = split[0]; } } break; } return output; }, buildFromRegex: function (key, countryCode) { var output; if (Date.CultureStrings && Date.CultureStrings[countryCode] && Date.CultureStrings[countryCode][key]) { output = new RegExp(Date.CultureStrings[countryCode][key], "i"); } else { output = new RegExp(key.replace(new RegExp("/", "g"),""), "i"); } return output; } }; var shallowMerge = function (obj1, obj2) { for (var attrname in obj2) { if (obj2.hasOwnProperty(attrname)) { obj1[attrname] = obj2[attrname]; } } }; var __ = function (key, language) { var countryCode = (language) ? language : lang; loggedKeys[key] = key; if (typeof key === "object") { if (key instanceof Array) { return getText.getFromArray(key, countryCode); } else { return getText.getFromObjectKeys(key, countryCode); } } else { return getText.getFromKey(key, countryCode); } }; var loadI18nScript = function (code) { // paatterned after jQuery's getScript. var url = Date.Config.i18n + code + ".js"; var head = document.getElementsByTagName("head")[0] || document.documentElement; var script = document.createElement("script"); script.src = url; var completed = false; var events = { done: function (){} // placeholder function }; // Attach handlers for all browsers script.onload = script.onreadystatechange = function() { if ( !completed && (!this.readyState || this.readyState === "loaded" || this.readyState === "complete") ) { events.done(); head.removeChild(script); } }; setTimeout(function() { head.insertBefore(script, head.firstChild); }, 0); // allows return to execute first return { done: function (cb) { events.done = function() { if (cb) { setTimeout(cb,0); } }; } }; }; var buildInfo = { buildFromMethodHash: function (obj) { var key; for(key in obj) { if (obj.hasOwnProperty(key)) { obj[key] = buildInfo[obj[key]](); } } return obj; }, timeZoneDST: function () { var DST = { "CHADT": "+1345", "NZDT": "+1300", "AEDT": "+1100", "ACDT": "+1030", "AZST": "+0500", "IRDT": "+0430", "EEST": "+0300", "CEST": "+0200", "BST": "+0100", "PMDT": "-0200", "ADT": "-0300", "NDT": "-0230", "EDT": "-0400", "CDT": "-0500", "MDT": "-0600", "PDT": "-0700", "AKDT": "-0800", "HADT": "-0900" }; return __(DST); }, timeZoneStandard: function () { var standard = { "LINT": "+1400", "TOT": "+1300", "CHAST": "+1245", "NZST": "+1200", "NFT": "+1130", "SBT": "+1100", "AEST": "+1000", "ACST": "+0930", "JST": "+0900", "CWST": "+0845", "CT": "+0800", "ICT": "+0700", "MMT": "+0630", "BST": "+0600", "NPT": "+0545", "IST": "+0530", "PKT": "+0500", "AFT": "+0430", "MSK": "+0400", "IRST": "+0330", "FET": "+0300", "EET": "+0200", "CET": "+0100", "GMT": "+0000", "UTC": "+0000", "CVT": "-0100", "GST": "-0200", "BRT": "-0300", "NST": "-0330", "AST": "-0400", "EST": "-0500", "CST": "-0600", "MST": "-0700", "PST": "-0800", "AKST": "-0900", "MIT": "-0930", "HST": "-1000", "SST": "-1100", "BIT": "-1200" }; return __(standard); }, timeZones: function (data) { var zone; data.timezones = []; for (zone in data.abbreviatedTimeZoneStandard) { if (data.abbreviatedTimeZoneStandard.hasOwnProperty(zone)) { data.timezones.push({ name: zone, offset: data.abbreviatedTimeZoneStandard[zone]}); } } for (zone in data.abbreviatedTimeZoneDST) { if (data.abbreviatedTimeZoneDST.hasOwnProperty(zone)) { data.timezones.push({ name: zone, offset: data.abbreviatedTimeZoneDST[zone], dst: true}); } } return data.timezones; }, days: function () { return __(["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"]); }, dayAbbr: function () { return __(["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"]); }, dayShortNames: function () { return __(["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"]); }, dayFirstLetters: function () { return __(["S_Sun_Initial", "M_Mon_Initial", "T_Tues_Initial", "W_Wed_Initial", "T_Thu_Initial", "F_Fri_Initial", "S_Sat_Initial"]); }, months: function () { return __(["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"]); }, monthAbbr: function () { return __(["Jan_Abbr", "Feb_Abbr", "Mar_Abbr", "Apr_Abbr", "May_Abbr", "Jun_Abbr", "Jul_Abbr", "Aug_Abbr", "Sep_Abbr", "Oct_Abbr", "Nov_Abbr", "Dec_Abbr"]); }, formatPatterns: function () { return getText.getFromObjectValues({ shortDate: "M/d/yyyy", longDate: "dddd, MMMM dd, yyyy", shortTime: "h:mm tt", longTime: "h:mm:ss tt", fullDateTime: "dddd, MMMM dd, yyyy h:mm:ss tt", sortableDateTime: "yyyy-MM-ddTHH:mm:ss", universalSortableDateTime: "yyyy-MM-dd HH:mm:ssZ", rfc1123: "ddd, dd MMM yyyy HH:mm:ss", monthDay: "MMMM dd", yearMonth: "MMMM, yyyy" }, Date.i18n.currentLanguage()); }, regex: function () { return getText.getFromObjectValues({ inTheMorning: "/( in the )(morn(ing)?)\\b/", thisMorning: "/(this )(morn(ing)?)\\b/", amThisMorning: "/(\b\\d(am)? )(this )(morn(ing)?)/", inTheEvening: "/( in the )(even(ing)?)\\b/", thisEvening: "/(this )(even(ing)?)\\b/", pmThisEvening: "/(\b\\d(pm)? )(this )(even(ing)?)/", jan: "/jan(uary)?/", feb: "/feb(ruary)?/", mar: "/mar(ch)?/", apr: "/apr(il)?/", may: "/may/", jun: "/jun(e)?/", jul: "/jul(y)?/", aug: "/aug(ust)?/", sep: "/sep(t(ember)?)?/", oct: "/oct(ober)?/", nov: "/nov(ember)?/", dec: "/dec(ember)?/", sun: "/^su(n(day)?)?/", mon: "/^mo(n(day)?)?/", tue: "/^tu(e(s(day)?)?)?/", wed: "/^we(d(nesday)?)?/", thu: "/^th(u(r(s(day)?)?)?)?/", fri: "/fr(i(day)?)?/", sat: "/^sa(t(urday)?)?/", future: "/^next/", past: "/^last|past|prev(ious)?/", add: "/^(\\+|aft(er)?|from|hence)/", subtract: "/^(\\-|bef(ore)?|ago)/", yesterday: "/^yes(terday)?/", today: "/^t(od(ay)?)?/", tomorrow: "/^tom(orrow)?/", now: "/^n(ow)?/", millisecond: "/^ms|milli(second)?s?/", second: "/^sec(ond)?s?/", minute: "/^mn|min(ute)?s?/", hour: "/^h(our)?s?/", week: "/^w(eek)?s?/", month: "/^m(onth)?s?/", day: "/^d(ay)?s?/", year: "/^y(ear)?s?/", shortMeridian: "/^(a|p)/", longMeridian: "/^(a\\.?m?\\.?|p\\.?m?\\.?)/", timezone: "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/", ordinalSuffix: "/^\\s*(st|nd|rd|th)/", timeContext: "/^\\s*(\\:|a(?!u|p)|p)/" }, Date.i18n.currentLanguage()); } }; var CultureInfo = function () { var info = getText.getFromObjectValues({ name: "name", englishName: "englishName", nativeName: "nativeName", amDesignator: "AM", pmDesignator: "PM", firstDayOfWeek: "firstDayOfWeek", twoDigitYearMax: "twoDigitYearMax", dateElementOrder: "mdy" }, Date.i18n.currentLanguage()); var constructedInfo = buildInfo.buildFromMethodHash({ dayNames: "days", abbreviatedDayNames: "dayAbbr", shortestDayNames: "dayShortNames", firstLetterDayNames: "dayFirstLetters", monthNames: "months", abbreviatedMonthNames: "monthAbbr", formatPatterns: "formatPatterns", regexPatterns: "regex", abbreviatedTimeZoneDST: "timeZoneDST", abbreviatedTimeZoneStandard: "timeZoneStandard" }); shallowMerge(info, constructedInfo); buildInfo.timeZones(info); return info; }; $D.i18n = { __: function (key, lang) { return __(key, lang); }, currentLanguage: function () { return lang || "en-US"; }, setLanguage: function (code, force, cb) { var async = false; if (force || code === "en-US" || (!!Date.CultureStrings && !!Date.CultureStrings[code])) { lang = code; Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings.lang = code; Date.CultureInfo = new CultureInfo(); } else { if (!(!!Date.CultureStrings && !!Date.CultureStrings[code])) { if (typeof exports !== "undefined" && this.exports !== exports) { // we're in a Node enviroment, load it using require try { require("../i18n/" + code + ".js"); lang = code; Date.CultureStrings.lang = code; Date.CultureInfo = new CultureInfo(); } catch (e) { // var str = "The language for '" + code + "' could not be loaded by Node. It likely does not exist."; throw new Error("The DateJS IETF language tag '" + code + "' could not be loaded by Node. It likely does not exist."); } } else if (Date.Config && Date.Config.i18n) { // we know the location of the files, so lets load them async = true; loadI18nScript(code).done(function(){ lang = code; Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings.lang = code; Date.CultureInfo = new CultureInfo(); $D.Parsing.Normalizer.buildReplaceData(); // because this is async if ($D.Grammar) { $D.Grammar.buildGrammarFormats(); // so we can parse those strings... } if (cb) { setTimeout(cb,0); } }); } else { Date.console.error("The DateJS IETF language tag '" + code + "' is not available and has not been loaded."); return false; } } } $D.Parsing.Normalizer.buildReplaceData(); // rebuild normalizer strings if ($D.Grammar) { $D.Grammar.buildGrammarFormats(); // so we can parse those strings... } if (!async && cb) { setTimeout(cb,0); } }, getLoggedKeys: function () { return loggedKeys; }, updateCultureInfo: function () { Date.CultureInfo = new CultureInfo(); } }; $D.i18n.updateCultureInfo(); // run automatically }()); (function () { var $D = Date, $P = $D.prototype, p = function (s, l) { if (!l) { l = 2; } return ("000" + s).slice(l * -1); }; if (typeof window !== "undefined" && typeof window.console !== "undefined" && typeof window.console.log !== "undefined") { $D.console = console; // used only to raise non-critical errors if available } else { // set mock so we don't give errors. $D.console = { log: function(){}, error: function(){} }; } $D.Config = $D.Config || {}; $D.initOverloads = function() { /** * Overload of Date.now. Allows an alternate call for Date.now where it returns the * current Date as an object rather than just milliseconds since the Unix Epoch. * * Also provides an implementation of now() for browsers (IE<9) that don't have it. * * Backwards compatible so with work with either: * Date.now() [returns ms] * or * Date.now(true) [returns Date] */ if (!$D.now) { $D._now = function now() { return new Date().getTime(); }; } else if (!$D._now) { $D._now = $D.now; } $D.now = function (returnObj) { if (returnObj) { return $D.present(); } else { return $D._now(); } }; if ( !$P.toISOString ) { $P.toISOString = function() { return this.getUTCFullYear() + "-" + p(this.getUTCMonth() + 1) + "-" + p(this.getUTCDate()) + "T" + p(this.getUTCHours()) + ":" + p(this.getUTCMinutes()) + ":" + p(this.getUTCSeconds()) + "." + String( (this.getUTCMilliseconds()/1000).toFixed(3)).slice(2, 5) + "Z"; }; } // private if ( $P._toString === undefined ){ $P._toString = $P.toString; } }; $D.initOverloads(); /** * Gets a date that is set to the current date. The time is set to the start of the day (00:00 or 12:00 AM). * @return {Date} The current date. */ $D.today = function () { return new Date().clearTime(); }; /** * Gets a date that is set to the current date and time (same as new Date, but chainable) * @return {Date} The current date. */ $D.present = function () { return new Date(); }; /** * Compares the first date to the second date and returns an number indication of their relative values. * @param {Date} First Date object to compare [Required]. * @param {Date} Second Date object to compare to [Required]. * @return {Number} -1 = date1 is lessthan date2. 0 = values are equal. 1 = date1 is greaterthan date2. */ $D.compare = function (date1, date2) { if (isNaN(date1) || isNaN(date2)) { throw new Error(date1 + " - " + date2); } else if (date1 instanceof Date && date2 instanceof Date) { return (date1 < date2) ? -1 : (date1 > date2) ? 1 : 0; } else { throw new TypeError(date1 + " - " + date2); } }; /** * Compares the first Date object to the second Date object and returns true if they are equal. * @param {Date} First Date object to compare [Required] * @param {Date} Second Date object to compare to [Required] * @return {Boolean} true if dates are equal. false if they are not equal. */ $D.equals = function (date1, date2) { return (date1.compareTo(date2) === 0); }; /** * Gets the language appropriate day name when given the day number(0-6) * eg - 0 == Sunday * @return {String} The day name */ $D.getDayName = function (n) { return Date.CultureInfo.dayNames[n]; }; /** * Gets the day number (0-6) if given a CultureInfo specific string which is a valid dayName, abbreviatedDayName or shortestDayName (two char). * @param {String} The name of the day (eg. "Monday, "Mon", "tuesday", "tue", "We", "we"). * @return {Number} The day number */ $D.getDayNumberFromName = function (name) { var n = Date.CultureInfo.dayNames, m = Date.CultureInfo.abbreviatedDayNames, o = Date.CultureInfo.shortestDayNames, s = name.toLowerCase(); for (var i = 0; i < n.length; i++) { if (n[i].toLowerCase() === s || m[i].toLowerCase() === s || o[i].toLowerCase() === s) { return i; } } return -1; }; /** * Gets the month number (0-11) if given a Culture Info specific string which is a valid monthName or abbreviatedMonthName. * @param {String} The name of the month (eg. "February, "Feb", "october", "oct"). * @return {Number} The day number */ $D.getMonthNumberFromName = function (name) { var n = Date.CultureInfo.monthNames, m = Date.CultureInfo.abbreviatedMonthNames, s = name.toLowerCase(); for (var i = 0; i < n.length; i++) { if (n[i].toLowerCase() === s || m[i].toLowerCase() === s) { return i; } } return -1; }; /** * Gets the language appropriate month name when given the month number(0-11) * eg - 0 == January * @return {String} The month name */ $D.getMonthName = function (n) { return Date.CultureInfo.monthNames[n]; }; /** * Determines if the current date instance is within a LeapYear. * @param {Number} The year. * @return {Boolean} true if date is within a LeapYear, otherwise false. */ $D.isLeapYear = function (year) { return ((year % 4 === 0 && year % 100 !== 0) || year % 400 === 0); }; /** * Gets the number of days in the month, given a year and month value. Automatically corrects for LeapYear. * @param {Number} The year. * @param {Number} The month (0-11). * @return {Number} The number of days in the month. */ $D.getDaysInMonth = function (year, month) { if (!month && $D.validateMonth(year)) { month = year; year = Date.today().getFullYear(); } return [31, ($D.isLeapYear(year) ? 29 : 28), 31, 30, 31, 30, 31, 31, 30, 31, 30, 31][month]; }; $P.getDaysInMonth = function () { return $D.getDaysInMonth(this.getFullYear(), this.getMonth()); }; $D.getTimezoneAbbreviation = function (offset, dst) { var p, n = (dst || false) ? Date.CultureInfo.abbreviatedTimeZoneDST : Date.CultureInfo.abbreviatedTimeZoneStandard; for (p in n) { if (n.hasOwnProperty(p)) { if (n[p] === offset) { return p; } } } return null; }; $D.getTimezoneOffset = function (name, dst) { var i, a =[], z = Date.CultureInfo.timezones; if (!name) { name = (new Date()).getTimezone();} for (i = 0; i < z.length; i++) { if (z[i].name === name.toUpperCase()) { a.push(i); } } if (!z[a[0]]) { return null; } if (a.length === 1 || !dst) { return z[a[0]].offset; } else { for (i=0; i < a.length; i++) { if (z[a[i]].dst) { return z[a[i]].offset; } } } }; $D.getQuarter = function (d) { d = d || new Date(); // If no date supplied, use today var q = [1,2,3,4]; return q[Math.floor(d.getMonth() / 3)]; // ~~~ is a bitwise op. Faster than Math.floor }; $D.getDaysLeftInQuarter = function (d) { d = d || new Date(); var qEnd = new Date(d); qEnd.setMonth(qEnd.getMonth() + 3 - qEnd.getMonth() % 3, 0); return Math.floor((qEnd - d) / 8.64e7); }; // private var validate = function (n, min, max, name) { name = name ? name : "Object"; if (typeof n === "undefined") { return false; } else if (typeof n !== "number") { throw new TypeError(n + " is not a Number."); } else if (n < min || n > max) { // As failing validation is *not* an exceptional circumstance // lets not throw a RangeError Exception here. // It's semantically correct but it's not sensible. return false; } return true; }; /** * Validates the number is within an acceptable range for milliseconds [0-999]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateMillisecond = function (value) { return validate(value, 0, 999, "millisecond"); }; /** * Validates the number is within an acceptable range for seconds [0-59]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateSecond = function (value) { return validate(value, 0, 59, "second"); }; /** * Validates the number is within an acceptable range for minutes [0-59]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateMinute = function (value) { return validate(value, 0, 59, "minute"); }; /** * Validates the number is within an acceptable range for hours [0-23]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateHour = function (value) { return validate(value, 0, 23, "hour"); }; /** * Validates the number is within an acceptable range for the days in a month [0-MaxDaysInMonth]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateDay = function (value, year, month) { if (year === undefined || year === null || month === undefined || month === null) { return false;} return validate(value, 1, $D.getDaysInMonth(year, month), "day"); }; /** * Validates the number is within an acceptable range for months [0-11]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateWeek = function (value) { return validate(value, 0, 53, "week"); }; /** * Validates the number is within an acceptable range for months [0-11]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateMonth = function (value) { return validate(value, 0, 11, "month"); }; /** * Validates the number is within an acceptable range for years. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateYear = function (value) { /** * Per ECMAScript spec the range of times supported by Date objects is * exactly -100,000,000 days to +100,000,000 days measured relative to * midnight at the beginning of 01 January, 1970 UTC. * This gives a range of 8,640,000,000,000,000 milliseconds to either * side of 01 January, 1970 UTC. * * Earliest possible date: Tue, 20 Apr 271,822 B.C. 00:00:00 UTC * Latest possible date: Sat, 13 Sep 275,760 00:00:00 UTC */ return validate(value, -271822, 275760, "year"); }; $D.validateTimezone = function(value) { var timezones = {"ACDT":1,"ACST":1,"ACT":1,"ADT":1,"AEDT":1,"AEST":1,"AFT":1,"AKDT":1,"AKST":1,"AMST":1,"AMT":1,"ART":1,"AST":1,"AWDT":1,"AWST":1,"AZOST":1,"AZT":1,"BDT":1,"BIOT":1,"BIT":1,"BOT":1,"BRT":1,"BST":1,"BTT":1,"CAT":1,"CCT":1,"CDT":1,"CEDT":1,"CEST":1,"CET":1,"CHADT":1,"CHAST":1,"CHOT":1,"ChST":1,"CHUT":1,"CIST":1,"CIT":1,"CKT":1,"CLST":1,"CLT":1,"COST":1,"COT":1,"CST":1,"CT":1,"CVT":1,"CWST":1,"CXT":1,"DAVT":1,"DDUT":1,"DFT":1,"EASST":1,"EAST":1,"EAT":1,"ECT":1,"EDT":1,"EEDT":1,"EEST":1,"EET":1,"EGST":1,"EGT":1,"EIT":1,"EST":1,"FET":1,"FJT":1,"FKST":1,"FKT":1,"FNT":1,"GALT":1,"GAMT":1,"GET":1,"GFT":1,"GILT":1,"GIT":1,"GMT":1,"GST":1,"GYT":1,"HADT":1,"HAEC":1,"HAST":1,"HKT":1,"HMT":1,"HOVT":1,"HST":1,"ICT":1,"IDT":1,"IOT":1,"IRDT":1,"IRKT":1,"IRST":1,"IST":1,"JST":1,"KGT":1,"KOST":1,"KRAT":1,"KST":1,"LHST":1,"LINT":1,"MAGT":1,"MART":1,"MAWT":1,"MDT":1,"MET":1,"MEST":1,"MHT":1,"MIST":1,"MIT":1,"MMT":1,"MSK":1,"MST":1,"MUT":1,"MVT":1,"MYT":1,"NCT":1,"NDT":1,"NFT":1,"NPT":1,"NST":1,"NT":1,"NUT":1,"NZDT":1,"NZST":1,"OMST":1,"ORAT":1,"PDT":1,"PET":1,"PETT":1,"PGT":1,"PHOT":1,"PHT":1,"PKT":1,"PMDT":1,"PMST":1,"PONT":1,"PST":1,"PYST":1,"PYT":1,"RET":1,"ROTT":1,"SAKT":1,"SAMT":1,"SAST":1,"SBT":1,"SCT":1,"SGT":1,"SLST":1,"SRT":1,"SST":1,"SYOT":1,"TAHT":1,"THA":1,"TFT":1,"TJT":1,"TKT":1,"TLT":1,"TMT":1,"TOT":1,"TVT":1,"UCT":1,"ULAT":1,"UTC":1,"UYST":1,"UYT":1,"UZT":1,"VET":1,"VLAT":1,"VOLT":1,"VOST":1,"VUT":1,"WAKT":1,"WAST":1,"WAT":1,"WEDT":1,"WEST":1,"WET":1,"WST":1,"YAKT":1,"YEKT":1,"Z":1}; return (timezones[value] === 1); }; $D.validateTimezoneOffset= function(value) { // timezones go from +14hrs to -12hrs, the +X hours are negative offsets. return (value > -841 && value < 721); }; }()); (function () { var $D = Date, $P = $D.prototype, p = function (s, l) { if (!l) { l = 2; } return ("000" + s).slice(l * -1); }; var validateConfigObject = function (obj) { var result = {}, self = this, prop, testFunc; testFunc = function (prop, func, value) { if (prop === "day") { var month = (obj.month !== undefined) ? obj.month : self.getMonth(); var year = (obj.year !== undefined) ? obj.year : self.getFullYear(); return $D[func](value, year, month); } else { return $D[func](value); } }; for (prop in obj) { if (Object.prototype.hasOwnProperty.call(obj, prop)) { var func = "validate" + prop.charAt(0).toUpperCase() + prop.slice(1); if ($D[func] && obj[prop] !== null && testFunc(prop, func, obj[prop])) { result[prop] = obj[prop]; } } } return result; }; /** * Resets the time of this Date object to 12:00 AM (00:00), which is the start of the day. * @param {Boolean} .clone() this date instance before clearing Time * @return {Date} this */ $P.clearTime = function () { this.setHours(0); this.setMinutes(0); this.setSeconds(0); this.setMilliseconds(0); return this; }; /** * Resets the time of this Date object to the current time ('now'). * @return {Date} this */ $P.setTimeToNow = function () { var n = new Date(); this.setHours(n.getHours()); this.setMinutes(n.getMinutes()); this.setSeconds(n.getSeconds()); this.setMilliseconds(n.getMilliseconds()); return this; }; /** * Returns a new Date object that is an exact date and time copy of the original instance. * @return {Date} A new Date instance */ $P.clone = function () { return new Date(this.getTime()); }; /** * Compares this instance to a Date object and returns an number indication of their relative values. * @param {Date} Date object to compare [Required] * @return {Number} -1 = this is lessthan date. 0 = values are equal. 1 = this is greaterthan date. */ $P.compareTo = function (date) { return Date.compare(this, date); }; /** * Compares this instance to another Date object and returns true if they are equal. * @param {Date} Date object to compare. If no date to compare, new Date() [now] is used. * @return {Boolean} true if dates are equal. false if they are not equal. */ $P.equals = function (date) { return Date.equals(this, (date !== undefined ? date : new Date())); }; /** * Determines if this instance is between a range of two dates or equal to either the start or end dates. * @param {Date} Start of range [Required] * @param {Date} End of range [Required] * @return {Boolean} true is this is between or equal to the start and end dates, else false */ $P.between = function (start, end) { return this.getTime() >= start.getTime() && this.getTime() <= end.getTime(); }; /** * Determines if this date occurs after the date to compare to. * @param {Date} Date object to compare. If no date to compare, new Date() ("now") is used. * @return {Boolean} true if this date instance is greater than the date to compare to (or "now"), otherwise false. */ $P.isAfter = function (date) { return this.compareTo(date || new Date()) === 1; }; /** * Determines if this date occurs before the date to compare to. * @param {Date} Date object to compare. If no date to compare, new Date() ("now") is used. * @return {Boolean} true if this date instance is less than the date to compare to (or "now"). */ $P.isBefore = function (date) { return (this.compareTo(date || new Date()) === -1); }; /** * Determines if the current Date instance occurs today. * @return {Boolean} true if this date instance is 'today', otherwise false. */ /** * Determines if the current Date instance occurs on the same Date as the supplied 'date'. * If no 'date' to compare to is provided, the current Date instance is compared to 'today'. * @param {date} Date object to compare. If no date to compare, the current Date ("now") is used. * @return {Boolean} true if this Date instance occurs on the same Day as the supplied 'date'. */ $P.isToday = $P.isSameDay = function (date) { return this.clone().clearTime().equals((date || new Date()).clone().clearTime()); }; /** * Adds the specified number of milliseconds to this instance. * @param {Number} The number of milliseconds to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addMilliseconds = function (value) { if (!value) { return this; } this.setTime(this.getTime() + value * 1); return this; }; /** * Adds the specified number of seconds to this instance. * @param {Number} The number of seconds to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addSeconds = function (value) { if (!value) { return this; } return this.addMilliseconds(value * 1000); }; /** * Adds the specified number of seconds to this instance. * @param {Number} The number of seconds to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addMinutes = function (value) { if (!value) { return this; } return this.addMilliseconds(value * 60000); // 60*1000 }; /** * Adds the specified number of hours to this instance. * @param {Number} The number of hours to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addHours = function (value) { if (!value) { return this; } return this.addMilliseconds(value * 3600000); // 60*60*1000 }; /** * Adds the specified number of days to this instance. * @param {Number} The number of days to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addDays = function (value) { if (!value) { return this; } this.setDate(this.getDate() + value * 1); return this; }; /** * Adds the specified number of weekdays (ie - not sat or sun) to this instance. * @param {Number} The number of days to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addWeekdays = function (value) { if (!value) { return this; } var day = this.getDay(); var weeks = (Math.ceil(Math.abs(value)/7)); if (day === 0 || day === 6) { if (value > 0) { this.next().monday(); this.addDays(-1); day = this.getDay(); } } if (value < 0) { while (value < 0) { this.addDays(-1); day = this.getDay(); if (day !== 0 && day !== 6) { value++; } } return this; } else if (value > 5 || (6-day) <= value) { value = value + (weeks * 2); } return this.addDays(value); }; /** * Adds the specified number of weeks to this instance. * @param {Number} The number of weeks to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addWeeks = function (value) { if (!value) { return this; } return this.addDays(value * 7); }; /** * Adds the specified number of months to this instance. * @param {Number} The number of months to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addMonths = function (value) { if (!value) { return this; } var n = this.getDate(); this.setDate(1); this.setMonth(this.getMonth() + value * 1); this.setDate(Math.min(n, $D.getDaysInMonth(this.getFullYear(), this.getMonth()))); return this; }; $P.addQuarters = function (value) { if (!value) { return this; } // note this will take you to the same point in the quarter as you are now. // i.e. - if you are 15 days into the quarter you'll be 15 days into the resulting one. // bonus: this allows adding fractional quarters return this.addMonths(value * 3); }; /** * Adds the specified number of years to this instance. * @param {Number} The number of years to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addYears = function (value) { if (!value) { return this; } return this.addMonths(value * 12); }; /** * Adds (or subtracts) to the value of the years, months, weeks, days, hours, minutes, seconds, milliseconds of the date instance using given configuration object. Positive and Negative values allowed. * Example

	Date.today().add( { days: 1, months: 1 } )

	new Date().add( { years: -1 } )
	
* @param {Object} Configuration object containing attributes (months, days, etc.) * @return {Date} this */ $P.add = function (config) { if (typeof config === "number") { this._orient = config; return this; } var x = config; if (x.day) { // If we should be a different date than today (eg: for 'tomorrow -1d', etc). // Should only effect parsing, not direct usage (eg, Finish and FinishExact) if ((x.day - this.getDate()) !== 0) { this.setDate(x.day); } } if (x.milliseconds) { this.addMilliseconds(x.milliseconds); } if (x.seconds) { this.addSeconds(x.seconds); } if (x.minutes) { this.addMinutes(x.minutes); } if (x.hours) { this.addHours(x.hours); } if (x.weeks) { this.addWeeks(x.weeks); } if (x.months) { this.addMonths(x.months); } if (x.years) { this.addYears(x.years); } if (x.days) { this.addDays(x.days); } return this; }; /** * Get the week number. Week one (1) is the week which contains the first Thursday of the year. Monday is considered the first day of the week. * The .getWeek() function does NOT convert the date to UTC. The local datetime is used. * Please use .getISOWeek() to get the week of the UTC converted date. * @return {Number} 1 to 53 */ $P.getWeek = function (utc) { // Create a copy of this date object var self, target = new Date(this.valueOf()); if (utc) { target.addMinutes(target.getTimezoneOffset()); self = target.clone(); } else { self = this; } // ISO week date weeks start on monday // so correct the day number var dayNr = (self.getDay() + 6) % 7; // ISO 8601 states that week 1 is the week // with the first thursday of that year. // Set the target date to the thursday in the target week target.setDate(target.getDate() - dayNr + 3); // Store the millisecond value of the target date var firstThursday = target.valueOf(); // Set the target to the first thursday of the year // First set the target to january first target.setMonth(0, 1); // Not a thursday? Correct the date to the next thursday if (target.getDay() !== 4) { target.setMonth(0, 1 + ((4 - target.getDay()) + 7) % 7); } // The weeknumber is the number of weeks between the // first thursday of the year and the thursday in the target week return 1 + Math.ceil((firstThursday - target) / 604800000); // 604800000 = 7 * 24 * 3600 * 1000 }; /** * Get the ISO 8601 week number. Week one ("01") is the week which contains the first Thursday of the year. Monday is considered the first day of the week. * The .getISOWeek() function does convert the date to it's UTC value. Please use .getWeek() to get the week of the local date. * @return {String} "01" to "53" */ $P.getISOWeek = function () { return p(this.getWeek(true)); }; /** * Moves the date to Monday of the week set. Week one (1) is the week which contains the first Thursday of the year. * @param {Number} A Number (1 to 53) that represents the week of the year. * @return {Date} this */ $P.setWeek = function (n) { if ((n - this.getWeek()) === 0) { if (this.getDay() !== 1) { return this.moveToDayOfWeek(1, (this.getDay() > 1 ? -1 : 1)); } else { return this; } } else { return this.moveToDayOfWeek(1, (this.getDay() > 1 ? -1 : 1)).addWeeks(n - this.getWeek()); } }; $P.setQuarter = function (qtr) { var month = Math.abs(((qtr-1) * 3) + 1); return this.setMonth(month, 1); }; $P.getQuarter = function () { return Date.getQuarter(this); }; $P.getDaysLeftInQuarter = function () { return Date.getDaysLeftInQuarter(this); }; /** * Moves the date to the next n'th occurrence of the dayOfWeek starting from the beginning of the month. The number (-1) is a magic number and will return the last occurrence of the dayOfWeek in the month. * @param {Number} The dayOfWeek to move to * @param {Number} The n'th occurrence to move to. Use (-1) to return the last occurrence in the month * @return {Date} this */ $P.moveToNthOccurrence = function (dayOfWeek, occurrence) { if (dayOfWeek === "Weekday") { if (occurrence > 0) { this.moveToFirstDayOfMonth(); if (this.is().weekday()) { occurrence -= 1; } } else if (occurrence < 0) { this.moveToLastDayOfMonth(); if (this.is().weekday()) { occurrence += 1; } } else { return this; } return this.addWeekdays(occurrence); } var shift = 0; if (occurrence > 0) { shift = occurrence - 1; } else if (occurrence === -1) { this.moveToLastDayOfMonth(); if (this.getDay() !== dayOfWeek) { this.moveToDayOfWeek(dayOfWeek, -1); } return this; } return this.moveToFirstDayOfMonth().addDays(-1).moveToDayOfWeek(dayOfWeek, +1).addWeeks(shift); }; var moveToN = function (getFunc, addFunc, nVal) { return function (value, orient) { var diff = (value - this[getFunc]() + nVal * (orient || +1)) % nVal; return this[addFunc]((diff === 0) ? diff += nVal * (orient || +1) : diff); }; }; /** * Move to the next or last dayOfWeek based on the orient value. * @param {Number} The dayOfWeek to move to * @param {Number} Forward (+1) or Back (-1). Defaults to +1. [Optional] * @return {Date} this */ $P.moveToDayOfWeek = moveToN("getDay", "addDays", 7); /** * Move to the next or last month based on the orient value. * @param {Number} The month to move to. 0 = January, 11 = December * @param {Number} Forward (+1) or Back (-1). Defaults to +1. [Optional] * @return {Date} this */ $P.moveToMonth = moveToN("getMonth", "addMonths", 12); /** * Get the Ordinate of the current day ("th", "st", "rd"). * @return {String} */ $P.getOrdinate = function () { var num = this.getDate(); return ord(num); }; /** * Get the Ordinal day (numeric day number) of the year, adjusted for leap year. * @return {Number} 1 through 365 (366 in leap years) */ $P.getOrdinalNumber = function () { return Math.ceil((this.clone().clearTime() - new Date(this.getFullYear(), 0, 1)) / 86400000) + 1; }; /** * Get the time zone abbreviation of the current date. * @return {String} The abbreviated time zone name (e.g. "EST") */ $P.getTimezone = function () { return $D.getTimezoneAbbreviation(this.getUTCOffset(), this.isDaylightSavingTime()); }; $P.setTimezoneOffset = function (offset) { var here = this.getTimezoneOffset(), there = Number(offset) * -6 / 10; return (there || there === 0) ? this.addMinutes(there - here) : this; }; $P.setTimezone = function (offset) { return this.setTimezoneOffset($D.getTimezoneOffset(offset)); }; /** * Indicates whether Daylight Saving Time is observed in the current time zone. * @return {Boolean} true|false */ $P.hasDaylightSavingTime = function () { return (Date.today().set({month: 0, day: 1}).getTimezoneOffset() !== Date.today().set({month: 6, day: 1}).getTimezoneOffset()); }; /** * Indicates whether this Date instance is within the Daylight Saving Time range for the current time zone. * @return {Boolean} true|false */ $P.isDaylightSavingTime = function () { return Date.today().set({month: 0, day: 1}).getTimezoneOffset() !== this.getTimezoneOffset(); }; /** * Get the offset from UTC of the current date. * @return {String} The 4-character offset string prefixed with + or - (e.g. "-0500") */ $P.getUTCOffset = function (offset) { var n = (offset || this.getTimezoneOffset()) * -10 / 6, r; if (n < 0) { r = (n - 10000).toString(); return r.charAt(0) + r.substr(2); } else { r = (n + 10000).toString(); return "+" + r.substr(1); } }; /** * Returns the number of milliseconds between this date and date. * @param {Date} Defaults to now * @return {Number} The diff in milliseconds */ $P.getElapsed = function (date) { return (date || new Date()) - this; }; /** * Set the value of year, month, day, hour, minute, second, millisecond of date instance using given configuration object. * Example

	Date.today().set( { day: 20, month: 1 } )

	new Date().set( { millisecond: 0 } )
	
* * @param {Object} Configuration object containing attributes (month, day, etc.) * @return {Date} this */ $P.set = function (config) { config = validateConfigObject.call(this, config); var key; for (key in config) { if (Object.prototype.hasOwnProperty.call(config, key)) { var name = key.charAt(0).toUpperCase() + key.slice(1); var addFunc, getFunc; if (key !== "week" && key !== "month" && key !== "timezone" && key !== "timezoneOffset") { name += "s"; } addFunc = "add" + name; getFunc = "get" + name; if (key === "month") { addFunc = addFunc + "s"; } else if (key === "year"){ getFunc = "getFullYear"; } if (key !== "day" && key !== "timezone" && key !== "timezoneOffset" && key !== "week" && key !== "hour") { this[addFunc](config[key] - this[getFunc]()); } else if ( key === "timezone"|| key === "timezoneOffset" || key === "week" || key === "hour") { this["set"+name](config[key]); } } } // day has to go last because you can't validate the day without first knowing the month if (config.day) { this.addDays(config.day - this.getDate()); } return this; }; /** * Moves the date to the first day of the month. * @return {Date} this */ $P.moveToFirstDayOfMonth = function () { return this.set({ day: 1 }); }; /** * Moves the date to the last day of the month. * @return {Date} this */ $P.moveToLastDayOfMonth = function () { return this.set({ day: $D.getDaysInMonth(this.getFullYear(), this.getMonth())}); }; /** * Converts the value of the current Date object to its equivalent string representation. * Format Specifiers * CUSTOM DATE AND TIME FORMAT STRINGS * Format Description Example * ------ --------------------------------------------------------------------------- ----------------------- * s The seconds of the minute between 0-59. "0" to "59" * ss The seconds of the minute with leading zero if required. "00" to "59" * * m The minute of the hour between 0-59. "0" or "59" * mm The minute of the hour with leading zero if required. "00" or "59" * * h The hour of the day between 1-12. "1" to "12" * hh The hour of the day with leading zero if required. "01" to "12" * * H The hour of the day between 0-23. "0" to "23" * HH The hour of the day with leading zero if required. "00" to "23" * * d The day of the month between 1 and 31. "1" to "31" * dd The day of the month with leading zero if required. "01" to "31" * ddd Abbreviated day name. Date.CultureInfo.abbreviatedDayNames. "Mon" to "Sun" * dddd The full day name. Date.CultureInfo.dayNames. "Monday" to "Sunday" * * M The month of the year between 1-12. "1" to "12" * MM The month of the year with leading zero if required. "01" to "12" * MMM Abbreviated month name. Date.CultureInfo.abbreviatedMonthNames. "Jan" to "Dec" * MMMM The full month name. Date.CultureInfo.monthNames. "January" to "December" * * yy The year as a two-digit number. "99" or "08" * yyyy The full four digit year. "1999" or "2008" * * t Displays the first character of the A.M./P.M. designator. "A" or "P" * Date.CultureInfo.amDesignator or Date.CultureInfo.pmDesignator * tt Displays the A.M./P.M. designator. "AM" or "PM" * Date.CultureInfo.amDesignator or Date.CultureInfo.pmDesignator * * S The ordinal suffix ("st, "nd", "rd" or "th") of the current day. "st, "nd", "rd" or "th" * * STANDARD DATE AND TIME FORMAT STRINGS * Format Description Example *------ --------------------------------------------------------------------------- ----------------------- * d The CultureInfo shortDate Format Pattern "M/d/yyyy" * D The CultureInfo longDate Format Pattern "dddd, MMMM dd, yyyy" * F The CultureInfo fullDateTime Format Pattern "dddd, MMMM dd, yyyy h:mm:ss tt" * m The CultureInfo monthDay Format Pattern "MMMM dd" * r The CultureInfo rfc1123 Format Pattern "ddd, dd MMM yyyy HH:mm:ss GMT" * s The CultureInfo sortableDateTime Format Pattern "yyyy-MM-ddTHH:mm:ss" * t The CultureInfo shortTime Format Pattern "h:mm tt" * T The CultureInfo longTime Format Pattern "h:mm:ss tt" * u The CultureInfo universalSortableDateTime Format Pattern "yyyy-MM-dd HH:mm:ssZ" * y The CultureInfo yearMonth Format Pattern "MMMM, yyyy" * * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @return {String} A string representation of the current Date object. */ var ord = function (n) { switch (n * 1) { case 1: case 21: case 31: return "st"; case 2: case 22: return "nd"; case 3: case 23: return "rd"; default: return "th"; } }; var parseStandardFormats = function (format) { var y, c = Date.CultureInfo.formatPatterns; switch (format) { case "d": return this.toString(c.shortDate); case "D": return this.toString(c.longDate); case "F": return this.toString(c.fullDateTime); case "m": return this.toString(c.monthDay); case "r": case "R": y = this.clone().addMinutes(this.getTimezoneOffset()); return y.toString(c.rfc1123) + " GMT"; case "s": return this.toString(c.sortableDateTime); case "t": return this.toString(c.shortTime); case "T": return this.toString(c.longTime); case "u": y = this.clone().addMinutes(this.getTimezoneOffset()); return y.toString(c.universalSortableDateTime); case "y": return this.toString(c.yearMonth); default: return false; } }; var parseFormatStringsClosure = function (context) { return function (m) { if (m.charAt(0) === "\\") { return m.replace("\\", ""); } switch (m) { case "hh": return p(context.getHours() < 13 ? (context.getHours() === 0 ? 12 : context.getHours()) : (context.getHours() - 12)); case "h": return context.getHours() < 13 ? (context.getHours() === 0 ? 12 : context.getHours()) : (context.getHours() - 12); case "HH": return p(context.getHours()); case "H": return context.getHours(); case "mm": return p(context.getMinutes()); case "m": return context.getMinutes(); case "ss": return p(context.getSeconds()); case "s": return context.getSeconds(); case "yyyy": return p(context.getFullYear(), 4); case "yy": return p(context.getFullYear()); case "y": return context.getFullYear(); case "E": case "dddd": return Date.CultureInfo.dayNames[context.getDay()]; case "ddd": return Date.CultureInfo.abbreviatedDayNames[context.getDay()]; case "dd": return p(context.getDate()); case "d": return context.getDate(); case "MMMM": return Date.CultureInfo.monthNames[context.getMonth()]; case "MMM": return Date.CultureInfo.abbreviatedMonthNames[context.getMonth()]; case "MM": return p((context.getMonth() + 1)); case "M": return context.getMonth() + 1; case "t": return context.getHours() < 12 ? Date.CultureInfo.amDesignator.substring(0, 1) : Date.CultureInfo.pmDesignator.substring(0, 1); case "tt": return context.getHours() < 12 ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator; case "S": return ord(context.getDate()); case "W": return context.getWeek(); case "WW": return context.getISOWeek(); case "Q": return "Q" + context.getQuarter(); case "q": return String(context.getQuarter()); case "z": return context.getTimezone(); case "Z": case "X": return Date.getTimezoneOffset(context.getTimezone()); case "ZZ": // Timezone offset in seconds return context.getTimezoneOffset() * -60; case "u": return context.getDay(); case "L": return ($D.isLeapYear(context.getFullYear())) ? 1 : 0; case "B": // Swatch Internet Time (.beats) return "@"+((context.getUTCSeconds() + (context.getUTCMinutes()*60) + ((context.getUTCHours()+1)*3600))/86.4); default: return m; } }; }; $P.toString = function (format, ignoreStandards) { // Standard Date and Time Format Strings. Formats pulled from CultureInfo file and // may vary by culture. if (!ignoreStandards && format && format.length === 1) { output = parseStandardFormats.call(this, format); if (output) { return output; } } var parseFormatStrings = parseFormatStringsClosure(this); return format ? format.replace(/((\\)?(dd?d?d?|MM?M?M?|yy?y?y?|hh?|HH?|mm?|ss?|tt?|S|q|Q|WW?W?W?)(?![^\[]*\]))/g, parseFormatStrings).replace(/\[|\]/g, "") : this._toString(); }; }()); /************************************************************* * SugarPak - Domain Specific Language - Syntactical Sugar * *************************************************************/ (function () { var $D = Date, $P = $D.prototype, $N = Number.prototype; // private $P._orient = +1; // private $P._nth = null; // private $P._is = false; // private $P._same = false; // private $P._isSecond = false; // private $N._dateElement = "days"; /** * Moves the date to the next instance of a date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.today().next().friday();
	Date.today().next().fri();
	Date.today().next().march();
	Date.today().next().mar();
	Date.today().next().week();
	
* * @return {Date} date */ $P.next = function () { this._move = true; this._orient = +1; return this; }; /** * Creates a new Date (Date.today()) and moves the date to the next instance of the date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.next().friday();
	Date.next().fri();
	Date.next().march();
	Date.next().mar();
	Date.next().week();
	
* * @return {Date} date */ $D.next = function () { return $D.today().next(); }; /** * Moves the date to the previous instance of a date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.today().last().friday();
	Date.today().last().fri();
	Date.today().last().march();
	Date.today().last().mar();
	Date.today().last().week();
	
* * @return {Date} date */ $P.last = $P.prev = $P.previous = function () { this._move = true; this._orient = -1; return this; }; /** * Creates a new Date (Date.today()) and moves the date to the previous instance of the date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.last().friday();
	Date.last().fri();
	Date.previous().march();
	Date.prev().mar();
	Date.last().week();
	
* * @return {Date} date */ $D.last = $D.prev = $D.previous = function () { return $D.today().last(); }; /** * Performs a equality check when followed by either a month name, day name or .weekday() function. * Example

	Date.today().is().friday(); // true|false
	Date.today().is().fri();
	Date.today().is().march();
	Date.today().is().mar();
	
* * @return {Boolean} true|false */ $P.is = function () { this._is = true; return this; }; /** * Determines if two date objects occur on/in exactly the same instance of the subsequent date part function. * The function .same() must be followed by a date part function (example: .day(), .month(), .year(), etc). * * An optional Date can be passed in the date part function. If now date is passed as a parameter, 'Now' is used. * * The following example demonstrates how to determine if two dates fall on the exact same day. * * Example

	var d1 = Date.today(); // today at 00:00
	var d2 = new Date();   // exactly now.

	// Do they occur on the same day?
	d1.same().day(d2); // true
	
	// Do they occur on the same hour?
	d1.same().hour(d2); // false, unless d2 hour is '00' (midnight).
	
	// What if it's the same day, but one year apart?
	var nextYear = Date.today().add(1).year();

	d1.same().day(nextYear); // false, because the dates must occur on the exact same day. 
	
* * Scenario: Determine if a given date occurs during some week period 2 months from now. * * Example

	var future = Date.today().add(2).months();
	return someDate.same().week(future); // true|false;
	
* * @return {Boolean} true|false */ $P.same = function () { this._same = true; this._isSecond = false; return this; }; /** * Determines if the current date/time occurs during Today. Must be preceded by the .is() function. * Example

	someDate.is().today();    // true|false
	new Date().is().today();  // true
	Date.today().is().today();// true
	Date.today().add(-1).day().is().today(); // false
	
* * @return {Boolean} true|false */ $P.today = function () { return this.same().day(); }; /** * Determines if the current date is a weekday. This function must be preceded by the .is() function. * Example

	Date.today().is().weekday(); // true|false
	
* * @return {Boolean} true|false */ $P.weekday = function () { if (this._nth) { return df("Weekday").call(this); } if (this._move) { return this.addWeekdays(this._orient); } if (this._is) { this._is = false; return (!this.is().sat() && !this.is().sun()); } return false; }; /** * Determines if the current date is on the weekend. This function must be preceded by the .is() function. * Example

	Date.today().is().weekend(); // true|false
	
* * @return {Boolean} true|false */ $P.weekend = function () { if (this._is) { this._is = false; return (this.is().sat() || this.is().sun()); } return false; }; /** * Sets the Time of the current Date instance. A string "6:15 pm" or config object {hour:18, minute:15} are accepted. * Example

	// Set time to 6:15pm with a String
	Date.today().at("6:15pm");

	// Set time to 6:15pm with a config object
	Date.today().at({hour:18, minute:15});
	
* * @return {Date} date */ $P.at = function (time) { return (typeof time === "string") ? $D.parse(this.toString("d") + " " + time) : this.set(time); }; /** * Creates a new Date() and adds this (Number) to the date based on the preceding date element function (eg. second|minute|hour|day|month|year). * Example

	// Undeclared Numbers must be wrapped with parentheses. Requirment of JavaScript.
	(3).days().fromNow();
	(6).months().fromNow();

	// Declared Number variables do not require parentheses. 
	var n = 6;
	n.months().fromNow();
	
* * @return {Date} A new Date instance */ $N.fromNow = $N.after = function (date) { var c = {}; c[this._dateElement] = this; return ((!date) ? new Date() : date.clone()).add(c); }; /** * Creates a new Date() and subtract this (Number) from the date based on the preceding date element function (eg. second|minute|hour|day|month|year). * Example

	// Undeclared Numbers must be wrapped with parentheses. Requirment of JavaScript.
	(3).days().ago();
	(6).months().ago();

	// Declared Number variables do not require parentheses. 
	var n = 6;
	n.months().ago();
	
* * @return {Date} A new Date instance */ $N.ago = $N.before = function (date) { var c = {}, s = (this._dateElement[this._dateElement.length-1] !== "s") ? this._dateElement + "s" : this._dateElement; c[s] = this * -1; return ((!date) ? new Date() : date.clone()).add(c); }; // Do NOT modify the following string tokens. These tokens are used to build dynamic functions. // All culture-specific strings can be found in the CultureInfo files. var dx = ("sunday monday tuesday wednesday thursday friday saturday").split(/\s/), mx = ("january february march april may june july august september october november december").split(/\s/), px = ("Millisecond Second Minute Hour Day Week Month Year Quarter Weekday").split(/\s/), pxf = ("Milliseconds Seconds Minutes Hours Date Week Month FullYear Quarter").split(/\s/), nth = ("final first second third fourth fifth").split(/\s/), de; /** * Returns an object literal of all the date parts. * Example

	var o = new Date().toObject();
	
	// { year: 2008, month: 4, week: 20, day: 13, hour: 18, minute: 9, second: 32, millisecond: 812 }
	
	// The object properties can be referenced directly from the object.
	
	alert(o.day);  // alerts "13"
	alert(o.year); // alerts "2008"
	
* * @return {Date} An object literal representing the original date object. */ $P.toObject = function () { var o = {}; for (var i = 0; i < px.length; i++) { if (this["get" + pxf[i]]) { o[px[i].toLowerCase()] = this["get" + pxf[i]](); } } return o; }; /** * Returns a date created from an object literal. Ignores the .week property if set in the config. * Example

	var o = new Date().toObject();
	
	return Date.fromObject(o); // will return the same date. 

	var o2 = {month: 1, day: 20, hour: 18}; // birthday party!
	Date.fromObject(o2);
	
* * @return {Date} An object literal representing the original date object. */ $D.fromObject = function(config) { config.week = null; return Date.today().set(config); }; // Create day name functions and abbreviated day name functions (eg. monday(), friday(), fri()). var df = function (n) { return function () { if (this._is) { this._is = false; return this.getDay() === n; } if (this._move) { this._move = null; } if (this._nth !== null) { // If the .second() function was called earlier, remove the _orient // from the date, and then continue. // This is required because 'second' can be used in two different context. // // Example // // Date.today().add(1).second(); // Date.march().second().monday(); // // Things get crazy with the following... // Date.march().add(1).second().second().monday(); // but it works!! // if (this._isSecond) { this.addSeconds(this._orient * -1); } // make sure we reset _isSecond this._isSecond = false; var ntemp = this._nth; this._nth = null; var temp = this.clone().moveToLastDayOfMonth(); this.moveToNthOccurrence(n, ntemp); if (this > temp) { throw new RangeError($D.getDayName(n) + " does not occur " + ntemp + " times in the month of " + $D.getMonthName(temp.getMonth()) + " " + temp.getFullYear() + "."); } return this; } return this.moveToDayOfWeek(n, this._orient); }; }; var sdf = function (n) { return function () { var t = $D.today(), shift = n - t.getDay(); if (n === 0 && Date.CultureInfo.firstDayOfWeek === 1 && t.getDay() !== 0) { shift = shift + 7; } return t.addDays(shift); }; }; // Create month name functions and abbreviated month name functions (eg. january(), march(), mar()). var month_instance_functions = function (n) { return function () { if (this._is) { this._is = false; return this.getMonth() === n; } return this.moveToMonth(n, this._orient); }; }; var month_static_functions = function (n) { return function () { return $D.today().set({ month: n, day: 1 }); }; }; var processTerms = function (names, staticFunc, instanceFunc) { for (var i = 0; i < names.length; i++) { // Create constant static Name variables. $D[names[i].toUpperCase()] = $D[names[i].toUpperCase().substring(0, 3)] = i; // Create Name functions. $D[names[i]] = $D[names[i].substring(0, 3)] = staticFunc(i); // Create Name instance functions. $P[names[i]] = $P[names[i].substring(0, 3)] = instanceFunc(i); } }; processTerms(dx, sdf, df); processTerms(mx, month_static_functions, month_instance_functions); // Create date element functions and plural date element functions used with Date (eg. day(), days(), months()). var ef = function (j) { return function () { // if the .second() function was called earlier, the _orient // has alread been added. Just return this and reset _isSecond. if (this._isSecond) { this._isSecond = false; return this; } if (this._same) { this._same = this._is = false; var o1 = this.toObject(), o2 = (arguments[0] || new Date()).toObject(), v = "", k = j.toLowerCase(); // the substr trick with -1 doesn't work in IE8 or less k = (k[k.length-1] === "s") ? k.substring(0,k.length-1) : k; for (var m = (px.length - 1); m > -1; m--) { v = px[m].toLowerCase(); if (o1[v] !== o2[v]) { return false; } if (k === v) { break; } } return true; } if (j.substring(j.length - 1) !== "s") { j += "s"; } if (this._move) { this._move = null; } return this["add" + j](this._orient); }; }; var nf = function (n) { return function () { this._dateElement = n; return this; }; }; for (var k = 0; k < px.length; k++) { de = px[k].toLowerCase(); if(de !== "weekday") { // Create date element functions and plural date element functions used with Date (eg. day(), days(), months()). $P[de] = $P[de + "s"] = ef(px[k]); // Create date element functions and plural date element functions used with Number (eg. day(), days(), months()). $N[de] = $N[de + "s"] = nf(de + "s"); } } $P._ss = ef("Second"); var nthfn = function (n) { return function (dayOfWeek) { if (this._same) { return this._ss(arguments[0]); } if (dayOfWeek || dayOfWeek === 0) { return this.moveToNthOccurrence(dayOfWeek, n); } this._nth = n; // if the operator is 'second' add the _orient, then deal with it later... if (n === 2 && (dayOfWeek === undefined || dayOfWeek === null)) { this._isSecond = true; return this.addSeconds(this._orient); } return this; }; }; for (var l = 0; l < nth.length; l++) { $P[nth[l]] = (l === 0) ? nthfn(-1) : nthfn(l); } }()); (function () { "use strict"; Date.Parsing = { Exception: function (s) { this.message = "Parse error at '" + s.substring(0, 10) + " ...'"; } }; var $P = Date.Parsing; var dayOffsets = { standard: [0,31,59,90,120,151,181,212,243,273,304,334], leap: [0,31,60,91,121,152,182,213,244,274,305,335] }; $P.isLeapYear = function(year) { return ((year % 4 === 0) && (year % 100 !== 0)) || (year % 400 === 0); }; var utils = { multiReplace : function (str, hash ) { var key; for (key in hash) { if (Object.prototype.hasOwnProperty.call(hash, key)) { var regex; if (typeof hash[key] === "function") { } else { regex = (hash[key] instanceof RegExp) ? hash[key] : new RegExp(hash[key], "g"); } str = str.replace(regex, key); } } return str; }, getDayOfYearFromWeek : function (obj) { var d, jan4, offset; obj.weekDay = (!obj.weekDay && obj.weekDay !== 0) ? 1 : obj.weekDay; d = new Date(obj.year, 0, 4); jan4 = d.getDay() === 0 ? 7 : d.getDay(); // JS is 0 indexed on Sunday. offset = jan4+3; obj.dayOfYear = ((obj.week * 7) + (obj.weekDay === 0 ? 7 : obj.weekDay))-offset; return obj; }, getDayOfYear : function (obj, dayOffset) { if (!obj.dayOfYear) { obj = utils.getDayOfYearFromWeek(obj); } for (var i=0;i <= dayOffset.length;i++) { if (obj.dayOfYear < dayOffset[i] || i === dayOffset.length) { obj.day = obj.day ? obj.day : (obj.dayOfYear - dayOffset[i-1]); break; } else { obj.month = i; } } return obj; }, adjustForTimeZone : function (obj, date) { var offset; if (obj.zone.toUpperCase() === "Z" || (obj.zone_hours === 0 && obj.zone_minutes === 0)) { // it's UTC/GML so work out the current timeszone offset offset = -date.getTimezoneOffset(); } else { offset = (obj.zone_hours*60) + (obj.zone_minutes || 0); if (obj.zone_sign === "+") { offset *= -1; } offset -= date.getTimezoneOffset(); } date.setMinutes(date.getMinutes()+offset); return date; }, setDefaults : function (obj) { obj.year = obj.year || Date.today().getFullYear(); obj.hours = obj.hours || 0; obj.minutes = obj.minutes || 0; obj.seconds = obj.seconds || 0; obj.milliseconds = obj.milliseconds || 0; if (!(!obj.month && (obj.week || obj.dayOfYear))) { // if we have a month, or if we don't but don't have the day calculation data obj.month = obj.month || 0; obj.day = obj.day || 1; } return obj; }, dataNum: function (data, mod, explict, postProcess) { var dataNum = data*1; if (mod) { if (postProcess) { return data ? mod(data)*1 : data; } else { return data ? mod(dataNum) : data; } } else if (!explict){ return data ? dataNum : data; } else { return (data && typeof data !== "undefined") ? dataNum : data; } }, timeDataProcess: function (obj) { var timeObj = {}; for (var x in obj.data) { if (obj.data.hasOwnProperty(x)) { timeObj[x] = obj.ignore[x] ? obj.data[x] : utils.dataNum(obj.data[x], obj.mods[x], obj.explict[x], obj.postProcess[x]); } } if (obj.data.secmins) { obj.data.secmins = obj.data.secmins.replace(",", ".") * 60; if (!timeObj.minutes) { timeObj.minutes = obj.data.secmins; } else if (!timeObj.seconds) { timeObj.seconds = obj.data.secmins; } delete obj.secmins; } return timeObj; }, buildTimeObjectFromData: function (data) { var time = utils.timeDataProcess({ data: { year : data[1], month : data[5], day : data[7], week : data[8], dayOfYear : data[10], hours : data[15], zone_hours : data[23], zone_minutes : data[24], zone : data[21], zone_sign : data[22], weekDay : data[9], minutes: data[16], seconds: data[19], milliseconds: data[20], secmins: data[18] }, mods: { month: function(data) { return data-1; }, weekDay: function (data) { data = Math.abs(data); return (data === 7 ? 0 : data); }, minutes: function (data) { return data.replace(":",""); }, seconds: function (data) { return Math.floor( (data.replace(":","").replace(",","."))*1 ); }, milliseconds: function (data) { return (data.replace(",",".")*1000); } }, postProcess: { minutes: true, seconds: true, milliseconds: true }, explict: { zone_hours: true, zone_minutes: true }, ignore: { zone: true, zone_sign: true, secmins: true } }); return time; }, addToHash: function (hash, keys, data) { keys = keys; data = data; var len = keys.length; for (var i = 0; i < len; i++) { hash[keys[i]] = data[i]; } return hash; }, combineRegex: function (r1, r2) { return new RegExp("(("+r1.source+")\\s("+r2.source+"))"); }, getDateNthString: function(add, last, inc){ if (add) { return Date.today().addDays(inc).toString("d"); } else if (last) { return Date.today().last()[inc]().toString("d"); } }, buildRegexData: function (array) { var arr = []; var len = array.length; for (var i=0; i < len; i++) { if (Object.prototype.toString.call(array[i]) === '[object Array]') { // oldIE compat version of Array.isArray arr.push(this.combineRegex(array[i][0], array[i][1])); } else { arr.push(array[i]); } } return arr; } }; $P.processTimeObject = function (obj) { var date, dayOffset; utils.setDefaults(obj); dayOffset = ($P.isLeapYear(obj.year)) ? dayOffsets.leap : dayOffsets.standard; if (!obj.month && (obj.week || obj.dayOfYear)) { utils.getDayOfYear(obj, dayOffset); } else { obj.dayOfYear = dayOffset[obj.month] + obj.day; } date = new Date(obj.year, obj.month, obj.day, obj.hours, obj.minutes, obj.seconds, obj.milliseconds); if (obj.zone) { utils.adjustForTimeZone(obj, date); // adjust (and calculate) for timezone } return date; }; $P.ISO = { regex : /^([\+-]?\d{4}(?!\d{2}\b))((-?)((0[1-9]|1[0-2])(\3([12]\d|0[1-9]|3[01]))?|W([0-4]\d|5[0-3])(-?[1-7])?|(00[1-9]|0[1-9]\d|[12]\d{2}|3([0-5]\d|6[1-6])))([T\s]((([01]\d|2[0-4])((:?)[0-5]\d)?|24\:?00)([\.,]\d+(?!:))?)?(\17[0-5]\d([\.,]\d+)?)?\s?([zZ]|([\+-])([01]\d|2[0-3]):?([0-5]\d)?)?)?)?$/, parse : function (s) { var time, data = s.match(this.regex); if (!data || !data.length) { return null; } time = utils.buildTimeObjectFromData(data); if (!time.year || (!time.year && (!time.month && !time.day) && (!time.week && !time.dayOfYear)) ) { return null; } return $P.processTimeObject(time); } }; $P.Numeric = { isNumeric: function (e){return!isNaN(parseFloat(e))&&isFinite(e);}, regex: /\b([0-1]?[0-9])([0-3]?[0-9])([0-2]?[0-9]?[0-9][0-9])\b/i, parse: function (s) { var data, i, time = {}, order = Date.CultureInfo.dateElementOrder.split(""); if (!(this.isNumeric(s)) || // if it's non-numeric OR (s[0] === "+" && s[0] === "-")) { // It's an arithmatic string (eg +/-1000) return null; } if (s.length < 5 && s.indexOf(".") < 0 && s.indexOf("/") < 0) { // assume it's just a year. time.year = s; return $P.processTimeObject(time); } data = s.match(this.regex); if (!data || !data.length) { return null; } for (i=0; i < order.length; i++) { switch(order[i]) { case "d": time.day = data[i+1]; break; case "m": time.month = (data[i+1]-1); break; case "y": time.year = data[i+1]; break; } } return $P.processTimeObject(time); } }; $P.Normalizer = { regexData: function () { var $R = Date.CultureInfo.regexPatterns; return utils.buildRegexData([ $R.tomorrow, $R.yesterday, [$R.past, $R.mon], [$R.past, $R.tue], [$R.past, $R.wed], [$R.past, $R.thu], [$R.past, $R.fri], [$R.past, $R.sat], [$R.past, $R.sun] ]); }, basicReplaceHash : function() { var $R = Date.CultureInfo.regexPatterns; return { "January": $R.jan.source, "February": $R.feb, "March": $R.mar, "April": $R.apr, "May": $R.may, "June": $R.jun, "July": $R.jul, "August": $R.aug, "September": $R.sep, "October": $R.oct, "November": $R.nov, "December": $R.dec, "": /\bat\b/gi, " ": /\s{2,}/, "am": $R.inTheMorning, "9am": $R.thisMorning, "pm": $R.inTheEvening, "7pm":$R.thisEvening }; }, keys : function(){ return [ utils.getDateNthString(true, false, 1), // tomorrow utils.getDateNthString(true, false, -1), // yesterday utils.getDateNthString(false, true, "monday"), //last mon utils.getDateNthString(false, true, "tuesday"), //last tues utils.getDateNthString(false, true, "wednesday"), //last wed utils.getDateNthString(false, true, "thursday"), //last thurs utils.getDateNthString(false, true, "friday"), //last fri utils.getDateNthString(false, true, "saturday"), //last sat utils.getDateNthString(false, true, "sunday") //last sun ]; }, buildRegexFunctions: function () { var $R = Date.CultureInfo.regexPatterns; var __ = Date.i18n.__; var tomorrowRE = new RegExp("(\\b\\d\\d?("+__("AM")+"|"+__("PM")+")? )("+$R.tomorrow.source.slice(1)+")", "i"); // adapted tomorrow regex for AM PM relative dates var todayRE = new RegExp($R.today.source + "(?!\\s*([+-]))\\b"); // today, but excludes the math operators (eg "today + 2h") this.replaceFuncs = [ [todayRE, function (full) { return (full.length > 1) ? Date.today().toString("d") : full; }], [tomorrowRE, function(full, m1) { var t = Date.today().addDays(1).toString("d"); return (t + " " + m1); }], [$R.amThisMorning, function(str, am){return am;}], [$R.pmThisEvening, function(str, pm){return pm;}] ]; }, buildReplaceData: function () { this.buildRegexFunctions(); this.replaceHash = utils.addToHash(this.basicReplaceHash(), this.keys(), this.regexData()); }, stringReplaceFuncs: function (s) { for (var i=0; i < this.replaceFuncs.length; i++) { s = s.replace(this.replaceFuncs[i][0], this.replaceFuncs[i][1]); } return s; }, parse: function (s) { s = this.stringReplaceFuncs(s); s = utils.multiReplace(s, this.replaceHash); try { var n = s.split(/([\s\-\.\,\/\x27]+)/); if (n.length === 3 && $P.Numeric.isNumeric(n[0]) && $P.Numeric.isNumeric(n[2]) && (n[2].length >= 4)) { // ok, so we're dealing with x/year. But that's not a full date. // This fixes wonky dateElementOrder parsing when set to dmy order. if (Date.CultureInfo.dateElementOrder[0] === "d") { s = "1/" + n[0] + "/" + n[2]; // set to 1st of month and normalize the seperator } } } catch (e) {} return s; } }; $P.Normalizer.buildReplaceData(); }()); (function () { var $P = Date.Parsing; var _ = $P.Operators = { // // Tokenizers // rtoken: function (r) { // regex token return function (s) { var mx = s.match(r); if (mx) { return ([ mx[0], s.substring(mx[0].length) ]); } else { throw new $P.Exception(s); } }; }, token: function () { // whitespace-eating token return function (s) { return _.rtoken(new RegExp("^\\s*" + s + "\\s*"))(s); }; }, stoken: function (s) { // string token return _.rtoken(new RegExp("^" + s)); }, // Atomic Operators until: function (p) { return function (s) { var qx = [], rx = null; while (s.length) { try { rx = p.call(this, s); } catch (e) { qx.push(rx[0]); s = rx[1]; continue; } break; } return [ qx, s ]; }; }, many: function (p) { return function (s) { var rx = [], r = null; while (s.length) { try { r = p.call(this, s); } catch (e) { return [ rx, s ]; } rx.push(r[0]); s = r[1]; } return [ rx, s ]; }; }, // generator operators -- see below optional: function (p) { return function (s) { var r = null; try { r = p.call(this, s); } catch (e) { return [ null, s ]; } return [ r[0], r[1] ]; }; }, not: function (p) { return function (s) { try { p.call(this, s); } catch (e) { return [null, s]; } throw new $P.Exception(s); }; }, ignore: function (p) { return p ? function (s) { var r = null; r = p.call(this, s); return [null, r[1]]; } : null; }, product: function () { var px = arguments[0], qx = Array.prototype.slice.call(arguments, 1), rx = []; for (var i = 0 ; i < px.length ; i++) { rx.push(_.each(px[i], qx)); } return rx; }, cache: function (rule) { var cache = {}, cache_length = 0, cache_keys = [], CACHE_MAX = Date.Config.CACHE_MAX || 100000, r = null; var cacheCheck = function () { if (cache_length === CACHE_MAX) { // kill several keys, don't want to have to do this all the time... for (var i=0; i < 10; i++) { var key = cache_keys.shift(); if (key) { delete cache[key]; cache_length--; } } } }; return function (s) { cacheCheck(); try { r = cache[s] = (cache[s] || rule.call(this, s)); } catch (e) { r = cache[s] = e; } cache_length++; cache_keys.push(s); if (r instanceof $P.Exception) { throw r; } else { return r; } }; }, // vector operators -- see below any: function () { var px = arguments; return function (s) { var r = null; for (var i = 0; i < px.length; i++) { if (px[i] == null) { continue; } try { r = (px[i].call(this, s)); } catch (e) { r = null; } if (r) { return r; } } throw new $P.Exception(s); }; }, each: function () { var px = arguments; return function (s) { var rx = [], r = null; for (var i = 0; i < px.length ; i++) { if (px[i] == null) { continue; } try { r = (px[i].call(this, s)); } catch (e) { throw new $P.Exception(s); } rx.push(r[0]); s = r[1]; } return [ rx, s]; }; }, all: function () { var px = arguments, _ = _; return _.each(_.optional(px)); }, // delimited operators sequence: function (px, d, c) { d = d || _.rtoken(/^\s*/); c = c || null; if (px.length === 1) { return px[0]; } return function (s) { var r = null, q = null; var rx = []; for (var i = 0; i < px.length ; i++) { try { r = px[i].call(this, s); } catch (e) { break; } rx.push(r[0]); try { q = d.call(this, r[1]); } catch (ex) { q = null; break; } s = q[1]; } if (!r) { throw new $P.Exception(s); } if (q) { throw new $P.Exception(q[1]); } if (c) { try { r = c.call(this, r[1]); } catch (ey) { throw new $P.Exception(r[1]); } } return [ rx, (r?r[1]:s) ]; }; }, // // Composite Operators // between: function (d1, p, d2) { d2 = d2 || d1; var _fn = _.each(_.ignore(d1), p, _.ignore(d2)); return function (s) { var rx = _fn.call(this, s); return [[rx[0][0], r[0][2]], rx[1]]; }; }, list: function (p, d, c) { d = d || _.rtoken(/^\s*/); c = c || null; return (p instanceof Array ? _.each(_.product(p.slice(0, -1), _.ignore(d)), p.slice(-1), _.ignore(c)) : _.each(_.many(_.each(p, _.ignore(d))), px, _.ignore(c))); }, set: function (px, d, c) { d = d || _.rtoken(/^\s*/); c = c || null; return function (s) { // r is the current match, best the current 'best' match // which means it parsed the most amount of input var r = null, p = null, q = null, rx = null, best = [[], s], last = false; // go through the rules in the given set for (var i = 0; i < px.length ; i++) { // last is a flag indicating whether this must be the last element // if there is only 1 element, then it MUST be the last one q = null; p = null; r = null; last = (px.length === 1); // first, we try simply to match the current pattern // if not, try the next pattern try { r = px[i].call(this, s); } catch (e) { continue; } // since we are matching against a set of elements, the first // thing to do is to add r[0] to matched elements rx = [[r[0]], r[1]]; // if we matched and there is still input to parse and // we don't already know this is the last element, // we're going to next check for the delimiter ... // if there's none, or if there's no input left to parse // than this must be the last element after all ... if (r[1].length > 0 && ! last) { try { q = d.call(this, r[1]); } catch (ex) { last = true; } } else { last = true; } // if we parsed the delimiter and now there's no more input, // that means we shouldn't have parsed the delimiter at all // so don't update r and mark this as the last element ... if (!last && q[1].length === 0) { last = true; } // so, if this isn't the last element, we're going to see if // we can get any more matches from the remaining (unmatched) // elements ... if (!last) { // build a list of the remaining rules we can match against, // i.e., all but the one we just matched against var qx = []; for (var j = 0; j < px.length ; j++) { if (i !== j) { qx.push(px[j]); } } // now invoke recursively set with the remaining input // note that we don't include the closing delimiter ... // we'll check for that ourselves at the end p = _.set(qx, d).call(this, q[1]); // if we got a non-empty set as a result ... // (otw rx already contains everything we want to match) if (p[0].length > 0) { // update current result, which is stored in rx ... // basically, pick up the remaining text from p[1] // and concat the result from p[0] so that we don't // get endless nesting ... rx[0] = rx[0].concat(p[0]); rx[1] = p[1]; } } // at this point, rx either contains the last matched element // or the entire matched set that starts with this element. // now we just check to see if this variation is better than // our best so far, in terms of how much of the input is parsed if (rx[1].length < best[1].length) { best = rx; } // if we've parsed all the input, then we're finished if (best[1].length === 0) { break; } } // so now we've either gone through all the patterns trying them // as the initial match; or we found one that parsed the entire // input string ... // if best has no matches, just return empty set ... if (best[0].length === 0) { return best; } // if a closing delimiter is provided, then we have to check it also if (c) { // we try this even if there is no remaining input because the pattern // may well be optional or match empty input ... try { q = c.call(this, best[1]); } catch (ey) { throw new $P.Exception(best[1]); } // it parsed ... be sure to update the best match remaining input best[1] = q[1]; } // if we're here, either there was no closing delimiter or we parsed it // so now we have the best match; just return it! return best; }; }, forward: function (gr, fname) { return function (s) { return gr[fname].call(this, s); }; }, // // Translation Operators // replace: function (rule, repl) { return function (s) { var r = rule.call(this, s); return [repl, r[1]]; }; }, process: function (rule, fn) { return function (s) { var r = rule.call(this, s); return [fn.call(this, r[0]), r[1]]; }; }, min: function (min, rule) { return function (s) { var rx = rule.call(this, s); if (rx[0].length < min) { throw new $P.Exception(s); } return rx; }; } }; // Generator Operators And Vector Operators // Generators are operators that have a signature of F(R) => R, // taking a given rule and returning another rule, such as // ignore, which parses a given rule and throws away the result. // Vector operators are those that have a signature of F(R1,R2,...) => R, // take a list of rules and returning a new rule, such as each. // Generator operators are converted (via the following _generator // function) into functions that can also take a list or array of rules // and return an array of new rules as though the function had been // called on each rule in turn (which is what actually happens). // This allows generators to be used with vector operators more easily. // Example: // each(ignore(foo, bar)) instead of each(ignore(foo), ignore(bar)) // This also turns generators into vector operators, which allows // constructs like: // not(cache(foo, bar)) var _generator = function (op) { function gen() { var args = null, rx = [], px, i; if (arguments.length > 1) { args = Array.prototype.slice.call(arguments); } else if (arguments[0] instanceof Array) { args = arguments[0]; } if (args) { px = args.shift(); if (px.length > 0) { args.unshift(px[i]); rx.push(op.apply(null, args)); args.shift(); return rx; } } else { return op.apply(null, arguments); } } return gen; }; var gx = "optional not ignore cache".split(/\s/); for (var i = 0 ; i < gx.length ; i++) { _[gx[i]] = _generator(_[gx[i]]); } var _vector = function (op) { return function () { if (arguments[0] instanceof Array) { return op.apply(null, arguments[0]); } else { return op.apply(null, arguments); } }; }; var vx = "each any all".split(/\s/); for (var j = 0 ; j < vx.length ; j++) { _[vx[j]] = _vector(_[vx[j]]); } }()); (function () { var $D = Date; var flattenAndCompact = function (ax) { var rx = []; for (var i = 0; i < ax.length; i++) { if (ax[i] instanceof Array) { rx = rx.concat(flattenAndCompact(ax[i])); } else { if (ax[i]) { rx.push(ax[i]); } } } return rx; }; var parseMeridian = function () { if (this.meridian && (this.hour || this.hour === 0)) { if (this.meridian === "a" && this.hour > 11 && Date.Config.strict24hr){ throw "Invalid hour and meridian combination"; } else if (this.meridian === "p" && this.hour < 12 && Date.Config.strict24hr){ throw "Invalid hour and meridian combination"; } else if (this.meridian === "p" && this.hour < 12) { this.hour = this.hour + 12; } else if (this.meridian === "a" && this.hour === 12) { this.hour = 0; } } }; var setDefaults = function () { var now = new Date(); if ((this.hour || this.minute) && (!this.month && !this.year && !this.day)) { this.day = now.getDate(); } if (!this.year) { this.year = now.getFullYear(); } if (!this.month && this.month !== 0) { this.month = now.getMonth(); } if (!this.day) { this.day = 1; } if (!this.hour) { this.hour = 0; } if (!this.minute) { this.minute = 0; } if (!this.second) { this.second = 0; } if (!this.millisecond) { this.millisecond = 0; } }; var finishUtils = { getToday: function () { if (this.now || "hour minute second".indexOf(this.unit) !== -1) { return new Date(); } else { return $D.today(); } }, setDaysFromWeekday: function (today, orient){ var gap; orient = orient || 1; this.unit = "day"; gap = ($D.getDayNumberFromName(this.weekday) - today.getDay()); this.days = gap ? ((gap + (orient * 7)) % 7) : (orient * 7); return this; }, setMonthsFromMonth: function (today, orient) { var gap; orient = orient || 1; this.unit = "month"; gap = (this.month - today.getMonth()); this.months = gap ? ((gap + (orient * 12)) % 12) : (orient * 12); this.month = null; return this; }, setDMYFromWeekday: function () { var d = Date[this.weekday](); this.day = d.getDate(); if (!this.month) { this.month = d.getMonth(); } this.year = d.getFullYear(); return this; }, setUnitValue: function (orient) { if (!this.value && this.operator && this.operator !== null && this[this.unit + "s"] && this[this.unit + "s"] !== null) { this[this.unit + "s"] = this[this.unit + "s"] + ((this.operator === "add") ? 1 : -1) + (this.value||0) * orient; } else if (this[this.unit + "s"] == null || this.operator != null) { if (!this.value) { this.value = 1; } this[this.unit + "s"] = this.value * orient; } }, generateDateFromWeeks: function () { var weekday = (this.weekday !== undefined) ? this.weekday : "today"; var d = Date[weekday]().addWeeks(this.weeks); if (this.now) { d.setTimeToNow(); } return d; } }; $D.Translator = { hour: function (s) { return function () { this.hour = Number(s); }; }, minute: function (s) { return function () { this.minute = Number(s); }; }, second: function (s) { return function () { this.second = Number(s); }; }, /* for ss.s format */ secondAndMillisecond: function (s) { return function () { var mx = s.match(/^([0-5][0-9])\.([0-9]{1,3})/); this.second = Number(mx[1]); this.millisecond = Number(mx[2]); }; }, meridian: function (s) { return function () { this.meridian = s.slice(0, 1).toLowerCase(); }; }, timezone: function (s) { return function () { var n = s.replace(/[^\d\+\-]/g, ""); if (n.length) { this.timezoneOffset = Number(n); } else { this.timezone = s.toLowerCase(); } }; }, day: function (x) { var s = x[0]; return function () { this.day = Number(s.match(/\d+/)[0]); if (this.day < 1) { throw "invalid day"; } }; }, month: function (s) { return function () { this.month = (s.length === 3) ? "jan feb mar apr may jun jul aug sep oct nov dec".indexOf(s)/4 : Number(s) - 1; if (this.month < 0) { throw "invalid month"; } }; }, year: function (s) { return function () { var n = Number(s); this.year = ((s.length > 2) ? n : (n + (((n + 2000) < Date.CultureInfo.twoDigitYearMax) ? 2000 : 1900))); }; }, rday: function (s) { return function () { switch (s) { case "yesterday": this.days = -1; break; case "tomorrow": this.days = 1; break; case "today": this.days = 0; break; case "now": this.days = 0; this.now = true; break; } }; }, finishExact: function (x) { var d; x = (x instanceof Array) ? x : [x]; for (var i = 0 ; i < x.length ; i++) { if (x[i]) { x[i].call(this); } } setDefaults.call(this); parseMeridian.call(this); if (this.day > $D.getDaysInMonth(this.year, this.month)) { throw new RangeError(this.day + " is not a valid value for days."); } d = new Date(this.year, this.month, this.day, this.hour, this.minute, this.second, this.millisecond); if (this.year < 100) { d.setFullYear(this.year); // means years less that 100 are process correctly. JS will parse it otherwise as 1900-1999. } if (this.timezone) { d.set({ timezone: this.timezone }); } else if (this.timezoneOffset) { d.set({ timezoneOffset: this.timezoneOffset }); } return d; }, finish: function (x) { var today, expression, orient, temp; x = (x instanceof Array) ? flattenAndCompact(x) : [ x ]; if (x.length === 0) { return null; } for (var i = 0 ; i < x.length ; i++) { if (typeof x[i] === "function") { x[i].call(this); } } if (this.now && !this.unit && !this.operator) { return new Date(); } else { today = finishUtils.getToday.call(this); } expression = !!(this.days && this.days !== null || this.orient || this.operator); orient = ((this.orient === "past" || this.operator === "subtract") ? -1 : 1); if (this.month && this.unit === "week") { this.value = this.month + 1; delete this.month; delete this.day; } if ((this.month || this.month === 0) && "year day hour minute second".indexOf(this.unit) !== -1) { if (!this.value) { this.value = this.month + 1; } this.month = null; expression = true; } if (!expression && this.weekday && !this.day && !this.days) { finishUtils.setDMYFromWeekday.call(this); } if (expression && this.weekday && this.unit !== "month" && this.unit !== "week") { finishUtils.setDaysFromWeekday.call(this, today, orient); } if (this.weekday && this.unit !== "week" && !this.day && !this.days) { temp = Date[this.weekday](); this.day = temp.getDate(); if (temp.getMonth() !== today.getMonth()) { this.month = temp.getMonth(); } } if (this.month && this.unit === "day" && this.operator) { if (!this.value) { this.value = (this.month + 1); } this.month = null; } if (this.value != null && this.month != null && this.year != null) { this.day = this.value * 1; } if (this.month && !this.day && this.value) { today.set({ day: this.value * 1 }); if (!expression) { this.day = this.value * 1; } } if (!this.month && this.value && this.unit === "month" && !this.now) { this.month = this.value; expression = true; } if (expression && (this.month || this.month === 0) && this.unit !== "year") { finishUtils.setMonthsFromMonth.call(this, today, orient); } if (!this.unit) { this.unit = "day"; } finishUtils.setUnitValue.call(this, orient); parseMeridian.call(this); if ((this.month || this.month === 0) && !this.day) { this.day = 1; } if (!this.orient && !this.operator && this.unit === "week" && this.value && !this.day && !this.month) { return Date.today().setWeek(this.value); } if (this.unit === "week" && this.weeks && !this.day && !this.month) { return finishUtils.generateDateFromWeeks.call(this); } if (expression && this.timezone && this.day && this.days) { this.day = this.days; } if (expression){ today.add(this); } else { today.set(this); } if (this.timezone) { this.timezone = this.timezone.toUpperCase(); var offset = $D.getTimezoneOffset(this.timezone); var timezone; if (today.hasDaylightSavingTime()) { // lets check that we're being sane with timezone setting timezone = $D.getTimezoneAbbreviation(offset, today.isDaylightSavingTime()); if (timezone !== this.timezone) { // bugger, we're in a place where things like EST vs EDT matters. if (today.isDaylightSavingTime()) { today.addHours(-1); } else { today.addHours(1); } } } today.setTimezoneOffset(offset); } return today; } }; }()); (function () { var $D = Date; $D.Grammar = {}; var _ = $D.Parsing.Operators, g = $D.Grammar, t = $D.Translator, _fn; // Allow rolling up into general purpose rules _fn = function () { return _.each(_.any.apply(null, arguments), _.not(g.ctoken2("timeContext"))); }; g.datePartDelimiter = _.rtoken(/^([\s\-\.\,\/\x27]+)/); g.timePartDelimiter = _.stoken(":"); g.whiteSpace = _.rtoken(/^\s*/); g.generalDelimiter = _.rtoken(/^(([\s\,]|at|@|on)+)/); var _C = {}; g.ctoken = function (keys) { var fn = _C[keys]; if (! fn) { var c = Date.CultureInfo.regexPatterns; var kx = keys.split(/\s+/), px = []; for (var i = 0; i < kx.length ; i++) { px.push(_.replace(_.rtoken(c[kx[i]]), kx[i])); } fn = _C[keys] = _.any.apply(null, px); } return fn; }; g.ctoken2 = function (key) { return _.rtoken(Date.CultureInfo.regexPatterns[key]); }; var cacheProcessRtoken = function (key, token, type, eachToken) { if (eachToken) { g[key] = _.cache(_.process(_.each(_.rtoken(token),_.optional(g.ctoken2(eachToken))), type)); } else { g[key] = _.cache(_.process(_.rtoken(token), type)); } }; var cacheProcessCtoken = function (token, type) { return _.cache(_.process(g.ctoken2(token), type)); }; var _F = {}; //function cache var _get = function (f) { _F[f] = (_F[f] || g.format(f)[0]); return _F[f]; }; g.allformats = function (fx) { var rx = []; if (fx instanceof Array) { for (var i = 0; i < fx.length; i++) { rx.push(_get(fx[i])); } } else { rx.push(_get(fx)); } return rx; }; g.formats = function (fx) { if (fx instanceof Array) { var rx = []; for (var i = 0 ; i < fx.length ; i++) { rx.push(_get(fx[i])); } return _.any.apply(null, rx); } else { return _get(fx); } }; var grammarFormats = { timeFormats: function(){ var i, RTokenKeys = [ "h", "hh", "H", "HH", "m", "mm", "s", "ss", "ss.s", "z", "zz" ], RToken = [ /^(0[0-9]|1[0-2]|[1-9])/, /^(0[0-9]|1[0-2])/, /^([0-1][0-9]|2[0-3]|[0-9])/, /^([0-1][0-9]|2[0-3])/, /^([0-5][0-9]|[0-9])/, /^[0-5][0-9]/, /^([0-5][0-9]|[0-9])/, /^[0-5][0-9]/, /^[0-5][0-9]\.[0-9]{1,3}/, /^((\+|\-)\s*\d\d\d\d)|((\+|\-)\d\d\:?\d\d)/, /^((\+|\-)\s*\d\d\d\d)|((\+|\-)\d\d\:?\d\d)/ ], tokens = [ t.hour, t.hour, t.hour, t.hour, t.minute, t.minute, t.second, t.second, t.secondAndMillisecond, t.timezone, t.timezone ]; for (i=0; i < RTokenKeys.length; i++) { cacheProcessRtoken(RTokenKeys[i], RToken[i], tokens[i]); } g.hms = _.cache(_.sequence([g.H, g.m, g.s], g.timePartDelimiter)); g.t = cacheProcessCtoken("shortMeridian", t.meridian); g.tt = cacheProcessCtoken("longMeridian", t.meridian); g.zzz = cacheProcessCtoken("timezone", t.timezone); g.timeSuffix = _.each(_.ignore(g.whiteSpace), _.set([ g.tt, g.zzz ])); g.time = _.each(_.optional(_.ignore(_.stoken("T"))), g.hms, g.timeSuffix); }, dateFormats: function () { // pre-loaded rules for different date part order preferences var _setfn = function () { return _.set(arguments, g.datePartDelimiter); }; var i, RTokenKeys = [ "d", "dd", "M", "MM", "y", "yy", "yyy", "yyyy" ], RToken = [ /^([0-2]\d|3[0-1]|\d)/, /^([0-2]\d|3[0-1])/, /^(1[0-2]|0\d|\d)/, /^(1[0-2]|0\d)/, /^(\d+)/, /^(\d\d)/, /^(\d\d?\d?\d?)/, /^(\d\d\d\d)/ ], tokens = [ t.day, t.day, t.month, t.month, t.year, t.year, t.year, t.year ], eachToken = [ "ordinalSuffix", "ordinalSuffix" ]; for (i=0; i < RTokenKeys.length; i++) { cacheProcessRtoken(RTokenKeys[i], RToken[i], tokens[i], eachToken[i]); } g.MMM = g.MMMM = _.cache(_.process(g.ctoken("jan feb mar apr may jun jul aug sep oct nov dec"), t.month)); g.ddd = g.dddd = _.cache(_.process(g.ctoken("sun mon tue wed thu fri sat"), function (s) { return function () { this.weekday = s; }; } )); g.day = _fn(g.d, g.dd); g.month = _fn(g.M, g.MMM); g.year = _fn(g.yyyy, g.yy); g.mdy = _setfn(g.ddd, g.month, g.day, g.year); g.ymd = _setfn(g.ddd, g.year, g.month, g.day); g.dmy = _setfn(g.ddd, g.day, g.month, g.year); g.date = function (s) { return ((g[Date.CultureInfo.dateElementOrder] || g.mdy).call(this, s)); }; }, relative: function () { // relative date / time expressions g.orientation = _.process(g.ctoken("past future"), function (s) { return function () { this.orient = s; }; } ); g.operator = _.process(g.ctoken("add subtract"), function (s) { return function () { this.operator = s; }; } ); g.rday = _.process(g.ctoken("yesterday tomorrow today now"), t.rday); g.unit = _.process(g.ctoken("second minute hour day week month year"), function (s) { return function () { this.unit = s; }; } ); } }; g.buildGrammarFormats = function () { // these need to be rebuilt every time the language changes. _C = {}; grammarFormats.timeFormats(); grammarFormats.dateFormats(); grammarFormats.relative(); g.value = _.process(_.rtoken(/^([-+]?\d+)?(st|nd|rd|th)?/), function (s) { return function () { this.value = s.replace(/\D/g, ""); }; } ); g.expression = _.set([g.rday, g.operator, g.value, g.unit, g.orientation, g.ddd, g.MMM ]); g.format = _.process(_.many( _.any( // translate format specifiers into grammar rules _.process( _.rtoken(/^(dd?d?d?(?!e)|MM?M?M?|yy?y?y?|hh?|HH?|mm?|ss?|tt?|zz?z?)/), function (fmt) { if (g[fmt]) { return g[fmt]; } else { throw $D.Parsing.Exception(fmt); } } ), // translate separator tokens into token rules _.process(_.rtoken(/^[^dMyhHmstz]+/), // all legal separators function (s) { return _.ignore(_.stoken(s)); } ) ) ), // construct the parser ... function (rules) { return _.process(_.each.apply(null, rules), t.finishExact); } ); // starting rule for general purpose grammar g._start = _.process(_.set([ g.date, g.time, g.expression ], g.generalDelimiter, g.whiteSpace), t.finish); }; g.buildGrammarFormats(); // parsing date format specifiers - ex: "h:m:s tt" // this little guy will generate a custom parser based // on the format string, ex: g.format("h:m:s tt") // check for these formats first g._formats = g.formats([ "\"yyyy-MM-ddTHH:mm:ssZ\"", "yyyy-MM-ddTHH:mm:ss.sz", "yyyy-MM-ddTHH:mm:ssZ", "yyyy-MM-ddTHH:mm:ssz", "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-ddTHH:mmZ", "yyyy-MM-ddTHH:mmz", "yyyy-MM-ddTHH:mm", "ddd, MMM dd, yyyy H:mm:ss tt", "ddd MMM d yyyy HH:mm:ss zzz", "MMddyyyy", "ddMMyyyy", "Mddyyyy", "ddMyyyy", "Mdyyyy", "dMyyyy", "yyyy", "Mdyy", "dMyy", "d" ]); // real starting rule: tries selected formats first, // then general purpose rule g.start = function (s) { try { var r = g._formats.call({}, s); if (r[1].length === 0) { return r; } } catch (e) {} return g._start.call({}, s); }; }()); (function () { var $D = Date; /** * @desc Converts the specified string value into its JavaScript Date equivalent using CultureInfo specific format information. * * Example

	///////////
	// Dates //
	///////////

	// 15-Oct-2004
	var d1 = Date.parse("10/15/2004");

	// 15-Oct-2004
	var d1 = Date.parse("15-Oct-2004");

	// 15-Oct-2004
	var d1 = Date.parse("2004.10.15");

	//Fri Oct 15, 2004
	var d1 = Date.parse("Fri Oct 15, 2004");

	///////////
	// Times //
	///////////

	// Today at 10 PM.
	var d1 = Date.parse("10 PM");

	// Today at 10:30 PM.
	var d1 = Date.parse("10:30 P.M.");

	// Today at 6 AM.
	var d1 = Date.parse("06am");

	/////////////////////
	// Dates and Times //
	/////////////////////

	// 8-July-2004 @ 10:30 PM
	var d1 = Date.parse("July 8th, 2004, 10:30 PM");

	// 1-July-2004 @ 10:30 PM
	var d1 = Date.parse("2004-07-01T22:30:00");

	////////////////////
	// Relative Dates //
	////////////////////

	// Returns today's date. The string "today" is culture specific.
	var d1 = Date.parse("today");

	// Returns yesterday's date. The string "yesterday" is culture specific.
	var d1 = Date.parse("yesterday");

	// Returns the date of the next thursday.
	var d1 = Date.parse("Next thursday");

	// Returns the date of the most previous monday.
	var d1 = Date.parse("last monday");

	// Returns today's day + one year.
	var d1 = Date.parse("next year");

	///////////////
	// Date Math //
	///////////////

	// Today + 2 days
	var d1 = Date.parse("t+2");

	// Today + 2 days
	var d1 = Date.parse("today + 2 days");

	// Today + 3 months
	var d1 = Date.parse("t+3m");

	// Today - 1 year
	var d1 = Date.parse("today - 1 year");

	// Today - 1 year
	var d1 = Date.parse("t-1y"); 


	/////////////////////////////
	// Partial Dates and Times //
	/////////////////////////////

	// July 15th of this year.
	var d1 = Date.parse("July 15");

	// 15th day of current day and year.
	var d1 = Date.parse("15");

	// July 1st of current year at 10pm.
	var d1 = Date.parse("7/1 10pm");
	
* * @param {String} The string value to convert into a Date object [Required] * @return {Date} A Date object or null if the string cannot be converted into a Date. */ var parseUtils = { removeOrds: function (s) { ords = s.match(/\b(\d+)(?:st|nd|rd|th)\b/); // find ordinal matches s = ((ords && ords.length === 2) ? s.replace(ords[0], ords[1]) : s); return s; }, grammarParser: function (s) { var r = null; try { r = $D.Grammar.start.call({}, s.replace(/^\s*(\S*(\s+\S+)*)\s*$/, "$1")); } catch (e) { return null; } return ((r[1].length === 0) ? r[0] : null); }, nativeFallback: function(s) { var t; try { // ok we haven't parsed it, last ditch attempt with the built-in parser. t = Date._parse(s); return (t || t === 0) ? new Date(t) : null; } catch (e) { return null; } } }; function parse (s) { var d; if (!s) { return null; } if (s instanceof Date) { return s.clone(); } if (s.length >= 4 && s.charAt(0) !== "0" && s.charAt(0) !== "+"&& s.charAt(0) !== "-") { // ie: 2004 will pass, 0800 won't. // Start with specific formats d = $D.Parsing.ISO.parse(s) || $D.Parsing.Numeric.parse(s); } if (d instanceof Date && !isNaN(d.getTime())) { return d; } else { // find ordinal dates (1st, 3rd, 8th, etc and remove them as they cause parsing issues) s = $D.Parsing.Normalizer.parse(parseUtils.removeOrds(s)); d = parseUtils.grammarParser(s); if (d !== null) { return d; } else { return parseUtils.nativeFallback(s); } } } if (!$D._parse) { $D._parse = $D.parse; } $D.parse = parse; Date.getParseFunction = function (fx) { var fns = Date.Grammar.allformats(fx); return function (s) { var r = null; for (var i = 0; i < fns.length; i++) { try { r = fns[i].call({}, s); } catch (e) { continue; } if (r[1].length === 0) { return r[0]; } } return null; }; }; /** * Converts the specified string value into its JavaScript Date equivalent using the specified format {String} or formats {Array} and the CultureInfo specific format information. * The format of the string value must match one of the supplied formats exactly. * * Example

	// 15-Oct-2004
	var d1 = Date.parseExact("10/15/2004", "M/d/yyyy");

	// 15-Oct-2004
	var d1 = Date.parse("15-Oct-2004", "M-ddd-yyyy");

	// 15-Oct-2004
	var d1 = Date.parse("2004.10.15", "yyyy.MM.dd");

	// Multiple formats
	var d1 = Date.parseExact("10/15/2004", ["M/d/yyyy", "MMMM d, yyyy"]);
	
* * @param {String} The string value to convert into a Date object [Required]. * @param {Object} The expected format {String} or an array of expected formats {Array} of the date string [Required]. * @return {Date} A Date object or null if the string cannot be converted into a Date. */ $D.parseExact = function (s, fx) { return $D.getParseFunction(fx)(s); }; }()); (function () { var $D = Date, $P = $D.prototype, // $C = $D.CultureInfo, // not used atm p = function (s, l) { if (!l) { l = 2; } return ("000" + s).slice(l * -1); }; /** * Converts a PHP format string to Java/.NET format string. * A PHP format string can be used with ._format or .format. * A Java/.NET format string can be used with .toString(). * The .parseExact function will only accept a Java/.NET format string * * Example * var f1 = "%m/%d/%y" * var f2 = Date.normalizeFormat(f1); // "MM/dd/yy" * * new Date().format(f1); // "04/13/08" * new Date()._format(f1); // "04/13/08" * new Date().toString(f2); // "04/13/08" * * var date = Date.parseExact("04/13/08", f2); // Sun Apr 13 2008 * * @param {String} A PHP format string consisting of one or more format spcifiers. * @return {String} The PHP format converted to a Java/.NET format string. */ var normalizerSubstitutions = { "d" : "dd", "%d": "dd", "D" : "ddd", "%a": "ddd", "j" : "dddd", "l" : "dddd", "%A": "dddd", "S" : "S", "F" : "MMMM", "%B": "MMMM", "m" : "MM", "%m": "MM", "M" : "MMM", "%b": "MMM", "%h": "MMM", "n" : "M", "Y" : "yyyy", "%Y": "yyyy", "y" : "yy", "%y": "yy", "g" : "h", "%I": "h", "G" : "H", "h" : "hh", "H" : "HH", "%H": "HH", "i" : "mm", "%M": "mm", "s" : "ss", "%S": "ss", "%r": "hh:mm tt", "%R": "H:mm", "%T": "H:mm:ss", "%X": "t", "%x": "d", "%e": "d", "%D": "MM/dd/yy", "%n": "\\n", "%t": "\\t", "e" : "z", "T" : "z", "%z": "z", "%Z": "z", "Z" : "ZZ", "N" : "u", "w" : "u", "%w": "u", "W" : "W", "%V": "W" }; var normalizer = { substitutes: function (m) { return normalizerSubstitutions[m]; }, interpreted: function (m, x) { var y; switch (m) { case "%u": return x.getDay() + 1; case "z": return x.getOrdinalNumber(); case "%j": return p(x.getOrdinalNumber(), 3); case "%U": var d1 = x.clone().set({month: 0, day: 1}).addDays(-1).moveToDayOfWeek(0), d2 = x.clone().addDays(1).moveToDayOfWeek(0, -1); return (d2 < d1) ? "00" : p((d2.getOrdinalNumber() - d1.getOrdinalNumber()) / 7 + 1); case "%W": return p(x.getWeek()); case "t": return $D.getDaysInMonth(x.getFullYear(), x.getMonth()); case "o": case "%G": return x.setWeek(x.getISOWeek()).toString("yyyy"); case "%g": return x._format("%G").slice(-2); case "a": case "%p": return t("tt").toLowerCase(); case "A": return t("tt").toUpperCase(); case "u": return p(x.getMilliseconds(), 3); case "I": return (x.isDaylightSavingTime()) ? 1 : 0; case "O": return x.getUTCOffset(); case "P": y = x.getUTCOffset(); return y.substring(0, y.length - 2) + ":" + y.substring(y.length - 2); case "B": var now = new Date(); return Math.floor(((now.getHours() * 3600) + (now.getMinutes() * 60) + now.getSeconds() + (now.getTimezoneOffset() + 60) * 60) / 86.4); case "c": return x.toISOString().replace(/\"/g, ""); case "U": return $D.strtotime("now"); case "%c": return t("d") + " " + t("t"); case "%C": return Math.floor(x.getFullYear() / 100 + 1); } }, shouldOverrideDefaults: function (m) { switch (m) { case "%e": return true; default: return false; } }, parse: function (m, context) { var formatString, c = context || new Date(); formatString = normalizer.substitutes(m); if (formatString) { return formatString; } formatString = normalizer.interpreted(m, c); if (formatString) { return formatString; } else { return m; } } }; $D.normalizeFormat = function (format, context) { return format.replace(/(%|\\)?.|%%/g, function(t){ return normalizer.parse(t, context); }); }; /** * Format a local Unix timestamp according to locale settings * * Example: * Date.strftime("%m/%d/%y", new Date()); // "04/13/08" * Date.strftime("c", "2008-04-13T17:52:03Z"); // "04/13/08" * * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @param {Number|String} The number representing the number of seconds that have elapsed since January 1, 1970 (local time). * @return {String} A string representation of the current Date object. */ $D.strftime = function (format, time) { var d = Date.parse(time); return d._format(format); }; /** * Parse any textual datetime description into a Unix timestamp. * A Unix timestamp is the number of seconds that have elapsed since January 1, 1970 (midnight UTC/GMT). * * Example: * Date.strtotime("04/13/08"); // 1208044800 * Date.strtotime("1970-01-01T00:00:00Z"); // 0 * * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @param {Object} A string or date object. * @return {String} A string representation of the current Date object. */ $D.strtotime = function (time) { var d = $D.parse(time); return Math.round($D.UTC(d.getUTCFullYear(), d.getUTCMonth(), d.getUTCDate(), d.getUTCHours(), d.getUTCMinutes(), d.getUTCSeconds(), d.getUTCMilliseconds()) / 1000); }; /** * Converts the value of the current Date object to its equivalent string representation using a PHP/Unix style of date format specifiers. * Format Specifiers * Format Description Example * ------ --------------------------------------------------------------------------- ----------------------- * %a abbreviated weekday name according to the current localed "Mon" through "Sun" * %A full weekday name according to the current localed "Sunday" through "Saturday" * %b abbreviated month name according to the current localed "Jan" through "Dec" * %B full month name according to the current locale "January" through "December" * %c preferred date and time representation for the current locale "4/13/2008 12:33 PM" * %C century number (the year divided by 100 and truncated to an integer) "00" to "99" * %d day of the month as a decimal number "01" to "31" * %D same as %m/%d/%y "04/13/08" * %e day of the month as a decimal number, a single digit is preceded by a space "1" to "31" * %g like %G, but without the century "08" * %G The 4-digit year corresponding to the ISO week number (see %V). "2008" * This has the same format and value as %Y, except that if the ISO week number * belongs to the previous or next year, that year is used instead. * %h same as %b "Jan" through "Dec" * %H hour as a decimal number using a 24-hour clock. "00" to "23" * %I hour as a decimal number using a 12-hour clock. "01" to "12" * %j day of the year as a decimal number. "001" to "366" * %m month as a decimal number. "01" to "12" * %M minute as a decimal number. "00" to "59" * %n newline character "\n" * %p either "am" or "pm" according to the given time value, or the "am" or "pm" * corresponding strings for the current locale. * %r time in a.m. and p.m. notation "8:44 PM" * %R time in 24 hour notation "20:44" * %S second as a decimal number "00" to "59" * %t tab character "\t" * %T current time, equal to %H:%M:%S "12:49:11" * %u weekday as a decimal number ["1", "7"], with "1" representing Monday "1" to "7" * %U week number of the current year as a decimal number, starting with the "0" to ("52" or "53") * first Sunday as the first day of the first week * %V The ISO 8601:1988 week number of the current year as a decimal number, "00" to ("52" or "53") * range 01 to 53, where week 1 is the first week that has at least 4 days * in the current year, and with Monday as the first day of the week. * (Use %G or %g for the year component that corresponds to the week number * for the specified timestamp.) * %W week number of the current year as a decimal number, starting with the "00" to ("52" or "53") * first Monday as the first day of the first week * %w day of the week as a decimal, Sunday being "0" "0" to "6" * %x preferred date representation for the current locale without the time "4/13/2008" * %X preferred time representation for the current locale without the date "12:53:05" * %y year as a decimal number without a century "00" "99" * %Y year as a decimal number including the century "2008" * %Z time zone or name or abbreviation "UTC", "EST", "PST" * %z same as %Z * %% a literal "%" characters "%" * d Day of the month, 2 digits with leading zeros "01" to "31" * D A textual representation of a day, three letters "Mon" through "Sun" * j Day of the month without leading zeros "1" to "31" * l A full textual representation of the day of the week (lowercase "L") "Sunday" through "Saturday" * N ISO-8601 numeric representation of the day of the week (added in PHP 5.1.0) "1" (for Monday) through "7" (for Sunday) * S English ordinal suffix for the day of the month, 2 characters "st", "nd", "rd" or "th". Works well with j * w Numeric representation of the day of the week "0" (for Sunday) through "6" (for Saturday) * z The day of the year (starting from "0") "0" through "365" * W ISO-8601 week number of year, weeks starting on Monday "00" to ("52" or "53") * F A full textual representation of a month, such as January or March "January" through "December" * m Numeric representation of a month, with leading zeros "01" through "12" * M A short textual representation of a month, three letters "Jan" through "Dec" * n Numeric representation of a month, without leading zeros "1" through "12" * t Number of days in the given month "28" through "31" * L Whether it's a leap year "1" if it is a leap year, "0" otherwise * o ISO-8601 year number. This has the same value as Y, except that if the "2008" * ISO week number (W) belongs to the previous or next year, that year * is used instead. * Y A full numeric representation of a year, 4 digits "2008" * y A two digit representation of a year "08" * a Lowercase Ante meridiem and Post meridiem "am" or "pm" * A Uppercase Ante meridiem and Post meridiem "AM" or "PM" * B Swatch Internet time "000" through "999" * g 12-hour format of an hour without leading zeros "1" through "12" * G 24-hour format of an hour without leading zeros "0" through "23" * h 12-hour format of an hour with leading zeros "01" through "12" * H 24-hour format of an hour with leading zeros "00" through "23" * i Minutes with leading zeros "00" to "59" * s Seconds, with leading zeros "00" through "59" * u Milliseconds "54321" * e Timezone identifier "UTC", "EST", "PST" * I Whether or not the date is in daylight saving time (uppercase i) "1" if Daylight Saving Time, "0" otherwise * O Difference to Greenwich time (GMT) in hours "+0200", "-0600" * P Difference to Greenwich time (GMT) with colon between hours and minutes "+02:00", "-06:00" * T Timezone abbreviation "UTC", "EST", "PST" * Z Timezone offset in seconds. The offset for timezones west of UTC is "-43200" through "50400" * always negative, and for those east of UTC is always positive. * c ISO 8601 date "2004-02-12T15:19:21+00:00" * r RFC 2822 formatted date "Thu, 21 Dec 2000 16:01:07 +0200" * U Seconds since the Unix Epoch (January 1 1970 00:00:00 GMT) "0" * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @return {String} A string representation of the current Date object. */ var formatReplace = function (context) { return function (m) { var formatString, override = false; if (m.charAt(0) === "\\" || m.substring(0, 2) === "%%") { return m.replace("\\", "").replace("%%", "%"); } override = normalizer.shouldOverrideDefaults(m); formatString = $D.normalizeFormat(m, context); if (formatString) { return context.toString(formatString, override); } }; }; $P._format = function (format) { var formatter = formatReplace(this); if (!format) { return this._toString(); } else { return format.replace(/(%|\\)?.|%%/g, formatter); } }; if (!$P.format) { $P.format = $P._format; } }()); (function () { "use strict"; var gFn = function (attr) { return function () { return this[attr]; }; }; var sFn = function (attr) { return function (val) { this[attr] = val; return this; }; }; var attrs = ["years", "months", "days", "hours", "minutes", "seconds", "milliseconds"]; var addSetFuncs = function (context, attrs) { for (var i = 0; i < attrs.length ; i++) { var $a = attrs[i], $b = $a.slice(0, 1).toUpperCase() + $a.slice(1); context.prototype[$a] = 0; context.prototype["get" + $b] = gFn($a); context.prototype["set" + $b] = sFn($a); } }; /** * new TimeSpan(milliseconds); * new TimeSpan(days, hours, minutes, seconds); * new TimeSpan(days, hours, minutes, seconds, milliseconds); */ var TimeSpan = function (days, hours, minutes, seconds, milliseconds) { if (arguments.length === 1 && typeof days === "number") { var orient = (days < 0) ? -1 : +1; var millsLeft = Math.abs(days); this.setDays(Math.floor(millsLeft / 86400000) * orient); millsLeft = millsLeft % 86400000; this.setHours(Math.floor(millsLeft / 3600000) * orient); millsLeft = millsLeft % 3600000; this.setMinutes(Math.floor(millsLeft / 60000) * orient); millsLeft = millsLeft % 60000; this.setSeconds(Math.floor(millsLeft / 1000) * orient); millsLeft = millsLeft % 1000; this.setMilliseconds(millsLeft * orient); } else { this.set(days, hours, minutes, seconds, milliseconds); } this.getTotalMilliseconds = function () { return (this.getDays() * 86400000) + (this.getHours() * 3600000) + (this.getMinutes() * 60000) + (this.getSeconds() * 1000); }; this.compareTo = function (time) { var t1 = new Date(1970, 1, 1, this.getHours(), this.getMinutes(), this.getSeconds()), t2; if (time === null) { t2 = new Date(1970, 1, 1, 0, 0, 0); } else { t2 = new Date(1970, 1, 1, time.getHours(), time.getMinutes(), time.getSeconds()); } return (t1 < t2) ? -1 : (t1 > t2) ? 1 : 0; }; this.equals = function (time) { return (this.compareTo(time) === 0); }; this.add = function (time) { return (time === null) ? this : this.addSeconds(time.getTotalMilliseconds() / 1000); }; this.subtract = function (time) { return (time === null) ? this : this.addSeconds(-time.getTotalMilliseconds() / 1000); }; this.addDays = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 86400000)); }; this.addHours = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 3600000)); }; this.addMinutes = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 60000)); }; this.addSeconds = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 1000)); }; this.addMilliseconds = function (n) { return new TimeSpan(this.getTotalMilliseconds() + n); }; this.get12HourHour = function () { return (this.getHours() > 12) ? this.getHours() - 12 : (this.getHours() === 0) ? 12 : this.getHours(); }; this.getDesignator = function () { return (this.getHours() < 12) ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator; }; this.toString = function (format) { this._toString = function () { if (this.getDays() !== null && this.getDays() > 0) { return this.getDays() + "." + this.getHours() + ":" + this.p(this.getMinutes()) + ":" + this.p(this.getSeconds()); } else { return this.getHours() + ":" + this.p(this.getMinutes()) + ":" + this.p(this.getSeconds()); } }; this.p = function (s) { return (s.toString().length < 2) ? "0" + s : s; }; var me = this; return format ? format.replace(/dd?|HH?|hh?|mm?|ss?|tt?/g, function (format) { switch (format) { case "d": return me.getDays(); case "dd": return me.p(me.getDays()); case "H": return me.getHours(); case "HH": return me.p(me.getHours()); case "h": return me.get12HourHour(); case "hh": return me.p(me.get12HourHour()); case "m": return me.getMinutes(); case "mm": return me.p(me.getMinutes()); case "s": return me.getSeconds(); case "ss": return me.p(me.getSeconds()); case "t": return ((me.getHours() < 12) ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator).substring(0, 1); case "tt": return (me.getHours() < 12) ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator; } } ) : this._toString(); }; return this; }; addSetFuncs(TimeSpan, attrs.slice(2)); TimeSpan.prototype.set = function (days, hours, minutes, seconds, milliseconds){ this.setDays(days || this.getDays()); this.setHours(hours || this.getHours()); this.setMinutes(minutes || this.getMinutes()); this.setSeconds(seconds || this.getSeconds()); this.setMilliseconds(milliseconds || this.getMilliseconds()); }; /** * Gets the time of day for this date instances. * @return {TimeSpan} TimeSpan */ Date.prototype.getTimeOfDay = function () { return new TimeSpan(0, this.getHours(), this.getMinutes(), this.getSeconds(), this.getMilliseconds()); }; Date.TimeSpan = TimeSpan; if (typeof window !== "undefined" ) { // keeping API compatible for v1.x window.TimeSpan = TimeSpan; } }()); (function () { "use strict"; var attrs = ["years", "months", "days", "hours", "minutes", "seconds", "milliseconds"]; var gFn = function (attr) { return function () { return this[attr]; }; }; var sFn = function (attr) { return function (val) { this[attr] = val; return this; }; }; var addSetFuncs = function (context, attrs) { for (var i = 0; i < attrs.length ; i++) { var $a = attrs[i], $b = $a.slice(0, 1).toUpperCase() + $a.slice(1); context.prototype[$a] = 0; context.prototype["get" + $b] = gFn($a); context.prototype["set" + $b] = sFn($a); } }; var setMonthsAndYears = function (orient, d1, d2, context) { function inc() { d1.addMonths(-orient); context.months++; if (context.months === 12) { context.years++; context.months = 0; } } if (orient === +1) { while (d1 > d2) { inc(); } } else { while (d1 < d2) { inc(); } } context.months--; context.months *= orient; context.years *= orient; }; var adjustForDST = function(orient, startDate, endDate) { var hasDSTMismatch = (false === (startDate.isDaylightSavingTime() === endDate.isDaylightSavingTime())); if (hasDSTMismatch && orient === 1) { startDate.addHours(-1); } else if (hasDSTMismatch) { startDate.addHours(1); } }; /** * TimePeriod(startDate, endDate); * TimePeriod(years, months, days, hours, minutes, seconds, milliseconds); */ var TimePeriod = function (years, months, days, hours, minutes, seconds, milliseconds) { if (arguments.length === 7) { this.set(years, months, days, hours, minutes, seconds, milliseconds); } else if (arguments.length === 2 && arguments[0] instanceof Date && arguments[1] instanceof Date) { var startDate = arguments[0].clone(); var endDate = arguments[1].clone(); var orient = (startDate > endDate) ? +1 : -1; this.dates = { start: arguments[0].clone(), end: arguments[1].clone() }; setMonthsAndYears(orient, startDate, endDate, this); adjustForDST(orient, startDate, endDate); // // TODO - adjust for DST var diff = endDate - startDate; if (diff !== 0) { var ts = new TimeSpan(diff); this.set(this.years, this.months, ts.getDays(), ts.getHours(), ts.getMinutes(), ts.getSeconds(), ts.getMilliseconds()); } } return this; }; // create all the set functions. addSetFuncs(TimePeriod, attrs); TimePeriod.prototype.set = function (years, months, days, hours, minutes, seconds, milliseconds){ this.setYears(years || this.getYears()); this.setMonths(months || this.getMonths()); this.setDays(days || this.getDays()); this.setHours(hours || this.getHours()); this.setMinutes(minutes || this.getMinutes()); this.setSeconds(seconds || this.getSeconds()); this.setMilliseconds(milliseconds || this.getMilliseconds()); }; Date.TimePeriod = TimePeriod; if (typeof window !== "undefined") { // keeping API compatible for v1.x window.TimePeriod = TimePeriod; } }()); ================================================ FILE: build/date-sa-IN.js ================================================ /** * @overview datejs * @version 1.0.0-rc3 * @author Gregory Wild-Smith * @copyright 2015 Gregory Wild-Smith * @license MIT * @homepage https://github.com/abritinthebay/datejs */ /* * DateJS Culture String File * Country Code: sa-IN * Name: Sanskrit (India) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["sa-IN"] = { "name": "sa-IN", "englishName": "Sanskrit (India)", "nativeName": "संस्कृत (भारतम्)", "Sunday": "रविवासरः", "Monday": "सोमवासरः", "Tuesday": "मङ्गलवासरः", "Wednesday": "बुधवासरः", "Thursday": "गुरुवासरः", "Friday": "शुक्रवासरः", "Saturday": "शनिवासरः", "Sun": "रविवासरः", "Mon": "सोमवासरः", "Tue": "मङ्गलवासरः", "Wed": "बुधवासरः", "Thu": "गुरुवासरः", "Fri": "शुक्रवासरः", "Sat": "शनिवासरः", "Su": "र", "Mo": "स", "Tu": "म", "We": "ब", "Th": "ग", "Fr": "श", "Sa": "श", "S_Sun_Initial": "र", "M_Mon_Initial": "स", "T_Tue_Initial": "म", "W_Wed_Initial": "ब", "T_Thu_Initial": "ग", "F_Fri_Initial": "श", "S_Sat_Initial": "श", "January": "जनवरी", "February": "फरवरी", "March": "मार्च", "April": "अप्रैल", "May": "मई", "June": "जून", "July": "जुलाई", "August": "अगस्त", "September": "सितम्बर", "October": "अक्तूबर", "November": "नवम्बर", "December": "दिसम्बर", "Jan_Abbr": "जनवरी", "Feb_Abbr": "फरवरी", "Mar_Abbr": "मार्च", "Apr_Abbr": "अप्रैल", "May_Abbr": "मई", "Jun_Abbr": "जून", "Jul_Abbr": "जुलाई", "Aug_Abbr": "अगस्त", "Sep_Abbr": "सितम्बर", "Oct_Abbr": "अक्तूबर", "Nov_Abbr": "नवम्बर", "Dec_Abbr": "दिसम्बर", "AM": "पूर्वाह्न", "PM": "अपराह्न", "firstDayOfWeek": 0, "twoDigitYearMax": 2029, "mdy": "dmy", "M/d/yyyy": "dd-MM-yyyy", "dddd, MMMM dd, yyyy": "dd MMMM yyyy dddd", "h:mm tt": "HH:mm", "h:mm:ss tt": "HH:mm:ss", "dddd, MMMM dd, yyyy h:mm:ss tt": "dd MMMM yyyy dddd HH:mm:ss", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "dd MMMM", "MMMM, yyyy": "MMMM, yyyy", "/jan(uary)?/": "जनवरी", "/feb(ruary)?/": "फरवरी", "/mar(ch)?/": "मार्च", "/apr(il)?/": "अप्रैल", "/may/": "मई", "/jun(e)?/": "जून", "/jul(y)?/": "जुलाई", "/aug(ust)?/": "अगस्त", "/sep(t(ember)?)?/": "सितम्बर", "/oct(ober)?/": "अक्तूबर", "/nov(ember)?/": "नवम्बर", "/dec(ember)?/": "दिसम्बर", "/^su(n(day)?)?/": "^र(1)?", "/^mo(n(day)?)?/": "^स(1)?", "/^tu(e(s(day)?)?)?/": "^म(1)?", "/^we(d(nesday)?)?/": "^ब(1)?", "/^th(u(r(s(day)?)?)?)?/": "^ग(1)?", "/^fr(i(day)?)?/": "^श(1)?", "/^sa(t(urday)?)?/": "^श(1)?", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "sa-IN"; /** * @overview datejs * @version 1.0.0-rc3 * @author Gregory Wild-Smith * @copyright 2015 Gregory Wild-Smith * @license MIT * @homepage https://github.com/abritinthebay/datejs */(function () { var $D = Date; var lang = Date.CultureStrings ? Date.CultureStrings.lang : null; var loggedKeys = {}; // for debug purposes. var getText = { getFromKey: function (key, countryCode) { var output; if (Date.CultureStrings && Date.CultureStrings[countryCode] && Date.CultureStrings[countryCode][key]) { output = Date.CultureStrings[countryCode][key]; } else { output = getText.buildFromDefault(key); } if (key.charAt(0) === "/") { // Assume it's a regex output = getText.buildFromRegex(key, countryCode); } return output; }, getFromObjectValues: function (obj, countryCode) { var key, output = {}; for(key in obj) { if (obj.hasOwnProperty(key)) { output[key] = getText.getFromKey(obj[key], countryCode); } } return output; }, getFromObjectKeys: function (obj, countryCode) { var key, output = {}; for(key in obj) { if (obj.hasOwnProperty(key)) { output[getText.getFromKey(key, countryCode)] = obj[key]; } } return output; }, getFromArray: function (arr, countryCode) { var output = []; for (var i=0; i < arr.length; i++){ if (i in arr) { output[i] = getText.getFromKey(arr[i], countryCode); } } return output; }, buildFromDefault: function (key) { var output, length, split, last; switch(key) { case "name": output = "en-US"; break; case "englishName": output = "English (United States)"; break; case "nativeName": output = "English (United States)"; break; case "twoDigitYearMax": output = 2049; break; case "firstDayOfWeek": output = 0; break; default: output = key; split = key.split("_"); length = split.length; if (length > 1 && key.charAt(0) !== "/") { // if the key isn't a regex and it has a split. last = split[(length - 1)].toLowerCase(); if (last === "initial" || last === "abbr") { output = split[0]; } } break; } return output; }, buildFromRegex: function (key, countryCode) { var output; if (Date.CultureStrings && Date.CultureStrings[countryCode] && Date.CultureStrings[countryCode][key]) { output = new RegExp(Date.CultureStrings[countryCode][key], "i"); } else { output = new RegExp(key.replace(new RegExp("/", "g"),""), "i"); } return output; } }; var shallowMerge = function (obj1, obj2) { for (var attrname in obj2) { if (obj2.hasOwnProperty(attrname)) { obj1[attrname] = obj2[attrname]; } } }; var __ = function (key, language) { var countryCode = (language) ? language : lang; loggedKeys[key] = key; if (typeof key === "object") { if (key instanceof Array) { return getText.getFromArray(key, countryCode); } else { return getText.getFromObjectKeys(key, countryCode); } } else { return getText.getFromKey(key, countryCode); } }; var loadI18nScript = function (code) { // paatterned after jQuery's getScript. var url = Date.Config.i18n + code + ".js"; var head = document.getElementsByTagName("head")[0] || document.documentElement; var script = document.createElement("script"); script.src = url; var completed = false; var events = { done: function (){} // placeholder function }; // Attach handlers for all browsers script.onload = script.onreadystatechange = function() { if ( !completed && (!this.readyState || this.readyState === "loaded" || this.readyState === "complete") ) { events.done(); head.removeChild(script); } }; setTimeout(function() { head.insertBefore(script, head.firstChild); }, 0); // allows return to execute first return { done: function (cb) { events.done = function() { if (cb) { setTimeout(cb,0); } }; } }; }; var buildInfo = { buildFromMethodHash: function (obj) { var key; for(key in obj) { if (obj.hasOwnProperty(key)) { obj[key] = buildInfo[obj[key]](); } } return obj; }, timeZoneDST: function () { var DST = { "CHADT": "+1345", "NZDT": "+1300", "AEDT": "+1100", "ACDT": "+1030", "AZST": "+0500", "IRDT": "+0430", "EEST": "+0300", "CEST": "+0200", "BST": "+0100", "PMDT": "-0200", "ADT": "-0300", "NDT": "-0230", "EDT": "-0400", "CDT": "-0500", "MDT": "-0600", "PDT": "-0700", "AKDT": "-0800", "HADT": "-0900" }; return __(DST); }, timeZoneStandard: function () { var standard = { "LINT": "+1400", "TOT": "+1300", "CHAST": "+1245", "NZST": "+1200", "NFT": "+1130", "SBT": "+1100", "AEST": "+1000", "ACST": "+0930", "JST": "+0900", "CWST": "+0845", "CT": "+0800", "ICT": "+0700", "MMT": "+0630", "BST": "+0600", "NPT": "+0545", "IST": "+0530", "PKT": "+0500", "AFT": "+0430", "MSK": "+0400", "IRST": "+0330", "FET": "+0300", "EET": "+0200", "CET": "+0100", "GMT": "+0000", "UTC": "+0000", "CVT": "-0100", "GST": "-0200", "BRT": "-0300", "NST": "-0330", "AST": "-0400", "EST": "-0500", "CST": "-0600", "MST": "-0700", "PST": "-0800", "AKST": "-0900", "MIT": "-0930", "HST": "-1000", "SST": "-1100", "BIT": "-1200" }; return __(standard); }, timeZones: function (data) { var zone; data.timezones = []; for (zone in data.abbreviatedTimeZoneStandard) { if (data.abbreviatedTimeZoneStandard.hasOwnProperty(zone)) { data.timezones.push({ name: zone, offset: data.abbreviatedTimeZoneStandard[zone]}); } } for (zone in data.abbreviatedTimeZoneDST) { if (data.abbreviatedTimeZoneDST.hasOwnProperty(zone)) { data.timezones.push({ name: zone, offset: data.abbreviatedTimeZoneDST[zone], dst: true}); } } return data.timezones; }, days: function () { return __(["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"]); }, dayAbbr: function () { return __(["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"]); }, dayShortNames: function () { return __(["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"]); }, dayFirstLetters: function () { return __(["S_Sun_Initial", "M_Mon_Initial", "T_Tues_Initial", "W_Wed_Initial", "T_Thu_Initial", "F_Fri_Initial", "S_Sat_Initial"]); }, months: function () { return __(["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"]); }, monthAbbr: function () { return __(["Jan_Abbr", "Feb_Abbr", "Mar_Abbr", "Apr_Abbr", "May_Abbr", "Jun_Abbr", "Jul_Abbr", "Aug_Abbr", "Sep_Abbr", "Oct_Abbr", "Nov_Abbr", "Dec_Abbr"]); }, formatPatterns: function () { return getText.getFromObjectValues({ shortDate: "M/d/yyyy", longDate: "dddd, MMMM dd, yyyy", shortTime: "h:mm tt", longTime: "h:mm:ss tt", fullDateTime: "dddd, MMMM dd, yyyy h:mm:ss tt", sortableDateTime: "yyyy-MM-ddTHH:mm:ss", universalSortableDateTime: "yyyy-MM-dd HH:mm:ssZ", rfc1123: "ddd, dd MMM yyyy HH:mm:ss", monthDay: "MMMM dd", yearMonth: "MMMM, yyyy" }, Date.i18n.currentLanguage()); }, regex: function () { return getText.getFromObjectValues({ inTheMorning: "/( in the )(morn(ing)?)\\b/", thisMorning: "/(this )(morn(ing)?)\\b/", amThisMorning: "/(\b\\d(am)? )(this )(morn(ing)?)/", inTheEvening: "/( in the )(even(ing)?)\\b/", thisEvening: "/(this )(even(ing)?)\\b/", pmThisEvening: "/(\b\\d(pm)? )(this )(even(ing)?)/", jan: "/jan(uary)?/", feb: "/feb(ruary)?/", mar: "/mar(ch)?/", apr: "/apr(il)?/", may: "/may/", jun: "/jun(e)?/", jul: "/jul(y)?/", aug: "/aug(ust)?/", sep: "/sep(t(ember)?)?/", oct: "/oct(ober)?/", nov: "/nov(ember)?/", dec: "/dec(ember)?/", sun: "/^su(n(day)?)?/", mon: "/^mo(n(day)?)?/", tue: "/^tu(e(s(day)?)?)?/", wed: "/^we(d(nesday)?)?/", thu: "/^th(u(r(s(day)?)?)?)?/", fri: "/fr(i(day)?)?/", sat: "/^sa(t(urday)?)?/", future: "/^next/", past: "/^last|past|prev(ious)?/", add: "/^(\\+|aft(er)?|from|hence)/", subtract: "/^(\\-|bef(ore)?|ago)/", yesterday: "/^yes(terday)?/", today: "/^t(od(ay)?)?/", tomorrow: "/^tom(orrow)?/", now: "/^n(ow)?/", millisecond: "/^ms|milli(second)?s?/", second: "/^sec(ond)?s?/", minute: "/^mn|min(ute)?s?/", hour: "/^h(our)?s?/", week: "/^w(eek)?s?/", month: "/^m(onth)?s?/", day: "/^d(ay)?s?/", year: "/^y(ear)?s?/", shortMeridian: "/^(a|p)/", longMeridian: "/^(a\\.?m?\\.?|p\\.?m?\\.?)/", timezone: "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/", ordinalSuffix: "/^\\s*(st|nd|rd|th)/", timeContext: "/^\\s*(\\:|a(?!u|p)|p)/" }, Date.i18n.currentLanguage()); } }; var CultureInfo = function () { var info = getText.getFromObjectValues({ name: "name", englishName: "englishName", nativeName: "nativeName", amDesignator: "AM", pmDesignator: "PM", firstDayOfWeek: "firstDayOfWeek", twoDigitYearMax: "twoDigitYearMax", dateElementOrder: "mdy" }, Date.i18n.currentLanguage()); var constructedInfo = buildInfo.buildFromMethodHash({ dayNames: "days", abbreviatedDayNames: "dayAbbr", shortestDayNames: "dayShortNames", firstLetterDayNames: "dayFirstLetters", monthNames: "months", abbreviatedMonthNames: "monthAbbr", formatPatterns: "formatPatterns", regexPatterns: "regex", abbreviatedTimeZoneDST: "timeZoneDST", abbreviatedTimeZoneStandard: "timeZoneStandard" }); shallowMerge(info, constructedInfo); buildInfo.timeZones(info); return info; }; $D.i18n = { __: function (key, lang) { return __(key, lang); }, currentLanguage: function () { return lang || "en-US"; }, setLanguage: function (code, force, cb) { var async = false; if (force || code === "en-US" || (!!Date.CultureStrings && !!Date.CultureStrings[code])) { lang = code; Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings.lang = code; Date.CultureInfo = new CultureInfo(); } else { if (!(!!Date.CultureStrings && !!Date.CultureStrings[code])) { if (typeof exports !== "undefined" && this.exports !== exports) { // we're in a Node enviroment, load it using require try { require("../i18n/" + code + ".js"); lang = code; Date.CultureStrings.lang = code; Date.CultureInfo = new CultureInfo(); } catch (e) { // var str = "The language for '" + code + "' could not be loaded by Node. It likely does not exist."; throw new Error("The DateJS IETF language tag '" + code + "' could not be loaded by Node. It likely does not exist."); } } else if (Date.Config && Date.Config.i18n) { // we know the location of the files, so lets load them async = true; loadI18nScript(code).done(function(){ lang = code; Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings.lang = code; Date.CultureInfo = new CultureInfo(); $D.Parsing.Normalizer.buildReplaceData(); // because this is async if ($D.Grammar) { $D.Grammar.buildGrammarFormats(); // so we can parse those strings... } if (cb) { setTimeout(cb,0); } }); } else { Date.console.error("The DateJS IETF language tag '" + code + "' is not available and has not been loaded."); return false; } } } $D.Parsing.Normalizer.buildReplaceData(); // rebuild normalizer strings if ($D.Grammar) { $D.Grammar.buildGrammarFormats(); // so we can parse those strings... } if (!async && cb) { setTimeout(cb,0); } }, getLoggedKeys: function () { return loggedKeys; }, updateCultureInfo: function () { Date.CultureInfo = new CultureInfo(); } }; $D.i18n.updateCultureInfo(); // run automatically }()); (function () { var $D = Date, $P = $D.prototype, p = function (s, l) { if (!l) { l = 2; } return ("000" + s).slice(l * -1); }; if (typeof window !== "undefined" && typeof window.console !== "undefined" && typeof window.console.log !== "undefined") { $D.console = console; // used only to raise non-critical errors if available } else { // set mock so we don't give errors. $D.console = { log: function(){}, error: function(){} }; } $D.Config = $D.Config || {}; $D.initOverloads = function() { /** * Overload of Date.now. Allows an alternate call for Date.now where it returns the * current Date as an object rather than just milliseconds since the Unix Epoch. * * Also provides an implementation of now() for browsers (IE<9) that don't have it. * * Backwards compatible so with work with either: * Date.now() [returns ms] * or * Date.now(true) [returns Date] */ if (!$D.now) { $D._now = function now() { return new Date().getTime(); }; } else if (!$D._now) { $D._now = $D.now; } $D.now = function (returnObj) { if (returnObj) { return $D.present(); } else { return $D._now(); } }; if ( !$P.toISOString ) { $P.toISOString = function() { return this.getUTCFullYear() + "-" + p(this.getUTCMonth() + 1) + "-" + p(this.getUTCDate()) + "T" + p(this.getUTCHours()) + ":" + p(this.getUTCMinutes()) + ":" + p(this.getUTCSeconds()) + "." + String( (this.getUTCMilliseconds()/1000).toFixed(3)).slice(2, 5) + "Z"; }; } // private if ( $P._toString === undefined ){ $P._toString = $P.toString; } }; $D.initOverloads(); /** * Gets a date that is set to the current date. The time is set to the start of the day (00:00 or 12:00 AM). * @return {Date} The current date. */ $D.today = function () { return new Date().clearTime(); }; /** * Gets a date that is set to the current date and time (same as new Date, but chainable) * @return {Date} The current date. */ $D.present = function () { return new Date(); }; /** * Compares the first date to the second date and returns an number indication of their relative values. * @param {Date} First Date object to compare [Required]. * @param {Date} Second Date object to compare to [Required]. * @return {Number} -1 = date1 is lessthan date2. 0 = values are equal. 1 = date1 is greaterthan date2. */ $D.compare = function (date1, date2) { if (isNaN(date1) || isNaN(date2)) { throw new Error(date1 + " - " + date2); } else if (date1 instanceof Date && date2 instanceof Date) { return (date1 < date2) ? -1 : (date1 > date2) ? 1 : 0; } else { throw new TypeError(date1 + " - " + date2); } }; /** * Compares the first Date object to the second Date object and returns true if they are equal. * @param {Date} First Date object to compare [Required] * @param {Date} Second Date object to compare to [Required] * @return {Boolean} true if dates are equal. false if they are not equal. */ $D.equals = function (date1, date2) { return (date1.compareTo(date2) === 0); }; /** * Gets the language appropriate day name when given the day number(0-6) * eg - 0 == Sunday * @return {String} The day name */ $D.getDayName = function (n) { return Date.CultureInfo.dayNames[n]; }; /** * Gets the day number (0-6) if given a CultureInfo specific string which is a valid dayName, abbreviatedDayName or shortestDayName (two char). * @param {String} The name of the day (eg. "Monday, "Mon", "tuesday", "tue", "We", "we"). * @return {Number} The day number */ $D.getDayNumberFromName = function (name) { var n = Date.CultureInfo.dayNames, m = Date.CultureInfo.abbreviatedDayNames, o = Date.CultureInfo.shortestDayNames, s = name.toLowerCase(); for (var i = 0; i < n.length; i++) { if (n[i].toLowerCase() === s || m[i].toLowerCase() === s || o[i].toLowerCase() === s) { return i; } } return -1; }; /** * Gets the month number (0-11) if given a Culture Info specific string which is a valid monthName or abbreviatedMonthName. * @param {String} The name of the month (eg. "February, "Feb", "october", "oct"). * @return {Number} The day number */ $D.getMonthNumberFromName = function (name) { var n = Date.CultureInfo.monthNames, m = Date.CultureInfo.abbreviatedMonthNames, s = name.toLowerCase(); for (var i = 0; i < n.length; i++) { if (n[i].toLowerCase() === s || m[i].toLowerCase() === s) { return i; } } return -1; }; /** * Gets the language appropriate month name when given the month number(0-11) * eg - 0 == January * @return {String} The month name */ $D.getMonthName = function (n) { return Date.CultureInfo.monthNames[n]; }; /** * Determines if the current date instance is within a LeapYear. * @param {Number} The year. * @return {Boolean} true if date is within a LeapYear, otherwise false. */ $D.isLeapYear = function (year) { return ((year % 4 === 0 && year % 100 !== 0) || year % 400 === 0); }; /** * Gets the number of days in the month, given a year and month value. Automatically corrects for LeapYear. * @param {Number} The year. * @param {Number} The month (0-11). * @return {Number} The number of days in the month. */ $D.getDaysInMonth = function (year, month) { if (!month && $D.validateMonth(year)) { month = year; year = Date.today().getFullYear(); } return [31, ($D.isLeapYear(year) ? 29 : 28), 31, 30, 31, 30, 31, 31, 30, 31, 30, 31][month]; }; $P.getDaysInMonth = function () { return $D.getDaysInMonth(this.getFullYear(), this.getMonth()); }; $D.getTimezoneAbbreviation = function (offset, dst) { var p, n = (dst || false) ? Date.CultureInfo.abbreviatedTimeZoneDST : Date.CultureInfo.abbreviatedTimeZoneStandard; for (p in n) { if (n.hasOwnProperty(p)) { if (n[p] === offset) { return p; } } } return null; }; $D.getTimezoneOffset = function (name, dst) { var i, a =[], z = Date.CultureInfo.timezones; if (!name) { name = (new Date()).getTimezone();} for (i = 0; i < z.length; i++) { if (z[i].name === name.toUpperCase()) { a.push(i); } } if (!z[a[0]]) { return null; } if (a.length === 1 || !dst) { return z[a[0]].offset; } else { for (i=0; i < a.length; i++) { if (z[a[i]].dst) { return z[a[i]].offset; } } } }; $D.getQuarter = function (d) { d = d || new Date(); // If no date supplied, use today var q = [1,2,3,4]; return q[Math.floor(d.getMonth() / 3)]; // ~~~ is a bitwise op. Faster than Math.floor }; $D.getDaysLeftInQuarter = function (d) { d = d || new Date(); var qEnd = new Date(d); qEnd.setMonth(qEnd.getMonth() + 3 - qEnd.getMonth() % 3, 0); return Math.floor((qEnd - d) / 8.64e7); }; // private var validate = function (n, min, max, name) { name = name ? name : "Object"; if (typeof n === "undefined") { return false; } else if (typeof n !== "number") { throw new TypeError(n + " is not a Number."); } else if (n < min || n > max) { // As failing validation is *not* an exceptional circumstance // lets not throw a RangeError Exception here. // It's semantically correct but it's not sensible. return false; } return true; }; /** * Validates the number is within an acceptable range for milliseconds [0-999]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateMillisecond = function (value) { return validate(value, 0, 999, "millisecond"); }; /** * Validates the number is within an acceptable range for seconds [0-59]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateSecond = function (value) { return validate(value, 0, 59, "second"); }; /** * Validates the number is within an acceptable range for minutes [0-59]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateMinute = function (value) { return validate(value, 0, 59, "minute"); }; /** * Validates the number is within an acceptable range for hours [0-23]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateHour = function (value) { return validate(value, 0, 23, "hour"); }; /** * Validates the number is within an acceptable range for the days in a month [0-MaxDaysInMonth]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateDay = function (value, year, month) { if (year === undefined || year === null || month === undefined || month === null) { return false;} return validate(value, 1, $D.getDaysInMonth(year, month), "day"); }; /** * Validates the number is within an acceptable range for months [0-11]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateWeek = function (value) { return validate(value, 0, 53, "week"); }; /** * Validates the number is within an acceptable range for months [0-11]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateMonth = function (value) { return validate(value, 0, 11, "month"); }; /** * Validates the number is within an acceptable range for years. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateYear = function (value) { /** * Per ECMAScript spec the range of times supported by Date objects is * exactly -100,000,000 days to +100,000,000 days measured relative to * midnight at the beginning of 01 January, 1970 UTC. * This gives a range of 8,640,000,000,000,000 milliseconds to either * side of 01 January, 1970 UTC. * * Earliest possible date: Tue, 20 Apr 271,822 B.C. 00:00:00 UTC * Latest possible date: Sat, 13 Sep 275,760 00:00:00 UTC */ return validate(value, -271822, 275760, "year"); }; $D.validateTimezone = function(value) { var timezones = {"ACDT":1,"ACST":1,"ACT":1,"ADT":1,"AEDT":1,"AEST":1,"AFT":1,"AKDT":1,"AKST":1,"AMST":1,"AMT":1,"ART":1,"AST":1,"AWDT":1,"AWST":1,"AZOST":1,"AZT":1,"BDT":1,"BIOT":1,"BIT":1,"BOT":1,"BRT":1,"BST":1,"BTT":1,"CAT":1,"CCT":1,"CDT":1,"CEDT":1,"CEST":1,"CET":1,"CHADT":1,"CHAST":1,"CHOT":1,"ChST":1,"CHUT":1,"CIST":1,"CIT":1,"CKT":1,"CLST":1,"CLT":1,"COST":1,"COT":1,"CST":1,"CT":1,"CVT":1,"CWST":1,"CXT":1,"DAVT":1,"DDUT":1,"DFT":1,"EASST":1,"EAST":1,"EAT":1,"ECT":1,"EDT":1,"EEDT":1,"EEST":1,"EET":1,"EGST":1,"EGT":1,"EIT":1,"EST":1,"FET":1,"FJT":1,"FKST":1,"FKT":1,"FNT":1,"GALT":1,"GAMT":1,"GET":1,"GFT":1,"GILT":1,"GIT":1,"GMT":1,"GST":1,"GYT":1,"HADT":1,"HAEC":1,"HAST":1,"HKT":1,"HMT":1,"HOVT":1,"HST":1,"ICT":1,"IDT":1,"IOT":1,"IRDT":1,"IRKT":1,"IRST":1,"IST":1,"JST":1,"KGT":1,"KOST":1,"KRAT":1,"KST":1,"LHST":1,"LINT":1,"MAGT":1,"MART":1,"MAWT":1,"MDT":1,"MET":1,"MEST":1,"MHT":1,"MIST":1,"MIT":1,"MMT":1,"MSK":1,"MST":1,"MUT":1,"MVT":1,"MYT":1,"NCT":1,"NDT":1,"NFT":1,"NPT":1,"NST":1,"NT":1,"NUT":1,"NZDT":1,"NZST":1,"OMST":1,"ORAT":1,"PDT":1,"PET":1,"PETT":1,"PGT":1,"PHOT":1,"PHT":1,"PKT":1,"PMDT":1,"PMST":1,"PONT":1,"PST":1,"PYST":1,"PYT":1,"RET":1,"ROTT":1,"SAKT":1,"SAMT":1,"SAST":1,"SBT":1,"SCT":1,"SGT":1,"SLST":1,"SRT":1,"SST":1,"SYOT":1,"TAHT":1,"THA":1,"TFT":1,"TJT":1,"TKT":1,"TLT":1,"TMT":1,"TOT":1,"TVT":1,"UCT":1,"ULAT":1,"UTC":1,"UYST":1,"UYT":1,"UZT":1,"VET":1,"VLAT":1,"VOLT":1,"VOST":1,"VUT":1,"WAKT":1,"WAST":1,"WAT":1,"WEDT":1,"WEST":1,"WET":1,"WST":1,"YAKT":1,"YEKT":1,"Z":1}; return (timezones[value] === 1); }; $D.validateTimezoneOffset= function(value) { // timezones go from +14hrs to -12hrs, the +X hours are negative offsets. return (value > -841 && value < 721); }; }()); (function () { var $D = Date, $P = $D.prototype, p = function (s, l) { if (!l) { l = 2; } return ("000" + s).slice(l * -1); }; var validateConfigObject = function (obj) { var result = {}, self = this, prop, testFunc; testFunc = function (prop, func, value) { if (prop === "day") { var month = (obj.month !== undefined) ? obj.month : self.getMonth(); var year = (obj.year !== undefined) ? obj.year : self.getFullYear(); return $D[func](value, year, month); } else { return $D[func](value); } }; for (prop in obj) { if (Object.prototype.hasOwnProperty.call(obj, prop)) { var func = "validate" + prop.charAt(0).toUpperCase() + prop.slice(1); if ($D[func] && obj[prop] !== null && testFunc(prop, func, obj[prop])) { result[prop] = obj[prop]; } } } return result; }; /** * Resets the time of this Date object to 12:00 AM (00:00), which is the start of the day. * @param {Boolean} .clone() this date instance before clearing Time * @return {Date} this */ $P.clearTime = function () { this.setHours(0); this.setMinutes(0); this.setSeconds(0); this.setMilliseconds(0); return this; }; /** * Resets the time of this Date object to the current time ('now'). * @return {Date} this */ $P.setTimeToNow = function () { var n = new Date(); this.setHours(n.getHours()); this.setMinutes(n.getMinutes()); this.setSeconds(n.getSeconds()); this.setMilliseconds(n.getMilliseconds()); return this; }; /** * Returns a new Date object that is an exact date and time copy of the original instance. * @return {Date} A new Date instance */ $P.clone = function () { return new Date(this.getTime()); }; /** * Compares this instance to a Date object and returns an number indication of their relative values. * @param {Date} Date object to compare [Required] * @return {Number} -1 = this is lessthan date. 0 = values are equal. 1 = this is greaterthan date. */ $P.compareTo = function (date) { return Date.compare(this, date); }; /** * Compares this instance to another Date object and returns true if they are equal. * @param {Date} Date object to compare. If no date to compare, new Date() [now] is used. * @return {Boolean} true if dates are equal. false if they are not equal. */ $P.equals = function (date) { return Date.equals(this, (date !== undefined ? date : new Date())); }; /** * Determines if this instance is between a range of two dates or equal to either the start or end dates. * @param {Date} Start of range [Required] * @param {Date} End of range [Required] * @return {Boolean} true is this is between or equal to the start and end dates, else false */ $P.between = function (start, end) { return this.getTime() >= start.getTime() && this.getTime() <= end.getTime(); }; /** * Determines if this date occurs after the date to compare to. * @param {Date} Date object to compare. If no date to compare, new Date() ("now") is used. * @return {Boolean} true if this date instance is greater than the date to compare to (or "now"), otherwise false. */ $P.isAfter = function (date) { return this.compareTo(date || new Date()) === 1; }; /** * Determines if this date occurs before the date to compare to. * @param {Date} Date object to compare. If no date to compare, new Date() ("now") is used. * @return {Boolean} true if this date instance is less than the date to compare to (or "now"). */ $P.isBefore = function (date) { return (this.compareTo(date || new Date()) === -1); }; /** * Determines if the current Date instance occurs today. * @return {Boolean} true if this date instance is 'today', otherwise false. */ /** * Determines if the current Date instance occurs on the same Date as the supplied 'date'. * If no 'date' to compare to is provided, the current Date instance is compared to 'today'. * @param {date} Date object to compare. If no date to compare, the current Date ("now") is used. * @return {Boolean} true if this Date instance occurs on the same Day as the supplied 'date'. */ $P.isToday = $P.isSameDay = function (date) { return this.clone().clearTime().equals((date || new Date()).clone().clearTime()); }; /** * Adds the specified number of milliseconds to this instance. * @param {Number} The number of milliseconds to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addMilliseconds = function (value) { if (!value) { return this; } this.setTime(this.getTime() + value * 1); return this; }; /** * Adds the specified number of seconds to this instance. * @param {Number} The number of seconds to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addSeconds = function (value) { if (!value) { return this; } return this.addMilliseconds(value * 1000); }; /** * Adds the specified number of seconds to this instance. * @param {Number} The number of seconds to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addMinutes = function (value) { if (!value) { return this; } return this.addMilliseconds(value * 60000); // 60*1000 }; /** * Adds the specified number of hours to this instance. * @param {Number} The number of hours to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addHours = function (value) { if (!value) { return this; } return this.addMilliseconds(value * 3600000); // 60*60*1000 }; /** * Adds the specified number of days to this instance. * @param {Number} The number of days to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addDays = function (value) { if (!value) { return this; } this.setDate(this.getDate() + value * 1); return this; }; /** * Adds the specified number of weekdays (ie - not sat or sun) to this instance. * @param {Number} The number of days to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addWeekdays = function (value) { if (!value) { return this; } var day = this.getDay(); var weeks = (Math.ceil(Math.abs(value)/7)); if (day === 0 || day === 6) { if (value > 0) { this.next().monday(); this.addDays(-1); day = this.getDay(); } } if (value < 0) { while (value < 0) { this.addDays(-1); day = this.getDay(); if (day !== 0 && day !== 6) { value++; } } return this; } else if (value > 5 || (6-day) <= value) { value = value + (weeks * 2); } return this.addDays(value); }; /** * Adds the specified number of weeks to this instance. * @param {Number} The number of weeks to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addWeeks = function (value) { if (!value) { return this; } return this.addDays(value * 7); }; /** * Adds the specified number of months to this instance. * @param {Number} The number of months to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addMonths = function (value) { if (!value) { return this; } var n = this.getDate(); this.setDate(1); this.setMonth(this.getMonth() + value * 1); this.setDate(Math.min(n, $D.getDaysInMonth(this.getFullYear(), this.getMonth()))); return this; }; $P.addQuarters = function (value) { if (!value) { return this; } // note this will take you to the same point in the quarter as you are now. // i.e. - if you are 15 days into the quarter you'll be 15 days into the resulting one. // bonus: this allows adding fractional quarters return this.addMonths(value * 3); }; /** * Adds the specified number of years to this instance. * @param {Number} The number of years to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addYears = function (value) { if (!value) { return this; } return this.addMonths(value * 12); }; /** * Adds (or subtracts) to the value of the years, months, weeks, days, hours, minutes, seconds, milliseconds of the date instance using given configuration object. Positive and Negative values allowed. * Example

	Date.today().add( { days: 1, months: 1 } )

	new Date().add( { years: -1 } )
	
* @param {Object} Configuration object containing attributes (months, days, etc.) * @return {Date} this */ $P.add = function (config) { if (typeof config === "number") { this._orient = config; return this; } var x = config; if (x.day) { // If we should be a different date than today (eg: for 'tomorrow -1d', etc). // Should only effect parsing, not direct usage (eg, Finish and FinishExact) if ((x.day - this.getDate()) !== 0) { this.setDate(x.day); } } if (x.milliseconds) { this.addMilliseconds(x.milliseconds); } if (x.seconds) { this.addSeconds(x.seconds); } if (x.minutes) { this.addMinutes(x.minutes); } if (x.hours) { this.addHours(x.hours); } if (x.weeks) { this.addWeeks(x.weeks); } if (x.months) { this.addMonths(x.months); } if (x.years) { this.addYears(x.years); } if (x.days) { this.addDays(x.days); } return this; }; /** * Get the week number. Week one (1) is the week which contains the first Thursday of the year. Monday is considered the first day of the week. * The .getWeek() function does NOT convert the date to UTC. The local datetime is used. * Please use .getISOWeek() to get the week of the UTC converted date. * @return {Number} 1 to 53 */ $P.getWeek = function (utc) { // Create a copy of this date object var self, target = new Date(this.valueOf()); if (utc) { target.addMinutes(target.getTimezoneOffset()); self = target.clone(); } else { self = this; } // ISO week date weeks start on monday // so correct the day number var dayNr = (self.getDay() + 6) % 7; // ISO 8601 states that week 1 is the week // with the first thursday of that year. // Set the target date to the thursday in the target week target.setDate(target.getDate() - dayNr + 3); // Store the millisecond value of the target date var firstThursday = target.valueOf(); // Set the target to the first thursday of the year // First set the target to january first target.setMonth(0, 1); // Not a thursday? Correct the date to the next thursday if (target.getDay() !== 4) { target.setMonth(0, 1 + ((4 - target.getDay()) + 7) % 7); } // The weeknumber is the number of weeks between the // first thursday of the year and the thursday in the target week return 1 + Math.ceil((firstThursday - target) / 604800000); // 604800000 = 7 * 24 * 3600 * 1000 }; /** * Get the ISO 8601 week number. Week one ("01") is the week which contains the first Thursday of the year. Monday is considered the first day of the week. * The .getISOWeek() function does convert the date to it's UTC value. Please use .getWeek() to get the week of the local date. * @return {String} "01" to "53" */ $P.getISOWeek = function () { return p(this.getWeek(true)); }; /** * Moves the date to Monday of the week set. Week one (1) is the week which contains the first Thursday of the year. * @param {Number} A Number (1 to 53) that represents the week of the year. * @return {Date} this */ $P.setWeek = function (n) { if ((n - this.getWeek()) === 0) { if (this.getDay() !== 1) { return this.moveToDayOfWeek(1, (this.getDay() > 1 ? -1 : 1)); } else { return this; } } else { return this.moveToDayOfWeek(1, (this.getDay() > 1 ? -1 : 1)).addWeeks(n - this.getWeek()); } }; $P.setQuarter = function (qtr) { var month = Math.abs(((qtr-1) * 3) + 1); return this.setMonth(month, 1); }; $P.getQuarter = function () { return Date.getQuarter(this); }; $P.getDaysLeftInQuarter = function () { return Date.getDaysLeftInQuarter(this); }; /** * Moves the date to the next n'th occurrence of the dayOfWeek starting from the beginning of the month. The number (-1) is a magic number and will return the last occurrence of the dayOfWeek in the month. * @param {Number} The dayOfWeek to move to * @param {Number} The n'th occurrence to move to. Use (-1) to return the last occurrence in the month * @return {Date} this */ $P.moveToNthOccurrence = function (dayOfWeek, occurrence) { if (dayOfWeek === "Weekday") { if (occurrence > 0) { this.moveToFirstDayOfMonth(); if (this.is().weekday()) { occurrence -= 1; } } else if (occurrence < 0) { this.moveToLastDayOfMonth(); if (this.is().weekday()) { occurrence += 1; } } else { return this; } return this.addWeekdays(occurrence); } var shift = 0; if (occurrence > 0) { shift = occurrence - 1; } else if (occurrence === -1) { this.moveToLastDayOfMonth(); if (this.getDay() !== dayOfWeek) { this.moveToDayOfWeek(dayOfWeek, -1); } return this; } return this.moveToFirstDayOfMonth().addDays(-1).moveToDayOfWeek(dayOfWeek, +1).addWeeks(shift); }; var moveToN = function (getFunc, addFunc, nVal) { return function (value, orient) { var diff = (value - this[getFunc]() + nVal * (orient || +1)) % nVal; return this[addFunc]((diff === 0) ? diff += nVal * (orient || +1) : diff); }; }; /** * Move to the next or last dayOfWeek based on the orient value. * @param {Number} The dayOfWeek to move to * @param {Number} Forward (+1) or Back (-1). Defaults to +1. [Optional] * @return {Date} this */ $P.moveToDayOfWeek = moveToN("getDay", "addDays", 7); /** * Move to the next or last month based on the orient value. * @param {Number} The month to move to. 0 = January, 11 = December * @param {Number} Forward (+1) or Back (-1). Defaults to +1. [Optional] * @return {Date} this */ $P.moveToMonth = moveToN("getMonth", "addMonths", 12); /** * Get the Ordinate of the current day ("th", "st", "rd"). * @return {String} */ $P.getOrdinate = function () { var num = this.getDate(); return ord(num); }; /** * Get the Ordinal day (numeric day number) of the year, adjusted for leap year. * @return {Number} 1 through 365 (366 in leap years) */ $P.getOrdinalNumber = function () { return Math.ceil((this.clone().clearTime() - new Date(this.getFullYear(), 0, 1)) / 86400000) + 1; }; /** * Get the time zone abbreviation of the current date. * @return {String} The abbreviated time zone name (e.g. "EST") */ $P.getTimezone = function () { return $D.getTimezoneAbbreviation(this.getUTCOffset(), this.isDaylightSavingTime()); }; $P.setTimezoneOffset = function (offset) { var here = this.getTimezoneOffset(), there = Number(offset) * -6 / 10; return (there || there === 0) ? this.addMinutes(there - here) : this; }; $P.setTimezone = function (offset) { return this.setTimezoneOffset($D.getTimezoneOffset(offset)); }; /** * Indicates whether Daylight Saving Time is observed in the current time zone. * @return {Boolean} true|false */ $P.hasDaylightSavingTime = function () { return (Date.today().set({month: 0, day: 1}).getTimezoneOffset() !== Date.today().set({month: 6, day: 1}).getTimezoneOffset()); }; /** * Indicates whether this Date instance is within the Daylight Saving Time range for the current time zone. * @return {Boolean} true|false */ $P.isDaylightSavingTime = function () { return Date.today().set({month: 0, day: 1}).getTimezoneOffset() !== this.getTimezoneOffset(); }; /** * Get the offset from UTC of the current date. * @return {String} The 4-character offset string prefixed with + or - (e.g. "-0500") */ $P.getUTCOffset = function (offset) { var n = (offset || this.getTimezoneOffset()) * -10 / 6, r; if (n < 0) { r = (n - 10000).toString(); return r.charAt(0) + r.substr(2); } else { r = (n + 10000).toString(); return "+" + r.substr(1); } }; /** * Returns the number of milliseconds between this date and date. * @param {Date} Defaults to now * @return {Number} The diff in milliseconds */ $P.getElapsed = function (date) { return (date || new Date()) - this; }; /** * Set the value of year, month, day, hour, minute, second, millisecond of date instance using given configuration object. * Example

	Date.today().set( { day: 20, month: 1 } )

	new Date().set( { millisecond: 0 } )
	
* * @param {Object} Configuration object containing attributes (month, day, etc.) * @return {Date} this */ $P.set = function (config) { config = validateConfigObject.call(this, config); var key; for (key in config) { if (Object.prototype.hasOwnProperty.call(config, key)) { var name = key.charAt(0).toUpperCase() + key.slice(1); var addFunc, getFunc; if (key !== "week" && key !== "month" && key !== "timezone" && key !== "timezoneOffset") { name += "s"; } addFunc = "add" + name; getFunc = "get" + name; if (key === "month") { addFunc = addFunc + "s"; } else if (key === "year"){ getFunc = "getFullYear"; } if (key !== "day" && key !== "timezone" && key !== "timezoneOffset" && key !== "week" && key !== "hour") { this[addFunc](config[key] - this[getFunc]()); } else if ( key === "timezone"|| key === "timezoneOffset" || key === "week" || key === "hour") { this["set"+name](config[key]); } } } // day has to go last because you can't validate the day without first knowing the month if (config.day) { this.addDays(config.day - this.getDate()); } return this; }; /** * Moves the date to the first day of the month. * @return {Date} this */ $P.moveToFirstDayOfMonth = function () { return this.set({ day: 1 }); }; /** * Moves the date to the last day of the month. * @return {Date} this */ $P.moveToLastDayOfMonth = function () { return this.set({ day: $D.getDaysInMonth(this.getFullYear(), this.getMonth())}); }; /** * Converts the value of the current Date object to its equivalent string representation. * Format Specifiers * CUSTOM DATE AND TIME FORMAT STRINGS * Format Description Example * ------ --------------------------------------------------------------------------- ----------------------- * s The seconds of the minute between 0-59. "0" to "59" * ss The seconds of the minute with leading zero if required. "00" to "59" * * m The minute of the hour between 0-59. "0" or "59" * mm The minute of the hour with leading zero if required. "00" or "59" * * h The hour of the day between 1-12. "1" to "12" * hh The hour of the day with leading zero if required. "01" to "12" * * H The hour of the day between 0-23. "0" to "23" * HH The hour of the day with leading zero if required. "00" to "23" * * d The day of the month between 1 and 31. "1" to "31" * dd The day of the month with leading zero if required. "01" to "31" * ddd Abbreviated day name. Date.CultureInfo.abbreviatedDayNames. "Mon" to "Sun" * dddd The full day name. Date.CultureInfo.dayNames. "Monday" to "Sunday" * * M The month of the year between 1-12. "1" to "12" * MM The month of the year with leading zero if required. "01" to "12" * MMM Abbreviated month name. Date.CultureInfo.abbreviatedMonthNames. "Jan" to "Dec" * MMMM The full month name. Date.CultureInfo.monthNames. "January" to "December" * * yy The year as a two-digit number. "99" or "08" * yyyy The full four digit year. "1999" or "2008" * * t Displays the first character of the A.M./P.M. designator. "A" or "P" * Date.CultureInfo.amDesignator or Date.CultureInfo.pmDesignator * tt Displays the A.M./P.M. designator. "AM" or "PM" * Date.CultureInfo.amDesignator or Date.CultureInfo.pmDesignator * * S The ordinal suffix ("st, "nd", "rd" or "th") of the current day. "st, "nd", "rd" or "th" * * STANDARD DATE AND TIME FORMAT STRINGS * Format Description Example *------ --------------------------------------------------------------------------- ----------------------- * d The CultureInfo shortDate Format Pattern "M/d/yyyy" * D The CultureInfo longDate Format Pattern "dddd, MMMM dd, yyyy" * F The CultureInfo fullDateTime Format Pattern "dddd, MMMM dd, yyyy h:mm:ss tt" * m The CultureInfo monthDay Format Pattern "MMMM dd" * r The CultureInfo rfc1123 Format Pattern "ddd, dd MMM yyyy HH:mm:ss GMT" * s The CultureInfo sortableDateTime Format Pattern "yyyy-MM-ddTHH:mm:ss" * t The CultureInfo shortTime Format Pattern "h:mm tt" * T The CultureInfo longTime Format Pattern "h:mm:ss tt" * u The CultureInfo universalSortableDateTime Format Pattern "yyyy-MM-dd HH:mm:ssZ" * y The CultureInfo yearMonth Format Pattern "MMMM, yyyy" * * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @return {String} A string representation of the current Date object. */ var ord = function (n) { switch (n * 1) { case 1: case 21: case 31: return "st"; case 2: case 22: return "nd"; case 3: case 23: return "rd"; default: return "th"; } }; var parseStandardFormats = function (format) { var y, c = Date.CultureInfo.formatPatterns; switch (format) { case "d": return this.toString(c.shortDate); case "D": return this.toString(c.longDate); case "F": return this.toString(c.fullDateTime); case "m": return this.toString(c.monthDay); case "r": case "R": y = this.clone().addMinutes(this.getTimezoneOffset()); return y.toString(c.rfc1123) + " GMT"; case "s": return this.toString(c.sortableDateTime); case "t": return this.toString(c.shortTime); case "T": return this.toString(c.longTime); case "u": y = this.clone().addMinutes(this.getTimezoneOffset()); return y.toString(c.universalSortableDateTime); case "y": return this.toString(c.yearMonth); default: return false; } }; var parseFormatStringsClosure = function (context) { return function (m) { if (m.charAt(0) === "\\") { return m.replace("\\", ""); } switch (m) { case "hh": return p(context.getHours() < 13 ? (context.getHours() === 0 ? 12 : context.getHours()) : (context.getHours() - 12)); case "h": return context.getHours() < 13 ? (context.getHours() === 0 ? 12 : context.getHours()) : (context.getHours() - 12); case "HH": return p(context.getHours()); case "H": return context.getHours(); case "mm": return p(context.getMinutes()); case "m": return context.getMinutes(); case "ss": return p(context.getSeconds()); case "s": return context.getSeconds(); case "yyyy": return p(context.getFullYear(), 4); case "yy": return p(context.getFullYear()); case "y": return context.getFullYear(); case "E": case "dddd": return Date.CultureInfo.dayNames[context.getDay()]; case "ddd": return Date.CultureInfo.abbreviatedDayNames[context.getDay()]; case "dd": return p(context.getDate()); case "d": return context.getDate(); case "MMMM": return Date.CultureInfo.monthNames[context.getMonth()]; case "MMM": return Date.CultureInfo.abbreviatedMonthNames[context.getMonth()]; case "MM": return p((context.getMonth() + 1)); case "M": return context.getMonth() + 1; case "t": return context.getHours() < 12 ? Date.CultureInfo.amDesignator.substring(0, 1) : Date.CultureInfo.pmDesignator.substring(0, 1); case "tt": return context.getHours() < 12 ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator; case "S": return ord(context.getDate()); case "W": return context.getWeek(); case "WW": return context.getISOWeek(); case "Q": return "Q" + context.getQuarter(); case "q": return String(context.getQuarter()); case "z": return context.getTimezone(); case "Z": case "X": return Date.getTimezoneOffset(context.getTimezone()); case "ZZ": // Timezone offset in seconds return context.getTimezoneOffset() * -60; case "u": return context.getDay(); case "L": return ($D.isLeapYear(context.getFullYear())) ? 1 : 0; case "B": // Swatch Internet Time (.beats) return "@"+((context.getUTCSeconds() + (context.getUTCMinutes()*60) + ((context.getUTCHours()+1)*3600))/86.4); default: return m; } }; }; $P.toString = function (format, ignoreStandards) { // Standard Date and Time Format Strings. Formats pulled from CultureInfo file and // may vary by culture. if (!ignoreStandards && format && format.length === 1) { output = parseStandardFormats.call(this, format); if (output) { return output; } } var parseFormatStrings = parseFormatStringsClosure(this); return format ? format.replace(/((\\)?(dd?d?d?|MM?M?M?|yy?y?y?|hh?|HH?|mm?|ss?|tt?|S|q|Q|WW?W?W?)(?![^\[]*\]))/g, parseFormatStrings).replace(/\[|\]/g, "") : this._toString(); }; }()); /************************************************************* * SugarPak - Domain Specific Language - Syntactical Sugar * *************************************************************/ (function () { var $D = Date, $P = $D.prototype, $N = Number.prototype; // private $P._orient = +1; // private $P._nth = null; // private $P._is = false; // private $P._same = false; // private $P._isSecond = false; // private $N._dateElement = "days"; /** * Moves the date to the next instance of a date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.today().next().friday();
	Date.today().next().fri();
	Date.today().next().march();
	Date.today().next().mar();
	Date.today().next().week();
	
* * @return {Date} date */ $P.next = function () { this._move = true; this._orient = +1; return this; }; /** * Creates a new Date (Date.today()) and moves the date to the next instance of the date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.next().friday();
	Date.next().fri();
	Date.next().march();
	Date.next().mar();
	Date.next().week();
	
* * @return {Date} date */ $D.next = function () { return $D.today().next(); }; /** * Moves the date to the previous instance of a date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.today().last().friday();
	Date.today().last().fri();
	Date.today().last().march();
	Date.today().last().mar();
	Date.today().last().week();
	
* * @return {Date} date */ $P.last = $P.prev = $P.previous = function () { this._move = true; this._orient = -1; return this; }; /** * Creates a new Date (Date.today()) and moves the date to the previous instance of the date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.last().friday();
	Date.last().fri();
	Date.previous().march();
	Date.prev().mar();
	Date.last().week();
	
* * @return {Date} date */ $D.last = $D.prev = $D.previous = function () { return $D.today().last(); }; /** * Performs a equality check when followed by either a month name, day name or .weekday() function. * Example

	Date.today().is().friday(); // true|false
	Date.today().is().fri();
	Date.today().is().march();
	Date.today().is().mar();
	
* * @return {Boolean} true|false */ $P.is = function () { this._is = true; return this; }; /** * Determines if two date objects occur on/in exactly the same instance of the subsequent date part function. * The function .same() must be followed by a date part function (example: .day(), .month(), .year(), etc). * * An optional Date can be passed in the date part function. If now date is passed as a parameter, 'Now' is used. * * The following example demonstrates how to determine if two dates fall on the exact same day. * * Example

	var d1 = Date.today(); // today at 00:00
	var d2 = new Date();   // exactly now.

	// Do they occur on the same day?
	d1.same().day(d2); // true
	
	// Do they occur on the same hour?
	d1.same().hour(d2); // false, unless d2 hour is '00' (midnight).
	
	// What if it's the same day, but one year apart?
	var nextYear = Date.today().add(1).year();

	d1.same().day(nextYear); // false, because the dates must occur on the exact same day. 
	
* * Scenario: Determine if a given date occurs during some week period 2 months from now. * * Example

	var future = Date.today().add(2).months();
	return someDate.same().week(future); // true|false;
	
* * @return {Boolean} true|false */ $P.same = function () { this._same = true; this._isSecond = false; return this; }; /** * Determines if the current date/time occurs during Today. Must be preceded by the .is() function. * Example

	someDate.is().today();    // true|false
	new Date().is().today();  // true
	Date.today().is().today();// true
	Date.today().add(-1).day().is().today(); // false
	
* * @return {Boolean} true|false */ $P.today = function () { return this.same().day(); }; /** * Determines if the current date is a weekday. This function must be preceded by the .is() function. * Example

	Date.today().is().weekday(); // true|false
	
* * @return {Boolean} true|false */ $P.weekday = function () { if (this._nth) { return df("Weekday").call(this); } if (this._move) { return this.addWeekdays(this._orient); } if (this._is) { this._is = false; return (!this.is().sat() && !this.is().sun()); } return false; }; /** * Determines if the current date is on the weekend. This function must be preceded by the .is() function. * Example

	Date.today().is().weekend(); // true|false
	
* * @return {Boolean} true|false */ $P.weekend = function () { if (this._is) { this._is = false; return (this.is().sat() || this.is().sun()); } return false; }; /** * Sets the Time of the current Date instance. A string "6:15 pm" or config object {hour:18, minute:15} are accepted. * Example

	// Set time to 6:15pm with a String
	Date.today().at("6:15pm");

	// Set time to 6:15pm with a config object
	Date.today().at({hour:18, minute:15});
	
* * @return {Date} date */ $P.at = function (time) { return (typeof time === "string") ? $D.parse(this.toString("d") + " " + time) : this.set(time); }; /** * Creates a new Date() and adds this (Number) to the date based on the preceding date element function (eg. second|minute|hour|day|month|year). * Example

	// Undeclared Numbers must be wrapped with parentheses. Requirment of JavaScript.
	(3).days().fromNow();
	(6).months().fromNow();

	// Declared Number variables do not require parentheses. 
	var n = 6;
	n.months().fromNow();
	
* * @return {Date} A new Date instance */ $N.fromNow = $N.after = function (date) { var c = {}; c[this._dateElement] = this; return ((!date) ? new Date() : date.clone()).add(c); }; /** * Creates a new Date() and subtract this (Number) from the date based on the preceding date element function (eg. second|minute|hour|day|month|year). * Example

	// Undeclared Numbers must be wrapped with parentheses. Requirment of JavaScript.
	(3).days().ago();
	(6).months().ago();

	// Declared Number variables do not require parentheses. 
	var n = 6;
	n.months().ago();
	
* * @return {Date} A new Date instance */ $N.ago = $N.before = function (date) { var c = {}, s = (this._dateElement[this._dateElement.length-1] !== "s") ? this._dateElement + "s" : this._dateElement; c[s] = this * -1; return ((!date) ? new Date() : date.clone()).add(c); }; // Do NOT modify the following string tokens. These tokens are used to build dynamic functions. // All culture-specific strings can be found in the CultureInfo files. var dx = ("sunday monday tuesday wednesday thursday friday saturday").split(/\s/), mx = ("january february march april may june july august september october november december").split(/\s/), px = ("Millisecond Second Minute Hour Day Week Month Year Quarter Weekday").split(/\s/), pxf = ("Milliseconds Seconds Minutes Hours Date Week Month FullYear Quarter").split(/\s/), nth = ("final first second third fourth fifth").split(/\s/), de; /** * Returns an object literal of all the date parts. * Example

	var o = new Date().toObject();
	
	// { year: 2008, month: 4, week: 20, day: 13, hour: 18, minute: 9, second: 32, millisecond: 812 }
	
	// The object properties can be referenced directly from the object.
	
	alert(o.day);  // alerts "13"
	alert(o.year); // alerts "2008"
	
* * @return {Date} An object literal representing the original date object. */ $P.toObject = function () { var o = {}; for (var i = 0; i < px.length; i++) { if (this["get" + pxf[i]]) { o[px[i].toLowerCase()] = this["get" + pxf[i]](); } } return o; }; /** * Returns a date created from an object literal. Ignores the .week property if set in the config. * Example

	var o = new Date().toObject();
	
	return Date.fromObject(o); // will return the same date. 

	var o2 = {month: 1, day: 20, hour: 18}; // birthday party!
	Date.fromObject(o2);
	
* * @return {Date} An object literal representing the original date object. */ $D.fromObject = function(config) { config.week = null; return Date.today().set(config); }; // Create day name functions and abbreviated day name functions (eg. monday(), friday(), fri()). var df = function (n) { return function () { if (this._is) { this._is = false; return this.getDay() === n; } if (this._move) { this._move = null; } if (this._nth !== null) { // If the .second() function was called earlier, remove the _orient // from the date, and then continue. // This is required because 'second' can be used in two different context. // // Example // // Date.today().add(1).second(); // Date.march().second().monday(); // // Things get crazy with the following... // Date.march().add(1).second().second().monday(); // but it works!! // if (this._isSecond) { this.addSeconds(this._orient * -1); } // make sure we reset _isSecond this._isSecond = false; var ntemp = this._nth; this._nth = null; var temp = this.clone().moveToLastDayOfMonth(); this.moveToNthOccurrence(n, ntemp); if (this > temp) { throw new RangeError($D.getDayName(n) + " does not occur " + ntemp + " times in the month of " + $D.getMonthName(temp.getMonth()) + " " + temp.getFullYear() + "."); } return this; } return this.moveToDayOfWeek(n, this._orient); }; }; var sdf = function (n) { return function () { var t = $D.today(), shift = n - t.getDay(); if (n === 0 && Date.CultureInfo.firstDayOfWeek === 1 && t.getDay() !== 0) { shift = shift + 7; } return t.addDays(shift); }; }; // Create month name functions and abbreviated month name functions (eg. january(), march(), mar()). var month_instance_functions = function (n) { return function () { if (this._is) { this._is = false; return this.getMonth() === n; } return this.moveToMonth(n, this._orient); }; }; var month_static_functions = function (n) { return function () { return $D.today().set({ month: n, day: 1 }); }; }; var processTerms = function (names, staticFunc, instanceFunc) { for (var i = 0; i < names.length; i++) { // Create constant static Name variables. $D[names[i].toUpperCase()] = $D[names[i].toUpperCase().substring(0, 3)] = i; // Create Name functions. $D[names[i]] = $D[names[i].substring(0, 3)] = staticFunc(i); // Create Name instance functions. $P[names[i]] = $P[names[i].substring(0, 3)] = instanceFunc(i); } }; processTerms(dx, sdf, df); processTerms(mx, month_static_functions, month_instance_functions); // Create date element functions and plural date element functions used with Date (eg. day(), days(), months()). var ef = function (j) { return function () { // if the .second() function was called earlier, the _orient // has alread been added. Just return this and reset _isSecond. if (this._isSecond) { this._isSecond = false; return this; } if (this._same) { this._same = this._is = false; var o1 = this.toObject(), o2 = (arguments[0] || new Date()).toObject(), v = "", k = j.toLowerCase(); // the substr trick with -1 doesn't work in IE8 or less k = (k[k.length-1] === "s") ? k.substring(0,k.length-1) : k; for (var m = (px.length - 1); m > -1; m--) { v = px[m].toLowerCase(); if (o1[v] !== o2[v]) { return false; } if (k === v) { break; } } return true; } if (j.substring(j.length - 1) !== "s") { j += "s"; } if (this._move) { this._move = null; } return this["add" + j](this._orient); }; }; var nf = function (n) { return function () { this._dateElement = n; return this; }; }; for (var k = 0; k < px.length; k++) { de = px[k].toLowerCase(); if(de !== "weekday") { // Create date element functions and plural date element functions used with Date (eg. day(), days(), months()). $P[de] = $P[de + "s"] = ef(px[k]); // Create date element functions and plural date element functions used with Number (eg. day(), days(), months()). $N[de] = $N[de + "s"] = nf(de + "s"); } } $P._ss = ef("Second"); var nthfn = function (n) { return function (dayOfWeek) { if (this._same) { return this._ss(arguments[0]); } if (dayOfWeek || dayOfWeek === 0) { return this.moveToNthOccurrence(dayOfWeek, n); } this._nth = n; // if the operator is 'second' add the _orient, then deal with it later... if (n === 2 && (dayOfWeek === undefined || dayOfWeek === null)) { this._isSecond = true; return this.addSeconds(this._orient); } return this; }; }; for (var l = 0; l < nth.length; l++) { $P[nth[l]] = (l === 0) ? nthfn(-1) : nthfn(l); } }()); (function () { "use strict"; Date.Parsing = { Exception: function (s) { this.message = "Parse error at '" + s.substring(0, 10) + " ...'"; } }; var $P = Date.Parsing; var dayOffsets = { standard: [0,31,59,90,120,151,181,212,243,273,304,334], leap: [0,31,60,91,121,152,182,213,244,274,305,335] }; $P.isLeapYear = function(year) { return ((year % 4 === 0) && (year % 100 !== 0)) || (year % 400 === 0); }; var utils = { multiReplace : function (str, hash ) { var key; for (key in hash) { if (Object.prototype.hasOwnProperty.call(hash, key)) { var regex; if (typeof hash[key] === "function") { } else { regex = (hash[key] instanceof RegExp) ? hash[key] : new RegExp(hash[key], "g"); } str = str.replace(regex, key); } } return str; }, getDayOfYearFromWeek : function (obj) { var d, jan4, offset; obj.weekDay = (!obj.weekDay && obj.weekDay !== 0) ? 1 : obj.weekDay; d = new Date(obj.year, 0, 4); jan4 = d.getDay() === 0 ? 7 : d.getDay(); // JS is 0 indexed on Sunday. offset = jan4+3; obj.dayOfYear = ((obj.week * 7) + (obj.weekDay === 0 ? 7 : obj.weekDay))-offset; return obj; }, getDayOfYear : function (obj, dayOffset) { if (!obj.dayOfYear) { obj = utils.getDayOfYearFromWeek(obj); } for (var i=0;i <= dayOffset.length;i++) { if (obj.dayOfYear < dayOffset[i] || i === dayOffset.length) { obj.day = obj.day ? obj.day : (obj.dayOfYear - dayOffset[i-1]); break; } else { obj.month = i; } } return obj; }, adjustForTimeZone : function (obj, date) { var offset; if (obj.zone.toUpperCase() === "Z" || (obj.zone_hours === 0 && obj.zone_minutes === 0)) { // it's UTC/GML so work out the current timeszone offset offset = -date.getTimezoneOffset(); } else { offset = (obj.zone_hours*60) + (obj.zone_minutes || 0); if (obj.zone_sign === "+") { offset *= -1; } offset -= date.getTimezoneOffset(); } date.setMinutes(date.getMinutes()+offset); return date; }, setDefaults : function (obj) { obj.year = obj.year || Date.today().getFullYear(); obj.hours = obj.hours || 0; obj.minutes = obj.minutes || 0; obj.seconds = obj.seconds || 0; obj.milliseconds = obj.milliseconds || 0; if (!(!obj.month && (obj.week || obj.dayOfYear))) { // if we have a month, or if we don't but don't have the day calculation data obj.month = obj.month || 0; obj.day = obj.day || 1; } return obj; }, dataNum: function (data, mod, explict, postProcess) { var dataNum = data*1; if (mod) { if (postProcess) { return data ? mod(data)*1 : data; } else { return data ? mod(dataNum) : data; } } else if (!explict){ return data ? dataNum : data; } else { return (data && typeof data !== "undefined") ? dataNum : data; } }, timeDataProcess: function (obj) { var timeObj = {}; for (var x in obj.data) { if (obj.data.hasOwnProperty(x)) { timeObj[x] = obj.ignore[x] ? obj.data[x] : utils.dataNum(obj.data[x], obj.mods[x], obj.explict[x], obj.postProcess[x]); } } if (obj.data.secmins) { obj.data.secmins = obj.data.secmins.replace(",", ".") * 60; if (!timeObj.minutes) { timeObj.minutes = obj.data.secmins; } else if (!timeObj.seconds) { timeObj.seconds = obj.data.secmins; } delete obj.secmins; } return timeObj; }, buildTimeObjectFromData: function (data) { var time = utils.timeDataProcess({ data: { year : data[1], month : data[5], day : data[7], week : data[8], dayOfYear : data[10], hours : data[15], zone_hours : data[23], zone_minutes : data[24], zone : data[21], zone_sign : data[22], weekDay : data[9], minutes: data[16], seconds: data[19], milliseconds: data[20], secmins: data[18] }, mods: { month: function(data) { return data-1; }, weekDay: function (data) { data = Math.abs(data); return (data === 7 ? 0 : data); }, minutes: function (data) { return data.replace(":",""); }, seconds: function (data) { return Math.floor( (data.replace(":","").replace(",","."))*1 ); }, milliseconds: function (data) { return (data.replace(",",".")*1000); } }, postProcess: { minutes: true, seconds: true, milliseconds: true }, explict: { zone_hours: true, zone_minutes: true }, ignore: { zone: true, zone_sign: true, secmins: true } }); return time; }, addToHash: function (hash, keys, data) { keys = keys; data = data; var len = keys.length; for (var i = 0; i < len; i++) { hash[keys[i]] = data[i]; } return hash; }, combineRegex: function (r1, r2) { return new RegExp("(("+r1.source+")\\s("+r2.source+"))"); }, getDateNthString: function(add, last, inc){ if (add) { return Date.today().addDays(inc).toString("d"); } else if (last) { return Date.today().last()[inc]().toString("d"); } }, buildRegexData: function (array) { var arr = []; var len = array.length; for (var i=0; i < len; i++) { if (Object.prototype.toString.call(array[i]) === '[object Array]') { // oldIE compat version of Array.isArray arr.push(this.combineRegex(array[i][0], array[i][1])); } else { arr.push(array[i]); } } return arr; } }; $P.processTimeObject = function (obj) { var date, dayOffset; utils.setDefaults(obj); dayOffset = ($P.isLeapYear(obj.year)) ? dayOffsets.leap : dayOffsets.standard; if (!obj.month && (obj.week || obj.dayOfYear)) { utils.getDayOfYear(obj, dayOffset); } else { obj.dayOfYear = dayOffset[obj.month] + obj.day; } date = new Date(obj.year, obj.month, obj.day, obj.hours, obj.minutes, obj.seconds, obj.milliseconds); if (obj.zone) { utils.adjustForTimeZone(obj, date); // adjust (and calculate) for timezone } return date; }; $P.ISO = { regex : /^([\+-]?\d{4}(?!\d{2}\b))((-?)((0[1-9]|1[0-2])(\3([12]\d|0[1-9]|3[01]))?|W([0-4]\d|5[0-3])(-?[1-7])?|(00[1-9]|0[1-9]\d|[12]\d{2}|3([0-5]\d|6[1-6])))([T\s]((([01]\d|2[0-4])((:?)[0-5]\d)?|24\:?00)([\.,]\d+(?!:))?)?(\17[0-5]\d([\.,]\d+)?)?\s?([zZ]|([\+-])([01]\d|2[0-3]):?([0-5]\d)?)?)?)?$/, parse : function (s) { var time, data = s.match(this.regex); if (!data || !data.length) { return null; } time = utils.buildTimeObjectFromData(data); if (!time.year || (!time.year && (!time.month && !time.day) && (!time.week && !time.dayOfYear)) ) { return null; } return $P.processTimeObject(time); } }; $P.Numeric = { isNumeric: function (e){return!isNaN(parseFloat(e))&&isFinite(e);}, regex: /\b([0-1]?[0-9])([0-3]?[0-9])([0-2]?[0-9]?[0-9][0-9])\b/i, parse: function (s) { var data, i, time = {}, order = Date.CultureInfo.dateElementOrder.split(""); if (!(this.isNumeric(s)) || // if it's non-numeric OR (s[0] === "+" && s[0] === "-")) { // It's an arithmatic string (eg +/-1000) return null; } if (s.length < 5 && s.indexOf(".") < 0 && s.indexOf("/") < 0) { // assume it's just a year. time.year = s; return $P.processTimeObject(time); } data = s.match(this.regex); if (!data || !data.length) { return null; } for (i=0; i < order.length; i++) { switch(order[i]) { case "d": time.day = data[i+1]; break; case "m": time.month = (data[i+1]-1); break; case "y": time.year = data[i+1]; break; } } return $P.processTimeObject(time); } }; $P.Normalizer = { regexData: function () { var $R = Date.CultureInfo.regexPatterns; return utils.buildRegexData([ $R.tomorrow, $R.yesterday, [$R.past, $R.mon], [$R.past, $R.tue], [$R.past, $R.wed], [$R.past, $R.thu], [$R.past, $R.fri], [$R.past, $R.sat], [$R.past, $R.sun] ]); }, basicReplaceHash : function() { var $R = Date.CultureInfo.regexPatterns; return { "January": $R.jan.source, "February": $R.feb, "March": $R.mar, "April": $R.apr, "May": $R.may, "June": $R.jun, "July": $R.jul, "August": $R.aug, "September": $R.sep, "October": $R.oct, "November": $R.nov, "December": $R.dec, "": /\bat\b/gi, " ": /\s{2,}/, "am": $R.inTheMorning, "9am": $R.thisMorning, "pm": $R.inTheEvening, "7pm":$R.thisEvening }; }, keys : function(){ return [ utils.getDateNthString(true, false, 1), // tomorrow utils.getDateNthString(true, false, -1), // yesterday utils.getDateNthString(false, true, "monday"), //last mon utils.getDateNthString(false, true, "tuesday"), //last tues utils.getDateNthString(false, true, "wednesday"), //last wed utils.getDateNthString(false, true, "thursday"), //last thurs utils.getDateNthString(false, true, "friday"), //last fri utils.getDateNthString(false, true, "saturday"), //last sat utils.getDateNthString(false, true, "sunday") //last sun ]; }, buildRegexFunctions: function () { var $R = Date.CultureInfo.regexPatterns; var __ = Date.i18n.__; var tomorrowRE = new RegExp("(\\b\\d\\d?("+__("AM")+"|"+__("PM")+")? )("+$R.tomorrow.source.slice(1)+")", "i"); // adapted tomorrow regex for AM PM relative dates var todayRE = new RegExp($R.today.source + "(?!\\s*([+-]))\\b"); // today, but excludes the math operators (eg "today + 2h") this.replaceFuncs = [ [todayRE, function (full) { return (full.length > 1) ? Date.today().toString("d") : full; }], [tomorrowRE, function(full, m1) { var t = Date.today().addDays(1).toString("d"); return (t + " " + m1); }], [$R.amThisMorning, function(str, am){return am;}], [$R.pmThisEvening, function(str, pm){return pm;}] ]; }, buildReplaceData: function () { this.buildRegexFunctions(); this.replaceHash = utils.addToHash(this.basicReplaceHash(), this.keys(), this.regexData()); }, stringReplaceFuncs: function (s) { for (var i=0; i < this.replaceFuncs.length; i++) { s = s.replace(this.replaceFuncs[i][0], this.replaceFuncs[i][1]); } return s; }, parse: function (s) { s = this.stringReplaceFuncs(s); s = utils.multiReplace(s, this.replaceHash); try { var n = s.split(/([\s\-\.\,\/\x27]+)/); if (n.length === 3 && $P.Numeric.isNumeric(n[0]) && $P.Numeric.isNumeric(n[2]) && (n[2].length >= 4)) { // ok, so we're dealing with x/year. But that's not a full date. // This fixes wonky dateElementOrder parsing when set to dmy order. if (Date.CultureInfo.dateElementOrder[0] === "d") { s = "1/" + n[0] + "/" + n[2]; // set to 1st of month and normalize the seperator } } } catch (e) {} return s; } }; $P.Normalizer.buildReplaceData(); }()); (function () { var $P = Date.Parsing; var _ = $P.Operators = { // // Tokenizers // rtoken: function (r) { // regex token return function (s) { var mx = s.match(r); if (mx) { return ([ mx[0], s.substring(mx[0].length) ]); } else { throw new $P.Exception(s); } }; }, token: function () { // whitespace-eating token return function (s) { return _.rtoken(new RegExp("^\\s*" + s + "\\s*"))(s); }; }, stoken: function (s) { // string token return _.rtoken(new RegExp("^" + s)); }, // Atomic Operators until: function (p) { return function (s) { var qx = [], rx = null; while (s.length) { try { rx = p.call(this, s); } catch (e) { qx.push(rx[0]); s = rx[1]; continue; } break; } return [ qx, s ]; }; }, many: function (p) { return function (s) { var rx = [], r = null; while (s.length) { try { r = p.call(this, s); } catch (e) { return [ rx, s ]; } rx.push(r[0]); s = r[1]; } return [ rx, s ]; }; }, // generator operators -- see below optional: function (p) { return function (s) { var r = null; try { r = p.call(this, s); } catch (e) { return [ null, s ]; } return [ r[0], r[1] ]; }; }, not: function (p) { return function (s) { try { p.call(this, s); } catch (e) { return [null, s]; } throw new $P.Exception(s); }; }, ignore: function (p) { return p ? function (s) { var r = null; r = p.call(this, s); return [null, r[1]]; } : null; }, product: function () { var px = arguments[0], qx = Array.prototype.slice.call(arguments, 1), rx = []; for (var i = 0 ; i < px.length ; i++) { rx.push(_.each(px[i], qx)); } return rx; }, cache: function (rule) { var cache = {}, cache_length = 0, cache_keys = [], CACHE_MAX = Date.Config.CACHE_MAX || 100000, r = null; var cacheCheck = function () { if (cache_length === CACHE_MAX) { // kill several keys, don't want to have to do this all the time... for (var i=0; i < 10; i++) { var key = cache_keys.shift(); if (key) { delete cache[key]; cache_length--; } } } }; return function (s) { cacheCheck(); try { r = cache[s] = (cache[s] || rule.call(this, s)); } catch (e) { r = cache[s] = e; } cache_length++; cache_keys.push(s); if (r instanceof $P.Exception) { throw r; } else { return r; } }; }, // vector operators -- see below any: function () { var px = arguments; return function (s) { var r = null; for (var i = 0; i < px.length; i++) { if (px[i] == null) { continue; } try { r = (px[i].call(this, s)); } catch (e) { r = null; } if (r) { return r; } } throw new $P.Exception(s); }; }, each: function () { var px = arguments; return function (s) { var rx = [], r = null; for (var i = 0; i < px.length ; i++) { if (px[i] == null) { continue; } try { r = (px[i].call(this, s)); } catch (e) { throw new $P.Exception(s); } rx.push(r[0]); s = r[1]; } return [ rx, s]; }; }, all: function () { var px = arguments, _ = _; return _.each(_.optional(px)); }, // delimited operators sequence: function (px, d, c) { d = d || _.rtoken(/^\s*/); c = c || null; if (px.length === 1) { return px[0]; } return function (s) { var r = null, q = null; var rx = []; for (var i = 0; i < px.length ; i++) { try { r = px[i].call(this, s); } catch (e) { break; } rx.push(r[0]); try { q = d.call(this, r[1]); } catch (ex) { q = null; break; } s = q[1]; } if (!r) { throw new $P.Exception(s); } if (q) { throw new $P.Exception(q[1]); } if (c) { try { r = c.call(this, r[1]); } catch (ey) { throw new $P.Exception(r[1]); } } return [ rx, (r?r[1]:s) ]; }; }, // // Composite Operators // between: function (d1, p, d2) { d2 = d2 || d1; var _fn = _.each(_.ignore(d1), p, _.ignore(d2)); return function (s) { var rx = _fn.call(this, s); return [[rx[0][0], r[0][2]], rx[1]]; }; }, list: function (p, d, c) { d = d || _.rtoken(/^\s*/); c = c || null; return (p instanceof Array ? _.each(_.product(p.slice(0, -1), _.ignore(d)), p.slice(-1), _.ignore(c)) : _.each(_.many(_.each(p, _.ignore(d))), px, _.ignore(c))); }, set: function (px, d, c) { d = d || _.rtoken(/^\s*/); c = c || null; return function (s) { // r is the current match, best the current 'best' match // which means it parsed the most amount of input var r = null, p = null, q = null, rx = null, best = [[], s], last = false; // go through the rules in the given set for (var i = 0; i < px.length ; i++) { // last is a flag indicating whether this must be the last element // if there is only 1 element, then it MUST be the last one q = null; p = null; r = null; last = (px.length === 1); // first, we try simply to match the current pattern // if not, try the next pattern try { r = px[i].call(this, s); } catch (e) { continue; } // since we are matching against a set of elements, the first // thing to do is to add r[0] to matched elements rx = [[r[0]], r[1]]; // if we matched and there is still input to parse and // we don't already know this is the last element, // we're going to next check for the delimiter ... // if there's none, or if there's no input left to parse // than this must be the last element after all ... if (r[1].length > 0 && ! last) { try { q = d.call(this, r[1]); } catch (ex) { last = true; } } else { last = true; } // if we parsed the delimiter and now there's no more input, // that means we shouldn't have parsed the delimiter at all // so don't update r and mark this as the last element ... if (!last && q[1].length === 0) { last = true; } // so, if this isn't the last element, we're going to see if // we can get any more matches from the remaining (unmatched) // elements ... if (!last) { // build a list of the remaining rules we can match against, // i.e., all but the one we just matched against var qx = []; for (var j = 0; j < px.length ; j++) { if (i !== j) { qx.push(px[j]); } } // now invoke recursively set with the remaining input // note that we don't include the closing delimiter ... // we'll check for that ourselves at the end p = _.set(qx, d).call(this, q[1]); // if we got a non-empty set as a result ... // (otw rx already contains everything we want to match) if (p[0].length > 0) { // update current result, which is stored in rx ... // basically, pick up the remaining text from p[1] // and concat the result from p[0] so that we don't // get endless nesting ... rx[0] = rx[0].concat(p[0]); rx[1] = p[1]; } } // at this point, rx either contains the last matched element // or the entire matched set that starts with this element. // now we just check to see if this variation is better than // our best so far, in terms of how much of the input is parsed if (rx[1].length < best[1].length) { best = rx; } // if we've parsed all the input, then we're finished if (best[1].length === 0) { break; } } // so now we've either gone through all the patterns trying them // as the initial match; or we found one that parsed the entire // input string ... // if best has no matches, just return empty set ... if (best[0].length === 0) { return best; } // if a closing delimiter is provided, then we have to check it also if (c) { // we try this even if there is no remaining input because the pattern // may well be optional or match empty input ... try { q = c.call(this, best[1]); } catch (ey) { throw new $P.Exception(best[1]); } // it parsed ... be sure to update the best match remaining input best[1] = q[1]; } // if we're here, either there was no closing delimiter or we parsed it // so now we have the best match; just return it! return best; }; }, forward: function (gr, fname) { return function (s) { return gr[fname].call(this, s); }; }, // // Translation Operators // replace: function (rule, repl) { return function (s) { var r = rule.call(this, s); return [repl, r[1]]; }; }, process: function (rule, fn) { return function (s) { var r = rule.call(this, s); return [fn.call(this, r[0]), r[1]]; }; }, min: function (min, rule) { return function (s) { var rx = rule.call(this, s); if (rx[0].length < min) { throw new $P.Exception(s); } return rx; }; } }; // Generator Operators And Vector Operators // Generators are operators that have a signature of F(R) => R, // taking a given rule and returning another rule, such as // ignore, which parses a given rule and throws away the result. // Vector operators are those that have a signature of F(R1,R2,...) => R, // take a list of rules and returning a new rule, such as each. // Generator operators are converted (via the following _generator // function) into functions that can also take a list or array of rules // and return an array of new rules as though the function had been // called on each rule in turn (which is what actually happens). // This allows generators to be used with vector operators more easily. // Example: // each(ignore(foo, bar)) instead of each(ignore(foo), ignore(bar)) // This also turns generators into vector operators, which allows // constructs like: // not(cache(foo, bar)) var _generator = function (op) { function gen() { var args = null, rx = [], px, i; if (arguments.length > 1) { args = Array.prototype.slice.call(arguments); } else if (arguments[0] instanceof Array) { args = arguments[0]; } if (args) { px = args.shift(); if (px.length > 0) { args.unshift(px[i]); rx.push(op.apply(null, args)); args.shift(); return rx; } } else { return op.apply(null, arguments); } } return gen; }; var gx = "optional not ignore cache".split(/\s/); for (var i = 0 ; i < gx.length ; i++) { _[gx[i]] = _generator(_[gx[i]]); } var _vector = function (op) { return function () { if (arguments[0] instanceof Array) { return op.apply(null, arguments[0]); } else { return op.apply(null, arguments); } }; }; var vx = "each any all".split(/\s/); for (var j = 0 ; j < vx.length ; j++) { _[vx[j]] = _vector(_[vx[j]]); } }()); (function () { var $D = Date; var flattenAndCompact = function (ax) { var rx = []; for (var i = 0; i < ax.length; i++) { if (ax[i] instanceof Array) { rx = rx.concat(flattenAndCompact(ax[i])); } else { if (ax[i]) { rx.push(ax[i]); } } } return rx; }; var parseMeridian = function () { if (this.meridian && (this.hour || this.hour === 0)) { if (this.meridian === "a" && this.hour > 11 && Date.Config.strict24hr){ throw "Invalid hour and meridian combination"; } else if (this.meridian === "p" && this.hour < 12 && Date.Config.strict24hr){ throw "Invalid hour and meridian combination"; } else if (this.meridian === "p" && this.hour < 12) { this.hour = this.hour + 12; } else if (this.meridian === "a" && this.hour === 12) { this.hour = 0; } } }; var setDefaults = function () { var now = new Date(); if ((this.hour || this.minute) && (!this.month && !this.year && !this.day)) { this.day = now.getDate(); } if (!this.year) { this.year = now.getFullYear(); } if (!this.month && this.month !== 0) { this.month = now.getMonth(); } if (!this.day) { this.day = 1; } if (!this.hour) { this.hour = 0; } if (!this.minute) { this.minute = 0; } if (!this.second) { this.second = 0; } if (!this.millisecond) { this.millisecond = 0; } }; var finishUtils = { getToday: function () { if (this.now || "hour minute second".indexOf(this.unit) !== -1) { return new Date(); } else { return $D.today(); } }, setDaysFromWeekday: function (today, orient){ var gap; orient = orient || 1; this.unit = "day"; gap = ($D.getDayNumberFromName(this.weekday) - today.getDay()); this.days = gap ? ((gap + (orient * 7)) % 7) : (orient * 7); return this; }, setMonthsFromMonth: function (today, orient) { var gap; orient = orient || 1; this.unit = "month"; gap = (this.month - today.getMonth()); this.months = gap ? ((gap + (orient * 12)) % 12) : (orient * 12); this.month = null; return this; }, setDMYFromWeekday: function () { var d = Date[this.weekday](); this.day = d.getDate(); if (!this.month) { this.month = d.getMonth(); } this.year = d.getFullYear(); return this; }, setUnitValue: function (orient) { if (!this.value && this.operator && this.operator !== null && this[this.unit + "s"] && this[this.unit + "s"] !== null) { this[this.unit + "s"] = this[this.unit + "s"] + ((this.operator === "add") ? 1 : -1) + (this.value||0) * orient; } else if (this[this.unit + "s"] == null || this.operator != null) { if (!this.value) { this.value = 1; } this[this.unit + "s"] = this.value * orient; } }, generateDateFromWeeks: function () { var weekday = (this.weekday !== undefined) ? this.weekday : "today"; var d = Date[weekday]().addWeeks(this.weeks); if (this.now) { d.setTimeToNow(); } return d; } }; $D.Translator = { hour: function (s) { return function () { this.hour = Number(s); }; }, minute: function (s) { return function () { this.minute = Number(s); }; }, second: function (s) { return function () { this.second = Number(s); }; }, /* for ss.s format */ secondAndMillisecond: function (s) { return function () { var mx = s.match(/^([0-5][0-9])\.([0-9]{1,3})/); this.second = Number(mx[1]); this.millisecond = Number(mx[2]); }; }, meridian: function (s) { return function () { this.meridian = s.slice(0, 1).toLowerCase(); }; }, timezone: function (s) { return function () { var n = s.replace(/[^\d\+\-]/g, ""); if (n.length) { this.timezoneOffset = Number(n); } else { this.timezone = s.toLowerCase(); } }; }, day: function (x) { var s = x[0]; return function () { this.day = Number(s.match(/\d+/)[0]); if (this.day < 1) { throw "invalid day"; } }; }, month: function (s) { return function () { this.month = (s.length === 3) ? "jan feb mar apr may jun jul aug sep oct nov dec".indexOf(s)/4 : Number(s) - 1; if (this.month < 0) { throw "invalid month"; } }; }, year: function (s) { return function () { var n = Number(s); this.year = ((s.length > 2) ? n : (n + (((n + 2000) < Date.CultureInfo.twoDigitYearMax) ? 2000 : 1900))); }; }, rday: function (s) { return function () { switch (s) { case "yesterday": this.days = -1; break; case "tomorrow": this.days = 1; break; case "today": this.days = 0; break; case "now": this.days = 0; this.now = true; break; } }; }, finishExact: function (x) { var d; x = (x instanceof Array) ? x : [x]; for (var i = 0 ; i < x.length ; i++) { if (x[i]) { x[i].call(this); } } setDefaults.call(this); parseMeridian.call(this); if (this.day > $D.getDaysInMonth(this.year, this.month)) { throw new RangeError(this.day + " is not a valid value for days."); } d = new Date(this.year, this.month, this.day, this.hour, this.minute, this.second, this.millisecond); if (this.year < 100) { d.setFullYear(this.year); // means years less that 100 are process correctly. JS will parse it otherwise as 1900-1999. } if (this.timezone) { d.set({ timezone: this.timezone }); } else if (this.timezoneOffset) { d.set({ timezoneOffset: this.timezoneOffset }); } return d; }, finish: function (x) { var today, expression, orient, temp; x = (x instanceof Array) ? flattenAndCompact(x) : [ x ]; if (x.length === 0) { return null; } for (var i = 0 ; i < x.length ; i++) { if (typeof x[i] === "function") { x[i].call(this); } } if (this.now && !this.unit && !this.operator) { return new Date(); } else { today = finishUtils.getToday.call(this); } expression = !!(this.days && this.days !== null || this.orient || this.operator); orient = ((this.orient === "past" || this.operator === "subtract") ? -1 : 1); if (this.month && this.unit === "week") { this.value = this.month + 1; delete this.month; delete this.day; } if ((this.month || this.month === 0) && "year day hour minute second".indexOf(this.unit) !== -1) { if (!this.value) { this.value = this.month + 1; } this.month = null; expression = true; } if (!expression && this.weekday && !this.day && !this.days) { finishUtils.setDMYFromWeekday.call(this); } if (expression && this.weekday && this.unit !== "month" && this.unit !== "week") { finishUtils.setDaysFromWeekday.call(this, today, orient); } if (this.weekday && this.unit !== "week" && !this.day && !this.days) { temp = Date[this.weekday](); this.day = temp.getDate(); if (temp.getMonth() !== today.getMonth()) { this.month = temp.getMonth(); } } if (this.month && this.unit === "day" && this.operator) { if (!this.value) { this.value = (this.month + 1); } this.month = null; } if (this.value != null && this.month != null && this.year != null) { this.day = this.value * 1; } if (this.month && !this.day && this.value) { today.set({ day: this.value * 1 }); if (!expression) { this.day = this.value * 1; } } if (!this.month && this.value && this.unit === "month" && !this.now) { this.month = this.value; expression = true; } if (expression && (this.month || this.month === 0) && this.unit !== "year") { finishUtils.setMonthsFromMonth.call(this, today, orient); } if (!this.unit) { this.unit = "day"; } finishUtils.setUnitValue.call(this, orient); parseMeridian.call(this); if ((this.month || this.month === 0) && !this.day) { this.day = 1; } if (!this.orient && !this.operator && this.unit === "week" && this.value && !this.day && !this.month) { return Date.today().setWeek(this.value); } if (this.unit === "week" && this.weeks && !this.day && !this.month) { return finishUtils.generateDateFromWeeks.call(this); } if (expression && this.timezone && this.day && this.days) { this.day = this.days; } if (expression){ today.add(this); } else { today.set(this); } if (this.timezone) { this.timezone = this.timezone.toUpperCase(); var offset = $D.getTimezoneOffset(this.timezone); var timezone; if (today.hasDaylightSavingTime()) { // lets check that we're being sane with timezone setting timezone = $D.getTimezoneAbbreviation(offset, today.isDaylightSavingTime()); if (timezone !== this.timezone) { // bugger, we're in a place where things like EST vs EDT matters. if (today.isDaylightSavingTime()) { today.addHours(-1); } else { today.addHours(1); } } } today.setTimezoneOffset(offset); } return today; } }; }()); (function () { var $D = Date; $D.Grammar = {}; var _ = $D.Parsing.Operators, g = $D.Grammar, t = $D.Translator, _fn; // Allow rolling up into general purpose rules _fn = function () { return _.each(_.any.apply(null, arguments), _.not(g.ctoken2("timeContext"))); }; g.datePartDelimiter = _.rtoken(/^([\s\-\.\,\/\x27]+)/); g.timePartDelimiter = _.stoken(":"); g.whiteSpace = _.rtoken(/^\s*/); g.generalDelimiter = _.rtoken(/^(([\s\,]|at|@|on)+)/); var _C = {}; g.ctoken = function (keys) { var fn = _C[keys]; if (! fn) { var c = Date.CultureInfo.regexPatterns; var kx = keys.split(/\s+/), px = []; for (var i = 0; i < kx.length ; i++) { px.push(_.replace(_.rtoken(c[kx[i]]), kx[i])); } fn = _C[keys] = _.any.apply(null, px); } return fn; }; g.ctoken2 = function (key) { return _.rtoken(Date.CultureInfo.regexPatterns[key]); }; var cacheProcessRtoken = function (key, token, type, eachToken) { if (eachToken) { g[key] = _.cache(_.process(_.each(_.rtoken(token),_.optional(g.ctoken2(eachToken))), type)); } else { g[key] = _.cache(_.process(_.rtoken(token), type)); } }; var cacheProcessCtoken = function (token, type) { return _.cache(_.process(g.ctoken2(token), type)); }; var _F = {}; //function cache var _get = function (f) { _F[f] = (_F[f] || g.format(f)[0]); return _F[f]; }; g.allformats = function (fx) { var rx = []; if (fx instanceof Array) { for (var i = 0; i < fx.length; i++) { rx.push(_get(fx[i])); } } else { rx.push(_get(fx)); } return rx; }; g.formats = function (fx) { if (fx instanceof Array) { var rx = []; for (var i = 0 ; i < fx.length ; i++) { rx.push(_get(fx[i])); } return _.any.apply(null, rx); } else { return _get(fx); } }; var grammarFormats = { timeFormats: function(){ var i, RTokenKeys = [ "h", "hh", "H", "HH", "m", "mm", "s", "ss", "ss.s", "z", "zz" ], RToken = [ /^(0[0-9]|1[0-2]|[1-9])/, /^(0[0-9]|1[0-2])/, /^([0-1][0-9]|2[0-3]|[0-9])/, /^([0-1][0-9]|2[0-3])/, /^([0-5][0-9]|[0-9])/, /^[0-5][0-9]/, /^([0-5][0-9]|[0-9])/, /^[0-5][0-9]/, /^[0-5][0-9]\.[0-9]{1,3}/, /^((\+|\-)\s*\d\d\d\d)|((\+|\-)\d\d\:?\d\d)/, /^((\+|\-)\s*\d\d\d\d)|((\+|\-)\d\d\:?\d\d)/ ], tokens = [ t.hour, t.hour, t.hour, t.hour, t.minute, t.minute, t.second, t.second, t.secondAndMillisecond, t.timezone, t.timezone ]; for (i=0; i < RTokenKeys.length; i++) { cacheProcessRtoken(RTokenKeys[i], RToken[i], tokens[i]); } g.hms = _.cache(_.sequence([g.H, g.m, g.s], g.timePartDelimiter)); g.t = cacheProcessCtoken("shortMeridian", t.meridian); g.tt = cacheProcessCtoken("longMeridian", t.meridian); g.zzz = cacheProcessCtoken("timezone", t.timezone); g.timeSuffix = _.each(_.ignore(g.whiteSpace), _.set([ g.tt, g.zzz ])); g.time = _.each(_.optional(_.ignore(_.stoken("T"))), g.hms, g.timeSuffix); }, dateFormats: function () { // pre-loaded rules for different date part order preferences var _setfn = function () { return _.set(arguments, g.datePartDelimiter); }; var i, RTokenKeys = [ "d", "dd", "M", "MM", "y", "yy", "yyy", "yyyy" ], RToken = [ /^([0-2]\d|3[0-1]|\d)/, /^([0-2]\d|3[0-1])/, /^(1[0-2]|0\d|\d)/, /^(1[0-2]|0\d)/, /^(\d+)/, /^(\d\d)/, /^(\d\d?\d?\d?)/, /^(\d\d\d\d)/ ], tokens = [ t.day, t.day, t.month, t.month, t.year, t.year, t.year, t.year ], eachToken = [ "ordinalSuffix", "ordinalSuffix" ]; for (i=0; i < RTokenKeys.length; i++) { cacheProcessRtoken(RTokenKeys[i], RToken[i], tokens[i], eachToken[i]); } g.MMM = g.MMMM = _.cache(_.process(g.ctoken("jan feb mar apr may jun jul aug sep oct nov dec"), t.month)); g.ddd = g.dddd = _.cache(_.process(g.ctoken("sun mon tue wed thu fri sat"), function (s) { return function () { this.weekday = s; }; } )); g.day = _fn(g.d, g.dd); g.month = _fn(g.M, g.MMM); g.year = _fn(g.yyyy, g.yy); g.mdy = _setfn(g.ddd, g.month, g.day, g.year); g.ymd = _setfn(g.ddd, g.year, g.month, g.day); g.dmy = _setfn(g.ddd, g.day, g.month, g.year); g.date = function (s) { return ((g[Date.CultureInfo.dateElementOrder] || g.mdy).call(this, s)); }; }, relative: function () { // relative date / time expressions g.orientation = _.process(g.ctoken("past future"), function (s) { return function () { this.orient = s; }; } ); g.operator = _.process(g.ctoken("add subtract"), function (s) { return function () { this.operator = s; }; } ); g.rday = _.process(g.ctoken("yesterday tomorrow today now"), t.rday); g.unit = _.process(g.ctoken("second minute hour day week month year"), function (s) { return function () { this.unit = s; }; } ); } }; g.buildGrammarFormats = function () { // these need to be rebuilt every time the language changes. _C = {}; grammarFormats.timeFormats(); grammarFormats.dateFormats(); grammarFormats.relative(); g.value = _.process(_.rtoken(/^([-+]?\d+)?(st|nd|rd|th)?/), function (s) { return function () { this.value = s.replace(/\D/g, ""); }; } ); g.expression = _.set([g.rday, g.operator, g.value, g.unit, g.orientation, g.ddd, g.MMM ]); g.format = _.process(_.many( _.any( // translate format specifiers into grammar rules _.process( _.rtoken(/^(dd?d?d?(?!e)|MM?M?M?|yy?y?y?|hh?|HH?|mm?|ss?|tt?|zz?z?)/), function (fmt) { if (g[fmt]) { return g[fmt]; } else { throw $D.Parsing.Exception(fmt); } } ), // translate separator tokens into token rules _.process(_.rtoken(/^[^dMyhHmstz]+/), // all legal separators function (s) { return _.ignore(_.stoken(s)); } ) ) ), // construct the parser ... function (rules) { return _.process(_.each.apply(null, rules), t.finishExact); } ); // starting rule for general purpose grammar g._start = _.process(_.set([ g.date, g.time, g.expression ], g.generalDelimiter, g.whiteSpace), t.finish); }; g.buildGrammarFormats(); // parsing date format specifiers - ex: "h:m:s tt" // this little guy will generate a custom parser based // on the format string, ex: g.format("h:m:s tt") // check for these formats first g._formats = g.formats([ "\"yyyy-MM-ddTHH:mm:ssZ\"", "yyyy-MM-ddTHH:mm:ss.sz", "yyyy-MM-ddTHH:mm:ssZ", "yyyy-MM-ddTHH:mm:ssz", "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-ddTHH:mmZ", "yyyy-MM-ddTHH:mmz", "yyyy-MM-ddTHH:mm", "ddd, MMM dd, yyyy H:mm:ss tt", "ddd MMM d yyyy HH:mm:ss zzz", "MMddyyyy", "ddMMyyyy", "Mddyyyy", "ddMyyyy", "Mdyyyy", "dMyyyy", "yyyy", "Mdyy", "dMyy", "d" ]); // real starting rule: tries selected formats first, // then general purpose rule g.start = function (s) { try { var r = g._formats.call({}, s); if (r[1].length === 0) { return r; } } catch (e) {} return g._start.call({}, s); }; }()); (function () { var $D = Date; /** * @desc Converts the specified string value into its JavaScript Date equivalent using CultureInfo specific format information. * * Example

	///////////
	// Dates //
	///////////

	// 15-Oct-2004
	var d1 = Date.parse("10/15/2004");

	// 15-Oct-2004
	var d1 = Date.parse("15-Oct-2004");

	// 15-Oct-2004
	var d1 = Date.parse("2004.10.15");

	//Fri Oct 15, 2004
	var d1 = Date.parse("Fri Oct 15, 2004");

	///////////
	// Times //
	///////////

	// Today at 10 PM.
	var d1 = Date.parse("10 PM");

	// Today at 10:30 PM.
	var d1 = Date.parse("10:30 P.M.");

	// Today at 6 AM.
	var d1 = Date.parse("06am");

	/////////////////////
	// Dates and Times //
	/////////////////////

	// 8-July-2004 @ 10:30 PM
	var d1 = Date.parse("July 8th, 2004, 10:30 PM");

	// 1-July-2004 @ 10:30 PM
	var d1 = Date.parse("2004-07-01T22:30:00");

	////////////////////
	// Relative Dates //
	////////////////////

	// Returns today's date. The string "today" is culture specific.
	var d1 = Date.parse("today");

	// Returns yesterday's date. The string "yesterday" is culture specific.
	var d1 = Date.parse("yesterday");

	// Returns the date of the next thursday.
	var d1 = Date.parse("Next thursday");

	// Returns the date of the most previous monday.
	var d1 = Date.parse("last monday");

	// Returns today's day + one year.
	var d1 = Date.parse("next year");

	///////////////
	// Date Math //
	///////////////

	// Today + 2 days
	var d1 = Date.parse("t+2");

	// Today + 2 days
	var d1 = Date.parse("today + 2 days");

	// Today + 3 months
	var d1 = Date.parse("t+3m");

	// Today - 1 year
	var d1 = Date.parse("today - 1 year");

	// Today - 1 year
	var d1 = Date.parse("t-1y"); 


	/////////////////////////////
	// Partial Dates and Times //
	/////////////////////////////

	// July 15th of this year.
	var d1 = Date.parse("July 15");

	// 15th day of current day and year.
	var d1 = Date.parse("15");

	// July 1st of current year at 10pm.
	var d1 = Date.parse("7/1 10pm");
	
* * @param {String} The string value to convert into a Date object [Required] * @return {Date} A Date object or null if the string cannot be converted into a Date. */ var parseUtils = { removeOrds: function (s) { ords = s.match(/\b(\d+)(?:st|nd|rd|th)\b/); // find ordinal matches s = ((ords && ords.length === 2) ? s.replace(ords[0], ords[1]) : s); return s; }, grammarParser: function (s) { var r = null; try { r = $D.Grammar.start.call({}, s.replace(/^\s*(\S*(\s+\S+)*)\s*$/, "$1")); } catch (e) { return null; } return ((r[1].length === 0) ? r[0] : null); }, nativeFallback: function(s) { var t; try { // ok we haven't parsed it, last ditch attempt with the built-in parser. t = Date._parse(s); return (t || t === 0) ? new Date(t) : null; } catch (e) { return null; } } }; function parse (s) { var d; if (!s) { return null; } if (s instanceof Date) { return s.clone(); } if (s.length >= 4 && s.charAt(0) !== "0" && s.charAt(0) !== "+"&& s.charAt(0) !== "-") { // ie: 2004 will pass, 0800 won't. // Start with specific formats d = $D.Parsing.ISO.parse(s) || $D.Parsing.Numeric.parse(s); } if (d instanceof Date && !isNaN(d.getTime())) { return d; } else { // find ordinal dates (1st, 3rd, 8th, etc and remove them as they cause parsing issues) s = $D.Parsing.Normalizer.parse(parseUtils.removeOrds(s)); d = parseUtils.grammarParser(s); if (d !== null) { return d; } else { return parseUtils.nativeFallback(s); } } } if (!$D._parse) { $D._parse = $D.parse; } $D.parse = parse; Date.getParseFunction = function (fx) { var fns = Date.Grammar.allformats(fx); return function (s) { var r = null; for (var i = 0; i < fns.length; i++) { try { r = fns[i].call({}, s); } catch (e) { continue; } if (r[1].length === 0) { return r[0]; } } return null; }; }; /** * Converts the specified string value into its JavaScript Date equivalent using the specified format {String} or formats {Array} and the CultureInfo specific format information. * The format of the string value must match one of the supplied formats exactly. * * Example

	// 15-Oct-2004
	var d1 = Date.parseExact("10/15/2004", "M/d/yyyy");

	// 15-Oct-2004
	var d1 = Date.parse("15-Oct-2004", "M-ddd-yyyy");

	// 15-Oct-2004
	var d1 = Date.parse("2004.10.15", "yyyy.MM.dd");

	// Multiple formats
	var d1 = Date.parseExact("10/15/2004", ["M/d/yyyy", "MMMM d, yyyy"]);
	
* * @param {String} The string value to convert into a Date object [Required]. * @param {Object} The expected format {String} or an array of expected formats {Array} of the date string [Required]. * @return {Date} A Date object or null if the string cannot be converted into a Date. */ $D.parseExact = function (s, fx) { return $D.getParseFunction(fx)(s); }; }()); (function () { var $D = Date, $P = $D.prototype, // $C = $D.CultureInfo, // not used atm p = function (s, l) { if (!l) { l = 2; } return ("000" + s).slice(l * -1); }; /** * Converts a PHP format string to Java/.NET format string. * A PHP format string can be used with ._format or .format. * A Java/.NET format string can be used with .toString(). * The .parseExact function will only accept a Java/.NET format string * * Example * var f1 = "%m/%d/%y" * var f2 = Date.normalizeFormat(f1); // "MM/dd/yy" * * new Date().format(f1); // "04/13/08" * new Date()._format(f1); // "04/13/08" * new Date().toString(f2); // "04/13/08" * * var date = Date.parseExact("04/13/08", f2); // Sun Apr 13 2008 * * @param {String} A PHP format string consisting of one or more format spcifiers. * @return {String} The PHP format converted to a Java/.NET format string. */ var normalizerSubstitutions = { "d" : "dd", "%d": "dd", "D" : "ddd", "%a": "ddd", "j" : "dddd", "l" : "dddd", "%A": "dddd", "S" : "S", "F" : "MMMM", "%B": "MMMM", "m" : "MM", "%m": "MM", "M" : "MMM", "%b": "MMM", "%h": "MMM", "n" : "M", "Y" : "yyyy", "%Y": "yyyy", "y" : "yy", "%y": "yy", "g" : "h", "%I": "h", "G" : "H", "h" : "hh", "H" : "HH", "%H": "HH", "i" : "mm", "%M": "mm", "s" : "ss", "%S": "ss", "%r": "hh:mm tt", "%R": "H:mm", "%T": "H:mm:ss", "%X": "t", "%x": "d", "%e": "d", "%D": "MM/dd/yy", "%n": "\\n", "%t": "\\t", "e" : "z", "T" : "z", "%z": "z", "%Z": "z", "Z" : "ZZ", "N" : "u", "w" : "u", "%w": "u", "W" : "W", "%V": "W" }; var normalizer = { substitutes: function (m) { return normalizerSubstitutions[m]; }, interpreted: function (m, x) { var y; switch (m) { case "%u": return x.getDay() + 1; case "z": return x.getOrdinalNumber(); case "%j": return p(x.getOrdinalNumber(), 3); case "%U": var d1 = x.clone().set({month: 0, day: 1}).addDays(-1).moveToDayOfWeek(0), d2 = x.clone().addDays(1).moveToDayOfWeek(0, -1); return (d2 < d1) ? "00" : p((d2.getOrdinalNumber() - d1.getOrdinalNumber()) / 7 + 1); case "%W": return p(x.getWeek()); case "t": return $D.getDaysInMonth(x.getFullYear(), x.getMonth()); case "o": case "%G": return x.setWeek(x.getISOWeek()).toString("yyyy"); case "%g": return x._format("%G").slice(-2); case "a": case "%p": return t("tt").toLowerCase(); case "A": return t("tt").toUpperCase(); case "u": return p(x.getMilliseconds(), 3); case "I": return (x.isDaylightSavingTime()) ? 1 : 0; case "O": return x.getUTCOffset(); case "P": y = x.getUTCOffset(); return y.substring(0, y.length - 2) + ":" + y.substring(y.length - 2); case "B": var now = new Date(); return Math.floor(((now.getHours() * 3600) + (now.getMinutes() * 60) + now.getSeconds() + (now.getTimezoneOffset() + 60) * 60) / 86.4); case "c": return x.toISOString().replace(/\"/g, ""); case "U": return $D.strtotime("now"); case "%c": return t("d") + " " + t("t"); case "%C": return Math.floor(x.getFullYear() / 100 + 1); } }, shouldOverrideDefaults: function (m) { switch (m) { case "%e": return true; default: return false; } }, parse: function (m, context) { var formatString, c = context || new Date(); formatString = normalizer.substitutes(m); if (formatString) { return formatString; } formatString = normalizer.interpreted(m, c); if (formatString) { return formatString; } else { return m; } } }; $D.normalizeFormat = function (format, context) { return format.replace(/(%|\\)?.|%%/g, function(t){ return normalizer.parse(t, context); }); }; /** * Format a local Unix timestamp according to locale settings * * Example: * Date.strftime("%m/%d/%y", new Date()); // "04/13/08" * Date.strftime("c", "2008-04-13T17:52:03Z"); // "04/13/08" * * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @param {Number|String} The number representing the number of seconds that have elapsed since January 1, 1970 (local time). * @return {String} A string representation of the current Date object. */ $D.strftime = function (format, time) { var d = Date.parse(time); return d._format(format); }; /** * Parse any textual datetime description into a Unix timestamp. * A Unix timestamp is the number of seconds that have elapsed since January 1, 1970 (midnight UTC/GMT). * * Example: * Date.strtotime("04/13/08"); // 1208044800 * Date.strtotime("1970-01-01T00:00:00Z"); // 0 * * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @param {Object} A string or date object. * @return {String} A string representation of the current Date object. */ $D.strtotime = function (time) { var d = $D.parse(time); return Math.round($D.UTC(d.getUTCFullYear(), d.getUTCMonth(), d.getUTCDate(), d.getUTCHours(), d.getUTCMinutes(), d.getUTCSeconds(), d.getUTCMilliseconds()) / 1000); }; /** * Converts the value of the current Date object to its equivalent string representation using a PHP/Unix style of date format specifiers. * Format Specifiers * Format Description Example * ------ --------------------------------------------------------------------------- ----------------------- * %a abbreviated weekday name according to the current localed "Mon" through "Sun" * %A full weekday name according to the current localed "Sunday" through "Saturday" * %b abbreviated month name according to the current localed "Jan" through "Dec" * %B full month name according to the current locale "January" through "December" * %c preferred date and time representation for the current locale "4/13/2008 12:33 PM" * %C century number (the year divided by 100 and truncated to an integer) "00" to "99" * %d day of the month as a decimal number "01" to "31" * %D same as %m/%d/%y "04/13/08" * %e day of the month as a decimal number, a single digit is preceded by a space "1" to "31" * %g like %G, but without the century "08" * %G The 4-digit year corresponding to the ISO week number (see %V). "2008" * This has the same format and value as %Y, except that if the ISO week number * belongs to the previous or next year, that year is used instead. * %h same as %b "Jan" through "Dec" * %H hour as a decimal number using a 24-hour clock. "00" to "23" * %I hour as a decimal number using a 12-hour clock. "01" to "12" * %j day of the year as a decimal number. "001" to "366" * %m month as a decimal number. "01" to "12" * %M minute as a decimal number. "00" to "59" * %n newline character "\n" * %p either "am" or "pm" according to the given time value, or the "am" or "pm" * corresponding strings for the current locale. * %r time in a.m. and p.m. notation "8:44 PM" * %R time in 24 hour notation "20:44" * %S second as a decimal number "00" to "59" * %t tab character "\t" * %T current time, equal to %H:%M:%S "12:49:11" * %u weekday as a decimal number ["1", "7"], with "1" representing Monday "1" to "7" * %U week number of the current year as a decimal number, starting with the "0" to ("52" or "53") * first Sunday as the first day of the first week * %V The ISO 8601:1988 week number of the current year as a decimal number, "00" to ("52" or "53") * range 01 to 53, where week 1 is the first week that has at least 4 days * in the current year, and with Monday as the first day of the week. * (Use %G or %g for the year component that corresponds to the week number * for the specified timestamp.) * %W week number of the current year as a decimal number, starting with the "00" to ("52" or "53") * first Monday as the first day of the first week * %w day of the week as a decimal, Sunday being "0" "0" to "6" * %x preferred date representation for the current locale without the time "4/13/2008" * %X preferred time representation for the current locale without the date "12:53:05" * %y year as a decimal number without a century "00" "99" * %Y year as a decimal number including the century "2008" * %Z time zone or name or abbreviation "UTC", "EST", "PST" * %z same as %Z * %% a literal "%" characters "%" * d Day of the month, 2 digits with leading zeros "01" to "31" * D A textual representation of a day, three letters "Mon" through "Sun" * j Day of the month without leading zeros "1" to "31" * l A full textual representation of the day of the week (lowercase "L") "Sunday" through "Saturday" * N ISO-8601 numeric representation of the day of the week (added in PHP 5.1.0) "1" (for Monday) through "7" (for Sunday) * S English ordinal suffix for the day of the month, 2 characters "st", "nd", "rd" or "th". Works well with j * w Numeric representation of the day of the week "0" (for Sunday) through "6" (for Saturday) * z The day of the year (starting from "0") "0" through "365" * W ISO-8601 week number of year, weeks starting on Monday "00" to ("52" or "53") * F A full textual representation of a month, such as January or March "January" through "December" * m Numeric representation of a month, with leading zeros "01" through "12" * M A short textual representation of a month, three letters "Jan" through "Dec" * n Numeric representation of a month, without leading zeros "1" through "12" * t Number of days in the given month "28" through "31" * L Whether it's a leap year "1" if it is a leap year, "0" otherwise * o ISO-8601 year number. This has the same value as Y, except that if the "2008" * ISO week number (W) belongs to the previous or next year, that year * is used instead. * Y A full numeric representation of a year, 4 digits "2008" * y A two digit representation of a year "08" * a Lowercase Ante meridiem and Post meridiem "am" or "pm" * A Uppercase Ante meridiem and Post meridiem "AM" or "PM" * B Swatch Internet time "000" through "999" * g 12-hour format of an hour without leading zeros "1" through "12" * G 24-hour format of an hour without leading zeros "0" through "23" * h 12-hour format of an hour with leading zeros "01" through "12" * H 24-hour format of an hour with leading zeros "00" through "23" * i Minutes with leading zeros "00" to "59" * s Seconds, with leading zeros "00" through "59" * u Milliseconds "54321" * e Timezone identifier "UTC", "EST", "PST" * I Whether or not the date is in daylight saving time (uppercase i) "1" if Daylight Saving Time, "0" otherwise * O Difference to Greenwich time (GMT) in hours "+0200", "-0600" * P Difference to Greenwich time (GMT) with colon between hours and minutes "+02:00", "-06:00" * T Timezone abbreviation "UTC", "EST", "PST" * Z Timezone offset in seconds. The offset for timezones west of UTC is "-43200" through "50400" * always negative, and for those east of UTC is always positive. * c ISO 8601 date "2004-02-12T15:19:21+00:00" * r RFC 2822 formatted date "Thu, 21 Dec 2000 16:01:07 +0200" * U Seconds since the Unix Epoch (January 1 1970 00:00:00 GMT) "0" * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @return {String} A string representation of the current Date object. */ var formatReplace = function (context) { return function (m) { var formatString, override = false; if (m.charAt(0) === "\\" || m.substring(0, 2) === "%%") { return m.replace("\\", "").replace("%%", "%"); } override = normalizer.shouldOverrideDefaults(m); formatString = $D.normalizeFormat(m, context); if (formatString) { return context.toString(formatString, override); } }; }; $P._format = function (format) { var formatter = formatReplace(this); if (!format) { return this._toString(); } else { return format.replace(/(%|\\)?.|%%/g, formatter); } }; if (!$P.format) { $P.format = $P._format; } }()); (function () { "use strict"; var gFn = function (attr) { return function () { return this[attr]; }; }; var sFn = function (attr) { return function (val) { this[attr] = val; return this; }; }; var attrs = ["years", "months", "days", "hours", "minutes", "seconds", "milliseconds"]; var addSetFuncs = function (context, attrs) { for (var i = 0; i < attrs.length ; i++) { var $a = attrs[i], $b = $a.slice(0, 1).toUpperCase() + $a.slice(1); context.prototype[$a] = 0; context.prototype["get" + $b] = gFn($a); context.prototype["set" + $b] = sFn($a); } }; /** * new TimeSpan(milliseconds); * new TimeSpan(days, hours, minutes, seconds); * new TimeSpan(days, hours, minutes, seconds, milliseconds); */ var TimeSpan = function (days, hours, minutes, seconds, milliseconds) { if (arguments.length === 1 && typeof days === "number") { var orient = (days < 0) ? -1 : +1; var millsLeft = Math.abs(days); this.setDays(Math.floor(millsLeft / 86400000) * orient); millsLeft = millsLeft % 86400000; this.setHours(Math.floor(millsLeft / 3600000) * orient); millsLeft = millsLeft % 3600000; this.setMinutes(Math.floor(millsLeft / 60000) * orient); millsLeft = millsLeft % 60000; this.setSeconds(Math.floor(millsLeft / 1000) * orient); millsLeft = millsLeft % 1000; this.setMilliseconds(millsLeft * orient); } else { this.set(days, hours, minutes, seconds, milliseconds); } this.getTotalMilliseconds = function () { return (this.getDays() * 86400000) + (this.getHours() * 3600000) + (this.getMinutes() * 60000) + (this.getSeconds() * 1000); }; this.compareTo = function (time) { var t1 = new Date(1970, 1, 1, this.getHours(), this.getMinutes(), this.getSeconds()), t2; if (time === null) { t2 = new Date(1970, 1, 1, 0, 0, 0); } else { t2 = new Date(1970, 1, 1, time.getHours(), time.getMinutes(), time.getSeconds()); } return (t1 < t2) ? -1 : (t1 > t2) ? 1 : 0; }; this.equals = function (time) { return (this.compareTo(time) === 0); }; this.add = function (time) { return (time === null) ? this : this.addSeconds(time.getTotalMilliseconds() / 1000); }; this.subtract = function (time) { return (time === null) ? this : this.addSeconds(-time.getTotalMilliseconds() / 1000); }; this.addDays = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 86400000)); }; this.addHours = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 3600000)); }; this.addMinutes = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 60000)); }; this.addSeconds = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 1000)); }; this.addMilliseconds = function (n) { return new TimeSpan(this.getTotalMilliseconds() + n); }; this.get12HourHour = function () { return (this.getHours() > 12) ? this.getHours() - 12 : (this.getHours() === 0) ? 12 : this.getHours(); }; this.getDesignator = function () { return (this.getHours() < 12) ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator; }; this.toString = function (format) { this._toString = function () { if (this.getDays() !== null && this.getDays() > 0) { return this.getDays() + "." + this.getHours() + ":" + this.p(this.getMinutes()) + ":" + this.p(this.getSeconds()); } else { return this.getHours() + ":" + this.p(this.getMinutes()) + ":" + this.p(this.getSeconds()); } }; this.p = function (s) { return (s.toString().length < 2) ? "0" + s : s; }; var me = this; return format ? format.replace(/dd?|HH?|hh?|mm?|ss?|tt?/g, function (format) { switch (format) { case "d": return me.getDays(); case "dd": return me.p(me.getDays()); case "H": return me.getHours(); case "HH": return me.p(me.getHours()); case "h": return me.get12HourHour(); case "hh": return me.p(me.get12HourHour()); case "m": return me.getMinutes(); case "mm": return me.p(me.getMinutes()); case "s": return me.getSeconds(); case "ss": return me.p(me.getSeconds()); case "t": return ((me.getHours() < 12) ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator).substring(0, 1); case "tt": return (me.getHours() < 12) ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator; } } ) : this._toString(); }; return this; }; addSetFuncs(TimeSpan, attrs.slice(2)); TimeSpan.prototype.set = function (days, hours, minutes, seconds, milliseconds){ this.setDays(days || this.getDays()); this.setHours(hours || this.getHours()); this.setMinutes(minutes || this.getMinutes()); this.setSeconds(seconds || this.getSeconds()); this.setMilliseconds(milliseconds || this.getMilliseconds()); }; /** * Gets the time of day for this date instances. * @return {TimeSpan} TimeSpan */ Date.prototype.getTimeOfDay = function () { return new TimeSpan(0, this.getHours(), this.getMinutes(), this.getSeconds(), this.getMilliseconds()); }; Date.TimeSpan = TimeSpan; if (typeof window !== "undefined" ) { // keeping API compatible for v1.x window.TimeSpan = TimeSpan; } }()); (function () { "use strict"; var attrs = ["years", "months", "days", "hours", "minutes", "seconds", "milliseconds"]; var gFn = function (attr) { return function () { return this[attr]; }; }; var sFn = function (attr) { return function (val) { this[attr] = val; return this; }; }; var addSetFuncs = function (context, attrs) { for (var i = 0; i < attrs.length ; i++) { var $a = attrs[i], $b = $a.slice(0, 1).toUpperCase() + $a.slice(1); context.prototype[$a] = 0; context.prototype["get" + $b] = gFn($a); context.prototype["set" + $b] = sFn($a); } }; var setMonthsAndYears = function (orient, d1, d2, context) { function inc() { d1.addMonths(-orient); context.months++; if (context.months === 12) { context.years++; context.months = 0; } } if (orient === +1) { while (d1 > d2) { inc(); } } else { while (d1 < d2) { inc(); } } context.months--; context.months *= orient; context.years *= orient; }; var adjustForDST = function(orient, startDate, endDate) { var hasDSTMismatch = (false === (startDate.isDaylightSavingTime() === endDate.isDaylightSavingTime())); if (hasDSTMismatch && orient === 1) { startDate.addHours(-1); } else if (hasDSTMismatch) { startDate.addHours(1); } }; /** * TimePeriod(startDate, endDate); * TimePeriod(years, months, days, hours, minutes, seconds, milliseconds); */ var TimePeriod = function (years, months, days, hours, minutes, seconds, milliseconds) { if (arguments.length === 7) { this.set(years, months, days, hours, minutes, seconds, milliseconds); } else if (arguments.length === 2 && arguments[0] instanceof Date && arguments[1] instanceof Date) { var startDate = arguments[0].clone(); var endDate = arguments[1].clone(); var orient = (startDate > endDate) ? +1 : -1; this.dates = { start: arguments[0].clone(), end: arguments[1].clone() }; setMonthsAndYears(orient, startDate, endDate, this); adjustForDST(orient, startDate, endDate); // // TODO - adjust for DST var diff = endDate - startDate; if (diff !== 0) { var ts = new TimeSpan(diff); this.set(this.years, this.months, ts.getDays(), ts.getHours(), ts.getMinutes(), ts.getSeconds(), ts.getMilliseconds()); } } return this; }; // create all the set functions. addSetFuncs(TimePeriod, attrs); TimePeriod.prototype.set = function (years, months, days, hours, minutes, seconds, milliseconds){ this.setYears(years || this.getYears()); this.setMonths(months || this.getMonths()); this.setDays(days || this.getDays()); this.setHours(hours || this.getHours()); this.setMinutes(minutes || this.getMinutes()); this.setSeconds(seconds || this.getSeconds()); this.setMilliseconds(milliseconds || this.getMilliseconds()); }; Date.TimePeriod = TimePeriod; if (typeof window !== "undefined") { // keeping API compatible for v1.x window.TimePeriod = TimePeriod; } }()); ================================================ FILE: build/date-se-FI.js ================================================ /** * @overview datejs * @version 1.0.0-rc3 * @author Gregory Wild-Smith * @copyright 2015 Gregory Wild-Smith * @license MIT * @homepage https://github.com/abritinthebay/datejs */ /* * DateJS Culture String File * Country Code: se-FI * Name: Sami (Northern) (Finland) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["se-FI"] = { "name": "se-FI", "englishName": "Sami (Northern) (Finland)", "nativeName": "davvisámegiella (Suopma)", "Sunday": "sotnabeaivi", "Monday": "vuossárga", "Tuesday": "maŋŋebárga", "Wednesday": "gaskavahkku", "Thursday": "duorastat", "Friday": "bearjadat", "Saturday": "lávvardat", "Sun": "sotn", "Mon": "vuos", "Tue": "maŋ", "Wed": "gask", "Thu": "duor", "Fri": "bear", "Sat": "láv", "Su": "sotn", "Mo": "vuos", "Tu": "maŋ", "We": "gask", "Th": "duor", "Fr": "bear", "Sa": "láv", "S_Sun_Initial": "s", "M_Mon_Initial": "v", "T_Tue_Initial": "m", "W_Wed_Initial": "g", "T_Thu_Initial": "d", "F_Fri_Initial": "b", "S_Sat_Initial": "l", "January": "ođđajagemánnu", "February": "guovvamánnu", "March": "njukčamánnu", "April": "cuoŋománnu", "May": "miessemánnu", "June": "geassemánnu", "July": "suoidnemánnu", "August": "borgemánnu", "September": "čakčamánnu", "October": "golggotmánnu", "November": "skábmamánnu", "December": "juovlamánnu", "Jan_Abbr": "ođđj", "Feb_Abbr": "guov", "Mar_Abbr": "njuk", "Apr_Abbr": "cuo", "May_Abbr": "mies", "Jun_Abbr": "geas", "Jul_Abbr": "suoi", "Aug_Abbr": "borg", "Sep_Abbr": "čakč", "Oct_Abbr": "golg", "Nov_Abbr": "skáb", "Dec_Abbr": "juov", "AM": "", "PM": "", "firstDayOfWeek": 1, "twoDigitYearMax": 2029, "mdy": "dmy", "M/d/yyyy": "d.M.yyyy", "dddd, MMMM dd, yyyy": "MMMM d'. b. 'yyyy", "h:mm tt": "H:mm:ss", "h:mm:ss tt": "H:mm:ss", "dddd, MMMM dd, yyyy h:mm:ss tt": "MMMM d'. b. 'yyyy H:mm:ss", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "MMMM dd", "MMMM, yyyy": "MMMM yyyy", "/jan(uary)?/": "ođđajagemánnu", "/feb(ruary)?/": "guov(vamánnu)?", "/mar(ch)?/": "njuk(čamánnu)?", "/apr(il)?/": "cuo(ŋománnu)?", "/may/": "mies(semánnu)?", "/jun(e)?/": "geas(semánnu)?", "/jul(y)?/": "suoi(dnemánnu)?", "/aug(ust)?/": "borg(emánnu)?", "/sep(t(ember)?)?/": "čakč(amánnu)?", "/oct(ober)?/": "golg(gotmánnu)?", "/nov(ember)?/": "skáb(mamánnu)?", "/dec(ember)?/": "juov(lamánnu)?", "/^su(n(day)?)?/": "^sotnabeaivi", "/^mo(n(day)?)?/": "^vuossárga", "/^tu(e(s(day)?)?)?/": "^maŋŋebárga", "/^we(d(nesday)?)?/": "^gaskavahkku", "/^th(u(r(s(day)?)?)?)?/": "^duorastat", "/^fr(i(day)?)?/": "^bearjadat", "/^sa(t(urday)?)?/": "^lávvardat", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "se-FI"; /** * @overview datejs * @version 1.0.0-rc3 * @author Gregory Wild-Smith * @copyright 2015 Gregory Wild-Smith * @license MIT * @homepage https://github.com/abritinthebay/datejs */(function () { var $D = Date; var lang = Date.CultureStrings ? Date.CultureStrings.lang : null; var loggedKeys = {}; // for debug purposes. var getText = { getFromKey: function (key, countryCode) { var output; if (Date.CultureStrings && Date.CultureStrings[countryCode] && Date.CultureStrings[countryCode][key]) { output = Date.CultureStrings[countryCode][key]; } else { output = getText.buildFromDefault(key); } if (key.charAt(0) === "/") { // Assume it's a regex output = getText.buildFromRegex(key, countryCode); } return output; }, getFromObjectValues: function (obj, countryCode) { var key, output = {}; for(key in obj) { if (obj.hasOwnProperty(key)) { output[key] = getText.getFromKey(obj[key], countryCode); } } return output; }, getFromObjectKeys: function (obj, countryCode) { var key, output = {}; for(key in obj) { if (obj.hasOwnProperty(key)) { output[getText.getFromKey(key, countryCode)] = obj[key]; } } return output; }, getFromArray: function (arr, countryCode) { var output = []; for (var i=0; i < arr.length; i++){ if (i in arr) { output[i] = getText.getFromKey(arr[i], countryCode); } } return output; }, buildFromDefault: function (key) { var output, length, split, last; switch(key) { case "name": output = "en-US"; break; case "englishName": output = "English (United States)"; break; case "nativeName": output = "English (United States)"; break; case "twoDigitYearMax": output = 2049; break; case "firstDayOfWeek": output = 0; break; default: output = key; split = key.split("_"); length = split.length; if (length > 1 && key.charAt(0) !== "/") { // if the key isn't a regex and it has a split. last = split[(length - 1)].toLowerCase(); if (last === "initial" || last === "abbr") { output = split[0]; } } break; } return output; }, buildFromRegex: function (key, countryCode) { var output; if (Date.CultureStrings && Date.CultureStrings[countryCode] && Date.CultureStrings[countryCode][key]) { output = new RegExp(Date.CultureStrings[countryCode][key], "i"); } else { output = new RegExp(key.replace(new RegExp("/", "g"),""), "i"); } return output; } }; var shallowMerge = function (obj1, obj2) { for (var attrname in obj2) { if (obj2.hasOwnProperty(attrname)) { obj1[attrname] = obj2[attrname]; } } }; var __ = function (key, language) { var countryCode = (language) ? language : lang; loggedKeys[key] = key; if (typeof key === "object") { if (key instanceof Array) { return getText.getFromArray(key, countryCode); } else { return getText.getFromObjectKeys(key, countryCode); } } else { return getText.getFromKey(key, countryCode); } }; var loadI18nScript = function (code) { // paatterned after jQuery's getScript. var url = Date.Config.i18n + code + ".js"; var head = document.getElementsByTagName("head")[0] || document.documentElement; var script = document.createElement("script"); script.src = url; var completed = false; var events = { done: function (){} // placeholder function }; // Attach handlers for all browsers script.onload = script.onreadystatechange = function() { if ( !completed && (!this.readyState || this.readyState === "loaded" || this.readyState === "complete") ) { events.done(); head.removeChild(script); } }; setTimeout(function() { head.insertBefore(script, head.firstChild); }, 0); // allows return to execute first return { done: function (cb) { events.done = function() { if (cb) { setTimeout(cb,0); } }; } }; }; var buildInfo = { buildFromMethodHash: function (obj) { var key; for(key in obj) { if (obj.hasOwnProperty(key)) { obj[key] = buildInfo[obj[key]](); } } return obj; }, timeZoneDST: function () { var DST = { "CHADT": "+1345", "NZDT": "+1300", "AEDT": "+1100", "ACDT": "+1030", "AZST": "+0500", "IRDT": "+0430", "EEST": "+0300", "CEST": "+0200", "BST": "+0100", "PMDT": "-0200", "ADT": "-0300", "NDT": "-0230", "EDT": "-0400", "CDT": "-0500", "MDT": "-0600", "PDT": "-0700", "AKDT": "-0800", "HADT": "-0900" }; return __(DST); }, timeZoneStandard: function () { var standard = { "LINT": "+1400", "TOT": "+1300", "CHAST": "+1245", "NZST": "+1200", "NFT": "+1130", "SBT": "+1100", "AEST": "+1000", "ACST": "+0930", "JST": "+0900", "CWST": "+0845", "CT": "+0800", "ICT": "+0700", "MMT": "+0630", "BST": "+0600", "NPT": "+0545", "IST": "+0530", "PKT": "+0500", "AFT": "+0430", "MSK": "+0400", "IRST": "+0330", "FET": "+0300", "EET": "+0200", "CET": "+0100", "GMT": "+0000", "UTC": "+0000", "CVT": "-0100", "GST": "-0200", "BRT": "-0300", "NST": "-0330", "AST": "-0400", "EST": "-0500", "CST": "-0600", "MST": "-0700", "PST": "-0800", "AKST": "-0900", "MIT": "-0930", "HST": "-1000", "SST": "-1100", "BIT": "-1200" }; return __(standard); }, timeZones: function (data) { var zone; data.timezones = []; for (zone in data.abbreviatedTimeZoneStandard) { if (data.abbreviatedTimeZoneStandard.hasOwnProperty(zone)) { data.timezones.push({ name: zone, offset: data.abbreviatedTimeZoneStandard[zone]}); } } for (zone in data.abbreviatedTimeZoneDST) { if (data.abbreviatedTimeZoneDST.hasOwnProperty(zone)) { data.timezones.push({ name: zone, offset: data.abbreviatedTimeZoneDST[zone], dst: true}); } } return data.timezones; }, days: function () { return __(["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"]); }, dayAbbr: function () { return __(["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"]); }, dayShortNames: function () { return __(["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"]); }, dayFirstLetters: function () { return __(["S_Sun_Initial", "M_Mon_Initial", "T_Tues_Initial", "W_Wed_Initial", "T_Thu_Initial", "F_Fri_Initial", "S_Sat_Initial"]); }, months: function () { return __(["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"]); }, monthAbbr: function () { return __(["Jan_Abbr", "Feb_Abbr", "Mar_Abbr", "Apr_Abbr", "May_Abbr", "Jun_Abbr", "Jul_Abbr", "Aug_Abbr", "Sep_Abbr", "Oct_Abbr", "Nov_Abbr", "Dec_Abbr"]); }, formatPatterns: function () { return getText.getFromObjectValues({ shortDate: "M/d/yyyy", longDate: "dddd, MMMM dd, yyyy", shortTime: "h:mm tt", longTime: "h:mm:ss tt", fullDateTime: "dddd, MMMM dd, yyyy h:mm:ss tt", sortableDateTime: "yyyy-MM-ddTHH:mm:ss", universalSortableDateTime: "yyyy-MM-dd HH:mm:ssZ", rfc1123: "ddd, dd MMM yyyy HH:mm:ss", monthDay: "MMMM dd", yearMonth: "MMMM, yyyy" }, Date.i18n.currentLanguage()); }, regex: function () { return getText.getFromObjectValues({ inTheMorning: "/( in the )(morn(ing)?)\\b/", thisMorning: "/(this )(morn(ing)?)\\b/", amThisMorning: "/(\b\\d(am)? )(this )(morn(ing)?)/", inTheEvening: "/( in the )(even(ing)?)\\b/", thisEvening: "/(this )(even(ing)?)\\b/", pmThisEvening: "/(\b\\d(pm)? )(this )(even(ing)?)/", jan: "/jan(uary)?/", feb: "/feb(ruary)?/", mar: "/mar(ch)?/", apr: "/apr(il)?/", may: "/may/", jun: "/jun(e)?/", jul: "/jul(y)?/", aug: "/aug(ust)?/", sep: "/sep(t(ember)?)?/", oct: "/oct(ober)?/", nov: "/nov(ember)?/", dec: "/dec(ember)?/", sun: "/^su(n(day)?)?/", mon: "/^mo(n(day)?)?/", tue: "/^tu(e(s(day)?)?)?/", wed: "/^we(d(nesday)?)?/", thu: "/^th(u(r(s(day)?)?)?)?/", fri: "/fr(i(day)?)?/", sat: "/^sa(t(urday)?)?/", future: "/^next/", past: "/^last|past|prev(ious)?/", add: "/^(\\+|aft(er)?|from|hence)/", subtract: "/^(\\-|bef(ore)?|ago)/", yesterday: "/^yes(terday)?/", today: "/^t(od(ay)?)?/", tomorrow: "/^tom(orrow)?/", now: "/^n(ow)?/", millisecond: "/^ms|milli(second)?s?/", second: "/^sec(ond)?s?/", minute: "/^mn|min(ute)?s?/", hour: "/^h(our)?s?/", week: "/^w(eek)?s?/", month: "/^m(onth)?s?/", day: "/^d(ay)?s?/", year: "/^y(ear)?s?/", shortMeridian: "/^(a|p)/", longMeridian: "/^(a\\.?m?\\.?|p\\.?m?\\.?)/", timezone: "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/", ordinalSuffix: "/^\\s*(st|nd|rd|th)/", timeContext: "/^\\s*(\\:|a(?!u|p)|p)/" }, Date.i18n.currentLanguage()); } }; var CultureInfo = function () { var info = getText.getFromObjectValues({ name: "name", englishName: "englishName", nativeName: "nativeName", amDesignator: "AM", pmDesignator: "PM", firstDayOfWeek: "firstDayOfWeek", twoDigitYearMax: "twoDigitYearMax", dateElementOrder: "mdy" }, Date.i18n.currentLanguage()); var constructedInfo = buildInfo.buildFromMethodHash({ dayNames: "days", abbreviatedDayNames: "dayAbbr", shortestDayNames: "dayShortNames", firstLetterDayNames: "dayFirstLetters", monthNames: "months", abbreviatedMonthNames: "monthAbbr", formatPatterns: "formatPatterns", regexPatterns: "regex", abbreviatedTimeZoneDST: "timeZoneDST", abbreviatedTimeZoneStandard: "timeZoneStandard" }); shallowMerge(info, constructedInfo); buildInfo.timeZones(info); return info; }; $D.i18n = { __: function (key, lang) { return __(key, lang); }, currentLanguage: function () { return lang || "en-US"; }, setLanguage: function (code, force, cb) { var async = false; if (force || code === "en-US" || (!!Date.CultureStrings && !!Date.CultureStrings[code])) { lang = code; Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings.lang = code; Date.CultureInfo = new CultureInfo(); } else { if (!(!!Date.CultureStrings && !!Date.CultureStrings[code])) { if (typeof exports !== "undefined" && this.exports !== exports) { // we're in a Node enviroment, load it using require try { require("../i18n/" + code + ".js"); lang = code; Date.CultureStrings.lang = code; Date.CultureInfo = new CultureInfo(); } catch (e) { // var str = "The language for '" + code + "' could not be loaded by Node. It likely does not exist."; throw new Error("The DateJS IETF language tag '" + code + "' could not be loaded by Node. It likely does not exist."); } } else if (Date.Config && Date.Config.i18n) { // we know the location of the files, so lets load them async = true; loadI18nScript(code).done(function(){ lang = code; Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings.lang = code; Date.CultureInfo = new CultureInfo(); $D.Parsing.Normalizer.buildReplaceData(); // because this is async if ($D.Grammar) { $D.Grammar.buildGrammarFormats(); // so we can parse those strings... } if (cb) { setTimeout(cb,0); } }); } else { Date.console.error("The DateJS IETF language tag '" + code + "' is not available and has not been loaded."); return false; } } } $D.Parsing.Normalizer.buildReplaceData(); // rebuild normalizer strings if ($D.Grammar) { $D.Grammar.buildGrammarFormats(); // so we can parse those strings... } if (!async && cb) { setTimeout(cb,0); } }, getLoggedKeys: function () { return loggedKeys; }, updateCultureInfo: function () { Date.CultureInfo = new CultureInfo(); } }; $D.i18n.updateCultureInfo(); // run automatically }()); (function () { var $D = Date, $P = $D.prototype, p = function (s, l) { if (!l) { l = 2; } return ("000" + s).slice(l * -1); }; if (typeof window !== "undefined" && typeof window.console !== "undefined" && typeof window.console.log !== "undefined") { $D.console = console; // used only to raise non-critical errors if available } else { // set mock so we don't give errors. $D.console = { log: function(){}, error: function(){} }; } $D.Config = $D.Config || {}; $D.initOverloads = function() { /** * Overload of Date.now. Allows an alternate call for Date.now where it returns the * current Date as an object rather than just milliseconds since the Unix Epoch. * * Also provides an implementation of now() for browsers (IE<9) that don't have it. * * Backwards compatible so with work with either: * Date.now() [returns ms] * or * Date.now(true) [returns Date] */ if (!$D.now) { $D._now = function now() { return new Date().getTime(); }; } else if (!$D._now) { $D._now = $D.now; } $D.now = function (returnObj) { if (returnObj) { return $D.present(); } else { return $D._now(); } }; if ( !$P.toISOString ) { $P.toISOString = function() { return this.getUTCFullYear() + "-" + p(this.getUTCMonth() + 1) + "-" + p(this.getUTCDate()) + "T" + p(this.getUTCHours()) + ":" + p(this.getUTCMinutes()) + ":" + p(this.getUTCSeconds()) + "." + String( (this.getUTCMilliseconds()/1000).toFixed(3)).slice(2, 5) + "Z"; }; } // private if ( $P._toString === undefined ){ $P._toString = $P.toString; } }; $D.initOverloads(); /** * Gets a date that is set to the current date. The time is set to the start of the day (00:00 or 12:00 AM). * @return {Date} The current date. */ $D.today = function () { return new Date().clearTime(); }; /** * Gets a date that is set to the current date and time (same as new Date, but chainable) * @return {Date} The current date. */ $D.present = function () { return new Date(); }; /** * Compares the first date to the second date and returns an number indication of their relative values. * @param {Date} First Date object to compare [Required]. * @param {Date} Second Date object to compare to [Required]. * @return {Number} -1 = date1 is lessthan date2. 0 = values are equal. 1 = date1 is greaterthan date2. */ $D.compare = function (date1, date2) { if (isNaN(date1) || isNaN(date2)) { throw new Error(date1 + " - " + date2); } else if (date1 instanceof Date && date2 instanceof Date) { return (date1 < date2) ? -1 : (date1 > date2) ? 1 : 0; } else { throw new TypeError(date1 + " - " + date2); } }; /** * Compares the first Date object to the second Date object and returns true if they are equal. * @param {Date} First Date object to compare [Required] * @param {Date} Second Date object to compare to [Required] * @return {Boolean} true if dates are equal. false if they are not equal. */ $D.equals = function (date1, date2) { return (date1.compareTo(date2) === 0); }; /** * Gets the language appropriate day name when given the day number(0-6) * eg - 0 == Sunday * @return {String} The day name */ $D.getDayName = function (n) { return Date.CultureInfo.dayNames[n]; }; /** * Gets the day number (0-6) if given a CultureInfo specific string which is a valid dayName, abbreviatedDayName or shortestDayName (two char). * @param {String} The name of the day (eg. "Monday, "Mon", "tuesday", "tue", "We", "we"). * @return {Number} The day number */ $D.getDayNumberFromName = function (name) { var n = Date.CultureInfo.dayNames, m = Date.CultureInfo.abbreviatedDayNames, o = Date.CultureInfo.shortestDayNames, s = name.toLowerCase(); for (var i = 0; i < n.length; i++) { if (n[i].toLowerCase() === s || m[i].toLowerCase() === s || o[i].toLowerCase() === s) { return i; } } return -1; }; /** * Gets the month number (0-11) if given a Culture Info specific string which is a valid monthName or abbreviatedMonthName. * @param {String} The name of the month (eg. "February, "Feb", "october", "oct"). * @return {Number} The day number */ $D.getMonthNumberFromName = function (name) { var n = Date.CultureInfo.monthNames, m = Date.CultureInfo.abbreviatedMonthNames, s = name.toLowerCase(); for (var i = 0; i < n.length; i++) { if (n[i].toLowerCase() === s || m[i].toLowerCase() === s) { return i; } } return -1; }; /** * Gets the language appropriate month name when given the month number(0-11) * eg - 0 == January * @return {String} The month name */ $D.getMonthName = function (n) { return Date.CultureInfo.monthNames[n]; }; /** * Determines if the current date instance is within a LeapYear. * @param {Number} The year. * @return {Boolean} true if date is within a LeapYear, otherwise false. */ $D.isLeapYear = function (year) { return ((year % 4 === 0 && year % 100 !== 0) || year % 400 === 0); }; /** * Gets the number of days in the month, given a year and month value. Automatically corrects for LeapYear. * @param {Number} The year. * @param {Number} The month (0-11). * @return {Number} The number of days in the month. */ $D.getDaysInMonth = function (year, month) { if (!month && $D.validateMonth(year)) { month = year; year = Date.today().getFullYear(); } return [31, ($D.isLeapYear(year) ? 29 : 28), 31, 30, 31, 30, 31, 31, 30, 31, 30, 31][month]; }; $P.getDaysInMonth = function () { return $D.getDaysInMonth(this.getFullYear(), this.getMonth()); }; $D.getTimezoneAbbreviation = function (offset, dst) { var p, n = (dst || false) ? Date.CultureInfo.abbreviatedTimeZoneDST : Date.CultureInfo.abbreviatedTimeZoneStandard; for (p in n) { if (n.hasOwnProperty(p)) { if (n[p] === offset) { return p; } } } return null; }; $D.getTimezoneOffset = function (name, dst) { var i, a =[], z = Date.CultureInfo.timezones; if (!name) { name = (new Date()).getTimezone();} for (i = 0; i < z.length; i++) { if (z[i].name === name.toUpperCase()) { a.push(i); } } if (!z[a[0]]) { return null; } if (a.length === 1 || !dst) { return z[a[0]].offset; } else { for (i=0; i < a.length; i++) { if (z[a[i]].dst) { return z[a[i]].offset; } } } }; $D.getQuarter = function (d) { d = d || new Date(); // If no date supplied, use today var q = [1,2,3,4]; return q[Math.floor(d.getMonth() / 3)]; // ~~~ is a bitwise op. Faster than Math.floor }; $D.getDaysLeftInQuarter = function (d) { d = d || new Date(); var qEnd = new Date(d); qEnd.setMonth(qEnd.getMonth() + 3 - qEnd.getMonth() % 3, 0); return Math.floor((qEnd - d) / 8.64e7); }; // private var validate = function (n, min, max, name) { name = name ? name : "Object"; if (typeof n === "undefined") { return false; } else if (typeof n !== "number") { throw new TypeError(n + " is not a Number."); } else if (n < min || n > max) { // As failing validation is *not* an exceptional circumstance // lets not throw a RangeError Exception here. // It's semantically correct but it's not sensible. return false; } return true; }; /** * Validates the number is within an acceptable range for milliseconds [0-999]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateMillisecond = function (value) { return validate(value, 0, 999, "millisecond"); }; /** * Validates the number is within an acceptable range for seconds [0-59]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateSecond = function (value) { return validate(value, 0, 59, "second"); }; /** * Validates the number is within an acceptable range for minutes [0-59]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateMinute = function (value) { return validate(value, 0, 59, "minute"); }; /** * Validates the number is within an acceptable range for hours [0-23]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateHour = function (value) { return validate(value, 0, 23, "hour"); }; /** * Validates the number is within an acceptable range for the days in a month [0-MaxDaysInMonth]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateDay = function (value, year, month) { if (year === undefined || year === null || month === undefined || month === null) { return false;} return validate(value, 1, $D.getDaysInMonth(year, month), "day"); }; /** * Validates the number is within an acceptable range for months [0-11]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateWeek = function (value) { return validate(value, 0, 53, "week"); }; /** * Validates the number is within an acceptable range for months [0-11]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateMonth = function (value) { return validate(value, 0, 11, "month"); }; /** * Validates the number is within an acceptable range for years. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateYear = function (value) { /** * Per ECMAScript spec the range of times supported by Date objects is * exactly -100,000,000 days to +100,000,000 days measured relative to * midnight at the beginning of 01 January, 1970 UTC. * This gives a range of 8,640,000,000,000,000 milliseconds to either * side of 01 January, 1970 UTC. * * Earliest possible date: Tue, 20 Apr 271,822 B.C. 00:00:00 UTC * Latest possible date: Sat, 13 Sep 275,760 00:00:00 UTC */ return validate(value, -271822, 275760, "year"); }; $D.validateTimezone = function(value) { var timezones = {"ACDT":1,"ACST":1,"ACT":1,"ADT":1,"AEDT":1,"AEST":1,"AFT":1,"AKDT":1,"AKST":1,"AMST":1,"AMT":1,"ART":1,"AST":1,"AWDT":1,"AWST":1,"AZOST":1,"AZT":1,"BDT":1,"BIOT":1,"BIT":1,"BOT":1,"BRT":1,"BST":1,"BTT":1,"CAT":1,"CCT":1,"CDT":1,"CEDT":1,"CEST":1,"CET":1,"CHADT":1,"CHAST":1,"CHOT":1,"ChST":1,"CHUT":1,"CIST":1,"CIT":1,"CKT":1,"CLST":1,"CLT":1,"COST":1,"COT":1,"CST":1,"CT":1,"CVT":1,"CWST":1,"CXT":1,"DAVT":1,"DDUT":1,"DFT":1,"EASST":1,"EAST":1,"EAT":1,"ECT":1,"EDT":1,"EEDT":1,"EEST":1,"EET":1,"EGST":1,"EGT":1,"EIT":1,"EST":1,"FET":1,"FJT":1,"FKST":1,"FKT":1,"FNT":1,"GALT":1,"GAMT":1,"GET":1,"GFT":1,"GILT":1,"GIT":1,"GMT":1,"GST":1,"GYT":1,"HADT":1,"HAEC":1,"HAST":1,"HKT":1,"HMT":1,"HOVT":1,"HST":1,"ICT":1,"IDT":1,"IOT":1,"IRDT":1,"IRKT":1,"IRST":1,"IST":1,"JST":1,"KGT":1,"KOST":1,"KRAT":1,"KST":1,"LHST":1,"LINT":1,"MAGT":1,"MART":1,"MAWT":1,"MDT":1,"MET":1,"MEST":1,"MHT":1,"MIST":1,"MIT":1,"MMT":1,"MSK":1,"MST":1,"MUT":1,"MVT":1,"MYT":1,"NCT":1,"NDT":1,"NFT":1,"NPT":1,"NST":1,"NT":1,"NUT":1,"NZDT":1,"NZST":1,"OMST":1,"ORAT":1,"PDT":1,"PET":1,"PETT":1,"PGT":1,"PHOT":1,"PHT":1,"PKT":1,"PMDT":1,"PMST":1,"PONT":1,"PST":1,"PYST":1,"PYT":1,"RET":1,"ROTT":1,"SAKT":1,"SAMT":1,"SAST":1,"SBT":1,"SCT":1,"SGT":1,"SLST":1,"SRT":1,"SST":1,"SYOT":1,"TAHT":1,"THA":1,"TFT":1,"TJT":1,"TKT":1,"TLT":1,"TMT":1,"TOT":1,"TVT":1,"UCT":1,"ULAT":1,"UTC":1,"UYST":1,"UYT":1,"UZT":1,"VET":1,"VLAT":1,"VOLT":1,"VOST":1,"VUT":1,"WAKT":1,"WAST":1,"WAT":1,"WEDT":1,"WEST":1,"WET":1,"WST":1,"YAKT":1,"YEKT":1,"Z":1}; return (timezones[value] === 1); }; $D.validateTimezoneOffset= function(value) { // timezones go from +14hrs to -12hrs, the +X hours are negative offsets. return (value > -841 && value < 721); }; }()); (function () { var $D = Date, $P = $D.prototype, p = function (s, l) { if (!l) { l = 2; } return ("000" + s).slice(l * -1); }; var validateConfigObject = function (obj) { var result = {}, self = this, prop, testFunc; testFunc = function (prop, func, value) { if (prop === "day") { var month = (obj.month !== undefined) ? obj.month : self.getMonth(); var year = (obj.year !== undefined) ? obj.year : self.getFullYear(); return $D[func](value, year, month); } else { return $D[func](value); } }; for (prop in obj) { if (Object.prototype.hasOwnProperty.call(obj, prop)) { var func = "validate" + prop.charAt(0).toUpperCase() + prop.slice(1); if ($D[func] && obj[prop] !== null && testFunc(prop, func, obj[prop])) { result[prop] = obj[prop]; } } } return result; }; /** * Resets the time of this Date object to 12:00 AM (00:00), which is the start of the day. * @param {Boolean} .clone() this date instance before clearing Time * @return {Date} this */ $P.clearTime = function () { this.setHours(0); this.setMinutes(0); this.setSeconds(0); this.setMilliseconds(0); return this; }; /** * Resets the time of this Date object to the current time ('now'). * @return {Date} this */ $P.setTimeToNow = function () { var n = new Date(); this.setHours(n.getHours()); this.setMinutes(n.getMinutes()); this.setSeconds(n.getSeconds()); this.setMilliseconds(n.getMilliseconds()); return this; }; /** * Returns a new Date object that is an exact date and time copy of the original instance. * @return {Date} A new Date instance */ $P.clone = function () { return new Date(this.getTime()); }; /** * Compares this instance to a Date object and returns an number indication of their relative values. * @param {Date} Date object to compare [Required] * @return {Number} -1 = this is lessthan date. 0 = values are equal. 1 = this is greaterthan date. */ $P.compareTo = function (date) { return Date.compare(this, date); }; /** * Compares this instance to another Date object and returns true if they are equal. * @param {Date} Date object to compare. If no date to compare, new Date() [now] is used. * @return {Boolean} true if dates are equal. false if they are not equal. */ $P.equals = function (date) { return Date.equals(this, (date !== undefined ? date : new Date())); }; /** * Determines if this instance is between a range of two dates or equal to either the start or end dates. * @param {Date} Start of range [Required] * @param {Date} End of range [Required] * @return {Boolean} true is this is between or equal to the start and end dates, else false */ $P.between = function (start, end) { return this.getTime() >= start.getTime() && this.getTime() <= end.getTime(); }; /** * Determines if this date occurs after the date to compare to. * @param {Date} Date object to compare. If no date to compare, new Date() ("now") is used. * @return {Boolean} true if this date instance is greater than the date to compare to (or "now"), otherwise false. */ $P.isAfter = function (date) { return this.compareTo(date || new Date()) === 1; }; /** * Determines if this date occurs before the date to compare to. * @param {Date} Date object to compare. If no date to compare, new Date() ("now") is used. * @return {Boolean} true if this date instance is less than the date to compare to (or "now"). */ $P.isBefore = function (date) { return (this.compareTo(date || new Date()) === -1); }; /** * Determines if the current Date instance occurs today. * @return {Boolean} true if this date instance is 'today', otherwise false. */ /** * Determines if the current Date instance occurs on the same Date as the supplied 'date'. * If no 'date' to compare to is provided, the current Date instance is compared to 'today'. * @param {date} Date object to compare. If no date to compare, the current Date ("now") is used. * @return {Boolean} true if this Date instance occurs on the same Day as the supplied 'date'. */ $P.isToday = $P.isSameDay = function (date) { return this.clone().clearTime().equals((date || new Date()).clone().clearTime()); }; /** * Adds the specified number of milliseconds to this instance. * @param {Number} The number of milliseconds to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addMilliseconds = function (value) { if (!value) { return this; } this.setTime(this.getTime() + value * 1); return this; }; /** * Adds the specified number of seconds to this instance. * @param {Number} The number of seconds to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addSeconds = function (value) { if (!value) { return this; } return this.addMilliseconds(value * 1000); }; /** * Adds the specified number of seconds to this instance. * @param {Number} The number of seconds to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addMinutes = function (value) { if (!value) { return this; } return this.addMilliseconds(value * 60000); // 60*1000 }; /** * Adds the specified number of hours to this instance. * @param {Number} The number of hours to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addHours = function (value) { if (!value) { return this; } return this.addMilliseconds(value * 3600000); // 60*60*1000 }; /** * Adds the specified number of days to this instance. * @param {Number} The number of days to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addDays = function (value) { if (!value) { return this; } this.setDate(this.getDate() + value * 1); return this; }; /** * Adds the specified number of weekdays (ie - not sat or sun) to this instance. * @param {Number} The number of days to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addWeekdays = function (value) { if (!value) { return this; } var day = this.getDay(); var weeks = (Math.ceil(Math.abs(value)/7)); if (day === 0 || day === 6) { if (value > 0) { this.next().monday(); this.addDays(-1); day = this.getDay(); } } if (value < 0) { while (value < 0) { this.addDays(-1); day = this.getDay(); if (day !== 0 && day !== 6) { value++; } } return this; } else if (value > 5 || (6-day) <= value) { value = value + (weeks * 2); } return this.addDays(value); }; /** * Adds the specified number of weeks to this instance. * @param {Number} The number of weeks to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addWeeks = function (value) { if (!value) { return this; } return this.addDays(value * 7); }; /** * Adds the specified number of months to this instance. * @param {Number} The number of months to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addMonths = function (value) { if (!value) { return this; } var n = this.getDate(); this.setDate(1); this.setMonth(this.getMonth() + value * 1); this.setDate(Math.min(n, $D.getDaysInMonth(this.getFullYear(), this.getMonth()))); return this; }; $P.addQuarters = function (value) { if (!value) { return this; } // note this will take you to the same point in the quarter as you are now. // i.e. - if you are 15 days into the quarter you'll be 15 days into the resulting one. // bonus: this allows adding fractional quarters return this.addMonths(value * 3); }; /** * Adds the specified number of years to this instance. * @param {Number} The number of years to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addYears = function (value) { if (!value) { return this; } return this.addMonths(value * 12); }; /** * Adds (or subtracts) to the value of the years, months, weeks, days, hours, minutes, seconds, milliseconds of the date instance using given configuration object. Positive and Negative values allowed. * Example

	Date.today().add( { days: 1, months: 1 } )

	new Date().add( { years: -1 } )
	
* @param {Object} Configuration object containing attributes (months, days, etc.) * @return {Date} this */ $P.add = function (config) { if (typeof config === "number") { this._orient = config; return this; } var x = config; if (x.day) { // If we should be a different date than today (eg: for 'tomorrow -1d', etc). // Should only effect parsing, not direct usage (eg, Finish and FinishExact) if ((x.day - this.getDate()) !== 0) { this.setDate(x.day); } } if (x.milliseconds) { this.addMilliseconds(x.milliseconds); } if (x.seconds) { this.addSeconds(x.seconds); } if (x.minutes) { this.addMinutes(x.minutes); } if (x.hours) { this.addHours(x.hours); } if (x.weeks) { this.addWeeks(x.weeks); } if (x.months) { this.addMonths(x.months); } if (x.years) { this.addYears(x.years); } if (x.days) { this.addDays(x.days); } return this; }; /** * Get the week number. Week one (1) is the week which contains the first Thursday of the year. Monday is considered the first day of the week. * The .getWeek() function does NOT convert the date to UTC. The local datetime is used. * Please use .getISOWeek() to get the week of the UTC converted date. * @return {Number} 1 to 53 */ $P.getWeek = function (utc) { // Create a copy of this date object var self, target = new Date(this.valueOf()); if (utc) { target.addMinutes(target.getTimezoneOffset()); self = target.clone(); } else { self = this; } // ISO week date weeks start on monday // so correct the day number var dayNr = (self.getDay() + 6) % 7; // ISO 8601 states that week 1 is the week // with the first thursday of that year. // Set the target date to the thursday in the target week target.setDate(target.getDate() - dayNr + 3); // Store the millisecond value of the target date var firstThursday = target.valueOf(); // Set the target to the first thursday of the year // First set the target to january first target.setMonth(0, 1); // Not a thursday? Correct the date to the next thursday if (target.getDay() !== 4) { target.setMonth(0, 1 + ((4 - target.getDay()) + 7) % 7); } // The weeknumber is the number of weeks between the // first thursday of the year and the thursday in the target week return 1 + Math.ceil((firstThursday - target) / 604800000); // 604800000 = 7 * 24 * 3600 * 1000 }; /** * Get the ISO 8601 week number. Week one ("01") is the week which contains the first Thursday of the year. Monday is considered the first day of the week. * The .getISOWeek() function does convert the date to it's UTC value. Please use .getWeek() to get the week of the local date. * @return {String} "01" to "53" */ $P.getISOWeek = function () { return p(this.getWeek(true)); }; /** * Moves the date to Monday of the week set. Week one (1) is the week which contains the first Thursday of the year. * @param {Number} A Number (1 to 53) that represents the week of the year. * @return {Date} this */ $P.setWeek = function (n) { if ((n - this.getWeek()) === 0) { if (this.getDay() !== 1) { return this.moveToDayOfWeek(1, (this.getDay() > 1 ? -1 : 1)); } else { return this; } } else { return this.moveToDayOfWeek(1, (this.getDay() > 1 ? -1 : 1)).addWeeks(n - this.getWeek()); } }; $P.setQuarter = function (qtr) { var month = Math.abs(((qtr-1) * 3) + 1); return this.setMonth(month, 1); }; $P.getQuarter = function () { return Date.getQuarter(this); }; $P.getDaysLeftInQuarter = function () { return Date.getDaysLeftInQuarter(this); }; /** * Moves the date to the next n'th occurrence of the dayOfWeek starting from the beginning of the month. The number (-1) is a magic number and will return the last occurrence of the dayOfWeek in the month. * @param {Number} The dayOfWeek to move to * @param {Number} The n'th occurrence to move to. Use (-1) to return the last occurrence in the month * @return {Date} this */ $P.moveToNthOccurrence = function (dayOfWeek, occurrence) { if (dayOfWeek === "Weekday") { if (occurrence > 0) { this.moveToFirstDayOfMonth(); if (this.is().weekday()) { occurrence -= 1; } } else if (occurrence < 0) { this.moveToLastDayOfMonth(); if (this.is().weekday()) { occurrence += 1; } } else { return this; } return this.addWeekdays(occurrence); } var shift = 0; if (occurrence > 0) { shift = occurrence - 1; } else if (occurrence === -1) { this.moveToLastDayOfMonth(); if (this.getDay() !== dayOfWeek) { this.moveToDayOfWeek(dayOfWeek, -1); } return this; } return this.moveToFirstDayOfMonth().addDays(-1).moveToDayOfWeek(dayOfWeek, +1).addWeeks(shift); }; var moveToN = function (getFunc, addFunc, nVal) { return function (value, orient) { var diff = (value - this[getFunc]() + nVal * (orient || +1)) % nVal; return this[addFunc]((diff === 0) ? diff += nVal * (orient || +1) : diff); }; }; /** * Move to the next or last dayOfWeek based on the orient value. * @param {Number} The dayOfWeek to move to * @param {Number} Forward (+1) or Back (-1). Defaults to +1. [Optional] * @return {Date} this */ $P.moveToDayOfWeek = moveToN("getDay", "addDays", 7); /** * Move to the next or last month based on the orient value. * @param {Number} The month to move to. 0 = January, 11 = December * @param {Number} Forward (+1) or Back (-1). Defaults to +1. [Optional] * @return {Date} this */ $P.moveToMonth = moveToN("getMonth", "addMonths", 12); /** * Get the Ordinate of the current day ("th", "st", "rd"). * @return {String} */ $P.getOrdinate = function () { var num = this.getDate(); return ord(num); }; /** * Get the Ordinal day (numeric day number) of the year, adjusted for leap year. * @return {Number} 1 through 365 (366 in leap years) */ $P.getOrdinalNumber = function () { return Math.ceil((this.clone().clearTime() - new Date(this.getFullYear(), 0, 1)) / 86400000) + 1; }; /** * Get the time zone abbreviation of the current date. * @return {String} The abbreviated time zone name (e.g. "EST") */ $P.getTimezone = function () { return $D.getTimezoneAbbreviation(this.getUTCOffset(), this.isDaylightSavingTime()); }; $P.setTimezoneOffset = function (offset) { var here = this.getTimezoneOffset(), there = Number(offset) * -6 / 10; return (there || there === 0) ? this.addMinutes(there - here) : this; }; $P.setTimezone = function (offset) { return this.setTimezoneOffset($D.getTimezoneOffset(offset)); }; /** * Indicates whether Daylight Saving Time is observed in the current time zone. * @return {Boolean} true|false */ $P.hasDaylightSavingTime = function () { return (Date.today().set({month: 0, day: 1}).getTimezoneOffset() !== Date.today().set({month: 6, day: 1}).getTimezoneOffset()); }; /** * Indicates whether this Date instance is within the Daylight Saving Time range for the current time zone. * @return {Boolean} true|false */ $P.isDaylightSavingTime = function () { return Date.today().set({month: 0, day: 1}).getTimezoneOffset() !== this.getTimezoneOffset(); }; /** * Get the offset from UTC of the current date. * @return {String} The 4-character offset string prefixed with + or - (e.g. "-0500") */ $P.getUTCOffset = function (offset) { var n = (offset || this.getTimezoneOffset()) * -10 / 6, r; if (n < 0) { r = (n - 10000).toString(); return r.charAt(0) + r.substr(2); } else { r = (n + 10000).toString(); return "+" + r.substr(1); } }; /** * Returns the number of milliseconds between this date and date. * @param {Date} Defaults to now * @return {Number} The diff in milliseconds */ $P.getElapsed = function (date) { return (date || new Date()) - this; }; /** * Set the value of year, month, day, hour, minute, second, millisecond of date instance using given configuration object. * Example

	Date.today().set( { day: 20, month: 1 } )

	new Date().set( { millisecond: 0 } )
	
* * @param {Object} Configuration object containing attributes (month, day, etc.) * @return {Date} this */ $P.set = function (config) { config = validateConfigObject.call(this, config); var key; for (key in config) { if (Object.prototype.hasOwnProperty.call(config, key)) { var name = key.charAt(0).toUpperCase() + key.slice(1); var addFunc, getFunc; if (key !== "week" && key !== "month" && key !== "timezone" && key !== "timezoneOffset") { name += "s"; } addFunc = "add" + name; getFunc = "get" + name; if (key === "month") { addFunc = addFunc + "s"; } else if (key === "year"){ getFunc = "getFullYear"; } if (key !== "day" && key !== "timezone" && key !== "timezoneOffset" && key !== "week" && key !== "hour") { this[addFunc](config[key] - this[getFunc]()); } else if ( key === "timezone"|| key === "timezoneOffset" || key === "week" || key === "hour") { this["set"+name](config[key]); } } } // day has to go last because you can't validate the day without first knowing the month if (config.day) { this.addDays(config.day - this.getDate()); } return this; }; /** * Moves the date to the first day of the month. * @return {Date} this */ $P.moveToFirstDayOfMonth = function () { return this.set({ day: 1 }); }; /** * Moves the date to the last day of the month. * @return {Date} this */ $P.moveToLastDayOfMonth = function () { return this.set({ day: $D.getDaysInMonth(this.getFullYear(), this.getMonth())}); }; /** * Converts the value of the current Date object to its equivalent string representation. * Format Specifiers * CUSTOM DATE AND TIME FORMAT STRINGS * Format Description Example * ------ --------------------------------------------------------------------------- ----------------------- * s The seconds of the minute between 0-59. "0" to "59" * ss The seconds of the minute with leading zero if required. "00" to "59" * * m The minute of the hour between 0-59. "0" or "59" * mm The minute of the hour with leading zero if required. "00" or "59" * * h The hour of the day between 1-12. "1" to "12" * hh The hour of the day with leading zero if required. "01" to "12" * * H The hour of the day between 0-23. "0" to "23" * HH The hour of the day with leading zero if required. "00" to "23" * * d The day of the month between 1 and 31. "1" to "31" * dd The day of the month with leading zero if required. "01" to "31" * ddd Abbreviated day name. Date.CultureInfo.abbreviatedDayNames. "Mon" to "Sun" * dddd The full day name. Date.CultureInfo.dayNames. "Monday" to "Sunday" * * M The month of the year between 1-12. "1" to "12" * MM The month of the year with leading zero if required. "01" to "12" * MMM Abbreviated month name. Date.CultureInfo.abbreviatedMonthNames. "Jan" to "Dec" * MMMM The full month name. Date.CultureInfo.monthNames. "January" to "December" * * yy The year as a two-digit number. "99" or "08" * yyyy The full four digit year. "1999" or "2008" * * t Displays the first character of the A.M./P.M. designator. "A" or "P" * Date.CultureInfo.amDesignator or Date.CultureInfo.pmDesignator * tt Displays the A.M./P.M. designator. "AM" or "PM" * Date.CultureInfo.amDesignator or Date.CultureInfo.pmDesignator * * S The ordinal suffix ("st, "nd", "rd" or "th") of the current day. "st, "nd", "rd" or "th" * * STANDARD DATE AND TIME FORMAT STRINGS * Format Description Example *------ --------------------------------------------------------------------------- ----------------------- * d The CultureInfo shortDate Format Pattern "M/d/yyyy" * D The CultureInfo longDate Format Pattern "dddd, MMMM dd, yyyy" * F The CultureInfo fullDateTime Format Pattern "dddd, MMMM dd, yyyy h:mm:ss tt" * m The CultureInfo monthDay Format Pattern "MMMM dd" * r The CultureInfo rfc1123 Format Pattern "ddd, dd MMM yyyy HH:mm:ss GMT" * s The CultureInfo sortableDateTime Format Pattern "yyyy-MM-ddTHH:mm:ss" * t The CultureInfo shortTime Format Pattern "h:mm tt" * T The CultureInfo longTime Format Pattern "h:mm:ss tt" * u The CultureInfo universalSortableDateTime Format Pattern "yyyy-MM-dd HH:mm:ssZ" * y The CultureInfo yearMonth Format Pattern "MMMM, yyyy" * * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @return {String} A string representation of the current Date object. */ var ord = function (n) { switch (n * 1) { case 1: case 21: case 31: return "st"; case 2: case 22: return "nd"; case 3: case 23: return "rd"; default: return "th"; } }; var parseStandardFormats = function (format) { var y, c = Date.CultureInfo.formatPatterns; switch (format) { case "d": return this.toString(c.shortDate); case "D": return this.toString(c.longDate); case "F": return this.toString(c.fullDateTime); case "m": return this.toString(c.monthDay); case "r": case "R": y = this.clone().addMinutes(this.getTimezoneOffset()); return y.toString(c.rfc1123) + " GMT"; case "s": return this.toString(c.sortableDateTime); case "t": return this.toString(c.shortTime); case "T": return this.toString(c.longTime); case "u": y = this.clone().addMinutes(this.getTimezoneOffset()); return y.toString(c.universalSortableDateTime); case "y": return this.toString(c.yearMonth); default: return false; } }; var parseFormatStringsClosure = function (context) { return function (m) { if (m.charAt(0) === "\\") { return m.replace("\\", ""); } switch (m) { case "hh": return p(context.getHours() < 13 ? (context.getHours() === 0 ? 12 : context.getHours()) : (context.getHours() - 12)); case "h": return context.getHours() < 13 ? (context.getHours() === 0 ? 12 : context.getHours()) : (context.getHours() - 12); case "HH": return p(context.getHours()); case "H": return context.getHours(); case "mm": return p(context.getMinutes()); case "m": return context.getMinutes(); case "ss": return p(context.getSeconds()); case "s": return context.getSeconds(); case "yyyy": return p(context.getFullYear(), 4); case "yy": return p(context.getFullYear()); case "y": return context.getFullYear(); case "E": case "dddd": return Date.CultureInfo.dayNames[context.getDay()]; case "ddd": return Date.CultureInfo.abbreviatedDayNames[context.getDay()]; case "dd": return p(context.getDate()); case "d": return context.getDate(); case "MMMM": return Date.CultureInfo.monthNames[context.getMonth()]; case "MMM": return Date.CultureInfo.abbreviatedMonthNames[context.getMonth()]; case "MM": return p((context.getMonth() + 1)); case "M": return context.getMonth() + 1; case "t": return context.getHours() < 12 ? Date.CultureInfo.amDesignator.substring(0, 1) : Date.CultureInfo.pmDesignator.substring(0, 1); case "tt": return context.getHours() < 12 ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator; case "S": return ord(context.getDate()); case "W": return context.getWeek(); case "WW": return context.getISOWeek(); case "Q": return "Q" + context.getQuarter(); case "q": return String(context.getQuarter()); case "z": return context.getTimezone(); case "Z": case "X": return Date.getTimezoneOffset(context.getTimezone()); case "ZZ": // Timezone offset in seconds return context.getTimezoneOffset() * -60; case "u": return context.getDay(); case "L": return ($D.isLeapYear(context.getFullYear())) ? 1 : 0; case "B": // Swatch Internet Time (.beats) return "@"+((context.getUTCSeconds() + (context.getUTCMinutes()*60) + ((context.getUTCHours()+1)*3600))/86.4); default: return m; } }; }; $P.toString = function (format, ignoreStandards) { // Standard Date and Time Format Strings. Formats pulled from CultureInfo file and // may vary by culture. if (!ignoreStandards && format && format.length === 1) { output = parseStandardFormats.call(this, format); if (output) { return output; } } var parseFormatStrings = parseFormatStringsClosure(this); return format ? format.replace(/((\\)?(dd?d?d?|MM?M?M?|yy?y?y?|hh?|HH?|mm?|ss?|tt?|S|q|Q|WW?W?W?)(?![^\[]*\]))/g, parseFormatStrings).replace(/\[|\]/g, "") : this._toString(); }; }()); /************************************************************* * SugarPak - Domain Specific Language - Syntactical Sugar * *************************************************************/ (function () { var $D = Date, $P = $D.prototype, $N = Number.prototype; // private $P._orient = +1; // private $P._nth = null; // private $P._is = false; // private $P._same = false; // private $P._isSecond = false; // private $N._dateElement = "days"; /** * Moves the date to the next instance of a date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.today().next().friday();
	Date.today().next().fri();
	Date.today().next().march();
	Date.today().next().mar();
	Date.today().next().week();
	
* * @return {Date} date */ $P.next = function () { this._move = true; this._orient = +1; return this; }; /** * Creates a new Date (Date.today()) and moves the date to the next instance of the date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.next().friday();
	Date.next().fri();
	Date.next().march();
	Date.next().mar();
	Date.next().week();
	
* * @return {Date} date */ $D.next = function () { return $D.today().next(); }; /** * Moves the date to the previous instance of a date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.today().last().friday();
	Date.today().last().fri();
	Date.today().last().march();
	Date.today().last().mar();
	Date.today().last().week();
	
* * @return {Date} date */ $P.last = $P.prev = $P.previous = function () { this._move = true; this._orient = -1; return this; }; /** * Creates a new Date (Date.today()) and moves the date to the previous instance of the date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.last().friday();
	Date.last().fri();
	Date.previous().march();
	Date.prev().mar();
	Date.last().week();
	
* * @return {Date} date */ $D.last = $D.prev = $D.previous = function () { return $D.today().last(); }; /** * Performs a equality check when followed by either a month name, day name or .weekday() function. * Example

	Date.today().is().friday(); // true|false
	Date.today().is().fri();
	Date.today().is().march();
	Date.today().is().mar();
	
* * @return {Boolean} true|false */ $P.is = function () { this._is = true; return this; }; /** * Determines if two date objects occur on/in exactly the same instance of the subsequent date part function. * The function .same() must be followed by a date part function (example: .day(), .month(), .year(), etc). * * An optional Date can be passed in the date part function. If now date is passed as a parameter, 'Now' is used. * * The following example demonstrates how to determine if two dates fall on the exact same day. * * Example

	var d1 = Date.today(); // today at 00:00
	var d2 = new Date();   // exactly now.

	// Do they occur on the same day?
	d1.same().day(d2); // true
	
	// Do they occur on the same hour?
	d1.same().hour(d2); // false, unless d2 hour is '00' (midnight).
	
	// What if it's the same day, but one year apart?
	var nextYear = Date.today().add(1).year();

	d1.same().day(nextYear); // false, because the dates must occur on the exact same day. 
	
* * Scenario: Determine if a given date occurs during some week period 2 months from now. * * Example

	var future = Date.today().add(2).months();
	return someDate.same().week(future); // true|false;
	
* * @return {Boolean} true|false */ $P.same = function () { this._same = true; this._isSecond = false; return this; }; /** * Determines if the current date/time occurs during Today. Must be preceded by the .is() function. * Example

	someDate.is().today();    // true|false
	new Date().is().today();  // true
	Date.today().is().today();// true
	Date.today().add(-1).day().is().today(); // false
	
* * @return {Boolean} true|false */ $P.today = function () { return this.same().day(); }; /** * Determines if the current date is a weekday. This function must be preceded by the .is() function. * Example

	Date.today().is().weekday(); // true|false
	
* * @return {Boolean} true|false */ $P.weekday = function () { if (this._nth) { return df("Weekday").call(this); } if (this._move) { return this.addWeekdays(this._orient); } if (this._is) { this._is = false; return (!this.is().sat() && !this.is().sun()); } return false; }; /** * Determines if the current date is on the weekend. This function must be preceded by the .is() function. * Example

	Date.today().is().weekend(); // true|false
	
* * @return {Boolean} true|false */ $P.weekend = function () { if (this._is) { this._is = false; return (this.is().sat() || this.is().sun()); } return false; }; /** * Sets the Time of the current Date instance. A string "6:15 pm" or config object {hour:18, minute:15} are accepted. * Example

	// Set time to 6:15pm with a String
	Date.today().at("6:15pm");

	// Set time to 6:15pm with a config object
	Date.today().at({hour:18, minute:15});
	
* * @return {Date} date */ $P.at = function (time) { return (typeof time === "string") ? $D.parse(this.toString("d") + " " + time) : this.set(time); }; /** * Creates a new Date() and adds this (Number) to the date based on the preceding date element function (eg. second|minute|hour|day|month|year). * Example

	// Undeclared Numbers must be wrapped with parentheses. Requirment of JavaScript.
	(3).days().fromNow();
	(6).months().fromNow();

	// Declared Number variables do not require parentheses. 
	var n = 6;
	n.months().fromNow();
	
* * @return {Date} A new Date instance */ $N.fromNow = $N.after = function (date) { var c = {}; c[this._dateElement] = this; return ((!date) ? new Date() : date.clone()).add(c); }; /** * Creates a new Date() and subtract this (Number) from the date based on the preceding date element function (eg. second|minute|hour|day|month|year). * Example

	// Undeclared Numbers must be wrapped with parentheses. Requirment of JavaScript.
	(3).days().ago();
	(6).months().ago();

	// Declared Number variables do not require parentheses. 
	var n = 6;
	n.months().ago();
	
* * @return {Date} A new Date instance */ $N.ago = $N.before = function (date) { var c = {}, s = (this._dateElement[this._dateElement.length-1] !== "s") ? this._dateElement + "s" : this._dateElement; c[s] = this * -1; return ((!date) ? new Date() : date.clone()).add(c); }; // Do NOT modify the following string tokens. These tokens are used to build dynamic functions. // All culture-specific strings can be found in the CultureInfo files. var dx = ("sunday monday tuesday wednesday thursday friday saturday").split(/\s/), mx = ("january february march april may june july august september october november december").split(/\s/), px = ("Millisecond Second Minute Hour Day Week Month Year Quarter Weekday").split(/\s/), pxf = ("Milliseconds Seconds Minutes Hours Date Week Month FullYear Quarter").split(/\s/), nth = ("final first second third fourth fifth").split(/\s/), de; /** * Returns an object literal of all the date parts. * Example

	var o = new Date().toObject();
	
	// { year: 2008, month: 4, week: 20, day: 13, hour: 18, minute: 9, second: 32, millisecond: 812 }
	
	// The object properties can be referenced directly from the object.
	
	alert(o.day);  // alerts "13"
	alert(o.year); // alerts "2008"
	
* * @return {Date} An object literal representing the original date object. */ $P.toObject = function () { var o = {}; for (var i = 0; i < px.length; i++) { if (this["get" + pxf[i]]) { o[px[i].toLowerCase()] = this["get" + pxf[i]](); } } return o; }; /** * Returns a date created from an object literal. Ignores the .week property if set in the config. * Example

	var o = new Date().toObject();
	
	return Date.fromObject(o); // will return the same date. 

	var o2 = {month: 1, day: 20, hour: 18}; // birthday party!
	Date.fromObject(o2);
	
* * @return {Date} An object literal representing the original date object. */ $D.fromObject = function(config) { config.week = null; return Date.today().set(config); }; // Create day name functions and abbreviated day name functions (eg. monday(), friday(), fri()). var df = function (n) { return function () { if (this._is) { this._is = false; return this.getDay() === n; } if (this._move) { this._move = null; } if (this._nth !== null) { // If the .second() function was called earlier, remove the _orient // from the date, and then continue. // This is required because 'second' can be used in two different context. // // Example // // Date.today().add(1).second(); // Date.march().second().monday(); // // Things get crazy with the following... // Date.march().add(1).second().second().monday(); // but it works!! // if (this._isSecond) { this.addSeconds(this._orient * -1); } // make sure we reset _isSecond this._isSecond = false; var ntemp = this._nth; this._nth = null; var temp = this.clone().moveToLastDayOfMonth(); this.moveToNthOccurrence(n, ntemp); if (this > temp) { throw new RangeError($D.getDayName(n) + " does not occur " + ntemp + " times in the month of " + $D.getMonthName(temp.getMonth()) + " " + temp.getFullYear() + "."); } return this; } return this.moveToDayOfWeek(n, this._orient); }; }; var sdf = function (n) { return function () { var t = $D.today(), shift = n - t.getDay(); if (n === 0 && Date.CultureInfo.firstDayOfWeek === 1 && t.getDay() !== 0) { shift = shift + 7; } return t.addDays(shift); }; }; // Create month name functions and abbreviated month name functions (eg. january(), march(), mar()). var month_instance_functions = function (n) { return function () { if (this._is) { this._is = false; return this.getMonth() === n; } return this.moveToMonth(n, this._orient); }; }; var month_static_functions = function (n) { return function () { return $D.today().set({ month: n, day: 1 }); }; }; var processTerms = function (names, staticFunc, instanceFunc) { for (var i = 0; i < names.length; i++) { // Create constant static Name variables. $D[names[i].toUpperCase()] = $D[names[i].toUpperCase().substring(0, 3)] = i; // Create Name functions. $D[names[i]] = $D[names[i].substring(0, 3)] = staticFunc(i); // Create Name instance functions. $P[names[i]] = $P[names[i].substring(0, 3)] = instanceFunc(i); } }; processTerms(dx, sdf, df); processTerms(mx, month_static_functions, month_instance_functions); // Create date element functions and plural date element functions used with Date (eg. day(), days(), months()). var ef = function (j) { return function () { // if the .second() function was called earlier, the _orient // has alread been added. Just return this and reset _isSecond. if (this._isSecond) { this._isSecond = false; return this; } if (this._same) { this._same = this._is = false; var o1 = this.toObject(), o2 = (arguments[0] || new Date()).toObject(), v = "", k = j.toLowerCase(); // the substr trick with -1 doesn't work in IE8 or less k = (k[k.length-1] === "s") ? k.substring(0,k.length-1) : k; for (var m = (px.length - 1); m > -1; m--) { v = px[m].toLowerCase(); if (o1[v] !== o2[v]) { return false; } if (k === v) { break; } } return true; } if (j.substring(j.length - 1) !== "s") { j += "s"; } if (this._move) { this._move = null; } return this["add" + j](this._orient); }; }; var nf = function (n) { return function () { this._dateElement = n; return this; }; }; for (var k = 0; k < px.length; k++) { de = px[k].toLowerCase(); if(de !== "weekday") { // Create date element functions and plural date element functions used with Date (eg. day(), days(), months()). $P[de] = $P[de + "s"] = ef(px[k]); // Create date element functions and plural date element functions used with Number (eg. day(), days(), months()). $N[de] = $N[de + "s"] = nf(de + "s"); } } $P._ss = ef("Second"); var nthfn = function (n) { return function (dayOfWeek) { if (this._same) { return this._ss(arguments[0]); } if (dayOfWeek || dayOfWeek === 0) { return this.moveToNthOccurrence(dayOfWeek, n); } this._nth = n; // if the operator is 'second' add the _orient, then deal with it later... if (n === 2 && (dayOfWeek === undefined || dayOfWeek === null)) { this._isSecond = true; return this.addSeconds(this._orient); } return this; }; }; for (var l = 0; l < nth.length; l++) { $P[nth[l]] = (l === 0) ? nthfn(-1) : nthfn(l); } }()); (function () { "use strict"; Date.Parsing = { Exception: function (s) { this.message = "Parse error at '" + s.substring(0, 10) + " ...'"; } }; var $P = Date.Parsing; var dayOffsets = { standard: [0,31,59,90,120,151,181,212,243,273,304,334], leap: [0,31,60,91,121,152,182,213,244,274,305,335] }; $P.isLeapYear = function(year) { return ((year % 4 === 0) && (year % 100 !== 0)) || (year % 400 === 0); }; var utils = { multiReplace : function (str, hash ) { var key; for (key in hash) { if (Object.prototype.hasOwnProperty.call(hash, key)) { var regex; if (typeof hash[key] === "function") { } else { regex = (hash[key] instanceof RegExp) ? hash[key] : new RegExp(hash[key], "g"); } str = str.replace(regex, key); } } return str; }, getDayOfYearFromWeek : function (obj) { var d, jan4, offset; obj.weekDay = (!obj.weekDay && obj.weekDay !== 0) ? 1 : obj.weekDay; d = new Date(obj.year, 0, 4); jan4 = d.getDay() === 0 ? 7 : d.getDay(); // JS is 0 indexed on Sunday. offset = jan4+3; obj.dayOfYear = ((obj.week * 7) + (obj.weekDay === 0 ? 7 : obj.weekDay))-offset; return obj; }, getDayOfYear : function (obj, dayOffset) { if (!obj.dayOfYear) { obj = utils.getDayOfYearFromWeek(obj); } for (var i=0;i <= dayOffset.length;i++) { if (obj.dayOfYear < dayOffset[i] || i === dayOffset.length) { obj.day = obj.day ? obj.day : (obj.dayOfYear - dayOffset[i-1]); break; } else { obj.month = i; } } return obj; }, adjustForTimeZone : function (obj, date) { var offset; if (obj.zone.toUpperCase() === "Z" || (obj.zone_hours === 0 && obj.zone_minutes === 0)) { // it's UTC/GML so work out the current timeszone offset offset = -date.getTimezoneOffset(); } else { offset = (obj.zone_hours*60) + (obj.zone_minutes || 0); if (obj.zone_sign === "+") { offset *= -1; } offset -= date.getTimezoneOffset(); } date.setMinutes(date.getMinutes()+offset); return date; }, setDefaults : function (obj) { obj.year = obj.year || Date.today().getFullYear(); obj.hours = obj.hours || 0; obj.minutes = obj.minutes || 0; obj.seconds = obj.seconds || 0; obj.milliseconds = obj.milliseconds || 0; if (!(!obj.month && (obj.week || obj.dayOfYear))) { // if we have a month, or if we don't but don't have the day calculation data obj.month = obj.month || 0; obj.day = obj.day || 1; } return obj; }, dataNum: function (data, mod, explict, postProcess) { var dataNum = data*1; if (mod) { if (postProcess) { return data ? mod(data)*1 : data; } else { return data ? mod(dataNum) : data; } } else if (!explict){ return data ? dataNum : data; } else { return (data && typeof data !== "undefined") ? dataNum : data; } }, timeDataProcess: function (obj) { var timeObj = {}; for (var x in obj.data) { if (obj.data.hasOwnProperty(x)) { timeObj[x] = obj.ignore[x] ? obj.data[x] : utils.dataNum(obj.data[x], obj.mods[x], obj.explict[x], obj.postProcess[x]); } } if (obj.data.secmins) { obj.data.secmins = obj.data.secmins.replace(",", ".") * 60; if (!timeObj.minutes) { timeObj.minutes = obj.data.secmins; } else if (!timeObj.seconds) { timeObj.seconds = obj.data.secmins; } delete obj.secmins; } return timeObj; }, buildTimeObjectFromData: function (data) { var time = utils.timeDataProcess({ data: { year : data[1], month : data[5], day : data[7], week : data[8], dayOfYear : data[10], hours : data[15], zone_hours : data[23], zone_minutes : data[24], zone : data[21], zone_sign : data[22], weekDay : data[9], minutes: data[16], seconds: data[19], milliseconds: data[20], secmins: data[18] }, mods: { month: function(data) { return data-1; }, weekDay: function (data) { data = Math.abs(data); return (data === 7 ? 0 : data); }, minutes: function (data) { return data.replace(":",""); }, seconds: function (data) { return Math.floor( (data.replace(":","").replace(",","."))*1 ); }, milliseconds: function (data) { return (data.replace(",",".")*1000); } }, postProcess: { minutes: true, seconds: true, milliseconds: true }, explict: { zone_hours: true, zone_minutes: true }, ignore: { zone: true, zone_sign: true, secmins: true } }); return time; }, addToHash: function (hash, keys, data) { keys = keys; data = data; var len = keys.length; for (var i = 0; i < len; i++) { hash[keys[i]] = data[i]; } return hash; }, combineRegex: function (r1, r2) { return new RegExp("(("+r1.source+")\\s("+r2.source+"))"); }, getDateNthString: function(add, last, inc){ if (add) { return Date.today().addDays(inc).toString("d"); } else if (last) { return Date.today().last()[inc]().toString("d"); } }, buildRegexData: function (array) { var arr = []; var len = array.length; for (var i=0; i < len; i++) { if (Object.prototype.toString.call(array[i]) === '[object Array]') { // oldIE compat version of Array.isArray arr.push(this.combineRegex(array[i][0], array[i][1])); } else { arr.push(array[i]); } } return arr; } }; $P.processTimeObject = function (obj) { var date, dayOffset; utils.setDefaults(obj); dayOffset = ($P.isLeapYear(obj.year)) ? dayOffsets.leap : dayOffsets.standard; if (!obj.month && (obj.week || obj.dayOfYear)) { utils.getDayOfYear(obj, dayOffset); } else { obj.dayOfYear = dayOffset[obj.month] + obj.day; } date = new Date(obj.year, obj.month, obj.day, obj.hours, obj.minutes, obj.seconds, obj.milliseconds); if (obj.zone) { utils.adjustForTimeZone(obj, date); // adjust (and calculate) for timezone } return date; }; $P.ISO = { regex : /^([\+-]?\d{4}(?!\d{2}\b))((-?)((0[1-9]|1[0-2])(\3([12]\d|0[1-9]|3[01]))?|W([0-4]\d|5[0-3])(-?[1-7])?|(00[1-9]|0[1-9]\d|[12]\d{2}|3([0-5]\d|6[1-6])))([T\s]((([01]\d|2[0-4])((:?)[0-5]\d)?|24\:?00)([\.,]\d+(?!:))?)?(\17[0-5]\d([\.,]\d+)?)?\s?([zZ]|([\+-])([01]\d|2[0-3]):?([0-5]\d)?)?)?)?$/, parse : function (s) { var time, data = s.match(this.regex); if (!data || !data.length) { return null; } time = utils.buildTimeObjectFromData(data); if (!time.year || (!time.year && (!time.month && !time.day) && (!time.week && !time.dayOfYear)) ) { return null; } return $P.processTimeObject(time); } }; $P.Numeric = { isNumeric: function (e){return!isNaN(parseFloat(e))&&isFinite(e);}, regex: /\b([0-1]?[0-9])([0-3]?[0-9])([0-2]?[0-9]?[0-9][0-9])\b/i, parse: function (s) { var data, i, time = {}, order = Date.CultureInfo.dateElementOrder.split(""); if (!(this.isNumeric(s)) || // if it's non-numeric OR (s[0] === "+" && s[0] === "-")) { // It's an arithmatic string (eg +/-1000) return null; } if (s.length < 5 && s.indexOf(".") < 0 && s.indexOf("/") < 0) { // assume it's just a year. time.year = s; return $P.processTimeObject(time); } data = s.match(this.regex); if (!data || !data.length) { return null; } for (i=0; i < order.length; i++) { switch(order[i]) { case "d": time.day = data[i+1]; break; case "m": time.month = (data[i+1]-1); break; case "y": time.year = data[i+1]; break; } } return $P.processTimeObject(time); } }; $P.Normalizer = { regexData: function () { var $R = Date.CultureInfo.regexPatterns; return utils.buildRegexData([ $R.tomorrow, $R.yesterday, [$R.past, $R.mon], [$R.past, $R.tue], [$R.past, $R.wed], [$R.past, $R.thu], [$R.past, $R.fri], [$R.past, $R.sat], [$R.past, $R.sun] ]); }, basicReplaceHash : function() { var $R = Date.CultureInfo.regexPatterns; return { "January": $R.jan.source, "February": $R.feb, "March": $R.mar, "April": $R.apr, "May": $R.may, "June": $R.jun, "July": $R.jul, "August": $R.aug, "September": $R.sep, "October": $R.oct, "November": $R.nov, "December": $R.dec, "": /\bat\b/gi, " ": /\s{2,}/, "am": $R.inTheMorning, "9am": $R.thisMorning, "pm": $R.inTheEvening, "7pm":$R.thisEvening }; }, keys : function(){ return [ utils.getDateNthString(true, false, 1), // tomorrow utils.getDateNthString(true, false, -1), // yesterday utils.getDateNthString(false, true, "monday"), //last mon utils.getDateNthString(false, true, "tuesday"), //last tues utils.getDateNthString(false, true, "wednesday"), //last wed utils.getDateNthString(false, true, "thursday"), //last thurs utils.getDateNthString(false, true, "friday"), //last fri utils.getDateNthString(false, true, "saturday"), //last sat utils.getDateNthString(false, true, "sunday") //last sun ]; }, buildRegexFunctions: function () { var $R = Date.CultureInfo.regexPatterns; var __ = Date.i18n.__; var tomorrowRE = new RegExp("(\\b\\d\\d?("+__("AM")+"|"+__("PM")+")? )("+$R.tomorrow.source.slice(1)+")", "i"); // adapted tomorrow regex for AM PM relative dates var todayRE = new RegExp($R.today.source + "(?!\\s*([+-]))\\b"); // today, but excludes the math operators (eg "today + 2h") this.replaceFuncs = [ [todayRE, function (full) { return (full.length > 1) ? Date.today().toString("d") : full; }], [tomorrowRE, function(full, m1) { var t = Date.today().addDays(1).toString("d"); return (t + " " + m1); }], [$R.amThisMorning, function(str, am){return am;}], [$R.pmThisEvening, function(str, pm){return pm;}] ]; }, buildReplaceData: function () { this.buildRegexFunctions(); this.replaceHash = utils.addToHash(this.basicReplaceHash(), this.keys(), this.regexData()); }, stringReplaceFuncs: function (s) { for (var i=0; i < this.replaceFuncs.length; i++) { s = s.replace(this.replaceFuncs[i][0], this.replaceFuncs[i][1]); } return s; }, parse: function (s) { s = this.stringReplaceFuncs(s); s = utils.multiReplace(s, this.replaceHash); try { var n = s.split(/([\s\-\.\,\/\x27]+)/); if (n.length === 3 && $P.Numeric.isNumeric(n[0]) && $P.Numeric.isNumeric(n[2]) && (n[2].length >= 4)) { // ok, so we're dealing with x/year. But that's not a full date. // This fixes wonky dateElementOrder parsing when set to dmy order. if (Date.CultureInfo.dateElementOrder[0] === "d") { s = "1/" + n[0] + "/" + n[2]; // set to 1st of month and normalize the seperator } } } catch (e) {} return s; } }; $P.Normalizer.buildReplaceData(); }()); (function () { var $P = Date.Parsing; var _ = $P.Operators = { // // Tokenizers // rtoken: function (r) { // regex token return function (s) { var mx = s.match(r); if (mx) { return ([ mx[0], s.substring(mx[0].length) ]); } else { throw new $P.Exception(s); } }; }, token: function () { // whitespace-eating token return function (s) { return _.rtoken(new RegExp("^\\s*" + s + "\\s*"))(s); }; }, stoken: function (s) { // string token return _.rtoken(new RegExp("^" + s)); }, // Atomic Operators until: function (p) { return function (s) { var qx = [], rx = null; while (s.length) { try { rx = p.call(this, s); } catch (e) { qx.push(rx[0]); s = rx[1]; continue; } break; } return [ qx, s ]; }; }, many: function (p) { return function (s) { var rx = [], r = null; while (s.length) { try { r = p.call(this, s); } catch (e) { return [ rx, s ]; } rx.push(r[0]); s = r[1]; } return [ rx, s ]; }; }, // generator operators -- see below optional: function (p) { return function (s) { var r = null; try { r = p.call(this, s); } catch (e) { return [ null, s ]; } return [ r[0], r[1] ]; }; }, not: function (p) { return function (s) { try { p.call(this, s); } catch (e) { return [null, s]; } throw new $P.Exception(s); }; }, ignore: function (p) { return p ? function (s) { var r = null; r = p.call(this, s); return [null, r[1]]; } : null; }, product: function () { var px = arguments[0], qx = Array.prototype.slice.call(arguments, 1), rx = []; for (var i = 0 ; i < px.length ; i++) { rx.push(_.each(px[i], qx)); } return rx; }, cache: function (rule) { var cache = {}, cache_length = 0, cache_keys = [], CACHE_MAX = Date.Config.CACHE_MAX || 100000, r = null; var cacheCheck = function () { if (cache_length === CACHE_MAX) { // kill several keys, don't want to have to do this all the time... for (var i=0; i < 10; i++) { var key = cache_keys.shift(); if (key) { delete cache[key]; cache_length--; } } } }; return function (s) { cacheCheck(); try { r = cache[s] = (cache[s] || rule.call(this, s)); } catch (e) { r = cache[s] = e; } cache_length++; cache_keys.push(s); if (r instanceof $P.Exception) { throw r; } else { return r; } }; }, // vector operators -- see below any: function () { var px = arguments; return function (s) { var r = null; for (var i = 0; i < px.length; i++) { if (px[i] == null) { continue; } try { r = (px[i].call(this, s)); } catch (e) { r = null; } if (r) { return r; } } throw new $P.Exception(s); }; }, each: function () { var px = arguments; return function (s) { var rx = [], r = null; for (var i = 0; i < px.length ; i++) { if (px[i] == null) { continue; } try { r = (px[i].call(this, s)); } catch (e) { throw new $P.Exception(s); } rx.push(r[0]); s = r[1]; } return [ rx, s]; }; }, all: function () { var px = arguments, _ = _; return _.each(_.optional(px)); }, // delimited operators sequence: function (px, d, c) { d = d || _.rtoken(/^\s*/); c = c || null; if (px.length === 1) { return px[0]; } return function (s) { var r = null, q = null; var rx = []; for (var i = 0; i < px.length ; i++) { try { r = px[i].call(this, s); } catch (e) { break; } rx.push(r[0]); try { q = d.call(this, r[1]); } catch (ex) { q = null; break; } s = q[1]; } if (!r) { throw new $P.Exception(s); } if (q) { throw new $P.Exception(q[1]); } if (c) { try { r = c.call(this, r[1]); } catch (ey) { throw new $P.Exception(r[1]); } } return [ rx, (r?r[1]:s) ]; }; }, // // Composite Operators // between: function (d1, p, d2) { d2 = d2 || d1; var _fn = _.each(_.ignore(d1), p, _.ignore(d2)); return function (s) { var rx = _fn.call(this, s); return [[rx[0][0], r[0][2]], rx[1]]; }; }, list: function (p, d, c) { d = d || _.rtoken(/^\s*/); c = c || null; return (p instanceof Array ? _.each(_.product(p.slice(0, -1), _.ignore(d)), p.slice(-1), _.ignore(c)) : _.each(_.many(_.each(p, _.ignore(d))), px, _.ignore(c))); }, set: function (px, d, c) { d = d || _.rtoken(/^\s*/); c = c || null; return function (s) { // r is the current match, best the current 'best' match // which means it parsed the most amount of input var r = null, p = null, q = null, rx = null, best = [[], s], last = false; // go through the rules in the given set for (var i = 0; i < px.length ; i++) { // last is a flag indicating whether this must be the last element // if there is only 1 element, then it MUST be the last one q = null; p = null; r = null; last = (px.length === 1); // first, we try simply to match the current pattern // if not, try the next pattern try { r = px[i].call(this, s); } catch (e) { continue; } // since we are matching against a set of elements, the first // thing to do is to add r[0] to matched elements rx = [[r[0]], r[1]]; // if we matched and there is still input to parse and // we don't already know this is the last element, // we're going to next check for the delimiter ... // if there's none, or if there's no input left to parse // than this must be the last element after all ... if (r[1].length > 0 && ! last) { try { q = d.call(this, r[1]); } catch (ex) { last = true; } } else { last = true; } // if we parsed the delimiter and now there's no more input, // that means we shouldn't have parsed the delimiter at all // so don't update r and mark this as the last element ... if (!last && q[1].length === 0) { last = true; } // so, if this isn't the last element, we're going to see if // we can get any more matches from the remaining (unmatched) // elements ... if (!last) { // build a list of the remaining rules we can match against, // i.e., all but the one we just matched against var qx = []; for (var j = 0; j < px.length ; j++) { if (i !== j) { qx.push(px[j]); } } // now invoke recursively set with the remaining input // note that we don't include the closing delimiter ... // we'll check for that ourselves at the end p = _.set(qx, d).call(this, q[1]); // if we got a non-empty set as a result ... // (otw rx already contains everything we want to match) if (p[0].length > 0) { // update current result, which is stored in rx ... // basically, pick up the remaining text from p[1] // and concat the result from p[0] so that we don't // get endless nesting ... rx[0] = rx[0].concat(p[0]); rx[1] = p[1]; } } // at this point, rx either contains the last matched element // or the entire matched set that starts with this element. // now we just check to see if this variation is better than // our best so far, in terms of how much of the input is parsed if (rx[1].length < best[1].length) { best = rx; } // if we've parsed all the input, then we're finished if (best[1].length === 0) { break; } } // so now we've either gone through all the patterns trying them // as the initial match; or we found one that parsed the entire // input string ... // if best has no matches, just return empty set ... if (best[0].length === 0) { return best; } // if a closing delimiter is provided, then we have to check it also if (c) { // we try this even if there is no remaining input because the pattern // may well be optional or match empty input ... try { q = c.call(this, best[1]); } catch (ey) { throw new $P.Exception(best[1]); } // it parsed ... be sure to update the best match remaining input best[1] = q[1]; } // if we're here, either there was no closing delimiter or we parsed it // so now we have the best match; just return it! return best; }; }, forward: function (gr, fname) { return function (s) { return gr[fname].call(this, s); }; }, // // Translation Operators // replace: function (rule, repl) { return function (s) { var r = rule.call(this, s); return [repl, r[1]]; }; }, process: function (rule, fn) { return function (s) { var r = rule.call(this, s); return [fn.call(this, r[0]), r[1]]; }; }, min: function (min, rule) { return function (s) { var rx = rule.call(this, s); if (rx[0].length < min) { throw new $P.Exception(s); } return rx; }; } }; // Generator Operators And Vector Operators // Generators are operators that have a signature of F(R) => R, // taking a given rule and returning another rule, such as // ignore, which parses a given rule and throws away the result. // Vector operators are those that have a signature of F(R1,R2,...) => R, // take a list of rules and returning a new rule, such as each. // Generator operators are converted (via the following _generator // function) into functions that can also take a list or array of rules // and return an array of new rules as though the function had been // called on each rule in turn (which is what actually happens). // This allows generators to be used with vector operators more easily. // Example: // each(ignore(foo, bar)) instead of each(ignore(foo), ignore(bar)) // This also turns generators into vector operators, which allows // constructs like: // not(cache(foo, bar)) var _generator = function (op) { function gen() { var args = null, rx = [], px, i; if (arguments.length > 1) { args = Array.prototype.slice.call(arguments); } else if (arguments[0] instanceof Array) { args = arguments[0]; } if (args) { px = args.shift(); if (px.length > 0) { args.unshift(px[i]); rx.push(op.apply(null, args)); args.shift(); return rx; } } else { return op.apply(null, arguments); } } return gen; }; var gx = "optional not ignore cache".split(/\s/); for (var i = 0 ; i < gx.length ; i++) { _[gx[i]] = _generator(_[gx[i]]); } var _vector = function (op) { return function () { if (arguments[0] instanceof Array) { return op.apply(null, arguments[0]); } else { return op.apply(null, arguments); } }; }; var vx = "each any all".split(/\s/); for (var j = 0 ; j < vx.length ; j++) { _[vx[j]] = _vector(_[vx[j]]); } }()); (function () { var $D = Date; var flattenAndCompact = function (ax) { var rx = []; for (var i = 0; i < ax.length; i++) { if (ax[i] instanceof Array) { rx = rx.concat(flattenAndCompact(ax[i])); } else { if (ax[i]) { rx.push(ax[i]); } } } return rx; }; var parseMeridian = function () { if (this.meridian && (this.hour || this.hour === 0)) { if (this.meridian === "a" && this.hour > 11 && Date.Config.strict24hr){ throw "Invalid hour and meridian combination"; } else if (this.meridian === "p" && this.hour < 12 && Date.Config.strict24hr){ throw "Invalid hour and meridian combination"; } else if (this.meridian === "p" && this.hour < 12) { this.hour = this.hour + 12; } else if (this.meridian === "a" && this.hour === 12) { this.hour = 0; } } }; var setDefaults = function () { var now = new Date(); if ((this.hour || this.minute) && (!this.month && !this.year && !this.day)) { this.day = now.getDate(); } if (!this.year) { this.year = now.getFullYear(); } if (!this.month && this.month !== 0) { this.month = now.getMonth(); } if (!this.day) { this.day = 1; } if (!this.hour) { this.hour = 0; } if (!this.minute) { this.minute = 0; } if (!this.second) { this.second = 0; } if (!this.millisecond) { this.millisecond = 0; } }; var finishUtils = { getToday: function () { if (this.now || "hour minute second".indexOf(this.unit) !== -1) { return new Date(); } else { return $D.today(); } }, setDaysFromWeekday: function (today, orient){ var gap; orient = orient || 1; this.unit = "day"; gap = ($D.getDayNumberFromName(this.weekday) - today.getDay()); this.days = gap ? ((gap + (orient * 7)) % 7) : (orient * 7); return this; }, setMonthsFromMonth: function (today, orient) { var gap; orient = orient || 1; this.unit = "month"; gap = (this.month - today.getMonth()); this.months = gap ? ((gap + (orient * 12)) % 12) : (orient * 12); this.month = null; return this; }, setDMYFromWeekday: function () { var d = Date[this.weekday](); this.day = d.getDate(); if (!this.month) { this.month = d.getMonth(); } this.year = d.getFullYear(); return this; }, setUnitValue: function (orient) { if (!this.value && this.operator && this.operator !== null && this[this.unit + "s"] && this[this.unit + "s"] !== null) { this[this.unit + "s"] = this[this.unit + "s"] + ((this.operator === "add") ? 1 : -1) + (this.value||0) * orient; } else if (this[this.unit + "s"] == null || this.operator != null) { if (!this.value) { this.value = 1; } this[this.unit + "s"] = this.value * orient; } }, generateDateFromWeeks: function () { var weekday = (this.weekday !== undefined) ? this.weekday : "today"; var d = Date[weekday]().addWeeks(this.weeks); if (this.now) { d.setTimeToNow(); } return d; } }; $D.Translator = { hour: function (s) { return function () { this.hour = Number(s); }; }, minute: function (s) { return function () { this.minute = Number(s); }; }, second: function (s) { return function () { this.second = Number(s); }; }, /* for ss.s format */ secondAndMillisecond: function (s) { return function () { var mx = s.match(/^([0-5][0-9])\.([0-9]{1,3})/); this.second = Number(mx[1]); this.millisecond = Number(mx[2]); }; }, meridian: function (s) { return function () { this.meridian = s.slice(0, 1).toLowerCase(); }; }, timezone: function (s) { return function () { var n = s.replace(/[^\d\+\-]/g, ""); if (n.length) { this.timezoneOffset = Number(n); } else { this.timezone = s.toLowerCase(); } }; }, day: function (x) { var s = x[0]; return function () { this.day = Number(s.match(/\d+/)[0]); if (this.day < 1) { throw "invalid day"; } }; }, month: function (s) { return function () { this.month = (s.length === 3) ? "jan feb mar apr may jun jul aug sep oct nov dec".indexOf(s)/4 : Number(s) - 1; if (this.month < 0) { throw "invalid month"; } }; }, year: function (s) { return function () { var n = Number(s); this.year = ((s.length > 2) ? n : (n + (((n + 2000) < Date.CultureInfo.twoDigitYearMax) ? 2000 : 1900))); }; }, rday: function (s) { return function () { switch (s) { case "yesterday": this.days = -1; break; case "tomorrow": this.days = 1; break; case "today": this.days = 0; break; case "now": this.days = 0; this.now = true; break; } }; }, finishExact: function (x) { var d; x = (x instanceof Array) ? x : [x]; for (var i = 0 ; i < x.length ; i++) { if (x[i]) { x[i].call(this); } } setDefaults.call(this); parseMeridian.call(this); if (this.day > $D.getDaysInMonth(this.year, this.month)) { throw new RangeError(this.day + " is not a valid value for days."); } d = new Date(this.year, this.month, this.day, this.hour, this.minute, this.second, this.millisecond); if (this.year < 100) { d.setFullYear(this.year); // means years less that 100 are process correctly. JS will parse it otherwise as 1900-1999. } if (this.timezone) { d.set({ timezone: this.timezone }); } else if (this.timezoneOffset) { d.set({ timezoneOffset: this.timezoneOffset }); } return d; }, finish: function (x) { var today, expression, orient, temp; x = (x instanceof Array) ? flattenAndCompact(x) : [ x ]; if (x.length === 0) { return null; } for (var i = 0 ; i < x.length ; i++) { if (typeof x[i] === "function") { x[i].call(this); } } if (this.now && !this.unit && !this.operator) { return new Date(); } else { today = finishUtils.getToday.call(this); } expression = !!(this.days && this.days !== null || this.orient || this.operator); orient = ((this.orient === "past" || this.operator === "subtract") ? -1 : 1); if (this.month && this.unit === "week") { this.value = this.month + 1; delete this.month; delete this.day; } if ((this.month || this.month === 0) && "year day hour minute second".indexOf(this.unit) !== -1) { if (!this.value) { this.value = this.month + 1; } this.month = null; expression = true; } if (!expression && this.weekday && !this.day && !this.days) { finishUtils.setDMYFromWeekday.call(this); } if (expression && this.weekday && this.unit !== "month" && this.unit !== "week") { finishUtils.setDaysFromWeekday.call(this, today, orient); } if (this.weekday && this.unit !== "week" && !this.day && !this.days) { temp = Date[this.weekday](); this.day = temp.getDate(); if (temp.getMonth() !== today.getMonth()) { this.month = temp.getMonth(); } } if (this.month && this.unit === "day" && this.operator) { if (!this.value) { this.value = (this.month + 1); } this.month = null; } if (this.value != null && this.month != null && this.year != null) { this.day = this.value * 1; } if (this.month && !this.day && this.value) { today.set({ day: this.value * 1 }); if (!expression) { this.day = this.value * 1; } } if (!this.month && this.value && this.unit === "month" && !this.now) { this.month = this.value; expression = true; } if (expression && (this.month || this.month === 0) && this.unit !== "year") { finishUtils.setMonthsFromMonth.call(this, today, orient); } if (!this.unit) { this.unit = "day"; } finishUtils.setUnitValue.call(this, orient); parseMeridian.call(this); if ((this.month || this.month === 0) && !this.day) { this.day = 1; } if (!this.orient && !this.operator && this.unit === "week" && this.value && !this.day && !this.month) { return Date.today().setWeek(this.value); } if (this.unit === "week" && this.weeks && !this.day && !this.month) { return finishUtils.generateDateFromWeeks.call(this); } if (expression && this.timezone && this.day && this.days) { this.day = this.days; } if (expression){ today.add(this); } else { today.set(this); } if (this.timezone) { this.timezone = this.timezone.toUpperCase(); var offset = $D.getTimezoneOffset(this.timezone); var timezone; if (today.hasDaylightSavingTime()) { // lets check that we're being sane with timezone setting timezone = $D.getTimezoneAbbreviation(offset, today.isDaylightSavingTime()); if (timezone !== this.timezone) { // bugger, we're in a place where things like EST vs EDT matters. if (today.isDaylightSavingTime()) { today.addHours(-1); } else { today.addHours(1); } } } today.setTimezoneOffset(offset); } return today; } }; }()); (function () { var $D = Date; $D.Grammar = {}; var _ = $D.Parsing.Operators, g = $D.Grammar, t = $D.Translator, _fn; // Allow rolling up into general purpose rules _fn = function () { return _.each(_.any.apply(null, arguments), _.not(g.ctoken2("timeContext"))); }; g.datePartDelimiter = _.rtoken(/^([\s\-\.\,\/\x27]+)/); g.timePartDelimiter = _.stoken(":"); g.whiteSpace = _.rtoken(/^\s*/); g.generalDelimiter = _.rtoken(/^(([\s\,]|at|@|on)+)/); var _C = {}; g.ctoken = function (keys) { var fn = _C[keys]; if (! fn) { var c = Date.CultureInfo.regexPatterns; var kx = keys.split(/\s+/), px = []; for (var i = 0; i < kx.length ; i++) { px.push(_.replace(_.rtoken(c[kx[i]]), kx[i])); } fn = _C[keys] = _.any.apply(null, px); } return fn; }; g.ctoken2 = function (key) { return _.rtoken(Date.CultureInfo.regexPatterns[key]); }; var cacheProcessRtoken = function (key, token, type, eachToken) { if (eachToken) { g[key] = _.cache(_.process(_.each(_.rtoken(token),_.optional(g.ctoken2(eachToken))), type)); } else { g[key] = _.cache(_.process(_.rtoken(token), type)); } }; var cacheProcessCtoken = function (token, type) { return _.cache(_.process(g.ctoken2(token), type)); }; var _F = {}; //function cache var _get = function (f) { _F[f] = (_F[f] || g.format(f)[0]); return _F[f]; }; g.allformats = function (fx) { var rx = []; if (fx instanceof Array) { for (var i = 0; i < fx.length; i++) { rx.push(_get(fx[i])); } } else { rx.push(_get(fx)); } return rx; }; g.formats = function (fx) { if (fx instanceof Array) { var rx = []; for (var i = 0 ; i < fx.length ; i++) { rx.push(_get(fx[i])); } return _.any.apply(null, rx); } else { return _get(fx); } }; var grammarFormats = { timeFormats: function(){ var i, RTokenKeys = [ "h", "hh", "H", "HH", "m", "mm", "s", "ss", "ss.s", "z", "zz" ], RToken = [ /^(0[0-9]|1[0-2]|[1-9])/, /^(0[0-9]|1[0-2])/, /^([0-1][0-9]|2[0-3]|[0-9])/, /^([0-1][0-9]|2[0-3])/, /^([0-5][0-9]|[0-9])/, /^[0-5][0-9]/, /^([0-5][0-9]|[0-9])/, /^[0-5][0-9]/, /^[0-5][0-9]\.[0-9]{1,3}/, /^((\+|\-)\s*\d\d\d\d)|((\+|\-)\d\d\:?\d\d)/, /^((\+|\-)\s*\d\d\d\d)|((\+|\-)\d\d\:?\d\d)/ ], tokens = [ t.hour, t.hour, t.hour, t.hour, t.minute, t.minute, t.second, t.second, t.secondAndMillisecond, t.timezone, t.timezone ]; for (i=0; i < RTokenKeys.length; i++) { cacheProcessRtoken(RTokenKeys[i], RToken[i], tokens[i]); } g.hms = _.cache(_.sequence([g.H, g.m, g.s], g.timePartDelimiter)); g.t = cacheProcessCtoken("shortMeridian", t.meridian); g.tt = cacheProcessCtoken("longMeridian", t.meridian); g.zzz = cacheProcessCtoken("timezone", t.timezone); g.timeSuffix = _.each(_.ignore(g.whiteSpace), _.set([ g.tt, g.zzz ])); g.time = _.each(_.optional(_.ignore(_.stoken("T"))), g.hms, g.timeSuffix); }, dateFormats: function () { // pre-loaded rules for different date part order preferences var _setfn = function () { return _.set(arguments, g.datePartDelimiter); }; var i, RTokenKeys = [ "d", "dd", "M", "MM", "y", "yy", "yyy", "yyyy" ], RToken = [ /^([0-2]\d|3[0-1]|\d)/, /^([0-2]\d|3[0-1])/, /^(1[0-2]|0\d|\d)/, /^(1[0-2]|0\d)/, /^(\d+)/, /^(\d\d)/, /^(\d\d?\d?\d?)/, /^(\d\d\d\d)/ ], tokens = [ t.day, t.day, t.month, t.month, t.year, t.year, t.year, t.year ], eachToken = [ "ordinalSuffix", "ordinalSuffix" ]; for (i=0; i < RTokenKeys.length; i++) { cacheProcessRtoken(RTokenKeys[i], RToken[i], tokens[i], eachToken[i]); } g.MMM = g.MMMM = _.cache(_.process(g.ctoken("jan feb mar apr may jun jul aug sep oct nov dec"), t.month)); g.ddd = g.dddd = _.cache(_.process(g.ctoken("sun mon tue wed thu fri sat"), function (s) { return function () { this.weekday = s; }; } )); g.day = _fn(g.d, g.dd); g.month = _fn(g.M, g.MMM); g.year = _fn(g.yyyy, g.yy); g.mdy = _setfn(g.ddd, g.month, g.day, g.year); g.ymd = _setfn(g.ddd, g.year, g.month, g.day); g.dmy = _setfn(g.ddd, g.day, g.month, g.year); g.date = function (s) { return ((g[Date.CultureInfo.dateElementOrder] || g.mdy).call(this, s)); }; }, relative: function () { // relative date / time expressions g.orientation = _.process(g.ctoken("past future"), function (s) { return function () { this.orient = s; }; } ); g.operator = _.process(g.ctoken("add subtract"), function (s) { return function () { this.operator = s; }; } ); g.rday = _.process(g.ctoken("yesterday tomorrow today now"), t.rday); g.unit = _.process(g.ctoken("second minute hour day week month year"), function (s) { return function () { this.unit = s; }; } ); } }; g.buildGrammarFormats = function () { // these need to be rebuilt every time the language changes. _C = {}; grammarFormats.timeFormats(); grammarFormats.dateFormats(); grammarFormats.relative(); g.value = _.process(_.rtoken(/^([-+]?\d+)?(st|nd|rd|th)?/), function (s) { return function () { this.value = s.replace(/\D/g, ""); }; } ); g.expression = _.set([g.rday, g.operator, g.value, g.unit, g.orientation, g.ddd, g.MMM ]); g.format = _.process(_.many( _.any( // translate format specifiers into grammar rules _.process( _.rtoken(/^(dd?d?d?(?!e)|MM?M?M?|yy?y?y?|hh?|HH?|mm?|ss?|tt?|zz?z?)/), function (fmt) { if (g[fmt]) { return g[fmt]; } else { throw $D.Parsing.Exception(fmt); } } ), // translate separator tokens into token rules _.process(_.rtoken(/^[^dMyhHmstz]+/), // all legal separators function (s) { return _.ignore(_.stoken(s)); } ) ) ), // construct the parser ... function (rules) { return _.process(_.each.apply(null, rules), t.finishExact); } ); // starting rule for general purpose grammar g._start = _.process(_.set([ g.date, g.time, g.expression ], g.generalDelimiter, g.whiteSpace), t.finish); }; g.buildGrammarFormats(); // parsing date format specifiers - ex: "h:m:s tt" // this little guy will generate a custom parser based // on the format string, ex: g.format("h:m:s tt") // check for these formats first g._formats = g.formats([ "\"yyyy-MM-ddTHH:mm:ssZ\"", "yyyy-MM-ddTHH:mm:ss.sz", "yyyy-MM-ddTHH:mm:ssZ", "yyyy-MM-ddTHH:mm:ssz", "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-ddTHH:mmZ", "yyyy-MM-ddTHH:mmz", "yyyy-MM-ddTHH:mm", "ddd, MMM dd, yyyy H:mm:ss tt", "ddd MMM d yyyy HH:mm:ss zzz", "MMddyyyy", "ddMMyyyy", "Mddyyyy", "ddMyyyy", "Mdyyyy", "dMyyyy", "yyyy", "Mdyy", "dMyy", "d" ]); // real starting rule: tries selected formats first, // then general purpose rule g.start = function (s) { try { var r = g._formats.call({}, s); if (r[1].length === 0) { return r; } } catch (e) {} return g._start.call({}, s); }; }()); (function () { var $D = Date; /** * @desc Converts the specified string value into its JavaScript Date equivalent using CultureInfo specific format information. * * Example

	///////////
	// Dates //
	///////////

	// 15-Oct-2004
	var d1 = Date.parse("10/15/2004");

	// 15-Oct-2004
	var d1 = Date.parse("15-Oct-2004");

	// 15-Oct-2004
	var d1 = Date.parse("2004.10.15");

	//Fri Oct 15, 2004
	var d1 = Date.parse("Fri Oct 15, 2004");

	///////////
	// Times //
	///////////

	// Today at 10 PM.
	var d1 = Date.parse("10 PM");

	// Today at 10:30 PM.
	var d1 = Date.parse("10:30 P.M.");

	// Today at 6 AM.
	var d1 = Date.parse("06am");

	/////////////////////
	// Dates and Times //
	/////////////////////

	// 8-July-2004 @ 10:30 PM
	var d1 = Date.parse("July 8th, 2004, 10:30 PM");

	// 1-July-2004 @ 10:30 PM
	var d1 = Date.parse("2004-07-01T22:30:00");

	////////////////////
	// Relative Dates //
	////////////////////

	// Returns today's date. The string "today" is culture specific.
	var d1 = Date.parse("today");

	// Returns yesterday's date. The string "yesterday" is culture specific.
	var d1 = Date.parse("yesterday");

	// Returns the date of the next thursday.
	var d1 = Date.parse("Next thursday");

	// Returns the date of the most previous monday.
	var d1 = Date.parse("last monday");

	// Returns today's day + one year.
	var d1 = Date.parse("next year");

	///////////////
	// Date Math //
	///////////////

	// Today + 2 days
	var d1 = Date.parse("t+2");

	// Today + 2 days
	var d1 = Date.parse("today + 2 days");

	// Today + 3 months
	var d1 = Date.parse("t+3m");

	// Today - 1 year
	var d1 = Date.parse("today - 1 year");

	// Today - 1 year
	var d1 = Date.parse("t-1y"); 


	/////////////////////////////
	// Partial Dates and Times //
	/////////////////////////////

	// July 15th of this year.
	var d1 = Date.parse("July 15");

	// 15th day of current day and year.
	var d1 = Date.parse("15");

	// July 1st of current year at 10pm.
	var d1 = Date.parse("7/1 10pm");
	
* * @param {String} The string value to convert into a Date object [Required] * @return {Date} A Date object or null if the string cannot be converted into a Date. */ var parseUtils = { removeOrds: function (s) { ords = s.match(/\b(\d+)(?:st|nd|rd|th)\b/); // find ordinal matches s = ((ords && ords.length === 2) ? s.replace(ords[0], ords[1]) : s); return s; }, grammarParser: function (s) { var r = null; try { r = $D.Grammar.start.call({}, s.replace(/^\s*(\S*(\s+\S+)*)\s*$/, "$1")); } catch (e) { return null; } return ((r[1].length === 0) ? r[0] : null); }, nativeFallback: function(s) { var t; try { // ok we haven't parsed it, last ditch attempt with the built-in parser. t = Date._parse(s); return (t || t === 0) ? new Date(t) : null; } catch (e) { return null; } } }; function parse (s) { var d; if (!s) { return null; } if (s instanceof Date) { return s.clone(); } if (s.length >= 4 && s.charAt(0) !== "0" && s.charAt(0) !== "+"&& s.charAt(0) !== "-") { // ie: 2004 will pass, 0800 won't. // Start with specific formats d = $D.Parsing.ISO.parse(s) || $D.Parsing.Numeric.parse(s); } if (d instanceof Date && !isNaN(d.getTime())) { return d; } else { // find ordinal dates (1st, 3rd, 8th, etc and remove them as they cause parsing issues) s = $D.Parsing.Normalizer.parse(parseUtils.removeOrds(s)); d = parseUtils.grammarParser(s); if (d !== null) { return d; } else { return parseUtils.nativeFallback(s); } } } if (!$D._parse) { $D._parse = $D.parse; } $D.parse = parse; Date.getParseFunction = function (fx) { var fns = Date.Grammar.allformats(fx); return function (s) { var r = null; for (var i = 0; i < fns.length; i++) { try { r = fns[i].call({}, s); } catch (e) { continue; } if (r[1].length === 0) { return r[0]; } } return null; }; }; /** * Converts the specified string value into its JavaScript Date equivalent using the specified format {String} or formats {Array} and the CultureInfo specific format information. * The format of the string value must match one of the supplied formats exactly. * * Example

	// 15-Oct-2004
	var d1 = Date.parseExact("10/15/2004", "M/d/yyyy");

	// 15-Oct-2004
	var d1 = Date.parse("15-Oct-2004", "M-ddd-yyyy");

	// 15-Oct-2004
	var d1 = Date.parse("2004.10.15", "yyyy.MM.dd");

	// Multiple formats
	var d1 = Date.parseExact("10/15/2004", ["M/d/yyyy", "MMMM d, yyyy"]);
	
* * @param {String} The string value to convert into a Date object [Required]. * @param {Object} The expected format {String} or an array of expected formats {Array} of the date string [Required]. * @return {Date} A Date object or null if the string cannot be converted into a Date. */ $D.parseExact = function (s, fx) { return $D.getParseFunction(fx)(s); }; }()); (function () { var $D = Date, $P = $D.prototype, // $C = $D.CultureInfo, // not used atm p = function (s, l) { if (!l) { l = 2; } return ("000" + s).slice(l * -1); }; /** * Converts a PHP format string to Java/.NET format string. * A PHP format string can be used with ._format or .format. * A Java/.NET format string can be used with .toString(). * The .parseExact function will only accept a Java/.NET format string * * Example * var f1 = "%m/%d/%y" * var f2 = Date.normalizeFormat(f1); // "MM/dd/yy" * * new Date().format(f1); // "04/13/08" * new Date()._format(f1); // "04/13/08" * new Date().toString(f2); // "04/13/08" * * var date = Date.parseExact("04/13/08", f2); // Sun Apr 13 2008 * * @param {String} A PHP format string consisting of one or more format spcifiers. * @return {String} The PHP format converted to a Java/.NET format string. */ var normalizerSubstitutions = { "d" : "dd", "%d": "dd", "D" : "ddd", "%a": "ddd", "j" : "dddd", "l" : "dddd", "%A": "dddd", "S" : "S", "F" : "MMMM", "%B": "MMMM", "m" : "MM", "%m": "MM", "M" : "MMM", "%b": "MMM", "%h": "MMM", "n" : "M", "Y" : "yyyy", "%Y": "yyyy", "y" : "yy", "%y": "yy", "g" : "h", "%I": "h", "G" : "H", "h" : "hh", "H" : "HH", "%H": "HH", "i" : "mm", "%M": "mm", "s" : "ss", "%S": "ss", "%r": "hh:mm tt", "%R": "H:mm", "%T": "H:mm:ss", "%X": "t", "%x": "d", "%e": "d", "%D": "MM/dd/yy", "%n": "\\n", "%t": "\\t", "e" : "z", "T" : "z", "%z": "z", "%Z": "z", "Z" : "ZZ", "N" : "u", "w" : "u", "%w": "u", "W" : "W", "%V": "W" }; var normalizer = { substitutes: function (m) { return normalizerSubstitutions[m]; }, interpreted: function (m, x) { var y; switch (m) { case "%u": return x.getDay() + 1; case "z": return x.getOrdinalNumber(); case "%j": return p(x.getOrdinalNumber(), 3); case "%U": var d1 = x.clone().set({month: 0, day: 1}).addDays(-1).moveToDayOfWeek(0), d2 = x.clone().addDays(1).moveToDayOfWeek(0, -1); return (d2 < d1) ? "00" : p((d2.getOrdinalNumber() - d1.getOrdinalNumber()) / 7 + 1); case "%W": return p(x.getWeek()); case "t": return $D.getDaysInMonth(x.getFullYear(), x.getMonth()); case "o": case "%G": return x.setWeek(x.getISOWeek()).toString("yyyy"); case "%g": return x._format("%G").slice(-2); case "a": case "%p": return t("tt").toLowerCase(); case "A": return t("tt").toUpperCase(); case "u": return p(x.getMilliseconds(), 3); case "I": return (x.isDaylightSavingTime()) ? 1 : 0; case "O": return x.getUTCOffset(); case "P": y = x.getUTCOffset(); return y.substring(0, y.length - 2) + ":" + y.substring(y.length - 2); case "B": var now = new Date(); return Math.floor(((now.getHours() * 3600) + (now.getMinutes() * 60) + now.getSeconds() + (now.getTimezoneOffset() + 60) * 60) / 86.4); case "c": return x.toISOString().replace(/\"/g, ""); case "U": return $D.strtotime("now"); case "%c": return t("d") + " " + t("t"); case "%C": return Math.floor(x.getFullYear() / 100 + 1); } }, shouldOverrideDefaults: function (m) { switch (m) { case "%e": return true; default: return false; } }, parse: function (m, context) { var formatString, c = context || new Date(); formatString = normalizer.substitutes(m); if (formatString) { return formatString; } formatString = normalizer.interpreted(m, c); if (formatString) { return formatString; } else { return m; } } }; $D.normalizeFormat = function (format, context) { return format.replace(/(%|\\)?.|%%/g, function(t){ return normalizer.parse(t, context); }); }; /** * Format a local Unix timestamp according to locale settings * * Example: * Date.strftime("%m/%d/%y", new Date()); // "04/13/08" * Date.strftime("c", "2008-04-13T17:52:03Z"); // "04/13/08" * * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @param {Number|String} The number representing the number of seconds that have elapsed since January 1, 1970 (local time). * @return {String} A string representation of the current Date object. */ $D.strftime = function (format, time) { var d = Date.parse(time); return d._format(format); }; /** * Parse any textual datetime description into a Unix timestamp. * A Unix timestamp is the number of seconds that have elapsed since January 1, 1970 (midnight UTC/GMT). * * Example: * Date.strtotime("04/13/08"); // 1208044800 * Date.strtotime("1970-01-01T00:00:00Z"); // 0 * * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @param {Object} A string or date object. * @return {String} A string representation of the current Date object. */ $D.strtotime = function (time) { var d = $D.parse(time); return Math.round($D.UTC(d.getUTCFullYear(), d.getUTCMonth(), d.getUTCDate(), d.getUTCHours(), d.getUTCMinutes(), d.getUTCSeconds(), d.getUTCMilliseconds()) / 1000); }; /** * Converts the value of the current Date object to its equivalent string representation using a PHP/Unix style of date format specifiers. * Format Specifiers * Format Description Example * ------ --------------------------------------------------------------------------- ----------------------- * %a abbreviated weekday name according to the current localed "Mon" through "Sun" * %A full weekday name according to the current localed "Sunday" through "Saturday" * %b abbreviated month name according to the current localed "Jan" through "Dec" * %B full month name according to the current locale "January" through "December" * %c preferred date and time representation for the current locale "4/13/2008 12:33 PM" * %C century number (the year divided by 100 and truncated to an integer) "00" to "99" * %d day of the month as a decimal number "01" to "31" * %D same as %m/%d/%y "04/13/08" * %e day of the month as a decimal number, a single digit is preceded by a space "1" to "31" * %g like %G, but without the century "08" * %G The 4-digit year corresponding to the ISO week number (see %V). "2008" * This has the same format and value as %Y, except that if the ISO week number * belongs to the previous or next year, that year is used instead. * %h same as %b "Jan" through "Dec" * %H hour as a decimal number using a 24-hour clock. "00" to "23" * %I hour as a decimal number using a 12-hour clock. "01" to "12" * %j day of the year as a decimal number. "001" to "366" * %m month as a decimal number. "01" to "12" * %M minute as a decimal number. "00" to "59" * %n newline character "\n" * %p either "am" or "pm" according to the given time value, or the "am" or "pm" * corresponding strings for the current locale. * %r time in a.m. and p.m. notation "8:44 PM" * %R time in 24 hour notation "20:44" * %S second as a decimal number "00" to "59" * %t tab character "\t" * %T current time, equal to %H:%M:%S "12:49:11" * %u weekday as a decimal number ["1", "7"], with "1" representing Monday "1" to "7" * %U week number of the current year as a decimal number, starting with the "0" to ("52" or "53") * first Sunday as the first day of the first week * %V The ISO 8601:1988 week number of the current year as a decimal number, "00" to ("52" or "53") * range 01 to 53, where week 1 is the first week that has at least 4 days * in the current year, and with Monday as the first day of the week. * (Use %G or %g for the year component that corresponds to the week number * for the specified timestamp.) * %W week number of the current year as a decimal number, starting with the "00" to ("52" or "53") * first Monday as the first day of the first week * %w day of the week as a decimal, Sunday being "0" "0" to "6" * %x preferred date representation for the current locale without the time "4/13/2008" * %X preferred time representation for the current locale without the date "12:53:05" * %y year as a decimal number without a century "00" "99" * %Y year as a decimal number including the century "2008" * %Z time zone or name or abbreviation "UTC", "EST", "PST" * %z same as %Z * %% a literal "%" characters "%" * d Day of the month, 2 digits with leading zeros "01" to "31" * D A textual representation of a day, three letters "Mon" through "Sun" * j Day of the month without leading zeros "1" to "31" * l A full textual representation of the day of the week (lowercase "L") "Sunday" through "Saturday" * N ISO-8601 numeric representation of the day of the week (added in PHP 5.1.0) "1" (for Monday) through "7" (for Sunday) * S English ordinal suffix for the day of the month, 2 characters "st", "nd", "rd" or "th". Works well with j * w Numeric representation of the day of the week "0" (for Sunday) through "6" (for Saturday) * z The day of the year (starting from "0") "0" through "365" * W ISO-8601 week number of year, weeks starting on Monday "00" to ("52" or "53") * F A full textual representation of a month, such as January or March "January" through "December" * m Numeric representation of a month, with leading zeros "01" through "12" * M A short textual representation of a month, three letters "Jan" through "Dec" * n Numeric representation of a month, without leading zeros "1" through "12" * t Number of days in the given month "28" through "31" * L Whether it's a leap year "1" if it is a leap year, "0" otherwise * o ISO-8601 year number. This has the same value as Y, except that if the "2008" * ISO week number (W) belongs to the previous or next year, that year * is used instead. * Y A full numeric representation of a year, 4 digits "2008" * y A two digit representation of a year "08" * a Lowercase Ante meridiem and Post meridiem "am" or "pm" * A Uppercase Ante meridiem and Post meridiem "AM" or "PM" * B Swatch Internet time "000" through "999" * g 12-hour format of an hour without leading zeros "1" through "12" * G 24-hour format of an hour without leading zeros "0" through "23" * h 12-hour format of an hour with leading zeros "01" through "12" * H 24-hour format of an hour with leading zeros "00" through "23" * i Minutes with leading zeros "00" to "59" * s Seconds, with leading zeros "00" through "59" * u Milliseconds "54321" * e Timezone identifier "UTC", "EST", "PST" * I Whether or not the date is in daylight saving time (uppercase i) "1" if Daylight Saving Time, "0" otherwise * O Difference to Greenwich time (GMT) in hours "+0200", "-0600" * P Difference to Greenwich time (GMT) with colon between hours and minutes "+02:00", "-06:00" * T Timezone abbreviation "UTC", "EST", "PST" * Z Timezone offset in seconds. The offset for timezones west of UTC is "-43200" through "50400" * always negative, and for those east of UTC is always positive. * c ISO 8601 date "2004-02-12T15:19:21+00:00" * r RFC 2822 formatted date "Thu, 21 Dec 2000 16:01:07 +0200" * U Seconds since the Unix Epoch (January 1 1970 00:00:00 GMT) "0" * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @return {String} A string representation of the current Date object. */ var formatReplace = function (context) { return function (m) { var formatString, override = false; if (m.charAt(0) === "\\" || m.substring(0, 2) === "%%") { return m.replace("\\", "").replace("%%", "%"); } override = normalizer.shouldOverrideDefaults(m); formatString = $D.normalizeFormat(m, context); if (formatString) { return context.toString(formatString, override); } }; }; $P._format = function (format) { var formatter = formatReplace(this); if (!format) { return this._toString(); } else { return format.replace(/(%|\\)?.|%%/g, formatter); } }; if (!$P.format) { $P.format = $P._format; } }()); (function () { "use strict"; var gFn = function (attr) { return function () { return this[attr]; }; }; var sFn = function (attr) { return function (val) { this[attr] = val; return this; }; }; var attrs = ["years", "months", "days", "hours", "minutes", "seconds", "milliseconds"]; var addSetFuncs = function (context, attrs) { for (var i = 0; i < attrs.length ; i++) { var $a = attrs[i], $b = $a.slice(0, 1).toUpperCase() + $a.slice(1); context.prototype[$a] = 0; context.prototype["get" + $b] = gFn($a); context.prototype["set" + $b] = sFn($a); } }; /** * new TimeSpan(milliseconds); * new TimeSpan(days, hours, minutes, seconds); * new TimeSpan(days, hours, minutes, seconds, milliseconds); */ var TimeSpan = function (days, hours, minutes, seconds, milliseconds) { if (arguments.length === 1 && typeof days === "number") { var orient = (days < 0) ? -1 : +1; var millsLeft = Math.abs(days); this.setDays(Math.floor(millsLeft / 86400000) * orient); millsLeft = millsLeft % 86400000; this.setHours(Math.floor(millsLeft / 3600000) * orient); millsLeft = millsLeft % 3600000; this.setMinutes(Math.floor(millsLeft / 60000) * orient); millsLeft = millsLeft % 60000; this.setSeconds(Math.floor(millsLeft / 1000) * orient); millsLeft = millsLeft % 1000; this.setMilliseconds(millsLeft * orient); } else { this.set(days, hours, minutes, seconds, milliseconds); } this.getTotalMilliseconds = function () { return (this.getDays() * 86400000) + (this.getHours() * 3600000) + (this.getMinutes() * 60000) + (this.getSeconds() * 1000); }; this.compareTo = function (time) { var t1 = new Date(1970, 1, 1, this.getHours(), this.getMinutes(), this.getSeconds()), t2; if (time === null) { t2 = new Date(1970, 1, 1, 0, 0, 0); } else { t2 = new Date(1970, 1, 1, time.getHours(), time.getMinutes(), time.getSeconds()); } return (t1 < t2) ? -1 : (t1 > t2) ? 1 : 0; }; this.equals = function (time) { return (this.compareTo(time) === 0); }; this.add = function (time) { return (time === null) ? this : this.addSeconds(time.getTotalMilliseconds() / 1000); }; this.subtract = function (time) { return (time === null) ? this : this.addSeconds(-time.getTotalMilliseconds() / 1000); }; this.addDays = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 86400000)); }; this.addHours = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 3600000)); }; this.addMinutes = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 60000)); }; this.addSeconds = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 1000)); }; this.addMilliseconds = function (n) { return new TimeSpan(this.getTotalMilliseconds() + n); }; this.get12HourHour = function () { return (this.getHours() > 12) ? this.getHours() - 12 : (this.getHours() === 0) ? 12 : this.getHours(); }; this.getDesignator = function () { return (this.getHours() < 12) ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator; }; this.toString = function (format) { this._toString = function () { if (this.getDays() !== null && this.getDays() > 0) { return this.getDays() + "." + this.getHours() + ":" + this.p(this.getMinutes()) + ":" + this.p(this.getSeconds()); } else { return this.getHours() + ":" + this.p(this.getMinutes()) + ":" + this.p(this.getSeconds()); } }; this.p = function (s) { return (s.toString().length < 2) ? "0" + s : s; }; var me = this; return format ? format.replace(/dd?|HH?|hh?|mm?|ss?|tt?/g, function (format) { switch (format) { case "d": return me.getDays(); case "dd": return me.p(me.getDays()); case "H": return me.getHours(); case "HH": return me.p(me.getHours()); case "h": return me.get12HourHour(); case "hh": return me.p(me.get12HourHour()); case "m": return me.getMinutes(); case "mm": return me.p(me.getMinutes()); case "s": return me.getSeconds(); case "ss": return me.p(me.getSeconds()); case "t": return ((me.getHours() < 12) ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator).substring(0, 1); case "tt": return (me.getHours() < 12) ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator; } } ) : this._toString(); }; return this; }; addSetFuncs(TimeSpan, attrs.slice(2)); TimeSpan.prototype.set = function (days, hours, minutes, seconds, milliseconds){ this.setDays(days || this.getDays()); this.setHours(hours || this.getHours()); this.setMinutes(minutes || this.getMinutes()); this.setSeconds(seconds || this.getSeconds()); this.setMilliseconds(milliseconds || this.getMilliseconds()); }; /** * Gets the time of day for this date instances. * @return {TimeSpan} TimeSpan */ Date.prototype.getTimeOfDay = function () { return new TimeSpan(0, this.getHours(), this.getMinutes(), this.getSeconds(), this.getMilliseconds()); }; Date.TimeSpan = TimeSpan; if (typeof window !== "undefined" ) { // keeping API compatible for v1.x window.TimeSpan = TimeSpan; } }()); (function () { "use strict"; var attrs = ["years", "months", "days", "hours", "minutes", "seconds", "milliseconds"]; var gFn = function (attr) { return function () { return this[attr]; }; }; var sFn = function (attr) { return function (val) { this[attr] = val; return this; }; }; var addSetFuncs = function (context, attrs) { for (var i = 0; i < attrs.length ; i++) { var $a = attrs[i], $b = $a.slice(0, 1).toUpperCase() + $a.slice(1); context.prototype[$a] = 0; context.prototype["get" + $b] = gFn($a); context.prototype["set" + $b] = sFn($a); } }; var setMonthsAndYears = function (orient, d1, d2, context) { function inc() { d1.addMonths(-orient); context.months++; if (context.months === 12) { context.years++; context.months = 0; } } if (orient === +1) { while (d1 > d2) { inc(); } } else { while (d1 < d2) { inc(); } } context.months--; context.months *= orient; context.years *= orient; }; var adjustForDST = function(orient, startDate, endDate) { var hasDSTMismatch = (false === (startDate.isDaylightSavingTime() === endDate.isDaylightSavingTime())); if (hasDSTMismatch && orient === 1) { startDate.addHours(-1); } else if (hasDSTMismatch) { startDate.addHours(1); } }; /** * TimePeriod(startDate, endDate); * TimePeriod(years, months, days, hours, minutes, seconds, milliseconds); */ var TimePeriod = function (years, months, days, hours, minutes, seconds, milliseconds) { if (arguments.length === 7) { this.set(years, months, days, hours, minutes, seconds, milliseconds); } else if (arguments.length === 2 && arguments[0] instanceof Date && arguments[1] instanceof Date) { var startDate = arguments[0].clone(); var endDate = arguments[1].clone(); var orient = (startDate > endDate) ? +1 : -1; this.dates = { start: arguments[0].clone(), end: arguments[1].clone() }; setMonthsAndYears(orient, startDate, endDate, this); adjustForDST(orient, startDate, endDate); // // TODO - adjust for DST var diff = endDate - startDate; if (diff !== 0) { var ts = new TimeSpan(diff); this.set(this.years, this.months, ts.getDays(), ts.getHours(), ts.getMinutes(), ts.getSeconds(), ts.getMilliseconds()); } } return this; }; // create all the set functions. addSetFuncs(TimePeriod, attrs); TimePeriod.prototype.set = function (years, months, days, hours, minutes, seconds, milliseconds){ this.setYears(years || this.getYears()); this.setMonths(months || this.getMonths()); this.setDays(days || this.getDays()); this.setHours(hours || this.getHours()); this.setMinutes(minutes || this.getMinutes()); this.setSeconds(seconds || this.getSeconds()); this.setMilliseconds(milliseconds || this.getMilliseconds()); }; Date.TimePeriod = TimePeriod; if (typeof window !== "undefined") { // keeping API compatible for v1.x window.TimePeriod = TimePeriod; } }()); ================================================ FILE: build/date-se-NO.js ================================================ /** * @overview datejs * @version 1.0.0-rc3 * @author Gregory Wild-Smith * @copyright 2015 Gregory Wild-Smith * @license MIT * @homepage https://github.com/abritinthebay/datejs */ /* * DateJS Culture String File * Country Code: se-NO * Name: Sami (Northern) (Norway) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["se-NO"] = { "name": "se-NO", "englishName": "Sami (Northern) (Norway)", "nativeName": "davvisámegiella (Norga)", "Sunday": "sotnabeaivi", "Monday": "vuossárga", "Tuesday": "maŋŋebárga", "Wednesday": "gaskavahkku", "Thursday": "duorastat", "Friday": "bearjadat", "Saturday": "lávvardat", "Sun": "sotn", "Mon": "vuos", "Tue": "maŋ", "Wed": "gask", "Thu": "duor", "Fri": "bear", "Sat": "láv", "Su": "sotn", "Mo": "vuos", "Tu": "maŋ", "We": "gask", "Th": "duor", "Fr": "bear", "Sa": "láv", "S_Sun_Initial": "s", "M_Mon_Initial": "v", "T_Tue_Initial": "m", "W_Wed_Initial": "g", "T_Thu_Initial": "d", "F_Fri_Initial": "b", "S_Sat_Initial": "l", "January": "ođđajagemánnu", "February": "guovvamánnu", "March": "njukčamánnu", "April": "cuoŋománnu", "May": "miessemánnu", "June": "geassemánnu", "July": "suoidnemánnu", "August": "borgemánnu", "September": "čakčamánnu", "October": "golggotmánnu", "November": "skábmamánnu", "December": "juovlamánnu", "Jan_Abbr": "ođđj", "Feb_Abbr": "guov", "Mar_Abbr": "njuk", "Apr_Abbr": "cuo", "May_Abbr": "mies", "Jun_Abbr": "geas", "Jul_Abbr": "suoi", "Aug_Abbr": "borg", "Sep_Abbr": "čakč", "Oct_Abbr": "golg", "Nov_Abbr": "skáb", "Dec_Abbr": "juov", "AM": "", "PM": "", "firstDayOfWeek": 1, "twoDigitYearMax": 2029, "mdy": "dmy", "M/d/yyyy": "dd.MM.yyyy", "dddd, MMMM dd, yyyy": "MMMM d'. b. 'yyyy", "h:mm tt": "HH:mm:ss", "h:mm:ss tt": "HH:mm:ss", "dddd, MMMM dd, yyyy h:mm:ss tt": "MMMM d'. b. 'yyyy HH:mm:ss", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "MMMM dd", "MMMM, yyyy": "MMMM yyyy", "/jan(uary)?/": "ođđajagemánnu", "/feb(ruary)?/": "guov(vamánnu)?", "/mar(ch)?/": "njuk(čamánnu)?", "/apr(il)?/": "cuo(ŋománnu)?", "/may/": "mies(semánnu)?", "/jun(e)?/": "geas(semánnu)?", "/jul(y)?/": "suoi(dnemánnu)?", "/aug(ust)?/": "borg(emánnu)?", "/sep(t(ember)?)?/": "čakč(amánnu)?", "/oct(ober)?/": "golg(gotmánnu)?", "/nov(ember)?/": "skáb(mamánnu)?", "/dec(ember)?/": "juov(lamánnu)?", "/^su(n(day)?)?/": "^sotnabeaivi", "/^mo(n(day)?)?/": "^vuossárga", "/^tu(e(s(day)?)?)?/": "^maŋŋebárga", "/^we(d(nesday)?)?/": "^gaskavahkku", "/^th(u(r(s(day)?)?)?)?/": "^duorastat", "/^fr(i(day)?)?/": "^bearjadat", "/^sa(t(urday)?)?/": "^lávvardat", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "se-NO"; /** * @overview datejs * @version 1.0.0-rc3 * @author Gregory Wild-Smith * @copyright 2015 Gregory Wild-Smith * @license MIT * @homepage https://github.com/abritinthebay/datejs */(function () { var $D = Date; var lang = Date.CultureStrings ? Date.CultureStrings.lang : null; var loggedKeys = {}; // for debug purposes. var getText = { getFromKey: function (key, countryCode) { var output; if (Date.CultureStrings && Date.CultureStrings[countryCode] && Date.CultureStrings[countryCode][key]) { output = Date.CultureStrings[countryCode][key]; } else { output = getText.buildFromDefault(key); } if (key.charAt(0) === "/") { // Assume it's a regex output = getText.buildFromRegex(key, countryCode); } return output; }, getFromObjectValues: function (obj, countryCode) { var key, output = {}; for(key in obj) { if (obj.hasOwnProperty(key)) { output[key] = getText.getFromKey(obj[key], countryCode); } } return output; }, getFromObjectKeys: function (obj, countryCode) { var key, output = {}; for(key in obj) { if (obj.hasOwnProperty(key)) { output[getText.getFromKey(key, countryCode)] = obj[key]; } } return output; }, getFromArray: function (arr, countryCode) { var output = []; for (var i=0; i < arr.length; i++){ if (i in arr) { output[i] = getText.getFromKey(arr[i], countryCode); } } return output; }, buildFromDefault: function (key) { var output, length, split, last; switch(key) { case "name": output = "en-US"; break; case "englishName": output = "English (United States)"; break; case "nativeName": output = "English (United States)"; break; case "twoDigitYearMax": output = 2049; break; case "firstDayOfWeek": output = 0; break; default: output = key; split = key.split("_"); length = split.length; if (length > 1 && key.charAt(0) !== "/") { // if the key isn't a regex and it has a split. last = split[(length - 1)].toLowerCase(); if (last === "initial" || last === "abbr") { output = split[0]; } } break; } return output; }, buildFromRegex: function (key, countryCode) { var output; if (Date.CultureStrings && Date.CultureStrings[countryCode] && Date.CultureStrings[countryCode][key]) { output = new RegExp(Date.CultureStrings[countryCode][key], "i"); } else { output = new RegExp(key.replace(new RegExp("/", "g"),""), "i"); } return output; } }; var shallowMerge = function (obj1, obj2) { for (var attrname in obj2) { if (obj2.hasOwnProperty(attrname)) { obj1[attrname] = obj2[attrname]; } } }; var __ = function (key, language) { var countryCode = (language) ? language : lang; loggedKeys[key] = key; if (typeof key === "object") { if (key instanceof Array) { return getText.getFromArray(key, countryCode); } else { return getText.getFromObjectKeys(key, countryCode); } } else { return getText.getFromKey(key, countryCode); } }; var loadI18nScript = function (code) { // paatterned after jQuery's getScript. var url = Date.Config.i18n + code + ".js"; var head = document.getElementsByTagName("head")[0] || document.documentElement; var script = document.createElement("script"); script.src = url; var completed = false; var events = { done: function (){} // placeholder function }; // Attach handlers for all browsers script.onload = script.onreadystatechange = function() { if ( !completed && (!this.readyState || this.readyState === "loaded" || this.readyState === "complete") ) { events.done(); head.removeChild(script); } }; setTimeout(function() { head.insertBefore(script, head.firstChild); }, 0); // allows return to execute first return { done: function (cb) { events.done = function() { if (cb) { setTimeout(cb,0); } }; } }; }; var buildInfo = { buildFromMethodHash: function (obj) { var key; for(key in obj) { if (obj.hasOwnProperty(key)) { obj[key] = buildInfo[obj[key]](); } } return obj; }, timeZoneDST: function () { var DST = { "CHADT": "+1345", "NZDT": "+1300", "AEDT": "+1100", "ACDT": "+1030", "AZST": "+0500", "IRDT": "+0430", "EEST": "+0300", "CEST": "+0200", "BST": "+0100", "PMDT": "-0200", "ADT": "-0300", "NDT": "-0230", "EDT": "-0400", "CDT": "-0500", "MDT": "-0600", "PDT": "-0700", "AKDT": "-0800", "HADT": "-0900" }; return __(DST); }, timeZoneStandard: function () { var standard = { "LINT": "+1400", "TOT": "+1300", "CHAST": "+1245", "NZST": "+1200", "NFT": "+1130", "SBT": "+1100", "AEST": "+1000", "ACST": "+0930", "JST": "+0900", "CWST": "+0845", "CT": "+0800", "ICT": "+0700", "MMT": "+0630", "BST": "+0600", "NPT": "+0545", "IST": "+0530", "PKT": "+0500", "AFT": "+0430", "MSK": "+0400", "IRST": "+0330", "FET": "+0300", "EET": "+0200", "CET": "+0100", "GMT": "+0000", "UTC": "+0000", "CVT": "-0100", "GST": "-0200", "BRT": "-0300", "NST": "-0330", "AST": "-0400", "EST": "-0500", "CST": "-0600", "MST": "-0700", "PST": "-0800", "AKST": "-0900", "MIT": "-0930", "HST": "-1000", "SST": "-1100", "BIT": "-1200" }; return __(standard); }, timeZones: function (data) { var zone; data.timezones = []; for (zone in data.abbreviatedTimeZoneStandard) { if (data.abbreviatedTimeZoneStandard.hasOwnProperty(zone)) { data.timezones.push({ name: zone, offset: data.abbreviatedTimeZoneStandard[zone]}); } } for (zone in data.abbreviatedTimeZoneDST) { if (data.abbreviatedTimeZoneDST.hasOwnProperty(zone)) { data.timezones.push({ name: zone, offset: data.abbreviatedTimeZoneDST[zone], dst: true}); } } return data.timezones; }, days: function () { return __(["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"]); }, dayAbbr: function () { return __(["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"]); }, dayShortNames: function () { return __(["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"]); }, dayFirstLetters: function () { return __(["S_Sun_Initial", "M_Mon_Initial", "T_Tues_Initial", "W_Wed_Initial", "T_Thu_Initial", "F_Fri_Initial", "S_Sat_Initial"]); }, months: function () { return __(["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"]); }, monthAbbr: function () { return __(["Jan_Abbr", "Feb_Abbr", "Mar_Abbr", "Apr_Abbr", "May_Abbr", "Jun_Abbr", "Jul_Abbr", "Aug_Abbr", "Sep_Abbr", "Oct_Abbr", "Nov_Abbr", "Dec_Abbr"]); }, formatPatterns: function () { return getText.getFromObjectValues({ shortDate: "M/d/yyyy", longDate: "dddd, MMMM dd, yyyy", shortTime: "h:mm tt", longTime: "h:mm:ss tt", fullDateTime: "dddd, MMMM dd, yyyy h:mm:ss tt", sortableDateTime: "yyyy-MM-ddTHH:mm:ss", universalSortableDateTime: "yyyy-MM-dd HH:mm:ssZ", rfc1123: "ddd, dd MMM yyyy HH:mm:ss", monthDay: "MMMM dd", yearMonth: "MMMM, yyyy" }, Date.i18n.currentLanguage()); }, regex: function () { return getText.getFromObjectValues({ inTheMorning: "/( in the )(morn(ing)?)\\b/", thisMorning: "/(this )(morn(ing)?)\\b/", amThisMorning: "/(\b\\d(am)? )(this )(morn(ing)?)/", inTheEvening: "/( in the )(even(ing)?)\\b/", thisEvening: "/(this )(even(ing)?)\\b/", pmThisEvening: "/(\b\\d(pm)? )(this )(even(ing)?)/", jan: "/jan(uary)?/", feb: "/feb(ruary)?/", mar: "/mar(ch)?/", apr: "/apr(il)?/", may: "/may/", jun: "/jun(e)?/", jul: "/jul(y)?/", aug: "/aug(ust)?/", sep: "/sep(t(ember)?)?/", oct: "/oct(ober)?/", nov: "/nov(ember)?/", dec: "/dec(ember)?/", sun: "/^su(n(day)?)?/", mon: "/^mo(n(day)?)?/", tue: "/^tu(e(s(day)?)?)?/", wed: "/^we(d(nesday)?)?/", thu: "/^th(u(r(s(day)?)?)?)?/", fri: "/fr(i(day)?)?/", sat: "/^sa(t(urday)?)?/", future: "/^next/", past: "/^last|past|prev(ious)?/", add: "/^(\\+|aft(er)?|from|hence)/", subtract: "/^(\\-|bef(ore)?|ago)/", yesterday: "/^yes(terday)?/", today: "/^t(od(ay)?)?/", tomorrow: "/^tom(orrow)?/", now: "/^n(ow)?/", millisecond: "/^ms|milli(second)?s?/", second: "/^sec(ond)?s?/", minute: "/^mn|min(ute)?s?/", hour: "/^h(our)?s?/", week: "/^w(eek)?s?/", month: "/^m(onth)?s?/", day: "/^d(ay)?s?/", year: "/^y(ear)?s?/", shortMeridian: "/^(a|p)/", longMeridian: "/^(a\\.?m?\\.?|p\\.?m?\\.?)/", timezone: "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/", ordinalSuffix: "/^\\s*(st|nd|rd|th)/", timeContext: "/^\\s*(\\:|a(?!u|p)|p)/" }, Date.i18n.currentLanguage()); } }; var CultureInfo = function () { var info = getText.getFromObjectValues({ name: "name", englishName: "englishName", nativeName: "nativeName", amDesignator: "AM", pmDesignator: "PM", firstDayOfWeek: "firstDayOfWeek", twoDigitYearMax: "twoDigitYearMax", dateElementOrder: "mdy" }, Date.i18n.currentLanguage()); var constructedInfo = buildInfo.buildFromMethodHash({ dayNames: "days", abbreviatedDayNames: "dayAbbr", shortestDayNames: "dayShortNames", firstLetterDayNames: "dayFirstLetters", monthNames: "months", abbreviatedMonthNames: "monthAbbr", formatPatterns: "formatPatterns", regexPatterns: "regex", abbreviatedTimeZoneDST: "timeZoneDST", abbreviatedTimeZoneStandard: "timeZoneStandard" }); shallowMerge(info, constructedInfo); buildInfo.timeZones(info); return info; }; $D.i18n = { __: function (key, lang) { return __(key, lang); }, currentLanguage: function () { return lang || "en-US"; }, setLanguage: function (code, force, cb) { var async = false; if (force || code === "en-US" || (!!Date.CultureStrings && !!Date.CultureStrings[code])) { lang = code; Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings.lang = code; Date.CultureInfo = new CultureInfo(); } else { if (!(!!Date.CultureStrings && !!Date.CultureStrings[code])) { if (typeof exports !== "undefined" && this.exports !== exports) { // we're in a Node enviroment, load it using require try { require("../i18n/" + code + ".js"); lang = code; Date.CultureStrings.lang = code; Date.CultureInfo = new CultureInfo(); } catch (e) { // var str = "The language for '" + code + "' could not be loaded by Node. It likely does not exist."; throw new Error("The DateJS IETF language tag '" + code + "' could not be loaded by Node. It likely does not exist."); } } else if (Date.Config && Date.Config.i18n) { // we know the location of the files, so lets load them async = true; loadI18nScript(code).done(function(){ lang = code; Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings.lang = code; Date.CultureInfo = new CultureInfo(); $D.Parsing.Normalizer.buildReplaceData(); // because this is async if ($D.Grammar) { $D.Grammar.buildGrammarFormats(); // so we can parse those strings... } if (cb) { setTimeout(cb,0); } }); } else { Date.console.error("The DateJS IETF language tag '" + code + "' is not available and has not been loaded."); return false; } } } $D.Parsing.Normalizer.buildReplaceData(); // rebuild normalizer strings if ($D.Grammar) { $D.Grammar.buildGrammarFormats(); // so we can parse those strings... } if (!async && cb) { setTimeout(cb,0); } }, getLoggedKeys: function () { return loggedKeys; }, updateCultureInfo: function () { Date.CultureInfo = new CultureInfo(); } }; $D.i18n.updateCultureInfo(); // run automatically }()); (function () { var $D = Date, $P = $D.prototype, p = function (s, l) { if (!l) { l = 2; } return ("000" + s).slice(l * -1); }; if (typeof window !== "undefined" && typeof window.console !== "undefined" && typeof window.console.log !== "undefined") { $D.console = console; // used only to raise non-critical errors if available } else { // set mock so we don't give errors. $D.console = { log: function(){}, error: function(){} }; } $D.Config = $D.Config || {}; $D.initOverloads = function() { /** * Overload of Date.now. Allows an alternate call for Date.now where it returns the * current Date as an object rather than just milliseconds since the Unix Epoch. * * Also provides an implementation of now() for browsers (IE<9) that don't have it. * * Backwards compatible so with work with either: * Date.now() [returns ms] * or * Date.now(true) [returns Date] */ if (!$D.now) { $D._now = function now() { return new Date().getTime(); }; } else if (!$D._now) { $D._now = $D.now; } $D.now = function (returnObj) { if (returnObj) { return $D.present(); } else { return $D._now(); } }; if ( !$P.toISOString ) { $P.toISOString = function() { return this.getUTCFullYear() + "-" + p(this.getUTCMonth() + 1) + "-" + p(this.getUTCDate()) + "T" + p(this.getUTCHours()) + ":" + p(this.getUTCMinutes()) + ":" + p(this.getUTCSeconds()) + "." + String( (this.getUTCMilliseconds()/1000).toFixed(3)).slice(2, 5) + "Z"; }; } // private if ( $P._toString === undefined ){ $P._toString = $P.toString; } }; $D.initOverloads(); /** * Gets a date that is set to the current date. The time is set to the start of the day (00:00 or 12:00 AM). * @return {Date} The current date. */ $D.today = function () { return new Date().clearTime(); }; /** * Gets a date that is set to the current date and time (same as new Date, but chainable) * @return {Date} The current date. */ $D.present = function () { return new Date(); }; /** * Compares the first date to the second date and returns an number indication of their relative values. * @param {Date} First Date object to compare [Required]. * @param {Date} Second Date object to compare to [Required]. * @return {Number} -1 = date1 is lessthan date2. 0 = values are equal. 1 = date1 is greaterthan date2. */ $D.compare = function (date1, date2) { if (isNaN(date1) || isNaN(date2)) { throw new Error(date1 + " - " + date2); } else if (date1 instanceof Date && date2 instanceof Date) { return (date1 < date2) ? -1 : (date1 > date2) ? 1 : 0; } else { throw new TypeError(date1 + " - " + date2); } }; /** * Compares the first Date object to the second Date object and returns true if they are equal. * @param {Date} First Date object to compare [Required] * @param {Date} Second Date object to compare to [Required] * @return {Boolean} true if dates are equal. false if they are not equal. */ $D.equals = function (date1, date2) { return (date1.compareTo(date2) === 0); }; /** * Gets the language appropriate day name when given the day number(0-6) * eg - 0 == Sunday * @return {String} The day name */ $D.getDayName = function (n) { return Date.CultureInfo.dayNames[n]; }; /** * Gets the day number (0-6) if given a CultureInfo specific string which is a valid dayName, abbreviatedDayName or shortestDayName (two char). * @param {String} The name of the day (eg. "Monday, "Mon", "tuesday", "tue", "We", "we"). * @return {Number} The day number */ $D.getDayNumberFromName = function (name) { var n = Date.CultureInfo.dayNames, m = Date.CultureInfo.abbreviatedDayNames, o = Date.CultureInfo.shortestDayNames, s = name.toLowerCase(); for (var i = 0; i < n.length; i++) { if (n[i].toLowerCase() === s || m[i].toLowerCase() === s || o[i].toLowerCase() === s) { return i; } } return -1; }; /** * Gets the month number (0-11) if given a Culture Info specific string which is a valid monthName or abbreviatedMonthName. * @param {String} The name of the month (eg. "February, "Feb", "october", "oct"). * @return {Number} The day number */ $D.getMonthNumberFromName = function (name) { var n = Date.CultureInfo.monthNames, m = Date.CultureInfo.abbreviatedMonthNames, s = name.toLowerCase(); for (var i = 0; i < n.length; i++) { if (n[i].toLowerCase() === s || m[i].toLowerCase() === s) { return i; } } return -1; }; /** * Gets the language appropriate month name when given the month number(0-11) * eg - 0 == January * @return {String} The month name */ $D.getMonthName = function (n) { return Date.CultureInfo.monthNames[n]; }; /** * Determines if the current date instance is within a LeapYear. * @param {Number} The year. * @return {Boolean} true if date is within a LeapYear, otherwise false. */ $D.isLeapYear = function (year) { return ((year % 4 === 0 && year % 100 !== 0) || year % 400 === 0); }; /** * Gets the number of days in the month, given a year and month value. Automatically corrects for LeapYear. * @param {Number} The year. * @param {Number} The month (0-11). * @return {Number} The number of days in the month. */ $D.getDaysInMonth = function (year, month) { if (!month && $D.validateMonth(year)) { month = year; year = Date.today().getFullYear(); } return [31, ($D.isLeapYear(year) ? 29 : 28), 31, 30, 31, 30, 31, 31, 30, 31, 30, 31][month]; }; $P.getDaysInMonth = function () { return $D.getDaysInMonth(this.getFullYear(), this.getMonth()); }; $D.getTimezoneAbbreviation = function (offset, dst) { var p, n = (dst || false) ? Date.CultureInfo.abbreviatedTimeZoneDST : Date.CultureInfo.abbreviatedTimeZoneStandard; for (p in n) { if (n.hasOwnProperty(p)) { if (n[p] === offset) { return p; } } } return null; }; $D.getTimezoneOffset = function (name, dst) { var i, a =[], z = Date.CultureInfo.timezones; if (!name) { name = (new Date()).getTimezone();} for (i = 0; i < z.length; i++) { if (z[i].name === name.toUpperCase()) { a.push(i); } } if (!z[a[0]]) { return null; } if (a.length === 1 || !dst) { return z[a[0]].offset; } else { for (i=0; i < a.length; i++) { if (z[a[i]].dst) { return z[a[i]].offset; } } } }; $D.getQuarter = function (d) { d = d || new Date(); // If no date supplied, use today var q = [1,2,3,4]; return q[Math.floor(d.getMonth() / 3)]; // ~~~ is a bitwise op. Faster than Math.floor }; $D.getDaysLeftInQuarter = function (d) { d = d || new Date(); var qEnd = new Date(d); qEnd.setMonth(qEnd.getMonth() + 3 - qEnd.getMonth() % 3, 0); return Math.floor((qEnd - d) / 8.64e7); }; // private var validate = function (n, min, max, name) { name = name ? name : "Object"; if (typeof n === "undefined") { return false; } else if (typeof n !== "number") { throw new TypeError(n + " is not a Number."); } else if (n < min || n > max) { // As failing validation is *not* an exceptional circumstance // lets not throw a RangeError Exception here. // It's semantically correct but it's not sensible. return false; } return true; }; /** * Validates the number is within an acceptable range for milliseconds [0-999]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateMillisecond = function (value) { return validate(value, 0, 999, "millisecond"); }; /** * Validates the number is within an acceptable range for seconds [0-59]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateSecond = function (value) { return validate(value, 0, 59, "second"); }; /** * Validates the number is within an acceptable range for minutes [0-59]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateMinute = function (value) { return validate(value, 0, 59, "minute"); }; /** * Validates the number is within an acceptable range for hours [0-23]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateHour = function (value) { return validate(value, 0, 23, "hour"); }; /** * Validates the number is within an acceptable range for the days in a month [0-MaxDaysInMonth]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateDay = function (value, year, month) { if (year === undefined || year === null || month === undefined || month === null) { return false;} return validate(value, 1, $D.getDaysInMonth(year, month), "day"); }; /** * Validates the number is within an acceptable range for months [0-11]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateWeek = function (value) { return validate(value, 0, 53, "week"); }; /** * Validates the number is within an acceptable range for months [0-11]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateMonth = function (value) { return validate(value, 0, 11, "month"); }; /** * Validates the number is within an acceptable range for years. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateYear = function (value) { /** * Per ECMAScript spec the range of times supported by Date objects is * exactly -100,000,000 days to +100,000,000 days measured relative to * midnight at the beginning of 01 January, 1970 UTC. * This gives a range of 8,640,000,000,000,000 milliseconds to either * side of 01 January, 1970 UTC. * * Earliest possible date: Tue, 20 Apr 271,822 B.C. 00:00:00 UTC * Latest possible date: Sat, 13 Sep 275,760 00:00:00 UTC */ return validate(value, -271822, 275760, "year"); }; $D.validateTimezone = function(value) { var timezones = {"ACDT":1,"ACST":1,"ACT":1,"ADT":1,"AEDT":1,"AEST":1,"AFT":1,"AKDT":1,"AKST":1,"AMST":1,"AMT":1,"ART":1,"AST":1,"AWDT":1,"AWST":1,"AZOST":1,"AZT":1,"BDT":1,"BIOT":1,"BIT":1,"BOT":1,"BRT":1,"BST":1,"BTT":1,"CAT":1,"CCT":1,"CDT":1,"CEDT":1,"CEST":1,"CET":1,"CHADT":1,"CHAST":1,"CHOT":1,"ChST":1,"CHUT":1,"CIST":1,"CIT":1,"CKT":1,"CLST":1,"CLT":1,"COST":1,"COT":1,"CST":1,"CT":1,"CVT":1,"CWST":1,"CXT":1,"DAVT":1,"DDUT":1,"DFT":1,"EASST":1,"EAST":1,"EAT":1,"ECT":1,"EDT":1,"EEDT":1,"EEST":1,"EET":1,"EGST":1,"EGT":1,"EIT":1,"EST":1,"FET":1,"FJT":1,"FKST":1,"FKT":1,"FNT":1,"GALT":1,"GAMT":1,"GET":1,"GFT":1,"GILT":1,"GIT":1,"GMT":1,"GST":1,"GYT":1,"HADT":1,"HAEC":1,"HAST":1,"HKT":1,"HMT":1,"HOVT":1,"HST":1,"ICT":1,"IDT":1,"IOT":1,"IRDT":1,"IRKT":1,"IRST":1,"IST":1,"JST":1,"KGT":1,"KOST":1,"KRAT":1,"KST":1,"LHST":1,"LINT":1,"MAGT":1,"MART":1,"MAWT":1,"MDT":1,"MET":1,"MEST":1,"MHT":1,"MIST":1,"MIT":1,"MMT":1,"MSK":1,"MST":1,"MUT":1,"MVT":1,"MYT":1,"NCT":1,"NDT":1,"NFT":1,"NPT":1,"NST":1,"NT":1,"NUT":1,"NZDT":1,"NZST":1,"OMST":1,"ORAT":1,"PDT":1,"PET":1,"PETT":1,"PGT":1,"PHOT":1,"PHT":1,"PKT":1,"PMDT":1,"PMST":1,"PONT":1,"PST":1,"PYST":1,"PYT":1,"RET":1,"ROTT":1,"SAKT":1,"SAMT":1,"SAST":1,"SBT":1,"SCT":1,"SGT":1,"SLST":1,"SRT":1,"SST":1,"SYOT":1,"TAHT":1,"THA":1,"TFT":1,"TJT":1,"TKT":1,"TLT":1,"TMT":1,"TOT":1,"TVT":1,"UCT":1,"ULAT":1,"UTC":1,"UYST":1,"UYT":1,"UZT":1,"VET":1,"VLAT":1,"VOLT":1,"VOST":1,"VUT":1,"WAKT":1,"WAST":1,"WAT":1,"WEDT":1,"WEST":1,"WET":1,"WST":1,"YAKT":1,"YEKT":1,"Z":1}; return (timezones[value] === 1); }; $D.validateTimezoneOffset= function(value) { // timezones go from +14hrs to -12hrs, the +X hours are negative offsets. return (value > -841 && value < 721); }; }()); (function () { var $D = Date, $P = $D.prototype, p = function (s, l) { if (!l) { l = 2; } return ("000" + s).slice(l * -1); }; var validateConfigObject = function (obj) { var result = {}, self = this, prop, testFunc; testFunc = function (prop, func, value) { if (prop === "day") { var month = (obj.month !== undefined) ? obj.month : self.getMonth(); var year = (obj.year !== undefined) ? obj.year : self.getFullYear(); return $D[func](value, year, month); } else { return $D[func](value); } }; for (prop in obj) { if (Object.prototype.hasOwnProperty.call(obj, prop)) { var func = "validate" + prop.charAt(0).toUpperCase() + prop.slice(1); if ($D[func] && obj[prop] !== null && testFunc(prop, func, obj[prop])) { result[prop] = obj[prop]; } } } return result; }; /** * Resets the time of this Date object to 12:00 AM (00:00), which is the start of the day. * @param {Boolean} .clone() this date instance before clearing Time * @return {Date} this */ $P.clearTime = function () { this.setHours(0); this.setMinutes(0); this.setSeconds(0); this.setMilliseconds(0); return this; }; /** * Resets the time of this Date object to the current time ('now'). * @return {Date} this */ $P.setTimeToNow = function () { var n = new Date(); this.setHours(n.getHours()); this.setMinutes(n.getMinutes()); this.setSeconds(n.getSeconds()); this.setMilliseconds(n.getMilliseconds()); return this; }; /** * Returns a new Date object that is an exact date and time copy of the original instance. * @return {Date} A new Date instance */ $P.clone = function () { return new Date(this.getTime()); }; /** * Compares this instance to a Date object and returns an number indication of their relative values. * @param {Date} Date object to compare [Required] * @return {Number} -1 = this is lessthan date. 0 = values are equal. 1 = this is greaterthan date. */ $P.compareTo = function (date) { return Date.compare(this, date); }; /** * Compares this instance to another Date object and returns true if they are equal. * @param {Date} Date object to compare. If no date to compare, new Date() [now] is used. * @return {Boolean} true if dates are equal. false if they are not equal. */ $P.equals = function (date) { return Date.equals(this, (date !== undefined ? date : new Date())); }; /** * Determines if this instance is between a range of two dates or equal to either the start or end dates. * @param {Date} Start of range [Required] * @param {Date} End of range [Required] * @return {Boolean} true is this is between or equal to the start and end dates, else false */ $P.between = function (start, end) { return this.getTime() >= start.getTime() && this.getTime() <= end.getTime(); }; /** * Determines if this date occurs after the date to compare to. * @param {Date} Date object to compare. If no date to compare, new Date() ("now") is used. * @return {Boolean} true if this date instance is greater than the date to compare to (or "now"), otherwise false. */ $P.isAfter = function (date) { return this.compareTo(date || new Date()) === 1; }; /** * Determines if this date occurs before the date to compare to. * @param {Date} Date object to compare. If no date to compare, new Date() ("now") is used. * @return {Boolean} true if this date instance is less than the date to compare to (or "now"). */ $P.isBefore = function (date) { return (this.compareTo(date || new Date()) === -1); }; /** * Determines if the current Date instance occurs today. * @return {Boolean} true if this date instance is 'today', otherwise false. */ /** * Determines if the current Date instance occurs on the same Date as the supplied 'date'. * If no 'date' to compare to is provided, the current Date instance is compared to 'today'. * @param {date} Date object to compare. If no date to compare, the current Date ("now") is used. * @return {Boolean} true if this Date instance occurs on the same Day as the supplied 'date'. */ $P.isToday = $P.isSameDay = function (date) { return this.clone().clearTime().equals((date || new Date()).clone().clearTime()); }; /** * Adds the specified number of milliseconds to this instance. * @param {Number} The number of milliseconds to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addMilliseconds = function (value) { if (!value) { return this; } this.setTime(this.getTime() + value * 1); return this; }; /** * Adds the specified number of seconds to this instance. * @param {Number} The number of seconds to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addSeconds = function (value) { if (!value) { return this; } return this.addMilliseconds(value * 1000); }; /** * Adds the specified number of seconds to this instance. * @param {Number} The number of seconds to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addMinutes = function (value) { if (!value) { return this; } return this.addMilliseconds(value * 60000); // 60*1000 }; /** * Adds the specified number of hours to this instance. * @param {Number} The number of hours to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addHours = function (value) { if (!value) { return this; } return this.addMilliseconds(value * 3600000); // 60*60*1000 }; /** * Adds the specified number of days to this instance. * @param {Number} The number of days to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addDays = function (value) { if (!value) { return this; } this.setDate(this.getDate() + value * 1); return this; }; /** * Adds the specified number of weekdays (ie - not sat or sun) to this instance. * @param {Number} The number of days to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addWeekdays = function (value) { if (!value) { return this; } var day = this.getDay(); var weeks = (Math.ceil(Math.abs(value)/7)); if (day === 0 || day === 6) { if (value > 0) { this.next().monday(); this.addDays(-1); day = this.getDay(); } } if (value < 0) { while (value < 0) { this.addDays(-1); day = this.getDay(); if (day !== 0 && day !== 6) { value++; } } return this; } else if (value > 5 || (6-day) <= value) { value = value + (weeks * 2); } return this.addDays(value); }; /** * Adds the specified number of weeks to this instance. * @param {Number} The number of weeks to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addWeeks = function (value) { if (!value) { return this; } return this.addDays(value * 7); }; /** * Adds the specified number of months to this instance. * @param {Number} The number of months to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addMonths = function (value) { if (!value) { return this; } var n = this.getDate(); this.setDate(1); this.setMonth(this.getMonth() + value * 1); this.setDate(Math.min(n, $D.getDaysInMonth(this.getFullYear(), this.getMonth()))); return this; }; $P.addQuarters = function (value) { if (!value) { return this; } // note this will take you to the same point in the quarter as you are now. // i.e. - if you are 15 days into the quarter you'll be 15 days into the resulting one. // bonus: this allows adding fractional quarters return this.addMonths(value * 3); }; /** * Adds the specified number of years to this instance. * @param {Number} The number of years to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addYears = function (value) { if (!value) { return this; } return this.addMonths(value * 12); }; /** * Adds (or subtracts) to the value of the years, months, weeks, days, hours, minutes, seconds, milliseconds of the date instance using given configuration object. Positive and Negative values allowed. * Example

	Date.today().add( { days: 1, months: 1 } )

	new Date().add( { years: -1 } )
	
* @param {Object} Configuration object containing attributes (months, days, etc.) * @return {Date} this */ $P.add = function (config) { if (typeof config === "number") { this._orient = config; return this; } var x = config; if (x.day) { // If we should be a different date than today (eg: for 'tomorrow -1d', etc). // Should only effect parsing, not direct usage (eg, Finish and FinishExact) if ((x.day - this.getDate()) !== 0) { this.setDate(x.day); } } if (x.milliseconds) { this.addMilliseconds(x.milliseconds); } if (x.seconds) { this.addSeconds(x.seconds); } if (x.minutes) { this.addMinutes(x.minutes); } if (x.hours) { this.addHours(x.hours); } if (x.weeks) { this.addWeeks(x.weeks); } if (x.months) { this.addMonths(x.months); } if (x.years) { this.addYears(x.years); } if (x.days) { this.addDays(x.days); } return this; }; /** * Get the week number. Week one (1) is the week which contains the first Thursday of the year. Monday is considered the first day of the week. * The .getWeek() function does NOT convert the date to UTC. The local datetime is used. * Please use .getISOWeek() to get the week of the UTC converted date. * @return {Number} 1 to 53 */ $P.getWeek = function (utc) { // Create a copy of this date object var self, target = new Date(this.valueOf()); if (utc) { target.addMinutes(target.getTimezoneOffset()); self = target.clone(); } else { self = this; } // ISO week date weeks start on monday // so correct the day number var dayNr = (self.getDay() + 6) % 7; // ISO 8601 states that week 1 is the week // with the first thursday of that year. // Set the target date to the thursday in the target week target.setDate(target.getDate() - dayNr + 3); // Store the millisecond value of the target date var firstThursday = target.valueOf(); // Set the target to the first thursday of the year // First set the target to january first target.setMonth(0, 1); // Not a thursday? Correct the date to the next thursday if (target.getDay() !== 4) { target.setMonth(0, 1 + ((4 - target.getDay()) + 7) % 7); } // The weeknumber is the number of weeks between the // first thursday of the year and the thursday in the target week return 1 + Math.ceil((firstThursday - target) / 604800000); // 604800000 = 7 * 24 * 3600 * 1000 }; /** * Get the ISO 8601 week number. Week one ("01") is the week which contains the first Thursday of the year. Monday is considered the first day of the week. * The .getISOWeek() function does convert the date to it's UTC value. Please use .getWeek() to get the week of the local date. * @return {String} "01" to "53" */ $P.getISOWeek = function () { return p(this.getWeek(true)); }; /** * Moves the date to Monday of the week set. Week one (1) is the week which contains the first Thursday of the year. * @param {Number} A Number (1 to 53) that represents the week of the year. * @return {Date} this */ $P.setWeek = function (n) { if ((n - this.getWeek()) === 0) { if (this.getDay() !== 1) { return this.moveToDayOfWeek(1, (this.getDay() > 1 ? -1 : 1)); } else { return this; } } else { return this.moveToDayOfWeek(1, (this.getDay() > 1 ? -1 : 1)).addWeeks(n - this.getWeek()); } }; $P.setQuarter = function (qtr) { var month = Math.abs(((qtr-1) * 3) + 1); return this.setMonth(month, 1); }; $P.getQuarter = function () { return Date.getQuarter(this); }; $P.getDaysLeftInQuarter = function () { return Date.getDaysLeftInQuarter(this); }; /** * Moves the date to the next n'th occurrence of the dayOfWeek starting from the beginning of the month. The number (-1) is a magic number and will return the last occurrence of the dayOfWeek in the month. * @param {Number} The dayOfWeek to move to * @param {Number} The n'th occurrence to move to. Use (-1) to return the last occurrence in the month * @return {Date} this */ $P.moveToNthOccurrence = function (dayOfWeek, occurrence) { if (dayOfWeek === "Weekday") { if (occurrence > 0) { this.moveToFirstDayOfMonth(); if (this.is().weekday()) { occurrence -= 1; } } else if (occurrence < 0) { this.moveToLastDayOfMonth(); if (this.is().weekday()) { occurrence += 1; } } else { return this; } return this.addWeekdays(occurrence); } var shift = 0; if (occurrence > 0) { shift = occurrence - 1; } else if (occurrence === -1) { this.moveToLastDayOfMonth(); if (this.getDay() !== dayOfWeek) { this.moveToDayOfWeek(dayOfWeek, -1); } return this; } return this.moveToFirstDayOfMonth().addDays(-1).moveToDayOfWeek(dayOfWeek, +1).addWeeks(shift); }; var moveToN = function (getFunc, addFunc, nVal) { return function (value, orient) { var diff = (value - this[getFunc]() + nVal * (orient || +1)) % nVal; return this[addFunc]((diff === 0) ? diff += nVal * (orient || +1) : diff); }; }; /** * Move to the next or last dayOfWeek based on the orient value. * @param {Number} The dayOfWeek to move to * @param {Number} Forward (+1) or Back (-1). Defaults to +1. [Optional] * @return {Date} this */ $P.moveToDayOfWeek = moveToN("getDay", "addDays", 7); /** * Move to the next or last month based on the orient value. * @param {Number} The month to move to. 0 = January, 11 = December * @param {Number} Forward (+1) or Back (-1). Defaults to +1. [Optional] * @return {Date} this */ $P.moveToMonth = moveToN("getMonth", "addMonths", 12); /** * Get the Ordinate of the current day ("th", "st", "rd"). * @return {String} */ $P.getOrdinate = function () { var num = this.getDate(); return ord(num); }; /** * Get the Ordinal day (numeric day number) of the year, adjusted for leap year. * @return {Number} 1 through 365 (366 in leap years) */ $P.getOrdinalNumber = function () { return Math.ceil((this.clone().clearTime() - new Date(this.getFullYear(), 0, 1)) / 86400000) + 1; }; /** * Get the time zone abbreviation of the current date. * @return {String} The abbreviated time zone name (e.g. "EST") */ $P.getTimezone = function () { return $D.getTimezoneAbbreviation(this.getUTCOffset(), this.isDaylightSavingTime()); }; $P.setTimezoneOffset = function (offset) { var here = this.getTimezoneOffset(), there = Number(offset) * -6 / 10; return (there || there === 0) ? this.addMinutes(there - here) : this; }; $P.setTimezone = function (offset) { return this.setTimezoneOffset($D.getTimezoneOffset(offset)); }; /** * Indicates whether Daylight Saving Time is observed in the current time zone. * @return {Boolean} true|false */ $P.hasDaylightSavingTime = function () { return (Date.today().set({month: 0, day: 1}).getTimezoneOffset() !== Date.today().set({month: 6, day: 1}).getTimezoneOffset()); }; /** * Indicates whether this Date instance is within the Daylight Saving Time range for the current time zone. * @return {Boolean} true|false */ $P.isDaylightSavingTime = function () { return Date.today().set({month: 0, day: 1}).getTimezoneOffset() !== this.getTimezoneOffset(); }; /** * Get the offset from UTC of the current date. * @return {String} The 4-character offset string prefixed with + or - (e.g. "-0500") */ $P.getUTCOffset = function (offset) { var n = (offset || this.getTimezoneOffset()) * -10 / 6, r; if (n < 0) { r = (n - 10000).toString(); return r.charAt(0) + r.substr(2); } else { r = (n + 10000).toString(); return "+" + r.substr(1); } }; /** * Returns the number of milliseconds between this date and date. * @param {Date} Defaults to now * @return {Number} The diff in milliseconds */ $P.getElapsed = function (date) { return (date || new Date()) - this; }; /** * Set the value of year, month, day, hour, minute, second, millisecond of date instance using given configuration object. * Example

	Date.today().set( { day: 20, month: 1 } )

	new Date().set( { millisecond: 0 } )
	
* * @param {Object} Configuration object containing attributes (month, day, etc.) * @return {Date} this */ $P.set = function (config) { config = validateConfigObject.call(this, config); var key; for (key in config) { if (Object.prototype.hasOwnProperty.call(config, key)) { var name = key.charAt(0).toUpperCase() + key.slice(1); var addFunc, getFunc; if (key !== "week" && key !== "month" && key !== "timezone" && key !== "timezoneOffset") { name += "s"; } addFunc = "add" + name; getFunc = "get" + name; if (key === "month") { addFunc = addFunc + "s"; } else if (key === "year"){ getFunc = "getFullYear"; } if (key !== "day" && key !== "timezone" && key !== "timezoneOffset" && key !== "week" && key !== "hour") { this[addFunc](config[key] - this[getFunc]()); } else if ( key === "timezone"|| key === "timezoneOffset" || key === "week" || key === "hour") { this["set"+name](config[key]); } } } // day has to go last because you can't validate the day without first knowing the month if (config.day) { this.addDays(config.day - this.getDate()); } return this; }; /** * Moves the date to the first day of the month. * @return {Date} this */ $P.moveToFirstDayOfMonth = function () { return this.set({ day: 1 }); }; /** * Moves the date to the last day of the month. * @return {Date} this */ $P.moveToLastDayOfMonth = function () { return this.set({ day: $D.getDaysInMonth(this.getFullYear(), this.getMonth())}); }; /** * Converts the value of the current Date object to its equivalent string representation. * Format Specifiers * CUSTOM DATE AND TIME FORMAT STRINGS * Format Description Example * ------ --------------------------------------------------------------------------- ----------------------- * s The seconds of the minute between 0-59. "0" to "59" * ss The seconds of the minute with leading zero if required. "00" to "59" * * m The minute of the hour between 0-59. "0" or "59" * mm The minute of the hour with leading zero if required. "00" or "59" * * h The hour of the day between 1-12. "1" to "12" * hh The hour of the day with leading zero if required. "01" to "12" * * H The hour of the day between 0-23. "0" to "23" * HH The hour of the day with leading zero if required. "00" to "23" * * d The day of the month between 1 and 31. "1" to "31" * dd The day of the month with leading zero if required. "01" to "31" * ddd Abbreviated day name. Date.CultureInfo.abbreviatedDayNames. "Mon" to "Sun" * dddd The full day name. Date.CultureInfo.dayNames. "Monday" to "Sunday" * * M The month of the year between 1-12. "1" to "12" * MM The month of the year with leading zero if required. "01" to "12" * MMM Abbreviated month name. Date.CultureInfo.abbreviatedMonthNames. "Jan" to "Dec" * MMMM The full month name. Date.CultureInfo.monthNames. "January" to "December" * * yy The year as a two-digit number. "99" or "08" * yyyy The full four digit year. "1999" or "2008" * * t Displays the first character of the A.M./P.M. designator. "A" or "P" * Date.CultureInfo.amDesignator or Date.CultureInfo.pmDesignator * tt Displays the A.M./P.M. designator. "AM" or "PM" * Date.CultureInfo.amDesignator or Date.CultureInfo.pmDesignator * * S The ordinal suffix ("st, "nd", "rd" or "th") of the current day. "st, "nd", "rd" or "th" * * STANDARD DATE AND TIME FORMAT STRINGS * Format Description Example *------ --------------------------------------------------------------------------- ----------------------- * d The CultureInfo shortDate Format Pattern "M/d/yyyy" * D The CultureInfo longDate Format Pattern "dddd, MMMM dd, yyyy" * F The CultureInfo fullDateTime Format Pattern "dddd, MMMM dd, yyyy h:mm:ss tt" * m The CultureInfo monthDay Format Pattern "MMMM dd" * r The CultureInfo rfc1123 Format Pattern "ddd, dd MMM yyyy HH:mm:ss GMT" * s The CultureInfo sortableDateTime Format Pattern "yyyy-MM-ddTHH:mm:ss" * t The CultureInfo shortTime Format Pattern "h:mm tt" * T The CultureInfo longTime Format Pattern "h:mm:ss tt" * u The CultureInfo universalSortableDateTime Format Pattern "yyyy-MM-dd HH:mm:ssZ" * y The CultureInfo yearMonth Format Pattern "MMMM, yyyy" * * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @return {String} A string representation of the current Date object. */ var ord = function (n) { switch (n * 1) { case 1: case 21: case 31: return "st"; case 2: case 22: return "nd"; case 3: case 23: return "rd"; default: return "th"; } }; var parseStandardFormats = function (format) { var y, c = Date.CultureInfo.formatPatterns; switch (format) { case "d": return this.toString(c.shortDate); case "D": return this.toString(c.longDate); case "F": return this.toString(c.fullDateTime); case "m": return this.toString(c.monthDay); case "r": case "R": y = this.clone().addMinutes(this.getTimezoneOffset()); return y.toString(c.rfc1123) + " GMT"; case "s": return this.toString(c.sortableDateTime); case "t": return this.toString(c.shortTime); case "T": return this.toString(c.longTime); case "u": y = this.clone().addMinutes(this.getTimezoneOffset()); return y.toString(c.universalSortableDateTime); case "y": return this.toString(c.yearMonth); default: return false; } }; var parseFormatStringsClosure = function (context) { return function (m) { if (m.charAt(0) === "\\") { return m.replace("\\", ""); } switch (m) { case "hh": return p(context.getHours() < 13 ? (context.getHours() === 0 ? 12 : context.getHours()) : (context.getHours() - 12)); case "h": return context.getHours() < 13 ? (context.getHours() === 0 ? 12 : context.getHours()) : (context.getHours() - 12); case "HH": return p(context.getHours()); case "H": return context.getHours(); case "mm": return p(context.getMinutes()); case "m": return context.getMinutes(); case "ss": return p(context.getSeconds()); case "s": return context.getSeconds(); case "yyyy": return p(context.getFullYear(), 4); case "yy": return p(context.getFullYear()); case "y": return context.getFullYear(); case "E": case "dddd": return Date.CultureInfo.dayNames[context.getDay()]; case "ddd": return Date.CultureInfo.abbreviatedDayNames[context.getDay()]; case "dd": return p(context.getDate()); case "d": return context.getDate(); case "MMMM": return Date.CultureInfo.monthNames[context.getMonth()]; case "MMM": return Date.CultureInfo.abbreviatedMonthNames[context.getMonth()]; case "MM": return p((context.getMonth() + 1)); case "M": return context.getMonth() + 1; case "t": return context.getHours() < 12 ? Date.CultureInfo.amDesignator.substring(0, 1) : Date.CultureInfo.pmDesignator.substring(0, 1); case "tt": return context.getHours() < 12 ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator; case "S": return ord(context.getDate()); case "W": return context.getWeek(); case "WW": return context.getISOWeek(); case "Q": return "Q" + context.getQuarter(); case "q": return String(context.getQuarter()); case "z": return context.getTimezone(); case "Z": case "X": return Date.getTimezoneOffset(context.getTimezone()); case "ZZ": // Timezone offset in seconds return context.getTimezoneOffset() * -60; case "u": return context.getDay(); case "L": return ($D.isLeapYear(context.getFullYear())) ? 1 : 0; case "B": // Swatch Internet Time (.beats) return "@"+((context.getUTCSeconds() + (context.getUTCMinutes()*60) + ((context.getUTCHours()+1)*3600))/86.4); default: return m; } }; }; $P.toString = function (format, ignoreStandards) { // Standard Date and Time Format Strings. Formats pulled from CultureInfo file and // may vary by culture. if (!ignoreStandards && format && format.length === 1) { output = parseStandardFormats.call(this, format); if (output) { return output; } } var parseFormatStrings = parseFormatStringsClosure(this); return format ? format.replace(/((\\)?(dd?d?d?|MM?M?M?|yy?y?y?|hh?|HH?|mm?|ss?|tt?|S|q|Q|WW?W?W?)(?![^\[]*\]))/g, parseFormatStrings).replace(/\[|\]/g, "") : this._toString(); }; }()); /************************************************************* * SugarPak - Domain Specific Language - Syntactical Sugar * *************************************************************/ (function () { var $D = Date, $P = $D.prototype, $N = Number.prototype; // private $P._orient = +1; // private $P._nth = null; // private $P._is = false; // private $P._same = false; // private $P._isSecond = false; // private $N._dateElement = "days"; /** * Moves the date to the next instance of a date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.today().next().friday();
	Date.today().next().fri();
	Date.today().next().march();
	Date.today().next().mar();
	Date.today().next().week();
	
* * @return {Date} date */ $P.next = function () { this._move = true; this._orient = +1; return this; }; /** * Creates a new Date (Date.today()) and moves the date to the next instance of the date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.next().friday();
	Date.next().fri();
	Date.next().march();
	Date.next().mar();
	Date.next().week();
	
* * @return {Date} date */ $D.next = function () { return $D.today().next(); }; /** * Moves the date to the previous instance of a date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.today().last().friday();
	Date.today().last().fri();
	Date.today().last().march();
	Date.today().last().mar();
	Date.today().last().week();
	
* * @return {Date} date */ $P.last = $P.prev = $P.previous = function () { this._move = true; this._orient = -1; return this; }; /** * Creates a new Date (Date.today()) and moves the date to the previous instance of the date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.last().friday();
	Date.last().fri();
	Date.previous().march();
	Date.prev().mar();
	Date.last().week();
	
* * @return {Date} date */ $D.last = $D.prev = $D.previous = function () { return $D.today().last(); }; /** * Performs a equality check when followed by either a month name, day name or .weekday() function. * Example

	Date.today().is().friday(); // true|false
	Date.today().is().fri();
	Date.today().is().march();
	Date.today().is().mar();
	
* * @return {Boolean} true|false */ $P.is = function () { this._is = true; return this; }; /** * Determines if two date objects occur on/in exactly the same instance of the subsequent date part function. * The function .same() must be followed by a date part function (example: .day(), .month(), .year(), etc). * * An optional Date can be passed in the date part function. If now date is passed as a parameter, 'Now' is used. * * The following example demonstrates how to determine if two dates fall on the exact same day. * * Example

	var d1 = Date.today(); // today at 00:00
	var d2 = new Date();   // exactly now.

	// Do they occur on the same day?
	d1.same().day(d2); // true
	
	// Do they occur on the same hour?
	d1.same().hour(d2); // false, unless d2 hour is '00' (midnight).
	
	// What if it's the same day, but one year apart?
	var nextYear = Date.today().add(1).year();

	d1.same().day(nextYear); // false, because the dates must occur on the exact same day. 
	
* * Scenario: Determine if a given date occurs during some week period 2 months from now. * * Example

	var future = Date.today().add(2).months();
	return someDate.same().week(future); // true|false;
	
* * @return {Boolean} true|false */ $P.same = function () { this._same = true; this._isSecond = false; return this; }; /** * Determines if the current date/time occurs during Today. Must be preceded by the .is() function. * Example

	someDate.is().today();    // true|false
	new Date().is().today();  // true
	Date.today().is().today();// true
	Date.today().add(-1).day().is().today(); // false
	
* * @return {Boolean} true|false */ $P.today = function () { return this.same().day(); }; /** * Determines if the current date is a weekday. This function must be preceded by the .is() function. * Example

	Date.today().is().weekday(); // true|false
	
* * @return {Boolean} true|false */ $P.weekday = function () { if (this._nth) { return df("Weekday").call(this); } if (this._move) { return this.addWeekdays(this._orient); } if (this._is) { this._is = false; return (!this.is().sat() && !this.is().sun()); } return false; }; /** * Determines if the current date is on the weekend. This function must be preceded by the .is() function. * Example

	Date.today().is().weekend(); // true|false
	
* * @return {Boolean} true|false */ $P.weekend = function () { if (this._is) { this._is = false; return (this.is().sat() || this.is().sun()); } return false; }; /** * Sets the Time of the current Date instance. A string "6:15 pm" or config object {hour:18, minute:15} are accepted. * Example

	// Set time to 6:15pm with a String
	Date.today().at("6:15pm");

	// Set time to 6:15pm with a config object
	Date.today().at({hour:18, minute:15});
	
* * @return {Date} date */ $P.at = function (time) { return (typeof time === "string") ? $D.parse(this.toString("d") + " " + time) : this.set(time); }; /** * Creates a new Date() and adds this (Number) to the date based on the preceding date element function (eg. second|minute|hour|day|month|year). * Example

	// Undeclared Numbers must be wrapped with parentheses. Requirment of JavaScript.
	(3).days().fromNow();
	(6).months().fromNow();

	// Declared Number variables do not require parentheses. 
	var n = 6;
	n.months().fromNow();
	
* * @return {Date} A new Date instance */ $N.fromNow = $N.after = function (date) { var c = {}; c[this._dateElement] = this; return ((!date) ? new Date() : date.clone()).add(c); }; /** * Creates a new Date() and subtract this (Number) from the date based on the preceding date element function (eg. second|minute|hour|day|month|year). * Example

	// Undeclared Numbers must be wrapped with parentheses. Requirment of JavaScript.
	(3).days().ago();
	(6).months().ago();

	// Declared Number variables do not require parentheses. 
	var n = 6;
	n.months().ago();
	
* * @return {Date} A new Date instance */ $N.ago = $N.before = function (date) { var c = {}, s = (this._dateElement[this._dateElement.length-1] !== "s") ? this._dateElement + "s" : this._dateElement; c[s] = this * -1; return ((!date) ? new Date() : date.clone()).add(c); }; // Do NOT modify the following string tokens. These tokens are used to build dynamic functions. // All culture-specific strings can be found in the CultureInfo files. var dx = ("sunday monday tuesday wednesday thursday friday saturday").split(/\s/), mx = ("january february march april may june july august september october november december").split(/\s/), px = ("Millisecond Second Minute Hour Day Week Month Year Quarter Weekday").split(/\s/), pxf = ("Milliseconds Seconds Minutes Hours Date Week Month FullYear Quarter").split(/\s/), nth = ("final first second third fourth fifth").split(/\s/), de; /** * Returns an object literal of all the date parts. * Example

	var o = new Date().toObject();
	
	// { year: 2008, month: 4, week: 20, day: 13, hour: 18, minute: 9, second: 32, millisecond: 812 }
	
	// The object properties can be referenced directly from the object.
	
	alert(o.day);  // alerts "13"
	alert(o.year); // alerts "2008"
	
* * @return {Date} An object literal representing the original date object. */ $P.toObject = function () { var o = {}; for (var i = 0; i < px.length; i++) { if (this["get" + pxf[i]]) { o[px[i].toLowerCase()] = this["get" + pxf[i]](); } } return o; }; /** * Returns a date created from an object literal. Ignores the .week property if set in the config. * Example

	var o = new Date().toObject();
	
	return Date.fromObject(o); // will return the same date. 

	var o2 = {month: 1, day: 20, hour: 18}; // birthday party!
	Date.fromObject(o2);
	
* * @return {Date} An object literal representing the original date object. */ $D.fromObject = function(config) { config.week = null; return Date.today().set(config); }; // Create day name functions and abbreviated day name functions (eg. monday(), friday(), fri()). var df = function (n) { return function () { if (this._is) { this._is = false; return this.getDay() === n; } if (this._move) { this._move = null; } if (this._nth !== null) { // If the .second() function was called earlier, remove the _orient // from the date, and then continue. // This is required because 'second' can be used in two different context. // // Example // // Date.today().add(1).second(); // Date.march().second().monday(); // // Things get crazy with the following... // Date.march().add(1).second().second().monday(); // but it works!! // if (this._isSecond) { this.addSeconds(this._orient * -1); } // make sure we reset _isSecond this._isSecond = false; var ntemp = this._nth; this._nth = null; var temp = this.clone().moveToLastDayOfMonth(); this.moveToNthOccurrence(n, ntemp); if (this > temp) { throw new RangeError($D.getDayName(n) + " does not occur " + ntemp + " times in the month of " + $D.getMonthName(temp.getMonth()) + " " + temp.getFullYear() + "."); } return this; } return this.moveToDayOfWeek(n, this._orient); }; }; var sdf = function (n) { return function () { var t = $D.today(), shift = n - t.getDay(); if (n === 0 && Date.CultureInfo.firstDayOfWeek === 1 && t.getDay() !== 0) { shift = shift + 7; } return t.addDays(shift); }; }; // Create month name functions and abbreviated month name functions (eg. january(), march(), mar()). var month_instance_functions = function (n) { return function () { if (this._is) { this._is = false; return this.getMonth() === n; } return this.moveToMonth(n, this._orient); }; }; var month_static_functions = function (n) { return function () { return $D.today().set({ month: n, day: 1 }); }; }; var processTerms = function (names, staticFunc, instanceFunc) { for (var i = 0; i < names.length; i++) { // Create constant static Name variables. $D[names[i].toUpperCase()] = $D[names[i].toUpperCase().substring(0, 3)] = i; // Create Name functions. $D[names[i]] = $D[names[i].substring(0, 3)] = staticFunc(i); // Create Name instance functions. $P[names[i]] = $P[names[i].substring(0, 3)] = instanceFunc(i); } }; processTerms(dx, sdf, df); processTerms(mx, month_static_functions, month_instance_functions); // Create date element functions and plural date element functions used with Date (eg. day(), days(), months()). var ef = function (j) { return function () { // if the .second() function was called earlier, the _orient // has alread been added. Just return this and reset _isSecond. if (this._isSecond) { this._isSecond = false; return this; } if (this._same) { this._same = this._is = false; var o1 = this.toObject(), o2 = (arguments[0] || new Date()).toObject(), v = "", k = j.toLowerCase(); // the substr trick with -1 doesn't work in IE8 or less k = (k[k.length-1] === "s") ? k.substring(0,k.length-1) : k; for (var m = (px.length - 1); m > -1; m--) { v = px[m].toLowerCase(); if (o1[v] !== o2[v]) { return false; } if (k === v) { break; } } return true; } if (j.substring(j.length - 1) !== "s") { j += "s"; } if (this._move) { this._move = null; } return this["add" + j](this._orient); }; }; var nf = function (n) { return function () { this._dateElement = n; return this; }; }; for (var k = 0; k < px.length; k++) { de = px[k].toLowerCase(); if(de !== "weekday") { // Create date element functions and plural date element functions used with Date (eg. day(), days(), months()). $P[de] = $P[de + "s"] = ef(px[k]); // Create date element functions and plural date element functions used with Number (eg. day(), days(), months()). $N[de] = $N[de + "s"] = nf(de + "s"); } } $P._ss = ef("Second"); var nthfn = function (n) { return function (dayOfWeek) { if (this._same) { return this._ss(arguments[0]); } if (dayOfWeek || dayOfWeek === 0) { return this.moveToNthOccurrence(dayOfWeek, n); } this._nth = n; // if the operator is 'second' add the _orient, then deal with it later... if (n === 2 && (dayOfWeek === undefined || dayOfWeek === null)) { this._isSecond = true; return this.addSeconds(this._orient); } return this; }; }; for (var l = 0; l < nth.length; l++) { $P[nth[l]] = (l === 0) ? nthfn(-1) : nthfn(l); } }()); (function () { "use strict"; Date.Parsing = { Exception: function (s) { this.message = "Parse error at '" + s.substring(0, 10) + " ...'"; } }; var $P = Date.Parsing; var dayOffsets = { standard: [0,31,59,90,120,151,181,212,243,273,304,334], leap: [0,31,60,91,121,152,182,213,244,274,305,335] }; $P.isLeapYear = function(year) { return ((year % 4 === 0) && (year % 100 !== 0)) || (year % 400 === 0); }; var utils = { multiReplace : function (str, hash ) { var key; for (key in hash) { if (Object.prototype.hasOwnProperty.call(hash, key)) { var regex; if (typeof hash[key] === "function") { } else { regex = (hash[key] instanceof RegExp) ? hash[key] : new RegExp(hash[key], "g"); } str = str.replace(regex, key); } } return str; }, getDayOfYearFromWeek : function (obj) { var d, jan4, offset; obj.weekDay = (!obj.weekDay && obj.weekDay !== 0) ? 1 : obj.weekDay; d = new Date(obj.year, 0, 4); jan4 = d.getDay() === 0 ? 7 : d.getDay(); // JS is 0 indexed on Sunday. offset = jan4+3; obj.dayOfYear = ((obj.week * 7) + (obj.weekDay === 0 ? 7 : obj.weekDay))-offset; return obj; }, getDayOfYear : function (obj, dayOffset) { if (!obj.dayOfYear) { obj = utils.getDayOfYearFromWeek(obj); } for (var i=0;i <= dayOffset.length;i++) { if (obj.dayOfYear < dayOffset[i] || i === dayOffset.length) { obj.day = obj.day ? obj.day : (obj.dayOfYear - dayOffset[i-1]); break; } else { obj.month = i; } } return obj; }, adjustForTimeZone : function (obj, date) { var offset; if (obj.zone.toUpperCase() === "Z" || (obj.zone_hours === 0 && obj.zone_minutes === 0)) { // it's UTC/GML so work out the current timeszone offset offset = -date.getTimezoneOffset(); } else { offset = (obj.zone_hours*60) + (obj.zone_minutes || 0); if (obj.zone_sign === "+") { offset *= -1; } offset -= date.getTimezoneOffset(); } date.setMinutes(date.getMinutes()+offset); return date; }, setDefaults : function (obj) { obj.year = obj.year || Date.today().getFullYear(); obj.hours = obj.hours || 0; obj.minutes = obj.minutes || 0; obj.seconds = obj.seconds || 0; obj.milliseconds = obj.milliseconds || 0; if (!(!obj.month && (obj.week || obj.dayOfYear))) { // if we have a month, or if we don't but don't have the day calculation data obj.month = obj.month || 0; obj.day = obj.day || 1; } return obj; }, dataNum: function (data, mod, explict, postProcess) { var dataNum = data*1; if (mod) { if (postProcess) { return data ? mod(data)*1 : data; } else { return data ? mod(dataNum) : data; } } else if (!explict){ return data ? dataNum : data; } else { return (data && typeof data !== "undefined") ? dataNum : data; } }, timeDataProcess: function (obj) { var timeObj = {}; for (var x in obj.data) { if (obj.data.hasOwnProperty(x)) { timeObj[x] = obj.ignore[x] ? obj.data[x] : utils.dataNum(obj.data[x], obj.mods[x], obj.explict[x], obj.postProcess[x]); } } if (obj.data.secmins) { obj.data.secmins = obj.data.secmins.replace(",", ".") * 60; if (!timeObj.minutes) { timeObj.minutes = obj.data.secmins; } else if (!timeObj.seconds) { timeObj.seconds = obj.data.secmins; } delete obj.secmins; } return timeObj; }, buildTimeObjectFromData: function (data) { var time = utils.timeDataProcess({ data: { year : data[1], month : data[5], day : data[7], week : data[8], dayOfYear : data[10], hours : data[15], zone_hours : data[23], zone_minutes : data[24], zone : data[21], zone_sign : data[22], weekDay : data[9], minutes: data[16], seconds: data[19], milliseconds: data[20], secmins: data[18] }, mods: { month: function(data) { return data-1; }, weekDay: function (data) { data = Math.abs(data); return (data === 7 ? 0 : data); }, minutes: function (data) { return data.replace(":",""); }, seconds: function (data) { return Math.floor( (data.replace(":","").replace(",","."))*1 ); }, milliseconds: function (data) { return (data.replace(",",".")*1000); } }, postProcess: { minutes: true, seconds: true, milliseconds: true }, explict: { zone_hours: true, zone_minutes: true }, ignore: { zone: true, zone_sign: true, secmins: true } }); return time; }, addToHash: function (hash, keys, data) { keys = keys; data = data; var len = keys.length; for (var i = 0; i < len; i++) { hash[keys[i]] = data[i]; } return hash; }, combineRegex: function (r1, r2) { return new RegExp("(("+r1.source+")\\s("+r2.source+"))"); }, getDateNthString: function(add, last, inc){ if (add) { return Date.today().addDays(inc).toString("d"); } else if (last) { return Date.today().last()[inc]().toString("d"); } }, buildRegexData: function (array) { var arr = []; var len = array.length; for (var i=0; i < len; i++) { if (Object.prototype.toString.call(array[i]) === '[object Array]') { // oldIE compat version of Array.isArray arr.push(this.combineRegex(array[i][0], array[i][1])); } else { arr.push(array[i]); } } return arr; } }; $P.processTimeObject = function (obj) { var date, dayOffset; utils.setDefaults(obj); dayOffset = ($P.isLeapYear(obj.year)) ? dayOffsets.leap : dayOffsets.standard; if (!obj.month && (obj.week || obj.dayOfYear)) { utils.getDayOfYear(obj, dayOffset); } else { obj.dayOfYear = dayOffset[obj.month] + obj.day; } date = new Date(obj.year, obj.month, obj.day, obj.hours, obj.minutes, obj.seconds, obj.milliseconds); if (obj.zone) { utils.adjustForTimeZone(obj, date); // adjust (and calculate) for timezone } return date; }; $P.ISO = { regex : /^([\+-]?\d{4}(?!\d{2}\b))((-?)((0[1-9]|1[0-2])(\3([12]\d|0[1-9]|3[01]))?|W([0-4]\d|5[0-3])(-?[1-7])?|(00[1-9]|0[1-9]\d|[12]\d{2}|3([0-5]\d|6[1-6])))([T\s]((([01]\d|2[0-4])((:?)[0-5]\d)?|24\:?00)([\.,]\d+(?!:))?)?(\17[0-5]\d([\.,]\d+)?)?\s?([zZ]|([\+-])([01]\d|2[0-3]):?([0-5]\d)?)?)?)?$/, parse : function (s) { var time, data = s.match(this.regex); if (!data || !data.length) { return null; } time = utils.buildTimeObjectFromData(data); if (!time.year || (!time.year && (!time.month && !time.day) && (!time.week && !time.dayOfYear)) ) { return null; } return $P.processTimeObject(time); } }; $P.Numeric = { isNumeric: function (e){return!isNaN(parseFloat(e))&&isFinite(e);}, regex: /\b([0-1]?[0-9])([0-3]?[0-9])([0-2]?[0-9]?[0-9][0-9])\b/i, parse: function (s) { var data, i, time = {}, order = Date.CultureInfo.dateElementOrder.split(""); if (!(this.isNumeric(s)) || // if it's non-numeric OR (s[0] === "+" && s[0] === "-")) { // It's an arithmatic string (eg +/-1000) return null; } if (s.length < 5 && s.indexOf(".") < 0 && s.indexOf("/") < 0) { // assume it's just a year. time.year = s; return $P.processTimeObject(time); } data = s.match(this.regex); if (!data || !data.length) { return null; } for (i=0; i < order.length; i++) { switch(order[i]) { case "d": time.day = data[i+1]; break; case "m": time.month = (data[i+1]-1); break; case "y": time.year = data[i+1]; break; } } return $P.processTimeObject(time); } }; $P.Normalizer = { regexData: function () { var $R = Date.CultureInfo.regexPatterns; return utils.buildRegexData([ $R.tomorrow, $R.yesterday, [$R.past, $R.mon], [$R.past, $R.tue], [$R.past, $R.wed], [$R.past, $R.thu], [$R.past, $R.fri], [$R.past, $R.sat], [$R.past, $R.sun] ]); }, basicReplaceHash : function() { var $R = Date.CultureInfo.regexPatterns; return { "January": $R.jan.source, "February": $R.feb, "March": $R.mar, "April": $R.apr, "May": $R.may, "June": $R.jun, "July": $R.jul, "August": $R.aug, "September": $R.sep, "October": $R.oct, "November": $R.nov, "December": $R.dec, "": /\bat\b/gi, " ": /\s{2,}/, "am": $R.inTheMorning, "9am": $R.thisMorning, "pm": $R.inTheEvening, "7pm":$R.thisEvening }; }, keys : function(){ return [ utils.getDateNthString(true, false, 1), // tomorrow utils.getDateNthString(true, false, -1), // yesterday utils.getDateNthString(false, true, "monday"), //last mon utils.getDateNthString(false, true, "tuesday"), //last tues utils.getDateNthString(false, true, "wednesday"), //last wed utils.getDateNthString(false, true, "thursday"), //last thurs utils.getDateNthString(false, true, "friday"), //last fri utils.getDateNthString(false, true, "saturday"), //last sat utils.getDateNthString(false, true, "sunday") //last sun ]; }, buildRegexFunctions: function () { var $R = Date.CultureInfo.regexPatterns; var __ = Date.i18n.__; var tomorrowRE = new RegExp("(\\b\\d\\d?("+__("AM")+"|"+__("PM")+")? )("+$R.tomorrow.source.slice(1)+")", "i"); // adapted tomorrow regex for AM PM relative dates var todayRE = new RegExp($R.today.source + "(?!\\s*([+-]))\\b"); // today, but excludes the math operators (eg "today + 2h") this.replaceFuncs = [ [todayRE, function (full) { return (full.length > 1) ? Date.today().toString("d") : full; }], [tomorrowRE, function(full, m1) { var t = Date.today().addDays(1).toString("d"); return (t + " " + m1); }], [$R.amThisMorning, function(str, am){return am;}], [$R.pmThisEvening, function(str, pm){return pm;}] ]; }, buildReplaceData: function () { this.buildRegexFunctions(); this.replaceHash = utils.addToHash(this.basicReplaceHash(), this.keys(), this.regexData()); }, stringReplaceFuncs: function (s) { for (var i=0; i < this.replaceFuncs.length; i++) { s = s.replace(this.replaceFuncs[i][0], this.replaceFuncs[i][1]); } return s; }, parse: function (s) { s = this.stringReplaceFuncs(s); s = utils.multiReplace(s, this.replaceHash); try { var n = s.split(/([\s\-\.\,\/\x27]+)/); if (n.length === 3 && $P.Numeric.isNumeric(n[0]) && $P.Numeric.isNumeric(n[2]) && (n[2].length >= 4)) { // ok, so we're dealing with x/year. But that's not a full date. // This fixes wonky dateElementOrder parsing when set to dmy order. if (Date.CultureInfo.dateElementOrder[0] === "d") { s = "1/" + n[0] + "/" + n[2]; // set to 1st of month and normalize the seperator } } } catch (e) {} return s; } }; $P.Normalizer.buildReplaceData(); }()); (function () { var $P = Date.Parsing; var _ = $P.Operators = { // // Tokenizers // rtoken: function (r) { // regex token return function (s) { var mx = s.match(r); if (mx) { return ([ mx[0], s.substring(mx[0].length) ]); } else { throw new $P.Exception(s); } }; }, token: function () { // whitespace-eating token return function (s) { return _.rtoken(new RegExp("^\\s*" + s + "\\s*"))(s); }; }, stoken: function (s) { // string token return _.rtoken(new RegExp("^" + s)); }, // Atomic Operators until: function (p) { return function (s) { var qx = [], rx = null; while (s.length) { try { rx = p.call(this, s); } catch (e) { qx.push(rx[0]); s = rx[1]; continue; } break; } return [ qx, s ]; }; }, many: function (p) { return function (s) { var rx = [], r = null; while (s.length) { try { r = p.call(this, s); } catch (e) { return [ rx, s ]; } rx.push(r[0]); s = r[1]; } return [ rx, s ]; }; }, // generator operators -- see below optional: function (p) { return function (s) { var r = null; try { r = p.call(this, s); } catch (e) { return [ null, s ]; } return [ r[0], r[1] ]; }; }, not: function (p) { return function (s) { try { p.call(this, s); } catch (e) { return [null, s]; } throw new $P.Exception(s); }; }, ignore: function (p) { return p ? function (s) { var r = null; r = p.call(this, s); return [null, r[1]]; } : null; }, product: function () { var px = arguments[0], qx = Array.prototype.slice.call(arguments, 1), rx = []; for (var i = 0 ; i < px.length ; i++) { rx.push(_.each(px[i], qx)); } return rx; }, cache: function (rule) { var cache = {}, cache_length = 0, cache_keys = [], CACHE_MAX = Date.Config.CACHE_MAX || 100000, r = null; var cacheCheck = function () { if (cache_length === CACHE_MAX) { // kill several keys, don't want to have to do this all the time... for (var i=0; i < 10; i++) { var key = cache_keys.shift(); if (key) { delete cache[key]; cache_length--; } } } }; return function (s) { cacheCheck(); try { r = cache[s] = (cache[s] || rule.call(this, s)); } catch (e) { r = cache[s] = e; } cache_length++; cache_keys.push(s); if (r instanceof $P.Exception) { throw r; } else { return r; } }; }, // vector operators -- see below any: function () { var px = arguments; return function (s) { var r = null; for (var i = 0; i < px.length; i++) { if (px[i] == null) { continue; } try { r = (px[i].call(this, s)); } catch (e) { r = null; } if (r) { return r; } } throw new $P.Exception(s); }; }, each: function () { var px = arguments; return function (s) { var rx = [], r = null; for (var i = 0; i < px.length ; i++) { if (px[i] == null) { continue; } try { r = (px[i].call(this, s)); } catch (e) { throw new $P.Exception(s); } rx.push(r[0]); s = r[1]; } return [ rx, s]; }; }, all: function () { var px = arguments, _ = _; return _.each(_.optional(px)); }, // delimited operators sequence: function (px, d, c) { d = d || _.rtoken(/^\s*/); c = c || null; if (px.length === 1) { return px[0]; } return function (s) { var r = null, q = null; var rx = []; for (var i = 0; i < px.length ; i++) { try { r = px[i].call(this, s); } catch (e) { break; } rx.push(r[0]); try { q = d.call(this, r[1]); } catch (ex) { q = null; break; } s = q[1]; } if (!r) { throw new $P.Exception(s); } if (q) { throw new $P.Exception(q[1]); } if (c) { try { r = c.call(this, r[1]); } catch (ey) { throw new $P.Exception(r[1]); } } return [ rx, (r?r[1]:s) ]; }; }, // // Composite Operators // between: function (d1, p, d2) { d2 = d2 || d1; var _fn = _.each(_.ignore(d1), p, _.ignore(d2)); return function (s) { var rx = _fn.call(this, s); return [[rx[0][0], r[0][2]], rx[1]]; }; }, list: function (p, d, c) { d = d || _.rtoken(/^\s*/); c = c || null; return (p instanceof Array ? _.each(_.product(p.slice(0, -1), _.ignore(d)), p.slice(-1), _.ignore(c)) : _.each(_.many(_.each(p, _.ignore(d))), px, _.ignore(c))); }, set: function (px, d, c) { d = d || _.rtoken(/^\s*/); c = c || null; return function (s) { // r is the current match, best the current 'best' match // which means it parsed the most amount of input var r = null, p = null, q = null, rx = null, best = [[], s], last = false; // go through the rules in the given set for (var i = 0; i < px.length ; i++) { // last is a flag indicating whether this must be the last element // if there is only 1 element, then it MUST be the last one q = null; p = null; r = null; last = (px.length === 1); // first, we try simply to match the current pattern // if not, try the next pattern try { r = px[i].call(this, s); } catch (e) { continue; } // since we are matching against a set of elements, the first // thing to do is to add r[0] to matched elements rx = [[r[0]], r[1]]; // if we matched and there is still input to parse and // we don't already know this is the last element, // we're going to next check for the delimiter ... // if there's none, or if there's no input left to parse // than this must be the last element after all ... if (r[1].length > 0 && ! last) { try { q = d.call(this, r[1]); } catch (ex) { last = true; } } else { last = true; } // if we parsed the delimiter and now there's no more input, // that means we shouldn't have parsed the delimiter at all // so don't update r and mark this as the last element ... if (!last && q[1].length === 0) { last = true; } // so, if this isn't the last element, we're going to see if // we can get any more matches from the remaining (unmatched) // elements ... if (!last) { // build a list of the remaining rules we can match against, // i.e., all but the one we just matched against var qx = []; for (var j = 0; j < px.length ; j++) { if (i !== j) { qx.push(px[j]); } } // now invoke recursively set with the remaining input // note that we don't include the closing delimiter ... // we'll check for that ourselves at the end p = _.set(qx, d).call(this, q[1]); // if we got a non-empty set as a result ... // (otw rx already contains everything we want to match) if (p[0].length > 0) { // update current result, which is stored in rx ... // basically, pick up the remaining text from p[1] // and concat the result from p[0] so that we don't // get endless nesting ... rx[0] = rx[0].concat(p[0]); rx[1] = p[1]; } } // at this point, rx either contains the last matched element // or the entire matched set that starts with this element. // now we just check to see if this variation is better than // our best so far, in terms of how much of the input is parsed if (rx[1].length < best[1].length) { best = rx; } // if we've parsed all the input, then we're finished if (best[1].length === 0) { break; } } // so now we've either gone through all the patterns trying them // as the initial match; or we found one that parsed the entire // input string ... // if best has no matches, just return empty set ... if (best[0].length === 0) { return best; } // if a closing delimiter is provided, then we have to check it also if (c) { // we try this even if there is no remaining input because the pattern // may well be optional or match empty input ... try { q = c.call(this, best[1]); } catch (ey) { throw new $P.Exception(best[1]); } // it parsed ... be sure to update the best match remaining input best[1] = q[1]; } // if we're here, either there was no closing delimiter or we parsed it // so now we have the best match; just return it! return best; }; }, forward: function (gr, fname) { return function (s) { return gr[fname].call(this, s); }; }, // // Translation Operators // replace: function (rule, repl) { return function (s) { var r = rule.call(this, s); return [repl, r[1]]; }; }, process: function (rule, fn) { return function (s) { var r = rule.call(this, s); return [fn.call(this, r[0]), r[1]]; }; }, min: function (min, rule) { return function (s) { var rx = rule.call(this, s); if (rx[0].length < min) { throw new $P.Exception(s); } return rx; }; } }; // Generator Operators And Vector Operators // Generators are operators that have a signature of F(R) => R, // taking a given rule and returning another rule, such as // ignore, which parses a given rule and throws away the result. // Vector operators are those that have a signature of F(R1,R2,...) => R, // take a list of rules and returning a new rule, such as each. // Generator operators are converted (via the following _generator // function) into functions that can also take a list or array of rules // and return an array of new rules as though the function had been // called on each rule in turn (which is what actually happens). // This allows generators to be used with vector operators more easily. // Example: // each(ignore(foo, bar)) instead of each(ignore(foo), ignore(bar)) // This also turns generators into vector operators, which allows // constructs like: // not(cache(foo, bar)) var _generator = function (op) { function gen() { var args = null, rx = [], px, i; if (arguments.length > 1) { args = Array.prototype.slice.call(arguments); } else if (arguments[0] instanceof Array) { args = arguments[0]; } if (args) { px = args.shift(); if (px.length > 0) { args.unshift(px[i]); rx.push(op.apply(null, args)); args.shift(); return rx; } } else { return op.apply(null, arguments); } } return gen; }; var gx = "optional not ignore cache".split(/\s/); for (var i = 0 ; i < gx.length ; i++) { _[gx[i]] = _generator(_[gx[i]]); } var _vector = function (op) { return function () { if (arguments[0] instanceof Array) { return op.apply(null, arguments[0]); } else { return op.apply(null, arguments); } }; }; var vx = "each any all".split(/\s/); for (var j = 0 ; j < vx.length ; j++) { _[vx[j]] = _vector(_[vx[j]]); } }()); (function () { var $D = Date; var flattenAndCompact = function (ax) { var rx = []; for (var i = 0; i < ax.length; i++) { if (ax[i] instanceof Array) { rx = rx.concat(flattenAndCompact(ax[i])); } else { if (ax[i]) { rx.push(ax[i]); } } } return rx; }; var parseMeridian = function () { if (this.meridian && (this.hour || this.hour === 0)) { if (this.meridian === "a" && this.hour > 11 && Date.Config.strict24hr){ throw "Invalid hour and meridian combination"; } else if (this.meridian === "p" && this.hour < 12 && Date.Config.strict24hr){ throw "Invalid hour and meridian combination"; } else if (this.meridian === "p" && this.hour < 12) { this.hour = this.hour + 12; } else if (this.meridian === "a" && this.hour === 12) { this.hour = 0; } } }; var setDefaults = function () { var now = new Date(); if ((this.hour || this.minute) && (!this.month && !this.year && !this.day)) { this.day = now.getDate(); } if (!this.year) { this.year = now.getFullYear(); } if (!this.month && this.month !== 0) { this.month = now.getMonth(); } if (!this.day) { this.day = 1; } if (!this.hour) { this.hour = 0; } if (!this.minute) { this.minute = 0; } if (!this.second) { this.second = 0; } if (!this.millisecond) { this.millisecond = 0; } }; var finishUtils = { getToday: function () { if (this.now || "hour minute second".indexOf(this.unit) !== -1) { return new Date(); } else { return $D.today(); } }, setDaysFromWeekday: function (today, orient){ var gap; orient = orient || 1; this.unit = "day"; gap = ($D.getDayNumberFromName(this.weekday) - today.getDay()); this.days = gap ? ((gap + (orient * 7)) % 7) : (orient * 7); return this; }, setMonthsFromMonth: function (today, orient) { var gap; orient = orient || 1; this.unit = "month"; gap = (this.month - today.getMonth()); this.months = gap ? ((gap + (orient * 12)) % 12) : (orient * 12); this.month = null; return this; }, setDMYFromWeekday: function () { var d = Date[this.weekday](); this.day = d.getDate(); if (!this.month) { this.month = d.getMonth(); } this.year = d.getFullYear(); return this; }, setUnitValue: function (orient) { if (!this.value && this.operator && this.operator !== null && this[this.unit + "s"] && this[this.unit + "s"] !== null) { this[this.unit + "s"] = this[this.unit + "s"] + ((this.operator === "add") ? 1 : -1) + (this.value||0) * orient; } else if (this[this.unit + "s"] == null || this.operator != null) { if (!this.value) { this.value = 1; } this[this.unit + "s"] = this.value * orient; } }, generateDateFromWeeks: function () { var weekday = (this.weekday !== undefined) ? this.weekday : "today"; var d = Date[weekday]().addWeeks(this.weeks); if (this.now) { d.setTimeToNow(); } return d; } }; $D.Translator = { hour: function (s) { return function () { this.hour = Number(s); }; }, minute: function (s) { return function () { this.minute = Number(s); }; }, second: function (s) { return function () { this.second = Number(s); }; }, /* for ss.s format */ secondAndMillisecond: function (s) { return function () { var mx = s.match(/^([0-5][0-9])\.([0-9]{1,3})/); this.second = Number(mx[1]); this.millisecond = Number(mx[2]); }; }, meridian: function (s) { return function () { this.meridian = s.slice(0, 1).toLowerCase(); }; }, timezone: function (s) { return function () { var n = s.replace(/[^\d\+\-]/g, ""); if (n.length) { this.timezoneOffset = Number(n); } else { this.timezone = s.toLowerCase(); } }; }, day: function (x) { var s = x[0]; return function () { this.day = Number(s.match(/\d+/)[0]); if (this.day < 1) { throw "invalid day"; } }; }, month: function (s) { return function () { this.month = (s.length === 3) ? "jan feb mar apr may jun jul aug sep oct nov dec".indexOf(s)/4 : Number(s) - 1; if (this.month < 0) { throw "invalid month"; } }; }, year: function (s) { return function () { var n = Number(s); this.year = ((s.length > 2) ? n : (n + (((n + 2000) < Date.CultureInfo.twoDigitYearMax) ? 2000 : 1900))); }; }, rday: function (s) { return function () { switch (s) { case "yesterday": this.days = -1; break; case "tomorrow": this.days = 1; break; case "today": this.days = 0; break; case "now": this.days = 0; this.now = true; break; } }; }, finishExact: function (x) { var d; x = (x instanceof Array) ? x : [x]; for (var i = 0 ; i < x.length ; i++) { if (x[i]) { x[i].call(this); } } setDefaults.call(this); parseMeridian.call(this); if (this.day > $D.getDaysInMonth(this.year, this.month)) { throw new RangeError(this.day + " is not a valid value for days."); } d = new Date(this.year, this.month, this.day, this.hour, this.minute, this.second, this.millisecond); if (this.year < 100) { d.setFullYear(this.year); // means years less that 100 are process correctly. JS will parse it otherwise as 1900-1999. } if (this.timezone) { d.set({ timezone: this.timezone }); } else if (this.timezoneOffset) { d.set({ timezoneOffset: this.timezoneOffset }); } return d; }, finish: function (x) { var today, expression, orient, temp; x = (x instanceof Array) ? flattenAndCompact(x) : [ x ]; if (x.length === 0) { return null; } for (var i = 0 ; i < x.length ; i++) { if (typeof x[i] === "function") { x[i].call(this); } } if (this.now && !this.unit && !this.operator) { return new Date(); } else { today = finishUtils.getToday.call(this); } expression = !!(this.days && this.days !== null || this.orient || this.operator); orient = ((this.orient === "past" || this.operator === "subtract") ? -1 : 1); if (this.month && this.unit === "week") { this.value = this.month + 1; delete this.month; delete this.day; } if ((this.month || this.month === 0) && "year day hour minute second".indexOf(this.unit) !== -1) { if (!this.value) { this.value = this.month + 1; } this.month = null; expression = true; } if (!expression && this.weekday && !this.day && !this.days) { finishUtils.setDMYFromWeekday.call(this); } if (expression && this.weekday && this.unit !== "month" && this.unit !== "week") { finishUtils.setDaysFromWeekday.call(this, today, orient); } if (this.weekday && this.unit !== "week" && !this.day && !this.days) { temp = Date[this.weekday](); this.day = temp.getDate(); if (temp.getMonth() !== today.getMonth()) { this.month = temp.getMonth(); } } if (this.month && this.unit === "day" && this.operator) { if (!this.value) { this.value = (this.month + 1); } this.month = null; } if (this.value != null && this.month != null && this.year != null) { this.day = this.value * 1; } if (this.month && !this.day && this.value) { today.set({ day: this.value * 1 }); if (!expression) { this.day = this.value * 1; } } if (!this.month && this.value && this.unit === "month" && !this.now) { this.month = this.value; expression = true; } if (expression && (this.month || this.month === 0) && this.unit !== "year") { finishUtils.setMonthsFromMonth.call(this, today, orient); } if (!this.unit) { this.unit = "day"; } finishUtils.setUnitValue.call(this, orient); parseMeridian.call(this); if ((this.month || this.month === 0) && !this.day) { this.day = 1; } if (!this.orient && !this.operator && this.unit === "week" && this.value && !this.day && !this.month) { return Date.today().setWeek(this.value); } if (this.unit === "week" && this.weeks && !this.day && !this.month) { return finishUtils.generateDateFromWeeks.call(this); } if (expression && this.timezone && this.day && this.days) { this.day = this.days; } if (expression){ today.add(this); } else { today.set(this); } if (this.timezone) { this.timezone = this.timezone.toUpperCase(); var offset = $D.getTimezoneOffset(this.timezone); var timezone; if (today.hasDaylightSavingTime()) { // lets check that we're being sane with timezone setting timezone = $D.getTimezoneAbbreviation(offset, today.isDaylightSavingTime()); if (timezone !== this.timezone) { // bugger, we're in a place where things like EST vs EDT matters. if (today.isDaylightSavingTime()) { today.addHours(-1); } else { today.addHours(1); } } } today.setTimezoneOffset(offset); } return today; } }; }()); (function () { var $D = Date; $D.Grammar = {}; var _ = $D.Parsing.Operators, g = $D.Grammar, t = $D.Translator, _fn; // Allow rolling up into general purpose rules _fn = function () { return _.each(_.any.apply(null, arguments), _.not(g.ctoken2("timeContext"))); }; g.datePartDelimiter = _.rtoken(/^([\s\-\.\,\/\x27]+)/); g.timePartDelimiter = _.stoken(":"); g.whiteSpace = _.rtoken(/^\s*/); g.generalDelimiter = _.rtoken(/^(([\s\,]|at|@|on)+)/); var _C = {}; g.ctoken = function (keys) { var fn = _C[keys]; if (! fn) { var c = Date.CultureInfo.regexPatterns; var kx = keys.split(/\s+/), px = []; for (var i = 0; i < kx.length ; i++) { px.push(_.replace(_.rtoken(c[kx[i]]), kx[i])); } fn = _C[keys] = _.any.apply(null, px); } return fn; }; g.ctoken2 = function (key) { return _.rtoken(Date.CultureInfo.regexPatterns[key]); }; var cacheProcessRtoken = function (key, token, type, eachToken) { if (eachToken) { g[key] = _.cache(_.process(_.each(_.rtoken(token),_.optional(g.ctoken2(eachToken))), type)); } else { g[key] = _.cache(_.process(_.rtoken(token), type)); } }; var cacheProcessCtoken = function (token, type) { return _.cache(_.process(g.ctoken2(token), type)); }; var _F = {}; //function cache var _get = function (f) { _F[f] = (_F[f] || g.format(f)[0]); return _F[f]; }; g.allformats = function (fx) { var rx = []; if (fx instanceof Array) { for (var i = 0; i < fx.length; i++) { rx.push(_get(fx[i])); } } else { rx.push(_get(fx)); } return rx; }; g.formats = function (fx) { if (fx instanceof Array) { var rx = []; for (var i = 0 ; i < fx.length ; i++) { rx.push(_get(fx[i])); } return _.any.apply(null, rx); } else { return _get(fx); } }; var grammarFormats = { timeFormats: function(){ var i, RTokenKeys = [ "h", "hh", "H", "HH", "m", "mm", "s", "ss", "ss.s", "z", "zz" ], RToken = [ /^(0[0-9]|1[0-2]|[1-9])/, /^(0[0-9]|1[0-2])/, /^([0-1][0-9]|2[0-3]|[0-9])/, /^([0-1][0-9]|2[0-3])/, /^([0-5][0-9]|[0-9])/, /^[0-5][0-9]/, /^([0-5][0-9]|[0-9])/, /^[0-5][0-9]/, /^[0-5][0-9]\.[0-9]{1,3}/, /^((\+|\-)\s*\d\d\d\d)|((\+|\-)\d\d\:?\d\d)/, /^((\+|\-)\s*\d\d\d\d)|((\+|\-)\d\d\:?\d\d)/ ], tokens = [ t.hour, t.hour, t.hour, t.hour, t.minute, t.minute, t.second, t.second, t.secondAndMillisecond, t.timezone, t.timezone ]; for (i=0; i < RTokenKeys.length; i++) { cacheProcessRtoken(RTokenKeys[i], RToken[i], tokens[i]); } g.hms = _.cache(_.sequence([g.H, g.m, g.s], g.timePartDelimiter)); g.t = cacheProcessCtoken("shortMeridian", t.meridian); g.tt = cacheProcessCtoken("longMeridian", t.meridian); g.zzz = cacheProcessCtoken("timezone", t.timezone); g.timeSuffix = _.each(_.ignore(g.whiteSpace), _.set([ g.tt, g.zzz ])); g.time = _.each(_.optional(_.ignore(_.stoken("T"))), g.hms, g.timeSuffix); }, dateFormats: function () { // pre-loaded rules for different date part order preferences var _setfn = function () { return _.set(arguments, g.datePartDelimiter); }; var i, RTokenKeys = [ "d", "dd", "M", "MM", "y", "yy", "yyy", "yyyy" ], RToken = [ /^([0-2]\d|3[0-1]|\d)/, /^([0-2]\d|3[0-1])/, /^(1[0-2]|0\d|\d)/, /^(1[0-2]|0\d)/, /^(\d+)/, /^(\d\d)/, /^(\d\d?\d?\d?)/, /^(\d\d\d\d)/ ], tokens = [ t.day, t.day, t.month, t.month, t.year, t.year, t.year, t.year ], eachToken = [ "ordinalSuffix", "ordinalSuffix" ]; for (i=0; i < RTokenKeys.length; i++) { cacheProcessRtoken(RTokenKeys[i], RToken[i], tokens[i], eachToken[i]); } g.MMM = g.MMMM = _.cache(_.process(g.ctoken("jan feb mar apr may jun jul aug sep oct nov dec"), t.month)); g.ddd = g.dddd = _.cache(_.process(g.ctoken("sun mon tue wed thu fri sat"), function (s) { return function () { this.weekday = s; }; } )); g.day = _fn(g.d, g.dd); g.month = _fn(g.M, g.MMM); g.year = _fn(g.yyyy, g.yy); g.mdy = _setfn(g.ddd, g.month, g.day, g.year); g.ymd = _setfn(g.ddd, g.year, g.month, g.day); g.dmy = _setfn(g.ddd, g.day, g.month, g.year); g.date = function (s) { return ((g[Date.CultureInfo.dateElementOrder] || g.mdy).call(this, s)); }; }, relative: function () { // relative date / time expressions g.orientation = _.process(g.ctoken("past future"), function (s) { return function () { this.orient = s; }; } ); g.operator = _.process(g.ctoken("add subtract"), function (s) { return function () { this.operator = s; }; } ); g.rday = _.process(g.ctoken("yesterday tomorrow today now"), t.rday); g.unit = _.process(g.ctoken("second minute hour day week month year"), function (s) { return function () { this.unit = s; }; } ); } }; g.buildGrammarFormats = function () { // these need to be rebuilt every time the language changes. _C = {}; grammarFormats.timeFormats(); grammarFormats.dateFormats(); grammarFormats.relative(); g.value = _.process(_.rtoken(/^([-+]?\d+)?(st|nd|rd|th)?/), function (s) { return function () { this.value = s.replace(/\D/g, ""); }; } ); g.expression = _.set([g.rday, g.operator, g.value, g.unit, g.orientation, g.ddd, g.MMM ]); g.format = _.process(_.many( _.any( // translate format specifiers into grammar rules _.process( _.rtoken(/^(dd?d?d?(?!e)|MM?M?M?|yy?y?y?|hh?|HH?|mm?|ss?|tt?|zz?z?)/), function (fmt) { if (g[fmt]) { return g[fmt]; } else { throw $D.Parsing.Exception(fmt); } } ), // translate separator tokens into token rules _.process(_.rtoken(/^[^dMyhHmstz]+/), // all legal separators function (s) { return _.ignore(_.stoken(s)); } ) ) ), // construct the parser ... function (rules) { return _.process(_.each.apply(null, rules), t.finishExact); } ); // starting rule for general purpose grammar g._start = _.process(_.set([ g.date, g.time, g.expression ], g.generalDelimiter, g.whiteSpace), t.finish); }; g.buildGrammarFormats(); // parsing date format specifiers - ex: "h:m:s tt" // this little guy will generate a custom parser based // on the format string, ex: g.format("h:m:s tt") // check for these formats first g._formats = g.formats([ "\"yyyy-MM-ddTHH:mm:ssZ\"", "yyyy-MM-ddTHH:mm:ss.sz", "yyyy-MM-ddTHH:mm:ssZ", "yyyy-MM-ddTHH:mm:ssz", "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-ddTHH:mmZ", "yyyy-MM-ddTHH:mmz", "yyyy-MM-ddTHH:mm", "ddd, MMM dd, yyyy H:mm:ss tt", "ddd MMM d yyyy HH:mm:ss zzz", "MMddyyyy", "ddMMyyyy", "Mddyyyy", "ddMyyyy", "Mdyyyy", "dMyyyy", "yyyy", "Mdyy", "dMyy", "d" ]); // real starting rule: tries selected formats first, // then general purpose rule g.start = function (s) { try { var r = g._formats.call({}, s); if (r[1].length === 0) { return r; } } catch (e) {} return g._start.call({}, s); }; }()); (function () { var $D = Date; /** * @desc Converts the specified string value into its JavaScript Date equivalent using CultureInfo specific format information. * * Example

	///////////
	// Dates //
	///////////

	// 15-Oct-2004
	var d1 = Date.parse("10/15/2004");

	// 15-Oct-2004
	var d1 = Date.parse("15-Oct-2004");

	// 15-Oct-2004
	var d1 = Date.parse("2004.10.15");

	//Fri Oct 15, 2004
	var d1 = Date.parse("Fri Oct 15, 2004");

	///////////
	// Times //
	///////////

	// Today at 10 PM.
	var d1 = Date.parse("10 PM");

	// Today at 10:30 PM.
	var d1 = Date.parse("10:30 P.M.");

	// Today at 6 AM.
	var d1 = Date.parse("06am");

	/////////////////////
	// Dates and Times //
	/////////////////////

	// 8-July-2004 @ 10:30 PM
	var d1 = Date.parse("July 8th, 2004, 10:30 PM");

	// 1-July-2004 @ 10:30 PM
	var d1 = Date.parse("2004-07-01T22:30:00");

	////////////////////
	// Relative Dates //
	////////////////////

	// Returns today's date. The string "today" is culture specific.
	var d1 = Date.parse("today");

	// Returns yesterday's date. The string "yesterday" is culture specific.
	var d1 = Date.parse("yesterday");

	// Returns the date of the next thursday.
	var d1 = Date.parse("Next thursday");

	// Returns the date of the most previous monday.
	var d1 = Date.parse("last monday");

	// Returns today's day + one year.
	var d1 = Date.parse("next year");

	///////////////
	// Date Math //
	///////////////

	// Today + 2 days
	var d1 = Date.parse("t+2");

	// Today + 2 days
	var d1 = Date.parse("today + 2 days");

	// Today + 3 months
	var d1 = Date.parse("t+3m");

	// Today - 1 year
	var d1 = Date.parse("today - 1 year");

	// Today - 1 year
	var d1 = Date.parse("t-1y"); 


	/////////////////////////////
	// Partial Dates and Times //
	/////////////////////////////

	// July 15th of this year.
	var d1 = Date.parse("July 15");

	// 15th day of current day and year.
	var d1 = Date.parse("15");

	// July 1st of current year at 10pm.
	var d1 = Date.parse("7/1 10pm");
	
* * @param {String} The string value to convert into a Date object [Required] * @return {Date} A Date object or null if the string cannot be converted into a Date. */ var parseUtils = { removeOrds: function (s) { ords = s.match(/\b(\d+)(?:st|nd|rd|th)\b/); // find ordinal matches s = ((ords && ords.length === 2) ? s.replace(ords[0], ords[1]) : s); return s; }, grammarParser: function (s) { var r = null; try { r = $D.Grammar.start.call({}, s.replace(/^\s*(\S*(\s+\S+)*)\s*$/, "$1")); } catch (e) { return null; } return ((r[1].length === 0) ? r[0] : null); }, nativeFallback: function(s) { var t; try { // ok we haven't parsed it, last ditch attempt with the built-in parser. t = Date._parse(s); return (t || t === 0) ? new Date(t) : null; } catch (e) { return null; } } }; function parse (s) { var d; if (!s) { return null; } if (s instanceof Date) { return s.clone(); } if (s.length >= 4 && s.charAt(0) !== "0" && s.charAt(0) !== "+"&& s.charAt(0) !== "-") { // ie: 2004 will pass, 0800 won't. // Start with specific formats d = $D.Parsing.ISO.parse(s) || $D.Parsing.Numeric.parse(s); } if (d instanceof Date && !isNaN(d.getTime())) { return d; } else { // find ordinal dates (1st, 3rd, 8th, etc and remove them as they cause parsing issues) s = $D.Parsing.Normalizer.parse(parseUtils.removeOrds(s)); d = parseUtils.grammarParser(s); if (d !== null) { return d; } else { return parseUtils.nativeFallback(s); } } } if (!$D._parse) { $D._parse = $D.parse; } $D.parse = parse; Date.getParseFunction = function (fx) { var fns = Date.Grammar.allformats(fx); return function (s) { var r = null; for (var i = 0; i < fns.length; i++) { try { r = fns[i].call({}, s); } catch (e) { continue; } if (r[1].length === 0) { return r[0]; } } return null; }; }; /** * Converts the specified string value into its JavaScript Date equivalent using the specified format {String} or formats {Array} and the CultureInfo specific format information. * The format of the string value must match one of the supplied formats exactly. * * Example

	// 15-Oct-2004
	var d1 = Date.parseExact("10/15/2004", "M/d/yyyy");

	// 15-Oct-2004
	var d1 = Date.parse("15-Oct-2004", "M-ddd-yyyy");

	// 15-Oct-2004
	var d1 = Date.parse("2004.10.15", "yyyy.MM.dd");

	// Multiple formats
	var d1 = Date.parseExact("10/15/2004", ["M/d/yyyy", "MMMM d, yyyy"]);
	
* * @param {String} The string value to convert into a Date object [Required]. * @param {Object} The expected format {String} or an array of expected formats {Array} of the date string [Required]. * @return {Date} A Date object or null if the string cannot be converted into a Date. */ $D.parseExact = function (s, fx) { return $D.getParseFunction(fx)(s); }; }()); (function () { var $D = Date, $P = $D.prototype, // $C = $D.CultureInfo, // not used atm p = function (s, l) { if (!l) { l = 2; } return ("000" + s).slice(l * -1); }; /** * Converts a PHP format string to Java/.NET format string. * A PHP format string can be used with ._format or .format. * A Java/.NET format string can be used with .toString(). * The .parseExact function will only accept a Java/.NET format string * * Example * var f1 = "%m/%d/%y" * var f2 = Date.normalizeFormat(f1); // "MM/dd/yy" * * new Date().format(f1); // "04/13/08" * new Date()._format(f1); // "04/13/08" * new Date().toString(f2); // "04/13/08" * * var date = Date.parseExact("04/13/08", f2); // Sun Apr 13 2008 * * @param {String} A PHP format string consisting of one or more format spcifiers. * @return {String} The PHP format converted to a Java/.NET format string. */ var normalizerSubstitutions = { "d" : "dd", "%d": "dd", "D" : "ddd", "%a": "ddd", "j" : "dddd", "l" : "dddd", "%A": "dddd", "S" : "S", "F" : "MMMM", "%B": "MMMM", "m" : "MM", "%m": "MM", "M" : "MMM", "%b": "MMM", "%h": "MMM", "n" : "M", "Y" : "yyyy", "%Y": "yyyy", "y" : "yy", "%y": "yy", "g" : "h", "%I": "h", "G" : "H", "h" : "hh", "H" : "HH", "%H": "HH", "i" : "mm", "%M": "mm", "s" : "ss", "%S": "ss", "%r": "hh:mm tt", "%R": "H:mm", "%T": "H:mm:ss", "%X": "t", "%x": "d", "%e": "d", "%D": "MM/dd/yy", "%n": "\\n", "%t": "\\t", "e" : "z", "T" : "z", "%z": "z", "%Z": "z", "Z" : "ZZ", "N" : "u", "w" : "u", "%w": "u", "W" : "W", "%V": "W" }; var normalizer = { substitutes: function (m) { return normalizerSubstitutions[m]; }, interpreted: function (m, x) { var y; switch (m) { case "%u": return x.getDay() + 1; case "z": return x.getOrdinalNumber(); case "%j": return p(x.getOrdinalNumber(), 3); case "%U": var d1 = x.clone().set({month: 0, day: 1}).addDays(-1).moveToDayOfWeek(0), d2 = x.clone().addDays(1).moveToDayOfWeek(0, -1); return (d2 < d1) ? "00" : p((d2.getOrdinalNumber() - d1.getOrdinalNumber()) / 7 + 1); case "%W": return p(x.getWeek()); case "t": return $D.getDaysInMonth(x.getFullYear(), x.getMonth()); case "o": case "%G": return x.setWeek(x.getISOWeek()).toString("yyyy"); case "%g": return x._format("%G").slice(-2); case "a": case "%p": return t("tt").toLowerCase(); case "A": return t("tt").toUpperCase(); case "u": return p(x.getMilliseconds(), 3); case "I": return (x.isDaylightSavingTime()) ? 1 : 0; case "O": return x.getUTCOffset(); case "P": y = x.getUTCOffset(); return y.substring(0, y.length - 2) + ":" + y.substring(y.length - 2); case "B": var now = new Date(); return Math.floor(((now.getHours() * 3600) + (now.getMinutes() * 60) + now.getSeconds() + (now.getTimezoneOffset() + 60) * 60) / 86.4); case "c": return x.toISOString().replace(/\"/g, ""); case "U": return $D.strtotime("now"); case "%c": return t("d") + " " + t("t"); case "%C": return Math.floor(x.getFullYear() / 100 + 1); } }, shouldOverrideDefaults: function (m) { switch (m) { case "%e": return true; default: return false; } }, parse: function (m, context) { var formatString, c = context || new Date(); formatString = normalizer.substitutes(m); if (formatString) { return formatString; } formatString = normalizer.interpreted(m, c); if (formatString) { return formatString; } else { return m; } } }; $D.normalizeFormat = function (format, context) { return format.replace(/(%|\\)?.|%%/g, function(t){ return normalizer.parse(t, context); }); }; /** * Format a local Unix timestamp according to locale settings * * Example: * Date.strftime("%m/%d/%y", new Date()); // "04/13/08" * Date.strftime("c", "2008-04-13T17:52:03Z"); // "04/13/08" * * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @param {Number|String} The number representing the number of seconds that have elapsed since January 1, 1970 (local time). * @return {String} A string representation of the current Date object. */ $D.strftime = function (format, time) { var d = Date.parse(time); return d._format(format); }; /** * Parse any textual datetime description into a Unix timestamp. * A Unix timestamp is the number of seconds that have elapsed since January 1, 1970 (midnight UTC/GMT). * * Example: * Date.strtotime("04/13/08"); // 1208044800 * Date.strtotime("1970-01-01T00:00:00Z"); // 0 * * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @param {Object} A string or date object. * @return {String} A string representation of the current Date object. */ $D.strtotime = function (time) { var d = $D.parse(time); return Math.round($D.UTC(d.getUTCFullYear(), d.getUTCMonth(), d.getUTCDate(), d.getUTCHours(), d.getUTCMinutes(), d.getUTCSeconds(), d.getUTCMilliseconds()) / 1000); }; /** * Converts the value of the current Date object to its equivalent string representation using a PHP/Unix style of date format specifiers. * Format Specifiers * Format Description Example * ------ --------------------------------------------------------------------------- ----------------------- * %a abbreviated weekday name according to the current localed "Mon" through "Sun" * %A full weekday name according to the current localed "Sunday" through "Saturday" * %b abbreviated month name according to the current localed "Jan" through "Dec" * %B full month name according to the current locale "January" through "December" * %c preferred date and time representation for the current locale "4/13/2008 12:33 PM" * %C century number (the year divided by 100 and truncated to an integer) "00" to "99" * %d day of the month as a decimal number "01" to "31" * %D same as %m/%d/%y "04/13/08" * %e day of the month as a decimal number, a single digit is preceded by a space "1" to "31" * %g like %G, but without the century "08" * %G The 4-digit year corresponding to the ISO week number (see %V). "2008" * This has the same format and value as %Y, except that if the ISO week number * belongs to the previous or next year, that year is used instead. * %h same as %b "Jan" through "Dec" * %H hour as a decimal number using a 24-hour clock. "00" to "23" * %I hour as a decimal number using a 12-hour clock. "01" to "12" * %j day of the year as a decimal number. "001" to "366" * %m month as a decimal number. "01" to "12" * %M minute as a decimal number. "00" to "59" * %n newline character "\n" * %p either "am" or "pm" according to the given time value, or the "am" or "pm" * corresponding strings for the current locale. * %r time in a.m. and p.m. notation "8:44 PM" * %R time in 24 hour notation "20:44" * %S second as a decimal number "00" to "59" * %t tab character "\t" * %T current time, equal to %H:%M:%S "12:49:11" * %u weekday as a decimal number ["1", "7"], with "1" representing Monday "1" to "7" * %U week number of the current year as a decimal number, starting with the "0" to ("52" or "53") * first Sunday as the first day of the first week * %V The ISO 8601:1988 week number of the current year as a decimal number, "00" to ("52" or "53") * range 01 to 53, where week 1 is the first week that has at least 4 days * in the current year, and with Monday as the first day of the week. * (Use %G or %g for the year component that corresponds to the week number * for the specified timestamp.) * %W week number of the current year as a decimal number, starting with the "00" to ("52" or "53") * first Monday as the first day of the first week * %w day of the week as a decimal, Sunday being "0" "0" to "6" * %x preferred date representation for the current locale without the time "4/13/2008" * %X preferred time representation for the current locale without the date "12:53:05" * %y year as a decimal number without a century "00" "99" * %Y year as a decimal number including the century "2008" * %Z time zone or name or abbreviation "UTC", "EST", "PST" * %z same as %Z * %% a literal "%" characters "%" * d Day of the month, 2 digits with leading zeros "01" to "31" * D A textual representation of a day, three letters "Mon" through "Sun" * j Day of the month without leading zeros "1" to "31" * l A full textual representation of the day of the week (lowercase "L") "Sunday" through "Saturday" * N ISO-8601 numeric representation of the day of the week (added in PHP 5.1.0) "1" (for Monday) through "7" (for Sunday) * S English ordinal suffix for the day of the month, 2 characters "st", "nd", "rd" or "th". Works well with j * w Numeric representation of the day of the week "0" (for Sunday) through "6" (for Saturday) * z The day of the year (starting from "0") "0" through "365" * W ISO-8601 week number of year, weeks starting on Monday "00" to ("52" or "53") * F A full textual representation of a month, such as January or March "January" through "December" * m Numeric representation of a month, with leading zeros "01" through "12" * M A short textual representation of a month, three letters "Jan" through "Dec" * n Numeric representation of a month, without leading zeros "1" through "12" * t Number of days in the given month "28" through "31" * L Whether it's a leap year "1" if it is a leap year, "0" otherwise * o ISO-8601 year number. This has the same value as Y, except that if the "2008" * ISO week number (W) belongs to the previous or next year, that year * is used instead. * Y A full numeric representation of a year, 4 digits "2008" * y A two digit representation of a year "08" * a Lowercase Ante meridiem and Post meridiem "am" or "pm" * A Uppercase Ante meridiem and Post meridiem "AM" or "PM" * B Swatch Internet time "000" through "999" * g 12-hour format of an hour without leading zeros "1" through "12" * G 24-hour format of an hour without leading zeros "0" through "23" * h 12-hour format of an hour with leading zeros "01" through "12" * H 24-hour format of an hour with leading zeros "00" through "23" * i Minutes with leading zeros "00" to "59" * s Seconds, with leading zeros "00" through "59" * u Milliseconds "54321" * e Timezone identifier "UTC", "EST", "PST" * I Whether or not the date is in daylight saving time (uppercase i) "1" if Daylight Saving Time, "0" otherwise * O Difference to Greenwich time (GMT) in hours "+0200", "-0600" * P Difference to Greenwich time (GMT) with colon between hours and minutes "+02:00", "-06:00" * T Timezone abbreviation "UTC", "EST", "PST" * Z Timezone offset in seconds. The offset for timezones west of UTC is "-43200" through "50400" * always negative, and for those east of UTC is always positive. * c ISO 8601 date "2004-02-12T15:19:21+00:00" * r RFC 2822 formatted date "Thu, 21 Dec 2000 16:01:07 +0200" * U Seconds since the Unix Epoch (January 1 1970 00:00:00 GMT) "0" * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @return {String} A string representation of the current Date object. */ var formatReplace = function (context) { return function (m) { var formatString, override = false; if (m.charAt(0) === "\\" || m.substring(0, 2) === "%%") { return m.replace("\\", "").replace("%%", "%"); } override = normalizer.shouldOverrideDefaults(m); formatString = $D.normalizeFormat(m, context); if (formatString) { return context.toString(formatString, override); } }; }; $P._format = function (format) { var formatter = formatReplace(this); if (!format) { return this._toString(); } else { return format.replace(/(%|\\)?.|%%/g, formatter); } }; if (!$P.format) { $P.format = $P._format; } }()); (function () { "use strict"; var gFn = function (attr) { return function () { return this[attr]; }; }; var sFn = function (attr) { return function (val) { this[attr] = val; return this; }; }; var attrs = ["years", "months", "days", "hours", "minutes", "seconds", "milliseconds"]; var addSetFuncs = function (context, attrs) { for (var i = 0; i < attrs.length ; i++) { var $a = attrs[i], $b = $a.slice(0, 1).toUpperCase() + $a.slice(1); context.prototype[$a] = 0; context.prototype["get" + $b] = gFn($a); context.prototype["set" + $b] = sFn($a); } }; /** * new TimeSpan(milliseconds); * new TimeSpan(days, hours, minutes, seconds); * new TimeSpan(days, hours, minutes, seconds, milliseconds); */ var TimeSpan = function (days, hours, minutes, seconds, milliseconds) { if (arguments.length === 1 && typeof days === "number") { var orient = (days < 0) ? -1 : +1; var millsLeft = Math.abs(days); this.setDays(Math.floor(millsLeft / 86400000) * orient); millsLeft = millsLeft % 86400000; this.setHours(Math.floor(millsLeft / 3600000) * orient); millsLeft = millsLeft % 3600000; this.setMinutes(Math.floor(millsLeft / 60000) * orient); millsLeft = millsLeft % 60000; this.setSeconds(Math.floor(millsLeft / 1000) * orient); millsLeft = millsLeft % 1000; this.setMilliseconds(millsLeft * orient); } else { this.set(days, hours, minutes, seconds, milliseconds); } this.getTotalMilliseconds = function () { return (this.getDays() * 86400000) + (this.getHours() * 3600000) + (this.getMinutes() * 60000) + (this.getSeconds() * 1000); }; this.compareTo = function (time) { var t1 = new Date(1970, 1, 1, this.getHours(), this.getMinutes(), this.getSeconds()), t2; if (time === null) { t2 = new Date(1970, 1, 1, 0, 0, 0); } else { t2 = new Date(1970, 1, 1, time.getHours(), time.getMinutes(), time.getSeconds()); } return (t1 < t2) ? -1 : (t1 > t2) ? 1 : 0; }; this.equals = function (time) { return (this.compareTo(time) === 0); }; this.add = function (time) { return (time === null) ? this : this.addSeconds(time.getTotalMilliseconds() / 1000); }; this.subtract = function (time) { return (time === null) ? this : this.addSeconds(-time.getTotalMilliseconds() / 1000); }; this.addDays = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 86400000)); }; this.addHours = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 3600000)); }; this.addMinutes = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 60000)); }; this.addSeconds = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 1000)); }; this.addMilliseconds = function (n) { return new TimeSpan(this.getTotalMilliseconds() + n); }; this.get12HourHour = function () { return (this.getHours() > 12) ? this.getHours() - 12 : (this.getHours() === 0) ? 12 : this.getHours(); }; this.getDesignator = function () { return (this.getHours() < 12) ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator; }; this.toString = function (format) { this._toString = function () { if (this.getDays() !== null && this.getDays() > 0) { return this.getDays() + "." + this.getHours() + ":" + this.p(this.getMinutes()) + ":" + this.p(this.getSeconds()); } else { return this.getHours() + ":" + this.p(this.getMinutes()) + ":" + this.p(this.getSeconds()); } }; this.p = function (s) { return (s.toString().length < 2) ? "0" + s : s; }; var me = this; return format ? format.replace(/dd?|HH?|hh?|mm?|ss?|tt?/g, function (format) { switch (format) { case "d": return me.getDays(); case "dd": return me.p(me.getDays()); case "H": return me.getHours(); case "HH": return me.p(me.getHours()); case "h": return me.get12HourHour(); case "hh": return me.p(me.get12HourHour()); case "m": return me.getMinutes(); case "mm": return me.p(me.getMinutes()); case "s": return me.getSeconds(); case "ss": return me.p(me.getSeconds()); case "t": return ((me.getHours() < 12) ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator).substring(0, 1); case "tt": return (me.getHours() < 12) ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator; } } ) : this._toString(); }; return this; }; addSetFuncs(TimeSpan, attrs.slice(2)); TimeSpan.prototype.set = function (days, hours, minutes, seconds, milliseconds){ this.setDays(days || this.getDays()); this.setHours(hours || this.getHours()); this.setMinutes(minutes || this.getMinutes()); this.setSeconds(seconds || this.getSeconds()); this.setMilliseconds(milliseconds || this.getMilliseconds()); }; /** * Gets the time of day for this date instances. * @return {TimeSpan} TimeSpan */ Date.prototype.getTimeOfDay = function () { return new TimeSpan(0, this.getHours(), this.getMinutes(), this.getSeconds(), this.getMilliseconds()); }; Date.TimeSpan = TimeSpan; if (typeof window !== "undefined" ) { // keeping API compatible for v1.x window.TimeSpan = TimeSpan; } }()); (function () { "use strict"; var attrs = ["years", "months", "days", "hours", "minutes", "seconds", "milliseconds"]; var gFn = function (attr) { return function () { return this[attr]; }; }; var sFn = function (attr) { return function (val) { this[attr] = val; return this; }; }; var addSetFuncs = function (context, attrs) { for (var i = 0; i < attrs.length ; i++) { var $a = attrs[i], $b = $a.slice(0, 1).toUpperCase() + $a.slice(1); context.prototype[$a] = 0; context.prototype["get" + $b] = gFn($a); context.prototype["set" + $b] = sFn($a); } }; var setMonthsAndYears = function (orient, d1, d2, context) { function inc() { d1.addMonths(-orient); context.months++; if (context.months === 12) { context.years++; context.months = 0; } } if (orient === +1) { while (d1 > d2) { inc(); } } else { while (d1 < d2) { inc(); } } context.months--; context.months *= orient; context.years *= orient; }; var adjustForDST = function(orient, startDate, endDate) { var hasDSTMismatch = (false === (startDate.isDaylightSavingTime() === endDate.isDaylightSavingTime())); if (hasDSTMismatch && orient === 1) { startDate.addHours(-1); } else if (hasDSTMismatch) { startDate.addHours(1); } }; /** * TimePeriod(startDate, endDate); * TimePeriod(years, months, days, hours, minutes, seconds, milliseconds); */ var TimePeriod = function (years, months, days, hours, minutes, seconds, milliseconds) { if (arguments.length === 7) { this.set(years, months, days, hours, minutes, seconds, milliseconds); } else if (arguments.length === 2 && arguments[0] instanceof Date && arguments[1] instanceof Date) { var startDate = arguments[0].clone(); var endDate = arguments[1].clone(); var orient = (startDate > endDate) ? +1 : -1; this.dates = { start: arguments[0].clone(), end: arguments[1].clone() }; setMonthsAndYears(orient, startDate, endDate, this); adjustForDST(orient, startDate, endDate); // // TODO - adjust for DST var diff = endDate - startDate; if (diff !== 0) { var ts = new TimeSpan(diff); this.set(this.years, this.months, ts.getDays(), ts.getHours(), ts.getMinutes(), ts.getSeconds(), ts.getMilliseconds()); } } return this; }; // create all the set functions. addSetFuncs(TimePeriod, attrs); TimePeriod.prototype.set = function (years, months, days, hours, minutes, seconds, milliseconds){ this.setYears(years || this.getYears()); this.setMonths(months || this.getMonths()); this.setDays(days || this.getDays()); this.setHours(hours || this.getHours()); this.setMinutes(minutes || this.getMinutes()); this.setSeconds(seconds || this.getSeconds()); this.setMilliseconds(milliseconds || this.getMilliseconds()); }; Date.TimePeriod = TimePeriod; if (typeof window !== "undefined") { // keeping API compatible for v1.x window.TimePeriod = TimePeriod; } }()); ================================================ FILE: build/date-se-SE.js ================================================ /** * @overview datejs * @version 1.0.0-rc3 * @author Gregory Wild-Smith * @copyright 2015 Gregory Wild-Smith * @license MIT * @homepage https://github.com/abritinthebay/datejs */ /* * DateJS Culture String File * Country Code: se-SE * Name: Sami (Northern) (Sweden) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["se-SE"] = { "name": "se-SE", "englishName": "Sami (Northern) (Sweden)", "nativeName": "davvisámegiella (Ruoŧŧa)", "Sunday": "sotnabeaivi", "Monday": "mánnodat", "Tuesday": "disdat", "Wednesday": "gaskavahkku", "Thursday": "duorastat", "Friday": "bearjadat", "Saturday": "lávvardat", "Sun": "sotn", "Mon": "mán", "Tue": "dis", "Wed": "gask", "Thu": "duor", "Fri": "bear", "Sat": "láv", "Su": "sotn", "Mo": "mán", "Tu": "dis", "We": "gask", "Th": "duor", "Fr": "bear", "Sa": "láv", "S_Sun_Initial": "s", "M_Mon_Initial": "m", "T_Tue_Initial": "d", "W_Wed_Initial": "g", "T_Thu_Initial": "d", "F_Fri_Initial": "b", "S_Sat_Initial": "l", "January": "ođđajagemánnu", "February": "guovvamánnu", "March": "njukčamánnu", "April": "cuoŋománnu", "May": "miessemánnu", "June": "geassemánnu", "July": "suoidnemánnu", "August": "borgemánnu", "September": "čakčamánnu", "October": "golggotmánnu", "November": "skábmamánnu", "December": "juovlamánnu", "Jan_Abbr": "ođđj", "Feb_Abbr": "guov", "Mar_Abbr": "njuk", "Apr_Abbr": "cuo", "May_Abbr": "mies", "Jun_Abbr": "geas", "Jul_Abbr": "suoi", "Aug_Abbr": "borg", "Sep_Abbr": "čakč", "Oct_Abbr": "golg", "Nov_Abbr": "skáb", "Dec_Abbr": "juov", "AM": "", "PM": "", "firstDayOfWeek": 1, "twoDigitYearMax": 2029, "mdy": "ymd", "M/d/yyyy": "yyyy-MM-dd", "dddd, MMMM dd, yyyy": "MMMM d'. b. 'yyyy", "h:mm tt": "HH:mm:ss", "h:mm:ss tt": "HH:mm:ss", "dddd, MMMM dd, yyyy h:mm:ss tt": "MMMM d'. b. 'yyyy HH:mm:ss", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "MMMM dd", "MMMM, yyyy": "MMMM yyyy", "/jan(uary)?/": "ođđajagemánnu", "/feb(ruary)?/": "guov(vamánnu)?", "/mar(ch)?/": "njuk(čamánnu)?", "/apr(il)?/": "cuo(ŋománnu)?", "/may/": "mies(semánnu)?", "/jun(e)?/": "geas(semánnu)?", "/jul(y)?/": "suoi(dnemánnu)?", "/aug(ust)?/": "borg(emánnu)?", "/sep(t(ember)?)?/": "čakč(amánnu)?", "/oct(ober)?/": "golg(gotmánnu)?", "/nov(ember)?/": "skáb(mamánnu)?", "/dec(ember)?/": "juov(lamánnu)?", "/^su(n(day)?)?/": "^sotnabeaivi", "/^mo(n(day)?)?/": "^mánnodat", "/^tu(e(s(day)?)?)?/": "^disdat", "/^we(d(nesday)?)?/": "^gaskavahkku", "/^th(u(r(s(day)?)?)?)?/": "^duorastat", "/^fr(i(day)?)?/": "^bearjadat", "/^sa(t(urday)?)?/": "^lávvardat", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "se-SE"; /** * @overview datejs * @version 1.0.0-rc3 * @author Gregory Wild-Smith * @copyright 2015 Gregory Wild-Smith * @license MIT * @homepage https://github.com/abritinthebay/datejs */(function () { var $D = Date; var lang = Date.CultureStrings ? Date.CultureStrings.lang : null; var loggedKeys = {}; // for debug purposes. var getText = { getFromKey: function (key, countryCode) { var output; if (Date.CultureStrings && Date.CultureStrings[countryCode] && Date.CultureStrings[countryCode][key]) { output = Date.CultureStrings[countryCode][key]; } else { output = getText.buildFromDefault(key); } if (key.charAt(0) === "/") { // Assume it's a regex output = getText.buildFromRegex(key, countryCode); } return output; }, getFromObjectValues: function (obj, countryCode) { var key, output = {}; for(key in obj) { if (obj.hasOwnProperty(key)) { output[key] = getText.getFromKey(obj[key], countryCode); } } return output; }, getFromObjectKeys: function (obj, countryCode) { var key, output = {}; for(key in obj) { if (obj.hasOwnProperty(key)) { output[getText.getFromKey(key, countryCode)] = obj[key]; } } return output; }, getFromArray: function (arr, countryCode) { var output = []; for (var i=0; i < arr.length; i++){ if (i in arr) { output[i] = getText.getFromKey(arr[i], countryCode); } } return output; }, buildFromDefault: function (key) { var output, length, split, last; switch(key) { case "name": output = "en-US"; break; case "englishName": output = "English (United States)"; break; case "nativeName": output = "English (United States)"; break; case "twoDigitYearMax": output = 2049; break; case "firstDayOfWeek": output = 0; break; default: output = key; split = key.split("_"); length = split.length; if (length > 1 && key.charAt(0) !== "/") { // if the key isn't a regex and it has a split. last = split[(length - 1)].toLowerCase(); if (last === "initial" || last === "abbr") { output = split[0]; } } break; } return output; }, buildFromRegex: function (key, countryCode) { var output; if (Date.CultureStrings && Date.CultureStrings[countryCode] && Date.CultureStrings[countryCode][key]) { output = new RegExp(Date.CultureStrings[countryCode][key], "i"); } else { output = new RegExp(key.replace(new RegExp("/", "g"),""), "i"); } return output; } }; var shallowMerge = function (obj1, obj2) { for (var attrname in obj2) { if (obj2.hasOwnProperty(attrname)) { obj1[attrname] = obj2[attrname]; } } }; var __ = function (key, language) { var countryCode = (language) ? language : lang; loggedKeys[key] = key; if (typeof key === "object") { if (key instanceof Array) { return getText.getFromArray(key, countryCode); } else { return getText.getFromObjectKeys(key, countryCode); } } else { return getText.getFromKey(key, countryCode); } }; var loadI18nScript = function (code) { // paatterned after jQuery's getScript. var url = Date.Config.i18n + code + ".js"; var head = document.getElementsByTagName("head")[0] || document.documentElement; var script = document.createElement("script"); script.src = url; var completed = false; var events = { done: function (){} // placeholder function }; // Attach handlers for all browsers script.onload = script.onreadystatechange = function() { if ( !completed && (!this.readyState || this.readyState === "loaded" || this.readyState === "complete") ) { events.done(); head.removeChild(script); } }; setTimeout(function() { head.insertBefore(script, head.firstChild); }, 0); // allows return to execute first return { done: function (cb) { events.done = function() { if (cb) { setTimeout(cb,0); } }; } }; }; var buildInfo = { buildFromMethodHash: function (obj) { var key; for(key in obj) { if (obj.hasOwnProperty(key)) { obj[key] = buildInfo[obj[key]](); } } return obj; }, timeZoneDST: function () { var DST = { "CHADT": "+1345", "NZDT": "+1300", "AEDT": "+1100", "ACDT": "+1030", "AZST": "+0500", "IRDT": "+0430", "EEST": "+0300", "CEST": "+0200", "BST": "+0100", "PMDT": "-0200", "ADT": "-0300", "NDT": "-0230", "EDT": "-0400", "CDT": "-0500", "MDT": "-0600", "PDT": "-0700", "AKDT": "-0800", "HADT": "-0900" }; return __(DST); }, timeZoneStandard: function () { var standard = { "LINT": "+1400", "TOT": "+1300", "CHAST": "+1245", "NZST": "+1200", "NFT": "+1130", "SBT": "+1100", "AEST": "+1000", "ACST": "+0930", "JST": "+0900", "CWST": "+0845", "CT": "+0800", "ICT": "+0700", "MMT": "+0630", "BST": "+0600", "NPT": "+0545", "IST": "+0530", "PKT": "+0500", "AFT": "+0430", "MSK": "+0400", "IRST": "+0330", "FET": "+0300", "EET": "+0200", "CET": "+0100", "GMT": "+0000", "UTC": "+0000", "CVT": "-0100", "GST": "-0200", "BRT": "-0300", "NST": "-0330", "AST": "-0400", "EST": "-0500", "CST": "-0600", "MST": "-0700", "PST": "-0800", "AKST": "-0900", "MIT": "-0930", "HST": "-1000", "SST": "-1100", "BIT": "-1200" }; return __(standard); }, timeZones: function (data) { var zone; data.timezones = []; for (zone in data.abbreviatedTimeZoneStandard) { if (data.abbreviatedTimeZoneStandard.hasOwnProperty(zone)) { data.timezones.push({ name: zone, offset: data.abbreviatedTimeZoneStandard[zone]}); } } for (zone in data.abbreviatedTimeZoneDST) { if (data.abbreviatedTimeZoneDST.hasOwnProperty(zone)) { data.timezones.push({ name: zone, offset: data.abbreviatedTimeZoneDST[zone], dst: true}); } } return data.timezones; }, days: function () { return __(["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"]); }, dayAbbr: function () { return __(["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"]); }, dayShortNames: function () { return __(["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"]); }, dayFirstLetters: function () { return __(["S_Sun_Initial", "M_Mon_Initial", "T_Tues_Initial", "W_Wed_Initial", "T_Thu_Initial", "F_Fri_Initial", "S_Sat_Initial"]); }, months: function () { return __(["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"]); }, monthAbbr: function () { return __(["Jan_Abbr", "Feb_Abbr", "Mar_Abbr", "Apr_Abbr", "May_Abbr", "Jun_Abbr", "Jul_Abbr", "Aug_Abbr", "Sep_Abbr", "Oct_Abbr", "Nov_Abbr", "Dec_Abbr"]); }, formatPatterns: function () { return getText.getFromObjectValues({ shortDate: "M/d/yyyy", longDate: "dddd, MMMM dd, yyyy", shortTime: "h:mm tt", longTime: "h:mm:ss tt", fullDateTime: "dddd, MMMM dd, yyyy h:mm:ss tt", sortableDateTime: "yyyy-MM-ddTHH:mm:ss", universalSortableDateTime: "yyyy-MM-dd HH:mm:ssZ", rfc1123: "ddd, dd MMM yyyy HH:mm:ss", monthDay: "MMMM dd", yearMonth: "MMMM, yyyy" }, Date.i18n.currentLanguage()); }, regex: function () { return getText.getFromObjectValues({ inTheMorning: "/( in the )(morn(ing)?)\\b/", thisMorning: "/(this )(morn(ing)?)\\b/", amThisMorning: "/(\b\\d(am)? )(this )(morn(ing)?)/", inTheEvening: "/( in the )(even(ing)?)\\b/", thisEvening: "/(this )(even(ing)?)\\b/", pmThisEvening: "/(\b\\d(pm)? )(this )(even(ing)?)/", jan: "/jan(uary)?/", feb: "/feb(ruary)?/", mar: "/mar(ch)?/", apr: "/apr(il)?/", may: "/may/", jun: "/jun(e)?/", jul: "/jul(y)?/", aug: "/aug(ust)?/", sep: "/sep(t(ember)?)?/", oct: "/oct(ober)?/", nov: "/nov(ember)?/", dec: "/dec(ember)?/", sun: "/^su(n(day)?)?/", mon: "/^mo(n(day)?)?/", tue: "/^tu(e(s(day)?)?)?/", wed: "/^we(d(nesday)?)?/", thu: "/^th(u(r(s(day)?)?)?)?/", fri: "/fr(i(day)?)?/", sat: "/^sa(t(urday)?)?/", future: "/^next/", past: "/^last|past|prev(ious)?/", add: "/^(\\+|aft(er)?|from|hence)/", subtract: "/^(\\-|bef(ore)?|ago)/", yesterday: "/^yes(terday)?/", today: "/^t(od(ay)?)?/", tomorrow: "/^tom(orrow)?/", now: "/^n(ow)?/", millisecond: "/^ms|milli(second)?s?/", second: "/^sec(ond)?s?/", minute: "/^mn|min(ute)?s?/", hour: "/^h(our)?s?/", week: "/^w(eek)?s?/", month: "/^m(onth)?s?/", day: "/^d(ay)?s?/", year: "/^y(ear)?s?/", shortMeridian: "/^(a|p)/", longMeridian: "/^(a\\.?m?\\.?|p\\.?m?\\.?)/", timezone: "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/", ordinalSuffix: "/^\\s*(st|nd|rd|th)/", timeContext: "/^\\s*(\\:|a(?!u|p)|p)/" }, Date.i18n.currentLanguage()); } }; var CultureInfo = function () { var info = getText.getFromObjectValues({ name: "name", englishName: "englishName", nativeName: "nativeName", amDesignator: "AM", pmDesignator: "PM", firstDayOfWeek: "firstDayOfWeek", twoDigitYearMax: "twoDigitYearMax", dateElementOrder: "mdy" }, Date.i18n.currentLanguage()); var constructedInfo = buildInfo.buildFromMethodHash({ dayNames: "days", abbreviatedDayNames: "dayAbbr", shortestDayNames: "dayShortNames", firstLetterDayNames: "dayFirstLetters", monthNames: "months", abbreviatedMonthNames: "monthAbbr", formatPatterns: "formatPatterns", regexPatterns: "regex", abbreviatedTimeZoneDST: "timeZoneDST", abbreviatedTimeZoneStandard: "timeZoneStandard" }); shallowMerge(info, constructedInfo); buildInfo.timeZones(info); return info; }; $D.i18n = { __: function (key, lang) { return __(key, lang); }, currentLanguage: function () { return lang || "en-US"; }, setLanguage: function (code, force, cb) { var async = false; if (force || code === "en-US" || (!!Date.CultureStrings && !!Date.CultureStrings[code])) { lang = code; Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings.lang = code; Date.CultureInfo = new CultureInfo(); } else { if (!(!!Date.CultureStrings && !!Date.CultureStrings[code])) { if (typeof exports !== "undefined" && this.exports !== exports) { // we're in a Node enviroment, load it using require try { require("../i18n/" + code + ".js"); lang = code; Date.CultureStrings.lang = code; Date.CultureInfo = new CultureInfo(); } catch (e) { // var str = "The language for '" + code + "' could not be loaded by Node. It likely does not exist."; throw new Error("The DateJS IETF language tag '" + code + "' could not be loaded by Node. It likely does not exist."); } } else if (Date.Config && Date.Config.i18n) { // we know the location of the files, so lets load them async = true; loadI18nScript(code).done(function(){ lang = code; Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings.lang = code; Date.CultureInfo = new CultureInfo(); $D.Parsing.Normalizer.buildReplaceData(); // because this is async if ($D.Grammar) { $D.Grammar.buildGrammarFormats(); // so we can parse those strings... } if (cb) { setTimeout(cb,0); } }); } else { Date.console.error("The DateJS IETF language tag '" + code + "' is not available and has not been loaded."); return false; } } } $D.Parsing.Normalizer.buildReplaceData(); // rebuild normalizer strings if ($D.Grammar) { $D.Grammar.buildGrammarFormats(); // so we can parse those strings... } if (!async && cb) { setTimeout(cb,0); } }, getLoggedKeys: function () { return loggedKeys; }, updateCultureInfo: function () { Date.CultureInfo = new CultureInfo(); } }; $D.i18n.updateCultureInfo(); // run automatically }()); (function () { var $D = Date, $P = $D.prototype, p = function (s, l) { if (!l) { l = 2; } return ("000" + s).slice(l * -1); }; if (typeof window !== "undefined" && typeof window.console !== "undefined" && typeof window.console.log !== "undefined") { $D.console = console; // used only to raise non-critical errors if available } else { // set mock so we don't give errors. $D.console = { log: function(){}, error: function(){} }; } $D.Config = $D.Config || {}; $D.initOverloads = function() { /** * Overload of Date.now. Allows an alternate call for Date.now where it returns the * current Date as an object rather than just milliseconds since the Unix Epoch. * * Also provides an implementation of now() for browsers (IE<9) that don't have it. * * Backwards compatible so with work with either: * Date.now() [returns ms] * or * Date.now(true) [returns Date] */ if (!$D.now) { $D._now = function now() { return new Date().getTime(); }; } else if (!$D._now) { $D._now = $D.now; } $D.now = function (returnObj) { if (returnObj) { return $D.present(); } else { return $D._now(); } }; if ( !$P.toISOString ) { $P.toISOString = function() { return this.getUTCFullYear() + "-" + p(this.getUTCMonth() + 1) + "-" + p(this.getUTCDate()) + "T" + p(this.getUTCHours()) + ":" + p(this.getUTCMinutes()) + ":" + p(this.getUTCSeconds()) + "." + String( (this.getUTCMilliseconds()/1000).toFixed(3)).slice(2, 5) + "Z"; }; } // private if ( $P._toString === undefined ){ $P._toString = $P.toString; } }; $D.initOverloads(); /** * Gets a date that is set to the current date. The time is set to the start of the day (00:00 or 12:00 AM). * @return {Date} The current date. */ $D.today = function () { return new Date().clearTime(); }; /** * Gets a date that is set to the current date and time (same as new Date, but chainable) * @return {Date} The current date. */ $D.present = function () { return new Date(); }; /** * Compares the first date to the second date and returns an number indication of their relative values. * @param {Date} First Date object to compare [Required]. * @param {Date} Second Date object to compare to [Required]. * @return {Number} -1 = date1 is lessthan date2. 0 = values are equal. 1 = date1 is greaterthan date2. */ $D.compare = function (date1, date2) { if (isNaN(date1) || isNaN(date2)) { throw new Error(date1 + " - " + date2); } else if (date1 instanceof Date && date2 instanceof Date) { return (date1 < date2) ? -1 : (date1 > date2) ? 1 : 0; } else { throw new TypeError(date1 + " - " + date2); } }; /** * Compares the first Date object to the second Date object and returns true if they are equal. * @param {Date} First Date object to compare [Required] * @param {Date} Second Date object to compare to [Required] * @return {Boolean} true if dates are equal. false if they are not equal. */ $D.equals = function (date1, date2) { return (date1.compareTo(date2) === 0); }; /** * Gets the language appropriate day name when given the day number(0-6) * eg - 0 == Sunday * @return {String} The day name */ $D.getDayName = function (n) { return Date.CultureInfo.dayNames[n]; }; /** * Gets the day number (0-6) if given a CultureInfo specific string which is a valid dayName, abbreviatedDayName or shortestDayName (two char). * @param {String} The name of the day (eg. "Monday, "Mon", "tuesday", "tue", "We", "we"). * @return {Number} The day number */ $D.getDayNumberFromName = function (name) { var n = Date.CultureInfo.dayNames, m = Date.CultureInfo.abbreviatedDayNames, o = Date.CultureInfo.shortestDayNames, s = name.toLowerCase(); for (var i = 0; i < n.length; i++) { if (n[i].toLowerCase() === s || m[i].toLowerCase() === s || o[i].toLowerCase() === s) { return i; } } return -1; }; /** * Gets the month number (0-11) if given a Culture Info specific string which is a valid monthName or abbreviatedMonthName. * @param {String} The name of the month (eg. "February, "Feb", "october", "oct"). * @return {Number} The day number */ $D.getMonthNumberFromName = function (name) { var n = Date.CultureInfo.monthNames, m = Date.CultureInfo.abbreviatedMonthNames, s = name.toLowerCase(); for (var i = 0; i < n.length; i++) { if (n[i].toLowerCase() === s || m[i].toLowerCase() === s) { return i; } } return -1; }; /** * Gets the language appropriate month name when given the month number(0-11) * eg - 0 == January * @return {String} The month name */ $D.getMonthName = function (n) { return Date.CultureInfo.monthNames[n]; }; /** * Determines if the current date instance is within a LeapYear. * @param {Number} The year. * @return {Boolean} true if date is within a LeapYear, otherwise false. */ $D.isLeapYear = function (year) { return ((year % 4 === 0 && year % 100 !== 0) || year % 400 === 0); }; /** * Gets the number of days in the month, given a year and month value. Automatically corrects for LeapYear. * @param {Number} The year. * @param {Number} The month (0-11). * @return {Number} The number of days in the month. */ $D.getDaysInMonth = function (year, month) { if (!month && $D.validateMonth(year)) { month = year; year = Date.today().getFullYear(); } return [31, ($D.isLeapYear(year) ? 29 : 28), 31, 30, 31, 30, 31, 31, 30, 31, 30, 31][month]; }; $P.getDaysInMonth = function () { return $D.getDaysInMonth(this.getFullYear(), this.getMonth()); }; $D.getTimezoneAbbreviation = function (offset, dst) { var p, n = (dst || false) ? Date.CultureInfo.abbreviatedTimeZoneDST : Date.CultureInfo.abbreviatedTimeZoneStandard; for (p in n) { if (n.hasOwnProperty(p)) { if (n[p] === offset) { return p; } } } return null; }; $D.getTimezoneOffset = function (name, dst) { var i, a =[], z = Date.CultureInfo.timezones; if (!name) { name = (new Date()).getTimezone();} for (i = 0; i < z.length; i++) { if (z[i].name === name.toUpperCase()) { a.push(i); } } if (!z[a[0]]) { return null; } if (a.length === 1 || !dst) { return z[a[0]].offset; } else { for (i=0; i < a.length; i++) { if (z[a[i]].dst) { return z[a[i]].offset; } } } }; $D.getQuarter = function (d) { d = d || new Date(); // If no date supplied, use today var q = [1,2,3,4]; return q[Math.floor(d.getMonth() / 3)]; // ~~~ is a bitwise op. Faster than Math.floor }; $D.getDaysLeftInQuarter = function (d) { d = d || new Date(); var qEnd = new Date(d); qEnd.setMonth(qEnd.getMonth() + 3 - qEnd.getMonth() % 3, 0); return Math.floor((qEnd - d) / 8.64e7); }; // private var validate = function (n, min, max, name) { name = name ? name : "Object"; if (typeof n === "undefined") { return false; } else if (typeof n !== "number") { throw new TypeError(n + " is not a Number."); } else if (n < min || n > max) { // As failing validation is *not* an exceptional circumstance // lets not throw a RangeError Exception here. // It's semantically correct but it's not sensible. return false; } return true; }; /** * Validates the number is within an acceptable range for milliseconds [0-999]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateMillisecond = function (value) { return validate(value, 0, 999, "millisecond"); }; /** * Validates the number is within an acceptable range for seconds [0-59]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateSecond = function (value) { return validate(value, 0, 59, "second"); }; /** * Validates the number is within an acceptable range for minutes [0-59]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateMinute = function (value) { return validate(value, 0, 59, "minute"); }; /** * Validates the number is within an acceptable range for hours [0-23]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateHour = function (value) { return validate(value, 0, 23, "hour"); }; /** * Validates the number is within an acceptable range for the days in a month [0-MaxDaysInMonth]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateDay = function (value, year, month) { if (year === undefined || year === null || month === undefined || month === null) { return false;} return validate(value, 1, $D.getDaysInMonth(year, month), "day"); }; /** * Validates the number is within an acceptable range for months [0-11]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateWeek = function (value) { return validate(value, 0, 53, "week"); }; /** * Validates the number is within an acceptable range for months [0-11]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateMonth = function (value) { return validate(value, 0, 11, "month"); }; /** * Validates the number is within an acceptable range for years. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateYear = function (value) { /** * Per ECMAScript spec the range of times supported by Date objects is * exactly -100,000,000 days to +100,000,000 days measured relative to * midnight at the beginning of 01 January, 1970 UTC. * This gives a range of 8,640,000,000,000,000 milliseconds to either * side of 01 January, 1970 UTC. * * Earliest possible date: Tue, 20 Apr 271,822 B.C. 00:00:00 UTC * Latest possible date: Sat, 13 Sep 275,760 00:00:00 UTC */ return validate(value, -271822, 275760, "year"); }; $D.validateTimezone = function(value) { var timezones = {"ACDT":1,"ACST":1,"ACT":1,"ADT":1,"AEDT":1,"AEST":1,"AFT":1,"AKDT":1,"AKST":1,"AMST":1,"AMT":1,"ART":1,"AST":1,"AWDT":1,"AWST":1,"AZOST":1,"AZT":1,"BDT":1,"BIOT":1,"BIT":1,"BOT":1,"BRT":1,"BST":1,"BTT":1,"CAT":1,"CCT":1,"CDT":1,"CEDT":1,"CEST":1,"CET":1,"CHADT":1,"CHAST":1,"CHOT":1,"ChST":1,"CHUT":1,"CIST":1,"CIT":1,"CKT":1,"CLST":1,"CLT":1,"COST":1,"COT":1,"CST":1,"CT":1,"CVT":1,"CWST":1,"CXT":1,"DAVT":1,"DDUT":1,"DFT":1,"EASST":1,"EAST":1,"EAT":1,"ECT":1,"EDT":1,"EEDT":1,"EEST":1,"EET":1,"EGST":1,"EGT":1,"EIT":1,"EST":1,"FET":1,"FJT":1,"FKST":1,"FKT":1,"FNT":1,"GALT":1,"GAMT":1,"GET":1,"GFT":1,"GILT":1,"GIT":1,"GMT":1,"GST":1,"GYT":1,"HADT":1,"HAEC":1,"HAST":1,"HKT":1,"HMT":1,"HOVT":1,"HST":1,"ICT":1,"IDT":1,"IOT":1,"IRDT":1,"IRKT":1,"IRST":1,"IST":1,"JST":1,"KGT":1,"KOST":1,"KRAT":1,"KST":1,"LHST":1,"LINT":1,"MAGT":1,"MART":1,"MAWT":1,"MDT":1,"MET":1,"MEST":1,"MHT":1,"MIST":1,"MIT":1,"MMT":1,"MSK":1,"MST":1,"MUT":1,"MVT":1,"MYT":1,"NCT":1,"NDT":1,"NFT":1,"NPT":1,"NST":1,"NT":1,"NUT":1,"NZDT":1,"NZST":1,"OMST":1,"ORAT":1,"PDT":1,"PET":1,"PETT":1,"PGT":1,"PHOT":1,"PHT":1,"PKT":1,"PMDT":1,"PMST":1,"PONT":1,"PST":1,"PYST":1,"PYT":1,"RET":1,"ROTT":1,"SAKT":1,"SAMT":1,"SAST":1,"SBT":1,"SCT":1,"SGT":1,"SLST":1,"SRT":1,"SST":1,"SYOT":1,"TAHT":1,"THA":1,"TFT":1,"TJT":1,"TKT":1,"TLT":1,"TMT":1,"TOT":1,"TVT":1,"UCT":1,"ULAT":1,"UTC":1,"UYST":1,"UYT":1,"UZT":1,"VET":1,"VLAT":1,"VOLT":1,"VOST":1,"VUT":1,"WAKT":1,"WAST":1,"WAT":1,"WEDT":1,"WEST":1,"WET":1,"WST":1,"YAKT":1,"YEKT":1,"Z":1}; return (timezones[value] === 1); }; $D.validateTimezoneOffset= function(value) { // timezones go from +14hrs to -12hrs, the +X hours are negative offsets. return (value > -841 && value < 721); }; }()); (function () { var $D = Date, $P = $D.prototype, p = function (s, l) { if (!l) { l = 2; } return ("000" + s).slice(l * -1); }; var validateConfigObject = function (obj) { var result = {}, self = this, prop, testFunc; testFunc = function (prop, func, value) { if (prop === "day") { var month = (obj.month !== undefined) ? obj.month : self.getMonth(); var year = (obj.year !== undefined) ? obj.year : self.getFullYear(); return $D[func](value, year, month); } else { return $D[func](value); } }; for (prop in obj) { if (Object.prototype.hasOwnProperty.call(obj, prop)) { var func = "validate" + prop.charAt(0).toUpperCase() + prop.slice(1); if ($D[func] && obj[prop] !== null && testFunc(prop, func, obj[prop])) { result[prop] = obj[prop]; } } } return result; }; /** * Resets the time of this Date object to 12:00 AM (00:00), which is the start of the day. * @param {Boolean} .clone() this date instance before clearing Time * @return {Date} this */ $P.clearTime = function () { this.setHours(0); this.setMinutes(0); this.setSeconds(0); this.setMilliseconds(0); return this; }; /** * Resets the time of this Date object to the current time ('now'). * @return {Date} this */ $P.setTimeToNow = function () { var n = new Date(); this.setHours(n.getHours()); this.setMinutes(n.getMinutes()); this.setSeconds(n.getSeconds()); this.setMilliseconds(n.getMilliseconds()); return this; }; /** * Returns a new Date object that is an exact date and time copy of the original instance. * @return {Date} A new Date instance */ $P.clone = function () { return new Date(this.getTime()); }; /** * Compares this instance to a Date object and returns an number indication of their relative values. * @param {Date} Date object to compare [Required] * @return {Number} -1 = this is lessthan date. 0 = values are equal. 1 = this is greaterthan date. */ $P.compareTo = function (date) { return Date.compare(this, date); }; /** * Compares this instance to another Date object and returns true if they are equal. * @param {Date} Date object to compare. If no date to compare, new Date() [now] is used. * @return {Boolean} true if dates are equal. false if they are not equal. */ $P.equals = function (date) { return Date.equals(this, (date !== undefined ? date : new Date())); }; /** * Determines if this instance is between a range of two dates or equal to either the start or end dates. * @param {Date} Start of range [Required] * @param {Date} End of range [Required] * @return {Boolean} true is this is between or equal to the start and end dates, else false */ $P.between = function (start, end) { return this.getTime() >= start.getTime() && this.getTime() <= end.getTime(); }; /** * Determines if this date occurs after the date to compare to. * @param {Date} Date object to compare. If no date to compare, new Date() ("now") is used. * @return {Boolean} true if this date instance is greater than the date to compare to (or "now"), otherwise false. */ $P.isAfter = function (date) { return this.compareTo(date || new Date()) === 1; }; /** * Determines if this date occurs before the date to compare to. * @param {Date} Date object to compare. If no date to compare, new Date() ("now") is used. * @return {Boolean} true if this date instance is less than the date to compare to (or "now"). */ $P.isBefore = function (date) { return (this.compareTo(date || new Date()) === -1); }; /** * Determines if the current Date instance occurs today. * @return {Boolean} true if this date instance is 'today', otherwise false. */ /** * Determines if the current Date instance occurs on the same Date as the supplied 'date'. * If no 'date' to compare to is provided, the current Date instance is compared to 'today'. * @param {date} Date object to compare. If no date to compare, the current Date ("now") is used. * @return {Boolean} true if this Date instance occurs on the same Day as the supplied 'date'. */ $P.isToday = $P.isSameDay = function (date) { return this.clone().clearTime().equals((date || new Date()).clone().clearTime()); }; /** * Adds the specified number of milliseconds to this instance. * @param {Number} The number of milliseconds to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addMilliseconds = function (value) { if (!value) { return this; } this.setTime(this.getTime() + value * 1); return this; }; /** * Adds the specified number of seconds to this instance. * @param {Number} The number of seconds to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addSeconds = function (value) { if (!value) { return this; } return this.addMilliseconds(value * 1000); }; /** * Adds the specified number of seconds to this instance. * @param {Number} The number of seconds to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addMinutes = function (value) { if (!value) { return this; } return this.addMilliseconds(value * 60000); // 60*1000 }; /** * Adds the specified number of hours to this instance. * @param {Number} The number of hours to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addHours = function (value) { if (!value) { return this; } return this.addMilliseconds(value * 3600000); // 60*60*1000 }; /** * Adds the specified number of days to this instance. * @param {Number} The number of days to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addDays = function (value) { if (!value) { return this; } this.setDate(this.getDate() + value * 1); return this; }; /** * Adds the specified number of weekdays (ie - not sat or sun) to this instance. * @param {Number} The number of days to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addWeekdays = function (value) { if (!value) { return this; } var day = this.getDay(); var weeks = (Math.ceil(Math.abs(value)/7)); if (day === 0 || day === 6) { if (value > 0) { this.next().monday(); this.addDays(-1); day = this.getDay(); } } if (value < 0) { while (value < 0) { this.addDays(-1); day = this.getDay(); if (day !== 0 && day !== 6) { value++; } } return this; } else if (value > 5 || (6-day) <= value) { value = value + (weeks * 2); } return this.addDays(value); }; /** * Adds the specified number of weeks to this instance. * @param {Number} The number of weeks to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addWeeks = function (value) { if (!value) { return this; } return this.addDays(value * 7); }; /** * Adds the specified number of months to this instance. * @param {Number} The number of months to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addMonths = function (value) { if (!value) { return this; } var n = this.getDate(); this.setDate(1); this.setMonth(this.getMonth() + value * 1); this.setDate(Math.min(n, $D.getDaysInMonth(this.getFullYear(), this.getMonth()))); return this; }; $P.addQuarters = function (value) { if (!value) { return this; } // note this will take you to the same point in the quarter as you are now. // i.e. - if you are 15 days into the quarter you'll be 15 days into the resulting one. // bonus: this allows adding fractional quarters return this.addMonths(value * 3); }; /** * Adds the specified number of years to this instance. * @param {Number} The number of years to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addYears = function (value) { if (!value) { return this; } return this.addMonths(value * 12); }; /** * Adds (or subtracts) to the value of the years, months, weeks, days, hours, minutes, seconds, milliseconds of the date instance using given configuration object. Positive and Negative values allowed. * Example

	Date.today().add( { days: 1, months: 1 } )

	new Date().add( { years: -1 } )
	
* @param {Object} Configuration object containing attributes (months, days, etc.) * @return {Date} this */ $P.add = function (config) { if (typeof config === "number") { this._orient = config; return this; } var x = config; if (x.day) { // If we should be a different date than today (eg: for 'tomorrow -1d', etc). // Should only effect parsing, not direct usage (eg, Finish and FinishExact) if ((x.day - this.getDate()) !== 0) { this.setDate(x.day); } } if (x.milliseconds) { this.addMilliseconds(x.milliseconds); } if (x.seconds) { this.addSeconds(x.seconds); } if (x.minutes) { this.addMinutes(x.minutes); } if (x.hours) { this.addHours(x.hours); } if (x.weeks) { this.addWeeks(x.weeks); } if (x.months) { this.addMonths(x.months); } if (x.years) { this.addYears(x.years); } if (x.days) { this.addDays(x.days); } return this; }; /** * Get the week number. Week one (1) is the week which contains the first Thursday of the year. Monday is considered the first day of the week. * The .getWeek() function does NOT convert the date to UTC. The local datetime is used. * Please use .getISOWeek() to get the week of the UTC converted date. * @return {Number} 1 to 53 */ $P.getWeek = function (utc) { // Create a copy of this date object var self, target = new Date(this.valueOf()); if (utc) { target.addMinutes(target.getTimezoneOffset()); self = target.clone(); } else { self = this; } // ISO week date weeks start on monday // so correct the day number var dayNr = (self.getDay() + 6) % 7; // ISO 8601 states that week 1 is the week // with the first thursday of that year. // Set the target date to the thursday in the target week target.setDate(target.getDate() - dayNr + 3); // Store the millisecond value of the target date var firstThursday = target.valueOf(); // Set the target to the first thursday of the year // First set the target to january first target.setMonth(0, 1); // Not a thursday? Correct the date to the next thursday if (target.getDay() !== 4) { target.setMonth(0, 1 + ((4 - target.getDay()) + 7) % 7); } // The weeknumber is the number of weeks between the // first thursday of the year and the thursday in the target week return 1 + Math.ceil((firstThursday - target) / 604800000); // 604800000 = 7 * 24 * 3600 * 1000 }; /** * Get the ISO 8601 week number. Week one ("01") is the week which contains the first Thursday of the year. Monday is considered the first day of the week. * The .getISOWeek() function does convert the date to it's UTC value. Please use .getWeek() to get the week of the local date. * @return {String} "01" to "53" */ $P.getISOWeek = function () { return p(this.getWeek(true)); }; /** * Moves the date to Monday of the week set. Week one (1) is the week which contains the first Thursday of the year. * @param {Number} A Number (1 to 53) that represents the week of the year. * @return {Date} this */ $P.setWeek = function (n) { if ((n - this.getWeek()) === 0) { if (this.getDay() !== 1) { return this.moveToDayOfWeek(1, (this.getDay() > 1 ? -1 : 1)); } else { return this; } } else { return this.moveToDayOfWeek(1, (this.getDay() > 1 ? -1 : 1)).addWeeks(n - this.getWeek()); } }; $P.setQuarter = function (qtr) { var month = Math.abs(((qtr-1) * 3) + 1); return this.setMonth(month, 1); }; $P.getQuarter = function () { return Date.getQuarter(this); }; $P.getDaysLeftInQuarter = function () { return Date.getDaysLeftInQuarter(this); }; /** * Moves the date to the next n'th occurrence of the dayOfWeek starting from the beginning of the month. The number (-1) is a magic number and will return the last occurrence of the dayOfWeek in the month. * @param {Number} The dayOfWeek to move to * @param {Number} The n'th occurrence to move to. Use (-1) to return the last occurrence in the month * @return {Date} this */ $P.moveToNthOccurrence = function (dayOfWeek, occurrence) { if (dayOfWeek === "Weekday") { if (occurrence > 0) { this.moveToFirstDayOfMonth(); if (this.is().weekday()) { occurrence -= 1; } } else if (occurrence < 0) { this.moveToLastDayOfMonth(); if (this.is().weekday()) { occurrence += 1; } } else { return this; } return this.addWeekdays(occurrence); } var shift = 0; if (occurrence > 0) { shift = occurrence - 1; } else if (occurrence === -1) { this.moveToLastDayOfMonth(); if (this.getDay() !== dayOfWeek) { this.moveToDayOfWeek(dayOfWeek, -1); } return this; } return this.moveToFirstDayOfMonth().addDays(-1).moveToDayOfWeek(dayOfWeek, +1).addWeeks(shift); }; var moveToN = function (getFunc, addFunc, nVal) { return function (value, orient) { var diff = (value - this[getFunc]() + nVal * (orient || +1)) % nVal; return this[addFunc]((diff === 0) ? diff += nVal * (orient || +1) : diff); }; }; /** * Move to the next or last dayOfWeek based on the orient value. * @param {Number} The dayOfWeek to move to * @param {Number} Forward (+1) or Back (-1). Defaults to +1. [Optional] * @return {Date} this */ $P.moveToDayOfWeek = moveToN("getDay", "addDays", 7); /** * Move to the next or last month based on the orient value. * @param {Number} The month to move to. 0 = January, 11 = December * @param {Number} Forward (+1) or Back (-1). Defaults to +1. [Optional] * @return {Date} this */ $P.moveToMonth = moveToN("getMonth", "addMonths", 12); /** * Get the Ordinate of the current day ("th", "st", "rd"). * @return {String} */ $P.getOrdinate = function () { var num = this.getDate(); return ord(num); }; /** * Get the Ordinal day (numeric day number) of the year, adjusted for leap year. * @return {Number} 1 through 365 (366 in leap years) */ $P.getOrdinalNumber = function () { return Math.ceil((this.clone().clearTime() - new Date(this.getFullYear(), 0, 1)) / 86400000) + 1; }; /** * Get the time zone abbreviation of the current date. * @return {String} The abbreviated time zone name (e.g. "EST") */ $P.getTimezone = function () { return $D.getTimezoneAbbreviation(this.getUTCOffset(), this.isDaylightSavingTime()); }; $P.setTimezoneOffset = function (offset) { var here = this.getTimezoneOffset(), there = Number(offset) * -6 / 10; return (there || there === 0) ? this.addMinutes(there - here) : this; }; $P.setTimezone = function (offset) { return this.setTimezoneOffset($D.getTimezoneOffset(offset)); }; /** * Indicates whether Daylight Saving Time is observed in the current time zone. * @return {Boolean} true|false */ $P.hasDaylightSavingTime = function () { return (Date.today().set({month: 0, day: 1}).getTimezoneOffset() !== Date.today().set({month: 6, day: 1}).getTimezoneOffset()); }; /** * Indicates whether this Date instance is within the Daylight Saving Time range for the current time zone. * @return {Boolean} true|false */ $P.isDaylightSavingTime = function () { return Date.today().set({month: 0, day: 1}).getTimezoneOffset() !== this.getTimezoneOffset(); }; /** * Get the offset from UTC of the current date. * @return {String} The 4-character offset string prefixed with + or - (e.g. "-0500") */ $P.getUTCOffset = function (offset) { var n = (offset || this.getTimezoneOffset()) * -10 / 6, r; if (n < 0) { r = (n - 10000).toString(); return r.charAt(0) + r.substr(2); } else { r = (n + 10000).toString(); return "+" + r.substr(1); } }; /** * Returns the number of milliseconds between this date and date. * @param {Date} Defaults to now * @return {Number} The diff in milliseconds */ $P.getElapsed = function (date) { return (date || new Date()) - this; }; /** * Set the value of year, month, day, hour, minute, second, millisecond of date instance using given configuration object. * Example

	Date.today().set( { day: 20, month: 1 } )

	new Date().set( { millisecond: 0 } )
	
* * @param {Object} Configuration object containing attributes (month, day, etc.) * @return {Date} this */ $P.set = function (config) { config = validateConfigObject.call(this, config); var key; for (key in config) { if (Object.prototype.hasOwnProperty.call(config, key)) { var name = key.charAt(0).toUpperCase() + key.slice(1); var addFunc, getFunc; if (key !== "week" && key !== "month" && key !== "timezone" && key !== "timezoneOffset") { name += "s"; } addFunc = "add" + name; getFunc = "get" + name; if (key === "month") { addFunc = addFunc + "s"; } else if (key === "year"){ getFunc = "getFullYear"; } if (key !== "day" && key !== "timezone" && key !== "timezoneOffset" && key !== "week" && key !== "hour") { this[addFunc](config[key] - this[getFunc]()); } else if ( key === "timezone"|| key === "timezoneOffset" || key === "week" || key === "hour") { this["set"+name](config[key]); } } } // day has to go last because you can't validate the day without first knowing the month if (config.day) { this.addDays(config.day - this.getDate()); } return this; }; /** * Moves the date to the first day of the month. * @return {Date} this */ $P.moveToFirstDayOfMonth = function () { return this.set({ day: 1 }); }; /** * Moves the date to the last day of the month. * @return {Date} this */ $P.moveToLastDayOfMonth = function () { return this.set({ day: $D.getDaysInMonth(this.getFullYear(), this.getMonth())}); }; /** * Converts the value of the current Date object to its equivalent string representation. * Format Specifiers * CUSTOM DATE AND TIME FORMAT STRINGS * Format Description Example * ------ --------------------------------------------------------------------------- ----------------------- * s The seconds of the minute between 0-59. "0" to "59" * ss The seconds of the minute with leading zero if required. "00" to "59" * * m The minute of the hour between 0-59. "0" or "59" * mm The minute of the hour with leading zero if required. "00" or "59" * * h The hour of the day between 1-12. "1" to "12" * hh The hour of the day with leading zero if required. "01" to "12" * * H The hour of the day between 0-23. "0" to "23" * HH The hour of the day with leading zero if required. "00" to "23" * * d The day of the month between 1 and 31. "1" to "31" * dd The day of the month with leading zero if required. "01" to "31" * ddd Abbreviated day name. Date.CultureInfo.abbreviatedDayNames. "Mon" to "Sun" * dddd The full day name. Date.CultureInfo.dayNames. "Monday" to "Sunday" * * M The month of the year between 1-12. "1" to "12" * MM The month of the year with leading zero if required. "01" to "12" * MMM Abbreviated month name. Date.CultureInfo.abbreviatedMonthNames. "Jan" to "Dec" * MMMM The full month name. Date.CultureInfo.monthNames. "January" to "December" * * yy The year as a two-digit number. "99" or "08" * yyyy The full four digit year. "1999" or "2008" * * t Displays the first character of the A.M./P.M. designator. "A" or "P" * Date.CultureInfo.amDesignator or Date.CultureInfo.pmDesignator * tt Displays the A.M./P.M. designator. "AM" or "PM" * Date.CultureInfo.amDesignator or Date.CultureInfo.pmDesignator * * S The ordinal suffix ("st, "nd", "rd" or "th") of the current day. "st, "nd", "rd" or "th" * * STANDARD DATE AND TIME FORMAT STRINGS * Format Description Example *------ --------------------------------------------------------------------------- ----------------------- * d The CultureInfo shortDate Format Pattern "M/d/yyyy" * D The CultureInfo longDate Format Pattern "dddd, MMMM dd, yyyy" * F The CultureInfo fullDateTime Format Pattern "dddd, MMMM dd, yyyy h:mm:ss tt" * m The CultureInfo monthDay Format Pattern "MMMM dd" * r The CultureInfo rfc1123 Format Pattern "ddd, dd MMM yyyy HH:mm:ss GMT" * s The CultureInfo sortableDateTime Format Pattern "yyyy-MM-ddTHH:mm:ss" * t The CultureInfo shortTime Format Pattern "h:mm tt" * T The CultureInfo longTime Format Pattern "h:mm:ss tt" * u The CultureInfo universalSortableDateTime Format Pattern "yyyy-MM-dd HH:mm:ssZ" * y The CultureInfo yearMonth Format Pattern "MMMM, yyyy" * * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @return {String} A string representation of the current Date object. */ var ord = function (n) { switch (n * 1) { case 1: case 21: case 31: return "st"; case 2: case 22: return "nd"; case 3: case 23: return "rd"; default: return "th"; } }; var parseStandardFormats = function (format) { var y, c = Date.CultureInfo.formatPatterns; switch (format) { case "d": return this.toString(c.shortDate); case "D": return this.toString(c.longDate); case "F": return this.toString(c.fullDateTime); case "m": return this.toString(c.monthDay); case "r": case "R": y = this.clone().addMinutes(this.getTimezoneOffset()); return y.toString(c.rfc1123) + " GMT"; case "s": return this.toString(c.sortableDateTime); case "t": return this.toString(c.shortTime); case "T": return this.toString(c.longTime); case "u": y = this.clone().addMinutes(this.getTimezoneOffset()); return y.toString(c.universalSortableDateTime); case "y": return this.toString(c.yearMonth); default: return false; } }; var parseFormatStringsClosure = function (context) { return function (m) { if (m.charAt(0) === "\\") { return m.replace("\\", ""); } switch (m) { case "hh": return p(context.getHours() < 13 ? (context.getHours() === 0 ? 12 : context.getHours()) : (context.getHours() - 12)); case "h": return context.getHours() < 13 ? (context.getHours() === 0 ? 12 : context.getHours()) : (context.getHours() - 12); case "HH": return p(context.getHours()); case "H": return context.getHours(); case "mm": return p(context.getMinutes()); case "m": return context.getMinutes(); case "ss": return p(context.getSeconds()); case "s": return context.getSeconds(); case "yyyy": return p(context.getFullYear(), 4); case "yy": return p(context.getFullYear()); case "y": return context.getFullYear(); case "E": case "dddd": return Date.CultureInfo.dayNames[context.getDay()]; case "ddd": return Date.CultureInfo.abbreviatedDayNames[context.getDay()]; case "dd": return p(context.getDate()); case "d": return context.getDate(); case "MMMM": return Date.CultureInfo.monthNames[context.getMonth()]; case "MMM": return Date.CultureInfo.abbreviatedMonthNames[context.getMonth()]; case "MM": return p((context.getMonth() + 1)); case "M": return context.getMonth() + 1; case "t": return context.getHours() < 12 ? Date.CultureInfo.amDesignator.substring(0, 1) : Date.CultureInfo.pmDesignator.substring(0, 1); case "tt": return context.getHours() < 12 ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator; case "S": return ord(context.getDate()); case "W": return context.getWeek(); case "WW": return context.getISOWeek(); case "Q": return "Q" + context.getQuarter(); case "q": return String(context.getQuarter()); case "z": return context.getTimezone(); case "Z": case "X": return Date.getTimezoneOffset(context.getTimezone()); case "ZZ": // Timezone offset in seconds return context.getTimezoneOffset() * -60; case "u": return context.getDay(); case "L": return ($D.isLeapYear(context.getFullYear())) ? 1 : 0; case "B": // Swatch Internet Time (.beats) return "@"+((context.getUTCSeconds() + (context.getUTCMinutes()*60) + ((context.getUTCHours()+1)*3600))/86.4); default: return m; } }; }; $P.toString = function (format, ignoreStandards) { // Standard Date and Time Format Strings. Formats pulled from CultureInfo file and // may vary by culture. if (!ignoreStandards && format && format.length === 1) { output = parseStandardFormats.call(this, format); if (output) { return output; } } var parseFormatStrings = parseFormatStringsClosure(this); return format ? format.replace(/((\\)?(dd?d?d?|MM?M?M?|yy?y?y?|hh?|HH?|mm?|ss?|tt?|S|q|Q|WW?W?W?)(?![^\[]*\]))/g, parseFormatStrings).replace(/\[|\]/g, "") : this._toString(); }; }()); /************************************************************* * SugarPak - Domain Specific Language - Syntactical Sugar * *************************************************************/ (function () { var $D = Date, $P = $D.prototype, $N = Number.prototype; // private $P._orient = +1; // private $P._nth = null; // private $P._is = false; // private $P._same = false; // private $P._isSecond = false; // private $N._dateElement = "days"; /** * Moves the date to the next instance of a date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.today().next().friday();
	Date.today().next().fri();
	Date.today().next().march();
	Date.today().next().mar();
	Date.today().next().week();
	
* * @return {Date} date */ $P.next = function () { this._move = true; this._orient = +1; return this; }; /** * Creates a new Date (Date.today()) and moves the date to the next instance of the date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.next().friday();
	Date.next().fri();
	Date.next().march();
	Date.next().mar();
	Date.next().week();
	
* * @return {Date} date */ $D.next = function () { return $D.today().next(); }; /** * Moves the date to the previous instance of a date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.today().last().friday();
	Date.today().last().fri();
	Date.today().last().march();
	Date.today().last().mar();
	Date.today().last().week();
	
* * @return {Date} date */ $P.last = $P.prev = $P.previous = function () { this._move = true; this._orient = -1; return this; }; /** * Creates a new Date (Date.today()) and moves the date to the previous instance of the date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.last().friday();
	Date.last().fri();
	Date.previous().march();
	Date.prev().mar();
	Date.last().week();
	
* * @return {Date} date */ $D.last = $D.prev = $D.previous = function () { return $D.today().last(); }; /** * Performs a equality check when followed by either a month name, day name or .weekday() function. * Example

	Date.today().is().friday(); // true|false
	Date.today().is().fri();
	Date.today().is().march();
	Date.today().is().mar();
	
* * @return {Boolean} true|false */ $P.is = function () { this._is = true; return this; }; /** * Determines if two date objects occur on/in exactly the same instance of the subsequent date part function. * The function .same() must be followed by a date part function (example: .day(), .month(), .year(), etc). * * An optional Date can be passed in the date part function. If now date is passed as a parameter, 'Now' is used. * * The following example demonstrates how to determine if two dates fall on the exact same day. * * Example

	var d1 = Date.today(); // today at 00:00
	var d2 = new Date();   // exactly now.

	// Do they occur on the same day?
	d1.same().day(d2); // true
	
	// Do they occur on the same hour?
	d1.same().hour(d2); // false, unless d2 hour is '00' (midnight).
	
	// What if it's the same day, but one year apart?
	var nextYear = Date.today().add(1).year();

	d1.same().day(nextYear); // false, because the dates must occur on the exact same day. 
	
* * Scenario: Determine if a given date occurs during some week period 2 months from now. * * Example

	var future = Date.today().add(2).months();
	return someDate.same().week(future); // true|false;
	
* * @return {Boolean} true|false */ $P.same = function () { this._same = true; this._isSecond = false; return this; }; /** * Determines if the current date/time occurs during Today. Must be preceded by the .is() function. * Example

	someDate.is().today();    // true|false
	new Date().is().today();  // true
	Date.today().is().today();// true
	Date.today().add(-1).day().is().today(); // false
	
* * @return {Boolean} true|false */ $P.today = function () { return this.same().day(); }; /** * Determines if the current date is a weekday. This function must be preceded by the .is() function. * Example

	Date.today().is().weekday(); // true|false
	
* * @return {Boolean} true|false */ $P.weekday = function () { if (this._nth) { return df("Weekday").call(this); } if (this._move) { return this.addWeekdays(this._orient); } if (this._is) { this._is = false; return (!this.is().sat() && !this.is().sun()); } return false; }; /** * Determines if the current date is on the weekend. This function must be preceded by the .is() function. * Example

	Date.today().is().weekend(); // true|false
	
* * @return {Boolean} true|false */ $P.weekend = function () { if (this._is) { this._is = false; return (this.is().sat() || this.is().sun()); } return false; }; /** * Sets the Time of the current Date instance. A string "6:15 pm" or config object {hour:18, minute:15} are accepted. * Example

	// Set time to 6:15pm with a String
	Date.today().at("6:15pm");

	// Set time to 6:15pm with a config object
	Date.today().at({hour:18, minute:15});
	
* * @return {Date} date */ $P.at = function (time) { return (typeof time === "string") ? $D.parse(this.toString("d") + " " + time) : this.set(time); }; /** * Creates a new Date() and adds this (Number) to the date based on the preceding date element function (eg. second|minute|hour|day|month|year). * Example

	// Undeclared Numbers must be wrapped with parentheses. Requirment of JavaScript.
	(3).days().fromNow();
	(6).months().fromNow();

	// Declared Number variables do not require parentheses. 
	var n = 6;
	n.months().fromNow();
	
* * @return {Date} A new Date instance */ $N.fromNow = $N.after = function (date) { var c = {}; c[this._dateElement] = this; return ((!date) ? new Date() : date.clone()).add(c); }; /** * Creates a new Date() and subtract this (Number) from the date based on the preceding date element function (eg. second|minute|hour|day|month|year). * Example

	// Undeclared Numbers must be wrapped with parentheses. Requirment of JavaScript.
	(3).days().ago();
	(6).months().ago();

	// Declared Number variables do not require parentheses. 
	var n = 6;
	n.months().ago();
	
* * @return {Date} A new Date instance */ $N.ago = $N.before = function (date) { var c = {}, s = (this._dateElement[this._dateElement.length-1] !== "s") ? this._dateElement + "s" : this._dateElement; c[s] = this * -1; return ((!date) ? new Date() : date.clone()).add(c); }; // Do NOT modify the following string tokens. These tokens are used to build dynamic functions. // All culture-specific strings can be found in the CultureInfo files. var dx = ("sunday monday tuesday wednesday thursday friday saturday").split(/\s/), mx = ("january february march april may june july august september october november december").split(/\s/), px = ("Millisecond Second Minute Hour Day Week Month Year Quarter Weekday").split(/\s/), pxf = ("Milliseconds Seconds Minutes Hours Date Week Month FullYear Quarter").split(/\s/), nth = ("final first second third fourth fifth").split(/\s/), de; /** * Returns an object literal of all the date parts. * Example

	var o = new Date().toObject();
	
	// { year: 2008, month: 4, week: 20, day: 13, hour: 18, minute: 9, second: 32, millisecond: 812 }
	
	// The object properties can be referenced directly from the object.
	
	alert(o.day);  // alerts "13"
	alert(o.year); // alerts "2008"
	
* * @return {Date} An object literal representing the original date object. */ $P.toObject = function () { var o = {}; for (var i = 0; i < px.length; i++) { if (this["get" + pxf[i]]) { o[px[i].toLowerCase()] = this["get" + pxf[i]](); } } return o; }; /** * Returns a date created from an object literal. Ignores the .week property if set in the config. * Example

	var o = new Date().toObject();
	
	return Date.fromObject(o); // will return the same date. 

	var o2 = {month: 1, day: 20, hour: 18}; // birthday party!
	Date.fromObject(o2);
	
* * @return {Date} An object literal representing the original date object. */ $D.fromObject = function(config) { config.week = null; return Date.today().set(config); }; // Create day name functions and abbreviated day name functions (eg. monday(), friday(), fri()). var df = function (n) { return function () { if (this._is) { this._is = false; return this.getDay() === n; } if (this._move) { this._move = null; } if (this._nth !== null) { // If the .second() function was called earlier, remove the _orient // from the date, and then continue. // This is required because 'second' can be used in two different context. // // Example // // Date.today().add(1).second(); // Date.march().second().monday(); // // Things get crazy with the following... // Date.march().add(1).second().second().monday(); // but it works!! // if (this._isSecond) { this.addSeconds(this._orient * -1); } // make sure we reset _isSecond this._isSecond = false; var ntemp = this._nth; this._nth = null; var temp = this.clone().moveToLastDayOfMonth(); this.moveToNthOccurrence(n, ntemp); if (this > temp) { throw new RangeError($D.getDayName(n) + " does not occur " + ntemp + " times in the month of " + $D.getMonthName(temp.getMonth()) + " " + temp.getFullYear() + "."); } return this; } return this.moveToDayOfWeek(n, this._orient); }; }; var sdf = function (n) { return function () { var t = $D.today(), shift = n - t.getDay(); if (n === 0 && Date.CultureInfo.firstDayOfWeek === 1 && t.getDay() !== 0) { shift = shift + 7; } return t.addDays(shift); }; }; // Create month name functions and abbreviated month name functions (eg. january(), march(), mar()). var month_instance_functions = function (n) { return function () { if (this._is) { this._is = false; return this.getMonth() === n; } return this.moveToMonth(n, this._orient); }; }; var month_static_functions = function (n) { return function () { return $D.today().set({ month: n, day: 1 }); }; }; var processTerms = function (names, staticFunc, instanceFunc) { for (var i = 0; i < names.length; i++) { // Create constant static Name variables. $D[names[i].toUpperCase()] = $D[names[i].toUpperCase().substring(0, 3)] = i; // Create Name functions. $D[names[i]] = $D[names[i].substring(0, 3)] = staticFunc(i); // Create Name instance functions. $P[names[i]] = $P[names[i].substring(0, 3)] = instanceFunc(i); } }; processTerms(dx, sdf, df); processTerms(mx, month_static_functions, month_instance_functions); // Create date element functions and plural date element functions used with Date (eg. day(), days(), months()). var ef = function (j) { return function () { // if the .second() function was called earlier, the _orient // has alread been added. Just return this and reset _isSecond. if (this._isSecond) { this._isSecond = false; return this; } if (this._same) { this._same = this._is = false; var o1 = this.toObject(), o2 = (arguments[0] || new Date()).toObject(), v = "", k = j.toLowerCase(); // the substr trick with -1 doesn't work in IE8 or less k = (k[k.length-1] === "s") ? k.substring(0,k.length-1) : k; for (var m = (px.length - 1); m > -1; m--) { v = px[m].toLowerCase(); if (o1[v] !== o2[v]) { return false; } if (k === v) { break; } } return true; } if (j.substring(j.length - 1) !== "s") { j += "s"; } if (this._move) { this._move = null; } return this["add" + j](this._orient); }; }; var nf = function (n) { return function () { this._dateElement = n; return this; }; }; for (var k = 0; k < px.length; k++) { de = px[k].toLowerCase(); if(de !== "weekday") { // Create date element functions and plural date element functions used with Date (eg. day(), days(), months()). $P[de] = $P[de + "s"] = ef(px[k]); // Create date element functions and plural date element functions used with Number (eg. day(), days(), months()). $N[de] = $N[de + "s"] = nf(de + "s"); } } $P._ss = ef("Second"); var nthfn = function (n) { return function (dayOfWeek) { if (this._same) { return this._ss(arguments[0]); } if (dayOfWeek || dayOfWeek === 0) { return this.moveToNthOccurrence(dayOfWeek, n); } this._nth = n; // if the operator is 'second' add the _orient, then deal with it later... if (n === 2 && (dayOfWeek === undefined || dayOfWeek === null)) { this._isSecond = true; return this.addSeconds(this._orient); } return this; }; }; for (var l = 0; l < nth.length; l++) { $P[nth[l]] = (l === 0) ? nthfn(-1) : nthfn(l); } }()); (function () { "use strict"; Date.Parsing = { Exception: function (s) { this.message = "Parse error at '" + s.substring(0, 10) + " ...'"; } }; var $P = Date.Parsing; var dayOffsets = { standard: [0,31,59,90,120,151,181,212,243,273,304,334], leap: [0,31,60,91,121,152,182,213,244,274,305,335] }; $P.isLeapYear = function(year) { return ((year % 4 === 0) && (year % 100 !== 0)) || (year % 400 === 0); }; var utils = { multiReplace : function (str, hash ) { var key; for (key in hash) { if (Object.prototype.hasOwnProperty.call(hash, key)) { var regex; if (typeof hash[key] === "function") { } else { regex = (hash[key] instanceof RegExp) ? hash[key] : new RegExp(hash[key], "g"); } str = str.replace(regex, key); } } return str; }, getDayOfYearFromWeek : function (obj) { var d, jan4, offset; obj.weekDay = (!obj.weekDay && obj.weekDay !== 0) ? 1 : obj.weekDay; d = new Date(obj.year, 0, 4); jan4 = d.getDay() === 0 ? 7 : d.getDay(); // JS is 0 indexed on Sunday. offset = jan4+3; obj.dayOfYear = ((obj.week * 7) + (obj.weekDay === 0 ? 7 : obj.weekDay))-offset; return obj; }, getDayOfYear : function (obj, dayOffset) { if (!obj.dayOfYear) { obj = utils.getDayOfYearFromWeek(obj); } for (var i=0;i <= dayOffset.length;i++) { if (obj.dayOfYear < dayOffset[i] || i === dayOffset.length) { obj.day = obj.day ? obj.day : (obj.dayOfYear - dayOffset[i-1]); break; } else { obj.month = i; } } return obj; }, adjustForTimeZone : function (obj, date) { var offset; if (obj.zone.toUpperCase() === "Z" || (obj.zone_hours === 0 && obj.zone_minutes === 0)) { // it's UTC/GML so work out the current timeszone offset offset = -date.getTimezoneOffset(); } else { offset = (obj.zone_hours*60) + (obj.zone_minutes || 0); if (obj.zone_sign === "+") { offset *= -1; } offset -= date.getTimezoneOffset(); } date.setMinutes(date.getMinutes()+offset); return date; }, setDefaults : function (obj) { obj.year = obj.year || Date.today().getFullYear(); obj.hours = obj.hours || 0; obj.minutes = obj.minutes || 0; obj.seconds = obj.seconds || 0; obj.milliseconds = obj.milliseconds || 0; if (!(!obj.month && (obj.week || obj.dayOfYear))) { // if we have a month, or if we don't but don't have the day calculation data obj.month = obj.month || 0; obj.day = obj.day || 1; } return obj; }, dataNum: function (data, mod, explict, postProcess) { var dataNum = data*1; if (mod) { if (postProcess) { return data ? mod(data)*1 : data; } else { return data ? mod(dataNum) : data; } } else if (!explict){ return data ? dataNum : data; } else { return (data && typeof data !== "undefined") ? dataNum : data; } }, timeDataProcess: function (obj) { var timeObj = {}; for (var x in obj.data) { if (obj.data.hasOwnProperty(x)) { timeObj[x] = obj.ignore[x] ? obj.data[x] : utils.dataNum(obj.data[x], obj.mods[x], obj.explict[x], obj.postProcess[x]); } } if (obj.data.secmins) { obj.data.secmins = obj.data.secmins.replace(",", ".") * 60; if (!timeObj.minutes) { timeObj.minutes = obj.data.secmins; } else if (!timeObj.seconds) { timeObj.seconds = obj.data.secmins; } delete obj.secmins; } return timeObj; }, buildTimeObjectFromData: function (data) { var time = utils.timeDataProcess({ data: { year : data[1], month : data[5], day : data[7], week : data[8], dayOfYear : data[10], hours : data[15], zone_hours : data[23], zone_minutes : data[24], zone : data[21], zone_sign : data[22], weekDay : data[9], minutes: data[16], seconds: data[19], milliseconds: data[20], secmins: data[18] }, mods: { month: function(data) { return data-1; }, weekDay: function (data) { data = Math.abs(data); return (data === 7 ? 0 : data); }, minutes: function (data) { return data.replace(":",""); }, seconds: function (data) { return Math.floor( (data.replace(":","").replace(",","."))*1 ); }, milliseconds: function (data) { return (data.replace(",",".")*1000); } }, postProcess: { minutes: true, seconds: true, milliseconds: true }, explict: { zone_hours: true, zone_minutes: true }, ignore: { zone: true, zone_sign: true, secmins: true } }); return time; }, addToHash: function (hash, keys, data) { keys = keys; data = data; var len = keys.length; for (var i = 0; i < len; i++) { hash[keys[i]] = data[i]; } return hash; }, combineRegex: function (r1, r2) { return new RegExp("(("+r1.source+")\\s("+r2.source+"))"); }, getDateNthString: function(add, last, inc){ if (add) { return Date.today().addDays(inc).toString("d"); } else if (last) { return Date.today().last()[inc]().toString("d"); } }, buildRegexData: function (array) { var arr = []; var len = array.length; for (var i=0; i < len; i++) { if (Object.prototype.toString.call(array[i]) === '[object Array]') { // oldIE compat version of Array.isArray arr.push(this.combineRegex(array[i][0], array[i][1])); } else { arr.push(array[i]); } } return arr; } }; $P.processTimeObject = function (obj) { var date, dayOffset; utils.setDefaults(obj); dayOffset = ($P.isLeapYear(obj.year)) ? dayOffsets.leap : dayOffsets.standard; if (!obj.month && (obj.week || obj.dayOfYear)) { utils.getDayOfYear(obj, dayOffset); } else { obj.dayOfYear = dayOffset[obj.month] + obj.day; } date = new Date(obj.year, obj.month, obj.day, obj.hours, obj.minutes, obj.seconds, obj.milliseconds); if (obj.zone) { utils.adjustForTimeZone(obj, date); // adjust (and calculate) for timezone } return date; }; $P.ISO = { regex : /^([\+-]?\d{4}(?!\d{2}\b))((-?)((0[1-9]|1[0-2])(\3([12]\d|0[1-9]|3[01]))?|W([0-4]\d|5[0-3])(-?[1-7])?|(00[1-9]|0[1-9]\d|[12]\d{2}|3([0-5]\d|6[1-6])))([T\s]((([01]\d|2[0-4])((:?)[0-5]\d)?|24\:?00)([\.,]\d+(?!:))?)?(\17[0-5]\d([\.,]\d+)?)?\s?([zZ]|([\+-])([01]\d|2[0-3]):?([0-5]\d)?)?)?)?$/, parse : function (s) { var time, data = s.match(this.regex); if (!data || !data.length) { return null; } time = utils.buildTimeObjectFromData(data); if (!time.year || (!time.year && (!time.month && !time.day) && (!time.week && !time.dayOfYear)) ) { return null; } return $P.processTimeObject(time); } }; $P.Numeric = { isNumeric: function (e){return!isNaN(parseFloat(e))&&isFinite(e);}, regex: /\b([0-1]?[0-9])([0-3]?[0-9])([0-2]?[0-9]?[0-9][0-9])\b/i, parse: function (s) { var data, i, time = {}, order = Date.CultureInfo.dateElementOrder.split(""); if (!(this.isNumeric(s)) || // if it's non-numeric OR (s[0] === "+" && s[0] === "-")) { // It's an arithmatic string (eg +/-1000) return null; } if (s.length < 5 && s.indexOf(".") < 0 && s.indexOf("/") < 0) { // assume it's just a year. time.year = s; return $P.processTimeObject(time); } data = s.match(this.regex); if (!data || !data.length) { return null; } for (i=0; i < order.length; i++) { switch(order[i]) { case "d": time.day = data[i+1]; break; case "m": time.month = (data[i+1]-1); break; case "y": time.year = data[i+1]; break; } } return $P.processTimeObject(time); } }; $P.Normalizer = { regexData: function () { var $R = Date.CultureInfo.regexPatterns; return utils.buildRegexData([ $R.tomorrow, $R.yesterday, [$R.past, $R.mon], [$R.past, $R.tue], [$R.past, $R.wed], [$R.past, $R.thu], [$R.past, $R.fri], [$R.past, $R.sat], [$R.past, $R.sun] ]); }, basicReplaceHash : function() { var $R = Date.CultureInfo.regexPatterns; return { "January": $R.jan.source, "February": $R.feb, "March": $R.mar, "April": $R.apr, "May": $R.may, "June": $R.jun, "July": $R.jul, "August": $R.aug, "September": $R.sep, "October": $R.oct, "November": $R.nov, "December": $R.dec, "": /\bat\b/gi, " ": /\s{2,}/, "am": $R.inTheMorning, "9am": $R.thisMorning, "pm": $R.inTheEvening, "7pm":$R.thisEvening }; }, keys : function(){ return [ utils.getDateNthString(true, false, 1), // tomorrow utils.getDateNthString(true, false, -1), // yesterday utils.getDateNthString(false, true, "monday"), //last mon utils.getDateNthString(false, true, "tuesday"), //last tues utils.getDateNthString(false, true, "wednesday"), //last wed utils.getDateNthString(false, true, "thursday"), //last thurs utils.getDateNthString(false, true, "friday"), //last fri utils.getDateNthString(false, true, "saturday"), //last sat utils.getDateNthString(false, true, "sunday") //last sun ]; }, buildRegexFunctions: function () { var $R = Date.CultureInfo.regexPatterns; var __ = Date.i18n.__; var tomorrowRE = new RegExp("(\\b\\d\\d?("+__("AM")+"|"+__("PM")+")? )("+$R.tomorrow.source.slice(1)+")", "i"); // adapted tomorrow regex for AM PM relative dates var todayRE = new RegExp($R.today.source + "(?!\\s*([+-]))\\b"); // today, but excludes the math operators (eg "today + 2h") this.replaceFuncs = [ [todayRE, function (full) { return (full.length > 1) ? Date.today().toString("d") : full; }], [tomorrowRE, function(full, m1) { var t = Date.today().addDays(1).toString("d"); return (t + " " + m1); }], [$R.amThisMorning, function(str, am){return am;}], [$R.pmThisEvening, function(str, pm){return pm;}] ]; }, buildReplaceData: function () { this.buildRegexFunctions(); this.replaceHash = utils.addToHash(this.basicReplaceHash(), this.keys(), this.regexData()); }, stringReplaceFuncs: function (s) { for (var i=0; i < this.replaceFuncs.length; i++) { s = s.replace(this.replaceFuncs[i][0], this.replaceFuncs[i][1]); } return s; }, parse: function (s) { s = this.stringReplaceFuncs(s); s = utils.multiReplace(s, this.replaceHash); try { var n = s.split(/([\s\-\.\,\/\x27]+)/); if (n.length === 3 && $P.Numeric.isNumeric(n[0]) && $P.Numeric.isNumeric(n[2]) && (n[2].length >= 4)) { // ok, so we're dealing with x/year. But that's not a full date. // This fixes wonky dateElementOrder parsing when set to dmy order. if (Date.CultureInfo.dateElementOrder[0] === "d") { s = "1/" + n[0] + "/" + n[2]; // set to 1st of month and normalize the seperator } } } catch (e) {} return s; } }; $P.Normalizer.buildReplaceData(); }()); (function () { var $P = Date.Parsing; var _ = $P.Operators = { // // Tokenizers // rtoken: function (r) { // regex token return function (s) { var mx = s.match(r); if (mx) { return ([ mx[0], s.substring(mx[0].length) ]); } else { throw new $P.Exception(s); } }; }, token: function () { // whitespace-eating token return function (s) { return _.rtoken(new RegExp("^\\s*" + s + "\\s*"))(s); }; }, stoken: function (s) { // string token return _.rtoken(new RegExp("^" + s)); }, // Atomic Operators until: function (p) { return function (s) { var qx = [], rx = null; while (s.length) { try { rx = p.call(this, s); } catch (e) { qx.push(rx[0]); s = rx[1]; continue; } break; } return [ qx, s ]; }; }, many: function (p) { return function (s) { var rx = [], r = null; while (s.length) { try { r = p.call(this, s); } catch (e) { return [ rx, s ]; } rx.push(r[0]); s = r[1]; } return [ rx, s ]; }; }, // generator operators -- see below optional: function (p) { return function (s) { var r = null; try { r = p.call(this, s); } catch (e) { return [ null, s ]; } return [ r[0], r[1] ]; }; }, not: function (p) { return function (s) { try { p.call(this, s); } catch (e) { return [null, s]; } throw new $P.Exception(s); }; }, ignore: function (p) { return p ? function (s) { var r = null; r = p.call(this, s); return [null, r[1]]; } : null; }, product: function () { var px = arguments[0], qx = Array.prototype.slice.call(arguments, 1), rx = []; for (var i = 0 ; i < px.length ; i++) { rx.push(_.each(px[i], qx)); } return rx; }, cache: function (rule) { var cache = {}, cache_length = 0, cache_keys = [], CACHE_MAX = Date.Config.CACHE_MAX || 100000, r = null; var cacheCheck = function () { if (cache_length === CACHE_MAX) { // kill several keys, don't want to have to do this all the time... for (var i=0; i < 10; i++) { var key = cache_keys.shift(); if (key) { delete cache[key]; cache_length--; } } } }; return function (s) { cacheCheck(); try { r = cache[s] = (cache[s] || rule.call(this, s)); } catch (e) { r = cache[s] = e; } cache_length++; cache_keys.push(s); if (r instanceof $P.Exception) { throw r; } else { return r; } }; }, // vector operators -- see below any: function () { var px = arguments; return function (s) { var r = null; for (var i = 0; i < px.length; i++) { if (px[i] == null) { continue; } try { r = (px[i].call(this, s)); } catch (e) { r = null; } if (r) { return r; } } throw new $P.Exception(s); }; }, each: function () { var px = arguments; return function (s) { var rx = [], r = null; for (var i = 0; i < px.length ; i++) { if (px[i] == null) { continue; } try { r = (px[i].call(this, s)); } catch (e) { throw new $P.Exception(s); } rx.push(r[0]); s = r[1]; } return [ rx, s]; }; }, all: function () { var px = arguments, _ = _; return _.each(_.optional(px)); }, // delimited operators sequence: function (px, d, c) { d = d || _.rtoken(/^\s*/); c = c || null; if (px.length === 1) { return px[0]; } return function (s) { var r = null, q = null; var rx = []; for (var i = 0; i < px.length ; i++) { try { r = px[i].call(this, s); } catch (e) { break; } rx.push(r[0]); try { q = d.call(this, r[1]); } catch (ex) { q = null; break; } s = q[1]; } if (!r) { throw new $P.Exception(s); } if (q) { throw new $P.Exception(q[1]); } if (c) { try { r = c.call(this, r[1]); } catch (ey) { throw new $P.Exception(r[1]); } } return [ rx, (r?r[1]:s) ]; }; }, // // Composite Operators // between: function (d1, p, d2) { d2 = d2 || d1; var _fn = _.each(_.ignore(d1), p, _.ignore(d2)); return function (s) { var rx = _fn.call(this, s); return [[rx[0][0], r[0][2]], rx[1]]; }; }, list: function (p, d, c) { d = d || _.rtoken(/^\s*/); c = c || null; return (p instanceof Array ? _.each(_.product(p.slice(0, -1), _.ignore(d)), p.slice(-1), _.ignore(c)) : _.each(_.many(_.each(p, _.ignore(d))), px, _.ignore(c))); }, set: function (px, d, c) { d = d || _.rtoken(/^\s*/); c = c || null; return function (s) { // r is the current match, best the current 'best' match // which means it parsed the most amount of input var r = null, p = null, q = null, rx = null, best = [[], s], last = false; // go through the rules in the given set for (var i = 0; i < px.length ; i++) { // last is a flag indicating whether this must be the last element // if there is only 1 element, then it MUST be the last one q = null; p = null; r = null; last = (px.length === 1); // first, we try simply to match the current pattern // if not, try the next pattern try { r = px[i].call(this, s); } catch (e) { continue; } // since we are matching against a set of elements, the first // thing to do is to add r[0] to matched elements rx = [[r[0]], r[1]]; // if we matched and there is still input to parse and // we don't already know this is the last element, // we're going to next check for the delimiter ... // if there's none, or if there's no input left to parse // than this must be the last element after all ... if (r[1].length > 0 && ! last) { try { q = d.call(this, r[1]); } catch (ex) { last = true; } } else { last = true; } // if we parsed the delimiter and now there's no more input, // that means we shouldn't have parsed the delimiter at all // so don't update r and mark this as the last element ... if (!last && q[1].length === 0) { last = true; } // so, if this isn't the last element, we're going to see if // we can get any more matches from the remaining (unmatched) // elements ... if (!last) { // build a list of the remaining rules we can match against, // i.e., all but the one we just matched against var qx = []; for (var j = 0; j < px.length ; j++) { if (i !== j) { qx.push(px[j]); } } // now invoke recursively set with the remaining input // note that we don't include the closing delimiter ... // we'll check for that ourselves at the end p = _.set(qx, d).call(this, q[1]); // if we got a non-empty set as a result ... // (otw rx already contains everything we want to match) if (p[0].length > 0) { // update current result, which is stored in rx ... // basically, pick up the remaining text from p[1] // and concat the result from p[0] so that we don't // get endless nesting ... rx[0] = rx[0].concat(p[0]); rx[1] = p[1]; } } // at this point, rx either contains the last matched element // or the entire matched set that starts with this element. // now we just check to see if this variation is better than // our best so far, in terms of how much of the input is parsed if (rx[1].length < best[1].length) { best = rx; } // if we've parsed all the input, then we're finished if (best[1].length === 0) { break; } } // so now we've either gone through all the patterns trying them // as the initial match; or we found one that parsed the entire // input string ... // if best has no matches, just return empty set ... if (best[0].length === 0) { return best; } // if a closing delimiter is provided, then we have to check it also if (c) { // we try this even if there is no remaining input because the pattern // may well be optional or match empty input ... try { q = c.call(this, best[1]); } catch (ey) { throw new $P.Exception(best[1]); } // it parsed ... be sure to update the best match remaining input best[1] = q[1]; } // if we're here, either there was no closing delimiter or we parsed it // so now we have the best match; just return it! return best; }; }, forward: function (gr, fname) { return function (s) { return gr[fname].call(this, s); }; }, // // Translation Operators // replace: function (rule, repl) { return function (s) { var r = rule.call(this, s); return [repl, r[1]]; }; }, process: function (rule, fn) { return function (s) { var r = rule.call(this, s); return [fn.call(this, r[0]), r[1]]; }; }, min: function (min, rule) { return function (s) { var rx = rule.call(this, s); if (rx[0].length < min) { throw new $P.Exception(s); } return rx; }; } }; // Generator Operators And Vector Operators // Generators are operators that have a signature of F(R) => R, // taking a given rule and returning another rule, such as // ignore, which parses a given rule and throws away the result. // Vector operators are those that have a signature of F(R1,R2,...) => R, // take a list of rules and returning a new rule, such as each. // Generator operators are converted (via the following _generator // function) into functions that can also take a list or array of rules // and return an array of new rules as though the function had been // called on each rule in turn (which is what actually happens). // This allows generators to be used with vector operators more easily. // Example: // each(ignore(foo, bar)) instead of each(ignore(foo), ignore(bar)) // This also turns generators into vector operators, which allows // constructs like: // not(cache(foo, bar)) var _generator = function (op) { function gen() { var args = null, rx = [], px, i; if (arguments.length > 1) { args = Array.prototype.slice.call(arguments); } else if (arguments[0] instanceof Array) { args = arguments[0]; } if (args) { px = args.shift(); if (px.length > 0) { args.unshift(px[i]); rx.push(op.apply(null, args)); args.shift(); return rx; } } else { return op.apply(null, arguments); } } return gen; }; var gx = "optional not ignore cache".split(/\s/); for (var i = 0 ; i < gx.length ; i++) { _[gx[i]] = _generator(_[gx[i]]); } var _vector = function (op) { return function () { if (arguments[0] instanceof Array) { return op.apply(null, arguments[0]); } else { return op.apply(null, arguments); } }; }; var vx = "each any all".split(/\s/); for (var j = 0 ; j < vx.length ; j++) { _[vx[j]] = _vector(_[vx[j]]); } }()); (function () { var $D = Date; var flattenAndCompact = function (ax) { var rx = []; for (var i = 0; i < ax.length; i++) { if (ax[i] instanceof Array) { rx = rx.concat(flattenAndCompact(ax[i])); } else { if (ax[i]) { rx.push(ax[i]); } } } return rx; }; var parseMeridian = function () { if (this.meridian && (this.hour || this.hour === 0)) { if (this.meridian === "a" && this.hour > 11 && Date.Config.strict24hr){ throw "Invalid hour and meridian combination"; } else if (this.meridian === "p" && this.hour < 12 && Date.Config.strict24hr){ throw "Invalid hour and meridian combination"; } else if (this.meridian === "p" && this.hour < 12) { this.hour = this.hour + 12; } else if (this.meridian === "a" && this.hour === 12) { this.hour = 0; } } }; var setDefaults = function () { var now = new Date(); if ((this.hour || this.minute) && (!this.month && !this.year && !this.day)) { this.day = now.getDate(); } if (!this.year) { this.year = now.getFullYear(); } if (!this.month && this.month !== 0) { this.month = now.getMonth(); } if (!this.day) { this.day = 1; } if (!this.hour) { this.hour = 0; } if (!this.minute) { this.minute = 0; } if (!this.second) { this.second = 0; } if (!this.millisecond) { this.millisecond = 0; } }; var finishUtils = { getToday: function () { if (this.now || "hour minute second".indexOf(this.unit) !== -1) { return new Date(); } else { return $D.today(); } }, setDaysFromWeekday: function (today, orient){ var gap; orient = orient || 1; this.unit = "day"; gap = ($D.getDayNumberFromName(this.weekday) - today.getDay()); this.days = gap ? ((gap + (orient * 7)) % 7) : (orient * 7); return this; }, setMonthsFromMonth: function (today, orient) { var gap; orient = orient || 1; this.unit = "month"; gap = (this.month - today.getMonth()); this.months = gap ? ((gap + (orient * 12)) % 12) : (orient * 12); this.month = null; return this; }, setDMYFromWeekday: function () { var d = Date[this.weekday](); this.day = d.getDate(); if (!this.month) { this.month = d.getMonth(); } this.year = d.getFullYear(); return this; }, setUnitValue: function (orient) { if (!this.value && this.operator && this.operator !== null && this[this.unit + "s"] && this[this.unit + "s"] !== null) { this[this.unit + "s"] = this[this.unit + "s"] + ((this.operator === "add") ? 1 : -1) + (this.value||0) * orient; } else if (this[this.unit + "s"] == null || this.operator != null) { if (!this.value) { this.value = 1; } this[this.unit + "s"] = this.value * orient; } }, generateDateFromWeeks: function () { var weekday = (this.weekday !== undefined) ? this.weekday : "today"; var d = Date[weekday]().addWeeks(this.weeks); if (this.now) { d.setTimeToNow(); } return d; } }; $D.Translator = { hour: function (s) { return function () { this.hour = Number(s); }; }, minute: function (s) { return function () { this.minute = Number(s); }; }, second: function (s) { return function () { this.second = Number(s); }; }, /* for ss.s format */ secondAndMillisecond: function (s) { return function () { var mx = s.match(/^([0-5][0-9])\.([0-9]{1,3})/); this.second = Number(mx[1]); this.millisecond = Number(mx[2]); }; }, meridian: function (s) { return function () { this.meridian = s.slice(0, 1).toLowerCase(); }; }, timezone: function (s) { return function () { var n = s.replace(/[^\d\+\-]/g, ""); if (n.length) { this.timezoneOffset = Number(n); } else { this.timezone = s.toLowerCase(); } }; }, day: function (x) { var s = x[0]; return function () { this.day = Number(s.match(/\d+/)[0]); if (this.day < 1) { throw "invalid day"; } }; }, month: function (s) { return function () { this.month = (s.length === 3) ? "jan feb mar apr may jun jul aug sep oct nov dec".indexOf(s)/4 : Number(s) - 1; if (this.month < 0) { throw "invalid month"; } }; }, year: function (s) { return function () { var n = Number(s); this.year = ((s.length > 2) ? n : (n + (((n + 2000) < Date.CultureInfo.twoDigitYearMax) ? 2000 : 1900))); }; }, rday: function (s) { return function () { switch (s) { case "yesterday": this.days = -1; break; case "tomorrow": this.days = 1; break; case "today": this.days = 0; break; case "now": this.days = 0; this.now = true; break; } }; }, finishExact: function (x) { var d; x = (x instanceof Array) ? x : [x]; for (var i = 0 ; i < x.length ; i++) { if (x[i]) { x[i].call(this); } } setDefaults.call(this); parseMeridian.call(this); if (this.day > $D.getDaysInMonth(this.year, this.month)) { throw new RangeError(this.day + " is not a valid value for days."); } d = new Date(this.year, this.month, this.day, this.hour, this.minute, this.second, this.millisecond); if (this.year < 100) { d.setFullYear(this.year); // means years less that 100 are process correctly. JS will parse it otherwise as 1900-1999. } if (this.timezone) { d.set({ timezone: this.timezone }); } else if (this.timezoneOffset) { d.set({ timezoneOffset: this.timezoneOffset }); } return d; }, finish: function (x) { var today, expression, orient, temp; x = (x instanceof Array) ? flattenAndCompact(x) : [ x ]; if (x.length === 0) { return null; } for (var i = 0 ; i < x.length ; i++) { if (typeof x[i] === "function") { x[i].call(this); } } if (this.now && !this.unit && !this.operator) { return new Date(); } else { today = finishUtils.getToday.call(this); } expression = !!(this.days && this.days !== null || this.orient || this.operator); orient = ((this.orient === "past" || this.operator === "subtract") ? -1 : 1); if (this.month && this.unit === "week") { this.value = this.month + 1; delete this.month; delete this.day; } if ((this.month || this.month === 0) && "year day hour minute second".indexOf(this.unit) !== -1) { if (!this.value) { this.value = this.month + 1; } this.month = null; expression = true; } if (!expression && this.weekday && !this.day && !this.days) { finishUtils.setDMYFromWeekday.call(this); } if (expression && this.weekday && this.unit !== "month" && this.unit !== "week") { finishUtils.setDaysFromWeekday.call(this, today, orient); } if (this.weekday && this.unit !== "week" && !this.day && !this.days) { temp = Date[this.weekday](); this.day = temp.getDate(); if (temp.getMonth() !== today.getMonth()) { this.month = temp.getMonth(); } } if (this.month && this.unit === "day" && this.operator) { if (!this.value) { this.value = (this.month + 1); } this.month = null; } if (this.value != null && this.month != null && this.year != null) { this.day = this.value * 1; } if (this.month && !this.day && this.value) { today.set({ day: this.value * 1 }); if (!expression) { this.day = this.value * 1; } } if (!this.month && this.value && this.unit === "month" && !this.now) { this.month = this.value; expression = true; } if (expression && (this.month || this.month === 0) && this.unit !== "year") { finishUtils.setMonthsFromMonth.call(this, today, orient); } if (!this.unit) { this.unit = "day"; } finishUtils.setUnitValue.call(this, orient); parseMeridian.call(this); if ((this.month || this.month === 0) && !this.day) { this.day = 1; } if (!this.orient && !this.operator && this.unit === "week" && this.value && !this.day && !this.month) { return Date.today().setWeek(this.value); } if (this.unit === "week" && this.weeks && !this.day && !this.month) { return finishUtils.generateDateFromWeeks.call(this); } if (expression && this.timezone && this.day && this.days) { this.day = this.days; } if (expression){ today.add(this); } else { today.set(this); } if (this.timezone) { this.timezone = this.timezone.toUpperCase(); var offset = $D.getTimezoneOffset(this.timezone); var timezone; if (today.hasDaylightSavingTime()) { // lets check that we're being sane with timezone setting timezone = $D.getTimezoneAbbreviation(offset, today.isDaylightSavingTime()); if (timezone !== this.timezone) { // bugger, we're in a place where things like EST vs EDT matters. if (today.isDaylightSavingTime()) { today.addHours(-1); } else { today.addHours(1); } } } today.setTimezoneOffset(offset); } return today; } }; }()); (function () { var $D = Date; $D.Grammar = {}; var _ = $D.Parsing.Operators, g = $D.Grammar, t = $D.Translator, _fn; // Allow rolling up into general purpose rules _fn = function () { return _.each(_.any.apply(null, arguments), _.not(g.ctoken2("timeContext"))); }; g.datePartDelimiter = _.rtoken(/^([\s\-\.\,\/\x27]+)/); g.timePartDelimiter = _.stoken(":"); g.whiteSpace = _.rtoken(/^\s*/); g.generalDelimiter = _.rtoken(/^(([\s\,]|at|@|on)+)/); var _C = {}; g.ctoken = function (keys) { var fn = _C[keys]; if (! fn) { var c = Date.CultureInfo.regexPatterns; var kx = keys.split(/\s+/), px = []; for (var i = 0; i < kx.length ; i++) { px.push(_.replace(_.rtoken(c[kx[i]]), kx[i])); } fn = _C[keys] = _.any.apply(null, px); } return fn; }; g.ctoken2 = function (key) { return _.rtoken(Date.CultureInfo.regexPatterns[key]); }; var cacheProcessRtoken = function (key, token, type, eachToken) { if (eachToken) { g[key] = _.cache(_.process(_.each(_.rtoken(token),_.optional(g.ctoken2(eachToken))), type)); } else { g[key] = _.cache(_.process(_.rtoken(token), type)); } }; var cacheProcessCtoken = function (token, type) { return _.cache(_.process(g.ctoken2(token), type)); }; var _F = {}; //function cache var _get = function (f) { _F[f] = (_F[f] || g.format(f)[0]); return _F[f]; }; g.allformats = function (fx) { var rx = []; if (fx instanceof Array) { for (var i = 0; i < fx.length; i++) { rx.push(_get(fx[i])); } } else { rx.push(_get(fx)); } return rx; }; g.formats = function (fx) { if (fx instanceof Array) { var rx = []; for (var i = 0 ; i < fx.length ; i++) { rx.push(_get(fx[i])); } return _.any.apply(null, rx); } else { return _get(fx); } }; var grammarFormats = { timeFormats: function(){ var i, RTokenKeys = [ "h", "hh", "H", "HH", "m", "mm", "s", "ss", "ss.s", "z", "zz" ], RToken = [ /^(0[0-9]|1[0-2]|[1-9])/, /^(0[0-9]|1[0-2])/, /^([0-1][0-9]|2[0-3]|[0-9])/, /^([0-1][0-9]|2[0-3])/, /^([0-5][0-9]|[0-9])/, /^[0-5][0-9]/, /^([0-5][0-9]|[0-9])/, /^[0-5][0-9]/, /^[0-5][0-9]\.[0-9]{1,3}/, /^((\+|\-)\s*\d\d\d\d)|((\+|\-)\d\d\:?\d\d)/, /^((\+|\-)\s*\d\d\d\d)|((\+|\-)\d\d\:?\d\d)/ ], tokens = [ t.hour, t.hour, t.hour, t.hour, t.minute, t.minute, t.second, t.second, t.secondAndMillisecond, t.timezone, t.timezone ]; for (i=0; i < RTokenKeys.length; i++) { cacheProcessRtoken(RTokenKeys[i], RToken[i], tokens[i]); } g.hms = _.cache(_.sequence([g.H, g.m, g.s], g.timePartDelimiter)); g.t = cacheProcessCtoken("shortMeridian", t.meridian); g.tt = cacheProcessCtoken("longMeridian", t.meridian); g.zzz = cacheProcessCtoken("timezone", t.timezone); g.timeSuffix = _.each(_.ignore(g.whiteSpace), _.set([ g.tt, g.zzz ])); g.time = _.each(_.optional(_.ignore(_.stoken("T"))), g.hms, g.timeSuffix); }, dateFormats: function () { // pre-loaded rules for different date part order preferences var _setfn = function () { return _.set(arguments, g.datePartDelimiter); }; var i, RTokenKeys = [ "d", "dd", "M", "MM", "y", "yy", "yyy", "yyyy" ], RToken = [ /^([0-2]\d|3[0-1]|\d)/, /^([0-2]\d|3[0-1])/, /^(1[0-2]|0\d|\d)/, /^(1[0-2]|0\d)/, /^(\d+)/, /^(\d\d)/, /^(\d\d?\d?\d?)/, /^(\d\d\d\d)/ ], tokens = [ t.day, t.day, t.month, t.month, t.year, t.year, t.year, t.year ], eachToken = [ "ordinalSuffix", "ordinalSuffix" ]; for (i=0; i < RTokenKeys.length; i++) { cacheProcessRtoken(RTokenKeys[i], RToken[i], tokens[i], eachToken[i]); } g.MMM = g.MMMM = _.cache(_.process(g.ctoken("jan feb mar apr may jun jul aug sep oct nov dec"), t.month)); g.ddd = g.dddd = _.cache(_.process(g.ctoken("sun mon tue wed thu fri sat"), function (s) { return function () { this.weekday = s; }; } )); g.day = _fn(g.d, g.dd); g.month = _fn(g.M, g.MMM); g.year = _fn(g.yyyy, g.yy); g.mdy = _setfn(g.ddd, g.month, g.day, g.year); g.ymd = _setfn(g.ddd, g.year, g.month, g.day); g.dmy = _setfn(g.ddd, g.day, g.month, g.year); g.date = function (s) { return ((g[Date.CultureInfo.dateElementOrder] || g.mdy).call(this, s)); }; }, relative: function () { // relative date / time expressions g.orientation = _.process(g.ctoken("past future"), function (s) { return function () { this.orient = s; }; } ); g.operator = _.process(g.ctoken("add subtract"), function (s) { return function () { this.operator = s; }; } ); g.rday = _.process(g.ctoken("yesterday tomorrow today now"), t.rday); g.unit = _.process(g.ctoken("second minute hour day week month year"), function (s) { return function () { this.unit = s; }; } ); } }; g.buildGrammarFormats = function () { // these need to be rebuilt every time the language changes. _C = {}; grammarFormats.timeFormats(); grammarFormats.dateFormats(); grammarFormats.relative(); g.value = _.process(_.rtoken(/^([-+]?\d+)?(st|nd|rd|th)?/), function (s) { return function () { this.value = s.replace(/\D/g, ""); }; } ); g.expression = _.set([g.rday, g.operator, g.value, g.unit, g.orientation, g.ddd, g.MMM ]); g.format = _.process(_.many( _.any( // translate format specifiers into grammar rules _.process( _.rtoken(/^(dd?d?d?(?!e)|MM?M?M?|yy?y?y?|hh?|HH?|mm?|ss?|tt?|zz?z?)/), function (fmt) { if (g[fmt]) { return g[fmt]; } else { throw $D.Parsing.Exception(fmt); } } ), // translate separator tokens into token rules _.process(_.rtoken(/^[^dMyhHmstz]+/), // all legal separators function (s) { return _.ignore(_.stoken(s)); } ) ) ), // construct the parser ... function (rules) { return _.process(_.each.apply(null, rules), t.finishExact); } ); // starting rule for general purpose grammar g._start = _.process(_.set([ g.date, g.time, g.expression ], g.generalDelimiter, g.whiteSpace), t.finish); }; g.buildGrammarFormats(); // parsing date format specifiers - ex: "h:m:s tt" // this little guy will generate a custom parser based // on the format string, ex: g.format("h:m:s tt") // check for these formats first g._formats = g.formats([ "\"yyyy-MM-ddTHH:mm:ssZ\"", "yyyy-MM-ddTHH:mm:ss.sz", "yyyy-MM-ddTHH:mm:ssZ", "yyyy-MM-ddTHH:mm:ssz", "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-ddTHH:mmZ", "yyyy-MM-ddTHH:mmz", "yyyy-MM-ddTHH:mm", "ddd, MMM dd, yyyy H:mm:ss tt", "ddd MMM d yyyy HH:mm:ss zzz", "MMddyyyy", "ddMMyyyy", "Mddyyyy", "ddMyyyy", "Mdyyyy", "dMyyyy", "yyyy", "Mdyy", "dMyy", "d" ]); // real starting rule: tries selected formats first, // then general purpose rule g.start = function (s) { try { var r = g._formats.call({}, s); if (r[1].length === 0) { return r; } } catch (e) {} return g._start.call({}, s); }; }()); (function () { var $D = Date; /** * @desc Converts the specified string value into its JavaScript Date equivalent using CultureInfo specific format information. * * Example

	///////////
	// Dates //
	///////////

	// 15-Oct-2004
	var d1 = Date.parse("10/15/2004");

	// 15-Oct-2004
	var d1 = Date.parse("15-Oct-2004");

	// 15-Oct-2004
	var d1 = Date.parse("2004.10.15");

	//Fri Oct 15, 2004
	var d1 = Date.parse("Fri Oct 15, 2004");

	///////////
	// Times //
	///////////

	// Today at 10 PM.
	var d1 = Date.parse("10 PM");

	// Today at 10:30 PM.
	var d1 = Date.parse("10:30 P.M.");

	// Today at 6 AM.
	var d1 = Date.parse("06am");

	/////////////////////
	// Dates and Times //
	/////////////////////

	// 8-July-2004 @ 10:30 PM
	var d1 = Date.parse("July 8th, 2004, 10:30 PM");

	// 1-July-2004 @ 10:30 PM
	var d1 = Date.parse("2004-07-01T22:30:00");

	////////////////////
	// Relative Dates //
	////////////////////

	// Returns today's date. The string "today" is culture specific.
	var d1 = Date.parse("today");

	// Returns yesterday's date. The string "yesterday" is culture specific.
	var d1 = Date.parse("yesterday");

	// Returns the date of the next thursday.
	var d1 = Date.parse("Next thursday");

	// Returns the date of the most previous monday.
	var d1 = Date.parse("last monday");

	// Returns today's day + one year.
	var d1 = Date.parse("next year");

	///////////////
	// Date Math //
	///////////////

	// Today + 2 days
	var d1 = Date.parse("t+2");

	// Today + 2 days
	var d1 = Date.parse("today + 2 days");

	// Today + 3 months
	var d1 = Date.parse("t+3m");

	// Today - 1 year
	var d1 = Date.parse("today - 1 year");

	// Today - 1 year
	var d1 = Date.parse("t-1y"); 


	/////////////////////////////
	// Partial Dates and Times //
	/////////////////////////////

	// July 15th of this year.
	var d1 = Date.parse("July 15");

	// 15th day of current day and year.
	var d1 = Date.parse("15");

	// July 1st of current year at 10pm.
	var d1 = Date.parse("7/1 10pm");
	
* * @param {String} The string value to convert into a Date object [Required] * @return {Date} A Date object or null if the string cannot be converted into a Date. */ var parseUtils = { removeOrds: function (s) { ords = s.match(/\b(\d+)(?:st|nd|rd|th)\b/); // find ordinal matches s = ((ords && ords.length === 2) ? s.replace(ords[0], ords[1]) : s); return s; }, grammarParser: function (s) { var r = null; try { r = $D.Grammar.start.call({}, s.replace(/^\s*(\S*(\s+\S+)*)\s*$/, "$1")); } catch (e) { return null; } return ((r[1].length === 0) ? r[0] : null); }, nativeFallback: function(s) { var t; try { // ok we haven't parsed it, last ditch attempt with the built-in parser. t = Date._parse(s); return (t || t === 0) ? new Date(t) : null; } catch (e) { return null; } } }; function parse (s) { var d; if (!s) { return null; } if (s instanceof Date) { return s.clone(); } if (s.length >= 4 && s.charAt(0) !== "0" && s.charAt(0) !== "+"&& s.charAt(0) !== "-") { // ie: 2004 will pass, 0800 won't. // Start with specific formats d = $D.Parsing.ISO.parse(s) || $D.Parsing.Numeric.parse(s); } if (d instanceof Date && !isNaN(d.getTime())) { return d; } else { // find ordinal dates (1st, 3rd, 8th, etc and remove them as they cause parsing issues) s = $D.Parsing.Normalizer.parse(parseUtils.removeOrds(s)); d = parseUtils.grammarParser(s); if (d !== null) { return d; } else { return parseUtils.nativeFallback(s); } } } if (!$D._parse) { $D._parse = $D.parse; } $D.parse = parse; Date.getParseFunction = function (fx) { var fns = Date.Grammar.allformats(fx); return function (s) { var r = null; for (var i = 0; i < fns.length; i++) { try { r = fns[i].call({}, s); } catch (e) { continue; } if (r[1].length === 0) { return r[0]; } } return null; }; }; /** * Converts the specified string value into its JavaScript Date equivalent using the specified format {String} or formats {Array} and the CultureInfo specific format information. * The format of the string value must match one of the supplied formats exactly. * * Example

	// 15-Oct-2004
	var d1 = Date.parseExact("10/15/2004", "M/d/yyyy");

	// 15-Oct-2004
	var d1 = Date.parse("15-Oct-2004", "M-ddd-yyyy");

	// 15-Oct-2004
	var d1 = Date.parse("2004.10.15", "yyyy.MM.dd");

	// Multiple formats
	var d1 = Date.parseExact("10/15/2004", ["M/d/yyyy", "MMMM d, yyyy"]);
	
* * @param {String} The string value to convert into a Date object [Required]. * @param {Object} The expected format {String} or an array of expected formats {Array} of the date string [Required]. * @return {Date} A Date object or null if the string cannot be converted into a Date. */ $D.parseExact = function (s, fx) { return $D.getParseFunction(fx)(s); }; }()); (function () { var $D = Date, $P = $D.prototype, // $C = $D.CultureInfo, // not used atm p = function (s, l) { if (!l) { l = 2; } return ("000" + s).slice(l * -1); }; /** * Converts a PHP format string to Java/.NET format string. * A PHP format string can be used with ._format or .format. * A Java/.NET format string can be used with .toString(). * The .parseExact function will only accept a Java/.NET format string * * Example * var f1 = "%m/%d/%y" * var f2 = Date.normalizeFormat(f1); // "MM/dd/yy" * * new Date().format(f1); // "04/13/08" * new Date()._format(f1); // "04/13/08" * new Date().toString(f2); // "04/13/08" * * var date = Date.parseExact("04/13/08", f2); // Sun Apr 13 2008 * * @param {String} A PHP format string consisting of one or more format spcifiers. * @return {String} The PHP format converted to a Java/.NET format string. */ var normalizerSubstitutions = { "d" : "dd", "%d": "dd", "D" : "ddd", "%a": "ddd", "j" : "dddd", "l" : "dddd", "%A": "dddd", "S" : "S", "F" : "MMMM", "%B": "MMMM", "m" : "MM", "%m": "MM", "M" : "MMM", "%b": "MMM", "%h": "MMM", "n" : "M", "Y" : "yyyy", "%Y": "yyyy", "y" : "yy", "%y": "yy", "g" : "h", "%I": "h", "G" : "H", "h" : "hh", "H" : "HH", "%H": "HH", "i" : "mm", "%M": "mm", "s" : "ss", "%S": "ss", "%r": "hh:mm tt", "%R": "H:mm", "%T": "H:mm:ss", "%X": "t", "%x": "d", "%e": "d", "%D": "MM/dd/yy", "%n": "\\n", "%t": "\\t", "e" : "z", "T" : "z", "%z": "z", "%Z": "z", "Z" : "ZZ", "N" : "u", "w" : "u", "%w": "u", "W" : "W", "%V": "W" }; var normalizer = { substitutes: function (m) { return normalizerSubstitutions[m]; }, interpreted: function (m, x) { var y; switch (m) { case "%u": return x.getDay() + 1; case "z": return x.getOrdinalNumber(); case "%j": return p(x.getOrdinalNumber(), 3); case "%U": var d1 = x.clone().set({month: 0, day: 1}).addDays(-1).moveToDayOfWeek(0), d2 = x.clone().addDays(1).moveToDayOfWeek(0, -1); return (d2 < d1) ? "00" : p((d2.getOrdinalNumber() - d1.getOrdinalNumber()) / 7 + 1); case "%W": return p(x.getWeek()); case "t": return $D.getDaysInMonth(x.getFullYear(), x.getMonth()); case "o": case "%G": return x.setWeek(x.getISOWeek()).toString("yyyy"); case "%g": return x._format("%G").slice(-2); case "a": case "%p": return t("tt").toLowerCase(); case "A": return t("tt").toUpperCase(); case "u": return p(x.getMilliseconds(), 3); case "I": return (x.isDaylightSavingTime()) ? 1 : 0; case "O": return x.getUTCOffset(); case "P": y = x.getUTCOffset(); return y.substring(0, y.length - 2) + ":" + y.substring(y.length - 2); case "B": var now = new Date(); return Math.floor(((now.getHours() * 3600) + (now.getMinutes() * 60) + now.getSeconds() + (now.getTimezoneOffset() + 60) * 60) / 86.4); case "c": return x.toISOString().replace(/\"/g, ""); case "U": return $D.strtotime("now"); case "%c": return t("d") + " " + t("t"); case "%C": return Math.floor(x.getFullYear() / 100 + 1); } }, shouldOverrideDefaults: function (m) { switch (m) { case "%e": return true; default: return false; } }, parse: function (m, context) { var formatString, c = context || new Date(); formatString = normalizer.substitutes(m); if (formatString) { return formatString; } formatString = normalizer.interpreted(m, c); if (formatString) { return formatString; } else { return m; } } }; $D.normalizeFormat = function (format, context) { return format.replace(/(%|\\)?.|%%/g, function(t){ return normalizer.parse(t, context); }); }; /** * Format a local Unix timestamp according to locale settings * * Example: * Date.strftime("%m/%d/%y", new Date()); // "04/13/08" * Date.strftime("c", "2008-04-13T17:52:03Z"); // "04/13/08" * * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @param {Number|String} The number representing the number of seconds that have elapsed since January 1, 1970 (local time). * @return {String} A string representation of the current Date object. */ $D.strftime = function (format, time) { var d = Date.parse(time); return d._format(format); }; /** * Parse any textual datetime description into a Unix timestamp. * A Unix timestamp is the number of seconds that have elapsed since January 1, 1970 (midnight UTC/GMT). * * Example: * Date.strtotime("04/13/08"); // 1208044800 * Date.strtotime("1970-01-01T00:00:00Z"); // 0 * * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @param {Object} A string or date object. * @return {String} A string representation of the current Date object. */ $D.strtotime = function (time) { var d = $D.parse(time); return Math.round($D.UTC(d.getUTCFullYear(), d.getUTCMonth(), d.getUTCDate(), d.getUTCHours(), d.getUTCMinutes(), d.getUTCSeconds(), d.getUTCMilliseconds()) / 1000); }; /** * Converts the value of the current Date object to its equivalent string representation using a PHP/Unix style of date format specifiers. * Format Specifiers * Format Description Example * ------ --------------------------------------------------------------------------- ----------------------- * %a abbreviated weekday name according to the current localed "Mon" through "Sun" * %A full weekday name according to the current localed "Sunday" through "Saturday" * %b abbreviated month name according to the current localed "Jan" through "Dec" * %B full month name according to the current locale "January" through "December" * %c preferred date and time representation for the current locale "4/13/2008 12:33 PM" * %C century number (the year divided by 100 and truncated to an integer) "00" to "99" * %d day of the month as a decimal number "01" to "31" * %D same as %m/%d/%y "04/13/08" * %e day of the month as a decimal number, a single digit is preceded by a space "1" to "31" * %g like %G, but without the century "08" * %G The 4-digit year corresponding to the ISO week number (see %V). "2008" * This has the same format and value as %Y, except that if the ISO week number * belongs to the previous or next year, that year is used instead. * %h same as %b "Jan" through "Dec" * %H hour as a decimal number using a 24-hour clock. "00" to "23" * %I hour as a decimal number using a 12-hour clock. "01" to "12" * %j day of the year as a decimal number. "001" to "366" * %m month as a decimal number. "01" to "12" * %M minute as a decimal number. "00" to "59" * %n newline character "\n" * %p either "am" or "pm" according to the given time value, or the "am" or "pm" * corresponding strings for the current locale. * %r time in a.m. and p.m. notation "8:44 PM" * %R time in 24 hour notation "20:44" * %S second as a decimal number "00" to "59" * %t tab character "\t" * %T current time, equal to %H:%M:%S "12:49:11" * %u weekday as a decimal number ["1", "7"], with "1" representing Monday "1" to "7" * %U week number of the current year as a decimal number, starting with the "0" to ("52" or "53") * first Sunday as the first day of the first week * %V The ISO 8601:1988 week number of the current year as a decimal number, "00" to ("52" or "53") * range 01 to 53, where week 1 is the first week that has at least 4 days * in the current year, and with Monday as the first day of the week. * (Use %G or %g for the year component that corresponds to the week number * for the specified timestamp.) * %W week number of the current year as a decimal number, starting with the "00" to ("52" or "53") * first Monday as the first day of the first week * %w day of the week as a decimal, Sunday being "0" "0" to "6" * %x preferred date representation for the current locale without the time "4/13/2008" * %X preferred time representation for the current locale without the date "12:53:05" * %y year as a decimal number without a century "00" "99" * %Y year as a decimal number including the century "2008" * %Z time zone or name or abbreviation "UTC", "EST", "PST" * %z same as %Z * %% a literal "%" characters "%" * d Day of the month, 2 digits with leading zeros "01" to "31" * D A textual representation of a day, three letters "Mon" through "Sun" * j Day of the month without leading zeros "1" to "31" * l A full textual representation of the day of the week (lowercase "L") "Sunday" through "Saturday" * N ISO-8601 numeric representation of the day of the week (added in PHP 5.1.0) "1" (for Monday) through "7" (for Sunday) * S English ordinal suffix for the day of the month, 2 characters "st", "nd", "rd" or "th". Works well with j * w Numeric representation of the day of the week "0" (for Sunday) through "6" (for Saturday) * z The day of the year (starting from "0") "0" through "365" * W ISO-8601 week number of year, weeks starting on Monday "00" to ("52" or "53") * F A full textual representation of a month, such as January or March "January" through "December" * m Numeric representation of a month, with leading zeros "01" through "12" * M A short textual representation of a month, three letters "Jan" through "Dec" * n Numeric representation of a month, without leading zeros "1" through "12" * t Number of days in the given month "28" through "31" * L Whether it's a leap year "1" if it is a leap year, "0" otherwise * o ISO-8601 year number. This has the same value as Y, except that if the "2008" * ISO week number (W) belongs to the previous or next year, that year * is used instead. * Y A full numeric representation of a year, 4 digits "2008" * y A two digit representation of a year "08" * a Lowercase Ante meridiem and Post meridiem "am" or "pm" * A Uppercase Ante meridiem and Post meridiem "AM" or "PM" * B Swatch Internet time "000" through "999" * g 12-hour format of an hour without leading zeros "1" through "12" * G 24-hour format of an hour without leading zeros "0" through "23" * h 12-hour format of an hour with leading zeros "01" through "12" * H 24-hour format of an hour with leading zeros "00" through "23" * i Minutes with leading zeros "00" to "59" * s Seconds, with leading zeros "00" through "59" * u Milliseconds "54321" * e Timezone identifier "UTC", "EST", "PST" * I Whether or not the date is in daylight saving time (uppercase i) "1" if Daylight Saving Time, "0" otherwise * O Difference to Greenwich time (GMT) in hours "+0200", "-0600" * P Difference to Greenwich time (GMT) with colon between hours and minutes "+02:00", "-06:00" * T Timezone abbreviation "UTC", "EST", "PST" * Z Timezone offset in seconds. The offset for timezones west of UTC is "-43200" through "50400" * always negative, and for those east of UTC is always positive. * c ISO 8601 date "2004-02-12T15:19:21+00:00" * r RFC 2822 formatted date "Thu, 21 Dec 2000 16:01:07 +0200" * U Seconds since the Unix Epoch (January 1 1970 00:00:00 GMT) "0" * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @return {String} A string representation of the current Date object. */ var formatReplace = function (context) { return function (m) { var formatString, override = false; if (m.charAt(0) === "\\" || m.substring(0, 2) === "%%") { return m.replace("\\", "").replace("%%", "%"); } override = normalizer.shouldOverrideDefaults(m); formatString = $D.normalizeFormat(m, context); if (formatString) { return context.toString(formatString, override); } }; }; $P._format = function (format) { var formatter = formatReplace(this); if (!format) { return this._toString(); } else { return format.replace(/(%|\\)?.|%%/g, formatter); } }; if (!$P.format) { $P.format = $P._format; } }()); (function () { "use strict"; var gFn = function (attr) { return function () { return this[attr]; }; }; var sFn = function (attr) { return function (val) { this[attr] = val; return this; }; }; var attrs = ["years", "months", "days", "hours", "minutes", "seconds", "milliseconds"]; var addSetFuncs = function (context, attrs) { for (var i = 0; i < attrs.length ; i++) { var $a = attrs[i], $b = $a.slice(0, 1).toUpperCase() + $a.slice(1); context.prototype[$a] = 0; context.prototype["get" + $b] = gFn($a); context.prototype["set" + $b] = sFn($a); } }; /** * new TimeSpan(milliseconds); * new TimeSpan(days, hours, minutes, seconds); * new TimeSpan(days, hours, minutes, seconds, milliseconds); */ var TimeSpan = function (days, hours, minutes, seconds, milliseconds) { if (arguments.length === 1 && typeof days === "number") { var orient = (days < 0) ? -1 : +1; var millsLeft = Math.abs(days); this.setDays(Math.floor(millsLeft / 86400000) * orient); millsLeft = millsLeft % 86400000; this.setHours(Math.floor(millsLeft / 3600000) * orient); millsLeft = millsLeft % 3600000; this.setMinutes(Math.floor(millsLeft / 60000) * orient); millsLeft = millsLeft % 60000; this.setSeconds(Math.floor(millsLeft / 1000) * orient); millsLeft = millsLeft % 1000; this.setMilliseconds(millsLeft * orient); } else { this.set(days, hours, minutes, seconds, milliseconds); } this.getTotalMilliseconds = function () { return (this.getDays() * 86400000) + (this.getHours() * 3600000) + (this.getMinutes() * 60000) + (this.getSeconds() * 1000); }; this.compareTo = function (time) { var t1 = new Date(1970, 1, 1, this.getHours(), this.getMinutes(), this.getSeconds()), t2; if (time === null) { t2 = new Date(1970, 1, 1, 0, 0, 0); } else { t2 = new Date(1970, 1, 1, time.getHours(), time.getMinutes(), time.getSeconds()); } return (t1 < t2) ? -1 : (t1 > t2) ? 1 : 0; }; this.equals = function (time) { return (this.compareTo(time) === 0); }; this.add = function (time) { return (time === null) ? this : this.addSeconds(time.getTotalMilliseconds() / 1000); }; this.subtract = function (time) { return (time === null) ? this : this.addSeconds(-time.getTotalMilliseconds() / 1000); }; this.addDays = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 86400000)); }; this.addHours = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 3600000)); }; this.addMinutes = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 60000)); }; this.addSeconds = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 1000)); }; this.addMilliseconds = function (n) { return new TimeSpan(this.getTotalMilliseconds() + n); }; this.get12HourHour = function () { return (this.getHours() > 12) ? this.getHours() - 12 : (this.getHours() === 0) ? 12 : this.getHours(); }; this.getDesignator = function () { return (this.getHours() < 12) ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator; }; this.toString = function (format) { this._toString = function () { if (this.getDays() !== null && this.getDays() > 0) { return this.getDays() + "." + this.getHours() + ":" + this.p(this.getMinutes()) + ":" + this.p(this.getSeconds()); } else { return this.getHours() + ":" + this.p(this.getMinutes()) + ":" + this.p(this.getSeconds()); } }; this.p = function (s) { return (s.toString().length < 2) ? "0" + s : s; }; var me = this; return format ? format.replace(/dd?|HH?|hh?|mm?|ss?|tt?/g, function (format) { switch (format) { case "d": return me.getDays(); case "dd": return me.p(me.getDays()); case "H": return me.getHours(); case "HH": return me.p(me.getHours()); case "h": return me.get12HourHour(); case "hh": return me.p(me.get12HourHour()); case "m": return me.getMinutes(); case "mm": return me.p(me.getMinutes()); case "s": return me.getSeconds(); case "ss": return me.p(me.getSeconds()); case "t": return ((me.getHours() < 12) ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator).substring(0, 1); case "tt": return (me.getHours() < 12) ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator; } } ) : this._toString(); }; return this; }; addSetFuncs(TimeSpan, attrs.slice(2)); TimeSpan.prototype.set = function (days, hours, minutes, seconds, milliseconds){ this.setDays(days || this.getDays()); this.setHours(hours || this.getHours()); this.setMinutes(minutes || this.getMinutes()); this.setSeconds(seconds || this.getSeconds()); this.setMilliseconds(milliseconds || this.getMilliseconds()); }; /** * Gets the time of day for this date instances. * @return {TimeSpan} TimeSpan */ Date.prototype.getTimeOfDay = function () { return new TimeSpan(0, this.getHours(), this.getMinutes(), this.getSeconds(), this.getMilliseconds()); }; Date.TimeSpan = TimeSpan; if (typeof window !== "undefined" ) { // keeping API compatible for v1.x window.TimeSpan = TimeSpan; } }()); (function () { "use strict"; var attrs = ["years", "months", "days", "hours", "minutes", "seconds", "milliseconds"]; var gFn = function (attr) { return function () { return this[attr]; }; }; var sFn = function (attr) { return function (val) { this[attr] = val; return this; }; }; var addSetFuncs = function (context, attrs) { for (var i = 0; i < attrs.length ; i++) { var $a = attrs[i], $b = $a.slice(0, 1).toUpperCase() + $a.slice(1); context.prototype[$a] = 0; context.prototype["get" + $b] = gFn($a); context.prototype["set" + $b] = sFn($a); } }; var setMonthsAndYears = function (orient, d1, d2, context) { function inc() { d1.addMonths(-orient); context.months++; if (context.months === 12) { context.years++; context.months = 0; } } if (orient === +1) { while (d1 > d2) { inc(); } } else { while (d1 < d2) { inc(); } } context.months--; context.months *= orient; context.years *= orient; }; var adjustForDST = function(orient, startDate, endDate) { var hasDSTMismatch = (false === (startDate.isDaylightSavingTime() === endDate.isDaylightSavingTime())); if (hasDSTMismatch && orient === 1) { startDate.addHours(-1); } else if (hasDSTMismatch) { startDate.addHours(1); } }; /** * TimePeriod(startDate, endDate); * TimePeriod(years, months, days, hours, minutes, seconds, milliseconds); */ var TimePeriod = function (years, months, days, hours, minutes, seconds, milliseconds) { if (arguments.length === 7) { this.set(years, months, days, hours, minutes, seconds, milliseconds); } else if (arguments.length === 2 && arguments[0] instanceof Date && arguments[1] instanceof Date) { var startDate = arguments[0].clone(); var endDate = arguments[1].clone(); var orient = (startDate > endDate) ? +1 : -1; this.dates = { start: arguments[0].clone(), end: arguments[1].clone() }; setMonthsAndYears(orient, startDate, endDate, this); adjustForDST(orient, startDate, endDate); // // TODO - adjust for DST var diff = endDate - startDate; if (diff !== 0) { var ts = new TimeSpan(diff); this.set(this.years, this.months, ts.getDays(), ts.getHours(), ts.getMinutes(), ts.getSeconds(), ts.getMilliseconds()); } } return this; }; // create all the set functions. addSetFuncs(TimePeriod, attrs); TimePeriod.prototype.set = function (years, months, days, hours, minutes, seconds, milliseconds){ this.setYears(years || this.getYears()); this.setMonths(months || this.getMonths()); this.setDays(days || this.getDays()); this.setHours(hours || this.getHours()); this.setMinutes(minutes || this.getMinutes()); this.setSeconds(seconds || this.getSeconds()); this.setMilliseconds(milliseconds || this.getMilliseconds()); }; Date.TimePeriod = TimePeriod; if (typeof window !== "undefined") { // keeping API compatible for v1.x window.TimePeriod = TimePeriod; } }()); ================================================ FILE: build/date-sk-SK.js ================================================ /** * @overview datejs * @version 1.0.0-rc3 * @author Gregory Wild-Smith * @copyright 2015 Gregory Wild-Smith * @license MIT * @homepage https://github.com/abritinthebay/datejs */ /* * DateJS Culture String File * Country Code: sk-SK * Name: Slovak (Slovakia) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["sk-SK"] = { "name": "sk-SK", "englishName": "Slovak (Slovakia)", "nativeName": "slovenčina (Slovenská republika)", "Sunday": "nedeľa", "Monday": "pondelok", "Tuesday": "utorok", "Wednesday": "streda", "Thursday": "štvrtok", "Friday": "piatok", "Saturday": "sobota", "Sun": "ne", "Mon": "po", "Tue": "ut", "Wed": "st", "Thu": "št", "Fri": "pi", "Sat": "so", "Su": "ne", "Mo": "po", "Tu": "ut", "We": "st", "Th": "št", "Fr": "pi", "Sa": "so", "S_Sun_Initial": "n", "M_Mon_Initial": "p", "T_Tue_Initial": "u", "W_Wed_Initial": "s", "T_Thu_Initial": "š", "F_Fri_Initial": "p", "S_Sat_Initial": "s", "January": "január", "February": "február", "March": "marec", "April": "apríl", "May": "máj", "June": "jún", "July": "júl", "August": "august", "September": "september", "October": "október", "November": "november", "December": "december", "Jan_Abbr": "I", "Feb_Abbr": "II", "Mar_Abbr": "III", "Apr_Abbr": "IV", "May_Abbr": "V", "Jun_Abbr": "VI", "Jul_Abbr": "VII", "Aug_Abbr": "VIII", "Sep_Abbr": "IX", "Oct_Abbr": "X", "Nov_Abbr": "XI", "Dec_Abbr": "XII", "AM": "", "PM": "", "firstDayOfWeek": 1, "twoDigitYearMax": 2029, "mdy": "dmy", "M/d/yyyy": "d. M. yyyy", "dddd, MMMM dd, yyyy": "d. MMMM yyyy", "h:mm tt": "H:mm", "h:mm:ss tt": "H:mm:ss", "dddd, MMMM dd, yyyy h:mm:ss tt": "d. MMMM yyyy H:mm:ss", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "dd MMMM", "MMMM, yyyy": "MMMM yyyy", "/jan(uary)?/": "január", "/feb(ruary)?/": "február", "/mar(ch)?/": "marec", "/apr(il)?/": "apríl", "/may/": "máj", "/jun(e)?/": "jún", "/jul(y)?/": "júl", "/aug(ust)?/": "august", "/sep(t(ember)?)?/": "sep(t(ember)?)?", "/oct(ober)?/": "október", "/nov(ember)?/": "november", "/dec(ember)?/": "december", "/^su(n(day)?)?/": "^nedeľa", "/^mo(n(day)?)?/": "^pondelok", "/^tu(e(s(day)?)?)?/": "^utorok", "/^we(d(nesday)?)?/": "^streda", "/^th(u(r(s(day)?)?)?)?/": "^štvrtok", "/^fr(i(day)?)?/": "^piatok", "/^sa(t(urday)?)?/": "^sobota", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "sk-SK"; /** * @overview datejs * @version 1.0.0-rc3 * @author Gregory Wild-Smith * @copyright 2015 Gregory Wild-Smith * @license MIT * @homepage https://github.com/abritinthebay/datejs */(function () { var $D = Date; var lang = Date.CultureStrings ? Date.CultureStrings.lang : null; var loggedKeys = {}; // for debug purposes. var getText = { getFromKey: function (key, countryCode) { var output; if (Date.CultureStrings && Date.CultureStrings[countryCode] && Date.CultureStrings[countryCode][key]) { output = Date.CultureStrings[countryCode][key]; } else { output = getText.buildFromDefault(key); } if (key.charAt(0) === "/") { // Assume it's a regex output = getText.buildFromRegex(key, countryCode); } return output; }, getFromObjectValues: function (obj, countryCode) { var key, output = {}; for(key in obj) { if (obj.hasOwnProperty(key)) { output[key] = getText.getFromKey(obj[key], countryCode); } } return output; }, getFromObjectKeys: function (obj, countryCode) { var key, output = {}; for(key in obj) { if (obj.hasOwnProperty(key)) { output[getText.getFromKey(key, countryCode)] = obj[key]; } } return output; }, getFromArray: function (arr, countryCode) { var output = []; for (var i=0; i < arr.length; i++){ if (i in arr) { output[i] = getText.getFromKey(arr[i], countryCode); } } return output; }, buildFromDefault: function (key) { var output, length, split, last; switch(key) { case "name": output = "en-US"; break; case "englishName": output = "English (United States)"; break; case "nativeName": output = "English (United States)"; break; case "twoDigitYearMax": output = 2049; break; case "firstDayOfWeek": output = 0; break; default: output = key; split = key.split("_"); length = split.length; if (length > 1 && key.charAt(0) !== "/") { // if the key isn't a regex and it has a split. last = split[(length - 1)].toLowerCase(); if (last === "initial" || last === "abbr") { output = split[0]; } } break; } return output; }, buildFromRegex: function (key, countryCode) { var output; if (Date.CultureStrings && Date.CultureStrings[countryCode] && Date.CultureStrings[countryCode][key]) { output = new RegExp(Date.CultureStrings[countryCode][key], "i"); } else { output = new RegExp(key.replace(new RegExp("/", "g"),""), "i"); } return output; } }; var shallowMerge = function (obj1, obj2) { for (var attrname in obj2) { if (obj2.hasOwnProperty(attrname)) { obj1[attrname] = obj2[attrname]; } } }; var __ = function (key, language) { var countryCode = (language) ? language : lang; loggedKeys[key] = key; if (typeof key === "object") { if (key instanceof Array) { return getText.getFromArray(key, countryCode); } else { return getText.getFromObjectKeys(key, countryCode); } } else { return getText.getFromKey(key, countryCode); } }; var loadI18nScript = function (code) { // paatterned after jQuery's getScript. var url = Date.Config.i18n + code + ".js"; var head = document.getElementsByTagName("head")[0] || document.documentElement; var script = document.createElement("script"); script.src = url; var completed = false; var events = { done: function (){} // placeholder function }; // Attach handlers for all browsers script.onload = script.onreadystatechange = function() { if ( !completed && (!this.readyState || this.readyState === "loaded" || this.readyState === "complete") ) { events.done(); head.removeChild(script); } }; setTimeout(function() { head.insertBefore(script, head.firstChild); }, 0); // allows return to execute first return { done: function (cb) { events.done = function() { if (cb) { setTimeout(cb,0); } }; } }; }; var buildInfo = { buildFromMethodHash: function (obj) { var key; for(key in obj) { if (obj.hasOwnProperty(key)) { obj[key] = buildInfo[obj[key]](); } } return obj; }, timeZoneDST: function () { var DST = { "CHADT": "+1345", "NZDT": "+1300", "AEDT": "+1100", "ACDT": "+1030", "AZST": "+0500", "IRDT": "+0430", "EEST": "+0300", "CEST": "+0200", "BST": "+0100", "PMDT": "-0200", "ADT": "-0300", "NDT": "-0230", "EDT": "-0400", "CDT": "-0500", "MDT": "-0600", "PDT": "-0700", "AKDT": "-0800", "HADT": "-0900" }; return __(DST); }, timeZoneStandard: function () { var standard = { "LINT": "+1400", "TOT": "+1300", "CHAST": "+1245", "NZST": "+1200", "NFT": "+1130", "SBT": "+1100", "AEST": "+1000", "ACST": "+0930", "JST": "+0900", "CWST": "+0845", "CT": "+0800", "ICT": "+0700", "MMT": "+0630", "BST": "+0600", "NPT": "+0545", "IST": "+0530", "PKT": "+0500", "AFT": "+0430", "MSK": "+0400", "IRST": "+0330", "FET": "+0300", "EET": "+0200", "CET": "+0100", "GMT": "+0000", "UTC": "+0000", "CVT": "-0100", "GST": "-0200", "BRT": "-0300", "NST": "-0330", "AST": "-0400", "EST": "-0500", "CST": "-0600", "MST": "-0700", "PST": "-0800", "AKST": "-0900", "MIT": "-0930", "HST": "-1000", "SST": "-1100", "BIT": "-1200" }; return __(standard); }, timeZones: function (data) { var zone; data.timezones = []; for (zone in data.abbreviatedTimeZoneStandard) { if (data.abbreviatedTimeZoneStandard.hasOwnProperty(zone)) { data.timezones.push({ name: zone, offset: data.abbreviatedTimeZoneStandard[zone]}); } } for (zone in data.abbreviatedTimeZoneDST) { if (data.abbreviatedTimeZoneDST.hasOwnProperty(zone)) { data.timezones.push({ name: zone, offset: data.abbreviatedTimeZoneDST[zone], dst: true}); } } return data.timezones; }, days: function () { return __(["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"]); }, dayAbbr: function () { return __(["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"]); }, dayShortNames: function () { return __(["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"]); }, dayFirstLetters: function () { return __(["S_Sun_Initial", "M_Mon_Initial", "T_Tues_Initial", "W_Wed_Initial", "T_Thu_Initial", "F_Fri_Initial", "S_Sat_Initial"]); }, months: function () { return __(["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"]); }, monthAbbr: function () { return __(["Jan_Abbr", "Feb_Abbr", "Mar_Abbr", "Apr_Abbr", "May_Abbr", "Jun_Abbr", "Jul_Abbr", "Aug_Abbr", "Sep_Abbr", "Oct_Abbr", "Nov_Abbr", "Dec_Abbr"]); }, formatPatterns: function () { return getText.getFromObjectValues({ shortDate: "M/d/yyyy", longDate: "dddd, MMMM dd, yyyy", shortTime: "h:mm tt", longTime: "h:mm:ss tt", fullDateTime: "dddd, MMMM dd, yyyy h:mm:ss tt", sortableDateTime: "yyyy-MM-ddTHH:mm:ss", universalSortableDateTime: "yyyy-MM-dd HH:mm:ssZ", rfc1123: "ddd, dd MMM yyyy HH:mm:ss", monthDay: "MMMM dd", yearMonth: "MMMM, yyyy" }, Date.i18n.currentLanguage()); }, regex: function () { return getText.getFromObjectValues({ inTheMorning: "/( in the )(morn(ing)?)\\b/", thisMorning: "/(this )(morn(ing)?)\\b/", amThisMorning: "/(\b\\d(am)? )(this )(morn(ing)?)/", inTheEvening: "/( in the )(even(ing)?)\\b/", thisEvening: "/(this )(even(ing)?)\\b/", pmThisEvening: "/(\b\\d(pm)? )(this )(even(ing)?)/", jan: "/jan(uary)?/", feb: "/feb(ruary)?/", mar: "/mar(ch)?/", apr: "/apr(il)?/", may: "/may/", jun: "/jun(e)?/", jul: "/jul(y)?/", aug: "/aug(ust)?/", sep: "/sep(t(ember)?)?/", oct: "/oct(ober)?/", nov: "/nov(ember)?/", dec: "/dec(ember)?/", sun: "/^su(n(day)?)?/", mon: "/^mo(n(day)?)?/", tue: "/^tu(e(s(day)?)?)?/", wed: "/^we(d(nesday)?)?/", thu: "/^th(u(r(s(day)?)?)?)?/", fri: "/fr(i(day)?)?/", sat: "/^sa(t(urday)?)?/", future: "/^next/", past: "/^last|past|prev(ious)?/", add: "/^(\\+|aft(er)?|from|hence)/", subtract: "/^(\\-|bef(ore)?|ago)/", yesterday: "/^yes(terday)?/", today: "/^t(od(ay)?)?/", tomorrow: "/^tom(orrow)?/", now: "/^n(ow)?/", millisecond: "/^ms|milli(second)?s?/", second: "/^sec(ond)?s?/", minute: "/^mn|min(ute)?s?/", hour: "/^h(our)?s?/", week: "/^w(eek)?s?/", month: "/^m(onth)?s?/", day: "/^d(ay)?s?/", year: "/^y(ear)?s?/", shortMeridian: "/^(a|p)/", longMeridian: "/^(a\\.?m?\\.?|p\\.?m?\\.?)/", timezone: "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/", ordinalSuffix: "/^\\s*(st|nd|rd|th)/", timeContext: "/^\\s*(\\:|a(?!u|p)|p)/" }, Date.i18n.currentLanguage()); } }; var CultureInfo = function () { var info = getText.getFromObjectValues({ name: "name", englishName: "englishName", nativeName: "nativeName", amDesignator: "AM", pmDesignator: "PM", firstDayOfWeek: "firstDayOfWeek", twoDigitYearMax: "twoDigitYearMax", dateElementOrder: "mdy" }, Date.i18n.currentLanguage()); var constructedInfo = buildInfo.buildFromMethodHash({ dayNames: "days", abbreviatedDayNames: "dayAbbr", shortestDayNames: "dayShortNames", firstLetterDayNames: "dayFirstLetters", monthNames: "months", abbreviatedMonthNames: "monthAbbr", formatPatterns: "formatPatterns", regexPatterns: "regex", abbreviatedTimeZoneDST: "timeZoneDST", abbreviatedTimeZoneStandard: "timeZoneStandard" }); shallowMerge(info, constructedInfo); buildInfo.timeZones(info); return info; }; $D.i18n = { __: function (key, lang) { return __(key, lang); }, currentLanguage: function () { return lang || "en-US"; }, setLanguage: function (code, force, cb) { var async = false; if (force || code === "en-US" || (!!Date.CultureStrings && !!Date.CultureStrings[code])) { lang = code; Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings.lang = code; Date.CultureInfo = new CultureInfo(); } else { if (!(!!Date.CultureStrings && !!Date.CultureStrings[code])) { if (typeof exports !== "undefined" && this.exports !== exports) { // we're in a Node enviroment, load it using require try { require("../i18n/" + code + ".js"); lang = code; Date.CultureStrings.lang = code; Date.CultureInfo = new CultureInfo(); } catch (e) { // var str = "The language for '" + code + "' could not be loaded by Node. It likely does not exist."; throw new Error("The DateJS IETF language tag '" + code + "' could not be loaded by Node. It likely does not exist."); } } else if (Date.Config && Date.Config.i18n) { // we know the location of the files, so lets load them async = true; loadI18nScript(code).done(function(){ lang = code; Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings.lang = code; Date.CultureInfo = new CultureInfo(); $D.Parsing.Normalizer.buildReplaceData(); // because this is async if ($D.Grammar) { $D.Grammar.buildGrammarFormats(); // so we can parse those strings... } if (cb) { setTimeout(cb,0); } }); } else { Date.console.error("The DateJS IETF language tag '" + code + "' is not available and has not been loaded."); return false; } } } $D.Parsing.Normalizer.buildReplaceData(); // rebuild normalizer strings if ($D.Grammar) { $D.Grammar.buildGrammarFormats(); // so we can parse those strings... } if (!async && cb) { setTimeout(cb,0); } }, getLoggedKeys: function () { return loggedKeys; }, updateCultureInfo: function () { Date.CultureInfo = new CultureInfo(); } }; $D.i18n.updateCultureInfo(); // run automatically }()); (function () { var $D = Date, $P = $D.prototype, p = function (s, l) { if (!l) { l = 2; } return ("000" + s).slice(l * -1); }; if (typeof window !== "undefined" && typeof window.console !== "undefined" && typeof window.console.log !== "undefined") { $D.console = console; // used only to raise non-critical errors if available } else { // set mock so we don't give errors. $D.console = { log: function(){}, error: function(){} }; } $D.Config = $D.Config || {}; $D.initOverloads = function() { /** * Overload of Date.now. Allows an alternate call for Date.now where it returns the * current Date as an object rather than just milliseconds since the Unix Epoch. * * Also provides an implementation of now() for browsers (IE<9) that don't have it. * * Backwards compatible so with work with either: * Date.now() [returns ms] * or * Date.now(true) [returns Date] */ if (!$D.now) { $D._now = function now() { return new Date().getTime(); }; } else if (!$D._now) { $D._now = $D.now; } $D.now = function (returnObj) { if (returnObj) { return $D.present(); } else { return $D._now(); } }; if ( !$P.toISOString ) { $P.toISOString = function() { return this.getUTCFullYear() + "-" + p(this.getUTCMonth() + 1) + "-" + p(this.getUTCDate()) + "T" + p(this.getUTCHours()) + ":" + p(this.getUTCMinutes()) + ":" + p(this.getUTCSeconds()) + "." + String( (this.getUTCMilliseconds()/1000).toFixed(3)).slice(2, 5) + "Z"; }; } // private if ( $P._toString === undefined ){ $P._toString = $P.toString; } }; $D.initOverloads(); /** * Gets a date that is set to the current date. The time is set to the start of the day (00:00 or 12:00 AM). * @return {Date} The current date. */ $D.today = function () { return new Date().clearTime(); }; /** * Gets a date that is set to the current date and time (same as new Date, but chainable) * @return {Date} The current date. */ $D.present = function () { return new Date(); }; /** * Compares the first date to the second date and returns an number indication of their relative values. * @param {Date} First Date object to compare [Required]. * @param {Date} Second Date object to compare to [Required]. * @return {Number} -1 = date1 is lessthan date2. 0 = values are equal. 1 = date1 is greaterthan date2. */ $D.compare = function (date1, date2) { if (isNaN(date1) || isNaN(date2)) { throw new Error(date1 + " - " + date2); } else if (date1 instanceof Date && date2 instanceof Date) { return (date1 < date2) ? -1 : (date1 > date2) ? 1 : 0; } else { throw new TypeError(date1 + " - " + date2); } }; /** * Compares the first Date object to the second Date object and returns true if they are equal. * @param {Date} First Date object to compare [Required] * @param {Date} Second Date object to compare to [Required] * @return {Boolean} true if dates are equal. false if they are not equal. */ $D.equals = function (date1, date2) { return (date1.compareTo(date2) === 0); }; /** * Gets the language appropriate day name when given the day number(0-6) * eg - 0 == Sunday * @return {String} The day name */ $D.getDayName = function (n) { return Date.CultureInfo.dayNames[n]; }; /** * Gets the day number (0-6) if given a CultureInfo specific string which is a valid dayName, abbreviatedDayName or shortestDayName (two char). * @param {String} The name of the day (eg. "Monday, "Mon", "tuesday", "tue", "We", "we"). * @return {Number} The day number */ $D.getDayNumberFromName = function (name) { var n = Date.CultureInfo.dayNames, m = Date.CultureInfo.abbreviatedDayNames, o = Date.CultureInfo.shortestDayNames, s = name.toLowerCase(); for (var i = 0; i < n.length; i++) { if (n[i].toLowerCase() === s || m[i].toLowerCase() === s || o[i].toLowerCase() === s) { return i; } } return -1; }; /** * Gets the month number (0-11) if given a Culture Info specific string which is a valid monthName or abbreviatedMonthName. * @param {String} The name of the month (eg. "February, "Feb", "october", "oct"). * @return {Number} The day number */ $D.getMonthNumberFromName = function (name) { var n = Date.CultureInfo.monthNames, m = Date.CultureInfo.abbreviatedMonthNames, s = name.toLowerCase(); for (var i = 0; i < n.length; i++) { if (n[i].toLowerCase() === s || m[i].toLowerCase() === s) { return i; } } return -1; }; /** * Gets the language appropriate month name when given the month number(0-11) * eg - 0 == January * @return {String} The month name */ $D.getMonthName = function (n) { return Date.CultureInfo.monthNames[n]; }; /** * Determines if the current date instance is within a LeapYear. * @param {Number} The year. * @return {Boolean} true if date is within a LeapYear, otherwise false. */ $D.isLeapYear = function (year) { return ((year % 4 === 0 && year % 100 !== 0) || year % 400 === 0); }; /** * Gets the number of days in the month, given a year and month value. Automatically corrects for LeapYear. * @param {Number} The year. * @param {Number} The month (0-11). * @return {Number} The number of days in the month. */ $D.getDaysInMonth = function (year, month) { if (!month && $D.validateMonth(year)) { month = year; year = Date.today().getFullYear(); } return [31, ($D.isLeapYear(year) ? 29 : 28), 31, 30, 31, 30, 31, 31, 30, 31, 30, 31][month]; }; $P.getDaysInMonth = function () { return $D.getDaysInMonth(this.getFullYear(), this.getMonth()); }; $D.getTimezoneAbbreviation = function (offset, dst) { var p, n = (dst || false) ? Date.CultureInfo.abbreviatedTimeZoneDST : Date.CultureInfo.abbreviatedTimeZoneStandard; for (p in n) { if (n.hasOwnProperty(p)) { if (n[p] === offset) { return p; } } } return null; }; $D.getTimezoneOffset = function (name, dst) { var i, a =[], z = Date.CultureInfo.timezones; if (!name) { name = (new Date()).getTimezone();} for (i = 0; i < z.length; i++) { if (z[i].name === name.toUpperCase()) { a.push(i); } } if (!z[a[0]]) { return null; } if (a.length === 1 || !dst) { return z[a[0]].offset; } else { for (i=0; i < a.length; i++) { if (z[a[i]].dst) { return z[a[i]].offset; } } } }; $D.getQuarter = function (d) { d = d || new Date(); // If no date supplied, use today var q = [1,2,3,4]; return q[Math.floor(d.getMonth() / 3)]; // ~~~ is a bitwise op. Faster than Math.floor }; $D.getDaysLeftInQuarter = function (d) { d = d || new Date(); var qEnd = new Date(d); qEnd.setMonth(qEnd.getMonth() + 3 - qEnd.getMonth() % 3, 0); return Math.floor((qEnd - d) / 8.64e7); }; // private var validate = function (n, min, max, name) { name = name ? name : "Object"; if (typeof n === "undefined") { return false; } else if (typeof n !== "number") { throw new TypeError(n + " is not a Number."); } else if (n < min || n > max) { // As failing validation is *not* an exceptional circumstance // lets not throw a RangeError Exception here. // It's semantically correct but it's not sensible. return false; } return true; }; /** * Validates the number is within an acceptable range for milliseconds [0-999]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateMillisecond = function (value) { return validate(value, 0, 999, "millisecond"); }; /** * Validates the number is within an acceptable range for seconds [0-59]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateSecond = function (value) { return validate(value, 0, 59, "second"); }; /** * Validates the number is within an acceptable range for minutes [0-59]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateMinute = function (value) { return validate(value, 0, 59, "minute"); }; /** * Validates the number is within an acceptable range for hours [0-23]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateHour = function (value) { return validate(value, 0, 23, "hour"); }; /** * Validates the number is within an acceptable range for the days in a month [0-MaxDaysInMonth]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateDay = function (value, year, month) { if (year === undefined || year === null || month === undefined || month === null) { return false;} return validate(value, 1, $D.getDaysInMonth(year, month), "day"); }; /** * Validates the number is within an acceptable range for months [0-11]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateWeek = function (value) { return validate(value, 0, 53, "week"); }; /** * Validates the number is within an acceptable range for months [0-11]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateMonth = function (value) { return validate(value, 0, 11, "month"); }; /** * Validates the number is within an acceptable range for years. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateYear = function (value) { /** * Per ECMAScript spec the range of times supported by Date objects is * exactly -100,000,000 days to +100,000,000 days measured relative to * midnight at the beginning of 01 January, 1970 UTC. * This gives a range of 8,640,000,000,000,000 milliseconds to either * side of 01 January, 1970 UTC. * * Earliest possible date: Tue, 20 Apr 271,822 B.C. 00:00:00 UTC * Latest possible date: Sat, 13 Sep 275,760 00:00:00 UTC */ return validate(value, -271822, 275760, "year"); }; $D.validateTimezone = function(value) { var timezones = {"ACDT":1,"ACST":1,"ACT":1,"ADT":1,"AEDT":1,"AEST":1,"AFT":1,"AKDT":1,"AKST":1,"AMST":1,"AMT":1,"ART":1,"AST":1,"AWDT":1,"AWST":1,"AZOST":1,"AZT":1,"BDT":1,"BIOT":1,"BIT":1,"BOT":1,"BRT":1,"BST":1,"BTT":1,"CAT":1,"CCT":1,"CDT":1,"CEDT":1,"CEST":1,"CET":1,"CHADT":1,"CHAST":1,"CHOT":1,"ChST":1,"CHUT":1,"CIST":1,"CIT":1,"CKT":1,"CLST":1,"CLT":1,"COST":1,"COT":1,"CST":1,"CT":1,"CVT":1,"CWST":1,"CXT":1,"DAVT":1,"DDUT":1,"DFT":1,"EASST":1,"EAST":1,"EAT":1,"ECT":1,"EDT":1,"EEDT":1,"EEST":1,"EET":1,"EGST":1,"EGT":1,"EIT":1,"EST":1,"FET":1,"FJT":1,"FKST":1,"FKT":1,"FNT":1,"GALT":1,"GAMT":1,"GET":1,"GFT":1,"GILT":1,"GIT":1,"GMT":1,"GST":1,"GYT":1,"HADT":1,"HAEC":1,"HAST":1,"HKT":1,"HMT":1,"HOVT":1,"HST":1,"ICT":1,"IDT":1,"IOT":1,"IRDT":1,"IRKT":1,"IRST":1,"IST":1,"JST":1,"KGT":1,"KOST":1,"KRAT":1,"KST":1,"LHST":1,"LINT":1,"MAGT":1,"MART":1,"MAWT":1,"MDT":1,"MET":1,"MEST":1,"MHT":1,"MIST":1,"MIT":1,"MMT":1,"MSK":1,"MST":1,"MUT":1,"MVT":1,"MYT":1,"NCT":1,"NDT":1,"NFT":1,"NPT":1,"NST":1,"NT":1,"NUT":1,"NZDT":1,"NZST":1,"OMST":1,"ORAT":1,"PDT":1,"PET":1,"PETT":1,"PGT":1,"PHOT":1,"PHT":1,"PKT":1,"PMDT":1,"PMST":1,"PONT":1,"PST":1,"PYST":1,"PYT":1,"RET":1,"ROTT":1,"SAKT":1,"SAMT":1,"SAST":1,"SBT":1,"SCT":1,"SGT":1,"SLST":1,"SRT":1,"SST":1,"SYOT":1,"TAHT":1,"THA":1,"TFT":1,"TJT":1,"TKT":1,"TLT":1,"TMT":1,"TOT":1,"TVT":1,"UCT":1,"ULAT":1,"UTC":1,"UYST":1,"UYT":1,"UZT":1,"VET":1,"VLAT":1,"VOLT":1,"VOST":1,"VUT":1,"WAKT":1,"WAST":1,"WAT":1,"WEDT":1,"WEST":1,"WET":1,"WST":1,"YAKT":1,"YEKT":1,"Z":1}; return (timezones[value] === 1); }; $D.validateTimezoneOffset= function(value) { // timezones go from +14hrs to -12hrs, the +X hours are negative offsets. return (value > -841 && value < 721); }; }()); (function () { var $D = Date, $P = $D.prototype, p = function (s, l) { if (!l) { l = 2; } return ("000" + s).slice(l * -1); }; var validateConfigObject = function (obj) { var result = {}, self = this, prop, testFunc; testFunc = function (prop, func, value) { if (prop === "day") { var month = (obj.month !== undefined) ? obj.month : self.getMonth(); var year = (obj.year !== undefined) ? obj.year : self.getFullYear(); return $D[func](value, year, month); } else { return $D[func](value); } }; for (prop in obj) { if (Object.prototype.hasOwnProperty.call(obj, prop)) { var func = "validate" + prop.charAt(0).toUpperCase() + prop.slice(1); if ($D[func] && obj[prop] !== null && testFunc(prop, func, obj[prop])) { result[prop] = obj[prop]; } } } return result; }; /** * Resets the time of this Date object to 12:00 AM (00:00), which is the start of the day. * @param {Boolean} .clone() this date instance before clearing Time * @return {Date} this */ $P.clearTime = function () { this.setHours(0); this.setMinutes(0); this.setSeconds(0); this.setMilliseconds(0); return this; }; /** * Resets the time of this Date object to the current time ('now'). * @return {Date} this */ $P.setTimeToNow = function () { var n = new Date(); this.setHours(n.getHours()); this.setMinutes(n.getMinutes()); this.setSeconds(n.getSeconds()); this.setMilliseconds(n.getMilliseconds()); return this; }; /** * Returns a new Date object that is an exact date and time copy of the original instance. * @return {Date} A new Date instance */ $P.clone = function () { return new Date(this.getTime()); }; /** * Compares this instance to a Date object and returns an number indication of their relative values. * @param {Date} Date object to compare [Required] * @return {Number} -1 = this is lessthan date. 0 = values are equal. 1 = this is greaterthan date. */ $P.compareTo = function (date) { return Date.compare(this, date); }; /** * Compares this instance to another Date object and returns true if they are equal. * @param {Date} Date object to compare. If no date to compare, new Date() [now] is used. * @return {Boolean} true if dates are equal. false if they are not equal. */ $P.equals = function (date) { return Date.equals(this, (date !== undefined ? date : new Date())); }; /** * Determines if this instance is between a range of two dates or equal to either the start or end dates. * @param {Date} Start of range [Required] * @param {Date} End of range [Required] * @return {Boolean} true is this is between or equal to the start and end dates, else false */ $P.between = function (start, end) { return this.getTime() >= start.getTime() && this.getTime() <= end.getTime(); }; /** * Determines if this date occurs after the date to compare to. * @param {Date} Date object to compare. If no date to compare, new Date() ("now") is used. * @return {Boolean} true if this date instance is greater than the date to compare to (or "now"), otherwise false. */ $P.isAfter = function (date) { return this.compareTo(date || new Date()) === 1; }; /** * Determines if this date occurs before the date to compare to. * @param {Date} Date object to compare. If no date to compare, new Date() ("now") is used. * @return {Boolean} true if this date instance is less than the date to compare to (or "now"). */ $P.isBefore = function (date) { return (this.compareTo(date || new Date()) === -1); }; /** * Determines if the current Date instance occurs today. * @return {Boolean} true if this date instance is 'today', otherwise false. */ /** * Determines if the current Date instance occurs on the same Date as the supplied 'date'. * If no 'date' to compare to is provided, the current Date instance is compared to 'today'. * @param {date} Date object to compare. If no date to compare, the current Date ("now") is used. * @return {Boolean} true if this Date instance occurs on the same Day as the supplied 'date'. */ $P.isToday = $P.isSameDay = function (date) { return this.clone().clearTime().equals((date || new Date()).clone().clearTime()); }; /** * Adds the specified number of milliseconds to this instance. * @param {Number} The number of milliseconds to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addMilliseconds = function (value) { if (!value) { return this; } this.setTime(this.getTime() + value * 1); return this; }; /** * Adds the specified number of seconds to this instance. * @param {Number} The number of seconds to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addSeconds = function (value) { if (!value) { return this; } return this.addMilliseconds(value * 1000); }; /** * Adds the specified number of seconds to this instance. * @param {Number} The number of seconds to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addMinutes = function (value) { if (!value) { return this; } return this.addMilliseconds(value * 60000); // 60*1000 }; /** * Adds the specified number of hours to this instance. * @param {Number} The number of hours to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addHours = function (value) { if (!value) { return this; } return this.addMilliseconds(value * 3600000); // 60*60*1000 }; /** * Adds the specified number of days to this instance. * @param {Number} The number of days to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addDays = function (value) { if (!value) { return this; } this.setDate(this.getDate() + value * 1); return this; }; /** * Adds the specified number of weekdays (ie - not sat or sun) to this instance. * @param {Number} The number of days to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addWeekdays = function (value) { if (!value) { return this; } var day = this.getDay(); var weeks = (Math.ceil(Math.abs(value)/7)); if (day === 0 || day === 6) { if (value > 0) { this.next().monday(); this.addDays(-1); day = this.getDay(); } } if (value < 0) { while (value < 0) { this.addDays(-1); day = this.getDay(); if (day !== 0 && day !== 6) { value++; } } return this; } else if (value > 5 || (6-day) <= value) { value = value + (weeks * 2); } return this.addDays(value); }; /** * Adds the specified number of weeks to this instance. * @param {Number} The number of weeks to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addWeeks = function (value) { if (!value) { return this; } return this.addDays(value * 7); }; /** * Adds the specified number of months to this instance. * @param {Number} The number of months to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addMonths = function (value) { if (!value) { return this; } var n = this.getDate(); this.setDate(1); this.setMonth(this.getMonth() + value * 1); this.setDate(Math.min(n, $D.getDaysInMonth(this.getFullYear(), this.getMonth()))); return this; }; $P.addQuarters = function (value) { if (!value) { return this; } // note this will take you to the same point in the quarter as you are now. // i.e. - if you are 15 days into the quarter you'll be 15 days into the resulting one. // bonus: this allows adding fractional quarters return this.addMonths(value * 3); }; /** * Adds the specified number of years to this instance. * @param {Number} The number of years to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addYears = function (value) { if (!value) { return this; } return this.addMonths(value * 12); }; /** * Adds (or subtracts) to the value of the years, months, weeks, days, hours, minutes, seconds, milliseconds of the date instance using given configuration object. Positive and Negative values allowed. * Example

	Date.today().add( { days: 1, months: 1 } )

	new Date().add( { years: -1 } )
	
* @param {Object} Configuration object containing attributes (months, days, etc.) * @return {Date} this */ $P.add = function (config) { if (typeof config === "number") { this._orient = config; return this; } var x = config; if (x.day) { // If we should be a different date than today (eg: for 'tomorrow -1d', etc). // Should only effect parsing, not direct usage (eg, Finish and FinishExact) if ((x.day - this.getDate()) !== 0) { this.setDate(x.day); } } if (x.milliseconds) { this.addMilliseconds(x.milliseconds); } if (x.seconds) { this.addSeconds(x.seconds); } if (x.minutes) { this.addMinutes(x.minutes); } if (x.hours) { this.addHours(x.hours); } if (x.weeks) { this.addWeeks(x.weeks); } if (x.months) { this.addMonths(x.months); } if (x.years) { this.addYears(x.years); } if (x.days) { this.addDays(x.days); } return this; }; /** * Get the week number. Week one (1) is the week which contains the first Thursday of the year. Monday is considered the first day of the week. * The .getWeek() function does NOT convert the date to UTC. The local datetime is used. * Please use .getISOWeek() to get the week of the UTC converted date. * @return {Number} 1 to 53 */ $P.getWeek = function (utc) { // Create a copy of this date object var self, target = new Date(this.valueOf()); if (utc) { target.addMinutes(target.getTimezoneOffset()); self = target.clone(); } else { self = this; } // ISO week date weeks start on monday // so correct the day number var dayNr = (self.getDay() + 6) % 7; // ISO 8601 states that week 1 is the week // with the first thursday of that year. // Set the target date to the thursday in the target week target.setDate(target.getDate() - dayNr + 3); // Store the millisecond value of the target date var firstThursday = target.valueOf(); // Set the target to the first thursday of the year // First set the target to january first target.setMonth(0, 1); // Not a thursday? Correct the date to the next thursday if (target.getDay() !== 4) { target.setMonth(0, 1 + ((4 - target.getDay()) + 7) % 7); } // The weeknumber is the number of weeks between the // first thursday of the year and the thursday in the target week return 1 + Math.ceil((firstThursday - target) / 604800000); // 604800000 = 7 * 24 * 3600 * 1000 }; /** * Get the ISO 8601 week number. Week one ("01") is the week which contains the first Thursday of the year. Monday is considered the first day of the week. * The .getISOWeek() function does convert the date to it's UTC value. Please use .getWeek() to get the week of the local date. * @return {String} "01" to "53" */ $P.getISOWeek = function () { return p(this.getWeek(true)); }; /** * Moves the date to Monday of the week set. Week one (1) is the week which contains the first Thursday of the year. * @param {Number} A Number (1 to 53) that represents the week of the year. * @return {Date} this */ $P.setWeek = function (n) { if ((n - this.getWeek()) === 0) { if (this.getDay() !== 1) { return this.moveToDayOfWeek(1, (this.getDay() > 1 ? -1 : 1)); } else { return this; } } else { return this.moveToDayOfWeek(1, (this.getDay() > 1 ? -1 : 1)).addWeeks(n - this.getWeek()); } }; $P.setQuarter = function (qtr) { var month = Math.abs(((qtr-1) * 3) + 1); return this.setMonth(month, 1); }; $P.getQuarter = function () { return Date.getQuarter(this); }; $P.getDaysLeftInQuarter = function () { return Date.getDaysLeftInQuarter(this); }; /** * Moves the date to the next n'th occurrence of the dayOfWeek starting from the beginning of the month. The number (-1) is a magic number and will return the last occurrence of the dayOfWeek in the month. * @param {Number} The dayOfWeek to move to * @param {Number} The n'th occurrence to move to. Use (-1) to return the last occurrence in the month * @return {Date} this */ $P.moveToNthOccurrence = function (dayOfWeek, occurrence) { if (dayOfWeek === "Weekday") { if (occurrence > 0) { this.moveToFirstDayOfMonth(); if (this.is().weekday()) { occurrence -= 1; } } else if (occurrence < 0) { this.moveToLastDayOfMonth(); if (this.is().weekday()) { occurrence += 1; } } else { return this; } return this.addWeekdays(occurrence); } var shift = 0; if (occurrence > 0) { shift = occurrence - 1; } else if (occurrence === -1) { this.moveToLastDayOfMonth(); if (this.getDay() !== dayOfWeek) { this.moveToDayOfWeek(dayOfWeek, -1); } return this; } return this.moveToFirstDayOfMonth().addDays(-1).moveToDayOfWeek(dayOfWeek, +1).addWeeks(shift); }; var moveToN = function (getFunc, addFunc, nVal) { return function (value, orient) { var diff = (value - this[getFunc]() + nVal * (orient || +1)) % nVal; return this[addFunc]((diff === 0) ? diff += nVal * (orient || +1) : diff); }; }; /** * Move to the next or last dayOfWeek based on the orient value. * @param {Number} The dayOfWeek to move to * @param {Number} Forward (+1) or Back (-1). Defaults to +1. [Optional] * @return {Date} this */ $P.moveToDayOfWeek = moveToN("getDay", "addDays", 7); /** * Move to the next or last month based on the orient value. * @param {Number} The month to move to. 0 = January, 11 = December * @param {Number} Forward (+1) or Back (-1). Defaults to +1. [Optional] * @return {Date} this */ $P.moveToMonth = moveToN("getMonth", "addMonths", 12); /** * Get the Ordinate of the current day ("th", "st", "rd"). * @return {String} */ $P.getOrdinate = function () { var num = this.getDate(); return ord(num); }; /** * Get the Ordinal day (numeric day number) of the year, adjusted for leap year. * @return {Number} 1 through 365 (366 in leap years) */ $P.getOrdinalNumber = function () { return Math.ceil((this.clone().clearTime() - new Date(this.getFullYear(), 0, 1)) / 86400000) + 1; }; /** * Get the time zone abbreviation of the current date. * @return {String} The abbreviated time zone name (e.g. "EST") */ $P.getTimezone = function () { return $D.getTimezoneAbbreviation(this.getUTCOffset(), this.isDaylightSavingTime()); }; $P.setTimezoneOffset = function (offset) { var here = this.getTimezoneOffset(), there = Number(offset) * -6 / 10; return (there || there === 0) ? this.addMinutes(there - here) : this; }; $P.setTimezone = function (offset) { return this.setTimezoneOffset($D.getTimezoneOffset(offset)); }; /** * Indicates whether Daylight Saving Time is observed in the current time zone. * @return {Boolean} true|false */ $P.hasDaylightSavingTime = function () { return (Date.today().set({month: 0, day: 1}).getTimezoneOffset() !== Date.today().set({month: 6, day: 1}).getTimezoneOffset()); }; /** * Indicates whether this Date instance is within the Daylight Saving Time range for the current time zone. * @return {Boolean} true|false */ $P.isDaylightSavingTime = function () { return Date.today().set({month: 0, day: 1}).getTimezoneOffset() !== this.getTimezoneOffset(); }; /** * Get the offset from UTC of the current date. * @return {String} The 4-character offset string prefixed with + or - (e.g. "-0500") */ $P.getUTCOffset = function (offset) { var n = (offset || this.getTimezoneOffset()) * -10 / 6, r; if (n < 0) { r = (n - 10000).toString(); return r.charAt(0) + r.substr(2); } else { r = (n + 10000).toString(); return "+" + r.substr(1); } }; /** * Returns the number of milliseconds between this date and date. * @param {Date} Defaults to now * @return {Number} The diff in milliseconds */ $P.getElapsed = function (date) { return (date || new Date()) - this; }; /** * Set the value of year, month, day, hour, minute, second, millisecond of date instance using given configuration object. * Example

	Date.today().set( { day: 20, month: 1 } )

	new Date().set( { millisecond: 0 } )
	
* * @param {Object} Configuration object containing attributes (month, day, etc.) * @return {Date} this */ $P.set = function (config) { config = validateConfigObject.call(this, config); var key; for (key in config) { if (Object.prototype.hasOwnProperty.call(config, key)) { var name = key.charAt(0).toUpperCase() + key.slice(1); var addFunc, getFunc; if (key !== "week" && key !== "month" && key !== "timezone" && key !== "timezoneOffset") { name += "s"; } addFunc = "add" + name; getFunc = "get" + name; if (key === "month") { addFunc = addFunc + "s"; } else if (key === "year"){ getFunc = "getFullYear"; } if (key !== "day" && key !== "timezone" && key !== "timezoneOffset" && key !== "week" && key !== "hour") { this[addFunc](config[key] - this[getFunc]()); } else if ( key === "timezone"|| key === "timezoneOffset" || key === "week" || key === "hour") { this["set"+name](config[key]); } } } // day has to go last because you can't validate the day without first knowing the month if (config.day) { this.addDays(config.day - this.getDate()); } return this; }; /** * Moves the date to the first day of the month. * @return {Date} this */ $P.moveToFirstDayOfMonth = function () { return this.set({ day: 1 }); }; /** * Moves the date to the last day of the month. * @return {Date} this */ $P.moveToLastDayOfMonth = function () { return this.set({ day: $D.getDaysInMonth(this.getFullYear(), this.getMonth())}); }; /** * Converts the value of the current Date object to its equivalent string representation. * Format Specifiers * CUSTOM DATE AND TIME FORMAT STRINGS * Format Description Example * ------ --------------------------------------------------------------------------- ----------------------- * s The seconds of the minute between 0-59. "0" to "59" * ss The seconds of the minute with leading zero if required. "00" to "59" * * m The minute of the hour between 0-59. "0" or "59" * mm The minute of the hour with leading zero if required. "00" or "59" * * h The hour of the day between 1-12. "1" to "12" * hh The hour of the day with leading zero if required. "01" to "12" * * H The hour of the day between 0-23. "0" to "23" * HH The hour of the day with leading zero if required. "00" to "23" * * d The day of the month between 1 and 31. "1" to "31" * dd The day of the month with leading zero if required. "01" to "31" * ddd Abbreviated day name. Date.CultureInfo.abbreviatedDayNames. "Mon" to "Sun" * dddd The full day name. Date.CultureInfo.dayNames. "Monday" to "Sunday" * * M The month of the year between 1-12. "1" to "12" * MM The month of the year with leading zero if required. "01" to "12" * MMM Abbreviated month name. Date.CultureInfo.abbreviatedMonthNames. "Jan" to "Dec" * MMMM The full month name. Date.CultureInfo.monthNames. "January" to "December" * * yy The year as a two-digit number. "99" or "08" * yyyy The full four digit year. "1999" or "2008" * * t Displays the first character of the A.M./P.M. designator. "A" or "P" * Date.CultureInfo.amDesignator or Date.CultureInfo.pmDesignator * tt Displays the A.M./P.M. designator. "AM" or "PM" * Date.CultureInfo.amDesignator or Date.CultureInfo.pmDesignator * * S The ordinal suffix ("st, "nd", "rd" or "th") of the current day. "st, "nd", "rd" or "th" * * STANDARD DATE AND TIME FORMAT STRINGS * Format Description Example *------ --------------------------------------------------------------------------- ----------------------- * d The CultureInfo shortDate Format Pattern "M/d/yyyy" * D The CultureInfo longDate Format Pattern "dddd, MMMM dd, yyyy" * F The CultureInfo fullDateTime Format Pattern "dddd, MMMM dd, yyyy h:mm:ss tt" * m The CultureInfo monthDay Format Pattern "MMMM dd" * r The CultureInfo rfc1123 Format Pattern "ddd, dd MMM yyyy HH:mm:ss GMT" * s The CultureInfo sortableDateTime Format Pattern "yyyy-MM-ddTHH:mm:ss" * t The CultureInfo shortTime Format Pattern "h:mm tt" * T The CultureInfo longTime Format Pattern "h:mm:ss tt" * u The CultureInfo universalSortableDateTime Format Pattern "yyyy-MM-dd HH:mm:ssZ" * y The CultureInfo yearMonth Format Pattern "MMMM, yyyy" * * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @return {String} A string representation of the current Date object. */ var ord = function (n) { switch (n * 1) { case 1: case 21: case 31: return "st"; case 2: case 22: return "nd"; case 3: case 23: return "rd"; default: return "th"; } }; var parseStandardFormats = function (format) { var y, c = Date.CultureInfo.formatPatterns; switch (format) { case "d": return this.toString(c.shortDate); case "D": return this.toString(c.longDate); case "F": return this.toString(c.fullDateTime); case "m": return this.toString(c.monthDay); case "r": case "R": y = this.clone().addMinutes(this.getTimezoneOffset()); return y.toString(c.rfc1123) + " GMT"; case "s": return this.toString(c.sortableDateTime); case "t": return this.toString(c.shortTime); case "T": return this.toString(c.longTime); case "u": y = this.clone().addMinutes(this.getTimezoneOffset()); return y.toString(c.universalSortableDateTime); case "y": return this.toString(c.yearMonth); default: return false; } }; var parseFormatStringsClosure = function (context) { return function (m) { if (m.charAt(0) === "\\") { return m.replace("\\", ""); } switch (m) { case "hh": return p(context.getHours() < 13 ? (context.getHours() === 0 ? 12 : context.getHours()) : (context.getHours() - 12)); case "h": return context.getHours() < 13 ? (context.getHours() === 0 ? 12 : context.getHours()) : (context.getHours() - 12); case "HH": return p(context.getHours()); case "H": return context.getHours(); case "mm": return p(context.getMinutes()); case "m": return context.getMinutes(); case "ss": return p(context.getSeconds()); case "s": return context.getSeconds(); case "yyyy": return p(context.getFullYear(), 4); case "yy": return p(context.getFullYear()); case "y": return context.getFullYear(); case "E": case "dddd": return Date.CultureInfo.dayNames[context.getDay()]; case "ddd": return Date.CultureInfo.abbreviatedDayNames[context.getDay()]; case "dd": return p(context.getDate()); case "d": return context.getDate(); case "MMMM": return Date.CultureInfo.monthNames[context.getMonth()]; case "MMM": return Date.CultureInfo.abbreviatedMonthNames[context.getMonth()]; case "MM": return p((context.getMonth() + 1)); case "M": return context.getMonth() + 1; case "t": return context.getHours() < 12 ? Date.CultureInfo.amDesignator.substring(0, 1) : Date.CultureInfo.pmDesignator.substring(0, 1); case "tt": return context.getHours() < 12 ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator; case "S": return ord(context.getDate()); case "W": return context.getWeek(); case "WW": return context.getISOWeek(); case "Q": return "Q" + context.getQuarter(); case "q": return String(context.getQuarter()); case "z": return context.getTimezone(); case "Z": case "X": return Date.getTimezoneOffset(context.getTimezone()); case "ZZ": // Timezone offset in seconds return context.getTimezoneOffset() * -60; case "u": return context.getDay(); case "L": return ($D.isLeapYear(context.getFullYear())) ? 1 : 0; case "B": // Swatch Internet Time (.beats) return "@"+((context.getUTCSeconds() + (context.getUTCMinutes()*60) + ((context.getUTCHours()+1)*3600))/86.4); default: return m; } }; }; $P.toString = function (format, ignoreStandards) { // Standard Date and Time Format Strings. Formats pulled from CultureInfo file and // may vary by culture. if (!ignoreStandards && format && format.length === 1) { output = parseStandardFormats.call(this, format); if (output) { return output; } } var parseFormatStrings = parseFormatStringsClosure(this); return format ? format.replace(/((\\)?(dd?d?d?|MM?M?M?|yy?y?y?|hh?|HH?|mm?|ss?|tt?|S|q|Q|WW?W?W?)(?![^\[]*\]))/g, parseFormatStrings).replace(/\[|\]/g, "") : this._toString(); }; }()); /************************************************************* * SugarPak - Domain Specific Language - Syntactical Sugar * *************************************************************/ (function () { var $D = Date, $P = $D.prototype, $N = Number.prototype; // private $P._orient = +1; // private $P._nth = null; // private $P._is = false; // private $P._same = false; // private $P._isSecond = false; // private $N._dateElement = "days"; /** * Moves the date to the next instance of a date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.today().next().friday();
	Date.today().next().fri();
	Date.today().next().march();
	Date.today().next().mar();
	Date.today().next().week();
	
* * @return {Date} date */ $P.next = function () { this._move = true; this._orient = +1; return this; }; /** * Creates a new Date (Date.today()) and moves the date to the next instance of the date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.next().friday();
	Date.next().fri();
	Date.next().march();
	Date.next().mar();
	Date.next().week();
	
* * @return {Date} date */ $D.next = function () { return $D.today().next(); }; /** * Moves the date to the previous instance of a date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.today().last().friday();
	Date.today().last().fri();
	Date.today().last().march();
	Date.today().last().mar();
	Date.today().last().week();
	
* * @return {Date} date */ $P.last = $P.prev = $P.previous = function () { this._move = true; this._orient = -1; return this; }; /** * Creates a new Date (Date.today()) and moves the date to the previous instance of the date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.last().friday();
	Date.last().fri();
	Date.previous().march();
	Date.prev().mar();
	Date.last().week();
	
* * @return {Date} date */ $D.last = $D.prev = $D.previous = function () { return $D.today().last(); }; /** * Performs a equality check when followed by either a month name, day name or .weekday() function. * Example

	Date.today().is().friday(); // true|false
	Date.today().is().fri();
	Date.today().is().march();
	Date.today().is().mar();
	
* * @return {Boolean} true|false */ $P.is = function () { this._is = true; return this; }; /** * Determines if two date objects occur on/in exactly the same instance of the subsequent date part function. * The function .same() must be followed by a date part function (example: .day(), .month(), .year(), etc). * * An optional Date can be passed in the date part function. If now date is passed as a parameter, 'Now' is used. * * The following example demonstrates how to determine if two dates fall on the exact same day. * * Example

	var d1 = Date.today(); // today at 00:00
	var d2 = new Date();   // exactly now.

	// Do they occur on the same day?
	d1.same().day(d2); // true
	
	// Do they occur on the same hour?
	d1.same().hour(d2); // false, unless d2 hour is '00' (midnight).
	
	// What if it's the same day, but one year apart?
	var nextYear = Date.today().add(1).year();

	d1.same().day(nextYear); // false, because the dates must occur on the exact same day. 
	
* * Scenario: Determine if a given date occurs during some week period 2 months from now. * * Example

	var future = Date.today().add(2).months();
	return someDate.same().week(future); // true|false;
	
* * @return {Boolean} true|false */ $P.same = function () { this._same = true; this._isSecond = false; return this; }; /** * Determines if the current date/time occurs during Today. Must be preceded by the .is() function. * Example

	someDate.is().today();    // true|false
	new Date().is().today();  // true
	Date.today().is().today();// true
	Date.today().add(-1).day().is().today(); // false
	
* * @return {Boolean} true|false */ $P.today = function () { return this.same().day(); }; /** * Determines if the current date is a weekday. This function must be preceded by the .is() function. * Example

	Date.today().is().weekday(); // true|false
	
* * @return {Boolean} true|false */ $P.weekday = function () { if (this._nth) { return df("Weekday").call(this); } if (this._move) { return this.addWeekdays(this._orient); } if (this._is) { this._is = false; return (!this.is().sat() && !this.is().sun()); } return false; }; /** * Determines if the current date is on the weekend. This function must be preceded by the .is() function. * Example

	Date.today().is().weekend(); // true|false
	
* * @return {Boolean} true|false */ $P.weekend = function () { if (this._is) { this._is = false; return (this.is().sat() || this.is().sun()); } return false; }; /** * Sets the Time of the current Date instance. A string "6:15 pm" or config object {hour:18, minute:15} are accepted. * Example

	// Set time to 6:15pm with a String
	Date.today().at("6:15pm");

	// Set time to 6:15pm with a config object
	Date.today().at({hour:18, minute:15});
	
* * @return {Date} date */ $P.at = function (time) { return (typeof time === "string") ? $D.parse(this.toString("d") + " " + time) : this.set(time); }; /** * Creates a new Date() and adds this (Number) to the date based on the preceding date element function (eg. second|minute|hour|day|month|year). * Example

	// Undeclared Numbers must be wrapped with parentheses. Requirment of JavaScript.
	(3).days().fromNow();
	(6).months().fromNow();

	// Declared Number variables do not require parentheses. 
	var n = 6;
	n.months().fromNow();
	
* * @return {Date} A new Date instance */ $N.fromNow = $N.after = function (date) { var c = {}; c[this._dateElement] = this; return ((!date) ? new Date() : date.clone()).add(c); }; /** * Creates a new Date() and subtract this (Number) from the date based on the preceding date element function (eg. second|minute|hour|day|month|year). * Example

	// Undeclared Numbers must be wrapped with parentheses. Requirment of JavaScript.
	(3).days().ago();
	(6).months().ago();

	// Declared Number variables do not require parentheses. 
	var n = 6;
	n.months().ago();
	
* * @return {Date} A new Date instance */ $N.ago = $N.before = function (date) { var c = {}, s = (this._dateElement[this._dateElement.length-1] !== "s") ? this._dateElement + "s" : this._dateElement; c[s] = this * -1; return ((!date) ? new Date() : date.clone()).add(c); }; // Do NOT modify the following string tokens. These tokens are used to build dynamic functions. // All culture-specific strings can be found in the CultureInfo files. var dx = ("sunday monday tuesday wednesday thursday friday saturday").split(/\s/), mx = ("january february march april may june july august september october november december").split(/\s/), px = ("Millisecond Second Minute Hour Day Week Month Year Quarter Weekday").split(/\s/), pxf = ("Milliseconds Seconds Minutes Hours Date Week Month FullYear Quarter").split(/\s/), nth = ("final first second third fourth fifth").split(/\s/), de; /** * Returns an object literal of all the date parts. * Example

	var o = new Date().toObject();
	
	// { year: 2008, month: 4, week: 20, day: 13, hour: 18, minute: 9, second: 32, millisecond: 812 }
	
	// The object properties can be referenced directly from the object.
	
	alert(o.day);  // alerts "13"
	alert(o.year); // alerts "2008"
	
* * @return {Date} An object literal representing the original date object. */ $P.toObject = function () { var o = {}; for (var i = 0; i < px.length; i++) { if (this["get" + pxf[i]]) { o[px[i].toLowerCase()] = this["get" + pxf[i]](); } } return o; }; /** * Returns a date created from an object literal. Ignores the .week property if set in the config. * Example

	var o = new Date().toObject();
	
	return Date.fromObject(o); // will return the same date. 

	var o2 = {month: 1, day: 20, hour: 18}; // birthday party!
	Date.fromObject(o2);
	
* * @return {Date} An object literal representing the original date object. */ $D.fromObject = function(config) { config.week = null; return Date.today().set(config); }; // Create day name functions and abbreviated day name functions (eg. monday(), friday(), fri()). var df = function (n) { return function () { if (this._is) { this._is = false; return this.getDay() === n; } if (this._move) { this._move = null; } if (this._nth !== null) { // If the .second() function was called earlier, remove the _orient // from the date, and then continue. // This is required because 'second' can be used in two different context. // // Example // // Date.today().add(1).second(); // Date.march().second().monday(); // // Things get crazy with the following... // Date.march().add(1).second().second().monday(); // but it works!! // if (this._isSecond) { this.addSeconds(this._orient * -1); } // make sure we reset _isSecond this._isSecond = false; var ntemp = this._nth; this._nth = null; var temp = this.clone().moveToLastDayOfMonth(); this.moveToNthOccurrence(n, ntemp); if (this > temp) { throw new RangeError($D.getDayName(n) + " does not occur " + ntemp + " times in the month of " + $D.getMonthName(temp.getMonth()) + " " + temp.getFullYear() + "."); } return this; } return this.moveToDayOfWeek(n, this._orient); }; }; var sdf = function (n) { return function () { var t = $D.today(), shift = n - t.getDay(); if (n === 0 && Date.CultureInfo.firstDayOfWeek === 1 && t.getDay() !== 0) { shift = shift + 7; } return t.addDays(shift); }; }; // Create month name functions and abbreviated month name functions (eg. january(), march(), mar()). var month_instance_functions = function (n) { return function () { if (this._is) { this._is = false; return this.getMonth() === n; } return this.moveToMonth(n, this._orient); }; }; var month_static_functions = function (n) { return function () { return $D.today().set({ month: n, day: 1 }); }; }; var processTerms = function (names, staticFunc, instanceFunc) { for (var i = 0; i < names.length; i++) { // Create constant static Name variables. $D[names[i].toUpperCase()] = $D[names[i].toUpperCase().substring(0, 3)] = i; // Create Name functions. $D[names[i]] = $D[names[i].substring(0, 3)] = staticFunc(i); // Create Name instance functions. $P[names[i]] = $P[names[i].substring(0, 3)] = instanceFunc(i); } }; processTerms(dx, sdf, df); processTerms(mx, month_static_functions, month_instance_functions); // Create date element functions and plural date element functions used with Date (eg. day(), days(), months()). var ef = function (j) { return function () { // if the .second() function was called earlier, the _orient // has alread been added. Just return this and reset _isSecond. if (this._isSecond) { this._isSecond = false; return this; } if (this._same) { this._same = this._is = false; var o1 = this.toObject(), o2 = (arguments[0] || new Date()).toObject(), v = "", k = j.toLowerCase(); // the substr trick with -1 doesn't work in IE8 or less k = (k[k.length-1] === "s") ? k.substring(0,k.length-1) : k; for (var m = (px.length - 1); m > -1; m--) { v = px[m].toLowerCase(); if (o1[v] !== o2[v]) { return false; } if (k === v) { break; } } return true; } if (j.substring(j.length - 1) !== "s") { j += "s"; } if (this._move) { this._move = null; } return this["add" + j](this._orient); }; }; var nf = function (n) { return function () { this._dateElement = n; return this; }; }; for (var k = 0; k < px.length; k++) { de = px[k].toLowerCase(); if(de !== "weekday") { // Create date element functions and plural date element functions used with Date (eg. day(), days(), months()). $P[de] = $P[de + "s"] = ef(px[k]); // Create date element functions and plural date element functions used with Number (eg. day(), days(), months()). $N[de] = $N[de + "s"] = nf(de + "s"); } } $P._ss = ef("Second"); var nthfn = function (n) { return function (dayOfWeek) { if (this._same) { return this._ss(arguments[0]); } if (dayOfWeek || dayOfWeek === 0) { return this.moveToNthOccurrence(dayOfWeek, n); } this._nth = n; // if the operator is 'second' add the _orient, then deal with it later... if (n === 2 && (dayOfWeek === undefined || dayOfWeek === null)) { this._isSecond = true; return this.addSeconds(this._orient); } return this; }; }; for (var l = 0; l < nth.length; l++) { $P[nth[l]] = (l === 0) ? nthfn(-1) : nthfn(l); } }()); (function () { "use strict"; Date.Parsing = { Exception: function (s) { this.message = "Parse error at '" + s.substring(0, 10) + " ...'"; } }; var $P = Date.Parsing; var dayOffsets = { standard: [0,31,59,90,120,151,181,212,243,273,304,334], leap: [0,31,60,91,121,152,182,213,244,274,305,335] }; $P.isLeapYear = function(year) { return ((year % 4 === 0) && (year % 100 !== 0)) || (year % 400 === 0); }; var utils = { multiReplace : function (str, hash ) { var key; for (key in hash) { if (Object.prototype.hasOwnProperty.call(hash, key)) { var regex; if (typeof hash[key] === "function") { } else { regex = (hash[key] instanceof RegExp) ? hash[key] : new RegExp(hash[key], "g"); } str = str.replace(regex, key); } } return str; }, getDayOfYearFromWeek : function (obj) { var d, jan4, offset; obj.weekDay = (!obj.weekDay && obj.weekDay !== 0) ? 1 : obj.weekDay; d = new Date(obj.year, 0, 4); jan4 = d.getDay() === 0 ? 7 : d.getDay(); // JS is 0 indexed on Sunday. offset = jan4+3; obj.dayOfYear = ((obj.week * 7) + (obj.weekDay === 0 ? 7 : obj.weekDay))-offset; return obj; }, getDayOfYear : function (obj, dayOffset) { if (!obj.dayOfYear) { obj = utils.getDayOfYearFromWeek(obj); } for (var i=0;i <= dayOffset.length;i++) { if (obj.dayOfYear < dayOffset[i] || i === dayOffset.length) { obj.day = obj.day ? obj.day : (obj.dayOfYear - dayOffset[i-1]); break; } else { obj.month = i; } } return obj; }, adjustForTimeZone : function (obj, date) { var offset; if (obj.zone.toUpperCase() === "Z" || (obj.zone_hours === 0 && obj.zone_minutes === 0)) { // it's UTC/GML so work out the current timeszone offset offset = -date.getTimezoneOffset(); } else { offset = (obj.zone_hours*60) + (obj.zone_minutes || 0); if (obj.zone_sign === "+") { offset *= -1; } offset -= date.getTimezoneOffset(); } date.setMinutes(date.getMinutes()+offset); return date; }, setDefaults : function (obj) { obj.year = obj.year || Date.today().getFullYear(); obj.hours = obj.hours || 0; obj.minutes = obj.minutes || 0; obj.seconds = obj.seconds || 0; obj.milliseconds = obj.milliseconds || 0; if (!(!obj.month && (obj.week || obj.dayOfYear))) { // if we have a month, or if we don't but don't have the day calculation data obj.month = obj.month || 0; obj.day = obj.day || 1; } return obj; }, dataNum: function (data, mod, explict, postProcess) { var dataNum = data*1; if (mod) { if (postProcess) { return data ? mod(data)*1 : data; } else { return data ? mod(dataNum) : data; } } else if (!explict){ return data ? dataNum : data; } else { return (data && typeof data !== "undefined") ? dataNum : data; } }, timeDataProcess: function (obj) { var timeObj = {}; for (var x in obj.data) { if (obj.data.hasOwnProperty(x)) { timeObj[x] = obj.ignore[x] ? obj.data[x] : utils.dataNum(obj.data[x], obj.mods[x], obj.explict[x], obj.postProcess[x]); } } if (obj.data.secmins) { obj.data.secmins = obj.data.secmins.replace(",", ".") * 60; if (!timeObj.minutes) { timeObj.minutes = obj.data.secmins; } else if (!timeObj.seconds) { timeObj.seconds = obj.data.secmins; } delete obj.secmins; } return timeObj; }, buildTimeObjectFromData: function (data) { var time = utils.timeDataProcess({ data: { year : data[1], month : data[5], day : data[7], week : data[8], dayOfYear : data[10], hours : data[15], zone_hours : data[23], zone_minutes : data[24], zone : data[21], zone_sign : data[22], weekDay : data[9], minutes: data[16], seconds: data[19], milliseconds: data[20], secmins: data[18] }, mods: { month: function(data) { return data-1; }, weekDay: function (data) { data = Math.abs(data); return (data === 7 ? 0 : data); }, minutes: function (data) { return data.replace(":",""); }, seconds: function (data) { return Math.floor( (data.replace(":","").replace(",","."))*1 ); }, milliseconds: function (data) { return (data.replace(",",".")*1000); } }, postProcess: { minutes: true, seconds: true, milliseconds: true }, explict: { zone_hours: true, zone_minutes: true }, ignore: { zone: true, zone_sign: true, secmins: true } }); return time; }, addToHash: function (hash, keys, data) { keys = keys; data = data; var len = keys.length; for (var i = 0; i < len; i++) { hash[keys[i]] = data[i]; } return hash; }, combineRegex: function (r1, r2) { return new RegExp("(("+r1.source+")\\s("+r2.source+"))"); }, getDateNthString: function(add, last, inc){ if (add) { return Date.today().addDays(inc).toString("d"); } else if (last) { return Date.today().last()[inc]().toString("d"); } }, buildRegexData: function (array) { var arr = []; var len = array.length; for (var i=0; i < len; i++) { if (Object.prototype.toString.call(array[i]) === '[object Array]') { // oldIE compat version of Array.isArray arr.push(this.combineRegex(array[i][0], array[i][1])); } else { arr.push(array[i]); } } return arr; } }; $P.processTimeObject = function (obj) { var date, dayOffset; utils.setDefaults(obj); dayOffset = ($P.isLeapYear(obj.year)) ? dayOffsets.leap : dayOffsets.standard; if (!obj.month && (obj.week || obj.dayOfYear)) { utils.getDayOfYear(obj, dayOffset); } else { obj.dayOfYear = dayOffset[obj.month] + obj.day; } date = new Date(obj.year, obj.month, obj.day, obj.hours, obj.minutes, obj.seconds, obj.milliseconds); if (obj.zone) { utils.adjustForTimeZone(obj, date); // adjust (and calculate) for timezone } return date; }; $P.ISO = { regex : /^([\+-]?\d{4}(?!\d{2}\b))((-?)((0[1-9]|1[0-2])(\3([12]\d|0[1-9]|3[01]))?|W([0-4]\d|5[0-3])(-?[1-7])?|(00[1-9]|0[1-9]\d|[12]\d{2}|3([0-5]\d|6[1-6])))([T\s]((([01]\d|2[0-4])((:?)[0-5]\d)?|24\:?00)([\.,]\d+(?!:))?)?(\17[0-5]\d([\.,]\d+)?)?\s?([zZ]|([\+-])([01]\d|2[0-3]):?([0-5]\d)?)?)?)?$/, parse : function (s) { var time, data = s.match(this.regex); if (!data || !data.length) { return null; } time = utils.buildTimeObjectFromData(data); if (!time.year || (!time.year && (!time.month && !time.day) && (!time.week && !time.dayOfYear)) ) { return null; } return $P.processTimeObject(time); } }; $P.Numeric = { isNumeric: function (e){return!isNaN(parseFloat(e))&&isFinite(e);}, regex: /\b([0-1]?[0-9])([0-3]?[0-9])([0-2]?[0-9]?[0-9][0-9])\b/i, parse: function (s) { var data, i, time = {}, order = Date.CultureInfo.dateElementOrder.split(""); if (!(this.isNumeric(s)) || // if it's non-numeric OR (s[0] === "+" && s[0] === "-")) { // It's an arithmatic string (eg +/-1000) return null; } if (s.length < 5 && s.indexOf(".") < 0 && s.indexOf("/") < 0) { // assume it's just a year. time.year = s; return $P.processTimeObject(time); } data = s.match(this.regex); if (!data || !data.length) { return null; } for (i=0; i < order.length; i++) { switch(order[i]) { case "d": time.day = data[i+1]; break; case "m": time.month = (data[i+1]-1); break; case "y": time.year = data[i+1]; break; } } return $P.processTimeObject(time); } }; $P.Normalizer = { regexData: function () { var $R = Date.CultureInfo.regexPatterns; return utils.buildRegexData([ $R.tomorrow, $R.yesterday, [$R.past, $R.mon], [$R.past, $R.tue], [$R.past, $R.wed], [$R.past, $R.thu], [$R.past, $R.fri], [$R.past, $R.sat], [$R.past, $R.sun] ]); }, basicReplaceHash : function() { var $R = Date.CultureInfo.regexPatterns; return { "January": $R.jan.source, "February": $R.feb, "March": $R.mar, "April": $R.apr, "May": $R.may, "June": $R.jun, "July": $R.jul, "August": $R.aug, "September": $R.sep, "October": $R.oct, "November": $R.nov, "December": $R.dec, "": /\bat\b/gi, " ": /\s{2,}/, "am": $R.inTheMorning, "9am": $R.thisMorning, "pm": $R.inTheEvening, "7pm":$R.thisEvening }; }, keys : function(){ return [ utils.getDateNthString(true, false, 1), // tomorrow utils.getDateNthString(true, false, -1), // yesterday utils.getDateNthString(false, true, "monday"), //last mon utils.getDateNthString(false, true, "tuesday"), //last tues utils.getDateNthString(false, true, "wednesday"), //last wed utils.getDateNthString(false, true, "thursday"), //last thurs utils.getDateNthString(false, true, "friday"), //last fri utils.getDateNthString(false, true, "saturday"), //last sat utils.getDateNthString(false, true, "sunday") //last sun ]; }, buildRegexFunctions: function () { var $R = Date.CultureInfo.regexPatterns; var __ = Date.i18n.__; var tomorrowRE = new RegExp("(\\b\\d\\d?("+__("AM")+"|"+__("PM")+")? )("+$R.tomorrow.source.slice(1)+")", "i"); // adapted tomorrow regex for AM PM relative dates var todayRE = new RegExp($R.today.source + "(?!\\s*([+-]))\\b"); // today, but excludes the math operators (eg "today + 2h") this.replaceFuncs = [ [todayRE, function (full) { return (full.length > 1) ? Date.today().toString("d") : full; }], [tomorrowRE, function(full, m1) { var t = Date.today().addDays(1).toString("d"); return (t + " " + m1); }], [$R.amThisMorning, function(str, am){return am;}], [$R.pmThisEvening, function(str, pm){return pm;}] ]; }, buildReplaceData: function () { this.buildRegexFunctions(); this.replaceHash = utils.addToHash(this.basicReplaceHash(), this.keys(), this.regexData()); }, stringReplaceFuncs: function (s) { for (var i=0; i < this.replaceFuncs.length; i++) { s = s.replace(this.replaceFuncs[i][0], this.replaceFuncs[i][1]); } return s; }, parse: function (s) { s = this.stringReplaceFuncs(s); s = utils.multiReplace(s, this.replaceHash); try { var n = s.split(/([\s\-\.\,\/\x27]+)/); if (n.length === 3 && $P.Numeric.isNumeric(n[0]) && $P.Numeric.isNumeric(n[2]) && (n[2].length >= 4)) { // ok, so we're dealing with x/year. But that's not a full date. // This fixes wonky dateElementOrder parsing when set to dmy order. if (Date.CultureInfo.dateElementOrder[0] === "d") { s = "1/" + n[0] + "/" + n[2]; // set to 1st of month and normalize the seperator } } } catch (e) {} return s; } }; $P.Normalizer.buildReplaceData(); }()); (function () { var $P = Date.Parsing; var _ = $P.Operators = { // // Tokenizers // rtoken: function (r) { // regex token return function (s) { var mx = s.match(r); if (mx) { return ([ mx[0], s.substring(mx[0].length) ]); } else { throw new $P.Exception(s); } }; }, token: function () { // whitespace-eating token return function (s) { return _.rtoken(new RegExp("^\\s*" + s + "\\s*"))(s); }; }, stoken: function (s) { // string token return _.rtoken(new RegExp("^" + s)); }, // Atomic Operators until: function (p) { return function (s) { var qx = [], rx = null; while (s.length) { try { rx = p.call(this, s); } catch (e) { qx.push(rx[0]); s = rx[1]; continue; } break; } return [ qx, s ]; }; }, many: function (p) { return function (s) { var rx = [], r = null; while (s.length) { try { r = p.call(this, s); } catch (e) { return [ rx, s ]; } rx.push(r[0]); s = r[1]; } return [ rx, s ]; }; }, // generator operators -- see below optional: function (p) { return function (s) { var r = null; try { r = p.call(this, s); } catch (e) { return [ null, s ]; } return [ r[0], r[1] ]; }; }, not: function (p) { return function (s) { try { p.call(this, s); } catch (e) { return [null, s]; } throw new $P.Exception(s); }; }, ignore: function (p) { return p ? function (s) { var r = null; r = p.call(this, s); return [null, r[1]]; } : null; }, product: function () { var px = arguments[0], qx = Array.prototype.slice.call(arguments, 1), rx = []; for (var i = 0 ; i < px.length ; i++) { rx.push(_.each(px[i], qx)); } return rx; }, cache: function (rule) { var cache = {}, cache_length = 0, cache_keys = [], CACHE_MAX = Date.Config.CACHE_MAX || 100000, r = null; var cacheCheck = function () { if (cache_length === CACHE_MAX) { // kill several keys, don't want to have to do this all the time... for (var i=0; i < 10; i++) { var key = cache_keys.shift(); if (key) { delete cache[key]; cache_length--; } } } }; return function (s) { cacheCheck(); try { r = cache[s] = (cache[s] || rule.call(this, s)); } catch (e) { r = cache[s] = e; } cache_length++; cache_keys.push(s); if (r instanceof $P.Exception) { throw r; } else { return r; } }; }, // vector operators -- see below any: function () { var px = arguments; return function (s) { var r = null; for (var i = 0; i < px.length; i++) { if (px[i] == null) { continue; } try { r = (px[i].call(this, s)); } catch (e) { r = null; } if (r) { return r; } } throw new $P.Exception(s); }; }, each: function () { var px = arguments; return function (s) { var rx = [], r = null; for (var i = 0; i < px.length ; i++) { if (px[i] == null) { continue; } try { r = (px[i].call(this, s)); } catch (e) { throw new $P.Exception(s); } rx.push(r[0]); s = r[1]; } return [ rx, s]; }; }, all: function () { var px = arguments, _ = _; return _.each(_.optional(px)); }, // delimited operators sequence: function (px, d, c) { d = d || _.rtoken(/^\s*/); c = c || null; if (px.length === 1) { return px[0]; } return function (s) { var r = null, q = null; var rx = []; for (var i = 0; i < px.length ; i++) { try { r = px[i].call(this, s); } catch (e) { break; } rx.push(r[0]); try { q = d.call(this, r[1]); } catch (ex) { q = null; break; } s = q[1]; } if (!r) { throw new $P.Exception(s); } if (q) { throw new $P.Exception(q[1]); } if (c) { try { r = c.call(this, r[1]); } catch (ey) { throw new $P.Exception(r[1]); } } return [ rx, (r?r[1]:s) ]; }; }, // // Composite Operators // between: function (d1, p, d2) { d2 = d2 || d1; var _fn = _.each(_.ignore(d1), p, _.ignore(d2)); return function (s) { var rx = _fn.call(this, s); return [[rx[0][0], r[0][2]], rx[1]]; }; }, list: function (p, d, c) { d = d || _.rtoken(/^\s*/); c = c || null; return (p instanceof Array ? _.each(_.product(p.slice(0, -1), _.ignore(d)), p.slice(-1), _.ignore(c)) : _.each(_.many(_.each(p, _.ignore(d))), px, _.ignore(c))); }, set: function (px, d, c) { d = d || _.rtoken(/^\s*/); c = c || null; return function (s) { // r is the current match, best the current 'best' match // which means it parsed the most amount of input var r = null, p = null, q = null, rx = null, best = [[], s], last = false; // go through the rules in the given set for (var i = 0; i < px.length ; i++) { // last is a flag indicating whether this must be the last element // if there is only 1 element, then it MUST be the last one q = null; p = null; r = null; last = (px.length === 1); // first, we try simply to match the current pattern // if not, try the next pattern try { r = px[i].call(this, s); } catch (e) { continue; } // since we are matching against a set of elements, the first // thing to do is to add r[0] to matched elements rx = [[r[0]], r[1]]; // if we matched and there is still input to parse and // we don't already know this is the last element, // we're going to next check for the delimiter ... // if there's none, or if there's no input left to parse // than this must be the last element after all ... if (r[1].length > 0 && ! last) { try { q = d.call(this, r[1]); } catch (ex) { last = true; } } else { last = true; } // if we parsed the delimiter and now there's no more input, // that means we shouldn't have parsed the delimiter at all // so don't update r and mark this as the last element ... if (!last && q[1].length === 0) { last = true; } // so, if this isn't the last element, we're going to see if // we can get any more matches from the remaining (unmatched) // elements ... if (!last) { // build a list of the remaining rules we can match against, // i.e., all but the one we just matched against var qx = []; for (var j = 0; j < px.length ; j++) { if (i !== j) { qx.push(px[j]); } } // now invoke recursively set with the remaining input // note that we don't include the closing delimiter ... // we'll check for that ourselves at the end p = _.set(qx, d).call(this, q[1]); // if we got a non-empty set as a result ... // (otw rx already contains everything we want to match) if (p[0].length > 0) { // update current result, which is stored in rx ... // basically, pick up the remaining text from p[1] // and concat the result from p[0] so that we don't // get endless nesting ... rx[0] = rx[0].concat(p[0]); rx[1] = p[1]; } } // at this point, rx either contains the last matched element // or the entire matched set that starts with this element. // now we just check to see if this variation is better than // our best so far, in terms of how much of the input is parsed if (rx[1].length < best[1].length) { best = rx; } // if we've parsed all the input, then we're finished if (best[1].length === 0) { break; } } // so now we've either gone through all the patterns trying them // as the initial match; or we found one that parsed the entire // input string ... // if best has no matches, just return empty set ... if (best[0].length === 0) { return best; } // if a closing delimiter is provided, then we have to check it also if (c) { // we try this even if there is no remaining input because the pattern // may well be optional or match empty input ... try { q = c.call(this, best[1]); } catch (ey) { throw new $P.Exception(best[1]); } // it parsed ... be sure to update the best match remaining input best[1] = q[1]; } // if we're here, either there was no closing delimiter or we parsed it // so now we have the best match; just return it! return best; }; }, forward: function (gr, fname) { return function (s) { return gr[fname].call(this, s); }; }, // // Translation Operators // replace: function (rule, repl) { return function (s) { var r = rule.call(this, s); return [repl, r[1]]; }; }, process: function (rule, fn) { return function (s) { var r = rule.call(this, s); return [fn.call(this, r[0]), r[1]]; }; }, min: function (min, rule) { return function (s) { var rx = rule.call(this, s); if (rx[0].length < min) { throw new $P.Exception(s); } return rx; }; } }; // Generator Operators And Vector Operators // Generators are operators that have a signature of F(R) => R, // taking a given rule and returning another rule, such as // ignore, which parses a given rule and throws away the result. // Vector operators are those that have a signature of F(R1,R2,...) => R, // take a list of rules and returning a new rule, such as each. // Generator operators are converted (via the following _generator // function) into functions that can also take a list or array of rules // and return an array of new rules as though the function had been // called on each rule in turn (which is what actually happens). // This allows generators to be used with vector operators more easily. // Example: // each(ignore(foo, bar)) instead of each(ignore(foo), ignore(bar)) // This also turns generators into vector operators, which allows // constructs like: // not(cache(foo, bar)) var _generator = function (op) { function gen() { var args = null, rx = [], px, i; if (arguments.length > 1) { args = Array.prototype.slice.call(arguments); } else if (arguments[0] instanceof Array) { args = arguments[0]; } if (args) { px = args.shift(); if (px.length > 0) { args.unshift(px[i]); rx.push(op.apply(null, args)); args.shift(); return rx; } } else { return op.apply(null, arguments); } } return gen; }; var gx = "optional not ignore cache".split(/\s/); for (var i = 0 ; i < gx.length ; i++) { _[gx[i]] = _generator(_[gx[i]]); } var _vector = function (op) { return function () { if (arguments[0] instanceof Array) { return op.apply(null, arguments[0]); } else { return op.apply(null, arguments); } }; }; var vx = "each any all".split(/\s/); for (var j = 0 ; j < vx.length ; j++) { _[vx[j]] = _vector(_[vx[j]]); } }()); (function () { var $D = Date; var flattenAndCompact = function (ax) { var rx = []; for (var i = 0; i < ax.length; i++) { if (ax[i] instanceof Array) { rx = rx.concat(flattenAndCompact(ax[i])); } else { if (ax[i]) { rx.push(ax[i]); } } } return rx; }; var parseMeridian = function () { if (this.meridian && (this.hour || this.hour === 0)) { if (this.meridian === "a" && this.hour > 11 && Date.Config.strict24hr){ throw "Invalid hour and meridian combination"; } else if (this.meridian === "p" && this.hour < 12 && Date.Config.strict24hr){ throw "Invalid hour and meridian combination"; } else if (this.meridian === "p" && this.hour < 12) { this.hour = this.hour + 12; } else if (this.meridian === "a" && this.hour === 12) { this.hour = 0; } } }; var setDefaults = function () { var now = new Date(); if ((this.hour || this.minute) && (!this.month && !this.year && !this.day)) { this.day = now.getDate(); } if (!this.year) { this.year = now.getFullYear(); } if (!this.month && this.month !== 0) { this.month = now.getMonth(); } if (!this.day) { this.day = 1; } if (!this.hour) { this.hour = 0; } if (!this.minute) { this.minute = 0; } if (!this.second) { this.second = 0; } if (!this.millisecond) { this.millisecond = 0; } }; var finishUtils = { getToday: function () { if (this.now || "hour minute second".indexOf(this.unit) !== -1) { return new Date(); } else { return $D.today(); } }, setDaysFromWeekday: function (today, orient){ var gap; orient = orient || 1; this.unit = "day"; gap = ($D.getDayNumberFromName(this.weekday) - today.getDay()); this.days = gap ? ((gap + (orient * 7)) % 7) : (orient * 7); return this; }, setMonthsFromMonth: function (today, orient) { var gap; orient = orient || 1; this.unit = "month"; gap = (this.month - today.getMonth()); this.months = gap ? ((gap + (orient * 12)) % 12) : (orient * 12); this.month = null; return this; }, setDMYFromWeekday: function () { var d = Date[this.weekday](); this.day = d.getDate(); if (!this.month) { this.month = d.getMonth(); } this.year = d.getFullYear(); return this; }, setUnitValue: function (orient) { if (!this.value && this.operator && this.operator !== null && this[this.unit + "s"] && this[this.unit + "s"] !== null) { this[this.unit + "s"] = this[this.unit + "s"] + ((this.operator === "add") ? 1 : -1) + (this.value||0) * orient; } else if (this[this.unit + "s"] == null || this.operator != null) { if (!this.value) { this.value = 1; } this[this.unit + "s"] = this.value * orient; } }, generateDateFromWeeks: function () { var weekday = (this.weekday !== undefined) ? this.weekday : "today"; var d = Date[weekday]().addWeeks(this.weeks); if (this.now) { d.setTimeToNow(); } return d; } }; $D.Translator = { hour: function (s) { return function () { this.hour = Number(s); }; }, minute: function (s) { return function () { this.minute = Number(s); }; }, second: function (s) { return function () { this.second = Number(s); }; }, /* for ss.s format */ secondAndMillisecond: function (s) { return function () { var mx = s.match(/^([0-5][0-9])\.([0-9]{1,3})/); this.second = Number(mx[1]); this.millisecond = Number(mx[2]); }; }, meridian: function (s) { return function () { this.meridian = s.slice(0, 1).toLowerCase(); }; }, timezone: function (s) { return function () { var n = s.replace(/[^\d\+\-]/g, ""); if (n.length) { this.timezoneOffset = Number(n); } else { this.timezone = s.toLowerCase(); } }; }, day: function (x) { var s = x[0]; return function () { this.day = Number(s.match(/\d+/)[0]); if (this.day < 1) { throw "invalid day"; } }; }, month: function (s) { return function () { this.month = (s.length === 3) ? "jan feb mar apr may jun jul aug sep oct nov dec".indexOf(s)/4 : Number(s) - 1; if (this.month < 0) { throw "invalid month"; } }; }, year: function (s) { return function () { var n = Number(s); this.year = ((s.length > 2) ? n : (n + (((n + 2000) < Date.CultureInfo.twoDigitYearMax) ? 2000 : 1900))); }; }, rday: function (s) { return function () { switch (s) { case "yesterday": this.days = -1; break; case "tomorrow": this.days = 1; break; case "today": this.days = 0; break; case "now": this.days = 0; this.now = true; break; } }; }, finishExact: function (x) { var d; x = (x instanceof Array) ? x : [x]; for (var i = 0 ; i < x.length ; i++) { if (x[i]) { x[i].call(this); } } setDefaults.call(this); parseMeridian.call(this); if (this.day > $D.getDaysInMonth(this.year, this.month)) { throw new RangeError(this.day + " is not a valid value for days."); } d = new Date(this.year, this.month, this.day, this.hour, this.minute, this.second, this.millisecond); if (this.year < 100) { d.setFullYear(this.year); // means years less that 100 are process correctly. JS will parse it otherwise as 1900-1999. } if (this.timezone) { d.set({ timezone: this.timezone }); } else if (this.timezoneOffset) { d.set({ timezoneOffset: this.timezoneOffset }); } return d; }, finish: function (x) { var today, expression, orient, temp; x = (x instanceof Array) ? flattenAndCompact(x) : [ x ]; if (x.length === 0) { return null; } for (var i = 0 ; i < x.length ; i++) { if (typeof x[i] === "function") { x[i].call(this); } } if (this.now && !this.unit && !this.operator) { return new Date(); } else { today = finishUtils.getToday.call(this); } expression = !!(this.days && this.days !== null || this.orient || this.operator); orient = ((this.orient === "past" || this.operator === "subtract") ? -1 : 1); if (this.month && this.unit === "week") { this.value = this.month + 1; delete this.month; delete this.day; } if ((this.month || this.month === 0) && "year day hour minute second".indexOf(this.unit) !== -1) { if (!this.value) { this.value = this.month + 1; } this.month = null; expression = true; } if (!expression && this.weekday && !this.day && !this.days) { finishUtils.setDMYFromWeekday.call(this); } if (expression && this.weekday && this.unit !== "month" && this.unit !== "week") { finishUtils.setDaysFromWeekday.call(this, today, orient); } if (this.weekday && this.unit !== "week" && !this.day && !this.days) { temp = Date[this.weekday](); this.day = temp.getDate(); if (temp.getMonth() !== today.getMonth()) { this.month = temp.getMonth(); } } if (this.month && this.unit === "day" && this.operator) { if (!this.value) { this.value = (this.month + 1); } this.month = null; } if (this.value != null && this.month != null && this.year != null) { this.day = this.value * 1; } if (this.month && !this.day && this.value) { today.set({ day: this.value * 1 }); if (!expression) { this.day = this.value * 1; } } if (!this.month && this.value && this.unit === "month" && !this.now) { this.month = this.value; expression = true; } if (expression && (this.month || this.month === 0) && this.unit !== "year") { finishUtils.setMonthsFromMonth.call(this, today, orient); } if (!this.unit) { this.unit = "day"; } finishUtils.setUnitValue.call(this, orient); parseMeridian.call(this); if ((this.month || this.month === 0) && !this.day) { this.day = 1; } if (!this.orient && !this.operator && this.unit === "week" && this.value && !this.day && !this.month) { return Date.today().setWeek(this.value); } if (this.unit === "week" && this.weeks && !this.day && !this.month) { return finishUtils.generateDateFromWeeks.call(this); } if (expression && this.timezone && this.day && this.days) { this.day = this.days; } if (expression){ today.add(this); } else { today.set(this); } if (this.timezone) { this.timezone = this.timezone.toUpperCase(); var offset = $D.getTimezoneOffset(this.timezone); var timezone; if (today.hasDaylightSavingTime()) { // lets check that we're being sane with timezone setting timezone = $D.getTimezoneAbbreviation(offset, today.isDaylightSavingTime()); if (timezone !== this.timezone) { // bugger, we're in a place where things like EST vs EDT matters. if (today.isDaylightSavingTime()) { today.addHours(-1); } else { today.addHours(1); } } } today.setTimezoneOffset(offset); } return today; } }; }()); (function () { var $D = Date; $D.Grammar = {}; var _ = $D.Parsing.Operators, g = $D.Grammar, t = $D.Translator, _fn; // Allow rolling up into general purpose rules _fn = function () { return _.each(_.any.apply(null, arguments), _.not(g.ctoken2("timeContext"))); }; g.datePartDelimiter = _.rtoken(/^([\s\-\.\,\/\x27]+)/); g.timePartDelimiter = _.stoken(":"); g.whiteSpace = _.rtoken(/^\s*/); g.generalDelimiter = _.rtoken(/^(([\s\,]|at|@|on)+)/); var _C = {}; g.ctoken = function (keys) { var fn = _C[keys]; if (! fn) { var c = Date.CultureInfo.regexPatterns; var kx = keys.split(/\s+/), px = []; for (var i = 0; i < kx.length ; i++) { px.push(_.replace(_.rtoken(c[kx[i]]), kx[i])); } fn = _C[keys] = _.any.apply(null, px); } return fn; }; g.ctoken2 = function (key) { return _.rtoken(Date.CultureInfo.regexPatterns[key]); }; var cacheProcessRtoken = function (key, token, type, eachToken) { if (eachToken) { g[key] = _.cache(_.process(_.each(_.rtoken(token),_.optional(g.ctoken2(eachToken))), type)); } else { g[key] = _.cache(_.process(_.rtoken(token), type)); } }; var cacheProcessCtoken = function (token, type) { return _.cache(_.process(g.ctoken2(token), type)); }; var _F = {}; //function cache var _get = function (f) { _F[f] = (_F[f] || g.format(f)[0]); return _F[f]; }; g.allformats = function (fx) { var rx = []; if (fx instanceof Array) { for (var i = 0; i < fx.length; i++) { rx.push(_get(fx[i])); } } else { rx.push(_get(fx)); } return rx; }; g.formats = function (fx) { if (fx instanceof Array) { var rx = []; for (var i = 0 ; i < fx.length ; i++) { rx.push(_get(fx[i])); } return _.any.apply(null, rx); } else { return _get(fx); } }; var grammarFormats = { timeFormats: function(){ var i, RTokenKeys = [ "h", "hh", "H", "HH", "m", "mm", "s", "ss", "ss.s", "z", "zz" ], RToken = [ /^(0[0-9]|1[0-2]|[1-9])/, /^(0[0-9]|1[0-2])/, /^([0-1][0-9]|2[0-3]|[0-9])/, /^([0-1][0-9]|2[0-3])/, /^([0-5][0-9]|[0-9])/, /^[0-5][0-9]/, /^([0-5][0-9]|[0-9])/, /^[0-5][0-9]/, /^[0-5][0-9]\.[0-9]{1,3}/, /^((\+|\-)\s*\d\d\d\d)|((\+|\-)\d\d\:?\d\d)/, /^((\+|\-)\s*\d\d\d\d)|((\+|\-)\d\d\:?\d\d)/ ], tokens = [ t.hour, t.hour, t.hour, t.hour, t.minute, t.minute, t.second, t.second, t.secondAndMillisecond, t.timezone, t.timezone ]; for (i=0; i < RTokenKeys.length; i++) { cacheProcessRtoken(RTokenKeys[i], RToken[i], tokens[i]); } g.hms = _.cache(_.sequence([g.H, g.m, g.s], g.timePartDelimiter)); g.t = cacheProcessCtoken("shortMeridian", t.meridian); g.tt = cacheProcessCtoken("longMeridian", t.meridian); g.zzz = cacheProcessCtoken("timezone", t.timezone); g.timeSuffix = _.each(_.ignore(g.whiteSpace), _.set([ g.tt, g.zzz ])); g.time = _.each(_.optional(_.ignore(_.stoken("T"))), g.hms, g.timeSuffix); }, dateFormats: function () { // pre-loaded rules for different date part order preferences var _setfn = function () { return _.set(arguments, g.datePartDelimiter); }; var i, RTokenKeys = [ "d", "dd", "M", "MM", "y", "yy", "yyy", "yyyy" ], RToken = [ /^([0-2]\d|3[0-1]|\d)/, /^([0-2]\d|3[0-1])/, /^(1[0-2]|0\d|\d)/, /^(1[0-2]|0\d)/, /^(\d+)/, /^(\d\d)/, /^(\d\d?\d?\d?)/, /^(\d\d\d\d)/ ], tokens = [ t.day, t.day, t.month, t.month, t.year, t.year, t.year, t.year ], eachToken = [ "ordinalSuffix", "ordinalSuffix" ]; for (i=0; i < RTokenKeys.length; i++) { cacheProcessRtoken(RTokenKeys[i], RToken[i], tokens[i], eachToken[i]); } g.MMM = g.MMMM = _.cache(_.process(g.ctoken("jan feb mar apr may jun jul aug sep oct nov dec"), t.month)); g.ddd = g.dddd = _.cache(_.process(g.ctoken("sun mon tue wed thu fri sat"), function (s) { return function () { this.weekday = s; }; } )); g.day = _fn(g.d, g.dd); g.month = _fn(g.M, g.MMM); g.year = _fn(g.yyyy, g.yy); g.mdy = _setfn(g.ddd, g.month, g.day, g.year); g.ymd = _setfn(g.ddd, g.year, g.month, g.day); g.dmy = _setfn(g.ddd, g.day, g.month, g.year); g.date = function (s) { return ((g[Date.CultureInfo.dateElementOrder] || g.mdy).call(this, s)); }; }, relative: function () { // relative date / time expressions g.orientation = _.process(g.ctoken("past future"), function (s) { return function () { this.orient = s; }; } ); g.operator = _.process(g.ctoken("add subtract"), function (s) { return function () { this.operator = s; }; } ); g.rday = _.process(g.ctoken("yesterday tomorrow today now"), t.rday); g.unit = _.process(g.ctoken("second minute hour day week month year"), function (s) { return function () { this.unit = s; }; } ); } }; g.buildGrammarFormats = function () { // these need to be rebuilt every time the language changes. _C = {}; grammarFormats.timeFormats(); grammarFormats.dateFormats(); grammarFormats.relative(); g.value = _.process(_.rtoken(/^([-+]?\d+)?(st|nd|rd|th)?/), function (s) { return function () { this.value = s.replace(/\D/g, ""); }; } ); g.expression = _.set([g.rday, g.operator, g.value, g.unit, g.orientation, g.ddd, g.MMM ]); g.format = _.process(_.many( _.any( // translate format specifiers into grammar rules _.process( _.rtoken(/^(dd?d?d?(?!e)|MM?M?M?|yy?y?y?|hh?|HH?|mm?|ss?|tt?|zz?z?)/), function (fmt) { if (g[fmt]) { return g[fmt]; } else { throw $D.Parsing.Exception(fmt); } } ), // translate separator tokens into token rules _.process(_.rtoken(/^[^dMyhHmstz]+/), // all legal separators function (s) { return _.ignore(_.stoken(s)); } ) ) ), // construct the parser ... function (rules) { return _.process(_.each.apply(null, rules), t.finishExact); } ); // starting rule for general purpose grammar g._start = _.process(_.set([ g.date, g.time, g.expression ], g.generalDelimiter, g.whiteSpace), t.finish); }; g.buildGrammarFormats(); // parsing date format specifiers - ex: "h:m:s tt" // this little guy will generate a custom parser based // on the format string, ex: g.format("h:m:s tt") // check for these formats first g._formats = g.formats([ "\"yyyy-MM-ddTHH:mm:ssZ\"", "yyyy-MM-ddTHH:mm:ss.sz", "yyyy-MM-ddTHH:mm:ssZ", "yyyy-MM-ddTHH:mm:ssz", "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-ddTHH:mmZ", "yyyy-MM-ddTHH:mmz", "yyyy-MM-ddTHH:mm", "ddd, MMM dd, yyyy H:mm:ss tt", "ddd MMM d yyyy HH:mm:ss zzz", "MMddyyyy", "ddMMyyyy", "Mddyyyy", "ddMyyyy", "Mdyyyy", "dMyyyy", "yyyy", "Mdyy", "dMyy", "d" ]); // real starting rule: tries selected formats first, // then general purpose rule g.start = function (s) { try { var r = g._formats.call({}, s); if (r[1].length === 0) { return r; } } catch (e) {} return g._start.call({}, s); }; }()); (function () { var $D = Date; /** * @desc Converts the specified string value into its JavaScript Date equivalent using CultureInfo specific format information. * * Example

	///////////
	// Dates //
	///////////

	// 15-Oct-2004
	var d1 = Date.parse("10/15/2004");

	// 15-Oct-2004
	var d1 = Date.parse("15-Oct-2004");

	// 15-Oct-2004
	var d1 = Date.parse("2004.10.15");

	//Fri Oct 15, 2004
	var d1 = Date.parse("Fri Oct 15, 2004");

	///////////
	// Times //
	///////////

	// Today at 10 PM.
	var d1 = Date.parse("10 PM");

	// Today at 10:30 PM.
	var d1 = Date.parse("10:30 P.M.");

	// Today at 6 AM.
	var d1 = Date.parse("06am");

	/////////////////////
	// Dates and Times //
	/////////////////////

	// 8-July-2004 @ 10:30 PM
	var d1 = Date.parse("July 8th, 2004, 10:30 PM");

	// 1-July-2004 @ 10:30 PM
	var d1 = Date.parse("2004-07-01T22:30:00");

	////////////////////
	// Relative Dates //
	////////////////////

	// Returns today's date. The string "today" is culture specific.
	var d1 = Date.parse("today");

	// Returns yesterday's date. The string "yesterday" is culture specific.
	var d1 = Date.parse("yesterday");

	// Returns the date of the next thursday.
	var d1 = Date.parse("Next thursday");

	// Returns the date of the most previous monday.
	var d1 = Date.parse("last monday");

	// Returns today's day + one year.
	var d1 = Date.parse("next year");

	///////////////
	// Date Math //
	///////////////

	// Today + 2 days
	var d1 = Date.parse("t+2");

	// Today + 2 days
	var d1 = Date.parse("today + 2 days");

	// Today + 3 months
	var d1 = Date.parse("t+3m");

	// Today - 1 year
	var d1 = Date.parse("today - 1 year");

	// Today - 1 year
	var d1 = Date.parse("t-1y"); 


	/////////////////////////////
	// Partial Dates and Times //
	/////////////////////////////

	// July 15th of this year.
	var d1 = Date.parse("July 15");

	// 15th day of current day and year.
	var d1 = Date.parse("15");

	// July 1st of current year at 10pm.
	var d1 = Date.parse("7/1 10pm");
	
* * @param {String} The string value to convert into a Date object [Required] * @return {Date} A Date object or null if the string cannot be converted into a Date. */ var parseUtils = { removeOrds: function (s) { ords = s.match(/\b(\d+)(?:st|nd|rd|th)\b/); // find ordinal matches s = ((ords && ords.length === 2) ? s.replace(ords[0], ords[1]) : s); return s; }, grammarParser: function (s) { var r = null; try { r = $D.Grammar.start.call({}, s.replace(/^\s*(\S*(\s+\S+)*)\s*$/, "$1")); } catch (e) { return null; } return ((r[1].length === 0) ? r[0] : null); }, nativeFallback: function(s) { var t; try { // ok we haven't parsed it, last ditch attempt with the built-in parser. t = Date._parse(s); return (t || t === 0) ? new Date(t) : null; } catch (e) { return null; } } }; function parse (s) { var d; if (!s) { return null; } if (s instanceof Date) { return s.clone(); } if (s.length >= 4 && s.charAt(0) !== "0" && s.charAt(0) !== "+"&& s.charAt(0) !== "-") { // ie: 2004 will pass, 0800 won't. // Start with specific formats d = $D.Parsing.ISO.parse(s) || $D.Parsing.Numeric.parse(s); } if (d instanceof Date && !isNaN(d.getTime())) { return d; } else { // find ordinal dates (1st, 3rd, 8th, etc and remove them as they cause parsing issues) s = $D.Parsing.Normalizer.parse(parseUtils.removeOrds(s)); d = parseUtils.grammarParser(s); if (d !== null) { return d; } else { return parseUtils.nativeFallback(s); } } } if (!$D._parse) { $D._parse = $D.parse; } $D.parse = parse; Date.getParseFunction = function (fx) { var fns = Date.Grammar.allformats(fx); return function (s) { var r = null; for (var i = 0; i < fns.length; i++) { try { r = fns[i].call({}, s); } catch (e) { continue; } if (r[1].length === 0) { return r[0]; } } return null; }; }; /** * Converts the specified string value into its JavaScript Date equivalent using the specified format {String} or formats {Array} and the CultureInfo specific format information. * The format of the string value must match one of the supplied formats exactly. * * Example

	// 15-Oct-2004
	var d1 = Date.parseExact("10/15/2004", "M/d/yyyy");

	// 15-Oct-2004
	var d1 = Date.parse("15-Oct-2004", "M-ddd-yyyy");

	// 15-Oct-2004
	var d1 = Date.parse("2004.10.15", "yyyy.MM.dd");

	// Multiple formats
	var d1 = Date.parseExact("10/15/2004", ["M/d/yyyy", "MMMM d, yyyy"]);
	
* * @param {String} The string value to convert into a Date object [Required]. * @param {Object} The expected format {String} or an array of expected formats {Array} of the date string [Required]. * @return {Date} A Date object or null if the string cannot be converted into a Date. */ $D.parseExact = function (s, fx) { return $D.getParseFunction(fx)(s); }; }()); (function () { var $D = Date, $P = $D.prototype, // $C = $D.CultureInfo, // not used atm p = function (s, l) { if (!l) { l = 2; } return ("000" + s).slice(l * -1); }; /** * Converts a PHP format string to Java/.NET format string. * A PHP format string can be used with ._format or .format. * A Java/.NET format string can be used with .toString(). * The .parseExact function will only accept a Java/.NET format string * * Example * var f1 = "%m/%d/%y" * var f2 = Date.normalizeFormat(f1); // "MM/dd/yy" * * new Date().format(f1); // "04/13/08" * new Date()._format(f1); // "04/13/08" * new Date().toString(f2); // "04/13/08" * * var date = Date.parseExact("04/13/08", f2); // Sun Apr 13 2008 * * @param {String} A PHP format string consisting of one or more format spcifiers. * @return {String} The PHP format converted to a Java/.NET format string. */ var normalizerSubstitutions = { "d" : "dd", "%d": "dd", "D" : "ddd", "%a": "ddd", "j" : "dddd", "l" : "dddd", "%A": "dddd", "S" : "S", "F" : "MMMM", "%B": "MMMM", "m" : "MM", "%m": "MM", "M" : "MMM", "%b": "MMM", "%h": "MMM", "n" : "M", "Y" : "yyyy", "%Y": "yyyy", "y" : "yy", "%y": "yy", "g" : "h", "%I": "h", "G" : "H", "h" : "hh", "H" : "HH", "%H": "HH", "i" : "mm", "%M": "mm", "s" : "ss", "%S": "ss", "%r": "hh:mm tt", "%R": "H:mm", "%T": "H:mm:ss", "%X": "t", "%x": "d", "%e": "d", "%D": "MM/dd/yy", "%n": "\\n", "%t": "\\t", "e" : "z", "T" : "z", "%z": "z", "%Z": "z", "Z" : "ZZ", "N" : "u", "w" : "u", "%w": "u", "W" : "W", "%V": "W" }; var normalizer = { substitutes: function (m) { return normalizerSubstitutions[m]; }, interpreted: function (m, x) { var y; switch (m) { case "%u": return x.getDay() + 1; case "z": return x.getOrdinalNumber(); case "%j": return p(x.getOrdinalNumber(), 3); case "%U": var d1 = x.clone().set({month: 0, day: 1}).addDays(-1).moveToDayOfWeek(0), d2 = x.clone().addDays(1).moveToDayOfWeek(0, -1); return (d2 < d1) ? "00" : p((d2.getOrdinalNumber() - d1.getOrdinalNumber()) / 7 + 1); case "%W": return p(x.getWeek()); case "t": return $D.getDaysInMonth(x.getFullYear(), x.getMonth()); case "o": case "%G": return x.setWeek(x.getISOWeek()).toString("yyyy"); case "%g": return x._format("%G").slice(-2); case "a": case "%p": return t("tt").toLowerCase(); case "A": return t("tt").toUpperCase(); case "u": return p(x.getMilliseconds(), 3); case "I": return (x.isDaylightSavingTime()) ? 1 : 0; case "O": return x.getUTCOffset(); case "P": y = x.getUTCOffset(); return y.substring(0, y.length - 2) + ":" + y.substring(y.length - 2); case "B": var now = new Date(); return Math.floor(((now.getHours() * 3600) + (now.getMinutes() * 60) + now.getSeconds() + (now.getTimezoneOffset() + 60) * 60) / 86.4); case "c": return x.toISOString().replace(/\"/g, ""); case "U": return $D.strtotime("now"); case "%c": return t("d") + " " + t("t"); case "%C": return Math.floor(x.getFullYear() / 100 + 1); } }, shouldOverrideDefaults: function (m) { switch (m) { case "%e": return true; default: return false; } }, parse: function (m, context) { var formatString, c = context || new Date(); formatString = normalizer.substitutes(m); if (formatString) { return formatString; } formatString = normalizer.interpreted(m, c); if (formatString) { return formatString; } else { return m; } } }; $D.normalizeFormat = function (format, context) { return format.replace(/(%|\\)?.|%%/g, function(t){ return normalizer.parse(t, context); }); }; /** * Format a local Unix timestamp according to locale settings * * Example: * Date.strftime("%m/%d/%y", new Date()); // "04/13/08" * Date.strftime("c", "2008-04-13T17:52:03Z"); // "04/13/08" * * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @param {Number|String} The number representing the number of seconds that have elapsed since January 1, 1970 (local time). * @return {String} A string representation of the current Date object. */ $D.strftime = function (format, time) { var d = Date.parse(time); return d._format(format); }; /** * Parse any textual datetime description into a Unix timestamp. * A Unix timestamp is the number of seconds that have elapsed since January 1, 1970 (midnight UTC/GMT). * * Example: * Date.strtotime("04/13/08"); // 1208044800 * Date.strtotime("1970-01-01T00:00:00Z"); // 0 * * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @param {Object} A string or date object. * @return {String} A string representation of the current Date object. */ $D.strtotime = function (time) { var d = $D.parse(time); return Math.round($D.UTC(d.getUTCFullYear(), d.getUTCMonth(), d.getUTCDate(), d.getUTCHours(), d.getUTCMinutes(), d.getUTCSeconds(), d.getUTCMilliseconds()) / 1000); }; /** * Converts the value of the current Date object to its equivalent string representation using a PHP/Unix style of date format specifiers. * Format Specifiers * Format Description Example * ------ --------------------------------------------------------------------------- ----------------------- * %a abbreviated weekday name according to the current localed "Mon" through "Sun" * %A full weekday name according to the current localed "Sunday" through "Saturday" * %b abbreviated month name according to the current localed "Jan" through "Dec" * %B full month name according to the current locale "January" through "December" * %c preferred date and time representation for the current locale "4/13/2008 12:33 PM" * %C century number (the year divided by 100 and truncated to an integer) "00" to "99" * %d day of the month as a decimal number "01" to "31" * %D same as %m/%d/%y "04/13/08" * %e day of the month as a decimal number, a single digit is preceded by a space "1" to "31" * %g like %G, but without the century "08" * %G The 4-digit year corresponding to the ISO week number (see %V). "2008" * This has the same format and value as %Y, except that if the ISO week number * belongs to the previous or next year, that year is used instead. * %h same as %b "Jan" through "Dec" * %H hour as a decimal number using a 24-hour clock. "00" to "23" * %I hour as a decimal number using a 12-hour clock. "01" to "12" * %j day of the year as a decimal number. "001" to "366" * %m month as a decimal number. "01" to "12" * %M minute as a decimal number. "00" to "59" * %n newline character "\n" * %p either "am" or "pm" according to the given time value, or the "am" or "pm" * corresponding strings for the current locale. * %r time in a.m. and p.m. notation "8:44 PM" * %R time in 24 hour notation "20:44" * %S second as a decimal number "00" to "59" * %t tab character "\t" * %T current time, equal to %H:%M:%S "12:49:11" * %u weekday as a decimal number ["1", "7"], with "1" representing Monday "1" to "7" * %U week number of the current year as a decimal number, starting with the "0" to ("52" or "53") * first Sunday as the first day of the first week * %V The ISO 8601:1988 week number of the current year as a decimal number, "00" to ("52" or "53") * range 01 to 53, where week 1 is the first week that has at least 4 days * in the current year, and with Monday as the first day of the week. * (Use %G or %g for the year component that corresponds to the week number * for the specified timestamp.) * %W week number of the current year as a decimal number, starting with the "00" to ("52" or "53") * first Monday as the first day of the first week * %w day of the week as a decimal, Sunday being "0" "0" to "6" * %x preferred date representation for the current locale without the time "4/13/2008" * %X preferred time representation for the current locale without the date "12:53:05" * %y year as a decimal number without a century "00" "99" * %Y year as a decimal number including the century "2008" * %Z time zone or name or abbreviation "UTC", "EST", "PST" * %z same as %Z * %% a literal "%" characters "%" * d Day of the month, 2 digits with leading zeros "01" to "31" * D A textual representation of a day, three letters "Mon" through "Sun" * j Day of the month without leading zeros "1" to "31" * l A full textual representation of the day of the week (lowercase "L") "Sunday" through "Saturday" * N ISO-8601 numeric representation of the day of the week (added in PHP 5.1.0) "1" (for Monday) through "7" (for Sunday) * S English ordinal suffix for the day of the month, 2 characters "st", "nd", "rd" or "th". Works well with j * w Numeric representation of the day of the week "0" (for Sunday) through "6" (for Saturday) * z The day of the year (starting from "0") "0" through "365" * W ISO-8601 week number of year, weeks starting on Monday "00" to ("52" or "53") * F A full textual representation of a month, such as January or March "January" through "December" * m Numeric representation of a month, with leading zeros "01" through "12" * M A short textual representation of a month, three letters "Jan" through "Dec" * n Numeric representation of a month, without leading zeros "1" through "12" * t Number of days in the given month "28" through "31" * L Whether it's a leap year "1" if it is a leap year, "0" otherwise * o ISO-8601 year number. This has the same value as Y, except that if the "2008" * ISO week number (W) belongs to the previous or next year, that year * is used instead. * Y A full numeric representation of a year, 4 digits "2008" * y A two digit representation of a year "08" * a Lowercase Ante meridiem and Post meridiem "am" or "pm" * A Uppercase Ante meridiem and Post meridiem "AM" or "PM" * B Swatch Internet time "000" through "999" * g 12-hour format of an hour without leading zeros "1" through "12" * G 24-hour format of an hour without leading zeros "0" through "23" * h 12-hour format of an hour with leading zeros "01" through "12" * H 24-hour format of an hour with leading zeros "00" through "23" * i Minutes with leading zeros "00" to "59" * s Seconds, with leading zeros "00" through "59" * u Milliseconds "54321" * e Timezone identifier "UTC", "EST", "PST" * I Whether or not the date is in daylight saving time (uppercase i) "1" if Daylight Saving Time, "0" otherwise * O Difference to Greenwich time (GMT) in hours "+0200", "-0600" * P Difference to Greenwich time (GMT) with colon between hours and minutes "+02:00", "-06:00" * T Timezone abbreviation "UTC", "EST", "PST" * Z Timezone offset in seconds. The offset for timezones west of UTC is "-43200" through "50400" * always negative, and for those east of UTC is always positive. * c ISO 8601 date "2004-02-12T15:19:21+00:00" * r RFC 2822 formatted date "Thu, 21 Dec 2000 16:01:07 +0200" * U Seconds since the Unix Epoch (January 1 1970 00:00:00 GMT) "0" * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @return {String} A string representation of the current Date object. */ var formatReplace = function (context) { return function (m) { var formatString, override = false; if (m.charAt(0) === "\\" || m.substring(0, 2) === "%%") { return m.replace("\\", "").replace("%%", "%"); } override = normalizer.shouldOverrideDefaults(m); formatString = $D.normalizeFormat(m, context); if (formatString) { return context.toString(formatString, override); } }; }; $P._format = function (format) { var formatter = formatReplace(this); if (!format) { return this._toString(); } else { return format.replace(/(%|\\)?.|%%/g, formatter); } }; if (!$P.format) { $P.format = $P._format; } }()); (function () { "use strict"; var gFn = function (attr) { return function () { return this[attr]; }; }; var sFn = function (attr) { return function (val) { this[attr] = val; return this; }; }; var attrs = ["years", "months", "days", "hours", "minutes", "seconds", "milliseconds"]; var addSetFuncs = function (context, attrs) { for (var i = 0; i < attrs.length ; i++) { var $a = attrs[i], $b = $a.slice(0, 1).toUpperCase() + $a.slice(1); context.prototype[$a] = 0; context.prototype["get" + $b] = gFn($a); context.prototype["set" + $b] = sFn($a); } }; /** * new TimeSpan(milliseconds); * new TimeSpan(days, hours, minutes, seconds); * new TimeSpan(days, hours, minutes, seconds, milliseconds); */ var TimeSpan = function (days, hours, minutes, seconds, milliseconds) { if (arguments.length === 1 && typeof days === "number") { var orient = (days < 0) ? -1 : +1; var millsLeft = Math.abs(days); this.setDays(Math.floor(millsLeft / 86400000) * orient); millsLeft = millsLeft % 86400000; this.setHours(Math.floor(millsLeft / 3600000) * orient); millsLeft = millsLeft % 3600000; this.setMinutes(Math.floor(millsLeft / 60000) * orient); millsLeft = millsLeft % 60000; this.setSeconds(Math.floor(millsLeft / 1000) * orient); millsLeft = millsLeft % 1000; this.setMilliseconds(millsLeft * orient); } else { this.set(days, hours, minutes, seconds, milliseconds); } this.getTotalMilliseconds = function () { return (this.getDays() * 86400000) + (this.getHours() * 3600000) + (this.getMinutes() * 60000) + (this.getSeconds() * 1000); }; this.compareTo = function (time) { var t1 = new Date(1970, 1, 1, this.getHours(), this.getMinutes(), this.getSeconds()), t2; if (time === null) { t2 = new Date(1970, 1, 1, 0, 0, 0); } else { t2 = new Date(1970, 1, 1, time.getHours(), time.getMinutes(), time.getSeconds()); } return (t1 < t2) ? -1 : (t1 > t2) ? 1 : 0; }; this.equals = function (time) { return (this.compareTo(time) === 0); }; this.add = function (time) { return (time === null) ? this : this.addSeconds(time.getTotalMilliseconds() / 1000); }; this.subtract = function (time) { return (time === null) ? this : this.addSeconds(-time.getTotalMilliseconds() / 1000); }; this.addDays = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 86400000)); }; this.addHours = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 3600000)); }; this.addMinutes = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 60000)); }; this.addSeconds = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 1000)); }; this.addMilliseconds = function (n) { return new TimeSpan(this.getTotalMilliseconds() + n); }; this.get12HourHour = function () { return (this.getHours() > 12) ? this.getHours() - 12 : (this.getHours() === 0) ? 12 : this.getHours(); }; this.getDesignator = function () { return (this.getHours() < 12) ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator; }; this.toString = function (format) { this._toString = function () { if (this.getDays() !== null && this.getDays() > 0) { return this.getDays() + "." + this.getHours() + ":" + this.p(this.getMinutes()) + ":" + this.p(this.getSeconds()); } else { return this.getHours() + ":" + this.p(this.getMinutes()) + ":" + this.p(this.getSeconds()); } }; this.p = function (s) { return (s.toString().length < 2) ? "0" + s : s; }; var me = this; return format ? format.replace(/dd?|HH?|hh?|mm?|ss?|tt?/g, function (format) { switch (format) { case "d": return me.getDays(); case "dd": return me.p(me.getDays()); case "H": return me.getHours(); case "HH": return me.p(me.getHours()); case "h": return me.get12HourHour(); case "hh": return me.p(me.get12HourHour()); case "m": return me.getMinutes(); case "mm": return me.p(me.getMinutes()); case "s": return me.getSeconds(); case "ss": return me.p(me.getSeconds()); case "t": return ((me.getHours() < 12) ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator).substring(0, 1); case "tt": return (me.getHours() < 12) ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator; } } ) : this._toString(); }; return this; }; addSetFuncs(TimeSpan, attrs.slice(2)); TimeSpan.prototype.set = function (days, hours, minutes, seconds, milliseconds){ this.setDays(days || this.getDays()); this.setHours(hours || this.getHours()); this.setMinutes(minutes || this.getMinutes()); this.setSeconds(seconds || this.getSeconds()); this.setMilliseconds(milliseconds || this.getMilliseconds()); }; /** * Gets the time of day for this date instances. * @return {TimeSpan} TimeSpan */ Date.prototype.getTimeOfDay = function () { return new TimeSpan(0, this.getHours(), this.getMinutes(), this.getSeconds(), this.getMilliseconds()); }; Date.TimeSpan = TimeSpan; if (typeof window !== "undefined" ) { // keeping API compatible for v1.x window.TimeSpan = TimeSpan; } }()); (function () { "use strict"; var attrs = ["years", "months", "days", "hours", "minutes", "seconds", "milliseconds"]; var gFn = function (attr) { return function () { return this[attr]; }; }; var sFn = function (attr) { return function (val) { this[attr] = val; return this; }; }; var addSetFuncs = function (context, attrs) { for (var i = 0; i < attrs.length ; i++) { var $a = attrs[i], $b = $a.slice(0, 1).toUpperCase() + $a.slice(1); context.prototype[$a] = 0; context.prototype["get" + $b] = gFn($a); context.prototype["set" + $b] = sFn($a); } }; var setMonthsAndYears = function (orient, d1, d2, context) { function inc() { d1.addMonths(-orient); context.months++; if (context.months === 12) { context.years++; context.months = 0; } } if (orient === +1) { while (d1 > d2) { inc(); } } else { while (d1 < d2) { inc(); } } context.months--; context.months *= orient; context.years *= orient; }; var adjustForDST = function(orient, startDate, endDate) { var hasDSTMismatch = (false === (startDate.isDaylightSavingTime() === endDate.isDaylightSavingTime())); if (hasDSTMismatch && orient === 1) { startDate.addHours(-1); } else if (hasDSTMismatch) { startDate.addHours(1); } }; /** * TimePeriod(startDate, endDate); * TimePeriod(years, months, days, hours, minutes, seconds, milliseconds); */ var TimePeriod = function (years, months, days, hours, minutes, seconds, milliseconds) { if (arguments.length === 7) { this.set(years, months, days, hours, minutes, seconds, milliseconds); } else if (arguments.length === 2 && arguments[0] instanceof Date && arguments[1] instanceof Date) { var startDate = arguments[0].clone(); var endDate = arguments[1].clone(); var orient = (startDate > endDate) ? +1 : -1; this.dates = { start: arguments[0].clone(), end: arguments[1].clone() }; setMonthsAndYears(orient, startDate, endDate, this); adjustForDST(orient, startDate, endDate); // // TODO - adjust for DST var diff = endDate - startDate; if (diff !== 0) { var ts = new TimeSpan(diff); this.set(this.years, this.months, ts.getDays(), ts.getHours(), ts.getMinutes(), ts.getSeconds(), ts.getMilliseconds()); } } return this; }; // create all the set functions. addSetFuncs(TimePeriod, attrs); TimePeriod.prototype.set = function (years, months, days, hours, minutes, seconds, milliseconds){ this.setYears(years || this.getYears()); this.setMonths(months || this.getMonths()); this.setDays(days || this.getDays()); this.setHours(hours || this.getHours()); this.setMinutes(minutes || this.getMinutes()); this.setSeconds(seconds || this.getSeconds()); this.setMilliseconds(milliseconds || this.getMilliseconds()); }; Date.TimePeriod = TimePeriod; if (typeof window !== "undefined") { // keeping API compatible for v1.x window.TimePeriod = TimePeriod; } }()); ================================================ FILE: build/date-sl-SI.js ================================================ /** * @overview datejs * @version 1.0.0-rc3 * @author Gregory Wild-Smith * @copyright 2015 Gregory Wild-Smith * @license MIT * @homepage https://github.com/abritinthebay/datejs */ /* * DateJS Culture String File * Country Code: sl-SI * Name: Slovenian (Slovenia) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["sl-SI"] = { "name": "sl-SI", "englishName": "Slovenian (Slovenia)", "nativeName": "slovenski (Slovenija)", "Sunday": "nedelja", "Monday": "ponedeljek", "Tuesday": "torek", "Wednesday": "sreda", "Thursday": "četrtek", "Friday": "petek", "Saturday": "sobota", "Sun": "ned", "Mon": "pon", "Tue": "tor", "Wed": "sre", "Thu": "čet", "Fri": "pet", "Sat": "sob", "Su": "ne", "Mo": "po", "Tu": "to", "We": "sr", "Th": "če", "Fr": "pe", "Sa": "so", "S_Sun_Initial": "n", "M_Mon_Initial": "p", "T_Tue_Initial": "t", "W_Wed_Initial": "s", "T_Thu_Initial": "č", "F_Fri_Initial": "p", "S_Sat_Initial": "s", "January": "januar", "February": "februar", "March": "marec", "April": "april", "May": "maj", "June": "junij", "July": "julij", "August": "avgust", "September": "september", "October": "oktober", "November": "november", "December": "december", "Jan_Abbr": "jan", "Feb_Abbr": "feb", "Mar_Abbr": "mar", "Apr_Abbr": "apr", "May_Abbr": "maj", "Jun_Abbr": "jun", "Jul_Abbr": "jul", "Aug_Abbr": "avg", "Sep_Abbr": "sep", "Oct_Abbr": "okt", "Nov_Abbr": "nov", "Dec_Abbr": "dec", "AM": "", "PM": "", "firstDayOfWeek": 1, "twoDigitYearMax": 2029, "mdy": "dmy", "M/d/yyyy": "d.M.yyyy", "dddd, MMMM dd, yyyy": "d. MMMM yyyy", "h:mm tt": "H:mm", "h:mm:ss tt": "H:mm:ss", "dddd, MMMM dd, yyyy h:mm:ss tt": "d. MMMM yyyy H:mm:ss", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "d. MMMM", "MMMM, yyyy": "MMMM yyyy", "/jan(uary)?/": "jan(uar)?", "/feb(ruary)?/": "feb(ruar)?", "/mar(ch)?/": "mar(ec)?", "/apr(il)?/": "apr(il)?", "/may/": "maj", "/jun(e)?/": "jun(ij)?", "/jul(y)?/": "jul(ij)?", "/aug(ust)?/": "avg(ust)?", "/sep(t(ember)?)?/": "sep(t(ember)?)?", "/oct(ober)?/": "okt(ober)?", "/nov(ember)?/": "nov(ember)?", "/dec(ember)?/": "dec(ember)?", "/^su(n(day)?)?/": "^ne(d(elja)?)?", "/^mo(n(day)?)?/": "^po(n(edeljek)?)?", "/^tu(e(s(day)?)?)?/": "^to(r(ek)?)?", "/^we(d(nesday)?)?/": "^sr(e(da)?)?", "/^th(u(r(s(day)?)?)?)?/": "^če(t(rtek)?)?", "/^fr(i(day)?)?/": "^pe(t(ek)?)?", "/^sa(t(urday)?)?/": "^so(b(ota)?)?", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "sl-SI"; /** * @overview datejs * @version 1.0.0-rc3 * @author Gregory Wild-Smith * @copyright 2015 Gregory Wild-Smith * @license MIT * @homepage https://github.com/abritinthebay/datejs */(function () { var $D = Date; var lang = Date.CultureStrings ? Date.CultureStrings.lang : null; var loggedKeys = {}; // for debug purposes. var getText = { getFromKey: function (key, countryCode) { var output; if (Date.CultureStrings && Date.CultureStrings[countryCode] && Date.CultureStrings[countryCode][key]) { output = Date.CultureStrings[countryCode][key]; } else { output = getText.buildFromDefault(key); } if (key.charAt(0) === "/") { // Assume it's a regex output = getText.buildFromRegex(key, countryCode); } return output; }, getFromObjectValues: function (obj, countryCode) { var key, output = {}; for(key in obj) { if (obj.hasOwnProperty(key)) { output[key] = getText.getFromKey(obj[key], countryCode); } } return output; }, getFromObjectKeys: function (obj, countryCode) { var key, output = {}; for(key in obj) { if (obj.hasOwnProperty(key)) { output[getText.getFromKey(key, countryCode)] = obj[key]; } } return output; }, getFromArray: function (arr, countryCode) { var output = []; for (var i=0; i < arr.length; i++){ if (i in arr) { output[i] = getText.getFromKey(arr[i], countryCode); } } return output; }, buildFromDefault: function (key) { var output, length, split, last; switch(key) { case "name": output = "en-US"; break; case "englishName": output = "English (United States)"; break; case "nativeName": output = "English (United States)"; break; case "twoDigitYearMax": output = 2049; break; case "firstDayOfWeek": output = 0; break; default: output = key; split = key.split("_"); length = split.length; if (length > 1 && key.charAt(0) !== "/") { // if the key isn't a regex and it has a split. last = split[(length - 1)].toLowerCase(); if (last === "initial" || last === "abbr") { output = split[0]; } } break; } return output; }, buildFromRegex: function (key, countryCode) { var output; if (Date.CultureStrings && Date.CultureStrings[countryCode] && Date.CultureStrings[countryCode][key]) { output = new RegExp(Date.CultureStrings[countryCode][key], "i"); } else { output = new RegExp(key.replace(new RegExp("/", "g"),""), "i"); } return output; } }; var shallowMerge = function (obj1, obj2) { for (var attrname in obj2) { if (obj2.hasOwnProperty(attrname)) { obj1[attrname] = obj2[attrname]; } } }; var __ = function (key, language) { var countryCode = (language) ? language : lang; loggedKeys[key] = key; if (typeof key === "object") { if (key instanceof Array) { return getText.getFromArray(key, countryCode); } else { return getText.getFromObjectKeys(key, countryCode); } } else { return getText.getFromKey(key, countryCode); } }; var loadI18nScript = function (code) { // paatterned after jQuery's getScript. var url = Date.Config.i18n + code + ".js"; var head = document.getElementsByTagName("head")[0] || document.documentElement; var script = document.createElement("script"); script.src = url; var completed = false; var events = { done: function (){} // placeholder function }; // Attach handlers for all browsers script.onload = script.onreadystatechange = function() { if ( !completed && (!this.readyState || this.readyState === "loaded" || this.readyState === "complete") ) { events.done(); head.removeChild(script); } }; setTimeout(function() { head.insertBefore(script, head.firstChild); }, 0); // allows return to execute first return { done: function (cb) { events.done = function() { if (cb) { setTimeout(cb,0); } }; } }; }; var buildInfo = { buildFromMethodHash: function (obj) { var key; for(key in obj) { if (obj.hasOwnProperty(key)) { obj[key] = buildInfo[obj[key]](); } } return obj; }, timeZoneDST: function () { var DST = { "CHADT": "+1345", "NZDT": "+1300", "AEDT": "+1100", "ACDT": "+1030", "AZST": "+0500", "IRDT": "+0430", "EEST": "+0300", "CEST": "+0200", "BST": "+0100", "PMDT": "-0200", "ADT": "-0300", "NDT": "-0230", "EDT": "-0400", "CDT": "-0500", "MDT": "-0600", "PDT": "-0700", "AKDT": "-0800", "HADT": "-0900" }; return __(DST); }, timeZoneStandard: function () { var standard = { "LINT": "+1400", "TOT": "+1300", "CHAST": "+1245", "NZST": "+1200", "NFT": "+1130", "SBT": "+1100", "AEST": "+1000", "ACST": "+0930", "JST": "+0900", "CWST": "+0845", "CT": "+0800", "ICT": "+0700", "MMT": "+0630", "BST": "+0600", "NPT": "+0545", "IST": "+0530", "PKT": "+0500", "AFT": "+0430", "MSK": "+0400", "IRST": "+0330", "FET": "+0300", "EET": "+0200", "CET": "+0100", "GMT": "+0000", "UTC": "+0000", "CVT": "-0100", "GST": "-0200", "BRT": "-0300", "NST": "-0330", "AST": "-0400", "EST": "-0500", "CST": "-0600", "MST": "-0700", "PST": "-0800", "AKST": "-0900", "MIT": "-0930", "HST": "-1000", "SST": "-1100", "BIT": "-1200" }; return __(standard); }, timeZones: function (data) { var zone; data.timezones = []; for (zone in data.abbreviatedTimeZoneStandard) { if (data.abbreviatedTimeZoneStandard.hasOwnProperty(zone)) { data.timezones.push({ name: zone, offset: data.abbreviatedTimeZoneStandard[zone]}); } } for (zone in data.abbreviatedTimeZoneDST) { if (data.abbreviatedTimeZoneDST.hasOwnProperty(zone)) { data.timezones.push({ name: zone, offset: data.abbreviatedTimeZoneDST[zone], dst: true}); } } return data.timezones; }, days: function () { return __(["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"]); }, dayAbbr: function () { return __(["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"]); }, dayShortNames: function () { return __(["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"]); }, dayFirstLetters: function () { return __(["S_Sun_Initial", "M_Mon_Initial", "T_Tues_Initial", "W_Wed_Initial", "T_Thu_Initial", "F_Fri_Initial", "S_Sat_Initial"]); }, months: function () { return __(["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"]); }, monthAbbr: function () { return __(["Jan_Abbr", "Feb_Abbr", "Mar_Abbr", "Apr_Abbr", "May_Abbr", "Jun_Abbr", "Jul_Abbr", "Aug_Abbr", "Sep_Abbr", "Oct_Abbr", "Nov_Abbr", "Dec_Abbr"]); }, formatPatterns: function () { return getText.getFromObjectValues({ shortDate: "M/d/yyyy", longDate: "dddd, MMMM dd, yyyy", shortTime: "h:mm tt", longTime: "h:mm:ss tt", fullDateTime: "dddd, MMMM dd, yyyy h:mm:ss tt", sortableDateTime: "yyyy-MM-ddTHH:mm:ss", universalSortableDateTime: "yyyy-MM-dd HH:mm:ssZ", rfc1123: "ddd, dd MMM yyyy HH:mm:ss", monthDay: "MMMM dd", yearMonth: "MMMM, yyyy" }, Date.i18n.currentLanguage()); }, regex: function () { return getText.getFromObjectValues({ inTheMorning: "/( in the )(morn(ing)?)\\b/", thisMorning: "/(this )(morn(ing)?)\\b/", amThisMorning: "/(\b\\d(am)? )(this )(morn(ing)?)/", inTheEvening: "/( in the )(even(ing)?)\\b/", thisEvening: "/(this )(even(ing)?)\\b/", pmThisEvening: "/(\b\\d(pm)? )(this )(even(ing)?)/", jan: "/jan(uary)?/", feb: "/feb(ruary)?/", mar: "/mar(ch)?/", apr: "/apr(il)?/", may: "/may/", jun: "/jun(e)?/", jul: "/jul(y)?/", aug: "/aug(ust)?/", sep: "/sep(t(ember)?)?/", oct: "/oct(ober)?/", nov: "/nov(ember)?/", dec: "/dec(ember)?/", sun: "/^su(n(day)?)?/", mon: "/^mo(n(day)?)?/", tue: "/^tu(e(s(day)?)?)?/", wed: "/^we(d(nesday)?)?/", thu: "/^th(u(r(s(day)?)?)?)?/", fri: "/fr(i(day)?)?/", sat: "/^sa(t(urday)?)?/", future: "/^next/", past: "/^last|past|prev(ious)?/", add: "/^(\\+|aft(er)?|from|hence)/", subtract: "/^(\\-|bef(ore)?|ago)/", yesterday: "/^yes(terday)?/", today: "/^t(od(ay)?)?/", tomorrow: "/^tom(orrow)?/", now: "/^n(ow)?/", millisecond: "/^ms|milli(second)?s?/", second: "/^sec(ond)?s?/", minute: "/^mn|min(ute)?s?/", hour: "/^h(our)?s?/", week: "/^w(eek)?s?/", month: "/^m(onth)?s?/", day: "/^d(ay)?s?/", year: "/^y(ear)?s?/", shortMeridian: "/^(a|p)/", longMeridian: "/^(a\\.?m?\\.?|p\\.?m?\\.?)/", timezone: "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/", ordinalSuffix: "/^\\s*(st|nd|rd|th)/", timeContext: "/^\\s*(\\:|a(?!u|p)|p)/" }, Date.i18n.currentLanguage()); } }; var CultureInfo = function () { var info = getText.getFromObjectValues({ name: "name", englishName: "englishName", nativeName: "nativeName", amDesignator: "AM", pmDesignator: "PM", firstDayOfWeek: "firstDayOfWeek", twoDigitYearMax: "twoDigitYearMax", dateElementOrder: "mdy" }, Date.i18n.currentLanguage()); var constructedInfo = buildInfo.buildFromMethodHash({ dayNames: "days", abbreviatedDayNames: "dayAbbr", shortestDayNames: "dayShortNames", firstLetterDayNames: "dayFirstLetters", monthNames: "months", abbreviatedMonthNames: "monthAbbr", formatPatterns: "formatPatterns", regexPatterns: "regex", abbreviatedTimeZoneDST: "timeZoneDST", abbreviatedTimeZoneStandard: "timeZoneStandard" }); shallowMerge(info, constructedInfo); buildInfo.timeZones(info); return info; }; $D.i18n = { __: function (key, lang) { return __(key, lang); }, currentLanguage: function () { return lang || "en-US"; }, setLanguage: function (code, force, cb) { var async = false; if (force || code === "en-US" || (!!Date.CultureStrings && !!Date.CultureStrings[code])) { lang = code; Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings.lang = code; Date.CultureInfo = new CultureInfo(); } else { if (!(!!Date.CultureStrings && !!Date.CultureStrings[code])) { if (typeof exports !== "undefined" && this.exports !== exports) { // we're in a Node enviroment, load it using require try { require("../i18n/" + code + ".js"); lang = code; Date.CultureStrings.lang = code; Date.CultureInfo = new CultureInfo(); } catch (e) { // var str = "The language for '" + code + "' could not be loaded by Node. It likely does not exist."; throw new Error("The DateJS IETF language tag '" + code + "' could not be loaded by Node. It likely does not exist."); } } else if (Date.Config && Date.Config.i18n) { // we know the location of the files, so lets load them async = true; loadI18nScript(code).done(function(){ lang = code; Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings.lang = code; Date.CultureInfo = new CultureInfo(); $D.Parsing.Normalizer.buildReplaceData(); // because this is async if ($D.Grammar) { $D.Grammar.buildGrammarFormats(); // so we can parse those strings... } if (cb) { setTimeout(cb,0); } }); } else { Date.console.error("The DateJS IETF language tag '" + code + "' is not available and has not been loaded."); return false; } } } $D.Parsing.Normalizer.buildReplaceData(); // rebuild normalizer strings if ($D.Grammar) { $D.Grammar.buildGrammarFormats(); // so we can parse those strings... } if (!async && cb) { setTimeout(cb,0); } }, getLoggedKeys: function () { return loggedKeys; }, updateCultureInfo: function () { Date.CultureInfo = new CultureInfo(); } }; $D.i18n.updateCultureInfo(); // run automatically }()); (function () { var $D = Date, $P = $D.prototype, p = function (s, l) { if (!l) { l = 2; } return ("000" + s).slice(l * -1); }; if (typeof window !== "undefined" && typeof window.console !== "undefined" && typeof window.console.log !== "undefined") { $D.console = console; // used only to raise non-critical errors if available } else { // set mock so we don't give errors. $D.console = { log: function(){}, error: function(){} }; } $D.Config = $D.Config || {}; $D.initOverloads = function() { /** * Overload of Date.now. Allows an alternate call for Date.now where it returns the * current Date as an object rather than just milliseconds since the Unix Epoch. * * Also provides an implementation of now() for browsers (IE<9) that don't have it. * * Backwards compatible so with work with either: * Date.now() [returns ms] * or * Date.now(true) [returns Date] */ if (!$D.now) { $D._now = function now() { return new Date().getTime(); }; } else if (!$D._now) { $D._now = $D.now; } $D.now = function (returnObj) { if (returnObj) { return $D.present(); } else { return $D._now(); } }; if ( !$P.toISOString ) { $P.toISOString = function() { return this.getUTCFullYear() + "-" + p(this.getUTCMonth() + 1) + "-" + p(this.getUTCDate()) + "T" + p(this.getUTCHours()) + ":" + p(this.getUTCMinutes()) + ":" + p(this.getUTCSeconds()) + "." + String( (this.getUTCMilliseconds()/1000).toFixed(3)).slice(2, 5) + "Z"; }; } // private if ( $P._toString === undefined ){ $P._toString = $P.toString; } }; $D.initOverloads(); /** * Gets a date that is set to the current date. The time is set to the start of the day (00:00 or 12:00 AM). * @return {Date} The current date. */ $D.today = function () { return new Date().clearTime(); }; /** * Gets a date that is set to the current date and time (same as new Date, but chainable) * @return {Date} The current date. */ $D.present = function () { return new Date(); }; /** * Compares the first date to the second date and returns an number indication of their relative values. * @param {Date} First Date object to compare [Required]. * @param {Date} Second Date object to compare to [Required]. * @return {Number} -1 = date1 is lessthan date2. 0 = values are equal. 1 = date1 is greaterthan date2. */ $D.compare = function (date1, date2) { if (isNaN(date1) || isNaN(date2)) { throw new Error(date1 + " - " + date2); } else if (date1 instanceof Date && date2 instanceof Date) { return (date1 < date2) ? -1 : (date1 > date2) ? 1 : 0; } else { throw new TypeError(date1 + " - " + date2); } }; /** * Compares the first Date object to the second Date object and returns true if they are equal. * @param {Date} First Date object to compare [Required] * @param {Date} Second Date object to compare to [Required] * @return {Boolean} true if dates are equal. false if they are not equal. */ $D.equals = function (date1, date2) { return (date1.compareTo(date2) === 0); }; /** * Gets the language appropriate day name when given the day number(0-6) * eg - 0 == Sunday * @return {String} The day name */ $D.getDayName = function (n) { return Date.CultureInfo.dayNames[n]; }; /** * Gets the day number (0-6) if given a CultureInfo specific string which is a valid dayName, abbreviatedDayName or shortestDayName (two char). * @param {String} The name of the day (eg. "Monday, "Mon", "tuesday", "tue", "We", "we"). * @return {Number} The day number */ $D.getDayNumberFromName = function (name) { var n = Date.CultureInfo.dayNames, m = Date.CultureInfo.abbreviatedDayNames, o = Date.CultureInfo.shortestDayNames, s = name.toLowerCase(); for (var i = 0; i < n.length; i++) { if (n[i].toLowerCase() === s || m[i].toLowerCase() === s || o[i].toLowerCase() === s) { return i; } } return -1; }; /** * Gets the month number (0-11) if given a Culture Info specific string which is a valid monthName or abbreviatedMonthName. * @param {String} The name of the month (eg. "February, "Feb", "october", "oct"). * @return {Number} The day number */ $D.getMonthNumberFromName = function (name) { var n = Date.CultureInfo.monthNames, m = Date.CultureInfo.abbreviatedMonthNames, s = name.toLowerCase(); for (var i = 0; i < n.length; i++) { if (n[i].toLowerCase() === s || m[i].toLowerCase() === s) { return i; } } return -1; }; /** * Gets the language appropriate month name when given the month number(0-11) * eg - 0 == January * @return {String} The month name */ $D.getMonthName = function (n) { return Date.CultureInfo.monthNames[n]; }; /** * Determines if the current date instance is within a LeapYear. * @param {Number} The year. * @return {Boolean} true if date is within a LeapYear, otherwise false. */ $D.isLeapYear = function (year) { return ((year % 4 === 0 && year % 100 !== 0) || year % 400 === 0); }; /** * Gets the number of days in the month, given a year and month value. Automatically corrects for LeapYear. * @param {Number} The year. * @param {Number} The month (0-11). * @return {Number} The number of days in the month. */ $D.getDaysInMonth = function (year, month) { if (!month && $D.validateMonth(year)) { month = year; year = Date.today().getFullYear(); } return [31, ($D.isLeapYear(year) ? 29 : 28), 31, 30, 31, 30, 31, 31, 30, 31, 30, 31][month]; }; $P.getDaysInMonth = function () { return $D.getDaysInMonth(this.getFullYear(), this.getMonth()); }; $D.getTimezoneAbbreviation = function (offset, dst) { var p, n = (dst || false) ? Date.CultureInfo.abbreviatedTimeZoneDST : Date.CultureInfo.abbreviatedTimeZoneStandard; for (p in n) { if (n.hasOwnProperty(p)) { if (n[p] === offset) { return p; } } } return null; }; $D.getTimezoneOffset = function (name, dst) { var i, a =[], z = Date.CultureInfo.timezones; if (!name) { name = (new Date()).getTimezone();} for (i = 0; i < z.length; i++) { if (z[i].name === name.toUpperCase()) { a.push(i); } } if (!z[a[0]]) { return null; } if (a.length === 1 || !dst) { return z[a[0]].offset; } else { for (i=0; i < a.length; i++) { if (z[a[i]].dst) { return z[a[i]].offset; } } } }; $D.getQuarter = function (d) { d = d || new Date(); // If no date supplied, use today var q = [1,2,3,4]; return q[Math.floor(d.getMonth() / 3)]; // ~~~ is a bitwise op. Faster than Math.floor }; $D.getDaysLeftInQuarter = function (d) { d = d || new Date(); var qEnd = new Date(d); qEnd.setMonth(qEnd.getMonth() + 3 - qEnd.getMonth() % 3, 0); return Math.floor((qEnd - d) / 8.64e7); }; // private var validate = function (n, min, max, name) { name = name ? name : "Object"; if (typeof n === "undefined") { return false; } else if (typeof n !== "number") { throw new TypeError(n + " is not a Number."); } else if (n < min || n > max) { // As failing validation is *not* an exceptional circumstance // lets not throw a RangeError Exception here. // It's semantically correct but it's not sensible. return false; } return true; }; /** * Validates the number is within an acceptable range for milliseconds [0-999]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateMillisecond = function (value) { return validate(value, 0, 999, "millisecond"); }; /** * Validates the number is within an acceptable range for seconds [0-59]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateSecond = function (value) { return validate(value, 0, 59, "second"); }; /** * Validates the number is within an acceptable range for minutes [0-59]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateMinute = function (value) { return validate(value, 0, 59, "minute"); }; /** * Validates the number is within an acceptable range for hours [0-23]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateHour = function (value) { return validate(value, 0, 23, "hour"); }; /** * Validates the number is within an acceptable range for the days in a month [0-MaxDaysInMonth]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateDay = function (value, year, month) { if (year === undefined || year === null || month === undefined || month === null) { return false;} return validate(value, 1, $D.getDaysInMonth(year, month), "day"); }; /** * Validates the number is within an acceptable range for months [0-11]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateWeek = function (value) { return validate(value, 0, 53, "week"); }; /** * Validates the number is within an acceptable range for months [0-11]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateMonth = function (value) { return validate(value, 0, 11, "month"); }; /** * Validates the number is within an acceptable range for years. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateYear = function (value) { /** * Per ECMAScript spec the range of times supported by Date objects is * exactly -100,000,000 days to +100,000,000 days measured relative to * midnight at the beginning of 01 January, 1970 UTC. * This gives a range of 8,640,000,000,000,000 milliseconds to either * side of 01 January, 1970 UTC. * * Earliest possible date: Tue, 20 Apr 271,822 B.C. 00:00:00 UTC * Latest possible date: Sat, 13 Sep 275,760 00:00:00 UTC */ return validate(value, -271822, 275760, "year"); }; $D.validateTimezone = function(value) { var timezones = {"ACDT":1,"ACST":1,"ACT":1,"ADT":1,"AEDT":1,"AEST":1,"AFT":1,"AKDT":1,"AKST":1,"AMST":1,"AMT":1,"ART":1,"AST":1,"AWDT":1,"AWST":1,"AZOST":1,"AZT":1,"BDT":1,"BIOT":1,"BIT":1,"BOT":1,"BRT":1,"BST":1,"BTT":1,"CAT":1,"CCT":1,"CDT":1,"CEDT":1,"CEST":1,"CET":1,"CHADT":1,"CHAST":1,"CHOT":1,"ChST":1,"CHUT":1,"CIST":1,"CIT":1,"CKT":1,"CLST":1,"CLT":1,"COST":1,"COT":1,"CST":1,"CT":1,"CVT":1,"CWST":1,"CXT":1,"DAVT":1,"DDUT":1,"DFT":1,"EASST":1,"EAST":1,"EAT":1,"ECT":1,"EDT":1,"EEDT":1,"EEST":1,"EET":1,"EGST":1,"EGT":1,"EIT":1,"EST":1,"FET":1,"FJT":1,"FKST":1,"FKT":1,"FNT":1,"GALT":1,"GAMT":1,"GET":1,"GFT":1,"GILT":1,"GIT":1,"GMT":1,"GST":1,"GYT":1,"HADT":1,"HAEC":1,"HAST":1,"HKT":1,"HMT":1,"HOVT":1,"HST":1,"ICT":1,"IDT":1,"IOT":1,"IRDT":1,"IRKT":1,"IRST":1,"IST":1,"JST":1,"KGT":1,"KOST":1,"KRAT":1,"KST":1,"LHST":1,"LINT":1,"MAGT":1,"MART":1,"MAWT":1,"MDT":1,"MET":1,"MEST":1,"MHT":1,"MIST":1,"MIT":1,"MMT":1,"MSK":1,"MST":1,"MUT":1,"MVT":1,"MYT":1,"NCT":1,"NDT":1,"NFT":1,"NPT":1,"NST":1,"NT":1,"NUT":1,"NZDT":1,"NZST":1,"OMST":1,"ORAT":1,"PDT":1,"PET":1,"PETT":1,"PGT":1,"PHOT":1,"PHT":1,"PKT":1,"PMDT":1,"PMST":1,"PONT":1,"PST":1,"PYST":1,"PYT":1,"RET":1,"ROTT":1,"SAKT":1,"SAMT":1,"SAST":1,"SBT":1,"SCT":1,"SGT":1,"SLST":1,"SRT":1,"SST":1,"SYOT":1,"TAHT":1,"THA":1,"TFT":1,"TJT":1,"TKT":1,"TLT":1,"TMT":1,"TOT":1,"TVT":1,"UCT":1,"ULAT":1,"UTC":1,"UYST":1,"UYT":1,"UZT":1,"VET":1,"VLAT":1,"VOLT":1,"VOST":1,"VUT":1,"WAKT":1,"WAST":1,"WAT":1,"WEDT":1,"WEST":1,"WET":1,"WST":1,"YAKT":1,"YEKT":1,"Z":1}; return (timezones[value] === 1); }; $D.validateTimezoneOffset= function(value) { // timezones go from +14hrs to -12hrs, the +X hours are negative offsets. return (value > -841 && value < 721); }; }()); (function () { var $D = Date, $P = $D.prototype, p = function (s, l) { if (!l) { l = 2; } return ("000" + s).slice(l * -1); }; var validateConfigObject = function (obj) { var result = {}, self = this, prop, testFunc; testFunc = function (prop, func, value) { if (prop === "day") { var month = (obj.month !== undefined) ? obj.month : self.getMonth(); var year = (obj.year !== undefined) ? obj.year : self.getFullYear(); return $D[func](value, year, month); } else { return $D[func](value); } }; for (prop in obj) { if (Object.prototype.hasOwnProperty.call(obj, prop)) { var func = "validate" + prop.charAt(0).toUpperCase() + prop.slice(1); if ($D[func] && obj[prop] !== null && testFunc(prop, func, obj[prop])) { result[prop] = obj[prop]; } } } return result; }; /** * Resets the time of this Date object to 12:00 AM (00:00), which is the start of the day. * @param {Boolean} .clone() this date instance before clearing Time * @return {Date} this */ $P.clearTime = function () { this.setHours(0); this.setMinutes(0); this.setSeconds(0); this.setMilliseconds(0); return this; }; /** * Resets the time of this Date object to the current time ('now'). * @return {Date} this */ $P.setTimeToNow = function () { var n = new Date(); this.setHours(n.getHours()); this.setMinutes(n.getMinutes()); this.setSeconds(n.getSeconds()); this.setMilliseconds(n.getMilliseconds()); return this; }; /** * Returns a new Date object that is an exact date and time copy of the original instance. * @return {Date} A new Date instance */ $P.clone = function () { return new Date(this.getTime()); }; /** * Compares this instance to a Date object and returns an number indication of their relative values. * @param {Date} Date object to compare [Required] * @return {Number} -1 = this is lessthan date. 0 = values are equal. 1 = this is greaterthan date. */ $P.compareTo = function (date) { return Date.compare(this, date); }; /** * Compares this instance to another Date object and returns true if they are equal. * @param {Date} Date object to compare. If no date to compare, new Date() [now] is used. * @return {Boolean} true if dates are equal. false if they are not equal. */ $P.equals = function (date) { return Date.equals(this, (date !== undefined ? date : new Date())); }; /** * Determines if this instance is between a range of two dates or equal to either the start or end dates. * @param {Date} Start of range [Required] * @param {Date} End of range [Required] * @return {Boolean} true is this is between or equal to the start and end dates, else false */ $P.between = function (start, end) { return this.getTime() >= start.getTime() && this.getTime() <= end.getTime(); }; /** * Determines if this date occurs after the date to compare to. * @param {Date} Date object to compare. If no date to compare, new Date() ("now") is used. * @return {Boolean} true if this date instance is greater than the date to compare to (or "now"), otherwise false. */ $P.isAfter = function (date) { return this.compareTo(date || new Date()) === 1; }; /** * Determines if this date occurs before the date to compare to. * @param {Date} Date object to compare. If no date to compare, new Date() ("now") is used. * @return {Boolean} true if this date instance is less than the date to compare to (or "now"). */ $P.isBefore = function (date) { return (this.compareTo(date || new Date()) === -1); }; /** * Determines if the current Date instance occurs today. * @return {Boolean} true if this date instance is 'today', otherwise false. */ /** * Determines if the current Date instance occurs on the same Date as the supplied 'date'. * If no 'date' to compare to is provided, the current Date instance is compared to 'today'. * @param {date} Date object to compare. If no date to compare, the current Date ("now") is used. * @return {Boolean} true if this Date instance occurs on the same Day as the supplied 'date'. */ $P.isToday = $P.isSameDay = function (date) { return this.clone().clearTime().equals((date || new Date()).clone().clearTime()); }; /** * Adds the specified number of milliseconds to this instance. * @param {Number} The number of milliseconds to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addMilliseconds = function (value) { if (!value) { return this; } this.setTime(this.getTime() + value * 1); return this; }; /** * Adds the specified number of seconds to this instance. * @param {Number} The number of seconds to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addSeconds = function (value) { if (!value) { return this; } return this.addMilliseconds(value * 1000); }; /** * Adds the specified number of seconds to this instance. * @param {Number} The number of seconds to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addMinutes = function (value) { if (!value) { return this; } return this.addMilliseconds(value * 60000); // 60*1000 }; /** * Adds the specified number of hours to this instance. * @param {Number} The number of hours to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addHours = function (value) { if (!value) { return this; } return this.addMilliseconds(value * 3600000); // 60*60*1000 }; /** * Adds the specified number of days to this instance. * @param {Number} The number of days to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addDays = function (value) { if (!value) { return this; } this.setDate(this.getDate() + value * 1); return this; }; /** * Adds the specified number of weekdays (ie - not sat or sun) to this instance. * @param {Number} The number of days to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addWeekdays = function (value) { if (!value) { return this; } var day = this.getDay(); var weeks = (Math.ceil(Math.abs(value)/7)); if (day === 0 || day === 6) { if (value > 0) { this.next().monday(); this.addDays(-1); day = this.getDay(); } } if (value < 0) { while (value < 0) { this.addDays(-1); day = this.getDay(); if (day !== 0 && day !== 6) { value++; } } return this; } else if (value > 5 || (6-day) <= value) { value = value + (weeks * 2); } return this.addDays(value); }; /** * Adds the specified number of weeks to this instance. * @param {Number} The number of weeks to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addWeeks = function (value) { if (!value) { return this; } return this.addDays(value * 7); }; /** * Adds the specified number of months to this instance. * @param {Number} The number of months to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addMonths = function (value) { if (!value) { return this; } var n = this.getDate(); this.setDate(1); this.setMonth(this.getMonth() + value * 1); this.setDate(Math.min(n, $D.getDaysInMonth(this.getFullYear(), this.getMonth()))); return this; }; $P.addQuarters = function (value) { if (!value) { return this; } // note this will take you to the same point in the quarter as you are now. // i.e. - if you are 15 days into the quarter you'll be 15 days into the resulting one. // bonus: this allows adding fractional quarters return this.addMonths(value * 3); }; /** * Adds the specified number of years to this instance. * @param {Number} The number of years to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addYears = function (value) { if (!value) { return this; } return this.addMonths(value * 12); }; /** * Adds (or subtracts) to the value of the years, months, weeks, days, hours, minutes, seconds, milliseconds of the date instance using given configuration object. Positive and Negative values allowed. * Example

	Date.today().add( { days: 1, months: 1 } )

	new Date().add( { years: -1 } )
	
* @param {Object} Configuration object containing attributes (months, days, etc.) * @return {Date} this */ $P.add = function (config) { if (typeof config === "number") { this._orient = config; return this; } var x = config; if (x.day) { // If we should be a different date than today (eg: for 'tomorrow -1d', etc). // Should only effect parsing, not direct usage (eg, Finish and FinishExact) if ((x.day - this.getDate()) !== 0) { this.setDate(x.day); } } if (x.milliseconds) { this.addMilliseconds(x.milliseconds); } if (x.seconds) { this.addSeconds(x.seconds); } if (x.minutes) { this.addMinutes(x.minutes); } if (x.hours) { this.addHours(x.hours); } if (x.weeks) { this.addWeeks(x.weeks); } if (x.months) { this.addMonths(x.months); } if (x.years) { this.addYears(x.years); } if (x.days) { this.addDays(x.days); } return this; }; /** * Get the week number. Week one (1) is the week which contains the first Thursday of the year. Monday is considered the first day of the week. * The .getWeek() function does NOT convert the date to UTC. The local datetime is used. * Please use .getISOWeek() to get the week of the UTC converted date. * @return {Number} 1 to 53 */ $P.getWeek = function (utc) { // Create a copy of this date object var self, target = new Date(this.valueOf()); if (utc) { target.addMinutes(target.getTimezoneOffset()); self = target.clone(); } else { self = this; } // ISO week date weeks start on monday // so correct the day number var dayNr = (self.getDay() + 6) % 7; // ISO 8601 states that week 1 is the week // with the first thursday of that year. // Set the target date to the thursday in the target week target.setDate(target.getDate() - dayNr + 3); // Store the millisecond value of the target date var firstThursday = target.valueOf(); // Set the target to the first thursday of the year // First set the target to january first target.setMonth(0, 1); // Not a thursday? Correct the date to the next thursday if (target.getDay() !== 4) { target.setMonth(0, 1 + ((4 - target.getDay()) + 7) % 7); } // The weeknumber is the number of weeks between the // first thursday of the year and the thursday in the target week return 1 + Math.ceil((firstThursday - target) / 604800000); // 604800000 = 7 * 24 * 3600 * 1000 }; /** * Get the ISO 8601 week number. Week one ("01") is the week which contains the first Thursday of the year. Monday is considered the first day of the week. * The .getISOWeek() function does convert the date to it's UTC value. Please use .getWeek() to get the week of the local date. * @return {String} "01" to "53" */ $P.getISOWeek = function () { return p(this.getWeek(true)); }; /** * Moves the date to Monday of the week set. Week one (1) is the week which contains the first Thursday of the year. * @param {Number} A Number (1 to 53) that represents the week of the year. * @return {Date} this */ $P.setWeek = function (n) { if ((n - this.getWeek()) === 0) { if (this.getDay() !== 1) { return this.moveToDayOfWeek(1, (this.getDay() > 1 ? -1 : 1)); } else { return this; } } else { return this.moveToDayOfWeek(1, (this.getDay() > 1 ? -1 : 1)).addWeeks(n - this.getWeek()); } }; $P.setQuarter = function (qtr) { var month = Math.abs(((qtr-1) * 3) + 1); return this.setMonth(month, 1); }; $P.getQuarter = function () { return Date.getQuarter(this); }; $P.getDaysLeftInQuarter = function () { return Date.getDaysLeftInQuarter(this); }; /** * Moves the date to the next n'th occurrence of the dayOfWeek starting from the beginning of the month. The number (-1) is a magic number and will return the last occurrence of the dayOfWeek in the month. * @param {Number} The dayOfWeek to move to * @param {Number} The n'th occurrence to move to. Use (-1) to return the last occurrence in the month * @return {Date} this */ $P.moveToNthOccurrence = function (dayOfWeek, occurrence) { if (dayOfWeek === "Weekday") { if (occurrence > 0) { this.moveToFirstDayOfMonth(); if (this.is().weekday()) { occurrence -= 1; } } else if (occurrence < 0) { this.moveToLastDayOfMonth(); if (this.is().weekday()) { occurrence += 1; } } else { return this; } return this.addWeekdays(occurrence); } var shift = 0; if (occurrence > 0) { shift = occurrence - 1; } else if (occurrence === -1) { this.moveToLastDayOfMonth(); if (this.getDay() !== dayOfWeek) { this.moveToDayOfWeek(dayOfWeek, -1); } return this; } return this.moveToFirstDayOfMonth().addDays(-1).moveToDayOfWeek(dayOfWeek, +1).addWeeks(shift); }; var moveToN = function (getFunc, addFunc, nVal) { return function (value, orient) { var diff = (value - this[getFunc]() + nVal * (orient || +1)) % nVal; return this[addFunc]((diff === 0) ? diff += nVal * (orient || +1) : diff); }; }; /** * Move to the next or last dayOfWeek based on the orient value. * @param {Number} The dayOfWeek to move to * @param {Number} Forward (+1) or Back (-1). Defaults to +1. [Optional] * @return {Date} this */ $P.moveToDayOfWeek = moveToN("getDay", "addDays", 7); /** * Move to the next or last month based on the orient value. * @param {Number} The month to move to. 0 = January, 11 = December * @param {Number} Forward (+1) or Back (-1). Defaults to +1. [Optional] * @return {Date} this */ $P.moveToMonth = moveToN("getMonth", "addMonths", 12); /** * Get the Ordinate of the current day ("th", "st", "rd"). * @return {String} */ $P.getOrdinate = function () { var num = this.getDate(); return ord(num); }; /** * Get the Ordinal day (numeric day number) of the year, adjusted for leap year. * @return {Number} 1 through 365 (366 in leap years) */ $P.getOrdinalNumber = function () { return Math.ceil((this.clone().clearTime() - new Date(this.getFullYear(), 0, 1)) / 86400000) + 1; }; /** * Get the time zone abbreviation of the current date. * @return {String} The abbreviated time zone name (e.g. "EST") */ $P.getTimezone = function () { return $D.getTimezoneAbbreviation(this.getUTCOffset(), this.isDaylightSavingTime()); }; $P.setTimezoneOffset = function (offset) { var here = this.getTimezoneOffset(), there = Number(offset) * -6 / 10; return (there || there === 0) ? this.addMinutes(there - here) : this; }; $P.setTimezone = function (offset) { return this.setTimezoneOffset($D.getTimezoneOffset(offset)); }; /** * Indicates whether Daylight Saving Time is observed in the current time zone. * @return {Boolean} true|false */ $P.hasDaylightSavingTime = function () { return (Date.today().set({month: 0, day: 1}).getTimezoneOffset() !== Date.today().set({month: 6, day: 1}).getTimezoneOffset()); }; /** * Indicates whether this Date instance is within the Daylight Saving Time range for the current time zone. * @return {Boolean} true|false */ $P.isDaylightSavingTime = function () { return Date.today().set({month: 0, day: 1}).getTimezoneOffset() !== this.getTimezoneOffset(); }; /** * Get the offset from UTC of the current date. * @return {String} The 4-character offset string prefixed with + or - (e.g. "-0500") */ $P.getUTCOffset = function (offset) { var n = (offset || this.getTimezoneOffset()) * -10 / 6, r; if (n < 0) { r = (n - 10000).toString(); return r.charAt(0) + r.substr(2); } else { r = (n + 10000).toString(); return "+" + r.substr(1); } }; /** * Returns the number of milliseconds between this date and date. * @param {Date} Defaults to now * @return {Number} The diff in milliseconds */ $P.getElapsed = function (date) { return (date || new Date()) - this; }; /** * Set the value of year, month, day, hour, minute, second, millisecond of date instance using given configuration object. * Example

	Date.today().set( { day: 20, month: 1 } )

	new Date().set( { millisecond: 0 } )
	
* * @param {Object} Configuration object containing attributes (month, day, etc.) * @return {Date} this */ $P.set = function (config) { config = validateConfigObject.call(this, config); var key; for (key in config) { if (Object.prototype.hasOwnProperty.call(config, key)) { var name = key.charAt(0).toUpperCase() + key.slice(1); var addFunc, getFunc; if (key !== "week" && key !== "month" && key !== "timezone" && key !== "timezoneOffset") { name += "s"; } addFunc = "add" + name; getFunc = "get" + name; if (key === "month") { addFunc = addFunc + "s"; } else if (key === "year"){ getFunc = "getFullYear"; } if (key !== "day" && key !== "timezone" && key !== "timezoneOffset" && key !== "week" && key !== "hour") { this[addFunc](config[key] - this[getFunc]()); } else if ( key === "timezone"|| key === "timezoneOffset" || key === "week" || key === "hour") { this["set"+name](config[key]); } } } // day has to go last because you can't validate the day without first knowing the month if (config.day) { this.addDays(config.day - this.getDate()); } return this; }; /** * Moves the date to the first day of the month. * @return {Date} this */ $P.moveToFirstDayOfMonth = function () { return this.set({ day: 1 }); }; /** * Moves the date to the last day of the month. * @return {Date} this */ $P.moveToLastDayOfMonth = function () { return this.set({ day: $D.getDaysInMonth(this.getFullYear(), this.getMonth())}); }; /** * Converts the value of the current Date object to its equivalent string representation. * Format Specifiers * CUSTOM DATE AND TIME FORMAT STRINGS * Format Description Example * ------ --------------------------------------------------------------------------- ----------------------- * s The seconds of the minute between 0-59. "0" to "59" * ss The seconds of the minute with leading zero if required. "00" to "59" * * m The minute of the hour between 0-59. "0" or "59" * mm The minute of the hour with leading zero if required. "00" or "59" * * h The hour of the day between 1-12. "1" to "12" * hh The hour of the day with leading zero if required. "01" to "12" * * H The hour of the day between 0-23. "0" to "23" * HH The hour of the day with leading zero if required. "00" to "23" * * d The day of the month between 1 and 31. "1" to "31" * dd The day of the month with leading zero if required. "01" to "31" * ddd Abbreviated day name. Date.CultureInfo.abbreviatedDayNames. "Mon" to "Sun" * dddd The full day name. Date.CultureInfo.dayNames. "Monday" to "Sunday" * * M The month of the year between 1-12. "1" to "12" * MM The month of the year with leading zero if required. "01" to "12" * MMM Abbreviated month name. Date.CultureInfo.abbreviatedMonthNames. "Jan" to "Dec" * MMMM The full month name. Date.CultureInfo.monthNames. "January" to "December" * * yy The year as a two-digit number. "99" or "08" * yyyy The full four digit year. "1999" or "2008" * * t Displays the first character of the A.M./P.M. designator. "A" or "P" * Date.CultureInfo.amDesignator or Date.CultureInfo.pmDesignator * tt Displays the A.M./P.M. designator. "AM" or "PM" * Date.CultureInfo.amDesignator or Date.CultureInfo.pmDesignator * * S The ordinal suffix ("st, "nd", "rd" or "th") of the current day. "st, "nd", "rd" or "th" * * STANDARD DATE AND TIME FORMAT STRINGS * Format Description Example *------ --------------------------------------------------------------------------- ----------------------- * d The CultureInfo shortDate Format Pattern "M/d/yyyy" * D The CultureInfo longDate Format Pattern "dddd, MMMM dd, yyyy" * F The CultureInfo fullDateTime Format Pattern "dddd, MMMM dd, yyyy h:mm:ss tt" * m The CultureInfo monthDay Format Pattern "MMMM dd" * r The CultureInfo rfc1123 Format Pattern "ddd, dd MMM yyyy HH:mm:ss GMT" * s The CultureInfo sortableDateTime Format Pattern "yyyy-MM-ddTHH:mm:ss" * t The CultureInfo shortTime Format Pattern "h:mm tt" * T The CultureInfo longTime Format Pattern "h:mm:ss tt" * u The CultureInfo universalSortableDateTime Format Pattern "yyyy-MM-dd HH:mm:ssZ" * y The CultureInfo yearMonth Format Pattern "MMMM, yyyy" * * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @return {String} A string representation of the current Date object. */ var ord = function (n) { switch (n * 1) { case 1: case 21: case 31: return "st"; case 2: case 22: return "nd"; case 3: case 23: return "rd"; default: return "th"; } }; var parseStandardFormats = function (format) { var y, c = Date.CultureInfo.formatPatterns; switch (format) { case "d": return this.toString(c.shortDate); case "D": return this.toString(c.longDate); case "F": return this.toString(c.fullDateTime); case "m": return this.toString(c.monthDay); case "r": case "R": y = this.clone().addMinutes(this.getTimezoneOffset()); return y.toString(c.rfc1123) + " GMT"; case "s": return this.toString(c.sortableDateTime); case "t": return this.toString(c.shortTime); case "T": return this.toString(c.longTime); case "u": y = this.clone().addMinutes(this.getTimezoneOffset()); return y.toString(c.universalSortableDateTime); case "y": return this.toString(c.yearMonth); default: return false; } }; var parseFormatStringsClosure = function (context) { return function (m) { if (m.charAt(0) === "\\") { return m.replace("\\", ""); } switch (m) { case "hh": return p(context.getHours() < 13 ? (context.getHours() === 0 ? 12 : context.getHours()) : (context.getHours() - 12)); case "h": return context.getHours() < 13 ? (context.getHours() === 0 ? 12 : context.getHours()) : (context.getHours() - 12); case "HH": return p(context.getHours()); case "H": return context.getHours(); case "mm": return p(context.getMinutes()); case "m": return context.getMinutes(); case "ss": return p(context.getSeconds()); case "s": return context.getSeconds(); case "yyyy": return p(context.getFullYear(), 4); case "yy": return p(context.getFullYear()); case "y": return context.getFullYear(); case "E": case "dddd": return Date.CultureInfo.dayNames[context.getDay()]; case "ddd": return Date.CultureInfo.abbreviatedDayNames[context.getDay()]; case "dd": return p(context.getDate()); case "d": return context.getDate(); case "MMMM": return Date.CultureInfo.monthNames[context.getMonth()]; case "MMM": return Date.CultureInfo.abbreviatedMonthNames[context.getMonth()]; case "MM": return p((context.getMonth() + 1)); case "M": return context.getMonth() + 1; case "t": return context.getHours() < 12 ? Date.CultureInfo.amDesignator.substring(0, 1) : Date.CultureInfo.pmDesignator.substring(0, 1); case "tt": return context.getHours() < 12 ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator; case "S": return ord(context.getDate()); case "W": return context.getWeek(); case "WW": return context.getISOWeek(); case "Q": return "Q" + context.getQuarter(); case "q": return String(context.getQuarter()); case "z": return context.getTimezone(); case "Z": case "X": return Date.getTimezoneOffset(context.getTimezone()); case "ZZ": // Timezone offset in seconds return context.getTimezoneOffset() * -60; case "u": return context.getDay(); case "L": return ($D.isLeapYear(context.getFullYear())) ? 1 : 0; case "B": // Swatch Internet Time (.beats) return "@"+((context.getUTCSeconds() + (context.getUTCMinutes()*60) + ((context.getUTCHours()+1)*3600))/86.4); default: return m; } }; }; $P.toString = function (format, ignoreStandards) { // Standard Date and Time Format Strings. Formats pulled from CultureInfo file and // may vary by culture. if (!ignoreStandards && format && format.length === 1) { output = parseStandardFormats.call(this, format); if (output) { return output; } } var parseFormatStrings = parseFormatStringsClosure(this); return format ? format.replace(/((\\)?(dd?d?d?|MM?M?M?|yy?y?y?|hh?|HH?|mm?|ss?|tt?|S|q|Q|WW?W?W?)(?![^\[]*\]))/g, parseFormatStrings).replace(/\[|\]/g, "") : this._toString(); }; }()); /************************************************************* * SugarPak - Domain Specific Language - Syntactical Sugar * *************************************************************/ (function () { var $D = Date, $P = $D.prototype, $N = Number.prototype; // private $P._orient = +1; // private $P._nth = null; // private $P._is = false; // private $P._same = false; // private $P._isSecond = false; // private $N._dateElement = "days"; /** * Moves the date to the next instance of a date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.today().next().friday();
	Date.today().next().fri();
	Date.today().next().march();
	Date.today().next().mar();
	Date.today().next().week();
	
* * @return {Date} date */ $P.next = function () { this._move = true; this._orient = +1; return this; }; /** * Creates a new Date (Date.today()) and moves the date to the next instance of the date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.next().friday();
	Date.next().fri();
	Date.next().march();
	Date.next().mar();
	Date.next().week();
	
* * @return {Date} date */ $D.next = function () { return $D.today().next(); }; /** * Moves the date to the previous instance of a date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.today().last().friday();
	Date.today().last().fri();
	Date.today().last().march();
	Date.today().last().mar();
	Date.today().last().week();
	
* * @return {Date} date */ $P.last = $P.prev = $P.previous = function () { this._move = true; this._orient = -1; return this; }; /** * Creates a new Date (Date.today()) and moves the date to the previous instance of the date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.last().friday();
	Date.last().fri();
	Date.previous().march();
	Date.prev().mar();
	Date.last().week();
	
* * @return {Date} date */ $D.last = $D.prev = $D.previous = function () { return $D.today().last(); }; /** * Performs a equality check when followed by either a month name, day name or .weekday() function. * Example

	Date.today().is().friday(); // true|false
	Date.today().is().fri();
	Date.today().is().march();
	Date.today().is().mar();
	
* * @return {Boolean} true|false */ $P.is = function () { this._is = true; return this; }; /** * Determines if two date objects occur on/in exactly the same instance of the subsequent date part function. * The function .same() must be followed by a date part function (example: .day(), .month(), .year(), etc). * * An optional Date can be passed in the date part function. If now date is passed as a parameter, 'Now' is used. * * The following example demonstrates how to determine if two dates fall on the exact same day. * * Example

	var d1 = Date.today(); // today at 00:00
	var d2 = new Date();   // exactly now.

	// Do they occur on the same day?
	d1.same().day(d2); // true
	
	// Do they occur on the same hour?
	d1.same().hour(d2); // false, unless d2 hour is '00' (midnight).
	
	// What if it's the same day, but one year apart?
	var nextYear = Date.today().add(1).year();

	d1.same().day(nextYear); // false, because the dates must occur on the exact same day. 
	
* * Scenario: Determine if a given date occurs during some week period 2 months from now. * * Example

	var future = Date.today().add(2).months();
	return someDate.same().week(future); // true|false;
	
* * @return {Boolean} true|false */ $P.same = function () { this._same = true; this._isSecond = false; return this; }; /** * Determines if the current date/time occurs during Today. Must be preceded by the .is() function. * Example

	someDate.is().today();    // true|false
	new Date().is().today();  // true
	Date.today().is().today();// true
	Date.today().add(-1).day().is().today(); // false
	
* * @return {Boolean} true|false */ $P.today = function () { return this.same().day(); }; /** * Determines if the current date is a weekday. This function must be preceded by the .is() function. * Example

	Date.today().is().weekday(); // true|false
	
* * @return {Boolean} true|false */ $P.weekday = function () { if (this._nth) { return df("Weekday").call(this); } if (this._move) { return this.addWeekdays(this._orient); } if (this._is) { this._is = false; return (!this.is().sat() && !this.is().sun()); } return false; }; /** * Determines if the current date is on the weekend. This function must be preceded by the .is() function. * Example

	Date.today().is().weekend(); // true|false
	
* * @return {Boolean} true|false */ $P.weekend = function () { if (this._is) { this._is = false; return (this.is().sat() || this.is().sun()); } return false; }; /** * Sets the Time of the current Date instance. A string "6:15 pm" or config object {hour:18, minute:15} are accepted. * Example

	// Set time to 6:15pm with a String
	Date.today().at("6:15pm");

	// Set time to 6:15pm with a config object
	Date.today().at({hour:18, minute:15});
	
* * @return {Date} date */ $P.at = function (time) { return (typeof time === "string") ? $D.parse(this.toString("d") + " " + time) : this.set(time); }; /** * Creates a new Date() and adds this (Number) to the date based on the preceding date element function (eg. second|minute|hour|day|month|year). * Example

	// Undeclared Numbers must be wrapped with parentheses. Requirment of JavaScript.
	(3).days().fromNow();
	(6).months().fromNow();

	// Declared Number variables do not require parentheses. 
	var n = 6;
	n.months().fromNow();
	
* * @return {Date} A new Date instance */ $N.fromNow = $N.after = function (date) { var c = {}; c[this._dateElement] = this; return ((!date) ? new Date() : date.clone()).add(c); }; /** * Creates a new Date() and subtract this (Number) from the date based on the preceding date element function (eg. second|minute|hour|day|month|year). * Example

	// Undeclared Numbers must be wrapped with parentheses. Requirment of JavaScript.
	(3).days().ago();
	(6).months().ago();

	// Declared Number variables do not require parentheses. 
	var n = 6;
	n.months().ago();
	
* * @return {Date} A new Date instance */ $N.ago = $N.before = function (date) { var c = {}, s = (this._dateElement[this._dateElement.length-1] !== "s") ? this._dateElement + "s" : this._dateElement; c[s] = this * -1; return ((!date) ? new Date() : date.clone()).add(c); }; // Do NOT modify the following string tokens. These tokens are used to build dynamic functions. // All culture-specific strings can be found in the CultureInfo files. var dx = ("sunday monday tuesday wednesday thursday friday saturday").split(/\s/), mx = ("january february march april may june july august september october november december").split(/\s/), px = ("Millisecond Second Minute Hour Day Week Month Year Quarter Weekday").split(/\s/), pxf = ("Milliseconds Seconds Minutes Hours Date Week Month FullYear Quarter").split(/\s/), nth = ("final first second third fourth fifth").split(/\s/), de; /** * Returns an object literal of all the date parts. * Example

	var o = new Date().toObject();
	
	// { year: 2008, month: 4, week: 20, day: 13, hour: 18, minute: 9, second: 32, millisecond: 812 }
	
	// The object properties can be referenced directly from the object.
	
	alert(o.day);  // alerts "13"
	alert(o.year); // alerts "2008"
	
* * @return {Date} An object literal representing the original date object. */ $P.toObject = function () { var o = {}; for (var i = 0; i < px.length; i++) { if (this["get" + pxf[i]]) { o[px[i].toLowerCase()] = this["get" + pxf[i]](); } } return o; }; /** * Returns a date created from an object literal. Ignores the .week property if set in the config. * Example

	var o = new Date().toObject();
	
	return Date.fromObject(o); // will return the same date. 

	var o2 = {month: 1, day: 20, hour: 18}; // birthday party!
	Date.fromObject(o2);
	
* * @return {Date} An object literal representing the original date object. */ $D.fromObject = function(config) { config.week = null; return Date.today().set(config); }; // Create day name functions and abbreviated day name functions (eg. monday(), friday(), fri()). var df = function (n) { return function () { if (this._is) { this._is = false; return this.getDay() === n; } if (this._move) { this._move = null; } if (this._nth !== null) { // If the .second() function was called earlier, remove the _orient // from the date, and then continue. // This is required because 'second' can be used in two different context. // // Example // // Date.today().add(1).second(); // Date.march().second().monday(); // // Things get crazy with the following... // Date.march().add(1).second().second().monday(); // but it works!! // if (this._isSecond) { this.addSeconds(this._orient * -1); } // make sure we reset _isSecond this._isSecond = false; var ntemp = this._nth; this._nth = null; var temp = this.clone().moveToLastDayOfMonth(); this.moveToNthOccurrence(n, ntemp); if (this > temp) { throw new RangeError($D.getDayName(n) + " does not occur " + ntemp + " times in the month of " + $D.getMonthName(temp.getMonth()) + " " + temp.getFullYear() + "."); } return this; } return this.moveToDayOfWeek(n, this._orient); }; }; var sdf = function (n) { return function () { var t = $D.today(), shift = n - t.getDay(); if (n === 0 && Date.CultureInfo.firstDayOfWeek === 1 && t.getDay() !== 0) { shift = shift + 7; } return t.addDays(shift); }; }; // Create month name functions and abbreviated month name functions (eg. january(), march(), mar()). var month_instance_functions = function (n) { return function () { if (this._is) { this._is = false; return this.getMonth() === n; } return this.moveToMonth(n, this._orient); }; }; var month_static_functions = function (n) { return function () { return $D.today().set({ month: n, day: 1 }); }; }; var processTerms = function (names, staticFunc, instanceFunc) { for (var i = 0; i < names.length; i++) { // Create constant static Name variables. $D[names[i].toUpperCase()] = $D[names[i].toUpperCase().substring(0, 3)] = i; // Create Name functions. $D[names[i]] = $D[names[i].substring(0, 3)] = staticFunc(i); // Create Name instance functions. $P[names[i]] = $P[names[i].substring(0, 3)] = instanceFunc(i); } }; processTerms(dx, sdf, df); processTerms(mx, month_static_functions, month_instance_functions); // Create date element functions and plural date element functions used with Date (eg. day(), days(), months()). var ef = function (j) { return function () { // if the .second() function was called earlier, the _orient // has alread been added. Just return this and reset _isSecond. if (this._isSecond) { this._isSecond = false; return this; } if (this._same) { this._same = this._is = false; var o1 = this.toObject(), o2 = (arguments[0] || new Date()).toObject(), v = "", k = j.toLowerCase(); // the substr trick with -1 doesn't work in IE8 or less k = (k[k.length-1] === "s") ? k.substring(0,k.length-1) : k; for (var m = (px.length - 1); m > -1; m--) { v = px[m].toLowerCase(); if (o1[v] !== o2[v]) { return false; } if (k === v) { break; } } return true; } if (j.substring(j.length - 1) !== "s") { j += "s"; } if (this._move) { this._move = null; } return this["add" + j](this._orient); }; }; var nf = function (n) { return function () { this._dateElement = n; return this; }; }; for (var k = 0; k < px.length; k++) { de = px[k].toLowerCase(); if(de !== "weekday") { // Create date element functions and plural date element functions used with Date (eg. day(), days(), months()). $P[de] = $P[de + "s"] = ef(px[k]); // Create date element functions and plural date element functions used with Number (eg. day(), days(), months()). $N[de] = $N[de + "s"] = nf(de + "s"); } } $P._ss = ef("Second"); var nthfn = function (n) { return function (dayOfWeek) { if (this._same) { return this._ss(arguments[0]); } if (dayOfWeek || dayOfWeek === 0) { return this.moveToNthOccurrence(dayOfWeek, n); } this._nth = n; // if the operator is 'second' add the _orient, then deal with it later... if (n === 2 && (dayOfWeek === undefined || dayOfWeek === null)) { this._isSecond = true; return this.addSeconds(this._orient); } return this; }; }; for (var l = 0; l < nth.length; l++) { $P[nth[l]] = (l === 0) ? nthfn(-1) : nthfn(l); } }()); (function () { "use strict"; Date.Parsing = { Exception: function (s) { this.message = "Parse error at '" + s.substring(0, 10) + " ...'"; } }; var $P = Date.Parsing; var dayOffsets = { standard: [0,31,59,90,120,151,181,212,243,273,304,334], leap: [0,31,60,91,121,152,182,213,244,274,305,335] }; $P.isLeapYear = function(year) { return ((year % 4 === 0) && (year % 100 !== 0)) || (year % 400 === 0); }; var utils = { multiReplace : function (str, hash ) { var key; for (key in hash) { if (Object.prototype.hasOwnProperty.call(hash, key)) { var regex; if (typeof hash[key] === "function") { } else { regex = (hash[key] instanceof RegExp) ? hash[key] : new RegExp(hash[key], "g"); } str = str.replace(regex, key); } } return str; }, getDayOfYearFromWeek : function (obj) { var d, jan4, offset; obj.weekDay = (!obj.weekDay && obj.weekDay !== 0) ? 1 : obj.weekDay; d = new Date(obj.year, 0, 4); jan4 = d.getDay() === 0 ? 7 : d.getDay(); // JS is 0 indexed on Sunday. offset = jan4+3; obj.dayOfYear = ((obj.week * 7) + (obj.weekDay === 0 ? 7 : obj.weekDay))-offset; return obj; }, getDayOfYear : function (obj, dayOffset) { if (!obj.dayOfYear) { obj = utils.getDayOfYearFromWeek(obj); } for (var i=0;i <= dayOffset.length;i++) { if (obj.dayOfYear < dayOffset[i] || i === dayOffset.length) { obj.day = obj.day ? obj.day : (obj.dayOfYear - dayOffset[i-1]); break; } else { obj.month = i; } } return obj; }, adjustForTimeZone : function (obj, date) { var offset; if (obj.zone.toUpperCase() === "Z" || (obj.zone_hours === 0 && obj.zone_minutes === 0)) { // it's UTC/GML so work out the current timeszone offset offset = -date.getTimezoneOffset(); } else { offset = (obj.zone_hours*60) + (obj.zone_minutes || 0); if (obj.zone_sign === "+") { offset *= -1; } offset -= date.getTimezoneOffset(); } date.setMinutes(date.getMinutes()+offset); return date; }, setDefaults : function (obj) { obj.year = obj.year || Date.today().getFullYear(); obj.hours = obj.hours || 0; obj.minutes = obj.minutes || 0; obj.seconds = obj.seconds || 0; obj.milliseconds = obj.milliseconds || 0; if (!(!obj.month && (obj.week || obj.dayOfYear))) { // if we have a month, or if we don't but don't have the day calculation data obj.month = obj.month || 0; obj.day = obj.day || 1; } return obj; }, dataNum: function (data, mod, explict, postProcess) { var dataNum = data*1; if (mod) { if (postProcess) { return data ? mod(data)*1 : data; } else { return data ? mod(dataNum) : data; } } else if (!explict){ return data ? dataNum : data; } else { return (data && typeof data !== "undefined") ? dataNum : data; } }, timeDataProcess: function (obj) { var timeObj = {}; for (var x in obj.data) { if (obj.data.hasOwnProperty(x)) { timeObj[x] = obj.ignore[x] ? obj.data[x] : utils.dataNum(obj.data[x], obj.mods[x], obj.explict[x], obj.postProcess[x]); } } if (obj.data.secmins) { obj.data.secmins = obj.data.secmins.replace(",", ".") * 60; if (!timeObj.minutes) { timeObj.minutes = obj.data.secmins; } else if (!timeObj.seconds) { timeObj.seconds = obj.data.secmins; } delete obj.secmins; } return timeObj; }, buildTimeObjectFromData: function (data) { var time = utils.timeDataProcess({ data: { year : data[1], month : data[5], day : data[7], week : data[8], dayOfYear : data[10], hours : data[15], zone_hours : data[23], zone_minutes : data[24], zone : data[21], zone_sign : data[22], weekDay : data[9], minutes: data[16], seconds: data[19], milliseconds: data[20], secmins: data[18] }, mods: { month: function(data) { return data-1; }, weekDay: function (data) { data = Math.abs(data); return (data === 7 ? 0 : data); }, minutes: function (data) { return data.replace(":",""); }, seconds: function (data) { return Math.floor( (data.replace(":","").replace(",","."))*1 ); }, milliseconds: function (data) { return (data.replace(",",".")*1000); } }, postProcess: { minutes: true, seconds: true, milliseconds: true }, explict: { zone_hours: true, zone_minutes: true }, ignore: { zone: true, zone_sign: true, secmins: true } }); return time; }, addToHash: function (hash, keys, data) { keys = keys; data = data; var len = keys.length; for (var i = 0; i < len; i++) { hash[keys[i]] = data[i]; } return hash; }, combineRegex: function (r1, r2) { return new RegExp("(("+r1.source+")\\s("+r2.source+"))"); }, getDateNthString: function(add, last, inc){ if (add) { return Date.today().addDays(inc).toString("d"); } else if (last) { return Date.today().last()[inc]().toString("d"); } }, buildRegexData: function (array) { var arr = []; var len = array.length; for (var i=0; i < len; i++) { if (Object.prototype.toString.call(array[i]) === '[object Array]') { // oldIE compat version of Array.isArray arr.push(this.combineRegex(array[i][0], array[i][1])); } else { arr.push(array[i]); } } return arr; } }; $P.processTimeObject = function (obj) { var date, dayOffset; utils.setDefaults(obj); dayOffset = ($P.isLeapYear(obj.year)) ? dayOffsets.leap : dayOffsets.standard; if (!obj.month && (obj.week || obj.dayOfYear)) { utils.getDayOfYear(obj, dayOffset); } else { obj.dayOfYear = dayOffset[obj.month] + obj.day; } date = new Date(obj.year, obj.month, obj.day, obj.hours, obj.minutes, obj.seconds, obj.milliseconds); if (obj.zone) { utils.adjustForTimeZone(obj, date); // adjust (and calculate) for timezone } return date; }; $P.ISO = { regex : /^([\+-]?\d{4}(?!\d{2}\b))((-?)((0[1-9]|1[0-2])(\3([12]\d|0[1-9]|3[01]))?|W([0-4]\d|5[0-3])(-?[1-7])?|(00[1-9]|0[1-9]\d|[12]\d{2}|3([0-5]\d|6[1-6])))([T\s]((([01]\d|2[0-4])((:?)[0-5]\d)?|24\:?00)([\.,]\d+(?!:))?)?(\17[0-5]\d([\.,]\d+)?)?\s?([zZ]|([\+-])([01]\d|2[0-3]):?([0-5]\d)?)?)?)?$/, parse : function (s) { var time, data = s.match(this.regex); if (!data || !data.length) { return null; } time = utils.buildTimeObjectFromData(data); if (!time.year || (!time.year && (!time.month && !time.day) && (!time.week && !time.dayOfYear)) ) { return null; } return $P.processTimeObject(time); } }; $P.Numeric = { isNumeric: function (e){return!isNaN(parseFloat(e))&&isFinite(e);}, regex: /\b([0-1]?[0-9])([0-3]?[0-9])([0-2]?[0-9]?[0-9][0-9])\b/i, parse: function (s) { var data, i, time = {}, order = Date.CultureInfo.dateElementOrder.split(""); if (!(this.isNumeric(s)) || // if it's non-numeric OR (s[0] === "+" && s[0] === "-")) { // It's an arithmatic string (eg +/-1000) return null; } if (s.length < 5 && s.indexOf(".") < 0 && s.indexOf("/") < 0) { // assume it's just a year. time.year = s; return $P.processTimeObject(time); } data = s.match(this.regex); if (!data || !data.length) { return null; } for (i=0; i < order.length; i++) { switch(order[i]) { case "d": time.day = data[i+1]; break; case "m": time.month = (data[i+1]-1); break; case "y": time.year = data[i+1]; break; } } return $P.processTimeObject(time); } }; $P.Normalizer = { regexData: function () { var $R = Date.CultureInfo.regexPatterns; return utils.buildRegexData([ $R.tomorrow, $R.yesterday, [$R.past, $R.mon], [$R.past, $R.tue], [$R.past, $R.wed], [$R.past, $R.thu], [$R.past, $R.fri], [$R.past, $R.sat], [$R.past, $R.sun] ]); }, basicReplaceHash : function() { var $R = Date.CultureInfo.regexPatterns; return { "January": $R.jan.source, "February": $R.feb, "March": $R.mar, "April": $R.apr, "May": $R.may, "June": $R.jun, "July": $R.jul, "August": $R.aug, "September": $R.sep, "October": $R.oct, "November": $R.nov, "December": $R.dec, "": /\bat\b/gi, " ": /\s{2,}/, "am": $R.inTheMorning, "9am": $R.thisMorning, "pm": $R.inTheEvening, "7pm":$R.thisEvening }; }, keys : function(){ return [ utils.getDateNthString(true, false, 1), // tomorrow utils.getDateNthString(true, false, -1), // yesterday utils.getDateNthString(false, true, "monday"), //last mon utils.getDateNthString(false, true, "tuesday"), //last tues utils.getDateNthString(false, true, "wednesday"), //last wed utils.getDateNthString(false, true, "thursday"), //last thurs utils.getDateNthString(false, true, "friday"), //last fri utils.getDateNthString(false, true, "saturday"), //last sat utils.getDateNthString(false, true, "sunday") //last sun ]; }, buildRegexFunctions: function () { var $R = Date.CultureInfo.regexPatterns; var __ = Date.i18n.__; var tomorrowRE = new RegExp("(\\b\\d\\d?("+__("AM")+"|"+__("PM")+")? )("+$R.tomorrow.source.slice(1)+")", "i"); // adapted tomorrow regex for AM PM relative dates var todayRE = new RegExp($R.today.source + "(?!\\s*([+-]))\\b"); // today, but excludes the math operators (eg "today + 2h") this.replaceFuncs = [ [todayRE, function (full) { return (full.length > 1) ? Date.today().toString("d") : full; }], [tomorrowRE, function(full, m1) { var t = Date.today().addDays(1).toString("d"); return (t + " " + m1); }], [$R.amThisMorning, function(str, am){return am;}], [$R.pmThisEvening, function(str, pm){return pm;}] ]; }, buildReplaceData: function () { this.buildRegexFunctions(); this.replaceHash = utils.addToHash(this.basicReplaceHash(), this.keys(), this.regexData()); }, stringReplaceFuncs: function (s) { for (var i=0; i < this.replaceFuncs.length; i++) { s = s.replace(this.replaceFuncs[i][0], this.replaceFuncs[i][1]); } return s; }, parse: function (s) { s = this.stringReplaceFuncs(s); s = utils.multiReplace(s, this.replaceHash); try { var n = s.split(/([\s\-\.\,\/\x27]+)/); if (n.length === 3 && $P.Numeric.isNumeric(n[0]) && $P.Numeric.isNumeric(n[2]) && (n[2].length >= 4)) { // ok, so we're dealing with x/year. But that's not a full date. // This fixes wonky dateElementOrder parsing when set to dmy order. if (Date.CultureInfo.dateElementOrder[0] === "d") { s = "1/" + n[0] + "/" + n[2]; // set to 1st of month and normalize the seperator } } } catch (e) {} return s; } }; $P.Normalizer.buildReplaceData(); }()); (function () { var $P = Date.Parsing; var _ = $P.Operators = { // // Tokenizers // rtoken: function (r) { // regex token return function (s) { var mx = s.match(r); if (mx) { return ([ mx[0], s.substring(mx[0].length) ]); } else { throw new $P.Exception(s); } }; }, token: function () { // whitespace-eating token return function (s) { return _.rtoken(new RegExp("^\\s*" + s + "\\s*"))(s); }; }, stoken: function (s) { // string token return _.rtoken(new RegExp("^" + s)); }, // Atomic Operators until: function (p) { return function (s) { var qx = [], rx = null; while (s.length) { try { rx = p.call(this, s); } catch (e) { qx.push(rx[0]); s = rx[1]; continue; } break; } return [ qx, s ]; }; }, many: function (p) { return function (s) { var rx = [], r = null; while (s.length) { try { r = p.call(this, s); } catch (e) { return [ rx, s ]; } rx.push(r[0]); s = r[1]; } return [ rx, s ]; }; }, // generator operators -- see below optional: function (p) { return function (s) { var r = null; try { r = p.call(this, s); } catch (e) { return [ null, s ]; } return [ r[0], r[1] ]; }; }, not: function (p) { return function (s) { try { p.call(this, s); } catch (e) { return [null, s]; } throw new $P.Exception(s); }; }, ignore: function (p) { return p ? function (s) { var r = null; r = p.call(this, s); return [null, r[1]]; } : null; }, product: function () { var px = arguments[0], qx = Array.prototype.slice.call(arguments, 1), rx = []; for (var i = 0 ; i < px.length ; i++) { rx.push(_.each(px[i], qx)); } return rx; }, cache: function (rule) { var cache = {}, cache_length = 0, cache_keys = [], CACHE_MAX = Date.Config.CACHE_MAX || 100000, r = null; var cacheCheck = function () { if (cache_length === CACHE_MAX) { // kill several keys, don't want to have to do this all the time... for (var i=0; i < 10; i++) { var key = cache_keys.shift(); if (key) { delete cache[key]; cache_length--; } } } }; return function (s) { cacheCheck(); try { r = cache[s] = (cache[s] || rule.call(this, s)); } catch (e) { r = cache[s] = e; } cache_length++; cache_keys.push(s); if (r instanceof $P.Exception) { throw r; } else { return r; } }; }, // vector operators -- see below any: function () { var px = arguments; return function (s) { var r = null; for (var i = 0; i < px.length; i++) { if (px[i] == null) { continue; } try { r = (px[i].call(this, s)); } catch (e) { r = null; } if (r) { return r; } } throw new $P.Exception(s); }; }, each: function () { var px = arguments; return function (s) { var rx = [], r = null; for (var i = 0; i < px.length ; i++) { if (px[i] == null) { continue; } try { r = (px[i].call(this, s)); } catch (e) { throw new $P.Exception(s); } rx.push(r[0]); s = r[1]; } return [ rx, s]; }; }, all: function () { var px = arguments, _ = _; return _.each(_.optional(px)); }, // delimited operators sequence: function (px, d, c) { d = d || _.rtoken(/^\s*/); c = c || null; if (px.length === 1) { return px[0]; } return function (s) { var r = null, q = null; var rx = []; for (var i = 0; i < px.length ; i++) { try { r = px[i].call(this, s); } catch (e) { break; } rx.push(r[0]); try { q = d.call(this, r[1]); } catch (ex) { q = null; break; } s = q[1]; } if (!r) { throw new $P.Exception(s); } if (q) { throw new $P.Exception(q[1]); } if (c) { try { r = c.call(this, r[1]); } catch (ey) { throw new $P.Exception(r[1]); } } return [ rx, (r?r[1]:s) ]; }; }, // // Composite Operators // between: function (d1, p, d2) { d2 = d2 || d1; var _fn = _.each(_.ignore(d1), p, _.ignore(d2)); return function (s) { var rx = _fn.call(this, s); return [[rx[0][0], r[0][2]], rx[1]]; }; }, list: function (p, d, c) { d = d || _.rtoken(/^\s*/); c = c || null; return (p instanceof Array ? _.each(_.product(p.slice(0, -1), _.ignore(d)), p.slice(-1), _.ignore(c)) : _.each(_.many(_.each(p, _.ignore(d))), px, _.ignore(c))); }, set: function (px, d, c) { d = d || _.rtoken(/^\s*/); c = c || null; return function (s) { // r is the current match, best the current 'best' match // which means it parsed the most amount of input var r = null, p = null, q = null, rx = null, best = [[], s], last = false; // go through the rules in the given set for (var i = 0; i < px.length ; i++) { // last is a flag indicating whether this must be the last element // if there is only 1 element, then it MUST be the last one q = null; p = null; r = null; last = (px.length === 1); // first, we try simply to match the current pattern // if not, try the next pattern try { r = px[i].call(this, s); } catch (e) { continue; } // since we are matching against a set of elements, the first // thing to do is to add r[0] to matched elements rx = [[r[0]], r[1]]; // if we matched and there is still input to parse and // we don't already know this is the last element, // we're going to next check for the delimiter ... // if there's none, or if there's no input left to parse // than this must be the last element after all ... if (r[1].length > 0 && ! last) { try { q = d.call(this, r[1]); } catch (ex) { last = true; } } else { last = true; } // if we parsed the delimiter and now there's no more input, // that means we shouldn't have parsed the delimiter at all // so don't update r and mark this as the last element ... if (!last && q[1].length === 0) { last = true; } // so, if this isn't the last element, we're going to see if // we can get any more matches from the remaining (unmatched) // elements ... if (!last) { // build a list of the remaining rules we can match against, // i.e., all but the one we just matched against var qx = []; for (var j = 0; j < px.length ; j++) { if (i !== j) { qx.push(px[j]); } } // now invoke recursively set with the remaining input // note that we don't include the closing delimiter ... // we'll check for that ourselves at the end p = _.set(qx, d).call(this, q[1]); // if we got a non-empty set as a result ... // (otw rx already contains everything we want to match) if (p[0].length > 0) { // update current result, which is stored in rx ... // basically, pick up the remaining text from p[1] // and concat the result from p[0] so that we don't // get endless nesting ... rx[0] = rx[0].concat(p[0]); rx[1] = p[1]; } } // at this point, rx either contains the last matched element // or the entire matched set that starts with this element. // now we just check to see if this variation is better than // our best so far, in terms of how much of the input is parsed if (rx[1].length < best[1].length) { best = rx; } // if we've parsed all the input, then we're finished if (best[1].length === 0) { break; } } // so now we've either gone through all the patterns trying them // as the initial match; or we found one that parsed the entire // input string ... // if best has no matches, just return empty set ... if (best[0].length === 0) { return best; } // if a closing delimiter is provided, then we have to check it also if (c) { // we try this even if there is no remaining input because the pattern // may well be optional or match empty input ... try { q = c.call(this, best[1]); } catch (ey) { throw new $P.Exception(best[1]); } // it parsed ... be sure to update the best match remaining input best[1] = q[1]; } // if we're here, either there was no closing delimiter or we parsed it // so now we have the best match; just return it! return best; }; }, forward: function (gr, fname) { return function (s) { return gr[fname].call(this, s); }; }, // // Translation Operators // replace: function (rule, repl) { return function (s) { var r = rule.call(this, s); return [repl, r[1]]; }; }, process: function (rule, fn) { return function (s) { var r = rule.call(this, s); return [fn.call(this, r[0]), r[1]]; }; }, min: function (min, rule) { return function (s) { var rx = rule.call(this, s); if (rx[0].length < min) { throw new $P.Exception(s); } return rx; }; } }; // Generator Operators And Vector Operators // Generators are operators that have a signature of F(R) => R, // taking a given rule and returning another rule, such as // ignore, which parses a given rule and throws away the result. // Vector operators are those that have a signature of F(R1,R2,...) => R, // take a list of rules and returning a new rule, such as each. // Generator operators are converted (via the following _generator // function) into functions that can also take a list or array of rules // and return an array of new rules as though the function had been // called on each rule in turn (which is what actually happens). // This allows generators to be used with vector operators more easily. // Example: // each(ignore(foo, bar)) instead of each(ignore(foo), ignore(bar)) // This also turns generators into vector operators, which allows // constructs like: // not(cache(foo, bar)) var _generator = function (op) { function gen() { var args = null, rx = [], px, i; if (arguments.length > 1) { args = Array.prototype.slice.call(arguments); } else if (arguments[0] instanceof Array) { args = arguments[0]; } if (args) { px = args.shift(); if (px.length > 0) { args.unshift(px[i]); rx.push(op.apply(null, args)); args.shift(); return rx; } } else { return op.apply(null, arguments); } } return gen; }; var gx = "optional not ignore cache".split(/\s/); for (var i = 0 ; i < gx.length ; i++) { _[gx[i]] = _generator(_[gx[i]]); } var _vector = function (op) { return function () { if (arguments[0] instanceof Array) { return op.apply(null, arguments[0]); } else { return op.apply(null, arguments); } }; }; var vx = "each any all".split(/\s/); for (var j = 0 ; j < vx.length ; j++) { _[vx[j]] = _vector(_[vx[j]]); } }()); (function () { var $D = Date; var flattenAndCompact = function (ax) { var rx = []; for (var i = 0; i < ax.length; i++) { if (ax[i] instanceof Array) { rx = rx.concat(flattenAndCompact(ax[i])); } else { if (ax[i]) { rx.push(ax[i]); } } } return rx; }; var parseMeridian = function () { if (this.meridian && (this.hour || this.hour === 0)) { if (this.meridian === "a" && this.hour > 11 && Date.Config.strict24hr){ throw "Invalid hour and meridian combination"; } else if (this.meridian === "p" && this.hour < 12 && Date.Config.strict24hr){ throw "Invalid hour and meridian combination"; } else if (this.meridian === "p" && this.hour < 12) { this.hour = this.hour + 12; } else if (this.meridian === "a" && this.hour === 12) { this.hour = 0; } } }; var setDefaults = function () { var now = new Date(); if ((this.hour || this.minute) && (!this.month && !this.year && !this.day)) { this.day = now.getDate(); } if (!this.year) { this.year = now.getFullYear(); } if (!this.month && this.month !== 0) { this.month = now.getMonth(); } if (!this.day) { this.day = 1; } if (!this.hour) { this.hour = 0; } if (!this.minute) { this.minute = 0; } if (!this.second) { this.second = 0; } if (!this.millisecond) { this.millisecond = 0; } }; var finishUtils = { getToday: function () { if (this.now || "hour minute second".indexOf(this.unit) !== -1) { return new Date(); } else { return $D.today(); } }, setDaysFromWeekday: function (today, orient){ var gap; orient = orient || 1; this.unit = "day"; gap = ($D.getDayNumberFromName(this.weekday) - today.getDay()); this.days = gap ? ((gap + (orient * 7)) % 7) : (orient * 7); return this; }, setMonthsFromMonth: function (today, orient) { var gap; orient = orient || 1; this.unit = "month"; gap = (this.month - today.getMonth()); this.months = gap ? ((gap + (orient * 12)) % 12) : (orient * 12); this.month = null; return this; }, setDMYFromWeekday: function () { var d = Date[this.weekday](); this.day = d.getDate(); if (!this.month) { this.month = d.getMonth(); } this.year = d.getFullYear(); return this; }, setUnitValue: function (orient) { if (!this.value && this.operator && this.operator !== null && this[this.unit + "s"] && this[this.unit + "s"] !== null) { this[this.unit + "s"] = this[this.unit + "s"] + ((this.operator === "add") ? 1 : -1) + (this.value||0) * orient; } else if (this[this.unit + "s"] == null || this.operator != null) { if (!this.value) { this.value = 1; } this[this.unit + "s"] = this.value * orient; } }, generateDateFromWeeks: function () { var weekday = (this.weekday !== undefined) ? this.weekday : "today"; var d = Date[weekday]().addWeeks(this.weeks); if (this.now) { d.setTimeToNow(); } return d; } }; $D.Translator = { hour: function (s) { return function () { this.hour = Number(s); }; }, minute: function (s) { return function () { this.minute = Number(s); }; }, second: function (s) { return function () { this.second = Number(s); }; }, /* for ss.s format */ secondAndMillisecond: function (s) { return function () { var mx = s.match(/^([0-5][0-9])\.([0-9]{1,3})/); this.second = Number(mx[1]); this.millisecond = Number(mx[2]); }; }, meridian: function (s) { return function () { this.meridian = s.slice(0, 1).toLowerCase(); }; }, timezone: function (s) { return function () { var n = s.replace(/[^\d\+\-]/g, ""); if (n.length) { this.timezoneOffset = Number(n); } else { this.timezone = s.toLowerCase(); } }; }, day: function (x) { var s = x[0]; return function () { this.day = Number(s.match(/\d+/)[0]); if (this.day < 1) { throw "invalid day"; } }; }, month: function (s) { return function () { this.month = (s.length === 3) ? "jan feb mar apr may jun jul aug sep oct nov dec".indexOf(s)/4 : Number(s) - 1; if (this.month < 0) { throw "invalid month"; } }; }, year: function (s) { return function () { var n = Number(s); this.year = ((s.length > 2) ? n : (n + (((n + 2000) < Date.CultureInfo.twoDigitYearMax) ? 2000 : 1900))); }; }, rday: function (s) { return function () { switch (s) { case "yesterday": this.days = -1; break; case "tomorrow": this.days = 1; break; case "today": this.days = 0; break; case "now": this.days = 0; this.now = true; break; } }; }, finishExact: function (x) { var d; x = (x instanceof Array) ? x : [x]; for (var i = 0 ; i < x.length ; i++) { if (x[i]) { x[i].call(this); } } setDefaults.call(this); parseMeridian.call(this); if (this.day > $D.getDaysInMonth(this.year, this.month)) { throw new RangeError(this.day + " is not a valid value for days."); } d = new Date(this.year, this.month, this.day, this.hour, this.minute, this.second, this.millisecond); if (this.year < 100) { d.setFullYear(this.year); // means years less that 100 are process correctly. JS will parse it otherwise as 1900-1999. } if (this.timezone) { d.set({ timezone: this.timezone }); } else if (this.timezoneOffset) { d.set({ timezoneOffset: this.timezoneOffset }); } return d; }, finish: function (x) { var today, expression, orient, temp; x = (x instanceof Array) ? flattenAndCompact(x) : [ x ]; if (x.length === 0) { return null; } for (var i = 0 ; i < x.length ; i++) { if (typeof x[i] === "function") { x[i].call(this); } } if (this.now && !this.unit && !this.operator) { return new Date(); } else { today = finishUtils.getToday.call(this); } expression = !!(this.days && this.days !== null || this.orient || this.operator); orient = ((this.orient === "past" || this.operator === "subtract") ? -1 : 1); if (this.month && this.unit === "week") { this.value = this.month + 1; delete this.month; delete this.day; } if ((this.month || this.month === 0) && "year day hour minute second".indexOf(this.unit) !== -1) { if (!this.value) { this.value = this.month + 1; } this.month = null; expression = true; } if (!expression && this.weekday && !this.day && !this.days) { finishUtils.setDMYFromWeekday.call(this); } if (expression && this.weekday && this.unit !== "month" && this.unit !== "week") { finishUtils.setDaysFromWeekday.call(this, today, orient); } if (this.weekday && this.unit !== "week" && !this.day && !this.days) { temp = Date[this.weekday](); this.day = temp.getDate(); if (temp.getMonth() !== today.getMonth()) { this.month = temp.getMonth(); } } if (this.month && this.unit === "day" && this.operator) { if (!this.value) { this.value = (this.month + 1); } this.month = null; } if (this.value != null && this.month != null && this.year != null) { this.day = this.value * 1; } if (this.month && !this.day && this.value) { today.set({ day: this.value * 1 }); if (!expression) { this.day = this.value * 1; } } if (!this.month && this.value && this.unit === "month" && !this.now) { this.month = this.value; expression = true; } if (expression && (this.month || this.month === 0) && this.unit !== "year") { finishUtils.setMonthsFromMonth.call(this, today, orient); } if (!this.unit) { this.unit = "day"; } finishUtils.setUnitValue.call(this, orient); parseMeridian.call(this); if ((this.month || this.month === 0) && !this.day) { this.day = 1; } if (!this.orient && !this.operator && this.unit === "week" && this.value && !this.day && !this.month) { return Date.today().setWeek(this.value); } if (this.unit === "week" && this.weeks && !this.day && !this.month) { return finishUtils.generateDateFromWeeks.call(this); } if (expression && this.timezone && this.day && this.days) { this.day = this.days; } if (expression){ today.add(this); } else { today.set(this); } if (this.timezone) { this.timezone = this.timezone.toUpperCase(); var offset = $D.getTimezoneOffset(this.timezone); var timezone; if (today.hasDaylightSavingTime()) { // lets check that we're being sane with timezone setting timezone = $D.getTimezoneAbbreviation(offset, today.isDaylightSavingTime()); if (timezone !== this.timezone) { // bugger, we're in a place where things like EST vs EDT matters. if (today.isDaylightSavingTime()) { today.addHours(-1); } else { today.addHours(1); } } } today.setTimezoneOffset(offset); } return today; } }; }()); (function () { var $D = Date; $D.Grammar = {}; var _ = $D.Parsing.Operators, g = $D.Grammar, t = $D.Translator, _fn; // Allow rolling up into general purpose rules _fn = function () { return _.each(_.any.apply(null, arguments), _.not(g.ctoken2("timeContext"))); }; g.datePartDelimiter = _.rtoken(/^([\s\-\.\,\/\x27]+)/); g.timePartDelimiter = _.stoken(":"); g.whiteSpace = _.rtoken(/^\s*/); g.generalDelimiter = _.rtoken(/^(([\s\,]|at|@|on)+)/); var _C = {}; g.ctoken = function (keys) { var fn = _C[keys]; if (! fn) { var c = Date.CultureInfo.regexPatterns; var kx = keys.split(/\s+/), px = []; for (var i = 0; i < kx.length ; i++) { px.push(_.replace(_.rtoken(c[kx[i]]), kx[i])); } fn = _C[keys] = _.any.apply(null, px); } return fn; }; g.ctoken2 = function (key) { return _.rtoken(Date.CultureInfo.regexPatterns[key]); }; var cacheProcessRtoken = function (key, token, type, eachToken) { if (eachToken) { g[key] = _.cache(_.process(_.each(_.rtoken(token),_.optional(g.ctoken2(eachToken))), type)); } else { g[key] = _.cache(_.process(_.rtoken(token), type)); } }; var cacheProcessCtoken = function (token, type) { return _.cache(_.process(g.ctoken2(token), type)); }; var _F = {}; //function cache var _get = function (f) { _F[f] = (_F[f] || g.format(f)[0]); return _F[f]; }; g.allformats = function (fx) { var rx = []; if (fx instanceof Array) { for (var i = 0; i < fx.length; i++) { rx.push(_get(fx[i])); } } else { rx.push(_get(fx)); } return rx; }; g.formats = function (fx) { if (fx instanceof Array) { var rx = []; for (var i = 0 ; i < fx.length ; i++) { rx.push(_get(fx[i])); } return _.any.apply(null, rx); } else { return _get(fx); } }; var grammarFormats = { timeFormats: function(){ var i, RTokenKeys = [ "h", "hh", "H", "HH", "m", "mm", "s", "ss", "ss.s", "z", "zz" ], RToken = [ /^(0[0-9]|1[0-2]|[1-9])/, /^(0[0-9]|1[0-2])/, /^([0-1][0-9]|2[0-3]|[0-9])/, /^([0-1][0-9]|2[0-3])/, /^([0-5][0-9]|[0-9])/, /^[0-5][0-9]/, /^([0-5][0-9]|[0-9])/, /^[0-5][0-9]/, /^[0-5][0-9]\.[0-9]{1,3}/, /^((\+|\-)\s*\d\d\d\d)|((\+|\-)\d\d\:?\d\d)/, /^((\+|\-)\s*\d\d\d\d)|((\+|\-)\d\d\:?\d\d)/ ], tokens = [ t.hour, t.hour, t.hour, t.hour, t.minute, t.minute, t.second, t.second, t.secondAndMillisecond, t.timezone, t.timezone ]; for (i=0; i < RTokenKeys.length; i++) { cacheProcessRtoken(RTokenKeys[i], RToken[i], tokens[i]); } g.hms = _.cache(_.sequence([g.H, g.m, g.s], g.timePartDelimiter)); g.t = cacheProcessCtoken("shortMeridian", t.meridian); g.tt = cacheProcessCtoken("longMeridian", t.meridian); g.zzz = cacheProcessCtoken("timezone", t.timezone); g.timeSuffix = _.each(_.ignore(g.whiteSpace), _.set([ g.tt, g.zzz ])); g.time = _.each(_.optional(_.ignore(_.stoken("T"))), g.hms, g.timeSuffix); }, dateFormats: function () { // pre-loaded rules for different date part order preferences var _setfn = function () { return _.set(arguments, g.datePartDelimiter); }; var i, RTokenKeys = [ "d", "dd", "M", "MM", "y", "yy", "yyy", "yyyy" ], RToken = [ /^([0-2]\d|3[0-1]|\d)/, /^([0-2]\d|3[0-1])/, /^(1[0-2]|0\d|\d)/, /^(1[0-2]|0\d)/, /^(\d+)/, /^(\d\d)/, /^(\d\d?\d?\d?)/, /^(\d\d\d\d)/ ], tokens = [ t.day, t.day, t.month, t.month, t.year, t.year, t.year, t.year ], eachToken = [ "ordinalSuffix", "ordinalSuffix" ]; for (i=0; i < RTokenKeys.length; i++) { cacheProcessRtoken(RTokenKeys[i], RToken[i], tokens[i], eachToken[i]); } g.MMM = g.MMMM = _.cache(_.process(g.ctoken("jan feb mar apr may jun jul aug sep oct nov dec"), t.month)); g.ddd = g.dddd = _.cache(_.process(g.ctoken("sun mon tue wed thu fri sat"), function (s) { return function () { this.weekday = s; }; } )); g.day = _fn(g.d, g.dd); g.month = _fn(g.M, g.MMM); g.year = _fn(g.yyyy, g.yy); g.mdy = _setfn(g.ddd, g.month, g.day, g.year); g.ymd = _setfn(g.ddd, g.year, g.month, g.day); g.dmy = _setfn(g.ddd, g.day, g.month, g.year); g.date = function (s) { return ((g[Date.CultureInfo.dateElementOrder] || g.mdy).call(this, s)); }; }, relative: function () { // relative date / time expressions g.orientation = _.process(g.ctoken("past future"), function (s) { return function () { this.orient = s; }; } ); g.operator = _.process(g.ctoken("add subtract"), function (s) { return function () { this.operator = s; }; } ); g.rday = _.process(g.ctoken("yesterday tomorrow today now"), t.rday); g.unit = _.process(g.ctoken("second minute hour day week month year"), function (s) { return function () { this.unit = s; }; } ); } }; g.buildGrammarFormats = function () { // these need to be rebuilt every time the language changes. _C = {}; grammarFormats.timeFormats(); grammarFormats.dateFormats(); grammarFormats.relative(); g.value = _.process(_.rtoken(/^([-+]?\d+)?(st|nd|rd|th)?/), function (s) { return function () { this.value = s.replace(/\D/g, ""); }; } ); g.expression = _.set([g.rday, g.operator, g.value, g.unit, g.orientation, g.ddd, g.MMM ]); g.format = _.process(_.many( _.any( // translate format specifiers into grammar rules _.process( _.rtoken(/^(dd?d?d?(?!e)|MM?M?M?|yy?y?y?|hh?|HH?|mm?|ss?|tt?|zz?z?)/), function (fmt) { if (g[fmt]) { return g[fmt]; } else { throw $D.Parsing.Exception(fmt); } } ), // translate separator tokens into token rules _.process(_.rtoken(/^[^dMyhHmstz]+/), // all legal separators function (s) { return _.ignore(_.stoken(s)); } ) ) ), // construct the parser ... function (rules) { return _.process(_.each.apply(null, rules), t.finishExact); } ); // starting rule for general purpose grammar g._start = _.process(_.set([ g.date, g.time, g.expression ], g.generalDelimiter, g.whiteSpace), t.finish); }; g.buildGrammarFormats(); // parsing date format specifiers - ex: "h:m:s tt" // this little guy will generate a custom parser based // on the format string, ex: g.format("h:m:s tt") // check for these formats first g._formats = g.formats([ "\"yyyy-MM-ddTHH:mm:ssZ\"", "yyyy-MM-ddTHH:mm:ss.sz", "yyyy-MM-ddTHH:mm:ssZ", "yyyy-MM-ddTHH:mm:ssz", "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-ddTHH:mmZ", "yyyy-MM-ddTHH:mmz", "yyyy-MM-ddTHH:mm", "ddd, MMM dd, yyyy H:mm:ss tt", "ddd MMM d yyyy HH:mm:ss zzz", "MMddyyyy", "ddMMyyyy", "Mddyyyy", "ddMyyyy", "Mdyyyy", "dMyyyy", "yyyy", "Mdyy", "dMyy", "d" ]); // real starting rule: tries selected formats first, // then general purpose rule g.start = function (s) { try { var r = g._formats.call({}, s); if (r[1].length === 0) { return r; } } catch (e) {} return g._start.call({}, s); }; }()); (function () { var $D = Date; /** * @desc Converts the specified string value into its JavaScript Date equivalent using CultureInfo specific format information. * * Example

	///////////
	// Dates //
	///////////

	// 15-Oct-2004
	var d1 = Date.parse("10/15/2004");

	// 15-Oct-2004
	var d1 = Date.parse("15-Oct-2004");

	// 15-Oct-2004
	var d1 = Date.parse("2004.10.15");

	//Fri Oct 15, 2004
	var d1 = Date.parse("Fri Oct 15, 2004");

	///////////
	// Times //
	///////////

	// Today at 10 PM.
	var d1 = Date.parse("10 PM");

	// Today at 10:30 PM.
	var d1 = Date.parse("10:30 P.M.");

	// Today at 6 AM.
	var d1 = Date.parse("06am");

	/////////////////////
	// Dates and Times //
	/////////////////////

	// 8-July-2004 @ 10:30 PM
	var d1 = Date.parse("July 8th, 2004, 10:30 PM");

	// 1-July-2004 @ 10:30 PM
	var d1 = Date.parse("2004-07-01T22:30:00");

	////////////////////
	// Relative Dates //
	////////////////////

	// Returns today's date. The string "today" is culture specific.
	var d1 = Date.parse("today");

	// Returns yesterday's date. The string "yesterday" is culture specific.
	var d1 = Date.parse("yesterday");

	// Returns the date of the next thursday.
	var d1 = Date.parse("Next thursday");

	// Returns the date of the most previous monday.
	var d1 = Date.parse("last monday");

	// Returns today's day + one year.
	var d1 = Date.parse("next year");

	///////////////
	// Date Math //
	///////////////

	// Today + 2 days
	var d1 = Date.parse("t+2");

	// Today + 2 days
	var d1 = Date.parse("today + 2 days");

	// Today + 3 months
	var d1 = Date.parse("t+3m");

	// Today - 1 year
	var d1 = Date.parse("today - 1 year");

	// Today - 1 year
	var d1 = Date.parse("t-1y"); 


	/////////////////////////////
	// Partial Dates and Times //
	/////////////////////////////

	// July 15th of this year.
	var d1 = Date.parse("July 15");

	// 15th day of current day and year.
	var d1 = Date.parse("15");

	// July 1st of current year at 10pm.
	var d1 = Date.parse("7/1 10pm");
	
* * @param {String} The string value to convert into a Date object [Required] * @return {Date} A Date object or null if the string cannot be converted into a Date. */ var parseUtils = { removeOrds: function (s) { ords = s.match(/\b(\d+)(?:st|nd|rd|th)\b/); // find ordinal matches s = ((ords && ords.length === 2) ? s.replace(ords[0], ords[1]) : s); return s; }, grammarParser: function (s) { var r = null; try { r = $D.Grammar.start.call({}, s.replace(/^\s*(\S*(\s+\S+)*)\s*$/, "$1")); } catch (e) { return null; } return ((r[1].length === 0) ? r[0] : null); }, nativeFallback: function(s) { var t; try { // ok we haven't parsed it, last ditch attempt with the built-in parser. t = Date._parse(s); return (t || t === 0) ? new Date(t) : null; } catch (e) { return null; } } }; function parse (s) { var d; if (!s) { return null; } if (s instanceof Date) { return s.clone(); } if (s.length >= 4 && s.charAt(0) !== "0" && s.charAt(0) !== "+"&& s.charAt(0) !== "-") { // ie: 2004 will pass, 0800 won't. // Start with specific formats d = $D.Parsing.ISO.parse(s) || $D.Parsing.Numeric.parse(s); } if (d instanceof Date && !isNaN(d.getTime())) { return d; } else { // find ordinal dates (1st, 3rd, 8th, etc and remove them as they cause parsing issues) s = $D.Parsing.Normalizer.parse(parseUtils.removeOrds(s)); d = parseUtils.grammarParser(s); if (d !== null) { return d; } else { return parseUtils.nativeFallback(s); } } } if (!$D._parse) { $D._parse = $D.parse; } $D.parse = parse; Date.getParseFunction = function (fx) { var fns = Date.Grammar.allformats(fx); return function (s) { var r = null; for (var i = 0; i < fns.length; i++) { try { r = fns[i].call({}, s); } catch (e) { continue; } if (r[1].length === 0) { return r[0]; } } return null; }; }; /** * Converts the specified string value into its JavaScript Date equivalent using the specified format {String} or formats {Array} and the CultureInfo specific format information. * The format of the string value must match one of the supplied formats exactly. * * Example

	// 15-Oct-2004
	var d1 = Date.parseExact("10/15/2004", "M/d/yyyy");

	// 15-Oct-2004
	var d1 = Date.parse("15-Oct-2004", "M-ddd-yyyy");

	// 15-Oct-2004
	var d1 = Date.parse("2004.10.15", "yyyy.MM.dd");

	// Multiple formats
	var d1 = Date.parseExact("10/15/2004", ["M/d/yyyy", "MMMM d, yyyy"]);
	
* * @param {String} The string value to convert into a Date object [Required]. * @param {Object} The expected format {String} or an array of expected formats {Array} of the date string [Required]. * @return {Date} A Date object or null if the string cannot be converted into a Date. */ $D.parseExact = function (s, fx) { return $D.getParseFunction(fx)(s); }; }()); (function () { var $D = Date, $P = $D.prototype, // $C = $D.CultureInfo, // not used atm p = function (s, l) { if (!l) { l = 2; } return ("000" + s).slice(l * -1); }; /** * Converts a PHP format string to Java/.NET format string. * A PHP format string can be used with ._format or .format. * A Java/.NET format string can be used with .toString(). * The .parseExact function will only accept a Java/.NET format string * * Example * var f1 = "%m/%d/%y" * var f2 = Date.normalizeFormat(f1); // "MM/dd/yy" * * new Date().format(f1); // "04/13/08" * new Date()._format(f1); // "04/13/08" * new Date().toString(f2); // "04/13/08" * * var date = Date.parseExact("04/13/08", f2); // Sun Apr 13 2008 * * @param {String} A PHP format string consisting of one or more format spcifiers. * @return {String} The PHP format converted to a Java/.NET format string. */ var normalizerSubstitutions = { "d" : "dd", "%d": "dd", "D" : "ddd", "%a": "ddd", "j" : "dddd", "l" : "dddd", "%A": "dddd", "S" : "S", "F" : "MMMM", "%B": "MMMM", "m" : "MM", "%m": "MM", "M" : "MMM", "%b": "MMM", "%h": "MMM", "n" : "M", "Y" : "yyyy", "%Y": "yyyy", "y" : "yy", "%y": "yy", "g" : "h", "%I": "h", "G" : "H", "h" : "hh", "H" : "HH", "%H": "HH", "i" : "mm", "%M": "mm", "s" : "ss", "%S": "ss", "%r": "hh:mm tt", "%R": "H:mm", "%T": "H:mm:ss", "%X": "t", "%x": "d", "%e": "d", "%D": "MM/dd/yy", "%n": "\\n", "%t": "\\t", "e" : "z", "T" : "z", "%z": "z", "%Z": "z", "Z" : "ZZ", "N" : "u", "w" : "u", "%w": "u", "W" : "W", "%V": "W" }; var normalizer = { substitutes: function (m) { return normalizerSubstitutions[m]; }, interpreted: function (m, x) { var y; switch (m) { case "%u": return x.getDay() + 1; case "z": return x.getOrdinalNumber(); case "%j": return p(x.getOrdinalNumber(), 3); case "%U": var d1 = x.clone().set({month: 0, day: 1}).addDays(-1).moveToDayOfWeek(0), d2 = x.clone().addDays(1).moveToDayOfWeek(0, -1); return (d2 < d1) ? "00" : p((d2.getOrdinalNumber() - d1.getOrdinalNumber()) / 7 + 1); case "%W": return p(x.getWeek()); case "t": return $D.getDaysInMonth(x.getFullYear(), x.getMonth()); case "o": case "%G": return x.setWeek(x.getISOWeek()).toString("yyyy"); case "%g": return x._format("%G").slice(-2); case "a": case "%p": return t("tt").toLowerCase(); case "A": return t("tt").toUpperCase(); case "u": return p(x.getMilliseconds(), 3); case "I": return (x.isDaylightSavingTime()) ? 1 : 0; case "O": return x.getUTCOffset(); case "P": y = x.getUTCOffset(); return y.substring(0, y.length - 2) + ":" + y.substring(y.length - 2); case "B": var now = new Date(); return Math.floor(((now.getHours() * 3600) + (now.getMinutes() * 60) + now.getSeconds() + (now.getTimezoneOffset() + 60) * 60) / 86.4); case "c": return x.toISOString().replace(/\"/g, ""); case "U": return $D.strtotime("now"); case "%c": return t("d") + " " + t("t"); case "%C": return Math.floor(x.getFullYear() / 100 + 1); } }, shouldOverrideDefaults: function (m) { switch (m) { case "%e": return true; default: return false; } }, parse: function (m, context) { var formatString, c = context || new Date(); formatString = normalizer.substitutes(m); if (formatString) { return formatString; } formatString = normalizer.interpreted(m, c); if (formatString) { return formatString; } else { return m; } } }; $D.normalizeFormat = function (format, context) { return format.replace(/(%|\\)?.|%%/g, function(t){ return normalizer.parse(t, context); }); }; /** * Format a local Unix timestamp according to locale settings * * Example: * Date.strftime("%m/%d/%y", new Date()); // "04/13/08" * Date.strftime("c", "2008-04-13T17:52:03Z"); // "04/13/08" * * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @param {Number|String} The number representing the number of seconds that have elapsed since January 1, 1970 (local time). * @return {String} A string representation of the current Date object. */ $D.strftime = function (format, time) { var d = Date.parse(time); return d._format(format); }; /** * Parse any textual datetime description into a Unix timestamp. * A Unix timestamp is the number of seconds that have elapsed since January 1, 1970 (midnight UTC/GMT). * * Example: * Date.strtotime("04/13/08"); // 1208044800 * Date.strtotime("1970-01-01T00:00:00Z"); // 0 * * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @param {Object} A string or date object. * @return {String} A string representation of the current Date object. */ $D.strtotime = function (time) { var d = $D.parse(time); return Math.round($D.UTC(d.getUTCFullYear(), d.getUTCMonth(), d.getUTCDate(), d.getUTCHours(), d.getUTCMinutes(), d.getUTCSeconds(), d.getUTCMilliseconds()) / 1000); }; /** * Converts the value of the current Date object to its equivalent string representation using a PHP/Unix style of date format specifiers. * Format Specifiers * Format Description Example * ------ --------------------------------------------------------------------------- ----------------------- * %a abbreviated weekday name according to the current localed "Mon" through "Sun" * %A full weekday name according to the current localed "Sunday" through "Saturday" * %b abbreviated month name according to the current localed "Jan" through "Dec" * %B full month name according to the current locale "January" through "December" * %c preferred date and time representation for the current locale "4/13/2008 12:33 PM" * %C century number (the year divided by 100 and truncated to an integer) "00" to "99" * %d day of the month as a decimal number "01" to "31" * %D same as %m/%d/%y "04/13/08" * %e day of the month as a decimal number, a single digit is preceded by a space "1" to "31" * %g like %G, but without the century "08" * %G The 4-digit year corresponding to the ISO week number (see %V). "2008" * This has the same format and value as %Y, except that if the ISO week number * belongs to the previous or next year, that year is used instead. * %h same as %b "Jan" through "Dec" * %H hour as a decimal number using a 24-hour clock. "00" to "23" * %I hour as a decimal number using a 12-hour clock. "01" to "12" * %j day of the year as a decimal number. "001" to "366" * %m month as a decimal number. "01" to "12" * %M minute as a decimal number. "00" to "59" * %n newline character "\n" * %p either "am" or "pm" according to the given time value, or the "am" or "pm" * corresponding strings for the current locale. * %r time in a.m. and p.m. notation "8:44 PM" * %R time in 24 hour notation "20:44" * %S second as a decimal number "00" to "59" * %t tab character "\t" * %T current time, equal to %H:%M:%S "12:49:11" * %u weekday as a decimal number ["1", "7"], with "1" representing Monday "1" to "7" * %U week number of the current year as a decimal number, starting with the "0" to ("52" or "53") * first Sunday as the first day of the first week * %V The ISO 8601:1988 week number of the current year as a decimal number, "00" to ("52" or "53") * range 01 to 53, where week 1 is the first week that has at least 4 days * in the current year, and with Monday as the first day of the week. * (Use %G or %g for the year component that corresponds to the week number * for the specified timestamp.) * %W week number of the current year as a decimal number, starting with the "00" to ("52" or "53") * first Monday as the first day of the first week * %w day of the week as a decimal, Sunday being "0" "0" to "6" * %x preferred date representation for the current locale without the time "4/13/2008" * %X preferred time representation for the current locale without the date "12:53:05" * %y year as a decimal number without a century "00" "99" * %Y year as a decimal number including the century "2008" * %Z time zone or name or abbreviation "UTC", "EST", "PST" * %z same as %Z * %% a literal "%" characters "%" * d Day of the month, 2 digits with leading zeros "01" to "31" * D A textual representation of a day, three letters "Mon" through "Sun" * j Day of the month without leading zeros "1" to "31" * l A full textual representation of the day of the week (lowercase "L") "Sunday" through "Saturday" * N ISO-8601 numeric representation of the day of the week (added in PHP 5.1.0) "1" (for Monday) through "7" (for Sunday) * S English ordinal suffix for the day of the month, 2 characters "st", "nd", "rd" or "th". Works well with j * w Numeric representation of the day of the week "0" (for Sunday) through "6" (for Saturday) * z The day of the year (starting from "0") "0" through "365" * W ISO-8601 week number of year, weeks starting on Monday "00" to ("52" or "53") * F A full textual representation of a month, such as January or March "January" through "December" * m Numeric representation of a month, with leading zeros "01" through "12" * M A short textual representation of a month, three letters "Jan" through "Dec" * n Numeric representation of a month, without leading zeros "1" through "12" * t Number of days in the given month "28" through "31" * L Whether it's a leap year "1" if it is a leap year, "0" otherwise * o ISO-8601 year number. This has the same value as Y, except that if the "2008" * ISO week number (W) belongs to the previous or next year, that year * is used instead. * Y A full numeric representation of a year, 4 digits "2008" * y A two digit representation of a year "08" * a Lowercase Ante meridiem and Post meridiem "am" or "pm" * A Uppercase Ante meridiem and Post meridiem "AM" or "PM" * B Swatch Internet time "000" through "999" * g 12-hour format of an hour without leading zeros "1" through "12" * G 24-hour format of an hour without leading zeros "0" through "23" * h 12-hour format of an hour with leading zeros "01" through "12" * H 24-hour format of an hour with leading zeros "00" through "23" * i Minutes with leading zeros "00" to "59" * s Seconds, with leading zeros "00" through "59" * u Milliseconds "54321" * e Timezone identifier "UTC", "EST", "PST" * I Whether or not the date is in daylight saving time (uppercase i) "1" if Daylight Saving Time, "0" otherwise * O Difference to Greenwich time (GMT) in hours "+0200", "-0600" * P Difference to Greenwich time (GMT) with colon between hours and minutes "+02:00", "-06:00" * T Timezone abbreviation "UTC", "EST", "PST" * Z Timezone offset in seconds. The offset for timezones west of UTC is "-43200" through "50400" * always negative, and for those east of UTC is always positive. * c ISO 8601 date "2004-02-12T15:19:21+00:00" * r RFC 2822 formatted date "Thu, 21 Dec 2000 16:01:07 +0200" * U Seconds since the Unix Epoch (January 1 1970 00:00:00 GMT) "0" * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @return {String} A string representation of the current Date object. */ var formatReplace = function (context) { return function (m) { var formatString, override = false; if (m.charAt(0) === "\\" || m.substring(0, 2) === "%%") { return m.replace("\\", "").replace("%%", "%"); } override = normalizer.shouldOverrideDefaults(m); formatString = $D.normalizeFormat(m, context); if (formatString) { return context.toString(formatString, override); } }; }; $P._format = function (format) { var formatter = formatReplace(this); if (!format) { return this._toString(); } else { return format.replace(/(%|\\)?.|%%/g, formatter); } }; if (!$P.format) { $P.format = $P._format; } }()); (function () { "use strict"; var gFn = function (attr) { return function () { return this[attr]; }; }; var sFn = function (attr) { return function (val) { this[attr] = val; return this; }; }; var attrs = ["years", "months", "days", "hours", "minutes", "seconds", "milliseconds"]; var addSetFuncs = function (context, attrs) { for (var i = 0; i < attrs.length ; i++) { var $a = attrs[i], $b = $a.slice(0, 1).toUpperCase() + $a.slice(1); context.prototype[$a] = 0; context.prototype["get" + $b] = gFn($a); context.prototype["set" + $b] = sFn($a); } }; /** * new TimeSpan(milliseconds); * new TimeSpan(days, hours, minutes, seconds); * new TimeSpan(days, hours, minutes, seconds, milliseconds); */ var TimeSpan = function (days, hours, minutes, seconds, milliseconds) { if (arguments.length === 1 && typeof days === "number") { var orient = (days < 0) ? -1 : +1; var millsLeft = Math.abs(days); this.setDays(Math.floor(millsLeft / 86400000) * orient); millsLeft = millsLeft % 86400000; this.setHours(Math.floor(millsLeft / 3600000) * orient); millsLeft = millsLeft % 3600000; this.setMinutes(Math.floor(millsLeft / 60000) * orient); millsLeft = millsLeft % 60000; this.setSeconds(Math.floor(millsLeft / 1000) * orient); millsLeft = millsLeft % 1000; this.setMilliseconds(millsLeft * orient); } else { this.set(days, hours, minutes, seconds, milliseconds); } this.getTotalMilliseconds = function () { return (this.getDays() * 86400000) + (this.getHours() * 3600000) + (this.getMinutes() * 60000) + (this.getSeconds() * 1000); }; this.compareTo = function (time) { var t1 = new Date(1970, 1, 1, this.getHours(), this.getMinutes(), this.getSeconds()), t2; if (time === null) { t2 = new Date(1970, 1, 1, 0, 0, 0); } else { t2 = new Date(1970, 1, 1, time.getHours(), time.getMinutes(), time.getSeconds()); } return (t1 < t2) ? -1 : (t1 > t2) ? 1 : 0; }; this.equals = function (time) { return (this.compareTo(time) === 0); }; this.add = function (time) { return (time === null) ? this : this.addSeconds(time.getTotalMilliseconds() / 1000); }; this.subtract = function (time) { return (time === null) ? this : this.addSeconds(-time.getTotalMilliseconds() / 1000); }; this.addDays = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 86400000)); }; this.addHours = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 3600000)); }; this.addMinutes = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 60000)); }; this.addSeconds = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 1000)); }; this.addMilliseconds = function (n) { return new TimeSpan(this.getTotalMilliseconds() + n); }; this.get12HourHour = function () { return (this.getHours() > 12) ? this.getHours() - 12 : (this.getHours() === 0) ? 12 : this.getHours(); }; this.getDesignator = function () { return (this.getHours() < 12) ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator; }; this.toString = function (format) { this._toString = function () { if (this.getDays() !== null && this.getDays() > 0) { return this.getDays() + "." + this.getHours() + ":" + this.p(this.getMinutes()) + ":" + this.p(this.getSeconds()); } else { return this.getHours() + ":" + this.p(this.getMinutes()) + ":" + this.p(this.getSeconds()); } }; this.p = function (s) { return (s.toString().length < 2) ? "0" + s : s; }; var me = this; return format ? format.replace(/dd?|HH?|hh?|mm?|ss?|tt?/g, function (format) { switch (format) { case "d": return me.getDays(); case "dd": return me.p(me.getDays()); case "H": return me.getHours(); case "HH": return me.p(me.getHours()); case "h": return me.get12HourHour(); case "hh": return me.p(me.get12HourHour()); case "m": return me.getMinutes(); case "mm": return me.p(me.getMinutes()); case "s": return me.getSeconds(); case "ss": return me.p(me.getSeconds()); case "t": return ((me.getHours() < 12) ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator).substring(0, 1); case "tt": return (me.getHours() < 12) ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator; } } ) : this._toString(); }; return this; }; addSetFuncs(TimeSpan, attrs.slice(2)); TimeSpan.prototype.set = function (days, hours, minutes, seconds, milliseconds){ this.setDays(days || this.getDays()); this.setHours(hours || this.getHours()); this.setMinutes(minutes || this.getMinutes()); this.setSeconds(seconds || this.getSeconds()); this.setMilliseconds(milliseconds || this.getMilliseconds()); }; /** * Gets the time of day for this date instances. * @return {TimeSpan} TimeSpan */ Date.prototype.getTimeOfDay = function () { return new TimeSpan(0, this.getHours(), this.getMinutes(), this.getSeconds(), this.getMilliseconds()); }; Date.TimeSpan = TimeSpan; if (typeof window !== "undefined" ) { // keeping API compatible for v1.x window.TimeSpan = TimeSpan; } }()); (function () { "use strict"; var attrs = ["years", "months", "days", "hours", "minutes", "seconds", "milliseconds"]; var gFn = function (attr) { return function () { return this[attr]; }; }; var sFn = function (attr) { return function (val) { this[attr] = val; return this; }; }; var addSetFuncs = function (context, attrs) { for (var i = 0; i < attrs.length ; i++) { var $a = attrs[i], $b = $a.slice(0, 1).toUpperCase() + $a.slice(1); context.prototype[$a] = 0; context.prototype["get" + $b] = gFn($a); context.prototype["set" + $b] = sFn($a); } }; var setMonthsAndYears = function (orient, d1, d2, context) { function inc() { d1.addMonths(-orient); context.months++; if (context.months === 12) { context.years++; context.months = 0; } } if (orient === +1) { while (d1 > d2) { inc(); } } else { while (d1 < d2) { inc(); } } context.months--; context.months *= orient; context.years *= orient; }; var adjustForDST = function(orient, startDate, endDate) { var hasDSTMismatch = (false === (startDate.isDaylightSavingTime() === endDate.isDaylightSavingTime())); if (hasDSTMismatch && orient === 1) { startDate.addHours(-1); } else if (hasDSTMismatch) { startDate.addHours(1); } }; /** * TimePeriod(startDate, endDate); * TimePeriod(years, months, days, hours, minutes, seconds, milliseconds); */ var TimePeriod = function (years, months, days, hours, minutes, seconds, milliseconds) { if (arguments.length === 7) { this.set(years, months, days, hours, minutes, seconds, milliseconds); } else if (arguments.length === 2 && arguments[0] instanceof Date && arguments[1] instanceof Date) { var startDate = arguments[0].clone(); var endDate = arguments[1].clone(); var orient = (startDate > endDate) ? +1 : -1; this.dates = { start: arguments[0].clone(), end: arguments[1].clone() }; setMonthsAndYears(orient, startDate, endDate, this); adjustForDST(orient, startDate, endDate); // // TODO - adjust for DST var diff = endDate - startDate; if (diff !== 0) { var ts = new TimeSpan(diff); this.set(this.years, this.months, ts.getDays(), ts.getHours(), ts.getMinutes(), ts.getSeconds(), ts.getMilliseconds()); } } return this; }; // create all the set functions. addSetFuncs(TimePeriod, attrs); TimePeriod.prototype.set = function (years, months, days, hours, minutes, seconds, milliseconds){ this.setYears(years || this.getYears()); this.setMonths(months || this.getMonths()); this.setDays(days || this.getDays()); this.setHours(hours || this.getHours()); this.setMinutes(minutes || this.getMinutes()); this.setSeconds(seconds || this.getSeconds()); this.setMilliseconds(milliseconds || this.getMilliseconds()); }; Date.TimePeriod = TimePeriod; if (typeof window !== "undefined") { // keeping API compatible for v1.x window.TimePeriod = TimePeriod; } }()); ================================================ FILE: build/date-sma-NO.js ================================================ /** * @overview datejs * @version 1.0.0-rc3 * @author Gregory Wild-Smith * @copyright 2015 Gregory Wild-Smith * @license MIT * @homepage https://github.com/abritinthebay/datejs */ /* * DateJS Culture String File * Country Code: sma-NO * Name: Sami (Southern) (Norway) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["sma-NO"] = { "name": "sma-NO", "englishName": "Sami (Southern) (Norway)", "nativeName": "åarjelsaemiengiele (Nöörje)", "Sunday": "aejlege", "Monday": "måanta", "Tuesday": "dæjsta", "Wednesday": "gaskevåhkoe", "Thursday": "duarsta", "Friday": "bearjadahke", "Saturday": "laavvardahke", "Sun": "aej", "Mon": "måa", "Tue": "dæj", "Wed": "gask", "Thu": "duar", "Fri": "bearj", "Sat": "laav", "Su": "aej", "Mo": "måa", "Tu": "dæj", "We": "gask", "Th": "duar", "Fr": "bearj", "Sa": "laav", "S_Sun_Initial": "a", "M_Mon_Initial": "m", "T_Tue_Initial": "d", "W_Wed_Initial": "g", "T_Thu_Initial": "d", "F_Fri_Initial": "b", "S_Sat_Initial": "l", "January": "tsïengele", "February": "goevte", "March": "njoktje", "April": "voerhtje", "May": "suehpede", "June": "ruffie", "July": "snjaltje", "August": "mïetske", "September": "skïerede", "October": "golke", "November": "rahka", "December": "goeve", "Jan_Abbr": "tsïen", "Feb_Abbr": "goevt", "Mar_Abbr": "njok", "Apr_Abbr": "voer", "May_Abbr": "sueh", "Jun_Abbr": "ruff", "Jul_Abbr": "snja", "Aug_Abbr": "mïet", "Sep_Abbr": "skïer", "Oct_Abbr": "golk", "Nov_Abbr": "rahk", "Dec_Abbr": "goev", "AM": "", "PM": "", "firstDayOfWeek": 1, "twoDigitYearMax": 2029, "mdy": "dmy", "M/d/yyyy": "dd.MM.yyyy", "dddd, MMMM dd, yyyy": "MMMM d'. b. 'yyyy", "h:mm tt": "HH:mm:ss", "h:mm:ss tt": "HH:mm:ss", "dddd, MMMM dd, yyyy h:mm:ss tt": "MMMM d'. b. 'yyyy HH:mm:ss", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "MMMM dd", "MMMM, yyyy": "MMMM yyyy", "/jan(uary)?/": "tsïen(gele)?", "/feb(ruary)?/": "goevt(e)?", "/mar(ch)?/": "njok(tje)?", "/apr(il)?/": "voer(htje)?", "/may/": "sueh(pede)?", "/jun(e)?/": "ruff(ie)?", "/jul(y)?/": "snja(ltje)?", "/aug(ust)?/": "mïet(ske)?", "/sep(t(ember)?)?/": "skïer(ede)?", "/oct(ober)?/": "golk(e)?", "/nov(ember)?/": "rahk(a)?", "/dec(ember)?/": "goev(e)?", "/^su(n(day)?)?/": "^aejlege", "/^mo(n(day)?)?/": "^måanta", "/^tu(e(s(day)?)?)?/": "^dæjsta", "/^we(d(nesday)?)?/": "^gaskevåhkoe", "/^th(u(r(s(day)?)?)?)?/": "^duarsta", "/^fr(i(day)?)?/": "^bearjadahke", "/^sa(t(urday)?)?/": "^laavvardahke", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "sma-NO"; /** * @overview datejs * @version 1.0.0-rc3 * @author Gregory Wild-Smith * @copyright 2015 Gregory Wild-Smith * @license MIT * @homepage https://github.com/abritinthebay/datejs */(function () { var $D = Date; var lang = Date.CultureStrings ? Date.CultureStrings.lang : null; var loggedKeys = {}; // for debug purposes. var getText = { getFromKey: function (key, countryCode) { var output; if (Date.CultureStrings && Date.CultureStrings[countryCode] && Date.CultureStrings[countryCode][key]) { output = Date.CultureStrings[countryCode][key]; } else { output = getText.buildFromDefault(key); } if (key.charAt(0) === "/") { // Assume it's a regex output = getText.buildFromRegex(key, countryCode); } return output; }, getFromObjectValues: function (obj, countryCode) { var key, output = {}; for(key in obj) { if (obj.hasOwnProperty(key)) { output[key] = getText.getFromKey(obj[key], countryCode); } } return output; }, getFromObjectKeys: function (obj, countryCode) { var key, output = {}; for(key in obj) { if (obj.hasOwnProperty(key)) { output[getText.getFromKey(key, countryCode)] = obj[key]; } } return output; }, getFromArray: function (arr, countryCode) { var output = []; for (var i=0; i < arr.length; i++){ if (i in arr) { output[i] = getText.getFromKey(arr[i], countryCode); } } return output; }, buildFromDefault: function (key) { var output, length, split, last; switch(key) { case "name": output = "en-US"; break; case "englishName": output = "English (United States)"; break; case "nativeName": output = "English (United States)"; break; case "twoDigitYearMax": output = 2049; break; case "firstDayOfWeek": output = 0; break; default: output = key; split = key.split("_"); length = split.length; if (length > 1 && key.charAt(0) !== "/") { // if the key isn't a regex and it has a split. last = split[(length - 1)].toLowerCase(); if (last === "initial" || last === "abbr") { output = split[0]; } } break; } return output; }, buildFromRegex: function (key, countryCode) { var output; if (Date.CultureStrings && Date.CultureStrings[countryCode] && Date.CultureStrings[countryCode][key]) { output = new RegExp(Date.CultureStrings[countryCode][key], "i"); } else { output = new RegExp(key.replace(new RegExp("/", "g"),""), "i"); } return output; } }; var shallowMerge = function (obj1, obj2) { for (var attrname in obj2) { if (obj2.hasOwnProperty(attrname)) { obj1[attrname] = obj2[attrname]; } } }; var __ = function (key, language) { var countryCode = (language) ? language : lang; loggedKeys[key] = key; if (typeof key === "object") { if (key instanceof Array) { return getText.getFromArray(key, countryCode); } else { return getText.getFromObjectKeys(key, countryCode); } } else { return getText.getFromKey(key, countryCode); } }; var loadI18nScript = function (code) { // paatterned after jQuery's getScript. var url = Date.Config.i18n + code + ".js"; var head = document.getElementsByTagName("head")[0] || document.documentElement; var script = document.createElement("script"); script.src = url; var completed = false; var events = { done: function (){} // placeholder function }; // Attach handlers for all browsers script.onload = script.onreadystatechange = function() { if ( !completed && (!this.readyState || this.readyState === "loaded" || this.readyState === "complete") ) { events.done(); head.removeChild(script); } }; setTimeout(function() { head.insertBefore(script, head.firstChild); }, 0); // allows return to execute first return { done: function (cb) { events.done = function() { if (cb) { setTimeout(cb,0); } }; } }; }; var buildInfo = { buildFromMethodHash: function (obj) { var key; for(key in obj) { if (obj.hasOwnProperty(key)) { obj[key] = buildInfo[obj[key]](); } } return obj; }, timeZoneDST: function () { var DST = { "CHADT": "+1345", "NZDT": "+1300", "AEDT": "+1100", "ACDT": "+1030", "AZST": "+0500", "IRDT": "+0430", "EEST": "+0300", "CEST": "+0200", "BST": "+0100", "PMDT": "-0200", "ADT": "-0300", "NDT": "-0230", "EDT": "-0400", "CDT": "-0500", "MDT": "-0600", "PDT": "-0700", "AKDT": "-0800", "HADT": "-0900" }; return __(DST); }, timeZoneStandard: function () { var standard = { "LINT": "+1400", "TOT": "+1300", "CHAST": "+1245", "NZST": "+1200", "NFT": "+1130", "SBT": "+1100", "AEST": "+1000", "ACST": "+0930", "JST": "+0900", "CWST": "+0845", "CT": "+0800", "ICT": "+0700", "MMT": "+0630", "BST": "+0600", "NPT": "+0545", "IST": "+0530", "PKT": "+0500", "AFT": "+0430", "MSK": "+0400", "IRST": "+0330", "FET": "+0300", "EET": "+0200", "CET": "+0100", "GMT": "+0000", "UTC": "+0000", "CVT": "-0100", "GST": "-0200", "BRT": "-0300", "NST": "-0330", "AST": "-0400", "EST": "-0500", "CST": "-0600", "MST": "-0700", "PST": "-0800", "AKST": "-0900", "MIT": "-0930", "HST": "-1000", "SST": "-1100", "BIT": "-1200" }; return __(standard); }, timeZones: function (data) { var zone; data.timezones = []; for (zone in data.abbreviatedTimeZoneStandard) { if (data.abbreviatedTimeZoneStandard.hasOwnProperty(zone)) { data.timezones.push({ name: zone, offset: data.abbreviatedTimeZoneStandard[zone]}); } } for (zone in data.abbreviatedTimeZoneDST) { if (data.abbreviatedTimeZoneDST.hasOwnProperty(zone)) { data.timezones.push({ name: zone, offset: data.abbreviatedTimeZoneDST[zone], dst: true}); } } return data.timezones; }, days: function () { return __(["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"]); }, dayAbbr: function () { return __(["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"]); }, dayShortNames: function () { return __(["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"]); }, dayFirstLetters: function () { return __(["S_Sun_Initial", "M_Mon_Initial", "T_Tues_Initial", "W_Wed_Initial", "T_Thu_Initial", "F_Fri_Initial", "S_Sat_Initial"]); }, months: function () { return __(["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"]); }, monthAbbr: function () { return __(["Jan_Abbr", "Feb_Abbr", "Mar_Abbr", "Apr_Abbr", "May_Abbr", "Jun_Abbr", "Jul_Abbr", "Aug_Abbr", "Sep_Abbr", "Oct_Abbr", "Nov_Abbr", "Dec_Abbr"]); }, formatPatterns: function () { return getText.getFromObjectValues({ shortDate: "M/d/yyyy", longDate: "dddd, MMMM dd, yyyy", shortTime: "h:mm tt", longTime: "h:mm:ss tt", fullDateTime: "dddd, MMMM dd, yyyy h:mm:ss tt", sortableDateTime: "yyyy-MM-ddTHH:mm:ss", universalSortableDateTime: "yyyy-MM-dd HH:mm:ssZ", rfc1123: "ddd, dd MMM yyyy HH:mm:ss", monthDay: "MMMM dd", yearMonth: "MMMM, yyyy" }, Date.i18n.currentLanguage()); }, regex: function () { return getText.getFromObjectValues({ inTheMorning: "/( in the )(morn(ing)?)\\b/", thisMorning: "/(this )(morn(ing)?)\\b/", amThisMorning: "/(\b\\d(am)? )(this )(morn(ing)?)/", inTheEvening: "/( in the )(even(ing)?)\\b/", thisEvening: "/(this )(even(ing)?)\\b/", pmThisEvening: "/(\b\\d(pm)? )(this )(even(ing)?)/", jan: "/jan(uary)?/", feb: "/feb(ruary)?/", mar: "/mar(ch)?/", apr: "/apr(il)?/", may: "/may/", jun: "/jun(e)?/", jul: "/jul(y)?/", aug: "/aug(ust)?/", sep: "/sep(t(ember)?)?/", oct: "/oct(ober)?/", nov: "/nov(ember)?/", dec: "/dec(ember)?/", sun: "/^su(n(day)?)?/", mon: "/^mo(n(day)?)?/", tue: "/^tu(e(s(day)?)?)?/", wed: "/^we(d(nesday)?)?/", thu: "/^th(u(r(s(day)?)?)?)?/", fri: "/fr(i(day)?)?/", sat: "/^sa(t(urday)?)?/", future: "/^next/", past: "/^last|past|prev(ious)?/", add: "/^(\\+|aft(er)?|from|hence)/", subtract: "/^(\\-|bef(ore)?|ago)/", yesterday: "/^yes(terday)?/", today: "/^t(od(ay)?)?/", tomorrow: "/^tom(orrow)?/", now: "/^n(ow)?/", millisecond: "/^ms|milli(second)?s?/", second: "/^sec(ond)?s?/", minute: "/^mn|min(ute)?s?/", hour: "/^h(our)?s?/", week: "/^w(eek)?s?/", month: "/^m(onth)?s?/", day: "/^d(ay)?s?/", year: "/^y(ear)?s?/", shortMeridian: "/^(a|p)/", longMeridian: "/^(a\\.?m?\\.?|p\\.?m?\\.?)/", timezone: "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/", ordinalSuffix: "/^\\s*(st|nd|rd|th)/", timeContext: "/^\\s*(\\:|a(?!u|p)|p)/" }, Date.i18n.currentLanguage()); } }; var CultureInfo = function () { var info = getText.getFromObjectValues({ name: "name", englishName: "englishName", nativeName: "nativeName", amDesignator: "AM", pmDesignator: "PM", firstDayOfWeek: "firstDayOfWeek", twoDigitYearMax: "twoDigitYearMax", dateElementOrder: "mdy" }, Date.i18n.currentLanguage()); var constructedInfo = buildInfo.buildFromMethodHash({ dayNames: "days", abbreviatedDayNames: "dayAbbr", shortestDayNames: "dayShortNames", firstLetterDayNames: "dayFirstLetters", monthNames: "months", abbreviatedMonthNames: "monthAbbr", formatPatterns: "formatPatterns", regexPatterns: "regex", abbreviatedTimeZoneDST: "timeZoneDST", abbreviatedTimeZoneStandard: "timeZoneStandard" }); shallowMerge(info, constructedInfo); buildInfo.timeZones(info); return info; }; $D.i18n = { __: function (key, lang) { return __(key, lang); }, currentLanguage: function () { return lang || "en-US"; }, setLanguage: function (code, force, cb) { var async = false; if (force || code === "en-US" || (!!Date.CultureStrings && !!Date.CultureStrings[code])) { lang = code; Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings.lang = code; Date.CultureInfo = new CultureInfo(); } else { if (!(!!Date.CultureStrings && !!Date.CultureStrings[code])) { if (typeof exports !== "undefined" && this.exports !== exports) { // we're in a Node enviroment, load it using require try { require("../i18n/" + code + ".js"); lang = code; Date.CultureStrings.lang = code; Date.CultureInfo = new CultureInfo(); } catch (e) { // var str = "The language for '" + code + "' could not be loaded by Node. It likely does not exist."; throw new Error("The DateJS IETF language tag '" + code + "' could not be loaded by Node. It likely does not exist."); } } else if (Date.Config && Date.Config.i18n) { // we know the location of the files, so lets load them async = true; loadI18nScript(code).done(function(){ lang = code; Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings.lang = code; Date.CultureInfo = new CultureInfo(); $D.Parsing.Normalizer.buildReplaceData(); // because this is async if ($D.Grammar) { $D.Grammar.buildGrammarFormats(); // so we can parse those strings... } if (cb) { setTimeout(cb,0); } }); } else { Date.console.error("The DateJS IETF language tag '" + code + "' is not available and has not been loaded."); return false; } } } $D.Parsing.Normalizer.buildReplaceData(); // rebuild normalizer strings if ($D.Grammar) { $D.Grammar.buildGrammarFormats(); // so we can parse those strings... } if (!async && cb) { setTimeout(cb,0); } }, getLoggedKeys: function () { return loggedKeys; }, updateCultureInfo: function () { Date.CultureInfo = new CultureInfo(); } }; $D.i18n.updateCultureInfo(); // run automatically }()); (function () { var $D = Date, $P = $D.prototype, p = function (s, l) { if (!l) { l = 2; } return ("000" + s).slice(l * -1); }; if (typeof window !== "undefined" && typeof window.console !== "undefined" && typeof window.console.log !== "undefined") { $D.console = console; // used only to raise non-critical errors if available } else { // set mock so we don't give errors. $D.console = { log: function(){}, error: function(){} }; } $D.Config = $D.Config || {}; $D.initOverloads = function() { /** * Overload of Date.now. Allows an alternate call for Date.now where it returns the * current Date as an object rather than just milliseconds since the Unix Epoch. * * Also provides an implementation of now() for browsers (IE<9) that don't have it. * * Backwards compatible so with work with either: * Date.now() [returns ms] * or * Date.now(true) [returns Date] */ if (!$D.now) { $D._now = function now() { return new Date().getTime(); }; } else if (!$D._now) { $D._now = $D.now; } $D.now = function (returnObj) { if (returnObj) { return $D.present(); } else { return $D._now(); } }; if ( !$P.toISOString ) { $P.toISOString = function() { return this.getUTCFullYear() + "-" + p(this.getUTCMonth() + 1) + "-" + p(this.getUTCDate()) + "T" + p(this.getUTCHours()) + ":" + p(this.getUTCMinutes()) + ":" + p(this.getUTCSeconds()) + "." + String( (this.getUTCMilliseconds()/1000).toFixed(3)).slice(2, 5) + "Z"; }; } // private if ( $P._toString === undefined ){ $P._toString = $P.toString; } }; $D.initOverloads(); /** * Gets a date that is set to the current date. The time is set to the start of the day (00:00 or 12:00 AM). * @return {Date} The current date. */ $D.today = function () { return new Date().clearTime(); }; /** * Gets a date that is set to the current date and time (same as new Date, but chainable) * @return {Date} The current date. */ $D.present = function () { return new Date(); }; /** * Compares the first date to the second date and returns an number indication of their relative values. * @param {Date} First Date object to compare [Required]. * @param {Date} Second Date object to compare to [Required]. * @return {Number} -1 = date1 is lessthan date2. 0 = values are equal. 1 = date1 is greaterthan date2. */ $D.compare = function (date1, date2) { if (isNaN(date1) || isNaN(date2)) { throw new Error(date1 + " - " + date2); } else if (date1 instanceof Date && date2 instanceof Date) { return (date1 < date2) ? -1 : (date1 > date2) ? 1 : 0; } else { throw new TypeError(date1 + " - " + date2); } }; /** * Compares the first Date object to the second Date object and returns true if they are equal. * @param {Date} First Date object to compare [Required] * @param {Date} Second Date object to compare to [Required] * @return {Boolean} true if dates are equal. false if they are not equal. */ $D.equals = function (date1, date2) { return (date1.compareTo(date2) === 0); }; /** * Gets the language appropriate day name when given the day number(0-6) * eg - 0 == Sunday * @return {String} The day name */ $D.getDayName = function (n) { return Date.CultureInfo.dayNames[n]; }; /** * Gets the day number (0-6) if given a CultureInfo specific string which is a valid dayName, abbreviatedDayName or shortestDayName (two char). * @param {String} The name of the day (eg. "Monday, "Mon", "tuesday", "tue", "We", "we"). * @return {Number} The day number */ $D.getDayNumberFromName = function (name) { var n = Date.CultureInfo.dayNames, m = Date.CultureInfo.abbreviatedDayNames, o = Date.CultureInfo.shortestDayNames, s = name.toLowerCase(); for (var i = 0; i < n.length; i++) { if (n[i].toLowerCase() === s || m[i].toLowerCase() === s || o[i].toLowerCase() === s) { return i; } } return -1; }; /** * Gets the month number (0-11) if given a Culture Info specific string which is a valid monthName or abbreviatedMonthName. * @param {String} The name of the month (eg. "February, "Feb", "october", "oct"). * @return {Number} The day number */ $D.getMonthNumberFromName = function (name) { var n = Date.CultureInfo.monthNames, m = Date.CultureInfo.abbreviatedMonthNames, s = name.toLowerCase(); for (var i = 0; i < n.length; i++) { if (n[i].toLowerCase() === s || m[i].toLowerCase() === s) { return i; } } return -1; }; /** * Gets the language appropriate month name when given the month number(0-11) * eg - 0 == January * @return {String} The month name */ $D.getMonthName = function (n) { return Date.CultureInfo.monthNames[n]; }; /** * Determines if the current date instance is within a LeapYear. * @param {Number} The year. * @return {Boolean} true if date is within a LeapYear, otherwise false. */ $D.isLeapYear = function (year) { return ((year % 4 === 0 && year % 100 !== 0) || year % 400 === 0); }; /** * Gets the number of days in the month, given a year and month value. Automatically corrects for LeapYear. * @param {Number} The year. * @param {Number} The month (0-11). * @return {Number} The number of days in the month. */ $D.getDaysInMonth = function (year, month) { if (!month && $D.validateMonth(year)) { month = year; year = Date.today().getFullYear(); } return [31, ($D.isLeapYear(year) ? 29 : 28), 31, 30, 31, 30, 31, 31, 30, 31, 30, 31][month]; }; $P.getDaysInMonth = function () { return $D.getDaysInMonth(this.getFullYear(), this.getMonth()); }; $D.getTimezoneAbbreviation = function (offset, dst) { var p, n = (dst || false) ? Date.CultureInfo.abbreviatedTimeZoneDST : Date.CultureInfo.abbreviatedTimeZoneStandard; for (p in n) { if (n.hasOwnProperty(p)) { if (n[p] === offset) { return p; } } } return null; }; $D.getTimezoneOffset = function (name, dst) { var i, a =[], z = Date.CultureInfo.timezones; if (!name) { name = (new Date()).getTimezone();} for (i = 0; i < z.length; i++) { if (z[i].name === name.toUpperCase()) { a.push(i); } } if (!z[a[0]]) { return null; } if (a.length === 1 || !dst) { return z[a[0]].offset; } else { for (i=0; i < a.length; i++) { if (z[a[i]].dst) { return z[a[i]].offset; } } } }; $D.getQuarter = function (d) { d = d || new Date(); // If no date supplied, use today var q = [1,2,3,4]; return q[Math.floor(d.getMonth() / 3)]; // ~~~ is a bitwise op. Faster than Math.floor }; $D.getDaysLeftInQuarter = function (d) { d = d || new Date(); var qEnd = new Date(d); qEnd.setMonth(qEnd.getMonth() + 3 - qEnd.getMonth() % 3, 0); return Math.floor((qEnd - d) / 8.64e7); }; // private var validate = function (n, min, max, name) { name = name ? name : "Object"; if (typeof n === "undefined") { return false; } else if (typeof n !== "number") { throw new TypeError(n + " is not a Number."); } else if (n < min || n > max) { // As failing validation is *not* an exceptional circumstance // lets not throw a RangeError Exception here. // It's semantically correct but it's not sensible. return false; } return true; }; /** * Validates the number is within an acceptable range for milliseconds [0-999]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateMillisecond = function (value) { return validate(value, 0, 999, "millisecond"); }; /** * Validates the number is within an acceptable range for seconds [0-59]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateSecond = function (value) { return validate(value, 0, 59, "second"); }; /** * Validates the number is within an acceptable range for minutes [0-59]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateMinute = function (value) { return validate(value, 0, 59, "minute"); }; /** * Validates the number is within an acceptable range for hours [0-23]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateHour = function (value) { return validate(value, 0, 23, "hour"); }; /** * Validates the number is within an acceptable range for the days in a month [0-MaxDaysInMonth]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateDay = function (value, year, month) { if (year === undefined || year === null || month === undefined || month === null) { return false;} return validate(value, 1, $D.getDaysInMonth(year, month), "day"); }; /** * Validates the number is within an acceptable range for months [0-11]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateWeek = function (value) { return validate(value, 0, 53, "week"); }; /** * Validates the number is within an acceptable range for months [0-11]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateMonth = function (value) { return validate(value, 0, 11, "month"); }; /** * Validates the number is within an acceptable range for years. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateYear = function (value) { /** * Per ECMAScript spec the range of times supported by Date objects is * exactly -100,000,000 days to +100,000,000 days measured relative to * midnight at the beginning of 01 January, 1970 UTC. * This gives a range of 8,640,000,000,000,000 milliseconds to either * side of 01 January, 1970 UTC. * * Earliest possible date: Tue, 20 Apr 271,822 B.C. 00:00:00 UTC * Latest possible date: Sat, 13 Sep 275,760 00:00:00 UTC */ return validate(value, -271822, 275760, "year"); }; $D.validateTimezone = function(value) { var timezones = {"ACDT":1,"ACST":1,"ACT":1,"ADT":1,"AEDT":1,"AEST":1,"AFT":1,"AKDT":1,"AKST":1,"AMST":1,"AMT":1,"ART":1,"AST":1,"AWDT":1,"AWST":1,"AZOST":1,"AZT":1,"BDT":1,"BIOT":1,"BIT":1,"BOT":1,"BRT":1,"BST":1,"BTT":1,"CAT":1,"CCT":1,"CDT":1,"CEDT":1,"CEST":1,"CET":1,"CHADT":1,"CHAST":1,"CHOT":1,"ChST":1,"CHUT":1,"CIST":1,"CIT":1,"CKT":1,"CLST":1,"CLT":1,"COST":1,"COT":1,"CST":1,"CT":1,"CVT":1,"CWST":1,"CXT":1,"DAVT":1,"DDUT":1,"DFT":1,"EASST":1,"EAST":1,"EAT":1,"ECT":1,"EDT":1,"EEDT":1,"EEST":1,"EET":1,"EGST":1,"EGT":1,"EIT":1,"EST":1,"FET":1,"FJT":1,"FKST":1,"FKT":1,"FNT":1,"GALT":1,"GAMT":1,"GET":1,"GFT":1,"GILT":1,"GIT":1,"GMT":1,"GST":1,"GYT":1,"HADT":1,"HAEC":1,"HAST":1,"HKT":1,"HMT":1,"HOVT":1,"HST":1,"ICT":1,"IDT":1,"IOT":1,"IRDT":1,"IRKT":1,"IRST":1,"IST":1,"JST":1,"KGT":1,"KOST":1,"KRAT":1,"KST":1,"LHST":1,"LINT":1,"MAGT":1,"MART":1,"MAWT":1,"MDT":1,"MET":1,"MEST":1,"MHT":1,"MIST":1,"MIT":1,"MMT":1,"MSK":1,"MST":1,"MUT":1,"MVT":1,"MYT":1,"NCT":1,"NDT":1,"NFT":1,"NPT":1,"NST":1,"NT":1,"NUT":1,"NZDT":1,"NZST":1,"OMST":1,"ORAT":1,"PDT":1,"PET":1,"PETT":1,"PGT":1,"PHOT":1,"PHT":1,"PKT":1,"PMDT":1,"PMST":1,"PONT":1,"PST":1,"PYST":1,"PYT":1,"RET":1,"ROTT":1,"SAKT":1,"SAMT":1,"SAST":1,"SBT":1,"SCT":1,"SGT":1,"SLST":1,"SRT":1,"SST":1,"SYOT":1,"TAHT":1,"THA":1,"TFT":1,"TJT":1,"TKT":1,"TLT":1,"TMT":1,"TOT":1,"TVT":1,"UCT":1,"ULAT":1,"UTC":1,"UYST":1,"UYT":1,"UZT":1,"VET":1,"VLAT":1,"VOLT":1,"VOST":1,"VUT":1,"WAKT":1,"WAST":1,"WAT":1,"WEDT":1,"WEST":1,"WET":1,"WST":1,"YAKT":1,"YEKT":1,"Z":1}; return (timezones[value] === 1); }; $D.validateTimezoneOffset= function(value) { // timezones go from +14hrs to -12hrs, the +X hours are negative offsets. return (value > -841 && value < 721); }; }()); (function () { var $D = Date, $P = $D.prototype, p = function (s, l) { if (!l) { l = 2; } return ("000" + s).slice(l * -1); }; var validateConfigObject = function (obj) { var result = {}, self = this, prop, testFunc; testFunc = function (prop, func, value) { if (prop === "day") { var month = (obj.month !== undefined) ? obj.month : self.getMonth(); var year = (obj.year !== undefined) ? obj.year : self.getFullYear(); return $D[func](value, year, month); } else { return $D[func](value); } }; for (prop in obj) { if (Object.prototype.hasOwnProperty.call(obj, prop)) { var func = "validate" + prop.charAt(0).toUpperCase() + prop.slice(1); if ($D[func] && obj[prop] !== null && testFunc(prop, func, obj[prop])) { result[prop] = obj[prop]; } } } return result; }; /** * Resets the time of this Date object to 12:00 AM (00:00), which is the start of the day. * @param {Boolean} .clone() this date instance before clearing Time * @return {Date} this */ $P.clearTime = function () { this.setHours(0); this.setMinutes(0); this.setSeconds(0); this.setMilliseconds(0); return this; }; /** * Resets the time of this Date object to the current time ('now'). * @return {Date} this */ $P.setTimeToNow = function () { var n = new Date(); this.setHours(n.getHours()); this.setMinutes(n.getMinutes()); this.setSeconds(n.getSeconds()); this.setMilliseconds(n.getMilliseconds()); return this; }; /** * Returns a new Date object that is an exact date and time copy of the original instance. * @return {Date} A new Date instance */ $P.clone = function () { return new Date(this.getTime()); }; /** * Compares this instance to a Date object and returns an number indication of their relative values. * @param {Date} Date object to compare [Required] * @return {Number} -1 = this is lessthan date. 0 = values are equal. 1 = this is greaterthan date. */ $P.compareTo = function (date) { return Date.compare(this, date); }; /** * Compares this instance to another Date object and returns true if they are equal. * @param {Date} Date object to compare. If no date to compare, new Date() [now] is used. * @return {Boolean} true if dates are equal. false if they are not equal. */ $P.equals = function (date) { return Date.equals(this, (date !== undefined ? date : new Date())); }; /** * Determines if this instance is between a range of two dates or equal to either the start or end dates. * @param {Date} Start of range [Required] * @param {Date} End of range [Required] * @return {Boolean} true is this is between or equal to the start and end dates, else false */ $P.between = function (start, end) { return this.getTime() >= start.getTime() && this.getTime() <= end.getTime(); }; /** * Determines if this date occurs after the date to compare to. * @param {Date} Date object to compare. If no date to compare, new Date() ("now") is used. * @return {Boolean} true if this date instance is greater than the date to compare to (or "now"), otherwise false. */ $P.isAfter = function (date) { return this.compareTo(date || new Date()) === 1; }; /** * Determines if this date occurs before the date to compare to. * @param {Date} Date object to compare. If no date to compare, new Date() ("now") is used. * @return {Boolean} true if this date instance is less than the date to compare to (or "now"). */ $P.isBefore = function (date) { return (this.compareTo(date || new Date()) === -1); }; /** * Determines if the current Date instance occurs today. * @return {Boolean} true if this date instance is 'today', otherwise false. */ /** * Determines if the current Date instance occurs on the same Date as the supplied 'date'. * If no 'date' to compare to is provided, the current Date instance is compared to 'today'. * @param {date} Date object to compare. If no date to compare, the current Date ("now") is used. * @return {Boolean} true if this Date instance occurs on the same Day as the supplied 'date'. */ $P.isToday = $P.isSameDay = function (date) { return this.clone().clearTime().equals((date || new Date()).clone().clearTime()); }; /** * Adds the specified number of milliseconds to this instance. * @param {Number} The number of milliseconds to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addMilliseconds = function (value) { if (!value) { return this; } this.setTime(this.getTime() + value * 1); return this; }; /** * Adds the specified number of seconds to this instance. * @param {Number} The number of seconds to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addSeconds = function (value) { if (!value) { return this; } return this.addMilliseconds(value * 1000); }; /** * Adds the specified number of seconds to this instance. * @param {Number} The number of seconds to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addMinutes = function (value) { if (!value) { return this; } return this.addMilliseconds(value * 60000); // 60*1000 }; /** * Adds the specified number of hours to this instance. * @param {Number} The number of hours to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addHours = function (value) { if (!value) { return this; } return this.addMilliseconds(value * 3600000); // 60*60*1000 }; /** * Adds the specified number of days to this instance. * @param {Number} The number of days to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addDays = function (value) { if (!value) { return this; } this.setDate(this.getDate() + value * 1); return this; }; /** * Adds the specified number of weekdays (ie - not sat or sun) to this instance. * @param {Number} The number of days to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addWeekdays = function (value) { if (!value) { return this; } var day = this.getDay(); var weeks = (Math.ceil(Math.abs(value)/7)); if (day === 0 || day === 6) { if (value > 0) { this.next().monday(); this.addDays(-1); day = this.getDay(); } } if (value < 0) { while (value < 0) { this.addDays(-1); day = this.getDay(); if (day !== 0 && day !== 6) { value++; } } return this; } else if (value > 5 || (6-day) <= value) { value = value + (weeks * 2); } return this.addDays(value); }; /** * Adds the specified number of weeks to this instance. * @param {Number} The number of weeks to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addWeeks = function (value) { if (!value) { return this; } return this.addDays(value * 7); }; /** * Adds the specified number of months to this instance. * @param {Number} The number of months to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addMonths = function (value) { if (!value) { return this; } var n = this.getDate(); this.setDate(1); this.setMonth(this.getMonth() + value * 1); this.setDate(Math.min(n, $D.getDaysInMonth(this.getFullYear(), this.getMonth()))); return this; }; $P.addQuarters = function (value) { if (!value) { return this; } // note this will take you to the same point in the quarter as you are now. // i.e. - if you are 15 days into the quarter you'll be 15 days into the resulting one. // bonus: this allows adding fractional quarters return this.addMonths(value * 3); }; /** * Adds the specified number of years to this instance. * @param {Number} The number of years to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addYears = function (value) { if (!value) { return this; } return this.addMonths(value * 12); }; /** * Adds (or subtracts) to the value of the years, months, weeks, days, hours, minutes, seconds, milliseconds of the date instance using given configuration object. Positive and Negative values allowed. * Example

	Date.today().add( { days: 1, months: 1 } )

	new Date().add( { years: -1 } )
	
* @param {Object} Configuration object containing attributes (months, days, etc.) * @return {Date} this */ $P.add = function (config) { if (typeof config === "number") { this._orient = config; return this; } var x = config; if (x.day) { // If we should be a different date than today (eg: for 'tomorrow -1d', etc). // Should only effect parsing, not direct usage (eg, Finish and FinishExact) if ((x.day - this.getDate()) !== 0) { this.setDate(x.day); } } if (x.milliseconds) { this.addMilliseconds(x.milliseconds); } if (x.seconds) { this.addSeconds(x.seconds); } if (x.minutes) { this.addMinutes(x.minutes); } if (x.hours) { this.addHours(x.hours); } if (x.weeks) { this.addWeeks(x.weeks); } if (x.months) { this.addMonths(x.months); } if (x.years) { this.addYears(x.years); } if (x.days) { this.addDays(x.days); } return this; }; /** * Get the week number. Week one (1) is the week which contains the first Thursday of the year. Monday is considered the first day of the week. * The .getWeek() function does NOT convert the date to UTC. The local datetime is used. * Please use .getISOWeek() to get the week of the UTC converted date. * @return {Number} 1 to 53 */ $P.getWeek = function (utc) { // Create a copy of this date object var self, target = new Date(this.valueOf()); if (utc) { target.addMinutes(target.getTimezoneOffset()); self = target.clone(); } else { self = this; } // ISO week date weeks start on monday // so correct the day number var dayNr = (self.getDay() + 6) % 7; // ISO 8601 states that week 1 is the week // with the first thursday of that year. // Set the target date to the thursday in the target week target.setDate(target.getDate() - dayNr + 3); // Store the millisecond value of the target date var firstThursday = target.valueOf(); // Set the target to the first thursday of the year // First set the target to january first target.setMonth(0, 1); // Not a thursday? Correct the date to the next thursday if (target.getDay() !== 4) { target.setMonth(0, 1 + ((4 - target.getDay()) + 7) % 7); } // The weeknumber is the number of weeks between the // first thursday of the year and the thursday in the target week return 1 + Math.ceil((firstThursday - target) / 604800000); // 604800000 = 7 * 24 * 3600 * 1000 }; /** * Get the ISO 8601 week number. Week one ("01") is the week which contains the first Thursday of the year. Monday is considered the first day of the week. * The .getISOWeek() function does convert the date to it's UTC value. Please use .getWeek() to get the week of the local date. * @return {String} "01" to "53" */ $P.getISOWeek = function () { return p(this.getWeek(true)); }; /** * Moves the date to Monday of the week set. Week one (1) is the week which contains the first Thursday of the year. * @param {Number} A Number (1 to 53) that represents the week of the year. * @return {Date} this */ $P.setWeek = function (n) { if ((n - this.getWeek()) === 0) { if (this.getDay() !== 1) { return this.moveToDayOfWeek(1, (this.getDay() > 1 ? -1 : 1)); } else { return this; } } else { return this.moveToDayOfWeek(1, (this.getDay() > 1 ? -1 : 1)).addWeeks(n - this.getWeek()); } }; $P.setQuarter = function (qtr) { var month = Math.abs(((qtr-1) * 3) + 1); return this.setMonth(month, 1); }; $P.getQuarter = function () { return Date.getQuarter(this); }; $P.getDaysLeftInQuarter = function () { return Date.getDaysLeftInQuarter(this); }; /** * Moves the date to the next n'th occurrence of the dayOfWeek starting from the beginning of the month. The number (-1) is a magic number and will return the last occurrence of the dayOfWeek in the month. * @param {Number} The dayOfWeek to move to * @param {Number} The n'th occurrence to move to. Use (-1) to return the last occurrence in the month * @return {Date} this */ $P.moveToNthOccurrence = function (dayOfWeek, occurrence) { if (dayOfWeek === "Weekday") { if (occurrence > 0) { this.moveToFirstDayOfMonth(); if (this.is().weekday()) { occurrence -= 1; } } else if (occurrence < 0) { this.moveToLastDayOfMonth(); if (this.is().weekday()) { occurrence += 1; } } else { return this; } return this.addWeekdays(occurrence); } var shift = 0; if (occurrence > 0) { shift = occurrence - 1; } else if (occurrence === -1) { this.moveToLastDayOfMonth(); if (this.getDay() !== dayOfWeek) { this.moveToDayOfWeek(dayOfWeek, -1); } return this; } return this.moveToFirstDayOfMonth().addDays(-1).moveToDayOfWeek(dayOfWeek, +1).addWeeks(shift); }; var moveToN = function (getFunc, addFunc, nVal) { return function (value, orient) { var diff = (value - this[getFunc]() + nVal * (orient || +1)) % nVal; return this[addFunc]((diff === 0) ? diff += nVal * (orient || +1) : diff); }; }; /** * Move to the next or last dayOfWeek based on the orient value. * @param {Number} The dayOfWeek to move to * @param {Number} Forward (+1) or Back (-1). Defaults to +1. [Optional] * @return {Date} this */ $P.moveToDayOfWeek = moveToN("getDay", "addDays", 7); /** * Move to the next or last month based on the orient value. * @param {Number} The month to move to. 0 = January, 11 = December * @param {Number} Forward (+1) or Back (-1). Defaults to +1. [Optional] * @return {Date} this */ $P.moveToMonth = moveToN("getMonth", "addMonths", 12); /** * Get the Ordinate of the current day ("th", "st", "rd"). * @return {String} */ $P.getOrdinate = function () { var num = this.getDate(); return ord(num); }; /** * Get the Ordinal day (numeric day number) of the year, adjusted for leap year. * @return {Number} 1 through 365 (366 in leap years) */ $P.getOrdinalNumber = function () { return Math.ceil((this.clone().clearTime() - new Date(this.getFullYear(), 0, 1)) / 86400000) + 1; }; /** * Get the time zone abbreviation of the current date. * @return {String} The abbreviated time zone name (e.g. "EST") */ $P.getTimezone = function () { return $D.getTimezoneAbbreviation(this.getUTCOffset(), this.isDaylightSavingTime()); }; $P.setTimezoneOffset = function (offset) { var here = this.getTimezoneOffset(), there = Number(offset) * -6 / 10; return (there || there === 0) ? this.addMinutes(there - here) : this; }; $P.setTimezone = function (offset) { return this.setTimezoneOffset($D.getTimezoneOffset(offset)); }; /** * Indicates whether Daylight Saving Time is observed in the current time zone. * @return {Boolean} true|false */ $P.hasDaylightSavingTime = function () { return (Date.today().set({month: 0, day: 1}).getTimezoneOffset() !== Date.today().set({month: 6, day: 1}).getTimezoneOffset()); }; /** * Indicates whether this Date instance is within the Daylight Saving Time range for the current time zone. * @return {Boolean} true|false */ $P.isDaylightSavingTime = function () { return Date.today().set({month: 0, day: 1}).getTimezoneOffset() !== this.getTimezoneOffset(); }; /** * Get the offset from UTC of the current date. * @return {String} The 4-character offset string prefixed with + or - (e.g. "-0500") */ $P.getUTCOffset = function (offset) { var n = (offset || this.getTimezoneOffset()) * -10 / 6, r; if (n < 0) { r = (n - 10000).toString(); return r.charAt(0) + r.substr(2); } else { r = (n + 10000).toString(); return "+" + r.substr(1); } }; /** * Returns the number of milliseconds between this date and date. * @param {Date} Defaults to now * @return {Number} The diff in milliseconds */ $P.getElapsed = function (date) { return (date || new Date()) - this; }; /** * Set the value of year, month, day, hour, minute, second, millisecond of date instance using given configuration object. * Example

	Date.today().set( { day: 20, month: 1 } )

	new Date().set( { millisecond: 0 } )
	
* * @param {Object} Configuration object containing attributes (month, day, etc.) * @return {Date} this */ $P.set = function (config) { config = validateConfigObject.call(this, config); var key; for (key in config) { if (Object.prototype.hasOwnProperty.call(config, key)) { var name = key.charAt(0).toUpperCase() + key.slice(1); var addFunc, getFunc; if (key !== "week" && key !== "month" && key !== "timezone" && key !== "timezoneOffset") { name += "s"; } addFunc = "add" + name; getFunc = "get" + name; if (key === "month") { addFunc = addFunc + "s"; } else if (key === "year"){ getFunc = "getFullYear"; } if (key !== "day" && key !== "timezone" && key !== "timezoneOffset" && key !== "week" && key !== "hour") { this[addFunc](config[key] - this[getFunc]()); } else if ( key === "timezone"|| key === "timezoneOffset" || key === "week" || key === "hour") { this["set"+name](config[key]); } } } // day has to go last because you can't validate the day without first knowing the month if (config.day) { this.addDays(config.day - this.getDate()); } return this; }; /** * Moves the date to the first day of the month. * @return {Date} this */ $P.moveToFirstDayOfMonth = function () { return this.set({ day: 1 }); }; /** * Moves the date to the last day of the month. * @return {Date} this */ $P.moveToLastDayOfMonth = function () { return this.set({ day: $D.getDaysInMonth(this.getFullYear(), this.getMonth())}); }; /** * Converts the value of the current Date object to its equivalent string representation. * Format Specifiers * CUSTOM DATE AND TIME FORMAT STRINGS * Format Description Example * ------ --------------------------------------------------------------------------- ----------------------- * s The seconds of the minute between 0-59. "0" to "59" * ss The seconds of the minute with leading zero if required. "00" to "59" * * m The minute of the hour between 0-59. "0" or "59" * mm The minute of the hour with leading zero if required. "00" or "59" * * h The hour of the day between 1-12. "1" to "12" * hh The hour of the day with leading zero if required. "01" to "12" * * H The hour of the day between 0-23. "0" to "23" * HH The hour of the day with leading zero if required. "00" to "23" * * d The day of the month between 1 and 31. "1" to "31" * dd The day of the month with leading zero if required. "01" to "31" * ddd Abbreviated day name. Date.CultureInfo.abbreviatedDayNames. "Mon" to "Sun" * dddd The full day name. Date.CultureInfo.dayNames. "Monday" to "Sunday" * * M The month of the year between 1-12. "1" to "12" * MM The month of the year with leading zero if required. "01" to "12" * MMM Abbreviated month name. Date.CultureInfo.abbreviatedMonthNames. "Jan" to "Dec" * MMMM The full month name. Date.CultureInfo.monthNames. "January" to "December" * * yy The year as a two-digit number. "99" or "08" * yyyy The full four digit year. "1999" or "2008" * * t Displays the first character of the A.M./P.M. designator. "A" or "P" * Date.CultureInfo.amDesignator or Date.CultureInfo.pmDesignator * tt Displays the A.M./P.M. designator. "AM" or "PM" * Date.CultureInfo.amDesignator or Date.CultureInfo.pmDesignator * * S The ordinal suffix ("st, "nd", "rd" or "th") of the current day. "st, "nd", "rd" or "th" * * STANDARD DATE AND TIME FORMAT STRINGS * Format Description Example *------ --------------------------------------------------------------------------- ----------------------- * d The CultureInfo shortDate Format Pattern "M/d/yyyy" * D The CultureInfo longDate Format Pattern "dddd, MMMM dd, yyyy" * F The CultureInfo fullDateTime Format Pattern "dddd, MMMM dd, yyyy h:mm:ss tt" * m The CultureInfo monthDay Format Pattern "MMMM dd" * r The CultureInfo rfc1123 Format Pattern "ddd, dd MMM yyyy HH:mm:ss GMT" * s The CultureInfo sortableDateTime Format Pattern "yyyy-MM-ddTHH:mm:ss" * t The CultureInfo shortTime Format Pattern "h:mm tt" * T The CultureInfo longTime Format Pattern "h:mm:ss tt" * u The CultureInfo universalSortableDateTime Format Pattern "yyyy-MM-dd HH:mm:ssZ" * y The CultureInfo yearMonth Format Pattern "MMMM, yyyy" * * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @return {String} A string representation of the current Date object. */ var ord = function (n) { switch (n * 1) { case 1: case 21: case 31: return "st"; case 2: case 22: return "nd"; case 3: case 23: return "rd"; default: return "th"; } }; var parseStandardFormats = function (format) { var y, c = Date.CultureInfo.formatPatterns; switch (format) { case "d": return this.toString(c.shortDate); case "D": return this.toString(c.longDate); case "F": return this.toString(c.fullDateTime); case "m": return this.toString(c.monthDay); case "r": case "R": y = this.clone().addMinutes(this.getTimezoneOffset()); return y.toString(c.rfc1123) + " GMT"; case "s": return this.toString(c.sortableDateTime); case "t": return this.toString(c.shortTime); case "T": return this.toString(c.longTime); case "u": y = this.clone().addMinutes(this.getTimezoneOffset()); return y.toString(c.universalSortableDateTime); case "y": return this.toString(c.yearMonth); default: return false; } }; var parseFormatStringsClosure = function (context) { return function (m) { if (m.charAt(0) === "\\") { return m.replace("\\", ""); } switch (m) { case "hh": return p(context.getHours() < 13 ? (context.getHours() === 0 ? 12 : context.getHours()) : (context.getHours() - 12)); case "h": return context.getHours() < 13 ? (context.getHours() === 0 ? 12 : context.getHours()) : (context.getHours() - 12); case "HH": return p(context.getHours()); case "H": return context.getHours(); case "mm": return p(context.getMinutes()); case "m": return context.getMinutes(); case "ss": return p(context.getSeconds()); case "s": return context.getSeconds(); case "yyyy": return p(context.getFullYear(), 4); case "yy": return p(context.getFullYear()); case "y": return context.getFullYear(); case "E": case "dddd": return Date.CultureInfo.dayNames[context.getDay()]; case "ddd": return Date.CultureInfo.abbreviatedDayNames[context.getDay()]; case "dd": return p(context.getDate()); case "d": return context.getDate(); case "MMMM": return Date.CultureInfo.monthNames[context.getMonth()]; case "MMM": return Date.CultureInfo.abbreviatedMonthNames[context.getMonth()]; case "MM": return p((context.getMonth() + 1)); case "M": return context.getMonth() + 1; case "t": return context.getHours() < 12 ? Date.CultureInfo.amDesignator.substring(0, 1) : Date.CultureInfo.pmDesignator.substring(0, 1); case "tt": return context.getHours() < 12 ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator; case "S": return ord(context.getDate()); case "W": return context.getWeek(); case "WW": return context.getISOWeek(); case "Q": return "Q" + context.getQuarter(); case "q": return String(context.getQuarter()); case "z": return context.getTimezone(); case "Z": case "X": return Date.getTimezoneOffset(context.getTimezone()); case "ZZ": // Timezone offset in seconds return context.getTimezoneOffset() * -60; case "u": return context.getDay(); case "L": return ($D.isLeapYear(context.getFullYear())) ? 1 : 0; case "B": // Swatch Internet Time (.beats) return "@"+((context.getUTCSeconds() + (context.getUTCMinutes()*60) + ((context.getUTCHours()+1)*3600))/86.4); default: return m; } }; }; $P.toString = function (format, ignoreStandards) { // Standard Date and Time Format Strings. Formats pulled from CultureInfo file and // may vary by culture. if (!ignoreStandards && format && format.length === 1) { output = parseStandardFormats.call(this, format); if (output) { return output; } } var parseFormatStrings = parseFormatStringsClosure(this); return format ? format.replace(/((\\)?(dd?d?d?|MM?M?M?|yy?y?y?|hh?|HH?|mm?|ss?|tt?|S|q|Q|WW?W?W?)(?![^\[]*\]))/g, parseFormatStrings).replace(/\[|\]/g, "") : this._toString(); }; }()); /************************************************************* * SugarPak - Domain Specific Language - Syntactical Sugar * *************************************************************/ (function () { var $D = Date, $P = $D.prototype, $N = Number.prototype; // private $P._orient = +1; // private $P._nth = null; // private $P._is = false; // private $P._same = false; // private $P._isSecond = false; // private $N._dateElement = "days"; /** * Moves the date to the next instance of a date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.today().next().friday();
	Date.today().next().fri();
	Date.today().next().march();
	Date.today().next().mar();
	Date.today().next().week();
	
* * @return {Date} date */ $P.next = function () { this._move = true; this._orient = +1; return this; }; /** * Creates a new Date (Date.today()) and moves the date to the next instance of the date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.next().friday();
	Date.next().fri();
	Date.next().march();
	Date.next().mar();
	Date.next().week();
	
* * @return {Date} date */ $D.next = function () { return $D.today().next(); }; /** * Moves the date to the previous instance of a date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.today().last().friday();
	Date.today().last().fri();
	Date.today().last().march();
	Date.today().last().mar();
	Date.today().last().week();
	
* * @return {Date} date */ $P.last = $P.prev = $P.previous = function () { this._move = true; this._orient = -1; return this; }; /** * Creates a new Date (Date.today()) and moves the date to the previous instance of the date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.last().friday();
	Date.last().fri();
	Date.previous().march();
	Date.prev().mar();
	Date.last().week();
	
* * @return {Date} date */ $D.last = $D.prev = $D.previous = function () { return $D.today().last(); }; /** * Performs a equality check when followed by either a month name, day name or .weekday() function. * Example

	Date.today().is().friday(); // true|false
	Date.today().is().fri();
	Date.today().is().march();
	Date.today().is().mar();
	
* * @return {Boolean} true|false */ $P.is = function () { this._is = true; return this; }; /** * Determines if two date objects occur on/in exactly the same instance of the subsequent date part function. * The function .same() must be followed by a date part function (example: .day(), .month(), .year(), etc). * * An optional Date can be passed in the date part function. If now date is passed as a parameter, 'Now' is used. * * The following example demonstrates how to determine if two dates fall on the exact same day. * * Example

	var d1 = Date.today(); // today at 00:00
	var d2 = new Date();   // exactly now.

	// Do they occur on the same day?
	d1.same().day(d2); // true
	
	// Do they occur on the same hour?
	d1.same().hour(d2); // false, unless d2 hour is '00' (midnight).
	
	// What if it's the same day, but one year apart?
	var nextYear = Date.today().add(1).year();

	d1.same().day(nextYear); // false, because the dates must occur on the exact same day. 
	
* * Scenario: Determine if a given date occurs during some week period 2 months from now. * * Example

	var future = Date.today().add(2).months();
	return someDate.same().week(future); // true|false;
	
* * @return {Boolean} true|false */ $P.same = function () { this._same = true; this._isSecond = false; return this; }; /** * Determines if the current date/time occurs during Today. Must be preceded by the .is() function. * Example

	someDate.is().today();    // true|false
	new Date().is().today();  // true
	Date.today().is().today();// true
	Date.today().add(-1).day().is().today(); // false
	
* * @return {Boolean} true|false */ $P.today = function () { return this.same().day(); }; /** * Determines if the current date is a weekday. This function must be preceded by the .is() function. * Example

	Date.today().is().weekday(); // true|false
	
* * @return {Boolean} true|false */ $P.weekday = function () { if (this._nth) { return df("Weekday").call(this); } if (this._move) { return this.addWeekdays(this._orient); } if (this._is) { this._is = false; return (!this.is().sat() && !this.is().sun()); } return false; }; /** * Determines if the current date is on the weekend. This function must be preceded by the .is() function. * Example

	Date.today().is().weekend(); // true|false
	
* * @return {Boolean} true|false */ $P.weekend = function () { if (this._is) { this._is = false; return (this.is().sat() || this.is().sun()); } return false; }; /** * Sets the Time of the current Date instance. A string "6:15 pm" or config object {hour:18, minute:15} are accepted. * Example

	// Set time to 6:15pm with a String
	Date.today().at("6:15pm");

	// Set time to 6:15pm with a config object
	Date.today().at({hour:18, minute:15});
	
* * @return {Date} date */ $P.at = function (time) { return (typeof time === "string") ? $D.parse(this.toString("d") + " " + time) : this.set(time); }; /** * Creates a new Date() and adds this (Number) to the date based on the preceding date element function (eg. second|minute|hour|day|month|year). * Example

	// Undeclared Numbers must be wrapped with parentheses. Requirment of JavaScript.
	(3).days().fromNow();
	(6).months().fromNow();

	// Declared Number variables do not require parentheses. 
	var n = 6;
	n.months().fromNow();
	
* * @return {Date} A new Date instance */ $N.fromNow = $N.after = function (date) { var c = {}; c[this._dateElement] = this; return ((!date) ? new Date() : date.clone()).add(c); }; /** * Creates a new Date() and subtract this (Number) from the date based on the preceding date element function (eg. second|minute|hour|day|month|year). * Example

	// Undeclared Numbers must be wrapped with parentheses. Requirment of JavaScript.
	(3).days().ago();
	(6).months().ago();

	// Declared Number variables do not require parentheses. 
	var n = 6;
	n.months().ago();
	
* * @return {Date} A new Date instance */ $N.ago = $N.before = function (date) { var c = {}, s = (this._dateElement[this._dateElement.length-1] !== "s") ? this._dateElement + "s" : this._dateElement; c[s] = this * -1; return ((!date) ? new Date() : date.clone()).add(c); }; // Do NOT modify the following string tokens. These tokens are used to build dynamic functions. // All culture-specific strings can be found in the CultureInfo files. var dx = ("sunday monday tuesday wednesday thursday friday saturday").split(/\s/), mx = ("january february march april may june july august september october november december").split(/\s/), px = ("Millisecond Second Minute Hour Day Week Month Year Quarter Weekday").split(/\s/), pxf = ("Milliseconds Seconds Minutes Hours Date Week Month FullYear Quarter").split(/\s/), nth = ("final first second third fourth fifth").split(/\s/), de; /** * Returns an object literal of all the date parts. * Example

	var o = new Date().toObject();
	
	// { year: 2008, month: 4, week: 20, day: 13, hour: 18, minute: 9, second: 32, millisecond: 812 }
	
	// The object properties can be referenced directly from the object.
	
	alert(o.day);  // alerts "13"
	alert(o.year); // alerts "2008"
	
* * @return {Date} An object literal representing the original date object. */ $P.toObject = function () { var o = {}; for (var i = 0; i < px.length; i++) { if (this["get" + pxf[i]]) { o[px[i].toLowerCase()] = this["get" + pxf[i]](); } } return o; }; /** * Returns a date created from an object literal. Ignores the .week property if set in the config. * Example

	var o = new Date().toObject();
	
	return Date.fromObject(o); // will return the same date. 

	var o2 = {month: 1, day: 20, hour: 18}; // birthday party!
	Date.fromObject(o2);
	
* * @return {Date} An object literal representing the original date object. */ $D.fromObject = function(config) { config.week = null; return Date.today().set(config); }; // Create day name functions and abbreviated day name functions (eg. monday(), friday(), fri()). var df = function (n) { return function () { if (this._is) { this._is = false; return this.getDay() === n; } if (this._move) { this._move = null; } if (this._nth !== null) { // If the .second() function was called earlier, remove the _orient // from the date, and then continue. // This is required because 'second' can be used in two different context. // // Example // // Date.today().add(1).second(); // Date.march().second().monday(); // // Things get crazy with the following... // Date.march().add(1).second().second().monday(); // but it works!! // if (this._isSecond) { this.addSeconds(this._orient * -1); } // make sure we reset _isSecond this._isSecond = false; var ntemp = this._nth; this._nth = null; var temp = this.clone().moveToLastDayOfMonth(); this.moveToNthOccurrence(n, ntemp); if (this > temp) { throw new RangeError($D.getDayName(n) + " does not occur " + ntemp + " times in the month of " + $D.getMonthName(temp.getMonth()) + " " + temp.getFullYear() + "."); } return this; } return this.moveToDayOfWeek(n, this._orient); }; }; var sdf = function (n) { return function () { var t = $D.today(), shift = n - t.getDay(); if (n === 0 && Date.CultureInfo.firstDayOfWeek === 1 && t.getDay() !== 0) { shift = shift + 7; } return t.addDays(shift); }; }; // Create month name functions and abbreviated month name functions (eg. january(), march(), mar()). var month_instance_functions = function (n) { return function () { if (this._is) { this._is = false; return this.getMonth() === n; } return this.moveToMonth(n, this._orient); }; }; var month_static_functions = function (n) { return function () { return $D.today().set({ month: n, day: 1 }); }; }; var processTerms = function (names, staticFunc, instanceFunc) { for (var i = 0; i < names.length; i++) { // Create constant static Name variables. $D[names[i].toUpperCase()] = $D[names[i].toUpperCase().substring(0, 3)] = i; // Create Name functions. $D[names[i]] = $D[names[i].substring(0, 3)] = staticFunc(i); // Create Name instance functions. $P[names[i]] = $P[names[i].substring(0, 3)] = instanceFunc(i); } }; processTerms(dx, sdf, df); processTerms(mx, month_static_functions, month_instance_functions); // Create date element functions and plural date element functions used with Date (eg. day(), days(), months()). var ef = function (j) { return function () { // if the .second() function was called earlier, the _orient // has alread been added. Just return this and reset _isSecond. if (this._isSecond) { this._isSecond = false; return this; } if (this._same) { this._same = this._is = false; var o1 = this.toObject(), o2 = (arguments[0] || new Date()).toObject(), v = "", k = j.toLowerCase(); // the substr trick with -1 doesn't work in IE8 or less k = (k[k.length-1] === "s") ? k.substring(0,k.length-1) : k; for (var m = (px.length - 1); m > -1; m--) { v = px[m].toLowerCase(); if (o1[v] !== o2[v]) { return false; } if (k === v) { break; } } return true; } if (j.substring(j.length - 1) !== "s") { j += "s"; } if (this._move) { this._move = null; } return this["add" + j](this._orient); }; }; var nf = function (n) { return function () { this._dateElement = n; return this; }; }; for (var k = 0; k < px.length; k++) { de = px[k].toLowerCase(); if(de !== "weekday") { // Create date element functions and plural date element functions used with Date (eg. day(), days(), months()). $P[de] = $P[de + "s"] = ef(px[k]); // Create date element functions and plural date element functions used with Number (eg. day(), days(), months()). $N[de] = $N[de + "s"] = nf(de + "s"); } } $P._ss = ef("Second"); var nthfn = function (n) { return function (dayOfWeek) { if (this._same) { return this._ss(arguments[0]); } if (dayOfWeek || dayOfWeek === 0) { return this.moveToNthOccurrence(dayOfWeek, n); } this._nth = n; // if the operator is 'second' add the _orient, then deal with it later... if (n === 2 && (dayOfWeek === undefined || dayOfWeek === null)) { this._isSecond = true; return this.addSeconds(this._orient); } return this; }; }; for (var l = 0; l < nth.length; l++) { $P[nth[l]] = (l === 0) ? nthfn(-1) : nthfn(l); } }()); (function () { "use strict"; Date.Parsing = { Exception: function (s) { this.message = "Parse error at '" + s.substring(0, 10) + " ...'"; } }; var $P = Date.Parsing; var dayOffsets = { standard: [0,31,59,90,120,151,181,212,243,273,304,334], leap: [0,31,60,91,121,152,182,213,244,274,305,335] }; $P.isLeapYear = function(year) { return ((year % 4 === 0) && (year % 100 !== 0)) || (year % 400 === 0); }; var utils = { multiReplace : function (str, hash ) { var key; for (key in hash) { if (Object.prototype.hasOwnProperty.call(hash, key)) { var regex; if (typeof hash[key] === "function") { } else { regex = (hash[key] instanceof RegExp) ? hash[key] : new RegExp(hash[key], "g"); } str = str.replace(regex, key); } } return str; }, getDayOfYearFromWeek : function (obj) { var d, jan4, offset; obj.weekDay = (!obj.weekDay && obj.weekDay !== 0) ? 1 : obj.weekDay; d = new Date(obj.year, 0, 4); jan4 = d.getDay() === 0 ? 7 : d.getDay(); // JS is 0 indexed on Sunday. offset = jan4+3; obj.dayOfYear = ((obj.week * 7) + (obj.weekDay === 0 ? 7 : obj.weekDay))-offset; return obj; }, getDayOfYear : function (obj, dayOffset) { if (!obj.dayOfYear) { obj = utils.getDayOfYearFromWeek(obj); } for (var i=0;i <= dayOffset.length;i++) { if (obj.dayOfYear < dayOffset[i] || i === dayOffset.length) { obj.day = obj.day ? obj.day : (obj.dayOfYear - dayOffset[i-1]); break; } else { obj.month = i; } } return obj; }, adjustForTimeZone : function (obj, date) { var offset; if (obj.zone.toUpperCase() === "Z" || (obj.zone_hours === 0 && obj.zone_minutes === 0)) { // it's UTC/GML so work out the current timeszone offset offset = -date.getTimezoneOffset(); } else { offset = (obj.zone_hours*60) + (obj.zone_minutes || 0); if (obj.zone_sign === "+") { offset *= -1; } offset -= date.getTimezoneOffset(); } date.setMinutes(date.getMinutes()+offset); return date; }, setDefaults : function (obj) { obj.year = obj.year || Date.today().getFullYear(); obj.hours = obj.hours || 0; obj.minutes = obj.minutes || 0; obj.seconds = obj.seconds || 0; obj.milliseconds = obj.milliseconds || 0; if (!(!obj.month && (obj.week || obj.dayOfYear))) { // if we have a month, or if we don't but don't have the day calculation data obj.month = obj.month || 0; obj.day = obj.day || 1; } return obj; }, dataNum: function (data, mod, explict, postProcess) { var dataNum = data*1; if (mod) { if (postProcess) { return data ? mod(data)*1 : data; } else { return data ? mod(dataNum) : data; } } else if (!explict){ return data ? dataNum : data; } else { return (data && typeof data !== "undefined") ? dataNum : data; } }, timeDataProcess: function (obj) { var timeObj = {}; for (var x in obj.data) { if (obj.data.hasOwnProperty(x)) { timeObj[x] = obj.ignore[x] ? obj.data[x] : utils.dataNum(obj.data[x], obj.mods[x], obj.explict[x], obj.postProcess[x]); } } if (obj.data.secmins) { obj.data.secmins = obj.data.secmins.replace(",", ".") * 60; if (!timeObj.minutes) { timeObj.minutes = obj.data.secmins; } else if (!timeObj.seconds) { timeObj.seconds = obj.data.secmins; } delete obj.secmins; } return timeObj; }, buildTimeObjectFromData: function (data) { var time = utils.timeDataProcess({ data: { year : data[1], month : data[5], day : data[7], week : data[8], dayOfYear : data[10], hours : data[15], zone_hours : data[23], zone_minutes : data[24], zone : data[21], zone_sign : data[22], weekDay : data[9], minutes: data[16], seconds: data[19], milliseconds: data[20], secmins: data[18] }, mods: { month: function(data) { return data-1; }, weekDay: function (data) { data = Math.abs(data); return (data === 7 ? 0 : data); }, minutes: function (data) { return data.replace(":",""); }, seconds: function (data) { return Math.floor( (data.replace(":","").replace(",","."))*1 ); }, milliseconds: function (data) { return (data.replace(",",".")*1000); } }, postProcess: { minutes: true, seconds: true, milliseconds: true }, explict: { zone_hours: true, zone_minutes: true }, ignore: { zone: true, zone_sign: true, secmins: true } }); return time; }, addToHash: function (hash, keys, data) { keys = keys; data = data; var len = keys.length; for (var i = 0; i < len; i++) { hash[keys[i]] = data[i]; } return hash; }, combineRegex: function (r1, r2) { return new RegExp("(("+r1.source+")\\s("+r2.source+"))"); }, getDateNthString: function(add, last, inc){ if (add) { return Date.today().addDays(inc).toString("d"); } else if (last) { return Date.today().last()[inc]().toString("d"); } }, buildRegexData: function (array) { var arr = []; var len = array.length; for (var i=0; i < len; i++) { if (Object.prototype.toString.call(array[i]) === '[object Array]') { // oldIE compat version of Array.isArray arr.push(this.combineRegex(array[i][0], array[i][1])); } else { arr.push(array[i]); } } return arr; } }; $P.processTimeObject = function (obj) { var date, dayOffset; utils.setDefaults(obj); dayOffset = ($P.isLeapYear(obj.year)) ? dayOffsets.leap : dayOffsets.standard; if (!obj.month && (obj.week || obj.dayOfYear)) { utils.getDayOfYear(obj, dayOffset); } else { obj.dayOfYear = dayOffset[obj.month] + obj.day; } date = new Date(obj.year, obj.month, obj.day, obj.hours, obj.minutes, obj.seconds, obj.milliseconds); if (obj.zone) { utils.adjustForTimeZone(obj, date); // adjust (and calculate) for timezone } return date; }; $P.ISO = { regex : /^([\+-]?\d{4}(?!\d{2}\b))((-?)((0[1-9]|1[0-2])(\3([12]\d|0[1-9]|3[01]))?|W([0-4]\d|5[0-3])(-?[1-7])?|(00[1-9]|0[1-9]\d|[12]\d{2}|3([0-5]\d|6[1-6])))([T\s]((([01]\d|2[0-4])((:?)[0-5]\d)?|24\:?00)([\.,]\d+(?!:))?)?(\17[0-5]\d([\.,]\d+)?)?\s?([zZ]|([\+-])([01]\d|2[0-3]):?([0-5]\d)?)?)?)?$/, parse : function (s) { var time, data = s.match(this.regex); if (!data || !data.length) { return null; } time = utils.buildTimeObjectFromData(data); if (!time.year || (!time.year && (!time.month && !time.day) && (!time.week && !time.dayOfYear)) ) { return null; } return $P.processTimeObject(time); } }; $P.Numeric = { isNumeric: function (e){return!isNaN(parseFloat(e))&&isFinite(e);}, regex: /\b([0-1]?[0-9])([0-3]?[0-9])([0-2]?[0-9]?[0-9][0-9])\b/i, parse: function (s) { var data, i, time = {}, order = Date.CultureInfo.dateElementOrder.split(""); if (!(this.isNumeric(s)) || // if it's non-numeric OR (s[0] === "+" && s[0] === "-")) { // It's an arithmatic string (eg +/-1000) return null; } if (s.length < 5 && s.indexOf(".") < 0 && s.indexOf("/") < 0) { // assume it's just a year. time.year = s; return $P.processTimeObject(time); } data = s.match(this.regex); if (!data || !data.length) { return null; } for (i=0; i < order.length; i++) { switch(order[i]) { case "d": time.day = data[i+1]; break; case "m": time.month = (data[i+1]-1); break; case "y": time.year = data[i+1]; break; } } return $P.processTimeObject(time); } }; $P.Normalizer = { regexData: function () { var $R = Date.CultureInfo.regexPatterns; return utils.buildRegexData([ $R.tomorrow, $R.yesterday, [$R.past, $R.mon], [$R.past, $R.tue], [$R.past, $R.wed], [$R.past, $R.thu], [$R.past, $R.fri], [$R.past, $R.sat], [$R.past, $R.sun] ]); }, basicReplaceHash : function() { var $R = Date.CultureInfo.regexPatterns; return { "January": $R.jan.source, "February": $R.feb, "March": $R.mar, "April": $R.apr, "May": $R.may, "June": $R.jun, "July": $R.jul, "August": $R.aug, "September": $R.sep, "October": $R.oct, "November": $R.nov, "December": $R.dec, "": /\bat\b/gi, " ": /\s{2,}/, "am": $R.inTheMorning, "9am": $R.thisMorning, "pm": $R.inTheEvening, "7pm":$R.thisEvening }; }, keys : function(){ return [ utils.getDateNthString(true, false, 1), // tomorrow utils.getDateNthString(true, false, -1), // yesterday utils.getDateNthString(false, true, "monday"), //last mon utils.getDateNthString(false, true, "tuesday"), //last tues utils.getDateNthString(false, true, "wednesday"), //last wed utils.getDateNthString(false, true, "thursday"), //last thurs utils.getDateNthString(false, true, "friday"), //last fri utils.getDateNthString(false, true, "saturday"), //last sat utils.getDateNthString(false, true, "sunday") //last sun ]; }, buildRegexFunctions: function () { var $R = Date.CultureInfo.regexPatterns; var __ = Date.i18n.__; var tomorrowRE = new RegExp("(\\b\\d\\d?("+__("AM")+"|"+__("PM")+")? )("+$R.tomorrow.source.slice(1)+")", "i"); // adapted tomorrow regex for AM PM relative dates var todayRE = new RegExp($R.today.source + "(?!\\s*([+-]))\\b"); // today, but excludes the math operators (eg "today + 2h") this.replaceFuncs = [ [todayRE, function (full) { return (full.length > 1) ? Date.today().toString("d") : full; }], [tomorrowRE, function(full, m1) { var t = Date.today().addDays(1).toString("d"); return (t + " " + m1); }], [$R.amThisMorning, function(str, am){return am;}], [$R.pmThisEvening, function(str, pm){return pm;}] ]; }, buildReplaceData: function () { this.buildRegexFunctions(); this.replaceHash = utils.addToHash(this.basicReplaceHash(), this.keys(), this.regexData()); }, stringReplaceFuncs: function (s) { for (var i=0; i < this.replaceFuncs.length; i++) { s = s.replace(this.replaceFuncs[i][0], this.replaceFuncs[i][1]); } return s; }, parse: function (s) { s = this.stringReplaceFuncs(s); s = utils.multiReplace(s, this.replaceHash); try { var n = s.split(/([\s\-\.\,\/\x27]+)/); if (n.length === 3 && $P.Numeric.isNumeric(n[0]) && $P.Numeric.isNumeric(n[2]) && (n[2].length >= 4)) { // ok, so we're dealing with x/year. But that's not a full date. // This fixes wonky dateElementOrder parsing when set to dmy order. if (Date.CultureInfo.dateElementOrder[0] === "d") { s = "1/" + n[0] + "/" + n[2]; // set to 1st of month and normalize the seperator } } } catch (e) {} return s; } }; $P.Normalizer.buildReplaceData(); }()); (function () { var $P = Date.Parsing; var _ = $P.Operators = { // // Tokenizers // rtoken: function (r) { // regex token return function (s) { var mx = s.match(r); if (mx) { return ([ mx[0], s.substring(mx[0].length) ]); } else { throw new $P.Exception(s); } }; }, token: function () { // whitespace-eating token return function (s) { return _.rtoken(new RegExp("^\\s*" + s + "\\s*"))(s); }; }, stoken: function (s) { // string token return _.rtoken(new RegExp("^" + s)); }, // Atomic Operators until: function (p) { return function (s) { var qx = [], rx = null; while (s.length) { try { rx = p.call(this, s); } catch (e) { qx.push(rx[0]); s = rx[1]; continue; } break; } return [ qx, s ]; }; }, many: function (p) { return function (s) { var rx = [], r = null; while (s.length) { try { r = p.call(this, s); } catch (e) { return [ rx, s ]; } rx.push(r[0]); s = r[1]; } return [ rx, s ]; }; }, // generator operators -- see below optional: function (p) { return function (s) { var r = null; try { r = p.call(this, s); } catch (e) { return [ null, s ]; } return [ r[0], r[1] ]; }; }, not: function (p) { return function (s) { try { p.call(this, s); } catch (e) { return [null, s]; } throw new $P.Exception(s); }; }, ignore: function (p) { return p ? function (s) { var r = null; r = p.call(this, s); return [null, r[1]]; } : null; }, product: function () { var px = arguments[0], qx = Array.prototype.slice.call(arguments, 1), rx = []; for (var i = 0 ; i < px.length ; i++) { rx.push(_.each(px[i], qx)); } return rx; }, cache: function (rule) { var cache = {}, cache_length = 0, cache_keys = [], CACHE_MAX = Date.Config.CACHE_MAX || 100000, r = null; var cacheCheck = function () { if (cache_length === CACHE_MAX) { // kill several keys, don't want to have to do this all the time... for (var i=0; i < 10; i++) { var key = cache_keys.shift(); if (key) { delete cache[key]; cache_length--; } } } }; return function (s) { cacheCheck(); try { r = cache[s] = (cache[s] || rule.call(this, s)); } catch (e) { r = cache[s] = e; } cache_length++; cache_keys.push(s); if (r instanceof $P.Exception) { throw r; } else { return r; } }; }, // vector operators -- see below any: function () { var px = arguments; return function (s) { var r = null; for (var i = 0; i < px.length; i++) { if (px[i] == null) { continue; } try { r = (px[i].call(this, s)); } catch (e) { r = null; } if (r) { return r; } } throw new $P.Exception(s); }; }, each: function () { var px = arguments; return function (s) { var rx = [], r = null; for (var i = 0; i < px.length ; i++) { if (px[i] == null) { continue; } try { r = (px[i].call(this, s)); } catch (e) { throw new $P.Exception(s); } rx.push(r[0]); s = r[1]; } return [ rx, s]; }; }, all: function () { var px = arguments, _ = _; return _.each(_.optional(px)); }, // delimited operators sequence: function (px, d, c) { d = d || _.rtoken(/^\s*/); c = c || null; if (px.length === 1) { return px[0]; } return function (s) { var r = null, q = null; var rx = []; for (var i = 0; i < px.length ; i++) { try { r = px[i].call(this, s); } catch (e) { break; } rx.push(r[0]); try { q = d.call(this, r[1]); } catch (ex) { q = null; break; } s = q[1]; } if (!r) { throw new $P.Exception(s); } if (q) { throw new $P.Exception(q[1]); } if (c) { try { r = c.call(this, r[1]); } catch (ey) { throw new $P.Exception(r[1]); } } return [ rx, (r?r[1]:s) ]; }; }, // // Composite Operators // between: function (d1, p, d2) { d2 = d2 || d1; var _fn = _.each(_.ignore(d1), p, _.ignore(d2)); return function (s) { var rx = _fn.call(this, s); return [[rx[0][0], r[0][2]], rx[1]]; }; }, list: function (p, d, c) { d = d || _.rtoken(/^\s*/); c = c || null; return (p instanceof Array ? _.each(_.product(p.slice(0, -1), _.ignore(d)), p.slice(-1), _.ignore(c)) : _.each(_.many(_.each(p, _.ignore(d))), px, _.ignore(c))); }, set: function (px, d, c) { d = d || _.rtoken(/^\s*/); c = c || null; return function (s) { // r is the current match, best the current 'best' match // which means it parsed the most amount of input var r = null, p = null, q = null, rx = null, best = [[], s], last = false; // go through the rules in the given set for (var i = 0; i < px.length ; i++) { // last is a flag indicating whether this must be the last element // if there is only 1 element, then it MUST be the last one q = null; p = null; r = null; last = (px.length === 1); // first, we try simply to match the current pattern // if not, try the next pattern try { r = px[i].call(this, s); } catch (e) { continue; } // since we are matching against a set of elements, the first // thing to do is to add r[0] to matched elements rx = [[r[0]], r[1]]; // if we matched and there is still input to parse and // we don't already know this is the last element, // we're going to next check for the delimiter ... // if there's none, or if there's no input left to parse // than this must be the last element after all ... if (r[1].length > 0 && ! last) { try { q = d.call(this, r[1]); } catch (ex) { last = true; } } else { last = true; } // if we parsed the delimiter and now there's no more input, // that means we shouldn't have parsed the delimiter at all // so don't update r and mark this as the last element ... if (!last && q[1].length === 0) { last = true; } // so, if this isn't the last element, we're going to see if // we can get any more matches from the remaining (unmatched) // elements ... if (!last) { // build a list of the remaining rules we can match against, // i.e., all but the one we just matched against var qx = []; for (var j = 0; j < px.length ; j++) { if (i !== j) { qx.push(px[j]); } } // now invoke recursively set with the remaining input // note that we don't include the closing delimiter ... // we'll check for that ourselves at the end p = _.set(qx, d).call(this, q[1]); // if we got a non-empty set as a result ... // (otw rx already contains everything we want to match) if (p[0].length > 0) { // update current result, which is stored in rx ... // basically, pick up the remaining text from p[1] // and concat the result from p[0] so that we don't // get endless nesting ... rx[0] = rx[0].concat(p[0]); rx[1] = p[1]; } } // at this point, rx either contains the last matched element // or the entire matched set that starts with this element. // now we just check to see if this variation is better than // our best so far, in terms of how much of the input is parsed if (rx[1].length < best[1].length) { best = rx; } // if we've parsed all the input, then we're finished if (best[1].length === 0) { break; } } // so now we've either gone through all the patterns trying them // as the initial match; or we found one that parsed the entire // input string ... // if best has no matches, just return empty set ... if (best[0].length === 0) { return best; } // if a closing delimiter is provided, then we have to check it also if (c) { // we try this even if there is no remaining input because the pattern // may well be optional or match empty input ... try { q = c.call(this, best[1]); } catch (ey) { throw new $P.Exception(best[1]); } // it parsed ... be sure to update the best match remaining input best[1] = q[1]; } // if we're here, either there was no closing delimiter or we parsed it // so now we have the best match; just return it! return best; }; }, forward: function (gr, fname) { return function (s) { return gr[fname].call(this, s); }; }, // // Translation Operators // replace: function (rule, repl) { return function (s) { var r = rule.call(this, s); return [repl, r[1]]; }; }, process: function (rule, fn) { return function (s) { var r = rule.call(this, s); return [fn.call(this, r[0]), r[1]]; }; }, min: function (min, rule) { return function (s) { var rx = rule.call(this, s); if (rx[0].length < min) { throw new $P.Exception(s); } return rx; }; } }; // Generator Operators And Vector Operators // Generators are operators that have a signature of F(R) => R, // taking a given rule and returning another rule, such as // ignore, which parses a given rule and throws away the result. // Vector operators are those that have a signature of F(R1,R2,...) => R, // take a list of rules and returning a new rule, such as each. // Generator operators are converted (via the following _generator // function) into functions that can also take a list or array of rules // and return an array of new rules as though the function had been // called on each rule in turn (which is what actually happens). // This allows generators to be used with vector operators more easily. // Example: // each(ignore(foo, bar)) instead of each(ignore(foo), ignore(bar)) // This also turns generators into vector operators, which allows // constructs like: // not(cache(foo, bar)) var _generator = function (op) { function gen() { var args = null, rx = [], px, i; if (arguments.length > 1) { args = Array.prototype.slice.call(arguments); } else if (arguments[0] instanceof Array) { args = arguments[0]; } if (args) { px = args.shift(); if (px.length > 0) { args.unshift(px[i]); rx.push(op.apply(null, args)); args.shift(); return rx; } } else { return op.apply(null, arguments); } } return gen; }; var gx = "optional not ignore cache".split(/\s/); for (var i = 0 ; i < gx.length ; i++) { _[gx[i]] = _generator(_[gx[i]]); } var _vector = function (op) { return function () { if (arguments[0] instanceof Array) { return op.apply(null, arguments[0]); } else { return op.apply(null, arguments); } }; }; var vx = "each any all".split(/\s/); for (var j = 0 ; j < vx.length ; j++) { _[vx[j]] = _vector(_[vx[j]]); } }()); (function () { var $D = Date; var flattenAndCompact = function (ax) { var rx = []; for (var i = 0; i < ax.length; i++) { if (ax[i] instanceof Array) { rx = rx.concat(flattenAndCompact(ax[i])); } else { if (ax[i]) { rx.push(ax[i]); } } } return rx; }; var parseMeridian = function () { if (this.meridian && (this.hour || this.hour === 0)) { if (this.meridian === "a" && this.hour > 11 && Date.Config.strict24hr){ throw "Invalid hour and meridian combination"; } else if (this.meridian === "p" && this.hour < 12 && Date.Config.strict24hr){ throw "Invalid hour and meridian combination"; } else if (this.meridian === "p" && this.hour < 12) { this.hour = this.hour + 12; } else if (this.meridian === "a" && this.hour === 12) { this.hour = 0; } } }; var setDefaults = function () { var now = new Date(); if ((this.hour || this.minute) && (!this.month && !this.year && !this.day)) { this.day = now.getDate(); } if (!this.year) { this.year = now.getFullYear(); } if (!this.month && this.month !== 0) { this.month = now.getMonth(); } if (!this.day) { this.day = 1; } if (!this.hour) { this.hour = 0; } if (!this.minute) { this.minute = 0; } if (!this.second) { this.second = 0; } if (!this.millisecond) { this.millisecond = 0; } }; var finishUtils = { getToday: function () { if (this.now || "hour minute second".indexOf(this.unit) !== -1) { return new Date(); } else { return $D.today(); } }, setDaysFromWeekday: function (today, orient){ var gap; orient = orient || 1; this.unit = "day"; gap = ($D.getDayNumberFromName(this.weekday) - today.getDay()); this.days = gap ? ((gap + (orient * 7)) % 7) : (orient * 7); return this; }, setMonthsFromMonth: function (today, orient) { var gap; orient = orient || 1; this.unit = "month"; gap = (this.month - today.getMonth()); this.months = gap ? ((gap + (orient * 12)) % 12) : (orient * 12); this.month = null; return this; }, setDMYFromWeekday: function () { var d = Date[this.weekday](); this.day = d.getDate(); if (!this.month) { this.month = d.getMonth(); } this.year = d.getFullYear(); return this; }, setUnitValue: function (orient) { if (!this.value && this.operator && this.operator !== null && this[this.unit + "s"] && this[this.unit + "s"] !== null) { this[this.unit + "s"] = this[this.unit + "s"] + ((this.operator === "add") ? 1 : -1) + (this.value||0) * orient; } else if (this[this.unit + "s"] == null || this.operator != null) { if (!this.value) { this.value = 1; } this[this.unit + "s"] = this.value * orient; } }, generateDateFromWeeks: function () { var weekday = (this.weekday !== undefined) ? this.weekday : "today"; var d = Date[weekday]().addWeeks(this.weeks); if (this.now) { d.setTimeToNow(); } return d; } }; $D.Translator = { hour: function (s) { return function () { this.hour = Number(s); }; }, minute: function (s) { return function () { this.minute = Number(s); }; }, second: function (s) { return function () { this.second = Number(s); }; }, /* for ss.s format */ secondAndMillisecond: function (s) { return function () { var mx = s.match(/^([0-5][0-9])\.([0-9]{1,3})/); this.second = Number(mx[1]); this.millisecond = Number(mx[2]); }; }, meridian: function (s) { return function () { this.meridian = s.slice(0, 1).toLowerCase(); }; }, timezone: function (s) { return function () { var n = s.replace(/[^\d\+\-]/g, ""); if (n.length) { this.timezoneOffset = Number(n); } else { this.timezone = s.toLowerCase(); } }; }, day: function (x) { var s = x[0]; return function () { this.day = Number(s.match(/\d+/)[0]); if (this.day < 1) { throw "invalid day"; } }; }, month: function (s) { return function () { this.month = (s.length === 3) ? "jan feb mar apr may jun jul aug sep oct nov dec".indexOf(s)/4 : Number(s) - 1; if (this.month < 0) { throw "invalid month"; } }; }, year: function (s) { return function () { var n = Number(s); this.year = ((s.length > 2) ? n : (n + (((n + 2000) < Date.CultureInfo.twoDigitYearMax) ? 2000 : 1900))); }; }, rday: function (s) { return function () { switch (s) { case "yesterday": this.days = -1; break; case "tomorrow": this.days = 1; break; case "today": this.days = 0; break; case "now": this.days = 0; this.now = true; break; } }; }, finishExact: function (x) { var d; x = (x instanceof Array) ? x : [x]; for (var i = 0 ; i < x.length ; i++) { if (x[i]) { x[i].call(this); } } setDefaults.call(this); parseMeridian.call(this); if (this.day > $D.getDaysInMonth(this.year, this.month)) { throw new RangeError(this.day + " is not a valid value for days."); } d = new Date(this.year, this.month, this.day, this.hour, this.minute, this.second, this.millisecond); if (this.year < 100) { d.setFullYear(this.year); // means years less that 100 are process correctly. JS will parse it otherwise as 1900-1999. } if (this.timezone) { d.set({ timezone: this.timezone }); } else if (this.timezoneOffset) { d.set({ timezoneOffset: this.timezoneOffset }); } return d; }, finish: function (x) { var today, expression, orient, temp; x = (x instanceof Array) ? flattenAndCompact(x) : [ x ]; if (x.length === 0) { return null; } for (var i = 0 ; i < x.length ; i++) { if (typeof x[i] === "function") { x[i].call(this); } } if (this.now && !this.unit && !this.operator) { return new Date(); } else { today = finishUtils.getToday.call(this); } expression = !!(this.days && this.days !== null || this.orient || this.operator); orient = ((this.orient === "past" || this.operator === "subtract") ? -1 : 1); if (this.month && this.unit === "week") { this.value = this.month + 1; delete this.month; delete this.day; } if ((this.month || this.month === 0) && "year day hour minute second".indexOf(this.unit) !== -1) { if (!this.value) { this.value = this.month + 1; } this.month = null; expression = true; } if (!expression && this.weekday && !this.day && !this.days) { finishUtils.setDMYFromWeekday.call(this); } if (expression && this.weekday && this.unit !== "month" && this.unit !== "week") { finishUtils.setDaysFromWeekday.call(this, today, orient); } if (this.weekday && this.unit !== "week" && !this.day && !this.days) { temp = Date[this.weekday](); this.day = temp.getDate(); if (temp.getMonth() !== today.getMonth()) { this.month = temp.getMonth(); } } if (this.month && this.unit === "day" && this.operator) { if (!this.value) { this.value = (this.month + 1); } this.month = null; } if (this.value != null && this.month != null && this.year != null) { this.day = this.value * 1; } if (this.month && !this.day && this.value) { today.set({ day: this.value * 1 }); if (!expression) { this.day = this.value * 1; } } if (!this.month && this.value && this.unit === "month" && !this.now) { this.month = this.value; expression = true; } if (expression && (this.month || this.month === 0) && this.unit !== "year") { finishUtils.setMonthsFromMonth.call(this, today, orient); } if (!this.unit) { this.unit = "day"; } finishUtils.setUnitValue.call(this, orient); parseMeridian.call(this); if ((this.month || this.month === 0) && !this.day) { this.day = 1; } if (!this.orient && !this.operator && this.unit === "week" && this.value && !this.day && !this.month) { return Date.today().setWeek(this.value); } if (this.unit === "week" && this.weeks && !this.day && !this.month) { return finishUtils.generateDateFromWeeks.call(this); } if (expression && this.timezone && this.day && this.days) { this.day = this.days; } if (expression){ today.add(this); } else { today.set(this); } if (this.timezone) { this.timezone = this.timezone.toUpperCase(); var offset = $D.getTimezoneOffset(this.timezone); var timezone; if (today.hasDaylightSavingTime()) { // lets check that we're being sane with timezone setting timezone = $D.getTimezoneAbbreviation(offset, today.isDaylightSavingTime()); if (timezone !== this.timezone) { // bugger, we're in a place where things like EST vs EDT matters. if (today.isDaylightSavingTime()) { today.addHours(-1); } else { today.addHours(1); } } } today.setTimezoneOffset(offset); } return today; } }; }()); (function () { var $D = Date; $D.Grammar = {}; var _ = $D.Parsing.Operators, g = $D.Grammar, t = $D.Translator, _fn; // Allow rolling up into general purpose rules _fn = function () { return _.each(_.any.apply(null, arguments), _.not(g.ctoken2("timeContext"))); }; g.datePartDelimiter = _.rtoken(/^([\s\-\.\,\/\x27]+)/); g.timePartDelimiter = _.stoken(":"); g.whiteSpace = _.rtoken(/^\s*/); g.generalDelimiter = _.rtoken(/^(([\s\,]|at|@|on)+)/); var _C = {}; g.ctoken = function (keys) { var fn = _C[keys]; if (! fn) { var c = Date.CultureInfo.regexPatterns; var kx = keys.split(/\s+/), px = []; for (var i = 0; i < kx.length ; i++) { px.push(_.replace(_.rtoken(c[kx[i]]), kx[i])); } fn = _C[keys] = _.any.apply(null, px); } return fn; }; g.ctoken2 = function (key) { return _.rtoken(Date.CultureInfo.regexPatterns[key]); }; var cacheProcessRtoken = function (key, token, type, eachToken) { if (eachToken) { g[key] = _.cache(_.process(_.each(_.rtoken(token),_.optional(g.ctoken2(eachToken))), type)); } else { g[key] = _.cache(_.process(_.rtoken(token), type)); } }; var cacheProcessCtoken = function (token, type) { return _.cache(_.process(g.ctoken2(token), type)); }; var _F = {}; //function cache var _get = function (f) { _F[f] = (_F[f] || g.format(f)[0]); return _F[f]; }; g.allformats = function (fx) { var rx = []; if (fx instanceof Array) { for (var i = 0; i < fx.length; i++) { rx.push(_get(fx[i])); } } else { rx.push(_get(fx)); } return rx; }; g.formats = function (fx) { if (fx instanceof Array) { var rx = []; for (var i = 0 ; i < fx.length ; i++) { rx.push(_get(fx[i])); } return _.any.apply(null, rx); } else { return _get(fx); } }; var grammarFormats = { timeFormats: function(){ var i, RTokenKeys = [ "h", "hh", "H", "HH", "m", "mm", "s", "ss", "ss.s", "z", "zz" ], RToken = [ /^(0[0-9]|1[0-2]|[1-9])/, /^(0[0-9]|1[0-2])/, /^([0-1][0-9]|2[0-3]|[0-9])/, /^([0-1][0-9]|2[0-3])/, /^([0-5][0-9]|[0-9])/, /^[0-5][0-9]/, /^([0-5][0-9]|[0-9])/, /^[0-5][0-9]/, /^[0-5][0-9]\.[0-9]{1,3}/, /^((\+|\-)\s*\d\d\d\d)|((\+|\-)\d\d\:?\d\d)/, /^((\+|\-)\s*\d\d\d\d)|((\+|\-)\d\d\:?\d\d)/ ], tokens = [ t.hour, t.hour, t.hour, t.hour, t.minute, t.minute, t.second, t.second, t.secondAndMillisecond, t.timezone, t.timezone ]; for (i=0; i < RTokenKeys.length; i++) { cacheProcessRtoken(RTokenKeys[i], RToken[i], tokens[i]); } g.hms = _.cache(_.sequence([g.H, g.m, g.s], g.timePartDelimiter)); g.t = cacheProcessCtoken("shortMeridian", t.meridian); g.tt = cacheProcessCtoken("longMeridian", t.meridian); g.zzz = cacheProcessCtoken("timezone", t.timezone); g.timeSuffix = _.each(_.ignore(g.whiteSpace), _.set([ g.tt, g.zzz ])); g.time = _.each(_.optional(_.ignore(_.stoken("T"))), g.hms, g.timeSuffix); }, dateFormats: function () { // pre-loaded rules for different date part order preferences var _setfn = function () { return _.set(arguments, g.datePartDelimiter); }; var i, RTokenKeys = [ "d", "dd", "M", "MM", "y", "yy", "yyy", "yyyy" ], RToken = [ /^([0-2]\d|3[0-1]|\d)/, /^([0-2]\d|3[0-1])/, /^(1[0-2]|0\d|\d)/, /^(1[0-2]|0\d)/, /^(\d+)/, /^(\d\d)/, /^(\d\d?\d?\d?)/, /^(\d\d\d\d)/ ], tokens = [ t.day, t.day, t.month, t.month, t.year, t.year, t.year, t.year ], eachToken = [ "ordinalSuffix", "ordinalSuffix" ]; for (i=0; i < RTokenKeys.length; i++) { cacheProcessRtoken(RTokenKeys[i], RToken[i], tokens[i], eachToken[i]); } g.MMM = g.MMMM = _.cache(_.process(g.ctoken("jan feb mar apr may jun jul aug sep oct nov dec"), t.month)); g.ddd = g.dddd = _.cache(_.process(g.ctoken("sun mon tue wed thu fri sat"), function (s) { return function () { this.weekday = s; }; } )); g.day = _fn(g.d, g.dd); g.month = _fn(g.M, g.MMM); g.year = _fn(g.yyyy, g.yy); g.mdy = _setfn(g.ddd, g.month, g.day, g.year); g.ymd = _setfn(g.ddd, g.year, g.month, g.day); g.dmy = _setfn(g.ddd, g.day, g.month, g.year); g.date = function (s) { return ((g[Date.CultureInfo.dateElementOrder] || g.mdy).call(this, s)); }; }, relative: function () { // relative date / time expressions g.orientation = _.process(g.ctoken("past future"), function (s) { return function () { this.orient = s; }; } ); g.operator = _.process(g.ctoken("add subtract"), function (s) { return function () { this.operator = s; }; } ); g.rday = _.process(g.ctoken("yesterday tomorrow today now"), t.rday); g.unit = _.process(g.ctoken("second minute hour day week month year"), function (s) { return function () { this.unit = s; }; } ); } }; g.buildGrammarFormats = function () { // these need to be rebuilt every time the language changes. _C = {}; grammarFormats.timeFormats(); grammarFormats.dateFormats(); grammarFormats.relative(); g.value = _.process(_.rtoken(/^([-+]?\d+)?(st|nd|rd|th)?/), function (s) { return function () { this.value = s.replace(/\D/g, ""); }; } ); g.expression = _.set([g.rday, g.operator, g.value, g.unit, g.orientation, g.ddd, g.MMM ]); g.format = _.process(_.many( _.any( // translate format specifiers into grammar rules _.process( _.rtoken(/^(dd?d?d?(?!e)|MM?M?M?|yy?y?y?|hh?|HH?|mm?|ss?|tt?|zz?z?)/), function (fmt) { if (g[fmt]) { return g[fmt]; } else { throw $D.Parsing.Exception(fmt); } } ), // translate separator tokens into token rules _.process(_.rtoken(/^[^dMyhHmstz]+/), // all legal separators function (s) { return _.ignore(_.stoken(s)); } ) ) ), // construct the parser ... function (rules) { return _.process(_.each.apply(null, rules), t.finishExact); } ); // starting rule for general purpose grammar g._start = _.process(_.set([ g.date, g.time, g.expression ], g.generalDelimiter, g.whiteSpace), t.finish); }; g.buildGrammarFormats(); // parsing date format specifiers - ex: "h:m:s tt" // this little guy will generate a custom parser based // on the format string, ex: g.format("h:m:s tt") // check for these formats first g._formats = g.formats([ "\"yyyy-MM-ddTHH:mm:ssZ\"", "yyyy-MM-ddTHH:mm:ss.sz", "yyyy-MM-ddTHH:mm:ssZ", "yyyy-MM-ddTHH:mm:ssz", "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-ddTHH:mmZ", "yyyy-MM-ddTHH:mmz", "yyyy-MM-ddTHH:mm", "ddd, MMM dd, yyyy H:mm:ss tt", "ddd MMM d yyyy HH:mm:ss zzz", "MMddyyyy", "ddMMyyyy", "Mddyyyy", "ddMyyyy", "Mdyyyy", "dMyyyy", "yyyy", "Mdyy", "dMyy", "d" ]); // real starting rule: tries selected formats first, // then general purpose rule g.start = function (s) { try { var r = g._formats.call({}, s); if (r[1].length === 0) { return r; } } catch (e) {} return g._start.call({}, s); }; }()); (function () { var $D = Date; /** * @desc Converts the specified string value into its JavaScript Date equivalent using CultureInfo specific format information. * * Example

	///////////
	// Dates //
	///////////

	// 15-Oct-2004
	var d1 = Date.parse("10/15/2004");

	// 15-Oct-2004
	var d1 = Date.parse("15-Oct-2004");

	// 15-Oct-2004
	var d1 = Date.parse("2004.10.15");

	//Fri Oct 15, 2004
	var d1 = Date.parse("Fri Oct 15, 2004");

	///////////
	// Times //
	///////////

	// Today at 10 PM.
	var d1 = Date.parse("10 PM");

	// Today at 10:30 PM.
	var d1 = Date.parse("10:30 P.M.");

	// Today at 6 AM.
	var d1 = Date.parse("06am");

	/////////////////////
	// Dates and Times //
	/////////////////////

	// 8-July-2004 @ 10:30 PM
	var d1 = Date.parse("July 8th, 2004, 10:30 PM");

	// 1-July-2004 @ 10:30 PM
	var d1 = Date.parse("2004-07-01T22:30:00");

	////////////////////
	// Relative Dates //
	////////////////////

	// Returns today's date. The string "today" is culture specific.
	var d1 = Date.parse("today");

	// Returns yesterday's date. The string "yesterday" is culture specific.
	var d1 = Date.parse("yesterday");

	// Returns the date of the next thursday.
	var d1 = Date.parse("Next thursday");

	// Returns the date of the most previous monday.
	var d1 = Date.parse("last monday");

	// Returns today's day + one year.
	var d1 = Date.parse("next year");

	///////////////
	// Date Math //
	///////////////

	// Today + 2 days
	var d1 = Date.parse("t+2");

	// Today + 2 days
	var d1 = Date.parse("today + 2 days");

	// Today + 3 months
	var d1 = Date.parse("t+3m");

	// Today - 1 year
	var d1 = Date.parse("today - 1 year");

	// Today - 1 year
	var d1 = Date.parse("t-1y"); 


	/////////////////////////////
	// Partial Dates and Times //
	/////////////////////////////

	// July 15th of this year.
	var d1 = Date.parse("July 15");

	// 15th day of current day and year.
	var d1 = Date.parse("15");

	// July 1st of current year at 10pm.
	var d1 = Date.parse("7/1 10pm");
	
* * @param {String} The string value to convert into a Date object [Required] * @return {Date} A Date object or null if the string cannot be converted into a Date. */ var parseUtils = { removeOrds: function (s) { ords = s.match(/\b(\d+)(?:st|nd|rd|th)\b/); // find ordinal matches s = ((ords && ords.length === 2) ? s.replace(ords[0], ords[1]) : s); return s; }, grammarParser: function (s) { var r = null; try { r = $D.Grammar.start.call({}, s.replace(/^\s*(\S*(\s+\S+)*)\s*$/, "$1")); } catch (e) { return null; } return ((r[1].length === 0) ? r[0] : null); }, nativeFallback: function(s) { var t; try { // ok we haven't parsed it, last ditch attempt with the built-in parser. t = Date._parse(s); return (t || t === 0) ? new Date(t) : null; } catch (e) { return null; } } }; function parse (s) { var d; if (!s) { return null; } if (s instanceof Date) { return s.clone(); } if (s.length >= 4 && s.charAt(0) !== "0" && s.charAt(0) !== "+"&& s.charAt(0) !== "-") { // ie: 2004 will pass, 0800 won't. // Start with specific formats d = $D.Parsing.ISO.parse(s) || $D.Parsing.Numeric.parse(s); } if (d instanceof Date && !isNaN(d.getTime())) { return d; } else { // find ordinal dates (1st, 3rd, 8th, etc and remove them as they cause parsing issues) s = $D.Parsing.Normalizer.parse(parseUtils.removeOrds(s)); d = parseUtils.grammarParser(s); if (d !== null) { return d; } else { return parseUtils.nativeFallback(s); } } } if (!$D._parse) { $D._parse = $D.parse; } $D.parse = parse; Date.getParseFunction = function (fx) { var fns = Date.Grammar.allformats(fx); return function (s) { var r = null; for (var i = 0; i < fns.length; i++) { try { r = fns[i].call({}, s); } catch (e) { continue; } if (r[1].length === 0) { return r[0]; } } return null; }; }; /** * Converts the specified string value into its JavaScript Date equivalent using the specified format {String} or formats {Array} and the CultureInfo specific format information. * The format of the string value must match one of the supplied formats exactly. * * Example

	// 15-Oct-2004
	var d1 = Date.parseExact("10/15/2004", "M/d/yyyy");

	// 15-Oct-2004
	var d1 = Date.parse("15-Oct-2004", "M-ddd-yyyy");

	// 15-Oct-2004
	var d1 = Date.parse("2004.10.15", "yyyy.MM.dd");

	// Multiple formats
	var d1 = Date.parseExact("10/15/2004", ["M/d/yyyy", "MMMM d, yyyy"]);
	
* * @param {String} The string value to convert into a Date object [Required]. * @param {Object} The expected format {String} or an array of expected formats {Array} of the date string [Required]. * @return {Date} A Date object or null if the string cannot be converted into a Date. */ $D.parseExact = function (s, fx) { return $D.getParseFunction(fx)(s); }; }()); (function () { var $D = Date, $P = $D.prototype, // $C = $D.CultureInfo, // not used atm p = function (s, l) { if (!l) { l = 2; } return ("000" + s).slice(l * -1); }; /** * Converts a PHP format string to Java/.NET format string. * A PHP format string can be used with ._format or .format. * A Java/.NET format string can be used with .toString(). * The .parseExact function will only accept a Java/.NET format string * * Example * var f1 = "%m/%d/%y" * var f2 = Date.normalizeFormat(f1); // "MM/dd/yy" * * new Date().format(f1); // "04/13/08" * new Date()._format(f1); // "04/13/08" * new Date().toString(f2); // "04/13/08" * * var date = Date.parseExact("04/13/08", f2); // Sun Apr 13 2008 * * @param {String} A PHP format string consisting of one or more format spcifiers. * @return {String} The PHP format converted to a Java/.NET format string. */ var normalizerSubstitutions = { "d" : "dd", "%d": "dd", "D" : "ddd", "%a": "ddd", "j" : "dddd", "l" : "dddd", "%A": "dddd", "S" : "S", "F" : "MMMM", "%B": "MMMM", "m" : "MM", "%m": "MM", "M" : "MMM", "%b": "MMM", "%h": "MMM", "n" : "M", "Y" : "yyyy", "%Y": "yyyy", "y" : "yy", "%y": "yy", "g" : "h", "%I": "h", "G" : "H", "h" : "hh", "H" : "HH", "%H": "HH", "i" : "mm", "%M": "mm", "s" : "ss", "%S": "ss", "%r": "hh:mm tt", "%R": "H:mm", "%T": "H:mm:ss", "%X": "t", "%x": "d", "%e": "d", "%D": "MM/dd/yy", "%n": "\\n", "%t": "\\t", "e" : "z", "T" : "z", "%z": "z", "%Z": "z", "Z" : "ZZ", "N" : "u", "w" : "u", "%w": "u", "W" : "W", "%V": "W" }; var normalizer = { substitutes: function (m) { return normalizerSubstitutions[m]; }, interpreted: function (m, x) { var y; switch (m) { case "%u": return x.getDay() + 1; case "z": return x.getOrdinalNumber(); case "%j": return p(x.getOrdinalNumber(), 3); case "%U": var d1 = x.clone().set({month: 0, day: 1}).addDays(-1).moveToDayOfWeek(0), d2 = x.clone().addDays(1).moveToDayOfWeek(0, -1); return (d2 < d1) ? "00" : p((d2.getOrdinalNumber() - d1.getOrdinalNumber()) / 7 + 1); case "%W": return p(x.getWeek()); case "t": return $D.getDaysInMonth(x.getFullYear(), x.getMonth()); case "o": case "%G": return x.setWeek(x.getISOWeek()).toString("yyyy"); case "%g": return x._format("%G").slice(-2); case "a": case "%p": return t("tt").toLowerCase(); case "A": return t("tt").toUpperCase(); case "u": return p(x.getMilliseconds(), 3); case "I": return (x.isDaylightSavingTime()) ? 1 : 0; case "O": return x.getUTCOffset(); case "P": y = x.getUTCOffset(); return y.substring(0, y.length - 2) + ":" + y.substring(y.length - 2); case "B": var now = new Date(); return Math.floor(((now.getHours() * 3600) + (now.getMinutes() * 60) + now.getSeconds() + (now.getTimezoneOffset() + 60) * 60) / 86.4); case "c": return x.toISOString().replace(/\"/g, ""); case "U": return $D.strtotime("now"); case "%c": return t("d") + " " + t("t"); case "%C": return Math.floor(x.getFullYear() / 100 + 1); } }, shouldOverrideDefaults: function (m) { switch (m) { case "%e": return true; default: return false; } }, parse: function (m, context) { var formatString, c = context || new Date(); formatString = normalizer.substitutes(m); if (formatString) { return formatString; } formatString = normalizer.interpreted(m, c); if (formatString) { return formatString; } else { return m; } } }; $D.normalizeFormat = function (format, context) { return format.replace(/(%|\\)?.|%%/g, function(t){ return normalizer.parse(t, context); }); }; /** * Format a local Unix timestamp according to locale settings * * Example: * Date.strftime("%m/%d/%y", new Date()); // "04/13/08" * Date.strftime("c", "2008-04-13T17:52:03Z"); // "04/13/08" * * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @param {Number|String} The number representing the number of seconds that have elapsed since January 1, 1970 (local time). * @return {String} A string representation of the current Date object. */ $D.strftime = function (format, time) { var d = Date.parse(time); return d._format(format); }; /** * Parse any textual datetime description into a Unix timestamp. * A Unix timestamp is the number of seconds that have elapsed since January 1, 1970 (midnight UTC/GMT). * * Example: * Date.strtotime("04/13/08"); // 1208044800 * Date.strtotime("1970-01-01T00:00:00Z"); // 0 * * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @param {Object} A string or date object. * @return {String} A string representation of the current Date object. */ $D.strtotime = function (time) { var d = $D.parse(time); return Math.round($D.UTC(d.getUTCFullYear(), d.getUTCMonth(), d.getUTCDate(), d.getUTCHours(), d.getUTCMinutes(), d.getUTCSeconds(), d.getUTCMilliseconds()) / 1000); }; /** * Converts the value of the current Date object to its equivalent string representation using a PHP/Unix style of date format specifiers. * Format Specifiers * Format Description Example * ------ --------------------------------------------------------------------------- ----------------------- * %a abbreviated weekday name according to the current localed "Mon" through "Sun" * %A full weekday name according to the current localed "Sunday" through "Saturday" * %b abbreviated month name according to the current localed "Jan" through "Dec" * %B full month name according to the current locale "January" through "December" * %c preferred date and time representation for the current locale "4/13/2008 12:33 PM" * %C century number (the year divided by 100 and truncated to an integer) "00" to "99" * %d day of the month as a decimal number "01" to "31" * %D same as %m/%d/%y "04/13/08" * %e day of the month as a decimal number, a single digit is preceded by a space "1" to "31" * %g like %G, but without the century "08" * %G The 4-digit year corresponding to the ISO week number (see %V). "2008" * This has the same format and value as %Y, except that if the ISO week number * belongs to the previous or next year, that year is used instead. * %h same as %b "Jan" through "Dec" * %H hour as a decimal number using a 24-hour clock. "00" to "23" * %I hour as a decimal number using a 12-hour clock. "01" to "12" * %j day of the year as a decimal number. "001" to "366" * %m month as a decimal number. "01" to "12" * %M minute as a decimal number. "00" to "59" * %n newline character "\n" * %p either "am" or "pm" according to the given time value, or the "am" or "pm" * corresponding strings for the current locale. * %r time in a.m. and p.m. notation "8:44 PM" * %R time in 24 hour notation "20:44" * %S second as a decimal number "00" to "59" * %t tab character "\t" * %T current time, equal to %H:%M:%S "12:49:11" * %u weekday as a decimal number ["1", "7"], with "1" representing Monday "1" to "7" * %U week number of the current year as a decimal number, starting with the "0" to ("52" or "53") * first Sunday as the first day of the first week * %V The ISO 8601:1988 week number of the current year as a decimal number, "00" to ("52" or "53") * range 01 to 53, where week 1 is the first week that has at least 4 days * in the current year, and with Monday as the first day of the week. * (Use %G or %g for the year component that corresponds to the week number * for the specified timestamp.) * %W week number of the current year as a decimal number, starting with the "00" to ("52" or "53") * first Monday as the first day of the first week * %w day of the week as a decimal, Sunday being "0" "0" to "6" * %x preferred date representation for the current locale without the time "4/13/2008" * %X preferred time representation for the current locale without the date "12:53:05" * %y year as a decimal number without a century "00" "99" * %Y year as a decimal number including the century "2008" * %Z time zone or name or abbreviation "UTC", "EST", "PST" * %z same as %Z * %% a literal "%" characters "%" * d Day of the month, 2 digits with leading zeros "01" to "31" * D A textual representation of a day, three letters "Mon" through "Sun" * j Day of the month without leading zeros "1" to "31" * l A full textual representation of the day of the week (lowercase "L") "Sunday" through "Saturday" * N ISO-8601 numeric representation of the day of the week (added in PHP 5.1.0) "1" (for Monday) through "7" (for Sunday) * S English ordinal suffix for the day of the month, 2 characters "st", "nd", "rd" or "th". Works well with j * w Numeric representation of the day of the week "0" (for Sunday) through "6" (for Saturday) * z The day of the year (starting from "0") "0" through "365" * W ISO-8601 week number of year, weeks starting on Monday "00" to ("52" or "53") * F A full textual representation of a month, such as January or March "January" through "December" * m Numeric representation of a month, with leading zeros "01" through "12" * M A short textual representation of a month, three letters "Jan" through "Dec" * n Numeric representation of a month, without leading zeros "1" through "12" * t Number of days in the given month "28" through "31" * L Whether it's a leap year "1" if it is a leap year, "0" otherwise * o ISO-8601 year number. This has the same value as Y, except that if the "2008" * ISO week number (W) belongs to the previous or next year, that year * is used instead. * Y A full numeric representation of a year, 4 digits "2008" * y A two digit representation of a year "08" * a Lowercase Ante meridiem and Post meridiem "am" or "pm" * A Uppercase Ante meridiem and Post meridiem "AM" or "PM" * B Swatch Internet time "000" through "999" * g 12-hour format of an hour without leading zeros "1" through "12" * G 24-hour format of an hour without leading zeros "0" through "23" * h 12-hour format of an hour with leading zeros "01" through "12" * H 24-hour format of an hour with leading zeros "00" through "23" * i Minutes with leading zeros "00" to "59" * s Seconds, with leading zeros "00" through "59" * u Milliseconds "54321" * e Timezone identifier "UTC", "EST", "PST" * I Whether or not the date is in daylight saving time (uppercase i) "1" if Daylight Saving Time, "0" otherwise * O Difference to Greenwich time (GMT) in hours "+0200", "-0600" * P Difference to Greenwich time (GMT) with colon between hours and minutes "+02:00", "-06:00" * T Timezone abbreviation "UTC", "EST", "PST" * Z Timezone offset in seconds. The offset for timezones west of UTC is "-43200" through "50400" * always negative, and for those east of UTC is always positive. * c ISO 8601 date "2004-02-12T15:19:21+00:00" * r RFC 2822 formatted date "Thu, 21 Dec 2000 16:01:07 +0200" * U Seconds since the Unix Epoch (January 1 1970 00:00:00 GMT) "0" * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @return {String} A string representation of the current Date object. */ var formatReplace = function (context) { return function (m) { var formatString, override = false; if (m.charAt(0) === "\\" || m.substring(0, 2) === "%%") { return m.replace("\\", "").replace("%%", "%"); } override = normalizer.shouldOverrideDefaults(m); formatString = $D.normalizeFormat(m, context); if (formatString) { return context.toString(formatString, override); } }; }; $P._format = function (format) { var formatter = formatReplace(this); if (!format) { return this._toString(); } else { return format.replace(/(%|\\)?.|%%/g, formatter); } }; if (!$P.format) { $P.format = $P._format; } }()); (function () { "use strict"; var gFn = function (attr) { return function () { return this[attr]; }; }; var sFn = function (attr) { return function (val) { this[attr] = val; return this; }; }; var attrs = ["years", "months", "days", "hours", "minutes", "seconds", "milliseconds"]; var addSetFuncs = function (context, attrs) { for (var i = 0; i < attrs.length ; i++) { var $a = attrs[i], $b = $a.slice(0, 1).toUpperCase() + $a.slice(1); context.prototype[$a] = 0; context.prototype["get" + $b] = gFn($a); context.prototype["set" + $b] = sFn($a); } }; /** * new TimeSpan(milliseconds); * new TimeSpan(days, hours, minutes, seconds); * new TimeSpan(days, hours, minutes, seconds, milliseconds); */ var TimeSpan = function (days, hours, minutes, seconds, milliseconds) { if (arguments.length === 1 && typeof days === "number") { var orient = (days < 0) ? -1 : +1; var millsLeft = Math.abs(days); this.setDays(Math.floor(millsLeft / 86400000) * orient); millsLeft = millsLeft % 86400000; this.setHours(Math.floor(millsLeft / 3600000) * orient); millsLeft = millsLeft % 3600000; this.setMinutes(Math.floor(millsLeft / 60000) * orient); millsLeft = millsLeft % 60000; this.setSeconds(Math.floor(millsLeft / 1000) * orient); millsLeft = millsLeft % 1000; this.setMilliseconds(millsLeft * orient); } else { this.set(days, hours, minutes, seconds, milliseconds); } this.getTotalMilliseconds = function () { return (this.getDays() * 86400000) + (this.getHours() * 3600000) + (this.getMinutes() * 60000) + (this.getSeconds() * 1000); }; this.compareTo = function (time) { var t1 = new Date(1970, 1, 1, this.getHours(), this.getMinutes(), this.getSeconds()), t2; if (time === null) { t2 = new Date(1970, 1, 1, 0, 0, 0); } else { t2 = new Date(1970, 1, 1, time.getHours(), time.getMinutes(), time.getSeconds()); } return (t1 < t2) ? -1 : (t1 > t2) ? 1 : 0; }; this.equals = function (time) { return (this.compareTo(time) === 0); }; this.add = function (time) { return (time === null) ? this : this.addSeconds(time.getTotalMilliseconds() / 1000); }; this.subtract = function (time) { return (time === null) ? this : this.addSeconds(-time.getTotalMilliseconds() / 1000); }; this.addDays = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 86400000)); }; this.addHours = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 3600000)); }; this.addMinutes = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 60000)); }; this.addSeconds = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 1000)); }; this.addMilliseconds = function (n) { return new TimeSpan(this.getTotalMilliseconds() + n); }; this.get12HourHour = function () { return (this.getHours() > 12) ? this.getHours() - 12 : (this.getHours() === 0) ? 12 : this.getHours(); }; this.getDesignator = function () { return (this.getHours() < 12) ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator; }; this.toString = function (format) { this._toString = function () { if (this.getDays() !== null && this.getDays() > 0) { return this.getDays() + "." + this.getHours() + ":" + this.p(this.getMinutes()) + ":" + this.p(this.getSeconds()); } else { return this.getHours() + ":" + this.p(this.getMinutes()) + ":" + this.p(this.getSeconds()); } }; this.p = function (s) { return (s.toString().length < 2) ? "0" + s : s; }; var me = this; return format ? format.replace(/dd?|HH?|hh?|mm?|ss?|tt?/g, function (format) { switch (format) { case "d": return me.getDays(); case "dd": return me.p(me.getDays()); case "H": return me.getHours(); case "HH": return me.p(me.getHours()); case "h": return me.get12HourHour(); case "hh": return me.p(me.get12HourHour()); case "m": return me.getMinutes(); case "mm": return me.p(me.getMinutes()); case "s": return me.getSeconds(); case "ss": return me.p(me.getSeconds()); case "t": return ((me.getHours() < 12) ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator).substring(0, 1); case "tt": return (me.getHours() < 12) ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator; } } ) : this._toString(); }; return this; }; addSetFuncs(TimeSpan, attrs.slice(2)); TimeSpan.prototype.set = function (days, hours, minutes, seconds, milliseconds){ this.setDays(days || this.getDays()); this.setHours(hours || this.getHours()); this.setMinutes(minutes || this.getMinutes()); this.setSeconds(seconds || this.getSeconds()); this.setMilliseconds(milliseconds || this.getMilliseconds()); }; /** * Gets the time of day for this date instances. * @return {TimeSpan} TimeSpan */ Date.prototype.getTimeOfDay = function () { return new TimeSpan(0, this.getHours(), this.getMinutes(), this.getSeconds(), this.getMilliseconds()); }; Date.TimeSpan = TimeSpan; if (typeof window !== "undefined" ) { // keeping API compatible for v1.x window.TimeSpan = TimeSpan; } }()); (function () { "use strict"; var attrs = ["years", "months", "days", "hours", "minutes", "seconds", "milliseconds"]; var gFn = function (attr) { return function () { return this[attr]; }; }; var sFn = function (attr) { return function (val) { this[attr] = val; return this; }; }; var addSetFuncs = function (context, attrs) { for (var i = 0; i < attrs.length ; i++) { var $a = attrs[i], $b = $a.slice(0, 1).toUpperCase() + $a.slice(1); context.prototype[$a] = 0; context.prototype["get" + $b] = gFn($a); context.prototype["set" + $b] = sFn($a); } }; var setMonthsAndYears = function (orient, d1, d2, context) { function inc() { d1.addMonths(-orient); context.months++; if (context.months === 12) { context.years++; context.months = 0; } } if (orient === +1) { while (d1 > d2) { inc(); } } else { while (d1 < d2) { inc(); } } context.months--; context.months *= orient; context.years *= orient; }; var adjustForDST = function(orient, startDate, endDate) { var hasDSTMismatch = (false === (startDate.isDaylightSavingTime() === endDate.isDaylightSavingTime())); if (hasDSTMismatch && orient === 1) { startDate.addHours(-1); } else if (hasDSTMismatch) { startDate.addHours(1); } }; /** * TimePeriod(startDate, endDate); * TimePeriod(years, months, days, hours, minutes, seconds, milliseconds); */ var TimePeriod = function (years, months, days, hours, minutes, seconds, milliseconds) { if (arguments.length === 7) { this.set(years, months, days, hours, minutes, seconds, milliseconds); } else if (arguments.length === 2 && arguments[0] instanceof Date && arguments[1] instanceof Date) { var startDate = arguments[0].clone(); var endDate = arguments[1].clone(); var orient = (startDate > endDate) ? +1 : -1; this.dates = { start: arguments[0].clone(), end: arguments[1].clone() }; setMonthsAndYears(orient, startDate, endDate, this); adjustForDST(orient, startDate, endDate); // // TODO - adjust for DST var diff = endDate - startDate; if (diff !== 0) { var ts = new TimeSpan(diff); this.set(this.years, this.months, ts.getDays(), ts.getHours(), ts.getMinutes(), ts.getSeconds(), ts.getMilliseconds()); } } return this; }; // create all the set functions. addSetFuncs(TimePeriod, attrs); TimePeriod.prototype.set = function (years, months, days, hours, minutes, seconds, milliseconds){ this.setYears(years || this.getYears()); this.setMonths(months || this.getMonths()); this.setDays(days || this.getDays()); this.setHours(hours || this.getHours()); this.setMinutes(minutes || this.getMinutes()); this.setSeconds(seconds || this.getSeconds()); this.setMilliseconds(milliseconds || this.getMilliseconds()); }; Date.TimePeriod = TimePeriod; if (typeof window !== "undefined") { // keeping API compatible for v1.x window.TimePeriod = TimePeriod; } }()); ================================================ FILE: build/date-sma-SE.js ================================================ /** * @overview datejs * @version 1.0.0-rc3 * @author Gregory Wild-Smith * @copyright 2015 Gregory Wild-Smith * @license MIT * @homepage https://github.com/abritinthebay/datejs */ /* * DateJS Culture String File * Country Code: sma-SE * Name: Sami (Southern) (Sweden) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["sma-SE"] = { "name": "sma-SE", "englishName": "Sami (Southern) (Sweden)", "nativeName": "åarjelsaemiengiele (Sveerje)", "Sunday": "aejlege", "Monday": "måanta", "Tuesday": "dæjsta", "Wednesday": "gaskevåhkoe", "Thursday": "duarsta", "Friday": "bearjadahke", "Saturday": "laavvardahke", "Sun": "aej", "Mon": "måa", "Tue": "dæj", "Wed": "gask", "Thu": "duar", "Fri": "bearj", "Sat": "laav", "Su": "aej", "Mo": "måa", "Tu": "dæj", "We": "gask", "Th": "duar", "Fr": "bearj", "Sa": "laav", "S_Sun_Initial": "a", "M_Mon_Initial": "m", "T_Tue_Initial": "d", "W_Wed_Initial": "g", "T_Thu_Initial": "d", "F_Fri_Initial": "b", "S_Sat_Initial": "l", "January": "tsïengele", "February": "goevte", "March": "njoktje", "April": "voerhtje", "May": "suehpede", "June": "ruffie", "July": "snjaltje", "August": "mïetske", "September": "skïerede", "October": "golke", "November": "rahka", "December": "goeve", "Jan_Abbr": "tsïen", "Feb_Abbr": "goevt", "Mar_Abbr": "njok", "Apr_Abbr": "voer", "May_Abbr": "sueh", "Jun_Abbr": "ruff", "Jul_Abbr": "snja", "Aug_Abbr": "mïet", "Sep_Abbr": "skïer", "Oct_Abbr": "golk", "Nov_Abbr": "rahk", "Dec_Abbr": "goev", "AM": "", "PM": "", "firstDayOfWeek": 1, "twoDigitYearMax": 2029, "mdy": "ymd", "M/d/yyyy": "yyyy-MM-dd", "dddd, MMMM dd, yyyy": "MMMM d'. b. 'yyyy", "h:mm tt": "HH:mm:ss", "h:mm:ss tt": "HH:mm:ss", "dddd, MMMM dd, yyyy h:mm:ss tt": "MMMM d'. b. 'yyyy HH:mm:ss", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "MMMM dd", "MMMM, yyyy": "MMMM yyyy", "/jan(uary)?/": "tsïen(gele)?", "/feb(ruary)?/": "goevt(e)?", "/mar(ch)?/": "njok(tje)?", "/apr(il)?/": "voer(htje)?", "/may/": "sueh(pede)?", "/jun(e)?/": "ruff(ie)?", "/jul(y)?/": "snja(ltje)?", "/aug(ust)?/": "mïet(ske)?", "/sep(t(ember)?)?/": "skïer(ede)?", "/oct(ober)?/": "golk(e)?", "/nov(ember)?/": "rahk(a)?", "/dec(ember)?/": "goev(e)?", "/^su(n(day)?)?/": "^aejlege", "/^mo(n(day)?)?/": "^måanta", "/^tu(e(s(day)?)?)?/": "^dæjsta", "/^we(d(nesday)?)?/": "^gaskevåhkoe", "/^th(u(r(s(day)?)?)?)?/": "^duarsta", "/^fr(i(day)?)?/": "^bearjadahke", "/^sa(t(urday)?)?/": "^laavvardahke", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "sma-SE"; /** * @overview datejs * @version 1.0.0-rc3 * @author Gregory Wild-Smith * @copyright 2015 Gregory Wild-Smith * @license MIT * @homepage https://github.com/abritinthebay/datejs */(function () { var $D = Date; var lang = Date.CultureStrings ? Date.CultureStrings.lang : null; var loggedKeys = {}; // for debug purposes. var getText = { getFromKey: function (key, countryCode) { var output; if (Date.CultureStrings && Date.CultureStrings[countryCode] && Date.CultureStrings[countryCode][key]) { output = Date.CultureStrings[countryCode][key]; } else { output = getText.buildFromDefault(key); } if (key.charAt(0) === "/") { // Assume it's a regex output = getText.buildFromRegex(key, countryCode); } return output; }, getFromObjectValues: function (obj, countryCode) { var key, output = {}; for(key in obj) { if (obj.hasOwnProperty(key)) { output[key] = getText.getFromKey(obj[key], countryCode); } } return output; }, getFromObjectKeys: function (obj, countryCode) { var key, output = {}; for(key in obj) { if (obj.hasOwnProperty(key)) { output[getText.getFromKey(key, countryCode)] = obj[key]; } } return output; }, getFromArray: function (arr, countryCode) { var output = []; for (var i=0; i < arr.length; i++){ if (i in arr) { output[i] = getText.getFromKey(arr[i], countryCode); } } return output; }, buildFromDefault: function (key) { var output, length, split, last; switch(key) { case "name": output = "en-US"; break; case "englishName": output = "English (United States)"; break; case "nativeName": output = "English (United States)"; break; case "twoDigitYearMax": output = 2049; break; case "firstDayOfWeek": output = 0; break; default: output = key; split = key.split("_"); length = split.length; if (length > 1 && key.charAt(0) !== "/") { // if the key isn't a regex and it has a split. last = split[(length - 1)].toLowerCase(); if (last === "initial" || last === "abbr") { output = split[0]; } } break; } return output; }, buildFromRegex: function (key, countryCode) { var output; if (Date.CultureStrings && Date.CultureStrings[countryCode] && Date.CultureStrings[countryCode][key]) { output = new RegExp(Date.CultureStrings[countryCode][key], "i"); } else { output = new RegExp(key.replace(new RegExp("/", "g"),""), "i"); } return output; } }; var shallowMerge = function (obj1, obj2) { for (var attrname in obj2) { if (obj2.hasOwnProperty(attrname)) { obj1[attrname] = obj2[attrname]; } } }; var __ = function (key, language) { var countryCode = (language) ? language : lang; loggedKeys[key] = key; if (typeof key === "object") { if (key instanceof Array) { return getText.getFromArray(key, countryCode); } else { return getText.getFromObjectKeys(key, countryCode); } } else { return getText.getFromKey(key, countryCode); } }; var loadI18nScript = function (code) { // paatterned after jQuery's getScript. var url = Date.Config.i18n + code + ".js"; var head = document.getElementsByTagName("head")[0] || document.documentElement; var script = document.createElement("script"); script.src = url; var completed = false; var events = { done: function (){} // placeholder function }; // Attach handlers for all browsers script.onload = script.onreadystatechange = function() { if ( !completed && (!this.readyState || this.readyState === "loaded" || this.readyState === "complete") ) { events.done(); head.removeChild(script); } }; setTimeout(function() { head.insertBefore(script, head.firstChild); }, 0); // allows return to execute first return { done: function (cb) { events.done = function() { if (cb) { setTimeout(cb,0); } }; } }; }; var buildInfo = { buildFromMethodHash: function (obj) { var key; for(key in obj) { if (obj.hasOwnProperty(key)) { obj[key] = buildInfo[obj[key]](); } } return obj; }, timeZoneDST: function () { var DST = { "CHADT": "+1345", "NZDT": "+1300", "AEDT": "+1100", "ACDT": "+1030", "AZST": "+0500", "IRDT": "+0430", "EEST": "+0300", "CEST": "+0200", "BST": "+0100", "PMDT": "-0200", "ADT": "-0300", "NDT": "-0230", "EDT": "-0400", "CDT": "-0500", "MDT": "-0600", "PDT": "-0700", "AKDT": "-0800", "HADT": "-0900" }; return __(DST); }, timeZoneStandard: function () { var standard = { "LINT": "+1400", "TOT": "+1300", "CHAST": "+1245", "NZST": "+1200", "NFT": "+1130", "SBT": "+1100", "AEST": "+1000", "ACST": "+0930", "JST": "+0900", "CWST": "+0845", "CT": "+0800", "ICT": "+0700", "MMT": "+0630", "BST": "+0600", "NPT": "+0545", "IST": "+0530", "PKT": "+0500", "AFT": "+0430", "MSK": "+0400", "IRST": "+0330", "FET": "+0300", "EET": "+0200", "CET": "+0100", "GMT": "+0000", "UTC": "+0000", "CVT": "-0100", "GST": "-0200", "BRT": "-0300", "NST": "-0330", "AST": "-0400", "EST": "-0500", "CST": "-0600", "MST": "-0700", "PST": "-0800", "AKST": "-0900", "MIT": "-0930", "HST": "-1000", "SST": "-1100", "BIT": "-1200" }; return __(standard); }, timeZones: function (data) { var zone; data.timezones = []; for (zone in data.abbreviatedTimeZoneStandard) { if (data.abbreviatedTimeZoneStandard.hasOwnProperty(zone)) { data.timezones.push({ name: zone, offset: data.abbreviatedTimeZoneStandard[zone]}); } } for (zone in data.abbreviatedTimeZoneDST) { if (data.abbreviatedTimeZoneDST.hasOwnProperty(zone)) { data.timezones.push({ name: zone, offset: data.abbreviatedTimeZoneDST[zone], dst: true}); } } return data.timezones; }, days: function () { return __(["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"]); }, dayAbbr: function () { return __(["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"]); }, dayShortNames: function () { return __(["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"]); }, dayFirstLetters: function () { return __(["S_Sun_Initial", "M_Mon_Initial", "T_Tues_Initial", "W_Wed_Initial", "T_Thu_Initial", "F_Fri_Initial", "S_Sat_Initial"]); }, months: function () { return __(["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"]); }, monthAbbr: function () { return __(["Jan_Abbr", "Feb_Abbr", "Mar_Abbr", "Apr_Abbr", "May_Abbr", "Jun_Abbr", "Jul_Abbr", "Aug_Abbr", "Sep_Abbr", "Oct_Abbr", "Nov_Abbr", "Dec_Abbr"]); }, formatPatterns: function () { return getText.getFromObjectValues({ shortDate: "M/d/yyyy", longDate: "dddd, MMMM dd, yyyy", shortTime: "h:mm tt", longTime: "h:mm:ss tt", fullDateTime: "dddd, MMMM dd, yyyy h:mm:ss tt", sortableDateTime: "yyyy-MM-ddTHH:mm:ss", universalSortableDateTime: "yyyy-MM-dd HH:mm:ssZ", rfc1123: "ddd, dd MMM yyyy HH:mm:ss", monthDay: "MMMM dd", yearMonth: "MMMM, yyyy" }, Date.i18n.currentLanguage()); }, regex: function () { return getText.getFromObjectValues({ inTheMorning: "/( in the )(morn(ing)?)\\b/", thisMorning: "/(this )(morn(ing)?)\\b/", amThisMorning: "/(\b\\d(am)? )(this )(morn(ing)?)/", inTheEvening: "/( in the )(even(ing)?)\\b/", thisEvening: "/(this )(even(ing)?)\\b/", pmThisEvening: "/(\b\\d(pm)? )(this )(even(ing)?)/", jan: "/jan(uary)?/", feb: "/feb(ruary)?/", mar: "/mar(ch)?/", apr: "/apr(il)?/", may: "/may/", jun: "/jun(e)?/", jul: "/jul(y)?/", aug: "/aug(ust)?/", sep: "/sep(t(ember)?)?/", oct: "/oct(ober)?/", nov: "/nov(ember)?/", dec: "/dec(ember)?/", sun: "/^su(n(day)?)?/", mon: "/^mo(n(day)?)?/", tue: "/^tu(e(s(day)?)?)?/", wed: "/^we(d(nesday)?)?/", thu: "/^th(u(r(s(day)?)?)?)?/", fri: "/fr(i(day)?)?/", sat: "/^sa(t(urday)?)?/", future: "/^next/", past: "/^last|past|prev(ious)?/", add: "/^(\\+|aft(er)?|from|hence)/", subtract: "/^(\\-|bef(ore)?|ago)/", yesterday: "/^yes(terday)?/", today: "/^t(od(ay)?)?/", tomorrow: "/^tom(orrow)?/", now: "/^n(ow)?/", millisecond: "/^ms|milli(second)?s?/", second: "/^sec(ond)?s?/", minute: "/^mn|min(ute)?s?/", hour: "/^h(our)?s?/", week: "/^w(eek)?s?/", month: "/^m(onth)?s?/", day: "/^d(ay)?s?/", year: "/^y(ear)?s?/", shortMeridian: "/^(a|p)/", longMeridian: "/^(a\\.?m?\\.?|p\\.?m?\\.?)/", timezone: "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/", ordinalSuffix: "/^\\s*(st|nd|rd|th)/", timeContext: "/^\\s*(\\:|a(?!u|p)|p)/" }, Date.i18n.currentLanguage()); } }; var CultureInfo = function () { var info = getText.getFromObjectValues({ name: "name", englishName: "englishName", nativeName: "nativeName", amDesignator: "AM", pmDesignator: "PM", firstDayOfWeek: "firstDayOfWeek", twoDigitYearMax: "twoDigitYearMax", dateElementOrder: "mdy" }, Date.i18n.currentLanguage()); var constructedInfo = buildInfo.buildFromMethodHash({ dayNames: "days", abbreviatedDayNames: "dayAbbr", shortestDayNames: "dayShortNames", firstLetterDayNames: "dayFirstLetters", monthNames: "months", abbreviatedMonthNames: "monthAbbr", formatPatterns: "formatPatterns", regexPatterns: "regex", abbreviatedTimeZoneDST: "timeZoneDST", abbreviatedTimeZoneStandard: "timeZoneStandard" }); shallowMerge(info, constructedInfo); buildInfo.timeZones(info); return info; }; $D.i18n = { __: function (key, lang) { return __(key, lang); }, currentLanguage: function () { return lang || "en-US"; }, setLanguage: function (code, force, cb) { var async = false; if (force || code === "en-US" || (!!Date.CultureStrings && !!Date.CultureStrings[code])) { lang = code; Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings.lang = code; Date.CultureInfo = new CultureInfo(); } else { if (!(!!Date.CultureStrings && !!Date.CultureStrings[code])) { if (typeof exports !== "undefined" && this.exports !== exports) { // we're in a Node enviroment, load it using require try { require("../i18n/" + code + ".js"); lang = code; Date.CultureStrings.lang = code; Date.CultureInfo = new CultureInfo(); } catch (e) { // var str = "The language for '" + code + "' could not be loaded by Node. It likely does not exist."; throw new Error("The DateJS IETF language tag '" + code + "' could not be loaded by Node. It likely does not exist."); } } else if (Date.Config && Date.Config.i18n) { // we know the location of the files, so lets load them async = true; loadI18nScript(code).done(function(){ lang = code; Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings.lang = code; Date.CultureInfo = new CultureInfo(); $D.Parsing.Normalizer.buildReplaceData(); // because this is async if ($D.Grammar) { $D.Grammar.buildGrammarFormats(); // so we can parse those strings... } if (cb) { setTimeout(cb,0); } }); } else { Date.console.error("The DateJS IETF language tag '" + code + "' is not available and has not been loaded."); return false; } } } $D.Parsing.Normalizer.buildReplaceData(); // rebuild normalizer strings if ($D.Grammar) { $D.Grammar.buildGrammarFormats(); // so we can parse those strings... } if (!async && cb) { setTimeout(cb,0); } }, getLoggedKeys: function () { return loggedKeys; }, updateCultureInfo: function () { Date.CultureInfo = new CultureInfo(); } }; $D.i18n.updateCultureInfo(); // run automatically }()); (function () { var $D = Date, $P = $D.prototype, p = function (s, l) { if (!l) { l = 2; } return ("000" + s).slice(l * -1); }; if (typeof window !== "undefined" && typeof window.console !== "undefined" && typeof window.console.log !== "undefined") { $D.console = console; // used only to raise non-critical errors if available } else { // set mock so we don't give errors. $D.console = { log: function(){}, error: function(){} }; } $D.Config = $D.Config || {}; $D.initOverloads = function() { /** * Overload of Date.now. Allows an alternate call for Date.now where it returns the * current Date as an object rather than just milliseconds since the Unix Epoch. * * Also provides an implementation of now() for browsers (IE<9) that don't have it. * * Backwards compatible so with work with either: * Date.now() [returns ms] * or * Date.now(true) [returns Date] */ if (!$D.now) { $D._now = function now() { return new Date().getTime(); }; } else if (!$D._now) { $D._now = $D.now; } $D.now = function (returnObj) { if (returnObj) { return $D.present(); } else { return $D._now(); } }; if ( !$P.toISOString ) { $P.toISOString = function() { return this.getUTCFullYear() + "-" + p(this.getUTCMonth() + 1) + "-" + p(this.getUTCDate()) + "T" + p(this.getUTCHours()) + ":" + p(this.getUTCMinutes()) + ":" + p(this.getUTCSeconds()) + "." + String( (this.getUTCMilliseconds()/1000).toFixed(3)).slice(2, 5) + "Z"; }; } // private if ( $P._toString === undefined ){ $P._toString = $P.toString; } }; $D.initOverloads(); /** * Gets a date that is set to the current date. The time is set to the start of the day (00:00 or 12:00 AM). * @return {Date} The current date. */ $D.today = function () { return new Date().clearTime(); }; /** * Gets a date that is set to the current date and time (same as new Date, but chainable) * @return {Date} The current date. */ $D.present = function () { return new Date(); }; /** * Compares the first date to the second date and returns an number indication of their relative values. * @param {Date} First Date object to compare [Required]. * @param {Date} Second Date object to compare to [Required]. * @return {Number} -1 = date1 is lessthan date2. 0 = values are equal. 1 = date1 is greaterthan date2. */ $D.compare = function (date1, date2) { if (isNaN(date1) || isNaN(date2)) { throw new Error(date1 + " - " + date2); } else if (date1 instanceof Date && date2 instanceof Date) { return (date1 < date2) ? -1 : (date1 > date2) ? 1 : 0; } else { throw new TypeError(date1 + " - " + date2); } }; /** * Compares the first Date object to the second Date object and returns true if they are equal. * @param {Date} First Date object to compare [Required] * @param {Date} Second Date object to compare to [Required] * @return {Boolean} true if dates are equal. false if they are not equal. */ $D.equals = function (date1, date2) { return (date1.compareTo(date2) === 0); }; /** * Gets the language appropriate day name when given the day number(0-6) * eg - 0 == Sunday * @return {String} The day name */ $D.getDayName = function (n) { return Date.CultureInfo.dayNames[n]; }; /** * Gets the day number (0-6) if given a CultureInfo specific string which is a valid dayName, abbreviatedDayName or shortestDayName (two char). * @param {String} The name of the day (eg. "Monday, "Mon", "tuesday", "tue", "We", "we"). * @return {Number} The day number */ $D.getDayNumberFromName = function (name) { var n = Date.CultureInfo.dayNames, m = Date.CultureInfo.abbreviatedDayNames, o = Date.CultureInfo.shortestDayNames, s = name.toLowerCase(); for (var i = 0; i < n.length; i++) { if (n[i].toLowerCase() === s || m[i].toLowerCase() === s || o[i].toLowerCase() === s) { return i; } } return -1; }; /** * Gets the month number (0-11) if given a Culture Info specific string which is a valid monthName or abbreviatedMonthName. * @param {String} The name of the month (eg. "February, "Feb", "october", "oct"). * @return {Number} The day number */ $D.getMonthNumberFromName = function (name) { var n = Date.CultureInfo.monthNames, m = Date.CultureInfo.abbreviatedMonthNames, s = name.toLowerCase(); for (var i = 0; i < n.length; i++) { if (n[i].toLowerCase() === s || m[i].toLowerCase() === s) { return i; } } return -1; }; /** * Gets the language appropriate month name when given the month number(0-11) * eg - 0 == January * @return {String} The month name */ $D.getMonthName = function (n) { return Date.CultureInfo.monthNames[n]; }; /** * Determines if the current date instance is within a LeapYear. * @param {Number} The year. * @return {Boolean} true if date is within a LeapYear, otherwise false. */ $D.isLeapYear = function (year) { return ((year % 4 === 0 && year % 100 !== 0) || year % 400 === 0); }; /** * Gets the number of days in the month, given a year and month value. Automatically corrects for LeapYear. * @param {Number} The year. * @param {Number} The month (0-11). * @return {Number} The number of days in the month. */ $D.getDaysInMonth = function (year, month) { if (!month && $D.validateMonth(year)) { month = year; year = Date.today().getFullYear(); } return [31, ($D.isLeapYear(year) ? 29 : 28), 31, 30, 31, 30, 31, 31, 30, 31, 30, 31][month]; }; $P.getDaysInMonth = function () { return $D.getDaysInMonth(this.getFullYear(), this.getMonth()); }; $D.getTimezoneAbbreviation = function (offset, dst) { var p, n = (dst || false) ? Date.CultureInfo.abbreviatedTimeZoneDST : Date.CultureInfo.abbreviatedTimeZoneStandard; for (p in n) { if (n.hasOwnProperty(p)) { if (n[p] === offset) { return p; } } } return null; }; $D.getTimezoneOffset = function (name, dst) { var i, a =[], z = Date.CultureInfo.timezones; if (!name) { name = (new Date()).getTimezone();} for (i = 0; i < z.length; i++) { if (z[i].name === name.toUpperCase()) { a.push(i); } } if (!z[a[0]]) { return null; } if (a.length === 1 || !dst) { return z[a[0]].offset; } else { for (i=0; i < a.length; i++) { if (z[a[i]].dst) { return z[a[i]].offset; } } } }; $D.getQuarter = function (d) { d = d || new Date(); // If no date supplied, use today var q = [1,2,3,4]; return q[Math.floor(d.getMonth() / 3)]; // ~~~ is a bitwise op. Faster than Math.floor }; $D.getDaysLeftInQuarter = function (d) { d = d || new Date(); var qEnd = new Date(d); qEnd.setMonth(qEnd.getMonth() + 3 - qEnd.getMonth() % 3, 0); return Math.floor((qEnd - d) / 8.64e7); }; // private var validate = function (n, min, max, name) { name = name ? name : "Object"; if (typeof n === "undefined") { return false; } else if (typeof n !== "number") { throw new TypeError(n + " is not a Number."); } else if (n < min || n > max) { // As failing validation is *not* an exceptional circumstance // lets not throw a RangeError Exception here. // It's semantically correct but it's not sensible. return false; } return true; }; /** * Validates the number is within an acceptable range for milliseconds [0-999]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateMillisecond = function (value) { return validate(value, 0, 999, "millisecond"); }; /** * Validates the number is within an acceptable range for seconds [0-59]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateSecond = function (value) { return validate(value, 0, 59, "second"); }; /** * Validates the number is within an acceptable range for minutes [0-59]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateMinute = function (value) { return validate(value, 0, 59, "minute"); }; /** * Validates the number is within an acceptable range for hours [0-23]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateHour = function (value) { return validate(value, 0, 23, "hour"); }; /** * Validates the number is within an acceptable range for the days in a month [0-MaxDaysInMonth]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateDay = function (value, year, month) { if (year === undefined || year === null || month === undefined || month === null) { return false;} return validate(value, 1, $D.getDaysInMonth(year, month), "day"); }; /** * Validates the number is within an acceptable range for months [0-11]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateWeek = function (value) { return validate(value, 0, 53, "week"); }; /** * Validates the number is within an acceptable range for months [0-11]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateMonth = function (value) { return validate(value, 0, 11, "month"); }; /** * Validates the number is within an acceptable range for years. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateYear = function (value) { /** * Per ECMAScript spec the range of times supported by Date objects is * exactly -100,000,000 days to +100,000,000 days measured relative to * midnight at the beginning of 01 January, 1970 UTC. * This gives a range of 8,640,000,000,000,000 milliseconds to either * side of 01 January, 1970 UTC. * * Earliest possible date: Tue, 20 Apr 271,822 B.C. 00:00:00 UTC * Latest possible date: Sat, 13 Sep 275,760 00:00:00 UTC */ return validate(value, -271822, 275760, "year"); }; $D.validateTimezone = function(value) { var timezones = {"ACDT":1,"ACST":1,"ACT":1,"ADT":1,"AEDT":1,"AEST":1,"AFT":1,"AKDT":1,"AKST":1,"AMST":1,"AMT":1,"ART":1,"AST":1,"AWDT":1,"AWST":1,"AZOST":1,"AZT":1,"BDT":1,"BIOT":1,"BIT":1,"BOT":1,"BRT":1,"BST":1,"BTT":1,"CAT":1,"CCT":1,"CDT":1,"CEDT":1,"CEST":1,"CET":1,"CHADT":1,"CHAST":1,"CHOT":1,"ChST":1,"CHUT":1,"CIST":1,"CIT":1,"CKT":1,"CLST":1,"CLT":1,"COST":1,"COT":1,"CST":1,"CT":1,"CVT":1,"CWST":1,"CXT":1,"DAVT":1,"DDUT":1,"DFT":1,"EASST":1,"EAST":1,"EAT":1,"ECT":1,"EDT":1,"EEDT":1,"EEST":1,"EET":1,"EGST":1,"EGT":1,"EIT":1,"EST":1,"FET":1,"FJT":1,"FKST":1,"FKT":1,"FNT":1,"GALT":1,"GAMT":1,"GET":1,"GFT":1,"GILT":1,"GIT":1,"GMT":1,"GST":1,"GYT":1,"HADT":1,"HAEC":1,"HAST":1,"HKT":1,"HMT":1,"HOVT":1,"HST":1,"ICT":1,"IDT":1,"IOT":1,"IRDT":1,"IRKT":1,"IRST":1,"IST":1,"JST":1,"KGT":1,"KOST":1,"KRAT":1,"KST":1,"LHST":1,"LINT":1,"MAGT":1,"MART":1,"MAWT":1,"MDT":1,"MET":1,"MEST":1,"MHT":1,"MIST":1,"MIT":1,"MMT":1,"MSK":1,"MST":1,"MUT":1,"MVT":1,"MYT":1,"NCT":1,"NDT":1,"NFT":1,"NPT":1,"NST":1,"NT":1,"NUT":1,"NZDT":1,"NZST":1,"OMST":1,"ORAT":1,"PDT":1,"PET":1,"PETT":1,"PGT":1,"PHOT":1,"PHT":1,"PKT":1,"PMDT":1,"PMST":1,"PONT":1,"PST":1,"PYST":1,"PYT":1,"RET":1,"ROTT":1,"SAKT":1,"SAMT":1,"SAST":1,"SBT":1,"SCT":1,"SGT":1,"SLST":1,"SRT":1,"SST":1,"SYOT":1,"TAHT":1,"THA":1,"TFT":1,"TJT":1,"TKT":1,"TLT":1,"TMT":1,"TOT":1,"TVT":1,"UCT":1,"ULAT":1,"UTC":1,"UYST":1,"UYT":1,"UZT":1,"VET":1,"VLAT":1,"VOLT":1,"VOST":1,"VUT":1,"WAKT":1,"WAST":1,"WAT":1,"WEDT":1,"WEST":1,"WET":1,"WST":1,"YAKT":1,"YEKT":1,"Z":1}; return (timezones[value] === 1); }; $D.validateTimezoneOffset= function(value) { // timezones go from +14hrs to -12hrs, the +X hours are negative offsets. return (value > -841 && value < 721); }; }()); (function () { var $D = Date, $P = $D.prototype, p = function (s, l) { if (!l) { l = 2; } return ("000" + s).slice(l * -1); }; var validateConfigObject = function (obj) { var result = {}, self = this, prop, testFunc; testFunc = function (prop, func, value) { if (prop === "day") { var month = (obj.month !== undefined) ? obj.month : self.getMonth(); var year = (obj.year !== undefined) ? obj.year : self.getFullYear(); return $D[func](value, year, month); } else { return $D[func](value); } }; for (prop in obj) { if (Object.prototype.hasOwnProperty.call(obj, prop)) { var func = "validate" + prop.charAt(0).toUpperCase() + prop.slice(1); if ($D[func] && obj[prop] !== null && testFunc(prop, func, obj[prop])) { result[prop] = obj[prop]; } } } return result; }; /** * Resets the time of this Date object to 12:00 AM (00:00), which is the start of the day. * @param {Boolean} .clone() this date instance before clearing Time * @return {Date} this */ $P.clearTime = function () { this.setHours(0); this.setMinutes(0); this.setSeconds(0); this.setMilliseconds(0); return this; }; /** * Resets the time of this Date object to the current time ('now'). * @return {Date} this */ $P.setTimeToNow = function () { var n = new Date(); this.setHours(n.getHours()); this.setMinutes(n.getMinutes()); this.setSeconds(n.getSeconds()); this.setMilliseconds(n.getMilliseconds()); return this; }; /** * Returns a new Date object that is an exact date and time copy of the original instance. * @return {Date} A new Date instance */ $P.clone = function () { return new Date(this.getTime()); }; /** * Compares this instance to a Date object and returns an number indication of their relative values. * @param {Date} Date object to compare [Required] * @return {Number} -1 = this is lessthan date. 0 = values are equal. 1 = this is greaterthan date. */ $P.compareTo = function (date) { return Date.compare(this, date); }; /** * Compares this instance to another Date object and returns true if they are equal. * @param {Date} Date object to compare. If no date to compare, new Date() [now] is used. * @return {Boolean} true if dates are equal. false if they are not equal. */ $P.equals = function (date) { return Date.equals(this, (date !== undefined ? date : new Date())); }; /** * Determines if this instance is between a range of two dates or equal to either the start or end dates. * @param {Date} Start of range [Required] * @param {Date} End of range [Required] * @return {Boolean} true is this is between or equal to the start and end dates, else false */ $P.between = function (start, end) { return this.getTime() >= start.getTime() && this.getTime() <= end.getTime(); }; /** * Determines if this date occurs after the date to compare to. * @param {Date} Date object to compare. If no date to compare, new Date() ("now") is used. * @return {Boolean} true if this date instance is greater than the date to compare to (or "now"), otherwise false. */ $P.isAfter = function (date) { return this.compareTo(date || new Date()) === 1; }; /** * Determines if this date occurs before the date to compare to. * @param {Date} Date object to compare. If no date to compare, new Date() ("now") is used. * @return {Boolean} true if this date instance is less than the date to compare to (or "now"). */ $P.isBefore = function (date) { return (this.compareTo(date || new Date()) === -1); }; /** * Determines if the current Date instance occurs today. * @return {Boolean} true if this date instance is 'today', otherwise false. */ /** * Determines if the current Date instance occurs on the same Date as the supplied 'date'. * If no 'date' to compare to is provided, the current Date instance is compared to 'today'. * @param {date} Date object to compare. If no date to compare, the current Date ("now") is used. * @return {Boolean} true if this Date instance occurs on the same Day as the supplied 'date'. */ $P.isToday = $P.isSameDay = function (date) { return this.clone().clearTime().equals((date || new Date()).clone().clearTime()); }; /** * Adds the specified number of milliseconds to this instance. * @param {Number} The number of milliseconds to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addMilliseconds = function (value) { if (!value) { return this; } this.setTime(this.getTime() + value * 1); return this; }; /** * Adds the specified number of seconds to this instance. * @param {Number} The number of seconds to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addSeconds = function (value) { if (!value) { return this; } return this.addMilliseconds(value * 1000); }; /** * Adds the specified number of seconds to this instance. * @param {Number} The number of seconds to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addMinutes = function (value) { if (!value) { return this; } return this.addMilliseconds(value * 60000); // 60*1000 }; /** * Adds the specified number of hours to this instance. * @param {Number} The number of hours to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addHours = function (value) { if (!value) { return this; } return this.addMilliseconds(value * 3600000); // 60*60*1000 }; /** * Adds the specified number of days to this instance. * @param {Number} The number of days to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addDays = function (value) { if (!value) { return this; } this.setDate(this.getDate() + value * 1); return this; }; /** * Adds the specified number of weekdays (ie - not sat or sun) to this instance. * @param {Number} The number of days to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addWeekdays = function (value) { if (!value) { return this; } var day = this.getDay(); var weeks = (Math.ceil(Math.abs(value)/7)); if (day === 0 || day === 6) { if (value > 0) { this.next().monday(); this.addDays(-1); day = this.getDay(); } } if (value < 0) { while (value < 0) { this.addDays(-1); day = this.getDay(); if (day !== 0 && day !== 6) { value++; } } return this; } else if (value > 5 || (6-day) <= value) { value = value + (weeks * 2); } return this.addDays(value); }; /** * Adds the specified number of weeks to this instance. * @param {Number} The number of weeks to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addWeeks = function (value) { if (!value) { return this; } return this.addDays(value * 7); }; /** * Adds the specified number of months to this instance. * @param {Number} The number of months to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addMonths = function (value) { if (!value) { return this; } var n = this.getDate(); this.setDate(1); this.setMonth(this.getMonth() + value * 1); this.setDate(Math.min(n, $D.getDaysInMonth(this.getFullYear(), this.getMonth()))); return this; }; $P.addQuarters = function (value) { if (!value) { return this; } // note this will take you to the same point in the quarter as you are now. // i.e. - if you are 15 days into the quarter you'll be 15 days into the resulting one. // bonus: this allows adding fractional quarters return this.addMonths(value * 3); }; /** * Adds the specified number of years to this instance. * @param {Number} The number of years to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addYears = function (value) { if (!value) { return this; } return this.addMonths(value * 12); }; /** * Adds (or subtracts) to the value of the years, months, weeks, days, hours, minutes, seconds, milliseconds of the date instance using given configuration object. Positive and Negative values allowed. * Example

	Date.today().add( { days: 1, months: 1 } )

	new Date().add( { years: -1 } )
	
* @param {Object} Configuration object containing attributes (months, days, etc.) * @return {Date} this */ $P.add = function (config) { if (typeof config === "number") { this._orient = config; return this; } var x = config; if (x.day) { // If we should be a different date than today (eg: for 'tomorrow -1d', etc). // Should only effect parsing, not direct usage (eg, Finish and FinishExact) if ((x.day - this.getDate()) !== 0) { this.setDate(x.day); } } if (x.milliseconds) { this.addMilliseconds(x.milliseconds); } if (x.seconds) { this.addSeconds(x.seconds); } if (x.minutes) { this.addMinutes(x.minutes); } if (x.hours) { this.addHours(x.hours); } if (x.weeks) { this.addWeeks(x.weeks); } if (x.months) { this.addMonths(x.months); } if (x.years) { this.addYears(x.years); } if (x.days) { this.addDays(x.days); } return this; }; /** * Get the week number. Week one (1) is the week which contains the first Thursday of the year. Monday is considered the first day of the week. * The .getWeek() function does NOT convert the date to UTC. The local datetime is used. * Please use .getISOWeek() to get the week of the UTC converted date. * @return {Number} 1 to 53 */ $P.getWeek = function (utc) { // Create a copy of this date object var self, target = new Date(this.valueOf()); if (utc) { target.addMinutes(target.getTimezoneOffset()); self = target.clone(); } else { self = this; } // ISO week date weeks start on monday // so correct the day number var dayNr = (self.getDay() + 6) % 7; // ISO 8601 states that week 1 is the week // with the first thursday of that year. // Set the target date to the thursday in the target week target.setDate(target.getDate() - dayNr + 3); // Store the millisecond value of the target date var firstThursday = target.valueOf(); // Set the target to the first thursday of the year // First set the target to january first target.setMonth(0, 1); // Not a thursday? Correct the date to the next thursday if (target.getDay() !== 4) { target.setMonth(0, 1 + ((4 - target.getDay()) + 7) % 7); } // The weeknumber is the number of weeks between the // first thursday of the year and the thursday in the target week return 1 + Math.ceil((firstThursday - target) / 604800000); // 604800000 = 7 * 24 * 3600 * 1000 }; /** * Get the ISO 8601 week number. Week one ("01") is the week which contains the first Thursday of the year. Monday is considered the first day of the week. * The .getISOWeek() function does convert the date to it's UTC value. Please use .getWeek() to get the week of the local date. * @return {String} "01" to "53" */ $P.getISOWeek = function () { return p(this.getWeek(true)); }; /** * Moves the date to Monday of the week set. Week one (1) is the week which contains the first Thursday of the year. * @param {Number} A Number (1 to 53) that represents the week of the year. * @return {Date} this */ $P.setWeek = function (n) { if ((n - this.getWeek()) === 0) { if (this.getDay() !== 1) { return this.moveToDayOfWeek(1, (this.getDay() > 1 ? -1 : 1)); } else { return this; } } else { return this.moveToDayOfWeek(1, (this.getDay() > 1 ? -1 : 1)).addWeeks(n - this.getWeek()); } }; $P.setQuarter = function (qtr) { var month = Math.abs(((qtr-1) * 3) + 1); return this.setMonth(month, 1); }; $P.getQuarter = function () { return Date.getQuarter(this); }; $P.getDaysLeftInQuarter = function () { return Date.getDaysLeftInQuarter(this); }; /** * Moves the date to the next n'th occurrence of the dayOfWeek starting from the beginning of the month. The number (-1) is a magic number and will return the last occurrence of the dayOfWeek in the month. * @param {Number} The dayOfWeek to move to * @param {Number} The n'th occurrence to move to. Use (-1) to return the last occurrence in the month * @return {Date} this */ $P.moveToNthOccurrence = function (dayOfWeek, occurrence) { if (dayOfWeek === "Weekday") { if (occurrence > 0) { this.moveToFirstDayOfMonth(); if (this.is().weekday()) { occurrence -= 1; } } else if (occurrence < 0) { this.moveToLastDayOfMonth(); if (this.is().weekday()) { occurrence += 1; } } else { return this; } return this.addWeekdays(occurrence); } var shift = 0; if (occurrence > 0) { shift = occurrence - 1; } else if (occurrence === -1) { this.moveToLastDayOfMonth(); if (this.getDay() !== dayOfWeek) { this.moveToDayOfWeek(dayOfWeek, -1); } return this; } return this.moveToFirstDayOfMonth().addDays(-1).moveToDayOfWeek(dayOfWeek, +1).addWeeks(shift); }; var moveToN = function (getFunc, addFunc, nVal) { return function (value, orient) { var diff = (value - this[getFunc]() + nVal * (orient || +1)) % nVal; return this[addFunc]((diff === 0) ? diff += nVal * (orient || +1) : diff); }; }; /** * Move to the next or last dayOfWeek based on the orient value. * @param {Number} The dayOfWeek to move to * @param {Number} Forward (+1) or Back (-1). Defaults to +1. [Optional] * @return {Date} this */ $P.moveToDayOfWeek = moveToN("getDay", "addDays", 7); /** * Move to the next or last month based on the orient value. * @param {Number} The month to move to. 0 = January, 11 = December * @param {Number} Forward (+1) or Back (-1). Defaults to +1. [Optional] * @return {Date} this */ $P.moveToMonth = moveToN("getMonth", "addMonths", 12); /** * Get the Ordinate of the current day ("th", "st", "rd"). * @return {String} */ $P.getOrdinate = function () { var num = this.getDate(); return ord(num); }; /** * Get the Ordinal day (numeric day number) of the year, adjusted for leap year. * @return {Number} 1 through 365 (366 in leap years) */ $P.getOrdinalNumber = function () { return Math.ceil((this.clone().clearTime() - new Date(this.getFullYear(), 0, 1)) / 86400000) + 1; }; /** * Get the time zone abbreviation of the current date. * @return {String} The abbreviated time zone name (e.g. "EST") */ $P.getTimezone = function () { return $D.getTimezoneAbbreviation(this.getUTCOffset(), this.isDaylightSavingTime()); }; $P.setTimezoneOffset = function (offset) { var here = this.getTimezoneOffset(), there = Number(offset) * -6 / 10; return (there || there === 0) ? this.addMinutes(there - here) : this; }; $P.setTimezone = function (offset) { return this.setTimezoneOffset($D.getTimezoneOffset(offset)); }; /** * Indicates whether Daylight Saving Time is observed in the current time zone. * @return {Boolean} true|false */ $P.hasDaylightSavingTime = function () { return (Date.today().set({month: 0, day: 1}).getTimezoneOffset() !== Date.today().set({month: 6, day: 1}).getTimezoneOffset()); }; /** * Indicates whether this Date instance is within the Daylight Saving Time range for the current time zone. * @return {Boolean} true|false */ $P.isDaylightSavingTime = function () { return Date.today().set({month: 0, day: 1}).getTimezoneOffset() !== this.getTimezoneOffset(); }; /** * Get the offset from UTC of the current date. * @return {String} The 4-character offset string prefixed with + or - (e.g. "-0500") */ $P.getUTCOffset = function (offset) { var n = (offset || this.getTimezoneOffset()) * -10 / 6, r; if (n < 0) { r = (n - 10000).toString(); return r.charAt(0) + r.substr(2); } else { r = (n + 10000).toString(); return "+" + r.substr(1); } }; /** * Returns the number of milliseconds between this date and date. * @param {Date} Defaults to now * @return {Number} The diff in milliseconds */ $P.getElapsed = function (date) { return (date || new Date()) - this; }; /** * Set the value of year, month, day, hour, minute, second, millisecond of date instance using given configuration object. * Example

	Date.today().set( { day: 20, month: 1 } )

	new Date().set( { millisecond: 0 } )
	
* * @param {Object} Configuration object containing attributes (month, day, etc.) * @return {Date} this */ $P.set = function (config) { config = validateConfigObject.call(this, config); var key; for (key in config) { if (Object.prototype.hasOwnProperty.call(config, key)) { var name = key.charAt(0).toUpperCase() + key.slice(1); var addFunc, getFunc; if (key !== "week" && key !== "month" && key !== "timezone" && key !== "timezoneOffset") { name += "s"; } addFunc = "add" + name; getFunc = "get" + name; if (key === "month") { addFunc = addFunc + "s"; } else if (key === "year"){ getFunc = "getFullYear"; } if (key !== "day" && key !== "timezone" && key !== "timezoneOffset" && key !== "week" && key !== "hour") { this[addFunc](config[key] - this[getFunc]()); } else if ( key === "timezone"|| key === "timezoneOffset" || key === "week" || key === "hour") { this["set"+name](config[key]); } } } // day has to go last because you can't validate the day without first knowing the month if (config.day) { this.addDays(config.day - this.getDate()); } return this; }; /** * Moves the date to the first day of the month. * @return {Date} this */ $P.moveToFirstDayOfMonth = function () { return this.set({ day: 1 }); }; /** * Moves the date to the last day of the month. * @return {Date} this */ $P.moveToLastDayOfMonth = function () { return this.set({ day: $D.getDaysInMonth(this.getFullYear(), this.getMonth())}); }; /** * Converts the value of the current Date object to its equivalent string representation. * Format Specifiers * CUSTOM DATE AND TIME FORMAT STRINGS * Format Description Example * ------ --------------------------------------------------------------------------- ----------------------- * s The seconds of the minute between 0-59. "0" to "59" * ss The seconds of the minute with leading zero if required. "00" to "59" * * m The minute of the hour between 0-59. "0" or "59" * mm The minute of the hour with leading zero if required. "00" or "59" * * h The hour of the day between 1-12. "1" to "12" * hh The hour of the day with leading zero if required. "01" to "12" * * H The hour of the day between 0-23. "0" to "23" * HH The hour of the day with leading zero if required. "00" to "23" * * d The day of the month between 1 and 31. "1" to "31" * dd The day of the month with leading zero if required. "01" to "31" * ddd Abbreviated day name. Date.CultureInfo.abbreviatedDayNames. "Mon" to "Sun" * dddd The full day name. Date.CultureInfo.dayNames. "Monday" to "Sunday" * * M The month of the year between 1-12. "1" to "12" * MM The month of the year with leading zero if required. "01" to "12" * MMM Abbreviated month name. Date.CultureInfo.abbreviatedMonthNames. "Jan" to "Dec" * MMMM The full month name. Date.CultureInfo.monthNames. "January" to "December" * * yy The year as a two-digit number. "99" or "08" * yyyy The full four digit year. "1999" or "2008" * * t Displays the first character of the A.M./P.M. designator. "A" or "P" * Date.CultureInfo.amDesignator or Date.CultureInfo.pmDesignator * tt Displays the A.M./P.M. designator. "AM" or "PM" * Date.CultureInfo.amDesignator or Date.CultureInfo.pmDesignator * * S The ordinal suffix ("st, "nd", "rd" or "th") of the current day. "st, "nd", "rd" or "th" * * STANDARD DATE AND TIME FORMAT STRINGS * Format Description Example *------ --------------------------------------------------------------------------- ----------------------- * d The CultureInfo shortDate Format Pattern "M/d/yyyy" * D The CultureInfo longDate Format Pattern "dddd, MMMM dd, yyyy" * F The CultureInfo fullDateTime Format Pattern "dddd, MMMM dd, yyyy h:mm:ss tt" * m The CultureInfo monthDay Format Pattern "MMMM dd" * r The CultureInfo rfc1123 Format Pattern "ddd, dd MMM yyyy HH:mm:ss GMT" * s The CultureInfo sortableDateTime Format Pattern "yyyy-MM-ddTHH:mm:ss" * t The CultureInfo shortTime Format Pattern "h:mm tt" * T The CultureInfo longTime Format Pattern "h:mm:ss tt" * u The CultureInfo universalSortableDateTime Format Pattern "yyyy-MM-dd HH:mm:ssZ" * y The CultureInfo yearMonth Format Pattern "MMMM, yyyy" * * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @return {String} A string representation of the current Date object. */ var ord = function (n) { switch (n * 1) { case 1: case 21: case 31: return "st"; case 2: case 22: return "nd"; case 3: case 23: return "rd"; default: return "th"; } }; var parseStandardFormats = function (format) { var y, c = Date.CultureInfo.formatPatterns; switch (format) { case "d": return this.toString(c.shortDate); case "D": return this.toString(c.longDate); case "F": return this.toString(c.fullDateTime); case "m": return this.toString(c.monthDay); case "r": case "R": y = this.clone().addMinutes(this.getTimezoneOffset()); return y.toString(c.rfc1123) + " GMT"; case "s": return this.toString(c.sortableDateTime); case "t": return this.toString(c.shortTime); case "T": return this.toString(c.longTime); case "u": y = this.clone().addMinutes(this.getTimezoneOffset()); return y.toString(c.universalSortableDateTime); case "y": return this.toString(c.yearMonth); default: return false; } }; var parseFormatStringsClosure = function (context) { return function (m) { if (m.charAt(0) === "\\") { return m.replace("\\", ""); } switch (m) { case "hh": return p(context.getHours() < 13 ? (context.getHours() === 0 ? 12 : context.getHours()) : (context.getHours() - 12)); case "h": return context.getHours() < 13 ? (context.getHours() === 0 ? 12 : context.getHours()) : (context.getHours() - 12); case "HH": return p(context.getHours()); case "H": return context.getHours(); case "mm": return p(context.getMinutes()); case "m": return context.getMinutes(); case "ss": return p(context.getSeconds()); case "s": return context.getSeconds(); case "yyyy": return p(context.getFullYear(), 4); case "yy": return p(context.getFullYear()); case "y": return context.getFullYear(); case "E": case "dddd": return Date.CultureInfo.dayNames[context.getDay()]; case "ddd": return Date.CultureInfo.abbreviatedDayNames[context.getDay()]; case "dd": return p(context.getDate()); case "d": return context.getDate(); case "MMMM": return Date.CultureInfo.monthNames[context.getMonth()]; case "MMM": return Date.CultureInfo.abbreviatedMonthNames[context.getMonth()]; case "MM": return p((context.getMonth() + 1)); case "M": return context.getMonth() + 1; case "t": return context.getHours() < 12 ? Date.CultureInfo.amDesignator.substring(0, 1) : Date.CultureInfo.pmDesignator.substring(0, 1); case "tt": return context.getHours() < 12 ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator; case "S": return ord(context.getDate()); case "W": return context.getWeek(); case "WW": return context.getISOWeek(); case "Q": return "Q" + context.getQuarter(); case "q": return String(context.getQuarter()); case "z": return context.getTimezone(); case "Z": case "X": return Date.getTimezoneOffset(context.getTimezone()); case "ZZ": // Timezone offset in seconds return context.getTimezoneOffset() * -60; case "u": return context.getDay(); case "L": return ($D.isLeapYear(context.getFullYear())) ? 1 : 0; case "B": // Swatch Internet Time (.beats) return "@"+((context.getUTCSeconds() + (context.getUTCMinutes()*60) + ((context.getUTCHours()+1)*3600))/86.4); default: return m; } }; }; $P.toString = function (format, ignoreStandards) { // Standard Date and Time Format Strings. Formats pulled from CultureInfo file and // may vary by culture. if (!ignoreStandards && format && format.length === 1) { output = parseStandardFormats.call(this, format); if (output) { return output; } } var parseFormatStrings = parseFormatStringsClosure(this); return format ? format.replace(/((\\)?(dd?d?d?|MM?M?M?|yy?y?y?|hh?|HH?|mm?|ss?|tt?|S|q|Q|WW?W?W?)(?![^\[]*\]))/g, parseFormatStrings).replace(/\[|\]/g, "") : this._toString(); }; }()); /************************************************************* * SugarPak - Domain Specific Language - Syntactical Sugar * *************************************************************/ (function () { var $D = Date, $P = $D.prototype, $N = Number.prototype; // private $P._orient = +1; // private $P._nth = null; // private $P._is = false; // private $P._same = false; // private $P._isSecond = false; // private $N._dateElement = "days"; /** * Moves the date to the next instance of a date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.today().next().friday();
	Date.today().next().fri();
	Date.today().next().march();
	Date.today().next().mar();
	Date.today().next().week();
	
* * @return {Date} date */ $P.next = function () { this._move = true; this._orient = +1; return this; }; /** * Creates a new Date (Date.today()) and moves the date to the next instance of the date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.next().friday();
	Date.next().fri();
	Date.next().march();
	Date.next().mar();
	Date.next().week();
	
* * @return {Date} date */ $D.next = function () { return $D.today().next(); }; /** * Moves the date to the previous instance of a date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.today().last().friday();
	Date.today().last().fri();
	Date.today().last().march();
	Date.today().last().mar();
	Date.today().last().week();
	
* * @return {Date} date */ $P.last = $P.prev = $P.previous = function () { this._move = true; this._orient = -1; return this; }; /** * Creates a new Date (Date.today()) and moves the date to the previous instance of the date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.last().friday();
	Date.last().fri();
	Date.previous().march();
	Date.prev().mar();
	Date.last().week();
	
* * @return {Date} date */ $D.last = $D.prev = $D.previous = function () { return $D.today().last(); }; /** * Performs a equality check when followed by either a month name, day name or .weekday() function. * Example

	Date.today().is().friday(); // true|false
	Date.today().is().fri();
	Date.today().is().march();
	Date.today().is().mar();
	
* * @return {Boolean} true|false */ $P.is = function () { this._is = true; return this; }; /** * Determines if two date objects occur on/in exactly the same instance of the subsequent date part function. * The function .same() must be followed by a date part function (example: .day(), .month(), .year(), etc). * * An optional Date can be passed in the date part function. If now date is passed as a parameter, 'Now' is used. * * The following example demonstrates how to determine if two dates fall on the exact same day. * * Example

	var d1 = Date.today(); // today at 00:00
	var d2 = new Date();   // exactly now.

	// Do they occur on the same day?
	d1.same().day(d2); // true
	
	// Do they occur on the same hour?
	d1.same().hour(d2); // false, unless d2 hour is '00' (midnight).
	
	// What if it's the same day, but one year apart?
	var nextYear = Date.today().add(1).year();

	d1.same().day(nextYear); // false, because the dates must occur on the exact same day. 
	
* * Scenario: Determine if a given date occurs during some week period 2 months from now. * * Example

	var future = Date.today().add(2).months();
	return someDate.same().week(future); // true|false;
	
* * @return {Boolean} true|false */ $P.same = function () { this._same = true; this._isSecond = false; return this; }; /** * Determines if the current date/time occurs during Today. Must be preceded by the .is() function. * Example

	someDate.is().today();    // true|false
	new Date().is().today();  // true
	Date.today().is().today();// true
	Date.today().add(-1).day().is().today(); // false
	
* * @return {Boolean} true|false */ $P.today = function () { return this.same().day(); }; /** * Determines if the current date is a weekday. This function must be preceded by the .is() function. * Example

	Date.today().is().weekday(); // true|false
	
* * @return {Boolean} true|false */ $P.weekday = function () { if (this._nth) { return df("Weekday").call(this); } if (this._move) { return this.addWeekdays(this._orient); } if (this._is) { this._is = false; return (!this.is().sat() && !this.is().sun()); } return false; }; /** * Determines if the current date is on the weekend. This function must be preceded by the .is() function. * Example

	Date.today().is().weekend(); // true|false
	
* * @return {Boolean} true|false */ $P.weekend = function () { if (this._is) { this._is = false; return (this.is().sat() || this.is().sun()); } return false; }; /** * Sets the Time of the current Date instance. A string "6:15 pm" or config object {hour:18, minute:15} are accepted. * Example

	// Set time to 6:15pm with a String
	Date.today().at("6:15pm");

	// Set time to 6:15pm with a config object
	Date.today().at({hour:18, minute:15});
	
* * @return {Date} date */ $P.at = function (time) { return (typeof time === "string") ? $D.parse(this.toString("d") + " " + time) : this.set(time); }; /** * Creates a new Date() and adds this (Number) to the date based on the preceding date element function (eg. second|minute|hour|day|month|year). * Example

	// Undeclared Numbers must be wrapped with parentheses. Requirment of JavaScript.
	(3).days().fromNow();
	(6).months().fromNow();

	// Declared Number variables do not require parentheses. 
	var n = 6;
	n.months().fromNow();
	
* * @return {Date} A new Date instance */ $N.fromNow = $N.after = function (date) { var c = {}; c[this._dateElement] = this; return ((!date) ? new Date() : date.clone()).add(c); }; /** * Creates a new Date() and subtract this (Number) from the date based on the preceding date element function (eg. second|minute|hour|day|month|year). * Example

	// Undeclared Numbers must be wrapped with parentheses. Requirment of JavaScript.
	(3).days().ago();
	(6).months().ago();

	// Declared Number variables do not require parentheses. 
	var n = 6;
	n.months().ago();
	
* * @return {Date} A new Date instance */ $N.ago = $N.before = function (date) { var c = {}, s = (this._dateElement[this._dateElement.length-1] !== "s") ? this._dateElement + "s" : this._dateElement; c[s] = this * -1; return ((!date) ? new Date() : date.clone()).add(c); }; // Do NOT modify the following string tokens. These tokens are used to build dynamic functions. // All culture-specific strings can be found in the CultureInfo files. var dx = ("sunday monday tuesday wednesday thursday friday saturday").split(/\s/), mx = ("january february march april may june july august september october november december").split(/\s/), px = ("Millisecond Second Minute Hour Day Week Month Year Quarter Weekday").split(/\s/), pxf = ("Milliseconds Seconds Minutes Hours Date Week Month FullYear Quarter").split(/\s/), nth = ("final first second third fourth fifth").split(/\s/), de; /** * Returns an object literal of all the date parts. * Example

	var o = new Date().toObject();
	
	// { year: 2008, month: 4, week: 20, day: 13, hour: 18, minute: 9, second: 32, millisecond: 812 }
	
	// The object properties can be referenced directly from the object.
	
	alert(o.day);  // alerts "13"
	alert(o.year); // alerts "2008"
	
* * @return {Date} An object literal representing the original date object. */ $P.toObject = function () { var o = {}; for (var i = 0; i < px.length; i++) { if (this["get" + pxf[i]]) { o[px[i].toLowerCase()] = this["get" + pxf[i]](); } } return o; }; /** * Returns a date created from an object literal. Ignores the .week property if set in the config. * Example

	var o = new Date().toObject();
	
	return Date.fromObject(o); // will return the same date. 

	var o2 = {month: 1, day: 20, hour: 18}; // birthday party!
	Date.fromObject(o2);
	
* * @return {Date} An object literal representing the original date object. */ $D.fromObject = function(config) { config.week = null; return Date.today().set(config); }; // Create day name functions and abbreviated day name functions (eg. monday(), friday(), fri()). var df = function (n) { return function () { if (this._is) { this._is = false; return this.getDay() === n; } if (this._move) { this._move = null; } if (this._nth !== null) { // If the .second() function was called earlier, remove the _orient // from the date, and then continue. // This is required because 'second' can be used in two different context. // // Example // // Date.today().add(1).second(); // Date.march().second().monday(); // // Things get crazy with the following... // Date.march().add(1).second().second().monday(); // but it works!! // if (this._isSecond) { this.addSeconds(this._orient * -1); } // make sure we reset _isSecond this._isSecond = false; var ntemp = this._nth; this._nth = null; var temp = this.clone().moveToLastDayOfMonth(); this.moveToNthOccurrence(n, ntemp); if (this > temp) { throw new RangeError($D.getDayName(n) + " does not occur " + ntemp + " times in the month of " + $D.getMonthName(temp.getMonth()) + " " + temp.getFullYear() + "."); } return this; } return this.moveToDayOfWeek(n, this._orient); }; }; var sdf = function (n) { return function () { var t = $D.today(), shift = n - t.getDay(); if (n === 0 && Date.CultureInfo.firstDayOfWeek === 1 && t.getDay() !== 0) { shift = shift + 7; } return t.addDays(shift); }; }; // Create month name functions and abbreviated month name functions (eg. january(), march(), mar()). var month_instance_functions = function (n) { return function () { if (this._is) { this._is = false; return this.getMonth() === n; } return this.moveToMonth(n, this._orient); }; }; var month_static_functions = function (n) { return function () { return $D.today().set({ month: n, day: 1 }); }; }; var processTerms = function (names, staticFunc, instanceFunc) { for (var i = 0; i < names.length; i++) { // Create constant static Name variables. $D[names[i].toUpperCase()] = $D[names[i].toUpperCase().substring(0, 3)] = i; // Create Name functions. $D[names[i]] = $D[names[i].substring(0, 3)] = staticFunc(i); // Create Name instance functions. $P[names[i]] = $P[names[i].substring(0, 3)] = instanceFunc(i); } }; processTerms(dx, sdf, df); processTerms(mx, month_static_functions, month_instance_functions); // Create date element functions and plural date element functions used with Date (eg. day(), days(), months()). var ef = function (j) { return function () { // if the .second() function was called earlier, the _orient // has alread been added. Just return this and reset _isSecond. if (this._isSecond) { this._isSecond = false; return this; } if (this._same) { this._same = this._is = false; var o1 = this.toObject(), o2 = (arguments[0] || new Date()).toObject(), v = "", k = j.toLowerCase(); // the substr trick with -1 doesn't work in IE8 or less k = (k[k.length-1] === "s") ? k.substring(0,k.length-1) : k; for (var m = (px.length - 1); m > -1; m--) { v = px[m].toLowerCase(); if (o1[v] !== o2[v]) { return false; } if (k === v) { break; } } return true; } if (j.substring(j.length - 1) !== "s") { j += "s"; } if (this._move) { this._move = null; } return this["add" + j](this._orient); }; }; var nf = function (n) { return function () { this._dateElement = n; return this; }; }; for (var k = 0; k < px.length; k++) { de = px[k].toLowerCase(); if(de !== "weekday") { // Create date element functions and plural date element functions used with Date (eg. day(), days(), months()). $P[de] = $P[de + "s"] = ef(px[k]); // Create date element functions and plural date element functions used with Number (eg. day(), days(), months()). $N[de] = $N[de + "s"] = nf(de + "s"); } } $P._ss = ef("Second"); var nthfn = function (n) { return function (dayOfWeek) { if (this._same) { return this._ss(arguments[0]); } if (dayOfWeek || dayOfWeek === 0) { return this.moveToNthOccurrence(dayOfWeek, n); } this._nth = n; // if the operator is 'second' add the _orient, then deal with it later... if (n === 2 && (dayOfWeek === undefined || dayOfWeek === null)) { this._isSecond = true; return this.addSeconds(this._orient); } return this; }; }; for (var l = 0; l < nth.length; l++) { $P[nth[l]] = (l === 0) ? nthfn(-1) : nthfn(l); } }()); (function () { "use strict"; Date.Parsing = { Exception: function (s) { this.message = "Parse error at '" + s.substring(0, 10) + " ...'"; } }; var $P = Date.Parsing; var dayOffsets = { standard: [0,31,59,90,120,151,181,212,243,273,304,334], leap: [0,31,60,91,121,152,182,213,244,274,305,335] }; $P.isLeapYear = function(year) { return ((year % 4 === 0) && (year % 100 !== 0)) || (year % 400 === 0); }; var utils = { multiReplace : function (str, hash ) { var key; for (key in hash) { if (Object.prototype.hasOwnProperty.call(hash, key)) { var regex; if (typeof hash[key] === "function") { } else { regex = (hash[key] instanceof RegExp) ? hash[key] : new RegExp(hash[key], "g"); } str = str.replace(regex, key); } } return str; }, getDayOfYearFromWeek : function (obj) { var d, jan4, offset; obj.weekDay = (!obj.weekDay && obj.weekDay !== 0) ? 1 : obj.weekDay; d = new Date(obj.year, 0, 4); jan4 = d.getDay() === 0 ? 7 : d.getDay(); // JS is 0 indexed on Sunday. offset = jan4+3; obj.dayOfYear = ((obj.week * 7) + (obj.weekDay === 0 ? 7 : obj.weekDay))-offset; return obj; }, getDayOfYear : function (obj, dayOffset) { if (!obj.dayOfYear) { obj = utils.getDayOfYearFromWeek(obj); } for (var i=0;i <= dayOffset.length;i++) { if (obj.dayOfYear < dayOffset[i] || i === dayOffset.length) { obj.day = obj.day ? obj.day : (obj.dayOfYear - dayOffset[i-1]); break; } else { obj.month = i; } } return obj; }, adjustForTimeZone : function (obj, date) { var offset; if (obj.zone.toUpperCase() === "Z" || (obj.zone_hours === 0 && obj.zone_minutes === 0)) { // it's UTC/GML so work out the current timeszone offset offset = -date.getTimezoneOffset(); } else { offset = (obj.zone_hours*60) + (obj.zone_minutes || 0); if (obj.zone_sign === "+") { offset *= -1; } offset -= date.getTimezoneOffset(); } date.setMinutes(date.getMinutes()+offset); return date; }, setDefaults : function (obj) { obj.year = obj.year || Date.today().getFullYear(); obj.hours = obj.hours || 0; obj.minutes = obj.minutes || 0; obj.seconds = obj.seconds || 0; obj.milliseconds = obj.milliseconds || 0; if (!(!obj.month && (obj.week || obj.dayOfYear))) { // if we have a month, or if we don't but don't have the day calculation data obj.month = obj.month || 0; obj.day = obj.day || 1; } return obj; }, dataNum: function (data, mod, explict, postProcess) { var dataNum = data*1; if (mod) { if (postProcess) { return data ? mod(data)*1 : data; } else { return data ? mod(dataNum) : data; } } else if (!explict){ return data ? dataNum : data; } else { return (data && typeof data !== "undefined") ? dataNum : data; } }, timeDataProcess: function (obj) { var timeObj = {}; for (var x in obj.data) { if (obj.data.hasOwnProperty(x)) { timeObj[x] = obj.ignore[x] ? obj.data[x] : utils.dataNum(obj.data[x], obj.mods[x], obj.explict[x], obj.postProcess[x]); } } if (obj.data.secmins) { obj.data.secmins = obj.data.secmins.replace(",", ".") * 60; if (!timeObj.minutes) { timeObj.minutes = obj.data.secmins; } else if (!timeObj.seconds) { timeObj.seconds = obj.data.secmins; } delete obj.secmins; } return timeObj; }, buildTimeObjectFromData: function (data) { var time = utils.timeDataProcess({ data: { year : data[1], month : data[5], day : data[7], week : data[8], dayOfYear : data[10], hours : data[15], zone_hours : data[23], zone_minutes : data[24], zone : data[21], zone_sign : data[22], weekDay : data[9], minutes: data[16], seconds: data[19], milliseconds: data[20], secmins: data[18] }, mods: { month: function(data) { return data-1; }, weekDay: function (data) { data = Math.abs(data); return (data === 7 ? 0 : data); }, minutes: function (data) { return data.replace(":",""); }, seconds: function (data) { return Math.floor( (data.replace(":","").replace(",","."))*1 ); }, milliseconds: function (data) { return (data.replace(",",".")*1000); } }, postProcess: { minutes: true, seconds: true, milliseconds: true }, explict: { zone_hours: true, zone_minutes: true }, ignore: { zone: true, zone_sign: true, secmins: true } }); return time; }, addToHash: function (hash, keys, data) { keys = keys; data = data; var len = keys.length; for (var i = 0; i < len; i++) { hash[keys[i]] = data[i]; } return hash; }, combineRegex: function (r1, r2) { return new RegExp("(("+r1.source+")\\s("+r2.source+"))"); }, getDateNthString: function(add, last, inc){ if (add) { return Date.today().addDays(inc).toString("d"); } else if (last) { return Date.today().last()[inc]().toString("d"); } }, buildRegexData: function (array) { var arr = []; var len = array.length; for (var i=0; i < len; i++) { if (Object.prototype.toString.call(array[i]) === '[object Array]') { // oldIE compat version of Array.isArray arr.push(this.combineRegex(array[i][0], array[i][1])); } else { arr.push(array[i]); } } return arr; } }; $P.processTimeObject = function (obj) { var date, dayOffset; utils.setDefaults(obj); dayOffset = ($P.isLeapYear(obj.year)) ? dayOffsets.leap : dayOffsets.standard; if (!obj.month && (obj.week || obj.dayOfYear)) { utils.getDayOfYear(obj, dayOffset); } else { obj.dayOfYear = dayOffset[obj.month] + obj.day; } date = new Date(obj.year, obj.month, obj.day, obj.hours, obj.minutes, obj.seconds, obj.milliseconds); if (obj.zone) { utils.adjustForTimeZone(obj, date); // adjust (and calculate) for timezone } return date; }; $P.ISO = { regex : /^([\+-]?\d{4}(?!\d{2}\b))((-?)((0[1-9]|1[0-2])(\3([12]\d|0[1-9]|3[01]))?|W([0-4]\d|5[0-3])(-?[1-7])?|(00[1-9]|0[1-9]\d|[12]\d{2}|3([0-5]\d|6[1-6])))([T\s]((([01]\d|2[0-4])((:?)[0-5]\d)?|24\:?00)([\.,]\d+(?!:))?)?(\17[0-5]\d([\.,]\d+)?)?\s?([zZ]|([\+-])([01]\d|2[0-3]):?([0-5]\d)?)?)?)?$/, parse : function (s) { var time, data = s.match(this.regex); if (!data || !data.length) { return null; } time = utils.buildTimeObjectFromData(data); if (!time.year || (!time.year && (!time.month && !time.day) && (!time.week && !time.dayOfYear)) ) { return null; } return $P.processTimeObject(time); } }; $P.Numeric = { isNumeric: function (e){return!isNaN(parseFloat(e))&&isFinite(e);}, regex: /\b([0-1]?[0-9])([0-3]?[0-9])([0-2]?[0-9]?[0-9][0-9])\b/i, parse: function (s) { var data, i, time = {}, order = Date.CultureInfo.dateElementOrder.split(""); if (!(this.isNumeric(s)) || // if it's non-numeric OR (s[0] === "+" && s[0] === "-")) { // It's an arithmatic string (eg +/-1000) return null; } if (s.length < 5 && s.indexOf(".") < 0 && s.indexOf("/") < 0) { // assume it's just a year. time.year = s; return $P.processTimeObject(time); } data = s.match(this.regex); if (!data || !data.length) { return null; } for (i=0; i < order.length; i++) { switch(order[i]) { case "d": time.day = data[i+1]; break; case "m": time.month = (data[i+1]-1); break; case "y": time.year = data[i+1]; break; } } return $P.processTimeObject(time); } }; $P.Normalizer = { regexData: function () { var $R = Date.CultureInfo.regexPatterns; return utils.buildRegexData([ $R.tomorrow, $R.yesterday, [$R.past, $R.mon], [$R.past, $R.tue], [$R.past, $R.wed], [$R.past, $R.thu], [$R.past, $R.fri], [$R.past, $R.sat], [$R.past, $R.sun] ]); }, basicReplaceHash : function() { var $R = Date.CultureInfo.regexPatterns; return { "January": $R.jan.source, "February": $R.feb, "March": $R.mar, "April": $R.apr, "May": $R.may, "June": $R.jun, "July": $R.jul, "August": $R.aug, "September": $R.sep, "October": $R.oct, "November": $R.nov, "December": $R.dec, "": /\bat\b/gi, " ": /\s{2,}/, "am": $R.inTheMorning, "9am": $R.thisMorning, "pm": $R.inTheEvening, "7pm":$R.thisEvening }; }, keys : function(){ return [ utils.getDateNthString(true, false, 1), // tomorrow utils.getDateNthString(true, false, -1), // yesterday utils.getDateNthString(false, true, "monday"), //last mon utils.getDateNthString(false, true, "tuesday"), //last tues utils.getDateNthString(false, true, "wednesday"), //last wed utils.getDateNthString(false, true, "thursday"), //last thurs utils.getDateNthString(false, true, "friday"), //last fri utils.getDateNthString(false, true, "saturday"), //last sat utils.getDateNthString(false, true, "sunday") //last sun ]; }, buildRegexFunctions: function () { var $R = Date.CultureInfo.regexPatterns; var __ = Date.i18n.__; var tomorrowRE = new RegExp("(\\b\\d\\d?("+__("AM")+"|"+__("PM")+")? )("+$R.tomorrow.source.slice(1)+")", "i"); // adapted tomorrow regex for AM PM relative dates var todayRE = new RegExp($R.today.source + "(?!\\s*([+-]))\\b"); // today, but excludes the math operators (eg "today + 2h") this.replaceFuncs = [ [todayRE, function (full) { return (full.length > 1) ? Date.today().toString("d") : full; }], [tomorrowRE, function(full, m1) { var t = Date.today().addDays(1).toString("d"); return (t + " " + m1); }], [$R.amThisMorning, function(str, am){return am;}], [$R.pmThisEvening, function(str, pm){return pm;}] ]; }, buildReplaceData: function () { this.buildRegexFunctions(); this.replaceHash = utils.addToHash(this.basicReplaceHash(), this.keys(), this.regexData()); }, stringReplaceFuncs: function (s) { for (var i=0; i < this.replaceFuncs.length; i++) { s = s.replace(this.replaceFuncs[i][0], this.replaceFuncs[i][1]); } return s; }, parse: function (s) { s = this.stringReplaceFuncs(s); s = utils.multiReplace(s, this.replaceHash); try { var n = s.split(/([\s\-\.\,\/\x27]+)/); if (n.length === 3 && $P.Numeric.isNumeric(n[0]) && $P.Numeric.isNumeric(n[2]) && (n[2].length >= 4)) { // ok, so we're dealing with x/year. But that's not a full date. // This fixes wonky dateElementOrder parsing when set to dmy order. if (Date.CultureInfo.dateElementOrder[0] === "d") { s = "1/" + n[0] + "/" + n[2]; // set to 1st of month and normalize the seperator } } } catch (e) {} return s; } }; $P.Normalizer.buildReplaceData(); }()); (function () { var $P = Date.Parsing; var _ = $P.Operators = { // // Tokenizers // rtoken: function (r) { // regex token return function (s) { var mx = s.match(r); if (mx) { return ([ mx[0], s.substring(mx[0].length) ]); } else { throw new $P.Exception(s); } }; }, token: function () { // whitespace-eating token return function (s) { return _.rtoken(new RegExp("^\\s*" + s + "\\s*"))(s); }; }, stoken: function (s) { // string token return _.rtoken(new RegExp("^" + s)); }, // Atomic Operators until: function (p) { return function (s) { var qx = [], rx = null; while (s.length) { try { rx = p.call(this, s); } catch (e) { qx.push(rx[0]); s = rx[1]; continue; } break; } return [ qx, s ]; }; }, many: function (p) { return function (s) { var rx = [], r = null; while (s.length) { try { r = p.call(this, s); } catch (e) { return [ rx, s ]; } rx.push(r[0]); s = r[1]; } return [ rx, s ]; }; }, // generator operators -- see below optional: function (p) { return function (s) { var r = null; try { r = p.call(this, s); } catch (e) { return [ null, s ]; } return [ r[0], r[1] ]; }; }, not: function (p) { return function (s) { try { p.call(this, s); } catch (e) { return [null, s]; } throw new $P.Exception(s); }; }, ignore: function (p) { return p ? function (s) { var r = null; r = p.call(this, s); return [null, r[1]]; } : null; }, product: function () { var px = arguments[0], qx = Array.prototype.slice.call(arguments, 1), rx = []; for (var i = 0 ; i < px.length ; i++) { rx.push(_.each(px[i], qx)); } return rx; }, cache: function (rule) { var cache = {}, cache_length = 0, cache_keys = [], CACHE_MAX = Date.Config.CACHE_MAX || 100000, r = null; var cacheCheck = function () { if (cache_length === CACHE_MAX) { // kill several keys, don't want to have to do this all the time... for (var i=0; i < 10; i++) { var key = cache_keys.shift(); if (key) { delete cache[key]; cache_length--; } } } }; return function (s) { cacheCheck(); try { r = cache[s] = (cache[s] || rule.call(this, s)); } catch (e) { r = cache[s] = e; } cache_length++; cache_keys.push(s); if (r instanceof $P.Exception) { throw r; } else { return r; } }; }, // vector operators -- see below any: function () { var px = arguments; return function (s) { var r = null; for (var i = 0; i < px.length; i++) { if (px[i] == null) { continue; } try { r = (px[i].call(this, s)); } catch (e) { r = null; } if (r) { return r; } } throw new $P.Exception(s); }; }, each: function () { var px = arguments; return function (s) { var rx = [], r = null; for (var i = 0; i < px.length ; i++) { if (px[i] == null) { continue; } try { r = (px[i].call(this, s)); } catch (e) { throw new $P.Exception(s); } rx.push(r[0]); s = r[1]; } return [ rx, s]; }; }, all: function () { var px = arguments, _ = _; return _.each(_.optional(px)); }, // delimited operators sequence: function (px, d, c) { d = d || _.rtoken(/^\s*/); c = c || null; if (px.length === 1) { return px[0]; } return function (s) { var r = null, q = null; var rx = []; for (var i = 0; i < px.length ; i++) { try { r = px[i].call(this, s); } catch (e) { break; } rx.push(r[0]); try { q = d.call(this, r[1]); } catch (ex) { q = null; break; } s = q[1]; } if (!r) { throw new $P.Exception(s); } if (q) { throw new $P.Exception(q[1]); } if (c) { try { r = c.call(this, r[1]); } catch (ey) { throw new $P.Exception(r[1]); } } return [ rx, (r?r[1]:s) ]; }; }, // // Composite Operators // between: function (d1, p, d2) { d2 = d2 || d1; var _fn = _.each(_.ignore(d1), p, _.ignore(d2)); return function (s) { var rx = _fn.call(this, s); return [[rx[0][0], r[0][2]], rx[1]]; }; }, list: function (p, d, c) { d = d || _.rtoken(/^\s*/); c = c || null; return (p instanceof Array ? _.each(_.product(p.slice(0, -1), _.ignore(d)), p.slice(-1), _.ignore(c)) : _.each(_.many(_.each(p, _.ignore(d))), px, _.ignore(c))); }, set: function (px, d, c) { d = d || _.rtoken(/^\s*/); c = c || null; return function (s) { // r is the current match, best the current 'best' match // which means it parsed the most amount of input var r = null, p = null, q = null, rx = null, best = [[], s], last = false; // go through the rules in the given set for (var i = 0; i < px.length ; i++) { // last is a flag indicating whether this must be the last element // if there is only 1 element, then it MUST be the last one q = null; p = null; r = null; last = (px.length === 1); // first, we try simply to match the current pattern // if not, try the next pattern try { r = px[i].call(this, s); } catch (e) { continue; } // since we are matching against a set of elements, the first // thing to do is to add r[0] to matched elements rx = [[r[0]], r[1]]; // if we matched and there is still input to parse and // we don't already know this is the last element, // we're going to next check for the delimiter ... // if there's none, or if there's no input left to parse // than this must be the last element after all ... if (r[1].length > 0 && ! last) { try { q = d.call(this, r[1]); } catch (ex) { last = true; } } else { last = true; } // if we parsed the delimiter and now there's no more input, // that means we shouldn't have parsed the delimiter at all // so don't update r and mark this as the last element ... if (!last && q[1].length === 0) { last = true; } // so, if this isn't the last element, we're going to see if // we can get any more matches from the remaining (unmatched) // elements ... if (!last) { // build a list of the remaining rules we can match against, // i.e., all but the one we just matched against var qx = []; for (var j = 0; j < px.length ; j++) { if (i !== j) { qx.push(px[j]); } } // now invoke recursively set with the remaining input // note that we don't include the closing delimiter ... // we'll check for that ourselves at the end p = _.set(qx, d).call(this, q[1]); // if we got a non-empty set as a result ... // (otw rx already contains everything we want to match) if (p[0].length > 0) { // update current result, which is stored in rx ... // basically, pick up the remaining text from p[1] // and concat the result from p[0] so that we don't // get endless nesting ... rx[0] = rx[0].concat(p[0]); rx[1] = p[1]; } } // at this point, rx either contains the last matched element // or the entire matched set that starts with this element. // now we just check to see if this variation is better than // our best so far, in terms of how much of the input is parsed if (rx[1].length < best[1].length) { best = rx; } // if we've parsed all the input, then we're finished if (best[1].length === 0) { break; } } // so now we've either gone through all the patterns trying them // as the initial match; or we found one that parsed the entire // input string ... // if best has no matches, just return empty set ... if (best[0].length === 0) { return best; } // if a closing delimiter is provided, then we have to check it also if (c) { // we try this even if there is no remaining input because the pattern // may well be optional or match empty input ... try { q = c.call(this, best[1]); } catch (ey) { throw new $P.Exception(best[1]); } // it parsed ... be sure to update the best match remaining input best[1] = q[1]; } // if we're here, either there was no closing delimiter or we parsed it // so now we have the best match; just return it! return best; }; }, forward: function (gr, fname) { return function (s) { return gr[fname].call(this, s); }; }, // // Translation Operators // replace: function (rule, repl) { return function (s) { var r = rule.call(this, s); return [repl, r[1]]; }; }, process: function (rule, fn) { return function (s) { var r = rule.call(this, s); return [fn.call(this, r[0]), r[1]]; }; }, min: function (min, rule) { return function (s) { var rx = rule.call(this, s); if (rx[0].length < min) { throw new $P.Exception(s); } return rx; }; } }; // Generator Operators And Vector Operators // Generators are operators that have a signature of F(R) => R, // taking a given rule and returning another rule, such as // ignore, which parses a given rule and throws away the result. // Vector operators are those that have a signature of F(R1,R2,...) => R, // take a list of rules and returning a new rule, such as each. // Generator operators are converted (via the following _generator // function) into functions that can also take a list or array of rules // and return an array of new rules as though the function had been // called on each rule in turn (which is what actually happens). // This allows generators to be used with vector operators more easily. // Example: // each(ignore(foo, bar)) instead of each(ignore(foo), ignore(bar)) // This also turns generators into vector operators, which allows // constructs like: // not(cache(foo, bar)) var _generator = function (op) { function gen() { var args = null, rx = [], px, i; if (arguments.length > 1) { args = Array.prototype.slice.call(arguments); } else if (arguments[0] instanceof Array) { args = arguments[0]; } if (args) { px = args.shift(); if (px.length > 0) { args.unshift(px[i]); rx.push(op.apply(null, args)); args.shift(); return rx; } } else { return op.apply(null, arguments); } } return gen; }; var gx = "optional not ignore cache".split(/\s/); for (var i = 0 ; i < gx.length ; i++) { _[gx[i]] = _generator(_[gx[i]]); } var _vector = function (op) { return function () { if (arguments[0] instanceof Array) { return op.apply(null, arguments[0]); } else { return op.apply(null, arguments); } }; }; var vx = "each any all".split(/\s/); for (var j = 0 ; j < vx.length ; j++) { _[vx[j]] = _vector(_[vx[j]]); } }()); (function () { var $D = Date; var flattenAndCompact = function (ax) { var rx = []; for (var i = 0; i < ax.length; i++) { if (ax[i] instanceof Array) { rx = rx.concat(flattenAndCompact(ax[i])); } else { if (ax[i]) { rx.push(ax[i]); } } } return rx; }; var parseMeridian = function () { if (this.meridian && (this.hour || this.hour === 0)) { if (this.meridian === "a" && this.hour > 11 && Date.Config.strict24hr){ throw "Invalid hour and meridian combination"; } else if (this.meridian === "p" && this.hour < 12 && Date.Config.strict24hr){ throw "Invalid hour and meridian combination"; } else if (this.meridian === "p" && this.hour < 12) { this.hour = this.hour + 12; } else if (this.meridian === "a" && this.hour === 12) { this.hour = 0; } } }; var setDefaults = function () { var now = new Date(); if ((this.hour || this.minute) && (!this.month && !this.year && !this.day)) { this.day = now.getDate(); } if (!this.year) { this.year = now.getFullYear(); } if (!this.month && this.month !== 0) { this.month = now.getMonth(); } if (!this.day) { this.day = 1; } if (!this.hour) { this.hour = 0; } if (!this.minute) { this.minute = 0; } if (!this.second) { this.second = 0; } if (!this.millisecond) { this.millisecond = 0; } }; var finishUtils = { getToday: function () { if (this.now || "hour minute second".indexOf(this.unit) !== -1) { return new Date(); } else { return $D.today(); } }, setDaysFromWeekday: function (today, orient){ var gap; orient = orient || 1; this.unit = "day"; gap = ($D.getDayNumberFromName(this.weekday) - today.getDay()); this.days = gap ? ((gap + (orient * 7)) % 7) : (orient * 7); return this; }, setMonthsFromMonth: function (today, orient) { var gap; orient = orient || 1; this.unit = "month"; gap = (this.month - today.getMonth()); this.months = gap ? ((gap + (orient * 12)) % 12) : (orient * 12); this.month = null; return this; }, setDMYFromWeekday: function () { var d = Date[this.weekday](); this.day = d.getDate(); if (!this.month) { this.month = d.getMonth(); } this.year = d.getFullYear(); return this; }, setUnitValue: function (orient) { if (!this.value && this.operator && this.operator !== null && this[this.unit + "s"] && this[this.unit + "s"] !== null) { this[this.unit + "s"] = this[this.unit + "s"] + ((this.operator === "add") ? 1 : -1) + (this.value||0) * orient; } else if (this[this.unit + "s"] == null || this.operator != null) { if (!this.value) { this.value = 1; } this[this.unit + "s"] = this.value * orient; } }, generateDateFromWeeks: function () { var weekday = (this.weekday !== undefined) ? this.weekday : "today"; var d = Date[weekday]().addWeeks(this.weeks); if (this.now) { d.setTimeToNow(); } return d; } }; $D.Translator = { hour: function (s) { return function () { this.hour = Number(s); }; }, minute: function (s) { return function () { this.minute = Number(s); }; }, second: function (s) { return function () { this.second = Number(s); }; }, /* for ss.s format */ secondAndMillisecond: function (s) { return function () { var mx = s.match(/^([0-5][0-9])\.([0-9]{1,3})/); this.second = Number(mx[1]); this.millisecond = Number(mx[2]); }; }, meridian: function (s) { return function () { this.meridian = s.slice(0, 1).toLowerCase(); }; }, timezone: function (s) { return function () { var n = s.replace(/[^\d\+\-]/g, ""); if (n.length) { this.timezoneOffset = Number(n); } else { this.timezone = s.toLowerCase(); } }; }, day: function (x) { var s = x[0]; return function () { this.day = Number(s.match(/\d+/)[0]); if (this.day < 1) { throw "invalid day"; } }; }, month: function (s) { return function () { this.month = (s.length === 3) ? "jan feb mar apr may jun jul aug sep oct nov dec".indexOf(s)/4 : Number(s) - 1; if (this.month < 0) { throw "invalid month"; } }; }, year: function (s) { return function () { var n = Number(s); this.year = ((s.length > 2) ? n : (n + (((n + 2000) < Date.CultureInfo.twoDigitYearMax) ? 2000 : 1900))); }; }, rday: function (s) { return function () { switch (s) { case "yesterday": this.days = -1; break; case "tomorrow": this.days = 1; break; case "today": this.days = 0; break; case "now": this.days = 0; this.now = true; break; } }; }, finishExact: function (x) { var d; x = (x instanceof Array) ? x : [x]; for (var i = 0 ; i < x.length ; i++) { if (x[i]) { x[i].call(this); } } setDefaults.call(this); parseMeridian.call(this); if (this.day > $D.getDaysInMonth(this.year, this.month)) { throw new RangeError(this.day + " is not a valid value for days."); } d = new Date(this.year, this.month, this.day, this.hour, this.minute, this.second, this.millisecond); if (this.year < 100) { d.setFullYear(this.year); // means years less that 100 are process correctly. JS will parse it otherwise as 1900-1999. } if (this.timezone) { d.set({ timezone: this.timezone }); } else if (this.timezoneOffset) { d.set({ timezoneOffset: this.timezoneOffset }); } return d; }, finish: function (x) { var today, expression, orient, temp; x = (x instanceof Array) ? flattenAndCompact(x) : [ x ]; if (x.length === 0) { return null; } for (var i = 0 ; i < x.length ; i++) { if (typeof x[i] === "function") { x[i].call(this); } } if (this.now && !this.unit && !this.operator) { return new Date(); } else { today = finishUtils.getToday.call(this); } expression = !!(this.days && this.days !== null || this.orient || this.operator); orient = ((this.orient === "past" || this.operator === "subtract") ? -1 : 1); if (this.month && this.unit === "week") { this.value = this.month + 1; delete this.month; delete this.day; } if ((this.month || this.month === 0) && "year day hour minute second".indexOf(this.unit) !== -1) { if (!this.value) { this.value = this.month + 1; } this.month = null; expression = true; } if (!expression && this.weekday && !this.day && !this.days) { finishUtils.setDMYFromWeekday.call(this); } if (expression && this.weekday && this.unit !== "month" && this.unit !== "week") { finishUtils.setDaysFromWeekday.call(this, today, orient); } if (this.weekday && this.unit !== "week" && !this.day && !this.days) { temp = Date[this.weekday](); this.day = temp.getDate(); if (temp.getMonth() !== today.getMonth()) { this.month = temp.getMonth(); } } if (this.month && this.unit === "day" && this.operator) { if (!this.value) { this.value = (this.month + 1); } this.month = null; } if (this.value != null && this.month != null && this.year != null) { this.day = this.value * 1; } if (this.month && !this.day && this.value) { today.set({ day: this.value * 1 }); if (!expression) { this.day = this.value * 1; } } if (!this.month && this.value && this.unit === "month" && !this.now) { this.month = this.value; expression = true; } if (expression && (this.month || this.month === 0) && this.unit !== "year") { finishUtils.setMonthsFromMonth.call(this, today, orient); } if (!this.unit) { this.unit = "day"; } finishUtils.setUnitValue.call(this, orient); parseMeridian.call(this); if ((this.month || this.month === 0) && !this.day) { this.day = 1; } if (!this.orient && !this.operator && this.unit === "week" && this.value && !this.day && !this.month) { return Date.today().setWeek(this.value); } if (this.unit === "week" && this.weeks && !this.day && !this.month) { return finishUtils.generateDateFromWeeks.call(this); } if (expression && this.timezone && this.day && this.days) { this.day = this.days; } if (expression){ today.add(this); } else { today.set(this); } if (this.timezone) { this.timezone = this.timezone.toUpperCase(); var offset = $D.getTimezoneOffset(this.timezone); var timezone; if (today.hasDaylightSavingTime()) { // lets check that we're being sane with timezone setting timezone = $D.getTimezoneAbbreviation(offset, today.isDaylightSavingTime()); if (timezone !== this.timezone) { // bugger, we're in a place where things like EST vs EDT matters. if (today.isDaylightSavingTime()) { today.addHours(-1); } else { today.addHours(1); } } } today.setTimezoneOffset(offset); } return today; } }; }()); (function () { var $D = Date; $D.Grammar = {}; var _ = $D.Parsing.Operators, g = $D.Grammar, t = $D.Translator, _fn; // Allow rolling up into general purpose rules _fn = function () { return _.each(_.any.apply(null, arguments), _.not(g.ctoken2("timeContext"))); }; g.datePartDelimiter = _.rtoken(/^([\s\-\.\,\/\x27]+)/); g.timePartDelimiter = _.stoken(":"); g.whiteSpace = _.rtoken(/^\s*/); g.generalDelimiter = _.rtoken(/^(([\s\,]|at|@|on)+)/); var _C = {}; g.ctoken = function (keys) { var fn = _C[keys]; if (! fn) { var c = Date.CultureInfo.regexPatterns; var kx = keys.split(/\s+/), px = []; for (var i = 0; i < kx.length ; i++) { px.push(_.replace(_.rtoken(c[kx[i]]), kx[i])); } fn = _C[keys] = _.any.apply(null, px); } return fn; }; g.ctoken2 = function (key) { return _.rtoken(Date.CultureInfo.regexPatterns[key]); }; var cacheProcessRtoken = function (key, token, type, eachToken) { if (eachToken) { g[key] = _.cache(_.process(_.each(_.rtoken(token),_.optional(g.ctoken2(eachToken))), type)); } else { g[key] = _.cache(_.process(_.rtoken(token), type)); } }; var cacheProcessCtoken = function (token, type) { return _.cache(_.process(g.ctoken2(token), type)); }; var _F = {}; //function cache var _get = function (f) { _F[f] = (_F[f] || g.format(f)[0]); return _F[f]; }; g.allformats = function (fx) { var rx = []; if (fx instanceof Array) { for (var i = 0; i < fx.length; i++) { rx.push(_get(fx[i])); } } else { rx.push(_get(fx)); } return rx; }; g.formats = function (fx) { if (fx instanceof Array) { var rx = []; for (var i = 0 ; i < fx.length ; i++) { rx.push(_get(fx[i])); } return _.any.apply(null, rx); } else { return _get(fx); } }; var grammarFormats = { timeFormats: function(){ var i, RTokenKeys = [ "h", "hh", "H", "HH", "m", "mm", "s", "ss", "ss.s", "z", "zz" ], RToken = [ /^(0[0-9]|1[0-2]|[1-9])/, /^(0[0-9]|1[0-2])/, /^([0-1][0-9]|2[0-3]|[0-9])/, /^([0-1][0-9]|2[0-3])/, /^([0-5][0-9]|[0-9])/, /^[0-5][0-9]/, /^([0-5][0-9]|[0-9])/, /^[0-5][0-9]/, /^[0-5][0-9]\.[0-9]{1,3}/, /^((\+|\-)\s*\d\d\d\d)|((\+|\-)\d\d\:?\d\d)/, /^((\+|\-)\s*\d\d\d\d)|((\+|\-)\d\d\:?\d\d)/ ], tokens = [ t.hour, t.hour, t.hour, t.hour, t.minute, t.minute, t.second, t.second, t.secondAndMillisecond, t.timezone, t.timezone ]; for (i=0; i < RTokenKeys.length; i++) { cacheProcessRtoken(RTokenKeys[i], RToken[i], tokens[i]); } g.hms = _.cache(_.sequence([g.H, g.m, g.s], g.timePartDelimiter)); g.t = cacheProcessCtoken("shortMeridian", t.meridian); g.tt = cacheProcessCtoken("longMeridian", t.meridian); g.zzz = cacheProcessCtoken("timezone", t.timezone); g.timeSuffix = _.each(_.ignore(g.whiteSpace), _.set([ g.tt, g.zzz ])); g.time = _.each(_.optional(_.ignore(_.stoken("T"))), g.hms, g.timeSuffix); }, dateFormats: function () { // pre-loaded rules for different date part order preferences var _setfn = function () { return _.set(arguments, g.datePartDelimiter); }; var i, RTokenKeys = [ "d", "dd", "M", "MM", "y", "yy", "yyy", "yyyy" ], RToken = [ /^([0-2]\d|3[0-1]|\d)/, /^([0-2]\d|3[0-1])/, /^(1[0-2]|0\d|\d)/, /^(1[0-2]|0\d)/, /^(\d+)/, /^(\d\d)/, /^(\d\d?\d?\d?)/, /^(\d\d\d\d)/ ], tokens = [ t.day, t.day, t.month, t.month, t.year, t.year, t.year, t.year ], eachToken = [ "ordinalSuffix", "ordinalSuffix" ]; for (i=0; i < RTokenKeys.length; i++) { cacheProcessRtoken(RTokenKeys[i], RToken[i], tokens[i], eachToken[i]); } g.MMM = g.MMMM = _.cache(_.process(g.ctoken("jan feb mar apr may jun jul aug sep oct nov dec"), t.month)); g.ddd = g.dddd = _.cache(_.process(g.ctoken("sun mon tue wed thu fri sat"), function (s) { return function () { this.weekday = s; }; } )); g.day = _fn(g.d, g.dd); g.month = _fn(g.M, g.MMM); g.year = _fn(g.yyyy, g.yy); g.mdy = _setfn(g.ddd, g.month, g.day, g.year); g.ymd = _setfn(g.ddd, g.year, g.month, g.day); g.dmy = _setfn(g.ddd, g.day, g.month, g.year); g.date = function (s) { return ((g[Date.CultureInfo.dateElementOrder] || g.mdy).call(this, s)); }; }, relative: function () { // relative date / time expressions g.orientation = _.process(g.ctoken("past future"), function (s) { return function () { this.orient = s; }; } ); g.operator = _.process(g.ctoken("add subtract"), function (s) { return function () { this.operator = s; }; } ); g.rday = _.process(g.ctoken("yesterday tomorrow today now"), t.rday); g.unit = _.process(g.ctoken("second minute hour day week month year"), function (s) { return function () { this.unit = s; }; } ); } }; g.buildGrammarFormats = function () { // these need to be rebuilt every time the language changes. _C = {}; grammarFormats.timeFormats(); grammarFormats.dateFormats(); grammarFormats.relative(); g.value = _.process(_.rtoken(/^([-+]?\d+)?(st|nd|rd|th)?/), function (s) { return function () { this.value = s.replace(/\D/g, ""); }; } ); g.expression = _.set([g.rday, g.operator, g.value, g.unit, g.orientation, g.ddd, g.MMM ]); g.format = _.process(_.many( _.any( // translate format specifiers into grammar rules _.process( _.rtoken(/^(dd?d?d?(?!e)|MM?M?M?|yy?y?y?|hh?|HH?|mm?|ss?|tt?|zz?z?)/), function (fmt) { if (g[fmt]) { return g[fmt]; } else { throw $D.Parsing.Exception(fmt); } } ), // translate separator tokens into token rules _.process(_.rtoken(/^[^dMyhHmstz]+/), // all legal separators function (s) { return _.ignore(_.stoken(s)); } ) ) ), // construct the parser ... function (rules) { return _.process(_.each.apply(null, rules), t.finishExact); } ); // starting rule for general purpose grammar g._start = _.process(_.set([ g.date, g.time, g.expression ], g.generalDelimiter, g.whiteSpace), t.finish); }; g.buildGrammarFormats(); // parsing date format specifiers - ex: "h:m:s tt" // this little guy will generate a custom parser based // on the format string, ex: g.format("h:m:s tt") // check for these formats first g._formats = g.formats([ "\"yyyy-MM-ddTHH:mm:ssZ\"", "yyyy-MM-ddTHH:mm:ss.sz", "yyyy-MM-ddTHH:mm:ssZ", "yyyy-MM-ddTHH:mm:ssz", "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-ddTHH:mmZ", "yyyy-MM-ddTHH:mmz", "yyyy-MM-ddTHH:mm", "ddd, MMM dd, yyyy H:mm:ss tt", "ddd MMM d yyyy HH:mm:ss zzz", "MMddyyyy", "ddMMyyyy", "Mddyyyy", "ddMyyyy", "Mdyyyy", "dMyyyy", "yyyy", "Mdyy", "dMyy", "d" ]); // real starting rule: tries selected formats first, // then general purpose rule g.start = function (s) { try { var r = g._formats.call({}, s); if (r[1].length === 0) { return r; } } catch (e) {} return g._start.call({}, s); }; }()); (function () { var $D = Date; /** * @desc Converts the specified string value into its JavaScript Date equivalent using CultureInfo specific format information. * * Example

	///////////
	// Dates //
	///////////

	// 15-Oct-2004
	var d1 = Date.parse("10/15/2004");

	// 15-Oct-2004
	var d1 = Date.parse("15-Oct-2004");

	// 15-Oct-2004
	var d1 = Date.parse("2004.10.15");

	//Fri Oct 15, 2004
	var d1 = Date.parse("Fri Oct 15, 2004");

	///////////
	// Times //
	///////////

	// Today at 10 PM.
	var d1 = Date.parse("10 PM");

	// Today at 10:30 PM.
	var d1 = Date.parse("10:30 P.M.");

	// Today at 6 AM.
	var d1 = Date.parse("06am");

	/////////////////////
	// Dates and Times //
	/////////////////////

	// 8-July-2004 @ 10:30 PM
	var d1 = Date.parse("July 8th, 2004, 10:30 PM");

	// 1-July-2004 @ 10:30 PM
	var d1 = Date.parse("2004-07-01T22:30:00");

	////////////////////
	// Relative Dates //
	////////////////////

	// Returns today's date. The string "today" is culture specific.
	var d1 = Date.parse("today");

	// Returns yesterday's date. The string "yesterday" is culture specific.
	var d1 = Date.parse("yesterday");

	// Returns the date of the next thursday.
	var d1 = Date.parse("Next thursday");

	// Returns the date of the most previous monday.
	var d1 = Date.parse("last monday");

	// Returns today's day + one year.
	var d1 = Date.parse("next year");

	///////////////
	// Date Math //
	///////////////

	// Today + 2 days
	var d1 = Date.parse("t+2");

	// Today + 2 days
	var d1 = Date.parse("today + 2 days");

	// Today + 3 months
	var d1 = Date.parse("t+3m");

	// Today - 1 year
	var d1 = Date.parse("today - 1 year");

	// Today - 1 year
	var d1 = Date.parse("t-1y"); 


	/////////////////////////////
	// Partial Dates and Times //
	/////////////////////////////

	// July 15th of this year.
	var d1 = Date.parse("July 15");

	// 15th day of current day and year.
	var d1 = Date.parse("15");

	// July 1st of current year at 10pm.
	var d1 = Date.parse("7/1 10pm");
	
* * @param {String} The string value to convert into a Date object [Required] * @return {Date} A Date object or null if the string cannot be converted into a Date. */ var parseUtils = { removeOrds: function (s) { ords = s.match(/\b(\d+)(?:st|nd|rd|th)\b/); // find ordinal matches s = ((ords && ords.length === 2) ? s.replace(ords[0], ords[1]) : s); return s; }, grammarParser: function (s) { var r = null; try { r = $D.Grammar.start.call({}, s.replace(/^\s*(\S*(\s+\S+)*)\s*$/, "$1")); } catch (e) { return null; } return ((r[1].length === 0) ? r[0] : null); }, nativeFallback: function(s) { var t; try { // ok we haven't parsed it, last ditch attempt with the built-in parser. t = Date._parse(s); return (t || t === 0) ? new Date(t) : null; } catch (e) { return null; } } }; function parse (s) { var d; if (!s) { return null; } if (s instanceof Date) { return s.clone(); } if (s.length >= 4 && s.charAt(0) !== "0" && s.charAt(0) !== "+"&& s.charAt(0) !== "-") { // ie: 2004 will pass, 0800 won't. // Start with specific formats d = $D.Parsing.ISO.parse(s) || $D.Parsing.Numeric.parse(s); } if (d instanceof Date && !isNaN(d.getTime())) { return d; } else { // find ordinal dates (1st, 3rd, 8th, etc and remove them as they cause parsing issues) s = $D.Parsing.Normalizer.parse(parseUtils.removeOrds(s)); d = parseUtils.grammarParser(s); if (d !== null) { return d; } else { return parseUtils.nativeFallback(s); } } } if (!$D._parse) { $D._parse = $D.parse; } $D.parse = parse; Date.getParseFunction = function (fx) { var fns = Date.Grammar.allformats(fx); return function (s) { var r = null; for (var i = 0; i < fns.length; i++) { try { r = fns[i].call({}, s); } catch (e) { continue; } if (r[1].length === 0) { return r[0]; } } return null; }; }; /** * Converts the specified string value into its JavaScript Date equivalent using the specified format {String} or formats {Array} and the CultureInfo specific format information. * The format of the string value must match one of the supplied formats exactly. * * Example

	// 15-Oct-2004
	var d1 = Date.parseExact("10/15/2004", "M/d/yyyy");

	// 15-Oct-2004
	var d1 = Date.parse("15-Oct-2004", "M-ddd-yyyy");

	// 15-Oct-2004
	var d1 = Date.parse("2004.10.15", "yyyy.MM.dd");

	// Multiple formats
	var d1 = Date.parseExact("10/15/2004", ["M/d/yyyy", "MMMM d, yyyy"]);
	
* * @param {String} The string value to convert into a Date object [Required]. * @param {Object} The expected format {String} or an array of expected formats {Array} of the date string [Required]. * @return {Date} A Date object or null if the string cannot be converted into a Date. */ $D.parseExact = function (s, fx) { return $D.getParseFunction(fx)(s); }; }()); (function () { var $D = Date, $P = $D.prototype, // $C = $D.CultureInfo, // not used atm p = function (s, l) { if (!l) { l = 2; } return ("000" + s).slice(l * -1); }; /** * Converts a PHP format string to Java/.NET format string. * A PHP format string can be used with ._format or .format. * A Java/.NET format string can be used with .toString(). * The .parseExact function will only accept a Java/.NET format string * * Example * var f1 = "%m/%d/%y" * var f2 = Date.normalizeFormat(f1); // "MM/dd/yy" * * new Date().format(f1); // "04/13/08" * new Date()._format(f1); // "04/13/08" * new Date().toString(f2); // "04/13/08" * * var date = Date.parseExact("04/13/08", f2); // Sun Apr 13 2008 * * @param {String} A PHP format string consisting of one or more format spcifiers. * @return {String} The PHP format converted to a Java/.NET format string. */ var normalizerSubstitutions = { "d" : "dd", "%d": "dd", "D" : "ddd", "%a": "ddd", "j" : "dddd", "l" : "dddd", "%A": "dddd", "S" : "S", "F" : "MMMM", "%B": "MMMM", "m" : "MM", "%m": "MM", "M" : "MMM", "%b": "MMM", "%h": "MMM", "n" : "M", "Y" : "yyyy", "%Y": "yyyy", "y" : "yy", "%y": "yy", "g" : "h", "%I": "h", "G" : "H", "h" : "hh", "H" : "HH", "%H": "HH", "i" : "mm", "%M": "mm", "s" : "ss", "%S": "ss", "%r": "hh:mm tt", "%R": "H:mm", "%T": "H:mm:ss", "%X": "t", "%x": "d", "%e": "d", "%D": "MM/dd/yy", "%n": "\\n", "%t": "\\t", "e" : "z", "T" : "z", "%z": "z", "%Z": "z", "Z" : "ZZ", "N" : "u", "w" : "u", "%w": "u", "W" : "W", "%V": "W" }; var normalizer = { substitutes: function (m) { return normalizerSubstitutions[m]; }, interpreted: function (m, x) { var y; switch (m) { case "%u": return x.getDay() + 1; case "z": return x.getOrdinalNumber(); case "%j": return p(x.getOrdinalNumber(), 3); case "%U": var d1 = x.clone().set({month: 0, day: 1}).addDays(-1).moveToDayOfWeek(0), d2 = x.clone().addDays(1).moveToDayOfWeek(0, -1); return (d2 < d1) ? "00" : p((d2.getOrdinalNumber() - d1.getOrdinalNumber()) / 7 + 1); case "%W": return p(x.getWeek()); case "t": return $D.getDaysInMonth(x.getFullYear(), x.getMonth()); case "o": case "%G": return x.setWeek(x.getISOWeek()).toString("yyyy"); case "%g": return x._format("%G").slice(-2); case "a": case "%p": return t("tt").toLowerCase(); case "A": return t("tt").toUpperCase(); case "u": return p(x.getMilliseconds(), 3); case "I": return (x.isDaylightSavingTime()) ? 1 : 0; case "O": return x.getUTCOffset(); case "P": y = x.getUTCOffset(); return y.substring(0, y.length - 2) + ":" + y.substring(y.length - 2); case "B": var now = new Date(); return Math.floor(((now.getHours() * 3600) + (now.getMinutes() * 60) + now.getSeconds() + (now.getTimezoneOffset() + 60) * 60) / 86.4); case "c": return x.toISOString().replace(/\"/g, ""); case "U": return $D.strtotime("now"); case "%c": return t("d") + " " + t("t"); case "%C": return Math.floor(x.getFullYear() / 100 + 1); } }, shouldOverrideDefaults: function (m) { switch (m) { case "%e": return true; default: return false; } }, parse: function (m, context) { var formatString, c = context || new Date(); formatString = normalizer.substitutes(m); if (formatString) { return formatString; } formatString = normalizer.interpreted(m, c); if (formatString) { return formatString; } else { return m; } } }; $D.normalizeFormat = function (format, context) { return format.replace(/(%|\\)?.|%%/g, function(t){ return normalizer.parse(t, context); }); }; /** * Format a local Unix timestamp according to locale settings * * Example: * Date.strftime("%m/%d/%y", new Date()); // "04/13/08" * Date.strftime("c", "2008-04-13T17:52:03Z"); // "04/13/08" * * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @param {Number|String} The number representing the number of seconds that have elapsed since January 1, 1970 (local time). * @return {String} A string representation of the current Date object. */ $D.strftime = function (format, time) { var d = Date.parse(time); return d._format(format); }; /** * Parse any textual datetime description into a Unix timestamp. * A Unix timestamp is the number of seconds that have elapsed since January 1, 1970 (midnight UTC/GMT). * * Example: * Date.strtotime("04/13/08"); // 1208044800 * Date.strtotime("1970-01-01T00:00:00Z"); // 0 * * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @param {Object} A string or date object. * @return {String} A string representation of the current Date object. */ $D.strtotime = function (time) { var d = $D.parse(time); return Math.round($D.UTC(d.getUTCFullYear(), d.getUTCMonth(), d.getUTCDate(), d.getUTCHours(), d.getUTCMinutes(), d.getUTCSeconds(), d.getUTCMilliseconds()) / 1000); }; /** * Converts the value of the current Date object to its equivalent string representation using a PHP/Unix style of date format specifiers. * Format Specifiers * Format Description Example * ------ --------------------------------------------------------------------------- ----------------------- * %a abbreviated weekday name according to the current localed "Mon" through "Sun" * %A full weekday name according to the current localed "Sunday" through "Saturday" * %b abbreviated month name according to the current localed "Jan" through "Dec" * %B full month name according to the current locale "January" through "December" * %c preferred date and time representation for the current locale "4/13/2008 12:33 PM" * %C century number (the year divided by 100 and truncated to an integer) "00" to "99" * %d day of the month as a decimal number "01" to "31" * %D same as %m/%d/%y "04/13/08" * %e day of the month as a decimal number, a single digit is preceded by a space "1" to "31" * %g like %G, but without the century "08" * %G The 4-digit year corresponding to the ISO week number (see %V). "2008" * This has the same format and value as %Y, except that if the ISO week number * belongs to the previous or next year, that year is used instead. * %h same as %b "Jan" through "Dec" * %H hour as a decimal number using a 24-hour clock. "00" to "23" * %I hour as a decimal number using a 12-hour clock. "01" to "12" * %j day of the year as a decimal number. "001" to "366" * %m month as a decimal number. "01" to "12" * %M minute as a decimal number. "00" to "59" * %n newline character "\n" * %p either "am" or "pm" according to the given time value, or the "am" or "pm" * corresponding strings for the current locale. * %r time in a.m. and p.m. notation "8:44 PM" * %R time in 24 hour notation "20:44" * %S second as a decimal number "00" to "59" * %t tab character "\t" * %T current time, equal to %H:%M:%S "12:49:11" * %u weekday as a decimal number ["1", "7"], with "1" representing Monday "1" to "7" * %U week number of the current year as a decimal number, starting with the "0" to ("52" or "53") * first Sunday as the first day of the first week * %V The ISO 8601:1988 week number of the current year as a decimal number, "00" to ("52" or "53") * range 01 to 53, where week 1 is the first week that has at least 4 days * in the current year, and with Monday as the first day of the week. * (Use %G or %g for the year component that corresponds to the week number * for the specified timestamp.) * %W week number of the current year as a decimal number, starting with the "00" to ("52" or "53") * first Monday as the first day of the first week * %w day of the week as a decimal, Sunday being "0" "0" to "6" * %x preferred date representation for the current locale without the time "4/13/2008" * %X preferred time representation for the current locale without the date "12:53:05" * %y year as a decimal number without a century "00" "99" * %Y year as a decimal number including the century "2008" * %Z time zone or name or abbreviation "UTC", "EST", "PST" * %z same as %Z * %% a literal "%" characters "%" * d Day of the month, 2 digits with leading zeros "01" to "31" * D A textual representation of a day, three letters "Mon" through "Sun" * j Day of the month without leading zeros "1" to "31" * l A full textual representation of the day of the week (lowercase "L") "Sunday" through "Saturday" * N ISO-8601 numeric representation of the day of the week (added in PHP 5.1.0) "1" (for Monday) through "7" (for Sunday) * S English ordinal suffix for the day of the month, 2 characters "st", "nd", "rd" or "th". Works well with j * w Numeric representation of the day of the week "0" (for Sunday) through "6" (for Saturday) * z The day of the year (starting from "0") "0" through "365" * W ISO-8601 week number of year, weeks starting on Monday "00" to ("52" or "53") * F A full textual representation of a month, such as January or March "January" through "December" * m Numeric representation of a month, with leading zeros "01" through "12" * M A short textual representation of a month, three letters "Jan" through "Dec" * n Numeric representation of a month, without leading zeros "1" through "12" * t Number of days in the given month "28" through "31" * L Whether it's a leap year "1" if it is a leap year, "0" otherwise * o ISO-8601 year number. This has the same value as Y, except that if the "2008" * ISO week number (W) belongs to the previous or next year, that year * is used instead. * Y A full numeric representation of a year, 4 digits "2008" * y A two digit representation of a year "08" * a Lowercase Ante meridiem and Post meridiem "am" or "pm" * A Uppercase Ante meridiem and Post meridiem "AM" or "PM" * B Swatch Internet time "000" through "999" * g 12-hour format of an hour without leading zeros "1" through "12" * G 24-hour format of an hour without leading zeros "0" through "23" * h 12-hour format of an hour with leading zeros "01" through "12" * H 24-hour format of an hour with leading zeros "00" through "23" * i Minutes with leading zeros "00" to "59" * s Seconds, with leading zeros "00" through "59" * u Milliseconds "54321" * e Timezone identifier "UTC", "EST", "PST" * I Whether or not the date is in daylight saving time (uppercase i) "1" if Daylight Saving Time, "0" otherwise * O Difference to Greenwich time (GMT) in hours "+0200", "-0600" * P Difference to Greenwich time (GMT) with colon between hours and minutes "+02:00", "-06:00" * T Timezone abbreviation "UTC", "EST", "PST" * Z Timezone offset in seconds. The offset for timezones west of UTC is "-43200" through "50400" * always negative, and for those east of UTC is always positive. * c ISO 8601 date "2004-02-12T15:19:21+00:00" * r RFC 2822 formatted date "Thu, 21 Dec 2000 16:01:07 +0200" * U Seconds since the Unix Epoch (January 1 1970 00:00:00 GMT) "0" * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @return {String} A string representation of the current Date object. */ var formatReplace = function (context) { return function (m) { var formatString, override = false; if (m.charAt(0) === "\\" || m.substring(0, 2) === "%%") { return m.replace("\\", "").replace("%%", "%"); } override = normalizer.shouldOverrideDefaults(m); formatString = $D.normalizeFormat(m, context); if (formatString) { return context.toString(formatString, override); } }; }; $P._format = function (format) { var formatter = formatReplace(this); if (!format) { return this._toString(); } else { return format.replace(/(%|\\)?.|%%/g, formatter); } }; if (!$P.format) { $P.format = $P._format; } }()); (function () { "use strict"; var gFn = function (attr) { return function () { return this[attr]; }; }; var sFn = function (attr) { return function (val) { this[attr] = val; return this; }; }; var attrs = ["years", "months", "days", "hours", "minutes", "seconds", "milliseconds"]; var addSetFuncs = function (context, attrs) { for (var i = 0; i < attrs.length ; i++) { var $a = attrs[i], $b = $a.slice(0, 1).toUpperCase() + $a.slice(1); context.prototype[$a] = 0; context.prototype["get" + $b] = gFn($a); context.prototype["set" + $b] = sFn($a); } }; /** * new TimeSpan(milliseconds); * new TimeSpan(days, hours, minutes, seconds); * new TimeSpan(days, hours, minutes, seconds, milliseconds); */ var TimeSpan = function (days, hours, minutes, seconds, milliseconds) { if (arguments.length === 1 && typeof days === "number") { var orient = (days < 0) ? -1 : +1; var millsLeft = Math.abs(days); this.setDays(Math.floor(millsLeft / 86400000) * orient); millsLeft = millsLeft % 86400000; this.setHours(Math.floor(millsLeft / 3600000) * orient); millsLeft = millsLeft % 3600000; this.setMinutes(Math.floor(millsLeft / 60000) * orient); millsLeft = millsLeft % 60000; this.setSeconds(Math.floor(millsLeft / 1000) * orient); millsLeft = millsLeft % 1000; this.setMilliseconds(millsLeft * orient); } else { this.set(days, hours, minutes, seconds, milliseconds); } this.getTotalMilliseconds = function () { return (this.getDays() * 86400000) + (this.getHours() * 3600000) + (this.getMinutes() * 60000) + (this.getSeconds() * 1000); }; this.compareTo = function (time) { var t1 = new Date(1970, 1, 1, this.getHours(), this.getMinutes(), this.getSeconds()), t2; if (time === null) { t2 = new Date(1970, 1, 1, 0, 0, 0); } else { t2 = new Date(1970, 1, 1, time.getHours(), time.getMinutes(), time.getSeconds()); } return (t1 < t2) ? -1 : (t1 > t2) ? 1 : 0; }; this.equals = function (time) { return (this.compareTo(time) === 0); }; this.add = function (time) { return (time === null) ? this : this.addSeconds(time.getTotalMilliseconds() / 1000); }; this.subtract = function (time) { return (time === null) ? this : this.addSeconds(-time.getTotalMilliseconds() / 1000); }; this.addDays = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 86400000)); }; this.addHours = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 3600000)); }; this.addMinutes = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 60000)); }; this.addSeconds = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 1000)); }; this.addMilliseconds = function (n) { return new TimeSpan(this.getTotalMilliseconds() + n); }; this.get12HourHour = function () { return (this.getHours() > 12) ? this.getHours() - 12 : (this.getHours() === 0) ? 12 : this.getHours(); }; this.getDesignator = function () { return (this.getHours() < 12) ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator; }; this.toString = function (format) { this._toString = function () { if (this.getDays() !== null && this.getDays() > 0) { return this.getDays() + "." + this.getHours() + ":" + this.p(this.getMinutes()) + ":" + this.p(this.getSeconds()); } else { return this.getHours() + ":" + this.p(this.getMinutes()) + ":" + this.p(this.getSeconds()); } }; this.p = function (s) { return (s.toString().length < 2) ? "0" + s : s; }; var me = this; return format ? format.replace(/dd?|HH?|hh?|mm?|ss?|tt?/g, function (format) { switch (format) { case "d": return me.getDays(); case "dd": return me.p(me.getDays()); case "H": return me.getHours(); case "HH": return me.p(me.getHours()); case "h": return me.get12HourHour(); case "hh": return me.p(me.get12HourHour()); case "m": return me.getMinutes(); case "mm": return me.p(me.getMinutes()); case "s": return me.getSeconds(); case "ss": return me.p(me.getSeconds()); case "t": return ((me.getHours() < 12) ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator).substring(0, 1); case "tt": return (me.getHours() < 12) ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator; } } ) : this._toString(); }; return this; }; addSetFuncs(TimeSpan, attrs.slice(2)); TimeSpan.prototype.set = function (days, hours, minutes, seconds, milliseconds){ this.setDays(days || this.getDays()); this.setHours(hours || this.getHours()); this.setMinutes(minutes || this.getMinutes()); this.setSeconds(seconds || this.getSeconds()); this.setMilliseconds(milliseconds || this.getMilliseconds()); }; /** * Gets the time of day for this date instances. * @return {TimeSpan} TimeSpan */ Date.prototype.getTimeOfDay = function () { return new TimeSpan(0, this.getHours(), this.getMinutes(), this.getSeconds(), this.getMilliseconds()); }; Date.TimeSpan = TimeSpan; if (typeof window !== "undefined" ) { // keeping API compatible for v1.x window.TimeSpan = TimeSpan; } }()); (function () { "use strict"; var attrs = ["years", "months", "days", "hours", "minutes", "seconds", "milliseconds"]; var gFn = function (attr) { return function () { return this[attr]; }; }; var sFn = function (attr) { return function (val) { this[attr] = val; return this; }; }; var addSetFuncs = function (context, attrs) { for (var i = 0; i < attrs.length ; i++) { var $a = attrs[i], $b = $a.slice(0, 1).toUpperCase() + $a.slice(1); context.prototype[$a] = 0; context.prototype["get" + $b] = gFn($a); context.prototype["set" + $b] = sFn($a); } }; var setMonthsAndYears = function (orient, d1, d2, context) { function inc() { d1.addMonths(-orient); context.months++; if (context.months === 12) { context.years++; context.months = 0; } } if (orient === +1) { while (d1 > d2) { inc(); } } else { while (d1 < d2) { inc(); } } context.months--; context.months *= orient; context.years *= orient; }; var adjustForDST = function(orient, startDate, endDate) { var hasDSTMismatch = (false === (startDate.isDaylightSavingTime() === endDate.isDaylightSavingTime())); if (hasDSTMismatch && orient === 1) { startDate.addHours(-1); } else if (hasDSTMismatch) { startDate.addHours(1); } }; /** * TimePeriod(startDate, endDate); * TimePeriod(years, months, days, hours, minutes, seconds, milliseconds); */ var TimePeriod = function (years, months, days, hours, minutes, seconds, milliseconds) { if (arguments.length === 7) { this.set(years, months, days, hours, minutes, seconds, milliseconds); } else if (arguments.length === 2 && arguments[0] instanceof Date && arguments[1] instanceof Date) { var startDate = arguments[0].clone(); var endDate = arguments[1].clone(); var orient = (startDate > endDate) ? +1 : -1; this.dates = { start: arguments[0].clone(), end: arguments[1].clone() }; setMonthsAndYears(orient, startDate, endDate, this); adjustForDST(orient, startDate, endDate); // // TODO - adjust for DST var diff = endDate - startDate; if (diff !== 0) { var ts = new TimeSpan(diff); this.set(this.years, this.months, ts.getDays(), ts.getHours(), ts.getMinutes(), ts.getSeconds(), ts.getMilliseconds()); } } return this; }; // create all the set functions. addSetFuncs(TimePeriod, attrs); TimePeriod.prototype.set = function (years, months, days, hours, minutes, seconds, milliseconds){ this.setYears(years || this.getYears()); this.setMonths(months || this.getMonths()); this.setDays(days || this.getDays()); this.setHours(hours || this.getHours()); this.setMinutes(minutes || this.getMinutes()); this.setSeconds(seconds || this.getSeconds()); this.setMilliseconds(milliseconds || this.getMilliseconds()); }; Date.TimePeriod = TimePeriod; if (typeof window !== "undefined") { // keeping API compatible for v1.x window.TimePeriod = TimePeriod; } }()); ================================================ FILE: build/date-smj-NO.js ================================================ /** * @overview datejs * @version 1.0.0-rc3 * @author Gregory Wild-Smith * @copyright 2015 Gregory Wild-Smith * @license MIT * @homepage https://github.com/abritinthebay/datejs */ /* * DateJS Culture String File * Country Code: smj-NO * Name: Sami (Lule) (Norway) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["smj-NO"] = { "name": "smj-NO", "englishName": "Sami (Lule) (Norway)", "nativeName": "julevusámegiella (Vuodna)", "Sunday": "sådnåbiejvve", "Monday": "mánnodahka", "Tuesday": "dijstahka", "Wednesday": "gasskavahkko", "Thursday": "duorastahka", "Friday": "bierjjedahka", "Saturday": "lávvodahka", "Sun": "såd", "Mon": "mán", "Tue": "dis", "Wed": "gas", "Thu": "duor", "Fri": "bier", "Sat": "láv", "Su": "såd", "Mo": "mán", "Tu": "dis", "We": "gas", "Th": "duor", "Fr": "bier", "Sa": "láv", "S_Sun_Initial": "s", "M_Mon_Initial": "m", "T_Tue_Initial": "d", "W_Wed_Initial": "g", "T_Thu_Initial": "d", "F_Fri_Initial": "b", "S_Sat_Initial": "l", "January": "ådåjakmánno", "February": "guovvamánno", "March": "sjnjuktjamánno", "April": "vuoratjismánno", "May": "moarmesmánno", "June": "biehtsemánno", "July": "sjnjilltjamánno", "August": "bårggemánno", "September": "ragátmánno", "October": "gålgådismánno", "November": "basádismánno", "December": "javllamánno", "Jan_Abbr": "ådåj", "Feb_Abbr": "guov", "Mar_Abbr": "snju", "Apr_Abbr": "vuor", "May_Abbr": "moar", "Jun_Abbr": "bieh", "Jul_Abbr": "snji", "Aug_Abbr": "bårg", "Sep_Abbr": "ragá", "Oct_Abbr": "gålg", "Nov_Abbr": "basá", "Dec_Abbr": "javl", "AM": "", "PM": "", "firstDayOfWeek": 1, "twoDigitYearMax": 2029, "mdy": "dmy", "M/d/yyyy": "dd.MM.yyyy", "dddd, MMMM dd, yyyy": "MMMM d'. b. 'yyyy", "h:mm tt": "HH:mm:ss", "h:mm:ss tt": "HH:mm:ss", "dddd, MMMM dd, yyyy h:mm:ss tt": "MMMM d'. b. 'yyyy HH:mm:ss", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "MMMM dd", "MMMM, yyyy": "MMMM yyyy", "/jan(uary)?/": "ådåj(akmánno)?", "/feb(ruary)?/": "guov(vamánno)?", "/mar(ch)?/": "sjnjuktjamánno", "/apr(il)?/": "vuor(atjismánno)?", "/may/": "moar(mesmánno)?", "/jun(e)?/": "bieh(tsemánno)?", "/jul(y)?/": "sjnjilltjamánno", "/aug(ust)?/": "bårg(gemánno)?", "/sep(t(ember)?)?/": "ragá(tmánno)?", "/oct(ober)?/": "gålg(ådismánno)?", "/nov(ember)?/": "basá(dismánno)?", "/dec(ember)?/": "javl(lamánno)?", "/^su(n(day)?)?/": "^sådnåbiejvve", "/^mo(n(day)?)?/": "^mánnodahka", "/^tu(e(s(day)?)?)?/": "^dijstahka", "/^we(d(nesday)?)?/": "^gasskavahkko", "/^th(u(r(s(day)?)?)?)?/": "^duorastahka", "/^fr(i(day)?)?/": "^bierjjedahka", "/^sa(t(urday)?)?/": "^lávvodahka", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "smj-NO"; /** * @overview datejs * @version 1.0.0-rc3 * @author Gregory Wild-Smith * @copyright 2015 Gregory Wild-Smith * @license MIT * @homepage https://github.com/abritinthebay/datejs */(function () { var $D = Date; var lang = Date.CultureStrings ? Date.CultureStrings.lang : null; var loggedKeys = {}; // for debug purposes. var getText = { getFromKey: function (key, countryCode) { var output; if (Date.CultureStrings && Date.CultureStrings[countryCode] && Date.CultureStrings[countryCode][key]) { output = Date.CultureStrings[countryCode][key]; } else { output = getText.buildFromDefault(key); } if (key.charAt(0) === "/") { // Assume it's a regex output = getText.buildFromRegex(key, countryCode); } return output; }, getFromObjectValues: function (obj, countryCode) { var key, output = {}; for(key in obj) { if (obj.hasOwnProperty(key)) { output[key] = getText.getFromKey(obj[key], countryCode); } } return output; }, getFromObjectKeys: function (obj, countryCode) { var key, output = {}; for(key in obj) { if (obj.hasOwnProperty(key)) { output[getText.getFromKey(key, countryCode)] = obj[key]; } } return output; }, getFromArray: function (arr, countryCode) { var output = []; for (var i=0; i < arr.length; i++){ if (i in arr) { output[i] = getText.getFromKey(arr[i], countryCode); } } return output; }, buildFromDefault: function (key) { var output, length, split, last; switch(key) { case "name": output = "en-US"; break; case "englishName": output = "English (United States)"; break; case "nativeName": output = "English (United States)"; break; case "twoDigitYearMax": output = 2049; break; case "firstDayOfWeek": output = 0; break; default: output = key; split = key.split("_"); length = split.length; if (length > 1 && key.charAt(0) !== "/") { // if the key isn't a regex and it has a split. last = split[(length - 1)].toLowerCase(); if (last === "initial" || last === "abbr") { output = split[0]; } } break; } return output; }, buildFromRegex: function (key, countryCode) { var output; if (Date.CultureStrings && Date.CultureStrings[countryCode] && Date.CultureStrings[countryCode][key]) { output = new RegExp(Date.CultureStrings[countryCode][key], "i"); } else { output = new RegExp(key.replace(new RegExp("/", "g"),""), "i"); } return output; } }; var shallowMerge = function (obj1, obj2) { for (var attrname in obj2) { if (obj2.hasOwnProperty(attrname)) { obj1[attrname] = obj2[attrname]; } } }; var __ = function (key, language) { var countryCode = (language) ? language : lang; loggedKeys[key] = key; if (typeof key === "object") { if (key instanceof Array) { return getText.getFromArray(key, countryCode); } else { return getText.getFromObjectKeys(key, countryCode); } } else { return getText.getFromKey(key, countryCode); } }; var loadI18nScript = function (code) { // paatterned after jQuery's getScript. var url = Date.Config.i18n + code + ".js"; var head = document.getElementsByTagName("head")[0] || document.documentElement; var script = document.createElement("script"); script.src = url; var completed = false; var events = { done: function (){} // placeholder function }; // Attach handlers for all browsers script.onload = script.onreadystatechange = function() { if ( !completed && (!this.readyState || this.readyState === "loaded" || this.readyState === "complete") ) { events.done(); head.removeChild(script); } }; setTimeout(function() { head.insertBefore(script, head.firstChild); }, 0); // allows return to execute first return { done: function (cb) { events.done = function() { if (cb) { setTimeout(cb,0); } }; } }; }; var buildInfo = { buildFromMethodHash: function (obj) { var key; for(key in obj) { if (obj.hasOwnProperty(key)) { obj[key] = buildInfo[obj[key]](); } } return obj; }, timeZoneDST: function () { var DST = { "CHADT": "+1345", "NZDT": "+1300", "AEDT": "+1100", "ACDT": "+1030", "AZST": "+0500", "IRDT": "+0430", "EEST": "+0300", "CEST": "+0200", "BST": "+0100", "PMDT": "-0200", "ADT": "-0300", "NDT": "-0230", "EDT": "-0400", "CDT": "-0500", "MDT": "-0600", "PDT": "-0700", "AKDT": "-0800", "HADT": "-0900" }; return __(DST); }, timeZoneStandard: function () { var standard = { "LINT": "+1400", "TOT": "+1300", "CHAST": "+1245", "NZST": "+1200", "NFT": "+1130", "SBT": "+1100", "AEST": "+1000", "ACST": "+0930", "JST": "+0900", "CWST": "+0845", "CT": "+0800", "ICT": "+0700", "MMT": "+0630", "BST": "+0600", "NPT": "+0545", "IST": "+0530", "PKT": "+0500", "AFT": "+0430", "MSK": "+0400", "IRST": "+0330", "FET": "+0300", "EET": "+0200", "CET": "+0100", "GMT": "+0000", "UTC": "+0000", "CVT": "-0100", "GST": "-0200", "BRT": "-0300", "NST": "-0330", "AST": "-0400", "EST": "-0500", "CST": "-0600", "MST": "-0700", "PST": "-0800", "AKST": "-0900", "MIT": "-0930", "HST": "-1000", "SST": "-1100", "BIT": "-1200" }; return __(standard); }, timeZones: function (data) { var zone; data.timezones = []; for (zone in data.abbreviatedTimeZoneStandard) { if (data.abbreviatedTimeZoneStandard.hasOwnProperty(zone)) { data.timezones.push({ name: zone, offset: data.abbreviatedTimeZoneStandard[zone]}); } } for (zone in data.abbreviatedTimeZoneDST) { if (data.abbreviatedTimeZoneDST.hasOwnProperty(zone)) { data.timezones.push({ name: zone, offset: data.abbreviatedTimeZoneDST[zone], dst: true}); } } return data.timezones; }, days: function () { return __(["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"]); }, dayAbbr: function () { return __(["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"]); }, dayShortNames: function () { return __(["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"]); }, dayFirstLetters: function () { return __(["S_Sun_Initial", "M_Mon_Initial", "T_Tues_Initial", "W_Wed_Initial", "T_Thu_Initial", "F_Fri_Initial", "S_Sat_Initial"]); }, months: function () { return __(["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"]); }, monthAbbr: function () { return __(["Jan_Abbr", "Feb_Abbr", "Mar_Abbr", "Apr_Abbr", "May_Abbr", "Jun_Abbr", "Jul_Abbr", "Aug_Abbr", "Sep_Abbr", "Oct_Abbr", "Nov_Abbr", "Dec_Abbr"]); }, formatPatterns: function () { return getText.getFromObjectValues({ shortDate: "M/d/yyyy", longDate: "dddd, MMMM dd, yyyy", shortTime: "h:mm tt", longTime: "h:mm:ss tt", fullDateTime: "dddd, MMMM dd, yyyy h:mm:ss tt", sortableDateTime: "yyyy-MM-ddTHH:mm:ss", universalSortableDateTime: "yyyy-MM-dd HH:mm:ssZ", rfc1123: "ddd, dd MMM yyyy HH:mm:ss", monthDay: "MMMM dd", yearMonth: "MMMM, yyyy" }, Date.i18n.currentLanguage()); }, regex: function () { return getText.getFromObjectValues({ inTheMorning: "/( in the )(morn(ing)?)\\b/", thisMorning: "/(this )(morn(ing)?)\\b/", amThisMorning: "/(\b\\d(am)? )(this )(morn(ing)?)/", inTheEvening: "/( in the )(even(ing)?)\\b/", thisEvening: "/(this )(even(ing)?)\\b/", pmThisEvening: "/(\b\\d(pm)? )(this )(even(ing)?)/", jan: "/jan(uary)?/", feb: "/feb(ruary)?/", mar: "/mar(ch)?/", apr: "/apr(il)?/", may: "/may/", jun: "/jun(e)?/", jul: "/jul(y)?/", aug: "/aug(ust)?/", sep: "/sep(t(ember)?)?/", oct: "/oct(ober)?/", nov: "/nov(ember)?/", dec: "/dec(ember)?/", sun: "/^su(n(day)?)?/", mon: "/^mo(n(day)?)?/", tue: "/^tu(e(s(day)?)?)?/", wed: "/^we(d(nesday)?)?/", thu: "/^th(u(r(s(day)?)?)?)?/", fri: "/fr(i(day)?)?/", sat: "/^sa(t(urday)?)?/", future: "/^next/", past: "/^last|past|prev(ious)?/", add: "/^(\\+|aft(er)?|from|hence)/", subtract: "/^(\\-|bef(ore)?|ago)/", yesterday: "/^yes(terday)?/", today: "/^t(od(ay)?)?/", tomorrow: "/^tom(orrow)?/", now: "/^n(ow)?/", millisecond: "/^ms|milli(second)?s?/", second: "/^sec(ond)?s?/", minute: "/^mn|min(ute)?s?/", hour: "/^h(our)?s?/", week: "/^w(eek)?s?/", month: "/^m(onth)?s?/", day: "/^d(ay)?s?/", year: "/^y(ear)?s?/", shortMeridian: "/^(a|p)/", longMeridian: "/^(a\\.?m?\\.?|p\\.?m?\\.?)/", timezone: "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/", ordinalSuffix: "/^\\s*(st|nd|rd|th)/", timeContext: "/^\\s*(\\:|a(?!u|p)|p)/" }, Date.i18n.currentLanguage()); } }; var CultureInfo = function () { var info = getText.getFromObjectValues({ name: "name", englishName: "englishName", nativeName: "nativeName", amDesignator: "AM", pmDesignator: "PM", firstDayOfWeek: "firstDayOfWeek", twoDigitYearMax: "twoDigitYearMax", dateElementOrder: "mdy" }, Date.i18n.currentLanguage()); var constructedInfo = buildInfo.buildFromMethodHash({ dayNames: "days", abbreviatedDayNames: "dayAbbr", shortestDayNames: "dayShortNames", firstLetterDayNames: "dayFirstLetters", monthNames: "months", abbreviatedMonthNames: "monthAbbr", formatPatterns: "formatPatterns", regexPatterns: "regex", abbreviatedTimeZoneDST: "timeZoneDST", abbreviatedTimeZoneStandard: "timeZoneStandard" }); shallowMerge(info, constructedInfo); buildInfo.timeZones(info); return info; }; $D.i18n = { __: function (key, lang) { return __(key, lang); }, currentLanguage: function () { return lang || "en-US"; }, setLanguage: function (code, force, cb) { var async = false; if (force || code === "en-US" || (!!Date.CultureStrings && !!Date.CultureStrings[code])) { lang = code; Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings.lang = code; Date.CultureInfo = new CultureInfo(); } else { if (!(!!Date.CultureStrings && !!Date.CultureStrings[code])) { if (typeof exports !== "undefined" && this.exports !== exports) { // we're in a Node enviroment, load it using require try { require("../i18n/" + code + ".js"); lang = code; Date.CultureStrings.lang = code; Date.CultureInfo = new CultureInfo(); } catch (e) { // var str = "The language for '" + code + "' could not be loaded by Node. It likely does not exist."; throw new Error("The DateJS IETF language tag '" + code + "' could not be loaded by Node. It likely does not exist."); } } else if (Date.Config && Date.Config.i18n) { // we know the location of the files, so lets load them async = true; loadI18nScript(code).done(function(){ lang = code; Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings.lang = code; Date.CultureInfo = new CultureInfo(); $D.Parsing.Normalizer.buildReplaceData(); // because this is async if ($D.Grammar) { $D.Grammar.buildGrammarFormats(); // so we can parse those strings... } if (cb) { setTimeout(cb,0); } }); } else { Date.console.error("The DateJS IETF language tag '" + code + "' is not available and has not been loaded."); return false; } } } $D.Parsing.Normalizer.buildReplaceData(); // rebuild normalizer strings if ($D.Grammar) { $D.Grammar.buildGrammarFormats(); // so we can parse those strings... } if (!async && cb) { setTimeout(cb,0); } }, getLoggedKeys: function () { return loggedKeys; }, updateCultureInfo: function () { Date.CultureInfo = new CultureInfo(); } }; $D.i18n.updateCultureInfo(); // run automatically }()); (function () { var $D = Date, $P = $D.prototype, p = function (s, l) { if (!l) { l = 2; } return ("000" + s).slice(l * -1); }; if (typeof window !== "undefined" && typeof window.console !== "undefined" && typeof window.console.log !== "undefined") { $D.console = console; // used only to raise non-critical errors if available } else { // set mock so we don't give errors. $D.console = { log: function(){}, error: function(){} }; } $D.Config = $D.Config || {}; $D.initOverloads = function() { /** * Overload of Date.now. Allows an alternate call for Date.now where it returns the * current Date as an object rather than just milliseconds since the Unix Epoch. * * Also provides an implementation of now() for browsers (IE<9) that don't have it. * * Backwards compatible so with work with either: * Date.now() [returns ms] * or * Date.now(true) [returns Date] */ if (!$D.now) { $D._now = function now() { return new Date().getTime(); }; } else if (!$D._now) { $D._now = $D.now; } $D.now = function (returnObj) { if (returnObj) { return $D.present(); } else { return $D._now(); } }; if ( !$P.toISOString ) { $P.toISOString = function() { return this.getUTCFullYear() + "-" + p(this.getUTCMonth() + 1) + "-" + p(this.getUTCDate()) + "T" + p(this.getUTCHours()) + ":" + p(this.getUTCMinutes()) + ":" + p(this.getUTCSeconds()) + "." + String( (this.getUTCMilliseconds()/1000).toFixed(3)).slice(2, 5) + "Z"; }; } // private if ( $P._toString === undefined ){ $P._toString = $P.toString; } }; $D.initOverloads(); /** * Gets a date that is set to the current date. The time is set to the start of the day (00:00 or 12:00 AM). * @return {Date} The current date. */ $D.today = function () { return new Date().clearTime(); }; /** * Gets a date that is set to the current date and time (same as new Date, but chainable) * @return {Date} The current date. */ $D.present = function () { return new Date(); }; /** * Compares the first date to the second date and returns an number indication of their relative values. * @param {Date} First Date object to compare [Required]. * @param {Date} Second Date object to compare to [Required]. * @return {Number} -1 = date1 is lessthan date2. 0 = values are equal. 1 = date1 is greaterthan date2. */ $D.compare = function (date1, date2) { if (isNaN(date1) || isNaN(date2)) { throw new Error(date1 + " - " + date2); } else if (date1 instanceof Date && date2 instanceof Date) { return (date1 < date2) ? -1 : (date1 > date2) ? 1 : 0; } else { throw new TypeError(date1 + " - " + date2); } }; /** * Compares the first Date object to the second Date object and returns true if they are equal. * @param {Date} First Date object to compare [Required] * @param {Date} Second Date object to compare to [Required] * @return {Boolean} true if dates are equal. false if they are not equal. */ $D.equals = function (date1, date2) { return (date1.compareTo(date2) === 0); }; /** * Gets the language appropriate day name when given the day number(0-6) * eg - 0 == Sunday * @return {String} The day name */ $D.getDayName = function (n) { return Date.CultureInfo.dayNames[n]; }; /** * Gets the day number (0-6) if given a CultureInfo specific string which is a valid dayName, abbreviatedDayName or shortestDayName (two char). * @param {String} The name of the day (eg. "Monday, "Mon", "tuesday", "tue", "We", "we"). * @return {Number} The day number */ $D.getDayNumberFromName = function (name) { var n = Date.CultureInfo.dayNames, m = Date.CultureInfo.abbreviatedDayNames, o = Date.CultureInfo.shortestDayNames, s = name.toLowerCase(); for (var i = 0; i < n.length; i++) { if (n[i].toLowerCase() === s || m[i].toLowerCase() === s || o[i].toLowerCase() === s) { return i; } } return -1; }; /** * Gets the month number (0-11) if given a Culture Info specific string which is a valid monthName or abbreviatedMonthName. * @param {String} The name of the month (eg. "February, "Feb", "october", "oct"). * @return {Number} The day number */ $D.getMonthNumberFromName = function (name) { var n = Date.CultureInfo.monthNames, m = Date.CultureInfo.abbreviatedMonthNames, s = name.toLowerCase(); for (var i = 0; i < n.length; i++) { if (n[i].toLowerCase() === s || m[i].toLowerCase() === s) { return i; } } return -1; }; /** * Gets the language appropriate month name when given the month number(0-11) * eg - 0 == January * @return {String} The month name */ $D.getMonthName = function (n) { return Date.CultureInfo.monthNames[n]; }; /** * Determines if the current date instance is within a LeapYear. * @param {Number} The year. * @return {Boolean} true if date is within a LeapYear, otherwise false. */ $D.isLeapYear = function (year) { return ((year % 4 === 0 && year % 100 !== 0) || year % 400 === 0); }; /** * Gets the number of days in the month, given a year and month value. Automatically corrects for LeapYear. * @param {Number} The year. * @param {Number} The month (0-11). * @return {Number} The number of days in the month. */ $D.getDaysInMonth = function (year, month) { if (!month && $D.validateMonth(year)) { month = year; year = Date.today().getFullYear(); } return [31, ($D.isLeapYear(year) ? 29 : 28), 31, 30, 31, 30, 31, 31, 30, 31, 30, 31][month]; }; $P.getDaysInMonth = function () { return $D.getDaysInMonth(this.getFullYear(), this.getMonth()); }; $D.getTimezoneAbbreviation = function (offset, dst) { var p, n = (dst || false) ? Date.CultureInfo.abbreviatedTimeZoneDST : Date.CultureInfo.abbreviatedTimeZoneStandard; for (p in n) { if (n.hasOwnProperty(p)) { if (n[p] === offset) { return p; } } } return null; }; $D.getTimezoneOffset = function (name, dst) { var i, a =[], z = Date.CultureInfo.timezones; if (!name) { name = (new Date()).getTimezone();} for (i = 0; i < z.length; i++) { if (z[i].name === name.toUpperCase()) { a.push(i); } } if (!z[a[0]]) { return null; } if (a.length === 1 || !dst) { return z[a[0]].offset; } else { for (i=0; i < a.length; i++) { if (z[a[i]].dst) { return z[a[i]].offset; } } } }; $D.getQuarter = function (d) { d = d || new Date(); // If no date supplied, use today var q = [1,2,3,4]; return q[Math.floor(d.getMonth() / 3)]; // ~~~ is a bitwise op. Faster than Math.floor }; $D.getDaysLeftInQuarter = function (d) { d = d || new Date(); var qEnd = new Date(d); qEnd.setMonth(qEnd.getMonth() + 3 - qEnd.getMonth() % 3, 0); return Math.floor((qEnd - d) / 8.64e7); }; // private var validate = function (n, min, max, name) { name = name ? name : "Object"; if (typeof n === "undefined") { return false; } else if (typeof n !== "number") { throw new TypeError(n + " is not a Number."); } else if (n < min || n > max) { // As failing validation is *not* an exceptional circumstance // lets not throw a RangeError Exception here. // It's semantically correct but it's not sensible. return false; } return true; }; /** * Validates the number is within an acceptable range for milliseconds [0-999]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateMillisecond = function (value) { return validate(value, 0, 999, "millisecond"); }; /** * Validates the number is within an acceptable range for seconds [0-59]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateSecond = function (value) { return validate(value, 0, 59, "second"); }; /** * Validates the number is within an acceptable range for minutes [0-59]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateMinute = function (value) { return validate(value, 0, 59, "minute"); }; /** * Validates the number is within an acceptable range for hours [0-23]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateHour = function (value) { return validate(value, 0, 23, "hour"); }; /** * Validates the number is within an acceptable range for the days in a month [0-MaxDaysInMonth]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateDay = function (value, year, month) { if (year === undefined || year === null || month === undefined || month === null) { return false;} return validate(value, 1, $D.getDaysInMonth(year, month), "day"); }; /** * Validates the number is within an acceptable range for months [0-11]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateWeek = function (value) { return validate(value, 0, 53, "week"); }; /** * Validates the number is within an acceptable range for months [0-11]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateMonth = function (value) { return validate(value, 0, 11, "month"); }; /** * Validates the number is within an acceptable range for years. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateYear = function (value) { /** * Per ECMAScript spec the range of times supported by Date objects is * exactly -100,000,000 days to +100,000,000 days measured relative to * midnight at the beginning of 01 January, 1970 UTC. * This gives a range of 8,640,000,000,000,000 milliseconds to either * side of 01 January, 1970 UTC. * * Earliest possible date: Tue, 20 Apr 271,822 B.C. 00:00:00 UTC * Latest possible date: Sat, 13 Sep 275,760 00:00:00 UTC */ return validate(value, -271822, 275760, "year"); }; $D.validateTimezone = function(value) { var timezones = {"ACDT":1,"ACST":1,"ACT":1,"ADT":1,"AEDT":1,"AEST":1,"AFT":1,"AKDT":1,"AKST":1,"AMST":1,"AMT":1,"ART":1,"AST":1,"AWDT":1,"AWST":1,"AZOST":1,"AZT":1,"BDT":1,"BIOT":1,"BIT":1,"BOT":1,"BRT":1,"BST":1,"BTT":1,"CAT":1,"CCT":1,"CDT":1,"CEDT":1,"CEST":1,"CET":1,"CHADT":1,"CHAST":1,"CHOT":1,"ChST":1,"CHUT":1,"CIST":1,"CIT":1,"CKT":1,"CLST":1,"CLT":1,"COST":1,"COT":1,"CST":1,"CT":1,"CVT":1,"CWST":1,"CXT":1,"DAVT":1,"DDUT":1,"DFT":1,"EASST":1,"EAST":1,"EAT":1,"ECT":1,"EDT":1,"EEDT":1,"EEST":1,"EET":1,"EGST":1,"EGT":1,"EIT":1,"EST":1,"FET":1,"FJT":1,"FKST":1,"FKT":1,"FNT":1,"GALT":1,"GAMT":1,"GET":1,"GFT":1,"GILT":1,"GIT":1,"GMT":1,"GST":1,"GYT":1,"HADT":1,"HAEC":1,"HAST":1,"HKT":1,"HMT":1,"HOVT":1,"HST":1,"ICT":1,"IDT":1,"IOT":1,"IRDT":1,"IRKT":1,"IRST":1,"IST":1,"JST":1,"KGT":1,"KOST":1,"KRAT":1,"KST":1,"LHST":1,"LINT":1,"MAGT":1,"MART":1,"MAWT":1,"MDT":1,"MET":1,"MEST":1,"MHT":1,"MIST":1,"MIT":1,"MMT":1,"MSK":1,"MST":1,"MUT":1,"MVT":1,"MYT":1,"NCT":1,"NDT":1,"NFT":1,"NPT":1,"NST":1,"NT":1,"NUT":1,"NZDT":1,"NZST":1,"OMST":1,"ORAT":1,"PDT":1,"PET":1,"PETT":1,"PGT":1,"PHOT":1,"PHT":1,"PKT":1,"PMDT":1,"PMST":1,"PONT":1,"PST":1,"PYST":1,"PYT":1,"RET":1,"ROTT":1,"SAKT":1,"SAMT":1,"SAST":1,"SBT":1,"SCT":1,"SGT":1,"SLST":1,"SRT":1,"SST":1,"SYOT":1,"TAHT":1,"THA":1,"TFT":1,"TJT":1,"TKT":1,"TLT":1,"TMT":1,"TOT":1,"TVT":1,"UCT":1,"ULAT":1,"UTC":1,"UYST":1,"UYT":1,"UZT":1,"VET":1,"VLAT":1,"VOLT":1,"VOST":1,"VUT":1,"WAKT":1,"WAST":1,"WAT":1,"WEDT":1,"WEST":1,"WET":1,"WST":1,"YAKT":1,"YEKT":1,"Z":1}; return (timezones[value] === 1); }; $D.validateTimezoneOffset= function(value) { // timezones go from +14hrs to -12hrs, the +X hours are negative offsets. return (value > -841 && value < 721); }; }()); (function () { var $D = Date, $P = $D.prototype, p = function (s, l) { if (!l) { l = 2; } return ("000" + s).slice(l * -1); }; var validateConfigObject = function (obj) { var result = {}, self = this, prop, testFunc; testFunc = function (prop, func, value) { if (prop === "day") { var month = (obj.month !== undefined) ? obj.month : self.getMonth(); var year = (obj.year !== undefined) ? obj.year : self.getFullYear(); return $D[func](value, year, month); } else { return $D[func](value); } }; for (prop in obj) { if (Object.prototype.hasOwnProperty.call(obj, prop)) { var func = "validate" + prop.charAt(0).toUpperCase() + prop.slice(1); if ($D[func] && obj[prop] !== null && testFunc(prop, func, obj[prop])) { result[prop] = obj[prop]; } } } return result; }; /** * Resets the time of this Date object to 12:00 AM (00:00), which is the start of the day. * @param {Boolean} .clone() this date instance before clearing Time * @return {Date} this */ $P.clearTime = function () { this.setHours(0); this.setMinutes(0); this.setSeconds(0); this.setMilliseconds(0); return this; }; /** * Resets the time of this Date object to the current time ('now'). * @return {Date} this */ $P.setTimeToNow = function () { var n = new Date(); this.setHours(n.getHours()); this.setMinutes(n.getMinutes()); this.setSeconds(n.getSeconds()); this.setMilliseconds(n.getMilliseconds()); return this; }; /** * Returns a new Date object that is an exact date and time copy of the original instance. * @return {Date} A new Date instance */ $P.clone = function () { return new Date(this.getTime()); }; /** * Compares this instance to a Date object and returns an number indication of their relative values. * @param {Date} Date object to compare [Required] * @return {Number} -1 = this is lessthan date. 0 = values are equal. 1 = this is greaterthan date. */ $P.compareTo = function (date) { return Date.compare(this, date); }; /** * Compares this instance to another Date object and returns true if they are equal. * @param {Date} Date object to compare. If no date to compare, new Date() [now] is used. * @return {Boolean} true if dates are equal. false if they are not equal. */ $P.equals = function (date) { return Date.equals(this, (date !== undefined ? date : new Date())); }; /** * Determines if this instance is between a range of two dates or equal to either the start or end dates. * @param {Date} Start of range [Required] * @param {Date} End of range [Required] * @return {Boolean} true is this is between or equal to the start and end dates, else false */ $P.between = function (start, end) { return this.getTime() >= start.getTime() && this.getTime() <= end.getTime(); }; /** * Determines if this date occurs after the date to compare to. * @param {Date} Date object to compare. If no date to compare, new Date() ("now") is used. * @return {Boolean} true if this date instance is greater than the date to compare to (or "now"), otherwise false. */ $P.isAfter = function (date) { return this.compareTo(date || new Date()) === 1; }; /** * Determines if this date occurs before the date to compare to. * @param {Date} Date object to compare. If no date to compare, new Date() ("now") is used. * @return {Boolean} true if this date instance is less than the date to compare to (or "now"). */ $P.isBefore = function (date) { return (this.compareTo(date || new Date()) === -1); }; /** * Determines if the current Date instance occurs today. * @return {Boolean} true if this date instance is 'today', otherwise false. */ /** * Determines if the current Date instance occurs on the same Date as the supplied 'date'. * If no 'date' to compare to is provided, the current Date instance is compared to 'today'. * @param {date} Date object to compare. If no date to compare, the current Date ("now") is used. * @return {Boolean} true if this Date instance occurs on the same Day as the supplied 'date'. */ $P.isToday = $P.isSameDay = function (date) { return this.clone().clearTime().equals((date || new Date()).clone().clearTime()); }; /** * Adds the specified number of milliseconds to this instance. * @param {Number} The number of milliseconds to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addMilliseconds = function (value) { if (!value) { return this; } this.setTime(this.getTime() + value * 1); return this; }; /** * Adds the specified number of seconds to this instance. * @param {Number} The number of seconds to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addSeconds = function (value) { if (!value) { return this; } return this.addMilliseconds(value * 1000); }; /** * Adds the specified number of seconds to this instance. * @param {Number} The number of seconds to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addMinutes = function (value) { if (!value) { return this; } return this.addMilliseconds(value * 60000); // 60*1000 }; /** * Adds the specified number of hours to this instance. * @param {Number} The number of hours to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addHours = function (value) { if (!value) { return this; } return this.addMilliseconds(value * 3600000); // 60*60*1000 }; /** * Adds the specified number of days to this instance. * @param {Number} The number of days to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addDays = function (value) { if (!value) { return this; } this.setDate(this.getDate() + value * 1); return this; }; /** * Adds the specified number of weekdays (ie - not sat or sun) to this instance. * @param {Number} The number of days to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addWeekdays = function (value) { if (!value) { return this; } var day = this.getDay(); var weeks = (Math.ceil(Math.abs(value)/7)); if (day === 0 || day === 6) { if (value > 0) { this.next().monday(); this.addDays(-1); day = this.getDay(); } } if (value < 0) { while (value < 0) { this.addDays(-1); day = this.getDay(); if (day !== 0 && day !== 6) { value++; } } return this; } else if (value > 5 || (6-day) <= value) { value = value + (weeks * 2); } return this.addDays(value); }; /** * Adds the specified number of weeks to this instance. * @param {Number} The number of weeks to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addWeeks = function (value) { if (!value) { return this; } return this.addDays(value * 7); }; /** * Adds the specified number of months to this instance. * @param {Number} The number of months to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addMonths = function (value) { if (!value) { return this; } var n = this.getDate(); this.setDate(1); this.setMonth(this.getMonth() + value * 1); this.setDate(Math.min(n, $D.getDaysInMonth(this.getFullYear(), this.getMonth()))); return this; }; $P.addQuarters = function (value) { if (!value) { return this; } // note this will take you to the same point in the quarter as you are now. // i.e. - if you are 15 days into the quarter you'll be 15 days into the resulting one. // bonus: this allows adding fractional quarters return this.addMonths(value * 3); }; /** * Adds the specified number of years to this instance. * @param {Number} The number of years to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addYears = function (value) { if (!value) { return this; } return this.addMonths(value * 12); }; /** * Adds (or subtracts) to the value of the years, months, weeks, days, hours, minutes, seconds, milliseconds of the date instance using given configuration object. Positive and Negative values allowed. * Example

	Date.today().add( { days: 1, months: 1 } )

	new Date().add( { years: -1 } )
	
* @param {Object} Configuration object containing attributes (months, days, etc.) * @return {Date} this */ $P.add = function (config) { if (typeof config === "number") { this._orient = config; return this; } var x = config; if (x.day) { // If we should be a different date than today (eg: for 'tomorrow -1d', etc). // Should only effect parsing, not direct usage (eg, Finish and FinishExact) if ((x.day - this.getDate()) !== 0) { this.setDate(x.day); } } if (x.milliseconds) { this.addMilliseconds(x.milliseconds); } if (x.seconds) { this.addSeconds(x.seconds); } if (x.minutes) { this.addMinutes(x.minutes); } if (x.hours) { this.addHours(x.hours); } if (x.weeks) { this.addWeeks(x.weeks); } if (x.months) { this.addMonths(x.months); } if (x.years) { this.addYears(x.years); } if (x.days) { this.addDays(x.days); } return this; }; /** * Get the week number. Week one (1) is the week which contains the first Thursday of the year. Monday is considered the first day of the week. * The .getWeek() function does NOT convert the date to UTC. The local datetime is used. * Please use .getISOWeek() to get the week of the UTC converted date. * @return {Number} 1 to 53 */ $P.getWeek = function (utc) { // Create a copy of this date object var self, target = new Date(this.valueOf()); if (utc) { target.addMinutes(target.getTimezoneOffset()); self = target.clone(); } else { self = this; } // ISO week date weeks start on monday // so correct the day number var dayNr = (self.getDay() + 6) % 7; // ISO 8601 states that week 1 is the week // with the first thursday of that year. // Set the target date to the thursday in the target week target.setDate(target.getDate() - dayNr + 3); // Store the millisecond value of the target date var firstThursday = target.valueOf(); // Set the target to the first thursday of the year // First set the target to january first target.setMonth(0, 1); // Not a thursday? Correct the date to the next thursday if (target.getDay() !== 4) { target.setMonth(0, 1 + ((4 - target.getDay()) + 7) % 7); } // The weeknumber is the number of weeks between the // first thursday of the year and the thursday in the target week return 1 + Math.ceil((firstThursday - target) / 604800000); // 604800000 = 7 * 24 * 3600 * 1000 }; /** * Get the ISO 8601 week number. Week one ("01") is the week which contains the first Thursday of the year. Monday is considered the first day of the week. * The .getISOWeek() function does convert the date to it's UTC value. Please use .getWeek() to get the week of the local date. * @return {String} "01" to "53" */ $P.getISOWeek = function () { return p(this.getWeek(true)); }; /** * Moves the date to Monday of the week set. Week one (1) is the week which contains the first Thursday of the year. * @param {Number} A Number (1 to 53) that represents the week of the year. * @return {Date} this */ $P.setWeek = function (n) { if ((n - this.getWeek()) === 0) { if (this.getDay() !== 1) { return this.moveToDayOfWeek(1, (this.getDay() > 1 ? -1 : 1)); } else { return this; } } else { return this.moveToDayOfWeek(1, (this.getDay() > 1 ? -1 : 1)).addWeeks(n - this.getWeek()); } }; $P.setQuarter = function (qtr) { var month = Math.abs(((qtr-1) * 3) + 1); return this.setMonth(month, 1); }; $P.getQuarter = function () { return Date.getQuarter(this); }; $P.getDaysLeftInQuarter = function () { return Date.getDaysLeftInQuarter(this); }; /** * Moves the date to the next n'th occurrence of the dayOfWeek starting from the beginning of the month. The number (-1) is a magic number and will return the last occurrence of the dayOfWeek in the month. * @param {Number} The dayOfWeek to move to * @param {Number} The n'th occurrence to move to. Use (-1) to return the last occurrence in the month * @return {Date} this */ $P.moveToNthOccurrence = function (dayOfWeek, occurrence) { if (dayOfWeek === "Weekday") { if (occurrence > 0) { this.moveToFirstDayOfMonth(); if (this.is().weekday()) { occurrence -= 1; } } else if (occurrence < 0) { this.moveToLastDayOfMonth(); if (this.is().weekday()) { occurrence += 1; } } else { return this; } return this.addWeekdays(occurrence); } var shift = 0; if (occurrence > 0) { shift = occurrence - 1; } else if (occurrence === -1) { this.moveToLastDayOfMonth(); if (this.getDay() !== dayOfWeek) { this.moveToDayOfWeek(dayOfWeek, -1); } return this; } return this.moveToFirstDayOfMonth().addDays(-1).moveToDayOfWeek(dayOfWeek, +1).addWeeks(shift); }; var moveToN = function (getFunc, addFunc, nVal) { return function (value, orient) { var diff = (value - this[getFunc]() + nVal * (orient || +1)) % nVal; return this[addFunc]((diff === 0) ? diff += nVal * (orient || +1) : diff); }; }; /** * Move to the next or last dayOfWeek based on the orient value. * @param {Number} The dayOfWeek to move to * @param {Number} Forward (+1) or Back (-1). Defaults to +1. [Optional] * @return {Date} this */ $P.moveToDayOfWeek = moveToN("getDay", "addDays", 7); /** * Move to the next or last month based on the orient value. * @param {Number} The month to move to. 0 = January, 11 = December * @param {Number} Forward (+1) or Back (-1). Defaults to +1. [Optional] * @return {Date} this */ $P.moveToMonth = moveToN("getMonth", "addMonths", 12); /** * Get the Ordinate of the current day ("th", "st", "rd"). * @return {String} */ $P.getOrdinate = function () { var num = this.getDate(); return ord(num); }; /** * Get the Ordinal day (numeric day number) of the year, adjusted for leap year. * @return {Number} 1 through 365 (366 in leap years) */ $P.getOrdinalNumber = function () { return Math.ceil((this.clone().clearTime() - new Date(this.getFullYear(), 0, 1)) / 86400000) + 1; }; /** * Get the time zone abbreviation of the current date. * @return {String} The abbreviated time zone name (e.g. "EST") */ $P.getTimezone = function () { return $D.getTimezoneAbbreviation(this.getUTCOffset(), this.isDaylightSavingTime()); }; $P.setTimezoneOffset = function (offset) { var here = this.getTimezoneOffset(), there = Number(offset) * -6 / 10; return (there || there === 0) ? this.addMinutes(there - here) : this; }; $P.setTimezone = function (offset) { return this.setTimezoneOffset($D.getTimezoneOffset(offset)); }; /** * Indicates whether Daylight Saving Time is observed in the current time zone. * @return {Boolean} true|false */ $P.hasDaylightSavingTime = function () { return (Date.today().set({month: 0, day: 1}).getTimezoneOffset() !== Date.today().set({month: 6, day: 1}).getTimezoneOffset()); }; /** * Indicates whether this Date instance is within the Daylight Saving Time range for the current time zone. * @return {Boolean} true|false */ $P.isDaylightSavingTime = function () { return Date.today().set({month: 0, day: 1}).getTimezoneOffset() !== this.getTimezoneOffset(); }; /** * Get the offset from UTC of the current date. * @return {String} The 4-character offset string prefixed with + or - (e.g. "-0500") */ $P.getUTCOffset = function (offset) { var n = (offset || this.getTimezoneOffset()) * -10 / 6, r; if (n < 0) { r = (n - 10000).toString(); return r.charAt(0) + r.substr(2); } else { r = (n + 10000).toString(); return "+" + r.substr(1); } }; /** * Returns the number of milliseconds between this date and date. * @param {Date} Defaults to now * @return {Number} The diff in milliseconds */ $P.getElapsed = function (date) { return (date || new Date()) - this; }; /** * Set the value of year, month, day, hour, minute, second, millisecond of date instance using given configuration object. * Example

	Date.today().set( { day: 20, month: 1 } )

	new Date().set( { millisecond: 0 } )
	
* * @param {Object} Configuration object containing attributes (month, day, etc.) * @return {Date} this */ $P.set = function (config) { config = validateConfigObject.call(this, config); var key; for (key in config) { if (Object.prototype.hasOwnProperty.call(config, key)) { var name = key.charAt(0).toUpperCase() + key.slice(1); var addFunc, getFunc; if (key !== "week" && key !== "month" && key !== "timezone" && key !== "timezoneOffset") { name += "s"; } addFunc = "add" + name; getFunc = "get" + name; if (key === "month") { addFunc = addFunc + "s"; } else if (key === "year"){ getFunc = "getFullYear"; } if (key !== "day" && key !== "timezone" && key !== "timezoneOffset" && key !== "week" && key !== "hour") { this[addFunc](config[key] - this[getFunc]()); } else if ( key === "timezone"|| key === "timezoneOffset" || key === "week" || key === "hour") { this["set"+name](config[key]); } } } // day has to go last because you can't validate the day without first knowing the month if (config.day) { this.addDays(config.day - this.getDate()); } return this; }; /** * Moves the date to the first day of the month. * @return {Date} this */ $P.moveToFirstDayOfMonth = function () { return this.set({ day: 1 }); }; /** * Moves the date to the last day of the month. * @return {Date} this */ $P.moveToLastDayOfMonth = function () { return this.set({ day: $D.getDaysInMonth(this.getFullYear(), this.getMonth())}); }; /** * Converts the value of the current Date object to its equivalent string representation. * Format Specifiers * CUSTOM DATE AND TIME FORMAT STRINGS * Format Description Example * ------ --------------------------------------------------------------------------- ----------------------- * s The seconds of the minute between 0-59. "0" to "59" * ss The seconds of the minute with leading zero if required. "00" to "59" * * m The minute of the hour between 0-59. "0" or "59" * mm The minute of the hour with leading zero if required. "00" or "59" * * h The hour of the day between 1-12. "1" to "12" * hh The hour of the day with leading zero if required. "01" to "12" * * H The hour of the day between 0-23. "0" to "23" * HH The hour of the day with leading zero if required. "00" to "23" * * d The day of the month between 1 and 31. "1" to "31" * dd The day of the month with leading zero if required. "01" to "31" * ddd Abbreviated day name. Date.CultureInfo.abbreviatedDayNames. "Mon" to "Sun" * dddd The full day name. Date.CultureInfo.dayNames. "Monday" to "Sunday" * * M The month of the year between 1-12. "1" to "12" * MM The month of the year with leading zero if required. "01" to "12" * MMM Abbreviated month name. Date.CultureInfo.abbreviatedMonthNames. "Jan" to "Dec" * MMMM The full month name. Date.CultureInfo.monthNames. "January" to "December" * * yy The year as a two-digit number. "99" or "08" * yyyy The full four digit year. "1999" or "2008" * * t Displays the first character of the A.M./P.M. designator. "A" or "P" * Date.CultureInfo.amDesignator or Date.CultureInfo.pmDesignator * tt Displays the A.M./P.M. designator. "AM" or "PM" * Date.CultureInfo.amDesignator or Date.CultureInfo.pmDesignator * * S The ordinal suffix ("st, "nd", "rd" or "th") of the current day. "st, "nd", "rd" or "th" * * STANDARD DATE AND TIME FORMAT STRINGS * Format Description Example *------ --------------------------------------------------------------------------- ----------------------- * d The CultureInfo shortDate Format Pattern "M/d/yyyy" * D The CultureInfo longDate Format Pattern "dddd, MMMM dd, yyyy" * F The CultureInfo fullDateTime Format Pattern "dddd, MMMM dd, yyyy h:mm:ss tt" * m The CultureInfo monthDay Format Pattern "MMMM dd" * r The CultureInfo rfc1123 Format Pattern "ddd, dd MMM yyyy HH:mm:ss GMT" * s The CultureInfo sortableDateTime Format Pattern "yyyy-MM-ddTHH:mm:ss" * t The CultureInfo shortTime Format Pattern "h:mm tt" * T The CultureInfo longTime Format Pattern "h:mm:ss tt" * u The CultureInfo universalSortableDateTime Format Pattern "yyyy-MM-dd HH:mm:ssZ" * y The CultureInfo yearMonth Format Pattern "MMMM, yyyy" * * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @return {String} A string representation of the current Date object. */ var ord = function (n) { switch (n * 1) { case 1: case 21: case 31: return "st"; case 2: case 22: return "nd"; case 3: case 23: return "rd"; default: return "th"; } }; var parseStandardFormats = function (format) { var y, c = Date.CultureInfo.formatPatterns; switch (format) { case "d": return this.toString(c.shortDate); case "D": return this.toString(c.longDate); case "F": return this.toString(c.fullDateTime); case "m": return this.toString(c.monthDay); case "r": case "R": y = this.clone().addMinutes(this.getTimezoneOffset()); return y.toString(c.rfc1123) + " GMT"; case "s": return this.toString(c.sortableDateTime); case "t": return this.toString(c.shortTime); case "T": return this.toString(c.longTime); case "u": y = this.clone().addMinutes(this.getTimezoneOffset()); return y.toString(c.universalSortableDateTime); case "y": return this.toString(c.yearMonth); default: return false; } }; var parseFormatStringsClosure = function (context) { return function (m) { if (m.charAt(0) === "\\") { return m.replace("\\", ""); } switch (m) { case "hh": return p(context.getHours() < 13 ? (context.getHours() === 0 ? 12 : context.getHours()) : (context.getHours() - 12)); case "h": return context.getHours() < 13 ? (context.getHours() === 0 ? 12 : context.getHours()) : (context.getHours() - 12); case "HH": return p(context.getHours()); case "H": return context.getHours(); case "mm": return p(context.getMinutes()); case "m": return context.getMinutes(); case "ss": return p(context.getSeconds()); case "s": return context.getSeconds(); case "yyyy": return p(context.getFullYear(), 4); case "yy": return p(context.getFullYear()); case "y": return context.getFullYear(); case "E": case "dddd": return Date.CultureInfo.dayNames[context.getDay()]; case "ddd": return Date.CultureInfo.abbreviatedDayNames[context.getDay()]; case "dd": return p(context.getDate()); case "d": return context.getDate(); case "MMMM": return Date.CultureInfo.monthNames[context.getMonth()]; case "MMM": return Date.CultureInfo.abbreviatedMonthNames[context.getMonth()]; case "MM": return p((context.getMonth() + 1)); case "M": return context.getMonth() + 1; case "t": return context.getHours() < 12 ? Date.CultureInfo.amDesignator.substring(0, 1) : Date.CultureInfo.pmDesignator.substring(0, 1); case "tt": return context.getHours() < 12 ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator; case "S": return ord(context.getDate()); case "W": return context.getWeek(); case "WW": return context.getISOWeek(); case "Q": return "Q" + context.getQuarter(); case "q": return String(context.getQuarter()); case "z": return context.getTimezone(); case "Z": case "X": return Date.getTimezoneOffset(context.getTimezone()); case "ZZ": // Timezone offset in seconds return context.getTimezoneOffset() * -60; case "u": return context.getDay(); case "L": return ($D.isLeapYear(context.getFullYear())) ? 1 : 0; case "B": // Swatch Internet Time (.beats) return "@"+((context.getUTCSeconds() + (context.getUTCMinutes()*60) + ((context.getUTCHours()+1)*3600))/86.4); default: return m; } }; }; $P.toString = function (format, ignoreStandards) { // Standard Date and Time Format Strings. Formats pulled from CultureInfo file and // may vary by culture. if (!ignoreStandards && format && format.length === 1) { output = parseStandardFormats.call(this, format); if (output) { return output; } } var parseFormatStrings = parseFormatStringsClosure(this); return format ? format.replace(/((\\)?(dd?d?d?|MM?M?M?|yy?y?y?|hh?|HH?|mm?|ss?|tt?|S|q|Q|WW?W?W?)(?![^\[]*\]))/g, parseFormatStrings).replace(/\[|\]/g, "") : this._toString(); }; }()); /************************************************************* * SugarPak - Domain Specific Language - Syntactical Sugar * *************************************************************/ (function () { var $D = Date, $P = $D.prototype, $N = Number.prototype; // private $P._orient = +1; // private $P._nth = null; // private $P._is = false; // private $P._same = false; // private $P._isSecond = false; // private $N._dateElement = "days"; /** * Moves the date to the next instance of a date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.today().next().friday();
	Date.today().next().fri();
	Date.today().next().march();
	Date.today().next().mar();
	Date.today().next().week();
	
* * @return {Date} date */ $P.next = function () { this._move = true; this._orient = +1; return this; }; /** * Creates a new Date (Date.today()) and moves the date to the next instance of the date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.next().friday();
	Date.next().fri();
	Date.next().march();
	Date.next().mar();
	Date.next().week();
	
* * @return {Date} date */ $D.next = function () { return $D.today().next(); }; /** * Moves the date to the previous instance of a date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.today().last().friday();
	Date.today().last().fri();
	Date.today().last().march();
	Date.today().last().mar();
	Date.today().last().week();
	
* * @return {Date} date */ $P.last = $P.prev = $P.previous = function () { this._move = true; this._orient = -1; return this; }; /** * Creates a new Date (Date.today()) and moves the date to the previous instance of the date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.last().friday();
	Date.last().fri();
	Date.previous().march();
	Date.prev().mar();
	Date.last().week();
	
* * @return {Date} date */ $D.last = $D.prev = $D.previous = function () { return $D.today().last(); }; /** * Performs a equality check when followed by either a month name, day name or .weekday() function. * Example

	Date.today().is().friday(); // true|false
	Date.today().is().fri();
	Date.today().is().march();
	Date.today().is().mar();
	
* * @return {Boolean} true|false */ $P.is = function () { this._is = true; return this; }; /** * Determines if two date objects occur on/in exactly the same instance of the subsequent date part function. * The function .same() must be followed by a date part function (example: .day(), .month(), .year(), etc). * * An optional Date can be passed in the date part function. If now date is passed as a parameter, 'Now' is used. * * The following example demonstrates how to determine if two dates fall on the exact same day. * * Example

	var d1 = Date.today(); // today at 00:00
	var d2 = new Date();   // exactly now.

	// Do they occur on the same day?
	d1.same().day(d2); // true
	
	// Do they occur on the same hour?
	d1.same().hour(d2); // false, unless d2 hour is '00' (midnight).
	
	// What if it's the same day, but one year apart?
	var nextYear = Date.today().add(1).year();

	d1.same().day(nextYear); // false, because the dates must occur on the exact same day. 
	
* * Scenario: Determine if a given date occurs during some week period 2 months from now. * * Example

	var future = Date.today().add(2).months();
	return someDate.same().week(future); // true|false;
	
* * @return {Boolean} true|false */ $P.same = function () { this._same = true; this._isSecond = false; return this; }; /** * Determines if the current date/time occurs during Today. Must be preceded by the .is() function. * Example

	someDate.is().today();    // true|false
	new Date().is().today();  // true
	Date.today().is().today();// true
	Date.today().add(-1).day().is().today(); // false
	
* * @return {Boolean} true|false */ $P.today = function () { return this.same().day(); }; /** * Determines if the current date is a weekday. This function must be preceded by the .is() function. * Example

	Date.today().is().weekday(); // true|false
	
* * @return {Boolean} true|false */ $P.weekday = function () { if (this._nth) { return df("Weekday").call(this); } if (this._move) { return this.addWeekdays(this._orient); } if (this._is) { this._is = false; return (!this.is().sat() && !this.is().sun()); } return false; }; /** * Determines if the current date is on the weekend. This function must be preceded by the .is() function. * Example

	Date.today().is().weekend(); // true|false
	
* * @return {Boolean} true|false */ $P.weekend = function () { if (this._is) { this._is = false; return (this.is().sat() || this.is().sun()); } return false; }; /** * Sets the Time of the current Date instance. A string "6:15 pm" or config object {hour:18, minute:15} are accepted. * Example

	// Set time to 6:15pm with a String
	Date.today().at("6:15pm");

	// Set time to 6:15pm with a config object
	Date.today().at({hour:18, minute:15});
	
* * @return {Date} date */ $P.at = function (time) { return (typeof time === "string") ? $D.parse(this.toString("d") + " " + time) : this.set(time); }; /** * Creates a new Date() and adds this (Number) to the date based on the preceding date element function (eg. second|minute|hour|day|month|year). * Example

	// Undeclared Numbers must be wrapped with parentheses. Requirment of JavaScript.
	(3).days().fromNow();
	(6).months().fromNow();

	// Declared Number variables do not require parentheses. 
	var n = 6;
	n.months().fromNow();
	
* * @return {Date} A new Date instance */ $N.fromNow = $N.after = function (date) { var c = {}; c[this._dateElement] = this; return ((!date) ? new Date() : date.clone()).add(c); }; /** * Creates a new Date() and subtract this (Number) from the date based on the preceding date element function (eg. second|minute|hour|day|month|year). * Example

	// Undeclared Numbers must be wrapped with parentheses. Requirment of JavaScript.
	(3).days().ago();
	(6).months().ago();

	// Declared Number variables do not require parentheses. 
	var n = 6;
	n.months().ago();
	
* * @return {Date} A new Date instance */ $N.ago = $N.before = function (date) { var c = {}, s = (this._dateElement[this._dateElement.length-1] !== "s") ? this._dateElement + "s" : this._dateElement; c[s] = this * -1; return ((!date) ? new Date() : date.clone()).add(c); }; // Do NOT modify the following string tokens. These tokens are used to build dynamic functions. // All culture-specific strings can be found in the CultureInfo files. var dx = ("sunday monday tuesday wednesday thursday friday saturday").split(/\s/), mx = ("january february march april may june july august september october november december").split(/\s/), px = ("Millisecond Second Minute Hour Day Week Month Year Quarter Weekday").split(/\s/), pxf = ("Milliseconds Seconds Minutes Hours Date Week Month FullYear Quarter").split(/\s/), nth = ("final first second third fourth fifth").split(/\s/), de; /** * Returns an object literal of all the date parts. * Example

	var o = new Date().toObject();
	
	// { year: 2008, month: 4, week: 20, day: 13, hour: 18, minute: 9, second: 32, millisecond: 812 }
	
	// The object properties can be referenced directly from the object.
	
	alert(o.day);  // alerts "13"
	alert(o.year); // alerts "2008"
	
* * @return {Date} An object literal representing the original date object. */ $P.toObject = function () { var o = {}; for (var i = 0; i < px.length; i++) { if (this["get" + pxf[i]]) { o[px[i].toLowerCase()] = this["get" + pxf[i]](); } } return o; }; /** * Returns a date created from an object literal. Ignores the .week property if set in the config. * Example

	var o = new Date().toObject();
	
	return Date.fromObject(o); // will return the same date. 

	var o2 = {month: 1, day: 20, hour: 18}; // birthday party!
	Date.fromObject(o2);
	
* * @return {Date} An object literal representing the original date object. */ $D.fromObject = function(config) { config.week = null; return Date.today().set(config); }; // Create day name functions and abbreviated day name functions (eg. monday(), friday(), fri()). var df = function (n) { return function () { if (this._is) { this._is = false; return this.getDay() === n; } if (this._move) { this._move = null; } if (this._nth !== null) { // If the .second() function was called earlier, remove the _orient // from the date, and then continue. // This is required because 'second' can be used in two different context. // // Example // // Date.today().add(1).second(); // Date.march().second().monday(); // // Things get crazy with the following... // Date.march().add(1).second().second().monday(); // but it works!! // if (this._isSecond) { this.addSeconds(this._orient * -1); } // make sure we reset _isSecond this._isSecond = false; var ntemp = this._nth; this._nth = null; var temp = this.clone().moveToLastDayOfMonth(); this.moveToNthOccurrence(n, ntemp); if (this > temp) { throw new RangeError($D.getDayName(n) + " does not occur " + ntemp + " times in the month of " + $D.getMonthName(temp.getMonth()) + " " + temp.getFullYear() + "."); } return this; } return this.moveToDayOfWeek(n, this._orient); }; }; var sdf = function (n) { return function () { var t = $D.today(), shift = n - t.getDay(); if (n === 0 && Date.CultureInfo.firstDayOfWeek === 1 && t.getDay() !== 0) { shift = shift + 7; } return t.addDays(shift); }; }; // Create month name functions and abbreviated month name functions (eg. january(), march(), mar()). var month_instance_functions = function (n) { return function () { if (this._is) { this._is = false; return this.getMonth() === n; } return this.moveToMonth(n, this._orient); }; }; var month_static_functions = function (n) { return function () { return $D.today().set({ month: n, day: 1 }); }; }; var processTerms = function (names, staticFunc, instanceFunc) { for (var i = 0; i < names.length; i++) { // Create constant static Name variables. $D[names[i].toUpperCase()] = $D[names[i].toUpperCase().substring(0, 3)] = i; // Create Name functions. $D[names[i]] = $D[names[i].substring(0, 3)] = staticFunc(i); // Create Name instance functions. $P[names[i]] = $P[names[i].substring(0, 3)] = instanceFunc(i); } }; processTerms(dx, sdf, df); processTerms(mx, month_static_functions, month_instance_functions); // Create date element functions and plural date element functions used with Date (eg. day(), days(), months()). var ef = function (j) { return function () { // if the .second() function was called earlier, the _orient // has alread been added. Just return this and reset _isSecond. if (this._isSecond) { this._isSecond = false; return this; } if (this._same) { this._same = this._is = false; var o1 = this.toObject(), o2 = (arguments[0] || new Date()).toObject(), v = "", k = j.toLowerCase(); // the substr trick with -1 doesn't work in IE8 or less k = (k[k.length-1] === "s") ? k.substring(0,k.length-1) : k; for (var m = (px.length - 1); m > -1; m--) { v = px[m].toLowerCase(); if (o1[v] !== o2[v]) { return false; } if (k === v) { break; } } return true; } if (j.substring(j.length - 1) !== "s") { j += "s"; } if (this._move) { this._move = null; } return this["add" + j](this._orient); }; }; var nf = function (n) { return function () { this._dateElement = n; return this; }; }; for (var k = 0; k < px.length; k++) { de = px[k].toLowerCase(); if(de !== "weekday") { // Create date element functions and plural date element functions used with Date (eg. day(), days(), months()). $P[de] = $P[de + "s"] = ef(px[k]); // Create date element functions and plural date element functions used with Number (eg. day(), days(), months()). $N[de] = $N[de + "s"] = nf(de + "s"); } } $P._ss = ef("Second"); var nthfn = function (n) { return function (dayOfWeek) { if (this._same) { return this._ss(arguments[0]); } if (dayOfWeek || dayOfWeek === 0) { return this.moveToNthOccurrence(dayOfWeek, n); } this._nth = n; // if the operator is 'second' add the _orient, then deal with it later... if (n === 2 && (dayOfWeek === undefined || dayOfWeek === null)) { this._isSecond = true; return this.addSeconds(this._orient); } return this; }; }; for (var l = 0; l < nth.length; l++) { $P[nth[l]] = (l === 0) ? nthfn(-1) : nthfn(l); } }()); (function () { "use strict"; Date.Parsing = { Exception: function (s) { this.message = "Parse error at '" + s.substring(0, 10) + " ...'"; } }; var $P = Date.Parsing; var dayOffsets = { standard: [0,31,59,90,120,151,181,212,243,273,304,334], leap: [0,31,60,91,121,152,182,213,244,274,305,335] }; $P.isLeapYear = function(year) { return ((year % 4 === 0) && (year % 100 !== 0)) || (year % 400 === 0); }; var utils = { multiReplace : function (str, hash ) { var key; for (key in hash) { if (Object.prototype.hasOwnProperty.call(hash, key)) { var regex; if (typeof hash[key] === "function") { } else { regex = (hash[key] instanceof RegExp) ? hash[key] : new RegExp(hash[key], "g"); } str = str.replace(regex, key); } } return str; }, getDayOfYearFromWeek : function (obj) { var d, jan4, offset; obj.weekDay = (!obj.weekDay && obj.weekDay !== 0) ? 1 : obj.weekDay; d = new Date(obj.year, 0, 4); jan4 = d.getDay() === 0 ? 7 : d.getDay(); // JS is 0 indexed on Sunday. offset = jan4+3; obj.dayOfYear = ((obj.week * 7) + (obj.weekDay === 0 ? 7 : obj.weekDay))-offset; return obj; }, getDayOfYear : function (obj, dayOffset) { if (!obj.dayOfYear) { obj = utils.getDayOfYearFromWeek(obj); } for (var i=0;i <= dayOffset.length;i++) { if (obj.dayOfYear < dayOffset[i] || i === dayOffset.length) { obj.day = obj.day ? obj.day : (obj.dayOfYear - dayOffset[i-1]); break; } else { obj.month = i; } } return obj; }, adjustForTimeZone : function (obj, date) { var offset; if (obj.zone.toUpperCase() === "Z" || (obj.zone_hours === 0 && obj.zone_minutes === 0)) { // it's UTC/GML so work out the current timeszone offset offset = -date.getTimezoneOffset(); } else { offset = (obj.zone_hours*60) + (obj.zone_minutes || 0); if (obj.zone_sign === "+") { offset *= -1; } offset -= date.getTimezoneOffset(); } date.setMinutes(date.getMinutes()+offset); return date; }, setDefaults : function (obj) { obj.year = obj.year || Date.today().getFullYear(); obj.hours = obj.hours || 0; obj.minutes = obj.minutes || 0; obj.seconds = obj.seconds || 0; obj.milliseconds = obj.milliseconds || 0; if (!(!obj.month && (obj.week || obj.dayOfYear))) { // if we have a month, or if we don't but don't have the day calculation data obj.month = obj.month || 0; obj.day = obj.day || 1; } return obj; }, dataNum: function (data, mod, explict, postProcess) { var dataNum = data*1; if (mod) { if (postProcess) { return data ? mod(data)*1 : data; } else { return data ? mod(dataNum) : data; } } else if (!explict){ return data ? dataNum : data; } else { return (data && typeof data !== "undefined") ? dataNum : data; } }, timeDataProcess: function (obj) { var timeObj = {}; for (var x in obj.data) { if (obj.data.hasOwnProperty(x)) { timeObj[x] = obj.ignore[x] ? obj.data[x] : utils.dataNum(obj.data[x], obj.mods[x], obj.explict[x], obj.postProcess[x]); } } if (obj.data.secmins) { obj.data.secmins = obj.data.secmins.replace(",", ".") * 60; if (!timeObj.minutes) { timeObj.minutes = obj.data.secmins; } else if (!timeObj.seconds) { timeObj.seconds = obj.data.secmins; } delete obj.secmins; } return timeObj; }, buildTimeObjectFromData: function (data) { var time = utils.timeDataProcess({ data: { year : data[1], month : data[5], day : data[7], week : data[8], dayOfYear : data[10], hours : data[15], zone_hours : data[23], zone_minutes : data[24], zone : data[21], zone_sign : data[22], weekDay : data[9], minutes: data[16], seconds: data[19], milliseconds: data[20], secmins: data[18] }, mods: { month: function(data) { return data-1; }, weekDay: function (data) { data = Math.abs(data); return (data === 7 ? 0 : data); }, minutes: function (data) { return data.replace(":",""); }, seconds: function (data) { return Math.floor( (data.replace(":","").replace(",","."))*1 ); }, milliseconds: function (data) { return (data.replace(",",".")*1000); } }, postProcess: { minutes: true, seconds: true, milliseconds: true }, explict: { zone_hours: true, zone_minutes: true }, ignore: { zone: true, zone_sign: true, secmins: true } }); return time; }, addToHash: function (hash, keys, data) { keys = keys; data = data; var len = keys.length; for (var i = 0; i < len; i++) { hash[keys[i]] = data[i]; } return hash; }, combineRegex: function (r1, r2) { return new RegExp("(("+r1.source+")\\s("+r2.source+"))"); }, getDateNthString: function(add, last, inc){ if (add) { return Date.today().addDays(inc).toString("d"); } else if (last) { return Date.today().last()[inc]().toString("d"); } }, buildRegexData: function (array) { var arr = []; var len = array.length; for (var i=0; i < len; i++) { if (Object.prototype.toString.call(array[i]) === '[object Array]') { // oldIE compat version of Array.isArray arr.push(this.combineRegex(array[i][0], array[i][1])); } else { arr.push(array[i]); } } return arr; } }; $P.processTimeObject = function (obj) { var date, dayOffset; utils.setDefaults(obj); dayOffset = ($P.isLeapYear(obj.year)) ? dayOffsets.leap : dayOffsets.standard; if (!obj.month && (obj.week || obj.dayOfYear)) { utils.getDayOfYear(obj, dayOffset); } else { obj.dayOfYear = dayOffset[obj.month] + obj.day; } date = new Date(obj.year, obj.month, obj.day, obj.hours, obj.minutes, obj.seconds, obj.milliseconds); if (obj.zone) { utils.adjustForTimeZone(obj, date); // adjust (and calculate) for timezone } return date; }; $P.ISO = { regex : /^([\+-]?\d{4}(?!\d{2}\b))((-?)((0[1-9]|1[0-2])(\3([12]\d|0[1-9]|3[01]))?|W([0-4]\d|5[0-3])(-?[1-7])?|(00[1-9]|0[1-9]\d|[12]\d{2}|3([0-5]\d|6[1-6])))([T\s]((([01]\d|2[0-4])((:?)[0-5]\d)?|24\:?00)([\.,]\d+(?!:))?)?(\17[0-5]\d([\.,]\d+)?)?\s?([zZ]|([\+-])([01]\d|2[0-3]):?([0-5]\d)?)?)?)?$/, parse : function (s) { var time, data = s.match(this.regex); if (!data || !data.length) { return null; } time = utils.buildTimeObjectFromData(data); if (!time.year || (!time.year && (!time.month && !time.day) && (!time.week && !time.dayOfYear)) ) { return null; } return $P.processTimeObject(time); } }; $P.Numeric = { isNumeric: function (e){return!isNaN(parseFloat(e))&&isFinite(e);}, regex: /\b([0-1]?[0-9])([0-3]?[0-9])([0-2]?[0-9]?[0-9][0-9])\b/i, parse: function (s) { var data, i, time = {}, order = Date.CultureInfo.dateElementOrder.split(""); if (!(this.isNumeric(s)) || // if it's non-numeric OR (s[0] === "+" && s[0] === "-")) { // It's an arithmatic string (eg +/-1000) return null; } if (s.length < 5 && s.indexOf(".") < 0 && s.indexOf("/") < 0) { // assume it's just a year. time.year = s; return $P.processTimeObject(time); } data = s.match(this.regex); if (!data || !data.length) { return null; } for (i=0; i < order.length; i++) { switch(order[i]) { case "d": time.day = data[i+1]; break; case "m": time.month = (data[i+1]-1); break; case "y": time.year = data[i+1]; break; } } return $P.processTimeObject(time); } }; $P.Normalizer = { regexData: function () { var $R = Date.CultureInfo.regexPatterns; return utils.buildRegexData([ $R.tomorrow, $R.yesterday, [$R.past, $R.mon], [$R.past, $R.tue], [$R.past, $R.wed], [$R.past, $R.thu], [$R.past, $R.fri], [$R.past, $R.sat], [$R.past, $R.sun] ]); }, basicReplaceHash : function() { var $R = Date.CultureInfo.regexPatterns; return { "January": $R.jan.source, "February": $R.feb, "March": $R.mar, "April": $R.apr, "May": $R.may, "June": $R.jun, "July": $R.jul, "August": $R.aug, "September": $R.sep, "October": $R.oct, "November": $R.nov, "December": $R.dec, "": /\bat\b/gi, " ": /\s{2,}/, "am": $R.inTheMorning, "9am": $R.thisMorning, "pm": $R.inTheEvening, "7pm":$R.thisEvening }; }, keys : function(){ return [ utils.getDateNthString(true, false, 1), // tomorrow utils.getDateNthString(true, false, -1), // yesterday utils.getDateNthString(false, true, "monday"), //last mon utils.getDateNthString(false, true, "tuesday"), //last tues utils.getDateNthString(false, true, "wednesday"), //last wed utils.getDateNthString(false, true, "thursday"), //last thurs utils.getDateNthString(false, true, "friday"), //last fri utils.getDateNthString(false, true, "saturday"), //last sat utils.getDateNthString(false, true, "sunday") //last sun ]; }, buildRegexFunctions: function () { var $R = Date.CultureInfo.regexPatterns; var __ = Date.i18n.__; var tomorrowRE = new RegExp("(\\b\\d\\d?("+__("AM")+"|"+__("PM")+")? )("+$R.tomorrow.source.slice(1)+")", "i"); // adapted tomorrow regex for AM PM relative dates var todayRE = new RegExp($R.today.source + "(?!\\s*([+-]))\\b"); // today, but excludes the math operators (eg "today + 2h") this.replaceFuncs = [ [todayRE, function (full) { return (full.length > 1) ? Date.today().toString("d") : full; }], [tomorrowRE, function(full, m1) { var t = Date.today().addDays(1).toString("d"); return (t + " " + m1); }], [$R.amThisMorning, function(str, am){return am;}], [$R.pmThisEvening, function(str, pm){return pm;}] ]; }, buildReplaceData: function () { this.buildRegexFunctions(); this.replaceHash = utils.addToHash(this.basicReplaceHash(), this.keys(), this.regexData()); }, stringReplaceFuncs: function (s) { for (var i=0; i < this.replaceFuncs.length; i++) { s = s.replace(this.replaceFuncs[i][0], this.replaceFuncs[i][1]); } return s; }, parse: function (s) { s = this.stringReplaceFuncs(s); s = utils.multiReplace(s, this.replaceHash); try { var n = s.split(/([\s\-\.\,\/\x27]+)/); if (n.length === 3 && $P.Numeric.isNumeric(n[0]) && $P.Numeric.isNumeric(n[2]) && (n[2].length >= 4)) { // ok, so we're dealing with x/year. But that's not a full date. // This fixes wonky dateElementOrder parsing when set to dmy order. if (Date.CultureInfo.dateElementOrder[0] === "d") { s = "1/" + n[0] + "/" + n[2]; // set to 1st of month and normalize the seperator } } } catch (e) {} return s; } }; $P.Normalizer.buildReplaceData(); }()); (function () { var $P = Date.Parsing; var _ = $P.Operators = { // // Tokenizers // rtoken: function (r) { // regex token return function (s) { var mx = s.match(r); if (mx) { return ([ mx[0], s.substring(mx[0].length) ]); } else { throw new $P.Exception(s); } }; }, token: function () { // whitespace-eating token return function (s) { return _.rtoken(new RegExp("^\\s*" + s + "\\s*"))(s); }; }, stoken: function (s) { // string token return _.rtoken(new RegExp("^" + s)); }, // Atomic Operators until: function (p) { return function (s) { var qx = [], rx = null; while (s.length) { try { rx = p.call(this, s); } catch (e) { qx.push(rx[0]); s = rx[1]; continue; } break; } return [ qx, s ]; }; }, many: function (p) { return function (s) { var rx = [], r = null; while (s.length) { try { r = p.call(this, s); } catch (e) { return [ rx, s ]; } rx.push(r[0]); s = r[1]; } return [ rx, s ]; }; }, // generator operators -- see below optional: function (p) { return function (s) { var r = null; try { r = p.call(this, s); } catch (e) { return [ null, s ]; } return [ r[0], r[1] ]; }; }, not: function (p) { return function (s) { try { p.call(this, s); } catch (e) { return [null, s]; } throw new $P.Exception(s); }; }, ignore: function (p) { return p ? function (s) { var r = null; r = p.call(this, s); return [null, r[1]]; } : null; }, product: function () { var px = arguments[0], qx = Array.prototype.slice.call(arguments, 1), rx = []; for (var i = 0 ; i < px.length ; i++) { rx.push(_.each(px[i], qx)); } return rx; }, cache: function (rule) { var cache = {}, cache_length = 0, cache_keys = [], CACHE_MAX = Date.Config.CACHE_MAX || 100000, r = null; var cacheCheck = function () { if (cache_length === CACHE_MAX) { // kill several keys, don't want to have to do this all the time... for (var i=0; i < 10; i++) { var key = cache_keys.shift(); if (key) { delete cache[key]; cache_length--; } } } }; return function (s) { cacheCheck(); try { r = cache[s] = (cache[s] || rule.call(this, s)); } catch (e) { r = cache[s] = e; } cache_length++; cache_keys.push(s); if (r instanceof $P.Exception) { throw r; } else { return r; } }; }, // vector operators -- see below any: function () { var px = arguments; return function (s) { var r = null; for (var i = 0; i < px.length; i++) { if (px[i] == null) { continue; } try { r = (px[i].call(this, s)); } catch (e) { r = null; } if (r) { return r; } } throw new $P.Exception(s); }; }, each: function () { var px = arguments; return function (s) { var rx = [], r = null; for (var i = 0; i < px.length ; i++) { if (px[i] == null) { continue; } try { r = (px[i].call(this, s)); } catch (e) { throw new $P.Exception(s); } rx.push(r[0]); s = r[1]; } return [ rx, s]; }; }, all: function () { var px = arguments, _ = _; return _.each(_.optional(px)); }, // delimited operators sequence: function (px, d, c) { d = d || _.rtoken(/^\s*/); c = c || null; if (px.length === 1) { return px[0]; } return function (s) { var r = null, q = null; var rx = []; for (var i = 0; i < px.length ; i++) { try { r = px[i].call(this, s); } catch (e) { break; } rx.push(r[0]); try { q = d.call(this, r[1]); } catch (ex) { q = null; break; } s = q[1]; } if (!r) { throw new $P.Exception(s); } if (q) { throw new $P.Exception(q[1]); } if (c) { try { r = c.call(this, r[1]); } catch (ey) { throw new $P.Exception(r[1]); } } return [ rx, (r?r[1]:s) ]; }; }, // // Composite Operators // between: function (d1, p, d2) { d2 = d2 || d1; var _fn = _.each(_.ignore(d1), p, _.ignore(d2)); return function (s) { var rx = _fn.call(this, s); return [[rx[0][0], r[0][2]], rx[1]]; }; }, list: function (p, d, c) { d = d || _.rtoken(/^\s*/); c = c || null; return (p instanceof Array ? _.each(_.product(p.slice(0, -1), _.ignore(d)), p.slice(-1), _.ignore(c)) : _.each(_.many(_.each(p, _.ignore(d))), px, _.ignore(c))); }, set: function (px, d, c) { d = d || _.rtoken(/^\s*/); c = c || null; return function (s) { // r is the current match, best the current 'best' match // which means it parsed the most amount of input var r = null, p = null, q = null, rx = null, best = [[], s], last = false; // go through the rules in the given set for (var i = 0; i < px.length ; i++) { // last is a flag indicating whether this must be the last element // if there is only 1 element, then it MUST be the last one q = null; p = null; r = null; last = (px.length === 1); // first, we try simply to match the current pattern // if not, try the next pattern try { r = px[i].call(this, s); } catch (e) { continue; } // since we are matching against a set of elements, the first // thing to do is to add r[0] to matched elements rx = [[r[0]], r[1]]; // if we matched and there is still input to parse and // we don't already know this is the last element, // we're going to next check for the delimiter ... // if there's none, or if there's no input left to parse // than this must be the last element after all ... if (r[1].length > 0 && ! last) { try { q = d.call(this, r[1]); } catch (ex) { last = true; } } else { last = true; } // if we parsed the delimiter and now there's no more input, // that means we shouldn't have parsed the delimiter at all // so don't update r and mark this as the last element ... if (!last && q[1].length === 0) { last = true; } // so, if this isn't the last element, we're going to see if // we can get any more matches from the remaining (unmatched) // elements ... if (!last) { // build a list of the remaining rules we can match against, // i.e., all but the one we just matched against var qx = []; for (var j = 0; j < px.length ; j++) { if (i !== j) { qx.push(px[j]); } } // now invoke recursively set with the remaining input // note that we don't include the closing delimiter ... // we'll check for that ourselves at the end p = _.set(qx, d).call(this, q[1]); // if we got a non-empty set as a result ... // (otw rx already contains everything we want to match) if (p[0].length > 0) { // update current result, which is stored in rx ... // basically, pick up the remaining text from p[1] // and concat the result from p[0] so that we don't // get endless nesting ... rx[0] = rx[0].concat(p[0]); rx[1] = p[1]; } } // at this point, rx either contains the last matched element // or the entire matched set that starts with this element. // now we just check to see if this variation is better than // our best so far, in terms of how much of the input is parsed if (rx[1].length < best[1].length) { best = rx; } // if we've parsed all the input, then we're finished if (best[1].length === 0) { break; } } // so now we've either gone through all the patterns trying them // as the initial match; or we found one that parsed the entire // input string ... // if best has no matches, just return empty set ... if (best[0].length === 0) { return best; } // if a closing delimiter is provided, then we have to check it also if (c) { // we try this even if there is no remaining input because the pattern // may well be optional or match empty input ... try { q = c.call(this, best[1]); } catch (ey) { throw new $P.Exception(best[1]); } // it parsed ... be sure to update the best match remaining input best[1] = q[1]; } // if we're here, either there was no closing delimiter or we parsed it // so now we have the best match; just return it! return best; }; }, forward: function (gr, fname) { return function (s) { return gr[fname].call(this, s); }; }, // // Translation Operators // replace: function (rule, repl) { return function (s) { var r = rule.call(this, s); return [repl, r[1]]; }; }, process: function (rule, fn) { return function (s) { var r = rule.call(this, s); return [fn.call(this, r[0]), r[1]]; }; }, min: function (min, rule) { return function (s) { var rx = rule.call(this, s); if (rx[0].length < min) { throw new $P.Exception(s); } return rx; }; } }; // Generator Operators And Vector Operators // Generators are operators that have a signature of F(R) => R, // taking a given rule and returning another rule, such as // ignore, which parses a given rule and throws away the result. // Vector operators are those that have a signature of F(R1,R2,...) => R, // take a list of rules and returning a new rule, such as each. // Generator operators are converted (via the following _generator // function) into functions that can also take a list or array of rules // and return an array of new rules as though the function had been // called on each rule in turn (which is what actually happens). // This allows generators to be used with vector operators more easily. // Example: // each(ignore(foo, bar)) instead of each(ignore(foo), ignore(bar)) // This also turns generators into vector operators, which allows // constructs like: // not(cache(foo, bar)) var _generator = function (op) { function gen() { var args = null, rx = [], px, i; if (arguments.length > 1) { args = Array.prototype.slice.call(arguments); } else if (arguments[0] instanceof Array) { args = arguments[0]; } if (args) { px = args.shift(); if (px.length > 0) { args.unshift(px[i]); rx.push(op.apply(null, args)); args.shift(); return rx; } } else { return op.apply(null, arguments); } } return gen; }; var gx = "optional not ignore cache".split(/\s/); for (var i = 0 ; i < gx.length ; i++) { _[gx[i]] = _generator(_[gx[i]]); } var _vector = function (op) { return function () { if (arguments[0] instanceof Array) { return op.apply(null, arguments[0]); } else { return op.apply(null, arguments); } }; }; var vx = "each any all".split(/\s/); for (var j = 0 ; j < vx.length ; j++) { _[vx[j]] = _vector(_[vx[j]]); } }()); (function () { var $D = Date; var flattenAndCompact = function (ax) { var rx = []; for (var i = 0; i < ax.length; i++) { if (ax[i] instanceof Array) { rx = rx.concat(flattenAndCompact(ax[i])); } else { if (ax[i]) { rx.push(ax[i]); } } } return rx; }; var parseMeridian = function () { if (this.meridian && (this.hour || this.hour === 0)) { if (this.meridian === "a" && this.hour > 11 && Date.Config.strict24hr){ throw "Invalid hour and meridian combination"; } else if (this.meridian === "p" && this.hour < 12 && Date.Config.strict24hr){ throw "Invalid hour and meridian combination"; } else if (this.meridian === "p" && this.hour < 12) { this.hour = this.hour + 12; } else if (this.meridian === "a" && this.hour === 12) { this.hour = 0; } } }; var setDefaults = function () { var now = new Date(); if ((this.hour || this.minute) && (!this.month && !this.year && !this.day)) { this.day = now.getDate(); } if (!this.year) { this.year = now.getFullYear(); } if (!this.month && this.month !== 0) { this.month = now.getMonth(); } if (!this.day) { this.day = 1; } if (!this.hour) { this.hour = 0; } if (!this.minute) { this.minute = 0; } if (!this.second) { this.second = 0; } if (!this.millisecond) { this.millisecond = 0; } }; var finishUtils = { getToday: function () { if (this.now || "hour minute second".indexOf(this.unit) !== -1) { return new Date(); } else { return $D.today(); } }, setDaysFromWeekday: function (today, orient){ var gap; orient = orient || 1; this.unit = "day"; gap = ($D.getDayNumberFromName(this.weekday) - today.getDay()); this.days = gap ? ((gap + (orient * 7)) % 7) : (orient * 7); return this; }, setMonthsFromMonth: function (today, orient) { var gap; orient = orient || 1; this.unit = "month"; gap = (this.month - today.getMonth()); this.months = gap ? ((gap + (orient * 12)) % 12) : (orient * 12); this.month = null; return this; }, setDMYFromWeekday: function () { var d = Date[this.weekday](); this.day = d.getDate(); if (!this.month) { this.month = d.getMonth(); } this.year = d.getFullYear(); return this; }, setUnitValue: function (orient) { if (!this.value && this.operator && this.operator !== null && this[this.unit + "s"] && this[this.unit + "s"] !== null) { this[this.unit + "s"] = this[this.unit + "s"] + ((this.operator === "add") ? 1 : -1) + (this.value||0) * orient; } else if (this[this.unit + "s"] == null || this.operator != null) { if (!this.value) { this.value = 1; } this[this.unit + "s"] = this.value * orient; } }, generateDateFromWeeks: function () { var weekday = (this.weekday !== undefined) ? this.weekday : "today"; var d = Date[weekday]().addWeeks(this.weeks); if (this.now) { d.setTimeToNow(); } return d; } }; $D.Translator = { hour: function (s) { return function () { this.hour = Number(s); }; }, minute: function (s) { return function () { this.minute = Number(s); }; }, second: function (s) { return function () { this.second = Number(s); }; }, /* for ss.s format */ secondAndMillisecond: function (s) { return function () { var mx = s.match(/^([0-5][0-9])\.([0-9]{1,3})/); this.second = Number(mx[1]); this.millisecond = Number(mx[2]); }; }, meridian: function (s) { return function () { this.meridian = s.slice(0, 1).toLowerCase(); }; }, timezone: function (s) { return function () { var n = s.replace(/[^\d\+\-]/g, ""); if (n.length) { this.timezoneOffset = Number(n); } else { this.timezone = s.toLowerCase(); } }; }, day: function (x) { var s = x[0]; return function () { this.day = Number(s.match(/\d+/)[0]); if (this.day < 1) { throw "invalid day"; } }; }, month: function (s) { return function () { this.month = (s.length === 3) ? "jan feb mar apr may jun jul aug sep oct nov dec".indexOf(s)/4 : Number(s) - 1; if (this.month < 0) { throw "invalid month"; } }; }, year: function (s) { return function () { var n = Number(s); this.year = ((s.length > 2) ? n : (n + (((n + 2000) < Date.CultureInfo.twoDigitYearMax) ? 2000 : 1900))); }; }, rday: function (s) { return function () { switch (s) { case "yesterday": this.days = -1; break; case "tomorrow": this.days = 1; break; case "today": this.days = 0; break; case "now": this.days = 0; this.now = true; break; } }; }, finishExact: function (x) { var d; x = (x instanceof Array) ? x : [x]; for (var i = 0 ; i < x.length ; i++) { if (x[i]) { x[i].call(this); } } setDefaults.call(this); parseMeridian.call(this); if (this.day > $D.getDaysInMonth(this.year, this.month)) { throw new RangeError(this.day + " is not a valid value for days."); } d = new Date(this.year, this.month, this.day, this.hour, this.minute, this.second, this.millisecond); if (this.year < 100) { d.setFullYear(this.year); // means years less that 100 are process correctly. JS will parse it otherwise as 1900-1999. } if (this.timezone) { d.set({ timezone: this.timezone }); } else if (this.timezoneOffset) { d.set({ timezoneOffset: this.timezoneOffset }); } return d; }, finish: function (x) { var today, expression, orient, temp; x = (x instanceof Array) ? flattenAndCompact(x) : [ x ]; if (x.length === 0) { return null; } for (var i = 0 ; i < x.length ; i++) { if (typeof x[i] === "function") { x[i].call(this); } } if (this.now && !this.unit && !this.operator) { return new Date(); } else { today = finishUtils.getToday.call(this); } expression = !!(this.days && this.days !== null || this.orient || this.operator); orient = ((this.orient === "past" || this.operator === "subtract") ? -1 : 1); if (this.month && this.unit === "week") { this.value = this.month + 1; delete this.month; delete this.day; } if ((this.month || this.month === 0) && "year day hour minute second".indexOf(this.unit) !== -1) { if (!this.value) { this.value = this.month + 1; } this.month = null; expression = true; } if (!expression && this.weekday && !this.day && !this.days) { finishUtils.setDMYFromWeekday.call(this); } if (expression && this.weekday && this.unit !== "month" && this.unit !== "week") { finishUtils.setDaysFromWeekday.call(this, today, orient); } if (this.weekday && this.unit !== "week" && !this.day && !this.days) { temp = Date[this.weekday](); this.day = temp.getDate(); if (temp.getMonth() !== today.getMonth()) { this.month = temp.getMonth(); } } if (this.month && this.unit === "day" && this.operator) { if (!this.value) { this.value = (this.month + 1); } this.month = null; } if (this.value != null && this.month != null && this.year != null) { this.day = this.value * 1; } if (this.month && !this.day && this.value) { today.set({ day: this.value * 1 }); if (!expression) { this.day = this.value * 1; } } if (!this.month && this.value && this.unit === "month" && !this.now) { this.month = this.value; expression = true; } if (expression && (this.month || this.month === 0) && this.unit !== "year") { finishUtils.setMonthsFromMonth.call(this, today, orient); } if (!this.unit) { this.unit = "day"; } finishUtils.setUnitValue.call(this, orient); parseMeridian.call(this); if ((this.month || this.month === 0) && !this.day) { this.day = 1; } if (!this.orient && !this.operator && this.unit === "week" && this.value && !this.day && !this.month) { return Date.today().setWeek(this.value); } if (this.unit === "week" && this.weeks && !this.day && !this.month) { return finishUtils.generateDateFromWeeks.call(this); } if (expression && this.timezone && this.day && this.days) { this.day = this.days; } if (expression){ today.add(this); } else { today.set(this); } if (this.timezone) { this.timezone = this.timezone.toUpperCase(); var offset = $D.getTimezoneOffset(this.timezone); var timezone; if (today.hasDaylightSavingTime()) { // lets check that we're being sane with timezone setting timezone = $D.getTimezoneAbbreviation(offset, today.isDaylightSavingTime()); if (timezone !== this.timezone) { // bugger, we're in a place where things like EST vs EDT matters. if (today.isDaylightSavingTime()) { today.addHours(-1); } else { today.addHours(1); } } } today.setTimezoneOffset(offset); } return today; } }; }()); (function () { var $D = Date; $D.Grammar = {}; var _ = $D.Parsing.Operators, g = $D.Grammar, t = $D.Translator, _fn; // Allow rolling up into general purpose rules _fn = function () { return _.each(_.any.apply(null, arguments), _.not(g.ctoken2("timeContext"))); }; g.datePartDelimiter = _.rtoken(/^([\s\-\.\,\/\x27]+)/); g.timePartDelimiter = _.stoken(":"); g.whiteSpace = _.rtoken(/^\s*/); g.generalDelimiter = _.rtoken(/^(([\s\,]|at|@|on)+)/); var _C = {}; g.ctoken = function (keys) { var fn = _C[keys]; if (! fn) { var c = Date.CultureInfo.regexPatterns; var kx = keys.split(/\s+/), px = []; for (var i = 0; i < kx.length ; i++) { px.push(_.replace(_.rtoken(c[kx[i]]), kx[i])); } fn = _C[keys] = _.any.apply(null, px); } return fn; }; g.ctoken2 = function (key) { return _.rtoken(Date.CultureInfo.regexPatterns[key]); }; var cacheProcessRtoken = function (key, token, type, eachToken) { if (eachToken) { g[key] = _.cache(_.process(_.each(_.rtoken(token),_.optional(g.ctoken2(eachToken))), type)); } else { g[key] = _.cache(_.process(_.rtoken(token), type)); } }; var cacheProcessCtoken = function (token, type) { return _.cache(_.process(g.ctoken2(token), type)); }; var _F = {}; //function cache var _get = function (f) { _F[f] = (_F[f] || g.format(f)[0]); return _F[f]; }; g.allformats = function (fx) { var rx = []; if (fx instanceof Array) { for (var i = 0; i < fx.length; i++) { rx.push(_get(fx[i])); } } else { rx.push(_get(fx)); } return rx; }; g.formats = function (fx) { if (fx instanceof Array) { var rx = []; for (var i = 0 ; i < fx.length ; i++) { rx.push(_get(fx[i])); } return _.any.apply(null, rx); } else { return _get(fx); } }; var grammarFormats = { timeFormats: function(){ var i, RTokenKeys = [ "h", "hh", "H", "HH", "m", "mm", "s", "ss", "ss.s", "z", "zz" ], RToken = [ /^(0[0-9]|1[0-2]|[1-9])/, /^(0[0-9]|1[0-2])/, /^([0-1][0-9]|2[0-3]|[0-9])/, /^([0-1][0-9]|2[0-3])/, /^([0-5][0-9]|[0-9])/, /^[0-5][0-9]/, /^([0-5][0-9]|[0-9])/, /^[0-5][0-9]/, /^[0-5][0-9]\.[0-9]{1,3}/, /^((\+|\-)\s*\d\d\d\d)|((\+|\-)\d\d\:?\d\d)/, /^((\+|\-)\s*\d\d\d\d)|((\+|\-)\d\d\:?\d\d)/ ], tokens = [ t.hour, t.hour, t.hour, t.hour, t.minute, t.minute, t.second, t.second, t.secondAndMillisecond, t.timezone, t.timezone ]; for (i=0; i < RTokenKeys.length; i++) { cacheProcessRtoken(RTokenKeys[i], RToken[i], tokens[i]); } g.hms = _.cache(_.sequence([g.H, g.m, g.s], g.timePartDelimiter)); g.t = cacheProcessCtoken("shortMeridian", t.meridian); g.tt = cacheProcessCtoken("longMeridian", t.meridian); g.zzz = cacheProcessCtoken("timezone", t.timezone); g.timeSuffix = _.each(_.ignore(g.whiteSpace), _.set([ g.tt, g.zzz ])); g.time = _.each(_.optional(_.ignore(_.stoken("T"))), g.hms, g.timeSuffix); }, dateFormats: function () { // pre-loaded rules for different date part order preferences var _setfn = function () { return _.set(arguments, g.datePartDelimiter); }; var i, RTokenKeys = [ "d", "dd", "M", "MM", "y", "yy", "yyy", "yyyy" ], RToken = [ /^([0-2]\d|3[0-1]|\d)/, /^([0-2]\d|3[0-1])/, /^(1[0-2]|0\d|\d)/, /^(1[0-2]|0\d)/, /^(\d+)/, /^(\d\d)/, /^(\d\d?\d?\d?)/, /^(\d\d\d\d)/ ], tokens = [ t.day, t.day, t.month, t.month, t.year, t.year, t.year, t.year ], eachToken = [ "ordinalSuffix", "ordinalSuffix" ]; for (i=0; i < RTokenKeys.length; i++) { cacheProcessRtoken(RTokenKeys[i], RToken[i], tokens[i], eachToken[i]); } g.MMM = g.MMMM = _.cache(_.process(g.ctoken("jan feb mar apr may jun jul aug sep oct nov dec"), t.month)); g.ddd = g.dddd = _.cache(_.process(g.ctoken("sun mon tue wed thu fri sat"), function (s) { return function () { this.weekday = s; }; } )); g.day = _fn(g.d, g.dd); g.month = _fn(g.M, g.MMM); g.year = _fn(g.yyyy, g.yy); g.mdy = _setfn(g.ddd, g.month, g.day, g.year); g.ymd = _setfn(g.ddd, g.year, g.month, g.day); g.dmy = _setfn(g.ddd, g.day, g.month, g.year); g.date = function (s) { return ((g[Date.CultureInfo.dateElementOrder] || g.mdy).call(this, s)); }; }, relative: function () { // relative date / time expressions g.orientation = _.process(g.ctoken("past future"), function (s) { return function () { this.orient = s; }; } ); g.operator = _.process(g.ctoken("add subtract"), function (s) { return function () { this.operator = s; }; } ); g.rday = _.process(g.ctoken("yesterday tomorrow today now"), t.rday); g.unit = _.process(g.ctoken("second minute hour day week month year"), function (s) { return function () { this.unit = s; }; } ); } }; g.buildGrammarFormats = function () { // these need to be rebuilt every time the language changes. _C = {}; grammarFormats.timeFormats(); grammarFormats.dateFormats(); grammarFormats.relative(); g.value = _.process(_.rtoken(/^([-+]?\d+)?(st|nd|rd|th)?/), function (s) { return function () { this.value = s.replace(/\D/g, ""); }; } ); g.expression = _.set([g.rday, g.operator, g.value, g.unit, g.orientation, g.ddd, g.MMM ]); g.format = _.process(_.many( _.any( // translate format specifiers into grammar rules _.process( _.rtoken(/^(dd?d?d?(?!e)|MM?M?M?|yy?y?y?|hh?|HH?|mm?|ss?|tt?|zz?z?)/), function (fmt) { if (g[fmt]) { return g[fmt]; } else { throw $D.Parsing.Exception(fmt); } } ), // translate separator tokens into token rules _.process(_.rtoken(/^[^dMyhHmstz]+/), // all legal separators function (s) { return _.ignore(_.stoken(s)); } ) ) ), // construct the parser ... function (rules) { return _.process(_.each.apply(null, rules), t.finishExact); } ); // starting rule for general purpose grammar g._start = _.process(_.set([ g.date, g.time, g.expression ], g.generalDelimiter, g.whiteSpace), t.finish); }; g.buildGrammarFormats(); // parsing date format specifiers - ex: "h:m:s tt" // this little guy will generate a custom parser based // on the format string, ex: g.format("h:m:s tt") // check for these formats first g._formats = g.formats([ "\"yyyy-MM-ddTHH:mm:ssZ\"", "yyyy-MM-ddTHH:mm:ss.sz", "yyyy-MM-ddTHH:mm:ssZ", "yyyy-MM-ddTHH:mm:ssz", "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-ddTHH:mmZ", "yyyy-MM-ddTHH:mmz", "yyyy-MM-ddTHH:mm", "ddd, MMM dd, yyyy H:mm:ss tt", "ddd MMM d yyyy HH:mm:ss zzz", "MMddyyyy", "ddMMyyyy", "Mddyyyy", "ddMyyyy", "Mdyyyy", "dMyyyy", "yyyy", "Mdyy", "dMyy", "d" ]); // real starting rule: tries selected formats first, // then general purpose rule g.start = function (s) { try { var r = g._formats.call({}, s); if (r[1].length === 0) { return r; } } catch (e) {} return g._start.call({}, s); }; }()); (function () { var $D = Date; /** * @desc Converts the specified string value into its JavaScript Date equivalent using CultureInfo specific format information. * * Example

	///////////
	// Dates //
	///////////

	// 15-Oct-2004
	var d1 = Date.parse("10/15/2004");

	// 15-Oct-2004
	var d1 = Date.parse("15-Oct-2004");

	// 15-Oct-2004
	var d1 = Date.parse("2004.10.15");

	//Fri Oct 15, 2004
	var d1 = Date.parse("Fri Oct 15, 2004");

	///////////
	// Times //
	///////////

	// Today at 10 PM.
	var d1 = Date.parse("10 PM");

	// Today at 10:30 PM.
	var d1 = Date.parse("10:30 P.M.");

	// Today at 6 AM.
	var d1 = Date.parse("06am");

	/////////////////////
	// Dates and Times //
	/////////////////////

	// 8-July-2004 @ 10:30 PM
	var d1 = Date.parse("July 8th, 2004, 10:30 PM");

	// 1-July-2004 @ 10:30 PM
	var d1 = Date.parse("2004-07-01T22:30:00");

	////////////////////
	// Relative Dates //
	////////////////////

	// Returns today's date. The string "today" is culture specific.
	var d1 = Date.parse("today");

	// Returns yesterday's date. The string "yesterday" is culture specific.
	var d1 = Date.parse("yesterday");

	// Returns the date of the next thursday.
	var d1 = Date.parse("Next thursday");

	// Returns the date of the most previous monday.
	var d1 = Date.parse("last monday");

	// Returns today's day + one year.
	var d1 = Date.parse("next year");

	///////////////
	// Date Math //
	///////////////

	// Today + 2 days
	var d1 = Date.parse("t+2");

	// Today + 2 days
	var d1 = Date.parse("today + 2 days");

	// Today + 3 months
	var d1 = Date.parse("t+3m");

	// Today - 1 year
	var d1 = Date.parse("today - 1 year");

	// Today - 1 year
	var d1 = Date.parse("t-1y"); 


	/////////////////////////////
	// Partial Dates and Times //
	/////////////////////////////

	// July 15th of this year.
	var d1 = Date.parse("July 15");

	// 15th day of current day and year.
	var d1 = Date.parse("15");

	// July 1st of current year at 10pm.
	var d1 = Date.parse("7/1 10pm");
	
* * @param {String} The string value to convert into a Date object [Required] * @return {Date} A Date object or null if the string cannot be converted into a Date. */ var parseUtils = { removeOrds: function (s) { ords = s.match(/\b(\d+)(?:st|nd|rd|th)\b/); // find ordinal matches s = ((ords && ords.length === 2) ? s.replace(ords[0], ords[1]) : s); return s; }, grammarParser: function (s) { var r = null; try { r = $D.Grammar.start.call({}, s.replace(/^\s*(\S*(\s+\S+)*)\s*$/, "$1")); } catch (e) { return null; } return ((r[1].length === 0) ? r[0] : null); }, nativeFallback: function(s) { var t; try { // ok we haven't parsed it, last ditch attempt with the built-in parser. t = Date._parse(s); return (t || t === 0) ? new Date(t) : null; } catch (e) { return null; } } }; function parse (s) { var d; if (!s) { return null; } if (s instanceof Date) { return s.clone(); } if (s.length >= 4 && s.charAt(0) !== "0" && s.charAt(0) !== "+"&& s.charAt(0) !== "-") { // ie: 2004 will pass, 0800 won't. // Start with specific formats d = $D.Parsing.ISO.parse(s) || $D.Parsing.Numeric.parse(s); } if (d instanceof Date && !isNaN(d.getTime())) { return d; } else { // find ordinal dates (1st, 3rd, 8th, etc and remove them as they cause parsing issues) s = $D.Parsing.Normalizer.parse(parseUtils.removeOrds(s)); d = parseUtils.grammarParser(s); if (d !== null) { return d; } else { return parseUtils.nativeFallback(s); } } } if (!$D._parse) { $D._parse = $D.parse; } $D.parse = parse; Date.getParseFunction = function (fx) { var fns = Date.Grammar.allformats(fx); return function (s) { var r = null; for (var i = 0; i < fns.length; i++) { try { r = fns[i].call({}, s); } catch (e) { continue; } if (r[1].length === 0) { return r[0]; } } return null; }; }; /** * Converts the specified string value into its JavaScript Date equivalent using the specified format {String} or formats {Array} and the CultureInfo specific format information. * The format of the string value must match one of the supplied formats exactly. * * Example

	// 15-Oct-2004
	var d1 = Date.parseExact("10/15/2004", "M/d/yyyy");

	// 15-Oct-2004
	var d1 = Date.parse("15-Oct-2004", "M-ddd-yyyy");

	// 15-Oct-2004
	var d1 = Date.parse("2004.10.15", "yyyy.MM.dd");

	// Multiple formats
	var d1 = Date.parseExact("10/15/2004", ["M/d/yyyy", "MMMM d, yyyy"]);
	
* * @param {String} The string value to convert into a Date object [Required]. * @param {Object} The expected format {String} or an array of expected formats {Array} of the date string [Required]. * @return {Date} A Date object or null if the string cannot be converted into a Date. */ $D.parseExact = function (s, fx) { return $D.getParseFunction(fx)(s); }; }()); (function () { var $D = Date, $P = $D.prototype, // $C = $D.CultureInfo, // not used atm p = function (s, l) { if (!l) { l = 2; } return ("000" + s).slice(l * -1); }; /** * Converts a PHP format string to Java/.NET format string. * A PHP format string can be used with ._format or .format. * A Java/.NET format string can be used with .toString(). * The .parseExact function will only accept a Java/.NET format string * * Example * var f1 = "%m/%d/%y" * var f2 = Date.normalizeFormat(f1); // "MM/dd/yy" * * new Date().format(f1); // "04/13/08" * new Date()._format(f1); // "04/13/08" * new Date().toString(f2); // "04/13/08" * * var date = Date.parseExact("04/13/08", f2); // Sun Apr 13 2008 * * @param {String} A PHP format string consisting of one or more format spcifiers. * @return {String} The PHP format converted to a Java/.NET format string. */ var normalizerSubstitutions = { "d" : "dd", "%d": "dd", "D" : "ddd", "%a": "ddd", "j" : "dddd", "l" : "dddd", "%A": "dddd", "S" : "S", "F" : "MMMM", "%B": "MMMM", "m" : "MM", "%m": "MM", "M" : "MMM", "%b": "MMM", "%h": "MMM", "n" : "M", "Y" : "yyyy", "%Y": "yyyy", "y" : "yy", "%y": "yy", "g" : "h", "%I": "h", "G" : "H", "h" : "hh", "H" : "HH", "%H": "HH", "i" : "mm", "%M": "mm", "s" : "ss", "%S": "ss", "%r": "hh:mm tt", "%R": "H:mm", "%T": "H:mm:ss", "%X": "t", "%x": "d", "%e": "d", "%D": "MM/dd/yy", "%n": "\\n", "%t": "\\t", "e" : "z", "T" : "z", "%z": "z", "%Z": "z", "Z" : "ZZ", "N" : "u", "w" : "u", "%w": "u", "W" : "W", "%V": "W" }; var normalizer = { substitutes: function (m) { return normalizerSubstitutions[m]; }, interpreted: function (m, x) { var y; switch (m) { case "%u": return x.getDay() + 1; case "z": return x.getOrdinalNumber(); case "%j": return p(x.getOrdinalNumber(), 3); case "%U": var d1 = x.clone().set({month: 0, day: 1}).addDays(-1).moveToDayOfWeek(0), d2 = x.clone().addDays(1).moveToDayOfWeek(0, -1); return (d2 < d1) ? "00" : p((d2.getOrdinalNumber() - d1.getOrdinalNumber()) / 7 + 1); case "%W": return p(x.getWeek()); case "t": return $D.getDaysInMonth(x.getFullYear(), x.getMonth()); case "o": case "%G": return x.setWeek(x.getISOWeek()).toString("yyyy"); case "%g": return x._format("%G").slice(-2); case "a": case "%p": return t("tt").toLowerCase(); case "A": return t("tt").toUpperCase(); case "u": return p(x.getMilliseconds(), 3); case "I": return (x.isDaylightSavingTime()) ? 1 : 0; case "O": return x.getUTCOffset(); case "P": y = x.getUTCOffset(); return y.substring(0, y.length - 2) + ":" + y.substring(y.length - 2); case "B": var now = new Date(); return Math.floor(((now.getHours() * 3600) + (now.getMinutes() * 60) + now.getSeconds() + (now.getTimezoneOffset() + 60) * 60) / 86.4); case "c": return x.toISOString().replace(/\"/g, ""); case "U": return $D.strtotime("now"); case "%c": return t("d") + " " + t("t"); case "%C": return Math.floor(x.getFullYear() / 100 + 1); } }, shouldOverrideDefaults: function (m) { switch (m) { case "%e": return true; default: return false; } }, parse: function (m, context) { var formatString, c = context || new Date(); formatString = normalizer.substitutes(m); if (formatString) { return formatString; } formatString = normalizer.interpreted(m, c); if (formatString) { return formatString; } else { return m; } } }; $D.normalizeFormat = function (format, context) { return format.replace(/(%|\\)?.|%%/g, function(t){ return normalizer.parse(t, context); }); }; /** * Format a local Unix timestamp according to locale settings * * Example: * Date.strftime("%m/%d/%y", new Date()); // "04/13/08" * Date.strftime("c", "2008-04-13T17:52:03Z"); // "04/13/08" * * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @param {Number|String} The number representing the number of seconds that have elapsed since January 1, 1970 (local time). * @return {String} A string representation of the current Date object. */ $D.strftime = function (format, time) { var d = Date.parse(time); return d._format(format); }; /** * Parse any textual datetime description into a Unix timestamp. * A Unix timestamp is the number of seconds that have elapsed since January 1, 1970 (midnight UTC/GMT). * * Example: * Date.strtotime("04/13/08"); // 1208044800 * Date.strtotime("1970-01-01T00:00:00Z"); // 0 * * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @param {Object} A string or date object. * @return {String} A string representation of the current Date object. */ $D.strtotime = function (time) { var d = $D.parse(time); return Math.round($D.UTC(d.getUTCFullYear(), d.getUTCMonth(), d.getUTCDate(), d.getUTCHours(), d.getUTCMinutes(), d.getUTCSeconds(), d.getUTCMilliseconds()) / 1000); }; /** * Converts the value of the current Date object to its equivalent string representation using a PHP/Unix style of date format specifiers. * Format Specifiers * Format Description Example * ------ --------------------------------------------------------------------------- ----------------------- * %a abbreviated weekday name according to the current localed "Mon" through "Sun" * %A full weekday name according to the current localed "Sunday" through "Saturday" * %b abbreviated month name according to the current localed "Jan" through "Dec" * %B full month name according to the current locale "January" through "December" * %c preferred date and time representation for the current locale "4/13/2008 12:33 PM" * %C century number (the year divided by 100 and truncated to an integer) "00" to "99" * %d day of the month as a decimal number "01" to "31" * %D same as %m/%d/%y "04/13/08" * %e day of the month as a decimal number, a single digit is preceded by a space "1" to "31" * %g like %G, but without the century "08" * %G The 4-digit year corresponding to the ISO week number (see %V). "2008" * This has the same format and value as %Y, except that if the ISO week number * belongs to the previous or next year, that year is used instead. * %h same as %b "Jan" through "Dec" * %H hour as a decimal number using a 24-hour clock. "00" to "23" * %I hour as a decimal number using a 12-hour clock. "01" to "12" * %j day of the year as a decimal number. "001" to "366" * %m month as a decimal number. "01" to "12" * %M minute as a decimal number. "00" to "59" * %n newline character "\n" * %p either "am" or "pm" according to the given time value, or the "am" or "pm" * corresponding strings for the current locale. * %r time in a.m. and p.m. notation "8:44 PM" * %R time in 24 hour notation "20:44" * %S second as a decimal number "00" to "59" * %t tab character "\t" * %T current time, equal to %H:%M:%S "12:49:11" * %u weekday as a decimal number ["1", "7"], with "1" representing Monday "1" to "7" * %U week number of the current year as a decimal number, starting with the "0" to ("52" or "53") * first Sunday as the first day of the first week * %V The ISO 8601:1988 week number of the current year as a decimal number, "00" to ("52" or "53") * range 01 to 53, where week 1 is the first week that has at least 4 days * in the current year, and with Monday as the first day of the week. * (Use %G or %g for the year component that corresponds to the week number * for the specified timestamp.) * %W week number of the current year as a decimal number, starting with the "00" to ("52" or "53") * first Monday as the first day of the first week * %w day of the week as a decimal, Sunday being "0" "0" to "6" * %x preferred date representation for the current locale without the time "4/13/2008" * %X preferred time representation for the current locale without the date "12:53:05" * %y year as a decimal number without a century "00" "99" * %Y year as a decimal number including the century "2008" * %Z time zone or name or abbreviation "UTC", "EST", "PST" * %z same as %Z * %% a literal "%" characters "%" * d Day of the month, 2 digits with leading zeros "01" to "31" * D A textual representation of a day, three letters "Mon" through "Sun" * j Day of the month without leading zeros "1" to "31" * l A full textual representation of the day of the week (lowercase "L") "Sunday" through "Saturday" * N ISO-8601 numeric representation of the day of the week (added in PHP 5.1.0) "1" (for Monday) through "7" (for Sunday) * S English ordinal suffix for the day of the month, 2 characters "st", "nd", "rd" or "th". Works well with j * w Numeric representation of the day of the week "0" (for Sunday) through "6" (for Saturday) * z The day of the year (starting from "0") "0" through "365" * W ISO-8601 week number of year, weeks starting on Monday "00" to ("52" or "53") * F A full textual representation of a month, such as January or March "January" through "December" * m Numeric representation of a month, with leading zeros "01" through "12" * M A short textual representation of a month, three letters "Jan" through "Dec" * n Numeric representation of a month, without leading zeros "1" through "12" * t Number of days in the given month "28" through "31" * L Whether it's a leap year "1" if it is a leap year, "0" otherwise * o ISO-8601 year number. This has the same value as Y, except that if the "2008" * ISO week number (W) belongs to the previous or next year, that year * is used instead. * Y A full numeric representation of a year, 4 digits "2008" * y A two digit representation of a year "08" * a Lowercase Ante meridiem and Post meridiem "am" or "pm" * A Uppercase Ante meridiem and Post meridiem "AM" or "PM" * B Swatch Internet time "000" through "999" * g 12-hour format of an hour without leading zeros "1" through "12" * G 24-hour format of an hour without leading zeros "0" through "23" * h 12-hour format of an hour with leading zeros "01" through "12" * H 24-hour format of an hour with leading zeros "00" through "23" * i Minutes with leading zeros "00" to "59" * s Seconds, with leading zeros "00" through "59" * u Milliseconds "54321" * e Timezone identifier "UTC", "EST", "PST" * I Whether or not the date is in daylight saving time (uppercase i) "1" if Daylight Saving Time, "0" otherwise * O Difference to Greenwich time (GMT) in hours "+0200", "-0600" * P Difference to Greenwich time (GMT) with colon between hours and minutes "+02:00", "-06:00" * T Timezone abbreviation "UTC", "EST", "PST" * Z Timezone offset in seconds. The offset for timezones west of UTC is "-43200" through "50400" * always negative, and for those east of UTC is always positive. * c ISO 8601 date "2004-02-12T15:19:21+00:00" * r RFC 2822 formatted date "Thu, 21 Dec 2000 16:01:07 +0200" * U Seconds since the Unix Epoch (January 1 1970 00:00:00 GMT) "0" * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @return {String} A string representation of the current Date object. */ var formatReplace = function (context) { return function (m) { var formatString, override = false; if (m.charAt(0) === "\\" || m.substring(0, 2) === "%%") { return m.replace("\\", "").replace("%%", "%"); } override = normalizer.shouldOverrideDefaults(m); formatString = $D.normalizeFormat(m, context); if (formatString) { return context.toString(formatString, override); } }; }; $P._format = function (format) { var formatter = formatReplace(this); if (!format) { return this._toString(); } else { return format.replace(/(%|\\)?.|%%/g, formatter); } }; if (!$P.format) { $P.format = $P._format; } }()); (function () { "use strict"; var gFn = function (attr) { return function () { return this[attr]; }; }; var sFn = function (attr) { return function (val) { this[attr] = val; return this; }; }; var attrs = ["years", "months", "days", "hours", "minutes", "seconds", "milliseconds"]; var addSetFuncs = function (context, attrs) { for (var i = 0; i < attrs.length ; i++) { var $a = attrs[i], $b = $a.slice(0, 1).toUpperCase() + $a.slice(1); context.prototype[$a] = 0; context.prototype["get" + $b] = gFn($a); context.prototype["set" + $b] = sFn($a); } }; /** * new TimeSpan(milliseconds); * new TimeSpan(days, hours, minutes, seconds); * new TimeSpan(days, hours, minutes, seconds, milliseconds); */ var TimeSpan = function (days, hours, minutes, seconds, milliseconds) { if (arguments.length === 1 && typeof days === "number") { var orient = (days < 0) ? -1 : +1; var millsLeft = Math.abs(days); this.setDays(Math.floor(millsLeft / 86400000) * orient); millsLeft = millsLeft % 86400000; this.setHours(Math.floor(millsLeft / 3600000) * orient); millsLeft = millsLeft % 3600000; this.setMinutes(Math.floor(millsLeft / 60000) * orient); millsLeft = millsLeft % 60000; this.setSeconds(Math.floor(millsLeft / 1000) * orient); millsLeft = millsLeft % 1000; this.setMilliseconds(millsLeft * orient); } else { this.set(days, hours, minutes, seconds, milliseconds); } this.getTotalMilliseconds = function () { return (this.getDays() * 86400000) + (this.getHours() * 3600000) + (this.getMinutes() * 60000) + (this.getSeconds() * 1000); }; this.compareTo = function (time) { var t1 = new Date(1970, 1, 1, this.getHours(), this.getMinutes(), this.getSeconds()), t2; if (time === null) { t2 = new Date(1970, 1, 1, 0, 0, 0); } else { t2 = new Date(1970, 1, 1, time.getHours(), time.getMinutes(), time.getSeconds()); } return (t1 < t2) ? -1 : (t1 > t2) ? 1 : 0; }; this.equals = function (time) { return (this.compareTo(time) === 0); }; this.add = function (time) { return (time === null) ? this : this.addSeconds(time.getTotalMilliseconds() / 1000); }; this.subtract = function (time) { return (time === null) ? this : this.addSeconds(-time.getTotalMilliseconds() / 1000); }; this.addDays = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 86400000)); }; this.addHours = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 3600000)); }; this.addMinutes = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 60000)); }; this.addSeconds = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 1000)); }; this.addMilliseconds = function (n) { return new TimeSpan(this.getTotalMilliseconds() + n); }; this.get12HourHour = function () { return (this.getHours() > 12) ? this.getHours() - 12 : (this.getHours() === 0) ? 12 : this.getHours(); }; this.getDesignator = function () { return (this.getHours() < 12) ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator; }; this.toString = function (format) { this._toString = function () { if (this.getDays() !== null && this.getDays() > 0) { return this.getDays() + "." + this.getHours() + ":" + this.p(this.getMinutes()) + ":" + this.p(this.getSeconds()); } else { return this.getHours() + ":" + this.p(this.getMinutes()) + ":" + this.p(this.getSeconds()); } }; this.p = function (s) { return (s.toString().length < 2) ? "0" + s : s; }; var me = this; return format ? format.replace(/dd?|HH?|hh?|mm?|ss?|tt?/g, function (format) { switch (format) { case "d": return me.getDays(); case "dd": return me.p(me.getDays()); case "H": return me.getHours(); case "HH": return me.p(me.getHours()); case "h": return me.get12HourHour(); case "hh": return me.p(me.get12HourHour()); case "m": return me.getMinutes(); case "mm": return me.p(me.getMinutes()); case "s": return me.getSeconds(); case "ss": return me.p(me.getSeconds()); case "t": return ((me.getHours() < 12) ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator).substring(0, 1); case "tt": return (me.getHours() < 12) ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator; } } ) : this._toString(); }; return this; }; addSetFuncs(TimeSpan, attrs.slice(2)); TimeSpan.prototype.set = function (days, hours, minutes, seconds, milliseconds){ this.setDays(days || this.getDays()); this.setHours(hours || this.getHours()); this.setMinutes(minutes || this.getMinutes()); this.setSeconds(seconds || this.getSeconds()); this.setMilliseconds(milliseconds || this.getMilliseconds()); }; /** * Gets the time of day for this date instances. * @return {TimeSpan} TimeSpan */ Date.prototype.getTimeOfDay = function () { return new TimeSpan(0, this.getHours(), this.getMinutes(), this.getSeconds(), this.getMilliseconds()); }; Date.TimeSpan = TimeSpan; if (typeof window !== "undefined" ) { // keeping API compatible for v1.x window.TimeSpan = TimeSpan; } }()); (function () { "use strict"; var attrs = ["years", "months", "days", "hours", "minutes", "seconds", "milliseconds"]; var gFn = function (attr) { return function () { return this[attr]; }; }; var sFn = function (attr) { return function (val) { this[attr] = val; return this; }; }; var addSetFuncs = function (context, attrs) { for (var i = 0; i < attrs.length ; i++) { var $a = attrs[i], $b = $a.slice(0, 1).toUpperCase() + $a.slice(1); context.prototype[$a] = 0; context.prototype["get" + $b] = gFn($a); context.prototype["set" + $b] = sFn($a); } }; var setMonthsAndYears = function (orient, d1, d2, context) { function inc() { d1.addMonths(-orient); context.months++; if (context.months === 12) { context.years++; context.months = 0; } } if (orient === +1) { while (d1 > d2) { inc(); } } else { while (d1 < d2) { inc(); } } context.months--; context.months *= orient; context.years *= orient; }; var adjustForDST = function(orient, startDate, endDate) { var hasDSTMismatch = (false === (startDate.isDaylightSavingTime() === endDate.isDaylightSavingTime())); if (hasDSTMismatch && orient === 1) { startDate.addHours(-1); } else if (hasDSTMismatch) { startDate.addHours(1); } }; /** * TimePeriod(startDate, endDate); * TimePeriod(years, months, days, hours, minutes, seconds, milliseconds); */ var TimePeriod = function (years, months, days, hours, minutes, seconds, milliseconds) { if (arguments.length === 7) { this.set(years, months, days, hours, minutes, seconds, milliseconds); } else if (arguments.length === 2 && arguments[0] instanceof Date && arguments[1] instanceof Date) { var startDate = arguments[0].clone(); var endDate = arguments[1].clone(); var orient = (startDate > endDate) ? +1 : -1; this.dates = { start: arguments[0].clone(), end: arguments[1].clone() }; setMonthsAndYears(orient, startDate, endDate, this); adjustForDST(orient, startDate, endDate); // // TODO - adjust for DST var diff = endDate - startDate; if (diff !== 0) { var ts = new TimeSpan(diff); this.set(this.years, this.months, ts.getDays(), ts.getHours(), ts.getMinutes(), ts.getSeconds(), ts.getMilliseconds()); } } return this; }; // create all the set functions. addSetFuncs(TimePeriod, attrs); TimePeriod.prototype.set = function (years, months, days, hours, minutes, seconds, milliseconds){ this.setYears(years || this.getYears()); this.setMonths(months || this.getMonths()); this.setDays(days || this.getDays()); this.setHours(hours || this.getHours()); this.setMinutes(minutes || this.getMinutes()); this.setSeconds(seconds || this.getSeconds()); this.setMilliseconds(milliseconds || this.getMilliseconds()); }; Date.TimePeriod = TimePeriod; if (typeof window !== "undefined") { // keeping API compatible for v1.x window.TimePeriod = TimePeriod; } }()); ================================================ FILE: build/date-smj-SE.js ================================================ /** * @overview datejs * @version 1.0.0-rc3 * @author Gregory Wild-Smith * @copyright 2015 Gregory Wild-Smith * @license MIT * @homepage https://github.com/abritinthebay/datejs */ /* * DateJS Culture String File * Country Code: smj-SE * Name: Sami (Lule) (Sweden) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["smj-SE"] = { "name": "smj-SE", "englishName": "Sami (Lule) (Sweden)", "nativeName": "julevusámegiella (Svierik)", "Sunday": "ájllek", "Monday": "mánnodahka", "Tuesday": "dijstahka", "Wednesday": "gasskavahkko", "Thursday": "duorastahka", "Friday": "bierjjedahka", "Saturday": "lávvodahka", "Sun": "ájl", "Mon": "mán", "Tue": "dis", "Wed": "gas", "Thu": "duor", "Fri": "bier", "Sat": "láv", "Su": "ájl", "Mo": "mán", "Tu": "dis", "We": "gas", "Th": "duor", "Fr": "bier", "Sa": "láv", "S_Sun_Initial": "á", "M_Mon_Initial": "m", "T_Tue_Initial": "d", "W_Wed_Initial": "g", "T_Thu_Initial": "d", "F_Fri_Initial": "b", "S_Sat_Initial": "l", "January": "ådåjakmánno", "February": "guovvamánno", "March": "sjnjuktjamánno", "April": "vuoratjismánno", "May": "moarmesmánno", "June": "biehtsemánno", "July": "sjnjilltjamánno", "August": "bårggemánno", "September": "ragátmánno", "October": "gålgådismánno", "November": "basádismánno", "December": "javllamánno", "Jan_Abbr": "ådåj", "Feb_Abbr": "guov", "Mar_Abbr": "snju", "Apr_Abbr": "vuor", "May_Abbr": "moar", "Jun_Abbr": "bieh", "Jul_Abbr": "snji", "Aug_Abbr": "bårg", "Sep_Abbr": "ragá", "Oct_Abbr": "gålg", "Nov_Abbr": "basá", "Dec_Abbr": "javl", "AM": "", "PM": "", "firstDayOfWeek": 1, "twoDigitYearMax": 2029, "mdy": "ymd", "M/d/yyyy": "yyyy-MM-dd", "dddd, MMMM dd, yyyy": "MMMM d'. b. 'yyyy", "h:mm tt": "HH:mm:ss", "h:mm:ss tt": "HH:mm:ss", "dddd, MMMM dd, yyyy h:mm:ss tt": "MMMM d'. b. 'yyyy HH:mm:ss", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "MMMM dd", "MMMM, yyyy": "MMMM yyyy", "/jan(uary)?/": "ådåj(akmánno)?", "/feb(ruary)?/": "guov(vamánno)?", "/mar(ch)?/": "sjnjuktjamánno", "/apr(il)?/": "vuor(atjismánno)?", "/may/": "moar(mesmánno)?", "/jun(e)?/": "bieh(tsemánno)?", "/jul(y)?/": "sjnjilltjamánno", "/aug(ust)?/": "bårg(gemánno)?", "/sep(t(ember)?)?/": "ragá(tmánno)?", "/oct(ober)?/": "gålg(ådismánno)?", "/nov(ember)?/": "basá(dismánno)?", "/dec(ember)?/": "javl(lamánno)?", "/^su(n(day)?)?/": "^ájllek", "/^mo(n(day)?)?/": "^mánnodahka", "/^tu(e(s(day)?)?)?/": "^dijstahka", "/^we(d(nesday)?)?/": "^gasskavahkko", "/^th(u(r(s(day)?)?)?)?/": "^duorastahka", "/^fr(i(day)?)?/": "^bierjjedahka", "/^sa(t(urday)?)?/": "^lávvodahka", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "smj-SE"; /** * @overview datejs * @version 1.0.0-rc3 * @author Gregory Wild-Smith * @copyright 2015 Gregory Wild-Smith * @license MIT * @homepage https://github.com/abritinthebay/datejs */(function () { var $D = Date; var lang = Date.CultureStrings ? Date.CultureStrings.lang : null; var loggedKeys = {}; // for debug purposes. var getText = { getFromKey: function (key, countryCode) { var output; if (Date.CultureStrings && Date.CultureStrings[countryCode] && Date.CultureStrings[countryCode][key]) { output = Date.CultureStrings[countryCode][key]; } else { output = getText.buildFromDefault(key); } if (key.charAt(0) === "/") { // Assume it's a regex output = getText.buildFromRegex(key, countryCode); } return output; }, getFromObjectValues: function (obj, countryCode) { var key, output = {}; for(key in obj) { if (obj.hasOwnProperty(key)) { output[key] = getText.getFromKey(obj[key], countryCode); } } return output; }, getFromObjectKeys: function (obj, countryCode) { var key, output = {}; for(key in obj) { if (obj.hasOwnProperty(key)) { output[getText.getFromKey(key, countryCode)] = obj[key]; } } return output; }, getFromArray: function (arr, countryCode) { var output = []; for (var i=0; i < arr.length; i++){ if (i in arr) { output[i] = getText.getFromKey(arr[i], countryCode); } } return output; }, buildFromDefault: function (key) { var output, length, split, last; switch(key) { case "name": output = "en-US"; break; case "englishName": output = "English (United States)"; break; case "nativeName": output = "English (United States)"; break; case "twoDigitYearMax": output = 2049; break; case "firstDayOfWeek": output = 0; break; default: output = key; split = key.split("_"); length = split.length; if (length > 1 && key.charAt(0) !== "/") { // if the key isn't a regex and it has a split. last = split[(length - 1)].toLowerCase(); if (last === "initial" || last === "abbr") { output = split[0]; } } break; } return output; }, buildFromRegex: function (key, countryCode) { var output; if (Date.CultureStrings && Date.CultureStrings[countryCode] && Date.CultureStrings[countryCode][key]) { output = new RegExp(Date.CultureStrings[countryCode][key], "i"); } else { output = new RegExp(key.replace(new RegExp("/", "g"),""), "i"); } return output; } }; var shallowMerge = function (obj1, obj2) { for (var attrname in obj2) { if (obj2.hasOwnProperty(attrname)) { obj1[attrname] = obj2[attrname]; } } }; var __ = function (key, language) { var countryCode = (language) ? language : lang; loggedKeys[key] = key; if (typeof key === "object") { if (key instanceof Array) { return getText.getFromArray(key, countryCode); } else { return getText.getFromObjectKeys(key, countryCode); } } else { return getText.getFromKey(key, countryCode); } }; var loadI18nScript = function (code) { // paatterned after jQuery's getScript. var url = Date.Config.i18n + code + ".js"; var head = document.getElementsByTagName("head")[0] || document.documentElement; var script = document.createElement("script"); script.src = url; var completed = false; var events = { done: function (){} // placeholder function }; // Attach handlers for all browsers script.onload = script.onreadystatechange = function() { if ( !completed && (!this.readyState || this.readyState === "loaded" || this.readyState === "complete") ) { events.done(); head.removeChild(script); } }; setTimeout(function() { head.insertBefore(script, head.firstChild); }, 0); // allows return to execute first return { done: function (cb) { events.done = function() { if (cb) { setTimeout(cb,0); } }; } }; }; var buildInfo = { buildFromMethodHash: function (obj) { var key; for(key in obj) { if (obj.hasOwnProperty(key)) { obj[key] = buildInfo[obj[key]](); } } return obj; }, timeZoneDST: function () { var DST = { "CHADT": "+1345", "NZDT": "+1300", "AEDT": "+1100", "ACDT": "+1030", "AZST": "+0500", "IRDT": "+0430", "EEST": "+0300", "CEST": "+0200", "BST": "+0100", "PMDT": "-0200", "ADT": "-0300", "NDT": "-0230", "EDT": "-0400", "CDT": "-0500", "MDT": "-0600", "PDT": "-0700", "AKDT": "-0800", "HADT": "-0900" }; return __(DST); }, timeZoneStandard: function () { var standard = { "LINT": "+1400", "TOT": "+1300", "CHAST": "+1245", "NZST": "+1200", "NFT": "+1130", "SBT": "+1100", "AEST": "+1000", "ACST": "+0930", "JST": "+0900", "CWST": "+0845", "CT": "+0800", "ICT": "+0700", "MMT": "+0630", "BST": "+0600", "NPT": "+0545", "IST": "+0530", "PKT": "+0500", "AFT": "+0430", "MSK": "+0400", "IRST": "+0330", "FET": "+0300", "EET": "+0200", "CET": "+0100", "GMT": "+0000", "UTC": "+0000", "CVT": "-0100", "GST": "-0200", "BRT": "-0300", "NST": "-0330", "AST": "-0400", "EST": "-0500", "CST": "-0600", "MST": "-0700", "PST": "-0800", "AKST": "-0900", "MIT": "-0930", "HST": "-1000", "SST": "-1100", "BIT": "-1200" }; return __(standard); }, timeZones: function (data) { var zone; data.timezones = []; for (zone in data.abbreviatedTimeZoneStandard) { if (data.abbreviatedTimeZoneStandard.hasOwnProperty(zone)) { data.timezones.push({ name: zone, offset: data.abbreviatedTimeZoneStandard[zone]}); } } for (zone in data.abbreviatedTimeZoneDST) { if (data.abbreviatedTimeZoneDST.hasOwnProperty(zone)) { data.timezones.push({ name: zone, offset: data.abbreviatedTimeZoneDST[zone], dst: true}); } } return data.timezones; }, days: function () { return __(["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"]); }, dayAbbr: function () { return __(["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"]); }, dayShortNames: function () { return __(["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"]); }, dayFirstLetters: function () { return __(["S_Sun_Initial", "M_Mon_Initial", "T_Tues_Initial", "W_Wed_Initial", "T_Thu_Initial", "F_Fri_Initial", "S_Sat_Initial"]); }, months: function () { return __(["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"]); }, monthAbbr: function () { return __(["Jan_Abbr", "Feb_Abbr", "Mar_Abbr", "Apr_Abbr", "May_Abbr", "Jun_Abbr", "Jul_Abbr", "Aug_Abbr", "Sep_Abbr", "Oct_Abbr", "Nov_Abbr", "Dec_Abbr"]); }, formatPatterns: function () { return getText.getFromObjectValues({ shortDate: "M/d/yyyy", longDate: "dddd, MMMM dd, yyyy", shortTime: "h:mm tt", longTime: "h:mm:ss tt", fullDateTime: "dddd, MMMM dd, yyyy h:mm:ss tt", sortableDateTime: "yyyy-MM-ddTHH:mm:ss", universalSortableDateTime: "yyyy-MM-dd HH:mm:ssZ", rfc1123: "ddd, dd MMM yyyy HH:mm:ss", monthDay: "MMMM dd", yearMonth: "MMMM, yyyy" }, Date.i18n.currentLanguage()); }, regex: function () { return getText.getFromObjectValues({ inTheMorning: "/( in the )(morn(ing)?)\\b/", thisMorning: "/(this )(morn(ing)?)\\b/", amThisMorning: "/(\b\\d(am)? )(this )(morn(ing)?)/", inTheEvening: "/( in the )(even(ing)?)\\b/", thisEvening: "/(this )(even(ing)?)\\b/", pmThisEvening: "/(\b\\d(pm)? )(this )(even(ing)?)/", jan: "/jan(uary)?/", feb: "/feb(ruary)?/", mar: "/mar(ch)?/", apr: "/apr(il)?/", may: "/may/", jun: "/jun(e)?/", jul: "/jul(y)?/", aug: "/aug(ust)?/", sep: "/sep(t(ember)?)?/", oct: "/oct(ober)?/", nov: "/nov(ember)?/", dec: "/dec(ember)?/", sun: "/^su(n(day)?)?/", mon: "/^mo(n(day)?)?/", tue: "/^tu(e(s(day)?)?)?/", wed: "/^we(d(nesday)?)?/", thu: "/^th(u(r(s(day)?)?)?)?/", fri: "/fr(i(day)?)?/", sat: "/^sa(t(urday)?)?/", future: "/^next/", past: "/^last|past|prev(ious)?/", add: "/^(\\+|aft(er)?|from|hence)/", subtract: "/^(\\-|bef(ore)?|ago)/", yesterday: "/^yes(terday)?/", today: "/^t(od(ay)?)?/", tomorrow: "/^tom(orrow)?/", now: "/^n(ow)?/", millisecond: "/^ms|milli(second)?s?/", second: "/^sec(ond)?s?/", minute: "/^mn|min(ute)?s?/", hour: "/^h(our)?s?/", week: "/^w(eek)?s?/", month: "/^m(onth)?s?/", day: "/^d(ay)?s?/", year: "/^y(ear)?s?/", shortMeridian: "/^(a|p)/", longMeridian: "/^(a\\.?m?\\.?|p\\.?m?\\.?)/", timezone: "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/", ordinalSuffix: "/^\\s*(st|nd|rd|th)/", timeContext: "/^\\s*(\\:|a(?!u|p)|p)/" }, Date.i18n.currentLanguage()); } }; var CultureInfo = function () { var info = getText.getFromObjectValues({ name: "name", englishName: "englishName", nativeName: "nativeName", amDesignator: "AM", pmDesignator: "PM", firstDayOfWeek: "firstDayOfWeek", twoDigitYearMax: "twoDigitYearMax", dateElementOrder: "mdy" }, Date.i18n.currentLanguage()); var constructedInfo = buildInfo.buildFromMethodHash({ dayNames: "days", abbreviatedDayNames: "dayAbbr", shortestDayNames: "dayShortNames", firstLetterDayNames: "dayFirstLetters", monthNames: "months", abbreviatedMonthNames: "monthAbbr", formatPatterns: "formatPatterns", regexPatterns: "regex", abbreviatedTimeZoneDST: "timeZoneDST", abbreviatedTimeZoneStandard: "timeZoneStandard" }); shallowMerge(info, constructedInfo); buildInfo.timeZones(info); return info; }; $D.i18n = { __: function (key, lang) { return __(key, lang); }, currentLanguage: function () { return lang || "en-US"; }, setLanguage: function (code, force, cb) { var async = false; if (force || code === "en-US" || (!!Date.CultureStrings && !!Date.CultureStrings[code])) { lang = code; Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings.lang = code; Date.CultureInfo = new CultureInfo(); } else { if (!(!!Date.CultureStrings && !!Date.CultureStrings[code])) { if (typeof exports !== "undefined" && this.exports !== exports) { // we're in a Node enviroment, load it using require try { require("../i18n/" + code + ".js"); lang = code; Date.CultureStrings.lang = code; Date.CultureInfo = new CultureInfo(); } catch (e) { // var str = "The language for '" + code + "' could not be loaded by Node. It likely does not exist."; throw new Error("The DateJS IETF language tag '" + code + "' could not be loaded by Node. It likely does not exist."); } } else if (Date.Config && Date.Config.i18n) { // we know the location of the files, so lets load them async = true; loadI18nScript(code).done(function(){ lang = code; Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings.lang = code; Date.CultureInfo = new CultureInfo(); $D.Parsing.Normalizer.buildReplaceData(); // because this is async if ($D.Grammar) { $D.Grammar.buildGrammarFormats(); // so we can parse those strings... } if (cb) { setTimeout(cb,0); } }); } else { Date.console.error("The DateJS IETF language tag '" + code + "' is not available and has not been loaded."); return false; } } } $D.Parsing.Normalizer.buildReplaceData(); // rebuild normalizer strings if ($D.Grammar) { $D.Grammar.buildGrammarFormats(); // so we can parse those strings... } if (!async && cb) { setTimeout(cb,0); } }, getLoggedKeys: function () { return loggedKeys; }, updateCultureInfo: function () { Date.CultureInfo = new CultureInfo(); } }; $D.i18n.updateCultureInfo(); // run automatically }()); (function () { var $D = Date, $P = $D.prototype, p = function (s, l) { if (!l) { l = 2; } return ("000" + s).slice(l * -1); }; if (typeof window !== "undefined" && typeof window.console !== "undefined" && typeof window.console.log !== "undefined") { $D.console = console; // used only to raise non-critical errors if available } else { // set mock so we don't give errors. $D.console = { log: function(){}, error: function(){} }; } $D.Config = $D.Config || {}; $D.initOverloads = function() { /** * Overload of Date.now. Allows an alternate call for Date.now where it returns the * current Date as an object rather than just milliseconds since the Unix Epoch. * * Also provides an implementation of now() for browsers (IE<9) that don't have it. * * Backwards compatible so with work with either: * Date.now() [returns ms] * or * Date.now(true) [returns Date] */ if (!$D.now) { $D._now = function now() { return new Date().getTime(); }; } else if (!$D._now) { $D._now = $D.now; } $D.now = function (returnObj) { if (returnObj) { return $D.present(); } else { return $D._now(); } }; if ( !$P.toISOString ) { $P.toISOString = function() { return this.getUTCFullYear() + "-" + p(this.getUTCMonth() + 1) + "-" + p(this.getUTCDate()) + "T" + p(this.getUTCHours()) + ":" + p(this.getUTCMinutes()) + ":" + p(this.getUTCSeconds()) + "." + String( (this.getUTCMilliseconds()/1000).toFixed(3)).slice(2, 5) + "Z"; }; } // private if ( $P._toString === undefined ){ $P._toString = $P.toString; } }; $D.initOverloads(); /** * Gets a date that is set to the current date. The time is set to the start of the day (00:00 or 12:00 AM). * @return {Date} The current date. */ $D.today = function () { return new Date().clearTime(); }; /** * Gets a date that is set to the current date and time (same as new Date, but chainable) * @return {Date} The current date. */ $D.present = function () { return new Date(); }; /** * Compares the first date to the second date and returns an number indication of their relative values. * @param {Date} First Date object to compare [Required]. * @param {Date} Second Date object to compare to [Required]. * @return {Number} -1 = date1 is lessthan date2. 0 = values are equal. 1 = date1 is greaterthan date2. */ $D.compare = function (date1, date2) { if (isNaN(date1) || isNaN(date2)) { throw new Error(date1 + " - " + date2); } else if (date1 instanceof Date && date2 instanceof Date) { return (date1 < date2) ? -1 : (date1 > date2) ? 1 : 0; } else { throw new TypeError(date1 + " - " + date2); } }; /** * Compares the first Date object to the second Date object and returns true if they are equal. * @param {Date} First Date object to compare [Required] * @param {Date} Second Date object to compare to [Required] * @return {Boolean} true if dates are equal. false if they are not equal. */ $D.equals = function (date1, date2) { return (date1.compareTo(date2) === 0); }; /** * Gets the language appropriate day name when given the day number(0-6) * eg - 0 == Sunday * @return {String} The day name */ $D.getDayName = function (n) { return Date.CultureInfo.dayNames[n]; }; /** * Gets the day number (0-6) if given a CultureInfo specific string which is a valid dayName, abbreviatedDayName or shortestDayName (two char). * @param {String} The name of the day (eg. "Monday, "Mon", "tuesday", "tue", "We", "we"). * @return {Number} The day number */ $D.getDayNumberFromName = function (name) { var n = Date.CultureInfo.dayNames, m = Date.CultureInfo.abbreviatedDayNames, o = Date.CultureInfo.shortestDayNames, s = name.toLowerCase(); for (var i = 0; i < n.length; i++) { if (n[i].toLowerCase() === s || m[i].toLowerCase() === s || o[i].toLowerCase() === s) { return i; } } return -1; }; /** * Gets the month number (0-11) if given a Culture Info specific string which is a valid monthName or abbreviatedMonthName. * @param {String} The name of the month (eg. "February, "Feb", "october", "oct"). * @return {Number} The day number */ $D.getMonthNumberFromName = function (name) { var n = Date.CultureInfo.monthNames, m = Date.CultureInfo.abbreviatedMonthNames, s = name.toLowerCase(); for (var i = 0; i < n.length; i++) { if (n[i].toLowerCase() === s || m[i].toLowerCase() === s) { return i; } } return -1; }; /** * Gets the language appropriate month name when given the month number(0-11) * eg - 0 == January * @return {String} The month name */ $D.getMonthName = function (n) { return Date.CultureInfo.monthNames[n]; }; /** * Determines if the current date instance is within a LeapYear. * @param {Number} The year. * @return {Boolean} true if date is within a LeapYear, otherwise false. */ $D.isLeapYear = function (year) { return ((year % 4 === 0 && year % 100 !== 0) || year % 400 === 0); }; /** * Gets the number of days in the month, given a year and month value. Automatically corrects for LeapYear. * @param {Number} The year. * @param {Number} The month (0-11). * @return {Number} The number of days in the month. */ $D.getDaysInMonth = function (year, month) { if (!month && $D.validateMonth(year)) { month = year; year = Date.today().getFullYear(); } return [31, ($D.isLeapYear(year) ? 29 : 28), 31, 30, 31, 30, 31, 31, 30, 31, 30, 31][month]; }; $P.getDaysInMonth = function () { return $D.getDaysInMonth(this.getFullYear(), this.getMonth()); }; $D.getTimezoneAbbreviation = function (offset, dst) { var p, n = (dst || false) ? Date.CultureInfo.abbreviatedTimeZoneDST : Date.CultureInfo.abbreviatedTimeZoneStandard; for (p in n) { if (n.hasOwnProperty(p)) { if (n[p] === offset) { return p; } } } return null; }; $D.getTimezoneOffset = function (name, dst) { var i, a =[], z = Date.CultureInfo.timezones; if (!name) { name = (new Date()).getTimezone();} for (i = 0; i < z.length; i++) { if (z[i].name === name.toUpperCase()) { a.push(i); } } if (!z[a[0]]) { return null; } if (a.length === 1 || !dst) { return z[a[0]].offset; } else { for (i=0; i < a.length; i++) { if (z[a[i]].dst) { return z[a[i]].offset; } } } }; $D.getQuarter = function (d) { d = d || new Date(); // If no date supplied, use today var q = [1,2,3,4]; return q[Math.floor(d.getMonth() / 3)]; // ~~~ is a bitwise op. Faster than Math.floor }; $D.getDaysLeftInQuarter = function (d) { d = d || new Date(); var qEnd = new Date(d); qEnd.setMonth(qEnd.getMonth() + 3 - qEnd.getMonth() % 3, 0); return Math.floor((qEnd - d) / 8.64e7); }; // private var validate = function (n, min, max, name) { name = name ? name : "Object"; if (typeof n === "undefined") { return false; } else if (typeof n !== "number") { throw new TypeError(n + " is not a Number."); } else if (n < min || n > max) { // As failing validation is *not* an exceptional circumstance // lets not throw a RangeError Exception here. // It's semantically correct but it's not sensible. return false; } return true; }; /** * Validates the number is within an acceptable range for milliseconds [0-999]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateMillisecond = function (value) { return validate(value, 0, 999, "millisecond"); }; /** * Validates the number is within an acceptable range for seconds [0-59]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateSecond = function (value) { return validate(value, 0, 59, "second"); }; /** * Validates the number is within an acceptable range for minutes [0-59]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateMinute = function (value) { return validate(value, 0, 59, "minute"); }; /** * Validates the number is within an acceptable range for hours [0-23]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateHour = function (value) { return validate(value, 0, 23, "hour"); }; /** * Validates the number is within an acceptable range for the days in a month [0-MaxDaysInMonth]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateDay = function (value, year, month) { if (year === undefined || year === null || month === undefined || month === null) { return false;} return validate(value, 1, $D.getDaysInMonth(year, month), "day"); }; /** * Validates the number is within an acceptable range for months [0-11]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateWeek = function (value) { return validate(value, 0, 53, "week"); }; /** * Validates the number is within an acceptable range for months [0-11]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateMonth = function (value) { return validate(value, 0, 11, "month"); }; /** * Validates the number is within an acceptable range for years. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateYear = function (value) { /** * Per ECMAScript spec the range of times supported by Date objects is * exactly -100,000,000 days to +100,000,000 days measured relative to * midnight at the beginning of 01 January, 1970 UTC. * This gives a range of 8,640,000,000,000,000 milliseconds to either * side of 01 January, 1970 UTC. * * Earliest possible date: Tue, 20 Apr 271,822 B.C. 00:00:00 UTC * Latest possible date: Sat, 13 Sep 275,760 00:00:00 UTC */ return validate(value, -271822, 275760, "year"); }; $D.validateTimezone = function(value) { var timezones = {"ACDT":1,"ACST":1,"ACT":1,"ADT":1,"AEDT":1,"AEST":1,"AFT":1,"AKDT":1,"AKST":1,"AMST":1,"AMT":1,"ART":1,"AST":1,"AWDT":1,"AWST":1,"AZOST":1,"AZT":1,"BDT":1,"BIOT":1,"BIT":1,"BOT":1,"BRT":1,"BST":1,"BTT":1,"CAT":1,"CCT":1,"CDT":1,"CEDT":1,"CEST":1,"CET":1,"CHADT":1,"CHAST":1,"CHOT":1,"ChST":1,"CHUT":1,"CIST":1,"CIT":1,"CKT":1,"CLST":1,"CLT":1,"COST":1,"COT":1,"CST":1,"CT":1,"CVT":1,"CWST":1,"CXT":1,"DAVT":1,"DDUT":1,"DFT":1,"EASST":1,"EAST":1,"EAT":1,"ECT":1,"EDT":1,"EEDT":1,"EEST":1,"EET":1,"EGST":1,"EGT":1,"EIT":1,"EST":1,"FET":1,"FJT":1,"FKST":1,"FKT":1,"FNT":1,"GALT":1,"GAMT":1,"GET":1,"GFT":1,"GILT":1,"GIT":1,"GMT":1,"GST":1,"GYT":1,"HADT":1,"HAEC":1,"HAST":1,"HKT":1,"HMT":1,"HOVT":1,"HST":1,"ICT":1,"IDT":1,"IOT":1,"IRDT":1,"IRKT":1,"IRST":1,"IST":1,"JST":1,"KGT":1,"KOST":1,"KRAT":1,"KST":1,"LHST":1,"LINT":1,"MAGT":1,"MART":1,"MAWT":1,"MDT":1,"MET":1,"MEST":1,"MHT":1,"MIST":1,"MIT":1,"MMT":1,"MSK":1,"MST":1,"MUT":1,"MVT":1,"MYT":1,"NCT":1,"NDT":1,"NFT":1,"NPT":1,"NST":1,"NT":1,"NUT":1,"NZDT":1,"NZST":1,"OMST":1,"ORAT":1,"PDT":1,"PET":1,"PETT":1,"PGT":1,"PHOT":1,"PHT":1,"PKT":1,"PMDT":1,"PMST":1,"PONT":1,"PST":1,"PYST":1,"PYT":1,"RET":1,"ROTT":1,"SAKT":1,"SAMT":1,"SAST":1,"SBT":1,"SCT":1,"SGT":1,"SLST":1,"SRT":1,"SST":1,"SYOT":1,"TAHT":1,"THA":1,"TFT":1,"TJT":1,"TKT":1,"TLT":1,"TMT":1,"TOT":1,"TVT":1,"UCT":1,"ULAT":1,"UTC":1,"UYST":1,"UYT":1,"UZT":1,"VET":1,"VLAT":1,"VOLT":1,"VOST":1,"VUT":1,"WAKT":1,"WAST":1,"WAT":1,"WEDT":1,"WEST":1,"WET":1,"WST":1,"YAKT":1,"YEKT":1,"Z":1}; return (timezones[value] === 1); }; $D.validateTimezoneOffset= function(value) { // timezones go from +14hrs to -12hrs, the +X hours are negative offsets. return (value > -841 && value < 721); }; }()); (function () { var $D = Date, $P = $D.prototype, p = function (s, l) { if (!l) { l = 2; } return ("000" + s).slice(l * -1); }; var validateConfigObject = function (obj) { var result = {}, self = this, prop, testFunc; testFunc = function (prop, func, value) { if (prop === "day") { var month = (obj.month !== undefined) ? obj.month : self.getMonth(); var year = (obj.year !== undefined) ? obj.year : self.getFullYear(); return $D[func](value, year, month); } else { return $D[func](value); } }; for (prop in obj) { if (Object.prototype.hasOwnProperty.call(obj, prop)) { var func = "validate" + prop.charAt(0).toUpperCase() + prop.slice(1); if ($D[func] && obj[prop] !== null && testFunc(prop, func, obj[prop])) { result[prop] = obj[prop]; } } } return result; }; /** * Resets the time of this Date object to 12:00 AM (00:00), which is the start of the day. * @param {Boolean} .clone() this date instance before clearing Time * @return {Date} this */ $P.clearTime = function () { this.setHours(0); this.setMinutes(0); this.setSeconds(0); this.setMilliseconds(0); return this; }; /** * Resets the time of this Date object to the current time ('now'). * @return {Date} this */ $P.setTimeToNow = function () { var n = new Date(); this.setHours(n.getHours()); this.setMinutes(n.getMinutes()); this.setSeconds(n.getSeconds()); this.setMilliseconds(n.getMilliseconds()); return this; }; /** * Returns a new Date object that is an exact date and time copy of the original instance. * @return {Date} A new Date instance */ $P.clone = function () { return new Date(this.getTime()); }; /** * Compares this instance to a Date object and returns an number indication of their relative values. * @param {Date} Date object to compare [Required] * @return {Number} -1 = this is lessthan date. 0 = values are equal. 1 = this is greaterthan date. */ $P.compareTo = function (date) { return Date.compare(this, date); }; /** * Compares this instance to another Date object and returns true if they are equal. * @param {Date} Date object to compare. If no date to compare, new Date() [now] is used. * @return {Boolean} true if dates are equal. false if they are not equal. */ $P.equals = function (date) { return Date.equals(this, (date !== undefined ? date : new Date())); }; /** * Determines if this instance is between a range of two dates or equal to either the start or end dates. * @param {Date} Start of range [Required] * @param {Date} End of range [Required] * @return {Boolean} true is this is between or equal to the start and end dates, else false */ $P.between = function (start, end) { return this.getTime() >= start.getTime() && this.getTime() <= end.getTime(); }; /** * Determines if this date occurs after the date to compare to. * @param {Date} Date object to compare. If no date to compare, new Date() ("now") is used. * @return {Boolean} true if this date instance is greater than the date to compare to (or "now"), otherwise false. */ $P.isAfter = function (date) { return this.compareTo(date || new Date()) === 1; }; /** * Determines if this date occurs before the date to compare to. * @param {Date} Date object to compare. If no date to compare, new Date() ("now") is used. * @return {Boolean} true if this date instance is less than the date to compare to (or "now"). */ $P.isBefore = function (date) { return (this.compareTo(date || new Date()) === -1); }; /** * Determines if the current Date instance occurs today. * @return {Boolean} true if this date instance is 'today', otherwise false. */ /** * Determines if the current Date instance occurs on the same Date as the supplied 'date'. * If no 'date' to compare to is provided, the current Date instance is compared to 'today'. * @param {date} Date object to compare. If no date to compare, the current Date ("now") is used. * @return {Boolean} true if this Date instance occurs on the same Day as the supplied 'date'. */ $P.isToday = $P.isSameDay = function (date) { return this.clone().clearTime().equals((date || new Date()).clone().clearTime()); }; /** * Adds the specified number of milliseconds to this instance. * @param {Number} The number of milliseconds to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addMilliseconds = function (value) { if (!value) { return this; } this.setTime(this.getTime() + value * 1); return this; }; /** * Adds the specified number of seconds to this instance. * @param {Number} The number of seconds to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addSeconds = function (value) { if (!value) { return this; } return this.addMilliseconds(value * 1000); }; /** * Adds the specified number of seconds to this instance. * @param {Number} The number of seconds to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addMinutes = function (value) { if (!value) { return this; } return this.addMilliseconds(value * 60000); // 60*1000 }; /** * Adds the specified number of hours to this instance. * @param {Number} The number of hours to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addHours = function (value) { if (!value) { return this; } return this.addMilliseconds(value * 3600000); // 60*60*1000 }; /** * Adds the specified number of days to this instance. * @param {Number} The number of days to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addDays = function (value) { if (!value) { return this; } this.setDate(this.getDate() + value * 1); return this; }; /** * Adds the specified number of weekdays (ie - not sat or sun) to this instance. * @param {Number} The number of days to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addWeekdays = function (value) { if (!value) { return this; } var day = this.getDay(); var weeks = (Math.ceil(Math.abs(value)/7)); if (day === 0 || day === 6) { if (value > 0) { this.next().monday(); this.addDays(-1); day = this.getDay(); } } if (value < 0) { while (value < 0) { this.addDays(-1); day = this.getDay(); if (day !== 0 && day !== 6) { value++; } } return this; } else if (value > 5 || (6-day) <= value) { value = value + (weeks * 2); } return this.addDays(value); }; /** * Adds the specified number of weeks to this instance. * @param {Number} The number of weeks to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addWeeks = function (value) { if (!value) { return this; } return this.addDays(value * 7); }; /** * Adds the specified number of months to this instance. * @param {Number} The number of months to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addMonths = function (value) { if (!value) { return this; } var n = this.getDate(); this.setDate(1); this.setMonth(this.getMonth() + value * 1); this.setDate(Math.min(n, $D.getDaysInMonth(this.getFullYear(), this.getMonth()))); return this; }; $P.addQuarters = function (value) { if (!value) { return this; } // note this will take you to the same point in the quarter as you are now. // i.e. - if you are 15 days into the quarter you'll be 15 days into the resulting one. // bonus: this allows adding fractional quarters return this.addMonths(value * 3); }; /** * Adds the specified number of years to this instance. * @param {Number} The number of years to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addYears = function (value) { if (!value) { return this; } return this.addMonths(value * 12); }; /** * Adds (or subtracts) to the value of the years, months, weeks, days, hours, minutes, seconds, milliseconds of the date instance using given configuration object. Positive and Negative values allowed. * Example

	Date.today().add( { days: 1, months: 1 } )

	new Date().add( { years: -1 } )
	
* @param {Object} Configuration object containing attributes (months, days, etc.) * @return {Date} this */ $P.add = function (config) { if (typeof config === "number") { this._orient = config; return this; } var x = config; if (x.day) { // If we should be a different date than today (eg: for 'tomorrow -1d', etc). // Should only effect parsing, not direct usage (eg, Finish and FinishExact) if ((x.day - this.getDate()) !== 0) { this.setDate(x.day); } } if (x.milliseconds) { this.addMilliseconds(x.milliseconds); } if (x.seconds) { this.addSeconds(x.seconds); } if (x.minutes) { this.addMinutes(x.minutes); } if (x.hours) { this.addHours(x.hours); } if (x.weeks) { this.addWeeks(x.weeks); } if (x.months) { this.addMonths(x.months); } if (x.years) { this.addYears(x.years); } if (x.days) { this.addDays(x.days); } return this; }; /** * Get the week number. Week one (1) is the week which contains the first Thursday of the year. Monday is considered the first day of the week. * The .getWeek() function does NOT convert the date to UTC. The local datetime is used. * Please use .getISOWeek() to get the week of the UTC converted date. * @return {Number} 1 to 53 */ $P.getWeek = function (utc) { // Create a copy of this date object var self, target = new Date(this.valueOf()); if (utc) { target.addMinutes(target.getTimezoneOffset()); self = target.clone(); } else { self = this; } // ISO week date weeks start on monday // so correct the day number var dayNr = (self.getDay() + 6) % 7; // ISO 8601 states that week 1 is the week // with the first thursday of that year. // Set the target date to the thursday in the target week target.setDate(target.getDate() - dayNr + 3); // Store the millisecond value of the target date var firstThursday = target.valueOf(); // Set the target to the first thursday of the year // First set the target to january first target.setMonth(0, 1); // Not a thursday? Correct the date to the next thursday if (target.getDay() !== 4) { target.setMonth(0, 1 + ((4 - target.getDay()) + 7) % 7); } // The weeknumber is the number of weeks between the // first thursday of the year and the thursday in the target week return 1 + Math.ceil((firstThursday - target) / 604800000); // 604800000 = 7 * 24 * 3600 * 1000 }; /** * Get the ISO 8601 week number. Week one ("01") is the week which contains the first Thursday of the year. Monday is considered the first day of the week. * The .getISOWeek() function does convert the date to it's UTC value. Please use .getWeek() to get the week of the local date. * @return {String} "01" to "53" */ $P.getISOWeek = function () { return p(this.getWeek(true)); }; /** * Moves the date to Monday of the week set. Week one (1) is the week which contains the first Thursday of the year. * @param {Number} A Number (1 to 53) that represents the week of the year. * @return {Date} this */ $P.setWeek = function (n) { if ((n - this.getWeek()) === 0) { if (this.getDay() !== 1) { return this.moveToDayOfWeek(1, (this.getDay() > 1 ? -1 : 1)); } else { return this; } } else { return this.moveToDayOfWeek(1, (this.getDay() > 1 ? -1 : 1)).addWeeks(n - this.getWeek()); } }; $P.setQuarter = function (qtr) { var month = Math.abs(((qtr-1) * 3) + 1); return this.setMonth(month, 1); }; $P.getQuarter = function () { return Date.getQuarter(this); }; $P.getDaysLeftInQuarter = function () { return Date.getDaysLeftInQuarter(this); }; /** * Moves the date to the next n'th occurrence of the dayOfWeek starting from the beginning of the month. The number (-1) is a magic number and will return the last occurrence of the dayOfWeek in the month. * @param {Number} The dayOfWeek to move to * @param {Number} The n'th occurrence to move to. Use (-1) to return the last occurrence in the month * @return {Date} this */ $P.moveToNthOccurrence = function (dayOfWeek, occurrence) { if (dayOfWeek === "Weekday") { if (occurrence > 0) { this.moveToFirstDayOfMonth(); if (this.is().weekday()) { occurrence -= 1; } } else if (occurrence < 0) { this.moveToLastDayOfMonth(); if (this.is().weekday()) { occurrence += 1; } } else { return this; } return this.addWeekdays(occurrence); } var shift = 0; if (occurrence > 0) { shift = occurrence - 1; } else if (occurrence === -1) { this.moveToLastDayOfMonth(); if (this.getDay() !== dayOfWeek) { this.moveToDayOfWeek(dayOfWeek, -1); } return this; } return this.moveToFirstDayOfMonth().addDays(-1).moveToDayOfWeek(dayOfWeek, +1).addWeeks(shift); }; var moveToN = function (getFunc, addFunc, nVal) { return function (value, orient) { var diff = (value - this[getFunc]() + nVal * (orient || +1)) % nVal; return this[addFunc]((diff === 0) ? diff += nVal * (orient || +1) : diff); }; }; /** * Move to the next or last dayOfWeek based on the orient value. * @param {Number} The dayOfWeek to move to * @param {Number} Forward (+1) or Back (-1). Defaults to +1. [Optional] * @return {Date} this */ $P.moveToDayOfWeek = moveToN("getDay", "addDays", 7); /** * Move to the next or last month based on the orient value. * @param {Number} The month to move to. 0 = January, 11 = December * @param {Number} Forward (+1) or Back (-1). Defaults to +1. [Optional] * @return {Date} this */ $P.moveToMonth = moveToN("getMonth", "addMonths", 12); /** * Get the Ordinate of the current day ("th", "st", "rd"). * @return {String} */ $P.getOrdinate = function () { var num = this.getDate(); return ord(num); }; /** * Get the Ordinal day (numeric day number) of the year, adjusted for leap year. * @return {Number} 1 through 365 (366 in leap years) */ $P.getOrdinalNumber = function () { return Math.ceil((this.clone().clearTime() - new Date(this.getFullYear(), 0, 1)) / 86400000) + 1; }; /** * Get the time zone abbreviation of the current date. * @return {String} The abbreviated time zone name (e.g. "EST") */ $P.getTimezone = function () { return $D.getTimezoneAbbreviation(this.getUTCOffset(), this.isDaylightSavingTime()); }; $P.setTimezoneOffset = function (offset) { var here = this.getTimezoneOffset(), there = Number(offset) * -6 / 10; return (there || there === 0) ? this.addMinutes(there - here) : this; }; $P.setTimezone = function (offset) { return this.setTimezoneOffset($D.getTimezoneOffset(offset)); }; /** * Indicates whether Daylight Saving Time is observed in the current time zone. * @return {Boolean} true|false */ $P.hasDaylightSavingTime = function () { return (Date.today().set({month: 0, day: 1}).getTimezoneOffset() !== Date.today().set({month: 6, day: 1}).getTimezoneOffset()); }; /** * Indicates whether this Date instance is within the Daylight Saving Time range for the current time zone. * @return {Boolean} true|false */ $P.isDaylightSavingTime = function () { return Date.today().set({month: 0, day: 1}).getTimezoneOffset() !== this.getTimezoneOffset(); }; /** * Get the offset from UTC of the current date. * @return {String} The 4-character offset string prefixed with + or - (e.g. "-0500") */ $P.getUTCOffset = function (offset) { var n = (offset || this.getTimezoneOffset()) * -10 / 6, r; if (n < 0) { r = (n - 10000).toString(); return r.charAt(0) + r.substr(2); } else { r = (n + 10000).toString(); return "+" + r.substr(1); } }; /** * Returns the number of milliseconds between this date and date. * @param {Date} Defaults to now * @return {Number} The diff in milliseconds */ $P.getElapsed = function (date) { return (date || new Date()) - this; }; /** * Set the value of year, month, day, hour, minute, second, millisecond of date instance using given configuration object. * Example

	Date.today().set( { day: 20, month: 1 } )

	new Date().set( { millisecond: 0 } )
	
* * @param {Object} Configuration object containing attributes (month, day, etc.) * @return {Date} this */ $P.set = function (config) { config = validateConfigObject.call(this, config); var key; for (key in config) { if (Object.prototype.hasOwnProperty.call(config, key)) { var name = key.charAt(0).toUpperCase() + key.slice(1); var addFunc, getFunc; if (key !== "week" && key !== "month" && key !== "timezone" && key !== "timezoneOffset") { name += "s"; } addFunc = "add" + name; getFunc = "get" + name; if (key === "month") { addFunc = addFunc + "s"; } else if (key === "year"){ getFunc = "getFullYear"; } if (key !== "day" && key !== "timezone" && key !== "timezoneOffset" && key !== "week" && key !== "hour") { this[addFunc](config[key] - this[getFunc]()); } else if ( key === "timezone"|| key === "timezoneOffset" || key === "week" || key === "hour") { this["set"+name](config[key]); } } } // day has to go last because you can't validate the day without first knowing the month if (config.day) { this.addDays(config.day - this.getDate()); } return this; }; /** * Moves the date to the first day of the month. * @return {Date} this */ $P.moveToFirstDayOfMonth = function () { return this.set({ day: 1 }); }; /** * Moves the date to the last day of the month. * @return {Date} this */ $P.moveToLastDayOfMonth = function () { return this.set({ day: $D.getDaysInMonth(this.getFullYear(), this.getMonth())}); }; /** * Converts the value of the current Date object to its equivalent string representation. * Format Specifiers * CUSTOM DATE AND TIME FORMAT STRINGS * Format Description Example * ------ --------------------------------------------------------------------------- ----------------------- * s The seconds of the minute between 0-59. "0" to "59" * ss The seconds of the minute with leading zero if required. "00" to "59" * * m The minute of the hour between 0-59. "0" or "59" * mm The minute of the hour with leading zero if required. "00" or "59" * * h The hour of the day between 1-12. "1" to "12" * hh The hour of the day with leading zero if required. "01" to "12" * * H The hour of the day between 0-23. "0" to "23" * HH The hour of the day with leading zero if required. "00" to "23" * * d The day of the month between 1 and 31. "1" to "31" * dd The day of the month with leading zero if required. "01" to "31" * ddd Abbreviated day name. Date.CultureInfo.abbreviatedDayNames. "Mon" to "Sun" * dddd The full day name. Date.CultureInfo.dayNames. "Monday" to "Sunday" * * M The month of the year between 1-12. "1" to "12" * MM The month of the year with leading zero if required. "01" to "12" * MMM Abbreviated month name. Date.CultureInfo.abbreviatedMonthNames. "Jan" to "Dec" * MMMM The full month name. Date.CultureInfo.monthNames. "January" to "December" * * yy The year as a two-digit number. "99" or "08" * yyyy The full four digit year. "1999" or "2008" * * t Displays the first character of the A.M./P.M. designator. "A" or "P" * Date.CultureInfo.amDesignator or Date.CultureInfo.pmDesignator * tt Displays the A.M./P.M. designator. "AM" or "PM" * Date.CultureInfo.amDesignator or Date.CultureInfo.pmDesignator * * S The ordinal suffix ("st, "nd", "rd" or "th") of the current day. "st, "nd", "rd" or "th" * * STANDARD DATE AND TIME FORMAT STRINGS * Format Description Example *------ --------------------------------------------------------------------------- ----------------------- * d The CultureInfo shortDate Format Pattern "M/d/yyyy" * D The CultureInfo longDate Format Pattern "dddd, MMMM dd, yyyy" * F The CultureInfo fullDateTime Format Pattern "dddd, MMMM dd, yyyy h:mm:ss tt" * m The CultureInfo monthDay Format Pattern "MMMM dd" * r The CultureInfo rfc1123 Format Pattern "ddd, dd MMM yyyy HH:mm:ss GMT" * s The CultureInfo sortableDateTime Format Pattern "yyyy-MM-ddTHH:mm:ss" * t The CultureInfo shortTime Format Pattern "h:mm tt" * T The CultureInfo longTime Format Pattern "h:mm:ss tt" * u The CultureInfo universalSortableDateTime Format Pattern "yyyy-MM-dd HH:mm:ssZ" * y The CultureInfo yearMonth Format Pattern "MMMM, yyyy" * * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @return {String} A string representation of the current Date object. */ var ord = function (n) { switch (n * 1) { case 1: case 21: case 31: return "st"; case 2: case 22: return "nd"; case 3: case 23: return "rd"; default: return "th"; } }; var parseStandardFormats = function (format) { var y, c = Date.CultureInfo.formatPatterns; switch (format) { case "d": return this.toString(c.shortDate); case "D": return this.toString(c.longDate); case "F": return this.toString(c.fullDateTime); case "m": return this.toString(c.monthDay); case "r": case "R": y = this.clone().addMinutes(this.getTimezoneOffset()); return y.toString(c.rfc1123) + " GMT"; case "s": return this.toString(c.sortableDateTime); case "t": return this.toString(c.shortTime); case "T": return this.toString(c.longTime); case "u": y = this.clone().addMinutes(this.getTimezoneOffset()); return y.toString(c.universalSortableDateTime); case "y": return this.toString(c.yearMonth); default: return false; } }; var parseFormatStringsClosure = function (context) { return function (m) { if (m.charAt(0) === "\\") { return m.replace("\\", ""); } switch (m) { case "hh": return p(context.getHours() < 13 ? (context.getHours() === 0 ? 12 : context.getHours()) : (context.getHours() - 12)); case "h": return context.getHours() < 13 ? (context.getHours() === 0 ? 12 : context.getHours()) : (context.getHours() - 12); case "HH": return p(context.getHours()); case "H": return context.getHours(); case "mm": return p(context.getMinutes()); case "m": return context.getMinutes(); case "ss": return p(context.getSeconds()); case "s": return context.getSeconds(); case "yyyy": return p(context.getFullYear(), 4); case "yy": return p(context.getFullYear()); case "y": return context.getFullYear(); case "E": case "dddd": return Date.CultureInfo.dayNames[context.getDay()]; case "ddd": return Date.CultureInfo.abbreviatedDayNames[context.getDay()]; case "dd": return p(context.getDate()); case "d": return context.getDate(); case "MMMM": return Date.CultureInfo.monthNames[context.getMonth()]; case "MMM": return Date.CultureInfo.abbreviatedMonthNames[context.getMonth()]; case "MM": return p((context.getMonth() + 1)); case "M": return context.getMonth() + 1; case "t": return context.getHours() < 12 ? Date.CultureInfo.amDesignator.substring(0, 1) : Date.CultureInfo.pmDesignator.substring(0, 1); case "tt": return context.getHours() < 12 ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator; case "S": return ord(context.getDate()); case "W": return context.getWeek(); case "WW": return context.getISOWeek(); case "Q": return "Q" + context.getQuarter(); case "q": return String(context.getQuarter()); case "z": return context.getTimezone(); case "Z": case "X": return Date.getTimezoneOffset(context.getTimezone()); case "ZZ": // Timezone offset in seconds return context.getTimezoneOffset() * -60; case "u": return context.getDay(); case "L": return ($D.isLeapYear(context.getFullYear())) ? 1 : 0; case "B": // Swatch Internet Time (.beats) return "@"+((context.getUTCSeconds() + (context.getUTCMinutes()*60) + ((context.getUTCHours()+1)*3600))/86.4); default: return m; } }; }; $P.toString = function (format, ignoreStandards) { // Standard Date and Time Format Strings. Formats pulled from CultureInfo file and // may vary by culture. if (!ignoreStandards && format && format.length === 1) { output = parseStandardFormats.call(this, format); if (output) { return output; } } var parseFormatStrings = parseFormatStringsClosure(this); return format ? format.replace(/((\\)?(dd?d?d?|MM?M?M?|yy?y?y?|hh?|HH?|mm?|ss?|tt?|S|q|Q|WW?W?W?)(?![^\[]*\]))/g, parseFormatStrings).replace(/\[|\]/g, "") : this._toString(); }; }()); /************************************************************* * SugarPak - Domain Specific Language - Syntactical Sugar * *************************************************************/ (function () { var $D = Date, $P = $D.prototype, $N = Number.prototype; // private $P._orient = +1; // private $P._nth = null; // private $P._is = false; // private $P._same = false; // private $P._isSecond = false; // private $N._dateElement = "days"; /** * Moves the date to the next instance of a date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.today().next().friday();
	Date.today().next().fri();
	Date.today().next().march();
	Date.today().next().mar();
	Date.today().next().week();
	
* * @return {Date} date */ $P.next = function () { this._move = true; this._orient = +1; return this; }; /** * Creates a new Date (Date.today()) and moves the date to the next instance of the date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.next().friday();
	Date.next().fri();
	Date.next().march();
	Date.next().mar();
	Date.next().week();
	
* * @return {Date} date */ $D.next = function () { return $D.today().next(); }; /** * Moves the date to the previous instance of a date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.today().last().friday();
	Date.today().last().fri();
	Date.today().last().march();
	Date.today().last().mar();
	Date.today().last().week();
	
* * @return {Date} date */ $P.last = $P.prev = $P.previous = function () { this._move = true; this._orient = -1; return this; }; /** * Creates a new Date (Date.today()) and moves the date to the previous instance of the date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.last().friday();
	Date.last().fri();
	Date.previous().march();
	Date.prev().mar();
	Date.last().week();
	
* * @return {Date} date */ $D.last = $D.prev = $D.previous = function () { return $D.today().last(); }; /** * Performs a equality check when followed by either a month name, day name or .weekday() function. * Example

	Date.today().is().friday(); // true|false
	Date.today().is().fri();
	Date.today().is().march();
	Date.today().is().mar();
	
* * @return {Boolean} true|false */ $P.is = function () { this._is = true; return this; }; /** * Determines if two date objects occur on/in exactly the same instance of the subsequent date part function. * The function .same() must be followed by a date part function (example: .day(), .month(), .year(), etc). * * An optional Date can be passed in the date part function. If now date is passed as a parameter, 'Now' is used. * * The following example demonstrates how to determine if two dates fall on the exact same day. * * Example

	var d1 = Date.today(); // today at 00:00
	var d2 = new Date();   // exactly now.

	// Do they occur on the same day?
	d1.same().day(d2); // true
	
	// Do they occur on the same hour?
	d1.same().hour(d2); // false, unless d2 hour is '00' (midnight).
	
	// What if it's the same day, but one year apart?
	var nextYear = Date.today().add(1).year();

	d1.same().day(nextYear); // false, because the dates must occur on the exact same day. 
	
* * Scenario: Determine if a given date occurs during some week period 2 months from now. * * Example

	var future = Date.today().add(2).months();
	return someDate.same().week(future); // true|false;
	
* * @return {Boolean} true|false */ $P.same = function () { this._same = true; this._isSecond = false; return this; }; /** * Determines if the current date/time occurs during Today. Must be preceded by the .is() function. * Example

	someDate.is().today();    // true|false
	new Date().is().today();  // true
	Date.today().is().today();// true
	Date.today().add(-1).day().is().today(); // false
	
* * @return {Boolean} true|false */ $P.today = function () { return this.same().day(); }; /** * Determines if the current date is a weekday. This function must be preceded by the .is() function. * Example

	Date.today().is().weekday(); // true|false
	
* * @return {Boolean} true|false */ $P.weekday = function () { if (this._nth) { return df("Weekday").call(this); } if (this._move) { return this.addWeekdays(this._orient); } if (this._is) { this._is = false; return (!this.is().sat() && !this.is().sun()); } return false; }; /** * Determines if the current date is on the weekend. This function must be preceded by the .is() function. * Example

	Date.today().is().weekend(); // true|false
	
* * @return {Boolean} true|false */ $P.weekend = function () { if (this._is) { this._is = false; return (this.is().sat() || this.is().sun()); } return false; }; /** * Sets the Time of the current Date instance. A string "6:15 pm" or config object {hour:18, minute:15} are accepted. * Example

	// Set time to 6:15pm with a String
	Date.today().at("6:15pm");

	// Set time to 6:15pm with a config object
	Date.today().at({hour:18, minute:15});
	
* * @return {Date} date */ $P.at = function (time) { return (typeof time === "string") ? $D.parse(this.toString("d") + " " + time) : this.set(time); }; /** * Creates a new Date() and adds this (Number) to the date based on the preceding date element function (eg. second|minute|hour|day|month|year). * Example

	// Undeclared Numbers must be wrapped with parentheses. Requirment of JavaScript.
	(3).days().fromNow();
	(6).months().fromNow();

	// Declared Number variables do not require parentheses. 
	var n = 6;
	n.months().fromNow();
	
* * @return {Date} A new Date instance */ $N.fromNow = $N.after = function (date) { var c = {}; c[this._dateElement] = this; return ((!date) ? new Date() : date.clone()).add(c); }; /** * Creates a new Date() and subtract this (Number) from the date based on the preceding date element function (eg. second|minute|hour|day|month|year). * Example

	// Undeclared Numbers must be wrapped with parentheses. Requirment of JavaScript.
	(3).days().ago();
	(6).months().ago();

	// Declared Number variables do not require parentheses. 
	var n = 6;
	n.months().ago();
	
* * @return {Date} A new Date instance */ $N.ago = $N.before = function (date) { var c = {}, s = (this._dateElement[this._dateElement.length-1] !== "s") ? this._dateElement + "s" : this._dateElement; c[s] = this * -1; return ((!date) ? new Date() : date.clone()).add(c); }; // Do NOT modify the following string tokens. These tokens are used to build dynamic functions. // All culture-specific strings can be found in the CultureInfo files. var dx = ("sunday monday tuesday wednesday thursday friday saturday").split(/\s/), mx = ("january february march april may june july august september october november december").split(/\s/), px = ("Millisecond Second Minute Hour Day Week Month Year Quarter Weekday").split(/\s/), pxf = ("Milliseconds Seconds Minutes Hours Date Week Month FullYear Quarter").split(/\s/), nth = ("final first second third fourth fifth").split(/\s/), de; /** * Returns an object literal of all the date parts. * Example

	var o = new Date().toObject();
	
	// { year: 2008, month: 4, week: 20, day: 13, hour: 18, minute: 9, second: 32, millisecond: 812 }
	
	// The object properties can be referenced directly from the object.
	
	alert(o.day);  // alerts "13"
	alert(o.year); // alerts "2008"
	
* * @return {Date} An object literal representing the original date object. */ $P.toObject = function () { var o = {}; for (var i = 0; i < px.length; i++) { if (this["get" + pxf[i]]) { o[px[i].toLowerCase()] = this["get" + pxf[i]](); } } return o; }; /** * Returns a date created from an object literal. Ignores the .week property if set in the config. * Example

	var o = new Date().toObject();
	
	return Date.fromObject(o); // will return the same date. 

	var o2 = {month: 1, day: 20, hour: 18}; // birthday party!
	Date.fromObject(o2);
	
* * @return {Date} An object literal representing the original date object. */ $D.fromObject = function(config) { config.week = null; return Date.today().set(config); }; // Create day name functions and abbreviated day name functions (eg. monday(), friday(), fri()). var df = function (n) { return function () { if (this._is) { this._is = false; return this.getDay() === n; } if (this._move) { this._move = null; } if (this._nth !== null) { // If the .second() function was called earlier, remove the _orient // from the date, and then continue. // This is required because 'second' can be used in two different context. // // Example // // Date.today().add(1).second(); // Date.march().second().monday(); // // Things get crazy with the following... // Date.march().add(1).second().second().monday(); // but it works!! // if (this._isSecond) { this.addSeconds(this._orient * -1); } // make sure we reset _isSecond this._isSecond = false; var ntemp = this._nth; this._nth = null; var temp = this.clone().moveToLastDayOfMonth(); this.moveToNthOccurrence(n, ntemp); if (this > temp) { throw new RangeError($D.getDayName(n) + " does not occur " + ntemp + " times in the month of " + $D.getMonthName(temp.getMonth()) + " " + temp.getFullYear() + "."); } return this; } return this.moveToDayOfWeek(n, this._orient); }; }; var sdf = function (n) { return function () { var t = $D.today(), shift = n - t.getDay(); if (n === 0 && Date.CultureInfo.firstDayOfWeek === 1 && t.getDay() !== 0) { shift = shift + 7; } return t.addDays(shift); }; }; // Create month name functions and abbreviated month name functions (eg. january(), march(), mar()). var month_instance_functions = function (n) { return function () { if (this._is) { this._is = false; return this.getMonth() === n; } return this.moveToMonth(n, this._orient); }; }; var month_static_functions = function (n) { return function () { return $D.today().set({ month: n, day: 1 }); }; }; var processTerms = function (names, staticFunc, instanceFunc) { for (var i = 0; i < names.length; i++) { // Create constant static Name variables. $D[names[i].toUpperCase()] = $D[names[i].toUpperCase().substring(0, 3)] = i; // Create Name functions. $D[names[i]] = $D[names[i].substring(0, 3)] = staticFunc(i); // Create Name instance functions. $P[names[i]] = $P[names[i].substring(0, 3)] = instanceFunc(i); } }; processTerms(dx, sdf, df); processTerms(mx, month_static_functions, month_instance_functions); // Create date element functions and plural date element functions used with Date (eg. day(), days(), months()). var ef = function (j) { return function () { // if the .second() function was called earlier, the _orient // has alread been added. Just return this and reset _isSecond. if (this._isSecond) { this._isSecond = false; return this; } if (this._same) { this._same = this._is = false; var o1 = this.toObject(), o2 = (arguments[0] || new Date()).toObject(), v = "", k = j.toLowerCase(); // the substr trick with -1 doesn't work in IE8 or less k = (k[k.length-1] === "s") ? k.substring(0,k.length-1) : k; for (var m = (px.length - 1); m > -1; m--) { v = px[m].toLowerCase(); if (o1[v] !== o2[v]) { return false; } if (k === v) { break; } } return true; } if (j.substring(j.length - 1) !== "s") { j += "s"; } if (this._move) { this._move = null; } return this["add" + j](this._orient); }; }; var nf = function (n) { return function () { this._dateElement = n; return this; }; }; for (var k = 0; k < px.length; k++) { de = px[k].toLowerCase(); if(de !== "weekday") { // Create date element functions and plural date element functions used with Date (eg. day(), days(), months()). $P[de] = $P[de + "s"] = ef(px[k]); // Create date element functions and plural date element functions used with Number (eg. day(), days(), months()). $N[de] = $N[de + "s"] = nf(de + "s"); } } $P._ss = ef("Second"); var nthfn = function (n) { return function (dayOfWeek) { if (this._same) { return this._ss(arguments[0]); } if (dayOfWeek || dayOfWeek === 0) { return this.moveToNthOccurrence(dayOfWeek, n); } this._nth = n; // if the operator is 'second' add the _orient, then deal with it later... if (n === 2 && (dayOfWeek === undefined || dayOfWeek === null)) { this._isSecond = true; return this.addSeconds(this._orient); } return this; }; }; for (var l = 0; l < nth.length; l++) { $P[nth[l]] = (l === 0) ? nthfn(-1) : nthfn(l); } }()); (function () { "use strict"; Date.Parsing = { Exception: function (s) { this.message = "Parse error at '" + s.substring(0, 10) + " ...'"; } }; var $P = Date.Parsing; var dayOffsets = { standard: [0,31,59,90,120,151,181,212,243,273,304,334], leap: [0,31,60,91,121,152,182,213,244,274,305,335] }; $P.isLeapYear = function(year) { return ((year % 4 === 0) && (year % 100 !== 0)) || (year % 400 === 0); }; var utils = { multiReplace : function (str, hash ) { var key; for (key in hash) { if (Object.prototype.hasOwnProperty.call(hash, key)) { var regex; if (typeof hash[key] === "function") { } else { regex = (hash[key] instanceof RegExp) ? hash[key] : new RegExp(hash[key], "g"); } str = str.replace(regex, key); } } return str; }, getDayOfYearFromWeek : function (obj) { var d, jan4, offset; obj.weekDay = (!obj.weekDay && obj.weekDay !== 0) ? 1 : obj.weekDay; d = new Date(obj.year, 0, 4); jan4 = d.getDay() === 0 ? 7 : d.getDay(); // JS is 0 indexed on Sunday. offset = jan4+3; obj.dayOfYear = ((obj.week * 7) + (obj.weekDay === 0 ? 7 : obj.weekDay))-offset; return obj; }, getDayOfYear : function (obj, dayOffset) { if (!obj.dayOfYear) { obj = utils.getDayOfYearFromWeek(obj); } for (var i=0;i <= dayOffset.length;i++) { if (obj.dayOfYear < dayOffset[i] || i === dayOffset.length) { obj.day = obj.day ? obj.day : (obj.dayOfYear - dayOffset[i-1]); break; } else { obj.month = i; } } return obj; }, adjustForTimeZone : function (obj, date) { var offset; if (obj.zone.toUpperCase() === "Z" || (obj.zone_hours === 0 && obj.zone_minutes === 0)) { // it's UTC/GML so work out the current timeszone offset offset = -date.getTimezoneOffset(); } else { offset = (obj.zone_hours*60) + (obj.zone_minutes || 0); if (obj.zone_sign === "+") { offset *= -1; } offset -= date.getTimezoneOffset(); } date.setMinutes(date.getMinutes()+offset); return date; }, setDefaults : function (obj) { obj.year = obj.year || Date.today().getFullYear(); obj.hours = obj.hours || 0; obj.minutes = obj.minutes || 0; obj.seconds = obj.seconds || 0; obj.milliseconds = obj.milliseconds || 0; if (!(!obj.month && (obj.week || obj.dayOfYear))) { // if we have a month, or if we don't but don't have the day calculation data obj.month = obj.month || 0; obj.day = obj.day || 1; } return obj; }, dataNum: function (data, mod, explict, postProcess) { var dataNum = data*1; if (mod) { if (postProcess) { return data ? mod(data)*1 : data; } else { return data ? mod(dataNum) : data; } } else if (!explict){ return data ? dataNum : data; } else { return (data && typeof data !== "undefined") ? dataNum : data; } }, timeDataProcess: function (obj) { var timeObj = {}; for (var x in obj.data) { if (obj.data.hasOwnProperty(x)) { timeObj[x] = obj.ignore[x] ? obj.data[x] : utils.dataNum(obj.data[x], obj.mods[x], obj.explict[x], obj.postProcess[x]); } } if (obj.data.secmins) { obj.data.secmins = obj.data.secmins.replace(",", ".") * 60; if (!timeObj.minutes) { timeObj.minutes = obj.data.secmins; } else if (!timeObj.seconds) { timeObj.seconds = obj.data.secmins; } delete obj.secmins; } return timeObj; }, buildTimeObjectFromData: function (data) { var time = utils.timeDataProcess({ data: { year : data[1], month : data[5], day : data[7], week : data[8], dayOfYear : data[10], hours : data[15], zone_hours : data[23], zone_minutes : data[24], zone : data[21], zone_sign : data[22], weekDay : data[9], minutes: data[16], seconds: data[19], milliseconds: data[20], secmins: data[18] }, mods: { month: function(data) { return data-1; }, weekDay: function (data) { data = Math.abs(data); return (data === 7 ? 0 : data); }, minutes: function (data) { return data.replace(":",""); }, seconds: function (data) { return Math.floor( (data.replace(":","").replace(",","."))*1 ); }, milliseconds: function (data) { return (data.replace(",",".")*1000); } }, postProcess: { minutes: true, seconds: true, milliseconds: true }, explict: { zone_hours: true, zone_minutes: true }, ignore: { zone: true, zone_sign: true, secmins: true } }); return time; }, addToHash: function (hash, keys, data) { keys = keys; data = data; var len = keys.length; for (var i = 0; i < len; i++) { hash[keys[i]] = data[i]; } return hash; }, combineRegex: function (r1, r2) { return new RegExp("(("+r1.source+")\\s("+r2.source+"))"); }, getDateNthString: function(add, last, inc){ if (add) { return Date.today().addDays(inc).toString("d"); } else if (last) { return Date.today().last()[inc]().toString("d"); } }, buildRegexData: function (array) { var arr = []; var len = array.length; for (var i=0; i < len; i++) { if (Object.prototype.toString.call(array[i]) === '[object Array]') { // oldIE compat version of Array.isArray arr.push(this.combineRegex(array[i][0], array[i][1])); } else { arr.push(array[i]); } } return arr; } }; $P.processTimeObject = function (obj) { var date, dayOffset; utils.setDefaults(obj); dayOffset = ($P.isLeapYear(obj.year)) ? dayOffsets.leap : dayOffsets.standard; if (!obj.month && (obj.week || obj.dayOfYear)) { utils.getDayOfYear(obj, dayOffset); } else { obj.dayOfYear = dayOffset[obj.month] + obj.day; } date = new Date(obj.year, obj.month, obj.day, obj.hours, obj.minutes, obj.seconds, obj.milliseconds); if (obj.zone) { utils.adjustForTimeZone(obj, date); // adjust (and calculate) for timezone } return date; }; $P.ISO = { regex : /^([\+-]?\d{4}(?!\d{2}\b))((-?)((0[1-9]|1[0-2])(\3([12]\d|0[1-9]|3[01]))?|W([0-4]\d|5[0-3])(-?[1-7])?|(00[1-9]|0[1-9]\d|[12]\d{2}|3([0-5]\d|6[1-6])))([T\s]((([01]\d|2[0-4])((:?)[0-5]\d)?|24\:?00)([\.,]\d+(?!:))?)?(\17[0-5]\d([\.,]\d+)?)?\s?([zZ]|([\+-])([01]\d|2[0-3]):?([0-5]\d)?)?)?)?$/, parse : function (s) { var time, data = s.match(this.regex); if (!data || !data.length) { return null; } time = utils.buildTimeObjectFromData(data); if (!time.year || (!time.year && (!time.month && !time.day) && (!time.week && !time.dayOfYear)) ) { return null; } return $P.processTimeObject(time); } }; $P.Numeric = { isNumeric: function (e){return!isNaN(parseFloat(e))&&isFinite(e);}, regex: /\b([0-1]?[0-9])([0-3]?[0-9])([0-2]?[0-9]?[0-9][0-9])\b/i, parse: function (s) { var data, i, time = {}, order = Date.CultureInfo.dateElementOrder.split(""); if (!(this.isNumeric(s)) || // if it's non-numeric OR (s[0] === "+" && s[0] === "-")) { // It's an arithmatic string (eg +/-1000) return null; } if (s.length < 5 && s.indexOf(".") < 0 && s.indexOf("/") < 0) { // assume it's just a year. time.year = s; return $P.processTimeObject(time); } data = s.match(this.regex); if (!data || !data.length) { return null; } for (i=0; i < order.length; i++) { switch(order[i]) { case "d": time.day = data[i+1]; break; case "m": time.month = (data[i+1]-1); break; case "y": time.year = data[i+1]; break; } } return $P.processTimeObject(time); } }; $P.Normalizer = { regexData: function () { var $R = Date.CultureInfo.regexPatterns; return utils.buildRegexData([ $R.tomorrow, $R.yesterday, [$R.past, $R.mon], [$R.past, $R.tue], [$R.past, $R.wed], [$R.past, $R.thu], [$R.past, $R.fri], [$R.past, $R.sat], [$R.past, $R.sun] ]); }, basicReplaceHash : function() { var $R = Date.CultureInfo.regexPatterns; return { "January": $R.jan.source, "February": $R.feb, "March": $R.mar, "April": $R.apr, "May": $R.may, "June": $R.jun, "July": $R.jul, "August": $R.aug, "September": $R.sep, "October": $R.oct, "November": $R.nov, "December": $R.dec, "": /\bat\b/gi, " ": /\s{2,}/, "am": $R.inTheMorning, "9am": $R.thisMorning, "pm": $R.inTheEvening, "7pm":$R.thisEvening }; }, keys : function(){ return [ utils.getDateNthString(true, false, 1), // tomorrow utils.getDateNthString(true, false, -1), // yesterday utils.getDateNthString(false, true, "monday"), //last mon utils.getDateNthString(false, true, "tuesday"), //last tues utils.getDateNthString(false, true, "wednesday"), //last wed utils.getDateNthString(false, true, "thursday"), //last thurs utils.getDateNthString(false, true, "friday"), //last fri utils.getDateNthString(false, true, "saturday"), //last sat utils.getDateNthString(false, true, "sunday") //last sun ]; }, buildRegexFunctions: function () { var $R = Date.CultureInfo.regexPatterns; var __ = Date.i18n.__; var tomorrowRE = new RegExp("(\\b\\d\\d?("+__("AM")+"|"+__("PM")+")? )("+$R.tomorrow.source.slice(1)+")", "i"); // adapted tomorrow regex for AM PM relative dates var todayRE = new RegExp($R.today.source + "(?!\\s*([+-]))\\b"); // today, but excludes the math operators (eg "today + 2h") this.replaceFuncs = [ [todayRE, function (full) { return (full.length > 1) ? Date.today().toString("d") : full; }], [tomorrowRE, function(full, m1) { var t = Date.today().addDays(1).toString("d"); return (t + " " + m1); }], [$R.amThisMorning, function(str, am){return am;}], [$R.pmThisEvening, function(str, pm){return pm;}] ]; }, buildReplaceData: function () { this.buildRegexFunctions(); this.replaceHash = utils.addToHash(this.basicReplaceHash(), this.keys(), this.regexData()); }, stringReplaceFuncs: function (s) { for (var i=0; i < this.replaceFuncs.length; i++) { s = s.replace(this.replaceFuncs[i][0], this.replaceFuncs[i][1]); } return s; }, parse: function (s) { s = this.stringReplaceFuncs(s); s = utils.multiReplace(s, this.replaceHash); try { var n = s.split(/([\s\-\.\,\/\x27]+)/); if (n.length === 3 && $P.Numeric.isNumeric(n[0]) && $P.Numeric.isNumeric(n[2]) && (n[2].length >= 4)) { // ok, so we're dealing with x/year. But that's not a full date. // This fixes wonky dateElementOrder parsing when set to dmy order. if (Date.CultureInfo.dateElementOrder[0] === "d") { s = "1/" + n[0] + "/" + n[2]; // set to 1st of month and normalize the seperator } } } catch (e) {} return s; } }; $P.Normalizer.buildReplaceData(); }()); (function () { var $P = Date.Parsing; var _ = $P.Operators = { // // Tokenizers // rtoken: function (r) { // regex token return function (s) { var mx = s.match(r); if (mx) { return ([ mx[0], s.substring(mx[0].length) ]); } else { throw new $P.Exception(s); } }; }, token: function () { // whitespace-eating token return function (s) { return _.rtoken(new RegExp("^\\s*" + s + "\\s*"))(s); }; }, stoken: function (s) { // string token return _.rtoken(new RegExp("^" + s)); }, // Atomic Operators until: function (p) { return function (s) { var qx = [], rx = null; while (s.length) { try { rx = p.call(this, s); } catch (e) { qx.push(rx[0]); s = rx[1]; continue; } break; } return [ qx, s ]; }; }, many: function (p) { return function (s) { var rx = [], r = null; while (s.length) { try { r = p.call(this, s); } catch (e) { return [ rx, s ]; } rx.push(r[0]); s = r[1]; } return [ rx, s ]; }; }, // generator operators -- see below optional: function (p) { return function (s) { var r = null; try { r = p.call(this, s); } catch (e) { return [ null, s ]; } return [ r[0], r[1] ]; }; }, not: function (p) { return function (s) { try { p.call(this, s); } catch (e) { return [null, s]; } throw new $P.Exception(s); }; }, ignore: function (p) { return p ? function (s) { var r = null; r = p.call(this, s); return [null, r[1]]; } : null; }, product: function () { var px = arguments[0], qx = Array.prototype.slice.call(arguments, 1), rx = []; for (var i = 0 ; i < px.length ; i++) { rx.push(_.each(px[i], qx)); } return rx; }, cache: function (rule) { var cache = {}, cache_length = 0, cache_keys = [], CACHE_MAX = Date.Config.CACHE_MAX || 100000, r = null; var cacheCheck = function () { if (cache_length === CACHE_MAX) { // kill several keys, don't want to have to do this all the time... for (var i=0; i < 10; i++) { var key = cache_keys.shift(); if (key) { delete cache[key]; cache_length--; } } } }; return function (s) { cacheCheck(); try { r = cache[s] = (cache[s] || rule.call(this, s)); } catch (e) { r = cache[s] = e; } cache_length++; cache_keys.push(s); if (r instanceof $P.Exception) { throw r; } else { return r; } }; }, // vector operators -- see below any: function () { var px = arguments; return function (s) { var r = null; for (var i = 0; i < px.length; i++) { if (px[i] == null) { continue; } try { r = (px[i].call(this, s)); } catch (e) { r = null; } if (r) { return r; } } throw new $P.Exception(s); }; }, each: function () { var px = arguments; return function (s) { var rx = [], r = null; for (var i = 0; i < px.length ; i++) { if (px[i] == null) { continue; } try { r = (px[i].call(this, s)); } catch (e) { throw new $P.Exception(s); } rx.push(r[0]); s = r[1]; } return [ rx, s]; }; }, all: function () { var px = arguments, _ = _; return _.each(_.optional(px)); }, // delimited operators sequence: function (px, d, c) { d = d || _.rtoken(/^\s*/); c = c || null; if (px.length === 1) { return px[0]; } return function (s) { var r = null, q = null; var rx = []; for (var i = 0; i < px.length ; i++) { try { r = px[i].call(this, s); } catch (e) { break; } rx.push(r[0]); try { q = d.call(this, r[1]); } catch (ex) { q = null; break; } s = q[1]; } if (!r) { throw new $P.Exception(s); } if (q) { throw new $P.Exception(q[1]); } if (c) { try { r = c.call(this, r[1]); } catch (ey) { throw new $P.Exception(r[1]); } } return [ rx, (r?r[1]:s) ]; }; }, // // Composite Operators // between: function (d1, p, d2) { d2 = d2 || d1; var _fn = _.each(_.ignore(d1), p, _.ignore(d2)); return function (s) { var rx = _fn.call(this, s); return [[rx[0][0], r[0][2]], rx[1]]; }; }, list: function (p, d, c) { d = d || _.rtoken(/^\s*/); c = c || null; return (p instanceof Array ? _.each(_.product(p.slice(0, -1), _.ignore(d)), p.slice(-1), _.ignore(c)) : _.each(_.many(_.each(p, _.ignore(d))), px, _.ignore(c))); }, set: function (px, d, c) { d = d || _.rtoken(/^\s*/); c = c || null; return function (s) { // r is the current match, best the current 'best' match // which means it parsed the most amount of input var r = null, p = null, q = null, rx = null, best = [[], s], last = false; // go through the rules in the given set for (var i = 0; i < px.length ; i++) { // last is a flag indicating whether this must be the last element // if there is only 1 element, then it MUST be the last one q = null; p = null; r = null; last = (px.length === 1); // first, we try simply to match the current pattern // if not, try the next pattern try { r = px[i].call(this, s); } catch (e) { continue; } // since we are matching against a set of elements, the first // thing to do is to add r[0] to matched elements rx = [[r[0]], r[1]]; // if we matched and there is still input to parse and // we don't already know this is the last element, // we're going to next check for the delimiter ... // if there's none, or if there's no input left to parse // than this must be the last element after all ... if (r[1].length > 0 && ! last) { try { q = d.call(this, r[1]); } catch (ex) { last = true; } } else { last = true; } // if we parsed the delimiter and now there's no more input, // that means we shouldn't have parsed the delimiter at all // so don't update r and mark this as the last element ... if (!last && q[1].length === 0) { last = true; } // so, if this isn't the last element, we're going to see if // we can get any more matches from the remaining (unmatched) // elements ... if (!last) { // build a list of the remaining rules we can match against, // i.e., all but the one we just matched against var qx = []; for (var j = 0; j < px.length ; j++) { if (i !== j) { qx.push(px[j]); } } // now invoke recursively set with the remaining input // note that we don't include the closing delimiter ... // we'll check for that ourselves at the end p = _.set(qx, d).call(this, q[1]); // if we got a non-empty set as a result ... // (otw rx already contains everything we want to match) if (p[0].length > 0) { // update current result, which is stored in rx ... // basically, pick up the remaining text from p[1] // and concat the result from p[0] so that we don't // get endless nesting ... rx[0] = rx[0].concat(p[0]); rx[1] = p[1]; } } // at this point, rx either contains the last matched element // or the entire matched set that starts with this element. // now we just check to see if this variation is better than // our best so far, in terms of how much of the input is parsed if (rx[1].length < best[1].length) { best = rx; } // if we've parsed all the input, then we're finished if (best[1].length === 0) { break; } } // so now we've either gone through all the patterns trying them // as the initial match; or we found one that parsed the entire // input string ... // if best has no matches, just return empty set ... if (best[0].length === 0) { return best; } // if a closing delimiter is provided, then we have to check it also if (c) { // we try this even if there is no remaining input because the pattern // may well be optional or match empty input ... try { q = c.call(this, best[1]); } catch (ey) { throw new $P.Exception(best[1]); } // it parsed ... be sure to update the best match remaining input best[1] = q[1]; } // if we're here, either there was no closing delimiter or we parsed it // so now we have the best match; just return it! return best; }; }, forward: function (gr, fname) { return function (s) { return gr[fname].call(this, s); }; }, // // Translation Operators // replace: function (rule, repl) { return function (s) { var r = rule.call(this, s); return [repl, r[1]]; }; }, process: function (rule, fn) { return function (s) { var r = rule.call(this, s); return [fn.call(this, r[0]), r[1]]; }; }, min: function (min, rule) { return function (s) { var rx = rule.call(this, s); if (rx[0].length < min) { throw new $P.Exception(s); } return rx; }; } }; // Generator Operators And Vector Operators // Generators are operators that have a signature of F(R) => R, // taking a given rule and returning another rule, such as // ignore, which parses a given rule and throws away the result. // Vector operators are those that have a signature of F(R1,R2,...) => R, // take a list of rules and returning a new rule, such as each. // Generator operators are converted (via the following _generator // function) into functions that can also take a list or array of rules // and return an array of new rules as though the function had been // called on each rule in turn (which is what actually happens). // This allows generators to be used with vector operators more easily. // Example: // each(ignore(foo, bar)) instead of each(ignore(foo), ignore(bar)) // This also turns generators into vector operators, which allows // constructs like: // not(cache(foo, bar)) var _generator = function (op) { function gen() { var args = null, rx = [], px, i; if (arguments.length > 1) { args = Array.prototype.slice.call(arguments); } else if (arguments[0] instanceof Array) { args = arguments[0]; } if (args) { px = args.shift(); if (px.length > 0) { args.unshift(px[i]); rx.push(op.apply(null, args)); args.shift(); return rx; } } else { return op.apply(null, arguments); } } return gen; }; var gx = "optional not ignore cache".split(/\s/); for (var i = 0 ; i < gx.length ; i++) { _[gx[i]] = _generator(_[gx[i]]); } var _vector = function (op) { return function () { if (arguments[0] instanceof Array) { return op.apply(null, arguments[0]); } else { return op.apply(null, arguments); } }; }; var vx = "each any all".split(/\s/); for (var j = 0 ; j < vx.length ; j++) { _[vx[j]] = _vector(_[vx[j]]); } }()); (function () { var $D = Date; var flattenAndCompact = function (ax) { var rx = []; for (var i = 0; i < ax.length; i++) { if (ax[i] instanceof Array) { rx = rx.concat(flattenAndCompact(ax[i])); } else { if (ax[i]) { rx.push(ax[i]); } } } return rx; }; var parseMeridian = function () { if (this.meridian && (this.hour || this.hour === 0)) { if (this.meridian === "a" && this.hour > 11 && Date.Config.strict24hr){ throw "Invalid hour and meridian combination"; } else if (this.meridian === "p" && this.hour < 12 && Date.Config.strict24hr){ throw "Invalid hour and meridian combination"; } else if (this.meridian === "p" && this.hour < 12) { this.hour = this.hour + 12; } else if (this.meridian === "a" && this.hour === 12) { this.hour = 0; } } }; var setDefaults = function () { var now = new Date(); if ((this.hour || this.minute) && (!this.month && !this.year && !this.day)) { this.day = now.getDate(); } if (!this.year) { this.year = now.getFullYear(); } if (!this.month && this.month !== 0) { this.month = now.getMonth(); } if (!this.day) { this.day = 1; } if (!this.hour) { this.hour = 0; } if (!this.minute) { this.minute = 0; } if (!this.second) { this.second = 0; } if (!this.millisecond) { this.millisecond = 0; } }; var finishUtils = { getToday: function () { if (this.now || "hour minute second".indexOf(this.unit) !== -1) { return new Date(); } else { return $D.today(); } }, setDaysFromWeekday: function (today, orient){ var gap; orient = orient || 1; this.unit = "day"; gap = ($D.getDayNumberFromName(this.weekday) - today.getDay()); this.days = gap ? ((gap + (orient * 7)) % 7) : (orient * 7); return this; }, setMonthsFromMonth: function (today, orient) { var gap; orient = orient || 1; this.unit = "month"; gap = (this.month - today.getMonth()); this.months = gap ? ((gap + (orient * 12)) % 12) : (orient * 12); this.month = null; return this; }, setDMYFromWeekday: function () { var d = Date[this.weekday](); this.day = d.getDate(); if (!this.month) { this.month = d.getMonth(); } this.year = d.getFullYear(); return this; }, setUnitValue: function (orient) { if (!this.value && this.operator && this.operator !== null && this[this.unit + "s"] && this[this.unit + "s"] !== null) { this[this.unit + "s"] = this[this.unit + "s"] + ((this.operator === "add") ? 1 : -1) + (this.value||0) * orient; } else if (this[this.unit + "s"] == null || this.operator != null) { if (!this.value) { this.value = 1; } this[this.unit + "s"] = this.value * orient; } }, generateDateFromWeeks: function () { var weekday = (this.weekday !== undefined) ? this.weekday : "today"; var d = Date[weekday]().addWeeks(this.weeks); if (this.now) { d.setTimeToNow(); } return d; } }; $D.Translator = { hour: function (s) { return function () { this.hour = Number(s); }; }, minute: function (s) { return function () { this.minute = Number(s); }; }, second: function (s) { return function () { this.second = Number(s); }; }, /* for ss.s format */ secondAndMillisecond: function (s) { return function () { var mx = s.match(/^([0-5][0-9])\.([0-9]{1,3})/); this.second = Number(mx[1]); this.millisecond = Number(mx[2]); }; }, meridian: function (s) { return function () { this.meridian = s.slice(0, 1).toLowerCase(); }; }, timezone: function (s) { return function () { var n = s.replace(/[^\d\+\-]/g, ""); if (n.length) { this.timezoneOffset = Number(n); } else { this.timezone = s.toLowerCase(); } }; }, day: function (x) { var s = x[0]; return function () { this.day = Number(s.match(/\d+/)[0]); if (this.day < 1) { throw "invalid day"; } }; }, month: function (s) { return function () { this.month = (s.length === 3) ? "jan feb mar apr may jun jul aug sep oct nov dec".indexOf(s)/4 : Number(s) - 1; if (this.month < 0) { throw "invalid month"; } }; }, year: function (s) { return function () { var n = Number(s); this.year = ((s.length > 2) ? n : (n + (((n + 2000) < Date.CultureInfo.twoDigitYearMax) ? 2000 : 1900))); }; }, rday: function (s) { return function () { switch (s) { case "yesterday": this.days = -1; break; case "tomorrow": this.days = 1; break; case "today": this.days = 0; break; case "now": this.days = 0; this.now = true; break; } }; }, finishExact: function (x) { var d; x = (x instanceof Array) ? x : [x]; for (var i = 0 ; i < x.length ; i++) { if (x[i]) { x[i].call(this); } } setDefaults.call(this); parseMeridian.call(this); if (this.day > $D.getDaysInMonth(this.year, this.month)) { throw new RangeError(this.day + " is not a valid value for days."); } d = new Date(this.year, this.month, this.day, this.hour, this.minute, this.second, this.millisecond); if (this.year < 100) { d.setFullYear(this.year); // means years less that 100 are process correctly. JS will parse it otherwise as 1900-1999. } if (this.timezone) { d.set({ timezone: this.timezone }); } else if (this.timezoneOffset) { d.set({ timezoneOffset: this.timezoneOffset }); } return d; }, finish: function (x) { var today, expression, orient, temp; x = (x instanceof Array) ? flattenAndCompact(x) : [ x ]; if (x.length === 0) { return null; } for (var i = 0 ; i < x.length ; i++) { if (typeof x[i] === "function") { x[i].call(this); } } if (this.now && !this.unit && !this.operator) { return new Date(); } else { today = finishUtils.getToday.call(this); } expression = !!(this.days && this.days !== null || this.orient || this.operator); orient = ((this.orient === "past" || this.operator === "subtract") ? -1 : 1); if (this.month && this.unit === "week") { this.value = this.month + 1; delete this.month; delete this.day; } if ((this.month || this.month === 0) && "year day hour minute second".indexOf(this.unit) !== -1) { if (!this.value) { this.value = this.month + 1; } this.month = null; expression = true; } if (!expression && this.weekday && !this.day && !this.days) { finishUtils.setDMYFromWeekday.call(this); } if (expression && this.weekday && this.unit !== "month" && this.unit !== "week") { finishUtils.setDaysFromWeekday.call(this, today, orient); } if (this.weekday && this.unit !== "week" && !this.day && !this.days) { temp = Date[this.weekday](); this.day = temp.getDate(); if (temp.getMonth() !== today.getMonth()) { this.month = temp.getMonth(); } } if (this.month && this.unit === "day" && this.operator) { if (!this.value) { this.value = (this.month + 1); } this.month = null; } if (this.value != null && this.month != null && this.year != null) { this.day = this.value * 1; } if (this.month && !this.day && this.value) { today.set({ day: this.value * 1 }); if (!expression) { this.day = this.value * 1; } } if (!this.month && this.value && this.unit === "month" && !this.now) { this.month = this.value; expression = true; } if (expression && (this.month || this.month === 0) && this.unit !== "year") { finishUtils.setMonthsFromMonth.call(this, today, orient); } if (!this.unit) { this.unit = "day"; } finishUtils.setUnitValue.call(this, orient); parseMeridian.call(this); if ((this.month || this.month === 0) && !this.day) { this.day = 1; } if (!this.orient && !this.operator && this.unit === "week" && this.value && !this.day && !this.month) { return Date.today().setWeek(this.value); } if (this.unit === "week" && this.weeks && !this.day && !this.month) { return finishUtils.generateDateFromWeeks.call(this); } if (expression && this.timezone && this.day && this.days) { this.day = this.days; } if (expression){ today.add(this); } else { today.set(this); } if (this.timezone) { this.timezone = this.timezone.toUpperCase(); var offset = $D.getTimezoneOffset(this.timezone); var timezone; if (today.hasDaylightSavingTime()) { // lets check that we're being sane with timezone setting timezone = $D.getTimezoneAbbreviation(offset, today.isDaylightSavingTime()); if (timezone !== this.timezone) { // bugger, we're in a place where things like EST vs EDT matters. if (today.isDaylightSavingTime()) { today.addHours(-1); } else { today.addHours(1); } } } today.setTimezoneOffset(offset); } return today; } }; }()); (function () { var $D = Date; $D.Grammar = {}; var _ = $D.Parsing.Operators, g = $D.Grammar, t = $D.Translator, _fn; // Allow rolling up into general purpose rules _fn = function () { return _.each(_.any.apply(null, arguments), _.not(g.ctoken2("timeContext"))); }; g.datePartDelimiter = _.rtoken(/^([\s\-\.\,\/\x27]+)/); g.timePartDelimiter = _.stoken(":"); g.whiteSpace = _.rtoken(/^\s*/); g.generalDelimiter = _.rtoken(/^(([\s\,]|at|@|on)+)/); var _C = {}; g.ctoken = function (keys) { var fn = _C[keys]; if (! fn) { var c = Date.CultureInfo.regexPatterns; var kx = keys.split(/\s+/), px = []; for (var i = 0; i < kx.length ; i++) { px.push(_.replace(_.rtoken(c[kx[i]]), kx[i])); } fn = _C[keys] = _.any.apply(null, px); } return fn; }; g.ctoken2 = function (key) { return _.rtoken(Date.CultureInfo.regexPatterns[key]); }; var cacheProcessRtoken = function (key, token, type, eachToken) { if (eachToken) { g[key] = _.cache(_.process(_.each(_.rtoken(token),_.optional(g.ctoken2(eachToken))), type)); } else { g[key] = _.cache(_.process(_.rtoken(token), type)); } }; var cacheProcessCtoken = function (token, type) { return _.cache(_.process(g.ctoken2(token), type)); }; var _F = {}; //function cache var _get = function (f) { _F[f] = (_F[f] || g.format(f)[0]); return _F[f]; }; g.allformats = function (fx) { var rx = []; if (fx instanceof Array) { for (var i = 0; i < fx.length; i++) { rx.push(_get(fx[i])); } } else { rx.push(_get(fx)); } return rx; }; g.formats = function (fx) { if (fx instanceof Array) { var rx = []; for (var i = 0 ; i < fx.length ; i++) { rx.push(_get(fx[i])); } return _.any.apply(null, rx); } else { return _get(fx); } }; var grammarFormats = { timeFormats: function(){ var i, RTokenKeys = [ "h", "hh", "H", "HH", "m", "mm", "s", "ss", "ss.s", "z", "zz" ], RToken = [ /^(0[0-9]|1[0-2]|[1-9])/, /^(0[0-9]|1[0-2])/, /^([0-1][0-9]|2[0-3]|[0-9])/, /^([0-1][0-9]|2[0-3])/, /^([0-5][0-9]|[0-9])/, /^[0-5][0-9]/, /^([0-5][0-9]|[0-9])/, /^[0-5][0-9]/, /^[0-5][0-9]\.[0-9]{1,3}/, /^((\+|\-)\s*\d\d\d\d)|((\+|\-)\d\d\:?\d\d)/, /^((\+|\-)\s*\d\d\d\d)|((\+|\-)\d\d\:?\d\d)/ ], tokens = [ t.hour, t.hour, t.hour, t.hour, t.minute, t.minute, t.second, t.second, t.secondAndMillisecond, t.timezone, t.timezone ]; for (i=0; i < RTokenKeys.length; i++) { cacheProcessRtoken(RTokenKeys[i], RToken[i], tokens[i]); } g.hms = _.cache(_.sequence([g.H, g.m, g.s], g.timePartDelimiter)); g.t = cacheProcessCtoken("shortMeridian", t.meridian); g.tt = cacheProcessCtoken("longMeridian", t.meridian); g.zzz = cacheProcessCtoken("timezone", t.timezone); g.timeSuffix = _.each(_.ignore(g.whiteSpace), _.set([ g.tt, g.zzz ])); g.time = _.each(_.optional(_.ignore(_.stoken("T"))), g.hms, g.timeSuffix); }, dateFormats: function () { // pre-loaded rules for different date part order preferences var _setfn = function () { return _.set(arguments, g.datePartDelimiter); }; var i, RTokenKeys = [ "d", "dd", "M", "MM", "y", "yy", "yyy", "yyyy" ], RToken = [ /^([0-2]\d|3[0-1]|\d)/, /^([0-2]\d|3[0-1])/, /^(1[0-2]|0\d|\d)/, /^(1[0-2]|0\d)/, /^(\d+)/, /^(\d\d)/, /^(\d\d?\d?\d?)/, /^(\d\d\d\d)/ ], tokens = [ t.day, t.day, t.month, t.month, t.year, t.year, t.year, t.year ], eachToken = [ "ordinalSuffix", "ordinalSuffix" ]; for (i=0; i < RTokenKeys.length; i++) { cacheProcessRtoken(RTokenKeys[i], RToken[i], tokens[i], eachToken[i]); } g.MMM = g.MMMM = _.cache(_.process(g.ctoken("jan feb mar apr may jun jul aug sep oct nov dec"), t.month)); g.ddd = g.dddd = _.cache(_.process(g.ctoken("sun mon tue wed thu fri sat"), function (s) { return function () { this.weekday = s; }; } )); g.day = _fn(g.d, g.dd); g.month = _fn(g.M, g.MMM); g.year = _fn(g.yyyy, g.yy); g.mdy = _setfn(g.ddd, g.month, g.day, g.year); g.ymd = _setfn(g.ddd, g.year, g.month, g.day); g.dmy = _setfn(g.ddd, g.day, g.month, g.year); g.date = function (s) { return ((g[Date.CultureInfo.dateElementOrder] || g.mdy).call(this, s)); }; }, relative: function () { // relative date / time expressions g.orientation = _.process(g.ctoken("past future"), function (s) { return function () { this.orient = s; }; } ); g.operator = _.process(g.ctoken("add subtract"), function (s) { return function () { this.operator = s; }; } ); g.rday = _.process(g.ctoken("yesterday tomorrow today now"), t.rday); g.unit = _.process(g.ctoken("second minute hour day week month year"), function (s) { return function () { this.unit = s; }; } ); } }; g.buildGrammarFormats = function () { // these need to be rebuilt every time the language changes. _C = {}; grammarFormats.timeFormats(); grammarFormats.dateFormats(); grammarFormats.relative(); g.value = _.process(_.rtoken(/^([-+]?\d+)?(st|nd|rd|th)?/), function (s) { return function () { this.value = s.replace(/\D/g, ""); }; } ); g.expression = _.set([g.rday, g.operator, g.value, g.unit, g.orientation, g.ddd, g.MMM ]); g.format = _.process(_.many( _.any( // translate format specifiers into grammar rules _.process( _.rtoken(/^(dd?d?d?(?!e)|MM?M?M?|yy?y?y?|hh?|HH?|mm?|ss?|tt?|zz?z?)/), function (fmt) { if (g[fmt]) { return g[fmt]; } else { throw $D.Parsing.Exception(fmt); } } ), // translate separator tokens into token rules _.process(_.rtoken(/^[^dMyhHmstz]+/), // all legal separators function (s) { return _.ignore(_.stoken(s)); } ) ) ), // construct the parser ... function (rules) { return _.process(_.each.apply(null, rules), t.finishExact); } ); // starting rule for general purpose grammar g._start = _.process(_.set([ g.date, g.time, g.expression ], g.generalDelimiter, g.whiteSpace), t.finish); }; g.buildGrammarFormats(); // parsing date format specifiers - ex: "h:m:s tt" // this little guy will generate a custom parser based // on the format string, ex: g.format("h:m:s tt") // check for these formats first g._formats = g.formats([ "\"yyyy-MM-ddTHH:mm:ssZ\"", "yyyy-MM-ddTHH:mm:ss.sz", "yyyy-MM-ddTHH:mm:ssZ", "yyyy-MM-ddTHH:mm:ssz", "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-ddTHH:mmZ", "yyyy-MM-ddTHH:mmz", "yyyy-MM-ddTHH:mm", "ddd, MMM dd, yyyy H:mm:ss tt", "ddd MMM d yyyy HH:mm:ss zzz", "MMddyyyy", "ddMMyyyy", "Mddyyyy", "ddMyyyy", "Mdyyyy", "dMyyyy", "yyyy", "Mdyy", "dMyy", "d" ]); // real starting rule: tries selected formats first, // then general purpose rule g.start = function (s) { try { var r = g._formats.call({}, s); if (r[1].length === 0) { return r; } } catch (e) {} return g._start.call({}, s); }; }()); (function () { var $D = Date; /** * @desc Converts the specified string value into its JavaScript Date equivalent using CultureInfo specific format information. * * Example

	///////////
	// Dates //
	///////////

	// 15-Oct-2004
	var d1 = Date.parse("10/15/2004");

	// 15-Oct-2004
	var d1 = Date.parse("15-Oct-2004");

	// 15-Oct-2004
	var d1 = Date.parse("2004.10.15");

	//Fri Oct 15, 2004
	var d1 = Date.parse("Fri Oct 15, 2004");

	///////////
	// Times //
	///////////

	// Today at 10 PM.
	var d1 = Date.parse("10 PM");

	// Today at 10:30 PM.
	var d1 = Date.parse("10:30 P.M.");

	// Today at 6 AM.
	var d1 = Date.parse("06am");

	/////////////////////
	// Dates and Times //
	/////////////////////

	// 8-July-2004 @ 10:30 PM
	var d1 = Date.parse("July 8th, 2004, 10:30 PM");

	// 1-July-2004 @ 10:30 PM
	var d1 = Date.parse("2004-07-01T22:30:00");

	////////////////////
	// Relative Dates //
	////////////////////

	// Returns today's date. The string "today" is culture specific.
	var d1 = Date.parse("today");

	// Returns yesterday's date. The string "yesterday" is culture specific.
	var d1 = Date.parse("yesterday");

	// Returns the date of the next thursday.
	var d1 = Date.parse("Next thursday");

	// Returns the date of the most previous monday.
	var d1 = Date.parse("last monday");

	// Returns today's day + one year.
	var d1 = Date.parse("next year");

	///////////////
	// Date Math //
	///////////////

	// Today + 2 days
	var d1 = Date.parse("t+2");

	// Today + 2 days
	var d1 = Date.parse("today + 2 days");

	// Today + 3 months
	var d1 = Date.parse("t+3m");

	// Today - 1 year
	var d1 = Date.parse("today - 1 year");

	// Today - 1 year
	var d1 = Date.parse("t-1y"); 


	/////////////////////////////
	// Partial Dates and Times //
	/////////////////////////////

	// July 15th of this year.
	var d1 = Date.parse("July 15");

	// 15th day of current day and year.
	var d1 = Date.parse("15");

	// July 1st of current year at 10pm.
	var d1 = Date.parse("7/1 10pm");
	
* * @param {String} The string value to convert into a Date object [Required] * @return {Date} A Date object or null if the string cannot be converted into a Date. */ var parseUtils = { removeOrds: function (s) { ords = s.match(/\b(\d+)(?:st|nd|rd|th)\b/); // find ordinal matches s = ((ords && ords.length === 2) ? s.replace(ords[0], ords[1]) : s); return s; }, grammarParser: function (s) { var r = null; try { r = $D.Grammar.start.call({}, s.replace(/^\s*(\S*(\s+\S+)*)\s*$/, "$1")); } catch (e) { return null; } return ((r[1].length === 0) ? r[0] : null); }, nativeFallback: function(s) { var t; try { // ok we haven't parsed it, last ditch attempt with the built-in parser. t = Date._parse(s); return (t || t === 0) ? new Date(t) : null; } catch (e) { return null; } } }; function parse (s) { var d; if (!s) { return null; } if (s instanceof Date) { return s.clone(); } if (s.length >= 4 && s.charAt(0) !== "0" && s.charAt(0) !== "+"&& s.charAt(0) !== "-") { // ie: 2004 will pass, 0800 won't. // Start with specific formats d = $D.Parsing.ISO.parse(s) || $D.Parsing.Numeric.parse(s); } if (d instanceof Date && !isNaN(d.getTime())) { return d; } else { // find ordinal dates (1st, 3rd, 8th, etc and remove them as they cause parsing issues) s = $D.Parsing.Normalizer.parse(parseUtils.removeOrds(s)); d = parseUtils.grammarParser(s); if (d !== null) { return d; } else { return parseUtils.nativeFallback(s); } } } if (!$D._parse) { $D._parse = $D.parse; } $D.parse = parse; Date.getParseFunction = function (fx) { var fns = Date.Grammar.allformats(fx); return function (s) { var r = null; for (var i = 0; i < fns.length; i++) { try { r = fns[i].call({}, s); } catch (e) { continue; } if (r[1].length === 0) { return r[0]; } } return null; }; }; /** * Converts the specified string value into its JavaScript Date equivalent using the specified format {String} or formats {Array} and the CultureInfo specific format information. * The format of the string value must match one of the supplied formats exactly. * * Example

	// 15-Oct-2004
	var d1 = Date.parseExact("10/15/2004", "M/d/yyyy");

	// 15-Oct-2004
	var d1 = Date.parse("15-Oct-2004", "M-ddd-yyyy");

	// 15-Oct-2004
	var d1 = Date.parse("2004.10.15", "yyyy.MM.dd");

	// Multiple formats
	var d1 = Date.parseExact("10/15/2004", ["M/d/yyyy", "MMMM d, yyyy"]);
	
* * @param {String} The string value to convert into a Date object [Required]. * @param {Object} The expected format {String} or an array of expected formats {Array} of the date string [Required]. * @return {Date} A Date object or null if the string cannot be converted into a Date. */ $D.parseExact = function (s, fx) { return $D.getParseFunction(fx)(s); }; }()); (function () { var $D = Date, $P = $D.prototype, // $C = $D.CultureInfo, // not used atm p = function (s, l) { if (!l) { l = 2; } return ("000" + s).slice(l * -1); }; /** * Converts a PHP format string to Java/.NET format string. * A PHP format string can be used with ._format or .format. * A Java/.NET format string can be used with .toString(). * The .parseExact function will only accept a Java/.NET format string * * Example * var f1 = "%m/%d/%y" * var f2 = Date.normalizeFormat(f1); // "MM/dd/yy" * * new Date().format(f1); // "04/13/08" * new Date()._format(f1); // "04/13/08" * new Date().toString(f2); // "04/13/08" * * var date = Date.parseExact("04/13/08", f2); // Sun Apr 13 2008 * * @param {String} A PHP format string consisting of one or more format spcifiers. * @return {String} The PHP format converted to a Java/.NET format string. */ var normalizerSubstitutions = { "d" : "dd", "%d": "dd", "D" : "ddd", "%a": "ddd", "j" : "dddd", "l" : "dddd", "%A": "dddd", "S" : "S", "F" : "MMMM", "%B": "MMMM", "m" : "MM", "%m": "MM", "M" : "MMM", "%b": "MMM", "%h": "MMM", "n" : "M", "Y" : "yyyy", "%Y": "yyyy", "y" : "yy", "%y": "yy", "g" : "h", "%I": "h", "G" : "H", "h" : "hh", "H" : "HH", "%H": "HH", "i" : "mm", "%M": "mm", "s" : "ss", "%S": "ss", "%r": "hh:mm tt", "%R": "H:mm", "%T": "H:mm:ss", "%X": "t", "%x": "d", "%e": "d", "%D": "MM/dd/yy", "%n": "\\n", "%t": "\\t", "e" : "z", "T" : "z", "%z": "z", "%Z": "z", "Z" : "ZZ", "N" : "u", "w" : "u", "%w": "u", "W" : "W", "%V": "W" }; var normalizer = { substitutes: function (m) { return normalizerSubstitutions[m]; }, interpreted: function (m, x) { var y; switch (m) { case "%u": return x.getDay() + 1; case "z": return x.getOrdinalNumber(); case "%j": return p(x.getOrdinalNumber(), 3); case "%U": var d1 = x.clone().set({month: 0, day: 1}).addDays(-1).moveToDayOfWeek(0), d2 = x.clone().addDays(1).moveToDayOfWeek(0, -1); return (d2 < d1) ? "00" : p((d2.getOrdinalNumber() - d1.getOrdinalNumber()) / 7 + 1); case "%W": return p(x.getWeek()); case "t": return $D.getDaysInMonth(x.getFullYear(), x.getMonth()); case "o": case "%G": return x.setWeek(x.getISOWeek()).toString("yyyy"); case "%g": return x._format("%G").slice(-2); case "a": case "%p": return t("tt").toLowerCase(); case "A": return t("tt").toUpperCase(); case "u": return p(x.getMilliseconds(), 3); case "I": return (x.isDaylightSavingTime()) ? 1 : 0; case "O": return x.getUTCOffset(); case "P": y = x.getUTCOffset(); return y.substring(0, y.length - 2) + ":" + y.substring(y.length - 2); case "B": var now = new Date(); return Math.floor(((now.getHours() * 3600) + (now.getMinutes() * 60) + now.getSeconds() + (now.getTimezoneOffset() + 60) * 60) / 86.4); case "c": return x.toISOString().replace(/\"/g, ""); case "U": return $D.strtotime("now"); case "%c": return t("d") + " " + t("t"); case "%C": return Math.floor(x.getFullYear() / 100 + 1); } }, shouldOverrideDefaults: function (m) { switch (m) { case "%e": return true; default: return false; } }, parse: function (m, context) { var formatString, c = context || new Date(); formatString = normalizer.substitutes(m); if (formatString) { return formatString; } formatString = normalizer.interpreted(m, c); if (formatString) { return formatString; } else { return m; } } }; $D.normalizeFormat = function (format, context) { return format.replace(/(%|\\)?.|%%/g, function(t){ return normalizer.parse(t, context); }); }; /** * Format a local Unix timestamp according to locale settings * * Example: * Date.strftime("%m/%d/%y", new Date()); // "04/13/08" * Date.strftime("c", "2008-04-13T17:52:03Z"); // "04/13/08" * * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @param {Number|String} The number representing the number of seconds that have elapsed since January 1, 1970 (local time). * @return {String} A string representation of the current Date object. */ $D.strftime = function (format, time) { var d = Date.parse(time); return d._format(format); }; /** * Parse any textual datetime description into a Unix timestamp. * A Unix timestamp is the number of seconds that have elapsed since January 1, 1970 (midnight UTC/GMT). * * Example: * Date.strtotime("04/13/08"); // 1208044800 * Date.strtotime("1970-01-01T00:00:00Z"); // 0 * * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @param {Object} A string or date object. * @return {String} A string representation of the current Date object. */ $D.strtotime = function (time) { var d = $D.parse(time); return Math.round($D.UTC(d.getUTCFullYear(), d.getUTCMonth(), d.getUTCDate(), d.getUTCHours(), d.getUTCMinutes(), d.getUTCSeconds(), d.getUTCMilliseconds()) / 1000); }; /** * Converts the value of the current Date object to its equivalent string representation using a PHP/Unix style of date format specifiers. * Format Specifiers * Format Description Example * ------ --------------------------------------------------------------------------- ----------------------- * %a abbreviated weekday name according to the current localed "Mon" through "Sun" * %A full weekday name according to the current localed "Sunday" through "Saturday" * %b abbreviated month name according to the current localed "Jan" through "Dec" * %B full month name according to the current locale "January" through "December" * %c preferred date and time representation for the current locale "4/13/2008 12:33 PM" * %C century number (the year divided by 100 and truncated to an integer) "00" to "99" * %d day of the month as a decimal number "01" to "31" * %D same as %m/%d/%y "04/13/08" * %e day of the month as a decimal number, a single digit is preceded by a space "1" to "31" * %g like %G, but without the century "08" * %G The 4-digit year corresponding to the ISO week number (see %V). "2008" * This has the same format and value as %Y, except that if the ISO week number * belongs to the previous or next year, that year is used instead. * %h same as %b "Jan" through "Dec" * %H hour as a decimal number using a 24-hour clock. "00" to "23" * %I hour as a decimal number using a 12-hour clock. "01" to "12" * %j day of the year as a decimal number. "001" to "366" * %m month as a decimal number. "01" to "12" * %M minute as a decimal number. "00" to "59" * %n newline character "\n" * %p either "am" or "pm" according to the given time value, or the "am" or "pm" * corresponding strings for the current locale. * %r time in a.m. and p.m. notation "8:44 PM" * %R time in 24 hour notation "20:44" * %S second as a decimal number "00" to "59" * %t tab character "\t" * %T current time, equal to %H:%M:%S "12:49:11" * %u weekday as a decimal number ["1", "7"], with "1" representing Monday "1" to "7" * %U week number of the current year as a decimal number, starting with the "0" to ("52" or "53") * first Sunday as the first day of the first week * %V The ISO 8601:1988 week number of the current year as a decimal number, "00" to ("52" or "53") * range 01 to 53, where week 1 is the first week that has at least 4 days * in the current year, and with Monday as the first day of the week. * (Use %G or %g for the year component that corresponds to the week number * for the specified timestamp.) * %W week number of the current year as a decimal number, starting with the "00" to ("52" or "53") * first Monday as the first day of the first week * %w day of the week as a decimal, Sunday being "0" "0" to "6" * %x preferred date representation for the current locale without the time "4/13/2008" * %X preferred time representation for the current locale without the date "12:53:05" * %y year as a decimal number without a century "00" "99" * %Y year as a decimal number including the century "2008" * %Z time zone or name or abbreviation "UTC", "EST", "PST" * %z same as %Z * %% a literal "%" characters "%" * d Day of the month, 2 digits with leading zeros "01" to "31" * D A textual representation of a day, three letters "Mon" through "Sun" * j Day of the month without leading zeros "1" to "31" * l A full textual representation of the day of the week (lowercase "L") "Sunday" through "Saturday" * N ISO-8601 numeric representation of the day of the week (added in PHP 5.1.0) "1" (for Monday) through "7" (for Sunday) * S English ordinal suffix for the day of the month, 2 characters "st", "nd", "rd" or "th". Works well with j * w Numeric representation of the day of the week "0" (for Sunday) through "6" (for Saturday) * z The day of the year (starting from "0") "0" through "365" * W ISO-8601 week number of year, weeks starting on Monday "00" to ("52" or "53") * F A full textual representation of a month, such as January or March "January" through "December" * m Numeric representation of a month, with leading zeros "01" through "12" * M A short textual representation of a month, three letters "Jan" through "Dec" * n Numeric representation of a month, without leading zeros "1" through "12" * t Number of days in the given month "28" through "31" * L Whether it's a leap year "1" if it is a leap year, "0" otherwise * o ISO-8601 year number. This has the same value as Y, except that if the "2008" * ISO week number (W) belongs to the previous or next year, that year * is used instead. * Y A full numeric representation of a year, 4 digits "2008" * y A two digit representation of a year "08" * a Lowercase Ante meridiem and Post meridiem "am" or "pm" * A Uppercase Ante meridiem and Post meridiem "AM" or "PM" * B Swatch Internet time "000" through "999" * g 12-hour format of an hour without leading zeros "1" through "12" * G 24-hour format of an hour without leading zeros "0" through "23" * h 12-hour format of an hour with leading zeros "01" through "12" * H 24-hour format of an hour with leading zeros "00" through "23" * i Minutes with leading zeros "00" to "59" * s Seconds, with leading zeros "00" through "59" * u Milliseconds "54321" * e Timezone identifier "UTC", "EST", "PST" * I Whether or not the date is in daylight saving time (uppercase i) "1" if Daylight Saving Time, "0" otherwise * O Difference to Greenwich time (GMT) in hours "+0200", "-0600" * P Difference to Greenwich time (GMT) with colon between hours and minutes "+02:00", "-06:00" * T Timezone abbreviation "UTC", "EST", "PST" * Z Timezone offset in seconds. The offset for timezones west of UTC is "-43200" through "50400" * always negative, and for those east of UTC is always positive. * c ISO 8601 date "2004-02-12T15:19:21+00:00" * r RFC 2822 formatted date "Thu, 21 Dec 2000 16:01:07 +0200" * U Seconds since the Unix Epoch (January 1 1970 00:00:00 GMT) "0" * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @return {String} A string representation of the current Date object. */ var formatReplace = function (context) { return function (m) { var formatString, override = false; if (m.charAt(0) === "\\" || m.substring(0, 2) === "%%") { return m.replace("\\", "").replace("%%", "%"); } override = normalizer.shouldOverrideDefaults(m); formatString = $D.normalizeFormat(m, context); if (formatString) { return context.toString(formatString, override); } }; }; $P._format = function (format) { var formatter = formatReplace(this); if (!format) { return this._toString(); } else { return format.replace(/(%|\\)?.|%%/g, formatter); } }; if (!$P.format) { $P.format = $P._format; } }()); (function () { "use strict"; var gFn = function (attr) { return function () { return this[attr]; }; }; var sFn = function (attr) { return function (val) { this[attr] = val; return this; }; }; var attrs = ["years", "months", "days", "hours", "minutes", "seconds", "milliseconds"]; var addSetFuncs = function (context, attrs) { for (var i = 0; i < attrs.length ; i++) { var $a = attrs[i], $b = $a.slice(0, 1).toUpperCase() + $a.slice(1); context.prototype[$a] = 0; context.prototype["get" + $b] = gFn($a); context.prototype["set" + $b] = sFn($a); } }; /** * new TimeSpan(milliseconds); * new TimeSpan(days, hours, minutes, seconds); * new TimeSpan(days, hours, minutes, seconds, milliseconds); */ var TimeSpan = function (days, hours, minutes, seconds, milliseconds) { if (arguments.length === 1 && typeof days === "number") { var orient = (days < 0) ? -1 : +1; var millsLeft = Math.abs(days); this.setDays(Math.floor(millsLeft / 86400000) * orient); millsLeft = millsLeft % 86400000; this.setHours(Math.floor(millsLeft / 3600000) * orient); millsLeft = millsLeft % 3600000; this.setMinutes(Math.floor(millsLeft / 60000) * orient); millsLeft = millsLeft % 60000; this.setSeconds(Math.floor(millsLeft / 1000) * orient); millsLeft = millsLeft % 1000; this.setMilliseconds(millsLeft * orient); } else { this.set(days, hours, minutes, seconds, milliseconds); } this.getTotalMilliseconds = function () { return (this.getDays() * 86400000) + (this.getHours() * 3600000) + (this.getMinutes() * 60000) + (this.getSeconds() * 1000); }; this.compareTo = function (time) { var t1 = new Date(1970, 1, 1, this.getHours(), this.getMinutes(), this.getSeconds()), t2; if (time === null) { t2 = new Date(1970, 1, 1, 0, 0, 0); } else { t2 = new Date(1970, 1, 1, time.getHours(), time.getMinutes(), time.getSeconds()); } return (t1 < t2) ? -1 : (t1 > t2) ? 1 : 0; }; this.equals = function (time) { return (this.compareTo(time) === 0); }; this.add = function (time) { return (time === null) ? this : this.addSeconds(time.getTotalMilliseconds() / 1000); }; this.subtract = function (time) { return (time === null) ? this : this.addSeconds(-time.getTotalMilliseconds() / 1000); }; this.addDays = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 86400000)); }; this.addHours = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 3600000)); }; this.addMinutes = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 60000)); }; this.addSeconds = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 1000)); }; this.addMilliseconds = function (n) { return new TimeSpan(this.getTotalMilliseconds() + n); }; this.get12HourHour = function () { return (this.getHours() > 12) ? this.getHours() - 12 : (this.getHours() === 0) ? 12 : this.getHours(); }; this.getDesignator = function () { return (this.getHours() < 12) ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator; }; this.toString = function (format) { this._toString = function () { if (this.getDays() !== null && this.getDays() > 0) { return this.getDays() + "." + this.getHours() + ":" + this.p(this.getMinutes()) + ":" + this.p(this.getSeconds()); } else { return this.getHours() + ":" + this.p(this.getMinutes()) + ":" + this.p(this.getSeconds()); } }; this.p = function (s) { return (s.toString().length < 2) ? "0" + s : s; }; var me = this; return format ? format.replace(/dd?|HH?|hh?|mm?|ss?|tt?/g, function (format) { switch (format) { case "d": return me.getDays(); case "dd": return me.p(me.getDays()); case "H": return me.getHours(); case "HH": return me.p(me.getHours()); case "h": return me.get12HourHour(); case "hh": return me.p(me.get12HourHour()); case "m": return me.getMinutes(); case "mm": return me.p(me.getMinutes()); case "s": return me.getSeconds(); case "ss": return me.p(me.getSeconds()); case "t": return ((me.getHours() < 12) ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator).substring(0, 1); case "tt": return (me.getHours() < 12) ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator; } } ) : this._toString(); }; return this; }; addSetFuncs(TimeSpan, attrs.slice(2)); TimeSpan.prototype.set = function (days, hours, minutes, seconds, milliseconds){ this.setDays(days || this.getDays()); this.setHours(hours || this.getHours()); this.setMinutes(minutes || this.getMinutes()); this.setSeconds(seconds || this.getSeconds()); this.setMilliseconds(milliseconds || this.getMilliseconds()); }; /** * Gets the time of day for this date instances. * @return {TimeSpan} TimeSpan */ Date.prototype.getTimeOfDay = function () { return new TimeSpan(0, this.getHours(), this.getMinutes(), this.getSeconds(), this.getMilliseconds()); }; Date.TimeSpan = TimeSpan; if (typeof window !== "undefined" ) { // keeping API compatible for v1.x window.TimeSpan = TimeSpan; } }()); (function () { "use strict"; var attrs = ["years", "months", "days", "hours", "minutes", "seconds", "milliseconds"]; var gFn = function (attr) { return function () { return this[attr]; }; }; var sFn = function (attr) { return function (val) { this[attr] = val; return this; }; }; var addSetFuncs = function (context, attrs) { for (var i = 0; i < attrs.length ; i++) { var $a = attrs[i], $b = $a.slice(0, 1).toUpperCase() + $a.slice(1); context.prototype[$a] = 0; context.prototype["get" + $b] = gFn($a); context.prototype["set" + $b] = sFn($a); } }; var setMonthsAndYears = function (orient, d1, d2, context) { function inc() { d1.addMonths(-orient); context.months++; if (context.months === 12) { context.years++; context.months = 0; } } if (orient === +1) { while (d1 > d2) { inc(); } } else { while (d1 < d2) { inc(); } } context.months--; context.months *= orient; context.years *= orient; }; var adjustForDST = function(orient, startDate, endDate) { var hasDSTMismatch = (false === (startDate.isDaylightSavingTime() === endDate.isDaylightSavingTime())); if (hasDSTMismatch && orient === 1) { startDate.addHours(-1); } else if (hasDSTMismatch) { startDate.addHours(1); } }; /** * TimePeriod(startDate, endDate); * TimePeriod(years, months, days, hours, minutes, seconds, milliseconds); */ var TimePeriod = function (years, months, days, hours, minutes, seconds, milliseconds) { if (arguments.length === 7) { this.set(years, months, days, hours, minutes, seconds, milliseconds); } else if (arguments.length === 2 && arguments[0] instanceof Date && arguments[1] instanceof Date) { var startDate = arguments[0].clone(); var endDate = arguments[1].clone(); var orient = (startDate > endDate) ? +1 : -1; this.dates = { start: arguments[0].clone(), end: arguments[1].clone() }; setMonthsAndYears(orient, startDate, endDate, this); adjustForDST(orient, startDate, endDate); // // TODO - adjust for DST var diff = endDate - startDate; if (diff !== 0) { var ts = new TimeSpan(diff); this.set(this.years, this.months, ts.getDays(), ts.getHours(), ts.getMinutes(), ts.getSeconds(), ts.getMilliseconds()); } } return this; }; // create all the set functions. addSetFuncs(TimePeriod, attrs); TimePeriod.prototype.set = function (years, months, days, hours, minutes, seconds, milliseconds){ this.setYears(years || this.getYears()); this.setMonths(months || this.getMonths()); this.setDays(days || this.getDays()); this.setHours(hours || this.getHours()); this.setMinutes(minutes || this.getMinutes()); this.setSeconds(seconds || this.getSeconds()); this.setMilliseconds(milliseconds || this.getMilliseconds()); }; Date.TimePeriod = TimePeriod; if (typeof window !== "undefined") { // keeping API compatible for v1.x window.TimePeriod = TimePeriod; } }()); ================================================ FILE: build/date-smn-FI.js ================================================ /** * @overview datejs * @version 1.0.0-rc3 * @author Gregory Wild-Smith * @copyright 2015 Gregory Wild-Smith * @license MIT * @homepage https://github.com/abritinthebay/datejs */ /* * DateJS Culture String File * Country Code: smn-FI * Name: Sami (Inari) (Finland) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["smn-FI"] = { "name": "smn-FI", "englishName": "Sami (Inari) (Finland)", "nativeName": "sämikielâ (Suomâ)", "Sunday": "pasepeivi", "Monday": "vuossargâ", "Tuesday": "majebargâ", "Wednesday": "koskokko", "Thursday": "tuorâstâh", "Friday": "vástuppeivi", "Saturday": "lávárdâh", "Sun": "pa", "Mon": "vu", "Tue": "ma", "Wed": "ko", "Thu": "tu", "Fri": "vá", "Sat": "lá", "Su": "pa", "Mo": "vu", "Tu": "ma", "We": "ko", "Th": "tu", "Fr": "vá", "Sa": "lá", "S_Sun_Initial": "p", "M_Mon_Initial": "v", "T_Tue_Initial": "m", "W_Wed_Initial": "k", "T_Thu_Initial": "t", "F_Fri_Initial": "v", "S_Sat_Initial": "l", "January": "uđđâivemáánu", "February": "kuovâmáánu", "March": "njuhčâmáánu", "April": "cuáŋuimáánu", "May": "vyesimáánu", "June": "kesimáánu", "July": "syeinimáánu", "August": "porgemáánu", "September": "čohčâmáánu", "October": "roovvâdmáánu", "November": "skammâmáánu", "December": "juovlâmáánu", "Jan_Abbr": "uđiv", "Feb_Abbr": "kuov", "Mar_Abbr": "njuh", "Apr_Abbr": "cuoŋ", "May_Abbr": "vyes", "Jun_Abbr": "kesi", "Jul_Abbr": "syei", "Aug_Abbr": "porg", "Sep_Abbr": "čoh", "Oct_Abbr": "roov", "Nov_Abbr": "ska", "Dec_Abbr": "juov", "AM": "", "PM": "", "firstDayOfWeek": 1, "twoDigitYearMax": 2029, "mdy": "dmy", "M/d/yyyy": "d.M.yyyy", "dddd, MMMM dd, yyyy": "MMMM d'. p. 'yyyy", "h:mm tt": "H:mm:ss", "h:mm:ss tt": "H:mm:ss", "dddd, MMMM dd, yyyy h:mm:ss tt": "MMMM d'. p. 'yyyy H:mm:ss", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "MMMM dd", "MMMM, yyyy": "MMMM yyyy", "/jan(uary)?/": "uđđâivemáánu", "/feb(ruary)?/": "kuov(âmáánu)?", "/mar(ch)?/": "njuh(čâmáánu)?", "/apr(il)?/": "cuáŋuimáánu", "/may/": "vyes(imáánu)?", "/jun(e)?/": "kesi(máánu)?", "/jul(y)?/": "syei(nimáánu)?", "/aug(ust)?/": "porg(emáánu)?", "/sep(t(ember)?)?/": "čoh(čâmáánu)?", "/oct(ober)?/": "roov(vâdmáánu)?", "/nov(ember)?/": "ska(mmâmáánu)?", "/dec(ember)?/": "juov(lâmáánu)?", "/^su(n(day)?)?/": "^pasepeivi", "/^mo(n(day)?)?/": "^vuossargâ", "/^tu(e(s(day)?)?)?/": "^majebargâ", "/^we(d(nesday)?)?/": "^koskokko", "/^th(u(r(s(day)?)?)?)?/": "^tuorâstâh", "/^fr(i(day)?)?/": "^vástuppeivi", "/^sa(t(urday)?)?/": "^lávárdâh", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "smn-FI"; /** * @overview datejs * @version 1.0.0-rc3 * @author Gregory Wild-Smith * @copyright 2015 Gregory Wild-Smith * @license MIT * @homepage https://github.com/abritinthebay/datejs */(function () { var $D = Date; var lang = Date.CultureStrings ? Date.CultureStrings.lang : null; var loggedKeys = {}; // for debug purposes. var getText = { getFromKey: function (key, countryCode) { var output; if (Date.CultureStrings && Date.CultureStrings[countryCode] && Date.CultureStrings[countryCode][key]) { output = Date.CultureStrings[countryCode][key]; } else { output = getText.buildFromDefault(key); } if (key.charAt(0) === "/") { // Assume it's a regex output = getText.buildFromRegex(key, countryCode); } return output; }, getFromObjectValues: function (obj, countryCode) { var key, output = {}; for(key in obj) { if (obj.hasOwnProperty(key)) { output[key] = getText.getFromKey(obj[key], countryCode); } } return output; }, getFromObjectKeys: function (obj, countryCode) { var key, output = {}; for(key in obj) { if (obj.hasOwnProperty(key)) { output[getText.getFromKey(key, countryCode)] = obj[key]; } } return output; }, getFromArray: function (arr, countryCode) { var output = []; for (var i=0; i < arr.length; i++){ if (i in arr) { output[i] = getText.getFromKey(arr[i], countryCode); } } return output; }, buildFromDefault: function (key) { var output, length, split, last; switch(key) { case "name": output = "en-US"; break; case "englishName": output = "English (United States)"; break; case "nativeName": output = "English (United States)"; break; case "twoDigitYearMax": output = 2049; break; case "firstDayOfWeek": output = 0; break; default: output = key; split = key.split("_"); length = split.length; if (length > 1 && key.charAt(0) !== "/") { // if the key isn't a regex and it has a split. last = split[(length - 1)].toLowerCase(); if (last === "initial" || last === "abbr") { output = split[0]; } } break; } return output; }, buildFromRegex: function (key, countryCode) { var output; if (Date.CultureStrings && Date.CultureStrings[countryCode] && Date.CultureStrings[countryCode][key]) { output = new RegExp(Date.CultureStrings[countryCode][key], "i"); } else { output = new RegExp(key.replace(new RegExp("/", "g"),""), "i"); } return output; } }; var shallowMerge = function (obj1, obj2) { for (var attrname in obj2) { if (obj2.hasOwnProperty(attrname)) { obj1[attrname] = obj2[attrname]; } } }; var __ = function (key, language) { var countryCode = (language) ? language : lang; loggedKeys[key] = key; if (typeof key === "object") { if (key instanceof Array) { return getText.getFromArray(key, countryCode); } else { return getText.getFromObjectKeys(key, countryCode); } } else { return getText.getFromKey(key, countryCode); } }; var loadI18nScript = function (code) { // paatterned after jQuery's getScript. var url = Date.Config.i18n + code + ".js"; var head = document.getElementsByTagName("head")[0] || document.documentElement; var script = document.createElement("script"); script.src = url; var completed = false; var events = { done: function (){} // placeholder function }; // Attach handlers for all browsers script.onload = script.onreadystatechange = function() { if ( !completed && (!this.readyState || this.readyState === "loaded" || this.readyState === "complete") ) { events.done(); head.removeChild(script); } }; setTimeout(function() { head.insertBefore(script, head.firstChild); }, 0); // allows return to execute first return { done: function (cb) { events.done = function() { if (cb) { setTimeout(cb,0); } }; } }; }; var buildInfo = { buildFromMethodHash: function (obj) { var key; for(key in obj) { if (obj.hasOwnProperty(key)) { obj[key] = buildInfo[obj[key]](); } } return obj; }, timeZoneDST: function () { var DST = { "CHADT": "+1345", "NZDT": "+1300", "AEDT": "+1100", "ACDT": "+1030", "AZST": "+0500", "IRDT": "+0430", "EEST": "+0300", "CEST": "+0200", "BST": "+0100", "PMDT": "-0200", "ADT": "-0300", "NDT": "-0230", "EDT": "-0400", "CDT": "-0500", "MDT": "-0600", "PDT": "-0700", "AKDT": "-0800", "HADT": "-0900" }; return __(DST); }, timeZoneStandard: function () { var standard = { "LINT": "+1400", "TOT": "+1300", "CHAST": "+1245", "NZST": "+1200", "NFT": "+1130", "SBT": "+1100", "AEST": "+1000", "ACST": "+0930", "JST": "+0900", "CWST": "+0845", "CT": "+0800", "ICT": "+0700", "MMT": "+0630", "BST": "+0600", "NPT": "+0545", "IST": "+0530", "PKT": "+0500", "AFT": "+0430", "MSK": "+0400", "IRST": "+0330", "FET": "+0300", "EET": "+0200", "CET": "+0100", "GMT": "+0000", "UTC": "+0000", "CVT": "-0100", "GST": "-0200", "BRT": "-0300", "NST": "-0330", "AST": "-0400", "EST": "-0500", "CST": "-0600", "MST": "-0700", "PST": "-0800", "AKST": "-0900", "MIT": "-0930", "HST": "-1000", "SST": "-1100", "BIT": "-1200" }; return __(standard); }, timeZones: function (data) { var zone; data.timezones = []; for (zone in data.abbreviatedTimeZoneStandard) { if (data.abbreviatedTimeZoneStandard.hasOwnProperty(zone)) { data.timezones.push({ name: zone, offset: data.abbreviatedTimeZoneStandard[zone]}); } } for (zone in data.abbreviatedTimeZoneDST) { if (data.abbreviatedTimeZoneDST.hasOwnProperty(zone)) { data.timezones.push({ name: zone, offset: data.abbreviatedTimeZoneDST[zone], dst: true}); } } return data.timezones; }, days: function () { return __(["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"]); }, dayAbbr: function () { return __(["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"]); }, dayShortNames: function () { return __(["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"]); }, dayFirstLetters: function () { return __(["S_Sun_Initial", "M_Mon_Initial", "T_Tues_Initial", "W_Wed_Initial", "T_Thu_Initial", "F_Fri_Initial", "S_Sat_Initial"]); }, months: function () { return __(["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"]); }, monthAbbr: function () { return __(["Jan_Abbr", "Feb_Abbr", "Mar_Abbr", "Apr_Abbr", "May_Abbr", "Jun_Abbr", "Jul_Abbr", "Aug_Abbr", "Sep_Abbr", "Oct_Abbr", "Nov_Abbr", "Dec_Abbr"]); }, formatPatterns: function () { return getText.getFromObjectValues({ shortDate: "M/d/yyyy", longDate: "dddd, MMMM dd, yyyy", shortTime: "h:mm tt", longTime: "h:mm:ss tt", fullDateTime: "dddd, MMMM dd, yyyy h:mm:ss tt", sortableDateTime: "yyyy-MM-ddTHH:mm:ss", universalSortableDateTime: "yyyy-MM-dd HH:mm:ssZ", rfc1123: "ddd, dd MMM yyyy HH:mm:ss", monthDay: "MMMM dd", yearMonth: "MMMM, yyyy" }, Date.i18n.currentLanguage()); }, regex: function () { return getText.getFromObjectValues({ inTheMorning: "/( in the )(morn(ing)?)\\b/", thisMorning: "/(this )(morn(ing)?)\\b/", amThisMorning: "/(\b\\d(am)? )(this )(morn(ing)?)/", inTheEvening: "/( in the )(even(ing)?)\\b/", thisEvening: "/(this )(even(ing)?)\\b/", pmThisEvening: "/(\b\\d(pm)? )(this )(even(ing)?)/", jan: "/jan(uary)?/", feb: "/feb(ruary)?/", mar: "/mar(ch)?/", apr: "/apr(il)?/", may: "/may/", jun: "/jun(e)?/", jul: "/jul(y)?/", aug: "/aug(ust)?/", sep: "/sep(t(ember)?)?/", oct: "/oct(ober)?/", nov: "/nov(ember)?/", dec: "/dec(ember)?/", sun: "/^su(n(day)?)?/", mon: "/^mo(n(day)?)?/", tue: "/^tu(e(s(day)?)?)?/", wed: "/^we(d(nesday)?)?/", thu: "/^th(u(r(s(day)?)?)?)?/", fri: "/fr(i(day)?)?/", sat: "/^sa(t(urday)?)?/", future: "/^next/", past: "/^last|past|prev(ious)?/", add: "/^(\\+|aft(er)?|from|hence)/", subtract: "/^(\\-|bef(ore)?|ago)/", yesterday: "/^yes(terday)?/", today: "/^t(od(ay)?)?/", tomorrow: "/^tom(orrow)?/", now: "/^n(ow)?/", millisecond: "/^ms|milli(second)?s?/", second: "/^sec(ond)?s?/", minute: "/^mn|min(ute)?s?/", hour: "/^h(our)?s?/", week: "/^w(eek)?s?/", month: "/^m(onth)?s?/", day: "/^d(ay)?s?/", year: "/^y(ear)?s?/", shortMeridian: "/^(a|p)/", longMeridian: "/^(a\\.?m?\\.?|p\\.?m?\\.?)/", timezone: "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/", ordinalSuffix: "/^\\s*(st|nd|rd|th)/", timeContext: "/^\\s*(\\:|a(?!u|p)|p)/" }, Date.i18n.currentLanguage()); } }; var CultureInfo = function () { var info = getText.getFromObjectValues({ name: "name", englishName: "englishName", nativeName: "nativeName", amDesignator: "AM", pmDesignator: "PM", firstDayOfWeek: "firstDayOfWeek", twoDigitYearMax: "twoDigitYearMax", dateElementOrder: "mdy" }, Date.i18n.currentLanguage()); var constructedInfo = buildInfo.buildFromMethodHash({ dayNames: "days", abbreviatedDayNames: "dayAbbr", shortestDayNames: "dayShortNames", firstLetterDayNames: "dayFirstLetters", monthNames: "months", abbreviatedMonthNames: "monthAbbr", formatPatterns: "formatPatterns", regexPatterns: "regex", abbreviatedTimeZoneDST: "timeZoneDST", abbreviatedTimeZoneStandard: "timeZoneStandard" }); shallowMerge(info, constructedInfo); buildInfo.timeZones(info); return info; }; $D.i18n = { __: function (key, lang) { return __(key, lang); }, currentLanguage: function () { return lang || "en-US"; }, setLanguage: function (code, force, cb) { var async = false; if (force || code === "en-US" || (!!Date.CultureStrings && !!Date.CultureStrings[code])) { lang = code; Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings.lang = code; Date.CultureInfo = new CultureInfo(); } else { if (!(!!Date.CultureStrings && !!Date.CultureStrings[code])) { if (typeof exports !== "undefined" && this.exports !== exports) { // we're in a Node enviroment, load it using require try { require("../i18n/" + code + ".js"); lang = code; Date.CultureStrings.lang = code; Date.CultureInfo = new CultureInfo(); } catch (e) { // var str = "The language for '" + code + "' could not be loaded by Node. It likely does not exist."; throw new Error("The DateJS IETF language tag '" + code + "' could not be loaded by Node. It likely does not exist."); } } else if (Date.Config && Date.Config.i18n) { // we know the location of the files, so lets load them async = true; loadI18nScript(code).done(function(){ lang = code; Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings.lang = code; Date.CultureInfo = new CultureInfo(); $D.Parsing.Normalizer.buildReplaceData(); // because this is async if ($D.Grammar) { $D.Grammar.buildGrammarFormats(); // so we can parse those strings... } if (cb) { setTimeout(cb,0); } }); } else { Date.console.error("The DateJS IETF language tag '" + code + "' is not available and has not been loaded."); return false; } } } $D.Parsing.Normalizer.buildReplaceData(); // rebuild normalizer strings if ($D.Grammar) { $D.Grammar.buildGrammarFormats(); // so we can parse those strings... } if (!async && cb) { setTimeout(cb,0); } }, getLoggedKeys: function () { return loggedKeys; }, updateCultureInfo: function () { Date.CultureInfo = new CultureInfo(); } }; $D.i18n.updateCultureInfo(); // run automatically }()); (function () { var $D = Date, $P = $D.prototype, p = function (s, l) { if (!l) { l = 2; } return ("000" + s).slice(l * -1); }; if (typeof window !== "undefined" && typeof window.console !== "undefined" && typeof window.console.log !== "undefined") { $D.console = console; // used only to raise non-critical errors if available } else { // set mock so we don't give errors. $D.console = { log: function(){}, error: function(){} }; } $D.Config = $D.Config || {}; $D.initOverloads = function() { /** * Overload of Date.now. Allows an alternate call for Date.now where it returns the * current Date as an object rather than just milliseconds since the Unix Epoch. * * Also provides an implementation of now() for browsers (IE<9) that don't have it. * * Backwards compatible so with work with either: * Date.now() [returns ms] * or * Date.now(true) [returns Date] */ if (!$D.now) { $D._now = function now() { return new Date().getTime(); }; } else if (!$D._now) { $D._now = $D.now; } $D.now = function (returnObj) { if (returnObj) { return $D.present(); } else { return $D._now(); } }; if ( !$P.toISOString ) { $P.toISOString = function() { return this.getUTCFullYear() + "-" + p(this.getUTCMonth() + 1) + "-" + p(this.getUTCDate()) + "T" + p(this.getUTCHours()) + ":" + p(this.getUTCMinutes()) + ":" + p(this.getUTCSeconds()) + "." + String( (this.getUTCMilliseconds()/1000).toFixed(3)).slice(2, 5) + "Z"; }; } // private if ( $P._toString === undefined ){ $P._toString = $P.toString; } }; $D.initOverloads(); /** * Gets a date that is set to the current date. The time is set to the start of the day (00:00 or 12:00 AM). * @return {Date} The current date. */ $D.today = function () { return new Date().clearTime(); }; /** * Gets a date that is set to the current date and time (same as new Date, but chainable) * @return {Date} The current date. */ $D.present = function () { return new Date(); }; /** * Compares the first date to the second date and returns an number indication of their relative values. * @param {Date} First Date object to compare [Required]. * @param {Date} Second Date object to compare to [Required]. * @return {Number} -1 = date1 is lessthan date2. 0 = values are equal. 1 = date1 is greaterthan date2. */ $D.compare = function (date1, date2) { if (isNaN(date1) || isNaN(date2)) { throw new Error(date1 + " - " + date2); } else if (date1 instanceof Date && date2 instanceof Date) { return (date1 < date2) ? -1 : (date1 > date2) ? 1 : 0; } else { throw new TypeError(date1 + " - " + date2); } }; /** * Compares the first Date object to the second Date object and returns true if they are equal. * @param {Date} First Date object to compare [Required] * @param {Date} Second Date object to compare to [Required] * @return {Boolean} true if dates are equal. false if they are not equal. */ $D.equals = function (date1, date2) { return (date1.compareTo(date2) === 0); }; /** * Gets the language appropriate day name when given the day number(0-6) * eg - 0 == Sunday * @return {String} The day name */ $D.getDayName = function (n) { return Date.CultureInfo.dayNames[n]; }; /** * Gets the day number (0-6) if given a CultureInfo specific string which is a valid dayName, abbreviatedDayName or shortestDayName (two char). * @param {String} The name of the day (eg. "Monday, "Mon", "tuesday", "tue", "We", "we"). * @return {Number} The day number */ $D.getDayNumberFromName = function (name) { var n = Date.CultureInfo.dayNames, m = Date.CultureInfo.abbreviatedDayNames, o = Date.CultureInfo.shortestDayNames, s = name.toLowerCase(); for (var i = 0; i < n.length; i++) { if (n[i].toLowerCase() === s || m[i].toLowerCase() === s || o[i].toLowerCase() === s) { return i; } } return -1; }; /** * Gets the month number (0-11) if given a Culture Info specific string which is a valid monthName or abbreviatedMonthName. * @param {String} The name of the month (eg. "February, "Feb", "october", "oct"). * @return {Number} The day number */ $D.getMonthNumberFromName = function (name) { var n = Date.CultureInfo.monthNames, m = Date.CultureInfo.abbreviatedMonthNames, s = name.toLowerCase(); for (var i = 0; i < n.length; i++) { if (n[i].toLowerCase() === s || m[i].toLowerCase() === s) { return i; } } return -1; }; /** * Gets the language appropriate month name when given the month number(0-11) * eg - 0 == January * @return {String} The month name */ $D.getMonthName = function (n) { return Date.CultureInfo.monthNames[n]; }; /** * Determines if the current date instance is within a LeapYear. * @param {Number} The year. * @return {Boolean} true if date is within a LeapYear, otherwise false. */ $D.isLeapYear = function (year) { return ((year % 4 === 0 && year % 100 !== 0) || year % 400 === 0); }; /** * Gets the number of days in the month, given a year and month value. Automatically corrects for LeapYear. * @param {Number} The year. * @param {Number} The month (0-11). * @return {Number} The number of days in the month. */ $D.getDaysInMonth = function (year, month) { if (!month && $D.validateMonth(year)) { month = year; year = Date.today().getFullYear(); } return [31, ($D.isLeapYear(year) ? 29 : 28), 31, 30, 31, 30, 31, 31, 30, 31, 30, 31][month]; }; $P.getDaysInMonth = function () { return $D.getDaysInMonth(this.getFullYear(), this.getMonth()); }; $D.getTimezoneAbbreviation = function (offset, dst) { var p, n = (dst || false) ? Date.CultureInfo.abbreviatedTimeZoneDST : Date.CultureInfo.abbreviatedTimeZoneStandard; for (p in n) { if (n.hasOwnProperty(p)) { if (n[p] === offset) { return p; } } } return null; }; $D.getTimezoneOffset = function (name, dst) { var i, a =[], z = Date.CultureInfo.timezones; if (!name) { name = (new Date()).getTimezone();} for (i = 0; i < z.length; i++) { if (z[i].name === name.toUpperCase()) { a.push(i); } } if (!z[a[0]]) { return null; } if (a.length === 1 || !dst) { return z[a[0]].offset; } else { for (i=0; i < a.length; i++) { if (z[a[i]].dst) { return z[a[i]].offset; } } } }; $D.getQuarter = function (d) { d = d || new Date(); // If no date supplied, use today var q = [1,2,3,4]; return q[Math.floor(d.getMonth() / 3)]; // ~~~ is a bitwise op. Faster than Math.floor }; $D.getDaysLeftInQuarter = function (d) { d = d || new Date(); var qEnd = new Date(d); qEnd.setMonth(qEnd.getMonth() + 3 - qEnd.getMonth() % 3, 0); return Math.floor((qEnd - d) / 8.64e7); }; // private var validate = function (n, min, max, name) { name = name ? name : "Object"; if (typeof n === "undefined") { return false; } else if (typeof n !== "number") { throw new TypeError(n + " is not a Number."); } else if (n < min || n > max) { // As failing validation is *not* an exceptional circumstance // lets not throw a RangeError Exception here. // It's semantically correct but it's not sensible. return false; } return true; }; /** * Validates the number is within an acceptable range for milliseconds [0-999]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateMillisecond = function (value) { return validate(value, 0, 999, "millisecond"); }; /** * Validates the number is within an acceptable range for seconds [0-59]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateSecond = function (value) { return validate(value, 0, 59, "second"); }; /** * Validates the number is within an acceptable range for minutes [0-59]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateMinute = function (value) { return validate(value, 0, 59, "minute"); }; /** * Validates the number is within an acceptable range for hours [0-23]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateHour = function (value) { return validate(value, 0, 23, "hour"); }; /** * Validates the number is within an acceptable range for the days in a month [0-MaxDaysInMonth]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateDay = function (value, year, month) { if (year === undefined || year === null || month === undefined || month === null) { return false;} return validate(value, 1, $D.getDaysInMonth(year, month), "day"); }; /** * Validates the number is within an acceptable range for months [0-11]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateWeek = function (value) { return validate(value, 0, 53, "week"); }; /** * Validates the number is within an acceptable range for months [0-11]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateMonth = function (value) { return validate(value, 0, 11, "month"); }; /** * Validates the number is within an acceptable range for years. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateYear = function (value) { /** * Per ECMAScript spec the range of times supported by Date objects is * exactly -100,000,000 days to +100,000,000 days measured relative to * midnight at the beginning of 01 January, 1970 UTC. * This gives a range of 8,640,000,000,000,000 milliseconds to either * side of 01 January, 1970 UTC. * * Earliest possible date: Tue, 20 Apr 271,822 B.C. 00:00:00 UTC * Latest possible date: Sat, 13 Sep 275,760 00:00:00 UTC */ return validate(value, -271822, 275760, "year"); }; $D.validateTimezone = function(value) { var timezones = {"ACDT":1,"ACST":1,"ACT":1,"ADT":1,"AEDT":1,"AEST":1,"AFT":1,"AKDT":1,"AKST":1,"AMST":1,"AMT":1,"ART":1,"AST":1,"AWDT":1,"AWST":1,"AZOST":1,"AZT":1,"BDT":1,"BIOT":1,"BIT":1,"BOT":1,"BRT":1,"BST":1,"BTT":1,"CAT":1,"CCT":1,"CDT":1,"CEDT":1,"CEST":1,"CET":1,"CHADT":1,"CHAST":1,"CHOT":1,"ChST":1,"CHUT":1,"CIST":1,"CIT":1,"CKT":1,"CLST":1,"CLT":1,"COST":1,"COT":1,"CST":1,"CT":1,"CVT":1,"CWST":1,"CXT":1,"DAVT":1,"DDUT":1,"DFT":1,"EASST":1,"EAST":1,"EAT":1,"ECT":1,"EDT":1,"EEDT":1,"EEST":1,"EET":1,"EGST":1,"EGT":1,"EIT":1,"EST":1,"FET":1,"FJT":1,"FKST":1,"FKT":1,"FNT":1,"GALT":1,"GAMT":1,"GET":1,"GFT":1,"GILT":1,"GIT":1,"GMT":1,"GST":1,"GYT":1,"HADT":1,"HAEC":1,"HAST":1,"HKT":1,"HMT":1,"HOVT":1,"HST":1,"ICT":1,"IDT":1,"IOT":1,"IRDT":1,"IRKT":1,"IRST":1,"IST":1,"JST":1,"KGT":1,"KOST":1,"KRAT":1,"KST":1,"LHST":1,"LINT":1,"MAGT":1,"MART":1,"MAWT":1,"MDT":1,"MET":1,"MEST":1,"MHT":1,"MIST":1,"MIT":1,"MMT":1,"MSK":1,"MST":1,"MUT":1,"MVT":1,"MYT":1,"NCT":1,"NDT":1,"NFT":1,"NPT":1,"NST":1,"NT":1,"NUT":1,"NZDT":1,"NZST":1,"OMST":1,"ORAT":1,"PDT":1,"PET":1,"PETT":1,"PGT":1,"PHOT":1,"PHT":1,"PKT":1,"PMDT":1,"PMST":1,"PONT":1,"PST":1,"PYST":1,"PYT":1,"RET":1,"ROTT":1,"SAKT":1,"SAMT":1,"SAST":1,"SBT":1,"SCT":1,"SGT":1,"SLST":1,"SRT":1,"SST":1,"SYOT":1,"TAHT":1,"THA":1,"TFT":1,"TJT":1,"TKT":1,"TLT":1,"TMT":1,"TOT":1,"TVT":1,"UCT":1,"ULAT":1,"UTC":1,"UYST":1,"UYT":1,"UZT":1,"VET":1,"VLAT":1,"VOLT":1,"VOST":1,"VUT":1,"WAKT":1,"WAST":1,"WAT":1,"WEDT":1,"WEST":1,"WET":1,"WST":1,"YAKT":1,"YEKT":1,"Z":1}; return (timezones[value] === 1); }; $D.validateTimezoneOffset= function(value) { // timezones go from +14hrs to -12hrs, the +X hours are negative offsets. return (value > -841 && value < 721); }; }()); (function () { var $D = Date, $P = $D.prototype, p = function (s, l) { if (!l) { l = 2; } return ("000" + s).slice(l * -1); }; var validateConfigObject = function (obj) { var result = {}, self = this, prop, testFunc; testFunc = function (prop, func, value) { if (prop === "day") { var month = (obj.month !== undefined) ? obj.month : self.getMonth(); var year = (obj.year !== undefined) ? obj.year : self.getFullYear(); return $D[func](value, year, month); } else { return $D[func](value); } }; for (prop in obj) { if (Object.prototype.hasOwnProperty.call(obj, prop)) { var func = "validate" + prop.charAt(0).toUpperCase() + prop.slice(1); if ($D[func] && obj[prop] !== null && testFunc(prop, func, obj[prop])) { result[prop] = obj[prop]; } } } return result; }; /** * Resets the time of this Date object to 12:00 AM (00:00), which is the start of the day. * @param {Boolean} .clone() this date instance before clearing Time * @return {Date} this */ $P.clearTime = function () { this.setHours(0); this.setMinutes(0); this.setSeconds(0); this.setMilliseconds(0); return this; }; /** * Resets the time of this Date object to the current time ('now'). * @return {Date} this */ $P.setTimeToNow = function () { var n = new Date(); this.setHours(n.getHours()); this.setMinutes(n.getMinutes()); this.setSeconds(n.getSeconds()); this.setMilliseconds(n.getMilliseconds()); return this; }; /** * Returns a new Date object that is an exact date and time copy of the original instance. * @return {Date} A new Date instance */ $P.clone = function () { return new Date(this.getTime()); }; /** * Compares this instance to a Date object and returns an number indication of their relative values. * @param {Date} Date object to compare [Required] * @return {Number} -1 = this is lessthan date. 0 = values are equal. 1 = this is greaterthan date. */ $P.compareTo = function (date) { return Date.compare(this, date); }; /** * Compares this instance to another Date object and returns true if they are equal. * @param {Date} Date object to compare. If no date to compare, new Date() [now] is used. * @return {Boolean} true if dates are equal. false if they are not equal. */ $P.equals = function (date) { return Date.equals(this, (date !== undefined ? date : new Date())); }; /** * Determines if this instance is between a range of two dates or equal to either the start or end dates. * @param {Date} Start of range [Required] * @param {Date} End of range [Required] * @return {Boolean} true is this is between or equal to the start and end dates, else false */ $P.between = function (start, end) { return this.getTime() >= start.getTime() && this.getTime() <= end.getTime(); }; /** * Determines if this date occurs after the date to compare to. * @param {Date} Date object to compare. If no date to compare, new Date() ("now") is used. * @return {Boolean} true if this date instance is greater than the date to compare to (or "now"), otherwise false. */ $P.isAfter = function (date) { return this.compareTo(date || new Date()) === 1; }; /** * Determines if this date occurs before the date to compare to. * @param {Date} Date object to compare. If no date to compare, new Date() ("now") is used. * @return {Boolean} true if this date instance is less than the date to compare to (or "now"). */ $P.isBefore = function (date) { return (this.compareTo(date || new Date()) === -1); }; /** * Determines if the current Date instance occurs today. * @return {Boolean} true if this date instance is 'today', otherwise false. */ /** * Determines if the current Date instance occurs on the same Date as the supplied 'date'. * If no 'date' to compare to is provided, the current Date instance is compared to 'today'. * @param {date} Date object to compare. If no date to compare, the current Date ("now") is used. * @return {Boolean} true if this Date instance occurs on the same Day as the supplied 'date'. */ $P.isToday = $P.isSameDay = function (date) { return this.clone().clearTime().equals((date || new Date()).clone().clearTime()); }; /** * Adds the specified number of milliseconds to this instance. * @param {Number} The number of milliseconds to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addMilliseconds = function (value) { if (!value) { return this; } this.setTime(this.getTime() + value * 1); return this; }; /** * Adds the specified number of seconds to this instance. * @param {Number} The number of seconds to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addSeconds = function (value) { if (!value) { return this; } return this.addMilliseconds(value * 1000); }; /** * Adds the specified number of seconds to this instance. * @param {Number} The number of seconds to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addMinutes = function (value) { if (!value) { return this; } return this.addMilliseconds(value * 60000); // 60*1000 }; /** * Adds the specified number of hours to this instance. * @param {Number} The number of hours to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addHours = function (value) { if (!value) { return this; } return this.addMilliseconds(value * 3600000); // 60*60*1000 }; /** * Adds the specified number of days to this instance. * @param {Number} The number of days to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addDays = function (value) { if (!value) { return this; } this.setDate(this.getDate() + value * 1); return this; }; /** * Adds the specified number of weekdays (ie - not sat or sun) to this instance. * @param {Number} The number of days to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addWeekdays = function (value) { if (!value) { return this; } var day = this.getDay(); var weeks = (Math.ceil(Math.abs(value)/7)); if (day === 0 || day === 6) { if (value > 0) { this.next().monday(); this.addDays(-1); day = this.getDay(); } } if (value < 0) { while (value < 0) { this.addDays(-1); day = this.getDay(); if (day !== 0 && day !== 6) { value++; } } return this; } else if (value > 5 || (6-day) <= value) { value = value + (weeks * 2); } return this.addDays(value); }; /** * Adds the specified number of weeks to this instance. * @param {Number} The number of weeks to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addWeeks = function (value) { if (!value) { return this; } return this.addDays(value * 7); }; /** * Adds the specified number of months to this instance. * @param {Number} The number of months to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addMonths = function (value) { if (!value) { return this; } var n = this.getDate(); this.setDate(1); this.setMonth(this.getMonth() + value * 1); this.setDate(Math.min(n, $D.getDaysInMonth(this.getFullYear(), this.getMonth()))); return this; }; $P.addQuarters = function (value) { if (!value) { return this; } // note this will take you to the same point in the quarter as you are now. // i.e. - if you are 15 days into the quarter you'll be 15 days into the resulting one. // bonus: this allows adding fractional quarters return this.addMonths(value * 3); }; /** * Adds the specified number of years to this instance. * @param {Number} The number of years to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addYears = function (value) { if (!value) { return this; } return this.addMonths(value * 12); }; /** * Adds (or subtracts) to the value of the years, months, weeks, days, hours, minutes, seconds, milliseconds of the date instance using given configuration object. Positive and Negative values allowed. * Example

	Date.today().add( { days: 1, months: 1 } )

	new Date().add( { years: -1 } )
	
* @param {Object} Configuration object containing attributes (months, days, etc.) * @return {Date} this */ $P.add = function (config) { if (typeof config === "number") { this._orient = config; return this; } var x = config; if (x.day) { // If we should be a different date than today (eg: for 'tomorrow -1d', etc). // Should only effect parsing, not direct usage (eg, Finish and FinishExact) if ((x.day - this.getDate()) !== 0) { this.setDate(x.day); } } if (x.milliseconds) { this.addMilliseconds(x.milliseconds); } if (x.seconds) { this.addSeconds(x.seconds); } if (x.minutes) { this.addMinutes(x.minutes); } if (x.hours) { this.addHours(x.hours); } if (x.weeks) { this.addWeeks(x.weeks); } if (x.months) { this.addMonths(x.months); } if (x.years) { this.addYears(x.years); } if (x.days) { this.addDays(x.days); } return this; }; /** * Get the week number. Week one (1) is the week which contains the first Thursday of the year. Monday is considered the first day of the week. * The .getWeek() function does NOT convert the date to UTC. The local datetime is used. * Please use .getISOWeek() to get the week of the UTC converted date. * @return {Number} 1 to 53 */ $P.getWeek = function (utc) { // Create a copy of this date object var self, target = new Date(this.valueOf()); if (utc) { target.addMinutes(target.getTimezoneOffset()); self = target.clone(); } else { self = this; } // ISO week date weeks start on monday // so correct the day number var dayNr = (self.getDay() + 6) % 7; // ISO 8601 states that week 1 is the week // with the first thursday of that year. // Set the target date to the thursday in the target week target.setDate(target.getDate() - dayNr + 3); // Store the millisecond value of the target date var firstThursday = target.valueOf(); // Set the target to the first thursday of the year // First set the target to january first target.setMonth(0, 1); // Not a thursday? Correct the date to the next thursday if (target.getDay() !== 4) { target.setMonth(0, 1 + ((4 - target.getDay()) + 7) % 7); } // The weeknumber is the number of weeks between the // first thursday of the year and the thursday in the target week return 1 + Math.ceil((firstThursday - target) / 604800000); // 604800000 = 7 * 24 * 3600 * 1000 }; /** * Get the ISO 8601 week number. Week one ("01") is the week which contains the first Thursday of the year. Monday is considered the first day of the week. * The .getISOWeek() function does convert the date to it's UTC value. Please use .getWeek() to get the week of the local date. * @return {String} "01" to "53" */ $P.getISOWeek = function () { return p(this.getWeek(true)); }; /** * Moves the date to Monday of the week set. Week one (1) is the week which contains the first Thursday of the year. * @param {Number} A Number (1 to 53) that represents the week of the year. * @return {Date} this */ $P.setWeek = function (n) { if ((n - this.getWeek()) === 0) { if (this.getDay() !== 1) { return this.moveToDayOfWeek(1, (this.getDay() > 1 ? -1 : 1)); } else { return this; } } else { return this.moveToDayOfWeek(1, (this.getDay() > 1 ? -1 : 1)).addWeeks(n - this.getWeek()); } }; $P.setQuarter = function (qtr) { var month = Math.abs(((qtr-1) * 3) + 1); return this.setMonth(month, 1); }; $P.getQuarter = function () { return Date.getQuarter(this); }; $P.getDaysLeftInQuarter = function () { return Date.getDaysLeftInQuarter(this); }; /** * Moves the date to the next n'th occurrence of the dayOfWeek starting from the beginning of the month. The number (-1) is a magic number and will return the last occurrence of the dayOfWeek in the month. * @param {Number} The dayOfWeek to move to * @param {Number} The n'th occurrence to move to. Use (-1) to return the last occurrence in the month * @return {Date} this */ $P.moveToNthOccurrence = function (dayOfWeek, occurrence) { if (dayOfWeek === "Weekday") { if (occurrence > 0) { this.moveToFirstDayOfMonth(); if (this.is().weekday()) { occurrence -= 1; } } else if (occurrence < 0) { this.moveToLastDayOfMonth(); if (this.is().weekday()) { occurrence += 1; } } else { return this; } return this.addWeekdays(occurrence); } var shift = 0; if (occurrence > 0) { shift = occurrence - 1; } else if (occurrence === -1) { this.moveToLastDayOfMonth(); if (this.getDay() !== dayOfWeek) { this.moveToDayOfWeek(dayOfWeek, -1); } return this; } return this.moveToFirstDayOfMonth().addDays(-1).moveToDayOfWeek(dayOfWeek, +1).addWeeks(shift); }; var moveToN = function (getFunc, addFunc, nVal) { return function (value, orient) { var diff = (value - this[getFunc]() + nVal * (orient || +1)) % nVal; return this[addFunc]((diff === 0) ? diff += nVal * (orient || +1) : diff); }; }; /** * Move to the next or last dayOfWeek based on the orient value. * @param {Number} The dayOfWeek to move to * @param {Number} Forward (+1) or Back (-1). Defaults to +1. [Optional] * @return {Date} this */ $P.moveToDayOfWeek = moveToN("getDay", "addDays", 7); /** * Move to the next or last month based on the orient value. * @param {Number} The month to move to. 0 = January, 11 = December * @param {Number} Forward (+1) or Back (-1). Defaults to +1. [Optional] * @return {Date} this */ $P.moveToMonth = moveToN("getMonth", "addMonths", 12); /** * Get the Ordinate of the current day ("th", "st", "rd"). * @return {String} */ $P.getOrdinate = function () { var num = this.getDate(); return ord(num); }; /** * Get the Ordinal day (numeric day number) of the year, adjusted for leap year. * @return {Number} 1 through 365 (366 in leap years) */ $P.getOrdinalNumber = function () { return Math.ceil((this.clone().clearTime() - new Date(this.getFullYear(), 0, 1)) / 86400000) + 1; }; /** * Get the time zone abbreviation of the current date. * @return {String} The abbreviated time zone name (e.g. "EST") */ $P.getTimezone = function () { return $D.getTimezoneAbbreviation(this.getUTCOffset(), this.isDaylightSavingTime()); }; $P.setTimezoneOffset = function (offset) { var here = this.getTimezoneOffset(), there = Number(offset) * -6 / 10; return (there || there === 0) ? this.addMinutes(there - here) : this; }; $P.setTimezone = function (offset) { return this.setTimezoneOffset($D.getTimezoneOffset(offset)); }; /** * Indicates whether Daylight Saving Time is observed in the current time zone. * @return {Boolean} true|false */ $P.hasDaylightSavingTime = function () { return (Date.today().set({month: 0, day: 1}).getTimezoneOffset() !== Date.today().set({month: 6, day: 1}).getTimezoneOffset()); }; /** * Indicates whether this Date instance is within the Daylight Saving Time range for the current time zone. * @return {Boolean} true|false */ $P.isDaylightSavingTime = function () { return Date.today().set({month: 0, day: 1}).getTimezoneOffset() !== this.getTimezoneOffset(); }; /** * Get the offset from UTC of the current date. * @return {String} The 4-character offset string prefixed with + or - (e.g. "-0500") */ $P.getUTCOffset = function (offset) { var n = (offset || this.getTimezoneOffset()) * -10 / 6, r; if (n < 0) { r = (n - 10000).toString(); return r.charAt(0) + r.substr(2); } else { r = (n + 10000).toString(); return "+" + r.substr(1); } }; /** * Returns the number of milliseconds between this date and date. * @param {Date} Defaults to now * @return {Number} The diff in milliseconds */ $P.getElapsed = function (date) { return (date || new Date()) - this; }; /** * Set the value of year, month, day, hour, minute, second, millisecond of date instance using given configuration object. * Example

	Date.today().set( { day: 20, month: 1 } )

	new Date().set( { millisecond: 0 } )
	
* * @param {Object} Configuration object containing attributes (month, day, etc.) * @return {Date} this */ $P.set = function (config) { config = validateConfigObject.call(this, config); var key; for (key in config) { if (Object.prototype.hasOwnProperty.call(config, key)) { var name = key.charAt(0).toUpperCase() + key.slice(1); var addFunc, getFunc; if (key !== "week" && key !== "month" && key !== "timezone" && key !== "timezoneOffset") { name += "s"; } addFunc = "add" + name; getFunc = "get" + name; if (key === "month") { addFunc = addFunc + "s"; } else if (key === "year"){ getFunc = "getFullYear"; } if (key !== "day" && key !== "timezone" && key !== "timezoneOffset" && key !== "week" && key !== "hour") { this[addFunc](config[key] - this[getFunc]()); } else if ( key === "timezone"|| key === "timezoneOffset" || key === "week" || key === "hour") { this["set"+name](config[key]); } } } // day has to go last because you can't validate the day without first knowing the month if (config.day) { this.addDays(config.day - this.getDate()); } return this; }; /** * Moves the date to the first day of the month. * @return {Date} this */ $P.moveToFirstDayOfMonth = function () { return this.set({ day: 1 }); }; /** * Moves the date to the last day of the month. * @return {Date} this */ $P.moveToLastDayOfMonth = function () { return this.set({ day: $D.getDaysInMonth(this.getFullYear(), this.getMonth())}); }; /** * Converts the value of the current Date object to its equivalent string representation. * Format Specifiers * CUSTOM DATE AND TIME FORMAT STRINGS * Format Description Example * ------ --------------------------------------------------------------------------- ----------------------- * s The seconds of the minute between 0-59. "0" to "59" * ss The seconds of the minute with leading zero if required. "00" to "59" * * m The minute of the hour between 0-59. "0" or "59" * mm The minute of the hour with leading zero if required. "00" or "59" * * h The hour of the day between 1-12. "1" to "12" * hh The hour of the day with leading zero if required. "01" to "12" * * H The hour of the day between 0-23. "0" to "23" * HH The hour of the day with leading zero if required. "00" to "23" * * d The day of the month between 1 and 31. "1" to "31" * dd The day of the month with leading zero if required. "01" to "31" * ddd Abbreviated day name. Date.CultureInfo.abbreviatedDayNames. "Mon" to "Sun" * dddd The full day name. Date.CultureInfo.dayNames. "Monday" to "Sunday" * * M The month of the year between 1-12. "1" to "12" * MM The month of the year with leading zero if required. "01" to "12" * MMM Abbreviated month name. Date.CultureInfo.abbreviatedMonthNames. "Jan" to "Dec" * MMMM The full month name. Date.CultureInfo.monthNames. "January" to "December" * * yy The year as a two-digit number. "99" or "08" * yyyy The full four digit year. "1999" or "2008" * * t Displays the first character of the A.M./P.M. designator. "A" or "P" * Date.CultureInfo.amDesignator or Date.CultureInfo.pmDesignator * tt Displays the A.M./P.M. designator. "AM" or "PM" * Date.CultureInfo.amDesignator or Date.CultureInfo.pmDesignator * * S The ordinal suffix ("st, "nd", "rd" or "th") of the current day. "st, "nd", "rd" or "th" * * STANDARD DATE AND TIME FORMAT STRINGS * Format Description Example *------ --------------------------------------------------------------------------- ----------------------- * d The CultureInfo shortDate Format Pattern "M/d/yyyy" * D The CultureInfo longDate Format Pattern "dddd, MMMM dd, yyyy" * F The CultureInfo fullDateTime Format Pattern "dddd, MMMM dd, yyyy h:mm:ss tt" * m The CultureInfo monthDay Format Pattern "MMMM dd" * r The CultureInfo rfc1123 Format Pattern "ddd, dd MMM yyyy HH:mm:ss GMT" * s The CultureInfo sortableDateTime Format Pattern "yyyy-MM-ddTHH:mm:ss" * t The CultureInfo shortTime Format Pattern "h:mm tt" * T The CultureInfo longTime Format Pattern "h:mm:ss tt" * u The CultureInfo universalSortableDateTime Format Pattern "yyyy-MM-dd HH:mm:ssZ" * y The CultureInfo yearMonth Format Pattern "MMMM, yyyy" * * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @return {String} A string representation of the current Date object. */ var ord = function (n) { switch (n * 1) { case 1: case 21: case 31: return "st"; case 2: case 22: return "nd"; case 3: case 23: return "rd"; default: return "th"; } }; var parseStandardFormats = function (format) { var y, c = Date.CultureInfo.formatPatterns; switch (format) { case "d": return this.toString(c.shortDate); case "D": return this.toString(c.longDate); case "F": return this.toString(c.fullDateTime); case "m": return this.toString(c.monthDay); case "r": case "R": y = this.clone().addMinutes(this.getTimezoneOffset()); return y.toString(c.rfc1123) + " GMT"; case "s": return this.toString(c.sortableDateTime); case "t": return this.toString(c.shortTime); case "T": return this.toString(c.longTime); case "u": y = this.clone().addMinutes(this.getTimezoneOffset()); return y.toString(c.universalSortableDateTime); case "y": return this.toString(c.yearMonth); default: return false; } }; var parseFormatStringsClosure = function (context) { return function (m) { if (m.charAt(0) === "\\") { return m.replace("\\", ""); } switch (m) { case "hh": return p(context.getHours() < 13 ? (context.getHours() === 0 ? 12 : context.getHours()) : (context.getHours() - 12)); case "h": return context.getHours() < 13 ? (context.getHours() === 0 ? 12 : context.getHours()) : (context.getHours() - 12); case "HH": return p(context.getHours()); case "H": return context.getHours(); case "mm": return p(context.getMinutes()); case "m": return context.getMinutes(); case "ss": return p(context.getSeconds()); case "s": return context.getSeconds(); case "yyyy": return p(context.getFullYear(), 4); case "yy": return p(context.getFullYear()); case "y": return context.getFullYear(); case "E": case "dddd": return Date.CultureInfo.dayNames[context.getDay()]; case "ddd": return Date.CultureInfo.abbreviatedDayNames[context.getDay()]; case "dd": return p(context.getDate()); case "d": return context.getDate(); case "MMMM": return Date.CultureInfo.monthNames[context.getMonth()]; case "MMM": return Date.CultureInfo.abbreviatedMonthNames[context.getMonth()]; case "MM": return p((context.getMonth() + 1)); case "M": return context.getMonth() + 1; case "t": return context.getHours() < 12 ? Date.CultureInfo.amDesignator.substring(0, 1) : Date.CultureInfo.pmDesignator.substring(0, 1); case "tt": return context.getHours() < 12 ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator; case "S": return ord(context.getDate()); case "W": return context.getWeek(); case "WW": return context.getISOWeek(); case "Q": return "Q" + context.getQuarter(); case "q": return String(context.getQuarter()); case "z": return context.getTimezone(); case "Z": case "X": return Date.getTimezoneOffset(context.getTimezone()); case "ZZ": // Timezone offset in seconds return context.getTimezoneOffset() * -60; case "u": return context.getDay(); case "L": return ($D.isLeapYear(context.getFullYear())) ? 1 : 0; case "B": // Swatch Internet Time (.beats) return "@"+((context.getUTCSeconds() + (context.getUTCMinutes()*60) + ((context.getUTCHours()+1)*3600))/86.4); default: return m; } }; }; $P.toString = function (format, ignoreStandards) { // Standard Date and Time Format Strings. Formats pulled from CultureInfo file and // may vary by culture. if (!ignoreStandards && format && format.length === 1) { output = parseStandardFormats.call(this, format); if (output) { return output; } } var parseFormatStrings = parseFormatStringsClosure(this); return format ? format.replace(/((\\)?(dd?d?d?|MM?M?M?|yy?y?y?|hh?|HH?|mm?|ss?|tt?|S|q|Q|WW?W?W?)(?![^\[]*\]))/g, parseFormatStrings).replace(/\[|\]/g, "") : this._toString(); }; }()); /************************************************************* * SugarPak - Domain Specific Language - Syntactical Sugar * *************************************************************/ (function () { var $D = Date, $P = $D.prototype, $N = Number.prototype; // private $P._orient = +1; // private $P._nth = null; // private $P._is = false; // private $P._same = false; // private $P._isSecond = false; // private $N._dateElement = "days"; /** * Moves the date to the next instance of a date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.today().next().friday();
	Date.today().next().fri();
	Date.today().next().march();
	Date.today().next().mar();
	Date.today().next().week();
	
* * @return {Date} date */ $P.next = function () { this._move = true; this._orient = +1; return this; }; /** * Creates a new Date (Date.today()) and moves the date to the next instance of the date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.next().friday();
	Date.next().fri();
	Date.next().march();
	Date.next().mar();
	Date.next().week();
	
* * @return {Date} date */ $D.next = function () { return $D.today().next(); }; /** * Moves the date to the previous instance of a date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.today().last().friday();
	Date.today().last().fri();
	Date.today().last().march();
	Date.today().last().mar();
	Date.today().last().week();
	
* * @return {Date} date */ $P.last = $P.prev = $P.previous = function () { this._move = true; this._orient = -1; return this; }; /** * Creates a new Date (Date.today()) and moves the date to the previous instance of the date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.last().friday();
	Date.last().fri();
	Date.previous().march();
	Date.prev().mar();
	Date.last().week();
	
* * @return {Date} date */ $D.last = $D.prev = $D.previous = function () { return $D.today().last(); }; /** * Performs a equality check when followed by either a month name, day name or .weekday() function. * Example

	Date.today().is().friday(); // true|false
	Date.today().is().fri();
	Date.today().is().march();
	Date.today().is().mar();
	
* * @return {Boolean} true|false */ $P.is = function () { this._is = true; return this; }; /** * Determines if two date objects occur on/in exactly the same instance of the subsequent date part function. * The function .same() must be followed by a date part function (example: .day(), .month(), .year(), etc). * * An optional Date can be passed in the date part function. If now date is passed as a parameter, 'Now' is used. * * The following example demonstrates how to determine if two dates fall on the exact same day. * * Example

	var d1 = Date.today(); // today at 00:00
	var d2 = new Date();   // exactly now.

	// Do they occur on the same day?
	d1.same().day(d2); // true
	
	// Do they occur on the same hour?
	d1.same().hour(d2); // false, unless d2 hour is '00' (midnight).
	
	// What if it's the same day, but one year apart?
	var nextYear = Date.today().add(1).year();

	d1.same().day(nextYear); // false, because the dates must occur on the exact same day. 
	
* * Scenario: Determine if a given date occurs during some week period 2 months from now. * * Example

	var future = Date.today().add(2).months();
	return someDate.same().week(future); // true|false;
	
* * @return {Boolean} true|false */ $P.same = function () { this._same = true; this._isSecond = false; return this; }; /** * Determines if the current date/time occurs during Today. Must be preceded by the .is() function. * Example

	someDate.is().today();    // true|false
	new Date().is().today();  // true
	Date.today().is().today();// true
	Date.today().add(-1).day().is().today(); // false
	
* * @return {Boolean} true|false */ $P.today = function () { return this.same().day(); }; /** * Determines if the current date is a weekday. This function must be preceded by the .is() function. * Example

	Date.today().is().weekday(); // true|false
	
* * @return {Boolean} true|false */ $P.weekday = function () { if (this._nth) { return df("Weekday").call(this); } if (this._move) { return this.addWeekdays(this._orient); } if (this._is) { this._is = false; return (!this.is().sat() && !this.is().sun()); } return false; }; /** * Determines if the current date is on the weekend. This function must be preceded by the .is() function. * Example

	Date.today().is().weekend(); // true|false
	
* * @return {Boolean} true|false */ $P.weekend = function () { if (this._is) { this._is = false; return (this.is().sat() || this.is().sun()); } return false; }; /** * Sets the Time of the current Date instance. A string "6:15 pm" or config object {hour:18, minute:15} are accepted. * Example

	// Set time to 6:15pm with a String
	Date.today().at("6:15pm");

	// Set time to 6:15pm with a config object
	Date.today().at({hour:18, minute:15});
	
* * @return {Date} date */ $P.at = function (time) { return (typeof time === "string") ? $D.parse(this.toString("d") + " " + time) : this.set(time); }; /** * Creates a new Date() and adds this (Number) to the date based on the preceding date element function (eg. second|minute|hour|day|month|year). * Example

	// Undeclared Numbers must be wrapped with parentheses. Requirment of JavaScript.
	(3).days().fromNow();
	(6).months().fromNow();

	// Declared Number variables do not require parentheses. 
	var n = 6;
	n.months().fromNow();
	
* * @return {Date} A new Date instance */ $N.fromNow = $N.after = function (date) { var c = {}; c[this._dateElement] = this; return ((!date) ? new Date() : date.clone()).add(c); }; /** * Creates a new Date() and subtract this (Number) from the date based on the preceding date element function (eg. second|minute|hour|day|month|year). * Example

	// Undeclared Numbers must be wrapped with parentheses. Requirment of JavaScript.
	(3).days().ago();
	(6).months().ago();

	// Declared Number variables do not require parentheses. 
	var n = 6;
	n.months().ago();
	
* * @return {Date} A new Date instance */ $N.ago = $N.before = function (date) { var c = {}, s = (this._dateElement[this._dateElement.length-1] !== "s") ? this._dateElement + "s" : this._dateElement; c[s] = this * -1; return ((!date) ? new Date() : date.clone()).add(c); }; // Do NOT modify the following string tokens. These tokens are used to build dynamic functions. // All culture-specific strings can be found in the CultureInfo files. var dx = ("sunday monday tuesday wednesday thursday friday saturday").split(/\s/), mx = ("january february march april may june july august september october november december").split(/\s/), px = ("Millisecond Second Minute Hour Day Week Month Year Quarter Weekday").split(/\s/), pxf = ("Milliseconds Seconds Minutes Hours Date Week Month FullYear Quarter").split(/\s/), nth = ("final first second third fourth fifth").split(/\s/), de; /** * Returns an object literal of all the date parts. * Example

	var o = new Date().toObject();
	
	// { year: 2008, month: 4, week: 20, day: 13, hour: 18, minute: 9, second: 32, millisecond: 812 }
	
	// The object properties can be referenced directly from the object.
	
	alert(o.day);  // alerts "13"
	alert(o.year); // alerts "2008"
	
* * @return {Date} An object literal representing the original date object. */ $P.toObject = function () { var o = {}; for (var i = 0; i < px.length; i++) { if (this["get" + pxf[i]]) { o[px[i].toLowerCase()] = this["get" + pxf[i]](); } } return o; }; /** * Returns a date created from an object literal. Ignores the .week property if set in the config. * Example

	var o = new Date().toObject();
	
	return Date.fromObject(o); // will return the same date. 

	var o2 = {month: 1, day: 20, hour: 18}; // birthday party!
	Date.fromObject(o2);
	
* * @return {Date} An object literal representing the original date object. */ $D.fromObject = function(config) { config.week = null; return Date.today().set(config); }; // Create day name functions and abbreviated day name functions (eg. monday(), friday(), fri()). var df = function (n) { return function () { if (this._is) { this._is = false; return this.getDay() === n; } if (this._move) { this._move = null; } if (this._nth !== null) { // If the .second() function was called earlier, remove the _orient // from the date, and then continue. // This is required because 'second' can be used in two different context. // // Example // // Date.today().add(1).second(); // Date.march().second().monday(); // // Things get crazy with the following... // Date.march().add(1).second().second().monday(); // but it works!! // if (this._isSecond) { this.addSeconds(this._orient * -1); } // make sure we reset _isSecond this._isSecond = false; var ntemp = this._nth; this._nth = null; var temp = this.clone().moveToLastDayOfMonth(); this.moveToNthOccurrence(n, ntemp); if (this > temp) { throw new RangeError($D.getDayName(n) + " does not occur " + ntemp + " times in the month of " + $D.getMonthName(temp.getMonth()) + " " + temp.getFullYear() + "."); } return this; } return this.moveToDayOfWeek(n, this._orient); }; }; var sdf = function (n) { return function () { var t = $D.today(), shift = n - t.getDay(); if (n === 0 && Date.CultureInfo.firstDayOfWeek === 1 && t.getDay() !== 0) { shift = shift + 7; } return t.addDays(shift); }; }; // Create month name functions and abbreviated month name functions (eg. january(), march(), mar()). var month_instance_functions = function (n) { return function () { if (this._is) { this._is = false; return this.getMonth() === n; } return this.moveToMonth(n, this._orient); }; }; var month_static_functions = function (n) { return function () { return $D.today().set({ month: n, day: 1 }); }; }; var processTerms = function (names, staticFunc, instanceFunc) { for (var i = 0; i < names.length; i++) { // Create constant static Name variables. $D[names[i].toUpperCase()] = $D[names[i].toUpperCase().substring(0, 3)] = i; // Create Name functions. $D[names[i]] = $D[names[i].substring(0, 3)] = staticFunc(i); // Create Name instance functions. $P[names[i]] = $P[names[i].substring(0, 3)] = instanceFunc(i); } }; processTerms(dx, sdf, df); processTerms(mx, month_static_functions, month_instance_functions); // Create date element functions and plural date element functions used with Date (eg. day(), days(), months()). var ef = function (j) { return function () { // if the .second() function was called earlier, the _orient // has alread been added. Just return this and reset _isSecond. if (this._isSecond) { this._isSecond = false; return this; } if (this._same) { this._same = this._is = false; var o1 = this.toObject(), o2 = (arguments[0] || new Date()).toObject(), v = "", k = j.toLowerCase(); // the substr trick with -1 doesn't work in IE8 or less k = (k[k.length-1] === "s") ? k.substring(0,k.length-1) : k; for (var m = (px.length - 1); m > -1; m--) { v = px[m].toLowerCase(); if (o1[v] !== o2[v]) { return false; } if (k === v) { break; } } return true; } if (j.substring(j.length - 1) !== "s") { j += "s"; } if (this._move) { this._move = null; } return this["add" + j](this._orient); }; }; var nf = function (n) { return function () { this._dateElement = n; return this; }; }; for (var k = 0; k < px.length; k++) { de = px[k].toLowerCase(); if(de !== "weekday") { // Create date element functions and plural date element functions used with Date (eg. day(), days(), months()). $P[de] = $P[de + "s"] = ef(px[k]); // Create date element functions and plural date element functions used with Number (eg. day(), days(), months()). $N[de] = $N[de + "s"] = nf(de + "s"); } } $P._ss = ef("Second"); var nthfn = function (n) { return function (dayOfWeek) { if (this._same) { return this._ss(arguments[0]); } if (dayOfWeek || dayOfWeek === 0) { return this.moveToNthOccurrence(dayOfWeek, n); } this._nth = n; // if the operator is 'second' add the _orient, then deal with it later... if (n === 2 && (dayOfWeek === undefined || dayOfWeek === null)) { this._isSecond = true; return this.addSeconds(this._orient); } return this; }; }; for (var l = 0; l < nth.length; l++) { $P[nth[l]] = (l === 0) ? nthfn(-1) : nthfn(l); } }()); (function () { "use strict"; Date.Parsing = { Exception: function (s) { this.message = "Parse error at '" + s.substring(0, 10) + " ...'"; } }; var $P = Date.Parsing; var dayOffsets = { standard: [0,31,59,90,120,151,181,212,243,273,304,334], leap: [0,31,60,91,121,152,182,213,244,274,305,335] }; $P.isLeapYear = function(year) { return ((year % 4 === 0) && (year % 100 !== 0)) || (year % 400 === 0); }; var utils = { multiReplace : function (str, hash ) { var key; for (key in hash) { if (Object.prototype.hasOwnProperty.call(hash, key)) { var regex; if (typeof hash[key] === "function") { } else { regex = (hash[key] instanceof RegExp) ? hash[key] : new RegExp(hash[key], "g"); } str = str.replace(regex, key); } } return str; }, getDayOfYearFromWeek : function (obj) { var d, jan4, offset; obj.weekDay = (!obj.weekDay && obj.weekDay !== 0) ? 1 : obj.weekDay; d = new Date(obj.year, 0, 4); jan4 = d.getDay() === 0 ? 7 : d.getDay(); // JS is 0 indexed on Sunday. offset = jan4+3; obj.dayOfYear = ((obj.week * 7) + (obj.weekDay === 0 ? 7 : obj.weekDay))-offset; return obj; }, getDayOfYear : function (obj, dayOffset) { if (!obj.dayOfYear) { obj = utils.getDayOfYearFromWeek(obj); } for (var i=0;i <= dayOffset.length;i++) { if (obj.dayOfYear < dayOffset[i] || i === dayOffset.length) { obj.day = obj.day ? obj.day : (obj.dayOfYear - dayOffset[i-1]); break; } else { obj.month = i; } } return obj; }, adjustForTimeZone : function (obj, date) { var offset; if (obj.zone.toUpperCase() === "Z" || (obj.zone_hours === 0 && obj.zone_minutes === 0)) { // it's UTC/GML so work out the current timeszone offset offset = -date.getTimezoneOffset(); } else { offset = (obj.zone_hours*60) + (obj.zone_minutes || 0); if (obj.zone_sign === "+") { offset *= -1; } offset -= date.getTimezoneOffset(); } date.setMinutes(date.getMinutes()+offset); return date; }, setDefaults : function (obj) { obj.year = obj.year || Date.today().getFullYear(); obj.hours = obj.hours || 0; obj.minutes = obj.minutes || 0; obj.seconds = obj.seconds || 0; obj.milliseconds = obj.milliseconds || 0; if (!(!obj.month && (obj.week || obj.dayOfYear))) { // if we have a month, or if we don't but don't have the day calculation data obj.month = obj.month || 0; obj.day = obj.day || 1; } return obj; }, dataNum: function (data, mod, explict, postProcess) { var dataNum = data*1; if (mod) { if (postProcess) { return data ? mod(data)*1 : data; } else { return data ? mod(dataNum) : data; } } else if (!explict){ return data ? dataNum : data; } else { return (data && typeof data !== "undefined") ? dataNum : data; } }, timeDataProcess: function (obj) { var timeObj = {}; for (var x in obj.data) { if (obj.data.hasOwnProperty(x)) { timeObj[x] = obj.ignore[x] ? obj.data[x] : utils.dataNum(obj.data[x], obj.mods[x], obj.explict[x], obj.postProcess[x]); } } if (obj.data.secmins) { obj.data.secmins = obj.data.secmins.replace(",", ".") * 60; if (!timeObj.minutes) { timeObj.minutes = obj.data.secmins; } else if (!timeObj.seconds) { timeObj.seconds = obj.data.secmins; } delete obj.secmins; } return timeObj; }, buildTimeObjectFromData: function (data) { var time = utils.timeDataProcess({ data: { year : data[1], month : data[5], day : data[7], week : data[8], dayOfYear : data[10], hours : data[15], zone_hours : data[23], zone_minutes : data[24], zone : data[21], zone_sign : data[22], weekDay : data[9], minutes: data[16], seconds: data[19], milliseconds: data[20], secmins: data[18] }, mods: { month: function(data) { return data-1; }, weekDay: function (data) { data = Math.abs(data); return (data === 7 ? 0 : data); }, minutes: function (data) { return data.replace(":",""); }, seconds: function (data) { return Math.floor( (data.replace(":","").replace(",","."))*1 ); }, milliseconds: function (data) { return (data.replace(",",".")*1000); } }, postProcess: { minutes: true, seconds: true, milliseconds: true }, explict: { zone_hours: true, zone_minutes: true }, ignore: { zone: true, zone_sign: true, secmins: true } }); return time; }, addToHash: function (hash, keys, data) { keys = keys; data = data; var len = keys.length; for (var i = 0; i < len; i++) { hash[keys[i]] = data[i]; } return hash; }, combineRegex: function (r1, r2) { return new RegExp("(("+r1.source+")\\s("+r2.source+"))"); }, getDateNthString: function(add, last, inc){ if (add) { return Date.today().addDays(inc).toString("d"); } else if (last) { return Date.today().last()[inc]().toString("d"); } }, buildRegexData: function (array) { var arr = []; var len = array.length; for (var i=0; i < len; i++) { if (Object.prototype.toString.call(array[i]) === '[object Array]') { // oldIE compat version of Array.isArray arr.push(this.combineRegex(array[i][0], array[i][1])); } else { arr.push(array[i]); } } return arr; } }; $P.processTimeObject = function (obj) { var date, dayOffset; utils.setDefaults(obj); dayOffset = ($P.isLeapYear(obj.year)) ? dayOffsets.leap : dayOffsets.standard; if (!obj.month && (obj.week || obj.dayOfYear)) { utils.getDayOfYear(obj, dayOffset); } else { obj.dayOfYear = dayOffset[obj.month] + obj.day; } date = new Date(obj.year, obj.month, obj.day, obj.hours, obj.minutes, obj.seconds, obj.milliseconds); if (obj.zone) { utils.adjustForTimeZone(obj, date); // adjust (and calculate) for timezone } return date; }; $P.ISO = { regex : /^([\+-]?\d{4}(?!\d{2}\b))((-?)((0[1-9]|1[0-2])(\3([12]\d|0[1-9]|3[01]))?|W([0-4]\d|5[0-3])(-?[1-7])?|(00[1-9]|0[1-9]\d|[12]\d{2}|3([0-5]\d|6[1-6])))([T\s]((([01]\d|2[0-4])((:?)[0-5]\d)?|24\:?00)([\.,]\d+(?!:))?)?(\17[0-5]\d([\.,]\d+)?)?\s?([zZ]|([\+-])([01]\d|2[0-3]):?([0-5]\d)?)?)?)?$/, parse : function (s) { var time, data = s.match(this.regex); if (!data || !data.length) { return null; } time = utils.buildTimeObjectFromData(data); if (!time.year || (!time.year && (!time.month && !time.day) && (!time.week && !time.dayOfYear)) ) { return null; } return $P.processTimeObject(time); } }; $P.Numeric = { isNumeric: function (e){return!isNaN(parseFloat(e))&&isFinite(e);}, regex: /\b([0-1]?[0-9])([0-3]?[0-9])([0-2]?[0-9]?[0-9][0-9])\b/i, parse: function (s) { var data, i, time = {}, order = Date.CultureInfo.dateElementOrder.split(""); if (!(this.isNumeric(s)) || // if it's non-numeric OR (s[0] === "+" && s[0] === "-")) { // It's an arithmatic string (eg +/-1000) return null; } if (s.length < 5 && s.indexOf(".") < 0 && s.indexOf("/") < 0) { // assume it's just a year. time.year = s; return $P.processTimeObject(time); } data = s.match(this.regex); if (!data || !data.length) { return null; } for (i=0; i < order.length; i++) { switch(order[i]) { case "d": time.day = data[i+1]; break; case "m": time.month = (data[i+1]-1); break; case "y": time.year = data[i+1]; break; } } return $P.processTimeObject(time); } }; $P.Normalizer = { regexData: function () { var $R = Date.CultureInfo.regexPatterns; return utils.buildRegexData([ $R.tomorrow, $R.yesterday, [$R.past, $R.mon], [$R.past, $R.tue], [$R.past, $R.wed], [$R.past, $R.thu], [$R.past, $R.fri], [$R.past, $R.sat], [$R.past, $R.sun] ]); }, basicReplaceHash : function() { var $R = Date.CultureInfo.regexPatterns; return { "January": $R.jan.source, "February": $R.feb, "March": $R.mar, "April": $R.apr, "May": $R.may, "June": $R.jun, "July": $R.jul, "August": $R.aug, "September": $R.sep, "October": $R.oct, "November": $R.nov, "December": $R.dec, "": /\bat\b/gi, " ": /\s{2,}/, "am": $R.inTheMorning, "9am": $R.thisMorning, "pm": $R.inTheEvening, "7pm":$R.thisEvening }; }, keys : function(){ return [ utils.getDateNthString(true, false, 1), // tomorrow utils.getDateNthString(true, false, -1), // yesterday utils.getDateNthString(false, true, "monday"), //last mon utils.getDateNthString(false, true, "tuesday"), //last tues utils.getDateNthString(false, true, "wednesday"), //last wed utils.getDateNthString(false, true, "thursday"), //last thurs utils.getDateNthString(false, true, "friday"), //last fri utils.getDateNthString(false, true, "saturday"), //last sat utils.getDateNthString(false, true, "sunday") //last sun ]; }, buildRegexFunctions: function () { var $R = Date.CultureInfo.regexPatterns; var __ = Date.i18n.__; var tomorrowRE = new RegExp("(\\b\\d\\d?("+__("AM")+"|"+__("PM")+")? )("+$R.tomorrow.source.slice(1)+")", "i"); // adapted tomorrow regex for AM PM relative dates var todayRE = new RegExp($R.today.source + "(?!\\s*([+-]))\\b"); // today, but excludes the math operators (eg "today + 2h") this.replaceFuncs = [ [todayRE, function (full) { return (full.length > 1) ? Date.today().toString("d") : full; }], [tomorrowRE, function(full, m1) { var t = Date.today().addDays(1).toString("d"); return (t + " " + m1); }], [$R.amThisMorning, function(str, am){return am;}], [$R.pmThisEvening, function(str, pm){return pm;}] ]; }, buildReplaceData: function () { this.buildRegexFunctions(); this.replaceHash = utils.addToHash(this.basicReplaceHash(), this.keys(), this.regexData()); }, stringReplaceFuncs: function (s) { for (var i=0; i < this.replaceFuncs.length; i++) { s = s.replace(this.replaceFuncs[i][0], this.replaceFuncs[i][1]); } return s; }, parse: function (s) { s = this.stringReplaceFuncs(s); s = utils.multiReplace(s, this.replaceHash); try { var n = s.split(/([\s\-\.\,\/\x27]+)/); if (n.length === 3 && $P.Numeric.isNumeric(n[0]) && $P.Numeric.isNumeric(n[2]) && (n[2].length >= 4)) { // ok, so we're dealing with x/year. But that's not a full date. // This fixes wonky dateElementOrder parsing when set to dmy order. if (Date.CultureInfo.dateElementOrder[0] === "d") { s = "1/" + n[0] + "/" + n[2]; // set to 1st of month and normalize the seperator } } } catch (e) {} return s; } }; $P.Normalizer.buildReplaceData(); }()); (function () { var $P = Date.Parsing; var _ = $P.Operators = { // // Tokenizers // rtoken: function (r) { // regex token return function (s) { var mx = s.match(r); if (mx) { return ([ mx[0], s.substring(mx[0].length) ]); } else { throw new $P.Exception(s); } }; }, token: function () { // whitespace-eating token return function (s) { return _.rtoken(new RegExp("^\\s*" + s + "\\s*"))(s); }; }, stoken: function (s) { // string token return _.rtoken(new RegExp("^" + s)); }, // Atomic Operators until: function (p) { return function (s) { var qx = [], rx = null; while (s.length) { try { rx = p.call(this, s); } catch (e) { qx.push(rx[0]); s = rx[1]; continue; } break; } return [ qx, s ]; }; }, many: function (p) { return function (s) { var rx = [], r = null; while (s.length) { try { r = p.call(this, s); } catch (e) { return [ rx, s ]; } rx.push(r[0]); s = r[1]; } return [ rx, s ]; }; }, // generator operators -- see below optional: function (p) { return function (s) { var r = null; try { r = p.call(this, s); } catch (e) { return [ null, s ]; } return [ r[0], r[1] ]; }; }, not: function (p) { return function (s) { try { p.call(this, s); } catch (e) { return [null, s]; } throw new $P.Exception(s); }; }, ignore: function (p) { return p ? function (s) { var r = null; r = p.call(this, s); return [null, r[1]]; } : null; }, product: function () { var px = arguments[0], qx = Array.prototype.slice.call(arguments, 1), rx = []; for (var i = 0 ; i < px.length ; i++) { rx.push(_.each(px[i], qx)); } return rx; }, cache: function (rule) { var cache = {}, cache_length = 0, cache_keys = [], CACHE_MAX = Date.Config.CACHE_MAX || 100000, r = null; var cacheCheck = function () { if (cache_length === CACHE_MAX) { // kill several keys, don't want to have to do this all the time... for (var i=0; i < 10; i++) { var key = cache_keys.shift(); if (key) { delete cache[key]; cache_length--; } } } }; return function (s) { cacheCheck(); try { r = cache[s] = (cache[s] || rule.call(this, s)); } catch (e) { r = cache[s] = e; } cache_length++; cache_keys.push(s); if (r instanceof $P.Exception) { throw r; } else { return r; } }; }, // vector operators -- see below any: function () { var px = arguments; return function (s) { var r = null; for (var i = 0; i < px.length; i++) { if (px[i] == null) { continue; } try { r = (px[i].call(this, s)); } catch (e) { r = null; } if (r) { return r; } } throw new $P.Exception(s); }; }, each: function () { var px = arguments; return function (s) { var rx = [], r = null; for (var i = 0; i < px.length ; i++) { if (px[i] == null) { continue; } try { r = (px[i].call(this, s)); } catch (e) { throw new $P.Exception(s); } rx.push(r[0]); s = r[1]; } return [ rx, s]; }; }, all: function () { var px = arguments, _ = _; return _.each(_.optional(px)); }, // delimited operators sequence: function (px, d, c) { d = d || _.rtoken(/^\s*/); c = c || null; if (px.length === 1) { return px[0]; } return function (s) { var r = null, q = null; var rx = []; for (var i = 0; i < px.length ; i++) { try { r = px[i].call(this, s); } catch (e) { break; } rx.push(r[0]); try { q = d.call(this, r[1]); } catch (ex) { q = null; break; } s = q[1]; } if (!r) { throw new $P.Exception(s); } if (q) { throw new $P.Exception(q[1]); } if (c) { try { r = c.call(this, r[1]); } catch (ey) { throw new $P.Exception(r[1]); } } return [ rx, (r?r[1]:s) ]; }; }, // // Composite Operators // between: function (d1, p, d2) { d2 = d2 || d1; var _fn = _.each(_.ignore(d1), p, _.ignore(d2)); return function (s) { var rx = _fn.call(this, s); return [[rx[0][0], r[0][2]], rx[1]]; }; }, list: function (p, d, c) { d = d || _.rtoken(/^\s*/); c = c || null; return (p instanceof Array ? _.each(_.product(p.slice(0, -1), _.ignore(d)), p.slice(-1), _.ignore(c)) : _.each(_.many(_.each(p, _.ignore(d))), px, _.ignore(c))); }, set: function (px, d, c) { d = d || _.rtoken(/^\s*/); c = c || null; return function (s) { // r is the current match, best the current 'best' match // which means it parsed the most amount of input var r = null, p = null, q = null, rx = null, best = [[], s], last = false; // go through the rules in the given set for (var i = 0; i < px.length ; i++) { // last is a flag indicating whether this must be the last element // if there is only 1 element, then it MUST be the last one q = null; p = null; r = null; last = (px.length === 1); // first, we try simply to match the current pattern // if not, try the next pattern try { r = px[i].call(this, s); } catch (e) { continue; } // since we are matching against a set of elements, the first // thing to do is to add r[0] to matched elements rx = [[r[0]], r[1]]; // if we matched and there is still input to parse and // we don't already know this is the last element, // we're going to next check for the delimiter ... // if there's none, or if there's no input left to parse // than this must be the last element after all ... if (r[1].length > 0 && ! last) { try { q = d.call(this, r[1]); } catch (ex) { last = true; } } else { last = true; } // if we parsed the delimiter and now there's no more input, // that means we shouldn't have parsed the delimiter at all // so don't update r and mark this as the last element ... if (!last && q[1].length === 0) { last = true; } // so, if this isn't the last element, we're going to see if // we can get any more matches from the remaining (unmatched) // elements ... if (!last) { // build a list of the remaining rules we can match against, // i.e., all but the one we just matched against var qx = []; for (var j = 0; j < px.length ; j++) { if (i !== j) { qx.push(px[j]); } } // now invoke recursively set with the remaining input // note that we don't include the closing delimiter ... // we'll check for that ourselves at the end p = _.set(qx, d).call(this, q[1]); // if we got a non-empty set as a result ... // (otw rx already contains everything we want to match) if (p[0].length > 0) { // update current result, which is stored in rx ... // basically, pick up the remaining text from p[1] // and concat the result from p[0] so that we don't // get endless nesting ... rx[0] = rx[0].concat(p[0]); rx[1] = p[1]; } } // at this point, rx either contains the last matched element // or the entire matched set that starts with this element. // now we just check to see if this variation is better than // our best so far, in terms of how much of the input is parsed if (rx[1].length < best[1].length) { best = rx; } // if we've parsed all the input, then we're finished if (best[1].length === 0) { break; } } // so now we've either gone through all the patterns trying them // as the initial match; or we found one that parsed the entire // input string ... // if best has no matches, just return empty set ... if (best[0].length === 0) { return best; } // if a closing delimiter is provided, then we have to check it also if (c) { // we try this even if there is no remaining input because the pattern // may well be optional or match empty input ... try { q = c.call(this, best[1]); } catch (ey) { throw new $P.Exception(best[1]); } // it parsed ... be sure to update the best match remaining input best[1] = q[1]; } // if we're here, either there was no closing delimiter or we parsed it // so now we have the best match; just return it! return best; }; }, forward: function (gr, fname) { return function (s) { return gr[fname].call(this, s); }; }, // // Translation Operators // replace: function (rule, repl) { return function (s) { var r = rule.call(this, s); return [repl, r[1]]; }; }, process: function (rule, fn) { return function (s) { var r = rule.call(this, s); return [fn.call(this, r[0]), r[1]]; }; }, min: function (min, rule) { return function (s) { var rx = rule.call(this, s); if (rx[0].length < min) { throw new $P.Exception(s); } return rx; }; } }; // Generator Operators And Vector Operators // Generators are operators that have a signature of F(R) => R, // taking a given rule and returning another rule, such as // ignore, which parses a given rule and throws away the result. // Vector operators are those that have a signature of F(R1,R2,...) => R, // take a list of rules and returning a new rule, such as each. // Generator operators are converted (via the following _generator // function) into functions that can also take a list or array of rules // and return an array of new rules as though the function had been // called on each rule in turn (which is what actually happens). // This allows generators to be used with vector operators more easily. // Example: // each(ignore(foo, bar)) instead of each(ignore(foo), ignore(bar)) // This also turns generators into vector operators, which allows // constructs like: // not(cache(foo, bar)) var _generator = function (op) { function gen() { var args = null, rx = [], px, i; if (arguments.length > 1) { args = Array.prototype.slice.call(arguments); } else if (arguments[0] instanceof Array) { args = arguments[0]; } if (args) { px = args.shift(); if (px.length > 0) { args.unshift(px[i]); rx.push(op.apply(null, args)); args.shift(); return rx; } } else { return op.apply(null, arguments); } } return gen; }; var gx = "optional not ignore cache".split(/\s/); for (var i = 0 ; i < gx.length ; i++) { _[gx[i]] = _generator(_[gx[i]]); } var _vector = function (op) { return function () { if (arguments[0] instanceof Array) { return op.apply(null, arguments[0]); } else { return op.apply(null, arguments); } }; }; var vx = "each any all".split(/\s/); for (var j = 0 ; j < vx.length ; j++) { _[vx[j]] = _vector(_[vx[j]]); } }()); (function () { var $D = Date; var flattenAndCompact = function (ax) { var rx = []; for (var i = 0; i < ax.length; i++) { if (ax[i] instanceof Array) { rx = rx.concat(flattenAndCompact(ax[i])); } else { if (ax[i]) { rx.push(ax[i]); } } } return rx; }; var parseMeridian = function () { if (this.meridian && (this.hour || this.hour === 0)) { if (this.meridian === "a" && this.hour > 11 && Date.Config.strict24hr){ throw "Invalid hour and meridian combination"; } else if (this.meridian === "p" && this.hour < 12 && Date.Config.strict24hr){ throw "Invalid hour and meridian combination"; } else if (this.meridian === "p" && this.hour < 12) { this.hour = this.hour + 12; } else if (this.meridian === "a" && this.hour === 12) { this.hour = 0; } } }; var setDefaults = function () { var now = new Date(); if ((this.hour || this.minute) && (!this.month && !this.year && !this.day)) { this.day = now.getDate(); } if (!this.year) { this.year = now.getFullYear(); } if (!this.month && this.month !== 0) { this.month = now.getMonth(); } if (!this.day) { this.day = 1; } if (!this.hour) { this.hour = 0; } if (!this.minute) { this.minute = 0; } if (!this.second) { this.second = 0; } if (!this.millisecond) { this.millisecond = 0; } }; var finishUtils = { getToday: function () { if (this.now || "hour minute second".indexOf(this.unit) !== -1) { return new Date(); } else { return $D.today(); } }, setDaysFromWeekday: function (today, orient){ var gap; orient = orient || 1; this.unit = "day"; gap = ($D.getDayNumberFromName(this.weekday) - today.getDay()); this.days = gap ? ((gap + (orient * 7)) % 7) : (orient * 7); return this; }, setMonthsFromMonth: function (today, orient) { var gap; orient = orient || 1; this.unit = "month"; gap = (this.month - today.getMonth()); this.months = gap ? ((gap + (orient * 12)) % 12) : (orient * 12); this.month = null; return this; }, setDMYFromWeekday: function () { var d = Date[this.weekday](); this.day = d.getDate(); if (!this.month) { this.month = d.getMonth(); } this.year = d.getFullYear(); return this; }, setUnitValue: function (orient) { if (!this.value && this.operator && this.operator !== null && this[this.unit + "s"] && this[this.unit + "s"] !== null) { this[this.unit + "s"] = this[this.unit + "s"] + ((this.operator === "add") ? 1 : -1) + (this.value||0) * orient; } else if (this[this.unit + "s"] == null || this.operator != null) { if (!this.value) { this.value = 1; } this[this.unit + "s"] = this.value * orient; } }, generateDateFromWeeks: function () { var weekday = (this.weekday !== undefined) ? this.weekday : "today"; var d = Date[weekday]().addWeeks(this.weeks); if (this.now) { d.setTimeToNow(); } return d; } }; $D.Translator = { hour: function (s) { return function () { this.hour = Number(s); }; }, minute: function (s) { return function () { this.minute = Number(s); }; }, second: function (s) { return function () { this.second = Number(s); }; }, /* for ss.s format */ secondAndMillisecond: function (s) { return function () { var mx = s.match(/^([0-5][0-9])\.([0-9]{1,3})/); this.second = Number(mx[1]); this.millisecond = Number(mx[2]); }; }, meridian: function (s) { return function () { this.meridian = s.slice(0, 1).toLowerCase(); }; }, timezone: function (s) { return function () { var n = s.replace(/[^\d\+\-]/g, ""); if (n.length) { this.timezoneOffset = Number(n); } else { this.timezone = s.toLowerCase(); } }; }, day: function (x) { var s = x[0]; return function () { this.day = Number(s.match(/\d+/)[0]); if (this.day < 1) { throw "invalid day"; } }; }, month: function (s) { return function () { this.month = (s.length === 3) ? "jan feb mar apr may jun jul aug sep oct nov dec".indexOf(s)/4 : Number(s) - 1; if (this.month < 0) { throw "invalid month"; } }; }, year: function (s) { return function () { var n = Number(s); this.year = ((s.length > 2) ? n : (n + (((n + 2000) < Date.CultureInfo.twoDigitYearMax) ? 2000 : 1900))); }; }, rday: function (s) { return function () { switch (s) { case "yesterday": this.days = -1; break; case "tomorrow": this.days = 1; break; case "today": this.days = 0; break; case "now": this.days = 0; this.now = true; break; } }; }, finishExact: function (x) { var d; x = (x instanceof Array) ? x : [x]; for (var i = 0 ; i < x.length ; i++) { if (x[i]) { x[i].call(this); } } setDefaults.call(this); parseMeridian.call(this); if (this.day > $D.getDaysInMonth(this.year, this.month)) { throw new RangeError(this.day + " is not a valid value for days."); } d = new Date(this.year, this.month, this.day, this.hour, this.minute, this.second, this.millisecond); if (this.year < 100) { d.setFullYear(this.year); // means years less that 100 are process correctly. JS will parse it otherwise as 1900-1999. } if (this.timezone) { d.set({ timezone: this.timezone }); } else if (this.timezoneOffset) { d.set({ timezoneOffset: this.timezoneOffset }); } return d; }, finish: function (x) { var today, expression, orient, temp; x = (x instanceof Array) ? flattenAndCompact(x) : [ x ]; if (x.length === 0) { return null; } for (var i = 0 ; i < x.length ; i++) { if (typeof x[i] === "function") { x[i].call(this); } } if (this.now && !this.unit && !this.operator) { return new Date(); } else { today = finishUtils.getToday.call(this); } expression = !!(this.days && this.days !== null || this.orient || this.operator); orient = ((this.orient === "past" || this.operator === "subtract") ? -1 : 1); if (this.month && this.unit === "week") { this.value = this.month + 1; delete this.month; delete this.day; } if ((this.month || this.month === 0) && "year day hour minute second".indexOf(this.unit) !== -1) { if (!this.value) { this.value = this.month + 1; } this.month = null; expression = true; } if (!expression && this.weekday && !this.day && !this.days) { finishUtils.setDMYFromWeekday.call(this); } if (expression && this.weekday && this.unit !== "month" && this.unit !== "week") { finishUtils.setDaysFromWeekday.call(this, today, orient); } if (this.weekday && this.unit !== "week" && !this.day && !this.days) { temp = Date[this.weekday](); this.day = temp.getDate(); if (temp.getMonth() !== today.getMonth()) { this.month = temp.getMonth(); } } if (this.month && this.unit === "day" && this.operator) { if (!this.value) { this.value = (this.month + 1); } this.month = null; } if (this.value != null && this.month != null && this.year != null) { this.day = this.value * 1; } if (this.month && !this.day && this.value) { today.set({ day: this.value * 1 }); if (!expression) { this.day = this.value * 1; } } if (!this.month && this.value && this.unit === "month" && !this.now) { this.month = this.value; expression = true; } if (expression && (this.month || this.month === 0) && this.unit !== "year") { finishUtils.setMonthsFromMonth.call(this, today, orient); } if (!this.unit) { this.unit = "day"; } finishUtils.setUnitValue.call(this, orient); parseMeridian.call(this); if ((this.month || this.month === 0) && !this.day) { this.day = 1; } if (!this.orient && !this.operator && this.unit === "week" && this.value && !this.day && !this.month) { return Date.today().setWeek(this.value); } if (this.unit === "week" && this.weeks && !this.day && !this.month) { return finishUtils.generateDateFromWeeks.call(this); } if (expression && this.timezone && this.day && this.days) { this.day = this.days; } if (expression){ today.add(this); } else { today.set(this); } if (this.timezone) { this.timezone = this.timezone.toUpperCase(); var offset = $D.getTimezoneOffset(this.timezone); var timezone; if (today.hasDaylightSavingTime()) { // lets check that we're being sane with timezone setting timezone = $D.getTimezoneAbbreviation(offset, today.isDaylightSavingTime()); if (timezone !== this.timezone) { // bugger, we're in a place where things like EST vs EDT matters. if (today.isDaylightSavingTime()) { today.addHours(-1); } else { today.addHours(1); } } } today.setTimezoneOffset(offset); } return today; } }; }()); (function () { var $D = Date; $D.Grammar = {}; var _ = $D.Parsing.Operators, g = $D.Grammar, t = $D.Translator, _fn; // Allow rolling up into general purpose rules _fn = function () { return _.each(_.any.apply(null, arguments), _.not(g.ctoken2("timeContext"))); }; g.datePartDelimiter = _.rtoken(/^([\s\-\.\,\/\x27]+)/); g.timePartDelimiter = _.stoken(":"); g.whiteSpace = _.rtoken(/^\s*/); g.generalDelimiter = _.rtoken(/^(([\s\,]|at|@|on)+)/); var _C = {}; g.ctoken = function (keys) { var fn = _C[keys]; if (! fn) { var c = Date.CultureInfo.regexPatterns; var kx = keys.split(/\s+/), px = []; for (var i = 0; i < kx.length ; i++) { px.push(_.replace(_.rtoken(c[kx[i]]), kx[i])); } fn = _C[keys] = _.any.apply(null, px); } return fn; }; g.ctoken2 = function (key) { return _.rtoken(Date.CultureInfo.regexPatterns[key]); }; var cacheProcessRtoken = function (key, token, type, eachToken) { if (eachToken) { g[key] = _.cache(_.process(_.each(_.rtoken(token),_.optional(g.ctoken2(eachToken))), type)); } else { g[key] = _.cache(_.process(_.rtoken(token), type)); } }; var cacheProcessCtoken = function (token, type) { return _.cache(_.process(g.ctoken2(token), type)); }; var _F = {}; //function cache var _get = function (f) { _F[f] = (_F[f] || g.format(f)[0]); return _F[f]; }; g.allformats = function (fx) { var rx = []; if (fx instanceof Array) { for (var i = 0; i < fx.length; i++) { rx.push(_get(fx[i])); } } else { rx.push(_get(fx)); } return rx; }; g.formats = function (fx) { if (fx instanceof Array) { var rx = []; for (var i = 0 ; i < fx.length ; i++) { rx.push(_get(fx[i])); } return _.any.apply(null, rx); } else { return _get(fx); } }; var grammarFormats = { timeFormats: function(){ var i, RTokenKeys = [ "h", "hh", "H", "HH", "m", "mm", "s", "ss", "ss.s", "z", "zz" ], RToken = [ /^(0[0-9]|1[0-2]|[1-9])/, /^(0[0-9]|1[0-2])/, /^([0-1][0-9]|2[0-3]|[0-9])/, /^([0-1][0-9]|2[0-3])/, /^([0-5][0-9]|[0-9])/, /^[0-5][0-9]/, /^([0-5][0-9]|[0-9])/, /^[0-5][0-9]/, /^[0-5][0-9]\.[0-9]{1,3}/, /^((\+|\-)\s*\d\d\d\d)|((\+|\-)\d\d\:?\d\d)/, /^((\+|\-)\s*\d\d\d\d)|((\+|\-)\d\d\:?\d\d)/ ], tokens = [ t.hour, t.hour, t.hour, t.hour, t.minute, t.minute, t.second, t.second, t.secondAndMillisecond, t.timezone, t.timezone ]; for (i=0; i < RTokenKeys.length; i++) { cacheProcessRtoken(RTokenKeys[i], RToken[i], tokens[i]); } g.hms = _.cache(_.sequence([g.H, g.m, g.s], g.timePartDelimiter)); g.t = cacheProcessCtoken("shortMeridian", t.meridian); g.tt = cacheProcessCtoken("longMeridian", t.meridian); g.zzz = cacheProcessCtoken("timezone", t.timezone); g.timeSuffix = _.each(_.ignore(g.whiteSpace), _.set([ g.tt, g.zzz ])); g.time = _.each(_.optional(_.ignore(_.stoken("T"))), g.hms, g.timeSuffix); }, dateFormats: function () { // pre-loaded rules for different date part order preferences var _setfn = function () { return _.set(arguments, g.datePartDelimiter); }; var i, RTokenKeys = [ "d", "dd", "M", "MM", "y", "yy", "yyy", "yyyy" ], RToken = [ /^([0-2]\d|3[0-1]|\d)/, /^([0-2]\d|3[0-1])/, /^(1[0-2]|0\d|\d)/, /^(1[0-2]|0\d)/, /^(\d+)/, /^(\d\d)/, /^(\d\d?\d?\d?)/, /^(\d\d\d\d)/ ], tokens = [ t.day, t.day, t.month, t.month, t.year, t.year, t.year, t.year ], eachToken = [ "ordinalSuffix", "ordinalSuffix" ]; for (i=0; i < RTokenKeys.length; i++) { cacheProcessRtoken(RTokenKeys[i], RToken[i], tokens[i], eachToken[i]); } g.MMM = g.MMMM = _.cache(_.process(g.ctoken("jan feb mar apr may jun jul aug sep oct nov dec"), t.month)); g.ddd = g.dddd = _.cache(_.process(g.ctoken("sun mon tue wed thu fri sat"), function (s) { return function () { this.weekday = s; }; } )); g.day = _fn(g.d, g.dd); g.month = _fn(g.M, g.MMM); g.year = _fn(g.yyyy, g.yy); g.mdy = _setfn(g.ddd, g.month, g.day, g.year); g.ymd = _setfn(g.ddd, g.year, g.month, g.day); g.dmy = _setfn(g.ddd, g.day, g.month, g.year); g.date = function (s) { return ((g[Date.CultureInfo.dateElementOrder] || g.mdy).call(this, s)); }; }, relative: function () { // relative date / time expressions g.orientation = _.process(g.ctoken("past future"), function (s) { return function () { this.orient = s; }; } ); g.operator = _.process(g.ctoken("add subtract"), function (s) { return function () { this.operator = s; }; } ); g.rday = _.process(g.ctoken("yesterday tomorrow today now"), t.rday); g.unit = _.process(g.ctoken("second minute hour day week month year"), function (s) { return function () { this.unit = s; }; } ); } }; g.buildGrammarFormats = function () { // these need to be rebuilt every time the language changes. _C = {}; grammarFormats.timeFormats(); grammarFormats.dateFormats(); grammarFormats.relative(); g.value = _.process(_.rtoken(/^([-+]?\d+)?(st|nd|rd|th)?/), function (s) { return function () { this.value = s.replace(/\D/g, ""); }; } ); g.expression = _.set([g.rday, g.operator, g.value, g.unit, g.orientation, g.ddd, g.MMM ]); g.format = _.process(_.many( _.any( // translate format specifiers into grammar rules _.process( _.rtoken(/^(dd?d?d?(?!e)|MM?M?M?|yy?y?y?|hh?|HH?|mm?|ss?|tt?|zz?z?)/), function (fmt) { if (g[fmt]) { return g[fmt]; } else { throw $D.Parsing.Exception(fmt); } } ), // translate separator tokens into token rules _.process(_.rtoken(/^[^dMyhHmstz]+/), // all legal separators function (s) { return _.ignore(_.stoken(s)); } ) ) ), // construct the parser ... function (rules) { return _.process(_.each.apply(null, rules), t.finishExact); } ); // starting rule for general purpose grammar g._start = _.process(_.set([ g.date, g.time, g.expression ], g.generalDelimiter, g.whiteSpace), t.finish); }; g.buildGrammarFormats(); // parsing date format specifiers - ex: "h:m:s tt" // this little guy will generate a custom parser based // on the format string, ex: g.format("h:m:s tt") // check for these formats first g._formats = g.formats([ "\"yyyy-MM-ddTHH:mm:ssZ\"", "yyyy-MM-ddTHH:mm:ss.sz", "yyyy-MM-ddTHH:mm:ssZ", "yyyy-MM-ddTHH:mm:ssz", "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-ddTHH:mmZ", "yyyy-MM-ddTHH:mmz", "yyyy-MM-ddTHH:mm", "ddd, MMM dd, yyyy H:mm:ss tt", "ddd MMM d yyyy HH:mm:ss zzz", "MMddyyyy", "ddMMyyyy", "Mddyyyy", "ddMyyyy", "Mdyyyy", "dMyyyy", "yyyy", "Mdyy", "dMyy", "d" ]); // real starting rule: tries selected formats first, // then general purpose rule g.start = function (s) { try { var r = g._formats.call({}, s); if (r[1].length === 0) { return r; } } catch (e) {} return g._start.call({}, s); }; }()); (function () { var $D = Date; /** * @desc Converts the specified string value into its JavaScript Date equivalent using CultureInfo specific format information. * * Example

	///////////
	// Dates //
	///////////

	// 15-Oct-2004
	var d1 = Date.parse("10/15/2004");

	// 15-Oct-2004
	var d1 = Date.parse("15-Oct-2004");

	// 15-Oct-2004
	var d1 = Date.parse("2004.10.15");

	//Fri Oct 15, 2004
	var d1 = Date.parse("Fri Oct 15, 2004");

	///////////
	// Times //
	///////////

	// Today at 10 PM.
	var d1 = Date.parse("10 PM");

	// Today at 10:30 PM.
	var d1 = Date.parse("10:30 P.M.");

	// Today at 6 AM.
	var d1 = Date.parse("06am");

	/////////////////////
	// Dates and Times //
	/////////////////////

	// 8-July-2004 @ 10:30 PM
	var d1 = Date.parse("July 8th, 2004, 10:30 PM");

	// 1-July-2004 @ 10:30 PM
	var d1 = Date.parse("2004-07-01T22:30:00");

	////////////////////
	// Relative Dates //
	////////////////////

	// Returns today's date. The string "today" is culture specific.
	var d1 = Date.parse("today");

	// Returns yesterday's date. The string "yesterday" is culture specific.
	var d1 = Date.parse("yesterday");

	// Returns the date of the next thursday.
	var d1 = Date.parse("Next thursday");

	// Returns the date of the most previous monday.
	var d1 = Date.parse("last monday");

	// Returns today's day + one year.
	var d1 = Date.parse("next year");

	///////////////
	// Date Math //
	///////////////

	// Today + 2 days
	var d1 = Date.parse("t+2");

	// Today + 2 days
	var d1 = Date.parse("today + 2 days");

	// Today + 3 months
	var d1 = Date.parse("t+3m");

	// Today - 1 year
	var d1 = Date.parse("today - 1 year");

	// Today - 1 year
	var d1 = Date.parse("t-1y"); 


	/////////////////////////////
	// Partial Dates and Times //
	/////////////////////////////

	// July 15th of this year.
	var d1 = Date.parse("July 15");

	// 15th day of current day and year.
	var d1 = Date.parse("15");

	// July 1st of current year at 10pm.
	var d1 = Date.parse("7/1 10pm");
	
* * @param {String} The string value to convert into a Date object [Required] * @return {Date} A Date object or null if the string cannot be converted into a Date. */ var parseUtils = { removeOrds: function (s) { ords = s.match(/\b(\d+)(?:st|nd|rd|th)\b/); // find ordinal matches s = ((ords && ords.length === 2) ? s.replace(ords[0], ords[1]) : s); return s; }, grammarParser: function (s) { var r = null; try { r = $D.Grammar.start.call({}, s.replace(/^\s*(\S*(\s+\S+)*)\s*$/, "$1")); } catch (e) { return null; } return ((r[1].length === 0) ? r[0] : null); }, nativeFallback: function(s) { var t; try { // ok we haven't parsed it, last ditch attempt with the built-in parser. t = Date._parse(s); return (t || t === 0) ? new Date(t) : null; } catch (e) { return null; } } }; function parse (s) { var d; if (!s) { return null; } if (s instanceof Date) { return s.clone(); } if (s.length >= 4 && s.charAt(0) !== "0" && s.charAt(0) !== "+"&& s.charAt(0) !== "-") { // ie: 2004 will pass, 0800 won't. // Start with specific formats d = $D.Parsing.ISO.parse(s) || $D.Parsing.Numeric.parse(s); } if (d instanceof Date && !isNaN(d.getTime())) { return d; } else { // find ordinal dates (1st, 3rd, 8th, etc and remove them as they cause parsing issues) s = $D.Parsing.Normalizer.parse(parseUtils.removeOrds(s)); d = parseUtils.grammarParser(s); if (d !== null) { return d; } else { return parseUtils.nativeFallback(s); } } } if (!$D._parse) { $D._parse = $D.parse; } $D.parse = parse; Date.getParseFunction = function (fx) { var fns = Date.Grammar.allformats(fx); return function (s) { var r = null; for (var i = 0; i < fns.length; i++) { try { r = fns[i].call({}, s); } catch (e) { continue; } if (r[1].length === 0) { return r[0]; } } return null; }; }; /** * Converts the specified string value into its JavaScript Date equivalent using the specified format {String} or formats {Array} and the CultureInfo specific format information. * The format of the string value must match one of the supplied formats exactly. * * Example

	// 15-Oct-2004
	var d1 = Date.parseExact("10/15/2004", "M/d/yyyy");

	// 15-Oct-2004
	var d1 = Date.parse("15-Oct-2004", "M-ddd-yyyy");

	// 15-Oct-2004
	var d1 = Date.parse("2004.10.15", "yyyy.MM.dd");

	// Multiple formats
	var d1 = Date.parseExact("10/15/2004", ["M/d/yyyy", "MMMM d, yyyy"]);
	
* * @param {String} The string value to convert into a Date object [Required]. * @param {Object} The expected format {String} or an array of expected formats {Array} of the date string [Required]. * @return {Date} A Date object or null if the string cannot be converted into a Date. */ $D.parseExact = function (s, fx) { return $D.getParseFunction(fx)(s); }; }()); (function () { var $D = Date, $P = $D.prototype, // $C = $D.CultureInfo, // not used atm p = function (s, l) { if (!l) { l = 2; } return ("000" + s).slice(l * -1); }; /** * Converts a PHP format string to Java/.NET format string. * A PHP format string can be used with ._format or .format. * A Java/.NET format string can be used with .toString(). * The .parseExact function will only accept a Java/.NET format string * * Example * var f1 = "%m/%d/%y" * var f2 = Date.normalizeFormat(f1); // "MM/dd/yy" * * new Date().format(f1); // "04/13/08" * new Date()._format(f1); // "04/13/08" * new Date().toString(f2); // "04/13/08" * * var date = Date.parseExact("04/13/08", f2); // Sun Apr 13 2008 * * @param {String} A PHP format string consisting of one or more format spcifiers. * @return {String} The PHP format converted to a Java/.NET format string. */ var normalizerSubstitutions = { "d" : "dd", "%d": "dd", "D" : "ddd", "%a": "ddd", "j" : "dddd", "l" : "dddd", "%A": "dddd", "S" : "S", "F" : "MMMM", "%B": "MMMM", "m" : "MM", "%m": "MM", "M" : "MMM", "%b": "MMM", "%h": "MMM", "n" : "M", "Y" : "yyyy", "%Y": "yyyy", "y" : "yy", "%y": "yy", "g" : "h", "%I": "h", "G" : "H", "h" : "hh", "H" : "HH", "%H": "HH", "i" : "mm", "%M": "mm", "s" : "ss", "%S": "ss", "%r": "hh:mm tt", "%R": "H:mm", "%T": "H:mm:ss", "%X": "t", "%x": "d", "%e": "d", "%D": "MM/dd/yy", "%n": "\\n", "%t": "\\t", "e" : "z", "T" : "z", "%z": "z", "%Z": "z", "Z" : "ZZ", "N" : "u", "w" : "u", "%w": "u", "W" : "W", "%V": "W" }; var normalizer = { substitutes: function (m) { return normalizerSubstitutions[m]; }, interpreted: function (m, x) { var y; switch (m) { case "%u": return x.getDay() + 1; case "z": return x.getOrdinalNumber(); case "%j": return p(x.getOrdinalNumber(), 3); case "%U": var d1 = x.clone().set({month: 0, day: 1}).addDays(-1).moveToDayOfWeek(0), d2 = x.clone().addDays(1).moveToDayOfWeek(0, -1); return (d2 < d1) ? "00" : p((d2.getOrdinalNumber() - d1.getOrdinalNumber()) / 7 + 1); case "%W": return p(x.getWeek()); case "t": return $D.getDaysInMonth(x.getFullYear(), x.getMonth()); case "o": case "%G": return x.setWeek(x.getISOWeek()).toString("yyyy"); case "%g": return x._format("%G").slice(-2); case "a": case "%p": return t("tt").toLowerCase(); case "A": return t("tt").toUpperCase(); case "u": return p(x.getMilliseconds(), 3); case "I": return (x.isDaylightSavingTime()) ? 1 : 0; case "O": return x.getUTCOffset(); case "P": y = x.getUTCOffset(); return y.substring(0, y.length - 2) + ":" + y.substring(y.length - 2); case "B": var now = new Date(); return Math.floor(((now.getHours() * 3600) + (now.getMinutes() * 60) + now.getSeconds() + (now.getTimezoneOffset() + 60) * 60) / 86.4); case "c": return x.toISOString().replace(/\"/g, ""); case "U": return $D.strtotime("now"); case "%c": return t("d") + " " + t("t"); case "%C": return Math.floor(x.getFullYear() / 100 + 1); } }, shouldOverrideDefaults: function (m) { switch (m) { case "%e": return true; default: return false; } }, parse: function (m, context) { var formatString, c = context || new Date(); formatString = normalizer.substitutes(m); if (formatString) { return formatString; } formatString = normalizer.interpreted(m, c); if (formatString) { return formatString; } else { return m; } } }; $D.normalizeFormat = function (format, context) { return format.replace(/(%|\\)?.|%%/g, function(t){ return normalizer.parse(t, context); }); }; /** * Format a local Unix timestamp according to locale settings * * Example: * Date.strftime("%m/%d/%y", new Date()); // "04/13/08" * Date.strftime("c", "2008-04-13T17:52:03Z"); // "04/13/08" * * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @param {Number|String} The number representing the number of seconds that have elapsed since January 1, 1970 (local time). * @return {String} A string representation of the current Date object. */ $D.strftime = function (format, time) { var d = Date.parse(time); return d._format(format); }; /** * Parse any textual datetime description into a Unix timestamp. * A Unix timestamp is the number of seconds that have elapsed since January 1, 1970 (midnight UTC/GMT). * * Example: * Date.strtotime("04/13/08"); // 1208044800 * Date.strtotime("1970-01-01T00:00:00Z"); // 0 * * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @param {Object} A string or date object. * @return {String} A string representation of the current Date object. */ $D.strtotime = function (time) { var d = $D.parse(time); return Math.round($D.UTC(d.getUTCFullYear(), d.getUTCMonth(), d.getUTCDate(), d.getUTCHours(), d.getUTCMinutes(), d.getUTCSeconds(), d.getUTCMilliseconds()) / 1000); }; /** * Converts the value of the current Date object to its equivalent string representation using a PHP/Unix style of date format specifiers. * Format Specifiers * Format Description Example * ------ --------------------------------------------------------------------------- ----------------------- * %a abbreviated weekday name according to the current localed "Mon" through "Sun" * %A full weekday name according to the current localed "Sunday" through "Saturday" * %b abbreviated month name according to the current localed "Jan" through "Dec" * %B full month name according to the current locale "January" through "December" * %c preferred date and time representation for the current locale "4/13/2008 12:33 PM" * %C century number (the year divided by 100 and truncated to an integer) "00" to "99" * %d day of the month as a decimal number "01" to "31" * %D same as %m/%d/%y "04/13/08" * %e day of the month as a decimal number, a single digit is preceded by a space "1" to "31" * %g like %G, but without the century "08" * %G The 4-digit year corresponding to the ISO week number (see %V). "2008" * This has the same format and value as %Y, except that if the ISO week number * belongs to the previous or next year, that year is used instead. * %h same as %b "Jan" through "Dec" * %H hour as a decimal number using a 24-hour clock. "00" to "23" * %I hour as a decimal number using a 12-hour clock. "01" to "12" * %j day of the year as a decimal number. "001" to "366" * %m month as a decimal number. "01" to "12" * %M minute as a decimal number. "00" to "59" * %n newline character "\n" * %p either "am" or "pm" according to the given time value, or the "am" or "pm" * corresponding strings for the current locale. * %r time in a.m. and p.m. notation "8:44 PM" * %R time in 24 hour notation "20:44" * %S second as a decimal number "00" to "59" * %t tab character "\t" * %T current time, equal to %H:%M:%S "12:49:11" * %u weekday as a decimal number ["1", "7"], with "1" representing Monday "1" to "7" * %U week number of the current year as a decimal number, starting with the "0" to ("52" or "53") * first Sunday as the first day of the first week * %V The ISO 8601:1988 week number of the current year as a decimal number, "00" to ("52" or "53") * range 01 to 53, where week 1 is the first week that has at least 4 days * in the current year, and with Monday as the first day of the week. * (Use %G or %g for the year component that corresponds to the week number * for the specified timestamp.) * %W week number of the current year as a decimal number, starting with the "00" to ("52" or "53") * first Monday as the first day of the first week * %w day of the week as a decimal, Sunday being "0" "0" to "6" * %x preferred date representation for the current locale without the time "4/13/2008" * %X preferred time representation for the current locale without the date "12:53:05" * %y year as a decimal number without a century "00" "99" * %Y year as a decimal number including the century "2008" * %Z time zone or name or abbreviation "UTC", "EST", "PST" * %z same as %Z * %% a literal "%" characters "%" * d Day of the month, 2 digits with leading zeros "01" to "31" * D A textual representation of a day, three letters "Mon" through "Sun" * j Day of the month without leading zeros "1" to "31" * l A full textual representation of the day of the week (lowercase "L") "Sunday" through "Saturday" * N ISO-8601 numeric representation of the day of the week (added in PHP 5.1.0) "1" (for Monday) through "7" (for Sunday) * S English ordinal suffix for the day of the month, 2 characters "st", "nd", "rd" or "th". Works well with j * w Numeric representation of the day of the week "0" (for Sunday) through "6" (for Saturday) * z The day of the year (starting from "0") "0" through "365" * W ISO-8601 week number of year, weeks starting on Monday "00" to ("52" or "53") * F A full textual representation of a month, such as January or March "January" through "December" * m Numeric representation of a month, with leading zeros "01" through "12" * M A short textual representation of a month, three letters "Jan" through "Dec" * n Numeric representation of a month, without leading zeros "1" through "12" * t Number of days in the given month "28" through "31" * L Whether it's a leap year "1" if it is a leap year, "0" otherwise * o ISO-8601 year number. This has the same value as Y, except that if the "2008" * ISO week number (W) belongs to the previous or next year, that year * is used instead. * Y A full numeric representation of a year, 4 digits "2008" * y A two digit representation of a year "08" * a Lowercase Ante meridiem and Post meridiem "am" or "pm" * A Uppercase Ante meridiem and Post meridiem "AM" or "PM" * B Swatch Internet time "000" through "999" * g 12-hour format of an hour without leading zeros "1" through "12" * G 24-hour format of an hour without leading zeros "0" through "23" * h 12-hour format of an hour with leading zeros "01" through "12" * H 24-hour format of an hour with leading zeros "00" through "23" * i Minutes with leading zeros "00" to "59" * s Seconds, with leading zeros "00" through "59" * u Milliseconds "54321" * e Timezone identifier "UTC", "EST", "PST" * I Whether or not the date is in daylight saving time (uppercase i) "1" if Daylight Saving Time, "0" otherwise * O Difference to Greenwich time (GMT) in hours "+0200", "-0600" * P Difference to Greenwich time (GMT) with colon between hours and minutes "+02:00", "-06:00" * T Timezone abbreviation "UTC", "EST", "PST" * Z Timezone offset in seconds. The offset for timezones west of UTC is "-43200" through "50400" * always negative, and for those east of UTC is always positive. * c ISO 8601 date "2004-02-12T15:19:21+00:00" * r RFC 2822 formatted date "Thu, 21 Dec 2000 16:01:07 +0200" * U Seconds since the Unix Epoch (January 1 1970 00:00:00 GMT) "0" * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @return {String} A string representation of the current Date object. */ var formatReplace = function (context) { return function (m) { var formatString, override = false; if (m.charAt(0) === "\\" || m.substring(0, 2) === "%%") { return m.replace("\\", "").replace("%%", "%"); } override = normalizer.shouldOverrideDefaults(m); formatString = $D.normalizeFormat(m, context); if (formatString) { return context.toString(formatString, override); } }; }; $P._format = function (format) { var formatter = formatReplace(this); if (!format) { return this._toString(); } else { return format.replace(/(%|\\)?.|%%/g, formatter); } }; if (!$P.format) { $P.format = $P._format; } }()); (function () { "use strict"; var gFn = function (attr) { return function () { return this[attr]; }; }; var sFn = function (attr) { return function (val) { this[attr] = val; return this; }; }; var attrs = ["years", "months", "days", "hours", "minutes", "seconds", "milliseconds"]; var addSetFuncs = function (context, attrs) { for (var i = 0; i < attrs.length ; i++) { var $a = attrs[i], $b = $a.slice(0, 1).toUpperCase() + $a.slice(1); context.prototype[$a] = 0; context.prototype["get" + $b] = gFn($a); context.prototype["set" + $b] = sFn($a); } }; /** * new TimeSpan(milliseconds); * new TimeSpan(days, hours, minutes, seconds); * new TimeSpan(days, hours, minutes, seconds, milliseconds); */ var TimeSpan = function (days, hours, minutes, seconds, milliseconds) { if (arguments.length === 1 && typeof days === "number") { var orient = (days < 0) ? -1 : +1; var millsLeft = Math.abs(days); this.setDays(Math.floor(millsLeft / 86400000) * orient); millsLeft = millsLeft % 86400000; this.setHours(Math.floor(millsLeft / 3600000) * orient); millsLeft = millsLeft % 3600000; this.setMinutes(Math.floor(millsLeft / 60000) * orient); millsLeft = millsLeft % 60000; this.setSeconds(Math.floor(millsLeft / 1000) * orient); millsLeft = millsLeft % 1000; this.setMilliseconds(millsLeft * orient); } else { this.set(days, hours, minutes, seconds, milliseconds); } this.getTotalMilliseconds = function () { return (this.getDays() * 86400000) + (this.getHours() * 3600000) + (this.getMinutes() * 60000) + (this.getSeconds() * 1000); }; this.compareTo = function (time) { var t1 = new Date(1970, 1, 1, this.getHours(), this.getMinutes(), this.getSeconds()), t2; if (time === null) { t2 = new Date(1970, 1, 1, 0, 0, 0); } else { t2 = new Date(1970, 1, 1, time.getHours(), time.getMinutes(), time.getSeconds()); } return (t1 < t2) ? -1 : (t1 > t2) ? 1 : 0; }; this.equals = function (time) { return (this.compareTo(time) === 0); }; this.add = function (time) { return (time === null) ? this : this.addSeconds(time.getTotalMilliseconds() / 1000); }; this.subtract = function (time) { return (time === null) ? this : this.addSeconds(-time.getTotalMilliseconds() / 1000); }; this.addDays = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 86400000)); }; this.addHours = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 3600000)); }; this.addMinutes = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 60000)); }; this.addSeconds = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 1000)); }; this.addMilliseconds = function (n) { return new TimeSpan(this.getTotalMilliseconds() + n); }; this.get12HourHour = function () { return (this.getHours() > 12) ? this.getHours() - 12 : (this.getHours() === 0) ? 12 : this.getHours(); }; this.getDesignator = function () { return (this.getHours() < 12) ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator; }; this.toString = function (format) { this._toString = function () { if (this.getDays() !== null && this.getDays() > 0) { return this.getDays() + "." + this.getHours() + ":" + this.p(this.getMinutes()) + ":" + this.p(this.getSeconds()); } else { return this.getHours() + ":" + this.p(this.getMinutes()) + ":" + this.p(this.getSeconds()); } }; this.p = function (s) { return (s.toString().length < 2) ? "0" + s : s; }; var me = this; return format ? format.replace(/dd?|HH?|hh?|mm?|ss?|tt?/g, function (format) { switch (format) { case "d": return me.getDays(); case "dd": return me.p(me.getDays()); case "H": return me.getHours(); case "HH": return me.p(me.getHours()); case "h": return me.get12HourHour(); case "hh": return me.p(me.get12HourHour()); case "m": return me.getMinutes(); case "mm": return me.p(me.getMinutes()); case "s": return me.getSeconds(); case "ss": return me.p(me.getSeconds()); case "t": return ((me.getHours() < 12) ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator).substring(0, 1); case "tt": return (me.getHours() < 12) ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator; } } ) : this._toString(); }; return this; }; addSetFuncs(TimeSpan, attrs.slice(2)); TimeSpan.prototype.set = function (days, hours, minutes, seconds, milliseconds){ this.setDays(days || this.getDays()); this.setHours(hours || this.getHours()); this.setMinutes(minutes || this.getMinutes()); this.setSeconds(seconds || this.getSeconds()); this.setMilliseconds(milliseconds || this.getMilliseconds()); }; /** * Gets the time of day for this date instances. * @return {TimeSpan} TimeSpan */ Date.prototype.getTimeOfDay = function () { return new TimeSpan(0, this.getHours(), this.getMinutes(), this.getSeconds(), this.getMilliseconds()); }; Date.TimeSpan = TimeSpan; if (typeof window !== "undefined" ) { // keeping API compatible for v1.x window.TimeSpan = TimeSpan; } }()); (function () { "use strict"; var attrs = ["years", "months", "days", "hours", "minutes", "seconds", "milliseconds"]; var gFn = function (attr) { return function () { return this[attr]; }; }; var sFn = function (attr) { return function (val) { this[attr] = val; return this; }; }; var addSetFuncs = function (context, attrs) { for (var i = 0; i < attrs.length ; i++) { var $a = attrs[i], $b = $a.slice(0, 1).toUpperCase() + $a.slice(1); context.prototype[$a] = 0; context.prototype["get" + $b] = gFn($a); context.prototype["set" + $b] = sFn($a); } }; var setMonthsAndYears = function (orient, d1, d2, context) { function inc() { d1.addMonths(-orient); context.months++; if (context.months === 12) { context.years++; context.months = 0; } } if (orient === +1) { while (d1 > d2) { inc(); } } else { while (d1 < d2) { inc(); } } context.months--; context.months *= orient; context.years *= orient; }; var adjustForDST = function(orient, startDate, endDate) { var hasDSTMismatch = (false === (startDate.isDaylightSavingTime() === endDate.isDaylightSavingTime())); if (hasDSTMismatch && orient === 1) { startDate.addHours(-1); } else if (hasDSTMismatch) { startDate.addHours(1); } }; /** * TimePeriod(startDate, endDate); * TimePeriod(years, months, days, hours, minutes, seconds, milliseconds); */ var TimePeriod = function (years, months, days, hours, minutes, seconds, milliseconds) { if (arguments.length === 7) { this.set(years, months, days, hours, minutes, seconds, milliseconds); } else if (arguments.length === 2 && arguments[0] instanceof Date && arguments[1] instanceof Date) { var startDate = arguments[0].clone(); var endDate = arguments[1].clone(); var orient = (startDate > endDate) ? +1 : -1; this.dates = { start: arguments[0].clone(), end: arguments[1].clone() }; setMonthsAndYears(orient, startDate, endDate, this); adjustForDST(orient, startDate, endDate); // // TODO - adjust for DST var diff = endDate - startDate; if (diff !== 0) { var ts = new TimeSpan(diff); this.set(this.years, this.months, ts.getDays(), ts.getHours(), ts.getMinutes(), ts.getSeconds(), ts.getMilliseconds()); } } return this; }; // create all the set functions. addSetFuncs(TimePeriod, attrs); TimePeriod.prototype.set = function (years, months, days, hours, minutes, seconds, milliseconds){ this.setYears(years || this.getYears()); this.setMonths(months || this.getMonths()); this.setDays(days || this.getDays()); this.setHours(hours || this.getHours()); this.setMinutes(minutes || this.getMinutes()); this.setSeconds(seconds || this.getSeconds()); this.setMilliseconds(milliseconds || this.getMilliseconds()); }; Date.TimePeriod = TimePeriod; if (typeof window !== "undefined") { // keeping API compatible for v1.x window.TimePeriod = TimePeriod; } }()); ================================================ FILE: build/date-sms-FI.js ================================================ /** * @overview datejs * @version 1.0.0-rc3 * @author Gregory Wild-Smith * @copyright 2015 Gregory Wild-Smith * @license MIT * @homepage https://github.com/abritinthebay/datejs */ /* * DateJS Culture String File * Country Code: sms-FI * Name: Sami (Skolt) (Finland) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["sms-FI"] = { "name": "sms-FI", "englishName": "Sami (Skolt) (Finland)", "nativeName": "sääm´ǩiõll (Lää´ddjânnam)", "Sunday": "pâ´sspei´vv", "Monday": "vuõssargg", "Tuesday": "mââibargg", "Wednesday": "seärad", "Thursday": "nelljdpei´vv", "Friday": "piâtnâc", "Saturday": "sue´vet", "Sun": "pâ", "Mon": "vu", "Tue": "mâ", "Wed": "se", "Thu": "ne", "Fri": "pi", "Sat": "su", "Su": "pâ", "Mo": "vu", "Tu": "mâ", "We": "se", "Th": "ne", "Fr": "pi", "Sa": "su", "S_Sun_Initial": "p", "M_Mon_Initial": "v", "T_Tue_Initial": "m", "W_Wed_Initial": "s", "T_Thu_Initial": "n", "F_Fri_Initial": "p", "S_Sat_Initial": "s", "January": "ođđee´jjmään", "February": "tä´lvvmään", "March": "pâ´zzlâšttammään", "April": "njuhččmään", "May": "vue´ssmään", "June": "ǩie´ssmään", "July": "suei´nnmään", "August": "på´rǧǧmään", "September": "čõhččmään", "October": "kålggmään", "November": "skamm´mään", "December": "rosttovmään", "Jan_Abbr": "ođjm", "Feb_Abbr": "tä´lvv", "Mar_Abbr": "pâzl", "Apr_Abbr": "njuh", "May_Abbr": "vue", "Jun_Abbr": "ǩie", "Jul_Abbr": "suei", "Aug_Abbr": "på´r", "Sep_Abbr": "čõh", "Oct_Abbr": "kålg", "Nov_Abbr": "ska", "Dec_Abbr": "rost", "AM": "", "PM": "", "firstDayOfWeek": 1, "twoDigitYearMax": 2029, "mdy": "dmy", "M/d/yyyy": "d.M.yyyy", "dddd, MMMM dd, yyyy": "MMMM d'. p. 'yyyy", "h:mm tt": "H:mm:ss", "h:mm:ss tt": "H:mm:ss", "dddd, MMMM dd, yyyy h:mm:ss tt": "MMMM d'. p. 'yyyy H:mm:ss", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "MMMM dd", "MMMM, yyyy": "MMMM yyyy", "/jan(uary)?/": "ođđee´jjmään", "/feb(ruary)?/": "tä´lvv(mään)?", "/mar(ch)?/": "pâ´zzlâšttammään", "/apr(il)?/": "njuh(ččmään)?", "/may/": "vue(´ssmään)?", "/jun(e)?/": "ǩie(´ssmään)?", "/jul(y)?/": "suei(´nnmään)?", "/aug(ust)?/": "på´r(ǧǧmään)?", "/sep(t(ember)?)?/": "čõh(ččmään)?", "/oct(ober)?/": "kålg(gmään)?", "/nov(ember)?/": "ska(mm´mään)?", "/dec(ember)?/": "rost(tovmään)?", "/^su(n(day)?)?/": "^pâ´sspei´vv", "/^mo(n(day)?)?/": "^vuõssargg", "/^tu(e(s(day)?)?)?/": "^mââibargg", "/^we(d(nesday)?)?/": "^seärad", "/^th(u(r(s(day)?)?)?)?/": "^nelljdpei´vv", "/^fr(i(day)?)?/": "^piâtnâc", "/^sa(t(urday)?)?/": "^sue´vet", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "sms-FI"; /** * @overview datejs * @version 1.0.0-rc3 * @author Gregory Wild-Smith * @copyright 2015 Gregory Wild-Smith * @license MIT * @homepage https://github.com/abritinthebay/datejs */(function () { var $D = Date; var lang = Date.CultureStrings ? Date.CultureStrings.lang : null; var loggedKeys = {}; // for debug purposes. var getText = { getFromKey: function (key, countryCode) { var output; if (Date.CultureStrings && Date.CultureStrings[countryCode] && Date.CultureStrings[countryCode][key]) { output = Date.CultureStrings[countryCode][key]; } else { output = getText.buildFromDefault(key); } if (key.charAt(0) === "/") { // Assume it's a regex output = getText.buildFromRegex(key, countryCode); } return output; }, getFromObjectValues: function (obj, countryCode) { var key, output = {}; for(key in obj) { if (obj.hasOwnProperty(key)) { output[key] = getText.getFromKey(obj[key], countryCode); } } return output; }, getFromObjectKeys: function (obj, countryCode) { var key, output = {}; for(key in obj) { if (obj.hasOwnProperty(key)) { output[getText.getFromKey(key, countryCode)] = obj[key]; } } return output; }, getFromArray: function (arr, countryCode) { var output = []; for (var i=0; i < arr.length; i++){ if (i in arr) { output[i] = getText.getFromKey(arr[i], countryCode); } } return output; }, buildFromDefault: function (key) { var output, length, split, last; switch(key) { case "name": output = "en-US"; break; case "englishName": output = "English (United States)"; break; case "nativeName": output = "English (United States)"; break; case "twoDigitYearMax": output = 2049; break; case "firstDayOfWeek": output = 0; break; default: output = key; split = key.split("_"); length = split.length; if (length > 1 && key.charAt(0) !== "/") { // if the key isn't a regex and it has a split. last = split[(length - 1)].toLowerCase(); if (last === "initial" || last === "abbr") { output = split[0]; } } break; } return output; }, buildFromRegex: function (key, countryCode) { var output; if (Date.CultureStrings && Date.CultureStrings[countryCode] && Date.CultureStrings[countryCode][key]) { output = new RegExp(Date.CultureStrings[countryCode][key], "i"); } else { output = new RegExp(key.replace(new RegExp("/", "g"),""), "i"); } return output; } }; var shallowMerge = function (obj1, obj2) { for (var attrname in obj2) { if (obj2.hasOwnProperty(attrname)) { obj1[attrname] = obj2[attrname]; } } }; var __ = function (key, language) { var countryCode = (language) ? language : lang; loggedKeys[key] = key; if (typeof key === "object") { if (key instanceof Array) { return getText.getFromArray(key, countryCode); } else { return getText.getFromObjectKeys(key, countryCode); } } else { return getText.getFromKey(key, countryCode); } }; var loadI18nScript = function (code) { // paatterned after jQuery's getScript. var url = Date.Config.i18n + code + ".js"; var head = document.getElementsByTagName("head")[0] || document.documentElement; var script = document.createElement("script"); script.src = url; var completed = false; var events = { done: function (){} // placeholder function }; // Attach handlers for all browsers script.onload = script.onreadystatechange = function() { if ( !completed && (!this.readyState || this.readyState === "loaded" || this.readyState === "complete") ) { events.done(); head.removeChild(script); } }; setTimeout(function() { head.insertBefore(script, head.firstChild); }, 0); // allows return to execute first return { done: function (cb) { events.done = function() { if (cb) { setTimeout(cb,0); } }; } }; }; var buildInfo = { buildFromMethodHash: function (obj) { var key; for(key in obj) { if (obj.hasOwnProperty(key)) { obj[key] = buildInfo[obj[key]](); } } return obj; }, timeZoneDST: function () { var DST = { "CHADT": "+1345", "NZDT": "+1300", "AEDT": "+1100", "ACDT": "+1030", "AZST": "+0500", "IRDT": "+0430", "EEST": "+0300", "CEST": "+0200", "BST": "+0100", "PMDT": "-0200", "ADT": "-0300", "NDT": "-0230", "EDT": "-0400", "CDT": "-0500", "MDT": "-0600", "PDT": "-0700", "AKDT": "-0800", "HADT": "-0900" }; return __(DST); }, timeZoneStandard: function () { var standard = { "LINT": "+1400", "TOT": "+1300", "CHAST": "+1245", "NZST": "+1200", "NFT": "+1130", "SBT": "+1100", "AEST": "+1000", "ACST": "+0930", "JST": "+0900", "CWST": "+0845", "CT": "+0800", "ICT": "+0700", "MMT": "+0630", "BST": "+0600", "NPT": "+0545", "IST": "+0530", "PKT": "+0500", "AFT": "+0430", "MSK": "+0400", "IRST": "+0330", "FET": "+0300", "EET": "+0200", "CET": "+0100", "GMT": "+0000", "UTC": "+0000", "CVT": "-0100", "GST": "-0200", "BRT": "-0300", "NST": "-0330", "AST": "-0400", "EST": "-0500", "CST": "-0600", "MST": "-0700", "PST": "-0800", "AKST": "-0900", "MIT": "-0930", "HST": "-1000", "SST": "-1100", "BIT": "-1200" }; return __(standard); }, timeZones: function (data) { var zone; data.timezones = []; for (zone in data.abbreviatedTimeZoneStandard) { if (data.abbreviatedTimeZoneStandard.hasOwnProperty(zone)) { data.timezones.push({ name: zone, offset: data.abbreviatedTimeZoneStandard[zone]}); } } for (zone in data.abbreviatedTimeZoneDST) { if (data.abbreviatedTimeZoneDST.hasOwnProperty(zone)) { data.timezones.push({ name: zone, offset: data.abbreviatedTimeZoneDST[zone], dst: true}); } } return data.timezones; }, days: function () { return __(["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"]); }, dayAbbr: function () { return __(["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"]); }, dayShortNames: function () { return __(["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"]); }, dayFirstLetters: function () { return __(["S_Sun_Initial", "M_Mon_Initial", "T_Tues_Initial", "W_Wed_Initial", "T_Thu_Initial", "F_Fri_Initial", "S_Sat_Initial"]); }, months: function () { return __(["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"]); }, monthAbbr: function () { return __(["Jan_Abbr", "Feb_Abbr", "Mar_Abbr", "Apr_Abbr", "May_Abbr", "Jun_Abbr", "Jul_Abbr", "Aug_Abbr", "Sep_Abbr", "Oct_Abbr", "Nov_Abbr", "Dec_Abbr"]); }, formatPatterns: function () { return getText.getFromObjectValues({ shortDate: "M/d/yyyy", longDate: "dddd, MMMM dd, yyyy", shortTime: "h:mm tt", longTime: "h:mm:ss tt", fullDateTime: "dddd, MMMM dd, yyyy h:mm:ss tt", sortableDateTime: "yyyy-MM-ddTHH:mm:ss", universalSortableDateTime: "yyyy-MM-dd HH:mm:ssZ", rfc1123: "ddd, dd MMM yyyy HH:mm:ss", monthDay: "MMMM dd", yearMonth: "MMMM, yyyy" }, Date.i18n.currentLanguage()); }, regex: function () { return getText.getFromObjectValues({ inTheMorning: "/( in the )(morn(ing)?)\\b/", thisMorning: "/(this )(morn(ing)?)\\b/", amThisMorning: "/(\b\\d(am)? )(this )(morn(ing)?)/", inTheEvening: "/( in the )(even(ing)?)\\b/", thisEvening: "/(this )(even(ing)?)\\b/", pmThisEvening: "/(\b\\d(pm)? )(this )(even(ing)?)/", jan: "/jan(uary)?/", feb: "/feb(ruary)?/", mar: "/mar(ch)?/", apr: "/apr(il)?/", may: "/may/", jun: "/jun(e)?/", jul: "/jul(y)?/", aug: "/aug(ust)?/", sep: "/sep(t(ember)?)?/", oct: "/oct(ober)?/", nov: "/nov(ember)?/", dec: "/dec(ember)?/", sun: "/^su(n(day)?)?/", mon: "/^mo(n(day)?)?/", tue: "/^tu(e(s(day)?)?)?/", wed: "/^we(d(nesday)?)?/", thu: "/^th(u(r(s(day)?)?)?)?/", fri: "/fr(i(day)?)?/", sat: "/^sa(t(urday)?)?/", future: "/^next/", past: "/^last|past|prev(ious)?/", add: "/^(\\+|aft(er)?|from|hence)/", subtract: "/^(\\-|bef(ore)?|ago)/", yesterday: "/^yes(terday)?/", today: "/^t(od(ay)?)?/", tomorrow: "/^tom(orrow)?/", now: "/^n(ow)?/", millisecond: "/^ms|milli(second)?s?/", second: "/^sec(ond)?s?/", minute: "/^mn|min(ute)?s?/", hour: "/^h(our)?s?/", week: "/^w(eek)?s?/", month: "/^m(onth)?s?/", day: "/^d(ay)?s?/", year: "/^y(ear)?s?/", shortMeridian: "/^(a|p)/", longMeridian: "/^(a\\.?m?\\.?|p\\.?m?\\.?)/", timezone: "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/", ordinalSuffix: "/^\\s*(st|nd|rd|th)/", timeContext: "/^\\s*(\\:|a(?!u|p)|p)/" }, Date.i18n.currentLanguage()); } }; var CultureInfo = function () { var info = getText.getFromObjectValues({ name: "name", englishName: "englishName", nativeName: "nativeName", amDesignator: "AM", pmDesignator: "PM", firstDayOfWeek: "firstDayOfWeek", twoDigitYearMax: "twoDigitYearMax", dateElementOrder: "mdy" }, Date.i18n.currentLanguage()); var constructedInfo = buildInfo.buildFromMethodHash({ dayNames: "days", abbreviatedDayNames: "dayAbbr", shortestDayNames: "dayShortNames", firstLetterDayNames: "dayFirstLetters", monthNames: "months", abbreviatedMonthNames: "monthAbbr", formatPatterns: "formatPatterns", regexPatterns: "regex", abbreviatedTimeZoneDST: "timeZoneDST", abbreviatedTimeZoneStandard: "timeZoneStandard" }); shallowMerge(info, constructedInfo); buildInfo.timeZones(info); return info; }; $D.i18n = { __: function (key, lang) { return __(key, lang); }, currentLanguage: function () { return lang || "en-US"; }, setLanguage: function (code, force, cb) { var async = false; if (force || code === "en-US" || (!!Date.CultureStrings && !!Date.CultureStrings[code])) { lang = code; Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings.lang = code; Date.CultureInfo = new CultureInfo(); } else { if (!(!!Date.CultureStrings && !!Date.CultureStrings[code])) { if (typeof exports !== "undefined" && this.exports !== exports) { // we're in a Node enviroment, load it using require try { require("../i18n/" + code + ".js"); lang = code; Date.CultureStrings.lang = code; Date.CultureInfo = new CultureInfo(); } catch (e) { // var str = "The language for '" + code + "' could not be loaded by Node. It likely does not exist."; throw new Error("The DateJS IETF language tag '" + code + "' could not be loaded by Node. It likely does not exist."); } } else if (Date.Config && Date.Config.i18n) { // we know the location of the files, so lets load them async = true; loadI18nScript(code).done(function(){ lang = code; Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings.lang = code; Date.CultureInfo = new CultureInfo(); $D.Parsing.Normalizer.buildReplaceData(); // because this is async if ($D.Grammar) { $D.Grammar.buildGrammarFormats(); // so we can parse those strings... } if (cb) { setTimeout(cb,0); } }); } else { Date.console.error("The DateJS IETF language tag '" + code + "' is not available and has not been loaded."); return false; } } } $D.Parsing.Normalizer.buildReplaceData(); // rebuild normalizer strings if ($D.Grammar) { $D.Grammar.buildGrammarFormats(); // so we can parse those strings... } if (!async && cb) { setTimeout(cb,0); } }, getLoggedKeys: function () { return loggedKeys; }, updateCultureInfo: function () { Date.CultureInfo = new CultureInfo(); } }; $D.i18n.updateCultureInfo(); // run automatically }()); (function () { var $D = Date, $P = $D.prototype, p = function (s, l) { if (!l) { l = 2; } return ("000" + s).slice(l * -1); }; if (typeof window !== "undefined" && typeof window.console !== "undefined" && typeof window.console.log !== "undefined") { $D.console = console; // used only to raise non-critical errors if available } else { // set mock so we don't give errors. $D.console = { log: function(){}, error: function(){} }; } $D.Config = $D.Config || {}; $D.initOverloads = function() { /** * Overload of Date.now. Allows an alternate call for Date.now where it returns the * current Date as an object rather than just milliseconds since the Unix Epoch. * * Also provides an implementation of now() for browsers (IE<9) that don't have it. * * Backwards compatible so with work with either: * Date.now() [returns ms] * or * Date.now(true) [returns Date] */ if (!$D.now) { $D._now = function now() { return new Date().getTime(); }; } else if (!$D._now) { $D._now = $D.now; } $D.now = function (returnObj) { if (returnObj) { return $D.present(); } else { return $D._now(); } }; if ( !$P.toISOString ) { $P.toISOString = function() { return this.getUTCFullYear() + "-" + p(this.getUTCMonth() + 1) + "-" + p(this.getUTCDate()) + "T" + p(this.getUTCHours()) + ":" + p(this.getUTCMinutes()) + ":" + p(this.getUTCSeconds()) + "." + String( (this.getUTCMilliseconds()/1000).toFixed(3)).slice(2, 5) + "Z"; }; } // private if ( $P._toString === undefined ){ $P._toString = $P.toString; } }; $D.initOverloads(); /** * Gets a date that is set to the current date. The time is set to the start of the day (00:00 or 12:00 AM). * @return {Date} The current date. */ $D.today = function () { return new Date().clearTime(); }; /** * Gets a date that is set to the current date and time (same as new Date, but chainable) * @return {Date} The current date. */ $D.present = function () { return new Date(); }; /** * Compares the first date to the second date and returns an number indication of their relative values. * @param {Date} First Date object to compare [Required]. * @param {Date} Second Date object to compare to [Required]. * @return {Number} -1 = date1 is lessthan date2. 0 = values are equal. 1 = date1 is greaterthan date2. */ $D.compare = function (date1, date2) { if (isNaN(date1) || isNaN(date2)) { throw new Error(date1 + " - " + date2); } else if (date1 instanceof Date && date2 instanceof Date) { return (date1 < date2) ? -1 : (date1 > date2) ? 1 : 0; } else { throw new TypeError(date1 + " - " + date2); } }; /** * Compares the first Date object to the second Date object and returns true if they are equal. * @param {Date} First Date object to compare [Required] * @param {Date} Second Date object to compare to [Required] * @return {Boolean} true if dates are equal. false if they are not equal. */ $D.equals = function (date1, date2) { return (date1.compareTo(date2) === 0); }; /** * Gets the language appropriate day name when given the day number(0-6) * eg - 0 == Sunday * @return {String} The day name */ $D.getDayName = function (n) { return Date.CultureInfo.dayNames[n]; }; /** * Gets the day number (0-6) if given a CultureInfo specific string which is a valid dayName, abbreviatedDayName or shortestDayName (two char). * @param {String} The name of the day (eg. "Monday, "Mon", "tuesday", "tue", "We", "we"). * @return {Number} The day number */ $D.getDayNumberFromName = function (name) { var n = Date.CultureInfo.dayNames, m = Date.CultureInfo.abbreviatedDayNames, o = Date.CultureInfo.shortestDayNames, s = name.toLowerCase(); for (var i = 0; i < n.length; i++) { if (n[i].toLowerCase() === s || m[i].toLowerCase() === s || o[i].toLowerCase() === s) { return i; } } return -1; }; /** * Gets the month number (0-11) if given a Culture Info specific string which is a valid monthName or abbreviatedMonthName. * @param {String} The name of the month (eg. "February, "Feb", "october", "oct"). * @return {Number} The day number */ $D.getMonthNumberFromName = function (name) { var n = Date.CultureInfo.monthNames, m = Date.CultureInfo.abbreviatedMonthNames, s = name.toLowerCase(); for (var i = 0; i < n.length; i++) { if (n[i].toLowerCase() === s || m[i].toLowerCase() === s) { return i; } } return -1; }; /** * Gets the language appropriate month name when given the month number(0-11) * eg - 0 == January * @return {String} The month name */ $D.getMonthName = function (n) { return Date.CultureInfo.monthNames[n]; }; /** * Determines if the current date instance is within a LeapYear. * @param {Number} The year. * @return {Boolean} true if date is within a LeapYear, otherwise false. */ $D.isLeapYear = function (year) { return ((year % 4 === 0 && year % 100 !== 0) || year % 400 === 0); }; /** * Gets the number of days in the month, given a year and month value. Automatically corrects for LeapYear. * @param {Number} The year. * @param {Number} The month (0-11). * @return {Number} The number of days in the month. */ $D.getDaysInMonth = function (year, month) { if (!month && $D.validateMonth(year)) { month = year; year = Date.today().getFullYear(); } return [31, ($D.isLeapYear(year) ? 29 : 28), 31, 30, 31, 30, 31, 31, 30, 31, 30, 31][month]; }; $P.getDaysInMonth = function () { return $D.getDaysInMonth(this.getFullYear(), this.getMonth()); }; $D.getTimezoneAbbreviation = function (offset, dst) { var p, n = (dst || false) ? Date.CultureInfo.abbreviatedTimeZoneDST : Date.CultureInfo.abbreviatedTimeZoneStandard; for (p in n) { if (n.hasOwnProperty(p)) { if (n[p] === offset) { return p; } } } return null; }; $D.getTimezoneOffset = function (name, dst) { var i, a =[], z = Date.CultureInfo.timezones; if (!name) { name = (new Date()).getTimezone();} for (i = 0; i < z.length; i++) { if (z[i].name === name.toUpperCase()) { a.push(i); } } if (!z[a[0]]) { return null; } if (a.length === 1 || !dst) { return z[a[0]].offset; } else { for (i=0; i < a.length; i++) { if (z[a[i]].dst) { return z[a[i]].offset; } } } }; $D.getQuarter = function (d) { d = d || new Date(); // If no date supplied, use today var q = [1,2,3,4]; return q[Math.floor(d.getMonth() / 3)]; // ~~~ is a bitwise op. Faster than Math.floor }; $D.getDaysLeftInQuarter = function (d) { d = d || new Date(); var qEnd = new Date(d); qEnd.setMonth(qEnd.getMonth() + 3 - qEnd.getMonth() % 3, 0); return Math.floor((qEnd - d) / 8.64e7); }; // private var validate = function (n, min, max, name) { name = name ? name : "Object"; if (typeof n === "undefined") { return false; } else if (typeof n !== "number") { throw new TypeError(n + " is not a Number."); } else if (n < min || n > max) { // As failing validation is *not* an exceptional circumstance // lets not throw a RangeError Exception here. // It's semantically correct but it's not sensible. return false; } return true; }; /** * Validates the number is within an acceptable range for milliseconds [0-999]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateMillisecond = function (value) { return validate(value, 0, 999, "millisecond"); }; /** * Validates the number is within an acceptable range for seconds [0-59]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateSecond = function (value) { return validate(value, 0, 59, "second"); }; /** * Validates the number is within an acceptable range for minutes [0-59]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateMinute = function (value) { return validate(value, 0, 59, "minute"); }; /** * Validates the number is within an acceptable range for hours [0-23]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateHour = function (value) { return validate(value, 0, 23, "hour"); }; /** * Validates the number is within an acceptable range for the days in a month [0-MaxDaysInMonth]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateDay = function (value, year, month) { if (year === undefined || year === null || month === undefined || month === null) { return false;} return validate(value, 1, $D.getDaysInMonth(year, month), "day"); }; /** * Validates the number is within an acceptable range for months [0-11]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateWeek = function (value) { return validate(value, 0, 53, "week"); }; /** * Validates the number is within an acceptable range for months [0-11]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateMonth = function (value) { return validate(value, 0, 11, "month"); }; /** * Validates the number is within an acceptable range for years. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateYear = function (value) { /** * Per ECMAScript spec the range of times supported by Date objects is * exactly -100,000,000 days to +100,000,000 days measured relative to * midnight at the beginning of 01 January, 1970 UTC. * This gives a range of 8,640,000,000,000,000 milliseconds to either * side of 01 January, 1970 UTC. * * Earliest possible date: Tue, 20 Apr 271,822 B.C. 00:00:00 UTC * Latest possible date: Sat, 13 Sep 275,760 00:00:00 UTC */ return validate(value, -271822, 275760, "year"); }; $D.validateTimezone = function(value) { var timezones = {"ACDT":1,"ACST":1,"ACT":1,"ADT":1,"AEDT":1,"AEST":1,"AFT":1,"AKDT":1,"AKST":1,"AMST":1,"AMT":1,"ART":1,"AST":1,"AWDT":1,"AWST":1,"AZOST":1,"AZT":1,"BDT":1,"BIOT":1,"BIT":1,"BOT":1,"BRT":1,"BST":1,"BTT":1,"CAT":1,"CCT":1,"CDT":1,"CEDT":1,"CEST":1,"CET":1,"CHADT":1,"CHAST":1,"CHOT":1,"ChST":1,"CHUT":1,"CIST":1,"CIT":1,"CKT":1,"CLST":1,"CLT":1,"COST":1,"COT":1,"CST":1,"CT":1,"CVT":1,"CWST":1,"CXT":1,"DAVT":1,"DDUT":1,"DFT":1,"EASST":1,"EAST":1,"EAT":1,"ECT":1,"EDT":1,"EEDT":1,"EEST":1,"EET":1,"EGST":1,"EGT":1,"EIT":1,"EST":1,"FET":1,"FJT":1,"FKST":1,"FKT":1,"FNT":1,"GALT":1,"GAMT":1,"GET":1,"GFT":1,"GILT":1,"GIT":1,"GMT":1,"GST":1,"GYT":1,"HADT":1,"HAEC":1,"HAST":1,"HKT":1,"HMT":1,"HOVT":1,"HST":1,"ICT":1,"IDT":1,"IOT":1,"IRDT":1,"IRKT":1,"IRST":1,"IST":1,"JST":1,"KGT":1,"KOST":1,"KRAT":1,"KST":1,"LHST":1,"LINT":1,"MAGT":1,"MART":1,"MAWT":1,"MDT":1,"MET":1,"MEST":1,"MHT":1,"MIST":1,"MIT":1,"MMT":1,"MSK":1,"MST":1,"MUT":1,"MVT":1,"MYT":1,"NCT":1,"NDT":1,"NFT":1,"NPT":1,"NST":1,"NT":1,"NUT":1,"NZDT":1,"NZST":1,"OMST":1,"ORAT":1,"PDT":1,"PET":1,"PETT":1,"PGT":1,"PHOT":1,"PHT":1,"PKT":1,"PMDT":1,"PMST":1,"PONT":1,"PST":1,"PYST":1,"PYT":1,"RET":1,"ROTT":1,"SAKT":1,"SAMT":1,"SAST":1,"SBT":1,"SCT":1,"SGT":1,"SLST":1,"SRT":1,"SST":1,"SYOT":1,"TAHT":1,"THA":1,"TFT":1,"TJT":1,"TKT":1,"TLT":1,"TMT":1,"TOT":1,"TVT":1,"UCT":1,"ULAT":1,"UTC":1,"UYST":1,"UYT":1,"UZT":1,"VET":1,"VLAT":1,"VOLT":1,"VOST":1,"VUT":1,"WAKT":1,"WAST":1,"WAT":1,"WEDT":1,"WEST":1,"WET":1,"WST":1,"YAKT":1,"YEKT":1,"Z":1}; return (timezones[value] === 1); }; $D.validateTimezoneOffset= function(value) { // timezones go from +14hrs to -12hrs, the +X hours are negative offsets. return (value > -841 && value < 721); }; }()); (function () { var $D = Date, $P = $D.prototype, p = function (s, l) { if (!l) { l = 2; } return ("000" + s).slice(l * -1); }; var validateConfigObject = function (obj) { var result = {}, self = this, prop, testFunc; testFunc = function (prop, func, value) { if (prop === "day") { var month = (obj.month !== undefined) ? obj.month : self.getMonth(); var year = (obj.year !== undefined) ? obj.year : self.getFullYear(); return $D[func](value, year, month); } else { return $D[func](value); } }; for (prop in obj) { if (Object.prototype.hasOwnProperty.call(obj, prop)) { var func = "validate" + prop.charAt(0).toUpperCase() + prop.slice(1); if ($D[func] && obj[prop] !== null && testFunc(prop, func, obj[prop])) { result[prop] = obj[prop]; } } } return result; }; /** * Resets the time of this Date object to 12:00 AM (00:00), which is the start of the day. * @param {Boolean} .clone() this date instance before clearing Time * @return {Date} this */ $P.clearTime = function () { this.setHours(0); this.setMinutes(0); this.setSeconds(0); this.setMilliseconds(0); return this; }; /** * Resets the time of this Date object to the current time ('now'). * @return {Date} this */ $P.setTimeToNow = function () { var n = new Date(); this.setHours(n.getHours()); this.setMinutes(n.getMinutes()); this.setSeconds(n.getSeconds()); this.setMilliseconds(n.getMilliseconds()); return this; }; /** * Returns a new Date object that is an exact date and time copy of the original instance. * @return {Date} A new Date instance */ $P.clone = function () { return new Date(this.getTime()); }; /** * Compares this instance to a Date object and returns an number indication of their relative values. * @param {Date} Date object to compare [Required] * @return {Number} -1 = this is lessthan date. 0 = values are equal. 1 = this is greaterthan date. */ $P.compareTo = function (date) { return Date.compare(this, date); }; /** * Compares this instance to another Date object and returns true if they are equal. * @param {Date} Date object to compare. If no date to compare, new Date() [now] is used. * @return {Boolean} true if dates are equal. false if they are not equal. */ $P.equals = function (date) { return Date.equals(this, (date !== undefined ? date : new Date())); }; /** * Determines if this instance is between a range of two dates or equal to either the start or end dates. * @param {Date} Start of range [Required] * @param {Date} End of range [Required] * @return {Boolean} true is this is between or equal to the start and end dates, else false */ $P.between = function (start, end) { return this.getTime() >= start.getTime() && this.getTime() <= end.getTime(); }; /** * Determines if this date occurs after the date to compare to. * @param {Date} Date object to compare. If no date to compare, new Date() ("now") is used. * @return {Boolean} true if this date instance is greater than the date to compare to (or "now"), otherwise false. */ $P.isAfter = function (date) { return this.compareTo(date || new Date()) === 1; }; /** * Determines if this date occurs before the date to compare to. * @param {Date} Date object to compare. If no date to compare, new Date() ("now") is used. * @return {Boolean} true if this date instance is less than the date to compare to (or "now"). */ $P.isBefore = function (date) { return (this.compareTo(date || new Date()) === -1); }; /** * Determines if the current Date instance occurs today. * @return {Boolean} true if this date instance is 'today', otherwise false. */ /** * Determines if the current Date instance occurs on the same Date as the supplied 'date'. * If no 'date' to compare to is provided, the current Date instance is compared to 'today'. * @param {date} Date object to compare. If no date to compare, the current Date ("now") is used. * @return {Boolean} true if this Date instance occurs on the same Day as the supplied 'date'. */ $P.isToday = $P.isSameDay = function (date) { return this.clone().clearTime().equals((date || new Date()).clone().clearTime()); }; /** * Adds the specified number of milliseconds to this instance. * @param {Number} The number of milliseconds to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addMilliseconds = function (value) { if (!value) { return this; } this.setTime(this.getTime() + value * 1); return this; }; /** * Adds the specified number of seconds to this instance. * @param {Number} The number of seconds to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addSeconds = function (value) { if (!value) { return this; } return this.addMilliseconds(value * 1000); }; /** * Adds the specified number of seconds to this instance. * @param {Number} The number of seconds to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addMinutes = function (value) { if (!value) { return this; } return this.addMilliseconds(value * 60000); // 60*1000 }; /** * Adds the specified number of hours to this instance. * @param {Number} The number of hours to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addHours = function (value) { if (!value) { return this; } return this.addMilliseconds(value * 3600000); // 60*60*1000 }; /** * Adds the specified number of days to this instance. * @param {Number} The number of days to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addDays = function (value) { if (!value) { return this; } this.setDate(this.getDate() + value * 1); return this; }; /** * Adds the specified number of weekdays (ie - not sat or sun) to this instance. * @param {Number} The number of days to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addWeekdays = function (value) { if (!value) { return this; } var day = this.getDay(); var weeks = (Math.ceil(Math.abs(value)/7)); if (day === 0 || day === 6) { if (value > 0) { this.next().monday(); this.addDays(-1); day = this.getDay(); } } if (value < 0) { while (value < 0) { this.addDays(-1); day = this.getDay(); if (day !== 0 && day !== 6) { value++; } } return this; } else if (value > 5 || (6-day) <= value) { value = value + (weeks * 2); } return this.addDays(value); }; /** * Adds the specified number of weeks to this instance. * @param {Number} The number of weeks to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addWeeks = function (value) { if (!value) { return this; } return this.addDays(value * 7); }; /** * Adds the specified number of months to this instance. * @param {Number} The number of months to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addMonths = function (value) { if (!value) { return this; } var n = this.getDate(); this.setDate(1); this.setMonth(this.getMonth() + value * 1); this.setDate(Math.min(n, $D.getDaysInMonth(this.getFullYear(), this.getMonth()))); return this; }; $P.addQuarters = function (value) { if (!value) { return this; } // note this will take you to the same point in the quarter as you are now. // i.e. - if you are 15 days into the quarter you'll be 15 days into the resulting one. // bonus: this allows adding fractional quarters return this.addMonths(value * 3); }; /** * Adds the specified number of years to this instance. * @param {Number} The number of years to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addYears = function (value) { if (!value) { return this; } return this.addMonths(value * 12); }; /** * Adds (or subtracts) to the value of the years, months, weeks, days, hours, minutes, seconds, milliseconds of the date instance using given configuration object. Positive and Negative values allowed. * Example

	Date.today().add( { days: 1, months: 1 } )

	new Date().add( { years: -1 } )
	
* @param {Object} Configuration object containing attributes (months, days, etc.) * @return {Date} this */ $P.add = function (config) { if (typeof config === "number") { this._orient = config; return this; } var x = config; if (x.day) { // If we should be a different date than today (eg: for 'tomorrow -1d', etc). // Should only effect parsing, not direct usage (eg, Finish and FinishExact) if ((x.day - this.getDate()) !== 0) { this.setDate(x.day); } } if (x.milliseconds) { this.addMilliseconds(x.milliseconds); } if (x.seconds) { this.addSeconds(x.seconds); } if (x.minutes) { this.addMinutes(x.minutes); } if (x.hours) { this.addHours(x.hours); } if (x.weeks) { this.addWeeks(x.weeks); } if (x.months) { this.addMonths(x.months); } if (x.years) { this.addYears(x.years); } if (x.days) { this.addDays(x.days); } return this; }; /** * Get the week number. Week one (1) is the week which contains the first Thursday of the year. Monday is considered the first day of the week. * The .getWeek() function does NOT convert the date to UTC. The local datetime is used. * Please use .getISOWeek() to get the week of the UTC converted date. * @return {Number} 1 to 53 */ $P.getWeek = function (utc) { // Create a copy of this date object var self, target = new Date(this.valueOf()); if (utc) { target.addMinutes(target.getTimezoneOffset()); self = target.clone(); } else { self = this; } // ISO week date weeks start on monday // so correct the day number var dayNr = (self.getDay() + 6) % 7; // ISO 8601 states that week 1 is the week // with the first thursday of that year. // Set the target date to the thursday in the target week target.setDate(target.getDate() - dayNr + 3); // Store the millisecond value of the target date var firstThursday = target.valueOf(); // Set the target to the first thursday of the year // First set the target to january first target.setMonth(0, 1); // Not a thursday? Correct the date to the next thursday if (target.getDay() !== 4) { target.setMonth(0, 1 + ((4 - target.getDay()) + 7) % 7); } // The weeknumber is the number of weeks between the // first thursday of the year and the thursday in the target week return 1 + Math.ceil((firstThursday - target) / 604800000); // 604800000 = 7 * 24 * 3600 * 1000 }; /** * Get the ISO 8601 week number. Week one ("01") is the week which contains the first Thursday of the year. Monday is considered the first day of the week. * The .getISOWeek() function does convert the date to it's UTC value. Please use .getWeek() to get the week of the local date. * @return {String} "01" to "53" */ $P.getISOWeek = function () { return p(this.getWeek(true)); }; /** * Moves the date to Monday of the week set. Week one (1) is the week which contains the first Thursday of the year. * @param {Number} A Number (1 to 53) that represents the week of the year. * @return {Date} this */ $P.setWeek = function (n) { if ((n - this.getWeek()) === 0) { if (this.getDay() !== 1) { return this.moveToDayOfWeek(1, (this.getDay() > 1 ? -1 : 1)); } else { return this; } } else { return this.moveToDayOfWeek(1, (this.getDay() > 1 ? -1 : 1)).addWeeks(n - this.getWeek()); } }; $P.setQuarter = function (qtr) { var month = Math.abs(((qtr-1) * 3) + 1); return this.setMonth(month, 1); }; $P.getQuarter = function () { return Date.getQuarter(this); }; $P.getDaysLeftInQuarter = function () { return Date.getDaysLeftInQuarter(this); }; /** * Moves the date to the next n'th occurrence of the dayOfWeek starting from the beginning of the month. The number (-1) is a magic number and will return the last occurrence of the dayOfWeek in the month. * @param {Number} The dayOfWeek to move to * @param {Number} The n'th occurrence to move to. Use (-1) to return the last occurrence in the month * @return {Date} this */ $P.moveToNthOccurrence = function (dayOfWeek, occurrence) { if (dayOfWeek === "Weekday") { if (occurrence > 0) { this.moveToFirstDayOfMonth(); if (this.is().weekday()) { occurrence -= 1; } } else if (occurrence < 0) { this.moveToLastDayOfMonth(); if (this.is().weekday()) { occurrence += 1; } } else { return this; } return this.addWeekdays(occurrence); } var shift = 0; if (occurrence > 0) { shift = occurrence - 1; } else if (occurrence === -1) { this.moveToLastDayOfMonth(); if (this.getDay() !== dayOfWeek) { this.moveToDayOfWeek(dayOfWeek, -1); } return this; } return this.moveToFirstDayOfMonth().addDays(-1).moveToDayOfWeek(dayOfWeek, +1).addWeeks(shift); }; var moveToN = function (getFunc, addFunc, nVal) { return function (value, orient) { var diff = (value - this[getFunc]() + nVal * (orient || +1)) % nVal; return this[addFunc]((diff === 0) ? diff += nVal * (orient || +1) : diff); }; }; /** * Move to the next or last dayOfWeek based on the orient value. * @param {Number} The dayOfWeek to move to * @param {Number} Forward (+1) or Back (-1). Defaults to +1. [Optional] * @return {Date} this */ $P.moveToDayOfWeek = moveToN("getDay", "addDays", 7); /** * Move to the next or last month based on the orient value. * @param {Number} The month to move to. 0 = January, 11 = December * @param {Number} Forward (+1) or Back (-1). Defaults to +1. [Optional] * @return {Date} this */ $P.moveToMonth = moveToN("getMonth", "addMonths", 12); /** * Get the Ordinate of the current day ("th", "st", "rd"). * @return {String} */ $P.getOrdinate = function () { var num = this.getDate(); return ord(num); }; /** * Get the Ordinal day (numeric day number) of the year, adjusted for leap year. * @return {Number} 1 through 365 (366 in leap years) */ $P.getOrdinalNumber = function () { return Math.ceil((this.clone().clearTime() - new Date(this.getFullYear(), 0, 1)) / 86400000) + 1; }; /** * Get the time zone abbreviation of the current date. * @return {String} The abbreviated time zone name (e.g. "EST") */ $P.getTimezone = function () { return $D.getTimezoneAbbreviation(this.getUTCOffset(), this.isDaylightSavingTime()); }; $P.setTimezoneOffset = function (offset) { var here = this.getTimezoneOffset(), there = Number(offset) * -6 / 10; return (there || there === 0) ? this.addMinutes(there - here) : this; }; $P.setTimezone = function (offset) { return this.setTimezoneOffset($D.getTimezoneOffset(offset)); }; /** * Indicates whether Daylight Saving Time is observed in the current time zone. * @return {Boolean} true|false */ $P.hasDaylightSavingTime = function () { return (Date.today().set({month: 0, day: 1}).getTimezoneOffset() !== Date.today().set({month: 6, day: 1}).getTimezoneOffset()); }; /** * Indicates whether this Date instance is within the Daylight Saving Time range for the current time zone. * @return {Boolean} true|false */ $P.isDaylightSavingTime = function () { return Date.today().set({month: 0, day: 1}).getTimezoneOffset() !== this.getTimezoneOffset(); }; /** * Get the offset from UTC of the current date. * @return {String} The 4-character offset string prefixed with + or - (e.g. "-0500") */ $P.getUTCOffset = function (offset) { var n = (offset || this.getTimezoneOffset()) * -10 / 6, r; if (n < 0) { r = (n - 10000).toString(); return r.charAt(0) + r.substr(2); } else { r = (n + 10000).toString(); return "+" + r.substr(1); } }; /** * Returns the number of milliseconds between this date and date. * @param {Date} Defaults to now * @return {Number} The diff in milliseconds */ $P.getElapsed = function (date) { return (date || new Date()) - this; }; /** * Set the value of year, month, day, hour, minute, second, millisecond of date instance using given configuration object. * Example

	Date.today().set( { day: 20, month: 1 } )

	new Date().set( { millisecond: 0 } )
	
* * @param {Object} Configuration object containing attributes (month, day, etc.) * @return {Date} this */ $P.set = function (config) { config = validateConfigObject.call(this, config); var key; for (key in config) { if (Object.prototype.hasOwnProperty.call(config, key)) { var name = key.charAt(0).toUpperCase() + key.slice(1); var addFunc, getFunc; if (key !== "week" && key !== "month" && key !== "timezone" && key !== "timezoneOffset") { name += "s"; } addFunc = "add" + name; getFunc = "get" + name; if (key === "month") { addFunc = addFunc + "s"; } else if (key === "year"){ getFunc = "getFullYear"; } if (key !== "day" && key !== "timezone" && key !== "timezoneOffset" && key !== "week" && key !== "hour") { this[addFunc](config[key] - this[getFunc]()); } else if ( key === "timezone"|| key === "timezoneOffset" || key === "week" || key === "hour") { this["set"+name](config[key]); } } } // day has to go last because you can't validate the day without first knowing the month if (config.day) { this.addDays(config.day - this.getDate()); } return this; }; /** * Moves the date to the first day of the month. * @return {Date} this */ $P.moveToFirstDayOfMonth = function () { return this.set({ day: 1 }); }; /** * Moves the date to the last day of the month. * @return {Date} this */ $P.moveToLastDayOfMonth = function () { return this.set({ day: $D.getDaysInMonth(this.getFullYear(), this.getMonth())}); }; /** * Converts the value of the current Date object to its equivalent string representation. * Format Specifiers * CUSTOM DATE AND TIME FORMAT STRINGS * Format Description Example * ------ --------------------------------------------------------------------------- ----------------------- * s The seconds of the minute between 0-59. "0" to "59" * ss The seconds of the minute with leading zero if required. "00" to "59" * * m The minute of the hour between 0-59. "0" or "59" * mm The minute of the hour with leading zero if required. "00" or "59" * * h The hour of the day between 1-12. "1" to "12" * hh The hour of the day with leading zero if required. "01" to "12" * * H The hour of the day between 0-23. "0" to "23" * HH The hour of the day with leading zero if required. "00" to "23" * * d The day of the month between 1 and 31. "1" to "31" * dd The day of the month with leading zero if required. "01" to "31" * ddd Abbreviated day name. Date.CultureInfo.abbreviatedDayNames. "Mon" to "Sun" * dddd The full day name. Date.CultureInfo.dayNames. "Monday" to "Sunday" * * M The month of the year between 1-12. "1" to "12" * MM The month of the year with leading zero if required. "01" to "12" * MMM Abbreviated month name. Date.CultureInfo.abbreviatedMonthNames. "Jan" to "Dec" * MMMM The full month name. Date.CultureInfo.monthNames. "January" to "December" * * yy The year as a two-digit number. "99" or "08" * yyyy The full four digit year. "1999" or "2008" * * t Displays the first character of the A.M./P.M. designator. "A" or "P" * Date.CultureInfo.amDesignator or Date.CultureInfo.pmDesignator * tt Displays the A.M./P.M. designator. "AM" or "PM" * Date.CultureInfo.amDesignator or Date.CultureInfo.pmDesignator * * S The ordinal suffix ("st, "nd", "rd" or "th") of the current day. "st, "nd", "rd" or "th" * * STANDARD DATE AND TIME FORMAT STRINGS * Format Description Example *------ --------------------------------------------------------------------------- ----------------------- * d The CultureInfo shortDate Format Pattern "M/d/yyyy" * D The CultureInfo longDate Format Pattern "dddd, MMMM dd, yyyy" * F The CultureInfo fullDateTime Format Pattern "dddd, MMMM dd, yyyy h:mm:ss tt" * m The CultureInfo monthDay Format Pattern "MMMM dd" * r The CultureInfo rfc1123 Format Pattern "ddd, dd MMM yyyy HH:mm:ss GMT" * s The CultureInfo sortableDateTime Format Pattern "yyyy-MM-ddTHH:mm:ss" * t The CultureInfo shortTime Format Pattern "h:mm tt" * T The CultureInfo longTime Format Pattern "h:mm:ss tt" * u The CultureInfo universalSortableDateTime Format Pattern "yyyy-MM-dd HH:mm:ssZ" * y The CultureInfo yearMonth Format Pattern "MMMM, yyyy" * * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @return {String} A string representation of the current Date object. */ var ord = function (n) { switch (n * 1) { case 1: case 21: case 31: return "st"; case 2: case 22: return "nd"; case 3: case 23: return "rd"; default: return "th"; } }; var parseStandardFormats = function (format) { var y, c = Date.CultureInfo.formatPatterns; switch (format) { case "d": return this.toString(c.shortDate); case "D": return this.toString(c.longDate); case "F": return this.toString(c.fullDateTime); case "m": return this.toString(c.monthDay); case "r": case "R": y = this.clone().addMinutes(this.getTimezoneOffset()); return y.toString(c.rfc1123) + " GMT"; case "s": return this.toString(c.sortableDateTime); case "t": return this.toString(c.shortTime); case "T": return this.toString(c.longTime); case "u": y = this.clone().addMinutes(this.getTimezoneOffset()); return y.toString(c.universalSortableDateTime); case "y": return this.toString(c.yearMonth); default: return false; } }; var parseFormatStringsClosure = function (context) { return function (m) { if (m.charAt(0) === "\\") { return m.replace("\\", ""); } switch (m) { case "hh": return p(context.getHours() < 13 ? (context.getHours() === 0 ? 12 : context.getHours()) : (context.getHours() - 12)); case "h": return context.getHours() < 13 ? (context.getHours() === 0 ? 12 : context.getHours()) : (context.getHours() - 12); case "HH": return p(context.getHours()); case "H": return context.getHours(); case "mm": return p(context.getMinutes()); case "m": return context.getMinutes(); case "ss": return p(context.getSeconds()); case "s": return context.getSeconds(); case "yyyy": return p(context.getFullYear(), 4); case "yy": return p(context.getFullYear()); case "y": return context.getFullYear(); case "E": case "dddd": return Date.CultureInfo.dayNames[context.getDay()]; case "ddd": return Date.CultureInfo.abbreviatedDayNames[context.getDay()]; case "dd": return p(context.getDate()); case "d": return context.getDate(); case "MMMM": return Date.CultureInfo.monthNames[context.getMonth()]; case "MMM": return Date.CultureInfo.abbreviatedMonthNames[context.getMonth()]; case "MM": return p((context.getMonth() + 1)); case "M": return context.getMonth() + 1; case "t": return context.getHours() < 12 ? Date.CultureInfo.amDesignator.substring(0, 1) : Date.CultureInfo.pmDesignator.substring(0, 1); case "tt": return context.getHours() < 12 ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator; case "S": return ord(context.getDate()); case "W": return context.getWeek(); case "WW": return context.getISOWeek(); case "Q": return "Q" + context.getQuarter(); case "q": return String(context.getQuarter()); case "z": return context.getTimezone(); case "Z": case "X": return Date.getTimezoneOffset(context.getTimezone()); case "ZZ": // Timezone offset in seconds return context.getTimezoneOffset() * -60; case "u": return context.getDay(); case "L": return ($D.isLeapYear(context.getFullYear())) ? 1 : 0; case "B": // Swatch Internet Time (.beats) return "@"+((context.getUTCSeconds() + (context.getUTCMinutes()*60) + ((context.getUTCHours()+1)*3600))/86.4); default: return m; } }; }; $P.toString = function (format, ignoreStandards) { // Standard Date and Time Format Strings. Formats pulled from CultureInfo file and // may vary by culture. if (!ignoreStandards && format && format.length === 1) { output = parseStandardFormats.call(this, format); if (output) { return output; } } var parseFormatStrings = parseFormatStringsClosure(this); return format ? format.replace(/((\\)?(dd?d?d?|MM?M?M?|yy?y?y?|hh?|HH?|mm?|ss?|tt?|S|q|Q|WW?W?W?)(?![^\[]*\]))/g, parseFormatStrings).replace(/\[|\]/g, "") : this._toString(); }; }()); /************************************************************* * SugarPak - Domain Specific Language - Syntactical Sugar * *************************************************************/ (function () { var $D = Date, $P = $D.prototype, $N = Number.prototype; // private $P._orient = +1; // private $P._nth = null; // private $P._is = false; // private $P._same = false; // private $P._isSecond = false; // private $N._dateElement = "days"; /** * Moves the date to the next instance of a date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.today().next().friday();
	Date.today().next().fri();
	Date.today().next().march();
	Date.today().next().mar();
	Date.today().next().week();
	
* * @return {Date} date */ $P.next = function () { this._move = true; this._orient = +1; return this; }; /** * Creates a new Date (Date.today()) and moves the date to the next instance of the date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.next().friday();
	Date.next().fri();
	Date.next().march();
	Date.next().mar();
	Date.next().week();
	
* * @return {Date} date */ $D.next = function () { return $D.today().next(); }; /** * Moves the date to the previous instance of a date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.today().last().friday();
	Date.today().last().fri();
	Date.today().last().march();
	Date.today().last().mar();
	Date.today().last().week();
	
* * @return {Date} date */ $P.last = $P.prev = $P.previous = function () { this._move = true; this._orient = -1; return this; }; /** * Creates a new Date (Date.today()) and moves the date to the previous instance of the date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.last().friday();
	Date.last().fri();
	Date.previous().march();
	Date.prev().mar();
	Date.last().week();
	
* * @return {Date} date */ $D.last = $D.prev = $D.previous = function () { return $D.today().last(); }; /** * Performs a equality check when followed by either a month name, day name or .weekday() function. * Example

	Date.today().is().friday(); // true|false
	Date.today().is().fri();
	Date.today().is().march();
	Date.today().is().mar();
	
* * @return {Boolean} true|false */ $P.is = function () { this._is = true; return this; }; /** * Determines if two date objects occur on/in exactly the same instance of the subsequent date part function. * The function .same() must be followed by a date part function (example: .day(), .month(), .year(), etc). * * An optional Date can be passed in the date part function. If now date is passed as a parameter, 'Now' is used. * * The following example demonstrates how to determine if two dates fall on the exact same day. * * Example

	var d1 = Date.today(); // today at 00:00
	var d2 = new Date();   // exactly now.

	// Do they occur on the same day?
	d1.same().day(d2); // true
	
	// Do they occur on the same hour?
	d1.same().hour(d2); // false, unless d2 hour is '00' (midnight).
	
	// What if it's the same day, but one year apart?
	var nextYear = Date.today().add(1).year();

	d1.same().day(nextYear); // false, because the dates must occur on the exact same day. 
	
* * Scenario: Determine if a given date occurs during some week period 2 months from now. * * Example

	var future = Date.today().add(2).months();
	return someDate.same().week(future); // true|false;
	
* * @return {Boolean} true|false */ $P.same = function () { this._same = true; this._isSecond = false; return this; }; /** * Determines if the current date/time occurs during Today. Must be preceded by the .is() function. * Example

	someDate.is().today();    // true|false
	new Date().is().today();  // true
	Date.today().is().today();// true
	Date.today().add(-1).day().is().today(); // false
	
* * @return {Boolean} true|false */ $P.today = function () { return this.same().day(); }; /** * Determines if the current date is a weekday. This function must be preceded by the .is() function. * Example

	Date.today().is().weekday(); // true|false
	
* * @return {Boolean} true|false */ $P.weekday = function () { if (this._nth) { return df("Weekday").call(this); } if (this._move) { return this.addWeekdays(this._orient); } if (this._is) { this._is = false; return (!this.is().sat() && !this.is().sun()); } return false; }; /** * Determines if the current date is on the weekend. This function must be preceded by the .is() function. * Example

	Date.today().is().weekend(); // true|false
	
* * @return {Boolean} true|false */ $P.weekend = function () { if (this._is) { this._is = false; return (this.is().sat() || this.is().sun()); } return false; }; /** * Sets the Time of the current Date instance. A string "6:15 pm" or config object {hour:18, minute:15} are accepted. * Example

	// Set time to 6:15pm with a String
	Date.today().at("6:15pm");

	// Set time to 6:15pm with a config object
	Date.today().at({hour:18, minute:15});
	
* * @return {Date} date */ $P.at = function (time) { return (typeof time === "string") ? $D.parse(this.toString("d") + " " + time) : this.set(time); }; /** * Creates a new Date() and adds this (Number) to the date based on the preceding date element function (eg. second|minute|hour|day|month|year). * Example

	// Undeclared Numbers must be wrapped with parentheses. Requirment of JavaScript.
	(3).days().fromNow();
	(6).months().fromNow();

	// Declared Number variables do not require parentheses. 
	var n = 6;
	n.months().fromNow();
	
* * @return {Date} A new Date instance */ $N.fromNow = $N.after = function (date) { var c = {}; c[this._dateElement] = this; return ((!date) ? new Date() : date.clone()).add(c); }; /** * Creates a new Date() and subtract this (Number) from the date based on the preceding date element function (eg. second|minute|hour|day|month|year). * Example

	// Undeclared Numbers must be wrapped with parentheses. Requirment of JavaScript.
	(3).days().ago();
	(6).months().ago();

	// Declared Number variables do not require parentheses. 
	var n = 6;
	n.months().ago();
	
* * @return {Date} A new Date instance */ $N.ago = $N.before = function (date) { var c = {}, s = (this._dateElement[this._dateElement.length-1] !== "s") ? this._dateElement + "s" : this._dateElement; c[s] = this * -1; return ((!date) ? new Date() : date.clone()).add(c); }; // Do NOT modify the following string tokens. These tokens are used to build dynamic functions. // All culture-specific strings can be found in the CultureInfo files. var dx = ("sunday monday tuesday wednesday thursday friday saturday").split(/\s/), mx = ("january february march april may june july august september october november december").split(/\s/), px = ("Millisecond Second Minute Hour Day Week Month Year Quarter Weekday").split(/\s/), pxf = ("Milliseconds Seconds Minutes Hours Date Week Month FullYear Quarter").split(/\s/), nth = ("final first second third fourth fifth").split(/\s/), de; /** * Returns an object literal of all the date parts. * Example

	var o = new Date().toObject();
	
	// { year: 2008, month: 4, week: 20, day: 13, hour: 18, minute: 9, second: 32, millisecond: 812 }
	
	// The object properties can be referenced directly from the object.
	
	alert(o.day);  // alerts "13"
	alert(o.year); // alerts "2008"
	
* * @return {Date} An object literal representing the original date object. */ $P.toObject = function () { var o = {}; for (var i = 0; i < px.length; i++) { if (this["get" + pxf[i]]) { o[px[i].toLowerCase()] = this["get" + pxf[i]](); } } return o; }; /** * Returns a date created from an object literal. Ignores the .week property if set in the config. * Example

	var o = new Date().toObject();
	
	return Date.fromObject(o); // will return the same date. 

	var o2 = {month: 1, day: 20, hour: 18}; // birthday party!
	Date.fromObject(o2);
	
* * @return {Date} An object literal representing the original date object. */ $D.fromObject = function(config) { config.week = null; return Date.today().set(config); }; // Create day name functions and abbreviated day name functions (eg. monday(), friday(), fri()). var df = function (n) { return function () { if (this._is) { this._is = false; return this.getDay() === n; } if (this._move) { this._move = null; } if (this._nth !== null) { // If the .second() function was called earlier, remove the _orient // from the date, and then continue. // This is required because 'second' can be used in two different context. // // Example // // Date.today().add(1).second(); // Date.march().second().monday(); // // Things get crazy with the following... // Date.march().add(1).second().second().monday(); // but it works!! // if (this._isSecond) { this.addSeconds(this._orient * -1); } // make sure we reset _isSecond this._isSecond = false; var ntemp = this._nth; this._nth = null; var temp = this.clone().moveToLastDayOfMonth(); this.moveToNthOccurrence(n, ntemp); if (this > temp) { throw new RangeError($D.getDayName(n) + " does not occur " + ntemp + " times in the month of " + $D.getMonthName(temp.getMonth()) + " " + temp.getFullYear() + "."); } return this; } return this.moveToDayOfWeek(n, this._orient); }; }; var sdf = function (n) { return function () { var t = $D.today(), shift = n - t.getDay(); if (n === 0 && Date.CultureInfo.firstDayOfWeek === 1 && t.getDay() !== 0) { shift = shift + 7; } return t.addDays(shift); }; }; // Create month name functions and abbreviated month name functions (eg. january(), march(), mar()). var month_instance_functions = function (n) { return function () { if (this._is) { this._is = false; return this.getMonth() === n; } return this.moveToMonth(n, this._orient); }; }; var month_static_functions = function (n) { return function () { return $D.today().set({ month: n, day: 1 }); }; }; var processTerms = function (names, staticFunc, instanceFunc) { for (var i = 0; i < names.length; i++) { // Create constant static Name variables. $D[names[i].toUpperCase()] = $D[names[i].toUpperCase().substring(0, 3)] = i; // Create Name functions. $D[names[i]] = $D[names[i].substring(0, 3)] = staticFunc(i); // Create Name instance functions. $P[names[i]] = $P[names[i].substring(0, 3)] = instanceFunc(i); } }; processTerms(dx, sdf, df); processTerms(mx, month_static_functions, month_instance_functions); // Create date element functions and plural date element functions used with Date (eg. day(), days(), months()). var ef = function (j) { return function () { // if the .second() function was called earlier, the _orient // has alread been added. Just return this and reset _isSecond. if (this._isSecond) { this._isSecond = false; return this; } if (this._same) { this._same = this._is = false; var o1 = this.toObject(), o2 = (arguments[0] || new Date()).toObject(), v = "", k = j.toLowerCase(); // the substr trick with -1 doesn't work in IE8 or less k = (k[k.length-1] === "s") ? k.substring(0,k.length-1) : k; for (var m = (px.length - 1); m > -1; m--) { v = px[m].toLowerCase(); if (o1[v] !== o2[v]) { return false; } if (k === v) { break; } } return true; } if (j.substring(j.length - 1) !== "s") { j += "s"; } if (this._move) { this._move = null; } return this["add" + j](this._orient); }; }; var nf = function (n) { return function () { this._dateElement = n; return this; }; }; for (var k = 0; k < px.length; k++) { de = px[k].toLowerCase(); if(de !== "weekday") { // Create date element functions and plural date element functions used with Date (eg. day(), days(), months()). $P[de] = $P[de + "s"] = ef(px[k]); // Create date element functions and plural date element functions used with Number (eg. day(), days(), months()). $N[de] = $N[de + "s"] = nf(de + "s"); } } $P._ss = ef("Second"); var nthfn = function (n) { return function (dayOfWeek) { if (this._same) { return this._ss(arguments[0]); } if (dayOfWeek || dayOfWeek === 0) { return this.moveToNthOccurrence(dayOfWeek, n); } this._nth = n; // if the operator is 'second' add the _orient, then deal with it later... if (n === 2 && (dayOfWeek === undefined || dayOfWeek === null)) { this._isSecond = true; return this.addSeconds(this._orient); } return this; }; }; for (var l = 0; l < nth.length; l++) { $P[nth[l]] = (l === 0) ? nthfn(-1) : nthfn(l); } }()); (function () { "use strict"; Date.Parsing = { Exception: function (s) { this.message = "Parse error at '" + s.substring(0, 10) + " ...'"; } }; var $P = Date.Parsing; var dayOffsets = { standard: [0,31,59,90,120,151,181,212,243,273,304,334], leap: [0,31,60,91,121,152,182,213,244,274,305,335] }; $P.isLeapYear = function(year) { return ((year % 4 === 0) && (year % 100 !== 0)) || (year % 400 === 0); }; var utils = { multiReplace : function (str, hash ) { var key; for (key in hash) { if (Object.prototype.hasOwnProperty.call(hash, key)) { var regex; if (typeof hash[key] === "function") { } else { regex = (hash[key] instanceof RegExp) ? hash[key] : new RegExp(hash[key], "g"); } str = str.replace(regex, key); } } return str; }, getDayOfYearFromWeek : function (obj) { var d, jan4, offset; obj.weekDay = (!obj.weekDay && obj.weekDay !== 0) ? 1 : obj.weekDay; d = new Date(obj.year, 0, 4); jan4 = d.getDay() === 0 ? 7 : d.getDay(); // JS is 0 indexed on Sunday. offset = jan4+3; obj.dayOfYear = ((obj.week * 7) + (obj.weekDay === 0 ? 7 : obj.weekDay))-offset; return obj; }, getDayOfYear : function (obj, dayOffset) { if (!obj.dayOfYear) { obj = utils.getDayOfYearFromWeek(obj); } for (var i=0;i <= dayOffset.length;i++) { if (obj.dayOfYear < dayOffset[i] || i === dayOffset.length) { obj.day = obj.day ? obj.day : (obj.dayOfYear - dayOffset[i-1]); break; } else { obj.month = i; } } return obj; }, adjustForTimeZone : function (obj, date) { var offset; if (obj.zone.toUpperCase() === "Z" || (obj.zone_hours === 0 && obj.zone_minutes === 0)) { // it's UTC/GML so work out the current timeszone offset offset = -date.getTimezoneOffset(); } else { offset = (obj.zone_hours*60) + (obj.zone_minutes || 0); if (obj.zone_sign === "+") { offset *= -1; } offset -= date.getTimezoneOffset(); } date.setMinutes(date.getMinutes()+offset); return date; }, setDefaults : function (obj) { obj.year = obj.year || Date.today().getFullYear(); obj.hours = obj.hours || 0; obj.minutes = obj.minutes || 0; obj.seconds = obj.seconds || 0; obj.milliseconds = obj.milliseconds || 0; if (!(!obj.month && (obj.week || obj.dayOfYear))) { // if we have a month, or if we don't but don't have the day calculation data obj.month = obj.month || 0; obj.day = obj.day || 1; } return obj; }, dataNum: function (data, mod, explict, postProcess) { var dataNum = data*1; if (mod) { if (postProcess) { return data ? mod(data)*1 : data; } else { return data ? mod(dataNum) : data; } } else if (!explict){ return data ? dataNum : data; } else { return (data && typeof data !== "undefined") ? dataNum : data; } }, timeDataProcess: function (obj) { var timeObj = {}; for (var x in obj.data) { if (obj.data.hasOwnProperty(x)) { timeObj[x] = obj.ignore[x] ? obj.data[x] : utils.dataNum(obj.data[x], obj.mods[x], obj.explict[x], obj.postProcess[x]); } } if (obj.data.secmins) { obj.data.secmins = obj.data.secmins.replace(",", ".") * 60; if (!timeObj.minutes) { timeObj.minutes = obj.data.secmins; } else if (!timeObj.seconds) { timeObj.seconds = obj.data.secmins; } delete obj.secmins; } return timeObj; }, buildTimeObjectFromData: function (data) { var time = utils.timeDataProcess({ data: { year : data[1], month : data[5], day : data[7], week : data[8], dayOfYear : data[10], hours : data[15], zone_hours : data[23], zone_minutes : data[24], zone : data[21], zone_sign : data[22], weekDay : data[9], minutes: data[16], seconds: data[19], milliseconds: data[20], secmins: data[18] }, mods: { month: function(data) { return data-1; }, weekDay: function (data) { data = Math.abs(data); return (data === 7 ? 0 : data); }, minutes: function (data) { return data.replace(":",""); }, seconds: function (data) { return Math.floor( (data.replace(":","").replace(",","."))*1 ); }, milliseconds: function (data) { return (data.replace(",",".")*1000); } }, postProcess: { minutes: true, seconds: true, milliseconds: true }, explict: { zone_hours: true, zone_minutes: true }, ignore: { zone: true, zone_sign: true, secmins: true } }); return time; }, addToHash: function (hash, keys, data) { keys = keys; data = data; var len = keys.length; for (var i = 0; i < len; i++) { hash[keys[i]] = data[i]; } return hash; }, combineRegex: function (r1, r2) { return new RegExp("(("+r1.source+")\\s("+r2.source+"))"); }, getDateNthString: function(add, last, inc){ if (add) { return Date.today().addDays(inc).toString("d"); } else if (last) { return Date.today().last()[inc]().toString("d"); } }, buildRegexData: function (array) { var arr = []; var len = array.length; for (var i=0; i < len; i++) { if (Object.prototype.toString.call(array[i]) === '[object Array]') { // oldIE compat version of Array.isArray arr.push(this.combineRegex(array[i][0], array[i][1])); } else { arr.push(array[i]); } } return arr; } }; $P.processTimeObject = function (obj) { var date, dayOffset; utils.setDefaults(obj); dayOffset = ($P.isLeapYear(obj.year)) ? dayOffsets.leap : dayOffsets.standard; if (!obj.month && (obj.week || obj.dayOfYear)) { utils.getDayOfYear(obj, dayOffset); } else { obj.dayOfYear = dayOffset[obj.month] + obj.day; } date = new Date(obj.year, obj.month, obj.day, obj.hours, obj.minutes, obj.seconds, obj.milliseconds); if (obj.zone) { utils.adjustForTimeZone(obj, date); // adjust (and calculate) for timezone } return date; }; $P.ISO = { regex : /^([\+-]?\d{4}(?!\d{2}\b))((-?)((0[1-9]|1[0-2])(\3([12]\d|0[1-9]|3[01]))?|W([0-4]\d|5[0-3])(-?[1-7])?|(00[1-9]|0[1-9]\d|[12]\d{2}|3([0-5]\d|6[1-6])))([T\s]((([01]\d|2[0-4])((:?)[0-5]\d)?|24\:?00)([\.,]\d+(?!:))?)?(\17[0-5]\d([\.,]\d+)?)?\s?([zZ]|([\+-])([01]\d|2[0-3]):?([0-5]\d)?)?)?)?$/, parse : function (s) { var time, data = s.match(this.regex); if (!data || !data.length) { return null; } time = utils.buildTimeObjectFromData(data); if (!time.year || (!time.year && (!time.month && !time.day) && (!time.week && !time.dayOfYear)) ) { return null; } return $P.processTimeObject(time); } }; $P.Numeric = { isNumeric: function (e){return!isNaN(parseFloat(e))&&isFinite(e);}, regex: /\b([0-1]?[0-9])([0-3]?[0-9])([0-2]?[0-9]?[0-9][0-9])\b/i, parse: function (s) { var data, i, time = {}, order = Date.CultureInfo.dateElementOrder.split(""); if (!(this.isNumeric(s)) || // if it's non-numeric OR (s[0] === "+" && s[0] === "-")) { // It's an arithmatic string (eg +/-1000) return null; } if (s.length < 5 && s.indexOf(".") < 0 && s.indexOf("/") < 0) { // assume it's just a year. time.year = s; return $P.processTimeObject(time); } data = s.match(this.regex); if (!data || !data.length) { return null; } for (i=0; i < order.length; i++) { switch(order[i]) { case "d": time.day = data[i+1]; break; case "m": time.month = (data[i+1]-1); break; case "y": time.year = data[i+1]; break; } } return $P.processTimeObject(time); } }; $P.Normalizer = { regexData: function () { var $R = Date.CultureInfo.regexPatterns; return utils.buildRegexData([ $R.tomorrow, $R.yesterday, [$R.past, $R.mon], [$R.past, $R.tue], [$R.past, $R.wed], [$R.past, $R.thu], [$R.past, $R.fri], [$R.past, $R.sat], [$R.past, $R.sun] ]); }, basicReplaceHash : function() { var $R = Date.CultureInfo.regexPatterns; return { "January": $R.jan.source, "February": $R.feb, "March": $R.mar, "April": $R.apr, "May": $R.may, "June": $R.jun, "July": $R.jul, "August": $R.aug, "September": $R.sep, "October": $R.oct, "November": $R.nov, "December": $R.dec, "": /\bat\b/gi, " ": /\s{2,}/, "am": $R.inTheMorning, "9am": $R.thisMorning, "pm": $R.inTheEvening, "7pm":$R.thisEvening }; }, keys : function(){ return [ utils.getDateNthString(true, false, 1), // tomorrow utils.getDateNthString(true, false, -1), // yesterday utils.getDateNthString(false, true, "monday"), //last mon utils.getDateNthString(false, true, "tuesday"), //last tues utils.getDateNthString(false, true, "wednesday"), //last wed utils.getDateNthString(false, true, "thursday"), //last thurs utils.getDateNthString(false, true, "friday"), //last fri utils.getDateNthString(false, true, "saturday"), //last sat utils.getDateNthString(false, true, "sunday") //last sun ]; }, buildRegexFunctions: function () { var $R = Date.CultureInfo.regexPatterns; var __ = Date.i18n.__; var tomorrowRE = new RegExp("(\\b\\d\\d?("+__("AM")+"|"+__("PM")+")? )("+$R.tomorrow.source.slice(1)+")", "i"); // adapted tomorrow regex for AM PM relative dates var todayRE = new RegExp($R.today.source + "(?!\\s*([+-]))\\b"); // today, but excludes the math operators (eg "today + 2h") this.replaceFuncs = [ [todayRE, function (full) { return (full.length > 1) ? Date.today().toString("d") : full; }], [tomorrowRE, function(full, m1) { var t = Date.today().addDays(1).toString("d"); return (t + " " + m1); }], [$R.amThisMorning, function(str, am){return am;}], [$R.pmThisEvening, function(str, pm){return pm;}] ]; }, buildReplaceData: function () { this.buildRegexFunctions(); this.replaceHash = utils.addToHash(this.basicReplaceHash(), this.keys(), this.regexData()); }, stringReplaceFuncs: function (s) { for (var i=0; i < this.replaceFuncs.length; i++) { s = s.replace(this.replaceFuncs[i][0], this.replaceFuncs[i][1]); } return s; }, parse: function (s) { s = this.stringReplaceFuncs(s); s = utils.multiReplace(s, this.replaceHash); try { var n = s.split(/([\s\-\.\,\/\x27]+)/); if (n.length === 3 && $P.Numeric.isNumeric(n[0]) && $P.Numeric.isNumeric(n[2]) && (n[2].length >= 4)) { // ok, so we're dealing with x/year. But that's not a full date. // This fixes wonky dateElementOrder parsing when set to dmy order. if (Date.CultureInfo.dateElementOrder[0] === "d") { s = "1/" + n[0] + "/" + n[2]; // set to 1st of month and normalize the seperator } } } catch (e) {} return s; } }; $P.Normalizer.buildReplaceData(); }()); (function () { var $P = Date.Parsing; var _ = $P.Operators = { // // Tokenizers // rtoken: function (r) { // regex token return function (s) { var mx = s.match(r); if (mx) { return ([ mx[0], s.substring(mx[0].length) ]); } else { throw new $P.Exception(s); } }; }, token: function () { // whitespace-eating token return function (s) { return _.rtoken(new RegExp("^\\s*" + s + "\\s*"))(s); }; }, stoken: function (s) { // string token return _.rtoken(new RegExp("^" + s)); }, // Atomic Operators until: function (p) { return function (s) { var qx = [], rx = null; while (s.length) { try { rx = p.call(this, s); } catch (e) { qx.push(rx[0]); s = rx[1]; continue; } break; } return [ qx, s ]; }; }, many: function (p) { return function (s) { var rx = [], r = null; while (s.length) { try { r = p.call(this, s); } catch (e) { return [ rx, s ]; } rx.push(r[0]); s = r[1]; } return [ rx, s ]; }; }, // generator operators -- see below optional: function (p) { return function (s) { var r = null; try { r = p.call(this, s); } catch (e) { return [ null, s ]; } return [ r[0], r[1] ]; }; }, not: function (p) { return function (s) { try { p.call(this, s); } catch (e) { return [null, s]; } throw new $P.Exception(s); }; }, ignore: function (p) { return p ? function (s) { var r = null; r = p.call(this, s); return [null, r[1]]; } : null; }, product: function () { var px = arguments[0], qx = Array.prototype.slice.call(arguments, 1), rx = []; for (var i = 0 ; i < px.length ; i++) { rx.push(_.each(px[i], qx)); } return rx; }, cache: function (rule) { var cache = {}, cache_length = 0, cache_keys = [], CACHE_MAX = Date.Config.CACHE_MAX || 100000, r = null; var cacheCheck = function () { if (cache_length === CACHE_MAX) { // kill several keys, don't want to have to do this all the time... for (var i=0; i < 10; i++) { var key = cache_keys.shift(); if (key) { delete cache[key]; cache_length--; } } } }; return function (s) { cacheCheck(); try { r = cache[s] = (cache[s] || rule.call(this, s)); } catch (e) { r = cache[s] = e; } cache_length++; cache_keys.push(s); if (r instanceof $P.Exception) { throw r; } else { return r; } }; }, // vector operators -- see below any: function () { var px = arguments; return function (s) { var r = null; for (var i = 0; i < px.length; i++) { if (px[i] == null) { continue; } try { r = (px[i].call(this, s)); } catch (e) { r = null; } if (r) { return r; } } throw new $P.Exception(s); }; }, each: function () { var px = arguments; return function (s) { var rx = [], r = null; for (var i = 0; i < px.length ; i++) { if (px[i] == null) { continue; } try { r = (px[i].call(this, s)); } catch (e) { throw new $P.Exception(s); } rx.push(r[0]); s = r[1]; } return [ rx, s]; }; }, all: function () { var px = arguments, _ = _; return _.each(_.optional(px)); }, // delimited operators sequence: function (px, d, c) { d = d || _.rtoken(/^\s*/); c = c || null; if (px.length === 1) { return px[0]; } return function (s) { var r = null, q = null; var rx = []; for (var i = 0; i < px.length ; i++) { try { r = px[i].call(this, s); } catch (e) { break; } rx.push(r[0]); try { q = d.call(this, r[1]); } catch (ex) { q = null; break; } s = q[1]; } if (!r) { throw new $P.Exception(s); } if (q) { throw new $P.Exception(q[1]); } if (c) { try { r = c.call(this, r[1]); } catch (ey) { throw new $P.Exception(r[1]); } } return [ rx, (r?r[1]:s) ]; }; }, // // Composite Operators // between: function (d1, p, d2) { d2 = d2 || d1; var _fn = _.each(_.ignore(d1), p, _.ignore(d2)); return function (s) { var rx = _fn.call(this, s); return [[rx[0][0], r[0][2]], rx[1]]; }; }, list: function (p, d, c) { d = d || _.rtoken(/^\s*/); c = c || null; return (p instanceof Array ? _.each(_.product(p.slice(0, -1), _.ignore(d)), p.slice(-1), _.ignore(c)) : _.each(_.many(_.each(p, _.ignore(d))), px, _.ignore(c))); }, set: function (px, d, c) { d = d || _.rtoken(/^\s*/); c = c || null; return function (s) { // r is the current match, best the current 'best' match // which means it parsed the most amount of input var r = null, p = null, q = null, rx = null, best = [[], s], last = false; // go through the rules in the given set for (var i = 0; i < px.length ; i++) { // last is a flag indicating whether this must be the last element // if there is only 1 element, then it MUST be the last one q = null; p = null; r = null; last = (px.length === 1); // first, we try simply to match the current pattern // if not, try the next pattern try { r = px[i].call(this, s); } catch (e) { continue; } // since we are matching against a set of elements, the first // thing to do is to add r[0] to matched elements rx = [[r[0]], r[1]]; // if we matched and there is still input to parse and // we don't already know this is the last element, // we're going to next check for the delimiter ... // if there's none, or if there's no input left to parse // than this must be the last element after all ... if (r[1].length > 0 && ! last) { try { q = d.call(this, r[1]); } catch (ex) { last = true; } } else { last = true; } // if we parsed the delimiter and now there's no more input, // that means we shouldn't have parsed the delimiter at all // so don't update r and mark this as the last element ... if (!last && q[1].length === 0) { last = true; } // so, if this isn't the last element, we're going to see if // we can get any more matches from the remaining (unmatched) // elements ... if (!last) { // build a list of the remaining rules we can match against, // i.e., all but the one we just matched against var qx = []; for (var j = 0; j < px.length ; j++) { if (i !== j) { qx.push(px[j]); } } // now invoke recursively set with the remaining input // note that we don't include the closing delimiter ... // we'll check for that ourselves at the end p = _.set(qx, d).call(this, q[1]); // if we got a non-empty set as a result ... // (otw rx already contains everything we want to match) if (p[0].length > 0) { // update current result, which is stored in rx ... // basically, pick up the remaining text from p[1] // and concat the result from p[0] so that we don't // get endless nesting ... rx[0] = rx[0].concat(p[0]); rx[1] = p[1]; } } // at this point, rx either contains the last matched element // or the entire matched set that starts with this element. // now we just check to see if this variation is better than // our best so far, in terms of how much of the input is parsed if (rx[1].length < best[1].length) { best = rx; } // if we've parsed all the input, then we're finished if (best[1].length === 0) { break; } } // so now we've either gone through all the patterns trying them // as the initial match; or we found one that parsed the entire // input string ... // if best has no matches, just return empty set ... if (best[0].length === 0) { return best; } // if a closing delimiter is provided, then we have to check it also if (c) { // we try this even if there is no remaining input because the pattern // may well be optional or match empty input ... try { q = c.call(this, best[1]); } catch (ey) { throw new $P.Exception(best[1]); } // it parsed ... be sure to update the best match remaining input best[1] = q[1]; } // if we're here, either there was no closing delimiter or we parsed it // so now we have the best match; just return it! return best; }; }, forward: function (gr, fname) { return function (s) { return gr[fname].call(this, s); }; }, // // Translation Operators // replace: function (rule, repl) { return function (s) { var r = rule.call(this, s); return [repl, r[1]]; }; }, process: function (rule, fn) { return function (s) { var r = rule.call(this, s); return [fn.call(this, r[0]), r[1]]; }; }, min: function (min, rule) { return function (s) { var rx = rule.call(this, s); if (rx[0].length < min) { throw new $P.Exception(s); } return rx; }; } }; // Generator Operators And Vector Operators // Generators are operators that have a signature of F(R) => R, // taking a given rule and returning another rule, such as // ignore, which parses a given rule and throws away the result. // Vector operators are those that have a signature of F(R1,R2,...) => R, // take a list of rules and returning a new rule, such as each. // Generator operators are converted (via the following _generator // function) into functions that can also take a list or array of rules // and return an array of new rules as though the function had been // called on each rule in turn (which is what actually happens). // This allows generators to be used with vector operators more easily. // Example: // each(ignore(foo, bar)) instead of each(ignore(foo), ignore(bar)) // This also turns generators into vector operators, which allows // constructs like: // not(cache(foo, bar)) var _generator = function (op) { function gen() { var args = null, rx = [], px, i; if (arguments.length > 1) { args = Array.prototype.slice.call(arguments); } else if (arguments[0] instanceof Array) { args = arguments[0]; } if (args) { px = args.shift(); if (px.length > 0) { args.unshift(px[i]); rx.push(op.apply(null, args)); args.shift(); return rx; } } else { return op.apply(null, arguments); } } return gen; }; var gx = "optional not ignore cache".split(/\s/); for (var i = 0 ; i < gx.length ; i++) { _[gx[i]] = _generator(_[gx[i]]); } var _vector = function (op) { return function () { if (arguments[0] instanceof Array) { return op.apply(null, arguments[0]); } else { return op.apply(null, arguments); } }; }; var vx = "each any all".split(/\s/); for (var j = 0 ; j < vx.length ; j++) { _[vx[j]] = _vector(_[vx[j]]); } }()); (function () { var $D = Date; var flattenAndCompact = function (ax) { var rx = []; for (var i = 0; i < ax.length; i++) { if (ax[i] instanceof Array) { rx = rx.concat(flattenAndCompact(ax[i])); } else { if (ax[i]) { rx.push(ax[i]); } } } return rx; }; var parseMeridian = function () { if (this.meridian && (this.hour || this.hour === 0)) { if (this.meridian === "a" && this.hour > 11 && Date.Config.strict24hr){ throw "Invalid hour and meridian combination"; } else if (this.meridian === "p" && this.hour < 12 && Date.Config.strict24hr){ throw "Invalid hour and meridian combination"; } else if (this.meridian === "p" && this.hour < 12) { this.hour = this.hour + 12; } else if (this.meridian === "a" && this.hour === 12) { this.hour = 0; } } }; var setDefaults = function () { var now = new Date(); if ((this.hour || this.minute) && (!this.month && !this.year && !this.day)) { this.day = now.getDate(); } if (!this.year) { this.year = now.getFullYear(); } if (!this.month && this.month !== 0) { this.month = now.getMonth(); } if (!this.day) { this.day = 1; } if (!this.hour) { this.hour = 0; } if (!this.minute) { this.minute = 0; } if (!this.second) { this.second = 0; } if (!this.millisecond) { this.millisecond = 0; } }; var finishUtils = { getToday: function () { if (this.now || "hour minute second".indexOf(this.unit) !== -1) { return new Date(); } else { return $D.today(); } }, setDaysFromWeekday: function (today, orient){ var gap; orient = orient || 1; this.unit = "day"; gap = ($D.getDayNumberFromName(this.weekday) - today.getDay()); this.days = gap ? ((gap + (orient * 7)) % 7) : (orient * 7); return this; }, setMonthsFromMonth: function (today, orient) { var gap; orient = orient || 1; this.unit = "month"; gap = (this.month - today.getMonth()); this.months = gap ? ((gap + (orient * 12)) % 12) : (orient * 12); this.month = null; return this; }, setDMYFromWeekday: function () { var d = Date[this.weekday](); this.day = d.getDate(); if (!this.month) { this.month = d.getMonth(); } this.year = d.getFullYear(); return this; }, setUnitValue: function (orient) { if (!this.value && this.operator && this.operator !== null && this[this.unit + "s"] && this[this.unit + "s"] !== null) { this[this.unit + "s"] = this[this.unit + "s"] + ((this.operator === "add") ? 1 : -1) + (this.value||0) * orient; } else if (this[this.unit + "s"] == null || this.operator != null) { if (!this.value) { this.value = 1; } this[this.unit + "s"] = this.value * orient; } }, generateDateFromWeeks: function () { var weekday = (this.weekday !== undefined) ? this.weekday : "today"; var d = Date[weekday]().addWeeks(this.weeks); if (this.now) { d.setTimeToNow(); } return d; } }; $D.Translator = { hour: function (s) { return function () { this.hour = Number(s); }; }, minute: function (s) { return function () { this.minute = Number(s); }; }, second: function (s) { return function () { this.second = Number(s); }; }, /* for ss.s format */ secondAndMillisecond: function (s) { return function () { var mx = s.match(/^([0-5][0-9])\.([0-9]{1,3})/); this.second = Number(mx[1]); this.millisecond = Number(mx[2]); }; }, meridian: function (s) { return function () { this.meridian = s.slice(0, 1).toLowerCase(); }; }, timezone: function (s) { return function () { var n = s.replace(/[^\d\+\-]/g, ""); if (n.length) { this.timezoneOffset = Number(n); } else { this.timezone = s.toLowerCase(); } }; }, day: function (x) { var s = x[0]; return function () { this.day = Number(s.match(/\d+/)[0]); if (this.day < 1) { throw "invalid day"; } }; }, month: function (s) { return function () { this.month = (s.length === 3) ? "jan feb mar apr may jun jul aug sep oct nov dec".indexOf(s)/4 : Number(s) - 1; if (this.month < 0) { throw "invalid month"; } }; }, year: function (s) { return function () { var n = Number(s); this.year = ((s.length > 2) ? n : (n + (((n + 2000) < Date.CultureInfo.twoDigitYearMax) ? 2000 : 1900))); }; }, rday: function (s) { return function () { switch (s) { case "yesterday": this.days = -1; break; case "tomorrow": this.days = 1; break; case "today": this.days = 0; break; case "now": this.days = 0; this.now = true; break; } }; }, finishExact: function (x) { var d; x = (x instanceof Array) ? x : [x]; for (var i = 0 ; i < x.length ; i++) { if (x[i]) { x[i].call(this); } } setDefaults.call(this); parseMeridian.call(this); if (this.day > $D.getDaysInMonth(this.year, this.month)) { throw new RangeError(this.day + " is not a valid value for days."); } d = new Date(this.year, this.month, this.day, this.hour, this.minute, this.second, this.millisecond); if (this.year < 100) { d.setFullYear(this.year); // means years less that 100 are process correctly. JS will parse it otherwise as 1900-1999. } if (this.timezone) { d.set({ timezone: this.timezone }); } else if (this.timezoneOffset) { d.set({ timezoneOffset: this.timezoneOffset }); } return d; }, finish: function (x) { var today, expression, orient, temp; x = (x instanceof Array) ? flattenAndCompact(x) : [ x ]; if (x.length === 0) { return null; } for (var i = 0 ; i < x.length ; i++) { if (typeof x[i] === "function") { x[i].call(this); } } if (this.now && !this.unit && !this.operator) { return new Date(); } else { today = finishUtils.getToday.call(this); } expression = !!(this.days && this.days !== null || this.orient || this.operator); orient = ((this.orient === "past" || this.operator === "subtract") ? -1 : 1); if (this.month && this.unit === "week") { this.value = this.month + 1; delete this.month; delete this.day; } if ((this.month || this.month === 0) && "year day hour minute second".indexOf(this.unit) !== -1) { if (!this.value) { this.value = this.month + 1; } this.month = null; expression = true; } if (!expression && this.weekday && !this.day && !this.days) { finishUtils.setDMYFromWeekday.call(this); } if (expression && this.weekday && this.unit !== "month" && this.unit !== "week") { finishUtils.setDaysFromWeekday.call(this, today, orient); } if (this.weekday && this.unit !== "week" && !this.day && !this.days) { temp = Date[this.weekday](); this.day = temp.getDate(); if (temp.getMonth() !== today.getMonth()) { this.month = temp.getMonth(); } } if (this.month && this.unit === "day" && this.operator) { if (!this.value) { this.value = (this.month + 1); } this.month = null; } if (this.value != null && this.month != null && this.year != null) { this.day = this.value * 1; } if (this.month && !this.day && this.value) { today.set({ day: this.value * 1 }); if (!expression) { this.day = this.value * 1; } } if (!this.month && this.value && this.unit === "month" && !this.now) { this.month = this.value; expression = true; } if (expression && (this.month || this.month === 0) && this.unit !== "year") { finishUtils.setMonthsFromMonth.call(this, today, orient); } if (!this.unit) { this.unit = "day"; } finishUtils.setUnitValue.call(this, orient); parseMeridian.call(this); if ((this.month || this.month === 0) && !this.day) { this.day = 1; } if (!this.orient && !this.operator && this.unit === "week" && this.value && !this.day && !this.month) { return Date.today().setWeek(this.value); } if (this.unit === "week" && this.weeks && !this.day && !this.month) { return finishUtils.generateDateFromWeeks.call(this); } if (expression && this.timezone && this.day && this.days) { this.day = this.days; } if (expression){ today.add(this); } else { today.set(this); } if (this.timezone) { this.timezone = this.timezone.toUpperCase(); var offset = $D.getTimezoneOffset(this.timezone); var timezone; if (today.hasDaylightSavingTime()) { // lets check that we're being sane with timezone setting timezone = $D.getTimezoneAbbreviation(offset, today.isDaylightSavingTime()); if (timezone !== this.timezone) { // bugger, we're in a place where things like EST vs EDT matters. if (today.isDaylightSavingTime()) { today.addHours(-1); } else { today.addHours(1); } } } today.setTimezoneOffset(offset); } return today; } }; }()); (function () { var $D = Date; $D.Grammar = {}; var _ = $D.Parsing.Operators, g = $D.Grammar, t = $D.Translator, _fn; // Allow rolling up into general purpose rules _fn = function () { return _.each(_.any.apply(null, arguments), _.not(g.ctoken2("timeContext"))); }; g.datePartDelimiter = _.rtoken(/^([\s\-\.\,\/\x27]+)/); g.timePartDelimiter = _.stoken(":"); g.whiteSpace = _.rtoken(/^\s*/); g.generalDelimiter = _.rtoken(/^(([\s\,]|at|@|on)+)/); var _C = {}; g.ctoken = function (keys) { var fn = _C[keys]; if (! fn) { var c = Date.CultureInfo.regexPatterns; var kx = keys.split(/\s+/), px = []; for (var i = 0; i < kx.length ; i++) { px.push(_.replace(_.rtoken(c[kx[i]]), kx[i])); } fn = _C[keys] = _.any.apply(null, px); } return fn; }; g.ctoken2 = function (key) { return _.rtoken(Date.CultureInfo.regexPatterns[key]); }; var cacheProcessRtoken = function (key, token, type, eachToken) { if (eachToken) { g[key] = _.cache(_.process(_.each(_.rtoken(token),_.optional(g.ctoken2(eachToken))), type)); } else { g[key] = _.cache(_.process(_.rtoken(token), type)); } }; var cacheProcessCtoken = function (token, type) { return _.cache(_.process(g.ctoken2(token), type)); }; var _F = {}; //function cache var _get = function (f) { _F[f] = (_F[f] || g.format(f)[0]); return _F[f]; }; g.allformats = function (fx) { var rx = []; if (fx instanceof Array) { for (var i = 0; i < fx.length; i++) { rx.push(_get(fx[i])); } } else { rx.push(_get(fx)); } return rx; }; g.formats = function (fx) { if (fx instanceof Array) { var rx = []; for (var i = 0 ; i < fx.length ; i++) { rx.push(_get(fx[i])); } return _.any.apply(null, rx); } else { return _get(fx); } }; var grammarFormats = { timeFormats: function(){ var i, RTokenKeys = [ "h", "hh", "H", "HH", "m", "mm", "s", "ss", "ss.s", "z", "zz" ], RToken = [ /^(0[0-9]|1[0-2]|[1-9])/, /^(0[0-9]|1[0-2])/, /^([0-1][0-9]|2[0-3]|[0-9])/, /^([0-1][0-9]|2[0-3])/, /^([0-5][0-9]|[0-9])/, /^[0-5][0-9]/, /^([0-5][0-9]|[0-9])/, /^[0-5][0-9]/, /^[0-5][0-9]\.[0-9]{1,3}/, /^((\+|\-)\s*\d\d\d\d)|((\+|\-)\d\d\:?\d\d)/, /^((\+|\-)\s*\d\d\d\d)|((\+|\-)\d\d\:?\d\d)/ ], tokens = [ t.hour, t.hour, t.hour, t.hour, t.minute, t.minute, t.second, t.second, t.secondAndMillisecond, t.timezone, t.timezone ]; for (i=0; i < RTokenKeys.length; i++) { cacheProcessRtoken(RTokenKeys[i], RToken[i], tokens[i]); } g.hms = _.cache(_.sequence([g.H, g.m, g.s], g.timePartDelimiter)); g.t = cacheProcessCtoken("shortMeridian", t.meridian); g.tt = cacheProcessCtoken("longMeridian", t.meridian); g.zzz = cacheProcessCtoken("timezone", t.timezone); g.timeSuffix = _.each(_.ignore(g.whiteSpace), _.set([ g.tt, g.zzz ])); g.time = _.each(_.optional(_.ignore(_.stoken("T"))), g.hms, g.timeSuffix); }, dateFormats: function () { // pre-loaded rules for different date part order preferences var _setfn = function () { return _.set(arguments, g.datePartDelimiter); }; var i, RTokenKeys = [ "d", "dd", "M", "MM", "y", "yy", "yyy", "yyyy" ], RToken = [ /^([0-2]\d|3[0-1]|\d)/, /^([0-2]\d|3[0-1])/, /^(1[0-2]|0\d|\d)/, /^(1[0-2]|0\d)/, /^(\d+)/, /^(\d\d)/, /^(\d\d?\d?\d?)/, /^(\d\d\d\d)/ ], tokens = [ t.day, t.day, t.month, t.month, t.year, t.year, t.year, t.year ], eachToken = [ "ordinalSuffix", "ordinalSuffix" ]; for (i=0; i < RTokenKeys.length; i++) { cacheProcessRtoken(RTokenKeys[i], RToken[i], tokens[i], eachToken[i]); } g.MMM = g.MMMM = _.cache(_.process(g.ctoken("jan feb mar apr may jun jul aug sep oct nov dec"), t.month)); g.ddd = g.dddd = _.cache(_.process(g.ctoken("sun mon tue wed thu fri sat"), function (s) { return function () { this.weekday = s; }; } )); g.day = _fn(g.d, g.dd); g.month = _fn(g.M, g.MMM); g.year = _fn(g.yyyy, g.yy); g.mdy = _setfn(g.ddd, g.month, g.day, g.year); g.ymd = _setfn(g.ddd, g.year, g.month, g.day); g.dmy = _setfn(g.ddd, g.day, g.month, g.year); g.date = function (s) { return ((g[Date.CultureInfo.dateElementOrder] || g.mdy).call(this, s)); }; }, relative: function () { // relative date / time expressions g.orientation = _.process(g.ctoken("past future"), function (s) { return function () { this.orient = s; }; } ); g.operator = _.process(g.ctoken("add subtract"), function (s) { return function () { this.operator = s; }; } ); g.rday = _.process(g.ctoken("yesterday tomorrow today now"), t.rday); g.unit = _.process(g.ctoken("second minute hour day week month year"), function (s) { return function () { this.unit = s; }; } ); } }; g.buildGrammarFormats = function () { // these need to be rebuilt every time the language changes. _C = {}; grammarFormats.timeFormats(); grammarFormats.dateFormats(); grammarFormats.relative(); g.value = _.process(_.rtoken(/^([-+]?\d+)?(st|nd|rd|th)?/), function (s) { return function () { this.value = s.replace(/\D/g, ""); }; } ); g.expression = _.set([g.rday, g.operator, g.value, g.unit, g.orientation, g.ddd, g.MMM ]); g.format = _.process(_.many( _.any( // translate format specifiers into grammar rules _.process( _.rtoken(/^(dd?d?d?(?!e)|MM?M?M?|yy?y?y?|hh?|HH?|mm?|ss?|tt?|zz?z?)/), function (fmt) { if (g[fmt]) { return g[fmt]; } else { throw $D.Parsing.Exception(fmt); } } ), // translate separator tokens into token rules _.process(_.rtoken(/^[^dMyhHmstz]+/), // all legal separators function (s) { return _.ignore(_.stoken(s)); } ) ) ), // construct the parser ... function (rules) { return _.process(_.each.apply(null, rules), t.finishExact); } ); // starting rule for general purpose grammar g._start = _.process(_.set([ g.date, g.time, g.expression ], g.generalDelimiter, g.whiteSpace), t.finish); }; g.buildGrammarFormats(); // parsing date format specifiers - ex: "h:m:s tt" // this little guy will generate a custom parser based // on the format string, ex: g.format("h:m:s tt") // check for these formats first g._formats = g.formats([ "\"yyyy-MM-ddTHH:mm:ssZ\"", "yyyy-MM-ddTHH:mm:ss.sz", "yyyy-MM-ddTHH:mm:ssZ", "yyyy-MM-ddTHH:mm:ssz", "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-ddTHH:mmZ", "yyyy-MM-ddTHH:mmz", "yyyy-MM-ddTHH:mm", "ddd, MMM dd, yyyy H:mm:ss tt", "ddd MMM d yyyy HH:mm:ss zzz", "MMddyyyy", "ddMMyyyy", "Mddyyyy", "ddMyyyy", "Mdyyyy", "dMyyyy", "yyyy", "Mdyy", "dMyy", "d" ]); // real starting rule: tries selected formats first, // then general purpose rule g.start = function (s) { try { var r = g._formats.call({}, s); if (r[1].length === 0) { return r; } } catch (e) {} return g._start.call({}, s); }; }()); (function () { var $D = Date; /** * @desc Converts the specified string value into its JavaScript Date equivalent using CultureInfo specific format information. * * Example

	///////////
	// Dates //
	///////////

	// 15-Oct-2004
	var d1 = Date.parse("10/15/2004");

	// 15-Oct-2004
	var d1 = Date.parse("15-Oct-2004");

	// 15-Oct-2004
	var d1 = Date.parse("2004.10.15");

	//Fri Oct 15, 2004
	var d1 = Date.parse("Fri Oct 15, 2004");

	///////////
	// Times //
	///////////

	// Today at 10 PM.
	var d1 = Date.parse("10 PM");

	// Today at 10:30 PM.
	var d1 = Date.parse("10:30 P.M.");

	// Today at 6 AM.
	var d1 = Date.parse("06am");

	/////////////////////
	// Dates and Times //
	/////////////////////

	// 8-July-2004 @ 10:30 PM
	var d1 = Date.parse("July 8th, 2004, 10:30 PM");

	// 1-July-2004 @ 10:30 PM
	var d1 = Date.parse("2004-07-01T22:30:00");

	////////////////////
	// Relative Dates //
	////////////////////

	// Returns today's date. The string "today" is culture specific.
	var d1 = Date.parse("today");

	// Returns yesterday's date. The string "yesterday" is culture specific.
	var d1 = Date.parse("yesterday");

	// Returns the date of the next thursday.
	var d1 = Date.parse("Next thursday");

	// Returns the date of the most previous monday.
	var d1 = Date.parse("last monday");

	// Returns today's day + one year.
	var d1 = Date.parse("next year");

	///////////////
	// Date Math //
	///////////////

	// Today + 2 days
	var d1 = Date.parse("t+2");

	// Today + 2 days
	var d1 = Date.parse("today + 2 days");

	// Today + 3 months
	var d1 = Date.parse("t+3m");

	// Today - 1 year
	var d1 = Date.parse("today - 1 year");

	// Today - 1 year
	var d1 = Date.parse("t-1y"); 


	/////////////////////////////
	// Partial Dates and Times //
	/////////////////////////////

	// July 15th of this year.
	var d1 = Date.parse("July 15");

	// 15th day of current day and year.
	var d1 = Date.parse("15");

	// July 1st of current year at 10pm.
	var d1 = Date.parse("7/1 10pm");
	
* * @param {String} The string value to convert into a Date object [Required] * @return {Date} A Date object or null if the string cannot be converted into a Date. */ var parseUtils = { removeOrds: function (s) { ords = s.match(/\b(\d+)(?:st|nd|rd|th)\b/); // find ordinal matches s = ((ords && ords.length === 2) ? s.replace(ords[0], ords[1]) : s); return s; }, grammarParser: function (s) { var r = null; try { r = $D.Grammar.start.call({}, s.replace(/^\s*(\S*(\s+\S+)*)\s*$/, "$1")); } catch (e) { return null; } return ((r[1].length === 0) ? r[0] : null); }, nativeFallback: function(s) { var t; try { // ok we haven't parsed it, last ditch attempt with the built-in parser. t = Date._parse(s); return (t || t === 0) ? new Date(t) : null; } catch (e) { return null; } } }; function parse (s) { var d; if (!s) { return null; } if (s instanceof Date) { return s.clone(); } if (s.length >= 4 && s.charAt(0) !== "0" && s.charAt(0) !== "+"&& s.charAt(0) !== "-") { // ie: 2004 will pass, 0800 won't. // Start with specific formats d = $D.Parsing.ISO.parse(s) || $D.Parsing.Numeric.parse(s); } if (d instanceof Date && !isNaN(d.getTime())) { return d; } else { // find ordinal dates (1st, 3rd, 8th, etc and remove them as they cause parsing issues) s = $D.Parsing.Normalizer.parse(parseUtils.removeOrds(s)); d = parseUtils.grammarParser(s); if (d !== null) { return d; } else { return parseUtils.nativeFallback(s); } } } if (!$D._parse) { $D._parse = $D.parse; } $D.parse = parse; Date.getParseFunction = function (fx) { var fns = Date.Grammar.allformats(fx); return function (s) { var r = null; for (var i = 0; i < fns.length; i++) { try { r = fns[i].call({}, s); } catch (e) { continue; } if (r[1].length === 0) { return r[0]; } } return null; }; }; /** * Converts the specified string value into its JavaScript Date equivalent using the specified format {String} or formats {Array} and the CultureInfo specific format information. * The format of the string value must match one of the supplied formats exactly. * * Example

	// 15-Oct-2004
	var d1 = Date.parseExact("10/15/2004", "M/d/yyyy");

	// 15-Oct-2004
	var d1 = Date.parse("15-Oct-2004", "M-ddd-yyyy");

	// 15-Oct-2004
	var d1 = Date.parse("2004.10.15", "yyyy.MM.dd");

	// Multiple formats
	var d1 = Date.parseExact("10/15/2004", ["M/d/yyyy", "MMMM d, yyyy"]);
	
* * @param {String} The string value to convert into a Date object [Required]. * @param {Object} The expected format {String} or an array of expected formats {Array} of the date string [Required]. * @return {Date} A Date object or null if the string cannot be converted into a Date. */ $D.parseExact = function (s, fx) { return $D.getParseFunction(fx)(s); }; }()); (function () { var $D = Date, $P = $D.prototype, // $C = $D.CultureInfo, // not used atm p = function (s, l) { if (!l) { l = 2; } return ("000" + s).slice(l * -1); }; /** * Converts a PHP format string to Java/.NET format string. * A PHP format string can be used with ._format or .format. * A Java/.NET format string can be used with .toString(). * The .parseExact function will only accept a Java/.NET format string * * Example * var f1 = "%m/%d/%y" * var f2 = Date.normalizeFormat(f1); // "MM/dd/yy" * * new Date().format(f1); // "04/13/08" * new Date()._format(f1); // "04/13/08" * new Date().toString(f2); // "04/13/08" * * var date = Date.parseExact("04/13/08", f2); // Sun Apr 13 2008 * * @param {String} A PHP format string consisting of one or more format spcifiers. * @return {String} The PHP format converted to a Java/.NET format string. */ var normalizerSubstitutions = { "d" : "dd", "%d": "dd", "D" : "ddd", "%a": "ddd", "j" : "dddd", "l" : "dddd", "%A": "dddd", "S" : "S", "F" : "MMMM", "%B": "MMMM", "m" : "MM", "%m": "MM", "M" : "MMM", "%b": "MMM", "%h": "MMM", "n" : "M", "Y" : "yyyy", "%Y": "yyyy", "y" : "yy", "%y": "yy", "g" : "h", "%I": "h", "G" : "H", "h" : "hh", "H" : "HH", "%H": "HH", "i" : "mm", "%M": "mm", "s" : "ss", "%S": "ss", "%r": "hh:mm tt", "%R": "H:mm", "%T": "H:mm:ss", "%X": "t", "%x": "d", "%e": "d", "%D": "MM/dd/yy", "%n": "\\n", "%t": "\\t", "e" : "z", "T" : "z", "%z": "z", "%Z": "z", "Z" : "ZZ", "N" : "u", "w" : "u", "%w": "u", "W" : "W", "%V": "W" }; var normalizer = { substitutes: function (m) { return normalizerSubstitutions[m]; }, interpreted: function (m, x) { var y; switch (m) { case "%u": return x.getDay() + 1; case "z": return x.getOrdinalNumber(); case "%j": return p(x.getOrdinalNumber(), 3); case "%U": var d1 = x.clone().set({month: 0, day: 1}).addDays(-1).moveToDayOfWeek(0), d2 = x.clone().addDays(1).moveToDayOfWeek(0, -1); return (d2 < d1) ? "00" : p((d2.getOrdinalNumber() - d1.getOrdinalNumber()) / 7 + 1); case "%W": return p(x.getWeek()); case "t": return $D.getDaysInMonth(x.getFullYear(), x.getMonth()); case "o": case "%G": return x.setWeek(x.getISOWeek()).toString("yyyy"); case "%g": return x._format("%G").slice(-2); case "a": case "%p": return t("tt").toLowerCase(); case "A": return t("tt").toUpperCase(); case "u": return p(x.getMilliseconds(), 3); case "I": return (x.isDaylightSavingTime()) ? 1 : 0; case "O": return x.getUTCOffset(); case "P": y = x.getUTCOffset(); return y.substring(0, y.length - 2) + ":" + y.substring(y.length - 2); case "B": var now = new Date(); return Math.floor(((now.getHours() * 3600) + (now.getMinutes() * 60) + now.getSeconds() + (now.getTimezoneOffset() + 60) * 60) / 86.4); case "c": return x.toISOString().replace(/\"/g, ""); case "U": return $D.strtotime("now"); case "%c": return t("d") + " " + t("t"); case "%C": return Math.floor(x.getFullYear() / 100 + 1); } }, shouldOverrideDefaults: function (m) { switch (m) { case "%e": return true; default: return false; } }, parse: function (m, context) { var formatString, c = context || new Date(); formatString = normalizer.substitutes(m); if (formatString) { return formatString; } formatString = normalizer.interpreted(m, c); if (formatString) { return formatString; } else { return m; } } }; $D.normalizeFormat = function (format, context) { return format.replace(/(%|\\)?.|%%/g, function(t){ return normalizer.parse(t, context); }); }; /** * Format a local Unix timestamp according to locale settings * * Example: * Date.strftime("%m/%d/%y", new Date()); // "04/13/08" * Date.strftime("c", "2008-04-13T17:52:03Z"); // "04/13/08" * * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @param {Number|String} The number representing the number of seconds that have elapsed since January 1, 1970 (local time). * @return {String} A string representation of the current Date object. */ $D.strftime = function (format, time) { var d = Date.parse(time); return d._format(format); }; /** * Parse any textual datetime description into a Unix timestamp. * A Unix timestamp is the number of seconds that have elapsed since January 1, 1970 (midnight UTC/GMT). * * Example: * Date.strtotime("04/13/08"); // 1208044800 * Date.strtotime("1970-01-01T00:00:00Z"); // 0 * * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @param {Object} A string or date object. * @return {String} A string representation of the current Date object. */ $D.strtotime = function (time) { var d = $D.parse(time); return Math.round($D.UTC(d.getUTCFullYear(), d.getUTCMonth(), d.getUTCDate(), d.getUTCHours(), d.getUTCMinutes(), d.getUTCSeconds(), d.getUTCMilliseconds()) / 1000); }; /** * Converts the value of the current Date object to its equivalent string representation using a PHP/Unix style of date format specifiers. * Format Specifiers * Format Description Example * ------ --------------------------------------------------------------------------- ----------------------- * %a abbreviated weekday name according to the current localed "Mon" through "Sun" * %A full weekday name according to the current localed "Sunday" through "Saturday" * %b abbreviated month name according to the current localed "Jan" through "Dec" * %B full month name according to the current locale "January" through "December" * %c preferred date and time representation for the current locale "4/13/2008 12:33 PM" * %C century number (the year divided by 100 and truncated to an integer) "00" to "99" * %d day of the month as a decimal number "01" to "31" * %D same as %m/%d/%y "04/13/08" * %e day of the month as a decimal number, a single digit is preceded by a space "1" to "31" * %g like %G, but without the century "08" * %G The 4-digit year corresponding to the ISO week number (see %V). "2008" * This has the same format and value as %Y, except that if the ISO week number * belongs to the previous or next year, that year is used instead. * %h same as %b "Jan" through "Dec" * %H hour as a decimal number using a 24-hour clock. "00" to "23" * %I hour as a decimal number using a 12-hour clock. "01" to "12" * %j day of the year as a decimal number. "001" to "366" * %m month as a decimal number. "01" to "12" * %M minute as a decimal number. "00" to "59" * %n newline character "\n" * %p either "am" or "pm" according to the given time value, or the "am" or "pm" * corresponding strings for the current locale. * %r time in a.m. and p.m. notation "8:44 PM" * %R time in 24 hour notation "20:44" * %S second as a decimal number "00" to "59" * %t tab character "\t" * %T current time, equal to %H:%M:%S "12:49:11" * %u weekday as a decimal number ["1", "7"], with "1" representing Monday "1" to "7" * %U week number of the current year as a decimal number, starting with the "0" to ("52" or "53") * first Sunday as the first day of the first week * %V The ISO 8601:1988 week number of the current year as a decimal number, "00" to ("52" or "53") * range 01 to 53, where week 1 is the first week that has at least 4 days * in the current year, and with Monday as the first day of the week. * (Use %G or %g for the year component that corresponds to the week number * for the specified timestamp.) * %W week number of the current year as a decimal number, starting with the "00" to ("52" or "53") * first Monday as the first day of the first week * %w day of the week as a decimal, Sunday being "0" "0" to "6" * %x preferred date representation for the current locale without the time "4/13/2008" * %X preferred time representation for the current locale without the date "12:53:05" * %y year as a decimal number without a century "00" "99" * %Y year as a decimal number including the century "2008" * %Z time zone or name or abbreviation "UTC", "EST", "PST" * %z same as %Z * %% a literal "%" characters "%" * d Day of the month, 2 digits with leading zeros "01" to "31" * D A textual representation of a day, three letters "Mon" through "Sun" * j Day of the month without leading zeros "1" to "31" * l A full textual representation of the day of the week (lowercase "L") "Sunday" through "Saturday" * N ISO-8601 numeric representation of the day of the week (added in PHP 5.1.0) "1" (for Monday) through "7" (for Sunday) * S English ordinal suffix for the day of the month, 2 characters "st", "nd", "rd" or "th". Works well with j * w Numeric representation of the day of the week "0" (for Sunday) through "6" (for Saturday) * z The day of the year (starting from "0") "0" through "365" * W ISO-8601 week number of year, weeks starting on Monday "00" to ("52" or "53") * F A full textual representation of a month, such as January or March "January" through "December" * m Numeric representation of a month, with leading zeros "01" through "12" * M A short textual representation of a month, three letters "Jan" through "Dec" * n Numeric representation of a month, without leading zeros "1" through "12" * t Number of days in the given month "28" through "31" * L Whether it's a leap year "1" if it is a leap year, "0" otherwise * o ISO-8601 year number. This has the same value as Y, except that if the "2008" * ISO week number (W) belongs to the previous or next year, that year * is used instead. * Y A full numeric representation of a year, 4 digits "2008" * y A two digit representation of a year "08" * a Lowercase Ante meridiem and Post meridiem "am" or "pm" * A Uppercase Ante meridiem and Post meridiem "AM" or "PM" * B Swatch Internet time "000" through "999" * g 12-hour format of an hour without leading zeros "1" through "12" * G 24-hour format of an hour without leading zeros "0" through "23" * h 12-hour format of an hour with leading zeros "01" through "12" * H 24-hour format of an hour with leading zeros "00" through "23" * i Minutes with leading zeros "00" to "59" * s Seconds, with leading zeros "00" through "59" * u Milliseconds "54321" * e Timezone identifier "UTC", "EST", "PST" * I Whether or not the date is in daylight saving time (uppercase i) "1" if Daylight Saving Time, "0" otherwise * O Difference to Greenwich time (GMT) in hours "+0200", "-0600" * P Difference to Greenwich time (GMT) with colon between hours and minutes "+02:00", "-06:00" * T Timezone abbreviation "UTC", "EST", "PST" * Z Timezone offset in seconds. The offset for timezones west of UTC is "-43200" through "50400" * always negative, and for those east of UTC is always positive. * c ISO 8601 date "2004-02-12T15:19:21+00:00" * r RFC 2822 formatted date "Thu, 21 Dec 2000 16:01:07 +0200" * U Seconds since the Unix Epoch (January 1 1970 00:00:00 GMT) "0" * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @return {String} A string representation of the current Date object. */ var formatReplace = function (context) { return function (m) { var formatString, override = false; if (m.charAt(0) === "\\" || m.substring(0, 2) === "%%") { return m.replace("\\", "").replace("%%", "%"); } override = normalizer.shouldOverrideDefaults(m); formatString = $D.normalizeFormat(m, context); if (formatString) { return context.toString(formatString, override); } }; }; $P._format = function (format) { var formatter = formatReplace(this); if (!format) { return this._toString(); } else { return format.replace(/(%|\\)?.|%%/g, formatter); } }; if (!$P.format) { $P.format = $P._format; } }()); (function () { "use strict"; var gFn = function (attr) { return function () { return this[attr]; }; }; var sFn = function (attr) { return function (val) { this[attr] = val; return this; }; }; var attrs = ["years", "months", "days", "hours", "minutes", "seconds", "milliseconds"]; var addSetFuncs = function (context, attrs) { for (var i = 0; i < attrs.length ; i++) { var $a = attrs[i], $b = $a.slice(0, 1).toUpperCase() + $a.slice(1); context.prototype[$a] = 0; context.prototype["get" + $b] = gFn($a); context.prototype["set" + $b] = sFn($a); } }; /** * new TimeSpan(milliseconds); * new TimeSpan(days, hours, minutes, seconds); * new TimeSpan(days, hours, minutes, seconds, milliseconds); */ var TimeSpan = function (days, hours, minutes, seconds, milliseconds) { if (arguments.length === 1 && typeof days === "number") { var orient = (days < 0) ? -1 : +1; var millsLeft = Math.abs(days); this.setDays(Math.floor(millsLeft / 86400000) * orient); millsLeft = millsLeft % 86400000; this.setHours(Math.floor(millsLeft / 3600000) * orient); millsLeft = millsLeft % 3600000; this.setMinutes(Math.floor(millsLeft / 60000) * orient); millsLeft = millsLeft % 60000; this.setSeconds(Math.floor(millsLeft / 1000) * orient); millsLeft = millsLeft % 1000; this.setMilliseconds(millsLeft * orient); } else { this.set(days, hours, minutes, seconds, milliseconds); } this.getTotalMilliseconds = function () { return (this.getDays() * 86400000) + (this.getHours() * 3600000) + (this.getMinutes() * 60000) + (this.getSeconds() * 1000); }; this.compareTo = function (time) { var t1 = new Date(1970, 1, 1, this.getHours(), this.getMinutes(), this.getSeconds()), t2; if (time === null) { t2 = new Date(1970, 1, 1, 0, 0, 0); } else { t2 = new Date(1970, 1, 1, time.getHours(), time.getMinutes(), time.getSeconds()); } return (t1 < t2) ? -1 : (t1 > t2) ? 1 : 0; }; this.equals = function (time) { return (this.compareTo(time) === 0); }; this.add = function (time) { return (time === null) ? this : this.addSeconds(time.getTotalMilliseconds() / 1000); }; this.subtract = function (time) { return (time === null) ? this : this.addSeconds(-time.getTotalMilliseconds() / 1000); }; this.addDays = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 86400000)); }; this.addHours = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 3600000)); }; this.addMinutes = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 60000)); }; this.addSeconds = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 1000)); }; this.addMilliseconds = function (n) { return new TimeSpan(this.getTotalMilliseconds() + n); }; this.get12HourHour = function () { return (this.getHours() > 12) ? this.getHours() - 12 : (this.getHours() === 0) ? 12 : this.getHours(); }; this.getDesignator = function () { return (this.getHours() < 12) ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator; }; this.toString = function (format) { this._toString = function () { if (this.getDays() !== null && this.getDays() > 0) { return this.getDays() + "." + this.getHours() + ":" + this.p(this.getMinutes()) + ":" + this.p(this.getSeconds()); } else { return this.getHours() + ":" + this.p(this.getMinutes()) + ":" + this.p(this.getSeconds()); } }; this.p = function (s) { return (s.toString().length < 2) ? "0" + s : s; }; var me = this; return format ? format.replace(/dd?|HH?|hh?|mm?|ss?|tt?/g, function (format) { switch (format) { case "d": return me.getDays(); case "dd": return me.p(me.getDays()); case "H": return me.getHours(); case "HH": return me.p(me.getHours()); case "h": return me.get12HourHour(); case "hh": return me.p(me.get12HourHour()); case "m": return me.getMinutes(); case "mm": return me.p(me.getMinutes()); case "s": return me.getSeconds(); case "ss": return me.p(me.getSeconds()); case "t": return ((me.getHours() < 12) ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator).substring(0, 1); case "tt": return (me.getHours() < 12) ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator; } } ) : this._toString(); }; return this; }; addSetFuncs(TimeSpan, attrs.slice(2)); TimeSpan.prototype.set = function (days, hours, minutes, seconds, milliseconds){ this.setDays(days || this.getDays()); this.setHours(hours || this.getHours()); this.setMinutes(minutes || this.getMinutes()); this.setSeconds(seconds || this.getSeconds()); this.setMilliseconds(milliseconds || this.getMilliseconds()); }; /** * Gets the time of day for this date instances. * @return {TimeSpan} TimeSpan */ Date.prototype.getTimeOfDay = function () { return new TimeSpan(0, this.getHours(), this.getMinutes(), this.getSeconds(), this.getMilliseconds()); }; Date.TimeSpan = TimeSpan; if (typeof window !== "undefined" ) { // keeping API compatible for v1.x window.TimeSpan = TimeSpan; } }()); (function () { "use strict"; var attrs = ["years", "months", "days", "hours", "minutes", "seconds", "milliseconds"]; var gFn = function (attr) { return function () { return this[attr]; }; }; var sFn = function (attr) { return function (val) { this[attr] = val; return this; }; }; var addSetFuncs = function (context, attrs) { for (var i = 0; i < attrs.length ; i++) { var $a = attrs[i], $b = $a.slice(0, 1).toUpperCase() + $a.slice(1); context.prototype[$a] = 0; context.prototype["get" + $b] = gFn($a); context.prototype["set" + $b] = sFn($a); } }; var setMonthsAndYears = function (orient, d1, d2, context) { function inc() { d1.addMonths(-orient); context.months++; if (context.months === 12) { context.years++; context.months = 0; } } if (orient === +1) { while (d1 > d2) { inc(); } } else { while (d1 < d2) { inc(); } } context.months--; context.months *= orient; context.years *= orient; }; var adjustForDST = function(orient, startDate, endDate) { var hasDSTMismatch = (false === (startDate.isDaylightSavingTime() === endDate.isDaylightSavingTime())); if (hasDSTMismatch && orient === 1) { startDate.addHours(-1); } else if (hasDSTMismatch) { startDate.addHours(1); } }; /** * TimePeriod(startDate, endDate); * TimePeriod(years, months, days, hours, minutes, seconds, milliseconds); */ var TimePeriod = function (years, months, days, hours, minutes, seconds, milliseconds) { if (arguments.length === 7) { this.set(years, months, days, hours, minutes, seconds, milliseconds); } else if (arguments.length === 2 && arguments[0] instanceof Date && arguments[1] instanceof Date) { var startDate = arguments[0].clone(); var endDate = arguments[1].clone(); var orient = (startDate > endDate) ? +1 : -1; this.dates = { start: arguments[0].clone(), end: arguments[1].clone() }; setMonthsAndYears(orient, startDate, endDate, this); adjustForDST(orient, startDate, endDate); // // TODO - adjust for DST var diff = endDate - startDate; if (diff !== 0) { var ts = new TimeSpan(diff); this.set(this.years, this.months, ts.getDays(), ts.getHours(), ts.getMinutes(), ts.getSeconds(), ts.getMilliseconds()); } } return this; }; // create all the set functions. addSetFuncs(TimePeriod, attrs); TimePeriod.prototype.set = function (years, months, days, hours, minutes, seconds, milliseconds){ this.setYears(years || this.getYears()); this.setMonths(months || this.getMonths()); this.setDays(days || this.getDays()); this.setHours(hours || this.getHours()); this.setMinutes(minutes || this.getMinutes()); this.setSeconds(seconds || this.getSeconds()); this.setMilliseconds(milliseconds || this.getMilliseconds()); }; Date.TimePeriod = TimePeriod; if (typeof window !== "undefined") { // keeping API compatible for v1.x window.TimePeriod = TimePeriod; } }()); ================================================ FILE: build/date-sq-AL.js ================================================ /** * @overview datejs * @version 1.0.0-rc3 * @author Gregory Wild-Smith * @copyright 2015 Gregory Wild-Smith * @license MIT * @homepage https://github.com/abritinthebay/datejs */ /* * DateJS Culture String File * Country Code: sq-AL * Name: Albanian (Albania) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["sq-AL"] = { "name": "sq-AL", "englishName": "Albanian (Albania)", "nativeName": "shqipe (Shqipëria)", "Sunday": "e diel", "Monday": "e hënë", "Tuesday": "e martë", "Wednesday": "e mërkurë", "Thursday": "e enjte", "Friday": "e premte", "Saturday": "e shtunë", "Sun": "Die", "Mon": "Hën", "Tue": "Mar", "Wed": "Mër", "Thu": "Enj", "Fri": "Pre", "Sat": "Sht", "Su": "Di", "Mo": "Hë", "Tu": "Ma", "We": "Më", "Th": "En", "Fr": "Pr", "Sa": "Sh", "S_Sun_Initial": "D", "M_Mon_Initial": "H", "T_Tue_Initial": "M", "W_Wed_Initial": "M", "T_Thu_Initial": "E", "F_Fri_Initial": "P", "S_Sat_Initial": "S", "January": "janar", "February": "shkurt", "March": "mars", "April": "prill", "May": "maj", "June": "qershor", "July": "korrik", "August": "gusht", "September": "shtator", "October": "tetor", "November": "nëntor", "December": "dhjetor", "Jan_Abbr": "Jan", "Feb_Abbr": "Shk", "Mar_Abbr": "Mar", "Apr_Abbr": "Pri", "May_Abbr": "Maj", "Jun_Abbr": "Qer", "Jul_Abbr": "Kor", "Aug_Abbr": "Gsh", "Sep_Abbr": "Sht", "Oct_Abbr": "Tet", "Nov_Abbr": "Nën", "Dec_Abbr": "Dhj", "AM": "PD", "PM": "MD", "firstDayOfWeek": 1, "twoDigitYearMax": 2029, "mdy": "ymd", "M/d/yyyy": "yyyy-MM-dd", "dddd, MMMM dd, yyyy": "yyyy-MM-dd", "h:mm tt": "h:mm.tt", "h:mm:ss tt": "h:mm:ss.tt", "dddd, MMMM dd, yyyy h:mm:ss tt": "yyyy-MM-dd h:mm:ss.tt", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "MMMM dd", "MMMM, yyyy": "yyyy-MM", "/jan(uary)?/": "jan(ar)?", "/feb(ruary)?/": "shk(urt)?", "/mar(ch)?/": "mar(s)?", "/apr(il)?/": "pri(ll)?", "/may/": "maj", "/jun(e)?/": "qer(shor)?", "/jul(y)?/": "kor(rik)?", "/aug(ust)?/": "gusht", "/sep(t(ember)?)?/": "sht(ator)?", "/oct(ober)?/": "tet(or)?", "/nov(ember)?/": "nën(tor)?", "/dec(ember)?/": "dhj(etor)?", "/^su(n(day)?)?/": "^di(e(iel)?)?", "/^mo(n(day)?)?/": "^hë(n(ënë)?)?", "/^tu(e(s(day)?)?)?/": "^ma(r(artë)?)?", "/^we(d(nesday)?)?/": "^më(r(ërkurë)?)?", "/^th(u(r(s(day)?)?)?)?/": "^en(j(njte)?)?", "/^fr(i(day)?)?/": "^pr(e(remte)?)?", "/^sa(t(urday)?)?/": "^sh(t(htunë)?)?", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "sq-AL"; /** * @overview datejs * @version 1.0.0-rc3 * @author Gregory Wild-Smith * @copyright 2015 Gregory Wild-Smith * @license MIT * @homepage https://github.com/abritinthebay/datejs */(function () { var $D = Date; var lang = Date.CultureStrings ? Date.CultureStrings.lang : null; var loggedKeys = {}; // for debug purposes. var getText = { getFromKey: function (key, countryCode) { var output; if (Date.CultureStrings && Date.CultureStrings[countryCode] && Date.CultureStrings[countryCode][key]) { output = Date.CultureStrings[countryCode][key]; } else { output = getText.buildFromDefault(key); } if (key.charAt(0) === "/") { // Assume it's a regex output = getText.buildFromRegex(key, countryCode); } return output; }, getFromObjectValues: function (obj, countryCode) { var key, output = {}; for(key in obj) { if (obj.hasOwnProperty(key)) { output[key] = getText.getFromKey(obj[key], countryCode); } } return output; }, getFromObjectKeys: function (obj, countryCode) { var key, output = {}; for(key in obj) { if (obj.hasOwnProperty(key)) { output[getText.getFromKey(key, countryCode)] = obj[key]; } } return output; }, getFromArray: function (arr, countryCode) { var output = []; for (var i=0; i < arr.length; i++){ if (i in arr) { output[i] = getText.getFromKey(arr[i], countryCode); } } return output; }, buildFromDefault: function (key) { var output, length, split, last; switch(key) { case "name": output = "en-US"; break; case "englishName": output = "English (United States)"; break; case "nativeName": output = "English (United States)"; break; case "twoDigitYearMax": output = 2049; break; case "firstDayOfWeek": output = 0; break; default: output = key; split = key.split("_"); length = split.length; if (length > 1 && key.charAt(0) !== "/") { // if the key isn't a regex and it has a split. last = split[(length - 1)].toLowerCase(); if (last === "initial" || last === "abbr") { output = split[0]; } } break; } return output; }, buildFromRegex: function (key, countryCode) { var output; if (Date.CultureStrings && Date.CultureStrings[countryCode] && Date.CultureStrings[countryCode][key]) { output = new RegExp(Date.CultureStrings[countryCode][key], "i"); } else { output = new RegExp(key.replace(new RegExp("/", "g"),""), "i"); } return output; } }; var shallowMerge = function (obj1, obj2) { for (var attrname in obj2) { if (obj2.hasOwnProperty(attrname)) { obj1[attrname] = obj2[attrname]; } } }; var __ = function (key, language) { var countryCode = (language) ? language : lang; loggedKeys[key] = key; if (typeof key === "object") { if (key instanceof Array) { return getText.getFromArray(key, countryCode); } else { return getText.getFromObjectKeys(key, countryCode); } } else { return getText.getFromKey(key, countryCode); } }; var loadI18nScript = function (code) { // paatterned after jQuery's getScript. var url = Date.Config.i18n + code + ".js"; var head = document.getElementsByTagName("head")[0] || document.documentElement; var script = document.createElement("script"); script.src = url; var completed = false; var events = { done: function (){} // placeholder function }; // Attach handlers for all browsers script.onload = script.onreadystatechange = function() { if ( !completed && (!this.readyState || this.readyState === "loaded" || this.readyState === "complete") ) { events.done(); head.removeChild(script); } }; setTimeout(function() { head.insertBefore(script, head.firstChild); }, 0); // allows return to execute first return { done: function (cb) { events.done = function() { if (cb) { setTimeout(cb,0); } }; } }; }; var buildInfo = { buildFromMethodHash: function (obj) { var key; for(key in obj) { if (obj.hasOwnProperty(key)) { obj[key] = buildInfo[obj[key]](); } } return obj; }, timeZoneDST: function () { var DST = { "CHADT": "+1345", "NZDT": "+1300", "AEDT": "+1100", "ACDT": "+1030", "AZST": "+0500", "IRDT": "+0430", "EEST": "+0300", "CEST": "+0200", "BST": "+0100", "PMDT": "-0200", "ADT": "-0300", "NDT": "-0230", "EDT": "-0400", "CDT": "-0500", "MDT": "-0600", "PDT": "-0700", "AKDT": "-0800", "HADT": "-0900" }; return __(DST); }, timeZoneStandard: function () { var standard = { "LINT": "+1400", "TOT": "+1300", "CHAST": "+1245", "NZST": "+1200", "NFT": "+1130", "SBT": "+1100", "AEST": "+1000", "ACST": "+0930", "JST": "+0900", "CWST": "+0845", "CT": "+0800", "ICT": "+0700", "MMT": "+0630", "BST": "+0600", "NPT": "+0545", "IST": "+0530", "PKT": "+0500", "AFT": "+0430", "MSK": "+0400", "IRST": "+0330", "FET": "+0300", "EET": "+0200", "CET": "+0100", "GMT": "+0000", "UTC": "+0000", "CVT": "-0100", "GST": "-0200", "BRT": "-0300", "NST": "-0330", "AST": "-0400", "EST": "-0500", "CST": "-0600", "MST": "-0700", "PST": "-0800", "AKST": "-0900", "MIT": "-0930", "HST": "-1000", "SST": "-1100", "BIT": "-1200" }; return __(standard); }, timeZones: function (data) { var zone; data.timezones = []; for (zone in data.abbreviatedTimeZoneStandard) { if (data.abbreviatedTimeZoneStandard.hasOwnProperty(zone)) { data.timezones.push({ name: zone, offset: data.abbreviatedTimeZoneStandard[zone]}); } } for (zone in data.abbreviatedTimeZoneDST) { if (data.abbreviatedTimeZoneDST.hasOwnProperty(zone)) { data.timezones.push({ name: zone, offset: data.abbreviatedTimeZoneDST[zone], dst: true}); } } return data.timezones; }, days: function () { return __(["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"]); }, dayAbbr: function () { return __(["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"]); }, dayShortNames: function () { return __(["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"]); }, dayFirstLetters: function () { return __(["S_Sun_Initial", "M_Mon_Initial", "T_Tues_Initial", "W_Wed_Initial", "T_Thu_Initial", "F_Fri_Initial", "S_Sat_Initial"]); }, months: function () { return __(["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"]); }, monthAbbr: function () { return __(["Jan_Abbr", "Feb_Abbr", "Mar_Abbr", "Apr_Abbr", "May_Abbr", "Jun_Abbr", "Jul_Abbr", "Aug_Abbr", "Sep_Abbr", "Oct_Abbr", "Nov_Abbr", "Dec_Abbr"]); }, formatPatterns: function () { return getText.getFromObjectValues({ shortDate: "M/d/yyyy", longDate: "dddd, MMMM dd, yyyy", shortTime: "h:mm tt", longTime: "h:mm:ss tt", fullDateTime: "dddd, MMMM dd, yyyy h:mm:ss tt", sortableDateTime: "yyyy-MM-ddTHH:mm:ss", universalSortableDateTime: "yyyy-MM-dd HH:mm:ssZ", rfc1123: "ddd, dd MMM yyyy HH:mm:ss", monthDay: "MMMM dd", yearMonth: "MMMM, yyyy" }, Date.i18n.currentLanguage()); }, regex: function () { return getText.getFromObjectValues({ inTheMorning: "/( in the )(morn(ing)?)\\b/", thisMorning: "/(this )(morn(ing)?)\\b/", amThisMorning: "/(\b\\d(am)? )(this )(morn(ing)?)/", inTheEvening: "/( in the )(even(ing)?)\\b/", thisEvening: "/(this )(even(ing)?)\\b/", pmThisEvening: "/(\b\\d(pm)? )(this )(even(ing)?)/", jan: "/jan(uary)?/", feb: "/feb(ruary)?/", mar: "/mar(ch)?/", apr: "/apr(il)?/", may: "/may/", jun: "/jun(e)?/", jul: "/jul(y)?/", aug: "/aug(ust)?/", sep: "/sep(t(ember)?)?/", oct: "/oct(ober)?/", nov: "/nov(ember)?/", dec: "/dec(ember)?/", sun: "/^su(n(day)?)?/", mon: "/^mo(n(day)?)?/", tue: "/^tu(e(s(day)?)?)?/", wed: "/^we(d(nesday)?)?/", thu: "/^th(u(r(s(day)?)?)?)?/", fri: "/fr(i(day)?)?/", sat: "/^sa(t(urday)?)?/", future: "/^next/", past: "/^last|past|prev(ious)?/", add: "/^(\\+|aft(er)?|from|hence)/", subtract: "/^(\\-|bef(ore)?|ago)/", yesterday: "/^yes(terday)?/", today: "/^t(od(ay)?)?/", tomorrow: "/^tom(orrow)?/", now: "/^n(ow)?/", millisecond: "/^ms|milli(second)?s?/", second: "/^sec(ond)?s?/", minute: "/^mn|min(ute)?s?/", hour: "/^h(our)?s?/", week: "/^w(eek)?s?/", month: "/^m(onth)?s?/", day: "/^d(ay)?s?/", year: "/^y(ear)?s?/", shortMeridian: "/^(a|p)/", longMeridian: "/^(a\\.?m?\\.?|p\\.?m?\\.?)/", timezone: "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/", ordinalSuffix: "/^\\s*(st|nd|rd|th)/", timeContext: "/^\\s*(\\:|a(?!u|p)|p)/" }, Date.i18n.currentLanguage()); } }; var CultureInfo = function () { var info = getText.getFromObjectValues({ name: "name", englishName: "englishName", nativeName: "nativeName", amDesignator: "AM", pmDesignator: "PM", firstDayOfWeek: "firstDayOfWeek", twoDigitYearMax: "twoDigitYearMax", dateElementOrder: "mdy" }, Date.i18n.currentLanguage()); var constructedInfo = buildInfo.buildFromMethodHash({ dayNames: "days", abbreviatedDayNames: "dayAbbr", shortestDayNames: "dayShortNames", firstLetterDayNames: "dayFirstLetters", monthNames: "months", abbreviatedMonthNames: "monthAbbr", formatPatterns: "formatPatterns", regexPatterns: "regex", abbreviatedTimeZoneDST: "timeZoneDST", abbreviatedTimeZoneStandard: "timeZoneStandard" }); shallowMerge(info, constructedInfo); buildInfo.timeZones(info); return info; }; $D.i18n = { __: function (key, lang) { return __(key, lang); }, currentLanguage: function () { return lang || "en-US"; }, setLanguage: function (code, force, cb) { var async = false; if (force || code === "en-US" || (!!Date.CultureStrings && !!Date.CultureStrings[code])) { lang = code; Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings.lang = code; Date.CultureInfo = new CultureInfo(); } else { if (!(!!Date.CultureStrings && !!Date.CultureStrings[code])) { if (typeof exports !== "undefined" && this.exports !== exports) { // we're in a Node enviroment, load it using require try { require("../i18n/" + code + ".js"); lang = code; Date.CultureStrings.lang = code; Date.CultureInfo = new CultureInfo(); } catch (e) { // var str = "The language for '" + code + "' could not be loaded by Node. It likely does not exist."; throw new Error("The DateJS IETF language tag '" + code + "' could not be loaded by Node. It likely does not exist."); } } else if (Date.Config && Date.Config.i18n) { // we know the location of the files, so lets load them async = true; loadI18nScript(code).done(function(){ lang = code; Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings.lang = code; Date.CultureInfo = new CultureInfo(); $D.Parsing.Normalizer.buildReplaceData(); // because this is async if ($D.Grammar) { $D.Grammar.buildGrammarFormats(); // so we can parse those strings... } if (cb) { setTimeout(cb,0); } }); } else { Date.console.error("The DateJS IETF language tag '" + code + "' is not available and has not been loaded."); return false; } } } $D.Parsing.Normalizer.buildReplaceData(); // rebuild normalizer strings if ($D.Grammar) { $D.Grammar.buildGrammarFormats(); // so we can parse those strings... } if (!async && cb) { setTimeout(cb,0); } }, getLoggedKeys: function () { return loggedKeys; }, updateCultureInfo: function () { Date.CultureInfo = new CultureInfo(); } }; $D.i18n.updateCultureInfo(); // run automatically }()); (function () { var $D = Date, $P = $D.prototype, p = function (s, l) { if (!l) { l = 2; } return ("000" + s).slice(l * -1); }; if (typeof window !== "undefined" && typeof window.console !== "undefined" && typeof window.console.log !== "undefined") { $D.console = console; // used only to raise non-critical errors if available } else { // set mock so we don't give errors. $D.console = { log: function(){}, error: function(){} }; } $D.Config = $D.Config || {}; $D.initOverloads = function() { /** * Overload of Date.now. Allows an alternate call for Date.now where it returns the * current Date as an object rather than just milliseconds since the Unix Epoch. * * Also provides an implementation of now() for browsers (IE<9) that don't have it. * * Backwards compatible so with work with either: * Date.now() [returns ms] * or * Date.now(true) [returns Date] */ if (!$D.now) { $D._now = function now() { return new Date().getTime(); }; } else if (!$D._now) { $D._now = $D.now; } $D.now = function (returnObj) { if (returnObj) { return $D.present(); } else { return $D._now(); } }; if ( !$P.toISOString ) { $P.toISOString = function() { return this.getUTCFullYear() + "-" + p(this.getUTCMonth() + 1) + "-" + p(this.getUTCDate()) + "T" + p(this.getUTCHours()) + ":" + p(this.getUTCMinutes()) + ":" + p(this.getUTCSeconds()) + "." + String( (this.getUTCMilliseconds()/1000).toFixed(3)).slice(2, 5) + "Z"; }; } // private if ( $P._toString === undefined ){ $P._toString = $P.toString; } }; $D.initOverloads(); /** * Gets a date that is set to the current date. The time is set to the start of the day (00:00 or 12:00 AM). * @return {Date} The current date. */ $D.today = function () { return new Date().clearTime(); }; /** * Gets a date that is set to the current date and time (same as new Date, but chainable) * @return {Date} The current date. */ $D.present = function () { return new Date(); }; /** * Compares the first date to the second date and returns an number indication of their relative values. * @param {Date} First Date object to compare [Required]. * @param {Date} Second Date object to compare to [Required]. * @return {Number} -1 = date1 is lessthan date2. 0 = values are equal. 1 = date1 is greaterthan date2. */ $D.compare = function (date1, date2) { if (isNaN(date1) || isNaN(date2)) { throw new Error(date1 + " - " + date2); } else if (date1 instanceof Date && date2 instanceof Date) { return (date1 < date2) ? -1 : (date1 > date2) ? 1 : 0; } else { throw new TypeError(date1 + " - " + date2); } }; /** * Compares the first Date object to the second Date object and returns true if they are equal. * @param {Date} First Date object to compare [Required] * @param {Date} Second Date object to compare to [Required] * @return {Boolean} true if dates are equal. false if they are not equal. */ $D.equals = function (date1, date2) { return (date1.compareTo(date2) === 0); }; /** * Gets the language appropriate day name when given the day number(0-6) * eg - 0 == Sunday * @return {String} The day name */ $D.getDayName = function (n) { return Date.CultureInfo.dayNames[n]; }; /** * Gets the day number (0-6) if given a CultureInfo specific string which is a valid dayName, abbreviatedDayName or shortestDayName (two char). * @param {String} The name of the day (eg. "Monday, "Mon", "tuesday", "tue", "We", "we"). * @return {Number} The day number */ $D.getDayNumberFromName = function (name) { var n = Date.CultureInfo.dayNames, m = Date.CultureInfo.abbreviatedDayNames, o = Date.CultureInfo.shortestDayNames, s = name.toLowerCase(); for (var i = 0; i < n.length; i++) { if (n[i].toLowerCase() === s || m[i].toLowerCase() === s || o[i].toLowerCase() === s) { return i; } } return -1; }; /** * Gets the month number (0-11) if given a Culture Info specific string which is a valid monthName or abbreviatedMonthName. * @param {String} The name of the month (eg. "February, "Feb", "october", "oct"). * @return {Number} The day number */ $D.getMonthNumberFromName = function (name) { var n = Date.CultureInfo.monthNames, m = Date.CultureInfo.abbreviatedMonthNames, s = name.toLowerCase(); for (var i = 0; i < n.length; i++) { if (n[i].toLowerCase() === s || m[i].toLowerCase() === s) { return i; } } return -1; }; /** * Gets the language appropriate month name when given the month number(0-11) * eg - 0 == January * @return {String} The month name */ $D.getMonthName = function (n) { return Date.CultureInfo.monthNames[n]; }; /** * Determines if the current date instance is within a LeapYear. * @param {Number} The year. * @return {Boolean} true if date is within a LeapYear, otherwise false. */ $D.isLeapYear = function (year) { return ((year % 4 === 0 && year % 100 !== 0) || year % 400 === 0); }; /** * Gets the number of days in the month, given a year and month value. Automatically corrects for LeapYear. * @param {Number} The year. * @param {Number} The month (0-11). * @return {Number} The number of days in the month. */ $D.getDaysInMonth = function (year, month) { if (!month && $D.validateMonth(year)) { month = year; year = Date.today().getFullYear(); } return [31, ($D.isLeapYear(year) ? 29 : 28), 31, 30, 31, 30, 31, 31, 30, 31, 30, 31][month]; }; $P.getDaysInMonth = function () { return $D.getDaysInMonth(this.getFullYear(), this.getMonth()); }; $D.getTimezoneAbbreviation = function (offset, dst) { var p, n = (dst || false) ? Date.CultureInfo.abbreviatedTimeZoneDST : Date.CultureInfo.abbreviatedTimeZoneStandard; for (p in n) { if (n.hasOwnProperty(p)) { if (n[p] === offset) { return p; } } } return null; }; $D.getTimezoneOffset = function (name, dst) { var i, a =[], z = Date.CultureInfo.timezones; if (!name) { name = (new Date()).getTimezone();} for (i = 0; i < z.length; i++) { if (z[i].name === name.toUpperCase()) { a.push(i); } } if (!z[a[0]]) { return null; } if (a.length === 1 || !dst) { return z[a[0]].offset; } else { for (i=0; i < a.length; i++) { if (z[a[i]].dst) { return z[a[i]].offset; } } } }; $D.getQuarter = function (d) { d = d || new Date(); // If no date supplied, use today var q = [1,2,3,4]; return q[Math.floor(d.getMonth() / 3)]; // ~~~ is a bitwise op. Faster than Math.floor }; $D.getDaysLeftInQuarter = function (d) { d = d || new Date(); var qEnd = new Date(d); qEnd.setMonth(qEnd.getMonth() + 3 - qEnd.getMonth() % 3, 0); return Math.floor((qEnd - d) / 8.64e7); }; // private var validate = function (n, min, max, name) { name = name ? name : "Object"; if (typeof n === "undefined") { return false; } else if (typeof n !== "number") { throw new TypeError(n + " is not a Number."); } else if (n < min || n > max) { // As failing validation is *not* an exceptional circumstance // lets not throw a RangeError Exception here. // It's semantically correct but it's not sensible. return false; } return true; }; /** * Validates the number is within an acceptable range for milliseconds [0-999]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateMillisecond = function (value) { return validate(value, 0, 999, "millisecond"); }; /** * Validates the number is within an acceptable range for seconds [0-59]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateSecond = function (value) { return validate(value, 0, 59, "second"); }; /** * Validates the number is within an acceptable range for minutes [0-59]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateMinute = function (value) { return validate(value, 0, 59, "minute"); }; /** * Validates the number is within an acceptable range for hours [0-23]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateHour = function (value) { return validate(value, 0, 23, "hour"); }; /** * Validates the number is within an acceptable range for the days in a month [0-MaxDaysInMonth]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateDay = function (value, year, month) { if (year === undefined || year === null || month === undefined || month === null) { return false;} return validate(value, 1, $D.getDaysInMonth(year, month), "day"); }; /** * Validates the number is within an acceptable range for months [0-11]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateWeek = function (value) { return validate(value, 0, 53, "week"); }; /** * Validates the number is within an acceptable range for months [0-11]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateMonth = function (value) { return validate(value, 0, 11, "month"); }; /** * Validates the number is within an acceptable range for years. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateYear = function (value) { /** * Per ECMAScript spec the range of times supported by Date objects is * exactly -100,000,000 days to +100,000,000 days measured relative to * midnight at the beginning of 01 January, 1970 UTC. * This gives a range of 8,640,000,000,000,000 milliseconds to either * side of 01 January, 1970 UTC. * * Earliest possible date: Tue, 20 Apr 271,822 B.C. 00:00:00 UTC * Latest possible date: Sat, 13 Sep 275,760 00:00:00 UTC */ return validate(value, -271822, 275760, "year"); }; $D.validateTimezone = function(value) { var timezones = {"ACDT":1,"ACST":1,"ACT":1,"ADT":1,"AEDT":1,"AEST":1,"AFT":1,"AKDT":1,"AKST":1,"AMST":1,"AMT":1,"ART":1,"AST":1,"AWDT":1,"AWST":1,"AZOST":1,"AZT":1,"BDT":1,"BIOT":1,"BIT":1,"BOT":1,"BRT":1,"BST":1,"BTT":1,"CAT":1,"CCT":1,"CDT":1,"CEDT":1,"CEST":1,"CET":1,"CHADT":1,"CHAST":1,"CHOT":1,"ChST":1,"CHUT":1,"CIST":1,"CIT":1,"CKT":1,"CLST":1,"CLT":1,"COST":1,"COT":1,"CST":1,"CT":1,"CVT":1,"CWST":1,"CXT":1,"DAVT":1,"DDUT":1,"DFT":1,"EASST":1,"EAST":1,"EAT":1,"ECT":1,"EDT":1,"EEDT":1,"EEST":1,"EET":1,"EGST":1,"EGT":1,"EIT":1,"EST":1,"FET":1,"FJT":1,"FKST":1,"FKT":1,"FNT":1,"GALT":1,"GAMT":1,"GET":1,"GFT":1,"GILT":1,"GIT":1,"GMT":1,"GST":1,"GYT":1,"HADT":1,"HAEC":1,"HAST":1,"HKT":1,"HMT":1,"HOVT":1,"HST":1,"ICT":1,"IDT":1,"IOT":1,"IRDT":1,"IRKT":1,"IRST":1,"IST":1,"JST":1,"KGT":1,"KOST":1,"KRAT":1,"KST":1,"LHST":1,"LINT":1,"MAGT":1,"MART":1,"MAWT":1,"MDT":1,"MET":1,"MEST":1,"MHT":1,"MIST":1,"MIT":1,"MMT":1,"MSK":1,"MST":1,"MUT":1,"MVT":1,"MYT":1,"NCT":1,"NDT":1,"NFT":1,"NPT":1,"NST":1,"NT":1,"NUT":1,"NZDT":1,"NZST":1,"OMST":1,"ORAT":1,"PDT":1,"PET":1,"PETT":1,"PGT":1,"PHOT":1,"PHT":1,"PKT":1,"PMDT":1,"PMST":1,"PONT":1,"PST":1,"PYST":1,"PYT":1,"RET":1,"ROTT":1,"SAKT":1,"SAMT":1,"SAST":1,"SBT":1,"SCT":1,"SGT":1,"SLST":1,"SRT":1,"SST":1,"SYOT":1,"TAHT":1,"THA":1,"TFT":1,"TJT":1,"TKT":1,"TLT":1,"TMT":1,"TOT":1,"TVT":1,"UCT":1,"ULAT":1,"UTC":1,"UYST":1,"UYT":1,"UZT":1,"VET":1,"VLAT":1,"VOLT":1,"VOST":1,"VUT":1,"WAKT":1,"WAST":1,"WAT":1,"WEDT":1,"WEST":1,"WET":1,"WST":1,"YAKT":1,"YEKT":1,"Z":1}; return (timezones[value] === 1); }; $D.validateTimezoneOffset= function(value) { // timezones go from +14hrs to -12hrs, the +X hours are negative offsets. return (value > -841 && value < 721); }; }()); (function () { var $D = Date, $P = $D.prototype, p = function (s, l) { if (!l) { l = 2; } return ("000" + s).slice(l * -1); }; var validateConfigObject = function (obj) { var result = {}, self = this, prop, testFunc; testFunc = function (prop, func, value) { if (prop === "day") { var month = (obj.month !== undefined) ? obj.month : self.getMonth(); var year = (obj.year !== undefined) ? obj.year : self.getFullYear(); return $D[func](value, year, month); } else { return $D[func](value); } }; for (prop in obj) { if (Object.prototype.hasOwnProperty.call(obj, prop)) { var func = "validate" + prop.charAt(0).toUpperCase() + prop.slice(1); if ($D[func] && obj[prop] !== null && testFunc(prop, func, obj[prop])) { result[prop] = obj[prop]; } } } return result; }; /** * Resets the time of this Date object to 12:00 AM (00:00), which is the start of the day. * @param {Boolean} .clone() this date instance before clearing Time * @return {Date} this */ $P.clearTime = function () { this.setHours(0); this.setMinutes(0); this.setSeconds(0); this.setMilliseconds(0); return this; }; /** * Resets the time of this Date object to the current time ('now'). * @return {Date} this */ $P.setTimeToNow = function () { var n = new Date(); this.setHours(n.getHours()); this.setMinutes(n.getMinutes()); this.setSeconds(n.getSeconds()); this.setMilliseconds(n.getMilliseconds()); return this; }; /** * Returns a new Date object that is an exact date and time copy of the original instance. * @return {Date} A new Date instance */ $P.clone = function () { return new Date(this.getTime()); }; /** * Compares this instance to a Date object and returns an number indication of their relative values. * @param {Date} Date object to compare [Required] * @return {Number} -1 = this is lessthan date. 0 = values are equal. 1 = this is greaterthan date. */ $P.compareTo = function (date) { return Date.compare(this, date); }; /** * Compares this instance to another Date object and returns true if they are equal. * @param {Date} Date object to compare. If no date to compare, new Date() [now] is used. * @return {Boolean} true if dates are equal. false if they are not equal. */ $P.equals = function (date) { return Date.equals(this, (date !== undefined ? date : new Date())); }; /** * Determines if this instance is between a range of two dates or equal to either the start or end dates. * @param {Date} Start of range [Required] * @param {Date} End of range [Required] * @return {Boolean} true is this is between or equal to the start and end dates, else false */ $P.between = function (start, end) { return this.getTime() >= start.getTime() && this.getTime() <= end.getTime(); }; /** * Determines if this date occurs after the date to compare to. * @param {Date} Date object to compare. If no date to compare, new Date() ("now") is used. * @return {Boolean} true if this date instance is greater than the date to compare to (or "now"), otherwise false. */ $P.isAfter = function (date) { return this.compareTo(date || new Date()) === 1; }; /** * Determines if this date occurs before the date to compare to. * @param {Date} Date object to compare. If no date to compare, new Date() ("now") is used. * @return {Boolean} true if this date instance is less than the date to compare to (or "now"). */ $P.isBefore = function (date) { return (this.compareTo(date || new Date()) === -1); }; /** * Determines if the current Date instance occurs today. * @return {Boolean} true if this date instance is 'today', otherwise false. */ /** * Determines if the current Date instance occurs on the same Date as the supplied 'date'. * If no 'date' to compare to is provided, the current Date instance is compared to 'today'. * @param {date} Date object to compare. If no date to compare, the current Date ("now") is used. * @return {Boolean} true if this Date instance occurs on the same Day as the supplied 'date'. */ $P.isToday = $P.isSameDay = function (date) { return this.clone().clearTime().equals((date || new Date()).clone().clearTime()); }; /** * Adds the specified number of milliseconds to this instance. * @param {Number} The number of milliseconds to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addMilliseconds = function (value) { if (!value) { return this; } this.setTime(this.getTime() + value * 1); return this; }; /** * Adds the specified number of seconds to this instance. * @param {Number} The number of seconds to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addSeconds = function (value) { if (!value) { return this; } return this.addMilliseconds(value * 1000); }; /** * Adds the specified number of seconds to this instance. * @param {Number} The number of seconds to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addMinutes = function (value) { if (!value) { return this; } return this.addMilliseconds(value * 60000); // 60*1000 }; /** * Adds the specified number of hours to this instance. * @param {Number} The number of hours to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addHours = function (value) { if (!value) { return this; } return this.addMilliseconds(value * 3600000); // 60*60*1000 }; /** * Adds the specified number of days to this instance. * @param {Number} The number of days to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addDays = function (value) { if (!value) { return this; } this.setDate(this.getDate() + value * 1); return this; }; /** * Adds the specified number of weekdays (ie - not sat or sun) to this instance. * @param {Number} The number of days to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addWeekdays = function (value) { if (!value) { return this; } var day = this.getDay(); var weeks = (Math.ceil(Math.abs(value)/7)); if (day === 0 || day === 6) { if (value > 0) { this.next().monday(); this.addDays(-1); day = this.getDay(); } } if (value < 0) { while (value < 0) { this.addDays(-1); day = this.getDay(); if (day !== 0 && day !== 6) { value++; } } return this; } else if (value > 5 || (6-day) <= value) { value = value + (weeks * 2); } return this.addDays(value); }; /** * Adds the specified number of weeks to this instance. * @param {Number} The number of weeks to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addWeeks = function (value) { if (!value) { return this; } return this.addDays(value * 7); }; /** * Adds the specified number of months to this instance. * @param {Number} The number of months to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addMonths = function (value) { if (!value) { return this; } var n = this.getDate(); this.setDate(1); this.setMonth(this.getMonth() + value * 1); this.setDate(Math.min(n, $D.getDaysInMonth(this.getFullYear(), this.getMonth()))); return this; }; $P.addQuarters = function (value) { if (!value) { return this; } // note this will take you to the same point in the quarter as you are now. // i.e. - if you are 15 days into the quarter you'll be 15 days into the resulting one. // bonus: this allows adding fractional quarters return this.addMonths(value * 3); }; /** * Adds the specified number of years to this instance. * @param {Number} The number of years to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addYears = function (value) { if (!value) { return this; } return this.addMonths(value * 12); }; /** * Adds (or subtracts) to the value of the years, months, weeks, days, hours, minutes, seconds, milliseconds of the date instance using given configuration object. Positive and Negative values allowed. * Example

	Date.today().add( { days: 1, months: 1 } )

	new Date().add( { years: -1 } )
	
* @param {Object} Configuration object containing attributes (months, days, etc.) * @return {Date} this */ $P.add = function (config) { if (typeof config === "number") { this._orient = config; return this; } var x = config; if (x.day) { // If we should be a different date than today (eg: for 'tomorrow -1d', etc). // Should only effect parsing, not direct usage (eg, Finish and FinishExact) if ((x.day - this.getDate()) !== 0) { this.setDate(x.day); } } if (x.milliseconds) { this.addMilliseconds(x.milliseconds); } if (x.seconds) { this.addSeconds(x.seconds); } if (x.minutes) { this.addMinutes(x.minutes); } if (x.hours) { this.addHours(x.hours); } if (x.weeks) { this.addWeeks(x.weeks); } if (x.months) { this.addMonths(x.months); } if (x.years) { this.addYears(x.years); } if (x.days) { this.addDays(x.days); } return this; }; /** * Get the week number. Week one (1) is the week which contains the first Thursday of the year. Monday is considered the first day of the week. * The .getWeek() function does NOT convert the date to UTC. The local datetime is used. * Please use .getISOWeek() to get the week of the UTC converted date. * @return {Number} 1 to 53 */ $P.getWeek = function (utc) { // Create a copy of this date object var self, target = new Date(this.valueOf()); if (utc) { target.addMinutes(target.getTimezoneOffset()); self = target.clone(); } else { self = this; } // ISO week date weeks start on monday // so correct the day number var dayNr = (self.getDay() + 6) % 7; // ISO 8601 states that week 1 is the week // with the first thursday of that year. // Set the target date to the thursday in the target week target.setDate(target.getDate() - dayNr + 3); // Store the millisecond value of the target date var firstThursday = target.valueOf(); // Set the target to the first thursday of the year // First set the target to january first target.setMonth(0, 1); // Not a thursday? Correct the date to the next thursday if (target.getDay() !== 4) { target.setMonth(0, 1 + ((4 - target.getDay()) + 7) % 7); } // The weeknumber is the number of weeks between the // first thursday of the year and the thursday in the target week return 1 + Math.ceil((firstThursday - target) / 604800000); // 604800000 = 7 * 24 * 3600 * 1000 }; /** * Get the ISO 8601 week number. Week one ("01") is the week which contains the first Thursday of the year. Monday is considered the first day of the week. * The .getISOWeek() function does convert the date to it's UTC value. Please use .getWeek() to get the week of the local date. * @return {String} "01" to "53" */ $P.getISOWeek = function () { return p(this.getWeek(true)); }; /** * Moves the date to Monday of the week set. Week one (1) is the week which contains the first Thursday of the year. * @param {Number} A Number (1 to 53) that represents the week of the year. * @return {Date} this */ $P.setWeek = function (n) { if ((n - this.getWeek()) === 0) { if (this.getDay() !== 1) { return this.moveToDayOfWeek(1, (this.getDay() > 1 ? -1 : 1)); } else { return this; } } else { return this.moveToDayOfWeek(1, (this.getDay() > 1 ? -1 : 1)).addWeeks(n - this.getWeek()); } }; $P.setQuarter = function (qtr) { var month = Math.abs(((qtr-1) * 3) + 1); return this.setMonth(month, 1); }; $P.getQuarter = function () { return Date.getQuarter(this); }; $P.getDaysLeftInQuarter = function () { return Date.getDaysLeftInQuarter(this); }; /** * Moves the date to the next n'th occurrence of the dayOfWeek starting from the beginning of the month. The number (-1) is a magic number and will return the last occurrence of the dayOfWeek in the month. * @param {Number} The dayOfWeek to move to * @param {Number} The n'th occurrence to move to. Use (-1) to return the last occurrence in the month * @return {Date} this */ $P.moveToNthOccurrence = function (dayOfWeek, occurrence) { if (dayOfWeek === "Weekday") { if (occurrence > 0) { this.moveToFirstDayOfMonth(); if (this.is().weekday()) { occurrence -= 1; } } else if (occurrence < 0) { this.moveToLastDayOfMonth(); if (this.is().weekday()) { occurrence += 1; } } else { return this; } return this.addWeekdays(occurrence); } var shift = 0; if (occurrence > 0) { shift = occurrence - 1; } else if (occurrence === -1) { this.moveToLastDayOfMonth(); if (this.getDay() !== dayOfWeek) { this.moveToDayOfWeek(dayOfWeek, -1); } return this; } return this.moveToFirstDayOfMonth().addDays(-1).moveToDayOfWeek(dayOfWeek, +1).addWeeks(shift); }; var moveToN = function (getFunc, addFunc, nVal) { return function (value, orient) { var diff = (value - this[getFunc]() + nVal * (orient || +1)) % nVal; return this[addFunc]((diff === 0) ? diff += nVal * (orient || +1) : diff); }; }; /** * Move to the next or last dayOfWeek based on the orient value. * @param {Number} The dayOfWeek to move to * @param {Number} Forward (+1) or Back (-1). Defaults to +1. [Optional] * @return {Date} this */ $P.moveToDayOfWeek = moveToN("getDay", "addDays", 7); /** * Move to the next or last month based on the orient value. * @param {Number} The month to move to. 0 = January, 11 = December * @param {Number} Forward (+1) or Back (-1). Defaults to +1. [Optional] * @return {Date} this */ $P.moveToMonth = moveToN("getMonth", "addMonths", 12); /** * Get the Ordinate of the current day ("th", "st", "rd"). * @return {String} */ $P.getOrdinate = function () { var num = this.getDate(); return ord(num); }; /** * Get the Ordinal day (numeric day number) of the year, adjusted for leap year. * @return {Number} 1 through 365 (366 in leap years) */ $P.getOrdinalNumber = function () { return Math.ceil((this.clone().clearTime() - new Date(this.getFullYear(), 0, 1)) / 86400000) + 1; }; /** * Get the time zone abbreviation of the current date. * @return {String} The abbreviated time zone name (e.g. "EST") */ $P.getTimezone = function () { return $D.getTimezoneAbbreviation(this.getUTCOffset(), this.isDaylightSavingTime()); }; $P.setTimezoneOffset = function (offset) { var here = this.getTimezoneOffset(), there = Number(offset) * -6 / 10; return (there || there === 0) ? this.addMinutes(there - here) : this; }; $P.setTimezone = function (offset) { return this.setTimezoneOffset($D.getTimezoneOffset(offset)); }; /** * Indicates whether Daylight Saving Time is observed in the current time zone. * @return {Boolean} true|false */ $P.hasDaylightSavingTime = function () { return (Date.today().set({month: 0, day: 1}).getTimezoneOffset() !== Date.today().set({month: 6, day: 1}).getTimezoneOffset()); }; /** * Indicates whether this Date instance is within the Daylight Saving Time range for the current time zone. * @return {Boolean} true|false */ $P.isDaylightSavingTime = function () { return Date.today().set({month: 0, day: 1}).getTimezoneOffset() !== this.getTimezoneOffset(); }; /** * Get the offset from UTC of the current date. * @return {String} The 4-character offset string prefixed with + or - (e.g. "-0500") */ $P.getUTCOffset = function (offset) { var n = (offset || this.getTimezoneOffset()) * -10 / 6, r; if (n < 0) { r = (n - 10000).toString(); return r.charAt(0) + r.substr(2); } else { r = (n + 10000).toString(); return "+" + r.substr(1); } }; /** * Returns the number of milliseconds between this date and date. * @param {Date} Defaults to now * @return {Number} The diff in milliseconds */ $P.getElapsed = function (date) { return (date || new Date()) - this; }; /** * Set the value of year, month, day, hour, minute, second, millisecond of date instance using given configuration object. * Example

	Date.today().set( { day: 20, month: 1 } )

	new Date().set( { millisecond: 0 } )
	
* * @param {Object} Configuration object containing attributes (month, day, etc.) * @return {Date} this */ $P.set = function (config) { config = validateConfigObject.call(this, config); var key; for (key in config) { if (Object.prototype.hasOwnProperty.call(config, key)) { var name = key.charAt(0).toUpperCase() + key.slice(1); var addFunc, getFunc; if (key !== "week" && key !== "month" && key !== "timezone" && key !== "timezoneOffset") { name += "s"; } addFunc = "add" + name; getFunc = "get" + name; if (key === "month") { addFunc = addFunc + "s"; } else if (key === "year"){ getFunc = "getFullYear"; } if (key !== "day" && key !== "timezone" && key !== "timezoneOffset" && key !== "week" && key !== "hour") { this[addFunc](config[key] - this[getFunc]()); } else if ( key === "timezone"|| key === "timezoneOffset" || key === "week" || key === "hour") { this["set"+name](config[key]); } } } // day has to go last because you can't validate the day without first knowing the month if (config.day) { this.addDays(config.day - this.getDate()); } return this; }; /** * Moves the date to the first day of the month. * @return {Date} this */ $P.moveToFirstDayOfMonth = function () { return this.set({ day: 1 }); }; /** * Moves the date to the last day of the month. * @return {Date} this */ $P.moveToLastDayOfMonth = function () { return this.set({ day: $D.getDaysInMonth(this.getFullYear(), this.getMonth())}); }; /** * Converts the value of the current Date object to its equivalent string representation. * Format Specifiers * CUSTOM DATE AND TIME FORMAT STRINGS * Format Description Example * ------ --------------------------------------------------------------------------- ----------------------- * s The seconds of the minute between 0-59. "0" to "59" * ss The seconds of the minute with leading zero if required. "00" to "59" * * m The minute of the hour between 0-59. "0" or "59" * mm The minute of the hour with leading zero if required. "00" or "59" * * h The hour of the day between 1-12. "1" to "12" * hh The hour of the day with leading zero if required. "01" to "12" * * H The hour of the day between 0-23. "0" to "23" * HH The hour of the day with leading zero if required. "00" to "23" * * d The day of the month between 1 and 31. "1" to "31" * dd The day of the month with leading zero if required. "01" to "31" * ddd Abbreviated day name. Date.CultureInfo.abbreviatedDayNames. "Mon" to "Sun" * dddd The full day name. Date.CultureInfo.dayNames. "Monday" to "Sunday" * * M The month of the year between 1-12. "1" to "12" * MM The month of the year with leading zero if required. "01" to "12" * MMM Abbreviated month name. Date.CultureInfo.abbreviatedMonthNames. "Jan" to "Dec" * MMMM The full month name. Date.CultureInfo.monthNames. "January" to "December" * * yy The year as a two-digit number. "99" or "08" * yyyy The full four digit year. "1999" or "2008" * * t Displays the first character of the A.M./P.M. designator. "A" or "P" * Date.CultureInfo.amDesignator or Date.CultureInfo.pmDesignator * tt Displays the A.M./P.M. designator. "AM" or "PM" * Date.CultureInfo.amDesignator or Date.CultureInfo.pmDesignator * * S The ordinal suffix ("st, "nd", "rd" or "th") of the current day. "st, "nd", "rd" or "th" * * STANDARD DATE AND TIME FORMAT STRINGS * Format Description Example *------ --------------------------------------------------------------------------- ----------------------- * d The CultureInfo shortDate Format Pattern "M/d/yyyy" * D The CultureInfo longDate Format Pattern "dddd, MMMM dd, yyyy" * F The CultureInfo fullDateTime Format Pattern "dddd, MMMM dd, yyyy h:mm:ss tt" * m The CultureInfo monthDay Format Pattern "MMMM dd" * r The CultureInfo rfc1123 Format Pattern "ddd, dd MMM yyyy HH:mm:ss GMT" * s The CultureInfo sortableDateTime Format Pattern "yyyy-MM-ddTHH:mm:ss" * t The CultureInfo shortTime Format Pattern "h:mm tt" * T The CultureInfo longTime Format Pattern "h:mm:ss tt" * u The CultureInfo universalSortableDateTime Format Pattern "yyyy-MM-dd HH:mm:ssZ" * y The CultureInfo yearMonth Format Pattern "MMMM, yyyy" * * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @return {String} A string representation of the current Date object. */ var ord = function (n) { switch (n * 1) { case 1: case 21: case 31: return "st"; case 2: case 22: return "nd"; case 3: case 23: return "rd"; default: return "th"; } }; var parseStandardFormats = function (format) { var y, c = Date.CultureInfo.formatPatterns; switch (format) { case "d": return this.toString(c.shortDate); case "D": return this.toString(c.longDate); case "F": return this.toString(c.fullDateTime); case "m": return this.toString(c.monthDay); case "r": case "R": y = this.clone().addMinutes(this.getTimezoneOffset()); return y.toString(c.rfc1123) + " GMT"; case "s": return this.toString(c.sortableDateTime); case "t": return this.toString(c.shortTime); case "T": return this.toString(c.longTime); case "u": y = this.clone().addMinutes(this.getTimezoneOffset()); return y.toString(c.universalSortableDateTime); case "y": return this.toString(c.yearMonth); default: return false; } }; var parseFormatStringsClosure = function (context) { return function (m) { if (m.charAt(0) === "\\") { return m.replace("\\", ""); } switch (m) { case "hh": return p(context.getHours() < 13 ? (context.getHours() === 0 ? 12 : context.getHours()) : (context.getHours() - 12)); case "h": return context.getHours() < 13 ? (context.getHours() === 0 ? 12 : context.getHours()) : (context.getHours() - 12); case "HH": return p(context.getHours()); case "H": return context.getHours(); case "mm": return p(context.getMinutes()); case "m": return context.getMinutes(); case "ss": return p(context.getSeconds()); case "s": return context.getSeconds(); case "yyyy": return p(context.getFullYear(), 4); case "yy": return p(context.getFullYear()); case "y": return context.getFullYear(); case "E": case "dddd": return Date.CultureInfo.dayNames[context.getDay()]; case "ddd": return Date.CultureInfo.abbreviatedDayNames[context.getDay()]; case "dd": return p(context.getDate()); case "d": return context.getDate(); case "MMMM": return Date.CultureInfo.monthNames[context.getMonth()]; case "MMM": return Date.CultureInfo.abbreviatedMonthNames[context.getMonth()]; case "MM": return p((context.getMonth() + 1)); case "M": return context.getMonth() + 1; case "t": return context.getHours() < 12 ? Date.CultureInfo.amDesignator.substring(0, 1) : Date.CultureInfo.pmDesignator.substring(0, 1); case "tt": return context.getHours() < 12 ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator; case "S": return ord(context.getDate()); case "W": return context.getWeek(); case "WW": return context.getISOWeek(); case "Q": return "Q" + context.getQuarter(); case "q": return String(context.getQuarter()); case "z": return context.getTimezone(); case "Z": case "X": return Date.getTimezoneOffset(context.getTimezone()); case "ZZ": // Timezone offset in seconds return context.getTimezoneOffset() * -60; case "u": return context.getDay(); case "L": return ($D.isLeapYear(context.getFullYear())) ? 1 : 0; case "B": // Swatch Internet Time (.beats) return "@"+((context.getUTCSeconds() + (context.getUTCMinutes()*60) + ((context.getUTCHours()+1)*3600))/86.4); default: return m; } }; }; $P.toString = function (format, ignoreStandards) { // Standard Date and Time Format Strings. Formats pulled from CultureInfo file and // may vary by culture. if (!ignoreStandards && format && format.length === 1) { output = parseStandardFormats.call(this, format); if (output) { return output; } } var parseFormatStrings = parseFormatStringsClosure(this); return format ? format.replace(/((\\)?(dd?d?d?|MM?M?M?|yy?y?y?|hh?|HH?|mm?|ss?|tt?|S|q|Q|WW?W?W?)(?![^\[]*\]))/g, parseFormatStrings).replace(/\[|\]/g, "") : this._toString(); }; }()); /************************************************************* * SugarPak - Domain Specific Language - Syntactical Sugar * *************************************************************/ (function () { var $D = Date, $P = $D.prototype, $N = Number.prototype; // private $P._orient = +1; // private $P._nth = null; // private $P._is = false; // private $P._same = false; // private $P._isSecond = false; // private $N._dateElement = "days"; /** * Moves the date to the next instance of a date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.today().next().friday();
	Date.today().next().fri();
	Date.today().next().march();
	Date.today().next().mar();
	Date.today().next().week();
	
* * @return {Date} date */ $P.next = function () { this._move = true; this._orient = +1; return this; }; /** * Creates a new Date (Date.today()) and moves the date to the next instance of the date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.next().friday();
	Date.next().fri();
	Date.next().march();
	Date.next().mar();
	Date.next().week();
	
* * @return {Date} date */ $D.next = function () { return $D.today().next(); }; /** * Moves the date to the previous instance of a date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.today().last().friday();
	Date.today().last().fri();
	Date.today().last().march();
	Date.today().last().mar();
	Date.today().last().week();
	
* * @return {Date} date */ $P.last = $P.prev = $P.previous = function () { this._move = true; this._orient = -1; return this; }; /** * Creates a new Date (Date.today()) and moves the date to the previous instance of the date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.last().friday();
	Date.last().fri();
	Date.previous().march();
	Date.prev().mar();
	Date.last().week();
	
* * @return {Date} date */ $D.last = $D.prev = $D.previous = function () { return $D.today().last(); }; /** * Performs a equality check when followed by either a month name, day name or .weekday() function. * Example

	Date.today().is().friday(); // true|false
	Date.today().is().fri();
	Date.today().is().march();
	Date.today().is().mar();
	
* * @return {Boolean} true|false */ $P.is = function () { this._is = true; return this; }; /** * Determines if two date objects occur on/in exactly the same instance of the subsequent date part function. * The function .same() must be followed by a date part function (example: .day(), .month(), .year(), etc). * * An optional Date can be passed in the date part function. If now date is passed as a parameter, 'Now' is used. * * The following example demonstrates how to determine if two dates fall on the exact same day. * * Example

	var d1 = Date.today(); // today at 00:00
	var d2 = new Date();   // exactly now.

	// Do they occur on the same day?
	d1.same().day(d2); // true
	
	// Do they occur on the same hour?
	d1.same().hour(d2); // false, unless d2 hour is '00' (midnight).
	
	// What if it's the same day, but one year apart?
	var nextYear = Date.today().add(1).year();

	d1.same().day(nextYear); // false, because the dates must occur on the exact same day. 
	
* * Scenario: Determine if a given date occurs during some week period 2 months from now. * * Example

	var future = Date.today().add(2).months();
	return someDate.same().week(future); // true|false;
	
* * @return {Boolean} true|false */ $P.same = function () { this._same = true; this._isSecond = false; return this; }; /** * Determines if the current date/time occurs during Today. Must be preceded by the .is() function. * Example

	someDate.is().today();    // true|false
	new Date().is().today();  // true
	Date.today().is().today();// true
	Date.today().add(-1).day().is().today(); // false
	
* * @return {Boolean} true|false */ $P.today = function () { return this.same().day(); }; /** * Determines if the current date is a weekday. This function must be preceded by the .is() function. * Example

	Date.today().is().weekday(); // true|false
	
* * @return {Boolean} true|false */ $P.weekday = function () { if (this._nth) { return df("Weekday").call(this); } if (this._move) { return this.addWeekdays(this._orient); } if (this._is) { this._is = false; return (!this.is().sat() && !this.is().sun()); } return false; }; /** * Determines if the current date is on the weekend. This function must be preceded by the .is() function. * Example

	Date.today().is().weekend(); // true|false
	
* * @return {Boolean} true|false */ $P.weekend = function () { if (this._is) { this._is = false; return (this.is().sat() || this.is().sun()); } return false; }; /** * Sets the Time of the current Date instance. A string "6:15 pm" or config object {hour:18, minute:15} are accepted. * Example

	// Set time to 6:15pm with a String
	Date.today().at("6:15pm");

	// Set time to 6:15pm with a config object
	Date.today().at({hour:18, minute:15});
	
* * @return {Date} date */ $P.at = function (time) { return (typeof time === "string") ? $D.parse(this.toString("d") + " " + time) : this.set(time); }; /** * Creates a new Date() and adds this (Number) to the date based on the preceding date element function (eg. second|minute|hour|day|month|year). * Example

	// Undeclared Numbers must be wrapped with parentheses. Requirment of JavaScript.
	(3).days().fromNow();
	(6).months().fromNow();

	// Declared Number variables do not require parentheses. 
	var n = 6;
	n.months().fromNow();
	
* * @return {Date} A new Date instance */ $N.fromNow = $N.after = function (date) { var c = {}; c[this._dateElement] = this; return ((!date) ? new Date() : date.clone()).add(c); }; /** * Creates a new Date() and subtract this (Number) from the date based on the preceding date element function (eg. second|minute|hour|day|month|year). * Example

	// Undeclared Numbers must be wrapped with parentheses. Requirment of JavaScript.
	(3).days().ago();
	(6).months().ago();

	// Declared Number variables do not require parentheses. 
	var n = 6;
	n.months().ago();
	
* * @return {Date} A new Date instance */ $N.ago = $N.before = function (date) { var c = {}, s = (this._dateElement[this._dateElement.length-1] !== "s") ? this._dateElement + "s" : this._dateElement; c[s] = this * -1; return ((!date) ? new Date() : date.clone()).add(c); }; // Do NOT modify the following string tokens. These tokens are used to build dynamic functions. // All culture-specific strings can be found in the CultureInfo files. var dx = ("sunday monday tuesday wednesday thursday friday saturday").split(/\s/), mx = ("january february march april may june july august september october november december").split(/\s/), px = ("Millisecond Second Minute Hour Day Week Month Year Quarter Weekday").split(/\s/), pxf = ("Milliseconds Seconds Minutes Hours Date Week Month FullYear Quarter").split(/\s/), nth = ("final first second third fourth fifth").split(/\s/), de; /** * Returns an object literal of all the date parts. * Example

	var o = new Date().toObject();
	
	// { year: 2008, month: 4, week: 20, day: 13, hour: 18, minute: 9, second: 32, millisecond: 812 }
	
	// The object properties can be referenced directly from the object.
	
	alert(o.day);  // alerts "13"
	alert(o.year); // alerts "2008"
	
* * @return {Date} An object literal representing the original date object. */ $P.toObject = function () { var o = {}; for (var i = 0; i < px.length; i++) { if (this["get" + pxf[i]]) { o[px[i].toLowerCase()] = this["get" + pxf[i]](); } } return o; }; /** * Returns a date created from an object literal. Ignores the .week property if set in the config. * Example

	var o = new Date().toObject();
	
	return Date.fromObject(o); // will return the same date. 

	var o2 = {month: 1, day: 20, hour: 18}; // birthday party!
	Date.fromObject(o2);
	
* * @return {Date} An object literal representing the original date object. */ $D.fromObject = function(config) { config.week = null; return Date.today().set(config); }; // Create day name functions and abbreviated day name functions (eg. monday(), friday(), fri()). var df = function (n) { return function () { if (this._is) { this._is = false; return this.getDay() === n; } if (this._move) { this._move = null; } if (this._nth !== null) { // If the .second() function was called earlier, remove the _orient // from the date, and then continue. // This is required because 'second' can be used in two different context. // // Example // // Date.today().add(1).second(); // Date.march().second().monday(); // // Things get crazy with the following... // Date.march().add(1).second().second().monday(); // but it works!! // if (this._isSecond) { this.addSeconds(this._orient * -1); } // make sure we reset _isSecond this._isSecond = false; var ntemp = this._nth; this._nth = null; var temp = this.clone().moveToLastDayOfMonth(); this.moveToNthOccurrence(n, ntemp); if (this > temp) { throw new RangeError($D.getDayName(n) + " does not occur " + ntemp + " times in the month of " + $D.getMonthName(temp.getMonth()) + " " + temp.getFullYear() + "."); } return this; } return this.moveToDayOfWeek(n, this._orient); }; }; var sdf = function (n) { return function () { var t = $D.today(), shift = n - t.getDay(); if (n === 0 && Date.CultureInfo.firstDayOfWeek === 1 && t.getDay() !== 0) { shift = shift + 7; } return t.addDays(shift); }; }; // Create month name functions and abbreviated month name functions (eg. january(), march(), mar()). var month_instance_functions = function (n) { return function () { if (this._is) { this._is = false; return this.getMonth() === n; } return this.moveToMonth(n, this._orient); }; }; var month_static_functions = function (n) { return function () { return $D.today().set({ month: n, day: 1 }); }; }; var processTerms = function (names, staticFunc, instanceFunc) { for (var i = 0; i < names.length; i++) { // Create constant static Name variables. $D[names[i].toUpperCase()] = $D[names[i].toUpperCase().substring(0, 3)] = i; // Create Name functions. $D[names[i]] = $D[names[i].substring(0, 3)] = staticFunc(i); // Create Name instance functions. $P[names[i]] = $P[names[i].substring(0, 3)] = instanceFunc(i); } }; processTerms(dx, sdf, df); processTerms(mx, month_static_functions, month_instance_functions); // Create date element functions and plural date element functions used with Date (eg. day(), days(), months()). var ef = function (j) { return function () { // if the .second() function was called earlier, the _orient // has alread been added. Just return this and reset _isSecond. if (this._isSecond) { this._isSecond = false; return this; } if (this._same) { this._same = this._is = false; var o1 = this.toObject(), o2 = (arguments[0] || new Date()).toObject(), v = "", k = j.toLowerCase(); // the substr trick with -1 doesn't work in IE8 or less k = (k[k.length-1] === "s") ? k.substring(0,k.length-1) : k; for (var m = (px.length - 1); m > -1; m--) { v = px[m].toLowerCase(); if (o1[v] !== o2[v]) { return false; } if (k === v) { break; } } return true; } if (j.substring(j.length - 1) !== "s") { j += "s"; } if (this._move) { this._move = null; } return this["add" + j](this._orient); }; }; var nf = function (n) { return function () { this._dateElement = n; return this; }; }; for (var k = 0; k < px.length; k++) { de = px[k].toLowerCase(); if(de !== "weekday") { // Create date element functions and plural date element functions used with Date (eg. day(), days(), months()). $P[de] = $P[de + "s"] = ef(px[k]); // Create date element functions and plural date element functions used with Number (eg. day(), days(), months()). $N[de] = $N[de + "s"] = nf(de + "s"); } } $P._ss = ef("Second"); var nthfn = function (n) { return function (dayOfWeek) { if (this._same) { return this._ss(arguments[0]); } if (dayOfWeek || dayOfWeek === 0) { return this.moveToNthOccurrence(dayOfWeek, n); } this._nth = n; // if the operator is 'second' add the _orient, then deal with it later... if (n === 2 && (dayOfWeek === undefined || dayOfWeek === null)) { this._isSecond = true; return this.addSeconds(this._orient); } return this; }; }; for (var l = 0; l < nth.length; l++) { $P[nth[l]] = (l === 0) ? nthfn(-1) : nthfn(l); } }()); (function () { "use strict"; Date.Parsing = { Exception: function (s) { this.message = "Parse error at '" + s.substring(0, 10) + " ...'"; } }; var $P = Date.Parsing; var dayOffsets = { standard: [0,31,59,90,120,151,181,212,243,273,304,334], leap: [0,31,60,91,121,152,182,213,244,274,305,335] }; $P.isLeapYear = function(year) { return ((year % 4 === 0) && (year % 100 !== 0)) || (year % 400 === 0); }; var utils = { multiReplace : function (str, hash ) { var key; for (key in hash) { if (Object.prototype.hasOwnProperty.call(hash, key)) { var regex; if (typeof hash[key] === "function") { } else { regex = (hash[key] instanceof RegExp) ? hash[key] : new RegExp(hash[key], "g"); } str = str.replace(regex, key); } } return str; }, getDayOfYearFromWeek : function (obj) { var d, jan4, offset; obj.weekDay = (!obj.weekDay && obj.weekDay !== 0) ? 1 : obj.weekDay; d = new Date(obj.year, 0, 4); jan4 = d.getDay() === 0 ? 7 : d.getDay(); // JS is 0 indexed on Sunday. offset = jan4+3; obj.dayOfYear = ((obj.week * 7) + (obj.weekDay === 0 ? 7 : obj.weekDay))-offset; return obj; }, getDayOfYear : function (obj, dayOffset) { if (!obj.dayOfYear) { obj = utils.getDayOfYearFromWeek(obj); } for (var i=0;i <= dayOffset.length;i++) { if (obj.dayOfYear < dayOffset[i] || i === dayOffset.length) { obj.day = obj.day ? obj.day : (obj.dayOfYear - dayOffset[i-1]); break; } else { obj.month = i; } } return obj; }, adjustForTimeZone : function (obj, date) { var offset; if (obj.zone.toUpperCase() === "Z" || (obj.zone_hours === 0 && obj.zone_minutes === 0)) { // it's UTC/GML so work out the current timeszone offset offset = -date.getTimezoneOffset(); } else { offset = (obj.zone_hours*60) + (obj.zone_minutes || 0); if (obj.zone_sign === "+") { offset *= -1; } offset -= date.getTimezoneOffset(); } date.setMinutes(date.getMinutes()+offset); return date; }, setDefaults : function (obj) { obj.year = obj.year || Date.today().getFullYear(); obj.hours = obj.hours || 0; obj.minutes = obj.minutes || 0; obj.seconds = obj.seconds || 0; obj.milliseconds = obj.milliseconds || 0; if (!(!obj.month && (obj.week || obj.dayOfYear))) { // if we have a month, or if we don't but don't have the day calculation data obj.month = obj.month || 0; obj.day = obj.day || 1; } return obj; }, dataNum: function (data, mod, explict, postProcess) { var dataNum = data*1; if (mod) { if (postProcess) { return data ? mod(data)*1 : data; } else { return data ? mod(dataNum) : data; } } else if (!explict){ return data ? dataNum : data; } else { return (data && typeof data !== "undefined") ? dataNum : data; } }, timeDataProcess: function (obj) { var timeObj = {}; for (var x in obj.data) { if (obj.data.hasOwnProperty(x)) { timeObj[x] = obj.ignore[x] ? obj.data[x] : utils.dataNum(obj.data[x], obj.mods[x], obj.explict[x], obj.postProcess[x]); } } if (obj.data.secmins) { obj.data.secmins = obj.data.secmins.replace(",", ".") * 60; if (!timeObj.minutes) { timeObj.minutes = obj.data.secmins; } else if (!timeObj.seconds) { timeObj.seconds = obj.data.secmins; } delete obj.secmins; } return timeObj; }, buildTimeObjectFromData: function (data) { var time = utils.timeDataProcess({ data: { year : data[1], month : data[5], day : data[7], week : data[8], dayOfYear : data[10], hours : data[15], zone_hours : data[23], zone_minutes : data[24], zone : data[21], zone_sign : data[22], weekDay : data[9], minutes: data[16], seconds: data[19], milliseconds: data[20], secmins: data[18] }, mods: { month: function(data) { return data-1; }, weekDay: function (data) { data = Math.abs(data); return (data === 7 ? 0 : data); }, minutes: function (data) { return data.replace(":",""); }, seconds: function (data) { return Math.floor( (data.replace(":","").replace(",","."))*1 ); }, milliseconds: function (data) { return (data.replace(",",".")*1000); } }, postProcess: { minutes: true, seconds: true, milliseconds: true }, explict: { zone_hours: true, zone_minutes: true }, ignore: { zone: true, zone_sign: true, secmins: true } }); return time; }, addToHash: function (hash, keys, data) { keys = keys; data = data; var len = keys.length; for (var i = 0; i < len; i++) { hash[keys[i]] = data[i]; } return hash; }, combineRegex: function (r1, r2) { return new RegExp("(("+r1.source+")\\s("+r2.source+"))"); }, getDateNthString: function(add, last, inc){ if (add) { return Date.today().addDays(inc).toString("d"); } else if (last) { return Date.today().last()[inc]().toString("d"); } }, buildRegexData: function (array) { var arr = []; var len = array.length; for (var i=0; i < len; i++) { if (Object.prototype.toString.call(array[i]) === '[object Array]') { // oldIE compat version of Array.isArray arr.push(this.combineRegex(array[i][0], array[i][1])); } else { arr.push(array[i]); } } return arr; } }; $P.processTimeObject = function (obj) { var date, dayOffset; utils.setDefaults(obj); dayOffset = ($P.isLeapYear(obj.year)) ? dayOffsets.leap : dayOffsets.standard; if (!obj.month && (obj.week || obj.dayOfYear)) { utils.getDayOfYear(obj, dayOffset); } else { obj.dayOfYear = dayOffset[obj.month] + obj.day; } date = new Date(obj.year, obj.month, obj.day, obj.hours, obj.minutes, obj.seconds, obj.milliseconds); if (obj.zone) { utils.adjustForTimeZone(obj, date); // adjust (and calculate) for timezone } return date; }; $P.ISO = { regex : /^([\+-]?\d{4}(?!\d{2}\b))((-?)((0[1-9]|1[0-2])(\3([12]\d|0[1-9]|3[01]))?|W([0-4]\d|5[0-3])(-?[1-7])?|(00[1-9]|0[1-9]\d|[12]\d{2}|3([0-5]\d|6[1-6])))([T\s]((([01]\d|2[0-4])((:?)[0-5]\d)?|24\:?00)([\.,]\d+(?!:))?)?(\17[0-5]\d([\.,]\d+)?)?\s?([zZ]|([\+-])([01]\d|2[0-3]):?([0-5]\d)?)?)?)?$/, parse : function (s) { var time, data = s.match(this.regex); if (!data || !data.length) { return null; } time = utils.buildTimeObjectFromData(data); if (!time.year || (!time.year && (!time.month && !time.day) && (!time.week && !time.dayOfYear)) ) { return null; } return $P.processTimeObject(time); } }; $P.Numeric = { isNumeric: function (e){return!isNaN(parseFloat(e))&&isFinite(e);}, regex: /\b([0-1]?[0-9])([0-3]?[0-9])([0-2]?[0-9]?[0-9][0-9])\b/i, parse: function (s) { var data, i, time = {}, order = Date.CultureInfo.dateElementOrder.split(""); if (!(this.isNumeric(s)) || // if it's non-numeric OR (s[0] === "+" && s[0] === "-")) { // It's an arithmatic string (eg +/-1000) return null; } if (s.length < 5 && s.indexOf(".") < 0 && s.indexOf("/") < 0) { // assume it's just a year. time.year = s; return $P.processTimeObject(time); } data = s.match(this.regex); if (!data || !data.length) { return null; } for (i=0; i < order.length; i++) { switch(order[i]) { case "d": time.day = data[i+1]; break; case "m": time.month = (data[i+1]-1); break; case "y": time.year = data[i+1]; break; } } return $P.processTimeObject(time); } }; $P.Normalizer = { regexData: function () { var $R = Date.CultureInfo.regexPatterns; return utils.buildRegexData([ $R.tomorrow, $R.yesterday, [$R.past, $R.mon], [$R.past, $R.tue], [$R.past, $R.wed], [$R.past, $R.thu], [$R.past, $R.fri], [$R.past, $R.sat], [$R.past, $R.sun] ]); }, basicReplaceHash : function() { var $R = Date.CultureInfo.regexPatterns; return { "January": $R.jan.source, "February": $R.feb, "March": $R.mar, "April": $R.apr, "May": $R.may, "June": $R.jun, "July": $R.jul, "August": $R.aug, "September": $R.sep, "October": $R.oct, "November": $R.nov, "December": $R.dec, "": /\bat\b/gi, " ": /\s{2,}/, "am": $R.inTheMorning, "9am": $R.thisMorning, "pm": $R.inTheEvening, "7pm":$R.thisEvening }; }, keys : function(){ return [ utils.getDateNthString(true, false, 1), // tomorrow utils.getDateNthString(true, false, -1), // yesterday utils.getDateNthString(false, true, "monday"), //last mon utils.getDateNthString(false, true, "tuesday"), //last tues utils.getDateNthString(false, true, "wednesday"), //last wed utils.getDateNthString(false, true, "thursday"), //last thurs utils.getDateNthString(false, true, "friday"), //last fri utils.getDateNthString(false, true, "saturday"), //last sat utils.getDateNthString(false, true, "sunday") //last sun ]; }, buildRegexFunctions: function () { var $R = Date.CultureInfo.regexPatterns; var __ = Date.i18n.__; var tomorrowRE = new RegExp("(\\b\\d\\d?("+__("AM")+"|"+__("PM")+")? )("+$R.tomorrow.source.slice(1)+")", "i"); // adapted tomorrow regex for AM PM relative dates var todayRE = new RegExp($R.today.source + "(?!\\s*([+-]))\\b"); // today, but excludes the math operators (eg "today + 2h") this.replaceFuncs = [ [todayRE, function (full) { return (full.length > 1) ? Date.today().toString("d") : full; }], [tomorrowRE, function(full, m1) { var t = Date.today().addDays(1).toString("d"); return (t + " " + m1); }], [$R.amThisMorning, function(str, am){return am;}], [$R.pmThisEvening, function(str, pm){return pm;}] ]; }, buildReplaceData: function () { this.buildRegexFunctions(); this.replaceHash = utils.addToHash(this.basicReplaceHash(), this.keys(), this.regexData()); }, stringReplaceFuncs: function (s) { for (var i=0; i < this.replaceFuncs.length; i++) { s = s.replace(this.replaceFuncs[i][0], this.replaceFuncs[i][1]); } return s; }, parse: function (s) { s = this.stringReplaceFuncs(s); s = utils.multiReplace(s, this.replaceHash); try { var n = s.split(/([\s\-\.\,\/\x27]+)/); if (n.length === 3 && $P.Numeric.isNumeric(n[0]) && $P.Numeric.isNumeric(n[2]) && (n[2].length >= 4)) { // ok, so we're dealing with x/year. But that's not a full date. // This fixes wonky dateElementOrder parsing when set to dmy order. if (Date.CultureInfo.dateElementOrder[0] === "d") { s = "1/" + n[0] + "/" + n[2]; // set to 1st of month and normalize the seperator } } } catch (e) {} return s; } }; $P.Normalizer.buildReplaceData(); }()); (function () { var $P = Date.Parsing; var _ = $P.Operators = { // // Tokenizers // rtoken: function (r) { // regex token return function (s) { var mx = s.match(r); if (mx) { return ([ mx[0], s.substring(mx[0].length) ]); } else { throw new $P.Exception(s); } }; }, token: function () { // whitespace-eating token return function (s) { return _.rtoken(new RegExp("^\\s*" + s + "\\s*"))(s); }; }, stoken: function (s) { // string token return _.rtoken(new RegExp("^" + s)); }, // Atomic Operators until: function (p) { return function (s) { var qx = [], rx = null; while (s.length) { try { rx = p.call(this, s); } catch (e) { qx.push(rx[0]); s = rx[1]; continue; } break; } return [ qx, s ]; }; }, many: function (p) { return function (s) { var rx = [], r = null; while (s.length) { try { r = p.call(this, s); } catch (e) { return [ rx, s ]; } rx.push(r[0]); s = r[1]; } return [ rx, s ]; }; }, // generator operators -- see below optional: function (p) { return function (s) { var r = null; try { r = p.call(this, s); } catch (e) { return [ null, s ]; } return [ r[0], r[1] ]; }; }, not: function (p) { return function (s) { try { p.call(this, s); } catch (e) { return [null, s]; } throw new $P.Exception(s); }; }, ignore: function (p) { return p ? function (s) { var r = null; r = p.call(this, s); return [null, r[1]]; } : null; }, product: function () { var px = arguments[0], qx = Array.prototype.slice.call(arguments, 1), rx = []; for (var i = 0 ; i < px.length ; i++) { rx.push(_.each(px[i], qx)); } return rx; }, cache: function (rule) { var cache = {}, cache_length = 0, cache_keys = [], CACHE_MAX = Date.Config.CACHE_MAX || 100000, r = null; var cacheCheck = function () { if (cache_length === CACHE_MAX) { // kill several keys, don't want to have to do this all the time... for (var i=0; i < 10; i++) { var key = cache_keys.shift(); if (key) { delete cache[key]; cache_length--; } } } }; return function (s) { cacheCheck(); try { r = cache[s] = (cache[s] || rule.call(this, s)); } catch (e) { r = cache[s] = e; } cache_length++; cache_keys.push(s); if (r instanceof $P.Exception) { throw r; } else { return r; } }; }, // vector operators -- see below any: function () { var px = arguments; return function (s) { var r = null; for (var i = 0; i < px.length; i++) { if (px[i] == null) { continue; } try { r = (px[i].call(this, s)); } catch (e) { r = null; } if (r) { return r; } } throw new $P.Exception(s); }; }, each: function () { var px = arguments; return function (s) { var rx = [], r = null; for (var i = 0; i < px.length ; i++) { if (px[i] == null) { continue; } try { r = (px[i].call(this, s)); } catch (e) { throw new $P.Exception(s); } rx.push(r[0]); s = r[1]; } return [ rx, s]; }; }, all: function () { var px = arguments, _ = _; return _.each(_.optional(px)); }, // delimited operators sequence: function (px, d, c) { d = d || _.rtoken(/^\s*/); c = c || null; if (px.length === 1) { return px[0]; } return function (s) { var r = null, q = null; var rx = []; for (var i = 0; i < px.length ; i++) { try { r = px[i].call(this, s); } catch (e) { break; } rx.push(r[0]); try { q = d.call(this, r[1]); } catch (ex) { q = null; break; } s = q[1]; } if (!r) { throw new $P.Exception(s); } if (q) { throw new $P.Exception(q[1]); } if (c) { try { r = c.call(this, r[1]); } catch (ey) { throw new $P.Exception(r[1]); } } return [ rx, (r?r[1]:s) ]; }; }, // // Composite Operators // between: function (d1, p, d2) { d2 = d2 || d1; var _fn = _.each(_.ignore(d1), p, _.ignore(d2)); return function (s) { var rx = _fn.call(this, s); return [[rx[0][0], r[0][2]], rx[1]]; }; }, list: function (p, d, c) { d = d || _.rtoken(/^\s*/); c = c || null; return (p instanceof Array ? _.each(_.product(p.slice(0, -1), _.ignore(d)), p.slice(-1), _.ignore(c)) : _.each(_.many(_.each(p, _.ignore(d))), px, _.ignore(c))); }, set: function (px, d, c) { d = d || _.rtoken(/^\s*/); c = c || null; return function (s) { // r is the current match, best the current 'best' match // which means it parsed the most amount of input var r = null, p = null, q = null, rx = null, best = [[], s], last = false; // go through the rules in the given set for (var i = 0; i < px.length ; i++) { // last is a flag indicating whether this must be the last element // if there is only 1 element, then it MUST be the last one q = null; p = null; r = null; last = (px.length === 1); // first, we try simply to match the current pattern // if not, try the next pattern try { r = px[i].call(this, s); } catch (e) { continue; } // since we are matching against a set of elements, the first // thing to do is to add r[0] to matched elements rx = [[r[0]], r[1]]; // if we matched and there is still input to parse and // we don't already know this is the last element, // we're going to next check for the delimiter ... // if there's none, or if there's no input left to parse // than this must be the last element after all ... if (r[1].length > 0 && ! last) { try { q = d.call(this, r[1]); } catch (ex) { last = true; } } else { last = true; } // if we parsed the delimiter and now there's no more input, // that means we shouldn't have parsed the delimiter at all // so don't update r and mark this as the last element ... if (!last && q[1].length === 0) { last = true; } // so, if this isn't the last element, we're going to see if // we can get any more matches from the remaining (unmatched) // elements ... if (!last) { // build a list of the remaining rules we can match against, // i.e., all but the one we just matched against var qx = []; for (var j = 0; j < px.length ; j++) { if (i !== j) { qx.push(px[j]); } } // now invoke recursively set with the remaining input // note that we don't include the closing delimiter ... // we'll check for that ourselves at the end p = _.set(qx, d).call(this, q[1]); // if we got a non-empty set as a result ... // (otw rx already contains everything we want to match) if (p[0].length > 0) { // update current result, which is stored in rx ... // basically, pick up the remaining text from p[1] // and concat the result from p[0] so that we don't // get endless nesting ... rx[0] = rx[0].concat(p[0]); rx[1] = p[1]; } } // at this point, rx either contains the last matched element // or the entire matched set that starts with this element. // now we just check to see if this variation is better than // our best so far, in terms of how much of the input is parsed if (rx[1].length < best[1].length) { best = rx; } // if we've parsed all the input, then we're finished if (best[1].length === 0) { break; } } // so now we've either gone through all the patterns trying them // as the initial match; or we found one that parsed the entire // input string ... // if best has no matches, just return empty set ... if (best[0].length === 0) { return best; } // if a closing delimiter is provided, then we have to check it also if (c) { // we try this even if there is no remaining input because the pattern // may well be optional or match empty input ... try { q = c.call(this, best[1]); } catch (ey) { throw new $P.Exception(best[1]); } // it parsed ... be sure to update the best match remaining input best[1] = q[1]; } // if we're here, either there was no closing delimiter or we parsed it // so now we have the best match; just return it! return best; }; }, forward: function (gr, fname) { return function (s) { return gr[fname].call(this, s); }; }, // // Translation Operators // replace: function (rule, repl) { return function (s) { var r = rule.call(this, s); return [repl, r[1]]; }; }, process: function (rule, fn) { return function (s) { var r = rule.call(this, s); return [fn.call(this, r[0]), r[1]]; }; }, min: function (min, rule) { return function (s) { var rx = rule.call(this, s); if (rx[0].length < min) { throw new $P.Exception(s); } return rx; }; } }; // Generator Operators And Vector Operators // Generators are operators that have a signature of F(R) => R, // taking a given rule and returning another rule, such as // ignore, which parses a given rule and throws away the result. // Vector operators are those that have a signature of F(R1,R2,...) => R, // take a list of rules and returning a new rule, such as each. // Generator operators are converted (via the following _generator // function) into functions that can also take a list or array of rules // and return an array of new rules as though the function had been // called on each rule in turn (which is what actually happens). // This allows generators to be used with vector operators more easily. // Example: // each(ignore(foo, bar)) instead of each(ignore(foo), ignore(bar)) // This also turns generators into vector operators, which allows // constructs like: // not(cache(foo, bar)) var _generator = function (op) { function gen() { var args = null, rx = [], px, i; if (arguments.length > 1) { args = Array.prototype.slice.call(arguments); } else if (arguments[0] instanceof Array) { args = arguments[0]; } if (args) { px = args.shift(); if (px.length > 0) { args.unshift(px[i]); rx.push(op.apply(null, args)); args.shift(); return rx; } } else { return op.apply(null, arguments); } } return gen; }; var gx = "optional not ignore cache".split(/\s/); for (var i = 0 ; i < gx.length ; i++) { _[gx[i]] = _generator(_[gx[i]]); } var _vector = function (op) { return function () { if (arguments[0] instanceof Array) { return op.apply(null, arguments[0]); } else { return op.apply(null, arguments); } }; }; var vx = "each any all".split(/\s/); for (var j = 0 ; j < vx.length ; j++) { _[vx[j]] = _vector(_[vx[j]]); } }()); (function () { var $D = Date; var flattenAndCompact = function (ax) { var rx = []; for (var i = 0; i < ax.length; i++) { if (ax[i] instanceof Array) { rx = rx.concat(flattenAndCompact(ax[i])); } else { if (ax[i]) { rx.push(ax[i]); } } } return rx; }; var parseMeridian = function () { if (this.meridian && (this.hour || this.hour === 0)) { if (this.meridian === "a" && this.hour > 11 && Date.Config.strict24hr){ throw "Invalid hour and meridian combination"; } else if (this.meridian === "p" && this.hour < 12 && Date.Config.strict24hr){ throw "Invalid hour and meridian combination"; } else if (this.meridian === "p" && this.hour < 12) { this.hour = this.hour + 12; } else if (this.meridian === "a" && this.hour === 12) { this.hour = 0; } } }; var setDefaults = function () { var now = new Date(); if ((this.hour || this.minute) && (!this.month && !this.year && !this.day)) { this.day = now.getDate(); } if (!this.year) { this.year = now.getFullYear(); } if (!this.month && this.month !== 0) { this.month = now.getMonth(); } if (!this.day) { this.day = 1; } if (!this.hour) { this.hour = 0; } if (!this.minute) { this.minute = 0; } if (!this.second) { this.second = 0; } if (!this.millisecond) { this.millisecond = 0; } }; var finishUtils = { getToday: function () { if (this.now || "hour minute second".indexOf(this.unit) !== -1) { return new Date(); } else { return $D.today(); } }, setDaysFromWeekday: function (today, orient){ var gap; orient = orient || 1; this.unit = "day"; gap = ($D.getDayNumberFromName(this.weekday) - today.getDay()); this.days = gap ? ((gap + (orient * 7)) % 7) : (orient * 7); return this; }, setMonthsFromMonth: function (today, orient) { var gap; orient = orient || 1; this.unit = "month"; gap = (this.month - today.getMonth()); this.months = gap ? ((gap + (orient * 12)) % 12) : (orient * 12); this.month = null; return this; }, setDMYFromWeekday: function () { var d = Date[this.weekday](); this.day = d.getDate(); if (!this.month) { this.month = d.getMonth(); } this.year = d.getFullYear(); return this; }, setUnitValue: function (orient) { if (!this.value && this.operator && this.operator !== null && this[this.unit + "s"] && this[this.unit + "s"] !== null) { this[this.unit + "s"] = this[this.unit + "s"] + ((this.operator === "add") ? 1 : -1) + (this.value||0) * orient; } else if (this[this.unit + "s"] == null || this.operator != null) { if (!this.value) { this.value = 1; } this[this.unit + "s"] = this.value * orient; } }, generateDateFromWeeks: function () { var weekday = (this.weekday !== undefined) ? this.weekday : "today"; var d = Date[weekday]().addWeeks(this.weeks); if (this.now) { d.setTimeToNow(); } return d; } }; $D.Translator = { hour: function (s) { return function () { this.hour = Number(s); }; }, minute: function (s) { return function () { this.minute = Number(s); }; }, second: function (s) { return function () { this.second = Number(s); }; }, /* for ss.s format */ secondAndMillisecond: function (s) { return function () { var mx = s.match(/^([0-5][0-9])\.([0-9]{1,3})/); this.second = Number(mx[1]); this.millisecond = Number(mx[2]); }; }, meridian: function (s) { return function () { this.meridian = s.slice(0, 1).toLowerCase(); }; }, timezone: function (s) { return function () { var n = s.replace(/[^\d\+\-]/g, ""); if (n.length) { this.timezoneOffset = Number(n); } else { this.timezone = s.toLowerCase(); } }; }, day: function (x) { var s = x[0]; return function () { this.day = Number(s.match(/\d+/)[0]); if (this.day < 1) { throw "invalid day"; } }; }, month: function (s) { return function () { this.month = (s.length === 3) ? "jan feb mar apr may jun jul aug sep oct nov dec".indexOf(s)/4 : Number(s) - 1; if (this.month < 0) { throw "invalid month"; } }; }, year: function (s) { return function () { var n = Number(s); this.year = ((s.length > 2) ? n : (n + (((n + 2000) < Date.CultureInfo.twoDigitYearMax) ? 2000 : 1900))); }; }, rday: function (s) { return function () { switch (s) { case "yesterday": this.days = -1; break; case "tomorrow": this.days = 1; break; case "today": this.days = 0; break; case "now": this.days = 0; this.now = true; break; } }; }, finishExact: function (x) { var d; x = (x instanceof Array) ? x : [x]; for (var i = 0 ; i < x.length ; i++) { if (x[i]) { x[i].call(this); } } setDefaults.call(this); parseMeridian.call(this); if (this.day > $D.getDaysInMonth(this.year, this.month)) { throw new RangeError(this.day + " is not a valid value for days."); } d = new Date(this.year, this.month, this.day, this.hour, this.minute, this.second, this.millisecond); if (this.year < 100) { d.setFullYear(this.year); // means years less that 100 are process correctly. JS will parse it otherwise as 1900-1999. } if (this.timezone) { d.set({ timezone: this.timezone }); } else if (this.timezoneOffset) { d.set({ timezoneOffset: this.timezoneOffset }); } return d; }, finish: function (x) { var today, expression, orient, temp; x = (x instanceof Array) ? flattenAndCompact(x) : [ x ]; if (x.length === 0) { return null; } for (var i = 0 ; i < x.length ; i++) { if (typeof x[i] === "function") { x[i].call(this); } } if (this.now && !this.unit && !this.operator) { return new Date(); } else { today = finishUtils.getToday.call(this); } expression = !!(this.days && this.days !== null || this.orient || this.operator); orient = ((this.orient === "past" || this.operator === "subtract") ? -1 : 1); if (this.month && this.unit === "week") { this.value = this.month + 1; delete this.month; delete this.day; } if ((this.month || this.month === 0) && "year day hour minute second".indexOf(this.unit) !== -1) { if (!this.value) { this.value = this.month + 1; } this.month = null; expression = true; } if (!expression && this.weekday && !this.day && !this.days) { finishUtils.setDMYFromWeekday.call(this); } if (expression && this.weekday && this.unit !== "month" && this.unit !== "week") { finishUtils.setDaysFromWeekday.call(this, today, orient); } if (this.weekday && this.unit !== "week" && !this.day && !this.days) { temp = Date[this.weekday](); this.day = temp.getDate(); if (temp.getMonth() !== today.getMonth()) { this.month = temp.getMonth(); } } if (this.month && this.unit === "day" && this.operator) { if (!this.value) { this.value = (this.month + 1); } this.month = null; } if (this.value != null && this.month != null && this.year != null) { this.day = this.value * 1; } if (this.month && !this.day && this.value) { today.set({ day: this.value * 1 }); if (!expression) { this.day = this.value * 1; } } if (!this.month && this.value && this.unit === "month" && !this.now) { this.month = this.value; expression = true; } if (expression && (this.month || this.month === 0) && this.unit !== "year") { finishUtils.setMonthsFromMonth.call(this, today, orient); } if (!this.unit) { this.unit = "day"; } finishUtils.setUnitValue.call(this, orient); parseMeridian.call(this); if ((this.month || this.month === 0) && !this.day) { this.day = 1; } if (!this.orient && !this.operator && this.unit === "week" && this.value && !this.day && !this.month) { return Date.today().setWeek(this.value); } if (this.unit === "week" && this.weeks && !this.day && !this.month) { return finishUtils.generateDateFromWeeks.call(this); } if (expression && this.timezone && this.day && this.days) { this.day = this.days; } if (expression){ today.add(this); } else { today.set(this); } if (this.timezone) { this.timezone = this.timezone.toUpperCase(); var offset = $D.getTimezoneOffset(this.timezone); var timezone; if (today.hasDaylightSavingTime()) { // lets check that we're being sane with timezone setting timezone = $D.getTimezoneAbbreviation(offset, today.isDaylightSavingTime()); if (timezone !== this.timezone) { // bugger, we're in a place where things like EST vs EDT matters. if (today.isDaylightSavingTime()) { today.addHours(-1); } else { today.addHours(1); } } } today.setTimezoneOffset(offset); } return today; } }; }()); (function () { var $D = Date; $D.Grammar = {}; var _ = $D.Parsing.Operators, g = $D.Grammar, t = $D.Translator, _fn; // Allow rolling up into general purpose rules _fn = function () { return _.each(_.any.apply(null, arguments), _.not(g.ctoken2("timeContext"))); }; g.datePartDelimiter = _.rtoken(/^([\s\-\.\,\/\x27]+)/); g.timePartDelimiter = _.stoken(":"); g.whiteSpace = _.rtoken(/^\s*/); g.generalDelimiter = _.rtoken(/^(([\s\,]|at|@|on)+)/); var _C = {}; g.ctoken = function (keys) { var fn = _C[keys]; if (! fn) { var c = Date.CultureInfo.regexPatterns; var kx = keys.split(/\s+/), px = []; for (var i = 0; i < kx.length ; i++) { px.push(_.replace(_.rtoken(c[kx[i]]), kx[i])); } fn = _C[keys] = _.any.apply(null, px); } return fn; }; g.ctoken2 = function (key) { return _.rtoken(Date.CultureInfo.regexPatterns[key]); }; var cacheProcessRtoken = function (key, token, type, eachToken) { if (eachToken) { g[key] = _.cache(_.process(_.each(_.rtoken(token),_.optional(g.ctoken2(eachToken))), type)); } else { g[key] = _.cache(_.process(_.rtoken(token), type)); } }; var cacheProcessCtoken = function (token, type) { return _.cache(_.process(g.ctoken2(token), type)); }; var _F = {}; //function cache var _get = function (f) { _F[f] = (_F[f] || g.format(f)[0]); return _F[f]; }; g.allformats = function (fx) { var rx = []; if (fx instanceof Array) { for (var i = 0; i < fx.length; i++) { rx.push(_get(fx[i])); } } else { rx.push(_get(fx)); } return rx; }; g.formats = function (fx) { if (fx instanceof Array) { var rx = []; for (var i = 0 ; i < fx.length ; i++) { rx.push(_get(fx[i])); } return _.any.apply(null, rx); } else { return _get(fx); } }; var grammarFormats = { timeFormats: function(){ var i, RTokenKeys = [ "h", "hh", "H", "HH", "m", "mm", "s", "ss", "ss.s", "z", "zz" ], RToken = [ /^(0[0-9]|1[0-2]|[1-9])/, /^(0[0-9]|1[0-2])/, /^([0-1][0-9]|2[0-3]|[0-9])/, /^([0-1][0-9]|2[0-3])/, /^([0-5][0-9]|[0-9])/, /^[0-5][0-9]/, /^([0-5][0-9]|[0-9])/, /^[0-5][0-9]/, /^[0-5][0-9]\.[0-9]{1,3}/, /^((\+|\-)\s*\d\d\d\d)|((\+|\-)\d\d\:?\d\d)/, /^((\+|\-)\s*\d\d\d\d)|((\+|\-)\d\d\:?\d\d)/ ], tokens = [ t.hour, t.hour, t.hour, t.hour, t.minute, t.minute, t.second, t.second, t.secondAndMillisecond, t.timezone, t.timezone ]; for (i=0; i < RTokenKeys.length; i++) { cacheProcessRtoken(RTokenKeys[i], RToken[i], tokens[i]); } g.hms = _.cache(_.sequence([g.H, g.m, g.s], g.timePartDelimiter)); g.t = cacheProcessCtoken("shortMeridian", t.meridian); g.tt = cacheProcessCtoken("longMeridian", t.meridian); g.zzz = cacheProcessCtoken("timezone", t.timezone); g.timeSuffix = _.each(_.ignore(g.whiteSpace), _.set([ g.tt, g.zzz ])); g.time = _.each(_.optional(_.ignore(_.stoken("T"))), g.hms, g.timeSuffix); }, dateFormats: function () { // pre-loaded rules for different date part order preferences var _setfn = function () { return _.set(arguments, g.datePartDelimiter); }; var i, RTokenKeys = [ "d", "dd", "M", "MM", "y", "yy", "yyy", "yyyy" ], RToken = [ /^([0-2]\d|3[0-1]|\d)/, /^([0-2]\d|3[0-1])/, /^(1[0-2]|0\d|\d)/, /^(1[0-2]|0\d)/, /^(\d+)/, /^(\d\d)/, /^(\d\d?\d?\d?)/, /^(\d\d\d\d)/ ], tokens = [ t.day, t.day, t.month, t.month, t.year, t.year, t.year, t.year ], eachToken = [ "ordinalSuffix", "ordinalSuffix" ]; for (i=0; i < RTokenKeys.length; i++) { cacheProcessRtoken(RTokenKeys[i], RToken[i], tokens[i], eachToken[i]); } g.MMM = g.MMMM = _.cache(_.process(g.ctoken("jan feb mar apr may jun jul aug sep oct nov dec"), t.month)); g.ddd = g.dddd = _.cache(_.process(g.ctoken("sun mon tue wed thu fri sat"), function (s) { return function () { this.weekday = s; }; } )); g.day = _fn(g.d, g.dd); g.month = _fn(g.M, g.MMM); g.year = _fn(g.yyyy, g.yy); g.mdy = _setfn(g.ddd, g.month, g.day, g.year); g.ymd = _setfn(g.ddd, g.year, g.month, g.day); g.dmy = _setfn(g.ddd, g.day, g.month, g.year); g.date = function (s) { return ((g[Date.CultureInfo.dateElementOrder] || g.mdy).call(this, s)); }; }, relative: function () { // relative date / time expressions g.orientation = _.process(g.ctoken("past future"), function (s) { return function () { this.orient = s; }; } ); g.operator = _.process(g.ctoken("add subtract"), function (s) { return function () { this.operator = s; }; } ); g.rday = _.process(g.ctoken("yesterday tomorrow today now"), t.rday); g.unit = _.process(g.ctoken("second minute hour day week month year"), function (s) { return function () { this.unit = s; }; } ); } }; g.buildGrammarFormats = function () { // these need to be rebuilt every time the language changes. _C = {}; grammarFormats.timeFormats(); grammarFormats.dateFormats(); grammarFormats.relative(); g.value = _.process(_.rtoken(/^([-+]?\d+)?(st|nd|rd|th)?/), function (s) { return function () { this.value = s.replace(/\D/g, ""); }; } ); g.expression = _.set([g.rday, g.operator, g.value, g.unit, g.orientation, g.ddd, g.MMM ]); g.format = _.process(_.many( _.any( // translate format specifiers into grammar rules _.process( _.rtoken(/^(dd?d?d?(?!e)|MM?M?M?|yy?y?y?|hh?|HH?|mm?|ss?|tt?|zz?z?)/), function (fmt) { if (g[fmt]) { return g[fmt]; } else { throw $D.Parsing.Exception(fmt); } } ), // translate separator tokens into token rules _.process(_.rtoken(/^[^dMyhHmstz]+/), // all legal separators function (s) { return _.ignore(_.stoken(s)); } ) ) ), // construct the parser ... function (rules) { return _.process(_.each.apply(null, rules), t.finishExact); } ); // starting rule for general purpose grammar g._start = _.process(_.set([ g.date, g.time, g.expression ], g.generalDelimiter, g.whiteSpace), t.finish); }; g.buildGrammarFormats(); // parsing date format specifiers - ex: "h:m:s tt" // this little guy will generate a custom parser based // on the format string, ex: g.format("h:m:s tt") // check for these formats first g._formats = g.formats([ "\"yyyy-MM-ddTHH:mm:ssZ\"", "yyyy-MM-ddTHH:mm:ss.sz", "yyyy-MM-ddTHH:mm:ssZ", "yyyy-MM-ddTHH:mm:ssz", "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-ddTHH:mmZ", "yyyy-MM-ddTHH:mmz", "yyyy-MM-ddTHH:mm", "ddd, MMM dd, yyyy H:mm:ss tt", "ddd MMM d yyyy HH:mm:ss zzz", "MMddyyyy", "ddMMyyyy", "Mddyyyy", "ddMyyyy", "Mdyyyy", "dMyyyy", "yyyy", "Mdyy", "dMyy", "d" ]); // real starting rule: tries selected formats first, // then general purpose rule g.start = function (s) { try { var r = g._formats.call({}, s); if (r[1].length === 0) { return r; } } catch (e) {} return g._start.call({}, s); }; }()); (function () { var $D = Date; /** * @desc Converts the specified string value into its JavaScript Date equivalent using CultureInfo specific format information. * * Example

	///////////
	// Dates //
	///////////

	// 15-Oct-2004
	var d1 = Date.parse("10/15/2004");

	// 15-Oct-2004
	var d1 = Date.parse("15-Oct-2004");

	// 15-Oct-2004
	var d1 = Date.parse("2004.10.15");

	//Fri Oct 15, 2004
	var d1 = Date.parse("Fri Oct 15, 2004");

	///////////
	// Times //
	///////////

	// Today at 10 PM.
	var d1 = Date.parse("10 PM");

	// Today at 10:30 PM.
	var d1 = Date.parse("10:30 P.M.");

	// Today at 6 AM.
	var d1 = Date.parse("06am");

	/////////////////////
	// Dates and Times //
	/////////////////////

	// 8-July-2004 @ 10:30 PM
	var d1 = Date.parse("July 8th, 2004, 10:30 PM");

	// 1-July-2004 @ 10:30 PM
	var d1 = Date.parse("2004-07-01T22:30:00");

	////////////////////
	// Relative Dates //
	////////////////////

	// Returns today's date. The string "today" is culture specific.
	var d1 = Date.parse("today");

	// Returns yesterday's date. The string "yesterday" is culture specific.
	var d1 = Date.parse("yesterday");

	// Returns the date of the next thursday.
	var d1 = Date.parse("Next thursday");

	// Returns the date of the most previous monday.
	var d1 = Date.parse("last monday");

	// Returns today's day + one year.
	var d1 = Date.parse("next year");

	///////////////
	// Date Math //
	///////////////

	// Today + 2 days
	var d1 = Date.parse("t+2");

	// Today + 2 days
	var d1 = Date.parse("today + 2 days");

	// Today + 3 months
	var d1 = Date.parse("t+3m");

	// Today - 1 year
	var d1 = Date.parse("today - 1 year");

	// Today - 1 year
	var d1 = Date.parse("t-1y"); 


	/////////////////////////////
	// Partial Dates and Times //
	/////////////////////////////

	// July 15th of this year.
	var d1 = Date.parse("July 15");

	// 15th day of current day and year.
	var d1 = Date.parse("15");

	// July 1st of current year at 10pm.
	var d1 = Date.parse("7/1 10pm");
	
* * @param {String} The string value to convert into a Date object [Required] * @return {Date} A Date object or null if the string cannot be converted into a Date. */ var parseUtils = { removeOrds: function (s) { ords = s.match(/\b(\d+)(?:st|nd|rd|th)\b/); // find ordinal matches s = ((ords && ords.length === 2) ? s.replace(ords[0], ords[1]) : s); return s; }, grammarParser: function (s) { var r = null; try { r = $D.Grammar.start.call({}, s.replace(/^\s*(\S*(\s+\S+)*)\s*$/, "$1")); } catch (e) { return null; } return ((r[1].length === 0) ? r[0] : null); }, nativeFallback: function(s) { var t; try { // ok we haven't parsed it, last ditch attempt with the built-in parser. t = Date._parse(s); return (t || t === 0) ? new Date(t) : null; } catch (e) { return null; } } }; function parse (s) { var d; if (!s) { return null; } if (s instanceof Date) { return s.clone(); } if (s.length >= 4 && s.charAt(0) !== "0" && s.charAt(0) !== "+"&& s.charAt(0) !== "-") { // ie: 2004 will pass, 0800 won't. // Start with specific formats d = $D.Parsing.ISO.parse(s) || $D.Parsing.Numeric.parse(s); } if (d instanceof Date && !isNaN(d.getTime())) { return d; } else { // find ordinal dates (1st, 3rd, 8th, etc and remove them as they cause parsing issues) s = $D.Parsing.Normalizer.parse(parseUtils.removeOrds(s)); d = parseUtils.grammarParser(s); if (d !== null) { return d; } else { return parseUtils.nativeFallback(s); } } } if (!$D._parse) { $D._parse = $D.parse; } $D.parse = parse; Date.getParseFunction = function (fx) { var fns = Date.Grammar.allformats(fx); return function (s) { var r = null; for (var i = 0; i < fns.length; i++) { try { r = fns[i].call({}, s); } catch (e) { continue; } if (r[1].length === 0) { return r[0]; } } return null; }; }; /** * Converts the specified string value into its JavaScript Date equivalent using the specified format {String} or formats {Array} and the CultureInfo specific format information. * The format of the string value must match one of the supplied formats exactly. * * Example

	// 15-Oct-2004
	var d1 = Date.parseExact("10/15/2004", "M/d/yyyy");

	// 15-Oct-2004
	var d1 = Date.parse("15-Oct-2004", "M-ddd-yyyy");

	// 15-Oct-2004
	var d1 = Date.parse("2004.10.15", "yyyy.MM.dd");

	// Multiple formats
	var d1 = Date.parseExact("10/15/2004", ["M/d/yyyy", "MMMM d, yyyy"]);
	
* * @param {String} The string value to convert into a Date object [Required]. * @param {Object} The expected format {String} or an array of expected formats {Array} of the date string [Required]. * @return {Date} A Date object or null if the string cannot be converted into a Date. */ $D.parseExact = function (s, fx) { return $D.getParseFunction(fx)(s); }; }()); (function () { var $D = Date, $P = $D.prototype, // $C = $D.CultureInfo, // not used atm p = function (s, l) { if (!l) { l = 2; } return ("000" + s).slice(l * -1); }; /** * Converts a PHP format string to Java/.NET format string. * A PHP format string can be used with ._format or .format. * A Java/.NET format string can be used with .toString(). * The .parseExact function will only accept a Java/.NET format string * * Example * var f1 = "%m/%d/%y" * var f2 = Date.normalizeFormat(f1); // "MM/dd/yy" * * new Date().format(f1); // "04/13/08" * new Date()._format(f1); // "04/13/08" * new Date().toString(f2); // "04/13/08" * * var date = Date.parseExact("04/13/08", f2); // Sun Apr 13 2008 * * @param {String} A PHP format string consisting of one or more format spcifiers. * @return {String} The PHP format converted to a Java/.NET format string. */ var normalizerSubstitutions = { "d" : "dd", "%d": "dd", "D" : "ddd", "%a": "ddd", "j" : "dddd", "l" : "dddd", "%A": "dddd", "S" : "S", "F" : "MMMM", "%B": "MMMM", "m" : "MM", "%m": "MM", "M" : "MMM", "%b": "MMM", "%h": "MMM", "n" : "M", "Y" : "yyyy", "%Y": "yyyy", "y" : "yy", "%y": "yy", "g" : "h", "%I": "h", "G" : "H", "h" : "hh", "H" : "HH", "%H": "HH", "i" : "mm", "%M": "mm", "s" : "ss", "%S": "ss", "%r": "hh:mm tt", "%R": "H:mm", "%T": "H:mm:ss", "%X": "t", "%x": "d", "%e": "d", "%D": "MM/dd/yy", "%n": "\\n", "%t": "\\t", "e" : "z", "T" : "z", "%z": "z", "%Z": "z", "Z" : "ZZ", "N" : "u", "w" : "u", "%w": "u", "W" : "W", "%V": "W" }; var normalizer = { substitutes: function (m) { return normalizerSubstitutions[m]; }, interpreted: function (m, x) { var y; switch (m) { case "%u": return x.getDay() + 1; case "z": return x.getOrdinalNumber(); case "%j": return p(x.getOrdinalNumber(), 3); case "%U": var d1 = x.clone().set({month: 0, day: 1}).addDays(-1).moveToDayOfWeek(0), d2 = x.clone().addDays(1).moveToDayOfWeek(0, -1); return (d2 < d1) ? "00" : p((d2.getOrdinalNumber() - d1.getOrdinalNumber()) / 7 + 1); case "%W": return p(x.getWeek()); case "t": return $D.getDaysInMonth(x.getFullYear(), x.getMonth()); case "o": case "%G": return x.setWeek(x.getISOWeek()).toString("yyyy"); case "%g": return x._format("%G").slice(-2); case "a": case "%p": return t("tt").toLowerCase(); case "A": return t("tt").toUpperCase(); case "u": return p(x.getMilliseconds(), 3); case "I": return (x.isDaylightSavingTime()) ? 1 : 0; case "O": return x.getUTCOffset(); case "P": y = x.getUTCOffset(); return y.substring(0, y.length - 2) + ":" + y.substring(y.length - 2); case "B": var now = new Date(); return Math.floor(((now.getHours() * 3600) + (now.getMinutes() * 60) + now.getSeconds() + (now.getTimezoneOffset() + 60) * 60) / 86.4); case "c": return x.toISOString().replace(/\"/g, ""); case "U": return $D.strtotime("now"); case "%c": return t("d") + " " + t("t"); case "%C": return Math.floor(x.getFullYear() / 100 + 1); } }, shouldOverrideDefaults: function (m) { switch (m) { case "%e": return true; default: return false; } }, parse: function (m, context) { var formatString, c = context || new Date(); formatString = normalizer.substitutes(m); if (formatString) { return formatString; } formatString = normalizer.interpreted(m, c); if (formatString) { return formatString; } else { return m; } } }; $D.normalizeFormat = function (format, context) { return format.replace(/(%|\\)?.|%%/g, function(t){ return normalizer.parse(t, context); }); }; /** * Format a local Unix timestamp according to locale settings * * Example: * Date.strftime("%m/%d/%y", new Date()); // "04/13/08" * Date.strftime("c", "2008-04-13T17:52:03Z"); // "04/13/08" * * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @param {Number|String} The number representing the number of seconds that have elapsed since January 1, 1970 (local time). * @return {String} A string representation of the current Date object. */ $D.strftime = function (format, time) { var d = Date.parse(time); return d._format(format); }; /** * Parse any textual datetime description into a Unix timestamp. * A Unix timestamp is the number of seconds that have elapsed since January 1, 1970 (midnight UTC/GMT). * * Example: * Date.strtotime("04/13/08"); // 1208044800 * Date.strtotime("1970-01-01T00:00:00Z"); // 0 * * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @param {Object} A string or date object. * @return {String} A string representation of the current Date object. */ $D.strtotime = function (time) { var d = $D.parse(time); return Math.round($D.UTC(d.getUTCFullYear(), d.getUTCMonth(), d.getUTCDate(), d.getUTCHours(), d.getUTCMinutes(), d.getUTCSeconds(), d.getUTCMilliseconds()) / 1000); }; /** * Converts the value of the current Date object to its equivalent string representation using a PHP/Unix style of date format specifiers. * Format Specifiers * Format Description Example * ------ --------------------------------------------------------------------------- ----------------------- * %a abbreviated weekday name according to the current localed "Mon" through "Sun" * %A full weekday name according to the current localed "Sunday" through "Saturday" * %b abbreviated month name according to the current localed "Jan" through "Dec" * %B full month name according to the current locale "January" through "December" * %c preferred date and time representation for the current locale "4/13/2008 12:33 PM" * %C century number (the year divided by 100 and truncated to an integer) "00" to "99" * %d day of the month as a decimal number "01" to "31" * %D same as %m/%d/%y "04/13/08" * %e day of the month as a decimal number, a single digit is preceded by a space "1" to "31" * %g like %G, but without the century "08" * %G The 4-digit year corresponding to the ISO week number (see %V). "2008" * This has the same format and value as %Y, except that if the ISO week number * belongs to the previous or next year, that year is used instead. * %h same as %b "Jan" through "Dec" * %H hour as a decimal number using a 24-hour clock. "00" to "23" * %I hour as a decimal number using a 12-hour clock. "01" to "12" * %j day of the year as a decimal number. "001" to "366" * %m month as a decimal number. "01" to "12" * %M minute as a decimal number. "00" to "59" * %n newline character "\n" * %p either "am" or "pm" according to the given time value, or the "am" or "pm" * corresponding strings for the current locale. * %r time in a.m. and p.m. notation "8:44 PM" * %R time in 24 hour notation "20:44" * %S second as a decimal number "00" to "59" * %t tab character "\t" * %T current time, equal to %H:%M:%S "12:49:11" * %u weekday as a decimal number ["1", "7"], with "1" representing Monday "1" to "7" * %U week number of the current year as a decimal number, starting with the "0" to ("52" or "53") * first Sunday as the first day of the first week * %V The ISO 8601:1988 week number of the current year as a decimal number, "00" to ("52" or "53") * range 01 to 53, where week 1 is the first week that has at least 4 days * in the current year, and with Monday as the first day of the week. * (Use %G or %g for the year component that corresponds to the week number * for the specified timestamp.) * %W week number of the current year as a decimal number, starting with the "00" to ("52" or "53") * first Monday as the first day of the first week * %w day of the week as a decimal, Sunday being "0" "0" to "6" * %x preferred date representation for the current locale without the time "4/13/2008" * %X preferred time representation for the current locale without the date "12:53:05" * %y year as a decimal number without a century "00" "99" * %Y year as a decimal number including the century "2008" * %Z time zone or name or abbreviation "UTC", "EST", "PST" * %z same as %Z * %% a literal "%" characters "%" * d Day of the month, 2 digits with leading zeros "01" to "31" * D A textual representation of a day, three letters "Mon" through "Sun" * j Day of the month without leading zeros "1" to "31" * l A full textual representation of the day of the week (lowercase "L") "Sunday" through "Saturday" * N ISO-8601 numeric representation of the day of the week (added in PHP 5.1.0) "1" (for Monday) through "7" (for Sunday) * S English ordinal suffix for the day of the month, 2 characters "st", "nd", "rd" or "th". Works well with j * w Numeric representation of the day of the week "0" (for Sunday) through "6" (for Saturday) * z The day of the year (starting from "0") "0" through "365" * W ISO-8601 week number of year, weeks starting on Monday "00" to ("52" or "53") * F A full textual representation of a month, such as January or March "January" through "December" * m Numeric representation of a month, with leading zeros "01" through "12" * M A short textual representation of a month, three letters "Jan" through "Dec" * n Numeric representation of a month, without leading zeros "1" through "12" * t Number of days in the given month "28" through "31" * L Whether it's a leap year "1" if it is a leap year, "0" otherwise * o ISO-8601 year number. This has the same value as Y, except that if the "2008" * ISO week number (W) belongs to the previous or next year, that year * is used instead. * Y A full numeric representation of a year, 4 digits "2008" * y A two digit representation of a year "08" * a Lowercase Ante meridiem and Post meridiem "am" or "pm" * A Uppercase Ante meridiem and Post meridiem "AM" or "PM" * B Swatch Internet time "000" through "999" * g 12-hour format of an hour without leading zeros "1" through "12" * G 24-hour format of an hour without leading zeros "0" through "23" * h 12-hour format of an hour with leading zeros "01" through "12" * H 24-hour format of an hour with leading zeros "00" through "23" * i Minutes with leading zeros "00" to "59" * s Seconds, with leading zeros "00" through "59" * u Milliseconds "54321" * e Timezone identifier "UTC", "EST", "PST" * I Whether or not the date is in daylight saving time (uppercase i) "1" if Daylight Saving Time, "0" otherwise * O Difference to Greenwich time (GMT) in hours "+0200", "-0600" * P Difference to Greenwich time (GMT) with colon between hours and minutes "+02:00", "-06:00" * T Timezone abbreviation "UTC", "EST", "PST" * Z Timezone offset in seconds. The offset for timezones west of UTC is "-43200" through "50400" * always negative, and for those east of UTC is always positive. * c ISO 8601 date "2004-02-12T15:19:21+00:00" * r RFC 2822 formatted date "Thu, 21 Dec 2000 16:01:07 +0200" * U Seconds since the Unix Epoch (January 1 1970 00:00:00 GMT) "0" * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @return {String} A string representation of the current Date object. */ var formatReplace = function (context) { return function (m) { var formatString, override = false; if (m.charAt(0) === "\\" || m.substring(0, 2) === "%%") { return m.replace("\\", "").replace("%%", "%"); } override = normalizer.shouldOverrideDefaults(m); formatString = $D.normalizeFormat(m, context); if (formatString) { return context.toString(formatString, override); } }; }; $P._format = function (format) { var formatter = formatReplace(this); if (!format) { return this._toString(); } else { return format.replace(/(%|\\)?.|%%/g, formatter); } }; if (!$P.format) { $P.format = $P._format; } }()); (function () { "use strict"; var gFn = function (attr) { return function () { return this[attr]; }; }; var sFn = function (attr) { return function (val) { this[attr] = val; return this; }; }; var attrs = ["years", "months", "days", "hours", "minutes", "seconds", "milliseconds"]; var addSetFuncs = function (context, attrs) { for (var i = 0; i < attrs.length ; i++) { var $a = attrs[i], $b = $a.slice(0, 1).toUpperCase() + $a.slice(1); context.prototype[$a] = 0; context.prototype["get" + $b] = gFn($a); context.prototype["set" + $b] = sFn($a); } }; /** * new TimeSpan(milliseconds); * new TimeSpan(days, hours, minutes, seconds); * new TimeSpan(days, hours, minutes, seconds, milliseconds); */ var TimeSpan = function (days, hours, minutes, seconds, milliseconds) { if (arguments.length === 1 && typeof days === "number") { var orient = (days < 0) ? -1 : +1; var millsLeft = Math.abs(days); this.setDays(Math.floor(millsLeft / 86400000) * orient); millsLeft = millsLeft % 86400000; this.setHours(Math.floor(millsLeft / 3600000) * orient); millsLeft = millsLeft % 3600000; this.setMinutes(Math.floor(millsLeft / 60000) * orient); millsLeft = millsLeft % 60000; this.setSeconds(Math.floor(millsLeft / 1000) * orient); millsLeft = millsLeft % 1000; this.setMilliseconds(millsLeft * orient); } else { this.set(days, hours, minutes, seconds, milliseconds); } this.getTotalMilliseconds = function () { return (this.getDays() * 86400000) + (this.getHours() * 3600000) + (this.getMinutes() * 60000) + (this.getSeconds() * 1000); }; this.compareTo = function (time) { var t1 = new Date(1970, 1, 1, this.getHours(), this.getMinutes(), this.getSeconds()), t2; if (time === null) { t2 = new Date(1970, 1, 1, 0, 0, 0); } else { t2 = new Date(1970, 1, 1, time.getHours(), time.getMinutes(), time.getSeconds()); } return (t1 < t2) ? -1 : (t1 > t2) ? 1 : 0; }; this.equals = function (time) { return (this.compareTo(time) === 0); }; this.add = function (time) { return (time === null) ? this : this.addSeconds(time.getTotalMilliseconds() / 1000); }; this.subtract = function (time) { return (time === null) ? this : this.addSeconds(-time.getTotalMilliseconds() / 1000); }; this.addDays = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 86400000)); }; this.addHours = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 3600000)); }; this.addMinutes = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 60000)); }; this.addSeconds = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 1000)); }; this.addMilliseconds = function (n) { return new TimeSpan(this.getTotalMilliseconds() + n); }; this.get12HourHour = function () { return (this.getHours() > 12) ? this.getHours() - 12 : (this.getHours() === 0) ? 12 : this.getHours(); }; this.getDesignator = function () { return (this.getHours() < 12) ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator; }; this.toString = function (format) { this._toString = function () { if (this.getDays() !== null && this.getDays() > 0) { return this.getDays() + "." + this.getHours() + ":" + this.p(this.getMinutes()) + ":" + this.p(this.getSeconds()); } else { return this.getHours() + ":" + this.p(this.getMinutes()) + ":" + this.p(this.getSeconds()); } }; this.p = function (s) { return (s.toString().length < 2) ? "0" + s : s; }; var me = this; return format ? format.replace(/dd?|HH?|hh?|mm?|ss?|tt?/g, function (format) { switch (format) { case "d": return me.getDays(); case "dd": return me.p(me.getDays()); case "H": return me.getHours(); case "HH": return me.p(me.getHours()); case "h": return me.get12HourHour(); case "hh": return me.p(me.get12HourHour()); case "m": return me.getMinutes(); case "mm": return me.p(me.getMinutes()); case "s": return me.getSeconds(); case "ss": return me.p(me.getSeconds()); case "t": return ((me.getHours() < 12) ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator).substring(0, 1); case "tt": return (me.getHours() < 12) ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator; } } ) : this._toString(); }; return this; }; addSetFuncs(TimeSpan, attrs.slice(2)); TimeSpan.prototype.set = function (days, hours, minutes, seconds, milliseconds){ this.setDays(days || this.getDays()); this.setHours(hours || this.getHours()); this.setMinutes(minutes || this.getMinutes()); this.setSeconds(seconds || this.getSeconds()); this.setMilliseconds(milliseconds || this.getMilliseconds()); }; /** * Gets the time of day for this date instances. * @return {TimeSpan} TimeSpan */ Date.prototype.getTimeOfDay = function () { return new TimeSpan(0, this.getHours(), this.getMinutes(), this.getSeconds(), this.getMilliseconds()); }; Date.TimeSpan = TimeSpan; if (typeof window !== "undefined" ) { // keeping API compatible for v1.x window.TimeSpan = TimeSpan; } }()); (function () { "use strict"; var attrs = ["years", "months", "days", "hours", "minutes", "seconds", "milliseconds"]; var gFn = function (attr) { return function () { return this[attr]; }; }; var sFn = function (attr) { return function (val) { this[attr] = val; return this; }; }; var addSetFuncs = function (context, attrs) { for (var i = 0; i < attrs.length ; i++) { var $a = attrs[i], $b = $a.slice(0, 1).toUpperCase() + $a.slice(1); context.prototype[$a] = 0; context.prototype["get" + $b] = gFn($a); context.prototype["set" + $b] = sFn($a); } }; var setMonthsAndYears = function (orient, d1, d2, context) { function inc() { d1.addMonths(-orient); context.months++; if (context.months === 12) { context.years++; context.months = 0; } } if (orient === +1) { while (d1 > d2) { inc(); } } else { while (d1 < d2) { inc(); } } context.months--; context.months *= orient; context.years *= orient; }; var adjustForDST = function(orient, startDate, endDate) { var hasDSTMismatch = (false === (startDate.isDaylightSavingTime() === endDate.isDaylightSavingTime())); if (hasDSTMismatch && orient === 1) { startDate.addHours(-1); } else if (hasDSTMismatch) { startDate.addHours(1); } }; /** * TimePeriod(startDate, endDate); * TimePeriod(years, months, days, hours, minutes, seconds, milliseconds); */ var TimePeriod = function (years, months, days, hours, minutes, seconds, milliseconds) { if (arguments.length === 7) { this.set(years, months, days, hours, minutes, seconds, milliseconds); } else if (arguments.length === 2 && arguments[0] instanceof Date && arguments[1] instanceof Date) { var startDate = arguments[0].clone(); var endDate = arguments[1].clone(); var orient = (startDate > endDate) ? +1 : -1; this.dates = { start: arguments[0].clone(), end: arguments[1].clone() }; setMonthsAndYears(orient, startDate, endDate, this); adjustForDST(orient, startDate, endDate); // // TODO - adjust for DST var diff = endDate - startDate; if (diff !== 0) { var ts = new TimeSpan(diff); this.set(this.years, this.months, ts.getDays(), ts.getHours(), ts.getMinutes(), ts.getSeconds(), ts.getMilliseconds()); } } return this; }; // create all the set functions. addSetFuncs(TimePeriod, attrs); TimePeriod.prototype.set = function (years, months, days, hours, minutes, seconds, milliseconds){ this.setYears(years || this.getYears()); this.setMonths(months || this.getMonths()); this.setDays(days || this.getDays()); this.setHours(hours || this.getHours()); this.setMinutes(minutes || this.getMinutes()); this.setSeconds(seconds || this.getSeconds()); this.setMilliseconds(milliseconds || this.getMilliseconds()); }; Date.TimePeriod = TimePeriod; if (typeof window !== "undefined") { // keeping API compatible for v1.x window.TimePeriod = TimePeriod; } }()); ================================================ FILE: build/date-sr-Cyrl-BA.js ================================================ /** * @overview datejs * @version 1.0.0-rc3 * @author Gregory Wild-Smith * @copyright 2015 Gregory Wild-Smith * @license MIT * @homepage https://github.com/abritinthebay/datejs */ /* * DateJS Culture String File * Country Code: sr-Cyrl-BA * Name: Serbian (Cyrillic) (Bosnia and Herzegovina) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["sr-Cyrl-BA"] = { "name": "sr-Cyrl-BA", "englishName": "Serbian (Cyrillic) (Bosnia and Herzegovina)", "nativeName": "српски (Босна и Херцеговина)", "Sunday": "недеља", "Monday": "понедељак", "Tuesday": "уторак", "Wednesday": "среда", "Thursday": "четвртак", "Friday": "петак", "Saturday": "субота", "Sun": "нед", "Mon": "пон", "Tue": "уто", "Wed": "сре", "Thu": "чет", "Fri": "пет", "Sat": "суб", "Su": "нед", "Mo": "пон", "Tu": "уто", "We": "сре", "Th": "чет", "Fr": "пет", "Sa": "суб", "S_Sun_Initial": "н", "M_Mon_Initial": "п", "T_Tue_Initial": "у", "W_Wed_Initial": "с", "T_Thu_Initial": "ч", "F_Fri_Initial": "п", "S_Sat_Initial": "с", "January": "јануар", "February": "фебруар", "March": "март", "April": "април", "May": "мај", "June": "јун", "July": "јул", "August": "август", "September": "септембар", "October": "октобар", "November": "новембар", "December": "децембар", "Jan_Abbr": "јан", "Feb_Abbr": "феб", "Mar_Abbr": "мар", "Apr_Abbr": "апр", "May_Abbr": "мај", "Jun_Abbr": "јун", "Jul_Abbr": "јул", "Aug_Abbr": "авг", "Sep_Abbr": "сеп", "Oct_Abbr": "окт", "Nov_Abbr": "нов", "Dec_Abbr": "дец", "AM": "", "PM": "", "firstDayOfWeek": 1, "twoDigitYearMax": 2029, "mdy": "dmy", "M/d/yyyy": "d.M.yyyy", "dddd, MMMM dd, yyyy": "d. MMMM yyyy", "h:mm tt": "H:mm:ss", "h:mm:ss tt": "H:mm:ss", "dddd, MMMM dd, yyyy h:mm:ss tt": "d. MMMM yyyy H:mm:ss", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "MMMM dd", "MMMM, yyyy": "MMMM, yyyy", "/jan(uary)?/": "јан(уар)?", "/feb(ruary)?/": "феб(руар)?", "/mar(ch)?/": "мар(т)?", "/apr(il)?/": "апр(ил)?", "/may/": "мај", "/jun(e)?/": "јун", "/jul(y)?/": "јул", "/aug(ust)?/": "авг(уст)?", "/sep(t(ember)?)?/": "сеп(тембар)?", "/oct(ober)?/": "окт(обар)?", "/nov(ember)?/": "нов(ембар)?", "/dec(ember)?/": "дец(ембар)?", "/^su(n(day)?)?/": "^недеља", "/^mo(n(day)?)?/": "^понедељак", "/^tu(e(s(day)?)?)?/": "^уторак", "/^we(d(nesday)?)?/": "^среда", "/^th(u(r(s(day)?)?)?)?/": "^четвртак", "/^fr(i(day)?)?/": "^петак", "/^sa(t(urday)?)?/": "^субота", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "sr-Cyrl-BA"; /** * @overview datejs * @version 1.0.0-rc3 * @author Gregory Wild-Smith * @copyright 2015 Gregory Wild-Smith * @license MIT * @homepage https://github.com/abritinthebay/datejs */(function () { var $D = Date; var lang = Date.CultureStrings ? Date.CultureStrings.lang : null; var loggedKeys = {}; // for debug purposes. var getText = { getFromKey: function (key, countryCode) { var output; if (Date.CultureStrings && Date.CultureStrings[countryCode] && Date.CultureStrings[countryCode][key]) { output = Date.CultureStrings[countryCode][key]; } else { output = getText.buildFromDefault(key); } if (key.charAt(0) === "/") { // Assume it's a regex output = getText.buildFromRegex(key, countryCode); } return output; }, getFromObjectValues: function (obj, countryCode) { var key, output = {}; for(key in obj) { if (obj.hasOwnProperty(key)) { output[key] = getText.getFromKey(obj[key], countryCode); } } return output; }, getFromObjectKeys: function (obj, countryCode) { var key, output = {}; for(key in obj) { if (obj.hasOwnProperty(key)) { output[getText.getFromKey(key, countryCode)] = obj[key]; } } return output; }, getFromArray: function (arr, countryCode) { var output = []; for (var i=0; i < arr.length; i++){ if (i in arr) { output[i] = getText.getFromKey(arr[i], countryCode); } } return output; }, buildFromDefault: function (key) { var output, length, split, last; switch(key) { case "name": output = "en-US"; break; case "englishName": output = "English (United States)"; break; case "nativeName": output = "English (United States)"; break; case "twoDigitYearMax": output = 2049; break; case "firstDayOfWeek": output = 0; break; default: output = key; split = key.split("_"); length = split.length; if (length > 1 && key.charAt(0) !== "/") { // if the key isn't a regex and it has a split. last = split[(length - 1)].toLowerCase(); if (last === "initial" || last === "abbr") { output = split[0]; } } break; } return output; }, buildFromRegex: function (key, countryCode) { var output; if (Date.CultureStrings && Date.CultureStrings[countryCode] && Date.CultureStrings[countryCode][key]) { output = new RegExp(Date.CultureStrings[countryCode][key], "i"); } else { output = new RegExp(key.replace(new RegExp("/", "g"),""), "i"); } return output; } }; var shallowMerge = function (obj1, obj2) { for (var attrname in obj2) { if (obj2.hasOwnProperty(attrname)) { obj1[attrname] = obj2[attrname]; } } }; var __ = function (key, language) { var countryCode = (language) ? language : lang; loggedKeys[key] = key; if (typeof key === "object") { if (key instanceof Array) { return getText.getFromArray(key, countryCode); } else { return getText.getFromObjectKeys(key, countryCode); } } else { return getText.getFromKey(key, countryCode); } }; var loadI18nScript = function (code) { // paatterned after jQuery's getScript. var url = Date.Config.i18n + code + ".js"; var head = document.getElementsByTagName("head")[0] || document.documentElement; var script = document.createElement("script"); script.src = url; var completed = false; var events = { done: function (){} // placeholder function }; // Attach handlers for all browsers script.onload = script.onreadystatechange = function() { if ( !completed && (!this.readyState || this.readyState === "loaded" || this.readyState === "complete") ) { events.done(); head.removeChild(script); } }; setTimeout(function() { head.insertBefore(script, head.firstChild); }, 0); // allows return to execute first return { done: function (cb) { events.done = function() { if (cb) { setTimeout(cb,0); } }; } }; }; var buildInfo = { buildFromMethodHash: function (obj) { var key; for(key in obj) { if (obj.hasOwnProperty(key)) { obj[key] = buildInfo[obj[key]](); } } return obj; }, timeZoneDST: function () { var DST = { "CHADT": "+1345", "NZDT": "+1300", "AEDT": "+1100", "ACDT": "+1030", "AZST": "+0500", "IRDT": "+0430", "EEST": "+0300", "CEST": "+0200", "BST": "+0100", "PMDT": "-0200", "ADT": "-0300", "NDT": "-0230", "EDT": "-0400", "CDT": "-0500", "MDT": "-0600", "PDT": "-0700", "AKDT": "-0800", "HADT": "-0900" }; return __(DST); }, timeZoneStandard: function () { var standard = { "LINT": "+1400", "TOT": "+1300", "CHAST": "+1245", "NZST": "+1200", "NFT": "+1130", "SBT": "+1100", "AEST": "+1000", "ACST": "+0930", "JST": "+0900", "CWST": "+0845", "CT": "+0800", "ICT": "+0700", "MMT": "+0630", "BST": "+0600", "NPT": "+0545", "IST": "+0530", "PKT": "+0500", "AFT": "+0430", "MSK": "+0400", "IRST": "+0330", "FET": "+0300", "EET": "+0200", "CET": "+0100", "GMT": "+0000", "UTC": "+0000", "CVT": "-0100", "GST": "-0200", "BRT": "-0300", "NST": "-0330", "AST": "-0400", "EST": "-0500", "CST": "-0600", "MST": "-0700", "PST": "-0800", "AKST": "-0900", "MIT": "-0930", "HST": "-1000", "SST": "-1100", "BIT": "-1200" }; return __(standard); }, timeZones: function (data) { var zone; data.timezones = []; for (zone in data.abbreviatedTimeZoneStandard) { if (data.abbreviatedTimeZoneStandard.hasOwnProperty(zone)) { data.timezones.push({ name: zone, offset: data.abbreviatedTimeZoneStandard[zone]}); } } for (zone in data.abbreviatedTimeZoneDST) { if (data.abbreviatedTimeZoneDST.hasOwnProperty(zone)) { data.timezones.push({ name: zone, offset: data.abbreviatedTimeZoneDST[zone], dst: true}); } } return data.timezones; }, days: function () { return __(["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"]); }, dayAbbr: function () { return __(["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"]); }, dayShortNames: function () { return __(["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"]); }, dayFirstLetters: function () { return __(["S_Sun_Initial", "M_Mon_Initial", "T_Tues_Initial", "W_Wed_Initial", "T_Thu_Initial", "F_Fri_Initial", "S_Sat_Initial"]); }, months: function () { return __(["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"]); }, monthAbbr: function () { return __(["Jan_Abbr", "Feb_Abbr", "Mar_Abbr", "Apr_Abbr", "May_Abbr", "Jun_Abbr", "Jul_Abbr", "Aug_Abbr", "Sep_Abbr", "Oct_Abbr", "Nov_Abbr", "Dec_Abbr"]); }, formatPatterns: function () { return getText.getFromObjectValues({ shortDate: "M/d/yyyy", longDate: "dddd, MMMM dd, yyyy", shortTime: "h:mm tt", longTime: "h:mm:ss tt", fullDateTime: "dddd, MMMM dd, yyyy h:mm:ss tt", sortableDateTime: "yyyy-MM-ddTHH:mm:ss", universalSortableDateTime: "yyyy-MM-dd HH:mm:ssZ", rfc1123: "ddd, dd MMM yyyy HH:mm:ss", monthDay: "MMMM dd", yearMonth: "MMMM, yyyy" }, Date.i18n.currentLanguage()); }, regex: function () { return getText.getFromObjectValues({ inTheMorning: "/( in the )(morn(ing)?)\\b/", thisMorning: "/(this )(morn(ing)?)\\b/", amThisMorning: "/(\b\\d(am)? )(this )(morn(ing)?)/", inTheEvening: "/( in the )(even(ing)?)\\b/", thisEvening: "/(this )(even(ing)?)\\b/", pmThisEvening: "/(\b\\d(pm)? )(this )(even(ing)?)/", jan: "/jan(uary)?/", feb: "/feb(ruary)?/", mar: "/mar(ch)?/", apr: "/apr(il)?/", may: "/may/", jun: "/jun(e)?/", jul: "/jul(y)?/", aug: "/aug(ust)?/", sep: "/sep(t(ember)?)?/", oct: "/oct(ober)?/", nov: "/nov(ember)?/", dec: "/dec(ember)?/", sun: "/^su(n(day)?)?/", mon: "/^mo(n(day)?)?/", tue: "/^tu(e(s(day)?)?)?/", wed: "/^we(d(nesday)?)?/", thu: "/^th(u(r(s(day)?)?)?)?/", fri: "/fr(i(day)?)?/", sat: "/^sa(t(urday)?)?/", future: "/^next/", past: "/^last|past|prev(ious)?/", add: "/^(\\+|aft(er)?|from|hence)/", subtract: "/^(\\-|bef(ore)?|ago)/", yesterday: "/^yes(terday)?/", today: "/^t(od(ay)?)?/", tomorrow: "/^tom(orrow)?/", now: "/^n(ow)?/", millisecond: "/^ms|milli(second)?s?/", second: "/^sec(ond)?s?/", minute: "/^mn|min(ute)?s?/", hour: "/^h(our)?s?/", week: "/^w(eek)?s?/", month: "/^m(onth)?s?/", day: "/^d(ay)?s?/", year: "/^y(ear)?s?/", shortMeridian: "/^(a|p)/", longMeridian: "/^(a\\.?m?\\.?|p\\.?m?\\.?)/", timezone: "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/", ordinalSuffix: "/^\\s*(st|nd|rd|th)/", timeContext: "/^\\s*(\\:|a(?!u|p)|p)/" }, Date.i18n.currentLanguage()); } }; var CultureInfo = function () { var info = getText.getFromObjectValues({ name: "name", englishName: "englishName", nativeName: "nativeName", amDesignator: "AM", pmDesignator: "PM", firstDayOfWeek: "firstDayOfWeek", twoDigitYearMax: "twoDigitYearMax", dateElementOrder: "mdy" }, Date.i18n.currentLanguage()); var constructedInfo = buildInfo.buildFromMethodHash({ dayNames: "days", abbreviatedDayNames: "dayAbbr", shortestDayNames: "dayShortNames", firstLetterDayNames: "dayFirstLetters", monthNames: "months", abbreviatedMonthNames: "monthAbbr", formatPatterns: "formatPatterns", regexPatterns: "regex", abbreviatedTimeZoneDST: "timeZoneDST", abbreviatedTimeZoneStandard: "timeZoneStandard" }); shallowMerge(info, constructedInfo); buildInfo.timeZones(info); return info; }; $D.i18n = { __: function (key, lang) { return __(key, lang); }, currentLanguage: function () { return lang || "en-US"; }, setLanguage: function (code, force, cb) { var async = false; if (force || code === "en-US" || (!!Date.CultureStrings && !!Date.CultureStrings[code])) { lang = code; Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings.lang = code; Date.CultureInfo = new CultureInfo(); } else { if (!(!!Date.CultureStrings && !!Date.CultureStrings[code])) { if (typeof exports !== "undefined" && this.exports !== exports) { // we're in a Node enviroment, load it using require try { require("../i18n/" + code + ".js"); lang = code; Date.CultureStrings.lang = code; Date.CultureInfo = new CultureInfo(); } catch (e) { // var str = "The language for '" + code + "' could not be loaded by Node. It likely does not exist."; throw new Error("The DateJS IETF language tag '" + code + "' could not be loaded by Node. It likely does not exist."); } } else if (Date.Config && Date.Config.i18n) { // we know the location of the files, so lets load them async = true; loadI18nScript(code).done(function(){ lang = code; Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings.lang = code; Date.CultureInfo = new CultureInfo(); $D.Parsing.Normalizer.buildReplaceData(); // because this is async if ($D.Grammar) { $D.Grammar.buildGrammarFormats(); // so we can parse those strings... } if (cb) { setTimeout(cb,0); } }); } else { Date.console.error("The DateJS IETF language tag '" + code + "' is not available and has not been loaded."); return false; } } } $D.Parsing.Normalizer.buildReplaceData(); // rebuild normalizer strings if ($D.Grammar) { $D.Grammar.buildGrammarFormats(); // so we can parse those strings... } if (!async && cb) { setTimeout(cb,0); } }, getLoggedKeys: function () { return loggedKeys; }, updateCultureInfo: function () { Date.CultureInfo = new CultureInfo(); } }; $D.i18n.updateCultureInfo(); // run automatically }()); (function () { var $D = Date, $P = $D.prototype, p = function (s, l) { if (!l) { l = 2; } return ("000" + s).slice(l * -1); }; if (typeof window !== "undefined" && typeof window.console !== "undefined" && typeof window.console.log !== "undefined") { $D.console = console; // used only to raise non-critical errors if available } else { // set mock so we don't give errors. $D.console = { log: function(){}, error: function(){} }; } $D.Config = $D.Config || {}; $D.initOverloads = function() { /** * Overload of Date.now. Allows an alternate call for Date.now where it returns the * current Date as an object rather than just milliseconds since the Unix Epoch. * * Also provides an implementation of now() for browsers (IE<9) that don't have it. * * Backwards compatible so with work with either: * Date.now() [returns ms] * or * Date.now(true) [returns Date] */ if (!$D.now) { $D._now = function now() { return new Date().getTime(); }; } else if (!$D._now) { $D._now = $D.now; } $D.now = function (returnObj) { if (returnObj) { return $D.present(); } else { return $D._now(); } }; if ( !$P.toISOString ) { $P.toISOString = function() { return this.getUTCFullYear() + "-" + p(this.getUTCMonth() + 1) + "-" + p(this.getUTCDate()) + "T" + p(this.getUTCHours()) + ":" + p(this.getUTCMinutes()) + ":" + p(this.getUTCSeconds()) + "." + String( (this.getUTCMilliseconds()/1000).toFixed(3)).slice(2, 5) + "Z"; }; } // private if ( $P._toString === undefined ){ $P._toString = $P.toString; } }; $D.initOverloads(); /** * Gets a date that is set to the current date. The time is set to the start of the day (00:00 or 12:00 AM). * @return {Date} The current date. */ $D.today = function () { return new Date().clearTime(); }; /** * Gets a date that is set to the current date and time (same as new Date, but chainable) * @return {Date} The current date. */ $D.present = function () { return new Date(); }; /** * Compares the first date to the second date and returns an number indication of their relative values. * @param {Date} First Date object to compare [Required]. * @param {Date} Second Date object to compare to [Required]. * @return {Number} -1 = date1 is lessthan date2. 0 = values are equal. 1 = date1 is greaterthan date2. */ $D.compare = function (date1, date2) { if (isNaN(date1) || isNaN(date2)) { throw new Error(date1 + " - " + date2); } else if (date1 instanceof Date && date2 instanceof Date) { return (date1 < date2) ? -1 : (date1 > date2) ? 1 : 0; } else { throw new TypeError(date1 + " - " + date2); } }; /** * Compares the first Date object to the second Date object and returns true if they are equal. * @param {Date} First Date object to compare [Required] * @param {Date} Second Date object to compare to [Required] * @return {Boolean} true if dates are equal. false if they are not equal. */ $D.equals = function (date1, date2) { return (date1.compareTo(date2) === 0); }; /** * Gets the language appropriate day name when given the day number(0-6) * eg - 0 == Sunday * @return {String} The day name */ $D.getDayName = function (n) { return Date.CultureInfo.dayNames[n]; }; /** * Gets the day number (0-6) if given a CultureInfo specific string which is a valid dayName, abbreviatedDayName or shortestDayName (two char). * @param {String} The name of the day (eg. "Monday, "Mon", "tuesday", "tue", "We", "we"). * @return {Number} The day number */ $D.getDayNumberFromName = function (name) { var n = Date.CultureInfo.dayNames, m = Date.CultureInfo.abbreviatedDayNames, o = Date.CultureInfo.shortestDayNames, s = name.toLowerCase(); for (var i = 0; i < n.length; i++) { if (n[i].toLowerCase() === s || m[i].toLowerCase() === s || o[i].toLowerCase() === s) { return i; } } return -1; }; /** * Gets the month number (0-11) if given a Culture Info specific string which is a valid monthName or abbreviatedMonthName. * @param {String} The name of the month (eg. "February, "Feb", "october", "oct"). * @return {Number} The day number */ $D.getMonthNumberFromName = function (name) { var n = Date.CultureInfo.monthNames, m = Date.CultureInfo.abbreviatedMonthNames, s = name.toLowerCase(); for (var i = 0; i < n.length; i++) { if (n[i].toLowerCase() === s || m[i].toLowerCase() === s) { return i; } } return -1; }; /** * Gets the language appropriate month name when given the month number(0-11) * eg - 0 == January * @return {String} The month name */ $D.getMonthName = function (n) { return Date.CultureInfo.monthNames[n]; }; /** * Determines if the current date instance is within a LeapYear. * @param {Number} The year. * @return {Boolean} true if date is within a LeapYear, otherwise false. */ $D.isLeapYear = function (year) { return ((year % 4 === 0 && year % 100 !== 0) || year % 400 === 0); }; /** * Gets the number of days in the month, given a year and month value. Automatically corrects for LeapYear. * @param {Number} The year. * @param {Number} The month (0-11). * @return {Number} The number of days in the month. */ $D.getDaysInMonth = function (year, month) { if (!month && $D.validateMonth(year)) { month = year; year = Date.today().getFullYear(); } return [31, ($D.isLeapYear(year) ? 29 : 28), 31, 30, 31, 30, 31, 31, 30, 31, 30, 31][month]; }; $P.getDaysInMonth = function () { return $D.getDaysInMonth(this.getFullYear(), this.getMonth()); }; $D.getTimezoneAbbreviation = function (offset, dst) { var p, n = (dst || false) ? Date.CultureInfo.abbreviatedTimeZoneDST : Date.CultureInfo.abbreviatedTimeZoneStandard; for (p in n) { if (n.hasOwnProperty(p)) { if (n[p] === offset) { return p; } } } return null; }; $D.getTimezoneOffset = function (name, dst) { var i, a =[], z = Date.CultureInfo.timezones; if (!name) { name = (new Date()).getTimezone();} for (i = 0; i < z.length; i++) { if (z[i].name === name.toUpperCase()) { a.push(i); } } if (!z[a[0]]) { return null; } if (a.length === 1 || !dst) { return z[a[0]].offset; } else { for (i=0; i < a.length; i++) { if (z[a[i]].dst) { return z[a[i]].offset; } } } }; $D.getQuarter = function (d) { d = d || new Date(); // If no date supplied, use today var q = [1,2,3,4]; return q[Math.floor(d.getMonth() / 3)]; // ~~~ is a bitwise op. Faster than Math.floor }; $D.getDaysLeftInQuarter = function (d) { d = d || new Date(); var qEnd = new Date(d); qEnd.setMonth(qEnd.getMonth() + 3 - qEnd.getMonth() % 3, 0); return Math.floor((qEnd - d) / 8.64e7); }; // private var validate = function (n, min, max, name) { name = name ? name : "Object"; if (typeof n === "undefined") { return false; } else if (typeof n !== "number") { throw new TypeError(n + " is not a Number."); } else if (n < min || n > max) { // As failing validation is *not* an exceptional circumstance // lets not throw a RangeError Exception here. // It's semantically correct but it's not sensible. return false; } return true; }; /** * Validates the number is within an acceptable range for milliseconds [0-999]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateMillisecond = function (value) { return validate(value, 0, 999, "millisecond"); }; /** * Validates the number is within an acceptable range for seconds [0-59]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateSecond = function (value) { return validate(value, 0, 59, "second"); }; /** * Validates the number is within an acceptable range for minutes [0-59]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateMinute = function (value) { return validate(value, 0, 59, "minute"); }; /** * Validates the number is within an acceptable range for hours [0-23]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateHour = function (value) { return validate(value, 0, 23, "hour"); }; /** * Validates the number is within an acceptable range for the days in a month [0-MaxDaysInMonth]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateDay = function (value, year, month) { if (year === undefined || year === null || month === undefined || month === null) { return false;} return validate(value, 1, $D.getDaysInMonth(year, month), "day"); }; /** * Validates the number is within an acceptable range for months [0-11]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateWeek = function (value) { return validate(value, 0, 53, "week"); }; /** * Validates the number is within an acceptable range for months [0-11]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateMonth = function (value) { return validate(value, 0, 11, "month"); }; /** * Validates the number is within an acceptable range for years. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateYear = function (value) { /** * Per ECMAScript spec the range of times supported by Date objects is * exactly -100,000,000 days to +100,000,000 days measured relative to * midnight at the beginning of 01 January, 1970 UTC. * This gives a range of 8,640,000,000,000,000 milliseconds to either * side of 01 January, 1970 UTC. * * Earliest possible date: Tue, 20 Apr 271,822 B.C. 00:00:00 UTC * Latest possible date: Sat, 13 Sep 275,760 00:00:00 UTC */ return validate(value, -271822, 275760, "year"); }; $D.validateTimezone = function(value) { var timezones = {"ACDT":1,"ACST":1,"ACT":1,"ADT":1,"AEDT":1,"AEST":1,"AFT":1,"AKDT":1,"AKST":1,"AMST":1,"AMT":1,"ART":1,"AST":1,"AWDT":1,"AWST":1,"AZOST":1,"AZT":1,"BDT":1,"BIOT":1,"BIT":1,"BOT":1,"BRT":1,"BST":1,"BTT":1,"CAT":1,"CCT":1,"CDT":1,"CEDT":1,"CEST":1,"CET":1,"CHADT":1,"CHAST":1,"CHOT":1,"ChST":1,"CHUT":1,"CIST":1,"CIT":1,"CKT":1,"CLST":1,"CLT":1,"COST":1,"COT":1,"CST":1,"CT":1,"CVT":1,"CWST":1,"CXT":1,"DAVT":1,"DDUT":1,"DFT":1,"EASST":1,"EAST":1,"EAT":1,"ECT":1,"EDT":1,"EEDT":1,"EEST":1,"EET":1,"EGST":1,"EGT":1,"EIT":1,"EST":1,"FET":1,"FJT":1,"FKST":1,"FKT":1,"FNT":1,"GALT":1,"GAMT":1,"GET":1,"GFT":1,"GILT":1,"GIT":1,"GMT":1,"GST":1,"GYT":1,"HADT":1,"HAEC":1,"HAST":1,"HKT":1,"HMT":1,"HOVT":1,"HST":1,"ICT":1,"IDT":1,"IOT":1,"IRDT":1,"IRKT":1,"IRST":1,"IST":1,"JST":1,"KGT":1,"KOST":1,"KRAT":1,"KST":1,"LHST":1,"LINT":1,"MAGT":1,"MART":1,"MAWT":1,"MDT":1,"MET":1,"MEST":1,"MHT":1,"MIST":1,"MIT":1,"MMT":1,"MSK":1,"MST":1,"MUT":1,"MVT":1,"MYT":1,"NCT":1,"NDT":1,"NFT":1,"NPT":1,"NST":1,"NT":1,"NUT":1,"NZDT":1,"NZST":1,"OMST":1,"ORAT":1,"PDT":1,"PET":1,"PETT":1,"PGT":1,"PHOT":1,"PHT":1,"PKT":1,"PMDT":1,"PMST":1,"PONT":1,"PST":1,"PYST":1,"PYT":1,"RET":1,"ROTT":1,"SAKT":1,"SAMT":1,"SAST":1,"SBT":1,"SCT":1,"SGT":1,"SLST":1,"SRT":1,"SST":1,"SYOT":1,"TAHT":1,"THA":1,"TFT":1,"TJT":1,"TKT":1,"TLT":1,"TMT":1,"TOT":1,"TVT":1,"UCT":1,"ULAT":1,"UTC":1,"UYST":1,"UYT":1,"UZT":1,"VET":1,"VLAT":1,"VOLT":1,"VOST":1,"VUT":1,"WAKT":1,"WAST":1,"WAT":1,"WEDT":1,"WEST":1,"WET":1,"WST":1,"YAKT":1,"YEKT":1,"Z":1}; return (timezones[value] === 1); }; $D.validateTimezoneOffset= function(value) { // timezones go from +14hrs to -12hrs, the +X hours are negative offsets. return (value > -841 && value < 721); }; }()); (function () { var $D = Date, $P = $D.prototype, p = function (s, l) { if (!l) { l = 2; } return ("000" + s).slice(l * -1); }; var validateConfigObject = function (obj) { var result = {}, self = this, prop, testFunc; testFunc = function (prop, func, value) { if (prop === "day") { var month = (obj.month !== undefined) ? obj.month : self.getMonth(); var year = (obj.year !== undefined) ? obj.year : self.getFullYear(); return $D[func](value, year, month); } else { return $D[func](value); } }; for (prop in obj) { if (Object.prototype.hasOwnProperty.call(obj, prop)) { var func = "validate" + prop.charAt(0).toUpperCase() + prop.slice(1); if ($D[func] && obj[prop] !== null && testFunc(prop, func, obj[prop])) { result[prop] = obj[prop]; } } } return result; }; /** * Resets the time of this Date object to 12:00 AM (00:00), which is the start of the day. * @param {Boolean} .clone() this date instance before clearing Time * @return {Date} this */ $P.clearTime = function () { this.setHours(0); this.setMinutes(0); this.setSeconds(0); this.setMilliseconds(0); return this; }; /** * Resets the time of this Date object to the current time ('now'). * @return {Date} this */ $P.setTimeToNow = function () { var n = new Date(); this.setHours(n.getHours()); this.setMinutes(n.getMinutes()); this.setSeconds(n.getSeconds()); this.setMilliseconds(n.getMilliseconds()); return this; }; /** * Returns a new Date object that is an exact date and time copy of the original instance. * @return {Date} A new Date instance */ $P.clone = function () { return new Date(this.getTime()); }; /** * Compares this instance to a Date object and returns an number indication of their relative values. * @param {Date} Date object to compare [Required] * @return {Number} -1 = this is lessthan date. 0 = values are equal. 1 = this is greaterthan date. */ $P.compareTo = function (date) { return Date.compare(this, date); }; /** * Compares this instance to another Date object and returns true if they are equal. * @param {Date} Date object to compare. If no date to compare, new Date() [now] is used. * @return {Boolean} true if dates are equal. false if they are not equal. */ $P.equals = function (date) { return Date.equals(this, (date !== undefined ? date : new Date())); }; /** * Determines if this instance is between a range of two dates or equal to either the start or end dates. * @param {Date} Start of range [Required] * @param {Date} End of range [Required] * @return {Boolean} true is this is between or equal to the start and end dates, else false */ $P.between = function (start, end) { return this.getTime() >= start.getTime() && this.getTime() <= end.getTime(); }; /** * Determines if this date occurs after the date to compare to. * @param {Date} Date object to compare. If no date to compare, new Date() ("now") is used. * @return {Boolean} true if this date instance is greater than the date to compare to (or "now"), otherwise false. */ $P.isAfter = function (date) { return this.compareTo(date || new Date()) === 1; }; /** * Determines if this date occurs before the date to compare to. * @param {Date} Date object to compare. If no date to compare, new Date() ("now") is used. * @return {Boolean} true if this date instance is less than the date to compare to (or "now"). */ $P.isBefore = function (date) { return (this.compareTo(date || new Date()) === -1); }; /** * Determines if the current Date instance occurs today. * @return {Boolean} true if this date instance is 'today', otherwise false. */ /** * Determines if the current Date instance occurs on the same Date as the supplied 'date'. * If no 'date' to compare to is provided, the current Date instance is compared to 'today'. * @param {date} Date object to compare. If no date to compare, the current Date ("now") is used. * @return {Boolean} true if this Date instance occurs on the same Day as the supplied 'date'. */ $P.isToday = $P.isSameDay = function (date) { return this.clone().clearTime().equals((date || new Date()).clone().clearTime()); }; /** * Adds the specified number of milliseconds to this instance. * @param {Number} The number of milliseconds to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addMilliseconds = function (value) { if (!value) { return this; } this.setTime(this.getTime() + value * 1); return this; }; /** * Adds the specified number of seconds to this instance. * @param {Number} The number of seconds to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addSeconds = function (value) { if (!value) { return this; } return this.addMilliseconds(value * 1000); }; /** * Adds the specified number of seconds to this instance. * @param {Number} The number of seconds to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addMinutes = function (value) { if (!value) { return this; } return this.addMilliseconds(value * 60000); // 60*1000 }; /** * Adds the specified number of hours to this instance. * @param {Number} The number of hours to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addHours = function (value) { if (!value) { return this; } return this.addMilliseconds(value * 3600000); // 60*60*1000 }; /** * Adds the specified number of days to this instance. * @param {Number} The number of days to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addDays = function (value) { if (!value) { return this; } this.setDate(this.getDate() + value * 1); return this; }; /** * Adds the specified number of weekdays (ie - not sat or sun) to this instance. * @param {Number} The number of days to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addWeekdays = function (value) { if (!value) { return this; } var day = this.getDay(); var weeks = (Math.ceil(Math.abs(value)/7)); if (day === 0 || day === 6) { if (value > 0) { this.next().monday(); this.addDays(-1); day = this.getDay(); } } if (value < 0) { while (value < 0) { this.addDays(-1); day = this.getDay(); if (day !== 0 && day !== 6) { value++; } } return this; } else if (value > 5 || (6-day) <= value) { value = value + (weeks * 2); } return this.addDays(value); }; /** * Adds the specified number of weeks to this instance. * @param {Number} The number of weeks to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addWeeks = function (value) { if (!value) { return this; } return this.addDays(value * 7); }; /** * Adds the specified number of months to this instance. * @param {Number} The number of months to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addMonths = function (value) { if (!value) { return this; } var n = this.getDate(); this.setDate(1); this.setMonth(this.getMonth() + value * 1); this.setDate(Math.min(n, $D.getDaysInMonth(this.getFullYear(), this.getMonth()))); return this; }; $P.addQuarters = function (value) { if (!value) { return this; } // note this will take you to the same point in the quarter as you are now. // i.e. - if you are 15 days into the quarter you'll be 15 days into the resulting one. // bonus: this allows adding fractional quarters return this.addMonths(value * 3); }; /** * Adds the specified number of years to this instance. * @param {Number} The number of years to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addYears = function (value) { if (!value) { return this; } return this.addMonths(value * 12); }; /** * Adds (or subtracts) to the value of the years, months, weeks, days, hours, minutes, seconds, milliseconds of the date instance using given configuration object. Positive and Negative values allowed. * Example

	Date.today().add( { days: 1, months: 1 } )

	new Date().add( { years: -1 } )
	
* @param {Object} Configuration object containing attributes (months, days, etc.) * @return {Date} this */ $P.add = function (config) { if (typeof config === "number") { this._orient = config; return this; } var x = config; if (x.day) { // If we should be a different date than today (eg: for 'tomorrow -1d', etc). // Should only effect parsing, not direct usage (eg, Finish and FinishExact) if ((x.day - this.getDate()) !== 0) { this.setDate(x.day); } } if (x.milliseconds) { this.addMilliseconds(x.milliseconds); } if (x.seconds) { this.addSeconds(x.seconds); } if (x.minutes) { this.addMinutes(x.minutes); } if (x.hours) { this.addHours(x.hours); } if (x.weeks) { this.addWeeks(x.weeks); } if (x.months) { this.addMonths(x.months); } if (x.years) { this.addYears(x.years); } if (x.days) { this.addDays(x.days); } return this; }; /** * Get the week number. Week one (1) is the week which contains the first Thursday of the year. Monday is considered the first day of the week. * The .getWeek() function does NOT convert the date to UTC. The local datetime is used. * Please use .getISOWeek() to get the week of the UTC converted date. * @return {Number} 1 to 53 */ $P.getWeek = function (utc) { // Create a copy of this date object var self, target = new Date(this.valueOf()); if (utc) { target.addMinutes(target.getTimezoneOffset()); self = target.clone(); } else { self = this; } // ISO week date weeks start on monday // so correct the day number var dayNr = (self.getDay() + 6) % 7; // ISO 8601 states that week 1 is the week // with the first thursday of that year. // Set the target date to the thursday in the target week target.setDate(target.getDate() - dayNr + 3); // Store the millisecond value of the target date var firstThursday = target.valueOf(); // Set the target to the first thursday of the year // First set the target to january first target.setMonth(0, 1); // Not a thursday? Correct the date to the next thursday if (target.getDay() !== 4) { target.setMonth(0, 1 + ((4 - target.getDay()) + 7) % 7); } // The weeknumber is the number of weeks between the // first thursday of the year and the thursday in the target week return 1 + Math.ceil((firstThursday - target) / 604800000); // 604800000 = 7 * 24 * 3600 * 1000 }; /** * Get the ISO 8601 week number. Week one ("01") is the week which contains the first Thursday of the year. Monday is considered the first day of the week. * The .getISOWeek() function does convert the date to it's UTC value. Please use .getWeek() to get the week of the local date. * @return {String} "01" to "53" */ $P.getISOWeek = function () { return p(this.getWeek(true)); }; /** * Moves the date to Monday of the week set. Week one (1) is the week which contains the first Thursday of the year. * @param {Number} A Number (1 to 53) that represents the week of the year. * @return {Date} this */ $P.setWeek = function (n) { if ((n - this.getWeek()) === 0) { if (this.getDay() !== 1) { return this.moveToDayOfWeek(1, (this.getDay() > 1 ? -1 : 1)); } else { return this; } } else { return this.moveToDayOfWeek(1, (this.getDay() > 1 ? -1 : 1)).addWeeks(n - this.getWeek()); } }; $P.setQuarter = function (qtr) { var month = Math.abs(((qtr-1) * 3) + 1); return this.setMonth(month, 1); }; $P.getQuarter = function () { return Date.getQuarter(this); }; $P.getDaysLeftInQuarter = function () { return Date.getDaysLeftInQuarter(this); }; /** * Moves the date to the next n'th occurrence of the dayOfWeek starting from the beginning of the month. The number (-1) is a magic number and will return the last occurrence of the dayOfWeek in the month. * @param {Number} The dayOfWeek to move to * @param {Number} The n'th occurrence to move to. Use (-1) to return the last occurrence in the month * @return {Date} this */ $P.moveToNthOccurrence = function (dayOfWeek, occurrence) { if (dayOfWeek === "Weekday") { if (occurrence > 0) { this.moveToFirstDayOfMonth(); if (this.is().weekday()) { occurrence -= 1; } } else if (occurrence < 0) { this.moveToLastDayOfMonth(); if (this.is().weekday()) { occurrence += 1; } } else { return this; } return this.addWeekdays(occurrence); } var shift = 0; if (occurrence > 0) { shift = occurrence - 1; } else if (occurrence === -1) { this.moveToLastDayOfMonth(); if (this.getDay() !== dayOfWeek) { this.moveToDayOfWeek(dayOfWeek, -1); } return this; } return this.moveToFirstDayOfMonth().addDays(-1).moveToDayOfWeek(dayOfWeek, +1).addWeeks(shift); }; var moveToN = function (getFunc, addFunc, nVal) { return function (value, orient) { var diff = (value - this[getFunc]() + nVal * (orient || +1)) % nVal; return this[addFunc]((diff === 0) ? diff += nVal * (orient || +1) : diff); }; }; /** * Move to the next or last dayOfWeek based on the orient value. * @param {Number} The dayOfWeek to move to * @param {Number} Forward (+1) or Back (-1). Defaults to +1. [Optional] * @return {Date} this */ $P.moveToDayOfWeek = moveToN("getDay", "addDays", 7); /** * Move to the next or last month based on the orient value. * @param {Number} The month to move to. 0 = January, 11 = December * @param {Number} Forward (+1) or Back (-1). Defaults to +1. [Optional] * @return {Date} this */ $P.moveToMonth = moveToN("getMonth", "addMonths", 12); /** * Get the Ordinate of the current day ("th", "st", "rd"). * @return {String} */ $P.getOrdinate = function () { var num = this.getDate(); return ord(num); }; /** * Get the Ordinal day (numeric day number) of the year, adjusted for leap year. * @return {Number} 1 through 365 (366 in leap years) */ $P.getOrdinalNumber = function () { return Math.ceil((this.clone().clearTime() - new Date(this.getFullYear(), 0, 1)) / 86400000) + 1; }; /** * Get the time zone abbreviation of the current date. * @return {String} The abbreviated time zone name (e.g. "EST") */ $P.getTimezone = function () { return $D.getTimezoneAbbreviation(this.getUTCOffset(), this.isDaylightSavingTime()); }; $P.setTimezoneOffset = function (offset) { var here = this.getTimezoneOffset(), there = Number(offset) * -6 / 10; return (there || there === 0) ? this.addMinutes(there - here) : this; }; $P.setTimezone = function (offset) { return this.setTimezoneOffset($D.getTimezoneOffset(offset)); }; /** * Indicates whether Daylight Saving Time is observed in the current time zone. * @return {Boolean} true|false */ $P.hasDaylightSavingTime = function () { return (Date.today().set({month: 0, day: 1}).getTimezoneOffset() !== Date.today().set({month: 6, day: 1}).getTimezoneOffset()); }; /** * Indicates whether this Date instance is within the Daylight Saving Time range for the current time zone. * @return {Boolean} true|false */ $P.isDaylightSavingTime = function () { return Date.today().set({month: 0, day: 1}).getTimezoneOffset() !== this.getTimezoneOffset(); }; /** * Get the offset from UTC of the current date. * @return {String} The 4-character offset string prefixed with + or - (e.g. "-0500") */ $P.getUTCOffset = function (offset) { var n = (offset || this.getTimezoneOffset()) * -10 / 6, r; if (n < 0) { r = (n - 10000).toString(); return r.charAt(0) + r.substr(2); } else { r = (n + 10000).toString(); return "+" + r.substr(1); } }; /** * Returns the number of milliseconds between this date and date. * @param {Date} Defaults to now * @return {Number} The diff in milliseconds */ $P.getElapsed = function (date) { return (date || new Date()) - this; }; /** * Set the value of year, month, day, hour, minute, second, millisecond of date instance using given configuration object. * Example

	Date.today().set( { day: 20, month: 1 } )

	new Date().set( { millisecond: 0 } )
	
* * @param {Object} Configuration object containing attributes (month, day, etc.) * @return {Date} this */ $P.set = function (config) { config = validateConfigObject.call(this, config); var key; for (key in config) { if (Object.prototype.hasOwnProperty.call(config, key)) { var name = key.charAt(0).toUpperCase() + key.slice(1); var addFunc, getFunc; if (key !== "week" && key !== "month" && key !== "timezone" && key !== "timezoneOffset") { name += "s"; } addFunc = "add" + name; getFunc = "get" + name; if (key === "month") { addFunc = addFunc + "s"; } else if (key === "year"){ getFunc = "getFullYear"; } if (key !== "day" && key !== "timezone" && key !== "timezoneOffset" && key !== "week" && key !== "hour") { this[addFunc](config[key] - this[getFunc]()); } else if ( key === "timezone"|| key === "timezoneOffset" || key === "week" || key === "hour") { this["set"+name](config[key]); } } } // day has to go last because you can't validate the day without first knowing the month if (config.day) { this.addDays(config.day - this.getDate()); } return this; }; /** * Moves the date to the first day of the month. * @return {Date} this */ $P.moveToFirstDayOfMonth = function () { return this.set({ day: 1 }); }; /** * Moves the date to the last day of the month. * @return {Date} this */ $P.moveToLastDayOfMonth = function () { return this.set({ day: $D.getDaysInMonth(this.getFullYear(), this.getMonth())}); }; /** * Converts the value of the current Date object to its equivalent string representation. * Format Specifiers * CUSTOM DATE AND TIME FORMAT STRINGS * Format Description Example * ------ --------------------------------------------------------------------------- ----------------------- * s The seconds of the minute between 0-59. "0" to "59" * ss The seconds of the minute with leading zero if required. "00" to "59" * * m The minute of the hour between 0-59. "0" or "59" * mm The minute of the hour with leading zero if required. "00" or "59" * * h The hour of the day between 1-12. "1" to "12" * hh The hour of the day with leading zero if required. "01" to "12" * * H The hour of the day between 0-23. "0" to "23" * HH The hour of the day with leading zero if required. "00" to "23" * * d The day of the month between 1 and 31. "1" to "31" * dd The day of the month with leading zero if required. "01" to "31" * ddd Abbreviated day name. Date.CultureInfo.abbreviatedDayNames. "Mon" to "Sun" * dddd The full day name. Date.CultureInfo.dayNames. "Monday" to "Sunday" * * M The month of the year between 1-12. "1" to "12" * MM The month of the year with leading zero if required. "01" to "12" * MMM Abbreviated month name. Date.CultureInfo.abbreviatedMonthNames. "Jan" to "Dec" * MMMM The full month name. Date.CultureInfo.monthNames. "January" to "December" * * yy The year as a two-digit number. "99" or "08" * yyyy The full four digit year. "1999" or "2008" * * t Displays the first character of the A.M./P.M. designator. "A" or "P" * Date.CultureInfo.amDesignator or Date.CultureInfo.pmDesignator * tt Displays the A.M./P.M. designator. "AM" or "PM" * Date.CultureInfo.amDesignator or Date.CultureInfo.pmDesignator * * S The ordinal suffix ("st, "nd", "rd" or "th") of the current day. "st, "nd", "rd" or "th" * * STANDARD DATE AND TIME FORMAT STRINGS * Format Description Example *------ --------------------------------------------------------------------------- ----------------------- * d The CultureInfo shortDate Format Pattern "M/d/yyyy" * D The CultureInfo longDate Format Pattern "dddd, MMMM dd, yyyy" * F The CultureInfo fullDateTime Format Pattern "dddd, MMMM dd, yyyy h:mm:ss tt" * m The CultureInfo monthDay Format Pattern "MMMM dd" * r The CultureInfo rfc1123 Format Pattern "ddd, dd MMM yyyy HH:mm:ss GMT" * s The CultureInfo sortableDateTime Format Pattern "yyyy-MM-ddTHH:mm:ss" * t The CultureInfo shortTime Format Pattern "h:mm tt" * T The CultureInfo longTime Format Pattern "h:mm:ss tt" * u The CultureInfo universalSortableDateTime Format Pattern "yyyy-MM-dd HH:mm:ssZ" * y The CultureInfo yearMonth Format Pattern "MMMM, yyyy" * * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @return {String} A string representation of the current Date object. */ var ord = function (n) { switch (n * 1) { case 1: case 21: case 31: return "st"; case 2: case 22: return "nd"; case 3: case 23: return "rd"; default: return "th"; } }; var parseStandardFormats = function (format) { var y, c = Date.CultureInfo.formatPatterns; switch (format) { case "d": return this.toString(c.shortDate); case "D": return this.toString(c.longDate); case "F": return this.toString(c.fullDateTime); case "m": return this.toString(c.monthDay); case "r": case "R": y = this.clone().addMinutes(this.getTimezoneOffset()); return y.toString(c.rfc1123) + " GMT"; case "s": return this.toString(c.sortableDateTime); case "t": return this.toString(c.shortTime); case "T": return this.toString(c.longTime); case "u": y = this.clone().addMinutes(this.getTimezoneOffset()); return y.toString(c.universalSortableDateTime); case "y": return this.toString(c.yearMonth); default: return false; } }; var parseFormatStringsClosure = function (context) { return function (m) { if (m.charAt(0) === "\\") { return m.replace("\\", ""); } switch (m) { case "hh": return p(context.getHours() < 13 ? (context.getHours() === 0 ? 12 : context.getHours()) : (context.getHours() - 12)); case "h": return context.getHours() < 13 ? (context.getHours() === 0 ? 12 : context.getHours()) : (context.getHours() - 12); case "HH": return p(context.getHours()); case "H": return context.getHours(); case "mm": return p(context.getMinutes()); case "m": return context.getMinutes(); case "ss": return p(context.getSeconds()); case "s": return context.getSeconds(); case "yyyy": return p(context.getFullYear(), 4); case "yy": return p(context.getFullYear()); case "y": return context.getFullYear(); case "E": case "dddd": return Date.CultureInfo.dayNames[context.getDay()]; case "ddd": return Date.CultureInfo.abbreviatedDayNames[context.getDay()]; case "dd": return p(context.getDate()); case "d": return context.getDate(); case "MMMM": return Date.CultureInfo.monthNames[context.getMonth()]; case "MMM": return Date.CultureInfo.abbreviatedMonthNames[context.getMonth()]; case "MM": return p((context.getMonth() + 1)); case "M": return context.getMonth() + 1; case "t": return context.getHours() < 12 ? Date.CultureInfo.amDesignator.substring(0, 1) : Date.CultureInfo.pmDesignator.substring(0, 1); case "tt": return context.getHours() < 12 ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator; case "S": return ord(context.getDate()); case "W": return context.getWeek(); case "WW": return context.getISOWeek(); case "Q": return "Q" + context.getQuarter(); case "q": return String(context.getQuarter()); case "z": return context.getTimezone(); case "Z": case "X": return Date.getTimezoneOffset(context.getTimezone()); case "ZZ": // Timezone offset in seconds return context.getTimezoneOffset() * -60; case "u": return context.getDay(); case "L": return ($D.isLeapYear(context.getFullYear())) ? 1 : 0; case "B": // Swatch Internet Time (.beats) return "@"+((context.getUTCSeconds() + (context.getUTCMinutes()*60) + ((context.getUTCHours()+1)*3600))/86.4); default: return m; } }; }; $P.toString = function (format, ignoreStandards) { // Standard Date and Time Format Strings. Formats pulled from CultureInfo file and // may vary by culture. if (!ignoreStandards && format && format.length === 1) { output = parseStandardFormats.call(this, format); if (output) { return output; } } var parseFormatStrings = parseFormatStringsClosure(this); return format ? format.replace(/((\\)?(dd?d?d?|MM?M?M?|yy?y?y?|hh?|HH?|mm?|ss?|tt?|S|q|Q|WW?W?W?)(?![^\[]*\]))/g, parseFormatStrings).replace(/\[|\]/g, "") : this._toString(); }; }()); /************************************************************* * SugarPak - Domain Specific Language - Syntactical Sugar * *************************************************************/ (function () { var $D = Date, $P = $D.prototype, $N = Number.prototype; // private $P._orient = +1; // private $P._nth = null; // private $P._is = false; // private $P._same = false; // private $P._isSecond = false; // private $N._dateElement = "days"; /** * Moves the date to the next instance of a date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.today().next().friday();
	Date.today().next().fri();
	Date.today().next().march();
	Date.today().next().mar();
	Date.today().next().week();
	
* * @return {Date} date */ $P.next = function () { this._move = true; this._orient = +1; return this; }; /** * Creates a new Date (Date.today()) and moves the date to the next instance of the date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.next().friday();
	Date.next().fri();
	Date.next().march();
	Date.next().mar();
	Date.next().week();
	
* * @return {Date} date */ $D.next = function () { return $D.today().next(); }; /** * Moves the date to the previous instance of a date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.today().last().friday();
	Date.today().last().fri();
	Date.today().last().march();
	Date.today().last().mar();
	Date.today().last().week();
	
* * @return {Date} date */ $P.last = $P.prev = $P.previous = function () { this._move = true; this._orient = -1; return this; }; /** * Creates a new Date (Date.today()) and moves the date to the previous instance of the date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.last().friday();
	Date.last().fri();
	Date.previous().march();
	Date.prev().mar();
	Date.last().week();
	
* * @return {Date} date */ $D.last = $D.prev = $D.previous = function () { return $D.today().last(); }; /** * Performs a equality check when followed by either a month name, day name or .weekday() function. * Example

	Date.today().is().friday(); // true|false
	Date.today().is().fri();
	Date.today().is().march();
	Date.today().is().mar();
	
* * @return {Boolean} true|false */ $P.is = function () { this._is = true; return this; }; /** * Determines if two date objects occur on/in exactly the same instance of the subsequent date part function. * The function .same() must be followed by a date part function (example: .day(), .month(), .year(), etc). * * An optional Date can be passed in the date part function. If now date is passed as a parameter, 'Now' is used. * * The following example demonstrates how to determine if two dates fall on the exact same day. * * Example

	var d1 = Date.today(); // today at 00:00
	var d2 = new Date();   // exactly now.

	// Do they occur on the same day?
	d1.same().day(d2); // true
	
	// Do they occur on the same hour?
	d1.same().hour(d2); // false, unless d2 hour is '00' (midnight).
	
	// What if it's the same day, but one year apart?
	var nextYear = Date.today().add(1).year();

	d1.same().day(nextYear); // false, because the dates must occur on the exact same day. 
	
* * Scenario: Determine if a given date occurs during some week period 2 months from now. * * Example

	var future = Date.today().add(2).months();
	return someDate.same().week(future); // true|false;
	
* * @return {Boolean} true|false */ $P.same = function () { this._same = true; this._isSecond = false; return this; }; /** * Determines if the current date/time occurs during Today. Must be preceded by the .is() function. * Example

	someDate.is().today();    // true|false
	new Date().is().today();  // true
	Date.today().is().today();// true
	Date.today().add(-1).day().is().today(); // false
	
* * @return {Boolean} true|false */ $P.today = function () { return this.same().day(); }; /** * Determines if the current date is a weekday. This function must be preceded by the .is() function. * Example

	Date.today().is().weekday(); // true|false
	
* * @return {Boolean} true|false */ $P.weekday = function () { if (this._nth) { return df("Weekday").call(this); } if (this._move) { return this.addWeekdays(this._orient); } if (this._is) { this._is = false; return (!this.is().sat() && !this.is().sun()); } return false; }; /** * Determines if the current date is on the weekend. This function must be preceded by the .is() function. * Example

	Date.today().is().weekend(); // true|false
	
* * @return {Boolean} true|false */ $P.weekend = function () { if (this._is) { this._is = false; return (this.is().sat() || this.is().sun()); } return false; }; /** * Sets the Time of the current Date instance. A string "6:15 pm" or config object {hour:18, minute:15} are accepted. * Example

	// Set time to 6:15pm with a String
	Date.today().at("6:15pm");

	// Set time to 6:15pm with a config object
	Date.today().at({hour:18, minute:15});
	
* * @return {Date} date */ $P.at = function (time) { return (typeof time === "string") ? $D.parse(this.toString("d") + " " + time) : this.set(time); }; /** * Creates a new Date() and adds this (Number) to the date based on the preceding date element function (eg. second|minute|hour|day|month|year). * Example

	// Undeclared Numbers must be wrapped with parentheses. Requirment of JavaScript.
	(3).days().fromNow();
	(6).months().fromNow();

	// Declared Number variables do not require parentheses. 
	var n = 6;
	n.months().fromNow();
	
* * @return {Date} A new Date instance */ $N.fromNow = $N.after = function (date) { var c = {}; c[this._dateElement] = this; return ((!date) ? new Date() : date.clone()).add(c); }; /** * Creates a new Date() and subtract this (Number) from the date based on the preceding date element function (eg. second|minute|hour|day|month|year). * Example

	// Undeclared Numbers must be wrapped with parentheses. Requirment of JavaScript.
	(3).days().ago();
	(6).months().ago();

	// Declared Number variables do not require parentheses. 
	var n = 6;
	n.months().ago();
	
* * @return {Date} A new Date instance */ $N.ago = $N.before = function (date) { var c = {}, s = (this._dateElement[this._dateElement.length-1] !== "s") ? this._dateElement + "s" : this._dateElement; c[s] = this * -1; return ((!date) ? new Date() : date.clone()).add(c); }; // Do NOT modify the following string tokens. These tokens are used to build dynamic functions. // All culture-specific strings can be found in the CultureInfo files. var dx = ("sunday monday tuesday wednesday thursday friday saturday").split(/\s/), mx = ("january february march april may june july august september october november december").split(/\s/), px = ("Millisecond Second Minute Hour Day Week Month Year Quarter Weekday").split(/\s/), pxf = ("Milliseconds Seconds Minutes Hours Date Week Month FullYear Quarter").split(/\s/), nth = ("final first second third fourth fifth").split(/\s/), de; /** * Returns an object literal of all the date parts. * Example

	var o = new Date().toObject();
	
	// { year: 2008, month: 4, week: 20, day: 13, hour: 18, minute: 9, second: 32, millisecond: 812 }
	
	// The object properties can be referenced directly from the object.
	
	alert(o.day);  // alerts "13"
	alert(o.year); // alerts "2008"
	
* * @return {Date} An object literal representing the original date object. */ $P.toObject = function () { var o = {}; for (var i = 0; i < px.length; i++) { if (this["get" + pxf[i]]) { o[px[i].toLowerCase()] = this["get" + pxf[i]](); } } return o; }; /** * Returns a date created from an object literal. Ignores the .week property if set in the config. * Example

	var o = new Date().toObject();
	
	return Date.fromObject(o); // will return the same date. 

	var o2 = {month: 1, day: 20, hour: 18}; // birthday party!
	Date.fromObject(o2);
	
* * @return {Date} An object literal representing the original date object. */ $D.fromObject = function(config) { config.week = null; return Date.today().set(config); }; // Create day name functions and abbreviated day name functions (eg. monday(), friday(), fri()). var df = function (n) { return function () { if (this._is) { this._is = false; return this.getDay() === n; } if (this._move) { this._move = null; } if (this._nth !== null) { // If the .second() function was called earlier, remove the _orient // from the date, and then continue. // This is required because 'second' can be used in two different context. // // Example // // Date.today().add(1).second(); // Date.march().second().monday(); // // Things get crazy with the following... // Date.march().add(1).second().second().monday(); // but it works!! // if (this._isSecond) { this.addSeconds(this._orient * -1); } // make sure we reset _isSecond this._isSecond = false; var ntemp = this._nth; this._nth = null; var temp = this.clone().moveToLastDayOfMonth(); this.moveToNthOccurrence(n, ntemp); if (this > temp) { throw new RangeError($D.getDayName(n) + " does not occur " + ntemp + " times in the month of " + $D.getMonthName(temp.getMonth()) + " " + temp.getFullYear() + "."); } return this; } return this.moveToDayOfWeek(n, this._orient); }; }; var sdf = function (n) { return function () { var t = $D.today(), shift = n - t.getDay(); if (n === 0 && Date.CultureInfo.firstDayOfWeek === 1 && t.getDay() !== 0) { shift = shift + 7; } return t.addDays(shift); }; }; // Create month name functions and abbreviated month name functions (eg. january(), march(), mar()). var month_instance_functions = function (n) { return function () { if (this._is) { this._is = false; return this.getMonth() === n; } return this.moveToMonth(n, this._orient); }; }; var month_static_functions = function (n) { return function () { return $D.today().set({ month: n, day: 1 }); }; }; var processTerms = function (names, staticFunc, instanceFunc) { for (var i = 0; i < names.length; i++) { // Create constant static Name variables. $D[names[i].toUpperCase()] = $D[names[i].toUpperCase().substring(0, 3)] = i; // Create Name functions. $D[names[i]] = $D[names[i].substring(0, 3)] = staticFunc(i); // Create Name instance functions. $P[names[i]] = $P[names[i].substring(0, 3)] = instanceFunc(i); } }; processTerms(dx, sdf, df); processTerms(mx, month_static_functions, month_instance_functions); // Create date element functions and plural date element functions used with Date (eg. day(), days(), months()). var ef = function (j) { return function () { // if the .second() function was called earlier, the _orient // has alread been added. Just return this and reset _isSecond. if (this._isSecond) { this._isSecond = false; return this; } if (this._same) { this._same = this._is = false; var o1 = this.toObject(), o2 = (arguments[0] || new Date()).toObject(), v = "", k = j.toLowerCase(); // the substr trick with -1 doesn't work in IE8 or less k = (k[k.length-1] === "s") ? k.substring(0,k.length-1) : k; for (var m = (px.length - 1); m > -1; m--) { v = px[m].toLowerCase(); if (o1[v] !== o2[v]) { return false; } if (k === v) { break; } } return true; } if (j.substring(j.length - 1) !== "s") { j += "s"; } if (this._move) { this._move = null; } return this["add" + j](this._orient); }; }; var nf = function (n) { return function () { this._dateElement = n; return this; }; }; for (var k = 0; k < px.length; k++) { de = px[k].toLowerCase(); if(de !== "weekday") { // Create date element functions and plural date element functions used with Date (eg. day(), days(), months()). $P[de] = $P[de + "s"] = ef(px[k]); // Create date element functions and plural date element functions used with Number (eg. day(), days(), months()). $N[de] = $N[de + "s"] = nf(de + "s"); } } $P._ss = ef("Second"); var nthfn = function (n) { return function (dayOfWeek) { if (this._same) { return this._ss(arguments[0]); } if (dayOfWeek || dayOfWeek === 0) { return this.moveToNthOccurrence(dayOfWeek, n); } this._nth = n; // if the operator is 'second' add the _orient, then deal with it later... if (n === 2 && (dayOfWeek === undefined || dayOfWeek === null)) { this._isSecond = true; return this.addSeconds(this._orient); } return this; }; }; for (var l = 0; l < nth.length; l++) { $P[nth[l]] = (l === 0) ? nthfn(-1) : nthfn(l); } }()); (function () { "use strict"; Date.Parsing = { Exception: function (s) { this.message = "Parse error at '" + s.substring(0, 10) + " ...'"; } }; var $P = Date.Parsing; var dayOffsets = { standard: [0,31,59,90,120,151,181,212,243,273,304,334], leap: [0,31,60,91,121,152,182,213,244,274,305,335] }; $P.isLeapYear = function(year) { return ((year % 4 === 0) && (year % 100 !== 0)) || (year % 400 === 0); }; var utils = { multiReplace : function (str, hash ) { var key; for (key in hash) { if (Object.prototype.hasOwnProperty.call(hash, key)) { var regex; if (typeof hash[key] === "function") { } else { regex = (hash[key] instanceof RegExp) ? hash[key] : new RegExp(hash[key], "g"); } str = str.replace(regex, key); } } return str; }, getDayOfYearFromWeek : function (obj) { var d, jan4, offset; obj.weekDay = (!obj.weekDay && obj.weekDay !== 0) ? 1 : obj.weekDay; d = new Date(obj.year, 0, 4); jan4 = d.getDay() === 0 ? 7 : d.getDay(); // JS is 0 indexed on Sunday. offset = jan4+3; obj.dayOfYear = ((obj.week * 7) + (obj.weekDay === 0 ? 7 : obj.weekDay))-offset; return obj; }, getDayOfYear : function (obj, dayOffset) { if (!obj.dayOfYear) { obj = utils.getDayOfYearFromWeek(obj); } for (var i=0;i <= dayOffset.length;i++) { if (obj.dayOfYear < dayOffset[i] || i === dayOffset.length) { obj.day = obj.day ? obj.day : (obj.dayOfYear - dayOffset[i-1]); break; } else { obj.month = i; } } return obj; }, adjustForTimeZone : function (obj, date) { var offset; if (obj.zone.toUpperCase() === "Z" || (obj.zone_hours === 0 && obj.zone_minutes === 0)) { // it's UTC/GML so work out the current timeszone offset offset = -date.getTimezoneOffset(); } else { offset = (obj.zone_hours*60) + (obj.zone_minutes || 0); if (obj.zone_sign === "+") { offset *= -1; } offset -= date.getTimezoneOffset(); } date.setMinutes(date.getMinutes()+offset); return date; }, setDefaults : function (obj) { obj.year = obj.year || Date.today().getFullYear(); obj.hours = obj.hours || 0; obj.minutes = obj.minutes || 0; obj.seconds = obj.seconds || 0; obj.milliseconds = obj.milliseconds || 0; if (!(!obj.month && (obj.week || obj.dayOfYear))) { // if we have a month, or if we don't but don't have the day calculation data obj.month = obj.month || 0; obj.day = obj.day || 1; } return obj; }, dataNum: function (data, mod, explict, postProcess) { var dataNum = data*1; if (mod) { if (postProcess) { return data ? mod(data)*1 : data; } else { return data ? mod(dataNum) : data; } } else if (!explict){ return data ? dataNum : data; } else { return (data && typeof data !== "undefined") ? dataNum : data; } }, timeDataProcess: function (obj) { var timeObj = {}; for (var x in obj.data) { if (obj.data.hasOwnProperty(x)) { timeObj[x] = obj.ignore[x] ? obj.data[x] : utils.dataNum(obj.data[x], obj.mods[x], obj.explict[x], obj.postProcess[x]); } } if (obj.data.secmins) { obj.data.secmins = obj.data.secmins.replace(",", ".") * 60; if (!timeObj.minutes) { timeObj.minutes = obj.data.secmins; } else if (!timeObj.seconds) { timeObj.seconds = obj.data.secmins; } delete obj.secmins; } return timeObj; }, buildTimeObjectFromData: function (data) { var time = utils.timeDataProcess({ data: { year : data[1], month : data[5], day : data[7], week : data[8], dayOfYear : data[10], hours : data[15], zone_hours : data[23], zone_minutes : data[24], zone : data[21], zone_sign : data[22], weekDay : data[9], minutes: data[16], seconds: data[19], milliseconds: data[20], secmins: data[18] }, mods: { month: function(data) { return data-1; }, weekDay: function (data) { data = Math.abs(data); return (data === 7 ? 0 : data); }, minutes: function (data) { return data.replace(":",""); }, seconds: function (data) { return Math.floor( (data.replace(":","").replace(",","."))*1 ); }, milliseconds: function (data) { return (data.replace(",",".")*1000); } }, postProcess: { minutes: true, seconds: true, milliseconds: true }, explict: { zone_hours: true, zone_minutes: true }, ignore: { zone: true, zone_sign: true, secmins: true } }); return time; }, addToHash: function (hash, keys, data) { keys = keys; data = data; var len = keys.length; for (var i = 0; i < len; i++) { hash[keys[i]] = data[i]; } return hash; }, combineRegex: function (r1, r2) { return new RegExp("(("+r1.source+")\\s("+r2.source+"))"); }, getDateNthString: function(add, last, inc){ if (add) { return Date.today().addDays(inc).toString("d"); } else if (last) { return Date.today().last()[inc]().toString("d"); } }, buildRegexData: function (array) { var arr = []; var len = array.length; for (var i=0; i < len; i++) { if (Object.prototype.toString.call(array[i]) === '[object Array]') { // oldIE compat version of Array.isArray arr.push(this.combineRegex(array[i][0], array[i][1])); } else { arr.push(array[i]); } } return arr; } }; $P.processTimeObject = function (obj) { var date, dayOffset; utils.setDefaults(obj); dayOffset = ($P.isLeapYear(obj.year)) ? dayOffsets.leap : dayOffsets.standard; if (!obj.month && (obj.week || obj.dayOfYear)) { utils.getDayOfYear(obj, dayOffset); } else { obj.dayOfYear = dayOffset[obj.month] + obj.day; } date = new Date(obj.year, obj.month, obj.day, obj.hours, obj.minutes, obj.seconds, obj.milliseconds); if (obj.zone) { utils.adjustForTimeZone(obj, date); // adjust (and calculate) for timezone } return date; }; $P.ISO = { regex : /^([\+-]?\d{4}(?!\d{2}\b))((-?)((0[1-9]|1[0-2])(\3([12]\d|0[1-9]|3[01]))?|W([0-4]\d|5[0-3])(-?[1-7])?|(00[1-9]|0[1-9]\d|[12]\d{2}|3([0-5]\d|6[1-6])))([T\s]((([01]\d|2[0-4])((:?)[0-5]\d)?|24\:?00)([\.,]\d+(?!:))?)?(\17[0-5]\d([\.,]\d+)?)?\s?([zZ]|([\+-])([01]\d|2[0-3]):?([0-5]\d)?)?)?)?$/, parse : function (s) { var time, data = s.match(this.regex); if (!data || !data.length) { return null; } time = utils.buildTimeObjectFromData(data); if (!time.year || (!time.year && (!time.month && !time.day) && (!time.week && !time.dayOfYear)) ) { return null; } return $P.processTimeObject(time); } }; $P.Numeric = { isNumeric: function (e){return!isNaN(parseFloat(e))&&isFinite(e);}, regex: /\b([0-1]?[0-9])([0-3]?[0-9])([0-2]?[0-9]?[0-9][0-9])\b/i, parse: function (s) { var data, i, time = {}, order = Date.CultureInfo.dateElementOrder.split(""); if (!(this.isNumeric(s)) || // if it's non-numeric OR (s[0] === "+" && s[0] === "-")) { // It's an arithmatic string (eg +/-1000) return null; } if (s.length < 5 && s.indexOf(".") < 0 && s.indexOf("/") < 0) { // assume it's just a year. time.year = s; return $P.processTimeObject(time); } data = s.match(this.regex); if (!data || !data.length) { return null; } for (i=0; i < order.length; i++) { switch(order[i]) { case "d": time.day = data[i+1]; break; case "m": time.month = (data[i+1]-1); break; case "y": time.year = data[i+1]; break; } } return $P.processTimeObject(time); } }; $P.Normalizer = { regexData: function () { var $R = Date.CultureInfo.regexPatterns; return utils.buildRegexData([ $R.tomorrow, $R.yesterday, [$R.past, $R.mon], [$R.past, $R.tue], [$R.past, $R.wed], [$R.past, $R.thu], [$R.past, $R.fri], [$R.past, $R.sat], [$R.past, $R.sun] ]); }, basicReplaceHash : function() { var $R = Date.CultureInfo.regexPatterns; return { "January": $R.jan.source, "February": $R.feb, "March": $R.mar, "April": $R.apr, "May": $R.may, "June": $R.jun, "July": $R.jul, "August": $R.aug, "September": $R.sep, "October": $R.oct, "November": $R.nov, "December": $R.dec, "": /\bat\b/gi, " ": /\s{2,}/, "am": $R.inTheMorning, "9am": $R.thisMorning, "pm": $R.inTheEvening, "7pm":$R.thisEvening }; }, keys : function(){ return [ utils.getDateNthString(true, false, 1), // tomorrow utils.getDateNthString(true, false, -1), // yesterday utils.getDateNthString(false, true, "monday"), //last mon utils.getDateNthString(false, true, "tuesday"), //last tues utils.getDateNthString(false, true, "wednesday"), //last wed utils.getDateNthString(false, true, "thursday"), //last thurs utils.getDateNthString(false, true, "friday"), //last fri utils.getDateNthString(false, true, "saturday"), //last sat utils.getDateNthString(false, true, "sunday") //last sun ]; }, buildRegexFunctions: function () { var $R = Date.CultureInfo.regexPatterns; var __ = Date.i18n.__; var tomorrowRE = new RegExp("(\\b\\d\\d?("+__("AM")+"|"+__("PM")+")? )("+$R.tomorrow.source.slice(1)+")", "i"); // adapted tomorrow regex for AM PM relative dates var todayRE = new RegExp($R.today.source + "(?!\\s*([+-]))\\b"); // today, but excludes the math operators (eg "today + 2h") this.replaceFuncs = [ [todayRE, function (full) { return (full.length > 1) ? Date.today().toString("d") : full; }], [tomorrowRE, function(full, m1) { var t = Date.today().addDays(1).toString("d"); return (t + " " + m1); }], [$R.amThisMorning, function(str, am){return am;}], [$R.pmThisEvening, function(str, pm){return pm;}] ]; }, buildReplaceData: function () { this.buildRegexFunctions(); this.replaceHash = utils.addToHash(this.basicReplaceHash(), this.keys(), this.regexData()); }, stringReplaceFuncs: function (s) { for (var i=0; i < this.replaceFuncs.length; i++) { s = s.replace(this.replaceFuncs[i][0], this.replaceFuncs[i][1]); } return s; }, parse: function (s) { s = this.stringReplaceFuncs(s); s = utils.multiReplace(s, this.replaceHash); try { var n = s.split(/([\s\-\.\,\/\x27]+)/); if (n.length === 3 && $P.Numeric.isNumeric(n[0]) && $P.Numeric.isNumeric(n[2]) && (n[2].length >= 4)) { // ok, so we're dealing with x/year. But that's not a full date. // This fixes wonky dateElementOrder parsing when set to dmy order. if (Date.CultureInfo.dateElementOrder[0] === "d") { s = "1/" + n[0] + "/" + n[2]; // set to 1st of month and normalize the seperator } } } catch (e) {} return s; } }; $P.Normalizer.buildReplaceData(); }()); (function () { var $P = Date.Parsing; var _ = $P.Operators = { // // Tokenizers // rtoken: function (r) { // regex token return function (s) { var mx = s.match(r); if (mx) { return ([ mx[0], s.substring(mx[0].length) ]); } else { throw new $P.Exception(s); } }; }, token: function () { // whitespace-eating token return function (s) { return _.rtoken(new RegExp("^\\s*" + s + "\\s*"))(s); }; }, stoken: function (s) { // string token return _.rtoken(new RegExp("^" + s)); }, // Atomic Operators until: function (p) { return function (s) { var qx = [], rx = null; while (s.length) { try { rx = p.call(this, s); } catch (e) { qx.push(rx[0]); s = rx[1]; continue; } break; } return [ qx, s ]; }; }, many: function (p) { return function (s) { var rx = [], r = null; while (s.length) { try { r = p.call(this, s); } catch (e) { return [ rx, s ]; } rx.push(r[0]); s = r[1]; } return [ rx, s ]; }; }, // generator operators -- see below optional: function (p) { return function (s) { var r = null; try { r = p.call(this, s); } catch (e) { return [ null, s ]; } return [ r[0], r[1] ]; }; }, not: function (p) { return function (s) { try { p.call(this, s); } catch (e) { return [null, s]; } throw new $P.Exception(s); }; }, ignore: function (p) { return p ? function (s) { var r = null; r = p.call(this, s); return [null, r[1]]; } : null; }, product: function () { var px = arguments[0], qx = Array.prototype.slice.call(arguments, 1), rx = []; for (var i = 0 ; i < px.length ; i++) { rx.push(_.each(px[i], qx)); } return rx; }, cache: function (rule) { var cache = {}, cache_length = 0, cache_keys = [], CACHE_MAX = Date.Config.CACHE_MAX || 100000, r = null; var cacheCheck = function () { if (cache_length === CACHE_MAX) { // kill several keys, don't want to have to do this all the time... for (var i=0; i < 10; i++) { var key = cache_keys.shift(); if (key) { delete cache[key]; cache_length--; } } } }; return function (s) { cacheCheck(); try { r = cache[s] = (cache[s] || rule.call(this, s)); } catch (e) { r = cache[s] = e; } cache_length++; cache_keys.push(s); if (r instanceof $P.Exception) { throw r; } else { return r; } }; }, // vector operators -- see below any: function () { var px = arguments; return function (s) { var r = null; for (var i = 0; i < px.length; i++) { if (px[i] == null) { continue; } try { r = (px[i].call(this, s)); } catch (e) { r = null; } if (r) { return r; } } throw new $P.Exception(s); }; }, each: function () { var px = arguments; return function (s) { var rx = [], r = null; for (var i = 0; i < px.length ; i++) { if (px[i] == null) { continue; } try { r = (px[i].call(this, s)); } catch (e) { throw new $P.Exception(s); } rx.push(r[0]); s = r[1]; } return [ rx, s]; }; }, all: function () { var px = arguments, _ = _; return _.each(_.optional(px)); }, // delimited operators sequence: function (px, d, c) { d = d || _.rtoken(/^\s*/); c = c || null; if (px.length === 1) { return px[0]; } return function (s) { var r = null, q = null; var rx = []; for (var i = 0; i < px.length ; i++) { try { r = px[i].call(this, s); } catch (e) { break; } rx.push(r[0]); try { q = d.call(this, r[1]); } catch (ex) { q = null; break; } s = q[1]; } if (!r) { throw new $P.Exception(s); } if (q) { throw new $P.Exception(q[1]); } if (c) { try { r = c.call(this, r[1]); } catch (ey) { throw new $P.Exception(r[1]); } } return [ rx, (r?r[1]:s) ]; }; }, // // Composite Operators // between: function (d1, p, d2) { d2 = d2 || d1; var _fn = _.each(_.ignore(d1), p, _.ignore(d2)); return function (s) { var rx = _fn.call(this, s); return [[rx[0][0], r[0][2]], rx[1]]; }; }, list: function (p, d, c) { d = d || _.rtoken(/^\s*/); c = c || null; return (p instanceof Array ? _.each(_.product(p.slice(0, -1), _.ignore(d)), p.slice(-1), _.ignore(c)) : _.each(_.many(_.each(p, _.ignore(d))), px, _.ignore(c))); }, set: function (px, d, c) { d = d || _.rtoken(/^\s*/); c = c || null; return function (s) { // r is the current match, best the current 'best' match // which means it parsed the most amount of input var r = null, p = null, q = null, rx = null, best = [[], s], last = false; // go through the rules in the given set for (var i = 0; i < px.length ; i++) { // last is a flag indicating whether this must be the last element // if there is only 1 element, then it MUST be the last one q = null; p = null; r = null; last = (px.length === 1); // first, we try simply to match the current pattern // if not, try the next pattern try { r = px[i].call(this, s); } catch (e) { continue; } // since we are matching against a set of elements, the first // thing to do is to add r[0] to matched elements rx = [[r[0]], r[1]]; // if we matched and there is still input to parse and // we don't already know this is the last element, // we're going to next check for the delimiter ... // if there's none, or if there's no input left to parse // than this must be the last element after all ... if (r[1].length > 0 && ! last) { try { q = d.call(this, r[1]); } catch (ex) { last = true; } } else { last = true; } // if we parsed the delimiter and now there's no more input, // that means we shouldn't have parsed the delimiter at all // so don't update r and mark this as the last element ... if (!last && q[1].length === 0) { last = true; } // so, if this isn't the last element, we're going to see if // we can get any more matches from the remaining (unmatched) // elements ... if (!last) { // build a list of the remaining rules we can match against, // i.e., all but the one we just matched against var qx = []; for (var j = 0; j < px.length ; j++) { if (i !== j) { qx.push(px[j]); } } // now invoke recursively set with the remaining input // note that we don't include the closing delimiter ... // we'll check for that ourselves at the end p = _.set(qx, d).call(this, q[1]); // if we got a non-empty set as a result ... // (otw rx already contains everything we want to match) if (p[0].length > 0) { // update current result, which is stored in rx ... // basically, pick up the remaining text from p[1] // and concat the result from p[0] so that we don't // get endless nesting ... rx[0] = rx[0].concat(p[0]); rx[1] = p[1]; } } // at this point, rx either contains the last matched element // or the entire matched set that starts with this element. // now we just check to see if this variation is better than // our best so far, in terms of how much of the input is parsed if (rx[1].length < best[1].length) { best = rx; } // if we've parsed all the input, then we're finished if (best[1].length === 0) { break; } } // so now we've either gone through all the patterns trying them // as the initial match; or we found one that parsed the entire // input string ... // if best has no matches, just return empty set ... if (best[0].length === 0) { return best; } // if a closing delimiter is provided, then we have to check it also if (c) { // we try this even if there is no remaining input because the pattern // may well be optional or match empty input ... try { q = c.call(this, best[1]); } catch (ey) { throw new $P.Exception(best[1]); } // it parsed ... be sure to update the best match remaining input best[1] = q[1]; } // if we're here, either there was no closing delimiter or we parsed it // so now we have the best match; just return it! return best; }; }, forward: function (gr, fname) { return function (s) { return gr[fname].call(this, s); }; }, // // Translation Operators // replace: function (rule, repl) { return function (s) { var r = rule.call(this, s); return [repl, r[1]]; }; }, process: function (rule, fn) { return function (s) { var r = rule.call(this, s); return [fn.call(this, r[0]), r[1]]; }; }, min: function (min, rule) { return function (s) { var rx = rule.call(this, s); if (rx[0].length < min) { throw new $P.Exception(s); } return rx; }; } }; // Generator Operators And Vector Operators // Generators are operators that have a signature of F(R) => R, // taking a given rule and returning another rule, such as // ignore, which parses a given rule and throws away the result. // Vector operators are those that have a signature of F(R1,R2,...) => R, // take a list of rules and returning a new rule, such as each. // Generator operators are converted (via the following _generator // function) into functions that can also take a list or array of rules // and return an array of new rules as though the function had been // called on each rule in turn (which is what actually happens). // This allows generators to be used with vector operators more easily. // Example: // each(ignore(foo, bar)) instead of each(ignore(foo), ignore(bar)) // This also turns generators into vector operators, which allows // constructs like: // not(cache(foo, bar)) var _generator = function (op) { function gen() { var args = null, rx = [], px, i; if (arguments.length > 1) { args = Array.prototype.slice.call(arguments); } else if (arguments[0] instanceof Array) { args = arguments[0]; } if (args) { px = args.shift(); if (px.length > 0) { args.unshift(px[i]); rx.push(op.apply(null, args)); args.shift(); return rx; } } else { return op.apply(null, arguments); } } return gen; }; var gx = "optional not ignore cache".split(/\s/); for (var i = 0 ; i < gx.length ; i++) { _[gx[i]] = _generator(_[gx[i]]); } var _vector = function (op) { return function () { if (arguments[0] instanceof Array) { return op.apply(null, arguments[0]); } else { return op.apply(null, arguments); } }; }; var vx = "each any all".split(/\s/); for (var j = 0 ; j < vx.length ; j++) { _[vx[j]] = _vector(_[vx[j]]); } }()); (function () { var $D = Date; var flattenAndCompact = function (ax) { var rx = []; for (var i = 0; i < ax.length; i++) { if (ax[i] instanceof Array) { rx = rx.concat(flattenAndCompact(ax[i])); } else { if (ax[i]) { rx.push(ax[i]); } } } return rx; }; var parseMeridian = function () { if (this.meridian && (this.hour || this.hour === 0)) { if (this.meridian === "a" && this.hour > 11 && Date.Config.strict24hr){ throw "Invalid hour and meridian combination"; } else if (this.meridian === "p" && this.hour < 12 && Date.Config.strict24hr){ throw "Invalid hour and meridian combination"; } else if (this.meridian === "p" && this.hour < 12) { this.hour = this.hour + 12; } else if (this.meridian === "a" && this.hour === 12) { this.hour = 0; } } }; var setDefaults = function () { var now = new Date(); if ((this.hour || this.minute) && (!this.month && !this.year && !this.day)) { this.day = now.getDate(); } if (!this.year) { this.year = now.getFullYear(); } if (!this.month && this.month !== 0) { this.month = now.getMonth(); } if (!this.day) { this.day = 1; } if (!this.hour) { this.hour = 0; } if (!this.minute) { this.minute = 0; } if (!this.second) { this.second = 0; } if (!this.millisecond) { this.millisecond = 0; } }; var finishUtils = { getToday: function () { if (this.now || "hour minute second".indexOf(this.unit) !== -1) { return new Date(); } else { return $D.today(); } }, setDaysFromWeekday: function (today, orient){ var gap; orient = orient || 1; this.unit = "day"; gap = ($D.getDayNumberFromName(this.weekday) - today.getDay()); this.days = gap ? ((gap + (orient * 7)) % 7) : (orient * 7); return this; }, setMonthsFromMonth: function (today, orient) { var gap; orient = orient || 1; this.unit = "month"; gap = (this.month - today.getMonth()); this.months = gap ? ((gap + (orient * 12)) % 12) : (orient * 12); this.month = null; return this; }, setDMYFromWeekday: function () { var d = Date[this.weekday](); this.day = d.getDate(); if (!this.month) { this.month = d.getMonth(); } this.year = d.getFullYear(); return this; }, setUnitValue: function (orient) { if (!this.value && this.operator && this.operator !== null && this[this.unit + "s"] && this[this.unit + "s"] !== null) { this[this.unit + "s"] = this[this.unit + "s"] + ((this.operator === "add") ? 1 : -1) + (this.value||0) * orient; } else if (this[this.unit + "s"] == null || this.operator != null) { if (!this.value) { this.value = 1; } this[this.unit + "s"] = this.value * orient; } }, generateDateFromWeeks: function () { var weekday = (this.weekday !== undefined) ? this.weekday : "today"; var d = Date[weekday]().addWeeks(this.weeks); if (this.now) { d.setTimeToNow(); } return d; } }; $D.Translator = { hour: function (s) { return function () { this.hour = Number(s); }; }, minute: function (s) { return function () { this.minute = Number(s); }; }, second: function (s) { return function () { this.second = Number(s); }; }, /* for ss.s format */ secondAndMillisecond: function (s) { return function () { var mx = s.match(/^([0-5][0-9])\.([0-9]{1,3})/); this.second = Number(mx[1]); this.millisecond = Number(mx[2]); }; }, meridian: function (s) { return function () { this.meridian = s.slice(0, 1).toLowerCase(); }; }, timezone: function (s) { return function () { var n = s.replace(/[^\d\+\-]/g, ""); if (n.length) { this.timezoneOffset = Number(n); } else { this.timezone = s.toLowerCase(); } }; }, day: function (x) { var s = x[0]; return function () { this.day = Number(s.match(/\d+/)[0]); if (this.day < 1) { throw "invalid day"; } }; }, month: function (s) { return function () { this.month = (s.length === 3) ? "jan feb mar apr may jun jul aug sep oct nov dec".indexOf(s)/4 : Number(s) - 1; if (this.month < 0) { throw "invalid month"; } }; }, year: function (s) { return function () { var n = Number(s); this.year = ((s.length > 2) ? n : (n + (((n + 2000) < Date.CultureInfo.twoDigitYearMax) ? 2000 : 1900))); }; }, rday: function (s) { return function () { switch (s) { case "yesterday": this.days = -1; break; case "tomorrow": this.days = 1; break; case "today": this.days = 0; break; case "now": this.days = 0; this.now = true; break; } }; }, finishExact: function (x) { var d; x = (x instanceof Array) ? x : [x]; for (var i = 0 ; i < x.length ; i++) { if (x[i]) { x[i].call(this); } } setDefaults.call(this); parseMeridian.call(this); if (this.day > $D.getDaysInMonth(this.year, this.month)) { throw new RangeError(this.day + " is not a valid value for days."); } d = new Date(this.year, this.month, this.day, this.hour, this.minute, this.second, this.millisecond); if (this.year < 100) { d.setFullYear(this.year); // means years less that 100 are process correctly. JS will parse it otherwise as 1900-1999. } if (this.timezone) { d.set({ timezone: this.timezone }); } else if (this.timezoneOffset) { d.set({ timezoneOffset: this.timezoneOffset }); } return d; }, finish: function (x) { var today, expression, orient, temp; x = (x instanceof Array) ? flattenAndCompact(x) : [ x ]; if (x.length === 0) { return null; } for (var i = 0 ; i < x.length ; i++) { if (typeof x[i] === "function") { x[i].call(this); } } if (this.now && !this.unit && !this.operator) { return new Date(); } else { today = finishUtils.getToday.call(this); } expression = !!(this.days && this.days !== null || this.orient || this.operator); orient = ((this.orient === "past" || this.operator === "subtract") ? -1 : 1); if (this.month && this.unit === "week") { this.value = this.month + 1; delete this.month; delete this.day; } if ((this.month || this.month === 0) && "year day hour minute second".indexOf(this.unit) !== -1) { if (!this.value) { this.value = this.month + 1; } this.month = null; expression = true; } if (!expression && this.weekday && !this.day && !this.days) { finishUtils.setDMYFromWeekday.call(this); } if (expression && this.weekday && this.unit !== "month" && this.unit !== "week") { finishUtils.setDaysFromWeekday.call(this, today, orient); } if (this.weekday && this.unit !== "week" && !this.day && !this.days) { temp = Date[this.weekday](); this.day = temp.getDate(); if (temp.getMonth() !== today.getMonth()) { this.month = temp.getMonth(); } } if (this.month && this.unit === "day" && this.operator) { if (!this.value) { this.value = (this.month + 1); } this.month = null; } if (this.value != null && this.month != null && this.year != null) { this.day = this.value * 1; } if (this.month && !this.day && this.value) { today.set({ day: this.value * 1 }); if (!expression) { this.day = this.value * 1; } } if (!this.month && this.value && this.unit === "month" && !this.now) { this.month = this.value; expression = true; } if (expression && (this.month || this.month === 0) && this.unit !== "year") { finishUtils.setMonthsFromMonth.call(this, today, orient); } if (!this.unit) { this.unit = "day"; } finishUtils.setUnitValue.call(this, orient); parseMeridian.call(this); if ((this.month || this.month === 0) && !this.day) { this.day = 1; } if (!this.orient && !this.operator && this.unit === "week" && this.value && !this.day && !this.month) { return Date.today().setWeek(this.value); } if (this.unit === "week" && this.weeks && !this.day && !this.month) { return finishUtils.generateDateFromWeeks.call(this); } if (expression && this.timezone && this.day && this.days) { this.day = this.days; } if (expression){ today.add(this); } else { today.set(this); } if (this.timezone) { this.timezone = this.timezone.toUpperCase(); var offset = $D.getTimezoneOffset(this.timezone); var timezone; if (today.hasDaylightSavingTime()) { // lets check that we're being sane with timezone setting timezone = $D.getTimezoneAbbreviation(offset, today.isDaylightSavingTime()); if (timezone !== this.timezone) { // bugger, we're in a place where things like EST vs EDT matters. if (today.isDaylightSavingTime()) { today.addHours(-1); } else { today.addHours(1); } } } today.setTimezoneOffset(offset); } return today; } }; }()); (function () { var $D = Date; $D.Grammar = {}; var _ = $D.Parsing.Operators, g = $D.Grammar, t = $D.Translator, _fn; // Allow rolling up into general purpose rules _fn = function () { return _.each(_.any.apply(null, arguments), _.not(g.ctoken2("timeContext"))); }; g.datePartDelimiter = _.rtoken(/^([\s\-\.\,\/\x27]+)/); g.timePartDelimiter = _.stoken(":"); g.whiteSpace = _.rtoken(/^\s*/); g.generalDelimiter = _.rtoken(/^(([\s\,]|at|@|on)+)/); var _C = {}; g.ctoken = function (keys) { var fn = _C[keys]; if (! fn) { var c = Date.CultureInfo.regexPatterns; var kx = keys.split(/\s+/), px = []; for (var i = 0; i < kx.length ; i++) { px.push(_.replace(_.rtoken(c[kx[i]]), kx[i])); } fn = _C[keys] = _.any.apply(null, px); } return fn; }; g.ctoken2 = function (key) { return _.rtoken(Date.CultureInfo.regexPatterns[key]); }; var cacheProcessRtoken = function (key, token, type, eachToken) { if (eachToken) { g[key] = _.cache(_.process(_.each(_.rtoken(token),_.optional(g.ctoken2(eachToken))), type)); } else { g[key] = _.cache(_.process(_.rtoken(token), type)); } }; var cacheProcessCtoken = function (token, type) { return _.cache(_.process(g.ctoken2(token), type)); }; var _F = {}; //function cache var _get = function (f) { _F[f] = (_F[f] || g.format(f)[0]); return _F[f]; }; g.allformats = function (fx) { var rx = []; if (fx instanceof Array) { for (var i = 0; i < fx.length; i++) { rx.push(_get(fx[i])); } } else { rx.push(_get(fx)); } return rx; }; g.formats = function (fx) { if (fx instanceof Array) { var rx = []; for (var i = 0 ; i < fx.length ; i++) { rx.push(_get(fx[i])); } return _.any.apply(null, rx); } else { return _get(fx); } }; var grammarFormats = { timeFormats: function(){ var i, RTokenKeys = [ "h", "hh", "H", "HH", "m", "mm", "s", "ss", "ss.s", "z", "zz" ], RToken = [ /^(0[0-9]|1[0-2]|[1-9])/, /^(0[0-9]|1[0-2])/, /^([0-1][0-9]|2[0-3]|[0-9])/, /^([0-1][0-9]|2[0-3])/, /^([0-5][0-9]|[0-9])/, /^[0-5][0-9]/, /^([0-5][0-9]|[0-9])/, /^[0-5][0-9]/, /^[0-5][0-9]\.[0-9]{1,3}/, /^((\+|\-)\s*\d\d\d\d)|((\+|\-)\d\d\:?\d\d)/, /^((\+|\-)\s*\d\d\d\d)|((\+|\-)\d\d\:?\d\d)/ ], tokens = [ t.hour, t.hour, t.hour, t.hour, t.minute, t.minute, t.second, t.second, t.secondAndMillisecond, t.timezone, t.timezone ]; for (i=0; i < RTokenKeys.length; i++) { cacheProcessRtoken(RTokenKeys[i], RToken[i], tokens[i]); } g.hms = _.cache(_.sequence([g.H, g.m, g.s], g.timePartDelimiter)); g.t = cacheProcessCtoken("shortMeridian", t.meridian); g.tt = cacheProcessCtoken("longMeridian", t.meridian); g.zzz = cacheProcessCtoken("timezone", t.timezone); g.timeSuffix = _.each(_.ignore(g.whiteSpace), _.set([ g.tt, g.zzz ])); g.time = _.each(_.optional(_.ignore(_.stoken("T"))), g.hms, g.timeSuffix); }, dateFormats: function () { // pre-loaded rules for different date part order preferences var _setfn = function () { return _.set(arguments, g.datePartDelimiter); }; var i, RTokenKeys = [ "d", "dd", "M", "MM", "y", "yy", "yyy", "yyyy" ], RToken = [ /^([0-2]\d|3[0-1]|\d)/, /^([0-2]\d|3[0-1])/, /^(1[0-2]|0\d|\d)/, /^(1[0-2]|0\d)/, /^(\d+)/, /^(\d\d)/, /^(\d\d?\d?\d?)/, /^(\d\d\d\d)/ ], tokens = [ t.day, t.day, t.month, t.month, t.year, t.year, t.year, t.year ], eachToken = [ "ordinalSuffix", "ordinalSuffix" ]; for (i=0; i < RTokenKeys.length; i++) { cacheProcessRtoken(RTokenKeys[i], RToken[i], tokens[i], eachToken[i]); } g.MMM = g.MMMM = _.cache(_.process(g.ctoken("jan feb mar apr may jun jul aug sep oct nov dec"), t.month)); g.ddd = g.dddd = _.cache(_.process(g.ctoken("sun mon tue wed thu fri sat"), function (s) { return function () { this.weekday = s; }; } )); g.day = _fn(g.d, g.dd); g.month = _fn(g.M, g.MMM); g.year = _fn(g.yyyy, g.yy); g.mdy = _setfn(g.ddd, g.month, g.day, g.year); g.ymd = _setfn(g.ddd, g.year, g.month, g.day); g.dmy = _setfn(g.ddd, g.day, g.month, g.year); g.date = function (s) { return ((g[Date.CultureInfo.dateElementOrder] || g.mdy).call(this, s)); }; }, relative: function () { // relative date / time expressions g.orientation = _.process(g.ctoken("past future"), function (s) { return function () { this.orient = s; }; } ); g.operator = _.process(g.ctoken("add subtract"), function (s) { return function () { this.operator = s; }; } ); g.rday = _.process(g.ctoken("yesterday tomorrow today now"), t.rday); g.unit = _.process(g.ctoken("second minute hour day week month year"), function (s) { return function () { this.unit = s; }; } ); } }; g.buildGrammarFormats = function () { // these need to be rebuilt every time the language changes. _C = {}; grammarFormats.timeFormats(); grammarFormats.dateFormats(); grammarFormats.relative(); g.value = _.process(_.rtoken(/^([-+]?\d+)?(st|nd|rd|th)?/), function (s) { return function () { this.value = s.replace(/\D/g, ""); }; } ); g.expression = _.set([g.rday, g.operator, g.value, g.unit, g.orientation, g.ddd, g.MMM ]); g.format = _.process(_.many( _.any( // translate format specifiers into grammar rules _.process( _.rtoken(/^(dd?d?d?(?!e)|MM?M?M?|yy?y?y?|hh?|HH?|mm?|ss?|tt?|zz?z?)/), function (fmt) { if (g[fmt]) { return g[fmt]; } else { throw $D.Parsing.Exception(fmt); } } ), // translate separator tokens into token rules _.process(_.rtoken(/^[^dMyhHmstz]+/), // all legal separators function (s) { return _.ignore(_.stoken(s)); } ) ) ), // construct the parser ... function (rules) { return _.process(_.each.apply(null, rules), t.finishExact); } ); // starting rule for general purpose grammar g._start = _.process(_.set([ g.date, g.time, g.expression ], g.generalDelimiter, g.whiteSpace), t.finish); }; g.buildGrammarFormats(); // parsing date format specifiers - ex: "h:m:s tt" // this little guy will generate a custom parser based // on the format string, ex: g.format("h:m:s tt") // check for these formats first g._formats = g.formats([ "\"yyyy-MM-ddTHH:mm:ssZ\"", "yyyy-MM-ddTHH:mm:ss.sz", "yyyy-MM-ddTHH:mm:ssZ", "yyyy-MM-ddTHH:mm:ssz", "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-ddTHH:mmZ", "yyyy-MM-ddTHH:mmz", "yyyy-MM-ddTHH:mm", "ddd, MMM dd, yyyy H:mm:ss tt", "ddd MMM d yyyy HH:mm:ss zzz", "MMddyyyy", "ddMMyyyy", "Mddyyyy", "ddMyyyy", "Mdyyyy", "dMyyyy", "yyyy", "Mdyy", "dMyy", "d" ]); // real starting rule: tries selected formats first, // then general purpose rule g.start = function (s) { try { var r = g._formats.call({}, s); if (r[1].length === 0) { return r; } } catch (e) {} return g._start.call({}, s); }; }()); (function () { var $D = Date; /** * @desc Converts the specified string value into its JavaScript Date equivalent using CultureInfo specific format information. * * Example

	///////////
	// Dates //
	///////////

	// 15-Oct-2004
	var d1 = Date.parse("10/15/2004");

	// 15-Oct-2004
	var d1 = Date.parse("15-Oct-2004");

	// 15-Oct-2004
	var d1 = Date.parse("2004.10.15");

	//Fri Oct 15, 2004
	var d1 = Date.parse("Fri Oct 15, 2004");

	///////////
	// Times //
	///////////

	// Today at 10 PM.
	var d1 = Date.parse("10 PM");

	// Today at 10:30 PM.
	var d1 = Date.parse("10:30 P.M.");

	// Today at 6 AM.
	var d1 = Date.parse("06am");

	/////////////////////
	// Dates and Times //
	/////////////////////

	// 8-July-2004 @ 10:30 PM
	var d1 = Date.parse("July 8th, 2004, 10:30 PM");

	// 1-July-2004 @ 10:30 PM
	var d1 = Date.parse("2004-07-01T22:30:00");

	////////////////////
	// Relative Dates //
	////////////////////

	// Returns today's date. The string "today" is culture specific.
	var d1 = Date.parse("today");

	// Returns yesterday's date. The string "yesterday" is culture specific.
	var d1 = Date.parse("yesterday");

	// Returns the date of the next thursday.
	var d1 = Date.parse("Next thursday");

	// Returns the date of the most previous monday.
	var d1 = Date.parse("last monday");

	// Returns today's day + one year.
	var d1 = Date.parse("next year");

	///////////////
	// Date Math //
	///////////////

	// Today + 2 days
	var d1 = Date.parse("t+2");

	// Today + 2 days
	var d1 = Date.parse("today + 2 days");

	// Today + 3 months
	var d1 = Date.parse("t+3m");

	// Today - 1 year
	var d1 = Date.parse("today - 1 year");

	// Today - 1 year
	var d1 = Date.parse("t-1y"); 


	/////////////////////////////
	// Partial Dates and Times //
	/////////////////////////////

	// July 15th of this year.
	var d1 = Date.parse("July 15");

	// 15th day of current day and year.
	var d1 = Date.parse("15");

	// July 1st of current year at 10pm.
	var d1 = Date.parse("7/1 10pm");
	
* * @param {String} The string value to convert into a Date object [Required] * @return {Date} A Date object or null if the string cannot be converted into a Date. */ var parseUtils = { removeOrds: function (s) { ords = s.match(/\b(\d+)(?:st|nd|rd|th)\b/); // find ordinal matches s = ((ords && ords.length === 2) ? s.replace(ords[0], ords[1]) : s); return s; }, grammarParser: function (s) { var r = null; try { r = $D.Grammar.start.call({}, s.replace(/^\s*(\S*(\s+\S+)*)\s*$/, "$1")); } catch (e) { return null; } return ((r[1].length === 0) ? r[0] : null); }, nativeFallback: function(s) { var t; try { // ok we haven't parsed it, last ditch attempt with the built-in parser. t = Date._parse(s); return (t || t === 0) ? new Date(t) : null; } catch (e) { return null; } } }; function parse (s) { var d; if (!s) { return null; } if (s instanceof Date) { return s.clone(); } if (s.length >= 4 && s.charAt(0) !== "0" && s.charAt(0) !== "+"&& s.charAt(0) !== "-") { // ie: 2004 will pass, 0800 won't. // Start with specific formats d = $D.Parsing.ISO.parse(s) || $D.Parsing.Numeric.parse(s); } if (d instanceof Date && !isNaN(d.getTime())) { return d; } else { // find ordinal dates (1st, 3rd, 8th, etc and remove them as they cause parsing issues) s = $D.Parsing.Normalizer.parse(parseUtils.removeOrds(s)); d = parseUtils.grammarParser(s); if (d !== null) { return d; } else { return parseUtils.nativeFallback(s); } } } if (!$D._parse) { $D._parse = $D.parse; } $D.parse = parse; Date.getParseFunction = function (fx) { var fns = Date.Grammar.allformats(fx); return function (s) { var r = null; for (var i = 0; i < fns.length; i++) { try { r = fns[i].call({}, s); } catch (e) { continue; } if (r[1].length === 0) { return r[0]; } } return null; }; }; /** * Converts the specified string value into its JavaScript Date equivalent using the specified format {String} or formats {Array} and the CultureInfo specific format information. * The format of the string value must match one of the supplied formats exactly. * * Example

	// 15-Oct-2004
	var d1 = Date.parseExact("10/15/2004", "M/d/yyyy");

	// 15-Oct-2004
	var d1 = Date.parse("15-Oct-2004", "M-ddd-yyyy");

	// 15-Oct-2004
	var d1 = Date.parse("2004.10.15", "yyyy.MM.dd");

	// Multiple formats
	var d1 = Date.parseExact("10/15/2004", ["M/d/yyyy", "MMMM d, yyyy"]);
	
* * @param {String} The string value to convert into a Date object [Required]. * @param {Object} The expected format {String} or an array of expected formats {Array} of the date string [Required]. * @return {Date} A Date object or null if the string cannot be converted into a Date. */ $D.parseExact = function (s, fx) { return $D.getParseFunction(fx)(s); }; }()); (function () { var $D = Date, $P = $D.prototype, // $C = $D.CultureInfo, // not used atm p = function (s, l) { if (!l) { l = 2; } return ("000" + s).slice(l * -1); }; /** * Converts a PHP format string to Java/.NET format string. * A PHP format string can be used with ._format or .format. * A Java/.NET format string can be used with .toString(). * The .parseExact function will only accept a Java/.NET format string * * Example * var f1 = "%m/%d/%y" * var f2 = Date.normalizeFormat(f1); // "MM/dd/yy" * * new Date().format(f1); // "04/13/08" * new Date()._format(f1); // "04/13/08" * new Date().toString(f2); // "04/13/08" * * var date = Date.parseExact("04/13/08", f2); // Sun Apr 13 2008 * * @param {String} A PHP format string consisting of one or more format spcifiers. * @return {String} The PHP format converted to a Java/.NET format string. */ var normalizerSubstitutions = { "d" : "dd", "%d": "dd", "D" : "ddd", "%a": "ddd", "j" : "dddd", "l" : "dddd", "%A": "dddd", "S" : "S", "F" : "MMMM", "%B": "MMMM", "m" : "MM", "%m": "MM", "M" : "MMM", "%b": "MMM", "%h": "MMM", "n" : "M", "Y" : "yyyy", "%Y": "yyyy", "y" : "yy", "%y": "yy", "g" : "h", "%I": "h", "G" : "H", "h" : "hh", "H" : "HH", "%H": "HH", "i" : "mm", "%M": "mm", "s" : "ss", "%S": "ss", "%r": "hh:mm tt", "%R": "H:mm", "%T": "H:mm:ss", "%X": "t", "%x": "d", "%e": "d", "%D": "MM/dd/yy", "%n": "\\n", "%t": "\\t", "e" : "z", "T" : "z", "%z": "z", "%Z": "z", "Z" : "ZZ", "N" : "u", "w" : "u", "%w": "u", "W" : "W", "%V": "W" }; var normalizer = { substitutes: function (m) { return normalizerSubstitutions[m]; }, interpreted: function (m, x) { var y; switch (m) { case "%u": return x.getDay() + 1; case "z": return x.getOrdinalNumber(); case "%j": return p(x.getOrdinalNumber(), 3); case "%U": var d1 = x.clone().set({month: 0, day: 1}).addDays(-1).moveToDayOfWeek(0), d2 = x.clone().addDays(1).moveToDayOfWeek(0, -1); return (d2 < d1) ? "00" : p((d2.getOrdinalNumber() - d1.getOrdinalNumber()) / 7 + 1); case "%W": return p(x.getWeek()); case "t": return $D.getDaysInMonth(x.getFullYear(), x.getMonth()); case "o": case "%G": return x.setWeek(x.getISOWeek()).toString("yyyy"); case "%g": return x._format("%G").slice(-2); case "a": case "%p": return t("tt").toLowerCase(); case "A": return t("tt").toUpperCase(); case "u": return p(x.getMilliseconds(), 3); case "I": return (x.isDaylightSavingTime()) ? 1 : 0; case "O": return x.getUTCOffset(); case "P": y = x.getUTCOffset(); return y.substring(0, y.length - 2) + ":" + y.substring(y.length - 2); case "B": var now = new Date(); return Math.floor(((now.getHours() * 3600) + (now.getMinutes() * 60) + now.getSeconds() + (now.getTimezoneOffset() + 60) * 60) / 86.4); case "c": return x.toISOString().replace(/\"/g, ""); case "U": return $D.strtotime("now"); case "%c": return t("d") + " " + t("t"); case "%C": return Math.floor(x.getFullYear() / 100 + 1); } }, shouldOverrideDefaults: function (m) { switch (m) { case "%e": return true; default: return false; } }, parse: function (m, context) { var formatString, c = context || new Date(); formatString = normalizer.substitutes(m); if (formatString) { return formatString; } formatString = normalizer.interpreted(m, c); if (formatString) { return formatString; } else { return m; } } }; $D.normalizeFormat = function (format, context) { return format.replace(/(%|\\)?.|%%/g, function(t){ return normalizer.parse(t, context); }); }; /** * Format a local Unix timestamp according to locale settings * * Example: * Date.strftime("%m/%d/%y", new Date()); // "04/13/08" * Date.strftime("c", "2008-04-13T17:52:03Z"); // "04/13/08" * * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @param {Number|String} The number representing the number of seconds that have elapsed since January 1, 1970 (local time). * @return {String} A string representation of the current Date object. */ $D.strftime = function (format, time) { var d = Date.parse(time); return d._format(format); }; /** * Parse any textual datetime description into a Unix timestamp. * A Unix timestamp is the number of seconds that have elapsed since January 1, 1970 (midnight UTC/GMT). * * Example: * Date.strtotime("04/13/08"); // 1208044800 * Date.strtotime("1970-01-01T00:00:00Z"); // 0 * * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @param {Object} A string or date object. * @return {String} A string representation of the current Date object. */ $D.strtotime = function (time) { var d = $D.parse(time); return Math.round($D.UTC(d.getUTCFullYear(), d.getUTCMonth(), d.getUTCDate(), d.getUTCHours(), d.getUTCMinutes(), d.getUTCSeconds(), d.getUTCMilliseconds()) / 1000); }; /** * Converts the value of the current Date object to its equivalent string representation using a PHP/Unix style of date format specifiers. * Format Specifiers * Format Description Example * ------ --------------------------------------------------------------------------- ----------------------- * %a abbreviated weekday name according to the current localed "Mon" through "Sun" * %A full weekday name according to the current localed "Sunday" through "Saturday" * %b abbreviated month name according to the current localed "Jan" through "Dec" * %B full month name according to the current locale "January" through "December" * %c preferred date and time representation for the current locale "4/13/2008 12:33 PM" * %C century number (the year divided by 100 and truncated to an integer) "00" to "99" * %d day of the month as a decimal number "01" to "31" * %D same as %m/%d/%y "04/13/08" * %e day of the month as a decimal number, a single digit is preceded by a space "1" to "31" * %g like %G, but without the century "08" * %G The 4-digit year corresponding to the ISO week number (see %V). "2008" * This has the same format and value as %Y, except that if the ISO week number * belongs to the previous or next year, that year is used instead. * %h same as %b "Jan" through "Dec" * %H hour as a decimal number using a 24-hour clock. "00" to "23" * %I hour as a decimal number using a 12-hour clock. "01" to "12" * %j day of the year as a decimal number. "001" to "366" * %m month as a decimal number. "01" to "12" * %M minute as a decimal number. "00" to "59" * %n newline character "\n" * %p either "am" or "pm" according to the given time value, or the "am" or "pm" * corresponding strings for the current locale. * %r time in a.m. and p.m. notation "8:44 PM" * %R time in 24 hour notation "20:44" * %S second as a decimal number "00" to "59" * %t tab character "\t" * %T current time, equal to %H:%M:%S "12:49:11" * %u weekday as a decimal number ["1", "7"], with "1" representing Monday "1" to "7" * %U week number of the current year as a decimal number, starting with the "0" to ("52" or "53") * first Sunday as the first day of the first week * %V The ISO 8601:1988 week number of the current year as a decimal number, "00" to ("52" or "53") * range 01 to 53, where week 1 is the first week that has at least 4 days * in the current year, and with Monday as the first day of the week. * (Use %G or %g for the year component that corresponds to the week number * for the specified timestamp.) * %W week number of the current year as a decimal number, starting with the "00" to ("52" or "53") * first Monday as the first day of the first week * %w day of the week as a decimal, Sunday being "0" "0" to "6" * %x preferred date representation for the current locale without the time "4/13/2008" * %X preferred time representation for the current locale without the date "12:53:05" * %y year as a decimal number without a century "00" "99" * %Y year as a decimal number including the century "2008" * %Z time zone or name or abbreviation "UTC", "EST", "PST" * %z same as %Z * %% a literal "%" characters "%" * d Day of the month, 2 digits with leading zeros "01" to "31" * D A textual representation of a day, three letters "Mon" through "Sun" * j Day of the month without leading zeros "1" to "31" * l A full textual representation of the day of the week (lowercase "L") "Sunday" through "Saturday" * N ISO-8601 numeric representation of the day of the week (added in PHP 5.1.0) "1" (for Monday) through "7" (for Sunday) * S English ordinal suffix for the day of the month, 2 characters "st", "nd", "rd" or "th". Works well with j * w Numeric representation of the day of the week "0" (for Sunday) through "6" (for Saturday) * z The day of the year (starting from "0") "0" through "365" * W ISO-8601 week number of year, weeks starting on Monday "00" to ("52" or "53") * F A full textual representation of a month, such as January or March "January" through "December" * m Numeric representation of a month, with leading zeros "01" through "12" * M A short textual representation of a month, three letters "Jan" through "Dec" * n Numeric representation of a month, without leading zeros "1" through "12" * t Number of days in the given month "28" through "31" * L Whether it's a leap year "1" if it is a leap year, "0" otherwise * o ISO-8601 year number. This has the same value as Y, except that if the "2008" * ISO week number (W) belongs to the previous or next year, that year * is used instead. * Y A full numeric representation of a year, 4 digits "2008" * y A two digit representation of a year "08" * a Lowercase Ante meridiem and Post meridiem "am" or "pm" * A Uppercase Ante meridiem and Post meridiem "AM" or "PM" * B Swatch Internet time "000" through "999" * g 12-hour format of an hour without leading zeros "1" through "12" * G 24-hour format of an hour without leading zeros "0" through "23" * h 12-hour format of an hour with leading zeros "01" through "12" * H 24-hour format of an hour with leading zeros "00" through "23" * i Minutes with leading zeros "00" to "59" * s Seconds, with leading zeros "00" through "59" * u Milliseconds "54321" * e Timezone identifier "UTC", "EST", "PST" * I Whether or not the date is in daylight saving time (uppercase i) "1" if Daylight Saving Time, "0" otherwise * O Difference to Greenwich time (GMT) in hours "+0200", "-0600" * P Difference to Greenwich time (GMT) with colon between hours and minutes "+02:00", "-06:00" * T Timezone abbreviation "UTC", "EST", "PST" * Z Timezone offset in seconds. The offset for timezones west of UTC is "-43200" through "50400" * always negative, and for those east of UTC is always positive. * c ISO 8601 date "2004-02-12T15:19:21+00:00" * r RFC 2822 formatted date "Thu, 21 Dec 2000 16:01:07 +0200" * U Seconds since the Unix Epoch (January 1 1970 00:00:00 GMT) "0" * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @return {String} A string representation of the current Date object. */ var formatReplace = function (context) { return function (m) { var formatString, override = false; if (m.charAt(0) === "\\" || m.substring(0, 2) === "%%") { return m.replace("\\", "").replace("%%", "%"); } override = normalizer.shouldOverrideDefaults(m); formatString = $D.normalizeFormat(m, context); if (formatString) { return context.toString(formatString, override); } }; }; $P._format = function (format) { var formatter = formatReplace(this); if (!format) { return this._toString(); } else { return format.replace(/(%|\\)?.|%%/g, formatter); } }; if (!$P.format) { $P.format = $P._format; } }()); (function () { "use strict"; var gFn = function (attr) { return function () { return this[attr]; }; }; var sFn = function (attr) { return function (val) { this[attr] = val; return this; }; }; var attrs = ["years", "months", "days", "hours", "minutes", "seconds", "milliseconds"]; var addSetFuncs = function (context, attrs) { for (var i = 0; i < attrs.length ; i++) { var $a = attrs[i], $b = $a.slice(0, 1).toUpperCase() + $a.slice(1); context.prototype[$a] = 0; context.prototype["get" + $b] = gFn($a); context.prototype["set" + $b] = sFn($a); } }; /** * new TimeSpan(milliseconds); * new TimeSpan(days, hours, minutes, seconds); * new TimeSpan(days, hours, minutes, seconds, milliseconds); */ var TimeSpan = function (days, hours, minutes, seconds, milliseconds) { if (arguments.length === 1 && typeof days === "number") { var orient = (days < 0) ? -1 : +1; var millsLeft = Math.abs(days); this.setDays(Math.floor(millsLeft / 86400000) * orient); millsLeft = millsLeft % 86400000; this.setHours(Math.floor(millsLeft / 3600000) * orient); millsLeft = millsLeft % 3600000; this.setMinutes(Math.floor(millsLeft / 60000) * orient); millsLeft = millsLeft % 60000; this.setSeconds(Math.floor(millsLeft / 1000) * orient); millsLeft = millsLeft % 1000; this.setMilliseconds(millsLeft * orient); } else { this.set(days, hours, minutes, seconds, milliseconds); } this.getTotalMilliseconds = function () { return (this.getDays() * 86400000) + (this.getHours() * 3600000) + (this.getMinutes() * 60000) + (this.getSeconds() * 1000); }; this.compareTo = function (time) { var t1 = new Date(1970, 1, 1, this.getHours(), this.getMinutes(), this.getSeconds()), t2; if (time === null) { t2 = new Date(1970, 1, 1, 0, 0, 0); } else { t2 = new Date(1970, 1, 1, time.getHours(), time.getMinutes(), time.getSeconds()); } return (t1 < t2) ? -1 : (t1 > t2) ? 1 : 0; }; this.equals = function (time) { return (this.compareTo(time) === 0); }; this.add = function (time) { return (time === null) ? this : this.addSeconds(time.getTotalMilliseconds() / 1000); }; this.subtract = function (time) { return (time === null) ? this : this.addSeconds(-time.getTotalMilliseconds() / 1000); }; this.addDays = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 86400000)); }; this.addHours = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 3600000)); }; this.addMinutes = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 60000)); }; this.addSeconds = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 1000)); }; this.addMilliseconds = function (n) { return new TimeSpan(this.getTotalMilliseconds() + n); }; this.get12HourHour = function () { return (this.getHours() > 12) ? this.getHours() - 12 : (this.getHours() === 0) ? 12 : this.getHours(); }; this.getDesignator = function () { return (this.getHours() < 12) ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator; }; this.toString = function (format) { this._toString = function () { if (this.getDays() !== null && this.getDays() > 0) { return this.getDays() + "." + this.getHours() + ":" + this.p(this.getMinutes()) + ":" + this.p(this.getSeconds()); } else { return this.getHours() + ":" + this.p(this.getMinutes()) + ":" + this.p(this.getSeconds()); } }; this.p = function (s) { return (s.toString().length < 2) ? "0" + s : s; }; var me = this; return format ? format.replace(/dd?|HH?|hh?|mm?|ss?|tt?/g, function (format) { switch (format) { case "d": return me.getDays(); case "dd": return me.p(me.getDays()); case "H": return me.getHours(); case "HH": return me.p(me.getHours()); case "h": return me.get12HourHour(); case "hh": return me.p(me.get12HourHour()); case "m": return me.getMinutes(); case "mm": return me.p(me.getMinutes()); case "s": return me.getSeconds(); case "ss": return me.p(me.getSeconds()); case "t": return ((me.getHours() < 12) ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator).substring(0, 1); case "tt": return (me.getHours() < 12) ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator; } } ) : this._toString(); }; return this; }; addSetFuncs(TimeSpan, attrs.slice(2)); TimeSpan.prototype.set = function (days, hours, minutes, seconds, milliseconds){ this.setDays(days || this.getDays()); this.setHours(hours || this.getHours()); this.setMinutes(minutes || this.getMinutes()); this.setSeconds(seconds || this.getSeconds()); this.setMilliseconds(milliseconds || this.getMilliseconds()); }; /** * Gets the time of day for this date instances. * @return {TimeSpan} TimeSpan */ Date.prototype.getTimeOfDay = function () { return new TimeSpan(0, this.getHours(), this.getMinutes(), this.getSeconds(), this.getMilliseconds()); }; Date.TimeSpan = TimeSpan; if (typeof window !== "undefined" ) { // keeping API compatible for v1.x window.TimeSpan = TimeSpan; } }()); (function () { "use strict"; var attrs = ["years", "months", "days", "hours", "minutes", "seconds", "milliseconds"]; var gFn = function (attr) { return function () { return this[attr]; }; }; var sFn = function (attr) { return function (val) { this[attr] = val; return this; }; }; var addSetFuncs = function (context, attrs) { for (var i = 0; i < attrs.length ; i++) { var $a = attrs[i], $b = $a.slice(0, 1).toUpperCase() + $a.slice(1); context.prototype[$a] = 0; context.prototype["get" + $b] = gFn($a); context.prototype["set" + $b] = sFn($a); } }; var setMonthsAndYears = function (orient, d1, d2, context) { function inc() { d1.addMonths(-orient); context.months++; if (context.months === 12) { context.years++; context.months = 0; } } if (orient === +1) { while (d1 > d2) { inc(); } } else { while (d1 < d2) { inc(); } } context.months--; context.months *= orient; context.years *= orient; }; var adjustForDST = function(orient, startDate, endDate) { var hasDSTMismatch = (false === (startDate.isDaylightSavingTime() === endDate.isDaylightSavingTime())); if (hasDSTMismatch && orient === 1) { startDate.addHours(-1); } else if (hasDSTMismatch) { startDate.addHours(1); } }; /** * TimePeriod(startDate, endDate); * TimePeriod(years, months, days, hours, minutes, seconds, milliseconds); */ var TimePeriod = function (years, months, days, hours, minutes, seconds, milliseconds) { if (arguments.length === 7) { this.set(years, months, days, hours, minutes, seconds, milliseconds); } else if (arguments.length === 2 && arguments[0] instanceof Date && arguments[1] instanceof Date) { var startDate = arguments[0].clone(); var endDate = arguments[1].clone(); var orient = (startDate > endDate) ? +1 : -1; this.dates = { start: arguments[0].clone(), end: arguments[1].clone() }; setMonthsAndYears(orient, startDate, endDate, this); adjustForDST(orient, startDate, endDate); // // TODO - adjust for DST var diff = endDate - startDate; if (diff !== 0) { var ts = new TimeSpan(diff); this.set(this.years, this.months, ts.getDays(), ts.getHours(), ts.getMinutes(), ts.getSeconds(), ts.getMilliseconds()); } } return this; }; // create all the set functions. addSetFuncs(TimePeriod, attrs); TimePeriod.prototype.set = function (years, months, days, hours, minutes, seconds, milliseconds){ this.setYears(years || this.getYears()); this.setMonths(months || this.getMonths()); this.setDays(days || this.getDays()); this.setHours(hours || this.getHours()); this.setMinutes(minutes || this.getMinutes()); this.setSeconds(seconds || this.getSeconds()); this.setMilliseconds(milliseconds || this.getMilliseconds()); }; Date.TimePeriod = TimePeriod; if (typeof window !== "undefined") { // keeping API compatible for v1.x window.TimePeriod = TimePeriod; } }()); ================================================ FILE: build/date-sr-Cyrl-CS.js ================================================ /** * @overview datejs * @version 1.0.0-rc3 * @author Gregory Wild-Smith * @copyright 2015 Gregory Wild-Smith * @license MIT * @homepage https://github.com/abritinthebay/datejs */ /* * DateJS Culture String File * Country Code: sr-Cyrl-CS * Name: Serbian (Cyrillic, Serbia) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["sr-Cyrl-CS"] = { "name": "sr-Cyrl-CS", "englishName": "Serbian (Cyrillic, Serbia)", "nativeName": "српски (Србија)", "Sunday": "недеља", "Monday": "понедељак", "Tuesday": "уторак", "Wednesday": "среда", "Thursday": "четвртак", "Friday": "петак", "Saturday": "субота", "Sun": "нед", "Mon": "пон", "Tue": "уто", "Wed": "сре", "Thu": "чет", "Fri": "пет", "Sat": "суб", "Su": "не", "Mo": "по", "Tu": "ут", "We": "ср", "Th": "че", "Fr": "пе", "Sa": "су", "S_Sun_Initial": "н", "M_Mon_Initial": "п", "T_Tue_Initial": "у", "W_Wed_Initial": "с", "T_Thu_Initial": "ч", "F_Fri_Initial": "п", "S_Sat_Initial": "с", "January": "јануар", "February": "фебруар", "March": "март", "April": "април", "May": "мај", "June": "јун", "July": "јул", "August": "август", "September": "септембар", "October": "октобар", "November": "новембар", "December": "децембар", "Jan_Abbr": "јан", "Feb_Abbr": "феб", "Mar_Abbr": "мар", "Apr_Abbr": "апр", "May_Abbr": "мај", "Jun_Abbr": "јун", "Jul_Abbr": "јул", "Aug_Abbr": "авг", "Sep_Abbr": "сеп", "Oct_Abbr": "окт", "Nov_Abbr": "нов", "Dec_Abbr": "дец", "AM": "", "PM": "", "firstDayOfWeek": 1, "twoDigitYearMax": 2029, "mdy": "dmy", "M/d/yyyy": "d.M.yyyy", "dddd, MMMM dd, yyyy": "d. MMMM yyyy", "h:mm tt": "H:mm", "h:mm:ss tt": "H:mm:ss", "dddd, MMMM dd, yyyy h:mm:ss tt": "d. MMMM yyyy H:mm:ss", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "d. MMMM", "MMMM, yyyy": "MMMM yyyy", "/jan(uary)?/": "јан(уар)?", "/feb(ruary)?/": "феб(руар)?", "/mar(ch)?/": "мар(т)?", "/apr(il)?/": "апр(ил)?", "/may/": "мај", "/jun(e)?/": "јун", "/jul(y)?/": "јул", "/aug(ust)?/": "авг(уст)?", "/sep(t(ember)?)?/": "сеп(тембар)?", "/oct(ober)?/": "окт(обар)?", "/nov(ember)?/": "нов(ембар)?", "/dec(ember)?/": "дец(ембар)?", "/^su(n(day)?)?/": "^не(д(еља)?)?", "/^mo(n(day)?)?/": "^по(н(едељак)?)?", "/^tu(e(s(day)?)?)?/": "^ут(о(рак)?)?", "/^we(d(nesday)?)?/": "^ср(е(да)?)?", "/^th(u(r(s(day)?)?)?)?/": "^че(т(вртак)?)?", "/^fr(i(day)?)?/": "^пе(т(ак)?)?", "/^sa(t(urday)?)?/": "^су(б(ота)?)?", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "sr-Cyrl-CS"; /** * @overview datejs * @version 1.0.0-rc3 * @author Gregory Wild-Smith * @copyright 2015 Gregory Wild-Smith * @license MIT * @homepage https://github.com/abritinthebay/datejs */(function () { var $D = Date; var lang = Date.CultureStrings ? Date.CultureStrings.lang : null; var loggedKeys = {}; // for debug purposes. var getText = { getFromKey: function (key, countryCode) { var output; if (Date.CultureStrings && Date.CultureStrings[countryCode] && Date.CultureStrings[countryCode][key]) { output = Date.CultureStrings[countryCode][key]; } else { output = getText.buildFromDefault(key); } if (key.charAt(0) === "/") { // Assume it's a regex output = getText.buildFromRegex(key, countryCode); } return output; }, getFromObjectValues: function (obj, countryCode) { var key, output = {}; for(key in obj) { if (obj.hasOwnProperty(key)) { output[key] = getText.getFromKey(obj[key], countryCode); } } return output; }, getFromObjectKeys: function (obj, countryCode) { var key, output = {}; for(key in obj) { if (obj.hasOwnProperty(key)) { output[getText.getFromKey(key, countryCode)] = obj[key]; } } return output; }, getFromArray: function (arr, countryCode) { var output = []; for (var i=0; i < arr.length; i++){ if (i in arr) { output[i] = getText.getFromKey(arr[i], countryCode); } } return output; }, buildFromDefault: function (key) { var output, length, split, last; switch(key) { case "name": output = "en-US"; break; case "englishName": output = "English (United States)"; break; case "nativeName": output = "English (United States)"; break; case "twoDigitYearMax": output = 2049; break; case "firstDayOfWeek": output = 0; break; default: output = key; split = key.split("_"); length = split.length; if (length > 1 && key.charAt(0) !== "/") { // if the key isn't a regex and it has a split. last = split[(length - 1)].toLowerCase(); if (last === "initial" || last === "abbr") { output = split[0]; } } break; } return output; }, buildFromRegex: function (key, countryCode) { var output; if (Date.CultureStrings && Date.CultureStrings[countryCode] && Date.CultureStrings[countryCode][key]) { output = new RegExp(Date.CultureStrings[countryCode][key], "i"); } else { output = new RegExp(key.replace(new RegExp("/", "g"),""), "i"); } return output; } }; var shallowMerge = function (obj1, obj2) { for (var attrname in obj2) { if (obj2.hasOwnProperty(attrname)) { obj1[attrname] = obj2[attrname]; } } }; var __ = function (key, language) { var countryCode = (language) ? language : lang; loggedKeys[key] = key; if (typeof key === "object") { if (key instanceof Array) { return getText.getFromArray(key, countryCode); } else { return getText.getFromObjectKeys(key, countryCode); } } else { return getText.getFromKey(key, countryCode); } }; var loadI18nScript = function (code) { // paatterned after jQuery's getScript. var url = Date.Config.i18n + code + ".js"; var head = document.getElementsByTagName("head")[0] || document.documentElement; var script = document.createElement("script"); script.src = url; var completed = false; var events = { done: function (){} // placeholder function }; // Attach handlers for all browsers script.onload = script.onreadystatechange = function() { if ( !completed && (!this.readyState || this.readyState === "loaded" || this.readyState === "complete") ) { events.done(); head.removeChild(script); } }; setTimeout(function() { head.insertBefore(script, head.firstChild); }, 0); // allows return to execute first return { done: function (cb) { events.done = function() { if (cb) { setTimeout(cb,0); } }; } }; }; var buildInfo = { buildFromMethodHash: function (obj) { var key; for(key in obj) { if (obj.hasOwnProperty(key)) { obj[key] = buildInfo[obj[key]](); } } return obj; }, timeZoneDST: function () { var DST = { "CHADT": "+1345", "NZDT": "+1300", "AEDT": "+1100", "ACDT": "+1030", "AZST": "+0500", "IRDT": "+0430", "EEST": "+0300", "CEST": "+0200", "BST": "+0100", "PMDT": "-0200", "ADT": "-0300", "NDT": "-0230", "EDT": "-0400", "CDT": "-0500", "MDT": "-0600", "PDT": "-0700", "AKDT": "-0800", "HADT": "-0900" }; return __(DST); }, timeZoneStandard: function () { var standard = { "LINT": "+1400", "TOT": "+1300", "CHAST": "+1245", "NZST": "+1200", "NFT": "+1130", "SBT": "+1100", "AEST": "+1000", "ACST": "+0930", "JST": "+0900", "CWST": "+0845", "CT": "+0800", "ICT": "+0700", "MMT": "+0630", "BST": "+0600", "NPT": "+0545", "IST": "+0530", "PKT": "+0500", "AFT": "+0430", "MSK": "+0400", "IRST": "+0330", "FET": "+0300", "EET": "+0200", "CET": "+0100", "GMT": "+0000", "UTC": "+0000", "CVT": "-0100", "GST": "-0200", "BRT": "-0300", "NST": "-0330", "AST": "-0400", "EST": "-0500", "CST": "-0600", "MST": "-0700", "PST": "-0800", "AKST": "-0900", "MIT": "-0930", "HST": "-1000", "SST": "-1100", "BIT": "-1200" }; return __(standard); }, timeZones: function (data) { var zone; data.timezones = []; for (zone in data.abbreviatedTimeZoneStandard) { if (data.abbreviatedTimeZoneStandard.hasOwnProperty(zone)) { data.timezones.push({ name: zone, offset: data.abbreviatedTimeZoneStandard[zone]}); } } for (zone in data.abbreviatedTimeZoneDST) { if (data.abbreviatedTimeZoneDST.hasOwnProperty(zone)) { data.timezones.push({ name: zone, offset: data.abbreviatedTimeZoneDST[zone], dst: true}); } } return data.timezones; }, days: function () { return __(["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"]); }, dayAbbr: function () { return __(["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"]); }, dayShortNames: function () { return __(["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"]); }, dayFirstLetters: function () { return __(["S_Sun_Initial", "M_Mon_Initial", "T_Tues_Initial", "W_Wed_Initial", "T_Thu_Initial", "F_Fri_Initial", "S_Sat_Initial"]); }, months: function () { return __(["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"]); }, monthAbbr: function () { return __(["Jan_Abbr", "Feb_Abbr", "Mar_Abbr", "Apr_Abbr", "May_Abbr", "Jun_Abbr", "Jul_Abbr", "Aug_Abbr", "Sep_Abbr", "Oct_Abbr", "Nov_Abbr", "Dec_Abbr"]); }, formatPatterns: function () { return getText.getFromObjectValues({ shortDate: "M/d/yyyy", longDate: "dddd, MMMM dd, yyyy", shortTime: "h:mm tt", longTime: "h:mm:ss tt", fullDateTime: "dddd, MMMM dd, yyyy h:mm:ss tt", sortableDateTime: "yyyy-MM-ddTHH:mm:ss", universalSortableDateTime: "yyyy-MM-dd HH:mm:ssZ", rfc1123: "ddd, dd MMM yyyy HH:mm:ss", monthDay: "MMMM dd", yearMonth: "MMMM, yyyy" }, Date.i18n.currentLanguage()); }, regex: function () { return getText.getFromObjectValues({ inTheMorning: "/( in the )(morn(ing)?)\\b/", thisMorning: "/(this )(morn(ing)?)\\b/", amThisMorning: "/(\b\\d(am)? )(this )(morn(ing)?)/", inTheEvening: "/( in the )(even(ing)?)\\b/", thisEvening: "/(this )(even(ing)?)\\b/", pmThisEvening: "/(\b\\d(pm)? )(this )(even(ing)?)/", jan: "/jan(uary)?/", feb: "/feb(ruary)?/", mar: "/mar(ch)?/", apr: "/apr(il)?/", may: "/may/", jun: "/jun(e)?/", jul: "/jul(y)?/", aug: "/aug(ust)?/", sep: "/sep(t(ember)?)?/", oct: "/oct(ober)?/", nov: "/nov(ember)?/", dec: "/dec(ember)?/", sun: "/^su(n(day)?)?/", mon: "/^mo(n(day)?)?/", tue: "/^tu(e(s(day)?)?)?/", wed: "/^we(d(nesday)?)?/", thu: "/^th(u(r(s(day)?)?)?)?/", fri: "/fr(i(day)?)?/", sat: "/^sa(t(urday)?)?/", future: "/^next/", past: "/^last|past|prev(ious)?/", add: "/^(\\+|aft(er)?|from|hence)/", subtract: "/^(\\-|bef(ore)?|ago)/", yesterday: "/^yes(terday)?/", today: "/^t(od(ay)?)?/", tomorrow: "/^tom(orrow)?/", now: "/^n(ow)?/", millisecond: "/^ms|milli(second)?s?/", second: "/^sec(ond)?s?/", minute: "/^mn|min(ute)?s?/", hour: "/^h(our)?s?/", week: "/^w(eek)?s?/", month: "/^m(onth)?s?/", day: "/^d(ay)?s?/", year: "/^y(ear)?s?/", shortMeridian: "/^(a|p)/", longMeridian: "/^(a\\.?m?\\.?|p\\.?m?\\.?)/", timezone: "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/", ordinalSuffix: "/^\\s*(st|nd|rd|th)/", timeContext: "/^\\s*(\\:|a(?!u|p)|p)/" }, Date.i18n.currentLanguage()); } }; var CultureInfo = function () { var info = getText.getFromObjectValues({ name: "name", englishName: "englishName", nativeName: "nativeName", amDesignator: "AM", pmDesignator: "PM", firstDayOfWeek: "firstDayOfWeek", twoDigitYearMax: "twoDigitYearMax", dateElementOrder: "mdy" }, Date.i18n.currentLanguage()); var constructedInfo = buildInfo.buildFromMethodHash({ dayNames: "days", abbreviatedDayNames: "dayAbbr", shortestDayNames: "dayShortNames", firstLetterDayNames: "dayFirstLetters", monthNames: "months", abbreviatedMonthNames: "monthAbbr", formatPatterns: "formatPatterns", regexPatterns: "regex", abbreviatedTimeZoneDST: "timeZoneDST", abbreviatedTimeZoneStandard: "timeZoneStandard" }); shallowMerge(info, constructedInfo); buildInfo.timeZones(info); return info; }; $D.i18n = { __: function (key, lang) { return __(key, lang); }, currentLanguage: function () { return lang || "en-US"; }, setLanguage: function (code, force, cb) { var async = false; if (force || code === "en-US" || (!!Date.CultureStrings && !!Date.CultureStrings[code])) { lang = code; Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings.lang = code; Date.CultureInfo = new CultureInfo(); } else { if (!(!!Date.CultureStrings && !!Date.CultureStrings[code])) { if (typeof exports !== "undefined" && this.exports !== exports) { // we're in a Node enviroment, load it using require try { require("../i18n/" + code + ".js"); lang = code; Date.CultureStrings.lang = code; Date.CultureInfo = new CultureInfo(); } catch (e) { // var str = "The language for '" + code + "' could not be loaded by Node. It likely does not exist."; throw new Error("The DateJS IETF language tag '" + code + "' could not be loaded by Node. It likely does not exist."); } } else if (Date.Config && Date.Config.i18n) { // we know the location of the files, so lets load them async = true; loadI18nScript(code).done(function(){ lang = code; Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings.lang = code; Date.CultureInfo = new CultureInfo(); $D.Parsing.Normalizer.buildReplaceData(); // because this is async if ($D.Grammar) { $D.Grammar.buildGrammarFormats(); // so we can parse those strings... } if (cb) { setTimeout(cb,0); } }); } else { Date.console.error("The DateJS IETF language tag '" + code + "' is not available and has not been loaded."); return false; } } } $D.Parsing.Normalizer.buildReplaceData(); // rebuild normalizer strings if ($D.Grammar) { $D.Grammar.buildGrammarFormats(); // so we can parse those strings... } if (!async && cb) { setTimeout(cb,0); } }, getLoggedKeys: function () { return loggedKeys; }, updateCultureInfo: function () { Date.CultureInfo = new CultureInfo(); } }; $D.i18n.updateCultureInfo(); // run automatically }()); (function () { var $D = Date, $P = $D.prototype, p = function (s, l) { if (!l) { l = 2; } return ("000" + s).slice(l * -1); }; if (typeof window !== "undefined" && typeof window.console !== "undefined" && typeof window.console.log !== "undefined") { $D.console = console; // used only to raise non-critical errors if available } else { // set mock so we don't give errors. $D.console = { log: function(){}, error: function(){} }; } $D.Config = $D.Config || {}; $D.initOverloads = function() { /** * Overload of Date.now. Allows an alternate call for Date.now where it returns the * current Date as an object rather than just milliseconds since the Unix Epoch. * * Also provides an implementation of now() for browsers (IE<9) that don't have it. * * Backwards compatible so with work with either: * Date.now() [returns ms] * or * Date.now(true) [returns Date] */ if (!$D.now) { $D._now = function now() { return new Date().getTime(); }; } else if (!$D._now) { $D._now = $D.now; } $D.now = function (returnObj) { if (returnObj) { return $D.present(); } else { return $D._now(); } }; if ( !$P.toISOString ) { $P.toISOString = function() { return this.getUTCFullYear() + "-" + p(this.getUTCMonth() + 1) + "-" + p(this.getUTCDate()) + "T" + p(this.getUTCHours()) + ":" + p(this.getUTCMinutes()) + ":" + p(this.getUTCSeconds()) + "." + String( (this.getUTCMilliseconds()/1000).toFixed(3)).slice(2, 5) + "Z"; }; } // private if ( $P._toString === undefined ){ $P._toString = $P.toString; } }; $D.initOverloads(); /** * Gets a date that is set to the current date. The time is set to the start of the day (00:00 or 12:00 AM). * @return {Date} The current date. */ $D.today = function () { return new Date().clearTime(); }; /** * Gets a date that is set to the current date and time (same as new Date, but chainable) * @return {Date} The current date. */ $D.present = function () { return new Date(); }; /** * Compares the first date to the second date and returns an number indication of their relative values. * @param {Date} First Date object to compare [Required]. * @param {Date} Second Date object to compare to [Required]. * @return {Number} -1 = date1 is lessthan date2. 0 = values are equal. 1 = date1 is greaterthan date2. */ $D.compare = function (date1, date2) { if (isNaN(date1) || isNaN(date2)) { throw new Error(date1 + " - " + date2); } else if (date1 instanceof Date && date2 instanceof Date) { return (date1 < date2) ? -1 : (date1 > date2) ? 1 : 0; } else { throw new TypeError(date1 + " - " + date2); } }; /** * Compares the first Date object to the second Date object and returns true if they are equal. * @param {Date} First Date object to compare [Required] * @param {Date} Second Date object to compare to [Required] * @return {Boolean} true if dates are equal. false if they are not equal. */ $D.equals = function (date1, date2) { return (date1.compareTo(date2) === 0); }; /** * Gets the language appropriate day name when given the day number(0-6) * eg - 0 == Sunday * @return {String} The day name */ $D.getDayName = function (n) { return Date.CultureInfo.dayNames[n]; }; /** * Gets the day number (0-6) if given a CultureInfo specific string which is a valid dayName, abbreviatedDayName or shortestDayName (two char). * @param {String} The name of the day (eg. "Monday, "Mon", "tuesday", "tue", "We", "we"). * @return {Number} The day number */ $D.getDayNumberFromName = function (name) { var n = Date.CultureInfo.dayNames, m = Date.CultureInfo.abbreviatedDayNames, o = Date.CultureInfo.shortestDayNames, s = name.toLowerCase(); for (var i = 0; i < n.length; i++) { if (n[i].toLowerCase() === s || m[i].toLowerCase() === s || o[i].toLowerCase() === s) { return i; } } return -1; }; /** * Gets the month number (0-11) if given a Culture Info specific string which is a valid monthName or abbreviatedMonthName. * @param {String} The name of the month (eg. "February, "Feb", "october", "oct"). * @return {Number} The day number */ $D.getMonthNumberFromName = function (name) { var n = Date.CultureInfo.monthNames, m = Date.CultureInfo.abbreviatedMonthNames, s = name.toLowerCase(); for (var i = 0; i < n.length; i++) { if (n[i].toLowerCase() === s || m[i].toLowerCase() === s) { return i; } } return -1; }; /** * Gets the language appropriate month name when given the month number(0-11) * eg - 0 == January * @return {String} The month name */ $D.getMonthName = function (n) { return Date.CultureInfo.monthNames[n]; }; /** * Determines if the current date instance is within a LeapYear. * @param {Number} The year. * @return {Boolean} true if date is within a LeapYear, otherwise false. */ $D.isLeapYear = function (year) { return ((year % 4 === 0 && year % 100 !== 0) || year % 400 === 0); }; /** * Gets the number of days in the month, given a year and month value. Automatically corrects for LeapYear. * @param {Number} The year. * @param {Number} The month (0-11). * @return {Number} The number of days in the month. */ $D.getDaysInMonth = function (year, month) { if (!month && $D.validateMonth(year)) { month = year; year = Date.today().getFullYear(); } return [31, ($D.isLeapYear(year) ? 29 : 28), 31, 30, 31, 30, 31, 31, 30, 31, 30, 31][month]; }; $P.getDaysInMonth = function () { return $D.getDaysInMonth(this.getFullYear(), this.getMonth()); }; $D.getTimezoneAbbreviation = function (offset, dst) { var p, n = (dst || false) ? Date.CultureInfo.abbreviatedTimeZoneDST : Date.CultureInfo.abbreviatedTimeZoneStandard; for (p in n) { if (n.hasOwnProperty(p)) { if (n[p] === offset) { return p; } } } return null; }; $D.getTimezoneOffset = function (name, dst) { var i, a =[], z = Date.CultureInfo.timezones; if (!name) { name = (new Date()).getTimezone();} for (i = 0; i < z.length; i++) { if (z[i].name === name.toUpperCase()) { a.push(i); } } if (!z[a[0]]) { return null; } if (a.length === 1 || !dst) { return z[a[0]].offset; } else { for (i=0; i < a.length; i++) { if (z[a[i]].dst) { return z[a[i]].offset; } } } }; $D.getQuarter = function (d) { d = d || new Date(); // If no date supplied, use today var q = [1,2,3,4]; return q[Math.floor(d.getMonth() / 3)]; // ~~~ is a bitwise op. Faster than Math.floor }; $D.getDaysLeftInQuarter = function (d) { d = d || new Date(); var qEnd = new Date(d); qEnd.setMonth(qEnd.getMonth() + 3 - qEnd.getMonth() % 3, 0); return Math.floor((qEnd - d) / 8.64e7); }; // private var validate = function (n, min, max, name) { name = name ? name : "Object"; if (typeof n === "undefined") { return false; } else if (typeof n !== "number") { throw new TypeError(n + " is not a Number."); } else if (n < min || n > max) { // As failing validation is *not* an exceptional circumstance // lets not throw a RangeError Exception here. // It's semantically correct but it's not sensible. return false; } return true; }; /** * Validates the number is within an acceptable range for milliseconds [0-999]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateMillisecond = function (value) { return validate(value, 0, 999, "millisecond"); }; /** * Validates the number is within an acceptable range for seconds [0-59]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateSecond = function (value) { return validate(value, 0, 59, "second"); }; /** * Validates the number is within an acceptable range for minutes [0-59]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateMinute = function (value) { return validate(value, 0, 59, "minute"); }; /** * Validates the number is within an acceptable range for hours [0-23]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateHour = function (value) { return validate(value, 0, 23, "hour"); }; /** * Validates the number is within an acceptable range for the days in a month [0-MaxDaysInMonth]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateDay = function (value, year, month) { if (year === undefined || year === null || month === undefined || month === null) { return false;} return validate(value, 1, $D.getDaysInMonth(year, month), "day"); }; /** * Validates the number is within an acceptable range for months [0-11]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateWeek = function (value) { return validate(value, 0, 53, "week"); }; /** * Validates the number is within an acceptable range for months [0-11]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateMonth = function (value) { return validate(value, 0, 11, "month"); }; /** * Validates the number is within an acceptable range for years. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateYear = function (value) { /** * Per ECMAScript spec the range of times supported by Date objects is * exactly -100,000,000 days to +100,000,000 days measured relative to * midnight at the beginning of 01 January, 1970 UTC. * This gives a range of 8,640,000,000,000,000 milliseconds to either * side of 01 January, 1970 UTC. * * Earliest possible date: Tue, 20 Apr 271,822 B.C. 00:00:00 UTC * Latest possible date: Sat, 13 Sep 275,760 00:00:00 UTC */ return validate(value, -271822, 275760, "year"); }; $D.validateTimezone = function(value) { var timezones = {"ACDT":1,"ACST":1,"ACT":1,"ADT":1,"AEDT":1,"AEST":1,"AFT":1,"AKDT":1,"AKST":1,"AMST":1,"AMT":1,"ART":1,"AST":1,"AWDT":1,"AWST":1,"AZOST":1,"AZT":1,"BDT":1,"BIOT":1,"BIT":1,"BOT":1,"BRT":1,"BST":1,"BTT":1,"CAT":1,"CCT":1,"CDT":1,"CEDT":1,"CEST":1,"CET":1,"CHADT":1,"CHAST":1,"CHOT":1,"ChST":1,"CHUT":1,"CIST":1,"CIT":1,"CKT":1,"CLST":1,"CLT":1,"COST":1,"COT":1,"CST":1,"CT":1,"CVT":1,"CWST":1,"CXT":1,"DAVT":1,"DDUT":1,"DFT":1,"EASST":1,"EAST":1,"EAT":1,"ECT":1,"EDT":1,"EEDT":1,"EEST":1,"EET":1,"EGST":1,"EGT":1,"EIT":1,"EST":1,"FET":1,"FJT":1,"FKST":1,"FKT":1,"FNT":1,"GALT":1,"GAMT":1,"GET":1,"GFT":1,"GILT":1,"GIT":1,"GMT":1,"GST":1,"GYT":1,"HADT":1,"HAEC":1,"HAST":1,"HKT":1,"HMT":1,"HOVT":1,"HST":1,"ICT":1,"IDT":1,"IOT":1,"IRDT":1,"IRKT":1,"IRST":1,"IST":1,"JST":1,"KGT":1,"KOST":1,"KRAT":1,"KST":1,"LHST":1,"LINT":1,"MAGT":1,"MART":1,"MAWT":1,"MDT":1,"MET":1,"MEST":1,"MHT":1,"MIST":1,"MIT":1,"MMT":1,"MSK":1,"MST":1,"MUT":1,"MVT":1,"MYT":1,"NCT":1,"NDT":1,"NFT":1,"NPT":1,"NST":1,"NT":1,"NUT":1,"NZDT":1,"NZST":1,"OMST":1,"ORAT":1,"PDT":1,"PET":1,"PETT":1,"PGT":1,"PHOT":1,"PHT":1,"PKT":1,"PMDT":1,"PMST":1,"PONT":1,"PST":1,"PYST":1,"PYT":1,"RET":1,"ROTT":1,"SAKT":1,"SAMT":1,"SAST":1,"SBT":1,"SCT":1,"SGT":1,"SLST":1,"SRT":1,"SST":1,"SYOT":1,"TAHT":1,"THA":1,"TFT":1,"TJT":1,"TKT":1,"TLT":1,"TMT":1,"TOT":1,"TVT":1,"UCT":1,"ULAT":1,"UTC":1,"UYST":1,"UYT":1,"UZT":1,"VET":1,"VLAT":1,"VOLT":1,"VOST":1,"VUT":1,"WAKT":1,"WAST":1,"WAT":1,"WEDT":1,"WEST":1,"WET":1,"WST":1,"YAKT":1,"YEKT":1,"Z":1}; return (timezones[value] === 1); }; $D.validateTimezoneOffset= function(value) { // timezones go from +14hrs to -12hrs, the +X hours are negative offsets. return (value > -841 && value < 721); }; }()); (function () { var $D = Date, $P = $D.prototype, p = function (s, l) { if (!l) { l = 2; } return ("000" + s).slice(l * -1); }; var validateConfigObject = function (obj) { var result = {}, self = this, prop, testFunc; testFunc = function (prop, func, value) { if (prop === "day") { var month = (obj.month !== undefined) ? obj.month : self.getMonth(); var year = (obj.year !== undefined) ? obj.year : self.getFullYear(); return $D[func](value, year, month); } else { return $D[func](value); } }; for (prop in obj) { if (Object.prototype.hasOwnProperty.call(obj, prop)) { var func = "validate" + prop.charAt(0).toUpperCase() + prop.slice(1); if ($D[func] && obj[prop] !== null && testFunc(prop, func, obj[prop])) { result[prop] = obj[prop]; } } } return result; }; /** * Resets the time of this Date object to 12:00 AM (00:00), which is the start of the day. * @param {Boolean} .clone() this date instance before clearing Time * @return {Date} this */ $P.clearTime = function () { this.setHours(0); this.setMinutes(0); this.setSeconds(0); this.setMilliseconds(0); return this; }; /** * Resets the time of this Date object to the current time ('now'). * @return {Date} this */ $P.setTimeToNow = function () { var n = new Date(); this.setHours(n.getHours()); this.setMinutes(n.getMinutes()); this.setSeconds(n.getSeconds()); this.setMilliseconds(n.getMilliseconds()); return this; }; /** * Returns a new Date object that is an exact date and time copy of the original instance. * @return {Date} A new Date instance */ $P.clone = function () { return new Date(this.getTime()); }; /** * Compares this instance to a Date object and returns an number indication of their relative values. * @param {Date} Date object to compare [Required] * @return {Number} -1 = this is lessthan date. 0 = values are equal. 1 = this is greaterthan date. */ $P.compareTo = function (date) { return Date.compare(this, date); }; /** * Compares this instance to another Date object and returns true if they are equal. * @param {Date} Date object to compare. If no date to compare, new Date() [now] is used. * @return {Boolean} true if dates are equal. false if they are not equal. */ $P.equals = function (date) { return Date.equals(this, (date !== undefined ? date : new Date())); }; /** * Determines if this instance is between a range of two dates or equal to either the start or end dates. * @param {Date} Start of range [Required] * @param {Date} End of range [Required] * @return {Boolean} true is this is between or equal to the start and end dates, else false */ $P.between = function (start, end) { return this.getTime() >= start.getTime() && this.getTime() <= end.getTime(); }; /** * Determines if this date occurs after the date to compare to. * @param {Date} Date object to compare. If no date to compare, new Date() ("now") is used. * @return {Boolean} true if this date instance is greater than the date to compare to (or "now"), otherwise false. */ $P.isAfter = function (date) { return this.compareTo(date || new Date()) === 1; }; /** * Determines if this date occurs before the date to compare to. * @param {Date} Date object to compare. If no date to compare, new Date() ("now") is used. * @return {Boolean} true if this date instance is less than the date to compare to (or "now"). */ $P.isBefore = function (date) { return (this.compareTo(date || new Date()) === -1); }; /** * Determines if the current Date instance occurs today. * @return {Boolean} true if this date instance is 'today', otherwise false. */ /** * Determines if the current Date instance occurs on the same Date as the supplied 'date'. * If no 'date' to compare to is provided, the current Date instance is compared to 'today'. * @param {date} Date object to compare. If no date to compare, the current Date ("now") is used. * @return {Boolean} true if this Date instance occurs on the same Day as the supplied 'date'. */ $P.isToday = $P.isSameDay = function (date) { return this.clone().clearTime().equals((date || new Date()).clone().clearTime()); }; /** * Adds the specified number of milliseconds to this instance. * @param {Number} The number of milliseconds to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addMilliseconds = function (value) { if (!value) { return this; } this.setTime(this.getTime() + value * 1); return this; }; /** * Adds the specified number of seconds to this instance. * @param {Number} The number of seconds to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addSeconds = function (value) { if (!value) { return this; } return this.addMilliseconds(value * 1000); }; /** * Adds the specified number of seconds to this instance. * @param {Number} The number of seconds to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addMinutes = function (value) { if (!value) { return this; } return this.addMilliseconds(value * 60000); // 60*1000 }; /** * Adds the specified number of hours to this instance. * @param {Number} The number of hours to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addHours = function (value) { if (!value) { return this; } return this.addMilliseconds(value * 3600000); // 60*60*1000 }; /** * Adds the specified number of days to this instance. * @param {Number} The number of days to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addDays = function (value) { if (!value) { return this; } this.setDate(this.getDate() + value * 1); return this; }; /** * Adds the specified number of weekdays (ie - not sat or sun) to this instance. * @param {Number} The number of days to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addWeekdays = function (value) { if (!value) { return this; } var day = this.getDay(); var weeks = (Math.ceil(Math.abs(value)/7)); if (day === 0 || day === 6) { if (value > 0) { this.next().monday(); this.addDays(-1); day = this.getDay(); } } if (value < 0) { while (value < 0) { this.addDays(-1); day = this.getDay(); if (day !== 0 && day !== 6) { value++; } } return this; } else if (value > 5 || (6-day) <= value) { value = value + (weeks * 2); } return this.addDays(value); }; /** * Adds the specified number of weeks to this instance. * @param {Number} The number of weeks to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addWeeks = function (value) { if (!value) { return this; } return this.addDays(value * 7); }; /** * Adds the specified number of months to this instance. * @param {Number} The number of months to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addMonths = function (value) { if (!value) { return this; } var n = this.getDate(); this.setDate(1); this.setMonth(this.getMonth() + value * 1); this.setDate(Math.min(n, $D.getDaysInMonth(this.getFullYear(), this.getMonth()))); return this; }; $P.addQuarters = function (value) { if (!value) { return this; } // note this will take you to the same point in the quarter as you are now. // i.e. - if you are 15 days into the quarter you'll be 15 days into the resulting one. // bonus: this allows adding fractional quarters return this.addMonths(value * 3); }; /** * Adds the specified number of years to this instance. * @param {Number} The number of years to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addYears = function (value) { if (!value) { return this; } return this.addMonths(value * 12); }; /** * Adds (or subtracts) to the value of the years, months, weeks, days, hours, minutes, seconds, milliseconds of the date instance using given configuration object. Positive and Negative values allowed. * Example

	Date.today().add( { days: 1, months: 1 } )

	new Date().add( { years: -1 } )
	
* @param {Object} Configuration object containing attributes (months, days, etc.) * @return {Date} this */ $P.add = function (config) { if (typeof config === "number") { this._orient = config; return this; } var x = config; if (x.day) { // If we should be a different date than today (eg: for 'tomorrow -1d', etc). // Should only effect parsing, not direct usage (eg, Finish and FinishExact) if ((x.day - this.getDate()) !== 0) { this.setDate(x.day); } } if (x.milliseconds) { this.addMilliseconds(x.milliseconds); } if (x.seconds) { this.addSeconds(x.seconds); } if (x.minutes) { this.addMinutes(x.minutes); } if (x.hours) { this.addHours(x.hours); } if (x.weeks) { this.addWeeks(x.weeks); } if (x.months) { this.addMonths(x.months); } if (x.years) { this.addYears(x.years); } if (x.days) { this.addDays(x.days); } return this; }; /** * Get the week number. Week one (1) is the week which contains the first Thursday of the year. Monday is considered the first day of the week. * The .getWeek() function does NOT convert the date to UTC. The local datetime is used. * Please use .getISOWeek() to get the week of the UTC converted date. * @return {Number} 1 to 53 */ $P.getWeek = function (utc) { // Create a copy of this date object var self, target = new Date(this.valueOf()); if (utc) { target.addMinutes(target.getTimezoneOffset()); self = target.clone(); } else { self = this; } // ISO week date weeks start on monday // so correct the day number var dayNr = (self.getDay() + 6) % 7; // ISO 8601 states that week 1 is the week // with the first thursday of that year. // Set the target date to the thursday in the target week target.setDate(target.getDate() - dayNr + 3); // Store the millisecond value of the target date var firstThursday = target.valueOf(); // Set the target to the first thursday of the year // First set the target to january first target.setMonth(0, 1); // Not a thursday? Correct the date to the next thursday if (target.getDay() !== 4) { target.setMonth(0, 1 + ((4 - target.getDay()) + 7) % 7); } // The weeknumber is the number of weeks between the // first thursday of the year and the thursday in the target week return 1 + Math.ceil((firstThursday - target) / 604800000); // 604800000 = 7 * 24 * 3600 * 1000 }; /** * Get the ISO 8601 week number. Week one ("01") is the week which contains the first Thursday of the year. Monday is considered the first day of the week. * The .getISOWeek() function does convert the date to it's UTC value. Please use .getWeek() to get the week of the local date. * @return {String} "01" to "53" */ $P.getISOWeek = function () { return p(this.getWeek(true)); }; /** * Moves the date to Monday of the week set. Week one (1) is the week which contains the first Thursday of the year. * @param {Number} A Number (1 to 53) that represents the week of the year. * @return {Date} this */ $P.setWeek = function (n) { if ((n - this.getWeek()) === 0) { if (this.getDay() !== 1) { return this.moveToDayOfWeek(1, (this.getDay() > 1 ? -1 : 1)); } else { return this; } } else { return this.moveToDayOfWeek(1, (this.getDay() > 1 ? -1 : 1)).addWeeks(n - this.getWeek()); } }; $P.setQuarter = function (qtr) { var month = Math.abs(((qtr-1) * 3) + 1); return this.setMonth(month, 1); }; $P.getQuarter = function () { return Date.getQuarter(this); }; $P.getDaysLeftInQuarter = function () { return Date.getDaysLeftInQuarter(this); }; /** * Moves the date to the next n'th occurrence of the dayOfWeek starting from the beginning of the month. The number (-1) is a magic number and will return the last occurrence of the dayOfWeek in the month. * @param {Number} The dayOfWeek to move to * @param {Number} The n'th occurrence to move to. Use (-1) to return the last occurrence in the month * @return {Date} this */ $P.moveToNthOccurrence = function (dayOfWeek, occurrence) { if (dayOfWeek === "Weekday") { if (occurrence > 0) { this.moveToFirstDayOfMonth(); if (this.is().weekday()) { occurrence -= 1; } } else if (occurrence < 0) { this.moveToLastDayOfMonth(); if (this.is().weekday()) { occurrence += 1; } } else { return this; } return this.addWeekdays(occurrence); } var shift = 0; if (occurrence > 0) { shift = occurrence - 1; } else if (occurrence === -1) { this.moveToLastDayOfMonth(); if (this.getDay() !== dayOfWeek) { this.moveToDayOfWeek(dayOfWeek, -1); } return this; } return this.moveToFirstDayOfMonth().addDays(-1).moveToDayOfWeek(dayOfWeek, +1).addWeeks(shift); }; var moveToN = function (getFunc, addFunc, nVal) { return function (value, orient) { var diff = (value - this[getFunc]() + nVal * (orient || +1)) % nVal; return this[addFunc]((diff === 0) ? diff += nVal * (orient || +1) : diff); }; }; /** * Move to the next or last dayOfWeek based on the orient value. * @param {Number} The dayOfWeek to move to * @param {Number} Forward (+1) or Back (-1). Defaults to +1. [Optional] * @return {Date} this */ $P.moveToDayOfWeek = moveToN("getDay", "addDays", 7); /** * Move to the next or last month based on the orient value. * @param {Number} The month to move to. 0 = January, 11 = December * @param {Number} Forward (+1) or Back (-1). Defaults to +1. [Optional] * @return {Date} this */ $P.moveToMonth = moveToN("getMonth", "addMonths", 12); /** * Get the Ordinate of the current day ("th", "st", "rd"). * @return {String} */ $P.getOrdinate = function () { var num = this.getDate(); return ord(num); }; /** * Get the Ordinal day (numeric day number) of the year, adjusted for leap year. * @return {Number} 1 through 365 (366 in leap years) */ $P.getOrdinalNumber = function () { return Math.ceil((this.clone().clearTime() - new Date(this.getFullYear(), 0, 1)) / 86400000) + 1; }; /** * Get the time zone abbreviation of the current date. * @return {String} The abbreviated time zone name (e.g. "EST") */ $P.getTimezone = function () { return $D.getTimezoneAbbreviation(this.getUTCOffset(), this.isDaylightSavingTime()); }; $P.setTimezoneOffset = function (offset) { var here = this.getTimezoneOffset(), there = Number(offset) * -6 / 10; return (there || there === 0) ? this.addMinutes(there - here) : this; }; $P.setTimezone = function (offset) { return this.setTimezoneOffset($D.getTimezoneOffset(offset)); }; /** * Indicates whether Daylight Saving Time is observed in the current time zone. * @return {Boolean} true|false */ $P.hasDaylightSavingTime = function () { return (Date.today().set({month: 0, day: 1}).getTimezoneOffset() !== Date.today().set({month: 6, day: 1}).getTimezoneOffset()); }; /** * Indicates whether this Date instance is within the Daylight Saving Time range for the current time zone. * @return {Boolean} true|false */ $P.isDaylightSavingTime = function () { return Date.today().set({month: 0, day: 1}).getTimezoneOffset() !== this.getTimezoneOffset(); }; /** * Get the offset from UTC of the current date. * @return {String} The 4-character offset string prefixed with + or - (e.g. "-0500") */ $P.getUTCOffset = function (offset) { var n = (offset || this.getTimezoneOffset()) * -10 / 6, r; if (n < 0) { r = (n - 10000).toString(); return r.charAt(0) + r.substr(2); } else { r = (n + 10000).toString(); return "+" + r.substr(1); } }; /** * Returns the number of milliseconds between this date and date. * @param {Date} Defaults to now * @return {Number} The diff in milliseconds */ $P.getElapsed = function (date) { return (date || new Date()) - this; }; /** * Set the value of year, month, day, hour, minute, second, millisecond of date instance using given configuration object. * Example

	Date.today().set( { day: 20, month: 1 } )

	new Date().set( { millisecond: 0 } )
	
* * @param {Object} Configuration object containing attributes (month, day, etc.) * @return {Date} this */ $P.set = function (config) { config = validateConfigObject.call(this, config); var key; for (key in config) { if (Object.prototype.hasOwnProperty.call(config, key)) { var name = key.charAt(0).toUpperCase() + key.slice(1); var addFunc, getFunc; if (key !== "week" && key !== "month" && key !== "timezone" && key !== "timezoneOffset") { name += "s"; } addFunc = "add" + name; getFunc = "get" + name; if (key === "month") { addFunc = addFunc + "s"; } else if (key === "year"){ getFunc = "getFullYear"; } if (key !== "day" && key !== "timezone" && key !== "timezoneOffset" && key !== "week" && key !== "hour") { this[addFunc](config[key] - this[getFunc]()); } else if ( key === "timezone"|| key === "timezoneOffset" || key === "week" || key === "hour") { this["set"+name](config[key]); } } } // day has to go last because you can't validate the day without first knowing the month if (config.day) { this.addDays(config.day - this.getDate()); } return this; }; /** * Moves the date to the first day of the month. * @return {Date} this */ $P.moveToFirstDayOfMonth = function () { return this.set({ day: 1 }); }; /** * Moves the date to the last day of the month. * @return {Date} this */ $P.moveToLastDayOfMonth = function () { return this.set({ day: $D.getDaysInMonth(this.getFullYear(), this.getMonth())}); }; /** * Converts the value of the current Date object to its equivalent string representation. * Format Specifiers * CUSTOM DATE AND TIME FORMAT STRINGS * Format Description Example * ------ --------------------------------------------------------------------------- ----------------------- * s The seconds of the minute between 0-59. "0" to "59" * ss The seconds of the minute with leading zero if required. "00" to "59" * * m The minute of the hour between 0-59. "0" or "59" * mm The minute of the hour with leading zero if required. "00" or "59" * * h The hour of the day between 1-12. "1" to "12" * hh The hour of the day with leading zero if required. "01" to "12" * * H The hour of the day between 0-23. "0" to "23" * HH The hour of the day with leading zero if required. "00" to "23" * * d The day of the month between 1 and 31. "1" to "31" * dd The day of the month with leading zero if required. "01" to "31" * ddd Abbreviated day name. Date.CultureInfo.abbreviatedDayNames. "Mon" to "Sun" * dddd The full day name. Date.CultureInfo.dayNames. "Monday" to "Sunday" * * M The month of the year between 1-12. "1" to "12" * MM The month of the year with leading zero if required. "01" to "12" * MMM Abbreviated month name. Date.CultureInfo.abbreviatedMonthNames. "Jan" to "Dec" * MMMM The full month name. Date.CultureInfo.monthNames. "January" to "December" * * yy The year as a two-digit number. "99" or "08" * yyyy The full four digit year. "1999" or "2008" * * t Displays the first character of the A.M./P.M. designator. "A" or "P" * Date.CultureInfo.amDesignator or Date.CultureInfo.pmDesignator * tt Displays the A.M./P.M. designator. "AM" or "PM" * Date.CultureInfo.amDesignator or Date.CultureInfo.pmDesignator * * S The ordinal suffix ("st, "nd", "rd" or "th") of the current day. "st, "nd", "rd" or "th" * * STANDARD DATE AND TIME FORMAT STRINGS * Format Description Example *------ --------------------------------------------------------------------------- ----------------------- * d The CultureInfo shortDate Format Pattern "M/d/yyyy" * D The CultureInfo longDate Format Pattern "dddd, MMMM dd, yyyy" * F The CultureInfo fullDateTime Format Pattern "dddd, MMMM dd, yyyy h:mm:ss tt" * m The CultureInfo monthDay Format Pattern "MMMM dd" * r The CultureInfo rfc1123 Format Pattern "ddd, dd MMM yyyy HH:mm:ss GMT" * s The CultureInfo sortableDateTime Format Pattern "yyyy-MM-ddTHH:mm:ss" * t The CultureInfo shortTime Format Pattern "h:mm tt" * T The CultureInfo longTime Format Pattern "h:mm:ss tt" * u The CultureInfo universalSortableDateTime Format Pattern "yyyy-MM-dd HH:mm:ssZ" * y The CultureInfo yearMonth Format Pattern "MMMM, yyyy" * * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @return {String} A string representation of the current Date object. */ var ord = function (n) { switch (n * 1) { case 1: case 21: case 31: return "st"; case 2: case 22: return "nd"; case 3: case 23: return "rd"; default: return "th"; } }; var parseStandardFormats = function (format) { var y, c = Date.CultureInfo.formatPatterns; switch (format) { case "d": return this.toString(c.shortDate); case "D": return this.toString(c.longDate); case "F": return this.toString(c.fullDateTime); case "m": return this.toString(c.monthDay); case "r": case "R": y = this.clone().addMinutes(this.getTimezoneOffset()); return y.toString(c.rfc1123) + " GMT"; case "s": return this.toString(c.sortableDateTime); case "t": return this.toString(c.shortTime); case "T": return this.toString(c.longTime); case "u": y = this.clone().addMinutes(this.getTimezoneOffset()); return y.toString(c.universalSortableDateTime); case "y": return this.toString(c.yearMonth); default: return false; } }; var parseFormatStringsClosure = function (context) { return function (m) { if (m.charAt(0) === "\\") { return m.replace("\\", ""); } switch (m) { case "hh": return p(context.getHours() < 13 ? (context.getHours() === 0 ? 12 : context.getHours()) : (context.getHours() - 12)); case "h": return context.getHours() < 13 ? (context.getHours() === 0 ? 12 : context.getHours()) : (context.getHours() - 12); case "HH": return p(context.getHours()); case "H": return context.getHours(); case "mm": return p(context.getMinutes()); case "m": return context.getMinutes(); case "ss": return p(context.getSeconds()); case "s": return context.getSeconds(); case "yyyy": return p(context.getFullYear(), 4); case "yy": return p(context.getFullYear()); case "y": return context.getFullYear(); case "E": case "dddd": return Date.CultureInfo.dayNames[context.getDay()]; case "ddd": return Date.CultureInfo.abbreviatedDayNames[context.getDay()]; case "dd": return p(context.getDate()); case "d": return context.getDate(); case "MMMM": return Date.CultureInfo.monthNames[context.getMonth()]; case "MMM": return Date.CultureInfo.abbreviatedMonthNames[context.getMonth()]; case "MM": return p((context.getMonth() + 1)); case "M": return context.getMonth() + 1; case "t": return context.getHours() < 12 ? Date.CultureInfo.amDesignator.substring(0, 1) : Date.CultureInfo.pmDesignator.substring(0, 1); case "tt": return context.getHours() < 12 ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator; case "S": return ord(context.getDate()); case "W": return context.getWeek(); case "WW": return context.getISOWeek(); case "Q": return "Q" + context.getQuarter(); case "q": return String(context.getQuarter()); case "z": return context.getTimezone(); case "Z": case "X": return Date.getTimezoneOffset(context.getTimezone()); case "ZZ": // Timezone offset in seconds return context.getTimezoneOffset() * -60; case "u": return context.getDay(); case "L": return ($D.isLeapYear(context.getFullYear())) ? 1 : 0; case "B": // Swatch Internet Time (.beats) return "@"+((context.getUTCSeconds() + (context.getUTCMinutes()*60) + ((context.getUTCHours()+1)*3600))/86.4); default: return m; } }; }; $P.toString = function (format, ignoreStandards) { // Standard Date and Time Format Strings. Formats pulled from CultureInfo file and // may vary by culture. if (!ignoreStandards && format && format.length === 1) { output = parseStandardFormats.call(this, format); if (output) { return output; } } var parseFormatStrings = parseFormatStringsClosure(this); return format ? format.replace(/((\\)?(dd?d?d?|MM?M?M?|yy?y?y?|hh?|HH?|mm?|ss?|tt?|S|q|Q|WW?W?W?)(?![^\[]*\]))/g, parseFormatStrings).replace(/\[|\]/g, "") : this._toString(); }; }()); /************************************************************* * SugarPak - Domain Specific Language - Syntactical Sugar * *************************************************************/ (function () { var $D = Date, $P = $D.prototype, $N = Number.prototype; // private $P._orient = +1; // private $P._nth = null; // private $P._is = false; // private $P._same = false; // private $P._isSecond = false; // private $N._dateElement = "days"; /** * Moves the date to the next instance of a date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.today().next().friday();
	Date.today().next().fri();
	Date.today().next().march();
	Date.today().next().mar();
	Date.today().next().week();
	
* * @return {Date} date */ $P.next = function () { this._move = true; this._orient = +1; return this; }; /** * Creates a new Date (Date.today()) and moves the date to the next instance of the date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.next().friday();
	Date.next().fri();
	Date.next().march();
	Date.next().mar();
	Date.next().week();
	
* * @return {Date} date */ $D.next = function () { return $D.today().next(); }; /** * Moves the date to the previous instance of a date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.today().last().friday();
	Date.today().last().fri();
	Date.today().last().march();
	Date.today().last().mar();
	Date.today().last().week();
	
* * @return {Date} date */ $P.last = $P.prev = $P.previous = function () { this._move = true; this._orient = -1; return this; }; /** * Creates a new Date (Date.today()) and moves the date to the previous instance of the date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.last().friday();
	Date.last().fri();
	Date.previous().march();
	Date.prev().mar();
	Date.last().week();
	
* * @return {Date} date */ $D.last = $D.prev = $D.previous = function () { return $D.today().last(); }; /** * Performs a equality check when followed by either a month name, day name or .weekday() function. * Example

	Date.today().is().friday(); // true|false
	Date.today().is().fri();
	Date.today().is().march();
	Date.today().is().mar();
	
* * @return {Boolean} true|false */ $P.is = function () { this._is = true; return this; }; /** * Determines if two date objects occur on/in exactly the same instance of the subsequent date part function. * The function .same() must be followed by a date part function (example: .day(), .month(), .year(), etc). * * An optional Date can be passed in the date part function. If now date is passed as a parameter, 'Now' is used. * * The following example demonstrates how to determine if two dates fall on the exact same day. * * Example

	var d1 = Date.today(); // today at 00:00
	var d2 = new Date();   // exactly now.

	// Do they occur on the same day?
	d1.same().day(d2); // true
	
	// Do they occur on the same hour?
	d1.same().hour(d2); // false, unless d2 hour is '00' (midnight).
	
	// What if it's the same day, but one year apart?
	var nextYear = Date.today().add(1).year();

	d1.same().day(nextYear); // false, because the dates must occur on the exact same day. 
	
* * Scenario: Determine if a given date occurs during some week period 2 months from now. * * Example

	var future = Date.today().add(2).months();
	return someDate.same().week(future); // true|false;
	
* * @return {Boolean} true|false */ $P.same = function () { this._same = true; this._isSecond = false; return this; }; /** * Determines if the current date/time occurs during Today. Must be preceded by the .is() function. * Example

	someDate.is().today();    // true|false
	new Date().is().today();  // true
	Date.today().is().today();// true
	Date.today().add(-1).day().is().today(); // false
	
* * @return {Boolean} true|false */ $P.today = function () { return this.same().day(); }; /** * Determines if the current date is a weekday. This function must be preceded by the .is() function. * Example

	Date.today().is().weekday(); // true|false
	
* * @return {Boolean} true|false */ $P.weekday = function () { if (this._nth) { return df("Weekday").call(this); } if (this._move) { return this.addWeekdays(this._orient); } if (this._is) { this._is = false; return (!this.is().sat() && !this.is().sun()); } return false; }; /** * Determines if the current date is on the weekend. This function must be preceded by the .is() function. * Example

	Date.today().is().weekend(); // true|false
	
* * @return {Boolean} true|false */ $P.weekend = function () { if (this._is) { this._is = false; return (this.is().sat() || this.is().sun()); } return false; }; /** * Sets the Time of the current Date instance. A string "6:15 pm" or config object {hour:18, minute:15} are accepted. * Example

	// Set time to 6:15pm with a String
	Date.today().at("6:15pm");

	// Set time to 6:15pm with a config object
	Date.today().at({hour:18, minute:15});
	
* * @return {Date} date */ $P.at = function (time) { return (typeof time === "string") ? $D.parse(this.toString("d") + " " + time) : this.set(time); }; /** * Creates a new Date() and adds this (Number) to the date based on the preceding date element function (eg. second|minute|hour|day|month|year). * Example

	// Undeclared Numbers must be wrapped with parentheses. Requirment of JavaScript.
	(3).days().fromNow();
	(6).months().fromNow();

	// Declared Number variables do not require parentheses. 
	var n = 6;
	n.months().fromNow();
	
* * @return {Date} A new Date instance */ $N.fromNow = $N.after = function (date) { var c = {}; c[this._dateElement] = this; return ((!date) ? new Date() : date.clone()).add(c); }; /** * Creates a new Date() and subtract this (Number) from the date based on the preceding date element function (eg. second|minute|hour|day|month|year). * Example

	// Undeclared Numbers must be wrapped with parentheses. Requirment of JavaScript.
	(3).days().ago();
	(6).months().ago();

	// Declared Number variables do not require parentheses. 
	var n = 6;
	n.months().ago();
	
* * @return {Date} A new Date instance */ $N.ago = $N.before = function (date) { var c = {}, s = (this._dateElement[this._dateElement.length-1] !== "s") ? this._dateElement + "s" : this._dateElement; c[s] = this * -1; return ((!date) ? new Date() : date.clone()).add(c); }; // Do NOT modify the following string tokens. These tokens are used to build dynamic functions. // All culture-specific strings can be found in the CultureInfo files. var dx = ("sunday monday tuesday wednesday thursday friday saturday").split(/\s/), mx = ("january february march april may june july august september october november december").split(/\s/), px = ("Millisecond Second Minute Hour Day Week Month Year Quarter Weekday").split(/\s/), pxf = ("Milliseconds Seconds Minutes Hours Date Week Month FullYear Quarter").split(/\s/), nth = ("final first second third fourth fifth").split(/\s/), de; /** * Returns an object literal of all the date parts. * Example

	var o = new Date().toObject();
	
	// { year: 2008, month: 4, week: 20, day: 13, hour: 18, minute: 9, second: 32, millisecond: 812 }
	
	// The object properties can be referenced directly from the object.
	
	alert(o.day);  // alerts "13"
	alert(o.year); // alerts "2008"
	
* * @return {Date} An object literal representing the original date object. */ $P.toObject = function () { var o = {}; for (var i = 0; i < px.length; i++) { if (this["get" + pxf[i]]) { o[px[i].toLowerCase()] = this["get" + pxf[i]](); } } return o; }; /** * Returns a date created from an object literal. Ignores the .week property if set in the config. * Example

	var o = new Date().toObject();
	
	return Date.fromObject(o); // will return the same date. 

	var o2 = {month: 1, day: 20, hour: 18}; // birthday party!
	Date.fromObject(o2);
	
* * @return {Date} An object literal representing the original date object. */ $D.fromObject = function(config) { config.week = null; return Date.today().set(config); }; // Create day name functions and abbreviated day name functions (eg. monday(), friday(), fri()). var df = function (n) { return function () { if (this._is) { this._is = false; return this.getDay() === n; } if (this._move) { this._move = null; } if (this._nth !== null) { // If the .second() function was called earlier, remove the _orient // from the date, and then continue. // This is required because 'second' can be used in two different context. // // Example // // Date.today().add(1).second(); // Date.march().second().monday(); // // Things get crazy with the following... // Date.march().add(1).second().second().monday(); // but it works!! // if (this._isSecond) { this.addSeconds(this._orient * -1); } // make sure we reset _isSecond this._isSecond = false; var ntemp = this._nth; this._nth = null; var temp = this.clone().moveToLastDayOfMonth(); this.moveToNthOccurrence(n, ntemp); if (this > temp) { throw new RangeError($D.getDayName(n) + " does not occur " + ntemp + " times in the month of " + $D.getMonthName(temp.getMonth()) + " " + temp.getFullYear() + "."); } return this; } return this.moveToDayOfWeek(n, this._orient); }; }; var sdf = function (n) { return function () { var t = $D.today(), shift = n - t.getDay(); if (n === 0 && Date.CultureInfo.firstDayOfWeek === 1 && t.getDay() !== 0) { shift = shift + 7; } return t.addDays(shift); }; }; // Create month name functions and abbreviated month name functions (eg. january(), march(), mar()). var month_instance_functions = function (n) { return function () { if (this._is) { this._is = false; return this.getMonth() === n; } return this.moveToMonth(n, this._orient); }; }; var month_static_functions = function (n) { return function () { return $D.today().set({ month: n, day: 1 }); }; }; var processTerms = function (names, staticFunc, instanceFunc) { for (var i = 0; i < names.length; i++) { // Create constant static Name variables. $D[names[i].toUpperCase()] = $D[names[i].toUpperCase().substring(0, 3)] = i; // Create Name functions. $D[names[i]] = $D[names[i].substring(0, 3)] = staticFunc(i); // Create Name instance functions. $P[names[i]] = $P[names[i].substring(0, 3)] = instanceFunc(i); } }; processTerms(dx, sdf, df); processTerms(mx, month_static_functions, month_instance_functions); // Create date element functions and plural date element functions used with Date (eg. day(), days(), months()). var ef = function (j) { return function () { // if the .second() function was called earlier, the _orient // has alread been added. Just return this and reset _isSecond. if (this._isSecond) { this._isSecond = false; return this; } if (this._same) { this._same = this._is = false; var o1 = this.toObject(), o2 = (arguments[0] || new Date()).toObject(), v = "", k = j.toLowerCase(); // the substr trick with -1 doesn't work in IE8 or less k = (k[k.length-1] === "s") ? k.substring(0,k.length-1) : k; for (var m = (px.length - 1); m > -1; m--) { v = px[m].toLowerCase(); if (o1[v] !== o2[v]) { return false; } if (k === v) { break; } } return true; } if (j.substring(j.length - 1) !== "s") { j += "s"; } if (this._move) { this._move = null; } return this["add" + j](this._orient); }; }; var nf = function (n) { return function () { this._dateElement = n; return this; }; }; for (var k = 0; k < px.length; k++) { de = px[k].toLowerCase(); if(de !== "weekday") { // Create date element functions and plural date element functions used with Date (eg. day(), days(), months()). $P[de] = $P[de + "s"] = ef(px[k]); // Create date element functions and plural date element functions used with Number (eg. day(), days(), months()). $N[de] = $N[de + "s"] = nf(de + "s"); } } $P._ss = ef("Second"); var nthfn = function (n) { return function (dayOfWeek) { if (this._same) { return this._ss(arguments[0]); } if (dayOfWeek || dayOfWeek === 0) { return this.moveToNthOccurrence(dayOfWeek, n); } this._nth = n; // if the operator is 'second' add the _orient, then deal with it later... if (n === 2 && (dayOfWeek === undefined || dayOfWeek === null)) { this._isSecond = true; return this.addSeconds(this._orient); } return this; }; }; for (var l = 0; l < nth.length; l++) { $P[nth[l]] = (l === 0) ? nthfn(-1) : nthfn(l); } }()); (function () { "use strict"; Date.Parsing = { Exception: function (s) { this.message = "Parse error at '" + s.substring(0, 10) + " ...'"; } }; var $P = Date.Parsing; var dayOffsets = { standard: [0,31,59,90,120,151,181,212,243,273,304,334], leap: [0,31,60,91,121,152,182,213,244,274,305,335] }; $P.isLeapYear = function(year) { return ((year % 4 === 0) && (year % 100 !== 0)) || (year % 400 === 0); }; var utils = { multiReplace : function (str, hash ) { var key; for (key in hash) { if (Object.prototype.hasOwnProperty.call(hash, key)) { var regex; if (typeof hash[key] === "function") { } else { regex = (hash[key] instanceof RegExp) ? hash[key] : new RegExp(hash[key], "g"); } str = str.replace(regex, key); } } return str; }, getDayOfYearFromWeek : function (obj) { var d, jan4, offset; obj.weekDay = (!obj.weekDay && obj.weekDay !== 0) ? 1 : obj.weekDay; d = new Date(obj.year, 0, 4); jan4 = d.getDay() === 0 ? 7 : d.getDay(); // JS is 0 indexed on Sunday. offset = jan4+3; obj.dayOfYear = ((obj.week * 7) + (obj.weekDay === 0 ? 7 : obj.weekDay))-offset; return obj; }, getDayOfYear : function (obj, dayOffset) { if (!obj.dayOfYear) { obj = utils.getDayOfYearFromWeek(obj); } for (var i=0;i <= dayOffset.length;i++) { if (obj.dayOfYear < dayOffset[i] || i === dayOffset.length) { obj.day = obj.day ? obj.day : (obj.dayOfYear - dayOffset[i-1]); break; } else { obj.month = i; } } return obj; }, adjustForTimeZone : function (obj, date) { var offset; if (obj.zone.toUpperCase() === "Z" || (obj.zone_hours === 0 && obj.zone_minutes === 0)) { // it's UTC/GML so work out the current timeszone offset offset = -date.getTimezoneOffset(); } else { offset = (obj.zone_hours*60) + (obj.zone_minutes || 0); if (obj.zone_sign === "+") { offset *= -1; } offset -= date.getTimezoneOffset(); } date.setMinutes(date.getMinutes()+offset); return date; }, setDefaults : function (obj) { obj.year = obj.year || Date.today().getFullYear(); obj.hours = obj.hours || 0; obj.minutes = obj.minutes || 0; obj.seconds = obj.seconds || 0; obj.milliseconds = obj.milliseconds || 0; if (!(!obj.month && (obj.week || obj.dayOfYear))) { // if we have a month, or if we don't but don't have the day calculation data obj.month = obj.month || 0; obj.day = obj.day || 1; } return obj; }, dataNum: function (data, mod, explict, postProcess) { var dataNum = data*1; if (mod) { if (postProcess) { return data ? mod(data)*1 : data; } else { return data ? mod(dataNum) : data; } } else if (!explict){ return data ? dataNum : data; } else { return (data && typeof data !== "undefined") ? dataNum : data; } }, timeDataProcess: function (obj) { var timeObj = {}; for (var x in obj.data) { if (obj.data.hasOwnProperty(x)) { timeObj[x] = obj.ignore[x] ? obj.data[x] : utils.dataNum(obj.data[x], obj.mods[x], obj.explict[x], obj.postProcess[x]); } } if (obj.data.secmins) { obj.data.secmins = obj.data.secmins.replace(",", ".") * 60; if (!timeObj.minutes) { timeObj.minutes = obj.data.secmins; } else if (!timeObj.seconds) { timeObj.seconds = obj.data.secmins; } delete obj.secmins; } return timeObj; }, buildTimeObjectFromData: function (data) { var time = utils.timeDataProcess({ data: { year : data[1], month : data[5], day : data[7], week : data[8], dayOfYear : data[10], hours : data[15], zone_hours : data[23], zone_minutes : data[24], zone : data[21], zone_sign : data[22], weekDay : data[9], minutes: data[16], seconds: data[19], milliseconds: data[20], secmins: data[18] }, mods: { month: function(data) { return data-1; }, weekDay: function (data) { data = Math.abs(data); return (data === 7 ? 0 : data); }, minutes: function (data) { return data.replace(":",""); }, seconds: function (data) { return Math.floor( (data.replace(":","").replace(",","."))*1 ); }, milliseconds: function (data) { return (data.replace(",",".")*1000); } }, postProcess: { minutes: true, seconds: true, milliseconds: true }, explict: { zone_hours: true, zone_minutes: true }, ignore: { zone: true, zone_sign: true, secmins: true } }); return time; }, addToHash: function (hash, keys, data) { keys = keys; data = data; var len = keys.length; for (var i = 0; i < len; i++) { hash[keys[i]] = data[i]; } return hash; }, combineRegex: function (r1, r2) { return new RegExp("(("+r1.source+")\\s("+r2.source+"))"); }, getDateNthString: function(add, last, inc){ if (add) { return Date.today().addDays(inc).toString("d"); } else if (last) { return Date.today().last()[inc]().toString("d"); } }, buildRegexData: function (array) { var arr = []; var len = array.length; for (var i=0; i < len; i++) { if (Object.prototype.toString.call(array[i]) === '[object Array]') { // oldIE compat version of Array.isArray arr.push(this.combineRegex(array[i][0], array[i][1])); } else { arr.push(array[i]); } } return arr; } }; $P.processTimeObject = function (obj) { var date, dayOffset; utils.setDefaults(obj); dayOffset = ($P.isLeapYear(obj.year)) ? dayOffsets.leap : dayOffsets.standard; if (!obj.month && (obj.week || obj.dayOfYear)) { utils.getDayOfYear(obj, dayOffset); } else { obj.dayOfYear = dayOffset[obj.month] + obj.day; } date = new Date(obj.year, obj.month, obj.day, obj.hours, obj.minutes, obj.seconds, obj.milliseconds); if (obj.zone) { utils.adjustForTimeZone(obj, date); // adjust (and calculate) for timezone } return date; }; $P.ISO = { regex : /^([\+-]?\d{4}(?!\d{2}\b))((-?)((0[1-9]|1[0-2])(\3([12]\d|0[1-9]|3[01]))?|W([0-4]\d|5[0-3])(-?[1-7])?|(00[1-9]|0[1-9]\d|[12]\d{2}|3([0-5]\d|6[1-6])))([T\s]((([01]\d|2[0-4])((:?)[0-5]\d)?|24\:?00)([\.,]\d+(?!:))?)?(\17[0-5]\d([\.,]\d+)?)?\s?([zZ]|([\+-])([01]\d|2[0-3]):?([0-5]\d)?)?)?)?$/, parse : function (s) { var time, data = s.match(this.regex); if (!data || !data.length) { return null; } time = utils.buildTimeObjectFromData(data); if (!time.year || (!time.year && (!time.month && !time.day) && (!time.week && !time.dayOfYear)) ) { return null; } return $P.processTimeObject(time); } }; $P.Numeric = { isNumeric: function (e){return!isNaN(parseFloat(e))&&isFinite(e);}, regex: /\b([0-1]?[0-9])([0-3]?[0-9])([0-2]?[0-9]?[0-9][0-9])\b/i, parse: function (s) { var data, i, time = {}, order = Date.CultureInfo.dateElementOrder.split(""); if (!(this.isNumeric(s)) || // if it's non-numeric OR (s[0] === "+" && s[0] === "-")) { // It's an arithmatic string (eg +/-1000) return null; } if (s.length < 5 && s.indexOf(".") < 0 && s.indexOf("/") < 0) { // assume it's just a year. time.year = s; return $P.processTimeObject(time); } data = s.match(this.regex); if (!data || !data.length) { return null; } for (i=0; i < order.length; i++) { switch(order[i]) { case "d": time.day = data[i+1]; break; case "m": time.month = (data[i+1]-1); break; case "y": time.year = data[i+1]; break; } } return $P.processTimeObject(time); } }; $P.Normalizer = { regexData: function () { var $R = Date.CultureInfo.regexPatterns; return utils.buildRegexData([ $R.tomorrow, $R.yesterday, [$R.past, $R.mon], [$R.past, $R.tue], [$R.past, $R.wed], [$R.past, $R.thu], [$R.past, $R.fri], [$R.past, $R.sat], [$R.past, $R.sun] ]); }, basicReplaceHash : function() { var $R = Date.CultureInfo.regexPatterns; return { "January": $R.jan.source, "February": $R.feb, "March": $R.mar, "April": $R.apr, "May": $R.may, "June": $R.jun, "July": $R.jul, "August": $R.aug, "September": $R.sep, "October": $R.oct, "November": $R.nov, "December": $R.dec, "": /\bat\b/gi, " ": /\s{2,}/, "am": $R.inTheMorning, "9am": $R.thisMorning, "pm": $R.inTheEvening, "7pm":$R.thisEvening }; }, keys : function(){ return [ utils.getDateNthString(true, false, 1), // tomorrow utils.getDateNthString(true, false, -1), // yesterday utils.getDateNthString(false, true, "monday"), //last mon utils.getDateNthString(false, true, "tuesday"), //last tues utils.getDateNthString(false, true, "wednesday"), //last wed utils.getDateNthString(false, true, "thursday"), //last thurs utils.getDateNthString(false, true, "friday"), //last fri utils.getDateNthString(false, true, "saturday"), //last sat utils.getDateNthString(false, true, "sunday") //last sun ]; }, buildRegexFunctions: function () { var $R = Date.CultureInfo.regexPatterns; var __ = Date.i18n.__; var tomorrowRE = new RegExp("(\\b\\d\\d?("+__("AM")+"|"+__("PM")+")? )("+$R.tomorrow.source.slice(1)+")", "i"); // adapted tomorrow regex for AM PM relative dates var todayRE = new RegExp($R.today.source + "(?!\\s*([+-]))\\b"); // today, but excludes the math operators (eg "today + 2h") this.replaceFuncs = [ [todayRE, function (full) { return (full.length > 1) ? Date.today().toString("d") : full; }], [tomorrowRE, function(full, m1) { var t = Date.today().addDays(1).toString("d"); return (t + " " + m1); }], [$R.amThisMorning, function(str, am){return am;}], [$R.pmThisEvening, function(str, pm){return pm;}] ]; }, buildReplaceData: function () { this.buildRegexFunctions(); this.replaceHash = utils.addToHash(this.basicReplaceHash(), this.keys(), this.regexData()); }, stringReplaceFuncs: function (s) { for (var i=0; i < this.replaceFuncs.length; i++) { s = s.replace(this.replaceFuncs[i][0], this.replaceFuncs[i][1]); } return s; }, parse: function (s) { s = this.stringReplaceFuncs(s); s = utils.multiReplace(s, this.replaceHash); try { var n = s.split(/([\s\-\.\,\/\x27]+)/); if (n.length === 3 && $P.Numeric.isNumeric(n[0]) && $P.Numeric.isNumeric(n[2]) && (n[2].length >= 4)) { // ok, so we're dealing with x/year. But that's not a full date. // This fixes wonky dateElementOrder parsing when set to dmy order. if (Date.CultureInfo.dateElementOrder[0] === "d") { s = "1/" + n[0] + "/" + n[2]; // set to 1st of month and normalize the seperator } } } catch (e) {} return s; } }; $P.Normalizer.buildReplaceData(); }()); (function () { var $P = Date.Parsing; var _ = $P.Operators = { // // Tokenizers // rtoken: function (r) { // regex token return function (s) { var mx = s.match(r); if (mx) { return ([ mx[0], s.substring(mx[0].length) ]); } else { throw new $P.Exception(s); } }; }, token: function () { // whitespace-eating token return function (s) { return _.rtoken(new RegExp("^\\s*" + s + "\\s*"))(s); }; }, stoken: function (s) { // string token return _.rtoken(new RegExp("^" + s)); }, // Atomic Operators until: function (p) { return function (s) { var qx = [], rx = null; while (s.length) { try { rx = p.call(this, s); } catch (e) { qx.push(rx[0]); s = rx[1]; continue; } break; } return [ qx, s ]; }; }, many: function (p) { return function (s) { var rx = [], r = null; while (s.length) { try { r = p.call(this, s); } catch (e) { return [ rx, s ]; } rx.push(r[0]); s = r[1]; } return [ rx, s ]; }; }, // generator operators -- see below optional: function (p) { return function (s) { var r = null; try { r = p.call(this, s); } catch (e) { return [ null, s ]; } return [ r[0], r[1] ]; }; }, not: function (p) { return function (s) { try { p.call(this, s); } catch (e) { return [null, s]; } throw new $P.Exception(s); }; }, ignore: function (p) { return p ? function (s) { var r = null; r = p.call(this, s); return [null, r[1]]; } : null; }, product: function () { var px = arguments[0], qx = Array.prototype.slice.call(arguments, 1), rx = []; for (var i = 0 ; i < px.length ; i++) { rx.push(_.each(px[i], qx)); } return rx; }, cache: function (rule) { var cache = {}, cache_length = 0, cache_keys = [], CACHE_MAX = Date.Config.CACHE_MAX || 100000, r = null; var cacheCheck = function () { if (cache_length === CACHE_MAX) { // kill several keys, don't want to have to do this all the time... for (var i=0; i < 10; i++) { var key = cache_keys.shift(); if (key) { delete cache[key]; cache_length--; } } } }; return function (s) { cacheCheck(); try { r = cache[s] = (cache[s] || rule.call(this, s)); } catch (e) { r = cache[s] = e; } cache_length++; cache_keys.push(s); if (r instanceof $P.Exception) { throw r; } else { return r; } }; }, // vector operators -- see below any: function () { var px = arguments; return function (s) { var r = null; for (var i = 0; i < px.length; i++) { if (px[i] == null) { continue; } try { r = (px[i].call(this, s)); } catch (e) { r = null; } if (r) { return r; } } throw new $P.Exception(s); }; }, each: function () { var px = arguments; return function (s) { var rx = [], r = null; for (var i = 0; i < px.length ; i++) { if (px[i] == null) { continue; } try { r = (px[i].call(this, s)); } catch (e) { throw new $P.Exception(s); } rx.push(r[0]); s = r[1]; } return [ rx, s]; }; }, all: function () { var px = arguments, _ = _; return _.each(_.optional(px)); }, // delimited operators sequence: function (px, d, c) { d = d || _.rtoken(/^\s*/); c = c || null; if (px.length === 1) { return px[0]; } return function (s) { var r = null, q = null; var rx = []; for (var i = 0; i < px.length ; i++) { try { r = px[i].call(this, s); } catch (e) { break; } rx.push(r[0]); try { q = d.call(this, r[1]); } catch (ex) { q = null; break; } s = q[1]; } if (!r) { throw new $P.Exception(s); } if (q) { throw new $P.Exception(q[1]); } if (c) { try { r = c.call(this, r[1]); } catch (ey) { throw new $P.Exception(r[1]); } } return [ rx, (r?r[1]:s) ]; }; }, // // Composite Operators // between: function (d1, p, d2) { d2 = d2 || d1; var _fn = _.each(_.ignore(d1), p, _.ignore(d2)); return function (s) { var rx = _fn.call(this, s); return [[rx[0][0], r[0][2]], rx[1]]; }; }, list: function (p, d, c) { d = d || _.rtoken(/^\s*/); c = c || null; return (p instanceof Array ? _.each(_.product(p.slice(0, -1), _.ignore(d)), p.slice(-1), _.ignore(c)) : _.each(_.many(_.each(p, _.ignore(d))), px, _.ignore(c))); }, set: function (px, d, c) { d = d || _.rtoken(/^\s*/); c = c || null; return function (s) { // r is the current match, best the current 'best' match // which means it parsed the most amount of input var r = null, p = null, q = null, rx = null, best = [[], s], last = false; // go through the rules in the given set for (var i = 0; i < px.length ; i++) { // last is a flag indicating whether this must be the last element // if there is only 1 element, then it MUST be the last one q = null; p = null; r = null; last = (px.length === 1); // first, we try simply to match the current pattern // if not, try the next pattern try { r = px[i].call(this, s); } catch (e) { continue; } // since we are matching against a set of elements, the first // thing to do is to add r[0] to matched elements rx = [[r[0]], r[1]]; // if we matched and there is still input to parse and // we don't already know this is the last element, // we're going to next check for the delimiter ... // if there's none, or if there's no input left to parse // than this must be the last element after all ... if (r[1].length > 0 && ! last) { try { q = d.call(this, r[1]); } catch (ex) { last = true; } } else { last = true; } // if we parsed the delimiter and now there's no more input, // that means we shouldn't have parsed the delimiter at all // so don't update r and mark this as the last element ... if (!last && q[1].length === 0) { last = true; } // so, if this isn't the last element, we're going to see if // we can get any more matches from the remaining (unmatched) // elements ... if (!last) { // build a list of the remaining rules we can match against, // i.e., all but the one we just matched against var qx = []; for (var j = 0; j < px.length ; j++) { if (i !== j) { qx.push(px[j]); } } // now invoke recursively set with the remaining input // note that we don't include the closing delimiter ... // we'll check for that ourselves at the end p = _.set(qx, d).call(this, q[1]); // if we got a non-empty set as a result ... // (otw rx already contains everything we want to match) if (p[0].length > 0) { // update current result, which is stored in rx ... // basically, pick up the remaining text from p[1] // and concat the result from p[0] so that we don't // get endless nesting ... rx[0] = rx[0].concat(p[0]); rx[1] = p[1]; } } // at this point, rx either contains the last matched element // or the entire matched set that starts with this element. // now we just check to see if this variation is better than // our best so far, in terms of how much of the input is parsed if (rx[1].length < best[1].length) { best = rx; } // if we've parsed all the input, then we're finished if (best[1].length === 0) { break; } } // so now we've either gone through all the patterns trying them // as the initial match; or we found one that parsed the entire // input string ... // if best has no matches, just return empty set ... if (best[0].length === 0) { return best; } // if a closing delimiter is provided, then we have to check it also if (c) { // we try this even if there is no remaining input because the pattern // may well be optional or match empty input ... try { q = c.call(this, best[1]); } catch (ey) { throw new $P.Exception(best[1]); } // it parsed ... be sure to update the best match remaining input best[1] = q[1]; } // if we're here, either there was no closing delimiter or we parsed it // so now we have the best match; just return it! return best; }; }, forward: function (gr, fname) { return function (s) { return gr[fname].call(this, s); }; }, // // Translation Operators // replace: function (rule, repl) { return function (s) { var r = rule.call(this, s); return [repl, r[1]]; }; }, process: function (rule, fn) { return function (s) { var r = rule.call(this, s); return [fn.call(this, r[0]), r[1]]; }; }, min: function (min, rule) { return function (s) { var rx = rule.call(this, s); if (rx[0].length < min) { throw new $P.Exception(s); } return rx; }; } }; // Generator Operators And Vector Operators // Generators are operators that have a signature of F(R) => R, // taking a given rule and returning another rule, such as // ignore, which parses a given rule and throws away the result. // Vector operators are those that have a signature of F(R1,R2,...) => R, // take a list of rules and returning a new rule, such as each. // Generator operators are converted (via the following _generator // function) into functions that can also take a list or array of rules // and return an array of new rules as though the function had been // called on each rule in turn (which is what actually happens). // This allows generators to be used with vector operators more easily. // Example: // each(ignore(foo, bar)) instead of each(ignore(foo), ignore(bar)) // This also turns generators into vector operators, which allows // constructs like: // not(cache(foo, bar)) var _generator = function (op) { function gen() { var args = null, rx = [], px, i; if (arguments.length > 1) { args = Array.prototype.slice.call(arguments); } else if (arguments[0] instanceof Array) { args = arguments[0]; } if (args) { px = args.shift(); if (px.length > 0) { args.unshift(px[i]); rx.push(op.apply(null, args)); args.shift(); return rx; } } else { return op.apply(null, arguments); } } return gen; }; var gx = "optional not ignore cache".split(/\s/); for (var i = 0 ; i < gx.length ; i++) { _[gx[i]] = _generator(_[gx[i]]); } var _vector = function (op) { return function () { if (arguments[0] instanceof Array) { return op.apply(null, arguments[0]); } else { return op.apply(null, arguments); } }; }; var vx = "each any all".split(/\s/); for (var j = 0 ; j < vx.length ; j++) { _[vx[j]] = _vector(_[vx[j]]); } }()); (function () { var $D = Date; var flattenAndCompact = function (ax) { var rx = []; for (var i = 0; i < ax.length; i++) { if (ax[i] instanceof Array) { rx = rx.concat(flattenAndCompact(ax[i])); } else { if (ax[i]) { rx.push(ax[i]); } } } return rx; }; var parseMeridian = function () { if (this.meridian && (this.hour || this.hour === 0)) { if (this.meridian === "a" && this.hour > 11 && Date.Config.strict24hr){ throw "Invalid hour and meridian combination"; } else if (this.meridian === "p" && this.hour < 12 && Date.Config.strict24hr){ throw "Invalid hour and meridian combination"; } else if (this.meridian === "p" && this.hour < 12) { this.hour = this.hour + 12; } else if (this.meridian === "a" && this.hour === 12) { this.hour = 0; } } }; var setDefaults = function () { var now = new Date(); if ((this.hour || this.minute) && (!this.month && !this.year && !this.day)) { this.day = now.getDate(); } if (!this.year) { this.year = now.getFullYear(); } if (!this.month && this.month !== 0) { this.month = now.getMonth(); } if (!this.day) { this.day = 1; } if (!this.hour) { this.hour = 0; } if (!this.minute) { this.minute = 0; } if (!this.second) { this.second = 0; } if (!this.millisecond) { this.millisecond = 0; } }; var finishUtils = { getToday: function () { if (this.now || "hour minute second".indexOf(this.unit) !== -1) { return new Date(); } else { return $D.today(); } }, setDaysFromWeekday: function (today, orient){ var gap; orient = orient || 1; this.unit = "day"; gap = ($D.getDayNumberFromName(this.weekday) - today.getDay()); this.days = gap ? ((gap + (orient * 7)) % 7) : (orient * 7); return this; }, setMonthsFromMonth: function (today, orient) { var gap; orient = orient || 1; this.unit = "month"; gap = (this.month - today.getMonth()); this.months = gap ? ((gap + (orient * 12)) % 12) : (orient * 12); this.month = null; return this; }, setDMYFromWeekday: function () { var d = Date[this.weekday](); this.day = d.getDate(); if (!this.month) { this.month = d.getMonth(); } this.year = d.getFullYear(); return this; }, setUnitValue: function (orient) { if (!this.value && this.operator && this.operator !== null && this[this.unit + "s"] && this[this.unit + "s"] !== null) { this[this.unit + "s"] = this[this.unit + "s"] + ((this.operator === "add") ? 1 : -1) + (this.value||0) * orient; } else if (this[this.unit + "s"] == null || this.operator != null) { if (!this.value) { this.value = 1; } this[this.unit + "s"] = this.value * orient; } }, generateDateFromWeeks: function () { var weekday = (this.weekday !== undefined) ? this.weekday : "today"; var d = Date[weekday]().addWeeks(this.weeks); if (this.now) { d.setTimeToNow(); } return d; } }; $D.Translator = { hour: function (s) { return function () { this.hour = Number(s); }; }, minute: function (s) { return function () { this.minute = Number(s); }; }, second: function (s) { return function () { this.second = Number(s); }; }, /* for ss.s format */ secondAndMillisecond: function (s) { return function () { var mx = s.match(/^([0-5][0-9])\.([0-9]{1,3})/); this.second = Number(mx[1]); this.millisecond = Number(mx[2]); }; }, meridian: function (s) { return function () { this.meridian = s.slice(0, 1).toLowerCase(); }; }, timezone: function (s) { return function () { var n = s.replace(/[^\d\+\-]/g, ""); if (n.length) { this.timezoneOffset = Number(n); } else { this.timezone = s.toLowerCase(); } }; }, day: function (x) { var s = x[0]; return function () { this.day = Number(s.match(/\d+/)[0]); if (this.day < 1) { throw "invalid day"; } }; }, month: function (s) { return function () { this.month = (s.length === 3) ? "jan feb mar apr may jun jul aug sep oct nov dec".indexOf(s)/4 : Number(s) - 1; if (this.month < 0) { throw "invalid month"; } }; }, year: function (s) { return function () { var n = Number(s); this.year = ((s.length > 2) ? n : (n + (((n + 2000) < Date.CultureInfo.twoDigitYearMax) ? 2000 : 1900))); }; }, rday: function (s) { return function () { switch (s) { case "yesterday": this.days = -1; break; case "tomorrow": this.days = 1; break; case "today": this.days = 0; break; case "now": this.days = 0; this.now = true; break; } }; }, finishExact: function (x) { var d; x = (x instanceof Array) ? x : [x]; for (var i = 0 ; i < x.length ; i++) { if (x[i]) { x[i].call(this); } } setDefaults.call(this); parseMeridian.call(this); if (this.day > $D.getDaysInMonth(this.year, this.month)) { throw new RangeError(this.day + " is not a valid value for days."); } d = new Date(this.year, this.month, this.day, this.hour, this.minute, this.second, this.millisecond); if (this.year < 100) { d.setFullYear(this.year); // means years less that 100 are process correctly. JS will parse it otherwise as 1900-1999. } if (this.timezone) { d.set({ timezone: this.timezone }); } else if (this.timezoneOffset) { d.set({ timezoneOffset: this.timezoneOffset }); } return d; }, finish: function (x) { var today, expression, orient, temp; x = (x instanceof Array) ? flattenAndCompact(x) : [ x ]; if (x.length === 0) { return null; } for (var i = 0 ; i < x.length ; i++) { if (typeof x[i] === "function") { x[i].call(this); } } if (this.now && !this.unit && !this.operator) { return new Date(); } else { today = finishUtils.getToday.call(this); } expression = !!(this.days && this.days !== null || this.orient || this.operator); orient = ((this.orient === "past" || this.operator === "subtract") ? -1 : 1); if (this.month && this.unit === "week") { this.value = this.month + 1; delete this.month; delete this.day; } if ((this.month || this.month === 0) && "year day hour minute second".indexOf(this.unit) !== -1) { if (!this.value) { this.value = this.month + 1; } this.month = null; expression = true; } if (!expression && this.weekday && !this.day && !this.days) { finishUtils.setDMYFromWeekday.call(this); } if (expression && this.weekday && this.unit !== "month" && this.unit !== "week") { finishUtils.setDaysFromWeekday.call(this, today, orient); } if (this.weekday && this.unit !== "week" && !this.day && !this.days) { temp = Date[this.weekday](); this.day = temp.getDate(); if (temp.getMonth() !== today.getMonth()) { this.month = temp.getMonth(); } } if (this.month && this.unit === "day" && this.operator) { if (!this.value) { this.value = (this.month + 1); } this.month = null; } if (this.value != null && this.month != null && this.year != null) { this.day = this.value * 1; } if (this.month && !this.day && this.value) { today.set({ day: this.value * 1 }); if (!expression) { this.day = this.value * 1; } } if (!this.month && this.value && this.unit === "month" && !this.now) { this.month = this.value; expression = true; } if (expression && (this.month || this.month === 0) && this.unit !== "year") { finishUtils.setMonthsFromMonth.call(this, today, orient); } if (!this.unit) { this.unit = "day"; } finishUtils.setUnitValue.call(this, orient); parseMeridian.call(this); if ((this.month || this.month === 0) && !this.day) { this.day = 1; } if (!this.orient && !this.operator && this.unit === "week" && this.value && !this.day && !this.month) { return Date.today().setWeek(this.value); } if (this.unit === "week" && this.weeks && !this.day && !this.month) { return finishUtils.generateDateFromWeeks.call(this); } if (expression && this.timezone && this.day && this.days) { this.day = this.days; } if (expression){ today.add(this); } else { today.set(this); } if (this.timezone) { this.timezone = this.timezone.toUpperCase(); var offset = $D.getTimezoneOffset(this.timezone); var timezone; if (today.hasDaylightSavingTime()) { // lets check that we're being sane with timezone setting timezone = $D.getTimezoneAbbreviation(offset, today.isDaylightSavingTime()); if (timezone !== this.timezone) { // bugger, we're in a place where things like EST vs EDT matters. if (today.isDaylightSavingTime()) { today.addHours(-1); } else { today.addHours(1); } } } today.setTimezoneOffset(offset); } return today; } }; }()); (function () { var $D = Date; $D.Grammar = {}; var _ = $D.Parsing.Operators, g = $D.Grammar, t = $D.Translator, _fn; // Allow rolling up into general purpose rules _fn = function () { return _.each(_.any.apply(null, arguments), _.not(g.ctoken2("timeContext"))); }; g.datePartDelimiter = _.rtoken(/^([\s\-\.\,\/\x27]+)/); g.timePartDelimiter = _.stoken(":"); g.whiteSpace = _.rtoken(/^\s*/); g.generalDelimiter = _.rtoken(/^(([\s\,]|at|@|on)+)/); var _C = {}; g.ctoken = function (keys) { var fn = _C[keys]; if (! fn) { var c = Date.CultureInfo.regexPatterns; var kx = keys.split(/\s+/), px = []; for (var i = 0; i < kx.length ; i++) { px.push(_.replace(_.rtoken(c[kx[i]]), kx[i])); } fn = _C[keys] = _.any.apply(null, px); } return fn; }; g.ctoken2 = function (key) { return _.rtoken(Date.CultureInfo.regexPatterns[key]); }; var cacheProcessRtoken = function (key, token, type, eachToken) { if (eachToken) { g[key] = _.cache(_.process(_.each(_.rtoken(token),_.optional(g.ctoken2(eachToken))), type)); } else { g[key] = _.cache(_.process(_.rtoken(token), type)); } }; var cacheProcessCtoken = function (token, type) { return _.cache(_.process(g.ctoken2(token), type)); }; var _F = {}; //function cache var _get = function (f) { _F[f] = (_F[f] || g.format(f)[0]); return _F[f]; }; g.allformats = function (fx) { var rx = []; if (fx instanceof Array) { for (var i = 0; i < fx.length; i++) { rx.push(_get(fx[i])); } } else { rx.push(_get(fx)); } return rx; }; g.formats = function (fx) { if (fx instanceof Array) { var rx = []; for (var i = 0 ; i < fx.length ; i++) { rx.push(_get(fx[i])); } return _.any.apply(null, rx); } else { return _get(fx); } }; var grammarFormats = { timeFormats: function(){ var i, RTokenKeys = [ "h", "hh", "H", "HH", "m", "mm", "s", "ss", "ss.s", "z", "zz" ], RToken = [ /^(0[0-9]|1[0-2]|[1-9])/, /^(0[0-9]|1[0-2])/, /^([0-1][0-9]|2[0-3]|[0-9])/, /^([0-1][0-9]|2[0-3])/, /^([0-5][0-9]|[0-9])/, /^[0-5][0-9]/, /^([0-5][0-9]|[0-9])/, /^[0-5][0-9]/, /^[0-5][0-9]\.[0-9]{1,3}/, /^((\+|\-)\s*\d\d\d\d)|((\+|\-)\d\d\:?\d\d)/, /^((\+|\-)\s*\d\d\d\d)|((\+|\-)\d\d\:?\d\d)/ ], tokens = [ t.hour, t.hour, t.hour, t.hour, t.minute, t.minute, t.second, t.second, t.secondAndMillisecond, t.timezone, t.timezone ]; for (i=0; i < RTokenKeys.length; i++) { cacheProcessRtoken(RTokenKeys[i], RToken[i], tokens[i]); } g.hms = _.cache(_.sequence([g.H, g.m, g.s], g.timePartDelimiter)); g.t = cacheProcessCtoken("shortMeridian", t.meridian); g.tt = cacheProcessCtoken("longMeridian", t.meridian); g.zzz = cacheProcessCtoken("timezone", t.timezone); g.timeSuffix = _.each(_.ignore(g.whiteSpace), _.set([ g.tt, g.zzz ])); g.time = _.each(_.optional(_.ignore(_.stoken("T"))), g.hms, g.timeSuffix); }, dateFormats: function () { // pre-loaded rules for different date part order preferences var _setfn = function () { return _.set(arguments, g.datePartDelimiter); }; var i, RTokenKeys = [ "d", "dd", "M", "MM", "y", "yy", "yyy", "yyyy" ], RToken = [ /^([0-2]\d|3[0-1]|\d)/, /^([0-2]\d|3[0-1])/, /^(1[0-2]|0\d|\d)/, /^(1[0-2]|0\d)/, /^(\d+)/, /^(\d\d)/, /^(\d\d?\d?\d?)/, /^(\d\d\d\d)/ ], tokens = [ t.day, t.day, t.month, t.month, t.year, t.year, t.year, t.year ], eachToken = [ "ordinalSuffix", "ordinalSuffix" ]; for (i=0; i < RTokenKeys.length; i++) { cacheProcessRtoken(RTokenKeys[i], RToken[i], tokens[i], eachToken[i]); } g.MMM = g.MMMM = _.cache(_.process(g.ctoken("jan feb mar apr may jun jul aug sep oct nov dec"), t.month)); g.ddd = g.dddd = _.cache(_.process(g.ctoken("sun mon tue wed thu fri sat"), function (s) { return function () { this.weekday = s; }; } )); g.day = _fn(g.d, g.dd); g.month = _fn(g.M, g.MMM); g.year = _fn(g.yyyy, g.yy); g.mdy = _setfn(g.ddd, g.month, g.day, g.year); g.ymd = _setfn(g.ddd, g.year, g.month, g.day); g.dmy = _setfn(g.ddd, g.day, g.month, g.year); g.date = function (s) { return ((g[Date.CultureInfo.dateElementOrder] || g.mdy).call(this, s)); }; }, relative: function () { // relative date / time expressions g.orientation = _.process(g.ctoken("past future"), function (s) { return function () { this.orient = s; }; } ); g.operator = _.process(g.ctoken("add subtract"), function (s) { return function () { this.operator = s; }; } ); g.rday = _.process(g.ctoken("yesterday tomorrow today now"), t.rday); g.unit = _.process(g.ctoken("second minute hour day week month year"), function (s) { return function () { this.unit = s; }; } ); } }; g.buildGrammarFormats = function () { // these need to be rebuilt every time the language changes. _C = {}; grammarFormats.timeFormats(); grammarFormats.dateFormats(); grammarFormats.relative(); g.value = _.process(_.rtoken(/^([-+]?\d+)?(st|nd|rd|th)?/), function (s) { return function () { this.value = s.replace(/\D/g, ""); }; } ); g.expression = _.set([g.rday, g.operator, g.value, g.unit, g.orientation, g.ddd, g.MMM ]); g.format = _.process(_.many( _.any( // translate format specifiers into grammar rules _.process( _.rtoken(/^(dd?d?d?(?!e)|MM?M?M?|yy?y?y?|hh?|HH?|mm?|ss?|tt?|zz?z?)/), function (fmt) { if (g[fmt]) { return g[fmt]; } else { throw $D.Parsing.Exception(fmt); } } ), // translate separator tokens into token rules _.process(_.rtoken(/^[^dMyhHmstz]+/), // all legal separators function (s) { return _.ignore(_.stoken(s)); } ) ) ), // construct the parser ... function (rules) { return _.process(_.each.apply(null, rules), t.finishExact); } ); // starting rule for general purpose grammar g._start = _.process(_.set([ g.date, g.time, g.expression ], g.generalDelimiter, g.whiteSpace), t.finish); }; g.buildGrammarFormats(); // parsing date format specifiers - ex: "h:m:s tt" // this little guy will generate a custom parser based // on the format string, ex: g.format("h:m:s tt") // check for these formats first g._formats = g.formats([ "\"yyyy-MM-ddTHH:mm:ssZ\"", "yyyy-MM-ddTHH:mm:ss.sz", "yyyy-MM-ddTHH:mm:ssZ", "yyyy-MM-ddTHH:mm:ssz", "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-ddTHH:mmZ", "yyyy-MM-ddTHH:mmz", "yyyy-MM-ddTHH:mm", "ddd, MMM dd, yyyy H:mm:ss tt", "ddd MMM d yyyy HH:mm:ss zzz", "MMddyyyy", "ddMMyyyy", "Mddyyyy", "ddMyyyy", "Mdyyyy", "dMyyyy", "yyyy", "Mdyy", "dMyy", "d" ]); // real starting rule: tries selected formats first, // then general purpose rule g.start = function (s) { try { var r = g._formats.call({}, s); if (r[1].length === 0) { return r; } } catch (e) {} return g._start.call({}, s); }; }()); (function () { var $D = Date; /** * @desc Converts the specified string value into its JavaScript Date equivalent using CultureInfo specific format information. * * Example

	///////////
	// Dates //
	///////////

	// 15-Oct-2004
	var d1 = Date.parse("10/15/2004");

	// 15-Oct-2004
	var d1 = Date.parse("15-Oct-2004");

	// 15-Oct-2004
	var d1 = Date.parse("2004.10.15");

	//Fri Oct 15, 2004
	var d1 = Date.parse("Fri Oct 15, 2004");

	///////////
	// Times //
	///////////

	// Today at 10 PM.
	var d1 = Date.parse("10 PM");

	// Today at 10:30 PM.
	var d1 = Date.parse("10:30 P.M.");

	// Today at 6 AM.
	var d1 = Date.parse("06am");

	/////////////////////
	// Dates and Times //
	/////////////////////

	// 8-July-2004 @ 10:30 PM
	var d1 = Date.parse("July 8th, 2004, 10:30 PM");

	// 1-July-2004 @ 10:30 PM
	var d1 = Date.parse("2004-07-01T22:30:00");

	////////////////////
	// Relative Dates //
	////////////////////

	// Returns today's date. The string "today" is culture specific.
	var d1 = Date.parse("today");

	// Returns yesterday's date. The string "yesterday" is culture specific.
	var d1 = Date.parse("yesterday");

	// Returns the date of the next thursday.
	var d1 = Date.parse("Next thursday");

	// Returns the date of the most previous monday.
	var d1 = Date.parse("last monday");

	// Returns today's day + one year.
	var d1 = Date.parse("next year");

	///////////////
	// Date Math //
	///////////////

	// Today + 2 days
	var d1 = Date.parse("t+2");

	// Today + 2 days
	var d1 = Date.parse("today + 2 days");

	// Today + 3 months
	var d1 = Date.parse("t+3m");

	// Today - 1 year
	var d1 = Date.parse("today - 1 year");

	// Today - 1 year
	var d1 = Date.parse("t-1y"); 


	/////////////////////////////
	// Partial Dates and Times //
	/////////////////////////////

	// July 15th of this year.
	var d1 = Date.parse("July 15");

	// 15th day of current day and year.
	var d1 = Date.parse("15");

	// July 1st of current year at 10pm.
	var d1 = Date.parse("7/1 10pm");
	
* * @param {String} The string value to convert into a Date object [Required] * @return {Date} A Date object or null if the string cannot be converted into a Date. */ var parseUtils = { removeOrds: function (s) { ords = s.match(/\b(\d+)(?:st|nd|rd|th)\b/); // find ordinal matches s = ((ords && ords.length === 2) ? s.replace(ords[0], ords[1]) : s); return s; }, grammarParser: function (s) { var r = null; try { r = $D.Grammar.start.call({}, s.replace(/^\s*(\S*(\s+\S+)*)\s*$/, "$1")); } catch (e) { return null; } return ((r[1].length === 0) ? r[0] : null); }, nativeFallback: function(s) { var t; try { // ok we haven't parsed it, last ditch attempt with the built-in parser. t = Date._parse(s); return (t || t === 0) ? new Date(t) : null; } catch (e) { return null; } } }; function parse (s) { var d; if (!s) { return null; } if (s instanceof Date) { return s.clone(); } if (s.length >= 4 && s.charAt(0) !== "0" && s.charAt(0) !== "+"&& s.charAt(0) !== "-") { // ie: 2004 will pass, 0800 won't. // Start with specific formats d = $D.Parsing.ISO.parse(s) || $D.Parsing.Numeric.parse(s); } if (d instanceof Date && !isNaN(d.getTime())) { return d; } else { // find ordinal dates (1st, 3rd, 8th, etc and remove them as they cause parsing issues) s = $D.Parsing.Normalizer.parse(parseUtils.removeOrds(s)); d = parseUtils.grammarParser(s); if (d !== null) { return d; } else { return parseUtils.nativeFallback(s); } } } if (!$D._parse) { $D._parse = $D.parse; } $D.parse = parse; Date.getParseFunction = function (fx) { var fns = Date.Grammar.allformats(fx); return function (s) { var r = null; for (var i = 0; i < fns.length; i++) { try { r = fns[i].call({}, s); } catch (e) { continue; } if (r[1].length === 0) { return r[0]; } } return null; }; }; /** * Converts the specified string value into its JavaScript Date equivalent using the specified format {String} or formats {Array} and the CultureInfo specific format information. * The format of the string value must match one of the supplied formats exactly. * * Example

	// 15-Oct-2004
	var d1 = Date.parseExact("10/15/2004", "M/d/yyyy");

	// 15-Oct-2004
	var d1 = Date.parse("15-Oct-2004", "M-ddd-yyyy");

	// 15-Oct-2004
	var d1 = Date.parse("2004.10.15", "yyyy.MM.dd");

	// Multiple formats
	var d1 = Date.parseExact("10/15/2004", ["M/d/yyyy", "MMMM d, yyyy"]);
	
* * @param {String} The string value to convert into a Date object [Required]. * @param {Object} The expected format {String} or an array of expected formats {Array} of the date string [Required]. * @return {Date} A Date object or null if the string cannot be converted into a Date. */ $D.parseExact = function (s, fx) { return $D.getParseFunction(fx)(s); }; }()); (function () { var $D = Date, $P = $D.prototype, // $C = $D.CultureInfo, // not used atm p = function (s, l) { if (!l) { l = 2; } return ("000" + s).slice(l * -1); }; /** * Converts a PHP format string to Java/.NET format string. * A PHP format string can be used with ._format or .format. * A Java/.NET format string can be used with .toString(). * The .parseExact function will only accept a Java/.NET format string * * Example * var f1 = "%m/%d/%y" * var f2 = Date.normalizeFormat(f1); // "MM/dd/yy" * * new Date().format(f1); // "04/13/08" * new Date()._format(f1); // "04/13/08" * new Date().toString(f2); // "04/13/08" * * var date = Date.parseExact("04/13/08", f2); // Sun Apr 13 2008 * * @param {String} A PHP format string consisting of one or more format spcifiers. * @return {String} The PHP format converted to a Java/.NET format string. */ var normalizerSubstitutions = { "d" : "dd", "%d": "dd", "D" : "ddd", "%a": "ddd", "j" : "dddd", "l" : "dddd", "%A": "dddd", "S" : "S", "F" : "MMMM", "%B": "MMMM", "m" : "MM", "%m": "MM", "M" : "MMM", "%b": "MMM", "%h": "MMM", "n" : "M", "Y" : "yyyy", "%Y": "yyyy", "y" : "yy", "%y": "yy", "g" : "h", "%I": "h", "G" : "H", "h" : "hh", "H" : "HH", "%H": "HH", "i" : "mm", "%M": "mm", "s" : "ss", "%S": "ss", "%r": "hh:mm tt", "%R": "H:mm", "%T": "H:mm:ss", "%X": "t", "%x": "d", "%e": "d", "%D": "MM/dd/yy", "%n": "\\n", "%t": "\\t", "e" : "z", "T" : "z", "%z": "z", "%Z": "z", "Z" : "ZZ", "N" : "u", "w" : "u", "%w": "u", "W" : "W", "%V": "W" }; var normalizer = { substitutes: function (m) { return normalizerSubstitutions[m]; }, interpreted: function (m, x) { var y; switch (m) { case "%u": return x.getDay() + 1; case "z": return x.getOrdinalNumber(); case "%j": return p(x.getOrdinalNumber(), 3); case "%U": var d1 = x.clone().set({month: 0, day: 1}).addDays(-1).moveToDayOfWeek(0), d2 = x.clone().addDays(1).moveToDayOfWeek(0, -1); return (d2 < d1) ? "00" : p((d2.getOrdinalNumber() - d1.getOrdinalNumber()) / 7 + 1); case "%W": return p(x.getWeek()); case "t": return $D.getDaysInMonth(x.getFullYear(), x.getMonth()); case "o": case "%G": return x.setWeek(x.getISOWeek()).toString("yyyy"); case "%g": return x._format("%G").slice(-2); case "a": case "%p": return t("tt").toLowerCase(); case "A": return t("tt").toUpperCase(); case "u": return p(x.getMilliseconds(), 3); case "I": return (x.isDaylightSavingTime()) ? 1 : 0; case "O": return x.getUTCOffset(); case "P": y = x.getUTCOffset(); return y.substring(0, y.length - 2) + ":" + y.substring(y.length - 2); case "B": var now = new Date(); return Math.floor(((now.getHours() * 3600) + (now.getMinutes() * 60) + now.getSeconds() + (now.getTimezoneOffset() + 60) * 60) / 86.4); case "c": return x.toISOString().replace(/\"/g, ""); case "U": return $D.strtotime("now"); case "%c": return t("d") + " " + t("t"); case "%C": return Math.floor(x.getFullYear() / 100 + 1); } }, shouldOverrideDefaults: function (m) { switch (m) { case "%e": return true; default: return false; } }, parse: function (m, context) { var formatString, c = context || new Date(); formatString = normalizer.substitutes(m); if (formatString) { return formatString; } formatString = normalizer.interpreted(m, c); if (formatString) { return formatString; } else { return m; } } }; $D.normalizeFormat = function (format, context) { return format.replace(/(%|\\)?.|%%/g, function(t){ return normalizer.parse(t, context); }); }; /** * Format a local Unix timestamp according to locale settings * * Example: * Date.strftime("%m/%d/%y", new Date()); // "04/13/08" * Date.strftime("c", "2008-04-13T17:52:03Z"); // "04/13/08" * * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @param {Number|String} The number representing the number of seconds that have elapsed since January 1, 1970 (local time). * @return {String} A string representation of the current Date object. */ $D.strftime = function (format, time) { var d = Date.parse(time); return d._format(format); }; /** * Parse any textual datetime description into a Unix timestamp. * A Unix timestamp is the number of seconds that have elapsed since January 1, 1970 (midnight UTC/GMT). * * Example: * Date.strtotime("04/13/08"); // 1208044800 * Date.strtotime("1970-01-01T00:00:00Z"); // 0 * * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @param {Object} A string or date object. * @return {String} A string representation of the current Date object. */ $D.strtotime = function (time) { var d = $D.parse(time); return Math.round($D.UTC(d.getUTCFullYear(), d.getUTCMonth(), d.getUTCDate(), d.getUTCHours(), d.getUTCMinutes(), d.getUTCSeconds(), d.getUTCMilliseconds()) / 1000); }; /** * Converts the value of the current Date object to its equivalent string representation using a PHP/Unix style of date format specifiers. * Format Specifiers * Format Description Example * ------ --------------------------------------------------------------------------- ----------------------- * %a abbreviated weekday name according to the current localed "Mon" through "Sun" * %A full weekday name according to the current localed "Sunday" through "Saturday" * %b abbreviated month name according to the current localed "Jan" through "Dec" * %B full month name according to the current locale "January" through "December" * %c preferred date and time representation for the current locale "4/13/2008 12:33 PM" * %C century number (the year divided by 100 and truncated to an integer) "00" to "99" * %d day of the month as a decimal number "01" to "31" * %D same as %m/%d/%y "04/13/08" * %e day of the month as a decimal number, a single digit is preceded by a space "1" to "31" * %g like %G, but without the century "08" * %G The 4-digit year corresponding to the ISO week number (see %V). "2008" * This has the same format and value as %Y, except that if the ISO week number * belongs to the previous or next year, that year is used instead. * %h same as %b "Jan" through "Dec" * %H hour as a decimal number using a 24-hour clock. "00" to "23" * %I hour as a decimal number using a 12-hour clock. "01" to "12" * %j day of the year as a decimal number. "001" to "366" * %m month as a decimal number. "01" to "12" * %M minute as a decimal number. "00" to "59" * %n newline character "\n" * %p either "am" or "pm" according to the given time value, or the "am" or "pm" * corresponding strings for the current locale. * %r time in a.m. and p.m. notation "8:44 PM" * %R time in 24 hour notation "20:44" * %S second as a decimal number "00" to "59" * %t tab character "\t" * %T current time, equal to %H:%M:%S "12:49:11" * %u weekday as a decimal number ["1", "7"], with "1" representing Monday "1" to "7" * %U week number of the current year as a decimal number, starting with the "0" to ("52" or "53") * first Sunday as the first day of the first week * %V The ISO 8601:1988 week number of the current year as a decimal number, "00" to ("52" or "53") * range 01 to 53, where week 1 is the first week that has at least 4 days * in the current year, and with Monday as the first day of the week. * (Use %G or %g for the year component that corresponds to the week number * for the specified timestamp.) * %W week number of the current year as a decimal number, starting with the "00" to ("52" or "53") * first Monday as the first day of the first week * %w day of the week as a decimal, Sunday being "0" "0" to "6" * %x preferred date representation for the current locale without the time "4/13/2008" * %X preferred time representation for the current locale without the date "12:53:05" * %y year as a decimal number without a century "00" "99" * %Y year as a decimal number including the century "2008" * %Z time zone or name or abbreviation "UTC", "EST", "PST" * %z same as %Z * %% a literal "%" characters "%" * d Day of the month, 2 digits with leading zeros "01" to "31" * D A textual representation of a day, three letters "Mon" through "Sun" * j Day of the month without leading zeros "1" to "31" * l A full textual representation of the day of the week (lowercase "L") "Sunday" through "Saturday" * N ISO-8601 numeric representation of the day of the week (added in PHP 5.1.0) "1" (for Monday) through "7" (for Sunday) * S English ordinal suffix for the day of the month, 2 characters "st", "nd", "rd" or "th". Works well with j * w Numeric representation of the day of the week "0" (for Sunday) through "6" (for Saturday) * z The day of the year (starting from "0") "0" through "365" * W ISO-8601 week number of year, weeks starting on Monday "00" to ("52" or "53") * F A full textual representation of a month, such as January or March "January" through "December" * m Numeric representation of a month, with leading zeros "01" through "12" * M A short textual representation of a month, three letters "Jan" through "Dec" * n Numeric representation of a month, without leading zeros "1" through "12" * t Number of days in the given month "28" through "31" * L Whether it's a leap year "1" if it is a leap year, "0" otherwise * o ISO-8601 year number. This has the same value as Y, except that if the "2008" * ISO week number (W) belongs to the previous or next year, that year * is used instead. * Y A full numeric representation of a year, 4 digits "2008" * y A two digit representation of a year "08" * a Lowercase Ante meridiem and Post meridiem "am" or "pm" * A Uppercase Ante meridiem and Post meridiem "AM" or "PM" * B Swatch Internet time "000" through "999" * g 12-hour format of an hour without leading zeros "1" through "12" * G 24-hour format of an hour without leading zeros "0" through "23" * h 12-hour format of an hour with leading zeros "01" through "12" * H 24-hour format of an hour with leading zeros "00" through "23" * i Minutes with leading zeros "00" to "59" * s Seconds, with leading zeros "00" through "59" * u Milliseconds "54321" * e Timezone identifier "UTC", "EST", "PST" * I Whether or not the date is in daylight saving time (uppercase i) "1" if Daylight Saving Time, "0" otherwise * O Difference to Greenwich time (GMT) in hours "+0200", "-0600" * P Difference to Greenwich time (GMT) with colon between hours and minutes "+02:00", "-06:00" * T Timezone abbreviation "UTC", "EST", "PST" * Z Timezone offset in seconds. The offset for timezones west of UTC is "-43200" through "50400" * always negative, and for those east of UTC is always positive. * c ISO 8601 date "2004-02-12T15:19:21+00:00" * r RFC 2822 formatted date "Thu, 21 Dec 2000 16:01:07 +0200" * U Seconds since the Unix Epoch (January 1 1970 00:00:00 GMT) "0" * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @return {String} A string representation of the current Date object. */ var formatReplace = function (context) { return function (m) { var formatString, override = false; if (m.charAt(0) === "\\" || m.substring(0, 2) === "%%") { return m.replace("\\", "").replace("%%", "%"); } override = normalizer.shouldOverrideDefaults(m); formatString = $D.normalizeFormat(m, context); if (formatString) { return context.toString(formatString, override); } }; }; $P._format = function (format) { var formatter = formatReplace(this); if (!format) { return this._toString(); } else { return format.replace(/(%|\\)?.|%%/g, formatter); } }; if (!$P.format) { $P.format = $P._format; } }()); (function () { "use strict"; var gFn = function (attr) { return function () { return this[attr]; }; }; var sFn = function (attr) { return function (val) { this[attr] = val; return this; }; }; var attrs = ["years", "months", "days", "hours", "minutes", "seconds", "milliseconds"]; var addSetFuncs = function (context, attrs) { for (var i = 0; i < attrs.length ; i++) { var $a = attrs[i], $b = $a.slice(0, 1).toUpperCase() + $a.slice(1); context.prototype[$a] = 0; context.prototype["get" + $b] = gFn($a); context.prototype["set" + $b] = sFn($a); } }; /** * new TimeSpan(milliseconds); * new TimeSpan(days, hours, minutes, seconds); * new TimeSpan(days, hours, minutes, seconds, milliseconds); */ var TimeSpan = function (days, hours, minutes, seconds, milliseconds) { if (arguments.length === 1 && typeof days === "number") { var orient = (days < 0) ? -1 : +1; var millsLeft = Math.abs(days); this.setDays(Math.floor(millsLeft / 86400000) * orient); millsLeft = millsLeft % 86400000; this.setHours(Math.floor(millsLeft / 3600000) * orient); millsLeft = millsLeft % 3600000; this.setMinutes(Math.floor(millsLeft / 60000) * orient); millsLeft = millsLeft % 60000; this.setSeconds(Math.floor(millsLeft / 1000) * orient); millsLeft = millsLeft % 1000; this.setMilliseconds(millsLeft * orient); } else { this.set(days, hours, minutes, seconds, milliseconds); } this.getTotalMilliseconds = function () { return (this.getDays() * 86400000) + (this.getHours() * 3600000) + (this.getMinutes() * 60000) + (this.getSeconds() * 1000); }; this.compareTo = function (time) { var t1 = new Date(1970, 1, 1, this.getHours(), this.getMinutes(), this.getSeconds()), t2; if (time === null) { t2 = new Date(1970, 1, 1, 0, 0, 0); } else { t2 = new Date(1970, 1, 1, time.getHours(), time.getMinutes(), time.getSeconds()); } return (t1 < t2) ? -1 : (t1 > t2) ? 1 : 0; }; this.equals = function (time) { return (this.compareTo(time) === 0); }; this.add = function (time) { return (time === null) ? this : this.addSeconds(time.getTotalMilliseconds() / 1000); }; this.subtract = function (time) { return (time === null) ? this : this.addSeconds(-time.getTotalMilliseconds() / 1000); }; this.addDays = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 86400000)); }; this.addHours = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 3600000)); }; this.addMinutes = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 60000)); }; this.addSeconds = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 1000)); }; this.addMilliseconds = function (n) { return new TimeSpan(this.getTotalMilliseconds() + n); }; this.get12HourHour = function () { return (this.getHours() > 12) ? this.getHours() - 12 : (this.getHours() === 0) ? 12 : this.getHours(); }; this.getDesignator = function () { return (this.getHours() < 12) ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator; }; this.toString = function (format) { this._toString = function () { if (this.getDays() !== null && this.getDays() > 0) { return this.getDays() + "." + this.getHours() + ":" + this.p(this.getMinutes()) + ":" + this.p(this.getSeconds()); } else { return this.getHours() + ":" + this.p(this.getMinutes()) + ":" + this.p(this.getSeconds()); } }; this.p = function (s) { return (s.toString().length < 2) ? "0" + s : s; }; var me = this; return format ? format.replace(/dd?|HH?|hh?|mm?|ss?|tt?/g, function (format) { switch (format) { case "d": return me.getDays(); case "dd": return me.p(me.getDays()); case "H": return me.getHours(); case "HH": return me.p(me.getHours()); case "h": return me.get12HourHour(); case "hh": return me.p(me.get12HourHour()); case "m": return me.getMinutes(); case "mm": return me.p(me.getMinutes()); case "s": return me.getSeconds(); case "ss": return me.p(me.getSeconds()); case "t": return ((me.getHours() < 12) ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator).substring(0, 1); case "tt": return (me.getHours() < 12) ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator; } } ) : this._toString(); }; return this; }; addSetFuncs(TimeSpan, attrs.slice(2)); TimeSpan.prototype.set = function (days, hours, minutes, seconds, milliseconds){ this.setDays(days || this.getDays()); this.setHours(hours || this.getHours()); this.setMinutes(minutes || this.getMinutes()); this.setSeconds(seconds || this.getSeconds()); this.setMilliseconds(milliseconds || this.getMilliseconds()); }; /** * Gets the time of day for this date instances. * @return {TimeSpan} TimeSpan */ Date.prototype.getTimeOfDay = function () { return new TimeSpan(0, this.getHours(), this.getMinutes(), this.getSeconds(), this.getMilliseconds()); }; Date.TimeSpan = TimeSpan; if (typeof window !== "undefined" ) { // keeping API compatible for v1.x window.TimeSpan = TimeSpan; } }()); (function () { "use strict"; var attrs = ["years", "months", "days", "hours", "minutes", "seconds", "milliseconds"]; var gFn = function (attr) { return function () { return this[attr]; }; }; var sFn = function (attr) { return function (val) { this[attr] = val; return this; }; }; var addSetFuncs = function (context, attrs) { for (var i = 0; i < attrs.length ; i++) { var $a = attrs[i], $b = $a.slice(0, 1).toUpperCase() + $a.slice(1); context.prototype[$a] = 0; context.prototype["get" + $b] = gFn($a); context.prototype["set" + $b] = sFn($a); } }; var setMonthsAndYears = function (orient, d1, d2, context) { function inc() { d1.addMonths(-orient); context.months++; if (context.months === 12) { context.years++; context.months = 0; } } if (orient === +1) { while (d1 > d2) { inc(); } } else { while (d1 < d2) { inc(); } } context.months--; context.months *= orient; context.years *= orient; }; var adjustForDST = function(orient, startDate, endDate) { var hasDSTMismatch = (false === (startDate.isDaylightSavingTime() === endDate.isDaylightSavingTime())); if (hasDSTMismatch && orient === 1) { startDate.addHours(-1); } else if (hasDSTMismatch) { startDate.addHours(1); } }; /** * TimePeriod(startDate, endDate); * TimePeriod(years, months, days, hours, minutes, seconds, milliseconds); */ var TimePeriod = function (years, months, days, hours, minutes, seconds, milliseconds) { if (arguments.length === 7) { this.set(years, months, days, hours, minutes, seconds, milliseconds); } else if (arguments.length === 2 && arguments[0] instanceof Date && arguments[1] instanceof Date) { var startDate = arguments[0].clone(); var endDate = arguments[1].clone(); var orient = (startDate > endDate) ? +1 : -1; this.dates = { start: arguments[0].clone(), end: arguments[1].clone() }; setMonthsAndYears(orient, startDate, endDate, this); adjustForDST(orient, startDate, endDate); // // TODO - adjust for DST var diff = endDate - startDate; if (diff !== 0) { var ts = new TimeSpan(diff); this.set(this.years, this.months, ts.getDays(), ts.getHours(), ts.getMinutes(), ts.getSeconds(), ts.getMilliseconds()); } } return this; }; // create all the set functions. addSetFuncs(TimePeriod, attrs); TimePeriod.prototype.set = function (years, months, days, hours, minutes, seconds, milliseconds){ this.setYears(years || this.getYears()); this.setMonths(months || this.getMonths()); this.setDays(days || this.getDays()); this.setHours(hours || this.getHours()); this.setMinutes(minutes || this.getMinutes()); this.setSeconds(seconds || this.getSeconds()); this.setMilliseconds(milliseconds || this.getMilliseconds()); }; Date.TimePeriod = TimePeriod; if (typeof window !== "undefined") { // keeping API compatible for v1.x window.TimePeriod = TimePeriod; } }()); ================================================ FILE: build/date-sr-Latn-BA.js ================================================ /** * @overview datejs * @version 1.0.0-rc3 * @author Gregory Wild-Smith * @copyright 2015 Gregory Wild-Smith * @license MIT * @homepage https://github.com/abritinthebay/datejs */ /* * DateJS Culture String File * Country Code: sr-Latn-BA * Name: Serbian (Latin) (Bosnia and Herzegovina) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["sr-Latn-BA"] = { "name": "sr-Latn-BA", "englishName": "Serbian (Latin) (Bosnia and Herzegovina)", "nativeName": "srpski (Bosna i Hercegovina)", "Sunday": "nedelja", "Monday": "ponedeljak", "Tuesday": "utorak", "Wednesday": "sreda", "Thursday": "četvrtak", "Friday": "petak", "Saturday": "subota", "Sun": "ned", "Mon": "pon", "Tue": "uto", "Wed": "sre", "Thu": "čet", "Fri": "pet", "Sat": "sub", "Su": "ned", "Mo": "pon", "Tu": "uto", "We": "sre", "Th": "čet", "Fr": "pet", "Sa": "sub", "S_Sun_Initial": "n", "M_Mon_Initial": "p", "T_Tue_Initial": "u", "W_Wed_Initial": "s", "T_Thu_Initial": "č", "F_Fri_Initial": "p", "S_Sat_Initial": "s", "January": "januar", "February": "februar", "March": "mart", "April": "april", "May": "maj", "June": "jun", "July": "jul", "August": "avgust", "September": "septembar", "October": "oktobar", "November": "novembar", "December": "decembar", "Jan_Abbr": "jan", "Feb_Abbr": "feb", "Mar_Abbr": "mar", "Apr_Abbr": "apr", "May_Abbr": "maj", "Jun_Abbr": "jun", "Jul_Abbr": "jul", "Aug_Abbr": "avg", "Sep_Abbr": "sep", "Oct_Abbr": "okt", "Nov_Abbr": "nov", "Dec_Abbr": "dec", "AM": "", "PM": "", "firstDayOfWeek": 1, "twoDigitYearMax": 2029, "mdy": "dmy", "M/d/yyyy": "d.M.yyyy", "dddd, MMMM dd, yyyy": "d. MMMM yyyy", "h:mm tt": "H:mm:ss", "h:mm:ss tt": "H:mm:ss", "dddd, MMMM dd, yyyy h:mm:ss tt": "d. MMMM yyyy H:mm:ss", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "MMMM dd", "MMMM, yyyy": "MMMM yyyy", "/jan(uary)?/": "jan(uar)?", "/feb(ruary)?/": "feb(ruar)?", "/mar(ch)?/": "mar(t)?", "/apr(il)?/": "apr(il)?", "/may/": "maj", "/jun(e)?/": "jun", "/jul(y)?/": "jul", "/aug(ust)?/": "avg(ust)?", "/sep(t(ember)?)?/": "sep(tembar)?", "/oct(ober)?/": "okt(obar)?", "/nov(ember)?/": "nov(embar)?", "/dec(ember)?/": "dec(embar)?", "/^su(n(day)?)?/": "^nedelja", "/^mo(n(day)?)?/": "^ponedeljak", "/^tu(e(s(day)?)?)?/": "^utorak", "/^we(d(nesday)?)?/": "^sreda", "/^th(u(r(s(day)?)?)?)?/": "^četvrtak", "/^fr(i(day)?)?/": "^petak", "/^sa(t(urday)?)?/": "^subota", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "sr-Latn-BA"; /** * @overview datejs * @version 1.0.0-rc3 * @author Gregory Wild-Smith * @copyright 2015 Gregory Wild-Smith * @license MIT * @homepage https://github.com/abritinthebay/datejs */(function () { var $D = Date; var lang = Date.CultureStrings ? Date.CultureStrings.lang : null; var loggedKeys = {}; // for debug purposes. var getText = { getFromKey: function (key, countryCode) { var output; if (Date.CultureStrings && Date.CultureStrings[countryCode] && Date.CultureStrings[countryCode][key]) { output = Date.CultureStrings[countryCode][key]; } else { output = getText.buildFromDefault(key); } if (key.charAt(0) === "/") { // Assume it's a regex output = getText.buildFromRegex(key, countryCode); } return output; }, getFromObjectValues: function (obj, countryCode) { var key, output = {}; for(key in obj) { if (obj.hasOwnProperty(key)) { output[key] = getText.getFromKey(obj[key], countryCode); } } return output; }, getFromObjectKeys: function (obj, countryCode) { var key, output = {}; for(key in obj) { if (obj.hasOwnProperty(key)) { output[getText.getFromKey(key, countryCode)] = obj[key]; } } return output; }, getFromArray: function (arr, countryCode) { var output = []; for (var i=0; i < arr.length; i++){ if (i in arr) { output[i] = getText.getFromKey(arr[i], countryCode); } } return output; }, buildFromDefault: function (key) { var output, length, split, last; switch(key) { case "name": output = "en-US"; break; case "englishName": output = "English (United States)"; break; case "nativeName": output = "English (United States)"; break; case "twoDigitYearMax": output = 2049; break; case "firstDayOfWeek": output = 0; break; default: output = key; split = key.split("_"); length = split.length; if (length > 1 && key.charAt(0) !== "/") { // if the key isn't a regex and it has a split. last = split[(length - 1)].toLowerCase(); if (last === "initial" || last === "abbr") { output = split[0]; } } break; } return output; }, buildFromRegex: function (key, countryCode) { var output; if (Date.CultureStrings && Date.CultureStrings[countryCode] && Date.CultureStrings[countryCode][key]) { output = new RegExp(Date.CultureStrings[countryCode][key], "i"); } else { output = new RegExp(key.replace(new RegExp("/", "g"),""), "i"); } return output; } }; var shallowMerge = function (obj1, obj2) { for (var attrname in obj2) { if (obj2.hasOwnProperty(attrname)) { obj1[attrname] = obj2[attrname]; } } }; var __ = function (key, language) { var countryCode = (language) ? language : lang; loggedKeys[key] = key; if (typeof key === "object") { if (key instanceof Array) { return getText.getFromArray(key, countryCode); } else { return getText.getFromObjectKeys(key, countryCode); } } else { return getText.getFromKey(key, countryCode); } }; var loadI18nScript = function (code) { // paatterned after jQuery's getScript. var url = Date.Config.i18n + code + ".js"; var head = document.getElementsByTagName("head")[0] || document.documentElement; var script = document.createElement("script"); script.src = url; var completed = false; var events = { done: function (){} // placeholder function }; // Attach handlers for all browsers script.onload = script.onreadystatechange = function() { if ( !completed && (!this.readyState || this.readyState === "loaded" || this.readyState === "complete") ) { events.done(); head.removeChild(script); } }; setTimeout(function() { head.insertBefore(script, head.firstChild); }, 0); // allows return to execute first return { done: function (cb) { events.done = function() { if (cb) { setTimeout(cb,0); } }; } }; }; var buildInfo = { buildFromMethodHash: function (obj) { var key; for(key in obj) { if (obj.hasOwnProperty(key)) { obj[key] = buildInfo[obj[key]](); } } return obj; }, timeZoneDST: function () { var DST = { "CHADT": "+1345", "NZDT": "+1300", "AEDT": "+1100", "ACDT": "+1030", "AZST": "+0500", "IRDT": "+0430", "EEST": "+0300", "CEST": "+0200", "BST": "+0100", "PMDT": "-0200", "ADT": "-0300", "NDT": "-0230", "EDT": "-0400", "CDT": "-0500", "MDT": "-0600", "PDT": "-0700", "AKDT": "-0800", "HADT": "-0900" }; return __(DST); }, timeZoneStandard: function () { var standard = { "LINT": "+1400", "TOT": "+1300", "CHAST": "+1245", "NZST": "+1200", "NFT": "+1130", "SBT": "+1100", "AEST": "+1000", "ACST": "+0930", "JST": "+0900", "CWST": "+0845", "CT": "+0800", "ICT": "+0700", "MMT": "+0630", "BST": "+0600", "NPT": "+0545", "IST": "+0530", "PKT": "+0500", "AFT": "+0430", "MSK": "+0400", "IRST": "+0330", "FET": "+0300", "EET": "+0200", "CET": "+0100", "GMT": "+0000", "UTC": "+0000", "CVT": "-0100", "GST": "-0200", "BRT": "-0300", "NST": "-0330", "AST": "-0400", "EST": "-0500", "CST": "-0600", "MST": "-0700", "PST": "-0800", "AKST": "-0900", "MIT": "-0930", "HST": "-1000", "SST": "-1100", "BIT": "-1200" }; return __(standard); }, timeZones: function (data) { var zone; data.timezones = []; for (zone in data.abbreviatedTimeZoneStandard) { if (data.abbreviatedTimeZoneStandard.hasOwnProperty(zone)) { data.timezones.push({ name: zone, offset: data.abbreviatedTimeZoneStandard[zone]}); } } for (zone in data.abbreviatedTimeZoneDST) { if (data.abbreviatedTimeZoneDST.hasOwnProperty(zone)) { data.timezones.push({ name: zone, offset: data.abbreviatedTimeZoneDST[zone], dst: true}); } } return data.timezones; }, days: function () { return __(["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"]); }, dayAbbr: function () { return __(["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"]); }, dayShortNames: function () { return __(["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"]); }, dayFirstLetters: function () { return __(["S_Sun_Initial", "M_Mon_Initial", "T_Tues_Initial", "W_Wed_Initial", "T_Thu_Initial", "F_Fri_Initial", "S_Sat_Initial"]); }, months: function () { return __(["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"]); }, monthAbbr: function () { return __(["Jan_Abbr", "Feb_Abbr", "Mar_Abbr", "Apr_Abbr", "May_Abbr", "Jun_Abbr", "Jul_Abbr", "Aug_Abbr", "Sep_Abbr", "Oct_Abbr", "Nov_Abbr", "Dec_Abbr"]); }, formatPatterns: function () { return getText.getFromObjectValues({ shortDate: "M/d/yyyy", longDate: "dddd, MMMM dd, yyyy", shortTime: "h:mm tt", longTime: "h:mm:ss tt", fullDateTime: "dddd, MMMM dd, yyyy h:mm:ss tt", sortableDateTime: "yyyy-MM-ddTHH:mm:ss", universalSortableDateTime: "yyyy-MM-dd HH:mm:ssZ", rfc1123: "ddd, dd MMM yyyy HH:mm:ss", monthDay: "MMMM dd", yearMonth: "MMMM, yyyy" }, Date.i18n.currentLanguage()); }, regex: function () { return getText.getFromObjectValues({ inTheMorning: "/( in the )(morn(ing)?)\\b/", thisMorning: "/(this )(morn(ing)?)\\b/", amThisMorning: "/(\b\\d(am)? )(this )(morn(ing)?)/", inTheEvening: "/( in the )(even(ing)?)\\b/", thisEvening: "/(this )(even(ing)?)\\b/", pmThisEvening: "/(\b\\d(pm)? )(this )(even(ing)?)/", jan: "/jan(uary)?/", feb: "/feb(ruary)?/", mar: "/mar(ch)?/", apr: "/apr(il)?/", may: "/may/", jun: "/jun(e)?/", jul: "/jul(y)?/", aug: "/aug(ust)?/", sep: "/sep(t(ember)?)?/", oct: "/oct(ober)?/", nov: "/nov(ember)?/", dec: "/dec(ember)?/", sun: "/^su(n(day)?)?/", mon: "/^mo(n(day)?)?/", tue: "/^tu(e(s(day)?)?)?/", wed: "/^we(d(nesday)?)?/", thu: "/^th(u(r(s(day)?)?)?)?/", fri: "/fr(i(day)?)?/", sat: "/^sa(t(urday)?)?/", future: "/^next/", past: "/^last|past|prev(ious)?/", add: "/^(\\+|aft(er)?|from|hence)/", subtract: "/^(\\-|bef(ore)?|ago)/", yesterday: "/^yes(terday)?/", today: "/^t(od(ay)?)?/", tomorrow: "/^tom(orrow)?/", now: "/^n(ow)?/", millisecond: "/^ms|milli(second)?s?/", second: "/^sec(ond)?s?/", minute: "/^mn|min(ute)?s?/", hour: "/^h(our)?s?/", week: "/^w(eek)?s?/", month: "/^m(onth)?s?/", day: "/^d(ay)?s?/", year: "/^y(ear)?s?/", shortMeridian: "/^(a|p)/", longMeridian: "/^(a\\.?m?\\.?|p\\.?m?\\.?)/", timezone: "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/", ordinalSuffix: "/^\\s*(st|nd|rd|th)/", timeContext: "/^\\s*(\\:|a(?!u|p)|p)/" }, Date.i18n.currentLanguage()); } }; var CultureInfo = function () { var info = getText.getFromObjectValues({ name: "name", englishName: "englishName", nativeName: "nativeName", amDesignator: "AM", pmDesignator: "PM", firstDayOfWeek: "firstDayOfWeek", twoDigitYearMax: "twoDigitYearMax", dateElementOrder: "mdy" }, Date.i18n.currentLanguage()); var constructedInfo = buildInfo.buildFromMethodHash({ dayNames: "days", abbreviatedDayNames: "dayAbbr", shortestDayNames: "dayShortNames", firstLetterDayNames: "dayFirstLetters", monthNames: "months", abbreviatedMonthNames: "monthAbbr", formatPatterns: "formatPatterns", regexPatterns: "regex", abbreviatedTimeZoneDST: "timeZoneDST", abbreviatedTimeZoneStandard: "timeZoneStandard" }); shallowMerge(info, constructedInfo); buildInfo.timeZones(info); return info; }; $D.i18n = { __: function (key, lang) { return __(key, lang); }, currentLanguage: function () { return lang || "en-US"; }, setLanguage: function (code, force, cb) { var async = false; if (force || code === "en-US" || (!!Date.CultureStrings && !!Date.CultureStrings[code])) { lang = code; Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings.lang = code; Date.CultureInfo = new CultureInfo(); } else { if (!(!!Date.CultureStrings && !!Date.CultureStrings[code])) { if (typeof exports !== "undefined" && this.exports !== exports) { // we're in a Node enviroment, load it using require try { require("../i18n/" + code + ".js"); lang = code; Date.CultureStrings.lang = code; Date.CultureInfo = new CultureInfo(); } catch (e) { // var str = "The language for '" + code + "' could not be loaded by Node. It likely does not exist."; throw new Error("The DateJS IETF language tag '" + code + "' could not be loaded by Node. It likely does not exist."); } } else if (Date.Config && Date.Config.i18n) { // we know the location of the files, so lets load them async = true; loadI18nScript(code).done(function(){ lang = code; Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings.lang = code; Date.CultureInfo = new CultureInfo(); $D.Parsing.Normalizer.buildReplaceData(); // because this is async if ($D.Grammar) { $D.Grammar.buildGrammarFormats(); // so we can parse those strings... } if (cb) { setTimeout(cb,0); } }); } else { Date.console.error("The DateJS IETF language tag '" + code + "' is not available and has not been loaded."); return false; } } } $D.Parsing.Normalizer.buildReplaceData(); // rebuild normalizer strings if ($D.Grammar) { $D.Grammar.buildGrammarFormats(); // so we can parse those strings... } if (!async && cb) { setTimeout(cb,0); } }, getLoggedKeys: function () { return loggedKeys; }, updateCultureInfo: function () { Date.CultureInfo = new CultureInfo(); } }; $D.i18n.updateCultureInfo(); // run automatically }()); (function () { var $D = Date, $P = $D.prototype, p = function (s, l) { if (!l) { l = 2; } return ("000" + s).slice(l * -1); }; if (typeof window !== "undefined" && typeof window.console !== "undefined" && typeof window.console.log !== "undefined") { $D.console = console; // used only to raise non-critical errors if available } else { // set mock so we don't give errors. $D.console = { log: function(){}, error: function(){} }; } $D.Config = $D.Config || {}; $D.initOverloads = function() { /** * Overload of Date.now. Allows an alternate call for Date.now where it returns the * current Date as an object rather than just milliseconds since the Unix Epoch. * * Also provides an implementation of now() for browsers (IE<9) that don't have it. * * Backwards compatible so with work with either: * Date.now() [returns ms] * or * Date.now(true) [returns Date] */ if (!$D.now) { $D._now = function now() { return new Date().getTime(); }; } else if (!$D._now) { $D._now = $D.now; } $D.now = function (returnObj) { if (returnObj) { return $D.present(); } else { return $D._now(); } }; if ( !$P.toISOString ) { $P.toISOString = function() { return this.getUTCFullYear() + "-" + p(this.getUTCMonth() + 1) + "-" + p(this.getUTCDate()) + "T" + p(this.getUTCHours()) + ":" + p(this.getUTCMinutes()) + ":" + p(this.getUTCSeconds()) + "." + String( (this.getUTCMilliseconds()/1000).toFixed(3)).slice(2, 5) + "Z"; }; } // private if ( $P._toString === undefined ){ $P._toString = $P.toString; } }; $D.initOverloads(); /** * Gets a date that is set to the current date. The time is set to the start of the day (00:00 or 12:00 AM). * @return {Date} The current date. */ $D.today = function () { return new Date().clearTime(); }; /** * Gets a date that is set to the current date and time (same as new Date, but chainable) * @return {Date} The current date. */ $D.present = function () { return new Date(); }; /** * Compares the first date to the second date and returns an number indication of their relative values. * @param {Date} First Date object to compare [Required]. * @param {Date} Second Date object to compare to [Required]. * @return {Number} -1 = date1 is lessthan date2. 0 = values are equal. 1 = date1 is greaterthan date2. */ $D.compare = function (date1, date2) { if (isNaN(date1) || isNaN(date2)) { throw new Error(date1 + " - " + date2); } else if (date1 instanceof Date && date2 instanceof Date) { return (date1 < date2) ? -1 : (date1 > date2) ? 1 : 0; } else { throw new TypeError(date1 + " - " + date2); } }; /** * Compares the first Date object to the second Date object and returns true if they are equal. * @param {Date} First Date object to compare [Required] * @param {Date} Second Date object to compare to [Required] * @return {Boolean} true if dates are equal. false if they are not equal. */ $D.equals = function (date1, date2) { return (date1.compareTo(date2) === 0); }; /** * Gets the language appropriate day name when given the day number(0-6) * eg - 0 == Sunday * @return {String} The day name */ $D.getDayName = function (n) { return Date.CultureInfo.dayNames[n]; }; /** * Gets the day number (0-6) if given a CultureInfo specific string which is a valid dayName, abbreviatedDayName or shortestDayName (two char). * @param {String} The name of the day (eg. "Monday, "Mon", "tuesday", "tue", "We", "we"). * @return {Number} The day number */ $D.getDayNumberFromName = function (name) { var n = Date.CultureInfo.dayNames, m = Date.CultureInfo.abbreviatedDayNames, o = Date.CultureInfo.shortestDayNames, s = name.toLowerCase(); for (var i = 0; i < n.length; i++) { if (n[i].toLowerCase() === s || m[i].toLowerCase() === s || o[i].toLowerCase() === s) { return i; } } return -1; }; /** * Gets the month number (0-11) if given a Culture Info specific string which is a valid monthName or abbreviatedMonthName. * @param {String} The name of the month (eg. "February, "Feb", "october", "oct"). * @return {Number} The day number */ $D.getMonthNumberFromName = function (name) { var n = Date.CultureInfo.monthNames, m = Date.CultureInfo.abbreviatedMonthNames, s = name.toLowerCase(); for (var i = 0; i < n.length; i++) { if (n[i].toLowerCase() === s || m[i].toLowerCase() === s) { return i; } } return -1; }; /** * Gets the language appropriate month name when given the month number(0-11) * eg - 0 == January * @return {String} The month name */ $D.getMonthName = function (n) { return Date.CultureInfo.monthNames[n]; }; /** * Determines if the current date instance is within a LeapYear. * @param {Number} The year. * @return {Boolean} true if date is within a LeapYear, otherwise false. */ $D.isLeapYear = function (year) { return ((year % 4 === 0 && year % 100 !== 0) || year % 400 === 0); }; /** * Gets the number of days in the month, given a year and month value. Automatically corrects for LeapYear. * @param {Number} The year. * @param {Number} The month (0-11). * @return {Number} The number of days in the month. */ $D.getDaysInMonth = function (year, month) { if (!month && $D.validateMonth(year)) { month = year; year = Date.today().getFullYear(); } return [31, ($D.isLeapYear(year) ? 29 : 28), 31, 30, 31, 30, 31, 31, 30, 31, 30, 31][month]; }; $P.getDaysInMonth = function () { return $D.getDaysInMonth(this.getFullYear(), this.getMonth()); }; $D.getTimezoneAbbreviation = function (offset, dst) { var p, n = (dst || false) ? Date.CultureInfo.abbreviatedTimeZoneDST : Date.CultureInfo.abbreviatedTimeZoneStandard; for (p in n) { if (n.hasOwnProperty(p)) { if (n[p] === offset) { return p; } } } return null; }; $D.getTimezoneOffset = function (name, dst) { var i, a =[], z = Date.CultureInfo.timezones; if (!name) { name = (new Date()).getTimezone();} for (i = 0; i < z.length; i++) { if (z[i].name === name.toUpperCase()) { a.push(i); } } if (!z[a[0]]) { return null; } if (a.length === 1 || !dst) { return z[a[0]].offset; } else { for (i=0; i < a.length; i++) { if (z[a[i]].dst) { return z[a[i]].offset; } } } }; $D.getQuarter = function (d) { d = d || new Date(); // If no date supplied, use today var q = [1,2,3,4]; return q[Math.floor(d.getMonth() / 3)]; // ~~~ is a bitwise op. Faster than Math.floor }; $D.getDaysLeftInQuarter = function (d) { d = d || new Date(); var qEnd = new Date(d); qEnd.setMonth(qEnd.getMonth() + 3 - qEnd.getMonth() % 3, 0); return Math.floor((qEnd - d) / 8.64e7); }; // private var validate = function (n, min, max, name) { name = name ? name : "Object"; if (typeof n === "undefined") { return false; } else if (typeof n !== "number") { throw new TypeError(n + " is not a Number."); } else if (n < min || n > max) { // As failing validation is *not* an exceptional circumstance // lets not throw a RangeError Exception here. // It's semantically correct but it's not sensible. return false; } return true; }; /** * Validates the number is within an acceptable range for milliseconds [0-999]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateMillisecond = function (value) { return validate(value, 0, 999, "millisecond"); }; /** * Validates the number is within an acceptable range for seconds [0-59]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateSecond = function (value) { return validate(value, 0, 59, "second"); }; /** * Validates the number is within an acceptable range for minutes [0-59]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateMinute = function (value) { return validate(value, 0, 59, "minute"); }; /** * Validates the number is within an acceptable range for hours [0-23]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateHour = function (value) { return validate(value, 0, 23, "hour"); }; /** * Validates the number is within an acceptable range for the days in a month [0-MaxDaysInMonth]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateDay = function (value, year, month) { if (year === undefined || year === null || month === undefined || month === null) { return false;} return validate(value, 1, $D.getDaysInMonth(year, month), "day"); }; /** * Validates the number is within an acceptable range for months [0-11]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateWeek = function (value) { return validate(value, 0, 53, "week"); }; /** * Validates the number is within an acceptable range for months [0-11]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateMonth = function (value) { return validate(value, 0, 11, "month"); }; /** * Validates the number is within an acceptable range for years. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateYear = function (value) { /** * Per ECMAScript spec the range of times supported by Date objects is * exactly -100,000,000 days to +100,000,000 days measured relative to * midnight at the beginning of 01 January, 1970 UTC. * This gives a range of 8,640,000,000,000,000 milliseconds to either * side of 01 January, 1970 UTC. * * Earliest possible date: Tue, 20 Apr 271,822 B.C. 00:00:00 UTC * Latest possible date: Sat, 13 Sep 275,760 00:00:00 UTC */ return validate(value, -271822, 275760, "year"); }; $D.validateTimezone = function(value) { var timezones = {"ACDT":1,"ACST":1,"ACT":1,"ADT":1,"AEDT":1,"AEST":1,"AFT":1,"AKDT":1,"AKST":1,"AMST":1,"AMT":1,"ART":1,"AST":1,"AWDT":1,"AWST":1,"AZOST":1,"AZT":1,"BDT":1,"BIOT":1,"BIT":1,"BOT":1,"BRT":1,"BST":1,"BTT":1,"CAT":1,"CCT":1,"CDT":1,"CEDT":1,"CEST":1,"CET":1,"CHADT":1,"CHAST":1,"CHOT":1,"ChST":1,"CHUT":1,"CIST":1,"CIT":1,"CKT":1,"CLST":1,"CLT":1,"COST":1,"COT":1,"CST":1,"CT":1,"CVT":1,"CWST":1,"CXT":1,"DAVT":1,"DDUT":1,"DFT":1,"EASST":1,"EAST":1,"EAT":1,"ECT":1,"EDT":1,"EEDT":1,"EEST":1,"EET":1,"EGST":1,"EGT":1,"EIT":1,"EST":1,"FET":1,"FJT":1,"FKST":1,"FKT":1,"FNT":1,"GALT":1,"GAMT":1,"GET":1,"GFT":1,"GILT":1,"GIT":1,"GMT":1,"GST":1,"GYT":1,"HADT":1,"HAEC":1,"HAST":1,"HKT":1,"HMT":1,"HOVT":1,"HST":1,"ICT":1,"IDT":1,"IOT":1,"IRDT":1,"IRKT":1,"IRST":1,"IST":1,"JST":1,"KGT":1,"KOST":1,"KRAT":1,"KST":1,"LHST":1,"LINT":1,"MAGT":1,"MART":1,"MAWT":1,"MDT":1,"MET":1,"MEST":1,"MHT":1,"MIST":1,"MIT":1,"MMT":1,"MSK":1,"MST":1,"MUT":1,"MVT":1,"MYT":1,"NCT":1,"NDT":1,"NFT":1,"NPT":1,"NST":1,"NT":1,"NUT":1,"NZDT":1,"NZST":1,"OMST":1,"ORAT":1,"PDT":1,"PET":1,"PETT":1,"PGT":1,"PHOT":1,"PHT":1,"PKT":1,"PMDT":1,"PMST":1,"PONT":1,"PST":1,"PYST":1,"PYT":1,"RET":1,"ROTT":1,"SAKT":1,"SAMT":1,"SAST":1,"SBT":1,"SCT":1,"SGT":1,"SLST":1,"SRT":1,"SST":1,"SYOT":1,"TAHT":1,"THA":1,"TFT":1,"TJT":1,"TKT":1,"TLT":1,"TMT":1,"TOT":1,"TVT":1,"UCT":1,"ULAT":1,"UTC":1,"UYST":1,"UYT":1,"UZT":1,"VET":1,"VLAT":1,"VOLT":1,"VOST":1,"VUT":1,"WAKT":1,"WAST":1,"WAT":1,"WEDT":1,"WEST":1,"WET":1,"WST":1,"YAKT":1,"YEKT":1,"Z":1}; return (timezones[value] === 1); }; $D.validateTimezoneOffset= function(value) { // timezones go from +14hrs to -12hrs, the +X hours are negative offsets. return (value > -841 && value < 721); }; }()); (function () { var $D = Date, $P = $D.prototype, p = function (s, l) { if (!l) { l = 2; } return ("000" + s).slice(l * -1); }; var validateConfigObject = function (obj) { var result = {}, self = this, prop, testFunc; testFunc = function (prop, func, value) { if (prop === "day") { var month = (obj.month !== undefined) ? obj.month : self.getMonth(); var year = (obj.year !== undefined) ? obj.year : self.getFullYear(); return $D[func](value, year, month); } else { return $D[func](value); } }; for (prop in obj) { if (Object.prototype.hasOwnProperty.call(obj, prop)) { var func = "validate" + prop.charAt(0).toUpperCase() + prop.slice(1); if ($D[func] && obj[prop] !== null && testFunc(prop, func, obj[prop])) { result[prop] = obj[prop]; } } } return result; }; /** * Resets the time of this Date object to 12:00 AM (00:00), which is the start of the day. * @param {Boolean} .clone() this date instance before clearing Time * @return {Date} this */ $P.clearTime = function () { this.setHours(0); this.setMinutes(0); this.setSeconds(0); this.setMilliseconds(0); return this; }; /** * Resets the time of this Date object to the current time ('now'). * @return {Date} this */ $P.setTimeToNow = function () { var n = new Date(); this.setHours(n.getHours()); this.setMinutes(n.getMinutes()); this.setSeconds(n.getSeconds()); this.setMilliseconds(n.getMilliseconds()); return this; }; /** * Returns a new Date object that is an exact date and time copy of the original instance. * @return {Date} A new Date instance */ $P.clone = function () { return new Date(this.getTime()); }; /** * Compares this instance to a Date object and returns an number indication of their relative values. * @param {Date} Date object to compare [Required] * @return {Number} -1 = this is lessthan date. 0 = values are equal. 1 = this is greaterthan date. */ $P.compareTo = function (date) { return Date.compare(this, date); }; /** * Compares this instance to another Date object and returns true if they are equal. * @param {Date} Date object to compare. If no date to compare, new Date() [now] is used. * @return {Boolean} true if dates are equal. false if they are not equal. */ $P.equals = function (date) { return Date.equals(this, (date !== undefined ? date : new Date())); }; /** * Determines if this instance is between a range of two dates or equal to either the start or end dates. * @param {Date} Start of range [Required] * @param {Date} End of range [Required] * @return {Boolean} true is this is between or equal to the start and end dates, else false */ $P.between = function (start, end) { return this.getTime() >= start.getTime() && this.getTime() <= end.getTime(); }; /** * Determines if this date occurs after the date to compare to. * @param {Date} Date object to compare. If no date to compare, new Date() ("now") is used. * @return {Boolean} true if this date instance is greater than the date to compare to (or "now"), otherwise false. */ $P.isAfter = function (date) { return this.compareTo(date || new Date()) === 1; }; /** * Determines if this date occurs before the date to compare to. * @param {Date} Date object to compare. If no date to compare, new Date() ("now") is used. * @return {Boolean} true if this date instance is less than the date to compare to (or "now"). */ $P.isBefore = function (date) { return (this.compareTo(date || new Date()) === -1); }; /** * Determines if the current Date instance occurs today. * @return {Boolean} true if this date instance is 'today', otherwise false. */ /** * Determines if the current Date instance occurs on the same Date as the supplied 'date'. * If no 'date' to compare to is provided, the current Date instance is compared to 'today'. * @param {date} Date object to compare. If no date to compare, the current Date ("now") is used. * @return {Boolean} true if this Date instance occurs on the same Day as the supplied 'date'. */ $P.isToday = $P.isSameDay = function (date) { return this.clone().clearTime().equals((date || new Date()).clone().clearTime()); }; /** * Adds the specified number of milliseconds to this instance. * @param {Number} The number of milliseconds to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addMilliseconds = function (value) { if (!value) { return this; } this.setTime(this.getTime() + value * 1); return this; }; /** * Adds the specified number of seconds to this instance. * @param {Number} The number of seconds to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addSeconds = function (value) { if (!value) { return this; } return this.addMilliseconds(value * 1000); }; /** * Adds the specified number of seconds to this instance. * @param {Number} The number of seconds to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addMinutes = function (value) { if (!value) { return this; } return this.addMilliseconds(value * 60000); // 60*1000 }; /** * Adds the specified number of hours to this instance. * @param {Number} The number of hours to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addHours = function (value) { if (!value) { return this; } return this.addMilliseconds(value * 3600000); // 60*60*1000 }; /** * Adds the specified number of days to this instance. * @param {Number} The number of days to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addDays = function (value) { if (!value) { return this; } this.setDate(this.getDate() + value * 1); return this; }; /** * Adds the specified number of weekdays (ie - not sat or sun) to this instance. * @param {Number} The number of days to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addWeekdays = function (value) { if (!value) { return this; } var day = this.getDay(); var weeks = (Math.ceil(Math.abs(value)/7)); if (day === 0 || day === 6) { if (value > 0) { this.next().monday(); this.addDays(-1); day = this.getDay(); } } if (value < 0) { while (value < 0) { this.addDays(-1); day = this.getDay(); if (day !== 0 && day !== 6) { value++; } } return this; } else if (value > 5 || (6-day) <= value) { value = value + (weeks * 2); } return this.addDays(value); }; /** * Adds the specified number of weeks to this instance. * @param {Number} The number of weeks to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addWeeks = function (value) { if (!value) { return this; } return this.addDays(value * 7); }; /** * Adds the specified number of months to this instance. * @param {Number} The number of months to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addMonths = function (value) { if (!value) { return this; } var n = this.getDate(); this.setDate(1); this.setMonth(this.getMonth() + value * 1); this.setDate(Math.min(n, $D.getDaysInMonth(this.getFullYear(), this.getMonth()))); return this; }; $P.addQuarters = function (value) { if (!value) { return this; } // note this will take you to the same point in the quarter as you are now. // i.e. - if you are 15 days into the quarter you'll be 15 days into the resulting one. // bonus: this allows adding fractional quarters return this.addMonths(value * 3); }; /** * Adds the specified number of years to this instance. * @param {Number} The number of years to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addYears = function (value) { if (!value) { return this; } return this.addMonths(value * 12); }; /** * Adds (or subtracts) to the value of the years, months, weeks, days, hours, minutes, seconds, milliseconds of the date instance using given configuration object. Positive and Negative values allowed. * Example

	Date.today().add( { days: 1, months: 1 } )

	new Date().add( { years: -1 } )
	
* @param {Object} Configuration object containing attributes (months, days, etc.) * @return {Date} this */ $P.add = function (config) { if (typeof config === "number") { this._orient = config; return this; } var x = config; if (x.day) { // If we should be a different date than today (eg: for 'tomorrow -1d', etc). // Should only effect parsing, not direct usage (eg, Finish and FinishExact) if ((x.day - this.getDate()) !== 0) { this.setDate(x.day); } } if (x.milliseconds) { this.addMilliseconds(x.milliseconds); } if (x.seconds) { this.addSeconds(x.seconds); } if (x.minutes) { this.addMinutes(x.minutes); } if (x.hours) { this.addHours(x.hours); } if (x.weeks) { this.addWeeks(x.weeks); } if (x.months) { this.addMonths(x.months); } if (x.years) { this.addYears(x.years); } if (x.days) { this.addDays(x.days); } return this; }; /** * Get the week number. Week one (1) is the week which contains the first Thursday of the year. Monday is considered the first day of the week. * The .getWeek() function does NOT convert the date to UTC. The local datetime is used. * Please use .getISOWeek() to get the week of the UTC converted date. * @return {Number} 1 to 53 */ $P.getWeek = function (utc) { // Create a copy of this date object var self, target = new Date(this.valueOf()); if (utc) { target.addMinutes(target.getTimezoneOffset()); self = target.clone(); } else { self = this; } // ISO week date weeks start on monday // so correct the day number var dayNr = (self.getDay() + 6) % 7; // ISO 8601 states that week 1 is the week // with the first thursday of that year. // Set the target date to the thursday in the target week target.setDate(target.getDate() - dayNr + 3); // Store the millisecond value of the target date var firstThursday = target.valueOf(); // Set the target to the first thursday of the year // First set the target to january first target.setMonth(0, 1); // Not a thursday? Correct the date to the next thursday if (target.getDay() !== 4) { target.setMonth(0, 1 + ((4 - target.getDay()) + 7) % 7); } // The weeknumber is the number of weeks between the // first thursday of the year and the thursday in the target week return 1 + Math.ceil((firstThursday - target) / 604800000); // 604800000 = 7 * 24 * 3600 * 1000 }; /** * Get the ISO 8601 week number. Week one ("01") is the week which contains the first Thursday of the year. Monday is considered the first day of the week. * The .getISOWeek() function does convert the date to it's UTC value. Please use .getWeek() to get the week of the local date. * @return {String} "01" to "53" */ $P.getISOWeek = function () { return p(this.getWeek(true)); }; /** * Moves the date to Monday of the week set. Week one (1) is the week which contains the first Thursday of the year. * @param {Number} A Number (1 to 53) that represents the week of the year. * @return {Date} this */ $P.setWeek = function (n) { if ((n - this.getWeek()) === 0) { if (this.getDay() !== 1) { return this.moveToDayOfWeek(1, (this.getDay() > 1 ? -1 : 1)); } else { return this; } } else { return this.moveToDayOfWeek(1, (this.getDay() > 1 ? -1 : 1)).addWeeks(n - this.getWeek()); } }; $P.setQuarter = function (qtr) { var month = Math.abs(((qtr-1) * 3) + 1); return this.setMonth(month, 1); }; $P.getQuarter = function () { return Date.getQuarter(this); }; $P.getDaysLeftInQuarter = function () { return Date.getDaysLeftInQuarter(this); }; /** * Moves the date to the next n'th occurrence of the dayOfWeek starting from the beginning of the month. The number (-1) is a magic number and will return the last occurrence of the dayOfWeek in the month. * @param {Number} The dayOfWeek to move to * @param {Number} The n'th occurrence to move to. Use (-1) to return the last occurrence in the month * @return {Date} this */ $P.moveToNthOccurrence = function (dayOfWeek, occurrence) { if (dayOfWeek === "Weekday") { if (occurrence > 0) { this.moveToFirstDayOfMonth(); if (this.is().weekday()) { occurrence -= 1; } } else if (occurrence < 0) { this.moveToLastDayOfMonth(); if (this.is().weekday()) { occurrence += 1; } } else { return this; } return this.addWeekdays(occurrence); } var shift = 0; if (occurrence > 0) { shift = occurrence - 1; } else if (occurrence === -1) { this.moveToLastDayOfMonth(); if (this.getDay() !== dayOfWeek) { this.moveToDayOfWeek(dayOfWeek, -1); } return this; } return this.moveToFirstDayOfMonth().addDays(-1).moveToDayOfWeek(dayOfWeek, +1).addWeeks(shift); }; var moveToN = function (getFunc, addFunc, nVal) { return function (value, orient) { var diff = (value - this[getFunc]() + nVal * (orient || +1)) % nVal; return this[addFunc]((diff === 0) ? diff += nVal * (orient || +1) : diff); }; }; /** * Move to the next or last dayOfWeek based on the orient value. * @param {Number} The dayOfWeek to move to * @param {Number} Forward (+1) or Back (-1). Defaults to +1. [Optional] * @return {Date} this */ $P.moveToDayOfWeek = moveToN("getDay", "addDays", 7); /** * Move to the next or last month based on the orient value. * @param {Number} The month to move to. 0 = January, 11 = December * @param {Number} Forward (+1) or Back (-1). Defaults to +1. [Optional] * @return {Date} this */ $P.moveToMonth = moveToN("getMonth", "addMonths", 12); /** * Get the Ordinate of the current day ("th", "st", "rd"). * @return {String} */ $P.getOrdinate = function () { var num = this.getDate(); return ord(num); }; /** * Get the Ordinal day (numeric day number) of the year, adjusted for leap year. * @return {Number} 1 through 365 (366 in leap years) */ $P.getOrdinalNumber = function () { return Math.ceil((this.clone().clearTime() - new Date(this.getFullYear(), 0, 1)) / 86400000) + 1; }; /** * Get the time zone abbreviation of the current date. * @return {String} The abbreviated time zone name (e.g. "EST") */ $P.getTimezone = function () { return $D.getTimezoneAbbreviation(this.getUTCOffset(), this.isDaylightSavingTime()); }; $P.setTimezoneOffset = function (offset) { var here = this.getTimezoneOffset(), there = Number(offset) * -6 / 10; return (there || there === 0) ? this.addMinutes(there - here) : this; }; $P.setTimezone = function (offset) { return this.setTimezoneOffset($D.getTimezoneOffset(offset)); }; /** * Indicates whether Daylight Saving Time is observed in the current time zone. * @return {Boolean} true|false */ $P.hasDaylightSavingTime = function () { return (Date.today().set({month: 0, day: 1}).getTimezoneOffset() !== Date.today().set({month: 6, day: 1}).getTimezoneOffset()); }; /** * Indicates whether this Date instance is within the Daylight Saving Time range for the current time zone. * @return {Boolean} true|false */ $P.isDaylightSavingTime = function () { return Date.today().set({month: 0, day: 1}).getTimezoneOffset() !== this.getTimezoneOffset(); }; /** * Get the offset from UTC of the current date. * @return {String} The 4-character offset string prefixed with + or - (e.g. "-0500") */ $P.getUTCOffset = function (offset) { var n = (offset || this.getTimezoneOffset()) * -10 / 6, r; if (n < 0) { r = (n - 10000).toString(); return r.charAt(0) + r.substr(2); } else { r = (n + 10000).toString(); return "+" + r.substr(1); } }; /** * Returns the number of milliseconds between this date and date. * @param {Date} Defaults to now * @return {Number} The diff in milliseconds */ $P.getElapsed = function (date) { return (date || new Date()) - this; }; /** * Set the value of year, month, day, hour, minute, second, millisecond of date instance using given configuration object. * Example

	Date.today().set( { day: 20, month: 1 } )

	new Date().set( { millisecond: 0 } )
	
* * @param {Object} Configuration object containing attributes (month, day, etc.) * @return {Date} this */ $P.set = function (config) { config = validateConfigObject.call(this, config); var key; for (key in config) { if (Object.prototype.hasOwnProperty.call(config, key)) { var name = key.charAt(0).toUpperCase() + key.slice(1); var addFunc, getFunc; if (key !== "week" && key !== "month" && key !== "timezone" && key !== "timezoneOffset") { name += "s"; } addFunc = "add" + name; getFunc = "get" + name; if (key === "month") { addFunc = addFunc + "s"; } else if (key === "year"){ getFunc = "getFullYear"; } if (key !== "day" && key !== "timezone" && key !== "timezoneOffset" && key !== "week" && key !== "hour") { this[addFunc](config[key] - this[getFunc]()); } else if ( key === "timezone"|| key === "timezoneOffset" || key === "week" || key === "hour") { this["set"+name](config[key]); } } } // day has to go last because you can't validate the day without first knowing the month if (config.day) { this.addDays(config.day - this.getDate()); } return this; }; /** * Moves the date to the first day of the month. * @return {Date} this */ $P.moveToFirstDayOfMonth = function () { return this.set({ day: 1 }); }; /** * Moves the date to the last day of the month. * @return {Date} this */ $P.moveToLastDayOfMonth = function () { return this.set({ day: $D.getDaysInMonth(this.getFullYear(), this.getMonth())}); }; /** * Converts the value of the current Date object to its equivalent string representation. * Format Specifiers * CUSTOM DATE AND TIME FORMAT STRINGS * Format Description Example * ------ --------------------------------------------------------------------------- ----------------------- * s The seconds of the minute between 0-59. "0" to "59" * ss The seconds of the minute with leading zero if required. "00" to "59" * * m The minute of the hour between 0-59. "0" or "59" * mm The minute of the hour with leading zero if required. "00" or "59" * * h The hour of the day between 1-12. "1" to "12" * hh The hour of the day with leading zero if required. "01" to "12" * * H The hour of the day between 0-23. "0" to "23" * HH The hour of the day with leading zero if required. "00" to "23" * * d The day of the month between 1 and 31. "1" to "31" * dd The day of the month with leading zero if required. "01" to "31" * ddd Abbreviated day name. Date.CultureInfo.abbreviatedDayNames. "Mon" to "Sun" * dddd The full day name. Date.CultureInfo.dayNames. "Monday" to "Sunday" * * M The month of the year between 1-12. "1" to "12" * MM The month of the year with leading zero if required. "01" to "12" * MMM Abbreviated month name. Date.CultureInfo.abbreviatedMonthNames. "Jan" to "Dec" * MMMM The full month name. Date.CultureInfo.monthNames. "January" to "December" * * yy The year as a two-digit number. "99" or "08" * yyyy The full four digit year. "1999" or "2008" * * t Displays the first character of the A.M./P.M. designator. "A" or "P" * Date.CultureInfo.amDesignator or Date.CultureInfo.pmDesignator * tt Displays the A.M./P.M. designator. "AM" or "PM" * Date.CultureInfo.amDesignator or Date.CultureInfo.pmDesignator * * S The ordinal suffix ("st, "nd", "rd" or "th") of the current day. "st, "nd", "rd" or "th" * * STANDARD DATE AND TIME FORMAT STRINGS * Format Description Example *------ --------------------------------------------------------------------------- ----------------------- * d The CultureInfo shortDate Format Pattern "M/d/yyyy" * D The CultureInfo longDate Format Pattern "dddd, MMMM dd, yyyy" * F The CultureInfo fullDateTime Format Pattern "dddd, MMMM dd, yyyy h:mm:ss tt" * m The CultureInfo monthDay Format Pattern "MMMM dd" * r The CultureInfo rfc1123 Format Pattern "ddd, dd MMM yyyy HH:mm:ss GMT" * s The CultureInfo sortableDateTime Format Pattern "yyyy-MM-ddTHH:mm:ss" * t The CultureInfo shortTime Format Pattern "h:mm tt" * T The CultureInfo longTime Format Pattern "h:mm:ss tt" * u The CultureInfo universalSortableDateTime Format Pattern "yyyy-MM-dd HH:mm:ssZ" * y The CultureInfo yearMonth Format Pattern "MMMM, yyyy" * * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @return {String} A string representation of the current Date object. */ var ord = function (n) { switch (n * 1) { case 1: case 21: case 31: return "st"; case 2: case 22: return "nd"; case 3: case 23: return "rd"; default: return "th"; } }; var parseStandardFormats = function (format) { var y, c = Date.CultureInfo.formatPatterns; switch (format) { case "d": return this.toString(c.shortDate); case "D": return this.toString(c.longDate); case "F": return this.toString(c.fullDateTime); case "m": return this.toString(c.monthDay); case "r": case "R": y = this.clone().addMinutes(this.getTimezoneOffset()); return y.toString(c.rfc1123) + " GMT"; case "s": return this.toString(c.sortableDateTime); case "t": return this.toString(c.shortTime); case "T": return this.toString(c.longTime); case "u": y = this.clone().addMinutes(this.getTimezoneOffset()); return y.toString(c.universalSortableDateTime); case "y": return this.toString(c.yearMonth); default: return false; } }; var parseFormatStringsClosure = function (context) { return function (m) { if (m.charAt(0) === "\\") { return m.replace("\\", ""); } switch (m) { case "hh": return p(context.getHours() < 13 ? (context.getHours() === 0 ? 12 : context.getHours()) : (context.getHours() - 12)); case "h": return context.getHours() < 13 ? (context.getHours() === 0 ? 12 : context.getHours()) : (context.getHours() - 12); case "HH": return p(context.getHours()); case "H": return context.getHours(); case "mm": return p(context.getMinutes()); case "m": return context.getMinutes(); case "ss": return p(context.getSeconds()); case "s": return context.getSeconds(); case "yyyy": return p(context.getFullYear(), 4); case "yy": return p(context.getFullYear()); case "y": return context.getFullYear(); case "E": case "dddd": return Date.CultureInfo.dayNames[context.getDay()]; case "ddd": return Date.CultureInfo.abbreviatedDayNames[context.getDay()]; case "dd": return p(context.getDate()); case "d": return context.getDate(); case "MMMM": return Date.CultureInfo.monthNames[context.getMonth()]; case "MMM": return Date.CultureInfo.abbreviatedMonthNames[context.getMonth()]; case "MM": return p((context.getMonth() + 1)); case "M": return context.getMonth() + 1; case "t": return context.getHours() < 12 ? Date.CultureInfo.amDesignator.substring(0, 1) : Date.CultureInfo.pmDesignator.substring(0, 1); case "tt": return context.getHours() < 12 ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator; case "S": return ord(context.getDate()); case "W": return context.getWeek(); case "WW": return context.getISOWeek(); case "Q": return "Q" + context.getQuarter(); case "q": return String(context.getQuarter()); case "z": return context.getTimezone(); case "Z": case "X": return Date.getTimezoneOffset(context.getTimezone()); case "ZZ": // Timezone offset in seconds return context.getTimezoneOffset() * -60; case "u": return context.getDay(); case "L": return ($D.isLeapYear(context.getFullYear())) ? 1 : 0; case "B": // Swatch Internet Time (.beats) return "@"+((context.getUTCSeconds() + (context.getUTCMinutes()*60) + ((context.getUTCHours()+1)*3600))/86.4); default: return m; } }; }; $P.toString = function (format, ignoreStandards) { // Standard Date and Time Format Strings. Formats pulled from CultureInfo file and // may vary by culture. if (!ignoreStandards && format && format.length === 1) { output = parseStandardFormats.call(this, format); if (output) { return output; } } var parseFormatStrings = parseFormatStringsClosure(this); return format ? format.replace(/((\\)?(dd?d?d?|MM?M?M?|yy?y?y?|hh?|HH?|mm?|ss?|tt?|S|q|Q|WW?W?W?)(?![^\[]*\]))/g, parseFormatStrings).replace(/\[|\]/g, "") : this._toString(); }; }()); /************************************************************* * SugarPak - Domain Specific Language - Syntactical Sugar * *************************************************************/ (function () { var $D = Date, $P = $D.prototype, $N = Number.prototype; // private $P._orient = +1; // private $P._nth = null; // private $P._is = false; // private $P._same = false; // private $P._isSecond = false; // private $N._dateElement = "days"; /** * Moves the date to the next instance of a date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.today().next().friday();
	Date.today().next().fri();
	Date.today().next().march();
	Date.today().next().mar();
	Date.today().next().week();
	
* * @return {Date} date */ $P.next = function () { this._move = true; this._orient = +1; return this; }; /** * Creates a new Date (Date.today()) and moves the date to the next instance of the date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.next().friday();
	Date.next().fri();
	Date.next().march();
	Date.next().mar();
	Date.next().week();
	
* * @return {Date} date */ $D.next = function () { return $D.today().next(); }; /** * Moves the date to the previous instance of a date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.today().last().friday();
	Date.today().last().fri();
	Date.today().last().march();
	Date.today().last().mar();
	Date.today().last().week();
	
* * @return {Date} date */ $P.last = $P.prev = $P.previous = function () { this._move = true; this._orient = -1; return this; }; /** * Creates a new Date (Date.today()) and moves the date to the previous instance of the date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.last().friday();
	Date.last().fri();
	Date.previous().march();
	Date.prev().mar();
	Date.last().week();
	
* * @return {Date} date */ $D.last = $D.prev = $D.previous = function () { return $D.today().last(); }; /** * Performs a equality check when followed by either a month name, day name or .weekday() function. * Example

	Date.today().is().friday(); // true|false
	Date.today().is().fri();
	Date.today().is().march();
	Date.today().is().mar();
	
* * @return {Boolean} true|false */ $P.is = function () { this._is = true; return this; }; /** * Determines if two date objects occur on/in exactly the same instance of the subsequent date part function. * The function .same() must be followed by a date part function (example: .day(), .month(), .year(), etc). * * An optional Date can be passed in the date part function. If now date is passed as a parameter, 'Now' is used. * * The following example demonstrates how to determine if two dates fall on the exact same day. * * Example

	var d1 = Date.today(); // today at 00:00
	var d2 = new Date();   // exactly now.

	// Do they occur on the same day?
	d1.same().day(d2); // true
	
	// Do they occur on the same hour?
	d1.same().hour(d2); // false, unless d2 hour is '00' (midnight).
	
	// What if it's the same day, but one year apart?
	var nextYear = Date.today().add(1).year();

	d1.same().day(nextYear); // false, because the dates must occur on the exact same day. 
	
* * Scenario: Determine if a given date occurs during some week period 2 months from now. * * Example

	var future = Date.today().add(2).months();
	return someDate.same().week(future); // true|false;
	
* * @return {Boolean} true|false */ $P.same = function () { this._same = true; this._isSecond = false; return this; }; /** * Determines if the current date/time occurs during Today. Must be preceded by the .is() function. * Example

	someDate.is().today();    // true|false
	new Date().is().today();  // true
	Date.today().is().today();// true
	Date.today().add(-1).day().is().today(); // false
	
* * @return {Boolean} true|false */ $P.today = function () { return this.same().day(); }; /** * Determines if the current date is a weekday. This function must be preceded by the .is() function. * Example

	Date.today().is().weekday(); // true|false
	
* * @return {Boolean} true|false */ $P.weekday = function () { if (this._nth) { return df("Weekday").call(this); } if (this._move) { return this.addWeekdays(this._orient); } if (this._is) { this._is = false; return (!this.is().sat() && !this.is().sun()); } return false; }; /** * Determines if the current date is on the weekend. This function must be preceded by the .is() function. * Example

	Date.today().is().weekend(); // true|false
	
* * @return {Boolean} true|false */ $P.weekend = function () { if (this._is) { this._is = false; return (this.is().sat() || this.is().sun()); } return false; }; /** * Sets the Time of the current Date instance. A string "6:15 pm" or config object {hour:18, minute:15} are accepted. * Example

	// Set time to 6:15pm with a String
	Date.today().at("6:15pm");

	// Set time to 6:15pm with a config object
	Date.today().at({hour:18, minute:15});
	
* * @return {Date} date */ $P.at = function (time) { return (typeof time === "string") ? $D.parse(this.toString("d") + " " + time) : this.set(time); }; /** * Creates a new Date() and adds this (Number) to the date based on the preceding date element function (eg. second|minute|hour|day|month|year). * Example

	// Undeclared Numbers must be wrapped with parentheses. Requirment of JavaScript.
	(3).days().fromNow();
	(6).months().fromNow();

	// Declared Number variables do not require parentheses. 
	var n = 6;
	n.months().fromNow();
	
* * @return {Date} A new Date instance */ $N.fromNow = $N.after = function (date) { var c = {}; c[this._dateElement] = this; return ((!date) ? new Date() : date.clone()).add(c); }; /** * Creates a new Date() and subtract this (Number) from the date based on the preceding date element function (eg. second|minute|hour|day|month|year). * Example

	// Undeclared Numbers must be wrapped with parentheses. Requirment of JavaScript.
	(3).days().ago();
	(6).months().ago();

	// Declared Number variables do not require parentheses. 
	var n = 6;
	n.months().ago();
	
* * @return {Date} A new Date instance */ $N.ago = $N.before = function (date) { var c = {}, s = (this._dateElement[this._dateElement.length-1] !== "s") ? this._dateElement + "s" : this._dateElement; c[s] = this * -1; return ((!date) ? new Date() : date.clone()).add(c); }; // Do NOT modify the following string tokens. These tokens are used to build dynamic functions. // All culture-specific strings can be found in the CultureInfo files. var dx = ("sunday monday tuesday wednesday thursday friday saturday").split(/\s/), mx = ("january february march april may june july august september october november december").split(/\s/), px = ("Millisecond Second Minute Hour Day Week Month Year Quarter Weekday").split(/\s/), pxf = ("Milliseconds Seconds Minutes Hours Date Week Month FullYear Quarter").split(/\s/), nth = ("final first second third fourth fifth").split(/\s/), de; /** * Returns an object literal of all the date parts. * Example

	var o = new Date().toObject();
	
	// { year: 2008, month: 4, week: 20, day: 13, hour: 18, minute: 9, second: 32, millisecond: 812 }
	
	// The object properties can be referenced directly from the object.
	
	alert(o.day);  // alerts "13"
	alert(o.year); // alerts "2008"
	
* * @return {Date} An object literal representing the original date object. */ $P.toObject = function () { var o = {}; for (var i = 0; i < px.length; i++) { if (this["get" + pxf[i]]) { o[px[i].toLowerCase()] = this["get" + pxf[i]](); } } return o; }; /** * Returns a date created from an object literal. Ignores the .week property if set in the config. * Example

	var o = new Date().toObject();
	
	return Date.fromObject(o); // will return the same date. 

	var o2 = {month: 1, day: 20, hour: 18}; // birthday party!
	Date.fromObject(o2);
	
* * @return {Date} An object literal representing the original date object. */ $D.fromObject = function(config) { config.week = null; return Date.today().set(config); }; // Create day name functions and abbreviated day name functions (eg. monday(), friday(), fri()). var df = function (n) { return function () { if (this._is) { this._is = false; return this.getDay() === n; } if (this._move) { this._move = null; } if (this._nth !== null) { // If the .second() function was called earlier, remove the _orient // from the date, and then continue. // This is required because 'second' can be used in two different context. // // Example // // Date.today().add(1).second(); // Date.march().second().monday(); // // Things get crazy with the following... // Date.march().add(1).second().second().monday(); // but it works!! // if (this._isSecond) { this.addSeconds(this._orient * -1); } // make sure we reset _isSecond this._isSecond = false; var ntemp = this._nth; this._nth = null; var temp = this.clone().moveToLastDayOfMonth(); this.moveToNthOccurrence(n, ntemp); if (this > temp) { throw new RangeError($D.getDayName(n) + " does not occur " + ntemp + " times in the month of " + $D.getMonthName(temp.getMonth()) + " " + temp.getFullYear() + "."); } return this; } return this.moveToDayOfWeek(n, this._orient); }; }; var sdf = function (n) { return function () { var t = $D.today(), shift = n - t.getDay(); if (n === 0 && Date.CultureInfo.firstDayOfWeek === 1 && t.getDay() !== 0) { shift = shift + 7; } return t.addDays(shift); }; }; // Create month name functions and abbreviated month name functions (eg. january(), march(), mar()). var month_instance_functions = function (n) { return function () { if (this._is) { this._is = false; return this.getMonth() === n; } return this.moveToMonth(n, this._orient); }; }; var month_static_functions = function (n) { return function () { return $D.today().set({ month: n, day: 1 }); }; }; var processTerms = function (names, staticFunc, instanceFunc) { for (var i = 0; i < names.length; i++) { // Create constant static Name variables. $D[names[i].toUpperCase()] = $D[names[i].toUpperCase().substring(0, 3)] = i; // Create Name functions. $D[names[i]] = $D[names[i].substring(0, 3)] = staticFunc(i); // Create Name instance functions. $P[names[i]] = $P[names[i].substring(0, 3)] = instanceFunc(i); } }; processTerms(dx, sdf, df); processTerms(mx, month_static_functions, month_instance_functions); // Create date element functions and plural date element functions used with Date (eg. day(), days(), months()). var ef = function (j) { return function () { // if the .second() function was called earlier, the _orient // has alread been added. Just return this and reset _isSecond. if (this._isSecond) { this._isSecond = false; return this; } if (this._same) { this._same = this._is = false; var o1 = this.toObject(), o2 = (arguments[0] || new Date()).toObject(), v = "", k = j.toLowerCase(); // the substr trick with -1 doesn't work in IE8 or less k = (k[k.length-1] === "s") ? k.substring(0,k.length-1) : k; for (var m = (px.length - 1); m > -1; m--) { v = px[m].toLowerCase(); if (o1[v] !== o2[v]) { return false; } if (k === v) { break; } } return true; } if (j.substring(j.length - 1) !== "s") { j += "s"; } if (this._move) { this._move = null; } return this["add" + j](this._orient); }; }; var nf = function (n) { return function () { this._dateElement = n; return this; }; }; for (var k = 0; k < px.length; k++) { de = px[k].toLowerCase(); if(de !== "weekday") { // Create date element functions and plural date element functions used with Date (eg. day(), days(), months()). $P[de] = $P[de + "s"] = ef(px[k]); // Create date element functions and plural date element functions used with Number (eg. day(), days(), months()). $N[de] = $N[de + "s"] = nf(de + "s"); } } $P._ss = ef("Second"); var nthfn = function (n) { return function (dayOfWeek) { if (this._same) { return this._ss(arguments[0]); } if (dayOfWeek || dayOfWeek === 0) { return this.moveToNthOccurrence(dayOfWeek, n); } this._nth = n; // if the operator is 'second' add the _orient, then deal with it later... if (n === 2 && (dayOfWeek === undefined || dayOfWeek === null)) { this._isSecond = true; return this.addSeconds(this._orient); } return this; }; }; for (var l = 0; l < nth.length; l++) { $P[nth[l]] = (l === 0) ? nthfn(-1) : nthfn(l); } }()); (function () { "use strict"; Date.Parsing = { Exception: function (s) { this.message = "Parse error at '" + s.substring(0, 10) + " ...'"; } }; var $P = Date.Parsing; var dayOffsets = { standard: [0,31,59,90,120,151,181,212,243,273,304,334], leap: [0,31,60,91,121,152,182,213,244,274,305,335] }; $P.isLeapYear = function(year) { return ((year % 4 === 0) && (year % 100 !== 0)) || (year % 400 === 0); }; var utils = { multiReplace : function (str, hash ) { var key; for (key in hash) { if (Object.prototype.hasOwnProperty.call(hash, key)) { var regex; if (typeof hash[key] === "function") { } else { regex = (hash[key] instanceof RegExp) ? hash[key] : new RegExp(hash[key], "g"); } str = str.replace(regex, key); } } return str; }, getDayOfYearFromWeek : function (obj) { var d, jan4, offset; obj.weekDay = (!obj.weekDay && obj.weekDay !== 0) ? 1 : obj.weekDay; d = new Date(obj.year, 0, 4); jan4 = d.getDay() === 0 ? 7 : d.getDay(); // JS is 0 indexed on Sunday. offset = jan4+3; obj.dayOfYear = ((obj.week * 7) + (obj.weekDay === 0 ? 7 : obj.weekDay))-offset; return obj; }, getDayOfYear : function (obj, dayOffset) { if (!obj.dayOfYear) { obj = utils.getDayOfYearFromWeek(obj); } for (var i=0;i <= dayOffset.length;i++) { if (obj.dayOfYear < dayOffset[i] || i === dayOffset.length) { obj.day = obj.day ? obj.day : (obj.dayOfYear - dayOffset[i-1]); break; } else { obj.month = i; } } return obj; }, adjustForTimeZone : function (obj, date) { var offset; if (obj.zone.toUpperCase() === "Z" || (obj.zone_hours === 0 && obj.zone_minutes === 0)) { // it's UTC/GML so work out the current timeszone offset offset = -date.getTimezoneOffset(); } else { offset = (obj.zone_hours*60) + (obj.zone_minutes || 0); if (obj.zone_sign === "+") { offset *= -1; } offset -= date.getTimezoneOffset(); } date.setMinutes(date.getMinutes()+offset); return date; }, setDefaults : function (obj) { obj.year = obj.year || Date.today().getFullYear(); obj.hours = obj.hours || 0; obj.minutes = obj.minutes || 0; obj.seconds = obj.seconds || 0; obj.milliseconds = obj.milliseconds || 0; if (!(!obj.month && (obj.week || obj.dayOfYear))) { // if we have a month, or if we don't but don't have the day calculation data obj.month = obj.month || 0; obj.day = obj.day || 1; } return obj; }, dataNum: function (data, mod, explict, postProcess) { var dataNum = data*1; if (mod) { if (postProcess) { return data ? mod(data)*1 : data; } else { return data ? mod(dataNum) : data; } } else if (!explict){ return data ? dataNum : data; } else { return (data && typeof data !== "undefined") ? dataNum : data; } }, timeDataProcess: function (obj) { var timeObj = {}; for (var x in obj.data) { if (obj.data.hasOwnProperty(x)) { timeObj[x] = obj.ignore[x] ? obj.data[x] : utils.dataNum(obj.data[x], obj.mods[x], obj.explict[x], obj.postProcess[x]); } } if (obj.data.secmins) { obj.data.secmins = obj.data.secmins.replace(",", ".") * 60; if (!timeObj.minutes) { timeObj.minutes = obj.data.secmins; } else if (!timeObj.seconds) { timeObj.seconds = obj.data.secmins; } delete obj.secmins; } return timeObj; }, buildTimeObjectFromData: function (data) { var time = utils.timeDataProcess({ data: { year : data[1], month : data[5], day : data[7], week : data[8], dayOfYear : data[10], hours : data[15], zone_hours : data[23], zone_minutes : data[24], zone : data[21], zone_sign : data[22], weekDay : data[9], minutes: data[16], seconds: data[19], milliseconds: data[20], secmins: data[18] }, mods: { month: function(data) { return data-1; }, weekDay: function (data) { data = Math.abs(data); return (data === 7 ? 0 : data); }, minutes: function (data) { return data.replace(":",""); }, seconds: function (data) { return Math.floor( (data.replace(":","").replace(",","."))*1 ); }, milliseconds: function (data) { return (data.replace(",",".")*1000); } }, postProcess: { minutes: true, seconds: true, milliseconds: true }, explict: { zone_hours: true, zone_minutes: true }, ignore: { zone: true, zone_sign: true, secmins: true } }); return time; }, addToHash: function (hash, keys, data) { keys = keys; data = data; var len = keys.length; for (var i = 0; i < len; i++) { hash[keys[i]] = data[i]; } return hash; }, combineRegex: function (r1, r2) { return new RegExp("(("+r1.source+")\\s("+r2.source+"))"); }, getDateNthString: function(add, last, inc){ if (add) { return Date.today().addDays(inc).toString("d"); } else if (last) { return Date.today().last()[inc]().toString("d"); } }, buildRegexData: function (array) { var arr = []; var len = array.length; for (var i=0; i < len; i++) { if (Object.prototype.toString.call(array[i]) === '[object Array]') { // oldIE compat version of Array.isArray arr.push(this.combineRegex(array[i][0], array[i][1])); } else { arr.push(array[i]); } } return arr; } }; $P.processTimeObject = function (obj) { var date, dayOffset; utils.setDefaults(obj); dayOffset = ($P.isLeapYear(obj.year)) ? dayOffsets.leap : dayOffsets.standard; if (!obj.month && (obj.week || obj.dayOfYear)) { utils.getDayOfYear(obj, dayOffset); } else { obj.dayOfYear = dayOffset[obj.month] + obj.day; } date = new Date(obj.year, obj.month, obj.day, obj.hours, obj.minutes, obj.seconds, obj.milliseconds); if (obj.zone) { utils.adjustForTimeZone(obj, date); // adjust (and calculate) for timezone } return date; }; $P.ISO = { regex : /^([\+-]?\d{4}(?!\d{2}\b))((-?)((0[1-9]|1[0-2])(\3([12]\d|0[1-9]|3[01]))?|W([0-4]\d|5[0-3])(-?[1-7])?|(00[1-9]|0[1-9]\d|[12]\d{2}|3([0-5]\d|6[1-6])))([T\s]((([01]\d|2[0-4])((:?)[0-5]\d)?|24\:?00)([\.,]\d+(?!:))?)?(\17[0-5]\d([\.,]\d+)?)?\s?([zZ]|([\+-])([01]\d|2[0-3]):?([0-5]\d)?)?)?)?$/, parse : function (s) { var time, data = s.match(this.regex); if (!data || !data.length) { return null; } time = utils.buildTimeObjectFromData(data); if (!time.year || (!time.year && (!time.month && !time.day) && (!time.week && !time.dayOfYear)) ) { return null; } return $P.processTimeObject(time); } }; $P.Numeric = { isNumeric: function (e){return!isNaN(parseFloat(e))&&isFinite(e);}, regex: /\b([0-1]?[0-9])([0-3]?[0-9])([0-2]?[0-9]?[0-9][0-9])\b/i, parse: function (s) { var data, i, time = {}, order = Date.CultureInfo.dateElementOrder.split(""); if (!(this.isNumeric(s)) || // if it's non-numeric OR (s[0] === "+" && s[0] === "-")) { // It's an arithmatic string (eg +/-1000) return null; } if (s.length < 5 && s.indexOf(".") < 0 && s.indexOf("/") < 0) { // assume it's just a year. time.year = s; return $P.processTimeObject(time); } data = s.match(this.regex); if (!data || !data.length) { return null; } for (i=0; i < order.length; i++) { switch(order[i]) { case "d": time.day = data[i+1]; break; case "m": time.month = (data[i+1]-1); break; case "y": time.year = data[i+1]; break; } } return $P.processTimeObject(time); } }; $P.Normalizer = { regexData: function () { var $R = Date.CultureInfo.regexPatterns; return utils.buildRegexData([ $R.tomorrow, $R.yesterday, [$R.past, $R.mon], [$R.past, $R.tue], [$R.past, $R.wed], [$R.past, $R.thu], [$R.past, $R.fri], [$R.past, $R.sat], [$R.past, $R.sun] ]); }, basicReplaceHash : function() { var $R = Date.CultureInfo.regexPatterns; return { "January": $R.jan.source, "February": $R.feb, "March": $R.mar, "April": $R.apr, "May": $R.may, "June": $R.jun, "July": $R.jul, "August": $R.aug, "September": $R.sep, "October": $R.oct, "November": $R.nov, "December": $R.dec, "": /\bat\b/gi, " ": /\s{2,}/, "am": $R.inTheMorning, "9am": $R.thisMorning, "pm": $R.inTheEvening, "7pm":$R.thisEvening }; }, keys : function(){ return [ utils.getDateNthString(true, false, 1), // tomorrow utils.getDateNthString(true, false, -1), // yesterday utils.getDateNthString(false, true, "monday"), //last mon utils.getDateNthString(false, true, "tuesday"), //last tues utils.getDateNthString(false, true, "wednesday"), //last wed utils.getDateNthString(false, true, "thursday"), //last thurs utils.getDateNthString(false, true, "friday"), //last fri utils.getDateNthString(false, true, "saturday"), //last sat utils.getDateNthString(false, true, "sunday") //last sun ]; }, buildRegexFunctions: function () { var $R = Date.CultureInfo.regexPatterns; var __ = Date.i18n.__; var tomorrowRE = new RegExp("(\\b\\d\\d?("+__("AM")+"|"+__("PM")+")? )("+$R.tomorrow.source.slice(1)+")", "i"); // adapted tomorrow regex for AM PM relative dates var todayRE = new RegExp($R.today.source + "(?!\\s*([+-]))\\b"); // today, but excludes the math operators (eg "today + 2h") this.replaceFuncs = [ [todayRE, function (full) { return (full.length > 1) ? Date.today().toString("d") : full; }], [tomorrowRE, function(full, m1) { var t = Date.today().addDays(1).toString("d"); return (t + " " + m1); }], [$R.amThisMorning, function(str, am){return am;}], [$R.pmThisEvening, function(str, pm){return pm;}] ]; }, buildReplaceData: function () { this.buildRegexFunctions(); this.replaceHash = utils.addToHash(this.basicReplaceHash(), this.keys(), this.regexData()); }, stringReplaceFuncs: function (s) { for (var i=0; i < this.replaceFuncs.length; i++) { s = s.replace(this.replaceFuncs[i][0], this.replaceFuncs[i][1]); } return s; }, parse: function (s) { s = this.stringReplaceFuncs(s); s = utils.multiReplace(s, this.replaceHash); try { var n = s.split(/([\s\-\.\,\/\x27]+)/); if (n.length === 3 && $P.Numeric.isNumeric(n[0]) && $P.Numeric.isNumeric(n[2]) && (n[2].length >= 4)) { // ok, so we're dealing with x/year. But that's not a full date. // This fixes wonky dateElementOrder parsing when set to dmy order. if (Date.CultureInfo.dateElementOrder[0] === "d") { s = "1/" + n[0] + "/" + n[2]; // set to 1st of month and normalize the seperator } } } catch (e) {} return s; } }; $P.Normalizer.buildReplaceData(); }()); (function () { var $P = Date.Parsing; var _ = $P.Operators = { // // Tokenizers // rtoken: function (r) { // regex token return function (s) { var mx = s.match(r); if (mx) { return ([ mx[0], s.substring(mx[0].length) ]); } else { throw new $P.Exception(s); } }; }, token: function () { // whitespace-eating token return function (s) { return _.rtoken(new RegExp("^\\s*" + s + "\\s*"))(s); }; }, stoken: function (s) { // string token return _.rtoken(new RegExp("^" + s)); }, // Atomic Operators until: function (p) { return function (s) { var qx = [], rx = null; while (s.length) { try { rx = p.call(this, s); } catch (e) { qx.push(rx[0]); s = rx[1]; continue; } break; } return [ qx, s ]; }; }, many: function (p) { return function (s) { var rx = [], r = null; while (s.length) { try { r = p.call(this, s); } catch (e) { return [ rx, s ]; } rx.push(r[0]); s = r[1]; } return [ rx, s ]; }; }, // generator operators -- see below optional: function (p) { return function (s) { var r = null; try { r = p.call(this, s); } catch (e) { return [ null, s ]; } return [ r[0], r[1] ]; }; }, not: function (p) { return function (s) { try { p.call(this, s); } catch (e) { return [null, s]; } throw new $P.Exception(s); }; }, ignore: function (p) { return p ? function (s) { var r = null; r = p.call(this, s); return [null, r[1]]; } : null; }, product: function () { var px = arguments[0], qx = Array.prototype.slice.call(arguments, 1), rx = []; for (var i = 0 ; i < px.length ; i++) { rx.push(_.each(px[i], qx)); } return rx; }, cache: function (rule) { var cache = {}, cache_length = 0, cache_keys = [], CACHE_MAX = Date.Config.CACHE_MAX || 100000, r = null; var cacheCheck = function () { if (cache_length === CACHE_MAX) { // kill several keys, don't want to have to do this all the time... for (var i=0; i < 10; i++) { var key = cache_keys.shift(); if (key) { delete cache[key]; cache_length--; } } } }; return function (s) { cacheCheck(); try { r = cache[s] = (cache[s] || rule.call(this, s)); } catch (e) { r = cache[s] = e; } cache_length++; cache_keys.push(s); if (r instanceof $P.Exception) { throw r; } else { return r; } }; }, // vector operators -- see below any: function () { var px = arguments; return function (s) { var r = null; for (var i = 0; i < px.length; i++) { if (px[i] == null) { continue; } try { r = (px[i].call(this, s)); } catch (e) { r = null; } if (r) { return r; } } throw new $P.Exception(s); }; }, each: function () { var px = arguments; return function (s) { var rx = [], r = null; for (var i = 0; i < px.length ; i++) { if (px[i] == null) { continue; } try { r = (px[i].call(this, s)); } catch (e) { throw new $P.Exception(s); } rx.push(r[0]); s = r[1]; } return [ rx, s]; }; }, all: function () { var px = arguments, _ = _; return _.each(_.optional(px)); }, // delimited operators sequence: function (px, d, c) { d = d || _.rtoken(/^\s*/); c = c || null; if (px.length === 1) { return px[0]; } return function (s) { var r = null, q = null; var rx = []; for (var i = 0; i < px.length ; i++) { try { r = px[i].call(this, s); } catch (e) { break; } rx.push(r[0]); try { q = d.call(this, r[1]); } catch (ex) { q = null; break; } s = q[1]; } if (!r) { throw new $P.Exception(s); } if (q) { throw new $P.Exception(q[1]); } if (c) { try { r = c.call(this, r[1]); } catch (ey) { throw new $P.Exception(r[1]); } } return [ rx, (r?r[1]:s) ]; }; }, // // Composite Operators // between: function (d1, p, d2) { d2 = d2 || d1; var _fn = _.each(_.ignore(d1), p, _.ignore(d2)); return function (s) { var rx = _fn.call(this, s); return [[rx[0][0], r[0][2]], rx[1]]; }; }, list: function (p, d, c) { d = d || _.rtoken(/^\s*/); c = c || null; return (p instanceof Array ? _.each(_.product(p.slice(0, -1), _.ignore(d)), p.slice(-1), _.ignore(c)) : _.each(_.many(_.each(p, _.ignore(d))), px, _.ignore(c))); }, set: function (px, d, c) { d = d || _.rtoken(/^\s*/); c = c || null; return function (s) { // r is the current match, best the current 'best' match // which means it parsed the most amount of input var r = null, p = null, q = null, rx = null, best = [[], s], last = false; // go through the rules in the given set for (var i = 0; i < px.length ; i++) { // last is a flag indicating whether this must be the last element // if there is only 1 element, then it MUST be the last one q = null; p = null; r = null; last = (px.length === 1); // first, we try simply to match the current pattern // if not, try the next pattern try { r = px[i].call(this, s); } catch (e) { continue; } // since we are matching against a set of elements, the first // thing to do is to add r[0] to matched elements rx = [[r[0]], r[1]]; // if we matched and there is still input to parse and // we don't already know this is the last element, // we're going to next check for the delimiter ... // if there's none, or if there's no input left to parse // than this must be the last element after all ... if (r[1].length > 0 && ! last) { try { q = d.call(this, r[1]); } catch (ex) { last = true; } } else { last = true; } // if we parsed the delimiter and now there's no more input, // that means we shouldn't have parsed the delimiter at all // so don't update r and mark this as the last element ... if (!last && q[1].length === 0) { last = true; } // so, if this isn't the last element, we're going to see if // we can get any more matches from the remaining (unmatched) // elements ... if (!last) { // build a list of the remaining rules we can match against, // i.e., all but the one we just matched against var qx = []; for (var j = 0; j < px.length ; j++) { if (i !== j) { qx.push(px[j]); } } // now invoke recursively set with the remaining input // note that we don't include the closing delimiter ... // we'll check for that ourselves at the end p = _.set(qx, d).call(this, q[1]); // if we got a non-empty set as a result ... // (otw rx already contains everything we want to match) if (p[0].length > 0) { // update current result, which is stored in rx ... // basically, pick up the remaining text from p[1] // and concat the result from p[0] so that we don't // get endless nesting ... rx[0] = rx[0].concat(p[0]); rx[1] = p[1]; } } // at this point, rx either contains the last matched element // or the entire matched set that starts with this element. // now we just check to see if this variation is better than // our best so far, in terms of how much of the input is parsed if (rx[1].length < best[1].length) { best = rx; } // if we've parsed all the input, then we're finished if (best[1].length === 0) { break; } } // so now we've either gone through all the patterns trying them // as the initial match; or we found one that parsed the entire // input string ... // if best has no matches, just return empty set ... if (best[0].length === 0) { return best; } // if a closing delimiter is provided, then we have to check it also if (c) { // we try this even if there is no remaining input because the pattern // may well be optional or match empty input ... try { q = c.call(this, best[1]); } catch (ey) { throw new $P.Exception(best[1]); } // it parsed ... be sure to update the best match remaining input best[1] = q[1]; } // if we're here, either there was no closing delimiter or we parsed it // so now we have the best match; just return it! return best; }; }, forward: function (gr, fname) { return function (s) { return gr[fname].call(this, s); }; }, // // Translation Operators // replace: function (rule, repl) { return function (s) { var r = rule.call(this, s); return [repl, r[1]]; }; }, process: function (rule, fn) { return function (s) { var r = rule.call(this, s); return [fn.call(this, r[0]), r[1]]; }; }, min: function (min, rule) { return function (s) { var rx = rule.call(this, s); if (rx[0].length < min) { throw new $P.Exception(s); } return rx; }; } }; // Generator Operators And Vector Operators // Generators are operators that have a signature of F(R) => R, // taking a given rule and returning another rule, such as // ignore, which parses a given rule and throws away the result. // Vector operators are those that have a signature of F(R1,R2,...) => R, // take a list of rules and returning a new rule, such as each. // Generator operators are converted (via the following _generator // function) into functions that can also take a list or array of rules // and return an array of new rules as though the function had been // called on each rule in turn (which is what actually happens). // This allows generators to be used with vector operators more easily. // Example: // each(ignore(foo, bar)) instead of each(ignore(foo), ignore(bar)) // This also turns generators into vector operators, which allows // constructs like: // not(cache(foo, bar)) var _generator = function (op) { function gen() { var args = null, rx = [], px, i; if (arguments.length > 1) { args = Array.prototype.slice.call(arguments); } else if (arguments[0] instanceof Array) { args = arguments[0]; } if (args) { px = args.shift(); if (px.length > 0) { args.unshift(px[i]); rx.push(op.apply(null, args)); args.shift(); return rx; } } else { return op.apply(null, arguments); } } return gen; }; var gx = "optional not ignore cache".split(/\s/); for (var i = 0 ; i < gx.length ; i++) { _[gx[i]] = _generator(_[gx[i]]); } var _vector = function (op) { return function () { if (arguments[0] instanceof Array) { return op.apply(null, arguments[0]); } else { return op.apply(null, arguments); } }; }; var vx = "each any all".split(/\s/); for (var j = 0 ; j < vx.length ; j++) { _[vx[j]] = _vector(_[vx[j]]); } }()); (function () { var $D = Date; var flattenAndCompact = function (ax) { var rx = []; for (var i = 0; i < ax.length; i++) { if (ax[i] instanceof Array) { rx = rx.concat(flattenAndCompact(ax[i])); } else { if (ax[i]) { rx.push(ax[i]); } } } return rx; }; var parseMeridian = function () { if (this.meridian && (this.hour || this.hour === 0)) { if (this.meridian === "a" && this.hour > 11 && Date.Config.strict24hr){ throw "Invalid hour and meridian combination"; } else if (this.meridian === "p" && this.hour < 12 && Date.Config.strict24hr){ throw "Invalid hour and meridian combination"; } else if (this.meridian === "p" && this.hour < 12) { this.hour = this.hour + 12; } else if (this.meridian === "a" && this.hour === 12) { this.hour = 0; } } }; var setDefaults = function () { var now = new Date(); if ((this.hour || this.minute) && (!this.month && !this.year && !this.day)) { this.day = now.getDate(); } if (!this.year) { this.year = now.getFullYear(); } if (!this.month && this.month !== 0) { this.month = now.getMonth(); } if (!this.day) { this.day = 1; } if (!this.hour) { this.hour = 0; } if (!this.minute) { this.minute = 0; } if (!this.second) { this.second = 0; } if (!this.millisecond) { this.millisecond = 0; } }; var finishUtils = { getToday: function () { if (this.now || "hour minute second".indexOf(this.unit) !== -1) { return new Date(); } else { return $D.today(); } }, setDaysFromWeekday: function (today, orient){ var gap; orient = orient || 1; this.unit = "day"; gap = ($D.getDayNumberFromName(this.weekday) - today.getDay()); this.days = gap ? ((gap + (orient * 7)) % 7) : (orient * 7); return this; }, setMonthsFromMonth: function (today, orient) { var gap; orient = orient || 1; this.unit = "month"; gap = (this.month - today.getMonth()); this.months = gap ? ((gap + (orient * 12)) % 12) : (orient * 12); this.month = null; return this; }, setDMYFromWeekday: function () { var d = Date[this.weekday](); this.day = d.getDate(); if (!this.month) { this.month = d.getMonth(); } this.year = d.getFullYear(); return this; }, setUnitValue: function (orient) { if (!this.value && this.operator && this.operator !== null && this[this.unit + "s"] && this[this.unit + "s"] !== null) { this[this.unit + "s"] = this[this.unit + "s"] + ((this.operator === "add") ? 1 : -1) + (this.value||0) * orient; } else if (this[this.unit + "s"] == null || this.operator != null) { if (!this.value) { this.value = 1; } this[this.unit + "s"] = this.value * orient; } }, generateDateFromWeeks: function () { var weekday = (this.weekday !== undefined) ? this.weekday : "today"; var d = Date[weekday]().addWeeks(this.weeks); if (this.now) { d.setTimeToNow(); } return d; } }; $D.Translator = { hour: function (s) { return function () { this.hour = Number(s); }; }, minute: function (s) { return function () { this.minute = Number(s); }; }, second: function (s) { return function () { this.second = Number(s); }; }, /* for ss.s format */ secondAndMillisecond: function (s) { return function () { var mx = s.match(/^([0-5][0-9])\.([0-9]{1,3})/); this.second = Number(mx[1]); this.millisecond = Number(mx[2]); }; }, meridian: function (s) { return function () { this.meridian = s.slice(0, 1).toLowerCase(); }; }, timezone: function (s) { return function () { var n = s.replace(/[^\d\+\-]/g, ""); if (n.length) { this.timezoneOffset = Number(n); } else { this.timezone = s.toLowerCase(); } }; }, day: function (x) { var s = x[0]; return function () { this.day = Number(s.match(/\d+/)[0]); if (this.day < 1) { throw "invalid day"; } }; }, month: function (s) { return function () { this.month = (s.length === 3) ? "jan feb mar apr may jun jul aug sep oct nov dec".indexOf(s)/4 : Number(s) - 1; if (this.month < 0) { throw "invalid month"; } }; }, year: function (s) { return function () { var n = Number(s); this.year = ((s.length > 2) ? n : (n + (((n + 2000) < Date.CultureInfo.twoDigitYearMax) ? 2000 : 1900))); }; }, rday: function (s) { return function () { switch (s) { case "yesterday": this.days = -1; break; case "tomorrow": this.days = 1; break; case "today": this.days = 0; break; case "now": this.days = 0; this.now = true; break; } }; }, finishExact: function (x) { var d; x = (x instanceof Array) ? x : [x]; for (var i = 0 ; i < x.length ; i++) { if (x[i]) { x[i].call(this); } } setDefaults.call(this); parseMeridian.call(this); if (this.day > $D.getDaysInMonth(this.year, this.month)) { throw new RangeError(this.day + " is not a valid value for days."); } d = new Date(this.year, this.month, this.day, this.hour, this.minute, this.second, this.millisecond); if (this.year < 100) { d.setFullYear(this.year); // means years less that 100 are process correctly. JS will parse it otherwise as 1900-1999. } if (this.timezone) { d.set({ timezone: this.timezone }); } else if (this.timezoneOffset) { d.set({ timezoneOffset: this.timezoneOffset }); } return d; }, finish: function (x) { var today, expression, orient, temp; x = (x instanceof Array) ? flattenAndCompact(x) : [ x ]; if (x.length === 0) { return null; } for (var i = 0 ; i < x.length ; i++) { if (typeof x[i] === "function") { x[i].call(this); } } if (this.now && !this.unit && !this.operator) { return new Date(); } else { today = finishUtils.getToday.call(this); } expression = !!(this.days && this.days !== null || this.orient || this.operator); orient = ((this.orient === "past" || this.operator === "subtract") ? -1 : 1); if (this.month && this.unit === "week") { this.value = this.month + 1; delete this.month; delete this.day; } if ((this.month || this.month === 0) && "year day hour minute second".indexOf(this.unit) !== -1) { if (!this.value) { this.value = this.month + 1; } this.month = null; expression = true; } if (!expression && this.weekday && !this.day && !this.days) { finishUtils.setDMYFromWeekday.call(this); } if (expression && this.weekday && this.unit !== "month" && this.unit !== "week") { finishUtils.setDaysFromWeekday.call(this, today, orient); } if (this.weekday && this.unit !== "week" && !this.day && !this.days) { temp = Date[this.weekday](); this.day = temp.getDate(); if (temp.getMonth() !== today.getMonth()) { this.month = temp.getMonth(); } } if (this.month && this.unit === "day" && this.operator) { if (!this.value) { this.value = (this.month + 1); } this.month = null; } if (this.value != null && this.month != null && this.year != null) { this.day = this.value * 1; } if (this.month && !this.day && this.value) { today.set({ day: this.value * 1 }); if (!expression) { this.day = this.value * 1; } } if (!this.month && this.value && this.unit === "month" && !this.now) { this.month = this.value; expression = true; } if (expression && (this.month || this.month === 0) && this.unit !== "year") { finishUtils.setMonthsFromMonth.call(this, today, orient); } if (!this.unit) { this.unit = "day"; } finishUtils.setUnitValue.call(this, orient); parseMeridian.call(this); if ((this.month || this.month === 0) && !this.day) { this.day = 1; } if (!this.orient && !this.operator && this.unit === "week" && this.value && !this.day && !this.month) { return Date.today().setWeek(this.value); } if (this.unit === "week" && this.weeks && !this.day && !this.month) { return finishUtils.generateDateFromWeeks.call(this); } if (expression && this.timezone && this.day && this.days) { this.day = this.days; } if (expression){ today.add(this); } else { today.set(this); } if (this.timezone) { this.timezone = this.timezone.toUpperCase(); var offset = $D.getTimezoneOffset(this.timezone); var timezone; if (today.hasDaylightSavingTime()) { // lets check that we're being sane with timezone setting timezone = $D.getTimezoneAbbreviation(offset, today.isDaylightSavingTime()); if (timezone !== this.timezone) { // bugger, we're in a place where things like EST vs EDT matters. if (today.isDaylightSavingTime()) { today.addHours(-1); } else { today.addHours(1); } } } today.setTimezoneOffset(offset); } return today; } }; }()); (function () { var $D = Date; $D.Grammar = {}; var _ = $D.Parsing.Operators, g = $D.Grammar, t = $D.Translator, _fn; // Allow rolling up into general purpose rules _fn = function () { return _.each(_.any.apply(null, arguments), _.not(g.ctoken2("timeContext"))); }; g.datePartDelimiter = _.rtoken(/^([\s\-\.\,\/\x27]+)/); g.timePartDelimiter = _.stoken(":"); g.whiteSpace = _.rtoken(/^\s*/); g.generalDelimiter = _.rtoken(/^(([\s\,]|at|@|on)+)/); var _C = {}; g.ctoken = function (keys) { var fn = _C[keys]; if (! fn) { var c = Date.CultureInfo.regexPatterns; var kx = keys.split(/\s+/), px = []; for (var i = 0; i < kx.length ; i++) { px.push(_.replace(_.rtoken(c[kx[i]]), kx[i])); } fn = _C[keys] = _.any.apply(null, px); } return fn; }; g.ctoken2 = function (key) { return _.rtoken(Date.CultureInfo.regexPatterns[key]); }; var cacheProcessRtoken = function (key, token, type, eachToken) { if (eachToken) { g[key] = _.cache(_.process(_.each(_.rtoken(token),_.optional(g.ctoken2(eachToken))), type)); } else { g[key] = _.cache(_.process(_.rtoken(token), type)); } }; var cacheProcessCtoken = function (token, type) { return _.cache(_.process(g.ctoken2(token), type)); }; var _F = {}; //function cache var _get = function (f) { _F[f] = (_F[f] || g.format(f)[0]); return _F[f]; }; g.allformats = function (fx) { var rx = []; if (fx instanceof Array) { for (var i = 0; i < fx.length; i++) { rx.push(_get(fx[i])); } } else { rx.push(_get(fx)); } return rx; }; g.formats = function (fx) { if (fx instanceof Array) { var rx = []; for (var i = 0 ; i < fx.length ; i++) { rx.push(_get(fx[i])); } return _.any.apply(null, rx); } else { return _get(fx); } }; var grammarFormats = { timeFormats: function(){ var i, RTokenKeys = [ "h", "hh", "H", "HH", "m", "mm", "s", "ss", "ss.s", "z", "zz" ], RToken = [ /^(0[0-9]|1[0-2]|[1-9])/, /^(0[0-9]|1[0-2])/, /^([0-1][0-9]|2[0-3]|[0-9])/, /^([0-1][0-9]|2[0-3])/, /^([0-5][0-9]|[0-9])/, /^[0-5][0-9]/, /^([0-5][0-9]|[0-9])/, /^[0-5][0-9]/, /^[0-5][0-9]\.[0-9]{1,3}/, /^((\+|\-)\s*\d\d\d\d)|((\+|\-)\d\d\:?\d\d)/, /^((\+|\-)\s*\d\d\d\d)|((\+|\-)\d\d\:?\d\d)/ ], tokens = [ t.hour, t.hour, t.hour, t.hour, t.minute, t.minute, t.second, t.second, t.secondAndMillisecond, t.timezone, t.timezone ]; for (i=0; i < RTokenKeys.length; i++) { cacheProcessRtoken(RTokenKeys[i], RToken[i], tokens[i]); } g.hms = _.cache(_.sequence([g.H, g.m, g.s], g.timePartDelimiter)); g.t = cacheProcessCtoken("shortMeridian", t.meridian); g.tt = cacheProcessCtoken("longMeridian", t.meridian); g.zzz = cacheProcessCtoken("timezone", t.timezone); g.timeSuffix = _.each(_.ignore(g.whiteSpace), _.set([ g.tt, g.zzz ])); g.time = _.each(_.optional(_.ignore(_.stoken("T"))), g.hms, g.timeSuffix); }, dateFormats: function () { // pre-loaded rules for different date part order preferences var _setfn = function () { return _.set(arguments, g.datePartDelimiter); }; var i, RTokenKeys = [ "d", "dd", "M", "MM", "y", "yy", "yyy", "yyyy" ], RToken = [ /^([0-2]\d|3[0-1]|\d)/, /^([0-2]\d|3[0-1])/, /^(1[0-2]|0\d|\d)/, /^(1[0-2]|0\d)/, /^(\d+)/, /^(\d\d)/, /^(\d\d?\d?\d?)/, /^(\d\d\d\d)/ ], tokens = [ t.day, t.day, t.month, t.month, t.year, t.year, t.year, t.year ], eachToken = [ "ordinalSuffix", "ordinalSuffix" ]; for (i=0; i < RTokenKeys.length; i++) { cacheProcessRtoken(RTokenKeys[i], RToken[i], tokens[i], eachToken[i]); } g.MMM = g.MMMM = _.cache(_.process(g.ctoken("jan feb mar apr may jun jul aug sep oct nov dec"), t.month)); g.ddd = g.dddd = _.cache(_.process(g.ctoken("sun mon tue wed thu fri sat"), function (s) { return function () { this.weekday = s; }; } )); g.day = _fn(g.d, g.dd); g.month = _fn(g.M, g.MMM); g.year = _fn(g.yyyy, g.yy); g.mdy = _setfn(g.ddd, g.month, g.day, g.year); g.ymd = _setfn(g.ddd, g.year, g.month, g.day); g.dmy = _setfn(g.ddd, g.day, g.month, g.year); g.date = function (s) { return ((g[Date.CultureInfo.dateElementOrder] || g.mdy).call(this, s)); }; }, relative: function () { // relative date / time expressions g.orientation = _.process(g.ctoken("past future"), function (s) { return function () { this.orient = s; }; } ); g.operator = _.process(g.ctoken("add subtract"), function (s) { return function () { this.operator = s; }; } ); g.rday = _.process(g.ctoken("yesterday tomorrow today now"), t.rday); g.unit = _.process(g.ctoken("second minute hour day week month year"), function (s) { return function () { this.unit = s; }; } ); } }; g.buildGrammarFormats = function () { // these need to be rebuilt every time the language changes. _C = {}; grammarFormats.timeFormats(); grammarFormats.dateFormats(); grammarFormats.relative(); g.value = _.process(_.rtoken(/^([-+]?\d+)?(st|nd|rd|th)?/), function (s) { return function () { this.value = s.replace(/\D/g, ""); }; } ); g.expression = _.set([g.rday, g.operator, g.value, g.unit, g.orientation, g.ddd, g.MMM ]); g.format = _.process(_.many( _.any( // translate format specifiers into grammar rules _.process( _.rtoken(/^(dd?d?d?(?!e)|MM?M?M?|yy?y?y?|hh?|HH?|mm?|ss?|tt?|zz?z?)/), function (fmt) { if (g[fmt]) { return g[fmt]; } else { throw $D.Parsing.Exception(fmt); } } ), // translate separator tokens into token rules _.process(_.rtoken(/^[^dMyhHmstz]+/), // all legal separators function (s) { return _.ignore(_.stoken(s)); } ) ) ), // construct the parser ... function (rules) { return _.process(_.each.apply(null, rules), t.finishExact); } ); // starting rule for general purpose grammar g._start = _.process(_.set([ g.date, g.time, g.expression ], g.generalDelimiter, g.whiteSpace), t.finish); }; g.buildGrammarFormats(); // parsing date format specifiers - ex: "h:m:s tt" // this little guy will generate a custom parser based // on the format string, ex: g.format("h:m:s tt") // check for these formats first g._formats = g.formats([ "\"yyyy-MM-ddTHH:mm:ssZ\"", "yyyy-MM-ddTHH:mm:ss.sz", "yyyy-MM-ddTHH:mm:ssZ", "yyyy-MM-ddTHH:mm:ssz", "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-ddTHH:mmZ", "yyyy-MM-ddTHH:mmz", "yyyy-MM-ddTHH:mm", "ddd, MMM dd, yyyy H:mm:ss tt", "ddd MMM d yyyy HH:mm:ss zzz", "MMddyyyy", "ddMMyyyy", "Mddyyyy", "ddMyyyy", "Mdyyyy", "dMyyyy", "yyyy", "Mdyy", "dMyy", "d" ]); // real starting rule: tries selected formats first, // then general purpose rule g.start = function (s) { try { var r = g._formats.call({}, s); if (r[1].length === 0) { return r; } } catch (e) {} return g._start.call({}, s); }; }()); (function () { var $D = Date; /** * @desc Converts the specified string value into its JavaScript Date equivalent using CultureInfo specific format information. * * Example

	///////////
	// Dates //
	///////////

	// 15-Oct-2004
	var d1 = Date.parse("10/15/2004");

	// 15-Oct-2004
	var d1 = Date.parse("15-Oct-2004");

	// 15-Oct-2004
	var d1 = Date.parse("2004.10.15");

	//Fri Oct 15, 2004
	var d1 = Date.parse("Fri Oct 15, 2004");

	///////////
	// Times //
	///////////

	// Today at 10 PM.
	var d1 = Date.parse("10 PM");

	// Today at 10:30 PM.
	var d1 = Date.parse("10:30 P.M.");

	// Today at 6 AM.
	var d1 = Date.parse("06am");

	/////////////////////
	// Dates and Times //
	/////////////////////

	// 8-July-2004 @ 10:30 PM
	var d1 = Date.parse("July 8th, 2004, 10:30 PM");

	// 1-July-2004 @ 10:30 PM
	var d1 = Date.parse("2004-07-01T22:30:00");

	////////////////////
	// Relative Dates //
	////////////////////

	// Returns today's date. The string "today" is culture specific.
	var d1 = Date.parse("today");

	// Returns yesterday's date. The string "yesterday" is culture specific.
	var d1 = Date.parse("yesterday");

	// Returns the date of the next thursday.
	var d1 = Date.parse("Next thursday");

	// Returns the date of the most previous monday.
	var d1 = Date.parse("last monday");

	// Returns today's day + one year.
	var d1 = Date.parse("next year");

	///////////////
	// Date Math //
	///////////////

	// Today + 2 days
	var d1 = Date.parse("t+2");

	// Today + 2 days
	var d1 = Date.parse("today + 2 days");

	// Today + 3 months
	var d1 = Date.parse("t+3m");

	// Today - 1 year
	var d1 = Date.parse("today - 1 year");

	// Today - 1 year
	var d1 = Date.parse("t-1y"); 


	/////////////////////////////
	// Partial Dates and Times //
	/////////////////////////////

	// July 15th of this year.
	var d1 = Date.parse("July 15");

	// 15th day of current day and year.
	var d1 = Date.parse("15");

	// July 1st of current year at 10pm.
	var d1 = Date.parse("7/1 10pm");
	
* * @param {String} The string value to convert into a Date object [Required] * @return {Date} A Date object or null if the string cannot be converted into a Date. */ var parseUtils = { removeOrds: function (s) { ords = s.match(/\b(\d+)(?:st|nd|rd|th)\b/); // find ordinal matches s = ((ords && ords.length === 2) ? s.replace(ords[0], ords[1]) : s); return s; }, grammarParser: function (s) { var r = null; try { r = $D.Grammar.start.call({}, s.replace(/^\s*(\S*(\s+\S+)*)\s*$/, "$1")); } catch (e) { return null; } return ((r[1].length === 0) ? r[0] : null); }, nativeFallback: function(s) { var t; try { // ok we haven't parsed it, last ditch attempt with the built-in parser. t = Date._parse(s); return (t || t === 0) ? new Date(t) : null; } catch (e) { return null; } } }; function parse (s) { var d; if (!s) { return null; } if (s instanceof Date) { return s.clone(); } if (s.length >= 4 && s.charAt(0) !== "0" && s.charAt(0) !== "+"&& s.charAt(0) !== "-") { // ie: 2004 will pass, 0800 won't. // Start with specific formats d = $D.Parsing.ISO.parse(s) || $D.Parsing.Numeric.parse(s); } if (d instanceof Date && !isNaN(d.getTime())) { return d; } else { // find ordinal dates (1st, 3rd, 8th, etc and remove them as they cause parsing issues) s = $D.Parsing.Normalizer.parse(parseUtils.removeOrds(s)); d = parseUtils.grammarParser(s); if (d !== null) { return d; } else { return parseUtils.nativeFallback(s); } } } if (!$D._parse) { $D._parse = $D.parse; } $D.parse = parse; Date.getParseFunction = function (fx) { var fns = Date.Grammar.allformats(fx); return function (s) { var r = null; for (var i = 0; i < fns.length; i++) { try { r = fns[i].call({}, s); } catch (e) { continue; } if (r[1].length === 0) { return r[0]; } } return null; }; }; /** * Converts the specified string value into its JavaScript Date equivalent using the specified format {String} or formats {Array} and the CultureInfo specific format information. * The format of the string value must match one of the supplied formats exactly. * * Example

	// 15-Oct-2004
	var d1 = Date.parseExact("10/15/2004", "M/d/yyyy");

	// 15-Oct-2004
	var d1 = Date.parse("15-Oct-2004", "M-ddd-yyyy");

	// 15-Oct-2004
	var d1 = Date.parse("2004.10.15", "yyyy.MM.dd");

	// Multiple formats
	var d1 = Date.parseExact("10/15/2004", ["M/d/yyyy", "MMMM d, yyyy"]);
	
* * @param {String} The string value to convert into a Date object [Required]. * @param {Object} The expected format {String} or an array of expected formats {Array} of the date string [Required]. * @return {Date} A Date object or null if the string cannot be converted into a Date. */ $D.parseExact = function (s, fx) { return $D.getParseFunction(fx)(s); }; }()); (function () { var $D = Date, $P = $D.prototype, // $C = $D.CultureInfo, // not used atm p = function (s, l) { if (!l) { l = 2; } return ("000" + s).slice(l * -1); }; /** * Converts a PHP format string to Java/.NET format string. * A PHP format string can be used with ._format or .format. * A Java/.NET format string can be used with .toString(). * The .parseExact function will only accept a Java/.NET format string * * Example * var f1 = "%m/%d/%y" * var f2 = Date.normalizeFormat(f1); // "MM/dd/yy" * * new Date().format(f1); // "04/13/08" * new Date()._format(f1); // "04/13/08" * new Date().toString(f2); // "04/13/08" * * var date = Date.parseExact("04/13/08", f2); // Sun Apr 13 2008 * * @param {String} A PHP format string consisting of one or more format spcifiers. * @return {String} The PHP format converted to a Java/.NET format string. */ var normalizerSubstitutions = { "d" : "dd", "%d": "dd", "D" : "ddd", "%a": "ddd", "j" : "dddd", "l" : "dddd", "%A": "dddd", "S" : "S", "F" : "MMMM", "%B": "MMMM", "m" : "MM", "%m": "MM", "M" : "MMM", "%b": "MMM", "%h": "MMM", "n" : "M", "Y" : "yyyy", "%Y": "yyyy", "y" : "yy", "%y": "yy", "g" : "h", "%I": "h", "G" : "H", "h" : "hh", "H" : "HH", "%H": "HH", "i" : "mm", "%M": "mm", "s" : "ss", "%S": "ss", "%r": "hh:mm tt", "%R": "H:mm", "%T": "H:mm:ss", "%X": "t", "%x": "d", "%e": "d", "%D": "MM/dd/yy", "%n": "\\n", "%t": "\\t", "e" : "z", "T" : "z", "%z": "z", "%Z": "z", "Z" : "ZZ", "N" : "u", "w" : "u", "%w": "u", "W" : "W", "%V": "W" }; var normalizer = { substitutes: function (m) { return normalizerSubstitutions[m]; }, interpreted: function (m, x) { var y; switch (m) { case "%u": return x.getDay() + 1; case "z": return x.getOrdinalNumber(); case "%j": return p(x.getOrdinalNumber(), 3); case "%U": var d1 = x.clone().set({month: 0, day: 1}).addDays(-1).moveToDayOfWeek(0), d2 = x.clone().addDays(1).moveToDayOfWeek(0, -1); return (d2 < d1) ? "00" : p((d2.getOrdinalNumber() - d1.getOrdinalNumber()) / 7 + 1); case "%W": return p(x.getWeek()); case "t": return $D.getDaysInMonth(x.getFullYear(), x.getMonth()); case "o": case "%G": return x.setWeek(x.getISOWeek()).toString("yyyy"); case "%g": return x._format("%G").slice(-2); case "a": case "%p": return t("tt").toLowerCase(); case "A": return t("tt").toUpperCase(); case "u": return p(x.getMilliseconds(), 3); case "I": return (x.isDaylightSavingTime()) ? 1 : 0; case "O": return x.getUTCOffset(); case "P": y = x.getUTCOffset(); return y.substring(0, y.length - 2) + ":" + y.substring(y.length - 2); case "B": var now = new Date(); return Math.floor(((now.getHours() * 3600) + (now.getMinutes() * 60) + now.getSeconds() + (now.getTimezoneOffset() + 60) * 60) / 86.4); case "c": return x.toISOString().replace(/\"/g, ""); case "U": return $D.strtotime("now"); case "%c": return t("d") + " " + t("t"); case "%C": return Math.floor(x.getFullYear() / 100 + 1); } }, shouldOverrideDefaults: function (m) { switch (m) { case "%e": return true; default: return false; } }, parse: function (m, context) { var formatString, c = context || new Date(); formatString = normalizer.substitutes(m); if (formatString) { return formatString; } formatString = normalizer.interpreted(m, c); if (formatString) { return formatString; } else { return m; } } }; $D.normalizeFormat = function (format, context) { return format.replace(/(%|\\)?.|%%/g, function(t){ return normalizer.parse(t, context); }); }; /** * Format a local Unix timestamp according to locale settings * * Example: * Date.strftime("%m/%d/%y", new Date()); // "04/13/08" * Date.strftime("c", "2008-04-13T17:52:03Z"); // "04/13/08" * * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @param {Number|String} The number representing the number of seconds that have elapsed since January 1, 1970 (local time). * @return {String} A string representation of the current Date object. */ $D.strftime = function (format, time) { var d = Date.parse(time); return d._format(format); }; /** * Parse any textual datetime description into a Unix timestamp. * A Unix timestamp is the number of seconds that have elapsed since January 1, 1970 (midnight UTC/GMT). * * Example: * Date.strtotime("04/13/08"); // 1208044800 * Date.strtotime("1970-01-01T00:00:00Z"); // 0 * * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @param {Object} A string or date object. * @return {String} A string representation of the current Date object. */ $D.strtotime = function (time) { var d = $D.parse(time); return Math.round($D.UTC(d.getUTCFullYear(), d.getUTCMonth(), d.getUTCDate(), d.getUTCHours(), d.getUTCMinutes(), d.getUTCSeconds(), d.getUTCMilliseconds()) / 1000); }; /** * Converts the value of the current Date object to its equivalent string representation using a PHP/Unix style of date format specifiers. * Format Specifiers * Format Description Example * ------ --------------------------------------------------------------------------- ----------------------- * %a abbreviated weekday name according to the current localed "Mon" through "Sun" * %A full weekday name according to the current localed "Sunday" through "Saturday" * %b abbreviated month name according to the current localed "Jan" through "Dec" * %B full month name according to the current locale "January" through "December" * %c preferred date and time representation for the current locale "4/13/2008 12:33 PM" * %C century number (the year divided by 100 and truncated to an integer) "00" to "99" * %d day of the month as a decimal number "01" to "31" * %D same as %m/%d/%y "04/13/08" * %e day of the month as a decimal number, a single digit is preceded by a space "1" to "31" * %g like %G, but without the century "08" * %G The 4-digit year corresponding to the ISO week number (see %V). "2008" * This has the same format and value as %Y, except that if the ISO week number * belongs to the previous or next year, that year is used instead. * %h same as %b "Jan" through "Dec" * %H hour as a decimal number using a 24-hour clock. "00" to "23" * %I hour as a decimal number using a 12-hour clock. "01" to "12" * %j day of the year as a decimal number. "001" to "366" * %m month as a decimal number. "01" to "12" * %M minute as a decimal number. "00" to "59" * %n newline character "\n" * %p either "am" or "pm" according to the given time value, or the "am" or "pm" * corresponding strings for the current locale. * %r time in a.m. and p.m. notation "8:44 PM" * %R time in 24 hour notation "20:44" * %S second as a decimal number "00" to "59" * %t tab character "\t" * %T current time, equal to %H:%M:%S "12:49:11" * %u weekday as a decimal number ["1", "7"], with "1" representing Monday "1" to "7" * %U week number of the current year as a decimal number, starting with the "0" to ("52" or "53") * first Sunday as the first day of the first week * %V The ISO 8601:1988 week number of the current year as a decimal number, "00" to ("52" or "53") * range 01 to 53, where week 1 is the first week that has at least 4 days * in the current year, and with Monday as the first day of the week. * (Use %G or %g for the year component that corresponds to the week number * for the specified timestamp.) * %W week number of the current year as a decimal number, starting with the "00" to ("52" or "53") * first Monday as the first day of the first week * %w day of the week as a decimal, Sunday being "0" "0" to "6" * %x preferred date representation for the current locale without the time "4/13/2008" * %X preferred time representation for the current locale without the date "12:53:05" * %y year as a decimal number without a century "00" "99" * %Y year as a decimal number including the century "2008" * %Z time zone or name or abbreviation "UTC", "EST", "PST" * %z same as %Z * %% a literal "%" characters "%" * d Day of the month, 2 digits with leading zeros "01" to "31" * D A textual representation of a day, three letters "Mon" through "Sun" * j Day of the month without leading zeros "1" to "31" * l A full textual representation of the day of the week (lowercase "L") "Sunday" through "Saturday" * N ISO-8601 numeric representation of the day of the week (added in PHP 5.1.0) "1" (for Monday) through "7" (for Sunday) * S English ordinal suffix for the day of the month, 2 characters "st", "nd", "rd" or "th". Works well with j * w Numeric representation of the day of the week "0" (for Sunday) through "6" (for Saturday) * z The day of the year (starting from "0") "0" through "365" * W ISO-8601 week number of year, weeks starting on Monday "00" to ("52" or "53") * F A full textual representation of a month, such as January or March "January" through "December" * m Numeric representation of a month, with leading zeros "01" through "12" * M A short textual representation of a month, three letters "Jan" through "Dec" * n Numeric representation of a month, without leading zeros "1" through "12" * t Number of days in the given month "28" through "31" * L Whether it's a leap year "1" if it is a leap year, "0" otherwise * o ISO-8601 year number. This has the same value as Y, except that if the "2008" * ISO week number (W) belongs to the previous or next year, that year * is used instead. * Y A full numeric representation of a year, 4 digits "2008" * y A two digit representation of a year "08" * a Lowercase Ante meridiem and Post meridiem "am" or "pm" * A Uppercase Ante meridiem and Post meridiem "AM" or "PM" * B Swatch Internet time "000" through "999" * g 12-hour format of an hour without leading zeros "1" through "12" * G 24-hour format of an hour without leading zeros "0" through "23" * h 12-hour format of an hour with leading zeros "01" through "12" * H 24-hour format of an hour with leading zeros "00" through "23" * i Minutes with leading zeros "00" to "59" * s Seconds, with leading zeros "00" through "59" * u Milliseconds "54321" * e Timezone identifier "UTC", "EST", "PST" * I Whether or not the date is in daylight saving time (uppercase i) "1" if Daylight Saving Time, "0" otherwise * O Difference to Greenwich time (GMT) in hours "+0200", "-0600" * P Difference to Greenwich time (GMT) with colon between hours and minutes "+02:00", "-06:00" * T Timezone abbreviation "UTC", "EST", "PST" * Z Timezone offset in seconds. The offset for timezones west of UTC is "-43200" through "50400" * always negative, and for those east of UTC is always positive. * c ISO 8601 date "2004-02-12T15:19:21+00:00" * r RFC 2822 formatted date "Thu, 21 Dec 2000 16:01:07 +0200" * U Seconds since the Unix Epoch (January 1 1970 00:00:00 GMT) "0" * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @return {String} A string representation of the current Date object. */ var formatReplace = function (context) { return function (m) { var formatString, override = false; if (m.charAt(0) === "\\" || m.substring(0, 2) === "%%") { return m.replace("\\", "").replace("%%", "%"); } override = normalizer.shouldOverrideDefaults(m); formatString = $D.normalizeFormat(m, context); if (formatString) { return context.toString(formatString, override); } }; }; $P._format = function (format) { var formatter = formatReplace(this); if (!format) { return this._toString(); } else { return format.replace(/(%|\\)?.|%%/g, formatter); } }; if (!$P.format) { $P.format = $P._format; } }()); (function () { "use strict"; var gFn = function (attr) { return function () { return this[attr]; }; }; var sFn = function (attr) { return function (val) { this[attr] = val; return this; }; }; var attrs = ["years", "months", "days", "hours", "minutes", "seconds", "milliseconds"]; var addSetFuncs = function (context, attrs) { for (var i = 0; i < attrs.length ; i++) { var $a = attrs[i], $b = $a.slice(0, 1).toUpperCase() + $a.slice(1); context.prototype[$a] = 0; context.prototype["get" + $b] = gFn($a); context.prototype["set" + $b] = sFn($a); } }; /** * new TimeSpan(milliseconds); * new TimeSpan(days, hours, minutes, seconds); * new TimeSpan(days, hours, minutes, seconds, milliseconds); */ var TimeSpan = function (days, hours, minutes, seconds, milliseconds) { if (arguments.length === 1 && typeof days === "number") { var orient = (days < 0) ? -1 : +1; var millsLeft = Math.abs(days); this.setDays(Math.floor(millsLeft / 86400000) * orient); millsLeft = millsLeft % 86400000; this.setHours(Math.floor(millsLeft / 3600000) * orient); millsLeft = millsLeft % 3600000; this.setMinutes(Math.floor(millsLeft / 60000) * orient); millsLeft = millsLeft % 60000; this.setSeconds(Math.floor(millsLeft / 1000) * orient); millsLeft = millsLeft % 1000; this.setMilliseconds(millsLeft * orient); } else { this.set(days, hours, minutes, seconds, milliseconds); } this.getTotalMilliseconds = function () { return (this.getDays() * 86400000) + (this.getHours() * 3600000) + (this.getMinutes() * 60000) + (this.getSeconds() * 1000); }; this.compareTo = function (time) { var t1 = new Date(1970, 1, 1, this.getHours(), this.getMinutes(), this.getSeconds()), t2; if (time === null) { t2 = new Date(1970, 1, 1, 0, 0, 0); } else { t2 = new Date(1970, 1, 1, time.getHours(), time.getMinutes(), time.getSeconds()); } return (t1 < t2) ? -1 : (t1 > t2) ? 1 : 0; }; this.equals = function (time) { return (this.compareTo(time) === 0); }; this.add = function (time) { return (time === null) ? this : this.addSeconds(time.getTotalMilliseconds() / 1000); }; this.subtract = function (time) { return (time === null) ? this : this.addSeconds(-time.getTotalMilliseconds() / 1000); }; this.addDays = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 86400000)); }; this.addHours = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 3600000)); }; this.addMinutes = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 60000)); }; this.addSeconds = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 1000)); }; this.addMilliseconds = function (n) { return new TimeSpan(this.getTotalMilliseconds() + n); }; this.get12HourHour = function () { return (this.getHours() > 12) ? this.getHours() - 12 : (this.getHours() === 0) ? 12 : this.getHours(); }; this.getDesignator = function () { return (this.getHours() < 12) ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator; }; this.toString = function (format) { this._toString = function () { if (this.getDays() !== null && this.getDays() > 0) { return this.getDays() + "." + this.getHours() + ":" + this.p(this.getMinutes()) + ":" + this.p(this.getSeconds()); } else { return this.getHours() + ":" + this.p(this.getMinutes()) + ":" + this.p(this.getSeconds()); } }; this.p = function (s) { return (s.toString().length < 2) ? "0" + s : s; }; var me = this; return format ? format.replace(/dd?|HH?|hh?|mm?|ss?|tt?/g, function (format) { switch (format) { case "d": return me.getDays(); case "dd": return me.p(me.getDays()); case "H": return me.getHours(); case "HH": return me.p(me.getHours()); case "h": return me.get12HourHour(); case "hh": return me.p(me.get12HourHour()); case "m": return me.getMinutes(); case "mm": return me.p(me.getMinutes()); case "s": return me.getSeconds(); case "ss": return me.p(me.getSeconds()); case "t": return ((me.getHours() < 12) ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator).substring(0, 1); case "tt": return (me.getHours() < 12) ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator; } } ) : this._toString(); }; return this; }; addSetFuncs(TimeSpan, attrs.slice(2)); TimeSpan.prototype.set = function (days, hours, minutes, seconds, milliseconds){ this.setDays(days || this.getDays()); this.setHours(hours || this.getHours()); this.setMinutes(minutes || this.getMinutes()); this.setSeconds(seconds || this.getSeconds()); this.setMilliseconds(milliseconds || this.getMilliseconds()); }; /** * Gets the time of day for this date instances. * @return {TimeSpan} TimeSpan */ Date.prototype.getTimeOfDay = function () { return new TimeSpan(0, this.getHours(), this.getMinutes(), this.getSeconds(), this.getMilliseconds()); }; Date.TimeSpan = TimeSpan; if (typeof window !== "undefined" ) { // keeping API compatible for v1.x window.TimeSpan = TimeSpan; } }()); (function () { "use strict"; var attrs = ["years", "months", "days", "hours", "minutes", "seconds", "milliseconds"]; var gFn = function (attr) { return function () { return this[attr]; }; }; var sFn = function (attr) { return function (val) { this[attr] = val; return this; }; }; var addSetFuncs = function (context, attrs) { for (var i = 0; i < attrs.length ; i++) { var $a = attrs[i], $b = $a.slice(0, 1).toUpperCase() + $a.slice(1); context.prototype[$a] = 0; context.prototype["get" + $b] = gFn($a); context.prototype["set" + $b] = sFn($a); } }; var setMonthsAndYears = function (orient, d1, d2, context) { function inc() { d1.addMonths(-orient); context.months++; if (context.months === 12) { context.years++; context.months = 0; } } if (orient === +1) { while (d1 > d2) { inc(); } } else { while (d1 < d2) { inc(); } } context.months--; context.months *= orient; context.years *= orient; }; var adjustForDST = function(orient, startDate, endDate) { var hasDSTMismatch = (false === (startDate.isDaylightSavingTime() === endDate.isDaylightSavingTime())); if (hasDSTMismatch && orient === 1) { startDate.addHours(-1); } else if (hasDSTMismatch) { startDate.addHours(1); } }; /** * TimePeriod(startDate, endDate); * TimePeriod(years, months, days, hours, minutes, seconds, milliseconds); */ var TimePeriod = function (years, months, days, hours, minutes, seconds, milliseconds) { if (arguments.length === 7) { this.set(years, months, days, hours, minutes, seconds, milliseconds); } else if (arguments.length === 2 && arguments[0] instanceof Date && arguments[1] instanceof Date) { var startDate = arguments[0].clone(); var endDate = arguments[1].clone(); var orient = (startDate > endDate) ? +1 : -1; this.dates = { start: arguments[0].clone(), end: arguments[1].clone() }; setMonthsAndYears(orient, startDate, endDate, this); adjustForDST(orient, startDate, endDate); // // TODO - adjust for DST var diff = endDate - startDate; if (diff !== 0) { var ts = new TimeSpan(diff); this.set(this.years, this.months, ts.getDays(), ts.getHours(), ts.getMinutes(), ts.getSeconds(), ts.getMilliseconds()); } } return this; }; // create all the set functions. addSetFuncs(TimePeriod, attrs); TimePeriod.prototype.set = function (years, months, days, hours, minutes, seconds, milliseconds){ this.setYears(years || this.getYears()); this.setMonths(months || this.getMonths()); this.setDays(days || this.getDays()); this.setHours(hours || this.getHours()); this.setMinutes(minutes || this.getMinutes()); this.setSeconds(seconds || this.getSeconds()); this.setMilliseconds(milliseconds || this.getMilliseconds()); }; Date.TimePeriod = TimePeriod; if (typeof window !== "undefined") { // keeping API compatible for v1.x window.TimePeriod = TimePeriod; } }()); ================================================ FILE: build/date-sr-Latn-CS.js ================================================ /** * @overview datejs * @version 1.0.0-rc3 * @author Gregory Wild-Smith * @copyright 2015 Gregory Wild-Smith * @license MIT * @homepage https://github.com/abritinthebay/datejs */ /* * DateJS Culture String File * Country Code: sr-Latn-CS * Name: Serbian (Latin, Serbia) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["sr-Latn-CS"] = { "name": "sr-Latn-CS", "englishName": "Serbian (Latin, Serbia)", "nativeName": "srpski (Srbija)", "Sunday": "nedelja", "Monday": "ponedeljak", "Tuesday": "utorak", "Wednesday": "sreda", "Thursday": "četvrtak", "Friday": "petak", "Saturday": "subota", "Sun": "ned", "Mon": "pon", "Tue": "uto", "Wed": "sre", "Thu": "čet", "Fri": "pet", "Sat": "sub", "Su": "ne", "Mo": "po", "Tu": "ut", "We": "sr", "Th": "če", "Fr": "pe", "Sa": "su", "S_Sun_Initial": "n", "M_Mon_Initial": "p", "T_Tue_Initial": "u", "W_Wed_Initial": "s", "T_Thu_Initial": "č", "F_Fri_Initial": "p", "S_Sat_Initial": "s", "January": "januar", "February": "februar", "March": "mart", "April": "april", "May": "maj", "June": "jun", "July": "jul", "August": "avgust", "September": "septembar", "October": "oktobar", "November": "novembar", "December": "decembar", "Jan_Abbr": "jan", "Feb_Abbr": "feb", "Mar_Abbr": "mar", "Apr_Abbr": "apr", "May_Abbr": "maj", "Jun_Abbr": "jun", "Jul_Abbr": "jul", "Aug_Abbr": "avg", "Sep_Abbr": "sep", "Oct_Abbr": "okt", "Nov_Abbr": "nov", "Dec_Abbr": "dec", "AM": "", "PM": "", "firstDayOfWeek": 1, "twoDigitYearMax": 2029, "mdy": "dmy", "M/d/yyyy": "d.M.yyyy", "dddd, MMMM dd, yyyy": "d. MMMM yyyy", "h:mm tt": "H:mm", "h:mm:ss tt": "H:mm:ss", "dddd, MMMM dd, yyyy h:mm:ss tt": "d. MMMM yyyy H:mm:ss", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "d. MMMM", "MMMM, yyyy": "MMMM yyyy", "/jan(uary)?/": "jan(uar)?", "/feb(ruary)?/": "feb(ruar)?", "/mar(ch)?/": "mar(t)?", "/apr(il)?/": "apr(il)?", "/may/": "maj", "/jun(e)?/": "jun", "/jul(y)?/": "jul", "/aug(ust)?/": "avg(ust)?", "/sep(t(ember)?)?/": "sep(tembar)?", "/oct(ober)?/": "okt(obar)?", "/nov(ember)?/": "nov(embar)?", "/dec(ember)?/": "dec(embar)?", "/^su(n(day)?)?/": "^ne(d(elja)?)?", "/^mo(n(day)?)?/": "^po(n(edeljak)?)?", "/^tu(e(s(day)?)?)?/": "^ut(o(rak)?)?", "/^we(d(nesday)?)?/": "^sr(e(da)?)?", "/^th(u(r(s(day)?)?)?)?/": "^če(t(vrtak)?)?", "/^fr(i(day)?)?/": "^pe(t(ak)?)?", "/^sa(t(urday)?)?/": "^su(b(ota)?)?", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "sr-Latn-CS"; /** * @overview datejs * @version 1.0.0-rc3 * @author Gregory Wild-Smith * @copyright 2015 Gregory Wild-Smith * @license MIT * @homepage https://github.com/abritinthebay/datejs */(function () { var $D = Date; var lang = Date.CultureStrings ? Date.CultureStrings.lang : null; var loggedKeys = {}; // for debug purposes. var getText = { getFromKey: function (key, countryCode) { var output; if (Date.CultureStrings && Date.CultureStrings[countryCode] && Date.CultureStrings[countryCode][key]) { output = Date.CultureStrings[countryCode][key]; } else { output = getText.buildFromDefault(key); } if (key.charAt(0) === "/") { // Assume it's a regex output = getText.buildFromRegex(key, countryCode); } return output; }, getFromObjectValues: function (obj, countryCode) { var key, output = {}; for(key in obj) { if (obj.hasOwnProperty(key)) { output[key] = getText.getFromKey(obj[key], countryCode); } } return output; }, getFromObjectKeys: function (obj, countryCode) { var key, output = {}; for(key in obj) { if (obj.hasOwnProperty(key)) { output[getText.getFromKey(key, countryCode)] = obj[key]; } } return output; }, getFromArray: function (arr, countryCode) { var output = []; for (var i=0; i < arr.length; i++){ if (i in arr) { output[i] = getText.getFromKey(arr[i], countryCode); } } return output; }, buildFromDefault: function (key) { var output, length, split, last; switch(key) { case "name": output = "en-US"; break; case "englishName": output = "English (United States)"; break; case "nativeName": output = "English (United States)"; break; case "twoDigitYearMax": output = 2049; break; case "firstDayOfWeek": output = 0; break; default: output = key; split = key.split("_"); length = split.length; if (length > 1 && key.charAt(0) !== "/") { // if the key isn't a regex and it has a split. last = split[(length - 1)].toLowerCase(); if (last === "initial" || last === "abbr") { output = split[0]; } } break; } return output; }, buildFromRegex: function (key, countryCode) { var output; if (Date.CultureStrings && Date.CultureStrings[countryCode] && Date.CultureStrings[countryCode][key]) { output = new RegExp(Date.CultureStrings[countryCode][key], "i"); } else { output = new RegExp(key.replace(new RegExp("/", "g"),""), "i"); } return output; } }; var shallowMerge = function (obj1, obj2) { for (var attrname in obj2) { if (obj2.hasOwnProperty(attrname)) { obj1[attrname] = obj2[attrname]; } } }; var __ = function (key, language) { var countryCode = (language) ? language : lang; loggedKeys[key] = key; if (typeof key === "object") { if (key instanceof Array) { return getText.getFromArray(key, countryCode); } else { return getText.getFromObjectKeys(key, countryCode); } } else { return getText.getFromKey(key, countryCode); } }; var loadI18nScript = function (code) { // paatterned after jQuery's getScript. var url = Date.Config.i18n + code + ".js"; var head = document.getElementsByTagName("head")[0] || document.documentElement; var script = document.createElement("script"); script.src = url; var completed = false; var events = { done: function (){} // placeholder function }; // Attach handlers for all browsers script.onload = script.onreadystatechange = function() { if ( !completed && (!this.readyState || this.readyState === "loaded" || this.readyState === "complete") ) { events.done(); head.removeChild(script); } }; setTimeout(function() { head.insertBefore(script, head.firstChild); }, 0); // allows return to execute first return { done: function (cb) { events.done = function() { if (cb) { setTimeout(cb,0); } }; } }; }; var buildInfo = { buildFromMethodHash: function (obj) { var key; for(key in obj) { if (obj.hasOwnProperty(key)) { obj[key] = buildInfo[obj[key]](); } } return obj; }, timeZoneDST: function () { var DST = { "CHADT": "+1345", "NZDT": "+1300", "AEDT": "+1100", "ACDT": "+1030", "AZST": "+0500", "IRDT": "+0430", "EEST": "+0300", "CEST": "+0200", "BST": "+0100", "PMDT": "-0200", "ADT": "-0300", "NDT": "-0230", "EDT": "-0400", "CDT": "-0500", "MDT": "-0600", "PDT": "-0700", "AKDT": "-0800", "HADT": "-0900" }; return __(DST); }, timeZoneStandard: function () { var standard = { "LINT": "+1400", "TOT": "+1300", "CHAST": "+1245", "NZST": "+1200", "NFT": "+1130", "SBT": "+1100", "AEST": "+1000", "ACST": "+0930", "JST": "+0900", "CWST": "+0845", "CT": "+0800", "ICT": "+0700", "MMT": "+0630", "BST": "+0600", "NPT": "+0545", "IST": "+0530", "PKT": "+0500", "AFT": "+0430", "MSK": "+0400", "IRST": "+0330", "FET": "+0300", "EET": "+0200", "CET": "+0100", "GMT": "+0000", "UTC": "+0000", "CVT": "-0100", "GST": "-0200", "BRT": "-0300", "NST": "-0330", "AST": "-0400", "EST": "-0500", "CST": "-0600", "MST": "-0700", "PST": "-0800", "AKST": "-0900", "MIT": "-0930", "HST": "-1000", "SST": "-1100", "BIT": "-1200" }; return __(standard); }, timeZones: function (data) { var zone; data.timezones = []; for (zone in data.abbreviatedTimeZoneStandard) { if (data.abbreviatedTimeZoneStandard.hasOwnProperty(zone)) { data.timezones.push({ name: zone, offset: data.abbreviatedTimeZoneStandard[zone]}); } } for (zone in data.abbreviatedTimeZoneDST) { if (data.abbreviatedTimeZoneDST.hasOwnProperty(zone)) { data.timezones.push({ name: zone, offset: data.abbreviatedTimeZoneDST[zone], dst: true}); } } return data.timezones; }, days: function () { return __(["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"]); }, dayAbbr: function () { return __(["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"]); }, dayShortNames: function () { return __(["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"]); }, dayFirstLetters: function () { return __(["S_Sun_Initial", "M_Mon_Initial", "T_Tues_Initial", "W_Wed_Initial", "T_Thu_Initial", "F_Fri_Initial", "S_Sat_Initial"]); }, months: function () { return __(["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"]); }, monthAbbr: function () { return __(["Jan_Abbr", "Feb_Abbr", "Mar_Abbr", "Apr_Abbr", "May_Abbr", "Jun_Abbr", "Jul_Abbr", "Aug_Abbr", "Sep_Abbr", "Oct_Abbr", "Nov_Abbr", "Dec_Abbr"]); }, formatPatterns: function () { return getText.getFromObjectValues({ shortDate: "M/d/yyyy", longDate: "dddd, MMMM dd, yyyy", shortTime: "h:mm tt", longTime: "h:mm:ss tt", fullDateTime: "dddd, MMMM dd, yyyy h:mm:ss tt", sortableDateTime: "yyyy-MM-ddTHH:mm:ss", universalSortableDateTime: "yyyy-MM-dd HH:mm:ssZ", rfc1123: "ddd, dd MMM yyyy HH:mm:ss", monthDay: "MMMM dd", yearMonth: "MMMM, yyyy" }, Date.i18n.currentLanguage()); }, regex: function () { return getText.getFromObjectValues({ inTheMorning: "/( in the )(morn(ing)?)\\b/", thisMorning: "/(this )(morn(ing)?)\\b/", amThisMorning: "/(\b\\d(am)? )(this )(morn(ing)?)/", inTheEvening: "/( in the )(even(ing)?)\\b/", thisEvening: "/(this )(even(ing)?)\\b/", pmThisEvening: "/(\b\\d(pm)? )(this )(even(ing)?)/", jan: "/jan(uary)?/", feb: "/feb(ruary)?/", mar: "/mar(ch)?/", apr: "/apr(il)?/", may: "/may/", jun: "/jun(e)?/", jul: "/jul(y)?/", aug: "/aug(ust)?/", sep: "/sep(t(ember)?)?/", oct: "/oct(ober)?/", nov: "/nov(ember)?/", dec: "/dec(ember)?/", sun: "/^su(n(day)?)?/", mon: "/^mo(n(day)?)?/", tue: "/^tu(e(s(day)?)?)?/", wed: "/^we(d(nesday)?)?/", thu: "/^th(u(r(s(day)?)?)?)?/", fri: "/fr(i(day)?)?/", sat: "/^sa(t(urday)?)?/", future: "/^next/", past: "/^last|past|prev(ious)?/", add: "/^(\\+|aft(er)?|from|hence)/", subtract: "/^(\\-|bef(ore)?|ago)/", yesterday: "/^yes(terday)?/", today: "/^t(od(ay)?)?/", tomorrow: "/^tom(orrow)?/", now: "/^n(ow)?/", millisecond: "/^ms|milli(second)?s?/", second: "/^sec(ond)?s?/", minute: "/^mn|min(ute)?s?/", hour: "/^h(our)?s?/", week: "/^w(eek)?s?/", month: "/^m(onth)?s?/", day: "/^d(ay)?s?/", year: "/^y(ear)?s?/", shortMeridian: "/^(a|p)/", longMeridian: "/^(a\\.?m?\\.?|p\\.?m?\\.?)/", timezone: "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/", ordinalSuffix: "/^\\s*(st|nd|rd|th)/", timeContext: "/^\\s*(\\:|a(?!u|p)|p)/" }, Date.i18n.currentLanguage()); } }; var CultureInfo = function () { var info = getText.getFromObjectValues({ name: "name", englishName: "englishName", nativeName: "nativeName", amDesignator: "AM", pmDesignator: "PM", firstDayOfWeek: "firstDayOfWeek", twoDigitYearMax: "twoDigitYearMax", dateElementOrder: "mdy" }, Date.i18n.currentLanguage()); var constructedInfo = buildInfo.buildFromMethodHash({ dayNames: "days", abbreviatedDayNames: "dayAbbr", shortestDayNames: "dayShortNames", firstLetterDayNames: "dayFirstLetters", monthNames: "months", abbreviatedMonthNames: "monthAbbr", formatPatterns: "formatPatterns", regexPatterns: "regex", abbreviatedTimeZoneDST: "timeZoneDST", abbreviatedTimeZoneStandard: "timeZoneStandard" }); shallowMerge(info, constructedInfo); buildInfo.timeZones(info); return info; }; $D.i18n = { __: function (key, lang) { return __(key, lang); }, currentLanguage: function () { return lang || "en-US"; }, setLanguage: function (code, force, cb) { var async = false; if (force || code === "en-US" || (!!Date.CultureStrings && !!Date.CultureStrings[code])) { lang = code; Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings.lang = code; Date.CultureInfo = new CultureInfo(); } else { if (!(!!Date.CultureStrings && !!Date.CultureStrings[code])) { if (typeof exports !== "undefined" && this.exports !== exports) { // we're in a Node enviroment, load it using require try { require("../i18n/" + code + ".js"); lang = code; Date.CultureStrings.lang = code; Date.CultureInfo = new CultureInfo(); } catch (e) { // var str = "The language for '" + code + "' could not be loaded by Node. It likely does not exist."; throw new Error("The DateJS IETF language tag '" + code + "' could not be loaded by Node. It likely does not exist."); } } else if (Date.Config && Date.Config.i18n) { // we know the location of the files, so lets load them async = true; loadI18nScript(code).done(function(){ lang = code; Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings.lang = code; Date.CultureInfo = new CultureInfo(); $D.Parsing.Normalizer.buildReplaceData(); // because this is async if ($D.Grammar) { $D.Grammar.buildGrammarFormats(); // so we can parse those strings... } if (cb) { setTimeout(cb,0); } }); } else { Date.console.error("The DateJS IETF language tag '" + code + "' is not available and has not been loaded."); return false; } } } $D.Parsing.Normalizer.buildReplaceData(); // rebuild normalizer strings if ($D.Grammar) { $D.Grammar.buildGrammarFormats(); // so we can parse those strings... } if (!async && cb) { setTimeout(cb,0); } }, getLoggedKeys: function () { return loggedKeys; }, updateCultureInfo: function () { Date.CultureInfo = new CultureInfo(); } }; $D.i18n.updateCultureInfo(); // run automatically }()); (function () { var $D = Date, $P = $D.prototype, p = function (s, l) { if (!l) { l = 2; } return ("000" + s).slice(l * -1); }; if (typeof window !== "undefined" && typeof window.console !== "undefined" && typeof window.console.log !== "undefined") { $D.console = console; // used only to raise non-critical errors if available } else { // set mock so we don't give errors. $D.console = { log: function(){}, error: function(){} }; } $D.Config = $D.Config || {}; $D.initOverloads = function() { /** * Overload of Date.now. Allows an alternate call for Date.now where it returns the * current Date as an object rather than just milliseconds since the Unix Epoch. * * Also provides an implementation of now() for browsers (IE<9) that don't have it. * * Backwards compatible so with work with either: * Date.now() [returns ms] * or * Date.now(true) [returns Date] */ if (!$D.now) { $D._now = function now() { return new Date().getTime(); }; } else if (!$D._now) { $D._now = $D.now; } $D.now = function (returnObj) { if (returnObj) { return $D.present(); } else { return $D._now(); } }; if ( !$P.toISOString ) { $P.toISOString = function() { return this.getUTCFullYear() + "-" + p(this.getUTCMonth() + 1) + "-" + p(this.getUTCDate()) + "T" + p(this.getUTCHours()) + ":" + p(this.getUTCMinutes()) + ":" + p(this.getUTCSeconds()) + "." + String( (this.getUTCMilliseconds()/1000).toFixed(3)).slice(2, 5) + "Z"; }; } // private if ( $P._toString === undefined ){ $P._toString = $P.toString; } }; $D.initOverloads(); /** * Gets a date that is set to the current date. The time is set to the start of the day (00:00 or 12:00 AM). * @return {Date} The current date. */ $D.today = function () { return new Date().clearTime(); }; /** * Gets a date that is set to the current date and time (same as new Date, but chainable) * @return {Date} The current date. */ $D.present = function () { return new Date(); }; /** * Compares the first date to the second date and returns an number indication of their relative values. * @param {Date} First Date object to compare [Required]. * @param {Date} Second Date object to compare to [Required]. * @return {Number} -1 = date1 is lessthan date2. 0 = values are equal. 1 = date1 is greaterthan date2. */ $D.compare = function (date1, date2) { if (isNaN(date1) || isNaN(date2)) { throw new Error(date1 + " - " + date2); } else if (date1 instanceof Date && date2 instanceof Date) { return (date1 < date2) ? -1 : (date1 > date2) ? 1 : 0; } else { throw new TypeError(date1 + " - " + date2); } }; /** * Compares the first Date object to the second Date object and returns true if they are equal. * @param {Date} First Date object to compare [Required] * @param {Date} Second Date object to compare to [Required] * @return {Boolean} true if dates are equal. false if they are not equal. */ $D.equals = function (date1, date2) { return (date1.compareTo(date2) === 0); }; /** * Gets the language appropriate day name when given the day number(0-6) * eg - 0 == Sunday * @return {String} The day name */ $D.getDayName = function (n) { return Date.CultureInfo.dayNames[n]; }; /** * Gets the day number (0-6) if given a CultureInfo specific string which is a valid dayName, abbreviatedDayName or shortestDayName (two char). * @param {String} The name of the day (eg. "Monday, "Mon", "tuesday", "tue", "We", "we"). * @return {Number} The day number */ $D.getDayNumberFromName = function (name) { var n = Date.CultureInfo.dayNames, m = Date.CultureInfo.abbreviatedDayNames, o = Date.CultureInfo.shortestDayNames, s = name.toLowerCase(); for (var i = 0; i < n.length; i++) { if (n[i].toLowerCase() === s || m[i].toLowerCase() === s || o[i].toLowerCase() === s) { return i; } } return -1; }; /** * Gets the month number (0-11) if given a Culture Info specific string which is a valid monthName or abbreviatedMonthName. * @param {String} The name of the month (eg. "February, "Feb", "october", "oct"). * @return {Number} The day number */ $D.getMonthNumberFromName = function (name) { var n = Date.CultureInfo.monthNames, m = Date.CultureInfo.abbreviatedMonthNames, s = name.toLowerCase(); for (var i = 0; i < n.length; i++) { if (n[i].toLowerCase() === s || m[i].toLowerCase() === s) { return i; } } return -1; }; /** * Gets the language appropriate month name when given the month number(0-11) * eg - 0 == January * @return {String} The month name */ $D.getMonthName = function (n) { return Date.CultureInfo.monthNames[n]; }; /** * Determines if the current date instance is within a LeapYear. * @param {Number} The year. * @return {Boolean} true if date is within a LeapYear, otherwise false. */ $D.isLeapYear = function (year) { return ((year % 4 === 0 && year % 100 !== 0) || year % 400 === 0); }; /** * Gets the number of days in the month, given a year and month value. Automatically corrects for LeapYear. * @param {Number} The year. * @param {Number} The month (0-11). * @return {Number} The number of days in the month. */ $D.getDaysInMonth = function (year, month) { if (!month && $D.validateMonth(year)) { month = year; year = Date.today().getFullYear(); } return [31, ($D.isLeapYear(year) ? 29 : 28), 31, 30, 31, 30, 31, 31, 30, 31, 30, 31][month]; }; $P.getDaysInMonth = function () { return $D.getDaysInMonth(this.getFullYear(), this.getMonth()); }; $D.getTimezoneAbbreviation = function (offset, dst) { var p, n = (dst || false) ? Date.CultureInfo.abbreviatedTimeZoneDST : Date.CultureInfo.abbreviatedTimeZoneStandard; for (p in n) { if (n.hasOwnProperty(p)) { if (n[p] === offset) { return p; } } } return null; }; $D.getTimezoneOffset = function (name, dst) { var i, a =[], z = Date.CultureInfo.timezones; if (!name) { name = (new Date()).getTimezone();} for (i = 0; i < z.length; i++) { if (z[i].name === name.toUpperCase()) { a.push(i); } } if (!z[a[0]]) { return null; } if (a.length === 1 || !dst) { return z[a[0]].offset; } else { for (i=0; i < a.length; i++) { if (z[a[i]].dst) { return z[a[i]].offset; } } } }; $D.getQuarter = function (d) { d = d || new Date(); // If no date supplied, use today var q = [1,2,3,4]; return q[Math.floor(d.getMonth() / 3)]; // ~~~ is a bitwise op. Faster than Math.floor }; $D.getDaysLeftInQuarter = function (d) { d = d || new Date(); var qEnd = new Date(d); qEnd.setMonth(qEnd.getMonth() + 3 - qEnd.getMonth() % 3, 0); return Math.floor((qEnd - d) / 8.64e7); }; // private var validate = function (n, min, max, name) { name = name ? name : "Object"; if (typeof n === "undefined") { return false; } else if (typeof n !== "number") { throw new TypeError(n + " is not a Number."); } else if (n < min || n > max) { // As failing validation is *not* an exceptional circumstance // lets not throw a RangeError Exception here. // It's semantically correct but it's not sensible. return false; } return true; }; /** * Validates the number is within an acceptable range for milliseconds [0-999]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateMillisecond = function (value) { return validate(value, 0, 999, "millisecond"); }; /** * Validates the number is within an acceptable range for seconds [0-59]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateSecond = function (value) { return validate(value, 0, 59, "second"); }; /** * Validates the number is within an acceptable range for minutes [0-59]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateMinute = function (value) { return validate(value, 0, 59, "minute"); }; /** * Validates the number is within an acceptable range for hours [0-23]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateHour = function (value) { return validate(value, 0, 23, "hour"); }; /** * Validates the number is within an acceptable range for the days in a month [0-MaxDaysInMonth]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateDay = function (value, year, month) { if (year === undefined || year === null || month === undefined || month === null) { return false;} return validate(value, 1, $D.getDaysInMonth(year, month), "day"); }; /** * Validates the number is within an acceptable range for months [0-11]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateWeek = function (value) { return validate(value, 0, 53, "week"); }; /** * Validates the number is within an acceptable range for months [0-11]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateMonth = function (value) { return validate(value, 0, 11, "month"); }; /** * Validates the number is within an acceptable range for years. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateYear = function (value) { /** * Per ECMAScript spec the range of times supported by Date objects is * exactly -100,000,000 days to +100,000,000 days measured relative to * midnight at the beginning of 01 January, 1970 UTC. * This gives a range of 8,640,000,000,000,000 milliseconds to either * side of 01 January, 1970 UTC. * * Earliest possible date: Tue, 20 Apr 271,822 B.C. 00:00:00 UTC * Latest possible date: Sat, 13 Sep 275,760 00:00:00 UTC */ return validate(value, -271822, 275760, "year"); }; $D.validateTimezone = function(value) { var timezones = {"ACDT":1,"ACST":1,"ACT":1,"ADT":1,"AEDT":1,"AEST":1,"AFT":1,"AKDT":1,"AKST":1,"AMST":1,"AMT":1,"ART":1,"AST":1,"AWDT":1,"AWST":1,"AZOST":1,"AZT":1,"BDT":1,"BIOT":1,"BIT":1,"BOT":1,"BRT":1,"BST":1,"BTT":1,"CAT":1,"CCT":1,"CDT":1,"CEDT":1,"CEST":1,"CET":1,"CHADT":1,"CHAST":1,"CHOT":1,"ChST":1,"CHUT":1,"CIST":1,"CIT":1,"CKT":1,"CLST":1,"CLT":1,"COST":1,"COT":1,"CST":1,"CT":1,"CVT":1,"CWST":1,"CXT":1,"DAVT":1,"DDUT":1,"DFT":1,"EASST":1,"EAST":1,"EAT":1,"ECT":1,"EDT":1,"EEDT":1,"EEST":1,"EET":1,"EGST":1,"EGT":1,"EIT":1,"EST":1,"FET":1,"FJT":1,"FKST":1,"FKT":1,"FNT":1,"GALT":1,"GAMT":1,"GET":1,"GFT":1,"GILT":1,"GIT":1,"GMT":1,"GST":1,"GYT":1,"HADT":1,"HAEC":1,"HAST":1,"HKT":1,"HMT":1,"HOVT":1,"HST":1,"ICT":1,"IDT":1,"IOT":1,"IRDT":1,"IRKT":1,"IRST":1,"IST":1,"JST":1,"KGT":1,"KOST":1,"KRAT":1,"KST":1,"LHST":1,"LINT":1,"MAGT":1,"MART":1,"MAWT":1,"MDT":1,"MET":1,"MEST":1,"MHT":1,"MIST":1,"MIT":1,"MMT":1,"MSK":1,"MST":1,"MUT":1,"MVT":1,"MYT":1,"NCT":1,"NDT":1,"NFT":1,"NPT":1,"NST":1,"NT":1,"NUT":1,"NZDT":1,"NZST":1,"OMST":1,"ORAT":1,"PDT":1,"PET":1,"PETT":1,"PGT":1,"PHOT":1,"PHT":1,"PKT":1,"PMDT":1,"PMST":1,"PONT":1,"PST":1,"PYST":1,"PYT":1,"RET":1,"ROTT":1,"SAKT":1,"SAMT":1,"SAST":1,"SBT":1,"SCT":1,"SGT":1,"SLST":1,"SRT":1,"SST":1,"SYOT":1,"TAHT":1,"THA":1,"TFT":1,"TJT":1,"TKT":1,"TLT":1,"TMT":1,"TOT":1,"TVT":1,"UCT":1,"ULAT":1,"UTC":1,"UYST":1,"UYT":1,"UZT":1,"VET":1,"VLAT":1,"VOLT":1,"VOST":1,"VUT":1,"WAKT":1,"WAST":1,"WAT":1,"WEDT":1,"WEST":1,"WET":1,"WST":1,"YAKT":1,"YEKT":1,"Z":1}; return (timezones[value] === 1); }; $D.validateTimezoneOffset= function(value) { // timezones go from +14hrs to -12hrs, the +X hours are negative offsets. return (value > -841 && value < 721); }; }()); (function () { var $D = Date, $P = $D.prototype, p = function (s, l) { if (!l) { l = 2; } return ("000" + s).slice(l * -1); }; var validateConfigObject = function (obj) { var result = {}, self = this, prop, testFunc; testFunc = function (prop, func, value) { if (prop === "day") { var month = (obj.month !== undefined) ? obj.month : self.getMonth(); var year = (obj.year !== undefined) ? obj.year : self.getFullYear(); return $D[func](value, year, month); } else { return $D[func](value); } }; for (prop in obj) { if (Object.prototype.hasOwnProperty.call(obj, prop)) { var func = "validate" + prop.charAt(0).toUpperCase() + prop.slice(1); if ($D[func] && obj[prop] !== null && testFunc(prop, func, obj[prop])) { result[prop] = obj[prop]; } } } return result; }; /** * Resets the time of this Date object to 12:00 AM (00:00), which is the start of the day. * @param {Boolean} .clone() this date instance before clearing Time * @return {Date} this */ $P.clearTime = function () { this.setHours(0); this.setMinutes(0); this.setSeconds(0); this.setMilliseconds(0); return this; }; /** * Resets the time of this Date object to the current time ('now'). * @return {Date} this */ $P.setTimeToNow = function () { var n = new Date(); this.setHours(n.getHours()); this.setMinutes(n.getMinutes()); this.setSeconds(n.getSeconds()); this.setMilliseconds(n.getMilliseconds()); return this; }; /** * Returns a new Date object that is an exact date and time copy of the original instance. * @return {Date} A new Date instance */ $P.clone = function () { return new Date(this.getTime()); }; /** * Compares this instance to a Date object and returns an number indication of their relative values. * @param {Date} Date object to compare [Required] * @return {Number} -1 = this is lessthan date. 0 = values are equal. 1 = this is greaterthan date. */ $P.compareTo = function (date) { return Date.compare(this, date); }; /** * Compares this instance to another Date object and returns true if they are equal. * @param {Date} Date object to compare. If no date to compare, new Date() [now] is used. * @return {Boolean} true if dates are equal. false if they are not equal. */ $P.equals = function (date) { return Date.equals(this, (date !== undefined ? date : new Date())); }; /** * Determines if this instance is between a range of two dates or equal to either the start or end dates. * @param {Date} Start of range [Required] * @param {Date} End of range [Required] * @return {Boolean} true is this is between or equal to the start and end dates, else false */ $P.between = function (start, end) { return this.getTime() >= start.getTime() && this.getTime() <= end.getTime(); }; /** * Determines if this date occurs after the date to compare to. * @param {Date} Date object to compare. If no date to compare, new Date() ("now") is used. * @return {Boolean} true if this date instance is greater than the date to compare to (or "now"), otherwise false. */ $P.isAfter = function (date) { return this.compareTo(date || new Date()) === 1; }; /** * Determines if this date occurs before the date to compare to. * @param {Date} Date object to compare. If no date to compare, new Date() ("now") is used. * @return {Boolean} true if this date instance is less than the date to compare to (or "now"). */ $P.isBefore = function (date) { return (this.compareTo(date || new Date()) === -1); }; /** * Determines if the current Date instance occurs today. * @return {Boolean} true if this date instance is 'today', otherwise false. */ /** * Determines if the current Date instance occurs on the same Date as the supplied 'date'. * If no 'date' to compare to is provided, the current Date instance is compared to 'today'. * @param {date} Date object to compare. If no date to compare, the current Date ("now") is used. * @return {Boolean} true if this Date instance occurs on the same Day as the supplied 'date'. */ $P.isToday = $P.isSameDay = function (date) { return this.clone().clearTime().equals((date || new Date()).clone().clearTime()); }; /** * Adds the specified number of milliseconds to this instance. * @param {Number} The number of milliseconds to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addMilliseconds = function (value) { if (!value) { return this; } this.setTime(this.getTime() + value * 1); return this; }; /** * Adds the specified number of seconds to this instance. * @param {Number} The number of seconds to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addSeconds = function (value) { if (!value) { return this; } return this.addMilliseconds(value * 1000); }; /** * Adds the specified number of seconds to this instance. * @param {Number} The number of seconds to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addMinutes = function (value) { if (!value) { return this; } return this.addMilliseconds(value * 60000); // 60*1000 }; /** * Adds the specified number of hours to this instance. * @param {Number} The number of hours to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addHours = function (value) { if (!value) { return this; } return this.addMilliseconds(value * 3600000); // 60*60*1000 }; /** * Adds the specified number of days to this instance. * @param {Number} The number of days to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addDays = function (value) { if (!value) { return this; } this.setDate(this.getDate() + value * 1); return this; }; /** * Adds the specified number of weekdays (ie - not sat or sun) to this instance. * @param {Number} The number of days to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addWeekdays = function (value) { if (!value) { return this; } var day = this.getDay(); var weeks = (Math.ceil(Math.abs(value)/7)); if (day === 0 || day === 6) { if (value > 0) { this.next().monday(); this.addDays(-1); day = this.getDay(); } } if (value < 0) { while (value < 0) { this.addDays(-1); day = this.getDay(); if (day !== 0 && day !== 6) { value++; } } return this; } else if (value > 5 || (6-day) <= value) { value = value + (weeks * 2); } return this.addDays(value); }; /** * Adds the specified number of weeks to this instance. * @param {Number} The number of weeks to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addWeeks = function (value) { if (!value) { return this; } return this.addDays(value * 7); }; /** * Adds the specified number of months to this instance. * @param {Number} The number of months to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addMonths = function (value) { if (!value) { return this; } var n = this.getDate(); this.setDate(1); this.setMonth(this.getMonth() + value * 1); this.setDate(Math.min(n, $D.getDaysInMonth(this.getFullYear(), this.getMonth()))); return this; }; $P.addQuarters = function (value) { if (!value) { return this; } // note this will take you to the same point in the quarter as you are now. // i.e. - if you are 15 days into the quarter you'll be 15 days into the resulting one. // bonus: this allows adding fractional quarters return this.addMonths(value * 3); }; /** * Adds the specified number of years to this instance. * @param {Number} The number of years to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addYears = function (value) { if (!value) { return this; } return this.addMonths(value * 12); }; /** * Adds (or subtracts) to the value of the years, months, weeks, days, hours, minutes, seconds, milliseconds of the date instance using given configuration object. Positive and Negative values allowed. * Example

	Date.today().add( { days: 1, months: 1 } )

	new Date().add( { years: -1 } )
	
* @param {Object} Configuration object containing attributes (months, days, etc.) * @return {Date} this */ $P.add = function (config) { if (typeof config === "number") { this._orient = config; return this; } var x = config; if (x.day) { // If we should be a different date than today (eg: for 'tomorrow -1d', etc). // Should only effect parsing, not direct usage (eg, Finish and FinishExact) if ((x.day - this.getDate()) !== 0) { this.setDate(x.day); } } if (x.milliseconds) { this.addMilliseconds(x.milliseconds); } if (x.seconds) { this.addSeconds(x.seconds); } if (x.minutes) { this.addMinutes(x.minutes); } if (x.hours) { this.addHours(x.hours); } if (x.weeks) { this.addWeeks(x.weeks); } if (x.months) { this.addMonths(x.months); } if (x.years) { this.addYears(x.years); } if (x.days) { this.addDays(x.days); } return this; }; /** * Get the week number. Week one (1) is the week which contains the first Thursday of the year. Monday is considered the first day of the week. * The .getWeek() function does NOT convert the date to UTC. The local datetime is used. * Please use .getISOWeek() to get the week of the UTC converted date. * @return {Number} 1 to 53 */ $P.getWeek = function (utc) { // Create a copy of this date object var self, target = new Date(this.valueOf()); if (utc) { target.addMinutes(target.getTimezoneOffset()); self = target.clone(); } else { self = this; } // ISO week date weeks start on monday // so correct the day number var dayNr = (self.getDay() + 6) % 7; // ISO 8601 states that week 1 is the week // with the first thursday of that year. // Set the target date to the thursday in the target week target.setDate(target.getDate() - dayNr + 3); // Store the millisecond value of the target date var firstThursday = target.valueOf(); // Set the target to the first thursday of the year // First set the target to january first target.setMonth(0, 1); // Not a thursday? Correct the date to the next thursday if (target.getDay() !== 4) { target.setMonth(0, 1 + ((4 - target.getDay()) + 7) % 7); } // The weeknumber is the number of weeks between the // first thursday of the year and the thursday in the target week return 1 + Math.ceil((firstThursday - target) / 604800000); // 604800000 = 7 * 24 * 3600 * 1000 }; /** * Get the ISO 8601 week number. Week one ("01") is the week which contains the first Thursday of the year. Monday is considered the first day of the week. * The .getISOWeek() function does convert the date to it's UTC value. Please use .getWeek() to get the week of the local date. * @return {String} "01" to "53" */ $P.getISOWeek = function () { return p(this.getWeek(true)); }; /** * Moves the date to Monday of the week set. Week one (1) is the week which contains the first Thursday of the year. * @param {Number} A Number (1 to 53) that represents the week of the year. * @return {Date} this */ $P.setWeek = function (n) { if ((n - this.getWeek()) === 0) { if (this.getDay() !== 1) { return this.moveToDayOfWeek(1, (this.getDay() > 1 ? -1 : 1)); } else { return this; } } else { return this.moveToDayOfWeek(1, (this.getDay() > 1 ? -1 : 1)).addWeeks(n - this.getWeek()); } }; $P.setQuarter = function (qtr) { var month = Math.abs(((qtr-1) * 3) + 1); return this.setMonth(month, 1); }; $P.getQuarter = function () { return Date.getQuarter(this); }; $P.getDaysLeftInQuarter = function () { return Date.getDaysLeftInQuarter(this); }; /** * Moves the date to the next n'th occurrence of the dayOfWeek starting from the beginning of the month. The number (-1) is a magic number and will return the last occurrence of the dayOfWeek in the month. * @param {Number} The dayOfWeek to move to * @param {Number} The n'th occurrence to move to. Use (-1) to return the last occurrence in the month * @return {Date} this */ $P.moveToNthOccurrence = function (dayOfWeek, occurrence) { if (dayOfWeek === "Weekday") { if (occurrence > 0) { this.moveToFirstDayOfMonth(); if (this.is().weekday()) { occurrence -= 1; } } else if (occurrence < 0) { this.moveToLastDayOfMonth(); if (this.is().weekday()) { occurrence += 1; } } else { return this; } return this.addWeekdays(occurrence); } var shift = 0; if (occurrence > 0) { shift = occurrence - 1; } else if (occurrence === -1) { this.moveToLastDayOfMonth(); if (this.getDay() !== dayOfWeek) { this.moveToDayOfWeek(dayOfWeek, -1); } return this; } return this.moveToFirstDayOfMonth().addDays(-1).moveToDayOfWeek(dayOfWeek, +1).addWeeks(shift); }; var moveToN = function (getFunc, addFunc, nVal) { return function (value, orient) { var diff = (value - this[getFunc]() + nVal * (orient || +1)) % nVal; return this[addFunc]((diff === 0) ? diff += nVal * (orient || +1) : diff); }; }; /** * Move to the next or last dayOfWeek based on the orient value. * @param {Number} The dayOfWeek to move to * @param {Number} Forward (+1) or Back (-1). Defaults to +1. [Optional] * @return {Date} this */ $P.moveToDayOfWeek = moveToN("getDay", "addDays", 7); /** * Move to the next or last month based on the orient value. * @param {Number} The month to move to. 0 = January, 11 = December * @param {Number} Forward (+1) or Back (-1). Defaults to +1. [Optional] * @return {Date} this */ $P.moveToMonth = moveToN("getMonth", "addMonths", 12); /** * Get the Ordinate of the current day ("th", "st", "rd"). * @return {String} */ $P.getOrdinate = function () { var num = this.getDate(); return ord(num); }; /** * Get the Ordinal day (numeric day number) of the year, adjusted for leap year. * @return {Number} 1 through 365 (366 in leap years) */ $P.getOrdinalNumber = function () { return Math.ceil((this.clone().clearTime() - new Date(this.getFullYear(), 0, 1)) / 86400000) + 1; }; /** * Get the time zone abbreviation of the current date. * @return {String} The abbreviated time zone name (e.g. "EST") */ $P.getTimezone = function () { return $D.getTimezoneAbbreviation(this.getUTCOffset(), this.isDaylightSavingTime()); }; $P.setTimezoneOffset = function (offset) { var here = this.getTimezoneOffset(), there = Number(offset) * -6 / 10; return (there || there === 0) ? this.addMinutes(there - here) : this; }; $P.setTimezone = function (offset) { return this.setTimezoneOffset($D.getTimezoneOffset(offset)); }; /** * Indicates whether Daylight Saving Time is observed in the current time zone. * @return {Boolean} true|false */ $P.hasDaylightSavingTime = function () { return (Date.today().set({month: 0, day: 1}).getTimezoneOffset() !== Date.today().set({month: 6, day: 1}).getTimezoneOffset()); }; /** * Indicates whether this Date instance is within the Daylight Saving Time range for the current time zone. * @return {Boolean} true|false */ $P.isDaylightSavingTime = function () { return Date.today().set({month: 0, day: 1}).getTimezoneOffset() !== this.getTimezoneOffset(); }; /** * Get the offset from UTC of the current date. * @return {String} The 4-character offset string prefixed with + or - (e.g. "-0500") */ $P.getUTCOffset = function (offset) { var n = (offset || this.getTimezoneOffset()) * -10 / 6, r; if (n < 0) { r = (n - 10000).toString(); return r.charAt(0) + r.substr(2); } else { r = (n + 10000).toString(); return "+" + r.substr(1); } }; /** * Returns the number of milliseconds between this date and date. * @param {Date} Defaults to now * @return {Number} The diff in milliseconds */ $P.getElapsed = function (date) { return (date || new Date()) - this; }; /** * Set the value of year, month, day, hour, minute, second, millisecond of date instance using given configuration object. * Example

	Date.today().set( { day: 20, month: 1 } )

	new Date().set( { millisecond: 0 } )
	
* * @param {Object} Configuration object containing attributes (month, day, etc.) * @return {Date} this */ $P.set = function (config) { config = validateConfigObject.call(this, config); var key; for (key in config) { if (Object.prototype.hasOwnProperty.call(config, key)) { var name = key.charAt(0).toUpperCase() + key.slice(1); var addFunc, getFunc; if (key !== "week" && key !== "month" && key !== "timezone" && key !== "timezoneOffset") { name += "s"; } addFunc = "add" + name; getFunc = "get" + name; if (key === "month") { addFunc = addFunc + "s"; } else if (key === "year"){ getFunc = "getFullYear"; } if (key !== "day" && key !== "timezone" && key !== "timezoneOffset" && key !== "week" && key !== "hour") { this[addFunc](config[key] - this[getFunc]()); } else if ( key === "timezone"|| key === "timezoneOffset" || key === "week" || key === "hour") { this["set"+name](config[key]); } } } // day has to go last because you can't validate the day without first knowing the month if (config.day) { this.addDays(config.day - this.getDate()); } return this; }; /** * Moves the date to the first day of the month. * @return {Date} this */ $P.moveToFirstDayOfMonth = function () { return this.set({ day: 1 }); }; /** * Moves the date to the last day of the month. * @return {Date} this */ $P.moveToLastDayOfMonth = function () { return this.set({ day: $D.getDaysInMonth(this.getFullYear(), this.getMonth())}); }; /** * Converts the value of the current Date object to its equivalent string representation. * Format Specifiers * CUSTOM DATE AND TIME FORMAT STRINGS * Format Description Example * ------ --------------------------------------------------------------------------- ----------------------- * s The seconds of the minute between 0-59. "0" to "59" * ss The seconds of the minute with leading zero if required. "00" to "59" * * m The minute of the hour between 0-59. "0" or "59" * mm The minute of the hour with leading zero if required. "00" or "59" * * h The hour of the day between 1-12. "1" to "12" * hh The hour of the day with leading zero if required. "01" to "12" * * H The hour of the day between 0-23. "0" to "23" * HH The hour of the day with leading zero if required. "00" to "23" * * d The day of the month between 1 and 31. "1" to "31" * dd The day of the month with leading zero if required. "01" to "31" * ddd Abbreviated day name. Date.CultureInfo.abbreviatedDayNames. "Mon" to "Sun" * dddd The full day name. Date.CultureInfo.dayNames. "Monday" to "Sunday" * * M The month of the year between 1-12. "1" to "12" * MM The month of the year with leading zero if required. "01" to "12" * MMM Abbreviated month name. Date.CultureInfo.abbreviatedMonthNames. "Jan" to "Dec" * MMMM The full month name. Date.CultureInfo.monthNames. "January" to "December" * * yy The year as a two-digit number. "99" or "08" * yyyy The full four digit year. "1999" or "2008" * * t Displays the first character of the A.M./P.M. designator. "A" or "P" * Date.CultureInfo.amDesignator or Date.CultureInfo.pmDesignator * tt Displays the A.M./P.M. designator. "AM" or "PM" * Date.CultureInfo.amDesignator or Date.CultureInfo.pmDesignator * * S The ordinal suffix ("st, "nd", "rd" or "th") of the current day. "st, "nd", "rd" or "th" * * STANDARD DATE AND TIME FORMAT STRINGS * Format Description Example *------ --------------------------------------------------------------------------- ----------------------- * d The CultureInfo shortDate Format Pattern "M/d/yyyy" * D The CultureInfo longDate Format Pattern "dddd, MMMM dd, yyyy" * F The CultureInfo fullDateTime Format Pattern "dddd, MMMM dd, yyyy h:mm:ss tt" * m The CultureInfo monthDay Format Pattern "MMMM dd" * r The CultureInfo rfc1123 Format Pattern "ddd, dd MMM yyyy HH:mm:ss GMT" * s The CultureInfo sortableDateTime Format Pattern "yyyy-MM-ddTHH:mm:ss" * t The CultureInfo shortTime Format Pattern "h:mm tt" * T The CultureInfo longTime Format Pattern "h:mm:ss tt" * u The CultureInfo universalSortableDateTime Format Pattern "yyyy-MM-dd HH:mm:ssZ" * y The CultureInfo yearMonth Format Pattern "MMMM, yyyy" * * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @return {String} A string representation of the current Date object. */ var ord = function (n) { switch (n * 1) { case 1: case 21: case 31: return "st"; case 2: case 22: return "nd"; case 3: case 23: return "rd"; default: return "th"; } }; var parseStandardFormats = function (format) { var y, c = Date.CultureInfo.formatPatterns; switch (format) { case "d": return this.toString(c.shortDate); case "D": return this.toString(c.longDate); case "F": return this.toString(c.fullDateTime); case "m": return this.toString(c.monthDay); case "r": case "R": y = this.clone().addMinutes(this.getTimezoneOffset()); return y.toString(c.rfc1123) + " GMT"; case "s": return this.toString(c.sortableDateTime); case "t": return this.toString(c.shortTime); case "T": return this.toString(c.longTime); case "u": y = this.clone().addMinutes(this.getTimezoneOffset()); return y.toString(c.universalSortableDateTime); case "y": return this.toString(c.yearMonth); default: return false; } }; var parseFormatStringsClosure = function (context) { return function (m) { if (m.charAt(0) === "\\") { return m.replace("\\", ""); } switch (m) { case "hh": return p(context.getHours() < 13 ? (context.getHours() === 0 ? 12 : context.getHours()) : (context.getHours() - 12)); case "h": return context.getHours() < 13 ? (context.getHours() === 0 ? 12 : context.getHours()) : (context.getHours() - 12); case "HH": return p(context.getHours()); case "H": return context.getHours(); case "mm": return p(context.getMinutes()); case "m": return context.getMinutes(); case "ss": return p(context.getSeconds()); case "s": return context.getSeconds(); case "yyyy": return p(context.getFullYear(), 4); case "yy": return p(context.getFullYear()); case "y": return context.getFullYear(); case "E": case "dddd": return Date.CultureInfo.dayNames[context.getDay()]; case "ddd": return Date.CultureInfo.abbreviatedDayNames[context.getDay()]; case "dd": return p(context.getDate()); case "d": return context.getDate(); case "MMMM": return Date.CultureInfo.monthNames[context.getMonth()]; case "MMM": return Date.CultureInfo.abbreviatedMonthNames[context.getMonth()]; case "MM": return p((context.getMonth() + 1)); case "M": return context.getMonth() + 1; case "t": return context.getHours() < 12 ? Date.CultureInfo.amDesignator.substring(0, 1) : Date.CultureInfo.pmDesignator.substring(0, 1); case "tt": return context.getHours() < 12 ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator; case "S": return ord(context.getDate()); case "W": return context.getWeek(); case "WW": return context.getISOWeek(); case "Q": return "Q" + context.getQuarter(); case "q": return String(context.getQuarter()); case "z": return context.getTimezone(); case "Z": case "X": return Date.getTimezoneOffset(context.getTimezone()); case "ZZ": // Timezone offset in seconds return context.getTimezoneOffset() * -60; case "u": return context.getDay(); case "L": return ($D.isLeapYear(context.getFullYear())) ? 1 : 0; case "B": // Swatch Internet Time (.beats) return "@"+((context.getUTCSeconds() + (context.getUTCMinutes()*60) + ((context.getUTCHours()+1)*3600))/86.4); default: return m; } }; }; $P.toString = function (format, ignoreStandards) { // Standard Date and Time Format Strings. Formats pulled from CultureInfo file and // may vary by culture. if (!ignoreStandards && format && format.length === 1) { output = parseStandardFormats.call(this, format); if (output) { return output; } } var parseFormatStrings = parseFormatStringsClosure(this); return format ? format.replace(/((\\)?(dd?d?d?|MM?M?M?|yy?y?y?|hh?|HH?|mm?|ss?|tt?|S|q|Q|WW?W?W?)(?![^\[]*\]))/g, parseFormatStrings).replace(/\[|\]/g, "") : this._toString(); }; }()); /************************************************************* * SugarPak - Domain Specific Language - Syntactical Sugar * *************************************************************/ (function () { var $D = Date, $P = $D.prototype, $N = Number.prototype; // private $P._orient = +1; // private $P._nth = null; // private $P._is = false; // private $P._same = false; // private $P._isSecond = false; // private $N._dateElement = "days"; /** * Moves the date to the next instance of a date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.today().next().friday();
	Date.today().next().fri();
	Date.today().next().march();
	Date.today().next().mar();
	Date.today().next().week();
	
* * @return {Date} date */ $P.next = function () { this._move = true; this._orient = +1; return this; }; /** * Creates a new Date (Date.today()) and moves the date to the next instance of the date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.next().friday();
	Date.next().fri();
	Date.next().march();
	Date.next().mar();
	Date.next().week();
	
* * @return {Date} date */ $D.next = function () { return $D.today().next(); }; /** * Moves the date to the previous instance of a date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.today().last().friday();
	Date.today().last().fri();
	Date.today().last().march();
	Date.today().last().mar();
	Date.today().last().week();
	
* * @return {Date} date */ $P.last = $P.prev = $P.previous = function () { this._move = true; this._orient = -1; return this; }; /** * Creates a new Date (Date.today()) and moves the date to the previous instance of the date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.last().friday();
	Date.last().fri();
	Date.previous().march();
	Date.prev().mar();
	Date.last().week();
	
* * @return {Date} date */ $D.last = $D.prev = $D.previous = function () { return $D.today().last(); }; /** * Performs a equality check when followed by either a month name, day name or .weekday() function. * Example

	Date.today().is().friday(); // true|false
	Date.today().is().fri();
	Date.today().is().march();
	Date.today().is().mar();
	
* * @return {Boolean} true|false */ $P.is = function () { this._is = true; return this; }; /** * Determines if two date objects occur on/in exactly the same instance of the subsequent date part function. * The function .same() must be followed by a date part function (example: .day(), .month(), .year(), etc). * * An optional Date can be passed in the date part function. If now date is passed as a parameter, 'Now' is used. * * The following example demonstrates how to determine if two dates fall on the exact same day. * * Example

	var d1 = Date.today(); // today at 00:00
	var d2 = new Date();   // exactly now.

	// Do they occur on the same day?
	d1.same().day(d2); // true
	
	// Do they occur on the same hour?
	d1.same().hour(d2); // false, unless d2 hour is '00' (midnight).
	
	// What if it's the same day, but one year apart?
	var nextYear = Date.today().add(1).year();

	d1.same().day(nextYear); // false, because the dates must occur on the exact same day. 
	
* * Scenario: Determine if a given date occurs during some week period 2 months from now. * * Example

	var future = Date.today().add(2).months();
	return someDate.same().week(future); // true|false;
	
* * @return {Boolean} true|false */ $P.same = function () { this._same = true; this._isSecond = false; return this; }; /** * Determines if the current date/time occurs during Today. Must be preceded by the .is() function. * Example

	someDate.is().today();    // true|false
	new Date().is().today();  // true
	Date.today().is().today();// true
	Date.today().add(-1).day().is().today(); // false
	
* * @return {Boolean} true|false */ $P.today = function () { return this.same().day(); }; /** * Determines if the current date is a weekday. This function must be preceded by the .is() function. * Example

	Date.today().is().weekday(); // true|false
	
* * @return {Boolean} true|false */ $P.weekday = function () { if (this._nth) { return df("Weekday").call(this); } if (this._move) { return this.addWeekdays(this._orient); } if (this._is) { this._is = false; return (!this.is().sat() && !this.is().sun()); } return false; }; /** * Determines if the current date is on the weekend. This function must be preceded by the .is() function. * Example

	Date.today().is().weekend(); // true|false
	
* * @return {Boolean} true|false */ $P.weekend = function () { if (this._is) { this._is = false; return (this.is().sat() || this.is().sun()); } return false; }; /** * Sets the Time of the current Date instance. A string "6:15 pm" or config object {hour:18, minute:15} are accepted. * Example

	// Set time to 6:15pm with a String
	Date.today().at("6:15pm");

	// Set time to 6:15pm with a config object
	Date.today().at({hour:18, minute:15});
	
* * @return {Date} date */ $P.at = function (time) { return (typeof time === "string") ? $D.parse(this.toString("d") + " " + time) : this.set(time); }; /** * Creates a new Date() and adds this (Number) to the date based on the preceding date element function (eg. second|minute|hour|day|month|year). * Example

	// Undeclared Numbers must be wrapped with parentheses. Requirment of JavaScript.
	(3).days().fromNow();
	(6).months().fromNow();

	// Declared Number variables do not require parentheses. 
	var n = 6;
	n.months().fromNow();
	
* * @return {Date} A new Date instance */ $N.fromNow = $N.after = function (date) { var c = {}; c[this._dateElement] = this; return ((!date) ? new Date() : date.clone()).add(c); }; /** * Creates a new Date() and subtract this (Number) from the date based on the preceding date element function (eg. second|minute|hour|day|month|year). * Example

	// Undeclared Numbers must be wrapped with parentheses. Requirment of JavaScript.
	(3).days().ago();
	(6).months().ago();

	// Declared Number variables do not require parentheses. 
	var n = 6;
	n.months().ago();
	
* * @return {Date} A new Date instance */ $N.ago = $N.before = function (date) { var c = {}, s = (this._dateElement[this._dateElement.length-1] !== "s") ? this._dateElement + "s" : this._dateElement; c[s] = this * -1; return ((!date) ? new Date() : date.clone()).add(c); }; // Do NOT modify the following string tokens. These tokens are used to build dynamic functions. // All culture-specific strings can be found in the CultureInfo files. var dx = ("sunday monday tuesday wednesday thursday friday saturday").split(/\s/), mx = ("january february march april may june july august september october november december").split(/\s/), px = ("Millisecond Second Minute Hour Day Week Month Year Quarter Weekday").split(/\s/), pxf = ("Milliseconds Seconds Minutes Hours Date Week Month FullYear Quarter").split(/\s/), nth = ("final first second third fourth fifth").split(/\s/), de; /** * Returns an object literal of all the date parts. * Example

	var o = new Date().toObject();
	
	// { year: 2008, month: 4, week: 20, day: 13, hour: 18, minute: 9, second: 32, millisecond: 812 }
	
	// The object properties can be referenced directly from the object.
	
	alert(o.day);  // alerts "13"
	alert(o.year); // alerts "2008"
	
* * @return {Date} An object literal representing the original date object. */ $P.toObject = function () { var o = {}; for (var i = 0; i < px.length; i++) { if (this["get" + pxf[i]]) { o[px[i].toLowerCase()] = this["get" + pxf[i]](); } } return o; }; /** * Returns a date created from an object literal. Ignores the .week property if set in the config. * Example

	var o = new Date().toObject();
	
	return Date.fromObject(o); // will return the same date. 

	var o2 = {month: 1, day: 20, hour: 18}; // birthday party!
	Date.fromObject(o2);
	
* * @return {Date} An object literal representing the original date object. */ $D.fromObject = function(config) { config.week = null; return Date.today().set(config); }; // Create day name functions and abbreviated day name functions (eg. monday(), friday(), fri()). var df = function (n) { return function () { if (this._is) { this._is = false; return this.getDay() === n; } if (this._move) { this._move = null; } if (this._nth !== null) { // If the .second() function was called earlier, remove the _orient // from the date, and then continue. // This is required because 'second' can be used in two different context. // // Example // // Date.today().add(1).second(); // Date.march().second().monday(); // // Things get crazy with the following... // Date.march().add(1).second().second().monday(); // but it works!! // if (this._isSecond) { this.addSeconds(this._orient * -1); } // make sure we reset _isSecond this._isSecond = false; var ntemp = this._nth; this._nth = null; var temp = this.clone().moveToLastDayOfMonth(); this.moveToNthOccurrence(n, ntemp); if (this > temp) { throw new RangeError($D.getDayName(n) + " does not occur " + ntemp + " times in the month of " + $D.getMonthName(temp.getMonth()) + " " + temp.getFullYear() + "."); } return this; } return this.moveToDayOfWeek(n, this._orient); }; }; var sdf = function (n) { return function () { var t = $D.today(), shift = n - t.getDay(); if (n === 0 && Date.CultureInfo.firstDayOfWeek === 1 && t.getDay() !== 0) { shift = shift + 7; } return t.addDays(shift); }; }; // Create month name functions and abbreviated month name functions (eg. january(), march(), mar()). var month_instance_functions = function (n) { return function () { if (this._is) { this._is = false; return this.getMonth() === n; } return this.moveToMonth(n, this._orient); }; }; var month_static_functions = function (n) { return function () { return $D.today().set({ month: n, day: 1 }); }; }; var processTerms = function (names, staticFunc, instanceFunc) { for (var i = 0; i < names.length; i++) { // Create constant static Name variables. $D[names[i].toUpperCase()] = $D[names[i].toUpperCase().substring(0, 3)] = i; // Create Name functions. $D[names[i]] = $D[names[i].substring(0, 3)] = staticFunc(i); // Create Name instance functions. $P[names[i]] = $P[names[i].substring(0, 3)] = instanceFunc(i); } }; processTerms(dx, sdf, df); processTerms(mx, month_static_functions, month_instance_functions); // Create date element functions and plural date element functions used with Date (eg. day(), days(), months()). var ef = function (j) { return function () { // if the .second() function was called earlier, the _orient // has alread been added. Just return this and reset _isSecond. if (this._isSecond) { this._isSecond = false; return this; } if (this._same) { this._same = this._is = false; var o1 = this.toObject(), o2 = (arguments[0] || new Date()).toObject(), v = "", k = j.toLowerCase(); // the substr trick with -1 doesn't work in IE8 or less k = (k[k.length-1] === "s") ? k.substring(0,k.length-1) : k; for (var m = (px.length - 1); m > -1; m--) { v = px[m].toLowerCase(); if (o1[v] !== o2[v]) { return false; } if (k === v) { break; } } return true; } if (j.substring(j.length - 1) !== "s") { j += "s"; } if (this._move) { this._move = null; } return this["add" + j](this._orient); }; }; var nf = function (n) { return function () { this._dateElement = n; return this; }; }; for (var k = 0; k < px.length; k++) { de = px[k].toLowerCase(); if(de !== "weekday") { // Create date element functions and plural date element functions used with Date (eg. day(), days(), months()). $P[de] = $P[de + "s"] = ef(px[k]); // Create date element functions and plural date element functions used with Number (eg. day(), days(), months()). $N[de] = $N[de + "s"] = nf(de + "s"); } } $P._ss = ef("Second"); var nthfn = function (n) { return function (dayOfWeek) { if (this._same) { return this._ss(arguments[0]); } if (dayOfWeek || dayOfWeek === 0) { return this.moveToNthOccurrence(dayOfWeek, n); } this._nth = n; // if the operator is 'second' add the _orient, then deal with it later... if (n === 2 && (dayOfWeek === undefined || dayOfWeek === null)) { this._isSecond = true; return this.addSeconds(this._orient); } return this; }; }; for (var l = 0; l < nth.length; l++) { $P[nth[l]] = (l === 0) ? nthfn(-1) : nthfn(l); } }()); (function () { "use strict"; Date.Parsing = { Exception: function (s) { this.message = "Parse error at '" + s.substring(0, 10) + " ...'"; } }; var $P = Date.Parsing; var dayOffsets = { standard: [0,31,59,90,120,151,181,212,243,273,304,334], leap: [0,31,60,91,121,152,182,213,244,274,305,335] }; $P.isLeapYear = function(year) { return ((year % 4 === 0) && (year % 100 !== 0)) || (year % 400 === 0); }; var utils = { multiReplace : function (str, hash ) { var key; for (key in hash) { if (Object.prototype.hasOwnProperty.call(hash, key)) { var regex; if (typeof hash[key] === "function") { } else { regex = (hash[key] instanceof RegExp) ? hash[key] : new RegExp(hash[key], "g"); } str = str.replace(regex, key); } } return str; }, getDayOfYearFromWeek : function (obj) { var d, jan4, offset; obj.weekDay = (!obj.weekDay && obj.weekDay !== 0) ? 1 : obj.weekDay; d = new Date(obj.year, 0, 4); jan4 = d.getDay() === 0 ? 7 : d.getDay(); // JS is 0 indexed on Sunday. offset = jan4+3; obj.dayOfYear = ((obj.week * 7) + (obj.weekDay === 0 ? 7 : obj.weekDay))-offset; return obj; }, getDayOfYear : function (obj, dayOffset) { if (!obj.dayOfYear) { obj = utils.getDayOfYearFromWeek(obj); } for (var i=0;i <= dayOffset.length;i++) { if (obj.dayOfYear < dayOffset[i] || i === dayOffset.length) { obj.day = obj.day ? obj.day : (obj.dayOfYear - dayOffset[i-1]); break; } else { obj.month = i; } } return obj; }, adjustForTimeZone : function (obj, date) { var offset; if (obj.zone.toUpperCase() === "Z" || (obj.zone_hours === 0 && obj.zone_minutes === 0)) { // it's UTC/GML so work out the current timeszone offset offset = -date.getTimezoneOffset(); } else { offset = (obj.zone_hours*60) + (obj.zone_minutes || 0); if (obj.zone_sign === "+") { offset *= -1; } offset -= date.getTimezoneOffset(); } date.setMinutes(date.getMinutes()+offset); return date; }, setDefaults : function (obj) { obj.year = obj.year || Date.today().getFullYear(); obj.hours = obj.hours || 0; obj.minutes = obj.minutes || 0; obj.seconds = obj.seconds || 0; obj.milliseconds = obj.milliseconds || 0; if (!(!obj.month && (obj.week || obj.dayOfYear))) { // if we have a month, or if we don't but don't have the day calculation data obj.month = obj.month || 0; obj.day = obj.day || 1; } return obj; }, dataNum: function (data, mod, explict, postProcess) { var dataNum = data*1; if (mod) { if (postProcess) { return data ? mod(data)*1 : data; } else { return data ? mod(dataNum) : data; } } else if (!explict){ return data ? dataNum : data; } else { return (data && typeof data !== "undefined") ? dataNum : data; } }, timeDataProcess: function (obj) { var timeObj = {}; for (var x in obj.data) { if (obj.data.hasOwnProperty(x)) { timeObj[x] = obj.ignore[x] ? obj.data[x] : utils.dataNum(obj.data[x], obj.mods[x], obj.explict[x], obj.postProcess[x]); } } if (obj.data.secmins) { obj.data.secmins = obj.data.secmins.replace(",", ".") * 60; if (!timeObj.minutes) { timeObj.minutes = obj.data.secmins; } else if (!timeObj.seconds) { timeObj.seconds = obj.data.secmins; } delete obj.secmins; } return timeObj; }, buildTimeObjectFromData: function (data) { var time = utils.timeDataProcess({ data: { year : data[1], month : data[5], day : data[7], week : data[8], dayOfYear : data[10], hours : data[15], zone_hours : data[23], zone_minutes : data[24], zone : data[21], zone_sign : data[22], weekDay : data[9], minutes: data[16], seconds: data[19], milliseconds: data[20], secmins: data[18] }, mods: { month: function(data) { return data-1; }, weekDay: function (data) { data = Math.abs(data); return (data === 7 ? 0 : data); }, minutes: function (data) { return data.replace(":",""); }, seconds: function (data) { return Math.floor( (data.replace(":","").replace(",","."))*1 ); }, milliseconds: function (data) { return (data.replace(",",".")*1000); } }, postProcess: { minutes: true, seconds: true, milliseconds: true }, explict: { zone_hours: true, zone_minutes: true }, ignore: { zone: true, zone_sign: true, secmins: true } }); return time; }, addToHash: function (hash, keys, data) { keys = keys; data = data; var len = keys.length; for (var i = 0; i < len; i++) { hash[keys[i]] = data[i]; } return hash; }, combineRegex: function (r1, r2) { return new RegExp("(("+r1.source+")\\s("+r2.source+"))"); }, getDateNthString: function(add, last, inc){ if (add) { return Date.today().addDays(inc).toString("d"); } else if (last) { return Date.today().last()[inc]().toString("d"); } }, buildRegexData: function (array) { var arr = []; var len = array.length; for (var i=0; i < len; i++) { if (Object.prototype.toString.call(array[i]) === '[object Array]') { // oldIE compat version of Array.isArray arr.push(this.combineRegex(array[i][0], array[i][1])); } else { arr.push(array[i]); } } return arr; } }; $P.processTimeObject = function (obj) { var date, dayOffset; utils.setDefaults(obj); dayOffset = ($P.isLeapYear(obj.year)) ? dayOffsets.leap : dayOffsets.standard; if (!obj.month && (obj.week || obj.dayOfYear)) { utils.getDayOfYear(obj, dayOffset); } else { obj.dayOfYear = dayOffset[obj.month] + obj.day; } date = new Date(obj.year, obj.month, obj.day, obj.hours, obj.minutes, obj.seconds, obj.milliseconds); if (obj.zone) { utils.adjustForTimeZone(obj, date); // adjust (and calculate) for timezone } return date; }; $P.ISO = { regex : /^([\+-]?\d{4}(?!\d{2}\b))((-?)((0[1-9]|1[0-2])(\3([12]\d|0[1-9]|3[01]))?|W([0-4]\d|5[0-3])(-?[1-7])?|(00[1-9]|0[1-9]\d|[12]\d{2}|3([0-5]\d|6[1-6])))([T\s]((([01]\d|2[0-4])((:?)[0-5]\d)?|24\:?00)([\.,]\d+(?!:))?)?(\17[0-5]\d([\.,]\d+)?)?\s?([zZ]|([\+-])([01]\d|2[0-3]):?([0-5]\d)?)?)?)?$/, parse : function (s) { var time, data = s.match(this.regex); if (!data || !data.length) { return null; } time = utils.buildTimeObjectFromData(data); if (!time.year || (!time.year && (!time.month && !time.day) && (!time.week && !time.dayOfYear)) ) { return null; } return $P.processTimeObject(time); } }; $P.Numeric = { isNumeric: function (e){return!isNaN(parseFloat(e))&&isFinite(e);}, regex: /\b([0-1]?[0-9])([0-3]?[0-9])([0-2]?[0-9]?[0-9][0-9])\b/i, parse: function (s) { var data, i, time = {}, order = Date.CultureInfo.dateElementOrder.split(""); if (!(this.isNumeric(s)) || // if it's non-numeric OR (s[0] === "+" && s[0] === "-")) { // It's an arithmatic string (eg +/-1000) return null; } if (s.length < 5 && s.indexOf(".") < 0 && s.indexOf("/") < 0) { // assume it's just a year. time.year = s; return $P.processTimeObject(time); } data = s.match(this.regex); if (!data || !data.length) { return null; } for (i=0; i < order.length; i++) { switch(order[i]) { case "d": time.day = data[i+1]; break; case "m": time.month = (data[i+1]-1); break; case "y": time.year = data[i+1]; break; } } return $P.processTimeObject(time); } }; $P.Normalizer = { regexData: function () { var $R = Date.CultureInfo.regexPatterns; return utils.buildRegexData([ $R.tomorrow, $R.yesterday, [$R.past, $R.mon], [$R.past, $R.tue], [$R.past, $R.wed], [$R.past, $R.thu], [$R.past, $R.fri], [$R.past, $R.sat], [$R.past, $R.sun] ]); }, basicReplaceHash : function() { var $R = Date.CultureInfo.regexPatterns; return { "January": $R.jan.source, "February": $R.feb, "March": $R.mar, "April": $R.apr, "May": $R.may, "June": $R.jun, "July": $R.jul, "August": $R.aug, "September": $R.sep, "October": $R.oct, "November": $R.nov, "December": $R.dec, "": /\bat\b/gi, " ": /\s{2,}/, "am": $R.inTheMorning, "9am": $R.thisMorning, "pm": $R.inTheEvening, "7pm":$R.thisEvening }; }, keys : function(){ return [ utils.getDateNthString(true, false, 1), // tomorrow utils.getDateNthString(true, false, -1), // yesterday utils.getDateNthString(false, true, "monday"), //last mon utils.getDateNthString(false, true, "tuesday"), //last tues utils.getDateNthString(false, true, "wednesday"), //last wed utils.getDateNthString(false, true, "thursday"), //last thurs utils.getDateNthString(false, true, "friday"), //last fri utils.getDateNthString(false, true, "saturday"), //last sat utils.getDateNthString(false, true, "sunday") //last sun ]; }, buildRegexFunctions: function () { var $R = Date.CultureInfo.regexPatterns; var __ = Date.i18n.__; var tomorrowRE = new RegExp("(\\b\\d\\d?("+__("AM")+"|"+__("PM")+")? )("+$R.tomorrow.source.slice(1)+")", "i"); // adapted tomorrow regex for AM PM relative dates var todayRE = new RegExp($R.today.source + "(?!\\s*([+-]))\\b"); // today, but excludes the math operators (eg "today + 2h") this.replaceFuncs = [ [todayRE, function (full) { return (full.length > 1) ? Date.today().toString("d") : full; }], [tomorrowRE, function(full, m1) { var t = Date.today().addDays(1).toString("d"); return (t + " " + m1); }], [$R.amThisMorning, function(str, am){return am;}], [$R.pmThisEvening, function(str, pm){return pm;}] ]; }, buildReplaceData: function () { this.buildRegexFunctions(); this.replaceHash = utils.addToHash(this.basicReplaceHash(), this.keys(), this.regexData()); }, stringReplaceFuncs: function (s) { for (var i=0; i < this.replaceFuncs.length; i++) { s = s.replace(this.replaceFuncs[i][0], this.replaceFuncs[i][1]); } return s; }, parse: function (s) { s = this.stringReplaceFuncs(s); s = utils.multiReplace(s, this.replaceHash); try { var n = s.split(/([\s\-\.\,\/\x27]+)/); if (n.length === 3 && $P.Numeric.isNumeric(n[0]) && $P.Numeric.isNumeric(n[2]) && (n[2].length >= 4)) { // ok, so we're dealing with x/year. But that's not a full date. // This fixes wonky dateElementOrder parsing when set to dmy order. if (Date.CultureInfo.dateElementOrder[0] === "d") { s = "1/" + n[0] + "/" + n[2]; // set to 1st of month and normalize the seperator } } } catch (e) {} return s; } }; $P.Normalizer.buildReplaceData(); }()); (function () { var $P = Date.Parsing; var _ = $P.Operators = { // // Tokenizers // rtoken: function (r) { // regex token return function (s) { var mx = s.match(r); if (mx) { return ([ mx[0], s.substring(mx[0].length) ]); } else { throw new $P.Exception(s); } }; }, token: function () { // whitespace-eating token return function (s) { return _.rtoken(new RegExp("^\\s*" + s + "\\s*"))(s); }; }, stoken: function (s) { // string token return _.rtoken(new RegExp("^" + s)); }, // Atomic Operators until: function (p) { return function (s) { var qx = [], rx = null; while (s.length) { try { rx = p.call(this, s); } catch (e) { qx.push(rx[0]); s = rx[1]; continue; } break; } return [ qx, s ]; }; }, many: function (p) { return function (s) { var rx = [], r = null; while (s.length) { try { r = p.call(this, s); } catch (e) { return [ rx, s ]; } rx.push(r[0]); s = r[1]; } return [ rx, s ]; }; }, // generator operators -- see below optional: function (p) { return function (s) { var r = null; try { r = p.call(this, s); } catch (e) { return [ null, s ]; } return [ r[0], r[1] ]; }; }, not: function (p) { return function (s) { try { p.call(this, s); } catch (e) { return [null, s]; } throw new $P.Exception(s); }; }, ignore: function (p) { return p ? function (s) { var r = null; r = p.call(this, s); return [null, r[1]]; } : null; }, product: function () { var px = arguments[0], qx = Array.prototype.slice.call(arguments, 1), rx = []; for (var i = 0 ; i < px.length ; i++) { rx.push(_.each(px[i], qx)); } return rx; }, cache: function (rule) { var cache = {}, cache_length = 0, cache_keys = [], CACHE_MAX = Date.Config.CACHE_MAX || 100000, r = null; var cacheCheck = function () { if (cache_length === CACHE_MAX) { // kill several keys, don't want to have to do this all the time... for (var i=0; i < 10; i++) { var key = cache_keys.shift(); if (key) { delete cache[key]; cache_length--; } } } }; return function (s) { cacheCheck(); try { r = cache[s] = (cache[s] || rule.call(this, s)); } catch (e) { r = cache[s] = e; } cache_length++; cache_keys.push(s); if (r instanceof $P.Exception) { throw r; } else { return r; } }; }, // vector operators -- see below any: function () { var px = arguments; return function (s) { var r = null; for (var i = 0; i < px.length; i++) { if (px[i] == null) { continue; } try { r = (px[i].call(this, s)); } catch (e) { r = null; } if (r) { return r; } } throw new $P.Exception(s); }; }, each: function () { var px = arguments; return function (s) { var rx = [], r = null; for (var i = 0; i < px.length ; i++) { if (px[i] == null) { continue; } try { r = (px[i].call(this, s)); } catch (e) { throw new $P.Exception(s); } rx.push(r[0]); s = r[1]; } return [ rx, s]; }; }, all: function () { var px = arguments, _ = _; return _.each(_.optional(px)); }, // delimited operators sequence: function (px, d, c) { d = d || _.rtoken(/^\s*/); c = c || null; if (px.length === 1) { return px[0]; } return function (s) { var r = null, q = null; var rx = []; for (var i = 0; i < px.length ; i++) { try { r = px[i].call(this, s); } catch (e) { break; } rx.push(r[0]); try { q = d.call(this, r[1]); } catch (ex) { q = null; break; } s = q[1]; } if (!r) { throw new $P.Exception(s); } if (q) { throw new $P.Exception(q[1]); } if (c) { try { r = c.call(this, r[1]); } catch (ey) { throw new $P.Exception(r[1]); } } return [ rx, (r?r[1]:s) ]; }; }, // // Composite Operators // between: function (d1, p, d2) { d2 = d2 || d1; var _fn = _.each(_.ignore(d1), p, _.ignore(d2)); return function (s) { var rx = _fn.call(this, s); return [[rx[0][0], r[0][2]], rx[1]]; }; }, list: function (p, d, c) { d = d || _.rtoken(/^\s*/); c = c || null; return (p instanceof Array ? _.each(_.product(p.slice(0, -1), _.ignore(d)), p.slice(-1), _.ignore(c)) : _.each(_.many(_.each(p, _.ignore(d))), px, _.ignore(c))); }, set: function (px, d, c) { d = d || _.rtoken(/^\s*/); c = c || null; return function (s) { // r is the current match, best the current 'best' match // which means it parsed the most amount of input var r = null, p = null, q = null, rx = null, best = [[], s], last = false; // go through the rules in the given set for (var i = 0; i < px.length ; i++) { // last is a flag indicating whether this must be the last element // if there is only 1 element, then it MUST be the last one q = null; p = null; r = null; last = (px.length === 1); // first, we try simply to match the current pattern // if not, try the next pattern try { r = px[i].call(this, s); } catch (e) { continue; } // since we are matching against a set of elements, the first // thing to do is to add r[0] to matched elements rx = [[r[0]], r[1]]; // if we matched and there is still input to parse and // we don't already know this is the last element, // we're going to next check for the delimiter ... // if there's none, or if there's no input left to parse // than this must be the last element after all ... if (r[1].length > 0 && ! last) { try { q = d.call(this, r[1]); } catch (ex) { last = true; } } else { last = true; } // if we parsed the delimiter and now there's no more input, // that means we shouldn't have parsed the delimiter at all // so don't update r and mark this as the last element ... if (!last && q[1].length === 0) { last = true; } // so, if this isn't the last element, we're going to see if // we can get any more matches from the remaining (unmatched) // elements ... if (!last) { // build a list of the remaining rules we can match against, // i.e., all but the one we just matched against var qx = []; for (var j = 0; j < px.length ; j++) { if (i !== j) { qx.push(px[j]); } } // now invoke recursively set with the remaining input // note that we don't include the closing delimiter ... // we'll check for that ourselves at the end p = _.set(qx, d).call(this, q[1]); // if we got a non-empty set as a result ... // (otw rx already contains everything we want to match) if (p[0].length > 0) { // update current result, which is stored in rx ... // basically, pick up the remaining text from p[1] // and concat the result from p[0] so that we don't // get endless nesting ... rx[0] = rx[0].concat(p[0]); rx[1] = p[1]; } } // at this point, rx either contains the last matched element // or the entire matched set that starts with this element. // now we just check to see if this variation is better than // our best so far, in terms of how much of the input is parsed if (rx[1].length < best[1].length) { best = rx; } // if we've parsed all the input, then we're finished if (best[1].length === 0) { break; } } // so now we've either gone through all the patterns trying them // as the initial match; or we found one that parsed the entire // input string ... // if best has no matches, just return empty set ... if (best[0].length === 0) { return best; } // if a closing delimiter is provided, then we have to check it also if (c) { // we try this even if there is no remaining input because the pattern // may well be optional or match empty input ... try { q = c.call(this, best[1]); } catch (ey) { throw new $P.Exception(best[1]); } // it parsed ... be sure to update the best match remaining input best[1] = q[1]; } // if we're here, either there was no closing delimiter or we parsed it // so now we have the best match; just return it! return best; }; }, forward: function (gr, fname) { return function (s) { return gr[fname].call(this, s); }; }, // // Translation Operators // replace: function (rule, repl) { return function (s) { var r = rule.call(this, s); return [repl, r[1]]; }; }, process: function (rule, fn) { return function (s) { var r = rule.call(this, s); return [fn.call(this, r[0]), r[1]]; }; }, min: function (min, rule) { return function (s) { var rx = rule.call(this, s); if (rx[0].length < min) { throw new $P.Exception(s); } return rx; }; } }; // Generator Operators And Vector Operators // Generators are operators that have a signature of F(R) => R, // taking a given rule and returning another rule, such as // ignore, which parses a given rule and throws away the result. // Vector operators are those that have a signature of F(R1,R2,...) => R, // take a list of rules and returning a new rule, such as each. // Generator operators are converted (via the following _generator // function) into functions that can also take a list or array of rules // and return an array of new rules as though the function had been // called on each rule in turn (which is what actually happens). // This allows generators to be used with vector operators more easily. // Example: // each(ignore(foo, bar)) instead of each(ignore(foo), ignore(bar)) // This also turns generators into vector operators, which allows // constructs like: // not(cache(foo, bar)) var _generator = function (op) { function gen() { var args = null, rx = [], px, i; if (arguments.length > 1) { args = Array.prototype.slice.call(arguments); } else if (arguments[0] instanceof Array) { args = arguments[0]; } if (args) { px = args.shift(); if (px.length > 0) { args.unshift(px[i]); rx.push(op.apply(null, args)); args.shift(); return rx; } } else { return op.apply(null, arguments); } } return gen; }; var gx = "optional not ignore cache".split(/\s/); for (var i = 0 ; i < gx.length ; i++) { _[gx[i]] = _generator(_[gx[i]]); } var _vector = function (op) { return function () { if (arguments[0] instanceof Array) { return op.apply(null, arguments[0]); } else { return op.apply(null, arguments); } }; }; var vx = "each any all".split(/\s/); for (var j = 0 ; j < vx.length ; j++) { _[vx[j]] = _vector(_[vx[j]]); } }()); (function () { var $D = Date; var flattenAndCompact = function (ax) { var rx = []; for (var i = 0; i < ax.length; i++) { if (ax[i] instanceof Array) { rx = rx.concat(flattenAndCompact(ax[i])); } else { if (ax[i]) { rx.push(ax[i]); } } } return rx; }; var parseMeridian = function () { if (this.meridian && (this.hour || this.hour === 0)) { if (this.meridian === "a" && this.hour > 11 && Date.Config.strict24hr){ throw "Invalid hour and meridian combination"; } else if (this.meridian === "p" && this.hour < 12 && Date.Config.strict24hr){ throw "Invalid hour and meridian combination"; } else if (this.meridian === "p" && this.hour < 12) { this.hour = this.hour + 12; } else if (this.meridian === "a" && this.hour === 12) { this.hour = 0; } } }; var setDefaults = function () { var now = new Date(); if ((this.hour || this.minute) && (!this.month && !this.year && !this.day)) { this.day = now.getDate(); } if (!this.year) { this.year = now.getFullYear(); } if (!this.month && this.month !== 0) { this.month = now.getMonth(); } if (!this.day) { this.day = 1; } if (!this.hour) { this.hour = 0; } if (!this.minute) { this.minute = 0; } if (!this.second) { this.second = 0; } if (!this.millisecond) { this.millisecond = 0; } }; var finishUtils = { getToday: function () { if (this.now || "hour minute second".indexOf(this.unit) !== -1) { return new Date(); } else { return $D.today(); } }, setDaysFromWeekday: function (today, orient){ var gap; orient = orient || 1; this.unit = "day"; gap = ($D.getDayNumberFromName(this.weekday) - today.getDay()); this.days = gap ? ((gap + (orient * 7)) % 7) : (orient * 7); return this; }, setMonthsFromMonth: function (today, orient) { var gap; orient = orient || 1; this.unit = "month"; gap = (this.month - today.getMonth()); this.months = gap ? ((gap + (orient * 12)) % 12) : (orient * 12); this.month = null; return this; }, setDMYFromWeekday: function () { var d = Date[this.weekday](); this.day = d.getDate(); if (!this.month) { this.month = d.getMonth(); } this.year = d.getFullYear(); return this; }, setUnitValue: function (orient) { if (!this.value && this.operator && this.operator !== null && this[this.unit + "s"] && this[this.unit + "s"] !== null) { this[this.unit + "s"] = this[this.unit + "s"] + ((this.operator === "add") ? 1 : -1) + (this.value||0) * orient; } else if (this[this.unit + "s"] == null || this.operator != null) { if (!this.value) { this.value = 1; } this[this.unit + "s"] = this.value * orient; } }, generateDateFromWeeks: function () { var weekday = (this.weekday !== undefined) ? this.weekday : "today"; var d = Date[weekday]().addWeeks(this.weeks); if (this.now) { d.setTimeToNow(); } return d; } }; $D.Translator = { hour: function (s) { return function () { this.hour = Number(s); }; }, minute: function (s) { return function () { this.minute = Number(s); }; }, second: function (s) { return function () { this.second = Number(s); }; }, /* for ss.s format */ secondAndMillisecond: function (s) { return function () { var mx = s.match(/^([0-5][0-9])\.([0-9]{1,3})/); this.second = Number(mx[1]); this.millisecond = Number(mx[2]); }; }, meridian: function (s) { return function () { this.meridian = s.slice(0, 1).toLowerCase(); }; }, timezone: function (s) { return function () { var n = s.replace(/[^\d\+\-]/g, ""); if (n.length) { this.timezoneOffset = Number(n); } else { this.timezone = s.toLowerCase(); } }; }, day: function (x) { var s = x[0]; return function () { this.day = Number(s.match(/\d+/)[0]); if (this.day < 1) { throw "invalid day"; } }; }, month: function (s) { return function () { this.month = (s.length === 3) ? "jan feb mar apr may jun jul aug sep oct nov dec".indexOf(s)/4 : Number(s) - 1; if (this.month < 0) { throw "invalid month"; } }; }, year: function (s) { return function () { var n = Number(s); this.year = ((s.length > 2) ? n : (n + (((n + 2000) < Date.CultureInfo.twoDigitYearMax) ? 2000 : 1900))); }; }, rday: function (s) { return function () { switch (s) { case "yesterday": this.days = -1; break; case "tomorrow": this.days = 1; break; case "today": this.days = 0; break; case "now": this.days = 0; this.now = true; break; } }; }, finishExact: function (x) { var d; x = (x instanceof Array) ? x : [x]; for (var i = 0 ; i < x.length ; i++) { if (x[i]) { x[i].call(this); } } setDefaults.call(this); parseMeridian.call(this); if (this.day > $D.getDaysInMonth(this.year, this.month)) { throw new RangeError(this.day + " is not a valid value for days."); } d = new Date(this.year, this.month, this.day, this.hour, this.minute, this.second, this.millisecond); if (this.year < 100) { d.setFullYear(this.year); // means years less that 100 are process correctly. JS will parse it otherwise as 1900-1999. } if (this.timezone) { d.set({ timezone: this.timezone }); } else if (this.timezoneOffset) { d.set({ timezoneOffset: this.timezoneOffset }); } return d; }, finish: function (x) { var today, expression, orient, temp; x = (x instanceof Array) ? flattenAndCompact(x) : [ x ]; if (x.length === 0) { return null; } for (var i = 0 ; i < x.length ; i++) { if (typeof x[i] === "function") { x[i].call(this); } } if (this.now && !this.unit && !this.operator) { return new Date(); } else { today = finishUtils.getToday.call(this); } expression = !!(this.days && this.days !== null || this.orient || this.operator); orient = ((this.orient === "past" || this.operator === "subtract") ? -1 : 1); if (this.month && this.unit === "week") { this.value = this.month + 1; delete this.month; delete this.day; } if ((this.month || this.month === 0) && "year day hour minute second".indexOf(this.unit) !== -1) { if (!this.value) { this.value = this.month + 1; } this.month = null; expression = true; } if (!expression && this.weekday && !this.day && !this.days) { finishUtils.setDMYFromWeekday.call(this); } if (expression && this.weekday && this.unit !== "month" && this.unit !== "week") { finishUtils.setDaysFromWeekday.call(this, today, orient); } if (this.weekday && this.unit !== "week" && !this.day && !this.days) { temp = Date[this.weekday](); this.day = temp.getDate(); if (temp.getMonth() !== today.getMonth()) { this.month = temp.getMonth(); } } if (this.month && this.unit === "day" && this.operator) { if (!this.value) { this.value = (this.month + 1); } this.month = null; } if (this.value != null && this.month != null && this.year != null) { this.day = this.value * 1; } if (this.month && !this.day && this.value) { today.set({ day: this.value * 1 }); if (!expression) { this.day = this.value * 1; } } if (!this.month && this.value && this.unit === "month" && !this.now) { this.month = this.value; expression = true; } if (expression && (this.month || this.month === 0) && this.unit !== "year") { finishUtils.setMonthsFromMonth.call(this, today, orient); } if (!this.unit) { this.unit = "day"; } finishUtils.setUnitValue.call(this, orient); parseMeridian.call(this); if ((this.month || this.month === 0) && !this.day) { this.day = 1; } if (!this.orient && !this.operator && this.unit === "week" && this.value && !this.day && !this.month) { return Date.today().setWeek(this.value); } if (this.unit === "week" && this.weeks && !this.day && !this.month) { return finishUtils.generateDateFromWeeks.call(this); } if (expression && this.timezone && this.day && this.days) { this.day = this.days; } if (expression){ today.add(this); } else { today.set(this); } if (this.timezone) { this.timezone = this.timezone.toUpperCase(); var offset = $D.getTimezoneOffset(this.timezone); var timezone; if (today.hasDaylightSavingTime()) { // lets check that we're being sane with timezone setting timezone = $D.getTimezoneAbbreviation(offset, today.isDaylightSavingTime()); if (timezone !== this.timezone) { // bugger, we're in a place where things like EST vs EDT matters. if (today.isDaylightSavingTime()) { today.addHours(-1); } else { today.addHours(1); } } } today.setTimezoneOffset(offset); } return today; } }; }()); (function () { var $D = Date; $D.Grammar = {}; var _ = $D.Parsing.Operators, g = $D.Grammar, t = $D.Translator, _fn; // Allow rolling up into general purpose rules _fn = function () { return _.each(_.any.apply(null, arguments), _.not(g.ctoken2("timeContext"))); }; g.datePartDelimiter = _.rtoken(/^([\s\-\.\,\/\x27]+)/); g.timePartDelimiter = _.stoken(":"); g.whiteSpace = _.rtoken(/^\s*/); g.generalDelimiter = _.rtoken(/^(([\s\,]|at|@|on)+)/); var _C = {}; g.ctoken = function (keys) { var fn = _C[keys]; if (! fn) { var c = Date.CultureInfo.regexPatterns; var kx = keys.split(/\s+/), px = []; for (var i = 0; i < kx.length ; i++) { px.push(_.replace(_.rtoken(c[kx[i]]), kx[i])); } fn = _C[keys] = _.any.apply(null, px); } return fn; }; g.ctoken2 = function (key) { return _.rtoken(Date.CultureInfo.regexPatterns[key]); }; var cacheProcessRtoken = function (key, token, type, eachToken) { if (eachToken) { g[key] = _.cache(_.process(_.each(_.rtoken(token),_.optional(g.ctoken2(eachToken))), type)); } else { g[key] = _.cache(_.process(_.rtoken(token), type)); } }; var cacheProcessCtoken = function (token, type) { return _.cache(_.process(g.ctoken2(token), type)); }; var _F = {}; //function cache var _get = function (f) { _F[f] = (_F[f] || g.format(f)[0]); return _F[f]; }; g.allformats = function (fx) { var rx = []; if (fx instanceof Array) { for (var i = 0; i < fx.length; i++) { rx.push(_get(fx[i])); } } else { rx.push(_get(fx)); } return rx; }; g.formats = function (fx) { if (fx instanceof Array) { var rx = []; for (var i = 0 ; i < fx.length ; i++) { rx.push(_get(fx[i])); } return _.any.apply(null, rx); } else { return _get(fx); } }; var grammarFormats = { timeFormats: function(){ var i, RTokenKeys = [ "h", "hh", "H", "HH", "m", "mm", "s", "ss", "ss.s", "z", "zz" ], RToken = [ /^(0[0-9]|1[0-2]|[1-9])/, /^(0[0-9]|1[0-2])/, /^([0-1][0-9]|2[0-3]|[0-9])/, /^([0-1][0-9]|2[0-3])/, /^([0-5][0-9]|[0-9])/, /^[0-5][0-9]/, /^([0-5][0-9]|[0-9])/, /^[0-5][0-9]/, /^[0-5][0-9]\.[0-9]{1,3}/, /^((\+|\-)\s*\d\d\d\d)|((\+|\-)\d\d\:?\d\d)/, /^((\+|\-)\s*\d\d\d\d)|((\+|\-)\d\d\:?\d\d)/ ], tokens = [ t.hour, t.hour, t.hour, t.hour, t.minute, t.minute, t.second, t.second, t.secondAndMillisecond, t.timezone, t.timezone ]; for (i=0; i < RTokenKeys.length; i++) { cacheProcessRtoken(RTokenKeys[i], RToken[i], tokens[i]); } g.hms = _.cache(_.sequence([g.H, g.m, g.s], g.timePartDelimiter)); g.t = cacheProcessCtoken("shortMeridian", t.meridian); g.tt = cacheProcessCtoken("longMeridian", t.meridian); g.zzz = cacheProcessCtoken("timezone", t.timezone); g.timeSuffix = _.each(_.ignore(g.whiteSpace), _.set([ g.tt, g.zzz ])); g.time = _.each(_.optional(_.ignore(_.stoken("T"))), g.hms, g.timeSuffix); }, dateFormats: function () { // pre-loaded rules for different date part order preferences var _setfn = function () { return _.set(arguments, g.datePartDelimiter); }; var i, RTokenKeys = [ "d", "dd", "M", "MM", "y", "yy", "yyy", "yyyy" ], RToken = [ /^([0-2]\d|3[0-1]|\d)/, /^([0-2]\d|3[0-1])/, /^(1[0-2]|0\d|\d)/, /^(1[0-2]|0\d)/, /^(\d+)/, /^(\d\d)/, /^(\d\d?\d?\d?)/, /^(\d\d\d\d)/ ], tokens = [ t.day, t.day, t.month, t.month, t.year, t.year, t.year, t.year ], eachToken = [ "ordinalSuffix", "ordinalSuffix" ]; for (i=0; i < RTokenKeys.length; i++) { cacheProcessRtoken(RTokenKeys[i], RToken[i], tokens[i], eachToken[i]); } g.MMM = g.MMMM = _.cache(_.process(g.ctoken("jan feb mar apr may jun jul aug sep oct nov dec"), t.month)); g.ddd = g.dddd = _.cache(_.process(g.ctoken("sun mon tue wed thu fri sat"), function (s) { return function () { this.weekday = s; }; } )); g.day = _fn(g.d, g.dd); g.month = _fn(g.M, g.MMM); g.year = _fn(g.yyyy, g.yy); g.mdy = _setfn(g.ddd, g.month, g.day, g.year); g.ymd = _setfn(g.ddd, g.year, g.month, g.day); g.dmy = _setfn(g.ddd, g.day, g.month, g.year); g.date = function (s) { return ((g[Date.CultureInfo.dateElementOrder] || g.mdy).call(this, s)); }; }, relative: function () { // relative date / time expressions g.orientation = _.process(g.ctoken("past future"), function (s) { return function () { this.orient = s; }; } ); g.operator = _.process(g.ctoken("add subtract"), function (s) { return function () { this.operator = s; }; } ); g.rday = _.process(g.ctoken("yesterday tomorrow today now"), t.rday); g.unit = _.process(g.ctoken("second minute hour day week month year"), function (s) { return function () { this.unit = s; }; } ); } }; g.buildGrammarFormats = function () { // these need to be rebuilt every time the language changes. _C = {}; grammarFormats.timeFormats(); grammarFormats.dateFormats(); grammarFormats.relative(); g.value = _.process(_.rtoken(/^([-+]?\d+)?(st|nd|rd|th)?/), function (s) { return function () { this.value = s.replace(/\D/g, ""); }; } ); g.expression = _.set([g.rday, g.operator, g.value, g.unit, g.orientation, g.ddd, g.MMM ]); g.format = _.process(_.many( _.any( // translate format specifiers into grammar rules _.process( _.rtoken(/^(dd?d?d?(?!e)|MM?M?M?|yy?y?y?|hh?|HH?|mm?|ss?|tt?|zz?z?)/), function (fmt) { if (g[fmt]) { return g[fmt]; } else { throw $D.Parsing.Exception(fmt); } } ), // translate separator tokens into token rules _.process(_.rtoken(/^[^dMyhHmstz]+/), // all legal separators function (s) { return _.ignore(_.stoken(s)); } ) ) ), // construct the parser ... function (rules) { return _.process(_.each.apply(null, rules), t.finishExact); } ); // starting rule for general purpose grammar g._start = _.process(_.set([ g.date, g.time, g.expression ], g.generalDelimiter, g.whiteSpace), t.finish); }; g.buildGrammarFormats(); // parsing date format specifiers - ex: "h:m:s tt" // this little guy will generate a custom parser based // on the format string, ex: g.format("h:m:s tt") // check for these formats first g._formats = g.formats([ "\"yyyy-MM-ddTHH:mm:ssZ\"", "yyyy-MM-ddTHH:mm:ss.sz", "yyyy-MM-ddTHH:mm:ssZ", "yyyy-MM-ddTHH:mm:ssz", "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-ddTHH:mmZ", "yyyy-MM-ddTHH:mmz", "yyyy-MM-ddTHH:mm", "ddd, MMM dd, yyyy H:mm:ss tt", "ddd MMM d yyyy HH:mm:ss zzz", "MMddyyyy", "ddMMyyyy", "Mddyyyy", "ddMyyyy", "Mdyyyy", "dMyyyy", "yyyy", "Mdyy", "dMyy", "d" ]); // real starting rule: tries selected formats first, // then general purpose rule g.start = function (s) { try { var r = g._formats.call({}, s); if (r[1].length === 0) { return r; } } catch (e) {} return g._start.call({}, s); }; }()); (function () { var $D = Date; /** * @desc Converts the specified string value into its JavaScript Date equivalent using CultureInfo specific format information. * * Example

	///////////
	// Dates //
	///////////

	// 15-Oct-2004
	var d1 = Date.parse("10/15/2004");

	// 15-Oct-2004
	var d1 = Date.parse("15-Oct-2004");

	// 15-Oct-2004
	var d1 = Date.parse("2004.10.15");

	//Fri Oct 15, 2004
	var d1 = Date.parse("Fri Oct 15, 2004");

	///////////
	// Times //
	///////////

	// Today at 10 PM.
	var d1 = Date.parse("10 PM");

	// Today at 10:30 PM.
	var d1 = Date.parse("10:30 P.M.");

	// Today at 6 AM.
	var d1 = Date.parse("06am");

	/////////////////////
	// Dates and Times //
	/////////////////////

	// 8-July-2004 @ 10:30 PM
	var d1 = Date.parse("July 8th, 2004, 10:30 PM");

	// 1-July-2004 @ 10:30 PM
	var d1 = Date.parse("2004-07-01T22:30:00");

	////////////////////
	// Relative Dates //
	////////////////////

	// Returns today's date. The string "today" is culture specific.
	var d1 = Date.parse("today");

	// Returns yesterday's date. The string "yesterday" is culture specific.
	var d1 = Date.parse("yesterday");

	// Returns the date of the next thursday.
	var d1 = Date.parse("Next thursday");

	// Returns the date of the most previous monday.
	var d1 = Date.parse("last monday");

	// Returns today's day + one year.
	var d1 = Date.parse("next year");

	///////////////
	// Date Math //
	///////////////

	// Today + 2 days
	var d1 = Date.parse("t+2");

	// Today + 2 days
	var d1 = Date.parse("today + 2 days");

	// Today + 3 months
	var d1 = Date.parse("t+3m");

	// Today - 1 year
	var d1 = Date.parse("today - 1 year");

	// Today - 1 year
	var d1 = Date.parse("t-1y"); 


	/////////////////////////////
	// Partial Dates and Times //
	/////////////////////////////

	// July 15th of this year.
	var d1 = Date.parse("July 15");

	// 15th day of current day and year.
	var d1 = Date.parse("15");

	// July 1st of current year at 10pm.
	var d1 = Date.parse("7/1 10pm");
	
* * @param {String} The string value to convert into a Date object [Required] * @return {Date} A Date object or null if the string cannot be converted into a Date. */ var parseUtils = { removeOrds: function (s) { ords = s.match(/\b(\d+)(?:st|nd|rd|th)\b/); // find ordinal matches s = ((ords && ords.length === 2) ? s.replace(ords[0], ords[1]) : s); return s; }, grammarParser: function (s) { var r = null; try { r = $D.Grammar.start.call({}, s.replace(/^\s*(\S*(\s+\S+)*)\s*$/, "$1")); } catch (e) { return null; } return ((r[1].length === 0) ? r[0] : null); }, nativeFallback: function(s) { var t; try { // ok we haven't parsed it, last ditch attempt with the built-in parser. t = Date._parse(s); return (t || t === 0) ? new Date(t) : null; } catch (e) { return null; } } }; function parse (s) { var d; if (!s) { return null; } if (s instanceof Date) { return s.clone(); } if (s.length >= 4 && s.charAt(0) !== "0" && s.charAt(0) !== "+"&& s.charAt(0) !== "-") { // ie: 2004 will pass, 0800 won't. // Start with specific formats d = $D.Parsing.ISO.parse(s) || $D.Parsing.Numeric.parse(s); } if (d instanceof Date && !isNaN(d.getTime())) { return d; } else { // find ordinal dates (1st, 3rd, 8th, etc and remove them as they cause parsing issues) s = $D.Parsing.Normalizer.parse(parseUtils.removeOrds(s)); d = parseUtils.grammarParser(s); if (d !== null) { return d; } else { return parseUtils.nativeFallback(s); } } } if (!$D._parse) { $D._parse = $D.parse; } $D.parse = parse; Date.getParseFunction = function (fx) { var fns = Date.Grammar.allformats(fx); return function (s) { var r = null; for (var i = 0; i < fns.length; i++) { try { r = fns[i].call({}, s); } catch (e) { continue; } if (r[1].length === 0) { return r[0]; } } return null; }; }; /** * Converts the specified string value into its JavaScript Date equivalent using the specified format {String} or formats {Array} and the CultureInfo specific format information. * The format of the string value must match one of the supplied formats exactly. * * Example

	// 15-Oct-2004
	var d1 = Date.parseExact("10/15/2004", "M/d/yyyy");

	// 15-Oct-2004
	var d1 = Date.parse("15-Oct-2004", "M-ddd-yyyy");

	// 15-Oct-2004
	var d1 = Date.parse("2004.10.15", "yyyy.MM.dd");

	// Multiple formats
	var d1 = Date.parseExact("10/15/2004", ["M/d/yyyy", "MMMM d, yyyy"]);
	
* * @param {String} The string value to convert into a Date object [Required]. * @param {Object} The expected format {String} or an array of expected formats {Array} of the date string [Required]. * @return {Date} A Date object or null if the string cannot be converted into a Date. */ $D.parseExact = function (s, fx) { return $D.getParseFunction(fx)(s); }; }()); (function () { var $D = Date, $P = $D.prototype, // $C = $D.CultureInfo, // not used atm p = function (s, l) { if (!l) { l = 2; } return ("000" + s).slice(l * -1); }; /** * Converts a PHP format string to Java/.NET format string. * A PHP format string can be used with ._format or .format. * A Java/.NET format string can be used with .toString(). * The .parseExact function will only accept a Java/.NET format string * * Example * var f1 = "%m/%d/%y" * var f2 = Date.normalizeFormat(f1); // "MM/dd/yy" * * new Date().format(f1); // "04/13/08" * new Date()._format(f1); // "04/13/08" * new Date().toString(f2); // "04/13/08" * * var date = Date.parseExact("04/13/08", f2); // Sun Apr 13 2008 * * @param {String} A PHP format string consisting of one or more format spcifiers. * @return {String} The PHP format converted to a Java/.NET format string. */ var normalizerSubstitutions = { "d" : "dd", "%d": "dd", "D" : "ddd", "%a": "ddd", "j" : "dddd", "l" : "dddd", "%A": "dddd", "S" : "S", "F" : "MMMM", "%B": "MMMM", "m" : "MM", "%m": "MM", "M" : "MMM", "%b": "MMM", "%h": "MMM", "n" : "M", "Y" : "yyyy", "%Y": "yyyy", "y" : "yy", "%y": "yy", "g" : "h", "%I": "h", "G" : "H", "h" : "hh", "H" : "HH", "%H": "HH", "i" : "mm", "%M": "mm", "s" : "ss", "%S": "ss", "%r": "hh:mm tt", "%R": "H:mm", "%T": "H:mm:ss", "%X": "t", "%x": "d", "%e": "d", "%D": "MM/dd/yy", "%n": "\\n", "%t": "\\t", "e" : "z", "T" : "z", "%z": "z", "%Z": "z", "Z" : "ZZ", "N" : "u", "w" : "u", "%w": "u", "W" : "W", "%V": "W" }; var normalizer = { substitutes: function (m) { return normalizerSubstitutions[m]; }, interpreted: function (m, x) { var y; switch (m) { case "%u": return x.getDay() + 1; case "z": return x.getOrdinalNumber(); case "%j": return p(x.getOrdinalNumber(), 3); case "%U": var d1 = x.clone().set({month: 0, day: 1}).addDays(-1).moveToDayOfWeek(0), d2 = x.clone().addDays(1).moveToDayOfWeek(0, -1); return (d2 < d1) ? "00" : p((d2.getOrdinalNumber() - d1.getOrdinalNumber()) / 7 + 1); case "%W": return p(x.getWeek()); case "t": return $D.getDaysInMonth(x.getFullYear(), x.getMonth()); case "o": case "%G": return x.setWeek(x.getISOWeek()).toString("yyyy"); case "%g": return x._format("%G").slice(-2); case "a": case "%p": return t("tt").toLowerCase(); case "A": return t("tt").toUpperCase(); case "u": return p(x.getMilliseconds(), 3); case "I": return (x.isDaylightSavingTime()) ? 1 : 0; case "O": return x.getUTCOffset(); case "P": y = x.getUTCOffset(); return y.substring(0, y.length - 2) + ":" + y.substring(y.length - 2); case "B": var now = new Date(); return Math.floor(((now.getHours() * 3600) + (now.getMinutes() * 60) + now.getSeconds() + (now.getTimezoneOffset() + 60) * 60) / 86.4); case "c": return x.toISOString().replace(/\"/g, ""); case "U": return $D.strtotime("now"); case "%c": return t("d") + " " + t("t"); case "%C": return Math.floor(x.getFullYear() / 100 + 1); } }, shouldOverrideDefaults: function (m) { switch (m) { case "%e": return true; default: return false; } }, parse: function (m, context) { var formatString, c = context || new Date(); formatString = normalizer.substitutes(m); if (formatString) { return formatString; } formatString = normalizer.interpreted(m, c); if (formatString) { return formatString; } else { return m; } } }; $D.normalizeFormat = function (format, context) { return format.replace(/(%|\\)?.|%%/g, function(t){ return normalizer.parse(t, context); }); }; /** * Format a local Unix timestamp according to locale settings * * Example: * Date.strftime("%m/%d/%y", new Date()); // "04/13/08" * Date.strftime("c", "2008-04-13T17:52:03Z"); // "04/13/08" * * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @param {Number|String} The number representing the number of seconds that have elapsed since January 1, 1970 (local time). * @return {String} A string representation of the current Date object. */ $D.strftime = function (format, time) { var d = Date.parse(time); return d._format(format); }; /** * Parse any textual datetime description into a Unix timestamp. * A Unix timestamp is the number of seconds that have elapsed since January 1, 1970 (midnight UTC/GMT). * * Example: * Date.strtotime("04/13/08"); // 1208044800 * Date.strtotime("1970-01-01T00:00:00Z"); // 0 * * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @param {Object} A string or date object. * @return {String} A string representation of the current Date object. */ $D.strtotime = function (time) { var d = $D.parse(time); return Math.round($D.UTC(d.getUTCFullYear(), d.getUTCMonth(), d.getUTCDate(), d.getUTCHours(), d.getUTCMinutes(), d.getUTCSeconds(), d.getUTCMilliseconds()) / 1000); }; /** * Converts the value of the current Date object to its equivalent string representation using a PHP/Unix style of date format specifiers. * Format Specifiers * Format Description Example * ------ --------------------------------------------------------------------------- ----------------------- * %a abbreviated weekday name according to the current localed "Mon" through "Sun" * %A full weekday name according to the current localed "Sunday" through "Saturday" * %b abbreviated month name according to the current localed "Jan" through "Dec" * %B full month name according to the current locale "January" through "December" * %c preferred date and time representation for the current locale "4/13/2008 12:33 PM" * %C century number (the year divided by 100 and truncated to an integer) "00" to "99" * %d day of the month as a decimal number "01" to "31" * %D same as %m/%d/%y "04/13/08" * %e day of the month as a decimal number, a single digit is preceded by a space "1" to "31" * %g like %G, but without the century "08" * %G The 4-digit year corresponding to the ISO week number (see %V). "2008" * This has the same format and value as %Y, except that if the ISO week number * belongs to the previous or next year, that year is used instead. * %h same as %b "Jan" through "Dec" * %H hour as a decimal number using a 24-hour clock. "00" to "23" * %I hour as a decimal number using a 12-hour clock. "01" to "12" * %j day of the year as a decimal number. "001" to "366" * %m month as a decimal number. "01" to "12" * %M minute as a decimal number. "00" to "59" * %n newline character "\n" * %p either "am" or "pm" according to the given time value, or the "am" or "pm" * corresponding strings for the current locale. * %r time in a.m. and p.m. notation "8:44 PM" * %R time in 24 hour notation "20:44" * %S second as a decimal number "00" to "59" * %t tab character "\t" * %T current time, equal to %H:%M:%S "12:49:11" * %u weekday as a decimal number ["1", "7"], with "1" representing Monday "1" to "7" * %U week number of the current year as a decimal number, starting with the "0" to ("52" or "53") * first Sunday as the first day of the first week * %V The ISO 8601:1988 week number of the current year as a decimal number, "00" to ("52" or "53") * range 01 to 53, where week 1 is the first week that has at least 4 days * in the current year, and with Monday as the first day of the week. * (Use %G or %g for the year component that corresponds to the week number * for the specified timestamp.) * %W week number of the current year as a decimal number, starting with the "00" to ("52" or "53") * first Monday as the first day of the first week * %w day of the week as a decimal, Sunday being "0" "0" to "6" * %x preferred date representation for the current locale without the time "4/13/2008" * %X preferred time representation for the current locale without the date "12:53:05" * %y year as a decimal number without a century "00" "99" * %Y year as a decimal number including the century "2008" * %Z time zone or name or abbreviation "UTC", "EST", "PST" * %z same as %Z * %% a literal "%" characters "%" * d Day of the month, 2 digits with leading zeros "01" to "31" * D A textual representation of a day, three letters "Mon" through "Sun" * j Day of the month without leading zeros "1" to "31" * l A full textual representation of the day of the week (lowercase "L") "Sunday" through "Saturday" * N ISO-8601 numeric representation of the day of the week (added in PHP 5.1.0) "1" (for Monday) through "7" (for Sunday) * S English ordinal suffix for the day of the month, 2 characters "st", "nd", "rd" or "th". Works well with j * w Numeric representation of the day of the week "0" (for Sunday) through "6" (for Saturday) * z The day of the year (starting from "0") "0" through "365" * W ISO-8601 week number of year, weeks starting on Monday "00" to ("52" or "53") * F A full textual representation of a month, such as January or March "January" through "December" * m Numeric representation of a month, with leading zeros "01" through "12" * M A short textual representation of a month, three letters "Jan" through "Dec" * n Numeric representation of a month, without leading zeros "1" through "12" * t Number of days in the given month "28" through "31" * L Whether it's a leap year "1" if it is a leap year, "0" otherwise * o ISO-8601 year number. This has the same value as Y, except that if the "2008" * ISO week number (W) belongs to the previous or next year, that year * is used instead. * Y A full numeric representation of a year, 4 digits "2008" * y A two digit representation of a year "08" * a Lowercase Ante meridiem and Post meridiem "am" or "pm" * A Uppercase Ante meridiem and Post meridiem "AM" or "PM" * B Swatch Internet time "000" through "999" * g 12-hour format of an hour without leading zeros "1" through "12" * G 24-hour format of an hour without leading zeros "0" through "23" * h 12-hour format of an hour with leading zeros "01" through "12" * H 24-hour format of an hour with leading zeros "00" through "23" * i Minutes with leading zeros "00" to "59" * s Seconds, with leading zeros "00" through "59" * u Milliseconds "54321" * e Timezone identifier "UTC", "EST", "PST" * I Whether or not the date is in daylight saving time (uppercase i) "1" if Daylight Saving Time, "0" otherwise * O Difference to Greenwich time (GMT) in hours "+0200", "-0600" * P Difference to Greenwich time (GMT) with colon between hours and minutes "+02:00", "-06:00" * T Timezone abbreviation "UTC", "EST", "PST" * Z Timezone offset in seconds. The offset for timezones west of UTC is "-43200" through "50400" * always negative, and for those east of UTC is always positive. * c ISO 8601 date "2004-02-12T15:19:21+00:00" * r RFC 2822 formatted date "Thu, 21 Dec 2000 16:01:07 +0200" * U Seconds since the Unix Epoch (January 1 1970 00:00:00 GMT) "0" * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @return {String} A string representation of the current Date object. */ var formatReplace = function (context) { return function (m) { var formatString, override = false; if (m.charAt(0) === "\\" || m.substring(0, 2) === "%%") { return m.replace("\\", "").replace("%%", "%"); } override = normalizer.shouldOverrideDefaults(m); formatString = $D.normalizeFormat(m, context); if (formatString) { return context.toString(formatString, override); } }; }; $P._format = function (format) { var formatter = formatReplace(this); if (!format) { return this._toString(); } else { return format.replace(/(%|\\)?.|%%/g, formatter); } }; if (!$P.format) { $P.format = $P._format; } }()); (function () { "use strict"; var gFn = function (attr) { return function () { return this[attr]; }; }; var sFn = function (attr) { return function (val) { this[attr] = val; return this; }; }; var attrs = ["years", "months", "days", "hours", "minutes", "seconds", "milliseconds"]; var addSetFuncs = function (context, attrs) { for (var i = 0; i < attrs.length ; i++) { var $a = attrs[i], $b = $a.slice(0, 1).toUpperCase() + $a.slice(1); context.prototype[$a] = 0; context.prototype["get" + $b] = gFn($a); context.prototype["set" + $b] = sFn($a); } }; /** * new TimeSpan(milliseconds); * new TimeSpan(days, hours, minutes, seconds); * new TimeSpan(days, hours, minutes, seconds, milliseconds); */ var TimeSpan = function (days, hours, minutes, seconds, milliseconds) { if (arguments.length === 1 && typeof days === "number") { var orient = (days < 0) ? -1 : +1; var millsLeft = Math.abs(days); this.setDays(Math.floor(millsLeft / 86400000) * orient); millsLeft = millsLeft % 86400000; this.setHours(Math.floor(millsLeft / 3600000) * orient); millsLeft = millsLeft % 3600000; this.setMinutes(Math.floor(millsLeft / 60000) * orient); millsLeft = millsLeft % 60000; this.setSeconds(Math.floor(millsLeft / 1000) * orient); millsLeft = millsLeft % 1000; this.setMilliseconds(millsLeft * orient); } else { this.set(days, hours, minutes, seconds, milliseconds); } this.getTotalMilliseconds = function () { return (this.getDays() * 86400000) + (this.getHours() * 3600000) + (this.getMinutes() * 60000) + (this.getSeconds() * 1000); }; this.compareTo = function (time) { var t1 = new Date(1970, 1, 1, this.getHours(), this.getMinutes(), this.getSeconds()), t2; if (time === null) { t2 = new Date(1970, 1, 1, 0, 0, 0); } else { t2 = new Date(1970, 1, 1, time.getHours(), time.getMinutes(), time.getSeconds()); } return (t1 < t2) ? -1 : (t1 > t2) ? 1 : 0; }; this.equals = function (time) { return (this.compareTo(time) === 0); }; this.add = function (time) { return (time === null) ? this : this.addSeconds(time.getTotalMilliseconds() / 1000); }; this.subtract = function (time) { return (time === null) ? this : this.addSeconds(-time.getTotalMilliseconds() / 1000); }; this.addDays = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 86400000)); }; this.addHours = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 3600000)); }; this.addMinutes = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 60000)); }; this.addSeconds = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 1000)); }; this.addMilliseconds = function (n) { return new TimeSpan(this.getTotalMilliseconds() + n); }; this.get12HourHour = function () { return (this.getHours() > 12) ? this.getHours() - 12 : (this.getHours() === 0) ? 12 : this.getHours(); }; this.getDesignator = function () { return (this.getHours() < 12) ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator; }; this.toString = function (format) { this._toString = function () { if (this.getDays() !== null && this.getDays() > 0) { return this.getDays() + "." + this.getHours() + ":" + this.p(this.getMinutes()) + ":" + this.p(this.getSeconds()); } else { return this.getHours() + ":" + this.p(this.getMinutes()) + ":" + this.p(this.getSeconds()); } }; this.p = function (s) { return (s.toString().length < 2) ? "0" + s : s; }; var me = this; return format ? format.replace(/dd?|HH?|hh?|mm?|ss?|tt?/g, function (format) { switch (format) { case "d": return me.getDays(); case "dd": return me.p(me.getDays()); case "H": return me.getHours(); case "HH": return me.p(me.getHours()); case "h": return me.get12HourHour(); case "hh": return me.p(me.get12HourHour()); case "m": return me.getMinutes(); case "mm": return me.p(me.getMinutes()); case "s": return me.getSeconds(); case "ss": return me.p(me.getSeconds()); case "t": return ((me.getHours() < 12) ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator).substring(0, 1); case "tt": return (me.getHours() < 12) ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator; } } ) : this._toString(); }; return this; }; addSetFuncs(TimeSpan, attrs.slice(2)); TimeSpan.prototype.set = function (days, hours, minutes, seconds, milliseconds){ this.setDays(days || this.getDays()); this.setHours(hours || this.getHours()); this.setMinutes(minutes || this.getMinutes()); this.setSeconds(seconds || this.getSeconds()); this.setMilliseconds(milliseconds || this.getMilliseconds()); }; /** * Gets the time of day for this date instances. * @return {TimeSpan} TimeSpan */ Date.prototype.getTimeOfDay = function () { return new TimeSpan(0, this.getHours(), this.getMinutes(), this.getSeconds(), this.getMilliseconds()); }; Date.TimeSpan = TimeSpan; if (typeof window !== "undefined" ) { // keeping API compatible for v1.x window.TimeSpan = TimeSpan; } }()); (function () { "use strict"; var attrs = ["years", "months", "days", "hours", "minutes", "seconds", "milliseconds"]; var gFn = function (attr) { return function () { return this[attr]; }; }; var sFn = function (attr) { return function (val) { this[attr] = val; return this; }; }; var addSetFuncs = function (context, attrs) { for (var i = 0; i < attrs.length ; i++) { var $a = attrs[i], $b = $a.slice(0, 1).toUpperCase() + $a.slice(1); context.prototype[$a] = 0; context.prototype["get" + $b] = gFn($a); context.prototype["set" + $b] = sFn($a); } }; var setMonthsAndYears = function (orient, d1, d2, context) { function inc() { d1.addMonths(-orient); context.months++; if (context.months === 12) { context.years++; context.months = 0; } } if (orient === +1) { while (d1 > d2) { inc(); } } else { while (d1 < d2) { inc(); } } context.months--; context.months *= orient; context.years *= orient; }; var adjustForDST = function(orient, startDate, endDate) { var hasDSTMismatch = (false === (startDate.isDaylightSavingTime() === endDate.isDaylightSavingTime())); if (hasDSTMismatch && orient === 1) { startDate.addHours(-1); } else if (hasDSTMismatch) { startDate.addHours(1); } }; /** * TimePeriod(startDate, endDate); * TimePeriod(years, months, days, hours, minutes, seconds, milliseconds); */ var TimePeriod = function (years, months, days, hours, minutes, seconds, milliseconds) { if (arguments.length === 7) { this.set(years, months, days, hours, minutes, seconds, milliseconds); } else if (arguments.length === 2 && arguments[0] instanceof Date && arguments[1] instanceof Date) { var startDate = arguments[0].clone(); var endDate = arguments[1].clone(); var orient = (startDate > endDate) ? +1 : -1; this.dates = { start: arguments[0].clone(), end: arguments[1].clone() }; setMonthsAndYears(orient, startDate, endDate, this); adjustForDST(orient, startDate, endDate); // // TODO - adjust for DST var diff = endDate - startDate; if (diff !== 0) { var ts = new TimeSpan(diff); this.set(this.years, this.months, ts.getDays(), ts.getHours(), ts.getMinutes(), ts.getSeconds(), ts.getMilliseconds()); } } return this; }; // create all the set functions. addSetFuncs(TimePeriod, attrs); TimePeriod.prototype.set = function (years, months, days, hours, minutes, seconds, milliseconds){ this.setYears(years || this.getYears()); this.setMonths(months || this.getMonths()); this.setDays(days || this.getDays()); this.setHours(hours || this.getHours()); this.setMinutes(minutes || this.getMinutes()); this.setSeconds(seconds || this.getSeconds()); this.setMilliseconds(milliseconds || this.getMilliseconds()); }; Date.TimePeriod = TimePeriod; if (typeof window !== "undefined") { // keeping API compatible for v1.x window.TimePeriod = TimePeriod; } }()); ================================================ FILE: build/date-sv-FI.js ================================================ /** * @overview datejs * @version 1.0.0-rc3 * @author Gregory Wild-Smith * @copyright 2015 Gregory Wild-Smith * @license MIT * @homepage https://github.com/abritinthebay/datejs */ /* * DateJS Culture String File * Country Code: sv-FI * Name: Swedish (Finland) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["sv-FI"] = { "name": "sv-FI", "englishName": "Swedish (Finland)", "nativeName": "svenska (Finland)", "Sunday": "söndag", "Monday": "måndag", "Tuesday": "tisdag", "Wednesday": "onsdag", "Thursday": "torsdag", "Friday": "fredag", "Saturday": "lördag", "Sun": "sö", "Mon": "må", "Tue": "ti", "Wed": "on", "Thu": "to", "Fri": "fr", "Sat": "lö", "Su": "sö", "Mo": "må", "Tu": "ti", "We": "on", "Th": "to", "Fr": "fr", "Sa": "lö", "S_Sun_Initial": "s", "M_Mon_Initial": "m", "T_Tue_Initial": "t", "W_Wed_Initial": "o", "T_Thu_Initial": "t", "F_Fri_Initial": "f", "S_Sat_Initial": "l", "January": "januari", "February": "februari", "March": "mars", "April": "april", "May": "maj", "June": "juni", "July": "juli", "August": "augusti", "September": "september", "October": "oktober", "November": "november", "December": "december", "Jan_Abbr": "jan", "Feb_Abbr": "feb", "Mar_Abbr": "mar", "Apr_Abbr": "apr", "May_Abbr": "maj", "Jun_Abbr": "jun", "Jul_Abbr": "jul", "Aug_Abbr": "aug", "Sep_Abbr": "sep", "Oct_Abbr": "okt", "Nov_Abbr": "nov", "Dec_Abbr": "dec", "AM": "", "PM": "", "firstDayOfWeek": 1, "twoDigitYearMax": 2029, "mdy": "dmy", "M/d/yyyy": "d.M.yyyy", "dddd, MMMM dd, yyyy": "'den 'd MMMM yyyy", "h:mm tt": "HH:mm", "h:mm:ss tt": "HH:mm:ss", "dddd, MMMM dd, yyyy h:mm:ss tt": "'den 'd MMMM yyyy HH:mm:ss", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "'den 'd MMMM", "MMMM, yyyy": "MMMM yyyy", "/jan(uary)?/": "jan(uari)?", "/feb(ruary)?/": "feb(ruari)?", "/mar(ch)?/": "mar(s)?", "/apr(il)?/": "apr(il)?", "/may/": "maj", "/jun(e)?/": "jun(i)?", "/jul(y)?/": "jul(i)?", "/aug(ust)?/": "aug(usti)?", "/sep(t(ember)?)?/": "sep(t(ember)?)?", "/oct(ober)?/": "okt(ober)?", "/nov(ember)?/": "nov(ember)?", "/dec(ember)?/": "dec(ember)?", "/^su(n(day)?)?/": "^söndag", "/^mo(n(day)?)?/": "^måndag", "/^tu(e(s(day)?)?)?/": "^tisdag", "/^we(d(nesday)?)?/": "^onsdag", "/^th(u(r(s(day)?)?)?)?/": "^torsdag", "/^fr(i(day)?)?/": "^fredag", "/^sa(t(urday)?)?/": "^lördag", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "sv-FI"; /** * @overview datejs * @version 1.0.0-rc3 * @author Gregory Wild-Smith * @copyright 2015 Gregory Wild-Smith * @license MIT * @homepage https://github.com/abritinthebay/datejs */(function () { var $D = Date; var lang = Date.CultureStrings ? Date.CultureStrings.lang : null; var loggedKeys = {}; // for debug purposes. var getText = { getFromKey: function (key, countryCode) { var output; if (Date.CultureStrings && Date.CultureStrings[countryCode] && Date.CultureStrings[countryCode][key]) { output = Date.CultureStrings[countryCode][key]; } else { output = getText.buildFromDefault(key); } if (key.charAt(0) === "/") { // Assume it's a regex output = getText.buildFromRegex(key, countryCode); } return output; }, getFromObjectValues: function (obj, countryCode) { var key, output = {}; for(key in obj) { if (obj.hasOwnProperty(key)) { output[key] = getText.getFromKey(obj[key], countryCode); } } return output; }, getFromObjectKeys: function (obj, countryCode) { var key, output = {}; for(key in obj) { if (obj.hasOwnProperty(key)) { output[getText.getFromKey(key, countryCode)] = obj[key]; } } return output; }, getFromArray: function (arr, countryCode) { var output = []; for (var i=0; i < arr.length; i++){ if (i in arr) { output[i] = getText.getFromKey(arr[i], countryCode); } } return output; }, buildFromDefault: function (key) { var output, length, split, last; switch(key) { case "name": output = "en-US"; break; case "englishName": output = "English (United States)"; break; case "nativeName": output = "English (United States)"; break; case "twoDigitYearMax": output = 2049; break; case "firstDayOfWeek": output = 0; break; default: output = key; split = key.split("_"); length = split.length; if (length > 1 && key.charAt(0) !== "/") { // if the key isn't a regex and it has a split. last = split[(length - 1)].toLowerCase(); if (last === "initial" || last === "abbr") { output = split[0]; } } break; } return output; }, buildFromRegex: function (key, countryCode) { var output; if (Date.CultureStrings && Date.CultureStrings[countryCode] && Date.CultureStrings[countryCode][key]) { output = new RegExp(Date.CultureStrings[countryCode][key], "i"); } else { output = new RegExp(key.replace(new RegExp("/", "g"),""), "i"); } return output; } }; var shallowMerge = function (obj1, obj2) { for (var attrname in obj2) { if (obj2.hasOwnProperty(attrname)) { obj1[attrname] = obj2[attrname]; } } }; var __ = function (key, language) { var countryCode = (language) ? language : lang; loggedKeys[key] = key; if (typeof key === "object") { if (key instanceof Array) { return getText.getFromArray(key, countryCode); } else { return getText.getFromObjectKeys(key, countryCode); } } else { return getText.getFromKey(key, countryCode); } }; var loadI18nScript = function (code) { // paatterned after jQuery's getScript. var url = Date.Config.i18n + code + ".js"; var head = document.getElementsByTagName("head")[0] || document.documentElement; var script = document.createElement("script"); script.src = url; var completed = false; var events = { done: function (){} // placeholder function }; // Attach handlers for all browsers script.onload = script.onreadystatechange = function() { if ( !completed && (!this.readyState || this.readyState === "loaded" || this.readyState === "complete") ) { events.done(); head.removeChild(script); } }; setTimeout(function() { head.insertBefore(script, head.firstChild); }, 0); // allows return to execute first return { done: function (cb) { events.done = function() { if (cb) { setTimeout(cb,0); } }; } }; }; var buildInfo = { buildFromMethodHash: function (obj) { var key; for(key in obj) { if (obj.hasOwnProperty(key)) { obj[key] = buildInfo[obj[key]](); } } return obj; }, timeZoneDST: function () { var DST = { "CHADT": "+1345", "NZDT": "+1300", "AEDT": "+1100", "ACDT": "+1030", "AZST": "+0500", "IRDT": "+0430", "EEST": "+0300", "CEST": "+0200", "BST": "+0100", "PMDT": "-0200", "ADT": "-0300", "NDT": "-0230", "EDT": "-0400", "CDT": "-0500", "MDT": "-0600", "PDT": "-0700", "AKDT": "-0800", "HADT": "-0900" }; return __(DST); }, timeZoneStandard: function () { var standard = { "LINT": "+1400", "TOT": "+1300", "CHAST": "+1245", "NZST": "+1200", "NFT": "+1130", "SBT": "+1100", "AEST": "+1000", "ACST": "+0930", "JST": "+0900", "CWST": "+0845", "CT": "+0800", "ICT": "+0700", "MMT": "+0630", "BST": "+0600", "NPT": "+0545", "IST": "+0530", "PKT": "+0500", "AFT": "+0430", "MSK": "+0400", "IRST": "+0330", "FET": "+0300", "EET": "+0200", "CET": "+0100", "GMT": "+0000", "UTC": "+0000", "CVT": "-0100", "GST": "-0200", "BRT": "-0300", "NST": "-0330", "AST": "-0400", "EST": "-0500", "CST": "-0600", "MST": "-0700", "PST": "-0800", "AKST": "-0900", "MIT": "-0930", "HST": "-1000", "SST": "-1100", "BIT": "-1200" }; return __(standard); }, timeZones: function (data) { var zone; data.timezones = []; for (zone in data.abbreviatedTimeZoneStandard) { if (data.abbreviatedTimeZoneStandard.hasOwnProperty(zone)) { data.timezones.push({ name: zone, offset: data.abbreviatedTimeZoneStandard[zone]}); } } for (zone in data.abbreviatedTimeZoneDST) { if (data.abbreviatedTimeZoneDST.hasOwnProperty(zone)) { data.timezones.push({ name: zone, offset: data.abbreviatedTimeZoneDST[zone], dst: true}); } } return data.timezones; }, days: function () { return __(["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"]); }, dayAbbr: function () { return __(["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"]); }, dayShortNames: function () { return __(["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"]); }, dayFirstLetters: function () { return __(["S_Sun_Initial", "M_Mon_Initial", "T_Tues_Initial", "W_Wed_Initial", "T_Thu_Initial", "F_Fri_Initial", "S_Sat_Initial"]); }, months: function () { return __(["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"]); }, monthAbbr: function () { return __(["Jan_Abbr", "Feb_Abbr", "Mar_Abbr", "Apr_Abbr", "May_Abbr", "Jun_Abbr", "Jul_Abbr", "Aug_Abbr", "Sep_Abbr", "Oct_Abbr", "Nov_Abbr", "Dec_Abbr"]); }, formatPatterns: function () { return getText.getFromObjectValues({ shortDate: "M/d/yyyy", longDate: "dddd, MMMM dd, yyyy", shortTime: "h:mm tt", longTime: "h:mm:ss tt", fullDateTime: "dddd, MMMM dd, yyyy h:mm:ss tt", sortableDateTime: "yyyy-MM-ddTHH:mm:ss", universalSortableDateTime: "yyyy-MM-dd HH:mm:ssZ", rfc1123: "ddd, dd MMM yyyy HH:mm:ss", monthDay: "MMMM dd", yearMonth: "MMMM, yyyy" }, Date.i18n.currentLanguage()); }, regex: function () { return getText.getFromObjectValues({ inTheMorning: "/( in the )(morn(ing)?)\\b/", thisMorning: "/(this )(morn(ing)?)\\b/", amThisMorning: "/(\b\\d(am)? )(this )(morn(ing)?)/", inTheEvening: "/( in the )(even(ing)?)\\b/", thisEvening: "/(this )(even(ing)?)\\b/", pmThisEvening: "/(\b\\d(pm)? )(this )(even(ing)?)/", jan: "/jan(uary)?/", feb: "/feb(ruary)?/", mar: "/mar(ch)?/", apr: "/apr(il)?/", may: "/may/", jun: "/jun(e)?/", jul: "/jul(y)?/", aug: "/aug(ust)?/", sep: "/sep(t(ember)?)?/", oct: "/oct(ober)?/", nov: "/nov(ember)?/", dec: "/dec(ember)?/", sun: "/^su(n(day)?)?/", mon: "/^mo(n(day)?)?/", tue: "/^tu(e(s(day)?)?)?/", wed: "/^we(d(nesday)?)?/", thu: "/^th(u(r(s(day)?)?)?)?/", fri: "/fr(i(day)?)?/", sat: "/^sa(t(urday)?)?/", future: "/^next/", past: "/^last|past|prev(ious)?/", add: "/^(\\+|aft(er)?|from|hence)/", subtract: "/^(\\-|bef(ore)?|ago)/", yesterday: "/^yes(terday)?/", today: "/^t(od(ay)?)?/", tomorrow: "/^tom(orrow)?/", now: "/^n(ow)?/", millisecond: "/^ms|milli(second)?s?/", second: "/^sec(ond)?s?/", minute: "/^mn|min(ute)?s?/", hour: "/^h(our)?s?/", week: "/^w(eek)?s?/", month: "/^m(onth)?s?/", day: "/^d(ay)?s?/", year: "/^y(ear)?s?/", shortMeridian: "/^(a|p)/", longMeridian: "/^(a\\.?m?\\.?|p\\.?m?\\.?)/", timezone: "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/", ordinalSuffix: "/^\\s*(st|nd|rd|th)/", timeContext: "/^\\s*(\\:|a(?!u|p)|p)/" }, Date.i18n.currentLanguage()); } }; var CultureInfo = function () { var info = getText.getFromObjectValues({ name: "name", englishName: "englishName", nativeName: "nativeName", amDesignator: "AM", pmDesignator: "PM", firstDayOfWeek: "firstDayOfWeek", twoDigitYearMax: "twoDigitYearMax", dateElementOrder: "mdy" }, Date.i18n.currentLanguage()); var constructedInfo = buildInfo.buildFromMethodHash({ dayNames: "days", abbreviatedDayNames: "dayAbbr", shortestDayNames: "dayShortNames", firstLetterDayNames: "dayFirstLetters", monthNames: "months", abbreviatedMonthNames: "monthAbbr", formatPatterns: "formatPatterns", regexPatterns: "regex", abbreviatedTimeZoneDST: "timeZoneDST", abbreviatedTimeZoneStandard: "timeZoneStandard" }); shallowMerge(info, constructedInfo); buildInfo.timeZones(info); return info; }; $D.i18n = { __: function (key, lang) { return __(key, lang); }, currentLanguage: function () { return lang || "en-US"; }, setLanguage: function (code, force, cb) { var async = false; if (force || code === "en-US" || (!!Date.CultureStrings && !!Date.CultureStrings[code])) { lang = code; Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings.lang = code; Date.CultureInfo = new CultureInfo(); } else { if (!(!!Date.CultureStrings && !!Date.CultureStrings[code])) { if (typeof exports !== "undefined" && this.exports !== exports) { // we're in a Node enviroment, load it using require try { require("../i18n/" + code + ".js"); lang = code; Date.CultureStrings.lang = code; Date.CultureInfo = new CultureInfo(); } catch (e) { // var str = "The language for '" + code + "' could not be loaded by Node. It likely does not exist."; throw new Error("The DateJS IETF language tag '" + code + "' could not be loaded by Node. It likely does not exist."); } } else if (Date.Config && Date.Config.i18n) { // we know the location of the files, so lets load them async = true; loadI18nScript(code).done(function(){ lang = code; Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings.lang = code; Date.CultureInfo = new CultureInfo(); $D.Parsing.Normalizer.buildReplaceData(); // because this is async if ($D.Grammar) { $D.Grammar.buildGrammarFormats(); // so we can parse those strings... } if (cb) { setTimeout(cb,0); } }); } else { Date.console.error("The DateJS IETF language tag '" + code + "' is not available and has not been loaded."); return false; } } } $D.Parsing.Normalizer.buildReplaceData(); // rebuild normalizer strings if ($D.Grammar) { $D.Grammar.buildGrammarFormats(); // so we can parse those strings... } if (!async && cb) { setTimeout(cb,0); } }, getLoggedKeys: function () { return loggedKeys; }, updateCultureInfo: function () { Date.CultureInfo = new CultureInfo(); } }; $D.i18n.updateCultureInfo(); // run automatically }()); (function () { var $D = Date, $P = $D.prototype, p = function (s, l) { if (!l) { l = 2; } return ("000" + s).slice(l * -1); }; if (typeof window !== "undefined" && typeof window.console !== "undefined" && typeof window.console.log !== "undefined") { $D.console = console; // used only to raise non-critical errors if available } else { // set mock so we don't give errors. $D.console = { log: function(){}, error: function(){} }; } $D.Config = $D.Config || {}; $D.initOverloads = function() { /** * Overload of Date.now. Allows an alternate call for Date.now where it returns the * current Date as an object rather than just milliseconds since the Unix Epoch. * * Also provides an implementation of now() for browsers (IE<9) that don't have it. * * Backwards compatible so with work with either: * Date.now() [returns ms] * or * Date.now(true) [returns Date] */ if (!$D.now) { $D._now = function now() { return new Date().getTime(); }; } else if (!$D._now) { $D._now = $D.now; } $D.now = function (returnObj) { if (returnObj) { return $D.present(); } else { return $D._now(); } }; if ( !$P.toISOString ) { $P.toISOString = function() { return this.getUTCFullYear() + "-" + p(this.getUTCMonth() + 1) + "-" + p(this.getUTCDate()) + "T" + p(this.getUTCHours()) + ":" + p(this.getUTCMinutes()) + ":" + p(this.getUTCSeconds()) + "." + String( (this.getUTCMilliseconds()/1000).toFixed(3)).slice(2, 5) + "Z"; }; } // private if ( $P._toString === undefined ){ $P._toString = $P.toString; } }; $D.initOverloads(); /** * Gets a date that is set to the current date. The time is set to the start of the day (00:00 or 12:00 AM). * @return {Date} The current date. */ $D.today = function () { return new Date().clearTime(); }; /** * Gets a date that is set to the current date and time (same as new Date, but chainable) * @return {Date} The current date. */ $D.present = function () { return new Date(); }; /** * Compares the first date to the second date and returns an number indication of their relative values. * @param {Date} First Date object to compare [Required]. * @param {Date} Second Date object to compare to [Required]. * @return {Number} -1 = date1 is lessthan date2. 0 = values are equal. 1 = date1 is greaterthan date2. */ $D.compare = function (date1, date2) { if (isNaN(date1) || isNaN(date2)) { throw new Error(date1 + " - " + date2); } else if (date1 instanceof Date && date2 instanceof Date) { return (date1 < date2) ? -1 : (date1 > date2) ? 1 : 0; } else { throw new TypeError(date1 + " - " + date2); } }; /** * Compares the first Date object to the second Date object and returns true if they are equal. * @param {Date} First Date object to compare [Required] * @param {Date} Second Date object to compare to [Required] * @return {Boolean} true if dates are equal. false if they are not equal. */ $D.equals = function (date1, date2) { return (date1.compareTo(date2) === 0); }; /** * Gets the language appropriate day name when given the day number(0-6) * eg - 0 == Sunday * @return {String} The day name */ $D.getDayName = function (n) { return Date.CultureInfo.dayNames[n]; }; /** * Gets the day number (0-6) if given a CultureInfo specific string which is a valid dayName, abbreviatedDayName or shortestDayName (two char). * @param {String} The name of the day (eg. "Monday, "Mon", "tuesday", "tue", "We", "we"). * @return {Number} The day number */ $D.getDayNumberFromName = function (name) { var n = Date.CultureInfo.dayNames, m = Date.CultureInfo.abbreviatedDayNames, o = Date.CultureInfo.shortestDayNames, s = name.toLowerCase(); for (var i = 0; i < n.length; i++) { if (n[i].toLowerCase() === s || m[i].toLowerCase() === s || o[i].toLowerCase() === s) { return i; } } return -1; }; /** * Gets the month number (0-11) if given a Culture Info specific string which is a valid monthName or abbreviatedMonthName. * @param {String} The name of the month (eg. "February, "Feb", "october", "oct"). * @return {Number} The day number */ $D.getMonthNumberFromName = function (name) { var n = Date.CultureInfo.monthNames, m = Date.CultureInfo.abbreviatedMonthNames, s = name.toLowerCase(); for (var i = 0; i < n.length; i++) { if (n[i].toLowerCase() === s || m[i].toLowerCase() === s) { return i; } } return -1; }; /** * Gets the language appropriate month name when given the month number(0-11) * eg - 0 == January * @return {String} The month name */ $D.getMonthName = function (n) { return Date.CultureInfo.monthNames[n]; }; /** * Determines if the current date instance is within a LeapYear. * @param {Number} The year. * @return {Boolean} true if date is within a LeapYear, otherwise false. */ $D.isLeapYear = function (year) { return ((year % 4 === 0 && year % 100 !== 0) || year % 400 === 0); }; /** * Gets the number of days in the month, given a year and month value. Automatically corrects for LeapYear. * @param {Number} The year. * @param {Number} The month (0-11). * @return {Number} The number of days in the month. */ $D.getDaysInMonth = function (year, month) { if (!month && $D.validateMonth(year)) { month = year; year = Date.today().getFullYear(); } return [31, ($D.isLeapYear(year) ? 29 : 28), 31, 30, 31, 30, 31, 31, 30, 31, 30, 31][month]; }; $P.getDaysInMonth = function () { return $D.getDaysInMonth(this.getFullYear(), this.getMonth()); }; $D.getTimezoneAbbreviation = function (offset, dst) { var p, n = (dst || false) ? Date.CultureInfo.abbreviatedTimeZoneDST : Date.CultureInfo.abbreviatedTimeZoneStandard; for (p in n) { if (n.hasOwnProperty(p)) { if (n[p] === offset) { return p; } } } return null; }; $D.getTimezoneOffset = function (name, dst) { var i, a =[], z = Date.CultureInfo.timezones; if (!name) { name = (new Date()).getTimezone();} for (i = 0; i < z.length; i++) { if (z[i].name === name.toUpperCase()) { a.push(i); } } if (!z[a[0]]) { return null; } if (a.length === 1 || !dst) { return z[a[0]].offset; } else { for (i=0; i < a.length; i++) { if (z[a[i]].dst) { return z[a[i]].offset; } } } }; $D.getQuarter = function (d) { d = d || new Date(); // If no date supplied, use today var q = [1,2,3,4]; return q[Math.floor(d.getMonth() / 3)]; // ~~~ is a bitwise op. Faster than Math.floor }; $D.getDaysLeftInQuarter = function (d) { d = d || new Date(); var qEnd = new Date(d); qEnd.setMonth(qEnd.getMonth() + 3 - qEnd.getMonth() % 3, 0); return Math.floor((qEnd - d) / 8.64e7); }; // private var validate = function (n, min, max, name) { name = name ? name : "Object"; if (typeof n === "undefined") { return false; } else if (typeof n !== "number") { throw new TypeError(n + " is not a Number."); } else if (n < min || n > max) { // As failing validation is *not* an exceptional circumstance // lets not throw a RangeError Exception here. // It's semantically correct but it's not sensible. return false; } return true; }; /** * Validates the number is within an acceptable range for milliseconds [0-999]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateMillisecond = function (value) { return validate(value, 0, 999, "millisecond"); }; /** * Validates the number is within an acceptable range for seconds [0-59]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateSecond = function (value) { return validate(value, 0, 59, "second"); }; /** * Validates the number is within an acceptable range for minutes [0-59]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateMinute = function (value) { return validate(value, 0, 59, "minute"); }; /** * Validates the number is within an acceptable range for hours [0-23]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateHour = function (value) { return validate(value, 0, 23, "hour"); }; /** * Validates the number is within an acceptable range for the days in a month [0-MaxDaysInMonth]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateDay = function (value, year, month) { if (year === undefined || year === null || month === undefined || month === null) { return false;} return validate(value, 1, $D.getDaysInMonth(year, month), "day"); }; /** * Validates the number is within an acceptable range for months [0-11]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateWeek = function (value) { return validate(value, 0, 53, "week"); }; /** * Validates the number is within an acceptable range for months [0-11]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateMonth = function (value) { return validate(value, 0, 11, "month"); }; /** * Validates the number is within an acceptable range for years. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateYear = function (value) { /** * Per ECMAScript spec the range of times supported by Date objects is * exactly -100,000,000 days to +100,000,000 days measured relative to * midnight at the beginning of 01 January, 1970 UTC. * This gives a range of 8,640,000,000,000,000 milliseconds to either * side of 01 January, 1970 UTC. * * Earliest possible date: Tue, 20 Apr 271,822 B.C. 00:00:00 UTC * Latest possible date: Sat, 13 Sep 275,760 00:00:00 UTC */ return validate(value, -271822, 275760, "year"); }; $D.validateTimezone = function(value) { var timezones = {"ACDT":1,"ACST":1,"ACT":1,"ADT":1,"AEDT":1,"AEST":1,"AFT":1,"AKDT":1,"AKST":1,"AMST":1,"AMT":1,"ART":1,"AST":1,"AWDT":1,"AWST":1,"AZOST":1,"AZT":1,"BDT":1,"BIOT":1,"BIT":1,"BOT":1,"BRT":1,"BST":1,"BTT":1,"CAT":1,"CCT":1,"CDT":1,"CEDT":1,"CEST":1,"CET":1,"CHADT":1,"CHAST":1,"CHOT":1,"ChST":1,"CHUT":1,"CIST":1,"CIT":1,"CKT":1,"CLST":1,"CLT":1,"COST":1,"COT":1,"CST":1,"CT":1,"CVT":1,"CWST":1,"CXT":1,"DAVT":1,"DDUT":1,"DFT":1,"EASST":1,"EAST":1,"EAT":1,"ECT":1,"EDT":1,"EEDT":1,"EEST":1,"EET":1,"EGST":1,"EGT":1,"EIT":1,"EST":1,"FET":1,"FJT":1,"FKST":1,"FKT":1,"FNT":1,"GALT":1,"GAMT":1,"GET":1,"GFT":1,"GILT":1,"GIT":1,"GMT":1,"GST":1,"GYT":1,"HADT":1,"HAEC":1,"HAST":1,"HKT":1,"HMT":1,"HOVT":1,"HST":1,"ICT":1,"IDT":1,"IOT":1,"IRDT":1,"IRKT":1,"IRST":1,"IST":1,"JST":1,"KGT":1,"KOST":1,"KRAT":1,"KST":1,"LHST":1,"LINT":1,"MAGT":1,"MART":1,"MAWT":1,"MDT":1,"MET":1,"MEST":1,"MHT":1,"MIST":1,"MIT":1,"MMT":1,"MSK":1,"MST":1,"MUT":1,"MVT":1,"MYT":1,"NCT":1,"NDT":1,"NFT":1,"NPT":1,"NST":1,"NT":1,"NUT":1,"NZDT":1,"NZST":1,"OMST":1,"ORAT":1,"PDT":1,"PET":1,"PETT":1,"PGT":1,"PHOT":1,"PHT":1,"PKT":1,"PMDT":1,"PMST":1,"PONT":1,"PST":1,"PYST":1,"PYT":1,"RET":1,"ROTT":1,"SAKT":1,"SAMT":1,"SAST":1,"SBT":1,"SCT":1,"SGT":1,"SLST":1,"SRT":1,"SST":1,"SYOT":1,"TAHT":1,"THA":1,"TFT":1,"TJT":1,"TKT":1,"TLT":1,"TMT":1,"TOT":1,"TVT":1,"UCT":1,"ULAT":1,"UTC":1,"UYST":1,"UYT":1,"UZT":1,"VET":1,"VLAT":1,"VOLT":1,"VOST":1,"VUT":1,"WAKT":1,"WAST":1,"WAT":1,"WEDT":1,"WEST":1,"WET":1,"WST":1,"YAKT":1,"YEKT":1,"Z":1}; return (timezones[value] === 1); }; $D.validateTimezoneOffset= function(value) { // timezones go from +14hrs to -12hrs, the +X hours are negative offsets. return (value > -841 && value < 721); }; }()); (function () { var $D = Date, $P = $D.prototype, p = function (s, l) { if (!l) { l = 2; } return ("000" + s).slice(l * -1); }; var validateConfigObject = function (obj) { var result = {}, self = this, prop, testFunc; testFunc = function (prop, func, value) { if (prop === "day") { var month = (obj.month !== undefined) ? obj.month : self.getMonth(); var year = (obj.year !== undefined) ? obj.year : self.getFullYear(); return $D[func](value, year, month); } else { return $D[func](value); } }; for (prop in obj) { if (Object.prototype.hasOwnProperty.call(obj, prop)) { var func = "validate" + prop.charAt(0).toUpperCase() + prop.slice(1); if ($D[func] && obj[prop] !== null && testFunc(prop, func, obj[prop])) { result[prop] = obj[prop]; } } } return result; }; /** * Resets the time of this Date object to 12:00 AM (00:00), which is the start of the day. * @param {Boolean} .clone() this date instance before clearing Time * @return {Date} this */ $P.clearTime = function () { this.setHours(0); this.setMinutes(0); this.setSeconds(0); this.setMilliseconds(0); return this; }; /** * Resets the time of this Date object to the current time ('now'). * @return {Date} this */ $P.setTimeToNow = function () { var n = new Date(); this.setHours(n.getHours()); this.setMinutes(n.getMinutes()); this.setSeconds(n.getSeconds()); this.setMilliseconds(n.getMilliseconds()); return this; }; /** * Returns a new Date object that is an exact date and time copy of the original instance. * @return {Date} A new Date instance */ $P.clone = function () { return new Date(this.getTime()); }; /** * Compares this instance to a Date object and returns an number indication of their relative values. * @param {Date} Date object to compare [Required] * @return {Number} -1 = this is lessthan date. 0 = values are equal. 1 = this is greaterthan date. */ $P.compareTo = function (date) { return Date.compare(this, date); }; /** * Compares this instance to another Date object and returns true if they are equal. * @param {Date} Date object to compare. If no date to compare, new Date() [now] is used. * @return {Boolean} true if dates are equal. false if they are not equal. */ $P.equals = function (date) { return Date.equals(this, (date !== undefined ? date : new Date())); }; /** * Determines if this instance is between a range of two dates or equal to either the start or end dates. * @param {Date} Start of range [Required] * @param {Date} End of range [Required] * @return {Boolean} true is this is between or equal to the start and end dates, else false */ $P.between = function (start, end) { return this.getTime() >= start.getTime() && this.getTime() <= end.getTime(); }; /** * Determines if this date occurs after the date to compare to. * @param {Date} Date object to compare. If no date to compare, new Date() ("now") is used. * @return {Boolean} true if this date instance is greater than the date to compare to (or "now"), otherwise false. */ $P.isAfter = function (date) { return this.compareTo(date || new Date()) === 1; }; /** * Determines if this date occurs before the date to compare to. * @param {Date} Date object to compare. If no date to compare, new Date() ("now") is used. * @return {Boolean} true if this date instance is less than the date to compare to (or "now"). */ $P.isBefore = function (date) { return (this.compareTo(date || new Date()) === -1); }; /** * Determines if the current Date instance occurs today. * @return {Boolean} true if this date instance is 'today', otherwise false. */ /** * Determines if the current Date instance occurs on the same Date as the supplied 'date'. * If no 'date' to compare to is provided, the current Date instance is compared to 'today'. * @param {date} Date object to compare. If no date to compare, the current Date ("now") is used. * @return {Boolean} true if this Date instance occurs on the same Day as the supplied 'date'. */ $P.isToday = $P.isSameDay = function (date) { return this.clone().clearTime().equals((date || new Date()).clone().clearTime()); }; /** * Adds the specified number of milliseconds to this instance. * @param {Number} The number of milliseconds to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addMilliseconds = function (value) { if (!value) { return this; } this.setTime(this.getTime() + value * 1); return this; }; /** * Adds the specified number of seconds to this instance. * @param {Number} The number of seconds to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addSeconds = function (value) { if (!value) { return this; } return this.addMilliseconds(value * 1000); }; /** * Adds the specified number of seconds to this instance. * @param {Number} The number of seconds to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addMinutes = function (value) { if (!value) { return this; } return this.addMilliseconds(value * 60000); // 60*1000 }; /** * Adds the specified number of hours to this instance. * @param {Number} The number of hours to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addHours = function (value) { if (!value) { return this; } return this.addMilliseconds(value * 3600000); // 60*60*1000 }; /** * Adds the specified number of days to this instance. * @param {Number} The number of days to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addDays = function (value) { if (!value) { return this; } this.setDate(this.getDate() + value * 1); return this; }; /** * Adds the specified number of weekdays (ie - not sat or sun) to this instance. * @param {Number} The number of days to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addWeekdays = function (value) { if (!value) { return this; } var day = this.getDay(); var weeks = (Math.ceil(Math.abs(value)/7)); if (day === 0 || day === 6) { if (value > 0) { this.next().monday(); this.addDays(-1); day = this.getDay(); } } if (value < 0) { while (value < 0) { this.addDays(-1); day = this.getDay(); if (day !== 0 && day !== 6) { value++; } } return this; } else if (value > 5 || (6-day) <= value) { value = value + (weeks * 2); } return this.addDays(value); }; /** * Adds the specified number of weeks to this instance. * @param {Number} The number of weeks to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addWeeks = function (value) { if (!value) { return this; } return this.addDays(value * 7); }; /** * Adds the specified number of months to this instance. * @param {Number} The number of months to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addMonths = function (value) { if (!value) { return this; } var n = this.getDate(); this.setDate(1); this.setMonth(this.getMonth() + value * 1); this.setDate(Math.min(n, $D.getDaysInMonth(this.getFullYear(), this.getMonth()))); return this; }; $P.addQuarters = function (value) { if (!value) { return this; } // note this will take you to the same point in the quarter as you are now. // i.e. - if you are 15 days into the quarter you'll be 15 days into the resulting one. // bonus: this allows adding fractional quarters return this.addMonths(value * 3); }; /** * Adds the specified number of years to this instance. * @param {Number} The number of years to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addYears = function (value) { if (!value) { return this; } return this.addMonths(value * 12); }; /** * Adds (or subtracts) to the value of the years, months, weeks, days, hours, minutes, seconds, milliseconds of the date instance using given configuration object. Positive and Negative values allowed. * Example

	Date.today().add( { days: 1, months: 1 } )

	new Date().add( { years: -1 } )
	
* @param {Object} Configuration object containing attributes (months, days, etc.) * @return {Date} this */ $P.add = function (config) { if (typeof config === "number") { this._orient = config; return this; } var x = config; if (x.day) { // If we should be a different date than today (eg: for 'tomorrow -1d', etc). // Should only effect parsing, not direct usage (eg, Finish and FinishExact) if ((x.day - this.getDate()) !== 0) { this.setDate(x.day); } } if (x.milliseconds) { this.addMilliseconds(x.milliseconds); } if (x.seconds) { this.addSeconds(x.seconds); } if (x.minutes) { this.addMinutes(x.minutes); } if (x.hours) { this.addHours(x.hours); } if (x.weeks) { this.addWeeks(x.weeks); } if (x.months) { this.addMonths(x.months); } if (x.years) { this.addYears(x.years); } if (x.days) { this.addDays(x.days); } return this; }; /** * Get the week number. Week one (1) is the week which contains the first Thursday of the year. Monday is considered the first day of the week. * The .getWeek() function does NOT convert the date to UTC. The local datetime is used. * Please use .getISOWeek() to get the week of the UTC converted date. * @return {Number} 1 to 53 */ $P.getWeek = function (utc) { // Create a copy of this date object var self, target = new Date(this.valueOf()); if (utc) { target.addMinutes(target.getTimezoneOffset()); self = target.clone(); } else { self = this; } // ISO week date weeks start on monday // so correct the day number var dayNr = (self.getDay() + 6) % 7; // ISO 8601 states that week 1 is the week // with the first thursday of that year. // Set the target date to the thursday in the target week target.setDate(target.getDate() - dayNr + 3); // Store the millisecond value of the target date var firstThursday = target.valueOf(); // Set the target to the first thursday of the year // First set the target to january first target.setMonth(0, 1); // Not a thursday? Correct the date to the next thursday if (target.getDay() !== 4) { target.setMonth(0, 1 + ((4 - target.getDay()) + 7) % 7); } // The weeknumber is the number of weeks between the // first thursday of the year and the thursday in the target week return 1 + Math.ceil((firstThursday - target) / 604800000); // 604800000 = 7 * 24 * 3600 * 1000 }; /** * Get the ISO 8601 week number. Week one ("01") is the week which contains the first Thursday of the year. Monday is considered the first day of the week. * The .getISOWeek() function does convert the date to it's UTC value. Please use .getWeek() to get the week of the local date. * @return {String} "01" to "53" */ $P.getISOWeek = function () { return p(this.getWeek(true)); }; /** * Moves the date to Monday of the week set. Week one (1) is the week which contains the first Thursday of the year. * @param {Number} A Number (1 to 53) that represents the week of the year. * @return {Date} this */ $P.setWeek = function (n) { if ((n - this.getWeek()) === 0) { if (this.getDay() !== 1) { return this.moveToDayOfWeek(1, (this.getDay() > 1 ? -1 : 1)); } else { return this; } } else { return this.moveToDayOfWeek(1, (this.getDay() > 1 ? -1 : 1)).addWeeks(n - this.getWeek()); } }; $P.setQuarter = function (qtr) { var month = Math.abs(((qtr-1) * 3) + 1); return this.setMonth(month, 1); }; $P.getQuarter = function () { return Date.getQuarter(this); }; $P.getDaysLeftInQuarter = function () { return Date.getDaysLeftInQuarter(this); }; /** * Moves the date to the next n'th occurrence of the dayOfWeek starting from the beginning of the month. The number (-1) is a magic number and will return the last occurrence of the dayOfWeek in the month. * @param {Number} The dayOfWeek to move to * @param {Number} The n'th occurrence to move to. Use (-1) to return the last occurrence in the month * @return {Date} this */ $P.moveToNthOccurrence = function (dayOfWeek, occurrence) { if (dayOfWeek === "Weekday") { if (occurrence > 0) { this.moveToFirstDayOfMonth(); if (this.is().weekday()) { occurrence -= 1; } } else if (occurrence < 0) { this.moveToLastDayOfMonth(); if (this.is().weekday()) { occurrence += 1; } } else { return this; } return this.addWeekdays(occurrence); } var shift = 0; if (occurrence > 0) { shift = occurrence - 1; } else if (occurrence === -1) { this.moveToLastDayOfMonth(); if (this.getDay() !== dayOfWeek) { this.moveToDayOfWeek(dayOfWeek, -1); } return this; } return this.moveToFirstDayOfMonth().addDays(-1).moveToDayOfWeek(dayOfWeek, +1).addWeeks(shift); }; var moveToN = function (getFunc, addFunc, nVal) { return function (value, orient) { var diff = (value - this[getFunc]() + nVal * (orient || +1)) % nVal; return this[addFunc]((diff === 0) ? diff += nVal * (orient || +1) : diff); }; }; /** * Move to the next or last dayOfWeek based on the orient value. * @param {Number} The dayOfWeek to move to * @param {Number} Forward (+1) or Back (-1). Defaults to +1. [Optional] * @return {Date} this */ $P.moveToDayOfWeek = moveToN("getDay", "addDays", 7); /** * Move to the next or last month based on the orient value. * @param {Number} The month to move to. 0 = January, 11 = December * @param {Number} Forward (+1) or Back (-1). Defaults to +1. [Optional] * @return {Date} this */ $P.moveToMonth = moveToN("getMonth", "addMonths", 12); /** * Get the Ordinate of the current day ("th", "st", "rd"). * @return {String} */ $P.getOrdinate = function () { var num = this.getDate(); return ord(num); }; /** * Get the Ordinal day (numeric day number) of the year, adjusted for leap year. * @return {Number} 1 through 365 (366 in leap years) */ $P.getOrdinalNumber = function () { return Math.ceil((this.clone().clearTime() - new Date(this.getFullYear(), 0, 1)) / 86400000) + 1; }; /** * Get the time zone abbreviation of the current date. * @return {String} The abbreviated time zone name (e.g. "EST") */ $P.getTimezone = function () { return $D.getTimezoneAbbreviation(this.getUTCOffset(), this.isDaylightSavingTime()); }; $P.setTimezoneOffset = function (offset) { var here = this.getTimezoneOffset(), there = Number(offset) * -6 / 10; return (there || there === 0) ? this.addMinutes(there - here) : this; }; $P.setTimezone = function (offset) { return this.setTimezoneOffset($D.getTimezoneOffset(offset)); }; /** * Indicates whether Daylight Saving Time is observed in the current time zone. * @return {Boolean} true|false */ $P.hasDaylightSavingTime = function () { return (Date.today().set({month: 0, day: 1}).getTimezoneOffset() !== Date.today().set({month: 6, day: 1}).getTimezoneOffset()); }; /** * Indicates whether this Date instance is within the Daylight Saving Time range for the current time zone. * @return {Boolean} true|false */ $P.isDaylightSavingTime = function () { return Date.today().set({month: 0, day: 1}).getTimezoneOffset() !== this.getTimezoneOffset(); }; /** * Get the offset from UTC of the current date. * @return {String} The 4-character offset string prefixed with + or - (e.g. "-0500") */ $P.getUTCOffset = function (offset) { var n = (offset || this.getTimezoneOffset()) * -10 / 6, r; if (n < 0) { r = (n - 10000).toString(); return r.charAt(0) + r.substr(2); } else { r = (n + 10000).toString(); return "+" + r.substr(1); } }; /** * Returns the number of milliseconds between this date and date. * @param {Date} Defaults to now * @return {Number} The diff in milliseconds */ $P.getElapsed = function (date) { return (date || new Date()) - this; }; /** * Set the value of year, month, day, hour, minute, second, millisecond of date instance using given configuration object. * Example

	Date.today().set( { day: 20, month: 1 } )

	new Date().set( { millisecond: 0 } )
	
* * @param {Object} Configuration object containing attributes (month, day, etc.) * @return {Date} this */ $P.set = function (config) { config = validateConfigObject.call(this, config); var key; for (key in config) { if (Object.prototype.hasOwnProperty.call(config, key)) { var name = key.charAt(0).toUpperCase() + key.slice(1); var addFunc, getFunc; if (key !== "week" && key !== "month" && key !== "timezone" && key !== "timezoneOffset") { name += "s"; } addFunc = "add" + name; getFunc = "get" + name; if (key === "month") { addFunc = addFunc + "s"; } else if (key === "year"){ getFunc = "getFullYear"; } if (key !== "day" && key !== "timezone" && key !== "timezoneOffset" && key !== "week" && key !== "hour") { this[addFunc](config[key] - this[getFunc]()); } else if ( key === "timezone"|| key === "timezoneOffset" || key === "week" || key === "hour") { this["set"+name](config[key]); } } } // day has to go last because you can't validate the day without first knowing the month if (config.day) { this.addDays(config.day - this.getDate()); } return this; }; /** * Moves the date to the first day of the month. * @return {Date} this */ $P.moveToFirstDayOfMonth = function () { return this.set({ day: 1 }); }; /** * Moves the date to the last day of the month. * @return {Date} this */ $P.moveToLastDayOfMonth = function () { return this.set({ day: $D.getDaysInMonth(this.getFullYear(), this.getMonth())}); }; /** * Converts the value of the current Date object to its equivalent string representation. * Format Specifiers * CUSTOM DATE AND TIME FORMAT STRINGS * Format Description Example * ------ --------------------------------------------------------------------------- ----------------------- * s The seconds of the minute between 0-59. "0" to "59" * ss The seconds of the minute with leading zero if required. "00" to "59" * * m The minute of the hour between 0-59. "0" or "59" * mm The minute of the hour with leading zero if required. "00" or "59" * * h The hour of the day between 1-12. "1" to "12" * hh The hour of the day with leading zero if required. "01" to "12" * * H The hour of the day between 0-23. "0" to "23" * HH The hour of the day with leading zero if required. "00" to "23" * * d The day of the month between 1 and 31. "1" to "31" * dd The day of the month with leading zero if required. "01" to "31" * ddd Abbreviated day name. Date.CultureInfo.abbreviatedDayNames. "Mon" to "Sun" * dddd The full day name. Date.CultureInfo.dayNames. "Monday" to "Sunday" * * M The month of the year between 1-12. "1" to "12" * MM The month of the year with leading zero if required. "01" to "12" * MMM Abbreviated month name. Date.CultureInfo.abbreviatedMonthNames. "Jan" to "Dec" * MMMM The full month name. Date.CultureInfo.monthNames. "January" to "December" * * yy The year as a two-digit number. "99" or "08" * yyyy The full four digit year. "1999" or "2008" * * t Displays the first character of the A.M./P.M. designator. "A" or "P" * Date.CultureInfo.amDesignator or Date.CultureInfo.pmDesignator * tt Displays the A.M./P.M. designator. "AM" or "PM" * Date.CultureInfo.amDesignator or Date.CultureInfo.pmDesignator * * S The ordinal suffix ("st, "nd", "rd" or "th") of the current day. "st, "nd", "rd" or "th" * * STANDARD DATE AND TIME FORMAT STRINGS * Format Description Example *------ --------------------------------------------------------------------------- ----------------------- * d The CultureInfo shortDate Format Pattern "M/d/yyyy" * D The CultureInfo longDate Format Pattern "dddd, MMMM dd, yyyy" * F The CultureInfo fullDateTime Format Pattern "dddd, MMMM dd, yyyy h:mm:ss tt" * m The CultureInfo monthDay Format Pattern "MMMM dd" * r The CultureInfo rfc1123 Format Pattern "ddd, dd MMM yyyy HH:mm:ss GMT" * s The CultureInfo sortableDateTime Format Pattern "yyyy-MM-ddTHH:mm:ss" * t The CultureInfo shortTime Format Pattern "h:mm tt" * T The CultureInfo longTime Format Pattern "h:mm:ss tt" * u The CultureInfo universalSortableDateTime Format Pattern "yyyy-MM-dd HH:mm:ssZ" * y The CultureInfo yearMonth Format Pattern "MMMM, yyyy" * * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @return {String} A string representation of the current Date object. */ var ord = function (n) { switch (n * 1) { case 1: case 21: case 31: return "st"; case 2: case 22: return "nd"; case 3: case 23: return "rd"; default: return "th"; } }; var parseStandardFormats = function (format) { var y, c = Date.CultureInfo.formatPatterns; switch (format) { case "d": return this.toString(c.shortDate); case "D": return this.toString(c.longDate); case "F": return this.toString(c.fullDateTime); case "m": return this.toString(c.monthDay); case "r": case "R": y = this.clone().addMinutes(this.getTimezoneOffset()); return y.toString(c.rfc1123) + " GMT"; case "s": return this.toString(c.sortableDateTime); case "t": return this.toString(c.shortTime); case "T": return this.toString(c.longTime); case "u": y = this.clone().addMinutes(this.getTimezoneOffset()); return y.toString(c.universalSortableDateTime); case "y": return this.toString(c.yearMonth); default: return false; } }; var parseFormatStringsClosure = function (context) { return function (m) { if (m.charAt(0) === "\\") { return m.replace("\\", ""); } switch (m) { case "hh": return p(context.getHours() < 13 ? (context.getHours() === 0 ? 12 : context.getHours()) : (context.getHours() - 12)); case "h": return context.getHours() < 13 ? (context.getHours() === 0 ? 12 : context.getHours()) : (context.getHours() - 12); case "HH": return p(context.getHours()); case "H": return context.getHours(); case "mm": return p(context.getMinutes()); case "m": return context.getMinutes(); case "ss": return p(context.getSeconds()); case "s": return context.getSeconds(); case "yyyy": return p(context.getFullYear(), 4); case "yy": return p(context.getFullYear()); case "y": return context.getFullYear(); case "E": case "dddd": return Date.CultureInfo.dayNames[context.getDay()]; case "ddd": return Date.CultureInfo.abbreviatedDayNames[context.getDay()]; case "dd": return p(context.getDate()); case "d": return context.getDate(); case "MMMM": return Date.CultureInfo.monthNames[context.getMonth()]; case "MMM": return Date.CultureInfo.abbreviatedMonthNames[context.getMonth()]; case "MM": return p((context.getMonth() + 1)); case "M": return context.getMonth() + 1; case "t": return context.getHours() < 12 ? Date.CultureInfo.amDesignator.substring(0, 1) : Date.CultureInfo.pmDesignator.substring(0, 1); case "tt": return context.getHours() < 12 ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator; case "S": return ord(context.getDate()); case "W": return context.getWeek(); case "WW": return context.getISOWeek(); case "Q": return "Q" + context.getQuarter(); case "q": return String(context.getQuarter()); case "z": return context.getTimezone(); case "Z": case "X": return Date.getTimezoneOffset(context.getTimezone()); case "ZZ": // Timezone offset in seconds return context.getTimezoneOffset() * -60; case "u": return context.getDay(); case "L": return ($D.isLeapYear(context.getFullYear())) ? 1 : 0; case "B": // Swatch Internet Time (.beats) return "@"+((context.getUTCSeconds() + (context.getUTCMinutes()*60) + ((context.getUTCHours()+1)*3600))/86.4); default: return m; } }; }; $P.toString = function (format, ignoreStandards) { // Standard Date and Time Format Strings. Formats pulled from CultureInfo file and // may vary by culture. if (!ignoreStandards && format && format.length === 1) { output = parseStandardFormats.call(this, format); if (output) { return output; } } var parseFormatStrings = parseFormatStringsClosure(this); return format ? format.replace(/((\\)?(dd?d?d?|MM?M?M?|yy?y?y?|hh?|HH?|mm?|ss?|tt?|S|q|Q|WW?W?W?)(?![^\[]*\]))/g, parseFormatStrings).replace(/\[|\]/g, "") : this._toString(); }; }()); /************************************************************* * SugarPak - Domain Specific Language - Syntactical Sugar * *************************************************************/ (function () { var $D = Date, $P = $D.prototype, $N = Number.prototype; // private $P._orient = +1; // private $P._nth = null; // private $P._is = false; // private $P._same = false; // private $P._isSecond = false; // private $N._dateElement = "days"; /** * Moves the date to the next instance of a date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.today().next().friday();
	Date.today().next().fri();
	Date.today().next().march();
	Date.today().next().mar();
	Date.today().next().week();
	
* * @return {Date} date */ $P.next = function () { this._move = true; this._orient = +1; return this; }; /** * Creates a new Date (Date.today()) and moves the date to the next instance of the date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.next().friday();
	Date.next().fri();
	Date.next().march();
	Date.next().mar();
	Date.next().week();
	
* * @return {Date} date */ $D.next = function () { return $D.today().next(); }; /** * Moves the date to the previous instance of a date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.today().last().friday();
	Date.today().last().fri();
	Date.today().last().march();
	Date.today().last().mar();
	Date.today().last().week();
	
* * @return {Date} date */ $P.last = $P.prev = $P.previous = function () { this._move = true; this._orient = -1; return this; }; /** * Creates a new Date (Date.today()) and moves the date to the previous instance of the date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.last().friday();
	Date.last().fri();
	Date.previous().march();
	Date.prev().mar();
	Date.last().week();
	
* * @return {Date} date */ $D.last = $D.prev = $D.previous = function () { return $D.today().last(); }; /** * Performs a equality check when followed by either a month name, day name or .weekday() function. * Example

	Date.today().is().friday(); // true|false
	Date.today().is().fri();
	Date.today().is().march();
	Date.today().is().mar();
	
* * @return {Boolean} true|false */ $P.is = function () { this._is = true; return this; }; /** * Determines if two date objects occur on/in exactly the same instance of the subsequent date part function. * The function .same() must be followed by a date part function (example: .day(), .month(), .year(), etc). * * An optional Date can be passed in the date part function. If now date is passed as a parameter, 'Now' is used. * * The following example demonstrates how to determine if two dates fall on the exact same day. * * Example

	var d1 = Date.today(); // today at 00:00
	var d2 = new Date();   // exactly now.

	// Do they occur on the same day?
	d1.same().day(d2); // true
	
	// Do they occur on the same hour?
	d1.same().hour(d2); // false, unless d2 hour is '00' (midnight).
	
	// What if it's the same day, but one year apart?
	var nextYear = Date.today().add(1).year();

	d1.same().day(nextYear); // false, because the dates must occur on the exact same day. 
	
* * Scenario: Determine if a given date occurs during some week period 2 months from now. * * Example

	var future = Date.today().add(2).months();
	return someDate.same().week(future); // true|false;
	
* * @return {Boolean} true|false */ $P.same = function () { this._same = true; this._isSecond = false; return this; }; /** * Determines if the current date/time occurs during Today. Must be preceded by the .is() function. * Example

	someDate.is().today();    // true|false
	new Date().is().today();  // true
	Date.today().is().today();// true
	Date.today().add(-1).day().is().today(); // false
	
* * @return {Boolean} true|false */ $P.today = function () { return this.same().day(); }; /** * Determines if the current date is a weekday. This function must be preceded by the .is() function. * Example

	Date.today().is().weekday(); // true|false
	
* * @return {Boolean} true|false */ $P.weekday = function () { if (this._nth) { return df("Weekday").call(this); } if (this._move) { return this.addWeekdays(this._orient); } if (this._is) { this._is = false; return (!this.is().sat() && !this.is().sun()); } return false; }; /** * Determines if the current date is on the weekend. This function must be preceded by the .is() function. * Example

	Date.today().is().weekend(); // true|false
	
* * @return {Boolean} true|false */ $P.weekend = function () { if (this._is) { this._is = false; return (this.is().sat() || this.is().sun()); } return false; }; /** * Sets the Time of the current Date instance. A string "6:15 pm" or config object {hour:18, minute:15} are accepted. * Example

	// Set time to 6:15pm with a String
	Date.today().at("6:15pm");

	// Set time to 6:15pm with a config object
	Date.today().at({hour:18, minute:15});
	
* * @return {Date} date */ $P.at = function (time) { return (typeof time === "string") ? $D.parse(this.toString("d") + " " + time) : this.set(time); }; /** * Creates a new Date() and adds this (Number) to the date based on the preceding date element function (eg. second|minute|hour|day|month|year). * Example

	// Undeclared Numbers must be wrapped with parentheses. Requirment of JavaScript.
	(3).days().fromNow();
	(6).months().fromNow();

	// Declared Number variables do not require parentheses. 
	var n = 6;
	n.months().fromNow();
	
* * @return {Date} A new Date instance */ $N.fromNow = $N.after = function (date) { var c = {}; c[this._dateElement] = this; return ((!date) ? new Date() : date.clone()).add(c); }; /** * Creates a new Date() and subtract this (Number) from the date based on the preceding date element function (eg. second|minute|hour|day|month|year). * Example

	// Undeclared Numbers must be wrapped with parentheses. Requirment of JavaScript.
	(3).days().ago();
	(6).months().ago();

	// Declared Number variables do not require parentheses. 
	var n = 6;
	n.months().ago();
	
* * @return {Date} A new Date instance */ $N.ago = $N.before = function (date) { var c = {}, s = (this._dateElement[this._dateElement.length-1] !== "s") ? this._dateElement + "s" : this._dateElement; c[s] = this * -1; return ((!date) ? new Date() : date.clone()).add(c); }; // Do NOT modify the following string tokens. These tokens are used to build dynamic functions. // All culture-specific strings can be found in the CultureInfo files. var dx = ("sunday monday tuesday wednesday thursday friday saturday").split(/\s/), mx = ("january february march april may june july august september october november december").split(/\s/), px = ("Millisecond Second Minute Hour Day Week Month Year Quarter Weekday").split(/\s/), pxf = ("Milliseconds Seconds Minutes Hours Date Week Month FullYear Quarter").split(/\s/), nth = ("final first second third fourth fifth").split(/\s/), de; /** * Returns an object literal of all the date parts. * Example

	var o = new Date().toObject();
	
	// { year: 2008, month: 4, week: 20, day: 13, hour: 18, minute: 9, second: 32, millisecond: 812 }
	
	// The object properties can be referenced directly from the object.
	
	alert(o.day);  // alerts "13"
	alert(o.year); // alerts "2008"
	
* * @return {Date} An object literal representing the original date object. */ $P.toObject = function () { var o = {}; for (var i = 0; i < px.length; i++) { if (this["get" + pxf[i]]) { o[px[i].toLowerCase()] = this["get" + pxf[i]](); } } return o; }; /** * Returns a date created from an object literal. Ignores the .week property if set in the config. * Example

	var o = new Date().toObject();
	
	return Date.fromObject(o); // will return the same date. 

	var o2 = {month: 1, day: 20, hour: 18}; // birthday party!
	Date.fromObject(o2);
	
* * @return {Date} An object literal representing the original date object. */ $D.fromObject = function(config) { config.week = null; return Date.today().set(config); }; // Create day name functions and abbreviated day name functions (eg. monday(), friday(), fri()). var df = function (n) { return function () { if (this._is) { this._is = false; return this.getDay() === n; } if (this._move) { this._move = null; } if (this._nth !== null) { // If the .second() function was called earlier, remove the _orient // from the date, and then continue. // This is required because 'second' can be used in two different context. // // Example // // Date.today().add(1).second(); // Date.march().second().monday(); // // Things get crazy with the following... // Date.march().add(1).second().second().monday(); // but it works!! // if (this._isSecond) { this.addSeconds(this._orient * -1); } // make sure we reset _isSecond this._isSecond = false; var ntemp = this._nth; this._nth = null; var temp = this.clone().moveToLastDayOfMonth(); this.moveToNthOccurrence(n, ntemp); if (this > temp) { throw new RangeError($D.getDayName(n) + " does not occur " + ntemp + " times in the month of " + $D.getMonthName(temp.getMonth()) + " " + temp.getFullYear() + "."); } return this; } return this.moveToDayOfWeek(n, this._orient); }; }; var sdf = function (n) { return function () { var t = $D.today(), shift = n - t.getDay(); if (n === 0 && Date.CultureInfo.firstDayOfWeek === 1 && t.getDay() !== 0) { shift = shift + 7; } return t.addDays(shift); }; }; // Create month name functions and abbreviated month name functions (eg. january(), march(), mar()). var month_instance_functions = function (n) { return function () { if (this._is) { this._is = false; return this.getMonth() === n; } return this.moveToMonth(n, this._orient); }; }; var month_static_functions = function (n) { return function () { return $D.today().set({ month: n, day: 1 }); }; }; var processTerms = function (names, staticFunc, instanceFunc) { for (var i = 0; i < names.length; i++) { // Create constant static Name variables. $D[names[i].toUpperCase()] = $D[names[i].toUpperCase().substring(0, 3)] = i; // Create Name functions. $D[names[i]] = $D[names[i].substring(0, 3)] = staticFunc(i); // Create Name instance functions. $P[names[i]] = $P[names[i].substring(0, 3)] = instanceFunc(i); } }; processTerms(dx, sdf, df); processTerms(mx, month_static_functions, month_instance_functions); // Create date element functions and plural date element functions used with Date (eg. day(), days(), months()). var ef = function (j) { return function () { // if the .second() function was called earlier, the _orient // has alread been added. Just return this and reset _isSecond. if (this._isSecond) { this._isSecond = false; return this; } if (this._same) { this._same = this._is = false; var o1 = this.toObject(), o2 = (arguments[0] || new Date()).toObject(), v = "", k = j.toLowerCase(); // the substr trick with -1 doesn't work in IE8 or less k = (k[k.length-1] === "s") ? k.substring(0,k.length-1) : k; for (var m = (px.length - 1); m > -1; m--) { v = px[m].toLowerCase(); if (o1[v] !== o2[v]) { return false; } if (k === v) { break; } } return true; } if (j.substring(j.length - 1) !== "s") { j += "s"; } if (this._move) { this._move = null; } return this["add" + j](this._orient); }; }; var nf = function (n) { return function () { this._dateElement = n; return this; }; }; for (var k = 0; k < px.length; k++) { de = px[k].toLowerCase(); if(de !== "weekday") { // Create date element functions and plural date element functions used with Date (eg. day(), days(), months()). $P[de] = $P[de + "s"] = ef(px[k]); // Create date element functions and plural date element functions used with Number (eg. day(), days(), months()). $N[de] = $N[de + "s"] = nf(de + "s"); } } $P._ss = ef("Second"); var nthfn = function (n) { return function (dayOfWeek) { if (this._same) { return this._ss(arguments[0]); } if (dayOfWeek || dayOfWeek === 0) { return this.moveToNthOccurrence(dayOfWeek, n); } this._nth = n; // if the operator is 'second' add the _orient, then deal with it later... if (n === 2 && (dayOfWeek === undefined || dayOfWeek === null)) { this._isSecond = true; return this.addSeconds(this._orient); } return this; }; }; for (var l = 0; l < nth.length; l++) { $P[nth[l]] = (l === 0) ? nthfn(-1) : nthfn(l); } }()); (function () { "use strict"; Date.Parsing = { Exception: function (s) { this.message = "Parse error at '" + s.substring(0, 10) + " ...'"; } }; var $P = Date.Parsing; var dayOffsets = { standard: [0,31,59,90,120,151,181,212,243,273,304,334], leap: [0,31,60,91,121,152,182,213,244,274,305,335] }; $P.isLeapYear = function(year) { return ((year % 4 === 0) && (year % 100 !== 0)) || (year % 400 === 0); }; var utils = { multiReplace : function (str, hash ) { var key; for (key in hash) { if (Object.prototype.hasOwnProperty.call(hash, key)) { var regex; if (typeof hash[key] === "function") { } else { regex = (hash[key] instanceof RegExp) ? hash[key] : new RegExp(hash[key], "g"); } str = str.replace(regex, key); } } return str; }, getDayOfYearFromWeek : function (obj) { var d, jan4, offset; obj.weekDay = (!obj.weekDay && obj.weekDay !== 0) ? 1 : obj.weekDay; d = new Date(obj.year, 0, 4); jan4 = d.getDay() === 0 ? 7 : d.getDay(); // JS is 0 indexed on Sunday. offset = jan4+3; obj.dayOfYear = ((obj.week * 7) + (obj.weekDay === 0 ? 7 : obj.weekDay))-offset; return obj; }, getDayOfYear : function (obj, dayOffset) { if (!obj.dayOfYear) { obj = utils.getDayOfYearFromWeek(obj); } for (var i=0;i <= dayOffset.length;i++) { if (obj.dayOfYear < dayOffset[i] || i === dayOffset.length) { obj.day = obj.day ? obj.day : (obj.dayOfYear - dayOffset[i-1]); break; } else { obj.month = i; } } return obj; }, adjustForTimeZone : function (obj, date) { var offset; if (obj.zone.toUpperCase() === "Z" || (obj.zone_hours === 0 && obj.zone_minutes === 0)) { // it's UTC/GML so work out the current timeszone offset offset = -date.getTimezoneOffset(); } else { offset = (obj.zone_hours*60) + (obj.zone_minutes || 0); if (obj.zone_sign === "+") { offset *= -1; } offset -= date.getTimezoneOffset(); } date.setMinutes(date.getMinutes()+offset); return date; }, setDefaults : function (obj) { obj.year = obj.year || Date.today().getFullYear(); obj.hours = obj.hours || 0; obj.minutes = obj.minutes || 0; obj.seconds = obj.seconds || 0; obj.milliseconds = obj.milliseconds || 0; if (!(!obj.month && (obj.week || obj.dayOfYear))) { // if we have a month, or if we don't but don't have the day calculation data obj.month = obj.month || 0; obj.day = obj.day || 1; } return obj; }, dataNum: function (data, mod, explict, postProcess) { var dataNum = data*1; if (mod) { if (postProcess) { return data ? mod(data)*1 : data; } else { return data ? mod(dataNum) : data; } } else if (!explict){ return data ? dataNum : data; } else { return (data && typeof data !== "undefined") ? dataNum : data; } }, timeDataProcess: function (obj) { var timeObj = {}; for (var x in obj.data) { if (obj.data.hasOwnProperty(x)) { timeObj[x] = obj.ignore[x] ? obj.data[x] : utils.dataNum(obj.data[x], obj.mods[x], obj.explict[x], obj.postProcess[x]); } } if (obj.data.secmins) { obj.data.secmins = obj.data.secmins.replace(",", ".") * 60; if (!timeObj.minutes) { timeObj.minutes = obj.data.secmins; } else if (!timeObj.seconds) { timeObj.seconds = obj.data.secmins; } delete obj.secmins; } return timeObj; }, buildTimeObjectFromData: function (data) { var time = utils.timeDataProcess({ data: { year : data[1], month : data[5], day : data[7], week : data[8], dayOfYear : data[10], hours : data[15], zone_hours : data[23], zone_minutes : data[24], zone : data[21], zone_sign : data[22], weekDay : data[9], minutes: data[16], seconds: data[19], milliseconds: data[20], secmins: data[18] }, mods: { month: function(data) { return data-1; }, weekDay: function (data) { data = Math.abs(data); return (data === 7 ? 0 : data); }, minutes: function (data) { return data.replace(":",""); }, seconds: function (data) { return Math.floor( (data.replace(":","").replace(",","."))*1 ); }, milliseconds: function (data) { return (data.replace(",",".")*1000); } }, postProcess: { minutes: true, seconds: true, milliseconds: true }, explict: { zone_hours: true, zone_minutes: true }, ignore: { zone: true, zone_sign: true, secmins: true } }); return time; }, addToHash: function (hash, keys, data) { keys = keys; data = data; var len = keys.length; for (var i = 0; i < len; i++) { hash[keys[i]] = data[i]; } return hash; }, combineRegex: function (r1, r2) { return new RegExp("(("+r1.source+")\\s("+r2.source+"))"); }, getDateNthString: function(add, last, inc){ if (add) { return Date.today().addDays(inc).toString("d"); } else if (last) { return Date.today().last()[inc]().toString("d"); } }, buildRegexData: function (array) { var arr = []; var len = array.length; for (var i=0; i < len; i++) { if (Object.prototype.toString.call(array[i]) === '[object Array]') { // oldIE compat version of Array.isArray arr.push(this.combineRegex(array[i][0], array[i][1])); } else { arr.push(array[i]); } } return arr; } }; $P.processTimeObject = function (obj) { var date, dayOffset; utils.setDefaults(obj); dayOffset = ($P.isLeapYear(obj.year)) ? dayOffsets.leap : dayOffsets.standard; if (!obj.month && (obj.week || obj.dayOfYear)) { utils.getDayOfYear(obj, dayOffset); } else { obj.dayOfYear = dayOffset[obj.month] + obj.day; } date = new Date(obj.year, obj.month, obj.day, obj.hours, obj.minutes, obj.seconds, obj.milliseconds); if (obj.zone) { utils.adjustForTimeZone(obj, date); // adjust (and calculate) for timezone } return date; }; $P.ISO = { regex : /^([\+-]?\d{4}(?!\d{2}\b))((-?)((0[1-9]|1[0-2])(\3([12]\d|0[1-9]|3[01]))?|W([0-4]\d|5[0-3])(-?[1-7])?|(00[1-9]|0[1-9]\d|[12]\d{2}|3([0-5]\d|6[1-6])))([T\s]((([01]\d|2[0-4])((:?)[0-5]\d)?|24\:?00)([\.,]\d+(?!:))?)?(\17[0-5]\d([\.,]\d+)?)?\s?([zZ]|([\+-])([01]\d|2[0-3]):?([0-5]\d)?)?)?)?$/, parse : function (s) { var time, data = s.match(this.regex); if (!data || !data.length) { return null; } time = utils.buildTimeObjectFromData(data); if (!time.year || (!time.year && (!time.month && !time.day) && (!time.week && !time.dayOfYear)) ) { return null; } return $P.processTimeObject(time); } }; $P.Numeric = { isNumeric: function (e){return!isNaN(parseFloat(e))&&isFinite(e);}, regex: /\b([0-1]?[0-9])([0-3]?[0-9])([0-2]?[0-9]?[0-9][0-9])\b/i, parse: function (s) { var data, i, time = {}, order = Date.CultureInfo.dateElementOrder.split(""); if (!(this.isNumeric(s)) || // if it's non-numeric OR (s[0] === "+" && s[0] === "-")) { // It's an arithmatic string (eg +/-1000) return null; } if (s.length < 5 && s.indexOf(".") < 0 && s.indexOf("/") < 0) { // assume it's just a year. time.year = s; return $P.processTimeObject(time); } data = s.match(this.regex); if (!data || !data.length) { return null; } for (i=0; i < order.length; i++) { switch(order[i]) { case "d": time.day = data[i+1]; break; case "m": time.month = (data[i+1]-1); break; case "y": time.year = data[i+1]; break; } } return $P.processTimeObject(time); } }; $P.Normalizer = { regexData: function () { var $R = Date.CultureInfo.regexPatterns; return utils.buildRegexData([ $R.tomorrow, $R.yesterday, [$R.past, $R.mon], [$R.past, $R.tue], [$R.past, $R.wed], [$R.past, $R.thu], [$R.past, $R.fri], [$R.past, $R.sat], [$R.past, $R.sun] ]); }, basicReplaceHash : function() { var $R = Date.CultureInfo.regexPatterns; return { "January": $R.jan.source, "February": $R.feb, "March": $R.mar, "April": $R.apr, "May": $R.may, "June": $R.jun, "July": $R.jul, "August": $R.aug, "September": $R.sep, "October": $R.oct, "November": $R.nov, "December": $R.dec, "": /\bat\b/gi, " ": /\s{2,}/, "am": $R.inTheMorning, "9am": $R.thisMorning, "pm": $R.inTheEvening, "7pm":$R.thisEvening }; }, keys : function(){ return [ utils.getDateNthString(true, false, 1), // tomorrow utils.getDateNthString(true, false, -1), // yesterday utils.getDateNthString(false, true, "monday"), //last mon utils.getDateNthString(false, true, "tuesday"), //last tues utils.getDateNthString(false, true, "wednesday"), //last wed utils.getDateNthString(false, true, "thursday"), //last thurs utils.getDateNthString(false, true, "friday"), //last fri utils.getDateNthString(false, true, "saturday"), //last sat utils.getDateNthString(false, true, "sunday") //last sun ]; }, buildRegexFunctions: function () { var $R = Date.CultureInfo.regexPatterns; var __ = Date.i18n.__; var tomorrowRE = new RegExp("(\\b\\d\\d?("+__("AM")+"|"+__("PM")+")? )("+$R.tomorrow.source.slice(1)+")", "i"); // adapted tomorrow regex for AM PM relative dates var todayRE = new RegExp($R.today.source + "(?!\\s*([+-]))\\b"); // today, but excludes the math operators (eg "today + 2h") this.replaceFuncs = [ [todayRE, function (full) { return (full.length > 1) ? Date.today().toString("d") : full; }], [tomorrowRE, function(full, m1) { var t = Date.today().addDays(1).toString("d"); return (t + " " + m1); }], [$R.amThisMorning, function(str, am){return am;}], [$R.pmThisEvening, function(str, pm){return pm;}] ]; }, buildReplaceData: function () { this.buildRegexFunctions(); this.replaceHash = utils.addToHash(this.basicReplaceHash(), this.keys(), this.regexData()); }, stringReplaceFuncs: function (s) { for (var i=0; i < this.replaceFuncs.length; i++) { s = s.replace(this.replaceFuncs[i][0], this.replaceFuncs[i][1]); } return s; }, parse: function (s) { s = this.stringReplaceFuncs(s); s = utils.multiReplace(s, this.replaceHash); try { var n = s.split(/([\s\-\.\,\/\x27]+)/); if (n.length === 3 && $P.Numeric.isNumeric(n[0]) && $P.Numeric.isNumeric(n[2]) && (n[2].length >= 4)) { // ok, so we're dealing with x/year. But that's not a full date. // This fixes wonky dateElementOrder parsing when set to dmy order. if (Date.CultureInfo.dateElementOrder[0] === "d") { s = "1/" + n[0] + "/" + n[2]; // set to 1st of month and normalize the seperator } } } catch (e) {} return s; } }; $P.Normalizer.buildReplaceData(); }()); (function () { var $P = Date.Parsing; var _ = $P.Operators = { // // Tokenizers // rtoken: function (r) { // regex token return function (s) { var mx = s.match(r); if (mx) { return ([ mx[0], s.substring(mx[0].length) ]); } else { throw new $P.Exception(s); } }; }, token: function () { // whitespace-eating token return function (s) { return _.rtoken(new RegExp("^\\s*" + s + "\\s*"))(s); }; }, stoken: function (s) { // string token return _.rtoken(new RegExp("^" + s)); }, // Atomic Operators until: function (p) { return function (s) { var qx = [], rx = null; while (s.length) { try { rx = p.call(this, s); } catch (e) { qx.push(rx[0]); s = rx[1]; continue; } break; } return [ qx, s ]; }; }, many: function (p) { return function (s) { var rx = [], r = null; while (s.length) { try { r = p.call(this, s); } catch (e) { return [ rx, s ]; } rx.push(r[0]); s = r[1]; } return [ rx, s ]; }; }, // generator operators -- see below optional: function (p) { return function (s) { var r = null; try { r = p.call(this, s); } catch (e) { return [ null, s ]; } return [ r[0], r[1] ]; }; }, not: function (p) { return function (s) { try { p.call(this, s); } catch (e) { return [null, s]; } throw new $P.Exception(s); }; }, ignore: function (p) { return p ? function (s) { var r = null; r = p.call(this, s); return [null, r[1]]; } : null; }, product: function () { var px = arguments[0], qx = Array.prototype.slice.call(arguments, 1), rx = []; for (var i = 0 ; i < px.length ; i++) { rx.push(_.each(px[i], qx)); } return rx; }, cache: function (rule) { var cache = {}, cache_length = 0, cache_keys = [], CACHE_MAX = Date.Config.CACHE_MAX || 100000, r = null; var cacheCheck = function () { if (cache_length === CACHE_MAX) { // kill several keys, don't want to have to do this all the time... for (var i=0; i < 10; i++) { var key = cache_keys.shift(); if (key) { delete cache[key]; cache_length--; } } } }; return function (s) { cacheCheck(); try { r = cache[s] = (cache[s] || rule.call(this, s)); } catch (e) { r = cache[s] = e; } cache_length++; cache_keys.push(s); if (r instanceof $P.Exception) { throw r; } else { return r; } }; }, // vector operators -- see below any: function () { var px = arguments; return function (s) { var r = null; for (var i = 0; i < px.length; i++) { if (px[i] == null) { continue; } try { r = (px[i].call(this, s)); } catch (e) { r = null; } if (r) { return r; } } throw new $P.Exception(s); }; }, each: function () { var px = arguments; return function (s) { var rx = [], r = null; for (var i = 0; i < px.length ; i++) { if (px[i] == null) { continue; } try { r = (px[i].call(this, s)); } catch (e) { throw new $P.Exception(s); } rx.push(r[0]); s = r[1]; } return [ rx, s]; }; }, all: function () { var px = arguments, _ = _; return _.each(_.optional(px)); }, // delimited operators sequence: function (px, d, c) { d = d || _.rtoken(/^\s*/); c = c || null; if (px.length === 1) { return px[0]; } return function (s) { var r = null, q = null; var rx = []; for (var i = 0; i < px.length ; i++) { try { r = px[i].call(this, s); } catch (e) { break; } rx.push(r[0]); try { q = d.call(this, r[1]); } catch (ex) { q = null; break; } s = q[1]; } if (!r) { throw new $P.Exception(s); } if (q) { throw new $P.Exception(q[1]); } if (c) { try { r = c.call(this, r[1]); } catch (ey) { throw new $P.Exception(r[1]); } } return [ rx, (r?r[1]:s) ]; }; }, // // Composite Operators // between: function (d1, p, d2) { d2 = d2 || d1; var _fn = _.each(_.ignore(d1), p, _.ignore(d2)); return function (s) { var rx = _fn.call(this, s); return [[rx[0][0], r[0][2]], rx[1]]; }; }, list: function (p, d, c) { d = d || _.rtoken(/^\s*/); c = c || null; return (p instanceof Array ? _.each(_.product(p.slice(0, -1), _.ignore(d)), p.slice(-1), _.ignore(c)) : _.each(_.many(_.each(p, _.ignore(d))), px, _.ignore(c))); }, set: function (px, d, c) { d = d || _.rtoken(/^\s*/); c = c || null; return function (s) { // r is the current match, best the current 'best' match // which means it parsed the most amount of input var r = null, p = null, q = null, rx = null, best = [[], s], last = false; // go through the rules in the given set for (var i = 0; i < px.length ; i++) { // last is a flag indicating whether this must be the last element // if there is only 1 element, then it MUST be the last one q = null; p = null; r = null; last = (px.length === 1); // first, we try simply to match the current pattern // if not, try the next pattern try { r = px[i].call(this, s); } catch (e) { continue; } // since we are matching against a set of elements, the first // thing to do is to add r[0] to matched elements rx = [[r[0]], r[1]]; // if we matched and there is still input to parse and // we don't already know this is the last element, // we're going to next check for the delimiter ... // if there's none, or if there's no input left to parse // than this must be the last element after all ... if (r[1].length > 0 && ! last) { try { q = d.call(this, r[1]); } catch (ex) { last = true; } } else { last = true; } // if we parsed the delimiter and now there's no more input, // that means we shouldn't have parsed the delimiter at all // so don't update r and mark this as the last element ... if (!last && q[1].length === 0) { last = true; } // so, if this isn't the last element, we're going to see if // we can get any more matches from the remaining (unmatched) // elements ... if (!last) { // build a list of the remaining rules we can match against, // i.e., all but the one we just matched against var qx = []; for (var j = 0; j < px.length ; j++) { if (i !== j) { qx.push(px[j]); } } // now invoke recursively set with the remaining input // note that we don't include the closing delimiter ... // we'll check for that ourselves at the end p = _.set(qx, d).call(this, q[1]); // if we got a non-empty set as a result ... // (otw rx already contains everything we want to match) if (p[0].length > 0) { // update current result, which is stored in rx ... // basically, pick up the remaining text from p[1] // and concat the result from p[0] so that we don't // get endless nesting ... rx[0] = rx[0].concat(p[0]); rx[1] = p[1]; } } // at this point, rx either contains the last matched element // or the entire matched set that starts with this element. // now we just check to see if this variation is better than // our best so far, in terms of how much of the input is parsed if (rx[1].length < best[1].length) { best = rx; } // if we've parsed all the input, then we're finished if (best[1].length === 0) { break; } } // so now we've either gone through all the patterns trying them // as the initial match; or we found one that parsed the entire // input string ... // if best has no matches, just return empty set ... if (best[0].length === 0) { return best; } // if a closing delimiter is provided, then we have to check it also if (c) { // we try this even if there is no remaining input because the pattern // may well be optional or match empty input ... try { q = c.call(this, best[1]); } catch (ey) { throw new $P.Exception(best[1]); } // it parsed ... be sure to update the best match remaining input best[1] = q[1]; } // if we're here, either there was no closing delimiter or we parsed it // so now we have the best match; just return it! return best; }; }, forward: function (gr, fname) { return function (s) { return gr[fname].call(this, s); }; }, // // Translation Operators // replace: function (rule, repl) { return function (s) { var r = rule.call(this, s); return [repl, r[1]]; }; }, process: function (rule, fn) { return function (s) { var r = rule.call(this, s); return [fn.call(this, r[0]), r[1]]; }; }, min: function (min, rule) { return function (s) { var rx = rule.call(this, s); if (rx[0].length < min) { throw new $P.Exception(s); } return rx; }; } }; // Generator Operators And Vector Operators // Generators are operators that have a signature of F(R) => R, // taking a given rule and returning another rule, such as // ignore, which parses a given rule and throws away the result. // Vector operators are those that have a signature of F(R1,R2,...) => R, // take a list of rules and returning a new rule, such as each. // Generator operators are converted (via the following _generator // function) into functions that can also take a list or array of rules // and return an array of new rules as though the function had been // called on each rule in turn (which is what actually happens). // This allows generators to be used with vector operators more easily. // Example: // each(ignore(foo, bar)) instead of each(ignore(foo), ignore(bar)) // This also turns generators into vector operators, which allows // constructs like: // not(cache(foo, bar)) var _generator = function (op) { function gen() { var args = null, rx = [], px, i; if (arguments.length > 1) { args = Array.prototype.slice.call(arguments); } else if (arguments[0] instanceof Array) { args = arguments[0]; } if (args) { px = args.shift(); if (px.length > 0) { args.unshift(px[i]); rx.push(op.apply(null, args)); args.shift(); return rx; } } else { return op.apply(null, arguments); } } return gen; }; var gx = "optional not ignore cache".split(/\s/); for (var i = 0 ; i < gx.length ; i++) { _[gx[i]] = _generator(_[gx[i]]); } var _vector = function (op) { return function () { if (arguments[0] instanceof Array) { return op.apply(null, arguments[0]); } else { return op.apply(null, arguments); } }; }; var vx = "each any all".split(/\s/); for (var j = 0 ; j < vx.length ; j++) { _[vx[j]] = _vector(_[vx[j]]); } }()); (function () { var $D = Date; var flattenAndCompact = function (ax) { var rx = []; for (var i = 0; i < ax.length; i++) { if (ax[i] instanceof Array) { rx = rx.concat(flattenAndCompact(ax[i])); } else { if (ax[i]) { rx.push(ax[i]); } } } return rx; }; var parseMeridian = function () { if (this.meridian && (this.hour || this.hour === 0)) { if (this.meridian === "a" && this.hour > 11 && Date.Config.strict24hr){ throw "Invalid hour and meridian combination"; } else if (this.meridian === "p" && this.hour < 12 && Date.Config.strict24hr){ throw "Invalid hour and meridian combination"; } else if (this.meridian === "p" && this.hour < 12) { this.hour = this.hour + 12; } else if (this.meridian === "a" && this.hour === 12) { this.hour = 0; } } }; var setDefaults = function () { var now = new Date(); if ((this.hour || this.minute) && (!this.month && !this.year && !this.day)) { this.day = now.getDate(); } if (!this.year) { this.year = now.getFullYear(); } if (!this.month && this.month !== 0) { this.month = now.getMonth(); } if (!this.day) { this.day = 1; } if (!this.hour) { this.hour = 0; } if (!this.minute) { this.minute = 0; } if (!this.second) { this.second = 0; } if (!this.millisecond) { this.millisecond = 0; } }; var finishUtils = { getToday: function () { if (this.now || "hour minute second".indexOf(this.unit) !== -1) { return new Date(); } else { return $D.today(); } }, setDaysFromWeekday: function (today, orient){ var gap; orient = orient || 1; this.unit = "day"; gap = ($D.getDayNumberFromName(this.weekday) - today.getDay()); this.days = gap ? ((gap + (orient * 7)) % 7) : (orient * 7); return this; }, setMonthsFromMonth: function (today, orient) { var gap; orient = orient || 1; this.unit = "month"; gap = (this.month - today.getMonth()); this.months = gap ? ((gap + (orient * 12)) % 12) : (orient * 12); this.month = null; return this; }, setDMYFromWeekday: function () { var d = Date[this.weekday](); this.day = d.getDate(); if (!this.month) { this.month = d.getMonth(); } this.year = d.getFullYear(); return this; }, setUnitValue: function (orient) { if (!this.value && this.operator && this.operator !== null && this[this.unit + "s"] && this[this.unit + "s"] !== null) { this[this.unit + "s"] = this[this.unit + "s"] + ((this.operator === "add") ? 1 : -1) + (this.value||0) * orient; } else if (this[this.unit + "s"] == null || this.operator != null) { if (!this.value) { this.value = 1; } this[this.unit + "s"] = this.value * orient; } }, generateDateFromWeeks: function () { var weekday = (this.weekday !== undefined) ? this.weekday : "today"; var d = Date[weekday]().addWeeks(this.weeks); if (this.now) { d.setTimeToNow(); } return d; } }; $D.Translator = { hour: function (s) { return function () { this.hour = Number(s); }; }, minute: function (s) { return function () { this.minute = Number(s); }; }, second: function (s) { return function () { this.second = Number(s); }; }, /* for ss.s format */ secondAndMillisecond: function (s) { return function () { var mx = s.match(/^([0-5][0-9])\.([0-9]{1,3})/); this.second = Number(mx[1]); this.millisecond = Number(mx[2]); }; }, meridian: function (s) { return function () { this.meridian = s.slice(0, 1).toLowerCase(); }; }, timezone: function (s) { return function () { var n = s.replace(/[^\d\+\-]/g, ""); if (n.length) { this.timezoneOffset = Number(n); } else { this.timezone = s.toLowerCase(); } }; }, day: function (x) { var s = x[0]; return function () { this.day = Number(s.match(/\d+/)[0]); if (this.day < 1) { throw "invalid day"; } }; }, month: function (s) { return function () { this.month = (s.length === 3) ? "jan feb mar apr may jun jul aug sep oct nov dec".indexOf(s)/4 : Number(s) - 1; if (this.month < 0) { throw "invalid month"; } }; }, year: function (s) { return function () { var n = Number(s); this.year = ((s.length > 2) ? n : (n + (((n + 2000) < Date.CultureInfo.twoDigitYearMax) ? 2000 : 1900))); }; }, rday: function (s) { return function () { switch (s) { case "yesterday": this.days = -1; break; case "tomorrow": this.days = 1; break; case "today": this.days = 0; break; case "now": this.days = 0; this.now = true; break; } }; }, finishExact: function (x) { var d; x = (x instanceof Array) ? x : [x]; for (var i = 0 ; i < x.length ; i++) { if (x[i]) { x[i].call(this); } } setDefaults.call(this); parseMeridian.call(this); if (this.day > $D.getDaysInMonth(this.year, this.month)) { throw new RangeError(this.day + " is not a valid value for days."); } d = new Date(this.year, this.month, this.day, this.hour, this.minute, this.second, this.millisecond); if (this.year < 100) { d.setFullYear(this.year); // means years less that 100 are process correctly. JS will parse it otherwise as 1900-1999. } if (this.timezone) { d.set({ timezone: this.timezone }); } else if (this.timezoneOffset) { d.set({ timezoneOffset: this.timezoneOffset }); } return d; }, finish: function (x) { var today, expression, orient, temp; x = (x instanceof Array) ? flattenAndCompact(x) : [ x ]; if (x.length === 0) { return null; } for (var i = 0 ; i < x.length ; i++) { if (typeof x[i] === "function") { x[i].call(this); } } if (this.now && !this.unit && !this.operator) { return new Date(); } else { today = finishUtils.getToday.call(this); } expression = !!(this.days && this.days !== null || this.orient || this.operator); orient = ((this.orient === "past" || this.operator === "subtract") ? -1 : 1); if (this.month && this.unit === "week") { this.value = this.month + 1; delete this.month; delete this.day; } if ((this.month || this.month === 0) && "year day hour minute second".indexOf(this.unit) !== -1) { if (!this.value) { this.value = this.month + 1; } this.month = null; expression = true; } if (!expression && this.weekday && !this.day && !this.days) { finishUtils.setDMYFromWeekday.call(this); } if (expression && this.weekday && this.unit !== "month" && this.unit !== "week") { finishUtils.setDaysFromWeekday.call(this, today, orient); } if (this.weekday && this.unit !== "week" && !this.day && !this.days) { temp = Date[this.weekday](); this.day = temp.getDate(); if (temp.getMonth() !== today.getMonth()) { this.month = temp.getMonth(); } } if (this.month && this.unit === "day" && this.operator) { if (!this.value) { this.value = (this.month + 1); } this.month = null; } if (this.value != null && this.month != null && this.year != null) { this.day = this.value * 1; } if (this.month && !this.day && this.value) { today.set({ day: this.value * 1 }); if (!expression) { this.day = this.value * 1; } } if (!this.month && this.value && this.unit === "month" && !this.now) { this.month = this.value; expression = true; } if (expression && (this.month || this.month === 0) && this.unit !== "year") { finishUtils.setMonthsFromMonth.call(this, today, orient); } if (!this.unit) { this.unit = "day"; } finishUtils.setUnitValue.call(this, orient); parseMeridian.call(this); if ((this.month || this.month === 0) && !this.day) { this.day = 1; } if (!this.orient && !this.operator && this.unit === "week" && this.value && !this.day && !this.month) { return Date.today().setWeek(this.value); } if (this.unit === "week" && this.weeks && !this.day && !this.month) { return finishUtils.generateDateFromWeeks.call(this); } if (expression && this.timezone && this.day && this.days) { this.day = this.days; } if (expression){ today.add(this); } else { today.set(this); } if (this.timezone) { this.timezone = this.timezone.toUpperCase(); var offset = $D.getTimezoneOffset(this.timezone); var timezone; if (today.hasDaylightSavingTime()) { // lets check that we're being sane with timezone setting timezone = $D.getTimezoneAbbreviation(offset, today.isDaylightSavingTime()); if (timezone !== this.timezone) { // bugger, we're in a place where things like EST vs EDT matters. if (today.isDaylightSavingTime()) { today.addHours(-1); } else { today.addHours(1); } } } today.setTimezoneOffset(offset); } return today; } }; }()); (function () { var $D = Date; $D.Grammar = {}; var _ = $D.Parsing.Operators, g = $D.Grammar, t = $D.Translator, _fn; // Allow rolling up into general purpose rules _fn = function () { return _.each(_.any.apply(null, arguments), _.not(g.ctoken2("timeContext"))); }; g.datePartDelimiter = _.rtoken(/^([\s\-\.\,\/\x27]+)/); g.timePartDelimiter = _.stoken(":"); g.whiteSpace = _.rtoken(/^\s*/); g.generalDelimiter = _.rtoken(/^(([\s\,]|at|@|on)+)/); var _C = {}; g.ctoken = function (keys) { var fn = _C[keys]; if (! fn) { var c = Date.CultureInfo.regexPatterns; var kx = keys.split(/\s+/), px = []; for (var i = 0; i < kx.length ; i++) { px.push(_.replace(_.rtoken(c[kx[i]]), kx[i])); } fn = _C[keys] = _.any.apply(null, px); } return fn; }; g.ctoken2 = function (key) { return _.rtoken(Date.CultureInfo.regexPatterns[key]); }; var cacheProcessRtoken = function (key, token, type, eachToken) { if (eachToken) { g[key] = _.cache(_.process(_.each(_.rtoken(token),_.optional(g.ctoken2(eachToken))), type)); } else { g[key] = _.cache(_.process(_.rtoken(token), type)); } }; var cacheProcessCtoken = function (token, type) { return _.cache(_.process(g.ctoken2(token), type)); }; var _F = {}; //function cache var _get = function (f) { _F[f] = (_F[f] || g.format(f)[0]); return _F[f]; }; g.allformats = function (fx) { var rx = []; if (fx instanceof Array) { for (var i = 0; i < fx.length; i++) { rx.push(_get(fx[i])); } } else { rx.push(_get(fx)); } return rx; }; g.formats = function (fx) { if (fx instanceof Array) { var rx = []; for (var i = 0 ; i < fx.length ; i++) { rx.push(_get(fx[i])); } return _.any.apply(null, rx); } else { return _get(fx); } }; var grammarFormats = { timeFormats: function(){ var i, RTokenKeys = [ "h", "hh", "H", "HH", "m", "mm", "s", "ss", "ss.s", "z", "zz" ], RToken = [ /^(0[0-9]|1[0-2]|[1-9])/, /^(0[0-9]|1[0-2])/, /^([0-1][0-9]|2[0-3]|[0-9])/, /^([0-1][0-9]|2[0-3])/, /^([0-5][0-9]|[0-9])/, /^[0-5][0-9]/, /^([0-5][0-9]|[0-9])/, /^[0-5][0-9]/, /^[0-5][0-9]\.[0-9]{1,3}/, /^((\+|\-)\s*\d\d\d\d)|((\+|\-)\d\d\:?\d\d)/, /^((\+|\-)\s*\d\d\d\d)|((\+|\-)\d\d\:?\d\d)/ ], tokens = [ t.hour, t.hour, t.hour, t.hour, t.minute, t.minute, t.second, t.second, t.secondAndMillisecond, t.timezone, t.timezone ]; for (i=0; i < RTokenKeys.length; i++) { cacheProcessRtoken(RTokenKeys[i], RToken[i], tokens[i]); } g.hms = _.cache(_.sequence([g.H, g.m, g.s], g.timePartDelimiter)); g.t = cacheProcessCtoken("shortMeridian", t.meridian); g.tt = cacheProcessCtoken("longMeridian", t.meridian); g.zzz = cacheProcessCtoken("timezone", t.timezone); g.timeSuffix = _.each(_.ignore(g.whiteSpace), _.set([ g.tt, g.zzz ])); g.time = _.each(_.optional(_.ignore(_.stoken("T"))), g.hms, g.timeSuffix); }, dateFormats: function () { // pre-loaded rules for different date part order preferences var _setfn = function () { return _.set(arguments, g.datePartDelimiter); }; var i, RTokenKeys = [ "d", "dd", "M", "MM", "y", "yy", "yyy", "yyyy" ], RToken = [ /^([0-2]\d|3[0-1]|\d)/, /^([0-2]\d|3[0-1])/, /^(1[0-2]|0\d|\d)/, /^(1[0-2]|0\d)/, /^(\d+)/, /^(\d\d)/, /^(\d\d?\d?\d?)/, /^(\d\d\d\d)/ ], tokens = [ t.day, t.day, t.month, t.month, t.year, t.year, t.year, t.year ], eachToken = [ "ordinalSuffix", "ordinalSuffix" ]; for (i=0; i < RTokenKeys.length; i++) { cacheProcessRtoken(RTokenKeys[i], RToken[i], tokens[i], eachToken[i]); } g.MMM = g.MMMM = _.cache(_.process(g.ctoken("jan feb mar apr may jun jul aug sep oct nov dec"), t.month)); g.ddd = g.dddd = _.cache(_.process(g.ctoken("sun mon tue wed thu fri sat"), function (s) { return function () { this.weekday = s; }; } )); g.day = _fn(g.d, g.dd); g.month = _fn(g.M, g.MMM); g.year = _fn(g.yyyy, g.yy); g.mdy = _setfn(g.ddd, g.month, g.day, g.year); g.ymd = _setfn(g.ddd, g.year, g.month, g.day); g.dmy = _setfn(g.ddd, g.day, g.month, g.year); g.date = function (s) { return ((g[Date.CultureInfo.dateElementOrder] || g.mdy).call(this, s)); }; }, relative: function () { // relative date / time expressions g.orientation = _.process(g.ctoken("past future"), function (s) { return function () { this.orient = s; }; } ); g.operator = _.process(g.ctoken("add subtract"), function (s) { return function () { this.operator = s; }; } ); g.rday = _.process(g.ctoken("yesterday tomorrow today now"), t.rday); g.unit = _.process(g.ctoken("second minute hour day week month year"), function (s) { return function () { this.unit = s; }; } ); } }; g.buildGrammarFormats = function () { // these need to be rebuilt every time the language changes. _C = {}; grammarFormats.timeFormats(); grammarFormats.dateFormats(); grammarFormats.relative(); g.value = _.process(_.rtoken(/^([-+]?\d+)?(st|nd|rd|th)?/), function (s) { return function () { this.value = s.replace(/\D/g, ""); }; } ); g.expression = _.set([g.rday, g.operator, g.value, g.unit, g.orientation, g.ddd, g.MMM ]); g.format = _.process(_.many( _.any( // translate format specifiers into grammar rules _.process( _.rtoken(/^(dd?d?d?(?!e)|MM?M?M?|yy?y?y?|hh?|HH?|mm?|ss?|tt?|zz?z?)/), function (fmt) { if (g[fmt]) { return g[fmt]; } else { throw $D.Parsing.Exception(fmt); } } ), // translate separator tokens into token rules _.process(_.rtoken(/^[^dMyhHmstz]+/), // all legal separators function (s) { return _.ignore(_.stoken(s)); } ) ) ), // construct the parser ... function (rules) { return _.process(_.each.apply(null, rules), t.finishExact); } ); // starting rule for general purpose grammar g._start = _.process(_.set([ g.date, g.time, g.expression ], g.generalDelimiter, g.whiteSpace), t.finish); }; g.buildGrammarFormats(); // parsing date format specifiers - ex: "h:m:s tt" // this little guy will generate a custom parser based // on the format string, ex: g.format("h:m:s tt") // check for these formats first g._formats = g.formats([ "\"yyyy-MM-ddTHH:mm:ssZ\"", "yyyy-MM-ddTHH:mm:ss.sz", "yyyy-MM-ddTHH:mm:ssZ", "yyyy-MM-ddTHH:mm:ssz", "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-ddTHH:mmZ", "yyyy-MM-ddTHH:mmz", "yyyy-MM-ddTHH:mm", "ddd, MMM dd, yyyy H:mm:ss tt", "ddd MMM d yyyy HH:mm:ss zzz", "MMddyyyy", "ddMMyyyy", "Mddyyyy", "ddMyyyy", "Mdyyyy", "dMyyyy", "yyyy", "Mdyy", "dMyy", "d" ]); // real starting rule: tries selected formats first, // then general purpose rule g.start = function (s) { try { var r = g._formats.call({}, s); if (r[1].length === 0) { return r; } } catch (e) {} return g._start.call({}, s); }; }()); (function () { var $D = Date; /** * @desc Converts the specified string value into its JavaScript Date equivalent using CultureInfo specific format information. * * Example

	///////////
	// Dates //
	///////////

	// 15-Oct-2004
	var d1 = Date.parse("10/15/2004");

	// 15-Oct-2004
	var d1 = Date.parse("15-Oct-2004");

	// 15-Oct-2004
	var d1 = Date.parse("2004.10.15");

	//Fri Oct 15, 2004
	var d1 = Date.parse("Fri Oct 15, 2004");

	///////////
	// Times //
	///////////

	// Today at 10 PM.
	var d1 = Date.parse("10 PM");

	// Today at 10:30 PM.
	var d1 = Date.parse("10:30 P.M.");

	// Today at 6 AM.
	var d1 = Date.parse("06am");

	/////////////////////
	// Dates and Times //
	/////////////////////

	// 8-July-2004 @ 10:30 PM
	var d1 = Date.parse("July 8th, 2004, 10:30 PM");

	// 1-July-2004 @ 10:30 PM
	var d1 = Date.parse("2004-07-01T22:30:00");

	////////////////////
	// Relative Dates //
	////////////////////

	// Returns today's date. The string "today" is culture specific.
	var d1 = Date.parse("today");

	// Returns yesterday's date. The string "yesterday" is culture specific.
	var d1 = Date.parse("yesterday");

	// Returns the date of the next thursday.
	var d1 = Date.parse("Next thursday");

	// Returns the date of the most previous monday.
	var d1 = Date.parse("last monday");

	// Returns today's day + one year.
	var d1 = Date.parse("next year");

	///////////////
	// Date Math //
	///////////////

	// Today + 2 days
	var d1 = Date.parse("t+2");

	// Today + 2 days
	var d1 = Date.parse("today + 2 days");

	// Today + 3 months
	var d1 = Date.parse("t+3m");

	// Today - 1 year
	var d1 = Date.parse("today - 1 year");

	// Today - 1 year
	var d1 = Date.parse("t-1y"); 


	/////////////////////////////
	// Partial Dates and Times //
	/////////////////////////////

	// July 15th of this year.
	var d1 = Date.parse("July 15");

	// 15th day of current day and year.
	var d1 = Date.parse("15");

	// July 1st of current year at 10pm.
	var d1 = Date.parse("7/1 10pm");
	
* * @param {String} The string value to convert into a Date object [Required] * @return {Date} A Date object or null if the string cannot be converted into a Date. */ var parseUtils = { removeOrds: function (s) { ords = s.match(/\b(\d+)(?:st|nd|rd|th)\b/); // find ordinal matches s = ((ords && ords.length === 2) ? s.replace(ords[0], ords[1]) : s); return s; }, grammarParser: function (s) { var r = null; try { r = $D.Grammar.start.call({}, s.replace(/^\s*(\S*(\s+\S+)*)\s*$/, "$1")); } catch (e) { return null; } return ((r[1].length === 0) ? r[0] : null); }, nativeFallback: function(s) { var t; try { // ok we haven't parsed it, last ditch attempt with the built-in parser. t = Date._parse(s); return (t || t === 0) ? new Date(t) : null; } catch (e) { return null; } } }; function parse (s) { var d; if (!s) { return null; } if (s instanceof Date) { return s.clone(); } if (s.length >= 4 && s.charAt(0) !== "0" && s.charAt(0) !== "+"&& s.charAt(0) !== "-") { // ie: 2004 will pass, 0800 won't. // Start with specific formats d = $D.Parsing.ISO.parse(s) || $D.Parsing.Numeric.parse(s); } if (d instanceof Date && !isNaN(d.getTime())) { return d; } else { // find ordinal dates (1st, 3rd, 8th, etc and remove them as they cause parsing issues) s = $D.Parsing.Normalizer.parse(parseUtils.removeOrds(s)); d = parseUtils.grammarParser(s); if (d !== null) { return d; } else { return parseUtils.nativeFallback(s); } } } if (!$D._parse) { $D._parse = $D.parse; } $D.parse = parse; Date.getParseFunction = function (fx) { var fns = Date.Grammar.allformats(fx); return function (s) { var r = null; for (var i = 0; i < fns.length; i++) { try { r = fns[i].call({}, s); } catch (e) { continue; } if (r[1].length === 0) { return r[0]; } } return null; }; }; /** * Converts the specified string value into its JavaScript Date equivalent using the specified format {String} or formats {Array} and the CultureInfo specific format information. * The format of the string value must match one of the supplied formats exactly. * * Example

	// 15-Oct-2004
	var d1 = Date.parseExact("10/15/2004", "M/d/yyyy");

	// 15-Oct-2004
	var d1 = Date.parse("15-Oct-2004", "M-ddd-yyyy");

	// 15-Oct-2004
	var d1 = Date.parse("2004.10.15", "yyyy.MM.dd");

	// Multiple formats
	var d1 = Date.parseExact("10/15/2004", ["M/d/yyyy", "MMMM d, yyyy"]);
	
* * @param {String} The string value to convert into a Date object [Required]. * @param {Object} The expected format {String} or an array of expected formats {Array} of the date string [Required]. * @return {Date} A Date object or null if the string cannot be converted into a Date. */ $D.parseExact = function (s, fx) { return $D.getParseFunction(fx)(s); }; }()); (function () { var $D = Date, $P = $D.prototype, // $C = $D.CultureInfo, // not used atm p = function (s, l) { if (!l) { l = 2; } return ("000" + s).slice(l * -1); }; /** * Converts a PHP format string to Java/.NET format string. * A PHP format string can be used with ._format or .format. * A Java/.NET format string can be used with .toString(). * The .parseExact function will only accept a Java/.NET format string * * Example * var f1 = "%m/%d/%y" * var f2 = Date.normalizeFormat(f1); // "MM/dd/yy" * * new Date().format(f1); // "04/13/08" * new Date()._format(f1); // "04/13/08" * new Date().toString(f2); // "04/13/08" * * var date = Date.parseExact("04/13/08", f2); // Sun Apr 13 2008 * * @param {String} A PHP format string consisting of one or more format spcifiers. * @return {String} The PHP format converted to a Java/.NET format string. */ var normalizerSubstitutions = { "d" : "dd", "%d": "dd", "D" : "ddd", "%a": "ddd", "j" : "dddd", "l" : "dddd", "%A": "dddd", "S" : "S", "F" : "MMMM", "%B": "MMMM", "m" : "MM", "%m": "MM", "M" : "MMM", "%b": "MMM", "%h": "MMM", "n" : "M", "Y" : "yyyy", "%Y": "yyyy", "y" : "yy", "%y": "yy", "g" : "h", "%I": "h", "G" : "H", "h" : "hh", "H" : "HH", "%H": "HH", "i" : "mm", "%M": "mm", "s" : "ss", "%S": "ss", "%r": "hh:mm tt", "%R": "H:mm", "%T": "H:mm:ss", "%X": "t", "%x": "d", "%e": "d", "%D": "MM/dd/yy", "%n": "\\n", "%t": "\\t", "e" : "z", "T" : "z", "%z": "z", "%Z": "z", "Z" : "ZZ", "N" : "u", "w" : "u", "%w": "u", "W" : "W", "%V": "W" }; var normalizer = { substitutes: function (m) { return normalizerSubstitutions[m]; }, interpreted: function (m, x) { var y; switch (m) { case "%u": return x.getDay() + 1; case "z": return x.getOrdinalNumber(); case "%j": return p(x.getOrdinalNumber(), 3); case "%U": var d1 = x.clone().set({month: 0, day: 1}).addDays(-1).moveToDayOfWeek(0), d2 = x.clone().addDays(1).moveToDayOfWeek(0, -1); return (d2 < d1) ? "00" : p((d2.getOrdinalNumber() - d1.getOrdinalNumber()) / 7 + 1); case "%W": return p(x.getWeek()); case "t": return $D.getDaysInMonth(x.getFullYear(), x.getMonth()); case "o": case "%G": return x.setWeek(x.getISOWeek()).toString("yyyy"); case "%g": return x._format("%G").slice(-2); case "a": case "%p": return t("tt").toLowerCase(); case "A": return t("tt").toUpperCase(); case "u": return p(x.getMilliseconds(), 3); case "I": return (x.isDaylightSavingTime()) ? 1 : 0; case "O": return x.getUTCOffset(); case "P": y = x.getUTCOffset(); return y.substring(0, y.length - 2) + ":" + y.substring(y.length - 2); case "B": var now = new Date(); return Math.floor(((now.getHours() * 3600) + (now.getMinutes() * 60) + now.getSeconds() + (now.getTimezoneOffset() + 60) * 60) / 86.4); case "c": return x.toISOString().replace(/\"/g, ""); case "U": return $D.strtotime("now"); case "%c": return t("d") + " " + t("t"); case "%C": return Math.floor(x.getFullYear() / 100 + 1); } }, shouldOverrideDefaults: function (m) { switch (m) { case "%e": return true; default: return false; } }, parse: function (m, context) { var formatString, c = context || new Date(); formatString = normalizer.substitutes(m); if (formatString) { return formatString; } formatString = normalizer.interpreted(m, c); if (formatString) { return formatString; } else { return m; } } }; $D.normalizeFormat = function (format, context) { return format.replace(/(%|\\)?.|%%/g, function(t){ return normalizer.parse(t, context); }); }; /** * Format a local Unix timestamp according to locale settings * * Example: * Date.strftime("%m/%d/%y", new Date()); // "04/13/08" * Date.strftime("c", "2008-04-13T17:52:03Z"); // "04/13/08" * * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @param {Number|String} The number representing the number of seconds that have elapsed since January 1, 1970 (local time). * @return {String} A string representation of the current Date object. */ $D.strftime = function (format, time) { var d = Date.parse(time); return d._format(format); }; /** * Parse any textual datetime description into a Unix timestamp. * A Unix timestamp is the number of seconds that have elapsed since January 1, 1970 (midnight UTC/GMT). * * Example: * Date.strtotime("04/13/08"); // 1208044800 * Date.strtotime("1970-01-01T00:00:00Z"); // 0 * * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @param {Object} A string or date object. * @return {String} A string representation of the current Date object. */ $D.strtotime = function (time) { var d = $D.parse(time); return Math.round($D.UTC(d.getUTCFullYear(), d.getUTCMonth(), d.getUTCDate(), d.getUTCHours(), d.getUTCMinutes(), d.getUTCSeconds(), d.getUTCMilliseconds()) / 1000); }; /** * Converts the value of the current Date object to its equivalent string representation using a PHP/Unix style of date format specifiers. * Format Specifiers * Format Description Example * ------ --------------------------------------------------------------------------- ----------------------- * %a abbreviated weekday name according to the current localed "Mon" through "Sun" * %A full weekday name according to the current localed "Sunday" through "Saturday" * %b abbreviated month name according to the current localed "Jan" through "Dec" * %B full month name according to the current locale "January" through "December" * %c preferred date and time representation for the current locale "4/13/2008 12:33 PM" * %C century number (the year divided by 100 and truncated to an integer) "00" to "99" * %d day of the month as a decimal number "01" to "31" * %D same as %m/%d/%y "04/13/08" * %e day of the month as a decimal number, a single digit is preceded by a space "1" to "31" * %g like %G, but without the century "08" * %G The 4-digit year corresponding to the ISO week number (see %V). "2008" * This has the same format and value as %Y, except that if the ISO week number * belongs to the previous or next year, that year is used instead. * %h same as %b "Jan" through "Dec" * %H hour as a decimal number using a 24-hour clock. "00" to "23" * %I hour as a decimal number using a 12-hour clock. "01" to "12" * %j day of the year as a decimal number. "001" to "366" * %m month as a decimal number. "01" to "12" * %M minute as a decimal number. "00" to "59" * %n newline character "\n" * %p either "am" or "pm" according to the given time value, or the "am" or "pm" * corresponding strings for the current locale. * %r time in a.m. and p.m. notation "8:44 PM" * %R time in 24 hour notation "20:44" * %S second as a decimal number "00" to "59" * %t tab character "\t" * %T current time, equal to %H:%M:%S "12:49:11" * %u weekday as a decimal number ["1", "7"], with "1" representing Monday "1" to "7" * %U week number of the current year as a decimal number, starting with the "0" to ("52" or "53") * first Sunday as the first day of the first week * %V The ISO 8601:1988 week number of the current year as a decimal number, "00" to ("52" or "53") * range 01 to 53, where week 1 is the first week that has at least 4 days * in the current year, and with Monday as the first day of the week. * (Use %G or %g for the year component that corresponds to the week number * for the specified timestamp.) * %W week number of the current year as a decimal number, starting with the "00" to ("52" or "53") * first Monday as the first day of the first week * %w day of the week as a decimal, Sunday being "0" "0" to "6" * %x preferred date representation for the current locale without the time "4/13/2008" * %X preferred time representation for the current locale without the date "12:53:05" * %y year as a decimal number without a century "00" "99" * %Y year as a decimal number including the century "2008" * %Z time zone or name or abbreviation "UTC", "EST", "PST" * %z same as %Z * %% a literal "%" characters "%" * d Day of the month, 2 digits with leading zeros "01" to "31" * D A textual representation of a day, three letters "Mon" through "Sun" * j Day of the month without leading zeros "1" to "31" * l A full textual representation of the day of the week (lowercase "L") "Sunday" through "Saturday" * N ISO-8601 numeric representation of the day of the week (added in PHP 5.1.0) "1" (for Monday) through "7" (for Sunday) * S English ordinal suffix for the day of the month, 2 characters "st", "nd", "rd" or "th". Works well with j * w Numeric representation of the day of the week "0" (for Sunday) through "6" (for Saturday) * z The day of the year (starting from "0") "0" through "365" * W ISO-8601 week number of year, weeks starting on Monday "00" to ("52" or "53") * F A full textual representation of a month, such as January or March "January" through "December" * m Numeric representation of a month, with leading zeros "01" through "12" * M A short textual representation of a month, three letters "Jan" through "Dec" * n Numeric representation of a month, without leading zeros "1" through "12" * t Number of days in the given month "28" through "31" * L Whether it's a leap year "1" if it is a leap year, "0" otherwise * o ISO-8601 year number. This has the same value as Y, except that if the "2008" * ISO week number (W) belongs to the previous or next year, that year * is used instead. * Y A full numeric representation of a year, 4 digits "2008" * y A two digit representation of a year "08" * a Lowercase Ante meridiem and Post meridiem "am" or "pm" * A Uppercase Ante meridiem and Post meridiem "AM" or "PM" * B Swatch Internet time "000" through "999" * g 12-hour format of an hour without leading zeros "1" through "12" * G 24-hour format of an hour without leading zeros "0" through "23" * h 12-hour format of an hour with leading zeros "01" through "12" * H 24-hour format of an hour with leading zeros "00" through "23" * i Minutes with leading zeros "00" to "59" * s Seconds, with leading zeros "00" through "59" * u Milliseconds "54321" * e Timezone identifier "UTC", "EST", "PST" * I Whether or not the date is in daylight saving time (uppercase i) "1" if Daylight Saving Time, "0" otherwise * O Difference to Greenwich time (GMT) in hours "+0200", "-0600" * P Difference to Greenwich time (GMT) with colon between hours and minutes "+02:00", "-06:00" * T Timezone abbreviation "UTC", "EST", "PST" * Z Timezone offset in seconds. The offset for timezones west of UTC is "-43200" through "50400" * always negative, and for those east of UTC is always positive. * c ISO 8601 date "2004-02-12T15:19:21+00:00" * r RFC 2822 formatted date "Thu, 21 Dec 2000 16:01:07 +0200" * U Seconds since the Unix Epoch (January 1 1970 00:00:00 GMT) "0" * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @return {String} A string representation of the current Date object. */ var formatReplace = function (context) { return function (m) { var formatString, override = false; if (m.charAt(0) === "\\" || m.substring(0, 2) === "%%") { return m.replace("\\", "").replace("%%", "%"); } override = normalizer.shouldOverrideDefaults(m); formatString = $D.normalizeFormat(m, context); if (formatString) { return context.toString(formatString, override); } }; }; $P._format = function (format) { var formatter = formatReplace(this); if (!format) { return this._toString(); } else { return format.replace(/(%|\\)?.|%%/g, formatter); } }; if (!$P.format) { $P.format = $P._format; } }()); (function () { "use strict"; var gFn = function (attr) { return function () { return this[attr]; }; }; var sFn = function (attr) { return function (val) { this[attr] = val; return this; }; }; var attrs = ["years", "months", "days", "hours", "minutes", "seconds", "milliseconds"]; var addSetFuncs = function (context, attrs) { for (var i = 0; i < attrs.length ; i++) { var $a = attrs[i], $b = $a.slice(0, 1).toUpperCase() + $a.slice(1); context.prototype[$a] = 0; context.prototype["get" + $b] = gFn($a); context.prototype["set" + $b] = sFn($a); } }; /** * new TimeSpan(milliseconds); * new TimeSpan(days, hours, minutes, seconds); * new TimeSpan(days, hours, minutes, seconds, milliseconds); */ var TimeSpan = function (days, hours, minutes, seconds, milliseconds) { if (arguments.length === 1 && typeof days === "number") { var orient = (days < 0) ? -1 : +1; var millsLeft = Math.abs(days); this.setDays(Math.floor(millsLeft / 86400000) * orient); millsLeft = millsLeft % 86400000; this.setHours(Math.floor(millsLeft / 3600000) * orient); millsLeft = millsLeft % 3600000; this.setMinutes(Math.floor(millsLeft / 60000) * orient); millsLeft = millsLeft % 60000; this.setSeconds(Math.floor(millsLeft / 1000) * orient); millsLeft = millsLeft % 1000; this.setMilliseconds(millsLeft * orient); } else { this.set(days, hours, minutes, seconds, milliseconds); } this.getTotalMilliseconds = function () { return (this.getDays() * 86400000) + (this.getHours() * 3600000) + (this.getMinutes() * 60000) + (this.getSeconds() * 1000); }; this.compareTo = function (time) { var t1 = new Date(1970, 1, 1, this.getHours(), this.getMinutes(), this.getSeconds()), t2; if (time === null) { t2 = new Date(1970, 1, 1, 0, 0, 0); } else { t2 = new Date(1970, 1, 1, time.getHours(), time.getMinutes(), time.getSeconds()); } return (t1 < t2) ? -1 : (t1 > t2) ? 1 : 0; }; this.equals = function (time) { return (this.compareTo(time) === 0); }; this.add = function (time) { return (time === null) ? this : this.addSeconds(time.getTotalMilliseconds() / 1000); }; this.subtract = function (time) { return (time === null) ? this : this.addSeconds(-time.getTotalMilliseconds() / 1000); }; this.addDays = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 86400000)); }; this.addHours = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 3600000)); }; this.addMinutes = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 60000)); }; this.addSeconds = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 1000)); }; this.addMilliseconds = function (n) { return new TimeSpan(this.getTotalMilliseconds() + n); }; this.get12HourHour = function () { return (this.getHours() > 12) ? this.getHours() - 12 : (this.getHours() === 0) ? 12 : this.getHours(); }; this.getDesignator = function () { return (this.getHours() < 12) ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator; }; this.toString = function (format) { this._toString = function () { if (this.getDays() !== null && this.getDays() > 0) { return this.getDays() + "." + this.getHours() + ":" + this.p(this.getMinutes()) + ":" + this.p(this.getSeconds()); } else { return this.getHours() + ":" + this.p(this.getMinutes()) + ":" + this.p(this.getSeconds()); } }; this.p = function (s) { return (s.toString().length < 2) ? "0" + s : s; }; var me = this; return format ? format.replace(/dd?|HH?|hh?|mm?|ss?|tt?/g, function (format) { switch (format) { case "d": return me.getDays(); case "dd": return me.p(me.getDays()); case "H": return me.getHours(); case "HH": return me.p(me.getHours()); case "h": return me.get12HourHour(); case "hh": return me.p(me.get12HourHour()); case "m": return me.getMinutes(); case "mm": return me.p(me.getMinutes()); case "s": return me.getSeconds(); case "ss": return me.p(me.getSeconds()); case "t": return ((me.getHours() < 12) ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator).substring(0, 1); case "tt": return (me.getHours() < 12) ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator; } } ) : this._toString(); }; return this; }; addSetFuncs(TimeSpan, attrs.slice(2)); TimeSpan.prototype.set = function (days, hours, minutes, seconds, milliseconds){ this.setDays(days || this.getDays()); this.setHours(hours || this.getHours()); this.setMinutes(minutes || this.getMinutes()); this.setSeconds(seconds || this.getSeconds()); this.setMilliseconds(milliseconds || this.getMilliseconds()); }; /** * Gets the time of day for this date instances. * @return {TimeSpan} TimeSpan */ Date.prototype.getTimeOfDay = function () { return new TimeSpan(0, this.getHours(), this.getMinutes(), this.getSeconds(), this.getMilliseconds()); }; Date.TimeSpan = TimeSpan; if (typeof window !== "undefined" ) { // keeping API compatible for v1.x window.TimeSpan = TimeSpan; } }()); (function () { "use strict"; var attrs = ["years", "months", "days", "hours", "minutes", "seconds", "milliseconds"]; var gFn = function (attr) { return function () { return this[attr]; }; }; var sFn = function (attr) { return function (val) { this[attr] = val; return this; }; }; var addSetFuncs = function (context, attrs) { for (var i = 0; i < attrs.length ; i++) { var $a = attrs[i], $b = $a.slice(0, 1).toUpperCase() + $a.slice(1); context.prototype[$a] = 0; context.prototype["get" + $b] = gFn($a); context.prototype["set" + $b] = sFn($a); } }; var setMonthsAndYears = function (orient, d1, d2, context) { function inc() { d1.addMonths(-orient); context.months++; if (context.months === 12) { context.years++; context.months = 0; } } if (orient === +1) { while (d1 > d2) { inc(); } } else { while (d1 < d2) { inc(); } } context.months--; context.months *= orient; context.years *= orient; }; var adjustForDST = function(orient, startDate, endDate) { var hasDSTMismatch = (false === (startDate.isDaylightSavingTime() === endDate.isDaylightSavingTime())); if (hasDSTMismatch && orient === 1) { startDate.addHours(-1); } else if (hasDSTMismatch) { startDate.addHours(1); } }; /** * TimePeriod(startDate, endDate); * TimePeriod(years, months, days, hours, minutes, seconds, milliseconds); */ var TimePeriod = function (years, months, days, hours, minutes, seconds, milliseconds) { if (arguments.length === 7) { this.set(years, months, days, hours, minutes, seconds, milliseconds); } else if (arguments.length === 2 && arguments[0] instanceof Date && arguments[1] instanceof Date) { var startDate = arguments[0].clone(); var endDate = arguments[1].clone(); var orient = (startDate > endDate) ? +1 : -1; this.dates = { start: arguments[0].clone(), end: arguments[1].clone() }; setMonthsAndYears(orient, startDate, endDate, this); adjustForDST(orient, startDate, endDate); // // TODO - adjust for DST var diff = endDate - startDate; if (diff !== 0) { var ts = new TimeSpan(diff); this.set(this.years, this.months, ts.getDays(), ts.getHours(), ts.getMinutes(), ts.getSeconds(), ts.getMilliseconds()); } } return this; }; // create all the set functions. addSetFuncs(TimePeriod, attrs); TimePeriod.prototype.set = function (years, months, days, hours, minutes, seconds, milliseconds){ this.setYears(years || this.getYears()); this.setMonths(months || this.getMonths()); this.setDays(days || this.getDays()); this.setHours(hours || this.getHours()); this.setMinutes(minutes || this.getMinutes()); this.setSeconds(seconds || this.getSeconds()); this.setMilliseconds(milliseconds || this.getMilliseconds()); }; Date.TimePeriod = TimePeriod; if (typeof window !== "undefined") { // keeping API compatible for v1.x window.TimePeriod = TimePeriod; } }()); ================================================ FILE: build/date-sv-SE.js ================================================ /** * @overview datejs * @version 1.0.0-rc3 * @author Gregory Wild-Smith * @copyright 2015 Gregory Wild-Smith * @license MIT * @homepage https://github.com/abritinthebay/datejs */ /* * DateJS Culture String File * Country Code: sv-SE * Name: Swedish (Sweden) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["sv-SE"] = { "name": "sv-SE", "englishName": "Swedish (Sweden)", "nativeName": "Svenska (Sverige)", "Sunday": "Söndag", "Monday": "Måndag", "Tuesday": "Tisdag", "Wednesday": "Onsdag", "Thursday": "Torsdag", "Friday": "Fredag", "Saturday": "Lördag", "Sun": "Sön", "Mon": "Mån", "Tue": "Tis", "Wed": "Ons", "Thu": "Tor", "Fri": "Fre", "Sat": "Lör", "Su": "Sö", "Mo": "Må", "Tu": "Ti", "We": "On", "Th": "To", "Fr": "Fr", "Sa": "Lö", "S_Sun_Initial": "S", "M_Mon_Initial": "M", "T_Tue_Initial": "T", "W_Wed_Initial": "O", "T_Thu_Initial": "T", "F_Fri_Initial": "F", "S_Sat_Initial": "L", "January": "Januari", "February": "Februari", "March": "Mars", "April": "April", "May": "Maj", "June": "Juni", "July": "Juli", "August": "Augusti", "September": "September", "October": "Oktober", "November": "November", "December": "December", "Jan_Abbr": "Jan", "Feb_Abbr": "Feb", "Mar_Abbr": "Mar", "Apr_Abbr": "Apr", "May_Abbr": "Maj", "Jun_Abbr": "Jun", "Jul_Abbr": "Jul", "Aug_Abbr": "Aug", "Sep_Abbr": "Sep", "Oct_Abbr": "Okt", "Nov_Abbr": "Nov", "Dec_Abbr": "Dec", "AM": "", "PM": "", "firstDayOfWeek": 1, "twoDigitYearMax": 2029, "mdy": "ymd", "M/d/yyyy": "yyyy-MM-dd", "dddd, MMMM dd, yyyy": "'den 'd MMMM yyyy", "h:mm tt": "HH.mm", "h:mm:ss tt": "HH.mm.ss", "dddd, MMMM dd, yyyy h:mm:ss tt": "'den 'd MMMM yyyy HH.mm.ss", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH.mm.ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH.mm.ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH.mm.ss", "MMMM dd": "'den 'd MMMM", "MMMM, yyyy": "MMMM yyyy", "/jan(uary)?/": "jan(uari)?", "/feb(ruary)?/": "feb(ruari)?", "/mar(ch)?/": "mar(s)?", "/apr(il)?/": "apr(il)?", "/may/": "maj", "/jun(e)?/": "jun(i)?", "/jul(y)?/": "jul(i)?", "/aug(ust)?/": "aug(usti)?", "/sep(t(ember)?)?/": "sep(t(ember)?)?", "/oct(ober)?/": "okt(ober)?", "/nov(ember)?/": "nov(ember)?", "/dec(ember)?/": "dec(ember)?", "/^su(n(day)?)?/": "^sö(n(dag)?)?", "/^mo(n(day)?)?/": "^må(n(dag)?)?", "/^tu(e(s(day)?)?)?/": "^ti(s(dag)?)?", "/^we(d(nesday)?)?/": "^on(s(dag)?)?", "/^th(u(r(s(day)?)?)?)?/": "^to(r(s(dag)?)?)?", "/^fr(i(day)?)?/": "^fr(e(dag)?)?", "/^sa(t(urday)?)?/": "^lö(r(dag)?)?", "/^next/": "^nästa", "/^last|past|prev(ious)?/": "^föregående|förra|senaste", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|efter|från)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|före|tidigare)", "/^yes(terday)?/": "^i\\s?går|(för)går(dag)?", "/^t(od(ay)?)?/": "^i\\s?dag?", "/^tom(orrow)?/": "^i\\s?morgon|morgon(dag)?", "/^n(ow)?/": "^nu", "/^ms|milli(second)?s?/": "^ms|milli(sekund)?(er)?", "/^sec(ond)?s?/": "^sek(und)?(er)?", "/^mn|min(ute)?s?/": "^min(ut)?(er)?", "/^h(our)?s?/": "^t(im)?(ar)?", "/^w(eek)?s?/": "^v(eck(a)?)?(or)?", "/^m(onth)?s?/": "^m(ånad)?(er)?", "/^d(ay)?s?/": "^d(ag)?(ar)?", "/^y(ear)?s?/": "^å(r)?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "sv-SE"; /** * @overview datejs * @version 1.0.0-rc3 * @author Gregory Wild-Smith * @copyright 2015 Gregory Wild-Smith * @license MIT * @homepage https://github.com/abritinthebay/datejs */(function () { var $D = Date; var lang = Date.CultureStrings ? Date.CultureStrings.lang : null; var loggedKeys = {}; // for debug purposes. var getText = { getFromKey: function (key, countryCode) { var output; if (Date.CultureStrings && Date.CultureStrings[countryCode] && Date.CultureStrings[countryCode][key]) { output = Date.CultureStrings[countryCode][key]; } else { output = getText.buildFromDefault(key); } if (key.charAt(0) === "/") { // Assume it's a regex output = getText.buildFromRegex(key, countryCode); } return output; }, getFromObjectValues: function (obj, countryCode) { var key, output = {}; for(key in obj) { if (obj.hasOwnProperty(key)) { output[key] = getText.getFromKey(obj[key], countryCode); } } return output; }, getFromObjectKeys: function (obj, countryCode) { var key, output = {}; for(key in obj) { if (obj.hasOwnProperty(key)) { output[getText.getFromKey(key, countryCode)] = obj[key]; } } return output; }, getFromArray: function (arr, countryCode) { var output = []; for (var i=0; i < arr.length; i++){ if (i in arr) { output[i] = getText.getFromKey(arr[i], countryCode); } } return output; }, buildFromDefault: function (key) { var output, length, split, last; switch(key) { case "name": output = "en-US"; break; case "englishName": output = "English (United States)"; break; case "nativeName": output = "English (United States)"; break; case "twoDigitYearMax": output = 2049; break; case "firstDayOfWeek": output = 0; break; default: output = key; split = key.split("_"); length = split.length; if (length > 1 && key.charAt(0) !== "/") { // if the key isn't a regex and it has a split. last = split[(length - 1)].toLowerCase(); if (last === "initial" || last === "abbr") { output = split[0]; } } break; } return output; }, buildFromRegex: function (key, countryCode) { var output; if (Date.CultureStrings && Date.CultureStrings[countryCode] && Date.CultureStrings[countryCode][key]) { output = new RegExp(Date.CultureStrings[countryCode][key], "i"); } else { output = new RegExp(key.replace(new RegExp("/", "g"),""), "i"); } return output; } }; var shallowMerge = function (obj1, obj2) { for (var attrname in obj2) { if (obj2.hasOwnProperty(attrname)) { obj1[attrname] = obj2[attrname]; } } }; var __ = function (key, language) { var countryCode = (language) ? language : lang; loggedKeys[key] = key; if (typeof key === "object") { if (key instanceof Array) { return getText.getFromArray(key, countryCode); } else { return getText.getFromObjectKeys(key, countryCode); } } else { return getText.getFromKey(key, countryCode); } }; var loadI18nScript = function (code) { // paatterned after jQuery's getScript. var url = Date.Config.i18n + code + ".js"; var head = document.getElementsByTagName("head")[0] || document.documentElement; var script = document.createElement("script"); script.src = url; var completed = false; var events = { done: function (){} // placeholder function }; // Attach handlers for all browsers script.onload = script.onreadystatechange = function() { if ( !completed && (!this.readyState || this.readyState === "loaded" || this.readyState === "complete") ) { events.done(); head.removeChild(script); } }; setTimeout(function() { head.insertBefore(script, head.firstChild); }, 0); // allows return to execute first return { done: function (cb) { events.done = function() { if (cb) { setTimeout(cb,0); } }; } }; }; var buildInfo = { buildFromMethodHash: function (obj) { var key; for(key in obj) { if (obj.hasOwnProperty(key)) { obj[key] = buildInfo[obj[key]](); } } return obj; }, timeZoneDST: function () { var DST = { "CHADT": "+1345", "NZDT": "+1300", "AEDT": "+1100", "ACDT": "+1030", "AZST": "+0500", "IRDT": "+0430", "EEST": "+0300", "CEST": "+0200", "BST": "+0100", "PMDT": "-0200", "ADT": "-0300", "NDT": "-0230", "EDT": "-0400", "CDT": "-0500", "MDT": "-0600", "PDT": "-0700", "AKDT": "-0800", "HADT": "-0900" }; return __(DST); }, timeZoneStandard: function () { var standard = { "LINT": "+1400", "TOT": "+1300", "CHAST": "+1245", "NZST": "+1200", "NFT": "+1130", "SBT": "+1100", "AEST": "+1000", "ACST": "+0930", "JST": "+0900", "CWST": "+0845", "CT": "+0800", "ICT": "+0700", "MMT": "+0630", "BST": "+0600", "NPT": "+0545", "IST": "+0530", "PKT": "+0500", "AFT": "+0430", "MSK": "+0400", "IRST": "+0330", "FET": "+0300", "EET": "+0200", "CET": "+0100", "GMT": "+0000", "UTC": "+0000", "CVT": "-0100", "GST": "-0200", "BRT": "-0300", "NST": "-0330", "AST": "-0400", "EST": "-0500", "CST": "-0600", "MST": "-0700", "PST": "-0800", "AKST": "-0900", "MIT": "-0930", "HST": "-1000", "SST": "-1100", "BIT": "-1200" }; return __(standard); }, timeZones: function (data) { var zone; data.timezones = []; for (zone in data.abbreviatedTimeZoneStandard) { if (data.abbreviatedTimeZoneStandard.hasOwnProperty(zone)) { data.timezones.push({ name: zone, offset: data.abbreviatedTimeZoneStandard[zone]}); } } for (zone in data.abbreviatedTimeZoneDST) { if (data.abbreviatedTimeZoneDST.hasOwnProperty(zone)) { data.timezones.push({ name: zone, offset: data.abbreviatedTimeZoneDST[zone], dst: true}); } } return data.timezones; }, days: function () { return __(["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"]); }, dayAbbr: function () { return __(["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"]); }, dayShortNames: function () { return __(["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"]); }, dayFirstLetters: function () { return __(["S_Sun_Initial", "M_Mon_Initial", "T_Tues_Initial", "W_Wed_Initial", "T_Thu_Initial", "F_Fri_Initial", "S_Sat_Initial"]); }, months: function () { return __(["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"]); }, monthAbbr: function () { return __(["Jan_Abbr", "Feb_Abbr", "Mar_Abbr", "Apr_Abbr", "May_Abbr", "Jun_Abbr", "Jul_Abbr", "Aug_Abbr", "Sep_Abbr", "Oct_Abbr", "Nov_Abbr", "Dec_Abbr"]); }, formatPatterns: function () { return getText.getFromObjectValues({ shortDate: "M/d/yyyy", longDate: "dddd, MMMM dd, yyyy", shortTime: "h:mm tt", longTime: "h:mm:ss tt", fullDateTime: "dddd, MMMM dd, yyyy h:mm:ss tt", sortableDateTime: "yyyy-MM-ddTHH:mm:ss", universalSortableDateTime: "yyyy-MM-dd HH:mm:ssZ", rfc1123: "ddd, dd MMM yyyy HH:mm:ss", monthDay: "MMMM dd", yearMonth: "MMMM, yyyy" }, Date.i18n.currentLanguage()); }, regex: function () { return getText.getFromObjectValues({ inTheMorning: "/( in the )(morn(ing)?)\\b/", thisMorning: "/(this )(morn(ing)?)\\b/", amThisMorning: "/(\b\\d(am)? )(this )(morn(ing)?)/", inTheEvening: "/( in the )(even(ing)?)\\b/", thisEvening: "/(this )(even(ing)?)\\b/", pmThisEvening: "/(\b\\d(pm)? )(this )(even(ing)?)/", jan: "/jan(uary)?/", feb: "/feb(ruary)?/", mar: "/mar(ch)?/", apr: "/apr(il)?/", may: "/may/", jun: "/jun(e)?/", jul: "/jul(y)?/", aug: "/aug(ust)?/", sep: "/sep(t(ember)?)?/", oct: "/oct(ober)?/", nov: "/nov(ember)?/", dec: "/dec(ember)?/", sun: "/^su(n(day)?)?/", mon: "/^mo(n(day)?)?/", tue: "/^tu(e(s(day)?)?)?/", wed: "/^we(d(nesday)?)?/", thu: "/^th(u(r(s(day)?)?)?)?/", fri: "/fr(i(day)?)?/", sat: "/^sa(t(urday)?)?/", future: "/^next/", past: "/^last|past|prev(ious)?/", add: "/^(\\+|aft(er)?|from|hence)/", subtract: "/^(\\-|bef(ore)?|ago)/", yesterday: "/^yes(terday)?/", today: "/^t(od(ay)?)?/", tomorrow: "/^tom(orrow)?/", now: "/^n(ow)?/", millisecond: "/^ms|milli(second)?s?/", second: "/^sec(ond)?s?/", minute: "/^mn|min(ute)?s?/", hour: "/^h(our)?s?/", week: "/^w(eek)?s?/", month: "/^m(onth)?s?/", day: "/^d(ay)?s?/", year: "/^y(ear)?s?/", shortMeridian: "/^(a|p)/", longMeridian: "/^(a\\.?m?\\.?|p\\.?m?\\.?)/", timezone: "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/", ordinalSuffix: "/^\\s*(st|nd|rd|th)/", timeContext: "/^\\s*(\\:|a(?!u|p)|p)/" }, Date.i18n.currentLanguage()); } }; var CultureInfo = function () { var info = getText.getFromObjectValues({ name: "name", englishName: "englishName", nativeName: "nativeName", amDesignator: "AM", pmDesignator: "PM", firstDayOfWeek: "firstDayOfWeek", twoDigitYearMax: "twoDigitYearMax", dateElementOrder: "mdy" }, Date.i18n.currentLanguage()); var constructedInfo = buildInfo.buildFromMethodHash({ dayNames: "days", abbreviatedDayNames: "dayAbbr", shortestDayNames: "dayShortNames", firstLetterDayNames: "dayFirstLetters", monthNames: "months", abbreviatedMonthNames: "monthAbbr", formatPatterns: "formatPatterns", regexPatterns: "regex", abbreviatedTimeZoneDST: "timeZoneDST", abbreviatedTimeZoneStandard: "timeZoneStandard" }); shallowMerge(info, constructedInfo); buildInfo.timeZones(info); return info; }; $D.i18n = { __: function (key, lang) { return __(key, lang); }, currentLanguage: function () { return lang || "en-US"; }, setLanguage: function (code, force, cb) { var async = false; if (force || code === "en-US" || (!!Date.CultureStrings && !!Date.CultureStrings[code])) { lang = code; Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings.lang = code; Date.CultureInfo = new CultureInfo(); } else { if (!(!!Date.CultureStrings && !!Date.CultureStrings[code])) { if (typeof exports !== "undefined" && this.exports !== exports) { // we're in a Node enviroment, load it using require try { require("../i18n/" + code + ".js"); lang = code; Date.CultureStrings.lang = code; Date.CultureInfo = new CultureInfo(); } catch (e) { // var str = "The language for '" + code + "' could not be loaded by Node. It likely does not exist."; throw new Error("The DateJS IETF language tag '" + code + "' could not be loaded by Node. It likely does not exist."); } } else if (Date.Config && Date.Config.i18n) { // we know the location of the files, so lets load them async = true; loadI18nScript(code).done(function(){ lang = code; Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings.lang = code; Date.CultureInfo = new CultureInfo(); $D.Parsing.Normalizer.buildReplaceData(); // because this is async if ($D.Grammar) { $D.Grammar.buildGrammarFormats(); // so we can parse those strings... } if (cb) { setTimeout(cb,0); } }); } else { Date.console.error("The DateJS IETF language tag '" + code + "' is not available and has not been loaded."); return false; } } } $D.Parsing.Normalizer.buildReplaceData(); // rebuild normalizer strings if ($D.Grammar) { $D.Grammar.buildGrammarFormats(); // so we can parse those strings... } if (!async && cb) { setTimeout(cb,0); } }, getLoggedKeys: function () { return loggedKeys; }, updateCultureInfo: function () { Date.CultureInfo = new CultureInfo(); } }; $D.i18n.updateCultureInfo(); // run automatically }()); (function () { var $D = Date, $P = $D.prototype, p = function (s, l) { if (!l) { l = 2; } return ("000" + s).slice(l * -1); }; if (typeof window !== "undefined" && typeof window.console !== "undefined" && typeof window.console.log !== "undefined") { $D.console = console; // used only to raise non-critical errors if available } else { // set mock so we don't give errors. $D.console = { log: function(){}, error: function(){} }; } $D.Config = $D.Config || {}; $D.initOverloads = function() { /** * Overload of Date.now. Allows an alternate call for Date.now where it returns the * current Date as an object rather than just milliseconds since the Unix Epoch. * * Also provides an implementation of now() for browsers (IE<9) that don't have it. * * Backwards compatible so with work with either: * Date.now() [returns ms] * or * Date.now(true) [returns Date] */ if (!$D.now) { $D._now = function now() { return new Date().getTime(); }; } else if (!$D._now) { $D._now = $D.now; } $D.now = function (returnObj) { if (returnObj) { return $D.present(); } else { return $D._now(); } }; if ( !$P.toISOString ) { $P.toISOString = function() { return this.getUTCFullYear() + "-" + p(this.getUTCMonth() + 1) + "-" + p(this.getUTCDate()) + "T" + p(this.getUTCHours()) + ":" + p(this.getUTCMinutes()) + ":" + p(this.getUTCSeconds()) + "." + String( (this.getUTCMilliseconds()/1000).toFixed(3)).slice(2, 5) + "Z"; }; } // private if ( $P._toString === undefined ){ $P._toString = $P.toString; } }; $D.initOverloads(); /** * Gets a date that is set to the current date. The time is set to the start of the day (00:00 or 12:00 AM). * @return {Date} The current date. */ $D.today = function () { return new Date().clearTime(); }; /** * Gets a date that is set to the current date and time (same as new Date, but chainable) * @return {Date} The current date. */ $D.present = function () { return new Date(); }; /** * Compares the first date to the second date and returns an number indication of their relative values. * @param {Date} First Date object to compare [Required]. * @param {Date} Second Date object to compare to [Required]. * @return {Number} -1 = date1 is lessthan date2. 0 = values are equal. 1 = date1 is greaterthan date2. */ $D.compare = function (date1, date2) { if (isNaN(date1) || isNaN(date2)) { throw new Error(date1 + " - " + date2); } else if (date1 instanceof Date && date2 instanceof Date) { return (date1 < date2) ? -1 : (date1 > date2) ? 1 : 0; } else { throw new TypeError(date1 + " - " + date2); } }; /** * Compares the first Date object to the second Date object and returns true if they are equal. * @param {Date} First Date object to compare [Required] * @param {Date} Second Date object to compare to [Required] * @return {Boolean} true if dates are equal. false if they are not equal. */ $D.equals = function (date1, date2) { return (date1.compareTo(date2) === 0); }; /** * Gets the language appropriate day name when given the day number(0-6) * eg - 0 == Sunday * @return {String} The day name */ $D.getDayName = function (n) { return Date.CultureInfo.dayNames[n]; }; /** * Gets the day number (0-6) if given a CultureInfo specific string which is a valid dayName, abbreviatedDayName or shortestDayName (two char). * @param {String} The name of the day (eg. "Monday, "Mon", "tuesday", "tue", "We", "we"). * @return {Number} The day number */ $D.getDayNumberFromName = function (name) { var n = Date.CultureInfo.dayNames, m = Date.CultureInfo.abbreviatedDayNames, o = Date.CultureInfo.shortestDayNames, s = name.toLowerCase(); for (var i = 0; i < n.length; i++) { if (n[i].toLowerCase() === s || m[i].toLowerCase() === s || o[i].toLowerCase() === s) { return i; } } return -1; }; /** * Gets the month number (0-11) if given a Culture Info specific string which is a valid monthName or abbreviatedMonthName. * @param {String} The name of the month (eg. "February, "Feb", "october", "oct"). * @return {Number} The day number */ $D.getMonthNumberFromName = function (name) { var n = Date.CultureInfo.monthNames, m = Date.CultureInfo.abbreviatedMonthNames, s = name.toLowerCase(); for (var i = 0; i < n.length; i++) { if (n[i].toLowerCase() === s || m[i].toLowerCase() === s) { return i; } } return -1; }; /** * Gets the language appropriate month name when given the month number(0-11) * eg - 0 == January * @return {String} The month name */ $D.getMonthName = function (n) { return Date.CultureInfo.monthNames[n]; }; /** * Determines if the current date instance is within a LeapYear. * @param {Number} The year. * @return {Boolean} true if date is within a LeapYear, otherwise false. */ $D.isLeapYear = function (year) { return ((year % 4 === 0 && year % 100 !== 0) || year % 400 === 0); }; /** * Gets the number of days in the month, given a year and month value. Automatically corrects for LeapYear. * @param {Number} The year. * @param {Number} The month (0-11). * @return {Number} The number of days in the month. */ $D.getDaysInMonth = function (year, month) { if (!month && $D.validateMonth(year)) { month = year; year = Date.today().getFullYear(); } return [31, ($D.isLeapYear(year) ? 29 : 28), 31, 30, 31, 30, 31, 31, 30, 31, 30, 31][month]; }; $P.getDaysInMonth = function () { return $D.getDaysInMonth(this.getFullYear(), this.getMonth()); }; $D.getTimezoneAbbreviation = function (offset, dst) { var p, n = (dst || false) ? Date.CultureInfo.abbreviatedTimeZoneDST : Date.CultureInfo.abbreviatedTimeZoneStandard; for (p in n) { if (n.hasOwnProperty(p)) { if (n[p] === offset) { return p; } } } return null; }; $D.getTimezoneOffset = function (name, dst) { var i, a =[], z = Date.CultureInfo.timezones; if (!name) { name = (new Date()).getTimezone();} for (i = 0; i < z.length; i++) { if (z[i].name === name.toUpperCase()) { a.push(i); } } if (!z[a[0]]) { return null; } if (a.length === 1 || !dst) { return z[a[0]].offset; } else { for (i=0; i < a.length; i++) { if (z[a[i]].dst) { return z[a[i]].offset; } } } }; $D.getQuarter = function (d) { d = d || new Date(); // If no date supplied, use today var q = [1,2,3,4]; return q[Math.floor(d.getMonth() / 3)]; // ~~~ is a bitwise op. Faster than Math.floor }; $D.getDaysLeftInQuarter = function (d) { d = d || new Date(); var qEnd = new Date(d); qEnd.setMonth(qEnd.getMonth() + 3 - qEnd.getMonth() % 3, 0); return Math.floor((qEnd - d) / 8.64e7); }; // private var validate = function (n, min, max, name) { name = name ? name : "Object"; if (typeof n === "undefined") { return false; } else if (typeof n !== "number") { throw new TypeError(n + " is not a Number."); } else if (n < min || n > max) { // As failing validation is *not* an exceptional circumstance // lets not throw a RangeError Exception here. // It's semantically correct but it's not sensible. return false; } return true; }; /** * Validates the number is within an acceptable range for milliseconds [0-999]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateMillisecond = function (value) { return validate(value, 0, 999, "millisecond"); }; /** * Validates the number is within an acceptable range for seconds [0-59]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateSecond = function (value) { return validate(value, 0, 59, "second"); }; /** * Validates the number is within an acceptable range for minutes [0-59]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateMinute = function (value) { return validate(value, 0, 59, "minute"); }; /** * Validates the number is within an acceptable range for hours [0-23]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateHour = function (value) { return validate(value, 0, 23, "hour"); }; /** * Validates the number is within an acceptable range for the days in a month [0-MaxDaysInMonth]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateDay = function (value, year, month) { if (year === undefined || year === null || month === undefined || month === null) { return false;} return validate(value, 1, $D.getDaysInMonth(year, month), "day"); }; /** * Validates the number is within an acceptable range for months [0-11]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateWeek = function (value) { return validate(value, 0, 53, "week"); }; /** * Validates the number is within an acceptable range for months [0-11]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateMonth = function (value) { return validate(value, 0, 11, "month"); }; /** * Validates the number is within an acceptable range for years. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateYear = function (value) { /** * Per ECMAScript spec the range of times supported by Date objects is * exactly -100,000,000 days to +100,000,000 days measured relative to * midnight at the beginning of 01 January, 1970 UTC. * This gives a range of 8,640,000,000,000,000 milliseconds to either * side of 01 January, 1970 UTC. * * Earliest possible date: Tue, 20 Apr 271,822 B.C. 00:00:00 UTC * Latest possible date: Sat, 13 Sep 275,760 00:00:00 UTC */ return validate(value, -271822, 275760, "year"); }; $D.validateTimezone = function(value) { var timezones = {"ACDT":1,"ACST":1,"ACT":1,"ADT":1,"AEDT":1,"AEST":1,"AFT":1,"AKDT":1,"AKST":1,"AMST":1,"AMT":1,"ART":1,"AST":1,"AWDT":1,"AWST":1,"AZOST":1,"AZT":1,"BDT":1,"BIOT":1,"BIT":1,"BOT":1,"BRT":1,"BST":1,"BTT":1,"CAT":1,"CCT":1,"CDT":1,"CEDT":1,"CEST":1,"CET":1,"CHADT":1,"CHAST":1,"CHOT":1,"ChST":1,"CHUT":1,"CIST":1,"CIT":1,"CKT":1,"CLST":1,"CLT":1,"COST":1,"COT":1,"CST":1,"CT":1,"CVT":1,"CWST":1,"CXT":1,"DAVT":1,"DDUT":1,"DFT":1,"EASST":1,"EAST":1,"EAT":1,"ECT":1,"EDT":1,"EEDT":1,"EEST":1,"EET":1,"EGST":1,"EGT":1,"EIT":1,"EST":1,"FET":1,"FJT":1,"FKST":1,"FKT":1,"FNT":1,"GALT":1,"GAMT":1,"GET":1,"GFT":1,"GILT":1,"GIT":1,"GMT":1,"GST":1,"GYT":1,"HADT":1,"HAEC":1,"HAST":1,"HKT":1,"HMT":1,"HOVT":1,"HST":1,"ICT":1,"IDT":1,"IOT":1,"IRDT":1,"IRKT":1,"IRST":1,"IST":1,"JST":1,"KGT":1,"KOST":1,"KRAT":1,"KST":1,"LHST":1,"LINT":1,"MAGT":1,"MART":1,"MAWT":1,"MDT":1,"MET":1,"MEST":1,"MHT":1,"MIST":1,"MIT":1,"MMT":1,"MSK":1,"MST":1,"MUT":1,"MVT":1,"MYT":1,"NCT":1,"NDT":1,"NFT":1,"NPT":1,"NST":1,"NT":1,"NUT":1,"NZDT":1,"NZST":1,"OMST":1,"ORAT":1,"PDT":1,"PET":1,"PETT":1,"PGT":1,"PHOT":1,"PHT":1,"PKT":1,"PMDT":1,"PMST":1,"PONT":1,"PST":1,"PYST":1,"PYT":1,"RET":1,"ROTT":1,"SAKT":1,"SAMT":1,"SAST":1,"SBT":1,"SCT":1,"SGT":1,"SLST":1,"SRT":1,"SST":1,"SYOT":1,"TAHT":1,"THA":1,"TFT":1,"TJT":1,"TKT":1,"TLT":1,"TMT":1,"TOT":1,"TVT":1,"UCT":1,"ULAT":1,"UTC":1,"UYST":1,"UYT":1,"UZT":1,"VET":1,"VLAT":1,"VOLT":1,"VOST":1,"VUT":1,"WAKT":1,"WAST":1,"WAT":1,"WEDT":1,"WEST":1,"WET":1,"WST":1,"YAKT":1,"YEKT":1,"Z":1}; return (timezones[value] === 1); }; $D.validateTimezoneOffset= function(value) { // timezones go from +14hrs to -12hrs, the +X hours are negative offsets. return (value > -841 && value < 721); }; }()); (function () { var $D = Date, $P = $D.prototype, p = function (s, l) { if (!l) { l = 2; } return ("000" + s).slice(l * -1); }; var validateConfigObject = function (obj) { var result = {}, self = this, prop, testFunc; testFunc = function (prop, func, value) { if (prop === "day") { var month = (obj.month !== undefined) ? obj.month : self.getMonth(); var year = (obj.year !== undefined) ? obj.year : self.getFullYear(); return $D[func](value, year, month); } else { return $D[func](value); } }; for (prop in obj) { if (Object.prototype.hasOwnProperty.call(obj, prop)) { var func = "validate" + prop.charAt(0).toUpperCase() + prop.slice(1); if ($D[func] && obj[prop] !== null && testFunc(prop, func, obj[prop])) { result[prop] = obj[prop]; } } } return result; }; /** * Resets the time of this Date object to 12:00 AM (00:00), which is the start of the day. * @param {Boolean} .clone() this date instance before clearing Time * @return {Date} this */ $P.clearTime = function () { this.setHours(0); this.setMinutes(0); this.setSeconds(0); this.setMilliseconds(0); return this; }; /** * Resets the time of this Date object to the current time ('now'). * @return {Date} this */ $P.setTimeToNow = function () { var n = new Date(); this.setHours(n.getHours()); this.setMinutes(n.getMinutes()); this.setSeconds(n.getSeconds()); this.setMilliseconds(n.getMilliseconds()); return this; }; /** * Returns a new Date object that is an exact date and time copy of the original instance. * @return {Date} A new Date instance */ $P.clone = function () { return new Date(this.getTime()); }; /** * Compares this instance to a Date object and returns an number indication of their relative values. * @param {Date} Date object to compare [Required] * @return {Number} -1 = this is lessthan date. 0 = values are equal. 1 = this is greaterthan date. */ $P.compareTo = function (date) { return Date.compare(this, date); }; /** * Compares this instance to another Date object and returns true if they are equal. * @param {Date} Date object to compare. If no date to compare, new Date() [now] is used. * @return {Boolean} true if dates are equal. false if they are not equal. */ $P.equals = function (date) { return Date.equals(this, (date !== undefined ? date : new Date())); }; /** * Determines if this instance is between a range of two dates or equal to either the start or end dates. * @param {Date} Start of range [Required] * @param {Date} End of range [Required] * @return {Boolean} true is this is between or equal to the start and end dates, else false */ $P.between = function (start, end) { return this.getTime() >= start.getTime() && this.getTime() <= end.getTime(); }; /** * Determines if this date occurs after the date to compare to. * @param {Date} Date object to compare. If no date to compare, new Date() ("now") is used. * @return {Boolean} true if this date instance is greater than the date to compare to (or "now"), otherwise false. */ $P.isAfter = function (date) { return this.compareTo(date || new Date()) === 1; }; /** * Determines if this date occurs before the date to compare to. * @param {Date} Date object to compare. If no date to compare, new Date() ("now") is used. * @return {Boolean} true if this date instance is less than the date to compare to (or "now"). */ $P.isBefore = function (date) { return (this.compareTo(date || new Date()) === -1); }; /** * Determines if the current Date instance occurs today. * @return {Boolean} true if this date instance is 'today', otherwise false. */ /** * Determines if the current Date instance occurs on the same Date as the supplied 'date'. * If no 'date' to compare to is provided, the current Date instance is compared to 'today'. * @param {date} Date object to compare. If no date to compare, the current Date ("now") is used. * @return {Boolean} true if this Date instance occurs on the same Day as the supplied 'date'. */ $P.isToday = $P.isSameDay = function (date) { return this.clone().clearTime().equals((date || new Date()).clone().clearTime()); }; /** * Adds the specified number of milliseconds to this instance. * @param {Number} The number of milliseconds to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addMilliseconds = function (value) { if (!value) { return this; } this.setTime(this.getTime() + value * 1); return this; }; /** * Adds the specified number of seconds to this instance. * @param {Number} The number of seconds to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addSeconds = function (value) { if (!value) { return this; } return this.addMilliseconds(value * 1000); }; /** * Adds the specified number of seconds to this instance. * @param {Number} The number of seconds to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addMinutes = function (value) { if (!value) { return this; } return this.addMilliseconds(value * 60000); // 60*1000 }; /** * Adds the specified number of hours to this instance. * @param {Number} The number of hours to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addHours = function (value) { if (!value) { return this; } return this.addMilliseconds(value * 3600000); // 60*60*1000 }; /** * Adds the specified number of days to this instance. * @param {Number} The number of days to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addDays = function (value) { if (!value) { return this; } this.setDate(this.getDate() + value * 1); return this; }; /** * Adds the specified number of weekdays (ie - not sat or sun) to this instance. * @param {Number} The number of days to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addWeekdays = function (value) { if (!value) { return this; } var day = this.getDay(); var weeks = (Math.ceil(Math.abs(value)/7)); if (day === 0 || day === 6) { if (value > 0) { this.next().monday(); this.addDays(-1); day = this.getDay(); } } if (value < 0) { while (value < 0) { this.addDays(-1); day = this.getDay(); if (day !== 0 && day !== 6) { value++; } } return this; } else if (value > 5 || (6-day) <= value) { value = value + (weeks * 2); } return this.addDays(value); }; /** * Adds the specified number of weeks to this instance. * @param {Number} The number of weeks to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addWeeks = function (value) { if (!value) { return this; } return this.addDays(value * 7); }; /** * Adds the specified number of months to this instance. * @param {Number} The number of months to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addMonths = function (value) { if (!value) { return this; } var n = this.getDate(); this.setDate(1); this.setMonth(this.getMonth() + value * 1); this.setDate(Math.min(n, $D.getDaysInMonth(this.getFullYear(), this.getMonth()))); return this; }; $P.addQuarters = function (value) { if (!value) { return this; } // note this will take you to the same point in the quarter as you are now. // i.e. - if you are 15 days into the quarter you'll be 15 days into the resulting one. // bonus: this allows adding fractional quarters return this.addMonths(value * 3); }; /** * Adds the specified number of years to this instance. * @param {Number} The number of years to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addYears = function (value) { if (!value) { return this; } return this.addMonths(value * 12); }; /** * Adds (or subtracts) to the value of the years, months, weeks, days, hours, minutes, seconds, milliseconds of the date instance using given configuration object. Positive and Negative values allowed. * Example

	Date.today().add( { days: 1, months: 1 } )

	new Date().add( { years: -1 } )
	
* @param {Object} Configuration object containing attributes (months, days, etc.) * @return {Date} this */ $P.add = function (config) { if (typeof config === "number") { this._orient = config; return this; } var x = config; if (x.day) { // If we should be a different date than today (eg: for 'tomorrow -1d', etc). // Should only effect parsing, not direct usage (eg, Finish and FinishExact) if ((x.day - this.getDate()) !== 0) { this.setDate(x.day); } } if (x.milliseconds) { this.addMilliseconds(x.milliseconds); } if (x.seconds) { this.addSeconds(x.seconds); } if (x.minutes) { this.addMinutes(x.minutes); } if (x.hours) { this.addHours(x.hours); } if (x.weeks) { this.addWeeks(x.weeks); } if (x.months) { this.addMonths(x.months); } if (x.years) { this.addYears(x.years); } if (x.days) { this.addDays(x.days); } return this; }; /** * Get the week number. Week one (1) is the week which contains the first Thursday of the year. Monday is considered the first day of the week. * The .getWeek() function does NOT convert the date to UTC. The local datetime is used. * Please use .getISOWeek() to get the week of the UTC converted date. * @return {Number} 1 to 53 */ $P.getWeek = function (utc) { // Create a copy of this date object var self, target = new Date(this.valueOf()); if (utc) { target.addMinutes(target.getTimezoneOffset()); self = target.clone(); } else { self = this; } // ISO week date weeks start on monday // so correct the day number var dayNr = (self.getDay() + 6) % 7; // ISO 8601 states that week 1 is the week // with the first thursday of that year. // Set the target date to the thursday in the target week target.setDate(target.getDate() - dayNr + 3); // Store the millisecond value of the target date var firstThursday = target.valueOf(); // Set the target to the first thursday of the year // First set the target to january first target.setMonth(0, 1); // Not a thursday? Correct the date to the next thursday if (target.getDay() !== 4) { target.setMonth(0, 1 + ((4 - target.getDay()) + 7) % 7); } // The weeknumber is the number of weeks between the // first thursday of the year and the thursday in the target week return 1 + Math.ceil((firstThursday - target) / 604800000); // 604800000 = 7 * 24 * 3600 * 1000 }; /** * Get the ISO 8601 week number. Week one ("01") is the week which contains the first Thursday of the year. Monday is considered the first day of the week. * The .getISOWeek() function does convert the date to it's UTC value. Please use .getWeek() to get the week of the local date. * @return {String} "01" to "53" */ $P.getISOWeek = function () { return p(this.getWeek(true)); }; /** * Moves the date to Monday of the week set. Week one (1) is the week which contains the first Thursday of the year. * @param {Number} A Number (1 to 53) that represents the week of the year. * @return {Date} this */ $P.setWeek = function (n) { if ((n - this.getWeek()) === 0) { if (this.getDay() !== 1) { return this.moveToDayOfWeek(1, (this.getDay() > 1 ? -1 : 1)); } else { return this; } } else { return this.moveToDayOfWeek(1, (this.getDay() > 1 ? -1 : 1)).addWeeks(n - this.getWeek()); } }; $P.setQuarter = function (qtr) { var month = Math.abs(((qtr-1) * 3) + 1); return this.setMonth(month, 1); }; $P.getQuarter = function () { return Date.getQuarter(this); }; $P.getDaysLeftInQuarter = function () { return Date.getDaysLeftInQuarter(this); }; /** * Moves the date to the next n'th occurrence of the dayOfWeek starting from the beginning of the month. The number (-1) is a magic number and will return the last occurrence of the dayOfWeek in the month. * @param {Number} The dayOfWeek to move to * @param {Number} The n'th occurrence to move to. Use (-1) to return the last occurrence in the month * @return {Date} this */ $P.moveToNthOccurrence = function (dayOfWeek, occurrence) { if (dayOfWeek === "Weekday") { if (occurrence > 0) { this.moveToFirstDayOfMonth(); if (this.is().weekday()) { occurrence -= 1; } } else if (occurrence < 0) { this.moveToLastDayOfMonth(); if (this.is().weekday()) { occurrence += 1; } } else { return this; } return this.addWeekdays(occurrence); } var shift = 0; if (occurrence > 0) { shift = occurrence - 1; } else if (occurrence === -1) { this.moveToLastDayOfMonth(); if (this.getDay() !== dayOfWeek) { this.moveToDayOfWeek(dayOfWeek, -1); } return this; } return this.moveToFirstDayOfMonth().addDays(-1).moveToDayOfWeek(dayOfWeek, +1).addWeeks(shift); }; var moveToN = function (getFunc, addFunc, nVal) { return function (value, orient) { var diff = (value - this[getFunc]() + nVal * (orient || +1)) % nVal; return this[addFunc]((diff === 0) ? diff += nVal * (orient || +1) : diff); }; }; /** * Move to the next or last dayOfWeek based on the orient value. * @param {Number} The dayOfWeek to move to * @param {Number} Forward (+1) or Back (-1). Defaults to +1. [Optional] * @return {Date} this */ $P.moveToDayOfWeek = moveToN("getDay", "addDays", 7); /** * Move to the next or last month based on the orient value. * @param {Number} The month to move to. 0 = January, 11 = December * @param {Number} Forward (+1) or Back (-1). Defaults to +1. [Optional] * @return {Date} this */ $P.moveToMonth = moveToN("getMonth", "addMonths", 12); /** * Get the Ordinate of the current day ("th", "st", "rd"). * @return {String} */ $P.getOrdinate = function () { var num = this.getDate(); return ord(num); }; /** * Get the Ordinal day (numeric day number) of the year, adjusted for leap year. * @return {Number} 1 through 365 (366 in leap years) */ $P.getOrdinalNumber = function () { return Math.ceil((this.clone().clearTime() - new Date(this.getFullYear(), 0, 1)) / 86400000) + 1; }; /** * Get the time zone abbreviation of the current date. * @return {String} The abbreviated time zone name (e.g. "EST") */ $P.getTimezone = function () { return $D.getTimezoneAbbreviation(this.getUTCOffset(), this.isDaylightSavingTime()); }; $P.setTimezoneOffset = function (offset) { var here = this.getTimezoneOffset(), there = Number(offset) * -6 / 10; return (there || there === 0) ? this.addMinutes(there - here) : this; }; $P.setTimezone = function (offset) { return this.setTimezoneOffset($D.getTimezoneOffset(offset)); }; /** * Indicates whether Daylight Saving Time is observed in the current time zone. * @return {Boolean} true|false */ $P.hasDaylightSavingTime = function () { return (Date.today().set({month: 0, day: 1}).getTimezoneOffset() !== Date.today().set({month: 6, day: 1}).getTimezoneOffset()); }; /** * Indicates whether this Date instance is within the Daylight Saving Time range for the current time zone. * @return {Boolean} true|false */ $P.isDaylightSavingTime = function () { return Date.today().set({month: 0, day: 1}).getTimezoneOffset() !== this.getTimezoneOffset(); }; /** * Get the offset from UTC of the current date. * @return {String} The 4-character offset string prefixed with + or - (e.g. "-0500") */ $P.getUTCOffset = function (offset) { var n = (offset || this.getTimezoneOffset()) * -10 / 6, r; if (n < 0) { r = (n - 10000).toString(); return r.charAt(0) + r.substr(2); } else { r = (n + 10000).toString(); return "+" + r.substr(1); } }; /** * Returns the number of milliseconds between this date and date. * @param {Date} Defaults to now * @return {Number} The diff in milliseconds */ $P.getElapsed = function (date) { return (date || new Date()) - this; }; /** * Set the value of year, month, day, hour, minute, second, millisecond of date instance using given configuration object. * Example

	Date.today().set( { day: 20, month: 1 } )

	new Date().set( { millisecond: 0 } )
	
* * @param {Object} Configuration object containing attributes (month, day, etc.) * @return {Date} this */ $P.set = function (config) { config = validateConfigObject.call(this, config); var key; for (key in config) { if (Object.prototype.hasOwnProperty.call(config, key)) { var name = key.charAt(0).toUpperCase() + key.slice(1); var addFunc, getFunc; if (key !== "week" && key !== "month" && key !== "timezone" && key !== "timezoneOffset") { name += "s"; } addFunc = "add" + name; getFunc = "get" + name; if (key === "month") { addFunc = addFunc + "s"; } else if (key === "year"){ getFunc = "getFullYear"; } if (key !== "day" && key !== "timezone" && key !== "timezoneOffset" && key !== "week" && key !== "hour") { this[addFunc](config[key] - this[getFunc]()); } else if ( key === "timezone"|| key === "timezoneOffset" || key === "week" || key === "hour") { this["set"+name](config[key]); } } } // day has to go last because you can't validate the day without first knowing the month if (config.day) { this.addDays(config.day - this.getDate()); } return this; }; /** * Moves the date to the first day of the month. * @return {Date} this */ $P.moveToFirstDayOfMonth = function () { return this.set({ day: 1 }); }; /** * Moves the date to the last day of the month. * @return {Date} this */ $P.moveToLastDayOfMonth = function () { return this.set({ day: $D.getDaysInMonth(this.getFullYear(), this.getMonth())}); }; /** * Converts the value of the current Date object to its equivalent string representation. * Format Specifiers * CUSTOM DATE AND TIME FORMAT STRINGS * Format Description Example * ------ --------------------------------------------------------------------------- ----------------------- * s The seconds of the minute between 0-59. "0" to "59" * ss The seconds of the minute with leading zero if required. "00" to "59" * * m The minute of the hour between 0-59. "0" or "59" * mm The minute of the hour with leading zero if required. "00" or "59" * * h The hour of the day between 1-12. "1" to "12" * hh The hour of the day with leading zero if required. "01" to "12" * * H The hour of the day between 0-23. "0" to "23" * HH The hour of the day with leading zero if required. "00" to "23" * * d The day of the month between 1 and 31. "1" to "31" * dd The day of the month with leading zero if required. "01" to "31" * ddd Abbreviated day name. Date.CultureInfo.abbreviatedDayNames. "Mon" to "Sun" * dddd The full day name. Date.CultureInfo.dayNames. "Monday" to "Sunday" * * M The month of the year between 1-12. "1" to "12" * MM The month of the year with leading zero if required. "01" to "12" * MMM Abbreviated month name. Date.CultureInfo.abbreviatedMonthNames. "Jan" to "Dec" * MMMM The full month name. Date.CultureInfo.monthNames. "January" to "December" * * yy The year as a two-digit number. "99" or "08" * yyyy The full four digit year. "1999" or "2008" * * t Displays the first character of the A.M./P.M. designator. "A" or "P" * Date.CultureInfo.amDesignator or Date.CultureInfo.pmDesignator * tt Displays the A.M./P.M. designator. "AM" or "PM" * Date.CultureInfo.amDesignator or Date.CultureInfo.pmDesignator * * S The ordinal suffix ("st, "nd", "rd" or "th") of the current day. "st, "nd", "rd" or "th" * * STANDARD DATE AND TIME FORMAT STRINGS * Format Description Example *------ --------------------------------------------------------------------------- ----------------------- * d The CultureInfo shortDate Format Pattern "M/d/yyyy" * D The CultureInfo longDate Format Pattern "dddd, MMMM dd, yyyy" * F The CultureInfo fullDateTime Format Pattern "dddd, MMMM dd, yyyy h:mm:ss tt" * m The CultureInfo monthDay Format Pattern "MMMM dd" * r The CultureInfo rfc1123 Format Pattern "ddd, dd MMM yyyy HH:mm:ss GMT" * s The CultureInfo sortableDateTime Format Pattern "yyyy-MM-ddTHH:mm:ss" * t The CultureInfo shortTime Format Pattern "h:mm tt" * T The CultureInfo longTime Format Pattern "h:mm:ss tt" * u The CultureInfo universalSortableDateTime Format Pattern "yyyy-MM-dd HH:mm:ssZ" * y The CultureInfo yearMonth Format Pattern "MMMM, yyyy" * * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @return {String} A string representation of the current Date object. */ var ord = function (n) { switch (n * 1) { case 1: case 21: case 31: return "st"; case 2: case 22: return "nd"; case 3: case 23: return "rd"; default: return "th"; } }; var parseStandardFormats = function (format) { var y, c = Date.CultureInfo.formatPatterns; switch (format) { case "d": return this.toString(c.shortDate); case "D": return this.toString(c.longDate); case "F": return this.toString(c.fullDateTime); case "m": return this.toString(c.monthDay); case "r": case "R": y = this.clone().addMinutes(this.getTimezoneOffset()); return y.toString(c.rfc1123) + " GMT"; case "s": return this.toString(c.sortableDateTime); case "t": return this.toString(c.shortTime); case "T": return this.toString(c.longTime); case "u": y = this.clone().addMinutes(this.getTimezoneOffset()); return y.toString(c.universalSortableDateTime); case "y": return this.toString(c.yearMonth); default: return false; } }; var parseFormatStringsClosure = function (context) { return function (m) { if (m.charAt(0) === "\\") { return m.replace("\\", ""); } switch (m) { case "hh": return p(context.getHours() < 13 ? (context.getHours() === 0 ? 12 : context.getHours()) : (context.getHours() - 12)); case "h": return context.getHours() < 13 ? (context.getHours() === 0 ? 12 : context.getHours()) : (context.getHours() - 12); case "HH": return p(context.getHours()); case "H": return context.getHours(); case "mm": return p(context.getMinutes()); case "m": return context.getMinutes(); case "ss": return p(context.getSeconds()); case "s": return context.getSeconds(); case "yyyy": return p(context.getFullYear(), 4); case "yy": return p(context.getFullYear()); case "y": return context.getFullYear(); case "E": case "dddd": return Date.CultureInfo.dayNames[context.getDay()]; case "ddd": return Date.CultureInfo.abbreviatedDayNames[context.getDay()]; case "dd": return p(context.getDate()); case "d": return context.getDate(); case "MMMM": return Date.CultureInfo.monthNames[context.getMonth()]; case "MMM": return Date.CultureInfo.abbreviatedMonthNames[context.getMonth()]; case "MM": return p((context.getMonth() + 1)); case "M": return context.getMonth() + 1; case "t": return context.getHours() < 12 ? Date.CultureInfo.amDesignator.substring(0, 1) : Date.CultureInfo.pmDesignator.substring(0, 1); case "tt": return context.getHours() < 12 ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator; case "S": return ord(context.getDate()); case "W": return context.getWeek(); case "WW": return context.getISOWeek(); case "Q": return "Q" + context.getQuarter(); case "q": return String(context.getQuarter()); case "z": return context.getTimezone(); case "Z": case "X": return Date.getTimezoneOffset(context.getTimezone()); case "ZZ": // Timezone offset in seconds return context.getTimezoneOffset() * -60; case "u": return context.getDay(); case "L": return ($D.isLeapYear(context.getFullYear())) ? 1 : 0; case "B": // Swatch Internet Time (.beats) return "@"+((context.getUTCSeconds() + (context.getUTCMinutes()*60) + ((context.getUTCHours()+1)*3600))/86.4); default: return m; } }; }; $P.toString = function (format, ignoreStandards) { // Standard Date and Time Format Strings. Formats pulled from CultureInfo file and // may vary by culture. if (!ignoreStandards && format && format.length === 1) { output = parseStandardFormats.call(this, format); if (output) { return output; } } var parseFormatStrings = parseFormatStringsClosure(this); return format ? format.replace(/((\\)?(dd?d?d?|MM?M?M?|yy?y?y?|hh?|HH?|mm?|ss?|tt?|S|q|Q|WW?W?W?)(?![^\[]*\]))/g, parseFormatStrings).replace(/\[|\]/g, "") : this._toString(); }; }()); /************************************************************* * SugarPak - Domain Specific Language - Syntactical Sugar * *************************************************************/ (function () { var $D = Date, $P = $D.prototype, $N = Number.prototype; // private $P._orient = +1; // private $P._nth = null; // private $P._is = false; // private $P._same = false; // private $P._isSecond = false; // private $N._dateElement = "days"; /** * Moves the date to the next instance of a date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.today().next().friday();
	Date.today().next().fri();
	Date.today().next().march();
	Date.today().next().mar();
	Date.today().next().week();
	
* * @return {Date} date */ $P.next = function () { this._move = true; this._orient = +1; return this; }; /** * Creates a new Date (Date.today()) and moves the date to the next instance of the date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.next().friday();
	Date.next().fri();
	Date.next().march();
	Date.next().mar();
	Date.next().week();
	
* * @return {Date} date */ $D.next = function () { return $D.today().next(); }; /** * Moves the date to the previous instance of a date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.today().last().friday();
	Date.today().last().fri();
	Date.today().last().march();
	Date.today().last().mar();
	Date.today().last().week();
	
* * @return {Date} date */ $P.last = $P.prev = $P.previous = function () { this._move = true; this._orient = -1; return this; }; /** * Creates a new Date (Date.today()) and moves the date to the previous instance of the date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.last().friday();
	Date.last().fri();
	Date.previous().march();
	Date.prev().mar();
	Date.last().week();
	
* * @return {Date} date */ $D.last = $D.prev = $D.previous = function () { return $D.today().last(); }; /** * Performs a equality check when followed by either a month name, day name or .weekday() function. * Example

	Date.today().is().friday(); // true|false
	Date.today().is().fri();
	Date.today().is().march();
	Date.today().is().mar();
	
* * @return {Boolean} true|false */ $P.is = function () { this._is = true; return this; }; /** * Determines if two date objects occur on/in exactly the same instance of the subsequent date part function. * The function .same() must be followed by a date part function (example: .day(), .month(), .year(), etc). * * An optional Date can be passed in the date part function. If now date is passed as a parameter, 'Now' is used. * * The following example demonstrates how to determine if two dates fall on the exact same day. * * Example

	var d1 = Date.today(); // today at 00:00
	var d2 = new Date();   // exactly now.

	// Do they occur on the same day?
	d1.same().day(d2); // true
	
	// Do they occur on the same hour?
	d1.same().hour(d2); // false, unless d2 hour is '00' (midnight).
	
	// What if it's the same day, but one year apart?
	var nextYear = Date.today().add(1).year();

	d1.same().day(nextYear); // false, because the dates must occur on the exact same day. 
	
* * Scenario: Determine if a given date occurs during some week period 2 months from now. * * Example

	var future = Date.today().add(2).months();
	return someDate.same().week(future); // true|false;
	
* * @return {Boolean} true|false */ $P.same = function () { this._same = true; this._isSecond = false; return this; }; /** * Determines if the current date/time occurs during Today. Must be preceded by the .is() function. * Example

	someDate.is().today();    // true|false
	new Date().is().today();  // true
	Date.today().is().today();// true
	Date.today().add(-1).day().is().today(); // false
	
* * @return {Boolean} true|false */ $P.today = function () { return this.same().day(); }; /** * Determines if the current date is a weekday. This function must be preceded by the .is() function. * Example

	Date.today().is().weekday(); // true|false
	
* * @return {Boolean} true|false */ $P.weekday = function () { if (this._nth) { return df("Weekday").call(this); } if (this._move) { return this.addWeekdays(this._orient); } if (this._is) { this._is = false; return (!this.is().sat() && !this.is().sun()); } return false; }; /** * Determines if the current date is on the weekend. This function must be preceded by the .is() function. * Example

	Date.today().is().weekend(); // true|false
	
* * @return {Boolean} true|false */ $P.weekend = function () { if (this._is) { this._is = false; return (this.is().sat() || this.is().sun()); } return false; }; /** * Sets the Time of the current Date instance. A string "6:15 pm" or config object {hour:18, minute:15} are accepted. * Example

	// Set time to 6:15pm with a String
	Date.today().at("6:15pm");

	// Set time to 6:15pm with a config object
	Date.today().at({hour:18, minute:15});
	
* * @return {Date} date */ $P.at = function (time) { return (typeof time === "string") ? $D.parse(this.toString("d") + " " + time) : this.set(time); }; /** * Creates a new Date() and adds this (Number) to the date based on the preceding date element function (eg. second|minute|hour|day|month|year). * Example

	// Undeclared Numbers must be wrapped with parentheses. Requirment of JavaScript.
	(3).days().fromNow();
	(6).months().fromNow();

	// Declared Number variables do not require parentheses. 
	var n = 6;
	n.months().fromNow();
	
* * @return {Date} A new Date instance */ $N.fromNow = $N.after = function (date) { var c = {}; c[this._dateElement] = this; return ((!date) ? new Date() : date.clone()).add(c); }; /** * Creates a new Date() and subtract this (Number) from the date based on the preceding date element function (eg. second|minute|hour|day|month|year). * Example

	// Undeclared Numbers must be wrapped with parentheses. Requirment of JavaScript.
	(3).days().ago();
	(6).months().ago();

	// Declared Number variables do not require parentheses. 
	var n = 6;
	n.months().ago();
	
* * @return {Date} A new Date instance */ $N.ago = $N.before = function (date) { var c = {}, s = (this._dateElement[this._dateElement.length-1] !== "s") ? this._dateElement + "s" : this._dateElement; c[s] = this * -1; return ((!date) ? new Date() : date.clone()).add(c); }; // Do NOT modify the following string tokens. These tokens are used to build dynamic functions. // All culture-specific strings can be found in the CultureInfo files. var dx = ("sunday monday tuesday wednesday thursday friday saturday").split(/\s/), mx = ("january february march april may june july august september october november december").split(/\s/), px = ("Millisecond Second Minute Hour Day Week Month Year Quarter Weekday").split(/\s/), pxf = ("Milliseconds Seconds Minutes Hours Date Week Month FullYear Quarter").split(/\s/), nth = ("final first second third fourth fifth").split(/\s/), de; /** * Returns an object literal of all the date parts. * Example

	var o = new Date().toObject();
	
	// { year: 2008, month: 4, week: 20, day: 13, hour: 18, minute: 9, second: 32, millisecond: 812 }
	
	// The object properties can be referenced directly from the object.
	
	alert(o.day);  // alerts "13"
	alert(o.year); // alerts "2008"
	
* * @return {Date} An object literal representing the original date object. */ $P.toObject = function () { var o = {}; for (var i = 0; i < px.length; i++) { if (this["get" + pxf[i]]) { o[px[i].toLowerCase()] = this["get" + pxf[i]](); } } return o; }; /** * Returns a date created from an object literal. Ignores the .week property if set in the config. * Example

	var o = new Date().toObject();
	
	return Date.fromObject(o); // will return the same date. 

	var o2 = {month: 1, day: 20, hour: 18}; // birthday party!
	Date.fromObject(o2);
	
* * @return {Date} An object literal representing the original date object. */ $D.fromObject = function(config) { config.week = null; return Date.today().set(config); }; // Create day name functions and abbreviated day name functions (eg. monday(), friday(), fri()). var df = function (n) { return function () { if (this._is) { this._is = false; return this.getDay() === n; } if (this._move) { this._move = null; } if (this._nth !== null) { // If the .second() function was called earlier, remove the _orient // from the date, and then continue. // This is required because 'second' can be used in two different context. // // Example // // Date.today().add(1).second(); // Date.march().second().monday(); // // Things get crazy with the following... // Date.march().add(1).second().second().monday(); // but it works!! // if (this._isSecond) { this.addSeconds(this._orient * -1); } // make sure we reset _isSecond this._isSecond = false; var ntemp = this._nth; this._nth = null; var temp = this.clone().moveToLastDayOfMonth(); this.moveToNthOccurrence(n, ntemp); if (this > temp) { throw new RangeError($D.getDayName(n) + " does not occur " + ntemp + " times in the month of " + $D.getMonthName(temp.getMonth()) + " " + temp.getFullYear() + "."); } return this; } return this.moveToDayOfWeek(n, this._orient); }; }; var sdf = function (n) { return function () { var t = $D.today(), shift = n - t.getDay(); if (n === 0 && Date.CultureInfo.firstDayOfWeek === 1 && t.getDay() !== 0) { shift = shift + 7; } return t.addDays(shift); }; }; // Create month name functions and abbreviated month name functions (eg. january(), march(), mar()). var month_instance_functions = function (n) { return function () { if (this._is) { this._is = false; return this.getMonth() === n; } return this.moveToMonth(n, this._orient); }; }; var month_static_functions = function (n) { return function () { return $D.today().set({ month: n, day: 1 }); }; }; var processTerms = function (names, staticFunc, instanceFunc) { for (var i = 0; i < names.length; i++) { // Create constant static Name variables. $D[names[i].toUpperCase()] = $D[names[i].toUpperCase().substring(0, 3)] = i; // Create Name functions. $D[names[i]] = $D[names[i].substring(0, 3)] = staticFunc(i); // Create Name instance functions. $P[names[i]] = $P[names[i].substring(0, 3)] = instanceFunc(i); } }; processTerms(dx, sdf, df); processTerms(mx, month_static_functions, month_instance_functions); // Create date element functions and plural date element functions used with Date (eg. day(), days(), months()). var ef = function (j) { return function () { // if the .second() function was called earlier, the _orient // has alread been added. Just return this and reset _isSecond. if (this._isSecond) { this._isSecond = false; return this; } if (this._same) { this._same = this._is = false; var o1 = this.toObject(), o2 = (arguments[0] || new Date()).toObject(), v = "", k = j.toLowerCase(); // the substr trick with -1 doesn't work in IE8 or less k = (k[k.length-1] === "s") ? k.substring(0,k.length-1) : k; for (var m = (px.length - 1); m > -1; m--) { v = px[m].toLowerCase(); if (o1[v] !== o2[v]) { return false; } if (k === v) { break; } } return true; } if (j.substring(j.length - 1) !== "s") { j += "s"; } if (this._move) { this._move = null; } return this["add" + j](this._orient); }; }; var nf = function (n) { return function () { this._dateElement = n; return this; }; }; for (var k = 0; k < px.length; k++) { de = px[k].toLowerCase(); if(de !== "weekday") { // Create date element functions and plural date element functions used with Date (eg. day(), days(), months()). $P[de] = $P[de + "s"] = ef(px[k]); // Create date element functions and plural date element functions used with Number (eg. day(), days(), months()). $N[de] = $N[de + "s"] = nf(de + "s"); } } $P._ss = ef("Second"); var nthfn = function (n) { return function (dayOfWeek) { if (this._same) { return this._ss(arguments[0]); } if (dayOfWeek || dayOfWeek === 0) { return this.moveToNthOccurrence(dayOfWeek, n); } this._nth = n; // if the operator is 'second' add the _orient, then deal with it later... if (n === 2 && (dayOfWeek === undefined || dayOfWeek === null)) { this._isSecond = true; return this.addSeconds(this._orient); } return this; }; }; for (var l = 0; l < nth.length; l++) { $P[nth[l]] = (l === 0) ? nthfn(-1) : nthfn(l); } }()); (function () { "use strict"; Date.Parsing = { Exception: function (s) { this.message = "Parse error at '" + s.substring(0, 10) + " ...'"; } }; var $P = Date.Parsing; var dayOffsets = { standard: [0,31,59,90,120,151,181,212,243,273,304,334], leap: [0,31,60,91,121,152,182,213,244,274,305,335] }; $P.isLeapYear = function(year) { return ((year % 4 === 0) && (year % 100 !== 0)) || (year % 400 === 0); }; var utils = { multiReplace : function (str, hash ) { var key; for (key in hash) { if (Object.prototype.hasOwnProperty.call(hash, key)) { var regex; if (typeof hash[key] === "function") { } else { regex = (hash[key] instanceof RegExp) ? hash[key] : new RegExp(hash[key], "g"); } str = str.replace(regex, key); } } return str; }, getDayOfYearFromWeek : function (obj) { var d, jan4, offset; obj.weekDay = (!obj.weekDay && obj.weekDay !== 0) ? 1 : obj.weekDay; d = new Date(obj.year, 0, 4); jan4 = d.getDay() === 0 ? 7 : d.getDay(); // JS is 0 indexed on Sunday. offset = jan4+3; obj.dayOfYear = ((obj.week * 7) + (obj.weekDay === 0 ? 7 : obj.weekDay))-offset; return obj; }, getDayOfYear : function (obj, dayOffset) { if (!obj.dayOfYear) { obj = utils.getDayOfYearFromWeek(obj); } for (var i=0;i <= dayOffset.length;i++) { if (obj.dayOfYear < dayOffset[i] || i === dayOffset.length) { obj.day = obj.day ? obj.day : (obj.dayOfYear - dayOffset[i-1]); break; } else { obj.month = i; } } return obj; }, adjustForTimeZone : function (obj, date) { var offset; if (obj.zone.toUpperCase() === "Z" || (obj.zone_hours === 0 && obj.zone_minutes === 0)) { // it's UTC/GML so work out the current timeszone offset offset = -date.getTimezoneOffset(); } else { offset = (obj.zone_hours*60) + (obj.zone_minutes || 0); if (obj.zone_sign === "+") { offset *= -1; } offset -= date.getTimezoneOffset(); } date.setMinutes(date.getMinutes()+offset); return date; }, setDefaults : function (obj) { obj.year = obj.year || Date.today().getFullYear(); obj.hours = obj.hours || 0; obj.minutes = obj.minutes || 0; obj.seconds = obj.seconds || 0; obj.milliseconds = obj.milliseconds || 0; if (!(!obj.month && (obj.week || obj.dayOfYear))) { // if we have a month, or if we don't but don't have the day calculation data obj.month = obj.month || 0; obj.day = obj.day || 1; } return obj; }, dataNum: function (data, mod, explict, postProcess) { var dataNum = data*1; if (mod) { if (postProcess) { return data ? mod(data)*1 : data; } else { return data ? mod(dataNum) : data; } } else if (!explict){ return data ? dataNum : data; } else { return (data && typeof data !== "undefined") ? dataNum : data; } }, timeDataProcess: function (obj) { var timeObj = {}; for (var x in obj.data) { if (obj.data.hasOwnProperty(x)) { timeObj[x] = obj.ignore[x] ? obj.data[x] : utils.dataNum(obj.data[x], obj.mods[x], obj.explict[x], obj.postProcess[x]); } } if (obj.data.secmins) { obj.data.secmins = obj.data.secmins.replace(",", ".") * 60; if (!timeObj.minutes) { timeObj.minutes = obj.data.secmins; } else if (!timeObj.seconds) { timeObj.seconds = obj.data.secmins; } delete obj.secmins; } return timeObj; }, buildTimeObjectFromData: function (data) { var time = utils.timeDataProcess({ data: { year : data[1], month : data[5], day : data[7], week : data[8], dayOfYear : data[10], hours : data[15], zone_hours : data[23], zone_minutes : data[24], zone : data[21], zone_sign : data[22], weekDay : data[9], minutes: data[16], seconds: data[19], milliseconds: data[20], secmins: data[18] }, mods: { month: function(data) { return data-1; }, weekDay: function (data) { data = Math.abs(data); return (data === 7 ? 0 : data); }, minutes: function (data) { return data.replace(":",""); }, seconds: function (data) { return Math.floor( (data.replace(":","").replace(",","."))*1 ); }, milliseconds: function (data) { return (data.replace(",",".")*1000); } }, postProcess: { minutes: true, seconds: true, milliseconds: true }, explict: { zone_hours: true, zone_minutes: true }, ignore: { zone: true, zone_sign: true, secmins: true } }); return time; }, addToHash: function (hash, keys, data) { keys = keys; data = data; var len = keys.length; for (var i = 0; i < len; i++) { hash[keys[i]] = data[i]; } return hash; }, combineRegex: function (r1, r2) { return new RegExp("(("+r1.source+")\\s("+r2.source+"))"); }, getDateNthString: function(add, last, inc){ if (add) { return Date.today().addDays(inc).toString("d"); } else if (last) { return Date.today().last()[inc]().toString("d"); } }, buildRegexData: function (array) { var arr = []; var len = array.length; for (var i=0; i < len; i++) { if (Object.prototype.toString.call(array[i]) === '[object Array]') { // oldIE compat version of Array.isArray arr.push(this.combineRegex(array[i][0], array[i][1])); } else { arr.push(array[i]); } } return arr; } }; $P.processTimeObject = function (obj) { var date, dayOffset; utils.setDefaults(obj); dayOffset = ($P.isLeapYear(obj.year)) ? dayOffsets.leap : dayOffsets.standard; if (!obj.month && (obj.week || obj.dayOfYear)) { utils.getDayOfYear(obj, dayOffset); } else { obj.dayOfYear = dayOffset[obj.month] + obj.day; } date = new Date(obj.year, obj.month, obj.day, obj.hours, obj.minutes, obj.seconds, obj.milliseconds); if (obj.zone) { utils.adjustForTimeZone(obj, date); // adjust (and calculate) for timezone } return date; }; $P.ISO = { regex : /^([\+-]?\d{4}(?!\d{2}\b))((-?)((0[1-9]|1[0-2])(\3([12]\d|0[1-9]|3[01]))?|W([0-4]\d|5[0-3])(-?[1-7])?|(00[1-9]|0[1-9]\d|[12]\d{2}|3([0-5]\d|6[1-6])))([T\s]((([01]\d|2[0-4])((:?)[0-5]\d)?|24\:?00)([\.,]\d+(?!:))?)?(\17[0-5]\d([\.,]\d+)?)?\s?([zZ]|([\+-])([01]\d|2[0-3]):?([0-5]\d)?)?)?)?$/, parse : function (s) { var time, data = s.match(this.regex); if (!data || !data.length) { return null; } time = utils.buildTimeObjectFromData(data); if (!time.year || (!time.year && (!time.month && !time.day) && (!time.week && !time.dayOfYear)) ) { return null; } return $P.processTimeObject(time); } }; $P.Numeric = { isNumeric: function (e){return!isNaN(parseFloat(e))&&isFinite(e);}, regex: /\b([0-1]?[0-9])([0-3]?[0-9])([0-2]?[0-9]?[0-9][0-9])\b/i, parse: function (s) { var data, i, time = {}, order = Date.CultureInfo.dateElementOrder.split(""); if (!(this.isNumeric(s)) || // if it's non-numeric OR (s[0] === "+" && s[0] === "-")) { // It's an arithmatic string (eg +/-1000) return null; } if (s.length < 5 && s.indexOf(".") < 0 && s.indexOf("/") < 0) { // assume it's just a year. time.year = s; return $P.processTimeObject(time); } data = s.match(this.regex); if (!data || !data.length) { return null; } for (i=0; i < order.length; i++) { switch(order[i]) { case "d": time.day = data[i+1]; break; case "m": time.month = (data[i+1]-1); break; case "y": time.year = data[i+1]; break; } } return $P.processTimeObject(time); } }; $P.Normalizer = { regexData: function () { var $R = Date.CultureInfo.regexPatterns; return utils.buildRegexData([ $R.tomorrow, $R.yesterday, [$R.past, $R.mon], [$R.past, $R.tue], [$R.past, $R.wed], [$R.past, $R.thu], [$R.past, $R.fri], [$R.past, $R.sat], [$R.past, $R.sun] ]); }, basicReplaceHash : function() { var $R = Date.CultureInfo.regexPatterns; return { "January": $R.jan.source, "February": $R.feb, "March": $R.mar, "April": $R.apr, "May": $R.may, "June": $R.jun, "July": $R.jul, "August": $R.aug, "September": $R.sep, "October": $R.oct, "November": $R.nov, "December": $R.dec, "": /\bat\b/gi, " ": /\s{2,}/, "am": $R.inTheMorning, "9am": $R.thisMorning, "pm": $R.inTheEvening, "7pm":$R.thisEvening }; }, keys : function(){ return [ utils.getDateNthString(true, false, 1), // tomorrow utils.getDateNthString(true, false, -1), // yesterday utils.getDateNthString(false, true, "monday"), //last mon utils.getDateNthString(false, true, "tuesday"), //last tues utils.getDateNthString(false, true, "wednesday"), //last wed utils.getDateNthString(false, true, "thursday"), //last thurs utils.getDateNthString(false, true, "friday"), //last fri utils.getDateNthString(false, true, "saturday"), //last sat utils.getDateNthString(false, true, "sunday") //last sun ]; }, buildRegexFunctions: function () { var $R = Date.CultureInfo.regexPatterns; var __ = Date.i18n.__; var tomorrowRE = new RegExp("(\\b\\d\\d?("+__("AM")+"|"+__("PM")+")? )("+$R.tomorrow.source.slice(1)+")", "i"); // adapted tomorrow regex for AM PM relative dates var todayRE = new RegExp($R.today.source + "(?!\\s*([+-]))\\b"); // today, but excludes the math operators (eg "today + 2h") this.replaceFuncs = [ [todayRE, function (full) { return (full.length > 1) ? Date.today().toString("d") : full; }], [tomorrowRE, function(full, m1) { var t = Date.today().addDays(1).toString("d"); return (t + " " + m1); }], [$R.amThisMorning, function(str, am){return am;}], [$R.pmThisEvening, function(str, pm){return pm;}] ]; }, buildReplaceData: function () { this.buildRegexFunctions(); this.replaceHash = utils.addToHash(this.basicReplaceHash(), this.keys(), this.regexData()); }, stringReplaceFuncs: function (s) { for (var i=0; i < this.replaceFuncs.length; i++) { s = s.replace(this.replaceFuncs[i][0], this.replaceFuncs[i][1]); } return s; }, parse: function (s) { s = this.stringReplaceFuncs(s); s = utils.multiReplace(s, this.replaceHash); try { var n = s.split(/([\s\-\.\,\/\x27]+)/); if (n.length === 3 && $P.Numeric.isNumeric(n[0]) && $P.Numeric.isNumeric(n[2]) && (n[2].length >= 4)) { // ok, so we're dealing with x/year. But that's not a full date. // This fixes wonky dateElementOrder parsing when set to dmy order. if (Date.CultureInfo.dateElementOrder[0] === "d") { s = "1/" + n[0] + "/" + n[2]; // set to 1st of month and normalize the seperator } } } catch (e) {} return s; } }; $P.Normalizer.buildReplaceData(); }()); (function () { var $P = Date.Parsing; var _ = $P.Operators = { // // Tokenizers // rtoken: function (r) { // regex token return function (s) { var mx = s.match(r); if (mx) { return ([ mx[0], s.substring(mx[0].length) ]); } else { throw new $P.Exception(s); } }; }, token: function () { // whitespace-eating token return function (s) { return _.rtoken(new RegExp("^\\s*" + s + "\\s*"))(s); }; }, stoken: function (s) { // string token return _.rtoken(new RegExp("^" + s)); }, // Atomic Operators until: function (p) { return function (s) { var qx = [], rx = null; while (s.length) { try { rx = p.call(this, s); } catch (e) { qx.push(rx[0]); s = rx[1]; continue; } break; } return [ qx, s ]; }; }, many: function (p) { return function (s) { var rx = [], r = null; while (s.length) { try { r = p.call(this, s); } catch (e) { return [ rx, s ]; } rx.push(r[0]); s = r[1]; } return [ rx, s ]; }; }, // generator operators -- see below optional: function (p) { return function (s) { var r = null; try { r = p.call(this, s); } catch (e) { return [ null, s ]; } return [ r[0], r[1] ]; }; }, not: function (p) { return function (s) { try { p.call(this, s); } catch (e) { return [null, s]; } throw new $P.Exception(s); }; }, ignore: function (p) { return p ? function (s) { var r = null; r = p.call(this, s); return [null, r[1]]; } : null; }, product: function () { var px = arguments[0], qx = Array.prototype.slice.call(arguments, 1), rx = []; for (var i = 0 ; i < px.length ; i++) { rx.push(_.each(px[i], qx)); } return rx; }, cache: function (rule) { var cache = {}, cache_length = 0, cache_keys = [], CACHE_MAX = Date.Config.CACHE_MAX || 100000, r = null; var cacheCheck = function () { if (cache_length === CACHE_MAX) { // kill several keys, don't want to have to do this all the time... for (var i=0; i < 10; i++) { var key = cache_keys.shift(); if (key) { delete cache[key]; cache_length--; } } } }; return function (s) { cacheCheck(); try { r = cache[s] = (cache[s] || rule.call(this, s)); } catch (e) { r = cache[s] = e; } cache_length++; cache_keys.push(s); if (r instanceof $P.Exception) { throw r; } else { return r; } }; }, // vector operators -- see below any: function () { var px = arguments; return function (s) { var r = null; for (var i = 0; i < px.length; i++) { if (px[i] == null) { continue; } try { r = (px[i].call(this, s)); } catch (e) { r = null; } if (r) { return r; } } throw new $P.Exception(s); }; }, each: function () { var px = arguments; return function (s) { var rx = [], r = null; for (var i = 0; i < px.length ; i++) { if (px[i] == null) { continue; } try { r = (px[i].call(this, s)); } catch (e) { throw new $P.Exception(s); } rx.push(r[0]); s = r[1]; } return [ rx, s]; }; }, all: function () { var px = arguments, _ = _; return _.each(_.optional(px)); }, // delimited operators sequence: function (px, d, c) { d = d || _.rtoken(/^\s*/); c = c || null; if (px.length === 1) { return px[0]; } return function (s) { var r = null, q = null; var rx = []; for (var i = 0; i < px.length ; i++) { try { r = px[i].call(this, s); } catch (e) { break; } rx.push(r[0]); try { q = d.call(this, r[1]); } catch (ex) { q = null; break; } s = q[1]; } if (!r) { throw new $P.Exception(s); } if (q) { throw new $P.Exception(q[1]); } if (c) { try { r = c.call(this, r[1]); } catch (ey) { throw new $P.Exception(r[1]); } } return [ rx, (r?r[1]:s) ]; }; }, // // Composite Operators // between: function (d1, p, d2) { d2 = d2 || d1; var _fn = _.each(_.ignore(d1), p, _.ignore(d2)); return function (s) { var rx = _fn.call(this, s); return [[rx[0][0], r[0][2]], rx[1]]; }; }, list: function (p, d, c) { d = d || _.rtoken(/^\s*/); c = c || null; return (p instanceof Array ? _.each(_.product(p.slice(0, -1), _.ignore(d)), p.slice(-1), _.ignore(c)) : _.each(_.many(_.each(p, _.ignore(d))), px, _.ignore(c))); }, set: function (px, d, c) { d = d || _.rtoken(/^\s*/); c = c || null; return function (s) { // r is the current match, best the current 'best' match // which means it parsed the most amount of input var r = null, p = null, q = null, rx = null, best = [[], s], last = false; // go through the rules in the given set for (var i = 0; i < px.length ; i++) { // last is a flag indicating whether this must be the last element // if there is only 1 element, then it MUST be the last one q = null; p = null; r = null; last = (px.length === 1); // first, we try simply to match the current pattern // if not, try the next pattern try { r = px[i].call(this, s); } catch (e) { continue; } // since we are matching against a set of elements, the first // thing to do is to add r[0] to matched elements rx = [[r[0]], r[1]]; // if we matched and there is still input to parse and // we don't already know this is the last element, // we're going to next check for the delimiter ... // if there's none, or if there's no input left to parse // than this must be the last element after all ... if (r[1].length > 0 && ! last) { try { q = d.call(this, r[1]); } catch (ex) { last = true; } } else { last = true; } // if we parsed the delimiter and now there's no more input, // that means we shouldn't have parsed the delimiter at all // so don't update r and mark this as the last element ... if (!last && q[1].length === 0) { last = true; } // so, if this isn't the last element, we're going to see if // we can get any more matches from the remaining (unmatched) // elements ... if (!last) { // build a list of the remaining rules we can match against, // i.e., all but the one we just matched against var qx = []; for (var j = 0; j < px.length ; j++) { if (i !== j) { qx.push(px[j]); } } // now invoke recursively set with the remaining input // note that we don't include the closing delimiter ... // we'll check for that ourselves at the end p = _.set(qx, d).call(this, q[1]); // if we got a non-empty set as a result ... // (otw rx already contains everything we want to match) if (p[0].length > 0) { // update current result, which is stored in rx ... // basically, pick up the remaining text from p[1] // and concat the result from p[0] so that we don't // get endless nesting ... rx[0] = rx[0].concat(p[0]); rx[1] = p[1]; } } // at this point, rx either contains the last matched element // or the entire matched set that starts with this element. // now we just check to see if this variation is better than // our best so far, in terms of how much of the input is parsed if (rx[1].length < best[1].length) { best = rx; } // if we've parsed all the input, then we're finished if (best[1].length === 0) { break; } } // so now we've either gone through all the patterns trying them // as the initial match; or we found one that parsed the entire // input string ... // if best has no matches, just return empty set ... if (best[0].length === 0) { return best; } // if a closing delimiter is provided, then we have to check it also if (c) { // we try this even if there is no remaining input because the pattern // may well be optional or match empty input ... try { q = c.call(this, best[1]); } catch (ey) { throw new $P.Exception(best[1]); } // it parsed ... be sure to update the best match remaining input best[1] = q[1]; } // if we're here, either there was no closing delimiter or we parsed it // so now we have the best match; just return it! return best; }; }, forward: function (gr, fname) { return function (s) { return gr[fname].call(this, s); }; }, // // Translation Operators // replace: function (rule, repl) { return function (s) { var r = rule.call(this, s); return [repl, r[1]]; }; }, process: function (rule, fn) { return function (s) { var r = rule.call(this, s); return [fn.call(this, r[0]), r[1]]; }; }, min: function (min, rule) { return function (s) { var rx = rule.call(this, s); if (rx[0].length < min) { throw new $P.Exception(s); } return rx; }; } }; // Generator Operators And Vector Operators // Generators are operators that have a signature of F(R) => R, // taking a given rule and returning another rule, such as // ignore, which parses a given rule and throws away the result. // Vector operators are those that have a signature of F(R1,R2,...) => R, // take a list of rules and returning a new rule, such as each. // Generator operators are converted (via the following _generator // function) into functions that can also take a list or array of rules // and return an array of new rules as though the function had been // called on each rule in turn (which is what actually happens). // This allows generators to be used with vector operators more easily. // Example: // each(ignore(foo, bar)) instead of each(ignore(foo), ignore(bar)) // This also turns generators into vector operators, which allows // constructs like: // not(cache(foo, bar)) var _generator = function (op) { function gen() { var args = null, rx = [], px, i; if (arguments.length > 1) { args = Array.prototype.slice.call(arguments); } else if (arguments[0] instanceof Array) { args = arguments[0]; } if (args) { px = args.shift(); if (px.length > 0) { args.unshift(px[i]); rx.push(op.apply(null, args)); args.shift(); return rx; } } else { return op.apply(null, arguments); } } return gen; }; var gx = "optional not ignore cache".split(/\s/); for (var i = 0 ; i < gx.length ; i++) { _[gx[i]] = _generator(_[gx[i]]); } var _vector = function (op) { return function () { if (arguments[0] instanceof Array) { return op.apply(null, arguments[0]); } else { return op.apply(null, arguments); } }; }; var vx = "each any all".split(/\s/); for (var j = 0 ; j < vx.length ; j++) { _[vx[j]] = _vector(_[vx[j]]); } }()); (function () { var $D = Date; var flattenAndCompact = function (ax) { var rx = []; for (var i = 0; i < ax.length; i++) { if (ax[i] instanceof Array) { rx = rx.concat(flattenAndCompact(ax[i])); } else { if (ax[i]) { rx.push(ax[i]); } } } return rx; }; var parseMeridian = function () { if (this.meridian && (this.hour || this.hour === 0)) { if (this.meridian === "a" && this.hour > 11 && Date.Config.strict24hr){ throw "Invalid hour and meridian combination"; } else if (this.meridian === "p" && this.hour < 12 && Date.Config.strict24hr){ throw "Invalid hour and meridian combination"; } else if (this.meridian === "p" && this.hour < 12) { this.hour = this.hour + 12; } else if (this.meridian === "a" && this.hour === 12) { this.hour = 0; } } }; var setDefaults = function () { var now = new Date(); if ((this.hour || this.minute) && (!this.month && !this.year && !this.day)) { this.day = now.getDate(); } if (!this.year) { this.year = now.getFullYear(); } if (!this.month && this.month !== 0) { this.month = now.getMonth(); } if (!this.day) { this.day = 1; } if (!this.hour) { this.hour = 0; } if (!this.minute) { this.minute = 0; } if (!this.second) { this.second = 0; } if (!this.millisecond) { this.millisecond = 0; } }; var finishUtils = { getToday: function () { if (this.now || "hour minute second".indexOf(this.unit) !== -1) { return new Date(); } else { return $D.today(); } }, setDaysFromWeekday: function (today, orient){ var gap; orient = orient || 1; this.unit = "day"; gap = ($D.getDayNumberFromName(this.weekday) - today.getDay()); this.days = gap ? ((gap + (orient * 7)) % 7) : (orient * 7); return this; }, setMonthsFromMonth: function (today, orient) { var gap; orient = orient || 1; this.unit = "month"; gap = (this.month - today.getMonth()); this.months = gap ? ((gap + (orient * 12)) % 12) : (orient * 12); this.month = null; return this; }, setDMYFromWeekday: function () { var d = Date[this.weekday](); this.day = d.getDate(); if (!this.month) { this.month = d.getMonth(); } this.year = d.getFullYear(); return this; }, setUnitValue: function (orient) { if (!this.value && this.operator && this.operator !== null && this[this.unit + "s"] && this[this.unit + "s"] !== null) { this[this.unit + "s"] = this[this.unit + "s"] + ((this.operator === "add") ? 1 : -1) + (this.value||0) * orient; } else if (this[this.unit + "s"] == null || this.operator != null) { if (!this.value) { this.value = 1; } this[this.unit + "s"] = this.value * orient; } }, generateDateFromWeeks: function () { var weekday = (this.weekday !== undefined) ? this.weekday : "today"; var d = Date[weekday]().addWeeks(this.weeks); if (this.now) { d.setTimeToNow(); } return d; } }; $D.Translator = { hour: function (s) { return function () { this.hour = Number(s); }; }, minute: function (s) { return function () { this.minute = Number(s); }; }, second: function (s) { return function () { this.second = Number(s); }; }, /* for ss.s format */ secondAndMillisecond: function (s) { return function () { var mx = s.match(/^([0-5][0-9])\.([0-9]{1,3})/); this.second = Number(mx[1]); this.millisecond = Number(mx[2]); }; }, meridian: function (s) { return function () { this.meridian = s.slice(0, 1).toLowerCase(); }; }, timezone: function (s) { return function () { var n = s.replace(/[^\d\+\-]/g, ""); if (n.length) { this.timezoneOffset = Number(n); } else { this.timezone = s.toLowerCase(); } }; }, day: function (x) { var s = x[0]; return function () { this.day = Number(s.match(/\d+/)[0]); if (this.day < 1) { throw "invalid day"; } }; }, month: function (s) { return function () { this.month = (s.length === 3) ? "jan feb mar apr may jun jul aug sep oct nov dec".indexOf(s)/4 : Number(s) - 1; if (this.month < 0) { throw "invalid month"; } }; }, year: function (s) { return function () { var n = Number(s); this.year = ((s.length > 2) ? n : (n + (((n + 2000) < Date.CultureInfo.twoDigitYearMax) ? 2000 : 1900))); }; }, rday: function (s) { return function () { switch (s) { case "yesterday": this.days = -1; break; case "tomorrow": this.days = 1; break; case "today": this.days = 0; break; case "now": this.days = 0; this.now = true; break; } }; }, finishExact: function (x) { var d; x = (x instanceof Array) ? x : [x]; for (var i = 0 ; i < x.length ; i++) { if (x[i]) { x[i].call(this); } } setDefaults.call(this); parseMeridian.call(this); if (this.day > $D.getDaysInMonth(this.year, this.month)) { throw new RangeError(this.day + " is not a valid value for days."); } d = new Date(this.year, this.month, this.day, this.hour, this.minute, this.second, this.millisecond); if (this.year < 100) { d.setFullYear(this.year); // means years less that 100 are process correctly. JS will parse it otherwise as 1900-1999. } if (this.timezone) { d.set({ timezone: this.timezone }); } else if (this.timezoneOffset) { d.set({ timezoneOffset: this.timezoneOffset }); } return d; }, finish: function (x) { var today, expression, orient, temp; x = (x instanceof Array) ? flattenAndCompact(x) : [ x ]; if (x.length === 0) { return null; } for (var i = 0 ; i < x.length ; i++) { if (typeof x[i] === "function") { x[i].call(this); } } if (this.now && !this.unit && !this.operator) { return new Date(); } else { today = finishUtils.getToday.call(this); } expression = !!(this.days && this.days !== null || this.orient || this.operator); orient = ((this.orient === "past" || this.operator === "subtract") ? -1 : 1); if (this.month && this.unit === "week") { this.value = this.month + 1; delete this.month; delete this.day; } if ((this.month || this.month === 0) && "year day hour minute second".indexOf(this.unit) !== -1) { if (!this.value) { this.value = this.month + 1; } this.month = null; expression = true; } if (!expression && this.weekday && !this.day && !this.days) { finishUtils.setDMYFromWeekday.call(this); } if (expression && this.weekday && this.unit !== "month" && this.unit !== "week") { finishUtils.setDaysFromWeekday.call(this, today, orient); } if (this.weekday && this.unit !== "week" && !this.day && !this.days) { temp = Date[this.weekday](); this.day = temp.getDate(); if (temp.getMonth() !== today.getMonth()) { this.month = temp.getMonth(); } } if (this.month && this.unit === "day" && this.operator) { if (!this.value) { this.value = (this.month + 1); } this.month = null; } if (this.value != null && this.month != null && this.year != null) { this.day = this.value * 1; } if (this.month && !this.day && this.value) { today.set({ day: this.value * 1 }); if (!expression) { this.day = this.value * 1; } } if (!this.month && this.value && this.unit === "month" && !this.now) { this.month = this.value; expression = true; } if (expression && (this.month || this.month === 0) && this.unit !== "year") { finishUtils.setMonthsFromMonth.call(this, today, orient); } if (!this.unit) { this.unit = "day"; } finishUtils.setUnitValue.call(this, orient); parseMeridian.call(this); if ((this.month || this.month === 0) && !this.day) { this.day = 1; } if (!this.orient && !this.operator && this.unit === "week" && this.value && !this.day && !this.month) { return Date.today().setWeek(this.value); } if (this.unit === "week" && this.weeks && !this.day && !this.month) { return finishUtils.generateDateFromWeeks.call(this); } if (expression && this.timezone && this.day && this.days) { this.day = this.days; } if (expression){ today.add(this); } else { today.set(this); } if (this.timezone) { this.timezone = this.timezone.toUpperCase(); var offset = $D.getTimezoneOffset(this.timezone); var timezone; if (today.hasDaylightSavingTime()) { // lets check that we're being sane with timezone setting timezone = $D.getTimezoneAbbreviation(offset, today.isDaylightSavingTime()); if (timezone !== this.timezone) { // bugger, we're in a place where things like EST vs EDT matters. if (today.isDaylightSavingTime()) { today.addHours(-1); } else { today.addHours(1); } } } today.setTimezoneOffset(offset); } return today; } }; }()); (function () { var $D = Date; $D.Grammar = {}; var _ = $D.Parsing.Operators, g = $D.Grammar, t = $D.Translator, _fn; // Allow rolling up into general purpose rules _fn = function () { return _.each(_.any.apply(null, arguments), _.not(g.ctoken2("timeContext"))); }; g.datePartDelimiter = _.rtoken(/^([\s\-\.\,\/\x27]+)/); g.timePartDelimiter = _.stoken(":"); g.whiteSpace = _.rtoken(/^\s*/); g.generalDelimiter = _.rtoken(/^(([\s\,]|at|@|on)+)/); var _C = {}; g.ctoken = function (keys) { var fn = _C[keys]; if (! fn) { var c = Date.CultureInfo.regexPatterns; var kx = keys.split(/\s+/), px = []; for (var i = 0; i < kx.length ; i++) { px.push(_.replace(_.rtoken(c[kx[i]]), kx[i])); } fn = _C[keys] = _.any.apply(null, px); } return fn; }; g.ctoken2 = function (key) { return _.rtoken(Date.CultureInfo.regexPatterns[key]); }; var cacheProcessRtoken = function (key, token, type, eachToken) { if (eachToken) { g[key] = _.cache(_.process(_.each(_.rtoken(token),_.optional(g.ctoken2(eachToken))), type)); } else { g[key] = _.cache(_.process(_.rtoken(token), type)); } }; var cacheProcessCtoken = function (token, type) { return _.cache(_.process(g.ctoken2(token), type)); }; var _F = {}; //function cache var _get = function (f) { _F[f] = (_F[f] || g.format(f)[0]); return _F[f]; }; g.allformats = function (fx) { var rx = []; if (fx instanceof Array) { for (var i = 0; i < fx.length; i++) { rx.push(_get(fx[i])); } } else { rx.push(_get(fx)); } return rx; }; g.formats = function (fx) { if (fx instanceof Array) { var rx = []; for (var i = 0 ; i < fx.length ; i++) { rx.push(_get(fx[i])); } return _.any.apply(null, rx); } else { return _get(fx); } }; var grammarFormats = { timeFormats: function(){ var i, RTokenKeys = [ "h", "hh", "H", "HH", "m", "mm", "s", "ss", "ss.s", "z", "zz" ], RToken = [ /^(0[0-9]|1[0-2]|[1-9])/, /^(0[0-9]|1[0-2])/, /^([0-1][0-9]|2[0-3]|[0-9])/, /^([0-1][0-9]|2[0-3])/, /^([0-5][0-9]|[0-9])/, /^[0-5][0-9]/, /^([0-5][0-9]|[0-9])/, /^[0-5][0-9]/, /^[0-5][0-9]\.[0-9]{1,3}/, /^((\+|\-)\s*\d\d\d\d)|((\+|\-)\d\d\:?\d\d)/, /^((\+|\-)\s*\d\d\d\d)|((\+|\-)\d\d\:?\d\d)/ ], tokens = [ t.hour, t.hour, t.hour, t.hour, t.minute, t.minute, t.second, t.second, t.secondAndMillisecond, t.timezone, t.timezone ]; for (i=0; i < RTokenKeys.length; i++) { cacheProcessRtoken(RTokenKeys[i], RToken[i], tokens[i]); } g.hms = _.cache(_.sequence([g.H, g.m, g.s], g.timePartDelimiter)); g.t = cacheProcessCtoken("shortMeridian", t.meridian); g.tt = cacheProcessCtoken("longMeridian", t.meridian); g.zzz = cacheProcessCtoken("timezone", t.timezone); g.timeSuffix = _.each(_.ignore(g.whiteSpace), _.set([ g.tt, g.zzz ])); g.time = _.each(_.optional(_.ignore(_.stoken("T"))), g.hms, g.timeSuffix); }, dateFormats: function () { // pre-loaded rules for different date part order preferences var _setfn = function () { return _.set(arguments, g.datePartDelimiter); }; var i, RTokenKeys = [ "d", "dd", "M", "MM", "y", "yy", "yyy", "yyyy" ], RToken = [ /^([0-2]\d|3[0-1]|\d)/, /^([0-2]\d|3[0-1])/, /^(1[0-2]|0\d|\d)/, /^(1[0-2]|0\d)/, /^(\d+)/, /^(\d\d)/, /^(\d\d?\d?\d?)/, /^(\d\d\d\d)/ ], tokens = [ t.day, t.day, t.month, t.month, t.year, t.year, t.year, t.year ], eachToken = [ "ordinalSuffix", "ordinalSuffix" ]; for (i=0; i < RTokenKeys.length; i++) { cacheProcessRtoken(RTokenKeys[i], RToken[i], tokens[i], eachToken[i]); } g.MMM = g.MMMM = _.cache(_.process(g.ctoken("jan feb mar apr may jun jul aug sep oct nov dec"), t.month)); g.ddd = g.dddd = _.cache(_.process(g.ctoken("sun mon tue wed thu fri sat"), function (s) { return function () { this.weekday = s; }; } )); g.day = _fn(g.d, g.dd); g.month = _fn(g.M, g.MMM); g.year = _fn(g.yyyy, g.yy); g.mdy = _setfn(g.ddd, g.month, g.day, g.year); g.ymd = _setfn(g.ddd, g.year, g.month, g.day); g.dmy = _setfn(g.ddd, g.day, g.month, g.year); g.date = function (s) { return ((g[Date.CultureInfo.dateElementOrder] || g.mdy).call(this, s)); }; }, relative: function () { // relative date / time expressions g.orientation = _.process(g.ctoken("past future"), function (s) { return function () { this.orient = s; }; } ); g.operator = _.process(g.ctoken("add subtract"), function (s) { return function () { this.operator = s; }; } ); g.rday = _.process(g.ctoken("yesterday tomorrow today now"), t.rday); g.unit = _.process(g.ctoken("second minute hour day week month year"), function (s) { return function () { this.unit = s; }; } ); } }; g.buildGrammarFormats = function () { // these need to be rebuilt every time the language changes. _C = {}; grammarFormats.timeFormats(); grammarFormats.dateFormats(); grammarFormats.relative(); g.value = _.process(_.rtoken(/^([-+]?\d+)?(st|nd|rd|th)?/), function (s) { return function () { this.value = s.replace(/\D/g, ""); }; } ); g.expression = _.set([g.rday, g.operator, g.value, g.unit, g.orientation, g.ddd, g.MMM ]); g.format = _.process(_.many( _.any( // translate format specifiers into grammar rules _.process( _.rtoken(/^(dd?d?d?(?!e)|MM?M?M?|yy?y?y?|hh?|HH?|mm?|ss?|tt?|zz?z?)/), function (fmt) { if (g[fmt]) { return g[fmt]; } else { throw $D.Parsing.Exception(fmt); } } ), // translate separator tokens into token rules _.process(_.rtoken(/^[^dMyhHmstz]+/), // all legal separators function (s) { return _.ignore(_.stoken(s)); } ) ) ), // construct the parser ... function (rules) { return _.process(_.each.apply(null, rules), t.finishExact); } ); // starting rule for general purpose grammar g._start = _.process(_.set([ g.date, g.time, g.expression ], g.generalDelimiter, g.whiteSpace), t.finish); }; g.buildGrammarFormats(); // parsing date format specifiers - ex: "h:m:s tt" // this little guy will generate a custom parser based // on the format string, ex: g.format("h:m:s tt") // check for these formats first g._formats = g.formats([ "\"yyyy-MM-ddTHH:mm:ssZ\"", "yyyy-MM-ddTHH:mm:ss.sz", "yyyy-MM-ddTHH:mm:ssZ", "yyyy-MM-ddTHH:mm:ssz", "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-ddTHH:mmZ", "yyyy-MM-ddTHH:mmz", "yyyy-MM-ddTHH:mm", "ddd, MMM dd, yyyy H:mm:ss tt", "ddd MMM d yyyy HH:mm:ss zzz", "MMddyyyy", "ddMMyyyy", "Mddyyyy", "ddMyyyy", "Mdyyyy", "dMyyyy", "yyyy", "Mdyy", "dMyy", "d" ]); // real starting rule: tries selected formats first, // then general purpose rule g.start = function (s) { try { var r = g._formats.call({}, s); if (r[1].length === 0) { return r; } } catch (e) {} return g._start.call({}, s); }; }()); (function () { var $D = Date; /** * @desc Converts the specified string value into its JavaScript Date equivalent using CultureInfo specific format information. * * Example

	///////////
	// Dates //
	///////////

	// 15-Oct-2004
	var d1 = Date.parse("10/15/2004");

	// 15-Oct-2004
	var d1 = Date.parse("15-Oct-2004");

	// 15-Oct-2004
	var d1 = Date.parse("2004.10.15");

	//Fri Oct 15, 2004
	var d1 = Date.parse("Fri Oct 15, 2004");

	///////////
	// Times //
	///////////

	// Today at 10 PM.
	var d1 = Date.parse("10 PM");

	// Today at 10:30 PM.
	var d1 = Date.parse("10:30 P.M.");

	// Today at 6 AM.
	var d1 = Date.parse("06am");

	/////////////////////
	// Dates and Times //
	/////////////////////

	// 8-July-2004 @ 10:30 PM
	var d1 = Date.parse("July 8th, 2004, 10:30 PM");

	// 1-July-2004 @ 10:30 PM
	var d1 = Date.parse("2004-07-01T22:30:00");

	////////////////////
	// Relative Dates //
	////////////////////

	// Returns today's date. The string "today" is culture specific.
	var d1 = Date.parse("today");

	// Returns yesterday's date. The string "yesterday" is culture specific.
	var d1 = Date.parse("yesterday");

	// Returns the date of the next thursday.
	var d1 = Date.parse("Next thursday");

	// Returns the date of the most previous monday.
	var d1 = Date.parse("last monday");

	// Returns today's day + one year.
	var d1 = Date.parse("next year");

	///////////////
	// Date Math //
	///////////////

	// Today + 2 days
	var d1 = Date.parse("t+2");

	// Today + 2 days
	var d1 = Date.parse("today + 2 days");

	// Today + 3 months
	var d1 = Date.parse("t+3m");

	// Today - 1 year
	var d1 = Date.parse("today - 1 year");

	// Today - 1 year
	var d1 = Date.parse("t-1y"); 


	/////////////////////////////
	// Partial Dates and Times //
	/////////////////////////////

	// July 15th of this year.
	var d1 = Date.parse("July 15");

	// 15th day of current day and year.
	var d1 = Date.parse("15");

	// July 1st of current year at 10pm.
	var d1 = Date.parse("7/1 10pm");
	
* * @param {String} The string value to convert into a Date object [Required] * @return {Date} A Date object or null if the string cannot be converted into a Date. */ var parseUtils = { removeOrds: function (s) { ords = s.match(/\b(\d+)(?:st|nd|rd|th)\b/); // find ordinal matches s = ((ords && ords.length === 2) ? s.replace(ords[0], ords[1]) : s); return s; }, grammarParser: function (s) { var r = null; try { r = $D.Grammar.start.call({}, s.replace(/^\s*(\S*(\s+\S+)*)\s*$/, "$1")); } catch (e) { return null; } return ((r[1].length === 0) ? r[0] : null); }, nativeFallback: function(s) { var t; try { // ok we haven't parsed it, last ditch attempt with the built-in parser. t = Date._parse(s); return (t || t === 0) ? new Date(t) : null; } catch (e) { return null; } } }; function parse (s) { var d; if (!s) { return null; } if (s instanceof Date) { return s.clone(); } if (s.length >= 4 && s.charAt(0) !== "0" && s.charAt(0) !== "+"&& s.charAt(0) !== "-") { // ie: 2004 will pass, 0800 won't. // Start with specific formats d = $D.Parsing.ISO.parse(s) || $D.Parsing.Numeric.parse(s); } if (d instanceof Date && !isNaN(d.getTime())) { return d; } else { // find ordinal dates (1st, 3rd, 8th, etc and remove them as they cause parsing issues) s = $D.Parsing.Normalizer.parse(parseUtils.removeOrds(s)); d = parseUtils.grammarParser(s); if (d !== null) { return d; } else { return parseUtils.nativeFallback(s); } } } if (!$D._parse) { $D._parse = $D.parse; } $D.parse = parse; Date.getParseFunction = function (fx) { var fns = Date.Grammar.allformats(fx); return function (s) { var r = null; for (var i = 0; i < fns.length; i++) { try { r = fns[i].call({}, s); } catch (e) { continue; } if (r[1].length === 0) { return r[0]; } } return null; }; }; /** * Converts the specified string value into its JavaScript Date equivalent using the specified format {String} or formats {Array} and the CultureInfo specific format information. * The format of the string value must match one of the supplied formats exactly. * * Example

	// 15-Oct-2004
	var d1 = Date.parseExact("10/15/2004", "M/d/yyyy");

	// 15-Oct-2004
	var d1 = Date.parse("15-Oct-2004", "M-ddd-yyyy");

	// 15-Oct-2004
	var d1 = Date.parse("2004.10.15", "yyyy.MM.dd");

	// Multiple formats
	var d1 = Date.parseExact("10/15/2004", ["M/d/yyyy", "MMMM d, yyyy"]);
	
* * @param {String} The string value to convert into a Date object [Required]. * @param {Object} The expected format {String} or an array of expected formats {Array} of the date string [Required]. * @return {Date} A Date object or null if the string cannot be converted into a Date. */ $D.parseExact = function (s, fx) { return $D.getParseFunction(fx)(s); }; }()); (function () { var $D = Date, $P = $D.prototype, // $C = $D.CultureInfo, // not used atm p = function (s, l) { if (!l) { l = 2; } return ("000" + s).slice(l * -1); }; /** * Converts a PHP format string to Java/.NET format string. * A PHP format string can be used with ._format or .format. * A Java/.NET format string can be used with .toString(). * The .parseExact function will only accept a Java/.NET format string * * Example * var f1 = "%m/%d/%y" * var f2 = Date.normalizeFormat(f1); // "MM/dd/yy" * * new Date().format(f1); // "04/13/08" * new Date()._format(f1); // "04/13/08" * new Date().toString(f2); // "04/13/08" * * var date = Date.parseExact("04/13/08", f2); // Sun Apr 13 2008 * * @param {String} A PHP format string consisting of one or more format spcifiers. * @return {String} The PHP format converted to a Java/.NET format string. */ var normalizerSubstitutions = { "d" : "dd", "%d": "dd", "D" : "ddd", "%a": "ddd", "j" : "dddd", "l" : "dddd", "%A": "dddd", "S" : "S", "F" : "MMMM", "%B": "MMMM", "m" : "MM", "%m": "MM", "M" : "MMM", "%b": "MMM", "%h": "MMM", "n" : "M", "Y" : "yyyy", "%Y": "yyyy", "y" : "yy", "%y": "yy", "g" : "h", "%I": "h", "G" : "H", "h" : "hh", "H" : "HH", "%H": "HH", "i" : "mm", "%M": "mm", "s" : "ss", "%S": "ss", "%r": "hh:mm tt", "%R": "H:mm", "%T": "H:mm:ss", "%X": "t", "%x": "d", "%e": "d", "%D": "MM/dd/yy", "%n": "\\n", "%t": "\\t", "e" : "z", "T" : "z", "%z": "z", "%Z": "z", "Z" : "ZZ", "N" : "u", "w" : "u", "%w": "u", "W" : "W", "%V": "W" }; var normalizer = { substitutes: function (m) { return normalizerSubstitutions[m]; }, interpreted: function (m, x) { var y; switch (m) { case "%u": return x.getDay() + 1; case "z": return x.getOrdinalNumber(); case "%j": return p(x.getOrdinalNumber(), 3); case "%U": var d1 = x.clone().set({month: 0, day: 1}).addDays(-1).moveToDayOfWeek(0), d2 = x.clone().addDays(1).moveToDayOfWeek(0, -1); return (d2 < d1) ? "00" : p((d2.getOrdinalNumber() - d1.getOrdinalNumber()) / 7 + 1); case "%W": return p(x.getWeek()); case "t": return $D.getDaysInMonth(x.getFullYear(), x.getMonth()); case "o": case "%G": return x.setWeek(x.getISOWeek()).toString("yyyy"); case "%g": return x._format("%G").slice(-2); case "a": case "%p": return t("tt").toLowerCase(); case "A": return t("tt").toUpperCase(); case "u": return p(x.getMilliseconds(), 3); case "I": return (x.isDaylightSavingTime()) ? 1 : 0; case "O": return x.getUTCOffset(); case "P": y = x.getUTCOffset(); return y.substring(0, y.length - 2) + ":" + y.substring(y.length - 2); case "B": var now = new Date(); return Math.floor(((now.getHours() * 3600) + (now.getMinutes() * 60) + now.getSeconds() + (now.getTimezoneOffset() + 60) * 60) / 86.4); case "c": return x.toISOString().replace(/\"/g, ""); case "U": return $D.strtotime("now"); case "%c": return t("d") + " " + t("t"); case "%C": return Math.floor(x.getFullYear() / 100 + 1); } }, shouldOverrideDefaults: function (m) { switch (m) { case "%e": return true; default: return false; } }, parse: function (m, context) { var formatString, c = context || new Date(); formatString = normalizer.substitutes(m); if (formatString) { return formatString; } formatString = normalizer.interpreted(m, c); if (formatString) { return formatString; } else { return m; } } }; $D.normalizeFormat = function (format, context) { return format.replace(/(%|\\)?.|%%/g, function(t){ return normalizer.parse(t, context); }); }; /** * Format a local Unix timestamp according to locale settings * * Example: * Date.strftime("%m/%d/%y", new Date()); // "04/13/08" * Date.strftime("c", "2008-04-13T17:52:03Z"); // "04/13/08" * * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @param {Number|String} The number representing the number of seconds that have elapsed since January 1, 1970 (local time). * @return {String} A string representation of the current Date object. */ $D.strftime = function (format, time) { var d = Date.parse(time); return d._format(format); }; /** * Parse any textual datetime description into a Unix timestamp. * A Unix timestamp is the number of seconds that have elapsed since January 1, 1970 (midnight UTC/GMT). * * Example: * Date.strtotime("04/13/08"); // 1208044800 * Date.strtotime("1970-01-01T00:00:00Z"); // 0 * * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @param {Object} A string or date object. * @return {String} A string representation of the current Date object. */ $D.strtotime = function (time) { var d = $D.parse(time); return Math.round($D.UTC(d.getUTCFullYear(), d.getUTCMonth(), d.getUTCDate(), d.getUTCHours(), d.getUTCMinutes(), d.getUTCSeconds(), d.getUTCMilliseconds()) / 1000); }; /** * Converts the value of the current Date object to its equivalent string representation using a PHP/Unix style of date format specifiers. * Format Specifiers * Format Description Example * ------ --------------------------------------------------------------------------- ----------------------- * %a abbreviated weekday name according to the current localed "Mon" through "Sun" * %A full weekday name according to the current localed "Sunday" through "Saturday" * %b abbreviated month name according to the current localed "Jan" through "Dec" * %B full month name according to the current locale "January" through "December" * %c preferred date and time representation for the current locale "4/13/2008 12:33 PM" * %C century number (the year divided by 100 and truncated to an integer) "00" to "99" * %d day of the month as a decimal number "01" to "31" * %D same as %m/%d/%y "04/13/08" * %e day of the month as a decimal number, a single digit is preceded by a space "1" to "31" * %g like %G, but without the century "08" * %G The 4-digit year corresponding to the ISO week number (see %V). "2008" * This has the same format and value as %Y, except that if the ISO week number * belongs to the previous or next year, that year is used instead. * %h same as %b "Jan" through "Dec" * %H hour as a decimal number using a 24-hour clock. "00" to "23" * %I hour as a decimal number using a 12-hour clock. "01" to "12" * %j day of the year as a decimal number. "001" to "366" * %m month as a decimal number. "01" to "12" * %M minute as a decimal number. "00" to "59" * %n newline character "\n" * %p either "am" or "pm" according to the given time value, or the "am" or "pm" * corresponding strings for the current locale. * %r time in a.m. and p.m. notation "8:44 PM" * %R time in 24 hour notation "20:44" * %S second as a decimal number "00" to "59" * %t tab character "\t" * %T current time, equal to %H:%M:%S "12:49:11" * %u weekday as a decimal number ["1", "7"], with "1" representing Monday "1" to "7" * %U week number of the current year as a decimal number, starting with the "0" to ("52" or "53") * first Sunday as the first day of the first week * %V The ISO 8601:1988 week number of the current year as a decimal number, "00" to ("52" or "53") * range 01 to 53, where week 1 is the first week that has at least 4 days * in the current year, and with Monday as the first day of the week. * (Use %G or %g for the year component that corresponds to the week number * for the specified timestamp.) * %W week number of the current year as a decimal number, starting with the "00" to ("52" or "53") * first Monday as the first day of the first week * %w day of the week as a decimal, Sunday being "0" "0" to "6" * %x preferred date representation for the current locale without the time "4/13/2008" * %X preferred time representation for the current locale without the date "12:53:05" * %y year as a decimal number without a century "00" "99" * %Y year as a decimal number including the century "2008" * %Z time zone or name or abbreviation "UTC", "EST", "PST" * %z same as %Z * %% a literal "%" characters "%" * d Day of the month, 2 digits with leading zeros "01" to "31" * D A textual representation of a day, three letters "Mon" through "Sun" * j Day of the month without leading zeros "1" to "31" * l A full textual representation of the day of the week (lowercase "L") "Sunday" through "Saturday" * N ISO-8601 numeric representation of the day of the week (added in PHP 5.1.0) "1" (for Monday) through "7" (for Sunday) * S English ordinal suffix for the day of the month, 2 characters "st", "nd", "rd" or "th". Works well with j * w Numeric representation of the day of the week "0" (for Sunday) through "6" (for Saturday) * z The day of the year (starting from "0") "0" through "365" * W ISO-8601 week number of year, weeks starting on Monday "00" to ("52" or "53") * F A full textual representation of a month, such as January or March "January" through "December" * m Numeric representation of a month, with leading zeros "01" through "12" * M A short textual representation of a month, three letters "Jan" through "Dec" * n Numeric representation of a month, without leading zeros "1" through "12" * t Number of days in the given month "28" through "31" * L Whether it's a leap year "1" if it is a leap year, "0" otherwise * o ISO-8601 year number. This has the same value as Y, except that if the "2008" * ISO week number (W) belongs to the previous or next year, that year * is used instead. * Y A full numeric representation of a year, 4 digits "2008" * y A two digit representation of a year "08" * a Lowercase Ante meridiem and Post meridiem "am" or "pm" * A Uppercase Ante meridiem and Post meridiem "AM" or "PM" * B Swatch Internet time "000" through "999" * g 12-hour format of an hour without leading zeros "1" through "12" * G 24-hour format of an hour without leading zeros "0" through "23" * h 12-hour format of an hour with leading zeros "01" through "12" * H 24-hour format of an hour with leading zeros "00" through "23" * i Minutes with leading zeros "00" to "59" * s Seconds, with leading zeros "00" through "59" * u Milliseconds "54321" * e Timezone identifier "UTC", "EST", "PST" * I Whether or not the date is in daylight saving time (uppercase i) "1" if Daylight Saving Time, "0" otherwise * O Difference to Greenwich time (GMT) in hours "+0200", "-0600" * P Difference to Greenwich time (GMT) with colon between hours and minutes "+02:00", "-06:00" * T Timezone abbreviation "UTC", "EST", "PST" * Z Timezone offset in seconds. The offset for timezones west of UTC is "-43200" through "50400" * always negative, and for those east of UTC is always positive. * c ISO 8601 date "2004-02-12T15:19:21+00:00" * r RFC 2822 formatted date "Thu, 21 Dec 2000 16:01:07 +0200" * U Seconds since the Unix Epoch (January 1 1970 00:00:00 GMT) "0" * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @return {String} A string representation of the current Date object. */ var formatReplace = function (context) { return function (m) { var formatString, override = false; if (m.charAt(0) === "\\" || m.substring(0, 2) === "%%") { return m.replace("\\", "").replace("%%", "%"); } override = normalizer.shouldOverrideDefaults(m); formatString = $D.normalizeFormat(m, context); if (formatString) { return context.toString(formatString, override); } }; }; $P._format = function (format) { var formatter = formatReplace(this); if (!format) { return this._toString(); } else { return format.replace(/(%|\\)?.|%%/g, formatter); } }; if (!$P.format) { $P.format = $P._format; } }()); (function () { "use strict"; var gFn = function (attr) { return function () { return this[attr]; }; }; var sFn = function (attr) { return function (val) { this[attr] = val; return this; }; }; var attrs = ["years", "months", "days", "hours", "minutes", "seconds", "milliseconds"]; var addSetFuncs = function (context, attrs) { for (var i = 0; i < attrs.length ; i++) { var $a = attrs[i], $b = $a.slice(0, 1).toUpperCase() + $a.slice(1); context.prototype[$a] = 0; context.prototype["get" + $b] = gFn($a); context.prototype["set" + $b] = sFn($a); } }; /** * new TimeSpan(milliseconds); * new TimeSpan(days, hours, minutes, seconds); * new TimeSpan(days, hours, minutes, seconds, milliseconds); */ var TimeSpan = function (days, hours, minutes, seconds, milliseconds) { if (arguments.length === 1 && typeof days === "number") { var orient = (days < 0) ? -1 : +1; var millsLeft = Math.abs(days); this.setDays(Math.floor(millsLeft / 86400000) * orient); millsLeft = millsLeft % 86400000; this.setHours(Math.floor(millsLeft / 3600000) * orient); millsLeft = millsLeft % 3600000; this.setMinutes(Math.floor(millsLeft / 60000) * orient); millsLeft = millsLeft % 60000; this.setSeconds(Math.floor(millsLeft / 1000) * orient); millsLeft = millsLeft % 1000; this.setMilliseconds(millsLeft * orient); } else { this.set(days, hours, minutes, seconds, milliseconds); } this.getTotalMilliseconds = function () { return (this.getDays() * 86400000) + (this.getHours() * 3600000) + (this.getMinutes() * 60000) + (this.getSeconds() * 1000); }; this.compareTo = function (time) { var t1 = new Date(1970, 1, 1, this.getHours(), this.getMinutes(), this.getSeconds()), t2; if (time === null) { t2 = new Date(1970, 1, 1, 0, 0, 0); } else { t2 = new Date(1970, 1, 1, time.getHours(), time.getMinutes(), time.getSeconds()); } return (t1 < t2) ? -1 : (t1 > t2) ? 1 : 0; }; this.equals = function (time) { return (this.compareTo(time) === 0); }; this.add = function (time) { return (time === null) ? this : this.addSeconds(time.getTotalMilliseconds() / 1000); }; this.subtract = function (time) { return (time === null) ? this : this.addSeconds(-time.getTotalMilliseconds() / 1000); }; this.addDays = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 86400000)); }; this.addHours = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 3600000)); }; this.addMinutes = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 60000)); }; this.addSeconds = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 1000)); }; this.addMilliseconds = function (n) { return new TimeSpan(this.getTotalMilliseconds() + n); }; this.get12HourHour = function () { return (this.getHours() > 12) ? this.getHours() - 12 : (this.getHours() === 0) ? 12 : this.getHours(); }; this.getDesignator = function () { return (this.getHours() < 12) ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator; }; this.toString = function (format) { this._toString = function () { if (this.getDays() !== null && this.getDays() > 0) { return this.getDays() + "." + this.getHours() + ":" + this.p(this.getMinutes()) + ":" + this.p(this.getSeconds()); } else { return this.getHours() + ":" + this.p(this.getMinutes()) + ":" + this.p(this.getSeconds()); } }; this.p = function (s) { return (s.toString().length < 2) ? "0" + s : s; }; var me = this; return format ? format.replace(/dd?|HH?|hh?|mm?|ss?|tt?/g, function (format) { switch (format) { case "d": return me.getDays(); case "dd": return me.p(me.getDays()); case "H": return me.getHours(); case "HH": return me.p(me.getHours()); case "h": return me.get12HourHour(); case "hh": return me.p(me.get12HourHour()); case "m": return me.getMinutes(); case "mm": return me.p(me.getMinutes()); case "s": return me.getSeconds(); case "ss": return me.p(me.getSeconds()); case "t": return ((me.getHours() < 12) ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator).substring(0, 1); case "tt": return (me.getHours() < 12) ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator; } } ) : this._toString(); }; return this; }; addSetFuncs(TimeSpan, attrs.slice(2)); TimeSpan.prototype.set = function (days, hours, minutes, seconds, milliseconds){ this.setDays(days || this.getDays()); this.setHours(hours || this.getHours()); this.setMinutes(minutes || this.getMinutes()); this.setSeconds(seconds || this.getSeconds()); this.setMilliseconds(milliseconds || this.getMilliseconds()); }; /** * Gets the time of day for this date instances. * @return {TimeSpan} TimeSpan */ Date.prototype.getTimeOfDay = function () { return new TimeSpan(0, this.getHours(), this.getMinutes(), this.getSeconds(), this.getMilliseconds()); }; Date.TimeSpan = TimeSpan; if (typeof window !== "undefined" ) { // keeping API compatible for v1.x window.TimeSpan = TimeSpan; } }()); (function () { "use strict"; var attrs = ["years", "months", "days", "hours", "minutes", "seconds", "milliseconds"]; var gFn = function (attr) { return function () { return this[attr]; }; }; var sFn = function (attr) { return function (val) { this[attr] = val; return this; }; }; var addSetFuncs = function (context, attrs) { for (var i = 0; i < attrs.length ; i++) { var $a = attrs[i], $b = $a.slice(0, 1).toUpperCase() + $a.slice(1); context.prototype[$a] = 0; context.prototype["get" + $b] = gFn($a); context.prototype["set" + $b] = sFn($a); } }; var setMonthsAndYears = function (orient, d1, d2, context) { function inc() { d1.addMonths(-orient); context.months++; if (context.months === 12) { context.years++; context.months = 0; } } if (orient === +1) { while (d1 > d2) { inc(); } } else { while (d1 < d2) { inc(); } } context.months--; context.months *= orient; context.years *= orient; }; var adjustForDST = function(orient, startDate, endDate) { var hasDSTMismatch = (false === (startDate.isDaylightSavingTime() === endDate.isDaylightSavingTime())); if (hasDSTMismatch && orient === 1) { startDate.addHours(-1); } else if (hasDSTMismatch) { startDate.addHours(1); } }; /** * TimePeriod(startDate, endDate); * TimePeriod(years, months, days, hours, minutes, seconds, milliseconds); */ var TimePeriod = function (years, months, days, hours, minutes, seconds, milliseconds) { if (arguments.length === 7) { this.set(years, months, days, hours, minutes, seconds, milliseconds); } else if (arguments.length === 2 && arguments[0] instanceof Date && arguments[1] instanceof Date) { var startDate = arguments[0].clone(); var endDate = arguments[1].clone(); var orient = (startDate > endDate) ? +1 : -1; this.dates = { start: arguments[0].clone(), end: arguments[1].clone() }; setMonthsAndYears(orient, startDate, endDate, this); adjustForDST(orient, startDate, endDate); // // TODO - adjust for DST var diff = endDate - startDate; if (diff !== 0) { var ts = new TimeSpan(diff); this.set(this.years, this.months, ts.getDays(), ts.getHours(), ts.getMinutes(), ts.getSeconds(), ts.getMilliseconds()); } } return this; }; // create all the set functions. addSetFuncs(TimePeriod, attrs); TimePeriod.prototype.set = function (years, months, days, hours, minutes, seconds, milliseconds){ this.setYears(years || this.getYears()); this.setMonths(months || this.getMonths()); this.setDays(days || this.getDays()); this.setHours(hours || this.getHours()); this.setMinutes(minutes || this.getMinutes()); this.setSeconds(seconds || this.getSeconds()); this.setMilliseconds(milliseconds || this.getMilliseconds()); }; Date.TimePeriod = TimePeriod; if (typeof window !== "undefined") { // keeping API compatible for v1.x window.TimePeriod = TimePeriod; } }()); ================================================ FILE: build/date-sw-KE.js ================================================ /** * @overview datejs * @version 1.0.0-rc3 * @author Gregory Wild-Smith * @copyright 2015 Gregory Wild-Smith * @license MIT * @homepage https://github.com/abritinthebay/datejs */ /* * DateJS Culture String File * Country Code: sw-KE * Name: Kiswahili (Kenya) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["sw-KE"] = { "name": "sw-KE", "englishName": "Kiswahili (Kenya)", "nativeName": "Kiswahili (Kenya)", "Sunday": "Sunday", "Monday": "Monday", "Tuesday": "Tuesday", "Wednesday": "Wednesday", "Thursday": "Thursday", "Friday": "Friday", "Saturday": "Saturday", "Sun": "Sun", "Mon": "Mon", "Tue": "Tue", "Wed": "Wed", "Thu": "Thu", "Fri": "Fri", "Sat": "Sat", "Su": "S", "Mo": "M", "Tu": "T", "We": "W", "Th": "T", "Fr": "F", "Sa": "S", "S_Sun_Initial": "S", "M_Mon_Initial": "M", "T_Tue_Initial": "T", "W_Wed_Initial": "W", "T_Thu_Initial": "T", "F_Fri_Initial": "F", "S_Sat_Initial": "S", "January": "January", "February": "February", "March": "March", "April": "April", "May": "May", "June": "June", "July": "July", "August": "August", "September": "September", "October": "October", "November": "November", "December": "December", "Jan_Abbr": "Jan", "Feb_Abbr": "Feb", "Mar_Abbr": "Mar", "Apr_Abbr": "Apr", "May_Abbr": "May", "Jun_Abbr": "Jun", "Jul_Abbr": "Jul", "Aug_Abbr": "Aug", "Sep_Abbr": "Sep", "Oct_Abbr": "Oct", "Nov_Abbr": "Nov", "Dec_Abbr": "Dec", "AM": "AM", "PM": "PM", "firstDayOfWeek": 0, "twoDigitYearMax": 2029, "mdy": "mdy", "M/d/yyyy": "M/d/yyyy", "dddd, MMMM dd, yyyy": "dddd, MMMM dd, yyyy", "h:mm tt": "h:mm tt", "h:mm:ss tt": "h:mm:ss tt", "dddd, MMMM dd, yyyy h:mm:ss tt": "dddd, MMMM dd, yyyy h:mm:ss tt", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "MMMM dd", "MMMM, yyyy": "MMMM, yyyy", "/jan(uary)?/": "jan(uary)?", "/feb(ruary)?/": "feb(ruary)?", "/mar(ch)?/": "mar(ch)?", "/apr(il)?/": "apr(il)?", "/may/": "may", "/jun(e)?/": "jun(e)?", "/jul(y)?/": "jul(y)?", "/aug(ust)?/": "aug(ust)?", "/sep(t(ember)?)?/": "sep(t(ember)?)?", "/oct(ober)?/": "oct(ober)?", "/nov(ember)?/": "nov(ember)?", "/dec(ember)?/": "dec(ember)?", "/^su(n(day)?)?/": "^s(un(day)?)?", "/^mo(n(day)?)?/": "^m(on(day)?)?", "/^tu(e(s(day)?)?)?/": "^tu(e(s(day)?)?)?", "/^we(d(nesday)?)?/": "^w(ed(nesday)?)?", "/^th(u(r(s(day)?)?)?)?/": "^th(u(r(s(day)?)?)?)?", "/^fr(i(day)?)?/": "^f(ri(day)?)?", "/^sa(t(urday)?)?/": "^s(at(urday)?)?", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "sw-KE"; /** * @overview datejs * @version 1.0.0-rc3 * @author Gregory Wild-Smith * @copyright 2015 Gregory Wild-Smith * @license MIT * @homepage https://github.com/abritinthebay/datejs */(function () { var $D = Date; var lang = Date.CultureStrings ? Date.CultureStrings.lang : null; var loggedKeys = {}; // for debug purposes. var getText = { getFromKey: function (key, countryCode) { var output; if (Date.CultureStrings && Date.CultureStrings[countryCode] && Date.CultureStrings[countryCode][key]) { output = Date.CultureStrings[countryCode][key]; } else { output = getText.buildFromDefault(key); } if (key.charAt(0) === "/") { // Assume it's a regex output = getText.buildFromRegex(key, countryCode); } return output; }, getFromObjectValues: function (obj, countryCode) { var key, output = {}; for(key in obj) { if (obj.hasOwnProperty(key)) { output[key] = getText.getFromKey(obj[key], countryCode); } } return output; }, getFromObjectKeys: function (obj, countryCode) { var key, output = {}; for(key in obj) { if (obj.hasOwnProperty(key)) { output[getText.getFromKey(key, countryCode)] = obj[key]; } } return output; }, getFromArray: function (arr, countryCode) { var output = []; for (var i=0; i < arr.length; i++){ if (i in arr) { output[i] = getText.getFromKey(arr[i], countryCode); } } return output; }, buildFromDefault: function (key) { var output, length, split, last; switch(key) { case "name": output = "en-US"; break; case "englishName": output = "English (United States)"; break; case "nativeName": output = "English (United States)"; break; case "twoDigitYearMax": output = 2049; break; case "firstDayOfWeek": output = 0; break; default: output = key; split = key.split("_"); length = split.length; if (length > 1 && key.charAt(0) !== "/") { // if the key isn't a regex and it has a split. last = split[(length - 1)].toLowerCase(); if (last === "initial" || last === "abbr") { output = split[0]; } } break; } return output; }, buildFromRegex: function (key, countryCode) { var output; if (Date.CultureStrings && Date.CultureStrings[countryCode] && Date.CultureStrings[countryCode][key]) { output = new RegExp(Date.CultureStrings[countryCode][key], "i"); } else { output = new RegExp(key.replace(new RegExp("/", "g"),""), "i"); } return output; } }; var shallowMerge = function (obj1, obj2) { for (var attrname in obj2) { if (obj2.hasOwnProperty(attrname)) { obj1[attrname] = obj2[attrname]; } } }; var __ = function (key, language) { var countryCode = (language) ? language : lang; loggedKeys[key] = key; if (typeof key === "object") { if (key instanceof Array) { return getText.getFromArray(key, countryCode); } else { return getText.getFromObjectKeys(key, countryCode); } } else { return getText.getFromKey(key, countryCode); } }; var loadI18nScript = function (code) { // paatterned after jQuery's getScript. var url = Date.Config.i18n + code + ".js"; var head = document.getElementsByTagName("head")[0] || document.documentElement; var script = document.createElement("script"); script.src = url; var completed = false; var events = { done: function (){} // placeholder function }; // Attach handlers for all browsers script.onload = script.onreadystatechange = function() { if ( !completed && (!this.readyState || this.readyState === "loaded" || this.readyState === "complete") ) { events.done(); head.removeChild(script); } }; setTimeout(function() { head.insertBefore(script, head.firstChild); }, 0); // allows return to execute first return { done: function (cb) { events.done = function() { if (cb) { setTimeout(cb,0); } }; } }; }; var buildInfo = { buildFromMethodHash: function (obj) { var key; for(key in obj) { if (obj.hasOwnProperty(key)) { obj[key] = buildInfo[obj[key]](); } } return obj; }, timeZoneDST: function () { var DST = { "CHADT": "+1345", "NZDT": "+1300", "AEDT": "+1100", "ACDT": "+1030", "AZST": "+0500", "IRDT": "+0430", "EEST": "+0300", "CEST": "+0200", "BST": "+0100", "PMDT": "-0200", "ADT": "-0300", "NDT": "-0230", "EDT": "-0400", "CDT": "-0500", "MDT": "-0600", "PDT": "-0700", "AKDT": "-0800", "HADT": "-0900" }; return __(DST); }, timeZoneStandard: function () { var standard = { "LINT": "+1400", "TOT": "+1300", "CHAST": "+1245", "NZST": "+1200", "NFT": "+1130", "SBT": "+1100", "AEST": "+1000", "ACST": "+0930", "JST": "+0900", "CWST": "+0845", "CT": "+0800", "ICT": "+0700", "MMT": "+0630", "BST": "+0600", "NPT": "+0545", "IST": "+0530", "PKT": "+0500", "AFT": "+0430", "MSK": "+0400", "IRST": "+0330", "FET": "+0300", "EET": "+0200", "CET": "+0100", "GMT": "+0000", "UTC": "+0000", "CVT": "-0100", "GST": "-0200", "BRT": "-0300", "NST": "-0330", "AST": "-0400", "EST": "-0500", "CST": "-0600", "MST": "-0700", "PST": "-0800", "AKST": "-0900", "MIT": "-0930", "HST": "-1000", "SST": "-1100", "BIT": "-1200" }; return __(standard); }, timeZones: function (data) { var zone; data.timezones = []; for (zone in data.abbreviatedTimeZoneStandard) { if (data.abbreviatedTimeZoneStandard.hasOwnProperty(zone)) { data.timezones.push({ name: zone, offset: data.abbreviatedTimeZoneStandard[zone]}); } } for (zone in data.abbreviatedTimeZoneDST) { if (data.abbreviatedTimeZoneDST.hasOwnProperty(zone)) { data.timezones.push({ name: zone, offset: data.abbreviatedTimeZoneDST[zone], dst: true}); } } return data.timezones; }, days: function () { return __(["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"]); }, dayAbbr: function () { return __(["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"]); }, dayShortNames: function () { return __(["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"]); }, dayFirstLetters: function () { return __(["S_Sun_Initial", "M_Mon_Initial", "T_Tues_Initial", "W_Wed_Initial", "T_Thu_Initial", "F_Fri_Initial", "S_Sat_Initial"]); }, months: function () { return __(["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"]); }, monthAbbr: function () { return __(["Jan_Abbr", "Feb_Abbr", "Mar_Abbr", "Apr_Abbr", "May_Abbr", "Jun_Abbr", "Jul_Abbr", "Aug_Abbr", "Sep_Abbr", "Oct_Abbr", "Nov_Abbr", "Dec_Abbr"]); }, formatPatterns: function () { return getText.getFromObjectValues({ shortDate: "M/d/yyyy", longDate: "dddd, MMMM dd, yyyy", shortTime: "h:mm tt", longTime: "h:mm:ss tt", fullDateTime: "dddd, MMMM dd, yyyy h:mm:ss tt", sortableDateTime: "yyyy-MM-ddTHH:mm:ss", universalSortableDateTime: "yyyy-MM-dd HH:mm:ssZ", rfc1123: "ddd, dd MMM yyyy HH:mm:ss", monthDay: "MMMM dd", yearMonth: "MMMM, yyyy" }, Date.i18n.currentLanguage()); }, regex: function () { return getText.getFromObjectValues({ inTheMorning: "/( in the )(morn(ing)?)\\b/", thisMorning: "/(this )(morn(ing)?)\\b/", amThisMorning: "/(\b\\d(am)? )(this )(morn(ing)?)/", inTheEvening: "/( in the )(even(ing)?)\\b/", thisEvening: "/(this )(even(ing)?)\\b/", pmThisEvening: "/(\b\\d(pm)? )(this )(even(ing)?)/", jan: "/jan(uary)?/", feb: "/feb(ruary)?/", mar: "/mar(ch)?/", apr: "/apr(il)?/", may: "/may/", jun: "/jun(e)?/", jul: "/jul(y)?/", aug: "/aug(ust)?/", sep: "/sep(t(ember)?)?/", oct: "/oct(ober)?/", nov: "/nov(ember)?/", dec: "/dec(ember)?/", sun: "/^su(n(day)?)?/", mon: "/^mo(n(day)?)?/", tue: "/^tu(e(s(day)?)?)?/", wed: "/^we(d(nesday)?)?/", thu: "/^th(u(r(s(day)?)?)?)?/", fri: "/fr(i(day)?)?/", sat: "/^sa(t(urday)?)?/", future: "/^next/", past: "/^last|past|prev(ious)?/", add: "/^(\\+|aft(er)?|from|hence)/", subtract: "/^(\\-|bef(ore)?|ago)/", yesterday: "/^yes(terday)?/", today: "/^t(od(ay)?)?/", tomorrow: "/^tom(orrow)?/", now: "/^n(ow)?/", millisecond: "/^ms|milli(second)?s?/", second: "/^sec(ond)?s?/", minute: "/^mn|min(ute)?s?/", hour: "/^h(our)?s?/", week: "/^w(eek)?s?/", month: "/^m(onth)?s?/", day: "/^d(ay)?s?/", year: "/^y(ear)?s?/", shortMeridian: "/^(a|p)/", longMeridian: "/^(a\\.?m?\\.?|p\\.?m?\\.?)/", timezone: "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/", ordinalSuffix: "/^\\s*(st|nd|rd|th)/", timeContext: "/^\\s*(\\:|a(?!u|p)|p)/" }, Date.i18n.currentLanguage()); } }; var CultureInfo = function () { var info = getText.getFromObjectValues({ name: "name", englishName: "englishName", nativeName: "nativeName", amDesignator: "AM", pmDesignator: "PM", firstDayOfWeek: "firstDayOfWeek", twoDigitYearMax: "twoDigitYearMax", dateElementOrder: "mdy" }, Date.i18n.currentLanguage()); var constructedInfo = buildInfo.buildFromMethodHash({ dayNames: "days", abbreviatedDayNames: "dayAbbr", shortestDayNames: "dayShortNames", firstLetterDayNames: "dayFirstLetters", monthNames: "months", abbreviatedMonthNames: "monthAbbr", formatPatterns: "formatPatterns", regexPatterns: "regex", abbreviatedTimeZoneDST: "timeZoneDST", abbreviatedTimeZoneStandard: "timeZoneStandard" }); shallowMerge(info, constructedInfo); buildInfo.timeZones(info); return info; }; $D.i18n = { __: function (key, lang) { return __(key, lang); }, currentLanguage: function () { return lang || "en-US"; }, setLanguage: function (code, force, cb) { var async = false; if (force || code === "en-US" || (!!Date.CultureStrings && !!Date.CultureStrings[code])) { lang = code; Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings.lang = code; Date.CultureInfo = new CultureInfo(); } else { if (!(!!Date.CultureStrings && !!Date.CultureStrings[code])) { if (typeof exports !== "undefined" && this.exports !== exports) { // we're in a Node enviroment, load it using require try { require("../i18n/" + code + ".js"); lang = code; Date.CultureStrings.lang = code; Date.CultureInfo = new CultureInfo(); } catch (e) { // var str = "The language for '" + code + "' could not be loaded by Node. It likely does not exist."; throw new Error("The DateJS IETF language tag '" + code + "' could not be loaded by Node. It likely does not exist."); } } else if (Date.Config && Date.Config.i18n) { // we know the location of the files, so lets load them async = true; loadI18nScript(code).done(function(){ lang = code; Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings.lang = code; Date.CultureInfo = new CultureInfo(); $D.Parsing.Normalizer.buildReplaceData(); // because this is async if ($D.Grammar) { $D.Grammar.buildGrammarFormats(); // so we can parse those strings... } if (cb) { setTimeout(cb,0); } }); } else { Date.console.error("The DateJS IETF language tag '" + code + "' is not available and has not been loaded."); return false; } } } $D.Parsing.Normalizer.buildReplaceData(); // rebuild normalizer strings if ($D.Grammar) { $D.Grammar.buildGrammarFormats(); // so we can parse those strings... } if (!async && cb) { setTimeout(cb,0); } }, getLoggedKeys: function () { return loggedKeys; }, updateCultureInfo: function () { Date.CultureInfo = new CultureInfo(); } }; $D.i18n.updateCultureInfo(); // run automatically }()); (function () { var $D = Date, $P = $D.prototype, p = function (s, l) { if (!l) { l = 2; } return ("000" + s).slice(l * -1); }; if (typeof window !== "undefined" && typeof window.console !== "undefined" && typeof window.console.log !== "undefined") { $D.console = console; // used only to raise non-critical errors if available } else { // set mock so we don't give errors. $D.console = { log: function(){}, error: function(){} }; } $D.Config = $D.Config || {}; $D.initOverloads = function() { /** * Overload of Date.now. Allows an alternate call for Date.now where it returns the * current Date as an object rather than just milliseconds since the Unix Epoch. * * Also provides an implementation of now() for browsers (IE<9) that don't have it. * * Backwards compatible so with work with either: * Date.now() [returns ms] * or * Date.now(true) [returns Date] */ if (!$D.now) { $D._now = function now() { return new Date().getTime(); }; } else if (!$D._now) { $D._now = $D.now; } $D.now = function (returnObj) { if (returnObj) { return $D.present(); } else { return $D._now(); } }; if ( !$P.toISOString ) { $P.toISOString = function() { return this.getUTCFullYear() + "-" + p(this.getUTCMonth() + 1) + "-" + p(this.getUTCDate()) + "T" + p(this.getUTCHours()) + ":" + p(this.getUTCMinutes()) + ":" + p(this.getUTCSeconds()) + "." + String( (this.getUTCMilliseconds()/1000).toFixed(3)).slice(2, 5) + "Z"; }; } // private if ( $P._toString === undefined ){ $P._toString = $P.toString; } }; $D.initOverloads(); /** * Gets a date that is set to the current date. The time is set to the start of the day (00:00 or 12:00 AM). * @return {Date} The current date. */ $D.today = function () { return new Date().clearTime(); }; /** * Gets a date that is set to the current date and time (same as new Date, but chainable) * @return {Date} The current date. */ $D.present = function () { return new Date(); }; /** * Compares the first date to the second date and returns an number indication of their relative values. * @param {Date} First Date object to compare [Required]. * @param {Date} Second Date object to compare to [Required]. * @return {Number} -1 = date1 is lessthan date2. 0 = values are equal. 1 = date1 is greaterthan date2. */ $D.compare = function (date1, date2) { if (isNaN(date1) || isNaN(date2)) { throw new Error(date1 + " - " + date2); } else if (date1 instanceof Date && date2 instanceof Date) { return (date1 < date2) ? -1 : (date1 > date2) ? 1 : 0; } else { throw new TypeError(date1 + " - " + date2); } }; /** * Compares the first Date object to the second Date object and returns true if they are equal. * @param {Date} First Date object to compare [Required] * @param {Date} Second Date object to compare to [Required] * @return {Boolean} true if dates are equal. false if they are not equal. */ $D.equals = function (date1, date2) { return (date1.compareTo(date2) === 0); }; /** * Gets the language appropriate day name when given the day number(0-6) * eg - 0 == Sunday * @return {String} The day name */ $D.getDayName = function (n) { return Date.CultureInfo.dayNames[n]; }; /** * Gets the day number (0-6) if given a CultureInfo specific string which is a valid dayName, abbreviatedDayName or shortestDayName (two char). * @param {String} The name of the day (eg. "Monday, "Mon", "tuesday", "tue", "We", "we"). * @return {Number} The day number */ $D.getDayNumberFromName = function (name) { var n = Date.CultureInfo.dayNames, m = Date.CultureInfo.abbreviatedDayNames, o = Date.CultureInfo.shortestDayNames, s = name.toLowerCase(); for (var i = 0; i < n.length; i++) { if (n[i].toLowerCase() === s || m[i].toLowerCase() === s || o[i].toLowerCase() === s) { return i; } } return -1; }; /** * Gets the month number (0-11) if given a Culture Info specific string which is a valid monthName or abbreviatedMonthName. * @param {String} The name of the month (eg. "February, "Feb", "october", "oct"). * @return {Number} The day number */ $D.getMonthNumberFromName = function (name) { var n = Date.CultureInfo.monthNames, m = Date.CultureInfo.abbreviatedMonthNames, s = name.toLowerCase(); for (var i = 0; i < n.length; i++) { if (n[i].toLowerCase() === s || m[i].toLowerCase() === s) { return i; } } return -1; }; /** * Gets the language appropriate month name when given the month number(0-11) * eg - 0 == January * @return {String} The month name */ $D.getMonthName = function (n) { return Date.CultureInfo.monthNames[n]; }; /** * Determines if the current date instance is within a LeapYear. * @param {Number} The year. * @return {Boolean} true if date is within a LeapYear, otherwise false. */ $D.isLeapYear = function (year) { return ((year % 4 === 0 && year % 100 !== 0) || year % 400 === 0); }; /** * Gets the number of days in the month, given a year and month value. Automatically corrects for LeapYear. * @param {Number} The year. * @param {Number} The month (0-11). * @return {Number} The number of days in the month. */ $D.getDaysInMonth = function (year, month) { if (!month && $D.validateMonth(year)) { month = year; year = Date.today().getFullYear(); } return [31, ($D.isLeapYear(year) ? 29 : 28), 31, 30, 31, 30, 31, 31, 30, 31, 30, 31][month]; }; $P.getDaysInMonth = function () { return $D.getDaysInMonth(this.getFullYear(), this.getMonth()); }; $D.getTimezoneAbbreviation = function (offset, dst) { var p, n = (dst || false) ? Date.CultureInfo.abbreviatedTimeZoneDST : Date.CultureInfo.abbreviatedTimeZoneStandard; for (p in n) { if (n.hasOwnProperty(p)) { if (n[p] === offset) { return p; } } } return null; }; $D.getTimezoneOffset = function (name, dst) { var i, a =[], z = Date.CultureInfo.timezones; if (!name) { name = (new Date()).getTimezone();} for (i = 0; i < z.length; i++) { if (z[i].name === name.toUpperCase()) { a.push(i); } } if (!z[a[0]]) { return null; } if (a.length === 1 || !dst) { return z[a[0]].offset; } else { for (i=0; i < a.length; i++) { if (z[a[i]].dst) { return z[a[i]].offset; } } } }; $D.getQuarter = function (d) { d = d || new Date(); // If no date supplied, use today var q = [1,2,3,4]; return q[Math.floor(d.getMonth() / 3)]; // ~~~ is a bitwise op. Faster than Math.floor }; $D.getDaysLeftInQuarter = function (d) { d = d || new Date(); var qEnd = new Date(d); qEnd.setMonth(qEnd.getMonth() + 3 - qEnd.getMonth() % 3, 0); return Math.floor((qEnd - d) / 8.64e7); }; // private var validate = function (n, min, max, name) { name = name ? name : "Object"; if (typeof n === "undefined") { return false; } else if (typeof n !== "number") { throw new TypeError(n + " is not a Number."); } else if (n < min || n > max) { // As failing validation is *not* an exceptional circumstance // lets not throw a RangeError Exception here. // It's semantically correct but it's not sensible. return false; } return true; }; /** * Validates the number is within an acceptable range for milliseconds [0-999]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateMillisecond = function (value) { return validate(value, 0, 999, "millisecond"); }; /** * Validates the number is within an acceptable range for seconds [0-59]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateSecond = function (value) { return validate(value, 0, 59, "second"); }; /** * Validates the number is within an acceptable range for minutes [0-59]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateMinute = function (value) { return validate(value, 0, 59, "minute"); }; /** * Validates the number is within an acceptable range for hours [0-23]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateHour = function (value) { return validate(value, 0, 23, "hour"); }; /** * Validates the number is within an acceptable range for the days in a month [0-MaxDaysInMonth]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateDay = function (value, year, month) { if (year === undefined || year === null || month === undefined || month === null) { return false;} return validate(value, 1, $D.getDaysInMonth(year, month), "day"); }; /** * Validates the number is within an acceptable range for months [0-11]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateWeek = function (value) { return validate(value, 0, 53, "week"); }; /** * Validates the number is within an acceptable range for months [0-11]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateMonth = function (value) { return validate(value, 0, 11, "month"); }; /** * Validates the number is within an acceptable range for years. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateYear = function (value) { /** * Per ECMAScript spec the range of times supported by Date objects is * exactly -100,000,000 days to +100,000,000 days measured relative to * midnight at the beginning of 01 January, 1970 UTC. * This gives a range of 8,640,000,000,000,000 milliseconds to either * side of 01 January, 1970 UTC. * * Earliest possible date: Tue, 20 Apr 271,822 B.C. 00:00:00 UTC * Latest possible date: Sat, 13 Sep 275,760 00:00:00 UTC */ return validate(value, -271822, 275760, "year"); }; $D.validateTimezone = function(value) { var timezones = {"ACDT":1,"ACST":1,"ACT":1,"ADT":1,"AEDT":1,"AEST":1,"AFT":1,"AKDT":1,"AKST":1,"AMST":1,"AMT":1,"ART":1,"AST":1,"AWDT":1,"AWST":1,"AZOST":1,"AZT":1,"BDT":1,"BIOT":1,"BIT":1,"BOT":1,"BRT":1,"BST":1,"BTT":1,"CAT":1,"CCT":1,"CDT":1,"CEDT":1,"CEST":1,"CET":1,"CHADT":1,"CHAST":1,"CHOT":1,"ChST":1,"CHUT":1,"CIST":1,"CIT":1,"CKT":1,"CLST":1,"CLT":1,"COST":1,"COT":1,"CST":1,"CT":1,"CVT":1,"CWST":1,"CXT":1,"DAVT":1,"DDUT":1,"DFT":1,"EASST":1,"EAST":1,"EAT":1,"ECT":1,"EDT":1,"EEDT":1,"EEST":1,"EET":1,"EGST":1,"EGT":1,"EIT":1,"EST":1,"FET":1,"FJT":1,"FKST":1,"FKT":1,"FNT":1,"GALT":1,"GAMT":1,"GET":1,"GFT":1,"GILT":1,"GIT":1,"GMT":1,"GST":1,"GYT":1,"HADT":1,"HAEC":1,"HAST":1,"HKT":1,"HMT":1,"HOVT":1,"HST":1,"ICT":1,"IDT":1,"IOT":1,"IRDT":1,"IRKT":1,"IRST":1,"IST":1,"JST":1,"KGT":1,"KOST":1,"KRAT":1,"KST":1,"LHST":1,"LINT":1,"MAGT":1,"MART":1,"MAWT":1,"MDT":1,"MET":1,"MEST":1,"MHT":1,"MIST":1,"MIT":1,"MMT":1,"MSK":1,"MST":1,"MUT":1,"MVT":1,"MYT":1,"NCT":1,"NDT":1,"NFT":1,"NPT":1,"NST":1,"NT":1,"NUT":1,"NZDT":1,"NZST":1,"OMST":1,"ORAT":1,"PDT":1,"PET":1,"PETT":1,"PGT":1,"PHOT":1,"PHT":1,"PKT":1,"PMDT":1,"PMST":1,"PONT":1,"PST":1,"PYST":1,"PYT":1,"RET":1,"ROTT":1,"SAKT":1,"SAMT":1,"SAST":1,"SBT":1,"SCT":1,"SGT":1,"SLST":1,"SRT":1,"SST":1,"SYOT":1,"TAHT":1,"THA":1,"TFT":1,"TJT":1,"TKT":1,"TLT":1,"TMT":1,"TOT":1,"TVT":1,"UCT":1,"ULAT":1,"UTC":1,"UYST":1,"UYT":1,"UZT":1,"VET":1,"VLAT":1,"VOLT":1,"VOST":1,"VUT":1,"WAKT":1,"WAST":1,"WAT":1,"WEDT":1,"WEST":1,"WET":1,"WST":1,"YAKT":1,"YEKT":1,"Z":1}; return (timezones[value] === 1); }; $D.validateTimezoneOffset= function(value) { // timezones go from +14hrs to -12hrs, the +X hours are negative offsets. return (value > -841 && value < 721); }; }()); (function () { var $D = Date, $P = $D.prototype, p = function (s, l) { if (!l) { l = 2; } return ("000" + s).slice(l * -1); }; var validateConfigObject = function (obj) { var result = {}, self = this, prop, testFunc; testFunc = function (prop, func, value) { if (prop === "day") { var month = (obj.month !== undefined) ? obj.month : self.getMonth(); var year = (obj.year !== undefined) ? obj.year : self.getFullYear(); return $D[func](value, year, month); } else { return $D[func](value); } }; for (prop in obj) { if (Object.prototype.hasOwnProperty.call(obj, prop)) { var func = "validate" + prop.charAt(0).toUpperCase() + prop.slice(1); if ($D[func] && obj[prop] !== null && testFunc(prop, func, obj[prop])) { result[prop] = obj[prop]; } } } return result; }; /** * Resets the time of this Date object to 12:00 AM (00:00), which is the start of the day. * @param {Boolean} .clone() this date instance before clearing Time * @return {Date} this */ $P.clearTime = function () { this.setHours(0); this.setMinutes(0); this.setSeconds(0); this.setMilliseconds(0); return this; }; /** * Resets the time of this Date object to the current time ('now'). * @return {Date} this */ $P.setTimeToNow = function () { var n = new Date(); this.setHours(n.getHours()); this.setMinutes(n.getMinutes()); this.setSeconds(n.getSeconds()); this.setMilliseconds(n.getMilliseconds()); return this; }; /** * Returns a new Date object that is an exact date and time copy of the original instance. * @return {Date} A new Date instance */ $P.clone = function () { return new Date(this.getTime()); }; /** * Compares this instance to a Date object and returns an number indication of their relative values. * @param {Date} Date object to compare [Required] * @return {Number} -1 = this is lessthan date. 0 = values are equal. 1 = this is greaterthan date. */ $P.compareTo = function (date) { return Date.compare(this, date); }; /** * Compares this instance to another Date object and returns true if they are equal. * @param {Date} Date object to compare. If no date to compare, new Date() [now] is used. * @return {Boolean} true if dates are equal. false if they are not equal. */ $P.equals = function (date) { return Date.equals(this, (date !== undefined ? date : new Date())); }; /** * Determines if this instance is between a range of two dates or equal to either the start or end dates. * @param {Date} Start of range [Required] * @param {Date} End of range [Required] * @return {Boolean} true is this is between or equal to the start and end dates, else false */ $P.between = function (start, end) { return this.getTime() >= start.getTime() && this.getTime() <= end.getTime(); }; /** * Determines if this date occurs after the date to compare to. * @param {Date} Date object to compare. If no date to compare, new Date() ("now") is used. * @return {Boolean} true if this date instance is greater than the date to compare to (or "now"), otherwise false. */ $P.isAfter = function (date) { return this.compareTo(date || new Date()) === 1; }; /** * Determines if this date occurs before the date to compare to. * @param {Date} Date object to compare. If no date to compare, new Date() ("now") is used. * @return {Boolean} true if this date instance is less than the date to compare to (or "now"). */ $P.isBefore = function (date) { return (this.compareTo(date || new Date()) === -1); }; /** * Determines if the current Date instance occurs today. * @return {Boolean} true if this date instance is 'today', otherwise false. */ /** * Determines if the current Date instance occurs on the same Date as the supplied 'date'. * If no 'date' to compare to is provided, the current Date instance is compared to 'today'. * @param {date} Date object to compare. If no date to compare, the current Date ("now") is used. * @return {Boolean} true if this Date instance occurs on the same Day as the supplied 'date'. */ $P.isToday = $P.isSameDay = function (date) { return this.clone().clearTime().equals((date || new Date()).clone().clearTime()); }; /** * Adds the specified number of milliseconds to this instance. * @param {Number} The number of milliseconds to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addMilliseconds = function (value) { if (!value) { return this; } this.setTime(this.getTime() + value * 1); return this; }; /** * Adds the specified number of seconds to this instance. * @param {Number} The number of seconds to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addSeconds = function (value) { if (!value) { return this; } return this.addMilliseconds(value * 1000); }; /** * Adds the specified number of seconds to this instance. * @param {Number} The number of seconds to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addMinutes = function (value) { if (!value) { return this; } return this.addMilliseconds(value * 60000); // 60*1000 }; /** * Adds the specified number of hours to this instance. * @param {Number} The number of hours to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addHours = function (value) { if (!value) { return this; } return this.addMilliseconds(value * 3600000); // 60*60*1000 }; /** * Adds the specified number of days to this instance. * @param {Number} The number of days to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addDays = function (value) { if (!value) { return this; } this.setDate(this.getDate() + value * 1); return this; }; /** * Adds the specified number of weekdays (ie - not sat or sun) to this instance. * @param {Number} The number of days to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addWeekdays = function (value) { if (!value) { return this; } var day = this.getDay(); var weeks = (Math.ceil(Math.abs(value)/7)); if (day === 0 || day === 6) { if (value > 0) { this.next().monday(); this.addDays(-1); day = this.getDay(); } } if (value < 0) { while (value < 0) { this.addDays(-1); day = this.getDay(); if (day !== 0 && day !== 6) { value++; } } return this; } else if (value > 5 || (6-day) <= value) { value = value + (weeks * 2); } return this.addDays(value); }; /** * Adds the specified number of weeks to this instance. * @param {Number} The number of weeks to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addWeeks = function (value) { if (!value) { return this; } return this.addDays(value * 7); }; /** * Adds the specified number of months to this instance. * @param {Number} The number of months to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addMonths = function (value) { if (!value) { return this; } var n = this.getDate(); this.setDate(1); this.setMonth(this.getMonth() + value * 1); this.setDate(Math.min(n, $D.getDaysInMonth(this.getFullYear(), this.getMonth()))); return this; }; $P.addQuarters = function (value) { if (!value) { return this; } // note this will take you to the same point in the quarter as you are now. // i.e. - if you are 15 days into the quarter you'll be 15 days into the resulting one. // bonus: this allows adding fractional quarters return this.addMonths(value * 3); }; /** * Adds the specified number of years to this instance. * @param {Number} The number of years to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addYears = function (value) { if (!value) { return this; } return this.addMonths(value * 12); }; /** * Adds (or subtracts) to the value of the years, months, weeks, days, hours, minutes, seconds, milliseconds of the date instance using given configuration object. Positive and Negative values allowed. * Example

	Date.today().add( { days: 1, months: 1 } )

	new Date().add( { years: -1 } )
	
* @param {Object} Configuration object containing attributes (months, days, etc.) * @return {Date} this */ $P.add = function (config) { if (typeof config === "number") { this._orient = config; return this; } var x = config; if (x.day) { // If we should be a different date than today (eg: for 'tomorrow -1d', etc). // Should only effect parsing, not direct usage (eg, Finish and FinishExact) if ((x.day - this.getDate()) !== 0) { this.setDate(x.day); } } if (x.milliseconds) { this.addMilliseconds(x.milliseconds); } if (x.seconds) { this.addSeconds(x.seconds); } if (x.minutes) { this.addMinutes(x.minutes); } if (x.hours) { this.addHours(x.hours); } if (x.weeks) { this.addWeeks(x.weeks); } if (x.months) { this.addMonths(x.months); } if (x.years) { this.addYears(x.years); } if (x.days) { this.addDays(x.days); } return this; }; /** * Get the week number. Week one (1) is the week which contains the first Thursday of the year. Monday is considered the first day of the week. * The .getWeek() function does NOT convert the date to UTC. The local datetime is used. * Please use .getISOWeek() to get the week of the UTC converted date. * @return {Number} 1 to 53 */ $P.getWeek = function (utc) { // Create a copy of this date object var self, target = new Date(this.valueOf()); if (utc) { target.addMinutes(target.getTimezoneOffset()); self = target.clone(); } else { self = this; } // ISO week date weeks start on monday // so correct the day number var dayNr = (self.getDay() + 6) % 7; // ISO 8601 states that week 1 is the week // with the first thursday of that year. // Set the target date to the thursday in the target week target.setDate(target.getDate() - dayNr + 3); // Store the millisecond value of the target date var firstThursday = target.valueOf(); // Set the target to the first thursday of the year // First set the target to january first target.setMonth(0, 1); // Not a thursday? Correct the date to the next thursday if (target.getDay() !== 4) { target.setMonth(0, 1 + ((4 - target.getDay()) + 7) % 7); } // The weeknumber is the number of weeks between the // first thursday of the year and the thursday in the target week return 1 + Math.ceil((firstThursday - target) / 604800000); // 604800000 = 7 * 24 * 3600 * 1000 }; /** * Get the ISO 8601 week number. Week one ("01") is the week which contains the first Thursday of the year. Monday is considered the first day of the week. * The .getISOWeek() function does convert the date to it's UTC value. Please use .getWeek() to get the week of the local date. * @return {String} "01" to "53" */ $P.getISOWeek = function () { return p(this.getWeek(true)); }; /** * Moves the date to Monday of the week set. Week one (1) is the week which contains the first Thursday of the year. * @param {Number} A Number (1 to 53) that represents the week of the year. * @return {Date} this */ $P.setWeek = function (n) { if ((n - this.getWeek()) === 0) { if (this.getDay() !== 1) { return this.moveToDayOfWeek(1, (this.getDay() > 1 ? -1 : 1)); } else { return this; } } else { return this.moveToDayOfWeek(1, (this.getDay() > 1 ? -1 : 1)).addWeeks(n - this.getWeek()); } }; $P.setQuarter = function (qtr) { var month = Math.abs(((qtr-1) * 3) + 1); return this.setMonth(month, 1); }; $P.getQuarter = function () { return Date.getQuarter(this); }; $P.getDaysLeftInQuarter = function () { return Date.getDaysLeftInQuarter(this); }; /** * Moves the date to the next n'th occurrence of the dayOfWeek starting from the beginning of the month. The number (-1) is a magic number and will return the last occurrence of the dayOfWeek in the month. * @param {Number} The dayOfWeek to move to * @param {Number} The n'th occurrence to move to. Use (-1) to return the last occurrence in the month * @return {Date} this */ $P.moveToNthOccurrence = function (dayOfWeek, occurrence) { if (dayOfWeek === "Weekday") { if (occurrence > 0) { this.moveToFirstDayOfMonth(); if (this.is().weekday()) { occurrence -= 1; } } else if (occurrence < 0) { this.moveToLastDayOfMonth(); if (this.is().weekday()) { occurrence += 1; } } else { return this; } return this.addWeekdays(occurrence); } var shift = 0; if (occurrence > 0) { shift = occurrence - 1; } else if (occurrence === -1) { this.moveToLastDayOfMonth(); if (this.getDay() !== dayOfWeek) { this.moveToDayOfWeek(dayOfWeek, -1); } return this; } return this.moveToFirstDayOfMonth().addDays(-1).moveToDayOfWeek(dayOfWeek, +1).addWeeks(shift); }; var moveToN = function (getFunc, addFunc, nVal) { return function (value, orient) { var diff = (value - this[getFunc]() + nVal * (orient || +1)) % nVal; return this[addFunc]((diff === 0) ? diff += nVal * (orient || +1) : diff); }; }; /** * Move to the next or last dayOfWeek based on the orient value. * @param {Number} The dayOfWeek to move to * @param {Number} Forward (+1) or Back (-1). Defaults to +1. [Optional] * @return {Date} this */ $P.moveToDayOfWeek = moveToN("getDay", "addDays", 7); /** * Move to the next or last month based on the orient value. * @param {Number} The month to move to. 0 = January, 11 = December * @param {Number} Forward (+1) or Back (-1). Defaults to +1. [Optional] * @return {Date} this */ $P.moveToMonth = moveToN("getMonth", "addMonths", 12); /** * Get the Ordinate of the current day ("th", "st", "rd"). * @return {String} */ $P.getOrdinate = function () { var num = this.getDate(); return ord(num); }; /** * Get the Ordinal day (numeric day number) of the year, adjusted for leap year. * @return {Number} 1 through 365 (366 in leap years) */ $P.getOrdinalNumber = function () { return Math.ceil((this.clone().clearTime() - new Date(this.getFullYear(), 0, 1)) / 86400000) + 1; }; /** * Get the time zone abbreviation of the current date. * @return {String} The abbreviated time zone name (e.g. "EST") */ $P.getTimezone = function () { return $D.getTimezoneAbbreviation(this.getUTCOffset(), this.isDaylightSavingTime()); }; $P.setTimezoneOffset = function (offset) { var here = this.getTimezoneOffset(), there = Number(offset) * -6 / 10; return (there || there === 0) ? this.addMinutes(there - here) : this; }; $P.setTimezone = function (offset) { return this.setTimezoneOffset($D.getTimezoneOffset(offset)); }; /** * Indicates whether Daylight Saving Time is observed in the current time zone. * @return {Boolean} true|false */ $P.hasDaylightSavingTime = function () { return (Date.today().set({month: 0, day: 1}).getTimezoneOffset() !== Date.today().set({month: 6, day: 1}).getTimezoneOffset()); }; /** * Indicates whether this Date instance is within the Daylight Saving Time range for the current time zone. * @return {Boolean} true|false */ $P.isDaylightSavingTime = function () { return Date.today().set({month: 0, day: 1}).getTimezoneOffset() !== this.getTimezoneOffset(); }; /** * Get the offset from UTC of the current date. * @return {String} The 4-character offset string prefixed with + or - (e.g. "-0500") */ $P.getUTCOffset = function (offset) { var n = (offset || this.getTimezoneOffset()) * -10 / 6, r; if (n < 0) { r = (n - 10000).toString(); return r.charAt(0) + r.substr(2); } else { r = (n + 10000).toString(); return "+" + r.substr(1); } }; /** * Returns the number of milliseconds between this date and date. * @param {Date} Defaults to now * @return {Number} The diff in milliseconds */ $P.getElapsed = function (date) { return (date || new Date()) - this; }; /** * Set the value of year, month, day, hour, minute, second, millisecond of date instance using given configuration object. * Example

	Date.today().set( { day: 20, month: 1 } )

	new Date().set( { millisecond: 0 } )
	
* * @param {Object} Configuration object containing attributes (month, day, etc.) * @return {Date} this */ $P.set = function (config) { config = validateConfigObject.call(this, config); var key; for (key in config) { if (Object.prototype.hasOwnProperty.call(config, key)) { var name = key.charAt(0).toUpperCase() + key.slice(1); var addFunc, getFunc; if (key !== "week" && key !== "month" && key !== "timezone" && key !== "timezoneOffset") { name += "s"; } addFunc = "add" + name; getFunc = "get" + name; if (key === "month") { addFunc = addFunc + "s"; } else if (key === "year"){ getFunc = "getFullYear"; } if (key !== "day" && key !== "timezone" && key !== "timezoneOffset" && key !== "week" && key !== "hour") { this[addFunc](config[key] - this[getFunc]()); } else if ( key === "timezone"|| key === "timezoneOffset" || key === "week" || key === "hour") { this["set"+name](config[key]); } } } // day has to go last because you can't validate the day without first knowing the month if (config.day) { this.addDays(config.day - this.getDate()); } return this; }; /** * Moves the date to the first day of the month. * @return {Date} this */ $P.moveToFirstDayOfMonth = function () { return this.set({ day: 1 }); }; /** * Moves the date to the last day of the month. * @return {Date} this */ $P.moveToLastDayOfMonth = function () { return this.set({ day: $D.getDaysInMonth(this.getFullYear(), this.getMonth())}); }; /** * Converts the value of the current Date object to its equivalent string representation. * Format Specifiers * CUSTOM DATE AND TIME FORMAT STRINGS * Format Description Example * ------ --------------------------------------------------------------------------- ----------------------- * s The seconds of the minute between 0-59. "0" to "59" * ss The seconds of the minute with leading zero if required. "00" to "59" * * m The minute of the hour between 0-59. "0" or "59" * mm The minute of the hour with leading zero if required. "00" or "59" * * h The hour of the day between 1-12. "1" to "12" * hh The hour of the day with leading zero if required. "01" to "12" * * H The hour of the day between 0-23. "0" to "23" * HH The hour of the day with leading zero if required. "00" to "23" * * d The day of the month between 1 and 31. "1" to "31" * dd The day of the month with leading zero if required. "01" to "31" * ddd Abbreviated day name. Date.CultureInfo.abbreviatedDayNames. "Mon" to "Sun" * dddd The full day name. Date.CultureInfo.dayNames. "Monday" to "Sunday" * * M The month of the year between 1-12. "1" to "12" * MM The month of the year with leading zero if required. "01" to "12" * MMM Abbreviated month name. Date.CultureInfo.abbreviatedMonthNames. "Jan" to "Dec" * MMMM The full month name. Date.CultureInfo.monthNames. "January" to "December" * * yy The year as a two-digit number. "99" or "08" * yyyy The full four digit year. "1999" or "2008" * * t Displays the first character of the A.M./P.M. designator. "A" or "P" * Date.CultureInfo.amDesignator or Date.CultureInfo.pmDesignator * tt Displays the A.M./P.M. designator. "AM" or "PM" * Date.CultureInfo.amDesignator or Date.CultureInfo.pmDesignator * * S The ordinal suffix ("st, "nd", "rd" or "th") of the current day. "st, "nd", "rd" or "th" * * STANDARD DATE AND TIME FORMAT STRINGS * Format Description Example *------ --------------------------------------------------------------------------- ----------------------- * d The CultureInfo shortDate Format Pattern "M/d/yyyy" * D The CultureInfo longDate Format Pattern "dddd, MMMM dd, yyyy" * F The CultureInfo fullDateTime Format Pattern "dddd, MMMM dd, yyyy h:mm:ss tt" * m The CultureInfo monthDay Format Pattern "MMMM dd" * r The CultureInfo rfc1123 Format Pattern "ddd, dd MMM yyyy HH:mm:ss GMT" * s The CultureInfo sortableDateTime Format Pattern "yyyy-MM-ddTHH:mm:ss" * t The CultureInfo shortTime Format Pattern "h:mm tt" * T The CultureInfo longTime Format Pattern "h:mm:ss tt" * u The CultureInfo universalSortableDateTime Format Pattern "yyyy-MM-dd HH:mm:ssZ" * y The CultureInfo yearMonth Format Pattern "MMMM, yyyy" * * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @return {String} A string representation of the current Date object. */ var ord = function (n) { switch (n * 1) { case 1: case 21: case 31: return "st"; case 2: case 22: return "nd"; case 3: case 23: return "rd"; default: return "th"; } }; var parseStandardFormats = function (format) { var y, c = Date.CultureInfo.formatPatterns; switch (format) { case "d": return this.toString(c.shortDate); case "D": return this.toString(c.longDate); case "F": return this.toString(c.fullDateTime); case "m": return this.toString(c.monthDay); case "r": case "R": y = this.clone().addMinutes(this.getTimezoneOffset()); return y.toString(c.rfc1123) + " GMT"; case "s": return this.toString(c.sortableDateTime); case "t": return this.toString(c.shortTime); case "T": return this.toString(c.longTime); case "u": y = this.clone().addMinutes(this.getTimezoneOffset()); return y.toString(c.universalSortableDateTime); case "y": return this.toString(c.yearMonth); default: return false; } }; var parseFormatStringsClosure = function (context) { return function (m) { if (m.charAt(0) === "\\") { return m.replace("\\", ""); } switch (m) { case "hh": return p(context.getHours() < 13 ? (context.getHours() === 0 ? 12 : context.getHours()) : (context.getHours() - 12)); case "h": return context.getHours() < 13 ? (context.getHours() === 0 ? 12 : context.getHours()) : (context.getHours() - 12); case "HH": return p(context.getHours()); case "H": return context.getHours(); case "mm": return p(context.getMinutes()); case "m": return context.getMinutes(); case "ss": return p(context.getSeconds()); case "s": return context.getSeconds(); case "yyyy": return p(context.getFullYear(), 4); case "yy": return p(context.getFullYear()); case "y": return context.getFullYear(); case "E": case "dddd": return Date.CultureInfo.dayNames[context.getDay()]; case "ddd": return Date.CultureInfo.abbreviatedDayNames[context.getDay()]; case "dd": return p(context.getDate()); case "d": return context.getDate(); case "MMMM": return Date.CultureInfo.monthNames[context.getMonth()]; case "MMM": return Date.CultureInfo.abbreviatedMonthNames[context.getMonth()]; case "MM": return p((context.getMonth() + 1)); case "M": return context.getMonth() + 1; case "t": return context.getHours() < 12 ? Date.CultureInfo.amDesignator.substring(0, 1) : Date.CultureInfo.pmDesignator.substring(0, 1); case "tt": return context.getHours() < 12 ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator; case "S": return ord(context.getDate()); case "W": return context.getWeek(); case "WW": return context.getISOWeek(); case "Q": return "Q" + context.getQuarter(); case "q": return String(context.getQuarter()); case "z": return context.getTimezone(); case "Z": case "X": return Date.getTimezoneOffset(context.getTimezone()); case "ZZ": // Timezone offset in seconds return context.getTimezoneOffset() * -60; case "u": return context.getDay(); case "L": return ($D.isLeapYear(context.getFullYear())) ? 1 : 0; case "B": // Swatch Internet Time (.beats) return "@"+((context.getUTCSeconds() + (context.getUTCMinutes()*60) + ((context.getUTCHours()+1)*3600))/86.4); default: return m; } }; }; $P.toString = function (format, ignoreStandards) { // Standard Date and Time Format Strings. Formats pulled from CultureInfo file and // may vary by culture. if (!ignoreStandards && format && format.length === 1) { output = parseStandardFormats.call(this, format); if (output) { return output; } } var parseFormatStrings = parseFormatStringsClosure(this); return format ? format.replace(/((\\)?(dd?d?d?|MM?M?M?|yy?y?y?|hh?|HH?|mm?|ss?|tt?|S|q|Q|WW?W?W?)(?![^\[]*\]))/g, parseFormatStrings).replace(/\[|\]/g, "") : this._toString(); }; }()); /************************************************************* * SugarPak - Domain Specific Language - Syntactical Sugar * *************************************************************/ (function () { var $D = Date, $P = $D.prototype, $N = Number.prototype; // private $P._orient = +1; // private $P._nth = null; // private $P._is = false; // private $P._same = false; // private $P._isSecond = false; // private $N._dateElement = "days"; /** * Moves the date to the next instance of a date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.today().next().friday();
	Date.today().next().fri();
	Date.today().next().march();
	Date.today().next().mar();
	Date.today().next().week();
	
* * @return {Date} date */ $P.next = function () { this._move = true; this._orient = +1; return this; }; /** * Creates a new Date (Date.today()) and moves the date to the next instance of the date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.next().friday();
	Date.next().fri();
	Date.next().march();
	Date.next().mar();
	Date.next().week();
	
* * @return {Date} date */ $D.next = function () { return $D.today().next(); }; /** * Moves the date to the previous instance of a date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.today().last().friday();
	Date.today().last().fri();
	Date.today().last().march();
	Date.today().last().mar();
	Date.today().last().week();
	
* * @return {Date} date */ $P.last = $P.prev = $P.previous = function () { this._move = true; this._orient = -1; return this; }; /** * Creates a new Date (Date.today()) and moves the date to the previous instance of the date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.last().friday();
	Date.last().fri();
	Date.previous().march();
	Date.prev().mar();
	Date.last().week();
	
* * @return {Date} date */ $D.last = $D.prev = $D.previous = function () { return $D.today().last(); }; /** * Performs a equality check when followed by either a month name, day name or .weekday() function. * Example

	Date.today().is().friday(); // true|false
	Date.today().is().fri();
	Date.today().is().march();
	Date.today().is().mar();
	
* * @return {Boolean} true|false */ $P.is = function () { this._is = true; return this; }; /** * Determines if two date objects occur on/in exactly the same instance of the subsequent date part function. * The function .same() must be followed by a date part function (example: .day(), .month(), .year(), etc). * * An optional Date can be passed in the date part function. If now date is passed as a parameter, 'Now' is used. * * The following example demonstrates how to determine if two dates fall on the exact same day. * * Example

	var d1 = Date.today(); // today at 00:00
	var d2 = new Date();   // exactly now.

	// Do they occur on the same day?
	d1.same().day(d2); // true
	
	// Do they occur on the same hour?
	d1.same().hour(d2); // false, unless d2 hour is '00' (midnight).
	
	// What if it's the same day, but one year apart?
	var nextYear = Date.today().add(1).year();

	d1.same().day(nextYear); // false, because the dates must occur on the exact same day. 
	
* * Scenario: Determine if a given date occurs during some week period 2 months from now. * * Example

	var future = Date.today().add(2).months();
	return someDate.same().week(future); // true|false;
	
* * @return {Boolean} true|false */ $P.same = function () { this._same = true; this._isSecond = false; return this; }; /** * Determines if the current date/time occurs during Today. Must be preceded by the .is() function. * Example

	someDate.is().today();    // true|false
	new Date().is().today();  // true
	Date.today().is().today();// true
	Date.today().add(-1).day().is().today(); // false
	
* * @return {Boolean} true|false */ $P.today = function () { return this.same().day(); }; /** * Determines if the current date is a weekday. This function must be preceded by the .is() function. * Example

	Date.today().is().weekday(); // true|false
	
* * @return {Boolean} true|false */ $P.weekday = function () { if (this._nth) { return df("Weekday").call(this); } if (this._move) { return this.addWeekdays(this._orient); } if (this._is) { this._is = false; return (!this.is().sat() && !this.is().sun()); } return false; }; /** * Determines if the current date is on the weekend. This function must be preceded by the .is() function. * Example

	Date.today().is().weekend(); // true|false
	
* * @return {Boolean} true|false */ $P.weekend = function () { if (this._is) { this._is = false; return (this.is().sat() || this.is().sun()); } return false; }; /** * Sets the Time of the current Date instance. A string "6:15 pm" or config object {hour:18, minute:15} are accepted. * Example

	// Set time to 6:15pm with a String
	Date.today().at("6:15pm");

	// Set time to 6:15pm with a config object
	Date.today().at({hour:18, minute:15});
	
* * @return {Date} date */ $P.at = function (time) { return (typeof time === "string") ? $D.parse(this.toString("d") + " " + time) : this.set(time); }; /** * Creates a new Date() and adds this (Number) to the date based on the preceding date element function (eg. second|minute|hour|day|month|year). * Example

	// Undeclared Numbers must be wrapped with parentheses. Requirment of JavaScript.
	(3).days().fromNow();
	(6).months().fromNow();

	// Declared Number variables do not require parentheses. 
	var n = 6;
	n.months().fromNow();
	
* * @return {Date} A new Date instance */ $N.fromNow = $N.after = function (date) { var c = {}; c[this._dateElement] = this; return ((!date) ? new Date() : date.clone()).add(c); }; /** * Creates a new Date() and subtract this (Number) from the date based on the preceding date element function (eg. second|minute|hour|day|month|year). * Example

	// Undeclared Numbers must be wrapped with parentheses. Requirment of JavaScript.
	(3).days().ago();
	(6).months().ago();

	// Declared Number variables do not require parentheses. 
	var n = 6;
	n.months().ago();
	
* * @return {Date} A new Date instance */ $N.ago = $N.before = function (date) { var c = {}, s = (this._dateElement[this._dateElement.length-1] !== "s") ? this._dateElement + "s" : this._dateElement; c[s] = this * -1; return ((!date) ? new Date() : date.clone()).add(c); }; // Do NOT modify the following string tokens. These tokens are used to build dynamic functions. // All culture-specific strings can be found in the CultureInfo files. var dx = ("sunday monday tuesday wednesday thursday friday saturday").split(/\s/), mx = ("january february march april may june july august september october november december").split(/\s/), px = ("Millisecond Second Minute Hour Day Week Month Year Quarter Weekday").split(/\s/), pxf = ("Milliseconds Seconds Minutes Hours Date Week Month FullYear Quarter").split(/\s/), nth = ("final first second third fourth fifth").split(/\s/), de; /** * Returns an object literal of all the date parts. * Example

	var o = new Date().toObject();
	
	// { year: 2008, month: 4, week: 20, day: 13, hour: 18, minute: 9, second: 32, millisecond: 812 }
	
	// The object properties can be referenced directly from the object.
	
	alert(o.day);  // alerts "13"
	alert(o.year); // alerts "2008"
	
* * @return {Date} An object literal representing the original date object. */ $P.toObject = function () { var o = {}; for (var i = 0; i < px.length; i++) { if (this["get" + pxf[i]]) { o[px[i].toLowerCase()] = this["get" + pxf[i]](); } } return o; }; /** * Returns a date created from an object literal. Ignores the .week property if set in the config. * Example

	var o = new Date().toObject();
	
	return Date.fromObject(o); // will return the same date. 

	var o2 = {month: 1, day: 20, hour: 18}; // birthday party!
	Date.fromObject(o2);
	
* * @return {Date} An object literal representing the original date object. */ $D.fromObject = function(config) { config.week = null; return Date.today().set(config); }; // Create day name functions and abbreviated day name functions (eg. monday(), friday(), fri()). var df = function (n) { return function () { if (this._is) { this._is = false; return this.getDay() === n; } if (this._move) { this._move = null; } if (this._nth !== null) { // If the .second() function was called earlier, remove the _orient // from the date, and then continue. // This is required because 'second' can be used in two different context. // // Example // // Date.today().add(1).second(); // Date.march().second().monday(); // // Things get crazy with the following... // Date.march().add(1).second().second().monday(); // but it works!! // if (this._isSecond) { this.addSeconds(this._orient * -1); } // make sure we reset _isSecond this._isSecond = false; var ntemp = this._nth; this._nth = null; var temp = this.clone().moveToLastDayOfMonth(); this.moveToNthOccurrence(n, ntemp); if (this > temp) { throw new RangeError($D.getDayName(n) + " does not occur " + ntemp + " times in the month of " + $D.getMonthName(temp.getMonth()) + " " + temp.getFullYear() + "."); } return this; } return this.moveToDayOfWeek(n, this._orient); }; }; var sdf = function (n) { return function () { var t = $D.today(), shift = n - t.getDay(); if (n === 0 && Date.CultureInfo.firstDayOfWeek === 1 && t.getDay() !== 0) { shift = shift + 7; } return t.addDays(shift); }; }; // Create month name functions and abbreviated month name functions (eg. january(), march(), mar()). var month_instance_functions = function (n) { return function () { if (this._is) { this._is = false; return this.getMonth() === n; } return this.moveToMonth(n, this._orient); }; }; var month_static_functions = function (n) { return function () { return $D.today().set({ month: n, day: 1 }); }; }; var processTerms = function (names, staticFunc, instanceFunc) { for (var i = 0; i < names.length; i++) { // Create constant static Name variables. $D[names[i].toUpperCase()] = $D[names[i].toUpperCase().substring(0, 3)] = i; // Create Name functions. $D[names[i]] = $D[names[i].substring(0, 3)] = staticFunc(i); // Create Name instance functions. $P[names[i]] = $P[names[i].substring(0, 3)] = instanceFunc(i); } }; processTerms(dx, sdf, df); processTerms(mx, month_static_functions, month_instance_functions); // Create date element functions and plural date element functions used with Date (eg. day(), days(), months()). var ef = function (j) { return function () { // if the .second() function was called earlier, the _orient // has alread been added. Just return this and reset _isSecond. if (this._isSecond) { this._isSecond = false; return this; } if (this._same) { this._same = this._is = false; var o1 = this.toObject(), o2 = (arguments[0] || new Date()).toObject(), v = "", k = j.toLowerCase(); // the substr trick with -1 doesn't work in IE8 or less k = (k[k.length-1] === "s") ? k.substring(0,k.length-1) : k; for (var m = (px.length - 1); m > -1; m--) { v = px[m].toLowerCase(); if (o1[v] !== o2[v]) { return false; } if (k === v) { break; } } return true; } if (j.substring(j.length - 1) !== "s") { j += "s"; } if (this._move) { this._move = null; } return this["add" + j](this._orient); }; }; var nf = function (n) { return function () { this._dateElement = n; return this; }; }; for (var k = 0; k < px.length; k++) { de = px[k].toLowerCase(); if(de !== "weekday") { // Create date element functions and plural date element functions used with Date (eg. day(), days(), months()). $P[de] = $P[de + "s"] = ef(px[k]); // Create date element functions and plural date element functions used with Number (eg. day(), days(), months()). $N[de] = $N[de + "s"] = nf(de + "s"); } } $P._ss = ef("Second"); var nthfn = function (n) { return function (dayOfWeek) { if (this._same) { return this._ss(arguments[0]); } if (dayOfWeek || dayOfWeek === 0) { return this.moveToNthOccurrence(dayOfWeek, n); } this._nth = n; // if the operator is 'second' add the _orient, then deal with it later... if (n === 2 && (dayOfWeek === undefined || dayOfWeek === null)) { this._isSecond = true; return this.addSeconds(this._orient); } return this; }; }; for (var l = 0; l < nth.length; l++) { $P[nth[l]] = (l === 0) ? nthfn(-1) : nthfn(l); } }()); (function () { "use strict"; Date.Parsing = { Exception: function (s) { this.message = "Parse error at '" + s.substring(0, 10) + " ...'"; } }; var $P = Date.Parsing; var dayOffsets = { standard: [0,31,59,90,120,151,181,212,243,273,304,334], leap: [0,31,60,91,121,152,182,213,244,274,305,335] }; $P.isLeapYear = function(year) { return ((year % 4 === 0) && (year % 100 !== 0)) || (year % 400 === 0); }; var utils = { multiReplace : function (str, hash ) { var key; for (key in hash) { if (Object.prototype.hasOwnProperty.call(hash, key)) { var regex; if (typeof hash[key] === "function") { } else { regex = (hash[key] instanceof RegExp) ? hash[key] : new RegExp(hash[key], "g"); } str = str.replace(regex, key); } } return str; }, getDayOfYearFromWeek : function (obj) { var d, jan4, offset; obj.weekDay = (!obj.weekDay && obj.weekDay !== 0) ? 1 : obj.weekDay; d = new Date(obj.year, 0, 4); jan4 = d.getDay() === 0 ? 7 : d.getDay(); // JS is 0 indexed on Sunday. offset = jan4+3; obj.dayOfYear = ((obj.week * 7) + (obj.weekDay === 0 ? 7 : obj.weekDay))-offset; return obj; }, getDayOfYear : function (obj, dayOffset) { if (!obj.dayOfYear) { obj = utils.getDayOfYearFromWeek(obj); } for (var i=0;i <= dayOffset.length;i++) { if (obj.dayOfYear < dayOffset[i] || i === dayOffset.length) { obj.day = obj.day ? obj.day : (obj.dayOfYear - dayOffset[i-1]); break; } else { obj.month = i; } } return obj; }, adjustForTimeZone : function (obj, date) { var offset; if (obj.zone.toUpperCase() === "Z" || (obj.zone_hours === 0 && obj.zone_minutes === 0)) { // it's UTC/GML so work out the current timeszone offset offset = -date.getTimezoneOffset(); } else { offset = (obj.zone_hours*60) + (obj.zone_minutes || 0); if (obj.zone_sign === "+") { offset *= -1; } offset -= date.getTimezoneOffset(); } date.setMinutes(date.getMinutes()+offset); return date; }, setDefaults : function (obj) { obj.year = obj.year || Date.today().getFullYear(); obj.hours = obj.hours || 0; obj.minutes = obj.minutes || 0; obj.seconds = obj.seconds || 0; obj.milliseconds = obj.milliseconds || 0; if (!(!obj.month && (obj.week || obj.dayOfYear))) { // if we have a month, or if we don't but don't have the day calculation data obj.month = obj.month || 0; obj.day = obj.day || 1; } return obj; }, dataNum: function (data, mod, explict, postProcess) { var dataNum = data*1; if (mod) { if (postProcess) { return data ? mod(data)*1 : data; } else { return data ? mod(dataNum) : data; } } else if (!explict){ return data ? dataNum : data; } else { return (data && typeof data !== "undefined") ? dataNum : data; } }, timeDataProcess: function (obj) { var timeObj = {}; for (var x in obj.data) { if (obj.data.hasOwnProperty(x)) { timeObj[x] = obj.ignore[x] ? obj.data[x] : utils.dataNum(obj.data[x], obj.mods[x], obj.explict[x], obj.postProcess[x]); } } if (obj.data.secmins) { obj.data.secmins = obj.data.secmins.replace(",", ".") * 60; if (!timeObj.minutes) { timeObj.minutes = obj.data.secmins; } else if (!timeObj.seconds) { timeObj.seconds = obj.data.secmins; } delete obj.secmins; } return timeObj; }, buildTimeObjectFromData: function (data) { var time = utils.timeDataProcess({ data: { year : data[1], month : data[5], day : data[7], week : data[8], dayOfYear : data[10], hours : data[15], zone_hours : data[23], zone_minutes : data[24], zone : data[21], zone_sign : data[22], weekDay : data[9], minutes: data[16], seconds: data[19], milliseconds: data[20], secmins: data[18] }, mods: { month: function(data) { return data-1; }, weekDay: function (data) { data = Math.abs(data); return (data === 7 ? 0 : data); }, minutes: function (data) { return data.replace(":",""); }, seconds: function (data) { return Math.floor( (data.replace(":","").replace(",","."))*1 ); }, milliseconds: function (data) { return (data.replace(",",".")*1000); } }, postProcess: { minutes: true, seconds: true, milliseconds: true }, explict: { zone_hours: true, zone_minutes: true }, ignore: { zone: true, zone_sign: true, secmins: true } }); return time; }, addToHash: function (hash, keys, data) { keys = keys; data = data; var len = keys.length; for (var i = 0; i < len; i++) { hash[keys[i]] = data[i]; } return hash; }, combineRegex: function (r1, r2) { return new RegExp("(("+r1.source+")\\s("+r2.source+"))"); }, getDateNthString: function(add, last, inc){ if (add) { return Date.today().addDays(inc).toString("d"); } else if (last) { return Date.today().last()[inc]().toString("d"); } }, buildRegexData: function (array) { var arr = []; var len = array.length; for (var i=0; i < len; i++) { if (Object.prototype.toString.call(array[i]) === '[object Array]') { // oldIE compat version of Array.isArray arr.push(this.combineRegex(array[i][0], array[i][1])); } else { arr.push(array[i]); } } return arr; } }; $P.processTimeObject = function (obj) { var date, dayOffset; utils.setDefaults(obj); dayOffset = ($P.isLeapYear(obj.year)) ? dayOffsets.leap : dayOffsets.standard; if (!obj.month && (obj.week || obj.dayOfYear)) { utils.getDayOfYear(obj, dayOffset); } else { obj.dayOfYear = dayOffset[obj.month] + obj.day; } date = new Date(obj.year, obj.month, obj.day, obj.hours, obj.minutes, obj.seconds, obj.milliseconds); if (obj.zone) { utils.adjustForTimeZone(obj, date); // adjust (and calculate) for timezone } return date; }; $P.ISO = { regex : /^([\+-]?\d{4}(?!\d{2}\b))((-?)((0[1-9]|1[0-2])(\3([12]\d|0[1-9]|3[01]))?|W([0-4]\d|5[0-3])(-?[1-7])?|(00[1-9]|0[1-9]\d|[12]\d{2}|3([0-5]\d|6[1-6])))([T\s]((([01]\d|2[0-4])((:?)[0-5]\d)?|24\:?00)([\.,]\d+(?!:))?)?(\17[0-5]\d([\.,]\d+)?)?\s?([zZ]|([\+-])([01]\d|2[0-3]):?([0-5]\d)?)?)?)?$/, parse : function (s) { var time, data = s.match(this.regex); if (!data || !data.length) { return null; } time = utils.buildTimeObjectFromData(data); if (!time.year || (!time.year && (!time.month && !time.day) && (!time.week && !time.dayOfYear)) ) { return null; } return $P.processTimeObject(time); } }; $P.Numeric = { isNumeric: function (e){return!isNaN(parseFloat(e))&&isFinite(e);}, regex: /\b([0-1]?[0-9])([0-3]?[0-9])([0-2]?[0-9]?[0-9][0-9])\b/i, parse: function (s) { var data, i, time = {}, order = Date.CultureInfo.dateElementOrder.split(""); if (!(this.isNumeric(s)) || // if it's non-numeric OR (s[0] === "+" && s[0] === "-")) { // It's an arithmatic string (eg +/-1000) return null; } if (s.length < 5 && s.indexOf(".") < 0 && s.indexOf("/") < 0) { // assume it's just a year. time.year = s; return $P.processTimeObject(time); } data = s.match(this.regex); if (!data || !data.length) { return null; } for (i=0; i < order.length; i++) { switch(order[i]) { case "d": time.day = data[i+1]; break; case "m": time.month = (data[i+1]-1); break; case "y": time.year = data[i+1]; break; } } return $P.processTimeObject(time); } }; $P.Normalizer = { regexData: function () { var $R = Date.CultureInfo.regexPatterns; return utils.buildRegexData([ $R.tomorrow, $R.yesterday, [$R.past, $R.mon], [$R.past, $R.tue], [$R.past, $R.wed], [$R.past, $R.thu], [$R.past, $R.fri], [$R.past, $R.sat], [$R.past, $R.sun] ]); }, basicReplaceHash : function() { var $R = Date.CultureInfo.regexPatterns; return { "January": $R.jan.source, "February": $R.feb, "March": $R.mar, "April": $R.apr, "May": $R.may, "June": $R.jun, "July": $R.jul, "August": $R.aug, "September": $R.sep, "October": $R.oct, "November": $R.nov, "December": $R.dec, "": /\bat\b/gi, " ": /\s{2,}/, "am": $R.inTheMorning, "9am": $R.thisMorning, "pm": $R.inTheEvening, "7pm":$R.thisEvening }; }, keys : function(){ return [ utils.getDateNthString(true, false, 1), // tomorrow utils.getDateNthString(true, false, -1), // yesterday utils.getDateNthString(false, true, "monday"), //last mon utils.getDateNthString(false, true, "tuesday"), //last tues utils.getDateNthString(false, true, "wednesday"), //last wed utils.getDateNthString(false, true, "thursday"), //last thurs utils.getDateNthString(false, true, "friday"), //last fri utils.getDateNthString(false, true, "saturday"), //last sat utils.getDateNthString(false, true, "sunday") //last sun ]; }, buildRegexFunctions: function () { var $R = Date.CultureInfo.regexPatterns; var __ = Date.i18n.__; var tomorrowRE = new RegExp("(\\b\\d\\d?("+__("AM")+"|"+__("PM")+")? )("+$R.tomorrow.source.slice(1)+")", "i"); // adapted tomorrow regex for AM PM relative dates var todayRE = new RegExp($R.today.source + "(?!\\s*([+-]))\\b"); // today, but excludes the math operators (eg "today + 2h") this.replaceFuncs = [ [todayRE, function (full) { return (full.length > 1) ? Date.today().toString("d") : full; }], [tomorrowRE, function(full, m1) { var t = Date.today().addDays(1).toString("d"); return (t + " " + m1); }], [$R.amThisMorning, function(str, am){return am;}], [$R.pmThisEvening, function(str, pm){return pm;}] ]; }, buildReplaceData: function () { this.buildRegexFunctions(); this.replaceHash = utils.addToHash(this.basicReplaceHash(), this.keys(), this.regexData()); }, stringReplaceFuncs: function (s) { for (var i=0; i < this.replaceFuncs.length; i++) { s = s.replace(this.replaceFuncs[i][0], this.replaceFuncs[i][1]); } return s; }, parse: function (s) { s = this.stringReplaceFuncs(s); s = utils.multiReplace(s, this.replaceHash); try { var n = s.split(/([\s\-\.\,\/\x27]+)/); if (n.length === 3 && $P.Numeric.isNumeric(n[0]) && $P.Numeric.isNumeric(n[2]) && (n[2].length >= 4)) { // ok, so we're dealing with x/year. But that's not a full date. // This fixes wonky dateElementOrder parsing when set to dmy order. if (Date.CultureInfo.dateElementOrder[0] === "d") { s = "1/" + n[0] + "/" + n[2]; // set to 1st of month and normalize the seperator } } } catch (e) {} return s; } }; $P.Normalizer.buildReplaceData(); }()); (function () { var $P = Date.Parsing; var _ = $P.Operators = { // // Tokenizers // rtoken: function (r) { // regex token return function (s) { var mx = s.match(r); if (mx) { return ([ mx[0], s.substring(mx[0].length) ]); } else { throw new $P.Exception(s); } }; }, token: function () { // whitespace-eating token return function (s) { return _.rtoken(new RegExp("^\\s*" + s + "\\s*"))(s); }; }, stoken: function (s) { // string token return _.rtoken(new RegExp("^" + s)); }, // Atomic Operators until: function (p) { return function (s) { var qx = [], rx = null; while (s.length) { try { rx = p.call(this, s); } catch (e) { qx.push(rx[0]); s = rx[1]; continue; } break; } return [ qx, s ]; }; }, many: function (p) { return function (s) { var rx = [], r = null; while (s.length) { try { r = p.call(this, s); } catch (e) { return [ rx, s ]; } rx.push(r[0]); s = r[1]; } return [ rx, s ]; }; }, // generator operators -- see below optional: function (p) { return function (s) { var r = null; try { r = p.call(this, s); } catch (e) { return [ null, s ]; } return [ r[0], r[1] ]; }; }, not: function (p) { return function (s) { try { p.call(this, s); } catch (e) { return [null, s]; } throw new $P.Exception(s); }; }, ignore: function (p) { return p ? function (s) { var r = null; r = p.call(this, s); return [null, r[1]]; } : null; }, product: function () { var px = arguments[0], qx = Array.prototype.slice.call(arguments, 1), rx = []; for (var i = 0 ; i < px.length ; i++) { rx.push(_.each(px[i], qx)); } return rx; }, cache: function (rule) { var cache = {}, cache_length = 0, cache_keys = [], CACHE_MAX = Date.Config.CACHE_MAX || 100000, r = null; var cacheCheck = function () { if (cache_length === CACHE_MAX) { // kill several keys, don't want to have to do this all the time... for (var i=0; i < 10; i++) { var key = cache_keys.shift(); if (key) { delete cache[key]; cache_length--; } } } }; return function (s) { cacheCheck(); try { r = cache[s] = (cache[s] || rule.call(this, s)); } catch (e) { r = cache[s] = e; } cache_length++; cache_keys.push(s); if (r instanceof $P.Exception) { throw r; } else { return r; } }; }, // vector operators -- see below any: function () { var px = arguments; return function (s) { var r = null; for (var i = 0; i < px.length; i++) { if (px[i] == null) { continue; } try { r = (px[i].call(this, s)); } catch (e) { r = null; } if (r) { return r; } } throw new $P.Exception(s); }; }, each: function () { var px = arguments; return function (s) { var rx = [], r = null; for (var i = 0; i < px.length ; i++) { if (px[i] == null) { continue; } try { r = (px[i].call(this, s)); } catch (e) { throw new $P.Exception(s); } rx.push(r[0]); s = r[1]; } return [ rx, s]; }; }, all: function () { var px = arguments, _ = _; return _.each(_.optional(px)); }, // delimited operators sequence: function (px, d, c) { d = d || _.rtoken(/^\s*/); c = c || null; if (px.length === 1) { return px[0]; } return function (s) { var r = null, q = null; var rx = []; for (var i = 0; i < px.length ; i++) { try { r = px[i].call(this, s); } catch (e) { break; } rx.push(r[0]); try { q = d.call(this, r[1]); } catch (ex) { q = null; break; } s = q[1]; } if (!r) { throw new $P.Exception(s); } if (q) { throw new $P.Exception(q[1]); } if (c) { try { r = c.call(this, r[1]); } catch (ey) { throw new $P.Exception(r[1]); } } return [ rx, (r?r[1]:s) ]; }; }, // // Composite Operators // between: function (d1, p, d2) { d2 = d2 || d1; var _fn = _.each(_.ignore(d1), p, _.ignore(d2)); return function (s) { var rx = _fn.call(this, s); return [[rx[0][0], r[0][2]], rx[1]]; }; }, list: function (p, d, c) { d = d || _.rtoken(/^\s*/); c = c || null; return (p instanceof Array ? _.each(_.product(p.slice(0, -1), _.ignore(d)), p.slice(-1), _.ignore(c)) : _.each(_.many(_.each(p, _.ignore(d))), px, _.ignore(c))); }, set: function (px, d, c) { d = d || _.rtoken(/^\s*/); c = c || null; return function (s) { // r is the current match, best the current 'best' match // which means it parsed the most amount of input var r = null, p = null, q = null, rx = null, best = [[], s], last = false; // go through the rules in the given set for (var i = 0; i < px.length ; i++) { // last is a flag indicating whether this must be the last element // if there is only 1 element, then it MUST be the last one q = null; p = null; r = null; last = (px.length === 1); // first, we try simply to match the current pattern // if not, try the next pattern try { r = px[i].call(this, s); } catch (e) { continue; } // since we are matching against a set of elements, the first // thing to do is to add r[0] to matched elements rx = [[r[0]], r[1]]; // if we matched and there is still input to parse and // we don't already know this is the last element, // we're going to next check for the delimiter ... // if there's none, or if there's no input left to parse // than this must be the last element after all ... if (r[1].length > 0 && ! last) { try { q = d.call(this, r[1]); } catch (ex) { last = true; } } else { last = true; } // if we parsed the delimiter and now there's no more input, // that means we shouldn't have parsed the delimiter at all // so don't update r and mark this as the last element ... if (!last && q[1].length === 0) { last = true; } // so, if this isn't the last element, we're going to see if // we can get any more matches from the remaining (unmatched) // elements ... if (!last) { // build a list of the remaining rules we can match against, // i.e., all but the one we just matched against var qx = []; for (var j = 0; j < px.length ; j++) { if (i !== j) { qx.push(px[j]); } } // now invoke recursively set with the remaining input // note that we don't include the closing delimiter ... // we'll check for that ourselves at the end p = _.set(qx, d).call(this, q[1]); // if we got a non-empty set as a result ... // (otw rx already contains everything we want to match) if (p[0].length > 0) { // update current result, which is stored in rx ... // basically, pick up the remaining text from p[1] // and concat the result from p[0] so that we don't // get endless nesting ... rx[0] = rx[0].concat(p[0]); rx[1] = p[1]; } } // at this point, rx either contains the last matched element // or the entire matched set that starts with this element. // now we just check to see if this variation is better than // our best so far, in terms of how much of the input is parsed if (rx[1].length < best[1].length) { best = rx; } // if we've parsed all the input, then we're finished if (best[1].length === 0) { break; } } // so now we've either gone through all the patterns trying them // as the initial match; or we found one that parsed the entire // input string ... // if best has no matches, just return empty set ... if (best[0].length === 0) { return best; } // if a closing delimiter is provided, then we have to check it also if (c) { // we try this even if there is no remaining input because the pattern // may well be optional or match empty input ... try { q = c.call(this, best[1]); } catch (ey) { throw new $P.Exception(best[1]); } // it parsed ... be sure to update the best match remaining input best[1] = q[1]; } // if we're here, either there was no closing delimiter or we parsed it // so now we have the best match; just return it! return best; }; }, forward: function (gr, fname) { return function (s) { return gr[fname].call(this, s); }; }, // // Translation Operators // replace: function (rule, repl) { return function (s) { var r = rule.call(this, s); return [repl, r[1]]; }; }, process: function (rule, fn) { return function (s) { var r = rule.call(this, s); return [fn.call(this, r[0]), r[1]]; }; }, min: function (min, rule) { return function (s) { var rx = rule.call(this, s); if (rx[0].length < min) { throw new $P.Exception(s); } return rx; }; } }; // Generator Operators And Vector Operators // Generators are operators that have a signature of F(R) => R, // taking a given rule and returning another rule, such as // ignore, which parses a given rule and throws away the result. // Vector operators are those that have a signature of F(R1,R2,...) => R, // take a list of rules and returning a new rule, such as each. // Generator operators are converted (via the following _generator // function) into functions that can also take a list or array of rules // and return an array of new rules as though the function had been // called on each rule in turn (which is what actually happens). // This allows generators to be used with vector operators more easily. // Example: // each(ignore(foo, bar)) instead of each(ignore(foo), ignore(bar)) // This also turns generators into vector operators, which allows // constructs like: // not(cache(foo, bar)) var _generator = function (op) { function gen() { var args = null, rx = [], px, i; if (arguments.length > 1) { args = Array.prototype.slice.call(arguments); } else if (arguments[0] instanceof Array) { args = arguments[0]; } if (args) { px = args.shift(); if (px.length > 0) { args.unshift(px[i]); rx.push(op.apply(null, args)); args.shift(); return rx; } } else { return op.apply(null, arguments); } } return gen; }; var gx = "optional not ignore cache".split(/\s/); for (var i = 0 ; i < gx.length ; i++) { _[gx[i]] = _generator(_[gx[i]]); } var _vector = function (op) { return function () { if (arguments[0] instanceof Array) { return op.apply(null, arguments[0]); } else { return op.apply(null, arguments); } }; }; var vx = "each any all".split(/\s/); for (var j = 0 ; j < vx.length ; j++) { _[vx[j]] = _vector(_[vx[j]]); } }()); (function () { var $D = Date; var flattenAndCompact = function (ax) { var rx = []; for (var i = 0; i < ax.length; i++) { if (ax[i] instanceof Array) { rx = rx.concat(flattenAndCompact(ax[i])); } else { if (ax[i]) { rx.push(ax[i]); } } } return rx; }; var parseMeridian = function () { if (this.meridian && (this.hour || this.hour === 0)) { if (this.meridian === "a" && this.hour > 11 && Date.Config.strict24hr){ throw "Invalid hour and meridian combination"; } else if (this.meridian === "p" && this.hour < 12 && Date.Config.strict24hr){ throw "Invalid hour and meridian combination"; } else if (this.meridian === "p" && this.hour < 12) { this.hour = this.hour + 12; } else if (this.meridian === "a" && this.hour === 12) { this.hour = 0; } } }; var setDefaults = function () { var now = new Date(); if ((this.hour || this.minute) && (!this.month && !this.year && !this.day)) { this.day = now.getDate(); } if (!this.year) { this.year = now.getFullYear(); } if (!this.month && this.month !== 0) { this.month = now.getMonth(); } if (!this.day) { this.day = 1; } if (!this.hour) { this.hour = 0; } if (!this.minute) { this.minute = 0; } if (!this.second) { this.second = 0; } if (!this.millisecond) { this.millisecond = 0; } }; var finishUtils = { getToday: function () { if (this.now || "hour minute second".indexOf(this.unit) !== -1) { return new Date(); } else { return $D.today(); } }, setDaysFromWeekday: function (today, orient){ var gap; orient = orient || 1; this.unit = "day"; gap = ($D.getDayNumberFromName(this.weekday) - today.getDay()); this.days = gap ? ((gap + (orient * 7)) % 7) : (orient * 7); return this; }, setMonthsFromMonth: function (today, orient) { var gap; orient = orient || 1; this.unit = "month"; gap = (this.month - today.getMonth()); this.months = gap ? ((gap + (orient * 12)) % 12) : (orient * 12); this.month = null; return this; }, setDMYFromWeekday: function () { var d = Date[this.weekday](); this.day = d.getDate(); if (!this.month) { this.month = d.getMonth(); } this.year = d.getFullYear(); return this; }, setUnitValue: function (orient) { if (!this.value && this.operator && this.operator !== null && this[this.unit + "s"] && this[this.unit + "s"] !== null) { this[this.unit + "s"] = this[this.unit + "s"] + ((this.operator === "add") ? 1 : -1) + (this.value||0) * orient; } else if (this[this.unit + "s"] == null || this.operator != null) { if (!this.value) { this.value = 1; } this[this.unit + "s"] = this.value * orient; } }, generateDateFromWeeks: function () { var weekday = (this.weekday !== undefined) ? this.weekday : "today"; var d = Date[weekday]().addWeeks(this.weeks); if (this.now) { d.setTimeToNow(); } return d; } }; $D.Translator = { hour: function (s) { return function () { this.hour = Number(s); }; }, minute: function (s) { return function () { this.minute = Number(s); }; }, second: function (s) { return function () { this.second = Number(s); }; }, /* for ss.s format */ secondAndMillisecond: function (s) { return function () { var mx = s.match(/^([0-5][0-9])\.([0-9]{1,3})/); this.second = Number(mx[1]); this.millisecond = Number(mx[2]); }; }, meridian: function (s) { return function () { this.meridian = s.slice(0, 1).toLowerCase(); }; }, timezone: function (s) { return function () { var n = s.replace(/[^\d\+\-]/g, ""); if (n.length) { this.timezoneOffset = Number(n); } else { this.timezone = s.toLowerCase(); } }; }, day: function (x) { var s = x[0]; return function () { this.day = Number(s.match(/\d+/)[0]); if (this.day < 1) { throw "invalid day"; } }; }, month: function (s) { return function () { this.month = (s.length === 3) ? "jan feb mar apr may jun jul aug sep oct nov dec".indexOf(s)/4 : Number(s) - 1; if (this.month < 0) { throw "invalid month"; } }; }, year: function (s) { return function () { var n = Number(s); this.year = ((s.length > 2) ? n : (n + (((n + 2000) < Date.CultureInfo.twoDigitYearMax) ? 2000 : 1900))); }; }, rday: function (s) { return function () { switch (s) { case "yesterday": this.days = -1; break; case "tomorrow": this.days = 1; break; case "today": this.days = 0; break; case "now": this.days = 0; this.now = true; break; } }; }, finishExact: function (x) { var d; x = (x instanceof Array) ? x : [x]; for (var i = 0 ; i < x.length ; i++) { if (x[i]) { x[i].call(this); } } setDefaults.call(this); parseMeridian.call(this); if (this.day > $D.getDaysInMonth(this.year, this.month)) { throw new RangeError(this.day + " is not a valid value for days."); } d = new Date(this.year, this.month, this.day, this.hour, this.minute, this.second, this.millisecond); if (this.year < 100) { d.setFullYear(this.year); // means years less that 100 are process correctly. JS will parse it otherwise as 1900-1999. } if (this.timezone) { d.set({ timezone: this.timezone }); } else if (this.timezoneOffset) { d.set({ timezoneOffset: this.timezoneOffset }); } return d; }, finish: function (x) { var today, expression, orient, temp; x = (x instanceof Array) ? flattenAndCompact(x) : [ x ]; if (x.length === 0) { return null; } for (var i = 0 ; i < x.length ; i++) { if (typeof x[i] === "function") { x[i].call(this); } } if (this.now && !this.unit && !this.operator) { return new Date(); } else { today = finishUtils.getToday.call(this); } expression = !!(this.days && this.days !== null || this.orient || this.operator); orient = ((this.orient === "past" || this.operator === "subtract") ? -1 : 1); if (this.month && this.unit === "week") { this.value = this.month + 1; delete this.month; delete this.day; } if ((this.month || this.month === 0) && "year day hour minute second".indexOf(this.unit) !== -1) { if (!this.value) { this.value = this.month + 1; } this.month = null; expression = true; } if (!expression && this.weekday && !this.day && !this.days) { finishUtils.setDMYFromWeekday.call(this); } if (expression && this.weekday && this.unit !== "month" && this.unit !== "week") { finishUtils.setDaysFromWeekday.call(this, today, orient); } if (this.weekday && this.unit !== "week" && !this.day && !this.days) { temp = Date[this.weekday](); this.day = temp.getDate(); if (temp.getMonth() !== today.getMonth()) { this.month = temp.getMonth(); } } if (this.month && this.unit === "day" && this.operator) { if (!this.value) { this.value = (this.month + 1); } this.month = null; } if (this.value != null && this.month != null && this.year != null) { this.day = this.value * 1; } if (this.month && !this.day && this.value) { today.set({ day: this.value * 1 }); if (!expression) { this.day = this.value * 1; } } if (!this.month && this.value && this.unit === "month" && !this.now) { this.month = this.value; expression = true; } if (expression && (this.month || this.month === 0) && this.unit !== "year") { finishUtils.setMonthsFromMonth.call(this, today, orient); } if (!this.unit) { this.unit = "day"; } finishUtils.setUnitValue.call(this, orient); parseMeridian.call(this); if ((this.month || this.month === 0) && !this.day) { this.day = 1; } if (!this.orient && !this.operator && this.unit === "week" && this.value && !this.day && !this.month) { return Date.today().setWeek(this.value); } if (this.unit === "week" && this.weeks && !this.day && !this.month) { return finishUtils.generateDateFromWeeks.call(this); } if (expression && this.timezone && this.day && this.days) { this.day = this.days; } if (expression){ today.add(this); } else { today.set(this); } if (this.timezone) { this.timezone = this.timezone.toUpperCase(); var offset = $D.getTimezoneOffset(this.timezone); var timezone; if (today.hasDaylightSavingTime()) { // lets check that we're being sane with timezone setting timezone = $D.getTimezoneAbbreviation(offset, today.isDaylightSavingTime()); if (timezone !== this.timezone) { // bugger, we're in a place where things like EST vs EDT matters. if (today.isDaylightSavingTime()) { today.addHours(-1); } else { today.addHours(1); } } } today.setTimezoneOffset(offset); } return today; } }; }()); (function () { var $D = Date; $D.Grammar = {}; var _ = $D.Parsing.Operators, g = $D.Grammar, t = $D.Translator, _fn; // Allow rolling up into general purpose rules _fn = function () { return _.each(_.any.apply(null, arguments), _.not(g.ctoken2("timeContext"))); }; g.datePartDelimiter = _.rtoken(/^([\s\-\.\,\/\x27]+)/); g.timePartDelimiter = _.stoken(":"); g.whiteSpace = _.rtoken(/^\s*/); g.generalDelimiter = _.rtoken(/^(([\s\,]|at|@|on)+)/); var _C = {}; g.ctoken = function (keys) { var fn = _C[keys]; if (! fn) { var c = Date.CultureInfo.regexPatterns; var kx = keys.split(/\s+/), px = []; for (var i = 0; i < kx.length ; i++) { px.push(_.replace(_.rtoken(c[kx[i]]), kx[i])); } fn = _C[keys] = _.any.apply(null, px); } return fn; }; g.ctoken2 = function (key) { return _.rtoken(Date.CultureInfo.regexPatterns[key]); }; var cacheProcessRtoken = function (key, token, type, eachToken) { if (eachToken) { g[key] = _.cache(_.process(_.each(_.rtoken(token),_.optional(g.ctoken2(eachToken))), type)); } else { g[key] = _.cache(_.process(_.rtoken(token), type)); } }; var cacheProcessCtoken = function (token, type) { return _.cache(_.process(g.ctoken2(token), type)); }; var _F = {}; //function cache var _get = function (f) { _F[f] = (_F[f] || g.format(f)[0]); return _F[f]; }; g.allformats = function (fx) { var rx = []; if (fx instanceof Array) { for (var i = 0; i < fx.length; i++) { rx.push(_get(fx[i])); } } else { rx.push(_get(fx)); } return rx; }; g.formats = function (fx) { if (fx instanceof Array) { var rx = []; for (var i = 0 ; i < fx.length ; i++) { rx.push(_get(fx[i])); } return _.any.apply(null, rx); } else { return _get(fx); } }; var grammarFormats = { timeFormats: function(){ var i, RTokenKeys = [ "h", "hh", "H", "HH", "m", "mm", "s", "ss", "ss.s", "z", "zz" ], RToken = [ /^(0[0-9]|1[0-2]|[1-9])/, /^(0[0-9]|1[0-2])/, /^([0-1][0-9]|2[0-3]|[0-9])/, /^([0-1][0-9]|2[0-3])/, /^([0-5][0-9]|[0-9])/, /^[0-5][0-9]/, /^([0-5][0-9]|[0-9])/, /^[0-5][0-9]/, /^[0-5][0-9]\.[0-9]{1,3}/, /^((\+|\-)\s*\d\d\d\d)|((\+|\-)\d\d\:?\d\d)/, /^((\+|\-)\s*\d\d\d\d)|((\+|\-)\d\d\:?\d\d)/ ], tokens = [ t.hour, t.hour, t.hour, t.hour, t.minute, t.minute, t.second, t.second, t.secondAndMillisecond, t.timezone, t.timezone ]; for (i=0; i < RTokenKeys.length; i++) { cacheProcessRtoken(RTokenKeys[i], RToken[i], tokens[i]); } g.hms = _.cache(_.sequence([g.H, g.m, g.s], g.timePartDelimiter)); g.t = cacheProcessCtoken("shortMeridian", t.meridian); g.tt = cacheProcessCtoken("longMeridian", t.meridian); g.zzz = cacheProcessCtoken("timezone", t.timezone); g.timeSuffix = _.each(_.ignore(g.whiteSpace), _.set([ g.tt, g.zzz ])); g.time = _.each(_.optional(_.ignore(_.stoken("T"))), g.hms, g.timeSuffix); }, dateFormats: function () { // pre-loaded rules for different date part order preferences var _setfn = function () { return _.set(arguments, g.datePartDelimiter); }; var i, RTokenKeys = [ "d", "dd", "M", "MM", "y", "yy", "yyy", "yyyy" ], RToken = [ /^([0-2]\d|3[0-1]|\d)/, /^([0-2]\d|3[0-1])/, /^(1[0-2]|0\d|\d)/, /^(1[0-2]|0\d)/, /^(\d+)/, /^(\d\d)/, /^(\d\d?\d?\d?)/, /^(\d\d\d\d)/ ], tokens = [ t.day, t.day, t.month, t.month, t.year, t.year, t.year, t.year ], eachToken = [ "ordinalSuffix", "ordinalSuffix" ]; for (i=0; i < RTokenKeys.length; i++) { cacheProcessRtoken(RTokenKeys[i], RToken[i], tokens[i], eachToken[i]); } g.MMM = g.MMMM = _.cache(_.process(g.ctoken("jan feb mar apr may jun jul aug sep oct nov dec"), t.month)); g.ddd = g.dddd = _.cache(_.process(g.ctoken("sun mon tue wed thu fri sat"), function (s) { return function () { this.weekday = s; }; } )); g.day = _fn(g.d, g.dd); g.month = _fn(g.M, g.MMM); g.year = _fn(g.yyyy, g.yy); g.mdy = _setfn(g.ddd, g.month, g.day, g.year); g.ymd = _setfn(g.ddd, g.year, g.month, g.day); g.dmy = _setfn(g.ddd, g.day, g.month, g.year); g.date = function (s) { return ((g[Date.CultureInfo.dateElementOrder] || g.mdy).call(this, s)); }; }, relative: function () { // relative date / time expressions g.orientation = _.process(g.ctoken("past future"), function (s) { return function () { this.orient = s; }; } ); g.operator = _.process(g.ctoken("add subtract"), function (s) { return function () { this.operator = s; }; } ); g.rday = _.process(g.ctoken("yesterday tomorrow today now"), t.rday); g.unit = _.process(g.ctoken("second minute hour day week month year"), function (s) { return function () { this.unit = s; }; } ); } }; g.buildGrammarFormats = function () { // these need to be rebuilt every time the language changes. _C = {}; grammarFormats.timeFormats(); grammarFormats.dateFormats(); grammarFormats.relative(); g.value = _.process(_.rtoken(/^([-+]?\d+)?(st|nd|rd|th)?/), function (s) { return function () { this.value = s.replace(/\D/g, ""); }; } ); g.expression = _.set([g.rday, g.operator, g.value, g.unit, g.orientation, g.ddd, g.MMM ]); g.format = _.process(_.many( _.any( // translate format specifiers into grammar rules _.process( _.rtoken(/^(dd?d?d?(?!e)|MM?M?M?|yy?y?y?|hh?|HH?|mm?|ss?|tt?|zz?z?)/), function (fmt) { if (g[fmt]) { return g[fmt]; } else { throw $D.Parsing.Exception(fmt); } } ), // translate separator tokens into token rules _.process(_.rtoken(/^[^dMyhHmstz]+/), // all legal separators function (s) { return _.ignore(_.stoken(s)); } ) ) ), // construct the parser ... function (rules) { return _.process(_.each.apply(null, rules), t.finishExact); } ); // starting rule for general purpose grammar g._start = _.process(_.set([ g.date, g.time, g.expression ], g.generalDelimiter, g.whiteSpace), t.finish); }; g.buildGrammarFormats(); // parsing date format specifiers - ex: "h:m:s tt" // this little guy will generate a custom parser based // on the format string, ex: g.format("h:m:s tt") // check for these formats first g._formats = g.formats([ "\"yyyy-MM-ddTHH:mm:ssZ\"", "yyyy-MM-ddTHH:mm:ss.sz", "yyyy-MM-ddTHH:mm:ssZ", "yyyy-MM-ddTHH:mm:ssz", "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-ddTHH:mmZ", "yyyy-MM-ddTHH:mmz", "yyyy-MM-ddTHH:mm", "ddd, MMM dd, yyyy H:mm:ss tt", "ddd MMM d yyyy HH:mm:ss zzz", "MMddyyyy", "ddMMyyyy", "Mddyyyy", "ddMyyyy", "Mdyyyy", "dMyyyy", "yyyy", "Mdyy", "dMyy", "d" ]); // real starting rule: tries selected formats first, // then general purpose rule g.start = function (s) { try { var r = g._formats.call({}, s); if (r[1].length === 0) { return r; } } catch (e) {} return g._start.call({}, s); }; }()); (function () { var $D = Date; /** * @desc Converts the specified string value into its JavaScript Date equivalent using CultureInfo specific format information. * * Example

	///////////
	// Dates //
	///////////

	// 15-Oct-2004
	var d1 = Date.parse("10/15/2004");

	// 15-Oct-2004
	var d1 = Date.parse("15-Oct-2004");

	// 15-Oct-2004
	var d1 = Date.parse("2004.10.15");

	//Fri Oct 15, 2004
	var d1 = Date.parse("Fri Oct 15, 2004");

	///////////
	// Times //
	///////////

	// Today at 10 PM.
	var d1 = Date.parse("10 PM");

	// Today at 10:30 PM.
	var d1 = Date.parse("10:30 P.M.");

	// Today at 6 AM.
	var d1 = Date.parse("06am");

	/////////////////////
	// Dates and Times //
	/////////////////////

	// 8-July-2004 @ 10:30 PM
	var d1 = Date.parse("July 8th, 2004, 10:30 PM");

	// 1-July-2004 @ 10:30 PM
	var d1 = Date.parse("2004-07-01T22:30:00");

	////////////////////
	// Relative Dates //
	////////////////////

	// Returns today's date. The string "today" is culture specific.
	var d1 = Date.parse("today");

	// Returns yesterday's date. The string "yesterday" is culture specific.
	var d1 = Date.parse("yesterday");

	// Returns the date of the next thursday.
	var d1 = Date.parse("Next thursday");

	// Returns the date of the most previous monday.
	var d1 = Date.parse("last monday");

	// Returns today's day + one year.
	var d1 = Date.parse("next year");

	///////////////
	// Date Math //
	///////////////

	// Today + 2 days
	var d1 = Date.parse("t+2");

	// Today + 2 days
	var d1 = Date.parse("today + 2 days");

	// Today + 3 months
	var d1 = Date.parse("t+3m");

	// Today - 1 year
	var d1 = Date.parse("today - 1 year");

	// Today - 1 year
	var d1 = Date.parse("t-1y"); 


	/////////////////////////////
	// Partial Dates and Times //
	/////////////////////////////

	// July 15th of this year.
	var d1 = Date.parse("July 15");

	// 15th day of current day and year.
	var d1 = Date.parse("15");

	// July 1st of current year at 10pm.
	var d1 = Date.parse("7/1 10pm");
	
* * @param {String} The string value to convert into a Date object [Required] * @return {Date} A Date object or null if the string cannot be converted into a Date. */ var parseUtils = { removeOrds: function (s) { ords = s.match(/\b(\d+)(?:st|nd|rd|th)\b/); // find ordinal matches s = ((ords && ords.length === 2) ? s.replace(ords[0], ords[1]) : s); return s; }, grammarParser: function (s) { var r = null; try { r = $D.Grammar.start.call({}, s.replace(/^\s*(\S*(\s+\S+)*)\s*$/, "$1")); } catch (e) { return null; } return ((r[1].length === 0) ? r[0] : null); }, nativeFallback: function(s) { var t; try { // ok we haven't parsed it, last ditch attempt with the built-in parser. t = Date._parse(s); return (t || t === 0) ? new Date(t) : null; } catch (e) { return null; } } }; function parse (s) { var d; if (!s) { return null; } if (s instanceof Date) { return s.clone(); } if (s.length >= 4 && s.charAt(0) !== "0" && s.charAt(0) !== "+"&& s.charAt(0) !== "-") { // ie: 2004 will pass, 0800 won't. // Start with specific formats d = $D.Parsing.ISO.parse(s) || $D.Parsing.Numeric.parse(s); } if (d instanceof Date && !isNaN(d.getTime())) { return d; } else { // find ordinal dates (1st, 3rd, 8th, etc and remove them as they cause parsing issues) s = $D.Parsing.Normalizer.parse(parseUtils.removeOrds(s)); d = parseUtils.grammarParser(s); if (d !== null) { return d; } else { return parseUtils.nativeFallback(s); } } } if (!$D._parse) { $D._parse = $D.parse; } $D.parse = parse; Date.getParseFunction = function (fx) { var fns = Date.Grammar.allformats(fx); return function (s) { var r = null; for (var i = 0; i < fns.length; i++) { try { r = fns[i].call({}, s); } catch (e) { continue; } if (r[1].length === 0) { return r[0]; } } return null; }; }; /** * Converts the specified string value into its JavaScript Date equivalent using the specified format {String} or formats {Array} and the CultureInfo specific format information. * The format of the string value must match one of the supplied formats exactly. * * Example

	// 15-Oct-2004
	var d1 = Date.parseExact("10/15/2004", "M/d/yyyy");

	// 15-Oct-2004
	var d1 = Date.parse("15-Oct-2004", "M-ddd-yyyy");

	// 15-Oct-2004
	var d1 = Date.parse("2004.10.15", "yyyy.MM.dd");

	// Multiple formats
	var d1 = Date.parseExact("10/15/2004", ["M/d/yyyy", "MMMM d, yyyy"]);
	
* * @param {String} The string value to convert into a Date object [Required]. * @param {Object} The expected format {String} or an array of expected formats {Array} of the date string [Required]. * @return {Date} A Date object or null if the string cannot be converted into a Date. */ $D.parseExact = function (s, fx) { return $D.getParseFunction(fx)(s); }; }()); (function () { var $D = Date, $P = $D.prototype, // $C = $D.CultureInfo, // not used atm p = function (s, l) { if (!l) { l = 2; } return ("000" + s).slice(l * -1); }; /** * Converts a PHP format string to Java/.NET format string. * A PHP format string can be used with ._format or .format. * A Java/.NET format string can be used with .toString(). * The .parseExact function will only accept a Java/.NET format string * * Example * var f1 = "%m/%d/%y" * var f2 = Date.normalizeFormat(f1); // "MM/dd/yy" * * new Date().format(f1); // "04/13/08" * new Date()._format(f1); // "04/13/08" * new Date().toString(f2); // "04/13/08" * * var date = Date.parseExact("04/13/08", f2); // Sun Apr 13 2008 * * @param {String} A PHP format string consisting of one or more format spcifiers. * @return {String} The PHP format converted to a Java/.NET format string. */ var normalizerSubstitutions = { "d" : "dd", "%d": "dd", "D" : "ddd", "%a": "ddd", "j" : "dddd", "l" : "dddd", "%A": "dddd", "S" : "S", "F" : "MMMM", "%B": "MMMM", "m" : "MM", "%m": "MM", "M" : "MMM", "%b": "MMM", "%h": "MMM", "n" : "M", "Y" : "yyyy", "%Y": "yyyy", "y" : "yy", "%y": "yy", "g" : "h", "%I": "h", "G" : "H", "h" : "hh", "H" : "HH", "%H": "HH", "i" : "mm", "%M": "mm", "s" : "ss", "%S": "ss", "%r": "hh:mm tt", "%R": "H:mm", "%T": "H:mm:ss", "%X": "t", "%x": "d", "%e": "d", "%D": "MM/dd/yy", "%n": "\\n", "%t": "\\t", "e" : "z", "T" : "z", "%z": "z", "%Z": "z", "Z" : "ZZ", "N" : "u", "w" : "u", "%w": "u", "W" : "W", "%V": "W" }; var normalizer = { substitutes: function (m) { return normalizerSubstitutions[m]; }, interpreted: function (m, x) { var y; switch (m) { case "%u": return x.getDay() + 1; case "z": return x.getOrdinalNumber(); case "%j": return p(x.getOrdinalNumber(), 3); case "%U": var d1 = x.clone().set({month: 0, day: 1}).addDays(-1).moveToDayOfWeek(0), d2 = x.clone().addDays(1).moveToDayOfWeek(0, -1); return (d2 < d1) ? "00" : p((d2.getOrdinalNumber() - d1.getOrdinalNumber()) / 7 + 1); case "%W": return p(x.getWeek()); case "t": return $D.getDaysInMonth(x.getFullYear(), x.getMonth()); case "o": case "%G": return x.setWeek(x.getISOWeek()).toString("yyyy"); case "%g": return x._format("%G").slice(-2); case "a": case "%p": return t("tt").toLowerCase(); case "A": return t("tt").toUpperCase(); case "u": return p(x.getMilliseconds(), 3); case "I": return (x.isDaylightSavingTime()) ? 1 : 0; case "O": return x.getUTCOffset(); case "P": y = x.getUTCOffset(); return y.substring(0, y.length - 2) + ":" + y.substring(y.length - 2); case "B": var now = new Date(); return Math.floor(((now.getHours() * 3600) + (now.getMinutes() * 60) + now.getSeconds() + (now.getTimezoneOffset() + 60) * 60) / 86.4); case "c": return x.toISOString().replace(/\"/g, ""); case "U": return $D.strtotime("now"); case "%c": return t("d") + " " + t("t"); case "%C": return Math.floor(x.getFullYear() / 100 + 1); } }, shouldOverrideDefaults: function (m) { switch (m) { case "%e": return true; default: return false; } }, parse: function (m, context) { var formatString, c = context || new Date(); formatString = normalizer.substitutes(m); if (formatString) { return formatString; } formatString = normalizer.interpreted(m, c); if (formatString) { return formatString; } else { return m; } } }; $D.normalizeFormat = function (format, context) { return format.replace(/(%|\\)?.|%%/g, function(t){ return normalizer.parse(t, context); }); }; /** * Format a local Unix timestamp according to locale settings * * Example: * Date.strftime("%m/%d/%y", new Date()); // "04/13/08" * Date.strftime("c", "2008-04-13T17:52:03Z"); // "04/13/08" * * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @param {Number|String} The number representing the number of seconds that have elapsed since January 1, 1970 (local time). * @return {String} A string representation of the current Date object. */ $D.strftime = function (format, time) { var d = Date.parse(time); return d._format(format); }; /** * Parse any textual datetime description into a Unix timestamp. * A Unix timestamp is the number of seconds that have elapsed since January 1, 1970 (midnight UTC/GMT). * * Example: * Date.strtotime("04/13/08"); // 1208044800 * Date.strtotime("1970-01-01T00:00:00Z"); // 0 * * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @param {Object} A string or date object. * @return {String} A string representation of the current Date object. */ $D.strtotime = function (time) { var d = $D.parse(time); return Math.round($D.UTC(d.getUTCFullYear(), d.getUTCMonth(), d.getUTCDate(), d.getUTCHours(), d.getUTCMinutes(), d.getUTCSeconds(), d.getUTCMilliseconds()) / 1000); }; /** * Converts the value of the current Date object to its equivalent string representation using a PHP/Unix style of date format specifiers. * Format Specifiers * Format Description Example * ------ --------------------------------------------------------------------------- ----------------------- * %a abbreviated weekday name according to the current localed "Mon" through "Sun" * %A full weekday name according to the current localed "Sunday" through "Saturday" * %b abbreviated month name according to the current localed "Jan" through "Dec" * %B full month name according to the current locale "January" through "December" * %c preferred date and time representation for the current locale "4/13/2008 12:33 PM" * %C century number (the year divided by 100 and truncated to an integer) "00" to "99" * %d day of the month as a decimal number "01" to "31" * %D same as %m/%d/%y "04/13/08" * %e day of the month as a decimal number, a single digit is preceded by a space "1" to "31" * %g like %G, but without the century "08" * %G The 4-digit year corresponding to the ISO week number (see %V). "2008" * This has the same format and value as %Y, except that if the ISO week number * belongs to the previous or next year, that year is used instead. * %h same as %b "Jan" through "Dec" * %H hour as a decimal number using a 24-hour clock. "00" to "23" * %I hour as a decimal number using a 12-hour clock. "01" to "12" * %j day of the year as a decimal number. "001" to "366" * %m month as a decimal number. "01" to "12" * %M minute as a decimal number. "00" to "59" * %n newline character "\n" * %p either "am" or "pm" according to the given time value, or the "am" or "pm" * corresponding strings for the current locale. * %r time in a.m. and p.m. notation "8:44 PM" * %R time in 24 hour notation "20:44" * %S second as a decimal number "00" to "59" * %t tab character "\t" * %T current time, equal to %H:%M:%S "12:49:11" * %u weekday as a decimal number ["1", "7"], with "1" representing Monday "1" to "7" * %U week number of the current year as a decimal number, starting with the "0" to ("52" or "53") * first Sunday as the first day of the first week * %V The ISO 8601:1988 week number of the current year as a decimal number, "00" to ("52" or "53") * range 01 to 53, where week 1 is the first week that has at least 4 days * in the current year, and with Monday as the first day of the week. * (Use %G or %g for the year component that corresponds to the week number * for the specified timestamp.) * %W week number of the current year as a decimal number, starting with the "00" to ("52" or "53") * first Monday as the first day of the first week * %w day of the week as a decimal, Sunday being "0" "0" to "6" * %x preferred date representation for the current locale without the time "4/13/2008" * %X preferred time representation for the current locale without the date "12:53:05" * %y year as a decimal number without a century "00" "99" * %Y year as a decimal number including the century "2008" * %Z time zone or name or abbreviation "UTC", "EST", "PST" * %z same as %Z * %% a literal "%" characters "%" * d Day of the month, 2 digits with leading zeros "01" to "31" * D A textual representation of a day, three letters "Mon" through "Sun" * j Day of the month without leading zeros "1" to "31" * l A full textual representation of the day of the week (lowercase "L") "Sunday" through "Saturday" * N ISO-8601 numeric representation of the day of the week (added in PHP 5.1.0) "1" (for Monday) through "7" (for Sunday) * S English ordinal suffix for the day of the month, 2 characters "st", "nd", "rd" or "th". Works well with j * w Numeric representation of the day of the week "0" (for Sunday) through "6" (for Saturday) * z The day of the year (starting from "0") "0" through "365" * W ISO-8601 week number of year, weeks starting on Monday "00" to ("52" or "53") * F A full textual representation of a month, such as January or March "January" through "December" * m Numeric representation of a month, with leading zeros "01" through "12" * M A short textual representation of a month, three letters "Jan" through "Dec" * n Numeric representation of a month, without leading zeros "1" through "12" * t Number of days in the given month "28" through "31" * L Whether it's a leap year "1" if it is a leap year, "0" otherwise * o ISO-8601 year number. This has the same value as Y, except that if the "2008" * ISO week number (W) belongs to the previous or next year, that year * is used instead. * Y A full numeric representation of a year, 4 digits "2008" * y A two digit representation of a year "08" * a Lowercase Ante meridiem and Post meridiem "am" or "pm" * A Uppercase Ante meridiem and Post meridiem "AM" or "PM" * B Swatch Internet time "000" through "999" * g 12-hour format of an hour without leading zeros "1" through "12" * G 24-hour format of an hour without leading zeros "0" through "23" * h 12-hour format of an hour with leading zeros "01" through "12" * H 24-hour format of an hour with leading zeros "00" through "23" * i Minutes with leading zeros "00" to "59" * s Seconds, with leading zeros "00" through "59" * u Milliseconds "54321" * e Timezone identifier "UTC", "EST", "PST" * I Whether or not the date is in daylight saving time (uppercase i) "1" if Daylight Saving Time, "0" otherwise * O Difference to Greenwich time (GMT) in hours "+0200", "-0600" * P Difference to Greenwich time (GMT) with colon between hours and minutes "+02:00", "-06:00" * T Timezone abbreviation "UTC", "EST", "PST" * Z Timezone offset in seconds. The offset for timezones west of UTC is "-43200" through "50400" * always negative, and for those east of UTC is always positive. * c ISO 8601 date "2004-02-12T15:19:21+00:00" * r RFC 2822 formatted date "Thu, 21 Dec 2000 16:01:07 +0200" * U Seconds since the Unix Epoch (January 1 1970 00:00:00 GMT) "0" * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @return {String} A string representation of the current Date object. */ var formatReplace = function (context) { return function (m) { var formatString, override = false; if (m.charAt(0) === "\\" || m.substring(0, 2) === "%%") { return m.replace("\\", "").replace("%%", "%"); } override = normalizer.shouldOverrideDefaults(m); formatString = $D.normalizeFormat(m, context); if (formatString) { return context.toString(formatString, override); } }; }; $P._format = function (format) { var formatter = formatReplace(this); if (!format) { return this._toString(); } else { return format.replace(/(%|\\)?.|%%/g, formatter); } }; if (!$P.format) { $P.format = $P._format; } }()); (function () { "use strict"; var gFn = function (attr) { return function () { return this[attr]; }; }; var sFn = function (attr) { return function (val) { this[attr] = val; return this; }; }; var attrs = ["years", "months", "days", "hours", "minutes", "seconds", "milliseconds"]; var addSetFuncs = function (context, attrs) { for (var i = 0; i < attrs.length ; i++) { var $a = attrs[i], $b = $a.slice(0, 1).toUpperCase() + $a.slice(1); context.prototype[$a] = 0; context.prototype["get" + $b] = gFn($a); context.prototype["set" + $b] = sFn($a); } }; /** * new TimeSpan(milliseconds); * new TimeSpan(days, hours, minutes, seconds); * new TimeSpan(days, hours, minutes, seconds, milliseconds); */ var TimeSpan = function (days, hours, minutes, seconds, milliseconds) { if (arguments.length === 1 && typeof days === "number") { var orient = (days < 0) ? -1 : +1; var millsLeft = Math.abs(days); this.setDays(Math.floor(millsLeft / 86400000) * orient); millsLeft = millsLeft % 86400000; this.setHours(Math.floor(millsLeft / 3600000) * orient); millsLeft = millsLeft % 3600000; this.setMinutes(Math.floor(millsLeft / 60000) * orient); millsLeft = millsLeft % 60000; this.setSeconds(Math.floor(millsLeft / 1000) * orient); millsLeft = millsLeft % 1000; this.setMilliseconds(millsLeft * orient); } else { this.set(days, hours, minutes, seconds, milliseconds); } this.getTotalMilliseconds = function () { return (this.getDays() * 86400000) + (this.getHours() * 3600000) + (this.getMinutes() * 60000) + (this.getSeconds() * 1000); }; this.compareTo = function (time) { var t1 = new Date(1970, 1, 1, this.getHours(), this.getMinutes(), this.getSeconds()), t2; if (time === null) { t2 = new Date(1970, 1, 1, 0, 0, 0); } else { t2 = new Date(1970, 1, 1, time.getHours(), time.getMinutes(), time.getSeconds()); } return (t1 < t2) ? -1 : (t1 > t2) ? 1 : 0; }; this.equals = function (time) { return (this.compareTo(time) === 0); }; this.add = function (time) { return (time === null) ? this : this.addSeconds(time.getTotalMilliseconds() / 1000); }; this.subtract = function (time) { return (time === null) ? this : this.addSeconds(-time.getTotalMilliseconds() / 1000); }; this.addDays = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 86400000)); }; this.addHours = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 3600000)); }; this.addMinutes = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 60000)); }; this.addSeconds = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 1000)); }; this.addMilliseconds = function (n) { return new TimeSpan(this.getTotalMilliseconds() + n); }; this.get12HourHour = function () { return (this.getHours() > 12) ? this.getHours() - 12 : (this.getHours() === 0) ? 12 : this.getHours(); }; this.getDesignator = function () { return (this.getHours() < 12) ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator; }; this.toString = function (format) { this._toString = function () { if (this.getDays() !== null && this.getDays() > 0) { return this.getDays() + "." + this.getHours() + ":" + this.p(this.getMinutes()) + ":" + this.p(this.getSeconds()); } else { return this.getHours() + ":" + this.p(this.getMinutes()) + ":" + this.p(this.getSeconds()); } }; this.p = function (s) { return (s.toString().length < 2) ? "0" + s : s; }; var me = this; return format ? format.replace(/dd?|HH?|hh?|mm?|ss?|tt?/g, function (format) { switch (format) { case "d": return me.getDays(); case "dd": return me.p(me.getDays()); case "H": return me.getHours(); case "HH": return me.p(me.getHours()); case "h": return me.get12HourHour(); case "hh": return me.p(me.get12HourHour()); case "m": return me.getMinutes(); case "mm": return me.p(me.getMinutes()); case "s": return me.getSeconds(); case "ss": return me.p(me.getSeconds()); case "t": return ((me.getHours() < 12) ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator).substring(0, 1); case "tt": return (me.getHours() < 12) ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator; } } ) : this._toString(); }; return this; }; addSetFuncs(TimeSpan, attrs.slice(2)); TimeSpan.prototype.set = function (days, hours, minutes, seconds, milliseconds){ this.setDays(days || this.getDays()); this.setHours(hours || this.getHours()); this.setMinutes(minutes || this.getMinutes()); this.setSeconds(seconds || this.getSeconds()); this.setMilliseconds(milliseconds || this.getMilliseconds()); }; /** * Gets the time of day for this date instances. * @return {TimeSpan} TimeSpan */ Date.prototype.getTimeOfDay = function () { return new TimeSpan(0, this.getHours(), this.getMinutes(), this.getSeconds(), this.getMilliseconds()); }; Date.TimeSpan = TimeSpan; if (typeof window !== "undefined" ) { // keeping API compatible for v1.x window.TimeSpan = TimeSpan; } }()); (function () { "use strict"; var attrs = ["years", "months", "days", "hours", "minutes", "seconds", "milliseconds"]; var gFn = function (attr) { return function () { return this[attr]; }; }; var sFn = function (attr) { return function (val) { this[attr] = val; return this; }; }; var addSetFuncs = function (context, attrs) { for (var i = 0; i < attrs.length ; i++) { var $a = attrs[i], $b = $a.slice(0, 1).toUpperCase() + $a.slice(1); context.prototype[$a] = 0; context.prototype["get" + $b] = gFn($a); context.prototype["set" + $b] = sFn($a); } }; var setMonthsAndYears = function (orient, d1, d2, context) { function inc() { d1.addMonths(-orient); context.months++; if (context.months === 12) { context.years++; context.months = 0; } } if (orient === +1) { while (d1 > d2) { inc(); } } else { while (d1 < d2) { inc(); } } context.months--; context.months *= orient; context.years *= orient; }; var adjustForDST = function(orient, startDate, endDate) { var hasDSTMismatch = (false === (startDate.isDaylightSavingTime() === endDate.isDaylightSavingTime())); if (hasDSTMismatch && orient === 1) { startDate.addHours(-1); } else if (hasDSTMismatch) { startDate.addHours(1); } }; /** * TimePeriod(startDate, endDate); * TimePeriod(years, months, days, hours, minutes, seconds, milliseconds); */ var TimePeriod = function (years, months, days, hours, minutes, seconds, milliseconds) { if (arguments.length === 7) { this.set(years, months, days, hours, minutes, seconds, milliseconds); } else if (arguments.length === 2 && arguments[0] instanceof Date && arguments[1] instanceof Date) { var startDate = arguments[0].clone(); var endDate = arguments[1].clone(); var orient = (startDate > endDate) ? +1 : -1; this.dates = { start: arguments[0].clone(), end: arguments[1].clone() }; setMonthsAndYears(orient, startDate, endDate, this); adjustForDST(orient, startDate, endDate); // // TODO - adjust for DST var diff = endDate - startDate; if (diff !== 0) { var ts = new TimeSpan(diff); this.set(this.years, this.months, ts.getDays(), ts.getHours(), ts.getMinutes(), ts.getSeconds(), ts.getMilliseconds()); } } return this; }; // create all the set functions. addSetFuncs(TimePeriod, attrs); TimePeriod.prototype.set = function (years, months, days, hours, minutes, seconds, milliseconds){ this.setYears(years || this.getYears()); this.setMonths(months || this.getMonths()); this.setDays(days || this.getDays()); this.setHours(hours || this.getHours()); this.setMinutes(minutes || this.getMinutes()); this.setSeconds(seconds || this.getSeconds()); this.setMilliseconds(milliseconds || this.getMilliseconds()); }; Date.TimePeriod = TimePeriod; if (typeof window !== "undefined") { // keeping API compatible for v1.x window.TimePeriod = TimePeriod; } }()); ================================================ FILE: build/date-syr-SY.js ================================================ /** * @overview datejs * @version 1.0.0-rc3 * @author Gregory Wild-Smith * @copyright 2015 Gregory Wild-Smith * @license MIT * @homepage https://github.com/abritinthebay/datejs */ /* * DateJS Culture String File * Country Code: syr-SY * Name: Syriac (Syria) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["syr-SY"] = { "name": "syr-SY", "englishName": "Syriac (Syria)", "nativeName": "ܣܘܪܝܝܐ (سوريا)", "Sunday": "ܚܕ ܒܫܒܐ", "Monday": "ܬܪܝܢ ܒܫܒܐ", "Tuesday": "ܬܠܬܐ ܒܫܒܐ", "Wednesday": "ܐܪܒܥܐ ܒܫܒܐ", "Thursday": "ܚܡܫܐ ܒܫܒܐ", "Friday": "ܥܪܘܒܬܐ", "Saturday": "ܫܒܬܐ", "Sun": "܏ܐ ܏ܒܫ", "Mon": "܏ܒ ܏ܒܫ", "Tue": "܏ܓ ܏ܒܫ", "Wed": "܏ܕ ܏ܒܫ", "Thu": "܏ܗ ܏ܒܫ", "Fri": "܏ܥܪܘܒ", "Sat": "܏ܫܒ", "Su": "܏", "Mo": "܏", "Tu": "܏", "We": "܏", "Th": "܏", "Fr": "܏", "Sa": "܏", "S_Sun_Initial": "܏", "M_Mon_Initial": "܏", "T_Tue_Initial": "܏", "W_Wed_Initial": "܏", "T_Thu_Initial": "܏", "F_Fri_Initial": "܏", "S_Sat_Initial": "܏", "January": "ܟܢܘܢ ܐܚܪܝ", "February": "ܫܒܛ", "March": "ܐܕܪ", "April": "ܢܝܣܢ", "May": "ܐܝܪ", "June": "ܚܙܝܪܢ", "July": "ܬܡܘܙ", "August": "ܐܒ", "September": "ܐܝܠܘܠ", "October": "ܬܫܪܝ ܩܕܝܡ", "November": "ܬܫܪܝ ܐܚܪܝ", "December": "ܟܢܘܢ ܩܕܝܡ", "Jan_Abbr": "܏ܟܢ ܏ܒ", "Feb_Abbr": "ܫܒܛ", "Mar_Abbr": "ܐܕܪ", "Apr_Abbr": "ܢܝܣܢ", "May_Abbr": "ܐܝܪ", "Jun_Abbr": "ܚܙܝܪܢ", "Jul_Abbr": "ܬܡܘܙ", "Aug_Abbr": "ܐܒ", "Sep_Abbr": "ܐܝܠܘܠ", "Oct_Abbr": "܏ܬܫ ܏ܐ", "Nov_Abbr": "܏ܬܫ ܏ܒ", "Dec_Abbr": "܏ܟܢ ܏ܐ", "AM": "ܩ.ܛ", "PM": "ܒ.ܛ", "firstDayOfWeek": 6, "twoDigitYearMax": 2029, "mdy": "dmy", "M/d/yyyy": "dd/MM/yyyy", "dddd, MMMM dd, yyyy": "dd MMMM, yyyy", "h:mm tt": "hh:mm tt", "h:mm:ss tt": "hh:mm:ss tt", "dddd, MMMM dd, yyyy h:mm:ss tt": "dd MMMM, yyyy hh:mm:ss tt", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "dd MMMM", "MMMM, yyyy": "MMMM, yyyy", "/jan(uary)?/": "ܟܢܘܢ ܐܚܪܝ", "/feb(ruary)?/": "ܫܒܛ", "/mar(ch)?/": "ܐܕܪ", "/apr(il)?/": "ܢܝܣܢ", "/may/": "ܐܝܪ", "/jun(e)?/": "ܚܙܝܪܢ", "/jul(y)?/": "ܬܡܘܙ", "/aug(ust)?/": "ܐܒ", "/sep(t(ember)?)?/": "ܐܝܠܘܠ", "/oct(ober)?/": "ܬܫܪܝ ܩܕܝܡ", "/nov(ember)?/": "ܬܫܪܝ ܐܚܪܝ", "/dec(ember)?/": "ܟܢܘܢ ܩܕܝܡ", "/^su(n(day)?)?/": "^܏(ܐ ܏ܒܫ(ܐ)?)?", "/^mo(n(day)?)?/": "^܏(ܒ ܏ܒܫ(ܫܒܐ)?)?", "/^tu(e(s(day)?)?)?/": "^܏(ܓ ܏ܒܫ(ܫܒܐ)?)?", "/^we(d(nesday)?)?/": "^܏(ܕ ܏ܒܫ(ܒܫܒܐ)?)?", "/^th(u(r(s(day)?)?)?)?/": "^܏(ܗ ܏ܒܫ(ܫܒܐ)?)?", "/^fr(i(day)?)?/": "^܏(ܥܪܘܒ(ܐ)?)?", "/^sa(t(urday)?)?/": "^܏(ܫܒ(ܐ)?)?", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "syr-SY"; /** * @overview datejs * @version 1.0.0-rc3 * @author Gregory Wild-Smith * @copyright 2015 Gregory Wild-Smith * @license MIT * @homepage https://github.com/abritinthebay/datejs */(function () { var $D = Date; var lang = Date.CultureStrings ? Date.CultureStrings.lang : null; var loggedKeys = {}; // for debug purposes. var getText = { getFromKey: function (key, countryCode) { var output; if (Date.CultureStrings && Date.CultureStrings[countryCode] && Date.CultureStrings[countryCode][key]) { output = Date.CultureStrings[countryCode][key]; } else { output = getText.buildFromDefault(key); } if (key.charAt(0) === "/") { // Assume it's a regex output = getText.buildFromRegex(key, countryCode); } return output; }, getFromObjectValues: function (obj, countryCode) { var key, output = {}; for(key in obj) { if (obj.hasOwnProperty(key)) { output[key] = getText.getFromKey(obj[key], countryCode); } } return output; }, getFromObjectKeys: function (obj, countryCode) { var key, output = {}; for(key in obj) { if (obj.hasOwnProperty(key)) { output[getText.getFromKey(key, countryCode)] = obj[key]; } } return output; }, getFromArray: function (arr, countryCode) { var output = []; for (var i=0; i < arr.length; i++){ if (i in arr) { output[i] = getText.getFromKey(arr[i], countryCode); } } return output; }, buildFromDefault: function (key) { var output, length, split, last; switch(key) { case "name": output = "en-US"; break; case "englishName": output = "English (United States)"; break; case "nativeName": output = "English (United States)"; break; case "twoDigitYearMax": output = 2049; break; case "firstDayOfWeek": output = 0; break; default: output = key; split = key.split("_"); length = split.length; if (length > 1 && key.charAt(0) !== "/") { // if the key isn't a regex and it has a split. last = split[(length - 1)].toLowerCase(); if (last === "initial" || last === "abbr") { output = split[0]; } } break; } return output; }, buildFromRegex: function (key, countryCode) { var output; if (Date.CultureStrings && Date.CultureStrings[countryCode] && Date.CultureStrings[countryCode][key]) { output = new RegExp(Date.CultureStrings[countryCode][key], "i"); } else { output = new RegExp(key.replace(new RegExp("/", "g"),""), "i"); } return output; } }; var shallowMerge = function (obj1, obj2) { for (var attrname in obj2) { if (obj2.hasOwnProperty(attrname)) { obj1[attrname] = obj2[attrname]; } } }; var __ = function (key, language) { var countryCode = (language) ? language : lang; loggedKeys[key] = key; if (typeof key === "object") { if (key instanceof Array) { return getText.getFromArray(key, countryCode); } else { return getText.getFromObjectKeys(key, countryCode); } } else { return getText.getFromKey(key, countryCode); } }; var loadI18nScript = function (code) { // paatterned after jQuery's getScript. var url = Date.Config.i18n + code + ".js"; var head = document.getElementsByTagName("head")[0] || document.documentElement; var script = document.createElement("script"); script.src = url; var completed = false; var events = { done: function (){} // placeholder function }; // Attach handlers for all browsers script.onload = script.onreadystatechange = function() { if ( !completed && (!this.readyState || this.readyState === "loaded" || this.readyState === "complete") ) { events.done(); head.removeChild(script); } }; setTimeout(function() { head.insertBefore(script, head.firstChild); }, 0); // allows return to execute first return { done: function (cb) { events.done = function() { if (cb) { setTimeout(cb,0); } }; } }; }; var buildInfo = { buildFromMethodHash: function (obj) { var key; for(key in obj) { if (obj.hasOwnProperty(key)) { obj[key] = buildInfo[obj[key]](); } } return obj; }, timeZoneDST: function () { var DST = { "CHADT": "+1345", "NZDT": "+1300", "AEDT": "+1100", "ACDT": "+1030", "AZST": "+0500", "IRDT": "+0430", "EEST": "+0300", "CEST": "+0200", "BST": "+0100", "PMDT": "-0200", "ADT": "-0300", "NDT": "-0230", "EDT": "-0400", "CDT": "-0500", "MDT": "-0600", "PDT": "-0700", "AKDT": "-0800", "HADT": "-0900" }; return __(DST); }, timeZoneStandard: function () { var standard = { "LINT": "+1400", "TOT": "+1300", "CHAST": "+1245", "NZST": "+1200", "NFT": "+1130", "SBT": "+1100", "AEST": "+1000", "ACST": "+0930", "JST": "+0900", "CWST": "+0845", "CT": "+0800", "ICT": "+0700", "MMT": "+0630", "BST": "+0600", "NPT": "+0545", "IST": "+0530", "PKT": "+0500", "AFT": "+0430", "MSK": "+0400", "IRST": "+0330", "FET": "+0300", "EET": "+0200", "CET": "+0100", "GMT": "+0000", "UTC": "+0000", "CVT": "-0100", "GST": "-0200", "BRT": "-0300", "NST": "-0330", "AST": "-0400", "EST": "-0500", "CST": "-0600", "MST": "-0700", "PST": "-0800", "AKST": "-0900", "MIT": "-0930", "HST": "-1000", "SST": "-1100", "BIT": "-1200" }; return __(standard); }, timeZones: function (data) { var zone; data.timezones = []; for (zone in data.abbreviatedTimeZoneStandard) { if (data.abbreviatedTimeZoneStandard.hasOwnProperty(zone)) { data.timezones.push({ name: zone, offset: data.abbreviatedTimeZoneStandard[zone]}); } } for (zone in data.abbreviatedTimeZoneDST) { if (data.abbreviatedTimeZoneDST.hasOwnProperty(zone)) { data.timezones.push({ name: zone, offset: data.abbreviatedTimeZoneDST[zone], dst: true}); } } return data.timezones; }, days: function () { return __(["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"]); }, dayAbbr: function () { return __(["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"]); }, dayShortNames: function () { return __(["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"]); }, dayFirstLetters: function () { return __(["S_Sun_Initial", "M_Mon_Initial", "T_Tues_Initial", "W_Wed_Initial", "T_Thu_Initial", "F_Fri_Initial", "S_Sat_Initial"]); }, months: function () { return __(["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"]); }, monthAbbr: function () { return __(["Jan_Abbr", "Feb_Abbr", "Mar_Abbr", "Apr_Abbr", "May_Abbr", "Jun_Abbr", "Jul_Abbr", "Aug_Abbr", "Sep_Abbr", "Oct_Abbr", "Nov_Abbr", "Dec_Abbr"]); }, formatPatterns: function () { return getText.getFromObjectValues({ shortDate: "M/d/yyyy", longDate: "dddd, MMMM dd, yyyy", shortTime: "h:mm tt", longTime: "h:mm:ss tt", fullDateTime: "dddd, MMMM dd, yyyy h:mm:ss tt", sortableDateTime: "yyyy-MM-ddTHH:mm:ss", universalSortableDateTime: "yyyy-MM-dd HH:mm:ssZ", rfc1123: "ddd, dd MMM yyyy HH:mm:ss", monthDay: "MMMM dd", yearMonth: "MMMM, yyyy" }, Date.i18n.currentLanguage()); }, regex: function () { return getText.getFromObjectValues({ inTheMorning: "/( in the )(morn(ing)?)\\b/", thisMorning: "/(this )(morn(ing)?)\\b/", amThisMorning: "/(\b\\d(am)? )(this )(morn(ing)?)/", inTheEvening: "/( in the )(even(ing)?)\\b/", thisEvening: "/(this )(even(ing)?)\\b/", pmThisEvening: "/(\b\\d(pm)? )(this )(even(ing)?)/", jan: "/jan(uary)?/", feb: "/feb(ruary)?/", mar: "/mar(ch)?/", apr: "/apr(il)?/", may: "/may/", jun: "/jun(e)?/", jul: "/jul(y)?/", aug: "/aug(ust)?/", sep: "/sep(t(ember)?)?/", oct: "/oct(ober)?/", nov: "/nov(ember)?/", dec: "/dec(ember)?/", sun: "/^su(n(day)?)?/", mon: "/^mo(n(day)?)?/", tue: "/^tu(e(s(day)?)?)?/", wed: "/^we(d(nesday)?)?/", thu: "/^th(u(r(s(day)?)?)?)?/", fri: "/fr(i(day)?)?/", sat: "/^sa(t(urday)?)?/", future: "/^next/", past: "/^last|past|prev(ious)?/", add: "/^(\\+|aft(er)?|from|hence)/", subtract: "/^(\\-|bef(ore)?|ago)/", yesterday: "/^yes(terday)?/", today: "/^t(od(ay)?)?/", tomorrow: "/^tom(orrow)?/", now: "/^n(ow)?/", millisecond: "/^ms|milli(second)?s?/", second: "/^sec(ond)?s?/", minute: "/^mn|min(ute)?s?/", hour: "/^h(our)?s?/", week: "/^w(eek)?s?/", month: "/^m(onth)?s?/", day: "/^d(ay)?s?/", year: "/^y(ear)?s?/", shortMeridian: "/^(a|p)/", longMeridian: "/^(a\\.?m?\\.?|p\\.?m?\\.?)/", timezone: "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/", ordinalSuffix: "/^\\s*(st|nd|rd|th)/", timeContext: "/^\\s*(\\:|a(?!u|p)|p)/" }, Date.i18n.currentLanguage()); } }; var CultureInfo = function () { var info = getText.getFromObjectValues({ name: "name", englishName: "englishName", nativeName: "nativeName", amDesignator: "AM", pmDesignator: "PM", firstDayOfWeek: "firstDayOfWeek", twoDigitYearMax: "twoDigitYearMax", dateElementOrder: "mdy" }, Date.i18n.currentLanguage()); var constructedInfo = buildInfo.buildFromMethodHash({ dayNames: "days", abbreviatedDayNames: "dayAbbr", shortestDayNames: "dayShortNames", firstLetterDayNames: "dayFirstLetters", monthNames: "months", abbreviatedMonthNames: "monthAbbr", formatPatterns: "formatPatterns", regexPatterns: "regex", abbreviatedTimeZoneDST: "timeZoneDST", abbreviatedTimeZoneStandard: "timeZoneStandard" }); shallowMerge(info, constructedInfo); buildInfo.timeZones(info); return info; }; $D.i18n = { __: function (key, lang) { return __(key, lang); }, currentLanguage: function () { return lang || "en-US"; }, setLanguage: function (code, force, cb) { var async = false; if (force || code === "en-US" || (!!Date.CultureStrings && !!Date.CultureStrings[code])) { lang = code; Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings.lang = code; Date.CultureInfo = new CultureInfo(); } else { if (!(!!Date.CultureStrings && !!Date.CultureStrings[code])) { if (typeof exports !== "undefined" && this.exports !== exports) { // we're in a Node enviroment, load it using require try { require("../i18n/" + code + ".js"); lang = code; Date.CultureStrings.lang = code; Date.CultureInfo = new CultureInfo(); } catch (e) { // var str = "The language for '" + code + "' could not be loaded by Node. It likely does not exist."; throw new Error("The DateJS IETF language tag '" + code + "' could not be loaded by Node. It likely does not exist."); } } else if (Date.Config && Date.Config.i18n) { // we know the location of the files, so lets load them async = true; loadI18nScript(code).done(function(){ lang = code; Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings.lang = code; Date.CultureInfo = new CultureInfo(); $D.Parsing.Normalizer.buildReplaceData(); // because this is async if ($D.Grammar) { $D.Grammar.buildGrammarFormats(); // so we can parse those strings... } if (cb) { setTimeout(cb,0); } }); } else { Date.console.error("The DateJS IETF language tag '" + code + "' is not available and has not been loaded."); return false; } } } $D.Parsing.Normalizer.buildReplaceData(); // rebuild normalizer strings if ($D.Grammar) { $D.Grammar.buildGrammarFormats(); // so we can parse those strings... } if (!async && cb) { setTimeout(cb,0); } }, getLoggedKeys: function () { return loggedKeys; }, updateCultureInfo: function () { Date.CultureInfo = new CultureInfo(); } }; $D.i18n.updateCultureInfo(); // run automatically }()); (function () { var $D = Date, $P = $D.prototype, p = function (s, l) { if (!l) { l = 2; } return ("000" + s).slice(l * -1); }; if (typeof window !== "undefined" && typeof window.console !== "undefined" && typeof window.console.log !== "undefined") { $D.console = console; // used only to raise non-critical errors if available } else { // set mock so we don't give errors. $D.console = { log: function(){}, error: function(){} }; } $D.Config = $D.Config || {}; $D.initOverloads = function() { /** * Overload of Date.now. Allows an alternate call for Date.now where it returns the * current Date as an object rather than just milliseconds since the Unix Epoch. * * Also provides an implementation of now() for browsers (IE<9) that don't have it. * * Backwards compatible so with work with either: * Date.now() [returns ms] * or * Date.now(true) [returns Date] */ if (!$D.now) { $D._now = function now() { return new Date().getTime(); }; } else if (!$D._now) { $D._now = $D.now; } $D.now = function (returnObj) { if (returnObj) { return $D.present(); } else { return $D._now(); } }; if ( !$P.toISOString ) { $P.toISOString = function() { return this.getUTCFullYear() + "-" + p(this.getUTCMonth() + 1) + "-" + p(this.getUTCDate()) + "T" + p(this.getUTCHours()) + ":" + p(this.getUTCMinutes()) + ":" + p(this.getUTCSeconds()) + "." + String( (this.getUTCMilliseconds()/1000).toFixed(3)).slice(2, 5) + "Z"; }; } // private if ( $P._toString === undefined ){ $P._toString = $P.toString; } }; $D.initOverloads(); /** * Gets a date that is set to the current date. The time is set to the start of the day (00:00 or 12:00 AM). * @return {Date} The current date. */ $D.today = function () { return new Date().clearTime(); }; /** * Gets a date that is set to the current date and time (same as new Date, but chainable) * @return {Date} The current date. */ $D.present = function () { return new Date(); }; /** * Compares the first date to the second date and returns an number indication of their relative values. * @param {Date} First Date object to compare [Required]. * @param {Date} Second Date object to compare to [Required]. * @return {Number} -1 = date1 is lessthan date2. 0 = values are equal. 1 = date1 is greaterthan date2. */ $D.compare = function (date1, date2) { if (isNaN(date1) || isNaN(date2)) { throw new Error(date1 + " - " + date2); } else if (date1 instanceof Date && date2 instanceof Date) { return (date1 < date2) ? -1 : (date1 > date2) ? 1 : 0; } else { throw new TypeError(date1 + " - " + date2); } }; /** * Compares the first Date object to the second Date object and returns true if they are equal. * @param {Date} First Date object to compare [Required] * @param {Date} Second Date object to compare to [Required] * @return {Boolean} true if dates are equal. false if they are not equal. */ $D.equals = function (date1, date2) { return (date1.compareTo(date2) === 0); }; /** * Gets the language appropriate day name when given the day number(0-6) * eg - 0 == Sunday * @return {String} The day name */ $D.getDayName = function (n) { return Date.CultureInfo.dayNames[n]; }; /** * Gets the day number (0-6) if given a CultureInfo specific string which is a valid dayName, abbreviatedDayName or shortestDayName (two char). * @param {String} The name of the day (eg. "Monday, "Mon", "tuesday", "tue", "We", "we"). * @return {Number} The day number */ $D.getDayNumberFromName = function (name) { var n = Date.CultureInfo.dayNames, m = Date.CultureInfo.abbreviatedDayNames, o = Date.CultureInfo.shortestDayNames, s = name.toLowerCase(); for (var i = 0; i < n.length; i++) { if (n[i].toLowerCase() === s || m[i].toLowerCase() === s || o[i].toLowerCase() === s) { return i; } } return -1; }; /** * Gets the month number (0-11) if given a Culture Info specific string which is a valid monthName or abbreviatedMonthName. * @param {String} The name of the month (eg. "February, "Feb", "october", "oct"). * @return {Number} The day number */ $D.getMonthNumberFromName = function (name) { var n = Date.CultureInfo.monthNames, m = Date.CultureInfo.abbreviatedMonthNames, s = name.toLowerCase(); for (var i = 0; i < n.length; i++) { if (n[i].toLowerCase() === s || m[i].toLowerCase() === s) { return i; } } return -1; }; /** * Gets the language appropriate month name when given the month number(0-11) * eg - 0 == January * @return {String} The month name */ $D.getMonthName = function (n) { return Date.CultureInfo.monthNames[n]; }; /** * Determines if the current date instance is within a LeapYear. * @param {Number} The year. * @return {Boolean} true if date is within a LeapYear, otherwise false. */ $D.isLeapYear = function (year) { return ((year % 4 === 0 && year % 100 !== 0) || year % 400 === 0); }; /** * Gets the number of days in the month, given a year and month value. Automatically corrects for LeapYear. * @param {Number} The year. * @param {Number} The month (0-11). * @return {Number} The number of days in the month. */ $D.getDaysInMonth = function (year, month) { if (!month && $D.validateMonth(year)) { month = year; year = Date.today().getFullYear(); } return [31, ($D.isLeapYear(year) ? 29 : 28), 31, 30, 31, 30, 31, 31, 30, 31, 30, 31][month]; }; $P.getDaysInMonth = function () { return $D.getDaysInMonth(this.getFullYear(), this.getMonth()); }; $D.getTimezoneAbbreviation = function (offset, dst) { var p, n = (dst || false) ? Date.CultureInfo.abbreviatedTimeZoneDST : Date.CultureInfo.abbreviatedTimeZoneStandard; for (p in n) { if (n.hasOwnProperty(p)) { if (n[p] === offset) { return p; } } } return null; }; $D.getTimezoneOffset = function (name, dst) { var i, a =[], z = Date.CultureInfo.timezones; if (!name) { name = (new Date()).getTimezone();} for (i = 0; i < z.length; i++) { if (z[i].name === name.toUpperCase()) { a.push(i); } } if (!z[a[0]]) { return null; } if (a.length === 1 || !dst) { return z[a[0]].offset; } else { for (i=0; i < a.length; i++) { if (z[a[i]].dst) { return z[a[i]].offset; } } } }; $D.getQuarter = function (d) { d = d || new Date(); // If no date supplied, use today var q = [1,2,3,4]; return q[Math.floor(d.getMonth() / 3)]; // ~~~ is a bitwise op. Faster than Math.floor }; $D.getDaysLeftInQuarter = function (d) { d = d || new Date(); var qEnd = new Date(d); qEnd.setMonth(qEnd.getMonth() + 3 - qEnd.getMonth() % 3, 0); return Math.floor((qEnd - d) / 8.64e7); }; // private var validate = function (n, min, max, name) { name = name ? name : "Object"; if (typeof n === "undefined") { return false; } else if (typeof n !== "number") { throw new TypeError(n + " is not a Number."); } else if (n < min || n > max) { // As failing validation is *not* an exceptional circumstance // lets not throw a RangeError Exception here. // It's semantically correct but it's not sensible. return false; } return true; }; /** * Validates the number is within an acceptable range for milliseconds [0-999]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateMillisecond = function (value) { return validate(value, 0, 999, "millisecond"); }; /** * Validates the number is within an acceptable range for seconds [0-59]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateSecond = function (value) { return validate(value, 0, 59, "second"); }; /** * Validates the number is within an acceptable range for minutes [0-59]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateMinute = function (value) { return validate(value, 0, 59, "minute"); }; /** * Validates the number is within an acceptable range for hours [0-23]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateHour = function (value) { return validate(value, 0, 23, "hour"); }; /** * Validates the number is within an acceptable range for the days in a month [0-MaxDaysInMonth]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateDay = function (value, year, month) { if (year === undefined || year === null || month === undefined || month === null) { return false;} return validate(value, 1, $D.getDaysInMonth(year, month), "day"); }; /** * Validates the number is within an acceptable range for months [0-11]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateWeek = function (value) { return validate(value, 0, 53, "week"); }; /** * Validates the number is within an acceptable range for months [0-11]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateMonth = function (value) { return validate(value, 0, 11, "month"); }; /** * Validates the number is within an acceptable range for years. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateYear = function (value) { /** * Per ECMAScript spec the range of times supported by Date objects is * exactly -100,000,000 days to +100,000,000 days measured relative to * midnight at the beginning of 01 January, 1970 UTC. * This gives a range of 8,640,000,000,000,000 milliseconds to either * side of 01 January, 1970 UTC. * * Earliest possible date: Tue, 20 Apr 271,822 B.C. 00:00:00 UTC * Latest possible date: Sat, 13 Sep 275,760 00:00:00 UTC */ return validate(value, -271822, 275760, "year"); }; $D.validateTimezone = function(value) { var timezones = {"ACDT":1,"ACST":1,"ACT":1,"ADT":1,"AEDT":1,"AEST":1,"AFT":1,"AKDT":1,"AKST":1,"AMST":1,"AMT":1,"ART":1,"AST":1,"AWDT":1,"AWST":1,"AZOST":1,"AZT":1,"BDT":1,"BIOT":1,"BIT":1,"BOT":1,"BRT":1,"BST":1,"BTT":1,"CAT":1,"CCT":1,"CDT":1,"CEDT":1,"CEST":1,"CET":1,"CHADT":1,"CHAST":1,"CHOT":1,"ChST":1,"CHUT":1,"CIST":1,"CIT":1,"CKT":1,"CLST":1,"CLT":1,"COST":1,"COT":1,"CST":1,"CT":1,"CVT":1,"CWST":1,"CXT":1,"DAVT":1,"DDUT":1,"DFT":1,"EASST":1,"EAST":1,"EAT":1,"ECT":1,"EDT":1,"EEDT":1,"EEST":1,"EET":1,"EGST":1,"EGT":1,"EIT":1,"EST":1,"FET":1,"FJT":1,"FKST":1,"FKT":1,"FNT":1,"GALT":1,"GAMT":1,"GET":1,"GFT":1,"GILT":1,"GIT":1,"GMT":1,"GST":1,"GYT":1,"HADT":1,"HAEC":1,"HAST":1,"HKT":1,"HMT":1,"HOVT":1,"HST":1,"ICT":1,"IDT":1,"IOT":1,"IRDT":1,"IRKT":1,"IRST":1,"IST":1,"JST":1,"KGT":1,"KOST":1,"KRAT":1,"KST":1,"LHST":1,"LINT":1,"MAGT":1,"MART":1,"MAWT":1,"MDT":1,"MET":1,"MEST":1,"MHT":1,"MIST":1,"MIT":1,"MMT":1,"MSK":1,"MST":1,"MUT":1,"MVT":1,"MYT":1,"NCT":1,"NDT":1,"NFT":1,"NPT":1,"NST":1,"NT":1,"NUT":1,"NZDT":1,"NZST":1,"OMST":1,"ORAT":1,"PDT":1,"PET":1,"PETT":1,"PGT":1,"PHOT":1,"PHT":1,"PKT":1,"PMDT":1,"PMST":1,"PONT":1,"PST":1,"PYST":1,"PYT":1,"RET":1,"ROTT":1,"SAKT":1,"SAMT":1,"SAST":1,"SBT":1,"SCT":1,"SGT":1,"SLST":1,"SRT":1,"SST":1,"SYOT":1,"TAHT":1,"THA":1,"TFT":1,"TJT":1,"TKT":1,"TLT":1,"TMT":1,"TOT":1,"TVT":1,"UCT":1,"ULAT":1,"UTC":1,"UYST":1,"UYT":1,"UZT":1,"VET":1,"VLAT":1,"VOLT":1,"VOST":1,"VUT":1,"WAKT":1,"WAST":1,"WAT":1,"WEDT":1,"WEST":1,"WET":1,"WST":1,"YAKT":1,"YEKT":1,"Z":1}; return (timezones[value] === 1); }; $D.validateTimezoneOffset= function(value) { // timezones go from +14hrs to -12hrs, the +X hours are negative offsets. return (value > -841 && value < 721); }; }()); (function () { var $D = Date, $P = $D.prototype, p = function (s, l) { if (!l) { l = 2; } return ("000" + s).slice(l * -1); }; var validateConfigObject = function (obj) { var result = {}, self = this, prop, testFunc; testFunc = function (prop, func, value) { if (prop === "day") { var month = (obj.month !== undefined) ? obj.month : self.getMonth(); var year = (obj.year !== undefined) ? obj.year : self.getFullYear(); return $D[func](value, year, month); } else { return $D[func](value); } }; for (prop in obj) { if (Object.prototype.hasOwnProperty.call(obj, prop)) { var func = "validate" + prop.charAt(0).toUpperCase() + prop.slice(1); if ($D[func] && obj[prop] !== null && testFunc(prop, func, obj[prop])) { result[prop] = obj[prop]; } } } return result; }; /** * Resets the time of this Date object to 12:00 AM (00:00), which is the start of the day. * @param {Boolean} .clone() this date instance before clearing Time * @return {Date} this */ $P.clearTime = function () { this.setHours(0); this.setMinutes(0); this.setSeconds(0); this.setMilliseconds(0); return this; }; /** * Resets the time of this Date object to the current time ('now'). * @return {Date} this */ $P.setTimeToNow = function () { var n = new Date(); this.setHours(n.getHours()); this.setMinutes(n.getMinutes()); this.setSeconds(n.getSeconds()); this.setMilliseconds(n.getMilliseconds()); return this; }; /** * Returns a new Date object that is an exact date and time copy of the original instance. * @return {Date} A new Date instance */ $P.clone = function () { return new Date(this.getTime()); }; /** * Compares this instance to a Date object and returns an number indication of their relative values. * @param {Date} Date object to compare [Required] * @return {Number} -1 = this is lessthan date. 0 = values are equal. 1 = this is greaterthan date. */ $P.compareTo = function (date) { return Date.compare(this, date); }; /** * Compares this instance to another Date object and returns true if they are equal. * @param {Date} Date object to compare. If no date to compare, new Date() [now] is used. * @return {Boolean} true if dates are equal. false if they are not equal. */ $P.equals = function (date) { return Date.equals(this, (date !== undefined ? date : new Date())); }; /** * Determines if this instance is between a range of two dates or equal to either the start or end dates. * @param {Date} Start of range [Required] * @param {Date} End of range [Required] * @return {Boolean} true is this is between or equal to the start and end dates, else false */ $P.between = function (start, end) { return this.getTime() >= start.getTime() && this.getTime() <= end.getTime(); }; /** * Determines if this date occurs after the date to compare to. * @param {Date} Date object to compare. If no date to compare, new Date() ("now") is used. * @return {Boolean} true if this date instance is greater than the date to compare to (or "now"), otherwise false. */ $P.isAfter = function (date) { return this.compareTo(date || new Date()) === 1; }; /** * Determines if this date occurs before the date to compare to. * @param {Date} Date object to compare. If no date to compare, new Date() ("now") is used. * @return {Boolean} true if this date instance is less than the date to compare to (or "now"). */ $P.isBefore = function (date) { return (this.compareTo(date || new Date()) === -1); }; /** * Determines if the current Date instance occurs today. * @return {Boolean} true if this date instance is 'today', otherwise false. */ /** * Determines if the current Date instance occurs on the same Date as the supplied 'date'. * If no 'date' to compare to is provided, the current Date instance is compared to 'today'. * @param {date} Date object to compare. If no date to compare, the current Date ("now") is used. * @return {Boolean} true if this Date instance occurs on the same Day as the supplied 'date'. */ $P.isToday = $P.isSameDay = function (date) { return this.clone().clearTime().equals((date || new Date()).clone().clearTime()); }; /** * Adds the specified number of milliseconds to this instance. * @param {Number} The number of milliseconds to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addMilliseconds = function (value) { if (!value) { return this; } this.setTime(this.getTime() + value * 1); return this; }; /** * Adds the specified number of seconds to this instance. * @param {Number} The number of seconds to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addSeconds = function (value) { if (!value) { return this; } return this.addMilliseconds(value * 1000); }; /** * Adds the specified number of seconds to this instance. * @param {Number} The number of seconds to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addMinutes = function (value) { if (!value) { return this; } return this.addMilliseconds(value * 60000); // 60*1000 }; /** * Adds the specified number of hours to this instance. * @param {Number} The number of hours to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addHours = function (value) { if (!value) { return this; } return this.addMilliseconds(value * 3600000); // 60*60*1000 }; /** * Adds the specified number of days to this instance. * @param {Number} The number of days to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addDays = function (value) { if (!value) { return this; } this.setDate(this.getDate() + value * 1); return this; }; /** * Adds the specified number of weekdays (ie - not sat or sun) to this instance. * @param {Number} The number of days to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addWeekdays = function (value) { if (!value) { return this; } var day = this.getDay(); var weeks = (Math.ceil(Math.abs(value)/7)); if (day === 0 || day === 6) { if (value > 0) { this.next().monday(); this.addDays(-1); day = this.getDay(); } } if (value < 0) { while (value < 0) { this.addDays(-1); day = this.getDay(); if (day !== 0 && day !== 6) { value++; } } return this; } else if (value > 5 || (6-day) <= value) { value = value + (weeks * 2); } return this.addDays(value); }; /** * Adds the specified number of weeks to this instance. * @param {Number} The number of weeks to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addWeeks = function (value) { if (!value) { return this; } return this.addDays(value * 7); }; /** * Adds the specified number of months to this instance. * @param {Number} The number of months to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addMonths = function (value) { if (!value) { return this; } var n = this.getDate(); this.setDate(1); this.setMonth(this.getMonth() + value * 1); this.setDate(Math.min(n, $D.getDaysInMonth(this.getFullYear(), this.getMonth()))); return this; }; $P.addQuarters = function (value) { if (!value) { return this; } // note this will take you to the same point in the quarter as you are now. // i.e. - if you are 15 days into the quarter you'll be 15 days into the resulting one. // bonus: this allows adding fractional quarters return this.addMonths(value * 3); }; /** * Adds the specified number of years to this instance. * @param {Number} The number of years to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addYears = function (value) { if (!value) { return this; } return this.addMonths(value * 12); }; /** * Adds (or subtracts) to the value of the years, months, weeks, days, hours, minutes, seconds, milliseconds of the date instance using given configuration object. Positive and Negative values allowed. * Example

	Date.today().add( { days: 1, months: 1 } )

	new Date().add( { years: -1 } )
	
* @param {Object} Configuration object containing attributes (months, days, etc.) * @return {Date} this */ $P.add = function (config) { if (typeof config === "number") { this._orient = config; return this; } var x = config; if (x.day) { // If we should be a different date than today (eg: for 'tomorrow -1d', etc). // Should only effect parsing, not direct usage (eg, Finish and FinishExact) if ((x.day - this.getDate()) !== 0) { this.setDate(x.day); } } if (x.milliseconds) { this.addMilliseconds(x.milliseconds); } if (x.seconds) { this.addSeconds(x.seconds); } if (x.minutes) { this.addMinutes(x.minutes); } if (x.hours) { this.addHours(x.hours); } if (x.weeks) { this.addWeeks(x.weeks); } if (x.months) { this.addMonths(x.months); } if (x.years) { this.addYears(x.years); } if (x.days) { this.addDays(x.days); } return this; }; /** * Get the week number. Week one (1) is the week which contains the first Thursday of the year. Monday is considered the first day of the week. * The .getWeek() function does NOT convert the date to UTC. The local datetime is used. * Please use .getISOWeek() to get the week of the UTC converted date. * @return {Number} 1 to 53 */ $P.getWeek = function (utc) { // Create a copy of this date object var self, target = new Date(this.valueOf()); if (utc) { target.addMinutes(target.getTimezoneOffset()); self = target.clone(); } else { self = this; } // ISO week date weeks start on monday // so correct the day number var dayNr = (self.getDay() + 6) % 7; // ISO 8601 states that week 1 is the week // with the first thursday of that year. // Set the target date to the thursday in the target week target.setDate(target.getDate() - dayNr + 3); // Store the millisecond value of the target date var firstThursday = target.valueOf(); // Set the target to the first thursday of the year // First set the target to january first target.setMonth(0, 1); // Not a thursday? Correct the date to the next thursday if (target.getDay() !== 4) { target.setMonth(0, 1 + ((4 - target.getDay()) + 7) % 7); } // The weeknumber is the number of weeks between the // first thursday of the year and the thursday in the target week return 1 + Math.ceil((firstThursday - target) / 604800000); // 604800000 = 7 * 24 * 3600 * 1000 }; /** * Get the ISO 8601 week number. Week one ("01") is the week which contains the first Thursday of the year. Monday is considered the first day of the week. * The .getISOWeek() function does convert the date to it's UTC value. Please use .getWeek() to get the week of the local date. * @return {String} "01" to "53" */ $P.getISOWeek = function () { return p(this.getWeek(true)); }; /** * Moves the date to Monday of the week set. Week one (1) is the week which contains the first Thursday of the year. * @param {Number} A Number (1 to 53) that represents the week of the year. * @return {Date} this */ $P.setWeek = function (n) { if ((n - this.getWeek()) === 0) { if (this.getDay() !== 1) { return this.moveToDayOfWeek(1, (this.getDay() > 1 ? -1 : 1)); } else { return this; } } else { return this.moveToDayOfWeek(1, (this.getDay() > 1 ? -1 : 1)).addWeeks(n - this.getWeek()); } }; $P.setQuarter = function (qtr) { var month = Math.abs(((qtr-1) * 3) + 1); return this.setMonth(month, 1); }; $P.getQuarter = function () { return Date.getQuarter(this); }; $P.getDaysLeftInQuarter = function () { return Date.getDaysLeftInQuarter(this); }; /** * Moves the date to the next n'th occurrence of the dayOfWeek starting from the beginning of the month. The number (-1) is a magic number and will return the last occurrence of the dayOfWeek in the month. * @param {Number} The dayOfWeek to move to * @param {Number} The n'th occurrence to move to. Use (-1) to return the last occurrence in the month * @return {Date} this */ $P.moveToNthOccurrence = function (dayOfWeek, occurrence) { if (dayOfWeek === "Weekday") { if (occurrence > 0) { this.moveToFirstDayOfMonth(); if (this.is().weekday()) { occurrence -= 1; } } else if (occurrence < 0) { this.moveToLastDayOfMonth(); if (this.is().weekday()) { occurrence += 1; } } else { return this; } return this.addWeekdays(occurrence); } var shift = 0; if (occurrence > 0) { shift = occurrence - 1; } else if (occurrence === -1) { this.moveToLastDayOfMonth(); if (this.getDay() !== dayOfWeek) { this.moveToDayOfWeek(dayOfWeek, -1); } return this; } return this.moveToFirstDayOfMonth().addDays(-1).moveToDayOfWeek(dayOfWeek, +1).addWeeks(shift); }; var moveToN = function (getFunc, addFunc, nVal) { return function (value, orient) { var diff = (value - this[getFunc]() + nVal * (orient || +1)) % nVal; return this[addFunc]((diff === 0) ? diff += nVal * (orient || +1) : diff); }; }; /** * Move to the next or last dayOfWeek based on the orient value. * @param {Number} The dayOfWeek to move to * @param {Number} Forward (+1) or Back (-1). Defaults to +1. [Optional] * @return {Date} this */ $P.moveToDayOfWeek = moveToN("getDay", "addDays", 7); /** * Move to the next or last month based on the orient value. * @param {Number} The month to move to. 0 = January, 11 = December * @param {Number} Forward (+1) or Back (-1). Defaults to +1. [Optional] * @return {Date} this */ $P.moveToMonth = moveToN("getMonth", "addMonths", 12); /** * Get the Ordinate of the current day ("th", "st", "rd"). * @return {String} */ $P.getOrdinate = function () { var num = this.getDate(); return ord(num); }; /** * Get the Ordinal day (numeric day number) of the year, adjusted for leap year. * @return {Number} 1 through 365 (366 in leap years) */ $P.getOrdinalNumber = function () { return Math.ceil((this.clone().clearTime() - new Date(this.getFullYear(), 0, 1)) / 86400000) + 1; }; /** * Get the time zone abbreviation of the current date. * @return {String} The abbreviated time zone name (e.g. "EST") */ $P.getTimezone = function () { return $D.getTimezoneAbbreviation(this.getUTCOffset(), this.isDaylightSavingTime()); }; $P.setTimezoneOffset = function (offset) { var here = this.getTimezoneOffset(), there = Number(offset) * -6 / 10; return (there || there === 0) ? this.addMinutes(there - here) : this; }; $P.setTimezone = function (offset) { return this.setTimezoneOffset($D.getTimezoneOffset(offset)); }; /** * Indicates whether Daylight Saving Time is observed in the current time zone. * @return {Boolean} true|false */ $P.hasDaylightSavingTime = function () { return (Date.today().set({month: 0, day: 1}).getTimezoneOffset() !== Date.today().set({month: 6, day: 1}).getTimezoneOffset()); }; /** * Indicates whether this Date instance is within the Daylight Saving Time range for the current time zone. * @return {Boolean} true|false */ $P.isDaylightSavingTime = function () { return Date.today().set({month: 0, day: 1}).getTimezoneOffset() !== this.getTimezoneOffset(); }; /** * Get the offset from UTC of the current date. * @return {String} The 4-character offset string prefixed with + or - (e.g. "-0500") */ $P.getUTCOffset = function (offset) { var n = (offset || this.getTimezoneOffset()) * -10 / 6, r; if (n < 0) { r = (n - 10000).toString(); return r.charAt(0) + r.substr(2); } else { r = (n + 10000).toString(); return "+" + r.substr(1); } }; /** * Returns the number of milliseconds between this date and date. * @param {Date} Defaults to now * @return {Number} The diff in milliseconds */ $P.getElapsed = function (date) { return (date || new Date()) - this; }; /** * Set the value of year, month, day, hour, minute, second, millisecond of date instance using given configuration object. * Example

	Date.today().set( { day: 20, month: 1 } )

	new Date().set( { millisecond: 0 } )
	
* * @param {Object} Configuration object containing attributes (month, day, etc.) * @return {Date} this */ $P.set = function (config) { config = validateConfigObject.call(this, config); var key; for (key in config) { if (Object.prototype.hasOwnProperty.call(config, key)) { var name = key.charAt(0).toUpperCase() + key.slice(1); var addFunc, getFunc; if (key !== "week" && key !== "month" && key !== "timezone" && key !== "timezoneOffset") { name += "s"; } addFunc = "add" + name; getFunc = "get" + name; if (key === "month") { addFunc = addFunc + "s"; } else if (key === "year"){ getFunc = "getFullYear"; } if (key !== "day" && key !== "timezone" && key !== "timezoneOffset" && key !== "week" && key !== "hour") { this[addFunc](config[key] - this[getFunc]()); } else if ( key === "timezone"|| key === "timezoneOffset" || key === "week" || key === "hour") { this["set"+name](config[key]); } } } // day has to go last because you can't validate the day without first knowing the month if (config.day) { this.addDays(config.day - this.getDate()); } return this; }; /** * Moves the date to the first day of the month. * @return {Date} this */ $P.moveToFirstDayOfMonth = function () { return this.set({ day: 1 }); }; /** * Moves the date to the last day of the month. * @return {Date} this */ $P.moveToLastDayOfMonth = function () { return this.set({ day: $D.getDaysInMonth(this.getFullYear(), this.getMonth())}); }; /** * Converts the value of the current Date object to its equivalent string representation. * Format Specifiers * CUSTOM DATE AND TIME FORMAT STRINGS * Format Description Example * ------ --------------------------------------------------------------------------- ----------------------- * s The seconds of the minute between 0-59. "0" to "59" * ss The seconds of the minute with leading zero if required. "00" to "59" * * m The minute of the hour between 0-59. "0" or "59" * mm The minute of the hour with leading zero if required. "00" or "59" * * h The hour of the day between 1-12. "1" to "12" * hh The hour of the day with leading zero if required. "01" to "12" * * H The hour of the day between 0-23. "0" to "23" * HH The hour of the day with leading zero if required. "00" to "23" * * d The day of the month between 1 and 31. "1" to "31" * dd The day of the month with leading zero if required. "01" to "31" * ddd Abbreviated day name. Date.CultureInfo.abbreviatedDayNames. "Mon" to "Sun" * dddd The full day name. Date.CultureInfo.dayNames. "Monday" to "Sunday" * * M The month of the year between 1-12. "1" to "12" * MM The month of the year with leading zero if required. "01" to "12" * MMM Abbreviated month name. Date.CultureInfo.abbreviatedMonthNames. "Jan" to "Dec" * MMMM The full month name. Date.CultureInfo.monthNames. "January" to "December" * * yy The year as a two-digit number. "99" or "08" * yyyy The full four digit year. "1999" or "2008" * * t Displays the first character of the A.M./P.M. designator. "A" or "P" * Date.CultureInfo.amDesignator or Date.CultureInfo.pmDesignator * tt Displays the A.M./P.M. designator. "AM" or "PM" * Date.CultureInfo.amDesignator or Date.CultureInfo.pmDesignator * * S The ordinal suffix ("st, "nd", "rd" or "th") of the current day. "st, "nd", "rd" or "th" * * STANDARD DATE AND TIME FORMAT STRINGS * Format Description Example *------ --------------------------------------------------------------------------- ----------------------- * d The CultureInfo shortDate Format Pattern "M/d/yyyy" * D The CultureInfo longDate Format Pattern "dddd, MMMM dd, yyyy" * F The CultureInfo fullDateTime Format Pattern "dddd, MMMM dd, yyyy h:mm:ss tt" * m The CultureInfo monthDay Format Pattern "MMMM dd" * r The CultureInfo rfc1123 Format Pattern "ddd, dd MMM yyyy HH:mm:ss GMT" * s The CultureInfo sortableDateTime Format Pattern "yyyy-MM-ddTHH:mm:ss" * t The CultureInfo shortTime Format Pattern "h:mm tt" * T The CultureInfo longTime Format Pattern "h:mm:ss tt" * u The CultureInfo universalSortableDateTime Format Pattern "yyyy-MM-dd HH:mm:ssZ" * y The CultureInfo yearMonth Format Pattern "MMMM, yyyy" * * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @return {String} A string representation of the current Date object. */ var ord = function (n) { switch (n * 1) { case 1: case 21: case 31: return "st"; case 2: case 22: return "nd"; case 3: case 23: return "rd"; default: return "th"; } }; var parseStandardFormats = function (format) { var y, c = Date.CultureInfo.formatPatterns; switch (format) { case "d": return this.toString(c.shortDate); case "D": return this.toString(c.longDate); case "F": return this.toString(c.fullDateTime); case "m": return this.toString(c.monthDay); case "r": case "R": y = this.clone().addMinutes(this.getTimezoneOffset()); return y.toString(c.rfc1123) + " GMT"; case "s": return this.toString(c.sortableDateTime); case "t": return this.toString(c.shortTime); case "T": return this.toString(c.longTime); case "u": y = this.clone().addMinutes(this.getTimezoneOffset()); return y.toString(c.universalSortableDateTime); case "y": return this.toString(c.yearMonth); default: return false; } }; var parseFormatStringsClosure = function (context) { return function (m) { if (m.charAt(0) === "\\") { return m.replace("\\", ""); } switch (m) { case "hh": return p(context.getHours() < 13 ? (context.getHours() === 0 ? 12 : context.getHours()) : (context.getHours() - 12)); case "h": return context.getHours() < 13 ? (context.getHours() === 0 ? 12 : context.getHours()) : (context.getHours() - 12); case "HH": return p(context.getHours()); case "H": return context.getHours(); case "mm": return p(context.getMinutes()); case "m": return context.getMinutes(); case "ss": return p(context.getSeconds()); case "s": return context.getSeconds(); case "yyyy": return p(context.getFullYear(), 4); case "yy": return p(context.getFullYear()); case "y": return context.getFullYear(); case "E": case "dddd": return Date.CultureInfo.dayNames[context.getDay()]; case "ddd": return Date.CultureInfo.abbreviatedDayNames[context.getDay()]; case "dd": return p(context.getDate()); case "d": return context.getDate(); case "MMMM": return Date.CultureInfo.monthNames[context.getMonth()]; case "MMM": return Date.CultureInfo.abbreviatedMonthNames[context.getMonth()]; case "MM": return p((context.getMonth() + 1)); case "M": return context.getMonth() + 1; case "t": return context.getHours() < 12 ? Date.CultureInfo.amDesignator.substring(0, 1) : Date.CultureInfo.pmDesignator.substring(0, 1); case "tt": return context.getHours() < 12 ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator; case "S": return ord(context.getDate()); case "W": return context.getWeek(); case "WW": return context.getISOWeek(); case "Q": return "Q" + context.getQuarter(); case "q": return String(context.getQuarter()); case "z": return context.getTimezone(); case "Z": case "X": return Date.getTimezoneOffset(context.getTimezone()); case "ZZ": // Timezone offset in seconds return context.getTimezoneOffset() * -60; case "u": return context.getDay(); case "L": return ($D.isLeapYear(context.getFullYear())) ? 1 : 0; case "B": // Swatch Internet Time (.beats) return "@"+((context.getUTCSeconds() + (context.getUTCMinutes()*60) + ((context.getUTCHours()+1)*3600))/86.4); default: return m; } }; }; $P.toString = function (format, ignoreStandards) { // Standard Date and Time Format Strings. Formats pulled from CultureInfo file and // may vary by culture. if (!ignoreStandards && format && format.length === 1) { output = parseStandardFormats.call(this, format); if (output) { return output; } } var parseFormatStrings = parseFormatStringsClosure(this); return format ? format.replace(/((\\)?(dd?d?d?|MM?M?M?|yy?y?y?|hh?|HH?|mm?|ss?|tt?|S|q|Q|WW?W?W?)(?![^\[]*\]))/g, parseFormatStrings).replace(/\[|\]/g, "") : this._toString(); }; }()); /************************************************************* * SugarPak - Domain Specific Language - Syntactical Sugar * *************************************************************/ (function () { var $D = Date, $P = $D.prototype, $N = Number.prototype; // private $P._orient = +1; // private $P._nth = null; // private $P._is = false; // private $P._same = false; // private $P._isSecond = false; // private $N._dateElement = "days"; /** * Moves the date to the next instance of a date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.today().next().friday();
	Date.today().next().fri();
	Date.today().next().march();
	Date.today().next().mar();
	Date.today().next().week();
	
* * @return {Date} date */ $P.next = function () { this._move = true; this._orient = +1; return this; }; /** * Creates a new Date (Date.today()) and moves the date to the next instance of the date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.next().friday();
	Date.next().fri();
	Date.next().march();
	Date.next().mar();
	Date.next().week();
	
* * @return {Date} date */ $D.next = function () { return $D.today().next(); }; /** * Moves the date to the previous instance of a date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.today().last().friday();
	Date.today().last().fri();
	Date.today().last().march();
	Date.today().last().mar();
	Date.today().last().week();
	
* * @return {Date} date */ $P.last = $P.prev = $P.previous = function () { this._move = true; this._orient = -1; return this; }; /** * Creates a new Date (Date.today()) and moves the date to the previous instance of the date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.last().friday();
	Date.last().fri();
	Date.previous().march();
	Date.prev().mar();
	Date.last().week();
	
* * @return {Date} date */ $D.last = $D.prev = $D.previous = function () { return $D.today().last(); }; /** * Performs a equality check when followed by either a month name, day name or .weekday() function. * Example

	Date.today().is().friday(); // true|false
	Date.today().is().fri();
	Date.today().is().march();
	Date.today().is().mar();
	
* * @return {Boolean} true|false */ $P.is = function () { this._is = true; return this; }; /** * Determines if two date objects occur on/in exactly the same instance of the subsequent date part function. * The function .same() must be followed by a date part function (example: .day(), .month(), .year(), etc). * * An optional Date can be passed in the date part function. If now date is passed as a parameter, 'Now' is used. * * The following example demonstrates how to determine if two dates fall on the exact same day. * * Example

	var d1 = Date.today(); // today at 00:00
	var d2 = new Date();   // exactly now.

	// Do they occur on the same day?
	d1.same().day(d2); // true
	
	// Do they occur on the same hour?
	d1.same().hour(d2); // false, unless d2 hour is '00' (midnight).
	
	// What if it's the same day, but one year apart?
	var nextYear = Date.today().add(1).year();

	d1.same().day(nextYear); // false, because the dates must occur on the exact same day. 
	
* * Scenario: Determine if a given date occurs during some week period 2 months from now. * * Example

	var future = Date.today().add(2).months();
	return someDate.same().week(future); // true|false;
	
* * @return {Boolean} true|false */ $P.same = function () { this._same = true; this._isSecond = false; return this; }; /** * Determines if the current date/time occurs during Today. Must be preceded by the .is() function. * Example

	someDate.is().today();    // true|false
	new Date().is().today();  // true
	Date.today().is().today();// true
	Date.today().add(-1).day().is().today(); // false
	
* * @return {Boolean} true|false */ $P.today = function () { return this.same().day(); }; /** * Determines if the current date is a weekday. This function must be preceded by the .is() function. * Example

	Date.today().is().weekday(); // true|false
	
* * @return {Boolean} true|false */ $P.weekday = function () { if (this._nth) { return df("Weekday").call(this); } if (this._move) { return this.addWeekdays(this._orient); } if (this._is) { this._is = false; return (!this.is().sat() && !this.is().sun()); } return false; }; /** * Determines if the current date is on the weekend. This function must be preceded by the .is() function. * Example

	Date.today().is().weekend(); // true|false
	
* * @return {Boolean} true|false */ $P.weekend = function () { if (this._is) { this._is = false; return (this.is().sat() || this.is().sun()); } return false; }; /** * Sets the Time of the current Date instance. A string "6:15 pm" or config object {hour:18, minute:15} are accepted. * Example

	// Set time to 6:15pm with a String
	Date.today().at("6:15pm");

	// Set time to 6:15pm with a config object
	Date.today().at({hour:18, minute:15});
	
* * @return {Date} date */ $P.at = function (time) { return (typeof time === "string") ? $D.parse(this.toString("d") + " " + time) : this.set(time); }; /** * Creates a new Date() and adds this (Number) to the date based on the preceding date element function (eg. second|minute|hour|day|month|year). * Example

	// Undeclared Numbers must be wrapped with parentheses. Requirment of JavaScript.
	(3).days().fromNow();
	(6).months().fromNow();

	// Declared Number variables do not require parentheses. 
	var n = 6;
	n.months().fromNow();
	
* * @return {Date} A new Date instance */ $N.fromNow = $N.after = function (date) { var c = {}; c[this._dateElement] = this; return ((!date) ? new Date() : date.clone()).add(c); }; /** * Creates a new Date() and subtract this (Number) from the date based on the preceding date element function (eg. second|minute|hour|day|month|year). * Example

	// Undeclared Numbers must be wrapped with parentheses. Requirment of JavaScript.
	(3).days().ago();
	(6).months().ago();

	// Declared Number variables do not require parentheses. 
	var n = 6;
	n.months().ago();
	
* * @return {Date} A new Date instance */ $N.ago = $N.before = function (date) { var c = {}, s = (this._dateElement[this._dateElement.length-1] !== "s") ? this._dateElement + "s" : this._dateElement; c[s] = this * -1; return ((!date) ? new Date() : date.clone()).add(c); }; // Do NOT modify the following string tokens. These tokens are used to build dynamic functions. // All culture-specific strings can be found in the CultureInfo files. var dx = ("sunday monday tuesday wednesday thursday friday saturday").split(/\s/), mx = ("january february march april may june july august september october november december").split(/\s/), px = ("Millisecond Second Minute Hour Day Week Month Year Quarter Weekday").split(/\s/), pxf = ("Milliseconds Seconds Minutes Hours Date Week Month FullYear Quarter").split(/\s/), nth = ("final first second third fourth fifth").split(/\s/), de; /** * Returns an object literal of all the date parts. * Example

	var o = new Date().toObject();
	
	// { year: 2008, month: 4, week: 20, day: 13, hour: 18, minute: 9, second: 32, millisecond: 812 }
	
	// The object properties can be referenced directly from the object.
	
	alert(o.day);  // alerts "13"
	alert(o.year); // alerts "2008"
	
* * @return {Date} An object literal representing the original date object. */ $P.toObject = function () { var o = {}; for (var i = 0; i < px.length; i++) { if (this["get" + pxf[i]]) { o[px[i].toLowerCase()] = this["get" + pxf[i]](); } } return o; }; /** * Returns a date created from an object literal. Ignores the .week property if set in the config. * Example

	var o = new Date().toObject();
	
	return Date.fromObject(o); // will return the same date. 

	var o2 = {month: 1, day: 20, hour: 18}; // birthday party!
	Date.fromObject(o2);
	
* * @return {Date} An object literal representing the original date object. */ $D.fromObject = function(config) { config.week = null; return Date.today().set(config); }; // Create day name functions and abbreviated day name functions (eg. monday(), friday(), fri()). var df = function (n) { return function () { if (this._is) { this._is = false; return this.getDay() === n; } if (this._move) { this._move = null; } if (this._nth !== null) { // If the .second() function was called earlier, remove the _orient // from the date, and then continue. // This is required because 'second' can be used in two different context. // // Example // // Date.today().add(1).second(); // Date.march().second().monday(); // // Things get crazy with the following... // Date.march().add(1).second().second().monday(); // but it works!! // if (this._isSecond) { this.addSeconds(this._orient * -1); } // make sure we reset _isSecond this._isSecond = false; var ntemp = this._nth; this._nth = null; var temp = this.clone().moveToLastDayOfMonth(); this.moveToNthOccurrence(n, ntemp); if (this > temp) { throw new RangeError($D.getDayName(n) + " does not occur " + ntemp + " times in the month of " + $D.getMonthName(temp.getMonth()) + " " + temp.getFullYear() + "."); } return this; } return this.moveToDayOfWeek(n, this._orient); }; }; var sdf = function (n) { return function () { var t = $D.today(), shift = n - t.getDay(); if (n === 0 && Date.CultureInfo.firstDayOfWeek === 1 && t.getDay() !== 0) { shift = shift + 7; } return t.addDays(shift); }; }; // Create month name functions and abbreviated month name functions (eg. january(), march(), mar()). var month_instance_functions = function (n) { return function () { if (this._is) { this._is = false; return this.getMonth() === n; } return this.moveToMonth(n, this._orient); }; }; var month_static_functions = function (n) { return function () { return $D.today().set({ month: n, day: 1 }); }; }; var processTerms = function (names, staticFunc, instanceFunc) { for (var i = 0; i < names.length; i++) { // Create constant static Name variables. $D[names[i].toUpperCase()] = $D[names[i].toUpperCase().substring(0, 3)] = i; // Create Name functions. $D[names[i]] = $D[names[i].substring(0, 3)] = staticFunc(i); // Create Name instance functions. $P[names[i]] = $P[names[i].substring(0, 3)] = instanceFunc(i); } }; processTerms(dx, sdf, df); processTerms(mx, month_static_functions, month_instance_functions); // Create date element functions and plural date element functions used with Date (eg. day(), days(), months()). var ef = function (j) { return function () { // if the .second() function was called earlier, the _orient // has alread been added. Just return this and reset _isSecond. if (this._isSecond) { this._isSecond = false; return this; } if (this._same) { this._same = this._is = false; var o1 = this.toObject(), o2 = (arguments[0] || new Date()).toObject(), v = "", k = j.toLowerCase(); // the substr trick with -1 doesn't work in IE8 or less k = (k[k.length-1] === "s") ? k.substring(0,k.length-1) : k; for (var m = (px.length - 1); m > -1; m--) { v = px[m].toLowerCase(); if (o1[v] !== o2[v]) { return false; } if (k === v) { break; } } return true; } if (j.substring(j.length - 1) !== "s") { j += "s"; } if (this._move) { this._move = null; } return this["add" + j](this._orient); }; }; var nf = function (n) { return function () { this._dateElement = n; return this; }; }; for (var k = 0; k < px.length; k++) { de = px[k].toLowerCase(); if(de !== "weekday") { // Create date element functions and plural date element functions used with Date (eg. day(), days(), months()). $P[de] = $P[de + "s"] = ef(px[k]); // Create date element functions and plural date element functions used with Number (eg. day(), days(), months()). $N[de] = $N[de + "s"] = nf(de + "s"); } } $P._ss = ef("Second"); var nthfn = function (n) { return function (dayOfWeek) { if (this._same) { return this._ss(arguments[0]); } if (dayOfWeek || dayOfWeek === 0) { return this.moveToNthOccurrence(dayOfWeek, n); } this._nth = n; // if the operator is 'second' add the _orient, then deal with it later... if (n === 2 && (dayOfWeek === undefined || dayOfWeek === null)) { this._isSecond = true; return this.addSeconds(this._orient); } return this; }; }; for (var l = 0; l < nth.length; l++) { $P[nth[l]] = (l === 0) ? nthfn(-1) : nthfn(l); } }()); (function () { "use strict"; Date.Parsing = { Exception: function (s) { this.message = "Parse error at '" + s.substring(0, 10) + " ...'"; } }; var $P = Date.Parsing; var dayOffsets = { standard: [0,31,59,90,120,151,181,212,243,273,304,334], leap: [0,31,60,91,121,152,182,213,244,274,305,335] }; $P.isLeapYear = function(year) { return ((year % 4 === 0) && (year % 100 !== 0)) || (year % 400 === 0); }; var utils = { multiReplace : function (str, hash ) { var key; for (key in hash) { if (Object.prototype.hasOwnProperty.call(hash, key)) { var regex; if (typeof hash[key] === "function") { } else { regex = (hash[key] instanceof RegExp) ? hash[key] : new RegExp(hash[key], "g"); } str = str.replace(regex, key); } } return str; }, getDayOfYearFromWeek : function (obj) { var d, jan4, offset; obj.weekDay = (!obj.weekDay && obj.weekDay !== 0) ? 1 : obj.weekDay; d = new Date(obj.year, 0, 4); jan4 = d.getDay() === 0 ? 7 : d.getDay(); // JS is 0 indexed on Sunday. offset = jan4+3; obj.dayOfYear = ((obj.week * 7) + (obj.weekDay === 0 ? 7 : obj.weekDay))-offset; return obj; }, getDayOfYear : function (obj, dayOffset) { if (!obj.dayOfYear) { obj = utils.getDayOfYearFromWeek(obj); } for (var i=0;i <= dayOffset.length;i++) { if (obj.dayOfYear < dayOffset[i] || i === dayOffset.length) { obj.day = obj.day ? obj.day : (obj.dayOfYear - dayOffset[i-1]); break; } else { obj.month = i; } } return obj; }, adjustForTimeZone : function (obj, date) { var offset; if (obj.zone.toUpperCase() === "Z" || (obj.zone_hours === 0 && obj.zone_minutes === 0)) { // it's UTC/GML so work out the current timeszone offset offset = -date.getTimezoneOffset(); } else { offset = (obj.zone_hours*60) + (obj.zone_minutes || 0); if (obj.zone_sign === "+") { offset *= -1; } offset -= date.getTimezoneOffset(); } date.setMinutes(date.getMinutes()+offset); return date; }, setDefaults : function (obj) { obj.year = obj.year || Date.today().getFullYear(); obj.hours = obj.hours || 0; obj.minutes = obj.minutes || 0; obj.seconds = obj.seconds || 0; obj.milliseconds = obj.milliseconds || 0; if (!(!obj.month && (obj.week || obj.dayOfYear))) { // if we have a month, or if we don't but don't have the day calculation data obj.month = obj.month || 0; obj.day = obj.day || 1; } return obj; }, dataNum: function (data, mod, explict, postProcess) { var dataNum = data*1; if (mod) { if (postProcess) { return data ? mod(data)*1 : data; } else { return data ? mod(dataNum) : data; } } else if (!explict){ return data ? dataNum : data; } else { return (data && typeof data !== "undefined") ? dataNum : data; } }, timeDataProcess: function (obj) { var timeObj = {}; for (var x in obj.data) { if (obj.data.hasOwnProperty(x)) { timeObj[x] = obj.ignore[x] ? obj.data[x] : utils.dataNum(obj.data[x], obj.mods[x], obj.explict[x], obj.postProcess[x]); } } if (obj.data.secmins) { obj.data.secmins = obj.data.secmins.replace(",", ".") * 60; if (!timeObj.minutes) { timeObj.minutes = obj.data.secmins; } else if (!timeObj.seconds) { timeObj.seconds = obj.data.secmins; } delete obj.secmins; } return timeObj; }, buildTimeObjectFromData: function (data) { var time = utils.timeDataProcess({ data: { year : data[1], month : data[5], day : data[7], week : data[8], dayOfYear : data[10], hours : data[15], zone_hours : data[23], zone_minutes : data[24], zone : data[21], zone_sign : data[22], weekDay : data[9], minutes: data[16], seconds: data[19], milliseconds: data[20], secmins: data[18] }, mods: { month: function(data) { return data-1; }, weekDay: function (data) { data = Math.abs(data); return (data === 7 ? 0 : data); }, minutes: function (data) { return data.replace(":",""); }, seconds: function (data) { return Math.floor( (data.replace(":","").replace(",","."))*1 ); }, milliseconds: function (data) { return (data.replace(",",".")*1000); } }, postProcess: { minutes: true, seconds: true, milliseconds: true }, explict: { zone_hours: true, zone_minutes: true }, ignore: { zone: true, zone_sign: true, secmins: true } }); return time; }, addToHash: function (hash, keys, data) { keys = keys; data = data; var len = keys.length; for (var i = 0; i < len; i++) { hash[keys[i]] = data[i]; } return hash; }, combineRegex: function (r1, r2) { return new RegExp("(("+r1.source+")\\s("+r2.source+"))"); }, getDateNthString: function(add, last, inc){ if (add) { return Date.today().addDays(inc).toString("d"); } else if (last) { return Date.today().last()[inc]().toString("d"); } }, buildRegexData: function (array) { var arr = []; var len = array.length; for (var i=0; i < len; i++) { if (Object.prototype.toString.call(array[i]) === '[object Array]') { // oldIE compat version of Array.isArray arr.push(this.combineRegex(array[i][0], array[i][1])); } else { arr.push(array[i]); } } return arr; } }; $P.processTimeObject = function (obj) { var date, dayOffset; utils.setDefaults(obj); dayOffset = ($P.isLeapYear(obj.year)) ? dayOffsets.leap : dayOffsets.standard; if (!obj.month && (obj.week || obj.dayOfYear)) { utils.getDayOfYear(obj, dayOffset); } else { obj.dayOfYear = dayOffset[obj.month] + obj.day; } date = new Date(obj.year, obj.month, obj.day, obj.hours, obj.minutes, obj.seconds, obj.milliseconds); if (obj.zone) { utils.adjustForTimeZone(obj, date); // adjust (and calculate) for timezone } return date; }; $P.ISO = { regex : /^([\+-]?\d{4}(?!\d{2}\b))((-?)((0[1-9]|1[0-2])(\3([12]\d|0[1-9]|3[01]))?|W([0-4]\d|5[0-3])(-?[1-7])?|(00[1-9]|0[1-9]\d|[12]\d{2}|3([0-5]\d|6[1-6])))([T\s]((([01]\d|2[0-4])((:?)[0-5]\d)?|24\:?00)([\.,]\d+(?!:))?)?(\17[0-5]\d([\.,]\d+)?)?\s?([zZ]|([\+-])([01]\d|2[0-3]):?([0-5]\d)?)?)?)?$/, parse : function (s) { var time, data = s.match(this.regex); if (!data || !data.length) { return null; } time = utils.buildTimeObjectFromData(data); if (!time.year || (!time.year && (!time.month && !time.day) && (!time.week && !time.dayOfYear)) ) { return null; } return $P.processTimeObject(time); } }; $P.Numeric = { isNumeric: function (e){return!isNaN(parseFloat(e))&&isFinite(e);}, regex: /\b([0-1]?[0-9])([0-3]?[0-9])([0-2]?[0-9]?[0-9][0-9])\b/i, parse: function (s) { var data, i, time = {}, order = Date.CultureInfo.dateElementOrder.split(""); if (!(this.isNumeric(s)) || // if it's non-numeric OR (s[0] === "+" && s[0] === "-")) { // It's an arithmatic string (eg +/-1000) return null; } if (s.length < 5 && s.indexOf(".") < 0 && s.indexOf("/") < 0) { // assume it's just a year. time.year = s; return $P.processTimeObject(time); } data = s.match(this.regex); if (!data || !data.length) { return null; } for (i=0; i < order.length; i++) { switch(order[i]) { case "d": time.day = data[i+1]; break; case "m": time.month = (data[i+1]-1); break; case "y": time.year = data[i+1]; break; } } return $P.processTimeObject(time); } }; $P.Normalizer = { regexData: function () { var $R = Date.CultureInfo.regexPatterns; return utils.buildRegexData([ $R.tomorrow, $R.yesterday, [$R.past, $R.mon], [$R.past, $R.tue], [$R.past, $R.wed], [$R.past, $R.thu], [$R.past, $R.fri], [$R.past, $R.sat], [$R.past, $R.sun] ]); }, basicReplaceHash : function() { var $R = Date.CultureInfo.regexPatterns; return { "January": $R.jan.source, "February": $R.feb, "March": $R.mar, "April": $R.apr, "May": $R.may, "June": $R.jun, "July": $R.jul, "August": $R.aug, "September": $R.sep, "October": $R.oct, "November": $R.nov, "December": $R.dec, "": /\bat\b/gi, " ": /\s{2,}/, "am": $R.inTheMorning, "9am": $R.thisMorning, "pm": $R.inTheEvening, "7pm":$R.thisEvening }; }, keys : function(){ return [ utils.getDateNthString(true, false, 1), // tomorrow utils.getDateNthString(true, false, -1), // yesterday utils.getDateNthString(false, true, "monday"), //last mon utils.getDateNthString(false, true, "tuesday"), //last tues utils.getDateNthString(false, true, "wednesday"), //last wed utils.getDateNthString(false, true, "thursday"), //last thurs utils.getDateNthString(false, true, "friday"), //last fri utils.getDateNthString(false, true, "saturday"), //last sat utils.getDateNthString(false, true, "sunday") //last sun ]; }, buildRegexFunctions: function () { var $R = Date.CultureInfo.regexPatterns; var __ = Date.i18n.__; var tomorrowRE = new RegExp("(\\b\\d\\d?("+__("AM")+"|"+__("PM")+")? )("+$R.tomorrow.source.slice(1)+")", "i"); // adapted tomorrow regex for AM PM relative dates var todayRE = new RegExp($R.today.source + "(?!\\s*([+-]))\\b"); // today, but excludes the math operators (eg "today + 2h") this.replaceFuncs = [ [todayRE, function (full) { return (full.length > 1) ? Date.today().toString("d") : full; }], [tomorrowRE, function(full, m1) { var t = Date.today().addDays(1).toString("d"); return (t + " " + m1); }], [$R.amThisMorning, function(str, am){return am;}], [$R.pmThisEvening, function(str, pm){return pm;}] ]; }, buildReplaceData: function () { this.buildRegexFunctions(); this.replaceHash = utils.addToHash(this.basicReplaceHash(), this.keys(), this.regexData()); }, stringReplaceFuncs: function (s) { for (var i=0; i < this.replaceFuncs.length; i++) { s = s.replace(this.replaceFuncs[i][0], this.replaceFuncs[i][1]); } return s; }, parse: function (s) { s = this.stringReplaceFuncs(s); s = utils.multiReplace(s, this.replaceHash); try { var n = s.split(/([\s\-\.\,\/\x27]+)/); if (n.length === 3 && $P.Numeric.isNumeric(n[0]) && $P.Numeric.isNumeric(n[2]) && (n[2].length >= 4)) { // ok, so we're dealing with x/year. But that's not a full date. // This fixes wonky dateElementOrder parsing when set to dmy order. if (Date.CultureInfo.dateElementOrder[0] === "d") { s = "1/" + n[0] + "/" + n[2]; // set to 1st of month and normalize the seperator } } } catch (e) {} return s; } }; $P.Normalizer.buildReplaceData(); }()); (function () { var $P = Date.Parsing; var _ = $P.Operators = { // // Tokenizers // rtoken: function (r) { // regex token return function (s) { var mx = s.match(r); if (mx) { return ([ mx[0], s.substring(mx[0].length) ]); } else { throw new $P.Exception(s); } }; }, token: function () { // whitespace-eating token return function (s) { return _.rtoken(new RegExp("^\\s*" + s + "\\s*"))(s); }; }, stoken: function (s) { // string token return _.rtoken(new RegExp("^" + s)); }, // Atomic Operators until: function (p) { return function (s) { var qx = [], rx = null; while (s.length) { try { rx = p.call(this, s); } catch (e) { qx.push(rx[0]); s = rx[1]; continue; } break; } return [ qx, s ]; }; }, many: function (p) { return function (s) { var rx = [], r = null; while (s.length) { try { r = p.call(this, s); } catch (e) { return [ rx, s ]; } rx.push(r[0]); s = r[1]; } return [ rx, s ]; }; }, // generator operators -- see below optional: function (p) { return function (s) { var r = null; try { r = p.call(this, s); } catch (e) { return [ null, s ]; } return [ r[0], r[1] ]; }; }, not: function (p) { return function (s) { try { p.call(this, s); } catch (e) { return [null, s]; } throw new $P.Exception(s); }; }, ignore: function (p) { return p ? function (s) { var r = null; r = p.call(this, s); return [null, r[1]]; } : null; }, product: function () { var px = arguments[0], qx = Array.prototype.slice.call(arguments, 1), rx = []; for (var i = 0 ; i < px.length ; i++) { rx.push(_.each(px[i], qx)); } return rx; }, cache: function (rule) { var cache = {}, cache_length = 0, cache_keys = [], CACHE_MAX = Date.Config.CACHE_MAX || 100000, r = null; var cacheCheck = function () { if (cache_length === CACHE_MAX) { // kill several keys, don't want to have to do this all the time... for (var i=0; i < 10; i++) { var key = cache_keys.shift(); if (key) { delete cache[key]; cache_length--; } } } }; return function (s) { cacheCheck(); try { r = cache[s] = (cache[s] || rule.call(this, s)); } catch (e) { r = cache[s] = e; } cache_length++; cache_keys.push(s); if (r instanceof $P.Exception) { throw r; } else { return r; } }; }, // vector operators -- see below any: function () { var px = arguments; return function (s) { var r = null; for (var i = 0; i < px.length; i++) { if (px[i] == null) { continue; } try { r = (px[i].call(this, s)); } catch (e) { r = null; } if (r) { return r; } } throw new $P.Exception(s); }; }, each: function () { var px = arguments; return function (s) { var rx = [], r = null; for (var i = 0; i < px.length ; i++) { if (px[i] == null) { continue; } try { r = (px[i].call(this, s)); } catch (e) { throw new $P.Exception(s); } rx.push(r[0]); s = r[1]; } return [ rx, s]; }; }, all: function () { var px = arguments, _ = _; return _.each(_.optional(px)); }, // delimited operators sequence: function (px, d, c) { d = d || _.rtoken(/^\s*/); c = c || null; if (px.length === 1) { return px[0]; } return function (s) { var r = null, q = null; var rx = []; for (var i = 0; i < px.length ; i++) { try { r = px[i].call(this, s); } catch (e) { break; } rx.push(r[0]); try { q = d.call(this, r[1]); } catch (ex) { q = null; break; } s = q[1]; } if (!r) { throw new $P.Exception(s); } if (q) { throw new $P.Exception(q[1]); } if (c) { try { r = c.call(this, r[1]); } catch (ey) { throw new $P.Exception(r[1]); } } return [ rx, (r?r[1]:s) ]; }; }, // // Composite Operators // between: function (d1, p, d2) { d2 = d2 || d1; var _fn = _.each(_.ignore(d1), p, _.ignore(d2)); return function (s) { var rx = _fn.call(this, s); return [[rx[0][0], r[0][2]], rx[1]]; }; }, list: function (p, d, c) { d = d || _.rtoken(/^\s*/); c = c || null; return (p instanceof Array ? _.each(_.product(p.slice(0, -1), _.ignore(d)), p.slice(-1), _.ignore(c)) : _.each(_.many(_.each(p, _.ignore(d))), px, _.ignore(c))); }, set: function (px, d, c) { d = d || _.rtoken(/^\s*/); c = c || null; return function (s) { // r is the current match, best the current 'best' match // which means it parsed the most amount of input var r = null, p = null, q = null, rx = null, best = [[], s], last = false; // go through the rules in the given set for (var i = 0; i < px.length ; i++) { // last is a flag indicating whether this must be the last element // if there is only 1 element, then it MUST be the last one q = null; p = null; r = null; last = (px.length === 1); // first, we try simply to match the current pattern // if not, try the next pattern try { r = px[i].call(this, s); } catch (e) { continue; } // since we are matching against a set of elements, the first // thing to do is to add r[0] to matched elements rx = [[r[0]], r[1]]; // if we matched and there is still input to parse and // we don't already know this is the last element, // we're going to next check for the delimiter ... // if there's none, or if there's no input left to parse // than this must be the last element after all ... if (r[1].length > 0 && ! last) { try { q = d.call(this, r[1]); } catch (ex) { last = true; } } else { last = true; } // if we parsed the delimiter and now there's no more input, // that means we shouldn't have parsed the delimiter at all // so don't update r and mark this as the last element ... if (!last && q[1].length === 0) { last = true; } // so, if this isn't the last element, we're going to see if // we can get any more matches from the remaining (unmatched) // elements ... if (!last) { // build a list of the remaining rules we can match against, // i.e., all but the one we just matched against var qx = []; for (var j = 0; j < px.length ; j++) { if (i !== j) { qx.push(px[j]); } } // now invoke recursively set with the remaining input // note that we don't include the closing delimiter ... // we'll check for that ourselves at the end p = _.set(qx, d).call(this, q[1]); // if we got a non-empty set as a result ... // (otw rx already contains everything we want to match) if (p[0].length > 0) { // update current result, which is stored in rx ... // basically, pick up the remaining text from p[1] // and concat the result from p[0] so that we don't // get endless nesting ... rx[0] = rx[0].concat(p[0]); rx[1] = p[1]; } } // at this point, rx either contains the last matched element // or the entire matched set that starts with this element. // now we just check to see if this variation is better than // our best so far, in terms of how much of the input is parsed if (rx[1].length < best[1].length) { best = rx; } // if we've parsed all the input, then we're finished if (best[1].length === 0) { break; } } // so now we've either gone through all the patterns trying them // as the initial match; or we found one that parsed the entire // input string ... // if best has no matches, just return empty set ... if (best[0].length === 0) { return best; } // if a closing delimiter is provided, then we have to check it also if (c) { // we try this even if there is no remaining input because the pattern // may well be optional or match empty input ... try { q = c.call(this, best[1]); } catch (ey) { throw new $P.Exception(best[1]); } // it parsed ... be sure to update the best match remaining input best[1] = q[1]; } // if we're here, either there was no closing delimiter or we parsed it // so now we have the best match; just return it! return best; }; }, forward: function (gr, fname) { return function (s) { return gr[fname].call(this, s); }; }, // // Translation Operators // replace: function (rule, repl) { return function (s) { var r = rule.call(this, s); return [repl, r[1]]; }; }, process: function (rule, fn) { return function (s) { var r = rule.call(this, s); return [fn.call(this, r[0]), r[1]]; }; }, min: function (min, rule) { return function (s) { var rx = rule.call(this, s); if (rx[0].length < min) { throw new $P.Exception(s); } return rx; }; } }; // Generator Operators And Vector Operators // Generators are operators that have a signature of F(R) => R, // taking a given rule and returning another rule, such as // ignore, which parses a given rule and throws away the result. // Vector operators are those that have a signature of F(R1,R2,...) => R, // take a list of rules and returning a new rule, such as each. // Generator operators are converted (via the following _generator // function) into functions that can also take a list or array of rules // and return an array of new rules as though the function had been // called on each rule in turn (which is what actually happens). // This allows generators to be used with vector operators more easily. // Example: // each(ignore(foo, bar)) instead of each(ignore(foo), ignore(bar)) // This also turns generators into vector operators, which allows // constructs like: // not(cache(foo, bar)) var _generator = function (op) { function gen() { var args = null, rx = [], px, i; if (arguments.length > 1) { args = Array.prototype.slice.call(arguments); } else if (arguments[0] instanceof Array) { args = arguments[0]; } if (args) { px = args.shift(); if (px.length > 0) { args.unshift(px[i]); rx.push(op.apply(null, args)); args.shift(); return rx; } } else { return op.apply(null, arguments); } } return gen; }; var gx = "optional not ignore cache".split(/\s/); for (var i = 0 ; i < gx.length ; i++) { _[gx[i]] = _generator(_[gx[i]]); } var _vector = function (op) { return function () { if (arguments[0] instanceof Array) { return op.apply(null, arguments[0]); } else { return op.apply(null, arguments); } }; }; var vx = "each any all".split(/\s/); for (var j = 0 ; j < vx.length ; j++) { _[vx[j]] = _vector(_[vx[j]]); } }()); (function () { var $D = Date; var flattenAndCompact = function (ax) { var rx = []; for (var i = 0; i < ax.length; i++) { if (ax[i] instanceof Array) { rx = rx.concat(flattenAndCompact(ax[i])); } else { if (ax[i]) { rx.push(ax[i]); } } } return rx; }; var parseMeridian = function () { if (this.meridian && (this.hour || this.hour === 0)) { if (this.meridian === "a" && this.hour > 11 && Date.Config.strict24hr){ throw "Invalid hour and meridian combination"; } else if (this.meridian === "p" && this.hour < 12 && Date.Config.strict24hr){ throw "Invalid hour and meridian combination"; } else if (this.meridian === "p" && this.hour < 12) { this.hour = this.hour + 12; } else if (this.meridian === "a" && this.hour === 12) { this.hour = 0; } } }; var setDefaults = function () { var now = new Date(); if ((this.hour || this.minute) && (!this.month && !this.year && !this.day)) { this.day = now.getDate(); } if (!this.year) { this.year = now.getFullYear(); } if (!this.month && this.month !== 0) { this.month = now.getMonth(); } if (!this.day) { this.day = 1; } if (!this.hour) { this.hour = 0; } if (!this.minute) { this.minute = 0; } if (!this.second) { this.second = 0; } if (!this.millisecond) { this.millisecond = 0; } }; var finishUtils = { getToday: function () { if (this.now || "hour minute second".indexOf(this.unit) !== -1) { return new Date(); } else { return $D.today(); } }, setDaysFromWeekday: function (today, orient){ var gap; orient = orient || 1; this.unit = "day"; gap = ($D.getDayNumberFromName(this.weekday) - today.getDay()); this.days = gap ? ((gap + (orient * 7)) % 7) : (orient * 7); return this; }, setMonthsFromMonth: function (today, orient) { var gap; orient = orient || 1; this.unit = "month"; gap = (this.month - today.getMonth()); this.months = gap ? ((gap + (orient * 12)) % 12) : (orient * 12); this.month = null; return this; }, setDMYFromWeekday: function () { var d = Date[this.weekday](); this.day = d.getDate(); if (!this.month) { this.month = d.getMonth(); } this.year = d.getFullYear(); return this; }, setUnitValue: function (orient) { if (!this.value && this.operator && this.operator !== null && this[this.unit + "s"] && this[this.unit + "s"] !== null) { this[this.unit + "s"] = this[this.unit + "s"] + ((this.operator === "add") ? 1 : -1) + (this.value||0) * orient; } else if (this[this.unit + "s"] == null || this.operator != null) { if (!this.value) { this.value = 1; } this[this.unit + "s"] = this.value * orient; } }, generateDateFromWeeks: function () { var weekday = (this.weekday !== undefined) ? this.weekday : "today"; var d = Date[weekday]().addWeeks(this.weeks); if (this.now) { d.setTimeToNow(); } return d; } }; $D.Translator = { hour: function (s) { return function () { this.hour = Number(s); }; }, minute: function (s) { return function () { this.minute = Number(s); }; }, second: function (s) { return function () { this.second = Number(s); }; }, /* for ss.s format */ secondAndMillisecond: function (s) { return function () { var mx = s.match(/^([0-5][0-9])\.([0-9]{1,3})/); this.second = Number(mx[1]); this.millisecond = Number(mx[2]); }; }, meridian: function (s) { return function () { this.meridian = s.slice(0, 1).toLowerCase(); }; }, timezone: function (s) { return function () { var n = s.replace(/[^\d\+\-]/g, ""); if (n.length) { this.timezoneOffset = Number(n); } else { this.timezone = s.toLowerCase(); } }; }, day: function (x) { var s = x[0]; return function () { this.day = Number(s.match(/\d+/)[0]); if (this.day < 1) { throw "invalid day"; } }; }, month: function (s) { return function () { this.month = (s.length === 3) ? "jan feb mar apr may jun jul aug sep oct nov dec".indexOf(s)/4 : Number(s) - 1; if (this.month < 0) { throw "invalid month"; } }; }, year: function (s) { return function () { var n = Number(s); this.year = ((s.length > 2) ? n : (n + (((n + 2000) < Date.CultureInfo.twoDigitYearMax) ? 2000 : 1900))); }; }, rday: function (s) { return function () { switch (s) { case "yesterday": this.days = -1; break; case "tomorrow": this.days = 1; break; case "today": this.days = 0; break; case "now": this.days = 0; this.now = true; break; } }; }, finishExact: function (x) { var d; x = (x instanceof Array) ? x : [x]; for (var i = 0 ; i < x.length ; i++) { if (x[i]) { x[i].call(this); } } setDefaults.call(this); parseMeridian.call(this); if (this.day > $D.getDaysInMonth(this.year, this.month)) { throw new RangeError(this.day + " is not a valid value for days."); } d = new Date(this.year, this.month, this.day, this.hour, this.minute, this.second, this.millisecond); if (this.year < 100) { d.setFullYear(this.year); // means years less that 100 are process correctly. JS will parse it otherwise as 1900-1999. } if (this.timezone) { d.set({ timezone: this.timezone }); } else if (this.timezoneOffset) { d.set({ timezoneOffset: this.timezoneOffset }); } return d; }, finish: function (x) { var today, expression, orient, temp; x = (x instanceof Array) ? flattenAndCompact(x) : [ x ]; if (x.length === 0) { return null; } for (var i = 0 ; i < x.length ; i++) { if (typeof x[i] === "function") { x[i].call(this); } } if (this.now && !this.unit && !this.operator) { return new Date(); } else { today = finishUtils.getToday.call(this); } expression = !!(this.days && this.days !== null || this.orient || this.operator); orient = ((this.orient === "past" || this.operator === "subtract") ? -1 : 1); if (this.month && this.unit === "week") { this.value = this.month + 1; delete this.month; delete this.day; } if ((this.month || this.month === 0) && "year day hour minute second".indexOf(this.unit) !== -1) { if (!this.value) { this.value = this.month + 1; } this.month = null; expression = true; } if (!expression && this.weekday && !this.day && !this.days) { finishUtils.setDMYFromWeekday.call(this); } if (expression && this.weekday && this.unit !== "month" && this.unit !== "week") { finishUtils.setDaysFromWeekday.call(this, today, orient); } if (this.weekday && this.unit !== "week" && !this.day && !this.days) { temp = Date[this.weekday](); this.day = temp.getDate(); if (temp.getMonth() !== today.getMonth()) { this.month = temp.getMonth(); } } if (this.month && this.unit === "day" && this.operator) { if (!this.value) { this.value = (this.month + 1); } this.month = null; } if (this.value != null && this.month != null && this.year != null) { this.day = this.value * 1; } if (this.month && !this.day && this.value) { today.set({ day: this.value * 1 }); if (!expression) { this.day = this.value * 1; } } if (!this.month && this.value && this.unit === "month" && !this.now) { this.month = this.value; expression = true; } if (expression && (this.month || this.month === 0) && this.unit !== "year") { finishUtils.setMonthsFromMonth.call(this, today, orient); } if (!this.unit) { this.unit = "day"; } finishUtils.setUnitValue.call(this, orient); parseMeridian.call(this); if ((this.month || this.month === 0) && !this.day) { this.day = 1; } if (!this.orient && !this.operator && this.unit === "week" && this.value && !this.day && !this.month) { return Date.today().setWeek(this.value); } if (this.unit === "week" && this.weeks && !this.day && !this.month) { return finishUtils.generateDateFromWeeks.call(this); } if (expression && this.timezone && this.day && this.days) { this.day = this.days; } if (expression){ today.add(this); } else { today.set(this); } if (this.timezone) { this.timezone = this.timezone.toUpperCase(); var offset = $D.getTimezoneOffset(this.timezone); var timezone; if (today.hasDaylightSavingTime()) { // lets check that we're being sane with timezone setting timezone = $D.getTimezoneAbbreviation(offset, today.isDaylightSavingTime()); if (timezone !== this.timezone) { // bugger, we're in a place where things like EST vs EDT matters. if (today.isDaylightSavingTime()) { today.addHours(-1); } else { today.addHours(1); } } } today.setTimezoneOffset(offset); } return today; } }; }()); (function () { var $D = Date; $D.Grammar = {}; var _ = $D.Parsing.Operators, g = $D.Grammar, t = $D.Translator, _fn; // Allow rolling up into general purpose rules _fn = function () { return _.each(_.any.apply(null, arguments), _.not(g.ctoken2("timeContext"))); }; g.datePartDelimiter = _.rtoken(/^([\s\-\.\,\/\x27]+)/); g.timePartDelimiter = _.stoken(":"); g.whiteSpace = _.rtoken(/^\s*/); g.generalDelimiter = _.rtoken(/^(([\s\,]|at|@|on)+)/); var _C = {}; g.ctoken = function (keys) { var fn = _C[keys]; if (! fn) { var c = Date.CultureInfo.regexPatterns; var kx = keys.split(/\s+/), px = []; for (var i = 0; i < kx.length ; i++) { px.push(_.replace(_.rtoken(c[kx[i]]), kx[i])); } fn = _C[keys] = _.any.apply(null, px); } return fn; }; g.ctoken2 = function (key) { return _.rtoken(Date.CultureInfo.regexPatterns[key]); }; var cacheProcessRtoken = function (key, token, type, eachToken) { if (eachToken) { g[key] = _.cache(_.process(_.each(_.rtoken(token),_.optional(g.ctoken2(eachToken))), type)); } else { g[key] = _.cache(_.process(_.rtoken(token), type)); } }; var cacheProcessCtoken = function (token, type) { return _.cache(_.process(g.ctoken2(token), type)); }; var _F = {}; //function cache var _get = function (f) { _F[f] = (_F[f] || g.format(f)[0]); return _F[f]; }; g.allformats = function (fx) { var rx = []; if (fx instanceof Array) { for (var i = 0; i < fx.length; i++) { rx.push(_get(fx[i])); } } else { rx.push(_get(fx)); } return rx; }; g.formats = function (fx) { if (fx instanceof Array) { var rx = []; for (var i = 0 ; i < fx.length ; i++) { rx.push(_get(fx[i])); } return _.any.apply(null, rx); } else { return _get(fx); } }; var grammarFormats = { timeFormats: function(){ var i, RTokenKeys = [ "h", "hh", "H", "HH", "m", "mm", "s", "ss", "ss.s", "z", "zz" ], RToken = [ /^(0[0-9]|1[0-2]|[1-9])/, /^(0[0-9]|1[0-2])/, /^([0-1][0-9]|2[0-3]|[0-9])/, /^([0-1][0-9]|2[0-3])/, /^([0-5][0-9]|[0-9])/, /^[0-5][0-9]/, /^([0-5][0-9]|[0-9])/, /^[0-5][0-9]/, /^[0-5][0-9]\.[0-9]{1,3}/, /^((\+|\-)\s*\d\d\d\d)|((\+|\-)\d\d\:?\d\d)/, /^((\+|\-)\s*\d\d\d\d)|((\+|\-)\d\d\:?\d\d)/ ], tokens = [ t.hour, t.hour, t.hour, t.hour, t.minute, t.minute, t.second, t.second, t.secondAndMillisecond, t.timezone, t.timezone ]; for (i=0; i < RTokenKeys.length; i++) { cacheProcessRtoken(RTokenKeys[i], RToken[i], tokens[i]); } g.hms = _.cache(_.sequence([g.H, g.m, g.s], g.timePartDelimiter)); g.t = cacheProcessCtoken("shortMeridian", t.meridian); g.tt = cacheProcessCtoken("longMeridian", t.meridian); g.zzz = cacheProcessCtoken("timezone", t.timezone); g.timeSuffix = _.each(_.ignore(g.whiteSpace), _.set([ g.tt, g.zzz ])); g.time = _.each(_.optional(_.ignore(_.stoken("T"))), g.hms, g.timeSuffix); }, dateFormats: function () { // pre-loaded rules for different date part order preferences var _setfn = function () { return _.set(arguments, g.datePartDelimiter); }; var i, RTokenKeys = [ "d", "dd", "M", "MM", "y", "yy", "yyy", "yyyy" ], RToken = [ /^([0-2]\d|3[0-1]|\d)/, /^([0-2]\d|3[0-1])/, /^(1[0-2]|0\d|\d)/, /^(1[0-2]|0\d)/, /^(\d+)/, /^(\d\d)/, /^(\d\d?\d?\d?)/, /^(\d\d\d\d)/ ], tokens = [ t.day, t.day, t.month, t.month, t.year, t.year, t.year, t.year ], eachToken = [ "ordinalSuffix", "ordinalSuffix" ]; for (i=0; i < RTokenKeys.length; i++) { cacheProcessRtoken(RTokenKeys[i], RToken[i], tokens[i], eachToken[i]); } g.MMM = g.MMMM = _.cache(_.process(g.ctoken("jan feb mar apr may jun jul aug sep oct nov dec"), t.month)); g.ddd = g.dddd = _.cache(_.process(g.ctoken("sun mon tue wed thu fri sat"), function (s) { return function () { this.weekday = s; }; } )); g.day = _fn(g.d, g.dd); g.month = _fn(g.M, g.MMM); g.year = _fn(g.yyyy, g.yy); g.mdy = _setfn(g.ddd, g.month, g.day, g.year); g.ymd = _setfn(g.ddd, g.year, g.month, g.day); g.dmy = _setfn(g.ddd, g.day, g.month, g.year); g.date = function (s) { return ((g[Date.CultureInfo.dateElementOrder] || g.mdy).call(this, s)); }; }, relative: function () { // relative date / time expressions g.orientation = _.process(g.ctoken("past future"), function (s) { return function () { this.orient = s; }; } ); g.operator = _.process(g.ctoken("add subtract"), function (s) { return function () { this.operator = s; }; } ); g.rday = _.process(g.ctoken("yesterday tomorrow today now"), t.rday); g.unit = _.process(g.ctoken("second minute hour day week month year"), function (s) { return function () { this.unit = s; }; } ); } }; g.buildGrammarFormats = function () { // these need to be rebuilt every time the language changes. _C = {}; grammarFormats.timeFormats(); grammarFormats.dateFormats(); grammarFormats.relative(); g.value = _.process(_.rtoken(/^([-+]?\d+)?(st|nd|rd|th)?/), function (s) { return function () { this.value = s.replace(/\D/g, ""); }; } ); g.expression = _.set([g.rday, g.operator, g.value, g.unit, g.orientation, g.ddd, g.MMM ]); g.format = _.process(_.many( _.any( // translate format specifiers into grammar rules _.process( _.rtoken(/^(dd?d?d?(?!e)|MM?M?M?|yy?y?y?|hh?|HH?|mm?|ss?|tt?|zz?z?)/), function (fmt) { if (g[fmt]) { return g[fmt]; } else { throw $D.Parsing.Exception(fmt); } } ), // translate separator tokens into token rules _.process(_.rtoken(/^[^dMyhHmstz]+/), // all legal separators function (s) { return _.ignore(_.stoken(s)); } ) ) ), // construct the parser ... function (rules) { return _.process(_.each.apply(null, rules), t.finishExact); } ); // starting rule for general purpose grammar g._start = _.process(_.set([ g.date, g.time, g.expression ], g.generalDelimiter, g.whiteSpace), t.finish); }; g.buildGrammarFormats(); // parsing date format specifiers - ex: "h:m:s tt" // this little guy will generate a custom parser based // on the format string, ex: g.format("h:m:s tt") // check for these formats first g._formats = g.formats([ "\"yyyy-MM-ddTHH:mm:ssZ\"", "yyyy-MM-ddTHH:mm:ss.sz", "yyyy-MM-ddTHH:mm:ssZ", "yyyy-MM-ddTHH:mm:ssz", "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-ddTHH:mmZ", "yyyy-MM-ddTHH:mmz", "yyyy-MM-ddTHH:mm", "ddd, MMM dd, yyyy H:mm:ss tt", "ddd MMM d yyyy HH:mm:ss zzz", "MMddyyyy", "ddMMyyyy", "Mddyyyy", "ddMyyyy", "Mdyyyy", "dMyyyy", "yyyy", "Mdyy", "dMyy", "d" ]); // real starting rule: tries selected formats first, // then general purpose rule g.start = function (s) { try { var r = g._formats.call({}, s); if (r[1].length === 0) { return r; } } catch (e) {} return g._start.call({}, s); }; }()); (function () { var $D = Date; /** * @desc Converts the specified string value into its JavaScript Date equivalent using CultureInfo specific format information. * * Example

	///////////
	// Dates //
	///////////

	// 15-Oct-2004
	var d1 = Date.parse("10/15/2004");

	// 15-Oct-2004
	var d1 = Date.parse("15-Oct-2004");

	// 15-Oct-2004
	var d1 = Date.parse("2004.10.15");

	//Fri Oct 15, 2004
	var d1 = Date.parse("Fri Oct 15, 2004");

	///////////
	// Times //
	///////////

	// Today at 10 PM.
	var d1 = Date.parse("10 PM");

	// Today at 10:30 PM.
	var d1 = Date.parse("10:30 P.M.");

	// Today at 6 AM.
	var d1 = Date.parse("06am");

	/////////////////////
	// Dates and Times //
	/////////////////////

	// 8-July-2004 @ 10:30 PM
	var d1 = Date.parse("July 8th, 2004, 10:30 PM");

	// 1-July-2004 @ 10:30 PM
	var d1 = Date.parse("2004-07-01T22:30:00");

	////////////////////
	// Relative Dates //
	////////////////////

	// Returns today's date. The string "today" is culture specific.
	var d1 = Date.parse("today");

	// Returns yesterday's date. The string "yesterday" is culture specific.
	var d1 = Date.parse("yesterday");

	// Returns the date of the next thursday.
	var d1 = Date.parse("Next thursday");

	// Returns the date of the most previous monday.
	var d1 = Date.parse("last monday");

	// Returns today's day + one year.
	var d1 = Date.parse("next year");

	///////////////
	// Date Math //
	///////////////

	// Today + 2 days
	var d1 = Date.parse("t+2");

	// Today + 2 days
	var d1 = Date.parse("today + 2 days");

	// Today + 3 months
	var d1 = Date.parse("t+3m");

	// Today - 1 year
	var d1 = Date.parse("today - 1 year");

	// Today - 1 year
	var d1 = Date.parse("t-1y"); 


	/////////////////////////////
	// Partial Dates and Times //
	/////////////////////////////

	// July 15th of this year.
	var d1 = Date.parse("July 15");

	// 15th day of current day and year.
	var d1 = Date.parse("15");

	// July 1st of current year at 10pm.
	var d1 = Date.parse("7/1 10pm");
	
* * @param {String} The string value to convert into a Date object [Required] * @return {Date} A Date object or null if the string cannot be converted into a Date. */ var parseUtils = { removeOrds: function (s) { ords = s.match(/\b(\d+)(?:st|nd|rd|th)\b/); // find ordinal matches s = ((ords && ords.length === 2) ? s.replace(ords[0], ords[1]) : s); return s; }, grammarParser: function (s) { var r = null; try { r = $D.Grammar.start.call({}, s.replace(/^\s*(\S*(\s+\S+)*)\s*$/, "$1")); } catch (e) { return null; } return ((r[1].length === 0) ? r[0] : null); }, nativeFallback: function(s) { var t; try { // ok we haven't parsed it, last ditch attempt with the built-in parser. t = Date._parse(s); return (t || t === 0) ? new Date(t) : null; } catch (e) { return null; } } }; function parse (s) { var d; if (!s) { return null; } if (s instanceof Date) { return s.clone(); } if (s.length >= 4 && s.charAt(0) !== "0" && s.charAt(0) !== "+"&& s.charAt(0) !== "-") { // ie: 2004 will pass, 0800 won't. // Start with specific formats d = $D.Parsing.ISO.parse(s) || $D.Parsing.Numeric.parse(s); } if (d instanceof Date && !isNaN(d.getTime())) { return d; } else { // find ordinal dates (1st, 3rd, 8th, etc and remove them as they cause parsing issues) s = $D.Parsing.Normalizer.parse(parseUtils.removeOrds(s)); d = parseUtils.grammarParser(s); if (d !== null) { return d; } else { return parseUtils.nativeFallback(s); } } } if (!$D._parse) { $D._parse = $D.parse; } $D.parse = parse; Date.getParseFunction = function (fx) { var fns = Date.Grammar.allformats(fx); return function (s) { var r = null; for (var i = 0; i < fns.length; i++) { try { r = fns[i].call({}, s); } catch (e) { continue; } if (r[1].length === 0) { return r[0]; } } return null; }; }; /** * Converts the specified string value into its JavaScript Date equivalent using the specified format {String} or formats {Array} and the CultureInfo specific format information. * The format of the string value must match one of the supplied formats exactly. * * Example

	// 15-Oct-2004
	var d1 = Date.parseExact("10/15/2004", "M/d/yyyy");

	// 15-Oct-2004
	var d1 = Date.parse("15-Oct-2004", "M-ddd-yyyy");

	// 15-Oct-2004
	var d1 = Date.parse("2004.10.15", "yyyy.MM.dd");

	// Multiple formats
	var d1 = Date.parseExact("10/15/2004", ["M/d/yyyy", "MMMM d, yyyy"]);
	
* * @param {String} The string value to convert into a Date object [Required]. * @param {Object} The expected format {String} or an array of expected formats {Array} of the date string [Required]. * @return {Date} A Date object or null if the string cannot be converted into a Date. */ $D.parseExact = function (s, fx) { return $D.getParseFunction(fx)(s); }; }()); (function () { var $D = Date, $P = $D.prototype, // $C = $D.CultureInfo, // not used atm p = function (s, l) { if (!l) { l = 2; } return ("000" + s).slice(l * -1); }; /** * Converts a PHP format string to Java/.NET format string. * A PHP format string can be used with ._format or .format. * A Java/.NET format string can be used with .toString(). * The .parseExact function will only accept a Java/.NET format string * * Example * var f1 = "%m/%d/%y" * var f2 = Date.normalizeFormat(f1); // "MM/dd/yy" * * new Date().format(f1); // "04/13/08" * new Date()._format(f1); // "04/13/08" * new Date().toString(f2); // "04/13/08" * * var date = Date.parseExact("04/13/08", f2); // Sun Apr 13 2008 * * @param {String} A PHP format string consisting of one or more format spcifiers. * @return {String} The PHP format converted to a Java/.NET format string. */ var normalizerSubstitutions = { "d" : "dd", "%d": "dd", "D" : "ddd", "%a": "ddd", "j" : "dddd", "l" : "dddd", "%A": "dddd", "S" : "S", "F" : "MMMM", "%B": "MMMM", "m" : "MM", "%m": "MM", "M" : "MMM", "%b": "MMM", "%h": "MMM", "n" : "M", "Y" : "yyyy", "%Y": "yyyy", "y" : "yy", "%y": "yy", "g" : "h", "%I": "h", "G" : "H", "h" : "hh", "H" : "HH", "%H": "HH", "i" : "mm", "%M": "mm", "s" : "ss", "%S": "ss", "%r": "hh:mm tt", "%R": "H:mm", "%T": "H:mm:ss", "%X": "t", "%x": "d", "%e": "d", "%D": "MM/dd/yy", "%n": "\\n", "%t": "\\t", "e" : "z", "T" : "z", "%z": "z", "%Z": "z", "Z" : "ZZ", "N" : "u", "w" : "u", "%w": "u", "W" : "W", "%V": "W" }; var normalizer = { substitutes: function (m) { return normalizerSubstitutions[m]; }, interpreted: function (m, x) { var y; switch (m) { case "%u": return x.getDay() + 1; case "z": return x.getOrdinalNumber(); case "%j": return p(x.getOrdinalNumber(), 3); case "%U": var d1 = x.clone().set({month: 0, day: 1}).addDays(-1).moveToDayOfWeek(0), d2 = x.clone().addDays(1).moveToDayOfWeek(0, -1); return (d2 < d1) ? "00" : p((d2.getOrdinalNumber() - d1.getOrdinalNumber()) / 7 + 1); case "%W": return p(x.getWeek()); case "t": return $D.getDaysInMonth(x.getFullYear(), x.getMonth()); case "o": case "%G": return x.setWeek(x.getISOWeek()).toString("yyyy"); case "%g": return x._format("%G").slice(-2); case "a": case "%p": return t("tt").toLowerCase(); case "A": return t("tt").toUpperCase(); case "u": return p(x.getMilliseconds(), 3); case "I": return (x.isDaylightSavingTime()) ? 1 : 0; case "O": return x.getUTCOffset(); case "P": y = x.getUTCOffset(); return y.substring(0, y.length - 2) + ":" + y.substring(y.length - 2); case "B": var now = new Date(); return Math.floor(((now.getHours() * 3600) + (now.getMinutes() * 60) + now.getSeconds() + (now.getTimezoneOffset() + 60) * 60) / 86.4); case "c": return x.toISOString().replace(/\"/g, ""); case "U": return $D.strtotime("now"); case "%c": return t("d") + " " + t("t"); case "%C": return Math.floor(x.getFullYear() / 100 + 1); } }, shouldOverrideDefaults: function (m) { switch (m) { case "%e": return true; default: return false; } }, parse: function (m, context) { var formatString, c = context || new Date(); formatString = normalizer.substitutes(m); if (formatString) { return formatString; } formatString = normalizer.interpreted(m, c); if (formatString) { return formatString; } else { return m; } } }; $D.normalizeFormat = function (format, context) { return format.replace(/(%|\\)?.|%%/g, function(t){ return normalizer.parse(t, context); }); }; /** * Format a local Unix timestamp according to locale settings * * Example: * Date.strftime("%m/%d/%y", new Date()); // "04/13/08" * Date.strftime("c", "2008-04-13T17:52:03Z"); // "04/13/08" * * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @param {Number|String} The number representing the number of seconds that have elapsed since January 1, 1970 (local time). * @return {String} A string representation of the current Date object. */ $D.strftime = function (format, time) { var d = Date.parse(time); return d._format(format); }; /** * Parse any textual datetime description into a Unix timestamp. * A Unix timestamp is the number of seconds that have elapsed since January 1, 1970 (midnight UTC/GMT). * * Example: * Date.strtotime("04/13/08"); // 1208044800 * Date.strtotime("1970-01-01T00:00:00Z"); // 0 * * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @param {Object} A string or date object. * @return {String} A string representation of the current Date object. */ $D.strtotime = function (time) { var d = $D.parse(time); return Math.round($D.UTC(d.getUTCFullYear(), d.getUTCMonth(), d.getUTCDate(), d.getUTCHours(), d.getUTCMinutes(), d.getUTCSeconds(), d.getUTCMilliseconds()) / 1000); }; /** * Converts the value of the current Date object to its equivalent string representation using a PHP/Unix style of date format specifiers. * Format Specifiers * Format Description Example * ------ --------------------------------------------------------------------------- ----------------------- * %a abbreviated weekday name according to the current localed "Mon" through "Sun" * %A full weekday name according to the current localed "Sunday" through "Saturday" * %b abbreviated month name according to the current localed "Jan" through "Dec" * %B full month name according to the current locale "January" through "December" * %c preferred date and time representation for the current locale "4/13/2008 12:33 PM" * %C century number (the year divided by 100 and truncated to an integer) "00" to "99" * %d day of the month as a decimal number "01" to "31" * %D same as %m/%d/%y "04/13/08" * %e day of the month as a decimal number, a single digit is preceded by a space "1" to "31" * %g like %G, but without the century "08" * %G The 4-digit year corresponding to the ISO week number (see %V). "2008" * This has the same format and value as %Y, except that if the ISO week number * belongs to the previous or next year, that year is used instead. * %h same as %b "Jan" through "Dec" * %H hour as a decimal number using a 24-hour clock. "00" to "23" * %I hour as a decimal number using a 12-hour clock. "01" to "12" * %j day of the year as a decimal number. "001" to "366" * %m month as a decimal number. "01" to "12" * %M minute as a decimal number. "00" to "59" * %n newline character "\n" * %p either "am" or "pm" according to the given time value, or the "am" or "pm" * corresponding strings for the current locale. * %r time in a.m. and p.m. notation "8:44 PM" * %R time in 24 hour notation "20:44" * %S second as a decimal number "00" to "59" * %t tab character "\t" * %T current time, equal to %H:%M:%S "12:49:11" * %u weekday as a decimal number ["1", "7"], with "1" representing Monday "1" to "7" * %U week number of the current year as a decimal number, starting with the "0" to ("52" or "53") * first Sunday as the first day of the first week * %V The ISO 8601:1988 week number of the current year as a decimal number, "00" to ("52" or "53") * range 01 to 53, where week 1 is the first week that has at least 4 days * in the current year, and with Monday as the first day of the week. * (Use %G or %g for the year component that corresponds to the week number * for the specified timestamp.) * %W week number of the current year as a decimal number, starting with the "00" to ("52" or "53") * first Monday as the first day of the first week * %w day of the week as a decimal, Sunday being "0" "0" to "6" * %x preferred date representation for the current locale without the time "4/13/2008" * %X preferred time representation for the current locale without the date "12:53:05" * %y year as a decimal number without a century "00" "99" * %Y year as a decimal number including the century "2008" * %Z time zone or name or abbreviation "UTC", "EST", "PST" * %z same as %Z * %% a literal "%" characters "%" * d Day of the month, 2 digits with leading zeros "01" to "31" * D A textual representation of a day, three letters "Mon" through "Sun" * j Day of the month without leading zeros "1" to "31" * l A full textual representation of the day of the week (lowercase "L") "Sunday" through "Saturday" * N ISO-8601 numeric representation of the day of the week (added in PHP 5.1.0) "1" (for Monday) through "7" (for Sunday) * S English ordinal suffix for the day of the month, 2 characters "st", "nd", "rd" or "th". Works well with j * w Numeric representation of the day of the week "0" (for Sunday) through "6" (for Saturday) * z The day of the year (starting from "0") "0" through "365" * W ISO-8601 week number of year, weeks starting on Monday "00" to ("52" or "53") * F A full textual representation of a month, such as January or March "January" through "December" * m Numeric representation of a month, with leading zeros "01" through "12" * M A short textual representation of a month, three letters "Jan" through "Dec" * n Numeric representation of a month, without leading zeros "1" through "12" * t Number of days in the given month "28" through "31" * L Whether it's a leap year "1" if it is a leap year, "0" otherwise * o ISO-8601 year number. This has the same value as Y, except that if the "2008" * ISO week number (W) belongs to the previous or next year, that year * is used instead. * Y A full numeric representation of a year, 4 digits "2008" * y A two digit representation of a year "08" * a Lowercase Ante meridiem and Post meridiem "am" or "pm" * A Uppercase Ante meridiem and Post meridiem "AM" or "PM" * B Swatch Internet time "000" through "999" * g 12-hour format of an hour without leading zeros "1" through "12" * G 24-hour format of an hour without leading zeros "0" through "23" * h 12-hour format of an hour with leading zeros "01" through "12" * H 24-hour format of an hour with leading zeros "00" through "23" * i Minutes with leading zeros "00" to "59" * s Seconds, with leading zeros "00" through "59" * u Milliseconds "54321" * e Timezone identifier "UTC", "EST", "PST" * I Whether or not the date is in daylight saving time (uppercase i) "1" if Daylight Saving Time, "0" otherwise * O Difference to Greenwich time (GMT) in hours "+0200", "-0600" * P Difference to Greenwich time (GMT) with colon between hours and minutes "+02:00", "-06:00" * T Timezone abbreviation "UTC", "EST", "PST" * Z Timezone offset in seconds. The offset for timezones west of UTC is "-43200" through "50400" * always negative, and for those east of UTC is always positive. * c ISO 8601 date "2004-02-12T15:19:21+00:00" * r RFC 2822 formatted date "Thu, 21 Dec 2000 16:01:07 +0200" * U Seconds since the Unix Epoch (January 1 1970 00:00:00 GMT) "0" * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @return {String} A string representation of the current Date object. */ var formatReplace = function (context) { return function (m) { var formatString, override = false; if (m.charAt(0) === "\\" || m.substring(0, 2) === "%%") { return m.replace("\\", "").replace("%%", "%"); } override = normalizer.shouldOverrideDefaults(m); formatString = $D.normalizeFormat(m, context); if (formatString) { return context.toString(formatString, override); } }; }; $P._format = function (format) { var formatter = formatReplace(this); if (!format) { return this._toString(); } else { return format.replace(/(%|\\)?.|%%/g, formatter); } }; if (!$P.format) { $P.format = $P._format; } }()); (function () { "use strict"; var gFn = function (attr) { return function () { return this[attr]; }; }; var sFn = function (attr) { return function (val) { this[attr] = val; return this; }; }; var attrs = ["years", "months", "days", "hours", "minutes", "seconds", "milliseconds"]; var addSetFuncs = function (context, attrs) { for (var i = 0; i < attrs.length ; i++) { var $a = attrs[i], $b = $a.slice(0, 1).toUpperCase() + $a.slice(1); context.prototype[$a] = 0; context.prototype["get" + $b] = gFn($a); context.prototype["set" + $b] = sFn($a); } }; /** * new TimeSpan(milliseconds); * new TimeSpan(days, hours, minutes, seconds); * new TimeSpan(days, hours, minutes, seconds, milliseconds); */ var TimeSpan = function (days, hours, minutes, seconds, milliseconds) { if (arguments.length === 1 && typeof days === "number") { var orient = (days < 0) ? -1 : +1; var millsLeft = Math.abs(days); this.setDays(Math.floor(millsLeft / 86400000) * orient); millsLeft = millsLeft % 86400000; this.setHours(Math.floor(millsLeft / 3600000) * orient); millsLeft = millsLeft % 3600000; this.setMinutes(Math.floor(millsLeft / 60000) * orient); millsLeft = millsLeft % 60000; this.setSeconds(Math.floor(millsLeft / 1000) * orient); millsLeft = millsLeft % 1000; this.setMilliseconds(millsLeft * orient); } else { this.set(days, hours, minutes, seconds, milliseconds); } this.getTotalMilliseconds = function () { return (this.getDays() * 86400000) + (this.getHours() * 3600000) + (this.getMinutes() * 60000) + (this.getSeconds() * 1000); }; this.compareTo = function (time) { var t1 = new Date(1970, 1, 1, this.getHours(), this.getMinutes(), this.getSeconds()), t2; if (time === null) { t2 = new Date(1970, 1, 1, 0, 0, 0); } else { t2 = new Date(1970, 1, 1, time.getHours(), time.getMinutes(), time.getSeconds()); } return (t1 < t2) ? -1 : (t1 > t2) ? 1 : 0; }; this.equals = function (time) { return (this.compareTo(time) === 0); }; this.add = function (time) { return (time === null) ? this : this.addSeconds(time.getTotalMilliseconds() / 1000); }; this.subtract = function (time) { return (time === null) ? this : this.addSeconds(-time.getTotalMilliseconds() / 1000); }; this.addDays = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 86400000)); }; this.addHours = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 3600000)); }; this.addMinutes = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 60000)); }; this.addSeconds = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 1000)); }; this.addMilliseconds = function (n) { return new TimeSpan(this.getTotalMilliseconds() + n); }; this.get12HourHour = function () { return (this.getHours() > 12) ? this.getHours() - 12 : (this.getHours() === 0) ? 12 : this.getHours(); }; this.getDesignator = function () { return (this.getHours() < 12) ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator; }; this.toString = function (format) { this._toString = function () { if (this.getDays() !== null && this.getDays() > 0) { return this.getDays() + "." + this.getHours() + ":" + this.p(this.getMinutes()) + ":" + this.p(this.getSeconds()); } else { return this.getHours() + ":" + this.p(this.getMinutes()) + ":" + this.p(this.getSeconds()); } }; this.p = function (s) { return (s.toString().length < 2) ? "0" + s : s; }; var me = this; return format ? format.replace(/dd?|HH?|hh?|mm?|ss?|tt?/g, function (format) { switch (format) { case "d": return me.getDays(); case "dd": return me.p(me.getDays()); case "H": return me.getHours(); case "HH": return me.p(me.getHours()); case "h": return me.get12HourHour(); case "hh": return me.p(me.get12HourHour()); case "m": return me.getMinutes(); case "mm": return me.p(me.getMinutes()); case "s": return me.getSeconds(); case "ss": return me.p(me.getSeconds()); case "t": return ((me.getHours() < 12) ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator).substring(0, 1); case "tt": return (me.getHours() < 12) ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator; } } ) : this._toString(); }; return this; }; addSetFuncs(TimeSpan, attrs.slice(2)); TimeSpan.prototype.set = function (days, hours, minutes, seconds, milliseconds){ this.setDays(days || this.getDays()); this.setHours(hours || this.getHours()); this.setMinutes(minutes || this.getMinutes()); this.setSeconds(seconds || this.getSeconds()); this.setMilliseconds(milliseconds || this.getMilliseconds()); }; /** * Gets the time of day for this date instances. * @return {TimeSpan} TimeSpan */ Date.prototype.getTimeOfDay = function () { return new TimeSpan(0, this.getHours(), this.getMinutes(), this.getSeconds(), this.getMilliseconds()); }; Date.TimeSpan = TimeSpan; if (typeof window !== "undefined" ) { // keeping API compatible for v1.x window.TimeSpan = TimeSpan; } }()); (function () { "use strict"; var attrs = ["years", "months", "days", "hours", "minutes", "seconds", "milliseconds"]; var gFn = function (attr) { return function () { return this[attr]; }; }; var sFn = function (attr) { return function (val) { this[attr] = val; return this; }; }; var addSetFuncs = function (context, attrs) { for (var i = 0; i < attrs.length ; i++) { var $a = attrs[i], $b = $a.slice(0, 1).toUpperCase() + $a.slice(1); context.prototype[$a] = 0; context.prototype["get" + $b] = gFn($a); context.prototype["set" + $b] = sFn($a); } }; var setMonthsAndYears = function (orient, d1, d2, context) { function inc() { d1.addMonths(-orient); context.months++; if (context.months === 12) { context.years++; context.months = 0; } } if (orient === +1) { while (d1 > d2) { inc(); } } else { while (d1 < d2) { inc(); } } context.months--; context.months *= orient; context.years *= orient; }; var adjustForDST = function(orient, startDate, endDate) { var hasDSTMismatch = (false === (startDate.isDaylightSavingTime() === endDate.isDaylightSavingTime())); if (hasDSTMismatch && orient === 1) { startDate.addHours(-1); } else if (hasDSTMismatch) { startDate.addHours(1); } }; /** * TimePeriod(startDate, endDate); * TimePeriod(years, months, days, hours, minutes, seconds, milliseconds); */ var TimePeriod = function (years, months, days, hours, minutes, seconds, milliseconds) { if (arguments.length === 7) { this.set(years, months, days, hours, minutes, seconds, milliseconds); } else if (arguments.length === 2 && arguments[0] instanceof Date && arguments[1] instanceof Date) { var startDate = arguments[0].clone(); var endDate = arguments[1].clone(); var orient = (startDate > endDate) ? +1 : -1; this.dates = { start: arguments[0].clone(), end: arguments[1].clone() }; setMonthsAndYears(orient, startDate, endDate, this); adjustForDST(orient, startDate, endDate); // // TODO - adjust for DST var diff = endDate - startDate; if (diff !== 0) { var ts = new TimeSpan(diff); this.set(this.years, this.months, ts.getDays(), ts.getHours(), ts.getMinutes(), ts.getSeconds(), ts.getMilliseconds()); } } return this; }; // create all the set functions. addSetFuncs(TimePeriod, attrs); TimePeriod.prototype.set = function (years, months, days, hours, minutes, seconds, milliseconds){ this.setYears(years || this.getYears()); this.setMonths(months || this.getMonths()); this.setDays(days || this.getDays()); this.setHours(hours || this.getHours()); this.setMinutes(minutes || this.getMinutes()); this.setSeconds(seconds || this.getSeconds()); this.setMilliseconds(milliseconds || this.getMilliseconds()); }; Date.TimePeriod = TimePeriod; if (typeof window !== "undefined") { // keeping API compatible for v1.x window.TimePeriod = TimePeriod; } }()); ================================================ FILE: build/date-ta-IN.js ================================================ /** * @overview datejs * @version 1.0.0-rc3 * @author Gregory Wild-Smith * @copyright 2015 Gregory Wild-Smith * @license MIT * @homepage https://github.com/abritinthebay/datejs */ /* * DateJS Culture String File * Country Code: ta-IN * Name: Tamil (India) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["ta-IN"] = { "name": "ta-IN", "englishName": "Tamil (India)", "nativeName": "தமிழ் (இந்தியா)", "Sunday": "ஞாயிறு", "Monday": "திங்கள்", "Tuesday": "செவ்வாய்", "Wednesday": "புதன்", "Thursday": "வியாழன்", "Friday": "வெள்ளி", "Saturday": "சனி", "Sun": "ஞா", "Mon": "தி", "Tue": "செ", "Wed": "பு", "Thu": "வி", "Fri": "வெ", "Sat": "ச", "Su": "ஞ", "Mo": "த", "Tu": "ச", "We": "ப", "Th": "வ", "Fr": "வ", "Sa": "ச", "S_Sun_Initial": "ஞ", "M_Mon_Initial": "த", "T_Tue_Initial": "ச", "W_Wed_Initial": "ப", "T_Thu_Initial": "வ", "F_Fri_Initial": "வ", "S_Sat_Initial": "ச", "January": "ஜனவரி", "February": "பெப்ரவரி", "March": "மார்ச்", "April": "ஏப்ரல்", "May": "மே", "June": "ஜூன்", "July": "ஜூலை", "August": "ஆகஸ்ட்", "September": "செப்டம்பர்", "October": "அக்டோபர்", "November": "நவம்பர்", "December": "டிசம்பர்", "Jan_Abbr": "ஜன.", "Feb_Abbr": "பெப்.", "Mar_Abbr": "மார்.", "Apr_Abbr": "ஏப்.", "May_Abbr": "மே", "Jun_Abbr": "ஜூன்", "Jul_Abbr": "ஜூலை", "Aug_Abbr": "ஆக.", "Sep_Abbr": "செப்.", "Oct_Abbr": "அக்.", "Nov_Abbr": "நவ.", "Dec_Abbr": "டிச.", "AM": "காலை", "PM": "மாலை", "firstDayOfWeek": 1, "twoDigitYearMax": 2029, "mdy": "dmy", "M/d/yyyy": "dd-MM-yyyy", "dddd, MMMM dd, yyyy": "dd MMMM yyyy", "h:mm tt": "HH:mm", "h:mm:ss tt": "HH:mm:ss", "dddd, MMMM dd, yyyy h:mm:ss tt": "dd MMMM yyyy HH:mm:ss", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "dd MMMM", "MMMM, yyyy": "MMMM yyyy", "/jan(uary)?/": "ஜன(.(வரி)?)?", "/feb(ruary)?/": "பெப்(.(ரவரி)?)?", "/mar(ch)?/": "மார்(.(ச்)?)?", "/apr(il)?/": "ஏப்(.(ரல்)?)?", "/may/": "மே", "/jun(e)?/": "ஜூன்", "/jul(y)?/": "ஜூலை", "/aug(ust)?/": "ஆக(.(ஸ்ட்)?)?", "/sep(t(ember)?)?/": "செப்(.(டம்பர்)?)?", "/oct(ober)?/": "அக்(.(டோபர்)?)?", "/nov(ember)?/": "நவ(.(ம்பர்)?)?", "/dec(ember)?/": "டிச(.(ம்பர்)?)?", "/^su(n(day)?)?/": "^ஞ(ா(யிறு)?)?", "/^mo(n(day)?)?/": "^த(ி(ங்கள்)?)?", "/^tu(e(s(day)?)?)?/": "^ச(ெ(வ்வாய்)?)?", "/^we(d(nesday)?)?/": "^ப(ு(தன்)?)?", "/^th(u(r(s(day)?)?)?)?/": "^வ(ி(யாழன்)?)?", "/^fr(i(day)?)?/": "^வ(ெ(ள்ளி)?)?", "/^sa(t(urday)?)?/": "^சனி", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "ta-IN"; /** * @overview datejs * @version 1.0.0-rc3 * @author Gregory Wild-Smith * @copyright 2015 Gregory Wild-Smith * @license MIT * @homepage https://github.com/abritinthebay/datejs */(function () { var $D = Date; var lang = Date.CultureStrings ? Date.CultureStrings.lang : null; var loggedKeys = {}; // for debug purposes. var getText = { getFromKey: function (key, countryCode) { var output; if (Date.CultureStrings && Date.CultureStrings[countryCode] && Date.CultureStrings[countryCode][key]) { output = Date.CultureStrings[countryCode][key]; } else { output = getText.buildFromDefault(key); } if (key.charAt(0) === "/") { // Assume it's a regex output = getText.buildFromRegex(key, countryCode); } return output; }, getFromObjectValues: function (obj, countryCode) { var key, output = {}; for(key in obj) { if (obj.hasOwnProperty(key)) { output[key] = getText.getFromKey(obj[key], countryCode); } } return output; }, getFromObjectKeys: function (obj, countryCode) { var key, output = {}; for(key in obj) { if (obj.hasOwnProperty(key)) { output[getText.getFromKey(key, countryCode)] = obj[key]; } } return output; }, getFromArray: function (arr, countryCode) { var output = []; for (var i=0; i < arr.length; i++){ if (i in arr) { output[i] = getText.getFromKey(arr[i], countryCode); } } return output; }, buildFromDefault: function (key) { var output, length, split, last; switch(key) { case "name": output = "en-US"; break; case "englishName": output = "English (United States)"; break; case "nativeName": output = "English (United States)"; break; case "twoDigitYearMax": output = 2049; break; case "firstDayOfWeek": output = 0; break; default: output = key; split = key.split("_"); length = split.length; if (length > 1 && key.charAt(0) !== "/") { // if the key isn't a regex and it has a split. last = split[(length - 1)].toLowerCase(); if (last === "initial" || last === "abbr") { output = split[0]; } } break; } return output; }, buildFromRegex: function (key, countryCode) { var output; if (Date.CultureStrings && Date.CultureStrings[countryCode] && Date.CultureStrings[countryCode][key]) { output = new RegExp(Date.CultureStrings[countryCode][key], "i"); } else { output = new RegExp(key.replace(new RegExp("/", "g"),""), "i"); } return output; } }; var shallowMerge = function (obj1, obj2) { for (var attrname in obj2) { if (obj2.hasOwnProperty(attrname)) { obj1[attrname] = obj2[attrname]; } } }; var __ = function (key, language) { var countryCode = (language) ? language : lang; loggedKeys[key] = key; if (typeof key === "object") { if (key instanceof Array) { return getText.getFromArray(key, countryCode); } else { return getText.getFromObjectKeys(key, countryCode); } } else { return getText.getFromKey(key, countryCode); } }; var loadI18nScript = function (code) { // paatterned after jQuery's getScript. var url = Date.Config.i18n + code + ".js"; var head = document.getElementsByTagName("head")[0] || document.documentElement; var script = document.createElement("script"); script.src = url; var completed = false; var events = { done: function (){} // placeholder function }; // Attach handlers for all browsers script.onload = script.onreadystatechange = function() { if ( !completed && (!this.readyState || this.readyState === "loaded" || this.readyState === "complete") ) { events.done(); head.removeChild(script); } }; setTimeout(function() { head.insertBefore(script, head.firstChild); }, 0); // allows return to execute first return { done: function (cb) { events.done = function() { if (cb) { setTimeout(cb,0); } }; } }; }; var buildInfo = { buildFromMethodHash: function (obj) { var key; for(key in obj) { if (obj.hasOwnProperty(key)) { obj[key] = buildInfo[obj[key]](); } } return obj; }, timeZoneDST: function () { var DST = { "CHADT": "+1345", "NZDT": "+1300", "AEDT": "+1100", "ACDT": "+1030", "AZST": "+0500", "IRDT": "+0430", "EEST": "+0300", "CEST": "+0200", "BST": "+0100", "PMDT": "-0200", "ADT": "-0300", "NDT": "-0230", "EDT": "-0400", "CDT": "-0500", "MDT": "-0600", "PDT": "-0700", "AKDT": "-0800", "HADT": "-0900" }; return __(DST); }, timeZoneStandard: function () { var standard = { "LINT": "+1400", "TOT": "+1300", "CHAST": "+1245", "NZST": "+1200", "NFT": "+1130", "SBT": "+1100", "AEST": "+1000", "ACST": "+0930", "JST": "+0900", "CWST": "+0845", "CT": "+0800", "ICT": "+0700", "MMT": "+0630", "BST": "+0600", "NPT": "+0545", "IST": "+0530", "PKT": "+0500", "AFT": "+0430", "MSK": "+0400", "IRST": "+0330", "FET": "+0300", "EET": "+0200", "CET": "+0100", "GMT": "+0000", "UTC": "+0000", "CVT": "-0100", "GST": "-0200", "BRT": "-0300", "NST": "-0330", "AST": "-0400", "EST": "-0500", "CST": "-0600", "MST": "-0700", "PST": "-0800", "AKST": "-0900", "MIT": "-0930", "HST": "-1000", "SST": "-1100", "BIT": "-1200" }; return __(standard); }, timeZones: function (data) { var zone; data.timezones = []; for (zone in data.abbreviatedTimeZoneStandard) { if (data.abbreviatedTimeZoneStandard.hasOwnProperty(zone)) { data.timezones.push({ name: zone, offset: data.abbreviatedTimeZoneStandard[zone]}); } } for (zone in data.abbreviatedTimeZoneDST) { if (data.abbreviatedTimeZoneDST.hasOwnProperty(zone)) { data.timezones.push({ name: zone, offset: data.abbreviatedTimeZoneDST[zone], dst: true}); } } return data.timezones; }, days: function () { return __(["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"]); }, dayAbbr: function () { return __(["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"]); }, dayShortNames: function () { return __(["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"]); }, dayFirstLetters: function () { return __(["S_Sun_Initial", "M_Mon_Initial", "T_Tues_Initial", "W_Wed_Initial", "T_Thu_Initial", "F_Fri_Initial", "S_Sat_Initial"]); }, months: function () { return __(["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"]); }, monthAbbr: function () { return __(["Jan_Abbr", "Feb_Abbr", "Mar_Abbr", "Apr_Abbr", "May_Abbr", "Jun_Abbr", "Jul_Abbr", "Aug_Abbr", "Sep_Abbr", "Oct_Abbr", "Nov_Abbr", "Dec_Abbr"]); }, formatPatterns: function () { return getText.getFromObjectValues({ shortDate: "M/d/yyyy", longDate: "dddd, MMMM dd, yyyy", shortTime: "h:mm tt", longTime: "h:mm:ss tt", fullDateTime: "dddd, MMMM dd, yyyy h:mm:ss tt", sortableDateTime: "yyyy-MM-ddTHH:mm:ss", universalSortableDateTime: "yyyy-MM-dd HH:mm:ssZ", rfc1123: "ddd, dd MMM yyyy HH:mm:ss", monthDay: "MMMM dd", yearMonth: "MMMM, yyyy" }, Date.i18n.currentLanguage()); }, regex: function () { return getText.getFromObjectValues({ inTheMorning: "/( in the )(morn(ing)?)\\b/", thisMorning: "/(this )(morn(ing)?)\\b/", amThisMorning: "/(\b\\d(am)? )(this )(morn(ing)?)/", inTheEvening: "/( in the )(even(ing)?)\\b/", thisEvening: "/(this )(even(ing)?)\\b/", pmThisEvening: "/(\b\\d(pm)? )(this )(even(ing)?)/", jan: "/jan(uary)?/", feb: "/feb(ruary)?/", mar: "/mar(ch)?/", apr: "/apr(il)?/", may: "/may/", jun: "/jun(e)?/", jul: "/jul(y)?/", aug: "/aug(ust)?/", sep: "/sep(t(ember)?)?/", oct: "/oct(ober)?/", nov: "/nov(ember)?/", dec: "/dec(ember)?/", sun: "/^su(n(day)?)?/", mon: "/^mo(n(day)?)?/", tue: "/^tu(e(s(day)?)?)?/", wed: "/^we(d(nesday)?)?/", thu: "/^th(u(r(s(day)?)?)?)?/", fri: "/fr(i(day)?)?/", sat: "/^sa(t(urday)?)?/", future: "/^next/", past: "/^last|past|prev(ious)?/", add: "/^(\\+|aft(er)?|from|hence)/", subtract: "/^(\\-|bef(ore)?|ago)/", yesterday: "/^yes(terday)?/", today: "/^t(od(ay)?)?/", tomorrow: "/^tom(orrow)?/", now: "/^n(ow)?/", millisecond: "/^ms|milli(second)?s?/", second: "/^sec(ond)?s?/", minute: "/^mn|min(ute)?s?/", hour: "/^h(our)?s?/", week: "/^w(eek)?s?/", month: "/^m(onth)?s?/", day: "/^d(ay)?s?/", year: "/^y(ear)?s?/", shortMeridian: "/^(a|p)/", longMeridian: "/^(a\\.?m?\\.?|p\\.?m?\\.?)/", timezone: "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/", ordinalSuffix: "/^\\s*(st|nd|rd|th)/", timeContext: "/^\\s*(\\:|a(?!u|p)|p)/" }, Date.i18n.currentLanguage()); } }; var CultureInfo = function () { var info = getText.getFromObjectValues({ name: "name", englishName: "englishName", nativeName: "nativeName", amDesignator: "AM", pmDesignator: "PM", firstDayOfWeek: "firstDayOfWeek", twoDigitYearMax: "twoDigitYearMax", dateElementOrder: "mdy" }, Date.i18n.currentLanguage()); var constructedInfo = buildInfo.buildFromMethodHash({ dayNames: "days", abbreviatedDayNames: "dayAbbr", shortestDayNames: "dayShortNames", firstLetterDayNames: "dayFirstLetters", monthNames: "months", abbreviatedMonthNames: "monthAbbr", formatPatterns: "formatPatterns", regexPatterns: "regex", abbreviatedTimeZoneDST: "timeZoneDST", abbreviatedTimeZoneStandard: "timeZoneStandard" }); shallowMerge(info, constructedInfo); buildInfo.timeZones(info); return info; }; $D.i18n = { __: function (key, lang) { return __(key, lang); }, currentLanguage: function () { return lang || "en-US"; }, setLanguage: function (code, force, cb) { var async = false; if (force || code === "en-US" || (!!Date.CultureStrings && !!Date.CultureStrings[code])) { lang = code; Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings.lang = code; Date.CultureInfo = new CultureInfo(); } else { if (!(!!Date.CultureStrings && !!Date.CultureStrings[code])) { if (typeof exports !== "undefined" && this.exports !== exports) { // we're in a Node enviroment, load it using require try { require("../i18n/" + code + ".js"); lang = code; Date.CultureStrings.lang = code; Date.CultureInfo = new CultureInfo(); } catch (e) { // var str = "The language for '" + code + "' could not be loaded by Node. It likely does not exist."; throw new Error("The DateJS IETF language tag '" + code + "' could not be loaded by Node. It likely does not exist."); } } else if (Date.Config && Date.Config.i18n) { // we know the location of the files, so lets load them async = true; loadI18nScript(code).done(function(){ lang = code; Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings.lang = code; Date.CultureInfo = new CultureInfo(); $D.Parsing.Normalizer.buildReplaceData(); // because this is async if ($D.Grammar) { $D.Grammar.buildGrammarFormats(); // so we can parse those strings... } if (cb) { setTimeout(cb,0); } }); } else { Date.console.error("The DateJS IETF language tag '" + code + "' is not available and has not been loaded."); return false; } } } $D.Parsing.Normalizer.buildReplaceData(); // rebuild normalizer strings if ($D.Grammar) { $D.Grammar.buildGrammarFormats(); // so we can parse those strings... } if (!async && cb) { setTimeout(cb,0); } }, getLoggedKeys: function () { return loggedKeys; }, updateCultureInfo: function () { Date.CultureInfo = new CultureInfo(); } }; $D.i18n.updateCultureInfo(); // run automatically }()); (function () { var $D = Date, $P = $D.prototype, p = function (s, l) { if (!l) { l = 2; } return ("000" + s).slice(l * -1); }; if (typeof window !== "undefined" && typeof window.console !== "undefined" && typeof window.console.log !== "undefined") { $D.console = console; // used only to raise non-critical errors if available } else { // set mock so we don't give errors. $D.console = { log: function(){}, error: function(){} }; } $D.Config = $D.Config || {}; $D.initOverloads = function() { /** * Overload of Date.now. Allows an alternate call for Date.now where it returns the * current Date as an object rather than just milliseconds since the Unix Epoch. * * Also provides an implementation of now() for browsers (IE<9) that don't have it. * * Backwards compatible so with work with either: * Date.now() [returns ms] * or * Date.now(true) [returns Date] */ if (!$D.now) { $D._now = function now() { return new Date().getTime(); }; } else if (!$D._now) { $D._now = $D.now; } $D.now = function (returnObj) { if (returnObj) { return $D.present(); } else { return $D._now(); } }; if ( !$P.toISOString ) { $P.toISOString = function() { return this.getUTCFullYear() + "-" + p(this.getUTCMonth() + 1) + "-" + p(this.getUTCDate()) + "T" + p(this.getUTCHours()) + ":" + p(this.getUTCMinutes()) + ":" + p(this.getUTCSeconds()) + "." + String( (this.getUTCMilliseconds()/1000).toFixed(3)).slice(2, 5) + "Z"; }; } // private if ( $P._toString === undefined ){ $P._toString = $P.toString; } }; $D.initOverloads(); /** * Gets a date that is set to the current date. The time is set to the start of the day (00:00 or 12:00 AM). * @return {Date} The current date. */ $D.today = function () { return new Date().clearTime(); }; /** * Gets a date that is set to the current date and time (same as new Date, but chainable) * @return {Date} The current date. */ $D.present = function () { return new Date(); }; /** * Compares the first date to the second date and returns an number indication of their relative values. * @param {Date} First Date object to compare [Required]. * @param {Date} Second Date object to compare to [Required]. * @return {Number} -1 = date1 is lessthan date2. 0 = values are equal. 1 = date1 is greaterthan date2. */ $D.compare = function (date1, date2) { if (isNaN(date1) || isNaN(date2)) { throw new Error(date1 + " - " + date2); } else if (date1 instanceof Date && date2 instanceof Date) { return (date1 < date2) ? -1 : (date1 > date2) ? 1 : 0; } else { throw new TypeError(date1 + " - " + date2); } }; /** * Compares the first Date object to the second Date object and returns true if they are equal. * @param {Date} First Date object to compare [Required] * @param {Date} Second Date object to compare to [Required] * @return {Boolean} true if dates are equal. false if they are not equal. */ $D.equals = function (date1, date2) { return (date1.compareTo(date2) === 0); }; /** * Gets the language appropriate day name when given the day number(0-6) * eg - 0 == Sunday * @return {String} The day name */ $D.getDayName = function (n) { return Date.CultureInfo.dayNames[n]; }; /** * Gets the day number (0-6) if given a CultureInfo specific string which is a valid dayName, abbreviatedDayName or shortestDayName (two char). * @param {String} The name of the day (eg. "Monday, "Mon", "tuesday", "tue", "We", "we"). * @return {Number} The day number */ $D.getDayNumberFromName = function (name) { var n = Date.CultureInfo.dayNames, m = Date.CultureInfo.abbreviatedDayNames, o = Date.CultureInfo.shortestDayNames, s = name.toLowerCase(); for (var i = 0; i < n.length; i++) { if (n[i].toLowerCase() === s || m[i].toLowerCase() === s || o[i].toLowerCase() === s) { return i; } } return -1; }; /** * Gets the month number (0-11) if given a Culture Info specific string which is a valid monthName or abbreviatedMonthName. * @param {String} The name of the month (eg. "February, "Feb", "october", "oct"). * @return {Number} The day number */ $D.getMonthNumberFromName = function (name) { var n = Date.CultureInfo.monthNames, m = Date.CultureInfo.abbreviatedMonthNames, s = name.toLowerCase(); for (var i = 0; i < n.length; i++) { if (n[i].toLowerCase() === s || m[i].toLowerCase() === s) { return i; } } return -1; }; /** * Gets the language appropriate month name when given the month number(0-11) * eg - 0 == January * @return {String} The month name */ $D.getMonthName = function (n) { return Date.CultureInfo.monthNames[n]; }; /** * Determines if the current date instance is within a LeapYear. * @param {Number} The year. * @return {Boolean} true if date is within a LeapYear, otherwise false. */ $D.isLeapYear = function (year) { return ((year % 4 === 0 && year % 100 !== 0) || year % 400 === 0); }; /** * Gets the number of days in the month, given a year and month value. Automatically corrects for LeapYear. * @param {Number} The year. * @param {Number} The month (0-11). * @return {Number} The number of days in the month. */ $D.getDaysInMonth = function (year, month) { if (!month && $D.validateMonth(year)) { month = year; year = Date.today().getFullYear(); } return [31, ($D.isLeapYear(year) ? 29 : 28), 31, 30, 31, 30, 31, 31, 30, 31, 30, 31][month]; }; $P.getDaysInMonth = function () { return $D.getDaysInMonth(this.getFullYear(), this.getMonth()); }; $D.getTimezoneAbbreviation = function (offset, dst) { var p, n = (dst || false) ? Date.CultureInfo.abbreviatedTimeZoneDST : Date.CultureInfo.abbreviatedTimeZoneStandard; for (p in n) { if (n.hasOwnProperty(p)) { if (n[p] === offset) { return p; } } } return null; }; $D.getTimezoneOffset = function (name, dst) { var i, a =[], z = Date.CultureInfo.timezones; if (!name) { name = (new Date()).getTimezone();} for (i = 0; i < z.length; i++) { if (z[i].name === name.toUpperCase()) { a.push(i); } } if (!z[a[0]]) { return null; } if (a.length === 1 || !dst) { return z[a[0]].offset; } else { for (i=0; i < a.length; i++) { if (z[a[i]].dst) { return z[a[i]].offset; } } } }; $D.getQuarter = function (d) { d = d || new Date(); // If no date supplied, use today var q = [1,2,3,4]; return q[Math.floor(d.getMonth() / 3)]; // ~~~ is a bitwise op. Faster than Math.floor }; $D.getDaysLeftInQuarter = function (d) { d = d || new Date(); var qEnd = new Date(d); qEnd.setMonth(qEnd.getMonth() + 3 - qEnd.getMonth() % 3, 0); return Math.floor((qEnd - d) / 8.64e7); }; // private var validate = function (n, min, max, name) { name = name ? name : "Object"; if (typeof n === "undefined") { return false; } else if (typeof n !== "number") { throw new TypeError(n + " is not a Number."); } else if (n < min || n > max) { // As failing validation is *not* an exceptional circumstance // lets not throw a RangeError Exception here. // It's semantically correct but it's not sensible. return false; } return true; }; /** * Validates the number is within an acceptable range for milliseconds [0-999]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateMillisecond = function (value) { return validate(value, 0, 999, "millisecond"); }; /** * Validates the number is within an acceptable range for seconds [0-59]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateSecond = function (value) { return validate(value, 0, 59, "second"); }; /** * Validates the number is within an acceptable range for minutes [0-59]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateMinute = function (value) { return validate(value, 0, 59, "minute"); }; /** * Validates the number is within an acceptable range for hours [0-23]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateHour = function (value) { return validate(value, 0, 23, "hour"); }; /** * Validates the number is within an acceptable range for the days in a month [0-MaxDaysInMonth]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateDay = function (value, year, month) { if (year === undefined || year === null || month === undefined || month === null) { return false;} return validate(value, 1, $D.getDaysInMonth(year, month), "day"); }; /** * Validates the number is within an acceptable range for months [0-11]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateWeek = function (value) { return validate(value, 0, 53, "week"); }; /** * Validates the number is within an acceptable range for months [0-11]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateMonth = function (value) { return validate(value, 0, 11, "month"); }; /** * Validates the number is within an acceptable range for years. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateYear = function (value) { /** * Per ECMAScript spec the range of times supported by Date objects is * exactly -100,000,000 days to +100,000,000 days measured relative to * midnight at the beginning of 01 January, 1970 UTC. * This gives a range of 8,640,000,000,000,000 milliseconds to either * side of 01 January, 1970 UTC. * * Earliest possible date: Tue, 20 Apr 271,822 B.C. 00:00:00 UTC * Latest possible date: Sat, 13 Sep 275,760 00:00:00 UTC */ return validate(value, -271822, 275760, "year"); }; $D.validateTimezone = function(value) { var timezones = {"ACDT":1,"ACST":1,"ACT":1,"ADT":1,"AEDT":1,"AEST":1,"AFT":1,"AKDT":1,"AKST":1,"AMST":1,"AMT":1,"ART":1,"AST":1,"AWDT":1,"AWST":1,"AZOST":1,"AZT":1,"BDT":1,"BIOT":1,"BIT":1,"BOT":1,"BRT":1,"BST":1,"BTT":1,"CAT":1,"CCT":1,"CDT":1,"CEDT":1,"CEST":1,"CET":1,"CHADT":1,"CHAST":1,"CHOT":1,"ChST":1,"CHUT":1,"CIST":1,"CIT":1,"CKT":1,"CLST":1,"CLT":1,"COST":1,"COT":1,"CST":1,"CT":1,"CVT":1,"CWST":1,"CXT":1,"DAVT":1,"DDUT":1,"DFT":1,"EASST":1,"EAST":1,"EAT":1,"ECT":1,"EDT":1,"EEDT":1,"EEST":1,"EET":1,"EGST":1,"EGT":1,"EIT":1,"EST":1,"FET":1,"FJT":1,"FKST":1,"FKT":1,"FNT":1,"GALT":1,"GAMT":1,"GET":1,"GFT":1,"GILT":1,"GIT":1,"GMT":1,"GST":1,"GYT":1,"HADT":1,"HAEC":1,"HAST":1,"HKT":1,"HMT":1,"HOVT":1,"HST":1,"ICT":1,"IDT":1,"IOT":1,"IRDT":1,"IRKT":1,"IRST":1,"IST":1,"JST":1,"KGT":1,"KOST":1,"KRAT":1,"KST":1,"LHST":1,"LINT":1,"MAGT":1,"MART":1,"MAWT":1,"MDT":1,"MET":1,"MEST":1,"MHT":1,"MIST":1,"MIT":1,"MMT":1,"MSK":1,"MST":1,"MUT":1,"MVT":1,"MYT":1,"NCT":1,"NDT":1,"NFT":1,"NPT":1,"NST":1,"NT":1,"NUT":1,"NZDT":1,"NZST":1,"OMST":1,"ORAT":1,"PDT":1,"PET":1,"PETT":1,"PGT":1,"PHOT":1,"PHT":1,"PKT":1,"PMDT":1,"PMST":1,"PONT":1,"PST":1,"PYST":1,"PYT":1,"RET":1,"ROTT":1,"SAKT":1,"SAMT":1,"SAST":1,"SBT":1,"SCT":1,"SGT":1,"SLST":1,"SRT":1,"SST":1,"SYOT":1,"TAHT":1,"THA":1,"TFT":1,"TJT":1,"TKT":1,"TLT":1,"TMT":1,"TOT":1,"TVT":1,"UCT":1,"ULAT":1,"UTC":1,"UYST":1,"UYT":1,"UZT":1,"VET":1,"VLAT":1,"VOLT":1,"VOST":1,"VUT":1,"WAKT":1,"WAST":1,"WAT":1,"WEDT":1,"WEST":1,"WET":1,"WST":1,"YAKT":1,"YEKT":1,"Z":1}; return (timezones[value] === 1); }; $D.validateTimezoneOffset= function(value) { // timezones go from +14hrs to -12hrs, the +X hours are negative offsets. return (value > -841 && value < 721); }; }()); (function () { var $D = Date, $P = $D.prototype, p = function (s, l) { if (!l) { l = 2; } return ("000" + s).slice(l * -1); }; var validateConfigObject = function (obj) { var result = {}, self = this, prop, testFunc; testFunc = function (prop, func, value) { if (prop === "day") { var month = (obj.month !== undefined) ? obj.month : self.getMonth(); var year = (obj.year !== undefined) ? obj.year : self.getFullYear(); return $D[func](value, year, month); } else { return $D[func](value); } }; for (prop in obj) { if (Object.prototype.hasOwnProperty.call(obj, prop)) { var func = "validate" + prop.charAt(0).toUpperCase() + prop.slice(1); if ($D[func] && obj[prop] !== null && testFunc(prop, func, obj[prop])) { result[prop] = obj[prop]; } } } return result; }; /** * Resets the time of this Date object to 12:00 AM (00:00), which is the start of the day. * @param {Boolean} .clone() this date instance before clearing Time * @return {Date} this */ $P.clearTime = function () { this.setHours(0); this.setMinutes(0); this.setSeconds(0); this.setMilliseconds(0); return this; }; /** * Resets the time of this Date object to the current time ('now'). * @return {Date} this */ $P.setTimeToNow = function () { var n = new Date(); this.setHours(n.getHours()); this.setMinutes(n.getMinutes()); this.setSeconds(n.getSeconds()); this.setMilliseconds(n.getMilliseconds()); return this; }; /** * Returns a new Date object that is an exact date and time copy of the original instance. * @return {Date} A new Date instance */ $P.clone = function () { return new Date(this.getTime()); }; /** * Compares this instance to a Date object and returns an number indication of their relative values. * @param {Date} Date object to compare [Required] * @return {Number} -1 = this is lessthan date. 0 = values are equal. 1 = this is greaterthan date. */ $P.compareTo = function (date) { return Date.compare(this, date); }; /** * Compares this instance to another Date object and returns true if they are equal. * @param {Date} Date object to compare. If no date to compare, new Date() [now] is used. * @return {Boolean} true if dates are equal. false if they are not equal. */ $P.equals = function (date) { return Date.equals(this, (date !== undefined ? date : new Date())); }; /** * Determines if this instance is between a range of two dates or equal to either the start or end dates. * @param {Date} Start of range [Required] * @param {Date} End of range [Required] * @return {Boolean} true is this is between or equal to the start and end dates, else false */ $P.between = function (start, end) { return this.getTime() >= start.getTime() && this.getTime() <= end.getTime(); }; /** * Determines if this date occurs after the date to compare to. * @param {Date} Date object to compare. If no date to compare, new Date() ("now") is used. * @return {Boolean} true if this date instance is greater than the date to compare to (or "now"), otherwise false. */ $P.isAfter = function (date) { return this.compareTo(date || new Date()) === 1; }; /** * Determines if this date occurs before the date to compare to. * @param {Date} Date object to compare. If no date to compare, new Date() ("now") is used. * @return {Boolean} true if this date instance is less than the date to compare to (or "now"). */ $P.isBefore = function (date) { return (this.compareTo(date || new Date()) === -1); }; /** * Determines if the current Date instance occurs today. * @return {Boolean} true if this date instance is 'today', otherwise false. */ /** * Determines if the current Date instance occurs on the same Date as the supplied 'date'. * If no 'date' to compare to is provided, the current Date instance is compared to 'today'. * @param {date} Date object to compare. If no date to compare, the current Date ("now") is used. * @return {Boolean} true if this Date instance occurs on the same Day as the supplied 'date'. */ $P.isToday = $P.isSameDay = function (date) { return this.clone().clearTime().equals((date || new Date()).clone().clearTime()); }; /** * Adds the specified number of milliseconds to this instance. * @param {Number} The number of milliseconds to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addMilliseconds = function (value) { if (!value) { return this; } this.setTime(this.getTime() + value * 1); return this; }; /** * Adds the specified number of seconds to this instance. * @param {Number} The number of seconds to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addSeconds = function (value) { if (!value) { return this; } return this.addMilliseconds(value * 1000); }; /** * Adds the specified number of seconds to this instance. * @param {Number} The number of seconds to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addMinutes = function (value) { if (!value) { return this; } return this.addMilliseconds(value * 60000); // 60*1000 }; /** * Adds the specified number of hours to this instance. * @param {Number} The number of hours to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addHours = function (value) { if (!value) { return this; } return this.addMilliseconds(value * 3600000); // 60*60*1000 }; /** * Adds the specified number of days to this instance. * @param {Number} The number of days to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addDays = function (value) { if (!value) { return this; } this.setDate(this.getDate() + value * 1); return this; }; /** * Adds the specified number of weekdays (ie - not sat or sun) to this instance. * @param {Number} The number of days to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addWeekdays = function (value) { if (!value) { return this; } var day = this.getDay(); var weeks = (Math.ceil(Math.abs(value)/7)); if (day === 0 || day === 6) { if (value > 0) { this.next().monday(); this.addDays(-1); day = this.getDay(); } } if (value < 0) { while (value < 0) { this.addDays(-1); day = this.getDay(); if (day !== 0 && day !== 6) { value++; } } return this; } else if (value > 5 || (6-day) <= value) { value = value + (weeks * 2); } return this.addDays(value); }; /** * Adds the specified number of weeks to this instance. * @param {Number} The number of weeks to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addWeeks = function (value) { if (!value) { return this; } return this.addDays(value * 7); }; /** * Adds the specified number of months to this instance. * @param {Number} The number of months to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addMonths = function (value) { if (!value) { return this; } var n = this.getDate(); this.setDate(1); this.setMonth(this.getMonth() + value * 1); this.setDate(Math.min(n, $D.getDaysInMonth(this.getFullYear(), this.getMonth()))); return this; }; $P.addQuarters = function (value) { if (!value) { return this; } // note this will take you to the same point in the quarter as you are now. // i.e. - if you are 15 days into the quarter you'll be 15 days into the resulting one. // bonus: this allows adding fractional quarters return this.addMonths(value * 3); }; /** * Adds the specified number of years to this instance. * @param {Number} The number of years to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addYears = function (value) { if (!value) { return this; } return this.addMonths(value * 12); }; /** * Adds (or subtracts) to the value of the years, months, weeks, days, hours, minutes, seconds, milliseconds of the date instance using given configuration object. Positive and Negative values allowed. * Example

	Date.today().add( { days: 1, months: 1 } )

	new Date().add( { years: -1 } )
	
* @param {Object} Configuration object containing attributes (months, days, etc.) * @return {Date} this */ $P.add = function (config) { if (typeof config === "number") { this._orient = config; return this; } var x = config; if (x.day) { // If we should be a different date than today (eg: for 'tomorrow -1d', etc). // Should only effect parsing, not direct usage (eg, Finish and FinishExact) if ((x.day - this.getDate()) !== 0) { this.setDate(x.day); } } if (x.milliseconds) { this.addMilliseconds(x.milliseconds); } if (x.seconds) { this.addSeconds(x.seconds); } if (x.minutes) { this.addMinutes(x.minutes); } if (x.hours) { this.addHours(x.hours); } if (x.weeks) { this.addWeeks(x.weeks); } if (x.months) { this.addMonths(x.months); } if (x.years) { this.addYears(x.years); } if (x.days) { this.addDays(x.days); } return this; }; /** * Get the week number. Week one (1) is the week which contains the first Thursday of the year. Monday is considered the first day of the week. * The .getWeek() function does NOT convert the date to UTC. The local datetime is used. * Please use .getISOWeek() to get the week of the UTC converted date. * @return {Number} 1 to 53 */ $P.getWeek = function (utc) { // Create a copy of this date object var self, target = new Date(this.valueOf()); if (utc) { target.addMinutes(target.getTimezoneOffset()); self = target.clone(); } else { self = this; } // ISO week date weeks start on monday // so correct the day number var dayNr = (self.getDay() + 6) % 7; // ISO 8601 states that week 1 is the week // with the first thursday of that year. // Set the target date to the thursday in the target week target.setDate(target.getDate() - dayNr + 3); // Store the millisecond value of the target date var firstThursday = target.valueOf(); // Set the target to the first thursday of the year // First set the target to january first target.setMonth(0, 1); // Not a thursday? Correct the date to the next thursday if (target.getDay() !== 4) { target.setMonth(0, 1 + ((4 - target.getDay()) + 7) % 7); } // The weeknumber is the number of weeks between the // first thursday of the year and the thursday in the target week return 1 + Math.ceil((firstThursday - target) / 604800000); // 604800000 = 7 * 24 * 3600 * 1000 }; /** * Get the ISO 8601 week number. Week one ("01") is the week which contains the first Thursday of the year. Monday is considered the first day of the week. * The .getISOWeek() function does convert the date to it's UTC value. Please use .getWeek() to get the week of the local date. * @return {String} "01" to "53" */ $P.getISOWeek = function () { return p(this.getWeek(true)); }; /** * Moves the date to Monday of the week set. Week one (1) is the week which contains the first Thursday of the year. * @param {Number} A Number (1 to 53) that represents the week of the year. * @return {Date} this */ $P.setWeek = function (n) { if ((n - this.getWeek()) === 0) { if (this.getDay() !== 1) { return this.moveToDayOfWeek(1, (this.getDay() > 1 ? -1 : 1)); } else { return this; } } else { return this.moveToDayOfWeek(1, (this.getDay() > 1 ? -1 : 1)).addWeeks(n - this.getWeek()); } }; $P.setQuarter = function (qtr) { var month = Math.abs(((qtr-1) * 3) + 1); return this.setMonth(month, 1); }; $P.getQuarter = function () { return Date.getQuarter(this); }; $P.getDaysLeftInQuarter = function () { return Date.getDaysLeftInQuarter(this); }; /** * Moves the date to the next n'th occurrence of the dayOfWeek starting from the beginning of the month. The number (-1) is a magic number and will return the last occurrence of the dayOfWeek in the month. * @param {Number} The dayOfWeek to move to * @param {Number} The n'th occurrence to move to. Use (-1) to return the last occurrence in the month * @return {Date} this */ $P.moveToNthOccurrence = function (dayOfWeek, occurrence) { if (dayOfWeek === "Weekday") { if (occurrence > 0) { this.moveToFirstDayOfMonth(); if (this.is().weekday()) { occurrence -= 1; } } else if (occurrence < 0) { this.moveToLastDayOfMonth(); if (this.is().weekday()) { occurrence += 1; } } else { return this; } return this.addWeekdays(occurrence); } var shift = 0; if (occurrence > 0) { shift = occurrence - 1; } else if (occurrence === -1) { this.moveToLastDayOfMonth(); if (this.getDay() !== dayOfWeek) { this.moveToDayOfWeek(dayOfWeek, -1); } return this; } return this.moveToFirstDayOfMonth().addDays(-1).moveToDayOfWeek(dayOfWeek, +1).addWeeks(shift); }; var moveToN = function (getFunc, addFunc, nVal) { return function (value, orient) { var diff = (value - this[getFunc]() + nVal * (orient || +1)) % nVal; return this[addFunc]((diff === 0) ? diff += nVal * (orient || +1) : diff); }; }; /** * Move to the next or last dayOfWeek based on the orient value. * @param {Number} The dayOfWeek to move to * @param {Number} Forward (+1) or Back (-1). Defaults to +1. [Optional] * @return {Date} this */ $P.moveToDayOfWeek = moveToN("getDay", "addDays", 7); /** * Move to the next or last month based on the orient value. * @param {Number} The month to move to. 0 = January, 11 = December * @param {Number} Forward (+1) or Back (-1). Defaults to +1. [Optional] * @return {Date} this */ $P.moveToMonth = moveToN("getMonth", "addMonths", 12); /** * Get the Ordinate of the current day ("th", "st", "rd"). * @return {String} */ $P.getOrdinate = function () { var num = this.getDate(); return ord(num); }; /** * Get the Ordinal day (numeric day number) of the year, adjusted for leap year. * @return {Number} 1 through 365 (366 in leap years) */ $P.getOrdinalNumber = function () { return Math.ceil((this.clone().clearTime() - new Date(this.getFullYear(), 0, 1)) / 86400000) + 1; }; /** * Get the time zone abbreviation of the current date. * @return {String} The abbreviated time zone name (e.g. "EST") */ $P.getTimezone = function () { return $D.getTimezoneAbbreviation(this.getUTCOffset(), this.isDaylightSavingTime()); }; $P.setTimezoneOffset = function (offset) { var here = this.getTimezoneOffset(), there = Number(offset) * -6 / 10; return (there || there === 0) ? this.addMinutes(there - here) : this; }; $P.setTimezone = function (offset) { return this.setTimezoneOffset($D.getTimezoneOffset(offset)); }; /** * Indicates whether Daylight Saving Time is observed in the current time zone. * @return {Boolean} true|false */ $P.hasDaylightSavingTime = function () { return (Date.today().set({month: 0, day: 1}).getTimezoneOffset() !== Date.today().set({month: 6, day: 1}).getTimezoneOffset()); }; /** * Indicates whether this Date instance is within the Daylight Saving Time range for the current time zone. * @return {Boolean} true|false */ $P.isDaylightSavingTime = function () { return Date.today().set({month: 0, day: 1}).getTimezoneOffset() !== this.getTimezoneOffset(); }; /** * Get the offset from UTC of the current date. * @return {String} The 4-character offset string prefixed with + or - (e.g. "-0500") */ $P.getUTCOffset = function (offset) { var n = (offset || this.getTimezoneOffset()) * -10 / 6, r; if (n < 0) { r = (n - 10000).toString(); return r.charAt(0) + r.substr(2); } else { r = (n + 10000).toString(); return "+" + r.substr(1); } }; /** * Returns the number of milliseconds between this date and date. * @param {Date} Defaults to now * @return {Number} The diff in milliseconds */ $P.getElapsed = function (date) { return (date || new Date()) - this; }; /** * Set the value of year, month, day, hour, minute, second, millisecond of date instance using given configuration object. * Example

	Date.today().set( { day: 20, month: 1 } )

	new Date().set( { millisecond: 0 } )
	
* * @param {Object} Configuration object containing attributes (month, day, etc.) * @return {Date} this */ $P.set = function (config) { config = validateConfigObject.call(this, config); var key; for (key in config) { if (Object.prototype.hasOwnProperty.call(config, key)) { var name = key.charAt(0).toUpperCase() + key.slice(1); var addFunc, getFunc; if (key !== "week" && key !== "month" && key !== "timezone" && key !== "timezoneOffset") { name += "s"; } addFunc = "add" + name; getFunc = "get" + name; if (key === "month") { addFunc = addFunc + "s"; } else if (key === "year"){ getFunc = "getFullYear"; } if (key !== "day" && key !== "timezone" && key !== "timezoneOffset" && key !== "week" && key !== "hour") { this[addFunc](config[key] - this[getFunc]()); } else if ( key === "timezone"|| key === "timezoneOffset" || key === "week" || key === "hour") { this["set"+name](config[key]); } } } // day has to go last because you can't validate the day without first knowing the month if (config.day) { this.addDays(config.day - this.getDate()); } return this; }; /** * Moves the date to the first day of the month. * @return {Date} this */ $P.moveToFirstDayOfMonth = function () { return this.set({ day: 1 }); }; /** * Moves the date to the last day of the month. * @return {Date} this */ $P.moveToLastDayOfMonth = function () { return this.set({ day: $D.getDaysInMonth(this.getFullYear(), this.getMonth())}); }; /** * Converts the value of the current Date object to its equivalent string representation. * Format Specifiers * CUSTOM DATE AND TIME FORMAT STRINGS * Format Description Example * ------ --------------------------------------------------------------------------- ----------------------- * s The seconds of the minute between 0-59. "0" to "59" * ss The seconds of the minute with leading zero if required. "00" to "59" * * m The minute of the hour between 0-59. "0" or "59" * mm The minute of the hour with leading zero if required. "00" or "59" * * h The hour of the day between 1-12. "1" to "12" * hh The hour of the day with leading zero if required. "01" to "12" * * H The hour of the day between 0-23. "0" to "23" * HH The hour of the day with leading zero if required. "00" to "23" * * d The day of the month between 1 and 31. "1" to "31" * dd The day of the month with leading zero if required. "01" to "31" * ddd Abbreviated day name. Date.CultureInfo.abbreviatedDayNames. "Mon" to "Sun" * dddd The full day name. Date.CultureInfo.dayNames. "Monday" to "Sunday" * * M The month of the year between 1-12. "1" to "12" * MM The month of the year with leading zero if required. "01" to "12" * MMM Abbreviated month name. Date.CultureInfo.abbreviatedMonthNames. "Jan" to "Dec" * MMMM The full month name. Date.CultureInfo.monthNames. "January" to "December" * * yy The year as a two-digit number. "99" or "08" * yyyy The full four digit year. "1999" or "2008" * * t Displays the first character of the A.M./P.M. designator. "A" or "P" * Date.CultureInfo.amDesignator or Date.CultureInfo.pmDesignator * tt Displays the A.M./P.M. designator. "AM" or "PM" * Date.CultureInfo.amDesignator or Date.CultureInfo.pmDesignator * * S The ordinal suffix ("st, "nd", "rd" or "th") of the current day. "st, "nd", "rd" or "th" * * STANDARD DATE AND TIME FORMAT STRINGS * Format Description Example *------ --------------------------------------------------------------------------- ----------------------- * d The CultureInfo shortDate Format Pattern "M/d/yyyy" * D The CultureInfo longDate Format Pattern "dddd, MMMM dd, yyyy" * F The CultureInfo fullDateTime Format Pattern "dddd, MMMM dd, yyyy h:mm:ss tt" * m The CultureInfo monthDay Format Pattern "MMMM dd" * r The CultureInfo rfc1123 Format Pattern "ddd, dd MMM yyyy HH:mm:ss GMT" * s The CultureInfo sortableDateTime Format Pattern "yyyy-MM-ddTHH:mm:ss" * t The CultureInfo shortTime Format Pattern "h:mm tt" * T The CultureInfo longTime Format Pattern "h:mm:ss tt" * u The CultureInfo universalSortableDateTime Format Pattern "yyyy-MM-dd HH:mm:ssZ" * y The CultureInfo yearMonth Format Pattern "MMMM, yyyy" * * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @return {String} A string representation of the current Date object. */ var ord = function (n) { switch (n * 1) { case 1: case 21: case 31: return "st"; case 2: case 22: return "nd"; case 3: case 23: return "rd"; default: return "th"; } }; var parseStandardFormats = function (format) { var y, c = Date.CultureInfo.formatPatterns; switch (format) { case "d": return this.toString(c.shortDate); case "D": return this.toString(c.longDate); case "F": return this.toString(c.fullDateTime); case "m": return this.toString(c.monthDay); case "r": case "R": y = this.clone().addMinutes(this.getTimezoneOffset()); return y.toString(c.rfc1123) + " GMT"; case "s": return this.toString(c.sortableDateTime); case "t": return this.toString(c.shortTime); case "T": return this.toString(c.longTime); case "u": y = this.clone().addMinutes(this.getTimezoneOffset()); return y.toString(c.universalSortableDateTime); case "y": return this.toString(c.yearMonth); default: return false; } }; var parseFormatStringsClosure = function (context) { return function (m) { if (m.charAt(0) === "\\") { return m.replace("\\", ""); } switch (m) { case "hh": return p(context.getHours() < 13 ? (context.getHours() === 0 ? 12 : context.getHours()) : (context.getHours() - 12)); case "h": return context.getHours() < 13 ? (context.getHours() === 0 ? 12 : context.getHours()) : (context.getHours() - 12); case "HH": return p(context.getHours()); case "H": return context.getHours(); case "mm": return p(context.getMinutes()); case "m": return context.getMinutes(); case "ss": return p(context.getSeconds()); case "s": return context.getSeconds(); case "yyyy": return p(context.getFullYear(), 4); case "yy": return p(context.getFullYear()); case "y": return context.getFullYear(); case "E": case "dddd": return Date.CultureInfo.dayNames[context.getDay()]; case "ddd": return Date.CultureInfo.abbreviatedDayNames[context.getDay()]; case "dd": return p(context.getDate()); case "d": return context.getDate(); case "MMMM": return Date.CultureInfo.monthNames[context.getMonth()]; case "MMM": return Date.CultureInfo.abbreviatedMonthNames[context.getMonth()]; case "MM": return p((context.getMonth() + 1)); case "M": return context.getMonth() + 1; case "t": return context.getHours() < 12 ? Date.CultureInfo.amDesignator.substring(0, 1) : Date.CultureInfo.pmDesignator.substring(0, 1); case "tt": return context.getHours() < 12 ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator; case "S": return ord(context.getDate()); case "W": return context.getWeek(); case "WW": return context.getISOWeek(); case "Q": return "Q" + context.getQuarter(); case "q": return String(context.getQuarter()); case "z": return context.getTimezone(); case "Z": case "X": return Date.getTimezoneOffset(context.getTimezone()); case "ZZ": // Timezone offset in seconds return context.getTimezoneOffset() * -60; case "u": return context.getDay(); case "L": return ($D.isLeapYear(context.getFullYear())) ? 1 : 0; case "B": // Swatch Internet Time (.beats) return "@"+((context.getUTCSeconds() + (context.getUTCMinutes()*60) + ((context.getUTCHours()+1)*3600))/86.4); default: return m; } }; }; $P.toString = function (format, ignoreStandards) { // Standard Date and Time Format Strings. Formats pulled from CultureInfo file and // may vary by culture. if (!ignoreStandards && format && format.length === 1) { output = parseStandardFormats.call(this, format); if (output) { return output; } } var parseFormatStrings = parseFormatStringsClosure(this); return format ? format.replace(/((\\)?(dd?d?d?|MM?M?M?|yy?y?y?|hh?|HH?|mm?|ss?|tt?|S|q|Q|WW?W?W?)(?![^\[]*\]))/g, parseFormatStrings).replace(/\[|\]/g, "") : this._toString(); }; }()); /************************************************************* * SugarPak - Domain Specific Language - Syntactical Sugar * *************************************************************/ (function () { var $D = Date, $P = $D.prototype, $N = Number.prototype; // private $P._orient = +1; // private $P._nth = null; // private $P._is = false; // private $P._same = false; // private $P._isSecond = false; // private $N._dateElement = "days"; /** * Moves the date to the next instance of a date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.today().next().friday();
	Date.today().next().fri();
	Date.today().next().march();
	Date.today().next().mar();
	Date.today().next().week();
	
* * @return {Date} date */ $P.next = function () { this._move = true; this._orient = +1; return this; }; /** * Creates a new Date (Date.today()) and moves the date to the next instance of the date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.next().friday();
	Date.next().fri();
	Date.next().march();
	Date.next().mar();
	Date.next().week();
	
* * @return {Date} date */ $D.next = function () { return $D.today().next(); }; /** * Moves the date to the previous instance of a date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.today().last().friday();
	Date.today().last().fri();
	Date.today().last().march();
	Date.today().last().mar();
	Date.today().last().week();
	
* * @return {Date} date */ $P.last = $P.prev = $P.previous = function () { this._move = true; this._orient = -1; return this; }; /** * Creates a new Date (Date.today()) and moves the date to the previous instance of the date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.last().friday();
	Date.last().fri();
	Date.previous().march();
	Date.prev().mar();
	Date.last().week();
	
* * @return {Date} date */ $D.last = $D.prev = $D.previous = function () { return $D.today().last(); }; /** * Performs a equality check when followed by either a month name, day name or .weekday() function. * Example

	Date.today().is().friday(); // true|false
	Date.today().is().fri();
	Date.today().is().march();
	Date.today().is().mar();
	
* * @return {Boolean} true|false */ $P.is = function () { this._is = true; return this; }; /** * Determines if two date objects occur on/in exactly the same instance of the subsequent date part function. * The function .same() must be followed by a date part function (example: .day(), .month(), .year(), etc). * * An optional Date can be passed in the date part function. If now date is passed as a parameter, 'Now' is used. * * The following example demonstrates how to determine if two dates fall on the exact same day. * * Example

	var d1 = Date.today(); // today at 00:00
	var d2 = new Date();   // exactly now.

	// Do they occur on the same day?
	d1.same().day(d2); // true
	
	// Do they occur on the same hour?
	d1.same().hour(d2); // false, unless d2 hour is '00' (midnight).
	
	// What if it's the same day, but one year apart?
	var nextYear = Date.today().add(1).year();

	d1.same().day(nextYear); // false, because the dates must occur on the exact same day. 
	
* * Scenario: Determine if a given date occurs during some week period 2 months from now. * * Example

	var future = Date.today().add(2).months();
	return someDate.same().week(future); // true|false;
	
* * @return {Boolean} true|false */ $P.same = function () { this._same = true; this._isSecond = false; return this; }; /** * Determines if the current date/time occurs during Today. Must be preceded by the .is() function. * Example

	someDate.is().today();    // true|false
	new Date().is().today();  // true
	Date.today().is().today();// true
	Date.today().add(-1).day().is().today(); // false
	
* * @return {Boolean} true|false */ $P.today = function () { return this.same().day(); }; /** * Determines if the current date is a weekday. This function must be preceded by the .is() function. * Example

	Date.today().is().weekday(); // true|false
	
* * @return {Boolean} true|false */ $P.weekday = function () { if (this._nth) { return df("Weekday").call(this); } if (this._move) { return this.addWeekdays(this._orient); } if (this._is) { this._is = false; return (!this.is().sat() && !this.is().sun()); } return false; }; /** * Determines if the current date is on the weekend. This function must be preceded by the .is() function. * Example

	Date.today().is().weekend(); // true|false
	
* * @return {Boolean} true|false */ $P.weekend = function () { if (this._is) { this._is = false; return (this.is().sat() || this.is().sun()); } return false; }; /** * Sets the Time of the current Date instance. A string "6:15 pm" or config object {hour:18, minute:15} are accepted. * Example

	// Set time to 6:15pm with a String
	Date.today().at("6:15pm");

	// Set time to 6:15pm with a config object
	Date.today().at({hour:18, minute:15});
	
* * @return {Date} date */ $P.at = function (time) { return (typeof time === "string") ? $D.parse(this.toString("d") + " " + time) : this.set(time); }; /** * Creates a new Date() and adds this (Number) to the date based on the preceding date element function (eg. second|minute|hour|day|month|year). * Example

	// Undeclared Numbers must be wrapped with parentheses. Requirment of JavaScript.
	(3).days().fromNow();
	(6).months().fromNow();

	// Declared Number variables do not require parentheses. 
	var n = 6;
	n.months().fromNow();
	
* * @return {Date} A new Date instance */ $N.fromNow = $N.after = function (date) { var c = {}; c[this._dateElement] = this; return ((!date) ? new Date() : date.clone()).add(c); }; /** * Creates a new Date() and subtract this (Number) from the date based on the preceding date element function (eg. second|minute|hour|day|month|year). * Example

	// Undeclared Numbers must be wrapped with parentheses. Requirment of JavaScript.
	(3).days().ago();
	(6).months().ago();

	// Declared Number variables do not require parentheses. 
	var n = 6;
	n.months().ago();
	
* * @return {Date} A new Date instance */ $N.ago = $N.before = function (date) { var c = {}, s = (this._dateElement[this._dateElement.length-1] !== "s") ? this._dateElement + "s" : this._dateElement; c[s] = this * -1; return ((!date) ? new Date() : date.clone()).add(c); }; // Do NOT modify the following string tokens. These tokens are used to build dynamic functions. // All culture-specific strings can be found in the CultureInfo files. var dx = ("sunday monday tuesday wednesday thursday friday saturday").split(/\s/), mx = ("january february march april may june july august september october november december").split(/\s/), px = ("Millisecond Second Minute Hour Day Week Month Year Quarter Weekday").split(/\s/), pxf = ("Milliseconds Seconds Minutes Hours Date Week Month FullYear Quarter").split(/\s/), nth = ("final first second third fourth fifth").split(/\s/), de; /** * Returns an object literal of all the date parts. * Example

	var o = new Date().toObject();
	
	// { year: 2008, month: 4, week: 20, day: 13, hour: 18, minute: 9, second: 32, millisecond: 812 }
	
	// The object properties can be referenced directly from the object.
	
	alert(o.day);  // alerts "13"
	alert(o.year); // alerts "2008"
	
* * @return {Date} An object literal representing the original date object. */ $P.toObject = function () { var o = {}; for (var i = 0; i < px.length; i++) { if (this["get" + pxf[i]]) { o[px[i].toLowerCase()] = this["get" + pxf[i]](); } } return o; }; /** * Returns a date created from an object literal. Ignores the .week property if set in the config. * Example

	var o = new Date().toObject();
	
	return Date.fromObject(o); // will return the same date. 

	var o2 = {month: 1, day: 20, hour: 18}; // birthday party!
	Date.fromObject(o2);
	
* * @return {Date} An object literal representing the original date object. */ $D.fromObject = function(config) { config.week = null; return Date.today().set(config); }; // Create day name functions and abbreviated day name functions (eg. monday(), friday(), fri()). var df = function (n) { return function () { if (this._is) { this._is = false; return this.getDay() === n; } if (this._move) { this._move = null; } if (this._nth !== null) { // If the .second() function was called earlier, remove the _orient // from the date, and then continue. // This is required because 'second' can be used in two different context. // // Example // // Date.today().add(1).second(); // Date.march().second().monday(); // // Things get crazy with the following... // Date.march().add(1).second().second().monday(); // but it works!! // if (this._isSecond) { this.addSeconds(this._orient * -1); } // make sure we reset _isSecond this._isSecond = false; var ntemp = this._nth; this._nth = null; var temp = this.clone().moveToLastDayOfMonth(); this.moveToNthOccurrence(n, ntemp); if (this > temp) { throw new RangeError($D.getDayName(n) + " does not occur " + ntemp + " times in the month of " + $D.getMonthName(temp.getMonth()) + " " + temp.getFullYear() + "."); } return this; } return this.moveToDayOfWeek(n, this._orient); }; }; var sdf = function (n) { return function () { var t = $D.today(), shift = n - t.getDay(); if (n === 0 && Date.CultureInfo.firstDayOfWeek === 1 && t.getDay() !== 0) { shift = shift + 7; } return t.addDays(shift); }; }; // Create month name functions and abbreviated month name functions (eg. january(), march(), mar()). var month_instance_functions = function (n) { return function () { if (this._is) { this._is = false; return this.getMonth() === n; } return this.moveToMonth(n, this._orient); }; }; var month_static_functions = function (n) { return function () { return $D.today().set({ month: n, day: 1 }); }; }; var processTerms = function (names, staticFunc, instanceFunc) { for (var i = 0; i < names.length; i++) { // Create constant static Name variables. $D[names[i].toUpperCase()] = $D[names[i].toUpperCase().substring(0, 3)] = i; // Create Name functions. $D[names[i]] = $D[names[i].substring(0, 3)] = staticFunc(i); // Create Name instance functions. $P[names[i]] = $P[names[i].substring(0, 3)] = instanceFunc(i); } }; processTerms(dx, sdf, df); processTerms(mx, month_static_functions, month_instance_functions); // Create date element functions and plural date element functions used with Date (eg. day(), days(), months()). var ef = function (j) { return function () { // if the .second() function was called earlier, the _orient // has alread been added. Just return this and reset _isSecond. if (this._isSecond) { this._isSecond = false; return this; } if (this._same) { this._same = this._is = false; var o1 = this.toObject(), o2 = (arguments[0] || new Date()).toObject(), v = "", k = j.toLowerCase(); // the substr trick with -1 doesn't work in IE8 or less k = (k[k.length-1] === "s") ? k.substring(0,k.length-1) : k; for (var m = (px.length - 1); m > -1; m--) { v = px[m].toLowerCase(); if (o1[v] !== o2[v]) { return false; } if (k === v) { break; } } return true; } if (j.substring(j.length - 1) !== "s") { j += "s"; } if (this._move) { this._move = null; } return this["add" + j](this._orient); }; }; var nf = function (n) { return function () { this._dateElement = n; return this; }; }; for (var k = 0; k < px.length; k++) { de = px[k].toLowerCase(); if(de !== "weekday") { // Create date element functions and plural date element functions used with Date (eg. day(), days(), months()). $P[de] = $P[de + "s"] = ef(px[k]); // Create date element functions and plural date element functions used with Number (eg. day(), days(), months()). $N[de] = $N[de + "s"] = nf(de + "s"); } } $P._ss = ef("Second"); var nthfn = function (n) { return function (dayOfWeek) { if (this._same) { return this._ss(arguments[0]); } if (dayOfWeek || dayOfWeek === 0) { return this.moveToNthOccurrence(dayOfWeek, n); } this._nth = n; // if the operator is 'second' add the _orient, then deal with it later... if (n === 2 && (dayOfWeek === undefined || dayOfWeek === null)) { this._isSecond = true; return this.addSeconds(this._orient); } return this; }; }; for (var l = 0; l < nth.length; l++) { $P[nth[l]] = (l === 0) ? nthfn(-1) : nthfn(l); } }()); (function () { "use strict"; Date.Parsing = { Exception: function (s) { this.message = "Parse error at '" + s.substring(0, 10) + " ...'"; } }; var $P = Date.Parsing; var dayOffsets = { standard: [0,31,59,90,120,151,181,212,243,273,304,334], leap: [0,31,60,91,121,152,182,213,244,274,305,335] }; $P.isLeapYear = function(year) { return ((year % 4 === 0) && (year % 100 !== 0)) || (year % 400 === 0); }; var utils = { multiReplace : function (str, hash ) { var key; for (key in hash) { if (Object.prototype.hasOwnProperty.call(hash, key)) { var regex; if (typeof hash[key] === "function") { } else { regex = (hash[key] instanceof RegExp) ? hash[key] : new RegExp(hash[key], "g"); } str = str.replace(regex, key); } } return str; }, getDayOfYearFromWeek : function (obj) { var d, jan4, offset; obj.weekDay = (!obj.weekDay && obj.weekDay !== 0) ? 1 : obj.weekDay; d = new Date(obj.year, 0, 4); jan4 = d.getDay() === 0 ? 7 : d.getDay(); // JS is 0 indexed on Sunday. offset = jan4+3; obj.dayOfYear = ((obj.week * 7) + (obj.weekDay === 0 ? 7 : obj.weekDay))-offset; return obj; }, getDayOfYear : function (obj, dayOffset) { if (!obj.dayOfYear) { obj = utils.getDayOfYearFromWeek(obj); } for (var i=0;i <= dayOffset.length;i++) { if (obj.dayOfYear < dayOffset[i] || i === dayOffset.length) { obj.day = obj.day ? obj.day : (obj.dayOfYear - dayOffset[i-1]); break; } else { obj.month = i; } } return obj; }, adjustForTimeZone : function (obj, date) { var offset; if (obj.zone.toUpperCase() === "Z" || (obj.zone_hours === 0 && obj.zone_minutes === 0)) { // it's UTC/GML so work out the current timeszone offset offset = -date.getTimezoneOffset(); } else { offset = (obj.zone_hours*60) + (obj.zone_minutes || 0); if (obj.zone_sign === "+") { offset *= -1; } offset -= date.getTimezoneOffset(); } date.setMinutes(date.getMinutes()+offset); return date; }, setDefaults : function (obj) { obj.year = obj.year || Date.today().getFullYear(); obj.hours = obj.hours || 0; obj.minutes = obj.minutes || 0; obj.seconds = obj.seconds || 0; obj.milliseconds = obj.milliseconds || 0; if (!(!obj.month && (obj.week || obj.dayOfYear))) { // if we have a month, or if we don't but don't have the day calculation data obj.month = obj.month || 0; obj.day = obj.day || 1; } return obj; }, dataNum: function (data, mod, explict, postProcess) { var dataNum = data*1; if (mod) { if (postProcess) { return data ? mod(data)*1 : data; } else { return data ? mod(dataNum) : data; } } else if (!explict){ return data ? dataNum : data; } else { return (data && typeof data !== "undefined") ? dataNum : data; } }, timeDataProcess: function (obj) { var timeObj = {}; for (var x in obj.data) { if (obj.data.hasOwnProperty(x)) { timeObj[x] = obj.ignore[x] ? obj.data[x] : utils.dataNum(obj.data[x], obj.mods[x], obj.explict[x], obj.postProcess[x]); } } if (obj.data.secmins) { obj.data.secmins = obj.data.secmins.replace(",", ".") * 60; if (!timeObj.minutes) { timeObj.minutes = obj.data.secmins; } else if (!timeObj.seconds) { timeObj.seconds = obj.data.secmins; } delete obj.secmins; } return timeObj; }, buildTimeObjectFromData: function (data) { var time = utils.timeDataProcess({ data: { year : data[1], month : data[5], day : data[7], week : data[8], dayOfYear : data[10], hours : data[15], zone_hours : data[23], zone_minutes : data[24], zone : data[21], zone_sign : data[22], weekDay : data[9], minutes: data[16], seconds: data[19], milliseconds: data[20], secmins: data[18] }, mods: { month: function(data) { return data-1; }, weekDay: function (data) { data = Math.abs(data); return (data === 7 ? 0 : data); }, minutes: function (data) { return data.replace(":",""); }, seconds: function (data) { return Math.floor( (data.replace(":","").replace(",","."))*1 ); }, milliseconds: function (data) { return (data.replace(",",".")*1000); } }, postProcess: { minutes: true, seconds: true, milliseconds: true }, explict: { zone_hours: true, zone_minutes: true }, ignore: { zone: true, zone_sign: true, secmins: true } }); return time; }, addToHash: function (hash, keys, data) { keys = keys; data = data; var len = keys.length; for (var i = 0; i < len; i++) { hash[keys[i]] = data[i]; } return hash; }, combineRegex: function (r1, r2) { return new RegExp("(("+r1.source+")\\s("+r2.source+"))"); }, getDateNthString: function(add, last, inc){ if (add) { return Date.today().addDays(inc).toString("d"); } else if (last) { return Date.today().last()[inc]().toString("d"); } }, buildRegexData: function (array) { var arr = []; var len = array.length; for (var i=0; i < len; i++) { if (Object.prototype.toString.call(array[i]) === '[object Array]') { // oldIE compat version of Array.isArray arr.push(this.combineRegex(array[i][0], array[i][1])); } else { arr.push(array[i]); } } return arr; } }; $P.processTimeObject = function (obj) { var date, dayOffset; utils.setDefaults(obj); dayOffset = ($P.isLeapYear(obj.year)) ? dayOffsets.leap : dayOffsets.standard; if (!obj.month && (obj.week || obj.dayOfYear)) { utils.getDayOfYear(obj, dayOffset); } else { obj.dayOfYear = dayOffset[obj.month] + obj.day; } date = new Date(obj.year, obj.month, obj.day, obj.hours, obj.minutes, obj.seconds, obj.milliseconds); if (obj.zone) { utils.adjustForTimeZone(obj, date); // adjust (and calculate) for timezone } return date; }; $P.ISO = { regex : /^([\+-]?\d{4}(?!\d{2}\b))((-?)((0[1-9]|1[0-2])(\3([12]\d|0[1-9]|3[01]))?|W([0-4]\d|5[0-3])(-?[1-7])?|(00[1-9]|0[1-9]\d|[12]\d{2}|3([0-5]\d|6[1-6])))([T\s]((([01]\d|2[0-4])((:?)[0-5]\d)?|24\:?00)([\.,]\d+(?!:))?)?(\17[0-5]\d([\.,]\d+)?)?\s?([zZ]|([\+-])([01]\d|2[0-3]):?([0-5]\d)?)?)?)?$/, parse : function (s) { var time, data = s.match(this.regex); if (!data || !data.length) { return null; } time = utils.buildTimeObjectFromData(data); if (!time.year || (!time.year && (!time.month && !time.day) && (!time.week && !time.dayOfYear)) ) { return null; } return $P.processTimeObject(time); } }; $P.Numeric = { isNumeric: function (e){return!isNaN(parseFloat(e))&&isFinite(e);}, regex: /\b([0-1]?[0-9])([0-3]?[0-9])([0-2]?[0-9]?[0-9][0-9])\b/i, parse: function (s) { var data, i, time = {}, order = Date.CultureInfo.dateElementOrder.split(""); if (!(this.isNumeric(s)) || // if it's non-numeric OR (s[0] === "+" && s[0] === "-")) { // It's an arithmatic string (eg +/-1000) return null; } if (s.length < 5 && s.indexOf(".") < 0 && s.indexOf("/") < 0) { // assume it's just a year. time.year = s; return $P.processTimeObject(time); } data = s.match(this.regex); if (!data || !data.length) { return null; } for (i=0; i < order.length; i++) { switch(order[i]) { case "d": time.day = data[i+1]; break; case "m": time.month = (data[i+1]-1); break; case "y": time.year = data[i+1]; break; } } return $P.processTimeObject(time); } }; $P.Normalizer = { regexData: function () { var $R = Date.CultureInfo.regexPatterns; return utils.buildRegexData([ $R.tomorrow, $R.yesterday, [$R.past, $R.mon], [$R.past, $R.tue], [$R.past, $R.wed], [$R.past, $R.thu], [$R.past, $R.fri], [$R.past, $R.sat], [$R.past, $R.sun] ]); }, basicReplaceHash : function() { var $R = Date.CultureInfo.regexPatterns; return { "January": $R.jan.source, "February": $R.feb, "March": $R.mar, "April": $R.apr, "May": $R.may, "June": $R.jun, "July": $R.jul, "August": $R.aug, "September": $R.sep, "October": $R.oct, "November": $R.nov, "December": $R.dec, "": /\bat\b/gi, " ": /\s{2,}/, "am": $R.inTheMorning, "9am": $R.thisMorning, "pm": $R.inTheEvening, "7pm":$R.thisEvening }; }, keys : function(){ return [ utils.getDateNthString(true, false, 1), // tomorrow utils.getDateNthString(true, false, -1), // yesterday utils.getDateNthString(false, true, "monday"), //last mon utils.getDateNthString(false, true, "tuesday"), //last tues utils.getDateNthString(false, true, "wednesday"), //last wed utils.getDateNthString(false, true, "thursday"), //last thurs utils.getDateNthString(false, true, "friday"), //last fri utils.getDateNthString(false, true, "saturday"), //last sat utils.getDateNthString(false, true, "sunday") //last sun ]; }, buildRegexFunctions: function () { var $R = Date.CultureInfo.regexPatterns; var __ = Date.i18n.__; var tomorrowRE = new RegExp("(\\b\\d\\d?("+__("AM")+"|"+__("PM")+")? )("+$R.tomorrow.source.slice(1)+")", "i"); // adapted tomorrow regex for AM PM relative dates var todayRE = new RegExp($R.today.source + "(?!\\s*([+-]))\\b"); // today, but excludes the math operators (eg "today + 2h") this.replaceFuncs = [ [todayRE, function (full) { return (full.length > 1) ? Date.today().toString("d") : full; }], [tomorrowRE, function(full, m1) { var t = Date.today().addDays(1).toString("d"); return (t + " " + m1); }], [$R.amThisMorning, function(str, am){return am;}], [$R.pmThisEvening, function(str, pm){return pm;}] ]; }, buildReplaceData: function () { this.buildRegexFunctions(); this.replaceHash = utils.addToHash(this.basicReplaceHash(), this.keys(), this.regexData()); }, stringReplaceFuncs: function (s) { for (var i=0; i < this.replaceFuncs.length; i++) { s = s.replace(this.replaceFuncs[i][0], this.replaceFuncs[i][1]); } return s; }, parse: function (s) { s = this.stringReplaceFuncs(s); s = utils.multiReplace(s, this.replaceHash); try { var n = s.split(/([\s\-\.\,\/\x27]+)/); if (n.length === 3 && $P.Numeric.isNumeric(n[0]) && $P.Numeric.isNumeric(n[2]) && (n[2].length >= 4)) { // ok, so we're dealing with x/year. But that's not a full date. // This fixes wonky dateElementOrder parsing when set to dmy order. if (Date.CultureInfo.dateElementOrder[0] === "d") { s = "1/" + n[0] + "/" + n[2]; // set to 1st of month and normalize the seperator } } } catch (e) {} return s; } }; $P.Normalizer.buildReplaceData(); }()); (function () { var $P = Date.Parsing; var _ = $P.Operators = { // // Tokenizers // rtoken: function (r) { // regex token return function (s) { var mx = s.match(r); if (mx) { return ([ mx[0], s.substring(mx[0].length) ]); } else { throw new $P.Exception(s); } }; }, token: function () { // whitespace-eating token return function (s) { return _.rtoken(new RegExp("^\\s*" + s + "\\s*"))(s); }; }, stoken: function (s) { // string token return _.rtoken(new RegExp("^" + s)); }, // Atomic Operators until: function (p) { return function (s) { var qx = [], rx = null; while (s.length) { try { rx = p.call(this, s); } catch (e) { qx.push(rx[0]); s = rx[1]; continue; } break; } return [ qx, s ]; }; }, many: function (p) { return function (s) { var rx = [], r = null; while (s.length) { try { r = p.call(this, s); } catch (e) { return [ rx, s ]; } rx.push(r[0]); s = r[1]; } return [ rx, s ]; }; }, // generator operators -- see below optional: function (p) { return function (s) { var r = null; try { r = p.call(this, s); } catch (e) { return [ null, s ]; } return [ r[0], r[1] ]; }; }, not: function (p) { return function (s) { try { p.call(this, s); } catch (e) { return [null, s]; } throw new $P.Exception(s); }; }, ignore: function (p) { return p ? function (s) { var r = null; r = p.call(this, s); return [null, r[1]]; } : null; }, product: function () { var px = arguments[0], qx = Array.prototype.slice.call(arguments, 1), rx = []; for (var i = 0 ; i < px.length ; i++) { rx.push(_.each(px[i], qx)); } return rx; }, cache: function (rule) { var cache = {}, cache_length = 0, cache_keys = [], CACHE_MAX = Date.Config.CACHE_MAX || 100000, r = null; var cacheCheck = function () { if (cache_length === CACHE_MAX) { // kill several keys, don't want to have to do this all the time... for (var i=0; i < 10; i++) { var key = cache_keys.shift(); if (key) { delete cache[key]; cache_length--; } } } }; return function (s) { cacheCheck(); try { r = cache[s] = (cache[s] || rule.call(this, s)); } catch (e) { r = cache[s] = e; } cache_length++; cache_keys.push(s); if (r instanceof $P.Exception) { throw r; } else { return r; } }; }, // vector operators -- see below any: function () { var px = arguments; return function (s) { var r = null; for (var i = 0; i < px.length; i++) { if (px[i] == null) { continue; } try { r = (px[i].call(this, s)); } catch (e) { r = null; } if (r) { return r; } } throw new $P.Exception(s); }; }, each: function () { var px = arguments; return function (s) { var rx = [], r = null; for (var i = 0; i < px.length ; i++) { if (px[i] == null) { continue; } try { r = (px[i].call(this, s)); } catch (e) { throw new $P.Exception(s); } rx.push(r[0]); s = r[1]; } return [ rx, s]; }; }, all: function () { var px = arguments, _ = _; return _.each(_.optional(px)); }, // delimited operators sequence: function (px, d, c) { d = d || _.rtoken(/^\s*/); c = c || null; if (px.length === 1) { return px[0]; } return function (s) { var r = null, q = null; var rx = []; for (var i = 0; i < px.length ; i++) { try { r = px[i].call(this, s); } catch (e) { break; } rx.push(r[0]); try { q = d.call(this, r[1]); } catch (ex) { q = null; break; } s = q[1]; } if (!r) { throw new $P.Exception(s); } if (q) { throw new $P.Exception(q[1]); } if (c) { try { r = c.call(this, r[1]); } catch (ey) { throw new $P.Exception(r[1]); } } return [ rx, (r?r[1]:s) ]; }; }, // // Composite Operators // between: function (d1, p, d2) { d2 = d2 || d1; var _fn = _.each(_.ignore(d1), p, _.ignore(d2)); return function (s) { var rx = _fn.call(this, s); return [[rx[0][0], r[0][2]], rx[1]]; }; }, list: function (p, d, c) { d = d || _.rtoken(/^\s*/); c = c || null; return (p instanceof Array ? _.each(_.product(p.slice(0, -1), _.ignore(d)), p.slice(-1), _.ignore(c)) : _.each(_.many(_.each(p, _.ignore(d))), px, _.ignore(c))); }, set: function (px, d, c) { d = d || _.rtoken(/^\s*/); c = c || null; return function (s) { // r is the current match, best the current 'best' match // which means it parsed the most amount of input var r = null, p = null, q = null, rx = null, best = [[], s], last = false; // go through the rules in the given set for (var i = 0; i < px.length ; i++) { // last is a flag indicating whether this must be the last element // if there is only 1 element, then it MUST be the last one q = null; p = null; r = null; last = (px.length === 1); // first, we try simply to match the current pattern // if not, try the next pattern try { r = px[i].call(this, s); } catch (e) { continue; } // since we are matching against a set of elements, the first // thing to do is to add r[0] to matched elements rx = [[r[0]], r[1]]; // if we matched and there is still input to parse and // we don't already know this is the last element, // we're going to next check for the delimiter ... // if there's none, or if there's no input left to parse // than this must be the last element after all ... if (r[1].length > 0 && ! last) { try { q = d.call(this, r[1]); } catch (ex) { last = true; } } else { last = true; } // if we parsed the delimiter and now there's no more input, // that means we shouldn't have parsed the delimiter at all // so don't update r and mark this as the last element ... if (!last && q[1].length === 0) { last = true; } // so, if this isn't the last element, we're going to see if // we can get any more matches from the remaining (unmatched) // elements ... if (!last) { // build a list of the remaining rules we can match against, // i.e., all but the one we just matched against var qx = []; for (var j = 0; j < px.length ; j++) { if (i !== j) { qx.push(px[j]); } } // now invoke recursively set with the remaining input // note that we don't include the closing delimiter ... // we'll check for that ourselves at the end p = _.set(qx, d).call(this, q[1]); // if we got a non-empty set as a result ... // (otw rx already contains everything we want to match) if (p[0].length > 0) { // update current result, which is stored in rx ... // basically, pick up the remaining text from p[1] // and concat the result from p[0] so that we don't // get endless nesting ... rx[0] = rx[0].concat(p[0]); rx[1] = p[1]; } } // at this point, rx either contains the last matched element // or the entire matched set that starts with this element. // now we just check to see if this variation is better than // our best so far, in terms of how much of the input is parsed if (rx[1].length < best[1].length) { best = rx; } // if we've parsed all the input, then we're finished if (best[1].length === 0) { break; } } // so now we've either gone through all the patterns trying them // as the initial match; or we found one that parsed the entire // input string ... // if best has no matches, just return empty set ... if (best[0].length === 0) { return best; } // if a closing delimiter is provided, then we have to check it also if (c) { // we try this even if there is no remaining input because the pattern // may well be optional or match empty input ... try { q = c.call(this, best[1]); } catch (ey) { throw new $P.Exception(best[1]); } // it parsed ... be sure to update the best match remaining input best[1] = q[1]; } // if we're here, either there was no closing delimiter or we parsed it // so now we have the best match; just return it! return best; }; }, forward: function (gr, fname) { return function (s) { return gr[fname].call(this, s); }; }, // // Translation Operators // replace: function (rule, repl) { return function (s) { var r = rule.call(this, s); return [repl, r[1]]; }; }, process: function (rule, fn) { return function (s) { var r = rule.call(this, s); return [fn.call(this, r[0]), r[1]]; }; }, min: function (min, rule) { return function (s) { var rx = rule.call(this, s); if (rx[0].length < min) { throw new $P.Exception(s); } return rx; }; } }; // Generator Operators And Vector Operators // Generators are operators that have a signature of F(R) => R, // taking a given rule and returning another rule, such as // ignore, which parses a given rule and throws away the result. // Vector operators are those that have a signature of F(R1,R2,...) => R, // take a list of rules and returning a new rule, such as each. // Generator operators are converted (via the following _generator // function) into functions that can also take a list or array of rules // and return an array of new rules as though the function had been // called on each rule in turn (which is what actually happens). // This allows generators to be used with vector operators more easily. // Example: // each(ignore(foo, bar)) instead of each(ignore(foo), ignore(bar)) // This also turns generators into vector operators, which allows // constructs like: // not(cache(foo, bar)) var _generator = function (op) { function gen() { var args = null, rx = [], px, i; if (arguments.length > 1) { args = Array.prototype.slice.call(arguments); } else if (arguments[0] instanceof Array) { args = arguments[0]; } if (args) { px = args.shift(); if (px.length > 0) { args.unshift(px[i]); rx.push(op.apply(null, args)); args.shift(); return rx; } } else { return op.apply(null, arguments); } } return gen; }; var gx = "optional not ignore cache".split(/\s/); for (var i = 0 ; i < gx.length ; i++) { _[gx[i]] = _generator(_[gx[i]]); } var _vector = function (op) { return function () { if (arguments[0] instanceof Array) { return op.apply(null, arguments[0]); } else { return op.apply(null, arguments); } }; }; var vx = "each any all".split(/\s/); for (var j = 0 ; j < vx.length ; j++) { _[vx[j]] = _vector(_[vx[j]]); } }()); (function () { var $D = Date; var flattenAndCompact = function (ax) { var rx = []; for (var i = 0; i < ax.length; i++) { if (ax[i] instanceof Array) { rx = rx.concat(flattenAndCompact(ax[i])); } else { if (ax[i]) { rx.push(ax[i]); } } } return rx; }; var parseMeridian = function () { if (this.meridian && (this.hour || this.hour === 0)) { if (this.meridian === "a" && this.hour > 11 && Date.Config.strict24hr){ throw "Invalid hour and meridian combination"; } else if (this.meridian === "p" && this.hour < 12 && Date.Config.strict24hr){ throw "Invalid hour and meridian combination"; } else if (this.meridian === "p" && this.hour < 12) { this.hour = this.hour + 12; } else if (this.meridian === "a" && this.hour === 12) { this.hour = 0; } } }; var setDefaults = function () { var now = new Date(); if ((this.hour || this.minute) && (!this.month && !this.year && !this.day)) { this.day = now.getDate(); } if (!this.year) { this.year = now.getFullYear(); } if (!this.month && this.month !== 0) { this.month = now.getMonth(); } if (!this.day) { this.day = 1; } if (!this.hour) { this.hour = 0; } if (!this.minute) { this.minute = 0; } if (!this.second) { this.second = 0; } if (!this.millisecond) { this.millisecond = 0; } }; var finishUtils = { getToday: function () { if (this.now || "hour minute second".indexOf(this.unit) !== -1) { return new Date(); } else { return $D.today(); } }, setDaysFromWeekday: function (today, orient){ var gap; orient = orient || 1; this.unit = "day"; gap = ($D.getDayNumberFromName(this.weekday) - today.getDay()); this.days = gap ? ((gap + (orient * 7)) % 7) : (orient * 7); return this; }, setMonthsFromMonth: function (today, orient) { var gap; orient = orient || 1; this.unit = "month"; gap = (this.month - today.getMonth()); this.months = gap ? ((gap + (orient * 12)) % 12) : (orient * 12); this.month = null; return this; }, setDMYFromWeekday: function () { var d = Date[this.weekday](); this.day = d.getDate(); if (!this.month) { this.month = d.getMonth(); } this.year = d.getFullYear(); return this; }, setUnitValue: function (orient) { if (!this.value && this.operator && this.operator !== null && this[this.unit + "s"] && this[this.unit + "s"] !== null) { this[this.unit + "s"] = this[this.unit + "s"] + ((this.operator === "add") ? 1 : -1) + (this.value||0) * orient; } else if (this[this.unit + "s"] == null || this.operator != null) { if (!this.value) { this.value = 1; } this[this.unit + "s"] = this.value * orient; } }, generateDateFromWeeks: function () { var weekday = (this.weekday !== undefined) ? this.weekday : "today"; var d = Date[weekday]().addWeeks(this.weeks); if (this.now) { d.setTimeToNow(); } return d; } }; $D.Translator = { hour: function (s) { return function () { this.hour = Number(s); }; }, minute: function (s) { return function () { this.minute = Number(s); }; }, second: function (s) { return function () { this.second = Number(s); }; }, /* for ss.s format */ secondAndMillisecond: function (s) { return function () { var mx = s.match(/^([0-5][0-9])\.([0-9]{1,3})/); this.second = Number(mx[1]); this.millisecond = Number(mx[2]); }; }, meridian: function (s) { return function () { this.meridian = s.slice(0, 1).toLowerCase(); }; }, timezone: function (s) { return function () { var n = s.replace(/[^\d\+\-]/g, ""); if (n.length) { this.timezoneOffset = Number(n); } else { this.timezone = s.toLowerCase(); } }; }, day: function (x) { var s = x[0]; return function () { this.day = Number(s.match(/\d+/)[0]); if (this.day < 1) { throw "invalid day"; } }; }, month: function (s) { return function () { this.month = (s.length === 3) ? "jan feb mar apr may jun jul aug sep oct nov dec".indexOf(s)/4 : Number(s) - 1; if (this.month < 0) { throw "invalid month"; } }; }, year: function (s) { return function () { var n = Number(s); this.year = ((s.length > 2) ? n : (n + (((n + 2000) < Date.CultureInfo.twoDigitYearMax) ? 2000 : 1900))); }; }, rday: function (s) { return function () { switch (s) { case "yesterday": this.days = -1; break; case "tomorrow": this.days = 1; break; case "today": this.days = 0; break; case "now": this.days = 0; this.now = true; break; } }; }, finishExact: function (x) { var d; x = (x instanceof Array) ? x : [x]; for (var i = 0 ; i < x.length ; i++) { if (x[i]) { x[i].call(this); } } setDefaults.call(this); parseMeridian.call(this); if (this.day > $D.getDaysInMonth(this.year, this.month)) { throw new RangeError(this.day + " is not a valid value for days."); } d = new Date(this.year, this.month, this.day, this.hour, this.minute, this.second, this.millisecond); if (this.year < 100) { d.setFullYear(this.year); // means years less that 100 are process correctly. JS will parse it otherwise as 1900-1999. } if (this.timezone) { d.set({ timezone: this.timezone }); } else if (this.timezoneOffset) { d.set({ timezoneOffset: this.timezoneOffset }); } return d; }, finish: function (x) { var today, expression, orient, temp; x = (x instanceof Array) ? flattenAndCompact(x) : [ x ]; if (x.length === 0) { return null; } for (var i = 0 ; i < x.length ; i++) { if (typeof x[i] === "function") { x[i].call(this); } } if (this.now && !this.unit && !this.operator) { return new Date(); } else { today = finishUtils.getToday.call(this); } expression = !!(this.days && this.days !== null || this.orient || this.operator); orient = ((this.orient === "past" || this.operator === "subtract") ? -1 : 1); if (this.month && this.unit === "week") { this.value = this.month + 1; delete this.month; delete this.day; } if ((this.month || this.month === 0) && "year day hour minute second".indexOf(this.unit) !== -1) { if (!this.value) { this.value = this.month + 1; } this.month = null; expression = true; } if (!expression && this.weekday && !this.day && !this.days) { finishUtils.setDMYFromWeekday.call(this); } if (expression && this.weekday && this.unit !== "month" && this.unit !== "week") { finishUtils.setDaysFromWeekday.call(this, today, orient); } if (this.weekday && this.unit !== "week" && !this.day && !this.days) { temp = Date[this.weekday](); this.day = temp.getDate(); if (temp.getMonth() !== today.getMonth()) { this.month = temp.getMonth(); } } if (this.month && this.unit === "day" && this.operator) { if (!this.value) { this.value = (this.month + 1); } this.month = null; } if (this.value != null && this.month != null && this.year != null) { this.day = this.value * 1; } if (this.month && !this.day && this.value) { today.set({ day: this.value * 1 }); if (!expression) { this.day = this.value * 1; } } if (!this.month && this.value && this.unit === "month" && !this.now) { this.month = this.value; expression = true; } if (expression && (this.month || this.month === 0) && this.unit !== "year") { finishUtils.setMonthsFromMonth.call(this, today, orient); } if (!this.unit) { this.unit = "day"; } finishUtils.setUnitValue.call(this, orient); parseMeridian.call(this); if ((this.month || this.month === 0) && !this.day) { this.day = 1; } if (!this.orient && !this.operator && this.unit === "week" && this.value && !this.day && !this.month) { return Date.today().setWeek(this.value); } if (this.unit === "week" && this.weeks && !this.day && !this.month) { return finishUtils.generateDateFromWeeks.call(this); } if (expression && this.timezone && this.day && this.days) { this.day = this.days; } if (expression){ today.add(this); } else { today.set(this); } if (this.timezone) { this.timezone = this.timezone.toUpperCase(); var offset = $D.getTimezoneOffset(this.timezone); var timezone; if (today.hasDaylightSavingTime()) { // lets check that we're being sane with timezone setting timezone = $D.getTimezoneAbbreviation(offset, today.isDaylightSavingTime()); if (timezone !== this.timezone) { // bugger, we're in a place where things like EST vs EDT matters. if (today.isDaylightSavingTime()) { today.addHours(-1); } else { today.addHours(1); } } } today.setTimezoneOffset(offset); } return today; } }; }()); (function () { var $D = Date; $D.Grammar = {}; var _ = $D.Parsing.Operators, g = $D.Grammar, t = $D.Translator, _fn; // Allow rolling up into general purpose rules _fn = function () { return _.each(_.any.apply(null, arguments), _.not(g.ctoken2("timeContext"))); }; g.datePartDelimiter = _.rtoken(/^([\s\-\.\,\/\x27]+)/); g.timePartDelimiter = _.stoken(":"); g.whiteSpace = _.rtoken(/^\s*/); g.generalDelimiter = _.rtoken(/^(([\s\,]|at|@|on)+)/); var _C = {}; g.ctoken = function (keys) { var fn = _C[keys]; if (! fn) { var c = Date.CultureInfo.regexPatterns; var kx = keys.split(/\s+/), px = []; for (var i = 0; i < kx.length ; i++) { px.push(_.replace(_.rtoken(c[kx[i]]), kx[i])); } fn = _C[keys] = _.any.apply(null, px); } return fn; }; g.ctoken2 = function (key) { return _.rtoken(Date.CultureInfo.regexPatterns[key]); }; var cacheProcessRtoken = function (key, token, type, eachToken) { if (eachToken) { g[key] = _.cache(_.process(_.each(_.rtoken(token),_.optional(g.ctoken2(eachToken))), type)); } else { g[key] = _.cache(_.process(_.rtoken(token), type)); } }; var cacheProcessCtoken = function (token, type) { return _.cache(_.process(g.ctoken2(token), type)); }; var _F = {}; //function cache var _get = function (f) { _F[f] = (_F[f] || g.format(f)[0]); return _F[f]; }; g.allformats = function (fx) { var rx = []; if (fx instanceof Array) { for (var i = 0; i < fx.length; i++) { rx.push(_get(fx[i])); } } else { rx.push(_get(fx)); } return rx; }; g.formats = function (fx) { if (fx instanceof Array) { var rx = []; for (var i = 0 ; i < fx.length ; i++) { rx.push(_get(fx[i])); } return _.any.apply(null, rx); } else { return _get(fx); } }; var grammarFormats = { timeFormats: function(){ var i, RTokenKeys = [ "h", "hh", "H", "HH", "m", "mm", "s", "ss", "ss.s", "z", "zz" ], RToken = [ /^(0[0-9]|1[0-2]|[1-9])/, /^(0[0-9]|1[0-2])/, /^([0-1][0-9]|2[0-3]|[0-9])/, /^([0-1][0-9]|2[0-3])/, /^([0-5][0-9]|[0-9])/, /^[0-5][0-9]/, /^([0-5][0-9]|[0-9])/, /^[0-5][0-9]/, /^[0-5][0-9]\.[0-9]{1,3}/, /^((\+|\-)\s*\d\d\d\d)|((\+|\-)\d\d\:?\d\d)/, /^((\+|\-)\s*\d\d\d\d)|((\+|\-)\d\d\:?\d\d)/ ], tokens = [ t.hour, t.hour, t.hour, t.hour, t.minute, t.minute, t.second, t.second, t.secondAndMillisecond, t.timezone, t.timezone ]; for (i=0; i < RTokenKeys.length; i++) { cacheProcessRtoken(RTokenKeys[i], RToken[i], tokens[i]); } g.hms = _.cache(_.sequence([g.H, g.m, g.s], g.timePartDelimiter)); g.t = cacheProcessCtoken("shortMeridian", t.meridian); g.tt = cacheProcessCtoken("longMeridian", t.meridian); g.zzz = cacheProcessCtoken("timezone", t.timezone); g.timeSuffix = _.each(_.ignore(g.whiteSpace), _.set([ g.tt, g.zzz ])); g.time = _.each(_.optional(_.ignore(_.stoken("T"))), g.hms, g.timeSuffix); }, dateFormats: function () { // pre-loaded rules for different date part order preferences var _setfn = function () { return _.set(arguments, g.datePartDelimiter); }; var i, RTokenKeys = [ "d", "dd", "M", "MM", "y", "yy", "yyy", "yyyy" ], RToken = [ /^([0-2]\d|3[0-1]|\d)/, /^([0-2]\d|3[0-1])/, /^(1[0-2]|0\d|\d)/, /^(1[0-2]|0\d)/, /^(\d+)/, /^(\d\d)/, /^(\d\d?\d?\d?)/, /^(\d\d\d\d)/ ], tokens = [ t.day, t.day, t.month, t.month, t.year, t.year, t.year, t.year ], eachToken = [ "ordinalSuffix", "ordinalSuffix" ]; for (i=0; i < RTokenKeys.length; i++) { cacheProcessRtoken(RTokenKeys[i], RToken[i], tokens[i], eachToken[i]); } g.MMM = g.MMMM = _.cache(_.process(g.ctoken("jan feb mar apr may jun jul aug sep oct nov dec"), t.month)); g.ddd = g.dddd = _.cache(_.process(g.ctoken("sun mon tue wed thu fri sat"), function (s) { return function () { this.weekday = s; }; } )); g.day = _fn(g.d, g.dd); g.month = _fn(g.M, g.MMM); g.year = _fn(g.yyyy, g.yy); g.mdy = _setfn(g.ddd, g.month, g.day, g.year); g.ymd = _setfn(g.ddd, g.year, g.month, g.day); g.dmy = _setfn(g.ddd, g.day, g.month, g.year); g.date = function (s) { return ((g[Date.CultureInfo.dateElementOrder] || g.mdy).call(this, s)); }; }, relative: function () { // relative date / time expressions g.orientation = _.process(g.ctoken("past future"), function (s) { return function () { this.orient = s; }; } ); g.operator = _.process(g.ctoken("add subtract"), function (s) { return function () { this.operator = s; }; } ); g.rday = _.process(g.ctoken("yesterday tomorrow today now"), t.rday); g.unit = _.process(g.ctoken("second minute hour day week month year"), function (s) { return function () { this.unit = s; }; } ); } }; g.buildGrammarFormats = function () { // these need to be rebuilt every time the language changes. _C = {}; grammarFormats.timeFormats(); grammarFormats.dateFormats(); grammarFormats.relative(); g.value = _.process(_.rtoken(/^([-+]?\d+)?(st|nd|rd|th)?/), function (s) { return function () { this.value = s.replace(/\D/g, ""); }; } ); g.expression = _.set([g.rday, g.operator, g.value, g.unit, g.orientation, g.ddd, g.MMM ]); g.format = _.process(_.many( _.any( // translate format specifiers into grammar rules _.process( _.rtoken(/^(dd?d?d?(?!e)|MM?M?M?|yy?y?y?|hh?|HH?|mm?|ss?|tt?|zz?z?)/), function (fmt) { if (g[fmt]) { return g[fmt]; } else { throw $D.Parsing.Exception(fmt); } } ), // translate separator tokens into token rules _.process(_.rtoken(/^[^dMyhHmstz]+/), // all legal separators function (s) { return _.ignore(_.stoken(s)); } ) ) ), // construct the parser ... function (rules) { return _.process(_.each.apply(null, rules), t.finishExact); } ); // starting rule for general purpose grammar g._start = _.process(_.set([ g.date, g.time, g.expression ], g.generalDelimiter, g.whiteSpace), t.finish); }; g.buildGrammarFormats(); // parsing date format specifiers - ex: "h:m:s tt" // this little guy will generate a custom parser based // on the format string, ex: g.format("h:m:s tt") // check for these formats first g._formats = g.formats([ "\"yyyy-MM-ddTHH:mm:ssZ\"", "yyyy-MM-ddTHH:mm:ss.sz", "yyyy-MM-ddTHH:mm:ssZ", "yyyy-MM-ddTHH:mm:ssz", "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-ddTHH:mmZ", "yyyy-MM-ddTHH:mmz", "yyyy-MM-ddTHH:mm", "ddd, MMM dd, yyyy H:mm:ss tt", "ddd MMM d yyyy HH:mm:ss zzz", "MMddyyyy", "ddMMyyyy", "Mddyyyy", "ddMyyyy", "Mdyyyy", "dMyyyy", "yyyy", "Mdyy", "dMyy", "d" ]); // real starting rule: tries selected formats first, // then general purpose rule g.start = function (s) { try { var r = g._formats.call({}, s); if (r[1].length === 0) { return r; } } catch (e) {} return g._start.call({}, s); }; }()); (function () { var $D = Date; /** * @desc Converts the specified string value into its JavaScript Date equivalent using CultureInfo specific format information. * * Example

	///////////
	// Dates //
	///////////

	// 15-Oct-2004
	var d1 = Date.parse("10/15/2004");

	// 15-Oct-2004
	var d1 = Date.parse("15-Oct-2004");

	// 15-Oct-2004
	var d1 = Date.parse("2004.10.15");

	//Fri Oct 15, 2004
	var d1 = Date.parse("Fri Oct 15, 2004");

	///////////
	// Times //
	///////////

	// Today at 10 PM.
	var d1 = Date.parse("10 PM");

	// Today at 10:30 PM.
	var d1 = Date.parse("10:30 P.M.");

	// Today at 6 AM.
	var d1 = Date.parse("06am");

	/////////////////////
	// Dates and Times //
	/////////////////////

	// 8-July-2004 @ 10:30 PM
	var d1 = Date.parse("July 8th, 2004, 10:30 PM");

	// 1-July-2004 @ 10:30 PM
	var d1 = Date.parse("2004-07-01T22:30:00");

	////////////////////
	// Relative Dates //
	////////////////////

	// Returns today's date. The string "today" is culture specific.
	var d1 = Date.parse("today");

	// Returns yesterday's date. The string "yesterday" is culture specific.
	var d1 = Date.parse("yesterday");

	// Returns the date of the next thursday.
	var d1 = Date.parse("Next thursday");

	// Returns the date of the most previous monday.
	var d1 = Date.parse("last monday");

	// Returns today's day + one year.
	var d1 = Date.parse("next year");

	///////////////
	// Date Math //
	///////////////

	// Today + 2 days
	var d1 = Date.parse("t+2");

	// Today + 2 days
	var d1 = Date.parse("today + 2 days");

	// Today + 3 months
	var d1 = Date.parse("t+3m");

	// Today - 1 year
	var d1 = Date.parse("today - 1 year");

	// Today - 1 year
	var d1 = Date.parse("t-1y"); 


	/////////////////////////////
	// Partial Dates and Times //
	/////////////////////////////

	// July 15th of this year.
	var d1 = Date.parse("July 15");

	// 15th day of current day and year.
	var d1 = Date.parse("15");

	// July 1st of current year at 10pm.
	var d1 = Date.parse("7/1 10pm");
	
* * @param {String} The string value to convert into a Date object [Required] * @return {Date} A Date object or null if the string cannot be converted into a Date. */ var parseUtils = { removeOrds: function (s) { ords = s.match(/\b(\d+)(?:st|nd|rd|th)\b/); // find ordinal matches s = ((ords && ords.length === 2) ? s.replace(ords[0], ords[1]) : s); return s; }, grammarParser: function (s) { var r = null; try { r = $D.Grammar.start.call({}, s.replace(/^\s*(\S*(\s+\S+)*)\s*$/, "$1")); } catch (e) { return null; } return ((r[1].length === 0) ? r[0] : null); }, nativeFallback: function(s) { var t; try { // ok we haven't parsed it, last ditch attempt with the built-in parser. t = Date._parse(s); return (t || t === 0) ? new Date(t) : null; } catch (e) { return null; } } }; function parse (s) { var d; if (!s) { return null; } if (s instanceof Date) { return s.clone(); } if (s.length >= 4 && s.charAt(0) !== "0" && s.charAt(0) !== "+"&& s.charAt(0) !== "-") { // ie: 2004 will pass, 0800 won't. // Start with specific formats d = $D.Parsing.ISO.parse(s) || $D.Parsing.Numeric.parse(s); } if (d instanceof Date && !isNaN(d.getTime())) { return d; } else { // find ordinal dates (1st, 3rd, 8th, etc and remove them as they cause parsing issues) s = $D.Parsing.Normalizer.parse(parseUtils.removeOrds(s)); d = parseUtils.grammarParser(s); if (d !== null) { return d; } else { return parseUtils.nativeFallback(s); } } } if (!$D._parse) { $D._parse = $D.parse; } $D.parse = parse; Date.getParseFunction = function (fx) { var fns = Date.Grammar.allformats(fx); return function (s) { var r = null; for (var i = 0; i < fns.length; i++) { try { r = fns[i].call({}, s); } catch (e) { continue; } if (r[1].length === 0) { return r[0]; } } return null; }; }; /** * Converts the specified string value into its JavaScript Date equivalent using the specified format {String} or formats {Array} and the CultureInfo specific format information. * The format of the string value must match one of the supplied formats exactly. * * Example

	// 15-Oct-2004
	var d1 = Date.parseExact("10/15/2004", "M/d/yyyy");

	// 15-Oct-2004
	var d1 = Date.parse("15-Oct-2004", "M-ddd-yyyy");

	// 15-Oct-2004
	var d1 = Date.parse("2004.10.15", "yyyy.MM.dd");

	// Multiple formats
	var d1 = Date.parseExact("10/15/2004", ["M/d/yyyy", "MMMM d, yyyy"]);
	
* * @param {String} The string value to convert into a Date object [Required]. * @param {Object} The expected format {String} or an array of expected formats {Array} of the date string [Required]. * @return {Date} A Date object or null if the string cannot be converted into a Date. */ $D.parseExact = function (s, fx) { return $D.getParseFunction(fx)(s); }; }()); (function () { var $D = Date, $P = $D.prototype, // $C = $D.CultureInfo, // not used atm p = function (s, l) { if (!l) { l = 2; } return ("000" + s).slice(l * -1); }; /** * Converts a PHP format string to Java/.NET format string. * A PHP format string can be used with ._format or .format. * A Java/.NET format string can be used with .toString(). * The .parseExact function will only accept a Java/.NET format string * * Example * var f1 = "%m/%d/%y" * var f2 = Date.normalizeFormat(f1); // "MM/dd/yy" * * new Date().format(f1); // "04/13/08" * new Date()._format(f1); // "04/13/08" * new Date().toString(f2); // "04/13/08" * * var date = Date.parseExact("04/13/08", f2); // Sun Apr 13 2008 * * @param {String} A PHP format string consisting of one or more format spcifiers. * @return {String} The PHP format converted to a Java/.NET format string. */ var normalizerSubstitutions = { "d" : "dd", "%d": "dd", "D" : "ddd", "%a": "ddd", "j" : "dddd", "l" : "dddd", "%A": "dddd", "S" : "S", "F" : "MMMM", "%B": "MMMM", "m" : "MM", "%m": "MM", "M" : "MMM", "%b": "MMM", "%h": "MMM", "n" : "M", "Y" : "yyyy", "%Y": "yyyy", "y" : "yy", "%y": "yy", "g" : "h", "%I": "h", "G" : "H", "h" : "hh", "H" : "HH", "%H": "HH", "i" : "mm", "%M": "mm", "s" : "ss", "%S": "ss", "%r": "hh:mm tt", "%R": "H:mm", "%T": "H:mm:ss", "%X": "t", "%x": "d", "%e": "d", "%D": "MM/dd/yy", "%n": "\\n", "%t": "\\t", "e" : "z", "T" : "z", "%z": "z", "%Z": "z", "Z" : "ZZ", "N" : "u", "w" : "u", "%w": "u", "W" : "W", "%V": "W" }; var normalizer = { substitutes: function (m) { return normalizerSubstitutions[m]; }, interpreted: function (m, x) { var y; switch (m) { case "%u": return x.getDay() + 1; case "z": return x.getOrdinalNumber(); case "%j": return p(x.getOrdinalNumber(), 3); case "%U": var d1 = x.clone().set({month: 0, day: 1}).addDays(-1).moveToDayOfWeek(0), d2 = x.clone().addDays(1).moveToDayOfWeek(0, -1); return (d2 < d1) ? "00" : p((d2.getOrdinalNumber() - d1.getOrdinalNumber()) / 7 + 1); case "%W": return p(x.getWeek()); case "t": return $D.getDaysInMonth(x.getFullYear(), x.getMonth()); case "o": case "%G": return x.setWeek(x.getISOWeek()).toString("yyyy"); case "%g": return x._format("%G").slice(-2); case "a": case "%p": return t("tt").toLowerCase(); case "A": return t("tt").toUpperCase(); case "u": return p(x.getMilliseconds(), 3); case "I": return (x.isDaylightSavingTime()) ? 1 : 0; case "O": return x.getUTCOffset(); case "P": y = x.getUTCOffset(); return y.substring(0, y.length - 2) + ":" + y.substring(y.length - 2); case "B": var now = new Date(); return Math.floor(((now.getHours() * 3600) + (now.getMinutes() * 60) + now.getSeconds() + (now.getTimezoneOffset() + 60) * 60) / 86.4); case "c": return x.toISOString().replace(/\"/g, ""); case "U": return $D.strtotime("now"); case "%c": return t("d") + " " + t("t"); case "%C": return Math.floor(x.getFullYear() / 100 + 1); } }, shouldOverrideDefaults: function (m) { switch (m) { case "%e": return true; default: return false; } }, parse: function (m, context) { var formatString, c = context || new Date(); formatString = normalizer.substitutes(m); if (formatString) { return formatString; } formatString = normalizer.interpreted(m, c); if (formatString) { return formatString; } else { return m; } } }; $D.normalizeFormat = function (format, context) { return format.replace(/(%|\\)?.|%%/g, function(t){ return normalizer.parse(t, context); }); }; /** * Format a local Unix timestamp according to locale settings * * Example: * Date.strftime("%m/%d/%y", new Date()); // "04/13/08" * Date.strftime("c", "2008-04-13T17:52:03Z"); // "04/13/08" * * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @param {Number|String} The number representing the number of seconds that have elapsed since January 1, 1970 (local time). * @return {String} A string representation of the current Date object. */ $D.strftime = function (format, time) { var d = Date.parse(time); return d._format(format); }; /** * Parse any textual datetime description into a Unix timestamp. * A Unix timestamp is the number of seconds that have elapsed since January 1, 1970 (midnight UTC/GMT). * * Example: * Date.strtotime("04/13/08"); // 1208044800 * Date.strtotime("1970-01-01T00:00:00Z"); // 0 * * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @param {Object} A string or date object. * @return {String} A string representation of the current Date object. */ $D.strtotime = function (time) { var d = $D.parse(time); return Math.round($D.UTC(d.getUTCFullYear(), d.getUTCMonth(), d.getUTCDate(), d.getUTCHours(), d.getUTCMinutes(), d.getUTCSeconds(), d.getUTCMilliseconds()) / 1000); }; /** * Converts the value of the current Date object to its equivalent string representation using a PHP/Unix style of date format specifiers. * Format Specifiers * Format Description Example * ------ --------------------------------------------------------------------------- ----------------------- * %a abbreviated weekday name according to the current localed "Mon" through "Sun" * %A full weekday name according to the current localed "Sunday" through "Saturday" * %b abbreviated month name according to the current localed "Jan" through "Dec" * %B full month name according to the current locale "January" through "December" * %c preferred date and time representation for the current locale "4/13/2008 12:33 PM" * %C century number (the year divided by 100 and truncated to an integer) "00" to "99" * %d day of the month as a decimal number "01" to "31" * %D same as %m/%d/%y "04/13/08" * %e day of the month as a decimal number, a single digit is preceded by a space "1" to "31" * %g like %G, but without the century "08" * %G The 4-digit year corresponding to the ISO week number (see %V). "2008" * This has the same format and value as %Y, except that if the ISO week number * belongs to the previous or next year, that year is used instead. * %h same as %b "Jan" through "Dec" * %H hour as a decimal number using a 24-hour clock. "00" to "23" * %I hour as a decimal number using a 12-hour clock. "01" to "12" * %j day of the year as a decimal number. "001" to "366" * %m month as a decimal number. "01" to "12" * %M minute as a decimal number. "00" to "59" * %n newline character "\n" * %p either "am" or "pm" according to the given time value, or the "am" or "pm" * corresponding strings for the current locale. * %r time in a.m. and p.m. notation "8:44 PM" * %R time in 24 hour notation "20:44" * %S second as a decimal number "00" to "59" * %t tab character "\t" * %T current time, equal to %H:%M:%S "12:49:11" * %u weekday as a decimal number ["1", "7"], with "1" representing Monday "1" to "7" * %U week number of the current year as a decimal number, starting with the "0" to ("52" or "53") * first Sunday as the first day of the first week * %V The ISO 8601:1988 week number of the current year as a decimal number, "00" to ("52" or "53") * range 01 to 53, where week 1 is the first week that has at least 4 days * in the current year, and with Monday as the first day of the week. * (Use %G or %g for the year component that corresponds to the week number * for the specified timestamp.) * %W week number of the current year as a decimal number, starting with the "00" to ("52" or "53") * first Monday as the first day of the first week * %w day of the week as a decimal, Sunday being "0" "0" to "6" * %x preferred date representation for the current locale without the time "4/13/2008" * %X preferred time representation for the current locale without the date "12:53:05" * %y year as a decimal number without a century "00" "99" * %Y year as a decimal number including the century "2008" * %Z time zone or name or abbreviation "UTC", "EST", "PST" * %z same as %Z * %% a literal "%" characters "%" * d Day of the month, 2 digits with leading zeros "01" to "31" * D A textual representation of a day, three letters "Mon" through "Sun" * j Day of the month without leading zeros "1" to "31" * l A full textual representation of the day of the week (lowercase "L") "Sunday" through "Saturday" * N ISO-8601 numeric representation of the day of the week (added in PHP 5.1.0) "1" (for Monday) through "7" (for Sunday) * S English ordinal suffix for the day of the month, 2 characters "st", "nd", "rd" or "th". Works well with j * w Numeric representation of the day of the week "0" (for Sunday) through "6" (for Saturday) * z The day of the year (starting from "0") "0" through "365" * W ISO-8601 week number of year, weeks starting on Monday "00" to ("52" or "53") * F A full textual representation of a month, such as January or March "January" through "December" * m Numeric representation of a month, with leading zeros "01" through "12" * M A short textual representation of a month, three letters "Jan" through "Dec" * n Numeric representation of a month, without leading zeros "1" through "12" * t Number of days in the given month "28" through "31" * L Whether it's a leap year "1" if it is a leap year, "0" otherwise * o ISO-8601 year number. This has the same value as Y, except that if the "2008" * ISO week number (W) belongs to the previous or next year, that year * is used instead. * Y A full numeric representation of a year, 4 digits "2008" * y A two digit representation of a year "08" * a Lowercase Ante meridiem and Post meridiem "am" or "pm" * A Uppercase Ante meridiem and Post meridiem "AM" or "PM" * B Swatch Internet time "000" through "999" * g 12-hour format of an hour without leading zeros "1" through "12" * G 24-hour format of an hour without leading zeros "0" through "23" * h 12-hour format of an hour with leading zeros "01" through "12" * H 24-hour format of an hour with leading zeros "00" through "23" * i Minutes with leading zeros "00" to "59" * s Seconds, with leading zeros "00" through "59" * u Milliseconds "54321" * e Timezone identifier "UTC", "EST", "PST" * I Whether or not the date is in daylight saving time (uppercase i) "1" if Daylight Saving Time, "0" otherwise * O Difference to Greenwich time (GMT) in hours "+0200", "-0600" * P Difference to Greenwich time (GMT) with colon between hours and minutes "+02:00", "-06:00" * T Timezone abbreviation "UTC", "EST", "PST" * Z Timezone offset in seconds. The offset for timezones west of UTC is "-43200" through "50400" * always negative, and for those east of UTC is always positive. * c ISO 8601 date "2004-02-12T15:19:21+00:00" * r RFC 2822 formatted date "Thu, 21 Dec 2000 16:01:07 +0200" * U Seconds since the Unix Epoch (January 1 1970 00:00:00 GMT) "0" * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @return {String} A string representation of the current Date object. */ var formatReplace = function (context) { return function (m) { var formatString, override = false; if (m.charAt(0) === "\\" || m.substring(0, 2) === "%%") { return m.replace("\\", "").replace("%%", "%"); } override = normalizer.shouldOverrideDefaults(m); formatString = $D.normalizeFormat(m, context); if (formatString) { return context.toString(formatString, override); } }; }; $P._format = function (format) { var formatter = formatReplace(this); if (!format) { return this._toString(); } else { return format.replace(/(%|\\)?.|%%/g, formatter); } }; if (!$P.format) { $P.format = $P._format; } }()); (function () { "use strict"; var gFn = function (attr) { return function () { return this[attr]; }; }; var sFn = function (attr) { return function (val) { this[attr] = val; return this; }; }; var attrs = ["years", "months", "days", "hours", "minutes", "seconds", "milliseconds"]; var addSetFuncs = function (context, attrs) { for (var i = 0; i < attrs.length ; i++) { var $a = attrs[i], $b = $a.slice(0, 1).toUpperCase() + $a.slice(1); context.prototype[$a] = 0; context.prototype["get" + $b] = gFn($a); context.prototype["set" + $b] = sFn($a); } }; /** * new TimeSpan(milliseconds); * new TimeSpan(days, hours, minutes, seconds); * new TimeSpan(days, hours, minutes, seconds, milliseconds); */ var TimeSpan = function (days, hours, minutes, seconds, milliseconds) { if (arguments.length === 1 && typeof days === "number") { var orient = (days < 0) ? -1 : +1; var millsLeft = Math.abs(days); this.setDays(Math.floor(millsLeft / 86400000) * orient); millsLeft = millsLeft % 86400000; this.setHours(Math.floor(millsLeft / 3600000) * orient); millsLeft = millsLeft % 3600000; this.setMinutes(Math.floor(millsLeft / 60000) * orient); millsLeft = millsLeft % 60000; this.setSeconds(Math.floor(millsLeft / 1000) * orient); millsLeft = millsLeft % 1000; this.setMilliseconds(millsLeft * orient); } else { this.set(days, hours, minutes, seconds, milliseconds); } this.getTotalMilliseconds = function () { return (this.getDays() * 86400000) + (this.getHours() * 3600000) + (this.getMinutes() * 60000) + (this.getSeconds() * 1000); }; this.compareTo = function (time) { var t1 = new Date(1970, 1, 1, this.getHours(), this.getMinutes(), this.getSeconds()), t2; if (time === null) { t2 = new Date(1970, 1, 1, 0, 0, 0); } else { t2 = new Date(1970, 1, 1, time.getHours(), time.getMinutes(), time.getSeconds()); } return (t1 < t2) ? -1 : (t1 > t2) ? 1 : 0; }; this.equals = function (time) { return (this.compareTo(time) === 0); }; this.add = function (time) { return (time === null) ? this : this.addSeconds(time.getTotalMilliseconds() / 1000); }; this.subtract = function (time) { return (time === null) ? this : this.addSeconds(-time.getTotalMilliseconds() / 1000); }; this.addDays = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 86400000)); }; this.addHours = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 3600000)); }; this.addMinutes = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 60000)); }; this.addSeconds = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 1000)); }; this.addMilliseconds = function (n) { return new TimeSpan(this.getTotalMilliseconds() + n); }; this.get12HourHour = function () { return (this.getHours() > 12) ? this.getHours() - 12 : (this.getHours() === 0) ? 12 : this.getHours(); }; this.getDesignator = function () { return (this.getHours() < 12) ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator; }; this.toString = function (format) { this._toString = function () { if (this.getDays() !== null && this.getDays() > 0) { return this.getDays() + "." + this.getHours() + ":" + this.p(this.getMinutes()) + ":" + this.p(this.getSeconds()); } else { return this.getHours() + ":" + this.p(this.getMinutes()) + ":" + this.p(this.getSeconds()); } }; this.p = function (s) { return (s.toString().length < 2) ? "0" + s : s; }; var me = this; return format ? format.replace(/dd?|HH?|hh?|mm?|ss?|tt?/g, function (format) { switch (format) { case "d": return me.getDays(); case "dd": return me.p(me.getDays()); case "H": return me.getHours(); case "HH": return me.p(me.getHours()); case "h": return me.get12HourHour(); case "hh": return me.p(me.get12HourHour()); case "m": return me.getMinutes(); case "mm": return me.p(me.getMinutes()); case "s": return me.getSeconds(); case "ss": return me.p(me.getSeconds()); case "t": return ((me.getHours() < 12) ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator).substring(0, 1); case "tt": return (me.getHours() < 12) ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator; } } ) : this._toString(); }; return this; }; addSetFuncs(TimeSpan, attrs.slice(2)); TimeSpan.prototype.set = function (days, hours, minutes, seconds, milliseconds){ this.setDays(days || this.getDays()); this.setHours(hours || this.getHours()); this.setMinutes(minutes || this.getMinutes()); this.setSeconds(seconds || this.getSeconds()); this.setMilliseconds(milliseconds || this.getMilliseconds()); }; /** * Gets the time of day for this date instances. * @return {TimeSpan} TimeSpan */ Date.prototype.getTimeOfDay = function () { return new TimeSpan(0, this.getHours(), this.getMinutes(), this.getSeconds(), this.getMilliseconds()); }; Date.TimeSpan = TimeSpan; if (typeof window !== "undefined" ) { // keeping API compatible for v1.x window.TimeSpan = TimeSpan; } }()); (function () { "use strict"; var attrs = ["years", "months", "days", "hours", "minutes", "seconds", "milliseconds"]; var gFn = function (attr) { return function () { return this[attr]; }; }; var sFn = function (attr) { return function (val) { this[attr] = val; return this; }; }; var addSetFuncs = function (context, attrs) { for (var i = 0; i < attrs.length ; i++) { var $a = attrs[i], $b = $a.slice(0, 1).toUpperCase() + $a.slice(1); context.prototype[$a] = 0; context.prototype["get" + $b] = gFn($a); context.prototype["set" + $b] = sFn($a); } }; var setMonthsAndYears = function (orient, d1, d2, context) { function inc() { d1.addMonths(-orient); context.months++; if (context.months === 12) { context.years++; context.months = 0; } } if (orient === +1) { while (d1 > d2) { inc(); } } else { while (d1 < d2) { inc(); } } context.months--; context.months *= orient; context.years *= orient; }; var adjustForDST = function(orient, startDate, endDate) { var hasDSTMismatch = (false === (startDate.isDaylightSavingTime() === endDate.isDaylightSavingTime())); if (hasDSTMismatch && orient === 1) { startDate.addHours(-1); } else if (hasDSTMismatch) { startDate.addHours(1); } }; /** * TimePeriod(startDate, endDate); * TimePeriod(years, months, days, hours, minutes, seconds, milliseconds); */ var TimePeriod = function (years, months, days, hours, minutes, seconds, milliseconds) { if (arguments.length === 7) { this.set(years, months, days, hours, minutes, seconds, milliseconds); } else if (arguments.length === 2 && arguments[0] instanceof Date && arguments[1] instanceof Date) { var startDate = arguments[0].clone(); var endDate = arguments[1].clone(); var orient = (startDate > endDate) ? +1 : -1; this.dates = { start: arguments[0].clone(), end: arguments[1].clone() }; setMonthsAndYears(orient, startDate, endDate, this); adjustForDST(orient, startDate, endDate); // // TODO - adjust for DST var diff = endDate - startDate; if (diff !== 0) { var ts = new TimeSpan(diff); this.set(this.years, this.months, ts.getDays(), ts.getHours(), ts.getMinutes(), ts.getSeconds(), ts.getMilliseconds()); } } return this; }; // create all the set functions. addSetFuncs(TimePeriod, attrs); TimePeriod.prototype.set = function (years, months, days, hours, minutes, seconds, milliseconds){ this.setYears(years || this.getYears()); this.setMonths(months || this.getMonths()); this.setDays(days || this.getDays()); this.setHours(hours || this.getHours()); this.setMinutes(minutes || this.getMinutes()); this.setSeconds(seconds || this.getSeconds()); this.setMilliseconds(milliseconds || this.getMilliseconds()); }; Date.TimePeriod = TimePeriod; if (typeof window !== "undefined") { // keeping API compatible for v1.x window.TimePeriod = TimePeriod; } }()); ================================================ FILE: build/date-te-IN.js ================================================ /** * @overview datejs * @version 1.0.0-rc3 * @author Gregory Wild-Smith * @copyright 2015 Gregory Wild-Smith * @license MIT * @homepage https://github.com/abritinthebay/datejs */ /* * DateJS Culture String File * Country Code: te-IN * Name: Telugu (India) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["te-IN"] = { "name": "te-IN", "englishName": "Telugu (India)", "nativeName": "తెలుగు (భారత దేశం)", "Sunday": "ఆదివారం", "Monday": "సోమవారం", "Tuesday": "మంగళవారం", "Wednesday": "బుధవారం", "Thursday": "గురువారం", "Friday": "శుక్రవారం", "Saturday": "శనివారం", "Sun": "ఆది.", "Mon": "సోమ.", "Tue": "మంగళ.", "Wed": "బుధ.", "Thu": "గురు.", "Fri": "శుక్ర.", "Sat": "శని.", "Su": "ఆ", "Mo": "స", "Tu": "మ", "We": "బ", "Th": "గ", "Fr": "శ", "Sa": "శ", "S_Sun_Initial": "ఆ", "M_Mon_Initial": "స", "T_Tue_Initial": "మ", "W_Wed_Initial": "బ", "T_Thu_Initial": "గ", "F_Fri_Initial": "శ", "S_Sat_Initial": "శ", "January": "జనవరి", "February": "ఫిబ్రవరి", "March": "మార్చి", "April": "ఏప్రిల్", "May": "మే", "June": "జూన్", "July": "జూలై", "August": "ఆగస్టు", "September": "సెప్టెంబర్", "October": "అక్టోబర్", "November": "నవంబర్", "December": "డిసెంబర్", "Jan_Abbr": "జనవరి", "Feb_Abbr": "ఫిబ్రవరి", "Mar_Abbr": "మార్చి", "Apr_Abbr": "ఏప్రిల్", "May_Abbr": "మే", "Jun_Abbr": "జూన్", "Jul_Abbr": "జూలై", "Aug_Abbr": "ఆగస్టు", "Sep_Abbr": "సెప్టెంబర్", "Oct_Abbr": "అక్టోబర్", "Nov_Abbr": "నవంబర్", "Dec_Abbr": "డిసెంబర్", "AM": "పూర్వాహ్న", "PM": "అపరాహ్న", "firstDayOfWeek": 1, "twoDigitYearMax": 2029, "mdy": "dmy", "M/d/yyyy": "dd-MM-yy", "dddd, MMMM dd, yyyy": "dd MMMM yyyy", "h:mm tt": "HH:mm", "h:mm:ss tt": "HH:mm:ss", "dddd, MMMM dd, yyyy h:mm:ss tt": "dd MMMM yyyy HH:mm:ss", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "dd MMMM", "MMMM, yyyy": "MMMM, yyyy", "/jan(uary)?/": "జనవరి", "/feb(ruary)?/": "ఫిబ్రవరి", "/mar(ch)?/": "మార్చి", "/apr(il)?/": "ఏప్రిల్", "/may/": "మే", "/jun(e)?/": "జూన్", "/jul(y)?/": "జూలై", "/aug(ust)?/": "ఆగస్టు", "/sep(t(ember)?)?/": "సెప్టెంబర్", "/oct(ober)?/": "అక్టోబర్", "/nov(ember)?/": "నవంబర్", "/dec(ember)?/": "డిసెంబర్", "/^su(n(day)?)?/": "^ఆ(ది(.(వారం)?)?)?", "/^mo(n(day)?)?/": "^స(ోమ(.(వారం)?)?)?", "/^tu(e(s(day)?)?)?/": "^మ(ంగళ(.(వారం)?)?)?", "/^we(d(nesday)?)?/": "^బ(ుధ(.(వారం)?)?)?", "/^th(u(r(s(day)?)?)?)?/": "^గ(ురు(.(వారం)?)?)?", "/^fr(i(day)?)?/": "^శ(ుక్ర(.(వారం)?)?)?", "/^sa(t(urday)?)?/": "^శ(ని(.(వారం)?)?)?", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "te-IN"; /** * @overview datejs * @version 1.0.0-rc3 * @author Gregory Wild-Smith * @copyright 2015 Gregory Wild-Smith * @license MIT * @homepage https://github.com/abritinthebay/datejs */(function () { var $D = Date; var lang = Date.CultureStrings ? Date.CultureStrings.lang : null; var loggedKeys = {}; // for debug purposes. var getText = { getFromKey: function (key, countryCode) { var output; if (Date.CultureStrings && Date.CultureStrings[countryCode] && Date.CultureStrings[countryCode][key]) { output = Date.CultureStrings[countryCode][key]; } else { output = getText.buildFromDefault(key); } if (key.charAt(0) === "/") { // Assume it's a regex output = getText.buildFromRegex(key, countryCode); } return output; }, getFromObjectValues: function (obj, countryCode) { var key, output = {}; for(key in obj) { if (obj.hasOwnProperty(key)) { output[key] = getText.getFromKey(obj[key], countryCode); } } return output; }, getFromObjectKeys: function (obj, countryCode) { var key, output = {}; for(key in obj) { if (obj.hasOwnProperty(key)) { output[getText.getFromKey(key, countryCode)] = obj[key]; } } return output; }, getFromArray: function (arr, countryCode) { var output = []; for (var i=0; i < arr.length; i++){ if (i in arr) { output[i] = getText.getFromKey(arr[i], countryCode); } } return output; }, buildFromDefault: function (key) { var output, length, split, last; switch(key) { case "name": output = "en-US"; break; case "englishName": output = "English (United States)"; break; case "nativeName": output = "English (United States)"; break; case "twoDigitYearMax": output = 2049; break; case "firstDayOfWeek": output = 0; break; default: output = key; split = key.split("_"); length = split.length; if (length > 1 && key.charAt(0) !== "/") { // if the key isn't a regex and it has a split. last = split[(length - 1)].toLowerCase(); if (last === "initial" || last === "abbr") { output = split[0]; } } break; } return output; }, buildFromRegex: function (key, countryCode) { var output; if (Date.CultureStrings && Date.CultureStrings[countryCode] && Date.CultureStrings[countryCode][key]) { output = new RegExp(Date.CultureStrings[countryCode][key], "i"); } else { output = new RegExp(key.replace(new RegExp("/", "g"),""), "i"); } return output; } }; var shallowMerge = function (obj1, obj2) { for (var attrname in obj2) { if (obj2.hasOwnProperty(attrname)) { obj1[attrname] = obj2[attrname]; } } }; var __ = function (key, language) { var countryCode = (language) ? language : lang; loggedKeys[key] = key; if (typeof key === "object") { if (key instanceof Array) { return getText.getFromArray(key, countryCode); } else { return getText.getFromObjectKeys(key, countryCode); } } else { return getText.getFromKey(key, countryCode); } }; var loadI18nScript = function (code) { // paatterned after jQuery's getScript. var url = Date.Config.i18n + code + ".js"; var head = document.getElementsByTagName("head")[0] || document.documentElement; var script = document.createElement("script"); script.src = url; var completed = false; var events = { done: function (){} // placeholder function }; // Attach handlers for all browsers script.onload = script.onreadystatechange = function() { if ( !completed && (!this.readyState || this.readyState === "loaded" || this.readyState === "complete") ) { events.done(); head.removeChild(script); } }; setTimeout(function() { head.insertBefore(script, head.firstChild); }, 0); // allows return to execute first return { done: function (cb) { events.done = function() { if (cb) { setTimeout(cb,0); } }; } }; }; var buildInfo = { buildFromMethodHash: function (obj) { var key; for(key in obj) { if (obj.hasOwnProperty(key)) { obj[key] = buildInfo[obj[key]](); } } return obj; }, timeZoneDST: function () { var DST = { "CHADT": "+1345", "NZDT": "+1300", "AEDT": "+1100", "ACDT": "+1030", "AZST": "+0500", "IRDT": "+0430", "EEST": "+0300", "CEST": "+0200", "BST": "+0100", "PMDT": "-0200", "ADT": "-0300", "NDT": "-0230", "EDT": "-0400", "CDT": "-0500", "MDT": "-0600", "PDT": "-0700", "AKDT": "-0800", "HADT": "-0900" }; return __(DST); }, timeZoneStandard: function () { var standard = { "LINT": "+1400", "TOT": "+1300", "CHAST": "+1245", "NZST": "+1200", "NFT": "+1130", "SBT": "+1100", "AEST": "+1000", "ACST": "+0930", "JST": "+0900", "CWST": "+0845", "CT": "+0800", "ICT": "+0700", "MMT": "+0630", "BST": "+0600", "NPT": "+0545", "IST": "+0530", "PKT": "+0500", "AFT": "+0430", "MSK": "+0400", "IRST": "+0330", "FET": "+0300", "EET": "+0200", "CET": "+0100", "GMT": "+0000", "UTC": "+0000", "CVT": "-0100", "GST": "-0200", "BRT": "-0300", "NST": "-0330", "AST": "-0400", "EST": "-0500", "CST": "-0600", "MST": "-0700", "PST": "-0800", "AKST": "-0900", "MIT": "-0930", "HST": "-1000", "SST": "-1100", "BIT": "-1200" }; return __(standard); }, timeZones: function (data) { var zone; data.timezones = []; for (zone in data.abbreviatedTimeZoneStandard) { if (data.abbreviatedTimeZoneStandard.hasOwnProperty(zone)) { data.timezones.push({ name: zone, offset: data.abbreviatedTimeZoneStandard[zone]}); } } for (zone in data.abbreviatedTimeZoneDST) { if (data.abbreviatedTimeZoneDST.hasOwnProperty(zone)) { data.timezones.push({ name: zone, offset: data.abbreviatedTimeZoneDST[zone], dst: true}); } } return data.timezones; }, days: function () { return __(["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"]); }, dayAbbr: function () { return __(["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"]); }, dayShortNames: function () { return __(["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"]); }, dayFirstLetters: function () { return __(["S_Sun_Initial", "M_Mon_Initial", "T_Tues_Initial", "W_Wed_Initial", "T_Thu_Initial", "F_Fri_Initial", "S_Sat_Initial"]); }, months: function () { return __(["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"]); }, monthAbbr: function () { return __(["Jan_Abbr", "Feb_Abbr", "Mar_Abbr", "Apr_Abbr", "May_Abbr", "Jun_Abbr", "Jul_Abbr", "Aug_Abbr", "Sep_Abbr", "Oct_Abbr", "Nov_Abbr", "Dec_Abbr"]); }, formatPatterns: function () { return getText.getFromObjectValues({ shortDate: "M/d/yyyy", longDate: "dddd, MMMM dd, yyyy", shortTime: "h:mm tt", longTime: "h:mm:ss tt", fullDateTime: "dddd, MMMM dd, yyyy h:mm:ss tt", sortableDateTime: "yyyy-MM-ddTHH:mm:ss", universalSortableDateTime: "yyyy-MM-dd HH:mm:ssZ", rfc1123: "ddd, dd MMM yyyy HH:mm:ss", monthDay: "MMMM dd", yearMonth: "MMMM, yyyy" }, Date.i18n.currentLanguage()); }, regex: function () { return getText.getFromObjectValues({ inTheMorning: "/( in the )(morn(ing)?)\\b/", thisMorning: "/(this )(morn(ing)?)\\b/", amThisMorning: "/(\b\\d(am)? )(this )(morn(ing)?)/", inTheEvening: "/( in the )(even(ing)?)\\b/", thisEvening: "/(this )(even(ing)?)\\b/", pmThisEvening: "/(\b\\d(pm)? )(this )(even(ing)?)/", jan: "/jan(uary)?/", feb: "/feb(ruary)?/", mar: "/mar(ch)?/", apr: "/apr(il)?/", may: "/may/", jun: "/jun(e)?/", jul: "/jul(y)?/", aug: "/aug(ust)?/", sep: "/sep(t(ember)?)?/", oct: "/oct(ober)?/", nov: "/nov(ember)?/", dec: "/dec(ember)?/", sun: "/^su(n(day)?)?/", mon: "/^mo(n(day)?)?/", tue: "/^tu(e(s(day)?)?)?/", wed: "/^we(d(nesday)?)?/", thu: "/^th(u(r(s(day)?)?)?)?/", fri: "/fr(i(day)?)?/", sat: "/^sa(t(urday)?)?/", future: "/^next/", past: "/^last|past|prev(ious)?/", add: "/^(\\+|aft(er)?|from|hence)/", subtract: "/^(\\-|bef(ore)?|ago)/", yesterday: "/^yes(terday)?/", today: "/^t(od(ay)?)?/", tomorrow: "/^tom(orrow)?/", now: "/^n(ow)?/", millisecond: "/^ms|milli(second)?s?/", second: "/^sec(ond)?s?/", minute: "/^mn|min(ute)?s?/", hour: "/^h(our)?s?/", week: "/^w(eek)?s?/", month: "/^m(onth)?s?/", day: "/^d(ay)?s?/", year: "/^y(ear)?s?/", shortMeridian: "/^(a|p)/", longMeridian: "/^(a\\.?m?\\.?|p\\.?m?\\.?)/", timezone: "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/", ordinalSuffix: "/^\\s*(st|nd|rd|th)/", timeContext: "/^\\s*(\\:|a(?!u|p)|p)/" }, Date.i18n.currentLanguage()); } }; var CultureInfo = function () { var info = getText.getFromObjectValues({ name: "name", englishName: "englishName", nativeName: "nativeName", amDesignator: "AM", pmDesignator: "PM", firstDayOfWeek: "firstDayOfWeek", twoDigitYearMax: "twoDigitYearMax", dateElementOrder: "mdy" }, Date.i18n.currentLanguage()); var constructedInfo = buildInfo.buildFromMethodHash({ dayNames: "days", abbreviatedDayNames: "dayAbbr", shortestDayNames: "dayShortNames", firstLetterDayNames: "dayFirstLetters", monthNames: "months", abbreviatedMonthNames: "monthAbbr", formatPatterns: "formatPatterns", regexPatterns: "regex", abbreviatedTimeZoneDST: "timeZoneDST", abbreviatedTimeZoneStandard: "timeZoneStandard" }); shallowMerge(info, constructedInfo); buildInfo.timeZones(info); return info; }; $D.i18n = { __: function (key, lang) { return __(key, lang); }, currentLanguage: function () { return lang || "en-US"; }, setLanguage: function (code, force, cb) { var async = false; if (force || code === "en-US" || (!!Date.CultureStrings && !!Date.CultureStrings[code])) { lang = code; Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings.lang = code; Date.CultureInfo = new CultureInfo(); } else { if (!(!!Date.CultureStrings && !!Date.CultureStrings[code])) { if (typeof exports !== "undefined" && this.exports !== exports) { // we're in a Node enviroment, load it using require try { require("../i18n/" + code + ".js"); lang = code; Date.CultureStrings.lang = code; Date.CultureInfo = new CultureInfo(); } catch (e) { // var str = "The language for '" + code + "' could not be loaded by Node. It likely does not exist."; throw new Error("The DateJS IETF language tag '" + code + "' could not be loaded by Node. It likely does not exist."); } } else if (Date.Config && Date.Config.i18n) { // we know the location of the files, so lets load them async = true; loadI18nScript(code).done(function(){ lang = code; Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings.lang = code; Date.CultureInfo = new CultureInfo(); $D.Parsing.Normalizer.buildReplaceData(); // because this is async if ($D.Grammar) { $D.Grammar.buildGrammarFormats(); // so we can parse those strings... } if (cb) { setTimeout(cb,0); } }); } else { Date.console.error("The DateJS IETF language tag '" + code + "' is not available and has not been loaded."); return false; } } } $D.Parsing.Normalizer.buildReplaceData(); // rebuild normalizer strings if ($D.Grammar) { $D.Grammar.buildGrammarFormats(); // so we can parse those strings... } if (!async && cb) { setTimeout(cb,0); } }, getLoggedKeys: function () { return loggedKeys; }, updateCultureInfo: function () { Date.CultureInfo = new CultureInfo(); } }; $D.i18n.updateCultureInfo(); // run automatically }()); (function () { var $D = Date, $P = $D.prototype, p = function (s, l) { if (!l) { l = 2; } return ("000" + s).slice(l * -1); }; if (typeof window !== "undefined" && typeof window.console !== "undefined" && typeof window.console.log !== "undefined") { $D.console = console; // used only to raise non-critical errors if available } else { // set mock so we don't give errors. $D.console = { log: function(){}, error: function(){} }; } $D.Config = $D.Config || {}; $D.initOverloads = function() { /** * Overload of Date.now. Allows an alternate call for Date.now where it returns the * current Date as an object rather than just milliseconds since the Unix Epoch. * * Also provides an implementation of now() for browsers (IE<9) that don't have it. * * Backwards compatible so with work with either: * Date.now() [returns ms] * or * Date.now(true) [returns Date] */ if (!$D.now) { $D._now = function now() { return new Date().getTime(); }; } else if (!$D._now) { $D._now = $D.now; } $D.now = function (returnObj) { if (returnObj) { return $D.present(); } else { return $D._now(); } }; if ( !$P.toISOString ) { $P.toISOString = function() { return this.getUTCFullYear() + "-" + p(this.getUTCMonth() + 1) + "-" + p(this.getUTCDate()) + "T" + p(this.getUTCHours()) + ":" + p(this.getUTCMinutes()) + ":" + p(this.getUTCSeconds()) + "." + String( (this.getUTCMilliseconds()/1000).toFixed(3)).slice(2, 5) + "Z"; }; } // private if ( $P._toString === undefined ){ $P._toString = $P.toString; } }; $D.initOverloads(); /** * Gets a date that is set to the current date. The time is set to the start of the day (00:00 or 12:00 AM). * @return {Date} The current date. */ $D.today = function () { return new Date().clearTime(); }; /** * Gets a date that is set to the current date and time (same as new Date, but chainable) * @return {Date} The current date. */ $D.present = function () { return new Date(); }; /** * Compares the first date to the second date and returns an number indication of their relative values. * @param {Date} First Date object to compare [Required]. * @param {Date} Second Date object to compare to [Required]. * @return {Number} -1 = date1 is lessthan date2. 0 = values are equal. 1 = date1 is greaterthan date2. */ $D.compare = function (date1, date2) { if (isNaN(date1) || isNaN(date2)) { throw new Error(date1 + " - " + date2); } else if (date1 instanceof Date && date2 instanceof Date) { return (date1 < date2) ? -1 : (date1 > date2) ? 1 : 0; } else { throw new TypeError(date1 + " - " + date2); } }; /** * Compares the first Date object to the second Date object and returns true if they are equal. * @param {Date} First Date object to compare [Required] * @param {Date} Second Date object to compare to [Required] * @return {Boolean} true if dates are equal. false if they are not equal. */ $D.equals = function (date1, date2) { return (date1.compareTo(date2) === 0); }; /** * Gets the language appropriate day name when given the day number(0-6) * eg - 0 == Sunday * @return {String} The day name */ $D.getDayName = function (n) { return Date.CultureInfo.dayNames[n]; }; /** * Gets the day number (0-6) if given a CultureInfo specific string which is a valid dayName, abbreviatedDayName or shortestDayName (two char). * @param {String} The name of the day (eg. "Monday, "Mon", "tuesday", "tue", "We", "we"). * @return {Number} The day number */ $D.getDayNumberFromName = function (name) { var n = Date.CultureInfo.dayNames, m = Date.CultureInfo.abbreviatedDayNames, o = Date.CultureInfo.shortestDayNames, s = name.toLowerCase(); for (var i = 0; i < n.length; i++) { if (n[i].toLowerCase() === s || m[i].toLowerCase() === s || o[i].toLowerCase() === s) { return i; } } return -1; }; /** * Gets the month number (0-11) if given a Culture Info specific string which is a valid monthName or abbreviatedMonthName. * @param {String} The name of the month (eg. "February, "Feb", "october", "oct"). * @return {Number} The day number */ $D.getMonthNumberFromName = function (name) { var n = Date.CultureInfo.monthNames, m = Date.CultureInfo.abbreviatedMonthNames, s = name.toLowerCase(); for (var i = 0; i < n.length; i++) { if (n[i].toLowerCase() === s || m[i].toLowerCase() === s) { return i; } } return -1; }; /** * Gets the language appropriate month name when given the month number(0-11) * eg - 0 == January * @return {String} The month name */ $D.getMonthName = function (n) { return Date.CultureInfo.monthNames[n]; }; /** * Determines if the current date instance is within a LeapYear. * @param {Number} The year. * @return {Boolean} true if date is within a LeapYear, otherwise false. */ $D.isLeapYear = function (year) { return ((year % 4 === 0 && year % 100 !== 0) || year % 400 === 0); }; /** * Gets the number of days in the month, given a year and month value. Automatically corrects for LeapYear. * @param {Number} The year. * @param {Number} The month (0-11). * @return {Number} The number of days in the month. */ $D.getDaysInMonth = function (year, month) { if (!month && $D.validateMonth(year)) { month = year; year = Date.today().getFullYear(); } return [31, ($D.isLeapYear(year) ? 29 : 28), 31, 30, 31, 30, 31, 31, 30, 31, 30, 31][month]; }; $P.getDaysInMonth = function () { return $D.getDaysInMonth(this.getFullYear(), this.getMonth()); }; $D.getTimezoneAbbreviation = function (offset, dst) { var p, n = (dst || false) ? Date.CultureInfo.abbreviatedTimeZoneDST : Date.CultureInfo.abbreviatedTimeZoneStandard; for (p in n) { if (n.hasOwnProperty(p)) { if (n[p] === offset) { return p; } } } return null; }; $D.getTimezoneOffset = function (name, dst) { var i, a =[], z = Date.CultureInfo.timezones; if (!name) { name = (new Date()).getTimezone();} for (i = 0; i < z.length; i++) { if (z[i].name === name.toUpperCase()) { a.push(i); } } if (!z[a[0]]) { return null; } if (a.length === 1 || !dst) { return z[a[0]].offset; } else { for (i=0; i < a.length; i++) { if (z[a[i]].dst) { return z[a[i]].offset; } } } }; $D.getQuarter = function (d) { d = d || new Date(); // If no date supplied, use today var q = [1,2,3,4]; return q[Math.floor(d.getMonth() / 3)]; // ~~~ is a bitwise op. Faster than Math.floor }; $D.getDaysLeftInQuarter = function (d) { d = d || new Date(); var qEnd = new Date(d); qEnd.setMonth(qEnd.getMonth() + 3 - qEnd.getMonth() % 3, 0); return Math.floor((qEnd - d) / 8.64e7); }; // private var validate = function (n, min, max, name) { name = name ? name : "Object"; if (typeof n === "undefined") { return false; } else if (typeof n !== "number") { throw new TypeError(n + " is not a Number."); } else if (n < min || n > max) { // As failing validation is *not* an exceptional circumstance // lets not throw a RangeError Exception here. // It's semantically correct but it's not sensible. return false; } return true; }; /** * Validates the number is within an acceptable range for milliseconds [0-999]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateMillisecond = function (value) { return validate(value, 0, 999, "millisecond"); }; /** * Validates the number is within an acceptable range for seconds [0-59]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateSecond = function (value) { return validate(value, 0, 59, "second"); }; /** * Validates the number is within an acceptable range for minutes [0-59]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateMinute = function (value) { return validate(value, 0, 59, "minute"); }; /** * Validates the number is within an acceptable range for hours [0-23]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateHour = function (value) { return validate(value, 0, 23, "hour"); }; /** * Validates the number is within an acceptable range for the days in a month [0-MaxDaysInMonth]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateDay = function (value, year, month) { if (year === undefined || year === null || month === undefined || month === null) { return false;} return validate(value, 1, $D.getDaysInMonth(year, month), "day"); }; /** * Validates the number is within an acceptable range for months [0-11]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateWeek = function (value) { return validate(value, 0, 53, "week"); }; /** * Validates the number is within an acceptable range for months [0-11]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateMonth = function (value) { return validate(value, 0, 11, "month"); }; /** * Validates the number is within an acceptable range for years. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateYear = function (value) { /** * Per ECMAScript spec the range of times supported by Date objects is * exactly -100,000,000 days to +100,000,000 days measured relative to * midnight at the beginning of 01 January, 1970 UTC. * This gives a range of 8,640,000,000,000,000 milliseconds to either * side of 01 January, 1970 UTC. * * Earliest possible date: Tue, 20 Apr 271,822 B.C. 00:00:00 UTC * Latest possible date: Sat, 13 Sep 275,760 00:00:00 UTC */ return validate(value, -271822, 275760, "year"); }; $D.validateTimezone = function(value) { var timezones = {"ACDT":1,"ACST":1,"ACT":1,"ADT":1,"AEDT":1,"AEST":1,"AFT":1,"AKDT":1,"AKST":1,"AMST":1,"AMT":1,"ART":1,"AST":1,"AWDT":1,"AWST":1,"AZOST":1,"AZT":1,"BDT":1,"BIOT":1,"BIT":1,"BOT":1,"BRT":1,"BST":1,"BTT":1,"CAT":1,"CCT":1,"CDT":1,"CEDT":1,"CEST":1,"CET":1,"CHADT":1,"CHAST":1,"CHOT":1,"ChST":1,"CHUT":1,"CIST":1,"CIT":1,"CKT":1,"CLST":1,"CLT":1,"COST":1,"COT":1,"CST":1,"CT":1,"CVT":1,"CWST":1,"CXT":1,"DAVT":1,"DDUT":1,"DFT":1,"EASST":1,"EAST":1,"EAT":1,"ECT":1,"EDT":1,"EEDT":1,"EEST":1,"EET":1,"EGST":1,"EGT":1,"EIT":1,"EST":1,"FET":1,"FJT":1,"FKST":1,"FKT":1,"FNT":1,"GALT":1,"GAMT":1,"GET":1,"GFT":1,"GILT":1,"GIT":1,"GMT":1,"GST":1,"GYT":1,"HADT":1,"HAEC":1,"HAST":1,"HKT":1,"HMT":1,"HOVT":1,"HST":1,"ICT":1,"IDT":1,"IOT":1,"IRDT":1,"IRKT":1,"IRST":1,"IST":1,"JST":1,"KGT":1,"KOST":1,"KRAT":1,"KST":1,"LHST":1,"LINT":1,"MAGT":1,"MART":1,"MAWT":1,"MDT":1,"MET":1,"MEST":1,"MHT":1,"MIST":1,"MIT":1,"MMT":1,"MSK":1,"MST":1,"MUT":1,"MVT":1,"MYT":1,"NCT":1,"NDT":1,"NFT":1,"NPT":1,"NST":1,"NT":1,"NUT":1,"NZDT":1,"NZST":1,"OMST":1,"ORAT":1,"PDT":1,"PET":1,"PETT":1,"PGT":1,"PHOT":1,"PHT":1,"PKT":1,"PMDT":1,"PMST":1,"PONT":1,"PST":1,"PYST":1,"PYT":1,"RET":1,"ROTT":1,"SAKT":1,"SAMT":1,"SAST":1,"SBT":1,"SCT":1,"SGT":1,"SLST":1,"SRT":1,"SST":1,"SYOT":1,"TAHT":1,"THA":1,"TFT":1,"TJT":1,"TKT":1,"TLT":1,"TMT":1,"TOT":1,"TVT":1,"UCT":1,"ULAT":1,"UTC":1,"UYST":1,"UYT":1,"UZT":1,"VET":1,"VLAT":1,"VOLT":1,"VOST":1,"VUT":1,"WAKT":1,"WAST":1,"WAT":1,"WEDT":1,"WEST":1,"WET":1,"WST":1,"YAKT":1,"YEKT":1,"Z":1}; return (timezones[value] === 1); }; $D.validateTimezoneOffset= function(value) { // timezones go from +14hrs to -12hrs, the +X hours are negative offsets. return (value > -841 && value < 721); }; }()); (function () { var $D = Date, $P = $D.prototype, p = function (s, l) { if (!l) { l = 2; } return ("000" + s).slice(l * -1); }; var validateConfigObject = function (obj) { var result = {}, self = this, prop, testFunc; testFunc = function (prop, func, value) { if (prop === "day") { var month = (obj.month !== undefined) ? obj.month : self.getMonth(); var year = (obj.year !== undefined) ? obj.year : self.getFullYear(); return $D[func](value, year, month); } else { return $D[func](value); } }; for (prop in obj) { if (Object.prototype.hasOwnProperty.call(obj, prop)) { var func = "validate" + prop.charAt(0).toUpperCase() + prop.slice(1); if ($D[func] && obj[prop] !== null && testFunc(prop, func, obj[prop])) { result[prop] = obj[prop]; } } } return result; }; /** * Resets the time of this Date object to 12:00 AM (00:00), which is the start of the day. * @param {Boolean} .clone() this date instance before clearing Time * @return {Date} this */ $P.clearTime = function () { this.setHours(0); this.setMinutes(0); this.setSeconds(0); this.setMilliseconds(0); return this; }; /** * Resets the time of this Date object to the current time ('now'). * @return {Date} this */ $P.setTimeToNow = function () { var n = new Date(); this.setHours(n.getHours()); this.setMinutes(n.getMinutes()); this.setSeconds(n.getSeconds()); this.setMilliseconds(n.getMilliseconds()); return this; }; /** * Returns a new Date object that is an exact date and time copy of the original instance. * @return {Date} A new Date instance */ $P.clone = function () { return new Date(this.getTime()); }; /** * Compares this instance to a Date object and returns an number indication of their relative values. * @param {Date} Date object to compare [Required] * @return {Number} -1 = this is lessthan date. 0 = values are equal. 1 = this is greaterthan date. */ $P.compareTo = function (date) { return Date.compare(this, date); }; /** * Compares this instance to another Date object and returns true if they are equal. * @param {Date} Date object to compare. If no date to compare, new Date() [now] is used. * @return {Boolean} true if dates are equal. false if they are not equal. */ $P.equals = function (date) { return Date.equals(this, (date !== undefined ? date : new Date())); }; /** * Determines if this instance is between a range of two dates or equal to either the start or end dates. * @param {Date} Start of range [Required] * @param {Date} End of range [Required] * @return {Boolean} true is this is between or equal to the start and end dates, else false */ $P.between = function (start, end) { return this.getTime() >= start.getTime() && this.getTime() <= end.getTime(); }; /** * Determines if this date occurs after the date to compare to. * @param {Date} Date object to compare. If no date to compare, new Date() ("now") is used. * @return {Boolean} true if this date instance is greater than the date to compare to (or "now"), otherwise false. */ $P.isAfter = function (date) { return this.compareTo(date || new Date()) === 1; }; /** * Determines if this date occurs before the date to compare to. * @param {Date} Date object to compare. If no date to compare, new Date() ("now") is used. * @return {Boolean} true if this date instance is less than the date to compare to (or "now"). */ $P.isBefore = function (date) { return (this.compareTo(date || new Date()) === -1); }; /** * Determines if the current Date instance occurs today. * @return {Boolean} true if this date instance is 'today', otherwise false. */ /** * Determines if the current Date instance occurs on the same Date as the supplied 'date'. * If no 'date' to compare to is provided, the current Date instance is compared to 'today'. * @param {date} Date object to compare. If no date to compare, the current Date ("now") is used. * @return {Boolean} true if this Date instance occurs on the same Day as the supplied 'date'. */ $P.isToday = $P.isSameDay = function (date) { return this.clone().clearTime().equals((date || new Date()).clone().clearTime()); }; /** * Adds the specified number of milliseconds to this instance. * @param {Number} The number of milliseconds to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addMilliseconds = function (value) { if (!value) { return this; } this.setTime(this.getTime() + value * 1); return this; }; /** * Adds the specified number of seconds to this instance. * @param {Number} The number of seconds to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addSeconds = function (value) { if (!value) { return this; } return this.addMilliseconds(value * 1000); }; /** * Adds the specified number of seconds to this instance. * @param {Number} The number of seconds to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addMinutes = function (value) { if (!value) { return this; } return this.addMilliseconds(value * 60000); // 60*1000 }; /** * Adds the specified number of hours to this instance. * @param {Number} The number of hours to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addHours = function (value) { if (!value) { return this; } return this.addMilliseconds(value * 3600000); // 60*60*1000 }; /** * Adds the specified number of days to this instance. * @param {Number} The number of days to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addDays = function (value) { if (!value) { return this; } this.setDate(this.getDate() + value * 1); return this; }; /** * Adds the specified number of weekdays (ie - not sat or sun) to this instance. * @param {Number} The number of days to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addWeekdays = function (value) { if (!value) { return this; } var day = this.getDay(); var weeks = (Math.ceil(Math.abs(value)/7)); if (day === 0 || day === 6) { if (value > 0) { this.next().monday(); this.addDays(-1); day = this.getDay(); } } if (value < 0) { while (value < 0) { this.addDays(-1); day = this.getDay(); if (day !== 0 && day !== 6) { value++; } } return this; } else if (value > 5 || (6-day) <= value) { value = value + (weeks * 2); } return this.addDays(value); }; /** * Adds the specified number of weeks to this instance. * @param {Number} The number of weeks to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addWeeks = function (value) { if (!value) { return this; } return this.addDays(value * 7); }; /** * Adds the specified number of months to this instance. * @param {Number} The number of months to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addMonths = function (value) { if (!value) { return this; } var n = this.getDate(); this.setDate(1); this.setMonth(this.getMonth() + value * 1); this.setDate(Math.min(n, $D.getDaysInMonth(this.getFullYear(), this.getMonth()))); return this; }; $P.addQuarters = function (value) { if (!value) { return this; } // note this will take you to the same point in the quarter as you are now. // i.e. - if you are 15 days into the quarter you'll be 15 days into the resulting one. // bonus: this allows adding fractional quarters return this.addMonths(value * 3); }; /** * Adds the specified number of years to this instance. * @param {Number} The number of years to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addYears = function (value) { if (!value) { return this; } return this.addMonths(value * 12); }; /** * Adds (or subtracts) to the value of the years, months, weeks, days, hours, minutes, seconds, milliseconds of the date instance using given configuration object. Positive and Negative values allowed. * Example

	Date.today().add( { days: 1, months: 1 } )

	new Date().add( { years: -1 } )
	
* @param {Object} Configuration object containing attributes (months, days, etc.) * @return {Date} this */ $P.add = function (config) { if (typeof config === "number") { this._orient = config; return this; } var x = config; if (x.day) { // If we should be a different date than today (eg: for 'tomorrow -1d', etc). // Should only effect parsing, not direct usage (eg, Finish and FinishExact) if ((x.day - this.getDate()) !== 0) { this.setDate(x.day); } } if (x.milliseconds) { this.addMilliseconds(x.milliseconds); } if (x.seconds) { this.addSeconds(x.seconds); } if (x.minutes) { this.addMinutes(x.minutes); } if (x.hours) { this.addHours(x.hours); } if (x.weeks) { this.addWeeks(x.weeks); } if (x.months) { this.addMonths(x.months); } if (x.years) { this.addYears(x.years); } if (x.days) { this.addDays(x.days); } return this; }; /** * Get the week number. Week one (1) is the week which contains the first Thursday of the year. Monday is considered the first day of the week. * The .getWeek() function does NOT convert the date to UTC. The local datetime is used. * Please use .getISOWeek() to get the week of the UTC converted date. * @return {Number} 1 to 53 */ $P.getWeek = function (utc) { // Create a copy of this date object var self, target = new Date(this.valueOf()); if (utc) { target.addMinutes(target.getTimezoneOffset()); self = target.clone(); } else { self = this; } // ISO week date weeks start on monday // so correct the day number var dayNr = (self.getDay() + 6) % 7; // ISO 8601 states that week 1 is the week // with the first thursday of that year. // Set the target date to the thursday in the target week target.setDate(target.getDate() - dayNr + 3); // Store the millisecond value of the target date var firstThursday = target.valueOf(); // Set the target to the first thursday of the year // First set the target to january first target.setMonth(0, 1); // Not a thursday? Correct the date to the next thursday if (target.getDay() !== 4) { target.setMonth(0, 1 + ((4 - target.getDay()) + 7) % 7); } // The weeknumber is the number of weeks between the // first thursday of the year and the thursday in the target week return 1 + Math.ceil((firstThursday - target) / 604800000); // 604800000 = 7 * 24 * 3600 * 1000 }; /** * Get the ISO 8601 week number. Week one ("01") is the week which contains the first Thursday of the year. Monday is considered the first day of the week. * The .getISOWeek() function does convert the date to it's UTC value. Please use .getWeek() to get the week of the local date. * @return {String} "01" to "53" */ $P.getISOWeek = function () { return p(this.getWeek(true)); }; /** * Moves the date to Monday of the week set. Week one (1) is the week which contains the first Thursday of the year. * @param {Number} A Number (1 to 53) that represents the week of the year. * @return {Date} this */ $P.setWeek = function (n) { if ((n - this.getWeek()) === 0) { if (this.getDay() !== 1) { return this.moveToDayOfWeek(1, (this.getDay() > 1 ? -1 : 1)); } else { return this; } } else { return this.moveToDayOfWeek(1, (this.getDay() > 1 ? -1 : 1)).addWeeks(n - this.getWeek()); } }; $P.setQuarter = function (qtr) { var month = Math.abs(((qtr-1) * 3) + 1); return this.setMonth(month, 1); }; $P.getQuarter = function () { return Date.getQuarter(this); }; $P.getDaysLeftInQuarter = function () { return Date.getDaysLeftInQuarter(this); }; /** * Moves the date to the next n'th occurrence of the dayOfWeek starting from the beginning of the month. The number (-1) is a magic number and will return the last occurrence of the dayOfWeek in the month. * @param {Number} The dayOfWeek to move to * @param {Number} The n'th occurrence to move to. Use (-1) to return the last occurrence in the month * @return {Date} this */ $P.moveToNthOccurrence = function (dayOfWeek, occurrence) { if (dayOfWeek === "Weekday") { if (occurrence > 0) { this.moveToFirstDayOfMonth(); if (this.is().weekday()) { occurrence -= 1; } } else if (occurrence < 0) { this.moveToLastDayOfMonth(); if (this.is().weekday()) { occurrence += 1; } } else { return this; } return this.addWeekdays(occurrence); } var shift = 0; if (occurrence > 0) { shift = occurrence - 1; } else if (occurrence === -1) { this.moveToLastDayOfMonth(); if (this.getDay() !== dayOfWeek) { this.moveToDayOfWeek(dayOfWeek, -1); } return this; } return this.moveToFirstDayOfMonth().addDays(-1).moveToDayOfWeek(dayOfWeek, +1).addWeeks(shift); }; var moveToN = function (getFunc, addFunc, nVal) { return function (value, orient) { var diff = (value - this[getFunc]() + nVal * (orient || +1)) % nVal; return this[addFunc]((diff === 0) ? diff += nVal * (orient || +1) : diff); }; }; /** * Move to the next or last dayOfWeek based on the orient value. * @param {Number} The dayOfWeek to move to * @param {Number} Forward (+1) or Back (-1). Defaults to +1. [Optional] * @return {Date} this */ $P.moveToDayOfWeek = moveToN("getDay", "addDays", 7); /** * Move to the next or last month based on the orient value. * @param {Number} The month to move to. 0 = January, 11 = December * @param {Number} Forward (+1) or Back (-1). Defaults to +1. [Optional] * @return {Date} this */ $P.moveToMonth = moveToN("getMonth", "addMonths", 12); /** * Get the Ordinate of the current day ("th", "st", "rd"). * @return {String} */ $P.getOrdinate = function () { var num = this.getDate(); return ord(num); }; /** * Get the Ordinal day (numeric day number) of the year, adjusted for leap year. * @return {Number} 1 through 365 (366 in leap years) */ $P.getOrdinalNumber = function () { return Math.ceil((this.clone().clearTime() - new Date(this.getFullYear(), 0, 1)) / 86400000) + 1; }; /** * Get the time zone abbreviation of the current date. * @return {String} The abbreviated time zone name (e.g. "EST") */ $P.getTimezone = function () { return $D.getTimezoneAbbreviation(this.getUTCOffset(), this.isDaylightSavingTime()); }; $P.setTimezoneOffset = function (offset) { var here = this.getTimezoneOffset(), there = Number(offset) * -6 / 10; return (there || there === 0) ? this.addMinutes(there - here) : this; }; $P.setTimezone = function (offset) { return this.setTimezoneOffset($D.getTimezoneOffset(offset)); }; /** * Indicates whether Daylight Saving Time is observed in the current time zone. * @return {Boolean} true|false */ $P.hasDaylightSavingTime = function () { return (Date.today().set({month: 0, day: 1}).getTimezoneOffset() !== Date.today().set({month: 6, day: 1}).getTimezoneOffset()); }; /** * Indicates whether this Date instance is within the Daylight Saving Time range for the current time zone. * @return {Boolean} true|false */ $P.isDaylightSavingTime = function () { return Date.today().set({month: 0, day: 1}).getTimezoneOffset() !== this.getTimezoneOffset(); }; /** * Get the offset from UTC of the current date. * @return {String} The 4-character offset string prefixed with + or - (e.g. "-0500") */ $P.getUTCOffset = function (offset) { var n = (offset || this.getTimezoneOffset()) * -10 / 6, r; if (n < 0) { r = (n - 10000).toString(); return r.charAt(0) + r.substr(2); } else { r = (n + 10000).toString(); return "+" + r.substr(1); } }; /** * Returns the number of milliseconds between this date and date. * @param {Date} Defaults to now * @return {Number} The diff in milliseconds */ $P.getElapsed = function (date) { return (date || new Date()) - this; }; /** * Set the value of year, month, day, hour, minute, second, millisecond of date instance using given configuration object. * Example

	Date.today().set( { day: 20, month: 1 } )

	new Date().set( { millisecond: 0 } )
	
* * @param {Object} Configuration object containing attributes (month, day, etc.) * @return {Date} this */ $P.set = function (config) { config = validateConfigObject.call(this, config); var key; for (key in config) { if (Object.prototype.hasOwnProperty.call(config, key)) { var name = key.charAt(0).toUpperCase() + key.slice(1); var addFunc, getFunc; if (key !== "week" && key !== "month" && key !== "timezone" && key !== "timezoneOffset") { name += "s"; } addFunc = "add" + name; getFunc = "get" + name; if (key === "month") { addFunc = addFunc + "s"; } else if (key === "year"){ getFunc = "getFullYear"; } if (key !== "day" && key !== "timezone" && key !== "timezoneOffset" && key !== "week" && key !== "hour") { this[addFunc](config[key] - this[getFunc]()); } else if ( key === "timezone"|| key === "timezoneOffset" || key === "week" || key === "hour") { this["set"+name](config[key]); } } } // day has to go last because you can't validate the day without first knowing the month if (config.day) { this.addDays(config.day - this.getDate()); } return this; }; /** * Moves the date to the first day of the month. * @return {Date} this */ $P.moveToFirstDayOfMonth = function () { return this.set({ day: 1 }); }; /** * Moves the date to the last day of the month. * @return {Date} this */ $P.moveToLastDayOfMonth = function () { return this.set({ day: $D.getDaysInMonth(this.getFullYear(), this.getMonth())}); }; /** * Converts the value of the current Date object to its equivalent string representation. * Format Specifiers * CUSTOM DATE AND TIME FORMAT STRINGS * Format Description Example * ------ --------------------------------------------------------------------------- ----------------------- * s The seconds of the minute between 0-59. "0" to "59" * ss The seconds of the minute with leading zero if required. "00" to "59" * * m The minute of the hour between 0-59. "0" or "59" * mm The minute of the hour with leading zero if required. "00" or "59" * * h The hour of the day between 1-12. "1" to "12" * hh The hour of the day with leading zero if required. "01" to "12" * * H The hour of the day between 0-23. "0" to "23" * HH The hour of the day with leading zero if required. "00" to "23" * * d The day of the month between 1 and 31. "1" to "31" * dd The day of the month with leading zero if required. "01" to "31" * ddd Abbreviated day name. Date.CultureInfo.abbreviatedDayNames. "Mon" to "Sun" * dddd The full day name. Date.CultureInfo.dayNames. "Monday" to "Sunday" * * M The month of the year between 1-12. "1" to "12" * MM The month of the year with leading zero if required. "01" to "12" * MMM Abbreviated month name. Date.CultureInfo.abbreviatedMonthNames. "Jan" to "Dec" * MMMM The full month name. Date.CultureInfo.monthNames. "January" to "December" * * yy The year as a two-digit number. "99" or "08" * yyyy The full four digit year. "1999" or "2008" * * t Displays the first character of the A.M./P.M. designator. "A" or "P" * Date.CultureInfo.amDesignator or Date.CultureInfo.pmDesignator * tt Displays the A.M./P.M. designator. "AM" or "PM" * Date.CultureInfo.amDesignator or Date.CultureInfo.pmDesignator * * S The ordinal suffix ("st, "nd", "rd" or "th") of the current day. "st, "nd", "rd" or "th" * * STANDARD DATE AND TIME FORMAT STRINGS * Format Description Example *------ --------------------------------------------------------------------------- ----------------------- * d The CultureInfo shortDate Format Pattern "M/d/yyyy" * D The CultureInfo longDate Format Pattern "dddd, MMMM dd, yyyy" * F The CultureInfo fullDateTime Format Pattern "dddd, MMMM dd, yyyy h:mm:ss tt" * m The CultureInfo monthDay Format Pattern "MMMM dd" * r The CultureInfo rfc1123 Format Pattern "ddd, dd MMM yyyy HH:mm:ss GMT" * s The CultureInfo sortableDateTime Format Pattern "yyyy-MM-ddTHH:mm:ss" * t The CultureInfo shortTime Format Pattern "h:mm tt" * T The CultureInfo longTime Format Pattern "h:mm:ss tt" * u The CultureInfo universalSortableDateTime Format Pattern "yyyy-MM-dd HH:mm:ssZ" * y The CultureInfo yearMonth Format Pattern "MMMM, yyyy" * * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @return {String} A string representation of the current Date object. */ var ord = function (n) { switch (n * 1) { case 1: case 21: case 31: return "st"; case 2: case 22: return "nd"; case 3: case 23: return "rd"; default: return "th"; } }; var parseStandardFormats = function (format) { var y, c = Date.CultureInfo.formatPatterns; switch (format) { case "d": return this.toString(c.shortDate); case "D": return this.toString(c.longDate); case "F": return this.toString(c.fullDateTime); case "m": return this.toString(c.monthDay); case "r": case "R": y = this.clone().addMinutes(this.getTimezoneOffset()); return y.toString(c.rfc1123) + " GMT"; case "s": return this.toString(c.sortableDateTime); case "t": return this.toString(c.shortTime); case "T": return this.toString(c.longTime); case "u": y = this.clone().addMinutes(this.getTimezoneOffset()); return y.toString(c.universalSortableDateTime); case "y": return this.toString(c.yearMonth); default: return false; } }; var parseFormatStringsClosure = function (context) { return function (m) { if (m.charAt(0) === "\\") { return m.replace("\\", ""); } switch (m) { case "hh": return p(context.getHours() < 13 ? (context.getHours() === 0 ? 12 : context.getHours()) : (context.getHours() - 12)); case "h": return context.getHours() < 13 ? (context.getHours() === 0 ? 12 : context.getHours()) : (context.getHours() - 12); case "HH": return p(context.getHours()); case "H": return context.getHours(); case "mm": return p(context.getMinutes()); case "m": return context.getMinutes(); case "ss": return p(context.getSeconds()); case "s": return context.getSeconds(); case "yyyy": return p(context.getFullYear(), 4); case "yy": return p(context.getFullYear()); case "y": return context.getFullYear(); case "E": case "dddd": return Date.CultureInfo.dayNames[context.getDay()]; case "ddd": return Date.CultureInfo.abbreviatedDayNames[context.getDay()]; case "dd": return p(context.getDate()); case "d": return context.getDate(); case "MMMM": return Date.CultureInfo.monthNames[context.getMonth()]; case "MMM": return Date.CultureInfo.abbreviatedMonthNames[context.getMonth()]; case "MM": return p((context.getMonth() + 1)); case "M": return context.getMonth() + 1; case "t": return context.getHours() < 12 ? Date.CultureInfo.amDesignator.substring(0, 1) : Date.CultureInfo.pmDesignator.substring(0, 1); case "tt": return context.getHours() < 12 ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator; case "S": return ord(context.getDate()); case "W": return context.getWeek(); case "WW": return context.getISOWeek(); case "Q": return "Q" + context.getQuarter(); case "q": return String(context.getQuarter()); case "z": return context.getTimezone(); case "Z": case "X": return Date.getTimezoneOffset(context.getTimezone()); case "ZZ": // Timezone offset in seconds return context.getTimezoneOffset() * -60; case "u": return context.getDay(); case "L": return ($D.isLeapYear(context.getFullYear())) ? 1 : 0; case "B": // Swatch Internet Time (.beats) return "@"+((context.getUTCSeconds() + (context.getUTCMinutes()*60) + ((context.getUTCHours()+1)*3600))/86.4); default: return m; } }; }; $P.toString = function (format, ignoreStandards) { // Standard Date and Time Format Strings. Formats pulled from CultureInfo file and // may vary by culture. if (!ignoreStandards && format && format.length === 1) { output = parseStandardFormats.call(this, format); if (output) { return output; } } var parseFormatStrings = parseFormatStringsClosure(this); return format ? format.replace(/((\\)?(dd?d?d?|MM?M?M?|yy?y?y?|hh?|HH?|mm?|ss?|tt?|S|q|Q|WW?W?W?)(?![^\[]*\]))/g, parseFormatStrings).replace(/\[|\]/g, "") : this._toString(); }; }()); /************************************************************* * SugarPak - Domain Specific Language - Syntactical Sugar * *************************************************************/ (function () { var $D = Date, $P = $D.prototype, $N = Number.prototype; // private $P._orient = +1; // private $P._nth = null; // private $P._is = false; // private $P._same = false; // private $P._isSecond = false; // private $N._dateElement = "days"; /** * Moves the date to the next instance of a date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.today().next().friday();
	Date.today().next().fri();
	Date.today().next().march();
	Date.today().next().mar();
	Date.today().next().week();
	
* * @return {Date} date */ $P.next = function () { this._move = true; this._orient = +1; return this; }; /** * Creates a new Date (Date.today()) and moves the date to the next instance of the date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.next().friday();
	Date.next().fri();
	Date.next().march();
	Date.next().mar();
	Date.next().week();
	
* * @return {Date} date */ $D.next = function () { return $D.today().next(); }; /** * Moves the date to the previous instance of a date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.today().last().friday();
	Date.today().last().fri();
	Date.today().last().march();
	Date.today().last().mar();
	Date.today().last().week();
	
* * @return {Date} date */ $P.last = $P.prev = $P.previous = function () { this._move = true; this._orient = -1; return this; }; /** * Creates a new Date (Date.today()) and moves the date to the previous instance of the date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.last().friday();
	Date.last().fri();
	Date.previous().march();
	Date.prev().mar();
	Date.last().week();
	
* * @return {Date} date */ $D.last = $D.prev = $D.previous = function () { return $D.today().last(); }; /** * Performs a equality check when followed by either a month name, day name or .weekday() function. * Example

	Date.today().is().friday(); // true|false
	Date.today().is().fri();
	Date.today().is().march();
	Date.today().is().mar();
	
* * @return {Boolean} true|false */ $P.is = function () { this._is = true; return this; }; /** * Determines if two date objects occur on/in exactly the same instance of the subsequent date part function. * The function .same() must be followed by a date part function (example: .day(), .month(), .year(), etc). * * An optional Date can be passed in the date part function. If now date is passed as a parameter, 'Now' is used. * * The following example demonstrates how to determine if two dates fall on the exact same day. * * Example

	var d1 = Date.today(); // today at 00:00
	var d2 = new Date();   // exactly now.

	// Do they occur on the same day?
	d1.same().day(d2); // true
	
	// Do they occur on the same hour?
	d1.same().hour(d2); // false, unless d2 hour is '00' (midnight).
	
	// What if it's the same day, but one year apart?
	var nextYear = Date.today().add(1).year();

	d1.same().day(nextYear); // false, because the dates must occur on the exact same day. 
	
* * Scenario: Determine if a given date occurs during some week period 2 months from now. * * Example

	var future = Date.today().add(2).months();
	return someDate.same().week(future); // true|false;
	
* * @return {Boolean} true|false */ $P.same = function () { this._same = true; this._isSecond = false; return this; }; /** * Determines if the current date/time occurs during Today. Must be preceded by the .is() function. * Example

	someDate.is().today();    // true|false
	new Date().is().today();  // true
	Date.today().is().today();// true
	Date.today().add(-1).day().is().today(); // false
	
* * @return {Boolean} true|false */ $P.today = function () { return this.same().day(); }; /** * Determines if the current date is a weekday. This function must be preceded by the .is() function. * Example

	Date.today().is().weekday(); // true|false
	
* * @return {Boolean} true|false */ $P.weekday = function () { if (this._nth) { return df("Weekday").call(this); } if (this._move) { return this.addWeekdays(this._orient); } if (this._is) { this._is = false; return (!this.is().sat() && !this.is().sun()); } return false; }; /** * Determines if the current date is on the weekend. This function must be preceded by the .is() function. * Example

	Date.today().is().weekend(); // true|false
	
* * @return {Boolean} true|false */ $P.weekend = function () { if (this._is) { this._is = false; return (this.is().sat() || this.is().sun()); } return false; }; /** * Sets the Time of the current Date instance. A string "6:15 pm" or config object {hour:18, minute:15} are accepted. * Example

	// Set time to 6:15pm with a String
	Date.today().at("6:15pm");

	// Set time to 6:15pm with a config object
	Date.today().at({hour:18, minute:15});
	
* * @return {Date} date */ $P.at = function (time) { return (typeof time === "string") ? $D.parse(this.toString("d") + " " + time) : this.set(time); }; /** * Creates a new Date() and adds this (Number) to the date based on the preceding date element function (eg. second|minute|hour|day|month|year). * Example

	// Undeclared Numbers must be wrapped with parentheses. Requirment of JavaScript.
	(3).days().fromNow();
	(6).months().fromNow();

	// Declared Number variables do not require parentheses. 
	var n = 6;
	n.months().fromNow();
	
* * @return {Date} A new Date instance */ $N.fromNow = $N.after = function (date) { var c = {}; c[this._dateElement] = this; return ((!date) ? new Date() : date.clone()).add(c); }; /** * Creates a new Date() and subtract this (Number) from the date based on the preceding date element function (eg. second|minute|hour|day|month|year). * Example

	// Undeclared Numbers must be wrapped with parentheses. Requirment of JavaScript.
	(3).days().ago();
	(6).months().ago();

	// Declared Number variables do not require parentheses. 
	var n = 6;
	n.months().ago();
	
* * @return {Date} A new Date instance */ $N.ago = $N.before = function (date) { var c = {}, s = (this._dateElement[this._dateElement.length-1] !== "s") ? this._dateElement + "s" : this._dateElement; c[s] = this * -1; return ((!date) ? new Date() : date.clone()).add(c); }; // Do NOT modify the following string tokens. These tokens are used to build dynamic functions. // All culture-specific strings can be found in the CultureInfo files. var dx = ("sunday monday tuesday wednesday thursday friday saturday").split(/\s/), mx = ("january february march april may june july august september october november december").split(/\s/), px = ("Millisecond Second Minute Hour Day Week Month Year Quarter Weekday").split(/\s/), pxf = ("Milliseconds Seconds Minutes Hours Date Week Month FullYear Quarter").split(/\s/), nth = ("final first second third fourth fifth").split(/\s/), de; /** * Returns an object literal of all the date parts. * Example

	var o = new Date().toObject();
	
	// { year: 2008, month: 4, week: 20, day: 13, hour: 18, minute: 9, second: 32, millisecond: 812 }
	
	// The object properties can be referenced directly from the object.
	
	alert(o.day);  // alerts "13"
	alert(o.year); // alerts "2008"
	
* * @return {Date} An object literal representing the original date object. */ $P.toObject = function () { var o = {}; for (var i = 0; i < px.length; i++) { if (this["get" + pxf[i]]) { o[px[i].toLowerCase()] = this["get" + pxf[i]](); } } return o; }; /** * Returns a date created from an object literal. Ignores the .week property if set in the config. * Example

	var o = new Date().toObject();
	
	return Date.fromObject(o); // will return the same date. 

	var o2 = {month: 1, day: 20, hour: 18}; // birthday party!
	Date.fromObject(o2);
	
* * @return {Date} An object literal representing the original date object. */ $D.fromObject = function(config) { config.week = null; return Date.today().set(config); }; // Create day name functions and abbreviated day name functions (eg. monday(), friday(), fri()). var df = function (n) { return function () { if (this._is) { this._is = false; return this.getDay() === n; } if (this._move) { this._move = null; } if (this._nth !== null) { // If the .second() function was called earlier, remove the _orient // from the date, and then continue. // This is required because 'second' can be used in two different context. // // Example // // Date.today().add(1).second(); // Date.march().second().monday(); // // Things get crazy with the following... // Date.march().add(1).second().second().monday(); // but it works!! // if (this._isSecond) { this.addSeconds(this._orient * -1); } // make sure we reset _isSecond this._isSecond = false; var ntemp = this._nth; this._nth = null; var temp = this.clone().moveToLastDayOfMonth(); this.moveToNthOccurrence(n, ntemp); if (this > temp) { throw new RangeError($D.getDayName(n) + " does not occur " + ntemp + " times in the month of " + $D.getMonthName(temp.getMonth()) + " " + temp.getFullYear() + "."); } return this; } return this.moveToDayOfWeek(n, this._orient); }; }; var sdf = function (n) { return function () { var t = $D.today(), shift = n - t.getDay(); if (n === 0 && Date.CultureInfo.firstDayOfWeek === 1 && t.getDay() !== 0) { shift = shift + 7; } return t.addDays(shift); }; }; // Create month name functions and abbreviated month name functions (eg. january(), march(), mar()). var month_instance_functions = function (n) { return function () { if (this._is) { this._is = false; return this.getMonth() === n; } return this.moveToMonth(n, this._orient); }; }; var month_static_functions = function (n) { return function () { return $D.today().set({ month: n, day: 1 }); }; }; var processTerms = function (names, staticFunc, instanceFunc) { for (var i = 0; i < names.length; i++) { // Create constant static Name variables. $D[names[i].toUpperCase()] = $D[names[i].toUpperCase().substring(0, 3)] = i; // Create Name functions. $D[names[i]] = $D[names[i].substring(0, 3)] = staticFunc(i); // Create Name instance functions. $P[names[i]] = $P[names[i].substring(0, 3)] = instanceFunc(i); } }; processTerms(dx, sdf, df); processTerms(mx, month_static_functions, month_instance_functions); // Create date element functions and plural date element functions used with Date (eg. day(), days(), months()). var ef = function (j) { return function () { // if the .second() function was called earlier, the _orient // has alread been added. Just return this and reset _isSecond. if (this._isSecond) { this._isSecond = false; return this; } if (this._same) { this._same = this._is = false; var o1 = this.toObject(), o2 = (arguments[0] || new Date()).toObject(), v = "", k = j.toLowerCase(); // the substr trick with -1 doesn't work in IE8 or less k = (k[k.length-1] === "s") ? k.substring(0,k.length-1) : k; for (var m = (px.length - 1); m > -1; m--) { v = px[m].toLowerCase(); if (o1[v] !== o2[v]) { return false; } if (k === v) { break; } } return true; } if (j.substring(j.length - 1) !== "s") { j += "s"; } if (this._move) { this._move = null; } return this["add" + j](this._orient); }; }; var nf = function (n) { return function () { this._dateElement = n; return this; }; }; for (var k = 0; k < px.length; k++) { de = px[k].toLowerCase(); if(de !== "weekday") { // Create date element functions and plural date element functions used with Date (eg. day(), days(), months()). $P[de] = $P[de + "s"] = ef(px[k]); // Create date element functions and plural date element functions used with Number (eg. day(), days(), months()). $N[de] = $N[de + "s"] = nf(de + "s"); } } $P._ss = ef("Second"); var nthfn = function (n) { return function (dayOfWeek) { if (this._same) { return this._ss(arguments[0]); } if (dayOfWeek || dayOfWeek === 0) { return this.moveToNthOccurrence(dayOfWeek, n); } this._nth = n; // if the operator is 'second' add the _orient, then deal with it later... if (n === 2 && (dayOfWeek === undefined || dayOfWeek === null)) { this._isSecond = true; return this.addSeconds(this._orient); } return this; }; }; for (var l = 0; l < nth.length; l++) { $P[nth[l]] = (l === 0) ? nthfn(-1) : nthfn(l); } }()); (function () { "use strict"; Date.Parsing = { Exception: function (s) { this.message = "Parse error at '" + s.substring(0, 10) + " ...'"; } }; var $P = Date.Parsing; var dayOffsets = { standard: [0,31,59,90,120,151,181,212,243,273,304,334], leap: [0,31,60,91,121,152,182,213,244,274,305,335] }; $P.isLeapYear = function(year) { return ((year % 4 === 0) && (year % 100 !== 0)) || (year % 400 === 0); }; var utils = { multiReplace : function (str, hash ) { var key; for (key in hash) { if (Object.prototype.hasOwnProperty.call(hash, key)) { var regex; if (typeof hash[key] === "function") { } else { regex = (hash[key] instanceof RegExp) ? hash[key] : new RegExp(hash[key], "g"); } str = str.replace(regex, key); } } return str; }, getDayOfYearFromWeek : function (obj) { var d, jan4, offset; obj.weekDay = (!obj.weekDay && obj.weekDay !== 0) ? 1 : obj.weekDay; d = new Date(obj.year, 0, 4); jan4 = d.getDay() === 0 ? 7 : d.getDay(); // JS is 0 indexed on Sunday. offset = jan4+3; obj.dayOfYear = ((obj.week * 7) + (obj.weekDay === 0 ? 7 : obj.weekDay))-offset; return obj; }, getDayOfYear : function (obj, dayOffset) { if (!obj.dayOfYear) { obj = utils.getDayOfYearFromWeek(obj); } for (var i=0;i <= dayOffset.length;i++) { if (obj.dayOfYear < dayOffset[i] || i === dayOffset.length) { obj.day = obj.day ? obj.day : (obj.dayOfYear - dayOffset[i-1]); break; } else { obj.month = i; } } return obj; }, adjustForTimeZone : function (obj, date) { var offset; if (obj.zone.toUpperCase() === "Z" || (obj.zone_hours === 0 && obj.zone_minutes === 0)) { // it's UTC/GML so work out the current timeszone offset offset = -date.getTimezoneOffset(); } else { offset = (obj.zone_hours*60) + (obj.zone_minutes || 0); if (obj.zone_sign === "+") { offset *= -1; } offset -= date.getTimezoneOffset(); } date.setMinutes(date.getMinutes()+offset); return date; }, setDefaults : function (obj) { obj.year = obj.year || Date.today().getFullYear(); obj.hours = obj.hours || 0; obj.minutes = obj.minutes || 0; obj.seconds = obj.seconds || 0; obj.milliseconds = obj.milliseconds || 0; if (!(!obj.month && (obj.week || obj.dayOfYear))) { // if we have a month, or if we don't but don't have the day calculation data obj.month = obj.month || 0; obj.day = obj.day || 1; } return obj; }, dataNum: function (data, mod, explict, postProcess) { var dataNum = data*1; if (mod) { if (postProcess) { return data ? mod(data)*1 : data; } else { return data ? mod(dataNum) : data; } } else if (!explict){ return data ? dataNum : data; } else { return (data && typeof data !== "undefined") ? dataNum : data; } }, timeDataProcess: function (obj) { var timeObj = {}; for (var x in obj.data) { if (obj.data.hasOwnProperty(x)) { timeObj[x] = obj.ignore[x] ? obj.data[x] : utils.dataNum(obj.data[x], obj.mods[x], obj.explict[x], obj.postProcess[x]); } } if (obj.data.secmins) { obj.data.secmins = obj.data.secmins.replace(",", ".") * 60; if (!timeObj.minutes) { timeObj.minutes = obj.data.secmins; } else if (!timeObj.seconds) { timeObj.seconds = obj.data.secmins; } delete obj.secmins; } return timeObj; }, buildTimeObjectFromData: function (data) { var time = utils.timeDataProcess({ data: { year : data[1], month : data[5], day : data[7], week : data[8], dayOfYear : data[10], hours : data[15], zone_hours : data[23], zone_minutes : data[24], zone : data[21], zone_sign : data[22], weekDay : data[9], minutes: data[16], seconds: data[19], milliseconds: data[20], secmins: data[18] }, mods: { month: function(data) { return data-1; }, weekDay: function (data) { data = Math.abs(data); return (data === 7 ? 0 : data); }, minutes: function (data) { return data.replace(":",""); }, seconds: function (data) { return Math.floor( (data.replace(":","").replace(",","."))*1 ); }, milliseconds: function (data) { return (data.replace(",",".")*1000); } }, postProcess: { minutes: true, seconds: true, milliseconds: true }, explict: { zone_hours: true, zone_minutes: true }, ignore: { zone: true, zone_sign: true, secmins: true } }); return time; }, addToHash: function (hash, keys, data) { keys = keys; data = data; var len = keys.length; for (var i = 0; i < len; i++) { hash[keys[i]] = data[i]; } return hash; }, combineRegex: function (r1, r2) { return new RegExp("(("+r1.source+")\\s("+r2.source+"))"); }, getDateNthString: function(add, last, inc){ if (add) { return Date.today().addDays(inc).toString("d"); } else if (last) { return Date.today().last()[inc]().toString("d"); } }, buildRegexData: function (array) { var arr = []; var len = array.length; for (var i=0; i < len; i++) { if (Object.prototype.toString.call(array[i]) === '[object Array]') { // oldIE compat version of Array.isArray arr.push(this.combineRegex(array[i][0], array[i][1])); } else { arr.push(array[i]); } } return arr; } }; $P.processTimeObject = function (obj) { var date, dayOffset; utils.setDefaults(obj); dayOffset = ($P.isLeapYear(obj.year)) ? dayOffsets.leap : dayOffsets.standard; if (!obj.month && (obj.week || obj.dayOfYear)) { utils.getDayOfYear(obj, dayOffset); } else { obj.dayOfYear = dayOffset[obj.month] + obj.day; } date = new Date(obj.year, obj.month, obj.day, obj.hours, obj.minutes, obj.seconds, obj.milliseconds); if (obj.zone) { utils.adjustForTimeZone(obj, date); // adjust (and calculate) for timezone } return date; }; $P.ISO = { regex : /^([\+-]?\d{4}(?!\d{2}\b))((-?)((0[1-9]|1[0-2])(\3([12]\d|0[1-9]|3[01]))?|W([0-4]\d|5[0-3])(-?[1-7])?|(00[1-9]|0[1-9]\d|[12]\d{2}|3([0-5]\d|6[1-6])))([T\s]((([01]\d|2[0-4])((:?)[0-5]\d)?|24\:?00)([\.,]\d+(?!:))?)?(\17[0-5]\d([\.,]\d+)?)?\s?([zZ]|([\+-])([01]\d|2[0-3]):?([0-5]\d)?)?)?)?$/, parse : function (s) { var time, data = s.match(this.regex); if (!data || !data.length) { return null; } time = utils.buildTimeObjectFromData(data); if (!time.year || (!time.year && (!time.month && !time.day) && (!time.week && !time.dayOfYear)) ) { return null; } return $P.processTimeObject(time); } }; $P.Numeric = { isNumeric: function (e){return!isNaN(parseFloat(e))&&isFinite(e);}, regex: /\b([0-1]?[0-9])([0-3]?[0-9])([0-2]?[0-9]?[0-9][0-9])\b/i, parse: function (s) { var data, i, time = {}, order = Date.CultureInfo.dateElementOrder.split(""); if (!(this.isNumeric(s)) || // if it's non-numeric OR (s[0] === "+" && s[0] === "-")) { // It's an arithmatic string (eg +/-1000) return null; } if (s.length < 5 && s.indexOf(".") < 0 && s.indexOf("/") < 0) { // assume it's just a year. time.year = s; return $P.processTimeObject(time); } data = s.match(this.regex); if (!data || !data.length) { return null; } for (i=0; i < order.length; i++) { switch(order[i]) { case "d": time.day = data[i+1]; break; case "m": time.month = (data[i+1]-1); break; case "y": time.year = data[i+1]; break; } } return $P.processTimeObject(time); } }; $P.Normalizer = { regexData: function () { var $R = Date.CultureInfo.regexPatterns; return utils.buildRegexData([ $R.tomorrow, $R.yesterday, [$R.past, $R.mon], [$R.past, $R.tue], [$R.past, $R.wed], [$R.past, $R.thu], [$R.past, $R.fri], [$R.past, $R.sat], [$R.past, $R.sun] ]); }, basicReplaceHash : function() { var $R = Date.CultureInfo.regexPatterns; return { "January": $R.jan.source, "February": $R.feb, "March": $R.mar, "April": $R.apr, "May": $R.may, "June": $R.jun, "July": $R.jul, "August": $R.aug, "September": $R.sep, "October": $R.oct, "November": $R.nov, "December": $R.dec, "": /\bat\b/gi, " ": /\s{2,}/, "am": $R.inTheMorning, "9am": $R.thisMorning, "pm": $R.inTheEvening, "7pm":$R.thisEvening }; }, keys : function(){ return [ utils.getDateNthString(true, false, 1), // tomorrow utils.getDateNthString(true, false, -1), // yesterday utils.getDateNthString(false, true, "monday"), //last mon utils.getDateNthString(false, true, "tuesday"), //last tues utils.getDateNthString(false, true, "wednesday"), //last wed utils.getDateNthString(false, true, "thursday"), //last thurs utils.getDateNthString(false, true, "friday"), //last fri utils.getDateNthString(false, true, "saturday"), //last sat utils.getDateNthString(false, true, "sunday") //last sun ]; }, buildRegexFunctions: function () { var $R = Date.CultureInfo.regexPatterns; var __ = Date.i18n.__; var tomorrowRE = new RegExp("(\\b\\d\\d?("+__("AM")+"|"+__("PM")+")? )("+$R.tomorrow.source.slice(1)+")", "i"); // adapted tomorrow regex for AM PM relative dates var todayRE = new RegExp($R.today.source + "(?!\\s*([+-]))\\b"); // today, but excludes the math operators (eg "today + 2h") this.replaceFuncs = [ [todayRE, function (full) { return (full.length > 1) ? Date.today().toString("d") : full; }], [tomorrowRE, function(full, m1) { var t = Date.today().addDays(1).toString("d"); return (t + " " + m1); }], [$R.amThisMorning, function(str, am){return am;}], [$R.pmThisEvening, function(str, pm){return pm;}] ]; }, buildReplaceData: function () { this.buildRegexFunctions(); this.replaceHash = utils.addToHash(this.basicReplaceHash(), this.keys(), this.regexData()); }, stringReplaceFuncs: function (s) { for (var i=0; i < this.replaceFuncs.length; i++) { s = s.replace(this.replaceFuncs[i][0], this.replaceFuncs[i][1]); } return s; }, parse: function (s) { s = this.stringReplaceFuncs(s); s = utils.multiReplace(s, this.replaceHash); try { var n = s.split(/([\s\-\.\,\/\x27]+)/); if (n.length === 3 && $P.Numeric.isNumeric(n[0]) && $P.Numeric.isNumeric(n[2]) && (n[2].length >= 4)) { // ok, so we're dealing with x/year. But that's not a full date. // This fixes wonky dateElementOrder parsing when set to dmy order. if (Date.CultureInfo.dateElementOrder[0] === "d") { s = "1/" + n[0] + "/" + n[2]; // set to 1st of month and normalize the seperator } } } catch (e) {} return s; } }; $P.Normalizer.buildReplaceData(); }()); (function () { var $P = Date.Parsing; var _ = $P.Operators = { // // Tokenizers // rtoken: function (r) { // regex token return function (s) { var mx = s.match(r); if (mx) { return ([ mx[0], s.substring(mx[0].length) ]); } else { throw new $P.Exception(s); } }; }, token: function () { // whitespace-eating token return function (s) { return _.rtoken(new RegExp("^\\s*" + s + "\\s*"))(s); }; }, stoken: function (s) { // string token return _.rtoken(new RegExp("^" + s)); }, // Atomic Operators until: function (p) { return function (s) { var qx = [], rx = null; while (s.length) { try { rx = p.call(this, s); } catch (e) { qx.push(rx[0]); s = rx[1]; continue; } break; } return [ qx, s ]; }; }, many: function (p) { return function (s) { var rx = [], r = null; while (s.length) { try { r = p.call(this, s); } catch (e) { return [ rx, s ]; } rx.push(r[0]); s = r[1]; } return [ rx, s ]; }; }, // generator operators -- see below optional: function (p) { return function (s) { var r = null; try { r = p.call(this, s); } catch (e) { return [ null, s ]; } return [ r[0], r[1] ]; }; }, not: function (p) { return function (s) { try { p.call(this, s); } catch (e) { return [null, s]; } throw new $P.Exception(s); }; }, ignore: function (p) { return p ? function (s) { var r = null; r = p.call(this, s); return [null, r[1]]; } : null; }, product: function () { var px = arguments[0], qx = Array.prototype.slice.call(arguments, 1), rx = []; for (var i = 0 ; i < px.length ; i++) { rx.push(_.each(px[i], qx)); } return rx; }, cache: function (rule) { var cache = {}, cache_length = 0, cache_keys = [], CACHE_MAX = Date.Config.CACHE_MAX || 100000, r = null; var cacheCheck = function () { if (cache_length === CACHE_MAX) { // kill several keys, don't want to have to do this all the time... for (var i=0; i < 10; i++) { var key = cache_keys.shift(); if (key) { delete cache[key]; cache_length--; } } } }; return function (s) { cacheCheck(); try { r = cache[s] = (cache[s] || rule.call(this, s)); } catch (e) { r = cache[s] = e; } cache_length++; cache_keys.push(s); if (r instanceof $P.Exception) { throw r; } else { return r; } }; }, // vector operators -- see below any: function () { var px = arguments; return function (s) { var r = null; for (var i = 0; i < px.length; i++) { if (px[i] == null) { continue; } try { r = (px[i].call(this, s)); } catch (e) { r = null; } if (r) { return r; } } throw new $P.Exception(s); }; }, each: function () { var px = arguments; return function (s) { var rx = [], r = null; for (var i = 0; i < px.length ; i++) { if (px[i] == null) { continue; } try { r = (px[i].call(this, s)); } catch (e) { throw new $P.Exception(s); } rx.push(r[0]); s = r[1]; } return [ rx, s]; }; }, all: function () { var px = arguments, _ = _; return _.each(_.optional(px)); }, // delimited operators sequence: function (px, d, c) { d = d || _.rtoken(/^\s*/); c = c || null; if (px.length === 1) { return px[0]; } return function (s) { var r = null, q = null; var rx = []; for (var i = 0; i < px.length ; i++) { try { r = px[i].call(this, s); } catch (e) { break; } rx.push(r[0]); try { q = d.call(this, r[1]); } catch (ex) { q = null; break; } s = q[1]; } if (!r) { throw new $P.Exception(s); } if (q) { throw new $P.Exception(q[1]); } if (c) { try { r = c.call(this, r[1]); } catch (ey) { throw new $P.Exception(r[1]); } } return [ rx, (r?r[1]:s) ]; }; }, // // Composite Operators // between: function (d1, p, d2) { d2 = d2 || d1; var _fn = _.each(_.ignore(d1), p, _.ignore(d2)); return function (s) { var rx = _fn.call(this, s); return [[rx[0][0], r[0][2]], rx[1]]; }; }, list: function (p, d, c) { d = d || _.rtoken(/^\s*/); c = c || null; return (p instanceof Array ? _.each(_.product(p.slice(0, -1), _.ignore(d)), p.slice(-1), _.ignore(c)) : _.each(_.many(_.each(p, _.ignore(d))), px, _.ignore(c))); }, set: function (px, d, c) { d = d || _.rtoken(/^\s*/); c = c || null; return function (s) { // r is the current match, best the current 'best' match // which means it parsed the most amount of input var r = null, p = null, q = null, rx = null, best = [[], s], last = false; // go through the rules in the given set for (var i = 0; i < px.length ; i++) { // last is a flag indicating whether this must be the last element // if there is only 1 element, then it MUST be the last one q = null; p = null; r = null; last = (px.length === 1); // first, we try simply to match the current pattern // if not, try the next pattern try { r = px[i].call(this, s); } catch (e) { continue; } // since we are matching against a set of elements, the first // thing to do is to add r[0] to matched elements rx = [[r[0]], r[1]]; // if we matched and there is still input to parse and // we don't already know this is the last element, // we're going to next check for the delimiter ... // if there's none, or if there's no input left to parse // than this must be the last element after all ... if (r[1].length > 0 && ! last) { try { q = d.call(this, r[1]); } catch (ex) { last = true; } } else { last = true; } // if we parsed the delimiter and now there's no more input, // that means we shouldn't have parsed the delimiter at all // so don't update r and mark this as the last element ... if (!last && q[1].length === 0) { last = true; } // so, if this isn't the last element, we're going to see if // we can get any more matches from the remaining (unmatched) // elements ... if (!last) { // build a list of the remaining rules we can match against, // i.e., all but the one we just matched against var qx = []; for (var j = 0; j < px.length ; j++) { if (i !== j) { qx.push(px[j]); } } // now invoke recursively set with the remaining input // note that we don't include the closing delimiter ... // we'll check for that ourselves at the end p = _.set(qx, d).call(this, q[1]); // if we got a non-empty set as a result ... // (otw rx already contains everything we want to match) if (p[0].length > 0) { // update current result, which is stored in rx ... // basically, pick up the remaining text from p[1] // and concat the result from p[0] so that we don't // get endless nesting ... rx[0] = rx[0].concat(p[0]); rx[1] = p[1]; } } // at this point, rx either contains the last matched element // or the entire matched set that starts with this element. // now we just check to see if this variation is better than // our best so far, in terms of how much of the input is parsed if (rx[1].length < best[1].length) { best = rx; } // if we've parsed all the input, then we're finished if (best[1].length === 0) { break; } } // so now we've either gone through all the patterns trying them // as the initial match; or we found one that parsed the entire // input string ... // if best has no matches, just return empty set ... if (best[0].length === 0) { return best; } // if a closing delimiter is provided, then we have to check it also if (c) { // we try this even if there is no remaining input because the pattern // may well be optional or match empty input ... try { q = c.call(this, best[1]); } catch (ey) { throw new $P.Exception(best[1]); } // it parsed ... be sure to update the best match remaining input best[1] = q[1]; } // if we're here, either there was no closing delimiter or we parsed it // so now we have the best match; just return it! return best; }; }, forward: function (gr, fname) { return function (s) { return gr[fname].call(this, s); }; }, // // Translation Operators // replace: function (rule, repl) { return function (s) { var r = rule.call(this, s); return [repl, r[1]]; }; }, process: function (rule, fn) { return function (s) { var r = rule.call(this, s); return [fn.call(this, r[0]), r[1]]; }; }, min: function (min, rule) { return function (s) { var rx = rule.call(this, s); if (rx[0].length < min) { throw new $P.Exception(s); } return rx; }; } }; // Generator Operators And Vector Operators // Generators are operators that have a signature of F(R) => R, // taking a given rule and returning another rule, such as // ignore, which parses a given rule and throws away the result. // Vector operators are those that have a signature of F(R1,R2,...) => R, // take a list of rules and returning a new rule, such as each. // Generator operators are converted (via the following _generator // function) into functions that can also take a list or array of rules // and return an array of new rules as though the function had been // called on each rule in turn (which is what actually happens). // This allows generators to be used with vector operators more easily. // Example: // each(ignore(foo, bar)) instead of each(ignore(foo), ignore(bar)) // This also turns generators into vector operators, which allows // constructs like: // not(cache(foo, bar)) var _generator = function (op) { function gen() { var args = null, rx = [], px, i; if (arguments.length > 1) { args = Array.prototype.slice.call(arguments); } else if (arguments[0] instanceof Array) { args = arguments[0]; } if (args) { px = args.shift(); if (px.length > 0) { args.unshift(px[i]); rx.push(op.apply(null, args)); args.shift(); return rx; } } else { return op.apply(null, arguments); } } return gen; }; var gx = "optional not ignore cache".split(/\s/); for (var i = 0 ; i < gx.length ; i++) { _[gx[i]] = _generator(_[gx[i]]); } var _vector = function (op) { return function () { if (arguments[0] instanceof Array) { return op.apply(null, arguments[0]); } else { return op.apply(null, arguments); } }; }; var vx = "each any all".split(/\s/); for (var j = 0 ; j < vx.length ; j++) { _[vx[j]] = _vector(_[vx[j]]); } }()); (function () { var $D = Date; var flattenAndCompact = function (ax) { var rx = []; for (var i = 0; i < ax.length; i++) { if (ax[i] instanceof Array) { rx = rx.concat(flattenAndCompact(ax[i])); } else { if (ax[i]) { rx.push(ax[i]); } } } return rx; }; var parseMeridian = function () { if (this.meridian && (this.hour || this.hour === 0)) { if (this.meridian === "a" && this.hour > 11 && Date.Config.strict24hr){ throw "Invalid hour and meridian combination"; } else if (this.meridian === "p" && this.hour < 12 && Date.Config.strict24hr){ throw "Invalid hour and meridian combination"; } else if (this.meridian === "p" && this.hour < 12) { this.hour = this.hour + 12; } else if (this.meridian === "a" && this.hour === 12) { this.hour = 0; } } }; var setDefaults = function () { var now = new Date(); if ((this.hour || this.minute) && (!this.month && !this.year && !this.day)) { this.day = now.getDate(); } if (!this.year) { this.year = now.getFullYear(); } if (!this.month && this.month !== 0) { this.month = now.getMonth(); } if (!this.day) { this.day = 1; } if (!this.hour) { this.hour = 0; } if (!this.minute) { this.minute = 0; } if (!this.second) { this.second = 0; } if (!this.millisecond) { this.millisecond = 0; } }; var finishUtils = { getToday: function () { if (this.now || "hour minute second".indexOf(this.unit) !== -1) { return new Date(); } else { return $D.today(); } }, setDaysFromWeekday: function (today, orient){ var gap; orient = orient || 1; this.unit = "day"; gap = ($D.getDayNumberFromName(this.weekday) - today.getDay()); this.days = gap ? ((gap + (orient * 7)) % 7) : (orient * 7); return this; }, setMonthsFromMonth: function (today, orient) { var gap; orient = orient || 1; this.unit = "month"; gap = (this.month - today.getMonth()); this.months = gap ? ((gap + (orient * 12)) % 12) : (orient * 12); this.month = null; return this; }, setDMYFromWeekday: function () { var d = Date[this.weekday](); this.day = d.getDate(); if (!this.month) { this.month = d.getMonth(); } this.year = d.getFullYear(); return this; }, setUnitValue: function (orient) { if (!this.value && this.operator && this.operator !== null && this[this.unit + "s"] && this[this.unit + "s"] !== null) { this[this.unit + "s"] = this[this.unit + "s"] + ((this.operator === "add") ? 1 : -1) + (this.value||0) * orient; } else if (this[this.unit + "s"] == null || this.operator != null) { if (!this.value) { this.value = 1; } this[this.unit + "s"] = this.value * orient; } }, generateDateFromWeeks: function () { var weekday = (this.weekday !== undefined) ? this.weekday : "today"; var d = Date[weekday]().addWeeks(this.weeks); if (this.now) { d.setTimeToNow(); } return d; } }; $D.Translator = { hour: function (s) { return function () { this.hour = Number(s); }; }, minute: function (s) { return function () { this.minute = Number(s); }; }, second: function (s) { return function () { this.second = Number(s); }; }, /* for ss.s format */ secondAndMillisecond: function (s) { return function () { var mx = s.match(/^([0-5][0-9])\.([0-9]{1,3})/); this.second = Number(mx[1]); this.millisecond = Number(mx[2]); }; }, meridian: function (s) { return function () { this.meridian = s.slice(0, 1).toLowerCase(); }; }, timezone: function (s) { return function () { var n = s.replace(/[^\d\+\-]/g, ""); if (n.length) { this.timezoneOffset = Number(n); } else { this.timezone = s.toLowerCase(); } }; }, day: function (x) { var s = x[0]; return function () { this.day = Number(s.match(/\d+/)[0]); if (this.day < 1) { throw "invalid day"; } }; }, month: function (s) { return function () { this.month = (s.length === 3) ? "jan feb mar apr may jun jul aug sep oct nov dec".indexOf(s)/4 : Number(s) - 1; if (this.month < 0) { throw "invalid month"; } }; }, year: function (s) { return function () { var n = Number(s); this.year = ((s.length > 2) ? n : (n + (((n + 2000) < Date.CultureInfo.twoDigitYearMax) ? 2000 : 1900))); }; }, rday: function (s) { return function () { switch (s) { case "yesterday": this.days = -1; break; case "tomorrow": this.days = 1; break; case "today": this.days = 0; break; case "now": this.days = 0; this.now = true; break; } }; }, finishExact: function (x) { var d; x = (x instanceof Array) ? x : [x]; for (var i = 0 ; i < x.length ; i++) { if (x[i]) { x[i].call(this); } } setDefaults.call(this); parseMeridian.call(this); if (this.day > $D.getDaysInMonth(this.year, this.month)) { throw new RangeError(this.day + " is not a valid value for days."); } d = new Date(this.year, this.month, this.day, this.hour, this.minute, this.second, this.millisecond); if (this.year < 100) { d.setFullYear(this.year); // means years less that 100 are process correctly. JS will parse it otherwise as 1900-1999. } if (this.timezone) { d.set({ timezone: this.timezone }); } else if (this.timezoneOffset) { d.set({ timezoneOffset: this.timezoneOffset }); } return d; }, finish: function (x) { var today, expression, orient, temp; x = (x instanceof Array) ? flattenAndCompact(x) : [ x ]; if (x.length === 0) { return null; } for (var i = 0 ; i < x.length ; i++) { if (typeof x[i] === "function") { x[i].call(this); } } if (this.now && !this.unit && !this.operator) { return new Date(); } else { today = finishUtils.getToday.call(this); } expression = !!(this.days && this.days !== null || this.orient || this.operator); orient = ((this.orient === "past" || this.operator === "subtract") ? -1 : 1); if (this.month && this.unit === "week") { this.value = this.month + 1; delete this.month; delete this.day; } if ((this.month || this.month === 0) && "year day hour minute second".indexOf(this.unit) !== -1) { if (!this.value) { this.value = this.month + 1; } this.month = null; expression = true; } if (!expression && this.weekday && !this.day && !this.days) { finishUtils.setDMYFromWeekday.call(this); } if (expression && this.weekday && this.unit !== "month" && this.unit !== "week") { finishUtils.setDaysFromWeekday.call(this, today, orient); } if (this.weekday && this.unit !== "week" && !this.day && !this.days) { temp = Date[this.weekday](); this.day = temp.getDate(); if (temp.getMonth() !== today.getMonth()) { this.month = temp.getMonth(); } } if (this.month && this.unit === "day" && this.operator) { if (!this.value) { this.value = (this.month + 1); } this.month = null; } if (this.value != null && this.month != null && this.year != null) { this.day = this.value * 1; } if (this.month && !this.day && this.value) { today.set({ day: this.value * 1 }); if (!expression) { this.day = this.value * 1; } } if (!this.month && this.value && this.unit === "month" && !this.now) { this.month = this.value; expression = true; } if (expression && (this.month || this.month === 0) && this.unit !== "year") { finishUtils.setMonthsFromMonth.call(this, today, orient); } if (!this.unit) { this.unit = "day"; } finishUtils.setUnitValue.call(this, orient); parseMeridian.call(this); if ((this.month || this.month === 0) && !this.day) { this.day = 1; } if (!this.orient && !this.operator && this.unit === "week" && this.value && !this.day && !this.month) { return Date.today().setWeek(this.value); } if (this.unit === "week" && this.weeks && !this.day && !this.month) { return finishUtils.generateDateFromWeeks.call(this); } if (expression && this.timezone && this.day && this.days) { this.day = this.days; } if (expression){ today.add(this); } else { today.set(this); } if (this.timezone) { this.timezone = this.timezone.toUpperCase(); var offset = $D.getTimezoneOffset(this.timezone); var timezone; if (today.hasDaylightSavingTime()) { // lets check that we're being sane with timezone setting timezone = $D.getTimezoneAbbreviation(offset, today.isDaylightSavingTime()); if (timezone !== this.timezone) { // bugger, we're in a place where things like EST vs EDT matters. if (today.isDaylightSavingTime()) { today.addHours(-1); } else { today.addHours(1); } } } today.setTimezoneOffset(offset); } return today; } }; }()); (function () { var $D = Date; $D.Grammar = {}; var _ = $D.Parsing.Operators, g = $D.Grammar, t = $D.Translator, _fn; // Allow rolling up into general purpose rules _fn = function () { return _.each(_.any.apply(null, arguments), _.not(g.ctoken2("timeContext"))); }; g.datePartDelimiter = _.rtoken(/^([\s\-\.\,\/\x27]+)/); g.timePartDelimiter = _.stoken(":"); g.whiteSpace = _.rtoken(/^\s*/); g.generalDelimiter = _.rtoken(/^(([\s\,]|at|@|on)+)/); var _C = {}; g.ctoken = function (keys) { var fn = _C[keys]; if (! fn) { var c = Date.CultureInfo.regexPatterns; var kx = keys.split(/\s+/), px = []; for (var i = 0; i < kx.length ; i++) { px.push(_.replace(_.rtoken(c[kx[i]]), kx[i])); } fn = _C[keys] = _.any.apply(null, px); } return fn; }; g.ctoken2 = function (key) { return _.rtoken(Date.CultureInfo.regexPatterns[key]); }; var cacheProcessRtoken = function (key, token, type, eachToken) { if (eachToken) { g[key] = _.cache(_.process(_.each(_.rtoken(token),_.optional(g.ctoken2(eachToken))), type)); } else { g[key] = _.cache(_.process(_.rtoken(token), type)); } }; var cacheProcessCtoken = function (token, type) { return _.cache(_.process(g.ctoken2(token), type)); }; var _F = {}; //function cache var _get = function (f) { _F[f] = (_F[f] || g.format(f)[0]); return _F[f]; }; g.allformats = function (fx) { var rx = []; if (fx instanceof Array) { for (var i = 0; i < fx.length; i++) { rx.push(_get(fx[i])); } } else { rx.push(_get(fx)); } return rx; }; g.formats = function (fx) { if (fx instanceof Array) { var rx = []; for (var i = 0 ; i < fx.length ; i++) { rx.push(_get(fx[i])); } return _.any.apply(null, rx); } else { return _get(fx); } }; var grammarFormats = { timeFormats: function(){ var i, RTokenKeys = [ "h", "hh", "H", "HH", "m", "mm", "s", "ss", "ss.s", "z", "zz" ], RToken = [ /^(0[0-9]|1[0-2]|[1-9])/, /^(0[0-9]|1[0-2])/, /^([0-1][0-9]|2[0-3]|[0-9])/, /^([0-1][0-9]|2[0-3])/, /^([0-5][0-9]|[0-9])/, /^[0-5][0-9]/, /^([0-5][0-9]|[0-9])/, /^[0-5][0-9]/, /^[0-5][0-9]\.[0-9]{1,3}/, /^((\+|\-)\s*\d\d\d\d)|((\+|\-)\d\d\:?\d\d)/, /^((\+|\-)\s*\d\d\d\d)|((\+|\-)\d\d\:?\d\d)/ ], tokens = [ t.hour, t.hour, t.hour, t.hour, t.minute, t.minute, t.second, t.second, t.secondAndMillisecond, t.timezone, t.timezone ]; for (i=0; i < RTokenKeys.length; i++) { cacheProcessRtoken(RTokenKeys[i], RToken[i], tokens[i]); } g.hms = _.cache(_.sequence([g.H, g.m, g.s], g.timePartDelimiter)); g.t = cacheProcessCtoken("shortMeridian", t.meridian); g.tt = cacheProcessCtoken("longMeridian", t.meridian); g.zzz = cacheProcessCtoken("timezone", t.timezone); g.timeSuffix = _.each(_.ignore(g.whiteSpace), _.set([ g.tt, g.zzz ])); g.time = _.each(_.optional(_.ignore(_.stoken("T"))), g.hms, g.timeSuffix); }, dateFormats: function () { // pre-loaded rules for different date part order preferences var _setfn = function () { return _.set(arguments, g.datePartDelimiter); }; var i, RTokenKeys = [ "d", "dd", "M", "MM", "y", "yy", "yyy", "yyyy" ], RToken = [ /^([0-2]\d|3[0-1]|\d)/, /^([0-2]\d|3[0-1])/, /^(1[0-2]|0\d|\d)/, /^(1[0-2]|0\d)/, /^(\d+)/, /^(\d\d)/, /^(\d\d?\d?\d?)/, /^(\d\d\d\d)/ ], tokens = [ t.day, t.day, t.month, t.month, t.year, t.year, t.year, t.year ], eachToken = [ "ordinalSuffix", "ordinalSuffix" ]; for (i=0; i < RTokenKeys.length; i++) { cacheProcessRtoken(RTokenKeys[i], RToken[i], tokens[i], eachToken[i]); } g.MMM = g.MMMM = _.cache(_.process(g.ctoken("jan feb mar apr may jun jul aug sep oct nov dec"), t.month)); g.ddd = g.dddd = _.cache(_.process(g.ctoken("sun mon tue wed thu fri sat"), function (s) { return function () { this.weekday = s; }; } )); g.day = _fn(g.d, g.dd); g.month = _fn(g.M, g.MMM); g.year = _fn(g.yyyy, g.yy); g.mdy = _setfn(g.ddd, g.month, g.day, g.year); g.ymd = _setfn(g.ddd, g.year, g.month, g.day); g.dmy = _setfn(g.ddd, g.day, g.month, g.year); g.date = function (s) { return ((g[Date.CultureInfo.dateElementOrder] || g.mdy).call(this, s)); }; }, relative: function () { // relative date / time expressions g.orientation = _.process(g.ctoken("past future"), function (s) { return function () { this.orient = s; }; } ); g.operator = _.process(g.ctoken("add subtract"), function (s) { return function () { this.operator = s; }; } ); g.rday = _.process(g.ctoken("yesterday tomorrow today now"), t.rday); g.unit = _.process(g.ctoken("second minute hour day week month year"), function (s) { return function () { this.unit = s; }; } ); } }; g.buildGrammarFormats = function () { // these need to be rebuilt every time the language changes. _C = {}; grammarFormats.timeFormats(); grammarFormats.dateFormats(); grammarFormats.relative(); g.value = _.process(_.rtoken(/^([-+]?\d+)?(st|nd|rd|th)?/), function (s) { return function () { this.value = s.replace(/\D/g, ""); }; } ); g.expression = _.set([g.rday, g.operator, g.value, g.unit, g.orientation, g.ddd, g.MMM ]); g.format = _.process(_.many( _.any( // translate format specifiers into grammar rules _.process( _.rtoken(/^(dd?d?d?(?!e)|MM?M?M?|yy?y?y?|hh?|HH?|mm?|ss?|tt?|zz?z?)/), function (fmt) { if (g[fmt]) { return g[fmt]; } else { throw $D.Parsing.Exception(fmt); } } ), // translate separator tokens into token rules _.process(_.rtoken(/^[^dMyhHmstz]+/), // all legal separators function (s) { return _.ignore(_.stoken(s)); } ) ) ), // construct the parser ... function (rules) { return _.process(_.each.apply(null, rules), t.finishExact); } ); // starting rule for general purpose grammar g._start = _.process(_.set([ g.date, g.time, g.expression ], g.generalDelimiter, g.whiteSpace), t.finish); }; g.buildGrammarFormats(); // parsing date format specifiers - ex: "h:m:s tt" // this little guy will generate a custom parser based // on the format string, ex: g.format("h:m:s tt") // check for these formats first g._formats = g.formats([ "\"yyyy-MM-ddTHH:mm:ssZ\"", "yyyy-MM-ddTHH:mm:ss.sz", "yyyy-MM-ddTHH:mm:ssZ", "yyyy-MM-ddTHH:mm:ssz", "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-ddTHH:mmZ", "yyyy-MM-ddTHH:mmz", "yyyy-MM-ddTHH:mm", "ddd, MMM dd, yyyy H:mm:ss tt", "ddd MMM d yyyy HH:mm:ss zzz", "MMddyyyy", "ddMMyyyy", "Mddyyyy", "ddMyyyy", "Mdyyyy", "dMyyyy", "yyyy", "Mdyy", "dMyy", "d" ]); // real starting rule: tries selected formats first, // then general purpose rule g.start = function (s) { try { var r = g._formats.call({}, s); if (r[1].length === 0) { return r; } } catch (e) {} return g._start.call({}, s); }; }()); (function () { var $D = Date; /** * @desc Converts the specified string value into its JavaScript Date equivalent using CultureInfo specific format information. * * Example

	///////////
	// Dates //
	///////////

	// 15-Oct-2004
	var d1 = Date.parse("10/15/2004");

	// 15-Oct-2004
	var d1 = Date.parse("15-Oct-2004");

	// 15-Oct-2004
	var d1 = Date.parse("2004.10.15");

	//Fri Oct 15, 2004
	var d1 = Date.parse("Fri Oct 15, 2004");

	///////////
	// Times //
	///////////

	// Today at 10 PM.
	var d1 = Date.parse("10 PM");

	// Today at 10:30 PM.
	var d1 = Date.parse("10:30 P.M.");

	// Today at 6 AM.
	var d1 = Date.parse("06am");

	/////////////////////
	// Dates and Times //
	/////////////////////

	// 8-July-2004 @ 10:30 PM
	var d1 = Date.parse("July 8th, 2004, 10:30 PM");

	// 1-July-2004 @ 10:30 PM
	var d1 = Date.parse("2004-07-01T22:30:00");

	////////////////////
	// Relative Dates //
	////////////////////

	// Returns today's date. The string "today" is culture specific.
	var d1 = Date.parse("today");

	// Returns yesterday's date. The string "yesterday" is culture specific.
	var d1 = Date.parse("yesterday");

	// Returns the date of the next thursday.
	var d1 = Date.parse("Next thursday");

	// Returns the date of the most previous monday.
	var d1 = Date.parse("last monday");

	// Returns today's day + one year.
	var d1 = Date.parse("next year");

	///////////////
	// Date Math //
	///////////////

	// Today + 2 days
	var d1 = Date.parse("t+2");

	// Today + 2 days
	var d1 = Date.parse("today + 2 days");

	// Today + 3 months
	var d1 = Date.parse("t+3m");

	// Today - 1 year
	var d1 = Date.parse("today - 1 year");

	// Today - 1 year
	var d1 = Date.parse("t-1y"); 


	/////////////////////////////
	// Partial Dates and Times //
	/////////////////////////////

	// July 15th of this year.
	var d1 = Date.parse("July 15");

	// 15th day of current day and year.
	var d1 = Date.parse("15");

	// July 1st of current year at 10pm.
	var d1 = Date.parse("7/1 10pm");
	
* * @param {String} The string value to convert into a Date object [Required] * @return {Date} A Date object or null if the string cannot be converted into a Date. */ var parseUtils = { removeOrds: function (s) { ords = s.match(/\b(\d+)(?:st|nd|rd|th)\b/); // find ordinal matches s = ((ords && ords.length === 2) ? s.replace(ords[0], ords[1]) : s); return s; }, grammarParser: function (s) { var r = null; try { r = $D.Grammar.start.call({}, s.replace(/^\s*(\S*(\s+\S+)*)\s*$/, "$1")); } catch (e) { return null; } return ((r[1].length === 0) ? r[0] : null); }, nativeFallback: function(s) { var t; try { // ok we haven't parsed it, last ditch attempt with the built-in parser. t = Date._parse(s); return (t || t === 0) ? new Date(t) : null; } catch (e) { return null; } } }; function parse (s) { var d; if (!s) { return null; } if (s instanceof Date) { return s.clone(); } if (s.length >= 4 && s.charAt(0) !== "0" && s.charAt(0) !== "+"&& s.charAt(0) !== "-") { // ie: 2004 will pass, 0800 won't. // Start with specific formats d = $D.Parsing.ISO.parse(s) || $D.Parsing.Numeric.parse(s); } if (d instanceof Date && !isNaN(d.getTime())) { return d; } else { // find ordinal dates (1st, 3rd, 8th, etc and remove them as they cause parsing issues) s = $D.Parsing.Normalizer.parse(parseUtils.removeOrds(s)); d = parseUtils.grammarParser(s); if (d !== null) { return d; } else { return parseUtils.nativeFallback(s); } } } if (!$D._parse) { $D._parse = $D.parse; } $D.parse = parse; Date.getParseFunction = function (fx) { var fns = Date.Grammar.allformats(fx); return function (s) { var r = null; for (var i = 0; i < fns.length; i++) { try { r = fns[i].call({}, s); } catch (e) { continue; } if (r[1].length === 0) { return r[0]; } } return null; }; }; /** * Converts the specified string value into its JavaScript Date equivalent using the specified format {String} or formats {Array} and the CultureInfo specific format information. * The format of the string value must match one of the supplied formats exactly. * * Example

	// 15-Oct-2004
	var d1 = Date.parseExact("10/15/2004", "M/d/yyyy");

	// 15-Oct-2004
	var d1 = Date.parse("15-Oct-2004", "M-ddd-yyyy");

	// 15-Oct-2004
	var d1 = Date.parse("2004.10.15", "yyyy.MM.dd");

	// Multiple formats
	var d1 = Date.parseExact("10/15/2004", ["M/d/yyyy", "MMMM d, yyyy"]);
	
* * @param {String} The string value to convert into a Date object [Required]. * @param {Object} The expected format {String} or an array of expected formats {Array} of the date string [Required]. * @return {Date} A Date object or null if the string cannot be converted into a Date. */ $D.parseExact = function (s, fx) { return $D.getParseFunction(fx)(s); }; }()); (function () { var $D = Date, $P = $D.prototype, // $C = $D.CultureInfo, // not used atm p = function (s, l) { if (!l) { l = 2; } return ("000" + s).slice(l * -1); }; /** * Converts a PHP format string to Java/.NET format string. * A PHP format string can be used with ._format or .format. * A Java/.NET format string can be used with .toString(). * The .parseExact function will only accept a Java/.NET format string * * Example * var f1 = "%m/%d/%y" * var f2 = Date.normalizeFormat(f1); // "MM/dd/yy" * * new Date().format(f1); // "04/13/08" * new Date()._format(f1); // "04/13/08" * new Date().toString(f2); // "04/13/08" * * var date = Date.parseExact("04/13/08", f2); // Sun Apr 13 2008 * * @param {String} A PHP format string consisting of one or more format spcifiers. * @return {String} The PHP format converted to a Java/.NET format string. */ var normalizerSubstitutions = { "d" : "dd", "%d": "dd", "D" : "ddd", "%a": "ddd", "j" : "dddd", "l" : "dddd", "%A": "dddd", "S" : "S", "F" : "MMMM", "%B": "MMMM", "m" : "MM", "%m": "MM", "M" : "MMM", "%b": "MMM", "%h": "MMM", "n" : "M", "Y" : "yyyy", "%Y": "yyyy", "y" : "yy", "%y": "yy", "g" : "h", "%I": "h", "G" : "H", "h" : "hh", "H" : "HH", "%H": "HH", "i" : "mm", "%M": "mm", "s" : "ss", "%S": "ss", "%r": "hh:mm tt", "%R": "H:mm", "%T": "H:mm:ss", "%X": "t", "%x": "d", "%e": "d", "%D": "MM/dd/yy", "%n": "\\n", "%t": "\\t", "e" : "z", "T" : "z", "%z": "z", "%Z": "z", "Z" : "ZZ", "N" : "u", "w" : "u", "%w": "u", "W" : "W", "%V": "W" }; var normalizer = { substitutes: function (m) { return normalizerSubstitutions[m]; }, interpreted: function (m, x) { var y; switch (m) { case "%u": return x.getDay() + 1; case "z": return x.getOrdinalNumber(); case "%j": return p(x.getOrdinalNumber(), 3); case "%U": var d1 = x.clone().set({month: 0, day: 1}).addDays(-1).moveToDayOfWeek(0), d2 = x.clone().addDays(1).moveToDayOfWeek(0, -1); return (d2 < d1) ? "00" : p((d2.getOrdinalNumber() - d1.getOrdinalNumber()) / 7 + 1); case "%W": return p(x.getWeek()); case "t": return $D.getDaysInMonth(x.getFullYear(), x.getMonth()); case "o": case "%G": return x.setWeek(x.getISOWeek()).toString("yyyy"); case "%g": return x._format("%G").slice(-2); case "a": case "%p": return t("tt").toLowerCase(); case "A": return t("tt").toUpperCase(); case "u": return p(x.getMilliseconds(), 3); case "I": return (x.isDaylightSavingTime()) ? 1 : 0; case "O": return x.getUTCOffset(); case "P": y = x.getUTCOffset(); return y.substring(0, y.length - 2) + ":" + y.substring(y.length - 2); case "B": var now = new Date(); return Math.floor(((now.getHours() * 3600) + (now.getMinutes() * 60) + now.getSeconds() + (now.getTimezoneOffset() + 60) * 60) / 86.4); case "c": return x.toISOString().replace(/\"/g, ""); case "U": return $D.strtotime("now"); case "%c": return t("d") + " " + t("t"); case "%C": return Math.floor(x.getFullYear() / 100 + 1); } }, shouldOverrideDefaults: function (m) { switch (m) { case "%e": return true; default: return false; } }, parse: function (m, context) { var formatString, c = context || new Date(); formatString = normalizer.substitutes(m); if (formatString) { return formatString; } formatString = normalizer.interpreted(m, c); if (formatString) { return formatString; } else { return m; } } }; $D.normalizeFormat = function (format, context) { return format.replace(/(%|\\)?.|%%/g, function(t){ return normalizer.parse(t, context); }); }; /** * Format a local Unix timestamp according to locale settings * * Example: * Date.strftime("%m/%d/%y", new Date()); // "04/13/08" * Date.strftime("c", "2008-04-13T17:52:03Z"); // "04/13/08" * * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @param {Number|String} The number representing the number of seconds that have elapsed since January 1, 1970 (local time). * @return {String} A string representation of the current Date object. */ $D.strftime = function (format, time) { var d = Date.parse(time); return d._format(format); }; /** * Parse any textual datetime description into a Unix timestamp. * A Unix timestamp is the number of seconds that have elapsed since January 1, 1970 (midnight UTC/GMT). * * Example: * Date.strtotime("04/13/08"); // 1208044800 * Date.strtotime("1970-01-01T00:00:00Z"); // 0 * * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @param {Object} A string or date object. * @return {String} A string representation of the current Date object. */ $D.strtotime = function (time) { var d = $D.parse(time); return Math.round($D.UTC(d.getUTCFullYear(), d.getUTCMonth(), d.getUTCDate(), d.getUTCHours(), d.getUTCMinutes(), d.getUTCSeconds(), d.getUTCMilliseconds()) / 1000); }; /** * Converts the value of the current Date object to its equivalent string representation using a PHP/Unix style of date format specifiers. * Format Specifiers * Format Description Example * ------ --------------------------------------------------------------------------- ----------------------- * %a abbreviated weekday name according to the current localed "Mon" through "Sun" * %A full weekday name according to the current localed "Sunday" through "Saturday" * %b abbreviated month name according to the current localed "Jan" through "Dec" * %B full month name according to the current locale "January" through "December" * %c preferred date and time representation for the current locale "4/13/2008 12:33 PM" * %C century number (the year divided by 100 and truncated to an integer) "00" to "99" * %d day of the month as a decimal number "01" to "31" * %D same as %m/%d/%y "04/13/08" * %e day of the month as a decimal number, a single digit is preceded by a space "1" to "31" * %g like %G, but without the century "08" * %G The 4-digit year corresponding to the ISO week number (see %V). "2008" * This has the same format and value as %Y, except that if the ISO week number * belongs to the previous or next year, that year is used instead. * %h same as %b "Jan" through "Dec" * %H hour as a decimal number using a 24-hour clock. "00" to "23" * %I hour as a decimal number using a 12-hour clock. "01" to "12" * %j day of the year as a decimal number. "001" to "366" * %m month as a decimal number. "01" to "12" * %M minute as a decimal number. "00" to "59" * %n newline character "\n" * %p either "am" or "pm" according to the given time value, or the "am" or "pm" * corresponding strings for the current locale. * %r time in a.m. and p.m. notation "8:44 PM" * %R time in 24 hour notation "20:44" * %S second as a decimal number "00" to "59" * %t tab character "\t" * %T current time, equal to %H:%M:%S "12:49:11" * %u weekday as a decimal number ["1", "7"], with "1" representing Monday "1" to "7" * %U week number of the current year as a decimal number, starting with the "0" to ("52" or "53") * first Sunday as the first day of the first week * %V The ISO 8601:1988 week number of the current year as a decimal number, "00" to ("52" or "53") * range 01 to 53, where week 1 is the first week that has at least 4 days * in the current year, and with Monday as the first day of the week. * (Use %G or %g for the year component that corresponds to the week number * for the specified timestamp.) * %W week number of the current year as a decimal number, starting with the "00" to ("52" or "53") * first Monday as the first day of the first week * %w day of the week as a decimal, Sunday being "0" "0" to "6" * %x preferred date representation for the current locale without the time "4/13/2008" * %X preferred time representation for the current locale without the date "12:53:05" * %y year as a decimal number without a century "00" "99" * %Y year as a decimal number including the century "2008" * %Z time zone or name or abbreviation "UTC", "EST", "PST" * %z same as %Z * %% a literal "%" characters "%" * d Day of the month, 2 digits with leading zeros "01" to "31" * D A textual representation of a day, three letters "Mon" through "Sun" * j Day of the month without leading zeros "1" to "31" * l A full textual representation of the day of the week (lowercase "L") "Sunday" through "Saturday" * N ISO-8601 numeric representation of the day of the week (added in PHP 5.1.0) "1" (for Monday) through "7" (for Sunday) * S English ordinal suffix for the day of the month, 2 characters "st", "nd", "rd" or "th". Works well with j * w Numeric representation of the day of the week "0" (for Sunday) through "6" (for Saturday) * z The day of the year (starting from "0") "0" through "365" * W ISO-8601 week number of year, weeks starting on Monday "00" to ("52" or "53") * F A full textual representation of a month, such as January or March "January" through "December" * m Numeric representation of a month, with leading zeros "01" through "12" * M A short textual representation of a month, three letters "Jan" through "Dec" * n Numeric representation of a month, without leading zeros "1" through "12" * t Number of days in the given month "28" through "31" * L Whether it's a leap year "1" if it is a leap year, "0" otherwise * o ISO-8601 year number. This has the same value as Y, except that if the "2008" * ISO week number (W) belongs to the previous or next year, that year * is used instead. * Y A full numeric representation of a year, 4 digits "2008" * y A two digit representation of a year "08" * a Lowercase Ante meridiem and Post meridiem "am" or "pm" * A Uppercase Ante meridiem and Post meridiem "AM" or "PM" * B Swatch Internet time "000" through "999" * g 12-hour format of an hour without leading zeros "1" through "12" * G 24-hour format of an hour without leading zeros "0" through "23" * h 12-hour format of an hour with leading zeros "01" through "12" * H 24-hour format of an hour with leading zeros "00" through "23" * i Minutes with leading zeros "00" to "59" * s Seconds, with leading zeros "00" through "59" * u Milliseconds "54321" * e Timezone identifier "UTC", "EST", "PST" * I Whether or not the date is in daylight saving time (uppercase i) "1" if Daylight Saving Time, "0" otherwise * O Difference to Greenwich time (GMT) in hours "+0200", "-0600" * P Difference to Greenwich time (GMT) with colon between hours and minutes "+02:00", "-06:00" * T Timezone abbreviation "UTC", "EST", "PST" * Z Timezone offset in seconds. The offset for timezones west of UTC is "-43200" through "50400" * always negative, and for those east of UTC is always positive. * c ISO 8601 date "2004-02-12T15:19:21+00:00" * r RFC 2822 formatted date "Thu, 21 Dec 2000 16:01:07 +0200" * U Seconds since the Unix Epoch (January 1 1970 00:00:00 GMT) "0" * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @return {String} A string representation of the current Date object. */ var formatReplace = function (context) { return function (m) { var formatString, override = false; if (m.charAt(0) === "\\" || m.substring(0, 2) === "%%") { return m.replace("\\", "").replace("%%", "%"); } override = normalizer.shouldOverrideDefaults(m); formatString = $D.normalizeFormat(m, context); if (formatString) { return context.toString(formatString, override); } }; }; $P._format = function (format) { var formatter = formatReplace(this); if (!format) { return this._toString(); } else { return format.replace(/(%|\\)?.|%%/g, formatter); } }; if (!$P.format) { $P.format = $P._format; } }()); (function () { "use strict"; var gFn = function (attr) { return function () { return this[attr]; }; }; var sFn = function (attr) { return function (val) { this[attr] = val; return this; }; }; var attrs = ["years", "months", "days", "hours", "minutes", "seconds", "milliseconds"]; var addSetFuncs = function (context, attrs) { for (var i = 0; i < attrs.length ; i++) { var $a = attrs[i], $b = $a.slice(0, 1).toUpperCase() + $a.slice(1); context.prototype[$a] = 0; context.prototype["get" + $b] = gFn($a); context.prototype["set" + $b] = sFn($a); } }; /** * new TimeSpan(milliseconds); * new TimeSpan(days, hours, minutes, seconds); * new TimeSpan(days, hours, minutes, seconds, milliseconds); */ var TimeSpan = function (days, hours, minutes, seconds, milliseconds) { if (arguments.length === 1 && typeof days === "number") { var orient = (days < 0) ? -1 : +1; var millsLeft = Math.abs(days); this.setDays(Math.floor(millsLeft / 86400000) * orient); millsLeft = millsLeft % 86400000; this.setHours(Math.floor(millsLeft / 3600000) * orient); millsLeft = millsLeft % 3600000; this.setMinutes(Math.floor(millsLeft / 60000) * orient); millsLeft = millsLeft % 60000; this.setSeconds(Math.floor(millsLeft / 1000) * orient); millsLeft = millsLeft % 1000; this.setMilliseconds(millsLeft * orient); } else { this.set(days, hours, minutes, seconds, milliseconds); } this.getTotalMilliseconds = function () { return (this.getDays() * 86400000) + (this.getHours() * 3600000) + (this.getMinutes() * 60000) + (this.getSeconds() * 1000); }; this.compareTo = function (time) { var t1 = new Date(1970, 1, 1, this.getHours(), this.getMinutes(), this.getSeconds()), t2; if (time === null) { t2 = new Date(1970, 1, 1, 0, 0, 0); } else { t2 = new Date(1970, 1, 1, time.getHours(), time.getMinutes(), time.getSeconds()); } return (t1 < t2) ? -1 : (t1 > t2) ? 1 : 0; }; this.equals = function (time) { return (this.compareTo(time) === 0); }; this.add = function (time) { return (time === null) ? this : this.addSeconds(time.getTotalMilliseconds() / 1000); }; this.subtract = function (time) { return (time === null) ? this : this.addSeconds(-time.getTotalMilliseconds() / 1000); }; this.addDays = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 86400000)); }; this.addHours = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 3600000)); }; this.addMinutes = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 60000)); }; this.addSeconds = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 1000)); }; this.addMilliseconds = function (n) { return new TimeSpan(this.getTotalMilliseconds() + n); }; this.get12HourHour = function () { return (this.getHours() > 12) ? this.getHours() - 12 : (this.getHours() === 0) ? 12 : this.getHours(); }; this.getDesignator = function () { return (this.getHours() < 12) ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator; }; this.toString = function (format) { this._toString = function () { if (this.getDays() !== null && this.getDays() > 0) { return this.getDays() + "." + this.getHours() + ":" + this.p(this.getMinutes()) + ":" + this.p(this.getSeconds()); } else { return this.getHours() + ":" + this.p(this.getMinutes()) + ":" + this.p(this.getSeconds()); } }; this.p = function (s) { return (s.toString().length < 2) ? "0" + s : s; }; var me = this; return format ? format.replace(/dd?|HH?|hh?|mm?|ss?|tt?/g, function (format) { switch (format) { case "d": return me.getDays(); case "dd": return me.p(me.getDays()); case "H": return me.getHours(); case "HH": return me.p(me.getHours()); case "h": return me.get12HourHour(); case "hh": return me.p(me.get12HourHour()); case "m": return me.getMinutes(); case "mm": return me.p(me.getMinutes()); case "s": return me.getSeconds(); case "ss": return me.p(me.getSeconds()); case "t": return ((me.getHours() < 12) ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator).substring(0, 1); case "tt": return (me.getHours() < 12) ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator; } } ) : this._toString(); }; return this; }; addSetFuncs(TimeSpan, attrs.slice(2)); TimeSpan.prototype.set = function (days, hours, minutes, seconds, milliseconds){ this.setDays(days || this.getDays()); this.setHours(hours || this.getHours()); this.setMinutes(minutes || this.getMinutes()); this.setSeconds(seconds || this.getSeconds()); this.setMilliseconds(milliseconds || this.getMilliseconds()); }; /** * Gets the time of day for this date instances. * @return {TimeSpan} TimeSpan */ Date.prototype.getTimeOfDay = function () { return new TimeSpan(0, this.getHours(), this.getMinutes(), this.getSeconds(), this.getMilliseconds()); }; Date.TimeSpan = TimeSpan; if (typeof window !== "undefined" ) { // keeping API compatible for v1.x window.TimeSpan = TimeSpan; } }()); (function () { "use strict"; var attrs = ["years", "months", "days", "hours", "minutes", "seconds", "milliseconds"]; var gFn = function (attr) { return function () { return this[attr]; }; }; var sFn = function (attr) { return function (val) { this[attr] = val; return this; }; }; var addSetFuncs = function (context, attrs) { for (var i = 0; i < attrs.length ; i++) { var $a = attrs[i], $b = $a.slice(0, 1).toUpperCase() + $a.slice(1); context.prototype[$a] = 0; context.prototype["get" + $b] = gFn($a); context.prototype["set" + $b] = sFn($a); } }; var setMonthsAndYears = function (orient, d1, d2, context) { function inc() { d1.addMonths(-orient); context.months++; if (context.months === 12) { context.years++; context.months = 0; } } if (orient === +1) { while (d1 > d2) { inc(); } } else { while (d1 < d2) { inc(); } } context.months--; context.months *= orient; context.years *= orient; }; var adjustForDST = function(orient, startDate, endDate) { var hasDSTMismatch = (false === (startDate.isDaylightSavingTime() === endDate.isDaylightSavingTime())); if (hasDSTMismatch && orient === 1) { startDate.addHours(-1); } else if (hasDSTMismatch) { startDate.addHours(1); } }; /** * TimePeriod(startDate, endDate); * TimePeriod(years, months, days, hours, minutes, seconds, milliseconds); */ var TimePeriod = function (years, months, days, hours, minutes, seconds, milliseconds) { if (arguments.length === 7) { this.set(years, months, days, hours, minutes, seconds, milliseconds); } else if (arguments.length === 2 && arguments[0] instanceof Date && arguments[1] instanceof Date) { var startDate = arguments[0].clone(); var endDate = arguments[1].clone(); var orient = (startDate > endDate) ? +1 : -1; this.dates = { start: arguments[0].clone(), end: arguments[1].clone() }; setMonthsAndYears(orient, startDate, endDate, this); adjustForDST(orient, startDate, endDate); // // TODO - adjust for DST var diff = endDate - startDate; if (diff !== 0) { var ts = new TimeSpan(diff); this.set(this.years, this.months, ts.getDays(), ts.getHours(), ts.getMinutes(), ts.getSeconds(), ts.getMilliseconds()); } } return this; }; // create all the set functions. addSetFuncs(TimePeriod, attrs); TimePeriod.prototype.set = function (years, months, days, hours, minutes, seconds, milliseconds){ this.setYears(years || this.getYears()); this.setMonths(months || this.getMonths()); this.setDays(days || this.getDays()); this.setHours(hours || this.getHours()); this.setMinutes(minutes || this.getMinutes()); this.setSeconds(seconds || this.getSeconds()); this.setMilliseconds(milliseconds || this.getMilliseconds()); }; Date.TimePeriod = TimePeriod; if (typeof window !== "undefined") { // keeping API compatible for v1.x window.TimePeriod = TimePeriod; } }()); ================================================ FILE: build/date-th-TH.js ================================================ /** * @overview datejs * @version 1.0.0-rc3 * @author Gregory Wild-Smith * @copyright 2015 Gregory Wild-Smith * @license MIT * @homepage https://github.com/abritinthebay/datejs */ /* * DateJS Culture String File * Country Code: th-TH * Name: Thai (Thailand) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["th-TH"] = { "name": "th-TH", "englishName": "Thai (Thailand)", "nativeName": "ไทย (ไทย)", "Sunday": "อาทิตย์", "Monday": "จันทร์", "Tuesday": "อังคาร", "Wednesday": "พุธ", "Thursday": "พฤหัสบดี", "Friday": "ศุกร์", "Saturday": "เสาร์", "Sun": "อา.", "Mon": "จ.", "Tue": "อ.", "Wed": "พ.", "Thu": "พฤ.", "Fri": "ศ.", "Sat": "ส.", "Su": "อ", "Mo": "จ", "Tu": "อ", "We": "พ", "Th": "พ", "Fr": "ศ", "Sa": "ส", "S_Sun_Initial": "อ", "M_Mon_Initial": "จ", "T_Tue_Initial": "อ", "W_Wed_Initial": "พ", "T_Thu_Initial": "พ", "F_Fri_Initial": "ศ", "S_Sat_Initial": "ส", "January": "มกราคม", "February": "กุมภาพันธ์", "March": "มีนาคม", "April": "เมษายน", "May": "พฤษภาคม", "June": "มิถุนายน", "July": "กรกฎาคม", "August": "สิงหาคม", "September": "กันยายน", "October": "ตุลาคม", "November": "พฤศจิกายน", "December": "ธันวาคม", "Jan_Abbr": "ม.ค.", "Feb_Abbr": "ก.พ.", "Mar_Abbr": "มี.ค.", "Apr_Abbr": "เม.ย.", "May_Abbr": "พ.ค.", "Jun_Abbr": "มิ.ย.", "Jul_Abbr": "ก.ค.", "Aug_Abbr": "ส.ค.", "Sep_Abbr": "ก.ย.", "Oct_Abbr": "ต.ค.", "Nov_Abbr": "พ.ย.", "Dec_Abbr": "ธ.ค.", "AM": "AM", "PM": "PM", "firstDayOfWeek": 1, "twoDigitYearMax": 2572, "mdy": "dmy", "M/d/yyyy": "d/M/yyyy", "dddd, MMMM dd, yyyy": "d MMMM yyyy", "h:mm tt": "H:mm", "h:mm:ss tt": "H:mm:ss", "dddd, MMMM dd, yyyy h:mm:ss tt": "d MMMM yyyy H:mm:ss", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "dd MMMM", "MMMM, yyyy": "MMMM yyyy", "/jan(uary)?/": "ม(.(กราค)?)?", "/feb(ruary)?/": "ก(.(ุมภาพันธ์)?)?", "/mar(ch)?/": "มี(.(นาคม)?)?", "/apr(il)?/": "เม(.(ษายน)?)?", "/may/": "พ(.(ฤษภาคม)?)?", "/jun(e)?/": "มิ(.(ถุนายน)?)?", "/jul(y)?/": "ก(.(รฎาคม)?)?", "/aug(ust)?/": "ส(.(ิงหาคม)?)?", "/sep(t(ember)?)?/": "ก(.(ันยายน)?)?", "/oct(ober)?/": "ต(.(ุลาคม)?)?", "/nov(ember)?/": "พ(.(ฤศจิกายน)?)?", "/dec(ember)?/": "ธ(.(ันวาคม)?)?", "/^su(n(day)?)?/": "^อ(า(.(ทิตย์)?)?)?", "/^mo(n(day)?)?/": "^จ((.(ันทร์)?)?)?", "/^tu(e(s(day)?)?)?/": "^อ((.(ังคาร)?)?)?", "/^we(d(nesday)?)?/": "^พ((.(ุธ)?)?)?", "/^th(u(r(s(day)?)?)?)?/": "^พ(ฤ(.(หัสบดี)?)?)?", "/^fr(i(day)?)?/": "^ศ((.(ุกร์)?)?)?", "/^sa(t(urday)?)?/": "^ส((.(สาร์)?)?)?", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "th-TH"; /** * @overview datejs * @version 1.0.0-rc3 * @author Gregory Wild-Smith * @copyright 2015 Gregory Wild-Smith * @license MIT * @homepage https://github.com/abritinthebay/datejs */(function () { var $D = Date; var lang = Date.CultureStrings ? Date.CultureStrings.lang : null; var loggedKeys = {}; // for debug purposes. var getText = { getFromKey: function (key, countryCode) { var output; if (Date.CultureStrings && Date.CultureStrings[countryCode] && Date.CultureStrings[countryCode][key]) { output = Date.CultureStrings[countryCode][key]; } else { output = getText.buildFromDefault(key); } if (key.charAt(0) === "/") { // Assume it's a regex output = getText.buildFromRegex(key, countryCode); } return output; }, getFromObjectValues: function (obj, countryCode) { var key, output = {}; for(key in obj) { if (obj.hasOwnProperty(key)) { output[key] = getText.getFromKey(obj[key], countryCode); } } return output; }, getFromObjectKeys: function (obj, countryCode) { var key, output = {}; for(key in obj) { if (obj.hasOwnProperty(key)) { output[getText.getFromKey(key, countryCode)] = obj[key]; } } return output; }, getFromArray: function (arr, countryCode) { var output = []; for (var i=0; i < arr.length; i++){ if (i in arr) { output[i] = getText.getFromKey(arr[i], countryCode); } } return output; }, buildFromDefault: function (key) { var output, length, split, last; switch(key) { case "name": output = "en-US"; break; case "englishName": output = "English (United States)"; break; case "nativeName": output = "English (United States)"; break; case "twoDigitYearMax": output = 2049; break; case "firstDayOfWeek": output = 0; break; default: output = key; split = key.split("_"); length = split.length; if (length > 1 && key.charAt(0) !== "/") { // if the key isn't a regex and it has a split. last = split[(length - 1)].toLowerCase(); if (last === "initial" || last === "abbr") { output = split[0]; } } break; } return output; }, buildFromRegex: function (key, countryCode) { var output; if (Date.CultureStrings && Date.CultureStrings[countryCode] && Date.CultureStrings[countryCode][key]) { output = new RegExp(Date.CultureStrings[countryCode][key], "i"); } else { output = new RegExp(key.replace(new RegExp("/", "g"),""), "i"); } return output; } }; var shallowMerge = function (obj1, obj2) { for (var attrname in obj2) { if (obj2.hasOwnProperty(attrname)) { obj1[attrname] = obj2[attrname]; } } }; var __ = function (key, language) { var countryCode = (language) ? language : lang; loggedKeys[key] = key; if (typeof key === "object") { if (key instanceof Array) { return getText.getFromArray(key, countryCode); } else { return getText.getFromObjectKeys(key, countryCode); } } else { return getText.getFromKey(key, countryCode); } }; var loadI18nScript = function (code) { // paatterned after jQuery's getScript. var url = Date.Config.i18n + code + ".js"; var head = document.getElementsByTagName("head")[0] || document.documentElement; var script = document.createElement("script"); script.src = url; var completed = false; var events = { done: function (){} // placeholder function }; // Attach handlers for all browsers script.onload = script.onreadystatechange = function() { if ( !completed && (!this.readyState || this.readyState === "loaded" || this.readyState === "complete") ) { events.done(); head.removeChild(script); } }; setTimeout(function() { head.insertBefore(script, head.firstChild); }, 0); // allows return to execute first return { done: function (cb) { events.done = function() { if (cb) { setTimeout(cb,0); } }; } }; }; var buildInfo = { buildFromMethodHash: function (obj) { var key; for(key in obj) { if (obj.hasOwnProperty(key)) { obj[key] = buildInfo[obj[key]](); } } return obj; }, timeZoneDST: function () { var DST = { "CHADT": "+1345", "NZDT": "+1300", "AEDT": "+1100", "ACDT": "+1030", "AZST": "+0500", "IRDT": "+0430", "EEST": "+0300", "CEST": "+0200", "BST": "+0100", "PMDT": "-0200", "ADT": "-0300", "NDT": "-0230", "EDT": "-0400", "CDT": "-0500", "MDT": "-0600", "PDT": "-0700", "AKDT": "-0800", "HADT": "-0900" }; return __(DST); }, timeZoneStandard: function () { var standard = { "LINT": "+1400", "TOT": "+1300", "CHAST": "+1245", "NZST": "+1200", "NFT": "+1130", "SBT": "+1100", "AEST": "+1000", "ACST": "+0930", "JST": "+0900", "CWST": "+0845", "CT": "+0800", "ICT": "+0700", "MMT": "+0630", "BST": "+0600", "NPT": "+0545", "IST": "+0530", "PKT": "+0500", "AFT": "+0430", "MSK": "+0400", "IRST": "+0330", "FET": "+0300", "EET": "+0200", "CET": "+0100", "GMT": "+0000", "UTC": "+0000", "CVT": "-0100", "GST": "-0200", "BRT": "-0300", "NST": "-0330", "AST": "-0400", "EST": "-0500", "CST": "-0600", "MST": "-0700", "PST": "-0800", "AKST": "-0900", "MIT": "-0930", "HST": "-1000", "SST": "-1100", "BIT": "-1200" }; return __(standard); }, timeZones: function (data) { var zone; data.timezones = []; for (zone in data.abbreviatedTimeZoneStandard) { if (data.abbreviatedTimeZoneStandard.hasOwnProperty(zone)) { data.timezones.push({ name: zone, offset: data.abbreviatedTimeZoneStandard[zone]}); } } for (zone in data.abbreviatedTimeZoneDST) { if (data.abbreviatedTimeZoneDST.hasOwnProperty(zone)) { data.timezones.push({ name: zone, offset: data.abbreviatedTimeZoneDST[zone], dst: true}); } } return data.timezones; }, days: function () { return __(["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"]); }, dayAbbr: function () { return __(["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"]); }, dayShortNames: function () { return __(["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"]); }, dayFirstLetters: function () { return __(["S_Sun_Initial", "M_Mon_Initial", "T_Tues_Initial", "W_Wed_Initial", "T_Thu_Initial", "F_Fri_Initial", "S_Sat_Initial"]); }, months: function () { return __(["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"]); }, monthAbbr: function () { return __(["Jan_Abbr", "Feb_Abbr", "Mar_Abbr", "Apr_Abbr", "May_Abbr", "Jun_Abbr", "Jul_Abbr", "Aug_Abbr", "Sep_Abbr", "Oct_Abbr", "Nov_Abbr", "Dec_Abbr"]); }, formatPatterns: function () { return getText.getFromObjectValues({ shortDate: "M/d/yyyy", longDate: "dddd, MMMM dd, yyyy", shortTime: "h:mm tt", longTime: "h:mm:ss tt", fullDateTime: "dddd, MMMM dd, yyyy h:mm:ss tt", sortableDateTime: "yyyy-MM-ddTHH:mm:ss", universalSortableDateTime: "yyyy-MM-dd HH:mm:ssZ", rfc1123: "ddd, dd MMM yyyy HH:mm:ss", monthDay: "MMMM dd", yearMonth: "MMMM, yyyy" }, Date.i18n.currentLanguage()); }, regex: function () { return getText.getFromObjectValues({ inTheMorning: "/( in the )(morn(ing)?)\\b/", thisMorning: "/(this )(morn(ing)?)\\b/", amThisMorning: "/(\b\\d(am)? )(this )(morn(ing)?)/", inTheEvening: "/( in the )(even(ing)?)\\b/", thisEvening: "/(this )(even(ing)?)\\b/", pmThisEvening: "/(\b\\d(pm)? )(this )(even(ing)?)/", jan: "/jan(uary)?/", feb: "/feb(ruary)?/", mar: "/mar(ch)?/", apr: "/apr(il)?/", may: "/may/", jun: "/jun(e)?/", jul: "/jul(y)?/", aug: "/aug(ust)?/", sep: "/sep(t(ember)?)?/", oct: "/oct(ober)?/", nov: "/nov(ember)?/", dec: "/dec(ember)?/", sun: "/^su(n(day)?)?/", mon: "/^mo(n(day)?)?/", tue: "/^tu(e(s(day)?)?)?/", wed: "/^we(d(nesday)?)?/", thu: "/^th(u(r(s(day)?)?)?)?/", fri: "/fr(i(day)?)?/", sat: "/^sa(t(urday)?)?/", future: "/^next/", past: "/^last|past|prev(ious)?/", add: "/^(\\+|aft(er)?|from|hence)/", subtract: "/^(\\-|bef(ore)?|ago)/", yesterday: "/^yes(terday)?/", today: "/^t(od(ay)?)?/", tomorrow: "/^tom(orrow)?/", now: "/^n(ow)?/", millisecond: "/^ms|milli(second)?s?/", second: "/^sec(ond)?s?/", minute: "/^mn|min(ute)?s?/", hour: "/^h(our)?s?/", week: "/^w(eek)?s?/", month: "/^m(onth)?s?/", day: "/^d(ay)?s?/", year: "/^y(ear)?s?/", shortMeridian: "/^(a|p)/", longMeridian: "/^(a\\.?m?\\.?|p\\.?m?\\.?)/", timezone: "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/", ordinalSuffix: "/^\\s*(st|nd|rd|th)/", timeContext: "/^\\s*(\\:|a(?!u|p)|p)/" }, Date.i18n.currentLanguage()); } }; var CultureInfo = function () { var info = getText.getFromObjectValues({ name: "name", englishName: "englishName", nativeName: "nativeName", amDesignator: "AM", pmDesignator: "PM", firstDayOfWeek: "firstDayOfWeek", twoDigitYearMax: "twoDigitYearMax", dateElementOrder: "mdy" }, Date.i18n.currentLanguage()); var constructedInfo = buildInfo.buildFromMethodHash({ dayNames: "days", abbreviatedDayNames: "dayAbbr", shortestDayNames: "dayShortNames", firstLetterDayNames: "dayFirstLetters", monthNames: "months", abbreviatedMonthNames: "monthAbbr", formatPatterns: "formatPatterns", regexPatterns: "regex", abbreviatedTimeZoneDST: "timeZoneDST", abbreviatedTimeZoneStandard: "timeZoneStandard" }); shallowMerge(info, constructedInfo); buildInfo.timeZones(info); return info; }; $D.i18n = { __: function (key, lang) { return __(key, lang); }, currentLanguage: function () { return lang || "en-US"; }, setLanguage: function (code, force, cb) { var async = false; if (force || code === "en-US" || (!!Date.CultureStrings && !!Date.CultureStrings[code])) { lang = code; Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings.lang = code; Date.CultureInfo = new CultureInfo(); } else { if (!(!!Date.CultureStrings && !!Date.CultureStrings[code])) { if (typeof exports !== "undefined" && this.exports !== exports) { // we're in a Node enviroment, load it using require try { require("../i18n/" + code + ".js"); lang = code; Date.CultureStrings.lang = code; Date.CultureInfo = new CultureInfo(); } catch (e) { // var str = "The language for '" + code + "' could not be loaded by Node. It likely does not exist."; throw new Error("The DateJS IETF language tag '" + code + "' could not be loaded by Node. It likely does not exist."); } } else if (Date.Config && Date.Config.i18n) { // we know the location of the files, so lets load them async = true; loadI18nScript(code).done(function(){ lang = code; Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings.lang = code; Date.CultureInfo = new CultureInfo(); $D.Parsing.Normalizer.buildReplaceData(); // because this is async if ($D.Grammar) { $D.Grammar.buildGrammarFormats(); // so we can parse those strings... } if (cb) { setTimeout(cb,0); } }); } else { Date.console.error("The DateJS IETF language tag '" + code + "' is not available and has not been loaded."); return false; } } } $D.Parsing.Normalizer.buildReplaceData(); // rebuild normalizer strings if ($D.Grammar) { $D.Grammar.buildGrammarFormats(); // so we can parse those strings... } if (!async && cb) { setTimeout(cb,0); } }, getLoggedKeys: function () { return loggedKeys; }, updateCultureInfo: function () { Date.CultureInfo = new CultureInfo(); } }; $D.i18n.updateCultureInfo(); // run automatically }()); (function () { var $D = Date, $P = $D.prototype, p = function (s, l) { if (!l) { l = 2; } return ("000" + s).slice(l * -1); }; if (typeof window !== "undefined" && typeof window.console !== "undefined" && typeof window.console.log !== "undefined") { $D.console = console; // used only to raise non-critical errors if available } else { // set mock so we don't give errors. $D.console = { log: function(){}, error: function(){} }; } $D.Config = $D.Config || {}; $D.initOverloads = function() { /** * Overload of Date.now. Allows an alternate call for Date.now where it returns the * current Date as an object rather than just milliseconds since the Unix Epoch. * * Also provides an implementation of now() for browsers (IE<9) that don't have it. * * Backwards compatible so with work with either: * Date.now() [returns ms] * or * Date.now(true) [returns Date] */ if (!$D.now) { $D._now = function now() { return new Date().getTime(); }; } else if (!$D._now) { $D._now = $D.now; } $D.now = function (returnObj) { if (returnObj) { return $D.present(); } else { return $D._now(); } }; if ( !$P.toISOString ) { $P.toISOString = function() { return this.getUTCFullYear() + "-" + p(this.getUTCMonth() + 1) + "-" + p(this.getUTCDate()) + "T" + p(this.getUTCHours()) + ":" + p(this.getUTCMinutes()) + ":" + p(this.getUTCSeconds()) + "." + String( (this.getUTCMilliseconds()/1000).toFixed(3)).slice(2, 5) + "Z"; }; } // private if ( $P._toString === undefined ){ $P._toString = $P.toString; } }; $D.initOverloads(); /** * Gets a date that is set to the current date. The time is set to the start of the day (00:00 or 12:00 AM). * @return {Date} The current date. */ $D.today = function () { return new Date().clearTime(); }; /** * Gets a date that is set to the current date and time (same as new Date, but chainable) * @return {Date} The current date. */ $D.present = function () { return new Date(); }; /** * Compares the first date to the second date and returns an number indication of their relative values. * @param {Date} First Date object to compare [Required]. * @param {Date} Second Date object to compare to [Required]. * @return {Number} -1 = date1 is lessthan date2. 0 = values are equal. 1 = date1 is greaterthan date2. */ $D.compare = function (date1, date2) { if (isNaN(date1) || isNaN(date2)) { throw new Error(date1 + " - " + date2); } else if (date1 instanceof Date && date2 instanceof Date) { return (date1 < date2) ? -1 : (date1 > date2) ? 1 : 0; } else { throw new TypeError(date1 + " - " + date2); } }; /** * Compares the first Date object to the second Date object and returns true if they are equal. * @param {Date} First Date object to compare [Required] * @param {Date} Second Date object to compare to [Required] * @return {Boolean} true if dates are equal. false if they are not equal. */ $D.equals = function (date1, date2) { return (date1.compareTo(date2) === 0); }; /** * Gets the language appropriate day name when given the day number(0-6) * eg - 0 == Sunday * @return {String} The day name */ $D.getDayName = function (n) { return Date.CultureInfo.dayNames[n]; }; /** * Gets the day number (0-6) if given a CultureInfo specific string which is a valid dayName, abbreviatedDayName or shortestDayName (two char). * @param {String} The name of the day (eg. "Monday, "Mon", "tuesday", "tue", "We", "we"). * @return {Number} The day number */ $D.getDayNumberFromName = function (name) { var n = Date.CultureInfo.dayNames, m = Date.CultureInfo.abbreviatedDayNames, o = Date.CultureInfo.shortestDayNames, s = name.toLowerCase(); for (var i = 0; i < n.length; i++) { if (n[i].toLowerCase() === s || m[i].toLowerCase() === s || o[i].toLowerCase() === s) { return i; } } return -1; }; /** * Gets the month number (0-11) if given a Culture Info specific string which is a valid monthName or abbreviatedMonthName. * @param {String} The name of the month (eg. "February, "Feb", "october", "oct"). * @return {Number} The day number */ $D.getMonthNumberFromName = function (name) { var n = Date.CultureInfo.monthNames, m = Date.CultureInfo.abbreviatedMonthNames, s = name.toLowerCase(); for (var i = 0; i < n.length; i++) { if (n[i].toLowerCase() === s || m[i].toLowerCase() === s) { return i; } } return -1; }; /** * Gets the language appropriate month name when given the month number(0-11) * eg - 0 == January * @return {String} The month name */ $D.getMonthName = function (n) { return Date.CultureInfo.monthNames[n]; }; /** * Determines if the current date instance is within a LeapYear. * @param {Number} The year. * @return {Boolean} true if date is within a LeapYear, otherwise false. */ $D.isLeapYear = function (year) { return ((year % 4 === 0 && year % 100 !== 0) || year % 400 === 0); }; /** * Gets the number of days in the month, given a year and month value. Automatically corrects for LeapYear. * @param {Number} The year. * @param {Number} The month (0-11). * @return {Number} The number of days in the month. */ $D.getDaysInMonth = function (year, month) { if (!month && $D.validateMonth(year)) { month = year; year = Date.today().getFullYear(); } return [31, ($D.isLeapYear(year) ? 29 : 28), 31, 30, 31, 30, 31, 31, 30, 31, 30, 31][month]; }; $P.getDaysInMonth = function () { return $D.getDaysInMonth(this.getFullYear(), this.getMonth()); }; $D.getTimezoneAbbreviation = function (offset, dst) { var p, n = (dst || false) ? Date.CultureInfo.abbreviatedTimeZoneDST : Date.CultureInfo.abbreviatedTimeZoneStandard; for (p in n) { if (n.hasOwnProperty(p)) { if (n[p] === offset) { return p; } } } return null; }; $D.getTimezoneOffset = function (name, dst) { var i, a =[], z = Date.CultureInfo.timezones; if (!name) { name = (new Date()).getTimezone();} for (i = 0; i < z.length; i++) { if (z[i].name === name.toUpperCase()) { a.push(i); } } if (!z[a[0]]) { return null; } if (a.length === 1 || !dst) { return z[a[0]].offset; } else { for (i=0; i < a.length; i++) { if (z[a[i]].dst) { return z[a[i]].offset; } } } }; $D.getQuarter = function (d) { d = d || new Date(); // If no date supplied, use today var q = [1,2,3,4]; return q[Math.floor(d.getMonth() / 3)]; // ~~~ is a bitwise op. Faster than Math.floor }; $D.getDaysLeftInQuarter = function (d) { d = d || new Date(); var qEnd = new Date(d); qEnd.setMonth(qEnd.getMonth() + 3 - qEnd.getMonth() % 3, 0); return Math.floor((qEnd - d) / 8.64e7); }; // private var validate = function (n, min, max, name) { name = name ? name : "Object"; if (typeof n === "undefined") { return false; } else if (typeof n !== "number") { throw new TypeError(n + " is not a Number."); } else if (n < min || n > max) { // As failing validation is *not* an exceptional circumstance // lets not throw a RangeError Exception here. // It's semantically correct but it's not sensible. return false; } return true; }; /** * Validates the number is within an acceptable range for milliseconds [0-999]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateMillisecond = function (value) { return validate(value, 0, 999, "millisecond"); }; /** * Validates the number is within an acceptable range for seconds [0-59]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateSecond = function (value) { return validate(value, 0, 59, "second"); }; /** * Validates the number is within an acceptable range for minutes [0-59]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateMinute = function (value) { return validate(value, 0, 59, "minute"); }; /** * Validates the number is within an acceptable range for hours [0-23]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateHour = function (value) { return validate(value, 0, 23, "hour"); }; /** * Validates the number is within an acceptable range for the days in a month [0-MaxDaysInMonth]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateDay = function (value, year, month) { if (year === undefined || year === null || month === undefined || month === null) { return false;} return validate(value, 1, $D.getDaysInMonth(year, month), "day"); }; /** * Validates the number is within an acceptable range for months [0-11]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateWeek = function (value) { return validate(value, 0, 53, "week"); }; /** * Validates the number is within an acceptable range for months [0-11]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateMonth = function (value) { return validate(value, 0, 11, "month"); }; /** * Validates the number is within an acceptable range for years. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateYear = function (value) { /** * Per ECMAScript spec the range of times supported by Date objects is * exactly -100,000,000 days to +100,000,000 days measured relative to * midnight at the beginning of 01 January, 1970 UTC. * This gives a range of 8,640,000,000,000,000 milliseconds to either * side of 01 January, 1970 UTC. * * Earliest possible date: Tue, 20 Apr 271,822 B.C. 00:00:00 UTC * Latest possible date: Sat, 13 Sep 275,760 00:00:00 UTC */ return validate(value, -271822, 275760, "year"); }; $D.validateTimezone = function(value) { var timezones = {"ACDT":1,"ACST":1,"ACT":1,"ADT":1,"AEDT":1,"AEST":1,"AFT":1,"AKDT":1,"AKST":1,"AMST":1,"AMT":1,"ART":1,"AST":1,"AWDT":1,"AWST":1,"AZOST":1,"AZT":1,"BDT":1,"BIOT":1,"BIT":1,"BOT":1,"BRT":1,"BST":1,"BTT":1,"CAT":1,"CCT":1,"CDT":1,"CEDT":1,"CEST":1,"CET":1,"CHADT":1,"CHAST":1,"CHOT":1,"ChST":1,"CHUT":1,"CIST":1,"CIT":1,"CKT":1,"CLST":1,"CLT":1,"COST":1,"COT":1,"CST":1,"CT":1,"CVT":1,"CWST":1,"CXT":1,"DAVT":1,"DDUT":1,"DFT":1,"EASST":1,"EAST":1,"EAT":1,"ECT":1,"EDT":1,"EEDT":1,"EEST":1,"EET":1,"EGST":1,"EGT":1,"EIT":1,"EST":1,"FET":1,"FJT":1,"FKST":1,"FKT":1,"FNT":1,"GALT":1,"GAMT":1,"GET":1,"GFT":1,"GILT":1,"GIT":1,"GMT":1,"GST":1,"GYT":1,"HADT":1,"HAEC":1,"HAST":1,"HKT":1,"HMT":1,"HOVT":1,"HST":1,"ICT":1,"IDT":1,"IOT":1,"IRDT":1,"IRKT":1,"IRST":1,"IST":1,"JST":1,"KGT":1,"KOST":1,"KRAT":1,"KST":1,"LHST":1,"LINT":1,"MAGT":1,"MART":1,"MAWT":1,"MDT":1,"MET":1,"MEST":1,"MHT":1,"MIST":1,"MIT":1,"MMT":1,"MSK":1,"MST":1,"MUT":1,"MVT":1,"MYT":1,"NCT":1,"NDT":1,"NFT":1,"NPT":1,"NST":1,"NT":1,"NUT":1,"NZDT":1,"NZST":1,"OMST":1,"ORAT":1,"PDT":1,"PET":1,"PETT":1,"PGT":1,"PHOT":1,"PHT":1,"PKT":1,"PMDT":1,"PMST":1,"PONT":1,"PST":1,"PYST":1,"PYT":1,"RET":1,"ROTT":1,"SAKT":1,"SAMT":1,"SAST":1,"SBT":1,"SCT":1,"SGT":1,"SLST":1,"SRT":1,"SST":1,"SYOT":1,"TAHT":1,"THA":1,"TFT":1,"TJT":1,"TKT":1,"TLT":1,"TMT":1,"TOT":1,"TVT":1,"UCT":1,"ULAT":1,"UTC":1,"UYST":1,"UYT":1,"UZT":1,"VET":1,"VLAT":1,"VOLT":1,"VOST":1,"VUT":1,"WAKT":1,"WAST":1,"WAT":1,"WEDT":1,"WEST":1,"WET":1,"WST":1,"YAKT":1,"YEKT":1,"Z":1}; return (timezones[value] === 1); }; $D.validateTimezoneOffset= function(value) { // timezones go from +14hrs to -12hrs, the +X hours are negative offsets. return (value > -841 && value < 721); }; }()); (function () { var $D = Date, $P = $D.prototype, p = function (s, l) { if (!l) { l = 2; } return ("000" + s).slice(l * -1); }; var validateConfigObject = function (obj) { var result = {}, self = this, prop, testFunc; testFunc = function (prop, func, value) { if (prop === "day") { var month = (obj.month !== undefined) ? obj.month : self.getMonth(); var year = (obj.year !== undefined) ? obj.year : self.getFullYear(); return $D[func](value, year, month); } else { return $D[func](value); } }; for (prop in obj) { if (Object.prototype.hasOwnProperty.call(obj, prop)) { var func = "validate" + prop.charAt(0).toUpperCase() + prop.slice(1); if ($D[func] && obj[prop] !== null && testFunc(prop, func, obj[prop])) { result[prop] = obj[prop]; } } } return result; }; /** * Resets the time of this Date object to 12:00 AM (00:00), which is the start of the day. * @param {Boolean} .clone() this date instance before clearing Time * @return {Date} this */ $P.clearTime = function () { this.setHours(0); this.setMinutes(0); this.setSeconds(0); this.setMilliseconds(0); return this; }; /** * Resets the time of this Date object to the current time ('now'). * @return {Date} this */ $P.setTimeToNow = function () { var n = new Date(); this.setHours(n.getHours()); this.setMinutes(n.getMinutes()); this.setSeconds(n.getSeconds()); this.setMilliseconds(n.getMilliseconds()); return this; }; /** * Returns a new Date object that is an exact date and time copy of the original instance. * @return {Date} A new Date instance */ $P.clone = function () { return new Date(this.getTime()); }; /** * Compares this instance to a Date object and returns an number indication of their relative values. * @param {Date} Date object to compare [Required] * @return {Number} -1 = this is lessthan date. 0 = values are equal. 1 = this is greaterthan date. */ $P.compareTo = function (date) { return Date.compare(this, date); }; /** * Compares this instance to another Date object and returns true if they are equal. * @param {Date} Date object to compare. If no date to compare, new Date() [now] is used. * @return {Boolean} true if dates are equal. false if they are not equal. */ $P.equals = function (date) { return Date.equals(this, (date !== undefined ? date : new Date())); }; /** * Determines if this instance is between a range of two dates or equal to either the start or end dates. * @param {Date} Start of range [Required] * @param {Date} End of range [Required] * @return {Boolean} true is this is between or equal to the start and end dates, else false */ $P.between = function (start, end) { return this.getTime() >= start.getTime() && this.getTime() <= end.getTime(); }; /** * Determines if this date occurs after the date to compare to. * @param {Date} Date object to compare. If no date to compare, new Date() ("now") is used. * @return {Boolean} true if this date instance is greater than the date to compare to (or "now"), otherwise false. */ $P.isAfter = function (date) { return this.compareTo(date || new Date()) === 1; }; /** * Determines if this date occurs before the date to compare to. * @param {Date} Date object to compare. If no date to compare, new Date() ("now") is used. * @return {Boolean} true if this date instance is less than the date to compare to (or "now"). */ $P.isBefore = function (date) { return (this.compareTo(date || new Date()) === -1); }; /** * Determines if the current Date instance occurs today. * @return {Boolean} true if this date instance is 'today', otherwise false. */ /** * Determines if the current Date instance occurs on the same Date as the supplied 'date'. * If no 'date' to compare to is provided, the current Date instance is compared to 'today'. * @param {date} Date object to compare. If no date to compare, the current Date ("now") is used. * @return {Boolean} true if this Date instance occurs on the same Day as the supplied 'date'. */ $P.isToday = $P.isSameDay = function (date) { return this.clone().clearTime().equals((date || new Date()).clone().clearTime()); }; /** * Adds the specified number of milliseconds to this instance. * @param {Number} The number of milliseconds to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addMilliseconds = function (value) { if (!value) { return this; } this.setTime(this.getTime() + value * 1); return this; }; /** * Adds the specified number of seconds to this instance. * @param {Number} The number of seconds to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addSeconds = function (value) { if (!value) { return this; } return this.addMilliseconds(value * 1000); }; /** * Adds the specified number of seconds to this instance. * @param {Number} The number of seconds to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addMinutes = function (value) { if (!value) { return this; } return this.addMilliseconds(value * 60000); // 60*1000 }; /** * Adds the specified number of hours to this instance. * @param {Number} The number of hours to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addHours = function (value) { if (!value) { return this; } return this.addMilliseconds(value * 3600000); // 60*60*1000 }; /** * Adds the specified number of days to this instance. * @param {Number} The number of days to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addDays = function (value) { if (!value) { return this; } this.setDate(this.getDate() + value * 1); return this; }; /** * Adds the specified number of weekdays (ie - not sat or sun) to this instance. * @param {Number} The number of days to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addWeekdays = function (value) { if (!value) { return this; } var day = this.getDay(); var weeks = (Math.ceil(Math.abs(value)/7)); if (day === 0 || day === 6) { if (value > 0) { this.next().monday(); this.addDays(-1); day = this.getDay(); } } if (value < 0) { while (value < 0) { this.addDays(-1); day = this.getDay(); if (day !== 0 && day !== 6) { value++; } } return this; } else if (value > 5 || (6-day) <= value) { value = value + (weeks * 2); } return this.addDays(value); }; /** * Adds the specified number of weeks to this instance. * @param {Number} The number of weeks to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addWeeks = function (value) { if (!value) { return this; } return this.addDays(value * 7); }; /** * Adds the specified number of months to this instance. * @param {Number} The number of months to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addMonths = function (value) { if (!value) { return this; } var n = this.getDate(); this.setDate(1); this.setMonth(this.getMonth() + value * 1); this.setDate(Math.min(n, $D.getDaysInMonth(this.getFullYear(), this.getMonth()))); return this; }; $P.addQuarters = function (value) { if (!value) { return this; } // note this will take you to the same point in the quarter as you are now. // i.e. - if you are 15 days into the quarter you'll be 15 days into the resulting one. // bonus: this allows adding fractional quarters return this.addMonths(value * 3); }; /** * Adds the specified number of years to this instance. * @param {Number} The number of years to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addYears = function (value) { if (!value) { return this; } return this.addMonths(value * 12); }; /** * Adds (or subtracts) to the value of the years, months, weeks, days, hours, minutes, seconds, milliseconds of the date instance using given configuration object. Positive and Negative values allowed. * Example

	Date.today().add( { days: 1, months: 1 } )

	new Date().add( { years: -1 } )
	
* @param {Object} Configuration object containing attributes (months, days, etc.) * @return {Date} this */ $P.add = function (config) { if (typeof config === "number") { this._orient = config; return this; } var x = config; if (x.day) { // If we should be a different date than today (eg: for 'tomorrow -1d', etc). // Should only effect parsing, not direct usage (eg, Finish and FinishExact) if ((x.day - this.getDate()) !== 0) { this.setDate(x.day); } } if (x.milliseconds) { this.addMilliseconds(x.milliseconds); } if (x.seconds) { this.addSeconds(x.seconds); } if (x.minutes) { this.addMinutes(x.minutes); } if (x.hours) { this.addHours(x.hours); } if (x.weeks) { this.addWeeks(x.weeks); } if (x.months) { this.addMonths(x.months); } if (x.years) { this.addYears(x.years); } if (x.days) { this.addDays(x.days); } return this; }; /** * Get the week number. Week one (1) is the week which contains the first Thursday of the year. Monday is considered the first day of the week. * The .getWeek() function does NOT convert the date to UTC. The local datetime is used. * Please use .getISOWeek() to get the week of the UTC converted date. * @return {Number} 1 to 53 */ $P.getWeek = function (utc) { // Create a copy of this date object var self, target = new Date(this.valueOf()); if (utc) { target.addMinutes(target.getTimezoneOffset()); self = target.clone(); } else { self = this; } // ISO week date weeks start on monday // so correct the day number var dayNr = (self.getDay() + 6) % 7; // ISO 8601 states that week 1 is the week // with the first thursday of that year. // Set the target date to the thursday in the target week target.setDate(target.getDate() - dayNr + 3); // Store the millisecond value of the target date var firstThursday = target.valueOf(); // Set the target to the first thursday of the year // First set the target to january first target.setMonth(0, 1); // Not a thursday? Correct the date to the next thursday if (target.getDay() !== 4) { target.setMonth(0, 1 + ((4 - target.getDay()) + 7) % 7); } // The weeknumber is the number of weeks between the // first thursday of the year and the thursday in the target week return 1 + Math.ceil((firstThursday - target) / 604800000); // 604800000 = 7 * 24 * 3600 * 1000 }; /** * Get the ISO 8601 week number. Week one ("01") is the week which contains the first Thursday of the year. Monday is considered the first day of the week. * The .getISOWeek() function does convert the date to it's UTC value. Please use .getWeek() to get the week of the local date. * @return {String} "01" to "53" */ $P.getISOWeek = function () { return p(this.getWeek(true)); }; /** * Moves the date to Monday of the week set. Week one (1) is the week which contains the first Thursday of the year. * @param {Number} A Number (1 to 53) that represents the week of the year. * @return {Date} this */ $P.setWeek = function (n) { if ((n - this.getWeek()) === 0) { if (this.getDay() !== 1) { return this.moveToDayOfWeek(1, (this.getDay() > 1 ? -1 : 1)); } else { return this; } } else { return this.moveToDayOfWeek(1, (this.getDay() > 1 ? -1 : 1)).addWeeks(n - this.getWeek()); } }; $P.setQuarter = function (qtr) { var month = Math.abs(((qtr-1) * 3) + 1); return this.setMonth(month, 1); }; $P.getQuarter = function () { return Date.getQuarter(this); }; $P.getDaysLeftInQuarter = function () { return Date.getDaysLeftInQuarter(this); }; /** * Moves the date to the next n'th occurrence of the dayOfWeek starting from the beginning of the month. The number (-1) is a magic number and will return the last occurrence of the dayOfWeek in the month. * @param {Number} The dayOfWeek to move to * @param {Number} The n'th occurrence to move to. Use (-1) to return the last occurrence in the month * @return {Date} this */ $P.moveToNthOccurrence = function (dayOfWeek, occurrence) { if (dayOfWeek === "Weekday") { if (occurrence > 0) { this.moveToFirstDayOfMonth(); if (this.is().weekday()) { occurrence -= 1; } } else if (occurrence < 0) { this.moveToLastDayOfMonth(); if (this.is().weekday()) { occurrence += 1; } } else { return this; } return this.addWeekdays(occurrence); } var shift = 0; if (occurrence > 0) { shift = occurrence - 1; } else if (occurrence === -1) { this.moveToLastDayOfMonth(); if (this.getDay() !== dayOfWeek) { this.moveToDayOfWeek(dayOfWeek, -1); } return this; } return this.moveToFirstDayOfMonth().addDays(-1).moveToDayOfWeek(dayOfWeek, +1).addWeeks(shift); }; var moveToN = function (getFunc, addFunc, nVal) { return function (value, orient) { var diff = (value - this[getFunc]() + nVal * (orient || +1)) % nVal; return this[addFunc]((diff === 0) ? diff += nVal * (orient || +1) : diff); }; }; /** * Move to the next or last dayOfWeek based on the orient value. * @param {Number} The dayOfWeek to move to * @param {Number} Forward (+1) or Back (-1). Defaults to +1. [Optional] * @return {Date} this */ $P.moveToDayOfWeek = moveToN("getDay", "addDays", 7); /** * Move to the next or last month based on the orient value. * @param {Number} The month to move to. 0 = January, 11 = December * @param {Number} Forward (+1) or Back (-1). Defaults to +1. [Optional] * @return {Date} this */ $P.moveToMonth = moveToN("getMonth", "addMonths", 12); /** * Get the Ordinate of the current day ("th", "st", "rd"). * @return {String} */ $P.getOrdinate = function () { var num = this.getDate(); return ord(num); }; /** * Get the Ordinal day (numeric day number) of the year, adjusted for leap year. * @return {Number} 1 through 365 (366 in leap years) */ $P.getOrdinalNumber = function () { return Math.ceil((this.clone().clearTime() - new Date(this.getFullYear(), 0, 1)) / 86400000) + 1; }; /** * Get the time zone abbreviation of the current date. * @return {String} The abbreviated time zone name (e.g. "EST") */ $P.getTimezone = function () { return $D.getTimezoneAbbreviation(this.getUTCOffset(), this.isDaylightSavingTime()); }; $P.setTimezoneOffset = function (offset) { var here = this.getTimezoneOffset(), there = Number(offset) * -6 / 10; return (there || there === 0) ? this.addMinutes(there - here) : this; }; $P.setTimezone = function (offset) { return this.setTimezoneOffset($D.getTimezoneOffset(offset)); }; /** * Indicates whether Daylight Saving Time is observed in the current time zone. * @return {Boolean} true|false */ $P.hasDaylightSavingTime = function () { return (Date.today().set({month: 0, day: 1}).getTimezoneOffset() !== Date.today().set({month: 6, day: 1}).getTimezoneOffset()); }; /** * Indicates whether this Date instance is within the Daylight Saving Time range for the current time zone. * @return {Boolean} true|false */ $P.isDaylightSavingTime = function () { return Date.today().set({month: 0, day: 1}).getTimezoneOffset() !== this.getTimezoneOffset(); }; /** * Get the offset from UTC of the current date. * @return {String} The 4-character offset string prefixed with + or - (e.g. "-0500") */ $P.getUTCOffset = function (offset) { var n = (offset || this.getTimezoneOffset()) * -10 / 6, r; if (n < 0) { r = (n - 10000).toString(); return r.charAt(0) + r.substr(2); } else { r = (n + 10000).toString(); return "+" + r.substr(1); } }; /** * Returns the number of milliseconds between this date and date. * @param {Date} Defaults to now * @return {Number} The diff in milliseconds */ $P.getElapsed = function (date) { return (date || new Date()) - this; }; /** * Set the value of year, month, day, hour, minute, second, millisecond of date instance using given configuration object. * Example

	Date.today().set( { day: 20, month: 1 } )

	new Date().set( { millisecond: 0 } )
	
* * @param {Object} Configuration object containing attributes (month, day, etc.) * @return {Date} this */ $P.set = function (config) { config = validateConfigObject.call(this, config); var key; for (key in config) { if (Object.prototype.hasOwnProperty.call(config, key)) { var name = key.charAt(0).toUpperCase() + key.slice(1); var addFunc, getFunc; if (key !== "week" && key !== "month" && key !== "timezone" && key !== "timezoneOffset") { name += "s"; } addFunc = "add" + name; getFunc = "get" + name; if (key === "month") { addFunc = addFunc + "s"; } else if (key === "year"){ getFunc = "getFullYear"; } if (key !== "day" && key !== "timezone" && key !== "timezoneOffset" && key !== "week" && key !== "hour") { this[addFunc](config[key] - this[getFunc]()); } else if ( key === "timezone"|| key === "timezoneOffset" || key === "week" || key === "hour") { this["set"+name](config[key]); } } } // day has to go last because you can't validate the day without first knowing the month if (config.day) { this.addDays(config.day - this.getDate()); } return this; }; /** * Moves the date to the first day of the month. * @return {Date} this */ $P.moveToFirstDayOfMonth = function () { return this.set({ day: 1 }); }; /** * Moves the date to the last day of the month. * @return {Date} this */ $P.moveToLastDayOfMonth = function () { return this.set({ day: $D.getDaysInMonth(this.getFullYear(), this.getMonth())}); }; /** * Converts the value of the current Date object to its equivalent string representation. * Format Specifiers * CUSTOM DATE AND TIME FORMAT STRINGS * Format Description Example * ------ --------------------------------------------------------------------------- ----------------------- * s The seconds of the minute between 0-59. "0" to "59" * ss The seconds of the minute with leading zero if required. "00" to "59" * * m The minute of the hour between 0-59. "0" or "59" * mm The minute of the hour with leading zero if required. "00" or "59" * * h The hour of the day between 1-12. "1" to "12" * hh The hour of the day with leading zero if required. "01" to "12" * * H The hour of the day between 0-23. "0" to "23" * HH The hour of the day with leading zero if required. "00" to "23" * * d The day of the month between 1 and 31. "1" to "31" * dd The day of the month with leading zero if required. "01" to "31" * ddd Abbreviated day name. Date.CultureInfo.abbreviatedDayNames. "Mon" to "Sun" * dddd The full day name. Date.CultureInfo.dayNames. "Monday" to "Sunday" * * M The month of the year between 1-12. "1" to "12" * MM The month of the year with leading zero if required. "01" to "12" * MMM Abbreviated month name. Date.CultureInfo.abbreviatedMonthNames. "Jan" to "Dec" * MMMM The full month name. Date.CultureInfo.monthNames. "January" to "December" * * yy The year as a two-digit number. "99" or "08" * yyyy The full four digit year. "1999" or "2008" * * t Displays the first character of the A.M./P.M. designator. "A" or "P" * Date.CultureInfo.amDesignator or Date.CultureInfo.pmDesignator * tt Displays the A.M./P.M. designator. "AM" or "PM" * Date.CultureInfo.amDesignator or Date.CultureInfo.pmDesignator * * S The ordinal suffix ("st, "nd", "rd" or "th") of the current day. "st, "nd", "rd" or "th" * * STANDARD DATE AND TIME FORMAT STRINGS * Format Description Example *------ --------------------------------------------------------------------------- ----------------------- * d The CultureInfo shortDate Format Pattern "M/d/yyyy" * D The CultureInfo longDate Format Pattern "dddd, MMMM dd, yyyy" * F The CultureInfo fullDateTime Format Pattern "dddd, MMMM dd, yyyy h:mm:ss tt" * m The CultureInfo monthDay Format Pattern "MMMM dd" * r The CultureInfo rfc1123 Format Pattern "ddd, dd MMM yyyy HH:mm:ss GMT" * s The CultureInfo sortableDateTime Format Pattern "yyyy-MM-ddTHH:mm:ss" * t The CultureInfo shortTime Format Pattern "h:mm tt" * T The CultureInfo longTime Format Pattern "h:mm:ss tt" * u The CultureInfo universalSortableDateTime Format Pattern "yyyy-MM-dd HH:mm:ssZ" * y The CultureInfo yearMonth Format Pattern "MMMM, yyyy" * * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @return {String} A string representation of the current Date object. */ var ord = function (n) { switch (n * 1) { case 1: case 21: case 31: return "st"; case 2: case 22: return "nd"; case 3: case 23: return "rd"; default: return "th"; } }; var parseStandardFormats = function (format) { var y, c = Date.CultureInfo.formatPatterns; switch (format) { case "d": return this.toString(c.shortDate); case "D": return this.toString(c.longDate); case "F": return this.toString(c.fullDateTime); case "m": return this.toString(c.monthDay); case "r": case "R": y = this.clone().addMinutes(this.getTimezoneOffset()); return y.toString(c.rfc1123) + " GMT"; case "s": return this.toString(c.sortableDateTime); case "t": return this.toString(c.shortTime); case "T": return this.toString(c.longTime); case "u": y = this.clone().addMinutes(this.getTimezoneOffset()); return y.toString(c.universalSortableDateTime); case "y": return this.toString(c.yearMonth); default: return false; } }; var parseFormatStringsClosure = function (context) { return function (m) { if (m.charAt(0) === "\\") { return m.replace("\\", ""); } switch (m) { case "hh": return p(context.getHours() < 13 ? (context.getHours() === 0 ? 12 : context.getHours()) : (context.getHours() - 12)); case "h": return context.getHours() < 13 ? (context.getHours() === 0 ? 12 : context.getHours()) : (context.getHours() - 12); case "HH": return p(context.getHours()); case "H": return context.getHours(); case "mm": return p(context.getMinutes()); case "m": return context.getMinutes(); case "ss": return p(context.getSeconds()); case "s": return context.getSeconds(); case "yyyy": return p(context.getFullYear(), 4); case "yy": return p(context.getFullYear()); case "y": return context.getFullYear(); case "E": case "dddd": return Date.CultureInfo.dayNames[context.getDay()]; case "ddd": return Date.CultureInfo.abbreviatedDayNames[context.getDay()]; case "dd": return p(context.getDate()); case "d": return context.getDate(); case "MMMM": return Date.CultureInfo.monthNames[context.getMonth()]; case "MMM": return Date.CultureInfo.abbreviatedMonthNames[context.getMonth()]; case "MM": return p((context.getMonth() + 1)); case "M": return context.getMonth() + 1; case "t": return context.getHours() < 12 ? Date.CultureInfo.amDesignator.substring(0, 1) : Date.CultureInfo.pmDesignator.substring(0, 1); case "tt": return context.getHours() < 12 ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator; case "S": return ord(context.getDate()); case "W": return context.getWeek(); case "WW": return context.getISOWeek(); case "Q": return "Q" + context.getQuarter(); case "q": return String(context.getQuarter()); case "z": return context.getTimezone(); case "Z": case "X": return Date.getTimezoneOffset(context.getTimezone()); case "ZZ": // Timezone offset in seconds return context.getTimezoneOffset() * -60; case "u": return context.getDay(); case "L": return ($D.isLeapYear(context.getFullYear())) ? 1 : 0; case "B": // Swatch Internet Time (.beats) return "@"+((context.getUTCSeconds() + (context.getUTCMinutes()*60) + ((context.getUTCHours()+1)*3600))/86.4); default: return m; } }; }; $P.toString = function (format, ignoreStandards) { // Standard Date and Time Format Strings. Formats pulled from CultureInfo file and // may vary by culture. if (!ignoreStandards && format && format.length === 1) { output = parseStandardFormats.call(this, format); if (output) { return output; } } var parseFormatStrings = parseFormatStringsClosure(this); return format ? format.replace(/((\\)?(dd?d?d?|MM?M?M?|yy?y?y?|hh?|HH?|mm?|ss?|tt?|S|q|Q|WW?W?W?)(?![^\[]*\]))/g, parseFormatStrings).replace(/\[|\]/g, "") : this._toString(); }; }()); /************************************************************* * SugarPak - Domain Specific Language - Syntactical Sugar * *************************************************************/ (function () { var $D = Date, $P = $D.prototype, $N = Number.prototype; // private $P._orient = +1; // private $P._nth = null; // private $P._is = false; // private $P._same = false; // private $P._isSecond = false; // private $N._dateElement = "days"; /** * Moves the date to the next instance of a date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.today().next().friday();
	Date.today().next().fri();
	Date.today().next().march();
	Date.today().next().mar();
	Date.today().next().week();
	
* * @return {Date} date */ $P.next = function () { this._move = true; this._orient = +1; return this; }; /** * Creates a new Date (Date.today()) and moves the date to the next instance of the date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.next().friday();
	Date.next().fri();
	Date.next().march();
	Date.next().mar();
	Date.next().week();
	
* * @return {Date} date */ $D.next = function () { return $D.today().next(); }; /** * Moves the date to the previous instance of a date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.today().last().friday();
	Date.today().last().fri();
	Date.today().last().march();
	Date.today().last().mar();
	Date.today().last().week();
	
* * @return {Date} date */ $P.last = $P.prev = $P.previous = function () { this._move = true; this._orient = -1; return this; }; /** * Creates a new Date (Date.today()) and moves the date to the previous instance of the date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.last().friday();
	Date.last().fri();
	Date.previous().march();
	Date.prev().mar();
	Date.last().week();
	
* * @return {Date} date */ $D.last = $D.prev = $D.previous = function () { return $D.today().last(); }; /** * Performs a equality check when followed by either a month name, day name or .weekday() function. * Example

	Date.today().is().friday(); // true|false
	Date.today().is().fri();
	Date.today().is().march();
	Date.today().is().mar();
	
* * @return {Boolean} true|false */ $P.is = function () { this._is = true; return this; }; /** * Determines if two date objects occur on/in exactly the same instance of the subsequent date part function. * The function .same() must be followed by a date part function (example: .day(), .month(), .year(), etc). * * An optional Date can be passed in the date part function. If now date is passed as a parameter, 'Now' is used. * * The following example demonstrates how to determine if two dates fall on the exact same day. * * Example

	var d1 = Date.today(); // today at 00:00
	var d2 = new Date();   // exactly now.

	// Do they occur on the same day?
	d1.same().day(d2); // true
	
	// Do they occur on the same hour?
	d1.same().hour(d2); // false, unless d2 hour is '00' (midnight).
	
	// What if it's the same day, but one year apart?
	var nextYear = Date.today().add(1).year();

	d1.same().day(nextYear); // false, because the dates must occur on the exact same day. 
	
* * Scenario: Determine if a given date occurs during some week period 2 months from now. * * Example

	var future = Date.today().add(2).months();
	return someDate.same().week(future); // true|false;
	
* * @return {Boolean} true|false */ $P.same = function () { this._same = true; this._isSecond = false; return this; }; /** * Determines if the current date/time occurs during Today. Must be preceded by the .is() function. * Example

	someDate.is().today();    // true|false
	new Date().is().today();  // true
	Date.today().is().today();// true
	Date.today().add(-1).day().is().today(); // false
	
* * @return {Boolean} true|false */ $P.today = function () { return this.same().day(); }; /** * Determines if the current date is a weekday. This function must be preceded by the .is() function. * Example

	Date.today().is().weekday(); // true|false
	
* * @return {Boolean} true|false */ $P.weekday = function () { if (this._nth) { return df("Weekday").call(this); } if (this._move) { return this.addWeekdays(this._orient); } if (this._is) { this._is = false; return (!this.is().sat() && !this.is().sun()); } return false; }; /** * Determines if the current date is on the weekend. This function must be preceded by the .is() function. * Example

	Date.today().is().weekend(); // true|false
	
* * @return {Boolean} true|false */ $P.weekend = function () { if (this._is) { this._is = false; return (this.is().sat() || this.is().sun()); } return false; }; /** * Sets the Time of the current Date instance. A string "6:15 pm" or config object {hour:18, minute:15} are accepted. * Example

	// Set time to 6:15pm with a String
	Date.today().at("6:15pm");

	// Set time to 6:15pm with a config object
	Date.today().at({hour:18, minute:15});
	
* * @return {Date} date */ $P.at = function (time) { return (typeof time === "string") ? $D.parse(this.toString("d") + " " + time) : this.set(time); }; /** * Creates a new Date() and adds this (Number) to the date based on the preceding date element function (eg. second|minute|hour|day|month|year). * Example

	// Undeclared Numbers must be wrapped with parentheses. Requirment of JavaScript.
	(3).days().fromNow();
	(6).months().fromNow();

	// Declared Number variables do not require parentheses. 
	var n = 6;
	n.months().fromNow();
	
* * @return {Date} A new Date instance */ $N.fromNow = $N.after = function (date) { var c = {}; c[this._dateElement] = this; return ((!date) ? new Date() : date.clone()).add(c); }; /** * Creates a new Date() and subtract this (Number) from the date based on the preceding date element function (eg. second|minute|hour|day|month|year). * Example

	// Undeclared Numbers must be wrapped with parentheses. Requirment of JavaScript.
	(3).days().ago();
	(6).months().ago();

	// Declared Number variables do not require parentheses. 
	var n = 6;
	n.months().ago();
	
* * @return {Date} A new Date instance */ $N.ago = $N.before = function (date) { var c = {}, s = (this._dateElement[this._dateElement.length-1] !== "s") ? this._dateElement + "s" : this._dateElement; c[s] = this * -1; return ((!date) ? new Date() : date.clone()).add(c); }; // Do NOT modify the following string tokens. These tokens are used to build dynamic functions. // All culture-specific strings can be found in the CultureInfo files. var dx = ("sunday monday tuesday wednesday thursday friday saturday").split(/\s/), mx = ("january february march april may june july august september october november december").split(/\s/), px = ("Millisecond Second Minute Hour Day Week Month Year Quarter Weekday").split(/\s/), pxf = ("Milliseconds Seconds Minutes Hours Date Week Month FullYear Quarter").split(/\s/), nth = ("final first second third fourth fifth").split(/\s/), de; /** * Returns an object literal of all the date parts. * Example

	var o = new Date().toObject();
	
	// { year: 2008, month: 4, week: 20, day: 13, hour: 18, minute: 9, second: 32, millisecond: 812 }
	
	// The object properties can be referenced directly from the object.
	
	alert(o.day);  // alerts "13"
	alert(o.year); // alerts "2008"
	
* * @return {Date} An object literal representing the original date object. */ $P.toObject = function () { var o = {}; for (var i = 0; i < px.length; i++) { if (this["get" + pxf[i]]) { o[px[i].toLowerCase()] = this["get" + pxf[i]](); } } return o; }; /** * Returns a date created from an object literal. Ignores the .week property if set in the config. * Example

	var o = new Date().toObject();
	
	return Date.fromObject(o); // will return the same date. 

	var o2 = {month: 1, day: 20, hour: 18}; // birthday party!
	Date.fromObject(o2);
	
* * @return {Date} An object literal representing the original date object. */ $D.fromObject = function(config) { config.week = null; return Date.today().set(config); }; // Create day name functions and abbreviated day name functions (eg. monday(), friday(), fri()). var df = function (n) { return function () { if (this._is) { this._is = false; return this.getDay() === n; } if (this._move) { this._move = null; } if (this._nth !== null) { // If the .second() function was called earlier, remove the _orient // from the date, and then continue. // This is required because 'second' can be used in two different context. // // Example // // Date.today().add(1).second(); // Date.march().second().monday(); // // Things get crazy with the following... // Date.march().add(1).second().second().monday(); // but it works!! // if (this._isSecond) { this.addSeconds(this._orient * -1); } // make sure we reset _isSecond this._isSecond = false; var ntemp = this._nth; this._nth = null; var temp = this.clone().moveToLastDayOfMonth(); this.moveToNthOccurrence(n, ntemp); if (this > temp) { throw new RangeError($D.getDayName(n) + " does not occur " + ntemp + " times in the month of " + $D.getMonthName(temp.getMonth()) + " " + temp.getFullYear() + "."); } return this; } return this.moveToDayOfWeek(n, this._orient); }; }; var sdf = function (n) { return function () { var t = $D.today(), shift = n - t.getDay(); if (n === 0 && Date.CultureInfo.firstDayOfWeek === 1 && t.getDay() !== 0) { shift = shift + 7; } return t.addDays(shift); }; }; // Create month name functions and abbreviated month name functions (eg. january(), march(), mar()). var month_instance_functions = function (n) { return function () { if (this._is) { this._is = false; return this.getMonth() === n; } return this.moveToMonth(n, this._orient); }; }; var month_static_functions = function (n) { return function () { return $D.today().set({ month: n, day: 1 }); }; }; var processTerms = function (names, staticFunc, instanceFunc) { for (var i = 0; i < names.length; i++) { // Create constant static Name variables. $D[names[i].toUpperCase()] = $D[names[i].toUpperCase().substring(0, 3)] = i; // Create Name functions. $D[names[i]] = $D[names[i].substring(0, 3)] = staticFunc(i); // Create Name instance functions. $P[names[i]] = $P[names[i].substring(0, 3)] = instanceFunc(i); } }; processTerms(dx, sdf, df); processTerms(mx, month_static_functions, month_instance_functions); // Create date element functions and plural date element functions used with Date (eg. day(), days(), months()). var ef = function (j) { return function () { // if the .second() function was called earlier, the _orient // has alread been added. Just return this and reset _isSecond. if (this._isSecond) { this._isSecond = false; return this; } if (this._same) { this._same = this._is = false; var o1 = this.toObject(), o2 = (arguments[0] || new Date()).toObject(), v = "", k = j.toLowerCase(); // the substr trick with -1 doesn't work in IE8 or less k = (k[k.length-1] === "s") ? k.substring(0,k.length-1) : k; for (var m = (px.length - 1); m > -1; m--) { v = px[m].toLowerCase(); if (o1[v] !== o2[v]) { return false; } if (k === v) { break; } } return true; } if (j.substring(j.length - 1) !== "s") { j += "s"; } if (this._move) { this._move = null; } return this["add" + j](this._orient); }; }; var nf = function (n) { return function () { this._dateElement = n; return this; }; }; for (var k = 0; k < px.length; k++) { de = px[k].toLowerCase(); if(de !== "weekday") { // Create date element functions and plural date element functions used with Date (eg. day(), days(), months()). $P[de] = $P[de + "s"] = ef(px[k]); // Create date element functions and plural date element functions used with Number (eg. day(), days(), months()). $N[de] = $N[de + "s"] = nf(de + "s"); } } $P._ss = ef("Second"); var nthfn = function (n) { return function (dayOfWeek) { if (this._same) { return this._ss(arguments[0]); } if (dayOfWeek || dayOfWeek === 0) { return this.moveToNthOccurrence(dayOfWeek, n); } this._nth = n; // if the operator is 'second' add the _orient, then deal with it later... if (n === 2 && (dayOfWeek === undefined || dayOfWeek === null)) { this._isSecond = true; return this.addSeconds(this._orient); } return this; }; }; for (var l = 0; l < nth.length; l++) { $P[nth[l]] = (l === 0) ? nthfn(-1) : nthfn(l); } }()); (function () { "use strict"; Date.Parsing = { Exception: function (s) { this.message = "Parse error at '" + s.substring(0, 10) + " ...'"; } }; var $P = Date.Parsing; var dayOffsets = { standard: [0,31,59,90,120,151,181,212,243,273,304,334], leap: [0,31,60,91,121,152,182,213,244,274,305,335] }; $P.isLeapYear = function(year) { return ((year % 4 === 0) && (year % 100 !== 0)) || (year % 400 === 0); }; var utils = { multiReplace : function (str, hash ) { var key; for (key in hash) { if (Object.prototype.hasOwnProperty.call(hash, key)) { var regex; if (typeof hash[key] === "function") { } else { regex = (hash[key] instanceof RegExp) ? hash[key] : new RegExp(hash[key], "g"); } str = str.replace(regex, key); } } return str; }, getDayOfYearFromWeek : function (obj) { var d, jan4, offset; obj.weekDay = (!obj.weekDay && obj.weekDay !== 0) ? 1 : obj.weekDay; d = new Date(obj.year, 0, 4); jan4 = d.getDay() === 0 ? 7 : d.getDay(); // JS is 0 indexed on Sunday. offset = jan4+3; obj.dayOfYear = ((obj.week * 7) + (obj.weekDay === 0 ? 7 : obj.weekDay))-offset; return obj; }, getDayOfYear : function (obj, dayOffset) { if (!obj.dayOfYear) { obj = utils.getDayOfYearFromWeek(obj); } for (var i=0;i <= dayOffset.length;i++) { if (obj.dayOfYear < dayOffset[i] || i === dayOffset.length) { obj.day = obj.day ? obj.day : (obj.dayOfYear - dayOffset[i-1]); break; } else { obj.month = i; } } return obj; }, adjustForTimeZone : function (obj, date) { var offset; if (obj.zone.toUpperCase() === "Z" || (obj.zone_hours === 0 && obj.zone_minutes === 0)) { // it's UTC/GML so work out the current timeszone offset offset = -date.getTimezoneOffset(); } else { offset = (obj.zone_hours*60) + (obj.zone_minutes || 0); if (obj.zone_sign === "+") { offset *= -1; } offset -= date.getTimezoneOffset(); } date.setMinutes(date.getMinutes()+offset); return date; }, setDefaults : function (obj) { obj.year = obj.year || Date.today().getFullYear(); obj.hours = obj.hours || 0; obj.minutes = obj.minutes || 0; obj.seconds = obj.seconds || 0; obj.milliseconds = obj.milliseconds || 0; if (!(!obj.month && (obj.week || obj.dayOfYear))) { // if we have a month, or if we don't but don't have the day calculation data obj.month = obj.month || 0; obj.day = obj.day || 1; } return obj; }, dataNum: function (data, mod, explict, postProcess) { var dataNum = data*1; if (mod) { if (postProcess) { return data ? mod(data)*1 : data; } else { return data ? mod(dataNum) : data; } } else if (!explict){ return data ? dataNum : data; } else { return (data && typeof data !== "undefined") ? dataNum : data; } }, timeDataProcess: function (obj) { var timeObj = {}; for (var x in obj.data) { if (obj.data.hasOwnProperty(x)) { timeObj[x] = obj.ignore[x] ? obj.data[x] : utils.dataNum(obj.data[x], obj.mods[x], obj.explict[x], obj.postProcess[x]); } } if (obj.data.secmins) { obj.data.secmins = obj.data.secmins.replace(",", ".") * 60; if (!timeObj.minutes) { timeObj.minutes = obj.data.secmins; } else if (!timeObj.seconds) { timeObj.seconds = obj.data.secmins; } delete obj.secmins; } return timeObj; }, buildTimeObjectFromData: function (data) { var time = utils.timeDataProcess({ data: { year : data[1], month : data[5], day : data[7], week : data[8], dayOfYear : data[10], hours : data[15], zone_hours : data[23], zone_minutes : data[24], zone : data[21], zone_sign : data[22], weekDay : data[9], minutes: data[16], seconds: data[19], milliseconds: data[20], secmins: data[18] }, mods: { month: function(data) { return data-1; }, weekDay: function (data) { data = Math.abs(data); return (data === 7 ? 0 : data); }, minutes: function (data) { return data.replace(":",""); }, seconds: function (data) { return Math.floor( (data.replace(":","").replace(",","."))*1 ); }, milliseconds: function (data) { return (data.replace(",",".")*1000); } }, postProcess: { minutes: true, seconds: true, milliseconds: true }, explict: { zone_hours: true, zone_minutes: true }, ignore: { zone: true, zone_sign: true, secmins: true } }); return time; }, addToHash: function (hash, keys, data) { keys = keys; data = data; var len = keys.length; for (var i = 0; i < len; i++) { hash[keys[i]] = data[i]; } return hash; }, combineRegex: function (r1, r2) { return new RegExp("(("+r1.source+")\\s("+r2.source+"))"); }, getDateNthString: function(add, last, inc){ if (add) { return Date.today().addDays(inc).toString("d"); } else if (last) { return Date.today().last()[inc]().toString("d"); } }, buildRegexData: function (array) { var arr = []; var len = array.length; for (var i=0; i < len; i++) { if (Object.prototype.toString.call(array[i]) === '[object Array]') { // oldIE compat version of Array.isArray arr.push(this.combineRegex(array[i][0], array[i][1])); } else { arr.push(array[i]); } } return arr; } }; $P.processTimeObject = function (obj) { var date, dayOffset; utils.setDefaults(obj); dayOffset = ($P.isLeapYear(obj.year)) ? dayOffsets.leap : dayOffsets.standard; if (!obj.month && (obj.week || obj.dayOfYear)) { utils.getDayOfYear(obj, dayOffset); } else { obj.dayOfYear = dayOffset[obj.month] + obj.day; } date = new Date(obj.year, obj.month, obj.day, obj.hours, obj.minutes, obj.seconds, obj.milliseconds); if (obj.zone) { utils.adjustForTimeZone(obj, date); // adjust (and calculate) for timezone } return date; }; $P.ISO = { regex : /^([\+-]?\d{4}(?!\d{2}\b))((-?)((0[1-9]|1[0-2])(\3([12]\d|0[1-9]|3[01]))?|W([0-4]\d|5[0-3])(-?[1-7])?|(00[1-9]|0[1-9]\d|[12]\d{2}|3([0-5]\d|6[1-6])))([T\s]((([01]\d|2[0-4])((:?)[0-5]\d)?|24\:?00)([\.,]\d+(?!:))?)?(\17[0-5]\d([\.,]\d+)?)?\s?([zZ]|([\+-])([01]\d|2[0-3]):?([0-5]\d)?)?)?)?$/, parse : function (s) { var time, data = s.match(this.regex); if (!data || !data.length) { return null; } time = utils.buildTimeObjectFromData(data); if (!time.year || (!time.year && (!time.month && !time.day) && (!time.week && !time.dayOfYear)) ) { return null; } return $P.processTimeObject(time); } }; $P.Numeric = { isNumeric: function (e){return!isNaN(parseFloat(e))&&isFinite(e);}, regex: /\b([0-1]?[0-9])([0-3]?[0-9])([0-2]?[0-9]?[0-9][0-9])\b/i, parse: function (s) { var data, i, time = {}, order = Date.CultureInfo.dateElementOrder.split(""); if (!(this.isNumeric(s)) || // if it's non-numeric OR (s[0] === "+" && s[0] === "-")) { // It's an arithmatic string (eg +/-1000) return null; } if (s.length < 5 && s.indexOf(".") < 0 && s.indexOf("/") < 0) { // assume it's just a year. time.year = s; return $P.processTimeObject(time); } data = s.match(this.regex); if (!data || !data.length) { return null; } for (i=0; i < order.length; i++) { switch(order[i]) { case "d": time.day = data[i+1]; break; case "m": time.month = (data[i+1]-1); break; case "y": time.year = data[i+1]; break; } } return $P.processTimeObject(time); } }; $P.Normalizer = { regexData: function () { var $R = Date.CultureInfo.regexPatterns; return utils.buildRegexData([ $R.tomorrow, $R.yesterday, [$R.past, $R.mon], [$R.past, $R.tue], [$R.past, $R.wed], [$R.past, $R.thu], [$R.past, $R.fri], [$R.past, $R.sat], [$R.past, $R.sun] ]); }, basicReplaceHash : function() { var $R = Date.CultureInfo.regexPatterns; return { "January": $R.jan.source, "February": $R.feb, "March": $R.mar, "April": $R.apr, "May": $R.may, "June": $R.jun, "July": $R.jul, "August": $R.aug, "September": $R.sep, "October": $R.oct, "November": $R.nov, "December": $R.dec, "": /\bat\b/gi, " ": /\s{2,}/, "am": $R.inTheMorning, "9am": $R.thisMorning, "pm": $R.inTheEvening, "7pm":$R.thisEvening }; }, keys : function(){ return [ utils.getDateNthString(true, false, 1), // tomorrow utils.getDateNthString(true, false, -1), // yesterday utils.getDateNthString(false, true, "monday"), //last mon utils.getDateNthString(false, true, "tuesday"), //last tues utils.getDateNthString(false, true, "wednesday"), //last wed utils.getDateNthString(false, true, "thursday"), //last thurs utils.getDateNthString(false, true, "friday"), //last fri utils.getDateNthString(false, true, "saturday"), //last sat utils.getDateNthString(false, true, "sunday") //last sun ]; }, buildRegexFunctions: function () { var $R = Date.CultureInfo.regexPatterns; var __ = Date.i18n.__; var tomorrowRE = new RegExp("(\\b\\d\\d?("+__("AM")+"|"+__("PM")+")? )("+$R.tomorrow.source.slice(1)+")", "i"); // adapted tomorrow regex for AM PM relative dates var todayRE = new RegExp($R.today.source + "(?!\\s*([+-]))\\b"); // today, but excludes the math operators (eg "today + 2h") this.replaceFuncs = [ [todayRE, function (full) { return (full.length > 1) ? Date.today().toString("d") : full; }], [tomorrowRE, function(full, m1) { var t = Date.today().addDays(1).toString("d"); return (t + " " + m1); }], [$R.amThisMorning, function(str, am){return am;}], [$R.pmThisEvening, function(str, pm){return pm;}] ]; }, buildReplaceData: function () { this.buildRegexFunctions(); this.replaceHash = utils.addToHash(this.basicReplaceHash(), this.keys(), this.regexData()); }, stringReplaceFuncs: function (s) { for (var i=0; i < this.replaceFuncs.length; i++) { s = s.replace(this.replaceFuncs[i][0], this.replaceFuncs[i][1]); } return s; }, parse: function (s) { s = this.stringReplaceFuncs(s); s = utils.multiReplace(s, this.replaceHash); try { var n = s.split(/([\s\-\.\,\/\x27]+)/); if (n.length === 3 && $P.Numeric.isNumeric(n[0]) && $P.Numeric.isNumeric(n[2]) && (n[2].length >= 4)) { // ok, so we're dealing with x/year. But that's not a full date. // This fixes wonky dateElementOrder parsing when set to dmy order. if (Date.CultureInfo.dateElementOrder[0] === "d") { s = "1/" + n[0] + "/" + n[2]; // set to 1st of month and normalize the seperator } } } catch (e) {} return s; } }; $P.Normalizer.buildReplaceData(); }()); (function () { var $P = Date.Parsing; var _ = $P.Operators = { // // Tokenizers // rtoken: function (r) { // regex token return function (s) { var mx = s.match(r); if (mx) { return ([ mx[0], s.substring(mx[0].length) ]); } else { throw new $P.Exception(s); } }; }, token: function () { // whitespace-eating token return function (s) { return _.rtoken(new RegExp("^\\s*" + s + "\\s*"))(s); }; }, stoken: function (s) { // string token return _.rtoken(new RegExp("^" + s)); }, // Atomic Operators until: function (p) { return function (s) { var qx = [], rx = null; while (s.length) { try { rx = p.call(this, s); } catch (e) { qx.push(rx[0]); s = rx[1]; continue; } break; } return [ qx, s ]; }; }, many: function (p) { return function (s) { var rx = [], r = null; while (s.length) { try { r = p.call(this, s); } catch (e) { return [ rx, s ]; } rx.push(r[0]); s = r[1]; } return [ rx, s ]; }; }, // generator operators -- see below optional: function (p) { return function (s) { var r = null; try { r = p.call(this, s); } catch (e) { return [ null, s ]; } return [ r[0], r[1] ]; }; }, not: function (p) { return function (s) { try { p.call(this, s); } catch (e) { return [null, s]; } throw new $P.Exception(s); }; }, ignore: function (p) { return p ? function (s) { var r = null; r = p.call(this, s); return [null, r[1]]; } : null; }, product: function () { var px = arguments[0], qx = Array.prototype.slice.call(arguments, 1), rx = []; for (var i = 0 ; i < px.length ; i++) { rx.push(_.each(px[i], qx)); } return rx; }, cache: function (rule) { var cache = {}, cache_length = 0, cache_keys = [], CACHE_MAX = Date.Config.CACHE_MAX || 100000, r = null; var cacheCheck = function () { if (cache_length === CACHE_MAX) { // kill several keys, don't want to have to do this all the time... for (var i=0; i < 10; i++) { var key = cache_keys.shift(); if (key) { delete cache[key]; cache_length--; } } } }; return function (s) { cacheCheck(); try { r = cache[s] = (cache[s] || rule.call(this, s)); } catch (e) { r = cache[s] = e; } cache_length++; cache_keys.push(s); if (r instanceof $P.Exception) { throw r; } else { return r; } }; }, // vector operators -- see below any: function () { var px = arguments; return function (s) { var r = null; for (var i = 0; i < px.length; i++) { if (px[i] == null) { continue; } try { r = (px[i].call(this, s)); } catch (e) { r = null; } if (r) { return r; } } throw new $P.Exception(s); }; }, each: function () { var px = arguments; return function (s) { var rx = [], r = null; for (var i = 0; i < px.length ; i++) { if (px[i] == null) { continue; } try { r = (px[i].call(this, s)); } catch (e) { throw new $P.Exception(s); } rx.push(r[0]); s = r[1]; } return [ rx, s]; }; }, all: function () { var px = arguments, _ = _; return _.each(_.optional(px)); }, // delimited operators sequence: function (px, d, c) { d = d || _.rtoken(/^\s*/); c = c || null; if (px.length === 1) { return px[0]; } return function (s) { var r = null, q = null; var rx = []; for (var i = 0; i < px.length ; i++) { try { r = px[i].call(this, s); } catch (e) { break; } rx.push(r[0]); try { q = d.call(this, r[1]); } catch (ex) { q = null; break; } s = q[1]; } if (!r) { throw new $P.Exception(s); } if (q) { throw new $P.Exception(q[1]); } if (c) { try { r = c.call(this, r[1]); } catch (ey) { throw new $P.Exception(r[1]); } } return [ rx, (r?r[1]:s) ]; }; }, // // Composite Operators // between: function (d1, p, d2) { d2 = d2 || d1; var _fn = _.each(_.ignore(d1), p, _.ignore(d2)); return function (s) { var rx = _fn.call(this, s); return [[rx[0][0], r[0][2]], rx[1]]; }; }, list: function (p, d, c) { d = d || _.rtoken(/^\s*/); c = c || null; return (p instanceof Array ? _.each(_.product(p.slice(0, -1), _.ignore(d)), p.slice(-1), _.ignore(c)) : _.each(_.many(_.each(p, _.ignore(d))), px, _.ignore(c))); }, set: function (px, d, c) { d = d || _.rtoken(/^\s*/); c = c || null; return function (s) { // r is the current match, best the current 'best' match // which means it parsed the most amount of input var r = null, p = null, q = null, rx = null, best = [[], s], last = false; // go through the rules in the given set for (var i = 0; i < px.length ; i++) { // last is a flag indicating whether this must be the last element // if there is only 1 element, then it MUST be the last one q = null; p = null; r = null; last = (px.length === 1); // first, we try simply to match the current pattern // if not, try the next pattern try { r = px[i].call(this, s); } catch (e) { continue; } // since we are matching against a set of elements, the first // thing to do is to add r[0] to matched elements rx = [[r[0]], r[1]]; // if we matched and there is still input to parse and // we don't already know this is the last element, // we're going to next check for the delimiter ... // if there's none, or if there's no input left to parse // than this must be the last element after all ... if (r[1].length > 0 && ! last) { try { q = d.call(this, r[1]); } catch (ex) { last = true; } } else { last = true; } // if we parsed the delimiter and now there's no more input, // that means we shouldn't have parsed the delimiter at all // so don't update r and mark this as the last element ... if (!last && q[1].length === 0) { last = true; } // so, if this isn't the last element, we're going to see if // we can get any more matches from the remaining (unmatched) // elements ... if (!last) { // build a list of the remaining rules we can match against, // i.e., all but the one we just matched against var qx = []; for (var j = 0; j < px.length ; j++) { if (i !== j) { qx.push(px[j]); } } // now invoke recursively set with the remaining input // note that we don't include the closing delimiter ... // we'll check for that ourselves at the end p = _.set(qx, d).call(this, q[1]); // if we got a non-empty set as a result ... // (otw rx already contains everything we want to match) if (p[0].length > 0) { // update current result, which is stored in rx ... // basically, pick up the remaining text from p[1] // and concat the result from p[0] so that we don't // get endless nesting ... rx[0] = rx[0].concat(p[0]); rx[1] = p[1]; } } // at this point, rx either contains the last matched element // or the entire matched set that starts with this element. // now we just check to see if this variation is better than // our best so far, in terms of how much of the input is parsed if (rx[1].length < best[1].length) { best = rx; } // if we've parsed all the input, then we're finished if (best[1].length === 0) { break; } } // so now we've either gone through all the patterns trying them // as the initial match; or we found one that parsed the entire // input string ... // if best has no matches, just return empty set ... if (best[0].length === 0) { return best; } // if a closing delimiter is provided, then we have to check it also if (c) { // we try this even if there is no remaining input because the pattern // may well be optional or match empty input ... try { q = c.call(this, best[1]); } catch (ey) { throw new $P.Exception(best[1]); } // it parsed ... be sure to update the best match remaining input best[1] = q[1]; } // if we're here, either there was no closing delimiter or we parsed it // so now we have the best match; just return it! return best; }; }, forward: function (gr, fname) { return function (s) { return gr[fname].call(this, s); }; }, // // Translation Operators // replace: function (rule, repl) { return function (s) { var r = rule.call(this, s); return [repl, r[1]]; }; }, process: function (rule, fn) { return function (s) { var r = rule.call(this, s); return [fn.call(this, r[0]), r[1]]; }; }, min: function (min, rule) { return function (s) { var rx = rule.call(this, s); if (rx[0].length < min) { throw new $P.Exception(s); } return rx; }; } }; // Generator Operators And Vector Operators // Generators are operators that have a signature of F(R) => R, // taking a given rule and returning another rule, such as // ignore, which parses a given rule and throws away the result. // Vector operators are those that have a signature of F(R1,R2,...) => R, // take a list of rules and returning a new rule, such as each. // Generator operators are converted (via the following _generator // function) into functions that can also take a list or array of rules // and return an array of new rules as though the function had been // called on each rule in turn (which is what actually happens). // This allows generators to be used with vector operators more easily. // Example: // each(ignore(foo, bar)) instead of each(ignore(foo), ignore(bar)) // This also turns generators into vector operators, which allows // constructs like: // not(cache(foo, bar)) var _generator = function (op) { function gen() { var args = null, rx = [], px, i; if (arguments.length > 1) { args = Array.prototype.slice.call(arguments); } else if (arguments[0] instanceof Array) { args = arguments[0]; } if (args) { px = args.shift(); if (px.length > 0) { args.unshift(px[i]); rx.push(op.apply(null, args)); args.shift(); return rx; } } else { return op.apply(null, arguments); } } return gen; }; var gx = "optional not ignore cache".split(/\s/); for (var i = 0 ; i < gx.length ; i++) { _[gx[i]] = _generator(_[gx[i]]); } var _vector = function (op) { return function () { if (arguments[0] instanceof Array) { return op.apply(null, arguments[0]); } else { return op.apply(null, arguments); } }; }; var vx = "each any all".split(/\s/); for (var j = 0 ; j < vx.length ; j++) { _[vx[j]] = _vector(_[vx[j]]); } }()); (function () { var $D = Date; var flattenAndCompact = function (ax) { var rx = []; for (var i = 0; i < ax.length; i++) { if (ax[i] instanceof Array) { rx = rx.concat(flattenAndCompact(ax[i])); } else { if (ax[i]) { rx.push(ax[i]); } } } return rx; }; var parseMeridian = function () { if (this.meridian && (this.hour || this.hour === 0)) { if (this.meridian === "a" && this.hour > 11 && Date.Config.strict24hr){ throw "Invalid hour and meridian combination"; } else if (this.meridian === "p" && this.hour < 12 && Date.Config.strict24hr){ throw "Invalid hour and meridian combination"; } else if (this.meridian === "p" && this.hour < 12) { this.hour = this.hour + 12; } else if (this.meridian === "a" && this.hour === 12) { this.hour = 0; } } }; var setDefaults = function () { var now = new Date(); if ((this.hour || this.minute) && (!this.month && !this.year && !this.day)) { this.day = now.getDate(); } if (!this.year) { this.year = now.getFullYear(); } if (!this.month && this.month !== 0) { this.month = now.getMonth(); } if (!this.day) { this.day = 1; } if (!this.hour) { this.hour = 0; } if (!this.minute) { this.minute = 0; } if (!this.second) { this.second = 0; } if (!this.millisecond) { this.millisecond = 0; } }; var finishUtils = { getToday: function () { if (this.now || "hour minute second".indexOf(this.unit) !== -1) { return new Date(); } else { return $D.today(); } }, setDaysFromWeekday: function (today, orient){ var gap; orient = orient || 1; this.unit = "day"; gap = ($D.getDayNumberFromName(this.weekday) - today.getDay()); this.days = gap ? ((gap + (orient * 7)) % 7) : (orient * 7); return this; }, setMonthsFromMonth: function (today, orient) { var gap; orient = orient || 1; this.unit = "month"; gap = (this.month - today.getMonth()); this.months = gap ? ((gap + (orient * 12)) % 12) : (orient * 12); this.month = null; return this; }, setDMYFromWeekday: function () { var d = Date[this.weekday](); this.day = d.getDate(); if (!this.month) { this.month = d.getMonth(); } this.year = d.getFullYear(); return this; }, setUnitValue: function (orient) { if (!this.value && this.operator && this.operator !== null && this[this.unit + "s"] && this[this.unit + "s"] !== null) { this[this.unit + "s"] = this[this.unit + "s"] + ((this.operator === "add") ? 1 : -1) + (this.value||0) * orient; } else if (this[this.unit + "s"] == null || this.operator != null) { if (!this.value) { this.value = 1; } this[this.unit + "s"] = this.value * orient; } }, generateDateFromWeeks: function () { var weekday = (this.weekday !== undefined) ? this.weekday : "today"; var d = Date[weekday]().addWeeks(this.weeks); if (this.now) { d.setTimeToNow(); } return d; } }; $D.Translator = { hour: function (s) { return function () { this.hour = Number(s); }; }, minute: function (s) { return function () { this.minute = Number(s); }; }, second: function (s) { return function () { this.second = Number(s); }; }, /* for ss.s format */ secondAndMillisecond: function (s) { return function () { var mx = s.match(/^([0-5][0-9])\.([0-9]{1,3})/); this.second = Number(mx[1]); this.millisecond = Number(mx[2]); }; }, meridian: function (s) { return function () { this.meridian = s.slice(0, 1).toLowerCase(); }; }, timezone: function (s) { return function () { var n = s.replace(/[^\d\+\-]/g, ""); if (n.length) { this.timezoneOffset = Number(n); } else { this.timezone = s.toLowerCase(); } }; }, day: function (x) { var s = x[0]; return function () { this.day = Number(s.match(/\d+/)[0]); if (this.day < 1) { throw "invalid day"; } }; }, month: function (s) { return function () { this.month = (s.length === 3) ? "jan feb mar apr may jun jul aug sep oct nov dec".indexOf(s)/4 : Number(s) - 1; if (this.month < 0) { throw "invalid month"; } }; }, year: function (s) { return function () { var n = Number(s); this.year = ((s.length > 2) ? n : (n + (((n + 2000) < Date.CultureInfo.twoDigitYearMax) ? 2000 : 1900))); }; }, rday: function (s) { return function () { switch (s) { case "yesterday": this.days = -1; break; case "tomorrow": this.days = 1; break; case "today": this.days = 0; break; case "now": this.days = 0; this.now = true; break; } }; }, finishExact: function (x) { var d; x = (x instanceof Array) ? x : [x]; for (var i = 0 ; i < x.length ; i++) { if (x[i]) { x[i].call(this); } } setDefaults.call(this); parseMeridian.call(this); if (this.day > $D.getDaysInMonth(this.year, this.month)) { throw new RangeError(this.day + " is not a valid value for days."); } d = new Date(this.year, this.month, this.day, this.hour, this.minute, this.second, this.millisecond); if (this.year < 100) { d.setFullYear(this.year); // means years less that 100 are process correctly. JS will parse it otherwise as 1900-1999. } if (this.timezone) { d.set({ timezone: this.timezone }); } else if (this.timezoneOffset) { d.set({ timezoneOffset: this.timezoneOffset }); } return d; }, finish: function (x) { var today, expression, orient, temp; x = (x instanceof Array) ? flattenAndCompact(x) : [ x ]; if (x.length === 0) { return null; } for (var i = 0 ; i < x.length ; i++) { if (typeof x[i] === "function") { x[i].call(this); } } if (this.now && !this.unit && !this.operator) { return new Date(); } else { today = finishUtils.getToday.call(this); } expression = !!(this.days && this.days !== null || this.orient || this.operator); orient = ((this.orient === "past" || this.operator === "subtract") ? -1 : 1); if (this.month && this.unit === "week") { this.value = this.month + 1; delete this.month; delete this.day; } if ((this.month || this.month === 0) && "year day hour minute second".indexOf(this.unit) !== -1) { if (!this.value) { this.value = this.month + 1; } this.month = null; expression = true; } if (!expression && this.weekday && !this.day && !this.days) { finishUtils.setDMYFromWeekday.call(this); } if (expression && this.weekday && this.unit !== "month" && this.unit !== "week") { finishUtils.setDaysFromWeekday.call(this, today, orient); } if (this.weekday && this.unit !== "week" && !this.day && !this.days) { temp = Date[this.weekday](); this.day = temp.getDate(); if (temp.getMonth() !== today.getMonth()) { this.month = temp.getMonth(); } } if (this.month && this.unit === "day" && this.operator) { if (!this.value) { this.value = (this.month + 1); } this.month = null; } if (this.value != null && this.month != null && this.year != null) { this.day = this.value * 1; } if (this.month && !this.day && this.value) { today.set({ day: this.value * 1 }); if (!expression) { this.day = this.value * 1; } } if (!this.month && this.value && this.unit === "month" && !this.now) { this.month = this.value; expression = true; } if (expression && (this.month || this.month === 0) && this.unit !== "year") { finishUtils.setMonthsFromMonth.call(this, today, orient); } if (!this.unit) { this.unit = "day"; } finishUtils.setUnitValue.call(this, orient); parseMeridian.call(this); if ((this.month || this.month === 0) && !this.day) { this.day = 1; } if (!this.orient && !this.operator && this.unit === "week" && this.value && !this.day && !this.month) { return Date.today().setWeek(this.value); } if (this.unit === "week" && this.weeks && !this.day && !this.month) { return finishUtils.generateDateFromWeeks.call(this); } if (expression && this.timezone && this.day && this.days) { this.day = this.days; } if (expression){ today.add(this); } else { today.set(this); } if (this.timezone) { this.timezone = this.timezone.toUpperCase(); var offset = $D.getTimezoneOffset(this.timezone); var timezone; if (today.hasDaylightSavingTime()) { // lets check that we're being sane with timezone setting timezone = $D.getTimezoneAbbreviation(offset, today.isDaylightSavingTime()); if (timezone !== this.timezone) { // bugger, we're in a place where things like EST vs EDT matters. if (today.isDaylightSavingTime()) { today.addHours(-1); } else { today.addHours(1); } } } today.setTimezoneOffset(offset); } return today; } }; }()); (function () { var $D = Date; $D.Grammar = {}; var _ = $D.Parsing.Operators, g = $D.Grammar, t = $D.Translator, _fn; // Allow rolling up into general purpose rules _fn = function () { return _.each(_.any.apply(null, arguments), _.not(g.ctoken2("timeContext"))); }; g.datePartDelimiter = _.rtoken(/^([\s\-\.\,\/\x27]+)/); g.timePartDelimiter = _.stoken(":"); g.whiteSpace = _.rtoken(/^\s*/); g.generalDelimiter = _.rtoken(/^(([\s\,]|at|@|on)+)/); var _C = {}; g.ctoken = function (keys) { var fn = _C[keys]; if (! fn) { var c = Date.CultureInfo.regexPatterns; var kx = keys.split(/\s+/), px = []; for (var i = 0; i < kx.length ; i++) { px.push(_.replace(_.rtoken(c[kx[i]]), kx[i])); } fn = _C[keys] = _.any.apply(null, px); } return fn; }; g.ctoken2 = function (key) { return _.rtoken(Date.CultureInfo.regexPatterns[key]); }; var cacheProcessRtoken = function (key, token, type, eachToken) { if (eachToken) { g[key] = _.cache(_.process(_.each(_.rtoken(token),_.optional(g.ctoken2(eachToken))), type)); } else { g[key] = _.cache(_.process(_.rtoken(token), type)); } }; var cacheProcessCtoken = function (token, type) { return _.cache(_.process(g.ctoken2(token), type)); }; var _F = {}; //function cache var _get = function (f) { _F[f] = (_F[f] || g.format(f)[0]); return _F[f]; }; g.allformats = function (fx) { var rx = []; if (fx instanceof Array) { for (var i = 0; i < fx.length; i++) { rx.push(_get(fx[i])); } } else { rx.push(_get(fx)); } return rx; }; g.formats = function (fx) { if (fx instanceof Array) { var rx = []; for (var i = 0 ; i < fx.length ; i++) { rx.push(_get(fx[i])); } return _.any.apply(null, rx); } else { return _get(fx); } }; var grammarFormats = { timeFormats: function(){ var i, RTokenKeys = [ "h", "hh", "H", "HH", "m", "mm", "s", "ss", "ss.s", "z", "zz" ], RToken = [ /^(0[0-9]|1[0-2]|[1-9])/, /^(0[0-9]|1[0-2])/, /^([0-1][0-9]|2[0-3]|[0-9])/, /^([0-1][0-9]|2[0-3])/, /^([0-5][0-9]|[0-9])/, /^[0-5][0-9]/, /^([0-5][0-9]|[0-9])/, /^[0-5][0-9]/, /^[0-5][0-9]\.[0-9]{1,3}/, /^((\+|\-)\s*\d\d\d\d)|((\+|\-)\d\d\:?\d\d)/, /^((\+|\-)\s*\d\d\d\d)|((\+|\-)\d\d\:?\d\d)/ ], tokens = [ t.hour, t.hour, t.hour, t.hour, t.minute, t.minute, t.second, t.second, t.secondAndMillisecond, t.timezone, t.timezone ]; for (i=0; i < RTokenKeys.length; i++) { cacheProcessRtoken(RTokenKeys[i], RToken[i], tokens[i]); } g.hms = _.cache(_.sequence([g.H, g.m, g.s], g.timePartDelimiter)); g.t = cacheProcessCtoken("shortMeridian", t.meridian); g.tt = cacheProcessCtoken("longMeridian", t.meridian); g.zzz = cacheProcessCtoken("timezone", t.timezone); g.timeSuffix = _.each(_.ignore(g.whiteSpace), _.set([ g.tt, g.zzz ])); g.time = _.each(_.optional(_.ignore(_.stoken("T"))), g.hms, g.timeSuffix); }, dateFormats: function () { // pre-loaded rules for different date part order preferences var _setfn = function () { return _.set(arguments, g.datePartDelimiter); }; var i, RTokenKeys = [ "d", "dd", "M", "MM", "y", "yy", "yyy", "yyyy" ], RToken = [ /^([0-2]\d|3[0-1]|\d)/, /^([0-2]\d|3[0-1])/, /^(1[0-2]|0\d|\d)/, /^(1[0-2]|0\d)/, /^(\d+)/, /^(\d\d)/, /^(\d\d?\d?\d?)/, /^(\d\d\d\d)/ ], tokens = [ t.day, t.day, t.month, t.month, t.year, t.year, t.year, t.year ], eachToken = [ "ordinalSuffix", "ordinalSuffix" ]; for (i=0; i < RTokenKeys.length; i++) { cacheProcessRtoken(RTokenKeys[i], RToken[i], tokens[i], eachToken[i]); } g.MMM = g.MMMM = _.cache(_.process(g.ctoken("jan feb mar apr may jun jul aug sep oct nov dec"), t.month)); g.ddd = g.dddd = _.cache(_.process(g.ctoken("sun mon tue wed thu fri sat"), function (s) { return function () { this.weekday = s; }; } )); g.day = _fn(g.d, g.dd); g.month = _fn(g.M, g.MMM); g.year = _fn(g.yyyy, g.yy); g.mdy = _setfn(g.ddd, g.month, g.day, g.year); g.ymd = _setfn(g.ddd, g.year, g.month, g.day); g.dmy = _setfn(g.ddd, g.day, g.month, g.year); g.date = function (s) { return ((g[Date.CultureInfo.dateElementOrder] || g.mdy).call(this, s)); }; }, relative: function () { // relative date / time expressions g.orientation = _.process(g.ctoken("past future"), function (s) { return function () { this.orient = s; }; } ); g.operator = _.process(g.ctoken("add subtract"), function (s) { return function () { this.operator = s; }; } ); g.rday = _.process(g.ctoken("yesterday tomorrow today now"), t.rday); g.unit = _.process(g.ctoken("second minute hour day week month year"), function (s) { return function () { this.unit = s; }; } ); } }; g.buildGrammarFormats = function () { // these need to be rebuilt every time the language changes. _C = {}; grammarFormats.timeFormats(); grammarFormats.dateFormats(); grammarFormats.relative(); g.value = _.process(_.rtoken(/^([-+]?\d+)?(st|nd|rd|th)?/), function (s) { return function () { this.value = s.replace(/\D/g, ""); }; } ); g.expression = _.set([g.rday, g.operator, g.value, g.unit, g.orientation, g.ddd, g.MMM ]); g.format = _.process(_.many( _.any( // translate format specifiers into grammar rules _.process( _.rtoken(/^(dd?d?d?(?!e)|MM?M?M?|yy?y?y?|hh?|HH?|mm?|ss?|tt?|zz?z?)/), function (fmt) { if (g[fmt]) { return g[fmt]; } else { throw $D.Parsing.Exception(fmt); } } ), // translate separator tokens into token rules _.process(_.rtoken(/^[^dMyhHmstz]+/), // all legal separators function (s) { return _.ignore(_.stoken(s)); } ) ) ), // construct the parser ... function (rules) { return _.process(_.each.apply(null, rules), t.finishExact); } ); // starting rule for general purpose grammar g._start = _.process(_.set([ g.date, g.time, g.expression ], g.generalDelimiter, g.whiteSpace), t.finish); }; g.buildGrammarFormats(); // parsing date format specifiers - ex: "h:m:s tt" // this little guy will generate a custom parser based // on the format string, ex: g.format("h:m:s tt") // check for these formats first g._formats = g.formats([ "\"yyyy-MM-ddTHH:mm:ssZ\"", "yyyy-MM-ddTHH:mm:ss.sz", "yyyy-MM-ddTHH:mm:ssZ", "yyyy-MM-ddTHH:mm:ssz", "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-ddTHH:mmZ", "yyyy-MM-ddTHH:mmz", "yyyy-MM-ddTHH:mm", "ddd, MMM dd, yyyy H:mm:ss tt", "ddd MMM d yyyy HH:mm:ss zzz", "MMddyyyy", "ddMMyyyy", "Mddyyyy", "ddMyyyy", "Mdyyyy", "dMyyyy", "yyyy", "Mdyy", "dMyy", "d" ]); // real starting rule: tries selected formats first, // then general purpose rule g.start = function (s) { try { var r = g._formats.call({}, s); if (r[1].length === 0) { return r; } } catch (e) {} return g._start.call({}, s); }; }()); (function () { var $D = Date; /** * @desc Converts the specified string value into its JavaScript Date equivalent using CultureInfo specific format information. * * Example

	///////////
	// Dates //
	///////////

	// 15-Oct-2004
	var d1 = Date.parse("10/15/2004");

	// 15-Oct-2004
	var d1 = Date.parse("15-Oct-2004");

	// 15-Oct-2004
	var d1 = Date.parse("2004.10.15");

	//Fri Oct 15, 2004
	var d1 = Date.parse("Fri Oct 15, 2004");

	///////////
	// Times //
	///////////

	// Today at 10 PM.
	var d1 = Date.parse("10 PM");

	// Today at 10:30 PM.
	var d1 = Date.parse("10:30 P.M.");

	// Today at 6 AM.
	var d1 = Date.parse("06am");

	/////////////////////
	// Dates and Times //
	/////////////////////

	// 8-July-2004 @ 10:30 PM
	var d1 = Date.parse("July 8th, 2004, 10:30 PM");

	// 1-July-2004 @ 10:30 PM
	var d1 = Date.parse("2004-07-01T22:30:00");

	////////////////////
	// Relative Dates //
	////////////////////

	// Returns today's date. The string "today" is culture specific.
	var d1 = Date.parse("today");

	// Returns yesterday's date. The string "yesterday" is culture specific.
	var d1 = Date.parse("yesterday");

	// Returns the date of the next thursday.
	var d1 = Date.parse("Next thursday");

	// Returns the date of the most previous monday.
	var d1 = Date.parse("last monday");

	// Returns today's day + one year.
	var d1 = Date.parse("next year");

	///////////////
	// Date Math //
	///////////////

	// Today + 2 days
	var d1 = Date.parse("t+2");

	// Today + 2 days
	var d1 = Date.parse("today + 2 days");

	// Today + 3 months
	var d1 = Date.parse("t+3m");

	// Today - 1 year
	var d1 = Date.parse("today - 1 year");

	// Today - 1 year
	var d1 = Date.parse("t-1y"); 


	/////////////////////////////
	// Partial Dates and Times //
	/////////////////////////////

	// July 15th of this year.
	var d1 = Date.parse("July 15");

	// 15th day of current day and year.
	var d1 = Date.parse("15");

	// July 1st of current year at 10pm.
	var d1 = Date.parse("7/1 10pm");
	
* * @param {String} The string value to convert into a Date object [Required] * @return {Date} A Date object or null if the string cannot be converted into a Date. */ var parseUtils = { removeOrds: function (s) { ords = s.match(/\b(\d+)(?:st|nd|rd|th)\b/); // find ordinal matches s = ((ords && ords.length === 2) ? s.replace(ords[0], ords[1]) : s); return s; }, grammarParser: function (s) { var r = null; try { r = $D.Grammar.start.call({}, s.replace(/^\s*(\S*(\s+\S+)*)\s*$/, "$1")); } catch (e) { return null; } return ((r[1].length === 0) ? r[0] : null); }, nativeFallback: function(s) { var t; try { // ok we haven't parsed it, last ditch attempt with the built-in parser. t = Date._parse(s); return (t || t === 0) ? new Date(t) : null; } catch (e) { return null; } } }; function parse (s) { var d; if (!s) { return null; } if (s instanceof Date) { return s.clone(); } if (s.length >= 4 && s.charAt(0) !== "0" && s.charAt(0) !== "+"&& s.charAt(0) !== "-") { // ie: 2004 will pass, 0800 won't. // Start with specific formats d = $D.Parsing.ISO.parse(s) || $D.Parsing.Numeric.parse(s); } if (d instanceof Date && !isNaN(d.getTime())) { return d; } else { // find ordinal dates (1st, 3rd, 8th, etc and remove them as they cause parsing issues) s = $D.Parsing.Normalizer.parse(parseUtils.removeOrds(s)); d = parseUtils.grammarParser(s); if (d !== null) { return d; } else { return parseUtils.nativeFallback(s); } } } if (!$D._parse) { $D._parse = $D.parse; } $D.parse = parse; Date.getParseFunction = function (fx) { var fns = Date.Grammar.allformats(fx); return function (s) { var r = null; for (var i = 0; i < fns.length; i++) { try { r = fns[i].call({}, s); } catch (e) { continue; } if (r[1].length === 0) { return r[0]; } } return null; }; }; /** * Converts the specified string value into its JavaScript Date equivalent using the specified format {String} or formats {Array} and the CultureInfo specific format information. * The format of the string value must match one of the supplied formats exactly. * * Example

	// 15-Oct-2004
	var d1 = Date.parseExact("10/15/2004", "M/d/yyyy");

	// 15-Oct-2004
	var d1 = Date.parse("15-Oct-2004", "M-ddd-yyyy");

	// 15-Oct-2004
	var d1 = Date.parse("2004.10.15", "yyyy.MM.dd");

	// Multiple formats
	var d1 = Date.parseExact("10/15/2004", ["M/d/yyyy", "MMMM d, yyyy"]);
	
* * @param {String} The string value to convert into a Date object [Required]. * @param {Object} The expected format {String} or an array of expected formats {Array} of the date string [Required]. * @return {Date} A Date object or null if the string cannot be converted into a Date. */ $D.parseExact = function (s, fx) { return $D.getParseFunction(fx)(s); }; }()); (function () { var $D = Date, $P = $D.prototype, // $C = $D.CultureInfo, // not used atm p = function (s, l) { if (!l) { l = 2; } return ("000" + s).slice(l * -1); }; /** * Converts a PHP format string to Java/.NET format string. * A PHP format string can be used with ._format or .format. * A Java/.NET format string can be used with .toString(). * The .parseExact function will only accept a Java/.NET format string * * Example * var f1 = "%m/%d/%y" * var f2 = Date.normalizeFormat(f1); // "MM/dd/yy" * * new Date().format(f1); // "04/13/08" * new Date()._format(f1); // "04/13/08" * new Date().toString(f2); // "04/13/08" * * var date = Date.parseExact("04/13/08", f2); // Sun Apr 13 2008 * * @param {String} A PHP format string consisting of one or more format spcifiers. * @return {String} The PHP format converted to a Java/.NET format string. */ var normalizerSubstitutions = { "d" : "dd", "%d": "dd", "D" : "ddd", "%a": "ddd", "j" : "dddd", "l" : "dddd", "%A": "dddd", "S" : "S", "F" : "MMMM", "%B": "MMMM", "m" : "MM", "%m": "MM", "M" : "MMM", "%b": "MMM", "%h": "MMM", "n" : "M", "Y" : "yyyy", "%Y": "yyyy", "y" : "yy", "%y": "yy", "g" : "h", "%I": "h", "G" : "H", "h" : "hh", "H" : "HH", "%H": "HH", "i" : "mm", "%M": "mm", "s" : "ss", "%S": "ss", "%r": "hh:mm tt", "%R": "H:mm", "%T": "H:mm:ss", "%X": "t", "%x": "d", "%e": "d", "%D": "MM/dd/yy", "%n": "\\n", "%t": "\\t", "e" : "z", "T" : "z", "%z": "z", "%Z": "z", "Z" : "ZZ", "N" : "u", "w" : "u", "%w": "u", "W" : "W", "%V": "W" }; var normalizer = { substitutes: function (m) { return normalizerSubstitutions[m]; }, interpreted: function (m, x) { var y; switch (m) { case "%u": return x.getDay() + 1; case "z": return x.getOrdinalNumber(); case "%j": return p(x.getOrdinalNumber(), 3); case "%U": var d1 = x.clone().set({month: 0, day: 1}).addDays(-1).moveToDayOfWeek(0), d2 = x.clone().addDays(1).moveToDayOfWeek(0, -1); return (d2 < d1) ? "00" : p((d2.getOrdinalNumber() - d1.getOrdinalNumber()) / 7 + 1); case "%W": return p(x.getWeek()); case "t": return $D.getDaysInMonth(x.getFullYear(), x.getMonth()); case "o": case "%G": return x.setWeek(x.getISOWeek()).toString("yyyy"); case "%g": return x._format("%G").slice(-2); case "a": case "%p": return t("tt").toLowerCase(); case "A": return t("tt").toUpperCase(); case "u": return p(x.getMilliseconds(), 3); case "I": return (x.isDaylightSavingTime()) ? 1 : 0; case "O": return x.getUTCOffset(); case "P": y = x.getUTCOffset(); return y.substring(0, y.length - 2) + ":" + y.substring(y.length - 2); case "B": var now = new Date(); return Math.floor(((now.getHours() * 3600) + (now.getMinutes() * 60) + now.getSeconds() + (now.getTimezoneOffset() + 60) * 60) / 86.4); case "c": return x.toISOString().replace(/\"/g, ""); case "U": return $D.strtotime("now"); case "%c": return t("d") + " " + t("t"); case "%C": return Math.floor(x.getFullYear() / 100 + 1); } }, shouldOverrideDefaults: function (m) { switch (m) { case "%e": return true; default: return false; } }, parse: function (m, context) { var formatString, c = context || new Date(); formatString = normalizer.substitutes(m); if (formatString) { return formatString; } formatString = normalizer.interpreted(m, c); if (formatString) { return formatString; } else { return m; } } }; $D.normalizeFormat = function (format, context) { return format.replace(/(%|\\)?.|%%/g, function(t){ return normalizer.parse(t, context); }); }; /** * Format a local Unix timestamp according to locale settings * * Example: * Date.strftime("%m/%d/%y", new Date()); // "04/13/08" * Date.strftime("c", "2008-04-13T17:52:03Z"); // "04/13/08" * * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @param {Number|String} The number representing the number of seconds that have elapsed since January 1, 1970 (local time). * @return {String} A string representation of the current Date object. */ $D.strftime = function (format, time) { var d = Date.parse(time); return d._format(format); }; /** * Parse any textual datetime description into a Unix timestamp. * A Unix timestamp is the number of seconds that have elapsed since January 1, 1970 (midnight UTC/GMT). * * Example: * Date.strtotime("04/13/08"); // 1208044800 * Date.strtotime("1970-01-01T00:00:00Z"); // 0 * * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @param {Object} A string or date object. * @return {String} A string representation of the current Date object. */ $D.strtotime = function (time) { var d = $D.parse(time); return Math.round($D.UTC(d.getUTCFullYear(), d.getUTCMonth(), d.getUTCDate(), d.getUTCHours(), d.getUTCMinutes(), d.getUTCSeconds(), d.getUTCMilliseconds()) / 1000); }; /** * Converts the value of the current Date object to its equivalent string representation using a PHP/Unix style of date format specifiers. * Format Specifiers * Format Description Example * ------ --------------------------------------------------------------------------- ----------------------- * %a abbreviated weekday name according to the current localed "Mon" through "Sun" * %A full weekday name according to the current localed "Sunday" through "Saturday" * %b abbreviated month name according to the current localed "Jan" through "Dec" * %B full month name according to the current locale "January" through "December" * %c preferred date and time representation for the current locale "4/13/2008 12:33 PM" * %C century number (the year divided by 100 and truncated to an integer) "00" to "99" * %d day of the month as a decimal number "01" to "31" * %D same as %m/%d/%y "04/13/08" * %e day of the month as a decimal number, a single digit is preceded by a space "1" to "31" * %g like %G, but without the century "08" * %G The 4-digit year corresponding to the ISO week number (see %V). "2008" * This has the same format and value as %Y, except that if the ISO week number * belongs to the previous or next year, that year is used instead. * %h same as %b "Jan" through "Dec" * %H hour as a decimal number using a 24-hour clock. "00" to "23" * %I hour as a decimal number using a 12-hour clock. "01" to "12" * %j day of the year as a decimal number. "001" to "366" * %m month as a decimal number. "01" to "12" * %M minute as a decimal number. "00" to "59" * %n newline character "\n" * %p either "am" or "pm" according to the given time value, or the "am" or "pm" * corresponding strings for the current locale. * %r time in a.m. and p.m. notation "8:44 PM" * %R time in 24 hour notation "20:44" * %S second as a decimal number "00" to "59" * %t tab character "\t" * %T current time, equal to %H:%M:%S "12:49:11" * %u weekday as a decimal number ["1", "7"], with "1" representing Monday "1" to "7" * %U week number of the current year as a decimal number, starting with the "0" to ("52" or "53") * first Sunday as the first day of the first week * %V The ISO 8601:1988 week number of the current year as a decimal number, "00" to ("52" or "53") * range 01 to 53, where week 1 is the first week that has at least 4 days * in the current year, and with Monday as the first day of the week. * (Use %G or %g for the year component that corresponds to the week number * for the specified timestamp.) * %W week number of the current year as a decimal number, starting with the "00" to ("52" or "53") * first Monday as the first day of the first week * %w day of the week as a decimal, Sunday being "0" "0" to "6" * %x preferred date representation for the current locale without the time "4/13/2008" * %X preferred time representation for the current locale without the date "12:53:05" * %y year as a decimal number without a century "00" "99" * %Y year as a decimal number including the century "2008" * %Z time zone or name or abbreviation "UTC", "EST", "PST" * %z same as %Z * %% a literal "%" characters "%" * d Day of the month, 2 digits with leading zeros "01" to "31" * D A textual representation of a day, three letters "Mon" through "Sun" * j Day of the month without leading zeros "1" to "31" * l A full textual representation of the day of the week (lowercase "L") "Sunday" through "Saturday" * N ISO-8601 numeric representation of the day of the week (added in PHP 5.1.0) "1" (for Monday) through "7" (for Sunday) * S English ordinal suffix for the day of the month, 2 characters "st", "nd", "rd" or "th". Works well with j * w Numeric representation of the day of the week "0" (for Sunday) through "6" (for Saturday) * z The day of the year (starting from "0") "0" through "365" * W ISO-8601 week number of year, weeks starting on Monday "00" to ("52" or "53") * F A full textual representation of a month, such as January or March "January" through "December" * m Numeric representation of a month, with leading zeros "01" through "12" * M A short textual representation of a month, three letters "Jan" through "Dec" * n Numeric representation of a month, without leading zeros "1" through "12" * t Number of days in the given month "28" through "31" * L Whether it's a leap year "1" if it is a leap year, "0" otherwise * o ISO-8601 year number. This has the same value as Y, except that if the "2008" * ISO week number (W) belongs to the previous or next year, that year * is used instead. * Y A full numeric representation of a year, 4 digits "2008" * y A two digit representation of a year "08" * a Lowercase Ante meridiem and Post meridiem "am" or "pm" * A Uppercase Ante meridiem and Post meridiem "AM" or "PM" * B Swatch Internet time "000" through "999" * g 12-hour format of an hour without leading zeros "1" through "12" * G 24-hour format of an hour without leading zeros "0" through "23" * h 12-hour format of an hour with leading zeros "01" through "12" * H 24-hour format of an hour with leading zeros "00" through "23" * i Minutes with leading zeros "00" to "59" * s Seconds, with leading zeros "00" through "59" * u Milliseconds "54321" * e Timezone identifier "UTC", "EST", "PST" * I Whether or not the date is in daylight saving time (uppercase i) "1" if Daylight Saving Time, "0" otherwise * O Difference to Greenwich time (GMT) in hours "+0200", "-0600" * P Difference to Greenwich time (GMT) with colon between hours and minutes "+02:00", "-06:00" * T Timezone abbreviation "UTC", "EST", "PST" * Z Timezone offset in seconds. The offset for timezones west of UTC is "-43200" through "50400" * always negative, and for those east of UTC is always positive. * c ISO 8601 date "2004-02-12T15:19:21+00:00" * r RFC 2822 formatted date "Thu, 21 Dec 2000 16:01:07 +0200" * U Seconds since the Unix Epoch (January 1 1970 00:00:00 GMT) "0" * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @return {String} A string representation of the current Date object. */ var formatReplace = function (context) { return function (m) { var formatString, override = false; if (m.charAt(0) === "\\" || m.substring(0, 2) === "%%") { return m.replace("\\", "").replace("%%", "%"); } override = normalizer.shouldOverrideDefaults(m); formatString = $D.normalizeFormat(m, context); if (formatString) { return context.toString(formatString, override); } }; }; $P._format = function (format) { var formatter = formatReplace(this); if (!format) { return this._toString(); } else { return format.replace(/(%|\\)?.|%%/g, formatter); } }; if (!$P.format) { $P.format = $P._format; } }()); (function () { "use strict"; var gFn = function (attr) { return function () { return this[attr]; }; }; var sFn = function (attr) { return function (val) { this[attr] = val; return this; }; }; var attrs = ["years", "months", "days", "hours", "minutes", "seconds", "milliseconds"]; var addSetFuncs = function (context, attrs) { for (var i = 0; i < attrs.length ; i++) { var $a = attrs[i], $b = $a.slice(0, 1).toUpperCase() + $a.slice(1); context.prototype[$a] = 0; context.prototype["get" + $b] = gFn($a); context.prototype["set" + $b] = sFn($a); } }; /** * new TimeSpan(milliseconds); * new TimeSpan(days, hours, minutes, seconds); * new TimeSpan(days, hours, minutes, seconds, milliseconds); */ var TimeSpan = function (days, hours, minutes, seconds, milliseconds) { if (arguments.length === 1 && typeof days === "number") { var orient = (days < 0) ? -1 : +1; var millsLeft = Math.abs(days); this.setDays(Math.floor(millsLeft / 86400000) * orient); millsLeft = millsLeft % 86400000; this.setHours(Math.floor(millsLeft / 3600000) * orient); millsLeft = millsLeft % 3600000; this.setMinutes(Math.floor(millsLeft / 60000) * orient); millsLeft = millsLeft % 60000; this.setSeconds(Math.floor(millsLeft / 1000) * orient); millsLeft = millsLeft % 1000; this.setMilliseconds(millsLeft * orient); } else { this.set(days, hours, minutes, seconds, milliseconds); } this.getTotalMilliseconds = function () { return (this.getDays() * 86400000) + (this.getHours() * 3600000) + (this.getMinutes() * 60000) + (this.getSeconds() * 1000); }; this.compareTo = function (time) { var t1 = new Date(1970, 1, 1, this.getHours(), this.getMinutes(), this.getSeconds()), t2; if (time === null) { t2 = new Date(1970, 1, 1, 0, 0, 0); } else { t2 = new Date(1970, 1, 1, time.getHours(), time.getMinutes(), time.getSeconds()); } return (t1 < t2) ? -1 : (t1 > t2) ? 1 : 0; }; this.equals = function (time) { return (this.compareTo(time) === 0); }; this.add = function (time) { return (time === null) ? this : this.addSeconds(time.getTotalMilliseconds() / 1000); }; this.subtract = function (time) { return (time === null) ? this : this.addSeconds(-time.getTotalMilliseconds() / 1000); }; this.addDays = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 86400000)); }; this.addHours = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 3600000)); }; this.addMinutes = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 60000)); }; this.addSeconds = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 1000)); }; this.addMilliseconds = function (n) { return new TimeSpan(this.getTotalMilliseconds() + n); }; this.get12HourHour = function () { return (this.getHours() > 12) ? this.getHours() - 12 : (this.getHours() === 0) ? 12 : this.getHours(); }; this.getDesignator = function () { return (this.getHours() < 12) ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator; }; this.toString = function (format) { this._toString = function () { if (this.getDays() !== null && this.getDays() > 0) { return this.getDays() + "." + this.getHours() + ":" + this.p(this.getMinutes()) + ":" + this.p(this.getSeconds()); } else { return this.getHours() + ":" + this.p(this.getMinutes()) + ":" + this.p(this.getSeconds()); } }; this.p = function (s) { return (s.toString().length < 2) ? "0" + s : s; }; var me = this; return format ? format.replace(/dd?|HH?|hh?|mm?|ss?|tt?/g, function (format) { switch (format) { case "d": return me.getDays(); case "dd": return me.p(me.getDays()); case "H": return me.getHours(); case "HH": return me.p(me.getHours()); case "h": return me.get12HourHour(); case "hh": return me.p(me.get12HourHour()); case "m": return me.getMinutes(); case "mm": return me.p(me.getMinutes()); case "s": return me.getSeconds(); case "ss": return me.p(me.getSeconds()); case "t": return ((me.getHours() < 12) ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator).substring(0, 1); case "tt": return (me.getHours() < 12) ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator; } } ) : this._toString(); }; return this; }; addSetFuncs(TimeSpan, attrs.slice(2)); TimeSpan.prototype.set = function (days, hours, minutes, seconds, milliseconds){ this.setDays(days || this.getDays()); this.setHours(hours || this.getHours()); this.setMinutes(minutes || this.getMinutes()); this.setSeconds(seconds || this.getSeconds()); this.setMilliseconds(milliseconds || this.getMilliseconds()); }; /** * Gets the time of day for this date instances. * @return {TimeSpan} TimeSpan */ Date.prototype.getTimeOfDay = function () { return new TimeSpan(0, this.getHours(), this.getMinutes(), this.getSeconds(), this.getMilliseconds()); }; Date.TimeSpan = TimeSpan; if (typeof window !== "undefined" ) { // keeping API compatible for v1.x window.TimeSpan = TimeSpan; } }()); (function () { "use strict"; var attrs = ["years", "months", "days", "hours", "minutes", "seconds", "milliseconds"]; var gFn = function (attr) { return function () { return this[attr]; }; }; var sFn = function (attr) { return function (val) { this[attr] = val; return this; }; }; var addSetFuncs = function (context, attrs) { for (var i = 0; i < attrs.length ; i++) { var $a = attrs[i], $b = $a.slice(0, 1).toUpperCase() + $a.slice(1); context.prototype[$a] = 0; context.prototype["get" + $b] = gFn($a); context.prototype["set" + $b] = sFn($a); } }; var setMonthsAndYears = function (orient, d1, d2, context) { function inc() { d1.addMonths(-orient); context.months++; if (context.months === 12) { context.years++; context.months = 0; } } if (orient === +1) { while (d1 > d2) { inc(); } } else { while (d1 < d2) { inc(); } } context.months--; context.months *= orient; context.years *= orient; }; var adjustForDST = function(orient, startDate, endDate) { var hasDSTMismatch = (false === (startDate.isDaylightSavingTime() === endDate.isDaylightSavingTime())); if (hasDSTMismatch && orient === 1) { startDate.addHours(-1); } else if (hasDSTMismatch) { startDate.addHours(1); } }; /** * TimePeriod(startDate, endDate); * TimePeriod(years, months, days, hours, minutes, seconds, milliseconds); */ var TimePeriod = function (years, months, days, hours, minutes, seconds, milliseconds) { if (arguments.length === 7) { this.set(years, months, days, hours, minutes, seconds, milliseconds); } else if (arguments.length === 2 && arguments[0] instanceof Date && arguments[1] instanceof Date) { var startDate = arguments[0].clone(); var endDate = arguments[1].clone(); var orient = (startDate > endDate) ? +1 : -1; this.dates = { start: arguments[0].clone(), end: arguments[1].clone() }; setMonthsAndYears(orient, startDate, endDate, this); adjustForDST(orient, startDate, endDate); // // TODO - adjust for DST var diff = endDate - startDate; if (diff !== 0) { var ts = new TimeSpan(diff); this.set(this.years, this.months, ts.getDays(), ts.getHours(), ts.getMinutes(), ts.getSeconds(), ts.getMilliseconds()); } } return this; }; // create all the set functions. addSetFuncs(TimePeriod, attrs); TimePeriod.prototype.set = function (years, months, days, hours, minutes, seconds, milliseconds){ this.setYears(years || this.getYears()); this.setMonths(months || this.getMonths()); this.setDays(days || this.getDays()); this.setHours(hours || this.getHours()); this.setMinutes(minutes || this.getMinutes()); this.setSeconds(seconds || this.getSeconds()); this.setMilliseconds(milliseconds || this.getMilliseconds()); }; Date.TimePeriod = TimePeriod; if (typeof window !== "undefined") { // keeping API compatible for v1.x window.TimePeriod = TimePeriod; } }()); ================================================ FILE: build/date-tn-ZA.js ================================================ /** * @overview datejs * @version 1.0.0-rc3 * @author Gregory Wild-Smith * @copyright 2015 Gregory Wild-Smith * @license MIT * @homepage https://github.com/abritinthebay/datejs */ /* * DateJS Culture String File * Country Code: tn-ZA * Name: Tswana (South Africa) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["tn-ZA"] = { "name": "tn-ZA", "englishName": "Tswana (South Africa)", "nativeName": "Setswana (Aforika Borwa)", "Sunday": "Latshipi", "Monday": "Mosupologo", "Tuesday": "Labobedi", "Wednesday": "Laboraro", "Thursday": "Labone", "Friday": "Labotlhano", "Saturday": "Lamatlhatso", "Sun": "Sun", "Mon": "Mon", "Tue": "Tue", "Wed": "Wed", "Thu": "Thu", "Fri": "Fri", "Sat": "Sat", "Su": "Sun", "Mo": "Mon", "Tu": "Tue", "We": "Wed", "Th": "Thu", "Fr": "Fri", "Sa": "Sat", "S_Sun_Initial": "S", "M_Mon_Initial": "M", "T_Tue_Initial": "T", "W_Wed_Initial": "W", "T_Thu_Initial": "T", "F_Fri_Initial": "F", "S_Sat_Initial": "S", "January": "Ferikgong", "February": "Tlhakole", "March": "Mopitloe", "April": "Moranang", "May": "Motsheganong", "June": "Seetebosigo", "July": "Phukwi", "August": "Phatwe", "September": "Lwetse", "October": "Diphalane", "November": "Ngwanatsele", "December": "Sedimothole", "Jan_Abbr": "Jan", "Feb_Abbr": "Feb", "Mar_Abbr": "Mar", "Apr_Abbr": "Apr", "May_Abbr": "May", "Jun_Abbr": "Jun", "Jul_Abbr": "Jul", "Aug_Abbr": "Aug", "Sep_Abbr": "Sep", "Oct_Abbr": "Oct", "Nov_Abbr": "Nov", "Dec_Abbr": "Dec", "AM": "AM", "PM": "PM", "firstDayOfWeek": 0, "twoDigitYearMax": 2029, "mdy": "ymd", "M/d/yyyy": "yyyy/MM/dd", "dddd, MMMM dd, yyyy": "dd MMMM yyyy", "h:mm tt": "hh:mm:ss tt", "h:mm:ss tt": "hh:mm:ss tt", "dddd, MMMM dd, yyyy h:mm:ss tt": "dd MMMM yyyy hh:mm:ss tt", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "MMMM dd", "MMMM, yyyy": "MMMM yyyy", "/jan(uary)?/": "ferikgong", "/feb(ruary)?/": "tlhakole", "/mar(ch)?/": "mopitloe", "/apr(il)?/": "moranang", "/may/": "motsheganong", "/jun(e)?/": "seetebosigo", "/jul(y)?/": "phukwi", "/aug(ust)?/": "phatwe", "/sep(t(ember)?)?/": "lwetse", "/oct(ober)?/": "diphalane", "/nov(ember)?/": "ngwanatsele", "/dec(ember)?/": "sedimothole", "/^su(n(day)?)?/": "^latshipi", "/^mo(n(day)?)?/": "^mosupologo", "/^tu(e(s(day)?)?)?/": "^labobedi", "/^we(d(nesday)?)?/": "^laboraro", "/^th(u(r(s(day)?)?)?)?/": "^labone", "/^fr(i(day)?)?/": "^labotlhano", "/^sa(t(urday)?)?/": "^lamatlhatso", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "tn-ZA"; /** * @overview datejs * @version 1.0.0-rc3 * @author Gregory Wild-Smith * @copyright 2015 Gregory Wild-Smith * @license MIT * @homepage https://github.com/abritinthebay/datejs */(function () { var $D = Date; var lang = Date.CultureStrings ? Date.CultureStrings.lang : null; var loggedKeys = {}; // for debug purposes. var getText = { getFromKey: function (key, countryCode) { var output; if (Date.CultureStrings && Date.CultureStrings[countryCode] && Date.CultureStrings[countryCode][key]) { output = Date.CultureStrings[countryCode][key]; } else { output = getText.buildFromDefault(key); } if (key.charAt(0) === "/") { // Assume it's a regex output = getText.buildFromRegex(key, countryCode); } return output; }, getFromObjectValues: function (obj, countryCode) { var key, output = {}; for(key in obj) { if (obj.hasOwnProperty(key)) { output[key] = getText.getFromKey(obj[key], countryCode); } } return output; }, getFromObjectKeys: function (obj, countryCode) { var key, output = {}; for(key in obj) { if (obj.hasOwnProperty(key)) { output[getText.getFromKey(key, countryCode)] = obj[key]; } } return output; }, getFromArray: function (arr, countryCode) { var output = []; for (var i=0; i < arr.length; i++){ if (i in arr) { output[i] = getText.getFromKey(arr[i], countryCode); } } return output; }, buildFromDefault: function (key) { var output, length, split, last; switch(key) { case "name": output = "en-US"; break; case "englishName": output = "English (United States)"; break; case "nativeName": output = "English (United States)"; break; case "twoDigitYearMax": output = 2049; break; case "firstDayOfWeek": output = 0; break; default: output = key; split = key.split("_"); length = split.length; if (length > 1 && key.charAt(0) !== "/") { // if the key isn't a regex and it has a split. last = split[(length - 1)].toLowerCase(); if (last === "initial" || last === "abbr") { output = split[0]; } } break; } return output; }, buildFromRegex: function (key, countryCode) { var output; if (Date.CultureStrings && Date.CultureStrings[countryCode] && Date.CultureStrings[countryCode][key]) { output = new RegExp(Date.CultureStrings[countryCode][key], "i"); } else { output = new RegExp(key.replace(new RegExp("/", "g"),""), "i"); } return output; } }; var shallowMerge = function (obj1, obj2) { for (var attrname in obj2) { if (obj2.hasOwnProperty(attrname)) { obj1[attrname] = obj2[attrname]; } } }; var __ = function (key, language) { var countryCode = (language) ? language : lang; loggedKeys[key] = key; if (typeof key === "object") { if (key instanceof Array) { return getText.getFromArray(key, countryCode); } else { return getText.getFromObjectKeys(key, countryCode); } } else { return getText.getFromKey(key, countryCode); } }; var loadI18nScript = function (code) { // paatterned after jQuery's getScript. var url = Date.Config.i18n + code + ".js"; var head = document.getElementsByTagName("head")[0] || document.documentElement; var script = document.createElement("script"); script.src = url; var completed = false; var events = { done: function (){} // placeholder function }; // Attach handlers for all browsers script.onload = script.onreadystatechange = function() { if ( !completed && (!this.readyState || this.readyState === "loaded" || this.readyState === "complete") ) { events.done(); head.removeChild(script); } }; setTimeout(function() { head.insertBefore(script, head.firstChild); }, 0); // allows return to execute first return { done: function (cb) { events.done = function() { if (cb) { setTimeout(cb,0); } }; } }; }; var buildInfo = { buildFromMethodHash: function (obj) { var key; for(key in obj) { if (obj.hasOwnProperty(key)) { obj[key] = buildInfo[obj[key]](); } } return obj; }, timeZoneDST: function () { var DST = { "CHADT": "+1345", "NZDT": "+1300", "AEDT": "+1100", "ACDT": "+1030", "AZST": "+0500", "IRDT": "+0430", "EEST": "+0300", "CEST": "+0200", "BST": "+0100", "PMDT": "-0200", "ADT": "-0300", "NDT": "-0230", "EDT": "-0400", "CDT": "-0500", "MDT": "-0600", "PDT": "-0700", "AKDT": "-0800", "HADT": "-0900" }; return __(DST); }, timeZoneStandard: function () { var standard = { "LINT": "+1400", "TOT": "+1300", "CHAST": "+1245", "NZST": "+1200", "NFT": "+1130", "SBT": "+1100", "AEST": "+1000", "ACST": "+0930", "JST": "+0900", "CWST": "+0845", "CT": "+0800", "ICT": "+0700", "MMT": "+0630", "BST": "+0600", "NPT": "+0545", "IST": "+0530", "PKT": "+0500", "AFT": "+0430", "MSK": "+0400", "IRST": "+0330", "FET": "+0300", "EET": "+0200", "CET": "+0100", "GMT": "+0000", "UTC": "+0000", "CVT": "-0100", "GST": "-0200", "BRT": "-0300", "NST": "-0330", "AST": "-0400", "EST": "-0500", "CST": "-0600", "MST": "-0700", "PST": "-0800", "AKST": "-0900", "MIT": "-0930", "HST": "-1000", "SST": "-1100", "BIT": "-1200" }; return __(standard); }, timeZones: function (data) { var zone; data.timezones = []; for (zone in data.abbreviatedTimeZoneStandard) { if (data.abbreviatedTimeZoneStandard.hasOwnProperty(zone)) { data.timezones.push({ name: zone, offset: data.abbreviatedTimeZoneStandard[zone]}); } } for (zone in data.abbreviatedTimeZoneDST) { if (data.abbreviatedTimeZoneDST.hasOwnProperty(zone)) { data.timezones.push({ name: zone, offset: data.abbreviatedTimeZoneDST[zone], dst: true}); } } return data.timezones; }, days: function () { return __(["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"]); }, dayAbbr: function () { return __(["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"]); }, dayShortNames: function () { return __(["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"]); }, dayFirstLetters: function () { return __(["S_Sun_Initial", "M_Mon_Initial", "T_Tues_Initial", "W_Wed_Initial", "T_Thu_Initial", "F_Fri_Initial", "S_Sat_Initial"]); }, months: function () { return __(["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"]); }, monthAbbr: function () { return __(["Jan_Abbr", "Feb_Abbr", "Mar_Abbr", "Apr_Abbr", "May_Abbr", "Jun_Abbr", "Jul_Abbr", "Aug_Abbr", "Sep_Abbr", "Oct_Abbr", "Nov_Abbr", "Dec_Abbr"]); }, formatPatterns: function () { return getText.getFromObjectValues({ shortDate: "M/d/yyyy", longDate: "dddd, MMMM dd, yyyy", shortTime: "h:mm tt", longTime: "h:mm:ss tt", fullDateTime: "dddd, MMMM dd, yyyy h:mm:ss tt", sortableDateTime: "yyyy-MM-ddTHH:mm:ss", universalSortableDateTime: "yyyy-MM-dd HH:mm:ssZ", rfc1123: "ddd, dd MMM yyyy HH:mm:ss", monthDay: "MMMM dd", yearMonth: "MMMM, yyyy" }, Date.i18n.currentLanguage()); }, regex: function () { return getText.getFromObjectValues({ inTheMorning: "/( in the )(morn(ing)?)\\b/", thisMorning: "/(this )(morn(ing)?)\\b/", amThisMorning: "/(\b\\d(am)? )(this )(morn(ing)?)/", inTheEvening: "/( in the )(even(ing)?)\\b/", thisEvening: "/(this )(even(ing)?)\\b/", pmThisEvening: "/(\b\\d(pm)? )(this )(even(ing)?)/", jan: "/jan(uary)?/", feb: "/feb(ruary)?/", mar: "/mar(ch)?/", apr: "/apr(il)?/", may: "/may/", jun: "/jun(e)?/", jul: "/jul(y)?/", aug: "/aug(ust)?/", sep: "/sep(t(ember)?)?/", oct: "/oct(ober)?/", nov: "/nov(ember)?/", dec: "/dec(ember)?/", sun: "/^su(n(day)?)?/", mon: "/^mo(n(day)?)?/", tue: "/^tu(e(s(day)?)?)?/", wed: "/^we(d(nesday)?)?/", thu: "/^th(u(r(s(day)?)?)?)?/", fri: "/fr(i(day)?)?/", sat: "/^sa(t(urday)?)?/", future: "/^next/", past: "/^last|past|prev(ious)?/", add: "/^(\\+|aft(er)?|from|hence)/", subtract: "/^(\\-|bef(ore)?|ago)/", yesterday: "/^yes(terday)?/", today: "/^t(od(ay)?)?/", tomorrow: "/^tom(orrow)?/", now: "/^n(ow)?/", millisecond: "/^ms|milli(second)?s?/", second: "/^sec(ond)?s?/", minute: "/^mn|min(ute)?s?/", hour: "/^h(our)?s?/", week: "/^w(eek)?s?/", month: "/^m(onth)?s?/", day: "/^d(ay)?s?/", year: "/^y(ear)?s?/", shortMeridian: "/^(a|p)/", longMeridian: "/^(a\\.?m?\\.?|p\\.?m?\\.?)/", timezone: "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/", ordinalSuffix: "/^\\s*(st|nd|rd|th)/", timeContext: "/^\\s*(\\:|a(?!u|p)|p)/" }, Date.i18n.currentLanguage()); } }; var CultureInfo = function () { var info = getText.getFromObjectValues({ name: "name", englishName: "englishName", nativeName: "nativeName", amDesignator: "AM", pmDesignator: "PM", firstDayOfWeek: "firstDayOfWeek", twoDigitYearMax: "twoDigitYearMax", dateElementOrder: "mdy" }, Date.i18n.currentLanguage()); var constructedInfo = buildInfo.buildFromMethodHash({ dayNames: "days", abbreviatedDayNames: "dayAbbr", shortestDayNames: "dayShortNames", firstLetterDayNames: "dayFirstLetters", monthNames: "months", abbreviatedMonthNames: "monthAbbr", formatPatterns: "formatPatterns", regexPatterns: "regex", abbreviatedTimeZoneDST: "timeZoneDST", abbreviatedTimeZoneStandard: "timeZoneStandard" }); shallowMerge(info, constructedInfo); buildInfo.timeZones(info); return info; }; $D.i18n = { __: function (key, lang) { return __(key, lang); }, currentLanguage: function () { return lang || "en-US"; }, setLanguage: function (code, force, cb) { var async = false; if (force || code === "en-US" || (!!Date.CultureStrings && !!Date.CultureStrings[code])) { lang = code; Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings.lang = code; Date.CultureInfo = new CultureInfo(); } else { if (!(!!Date.CultureStrings && !!Date.CultureStrings[code])) { if (typeof exports !== "undefined" && this.exports !== exports) { // we're in a Node enviroment, load it using require try { require("../i18n/" + code + ".js"); lang = code; Date.CultureStrings.lang = code; Date.CultureInfo = new CultureInfo(); } catch (e) { // var str = "The language for '" + code + "' could not be loaded by Node. It likely does not exist."; throw new Error("The DateJS IETF language tag '" + code + "' could not be loaded by Node. It likely does not exist."); } } else if (Date.Config && Date.Config.i18n) { // we know the location of the files, so lets load them async = true; loadI18nScript(code).done(function(){ lang = code; Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings.lang = code; Date.CultureInfo = new CultureInfo(); $D.Parsing.Normalizer.buildReplaceData(); // because this is async if ($D.Grammar) { $D.Grammar.buildGrammarFormats(); // so we can parse those strings... } if (cb) { setTimeout(cb,0); } }); } else { Date.console.error("The DateJS IETF language tag '" + code + "' is not available and has not been loaded."); return false; } } } $D.Parsing.Normalizer.buildReplaceData(); // rebuild normalizer strings if ($D.Grammar) { $D.Grammar.buildGrammarFormats(); // so we can parse those strings... } if (!async && cb) { setTimeout(cb,0); } }, getLoggedKeys: function () { return loggedKeys; }, updateCultureInfo: function () { Date.CultureInfo = new CultureInfo(); } }; $D.i18n.updateCultureInfo(); // run automatically }()); (function () { var $D = Date, $P = $D.prototype, p = function (s, l) { if (!l) { l = 2; } return ("000" + s).slice(l * -1); }; if (typeof window !== "undefined" && typeof window.console !== "undefined" && typeof window.console.log !== "undefined") { $D.console = console; // used only to raise non-critical errors if available } else { // set mock so we don't give errors. $D.console = { log: function(){}, error: function(){} }; } $D.Config = $D.Config || {}; $D.initOverloads = function() { /** * Overload of Date.now. Allows an alternate call for Date.now where it returns the * current Date as an object rather than just milliseconds since the Unix Epoch. * * Also provides an implementation of now() for browsers (IE<9) that don't have it. * * Backwards compatible so with work with either: * Date.now() [returns ms] * or * Date.now(true) [returns Date] */ if (!$D.now) { $D._now = function now() { return new Date().getTime(); }; } else if (!$D._now) { $D._now = $D.now; } $D.now = function (returnObj) { if (returnObj) { return $D.present(); } else { return $D._now(); } }; if ( !$P.toISOString ) { $P.toISOString = function() { return this.getUTCFullYear() + "-" + p(this.getUTCMonth() + 1) + "-" + p(this.getUTCDate()) + "T" + p(this.getUTCHours()) + ":" + p(this.getUTCMinutes()) + ":" + p(this.getUTCSeconds()) + "." + String( (this.getUTCMilliseconds()/1000).toFixed(3)).slice(2, 5) + "Z"; }; } // private if ( $P._toString === undefined ){ $P._toString = $P.toString; } }; $D.initOverloads(); /** * Gets a date that is set to the current date. The time is set to the start of the day (00:00 or 12:00 AM). * @return {Date} The current date. */ $D.today = function () { return new Date().clearTime(); }; /** * Gets a date that is set to the current date and time (same as new Date, but chainable) * @return {Date} The current date. */ $D.present = function () { return new Date(); }; /** * Compares the first date to the second date and returns an number indication of their relative values. * @param {Date} First Date object to compare [Required]. * @param {Date} Second Date object to compare to [Required]. * @return {Number} -1 = date1 is lessthan date2. 0 = values are equal. 1 = date1 is greaterthan date2. */ $D.compare = function (date1, date2) { if (isNaN(date1) || isNaN(date2)) { throw new Error(date1 + " - " + date2); } else if (date1 instanceof Date && date2 instanceof Date) { return (date1 < date2) ? -1 : (date1 > date2) ? 1 : 0; } else { throw new TypeError(date1 + " - " + date2); } }; /** * Compares the first Date object to the second Date object and returns true if they are equal. * @param {Date} First Date object to compare [Required] * @param {Date} Second Date object to compare to [Required] * @return {Boolean} true if dates are equal. false if they are not equal. */ $D.equals = function (date1, date2) { return (date1.compareTo(date2) === 0); }; /** * Gets the language appropriate day name when given the day number(0-6) * eg - 0 == Sunday * @return {String} The day name */ $D.getDayName = function (n) { return Date.CultureInfo.dayNames[n]; }; /** * Gets the day number (0-6) if given a CultureInfo specific string which is a valid dayName, abbreviatedDayName or shortestDayName (two char). * @param {String} The name of the day (eg. "Monday, "Mon", "tuesday", "tue", "We", "we"). * @return {Number} The day number */ $D.getDayNumberFromName = function (name) { var n = Date.CultureInfo.dayNames, m = Date.CultureInfo.abbreviatedDayNames, o = Date.CultureInfo.shortestDayNames, s = name.toLowerCase(); for (var i = 0; i < n.length; i++) { if (n[i].toLowerCase() === s || m[i].toLowerCase() === s || o[i].toLowerCase() === s) { return i; } } return -1; }; /** * Gets the month number (0-11) if given a Culture Info specific string which is a valid monthName or abbreviatedMonthName. * @param {String} The name of the month (eg. "February, "Feb", "october", "oct"). * @return {Number} The day number */ $D.getMonthNumberFromName = function (name) { var n = Date.CultureInfo.monthNames, m = Date.CultureInfo.abbreviatedMonthNames, s = name.toLowerCase(); for (var i = 0; i < n.length; i++) { if (n[i].toLowerCase() === s || m[i].toLowerCase() === s) { return i; } } return -1; }; /** * Gets the language appropriate month name when given the month number(0-11) * eg - 0 == January * @return {String} The month name */ $D.getMonthName = function (n) { return Date.CultureInfo.monthNames[n]; }; /** * Determines if the current date instance is within a LeapYear. * @param {Number} The year. * @return {Boolean} true if date is within a LeapYear, otherwise false. */ $D.isLeapYear = function (year) { return ((year % 4 === 0 && year % 100 !== 0) || year % 400 === 0); }; /** * Gets the number of days in the month, given a year and month value. Automatically corrects for LeapYear. * @param {Number} The year. * @param {Number} The month (0-11). * @return {Number} The number of days in the month. */ $D.getDaysInMonth = function (year, month) { if (!month && $D.validateMonth(year)) { month = year; year = Date.today().getFullYear(); } return [31, ($D.isLeapYear(year) ? 29 : 28), 31, 30, 31, 30, 31, 31, 30, 31, 30, 31][month]; }; $P.getDaysInMonth = function () { return $D.getDaysInMonth(this.getFullYear(), this.getMonth()); }; $D.getTimezoneAbbreviation = function (offset, dst) { var p, n = (dst || false) ? Date.CultureInfo.abbreviatedTimeZoneDST : Date.CultureInfo.abbreviatedTimeZoneStandard; for (p in n) { if (n.hasOwnProperty(p)) { if (n[p] === offset) { return p; } } } return null; }; $D.getTimezoneOffset = function (name, dst) { var i, a =[], z = Date.CultureInfo.timezones; if (!name) { name = (new Date()).getTimezone();} for (i = 0; i < z.length; i++) { if (z[i].name === name.toUpperCase()) { a.push(i); } } if (!z[a[0]]) { return null; } if (a.length === 1 || !dst) { return z[a[0]].offset; } else { for (i=0; i < a.length; i++) { if (z[a[i]].dst) { return z[a[i]].offset; } } } }; $D.getQuarter = function (d) { d = d || new Date(); // If no date supplied, use today var q = [1,2,3,4]; return q[Math.floor(d.getMonth() / 3)]; // ~~~ is a bitwise op. Faster than Math.floor }; $D.getDaysLeftInQuarter = function (d) { d = d || new Date(); var qEnd = new Date(d); qEnd.setMonth(qEnd.getMonth() + 3 - qEnd.getMonth() % 3, 0); return Math.floor((qEnd - d) / 8.64e7); }; // private var validate = function (n, min, max, name) { name = name ? name : "Object"; if (typeof n === "undefined") { return false; } else if (typeof n !== "number") { throw new TypeError(n + " is not a Number."); } else if (n < min || n > max) { // As failing validation is *not* an exceptional circumstance // lets not throw a RangeError Exception here. // It's semantically correct but it's not sensible. return false; } return true; }; /** * Validates the number is within an acceptable range for milliseconds [0-999]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateMillisecond = function (value) { return validate(value, 0, 999, "millisecond"); }; /** * Validates the number is within an acceptable range for seconds [0-59]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateSecond = function (value) { return validate(value, 0, 59, "second"); }; /** * Validates the number is within an acceptable range for minutes [0-59]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateMinute = function (value) { return validate(value, 0, 59, "minute"); }; /** * Validates the number is within an acceptable range for hours [0-23]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateHour = function (value) { return validate(value, 0, 23, "hour"); }; /** * Validates the number is within an acceptable range for the days in a month [0-MaxDaysInMonth]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateDay = function (value, year, month) { if (year === undefined || year === null || month === undefined || month === null) { return false;} return validate(value, 1, $D.getDaysInMonth(year, month), "day"); }; /** * Validates the number is within an acceptable range for months [0-11]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateWeek = function (value) { return validate(value, 0, 53, "week"); }; /** * Validates the number is within an acceptable range for months [0-11]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateMonth = function (value) { return validate(value, 0, 11, "month"); }; /** * Validates the number is within an acceptable range for years. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateYear = function (value) { /** * Per ECMAScript spec the range of times supported by Date objects is * exactly -100,000,000 days to +100,000,000 days measured relative to * midnight at the beginning of 01 January, 1970 UTC. * This gives a range of 8,640,000,000,000,000 milliseconds to either * side of 01 January, 1970 UTC. * * Earliest possible date: Tue, 20 Apr 271,822 B.C. 00:00:00 UTC * Latest possible date: Sat, 13 Sep 275,760 00:00:00 UTC */ return validate(value, -271822, 275760, "year"); }; $D.validateTimezone = function(value) { var timezones = {"ACDT":1,"ACST":1,"ACT":1,"ADT":1,"AEDT":1,"AEST":1,"AFT":1,"AKDT":1,"AKST":1,"AMST":1,"AMT":1,"ART":1,"AST":1,"AWDT":1,"AWST":1,"AZOST":1,"AZT":1,"BDT":1,"BIOT":1,"BIT":1,"BOT":1,"BRT":1,"BST":1,"BTT":1,"CAT":1,"CCT":1,"CDT":1,"CEDT":1,"CEST":1,"CET":1,"CHADT":1,"CHAST":1,"CHOT":1,"ChST":1,"CHUT":1,"CIST":1,"CIT":1,"CKT":1,"CLST":1,"CLT":1,"COST":1,"COT":1,"CST":1,"CT":1,"CVT":1,"CWST":1,"CXT":1,"DAVT":1,"DDUT":1,"DFT":1,"EASST":1,"EAST":1,"EAT":1,"ECT":1,"EDT":1,"EEDT":1,"EEST":1,"EET":1,"EGST":1,"EGT":1,"EIT":1,"EST":1,"FET":1,"FJT":1,"FKST":1,"FKT":1,"FNT":1,"GALT":1,"GAMT":1,"GET":1,"GFT":1,"GILT":1,"GIT":1,"GMT":1,"GST":1,"GYT":1,"HADT":1,"HAEC":1,"HAST":1,"HKT":1,"HMT":1,"HOVT":1,"HST":1,"ICT":1,"IDT":1,"IOT":1,"IRDT":1,"IRKT":1,"IRST":1,"IST":1,"JST":1,"KGT":1,"KOST":1,"KRAT":1,"KST":1,"LHST":1,"LINT":1,"MAGT":1,"MART":1,"MAWT":1,"MDT":1,"MET":1,"MEST":1,"MHT":1,"MIST":1,"MIT":1,"MMT":1,"MSK":1,"MST":1,"MUT":1,"MVT":1,"MYT":1,"NCT":1,"NDT":1,"NFT":1,"NPT":1,"NST":1,"NT":1,"NUT":1,"NZDT":1,"NZST":1,"OMST":1,"ORAT":1,"PDT":1,"PET":1,"PETT":1,"PGT":1,"PHOT":1,"PHT":1,"PKT":1,"PMDT":1,"PMST":1,"PONT":1,"PST":1,"PYST":1,"PYT":1,"RET":1,"ROTT":1,"SAKT":1,"SAMT":1,"SAST":1,"SBT":1,"SCT":1,"SGT":1,"SLST":1,"SRT":1,"SST":1,"SYOT":1,"TAHT":1,"THA":1,"TFT":1,"TJT":1,"TKT":1,"TLT":1,"TMT":1,"TOT":1,"TVT":1,"UCT":1,"ULAT":1,"UTC":1,"UYST":1,"UYT":1,"UZT":1,"VET":1,"VLAT":1,"VOLT":1,"VOST":1,"VUT":1,"WAKT":1,"WAST":1,"WAT":1,"WEDT":1,"WEST":1,"WET":1,"WST":1,"YAKT":1,"YEKT":1,"Z":1}; return (timezones[value] === 1); }; $D.validateTimezoneOffset= function(value) { // timezones go from +14hrs to -12hrs, the +X hours are negative offsets. return (value > -841 && value < 721); }; }()); (function () { var $D = Date, $P = $D.prototype, p = function (s, l) { if (!l) { l = 2; } return ("000" + s).slice(l * -1); }; var validateConfigObject = function (obj) { var result = {}, self = this, prop, testFunc; testFunc = function (prop, func, value) { if (prop === "day") { var month = (obj.month !== undefined) ? obj.month : self.getMonth(); var year = (obj.year !== undefined) ? obj.year : self.getFullYear(); return $D[func](value, year, month); } else { return $D[func](value); } }; for (prop in obj) { if (Object.prototype.hasOwnProperty.call(obj, prop)) { var func = "validate" + prop.charAt(0).toUpperCase() + prop.slice(1); if ($D[func] && obj[prop] !== null && testFunc(prop, func, obj[prop])) { result[prop] = obj[prop]; } } } return result; }; /** * Resets the time of this Date object to 12:00 AM (00:00), which is the start of the day. * @param {Boolean} .clone() this date instance before clearing Time * @return {Date} this */ $P.clearTime = function () { this.setHours(0); this.setMinutes(0); this.setSeconds(0); this.setMilliseconds(0); return this; }; /** * Resets the time of this Date object to the current time ('now'). * @return {Date} this */ $P.setTimeToNow = function () { var n = new Date(); this.setHours(n.getHours()); this.setMinutes(n.getMinutes()); this.setSeconds(n.getSeconds()); this.setMilliseconds(n.getMilliseconds()); return this; }; /** * Returns a new Date object that is an exact date and time copy of the original instance. * @return {Date} A new Date instance */ $P.clone = function () { return new Date(this.getTime()); }; /** * Compares this instance to a Date object and returns an number indication of their relative values. * @param {Date} Date object to compare [Required] * @return {Number} -1 = this is lessthan date. 0 = values are equal. 1 = this is greaterthan date. */ $P.compareTo = function (date) { return Date.compare(this, date); }; /** * Compares this instance to another Date object and returns true if they are equal. * @param {Date} Date object to compare. If no date to compare, new Date() [now] is used. * @return {Boolean} true if dates are equal. false if they are not equal. */ $P.equals = function (date) { return Date.equals(this, (date !== undefined ? date : new Date())); }; /** * Determines if this instance is between a range of two dates or equal to either the start or end dates. * @param {Date} Start of range [Required] * @param {Date} End of range [Required] * @return {Boolean} true is this is between or equal to the start and end dates, else false */ $P.between = function (start, end) { return this.getTime() >= start.getTime() && this.getTime() <= end.getTime(); }; /** * Determines if this date occurs after the date to compare to. * @param {Date} Date object to compare. If no date to compare, new Date() ("now") is used. * @return {Boolean} true if this date instance is greater than the date to compare to (or "now"), otherwise false. */ $P.isAfter = function (date) { return this.compareTo(date || new Date()) === 1; }; /** * Determines if this date occurs before the date to compare to. * @param {Date} Date object to compare. If no date to compare, new Date() ("now") is used. * @return {Boolean} true if this date instance is less than the date to compare to (or "now"). */ $P.isBefore = function (date) { return (this.compareTo(date || new Date()) === -1); }; /** * Determines if the current Date instance occurs today. * @return {Boolean} true if this date instance is 'today', otherwise false. */ /** * Determines if the current Date instance occurs on the same Date as the supplied 'date'. * If no 'date' to compare to is provided, the current Date instance is compared to 'today'. * @param {date} Date object to compare. If no date to compare, the current Date ("now") is used. * @return {Boolean} true if this Date instance occurs on the same Day as the supplied 'date'. */ $P.isToday = $P.isSameDay = function (date) { return this.clone().clearTime().equals((date || new Date()).clone().clearTime()); }; /** * Adds the specified number of milliseconds to this instance. * @param {Number} The number of milliseconds to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addMilliseconds = function (value) { if (!value) { return this; } this.setTime(this.getTime() + value * 1); return this; }; /** * Adds the specified number of seconds to this instance. * @param {Number} The number of seconds to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addSeconds = function (value) { if (!value) { return this; } return this.addMilliseconds(value * 1000); }; /** * Adds the specified number of seconds to this instance. * @param {Number} The number of seconds to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addMinutes = function (value) { if (!value) { return this; } return this.addMilliseconds(value * 60000); // 60*1000 }; /** * Adds the specified number of hours to this instance. * @param {Number} The number of hours to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addHours = function (value) { if (!value) { return this; } return this.addMilliseconds(value * 3600000); // 60*60*1000 }; /** * Adds the specified number of days to this instance. * @param {Number} The number of days to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addDays = function (value) { if (!value) { return this; } this.setDate(this.getDate() + value * 1); return this; }; /** * Adds the specified number of weekdays (ie - not sat or sun) to this instance. * @param {Number} The number of days to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addWeekdays = function (value) { if (!value) { return this; } var day = this.getDay(); var weeks = (Math.ceil(Math.abs(value)/7)); if (day === 0 || day === 6) { if (value > 0) { this.next().monday(); this.addDays(-1); day = this.getDay(); } } if (value < 0) { while (value < 0) { this.addDays(-1); day = this.getDay(); if (day !== 0 && day !== 6) { value++; } } return this; } else if (value > 5 || (6-day) <= value) { value = value + (weeks * 2); } return this.addDays(value); }; /** * Adds the specified number of weeks to this instance. * @param {Number} The number of weeks to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addWeeks = function (value) { if (!value) { return this; } return this.addDays(value * 7); }; /** * Adds the specified number of months to this instance. * @param {Number} The number of months to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addMonths = function (value) { if (!value) { return this; } var n = this.getDate(); this.setDate(1); this.setMonth(this.getMonth() + value * 1); this.setDate(Math.min(n, $D.getDaysInMonth(this.getFullYear(), this.getMonth()))); return this; }; $P.addQuarters = function (value) { if (!value) { return this; } // note this will take you to the same point in the quarter as you are now. // i.e. - if you are 15 days into the quarter you'll be 15 days into the resulting one. // bonus: this allows adding fractional quarters return this.addMonths(value * 3); }; /** * Adds the specified number of years to this instance. * @param {Number} The number of years to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addYears = function (value) { if (!value) { return this; } return this.addMonths(value * 12); }; /** * Adds (or subtracts) to the value of the years, months, weeks, days, hours, minutes, seconds, milliseconds of the date instance using given configuration object. Positive and Negative values allowed. * Example

	Date.today().add( { days: 1, months: 1 } )

	new Date().add( { years: -1 } )
	
* @param {Object} Configuration object containing attributes (months, days, etc.) * @return {Date} this */ $P.add = function (config) { if (typeof config === "number") { this._orient = config; return this; } var x = config; if (x.day) { // If we should be a different date than today (eg: for 'tomorrow -1d', etc). // Should only effect parsing, not direct usage (eg, Finish and FinishExact) if ((x.day - this.getDate()) !== 0) { this.setDate(x.day); } } if (x.milliseconds) { this.addMilliseconds(x.milliseconds); } if (x.seconds) { this.addSeconds(x.seconds); } if (x.minutes) { this.addMinutes(x.minutes); } if (x.hours) { this.addHours(x.hours); } if (x.weeks) { this.addWeeks(x.weeks); } if (x.months) { this.addMonths(x.months); } if (x.years) { this.addYears(x.years); } if (x.days) { this.addDays(x.days); } return this; }; /** * Get the week number. Week one (1) is the week which contains the first Thursday of the year. Monday is considered the first day of the week. * The .getWeek() function does NOT convert the date to UTC. The local datetime is used. * Please use .getISOWeek() to get the week of the UTC converted date. * @return {Number} 1 to 53 */ $P.getWeek = function (utc) { // Create a copy of this date object var self, target = new Date(this.valueOf()); if (utc) { target.addMinutes(target.getTimezoneOffset()); self = target.clone(); } else { self = this; } // ISO week date weeks start on monday // so correct the day number var dayNr = (self.getDay() + 6) % 7; // ISO 8601 states that week 1 is the week // with the first thursday of that year. // Set the target date to the thursday in the target week target.setDate(target.getDate() - dayNr + 3); // Store the millisecond value of the target date var firstThursday = target.valueOf(); // Set the target to the first thursday of the year // First set the target to january first target.setMonth(0, 1); // Not a thursday? Correct the date to the next thursday if (target.getDay() !== 4) { target.setMonth(0, 1 + ((4 - target.getDay()) + 7) % 7); } // The weeknumber is the number of weeks between the // first thursday of the year and the thursday in the target week return 1 + Math.ceil((firstThursday - target) / 604800000); // 604800000 = 7 * 24 * 3600 * 1000 }; /** * Get the ISO 8601 week number. Week one ("01") is the week which contains the first Thursday of the year. Monday is considered the first day of the week. * The .getISOWeek() function does convert the date to it's UTC value. Please use .getWeek() to get the week of the local date. * @return {String} "01" to "53" */ $P.getISOWeek = function () { return p(this.getWeek(true)); }; /** * Moves the date to Monday of the week set. Week one (1) is the week which contains the first Thursday of the year. * @param {Number} A Number (1 to 53) that represents the week of the year. * @return {Date} this */ $P.setWeek = function (n) { if ((n - this.getWeek()) === 0) { if (this.getDay() !== 1) { return this.moveToDayOfWeek(1, (this.getDay() > 1 ? -1 : 1)); } else { return this; } } else { return this.moveToDayOfWeek(1, (this.getDay() > 1 ? -1 : 1)).addWeeks(n - this.getWeek()); } }; $P.setQuarter = function (qtr) { var month = Math.abs(((qtr-1) * 3) + 1); return this.setMonth(month, 1); }; $P.getQuarter = function () { return Date.getQuarter(this); }; $P.getDaysLeftInQuarter = function () { return Date.getDaysLeftInQuarter(this); }; /** * Moves the date to the next n'th occurrence of the dayOfWeek starting from the beginning of the month. The number (-1) is a magic number and will return the last occurrence of the dayOfWeek in the month. * @param {Number} The dayOfWeek to move to * @param {Number} The n'th occurrence to move to. Use (-1) to return the last occurrence in the month * @return {Date} this */ $P.moveToNthOccurrence = function (dayOfWeek, occurrence) { if (dayOfWeek === "Weekday") { if (occurrence > 0) { this.moveToFirstDayOfMonth(); if (this.is().weekday()) { occurrence -= 1; } } else if (occurrence < 0) { this.moveToLastDayOfMonth(); if (this.is().weekday()) { occurrence += 1; } } else { return this; } return this.addWeekdays(occurrence); } var shift = 0; if (occurrence > 0) { shift = occurrence - 1; } else if (occurrence === -1) { this.moveToLastDayOfMonth(); if (this.getDay() !== dayOfWeek) { this.moveToDayOfWeek(dayOfWeek, -1); } return this; } return this.moveToFirstDayOfMonth().addDays(-1).moveToDayOfWeek(dayOfWeek, +1).addWeeks(shift); }; var moveToN = function (getFunc, addFunc, nVal) { return function (value, orient) { var diff = (value - this[getFunc]() + nVal * (orient || +1)) % nVal; return this[addFunc]((diff === 0) ? diff += nVal * (orient || +1) : diff); }; }; /** * Move to the next or last dayOfWeek based on the orient value. * @param {Number} The dayOfWeek to move to * @param {Number} Forward (+1) or Back (-1). Defaults to +1. [Optional] * @return {Date} this */ $P.moveToDayOfWeek = moveToN("getDay", "addDays", 7); /** * Move to the next or last month based on the orient value. * @param {Number} The month to move to. 0 = January, 11 = December * @param {Number} Forward (+1) or Back (-1). Defaults to +1. [Optional] * @return {Date} this */ $P.moveToMonth = moveToN("getMonth", "addMonths", 12); /** * Get the Ordinate of the current day ("th", "st", "rd"). * @return {String} */ $P.getOrdinate = function () { var num = this.getDate(); return ord(num); }; /** * Get the Ordinal day (numeric day number) of the year, adjusted for leap year. * @return {Number} 1 through 365 (366 in leap years) */ $P.getOrdinalNumber = function () { return Math.ceil((this.clone().clearTime() - new Date(this.getFullYear(), 0, 1)) / 86400000) + 1; }; /** * Get the time zone abbreviation of the current date. * @return {String} The abbreviated time zone name (e.g. "EST") */ $P.getTimezone = function () { return $D.getTimezoneAbbreviation(this.getUTCOffset(), this.isDaylightSavingTime()); }; $P.setTimezoneOffset = function (offset) { var here = this.getTimezoneOffset(), there = Number(offset) * -6 / 10; return (there || there === 0) ? this.addMinutes(there - here) : this; }; $P.setTimezone = function (offset) { return this.setTimezoneOffset($D.getTimezoneOffset(offset)); }; /** * Indicates whether Daylight Saving Time is observed in the current time zone. * @return {Boolean} true|false */ $P.hasDaylightSavingTime = function () { return (Date.today().set({month: 0, day: 1}).getTimezoneOffset() !== Date.today().set({month: 6, day: 1}).getTimezoneOffset()); }; /** * Indicates whether this Date instance is within the Daylight Saving Time range for the current time zone. * @return {Boolean} true|false */ $P.isDaylightSavingTime = function () { return Date.today().set({month: 0, day: 1}).getTimezoneOffset() !== this.getTimezoneOffset(); }; /** * Get the offset from UTC of the current date. * @return {String} The 4-character offset string prefixed with + or - (e.g. "-0500") */ $P.getUTCOffset = function (offset) { var n = (offset || this.getTimezoneOffset()) * -10 / 6, r; if (n < 0) { r = (n - 10000).toString(); return r.charAt(0) + r.substr(2); } else { r = (n + 10000).toString(); return "+" + r.substr(1); } }; /** * Returns the number of milliseconds between this date and date. * @param {Date} Defaults to now * @return {Number} The diff in milliseconds */ $P.getElapsed = function (date) { return (date || new Date()) - this; }; /** * Set the value of year, month, day, hour, minute, second, millisecond of date instance using given configuration object. * Example

	Date.today().set( { day: 20, month: 1 } )

	new Date().set( { millisecond: 0 } )
	
* * @param {Object} Configuration object containing attributes (month, day, etc.) * @return {Date} this */ $P.set = function (config) { config = validateConfigObject.call(this, config); var key; for (key in config) { if (Object.prototype.hasOwnProperty.call(config, key)) { var name = key.charAt(0).toUpperCase() + key.slice(1); var addFunc, getFunc; if (key !== "week" && key !== "month" && key !== "timezone" && key !== "timezoneOffset") { name += "s"; } addFunc = "add" + name; getFunc = "get" + name; if (key === "month") { addFunc = addFunc + "s"; } else if (key === "year"){ getFunc = "getFullYear"; } if (key !== "day" && key !== "timezone" && key !== "timezoneOffset" && key !== "week" && key !== "hour") { this[addFunc](config[key] - this[getFunc]()); } else if ( key === "timezone"|| key === "timezoneOffset" || key === "week" || key === "hour") { this["set"+name](config[key]); } } } // day has to go last because you can't validate the day without first knowing the month if (config.day) { this.addDays(config.day - this.getDate()); } return this; }; /** * Moves the date to the first day of the month. * @return {Date} this */ $P.moveToFirstDayOfMonth = function () { return this.set({ day: 1 }); }; /** * Moves the date to the last day of the month. * @return {Date} this */ $P.moveToLastDayOfMonth = function () { return this.set({ day: $D.getDaysInMonth(this.getFullYear(), this.getMonth())}); }; /** * Converts the value of the current Date object to its equivalent string representation. * Format Specifiers * CUSTOM DATE AND TIME FORMAT STRINGS * Format Description Example * ------ --------------------------------------------------------------------------- ----------------------- * s The seconds of the minute between 0-59. "0" to "59" * ss The seconds of the minute with leading zero if required. "00" to "59" * * m The minute of the hour between 0-59. "0" or "59" * mm The minute of the hour with leading zero if required. "00" or "59" * * h The hour of the day between 1-12. "1" to "12" * hh The hour of the day with leading zero if required. "01" to "12" * * H The hour of the day between 0-23. "0" to "23" * HH The hour of the day with leading zero if required. "00" to "23" * * d The day of the month between 1 and 31. "1" to "31" * dd The day of the month with leading zero if required. "01" to "31" * ddd Abbreviated day name. Date.CultureInfo.abbreviatedDayNames. "Mon" to "Sun" * dddd The full day name. Date.CultureInfo.dayNames. "Monday" to "Sunday" * * M The month of the year between 1-12. "1" to "12" * MM The month of the year with leading zero if required. "01" to "12" * MMM Abbreviated month name. Date.CultureInfo.abbreviatedMonthNames. "Jan" to "Dec" * MMMM The full month name. Date.CultureInfo.monthNames. "January" to "December" * * yy The year as a two-digit number. "99" or "08" * yyyy The full four digit year. "1999" or "2008" * * t Displays the first character of the A.M./P.M. designator. "A" or "P" * Date.CultureInfo.amDesignator or Date.CultureInfo.pmDesignator * tt Displays the A.M./P.M. designator. "AM" or "PM" * Date.CultureInfo.amDesignator or Date.CultureInfo.pmDesignator * * S The ordinal suffix ("st, "nd", "rd" or "th") of the current day. "st, "nd", "rd" or "th" * * STANDARD DATE AND TIME FORMAT STRINGS * Format Description Example *------ --------------------------------------------------------------------------- ----------------------- * d The CultureInfo shortDate Format Pattern "M/d/yyyy" * D The CultureInfo longDate Format Pattern "dddd, MMMM dd, yyyy" * F The CultureInfo fullDateTime Format Pattern "dddd, MMMM dd, yyyy h:mm:ss tt" * m The CultureInfo monthDay Format Pattern "MMMM dd" * r The CultureInfo rfc1123 Format Pattern "ddd, dd MMM yyyy HH:mm:ss GMT" * s The CultureInfo sortableDateTime Format Pattern "yyyy-MM-ddTHH:mm:ss" * t The CultureInfo shortTime Format Pattern "h:mm tt" * T The CultureInfo longTime Format Pattern "h:mm:ss tt" * u The CultureInfo universalSortableDateTime Format Pattern "yyyy-MM-dd HH:mm:ssZ" * y The CultureInfo yearMonth Format Pattern "MMMM, yyyy" * * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @return {String} A string representation of the current Date object. */ var ord = function (n) { switch (n * 1) { case 1: case 21: case 31: return "st"; case 2: case 22: return "nd"; case 3: case 23: return "rd"; default: return "th"; } }; var parseStandardFormats = function (format) { var y, c = Date.CultureInfo.formatPatterns; switch (format) { case "d": return this.toString(c.shortDate); case "D": return this.toString(c.longDate); case "F": return this.toString(c.fullDateTime); case "m": return this.toString(c.monthDay); case "r": case "R": y = this.clone().addMinutes(this.getTimezoneOffset()); return y.toString(c.rfc1123) + " GMT"; case "s": return this.toString(c.sortableDateTime); case "t": return this.toString(c.shortTime); case "T": return this.toString(c.longTime); case "u": y = this.clone().addMinutes(this.getTimezoneOffset()); return y.toString(c.universalSortableDateTime); case "y": return this.toString(c.yearMonth); default: return false; } }; var parseFormatStringsClosure = function (context) { return function (m) { if (m.charAt(0) === "\\") { return m.replace("\\", ""); } switch (m) { case "hh": return p(context.getHours() < 13 ? (context.getHours() === 0 ? 12 : context.getHours()) : (context.getHours() - 12)); case "h": return context.getHours() < 13 ? (context.getHours() === 0 ? 12 : context.getHours()) : (context.getHours() - 12); case "HH": return p(context.getHours()); case "H": return context.getHours(); case "mm": return p(context.getMinutes()); case "m": return context.getMinutes(); case "ss": return p(context.getSeconds()); case "s": return context.getSeconds(); case "yyyy": return p(context.getFullYear(), 4); case "yy": return p(context.getFullYear()); case "y": return context.getFullYear(); case "E": case "dddd": return Date.CultureInfo.dayNames[context.getDay()]; case "ddd": return Date.CultureInfo.abbreviatedDayNames[context.getDay()]; case "dd": return p(context.getDate()); case "d": return context.getDate(); case "MMMM": return Date.CultureInfo.monthNames[context.getMonth()]; case "MMM": return Date.CultureInfo.abbreviatedMonthNames[context.getMonth()]; case "MM": return p((context.getMonth() + 1)); case "M": return context.getMonth() + 1; case "t": return context.getHours() < 12 ? Date.CultureInfo.amDesignator.substring(0, 1) : Date.CultureInfo.pmDesignator.substring(0, 1); case "tt": return context.getHours() < 12 ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator; case "S": return ord(context.getDate()); case "W": return context.getWeek(); case "WW": return context.getISOWeek(); case "Q": return "Q" + context.getQuarter(); case "q": return String(context.getQuarter()); case "z": return context.getTimezone(); case "Z": case "X": return Date.getTimezoneOffset(context.getTimezone()); case "ZZ": // Timezone offset in seconds return context.getTimezoneOffset() * -60; case "u": return context.getDay(); case "L": return ($D.isLeapYear(context.getFullYear())) ? 1 : 0; case "B": // Swatch Internet Time (.beats) return "@"+((context.getUTCSeconds() + (context.getUTCMinutes()*60) + ((context.getUTCHours()+1)*3600))/86.4); default: return m; } }; }; $P.toString = function (format, ignoreStandards) { // Standard Date and Time Format Strings. Formats pulled from CultureInfo file and // may vary by culture. if (!ignoreStandards && format && format.length === 1) { output = parseStandardFormats.call(this, format); if (output) { return output; } } var parseFormatStrings = parseFormatStringsClosure(this); return format ? format.replace(/((\\)?(dd?d?d?|MM?M?M?|yy?y?y?|hh?|HH?|mm?|ss?|tt?|S|q|Q|WW?W?W?)(?![^\[]*\]))/g, parseFormatStrings).replace(/\[|\]/g, "") : this._toString(); }; }()); /************************************************************* * SugarPak - Domain Specific Language - Syntactical Sugar * *************************************************************/ (function () { var $D = Date, $P = $D.prototype, $N = Number.prototype; // private $P._orient = +1; // private $P._nth = null; // private $P._is = false; // private $P._same = false; // private $P._isSecond = false; // private $N._dateElement = "days"; /** * Moves the date to the next instance of a date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.today().next().friday();
	Date.today().next().fri();
	Date.today().next().march();
	Date.today().next().mar();
	Date.today().next().week();
	
* * @return {Date} date */ $P.next = function () { this._move = true; this._orient = +1; return this; }; /** * Creates a new Date (Date.today()) and moves the date to the next instance of the date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.next().friday();
	Date.next().fri();
	Date.next().march();
	Date.next().mar();
	Date.next().week();
	
* * @return {Date} date */ $D.next = function () { return $D.today().next(); }; /** * Moves the date to the previous instance of a date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.today().last().friday();
	Date.today().last().fri();
	Date.today().last().march();
	Date.today().last().mar();
	Date.today().last().week();
	
* * @return {Date} date */ $P.last = $P.prev = $P.previous = function () { this._move = true; this._orient = -1; return this; }; /** * Creates a new Date (Date.today()) and moves the date to the previous instance of the date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.last().friday();
	Date.last().fri();
	Date.previous().march();
	Date.prev().mar();
	Date.last().week();
	
* * @return {Date} date */ $D.last = $D.prev = $D.previous = function () { return $D.today().last(); }; /** * Performs a equality check when followed by either a month name, day name or .weekday() function. * Example

	Date.today().is().friday(); // true|false
	Date.today().is().fri();
	Date.today().is().march();
	Date.today().is().mar();
	
* * @return {Boolean} true|false */ $P.is = function () { this._is = true; return this; }; /** * Determines if two date objects occur on/in exactly the same instance of the subsequent date part function. * The function .same() must be followed by a date part function (example: .day(), .month(), .year(), etc). * * An optional Date can be passed in the date part function. If now date is passed as a parameter, 'Now' is used. * * The following example demonstrates how to determine if two dates fall on the exact same day. * * Example

	var d1 = Date.today(); // today at 00:00
	var d2 = new Date();   // exactly now.

	// Do they occur on the same day?
	d1.same().day(d2); // true
	
	// Do they occur on the same hour?
	d1.same().hour(d2); // false, unless d2 hour is '00' (midnight).
	
	// What if it's the same day, but one year apart?
	var nextYear = Date.today().add(1).year();

	d1.same().day(nextYear); // false, because the dates must occur on the exact same day. 
	
* * Scenario: Determine if a given date occurs during some week period 2 months from now. * * Example

	var future = Date.today().add(2).months();
	return someDate.same().week(future); // true|false;
	
* * @return {Boolean} true|false */ $P.same = function () { this._same = true; this._isSecond = false; return this; }; /** * Determines if the current date/time occurs during Today. Must be preceded by the .is() function. * Example

	someDate.is().today();    // true|false
	new Date().is().today();  // true
	Date.today().is().today();// true
	Date.today().add(-1).day().is().today(); // false
	
* * @return {Boolean} true|false */ $P.today = function () { return this.same().day(); }; /** * Determines if the current date is a weekday. This function must be preceded by the .is() function. * Example

	Date.today().is().weekday(); // true|false
	
* * @return {Boolean} true|false */ $P.weekday = function () { if (this._nth) { return df("Weekday").call(this); } if (this._move) { return this.addWeekdays(this._orient); } if (this._is) { this._is = false; return (!this.is().sat() && !this.is().sun()); } return false; }; /** * Determines if the current date is on the weekend. This function must be preceded by the .is() function. * Example

	Date.today().is().weekend(); // true|false
	
* * @return {Boolean} true|false */ $P.weekend = function () { if (this._is) { this._is = false; return (this.is().sat() || this.is().sun()); } return false; }; /** * Sets the Time of the current Date instance. A string "6:15 pm" or config object {hour:18, minute:15} are accepted. * Example

	// Set time to 6:15pm with a String
	Date.today().at("6:15pm");

	// Set time to 6:15pm with a config object
	Date.today().at({hour:18, minute:15});
	
* * @return {Date} date */ $P.at = function (time) { return (typeof time === "string") ? $D.parse(this.toString("d") + " " + time) : this.set(time); }; /** * Creates a new Date() and adds this (Number) to the date based on the preceding date element function (eg. second|minute|hour|day|month|year). * Example

	// Undeclared Numbers must be wrapped with parentheses. Requirment of JavaScript.
	(3).days().fromNow();
	(6).months().fromNow();

	// Declared Number variables do not require parentheses. 
	var n = 6;
	n.months().fromNow();
	
* * @return {Date} A new Date instance */ $N.fromNow = $N.after = function (date) { var c = {}; c[this._dateElement] = this; return ((!date) ? new Date() : date.clone()).add(c); }; /** * Creates a new Date() and subtract this (Number) from the date based on the preceding date element function (eg. second|minute|hour|day|month|year). * Example

	// Undeclared Numbers must be wrapped with parentheses. Requirment of JavaScript.
	(3).days().ago();
	(6).months().ago();

	// Declared Number variables do not require parentheses. 
	var n = 6;
	n.months().ago();
	
* * @return {Date} A new Date instance */ $N.ago = $N.before = function (date) { var c = {}, s = (this._dateElement[this._dateElement.length-1] !== "s") ? this._dateElement + "s" : this._dateElement; c[s] = this * -1; return ((!date) ? new Date() : date.clone()).add(c); }; // Do NOT modify the following string tokens. These tokens are used to build dynamic functions. // All culture-specific strings can be found in the CultureInfo files. var dx = ("sunday monday tuesday wednesday thursday friday saturday").split(/\s/), mx = ("january february march april may june july august september october november december").split(/\s/), px = ("Millisecond Second Minute Hour Day Week Month Year Quarter Weekday").split(/\s/), pxf = ("Milliseconds Seconds Minutes Hours Date Week Month FullYear Quarter").split(/\s/), nth = ("final first second third fourth fifth").split(/\s/), de; /** * Returns an object literal of all the date parts. * Example

	var o = new Date().toObject();
	
	// { year: 2008, month: 4, week: 20, day: 13, hour: 18, minute: 9, second: 32, millisecond: 812 }
	
	// The object properties can be referenced directly from the object.
	
	alert(o.day);  // alerts "13"
	alert(o.year); // alerts "2008"
	
* * @return {Date} An object literal representing the original date object. */ $P.toObject = function () { var o = {}; for (var i = 0; i < px.length; i++) { if (this["get" + pxf[i]]) { o[px[i].toLowerCase()] = this["get" + pxf[i]](); } } return o; }; /** * Returns a date created from an object literal. Ignores the .week property if set in the config. * Example

	var o = new Date().toObject();
	
	return Date.fromObject(o); // will return the same date. 

	var o2 = {month: 1, day: 20, hour: 18}; // birthday party!
	Date.fromObject(o2);
	
* * @return {Date} An object literal representing the original date object. */ $D.fromObject = function(config) { config.week = null; return Date.today().set(config); }; // Create day name functions and abbreviated day name functions (eg. monday(), friday(), fri()). var df = function (n) { return function () { if (this._is) { this._is = false; return this.getDay() === n; } if (this._move) { this._move = null; } if (this._nth !== null) { // If the .second() function was called earlier, remove the _orient // from the date, and then continue. // This is required because 'second' can be used in two different context. // // Example // // Date.today().add(1).second(); // Date.march().second().monday(); // // Things get crazy with the following... // Date.march().add(1).second().second().monday(); // but it works!! // if (this._isSecond) { this.addSeconds(this._orient * -1); } // make sure we reset _isSecond this._isSecond = false; var ntemp = this._nth; this._nth = null; var temp = this.clone().moveToLastDayOfMonth(); this.moveToNthOccurrence(n, ntemp); if (this > temp) { throw new RangeError($D.getDayName(n) + " does not occur " + ntemp + " times in the month of " + $D.getMonthName(temp.getMonth()) + " " + temp.getFullYear() + "."); } return this; } return this.moveToDayOfWeek(n, this._orient); }; }; var sdf = function (n) { return function () { var t = $D.today(), shift = n - t.getDay(); if (n === 0 && Date.CultureInfo.firstDayOfWeek === 1 && t.getDay() !== 0) { shift = shift + 7; } return t.addDays(shift); }; }; // Create month name functions and abbreviated month name functions (eg. january(), march(), mar()). var month_instance_functions = function (n) { return function () { if (this._is) { this._is = false; return this.getMonth() === n; } return this.moveToMonth(n, this._orient); }; }; var month_static_functions = function (n) { return function () { return $D.today().set({ month: n, day: 1 }); }; }; var processTerms = function (names, staticFunc, instanceFunc) { for (var i = 0; i < names.length; i++) { // Create constant static Name variables. $D[names[i].toUpperCase()] = $D[names[i].toUpperCase().substring(0, 3)] = i; // Create Name functions. $D[names[i]] = $D[names[i].substring(0, 3)] = staticFunc(i); // Create Name instance functions. $P[names[i]] = $P[names[i].substring(0, 3)] = instanceFunc(i); } }; processTerms(dx, sdf, df); processTerms(mx, month_static_functions, month_instance_functions); // Create date element functions and plural date element functions used with Date (eg. day(), days(), months()). var ef = function (j) { return function () { // if the .second() function was called earlier, the _orient // has alread been added. Just return this and reset _isSecond. if (this._isSecond) { this._isSecond = false; return this; } if (this._same) { this._same = this._is = false; var o1 = this.toObject(), o2 = (arguments[0] || new Date()).toObject(), v = "", k = j.toLowerCase(); // the substr trick with -1 doesn't work in IE8 or less k = (k[k.length-1] === "s") ? k.substring(0,k.length-1) : k; for (var m = (px.length - 1); m > -1; m--) { v = px[m].toLowerCase(); if (o1[v] !== o2[v]) { return false; } if (k === v) { break; } } return true; } if (j.substring(j.length - 1) !== "s") { j += "s"; } if (this._move) { this._move = null; } return this["add" + j](this._orient); }; }; var nf = function (n) { return function () { this._dateElement = n; return this; }; }; for (var k = 0; k < px.length; k++) { de = px[k].toLowerCase(); if(de !== "weekday") { // Create date element functions and plural date element functions used with Date (eg. day(), days(), months()). $P[de] = $P[de + "s"] = ef(px[k]); // Create date element functions and plural date element functions used with Number (eg. day(), days(), months()). $N[de] = $N[de + "s"] = nf(de + "s"); } } $P._ss = ef("Second"); var nthfn = function (n) { return function (dayOfWeek) { if (this._same) { return this._ss(arguments[0]); } if (dayOfWeek || dayOfWeek === 0) { return this.moveToNthOccurrence(dayOfWeek, n); } this._nth = n; // if the operator is 'second' add the _orient, then deal with it later... if (n === 2 && (dayOfWeek === undefined || dayOfWeek === null)) { this._isSecond = true; return this.addSeconds(this._orient); } return this; }; }; for (var l = 0; l < nth.length; l++) { $P[nth[l]] = (l === 0) ? nthfn(-1) : nthfn(l); } }()); (function () { "use strict"; Date.Parsing = { Exception: function (s) { this.message = "Parse error at '" + s.substring(0, 10) + " ...'"; } }; var $P = Date.Parsing; var dayOffsets = { standard: [0,31,59,90,120,151,181,212,243,273,304,334], leap: [0,31,60,91,121,152,182,213,244,274,305,335] }; $P.isLeapYear = function(year) { return ((year % 4 === 0) && (year % 100 !== 0)) || (year % 400 === 0); }; var utils = { multiReplace : function (str, hash ) { var key; for (key in hash) { if (Object.prototype.hasOwnProperty.call(hash, key)) { var regex; if (typeof hash[key] === "function") { } else { regex = (hash[key] instanceof RegExp) ? hash[key] : new RegExp(hash[key], "g"); } str = str.replace(regex, key); } } return str; }, getDayOfYearFromWeek : function (obj) { var d, jan4, offset; obj.weekDay = (!obj.weekDay && obj.weekDay !== 0) ? 1 : obj.weekDay; d = new Date(obj.year, 0, 4); jan4 = d.getDay() === 0 ? 7 : d.getDay(); // JS is 0 indexed on Sunday. offset = jan4+3; obj.dayOfYear = ((obj.week * 7) + (obj.weekDay === 0 ? 7 : obj.weekDay))-offset; return obj; }, getDayOfYear : function (obj, dayOffset) { if (!obj.dayOfYear) { obj = utils.getDayOfYearFromWeek(obj); } for (var i=0;i <= dayOffset.length;i++) { if (obj.dayOfYear < dayOffset[i] || i === dayOffset.length) { obj.day = obj.day ? obj.day : (obj.dayOfYear - dayOffset[i-1]); break; } else { obj.month = i; } } return obj; }, adjustForTimeZone : function (obj, date) { var offset; if (obj.zone.toUpperCase() === "Z" || (obj.zone_hours === 0 && obj.zone_minutes === 0)) { // it's UTC/GML so work out the current timeszone offset offset = -date.getTimezoneOffset(); } else { offset = (obj.zone_hours*60) + (obj.zone_minutes || 0); if (obj.zone_sign === "+") { offset *= -1; } offset -= date.getTimezoneOffset(); } date.setMinutes(date.getMinutes()+offset); return date; }, setDefaults : function (obj) { obj.year = obj.year || Date.today().getFullYear(); obj.hours = obj.hours || 0; obj.minutes = obj.minutes || 0; obj.seconds = obj.seconds || 0; obj.milliseconds = obj.milliseconds || 0; if (!(!obj.month && (obj.week || obj.dayOfYear))) { // if we have a month, or if we don't but don't have the day calculation data obj.month = obj.month || 0; obj.day = obj.day || 1; } return obj; }, dataNum: function (data, mod, explict, postProcess) { var dataNum = data*1; if (mod) { if (postProcess) { return data ? mod(data)*1 : data; } else { return data ? mod(dataNum) : data; } } else if (!explict){ return data ? dataNum : data; } else { return (data && typeof data !== "undefined") ? dataNum : data; } }, timeDataProcess: function (obj) { var timeObj = {}; for (var x in obj.data) { if (obj.data.hasOwnProperty(x)) { timeObj[x] = obj.ignore[x] ? obj.data[x] : utils.dataNum(obj.data[x], obj.mods[x], obj.explict[x], obj.postProcess[x]); } } if (obj.data.secmins) { obj.data.secmins = obj.data.secmins.replace(",", ".") * 60; if (!timeObj.minutes) { timeObj.minutes = obj.data.secmins; } else if (!timeObj.seconds) { timeObj.seconds = obj.data.secmins; } delete obj.secmins; } return timeObj; }, buildTimeObjectFromData: function (data) { var time = utils.timeDataProcess({ data: { year : data[1], month : data[5], day : data[7], week : data[8], dayOfYear : data[10], hours : data[15], zone_hours : data[23], zone_minutes : data[24], zone : data[21], zone_sign : data[22], weekDay : data[9], minutes: data[16], seconds: data[19], milliseconds: data[20], secmins: data[18] }, mods: { month: function(data) { return data-1; }, weekDay: function (data) { data = Math.abs(data); return (data === 7 ? 0 : data); }, minutes: function (data) { return data.replace(":",""); }, seconds: function (data) { return Math.floor( (data.replace(":","").replace(",","."))*1 ); }, milliseconds: function (data) { return (data.replace(",",".")*1000); } }, postProcess: { minutes: true, seconds: true, milliseconds: true }, explict: { zone_hours: true, zone_minutes: true }, ignore: { zone: true, zone_sign: true, secmins: true } }); return time; }, addToHash: function (hash, keys, data) { keys = keys; data = data; var len = keys.length; for (var i = 0; i < len; i++) { hash[keys[i]] = data[i]; } return hash; }, combineRegex: function (r1, r2) { return new RegExp("(("+r1.source+")\\s("+r2.source+"))"); }, getDateNthString: function(add, last, inc){ if (add) { return Date.today().addDays(inc).toString("d"); } else if (last) { return Date.today().last()[inc]().toString("d"); } }, buildRegexData: function (array) { var arr = []; var len = array.length; for (var i=0; i < len; i++) { if (Object.prototype.toString.call(array[i]) === '[object Array]') { // oldIE compat version of Array.isArray arr.push(this.combineRegex(array[i][0], array[i][1])); } else { arr.push(array[i]); } } return arr; } }; $P.processTimeObject = function (obj) { var date, dayOffset; utils.setDefaults(obj); dayOffset = ($P.isLeapYear(obj.year)) ? dayOffsets.leap : dayOffsets.standard; if (!obj.month && (obj.week || obj.dayOfYear)) { utils.getDayOfYear(obj, dayOffset); } else { obj.dayOfYear = dayOffset[obj.month] + obj.day; } date = new Date(obj.year, obj.month, obj.day, obj.hours, obj.minutes, obj.seconds, obj.milliseconds); if (obj.zone) { utils.adjustForTimeZone(obj, date); // adjust (and calculate) for timezone } return date; }; $P.ISO = { regex : /^([\+-]?\d{4}(?!\d{2}\b))((-?)((0[1-9]|1[0-2])(\3([12]\d|0[1-9]|3[01]))?|W([0-4]\d|5[0-3])(-?[1-7])?|(00[1-9]|0[1-9]\d|[12]\d{2}|3([0-5]\d|6[1-6])))([T\s]((([01]\d|2[0-4])((:?)[0-5]\d)?|24\:?00)([\.,]\d+(?!:))?)?(\17[0-5]\d([\.,]\d+)?)?\s?([zZ]|([\+-])([01]\d|2[0-3]):?([0-5]\d)?)?)?)?$/, parse : function (s) { var time, data = s.match(this.regex); if (!data || !data.length) { return null; } time = utils.buildTimeObjectFromData(data); if (!time.year || (!time.year && (!time.month && !time.day) && (!time.week && !time.dayOfYear)) ) { return null; } return $P.processTimeObject(time); } }; $P.Numeric = { isNumeric: function (e){return!isNaN(parseFloat(e))&&isFinite(e);}, regex: /\b([0-1]?[0-9])([0-3]?[0-9])([0-2]?[0-9]?[0-9][0-9])\b/i, parse: function (s) { var data, i, time = {}, order = Date.CultureInfo.dateElementOrder.split(""); if (!(this.isNumeric(s)) || // if it's non-numeric OR (s[0] === "+" && s[0] === "-")) { // It's an arithmatic string (eg +/-1000) return null; } if (s.length < 5 && s.indexOf(".") < 0 && s.indexOf("/") < 0) { // assume it's just a year. time.year = s; return $P.processTimeObject(time); } data = s.match(this.regex); if (!data || !data.length) { return null; } for (i=0; i < order.length; i++) { switch(order[i]) { case "d": time.day = data[i+1]; break; case "m": time.month = (data[i+1]-1); break; case "y": time.year = data[i+1]; break; } } return $P.processTimeObject(time); } }; $P.Normalizer = { regexData: function () { var $R = Date.CultureInfo.regexPatterns; return utils.buildRegexData([ $R.tomorrow, $R.yesterday, [$R.past, $R.mon], [$R.past, $R.tue], [$R.past, $R.wed], [$R.past, $R.thu], [$R.past, $R.fri], [$R.past, $R.sat], [$R.past, $R.sun] ]); }, basicReplaceHash : function() { var $R = Date.CultureInfo.regexPatterns; return { "January": $R.jan.source, "February": $R.feb, "March": $R.mar, "April": $R.apr, "May": $R.may, "June": $R.jun, "July": $R.jul, "August": $R.aug, "September": $R.sep, "October": $R.oct, "November": $R.nov, "December": $R.dec, "": /\bat\b/gi, " ": /\s{2,}/, "am": $R.inTheMorning, "9am": $R.thisMorning, "pm": $R.inTheEvening, "7pm":$R.thisEvening }; }, keys : function(){ return [ utils.getDateNthString(true, false, 1), // tomorrow utils.getDateNthString(true, false, -1), // yesterday utils.getDateNthString(false, true, "monday"), //last mon utils.getDateNthString(false, true, "tuesday"), //last tues utils.getDateNthString(false, true, "wednesday"), //last wed utils.getDateNthString(false, true, "thursday"), //last thurs utils.getDateNthString(false, true, "friday"), //last fri utils.getDateNthString(false, true, "saturday"), //last sat utils.getDateNthString(false, true, "sunday") //last sun ]; }, buildRegexFunctions: function () { var $R = Date.CultureInfo.regexPatterns; var __ = Date.i18n.__; var tomorrowRE = new RegExp("(\\b\\d\\d?("+__("AM")+"|"+__("PM")+")? )("+$R.tomorrow.source.slice(1)+")", "i"); // adapted tomorrow regex for AM PM relative dates var todayRE = new RegExp($R.today.source + "(?!\\s*([+-]))\\b"); // today, but excludes the math operators (eg "today + 2h") this.replaceFuncs = [ [todayRE, function (full) { return (full.length > 1) ? Date.today().toString("d") : full; }], [tomorrowRE, function(full, m1) { var t = Date.today().addDays(1).toString("d"); return (t + " " + m1); }], [$R.amThisMorning, function(str, am){return am;}], [$R.pmThisEvening, function(str, pm){return pm;}] ]; }, buildReplaceData: function () { this.buildRegexFunctions(); this.replaceHash = utils.addToHash(this.basicReplaceHash(), this.keys(), this.regexData()); }, stringReplaceFuncs: function (s) { for (var i=0; i < this.replaceFuncs.length; i++) { s = s.replace(this.replaceFuncs[i][0], this.replaceFuncs[i][1]); } return s; }, parse: function (s) { s = this.stringReplaceFuncs(s); s = utils.multiReplace(s, this.replaceHash); try { var n = s.split(/([\s\-\.\,\/\x27]+)/); if (n.length === 3 && $P.Numeric.isNumeric(n[0]) && $P.Numeric.isNumeric(n[2]) && (n[2].length >= 4)) { // ok, so we're dealing with x/year. But that's not a full date. // This fixes wonky dateElementOrder parsing when set to dmy order. if (Date.CultureInfo.dateElementOrder[0] === "d") { s = "1/" + n[0] + "/" + n[2]; // set to 1st of month and normalize the seperator } } } catch (e) {} return s; } }; $P.Normalizer.buildReplaceData(); }()); (function () { var $P = Date.Parsing; var _ = $P.Operators = { // // Tokenizers // rtoken: function (r) { // regex token return function (s) { var mx = s.match(r); if (mx) { return ([ mx[0], s.substring(mx[0].length) ]); } else { throw new $P.Exception(s); } }; }, token: function () { // whitespace-eating token return function (s) { return _.rtoken(new RegExp("^\\s*" + s + "\\s*"))(s); }; }, stoken: function (s) { // string token return _.rtoken(new RegExp("^" + s)); }, // Atomic Operators until: function (p) { return function (s) { var qx = [], rx = null; while (s.length) { try { rx = p.call(this, s); } catch (e) { qx.push(rx[0]); s = rx[1]; continue; } break; } return [ qx, s ]; }; }, many: function (p) { return function (s) { var rx = [], r = null; while (s.length) { try { r = p.call(this, s); } catch (e) { return [ rx, s ]; } rx.push(r[0]); s = r[1]; } return [ rx, s ]; }; }, // generator operators -- see below optional: function (p) { return function (s) { var r = null; try { r = p.call(this, s); } catch (e) { return [ null, s ]; } return [ r[0], r[1] ]; }; }, not: function (p) { return function (s) { try { p.call(this, s); } catch (e) { return [null, s]; } throw new $P.Exception(s); }; }, ignore: function (p) { return p ? function (s) { var r = null; r = p.call(this, s); return [null, r[1]]; } : null; }, product: function () { var px = arguments[0], qx = Array.prototype.slice.call(arguments, 1), rx = []; for (var i = 0 ; i < px.length ; i++) { rx.push(_.each(px[i], qx)); } return rx; }, cache: function (rule) { var cache = {}, cache_length = 0, cache_keys = [], CACHE_MAX = Date.Config.CACHE_MAX || 100000, r = null; var cacheCheck = function () { if (cache_length === CACHE_MAX) { // kill several keys, don't want to have to do this all the time... for (var i=0; i < 10; i++) { var key = cache_keys.shift(); if (key) { delete cache[key]; cache_length--; } } } }; return function (s) { cacheCheck(); try { r = cache[s] = (cache[s] || rule.call(this, s)); } catch (e) { r = cache[s] = e; } cache_length++; cache_keys.push(s); if (r instanceof $P.Exception) { throw r; } else { return r; } }; }, // vector operators -- see below any: function () { var px = arguments; return function (s) { var r = null; for (var i = 0; i < px.length; i++) { if (px[i] == null) { continue; } try { r = (px[i].call(this, s)); } catch (e) { r = null; } if (r) { return r; } } throw new $P.Exception(s); }; }, each: function () { var px = arguments; return function (s) { var rx = [], r = null; for (var i = 0; i < px.length ; i++) { if (px[i] == null) { continue; } try { r = (px[i].call(this, s)); } catch (e) { throw new $P.Exception(s); } rx.push(r[0]); s = r[1]; } return [ rx, s]; }; }, all: function () { var px = arguments, _ = _; return _.each(_.optional(px)); }, // delimited operators sequence: function (px, d, c) { d = d || _.rtoken(/^\s*/); c = c || null; if (px.length === 1) { return px[0]; } return function (s) { var r = null, q = null; var rx = []; for (var i = 0; i < px.length ; i++) { try { r = px[i].call(this, s); } catch (e) { break; } rx.push(r[0]); try { q = d.call(this, r[1]); } catch (ex) { q = null; break; } s = q[1]; } if (!r) { throw new $P.Exception(s); } if (q) { throw new $P.Exception(q[1]); } if (c) { try { r = c.call(this, r[1]); } catch (ey) { throw new $P.Exception(r[1]); } } return [ rx, (r?r[1]:s) ]; }; }, // // Composite Operators // between: function (d1, p, d2) { d2 = d2 || d1; var _fn = _.each(_.ignore(d1), p, _.ignore(d2)); return function (s) { var rx = _fn.call(this, s); return [[rx[0][0], r[0][2]], rx[1]]; }; }, list: function (p, d, c) { d = d || _.rtoken(/^\s*/); c = c || null; return (p instanceof Array ? _.each(_.product(p.slice(0, -1), _.ignore(d)), p.slice(-1), _.ignore(c)) : _.each(_.many(_.each(p, _.ignore(d))), px, _.ignore(c))); }, set: function (px, d, c) { d = d || _.rtoken(/^\s*/); c = c || null; return function (s) { // r is the current match, best the current 'best' match // which means it parsed the most amount of input var r = null, p = null, q = null, rx = null, best = [[], s], last = false; // go through the rules in the given set for (var i = 0; i < px.length ; i++) { // last is a flag indicating whether this must be the last element // if there is only 1 element, then it MUST be the last one q = null; p = null; r = null; last = (px.length === 1); // first, we try simply to match the current pattern // if not, try the next pattern try { r = px[i].call(this, s); } catch (e) { continue; } // since we are matching against a set of elements, the first // thing to do is to add r[0] to matched elements rx = [[r[0]], r[1]]; // if we matched and there is still input to parse and // we don't already know this is the last element, // we're going to next check for the delimiter ... // if there's none, or if there's no input left to parse // than this must be the last element after all ... if (r[1].length > 0 && ! last) { try { q = d.call(this, r[1]); } catch (ex) { last = true; } } else { last = true; } // if we parsed the delimiter and now there's no more input, // that means we shouldn't have parsed the delimiter at all // so don't update r and mark this as the last element ... if (!last && q[1].length === 0) { last = true; } // so, if this isn't the last element, we're going to see if // we can get any more matches from the remaining (unmatched) // elements ... if (!last) { // build a list of the remaining rules we can match against, // i.e., all but the one we just matched against var qx = []; for (var j = 0; j < px.length ; j++) { if (i !== j) { qx.push(px[j]); } } // now invoke recursively set with the remaining input // note that we don't include the closing delimiter ... // we'll check for that ourselves at the end p = _.set(qx, d).call(this, q[1]); // if we got a non-empty set as a result ... // (otw rx already contains everything we want to match) if (p[0].length > 0) { // update current result, which is stored in rx ... // basically, pick up the remaining text from p[1] // and concat the result from p[0] so that we don't // get endless nesting ... rx[0] = rx[0].concat(p[0]); rx[1] = p[1]; } } // at this point, rx either contains the last matched element // or the entire matched set that starts with this element. // now we just check to see if this variation is better than // our best so far, in terms of how much of the input is parsed if (rx[1].length < best[1].length) { best = rx; } // if we've parsed all the input, then we're finished if (best[1].length === 0) { break; } } // so now we've either gone through all the patterns trying them // as the initial match; or we found one that parsed the entire // input string ... // if best has no matches, just return empty set ... if (best[0].length === 0) { return best; } // if a closing delimiter is provided, then we have to check it also if (c) { // we try this even if there is no remaining input because the pattern // may well be optional or match empty input ... try { q = c.call(this, best[1]); } catch (ey) { throw new $P.Exception(best[1]); } // it parsed ... be sure to update the best match remaining input best[1] = q[1]; } // if we're here, either there was no closing delimiter or we parsed it // so now we have the best match; just return it! return best; }; }, forward: function (gr, fname) { return function (s) { return gr[fname].call(this, s); }; }, // // Translation Operators // replace: function (rule, repl) { return function (s) { var r = rule.call(this, s); return [repl, r[1]]; }; }, process: function (rule, fn) { return function (s) { var r = rule.call(this, s); return [fn.call(this, r[0]), r[1]]; }; }, min: function (min, rule) { return function (s) { var rx = rule.call(this, s); if (rx[0].length < min) { throw new $P.Exception(s); } return rx; }; } }; // Generator Operators And Vector Operators // Generators are operators that have a signature of F(R) => R, // taking a given rule and returning another rule, such as // ignore, which parses a given rule and throws away the result. // Vector operators are those that have a signature of F(R1,R2,...) => R, // take a list of rules and returning a new rule, such as each. // Generator operators are converted (via the following _generator // function) into functions that can also take a list or array of rules // and return an array of new rules as though the function had been // called on each rule in turn (which is what actually happens). // This allows generators to be used with vector operators more easily. // Example: // each(ignore(foo, bar)) instead of each(ignore(foo), ignore(bar)) // This also turns generators into vector operators, which allows // constructs like: // not(cache(foo, bar)) var _generator = function (op) { function gen() { var args = null, rx = [], px, i; if (arguments.length > 1) { args = Array.prototype.slice.call(arguments); } else if (arguments[0] instanceof Array) { args = arguments[0]; } if (args) { px = args.shift(); if (px.length > 0) { args.unshift(px[i]); rx.push(op.apply(null, args)); args.shift(); return rx; } } else { return op.apply(null, arguments); } } return gen; }; var gx = "optional not ignore cache".split(/\s/); for (var i = 0 ; i < gx.length ; i++) { _[gx[i]] = _generator(_[gx[i]]); } var _vector = function (op) { return function () { if (arguments[0] instanceof Array) { return op.apply(null, arguments[0]); } else { return op.apply(null, arguments); } }; }; var vx = "each any all".split(/\s/); for (var j = 0 ; j < vx.length ; j++) { _[vx[j]] = _vector(_[vx[j]]); } }()); (function () { var $D = Date; var flattenAndCompact = function (ax) { var rx = []; for (var i = 0; i < ax.length; i++) { if (ax[i] instanceof Array) { rx = rx.concat(flattenAndCompact(ax[i])); } else { if (ax[i]) { rx.push(ax[i]); } } } return rx; }; var parseMeridian = function () { if (this.meridian && (this.hour || this.hour === 0)) { if (this.meridian === "a" && this.hour > 11 && Date.Config.strict24hr){ throw "Invalid hour and meridian combination"; } else if (this.meridian === "p" && this.hour < 12 && Date.Config.strict24hr){ throw "Invalid hour and meridian combination"; } else if (this.meridian === "p" && this.hour < 12) { this.hour = this.hour + 12; } else if (this.meridian === "a" && this.hour === 12) { this.hour = 0; } } }; var setDefaults = function () { var now = new Date(); if ((this.hour || this.minute) && (!this.month && !this.year && !this.day)) { this.day = now.getDate(); } if (!this.year) { this.year = now.getFullYear(); } if (!this.month && this.month !== 0) { this.month = now.getMonth(); } if (!this.day) { this.day = 1; } if (!this.hour) { this.hour = 0; } if (!this.minute) { this.minute = 0; } if (!this.second) { this.second = 0; } if (!this.millisecond) { this.millisecond = 0; } }; var finishUtils = { getToday: function () { if (this.now || "hour minute second".indexOf(this.unit) !== -1) { return new Date(); } else { return $D.today(); } }, setDaysFromWeekday: function (today, orient){ var gap; orient = orient || 1; this.unit = "day"; gap = ($D.getDayNumberFromName(this.weekday) - today.getDay()); this.days = gap ? ((gap + (orient * 7)) % 7) : (orient * 7); return this; }, setMonthsFromMonth: function (today, orient) { var gap; orient = orient || 1; this.unit = "month"; gap = (this.month - today.getMonth()); this.months = gap ? ((gap + (orient * 12)) % 12) : (orient * 12); this.month = null; return this; }, setDMYFromWeekday: function () { var d = Date[this.weekday](); this.day = d.getDate(); if (!this.month) { this.month = d.getMonth(); } this.year = d.getFullYear(); return this; }, setUnitValue: function (orient) { if (!this.value && this.operator && this.operator !== null && this[this.unit + "s"] && this[this.unit + "s"] !== null) { this[this.unit + "s"] = this[this.unit + "s"] + ((this.operator === "add") ? 1 : -1) + (this.value||0) * orient; } else if (this[this.unit + "s"] == null || this.operator != null) { if (!this.value) { this.value = 1; } this[this.unit + "s"] = this.value * orient; } }, generateDateFromWeeks: function () { var weekday = (this.weekday !== undefined) ? this.weekday : "today"; var d = Date[weekday]().addWeeks(this.weeks); if (this.now) { d.setTimeToNow(); } return d; } }; $D.Translator = { hour: function (s) { return function () { this.hour = Number(s); }; }, minute: function (s) { return function () { this.minute = Number(s); }; }, second: function (s) { return function () { this.second = Number(s); }; }, /* for ss.s format */ secondAndMillisecond: function (s) { return function () { var mx = s.match(/^([0-5][0-9])\.([0-9]{1,3})/); this.second = Number(mx[1]); this.millisecond = Number(mx[2]); }; }, meridian: function (s) { return function () { this.meridian = s.slice(0, 1).toLowerCase(); }; }, timezone: function (s) { return function () { var n = s.replace(/[^\d\+\-]/g, ""); if (n.length) { this.timezoneOffset = Number(n); } else { this.timezone = s.toLowerCase(); } }; }, day: function (x) { var s = x[0]; return function () { this.day = Number(s.match(/\d+/)[0]); if (this.day < 1) { throw "invalid day"; } }; }, month: function (s) { return function () { this.month = (s.length === 3) ? "jan feb mar apr may jun jul aug sep oct nov dec".indexOf(s)/4 : Number(s) - 1; if (this.month < 0) { throw "invalid month"; } }; }, year: function (s) { return function () { var n = Number(s); this.year = ((s.length > 2) ? n : (n + (((n + 2000) < Date.CultureInfo.twoDigitYearMax) ? 2000 : 1900))); }; }, rday: function (s) { return function () { switch (s) { case "yesterday": this.days = -1; break; case "tomorrow": this.days = 1; break; case "today": this.days = 0; break; case "now": this.days = 0; this.now = true; break; } }; }, finishExact: function (x) { var d; x = (x instanceof Array) ? x : [x]; for (var i = 0 ; i < x.length ; i++) { if (x[i]) { x[i].call(this); } } setDefaults.call(this); parseMeridian.call(this); if (this.day > $D.getDaysInMonth(this.year, this.month)) { throw new RangeError(this.day + " is not a valid value for days."); } d = new Date(this.year, this.month, this.day, this.hour, this.minute, this.second, this.millisecond); if (this.year < 100) { d.setFullYear(this.year); // means years less that 100 are process correctly. JS will parse it otherwise as 1900-1999. } if (this.timezone) { d.set({ timezone: this.timezone }); } else if (this.timezoneOffset) { d.set({ timezoneOffset: this.timezoneOffset }); } return d; }, finish: function (x) { var today, expression, orient, temp; x = (x instanceof Array) ? flattenAndCompact(x) : [ x ]; if (x.length === 0) { return null; } for (var i = 0 ; i < x.length ; i++) { if (typeof x[i] === "function") { x[i].call(this); } } if (this.now && !this.unit && !this.operator) { return new Date(); } else { today = finishUtils.getToday.call(this); } expression = !!(this.days && this.days !== null || this.orient || this.operator); orient = ((this.orient === "past" || this.operator === "subtract") ? -1 : 1); if (this.month && this.unit === "week") { this.value = this.month + 1; delete this.month; delete this.day; } if ((this.month || this.month === 0) && "year day hour minute second".indexOf(this.unit) !== -1) { if (!this.value) { this.value = this.month + 1; } this.month = null; expression = true; } if (!expression && this.weekday && !this.day && !this.days) { finishUtils.setDMYFromWeekday.call(this); } if (expression && this.weekday && this.unit !== "month" && this.unit !== "week") { finishUtils.setDaysFromWeekday.call(this, today, orient); } if (this.weekday && this.unit !== "week" && !this.day && !this.days) { temp = Date[this.weekday](); this.day = temp.getDate(); if (temp.getMonth() !== today.getMonth()) { this.month = temp.getMonth(); } } if (this.month && this.unit === "day" && this.operator) { if (!this.value) { this.value = (this.month + 1); } this.month = null; } if (this.value != null && this.month != null && this.year != null) { this.day = this.value * 1; } if (this.month && !this.day && this.value) { today.set({ day: this.value * 1 }); if (!expression) { this.day = this.value * 1; } } if (!this.month && this.value && this.unit === "month" && !this.now) { this.month = this.value; expression = true; } if (expression && (this.month || this.month === 0) && this.unit !== "year") { finishUtils.setMonthsFromMonth.call(this, today, orient); } if (!this.unit) { this.unit = "day"; } finishUtils.setUnitValue.call(this, orient); parseMeridian.call(this); if ((this.month || this.month === 0) && !this.day) { this.day = 1; } if (!this.orient && !this.operator && this.unit === "week" && this.value && !this.day && !this.month) { return Date.today().setWeek(this.value); } if (this.unit === "week" && this.weeks && !this.day && !this.month) { return finishUtils.generateDateFromWeeks.call(this); } if (expression && this.timezone && this.day && this.days) { this.day = this.days; } if (expression){ today.add(this); } else { today.set(this); } if (this.timezone) { this.timezone = this.timezone.toUpperCase(); var offset = $D.getTimezoneOffset(this.timezone); var timezone; if (today.hasDaylightSavingTime()) { // lets check that we're being sane with timezone setting timezone = $D.getTimezoneAbbreviation(offset, today.isDaylightSavingTime()); if (timezone !== this.timezone) { // bugger, we're in a place where things like EST vs EDT matters. if (today.isDaylightSavingTime()) { today.addHours(-1); } else { today.addHours(1); } } } today.setTimezoneOffset(offset); } return today; } }; }()); (function () { var $D = Date; $D.Grammar = {}; var _ = $D.Parsing.Operators, g = $D.Grammar, t = $D.Translator, _fn; // Allow rolling up into general purpose rules _fn = function () { return _.each(_.any.apply(null, arguments), _.not(g.ctoken2("timeContext"))); }; g.datePartDelimiter = _.rtoken(/^([\s\-\.\,\/\x27]+)/); g.timePartDelimiter = _.stoken(":"); g.whiteSpace = _.rtoken(/^\s*/); g.generalDelimiter = _.rtoken(/^(([\s\,]|at|@|on)+)/); var _C = {}; g.ctoken = function (keys) { var fn = _C[keys]; if (! fn) { var c = Date.CultureInfo.regexPatterns; var kx = keys.split(/\s+/), px = []; for (var i = 0; i < kx.length ; i++) { px.push(_.replace(_.rtoken(c[kx[i]]), kx[i])); } fn = _C[keys] = _.any.apply(null, px); } return fn; }; g.ctoken2 = function (key) { return _.rtoken(Date.CultureInfo.regexPatterns[key]); }; var cacheProcessRtoken = function (key, token, type, eachToken) { if (eachToken) { g[key] = _.cache(_.process(_.each(_.rtoken(token),_.optional(g.ctoken2(eachToken))), type)); } else { g[key] = _.cache(_.process(_.rtoken(token), type)); } }; var cacheProcessCtoken = function (token, type) { return _.cache(_.process(g.ctoken2(token), type)); }; var _F = {}; //function cache var _get = function (f) { _F[f] = (_F[f] || g.format(f)[0]); return _F[f]; }; g.allformats = function (fx) { var rx = []; if (fx instanceof Array) { for (var i = 0; i < fx.length; i++) { rx.push(_get(fx[i])); } } else { rx.push(_get(fx)); } return rx; }; g.formats = function (fx) { if (fx instanceof Array) { var rx = []; for (var i = 0 ; i < fx.length ; i++) { rx.push(_get(fx[i])); } return _.any.apply(null, rx); } else { return _get(fx); } }; var grammarFormats = { timeFormats: function(){ var i, RTokenKeys = [ "h", "hh", "H", "HH", "m", "mm", "s", "ss", "ss.s", "z", "zz" ], RToken = [ /^(0[0-9]|1[0-2]|[1-9])/, /^(0[0-9]|1[0-2])/, /^([0-1][0-9]|2[0-3]|[0-9])/, /^([0-1][0-9]|2[0-3])/, /^([0-5][0-9]|[0-9])/, /^[0-5][0-9]/, /^([0-5][0-9]|[0-9])/, /^[0-5][0-9]/, /^[0-5][0-9]\.[0-9]{1,3}/, /^((\+|\-)\s*\d\d\d\d)|((\+|\-)\d\d\:?\d\d)/, /^((\+|\-)\s*\d\d\d\d)|((\+|\-)\d\d\:?\d\d)/ ], tokens = [ t.hour, t.hour, t.hour, t.hour, t.minute, t.minute, t.second, t.second, t.secondAndMillisecond, t.timezone, t.timezone ]; for (i=0; i < RTokenKeys.length; i++) { cacheProcessRtoken(RTokenKeys[i], RToken[i], tokens[i]); } g.hms = _.cache(_.sequence([g.H, g.m, g.s], g.timePartDelimiter)); g.t = cacheProcessCtoken("shortMeridian", t.meridian); g.tt = cacheProcessCtoken("longMeridian", t.meridian); g.zzz = cacheProcessCtoken("timezone", t.timezone); g.timeSuffix = _.each(_.ignore(g.whiteSpace), _.set([ g.tt, g.zzz ])); g.time = _.each(_.optional(_.ignore(_.stoken("T"))), g.hms, g.timeSuffix); }, dateFormats: function () { // pre-loaded rules for different date part order preferences var _setfn = function () { return _.set(arguments, g.datePartDelimiter); }; var i, RTokenKeys = [ "d", "dd", "M", "MM", "y", "yy", "yyy", "yyyy" ], RToken = [ /^([0-2]\d|3[0-1]|\d)/, /^([0-2]\d|3[0-1])/, /^(1[0-2]|0\d|\d)/, /^(1[0-2]|0\d)/, /^(\d+)/, /^(\d\d)/, /^(\d\d?\d?\d?)/, /^(\d\d\d\d)/ ], tokens = [ t.day, t.day, t.month, t.month, t.year, t.year, t.year, t.year ], eachToken = [ "ordinalSuffix", "ordinalSuffix" ]; for (i=0; i < RTokenKeys.length; i++) { cacheProcessRtoken(RTokenKeys[i], RToken[i], tokens[i], eachToken[i]); } g.MMM = g.MMMM = _.cache(_.process(g.ctoken("jan feb mar apr may jun jul aug sep oct nov dec"), t.month)); g.ddd = g.dddd = _.cache(_.process(g.ctoken("sun mon tue wed thu fri sat"), function (s) { return function () { this.weekday = s; }; } )); g.day = _fn(g.d, g.dd); g.month = _fn(g.M, g.MMM); g.year = _fn(g.yyyy, g.yy); g.mdy = _setfn(g.ddd, g.month, g.day, g.year); g.ymd = _setfn(g.ddd, g.year, g.month, g.day); g.dmy = _setfn(g.ddd, g.day, g.month, g.year); g.date = function (s) { return ((g[Date.CultureInfo.dateElementOrder] || g.mdy).call(this, s)); }; }, relative: function () { // relative date / time expressions g.orientation = _.process(g.ctoken("past future"), function (s) { return function () { this.orient = s; }; } ); g.operator = _.process(g.ctoken("add subtract"), function (s) { return function () { this.operator = s; }; } ); g.rday = _.process(g.ctoken("yesterday tomorrow today now"), t.rday); g.unit = _.process(g.ctoken("second minute hour day week month year"), function (s) { return function () { this.unit = s; }; } ); } }; g.buildGrammarFormats = function () { // these need to be rebuilt every time the language changes. _C = {}; grammarFormats.timeFormats(); grammarFormats.dateFormats(); grammarFormats.relative(); g.value = _.process(_.rtoken(/^([-+]?\d+)?(st|nd|rd|th)?/), function (s) { return function () { this.value = s.replace(/\D/g, ""); }; } ); g.expression = _.set([g.rday, g.operator, g.value, g.unit, g.orientation, g.ddd, g.MMM ]); g.format = _.process(_.many( _.any( // translate format specifiers into grammar rules _.process( _.rtoken(/^(dd?d?d?(?!e)|MM?M?M?|yy?y?y?|hh?|HH?|mm?|ss?|tt?|zz?z?)/), function (fmt) { if (g[fmt]) { return g[fmt]; } else { throw $D.Parsing.Exception(fmt); } } ), // translate separator tokens into token rules _.process(_.rtoken(/^[^dMyhHmstz]+/), // all legal separators function (s) { return _.ignore(_.stoken(s)); } ) ) ), // construct the parser ... function (rules) { return _.process(_.each.apply(null, rules), t.finishExact); } ); // starting rule for general purpose grammar g._start = _.process(_.set([ g.date, g.time, g.expression ], g.generalDelimiter, g.whiteSpace), t.finish); }; g.buildGrammarFormats(); // parsing date format specifiers - ex: "h:m:s tt" // this little guy will generate a custom parser based // on the format string, ex: g.format("h:m:s tt") // check for these formats first g._formats = g.formats([ "\"yyyy-MM-ddTHH:mm:ssZ\"", "yyyy-MM-ddTHH:mm:ss.sz", "yyyy-MM-ddTHH:mm:ssZ", "yyyy-MM-ddTHH:mm:ssz", "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-ddTHH:mmZ", "yyyy-MM-ddTHH:mmz", "yyyy-MM-ddTHH:mm", "ddd, MMM dd, yyyy H:mm:ss tt", "ddd MMM d yyyy HH:mm:ss zzz", "MMddyyyy", "ddMMyyyy", "Mddyyyy", "ddMyyyy", "Mdyyyy", "dMyyyy", "yyyy", "Mdyy", "dMyy", "d" ]); // real starting rule: tries selected formats first, // then general purpose rule g.start = function (s) { try { var r = g._formats.call({}, s); if (r[1].length === 0) { return r; } } catch (e) {} return g._start.call({}, s); }; }()); (function () { var $D = Date; /** * @desc Converts the specified string value into its JavaScript Date equivalent using CultureInfo specific format information. * * Example

	///////////
	// Dates //
	///////////

	// 15-Oct-2004
	var d1 = Date.parse("10/15/2004");

	// 15-Oct-2004
	var d1 = Date.parse("15-Oct-2004");

	// 15-Oct-2004
	var d1 = Date.parse("2004.10.15");

	//Fri Oct 15, 2004
	var d1 = Date.parse("Fri Oct 15, 2004");

	///////////
	// Times //
	///////////

	// Today at 10 PM.
	var d1 = Date.parse("10 PM");

	// Today at 10:30 PM.
	var d1 = Date.parse("10:30 P.M.");

	// Today at 6 AM.
	var d1 = Date.parse("06am");

	/////////////////////
	// Dates and Times //
	/////////////////////

	// 8-July-2004 @ 10:30 PM
	var d1 = Date.parse("July 8th, 2004, 10:30 PM");

	// 1-July-2004 @ 10:30 PM
	var d1 = Date.parse("2004-07-01T22:30:00");

	////////////////////
	// Relative Dates //
	////////////////////

	// Returns today's date. The string "today" is culture specific.
	var d1 = Date.parse("today");

	// Returns yesterday's date. The string "yesterday" is culture specific.
	var d1 = Date.parse("yesterday");

	// Returns the date of the next thursday.
	var d1 = Date.parse("Next thursday");

	// Returns the date of the most previous monday.
	var d1 = Date.parse("last monday");

	// Returns today's day + one year.
	var d1 = Date.parse("next year");

	///////////////
	// Date Math //
	///////////////

	// Today + 2 days
	var d1 = Date.parse("t+2");

	// Today + 2 days
	var d1 = Date.parse("today + 2 days");

	// Today + 3 months
	var d1 = Date.parse("t+3m");

	// Today - 1 year
	var d1 = Date.parse("today - 1 year");

	// Today - 1 year
	var d1 = Date.parse("t-1y"); 


	/////////////////////////////
	// Partial Dates and Times //
	/////////////////////////////

	// July 15th of this year.
	var d1 = Date.parse("July 15");

	// 15th day of current day and year.
	var d1 = Date.parse("15");

	// July 1st of current year at 10pm.
	var d1 = Date.parse("7/1 10pm");
	
* * @param {String} The string value to convert into a Date object [Required] * @return {Date} A Date object or null if the string cannot be converted into a Date. */ var parseUtils = { removeOrds: function (s) { ords = s.match(/\b(\d+)(?:st|nd|rd|th)\b/); // find ordinal matches s = ((ords && ords.length === 2) ? s.replace(ords[0], ords[1]) : s); return s; }, grammarParser: function (s) { var r = null; try { r = $D.Grammar.start.call({}, s.replace(/^\s*(\S*(\s+\S+)*)\s*$/, "$1")); } catch (e) { return null; } return ((r[1].length === 0) ? r[0] : null); }, nativeFallback: function(s) { var t; try { // ok we haven't parsed it, last ditch attempt with the built-in parser. t = Date._parse(s); return (t || t === 0) ? new Date(t) : null; } catch (e) { return null; } } }; function parse (s) { var d; if (!s) { return null; } if (s instanceof Date) { return s.clone(); } if (s.length >= 4 && s.charAt(0) !== "0" && s.charAt(0) !== "+"&& s.charAt(0) !== "-") { // ie: 2004 will pass, 0800 won't. // Start with specific formats d = $D.Parsing.ISO.parse(s) || $D.Parsing.Numeric.parse(s); } if (d instanceof Date && !isNaN(d.getTime())) { return d; } else { // find ordinal dates (1st, 3rd, 8th, etc and remove them as they cause parsing issues) s = $D.Parsing.Normalizer.parse(parseUtils.removeOrds(s)); d = parseUtils.grammarParser(s); if (d !== null) { return d; } else { return parseUtils.nativeFallback(s); } } } if (!$D._parse) { $D._parse = $D.parse; } $D.parse = parse; Date.getParseFunction = function (fx) { var fns = Date.Grammar.allformats(fx); return function (s) { var r = null; for (var i = 0; i < fns.length; i++) { try { r = fns[i].call({}, s); } catch (e) { continue; } if (r[1].length === 0) { return r[0]; } } return null; }; }; /** * Converts the specified string value into its JavaScript Date equivalent using the specified format {String} or formats {Array} and the CultureInfo specific format information. * The format of the string value must match one of the supplied formats exactly. * * Example

	// 15-Oct-2004
	var d1 = Date.parseExact("10/15/2004", "M/d/yyyy");

	// 15-Oct-2004
	var d1 = Date.parse("15-Oct-2004", "M-ddd-yyyy");

	// 15-Oct-2004
	var d1 = Date.parse("2004.10.15", "yyyy.MM.dd");

	// Multiple formats
	var d1 = Date.parseExact("10/15/2004", ["M/d/yyyy", "MMMM d, yyyy"]);
	
* * @param {String} The string value to convert into a Date object [Required]. * @param {Object} The expected format {String} or an array of expected formats {Array} of the date string [Required]. * @return {Date} A Date object or null if the string cannot be converted into a Date. */ $D.parseExact = function (s, fx) { return $D.getParseFunction(fx)(s); }; }()); (function () { var $D = Date, $P = $D.prototype, // $C = $D.CultureInfo, // not used atm p = function (s, l) { if (!l) { l = 2; } return ("000" + s).slice(l * -1); }; /** * Converts a PHP format string to Java/.NET format string. * A PHP format string can be used with ._format or .format. * A Java/.NET format string can be used with .toString(). * The .parseExact function will only accept a Java/.NET format string * * Example * var f1 = "%m/%d/%y" * var f2 = Date.normalizeFormat(f1); // "MM/dd/yy" * * new Date().format(f1); // "04/13/08" * new Date()._format(f1); // "04/13/08" * new Date().toString(f2); // "04/13/08" * * var date = Date.parseExact("04/13/08", f2); // Sun Apr 13 2008 * * @param {String} A PHP format string consisting of one or more format spcifiers. * @return {String} The PHP format converted to a Java/.NET format string. */ var normalizerSubstitutions = { "d" : "dd", "%d": "dd", "D" : "ddd", "%a": "ddd", "j" : "dddd", "l" : "dddd", "%A": "dddd", "S" : "S", "F" : "MMMM", "%B": "MMMM", "m" : "MM", "%m": "MM", "M" : "MMM", "%b": "MMM", "%h": "MMM", "n" : "M", "Y" : "yyyy", "%Y": "yyyy", "y" : "yy", "%y": "yy", "g" : "h", "%I": "h", "G" : "H", "h" : "hh", "H" : "HH", "%H": "HH", "i" : "mm", "%M": "mm", "s" : "ss", "%S": "ss", "%r": "hh:mm tt", "%R": "H:mm", "%T": "H:mm:ss", "%X": "t", "%x": "d", "%e": "d", "%D": "MM/dd/yy", "%n": "\\n", "%t": "\\t", "e" : "z", "T" : "z", "%z": "z", "%Z": "z", "Z" : "ZZ", "N" : "u", "w" : "u", "%w": "u", "W" : "W", "%V": "W" }; var normalizer = { substitutes: function (m) { return normalizerSubstitutions[m]; }, interpreted: function (m, x) { var y; switch (m) { case "%u": return x.getDay() + 1; case "z": return x.getOrdinalNumber(); case "%j": return p(x.getOrdinalNumber(), 3); case "%U": var d1 = x.clone().set({month: 0, day: 1}).addDays(-1).moveToDayOfWeek(0), d2 = x.clone().addDays(1).moveToDayOfWeek(0, -1); return (d2 < d1) ? "00" : p((d2.getOrdinalNumber() - d1.getOrdinalNumber()) / 7 + 1); case "%W": return p(x.getWeek()); case "t": return $D.getDaysInMonth(x.getFullYear(), x.getMonth()); case "o": case "%G": return x.setWeek(x.getISOWeek()).toString("yyyy"); case "%g": return x._format("%G").slice(-2); case "a": case "%p": return t("tt").toLowerCase(); case "A": return t("tt").toUpperCase(); case "u": return p(x.getMilliseconds(), 3); case "I": return (x.isDaylightSavingTime()) ? 1 : 0; case "O": return x.getUTCOffset(); case "P": y = x.getUTCOffset(); return y.substring(0, y.length - 2) + ":" + y.substring(y.length - 2); case "B": var now = new Date(); return Math.floor(((now.getHours() * 3600) + (now.getMinutes() * 60) + now.getSeconds() + (now.getTimezoneOffset() + 60) * 60) / 86.4); case "c": return x.toISOString().replace(/\"/g, ""); case "U": return $D.strtotime("now"); case "%c": return t("d") + " " + t("t"); case "%C": return Math.floor(x.getFullYear() / 100 + 1); } }, shouldOverrideDefaults: function (m) { switch (m) { case "%e": return true; default: return false; } }, parse: function (m, context) { var formatString, c = context || new Date(); formatString = normalizer.substitutes(m); if (formatString) { return formatString; } formatString = normalizer.interpreted(m, c); if (formatString) { return formatString; } else { return m; } } }; $D.normalizeFormat = function (format, context) { return format.replace(/(%|\\)?.|%%/g, function(t){ return normalizer.parse(t, context); }); }; /** * Format a local Unix timestamp according to locale settings * * Example: * Date.strftime("%m/%d/%y", new Date()); // "04/13/08" * Date.strftime("c", "2008-04-13T17:52:03Z"); // "04/13/08" * * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @param {Number|String} The number representing the number of seconds that have elapsed since January 1, 1970 (local time). * @return {String} A string representation of the current Date object. */ $D.strftime = function (format, time) { var d = Date.parse(time); return d._format(format); }; /** * Parse any textual datetime description into a Unix timestamp. * A Unix timestamp is the number of seconds that have elapsed since January 1, 1970 (midnight UTC/GMT). * * Example: * Date.strtotime("04/13/08"); // 1208044800 * Date.strtotime("1970-01-01T00:00:00Z"); // 0 * * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @param {Object} A string or date object. * @return {String} A string representation of the current Date object. */ $D.strtotime = function (time) { var d = $D.parse(time); return Math.round($D.UTC(d.getUTCFullYear(), d.getUTCMonth(), d.getUTCDate(), d.getUTCHours(), d.getUTCMinutes(), d.getUTCSeconds(), d.getUTCMilliseconds()) / 1000); }; /** * Converts the value of the current Date object to its equivalent string representation using a PHP/Unix style of date format specifiers. * Format Specifiers * Format Description Example * ------ --------------------------------------------------------------------------- ----------------------- * %a abbreviated weekday name according to the current localed "Mon" through "Sun" * %A full weekday name according to the current localed "Sunday" through "Saturday" * %b abbreviated month name according to the current localed "Jan" through "Dec" * %B full month name according to the current locale "January" through "December" * %c preferred date and time representation for the current locale "4/13/2008 12:33 PM" * %C century number (the year divided by 100 and truncated to an integer) "00" to "99" * %d day of the month as a decimal number "01" to "31" * %D same as %m/%d/%y "04/13/08" * %e day of the month as a decimal number, a single digit is preceded by a space "1" to "31" * %g like %G, but without the century "08" * %G The 4-digit year corresponding to the ISO week number (see %V). "2008" * This has the same format and value as %Y, except that if the ISO week number * belongs to the previous or next year, that year is used instead. * %h same as %b "Jan" through "Dec" * %H hour as a decimal number using a 24-hour clock. "00" to "23" * %I hour as a decimal number using a 12-hour clock. "01" to "12" * %j day of the year as a decimal number. "001" to "366" * %m month as a decimal number. "01" to "12" * %M minute as a decimal number. "00" to "59" * %n newline character "\n" * %p either "am" or "pm" according to the given time value, or the "am" or "pm" * corresponding strings for the current locale. * %r time in a.m. and p.m. notation "8:44 PM" * %R time in 24 hour notation "20:44" * %S second as a decimal number "00" to "59" * %t tab character "\t" * %T current time, equal to %H:%M:%S "12:49:11" * %u weekday as a decimal number ["1", "7"], with "1" representing Monday "1" to "7" * %U week number of the current year as a decimal number, starting with the "0" to ("52" or "53") * first Sunday as the first day of the first week * %V The ISO 8601:1988 week number of the current year as a decimal number, "00" to ("52" or "53") * range 01 to 53, where week 1 is the first week that has at least 4 days * in the current year, and with Monday as the first day of the week. * (Use %G or %g for the year component that corresponds to the week number * for the specified timestamp.) * %W week number of the current year as a decimal number, starting with the "00" to ("52" or "53") * first Monday as the first day of the first week * %w day of the week as a decimal, Sunday being "0" "0" to "6" * %x preferred date representation for the current locale without the time "4/13/2008" * %X preferred time representation for the current locale without the date "12:53:05" * %y year as a decimal number without a century "00" "99" * %Y year as a decimal number including the century "2008" * %Z time zone or name or abbreviation "UTC", "EST", "PST" * %z same as %Z * %% a literal "%" characters "%" * d Day of the month, 2 digits with leading zeros "01" to "31" * D A textual representation of a day, three letters "Mon" through "Sun" * j Day of the month without leading zeros "1" to "31" * l A full textual representation of the day of the week (lowercase "L") "Sunday" through "Saturday" * N ISO-8601 numeric representation of the day of the week (added in PHP 5.1.0) "1" (for Monday) through "7" (for Sunday) * S English ordinal suffix for the day of the month, 2 characters "st", "nd", "rd" or "th". Works well with j * w Numeric representation of the day of the week "0" (for Sunday) through "6" (for Saturday) * z The day of the year (starting from "0") "0" through "365" * W ISO-8601 week number of year, weeks starting on Monday "00" to ("52" or "53") * F A full textual representation of a month, such as January or March "January" through "December" * m Numeric representation of a month, with leading zeros "01" through "12" * M A short textual representation of a month, three letters "Jan" through "Dec" * n Numeric representation of a month, without leading zeros "1" through "12" * t Number of days in the given month "28" through "31" * L Whether it's a leap year "1" if it is a leap year, "0" otherwise * o ISO-8601 year number. This has the same value as Y, except that if the "2008" * ISO week number (W) belongs to the previous or next year, that year * is used instead. * Y A full numeric representation of a year, 4 digits "2008" * y A two digit representation of a year "08" * a Lowercase Ante meridiem and Post meridiem "am" or "pm" * A Uppercase Ante meridiem and Post meridiem "AM" or "PM" * B Swatch Internet time "000" through "999" * g 12-hour format of an hour without leading zeros "1" through "12" * G 24-hour format of an hour without leading zeros "0" through "23" * h 12-hour format of an hour with leading zeros "01" through "12" * H 24-hour format of an hour with leading zeros "00" through "23" * i Minutes with leading zeros "00" to "59" * s Seconds, with leading zeros "00" through "59" * u Milliseconds "54321" * e Timezone identifier "UTC", "EST", "PST" * I Whether or not the date is in daylight saving time (uppercase i) "1" if Daylight Saving Time, "0" otherwise * O Difference to Greenwich time (GMT) in hours "+0200", "-0600" * P Difference to Greenwich time (GMT) with colon between hours and minutes "+02:00", "-06:00" * T Timezone abbreviation "UTC", "EST", "PST" * Z Timezone offset in seconds. The offset for timezones west of UTC is "-43200" through "50400" * always negative, and for those east of UTC is always positive. * c ISO 8601 date "2004-02-12T15:19:21+00:00" * r RFC 2822 formatted date "Thu, 21 Dec 2000 16:01:07 +0200" * U Seconds since the Unix Epoch (January 1 1970 00:00:00 GMT) "0" * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @return {String} A string representation of the current Date object. */ var formatReplace = function (context) { return function (m) { var formatString, override = false; if (m.charAt(0) === "\\" || m.substring(0, 2) === "%%") { return m.replace("\\", "").replace("%%", "%"); } override = normalizer.shouldOverrideDefaults(m); formatString = $D.normalizeFormat(m, context); if (formatString) { return context.toString(formatString, override); } }; }; $P._format = function (format) { var formatter = formatReplace(this); if (!format) { return this._toString(); } else { return format.replace(/(%|\\)?.|%%/g, formatter); } }; if (!$P.format) { $P.format = $P._format; } }()); (function () { "use strict"; var gFn = function (attr) { return function () { return this[attr]; }; }; var sFn = function (attr) { return function (val) { this[attr] = val; return this; }; }; var attrs = ["years", "months", "days", "hours", "minutes", "seconds", "milliseconds"]; var addSetFuncs = function (context, attrs) { for (var i = 0; i < attrs.length ; i++) { var $a = attrs[i], $b = $a.slice(0, 1).toUpperCase() + $a.slice(1); context.prototype[$a] = 0; context.prototype["get" + $b] = gFn($a); context.prototype["set" + $b] = sFn($a); } }; /** * new TimeSpan(milliseconds); * new TimeSpan(days, hours, minutes, seconds); * new TimeSpan(days, hours, minutes, seconds, milliseconds); */ var TimeSpan = function (days, hours, minutes, seconds, milliseconds) { if (arguments.length === 1 && typeof days === "number") { var orient = (days < 0) ? -1 : +1; var millsLeft = Math.abs(days); this.setDays(Math.floor(millsLeft / 86400000) * orient); millsLeft = millsLeft % 86400000; this.setHours(Math.floor(millsLeft / 3600000) * orient); millsLeft = millsLeft % 3600000; this.setMinutes(Math.floor(millsLeft / 60000) * orient); millsLeft = millsLeft % 60000; this.setSeconds(Math.floor(millsLeft / 1000) * orient); millsLeft = millsLeft % 1000; this.setMilliseconds(millsLeft * orient); } else { this.set(days, hours, minutes, seconds, milliseconds); } this.getTotalMilliseconds = function () { return (this.getDays() * 86400000) + (this.getHours() * 3600000) + (this.getMinutes() * 60000) + (this.getSeconds() * 1000); }; this.compareTo = function (time) { var t1 = new Date(1970, 1, 1, this.getHours(), this.getMinutes(), this.getSeconds()), t2; if (time === null) { t2 = new Date(1970, 1, 1, 0, 0, 0); } else { t2 = new Date(1970, 1, 1, time.getHours(), time.getMinutes(), time.getSeconds()); } return (t1 < t2) ? -1 : (t1 > t2) ? 1 : 0; }; this.equals = function (time) { return (this.compareTo(time) === 0); }; this.add = function (time) { return (time === null) ? this : this.addSeconds(time.getTotalMilliseconds() / 1000); }; this.subtract = function (time) { return (time === null) ? this : this.addSeconds(-time.getTotalMilliseconds() / 1000); }; this.addDays = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 86400000)); }; this.addHours = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 3600000)); }; this.addMinutes = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 60000)); }; this.addSeconds = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 1000)); }; this.addMilliseconds = function (n) { return new TimeSpan(this.getTotalMilliseconds() + n); }; this.get12HourHour = function () { return (this.getHours() > 12) ? this.getHours() - 12 : (this.getHours() === 0) ? 12 : this.getHours(); }; this.getDesignator = function () { return (this.getHours() < 12) ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator; }; this.toString = function (format) { this._toString = function () { if (this.getDays() !== null && this.getDays() > 0) { return this.getDays() + "." + this.getHours() + ":" + this.p(this.getMinutes()) + ":" + this.p(this.getSeconds()); } else { return this.getHours() + ":" + this.p(this.getMinutes()) + ":" + this.p(this.getSeconds()); } }; this.p = function (s) { return (s.toString().length < 2) ? "0" + s : s; }; var me = this; return format ? format.replace(/dd?|HH?|hh?|mm?|ss?|tt?/g, function (format) { switch (format) { case "d": return me.getDays(); case "dd": return me.p(me.getDays()); case "H": return me.getHours(); case "HH": return me.p(me.getHours()); case "h": return me.get12HourHour(); case "hh": return me.p(me.get12HourHour()); case "m": return me.getMinutes(); case "mm": return me.p(me.getMinutes()); case "s": return me.getSeconds(); case "ss": return me.p(me.getSeconds()); case "t": return ((me.getHours() < 12) ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator).substring(0, 1); case "tt": return (me.getHours() < 12) ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator; } } ) : this._toString(); }; return this; }; addSetFuncs(TimeSpan, attrs.slice(2)); TimeSpan.prototype.set = function (days, hours, minutes, seconds, milliseconds){ this.setDays(days || this.getDays()); this.setHours(hours || this.getHours()); this.setMinutes(minutes || this.getMinutes()); this.setSeconds(seconds || this.getSeconds()); this.setMilliseconds(milliseconds || this.getMilliseconds()); }; /** * Gets the time of day for this date instances. * @return {TimeSpan} TimeSpan */ Date.prototype.getTimeOfDay = function () { return new TimeSpan(0, this.getHours(), this.getMinutes(), this.getSeconds(), this.getMilliseconds()); }; Date.TimeSpan = TimeSpan; if (typeof window !== "undefined" ) { // keeping API compatible for v1.x window.TimeSpan = TimeSpan; } }()); (function () { "use strict"; var attrs = ["years", "months", "days", "hours", "minutes", "seconds", "milliseconds"]; var gFn = function (attr) { return function () { return this[attr]; }; }; var sFn = function (attr) { return function (val) { this[attr] = val; return this; }; }; var addSetFuncs = function (context, attrs) { for (var i = 0; i < attrs.length ; i++) { var $a = attrs[i], $b = $a.slice(0, 1).toUpperCase() + $a.slice(1); context.prototype[$a] = 0; context.prototype["get" + $b] = gFn($a); context.prototype["set" + $b] = sFn($a); } }; var setMonthsAndYears = function (orient, d1, d2, context) { function inc() { d1.addMonths(-orient); context.months++; if (context.months === 12) { context.years++; context.months = 0; } } if (orient === +1) { while (d1 > d2) { inc(); } } else { while (d1 < d2) { inc(); } } context.months--; context.months *= orient; context.years *= orient; }; var adjustForDST = function(orient, startDate, endDate) { var hasDSTMismatch = (false === (startDate.isDaylightSavingTime() === endDate.isDaylightSavingTime())); if (hasDSTMismatch && orient === 1) { startDate.addHours(-1); } else if (hasDSTMismatch) { startDate.addHours(1); } }; /** * TimePeriod(startDate, endDate); * TimePeriod(years, months, days, hours, minutes, seconds, milliseconds); */ var TimePeriod = function (years, months, days, hours, minutes, seconds, milliseconds) { if (arguments.length === 7) { this.set(years, months, days, hours, minutes, seconds, milliseconds); } else if (arguments.length === 2 && arguments[0] instanceof Date && arguments[1] instanceof Date) { var startDate = arguments[0].clone(); var endDate = arguments[1].clone(); var orient = (startDate > endDate) ? +1 : -1; this.dates = { start: arguments[0].clone(), end: arguments[1].clone() }; setMonthsAndYears(orient, startDate, endDate, this); adjustForDST(orient, startDate, endDate); // // TODO - adjust for DST var diff = endDate - startDate; if (diff !== 0) { var ts = new TimeSpan(diff); this.set(this.years, this.months, ts.getDays(), ts.getHours(), ts.getMinutes(), ts.getSeconds(), ts.getMilliseconds()); } } return this; }; // create all the set functions. addSetFuncs(TimePeriod, attrs); TimePeriod.prototype.set = function (years, months, days, hours, minutes, seconds, milliseconds){ this.setYears(years || this.getYears()); this.setMonths(months || this.getMonths()); this.setDays(days || this.getDays()); this.setHours(hours || this.getHours()); this.setMinutes(minutes || this.getMinutes()); this.setSeconds(seconds || this.getSeconds()); this.setMilliseconds(milliseconds || this.getMilliseconds()); }; Date.TimePeriod = TimePeriod; if (typeof window !== "undefined") { // keeping API compatible for v1.x window.TimePeriod = TimePeriod; } }()); ================================================ FILE: build/date-tr-TR.js ================================================ /** * @overview datejs * @version 1.0.0-rc3 * @author Gregory Wild-Smith * @copyright 2015 Gregory Wild-Smith * @license MIT * @homepage https://github.com/abritinthebay/datejs */ /* * DateJS Culture String File * Country Code: tr-TR * Name: Turkish (Turkey) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["tr-TR"] = { "name": "tr-TR", "englishName": "Turkish (Turkey)", "nativeName": "Türkçe (Türkiye)", "Sunday": "Pazar", "Monday": "Pazartesi", "Tuesday": "Salı", "Wednesday": "Çarşamba", "Thursday": "Perşembe", "Friday": "Cuma", "Saturday": "Cumartesi", "Sun": "Paz", "Mon": "Pzt", "Tue": "Sal", "Wed": "Çar", "Thu": "Per", "Fri": "Cum", "Sat": "Cmt", "Su": "Pz", "Mo": "Pt", "Tu": "Sa", "We": "Ça", "Th": "Pe", "Fr": "Cu", "Sa": "Ct", "S_Sun_Initial": "P", "M_Mon_Initial": "P", "T_Tue_Initial": "S", "W_Wed_Initial": "Ç", "T_Thu_Initial": "P", "F_Fri_Initial": "C", "S_Sat_Initial": "C", "January": "Ocak", "February": "Şubat", "March": "Mart", "April": "Nisan", "May": "Mayıs", "June": "Haziran", "July": "Temmuz", "August": "Ağustos", "September": "Eylül", "October": "Ekim", "November": "Kasım", "December": "Aralık", "Jan_Abbr": "Oca", "Feb_Abbr": "Şub", "Mar_Abbr": "Mar", "Apr_Abbr": "Nis", "May_Abbr": "May", "Jun_Abbr": "Haz", "Jul_Abbr": "Tem", "Aug_Abbr": "Ağu", "Sep_Abbr": "Eyl", "Oct_Abbr": "Eki", "Nov_Abbr": "Kas", "Dec_Abbr": "Ara", "AM": "", "PM": "", "firstDayOfWeek": 1, "twoDigitYearMax": 2029, "mdy": "dmy", "M/d/yyyy": "dd.MM.yyyy", "dddd, MMMM dd, yyyy": "dd MMMM yyyy dddd", "h:mm tt": "HH:mm", "h:mm:ss tt": "HH:mm:ss", "dddd, MMMM dd, yyyy h:mm:ss tt": "dd MMMM yyyy dddd HH:mm:ss", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "dd MMMM", "MMMM, yyyy": "MMMM yyyy", "/jan(uary)?/": "oca(k)?", "/feb(ruary)?/": "şub(at)?", "/mar(ch)?/": "mar(t)?", "/apr(il)?/": "nis(an)?", "/may/": "may(ıs)?", "/jun(e)?/": "haz(iran)?", "/jul(y)?/": "tem(muz)?", "/aug(ust)?/": "ağu(stos)?", "/sep(t(ember)?)?/": "eyl(ül)?", "/oct(ober)?/": "eki(m)?", "/nov(ember)?/": "kas(ım)?", "/dec(ember)?/": "ara(lık)?", "/^su(n(day)?)?/": "^pz(z(ar)?)?", "/^mo(n(day)?)?/": "^pt(t(artesi)?)?", "/^tu(e(s(day)?)?)?/": "^sa(l(ı)?)?", "/^we(d(nesday)?)?/": "^ça(r(şamba)?)?", "/^th(u(r(s(day)?)?)?)?/": "^pe(r(şembe)?)?", "/^fr(i(day)?)?/": "^cu(m(a)?)?", "/^sa(t(urday)?)?/": "^ct(t(artesi)?)?", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "tr-TR"; /** * @overview datejs * @version 1.0.0-rc3 * @author Gregory Wild-Smith * @copyright 2015 Gregory Wild-Smith * @license MIT * @homepage https://github.com/abritinthebay/datejs */(function () { var $D = Date; var lang = Date.CultureStrings ? Date.CultureStrings.lang : null; var loggedKeys = {}; // for debug purposes. var getText = { getFromKey: function (key, countryCode) { var output; if (Date.CultureStrings && Date.CultureStrings[countryCode] && Date.CultureStrings[countryCode][key]) { output = Date.CultureStrings[countryCode][key]; } else { output = getText.buildFromDefault(key); } if (key.charAt(0) === "/") { // Assume it's a regex output = getText.buildFromRegex(key, countryCode); } return output; }, getFromObjectValues: function (obj, countryCode) { var key, output = {}; for(key in obj) { if (obj.hasOwnProperty(key)) { output[key] = getText.getFromKey(obj[key], countryCode); } } return output; }, getFromObjectKeys: function (obj, countryCode) { var key, output = {}; for(key in obj) { if (obj.hasOwnProperty(key)) { output[getText.getFromKey(key, countryCode)] = obj[key]; } } return output; }, getFromArray: function (arr, countryCode) { var output = []; for (var i=0; i < arr.length; i++){ if (i in arr) { output[i] = getText.getFromKey(arr[i], countryCode); } } return output; }, buildFromDefault: function (key) { var output, length, split, last; switch(key) { case "name": output = "en-US"; break; case "englishName": output = "English (United States)"; break; case "nativeName": output = "English (United States)"; break; case "twoDigitYearMax": output = 2049; break; case "firstDayOfWeek": output = 0; break; default: output = key; split = key.split("_"); length = split.length; if (length > 1 && key.charAt(0) !== "/") { // if the key isn't a regex and it has a split. last = split[(length - 1)].toLowerCase(); if (last === "initial" || last === "abbr") { output = split[0]; } } break; } return output; }, buildFromRegex: function (key, countryCode) { var output; if (Date.CultureStrings && Date.CultureStrings[countryCode] && Date.CultureStrings[countryCode][key]) { output = new RegExp(Date.CultureStrings[countryCode][key], "i"); } else { output = new RegExp(key.replace(new RegExp("/", "g"),""), "i"); } return output; } }; var shallowMerge = function (obj1, obj2) { for (var attrname in obj2) { if (obj2.hasOwnProperty(attrname)) { obj1[attrname] = obj2[attrname]; } } }; var __ = function (key, language) { var countryCode = (language) ? language : lang; loggedKeys[key] = key; if (typeof key === "object") { if (key instanceof Array) { return getText.getFromArray(key, countryCode); } else { return getText.getFromObjectKeys(key, countryCode); } } else { return getText.getFromKey(key, countryCode); } }; var loadI18nScript = function (code) { // paatterned after jQuery's getScript. var url = Date.Config.i18n + code + ".js"; var head = document.getElementsByTagName("head")[0] || document.documentElement; var script = document.createElement("script"); script.src = url; var completed = false; var events = { done: function (){} // placeholder function }; // Attach handlers for all browsers script.onload = script.onreadystatechange = function() { if ( !completed && (!this.readyState || this.readyState === "loaded" || this.readyState === "complete") ) { events.done(); head.removeChild(script); } }; setTimeout(function() { head.insertBefore(script, head.firstChild); }, 0); // allows return to execute first return { done: function (cb) { events.done = function() { if (cb) { setTimeout(cb,0); } }; } }; }; var buildInfo = { buildFromMethodHash: function (obj) { var key; for(key in obj) { if (obj.hasOwnProperty(key)) { obj[key] = buildInfo[obj[key]](); } } return obj; }, timeZoneDST: function () { var DST = { "CHADT": "+1345", "NZDT": "+1300", "AEDT": "+1100", "ACDT": "+1030", "AZST": "+0500", "IRDT": "+0430", "EEST": "+0300", "CEST": "+0200", "BST": "+0100", "PMDT": "-0200", "ADT": "-0300", "NDT": "-0230", "EDT": "-0400", "CDT": "-0500", "MDT": "-0600", "PDT": "-0700", "AKDT": "-0800", "HADT": "-0900" }; return __(DST); }, timeZoneStandard: function () { var standard = { "LINT": "+1400", "TOT": "+1300", "CHAST": "+1245", "NZST": "+1200", "NFT": "+1130", "SBT": "+1100", "AEST": "+1000", "ACST": "+0930", "JST": "+0900", "CWST": "+0845", "CT": "+0800", "ICT": "+0700", "MMT": "+0630", "BST": "+0600", "NPT": "+0545", "IST": "+0530", "PKT": "+0500", "AFT": "+0430", "MSK": "+0400", "IRST": "+0330", "FET": "+0300", "EET": "+0200", "CET": "+0100", "GMT": "+0000", "UTC": "+0000", "CVT": "-0100", "GST": "-0200", "BRT": "-0300", "NST": "-0330", "AST": "-0400", "EST": "-0500", "CST": "-0600", "MST": "-0700", "PST": "-0800", "AKST": "-0900", "MIT": "-0930", "HST": "-1000", "SST": "-1100", "BIT": "-1200" }; return __(standard); }, timeZones: function (data) { var zone; data.timezones = []; for (zone in data.abbreviatedTimeZoneStandard) { if (data.abbreviatedTimeZoneStandard.hasOwnProperty(zone)) { data.timezones.push({ name: zone, offset: data.abbreviatedTimeZoneStandard[zone]}); } } for (zone in data.abbreviatedTimeZoneDST) { if (data.abbreviatedTimeZoneDST.hasOwnProperty(zone)) { data.timezones.push({ name: zone, offset: data.abbreviatedTimeZoneDST[zone], dst: true}); } } return data.timezones; }, days: function () { return __(["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"]); }, dayAbbr: function () { return __(["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"]); }, dayShortNames: function () { return __(["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"]); }, dayFirstLetters: function () { return __(["S_Sun_Initial", "M_Mon_Initial", "T_Tues_Initial", "W_Wed_Initial", "T_Thu_Initial", "F_Fri_Initial", "S_Sat_Initial"]); }, months: function () { return __(["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"]); }, monthAbbr: function () { return __(["Jan_Abbr", "Feb_Abbr", "Mar_Abbr", "Apr_Abbr", "May_Abbr", "Jun_Abbr", "Jul_Abbr", "Aug_Abbr", "Sep_Abbr", "Oct_Abbr", "Nov_Abbr", "Dec_Abbr"]); }, formatPatterns: function () { return getText.getFromObjectValues({ shortDate: "M/d/yyyy", longDate: "dddd, MMMM dd, yyyy", shortTime: "h:mm tt", longTime: "h:mm:ss tt", fullDateTime: "dddd, MMMM dd, yyyy h:mm:ss tt", sortableDateTime: "yyyy-MM-ddTHH:mm:ss", universalSortableDateTime: "yyyy-MM-dd HH:mm:ssZ", rfc1123: "ddd, dd MMM yyyy HH:mm:ss", monthDay: "MMMM dd", yearMonth: "MMMM, yyyy" }, Date.i18n.currentLanguage()); }, regex: function () { return getText.getFromObjectValues({ inTheMorning: "/( in the )(morn(ing)?)\\b/", thisMorning: "/(this )(morn(ing)?)\\b/", amThisMorning: "/(\b\\d(am)? )(this )(morn(ing)?)/", inTheEvening: "/( in the )(even(ing)?)\\b/", thisEvening: "/(this )(even(ing)?)\\b/", pmThisEvening: "/(\b\\d(pm)? )(this )(even(ing)?)/", jan: "/jan(uary)?/", feb: "/feb(ruary)?/", mar: "/mar(ch)?/", apr: "/apr(il)?/", may: "/may/", jun: "/jun(e)?/", jul: "/jul(y)?/", aug: "/aug(ust)?/", sep: "/sep(t(ember)?)?/", oct: "/oct(ober)?/", nov: "/nov(ember)?/", dec: "/dec(ember)?/", sun: "/^su(n(day)?)?/", mon: "/^mo(n(day)?)?/", tue: "/^tu(e(s(day)?)?)?/", wed: "/^we(d(nesday)?)?/", thu: "/^th(u(r(s(day)?)?)?)?/", fri: "/fr(i(day)?)?/", sat: "/^sa(t(urday)?)?/", future: "/^next/", past: "/^last|past|prev(ious)?/", add: "/^(\\+|aft(er)?|from|hence)/", subtract: "/^(\\-|bef(ore)?|ago)/", yesterday: "/^yes(terday)?/", today: "/^t(od(ay)?)?/", tomorrow: "/^tom(orrow)?/", now: "/^n(ow)?/", millisecond: "/^ms|milli(second)?s?/", second: "/^sec(ond)?s?/", minute: "/^mn|min(ute)?s?/", hour: "/^h(our)?s?/", week: "/^w(eek)?s?/", month: "/^m(onth)?s?/", day: "/^d(ay)?s?/", year: "/^y(ear)?s?/", shortMeridian: "/^(a|p)/", longMeridian: "/^(a\\.?m?\\.?|p\\.?m?\\.?)/", timezone: "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/", ordinalSuffix: "/^\\s*(st|nd|rd|th)/", timeContext: "/^\\s*(\\:|a(?!u|p)|p)/" }, Date.i18n.currentLanguage()); } }; var CultureInfo = function () { var info = getText.getFromObjectValues({ name: "name", englishName: "englishName", nativeName: "nativeName", amDesignator: "AM", pmDesignator: "PM", firstDayOfWeek: "firstDayOfWeek", twoDigitYearMax: "twoDigitYearMax", dateElementOrder: "mdy" }, Date.i18n.currentLanguage()); var constructedInfo = buildInfo.buildFromMethodHash({ dayNames: "days", abbreviatedDayNames: "dayAbbr", shortestDayNames: "dayShortNames", firstLetterDayNames: "dayFirstLetters", monthNames: "months", abbreviatedMonthNames: "monthAbbr", formatPatterns: "formatPatterns", regexPatterns: "regex", abbreviatedTimeZoneDST: "timeZoneDST", abbreviatedTimeZoneStandard: "timeZoneStandard" }); shallowMerge(info, constructedInfo); buildInfo.timeZones(info); return info; }; $D.i18n = { __: function (key, lang) { return __(key, lang); }, currentLanguage: function () { return lang || "en-US"; }, setLanguage: function (code, force, cb) { var async = false; if (force || code === "en-US" || (!!Date.CultureStrings && !!Date.CultureStrings[code])) { lang = code; Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings.lang = code; Date.CultureInfo = new CultureInfo(); } else { if (!(!!Date.CultureStrings && !!Date.CultureStrings[code])) { if (typeof exports !== "undefined" && this.exports !== exports) { // we're in a Node enviroment, load it using require try { require("../i18n/" + code + ".js"); lang = code; Date.CultureStrings.lang = code; Date.CultureInfo = new CultureInfo(); } catch (e) { // var str = "The language for '" + code + "' could not be loaded by Node. It likely does not exist."; throw new Error("The DateJS IETF language tag '" + code + "' could not be loaded by Node. It likely does not exist."); } } else if (Date.Config && Date.Config.i18n) { // we know the location of the files, so lets load them async = true; loadI18nScript(code).done(function(){ lang = code; Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings.lang = code; Date.CultureInfo = new CultureInfo(); $D.Parsing.Normalizer.buildReplaceData(); // because this is async if ($D.Grammar) { $D.Grammar.buildGrammarFormats(); // so we can parse those strings... } if (cb) { setTimeout(cb,0); } }); } else { Date.console.error("The DateJS IETF language tag '" + code + "' is not available and has not been loaded."); return false; } } } $D.Parsing.Normalizer.buildReplaceData(); // rebuild normalizer strings if ($D.Grammar) { $D.Grammar.buildGrammarFormats(); // so we can parse those strings... } if (!async && cb) { setTimeout(cb,0); } }, getLoggedKeys: function () { return loggedKeys; }, updateCultureInfo: function () { Date.CultureInfo = new CultureInfo(); } }; $D.i18n.updateCultureInfo(); // run automatically }()); (function () { var $D = Date, $P = $D.prototype, p = function (s, l) { if (!l) { l = 2; } return ("000" + s).slice(l * -1); }; if (typeof window !== "undefined" && typeof window.console !== "undefined" && typeof window.console.log !== "undefined") { $D.console = console; // used only to raise non-critical errors if available } else { // set mock so we don't give errors. $D.console = { log: function(){}, error: function(){} }; } $D.Config = $D.Config || {}; $D.initOverloads = function() { /** * Overload of Date.now. Allows an alternate call for Date.now where it returns the * current Date as an object rather than just milliseconds since the Unix Epoch. * * Also provides an implementation of now() for browsers (IE<9) that don't have it. * * Backwards compatible so with work with either: * Date.now() [returns ms] * or * Date.now(true) [returns Date] */ if (!$D.now) { $D._now = function now() { return new Date().getTime(); }; } else if (!$D._now) { $D._now = $D.now; } $D.now = function (returnObj) { if (returnObj) { return $D.present(); } else { return $D._now(); } }; if ( !$P.toISOString ) { $P.toISOString = function() { return this.getUTCFullYear() + "-" + p(this.getUTCMonth() + 1) + "-" + p(this.getUTCDate()) + "T" + p(this.getUTCHours()) + ":" + p(this.getUTCMinutes()) + ":" + p(this.getUTCSeconds()) + "." + String( (this.getUTCMilliseconds()/1000).toFixed(3)).slice(2, 5) + "Z"; }; } // private if ( $P._toString === undefined ){ $P._toString = $P.toString; } }; $D.initOverloads(); /** * Gets a date that is set to the current date. The time is set to the start of the day (00:00 or 12:00 AM). * @return {Date} The current date. */ $D.today = function () { return new Date().clearTime(); }; /** * Gets a date that is set to the current date and time (same as new Date, but chainable) * @return {Date} The current date. */ $D.present = function () { return new Date(); }; /** * Compares the first date to the second date and returns an number indication of their relative values. * @param {Date} First Date object to compare [Required]. * @param {Date} Second Date object to compare to [Required]. * @return {Number} -1 = date1 is lessthan date2. 0 = values are equal. 1 = date1 is greaterthan date2. */ $D.compare = function (date1, date2) { if (isNaN(date1) || isNaN(date2)) { throw new Error(date1 + " - " + date2); } else if (date1 instanceof Date && date2 instanceof Date) { return (date1 < date2) ? -1 : (date1 > date2) ? 1 : 0; } else { throw new TypeError(date1 + " - " + date2); } }; /** * Compares the first Date object to the second Date object and returns true if they are equal. * @param {Date} First Date object to compare [Required] * @param {Date} Second Date object to compare to [Required] * @return {Boolean} true if dates are equal. false if they are not equal. */ $D.equals = function (date1, date2) { return (date1.compareTo(date2) === 0); }; /** * Gets the language appropriate day name when given the day number(0-6) * eg - 0 == Sunday * @return {String} The day name */ $D.getDayName = function (n) { return Date.CultureInfo.dayNames[n]; }; /** * Gets the day number (0-6) if given a CultureInfo specific string which is a valid dayName, abbreviatedDayName or shortestDayName (two char). * @param {String} The name of the day (eg. "Monday, "Mon", "tuesday", "tue", "We", "we"). * @return {Number} The day number */ $D.getDayNumberFromName = function (name) { var n = Date.CultureInfo.dayNames, m = Date.CultureInfo.abbreviatedDayNames, o = Date.CultureInfo.shortestDayNames, s = name.toLowerCase(); for (var i = 0; i < n.length; i++) { if (n[i].toLowerCase() === s || m[i].toLowerCase() === s || o[i].toLowerCase() === s) { return i; } } return -1; }; /** * Gets the month number (0-11) if given a Culture Info specific string which is a valid monthName or abbreviatedMonthName. * @param {String} The name of the month (eg. "February, "Feb", "october", "oct"). * @return {Number} The day number */ $D.getMonthNumberFromName = function (name) { var n = Date.CultureInfo.monthNames, m = Date.CultureInfo.abbreviatedMonthNames, s = name.toLowerCase(); for (var i = 0; i < n.length; i++) { if (n[i].toLowerCase() === s || m[i].toLowerCase() === s) { return i; } } return -1; }; /** * Gets the language appropriate month name when given the month number(0-11) * eg - 0 == January * @return {String} The month name */ $D.getMonthName = function (n) { return Date.CultureInfo.monthNames[n]; }; /** * Determines if the current date instance is within a LeapYear. * @param {Number} The year. * @return {Boolean} true if date is within a LeapYear, otherwise false. */ $D.isLeapYear = function (year) { return ((year % 4 === 0 && year % 100 !== 0) || year % 400 === 0); }; /** * Gets the number of days in the month, given a year and month value. Automatically corrects for LeapYear. * @param {Number} The year. * @param {Number} The month (0-11). * @return {Number} The number of days in the month. */ $D.getDaysInMonth = function (year, month) { if (!month && $D.validateMonth(year)) { month = year; year = Date.today().getFullYear(); } return [31, ($D.isLeapYear(year) ? 29 : 28), 31, 30, 31, 30, 31, 31, 30, 31, 30, 31][month]; }; $P.getDaysInMonth = function () { return $D.getDaysInMonth(this.getFullYear(), this.getMonth()); }; $D.getTimezoneAbbreviation = function (offset, dst) { var p, n = (dst || false) ? Date.CultureInfo.abbreviatedTimeZoneDST : Date.CultureInfo.abbreviatedTimeZoneStandard; for (p in n) { if (n.hasOwnProperty(p)) { if (n[p] === offset) { return p; } } } return null; }; $D.getTimezoneOffset = function (name, dst) { var i, a =[], z = Date.CultureInfo.timezones; if (!name) { name = (new Date()).getTimezone();} for (i = 0; i < z.length; i++) { if (z[i].name === name.toUpperCase()) { a.push(i); } } if (!z[a[0]]) { return null; } if (a.length === 1 || !dst) { return z[a[0]].offset; } else { for (i=0; i < a.length; i++) { if (z[a[i]].dst) { return z[a[i]].offset; } } } }; $D.getQuarter = function (d) { d = d || new Date(); // If no date supplied, use today var q = [1,2,3,4]; return q[Math.floor(d.getMonth() / 3)]; // ~~~ is a bitwise op. Faster than Math.floor }; $D.getDaysLeftInQuarter = function (d) { d = d || new Date(); var qEnd = new Date(d); qEnd.setMonth(qEnd.getMonth() + 3 - qEnd.getMonth() % 3, 0); return Math.floor((qEnd - d) / 8.64e7); }; // private var validate = function (n, min, max, name) { name = name ? name : "Object"; if (typeof n === "undefined") { return false; } else if (typeof n !== "number") { throw new TypeError(n + " is not a Number."); } else if (n < min || n > max) { // As failing validation is *not* an exceptional circumstance // lets not throw a RangeError Exception here. // It's semantically correct but it's not sensible. return false; } return true; }; /** * Validates the number is within an acceptable range for milliseconds [0-999]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateMillisecond = function (value) { return validate(value, 0, 999, "millisecond"); }; /** * Validates the number is within an acceptable range for seconds [0-59]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateSecond = function (value) { return validate(value, 0, 59, "second"); }; /** * Validates the number is within an acceptable range for minutes [0-59]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateMinute = function (value) { return validate(value, 0, 59, "minute"); }; /** * Validates the number is within an acceptable range for hours [0-23]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateHour = function (value) { return validate(value, 0, 23, "hour"); }; /** * Validates the number is within an acceptable range for the days in a month [0-MaxDaysInMonth]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateDay = function (value, year, month) { if (year === undefined || year === null || month === undefined || month === null) { return false;} return validate(value, 1, $D.getDaysInMonth(year, month), "day"); }; /** * Validates the number is within an acceptable range for months [0-11]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateWeek = function (value) { return validate(value, 0, 53, "week"); }; /** * Validates the number is within an acceptable range for months [0-11]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateMonth = function (value) { return validate(value, 0, 11, "month"); }; /** * Validates the number is within an acceptable range for years. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateYear = function (value) { /** * Per ECMAScript spec the range of times supported by Date objects is * exactly -100,000,000 days to +100,000,000 days measured relative to * midnight at the beginning of 01 January, 1970 UTC. * This gives a range of 8,640,000,000,000,000 milliseconds to either * side of 01 January, 1970 UTC. * * Earliest possible date: Tue, 20 Apr 271,822 B.C. 00:00:00 UTC * Latest possible date: Sat, 13 Sep 275,760 00:00:00 UTC */ return validate(value, -271822, 275760, "year"); }; $D.validateTimezone = function(value) { var timezones = {"ACDT":1,"ACST":1,"ACT":1,"ADT":1,"AEDT":1,"AEST":1,"AFT":1,"AKDT":1,"AKST":1,"AMST":1,"AMT":1,"ART":1,"AST":1,"AWDT":1,"AWST":1,"AZOST":1,"AZT":1,"BDT":1,"BIOT":1,"BIT":1,"BOT":1,"BRT":1,"BST":1,"BTT":1,"CAT":1,"CCT":1,"CDT":1,"CEDT":1,"CEST":1,"CET":1,"CHADT":1,"CHAST":1,"CHOT":1,"ChST":1,"CHUT":1,"CIST":1,"CIT":1,"CKT":1,"CLST":1,"CLT":1,"COST":1,"COT":1,"CST":1,"CT":1,"CVT":1,"CWST":1,"CXT":1,"DAVT":1,"DDUT":1,"DFT":1,"EASST":1,"EAST":1,"EAT":1,"ECT":1,"EDT":1,"EEDT":1,"EEST":1,"EET":1,"EGST":1,"EGT":1,"EIT":1,"EST":1,"FET":1,"FJT":1,"FKST":1,"FKT":1,"FNT":1,"GALT":1,"GAMT":1,"GET":1,"GFT":1,"GILT":1,"GIT":1,"GMT":1,"GST":1,"GYT":1,"HADT":1,"HAEC":1,"HAST":1,"HKT":1,"HMT":1,"HOVT":1,"HST":1,"ICT":1,"IDT":1,"IOT":1,"IRDT":1,"IRKT":1,"IRST":1,"IST":1,"JST":1,"KGT":1,"KOST":1,"KRAT":1,"KST":1,"LHST":1,"LINT":1,"MAGT":1,"MART":1,"MAWT":1,"MDT":1,"MET":1,"MEST":1,"MHT":1,"MIST":1,"MIT":1,"MMT":1,"MSK":1,"MST":1,"MUT":1,"MVT":1,"MYT":1,"NCT":1,"NDT":1,"NFT":1,"NPT":1,"NST":1,"NT":1,"NUT":1,"NZDT":1,"NZST":1,"OMST":1,"ORAT":1,"PDT":1,"PET":1,"PETT":1,"PGT":1,"PHOT":1,"PHT":1,"PKT":1,"PMDT":1,"PMST":1,"PONT":1,"PST":1,"PYST":1,"PYT":1,"RET":1,"ROTT":1,"SAKT":1,"SAMT":1,"SAST":1,"SBT":1,"SCT":1,"SGT":1,"SLST":1,"SRT":1,"SST":1,"SYOT":1,"TAHT":1,"THA":1,"TFT":1,"TJT":1,"TKT":1,"TLT":1,"TMT":1,"TOT":1,"TVT":1,"UCT":1,"ULAT":1,"UTC":1,"UYST":1,"UYT":1,"UZT":1,"VET":1,"VLAT":1,"VOLT":1,"VOST":1,"VUT":1,"WAKT":1,"WAST":1,"WAT":1,"WEDT":1,"WEST":1,"WET":1,"WST":1,"YAKT":1,"YEKT":1,"Z":1}; return (timezones[value] === 1); }; $D.validateTimezoneOffset= function(value) { // timezones go from +14hrs to -12hrs, the +X hours are negative offsets. return (value > -841 && value < 721); }; }()); (function () { var $D = Date, $P = $D.prototype, p = function (s, l) { if (!l) { l = 2; } return ("000" + s).slice(l * -1); }; var validateConfigObject = function (obj) { var result = {}, self = this, prop, testFunc; testFunc = function (prop, func, value) { if (prop === "day") { var month = (obj.month !== undefined) ? obj.month : self.getMonth(); var year = (obj.year !== undefined) ? obj.year : self.getFullYear(); return $D[func](value, year, month); } else { return $D[func](value); } }; for (prop in obj) { if (Object.prototype.hasOwnProperty.call(obj, prop)) { var func = "validate" + prop.charAt(0).toUpperCase() + prop.slice(1); if ($D[func] && obj[prop] !== null && testFunc(prop, func, obj[prop])) { result[prop] = obj[prop]; } } } return result; }; /** * Resets the time of this Date object to 12:00 AM (00:00), which is the start of the day. * @param {Boolean} .clone() this date instance before clearing Time * @return {Date} this */ $P.clearTime = function () { this.setHours(0); this.setMinutes(0); this.setSeconds(0); this.setMilliseconds(0); return this; }; /** * Resets the time of this Date object to the current time ('now'). * @return {Date} this */ $P.setTimeToNow = function () { var n = new Date(); this.setHours(n.getHours()); this.setMinutes(n.getMinutes()); this.setSeconds(n.getSeconds()); this.setMilliseconds(n.getMilliseconds()); return this; }; /** * Returns a new Date object that is an exact date and time copy of the original instance. * @return {Date} A new Date instance */ $P.clone = function () { return new Date(this.getTime()); }; /** * Compares this instance to a Date object and returns an number indication of their relative values. * @param {Date} Date object to compare [Required] * @return {Number} -1 = this is lessthan date. 0 = values are equal. 1 = this is greaterthan date. */ $P.compareTo = function (date) { return Date.compare(this, date); }; /** * Compares this instance to another Date object and returns true if they are equal. * @param {Date} Date object to compare. If no date to compare, new Date() [now] is used. * @return {Boolean} true if dates are equal. false if they are not equal. */ $P.equals = function (date) { return Date.equals(this, (date !== undefined ? date : new Date())); }; /** * Determines if this instance is between a range of two dates or equal to either the start or end dates. * @param {Date} Start of range [Required] * @param {Date} End of range [Required] * @return {Boolean} true is this is between or equal to the start and end dates, else false */ $P.between = function (start, end) { return this.getTime() >= start.getTime() && this.getTime() <= end.getTime(); }; /** * Determines if this date occurs after the date to compare to. * @param {Date} Date object to compare. If no date to compare, new Date() ("now") is used. * @return {Boolean} true if this date instance is greater than the date to compare to (or "now"), otherwise false. */ $P.isAfter = function (date) { return this.compareTo(date || new Date()) === 1; }; /** * Determines if this date occurs before the date to compare to. * @param {Date} Date object to compare. If no date to compare, new Date() ("now") is used. * @return {Boolean} true if this date instance is less than the date to compare to (or "now"). */ $P.isBefore = function (date) { return (this.compareTo(date || new Date()) === -1); }; /** * Determines if the current Date instance occurs today. * @return {Boolean} true if this date instance is 'today', otherwise false. */ /** * Determines if the current Date instance occurs on the same Date as the supplied 'date'. * If no 'date' to compare to is provided, the current Date instance is compared to 'today'. * @param {date} Date object to compare. If no date to compare, the current Date ("now") is used. * @return {Boolean} true if this Date instance occurs on the same Day as the supplied 'date'. */ $P.isToday = $P.isSameDay = function (date) { return this.clone().clearTime().equals((date || new Date()).clone().clearTime()); }; /** * Adds the specified number of milliseconds to this instance. * @param {Number} The number of milliseconds to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addMilliseconds = function (value) { if (!value) { return this; } this.setTime(this.getTime() + value * 1); return this; }; /** * Adds the specified number of seconds to this instance. * @param {Number} The number of seconds to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addSeconds = function (value) { if (!value) { return this; } return this.addMilliseconds(value * 1000); }; /** * Adds the specified number of seconds to this instance. * @param {Number} The number of seconds to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addMinutes = function (value) { if (!value) { return this; } return this.addMilliseconds(value * 60000); // 60*1000 }; /** * Adds the specified number of hours to this instance. * @param {Number} The number of hours to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addHours = function (value) { if (!value) { return this; } return this.addMilliseconds(value * 3600000); // 60*60*1000 }; /** * Adds the specified number of days to this instance. * @param {Number} The number of days to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addDays = function (value) { if (!value) { return this; } this.setDate(this.getDate() + value * 1); return this; }; /** * Adds the specified number of weekdays (ie - not sat or sun) to this instance. * @param {Number} The number of days to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addWeekdays = function (value) { if (!value) { return this; } var day = this.getDay(); var weeks = (Math.ceil(Math.abs(value)/7)); if (day === 0 || day === 6) { if (value > 0) { this.next().monday(); this.addDays(-1); day = this.getDay(); } } if (value < 0) { while (value < 0) { this.addDays(-1); day = this.getDay(); if (day !== 0 && day !== 6) { value++; } } return this; } else if (value > 5 || (6-day) <= value) { value = value + (weeks * 2); } return this.addDays(value); }; /** * Adds the specified number of weeks to this instance. * @param {Number} The number of weeks to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addWeeks = function (value) { if (!value) { return this; } return this.addDays(value * 7); }; /** * Adds the specified number of months to this instance. * @param {Number} The number of months to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addMonths = function (value) { if (!value) { return this; } var n = this.getDate(); this.setDate(1); this.setMonth(this.getMonth() + value * 1); this.setDate(Math.min(n, $D.getDaysInMonth(this.getFullYear(), this.getMonth()))); return this; }; $P.addQuarters = function (value) { if (!value) { return this; } // note this will take you to the same point in the quarter as you are now. // i.e. - if you are 15 days into the quarter you'll be 15 days into the resulting one. // bonus: this allows adding fractional quarters return this.addMonths(value * 3); }; /** * Adds the specified number of years to this instance. * @param {Number} The number of years to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addYears = function (value) { if (!value) { return this; } return this.addMonths(value * 12); }; /** * Adds (or subtracts) to the value of the years, months, weeks, days, hours, minutes, seconds, milliseconds of the date instance using given configuration object. Positive and Negative values allowed. * Example

	Date.today().add( { days: 1, months: 1 } )

	new Date().add( { years: -1 } )
	
* @param {Object} Configuration object containing attributes (months, days, etc.) * @return {Date} this */ $P.add = function (config) { if (typeof config === "number") { this._orient = config; return this; } var x = config; if (x.day) { // If we should be a different date than today (eg: for 'tomorrow -1d', etc). // Should only effect parsing, not direct usage (eg, Finish and FinishExact) if ((x.day - this.getDate()) !== 0) { this.setDate(x.day); } } if (x.milliseconds) { this.addMilliseconds(x.milliseconds); } if (x.seconds) { this.addSeconds(x.seconds); } if (x.minutes) { this.addMinutes(x.minutes); } if (x.hours) { this.addHours(x.hours); } if (x.weeks) { this.addWeeks(x.weeks); } if (x.months) { this.addMonths(x.months); } if (x.years) { this.addYears(x.years); } if (x.days) { this.addDays(x.days); } return this; }; /** * Get the week number. Week one (1) is the week which contains the first Thursday of the year. Monday is considered the first day of the week. * The .getWeek() function does NOT convert the date to UTC. The local datetime is used. * Please use .getISOWeek() to get the week of the UTC converted date. * @return {Number} 1 to 53 */ $P.getWeek = function (utc) { // Create a copy of this date object var self, target = new Date(this.valueOf()); if (utc) { target.addMinutes(target.getTimezoneOffset()); self = target.clone(); } else { self = this; } // ISO week date weeks start on monday // so correct the day number var dayNr = (self.getDay() + 6) % 7; // ISO 8601 states that week 1 is the week // with the first thursday of that year. // Set the target date to the thursday in the target week target.setDate(target.getDate() - dayNr + 3); // Store the millisecond value of the target date var firstThursday = target.valueOf(); // Set the target to the first thursday of the year // First set the target to january first target.setMonth(0, 1); // Not a thursday? Correct the date to the next thursday if (target.getDay() !== 4) { target.setMonth(0, 1 + ((4 - target.getDay()) + 7) % 7); } // The weeknumber is the number of weeks between the // first thursday of the year and the thursday in the target week return 1 + Math.ceil((firstThursday - target) / 604800000); // 604800000 = 7 * 24 * 3600 * 1000 }; /** * Get the ISO 8601 week number. Week one ("01") is the week which contains the first Thursday of the year. Monday is considered the first day of the week. * The .getISOWeek() function does convert the date to it's UTC value. Please use .getWeek() to get the week of the local date. * @return {String} "01" to "53" */ $P.getISOWeek = function () { return p(this.getWeek(true)); }; /** * Moves the date to Monday of the week set. Week one (1) is the week which contains the first Thursday of the year. * @param {Number} A Number (1 to 53) that represents the week of the year. * @return {Date} this */ $P.setWeek = function (n) { if ((n - this.getWeek()) === 0) { if (this.getDay() !== 1) { return this.moveToDayOfWeek(1, (this.getDay() > 1 ? -1 : 1)); } else { return this; } } else { return this.moveToDayOfWeek(1, (this.getDay() > 1 ? -1 : 1)).addWeeks(n - this.getWeek()); } }; $P.setQuarter = function (qtr) { var month = Math.abs(((qtr-1) * 3) + 1); return this.setMonth(month, 1); }; $P.getQuarter = function () { return Date.getQuarter(this); }; $P.getDaysLeftInQuarter = function () { return Date.getDaysLeftInQuarter(this); }; /** * Moves the date to the next n'th occurrence of the dayOfWeek starting from the beginning of the month. The number (-1) is a magic number and will return the last occurrence of the dayOfWeek in the month. * @param {Number} The dayOfWeek to move to * @param {Number} The n'th occurrence to move to. Use (-1) to return the last occurrence in the month * @return {Date} this */ $P.moveToNthOccurrence = function (dayOfWeek, occurrence) { if (dayOfWeek === "Weekday") { if (occurrence > 0) { this.moveToFirstDayOfMonth(); if (this.is().weekday()) { occurrence -= 1; } } else if (occurrence < 0) { this.moveToLastDayOfMonth(); if (this.is().weekday()) { occurrence += 1; } } else { return this; } return this.addWeekdays(occurrence); } var shift = 0; if (occurrence > 0) { shift = occurrence - 1; } else if (occurrence === -1) { this.moveToLastDayOfMonth(); if (this.getDay() !== dayOfWeek) { this.moveToDayOfWeek(dayOfWeek, -1); } return this; } return this.moveToFirstDayOfMonth().addDays(-1).moveToDayOfWeek(dayOfWeek, +1).addWeeks(shift); }; var moveToN = function (getFunc, addFunc, nVal) { return function (value, orient) { var diff = (value - this[getFunc]() + nVal * (orient || +1)) % nVal; return this[addFunc]((diff === 0) ? diff += nVal * (orient || +1) : diff); }; }; /** * Move to the next or last dayOfWeek based on the orient value. * @param {Number} The dayOfWeek to move to * @param {Number} Forward (+1) or Back (-1). Defaults to +1. [Optional] * @return {Date} this */ $P.moveToDayOfWeek = moveToN("getDay", "addDays", 7); /** * Move to the next or last month based on the orient value. * @param {Number} The month to move to. 0 = January, 11 = December * @param {Number} Forward (+1) or Back (-1). Defaults to +1. [Optional] * @return {Date} this */ $P.moveToMonth = moveToN("getMonth", "addMonths", 12); /** * Get the Ordinate of the current day ("th", "st", "rd"). * @return {String} */ $P.getOrdinate = function () { var num = this.getDate(); return ord(num); }; /** * Get the Ordinal day (numeric day number) of the year, adjusted for leap year. * @return {Number} 1 through 365 (366 in leap years) */ $P.getOrdinalNumber = function () { return Math.ceil((this.clone().clearTime() - new Date(this.getFullYear(), 0, 1)) / 86400000) + 1; }; /** * Get the time zone abbreviation of the current date. * @return {String} The abbreviated time zone name (e.g. "EST") */ $P.getTimezone = function () { return $D.getTimezoneAbbreviation(this.getUTCOffset(), this.isDaylightSavingTime()); }; $P.setTimezoneOffset = function (offset) { var here = this.getTimezoneOffset(), there = Number(offset) * -6 / 10; return (there || there === 0) ? this.addMinutes(there - here) : this; }; $P.setTimezone = function (offset) { return this.setTimezoneOffset($D.getTimezoneOffset(offset)); }; /** * Indicates whether Daylight Saving Time is observed in the current time zone. * @return {Boolean} true|false */ $P.hasDaylightSavingTime = function () { return (Date.today().set({month: 0, day: 1}).getTimezoneOffset() !== Date.today().set({month: 6, day: 1}).getTimezoneOffset()); }; /** * Indicates whether this Date instance is within the Daylight Saving Time range for the current time zone. * @return {Boolean} true|false */ $P.isDaylightSavingTime = function () { return Date.today().set({month: 0, day: 1}).getTimezoneOffset() !== this.getTimezoneOffset(); }; /** * Get the offset from UTC of the current date. * @return {String} The 4-character offset string prefixed with + or - (e.g. "-0500") */ $P.getUTCOffset = function (offset) { var n = (offset || this.getTimezoneOffset()) * -10 / 6, r; if (n < 0) { r = (n - 10000).toString(); return r.charAt(0) + r.substr(2); } else { r = (n + 10000).toString(); return "+" + r.substr(1); } }; /** * Returns the number of milliseconds between this date and date. * @param {Date} Defaults to now * @return {Number} The diff in milliseconds */ $P.getElapsed = function (date) { return (date || new Date()) - this; }; /** * Set the value of year, month, day, hour, minute, second, millisecond of date instance using given configuration object. * Example

	Date.today().set( { day: 20, month: 1 } )

	new Date().set( { millisecond: 0 } )
	
* * @param {Object} Configuration object containing attributes (month, day, etc.) * @return {Date} this */ $P.set = function (config) { config = validateConfigObject.call(this, config); var key; for (key in config) { if (Object.prototype.hasOwnProperty.call(config, key)) { var name = key.charAt(0).toUpperCase() + key.slice(1); var addFunc, getFunc; if (key !== "week" && key !== "month" && key !== "timezone" && key !== "timezoneOffset") { name += "s"; } addFunc = "add" + name; getFunc = "get" + name; if (key === "month") { addFunc = addFunc + "s"; } else if (key === "year"){ getFunc = "getFullYear"; } if (key !== "day" && key !== "timezone" && key !== "timezoneOffset" && key !== "week" && key !== "hour") { this[addFunc](config[key] - this[getFunc]()); } else if ( key === "timezone"|| key === "timezoneOffset" || key === "week" || key === "hour") { this["set"+name](config[key]); } } } // day has to go last because you can't validate the day without first knowing the month if (config.day) { this.addDays(config.day - this.getDate()); } return this; }; /** * Moves the date to the first day of the month. * @return {Date} this */ $P.moveToFirstDayOfMonth = function () { return this.set({ day: 1 }); }; /** * Moves the date to the last day of the month. * @return {Date} this */ $P.moveToLastDayOfMonth = function () { return this.set({ day: $D.getDaysInMonth(this.getFullYear(), this.getMonth())}); }; /** * Converts the value of the current Date object to its equivalent string representation. * Format Specifiers * CUSTOM DATE AND TIME FORMAT STRINGS * Format Description Example * ------ --------------------------------------------------------------------------- ----------------------- * s The seconds of the minute between 0-59. "0" to "59" * ss The seconds of the minute with leading zero if required. "00" to "59" * * m The minute of the hour between 0-59. "0" or "59" * mm The minute of the hour with leading zero if required. "00" or "59" * * h The hour of the day between 1-12. "1" to "12" * hh The hour of the day with leading zero if required. "01" to "12" * * H The hour of the day between 0-23. "0" to "23" * HH The hour of the day with leading zero if required. "00" to "23" * * d The day of the month between 1 and 31. "1" to "31" * dd The day of the month with leading zero if required. "01" to "31" * ddd Abbreviated day name. Date.CultureInfo.abbreviatedDayNames. "Mon" to "Sun" * dddd The full day name. Date.CultureInfo.dayNames. "Monday" to "Sunday" * * M The month of the year between 1-12. "1" to "12" * MM The month of the year with leading zero if required. "01" to "12" * MMM Abbreviated month name. Date.CultureInfo.abbreviatedMonthNames. "Jan" to "Dec" * MMMM The full month name. Date.CultureInfo.monthNames. "January" to "December" * * yy The year as a two-digit number. "99" or "08" * yyyy The full four digit year. "1999" or "2008" * * t Displays the first character of the A.M./P.M. designator. "A" or "P" * Date.CultureInfo.amDesignator or Date.CultureInfo.pmDesignator * tt Displays the A.M./P.M. designator. "AM" or "PM" * Date.CultureInfo.amDesignator or Date.CultureInfo.pmDesignator * * S The ordinal suffix ("st, "nd", "rd" or "th") of the current day. "st, "nd", "rd" or "th" * * STANDARD DATE AND TIME FORMAT STRINGS * Format Description Example *------ --------------------------------------------------------------------------- ----------------------- * d The CultureInfo shortDate Format Pattern "M/d/yyyy" * D The CultureInfo longDate Format Pattern "dddd, MMMM dd, yyyy" * F The CultureInfo fullDateTime Format Pattern "dddd, MMMM dd, yyyy h:mm:ss tt" * m The CultureInfo monthDay Format Pattern "MMMM dd" * r The CultureInfo rfc1123 Format Pattern "ddd, dd MMM yyyy HH:mm:ss GMT" * s The CultureInfo sortableDateTime Format Pattern "yyyy-MM-ddTHH:mm:ss" * t The CultureInfo shortTime Format Pattern "h:mm tt" * T The CultureInfo longTime Format Pattern "h:mm:ss tt" * u The CultureInfo universalSortableDateTime Format Pattern "yyyy-MM-dd HH:mm:ssZ" * y The CultureInfo yearMonth Format Pattern "MMMM, yyyy" * * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @return {String} A string representation of the current Date object. */ var ord = function (n) { switch (n * 1) { case 1: case 21: case 31: return "st"; case 2: case 22: return "nd"; case 3: case 23: return "rd"; default: return "th"; } }; var parseStandardFormats = function (format) { var y, c = Date.CultureInfo.formatPatterns; switch (format) { case "d": return this.toString(c.shortDate); case "D": return this.toString(c.longDate); case "F": return this.toString(c.fullDateTime); case "m": return this.toString(c.monthDay); case "r": case "R": y = this.clone().addMinutes(this.getTimezoneOffset()); return y.toString(c.rfc1123) + " GMT"; case "s": return this.toString(c.sortableDateTime); case "t": return this.toString(c.shortTime); case "T": return this.toString(c.longTime); case "u": y = this.clone().addMinutes(this.getTimezoneOffset()); return y.toString(c.universalSortableDateTime); case "y": return this.toString(c.yearMonth); default: return false; } }; var parseFormatStringsClosure = function (context) { return function (m) { if (m.charAt(0) === "\\") { return m.replace("\\", ""); } switch (m) { case "hh": return p(context.getHours() < 13 ? (context.getHours() === 0 ? 12 : context.getHours()) : (context.getHours() - 12)); case "h": return context.getHours() < 13 ? (context.getHours() === 0 ? 12 : context.getHours()) : (context.getHours() - 12); case "HH": return p(context.getHours()); case "H": return context.getHours(); case "mm": return p(context.getMinutes()); case "m": return context.getMinutes(); case "ss": return p(context.getSeconds()); case "s": return context.getSeconds(); case "yyyy": return p(context.getFullYear(), 4); case "yy": return p(context.getFullYear()); case "y": return context.getFullYear(); case "E": case "dddd": return Date.CultureInfo.dayNames[context.getDay()]; case "ddd": return Date.CultureInfo.abbreviatedDayNames[context.getDay()]; case "dd": return p(context.getDate()); case "d": return context.getDate(); case "MMMM": return Date.CultureInfo.monthNames[context.getMonth()]; case "MMM": return Date.CultureInfo.abbreviatedMonthNames[context.getMonth()]; case "MM": return p((context.getMonth() + 1)); case "M": return context.getMonth() + 1; case "t": return context.getHours() < 12 ? Date.CultureInfo.amDesignator.substring(0, 1) : Date.CultureInfo.pmDesignator.substring(0, 1); case "tt": return context.getHours() < 12 ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator; case "S": return ord(context.getDate()); case "W": return context.getWeek(); case "WW": return context.getISOWeek(); case "Q": return "Q" + context.getQuarter(); case "q": return String(context.getQuarter()); case "z": return context.getTimezone(); case "Z": case "X": return Date.getTimezoneOffset(context.getTimezone()); case "ZZ": // Timezone offset in seconds return context.getTimezoneOffset() * -60; case "u": return context.getDay(); case "L": return ($D.isLeapYear(context.getFullYear())) ? 1 : 0; case "B": // Swatch Internet Time (.beats) return "@"+((context.getUTCSeconds() + (context.getUTCMinutes()*60) + ((context.getUTCHours()+1)*3600))/86.4); default: return m; } }; }; $P.toString = function (format, ignoreStandards) { // Standard Date and Time Format Strings. Formats pulled from CultureInfo file and // may vary by culture. if (!ignoreStandards && format && format.length === 1) { output = parseStandardFormats.call(this, format); if (output) { return output; } } var parseFormatStrings = parseFormatStringsClosure(this); return format ? format.replace(/((\\)?(dd?d?d?|MM?M?M?|yy?y?y?|hh?|HH?|mm?|ss?|tt?|S|q|Q|WW?W?W?)(?![^\[]*\]))/g, parseFormatStrings).replace(/\[|\]/g, "") : this._toString(); }; }()); /************************************************************* * SugarPak - Domain Specific Language - Syntactical Sugar * *************************************************************/ (function () { var $D = Date, $P = $D.prototype, $N = Number.prototype; // private $P._orient = +1; // private $P._nth = null; // private $P._is = false; // private $P._same = false; // private $P._isSecond = false; // private $N._dateElement = "days"; /** * Moves the date to the next instance of a date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.today().next().friday();
	Date.today().next().fri();
	Date.today().next().march();
	Date.today().next().mar();
	Date.today().next().week();
	
* * @return {Date} date */ $P.next = function () { this._move = true; this._orient = +1; return this; }; /** * Creates a new Date (Date.today()) and moves the date to the next instance of the date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.next().friday();
	Date.next().fri();
	Date.next().march();
	Date.next().mar();
	Date.next().week();
	
* * @return {Date} date */ $D.next = function () { return $D.today().next(); }; /** * Moves the date to the previous instance of a date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.today().last().friday();
	Date.today().last().fri();
	Date.today().last().march();
	Date.today().last().mar();
	Date.today().last().week();
	
* * @return {Date} date */ $P.last = $P.prev = $P.previous = function () { this._move = true; this._orient = -1; return this; }; /** * Creates a new Date (Date.today()) and moves the date to the previous instance of the date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.last().friday();
	Date.last().fri();
	Date.previous().march();
	Date.prev().mar();
	Date.last().week();
	
* * @return {Date} date */ $D.last = $D.prev = $D.previous = function () { return $D.today().last(); }; /** * Performs a equality check when followed by either a month name, day name or .weekday() function. * Example

	Date.today().is().friday(); // true|false
	Date.today().is().fri();
	Date.today().is().march();
	Date.today().is().mar();
	
* * @return {Boolean} true|false */ $P.is = function () { this._is = true; return this; }; /** * Determines if two date objects occur on/in exactly the same instance of the subsequent date part function. * The function .same() must be followed by a date part function (example: .day(), .month(), .year(), etc). * * An optional Date can be passed in the date part function. If now date is passed as a parameter, 'Now' is used. * * The following example demonstrates how to determine if two dates fall on the exact same day. * * Example

	var d1 = Date.today(); // today at 00:00
	var d2 = new Date();   // exactly now.

	// Do they occur on the same day?
	d1.same().day(d2); // true
	
	// Do they occur on the same hour?
	d1.same().hour(d2); // false, unless d2 hour is '00' (midnight).
	
	// What if it's the same day, but one year apart?
	var nextYear = Date.today().add(1).year();

	d1.same().day(nextYear); // false, because the dates must occur on the exact same day. 
	
* * Scenario: Determine if a given date occurs during some week period 2 months from now. * * Example

	var future = Date.today().add(2).months();
	return someDate.same().week(future); // true|false;
	
* * @return {Boolean} true|false */ $P.same = function () { this._same = true; this._isSecond = false; return this; }; /** * Determines if the current date/time occurs during Today. Must be preceded by the .is() function. * Example

	someDate.is().today();    // true|false
	new Date().is().today();  // true
	Date.today().is().today();// true
	Date.today().add(-1).day().is().today(); // false
	
* * @return {Boolean} true|false */ $P.today = function () { return this.same().day(); }; /** * Determines if the current date is a weekday. This function must be preceded by the .is() function. * Example

	Date.today().is().weekday(); // true|false
	
* * @return {Boolean} true|false */ $P.weekday = function () { if (this._nth) { return df("Weekday").call(this); } if (this._move) { return this.addWeekdays(this._orient); } if (this._is) { this._is = false; return (!this.is().sat() && !this.is().sun()); } return false; }; /** * Determines if the current date is on the weekend. This function must be preceded by the .is() function. * Example

	Date.today().is().weekend(); // true|false
	
* * @return {Boolean} true|false */ $P.weekend = function () { if (this._is) { this._is = false; return (this.is().sat() || this.is().sun()); } return false; }; /** * Sets the Time of the current Date instance. A string "6:15 pm" or config object {hour:18, minute:15} are accepted. * Example

	// Set time to 6:15pm with a String
	Date.today().at("6:15pm");

	// Set time to 6:15pm with a config object
	Date.today().at({hour:18, minute:15});
	
* * @return {Date} date */ $P.at = function (time) { return (typeof time === "string") ? $D.parse(this.toString("d") + " " + time) : this.set(time); }; /** * Creates a new Date() and adds this (Number) to the date based on the preceding date element function (eg. second|minute|hour|day|month|year). * Example

	// Undeclared Numbers must be wrapped with parentheses. Requirment of JavaScript.
	(3).days().fromNow();
	(6).months().fromNow();

	// Declared Number variables do not require parentheses. 
	var n = 6;
	n.months().fromNow();
	
* * @return {Date} A new Date instance */ $N.fromNow = $N.after = function (date) { var c = {}; c[this._dateElement] = this; return ((!date) ? new Date() : date.clone()).add(c); }; /** * Creates a new Date() and subtract this (Number) from the date based on the preceding date element function (eg. second|minute|hour|day|month|year). * Example

	// Undeclared Numbers must be wrapped with parentheses. Requirment of JavaScript.
	(3).days().ago();
	(6).months().ago();

	// Declared Number variables do not require parentheses. 
	var n = 6;
	n.months().ago();
	
* * @return {Date} A new Date instance */ $N.ago = $N.before = function (date) { var c = {}, s = (this._dateElement[this._dateElement.length-1] !== "s") ? this._dateElement + "s" : this._dateElement; c[s] = this * -1; return ((!date) ? new Date() : date.clone()).add(c); }; // Do NOT modify the following string tokens. These tokens are used to build dynamic functions. // All culture-specific strings can be found in the CultureInfo files. var dx = ("sunday monday tuesday wednesday thursday friday saturday").split(/\s/), mx = ("january february march april may june july august september october november december").split(/\s/), px = ("Millisecond Second Minute Hour Day Week Month Year Quarter Weekday").split(/\s/), pxf = ("Milliseconds Seconds Minutes Hours Date Week Month FullYear Quarter").split(/\s/), nth = ("final first second third fourth fifth").split(/\s/), de; /** * Returns an object literal of all the date parts. * Example

	var o = new Date().toObject();
	
	// { year: 2008, month: 4, week: 20, day: 13, hour: 18, minute: 9, second: 32, millisecond: 812 }
	
	// The object properties can be referenced directly from the object.
	
	alert(o.day);  // alerts "13"
	alert(o.year); // alerts "2008"
	
* * @return {Date} An object literal representing the original date object. */ $P.toObject = function () { var o = {}; for (var i = 0; i < px.length; i++) { if (this["get" + pxf[i]]) { o[px[i].toLowerCase()] = this["get" + pxf[i]](); } } return o; }; /** * Returns a date created from an object literal. Ignores the .week property if set in the config. * Example

	var o = new Date().toObject();
	
	return Date.fromObject(o); // will return the same date. 

	var o2 = {month: 1, day: 20, hour: 18}; // birthday party!
	Date.fromObject(o2);
	
* * @return {Date} An object literal representing the original date object. */ $D.fromObject = function(config) { config.week = null; return Date.today().set(config); }; // Create day name functions and abbreviated day name functions (eg. monday(), friday(), fri()). var df = function (n) { return function () { if (this._is) { this._is = false; return this.getDay() === n; } if (this._move) { this._move = null; } if (this._nth !== null) { // If the .second() function was called earlier, remove the _orient // from the date, and then continue. // This is required because 'second' can be used in two different context. // // Example // // Date.today().add(1).second(); // Date.march().second().monday(); // // Things get crazy with the following... // Date.march().add(1).second().second().monday(); // but it works!! // if (this._isSecond) { this.addSeconds(this._orient * -1); } // make sure we reset _isSecond this._isSecond = false; var ntemp = this._nth; this._nth = null; var temp = this.clone().moveToLastDayOfMonth(); this.moveToNthOccurrence(n, ntemp); if (this > temp) { throw new RangeError($D.getDayName(n) + " does not occur " + ntemp + " times in the month of " + $D.getMonthName(temp.getMonth()) + " " + temp.getFullYear() + "."); } return this; } return this.moveToDayOfWeek(n, this._orient); }; }; var sdf = function (n) { return function () { var t = $D.today(), shift = n - t.getDay(); if (n === 0 && Date.CultureInfo.firstDayOfWeek === 1 && t.getDay() !== 0) { shift = shift + 7; } return t.addDays(shift); }; }; // Create month name functions and abbreviated month name functions (eg. january(), march(), mar()). var month_instance_functions = function (n) { return function () { if (this._is) { this._is = false; return this.getMonth() === n; } return this.moveToMonth(n, this._orient); }; }; var month_static_functions = function (n) { return function () { return $D.today().set({ month: n, day: 1 }); }; }; var processTerms = function (names, staticFunc, instanceFunc) { for (var i = 0; i < names.length; i++) { // Create constant static Name variables. $D[names[i].toUpperCase()] = $D[names[i].toUpperCase().substring(0, 3)] = i; // Create Name functions. $D[names[i]] = $D[names[i].substring(0, 3)] = staticFunc(i); // Create Name instance functions. $P[names[i]] = $P[names[i].substring(0, 3)] = instanceFunc(i); } }; processTerms(dx, sdf, df); processTerms(mx, month_static_functions, month_instance_functions); // Create date element functions and plural date element functions used with Date (eg. day(), days(), months()). var ef = function (j) { return function () { // if the .second() function was called earlier, the _orient // has alread been added. Just return this and reset _isSecond. if (this._isSecond) { this._isSecond = false; return this; } if (this._same) { this._same = this._is = false; var o1 = this.toObject(), o2 = (arguments[0] || new Date()).toObject(), v = "", k = j.toLowerCase(); // the substr trick with -1 doesn't work in IE8 or less k = (k[k.length-1] === "s") ? k.substring(0,k.length-1) : k; for (var m = (px.length - 1); m > -1; m--) { v = px[m].toLowerCase(); if (o1[v] !== o2[v]) { return false; } if (k === v) { break; } } return true; } if (j.substring(j.length - 1) !== "s") { j += "s"; } if (this._move) { this._move = null; } return this["add" + j](this._orient); }; }; var nf = function (n) { return function () { this._dateElement = n; return this; }; }; for (var k = 0; k < px.length; k++) { de = px[k].toLowerCase(); if(de !== "weekday") { // Create date element functions and plural date element functions used with Date (eg. day(), days(), months()). $P[de] = $P[de + "s"] = ef(px[k]); // Create date element functions and plural date element functions used with Number (eg. day(), days(), months()). $N[de] = $N[de + "s"] = nf(de + "s"); } } $P._ss = ef("Second"); var nthfn = function (n) { return function (dayOfWeek) { if (this._same) { return this._ss(arguments[0]); } if (dayOfWeek || dayOfWeek === 0) { return this.moveToNthOccurrence(dayOfWeek, n); } this._nth = n; // if the operator is 'second' add the _orient, then deal with it later... if (n === 2 && (dayOfWeek === undefined || dayOfWeek === null)) { this._isSecond = true; return this.addSeconds(this._orient); } return this; }; }; for (var l = 0; l < nth.length; l++) { $P[nth[l]] = (l === 0) ? nthfn(-1) : nthfn(l); } }()); (function () { "use strict"; Date.Parsing = { Exception: function (s) { this.message = "Parse error at '" + s.substring(0, 10) + " ...'"; } }; var $P = Date.Parsing; var dayOffsets = { standard: [0,31,59,90,120,151,181,212,243,273,304,334], leap: [0,31,60,91,121,152,182,213,244,274,305,335] }; $P.isLeapYear = function(year) { return ((year % 4 === 0) && (year % 100 !== 0)) || (year % 400 === 0); }; var utils = { multiReplace : function (str, hash ) { var key; for (key in hash) { if (Object.prototype.hasOwnProperty.call(hash, key)) { var regex; if (typeof hash[key] === "function") { } else { regex = (hash[key] instanceof RegExp) ? hash[key] : new RegExp(hash[key], "g"); } str = str.replace(regex, key); } } return str; }, getDayOfYearFromWeek : function (obj) { var d, jan4, offset; obj.weekDay = (!obj.weekDay && obj.weekDay !== 0) ? 1 : obj.weekDay; d = new Date(obj.year, 0, 4); jan4 = d.getDay() === 0 ? 7 : d.getDay(); // JS is 0 indexed on Sunday. offset = jan4+3; obj.dayOfYear = ((obj.week * 7) + (obj.weekDay === 0 ? 7 : obj.weekDay))-offset; return obj; }, getDayOfYear : function (obj, dayOffset) { if (!obj.dayOfYear) { obj = utils.getDayOfYearFromWeek(obj); } for (var i=0;i <= dayOffset.length;i++) { if (obj.dayOfYear < dayOffset[i] || i === dayOffset.length) { obj.day = obj.day ? obj.day : (obj.dayOfYear - dayOffset[i-1]); break; } else { obj.month = i; } } return obj; }, adjustForTimeZone : function (obj, date) { var offset; if (obj.zone.toUpperCase() === "Z" || (obj.zone_hours === 0 && obj.zone_minutes === 0)) { // it's UTC/GML so work out the current timeszone offset offset = -date.getTimezoneOffset(); } else { offset = (obj.zone_hours*60) + (obj.zone_minutes || 0); if (obj.zone_sign === "+") { offset *= -1; } offset -= date.getTimezoneOffset(); } date.setMinutes(date.getMinutes()+offset); return date; }, setDefaults : function (obj) { obj.year = obj.year || Date.today().getFullYear(); obj.hours = obj.hours || 0; obj.minutes = obj.minutes || 0; obj.seconds = obj.seconds || 0; obj.milliseconds = obj.milliseconds || 0; if (!(!obj.month && (obj.week || obj.dayOfYear))) { // if we have a month, or if we don't but don't have the day calculation data obj.month = obj.month || 0; obj.day = obj.day || 1; } return obj; }, dataNum: function (data, mod, explict, postProcess) { var dataNum = data*1; if (mod) { if (postProcess) { return data ? mod(data)*1 : data; } else { return data ? mod(dataNum) : data; } } else if (!explict){ return data ? dataNum : data; } else { return (data && typeof data !== "undefined") ? dataNum : data; } }, timeDataProcess: function (obj) { var timeObj = {}; for (var x in obj.data) { if (obj.data.hasOwnProperty(x)) { timeObj[x] = obj.ignore[x] ? obj.data[x] : utils.dataNum(obj.data[x], obj.mods[x], obj.explict[x], obj.postProcess[x]); } } if (obj.data.secmins) { obj.data.secmins = obj.data.secmins.replace(",", ".") * 60; if (!timeObj.minutes) { timeObj.minutes = obj.data.secmins; } else if (!timeObj.seconds) { timeObj.seconds = obj.data.secmins; } delete obj.secmins; } return timeObj; }, buildTimeObjectFromData: function (data) { var time = utils.timeDataProcess({ data: { year : data[1], month : data[5], day : data[7], week : data[8], dayOfYear : data[10], hours : data[15], zone_hours : data[23], zone_minutes : data[24], zone : data[21], zone_sign : data[22], weekDay : data[9], minutes: data[16], seconds: data[19], milliseconds: data[20], secmins: data[18] }, mods: { month: function(data) { return data-1; }, weekDay: function (data) { data = Math.abs(data); return (data === 7 ? 0 : data); }, minutes: function (data) { return data.replace(":",""); }, seconds: function (data) { return Math.floor( (data.replace(":","").replace(",","."))*1 ); }, milliseconds: function (data) { return (data.replace(",",".")*1000); } }, postProcess: { minutes: true, seconds: true, milliseconds: true }, explict: { zone_hours: true, zone_minutes: true }, ignore: { zone: true, zone_sign: true, secmins: true } }); return time; }, addToHash: function (hash, keys, data) { keys = keys; data = data; var len = keys.length; for (var i = 0; i < len; i++) { hash[keys[i]] = data[i]; } return hash; }, combineRegex: function (r1, r2) { return new RegExp("(("+r1.source+")\\s("+r2.source+"))"); }, getDateNthString: function(add, last, inc){ if (add) { return Date.today().addDays(inc).toString("d"); } else if (last) { return Date.today().last()[inc]().toString("d"); } }, buildRegexData: function (array) { var arr = []; var len = array.length; for (var i=0; i < len; i++) { if (Object.prototype.toString.call(array[i]) === '[object Array]') { // oldIE compat version of Array.isArray arr.push(this.combineRegex(array[i][0], array[i][1])); } else { arr.push(array[i]); } } return arr; } }; $P.processTimeObject = function (obj) { var date, dayOffset; utils.setDefaults(obj); dayOffset = ($P.isLeapYear(obj.year)) ? dayOffsets.leap : dayOffsets.standard; if (!obj.month && (obj.week || obj.dayOfYear)) { utils.getDayOfYear(obj, dayOffset); } else { obj.dayOfYear = dayOffset[obj.month] + obj.day; } date = new Date(obj.year, obj.month, obj.day, obj.hours, obj.minutes, obj.seconds, obj.milliseconds); if (obj.zone) { utils.adjustForTimeZone(obj, date); // adjust (and calculate) for timezone } return date; }; $P.ISO = { regex : /^([\+-]?\d{4}(?!\d{2}\b))((-?)((0[1-9]|1[0-2])(\3([12]\d|0[1-9]|3[01]))?|W([0-4]\d|5[0-3])(-?[1-7])?|(00[1-9]|0[1-9]\d|[12]\d{2}|3([0-5]\d|6[1-6])))([T\s]((([01]\d|2[0-4])((:?)[0-5]\d)?|24\:?00)([\.,]\d+(?!:))?)?(\17[0-5]\d([\.,]\d+)?)?\s?([zZ]|([\+-])([01]\d|2[0-3]):?([0-5]\d)?)?)?)?$/, parse : function (s) { var time, data = s.match(this.regex); if (!data || !data.length) { return null; } time = utils.buildTimeObjectFromData(data); if (!time.year || (!time.year && (!time.month && !time.day) && (!time.week && !time.dayOfYear)) ) { return null; } return $P.processTimeObject(time); } }; $P.Numeric = { isNumeric: function (e){return!isNaN(parseFloat(e))&&isFinite(e);}, regex: /\b([0-1]?[0-9])([0-3]?[0-9])([0-2]?[0-9]?[0-9][0-9])\b/i, parse: function (s) { var data, i, time = {}, order = Date.CultureInfo.dateElementOrder.split(""); if (!(this.isNumeric(s)) || // if it's non-numeric OR (s[0] === "+" && s[0] === "-")) { // It's an arithmatic string (eg +/-1000) return null; } if (s.length < 5 && s.indexOf(".") < 0 && s.indexOf("/") < 0) { // assume it's just a year. time.year = s; return $P.processTimeObject(time); } data = s.match(this.regex); if (!data || !data.length) { return null; } for (i=0; i < order.length; i++) { switch(order[i]) { case "d": time.day = data[i+1]; break; case "m": time.month = (data[i+1]-1); break; case "y": time.year = data[i+1]; break; } } return $P.processTimeObject(time); } }; $P.Normalizer = { regexData: function () { var $R = Date.CultureInfo.regexPatterns; return utils.buildRegexData([ $R.tomorrow, $R.yesterday, [$R.past, $R.mon], [$R.past, $R.tue], [$R.past, $R.wed], [$R.past, $R.thu], [$R.past, $R.fri], [$R.past, $R.sat], [$R.past, $R.sun] ]); }, basicReplaceHash : function() { var $R = Date.CultureInfo.regexPatterns; return { "January": $R.jan.source, "February": $R.feb, "March": $R.mar, "April": $R.apr, "May": $R.may, "June": $R.jun, "July": $R.jul, "August": $R.aug, "September": $R.sep, "October": $R.oct, "November": $R.nov, "December": $R.dec, "": /\bat\b/gi, " ": /\s{2,}/, "am": $R.inTheMorning, "9am": $R.thisMorning, "pm": $R.inTheEvening, "7pm":$R.thisEvening }; }, keys : function(){ return [ utils.getDateNthString(true, false, 1), // tomorrow utils.getDateNthString(true, false, -1), // yesterday utils.getDateNthString(false, true, "monday"), //last mon utils.getDateNthString(false, true, "tuesday"), //last tues utils.getDateNthString(false, true, "wednesday"), //last wed utils.getDateNthString(false, true, "thursday"), //last thurs utils.getDateNthString(false, true, "friday"), //last fri utils.getDateNthString(false, true, "saturday"), //last sat utils.getDateNthString(false, true, "sunday") //last sun ]; }, buildRegexFunctions: function () { var $R = Date.CultureInfo.regexPatterns; var __ = Date.i18n.__; var tomorrowRE = new RegExp("(\\b\\d\\d?("+__("AM")+"|"+__("PM")+")? )("+$R.tomorrow.source.slice(1)+")", "i"); // adapted tomorrow regex for AM PM relative dates var todayRE = new RegExp($R.today.source + "(?!\\s*([+-]))\\b"); // today, but excludes the math operators (eg "today + 2h") this.replaceFuncs = [ [todayRE, function (full) { return (full.length > 1) ? Date.today().toString("d") : full; }], [tomorrowRE, function(full, m1) { var t = Date.today().addDays(1).toString("d"); return (t + " " + m1); }], [$R.amThisMorning, function(str, am){return am;}], [$R.pmThisEvening, function(str, pm){return pm;}] ]; }, buildReplaceData: function () { this.buildRegexFunctions(); this.replaceHash = utils.addToHash(this.basicReplaceHash(), this.keys(), this.regexData()); }, stringReplaceFuncs: function (s) { for (var i=0; i < this.replaceFuncs.length; i++) { s = s.replace(this.replaceFuncs[i][0], this.replaceFuncs[i][1]); } return s; }, parse: function (s) { s = this.stringReplaceFuncs(s); s = utils.multiReplace(s, this.replaceHash); try { var n = s.split(/([\s\-\.\,\/\x27]+)/); if (n.length === 3 && $P.Numeric.isNumeric(n[0]) && $P.Numeric.isNumeric(n[2]) && (n[2].length >= 4)) { // ok, so we're dealing with x/year. But that's not a full date. // This fixes wonky dateElementOrder parsing when set to dmy order. if (Date.CultureInfo.dateElementOrder[0] === "d") { s = "1/" + n[0] + "/" + n[2]; // set to 1st of month and normalize the seperator } } } catch (e) {} return s; } }; $P.Normalizer.buildReplaceData(); }()); (function () { var $P = Date.Parsing; var _ = $P.Operators = { // // Tokenizers // rtoken: function (r) { // regex token return function (s) { var mx = s.match(r); if (mx) { return ([ mx[0], s.substring(mx[0].length) ]); } else { throw new $P.Exception(s); } }; }, token: function () { // whitespace-eating token return function (s) { return _.rtoken(new RegExp("^\\s*" + s + "\\s*"))(s); }; }, stoken: function (s) { // string token return _.rtoken(new RegExp("^" + s)); }, // Atomic Operators until: function (p) { return function (s) { var qx = [], rx = null; while (s.length) { try { rx = p.call(this, s); } catch (e) { qx.push(rx[0]); s = rx[1]; continue; } break; } return [ qx, s ]; }; }, many: function (p) { return function (s) { var rx = [], r = null; while (s.length) { try { r = p.call(this, s); } catch (e) { return [ rx, s ]; } rx.push(r[0]); s = r[1]; } return [ rx, s ]; }; }, // generator operators -- see below optional: function (p) { return function (s) { var r = null; try { r = p.call(this, s); } catch (e) { return [ null, s ]; } return [ r[0], r[1] ]; }; }, not: function (p) { return function (s) { try { p.call(this, s); } catch (e) { return [null, s]; } throw new $P.Exception(s); }; }, ignore: function (p) { return p ? function (s) { var r = null; r = p.call(this, s); return [null, r[1]]; } : null; }, product: function () { var px = arguments[0], qx = Array.prototype.slice.call(arguments, 1), rx = []; for (var i = 0 ; i < px.length ; i++) { rx.push(_.each(px[i], qx)); } return rx; }, cache: function (rule) { var cache = {}, cache_length = 0, cache_keys = [], CACHE_MAX = Date.Config.CACHE_MAX || 100000, r = null; var cacheCheck = function () { if (cache_length === CACHE_MAX) { // kill several keys, don't want to have to do this all the time... for (var i=0; i < 10; i++) { var key = cache_keys.shift(); if (key) { delete cache[key]; cache_length--; } } } }; return function (s) { cacheCheck(); try { r = cache[s] = (cache[s] || rule.call(this, s)); } catch (e) { r = cache[s] = e; } cache_length++; cache_keys.push(s); if (r instanceof $P.Exception) { throw r; } else { return r; } }; }, // vector operators -- see below any: function () { var px = arguments; return function (s) { var r = null; for (var i = 0; i < px.length; i++) { if (px[i] == null) { continue; } try { r = (px[i].call(this, s)); } catch (e) { r = null; } if (r) { return r; } } throw new $P.Exception(s); }; }, each: function () { var px = arguments; return function (s) { var rx = [], r = null; for (var i = 0; i < px.length ; i++) { if (px[i] == null) { continue; } try { r = (px[i].call(this, s)); } catch (e) { throw new $P.Exception(s); } rx.push(r[0]); s = r[1]; } return [ rx, s]; }; }, all: function () { var px = arguments, _ = _; return _.each(_.optional(px)); }, // delimited operators sequence: function (px, d, c) { d = d || _.rtoken(/^\s*/); c = c || null; if (px.length === 1) { return px[0]; } return function (s) { var r = null, q = null; var rx = []; for (var i = 0; i < px.length ; i++) { try { r = px[i].call(this, s); } catch (e) { break; } rx.push(r[0]); try { q = d.call(this, r[1]); } catch (ex) { q = null; break; } s = q[1]; } if (!r) { throw new $P.Exception(s); } if (q) { throw new $P.Exception(q[1]); } if (c) { try { r = c.call(this, r[1]); } catch (ey) { throw new $P.Exception(r[1]); } } return [ rx, (r?r[1]:s) ]; }; }, // // Composite Operators // between: function (d1, p, d2) { d2 = d2 || d1; var _fn = _.each(_.ignore(d1), p, _.ignore(d2)); return function (s) { var rx = _fn.call(this, s); return [[rx[0][0], r[0][2]], rx[1]]; }; }, list: function (p, d, c) { d = d || _.rtoken(/^\s*/); c = c || null; return (p instanceof Array ? _.each(_.product(p.slice(0, -1), _.ignore(d)), p.slice(-1), _.ignore(c)) : _.each(_.many(_.each(p, _.ignore(d))), px, _.ignore(c))); }, set: function (px, d, c) { d = d || _.rtoken(/^\s*/); c = c || null; return function (s) { // r is the current match, best the current 'best' match // which means it parsed the most amount of input var r = null, p = null, q = null, rx = null, best = [[], s], last = false; // go through the rules in the given set for (var i = 0; i < px.length ; i++) { // last is a flag indicating whether this must be the last element // if there is only 1 element, then it MUST be the last one q = null; p = null; r = null; last = (px.length === 1); // first, we try simply to match the current pattern // if not, try the next pattern try { r = px[i].call(this, s); } catch (e) { continue; } // since we are matching against a set of elements, the first // thing to do is to add r[0] to matched elements rx = [[r[0]], r[1]]; // if we matched and there is still input to parse and // we don't already know this is the last element, // we're going to next check for the delimiter ... // if there's none, or if there's no input left to parse // than this must be the last element after all ... if (r[1].length > 0 && ! last) { try { q = d.call(this, r[1]); } catch (ex) { last = true; } } else { last = true; } // if we parsed the delimiter and now there's no more input, // that means we shouldn't have parsed the delimiter at all // so don't update r and mark this as the last element ... if (!last && q[1].length === 0) { last = true; } // so, if this isn't the last element, we're going to see if // we can get any more matches from the remaining (unmatched) // elements ... if (!last) { // build a list of the remaining rules we can match against, // i.e., all but the one we just matched against var qx = []; for (var j = 0; j < px.length ; j++) { if (i !== j) { qx.push(px[j]); } } // now invoke recursively set with the remaining input // note that we don't include the closing delimiter ... // we'll check for that ourselves at the end p = _.set(qx, d).call(this, q[1]); // if we got a non-empty set as a result ... // (otw rx already contains everything we want to match) if (p[0].length > 0) { // update current result, which is stored in rx ... // basically, pick up the remaining text from p[1] // and concat the result from p[0] so that we don't // get endless nesting ... rx[0] = rx[0].concat(p[0]); rx[1] = p[1]; } } // at this point, rx either contains the last matched element // or the entire matched set that starts with this element. // now we just check to see if this variation is better than // our best so far, in terms of how much of the input is parsed if (rx[1].length < best[1].length) { best = rx; } // if we've parsed all the input, then we're finished if (best[1].length === 0) { break; } } // so now we've either gone through all the patterns trying them // as the initial match; or we found one that parsed the entire // input string ... // if best has no matches, just return empty set ... if (best[0].length === 0) { return best; } // if a closing delimiter is provided, then we have to check it also if (c) { // we try this even if there is no remaining input because the pattern // may well be optional or match empty input ... try { q = c.call(this, best[1]); } catch (ey) { throw new $P.Exception(best[1]); } // it parsed ... be sure to update the best match remaining input best[1] = q[1]; } // if we're here, either there was no closing delimiter or we parsed it // so now we have the best match; just return it! return best; }; }, forward: function (gr, fname) { return function (s) { return gr[fname].call(this, s); }; }, // // Translation Operators // replace: function (rule, repl) { return function (s) { var r = rule.call(this, s); return [repl, r[1]]; }; }, process: function (rule, fn) { return function (s) { var r = rule.call(this, s); return [fn.call(this, r[0]), r[1]]; }; }, min: function (min, rule) { return function (s) { var rx = rule.call(this, s); if (rx[0].length < min) { throw new $P.Exception(s); } return rx; }; } }; // Generator Operators And Vector Operators // Generators are operators that have a signature of F(R) => R, // taking a given rule and returning another rule, such as // ignore, which parses a given rule and throws away the result. // Vector operators are those that have a signature of F(R1,R2,...) => R, // take a list of rules and returning a new rule, such as each. // Generator operators are converted (via the following _generator // function) into functions that can also take a list or array of rules // and return an array of new rules as though the function had been // called on each rule in turn (which is what actually happens). // This allows generators to be used with vector operators more easily. // Example: // each(ignore(foo, bar)) instead of each(ignore(foo), ignore(bar)) // This also turns generators into vector operators, which allows // constructs like: // not(cache(foo, bar)) var _generator = function (op) { function gen() { var args = null, rx = [], px, i; if (arguments.length > 1) { args = Array.prototype.slice.call(arguments); } else if (arguments[0] instanceof Array) { args = arguments[0]; } if (args) { px = args.shift(); if (px.length > 0) { args.unshift(px[i]); rx.push(op.apply(null, args)); args.shift(); return rx; } } else { return op.apply(null, arguments); } } return gen; }; var gx = "optional not ignore cache".split(/\s/); for (var i = 0 ; i < gx.length ; i++) { _[gx[i]] = _generator(_[gx[i]]); } var _vector = function (op) { return function () { if (arguments[0] instanceof Array) { return op.apply(null, arguments[0]); } else { return op.apply(null, arguments); } }; }; var vx = "each any all".split(/\s/); for (var j = 0 ; j < vx.length ; j++) { _[vx[j]] = _vector(_[vx[j]]); } }()); (function () { var $D = Date; var flattenAndCompact = function (ax) { var rx = []; for (var i = 0; i < ax.length; i++) { if (ax[i] instanceof Array) { rx = rx.concat(flattenAndCompact(ax[i])); } else { if (ax[i]) { rx.push(ax[i]); } } } return rx; }; var parseMeridian = function () { if (this.meridian && (this.hour || this.hour === 0)) { if (this.meridian === "a" && this.hour > 11 && Date.Config.strict24hr){ throw "Invalid hour and meridian combination"; } else if (this.meridian === "p" && this.hour < 12 && Date.Config.strict24hr){ throw "Invalid hour and meridian combination"; } else if (this.meridian === "p" && this.hour < 12) { this.hour = this.hour + 12; } else if (this.meridian === "a" && this.hour === 12) { this.hour = 0; } } }; var setDefaults = function () { var now = new Date(); if ((this.hour || this.minute) && (!this.month && !this.year && !this.day)) { this.day = now.getDate(); } if (!this.year) { this.year = now.getFullYear(); } if (!this.month && this.month !== 0) { this.month = now.getMonth(); } if (!this.day) { this.day = 1; } if (!this.hour) { this.hour = 0; } if (!this.minute) { this.minute = 0; } if (!this.second) { this.second = 0; } if (!this.millisecond) { this.millisecond = 0; } }; var finishUtils = { getToday: function () { if (this.now || "hour minute second".indexOf(this.unit) !== -1) { return new Date(); } else { return $D.today(); } }, setDaysFromWeekday: function (today, orient){ var gap; orient = orient || 1; this.unit = "day"; gap = ($D.getDayNumberFromName(this.weekday) - today.getDay()); this.days = gap ? ((gap + (orient * 7)) % 7) : (orient * 7); return this; }, setMonthsFromMonth: function (today, orient) { var gap; orient = orient || 1; this.unit = "month"; gap = (this.month - today.getMonth()); this.months = gap ? ((gap + (orient * 12)) % 12) : (orient * 12); this.month = null; return this; }, setDMYFromWeekday: function () { var d = Date[this.weekday](); this.day = d.getDate(); if (!this.month) { this.month = d.getMonth(); } this.year = d.getFullYear(); return this; }, setUnitValue: function (orient) { if (!this.value && this.operator && this.operator !== null && this[this.unit + "s"] && this[this.unit + "s"] !== null) { this[this.unit + "s"] = this[this.unit + "s"] + ((this.operator === "add") ? 1 : -1) + (this.value||0) * orient; } else if (this[this.unit + "s"] == null || this.operator != null) { if (!this.value) { this.value = 1; } this[this.unit + "s"] = this.value * orient; } }, generateDateFromWeeks: function () { var weekday = (this.weekday !== undefined) ? this.weekday : "today"; var d = Date[weekday]().addWeeks(this.weeks); if (this.now) { d.setTimeToNow(); } return d; } }; $D.Translator = { hour: function (s) { return function () { this.hour = Number(s); }; }, minute: function (s) { return function () { this.minute = Number(s); }; }, second: function (s) { return function () { this.second = Number(s); }; }, /* for ss.s format */ secondAndMillisecond: function (s) { return function () { var mx = s.match(/^([0-5][0-9])\.([0-9]{1,3})/); this.second = Number(mx[1]); this.millisecond = Number(mx[2]); }; }, meridian: function (s) { return function () { this.meridian = s.slice(0, 1).toLowerCase(); }; }, timezone: function (s) { return function () { var n = s.replace(/[^\d\+\-]/g, ""); if (n.length) { this.timezoneOffset = Number(n); } else { this.timezone = s.toLowerCase(); } }; }, day: function (x) { var s = x[0]; return function () { this.day = Number(s.match(/\d+/)[0]); if (this.day < 1) { throw "invalid day"; } }; }, month: function (s) { return function () { this.month = (s.length === 3) ? "jan feb mar apr may jun jul aug sep oct nov dec".indexOf(s)/4 : Number(s) - 1; if (this.month < 0) { throw "invalid month"; } }; }, year: function (s) { return function () { var n = Number(s); this.year = ((s.length > 2) ? n : (n + (((n + 2000) < Date.CultureInfo.twoDigitYearMax) ? 2000 : 1900))); }; }, rday: function (s) { return function () { switch (s) { case "yesterday": this.days = -1; break; case "tomorrow": this.days = 1; break; case "today": this.days = 0; break; case "now": this.days = 0; this.now = true; break; } }; }, finishExact: function (x) { var d; x = (x instanceof Array) ? x : [x]; for (var i = 0 ; i < x.length ; i++) { if (x[i]) { x[i].call(this); } } setDefaults.call(this); parseMeridian.call(this); if (this.day > $D.getDaysInMonth(this.year, this.month)) { throw new RangeError(this.day + " is not a valid value for days."); } d = new Date(this.year, this.month, this.day, this.hour, this.minute, this.second, this.millisecond); if (this.year < 100) { d.setFullYear(this.year); // means years less that 100 are process correctly. JS will parse it otherwise as 1900-1999. } if (this.timezone) { d.set({ timezone: this.timezone }); } else if (this.timezoneOffset) { d.set({ timezoneOffset: this.timezoneOffset }); } return d; }, finish: function (x) { var today, expression, orient, temp; x = (x instanceof Array) ? flattenAndCompact(x) : [ x ]; if (x.length === 0) { return null; } for (var i = 0 ; i < x.length ; i++) { if (typeof x[i] === "function") { x[i].call(this); } } if (this.now && !this.unit && !this.operator) { return new Date(); } else { today = finishUtils.getToday.call(this); } expression = !!(this.days && this.days !== null || this.orient || this.operator); orient = ((this.orient === "past" || this.operator === "subtract") ? -1 : 1); if (this.month && this.unit === "week") { this.value = this.month + 1; delete this.month; delete this.day; } if ((this.month || this.month === 0) && "year day hour minute second".indexOf(this.unit) !== -1) { if (!this.value) { this.value = this.month + 1; } this.month = null; expression = true; } if (!expression && this.weekday && !this.day && !this.days) { finishUtils.setDMYFromWeekday.call(this); } if (expression && this.weekday && this.unit !== "month" && this.unit !== "week") { finishUtils.setDaysFromWeekday.call(this, today, orient); } if (this.weekday && this.unit !== "week" && !this.day && !this.days) { temp = Date[this.weekday](); this.day = temp.getDate(); if (temp.getMonth() !== today.getMonth()) { this.month = temp.getMonth(); } } if (this.month && this.unit === "day" && this.operator) { if (!this.value) { this.value = (this.month + 1); } this.month = null; } if (this.value != null && this.month != null && this.year != null) { this.day = this.value * 1; } if (this.month && !this.day && this.value) { today.set({ day: this.value * 1 }); if (!expression) { this.day = this.value * 1; } } if (!this.month && this.value && this.unit === "month" && !this.now) { this.month = this.value; expression = true; } if (expression && (this.month || this.month === 0) && this.unit !== "year") { finishUtils.setMonthsFromMonth.call(this, today, orient); } if (!this.unit) { this.unit = "day"; } finishUtils.setUnitValue.call(this, orient); parseMeridian.call(this); if ((this.month || this.month === 0) && !this.day) { this.day = 1; } if (!this.orient && !this.operator && this.unit === "week" && this.value && !this.day && !this.month) { return Date.today().setWeek(this.value); } if (this.unit === "week" && this.weeks && !this.day && !this.month) { return finishUtils.generateDateFromWeeks.call(this); } if (expression && this.timezone && this.day && this.days) { this.day = this.days; } if (expression){ today.add(this); } else { today.set(this); } if (this.timezone) { this.timezone = this.timezone.toUpperCase(); var offset = $D.getTimezoneOffset(this.timezone); var timezone; if (today.hasDaylightSavingTime()) { // lets check that we're being sane with timezone setting timezone = $D.getTimezoneAbbreviation(offset, today.isDaylightSavingTime()); if (timezone !== this.timezone) { // bugger, we're in a place where things like EST vs EDT matters. if (today.isDaylightSavingTime()) { today.addHours(-1); } else { today.addHours(1); } } } today.setTimezoneOffset(offset); } return today; } }; }()); (function () { var $D = Date; $D.Grammar = {}; var _ = $D.Parsing.Operators, g = $D.Grammar, t = $D.Translator, _fn; // Allow rolling up into general purpose rules _fn = function () { return _.each(_.any.apply(null, arguments), _.not(g.ctoken2("timeContext"))); }; g.datePartDelimiter = _.rtoken(/^([\s\-\.\,\/\x27]+)/); g.timePartDelimiter = _.stoken(":"); g.whiteSpace = _.rtoken(/^\s*/); g.generalDelimiter = _.rtoken(/^(([\s\,]|at|@|on)+)/); var _C = {}; g.ctoken = function (keys) { var fn = _C[keys]; if (! fn) { var c = Date.CultureInfo.regexPatterns; var kx = keys.split(/\s+/), px = []; for (var i = 0; i < kx.length ; i++) { px.push(_.replace(_.rtoken(c[kx[i]]), kx[i])); } fn = _C[keys] = _.any.apply(null, px); } return fn; }; g.ctoken2 = function (key) { return _.rtoken(Date.CultureInfo.regexPatterns[key]); }; var cacheProcessRtoken = function (key, token, type, eachToken) { if (eachToken) { g[key] = _.cache(_.process(_.each(_.rtoken(token),_.optional(g.ctoken2(eachToken))), type)); } else { g[key] = _.cache(_.process(_.rtoken(token), type)); } }; var cacheProcessCtoken = function (token, type) { return _.cache(_.process(g.ctoken2(token), type)); }; var _F = {}; //function cache var _get = function (f) { _F[f] = (_F[f] || g.format(f)[0]); return _F[f]; }; g.allformats = function (fx) { var rx = []; if (fx instanceof Array) { for (var i = 0; i < fx.length; i++) { rx.push(_get(fx[i])); } } else { rx.push(_get(fx)); } return rx; }; g.formats = function (fx) { if (fx instanceof Array) { var rx = []; for (var i = 0 ; i < fx.length ; i++) { rx.push(_get(fx[i])); } return _.any.apply(null, rx); } else { return _get(fx); } }; var grammarFormats = { timeFormats: function(){ var i, RTokenKeys = [ "h", "hh", "H", "HH", "m", "mm", "s", "ss", "ss.s", "z", "zz" ], RToken = [ /^(0[0-9]|1[0-2]|[1-9])/, /^(0[0-9]|1[0-2])/, /^([0-1][0-9]|2[0-3]|[0-9])/, /^([0-1][0-9]|2[0-3])/, /^([0-5][0-9]|[0-9])/, /^[0-5][0-9]/, /^([0-5][0-9]|[0-9])/, /^[0-5][0-9]/, /^[0-5][0-9]\.[0-9]{1,3}/, /^((\+|\-)\s*\d\d\d\d)|((\+|\-)\d\d\:?\d\d)/, /^((\+|\-)\s*\d\d\d\d)|((\+|\-)\d\d\:?\d\d)/ ], tokens = [ t.hour, t.hour, t.hour, t.hour, t.minute, t.minute, t.second, t.second, t.secondAndMillisecond, t.timezone, t.timezone ]; for (i=0; i < RTokenKeys.length; i++) { cacheProcessRtoken(RTokenKeys[i], RToken[i], tokens[i]); } g.hms = _.cache(_.sequence([g.H, g.m, g.s], g.timePartDelimiter)); g.t = cacheProcessCtoken("shortMeridian", t.meridian); g.tt = cacheProcessCtoken("longMeridian", t.meridian); g.zzz = cacheProcessCtoken("timezone", t.timezone); g.timeSuffix = _.each(_.ignore(g.whiteSpace), _.set([ g.tt, g.zzz ])); g.time = _.each(_.optional(_.ignore(_.stoken("T"))), g.hms, g.timeSuffix); }, dateFormats: function () { // pre-loaded rules for different date part order preferences var _setfn = function () { return _.set(arguments, g.datePartDelimiter); }; var i, RTokenKeys = [ "d", "dd", "M", "MM", "y", "yy", "yyy", "yyyy" ], RToken = [ /^([0-2]\d|3[0-1]|\d)/, /^([0-2]\d|3[0-1])/, /^(1[0-2]|0\d|\d)/, /^(1[0-2]|0\d)/, /^(\d+)/, /^(\d\d)/, /^(\d\d?\d?\d?)/, /^(\d\d\d\d)/ ], tokens = [ t.day, t.day, t.month, t.month, t.year, t.year, t.year, t.year ], eachToken = [ "ordinalSuffix", "ordinalSuffix" ]; for (i=0; i < RTokenKeys.length; i++) { cacheProcessRtoken(RTokenKeys[i], RToken[i], tokens[i], eachToken[i]); } g.MMM = g.MMMM = _.cache(_.process(g.ctoken("jan feb mar apr may jun jul aug sep oct nov dec"), t.month)); g.ddd = g.dddd = _.cache(_.process(g.ctoken("sun mon tue wed thu fri sat"), function (s) { return function () { this.weekday = s; }; } )); g.day = _fn(g.d, g.dd); g.month = _fn(g.M, g.MMM); g.year = _fn(g.yyyy, g.yy); g.mdy = _setfn(g.ddd, g.month, g.day, g.year); g.ymd = _setfn(g.ddd, g.year, g.month, g.day); g.dmy = _setfn(g.ddd, g.day, g.month, g.year); g.date = function (s) { return ((g[Date.CultureInfo.dateElementOrder] || g.mdy).call(this, s)); }; }, relative: function () { // relative date / time expressions g.orientation = _.process(g.ctoken("past future"), function (s) { return function () { this.orient = s; }; } ); g.operator = _.process(g.ctoken("add subtract"), function (s) { return function () { this.operator = s; }; } ); g.rday = _.process(g.ctoken("yesterday tomorrow today now"), t.rday); g.unit = _.process(g.ctoken("second minute hour day week month year"), function (s) { return function () { this.unit = s; }; } ); } }; g.buildGrammarFormats = function () { // these need to be rebuilt every time the language changes. _C = {}; grammarFormats.timeFormats(); grammarFormats.dateFormats(); grammarFormats.relative(); g.value = _.process(_.rtoken(/^([-+]?\d+)?(st|nd|rd|th)?/), function (s) { return function () { this.value = s.replace(/\D/g, ""); }; } ); g.expression = _.set([g.rday, g.operator, g.value, g.unit, g.orientation, g.ddd, g.MMM ]); g.format = _.process(_.many( _.any( // translate format specifiers into grammar rules _.process( _.rtoken(/^(dd?d?d?(?!e)|MM?M?M?|yy?y?y?|hh?|HH?|mm?|ss?|tt?|zz?z?)/), function (fmt) { if (g[fmt]) { return g[fmt]; } else { throw $D.Parsing.Exception(fmt); } } ), // translate separator tokens into token rules _.process(_.rtoken(/^[^dMyhHmstz]+/), // all legal separators function (s) { return _.ignore(_.stoken(s)); } ) ) ), // construct the parser ... function (rules) { return _.process(_.each.apply(null, rules), t.finishExact); } ); // starting rule for general purpose grammar g._start = _.process(_.set([ g.date, g.time, g.expression ], g.generalDelimiter, g.whiteSpace), t.finish); }; g.buildGrammarFormats(); // parsing date format specifiers - ex: "h:m:s tt" // this little guy will generate a custom parser based // on the format string, ex: g.format("h:m:s tt") // check for these formats first g._formats = g.formats([ "\"yyyy-MM-ddTHH:mm:ssZ\"", "yyyy-MM-ddTHH:mm:ss.sz", "yyyy-MM-ddTHH:mm:ssZ", "yyyy-MM-ddTHH:mm:ssz", "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-ddTHH:mmZ", "yyyy-MM-ddTHH:mmz", "yyyy-MM-ddTHH:mm", "ddd, MMM dd, yyyy H:mm:ss tt", "ddd MMM d yyyy HH:mm:ss zzz", "MMddyyyy", "ddMMyyyy", "Mddyyyy", "ddMyyyy", "Mdyyyy", "dMyyyy", "yyyy", "Mdyy", "dMyy", "d" ]); // real starting rule: tries selected formats first, // then general purpose rule g.start = function (s) { try { var r = g._formats.call({}, s); if (r[1].length === 0) { return r; } } catch (e) {} return g._start.call({}, s); }; }()); (function () { var $D = Date; /** * @desc Converts the specified string value into its JavaScript Date equivalent using CultureInfo specific format information. * * Example

	///////////
	// Dates //
	///////////

	// 15-Oct-2004
	var d1 = Date.parse("10/15/2004");

	// 15-Oct-2004
	var d1 = Date.parse("15-Oct-2004");

	// 15-Oct-2004
	var d1 = Date.parse("2004.10.15");

	//Fri Oct 15, 2004
	var d1 = Date.parse("Fri Oct 15, 2004");

	///////////
	// Times //
	///////////

	// Today at 10 PM.
	var d1 = Date.parse("10 PM");

	// Today at 10:30 PM.
	var d1 = Date.parse("10:30 P.M.");

	// Today at 6 AM.
	var d1 = Date.parse("06am");

	/////////////////////
	// Dates and Times //
	/////////////////////

	// 8-July-2004 @ 10:30 PM
	var d1 = Date.parse("July 8th, 2004, 10:30 PM");

	// 1-July-2004 @ 10:30 PM
	var d1 = Date.parse("2004-07-01T22:30:00");

	////////////////////
	// Relative Dates //
	////////////////////

	// Returns today's date. The string "today" is culture specific.
	var d1 = Date.parse("today");

	// Returns yesterday's date. The string "yesterday" is culture specific.
	var d1 = Date.parse("yesterday");

	// Returns the date of the next thursday.
	var d1 = Date.parse("Next thursday");

	// Returns the date of the most previous monday.
	var d1 = Date.parse("last monday");

	// Returns today's day + one year.
	var d1 = Date.parse("next year");

	///////////////
	// Date Math //
	///////////////

	// Today + 2 days
	var d1 = Date.parse("t+2");

	// Today + 2 days
	var d1 = Date.parse("today + 2 days");

	// Today + 3 months
	var d1 = Date.parse("t+3m");

	// Today - 1 year
	var d1 = Date.parse("today - 1 year");

	// Today - 1 year
	var d1 = Date.parse("t-1y"); 


	/////////////////////////////
	// Partial Dates and Times //
	/////////////////////////////

	// July 15th of this year.
	var d1 = Date.parse("July 15");

	// 15th day of current day and year.
	var d1 = Date.parse("15");

	// July 1st of current year at 10pm.
	var d1 = Date.parse("7/1 10pm");
	
* * @param {String} The string value to convert into a Date object [Required] * @return {Date} A Date object or null if the string cannot be converted into a Date. */ var parseUtils = { removeOrds: function (s) { ords = s.match(/\b(\d+)(?:st|nd|rd|th)\b/); // find ordinal matches s = ((ords && ords.length === 2) ? s.replace(ords[0], ords[1]) : s); return s; }, grammarParser: function (s) { var r = null; try { r = $D.Grammar.start.call({}, s.replace(/^\s*(\S*(\s+\S+)*)\s*$/, "$1")); } catch (e) { return null; } return ((r[1].length === 0) ? r[0] : null); }, nativeFallback: function(s) { var t; try { // ok we haven't parsed it, last ditch attempt with the built-in parser. t = Date._parse(s); return (t || t === 0) ? new Date(t) : null; } catch (e) { return null; } } }; function parse (s) { var d; if (!s) { return null; } if (s instanceof Date) { return s.clone(); } if (s.length >= 4 && s.charAt(0) !== "0" && s.charAt(0) !== "+"&& s.charAt(0) !== "-") { // ie: 2004 will pass, 0800 won't. // Start with specific formats d = $D.Parsing.ISO.parse(s) || $D.Parsing.Numeric.parse(s); } if (d instanceof Date && !isNaN(d.getTime())) { return d; } else { // find ordinal dates (1st, 3rd, 8th, etc and remove them as they cause parsing issues) s = $D.Parsing.Normalizer.parse(parseUtils.removeOrds(s)); d = parseUtils.grammarParser(s); if (d !== null) { return d; } else { return parseUtils.nativeFallback(s); } } } if (!$D._parse) { $D._parse = $D.parse; } $D.parse = parse; Date.getParseFunction = function (fx) { var fns = Date.Grammar.allformats(fx); return function (s) { var r = null; for (var i = 0; i < fns.length; i++) { try { r = fns[i].call({}, s); } catch (e) { continue; } if (r[1].length === 0) { return r[0]; } } return null; }; }; /** * Converts the specified string value into its JavaScript Date equivalent using the specified format {String} or formats {Array} and the CultureInfo specific format information. * The format of the string value must match one of the supplied formats exactly. * * Example

	// 15-Oct-2004
	var d1 = Date.parseExact("10/15/2004", "M/d/yyyy");

	// 15-Oct-2004
	var d1 = Date.parse("15-Oct-2004", "M-ddd-yyyy");

	// 15-Oct-2004
	var d1 = Date.parse("2004.10.15", "yyyy.MM.dd");

	// Multiple formats
	var d1 = Date.parseExact("10/15/2004", ["M/d/yyyy", "MMMM d, yyyy"]);
	
* * @param {String} The string value to convert into a Date object [Required]. * @param {Object} The expected format {String} or an array of expected formats {Array} of the date string [Required]. * @return {Date} A Date object or null if the string cannot be converted into a Date. */ $D.parseExact = function (s, fx) { return $D.getParseFunction(fx)(s); }; }()); (function () { var $D = Date, $P = $D.prototype, // $C = $D.CultureInfo, // not used atm p = function (s, l) { if (!l) { l = 2; } return ("000" + s).slice(l * -1); }; /** * Converts a PHP format string to Java/.NET format string. * A PHP format string can be used with ._format or .format. * A Java/.NET format string can be used with .toString(). * The .parseExact function will only accept a Java/.NET format string * * Example * var f1 = "%m/%d/%y" * var f2 = Date.normalizeFormat(f1); // "MM/dd/yy" * * new Date().format(f1); // "04/13/08" * new Date()._format(f1); // "04/13/08" * new Date().toString(f2); // "04/13/08" * * var date = Date.parseExact("04/13/08", f2); // Sun Apr 13 2008 * * @param {String} A PHP format string consisting of one or more format spcifiers. * @return {String} The PHP format converted to a Java/.NET format string. */ var normalizerSubstitutions = { "d" : "dd", "%d": "dd", "D" : "ddd", "%a": "ddd", "j" : "dddd", "l" : "dddd", "%A": "dddd", "S" : "S", "F" : "MMMM", "%B": "MMMM", "m" : "MM", "%m": "MM", "M" : "MMM", "%b": "MMM", "%h": "MMM", "n" : "M", "Y" : "yyyy", "%Y": "yyyy", "y" : "yy", "%y": "yy", "g" : "h", "%I": "h", "G" : "H", "h" : "hh", "H" : "HH", "%H": "HH", "i" : "mm", "%M": "mm", "s" : "ss", "%S": "ss", "%r": "hh:mm tt", "%R": "H:mm", "%T": "H:mm:ss", "%X": "t", "%x": "d", "%e": "d", "%D": "MM/dd/yy", "%n": "\\n", "%t": "\\t", "e" : "z", "T" : "z", "%z": "z", "%Z": "z", "Z" : "ZZ", "N" : "u", "w" : "u", "%w": "u", "W" : "W", "%V": "W" }; var normalizer = { substitutes: function (m) { return normalizerSubstitutions[m]; }, interpreted: function (m, x) { var y; switch (m) { case "%u": return x.getDay() + 1; case "z": return x.getOrdinalNumber(); case "%j": return p(x.getOrdinalNumber(), 3); case "%U": var d1 = x.clone().set({month: 0, day: 1}).addDays(-1).moveToDayOfWeek(0), d2 = x.clone().addDays(1).moveToDayOfWeek(0, -1); return (d2 < d1) ? "00" : p((d2.getOrdinalNumber() - d1.getOrdinalNumber()) / 7 + 1); case "%W": return p(x.getWeek()); case "t": return $D.getDaysInMonth(x.getFullYear(), x.getMonth()); case "o": case "%G": return x.setWeek(x.getISOWeek()).toString("yyyy"); case "%g": return x._format("%G").slice(-2); case "a": case "%p": return t("tt").toLowerCase(); case "A": return t("tt").toUpperCase(); case "u": return p(x.getMilliseconds(), 3); case "I": return (x.isDaylightSavingTime()) ? 1 : 0; case "O": return x.getUTCOffset(); case "P": y = x.getUTCOffset(); return y.substring(0, y.length - 2) + ":" + y.substring(y.length - 2); case "B": var now = new Date(); return Math.floor(((now.getHours() * 3600) + (now.getMinutes() * 60) + now.getSeconds() + (now.getTimezoneOffset() + 60) * 60) / 86.4); case "c": return x.toISOString().replace(/\"/g, ""); case "U": return $D.strtotime("now"); case "%c": return t("d") + " " + t("t"); case "%C": return Math.floor(x.getFullYear() / 100 + 1); } }, shouldOverrideDefaults: function (m) { switch (m) { case "%e": return true; default: return false; } }, parse: function (m, context) { var formatString, c = context || new Date(); formatString = normalizer.substitutes(m); if (formatString) { return formatString; } formatString = normalizer.interpreted(m, c); if (formatString) { return formatString; } else { return m; } } }; $D.normalizeFormat = function (format, context) { return format.replace(/(%|\\)?.|%%/g, function(t){ return normalizer.parse(t, context); }); }; /** * Format a local Unix timestamp according to locale settings * * Example: * Date.strftime("%m/%d/%y", new Date()); // "04/13/08" * Date.strftime("c", "2008-04-13T17:52:03Z"); // "04/13/08" * * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @param {Number|String} The number representing the number of seconds that have elapsed since January 1, 1970 (local time). * @return {String} A string representation of the current Date object. */ $D.strftime = function (format, time) { var d = Date.parse(time); return d._format(format); }; /** * Parse any textual datetime description into a Unix timestamp. * A Unix timestamp is the number of seconds that have elapsed since January 1, 1970 (midnight UTC/GMT). * * Example: * Date.strtotime("04/13/08"); // 1208044800 * Date.strtotime("1970-01-01T00:00:00Z"); // 0 * * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @param {Object} A string or date object. * @return {String} A string representation of the current Date object. */ $D.strtotime = function (time) { var d = $D.parse(time); return Math.round($D.UTC(d.getUTCFullYear(), d.getUTCMonth(), d.getUTCDate(), d.getUTCHours(), d.getUTCMinutes(), d.getUTCSeconds(), d.getUTCMilliseconds()) / 1000); }; /** * Converts the value of the current Date object to its equivalent string representation using a PHP/Unix style of date format specifiers. * Format Specifiers * Format Description Example * ------ --------------------------------------------------------------------------- ----------------------- * %a abbreviated weekday name according to the current localed "Mon" through "Sun" * %A full weekday name according to the current localed "Sunday" through "Saturday" * %b abbreviated month name according to the current localed "Jan" through "Dec" * %B full month name according to the current locale "January" through "December" * %c preferred date and time representation for the current locale "4/13/2008 12:33 PM" * %C century number (the year divided by 100 and truncated to an integer) "00" to "99" * %d day of the month as a decimal number "01" to "31" * %D same as %m/%d/%y "04/13/08" * %e day of the month as a decimal number, a single digit is preceded by a space "1" to "31" * %g like %G, but without the century "08" * %G The 4-digit year corresponding to the ISO week number (see %V). "2008" * This has the same format and value as %Y, except that if the ISO week number * belongs to the previous or next year, that year is used instead. * %h same as %b "Jan" through "Dec" * %H hour as a decimal number using a 24-hour clock. "00" to "23" * %I hour as a decimal number using a 12-hour clock. "01" to "12" * %j day of the year as a decimal number. "001" to "366" * %m month as a decimal number. "01" to "12" * %M minute as a decimal number. "00" to "59" * %n newline character "\n" * %p either "am" or "pm" according to the given time value, or the "am" or "pm" * corresponding strings for the current locale. * %r time in a.m. and p.m. notation "8:44 PM" * %R time in 24 hour notation "20:44" * %S second as a decimal number "00" to "59" * %t tab character "\t" * %T current time, equal to %H:%M:%S "12:49:11" * %u weekday as a decimal number ["1", "7"], with "1" representing Monday "1" to "7" * %U week number of the current year as a decimal number, starting with the "0" to ("52" or "53") * first Sunday as the first day of the first week * %V The ISO 8601:1988 week number of the current year as a decimal number, "00" to ("52" or "53") * range 01 to 53, where week 1 is the first week that has at least 4 days * in the current year, and with Monday as the first day of the week. * (Use %G or %g for the year component that corresponds to the week number * for the specified timestamp.) * %W week number of the current year as a decimal number, starting with the "00" to ("52" or "53") * first Monday as the first day of the first week * %w day of the week as a decimal, Sunday being "0" "0" to "6" * %x preferred date representation for the current locale without the time "4/13/2008" * %X preferred time representation for the current locale without the date "12:53:05" * %y year as a decimal number without a century "00" "99" * %Y year as a decimal number including the century "2008" * %Z time zone or name or abbreviation "UTC", "EST", "PST" * %z same as %Z * %% a literal "%" characters "%" * d Day of the month, 2 digits with leading zeros "01" to "31" * D A textual representation of a day, three letters "Mon" through "Sun" * j Day of the month without leading zeros "1" to "31" * l A full textual representation of the day of the week (lowercase "L") "Sunday" through "Saturday" * N ISO-8601 numeric representation of the day of the week (added in PHP 5.1.0) "1" (for Monday) through "7" (for Sunday) * S English ordinal suffix for the day of the month, 2 characters "st", "nd", "rd" or "th". Works well with j * w Numeric representation of the day of the week "0" (for Sunday) through "6" (for Saturday) * z The day of the year (starting from "0") "0" through "365" * W ISO-8601 week number of year, weeks starting on Monday "00" to ("52" or "53") * F A full textual representation of a month, such as January or March "January" through "December" * m Numeric representation of a month, with leading zeros "01" through "12" * M A short textual representation of a month, three letters "Jan" through "Dec" * n Numeric representation of a month, without leading zeros "1" through "12" * t Number of days in the given month "28" through "31" * L Whether it's a leap year "1" if it is a leap year, "0" otherwise * o ISO-8601 year number. This has the same value as Y, except that if the "2008" * ISO week number (W) belongs to the previous or next year, that year * is used instead. * Y A full numeric representation of a year, 4 digits "2008" * y A two digit representation of a year "08" * a Lowercase Ante meridiem and Post meridiem "am" or "pm" * A Uppercase Ante meridiem and Post meridiem "AM" or "PM" * B Swatch Internet time "000" through "999" * g 12-hour format of an hour without leading zeros "1" through "12" * G 24-hour format of an hour without leading zeros "0" through "23" * h 12-hour format of an hour with leading zeros "01" through "12" * H 24-hour format of an hour with leading zeros "00" through "23" * i Minutes with leading zeros "00" to "59" * s Seconds, with leading zeros "00" through "59" * u Milliseconds "54321" * e Timezone identifier "UTC", "EST", "PST" * I Whether or not the date is in daylight saving time (uppercase i) "1" if Daylight Saving Time, "0" otherwise * O Difference to Greenwich time (GMT) in hours "+0200", "-0600" * P Difference to Greenwich time (GMT) with colon between hours and minutes "+02:00", "-06:00" * T Timezone abbreviation "UTC", "EST", "PST" * Z Timezone offset in seconds. The offset for timezones west of UTC is "-43200" through "50400" * always negative, and for those east of UTC is always positive. * c ISO 8601 date "2004-02-12T15:19:21+00:00" * r RFC 2822 formatted date "Thu, 21 Dec 2000 16:01:07 +0200" * U Seconds since the Unix Epoch (January 1 1970 00:00:00 GMT) "0" * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @return {String} A string representation of the current Date object. */ var formatReplace = function (context) { return function (m) { var formatString, override = false; if (m.charAt(0) === "\\" || m.substring(0, 2) === "%%") { return m.replace("\\", "").replace("%%", "%"); } override = normalizer.shouldOverrideDefaults(m); formatString = $D.normalizeFormat(m, context); if (formatString) { return context.toString(formatString, override); } }; }; $P._format = function (format) { var formatter = formatReplace(this); if (!format) { return this._toString(); } else { return format.replace(/(%|\\)?.|%%/g, formatter); } }; if (!$P.format) { $P.format = $P._format; } }()); (function () { "use strict"; var gFn = function (attr) { return function () { return this[attr]; }; }; var sFn = function (attr) { return function (val) { this[attr] = val; return this; }; }; var attrs = ["years", "months", "days", "hours", "minutes", "seconds", "milliseconds"]; var addSetFuncs = function (context, attrs) { for (var i = 0; i < attrs.length ; i++) { var $a = attrs[i], $b = $a.slice(0, 1).toUpperCase() + $a.slice(1); context.prototype[$a] = 0; context.prototype["get" + $b] = gFn($a); context.prototype["set" + $b] = sFn($a); } }; /** * new TimeSpan(milliseconds); * new TimeSpan(days, hours, minutes, seconds); * new TimeSpan(days, hours, minutes, seconds, milliseconds); */ var TimeSpan = function (days, hours, minutes, seconds, milliseconds) { if (arguments.length === 1 && typeof days === "number") { var orient = (days < 0) ? -1 : +1; var millsLeft = Math.abs(days); this.setDays(Math.floor(millsLeft / 86400000) * orient); millsLeft = millsLeft % 86400000; this.setHours(Math.floor(millsLeft / 3600000) * orient); millsLeft = millsLeft % 3600000; this.setMinutes(Math.floor(millsLeft / 60000) * orient); millsLeft = millsLeft % 60000; this.setSeconds(Math.floor(millsLeft / 1000) * orient); millsLeft = millsLeft % 1000; this.setMilliseconds(millsLeft * orient); } else { this.set(days, hours, minutes, seconds, milliseconds); } this.getTotalMilliseconds = function () { return (this.getDays() * 86400000) + (this.getHours() * 3600000) + (this.getMinutes() * 60000) + (this.getSeconds() * 1000); }; this.compareTo = function (time) { var t1 = new Date(1970, 1, 1, this.getHours(), this.getMinutes(), this.getSeconds()), t2; if (time === null) { t2 = new Date(1970, 1, 1, 0, 0, 0); } else { t2 = new Date(1970, 1, 1, time.getHours(), time.getMinutes(), time.getSeconds()); } return (t1 < t2) ? -1 : (t1 > t2) ? 1 : 0; }; this.equals = function (time) { return (this.compareTo(time) === 0); }; this.add = function (time) { return (time === null) ? this : this.addSeconds(time.getTotalMilliseconds() / 1000); }; this.subtract = function (time) { return (time === null) ? this : this.addSeconds(-time.getTotalMilliseconds() / 1000); }; this.addDays = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 86400000)); }; this.addHours = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 3600000)); }; this.addMinutes = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 60000)); }; this.addSeconds = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 1000)); }; this.addMilliseconds = function (n) { return new TimeSpan(this.getTotalMilliseconds() + n); }; this.get12HourHour = function () { return (this.getHours() > 12) ? this.getHours() - 12 : (this.getHours() === 0) ? 12 : this.getHours(); }; this.getDesignator = function () { return (this.getHours() < 12) ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator; }; this.toString = function (format) { this._toString = function () { if (this.getDays() !== null && this.getDays() > 0) { return this.getDays() + "." + this.getHours() + ":" + this.p(this.getMinutes()) + ":" + this.p(this.getSeconds()); } else { return this.getHours() + ":" + this.p(this.getMinutes()) + ":" + this.p(this.getSeconds()); } }; this.p = function (s) { return (s.toString().length < 2) ? "0" + s : s; }; var me = this; return format ? format.replace(/dd?|HH?|hh?|mm?|ss?|tt?/g, function (format) { switch (format) { case "d": return me.getDays(); case "dd": return me.p(me.getDays()); case "H": return me.getHours(); case "HH": return me.p(me.getHours()); case "h": return me.get12HourHour(); case "hh": return me.p(me.get12HourHour()); case "m": return me.getMinutes(); case "mm": return me.p(me.getMinutes()); case "s": return me.getSeconds(); case "ss": return me.p(me.getSeconds()); case "t": return ((me.getHours() < 12) ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator).substring(0, 1); case "tt": return (me.getHours() < 12) ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator; } } ) : this._toString(); }; return this; }; addSetFuncs(TimeSpan, attrs.slice(2)); TimeSpan.prototype.set = function (days, hours, minutes, seconds, milliseconds){ this.setDays(days || this.getDays()); this.setHours(hours || this.getHours()); this.setMinutes(minutes || this.getMinutes()); this.setSeconds(seconds || this.getSeconds()); this.setMilliseconds(milliseconds || this.getMilliseconds()); }; /** * Gets the time of day for this date instances. * @return {TimeSpan} TimeSpan */ Date.prototype.getTimeOfDay = function () { return new TimeSpan(0, this.getHours(), this.getMinutes(), this.getSeconds(), this.getMilliseconds()); }; Date.TimeSpan = TimeSpan; if (typeof window !== "undefined" ) { // keeping API compatible for v1.x window.TimeSpan = TimeSpan; } }()); (function () { "use strict"; var attrs = ["years", "months", "days", "hours", "minutes", "seconds", "milliseconds"]; var gFn = function (attr) { return function () { return this[attr]; }; }; var sFn = function (attr) { return function (val) { this[attr] = val; return this; }; }; var addSetFuncs = function (context, attrs) { for (var i = 0; i < attrs.length ; i++) { var $a = attrs[i], $b = $a.slice(0, 1).toUpperCase() + $a.slice(1); context.prototype[$a] = 0; context.prototype["get" + $b] = gFn($a); context.prototype["set" + $b] = sFn($a); } }; var setMonthsAndYears = function (orient, d1, d2, context) { function inc() { d1.addMonths(-orient); context.months++; if (context.months === 12) { context.years++; context.months = 0; } } if (orient === +1) { while (d1 > d2) { inc(); } } else { while (d1 < d2) { inc(); } } context.months--; context.months *= orient; context.years *= orient; }; var adjustForDST = function(orient, startDate, endDate) { var hasDSTMismatch = (false === (startDate.isDaylightSavingTime() === endDate.isDaylightSavingTime())); if (hasDSTMismatch && orient === 1) { startDate.addHours(-1); } else if (hasDSTMismatch) { startDate.addHours(1); } }; /** * TimePeriod(startDate, endDate); * TimePeriod(years, months, days, hours, minutes, seconds, milliseconds); */ var TimePeriod = function (years, months, days, hours, minutes, seconds, milliseconds) { if (arguments.length === 7) { this.set(years, months, days, hours, minutes, seconds, milliseconds); } else if (arguments.length === 2 && arguments[0] instanceof Date && arguments[1] instanceof Date) { var startDate = arguments[0].clone(); var endDate = arguments[1].clone(); var orient = (startDate > endDate) ? +1 : -1; this.dates = { start: arguments[0].clone(), end: arguments[1].clone() }; setMonthsAndYears(orient, startDate, endDate, this); adjustForDST(orient, startDate, endDate); // // TODO - adjust for DST var diff = endDate - startDate; if (diff !== 0) { var ts = new TimeSpan(diff); this.set(this.years, this.months, ts.getDays(), ts.getHours(), ts.getMinutes(), ts.getSeconds(), ts.getMilliseconds()); } } return this; }; // create all the set functions. addSetFuncs(TimePeriod, attrs); TimePeriod.prototype.set = function (years, months, days, hours, minutes, seconds, milliseconds){ this.setYears(years || this.getYears()); this.setMonths(months || this.getMonths()); this.setDays(days || this.getDays()); this.setHours(hours || this.getHours()); this.setMinutes(minutes || this.getMinutes()); this.setSeconds(seconds || this.getSeconds()); this.setMilliseconds(milliseconds || this.getMilliseconds()); }; Date.TimePeriod = TimePeriod; if (typeof window !== "undefined") { // keeping API compatible for v1.x window.TimePeriod = TimePeriod; } }()); ================================================ FILE: build/date-tt-RU.js ================================================ /** * @overview datejs * @version 1.0.0-rc3 * @author Gregory Wild-Smith * @copyright 2015 Gregory Wild-Smith * @license MIT * @homepage https://github.com/abritinthebay/datejs */ /* * DateJS Culture String File * Country Code: tt-RU * Name: Tatar (Russia) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["tt-RU"] = { "name": "tt-RU", "englishName": "Tatar (Russia)", "nativeName": "Татар (Россия)", "Sunday": "Якшәмбе", "Monday": "Дүшәмбе", "Tuesday": "Сишәмбе", "Wednesday": "Чәршәмбе", "Thursday": "Пәнҗешәмбе", "Friday": "Җомга", "Saturday": "Шимбә", "Sun": "Якш", "Mon": "Дүш", "Tue": "Сиш", "Wed": "Чәрш", "Thu": "Пәнҗ", "Fri": "Җом", "Sat": "Шим", "Su": "Якш", "Mo": "Дүш", "Tu": "Сиш", "We": "Чәрш", "Th": "Пәнҗ", "Fr": "Җом", "Sa": "Шим", "S_Sun_Initial": "Я", "M_Mon_Initial": "Д", "T_Tue_Initial": "С", "W_Wed_Initial": "Ч", "T_Thu_Initial": "П", "F_Fri_Initial": "Җ", "S_Sat_Initial": "Ш", "January": "Гыйнварь", "February": "Февраль", "March": "Март", "April": "Апрель", "May": "Май", "June": "Июнь", "July": "Июль", "August": "Август", "September": "Сентябрь", "October": "Октябрь", "November": "Ноябрь", "December": "Декабрь", "Jan_Abbr": "Гыйнв", "Feb_Abbr": "Фев", "Mar_Abbr": "Мар", "Apr_Abbr": "Апр", "May_Abbr": "Май", "Jun_Abbr": "Июн", "Jul_Abbr": "Июл", "Aug_Abbr": "Авг", "Sep_Abbr": "Сен", "Oct_Abbr": "Окт", "Nov_Abbr": "Ноя", "Dec_Abbr": "Дек", "AM": "", "PM": "", "firstDayOfWeek": 1, "twoDigitYearMax": 2029, "mdy": "dmy", "M/d/yyyy": "dd.MM.yyyy", "dddd, MMMM dd, yyyy": "d MMMM yyyy", "h:mm tt": "H:mm", "h:mm:ss tt": "H:mm:ss", "dddd, MMMM dd, yyyy h:mm:ss tt": "d MMMM yyyy H:mm:ss", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "d MMMM", "MMMM, yyyy": "MMMM yyyy", "/jan(uary)?/": "гыйнв(арь)?", "/feb(ruary)?/": "фев(раль)?", "/mar(ch)?/": "мар(т)?", "/apr(il)?/": "апр(ель)?", "/may/": "май", "/jun(e)?/": "июн(ь)?", "/jul(y)?/": "июл(ь)?", "/aug(ust)?/": "авг(уст)?", "/sep(t(ember)?)?/": "сен(тябрь)?", "/oct(ober)?/": "окт(ябрь)?", "/nov(ember)?/": "ноя(брь)?", "/dec(ember)?/": "дек(абрь)?", "/^su(n(day)?)?/": "^якшәмбе", "/^mo(n(day)?)?/": "^дүшәмбе", "/^tu(e(s(day)?)?)?/": "^сишәмбе", "/^we(d(nesday)?)?/": "^чәршәмбе", "/^th(u(r(s(day)?)?)?)?/": "^пәнҗешәмбе", "/^fr(i(day)?)?/": "^җомга", "/^sa(t(urday)?)?/": "^шимбә", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "tt-RU"; /** * @overview datejs * @version 1.0.0-rc3 * @author Gregory Wild-Smith * @copyright 2015 Gregory Wild-Smith * @license MIT * @homepage https://github.com/abritinthebay/datejs */(function () { var $D = Date; var lang = Date.CultureStrings ? Date.CultureStrings.lang : null; var loggedKeys = {}; // for debug purposes. var getText = { getFromKey: function (key, countryCode) { var output; if (Date.CultureStrings && Date.CultureStrings[countryCode] && Date.CultureStrings[countryCode][key]) { output = Date.CultureStrings[countryCode][key]; } else { output = getText.buildFromDefault(key); } if (key.charAt(0) === "/") { // Assume it's a regex output = getText.buildFromRegex(key, countryCode); } return output; }, getFromObjectValues: function (obj, countryCode) { var key, output = {}; for(key in obj) { if (obj.hasOwnProperty(key)) { output[key] = getText.getFromKey(obj[key], countryCode); } } return output; }, getFromObjectKeys: function (obj, countryCode) { var key, output = {}; for(key in obj) { if (obj.hasOwnProperty(key)) { output[getText.getFromKey(key, countryCode)] = obj[key]; } } return output; }, getFromArray: function (arr, countryCode) { var output = []; for (var i=0; i < arr.length; i++){ if (i in arr) { output[i] = getText.getFromKey(arr[i], countryCode); } } return output; }, buildFromDefault: function (key) { var output, length, split, last; switch(key) { case "name": output = "en-US"; break; case "englishName": output = "English (United States)"; break; case "nativeName": output = "English (United States)"; break; case "twoDigitYearMax": output = 2049; break; case "firstDayOfWeek": output = 0; break; default: output = key; split = key.split("_"); length = split.length; if (length > 1 && key.charAt(0) !== "/") { // if the key isn't a regex and it has a split. last = split[(length - 1)].toLowerCase(); if (last === "initial" || last === "abbr") { output = split[0]; } } break; } return output; }, buildFromRegex: function (key, countryCode) { var output; if (Date.CultureStrings && Date.CultureStrings[countryCode] && Date.CultureStrings[countryCode][key]) { output = new RegExp(Date.CultureStrings[countryCode][key], "i"); } else { output = new RegExp(key.replace(new RegExp("/", "g"),""), "i"); } return output; } }; var shallowMerge = function (obj1, obj2) { for (var attrname in obj2) { if (obj2.hasOwnProperty(attrname)) { obj1[attrname] = obj2[attrname]; } } }; var __ = function (key, language) { var countryCode = (language) ? language : lang; loggedKeys[key] = key; if (typeof key === "object") { if (key instanceof Array) { return getText.getFromArray(key, countryCode); } else { return getText.getFromObjectKeys(key, countryCode); } } else { return getText.getFromKey(key, countryCode); } }; var loadI18nScript = function (code) { // paatterned after jQuery's getScript. var url = Date.Config.i18n + code + ".js"; var head = document.getElementsByTagName("head")[0] || document.documentElement; var script = document.createElement("script"); script.src = url; var completed = false; var events = { done: function (){} // placeholder function }; // Attach handlers for all browsers script.onload = script.onreadystatechange = function() { if ( !completed && (!this.readyState || this.readyState === "loaded" || this.readyState === "complete") ) { events.done(); head.removeChild(script); } }; setTimeout(function() { head.insertBefore(script, head.firstChild); }, 0); // allows return to execute first return { done: function (cb) { events.done = function() { if (cb) { setTimeout(cb,0); } }; } }; }; var buildInfo = { buildFromMethodHash: function (obj) { var key; for(key in obj) { if (obj.hasOwnProperty(key)) { obj[key] = buildInfo[obj[key]](); } } return obj; }, timeZoneDST: function () { var DST = { "CHADT": "+1345", "NZDT": "+1300", "AEDT": "+1100", "ACDT": "+1030", "AZST": "+0500", "IRDT": "+0430", "EEST": "+0300", "CEST": "+0200", "BST": "+0100", "PMDT": "-0200", "ADT": "-0300", "NDT": "-0230", "EDT": "-0400", "CDT": "-0500", "MDT": "-0600", "PDT": "-0700", "AKDT": "-0800", "HADT": "-0900" }; return __(DST); }, timeZoneStandard: function () { var standard = { "LINT": "+1400", "TOT": "+1300", "CHAST": "+1245", "NZST": "+1200", "NFT": "+1130", "SBT": "+1100", "AEST": "+1000", "ACST": "+0930", "JST": "+0900", "CWST": "+0845", "CT": "+0800", "ICT": "+0700", "MMT": "+0630", "BST": "+0600", "NPT": "+0545", "IST": "+0530", "PKT": "+0500", "AFT": "+0430", "MSK": "+0400", "IRST": "+0330", "FET": "+0300", "EET": "+0200", "CET": "+0100", "GMT": "+0000", "UTC": "+0000", "CVT": "-0100", "GST": "-0200", "BRT": "-0300", "NST": "-0330", "AST": "-0400", "EST": "-0500", "CST": "-0600", "MST": "-0700", "PST": "-0800", "AKST": "-0900", "MIT": "-0930", "HST": "-1000", "SST": "-1100", "BIT": "-1200" }; return __(standard); }, timeZones: function (data) { var zone; data.timezones = []; for (zone in data.abbreviatedTimeZoneStandard) { if (data.abbreviatedTimeZoneStandard.hasOwnProperty(zone)) { data.timezones.push({ name: zone, offset: data.abbreviatedTimeZoneStandard[zone]}); } } for (zone in data.abbreviatedTimeZoneDST) { if (data.abbreviatedTimeZoneDST.hasOwnProperty(zone)) { data.timezones.push({ name: zone, offset: data.abbreviatedTimeZoneDST[zone], dst: true}); } } return data.timezones; }, days: function () { return __(["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"]); }, dayAbbr: function () { return __(["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"]); }, dayShortNames: function () { return __(["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"]); }, dayFirstLetters: function () { return __(["S_Sun_Initial", "M_Mon_Initial", "T_Tues_Initial", "W_Wed_Initial", "T_Thu_Initial", "F_Fri_Initial", "S_Sat_Initial"]); }, months: function () { return __(["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"]); }, monthAbbr: function () { return __(["Jan_Abbr", "Feb_Abbr", "Mar_Abbr", "Apr_Abbr", "May_Abbr", "Jun_Abbr", "Jul_Abbr", "Aug_Abbr", "Sep_Abbr", "Oct_Abbr", "Nov_Abbr", "Dec_Abbr"]); }, formatPatterns: function () { return getText.getFromObjectValues({ shortDate: "M/d/yyyy", longDate: "dddd, MMMM dd, yyyy", shortTime: "h:mm tt", longTime: "h:mm:ss tt", fullDateTime: "dddd, MMMM dd, yyyy h:mm:ss tt", sortableDateTime: "yyyy-MM-ddTHH:mm:ss", universalSortableDateTime: "yyyy-MM-dd HH:mm:ssZ", rfc1123: "ddd, dd MMM yyyy HH:mm:ss", monthDay: "MMMM dd", yearMonth: "MMMM, yyyy" }, Date.i18n.currentLanguage()); }, regex: function () { return getText.getFromObjectValues({ inTheMorning: "/( in the )(morn(ing)?)\\b/", thisMorning: "/(this )(morn(ing)?)\\b/", amThisMorning: "/(\b\\d(am)? )(this )(morn(ing)?)/", inTheEvening: "/( in the )(even(ing)?)\\b/", thisEvening: "/(this )(even(ing)?)\\b/", pmThisEvening: "/(\b\\d(pm)? )(this )(even(ing)?)/", jan: "/jan(uary)?/", feb: "/feb(ruary)?/", mar: "/mar(ch)?/", apr: "/apr(il)?/", may: "/may/", jun: "/jun(e)?/", jul: "/jul(y)?/", aug: "/aug(ust)?/", sep: "/sep(t(ember)?)?/", oct: "/oct(ober)?/", nov: "/nov(ember)?/", dec: "/dec(ember)?/", sun: "/^su(n(day)?)?/", mon: "/^mo(n(day)?)?/", tue: "/^tu(e(s(day)?)?)?/", wed: "/^we(d(nesday)?)?/", thu: "/^th(u(r(s(day)?)?)?)?/", fri: "/fr(i(day)?)?/", sat: "/^sa(t(urday)?)?/", future: "/^next/", past: "/^last|past|prev(ious)?/", add: "/^(\\+|aft(er)?|from|hence)/", subtract: "/^(\\-|bef(ore)?|ago)/", yesterday: "/^yes(terday)?/", today: "/^t(od(ay)?)?/", tomorrow: "/^tom(orrow)?/", now: "/^n(ow)?/", millisecond: "/^ms|milli(second)?s?/", second: "/^sec(ond)?s?/", minute: "/^mn|min(ute)?s?/", hour: "/^h(our)?s?/", week: "/^w(eek)?s?/", month: "/^m(onth)?s?/", day: "/^d(ay)?s?/", year: "/^y(ear)?s?/", shortMeridian: "/^(a|p)/", longMeridian: "/^(a\\.?m?\\.?|p\\.?m?\\.?)/", timezone: "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/", ordinalSuffix: "/^\\s*(st|nd|rd|th)/", timeContext: "/^\\s*(\\:|a(?!u|p)|p)/" }, Date.i18n.currentLanguage()); } }; var CultureInfo = function () { var info = getText.getFromObjectValues({ name: "name", englishName: "englishName", nativeName: "nativeName", amDesignator: "AM", pmDesignator: "PM", firstDayOfWeek: "firstDayOfWeek", twoDigitYearMax: "twoDigitYearMax", dateElementOrder: "mdy" }, Date.i18n.currentLanguage()); var constructedInfo = buildInfo.buildFromMethodHash({ dayNames: "days", abbreviatedDayNames: "dayAbbr", shortestDayNames: "dayShortNames", firstLetterDayNames: "dayFirstLetters", monthNames: "months", abbreviatedMonthNames: "monthAbbr", formatPatterns: "formatPatterns", regexPatterns: "regex", abbreviatedTimeZoneDST: "timeZoneDST", abbreviatedTimeZoneStandard: "timeZoneStandard" }); shallowMerge(info, constructedInfo); buildInfo.timeZones(info); return info; }; $D.i18n = { __: function (key, lang) { return __(key, lang); }, currentLanguage: function () { return lang || "en-US"; }, setLanguage: function (code, force, cb) { var async = false; if (force || code === "en-US" || (!!Date.CultureStrings && !!Date.CultureStrings[code])) { lang = code; Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings.lang = code; Date.CultureInfo = new CultureInfo(); } else { if (!(!!Date.CultureStrings && !!Date.CultureStrings[code])) { if (typeof exports !== "undefined" && this.exports !== exports) { // we're in a Node enviroment, load it using require try { require("../i18n/" + code + ".js"); lang = code; Date.CultureStrings.lang = code; Date.CultureInfo = new CultureInfo(); } catch (e) { // var str = "The language for '" + code + "' could not be loaded by Node. It likely does not exist."; throw new Error("The DateJS IETF language tag '" + code + "' could not be loaded by Node. It likely does not exist."); } } else if (Date.Config && Date.Config.i18n) { // we know the location of the files, so lets load them async = true; loadI18nScript(code).done(function(){ lang = code; Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings.lang = code; Date.CultureInfo = new CultureInfo(); $D.Parsing.Normalizer.buildReplaceData(); // because this is async if ($D.Grammar) { $D.Grammar.buildGrammarFormats(); // so we can parse those strings... } if (cb) { setTimeout(cb,0); } }); } else { Date.console.error("The DateJS IETF language tag '" + code + "' is not available and has not been loaded."); return false; } } } $D.Parsing.Normalizer.buildReplaceData(); // rebuild normalizer strings if ($D.Grammar) { $D.Grammar.buildGrammarFormats(); // so we can parse those strings... } if (!async && cb) { setTimeout(cb,0); } }, getLoggedKeys: function () { return loggedKeys; }, updateCultureInfo: function () { Date.CultureInfo = new CultureInfo(); } }; $D.i18n.updateCultureInfo(); // run automatically }()); (function () { var $D = Date, $P = $D.prototype, p = function (s, l) { if (!l) { l = 2; } return ("000" + s).slice(l * -1); }; if (typeof window !== "undefined" && typeof window.console !== "undefined" && typeof window.console.log !== "undefined") { $D.console = console; // used only to raise non-critical errors if available } else { // set mock so we don't give errors. $D.console = { log: function(){}, error: function(){} }; } $D.Config = $D.Config || {}; $D.initOverloads = function() { /** * Overload of Date.now. Allows an alternate call for Date.now where it returns the * current Date as an object rather than just milliseconds since the Unix Epoch. * * Also provides an implementation of now() for browsers (IE<9) that don't have it. * * Backwards compatible so with work with either: * Date.now() [returns ms] * or * Date.now(true) [returns Date] */ if (!$D.now) { $D._now = function now() { return new Date().getTime(); }; } else if (!$D._now) { $D._now = $D.now; } $D.now = function (returnObj) { if (returnObj) { return $D.present(); } else { return $D._now(); } }; if ( !$P.toISOString ) { $P.toISOString = function() { return this.getUTCFullYear() + "-" + p(this.getUTCMonth() + 1) + "-" + p(this.getUTCDate()) + "T" + p(this.getUTCHours()) + ":" + p(this.getUTCMinutes()) + ":" + p(this.getUTCSeconds()) + "." + String( (this.getUTCMilliseconds()/1000).toFixed(3)).slice(2, 5) + "Z"; }; } // private if ( $P._toString === undefined ){ $P._toString = $P.toString; } }; $D.initOverloads(); /** * Gets a date that is set to the current date. The time is set to the start of the day (00:00 or 12:00 AM). * @return {Date} The current date. */ $D.today = function () { return new Date().clearTime(); }; /** * Gets a date that is set to the current date and time (same as new Date, but chainable) * @return {Date} The current date. */ $D.present = function () { return new Date(); }; /** * Compares the first date to the second date and returns an number indication of their relative values. * @param {Date} First Date object to compare [Required]. * @param {Date} Second Date object to compare to [Required]. * @return {Number} -1 = date1 is lessthan date2. 0 = values are equal. 1 = date1 is greaterthan date2. */ $D.compare = function (date1, date2) { if (isNaN(date1) || isNaN(date2)) { throw new Error(date1 + " - " + date2); } else if (date1 instanceof Date && date2 instanceof Date) { return (date1 < date2) ? -1 : (date1 > date2) ? 1 : 0; } else { throw new TypeError(date1 + " - " + date2); } }; /** * Compares the first Date object to the second Date object and returns true if they are equal. * @param {Date} First Date object to compare [Required] * @param {Date} Second Date object to compare to [Required] * @return {Boolean} true if dates are equal. false if they are not equal. */ $D.equals = function (date1, date2) { return (date1.compareTo(date2) === 0); }; /** * Gets the language appropriate day name when given the day number(0-6) * eg - 0 == Sunday * @return {String} The day name */ $D.getDayName = function (n) { return Date.CultureInfo.dayNames[n]; }; /** * Gets the day number (0-6) if given a CultureInfo specific string which is a valid dayName, abbreviatedDayName or shortestDayName (two char). * @param {String} The name of the day (eg. "Monday, "Mon", "tuesday", "tue", "We", "we"). * @return {Number} The day number */ $D.getDayNumberFromName = function (name) { var n = Date.CultureInfo.dayNames, m = Date.CultureInfo.abbreviatedDayNames, o = Date.CultureInfo.shortestDayNames, s = name.toLowerCase(); for (var i = 0; i < n.length; i++) { if (n[i].toLowerCase() === s || m[i].toLowerCase() === s || o[i].toLowerCase() === s) { return i; } } return -1; }; /** * Gets the month number (0-11) if given a Culture Info specific string which is a valid monthName or abbreviatedMonthName. * @param {String} The name of the month (eg. "February, "Feb", "october", "oct"). * @return {Number} The day number */ $D.getMonthNumberFromName = function (name) { var n = Date.CultureInfo.monthNames, m = Date.CultureInfo.abbreviatedMonthNames, s = name.toLowerCase(); for (var i = 0; i < n.length; i++) { if (n[i].toLowerCase() === s || m[i].toLowerCase() === s) { return i; } } return -1; }; /** * Gets the language appropriate month name when given the month number(0-11) * eg - 0 == January * @return {String} The month name */ $D.getMonthName = function (n) { return Date.CultureInfo.monthNames[n]; }; /** * Determines if the current date instance is within a LeapYear. * @param {Number} The year. * @return {Boolean} true if date is within a LeapYear, otherwise false. */ $D.isLeapYear = function (year) { return ((year % 4 === 0 && year % 100 !== 0) || year % 400 === 0); }; /** * Gets the number of days in the month, given a year and month value. Automatically corrects for LeapYear. * @param {Number} The year. * @param {Number} The month (0-11). * @return {Number} The number of days in the month. */ $D.getDaysInMonth = function (year, month) { if (!month && $D.validateMonth(year)) { month = year; year = Date.today().getFullYear(); } return [31, ($D.isLeapYear(year) ? 29 : 28), 31, 30, 31, 30, 31, 31, 30, 31, 30, 31][month]; }; $P.getDaysInMonth = function () { return $D.getDaysInMonth(this.getFullYear(), this.getMonth()); }; $D.getTimezoneAbbreviation = function (offset, dst) { var p, n = (dst || false) ? Date.CultureInfo.abbreviatedTimeZoneDST : Date.CultureInfo.abbreviatedTimeZoneStandard; for (p in n) { if (n.hasOwnProperty(p)) { if (n[p] === offset) { return p; } } } return null; }; $D.getTimezoneOffset = function (name, dst) { var i, a =[], z = Date.CultureInfo.timezones; if (!name) { name = (new Date()).getTimezone();} for (i = 0; i < z.length; i++) { if (z[i].name === name.toUpperCase()) { a.push(i); } } if (!z[a[0]]) { return null; } if (a.length === 1 || !dst) { return z[a[0]].offset; } else { for (i=0; i < a.length; i++) { if (z[a[i]].dst) { return z[a[i]].offset; } } } }; $D.getQuarter = function (d) { d = d || new Date(); // If no date supplied, use today var q = [1,2,3,4]; return q[Math.floor(d.getMonth() / 3)]; // ~~~ is a bitwise op. Faster than Math.floor }; $D.getDaysLeftInQuarter = function (d) { d = d || new Date(); var qEnd = new Date(d); qEnd.setMonth(qEnd.getMonth() + 3 - qEnd.getMonth() % 3, 0); return Math.floor((qEnd - d) / 8.64e7); }; // private var validate = function (n, min, max, name) { name = name ? name : "Object"; if (typeof n === "undefined") { return false; } else if (typeof n !== "number") { throw new TypeError(n + " is not a Number."); } else if (n < min || n > max) { // As failing validation is *not* an exceptional circumstance // lets not throw a RangeError Exception here. // It's semantically correct but it's not sensible. return false; } return true; }; /** * Validates the number is within an acceptable range for milliseconds [0-999]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateMillisecond = function (value) { return validate(value, 0, 999, "millisecond"); }; /** * Validates the number is within an acceptable range for seconds [0-59]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateSecond = function (value) { return validate(value, 0, 59, "second"); }; /** * Validates the number is within an acceptable range for minutes [0-59]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateMinute = function (value) { return validate(value, 0, 59, "minute"); }; /** * Validates the number is within an acceptable range for hours [0-23]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateHour = function (value) { return validate(value, 0, 23, "hour"); }; /** * Validates the number is within an acceptable range for the days in a month [0-MaxDaysInMonth]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateDay = function (value, year, month) { if (year === undefined || year === null || month === undefined || month === null) { return false;} return validate(value, 1, $D.getDaysInMonth(year, month), "day"); }; /** * Validates the number is within an acceptable range for months [0-11]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateWeek = function (value) { return validate(value, 0, 53, "week"); }; /** * Validates the number is within an acceptable range for months [0-11]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateMonth = function (value) { return validate(value, 0, 11, "month"); }; /** * Validates the number is within an acceptable range for years. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateYear = function (value) { /** * Per ECMAScript spec the range of times supported by Date objects is * exactly -100,000,000 days to +100,000,000 days measured relative to * midnight at the beginning of 01 January, 1970 UTC. * This gives a range of 8,640,000,000,000,000 milliseconds to either * side of 01 January, 1970 UTC. * * Earliest possible date: Tue, 20 Apr 271,822 B.C. 00:00:00 UTC * Latest possible date: Sat, 13 Sep 275,760 00:00:00 UTC */ return validate(value, -271822, 275760, "year"); }; $D.validateTimezone = function(value) { var timezones = {"ACDT":1,"ACST":1,"ACT":1,"ADT":1,"AEDT":1,"AEST":1,"AFT":1,"AKDT":1,"AKST":1,"AMST":1,"AMT":1,"ART":1,"AST":1,"AWDT":1,"AWST":1,"AZOST":1,"AZT":1,"BDT":1,"BIOT":1,"BIT":1,"BOT":1,"BRT":1,"BST":1,"BTT":1,"CAT":1,"CCT":1,"CDT":1,"CEDT":1,"CEST":1,"CET":1,"CHADT":1,"CHAST":1,"CHOT":1,"ChST":1,"CHUT":1,"CIST":1,"CIT":1,"CKT":1,"CLST":1,"CLT":1,"COST":1,"COT":1,"CST":1,"CT":1,"CVT":1,"CWST":1,"CXT":1,"DAVT":1,"DDUT":1,"DFT":1,"EASST":1,"EAST":1,"EAT":1,"ECT":1,"EDT":1,"EEDT":1,"EEST":1,"EET":1,"EGST":1,"EGT":1,"EIT":1,"EST":1,"FET":1,"FJT":1,"FKST":1,"FKT":1,"FNT":1,"GALT":1,"GAMT":1,"GET":1,"GFT":1,"GILT":1,"GIT":1,"GMT":1,"GST":1,"GYT":1,"HADT":1,"HAEC":1,"HAST":1,"HKT":1,"HMT":1,"HOVT":1,"HST":1,"ICT":1,"IDT":1,"IOT":1,"IRDT":1,"IRKT":1,"IRST":1,"IST":1,"JST":1,"KGT":1,"KOST":1,"KRAT":1,"KST":1,"LHST":1,"LINT":1,"MAGT":1,"MART":1,"MAWT":1,"MDT":1,"MET":1,"MEST":1,"MHT":1,"MIST":1,"MIT":1,"MMT":1,"MSK":1,"MST":1,"MUT":1,"MVT":1,"MYT":1,"NCT":1,"NDT":1,"NFT":1,"NPT":1,"NST":1,"NT":1,"NUT":1,"NZDT":1,"NZST":1,"OMST":1,"ORAT":1,"PDT":1,"PET":1,"PETT":1,"PGT":1,"PHOT":1,"PHT":1,"PKT":1,"PMDT":1,"PMST":1,"PONT":1,"PST":1,"PYST":1,"PYT":1,"RET":1,"ROTT":1,"SAKT":1,"SAMT":1,"SAST":1,"SBT":1,"SCT":1,"SGT":1,"SLST":1,"SRT":1,"SST":1,"SYOT":1,"TAHT":1,"THA":1,"TFT":1,"TJT":1,"TKT":1,"TLT":1,"TMT":1,"TOT":1,"TVT":1,"UCT":1,"ULAT":1,"UTC":1,"UYST":1,"UYT":1,"UZT":1,"VET":1,"VLAT":1,"VOLT":1,"VOST":1,"VUT":1,"WAKT":1,"WAST":1,"WAT":1,"WEDT":1,"WEST":1,"WET":1,"WST":1,"YAKT":1,"YEKT":1,"Z":1}; return (timezones[value] === 1); }; $D.validateTimezoneOffset= function(value) { // timezones go from +14hrs to -12hrs, the +X hours are negative offsets. return (value > -841 && value < 721); }; }()); (function () { var $D = Date, $P = $D.prototype, p = function (s, l) { if (!l) { l = 2; } return ("000" + s).slice(l * -1); }; var validateConfigObject = function (obj) { var result = {}, self = this, prop, testFunc; testFunc = function (prop, func, value) { if (prop === "day") { var month = (obj.month !== undefined) ? obj.month : self.getMonth(); var year = (obj.year !== undefined) ? obj.year : self.getFullYear(); return $D[func](value, year, month); } else { return $D[func](value); } }; for (prop in obj) { if (Object.prototype.hasOwnProperty.call(obj, prop)) { var func = "validate" + prop.charAt(0).toUpperCase() + prop.slice(1); if ($D[func] && obj[prop] !== null && testFunc(prop, func, obj[prop])) { result[prop] = obj[prop]; } } } return result; }; /** * Resets the time of this Date object to 12:00 AM (00:00), which is the start of the day. * @param {Boolean} .clone() this date instance before clearing Time * @return {Date} this */ $P.clearTime = function () { this.setHours(0); this.setMinutes(0); this.setSeconds(0); this.setMilliseconds(0); return this; }; /** * Resets the time of this Date object to the current time ('now'). * @return {Date} this */ $P.setTimeToNow = function () { var n = new Date(); this.setHours(n.getHours()); this.setMinutes(n.getMinutes()); this.setSeconds(n.getSeconds()); this.setMilliseconds(n.getMilliseconds()); return this; }; /** * Returns a new Date object that is an exact date and time copy of the original instance. * @return {Date} A new Date instance */ $P.clone = function () { return new Date(this.getTime()); }; /** * Compares this instance to a Date object and returns an number indication of their relative values. * @param {Date} Date object to compare [Required] * @return {Number} -1 = this is lessthan date. 0 = values are equal. 1 = this is greaterthan date. */ $P.compareTo = function (date) { return Date.compare(this, date); }; /** * Compares this instance to another Date object and returns true if they are equal. * @param {Date} Date object to compare. If no date to compare, new Date() [now] is used. * @return {Boolean} true if dates are equal. false if they are not equal. */ $P.equals = function (date) { return Date.equals(this, (date !== undefined ? date : new Date())); }; /** * Determines if this instance is between a range of two dates or equal to either the start or end dates. * @param {Date} Start of range [Required] * @param {Date} End of range [Required] * @return {Boolean} true is this is between or equal to the start and end dates, else false */ $P.between = function (start, end) { return this.getTime() >= start.getTime() && this.getTime() <= end.getTime(); }; /** * Determines if this date occurs after the date to compare to. * @param {Date} Date object to compare. If no date to compare, new Date() ("now") is used. * @return {Boolean} true if this date instance is greater than the date to compare to (or "now"), otherwise false. */ $P.isAfter = function (date) { return this.compareTo(date || new Date()) === 1; }; /** * Determines if this date occurs before the date to compare to. * @param {Date} Date object to compare. If no date to compare, new Date() ("now") is used. * @return {Boolean} true if this date instance is less than the date to compare to (or "now"). */ $P.isBefore = function (date) { return (this.compareTo(date || new Date()) === -1); }; /** * Determines if the current Date instance occurs today. * @return {Boolean} true if this date instance is 'today', otherwise false. */ /** * Determines if the current Date instance occurs on the same Date as the supplied 'date'. * If no 'date' to compare to is provided, the current Date instance is compared to 'today'. * @param {date} Date object to compare. If no date to compare, the current Date ("now") is used. * @return {Boolean} true if this Date instance occurs on the same Day as the supplied 'date'. */ $P.isToday = $P.isSameDay = function (date) { return this.clone().clearTime().equals((date || new Date()).clone().clearTime()); }; /** * Adds the specified number of milliseconds to this instance. * @param {Number} The number of milliseconds to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addMilliseconds = function (value) { if (!value) { return this; } this.setTime(this.getTime() + value * 1); return this; }; /** * Adds the specified number of seconds to this instance. * @param {Number} The number of seconds to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addSeconds = function (value) { if (!value) { return this; } return this.addMilliseconds(value * 1000); }; /** * Adds the specified number of seconds to this instance. * @param {Number} The number of seconds to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addMinutes = function (value) { if (!value) { return this; } return this.addMilliseconds(value * 60000); // 60*1000 }; /** * Adds the specified number of hours to this instance. * @param {Number} The number of hours to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addHours = function (value) { if (!value) { return this; } return this.addMilliseconds(value * 3600000); // 60*60*1000 }; /** * Adds the specified number of days to this instance. * @param {Number} The number of days to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addDays = function (value) { if (!value) { return this; } this.setDate(this.getDate() + value * 1); return this; }; /** * Adds the specified number of weekdays (ie - not sat or sun) to this instance. * @param {Number} The number of days to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addWeekdays = function (value) { if (!value) { return this; } var day = this.getDay(); var weeks = (Math.ceil(Math.abs(value)/7)); if (day === 0 || day === 6) { if (value > 0) { this.next().monday(); this.addDays(-1); day = this.getDay(); } } if (value < 0) { while (value < 0) { this.addDays(-1); day = this.getDay(); if (day !== 0 && day !== 6) { value++; } } return this; } else if (value > 5 || (6-day) <= value) { value = value + (weeks * 2); } return this.addDays(value); }; /** * Adds the specified number of weeks to this instance. * @param {Number} The number of weeks to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addWeeks = function (value) { if (!value) { return this; } return this.addDays(value * 7); }; /** * Adds the specified number of months to this instance. * @param {Number} The number of months to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addMonths = function (value) { if (!value) { return this; } var n = this.getDate(); this.setDate(1); this.setMonth(this.getMonth() + value * 1); this.setDate(Math.min(n, $D.getDaysInMonth(this.getFullYear(), this.getMonth()))); return this; }; $P.addQuarters = function (value) { if (!value) { return this; } // note this will take you to the same point in the quarter as you are now. // i.e. - if you are 15 days into the quarter you'll be 15 days into the resulting one. // bonus: this allows adding fractional quarters return this.addMonths(value * 3); }; /** * Adds the specified number of years to this instance. * @param {Number} The number of years to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addYears = function (value) { if (!value) { return this; } return this.addMonths(value * 12); }; /** * Adds (or subtracts) to the value of the years, months, weeks, days, hours, minutes, seconds, milliseconds of the date instance using given configuration object. Positive and Negative values allowed. * Example

	Date.today().add( { days: 1, months: 1 } )

	new Date().add( { years: -1 } )
	
* @param {Object} Configuration object containing attributes (months, days, etc.) * @return {Date} this */ $P.add = function (config) { if (typeof config === "number") { this._orient = config; return this; } var x = config; if (x.day) { // If we should be a different date than today (eg: for 'tomorrow -1d', etc). // Should only effect parsing, not direct usage (eg, Finish and FinishExact) if ((x.day - this.getDate()) !== 0) { this.setDate(x.day); } } if (x.milliseconds) { this.addMilliseconds(x.milliseconds); } if (x.seconds) { this.addSeconds(x.seconds); } if (x.minutes) { this.addMinutes(x.minutes); } if (x.hours) { this.addHours(x.hours); } if (x.weeks) { this.addWeeks(x.weeks); } if (x.months) { this.addMonths(x.months); } if (x.years) { this.addYears(x.years); } if (x.days) { this.addDays(x.days); } return this; }; /** * Get the week number. Week one (1) is the week which contains the first Thursday of the year. Monday is considered the first day of the week. * The .getWeek() function does NOT convert the date to UTC. The local datetime is used. * Please use .getISOWeek() to get the week of the UTC converted date. * @return {Number} 1 to 53 */ $P.getWeek = function (utc) { // Create a copy of this date object var self, target = new Date(this.valueOf()); if (utc) { target.addMinutes(target.getTimezoneOffset()); self = target.clone(); } else { self = this; } // ISO week date weeks start on monday // so correct the day number var dayNr = (self.getDay() + 6) % 7; // ISO 8601 states that week 1 is the week // with the first thursday of that year. // Set the target date to the thursday in the target week target.setDate(target.getDate() - dayNr + 3); // Store the millisecond value of the target date var firstThursday = target.valueOf(); // Set the target to the first thursday of the year // First set the target to january first target.setMonth(0, 1); // Not a thursday? Correct the date to the next thursday if (target.getDay() !== 4) { target.setMonth(0, 1 + ((4 - target.getDay()) + 7) % 7); } // The weeknumber is the number of weeks between the // first thursday of the year and the thursday in the target week return 1 + Math.ceil((firstThursday - target) / 604800000); // 604800000 = 7 * 24 * 3600 * 1000 }; /** * Get the ISO 8601 week number. Week one ("01") is the week which contains the first Thursday of the year. Monday is considered the first day of the week. * The .getISOWeek() function does convert the date to it's UTC value. Please use .getWeek() to get the week of the local date. * @return {String} "01" to "53" */ $P.getISOWeek = function () { return p(this.getWeek(true)); }; /** * Moves the date to Monday of the week set. Week one (1) is the week which contains the first Thursday of the year. * @param {Number} A Number (1 to 53) that represents the week of the year. * @return {Date} this */ $P.setWeek = function (n) { if ((n - this.getWeek()) === 0) { if (this.getDay() !== 1) { return this.moveToDayOfWeek(1, (this.getDay() > 1 ? -1 : 1)); } else { return this; } } else { return this.moveToDayOfWeek(1, (this.getDay() > 1 ? -1 : 1)).addWeeks(n - this.getWeek()); } }; $P.setQuarter = function (qtr) { var month = Math.abs(((qtr-1) * 3) + 1); return this.setMonth(month, 1); }; $P.getQuarter = function () { return Date.getQuarter(this); }; $P.getDaysLeftInQuarter = function () { return Date.getDaysLeftInQuarter(this); }; /** * Moves the date to the next n'th occurrence of the dayOfWeek starting from the beginning of the month. The number (-1) is a magic number and will return the last occurrence of the dayOfWeek in the month. * @param {Number} The dayOfWeek to move to * @param {Number} The n'th occurrence to move to. Use (-1) to return the last occurrence in the month * @return {Date} this */ $P.moveToNthOccurrence = function (dayOfWeek, occurrence) { if (dayOfWeek === "Weekday") { if (occurrence > 0) { this.moveToFirstDayOfMonth(); if (this.is().weekday()) { occurrence -= 1; } } else if (occurrence < 0) { this.moveToLastDayOfMonth(); if (this.is().weekday()) { occurrence += 1; } } else { return this; } return this.addWeekdays(occurrence); } var shift = 0; if (occurrence > 0) { shift = occurrence - 1; } else if (occurrence === -1) { this.moveToLastDayOfMonth(); if (this.getDay() !== dayOfWeek) { this.moveToDayOfWeek(dayOfWeek, -1); } return this; } return this.moveToFirstDayOfMonth().addDays(-1).moveToDayOfWeek(dayOfWeek, +1).addWeeks(shift); }; var moveToN = function (getFunc, addFunc, nVal) { return function (value, orient) { var diff = (value - this[getFunc]() + nVal * (orient || +1)) % nVal; return this[addFunc]((diff === 0) ? diff += nVal * (orient || +1) : diff); }; }; /** * Move to the next or last dayOfWeek based on the orient value. * @param {Number} The dayOfWeek to move to * @param {Number} Forward (+1) or Back (-1). Defaults to +1. [Optional] * @return {Date} this */ $P.moveToDayOfWeek = moveToN("getDay", "addDays", 7); /** * Move to the next or last month based on the orient value. * @param {Number} The month to move to. 0 = January, 11 = December * @param {Number} Forward (+1) or Back (-1). Defaults to +1. [Optional] * @return {Date} this */ $P.moveToMonth = moveToN("getMonth", "addMonths", 12); /** * Get the Ordinate of the current day ("th", "st", "rd"). * @return {String} */ $P.getOrdinate = function () { var num = this.getDate(); return ord(num); }; /** * Get the Ordinal day (numeric day number) of the year, adjusted for leap year. * @return {Number} 1 through 365 (366 in leap years) */ $P.getOrdinalNumber = function () { return Math.ceil((this.clone().clearTime() - new Date(this.getFullYear(), 0, 1)) / 86400000) + 1; }; /** * Get the time zone abbreviation of the current date. * @return {String} The abbreviated time zone name (e.g. "EST") */ $P.getTimezone = function () { return $D.getTimezoneAbbreviation(this.getUTCOffset(), this.isDaylightSavingTime()); }; $P.setTimezoneOffset = function (offset) { var here = this.getTimezoneOffset(), there = Number(offset) * -6 / 10; return (there || there === 0) ? this.addMinutes(there - here) : this; }; $P.setTimezone = function (offset) { return this.setTimezoneOffset($D.getTimezoneOffset(offset)); }; /** * Indicates whether Daylight Saving Time is observed in the current time zone. * @return {Boolean} true|false */ $P.hasDaylightSavingTime = function () { return (Date.today().set({month: 0, day: 1}).getTimezoneOffset() !== Date.today().set({month: 6, day: 1}).getTimezoneOffset()); }; /** * Indicates whether this Date instance is within the Daylight Saving Time range for the current time zone. * @return {Boolean} true|false */ $P.isDaylightSavingTime = function () { return Date.today().set({month: 0, day: 1}).getTimezoneOffset() !== this.getTimezoneOffset(); }; /** * Get the offset from UTC of the current date. * @return {String} The 4-character offset string prefixed with + or - (e.g. "-0500") */ $P.getUTCOffset = function (offset) { var n = (offset || this.getTimezoneOffset()) * -10 / 6, r; if (n < 0) { r = (n - 10000).toString(); return r.charAt(0) + r.substr(2); } else { r = (n + 10000).toString(); return "+" + r.substr(1); } }; /** * Returns the number of milliseconds between this date and date. * @param {Date} Defaults to now * @return {Number} The diff in milliseconds */ $P.getElapsed = function (date) { return (date || new Date()) - this; }; /** * Set the value of year, month, day, hour, minute, second, millisecond of date instance using given configuration object. * Example

	Date.today().set( { day: 20, month: 1 } )

	new Date().set( { millisecond: 0 } )
	
* * @param {Object} Configuration object containing attributes (month, day, etc.) * @return {Date} this */ $P.set = function (config) { config = validateConfigObject.call(this, config); var key; for (key in config) { if (Object.prototype.hasOwnProperty.call(config, key)) { var name = key.charAt(0).toUpperCase() + key.slice(1); var addFunc, getFunc; if (key !== "week" && key !== "month" && key !== "timezone" && key !== "timezoneOffset") { name += "s"; } addFunc = "add" + name; getFunc = "get" + name; if (key === "month") { addFunc = addFunc + "s"; } else if (key === "year"){ getFunc = "getFullYear"; } if (key !== "day" && key !== "timezone" && key !== "timezoneOffset" && key !== "week" && key !== "hour") { this[addFunc](config[key] - this[getFunc]()); } else if ( key === "timezone"|| key === "timezoneOffset" || key === "week" || key === "hour") { this["set"+name](config[key]); } } } // day has to go last because you can't validate the day without first knowing the month if (config.day) { this.addDays(config.day - this.getDate()); } return this; }; /** * Moves the date to the first day of the month. * @return {Date} this */ $P.moveToFirstDayOfMonth = function () { return this.set({ day: 1 }); }; /** * Moves the date to the last day of the month. * @return {Date} this */ $P.moveToLastDayOfMonth = function () { return this.set({ day: $D.getDaysInMonth(this.getFullYear(), this.getMonth())}); }; /** * Converts the value of the current Date object to its equivalent string representation. * Format Specifiers * CUSTOM DATE AND TIME FORMAT STRINGS * Format Description Example * ------ --------------------------------------------------------------------------- ----------------------- * s The seconds of the minute between 0-59. "0" to "59" * ss The seconds of the minute with leading zero if required. "00" to "59" * * m The minute of the hour between 0-59. "0" or "59" * mm The minute of the hour with leading zero if required. "00" or "59" * * h The hour of the day between 1-12. "1" to "12" * hh The hour of the day with leading zero if required. "01" to "12" * * H The hour of the day between 0-23. "0" to "23" * HH The hour of the day with leading zero if required. "00" to "23" * * d The day of the month between 1 and 31. "1" to "31" * dd The day of the month with leading zero if required. "01" to "31" * ddd Abbreviated day name. Date.CultureInfo.abbreviatedDayNames. "Mon" to "Sun" * dddd The full day name. Date.CultureInfo.dayNames. "Monday" to "Sunday" * * M The month of the year between 1-12. "1" to "12" * MM The month of the year with leading zero if required. "01" to "12" * MMM Abbreviated month name. Date.CultureInfo.abbreviatedMonthNames. "Jan" to "Dec" * MMMM The full month name. Date.CultureInfo.monthNames. "January" to "December" * * yy The year as a two-digit number. "99" or "08" * yyyy The full four digit year. "1999" or "2008" * * t Displays the first character of the A.M./P.M. designator. "A" or "P" * Date.CultureInfo.amDesignator or Date.CultureInfo.pmDesignator * tt Displays the A.M./P.M. designator. "AM" or "PM" * Date.CultureInfo.amDesignator or Date.CultureInfo.pmDesignator * * S The ordinal suffix ("st, "nd", "rd" or "th") of the current day. "st, "nd", "rd" or "th" * * STANDARD DATE AND TIME FORMAT STRINGS * Format Description Example *------ --------------------------------------------------------------------------- ----------------------- * d The CultureInfo shortDate Format Pattern "M/d/yyyy" * D The CultureInfo longDate Format Pattern "dddd, MMMM dd, yyyy" * F The CultureInfo fullDateTime Format Pattern "dddd, MMMM dd, yyyy h:mm:ss tt" * m The CultureInfo monthDay Format Pattern "MMMM dd" * r The CultureInfo rfc1123 Format Pattern "ddd, dd MMM yyyy HH:mm:ss GMT" * s The CultureInfo sortableDateTime Format Pattern "yyyy-MM-ddTHH:mm:ss" * t The CultureInfo shortTime Format Pattern "h:mm tt" * T The CultureInfo longTime Format Pattern "h:mm:ss tt" * u The CultureInfo universalSortableDateTime Format Pattern "yyyy-MM-dd HH:mm:ssZ" * y The CultureInfo yearMonth Format Pattern "MMMM, yyyy" * * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @return {String} A string representation of the current Date object. */ var ord = function (n) { switch (n * 1) { case 1: case 21: case 31: return "st"; case 2: case 22: return "nd"; case 3: case 23: return "rd"; default: return "th"; } }; var parseStandardFormats = function (format) { var y, c = Date.CultureInfo.formatPatterns; switch (format) { case "d": return this.toString(c.shortDate); case "D": return this.toString(c.longDate); case "F": return this.toString(c.fullDateTime); case "m": return this.toString(c.monthDay); case "r": case "R": y = this.clone().addMinutes(this.getTimezoneOffset()); return y.toString(c.rfc1123) + " GMT"; case "s": return this.toString(c.sortableDateTime); case "t": return this.toString(c.shortTime); case "T": return this.toString(c.longTime); case "u": y = this.clone().addMinutes(this.getTimezoneOffset()); return y.toString(c.universalSortableDateTime); case "y": return this.toString(c.yearMonth); default: return false; } }; var parseFormatStringsClosure = function (context) { return function (m) { if (m.charAt(0) === "\\") { return m.replace("\\", ""); } switch (m) { case "hh": return p(context.getHours() < 13 ? (context.getHours() === 0 ? 12 : context.getHours()) : (context.getHours() - 12)); case "h": return context.getHours() < 13 ? (context.getHours() === 0 ? 12 : context.getHours()) : (context.getHours() - 12); case "HH": return p(context.getHours()); case "H": return context.getHours(); case "mm": return p(context.getMinutes()); case "m": return context.getMinutes(); case "ss": return p(context.getSeconds()); case "s": return context.getSeconds(); case "yyyy": return p(context.getFullYear(), 4); case "yy": return p(context.getFullYear()); case "y": return context.getFullYear(); case "E": case "dddd": return Date.CultureInfo.dayNames[context.getDay()]; case "ddd": return Date.CultureInfo.abbreviatedDayNames[context.getDay()]; case "dd": return p(context.getDate()); case "d": return context.getDate(); case "MMMM": return Date.CultureInfo.monthNames[context.getMonth()]; case "MMM": return Date.CultureInfo.abbreviatedMonthNames[context.getMonth()]; case "MM": return p((context.getMonth() + 1)); case "M": return context.getMonth() + 1; case "t": return context.getHours() < 12 ? Date.CultureInfo.amDesignator.substring(0, 1) : Date.CultureInfo.pmDesignator.substring(0, 1); case "tt": return context.getHours() < 12 ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator; case "S": return ord(context.getDate()); case "W": return context.getWeek(); case "WW": return context.getISOWeek(); case "Q": return "Q" + context.getQuarter(); case "q": return String(context.getQuarter()); case "z": return context.getTimezone(); case "Z": case "X": return Date.getTimezoneOffset(context.getTimezone()); case "ZZ": // Timezone offset in seconds return context.getTimezoneOffset() * -60; case "u": return context.getDay(); case "L": return ($D.isLeapYear(context.getFullYear())) ? 1 : 0; case "B": // Swatch Internet Time (.beats) return "@"+((context.getUTCSeconds() + (context.getUTCMinutes()*60) + ((context.getUTCHours()+1)*3600))/86.4); default: return m; } }; }; $P.toString = function (format, ignoreStandards) { // Standard Date and Time Format Strings. Formats pulled from CultureInfo file and // may vary by culture. if (!ignoreStandards && format && format.length === 1) { output = parseStandardFormats.call(this, format); if (output) { return output; } } var parseFormatStrings = parseFormatStringsClosure(this); return format ? format.replace(/((\\)?(dd?d?d?|MM?M?M?|yy?y?y?|hh?|HH?|mm?|ss?|tt?|S|q|Q|WW?W?W?)(?![^\[]*\]))/g, parseFormatStrings).replace(/\[|\]/g, "") : this._toString(); }; }()); /************************************************************* * SugarPak - Domain Specific Language - Syntactical Sugar * *************************************************************/ (function () { var $D = Date, $P = $D.prototype, $N = Number.prototype; // private $P._orient = +1; // private $P._nth = null; // private $P._is = false; // private $P._same = false; // private $P._isSecond = false; // private $N._dateElement = "days"; /** * Moves the date to the next instance of a date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.today().next().friday();
	Date.today().next().fri();
	Date.today().next().march();
	Date.today().next().mar();
	Date.today().next().week();
	
* * @return {Date} date */ $P.next = function () { this._move = true; this._orient = +1; return this; }; /** * Creates a new Date (Date.today()) and moves the date to the next instance of the date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.next().friday();
	Date.next().fri();
	Date.next().march();
	Date.next().mar();
	Date.next().week();
	
* * @return {Date} date */ $D.next = function () { return $D.today().next(); }; /** * Moves the date to the previous instance of a date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.today().last().friday();
	Date.today().last().fri();
	Date.today().last().march();
	Date.today().last().mar();
	Date.today().last().week();
	
* * @return {Date} date */ $P.last = $P.prev = $P.previous = function () { this._move = true; this._orient = -1; return this; }; /** * Creates a new Date (Date.today()) and moves the date to the previous instance of the date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.last().friday();
	Date.last().fri();
	Date.previous().march();
	Date.prev().mar();
	Date.last().week();
	
* * @return {Date} date */ $D.last = $D.prev = $D.previous = function () { return $D.today().last(); }; /** * Performs a equality check when followed by either a month name, day name or .weekday() function. * Example

	Date.today().is().friday(); // true|false
	Date.today().is().fri();
	Date.today().is().march();
	Date.today().is().mar();
	
* * @return {Boolean} true|false */ $P.is = function () { this._is = true; return this; }; /** * Determines if two date objects occur on/in exactly the same instance of the subsequent date part function. * The function .same() must be followed by a date part function (example: .day(), .month(), .year(), etc). * * An optional Date can be passed in the date part function. If now date is passed as a parameter, 'Now' is used. * * The following example demonstrates how to determine if two dates fall on the exact same day. * * Example

	var d1 = Date.today(); // today at 00:00
	var d2 = new Date();   // exactly now.

	// Do they occur on the same day?
	d1.same().day(d2); // true
	
	// Do they occur on the same hour?
	d1.same().hour(d2); // false, unless d2 hour is '00' (midnight).
	
	// What if it's the same day, but one year apart?
	var nextYear = Date.today().add(1).year();

	d1.same().day(nextYear); // false, because the dates must occur on the exact same day. 
	
* * Scenario: Determine if a given date occurs during some week period 2 months from now. * * Example

	var future = Date.today().add(2).months();
	return someDate.same().week(future); // true|false;
	
* * @return {Boolean} true|false */ $P.same = function () { this._same = true; this._isSecond = false; return this; }; /** * Determines if the current date/time occurs during Today. Must be preceded by the .is() function. * Example

	someDate.is().today();    // true|false
	new Date().is().today();  // true
	Date.today().is().today();// true
	Date.today().add(-1).day().is().today(); // false
	
* * @return {Boolean} true|false */ $P.today = function () { return this.same().day(); }; /** * Determines if the current date is a weekday. This function must be preceded by the .is() function. * Example

	Date.today().is().weekday(); // true|false
	
* * @return {Boolean} true|false */ $P.weekday = function () { if (this._nth) { return df("Weekday").call(this); } if (this._move) { return this.addWeekdays(this._orient); } if (this._is) { this._is = false; return (!this.is().sat() && !this.is().sun()); } return false; }; /** * Determines if the current date is on the weekend. This function must be preceded by the .is() function. * Example

	Date.today().is().weekend(); // true|false
	
* * @return {Boolean} true|false */ $P.weekend = function () { if (this._is) { this._is = false; return (this.is().sat() || this.is().sun()); } return false; }; /** * Sets the Time of the current Date instance. A string "6:15 pm" or config object {hour:18, minute:15} are accepted. * Example

	// Set time to 6:15pm with a String
	Date.today().at("6:15pm");

	// Set time to 6:15pm with a config object
	Date.today().at({hour:18, minute:15});
	
* * @return {Date} date */ $P.at = function (time) { return (typeof time === "string") ? $D.parse(this.toString("d") + " " + time) : this.set(time); }; /** * Creates a new Date() and adds this (Number) to the date based on the preceding date element function (eg. second|minute|hour|day|month|year). * Example

	// Undeclared Numbers must be wrapped with parentheses. Requirment of JavaScript.
	(3).days().fromNow();
	(6).months().fromNow();

	// Declared Number variables do not require parentheses. 
	var n = 6;
	n.months().fromNow();
	
* * @return {Date} A new Date instance */ $N.fromNow = $N.after = function (date) { var c = {}; c[this._dateElement] = this; return ((!date) ? new Date() : date.clone()).add(c); }; /** * Creates a new Date() and subtract this (Number) from the date based on the preceding date element function (eg. second|minute|hour|day|month|year). * Example

	// Undeclared Numbers must be wrapped with parentheses. Requirment of JavaScript.
	(3).days().ago();
	(6).months().ago();

	// Declared Number variables do not require parentheses. 
	var n = 6;
	n.months().ago();
	
* * @return {Date} A new Date instance */ $N.ago = $N.before = function (date) { var c = {}, s = (this._dateElement[this._dateElement.length-1] !== "s") ? this._dateElement + "s" : this._dateElement; c[s] = this * -1; return ((!date) ? new Date() : date.clone()).add(c); }; // Do NOT modify the following string tokens. These tokens are used to build dynamic functions. // All culture-specific strings can be found in the CultureInfo files. var dx = ("sunday monday tuesday wednesday thursday friday saturday").split(/\s/), mx = ("january february march april may june july august september october november december").split(/\s/), px = ("Millisecond Second Minute Hour Day Week Month Year Quarter Weekday").split(/\s/), pxf = ("Milliseconds Seconds Minutes Hours Date Week Month FullYear Quarter").split(/\s/), nth = ("final first second third fourth fifth").split(/\s/), de; /** * Returns an object literal of all the date parts. * Example

	var o = new Date().toObject();
	
	// { year: 2008, month: 4, week: 20, day: 13, hour: 18, minute: 9, second: 32, millisecond: 812 }
	
	// The object properties can be referenced directly from the object.
	
	alert(o.day);  // alerts "13"
	alert(o.year); // alerts "2008"
	
* * @return {Date} An object literal representing the original date object. */ $P.toObject = function () { var o = {}; for (var i = 0; i < px.length; i++) { if (this["get" + pxf[i]]) { o[px[i].toLowerCase()] = this["get" + pxf[i]](); } } return o; }; /** * Returns a date created from an object literal. Ignores the .week property if set in the config. * Example

	var o = new Date().toObject();
	
	return Date.fromObject(o); // will return the same date. 

	var o2 = {month: 1, day: 20, hour: 18}; // birthday party!
	Date.fromObject(o2);
	
* * @return {Date} An object literal representing the original date object. */ $D.fromObject = function(config) { config.week = null; return Date.today().set(config); }; // Create day name functions and abbreviated day name functions (eg. monday(), friday(), fri()). var df = function (n) { return function () { if (this._is) { this._is = false; return this.getDay() === n; } if (this._move) { this._move = null; } if (this._nth !== null) { // If the .second() function was called earlier, remove the _orient // from the date, and then continue. // This is required because 'second' can be used in two different context. // // Example // // Date.today().add(1).second(); // Date.march().second().monday(); // // Things get crazy with the following... // Date.march().add(1).second().second().monday(); // but it works!! // if (this._isSecond) { this.addSeconds(this._orient * -1); } // make sure we reset _isSecond this._isSecond = false; var ntemp = this._nth; this._nth = null; var temp = this.clone().moveToLastDayOfMonth(); this.moveToNthOccurrence(n, ntemp); if (this > temp) { throw new RangeError($D.getDayName(n) + " does not occur " + ntemp + " times in the month of " + $D.getMonthName(temp.getMonth()) + " " + temp.getFullYear() + "."); } return this; } return this.moveToDayOfWeek(n, this._orient); }; }; var sdf = function (n) { return function () { var t = $D.today(), shift = n - t.getDay(); if (n === 0 && Date.CultureInfo.firstDayOfWeek === 1 && t.getDay() !== 0) { shift = shift + 7; } return t.addDays(shift); }; }; // Create month name functions and abbreviated month name functions (eg. january(), march(), mar()). var month_instance_functions = function (n) { return function () { if (this._is) { this._is = false; return this.getMonth() === n; } return this.moveToMonth(n, this._orient); }; }; var month_static_functions = function (n) { return function () { return $D.today().set({ month: n, day: 1 }); }; }; var processTerms = function (names, staticFunc, instanceFunc) { for (var i = 0; i < names.length; i++) { // Create constant static Name variables. $D[names[i].toUpperCase()] = $D[names[i].toUpperCase().substring(0, 3)] = i; // Create Name functions. $D[names[i]] = $D[names[i].substring(0, 3)] = staticFunc(i); // Create Name instance functions. $P[names[i]] = $P[names[i].substring(0, 3)] = instanceFunc(i); } }; processTerms(dx, sdf, df); processTerms(mx, month_static_functions, month_instance_functions); // Create date element functions and plural date element functions used with Date (eg. day(), days(), months()). var ef = function (j) { return function () { // if the .second() function was called earlier, the _orient // has alread been added. Just return this and reset _isSecond. if (this._isSecond) { this._isSecond = false; return this; } if (this._same) { this._same = this._is = false; var o1 = this.toObject(), o2 = (arguments[0] || new Date()).toObject(), v = "", k = j.toLowerCase(); // the substr trick with -1 doesn't work in IE8 or less k = (k[k.length-1] === "s") ? k.substring(0,k.length-1) : k; for (var m = (px.length - 1); m > -1; m--) { v = px[m].toLowerCase(); if (o1[v] !== o2[v]) { return false; } if (k === v) { break; } } return true; } if (j.substring(j.length - 1) !== "s") { j += "s"; } if (this._move) { this._move = null; } return this["add" + j](this._orient); }; }; var nf = function (n) { return function () { this._dateElement = n; return this; }; }; for (var k = 0; k < px.length; k++) { de = px[k].toLowerCase(); if(de !== "weekday") { // Create date element functions and plural date element functions used with Date (eg. day(), days(), months()). $P[de] = $P[de + "s"] = ef(px[k]); // Create date element functions and plural date element functions used with Number (eg. day(), days(), months()). $N[de] = $N[de + "s"] = nf(de + "s"); } } $P._ss = ef("Second"); var nthfn = function (n) { return function (dayOfWeek) { if (this._same) { return this._ss(arguments[0]); } if (dayOfWeek || dayOfWeek === 0) { return this.moveToNthOccurrence(dayOfWeek, n); } this._nth = n; // if the operator is 'second' add the _orient, then deal with it later... if (n === 2 && (dayOfWeek === undefined || dayOfWeek === null)) { this._isSecond = true; return this.addSeconds(this._orient); } return this; }; }; for (var l = 0; l < nth.length; l++) { $P[nth[l]] = (l === 0) ? nthfn(-1) : nthfn(l); } }()); (function () { "use strict"; Date.Parsing = { Exception: function (s) { this.message = "Parse error at '" + s.substring(0, 10) + " ...'"; } }; var $P = Date.Parsing; var dayOffsets = { standard: [0,31,59,90,120,151,181,212,243,273,304,334], leap: [0,31,60,91,121,152,182,213,244,274,305,335] }; $P.isLeapYear = function(year) { return ((year % 4 === 0) && (year % 100 !== 0)) || (year % 400 === 0); }; var utils = { multiReplace : function (str, hash ) { var key; for (key in hash) { if (Object.prototype.hasOwnProperty.call(hash, key)) { var regex; if (typeof hash[key] === "function") { } else { regex = (hash[key] instanceof RegExp) ? hash[key] : new RegExp(hash[key], "g"); } str = str.replace(regex, key); } } return str; }, getDayOfYearFromWeek : function (obj) { var d, jan4, offset; obj.weekDay = (!obj.weekDay && obj.weekDay !== 0) ? 1 : obj.weekDay; d = new Date(obj.year, 0, 4); jan4 = d.getDay() === 0 ? 7 : d.getDay(); // JS is 0 indexed on Sunday. offset = jan4+3; obj.dayOfYear = ((obj.week * 7) + (obj.weekDay === 0 ? 7 : obj.weekDay))-offset; return obj; }, getDayOfYear : function (obj, dayOffset) { if (!obj.dayOfYear) { obj = utils.getDayOfYearFromWeek(obj); } for (var i=0;i <= dayOffset.length;i++) { if (obj.dayOfYear < dayOffset[i] || i === dayOffset.length) { obj.day = obj.day ? obj.day : (obj.dayOfYear - dayOffset[i-1]); break; } else { obj.month = i; } } return obj; }, adjustForTimeZone : function (obj, date) { var offset; if (obj.zone.toUpperCase() === "Z" || (obj.zone_hours === 0 && obj.zone_minutes === 0)) { // it's UTC/GML so work out the current timeszone offset offset = -date.getTimezoneOffset(); } else { offset = (obj.zone_hours*60) + (obj.zone_minutes || 0); if (obj.zone_sign === "+") { offset *= -1; } offset -= date.getTimezoneOffset(); } date.setMinutes(date.getMinutes()+offset); return date; }, setDefaults : function (obj) { obj.year = obj.year || Date.today().getFullYear(); obj.hours = obj.hours || 0; obj.minutes = obj.minutes || 0; obj.seconds = obj.seconds || 0; obj.milliseconds = obj.milliseconds || 0; if (!(!obj.month && (obj.week || obj.dayOfYear))) { // if we have a month, or if we don't but don't have the day calculation data obj.month = obj.month || 0; obj.day = obj.day || 1; } return obj; }, dataNum: function (data, mod, explict, postProcess) { var dataNum = data*1; if (mod) { if (postProcess) { return data ? mod(data)*1 : data; } else { return data ? mod(dataNum) : data; } } else if (!explict){ return data ? dataNum : data; } else { return (data && typeof data !== "undefined") ? dataNum : data; } }, timeDataProcess: function (obj) { var timeObj = {}; for (var x in obj.data) { if (obj.data.hasOwnProperty(x)) { timeObj[x] = obj.ignore[x] ? obj.data[x] : utils.dataNum(obj.data[x], obj.mods[x], obj.explict[x], obj.postProcess[x]); } } if (obj.data.secmins) { obj.data.secmins = obj.data.secmins.replace(",", ".") * 60; if (!timeObj.minutes) { timeObj.minutes = obj.data.secmins; } else if (!timeObj.seconds) { timeObj.seconds = obj.data.secmins; } delete obj.secmins; } return timeObj; }, buildTimeObjectFromData: function (data) { var time = utils.timeDataProcess({ data: { year : data[1], month : data[5], day : data[7], week : data[8], dayOfYear : data[10], hours : data[15], zone_hours : data[23], zone_minutes : data[24], zone : data[21], zone_sign : data[22], weekDay : data[9], minutes: data[16], seconds: data[19], milliseconds: data[20], secmins: data[18] }, mods: { month: function(data) { return data-1; }, weekDay: function (data) { data = Math.abs(data); return (data === 7 ? 0 : data); }, minutes: function (data) { return data.replace(":",""); }, seconds: function (data) { return Math.floor( (data.replace(":","").replace(",","."))*1 ); }, milliseconds: function (data) { return (data.replace(",",".")*1000); } }, postProcess: { minutes: true, seconds: true, milliseconds: true }, explict: { zone_hours: true, zone_minutes: true }, ignore: { zone: true, zone_sign: true, secmins: true } }); return time; }, addToHash: function (hash, keys, data) { keys = keys; data = data; var len = keys.length; for (var i = 0; i < len; i++) { hash[keys[i]] = data[i]; } return hash; }, combineRegex: function (r1, r2) { return new RegExp("(("+r1.source+")\\s("+r2.source+"))"); }, getDateNthString: function(add, last, inc){ if (add) { return Date.today().addDays(inc).toString("d"); } else if (last) { return Date.today().last()[inc]().toString("d"); } }, buildRegexData: function (array) { var arr = []; var len = array.length; for (var i=0; i < len; i++) { if (Object.prototype.toString.call(array[i]) === '[object Array]') { // oldIE compat version of Array.isArray arr.push(this.combineRegex(array[i][0], array[i][1])); } else { arr.push(array[i]); } } return arr; } }; $P.processTimeObject = function (obj) { var date, dayOffset; utils.setDefaults(obj); dayOffset = ($P.isLeapYear(obj.year)) ? dayOffsets.leap : dayOffsets.standard; if (!obj.month && (obj.week || obj.dayOfYear)) { utils.getDayOfYear(obj, dayOffset); } else { obj.dayOfYear = dayOffset[obj.month] + obj.day; } date = new Date(obj.year, obj.month, obj.day, obj.hours, obj.minutes, obj.seconds, obj.milliseconds); if (obj.zone) { utils.adjustForTimeZone(obj, date); // adjust (and calculate) for timezone } return date; }; $P.ISO = { regex : /^([\+-]?\d{4}(?!\d{2}\b))((-?)((0[1-9]|1[0-2])(\3([12]\d|0[1-9]|3[01]))?|W([0-4]\d|5[0-3])(-?[1-7])?|(00[1-9]|0[1-9]\d|[12]\d{2}|3([0-5]\d|6[1-6])))([T\s]((([01]\d|2[0-4])((:?)[0-5]\d)?|24\:?00)([\.,]\d+(?!:))?)?(\17[0-5]\d([\.,]\d+)?)?\s?([zZ]|([\+-])([01]\d|2[0-3]):?([0-5]\d)?)?)?)?$/, parse : function (s) { var time, data = s.match(this.regex); if (!data || !data.length) { return null; } time = utils.buildTimeObjectFromData(data); if (!time.year || (!time.year && (!time.month && !time.day) && (!time.week && !time.dayOfYear)) ) { return null; } return $P.processTimeObject(time); } }; $P.Numeric = { isNumeric: function (e){return!isNaN(parseFloat(e))&&isFinite(e);}, regex: /\b([0-1]?[0-9])([0-3]?[0-9])([0-2]?[0-9]?[0-9][0-9])\b/i, parse: function (s) { var data, i, time = {}, order = Date.CultureInfo.dateElementOrder.split(""); if (!(this.isNumeric(s)) || // if it's non-numeric OR (s[0] === "+" && s[0] === "-")) { // It's an arithmatic string (eg +/-1000) return null; } if (s.length < 5 && s.indexOf(".") < 0 && s.indexOf("/") < 0) { // assume it's just a year. time.year = s; return $P.processTimeObject(time); } data = s.match(this.regex); if (!data || !data.length) { return null; } for (i=0; i < order.length; i++) { switch(order[i]) { case "d": time.day = data[i+1]; break; case "m": time.month = (data[i+1]-1); break; case "y": time.year = data[i+1]; break; } } return $P.processTimeObject(time); } }; $P.Normalizer = { regexData: function () { var $R = Date.CultureInfo.regexPatterns; return utils.buildRegexData([ $R.tomorrow, $R.yesterday, [$R.past, $R.mon], [$R.past, $R.tue], [$R.past, $R.wed], [$R.past, $R.thu], [$R.past, $R.fri], [$R.past, $R.sat], [$R.past, $R.sun] ]); }, basicReplaceHash : function() { var $R = Date.CultureInfo.regexPatterns; return { "January": $R.jan.source, "February": $R.feb, "March": $R.mar, "April": $R.apr, "May": $R.may, "June": $R.jun, "July": $R.jul, "August": $R.aug, "September": $R.sep, "October": $R.oct, "November": $R.nov, "December": $R.dec, "": /\bat\b/gi, " ": /\s{2,}/, "am": $R.inTheMorning, "9am": $R.thisMorning, "pm": $R.inTheEvening, "7pm":$R.thisEvening }; }, keys : function(){ return [ utils.getDateNthString(true, false, 1), // tomorrow utils.getDateNthString(true, false, -1), // yesterday utils.getDateNthString(false, true, "monday"), //last mon utils.getDateNthString(false, true, "tuesday"), //last tues utils.getDateNthString(false, true, "wednesday"), //last wed utils.getDateNthString(false, true, "thursday"), //last thurs utils.getDateNthString(false, true, "friday"), //last fri utils.getDateNthString(false, true, "saturday"), //last sat utils.getDateNthString(false, true, "sunday") //last sun ]; }, buildRegexFunctions: function () { var $R = Date.CultureInfo.regexPatterns; var __ = Date.i18n.__; var tomorrowRE = new RegExp("(\\b\\d\\d?("+__("AM")+"|"+__("PM")+")? )("+$R.tomorrow.source.slice(1)+")", "i"); // adapted tomorrow regex for AM PM relative dates var todayRE = new RegExp($R.today.source + "(?!\\s*([+-]))\\b"); // today, but excludes the math operators (eg "today + 2h") this.replaceFuncs = [ [todayRE, function (full) { return (full.length > 1) ? Date.today().toString("d") : full; }], [tomorrowRE, function(full, m1) { var t = Date.today().addDays(1).toString("d"); return (t + " " + m1); }], [$R.amThisMorning, function(str, am){return am;}], [$R.pmThisEvening, function(str, pm){return pm;}] ]; }, buildReplaceData: function () { this.buildRegexFunctions(); this.replaceHash = utils.addToHash(this.basicReplaceHash(), this.keys(), this.regexData()); }, stringReplaceFuncs: function (s) { for (var i=0; i < this.replaceFuncs.length; i++) { s = s.replace(this.replaceFuncs[i][0], this.replaceFuncs[i][1]); } return s; }, parse: function (s) { s = this.stringReplaceFuncs(s); s = utils.multiReplace(s, this.replaceHash); try { var n = s.split(/([\s\-\.\,\/\x27]+)/); if (n.length === 3 && $P.Numeric.isNumeric(n[0]) && $P.Numeric.isNumeric(n[2]) && (n[2].length >= 4)) { // ok, so we're dealing with x/year. But that's not a full date. // This fixes wonky dateElementOrder parsing when set to dmy order. if (Date.CultureInfo.dateElementOrder[0] === "d") { s = "1/" + n[0] + "/" + n[2]; // set to 1st of month and normalize the seperator } } } catch (e) {} return s; } }; $P.Normalizer.buildReplaceData(); }()); (function () { var $P = Date.Parsing; var _ = $P.Operators = { // // Tokenizers // rtoken: function (r) { // regex token return function (s) { var mx = s.match(r); if (mx) { return ([ mx[0], s.substring(mx[0].length) ]); } else { throw new $P.Exception(s); } }; }, token: function () { // whitespace-eating token return function (s) { return _.rtoken(new RegExp("^\\s*" + s + "\\s*"))(s); }; }, stoken: function (s) { // string token return _.rtoken(new RegExp("^" + s)); }, // Atomic Operators until: function (p) { return function (s) { var qx = [], rx = null; while (s.length) { try { rx = p.call(this, s); } catch (e) { qx.push(rx[0]); s = rx[1]; continue; } break; } return [ qx, s ]; }; }, many: function (p) { return function (s) { var rx = [], r = null; while (s.length) { try { r = p.call(this, s); } catch (e) { return [ rx, s ]; } rx.push(r[0]); s = r[1]; } return [ rx, s ]; }; }, // generator operators -- see below optional: function (p) { return function (s) { var r = null; try { r = p.call(this, s); } catch (e) { return [ null, s ]; } return [ r[0], r[1] ]; }; }, not: function (p) { return function (s) { try { p.call(this, s); } catch (e) { return [null, s]; } throw new $P.Exception(s); }; }, ignore: function (p) { return p ? function (s) { var r = null; r = p.call(this, s); return [null, r[1]]; } : null; }, product: function () { var px = arguments[0], qx = Array.prototype.slice.call(arguments, 1), rx = []; for (var i = 0 ; i < px.length ; i++) { rx.push(_.each(px[i], qx)); } return rx; }, cache: function (rule) { var cache = {}, cache_length = 0, cache_keys = [], CACHE_MAX = Date.Config.CACHE_MAX || 100000, r = null; var cacheCheck = function () { if (cache_length === CACHE_MAX) { // kill several keys, don't want to have to do this all the time... for (var i=0; i < 10; i++) { var key = cache_keys.shift(); if (key) { delete cache[key]; cache_length--; } } } }; return function (s) { cacheCheck(); try { r = cache[s] = (cache[s] || rule.call(this, s)); } catch (e) { r = cache[s] = e; } cache_length++; cache_keys.push(s); if (r instanceof $P.Exception) { throw r; } else { return r; } }; }, // vector operators -- see below any: function () { var px = arguments; return function (s) { var r = null; for (var i = 0; i < px.length; i++) { if (px[i] == null) { continue; } try { r = (px[i].call(this, s)); } catch (e) { r = null; } if (r) { return r; } } throw new $P.Exception(s); }; }, each: function () { var px = arguments; return function (s) { var rx = [], r = null; for (var i = 0; i < px.length ; i++) { if (px[i] == null) { continue; } try { r = (px[i].call(this, s)); } catch (e) { throw new $P.Exception(s); } rx.push(r[0]); s = r[1]; } return [ rx, s]; }; }, all: function () { var px = arguments, _ = _; return _.each(_.optional(px)); }, // delimited operators sequence: function (px, d, c) { d = d || _.rtoken(/^\s*/); c = c || null; if (px.length === 1) { return px[0]; } return function (s) { var r = null, q = null; var rx = []; for (var i = 0; i < px.length ; i++) { try { r = px[i].call(this, s); } catch (e) { break; } rx.push(r[0]); try { q = d.call(this, r[1]); } catch (ex) { q = null; break; } s = q[1]; } if (!r) { throw new $P.Exception(s); } if (q) { throw new $P.Exception(q[1]); } if (c) { try { r = c.call(this, r[1]); } catch (ey) { throw new $P.Exception(r[1]); } } return [ rx, (r?r[1]:s) ]; }; }, // // Composite Operators // between: function (d1, p, d2) { d2 = d2 || d1; var _fn = _.each(_.ignore(d1), p, _.ignore(d2)); return function (s) { var rx = _fn.call(this, s); return [[rx[0][0], r[0][2]], rx[1]]; }; }, list: function (p, d, c) { d = d || _.rtoken(/^\s*/); c = c || null; return (p instanceof Array ? _.each(_.product(p.slice(0, -1), _.ignore(d)), p.slice(-1), _.ignore(c)) : _.each(_.many(_.each(p, _.ignore(d))), px, _.ignore(c))); }, set: function (px, d, c) { d = d || _.rtoken(/^\s*/); c = c || null; return function (s) { // r is the current match, best the current 'best' match // which means it parsed the most amount of input var r = null, p = null, q = null, rx = null, best = [[], s], last = false; // go through the rules in the given set for (var i = 0; i < px.length ; i++) { // last is a flag indicating whether this must be the last element // if there is only 1 element, then it MUST be the last one q = null; p = null; r = null; last = (px.length === 1); // first, we try simply to match the current pattern // if not, try the next pattern try { r = px[i].call(this, s); } catch (e) { continue; } // since we are matching against a set of elements, the first // thing to do is to add r[0] to matched elements rx = [[r[0]], r[1]]; // if we matched and there is still input to parse and // we don't already know this is the last element, // we're going to next check for the delimiter ... // if there's none, or if there's no input left to parse // than this must be the last element after all ... if (r[1].length > 0 && ! last) { try { q = d.call(this, r[1]); } catch (ex) { last = true; } } else { last = true; } // if we parsed the delimiter and now there's no more input, // that means we shouldn't have parsed the delimiter at all // so don't update r and mark this as the last element ... if (!last && q[1].length === 0) { last = true; } // so, if this isn't the last element, we're going to see if // we can get any more matches from the remaining (unmatched) // elements ... if (!last) { // build a list of the remaining rules we can match against, // i.e., all but the one we just matched against var qx = []; for (var j = 0; j < px.length ; j++) { if (i !== j) { qx.push(px[j]); } } // now invoke recursively set with the remaining input // note that we don't include the closing delimiter ... // we'll check for that ourselves at the end p = _.set(qx, d).call(this, q[1]); // if we got a non-empty set as a result ... // (otw rx already contains everything we want to match) if (p[0].length > 0) { // update current result, which is stored in rx ... // basically, pick up the remaining text from p[1] // and concat the result from p[0] so that we don't // get endless nesting ... rx[0] = rx[0].concat(p[0]); rx[1] = p[1]; } } // at this point, rx either contains the last matched element // or the entire matched set that starts with this element. // now we just check to see if this variation is better than // our best so far, in terms of how much of the input is parsed if (rx[1].length < best[1].length) { best = rx; } // if we've parsed all the input, then we're finished if (best[1].length === 0) { break; } } // so now we've either gone through all the patterns trying them // as the initial match; or we found one that parsed the entire // input string ... // if best has no matches, just return empty set ... if (best[0].length === 0) { return best; } // if a closing delimiter is provided, then we have to check it also if (c) { // we try this even if there is no remaining input because the pattern // may well be optional or match empty input ... try { q = c.call(this, best[1]); } catch (ey) { throw new $P.Exception(best[1]); } // it parsed ... be sure to update the best match remaining input best[1] = q[1]; } // if we're here, either there was no closing delimiter or we parsed it // so now we have the best match; just return it! return best; }; }, forward: function (gr, fname) { return function (s) { return gr[fname].call(this, s); }; }, // // Translation Operators // replace: function (rule, repl) { return function (s) { var r = rule.call(this, s); return [repl, r[1]]; }; }, process: function (rule, fn) { return function (s) { var r = rule.call(this, s); return [fn.call(this, r[0]), r[1]]; }; }, min: function (min, rule) { return function (s) { var rx = rule.call(this, s); if (rx[0].length < min) { throw new $P.Exception(s); } return rx; }; } }; // Generator Operators And Vector Operators // Generators are operators that have a signature of F(R) => R, // taking a given rule and returning another rule, such as // ignore, which parses a given rule and throws away the result. // Vector operators are those that have a signature of F(R1,R2,...) => R, // take a list of rules and returning a new rule, such as each. // Generator operators are converted (via the following _generator // function) into functions that can also take a list or array of rules // and return an array of new rules as though the function had been // called on each rule in turn (which is what actually happens). // This allows generators to be used with vector operators more easily. // Example: // each(ignore(foo, bar)) instead of each(ignore(foo), ignore(bar)) // This also turns generators into vector operators, which allows // constructs like: // not(cache(foo, bar)) var _generator = function (op) { function gen() { var args = null, rx = [], px, i; if (arguments.length > 1) { args = Array.prototype.slice.call(arguments); } else if (arguments[0] instanceof Array) { args = arguments[0]; } if (args) { px = args.shift(); if (px.length > 0) { args.unshift(px[i]); rx.push(op.apply(null, args)); args.shift(); return rx; } } else { return op.apply(null, arguments); } } return gen; }; var gx = "optional not ignore cache".split(/\s/); for (var i = 0 ; i < gx.length ; i++) { _[gx[i]] = _generator(_[gx[i]]); } var _vector = function (op) { return function () { if (arguments[0] instanceof Array) { return op.apply(null, arguments[0]); } else { return op.apply(null, arguments); } }; }; var vx = "each any all".split(/\s/); for (var j = 0 ; j < vx.length ; j++) { _[vx[j]] = _vector(_[vx[j]]); } }()); (function () { var $D = Date; var flattenAndCompact = function (ax) { var rx = []; for (var i = 0; i < ax.length; i++) { if (ax[i] instanceof Array) { rx = rx.concat(flattenAndCompact(ax[i])); } else { if (ax[i]) { rx.push(ax[i]); } } } return rx; }; var parseMeridian = function () { if (this.meridian && (this.hour || this.hour === 0)) { if (this.meridian === "a" && this.hour > 11 && Date.Config.strict24hr){ throw "Invalid hour and meridian combination"; } else if (this.meridian === "p" && this.hour < 12 && Date.Config.strict24hr){ throw "Invalid hour and meridian combination"; } else if (this.meridian === "p" && this.hour < 12) { this.hour = this.hour + 12; } else if (this.meridian === "a" && this.hour === 12) { this.hour = 0; } } }; var setDefaults = function () { var now = new Date(); if ((this.hour || this.minute) && (!this.month && !this.year && !this.day)) { this.day = now.getDate(); } if (!this.year) { this.year = now.getFullYear(); } if (!this.month && this.month !== 0) { this.month = now.getMonth(); } if (!this.day) { this.day = 1; } if (!this.hour) { this.hour = 0; } if (!this.minute) { this.minute = 0; } if (!this.second) { this.second = 0; } if (!this.millisecond) { this.millisecond = 0; } }; var finishUtils = { getToday: function () { if (this.now || "hour minute second".indexOf(this.unit) !== -1) { return new Date(); } else { return $D.today(); } }, setDaysFromWeekday: function (today, orient){ var gap; orient = orient || 1; this.unit = "day"; gap = ($D.getDayNumberFromName(this.weekday) - today.getDay()); this.days = gap ? ((gap + (orient * 7)) % 7) : (orient * 7); return this; }, setMonthsFromMonth: function (today, orient) { var gap; orient = orient || 1; this.unit = "month"; gap = (this.month - today.getMonth()); this.months = gap ? ((gap + (orient * 12)) % 12) : (orient * 12); this.month = null; return this; }, setDMYFromWeekday: function () { var d = Date[this.weekday](); this.day = d.getDate(); if (!this.month) { this.month = d.getMonth(); } this.year = d.getFullYear(); return this; }, setUnitValue: function (orient) { if (!this.value && this.operator && this.operator !== null && this[this.unit + "s"] && this[this.unit + "s"] !== null) { this[this.unit + "s"] = this[this.unit + "s"] + ((this.operator === "add") ? 1 : -1) + (this.value||0) * orient; } else if (this[this.unit + "s"] == null || this.operator != null) { if (!this.value) { this.value = 1; } this[this.unit + "s"] = this.value * orient; } }, generateDateFromWeeks: function () { var weekday = (this.weekday !== undefined) ? this.weekday : "today"; var d = Date[weekday]().addWeeks(this.weeks); if (this.now) { d.setTimeToNow(); } return d; } }; $D.Translator = { hour: function (s) { return function () { this.hour = Number(s); }; }, minute: function (s) { return function () { this.minute = Number(s); }; }, second: function (s) { return function () { this.second = Number(s); }; }, /* for ss.s format */ secondAndMillisecond: function (s) { return function () { var mx = s.match(/^([0-5][0-9])\.([0-9]{1,3})/); this.second = Number(mx[1]); this.millisecond = Number(mx[2]); }; }, meridian: function (s) { return function () { this.meridian = s.slice(0, 1).toLowerCase(); }; }, timezone: function (s) { return function () { var n = s.replace(/[^\d\+\-]/g, ""); if (n.length) { this.timezoneOffset = Number(n); } else { this.timezone = s.toLowerCase(); } }; }, day: function (x) { var s = x[0]; return function () { this.day = Number(s.match(/\d+/)[0]); if (this.day < 1) { throw "invalid day"; } }; }, month: function (s) { return function () { this.month = (s.length === 3) ? "jan feb mar apr may jun jul aug sep oct nov dec".indexOf(s)/4 : Number(s) - 1; if (this.month < 0) { throw "invalid month"; } }; }, year: function (s) { return function () { var n = Number(s); this.year = ((s.length > 2) ? n : (n + (((n + 2000) < Date.CultureInfo.twoDigitYearMax) ? 2000 : 1900))); }; }, rday: function (s) { return function () { switch (s) { case "yesterday": this.days = -1; break; case "tomorrow": this.days = 1; break; case "today": this.days = 0; break; case "now": this.days = 0; this.now = true; break; } }; }, finishExact: function (x) { var d; x = (x instanceof Array) ? x : [x]; for (var i = 0 ; i < x.length ; i++) { if (x[i]) { x[i].call(this); } } setDefaults.call(this); parseMeridian.call(this); if (this.day > $D.getDaysInMonth(this.year, this.month)) { throw new RangeError(this.day + " is not a valid value for days."); } d = new Date(this.year, this.month, this.day, this.hour, this.minute, this.second, this.millisecond); if (this.year < 100) { d.setFullYear(this.year); // means years less that 100 are process correctly. JS will parse it otherwise as 1900-1999. } if (this.timezone) { d.set({ timezone: this.timezone }); } else if (this.timezoneOffset) { d.set({ timezoneOffset: this.timezoneOffset }); } return d; }, finish: function (x) { var today, expression, orient, temp; x = (x instanceof Array) ? flattenAndCompact(x) : [ x ]; if (x.length === 0) { return null; } for (var i = 0 ; i < x.length ; i++) { if (typeof x[i] === "function") { x[i].call(this); } } if (this.now && !this.unit && !this.operator) { return new Date(); } else { today = finishUtils.getToday.call(this); } expression = !!(this.days && this.days !== null || this.orient || this.operator); orient = ((this.orient === "past" || this.operator === "subtract") ? -1 : 1); if (this.month && this.unit === "week") { this.value = this.month + 1; delete this.month; delete this.day; } if ((this.month || this.month === 0) && "year day hour minute second".indexOf(this.unit) !== -1) { if (!this.value) { this.value = this.month + 1; } this.month = null; expression = true; } if (!expression && this.weekday && !this.day && !this.days) { finishUtils.setDMYFromWeekday.call(this); } if (expression && this.weekday && this.unit !== "month" && this.unit !== "week") { finishUtils.setDaysFromWeekday.call(this, today, orient); } if (this.weekday && this.unit !== "week" && !this.day && !this.days) { temp = Date[this.weekday](); this.day = temp.getDate(); if (temp.getMonth() !== today.getMonth()) { this.month = temp.getMonth(); } } if (this.month && this.unit === "day" && this.operator) { if (!this.value) { this.value = (this.month + 1); } this.month = null; } if (this.value != null && this.month != null && this.year != null) { this.day = this.value * 1; } if (this.month && !this.day && this.value) { today.set({ day: this.value * 1 }); if (!expression) { this.day = this.value * 1; } } if (!this.month && this.value && this.unit === "month" && !this.now) { this.month = this.value; expression = true; } if (expression && (this.month || this.month === 0) && this.unit !== "year") { finishUtils.setMonthsFromMonth.call(this, today, orient); } if (!this.unit) { this.unit = "day"; } finishUtils.setUnitValue.call(this, orient); parseMeridian.call(this); if ((this.month || this.month === 0) && !this.day) { this.day = 1; } if (!this.orient && !this.operator && this.unit === "week" && this.value && !this.day && !this.month) { return Date.today().setWeek(this.value); } if (this.unit === "week" && this.weeks && !this.day && !this.month) { return finishUtils.generateDateFromWeeks.call(this); } if (expression && this.timezone && this.day && this.days) { this.day = this.days; } if (expression){ today.add(this); } else { today.set(this); } if (this.timezone) { this.timezone = this.timezone.toUpperCase(); var offset = $D.getTimezoneOffset(this.timezone); var timezone; if (today.hasDaylightSavingTime()) { // lets check that we're being sane with timezone setting timezone = $D.getTimezoneAbbreviation(offset, today.isDaylightSavingTime()); if (timezone !== this.timezone) { // bugger, we're in a place where things like EST vs EDT matters. if (today.isDaylightSavingTime()) { today.addHours(-1); } else { today.addHours(1); } } } today.setTimezoneOffset(offset); } return today; } }; }()); (function () { var $D = Date; $D.Grammar = {}; var _ = $D.Parsing.Operators, g = $D.Grammar, t = $D.Translator, _fn; // Allow rolling up into general purpose rules _fn = function () { return _.each(_.any.apply(null, arguments), _.not(g.ctoken2("timeContext"))); }; g.datePartDelimiter = _.rtoken(/^([\s\-\.\,\/\x27]+)/); g.timePartDelimiter = _.stoken(":"); g.whiteSpace = _.rtoken(/^\s*/); g.generalDelimiter = _.rtoken(/^(([\s\,]|at|@|on)+)/); var _C = {}; g.ctoken = function (keys) { var fn = _C[keys]; if (! fn) { var c = Date.CultureInfo.regexPatterns; var kx = keys.split(/\s+/), px = []; for (var i = 0; i < kx.length ; i++) { px.push(_.replace(_.rtoken(c[kx[i]]), kx[i])); } fn = _C[keys] = _.any.apply(null, px); } return fn; }; g.ctoken2 = function (key) { return _.rtoken(Date.CultureInfo.regexPatterns[key]); }; var cacheProcessRtoken = function (key, token, type, eachToken) { if (eachToken) { g[key] = _.cache(_.process(_.each(_.rtoken(token),_.optional(g.ctoken2(eachToken))), type)); } else { g[key] = _.cache(_.process(_.rtoken(token), type)); } }; var cacheProcessCtoken = function (token, type) { return _.cache(_.process(g.ctoken2(token), type)); }; var _F = {}; //function cache var _get = function (f) { _F[f] = (_F[f] || g.format(f)[0]); return _F[f]; }; g.allformats = function (fx) { var rx = []; if (fx instanceof Array) { for (var i = 0; i < fx.length; i++) { rx.push(_get(fx[i])); } } else { rx.push(_get(fx)); } return rx; }; g.formats = function (fx) { if (fx instanceof Array) { var rx = []; for (var i = 0 ; i < fx.length ; i++) { rx.push(_get(fx[i])); } return _.any.apply(null, rx); } else { return _get(fx); } }; var grammarFormats = { timeFormats: function(){ var i, RTokenKeys = [ "h", "hh", "H", "HH", "m", "mm", "s", "ss", "ss.s", "z", "zz" ], RToken = [ /^(0[0-9]|1[0-2]|[1-9])/, /^(0[0-9]|1[0-2])/, /^([0-1][0-9]|2[0-3]|[0-9])/, /^([0-1][0-9]|2[0-3])/, /^([0-5][0-9]|[0-9])/, /^[0-5][0-9]/, /^([0-5][0-9]|[0-9])/, /^[0-5][0-9]/, /^[0-5][0-9]\.[0-9]{1,3}/, /^((\+|\-)\s*\d\d\d\d)|((\+|\-)\d\d\:?\d\d)/, /^((\+|\-)\s*\d\d\d\d)|((\+|\-)\d\d\:?\d\d)/ ], tokens = [ t.hour, t.hour, t.hour, t.hour, t.minute, t.minute, t.second, t.second, t.secondAndMillisecond, t.timezone, t.timezone ]; for (i=0; i < RTokenKeys.length; i++) { cacheProcessRtoken(RTokenKeys[i], RToken[i], tokens[i]); } g.hms = _.cache(_.sequence([g.H, g.m, g.s], g.timePartDelimiter)); g.t = cacheProcessCtoken("shortMeridian", t.meridian); g.tt = cacheProcessCtoken("longMeridian", t.meridian); g.zzz = cacheProcessCtoken("timezone", t.timezone); g.timeSuffix = _.each(_.ignore(g.whiteSpace), _.set([ g.tt, g.zzz ])); g.time = _.each(_.optional(_.ignore(_.stoken("T"))), g.hms, g.timeSuffix); }, dateFormats: function () { // pre-loaded rules for different date part order preferences var _setfn = function () { return _.set(arguments, g.datePartDelimiter); }; var i, RTokenKeys = [ "d", "dd", "M", "MM", "y", "yy", "yyy", "yyyy" ], RToken = [ /^([0-2]\d|3[0-1]|\d)/, /^([0-2]\d|3[0-1])/, /^(1[0-2]|0\d|\d)/, /^(1[0-2]|0\d)/, /^(\d+)/, /^(\d\d)/, /^(\d\d?\d?\d?)/, /^(\d\d\d\d)/ ], tokens = [ t.day, t.day, t.month, t.month, t.year, t.year, t.year, t.year ], eachToken = [ "ordinalSuffix", "ordinalSuffix" ]; for (i=0; i < RTokenKeys.length; i++) { cacheProcessRtoken(RTokenKeys[i], RToken[i], tokens[i], eachToken[i]); } g.MMM = g.MMMM = _.cache(_.process(g.ctoken("jan feb mar apr may jun jul aug sep oct nov dec"), t.month)); g.ddd = g.dddd = _.cache(_.process(g.ctoken("sun mon tue wed thu fri sat"), function (s) { return function () { this.weekday = s; }; } )); g.day = _fn(g.d, g.dd); g.month = _fn(g.M, g.MMM); g.year = _fn(g.yyyy, g.yy); g.mdy = _setfn(g.ddd, g.month, g.day, g.year); g.ymd = _setfn(g.ddd, g.year, g.month, g.day); g.dmy = _setfn(g.ddd, g.day, g.month, g.year); g.date = function (s) { return ((g[Date.CultureInfo.dateElementOrder] || g.mdy).call(this, s)); }; }, relative: function () { // relative date / time expressions g.orientation = _.process(g.ctoken("past future"), function (s) { return function () { this.orient = s; }; } ); g.operator = _.process(g.ctoken("add subtract"), function (s) { return function () { this.operator = s; }; } ); g.rday = _.process(g.ctoken("yesterday tomorrow today now"), t.rday); g.unit = _.process(g.ctoken("second minute hour day week month year"), function (s) { return function () { this.unit = s; }; } ); } }; g.buildGrammarFormats = function () { // these need to be rebuilt every time the language changes. _C = {}; grammarFormats.timeFormats(); grammarFormats.dateFormats(); grammarFormats.relative(); g.value = _.process(_.rtoken(/^([-+]?\d+)?(st|nd|rd|th)?/), function (s) { return function () { this.value = s.replace(/\D/g, ""); }; } ); g.expression = _.set([g.rday, g.operator, g.value, g.unit, g.orientation, g.ddd, g.MMM ]); g.format = _.process(_.many( _.any( // translate format specifiers into grammar rules _.process( _.rtoken(/^(dd?d?d?(?!e)|MM?M?M?|yy?y?y?|hh?|HH?|mm?|ss?|tt?|zz?z?)/), function (fmt) { if (g[fmt]) { return g[fmt]; } else { throw $D.Parsing.Exception(fmt); } } ), // translate separator tokens into token rules _.process(_.rtoken(/^[^dMyhHmstz]+/), // all legal separators function (s) { return _.ignore(_.stoken(s)); } ) ) ), // construct the parser ... function (rules) { return _.process(_.each.apply(null, rules), t.finishExact); } ); // starting rule for general purpose grammar g._start = _.process(_.set([ g.date, g.time, g.expression ], g.generalDelimiter, g.whiteSpace), t.finish); }; g.buildGrammarFormats(); // parsing date format specifiers - ex: "h:m:s tt" // this little guy will generate a custom parser based // on the format string, ex: g.format("h:m:s tt") // check for these formats first g._formats = g.formats([ "\"yyyy-MM-ddTHH:mm:ssZ\"", "yyyy-MM-ddTHH:mm:ss.sz", "yyyy-MM-ddTHH:mm:ssZ", "yyyy-MM-ddTHH:mm:ssz", "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-ddTHH:mmZ", "yyyy-MM-ddTHH:mmz", "yyyy-MM-ddTHH:mm", "ddd, MMM dd, yyyy H:mm:ss tt", "ddd MMM d yyyy HH:mm:ss zzz", "MMddyyyy", "ddMMyyyy", "Mddyyyy", "ddMyyyy", "Mdyyyy", "dMyyyy", "yyyy", "Mdyy", "dMyy", "d" ]); // real starting rule: tries selected formats first, // then general purpose rule g.start = function (s) { try { var r = g._formats.call({}, s); if (r[1].length === 0) { return r; } } catch (e) {} return g._start.call({}, s); }; }()); (function () { var $D = Date; /** * @desc Converts the specified string value into its JavaScript Date equivalent using CultureInfo specific format information. * * Example

	///////////
	// Dates //
	///////////

	// 15-Oct-2004
	var d1 = Date.parse("10/15/2004");

	// 15-Oct-2004
	var d1 = Date.parse("15-Oct-2004");

	// 15-Oct-2004
	var d1 = Date.parse("2004.10.15");

	//Fri Oct 15, 2004
	var d1 = Date.parse("Fri Oct 15, 2004");

	///////////
	// Times //
	///////////

	// Today at 10 PM.
	var d1 = Date.parse("10 PM");

	// Today at 10:30 PM.
	var d1 = Date.parse("10:30 P.M.");

	// Today at 6 AM.
	var d1 = Date.parse("06am");

	/////////////////////
	// Dates and Times //
	/////////////////////

	// 8-July-2004 @ 10:30 PM
	var d1 = Date.parse("July 8th, 2004, 10:30 PM");

	// 1-July-2004 @ 10:30 PM
	var d1 = Date.parse("2004-07-01T22:30:00");

	////////////////////
	// Relative Dates //
	////////////////////

	// Returns today's date. The string "today" is culture specific.
	var d1 = Date.parse("today");

	// Returns yesterday's date. The string "yesterday" is culture specific.
	var d1 = Date.parse("yesterday");

	// Returns the date of the next thursday.
	var d1 = Date.parse("Next thursday");

	// Returns the date of the most previous monday.
	var d1 = Date.parse("last monday");

	// Returns today's day + one year.
	var d1 = Date.parse("next year");

	///////////////
	// Date Math //
	///////////////

	// Today + 2 days
	var d1 = Date.parse("t+2");

	// Today + 2 days
	var d1 = Date.parse("today + 2 days");

	// Today + 3 months
	var d1 = Date.parse("t+3m");

	// Today - 1 year
	var d1 = Date.parse("today - 1 year");

	// Today - 1 year
	var d1 = Date.parse("t-1y"); 


	/////////////////////////////
	// Partial Dates and Times //
	/////////////////////////////

	// July 15th of this year.
	var d1 = Date.parse("July 15");

	// 15th day of current day and year.
	var d1 = Date.parse("15");

	// July 1st of current year at 10pm.
	var d1 = Date.parse("7/1 10pm");
	
* * @param {String} The string value to convert into a Date object [Required] * @return {Date} A Date object or null if the string cannot be converted into a Date. */ var parseUtils = { removeOrds: function (s) { ords = s.match(/\b(\d+)(?:st|nd|rd|th)\b/); // find ordinal matches s = ((ords && ords.length === 2) ? s.replace(ords[0], ords[1]) : s); return s; }, grammarParser: function (s) { var r = null; try { r = $D.Grammar.start.call({}, s.replace(/^\s*(\S*(\s+\S+)*)\s*$/, "$1")); } catch (e) { return null; } return ((r[1].length === 0) ? r[0] : null); }, nativeFallback: function(s) { var t; try { // ok we haven't parsed it, last ditch attempt with the built-in parser. t = Date._parse(s); return (t || t === 0) ? new Date(t) : null; } catch (e) { return null; } } }; function parse (s) { var d; if (!s) { return null; } if (s instanceof Date) { return s.clone(); } if (s.length >= 4 && s.charAt(0) !== "0" && s.charAt(0) !== "+"&& s.charAt(0) !== "-") { // ie: 2004 will pass, 0800 won't. // Start with specific formats d = $D.Parsing.ISO.parse(s) || $D.Parsing.Numeric.parse(s); } if (d instanceof Date && !isNaN(d.getTime())) { return d; } else { // find ordinal dates (1st, 3rd, 8th, etc and remove them as they cause parsing issues) s = $D.Parsing.Normalizer.parse(parseUtils.removeOrds(s)); d = parseUtils.grammarParser(s); if (d !== null) { return d; } else { return parseUtils.nativeFallback(s); } } } if (!$D._parse) { $D._parse = $D.parse; } $D.parse = parse; Date.getParseFunction = function (fx) { var fns = Date.Grammar.allformats(fx); return function (s) { var r = null; for (var i = 0; i < fns.length; i++) { try { r = fns[i].call({}, s); } catch (e) { continue; } if (r[1].length === 0) { return r[0]; } } return null; }; }; /** * Converts the specified string value into its JavaScript Date equivalent using the specified format {String} or formats {Array} and the CultureInfo specific format information. * The format of the string value must match one of the supplied formats exactly. * * Example

	// 15-Oct-2004
	var d1 = Date.parseExact("10/15/2004", "M/d/yyyy");

	// 15-Oct-2004
	var d1 = Date.parse("15-Oct-2004", "M-ddd-yyyy");

	// 15-Oct-2004
	var d1 = Date.parse("2004.10.15", "yyyy.MM.dd");

	// Multiple formats
	var d1 = Date.parseExact("10/15/2004", ["M/d/yyyy", "MMMM d, yyyy"]);
	
* * @param {String} The string value to convert into a Date object [Required]. * @param {Object} The expected format {String} or an array of expected formats {Array} of the date string [Required]. * @return {Date} A Date object or null if the string cannot be converted into a Date. */ $D.parseExact = function (s, fx) { return $D.getParseFunction(fx)(s); }; }()); (function () { var $D = Date, $P = $D.prototype, // $C = $D.CultureInfo, // not used atm p = function (s, l) { if (!l) { l = 2; } return ("000" + s).slice(l * -1); }; /** * Converts a PHP format string to Java/.NET format string. * A PHP format string can be used with ._format or .format. * A Java/.NET format string can be used with .toString(). * The .parseExact function will only accept a Java/.NET format string * * Example * var f1 = "%m/%d/%y" * var f2 = Date.normalizeFormat(f1); // "MM/dd/yy" * * new Date().format(f1); // "04/13/08" * new Date()._format(f1); // "04/13/08" * new Date().toString(f2); // "04/13/08" * * var date = Date.parseExact("04/13/08", f2); // Sun Apr 13 2008 * * @param {String} A PHP format string consisting of one or more format spcifiers. * @return {String} The PHP format converted to a Java/.NET format string. */ var normalizerSubstitutions = { "d" : "dd", "%d": "dd", "D" : "ddd", "%a": "ddd", "j" : "dddd", "l" : "dddd", "%A": "dddd", "S" : "S", "F" : "MMMM", "%B": "MMMM", "m" : "MM", "%m": "MM", "M" : "MMM", "%b": "MMM", "%h": "MMM", "n" : "M", "Y" : "yyyy", "%Y": "yyyy", "y" : "yy", "%y": "yy", "g" : "h", "%I": "h", "G" : "H", "h" : "hh", "H" : "HH", "%H": "HH", "i" : "mm", "%M": "mm", "s" : "ss", "%S": "ss", "%r": "hh:mm tt", "%R": "H:mm", "%T": "H:mm:ss", "%X": "t", "%x": "d", "%e": "d", "%D": "MM/dd/yy", "%n": "\\n", "%t": "\\t", "e" : "z", "T" : "z", "%z": "z", "%Z": "z", "Z" : "ZZ", "N" : "u", "w" : "u", "%w": "u", "W" : "W", "%V": "W" }; var normalizer = { substitutes: function (m) { return normalizerSubstitutions[m]; }, interpreted: function (m, x) { var y; switch (m) { case "%u": return x.getDay() + 1; case "z": return x.getOrdinalNumber(); case "%j": return p(x.getOrdinalNumber(), 3); case "%U": var d1 = x.clone().set({month: 0, day: 1}).addDays(-1).moveToDayOfWeek(0), d2 = x.clone().addDays(1).moveToDayOfWeek(0, -1); return (d2 < d1) ? "00" : p((d2.getOrdinalNumber() - d1.getOrdinalNumber()) / 7 + 1); case "%W": return p(x.getWeek()); case "t": return $D.getDaysInMonth(x.getFullYear(), x.getMonth()); case "o": case "%G": return x.setWeek(x.getISOWeek()).toString("yyyy"); case "%g": return x._format("%G").slice(-2); case "a": case "%p": return t("tt").toLowerCase(); case "A": return t("tt").toUpperCase(); case "u": return p(x.getMilliseconds(), 3); case "I": return (x.isDaylightSavingTime()) ? 1 : 0; case "O": return x.getUTCOffset(); case "P": y = x.getUTCOffset(); return y.substring(0, y.length - 2) + ":" + y.substring(y.length - 2); case "B": var now = new Date(); return Math.floor(((now.getHours() * 3600) + (now.getMinutes() * 60) + now.getSeconds() + (now.getTimezoneOffset() + 60) * 60) / 86.4); case "c": return x.toISOString().replace(/\"/g, ""); case "U": return $D.strtotime("now"); case "%c": return t("d") + " " + t("t"); case "%C": return Math.floor(x.getFullYear() / 100 + 1); } }, shouldOverrideDefaults: function (m) { switch (m) { case "%e": return true; default: return false; } }, parse: function (m, context) { var formatString, c = context || new Date(); formatString = normalizer.substitutes(m); if (formatString) { return formatString; } formatString = normalizer.interpreted(m, c); if (formatString) { return formatString; } else { return m; } } }; $D.normalizeFormat = function (format, context) { return format.replace(/(%|\\)?.|%%/g, function(t){ return normalizer.parse(t, context); }); }; /** * Format a local Unix timestamp according to locale settings * * Example: * Date.strftime("%m/%d/%y", new Date()); // "04/13/08" * Date.strftime("c", "2008-04-13T17:52:03Z"); // "04/13/08" * * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @param {Number|String} The number representing the number of seconds that have elapsed since January 1, 1970 (local time). * @return {String} A string representation of the current Date object. */ $D.strftime = function (format, time) { var d = Date.parse(time); return d._format(format); }; /** * Parse any textual datetime description into a Unix timestamp. * A Unix timestamp is the number of seconds that have elapsed since January 1, 1970 (midnight UTC/GMT). * * Example: * Date.strtotime("04/13/08"); // 1208044800 * Date.strtotime("1970-01-01T00:00:00Z"); // 0 * * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @param {Object} A string or date object. * @return {String} A string representation of the current Date object. */ $D.strtotime = function (time) { var d = $D.parse(time); return Math.round($D.UTC(d.getUTCFullYear(), d.getUTCMonth(), d.getUTCDate(), d.getUTCHours(), d.getUTCMinutes(), d.getUTCSeconds(), d.getUTCMilliseconds()) / 1000); }; /** * Converts the value of the current Date object to its equivalent string representation using a PHP/Unix style of date format specifiers. * Format Specifiers * Format Description Example * ------ --------------------------------------------------------------------------- ----------------------- * %a abbreviated weekday name according to the current localed "Mon" through "Sun" * %A full weekday name according to the current localed "Sunday" through "Saturday" * %b abbreviated month name according to the current localed "Jan" through "Dec" * %B full month name according to the current locale "January" through "December" * %c preferred date and time representation for the current locale "4/13/2008 12:33 PM" * %C century number (the year divided by 100 and truncated to an integer) "00" to "99" * %d day of the month as a decimal number "01" to "31" * %D same as %m/%d/%y "04/13/08" * %e day of the month as a decimal number, a single digit is preceded by a space "1" to "31" * %g like %G, but without the century "08" * %G The 4-digit year corresponding to the ISO week number (see %V). "2008" * This has the same format and value as %Y, except that if the ISO week number * belongs to the previous or next year, that year is used instead. * %h same as %b "Jan" through "Dec" * %H hour as a decimal number using a 24-hour clock. "00" to "23" * %I hour as a decimal number using a 12-hour clock. "01" to "12" * %j day of the year as a decimal number. "001" to "366" * %m month as a decimal number. "01" to "12" * %M minute as a decimal number. "00" to "59" * %n newline character "\n" * %p either "am" or "pm" according to the given time value, or the "am" or "pm" * corresponding strings for the current locale. * %r time in a.m. and p.m. notation "8:44 PM" * %R time in 24 hour notation "20:44" * %S second as a decimal number "00" to "59" * %t tab character "\t" * %T current time, equal to %H:%M:%S "12:49:11" * %u weekday as a decimal number ["1", "7"], with "1" representing Monday "1" to "7" * %U week number of the current year as a decimal number, starting with the "0" to ("52" or "53") * first Sunday as the first day of the first week * %V The ISO 8601:1988 week number of the current year as a decimal number, "00" to ("52" or "53") * range 01 to 53, where week 1 is the first week that has at least 4 days * in the current year, and with Monday as the first day of the week. * (Use %G or %g for the year component that corresponds to the week number * for the specified timestamp.) * %W week number of the current year as a decimal number, starting with the "00" to ("52" or "53") * first Monday as the first day of the first week * %w day of the week as a decimal, Sunday being "0" "0" to "6" * %x preferred date representation for the current locale without the time "4/13/2008" * %X preferred time representation for the current locale without the date "12:53:05" * %y year as a decimal number without a century "00" "99" * %Y year as a decimal number including the century "2008" * %Z time zone or name or abbreviation "UTC", "EST", "PST" * %z same as %Z * %% a literal "%" characters "%" * d Day of the month, 2 digits with leading zeros "01" to "31" * D A textual representation of a day, three letters "Mon" through "Sun" * j Day of the month without leading zeros "1" to "31" * l A full textual representation of the day of the week (lowercase "L") "Sunday" through "Saturday" * N ISO-8601 numeric representation of the day of the week (added in PHP 5.1.0) "1" (for Monday) through "7" (for Sunday) * S English ordinal suffix for the day of the month, 2 characters "st", "nd", "rd" or "th". Works well with j * w Numeric representation of the day of the week "0" (for Sunday) through "6" (for Saturday) * z The day of the year (starting from "0") "0" through "365" * W ISO-8601 week number of year, weeks starting on Monday "00" to ("52" or "53") * F A full textual representation of a month, such as January or March "January" through "December" * m Numeric representation of a month, with leading zeros "01" through "12" * M A short textual representation of a month, three letters "Jan" through "Dec" * n Numeric representation of a month, without leading zeros "1" through "12" * t Number of days in the given month "28" through "31" * L Whether it's a leap year "1" if it is a leap year, "0" otherwise * o ISO-8601 year number. This has the same value as Y, except that if the "2008" * ISO week number (W) belongs to the previous or next year, that year * is used instead. * Y A full numeric representation of a year, 4 digits "2008" * y A two digit representation of a year "08" * a Lowercase Ante meridiem and Post meridiem "am" or "pm" * A Uppercase Ante meridiem and Post meridiem "AM" or "PM" * B Swatch Internet time "000" through "999" * g 12-hour format of an hour without leading zeros "1" through "12" * G 24-hour format of an hour without leading zeros "0" through "23" * h 12-hour format of an hour with leading zeros "01" through "12" * H 24-hour format of an hour with leading zeros "00" through "23" * i Minutes with leading zeros "00" to "59" * s Seconds, with leading zeros "00" through "59" * u Milliseconds "54321" * e Timezone identifier "UTC", "EST", "PST" * I Whether or not the date is in daylight saving time (uppercase i) "1" if Daylight Saving Time, "0" otherwise * O Difference to Greenwich time (GMT) in hours "+0200", "-0600" * P Difference to Greenwich time (GMT) with colon between hours and minutes "+02:00", "-06:00" * T Timezone abbreviation "UTC", "EST", "PST" * Z Timezone offset in seconds. The offset for timezones west of UTC is "-43200" through "50400" * always negative, and for those east of UTC is always positive. * c ISO 8601 date "2004-02-12T15:19:21+00:00" * r RFC 2822 formatted date "Thu, 21 Dec 2000 16:01:07 +0200" * U Seconds since the Unix Epoch (January 1 1970 00:00:00 GMT) "0" * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @return {String} A string representation of the current Date object. */ var formatReplace = function (context) { return function (m) { var formatString, override = false; if (m.charAt(0) === "\\" || m.substring(0, 2) === "%%") { return m.replace("\\", "").replace("%%", "%"); } override = normalizer.shouldOverrideDefaults(m); formatString = $D.normalizeFormat(m, context); if (formatString) { return context.toString(formatString, override); } }; }; $P._format = function (format) { var formatter = formatReplace(this); if (!format) { return this._toString(); } else { return format.replace(/(%|\\)?.|%%/g, formatter); } }; if (!$P.format) { $P.format = $P._format; } }()); (function () { "use strict"; var gFn = function (attr) { return function () { return this[attr]; }; }; var sFn = function (attr) { return function (val) { this[attr] = val; return this; }; }; var attrs = ["years", "months", "days", "hours", "minutes", "seconds", "milliseconds"]; var addSetFuncs = function (context, attrs) { for (var i = 0; i < attrs.length ; i++) { var $a = attrs[i], $b = $a.slice(0, 1).toUpperCase() + $a.slice(1); context.prototype[$a] = 0; context.prototype["get" + $b] = gFn($a); context.prototype["set" + $b] = sFn($a); } }; /** * new TimeSpan(milliseconds); * new TimeSpan(days, hours, minutes, seconds); * new TimeSpan(days, hours, minutes, seconds, milliseconds); */ var TimeSpan = function (days, hours, minutes, seconds, milliseconds) { if (arguments.length === 1 && typeof days === "number") { var orient = (days < 0) ? -1 : +1; var millsLeft = Math.abs(days); this.setDays(Math.floor(millsLeft / 86400000) * orient); millsLeft = millsLeft % 86400000; this.setHours(Math.floor(millsLeft / 3600000) * orient); millsLeft = millsLeft % 3600000; this.setMinutes(Math.floor(millsLeft / 60000) * orient); millsLeft = millsLeft % 60000; this.setSeconds(Math.floor(millsLeft / 1000) * orient); millsLeft = millsLeft % 1000; this.setMilliseconds(millsLeft * orient); } else { this.set(days, hours, minutes, seconds, milliseconds); } this.getTotalMilliseconds = function () { return (this.getDays() * 86400000) + (this.getHours() * 3600000) + (this.getMinutes() * 60000) + (this.getSeconds() * 1000); }; this.compareTo = function (time) { var t1 = new Date(1970, 1, 1, this.getHours(), this.getMinutes(), this.getSeconds()), t2; if (time === null) { t2 = new Date(1970, 1, 1, 0, 0, 0); } else { t2 = new Date(1970, 1, 1, time.getHours(), time.getMinutes(), time.getSeconds()); } return (t1 < t2) ? -1 : (t1 > t2) ? 1 : 0; }; this.equals = function (time) { return (this.compareTo(time) === 0); }; this.add = function (time) { return (time === null) ? this : this.addSeconds(time.getTotalMilliseconds() / 1000); }; this.subtract = function (time) { return (time === null) ? this : this.addSeconds(-time.getTotalMilliseconds() / 1000); }; this.addDays = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 86400000)); }; this.addHours = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 3600000)); }; this.addMinutes = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 60000)); }; this.addSeconds = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 1000)); }; this.addMilliseconds = function (n) { return new TimeSpan(this.getTotalMilliseconds() + n); }; this.get12HourHour = function () { return (this.getHours() > 12) ? this.getHours() - 12 : (this.getHours() === 0) ? 12 : this.getHours(); }; this.getDesignator = function () { return (this.getHours() < 12) ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator; }; this.toString = function (format) { this._toString = function () { if (this.getDays() !== null && this.getDays() > 0) { return this.getDays() + "." + this.getHours() + ":" + this.p(this.getMinutes()) + ":" + this.p(this.getSeconds()); } else { return this.getHours() + ":" + this.p(this.getMinutes()) + ":" + this.p(this.getSeconds()); } }; this.p = function (s) { return (s.toString().length < 2) ? "0" + s : s; }; var me = this; return format ? format.replace(/dd?|HH?|hh?|mm?|ss?|tt?/g, function (format) { switch (format) { case "d": return me.getDays(); case "dd": return me.p(me.getDays()); case "H": return me.getHours(); case "HH": return me.p(me.getHours()); case "h": return me.get12HourHour(); case "hh": return me.p(me.get12HourHour()); case "m": return me.getMinutes(); case "mm": return me.p(me.getMinutes()); case "s": return me.getSeconds(); case "ss": return me.p(me.getSeconds()); case "t": return ((me.getHours() < 12) ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator).substring(0, 1); case "tt": return (me.getHours() < 12) ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator; } } ) : this._toString(); }; return this; }; addSetFuncs(TimeSpan, attrs.slice(2)); TimeSpan.prototype.set = function (days, hours, minutes, seconds, milliseconds){ this.setDays(days || this.getDays()); this.setHours(hours || this.getHours()); this.setMinutes(minutes || this.getMinutes()); this.setSeconds(seconds || this.getSeconds()); this.setMilliseconds(milliseconds || this.getMilliseconds()); }; /** * Gets the time of day for this date instances. * @return {TimeSpan} TimeSpan */ Date.prototype.getTimeOfDay = function () { return new TimeSpan(0, this.getHours(), this.getMinutes(), this.getSeconds(), this.getMilliseconds()); }; Date.TimeSpan = TimeSpan; if (typeof window !== "undefined" ) { // keeping API compatible for v1.x window.TimeSpan = TimeSpan; } }()); (function () { "use strict"; var attrs = ["years", "months", "days", "hours", "minutes", "seconds", "milliseconds"]; var gFn = function (attr) { return function () { return this[attr]; }; }; var sFn = function (attr) { return function (val) { this[attr] = val; return this; }; }; var addSetFuncs = function (context, attrs) { for (var i = 0; i < attrs.length ; i++) { var $a = attrs[i], $b = $a.slice(0, 1).toUpperCase() + $a.slice(1); context.prototype[$a] = 0; context.prototype["get" + $b] = gFn($a); context.prototype["set" + $b] = sFn($a); } }; var setMonthsAndYears = function (orient, d1, d2, context) { function inc() { d1.addMonths(-orient); context.months++; if (context.months === 12) { context.years++; context.months = 0; } } if (orient === +1) { while (d1 > d2) { inc(); } } else { while (d1 < d2) { inc(); } } context.months--; context.months *= orient; context.years *= orient; }; var adjustForDST = function(orient, startDate, endDate) { var hasDSTMismatch = (false === (startDate.isDaylightSavingTime() === endDate.isDaylightSavingTime())); if (hasDSTMismatch && orient === 1) { startDate.addHours(-1); } else if (hasDSTMismatch) { startDate.addHours(1); } }; /** * TimePeriod(startDate, endDate); * TimePeriod(years, months, days, hours, minutes, seconds, milliseconds); */ var TimePeriod = function (years, months, days, hours, minutes, seconds, milliseconds) { if (arguments.length === 7) { this.set(years, months, days, hours, minutes, seconds, milliseconds); } else if (arguments.length === 2 && arguments[0] instanceof Date && arguments[1] instanceof Date) { var startDate = arguments[0].clone(); var endDate = arguments[1].clone(); var orient = (startDate > endDate) ? +1 : -1; this.dates = { start: arguments[0].clone(), end: arguments[1].clone() }; setMonthsAndYears(orient, startDate, endDate, this); adjustForDST(orient, startDate, endDate); // // TODO - adjust for DST var diff = endDate - startDate; if (diff !== 0) { var ts = new TimeSpan(diff); this.set(this.years, this.months, ts.getDays(), ts.getHours(), ts.getMinutes(), ts.getSeconds(), ts.getMilliseconds()); } } return this; }; // create all the set functions. addSetFuncs(TimePeriod, attrs); TimePeriod.prototype.set = function (years, months, days, hours, minutes, seconds, milliseconds){ this.setYears(years || this.getYears()); this.setMonths(months || this.getMonths()); this.setDays(days || this.getDays()); this.setHours(hours || this.getHours()); this.setMinutes(minutes || this.getMinutes()); this.setSeconds(seconds || this.getSeconds()); this.setMilliseconds(milliseconds || this.getMilliseconds()); }; Date.TimePeriod = TimePeriod; if (typeof window !== "undefined") { // keeping API compatible for v1.x window.TimePeriod = TimePeriod; } }()); ================================================ FILE: build/date-uk-UA.js ================================================ /** * @overview datejs * @version 1.0.0-rc3 * @author Gregory Wild-Smith * @copyright 2015 Gregory Wild-Smith * @license MIT * @homepage https://github.com/abritinthebay/datejs */ /* * DateJS Culture String File * Country Code: uk-UA * Name: Ukrainian (Ukraine) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["uk-UA"] = { "name": "uk-UA", "englishName": "Ukrainian (Ukraine)", "nativeName": "україньска (Україна)", "Sunday": "неділя", "Monday": "понеділок", "Tuesday": "вівторок", "Wednesday": "середа", "Thursday": "четвер", "Friday": "п'ятниця", "Saturday": "субота", "Sun": "Нд", "Mon": "Пн", "Tue": "Вт", "Wed": "Ср", "Thu": "Чт", "Fri": "Пт", "Sat": "Сб", "Su": "Нд", "Mo": "Пн", "Tu": "Вт", "We": "Ср", "Th": "Чт", "Fr": "Пт", "Sa": "Сб", "S_Sun_Initial": "Н", "M_Mon_Initial": "П", "T_Tue_Initial": "В", "W_Wed_Initial": "С", "T_Thu_Initial": "Ч", "F_Fri_Initial": "П", "S_Sat_Initial": "С", "January": "Січень", "February": "Лютий", "March": "Березень", "April": "Квітень", "May": "Травень", "June": "Червень", "July": "Липень", "August": "Серпень", "September": "Вересень", "October": "Жовтень", "November": "Листопад", "December": "Грудень", "Jan_Abbr": "Січ", "Feb_Abbr": "Лют", "Mar_Abbr": "Бер", "Apr_Abbr": "Кві", "May_Abbr": "Тра", "Jun_Abbr": "Чер", "Jul_Abbr": "Лип", "Aug_Abbr": "Сер", "Sep_Abbr": "Вер", "Oct_Abbr": "Жов", "Nov_Abbr": "Лис", "Dec_Abbr": "Гру", "AM": "", "PM": "", "firstDayOfWeek": 1, "twoDigitYearMax": 2029, "mdy": "dmy", "M/d/yyyy": "dd.MM.yyyy", "dddd, MMMM dd, yyyy": "d MMMM yyyy' р.'", "h:mm tt": "H:mm", "h:mm:ss tt": "H:mm:ss", "dddd, MMMM dd, yyyy h:mm:ss tt": "d MMMM yyyy' р.' H:mm:ss", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "d MMMM", "MMMM, yyyy": "MMMM yyyy' р.'", "/jan(uary)?/": "січ(ень)?", "/feb(ruary)?/": "лют(ий)?", "/mar(ch)?/": "бер(езень)?", "/apr(il)?/": "кві(тень)?", "/may/": "тра(вень)?", "/jun(e)?/": "чер(вень)?", "/jul(y)?/": "лип(ень)?", "/aug(ust)?/": "сер(пень)?", "/sep(t(ember)?)?/": "вер(есень)?", "/oct(ober)?/": "жов(тень)?", "/nov(ember)?/": "лис(топад)?", "/dec(ember)?/": "гру(день)?", "/^su(n(day)?)?/": "^неділя", "/^mo(n(day)?)?/": "^понеділок", "/^tu(e(s(day)?)?)?/": "^вівторок", "/^we(d(nesday)?)?/": "^середа", "/^th(u(r(s(day)?)?)?)?/": "^четвер", "/^fr(i(day)?)?/": "^п'ятниця", "/^sa(t(urday)?)?/": "^субота", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "uk-UA"; /** * @overview datejs * @version 1.0.0-rc3 * @author Gregory Wild-Smith * @copyright 2015 Gregory Wild-Smith * @license MIT * @homepage https://github.com/abritinthebay/datejs */(function () { var $D = Date; var lang = Date.CultureStrings ? Date.CultureStrings.lang : null; var loggedKeys = {}; // for debug purposes. var getText = { getFromKey: function (key, countryCode) { var output; if (Date.CultureStrings && Date.CultureStrings[countryCode] && Date.CultureStrings[countryCode][key]) { output = Date.CultureStrings[countryCode][key]; } else { output = getText.buildFromDefault(key); } if (key.charAt(0) === "/") { // Assume it's a regex output = getText.buildFromRegex(key, countryCode); } return output; }, getFromObjectValues: function (obj, countryCode) { var key, output = {}; for(key in obj) { if (obj.hasOwnProperty(key)) { output[key] = getText.getFromKey(obj[key], countryCode); } } return output; }, getFromObjectKeys: function (obj, countryCode) { var key, output = {}; for(key in obj) { if (obj.hasOwnProperty(key)) { output[getText.getFromKey(key, countryCode)] = obj[key]; } } return output; }, getFromArray: function (arr, countryCode) { var output = []; for (var i=0; i < arr.length; i++){ if (i in arr) { output[i] = getText.getFromKey(arr[i], countryCode); } } return output; }, buildFromDefault: function (key) { var output, length, split, last; switch(key) { case "name": output = "en-US"; break; case "englishName": output = "English (United States)"; break; case "nativeName": output = "English (United States)"; break; case "twoDigitYearMax": output = 2049; break; case "firstDayOfWeek": output = 0; break; default: output = key; split = key.split("_"); length = split.length; if (length > 1 && key.charAt(0) !== "/") { // if the key isn't a regex and it has a split. last = split[(length - 1)].toLowerCase(); if (last === "initial" || last === "abbr") { output = split[0]; } } break; } return output; }, buildFromRegex: function (key, countryCode) { var output; if (Date.CultureStrings && Date.CultureStrings[countryCode] && Date.CultureStrings[countryCode][key]) { output = new RegExp(Date.CultureStrings[countryCode][key], "i"); } else { output = new RegExp(key.replace(new RegExp("/", "g"),""), "i"); } return output; } }; var shallowMerge = function (obj1, obj2) { for (var attrname in obj2) { if (obj2.hasOwnProperty(attrname)) { obj1[attrname] = obj2[attrname]; } } }; var __ = function (key, language) { var countryCode = (language) ? language : lang; loggedKeys[key] = key; if (typeof key === "object") { if (key instanceof Array) { return getText.getFromArray(key, countryCode); } else { return getText.getFromObjectKeys(key, countryCode); } } else { return getText.getFromKey(key, countryCode); } }; var loadI18nScript = function (code) { // paatterned after jQuery's getScript. var url = Date.Config.i18n + code + ".js"; var head = document.getElementsByTagName("head")[0] || document.documentElement; var script = document.createElement("script"); script.src = url; var completed = false; var events = { done: function (){} // placeholder function }; // Attach handlers for all browsers script.onload = script.onreadystatechange = function() { if ( !completed && (!this.readyState || this.readyState === "loaded" || this.readyState === "complete") ) { events.done(); head.removeChild(script); } }; setTimeout(function() { head.insertBefore(script, head.firstChild); }, 0); // allows return to execute first return { done: function (cb) { events.done = function() { if (cb) { setTimeout(cb,0); } }; } }; }; var buildInfo = { buildFromMethodHash: function (obj) { var key; for(key in obj) { if (obj.hasOwnProperty(key)) { obj[key] = buildInfo[obj[key]](); } } return obj; }, timeZoneDST: function () { var DST = { "CHADT": "+1345", "NZDT": "+1300", "AEDT": "+1100", "ACDT": "+1030", "AZST": "+0500", "IRDT": "+0430", "EEST": "+0300", "CEST": "+0200", "BST": "+0100", "PMDT": "-0200", "ADT": "-0300", "NDT": "-0230", "EDT": "-0400", "CDT": "-0500", "MDT": "-0600", "PDT": "-0700", "AKDT": "-0800", "HADT": "-0900" }; return __(DST); }, timeZoneStandard: function () { var standard = { "LINT": "+1400", "TOT": "+1300", "CHAST": "+1245", "NZST": "+1200", "NFT": "+1130", "SBT": "+1100", "AEST": "+1000", "ACST": "+0930", "JST": "+0900", "CWST": "+0845", "CT": "+0800", "ICT": "+0700", "MMT": "+0630", "BST": "+0600", "NPT": "+0545", "IST": "+0530", "PKT": "+0500", "AFT": "+0430", "MSK": "+0400", "IRST": "+0330", "FET": "+0300", "EET": "+0200", "CET": "+0100", "GMT": "+0000", "UTC": "+0000", "CVT": "-0100", "GST": "-0200", "BRT": "-0300", "NST": "-0330", "AST": "-0400", "EST": "-0500", "CST": "-0600", "MST": "-0700", "PST": "-0800", "AKST": "-0900", "MIT": "-0930", "HST": "-1000", "SST": "-1100", "BIT": "-1200" }; return __(standard); }, timeZones: function (data) { var zone; data.timezones = []; for (zone in data.abbreviatedTimeZoneStandard) { if (data.abbreviatedTimeZoneStandard.hasOwnProperty(zone)) { data.timezones.push({ name: zone, offset: data.abbreviatedTimeZoneStandard[zone]}); } } for (zone in data.abbreviatedTimeZoneDST) { if (data.abbreviatedTimeZoneDST.hasOwnProperty(zone)) { data.timezones.push({ name: zone, offset: data.abbreviatedTimeZoneDST[zone], dst: true}); } } return data.timezones; }, days: function () { return __(["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"]); }, dayAbbr: function () { return __(["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"]); }, dayShortNames: function () { return __(["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"]); }, dayFirstLetters: function () { return __(["S_Sun_Initial", "M_Mon_Initial", "T_Tues_Initial", "W_Wed_Initial", "T_Thu_Initial", "F_Fri_Initial", "S_Sat_Initial"]); }, months: function () { return __(["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"]); }, monthAbbr: function () { return __(["Jan_Abbr", "Feb_Abbr", "Mar_Abbr", "Apr_Abbr", "May_Abbr", "Jun_Abbr", "Jul_Abbr", "Aug_Abbr", "Sep_Abbr", "Oct_Abbr", "Nov_Abbr", "Dec_Abbr"]); }, formatPatterns: function () { return getText.getFromObjectValues({ shortDate: "M/d/yyyy", longDate: "dddd, MMMM dd, yyyy", shortTime: "h:mm tt", longTime: "h:mm:ss tt", fullDateTime: "dddd, MMMM dd, yyyy h:mm:ss tt", sortableDateTime: "yyyy-MM-ddTHH:mm:ss", universalSortableDateTime: "yyyy-MM-dd HH:mm:ssZ", rfc1123: "ddd, dd MMM yyyy HH:mm:ss", monthDay: "MMMM dd", yearMonth: "MMMM, yyyy" }, Date.i18n.currentLanguage()); }, regex: function () { return getText.getFromObjectValues({ inTheMorning: "/( in the )(morn(ing)?)\\b/", thisMorning: "/(this )(morn(ing)?)\\b/", amThisMorning: "/(\b\\d(am)? )(this )(morn(ing)?)/", inTheEvening: "/( in the )(even(ing)?)\\b/", thisEvening: "/(this )(even(ing)?)\\b/", pmThisEvening: "/(\b\\d(pm)? )(this )(even(ing)?)/", jan: "/jan(uary)?/", feb: "/feb(ruary)?/", mar: "/mar(ch)?/", apr: "/apr(il)?/", may: "/may/", jun: "/jun(e)?/", jul: "/jul(y)?/", aug: "/aug(ust)?/", sep: "/sep(t(ember)?)?/", oct: "/oct(ober)?/", nov: "/nov(ember)?/", dec: "/dec(ember)?/", sun: "/^su(n(day)?)?/", mon: "/^mo(n(day)?)?/", tue: "/^tu(e(s(day)?)?)?/", wed: "/^we(d(nesday)?)?/", thu: "/^th(u(r(s(day)?)?)?)?/", fri: "/fr(i(day)?)?/", sat: "/^sa(t(urday)?)?/", future: "/^next/", past: "/^last|past|prev(ious)?/", add: "/^(\\+|aft(er)?|from|hence)/", subtract: "/^(\\-|bef(ore)?|ago)/", yesterday: "/^yes(terday)?/", today: "/^t(od(ay)?)?/", tomorrow: "/^tom(orrow)?/", now: "/^n(ow)?/", millisecond: "/^ms|milli(second)?s?/", second: "/^sec(ond)?s?/", minute: "/^mn|min(ute)?s?/", hour: "/^h(our)?s?/", week: "/^w(eek)?s?/", month: "/^m(onth)?s?/", day: "/^d(ay)?s?/", year: "/^y(ear)?s?/", shortMeridian: "/^(a|p)/", longMeridian: "/^(a\\.?m?\\.?|p\\.?m?\\.?)/", timezone: "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/", ordinalSuffix: "/^\\s*(st|nd|rd|th)/", timeContext: "/^\\s*(\\:|a(?!u|p)|p)/" }, Date.i18n.currentLanguage()); } }; var CultureInfo = function () { var info = getText.getFromObjectValues({ name: "name", englishName: "englishName", nativeName: "nativeName", amDesignator: "AM", pmDesignator: "PM", firstDayOfWeek: "firstDayOfWeek", twoDigitYearMax: "twoDigitYearMax", dateElementOrder: "mdy" }, Date.i18n.currentLanguage()); var constructedInfo = buildInfo.buildFromMethodHash({ dayNames: "days", abbreviatedDayNames: "dayAbbr", shortestDayNames: "dayShortNames", firstLetterDayNames: "dayFirstLetters", monthNames: "months", abbreviatedMonthNames: "monthAbbr", formatPatterns: "formatPatterns", regexPatterns: "regex", abbreviatedTimeZoneDST: "timeZoneDST", abbreviatedTimeZoneStandard: "timeZoneStandard" }); shallowMerge(info, constructedInfo); buildInfo.timeZones(info); return info; }; $D.i18n = { __: function (key, lang) { return __(key, lang); }, currentLanguage: function () { return lang || "en-US"; }, setLanguage: function (code, force, cb) { var async = false; if (force || code === "en-US" || (!!Date.CultureStrings && !!Date.CultureStrings[code])) { lang = code; Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings.lang = code; Date.CultureInfo = new CultureInfo(); } else { if (!(!!Date.CultureStrings && !!Date.CultureStrings[code])) { if (typeof exports !== "undefined" && this.exports !== exports) { // we're in a Node enviroment, load it using require try { require("../i18n/" + code + ".js"); lang = code; Date.CultureStrings.lang = code; Date.CultureInfo = new CultureInfo(); } catch (e) { // var str = "The language for '" + code + "' could not be loaded by Node. It likely does not exist."; throw new Error("The DateJS IETF language tag '" + code + "' could not be loaded by Node. It likely does not exist."); } } else if (Date.Config && Date.Config.i18n) { // we know the location of the files, so lets load them async = true; loadI18nScript(code).done(function(){ lang = code; Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings.lang = code; Date.CultureInfo = new CultureInfo(); $D.Parsing.Normalizer.buildReplaceData(); // because this is async if ($D.Grammar) { $D.Grammar.buildGrammarFormats(); // so we can parse those strings... } if (cb) { setTimeout(cb,0); } }); } else { Date.console.error("The DateJS IETF language tag '" + code + "' is not available and has not been loaded."); return false; } } } $D.Parsing.Normalizer.buildReplaceData(); // rebuild normalizer strings if ($D.Grammar) { $D.Grammar.buildGrammarFormats(); // so we can parse those strings... } if (!async && cb) { setTimeout(cb,0); } }, getLoggedKeys: function () { return loggedKeys; }, updateCultureInfo: function () { Date.CultureInfo = new CultureInfo(); } }; $D.i18n.updateCultureInfo(); // run automatically }()); (function () { var $D = Date, $P = $D.prototype, p = function (s, l) { if (!l) { l = 2; } return ("000" + s).slice(l * -1); }; if (typeof window !== "undefined" && typeof window.console !== "undefined" && typeof window.console.log !== "undefined") { $D.console = console; // used only to raise non-critical errors if available } else { // set mock so we don't give errors. $D.console = { log: function(){}, error: function(){} }; } $D.Config = $D.Config || {}; $D.initOverloads = function() { /** * Overload of Date.now. Allows an alternate call for Date.now where it returns the * current Date as an object rather than just milliseconds since the Unix Epoch. * * Also provides an implementation of now() for browsers (IE<9) that don't have it. * * Backwards compatible so with work with either: * Date.now() [returns ms] * or * Date.now(true) [returns Date] */ if (!$D.now) { $D._now = function now() { return new Date().getTime(); }; } else if (!$D._now) { $D._now = $D.now; } $D.now = function (returnObj) { if (returnObj) { return $D.present(); } else { return $D._now(); } }; if ( !$P.toISOString ) { $P.toISOString = function() { return this.getUTCFullYear() + "-" + p(this.getUTCMonth() + 1) + "-" + p(this.getUTCDate()) + "T" + p(this.getUTCHours()) + ":" + p(this.getUTCMinutes()) + ":" + p(this.getUTCSeconds()) + "." + String( (this.getUTCMilliseconds()/1000).toFixed(3)).slice(2, 5) + "Z"; }; } // private if ( $P._toString === undefined ){ $P._toString = $P.toString; } }; $D.initOverloads(); /** * Gets a date that is set to the current date. The time is set to the start of the day (00:00 or 12:00 AM). * @return {Date} The current date. */ $D.today = function () { return new Date().clearTime(); }; /** * Gets a date that is set to the current date and time (same as new Date, but chainable) * @return {Date} The current date. */ $D.present = function () { return new Date(); }; /** * Compares the first date to the second date and returns an number indication of their relative values. * @param {Date} First Date object to compare [Required]. * @param {Date} Second Date object to compare to [Required]. * @return {Number} -1 = date1 is lessthan date2. 0 = values are equal. 1 = date1 is greaterthan date2. */ $D.compare = function (date1, date2) { if (isNaN(date1) || isNaN(date2)) { throw new Error(date1 + " - " + date2); } else if (date1 instanceof Date && date2 instanceof Date) { return (date1 < date2) ? -1 : (date1 > date2) ? 1 : 0; } else { throw new TypeError(date1 + " - " + date2); } }; /** * Compares the first Date object to the second Date object and returns true if they are equal. * @param {Date} First Date object to compare [Required] * @param {Date} Second Date object to compare to [Required] * @return {Boolean} true if dates are equal. false if they are not equal. */ $D.equals = function (date1, date2) { return (date1.compareTo(date2) === 0); }; /** * Gets the language appropriate day name when given the day number(0-6) * eg - 0 == Sunday * @return {String} The day name */ $D.getDayName = function (n) { return Date.CultureInfo.dayNames[n]; }; /** * Gets the day number (0-6) if given a CultureInfo specific string which is a valid dayName, abbreviatedDayName or shortestDayName (two char). * @param {String} The name of the day (eg. "Monday, "Mon", "tuesday", "tue", "We", "we"). * @return {Number} The day number */ $D.getDayNumberFromName = function (name) { var n = Date.CultureInfo.dayNames, m = Date.CultureInfo.abbreviatedDayNames, o = Date.CultureInfo.shortestDayNames, s = name.toLowerCase(); for (var i = 0; i < n.length; i++) { if (n[i].toLowerCase() === s || m[i].toLowerCase() === s || o[i].toLowerCase() === s) { return i; } } return -1; }; /** * Gets the month number (0-11) if given a Culture Info specific string which is a valid monthName or abbreviatedMonthName. * @param {String} The name of the month (eg. "February, "Feb", "october", "oct"). * @return {Number} The day number */ $D.getMonthNumberFromName = function (name) { var n = Date.CultureInfo.monthNames, m = Date.CultureInfo.abbreviatedMonthNames, s = name.toLowerCase(); for (var i = 0; i < n.length; i++) { if (n[i].toLowerCase() === s || m[i].toLowerCase() === s) { return i; } } return -1; }; /** * Gets the language appropriate month name when given the month number(0-11) * eg - 0 == January * @return {String} The month name */ $D.getMonthName = function (n) { return Date.CultureInfo.monthNames[n]; }; /** * Determines if the current date instance is within a LeapYear. * @param {Number} The year. * @return {Boolean} true if date is within a LeapYear, otherwise false. */ $D.isLeapYear = function (year) { return ((year % 4 === 0 && year % 100 !== 0) || year % 400 === 0); }; /** * Gets the number of days in the month, given a year and month value. Automatically corrects for LeapYear. * @param {Number} The year. * @param {Number} The month (0-11). * @return {Number} The number of days in the month. */ $D.getDaysInMonth = function (year, month) { if (!month && $D.validateMonth(year)) { month = year; year = Date.today().getFullYear(); } return [31, ($D.isLeapYear(year) ? 29 : 28), 31, 30, 31, 30, 31, 31, 30, 31, 30, 31][month]; }; $P.getDaysInMonth = function () { return $D.getDaysInMonth(this.getFullYear(), this.getMonth()); }; $D.getTimezoneAbbreviation = function (offset, dst) { var p, n = (dst || false) ? Date.CultureInfo.abbreviatedTimeZoneDST : Date.CultureInfo.abbreviatedTimeZoneStandard; for (p in n) { if (n.hasOwnProperty(p)) { if (n[p] === offset) { return p; } } } return null; }; $D.getTimezoneOffset = function (name, dst) { var i, a =[], z = Date.CultureInfo.timezones; if (!name) { name = (new Date()).getTimezone();} for (i = 0; i < z.length; i++) { if (z[i].name === name.toUpperCase()) { a.push(i); } } if (!z[a[0]]) { return null; } if (a.length === 1 || !dst) { return z[a[0]].offset; } else { for (i=0; i < a.length; i++) { if (z[a[i]].dst) { return z[a[i]].offset; } } } }; $D.getQuarter = function (d) { d = d || new Date(); // If no date supplied, use today var q = [1,2,3,4]; return q[Math.floor(d.getMonth() / 3)]; // ~~~ is a bitwise op. Faster than Math.floor }; $D.getDaysLeftInQuarter = function (d) { d = d || new Date(); var qEnd = new Date(d); qEnd.setMonth(qEnd.getMonth() + 3 - qEnd.getMonth() % 3, 0); return Math.floor((qEnd - d) / 8.64e7); }; // private var validate = function (n, min, max, name) { name = name ? name : "Object"; if (typeof n === "undefined") { return false; } else if (typeof n !== "number") { throw new TypeError(n + " is not a Number."); } else if (n < min || n > max) { // As failing validation is *not* an exceptional circumstance // lets not throw a RangeError Exception here. // It's semantically correct but it's not sensible. return false; } return true; }; /** * Validates the number is within an acceptable range for milliseconds [0-999]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateMillisecond = function (value) { return validate(value, 0, 999, "millisecond"); }; /** * Validates the number is within an acceptable range for seconds [0-59]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateSecond = function (value) { return validate(value, 0, 59, "second"); }; /** * Validates the number is within an acceptable range for minutes [0-59]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateMinute = function (value) { return validate(value, 0, 59, "minute"); }; /** * Validates the number is within an acceptable range for hours [0-23]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateHour = function (value) { return validate(value, 0, 23, "hour"); }; /** * Validates the number is within an acceptable range for the days in a month [0-MaxDaysInMonth]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateDay = function (value, year, month) { if (year === undefined || year === null || month === undefined || month === null) { return false;} return validate(value, 1, $D.getDaysInMonth(year, month), "day"); }; /** * Validates the number is within an acceptable range for months [0-11]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateWeek = function (value) { return validate(value, 0, 53, "week"); }; /** * Validates the number is within an acceptable range for months [0-11]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateMonth = function (value) { return validate(value, 0, 11, "month"); }; /** * Validates the number is within an acceptable range for years. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateYear = function (value) { /** * Per ECMAScript spec the range of times supported by Date objects is * exactly -100,000,000 days to +100,000,000 days measured relative to * midnight at the beginning of 01 January, 1970 UTC. * This gives a range of 8,640,000,000,000,000 milliseconds to either * side of 01 January, 1970 UTC. * * Earliest possible date: Tue, 20 Apr 271,822 B.C. 00:00:00 UTC * Latest possible date: Sat, 13 Sep 275,760 00:00:00 UTC */ return validate(value, -271822, 275760, "year"); }; $D.validateTimezone = function(value) { var timezones = {"ACDT":1,"ACST":1,"ACT":1,"ADT":1,"AEDT":1,"AEST":1,"AFT":1,"AKDT":1,"AKST":1,"AMST":1,"AMT":1,"ART":1,"AST":1,"AWDT":1,"AWST":1,"AZOST":1,"AZT":1,"BDT":1,"BIOT":1,"BIT":1,"BOT":1,"BRT":1,"BST":1,"BTT":1,"CAT":1,"CCT":1,"CDT":1,"CEDT":1,"CEST":1,"CET":1,"CHADT":1,"CHAST":1,"CHOT":1,"ChST":1,"CHUT":1,"CIST":1,"CIT":1,"CKT":1,"CLST":1,"CLT":1,"COST":1,"COT":1,"CST":1,"CT":1,"CVT":1,"CWST":1,"CXT":1,"DAVT":1,"DDUT":1,"DFT":1,"EASST":1,"EAST":1,"EAT":1,"ECT":1,"EDT":1,"EEDT":1,"EEST":1,"EET":1,"EGST":1,"EGT":1,"EIT":1,"EST":1,"FET":1,"FJT":1,"FKST":1,"FKT":1,"FNT":1,"GALT":1,"GAMT":1,"GET":1,"GFT":1,"GILT":1,"GIT":1,"GMT":1,"GST":1,"GYT":1,"HADT":1,"HAEC":1,"HAST":1,"HKT":1,"HMT":1,"HOVT":1,"HST":1,"ICT":1,"IDT":1,"IOT":1,"IRDT":1,"IRKT":1,"IRST":1,"IST":1,"JST":1,"KGT":1,"KOST":1,"KRAT":1,"KST":1,"LHST":1,"LINT":1,"MAGT":1,"MART":1,"MAWT":1,"MDT":1,"MET":1,"MEST":1,"MHT":1,"MIST":1,"MIT":1,"MMT":1,"MSK":1,"MST":1,"MUT":1,"MVT":1,"MYT":1,"NCT":1,"NDT":1,"NFT":1,"NPT":1,"NST":1,"NT":1,"NUT":1,"NZDT":1,"NZST":1,"OMST":1,"ORAT":1,"PDT":1,"PET":1,"PETT":1,"PGT":1,"PHOT":1,"PHT":1,"PKT":1,"PMDT":1,"PMST":1,"PONT":1,"PST":1,"PYST":1,"PYT":1,"RET":1,"ROTT":1,"SAKT":1,"SAMT":1,"SAST":1,"SBT":1,"SCT":1,"SGT":1,"SLST":1,"SRT":1,"SST":1,"SYOT":1,"TAHT":1,"THA":1,"TFT":1,"TJT":1,"TKT":1,"TLT":1,"TMT":1,"TOT":1,"TVT":1,"UCT":1,"ULAT":1,"UTC":1,"UYST":1,"UYT":1,"UZT":1,"VET":1,"VLAT":1,"VOLT":1,"VOST":1,"VUT":1,"WAKT":1,"WAST":1,"WAT":1,"WEDT":1,"WEST":1,"WET":1,"WST":1,"YAKT":1,"YEKT":1,"Z":1}; return (timezones[value] === 1); }; $D.validateTimezoneOffset= function(value) { // timezones go from +14hrs to -12hrs, the +X hours are negative offsets. return (value > -841 && value < 721); }; }()); (function () { var $D = Date, $P = $D.prototype, p = function (s, l) { if (!l) { l = 2; } return ("000" + s).slice(l * -1); }; var validateConfigObject = function (obj) { var result = {}, self = this, prop, testFunc; testFunc = function (prop, func, value) { if (prop === "day") { var month = (obj.month !== undefined) ? obj.month : self.getMonth(); var year = (obj.year !== undefined) ? obj.year : self.getFullYear(); return $D[func](value, year, month); } else { return $D[func](value); } }; for (prop in obj) { if (Object.prototype.hasOwnProperty.call(obj, prop)) { var func = "validate" + prop.charAt(0).toUpperCase() + prop.slice(1); if ($D[func] && obj[prop] !== null && testFunc(prop, func, obj[prop])) { result[prop] = obj[prop]; } } } return result; }; /** * Resets the time of this Date object to 12:00 AM (00:00), which is the start of the day. * @param {Boolean} .clone() this date instance before clearing Time * @return {Date} this */ $P.clearTime = function () { this.setHours(0); this.setMinutes(0); this.setSeconds(0); this.setMilliseconds(0); return this; }; /** * Resets the time of this Date object to the current time ('now'). * @return {Date} this */ $P.setTimeToNow = function () { var n = new Date(); this.setHours(n.getHours()); this.setMinutes(n.getMinutes()); this.setSeconds(n.getSeconds()); this.setMilliseconds(n.getMilliseconds()); return this; }; /** * Returns a new Date object that is an exact date and time copy of the original instance. * @return {Date} A new Date instance */ $P.clone = function () { return new Date(this.getTime()); }; /** * Compares this instance to a Date object and returns an number indication of their relative values. * @param {Date} Date object to compare [Required] * @return {Number} -1 = this is lessthan date. 0 = values are equal. 1 = this is greaterthan date. */ $P.compareTo = function (date) { return Date.compare(this, date); }; /** * Compares this instance to another Date object and returns true if they are equal. * @param {Date} Date object to compare. If no date to compare, new Date() [now] is used. * @return {Boolean} true if dates are equal. false if they are not equal. */ $P.equals = function (date) { return Date.equals(this, (date !== undefined ? date : new Date())); }; /** * Determines if this instance is between a range of two dates or equal to either the start or end dates. * @param {Date} Start of range [Required] * @param {Date} End of range [Required] * @return {Boolean} true is this is between or equal to the start and end dates, else false */ $P.between = function (start, end) { return this.getTime() >= start.getTime() && this.getTime() <= end.getTime(); }; /** * Determines if this date occurs after the date to compare to. * @param {Date} Date object to compare. If no date to compare, new Date() ("now") is used. * @return {Boolean} true if this date instance is greater than the date to compare to (or "now"), otherwise false. */ $P.isAfter = function (date) { return this.compareTo(date || new Date()) === 1; }; /** * Determines if this date occurs before the date to compare to. * @param {Date} Date object to compare. If no date to compare, new Date() ("now") is used. * @return {Boolean} true if this date instance is less than the date to compare to (or "now"). */ $P.isBefore = function (date) { return (this.compareTo(date || new Date()) === -1); }; /** * Determines if the current Date instance occurs today. * @return {Boolean} true if this date instance is 'today', otherwise false. */ /** * Determines if the current Date instance occurs on the same Date as the supplied 'date'. * If no 'date' to compare to is provided, the current Date instance is compared to 'today'. * @param {date} Date object to compare. If no date to compare, the current Date ("now") is used. * @return {Boolean} true if this Date instance occurs on the same Day as the supplied 'date'. */ $P.isToday = $P.isSameDay = function (date) { return this.clone().clearTime().equals((date || new Date()).clone().clearTime()); }; /** * Adds the specified number of milliseconds to this instance. * @param {Number} The number of milliseconds to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addMilliseconds = function (value) { if (!value) { return this; } this.setTime(this.getTime() + value * 1); return this; }; /** * Adds the specified number of seconds to this instance. * @param {Number} The number of seconds to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addSeconds = function (value) { if (!value) { return this; } return this.addMilliseconds(value * 1000); }; /** * Adds the specified number of seconds to this instance. * @param {Number} The number of seconds to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addMinutes = function (value) { if (!value) { return this; } return this.addMilliseconds(value * 60000); // 60*1000 }; /** * Adds the specified number of hours to this instance. * @param {Number} The number of hours to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addHours = function (value) { if (!value) { return this; } return this.addMilliseconds(value * 3600000); // 60*60*1000 }; /** * Adds the specified number of days to this instance. * @param {Number} The number of days to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addDays = function (value) { if (!value) { return this; } this.setDate(this.getDate() + value * 1); return this; }; /** * Adds the specified number of weekdays (ie - not sat or sun) to this instance. * @param {Number} The number of days to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addWeekdays = function (value) { if (!value) { return this; } var day = this.getDay(); var weeks = (Math.ceil(Math.abs(value)/7)); if (day === 0 || day === 6) { if (value > 0) { this.next().monday(); this.addDays(-1); day = this.getDay(); } } if (value < 0) { while (value < 0) { this.addDays(-1); day = this.getDay(); if (day !== 0 && day !== 6) { value++; } } return this; } else if (value > 5 || (6-day) <= value) { value = value + (weeks * 2); } return this.addDays(value); }; /** * Adds the specified number of weeks to this instance. * @param {Number} The number of weeks to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addWeeks = function (value) { if (!value) { return this; } return this.addDays(value * 7); }; /** * Adds the specified number of months to this instance. * @param {Number} The number of months to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addMonths = function (value) { if (!value) { return this; } var n = this.getDate(); this.setDate(1); this.setMonth(this.getMonth() + value * 1); this.setDate(Math.min(n, $D.getDaysInMonth(this.getFullYear(), this.getMonth()))); return this; }; $P.addQuarters = function (value) { if (!value) { return this; } // note this will take you to the same point in the quarter as you are now. // i.e. - if you are 15 days into the quarter you'll be 15 days into the resulting one. // bonus: this allows adding fractional quarters return this.addMonths(value * 3); }; /** * Adds the specified number of years to this instance. * @param {Number} The number of years to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addYears = function (value) { if (!value) { return this; } return this.addMonths(value * 12); }; /** * Adds (or subtracts) to the value of the years, months, weeks, days, hours, minutes, seconds, milliseconds of the date instance using given configuration object. Positive and Negative values allowed. * Example

	Date.today().add( { days: 1, months: 1 } )

	new Date().add( { years: -1 } )
	
* @param {Object} Configuration object containing attributes (months, days, etc.) * @return {Date} this */ $P.add = function (config) { if (typeof config === "number") { this._orient = config; return this; } var x = config; if (x.day) { // If we should be a different date than today (eg: for 'tomorrow -1d', etc). // Should only effect parsing, not direct usage (eg, Finish and FinishExact) if ((x.day - this.getDate()) !== 0) { this.setDate(x.day); } } if (x.milliseconds) { this.addMilliseconds(x.milliseconds); } if (x.seconds) { this.addSeconds(x.seconds); } if (x.minutes) { this.addMinutes(x.minutes); } if (x.hours) { this.addHours(x.hours); } if (x.weeks) { this.addWeeks(x.weeks); } if (x.months) { this.addMonths(x.months); } if (x.years) { this.addYears(x.years); } if (x.days) { this.addDays(x.days); } return this; }; /** * Get the week number. Week one (1) is the week which contains the first Thursday of the year. Monday is considered the first day of the week. * The .getWeek() function does NOT convert the date to UTC. The local datetime is used. * Please use .getISOWeek() to get the week of the UTC converted date. * @return {Number} 1 to 53 */ $P.getWeek = function (utc) { // Create a copy of this date object var self, target = new Date(this.valueOf()); if (utc) { target.addMinutes(target.getTimezoneOffset()); self = target.clone(); } else { self = this; } // ISO week date weeks start on monday // so correct the day number var dayNr = (self.getDay() + 6) % 7; // ISO 8601 states that week 1 is the week // with the first thursday of that year. // Set the target date to the thursday in the target week target.setDate(target.getDate() - dayNr + 3); // Store the millisecond value of the target date var firstThursday = target.valueOf(); // Set the target to the first thursday of the year // First set the target to january first target.setMonth(0, 1); // Not a thursday? Correct the date to the next thursday if (target.getDay() !== 4) { target.setMonth(0, 1 + ((4 - target.getDay()) + 7) % 7); } // The weeknumber is the number of weeks between the // first thursday of the year and the thursday in the target week return 1 + Math.ceil((firstThursday - target) / 604800000); // 604800000 = 7 * 24 * 3600 * 1000 }; /** * Get the ISO 8601 week number. Week one ("01") is the week which contains the first Thursday of the year. Monday is considered the first day of the week. * The .getISOWeek() function does convert the date to it's UTC value. Please use .getWeek() to get the week of the local date. * @return {String} "01" to "53" */ $P.getISOWeek = function () { return p(this.getWeek(true)); }; /** * Moves the date to Monday of the week set. Week one (1) is the week which contains the first Thursday of the year. * @param {Number} A Number (1 to 53) that represents the week of the year. * @return {Date} this */ $P.setWeek = function (n) { if ((n - this.getWeek()) === 0) { if (this.getDay() !== 1) { return this.moveToDayOfWeek(1, (this.getDay() > 1 ? -1 : 1)); } else { return this; } } else { return this.moveToDayOfWeek(1, (this.getDay() > 1 ? -1 : 1)).addWeeks(n - this.getWeek()); } }; $P.setQuarter = function (qtr) { var month = Math.abs(((qtr-1) * 3) + 1); return this.setMonth(month, 1); }; $P.getQuarter = function () { return Date.getQuarter(this); }; $P.getDaysLeftInQuarter = function () { return Date.getDaysLeftInQuarter(this); }; /** * Moves the date to the next n'th occurrence of the dayOfWeek starting from the beginning of the month. The number (-1) is a magic number and will return the last occurrence of the dayOfWeek in the month. * @param {Number} The dayOfWeek to move to * @param {Number} The n'th occurrence to move to. Use (-1) to return the last occurrence in the month * @return {Date} this */ $P.moveToNthOccurrence = function (dayOfWeek, occurrence) { if (dayOfWeek === "Weekday") { if (occurrence > 0) { this.moveToFirstDayOfMonth(); if (this.is().weekday()) { occurrence -= 1; } } else if (occurrence < 0) { this.moveToLastDayOfMonth(); if (this.is().weekday()) { occurrence += 1; } } else { return this; } return this.addWeekdays(occurrence); } var shift = 0; if (occurrence > 0) { shift = occurrence - 1; } else if (occurrence === -1) { this.moveToLastDayOfMonth(); if (this.getDay() !== dayOfWeek) { this.moveToDayOfWeek(dayOfWeek, -1); } return this; } return this.moveToFirstDayOfMonth().addDays(-1).moveToDayOfWeek(dayOfWeek, +1).addWeeks(shift); }; var moveToN = function (getFunc, addFunc, nVal) { return function (value, orient) { var diff = (value - this[getFunc]() + nVal * (orient || +1)) % nVal; return this[addFunc]((diff === 0) ? diff += nVal * (orient || +1) : diff); }; }; /** * Move to the next or last dayOfWeek based on the orient value. * @param {Number} The dayOfWeek to move to * @param {Number} Forward (+1) or Back (-1). Defaults to +1. [Optional] * @return {Date} this */ $P.moveToDayOfWeek = moveToN("getDay", "addDays", 7); /** * Move to the next or last month based on the orient value. * @param {Number} The month to move to. 0 = January, 11 = December * @param {Number} Forward (+1) or Back (-1). Defaults to +1. [Optional] * @return {Date} this */ $P.moveToMonth = moveToN("getMonth", "addMonths", 12); /** * Get the Ordinate of the current day ("th", "st", "rd"). * @return {String} */ $P.getOrdinate = function () { var num = this.getDate(); return ord(num); }; /** * Get the Ordinal day (numeric day number) of the year, adjusted for leap year. * @return {Number} 1 through 365 (366 in leap years) */ $P.getOrdinalNumber = function () { return Math.ceil((this.clone().clearTime() - new Date(this.getFullYear(), 0, 1)) / 86400000) + 1; }; /** * Get the time zone abbreviation of the current date. * @return {String} The abbreviated time zone name (e.g. "EST") */ $P.getTimezone = function () { return $D.getTimezoneAbbreviation(this.getUTCOffset(), this.isDaylightSavingTime()); }; $P.setTimezoneOffset = function (offset) { var here = this.getTimezoneOffset(), there = Number(offset) * -6 / 10; return (there || there === 0) ? this.addMinutes(there - here) : this; }; $P.setTimezone = function (offset) { return this.setTimezoneOffset($D.getTimezoneOffset(offset)); }; /** * Indicates whether Daylight Saving Time is observed in the current time zone. * @return {Boolean} true|false */ $P.hasDaylightSavingTime = function () { return (Date.today().set({month: 0, day: 1}).getTimezoneOffset() !== Date.today().set({month: 6, day: 1}).getTimezoneOffset()); }; /** * Indicates whether this Date instance is within the Daylight Saving Time range for the current time zone. * @return {Boolean} true|false */ $P.isDaylightSavingTime = function () { return Date.today().set({month: 0, day: 1}).getTimezoneOffset() !== this.getTimezoneOffset(); }; /** * Get the offset from UTC of the current date. * @return {String} The 4-character offset string prefixed with + or - (e.g. "-0500") */ $P.getUTCOffset = function (offset) { var n = (offset || this.getTimezoneOffset()) * -10 / 6, r; if (n < 0) { r = (n - 10000).toString(); return r.charAt(0) + r.substr(2); } else { r = (n + 10000).toString(); return "+" + r.substr(1); } }; /** * Returns the number of milliseconds between this date and date. * @param {Date} Defaults to now * @return {Number} The diff in milliseconds */ $P.getElapsed = function (date) { return (date || new Date()) - this; }; /** * Set the value of year, month, day, hour, minute, second, millisecond of date instance using given configuration object. * Example

	Date.today().set( { day: 20, month: 1 } )

	new Date().set( { millisecond: 0 } )
	
* * @param {Object} Configuration object containing attributes (month, day, etc.) * @return {Date} this */ $P.set = function (config) { config = validateConfigObject.call(this, config); var key; for (key in config) { if (Object.prototype.hasOwnProperty.call(config, key)) { var name = key.charAt(0).toUpperCase() + key.slice(1); var addFunc, getFunc; if (key !== "week" && key !== "month" && key !== "timezone" && key !== "timezoneOffset") { name += "s"; } addFunc = "add" + name; getFunc = "get" + name; if (key === "month") { addFunc = addFunc + "s"; } else if (key === "year"){ getFunc = "getFullYear"; } if (key !== "day" && key !== "timezone" && key !== "timezoneOffset" && key !== "week" && key !== "hour") { this[addFunc](config[key] - this[getFunc]()); } else if ( key === "timezone"|| key === "timezoneOffset" || key === "week" || key === "hour") { this["set"+name](config[key]); } } } // day has to go last because you can't validate the day without first knowing the month if (config.day) { this.addDays(config.day - this.getDate()); } return this; }; /** * Moves the date to the first day of the month. * @return {Date} this */ $P.moveToFirstDayOfMonth = function () { return this.set({ day: 1 }); }; /** * Moves the date to the last day of the month. * @return {Date} this */ $P.moveToLastDayOfMonth = function () { return this.set({ day: $D.getDaysInMonth(this.getFullYear(), this.getMonth())}); }; /** * Converts the value of the current Date object to its equivalent string representation. * Format Specifiers * CUSTOM DATE AND TIME FORMAT STRINGS * Format Description Example * ------ --------------------------------------------------------------------------- ----------------------- * s The seconds of the minute between 0-59. "0" to "59" * ss The seconds of the minute with leading zero if required. "00" to "59" * * m The minute of the hour between 0-59. "0" or "59" * mm The minute of the hour with leading zero if required. "00" or "59" * * h The hour of the day between 1-12. "1" to "12" * hh The hour of the day with leading zero if required. "01" to "12" * * H The hour of the day between 0-23. "0" to "23" * HH The hour of the day with leading zero if required. "00" to "23" * * d The day of the month between 1 and 31. "1" to "31" * dd The day of the month with leading zero if required. "01" to "31" * ddd Abbreviated day name. Date.CultureInfo.abbreviatedDayNames. "Mon" to "Sun" * dddd The full day name. Date.CultureInfo.dayNames. "Monday" to "Sunday" * * M The month of the year between 1-12. "1" to "12" * MM The month of the year with leading zero if required. "01" to "12" * MMM Abbreviated month name. Date.CultureInfo.abbreviatedMonthNames. "Jan" to "Dec" * MMMM The full month name. Date.CultureInfo.monthNames. "January" to "December" * * yy The year as a two-digit number. "99" or "08" * yyyy The full four digit year. "1999" or "2008" * * t Displays the first character of the A.M./P.M. designator. "A" or "P" * Date.CultureInfo.amDesignator or Date.CultureInfo.pmDesignator * tt Displays the A.M./P.M. designator. "AM" or "PM" * Date.CultureInfo.amDesignator or Date.CultureInfo.pmDesignator * * S The ordinal suffix ("st, "nd", "rd" or "th") of the current day. "st, "nd", "rd" or "th" * * STANDARD DATE AND TIME FORMAT STRINGS * Format Description Example *------ --------------------------------------------------------------------------- ----------------------- * d The CultureInfo shortDate Format Pattern "M/d/yyyy" * D The CultureInfo longDate Format Pattern "dddd, MMMM dd, yyyy" * F The CultureInfo fullDateTime Format Pattern "dddd, MMMM dd, yyyy h:mm:ss tt" * m The CultureInfo monthDay Format Pattern "MMMM dd" * r The CultureInfo rfc1123 Format Pattern "ddd, dd MMM yyyy HH:mm:ss GMT" * s The CultureInfo sortableDateTime Format Pattern "yyyy-MM-ddTHH:mm:ss" * t The CultureInfo shortTime Format Pattern "h:mm tt" * T The CultureInfo longTime Format Pattern "h:mm:ss tt" * u The CultureInfo universalSortableDateTime Format Pattern "yyyy-MM-dd HH:mm:ssZ" * y The CultureInfo yearMonth Format Pattern "MMMM, yyyy" * * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @return {String} A string representation of the current Date object. */ var ord = function (n) { switch (n * 1) { case 1: case 21: case 31: return "st"; case 2: case 22: return "nd"; case 3: case 23: return "rd"; default: return "th"; } }; var parseStandardFormats = function (format) { var y, c = Date.CultureInfo.formatPatterns; switch (format) { case "d": return this.toString(c.shortDate); case "D": return this.toString(c.longDate); case "F": return this.toString(c.fullDateTime); case "m": return this.toString(c.monthDay); case "r": case "R": y = this.clone().addMinutes(this.getTimezoneOffset()); return y.toString(c.rfc1123) + " GMT"; case "s": return this.toString(c.sortableDateTime); case "t": return this.toString(c.shortTime); case "T": return this.toString(c.longTime); case "u": y = this.clone().addMinutes(this.getTimezoneOffset()); return y.toString(c.universalSortableDateTime); case "y": return this.toString(c.yearMonth); default: return false; } }; var parseFormatStringsClosure = function (context) { return function (m) { if (m.charAt(0) === "\\") { return m.replace("\\", ""); } switch (m) { case "hh": return p(context.getHours() < 13 ? (context.getHours() === 0 ? 12 : context.getHours()) : (context.getHours() - 12)); case "h": return context.getHours() < 13 ? (context.getHours() === 0 ? 12 : context.getHours()) : (context.getHours() - 12); case "HH": return p(context.getHours()); case "H": return context.getHours(); case "mm": return p(context.getMinutes()); case "m": return context.getMinutes(); case "ss": return p(context.getSeconds()); case "s": return context.getSeconds(); case "yyyy": return p(context.getFullYear(), 4); case "yy": return p(context.getFullYear()); case "y": return context.getFullYear(); case "E": case "dddd": return Date.CultureInfo.dayNames[context.getDay()]; case "ddd": return Date.CultureInfo.abbreviatedDayNames[context.getDay()]; case "dd": return p(context.getDate()); case "d": return context.getDate(); case "MMMM": return Date.CultureInfo.monthNames[context.getMonth()]; case "MMM": return Date.CultureInfo.abbreviatedMonthNames[context.getMonth()]; case "MM": return p((context.getMonth() + 1)); case "M": return context.getMonth() + 1; case "t": return context.getHours() < 12 ? Date.CultureInfo.amDesignator.substring(0, 1) : Date.CultureInfo.pmDesignator.substring(0, 1); case "tt": return context.getHours() < 12 ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator; case "S": return ord(context.getDate()); case "W": return context.getWeek(); case "WW": return context.getISOWeek(); case "Q": return "Q" + context.getQuarter(); case "q": return String(context.getQuarter()); case "z": return context.getTimezone(); case "Z": case "X": return Date.getTimezoneOffset(context.getTimezone()); case "ZZ": // Timezone offset in seconds return context.getTimezoneOffset() * -60; case "u": return context.getDay(); case "L": return ($D.isLeapYear(context.getFullYear())) ? 1 : 0; case "B": // Swatch Internet Time (.beats) return "@"+((context.getUTCSeconds() + (context.getUTCMinutes()*60) + ((context.getUTCHours()+1)*3600))/86.4); default: return m; } }; }; $P.toString = function (format, ignoreStandards) { // Standard Date and Time Format Strings. Formats pulled from CultureInfo file and // may vary by culture. if (!ignoreStandards && format && format.length === 1) { output = parseStandardFormats.call(this, format); if (output) { return output; } } var parseFormatStrings = parseFormatStringsClosure(this); return format ? format.replace(/((\\)?(dd?d?d?|MM?M?M?|yy?y?y?|hh?|HH?|mm?|ss?|tt?|S|q|Q|WW?W?W?)(?![^\[]*\]))/g, parseFormatStrings).replace(/\[|\]/g, "") : this._toString(); }; }()); /************************************************************* * SugarPak - Domain Specific Language - Syntactical Sugar * *************************************************************/ (function () { var $D = Date, $P = $D.prototype, $N = Number.prototype; // private $P._orient = +1; // private $P._nth = null; // private $P._is = false; // private $P._same = false; // private $P._isSecond = false; // private $N._dateElement = "days"; /** * Moves the date to the next instance of a date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.today().next().friday();
	Date.today().next().fri();
	Date.today().next().march();
	Date.today().next().mar();
	Date.today().next().week();
	
* * @return {Date} date */ $P.next = function () { this._move = true; this._orient = +1; return this; }; /** * Creates a new Date (Date.today()) and moves the date to the next instance of the date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.next().friday();
	Date.next().fri();
	Date.next().march();
	Date.next().mar();
	Date.next().week();
	
* * @return {Date} date */ $D.next = function () { return $D.today().next(); }; /** * Moves the date to the previous instance of a date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.today().last().friday();
	Date.today().last().fri();
	Date.today().last().march();
	Date.today().last().mar();
	Date.today().last().week();
	
* * @return {Date} date */ $P.last = $P.prev = $P.previous = function () { this._move = true; this._orient = -1; return this; }; /** * Creates a new Date (Date.today()) and moves the date to the previous instance of the date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.last().friday();
	Date.last().fri();
	Date.previous().march();
	Date.prev().mar();
	Date.last().week();
	
* * @return {Date} date */ $D.last = $D.prev = $D.previous = function () { return $D.today().last(); }; /** * Performs a equality check when followed by either a month name, day name or .weekday() function. * Example

	Date.today().is().friday(); // true|false
	Date.today().is().fri();
	Date.today().is().march();
	Date.today().is().mar();
	
* * @return {Boolean} true|false */ $P.is = function () { this._is = true; return this; }; /** * Determines if two date objects occur on/in exactly the same instance of the subsequent date part function. * The function .same() must be followed by a date part function (example: .day(), .month(), .year(), etc). * * An optional Date can be passed in the date part function. If now date is passed as a parameter, 'Now' is used. * * The following example demonstrates how to determine if two dates fall on the exact same day. * * Example

	var d1 = Date.today(); // today at 00:00
	var d2 = new Date();   // exactly now.

	// Do they occur on the same day?
	d1.same().day(d2); // true
	
	// Do they occur on the same hour?
	d1.same().hour(d2); // false, unless d2 hour is '00' (midnight).
	
	// What if it's the same day, but one year apart?
	var nextYear = Date.today().add(1).year();

	d1.same().day(nextYear); // false, because the dates must occur on the exact same day. 
	
* * Scenario: Determine if a given date occurs during some week period 2 months from now. * * Example

	var future = Date.today().add(2).months();
	return someDate.same().week(future); // true|false;
	
* * @return {Boolean} true|false */ $P.same = function () { this._same = true; this._isSecond = false; return this; }; /** * Determines if the current date/time occurs during Today. Must be preceded by the .is() function. * Example

	someDate.is().today();    // true|false
	new Date().is().today();  // true
	Date.today().is().today();// true
	Date.today().add(-1).day().is().today(); // false
	
* * @return {Boolean} true|false */ $P.today = function () { return this.same().day(); }; /** * Determines if the current date is a weekday. This function must be preceded by the .is() function. * Example

	Date.today().is().weekday(); // true|false
	
* * @return {Boolean} true|false */ $P.weekday = function () { if (this._nth) { return df("Weekday").call(this); } if (this._move) { return this.addWeekdays(this._orient); } if (this._is) { this._is = false; return (!this.is().sat() && !this.is().sun()); } return false; }; /** * Determines if the current date is on the weekend. This function must be preceded by the .is() function. * Example

	Date.today().is().weekend(); // true|false
	
* * @return {Boolean} true|false */ $P.weekend = function () { if (this._is) { this._is = false; return (this.is().sat() || this.is().sun()); } return false; }; /** * Sets the Time of the current Date instance. A string "6:15 pm" or config object {hour:18, minute:15} are accepted. * Example

	// Set time to 6:15pm with a String
	Date.today().at("6:15pm");

	// Set time to 6:15pm with a config object
	Date.today().at({hour:18, minute:15});
	
* * @return {Date} date */ $P.at = function (time) { return (typeof time === "string") ? $D.parse(this.toString("d") + " " + time) : this.set(time); }; /** * Creates a new Date() and adds this (Number) to the date based on the preceding date element function (eg. second|minute|hour|day|month|year). * Example

	// Undeclared Numbers must be wrapped with parentheses. Requirment of JavaScript.
	(3).days().fromNow();
	(6).months().fromNow();

	// Declared Number variables do not require parentheses. 
	var n = 6;
	n.months().fromNow();
	
* * @return {Date} A new Date instance */ $N.fromNow = $N.after = function (date) { var c = {}; c[this._dateElement] = this; return ((!date) ? new Date() : date.clone()).add(c); }; /** * Creates a new Date() and subtract this (Number) from the date based on the preceding date element function (eg. second|minute|hour|day|month|year). * Example

	// Undeclared Numbers must be wrapped with parentheses. Requirment of JavaScript.
	(3).days().ago();
	(6).months().ago();

	// Declared Number variables do not require parentheses. 
	var n = 6;
	n.months().ago();
	
* * @return {Date} A new Date instance */ $N.ago = $N.before = function (date) { var c = {}, s = (this._dateElement[this._dateElement.length-1] !== "s") ? this._dateElement + "s" : this._dateElement; c[s] = this * -1; return ((!date) ? new Date() : date.clone()).add(c); }; // Do NOT modify the following string tokens. These tokens are used to build dynamic functions. // All culture-specific strings can be found in the CultureInfo files. var dx = ("sunday monday tuesday wednesday thursday friday saturday").split(/\s/), mx = ("january february march april may june july august september october november december").split(/\s/), px = ("Millisecond Second Minute Hour Day Week Month Year Quarter Weekday").split(/\s/), pxf = ("Milliseconds Seconds Minutes Hours Date Week Month FullYear Quarter").split(/\s/), nth = ("final first second third fourth fifth").split(/\s/), de; /** * Returns an object literal of all the date parts. * Example

	var o = new Date().toObject();
	
	// { year: 2008, month: 4, week: 20, day: 13, hour: 18, minute: 9, second: 32, millisecond: 812 }
	
	// The object properties can be referenced directly from the object.
	
	alert(o.day);  // alerts "13"
	alert(o.year); // alerts "2008"
	
* * @return {Date} An object literal representing the original date object. */ $P.toObject = function () { var o = {}; for (var i = 0; i < px.length; i++) { if (this["get" + pxf[i]]) { o[px[i].toLowerCase()] = this["get" + pxf[i]](); } } return o; }; /** * Returns a date created from an object literal. Ignores the .week property if set in the config. * Example

	var o = new Date().toObject();
	
	return Date.fromObject(o); // will return the same date. 

	var o2 = {month: 1, day: 20, hour: 18}; // birthday party!
	Date.fromObject(o2);
	
* * @return {Date} An object literal representing the original date object. */ $D.fromObject = function(config) { config.week = null; return Date.today().set(config); }; // Create day name functions and abbreviated day name functions (eg. monday(), friday(), fri()). var df = function (n) { return function () { if (this._is) { this._is = false; return this.getDay() === n; } if (this._move) { this._move = null; } if (this._nth !== null) { // If the .second() function was called earlier, remove the _orient // from the date, and then continue. // This is required because 'second' can be used in two different context. // // Example // // Date.today().add(1).second(); // Date.march().second().monday(); // // Things get crazy with the following... // Date.march().add(1).second().second().monday(); // but it works!! // if (this._isSecond) { this.addSeconds(this._orient * -1); } // make sure we reset _isSecond this._isSecond = false; var ntemp = this._nth; this._nth = null; var temp = this.clone().moveToLastDayOfMonth(); this.moveToNthOccurrence(n, ntemp); if (this > temp) { throw new RangeError($D.getDayName(n) + " does not occur " + ntemp + " times in the month of " + $D.getMonthName(temp.getMonth()) + " " + temp.getFullYear() + "."); } return this; } return this.moveToDayOfWeek(n, this._orient); }; }; var sdf = function (n) { return function () { var t = $D.today(), shift = n - t.getDay(); if (n === 0 && Date.CultureInfo.firstDayOfWeek === 1 && t.getDay() !== 0) { shift = shift + 7; } return t.addDays(shift); }; }; // Create month name functions and abbreviated month name functions (eg. january(), march(), mar()). var month_instance_functions = function (n) { return function () { if (this._is) { this._is = false; return this.getMonth() === n; } return this.moveToMonth(n, this._orient); }; }; var month_static_functions = function (n) { return function () { return $D.today().set({ month: n, day: 1 }); }; }; var processTerms = function (names, staticFunc, instanceFunc) { for (var i = 0; i < names.length; i++) { // Create constant static Name variables. $D[names[i].toUpperCase()] = $D[names[i].toUpperCase().substring(0, 3)] = i; // Create Name functions. $D[names[i]] = $D[names[i].substring(0, 3)] = staticFunc(i); // Create Name instance functions. $P[names[i]] = $P[names[i].substring(0, 3)] = instanceFunc(i); } }; processTerms(dx, sdf, df); processTerms(mx, month_static_functions, month_instance_functions); // Create date element functions and plural date element functions used with Date (eg. day(), days(), months()). var ef = function (j) { return function () { // if the .second() function was called earlier, the _orient // has alread been added. Just return this and reset _isSecond. if (this._isSecond) { this._isSecond = false; return this; } if (this._same) { this._same = this._is = false; var o1 = this.toObject(), o2 = (arguments[0] || new Date()).toObject(), v = "", k = j.toLowerCase(); // the substr trick with -1 doesn't work in IE8 or less k = (k[k.length-1] === "s") ? k.substring(0,k.length-1) : k; for (var m = (px.length - 1); m > -1; m--) { v = px[m].toLowerCase(); if (o1[v] !== o2[v]) { return false; } if (k === v) { break; } } return true; } if (j.substring(j.length - 1) !== "s") { j += "s"; } if (this._move) { this._move = null; } return this["add" + j](this._orient); }; }; var nf = function (n) { return function () { this._dateElement = n; return this; }; }; for (var k = 0; k < px.length; k++) { de = px[k].toLowerCase(); if(de !== "weekday") { // Create date element functions and plural date element functions used with Date (eg. day(), days(), months()). $P[de] = $P[de + "s"] = ef(px[k]); // Create date element functions and plural date element functions used with Number (eg. day(), days(), months()). $N[de] = $N[de + "s"] = nf(de + "s"); } } $P._ss = ef("Second"); var nthfn = function (n) { return function (dayOfWeek) { if (this._same) { return this._ss(arguments[0]); } if (dayOfWeek || dayOfWeek === 0) { return this.moveToNthOccurrence(dayOfWeek, n); } this._nth = n; // if the operator is 'second' add the _orient, then deal with it later... if (n === 2 && (dayOfWeek === undefined || dayOfWeek === null)) { this._isSecond = true; return this.addSeconds(this._orient); } return this; }; }; for (var l = 0; l < nth.length; l++) { $P[nth[l]] = (l === 0) ? nthfn(-1) : nthfn(l); } }()); (function () { "use strict"; Date.Parsing = { Exception: function (s) { this.message = "Parse error at '" + s.substring(0, 10) + " ...'"; } }; var $P = Date.Parsing; var dayOffsets = { standard: [0,31,59,90,120,151,181,212,243,273,304,334], leap: [0,31,60,91,121,152,182,213,244,274,305,335] }; $P.isLeapYear = function(year) { return ((year % 4 === 0) && (year % 100 !== 0)) || (year % 400 === 0); }; var utils = { multiReplace : function (str, hash ) { var key; for (key in hash) { if (Object.prototype.hasOwnProperty.call(hash, key)) { var regex; if (typeof hash[key] === "function") { } else { regex = (hash[key] instanceof RegExp) ? hash[key] : new RegExp(hash[key], "g"); } str = str.replace(regex, key); } } return str; }, getDayOfYearFromWeek : function (obj) { var d, jan4, offset; obj.weekDay = (!obj.weekDay && obj.weekDay !== 0) ? 1 : obj.weekDay; d = new Date(obj.year, 0, 4); jan4 = d.getDay() === 0 ? 7 : d.getDay(); // JS is 0 indexed on Sunday. offset = jan4+3; obj.dayOfYear = ((obj.week * 7) + (obj.weekDay === 0 ? 7 : obj.weekDay))-offset; return obj; }, getDayOfYear : function (obj, dayOffset) { if (!obj.dayOfYear) { obj = utils.getDayOfYearFromWeek(obj); } for (var i=0;i <= dayOffset.length;i++) { if (obj.dayOfYear < dayOffset[i] || i === dayOffset.length) { obj.day = obj.day ? obj.day : (obj.dayOfYear - dayOffset[i-1]); break; } else { obj.month = i; } } return obj; }, adjustForTimeZone : function (obj, date) { var offset; if (obj.zone.toUpperCase() === "Z" || (obj.zone_hours === 0 && obj.zone_minutes === 0)) { // it's UTC/GML so work out the current timeszone offset offset = -date.getTimezoneOffset(); } else { offset = (obj.zone_hours*60) + (obj.zone_minutes || 0); if (obj.zone_sign === "+") { offset *= -1; } offset -= date.getTimezoneOffset(); } date.setMinutes(date.getMinutes()+offset); return date; }, setDefaults : function (obj) { obj.year = obj.year || Date.today().getFullYear(); obj.hours = obj.hours || 0; obj.minutes = obj.minutes || 0; obj.seconds = obj.seconds || 0; obj.milliseconds = obj.milliseconds || 0; if (!(!obj.month && (obj.week || obj.dayOfYear))) { // if we have a month, or if we don't but don't have the day calculation data obj.month = obj.month || 0; obj.day = obj.day || 1; } return obj; }, dataNum: function (data, mod, explict, postProcess) { var dataNum = data*1; if (mod) { if (postProcess) { return data ? mod(data)*1 : data; } else { return data ? mod(dataNum) : data; } } else if (!explict){ return data ? dataNum : data; } else { return (data && typeof data !== "undefined") ? dataNum : data; } }, timeDataProcess: function (obj) { var timeObj = {}; for (var x in obj.data) { if (obj.data.hasOwnProperty(x)) { timeObj[x] = obj.ignore[x] ? obj.data[x] : utils.dataNum(obj.data[x], obj.mods[x], obj.explict[x], obj.postProcess[x]); } } if (obj.data.secmins) { obj.data.secmins = obj.data.secmins.replace(",", ".") * 60; if (!timeObj.minutes) { timeObj.minutes = obj.data.secmins; } else if (!timeObj.seconds) { timeObj.seconds = obj.data.secmins; } delete obj.secmins; } return timeObj; }, buildTimeObjectFromData: function (data) { var time = utils.timeDataProcess({ data: { year : data[1], month : data[5], day : data[7], week : data[8], dayOfYear : data[10], hours : data[15], zone_hours : data[23], zone_minutes : data[24], zone : data[21], zone_sign : data[22], weekDay : data[9], minutes: data[16], seconds: data[19], milliseconds: data[20], secmins: data[18] }, mods: { month: function(data) { return data-1; }, weekDay: function (data) { data = Math.abs(data); return (data === 7 ? 0 : data); }, minutes: function (data) { return data.replace(":",""); }, seconds: function (data) { return Math.floor( (data.replace(":","").replace(",","."))*1 ); }, milliseconds: function (data) { return (data.replace(",",".")*1000); } }, postProcess: { minutes: true, seconds: true, milliseconds: true }, explict: { zone_hours: true, zone_minutes: true }, ignore: { zone: true, zone_sign: true, secmins: true } }); return time; }, addToHash: function (hash, keys, data) { keys = keys; data = data; var len = keys.length; for (var i = 0; i < len; i++) { hash[keys[i]] = data[i]; } return hash; }, combineRegex: function (r1, r2) { return new RegExp("(("+r1.source+")\\s("+r2.source+"))"); }, getDateNthString: function(add, last, inc){ if (add) { return Date.today().addDays(inc).toString("d"); } else if (last) { return Date.today().last()[inc]().toString("d"); } }, buildRegexData: function (array) { var arr = []; var len = array.length; for (var i=0; i < len; i++) { if (Object.prototype.toString.call(array[i]) === '[object Array]') { // oldIE compat version of Array.isArray arr.push(this.combineRegex(array[i][0], array[i][1])); } else { arr.push(array[i]); } } return arr; } }; $P.processTimeObject = function (obj) { var date, dayOffset; utils.setDefaults(obj); dayOffset = ($P.isLeapYear(obj.year)) ? dayOffsets.leap : dayOffsets.standard; if (!obj.month && (obj.week || obj.dayOfYear)) { utils.getDayOfYear(obj, dayOffset); } else { obj.dayOfYear = dayOffset[obj.month] + obj.day; } date = new Date(obj.year, obj.month, obj.day, obj.hours, obj.minutes, obj.seconds, obj.milliseconds); if (obj.zone) { utils.adjustForTimeZone(obj, date); // adjust (and calculate) for timezone } return date; }; $P.ISO = { regex : /^([\+-]?\d{4}(?!\d{2}\b))((-?)((0[1-9]|1[0-2])(\3([12]\d|0[1-9]|3[01]))?|W([0-4]\d|5[0-3])(-?[1-7])?|(00[1-9]|0[1-9]\d|[12]\d{2}|3([0-5]\d|6[1-6])))([T\s]((([01]\d|2[0-4])((:?)[0-5]\d)?|24\:?00)([\.,]\d+(?!:))?)?(\17[0-5]\d([\.,]\d+)?)?\s?([zZ]|([\+-])([01]\d|2[0-3]):?([0-5]\d)?)?)?)?$/, parse : function (s) { var time, data = s.match(this.regex); if (!data || !data.length) { return null; } time = utils.buildTimeObjectFromData(data); if (!time.year || (!time.year && (!time.month && !time.day) && (!time.week && !time.dayOfYear)) ) { return null; } return $P.processTimeObject(time); } }; $P.Numeric = { isNumeric: function (e){return!isNaN(parseFloat(e))&&isFinite(e);}, regex: /\b([0-1]?[0-9])([0-3]?[0-9])([0-2]?[0-9]?[0-9][0-9])\b/i, parse: function (s) { var data, i, time = {}, order = Date.CultureInfo.dateElementOrder.split(""); if (!(this.isNumeric(s)) || // if it's non-numeric OR (s[0] === "+" && s[0] === "-")) { // It's an arithmatic string (eg +/-1000) return null; } if (s.length < 5 && s.indexOf(".") < 0 && s.indexOf("/") < 0) { // assume it's just a year. time.year = s; return $P.processTimeObject(time); } data = s.match(this.regex); if (!data || !data.length) { return null; } for (i=0; i < order.length; i++) { switch(order[i]) { case "d": time.day = data[i+1]; break; case "m": time.month = (data[i+1]-1); break; case "y": time.year = data[i+1]; break; } } return $P.processTimeObject(time); } }; $P.Normalizer = { regexData: function () { var $R = Date.CultureInfo.regexPatterns; return utils.buildRegexData([ $R.tomorrow, $R.yesterday, [$R.past, $R.mon], [$R.past, $R.tue], [$R.past, $R.wed], [$R.past, $R.thu], [$R.past, $R.fri], [$R.past, $R.sat], [$R.past, $R.sun] ]); }, basicReplaceHash : function() { var $R = Date.CultureInfo.regexPatterns; return { "January": $R.jan.source, "February": $R.feb, "March": $R.mar, "April": $R.apr, "May": $R.may, "June": $R.jun, "July": $R.jul, "August": $R.aug, "September": $R.sep, "October": $R.oct, "November": $R.nov, "December": $R.dec, "": /\bat\b/gi, " ": /\s{2,}/, "am": $R.inTheMorning, "9am": $R.thisMorning, "pm": $R.inTheEvening, "7pm":$R.thisEvening }; }, keys : function(){ return [ utils.getDateNthString(true, false, 1), // tomorrow utils.getDateNthString(true, false, -1), // yesterday utils.getDateNthString(false, true, "monday"), //last mon utils.getDateNthString(false, true, "tuesday"), //last tues utils.getDateNthString(false, true, "wednesday"), //last wed utils.getDateNthString(false, true, "thursday"), //last thurs utils.getDateNthString(false, true, "friday"), //last fri utils.getDateNthString(false, true, "saturday"), //last sat utils.getDateNthString(false, true, "sunday") //last sun ]; }, buildRegexFunctions: function () { var $R = Date.CultureInfo.regexPatterns; var __ = Date.i18n.__; var tomorrowRE = new RegExp("(\\b\\d\\d?("+__("AM")+"|"+__("PM")+")? )("+$R.tomorrow.source.slice(1)+")", "i"); // adapted tomorrow regex for AM PM relative dates var todayRE = new RegExp($R.today.source + "(?!\\s*([+-]))\\b"); // today, but excludes the math operators (eg "today + 2h") this.replaceFuncs = [ [todayRE, function (full) { return (full.length > 1) ? Date.today().toString("d") : full; }], [tomorrowRE, function(full, m1) { var t = Date.today().addDays(1).toString("d"); return (t + " " + m1); }], [$R.amThisMorning, function(str, am){return am;}], [$R.pmThisEvening, function(str, pm){return pm;}] ]; }, buildReplaceData: function () { this.buildRegexFunctions(); this.replaceHash = utils.addToHash(this.basicReplaceHash(), this.keys(), this.regexData()); }, stringReplaceFuncs: function (s) { for (var i=0; i < this.replaceFuncs.length; i++) { s = s.replace(this.replaceFuncs[i][0], this.replaceFuncs[i][1]); } return s; }, parse: function (s) { s = this.stringReplaceFuncs(s); s = utils.multiReplace(s, this.replaceHash); try { var n = s.split(/([\s\-\.\,\/\x27]+)/); if (n.length === 3 && $P.Numeric.isNumeric(n[0]) && $P.Numeric.isNumeric(n[2]) && (n[2].length >= 4)) { // ok, so we're dealing with x/year. But that's not a full date. // This fixes wonky dateElementOrder parsing when set to dmy order. if (Date.CultureInfo.dateElementOrder[0] === "d") { s = "1/" + n[0] + "/" + n[2]; // set to 1st of month and normalize the seperator } } } catch (e) {} return s; } }; $P.Normalizer.buildReplaceData(); }()); (function () { var $P = Date.Parsing; var _ = $P.Operators = { // // Tokenizers // rtoken: function (r) { // regex token return function (s) { var mx = s.match(r); if (mx) { return ([ mx[0], s.substring(mx[0].length) ]); } else { throw new $P.Exception(s); } }; }, token: function () { // whitespace-eating token return function (s) { return _.rtoken(new RegExp("^\\s*" + s + "\\s*"))(s); }; }, stoken: function (s) { // string token return _.rtoken(new RegExp("^" + s)); }, // Atomic Operators until: function (p) { return function (s) { var qx = [], rx = null; while (s.length) { try { rx = p.call(this, s); } catch (e) { qx.push(rx[0]); s = rx[1]; continue; } break; } return [ qx, s ]; }; }, many: function (p) { return function (s) { var rx = [], r = null; while (s.length) { try { r = p.call(this, s); } catch (e) { return [ rx, s ]; } rx.push(r[0]); s = r[1]; } return [ rx, s ]; }; }, // generator operators -- see below optional: function (p) { return function (s) { var r = null; try { r = p.call(this, s); } catch (e) { return [ null, s ]; } return [ r[0], r[1] ]; }; }, not: function (p) { return function (s) { try { p.call(this, s); } catch (e) { return [null, s]; } throw new $P.Exception(s); }; }, ignore: function (p) { return p ? function (s) { var r = null; r = p.call(this, s); return [null, r[1]]; } : null; }, product: function () { var px = arguments[0], qx = Array.prototype.slice.call(arguments, 1), rx = []; for (var i = 0 ; i < px.length ; i++) { rx.push(_.each(px[i], qx)); } return rx; }, cache: function (rule) { var cache = {}, cache_length = 0, cache_keys = [], CACHE_MAX = Date.Config.CACHE_MAX || 100000, r = null; var cacheCheck = function () { if (cache_length === CACHE_MAX) { // kill several keys, don't want to have to do this all the time... for (var i=0; i < 10; i++) { var key = cache_keys.shift(); if (key) { delete cache[key]; cache_length--; } } } }; return function (s) { cacheCheck(); try { r = cache[s] = (cache[s] || rule.call(this, s)); } catch (e) { r = cache[s] = e; } cache_length++; cache_keys.push(s); if (r instanceof $P.Exception) { throw r; } else { return r; } }; }, // vector operators -- see below any: function () { var px = arguments; return function (s) { var r = null; for (var i = 0; i < px.length; i++) { if (px[i] == null) { continue; } try { r = (px[i].call(this, s)); } catch (e) { r = null; } if (r) { return r; } } throw new $P.Exception(s); }; }, each: function () { var px = arguments; return function (s) { var rx = [], r = null; for (var i = 0; i < px.length ; i++) { if (px[i] == null) { continue; } try { r = (px[i].call(this, s)); } catch (e) { throw new $P.Exception(s); } rx.push(r[0]); s = r[1]; } return [ rx, s]; }; }, all: function () { var px = arguments, _ = _; return _.each(_.optional(px)); }, // delimited operators sequence: function (px, d, c) { d = d || _.rtoken(/^\s*/); c = c || null; if (px.length === 1) { return px[0]; } return function (s) { var r = null, q = null; var rx = []; for (var i = 0; i < px.length ; i++) { try { r = px[i].call(this, s); } catch (e) { break; } rx.push(r[0]); try { q = d.call(this, r[1]); } catch (ex) { q = null; break; } s = q[1]; } if (!r) { throw new $P.Exception(s); } if (q) { throw new $P.Exception(q[1]); } if (c) { try { r = c.call(this, r[1]); } catch (ey) { throw new $P.Exception(r[1]); } } return [ rx, (r?r[1]:s) ]; }; }, // // Composite Operators // between: function (d1, p, d2) { d2 = d2 || d1; var _fn = _.each(_.ignore(d1), p, _.ignore(d2)); return function (s) { var rx = _fn.call(this, s); return [[rx[0][0], r[0][2]], rx[1]]; }; }, list: function (p, d, c) { d = d || _.rtoken(/^\s*/); c = c || null; return (p instanceof Array ? _.each(_.product(p.slice(0, -1), _.ignore(d)), p.slice(-1), _.ignore(c)) : _.each(_.many(_.each(p, _.ignore(d))), px, _.ignore(c))); }, set: function (px, d, c) { d = d || _.rtoken(/^\s*/); c = c || null; return function (s) { // r is the current match, best the current 'best' match // which means it parsed the most amount of input var r = null, p = null, q = null, rx = null, best = [[], s], last = false; // go through the rules in the given set for (var i = 0; i < px.length ; i++) { // last is a flag indicating whether this must be the last element // if there is only 1 element, then it MUST be the last one q = null; p = null; r = null; last = (px.length === 1); // first, we try simply to match the current pattern // if not, try the next pattern try { r = px[i].call(this, s); } catch (e) { continue; } // since we are matching against a set of elements, the first // thing to do is to add r[0] to matched elements rx = [[r[0]], r[1]]; // if we matched and there is still input to parse and // we don't already know this is the last element, // we're going to next check for the delimiter ... // if there's none, or if there's no input left to parse // than this must be the last element after all ... if (r[1].length > 0 && ! last) { try { q = d.call(this, r[1]); } catch (ex) { last = true; } } else { last = true; } // if we parsed the delimiter and now there's no more input, // that means we shouldn't have parsed the delimiter at all // so don't update r and mark this as the last element ... if (!last && q[1].length === 0) { last = true; } // so, if this isn't the last element, we're going to see if // we can get any more matches from the remaining (unmatched) // elements ... if (!last) { // build a list of the remaining rules we can match against, // i.e., all but the one we just matched against var qx = []; for (var j = 0; j < px.length ; j++) { if (i !== j) { qx.push(px[j]); } } // now invoke recursively set with the remaining input // note that we don't include the closing delimiter ... // we'll check for that ourselves at the end p = _.set(qx, d).call(this, q[1]); // if we got a non-empty set as a result ... // (otw rx already contains everything we want to match) if (p[0].length > 0) { // update current result, which is stored in rx ... // basically, pick up the remaining text from p[1] // and concat the result from p[0] so that we don't // get endless nesting ... rx[0] = rx[0].concat(p[0]); rx[1] = p[1]; } } // at this point, rx either contains the last matched element // or the entire matched set that starts with this element. // now we just check to see if this variation is better than // our best so far, in terms of how much of the input is parsed if (rx[1].length < best[1].length) { best = rx; } // if we've parsed all the input, then we're finished if (best[1].length === 0) { break; } } // so now we've either gone through all the patterns trying them // as the initial match; or we found one that parsed the entire // input string ... // if best has no matches, just return empty set ... if (best[0].length === 0) { return best; } // if a closing delimiter is provided, then we have to check it also if (c) { // we try this even if there is no remaining input because the pattern // may well be optional or match empty input ... try { q = c.call(this, best[1]); } catch (ey) { throw new $P.Exception(best[1]); } // it parsed ... be sure to update the best match remaining input best[1] = q[1]; } // if we're here, either there was no closing delimiter or we parsed it // so now we have the best match; just return it! return best; }; }, forward: function (gr, fname) { return function (s) { return gr[fname].call(this, s); }; }, // // Translation Operators // replace: function (rule, repl) { return function (s) { var r = rule.call(this, s); return [repl, r[1]]; }; }, process: function (rule, fn) { return function (s) { var r = rule.call(this, s); return [fn.call(this, r[0]), r[1]]; }; }, min: function (min, rule) { return function (s) { var rx = rule.call(this, s); if (rx[0].length < min) { throw new $P.Exception(s); } return rx; }; } }; // Generator Operators And Vector Operators // Generators are operators that have a signature of F(R) => R, // taking a given rule and returning another rule, such as // ignore, which parses a given rule and throws away the result. // Vector operators are those that have a signature of F(R1,R2,...) => R, // take a list of rules and returning a new rule, such as each. // Generator operators are converted (via the following _generator // function) into functions that can also take a list or array of rules // and return an array of new rules as though the function had been // called on each rule in turn (which is what actually happens). // This allows generators to be used with vector operators more easily. // Example: // each(ignore(foo, bar)) instead of each(ignore(foo), ignore(bar)) // This also turns generators into vector operators, which allows // constructs like: // not(cache(foo, bar)) var _generator = function (op) { function gen() { var args = null, rx = [], px, i; if (arguments.length > 1) { args = Array.prototype.slice.call(arguments); } else if (arguments[0] instanceof Array) { args = arguments[0]; } if (args) { px = args.shift(); if (px.length > 0) { args.unshift(px[i]); rx.push(op.apply(null, args)); args.shift(); return rx; } } else { return op.apply(null, arguments); } } return gen; }; var gx = "optional not ignore cache".split(/\s/); for (var i = 0 ; i < gx.length ; i++) { _[gx[i]] = _generator(_[gx[i]]); } var _vector = function (op) { return function () { if (arguments[0] instanceof Array) { return op.apply(null, arguments[0]); } else { return op.apply(null, arguments); } }; }; var vx = "each any all".split(/\s/); for (var j = 0 ; j < vx.length ; j++) { _[vx[j]] = _vector(_[vx[j]]); } }()); (function () { var $D = Date; var flattenAndCompact = function (ax) { var rx = []; for (var i = 0; i < ax.length; i++) { if (ax[i] instanceof Array) { rx = rx.concat(flattenAndCompact(ax[i])); } else { if (ax[i]) { rx.push(ax[i]); } } } return rx; }; var parseMeridian = function () { if (this.meridian && (this.hour || this.hour === 0)) { if (this.meridian === "a" && this.hour > 11 && Date.Config.strict24hr){ throw "Invalid hour and meridian combination"; } else if (this.meridian === "p" && this.hour < 12 && Date.Config.strict24hr){ throw "Invalid hour and meridian combination"; } else if (this.meridian === "p" && this.hour < 12) { this.hour = this.hour + 12; } else if (this.meridian === "a" && this.hour === 12) { this.hour = 0; } } }; var setDefaults = function () { var now = new Date(); if ((this.hour || this.minute) && (!this.month && !this.year && !this.day)) { this.day = now.getDate(); } if (!this.year) { this.year = now.getFullYear(); } if (!this.month && this.month !== 0) { this.month = now.getMonth(); } if (!this.day) { this.day = 1; } if (!this.hour) { this.hour = 0; } if (!this.minute) { this.minute = 0; } if (!this.second) { this.second = 0; } if (!this.millisecond) { this.millisecond = 0; } }; var finishUtils = { getToday: function () { if (this.now || "hour minute second".indexOf(this.unit) !== -1) { return new Date(); } else { return $D.today(); } }, setDaysFromWeekday: function (today, orient){ var gap; orient = orient || 1; this.unit = "day"; gap = ($D.getDayNumberFromName(this.weekday) - today.getDay()); this.days = gap ? ((gap + (orient * 7)) % 7) : (orient * 7); return this; }, setMonthsFromMonth: function (today, orient) { var gap; orient = orient || 1; this.unit = "month"; gap = (this.month - today.getMonth()); this.months = gap ? ((gap + (orient * 12)) % 12) : (orient * 12); this.month = null; return this; }, setDMYFromWeekday: function () { var d = Date[this.weekday](); this.day = d.getDate(); if (!this.month) { this.month = d.getMonth(); } this.year = d.getFullYear(); return this; }, setUnitValue: function (orient) { if (!this.value && this.operator && this.operator !== null && this[this.unit + "s"] && this[this.unit + "s"] !== null) { this[this.unit + "s"] = this[this.unit + "s"] + ((this.operator === "add") ? 1 : -1) + (this.value||0) * orient; } else if (this[this.unit + "s"] == null || this.operator != null) { if (!this.value) { this.value = 1; } this[this.unit + "s"] = this.value * orient; } }, generateDateFromWeeks: function () { var weekday = (this.weekday !== undefined) ? this.weekday : "today"; var d = Date[weekday]().addWeeks(this.weeks); if (this.now) { d.setTimeToNow(); } return d; } }; $D.Translator = { hour: function (s) { return function () { this.hour = Number(s); }; }, minute: function (s) { return function () { this.minute = Number(s); }; }, second: function (s) { return function () { this.second = Number(s); }; }, /* for ss.s format */ secondAndMillisecond: function (s) { return function () { var mx = s.match(/^([0-5][0-9])\.([0-9]{1,3})/); this.second = Number(mx[1]); this.millisecond = Number(mx[2]); }; }, meridian: function (s) { return function () { this.meridian = s.slice(0, 1).toLowerCase(); }; }, timezone: function (s) { return function () { var n = s.replace(/[^\d\+\-]/g, ""); if (n.length) { this.timezoneOffset = Number(n); } else { this.timezone = s.toLowerCase(); } }; }, day: function (x) { var s = x[0]; return function () { this.day = Number(s.match(/\d+/)[0]); if (this.day < 1) { throw "invalid day"; } }; }, month: function (s) { return function () { this.month = (s.length === 3) ? "jan feb mar apr may jun jul aug sep oct nov dec".indexOf(s)/4 : Number(s) - 1; if (this.month < 0) { throw "invalid month"; } }; }, year: function (s) { return function () { var n = Number(s); this.year = ((s.length > 2) ? n : (n + (((n + 2000) < Date.CultureInfo.twoDigitYearMax) ? 2000 : 1900))); }; }, rday: function (s) { return function () { switch (s) { case "yesterday": this.days = -1; break; case "tomorrow": this.days = 1; break; case "today": this.days = 0; break; case "now": this.days = 0; this.now = true; break; } }; }, finishExact: function (x) { var d; x = (x instanceof Array) ? x : [x]; for (var i = 0 ; i < x.length ; i++) { if (x[i]) { x[i].call(this); } } setDefaults.call(this); parseMeridian.call(this); if (this.day > $D.getDaysInMonth(this.year, this.month)) { throw new RangeError(this.day + " is not a valid value for days."); } d = new Date(this.year, this.month, this.day, this.hour, this.minute, this.second, this.millisecond); if (this.year < 100) { d.setFullYear(this.year); // means years less that 100 are process correctly. JS will parse it otherwise as 1900-1999. } if (this.timezone) { d.set({ timezone: this.timezone }); } else if (this.timezoneOffset) { d.set({ timezoneOffset: this.timezoneOffset }); } return d; }, finish: function (x) { var today, expression, orient, temp; x = (x instanceof Array) ? flattenAndCompact(x) : [ x ]; if (x.length === 0) { return null; } for (var i = 0 ; i < x.length ; i++) { if (typeof x[i] === "function") { x[i].call(this); } } if (this.now && !this.unit && !this.operator) { return new Date(); } else { today = finishUtils.getToday.call(this); } expression = !!(this.days && this.days !== null || this.orient || this.operator); orient = ((this.orient === "past" || this.operator === "subtract") ? -1 : 1); if (this.month && this.unit === "week") { this.value = this.month + 1; delete this.month; delete this.day; } if ((this.month || this.month === 0) && "year day hour minute second".indexOf(this.unit) !== -1) { if (!this.value) { this.value = this.month + 1; } this.month = null; expression = true; } if (!expression && this.weekday && !this.day && !this.days) { finishUtils.setDMYFromWeekday.call(this); } if (expression && this.weekday && this.unit !== "month" && this.unit !== "week") { finishUtils.setDaysFromWeekday.call(this, today, orient); } if (this.weekday && this.unit !== "week" && !this.day && !this.days) { temp = Date[this.weekday](); this.day = temp.getDate(); if (temp.getMonth() !== today.getMonth()) { this.month = temp.getMonth(); } } if (this.month && this.unit === "day" && this.operator) { if (!this.value) { this.value = (this.month + 1); } this.month = null; } if (this.value != null && this.month != null && this.year != null) { this.day = this.value * 1; } if (this.month && !this.day && this.value) { today.set({ day: this.value * 1 }); if (!expression) { this.day = this.value * 1; } } if (!this.month && this.value && this.unit === "month" && !this.now) { this.month = this.value; expression = true; } if (expression && (this.month || this.month === 0) && this.unit !== "year") { finishUtils.setMonthsFromMonth.call(this, today, orient); } if (!this.unit) { this.unit = "day"; } finishUtils.setUnitValue.call(this, orient); parseMeridian.call(this); if ((this.month || this.month === 0) && !this.day) { this.day = 1; } if (!this.orient && !this.operator && this.unit === "week" && this.value && !this.day && !this.month) { return Date.today().setWeek(this.value); } if (this.unit === "week" && this.weeks && !this.day && !this.month) { return finishUtils.generateDateFromWeeks.call(this); } if (expression && this.timezone && this.day && this.days) { this.day = this.days; } if (expression){ today.add(this); } else { today.set(this); } if (this.timezone) { this.timezone = this.timezone.toUpperCase(); var offset = $D.getTimezoneOffset(this.timezone); var timezone; if (today.hasDaylightSavingTime()) { // lets check that we're being sane with timezone setting timezone = $D.getTimezoneAbbreviation(offset, today.isDaylightSavingTime()); if (timezone !== this.timezone) { // bugger, we're in a place where things like EST vs EDT matters. if (today.isDaylightSavingTime()) { today.addHours(-1); } else { today.addHours(1); } } } today.setTimezoneOffset(offset); } return today; } }; }()); (function () { var $D = Date; $D.Grammar = {}; var _ = $D.Parsing.Operators, g = $D.Grammar, t = $D.Translator, _fn; // Allow rolling up into general purpose rules _fn = function () { return _.each(_.any.apply(null, arguments), _.not(g.ctoken2("timeContext"))); }; g.datePartDelimiter = _.rtoken(/^([\s\-\.\,\/\x27]+)/); g.timePartDelimiter = _.stoken(":"); g.whiteSpace = _.rtoken(/^\s*/); g.generalDelimiter = _.rtoken(/^(([\s\,]|at|@|on)+)/); var _C = {}; g.ctoken = function (keys) { var fn = _C[keys]; if (! fn) { var c = Date.CultureInfo.regexPatterns; var kx = keys.split(/\s+/), px = []; for (var i = 0; i < kx.length ; i++) { px.push(_.replace(_.rtoken(c[kx[i]]), kx[i])); } fn = _C[keys] = _.any.apply(null, px); } return fn; }; g.ctoken2 = function (key) { return _.rtoken(Date.CultureInfo.regexPatterns[key]); }; var cacheProcessRtoken = function (key, token, type, eachToken) { if (eachToken) { g[key] = _.cache(_.process(_.each(_.rtoken(token),_.optional(g.ctoken2(eachToken))), type)); } else { g[key] = _.cache(_.process(_.rtoken(token), type)); } }; var cacheProcessCtoken = function (token, type) { return _.cache(_.process(g.ctoken2(token), type)); }; var _F = {}; //function cache var _get = function (f) { _F[f] = (_F[f] || g.format(f)[0]); return _F[f]; }; g.allformats = function (fx) { var rx = []; if (fx instanceof Array) { for (var i = 0; i < fx.length; i++) { rx.push(_get(fx[i])); } } else { rx.push(_get(fx)); } return rx; }; g.formats = function (fx) { if (fx instanceof Array) { var rx = []; for (var i = 0 ; i < fx.length ; i++) { rx.push(_get(fx[i])); } return _.any.apply(null, rx); } else { return _get(fx); } }; var grammarFormats = { timeFormats: function(){ var i, RTokenKeys = [ "h", "hh", "H", "HH", "m", "mm", "s", "ss", "ss.s", "z", "zz" ], RToken = [ /^(0[0-9]|1[0-2]|[1-9])/, /^(0[0-9]|1[0-2])/, /^([0-1][0-9]|2[0-3]|[0-9])/, /^([0-1][0-9]|2[0-3])/, /^([0-5][0-9]|[0-9])/, /^[0-5][0-9]/, /^([0-5][0-9]|[0-9])/, /^[0-5][0-9]/, /^[0-5][0-9]\.[0-9]{1,3}/, /^((\+|\-)\s*\d\d\d\d)|((\+|\-)\d\d\:?\d\d)/, /^((\+|\-)\s*\d\d\d\d)|((\+|\-)\d\d\:?\d\d)/ ], tokens = [ t.hour, t.hour, t.hour, t.hour, t.minute, t.minute, t.second, t.second, t.secondAndMillisecond, t.timezone, t.timezone ]; for (i=0; i < RTokenKeys.length; i++) { cacheProcessRtoken(RTokenKeys[i], RToken[i], tokens[i]); } g.hms = _.cache(_.sequence([g.H, g.m, g.s], g.timePartDelimiter)); g.t = cacheProcessCtoken("shortMeridian", t.meridian); g.tt = cacheProcessCtoken("longMeridian", t.meridian); g.zzz = cacheProcessCtoken("timezone", t.timezone); g.timeSuffix = _.each(_.ignore(g.whiteSpace), _.set([ g.tt, g.zzz ])); g.time = _.each(_.optional(_.ignore(_.stoken("T"))), g.hms, g.timeSuffix); }, dateFormats: function () { // pre-loaded rules for different date part order preferences var _setfn = function () { return _.set(arguments, g.datePartDelimiter); }; var i, RTokenKeys = [ "d", "dd", "M", "MM", "y", "yy", "yyy", "yyyy" ], RToken = [ /^([0-2]\d|3[0-1]|\d)/, /^([0-2]\d|3[0-1])/, /^(1[0-2]|0\d|\d)/, /^(1[0-2]|0\d)/, /^(\d+)/, /^(\d\d)/, /^(\d\d?\d?\d?)/, /^(\d\d\d\d)/ ], tokens = [ t.day, t.day, t.month, t.month, t.year, t.year, t.year, t.year ], eachToken = [ "ordinalSuffix", "ordinalSuffix" ]; for (i=0; i < RTokenKeys.length; i++) { cacheProcessRtoken(RTokenKeys[i], RToken[i], tokens[i], eachToken[i]); } g.MMM = g.MMMM = _.cache(_.process(g.ctoken("jan feb mar apr may jun jul aug sep oct nov dec"), t.month)); g.ddd = g.dddd = _.cache(_.process(g.ctoken("sun mon tue wed thu fri sat"), function (s) { return function () { this.weekday = s; }; } )); g.day = _fn(g.d, g.dd); g.month = _fn(g.M, g.MMM); g.year = _fn(g.yyyy, g.yy); g.mdy = _setfn(g.ddd, g.month, g.day, g.year); g.ymd = _setfn(g.ddd, g.year, g.month, g.day); g.dmy = _setfn(g.ddd, g.day, g.month, g.year); g.date = function (s) { return ((g[Date.CultureInfo.dateElementOrder] || g.mdy).call(this, s)); }; }, relative: function () { // relative date / time expressions g.orientation = _.process(g.ctoken("past future"), function (s) { return function () { this.orient = s; }; } ); g.operator = _.process(g.ctoken("add subtract"), function (s) { return function () { this.operator = s; }; } ); g.rday = _.process(g.ctoken("yesterday tomorrow today now"), t.rday); g.unit = _.process(g.ctoken("second minute hour day week month year"), function (s) { return function () { this.unit = s; }; } ); } }; g.buildGrammarFormats = function () { // these need to be rebuilt every time the language changes. _C = {}; grammarFormats.timeFormats(); grammarFormats.dateFormats(); grammarFormats.relative(); g.value = _.process(_.rtoken(/^([-+]?\d+)?(st|nd|rd|th)?/), function (s) { return function () { this.value = s.replace(/\D/g, ""); }; } ); g.expression = _.set([g.rday, g.operator, g.value, g.unit, g.orientation, g.ddd, g.MMM ]); g.format = _.process(_.many( _.any( // translate format specifiers into grammar rules _.process( _.rtoken(/^(dd?d?d?(?!e)|MM?M?M?|yy?y?y?|hh?|HH?|mm?|ss?|tt?|zz?z?)/), function (fmt) { if (g[fmt]) { return g[fmt]; } else { throw $D.Parsing.Exception(fmt); } } ), // translate separator tokens into token rules _.process(_.rtoken(/^[^dMyhHmstz]+/), // all legal separators function (s) { return _.ignore(_.stoken(s)); } ) ) ), // construct the parser ... function (rules) { return _.process(_.each.apply(null, rules), t.finishExact); } ); // starting rule for general purpose grammar g._start = _.process(_.set([ g.date, g.time, g.expression ], g.generalDelimiter, g.whiteSpace), t.finish); }; g.buildGrammarFormats(); // parsing date format specifiers - ex: "h:m:s tt" // this little guy will generate a custom parser based // on the format string, ex: g.format("h:m:s tt") // check for these formats first g._formats = g.formats([ "\"yyyy-MM-ddTHH:mm:ssZ\"", "yyyy-MM-ddTHH:mm:ss.sz", "yyyy-MM-ddTHH:mm:ssZ", "yyyy-MM-ddTHH:mm:ssz", "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-ddTHH:mmZ", "yyyy-MM-ddTHH:mmz", "yyyy-MM-ddTHH:mm", "ddd, MMM dd, yyyy H:mm:ss tt", "ddd MMM d yyyy HH:mm:ss zzz", "MMddyyyy", "ddMMyyyy", "Mddyyyy", "ddMyyyy", "Mdyyyy", "dMyyyy", "yyyy", "Mdyy", "dMyy", "d" ]); // real starting rule: tries selected formats first, // then general purpose rule g.start = function (s) { try { var r = g._formats.call({}, s); if (r[1].length === 0) { return r; } } catch (e) {} return g._start.call({}, s); }; }()); (function () { var $D = Date; /** * @desc Converts the specified string value into its JavaScript Date equivalent using CultureInfo specific format information. * * Example

	///////////
	// Dates //
	///////////

	// 15-Oct-2004
	var d1 = Date.parse("10/15/2004");

	// 15-Oct-2004
	var d1 = Date.parse("15-Oct-2004");

	// 15-Oct-2004
	var d1 = Date.parse("2004.10.15");

	//Fri Oct 15, 2004
	var d1 = Date.parse("Fri Oct 15, 2004");

	///////////
	// Times //
	///////////

	// Today at 10 PM.
	var d1 = Date.parse("10 PM");

	// Today at 10:30 PM.
	var d1 = Date.parse("10:30 P.M.");

	// Today at 6 AM.
	var d1 = Date.parse("06am");

	/////////////////////
	// Dates and Times //
	/////////////////////

	// 8-July-2004 @ 10:30 PM
	var d1 = Date.parse("July 8th, 2004, 10:30 PM");

	// 1-July-2004 @ 10:30 PM
	var d1 = Date.parse("2004-07-01T22:30:00");

	////////////////////
	// Relative Dates //
	////////////////////

	// Returns today's date. The string "today" is culture specific.
	var d1 = Date.parse("today");

	// Returns yesterday's date. The string "yesterday" is culture specific.
	var d1 = Date.parse("yesterday");

	// Returns the date of the next thursday.
	var d1 = Date.parse("Next thursday");

	// Returns the date of the most previous monday.
	var d1 = Date.parse("last monday");

	// Returns today's day + one year.
	var d1 = Date.parse("next year");

	///////////////
	// Date Math //
	///////////////

	// Today + 2 days
	var d1 = Date.parse("t+2");

	// Today + 2 days
	var d1 = Date.parse("today + 2 days");

	// Today + 3 months
	var d1 = Date.parse("t+3m");

	// Today - 1 year
	var d1 = Date.parse("today - 1 year");

	// Today - 1 year
	var d1 = Date.parse("t-1y"); 


	/////////////////////////////
	// Partial Dates and Times //
	/////////////////////////////

	// July 15th of this year.
	var d1 = Date.parse("July 15");

	// 15th day of current day and year.
	var d1 = Date.parse("15");

	// July 1st of current year at 10pm.
	var d1 = Date.parse("7/1 10pm");
	
* * @param {String} The string value to convert into a Date object [Required] * @return {Date} A Date object or null if the string cannot be converted into a Date. */ var parseUtils = { removeOrds: function (s) { ords = s.match(/\b(\d+)(?:st|nd|rd|th)\b/); // find ordinal matches s = ((ords && ords.length === 2) ? s.replace(ords[0], ords[1]) : s); return s; }, grammarParser: function (s) { var r = null; try { r = $D.Grammar.start.call({}, s.replace(/^\s*(\S*(\s+\S+)*)\s*$/, "$1")); } catch (e) { return null; } return ((r[1].length === 0) ? r[0] : null); }, nativeFallback: function(s) { var t; try { // ok we haven't parsed it, last ditch attempt with the built-in parser. t = Date._parse(s); return (t || t === 0) ? new Date(t) : null; } catch (e) { return null; } } }; function parse (s) { var d; if (!s) { return null; } if (s instanceof Date) { return s.clone(); } if (s.length >= 4 && s.charAt(0) !== "0" && s.charAt(0) !== "+"&& s.charAt(0) !== "-") { // ie: 2004 will pass, 0800 won't. // Start with specific formats d = $D.Parsing.ISO.parse(s) || $D.Parsing.Numeric.parse(s); } if (d instanceof Date && !isNaN(d.getTime())) { return d; } else { // find ordinal dates (1st, 3rd, 8th, etc and remove them as they cause parsing issues) s = $D.Parsing.Normalizer.parse(parseUtils.removeOrds(s)); d = parseUtils.grammarParser(s); if (d !== null) { return d; } else { return parseUtils.nativeFallback(s); } } } if (!$D._parse) { $D._parse = $D.parse; } $D.parse = parse; Date.getParseFunction = function (fx) { var fns = Date.Grammar.allformats(fx); return function (s) { var r = null; for (var i = 0; i < fns.length; i++) { try { r = fns[i].call({}, s); } catch (e) { continue; } if (r[1].length === 0) { return r[0]; } } return null; }; }; /** * Converts the specified string value into its JavaScript Date equivalent using the specified format {String} or formats {Array} and the CultureInfo specific format information. * The format of the string value must match one of the supplied formats exactly. * * Example

	// 15-Oct-2004
	var d1 = Date.parseExact("10/15/2004", "M/d/yyyy");

	// 15-Oct-2004
	var d1 = Date.parse("15-Oct-2004", "M-ddd-yyyy");

	// 15-Oct-2004
	var d1 = Date.parse("2004.10.15", "yyyy.MM.dd");

	// Multiple formats
	var d1 = Date.parseExact("10/15/2004", ["M/d/yyyy", "MMMM d, yyyy"]);
	
* * @param {String} The string value to convert into a Date object [Required]. * @param {Object} The expected format {String} or an array of expected formats {Array} of the date string [Required]. * @return {Date} A Date object or null if the string cannot be converted into a Date. */ $D.parseExact = function (s, fx) { return $D.getParseFunction(fx)(s); }; }()); (function () { var $D = Date, $P = $D.prototype, // $C = $D.CultureInfo, // not used atm p = function (s, l) { if (!l) { l = 2; } return ("000" + s).slice(l * -1); }; /** * Converts a PHP format string to Java/.NET format string. * A PHP format string can be used with ._format or .format. * A Java/.NET format string can be used with .toString(). * The .parseExact function will only accept a Java/.NET format string * * Example * var f1 = "%m/%d/%y" * var f2 = Date.normalizeFormat(f1); // "MM/dd/yy" * * new Date().format(f1); // "04/13/08" * new Date()._format(f1); // "04/13/08" * new Date().toString(f2); // "04/13/08" * * var date = Date.parseExact("04/13/08", f2); // Sun Apr 13 2008 * * @param {String} A PHP format string consisting of one or more format spcifiers. * @return {String} The PHP format converted to a Java/.NET format string. */ var normalizerSubstitutions = { "d" : "dd", "%d": "dd", "D" : "ddd", "%a": "ddd", "j" : "dddd", "l" : "dddd", "%A": "dddd", "S" : "S", "F" : "MMMM", "%B": "MMMM", "m" : "MM", "%m": "MM", "M" : "MMM", "%b": "MMM", "%h": "MMM", "n" : "M", "Y" : "yyyy", "%Y": "yyyy", "y" : "yy", "%y": "yy", "g" : "h", "%I": "h", "G" : "H", "h" : "hh", "H" : "HH", "%H": "HH", "i" : "mm", "%M": "mm", "s" : "ss", "%S": "ss", "%r": "hh:mm tt", "%R": "H:mm", "%T": "H:mm:ss", "%X": "t", "%x": "d", "%e": "d", "%D": "MM/dd/yy", "%n": "\\n", "%t": "\\t", "e" : "z", "T" : "z", "%z": "z", "%Z": "z", "Z" : "ZZ", "N" : "u", "w" : "u", "%w": "u", "W" : "W", "%V": "W" }; var normalizer = { substitutes: function (m) { return normalizerSubstitutions[m]; }, interpreted: function (m, x) { var y; switch (m) { case "%u": return x.getDay() + 1; case "z": return x.getOrdinalNumber(); case "%j": return p(x.getOrdinalNumber(), 3); case "%U": var d1 = x.clone().set({month: 0, day: 1}).addDays(-1).moveToDayOfWeek(0), d2 = x.clone().addDays(1).moveToDayOfWeek(0, -1); return (d2 < d1) ? "00" : p((d2.getOrdinalNumber() - d1.getOrdinalNumber()) / 7 + 1); case "%W": return p(x.getWeek()); case "t": return $D.getDaysInMonth(x.getFullYear(), x.getMonth()); case "o": case "%G": return x.setWeek(x.getISOWeek()).toString("yyyy"); case "%g": return x._format("%G").slice(-2); case "a": case "%p": return t("tt").toLowerCase(); case "A": return t("tt").toUpperCase(); case "u": return p(x.getMilliseconds(), 3); case "I": return (x.isDaylightSavingTime()) ? 1 : 0; case "O": return x.getUTCOffset(); case "P": y = x.getUTCOffset(); return y.substring(0, y.length - 2) + ":" + y.substring(y.length - 2); case "B": var now = new Date(); return Math.floor(((now.getHours() * 3600) + (now.getMinutes() * 60) + now.getSeconds() + (now.getTimezoneOffset() + 60) * 60) / 86.4); case "c": return x.toISOString().replace(/\"/g, ""); case "U": return $D.strtotime("now"); case "%c": return t("d") + " " + t("t"); case "%C": return Math.floor(x.getFullYear() / 100 + 1); } }, shouldOverrideDefaults: function (m) { switch (m) { case "%e": return true; default: return false; } }, parse: function (m, context) { var formatString, c = context || new Date(); formatString = normalizer.substitutes(m); if (formatString) { return formatString; } formatString = normalizer.interpreted(m, c); if (formatString) { return formatString; } else { return m; } } }; $D.normalizeFormat = function (format, context) { return format.replace(/(%|\\)?.|%%/g, function(t){ return normalizer.parse(t, context); }); }; /** * Format a local Unix timestamp according to locale settings * * Example: * Date.strftime("%m/%d/%y", new Date()); // "04/13/08" * Date.strftime("c", "2008-04-13T17:52:03Z"); // "04/13/08" * * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @param {Number|String} The number representing the number of seconds that have elapsed since January 1, 1970 (local time). * @return {String} A string representation of the current Date object. */ $D.strftime = function (format, time) { var d = Date.parse(time); return d._format(format); }; /** * Parse any textual datetime description into a Unix timestamp. * A Unix timestamp is the number of seconds that have elapsed since January 1, 1970 (midnight UTC/GMT). * * Example: * Date.strtotime("04/13/08"); // 1208044800 * Date.strtotime("1970-01-01T00:00:00Z"); // 0 * * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @param {Object} A string or date object. * @return {String} A string representation of the current Date object. */ $D.strtotime = function (time) { var d = $D.parse(time); return Math.round($D.UTC(d.getUTCFullYear(), d.getUTCMonth(), d.getUTCDate(), d.getUTCHours(), d.getUTCMinutes(), d.getUTCSeconds(), d.getUTCMilliseconds()) / 1000); }; /** * Converts the value of the current Date object to its equivalent string representation using a PHP/Unix style of date format specifiers. * Format Specifiers * Format Description Example * ------ --------------------------------------------------------------------------- ----------------------- * %a abbreviated weekday name according to the current localed "Mon" through "Sun" * %A full weekday name according to the current localed "Sunday" through "Saturday" * %b abbreviated month name according to the current localed "Jan" through "Dec" * %B full month name according to the current locale "January" through "December" * %c preferred date and time representation for the current locale "4/13/2008 12:33 PM" * %C century number (the year divided by 100 and truncated to an integer) "00" to "99" * %d day of the month as a decimal number "01" to "31" * %D same as %m/%d/%y "04/13/08" * %e day of the month as a decimal number, a single digit is preceded by a space "1" to "31" * %g like %G, but without the century "08" * %G The 4-digit year corresponding to the ISO week number (see %V). "2008" * This has the same format and value as %Y, except that if the ISO week number * belongs to the previous or next year, that year is used instead. * %h same as %b "Jan" through "Dec" * %H hour as a decimal number using a 24-hour clock. "00" to "23" * %I hour as a decimal number using a 12-hour clock. "01" to "12" * %j day of the year as a decimal number. "001" to "366" * %m month as a decimal number. "01" to "12" * %M minute as a decimal number. "00" to "59" * %n newline character "\n" * %p either "am" or "pm" according to the given time value, or the "am" or "pm" * corresponding strings for the current locale. * %r time in a.m. and p.m. notation "8:44 PM" * %R time in 24 hour notation "20:44" * %S second as a decimal number "00" to "59" * %t tab character "\t" * %T current time, equal to %H:%M:%S "12:49:11" * %u weekday as a decimal number ["1", "7"], with "1" representing Monday "1" to "7" * %U week number of the current year as a decimal number, starting with the "0" to ("52" or "53") * first Sunday as the first day of the first week * %V The ISO 8601:1988 week number of the current year as a decimal number, "00" to ("52" or "53") * range 01 to 53, where week 1 is the first week that has at least 4 days * in the current year, and with Monday as the first day of the week. * (Use %G or %g for the year component that corresponds to the week number * for the specified timestamp.) * %W week number of the current year as a decimal number, starting with the "00" to ("52" or "53") * first Monday as the first day of the first week * %w day of the week as a decimal, Sunday being "0" "0" to "6" * %x preferred date representation for the current locale without the time "4/13/2008" * %X preferred time representation for the current locale without the date "12:53:05" * %y year as a decimal number without a century "00" "99" * %Y year as a decimal number including the century "2008" * %Z time zone or name or abbreviation "UTC", "EST", "PST" * %z same as %Z * %% a literal "%" characters "%" * d Day of the month, 2 digits with leading zeros "01" to "31" * D A textual representation of a day, three letters "Mon" through "Sun" * j Day of the month without leading zeros "1" to "31" * l A full textual representation of the day of the week (lowercase "L") "Sunday" through "Saturday" * N ISO-8601 numeric representation of the day of the week (added in PHP 5.1.0) "1" (for Monday) through "7" (for Sunday) * S English ordinal suffix for the day of the month, 2 characters "st", "nd", "rd" or "th". Works well with j * w Numeric representation of the day of the week "0" (for Sunday) through "6" (for Saturday) * z The day of the year (starting from "0") "0" through "365" * W ISO-8601 week number of year, weeks starting on Monday "00" to ("52" or "53") * F A full textual representation of a month, such as January or March "January" through "December" * m Numeric representation of a month, with leading zeros "01" through "12" * M A short textual representation of a month, three letters "Jan" through "Dec" * n Numeric representation of a month, without leading zeros "1" through "12" * t Number of days in the given month "28" through "31" * L Whether it's a leap year "1" if it is a leap year, "0" otherwise * o ISO-8601 year number. This has the same value as Y, except that if the "2008" * ISO week number (W) belongs to the previous or next year, that year * is used instead. * Y A full numeric representation of a year, 4 digits "2008" * y A two digit representation of a year "08" * a Lowercase Ante meridiem and Post meridiem "am" or "pm" * A Uppercase Ante meridiem and Post meridiem "AM" or "PM" * B Swatch Internet time "000" through "999" * g 12-hour format of an hour without leading zeros "1" through "12" * G 24-hour format of an hour without leading zeros "0" through "23" * h 12-hour format of an hour with leading zeros "01" through "12" * H 24-hour format of an hour with leading zeros "00" through "23" * i Minutes with leading zeros "00" to "59" * s Seconds, with leading zeros "00" through "59" * u Milliseconds "54321" * e Timezone identifier "UTC", "EST", "PST" * I Whether or not the date is in daylight saving time (uppercase i) "1" if Daylight Saving Time, "0" otherwise * O Difference to Greenwich time (GMT) in hours "+0200", "-0600" * P Difference to Greenwich time (GMT) with colon between hours and minutes "+02:00", "-06:00" * T Timezone abbreviation "UTC", "EST", "PST" * Z Timezone offset in seconds. The offset for timezones west of UTC is "-43200" through "50400" * always negative, and for those east of UTC is always positive. * c ISO 8601 date "2004-02-12T15:19:21+00:00" * r RFC 2822 formatted date "Thu, 21 Dec 2000 16:01:07 +0200" * U Seconds since the Unix Epoch (January 1 1970 00:00:00 GMT) "0" * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @return {String} A string representation of the current Date object. */ var formatReplace = function (context) { return function (m) { var formatString, override = false; if (m.charAt(0) === "\\" || m.substring(0, 2) === "%%") { return m.replace("\\", "").replace("%%", "%"); } override = normalizer.shouldOverrideDefaults(m); formatString = $D.normalizeFormat(m, context); if (formatString) { return context.toString(formatString, override); } }; }; $P._format = function (format) { var formatter = formatReplace(this); if (!format) { return this._toString(); } else { return format.replace(/(%|\\)?.|%%/g, formatter); } }; if (!$P.format) { $P.format = $P._format; } }()); (function () { "use strict"; var gFn = function (attr) { return function () { return this[attr]; }; }; var sFn = function (attr) { return function (val) { this[attr] = val; return this; }; }; var attrs = ["years", "months", "days", "hours", "minutes", "seconds", "milliseconds"]; var addSetFuncs = function (context, attrs) { for (var i = 0; i < attrs.length ; i++) { var $a = attrs[i], $b = $a.slice(0, 1).toUpperCase() + $a.slice(1); context.prototype[$a] = 0; context.prototype["get" + $b] = gFn($a); context.prototype["set" + $b] = sFn($a); } }; /** * new TimeSpan(milliseconds); * new TimeSpan(days, hours, minutes, seconds); * new TimeSpan(days, hours, minutes, seconds, milliseconds); */ var TimeSpan = function (days, hours, minutes, seconds, milliseconds) { if (arguments.length === 1 && typeof days === "number") { var orient = (days < 0) ? -1 : +1; var millsLeft = Math.abs(days); this.setDays(Math.floor(millsLeft / 86400000) * orient); millsLeft = millsLeft % 86400000; this.setHours(Math.floor(millsLeft / 3600000) * orient); millsLeft = millsLeft % 3600000; this.setMinutes(Math.floor(millsLeft / 60000) * orient); millsLeft = millsLeft % 60000; this.setSeconds(Math.floor(millsLeft / 1000) * orient); millsLeft = millsLeft % 1000; this.setMilliseconds(millsLeft * orient); } else { this.set(days, hours, minutes, seconds, milliseconds); } this.getTotalMilliseconds = function () { return (this.getDays() * 86400000) + (this.getHours() * 3600000) + (this.getMinutes() * 60000) + (this.getSeconds() * 1000); }; this.compareTo = function (time) { var t1 = new Date(1970, 1, 1, this.getHours(), this.getMinutes(), this.getSeconds()), t2; if (time === null) { t2 = new Date(1970, 1, 1, 0, 0, 0); } else { t2 = new Date(1970, 1, 1, time.getHours(), time.getMinutes(), time.getSeconds()); } return (t1 < t2) ? -1 : (t1 > t2) ? 1 : 0; }; this.equals = function (time) { return (this.compareTo(time) === 0); }; this.add = function (time) { return (time === null) ? this : this.addSeconds(time.getTotalMilliseconds() / 1000); }; this.subtract = function (time) { return (time === null) ? this : this.addSeconds(-time.getTotalMilliseconds() / 1000); }; this.addDays = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 86400000)); }; this.addHours = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 3600000)); }; this.addMinutes = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 60000)); }; this.addSeconds = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 1000)); }; this.addMilliseconds = function (n) { return new TimeSpan(this.getTotalMilliseconds() + n); }; this.get12HourHour = function () { return (this.getHours() > 12) ? this.getHours() - 12 : (this.getHours() === 0) ? 12 : this.getHours(); }; this.getDesignator = function () { return (this.getHours() < 12) ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator; }; this.toString = function (format) { this._toString = function () { if (this.getDays() !== null && this.getDays() > 0) { return this.getDays() + "." + this.getHours() + ":" + this.p(this.getMinutes()) + ":" + this.p(this.getSeconds()); } else { return this.getHours() + ":" + this.p(this.getMinutes()) + ":" + this.p(this.getSeconds()); } }; this.p = function (s) { return (s.toString().length < 2) ? "0" + s : s; }; var me = this; return format ? format.replace(/dd?|HH?|hh?|mm?|ss?|tt?/g, function (format) { switch (format) { case "d": return me.getDays(); case "dd": return me.p(me.getDays()); case "H": return me.getHours(); case "HH": return me.p(me.getHours()); case "h": return me.get12HourHour(); case "hh": return me.p(me.get12HourHour()); case "m": return me.getMinutes(); case "mm": return me.p(me.getMinutes()); case "s": return me.getSeconds(); case "ss": return me.p(me.getSeconds()); case "t": return ((me.getHours() < 12) ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator).substring(0, 1); case "tt": return (me.getHours() < 12) ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator; } } ) : this._toString(); }; return this; }; addSetFuncs(TimeSpan, attrs.slice(2)); TimeSpan.prototype.set = function (days, hours, minutes, seconds, milliseconds){ this.setDays(days || this.getDays()); this.setHours(hours || this.getHours()); this.setMinutes(minutes || this.getMinutes()); this.setSeconds(seconds || this.getSeconds()); this.setMilliseconds(milliseconds || this.getMilliseconds()); }; /** * Gets the time of day for this date instances. * @return {TimeSpan} TimeSpan */ Date.prototype.getTimeOfDay = function () { return new TimeSpan(0, this.getHours(), this.getMinutes(), this.getSeconds(), this.getMilliseconds()); }; Date.TimeSpan = TimeSpan; if (typeof window !== "undefined" ) { // keeping API compatible for v1.x window.TimeSpan = TimeSpan; } }()); (function () { "use strict"; var attrs = ["years", "months", "days", "hours", "minutes", "seconds", "milliseconds"]; var gFn = function (attr) { return function () { return this[attr]; }; }; var sFn = function (attr) { return function (val) { this[attr] = val; return this; }; }; var addSetFuncs = function (context, attrs) { for (var i = 0; i < attrs.length ; i++) { var $a = attrs[i], $b = $a.slice(0, 1).toUpperCase() + $a.slice(1); context.prototype[$a] = 0; context.prototype["get" + $b] = gFn($a); context.prototype["set" + $b] = sFn($a); } }; var setMonthsAndYears = function (orient, d1, d2, context) { function inc() { d1.addMonths(-orient); context.months++; if (context.months === 12) { context.years++; context.months = 0; } } if (orient === +1) { while (d1 > d2) { inc(); } } else { while (d1 < d2) { inc(); } } context.months--; context.months *= orient; context.years *= orient; }; var adjustForDST = function(orient, startDate, endDate) { var hasDSTMismatch = (false === (startDate.isDaylightSavingTime() === endDate.isDaylightSavingTime())); if (hasDSTMismatch && orient === 1) { startDate.addHours(-1); } else if (hasDSTMismatch) { startDate.addHours(1); } }; /** * TimePeriod(startDate, endDate); * TimePeriod(years, months, days, hours, minutes, seconds, milliseconds); */ var TimePeriod = function (years, months, days, hours, minutes, seconds, milliseconds) { if (arguments.length === 7) { this.set(years, months, days, hours, minutes, seconds, milliseconds); } else if (arguments.length === 2 && arguments[0] instanceof Date && arguments[1] instanceof Date) { var startDate = arguments[0].clone(); var endDate = arguments[1].clone(); var orient = (startDate > endDate) ? +1 : -1; this.dates = { start: arguments[0].clone(), end: arguments[1].clone() }; setMonthsAndYears(orient, startDate, endDate, this); adjustForDST(orient, startDate, endDate); // // TODO - adjust for DST var diff = endDate - startDate; if (diff !== 0) { var ts = new TimeSpan(diff); this.set(this.years, this.months, ts.getDays(), ts.getHours(), ts.getMinutes(), ts.getSeconds(), ts.getMilliseconds()); } } return this; }; // create all the set functions. addSetFuncs(TimePeriod, attrs); TimePeriod.prototype.set = function (years, months, days, hours, minutes, seconds, milliseconds){ this.setYears(years || this.getYears()); this.setMonths(months || this.getMonths()); this.setDays(days || this.getDays()); this.setHours(hours || this.getHours()); this.setMinutes(minutes || this.getMinutes()); this.setSeconds(seconds || this.getSeconds()); this.setMilliseconds(milliseconds || this.getMilliseconds()); }; Date.TimePeriod = TimePeriod; if (typeof window !== "undefined") { // keeping API compatible for v1.x window.TimePeriod = TimePeriod; } }()); ================================================ FILE: build/date-ur-PK.js ================================================ /** * @overview datejs * @version 1.0.0-rc3 * @author Gregory Wild-Smith * @copyright 2015 Gregory Wild-Smith * @license MIT * @homepage https://github.com/abritinthebay/datejs */ /* * DateJS Culture String File * Country Code: ur-PK * Name: Urdu (Islamic Republic of Pakistan) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["ur-PK"] = { "name": "ur-PK", "englishName": "Urdu (Islamic Republic of Pakistan)", "nativeName": "اُردو (پاکستان)", "Sunday": "اتوار", "Monday": "پير", "Tuesday": "منگل", "Wednesday": "بدھ", "Thursday": "جمعرات", "Friday": "جمعه", "Saturday": "هفته", "Sun": "اتوار", "Mon": "پير", "Tue": "منگل", "Wed": "بدھ", "Thu": "جمعرات", "Fri": "جمعه", "Sat": "هفته", "Su": "ا", "Mo": "پ", "Tu": "م", "We": "ب", "Th": "ج", "Fr": "ج", "Sa": "ه", "S_Sun_Initial": "ا", "M_Mon_Initial": "پ", "T_Tue_Initial": "م", "W_Wed_Initial": "ب", "T_Thu_Initial": "ج", "F_Fri_Initial": "ج", "S_Sat_Initial": "ه", "January": "جنورى", "February": "فرورى", "March": "مارچ", "April": "اپريل", "May": "مئ", "June": "جون", "July": "جولاٸ", "August": "اگست", "September": "ستمبر", "October": "اکتوبر", "November": "نومبر", "December": "دسمبر", "Jan_Abbr": "جنورى", "Feb_Abbr": "فرورى", "Mar_Abbr": "مارچ", "Apr_Abbr": "اپريل", "May_Abbr": "مئ", "Jun_Abbr": "جون", "Jul_Abbr": "جولاٸ", "Aug_Abbr": "اگست", "Sep_Abbr": "ستمبر", "Oct_Abbr": "اکتوبر", "Nov_Abbr": "نومبر", "Dec_Abbr": "دسمبر", "AM": "AM", "PM": "PM", "firstDayOfWeek": 1, "twoDigitYearMax": 2029, "mdy": "dmy", "M/d/yyyy": "dd/MM/yyyy", "dddd, MMMM dd, yyyy": "dd MMMM, yyyy", "h:mm tt": "h:mm tt", "h:mm:ss tt": "h:mm:ss tt", "dddd, MMMM dd, yyyy h:mm:ss tt": "dd MMMM, yyyy h:mm:ss tt", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "dd MMMM", "MMMM, yyyy": "MMMM, yyyy", "/jan(uary)?/": "جنورى", "/feb(ruary)?/": "فرورى", "/mar(ch)?/": "مارچ", "/apr(il)?/": "اپريل", "/may/": "مئ", "/jun(e)?/": "جون", "/jul(y)?/": "جولاٸ", "/aug(ust)?/": "اگست", "/sep(t(ember)?)?/": "ستمبر", "/oct(ober)?/": "اکتوبر", "/nov(ember)?/": "نومبر", "/dec(ember)?/": "دسمبر", "/^su(n(day)?)?/": "^ا(1)?", "/^mo(n(day)?)?/": "^پ(1)?", "/^tu(e(s(day)?)?)?/": "^م(1)?", "/^we(d(nesday)?)?/": "^ب(1)?", "/^th(u(r(s(day)?)?)?)?/": "^ج(1)?", "/^fr(i(day)?)?/": "^ج(1)?", "/^sa(t(urday)?)?/": "^ه(1)?", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "ur-PK"; /** * @overview datejs * @version 1.0.0-rc3 * @author Gregory Wild-Smith * @copyright 2015 Gregory Wild-Smith * @license MIT * @homepage https://github.com/abritinthebay/datejs */(function () { var $D = Date; var lang = Date.CultureStrings ? Date.CultureStrings.lang : null; var loggedKeys = {}; // for debug purposes. var getText = { getFromKey: function (key, countryCode) { var output; if (Date.CultureStrings && Date.CultureStrings[countryCode] && Date.CultureStrings[countryCode][key]) { output = Date.CultureStrings[countryCode][key]; } else { output = getText.buildFromDefault(key); } if (key.charAt(0) === "/") { // Assume it's a regex output = getText.buildFromRegex(key, countryCode); } return output; }, getFromObjectValues: function (obj, countryCode) { var key, output = {}; for(key in obj) { if (obj.hasOwnProperty(key)) { output[key] = getText.getFromKey(obj[key], countryCode); } } return output; }, getFromObjectKeys: function (obj, countryCode) { var key, output = {}; for(key in obj) { if (obj.hasOwnProperty(key)) { output[getText.getFromKey(key, countryCode)] = obj[key]; } } return output; }, getFromArray: function (arr, countryCode) { var output = []; for (var i=0; i < arr.length; i++){ if (i in arr) { output[i] = getText.getFromKey(arr[i], countryCode); } } return output; }, buildFromDefault: function (key) { var output, length, split, last; switch(key) { case "name": output = "en-US"; break; case "englishName": output = "English (United States)"; break; case "nativeName": output = "English (United States)"; break; case "twoDigitYearMax": output = 2049; break; case "firstDayOfWeek": output = 0; break; default: output = key; split = key.split("_"); length = split.length; if (length > 1 && key.charAt(0) !== "/") { // if the key isn't a regex and it has a split. last = split[(length - 1)].toLowerCase(); if (last === "initial" || last === "abbr") { output = split[0]; } } break; } return output; }, buildFromRegex: function (key, countryCode) { var output; if (Date.CultureStrings && Date.CultureStrings[countryCode] && Date.CultureStrings[countryCode][key]) { output = new RegExp(Date.CultureStrings[countryCode][key], "i"); } else { output = new RegExp(key.replace(new RegExp("/", "g"),""), "i"); } return output; } }; var shallowMerge = function (obj1, obj2) { for (var attrname in obj2) { if (obj2.hasOwnProperty(attrname)) { obj1[attrname] = obj2[attrname]; } } }; var __ = function (key, language) { var countryCode = (language) ? language : lang; loggedKeys[key] = key; if (typeof key === "object") { if (key instanceof Array) { return getText.getFromArray(key, countryCode); } else { return getText.getFromObjectKeys(key, countryCode); } } else { return getText.getFromKey(key, countryCode); } }; var loadI18nScript = function (code) { // paatterned after jQuery's getScript. var url = Date.Config.i18n + code + ".js"; var head = document.getElementsByTagName("head")[0] || document.documentElement; var script = document.createElement("script"); script.src = url; var completed = false; var events = { done: function (){} // placeholder function }; // Attach handlers for all browsers script.onload = script.onreadystatechange = function() { if ( !completed && (!this.readyState || this.readyState === "loaded" || this.readyState === "complete") ) { events.done(); head.removeChild(script); } }; setTimeout(function() { head.insertBefore(script, head.firstChild); }, 0); // allows return to execute first return { done: function (cb) { events.done = function() { if (cb) { setTimeout(cb,0); } }; } }; }; var buildInfo = { buildFromMethodHash: function (obj) { var key; for(key in obj) { if (obj.hasOwnProperty(key)) { obj[key] = buildInfo[obj[key]](); } } return obj; }, timeZoneDST: function () { var DST = { "CHADT": "+1345", "NZDT": "+1300", "AEDT": "+1100", "ACDT": "+1030", "AZST": "+0500", "IRDT": "+0430", "EEST": "+0300", "CEST": "+0200", "BST": "+0100", "PMDT": "-0200", "ADT": "-0300", "NDT": "-0230", "EDT": "-0400", "CDT": "-0500", "MDT": "-0600", "PDT": "-0700", "AKDT": "-0800", "HADT": "-0900" }; return __(DST); }, timeZoneStandard: function () { var standard = { "LINT": "+1400", "TOT": "+1300", "CHAST": "+1245", "NZST": "+1200", "NFT": "+1130", "SBT": "+1100", "AEST": "+1000", "ACST": "+0930", "JST": "+0900", "CWST": "+0845", "CT": "+0800", "ICT": "+0700", "MMT": "+0630", "BST": "+0600", "NPT": "+0545", "IST": "+0530", "PKT": "+0500", "AFT": "+0430", "MSK": "+0400", "IRST": "+0330", "FET": "+0300", "EET": "+0200", "CET": "+0100", "GMT": "+0000", "UTC": "+0000", "CVT": "-0100", "GST": "-0200", "BRT": "-0300", "NST": "-0330", "AST": "-0400", "EST": "-0500", "CST": "-0600", "MST": "-0700", "PST": "-0800", "AKST": "-0900", "MIT": "-0930", "HST": "-1000", "SST": "-1100", "BIT": "-1200" }; return __(standard); }, timeZones: function (data) { var zone; data.timezones = []; for (zone in data.abbreviatedTimeZoneStandard) { if (data.abbreviatedTimeZoneStandard.hasOwnProperty(zone)) { data.timezones.push({ name: zone, offset: data.abbreviatedTimeZoneStandard[zone]}); } } for (zone in data.abbreviatedTimeZoneDST) { if (data.abbreviatedTimeZoneDST.hasOwnProperty(zone)) { data.timezones.push({ name: zone, offset: data.abbreviatedTimeZoneDST[zone], dst: true}); } } return data.timezones; }, days: function () { return __(["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"]); }, dayAbbr: function () { return __(["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"]); }, dayShortNames: function () { return __(["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"]); }, dayFirstLetters: function () { return __(["S_Sun_Initial", "M_Mon_Initial", "T_Tues_Initial", "W_Wed_Initial", "T_Thu_Initial", "F_Fri_Initial", "S_Sat_Initial"]); }, months: function () { return __(["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"]); }, monthAbbr: function () { return __(["Jan_Abbr", "Feb_Abbr", "Mar_Abbr", "Apr_Abbr", "May_Abbr", "Jun_Abbr", "Jul_Abbr", "Aug_Abbr", "Sep_Abbr", "Oct_Abbr", "Nov_Abbr", "Dec_Abbr"]); }, formatPatterns: function () { return getText.getFromObjectValues({ shortDate: "M/d/yyyy", longDate: "dddd, MMMM dd, yyyy", shortTime: "h:mm tt", longTime: "h:mm:ss tt", fullDateTime: "dddd, MMMM dd, yyyy h:mm:ss tt", sortableDateTime: "yyyy-MM-ddTHH:mm:ss", universalSortableDateTime: "yyyy-MM-dd HH:mm:ssZ", rfc1123: "ddd, dd MMM yyyy HH:mm:ss", monthDay: "MMMM dd", yearMonth: "MMMM, yyyy" }, Date.i18n.currentLanguage()); }, regex: function () { return getText.getFromObjectValues({ inTheMorning: "/( in the )(morn(ing)?)\\b/", thisMorning: "/(this )(morn(ing)?)\\b/", amThisMorning: "/(\b\\d(am)? )(this )(morn(ing)?)/", inTheEvening: "/( in the )(even(ing)?)\\b/", thisEvening: "/(this )(even(ing)?)\\b/", pmThisEvening: "/(\b\\d(pm)? )(this )(even(ing)?)/", jan: "/jan(uary)?/", feb: "/feb(ruary)?/", mar: "/mar(ch)?/", apr: "/apr(il)?/", may: "/may/", jun: "/jun(e)?/", jul: "/jul(y)?/", aug: "/aug(ust)?/", sep: "/sep(t(ember)?)?/", oct: "/oct(ober)?/", nov: "/nov(ember)?/", dec: "/dec(ember)?/", sun: "/^su(n(day)?)?/", mon: "/^mo(n(day)?)?/", tue: "/^tu(e(s(day)?)?)?/", wed: "/^we(d(nesday)?)?/", thu: "/^th(u(r(s(day)?)?)?)?/", fri: "/fr(i(day)?)?/", sat: "/^sa(t(urday)?)?/", future: "/^next/", past: "/^last|past|prev(ious)?/", add: "/^(\\+|aft(er)?|from|hence)/", subtract: "/^(\\-|bef(ore)?|ago)/", yesterday: "/^yes(terday)?/", today: "/^t(od(ay)?)?/", tomorrow: "/^tom(orrow)?/", now: "/^n(ow)?/", millisecond: "/^ms|milli(second)?s?/", second: "/^sec(ond)?s?/", minute: "/^mn|min(ute)?s?/", hour: "/^h(our)?s?/", week: "/^w(eek)?s?/", month: "/^m(onth)?s?/", day: "/^d(ay)?s?/", year: "/^y(ear)?s?/", shortMeridian: "/^(a|p)/", longMeridian: "/^(a\\.?m?\\.?|p\\.?m?\\.?)/", timezone: "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/", ordinalSuffix: "/^\\s*(st|nd|rd|th)/", timeContext: "/^\\s*(\\:|a(?!u|p)|p)/" }, Date.i18n.currentLanguage()); } }; var CultureInfo = function () { var info = getText.getFromObjectValues({ name: "name", englishName: "englishName", nativeName: "nativeName", amDesignator: "AM", pmDesignator: "PM", firstDayOfWeek: "firstDayOfWeek", twoDigitYearMax: "twoDigitYearMax", dateElementOrder: "mdy" }, Date.i18n.currentLanguage()); var constructedInfo = buildInfo.buildFromMethodHash({ dayNames: "days", abbreviatedDayNames: "dayAbbr", shortestDayNames: "dayShortNames", firstLetterDayNames: "dayFirstLetters", monthNames: "months", abbreviatedMonthNames: "monthAbbr", formatPatterns: "formatPatterns", regexPatterns: "regex", abbreviatedTimeZoneDST: "timeZoneDST", abbreviatedTimeZoneStandard: "timeZoneStandard" }); shallowMerge(info, constructedInfo); buildInfo.timeZones(info); return info; }; $D.i18n = { __: function (key, lang) { return __(key, lang); }, currentLanguage: function () { return lang || "en-US"; }, setLanguage: function (code, force, cb) { var async = false; if (force || code === "en-US" || (!!Date.CultureStrings && !!Date.CultureStrings[code])) { lang = code; Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings.lang = code; Date.CultureInfo = new CultureInfo(); } else { if (!(!!Date.CultureStrings && !!Date.CultureStrings[code])) { if (typeof exports !== "undefined" && this.exports !== exports) { // we're in a Node enviroment, load it using require try { require("../i18n/" + code + ".js"); lang = code; Date.CultureStrings.lang = code; Date.CultureInfo = new CultureInfo(); } catch (e) { // var str = "The language for '" + code + "' could not be loaded by Node. It likely does not exist."; throw new Error("The DateJS IETF language tag '" + code + "' could not be loaded by Node. It likely does not exist."); } } else if (Date.Config && Date.Config.i18n) { // we know the location of the files, so lets load them async = true; loadI18nScript(code).done(function(){ lang = code; Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings.lang = code; Date.CultureInfo = new CultureInfo(); $D.Parsing.Normalizer.buildReplaceData(); // because this is async if ($D.Grammar) { $D.Grammar.buildGrammarFormats(); // so we can parse those strings... } if (cb) { setTimeout(cb,0); } }); } else { Date.console.error("The DateJS IETF language tag '" + code + "' is not available and has not been loaded."); return false; } } } $D.Parsing.Normalizer.buildReplaceData(); // rebuild normalizer strings if ($D.Grammar) { $D.Grammar.buildGrammarFormats(); // so we can parse those strings... } if (!async && cb) { setTimeout(cb,0); } }, getLoggedKeys: function () { return loggedKeys; }, updateCultureInfo: function () { Date.CultureInfo = new CultureInfo(); } }; $D.i18n.updateCultureInfo(); // run automatically }()); (function () { var $D = Date, $P = $D.prototype, p = function (s, l) { if (!l) { l = 2; } return ("000" + s).slice(l * -1); }; if (typeof window !== "undefined" && typeof window.console !== "undefined" && typeof window.console.log !== "undefined") { $D.console = console; // used only to raise non-critical errors if available } else { // set mock so we don't give errors. $D.console = { log: function(){}, error: function(){} }; } $D.Config = $D.Config || {}; $D.initOverloads = function() { /** * Overload of Date.now. Allows an alternate call for Date.now where it returns the * current Date as an object rather than just milliseconds since the Unix Epoch. * * Also provides an implementation of now() for browsers (IE<9) that don't have it. * * Backwards compatible so with work with either: * Date.now() [returns ms] * or * Date.now(true) [returns Date] */ if (!$D.now) { $D._now = function now() { return new Date().getTime(); }; } else if (!$D._now) { $D._now = $D.now; } $D.now = function (returnObj) { if (returnObj) { return $D.present(); } else { return $D._now(); } }; if ( !$P.toISOString ) { $P.toISOString = function() { return this.getUTCFullYear() + "-" + p(this.getUTCMonth() + 1) + "-" + p(this.getUTCDate()) + "T" + p(this.getUTCHours()) + ":" + p(this.getUTCMinutes()) + ":" + p(this.getUTCSeconds()) + "." + String( (this.getUTCMilliseconds()/1000).toFixed(3)).slice(2, 5) + "Z"; }; } // private if ( $P._toString === undefined ){ $P._toString = $P.toString; } }; $D.initOverloads(); /** * Gets a date that is set to the current date. The time is set to the start of the day (00:00 or 12:00 AM). * @return {Date} The current date. */ $D.today = function () { return new Date().clearTime(); }; /** * Gets a date that is set to the current date and time (same as new Date, but chainable) * @return {Date} The current date. */ $D.present = function () { return new Date(); }; /** * Compares the first date to the second date and returns an number indication of their relative values. * @param {Date} First Date object to compare [Required]. * @param {Date} Second Date object to compare to [Required]. * @return {Number} -1 = date1 is lessthan date2. 0 = values are equal. 1 = date1 is greaterthan date2. */ $D.compare = function (date1, date2) { if (isNaN(date1) || isNaN(date2)) { throw new Error(date1 + " - " + date2); } else if (date1 instanceof Date && date2 instanceof Date) { return (date1 < date2) ? -1 : (date1 > date2) ? 1 : 0; } else { throw new TypeError(date1 + " - " + date2); } }; /** * Compares the first Date object to the second Date object and returns true if they are equal. * @param {Date} First Date object to compare [Required] * @param {Date} Second Date object to compare to [Required] * @return {Boolean} true if dates are equal. false if they are not equal. */ $D.equals = function (date1, date2) { return (date1.compareTo(date2) === 0); }; /** * Gets the language appropriate day name when given the day number(0-6) * eg - 0 == Sunday * @return {String} The day name */ $D.getDayName = function (n) { return Date.CultureInfo.dayNames[n]; }; /** * Gets the day number (0-6) if given a CultureInfo specific string which is a valid dayName, abbreviatedDayName or shortestDayName (two char). * @param {String} The name of the day (eg. "Monday, "Mon", "tuesday", "tue", "We", "we"). * @return {Number} The day number */ $D.getDayNumberFromName = function (name) { var n = Date.CultureInfo.dayNames, m = Date.CultureInfo.abbreviatedDayNames, o = Date.CultureInfo.shortestDayNames, s = name.toLowerCase(); for (var i = 0; i < n.length; i++) { if (n[i].toLowerCase() === s || m[i].toLowerCase() === s || o[i].toLowerCase() === s) { return i; } } return -1; }; /** * Gets the month number (0-11) if given a Culture Info specific string which is a valid monthName or abbreviatedMonthName. * @param {String} The name of the month (eg. "February, "Feb", "october", "oct"). * @return {Number} The day number */ $D.getMonthNumberFromName = function (name) { var n = Date.CultureInfo.monthNames, m = Date.CultureInfo.abbreviatedMonthNames, s = name.toLowerCase(); for (var i = 0; i < n.length; i++) { if (n[i].toLowerCase() === s || m[i].toLowerCase() === s) { return i; } } return -1; }; /** * Gets the language appropriate month name when given the month number(0-11) * eg - 0 == January * @return {String} The month name */ $D.getMonthName = function (n) { return Date.CultureInfo.monthNames[n]; }; /** * Determines if the current date instance is within a LeapYear. * @param {Number} The year. * @return {Boolean} true if date is within a LeapYear, otherwise false. */ $D.isLeapYear = function (year) { return ((year % 4 === 0 && year % 100 !== 0) || year % 400 === 0); }; /** * Gets the number of days in the month, given a year and month value. Automatically corrects for LeapYear. * @param {Number} The year. * @param {Number} The month (0-11). * @return {Number} The number of days in the month. */ $D.getDaysInMonth = function (year, month) { if (!month && $D.validateMonth(year)) { month = year; year = Date.today().getFullYear(); } return [31, ($D.isLeapYear(year) ? 29 : 28), 31, 30, 31, 30, 31, 31, 30, 31, 30, 31][month]; }; $P.getDaysInMonth = function () { return $D.getDaysInMonth(this.getFullYear(), this.getMonth()); }; $D.getTimezoneAbbreviation = function (offset, dst) { var p, n = (dst || false) ? Date.CultureInfo.abbreviatedTimeZoneDST : Date.CultureInfo.abbreviatedTimeZoneStandard; for (p in n) { if (n.hasOwnProperty(p)) { if (n[p] === offset) { return p; } } } return null; }; $D.getTimezoneOffset = function (name, dst) { var i, a =[], z = Date.CultureInfo.timezones; if (!name) { name = (new Date()).getTimezone();} for (i = 0; i < z.length; i++) { if (z[i].name === name.toUpperCase()) { a.push(i); } } if (!z[a[0]]) { return null; } if (a.length === 1 || !dst) { return z[a[0]].offset; } else { for (i=0; i < a.length; i++) { if (z[a[i]].dst) { return z[a[i]].offset; } } } }; $D.getQuarter = function (d) { d = d || new Date(); // If no date supplied, use today var q = [1,2,3,4]; return q[Math.floor(d.getMonth() / 3)]; // ~~~ is a bitwise op. Faster than Math.floor }; $D.getDaysLeftInQuarter = function (d) { d = d || new Date(); var qEnd = new Date(d); qEnd.setMonth(qEnd.getMonth() + 3 - qEnd.getMonth() % 3, 0); return Math.floor((qEnd - d) / 8.64e7); }; // private var validate = function (n, min, max, name) { name = name ? name : "Object"; if (typeof n === "undefined") { return false; } else if (typeof n !== "number") { throw new TypeError(n + " is not a Number."); } else if (n < min || n > max) { // As failing validation is *not* an exceptional circumstance // lets not throw a RangeError Exception here. // It's semantically correct but it's not sensible. return false; } return true; }; /** * Validates the number is within an acceptable range for milliseconds [0-999]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateMillisecond = function (value) { return validate(value, 0, 999, "millisecond"); }; /** * Validates the number is within an acceptable range for seconds [0-59]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateSecond = function (value) { return validate(value, 0, 59, "second"); }; /** * Validates the number is within an acceptable range for minutes [0-59]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateMinute = function (value) { return validate(value, 0, 59, "minute"); }; /** * Validates the number is within an acceptable range for hours [0-23]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateHour = function (value) { return validate(value, 0, 23, "hour"); }; /** * Validates the number is within an acceptable range for the days in a month [0-MaxDaysInMonth]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateDay = function (value, year, month) { if (year === undefined || year === null || month === undefined || month === null) { return false;} return validate(value, 1, $D.getDaysInMonth(year, month), "day"); }; /** * Validates the number is within an acceptable range for months [0-11]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateWeek = function (value) { return validate(value, 0, 53, "week"); }; /** * Validates the number is within an acceptable range for months [0-11]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateMonth = function (value) { return validate(value, 0, 11, "month"); }; /** * Validates the number is within an acceptable range for years. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateYear = function (value) { /** * Per ECMAScript spec the range of times supported by Date objects is * exactly -100,000,000 days to +100,000,000 days measured relative to * midnight at the beginning of 01 January, 1970 UTC. * This gives a range of 8,640,000,000,000,000 milliseconds to either * side of 01 January, 1970 UTC. * * Earliest possible date: Tue, 20 Apr 271,822 B.C. 00:00:00 UTC * Latest possible date: Sat, 13 Sep 275,760 00:00:00 UTC */ return validate(value, -271822, 275760, "year"); }; $D.validateTimezone = function(value) { var timezones = {"ACDT":1,"ACST":1,"ACT":1,"ADT":1,"AEDT":1,"AEST":1,"AFT":1,"AKDT":1,"AKST":1,"AMST":1,"AMT":1,"ART":1,"AST":1,"AWDT":1,"AWST":1,"AZOST":1,"AZT":1,"BDT":1,"BIOT":1,"BIT":1,"BOT":1,"BRT":1,"BST":1,"BTT":1,"CAT":1,"CCT":1,"CDT":1,"CEDT":1,"CEST":1,"CET":1,"CHADT":1,"CHAST":1,"CHOT":1,"ChST":1,"CHUT":1,"CIST":1,"CIT":1,"CKT":1,"CLST":1,"CLT":1,"COST":1,"COT":1,"CST":1,"CT":1,"CVT":1,"CWST":1,"CXT":1,"DAVT":1,"DDUT":1,"DFT":1,"EASST":1,"EAST":1,"EAT":1,"ECT":1,"EDT":1,"EEDT":1,"EEST":1,"EET":1,"EGST":1,"EGT":1,"EIT":1,"EST":1,"FET":1,"FJT":1,"FKST":1,"FKT":1,"FNT":1,"GALT":1,"GAMT":1,"GET":1,"GFT":1,"GILT":1,"GIT":1,"GMT":1,"GST":1,"GYT":1,"HADT":1,"HAEC":1,"HAST":1,"HKT":1,"HMT":1,"HOVT":1,"HST":1,"ICT":1,"IDT":1,"IOT":1,"IRDT":1,"IRKT":1,"IRST":1,"IST":1,"JST":1,"KGT":1,"KOST":1,"KRAT":1,"KST":1,"LHST":1,"LINT":1,"MAGT":1,"MART":1,"MAWT":1,"MDT":1,"MET":1,"MEST":1,"MHT":1,"MIST":1,"MIT":1,"MMT":1,"MSK":1,"MST":1,"MUT":1,"MVT":1,"MYT":1,"NCT":1,"NDT":1,"NFT":1,"NPT":1,"NST":1,"NT":1,"NUT":1,"NZDT":1,"NZST":1,"OMST":1,"ORAT":1,"PDT":1,"PET":1,"PETT":1,"PGT":1,"PHOT":1,"PHT":1,"PKT":1,"PMDT":1,"PMST":1,"PONT":1,"PST":1,"PYST":1,"PYT":1,"RET":1,"ROTT":1,"SAKT":1,"SAMT":1,"SAST":1,"SBT":1,"SCT":1,"SGT":1,"SLST":1,"SRT":1,"SST":1,"SYOT":1,"TAHT":1,"THA":1,"TFT":1,"TJT":1,"TKT":1,"TLT":1,"TMT":1,"TOT":1,"TVT":1,"UCT":1,"ULAT":1,"UTC":1,"UYST":1,"UYT":1,"UZT":1,"VET":1,"VLAT":1,"VOLT":1,"VOST":1,"VUT":1,"WAKT":1,"WAST":1,"WAT":1,"WEDT":1,"WEST":1,"WET":1,"WST":1,"YAKT":1,"YEKT":1,"Z":1}; return (timezones[value] === 1); }; $D.validateTimezoneOffset= function(value) { // timezones go from +14hrs to -12hrs, the +X hours are negative offsets. return (value > -841 && value < 721); }; }()); (function () { var $D = Date, $P = $D.prototype, p = function (s, l) { if (!l) { l = 2; } return ("000" + s).slice(l * -1); }; var validateConfigObject = function (obj) { var result = {}, self = this, prop, testFunc; testFunc = function (prop, func, value) { if (prop === "day") { var month = (obj.month !== undefined) ? obj.month : self.getMonth(); var year = (obj.year !== undefined) ? obj.year : self.getFullYear(); return $D[func](value, year, month); } else { return $D[func](value); } }; for (prop in obj) { if (Object.prototype.hasOwnProperty.call(obj, prop)) { var func = "validate" + prop.charAt(0).toUpperCase() + prop.slice(1); if ($D[func] && obj[prop] !== null && testFunc(prop, func, obj[prop])) { result[prop] = obj[prop]; } } } return result; }; /** * Resets the time of this Date object to 12:00 AM (00:00), which is the start of the day. * @param {Boolean} .clone() this date instance before clearing Time * @return {Date} this */ $P.clearTime = function () { this.setHours(0); this.setMinutes(0); this.setSeconds(0); this.setMilliseconds(0); return this; }; /** * Resets the time of this Date object to the current time ('now'). * @return {Date} this */ $P.setTimeToNow = function () { var n = new Date(); this.setHours(n.getHours()); this.setMinutes(n.getMinutes()); this.setSeconds(n.getSeconds()); this.setMilliseconds(n.getMilliseconds()); return this; }; /** * Returns a new Date object that is an exact date and time copy of the original instance. * @return {Date} A new Date instance */ $P.clone = function () { return new Date(this.getTime()); }; /** * Compares this instance to a Date object and returns an number indication of their relative values. * @param {Date} Date object to compare [Required] * @return {Number} -1 = this is lessthan date. 0 = values are equal. 1 = this is greaterthan date. */ $P.compareTo = function (date) { return Date.compare(this, date); }; /** * Compares this instance to another Date object and returns true if they are equal. * @param {Date} Date object to compare. If no date to compare, new Date() [now] is used. * @return {Boolean} true if dates are equal. false if they are not equal. */ $P.equals = function (date) { return Date.equals(this, (date !== undefined ? date : new Date())); }; /** * Determines if this instance is between a range of two dates or equal to either the start or end dates. * @param {Date} Start of range [Required] * @param {Date} End of range [Required] * @return {Boolean} true is this is between or equal to the start and end dates, else false */ $P.between = function (start, end) { return this.getTime() >= start.getTime() && this.getTime() <= end.getTime(); }; /** * Determines if this date occurs after the date to compare to. * @param {Date} Date object to compare. If no date to compare, new Date() ("now") is used. * @return {Boolean} true if this date instance is greater than the date to compare to (or "now"), otherwise false. */ $P.isAfter = function (date) { return this.compareTo(date || new Date()) === 1; }; /** * Determines if this date occurs before the date to compare to. * @param {Date} Date object to compare. If no date to compare, new Date() ("now") is used. * @return {Boolean} true if this date instance is less than the date to compare to (or "now"). */ $P.isBefore = function (date) { return (this.compareTo(date || new Date()) === -1); }; /** * Determines if the current Date instance occurs today. * @return {Boolean} true if this date instance is 'today', otherwise false. */ /** * Determines if the current Date instance occurs on the same Date as the supplied 'date'. * If no 'date' to compare to is provided, the current Date instance is compared to 'today'. * @param {date} Date object to compare. If no date to compare, the current Date ("now") is used. * @return {Boolean} true if this Date instance occurs on the same Day as the supplied 'date'. */ $P.isToday = $P.isSameDay = function (date) { return this.clone().clearTime().equals((date || new Date()).clone().clearTime()); }; /** * Adds the specified number of milliseconds to this instance. * @param {Number} The number of milliseconds to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addMilliseconds = function (value) { if (!value) { return this; } this.setTime(this.getTime() + value * 1); return this; }; /** * Adds the specified number of seconds to this instance. * @param {Number} The number of seconds to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addSeconds = function (value) { if (!value) { return this; } return this.addMilliseconds(value * 1000); }; /** * Adds the specified number of seconds to this instance. * @param {Number} The number of seconds to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addMinutes = function (value) { if (!value) { return this; } return this.addMilliseconds(value * 60000); // 60*1000 }; /** * Adds the specified number of hours to this instance. * @param {Number} The number of hours to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addHours = function (value) { if (!value) { return this; } return this.addMilliseconds(value * 3600000); // 60*60*1000 }; /** * Adds the specified number of days to this instance. * @param {Number} The number of days to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addDays = function (value) { if (!value) { return this; } this.setDate(this.getDate() + value * 1); return this; }; /** * Adds the specified number of weekdays (ie - not sat or sun) to this instance. * @param {Number} The number of days to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addWeekdays = function (value) { if (!value) { return this; } var day = this.getDay(); var weeks = (Math.ceil(Math.abs(value)/7)); if (day === 0 || day === 6) { if (value > 0) { this.next().monday(); this.addDays(-1); day = this.getDay(); } } if (value < 0) { while (value < 0) { this.addDays(-1); day = this.getDay(); if (day !== 0 && day !== 6) { value++; } } return this; } else if (value > 5 || (6-day) <= value) { value = value + (weeks * 2); } return this.addDays(value); }; /** * Adds the specified number of weeks to this instance. * @param {Number} The number of weeks to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addWeeks = function (value) { if (!value) { return this; } return this.addDays(value * 7); }; /** * Adds the specified number of months to this instance. * @param {Number} The number of months to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addMonths = function (value) { if (!value) { return this; } var n = this.getDate(); this.setDate(1); this.setMonth(this.getMonth() + value * 1); this.setDate(Math.min(n, $D.getDaysInMonth(this.getFullYear(), this.getMonth()))); return this; }; $P.addQuarters = function (value) { if (!value) { return this; } // note this will take you to the same point in the quarter as you are now. // i.e. - if you are 15 days into the quarter you'll be 15 days into the resulting one. // bonus: this allows adding fractional quarters return this.addMonths(value * 3); }; /** * Adds the specified number of years to this instance. * @param {Number} The number of years to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addYears = function (value) { if (!value) { return this; } return this.addMonths(value * 12); }; /** * Adds (or subtracts) to the value of the years, months, weeks, days, hours, minutes, seconds, milliseconds of the date instance using given configuration object. Positive and Negative values allowed. * Example

	Date.today().add( { days: 1, months: 1 } )

	new Date().add( { years: -1 } )
	
* @param {Object} Configuration object containing attributes (months, days, etc.) * @return {Date} this */ $P.add = function (config) { if (typeof config === "number") { this._orient = config; return this; } var x = config; if (x.day) { // If we should be a different date than today (eg: for 'tomorrow -1d', etc). // Should only effect parsing, not direct usage (eg, Finish and FinishExact) if ((x.day - this.getDate()) !== 0) { this.setDate(x.day); } } if (x.milliseconds) { this.addMilliseconds(x.milliseconds); } if (x.seconds) { this.addSeconds(x.seconds); } if (x.minutes) { this.addMinutes(x.minutes); } if (x.hours) { this.addHours(x.hours); } if (x.weeks) { this.addWeeks(x.weeks); } if (x.months) { this.addMonths(x.months); } if (x.years) { this.addYears(x.years); } if (x.days) { this.addDays(x.days); } return this; }; /** * Get the week number. Week one (1) is the week which contains the first Thursday of the year. Monday is considered the first day of the week. * The .getWeek() function does NOT convert the date to UTC. The local datetime is used. * Please use .getISOWeek() to get the week of the UTC converted date. * @return {Number} 1 to 53 */ $P.getWeek = function (utc) { // Create a copy of this date object var self, target = new Date(this.valueOf()); if (utc) { target.addMinutes(target.getTimezoneOffset()); self = target.clone(); } else { self = this; } // ISO week date weeks start on monday // so correct the day number var dayNr = (self.getDay() + 6) % 7; // ISO 8601 states that week 1 is the week // with the first thursday of that year. // Set the target date to the thursday in the target week target.setDate(target.getDate() - dayNr + 3); // Store the millisecond value of the target date var firstThursday = target.valueOf(); // Set the target to the first thursday of the year // First set the target to january first target.setMonth(0, 1); // Not a thursday? Correct the date to the next thursday if (target.getDay() !== 4) { target.setMonth(0, 1 + ((4 - target.getDay()) + 7) % 7); } // The weeknumber is the number of weeks between the // first thursday of the year and the thursday in the target week return 1 + Math.ceil((firstThursday - target) / 604800000); // 604800000 = 7 * 24 * 3600 * 1000 }; /** * Get the ISO 8601 week number. Week one ("01") is the week which contains the first Thursday of the year. Monday is considered the first day of the week. * The .getISOWeek() function does convert the date to it's UTC value. Please use .getWeek() to get the week of the local date. * @return {String} "01" to "53" */ $P.getISOWeek = function () { return p(this.getWeek(true)); }; /** * Moves the date to Monday of the week set. Week one (1) is the week which contains the first Thursday of the year. * @param {Number} A Number (1 to 53) that represents the week of the year. * @return {Date} this */ $P.setWeek = function (n) { if ((n - this.getWeek()) === 0) { if (this.getDay() !== 1) { return this.moveToDayOfWeek(1, (this.getDay() > 1 ? -1 : 1)); } else { return this; } } else { return this.moveToDayOfWeek(1, (this.getDay() > 1 ? -1 : 1)).addWeeks(n - this.getWeek()); } }; $P.setQuarter = function (qtr) { var month = Math.abs(((qtr-1) * 3) + 1); return this.setMonth(month, 1); }; $P.getQuarter = function () { return Date.getQuarter(this); }; $P.getDaysLeftInQuarter = function () { return Date.getDaysLeftInQuarter(this); }; /** * Moves the date to the next n'th occurrence of the dayOfWeek starting from the beginning of the month. The number (-1) is a magic number and will return the last occurrence of the dayOfWeek in the month. * @param {Number} The dayOfWeek to move to * @param {Number} The n'th occurrence to move to. Use (-1) to return the last occurrence in the month * @return {Date} this */ $P.moveToNthOccurrence = function (dayOfWeek, occurrence) { if (dayOfWeek === "Weekday") { if (occurrence > 0) { this.moveToFirstDayOfMonth(); if (this.is().weekday()) { occurrence -= 1; } } else if (occurrence < 0) { this.moveToLastDayOfMonth(); if (this.is().weekday()) { occurrence += 1; } } else { return this; } return this.addWeekdays(occurrence); } var shift = 0; if (occurrence > 0) { shift = occurrence - 1; } else if (occurrence === -1) { this.moveToLastDayOfMonth(); if (this.getDay() !== dayOfWeek) { this.moveToDayOfWeek(dayOfWeek, -1); } return this; } return this.moveToFirstDayOfMonth().addDays(-1).moveToDayOfWeek(dayOfWeek, +1).addWeeks(shift); }; var moveToN = function (getFunc, addFunc, nVal) { return function (value, orient) { var diff = (value - this[getFunc]() + nVal * (orient || +1)) % nVal; return this[addFunc]((diff === 0) ? diff += nVal * (orient || +1) : diff); }; }; /** * Move to the next or last dayOfWeek based on the orient value. * @param {Number} The dayOfWeek to move to * @param {Number} Forward (+1) or Back (-1). Defaults to +1. [Optional] * @return {Date} this */ $P.moveToDayOfWeek = moveToN("getDay", "addDays", 7); /** * Move to the next or last month based on the orient value. * @param {Number} The month to move to. 0 = January, 11 = December * @param {Number} Forward (+1) or Back (-1). Defaults to +1. [Optional] * @return {Date} this */ $P.moveToMonth = moveToN("getMonth", "addMonths", 12); /** * Get the Ordinate of the current day ("th", "st", "rd"). * @return {String} */ $P.getOrdinate = function () { var num = this.getDate(); return ord(num); }; /** * Get the Ordinal day (numeric day number) of the year, adjusted for leap year. * @return {Number} 1 through 365 (366 in leap years) */ $P.getOrdinalNumber = function () { return Math.ceil((this.clone().clearTime() - new Date(this.getFullYear(), 0, 1)) / 86400000) + 1; }; /** * Get the time zone abbreviation of the current date. * @return {String} The abbreviated time zone name (e.g. "EST") */ $P.getTimezone = function () { return $D.getTimezoneAbbreviation(this.getUTCOffset(), this.isDaylightSavingTime()); }; $P.setTimezoneOffset = function (offset) { var here = this.getTimezoneOffset(), there = Number(offset) * -6 / 10; return (there || there === 0) ? this.addMinutes(there - here) : this; }; $P.setTimezone = function (offset) { return this.setTimezoneOffset($D.getTimezoneOffset(offset)); }; /** * Indicates whether Daylight Saving Time is observed in the current time zone. * @return {Boolean} true|false */ $P.hasDaylightSavingTime = function () { return (Date.today().set({month: 0, day: 1}).getTimezoneOffset() !== Date.today().set({month: 6, day: 1}).getTimezoneOffset()); }; /** * Indicates whether this Date instance is within the Daylight Saving Time range for the current time zone. * @return {Boolean} true|false */ $P.isDaylightSavingTime = function () { return Date.today().set({month: 0, day: 1}).getTimezoneOffset() !== this.getTimezoneOffset(); }; /** * Get the offset from UTC of the current date. * @return {String} The 4-character offset string prefixed with + or - (e.g. "-0500") */ $P.getUTCOffset = function (offset) { var n = (offset || this.getTimezoneOffset()) * -10 / 6, r; if (n < 0) { r = (n - 10000).toString(); return r.charAt(0) + r.substr(2); } else { r = (n + 10000).toString(); return "+" + r.substr(1); } }; /** * Returns the number of milliseconds between this date and date. * @param {Date} Defaults to now * @return {Number} The diff in milliseconds */ $P.getElapsed = function (date) { return (date || new Date()) - this; }; /** * Set the value of year, month, day, hour, minute, second, millisecond of date instance using given configuration object. * Example

	Date.today().set( { day: 20, month: 1 } )

	new Date().set( { millisecond: 0 } )
	
* * @param {Object} Configuration object containing attributes (month, day, etc.) * @return {Date} this */ $P.set = function (config) { config = validateConfigObject.call(this, config); var key; for (key in config) { if (Object.prototype.hasOwnProperty.call(config, key)) { var name = key.charAt(0).toUpperCase() + key.slice(1); var addFunc, getFunc; if (key !== "week" && key !== "month" && key !== "timezone" && key !== "timezoneOffset") { name += "s"; } addFunc = "add" + name; getFunc = "get" + name; if (key === "month") { addFunc = addFunc + "s"; } else if (key === "year"){ getFunc = "getFullYear"; } if (key !== "day" && key !== "timezone" && key !== "timezoneOffset" && key !== "week" && key !== "hour") { this[addFunc](config[key] - this[getFunc]()); } else if ( key === "timezone"|| key === "timezoneOffset" || key === "week" || key === "hour") { this["set"+name](config[key]); } } } // day has to go last because you can't validate the day without first knowing the month if (config.day) { this.addDays(config.day - this.getDate()); } return this; }; /** * Moves the date to the first day of the month. * @return {Date} this */ $P.moveToFirstDayOfMonth = function () { return this.set({ day: 1 }); }; /** * Moves the date to the last day of the month. * @return {Date} this */ $P.moveToLastDayOfMonth = function () { return this.set({ day: $D.getDaysInMonth(this.getFullYear(), this.getMonth())}); }; /** * Converts the value of the current Date object to its equivalent string representation. * Format Specifiers * CUSTOM DATE AND TIME FORMAT STRINGS * Format Description Example * ------ --------------------------------------------------------------------------- ----------------------- * s The seconds of the minute between 0-59. "0" to "59" * ss The seconds of the minute with leading zero if required. "00" to "59" * * m The minute of the hour between 0-59. "0" or "59" * mm The minute of the hour with leading zero if required. "00" or "59" * * h The hour of the day between 1-12. "1" to "12" * hh The hour of the day with leading zero if required. "01" to "12" * * H The hour of the day between 0-23. "0" to "23" * HH The hour of the day with leading zero if required. "00" to "23" * * d The day of the month between 1 and 31. "1" to "31" * dd The day of the month with leading zero if required. "01" to "31" * ddd Abbreviated day name. Date.CultureInfo.abbreviatedDayNames. "Mon" to "Sun" * dddd The full day name. Date.CultureInfo.dayNames. "Monday" to "Sunday" * * M The month of the year between 1-12. "1" to "12" * MM The month of the year with leading zero if required. "01" to "12" * MMM Abbreviated month name. Date.CultureInfo.abbreviatedMonthNames. "Jan" to "Dec" * MMMM The full month name. Date.CultureInfo.monthNames. "January" to "December" * * yy The year as a two-digit number. "99" or "08" * yyyy The full four digit year. "1999" or "2008" * * t Displays the first character of the A.M./P.M. designator. "A" or "P" * Date.CultureInfo.amDesignator or Date.CultureInfo.pmDesignator * tt Displays the A.M./P.M. designator. "AM" or "PM" * Date.CultureInfo.amDesignator or Date.CultureInfo.pmDesignator * * S The ordinal suffix ("st, "nd", "rd" or "th") of the current day. "st, "nd", "rd" or "th" * * STANDARD DATE AND TIME FORMAT STRINGS * Format Description Example *------ --------------------------------------------------------------------------- ----------------------- * d The CultureInfo shortDate Format Pattern "M/d/yyyy" * D The CultureInfo longDate Format Pattern "dddd, MMMM dd, yyyy" * F The CultureInfo fullDateTime Format Pattern "dddd, MMMM dd, yyyy h:mm:ss tt" * m The CultureInfo monthDay Format Pattern "MMMM dd" * r The CultureInfo rfc1123 Format Pattern "ddd, dd MMM yyyy HH:mm:ss GMT" * s The CultureInfo sortableDateTime Format Pattern "yyyy-MM-ddTHH:mm:ss" * t The CultureInfo shortTime Format Pattern "h:mm tt" * T The CultureInfo longTime Format Pattern "h:mm:ss tt" * u The CultureInfo universalSortableDateTime Format Pattern "yyyy-MM-dd HH:mm:ssZ" * y The CultureInfo yearMonth Format Pattern "MMMM, yyyy" * * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @return {String} A string representation of the current Date object. */ var ord = function (n) { switch (n * 1) { case 1: case 21: case 31: return "st"; case 2: case 22: return "nd"; case 3: case 23: return "rd"; default: return "th"; } }; var parseStandardFormats = function (format) { var y, c = Date.CultureInfo.formatPatterns; switch (format) { case "d": return this.toString(c.shortDate); case "D": return this.toString(c.longDate); case "F": return this.toString(c.fullDateTime); case "m": return this.toString(c.monthDay); case "r": case "R": y = this.clone().addMinutes(this.getTimezoneOffset()); return y.toString(c.rfc1123) + " GMT"; case "s": return this.toString(c.sortableDateTime); case "t": return this.toString(c.shortTime); case "T": return this.toString(c.longTime); case "u": y = this.clone().addMinutes(this.getTimezoneOffset()); return y.toString(c.universalSortableDateTime); case "y": return this.toString(c.yearMonth); default: return false; } }; var parseFormatStringsClosure = function (context) { return function (m) { if (m.charAt(0) === "\\") { return m.replace("\\", ""); } switch (m) { case "hh": return p(context.getHours() < 13 ? (context.getHours() === 0 ? 12 : context.getHours()) : (context.getHours() - 12)); case "h": return context.getHours() < 13 ? (context.getHours() === 0 ? 12 : context.getHours()) : (context.getHours() - 12); case "HH": return p(context.getHours()); case "H": return context.getHours(); case "mm": return p(context.getMinutes()); case "m": return context.getMinutes(); case "ss": return p(context.getSeconds()); case "s": return context.getSeconds(); case "yyyy": return p(context.getFullYear(), 4); case "yy": return p(context.getFullYear()); case "y": return context.getFullYear(); case "E": case "dddd": return Date.CultureInfo.dayNames[context.getDay()]; case "ddd": return Date.CultureInfo.abbreviatedDayNames[context.getDay()]; case "dd": return p(context.getDate()); case "d": return context.getDate(); case "MMMM": return Date.CultureInfo.monthNames[context.getMonth()]; case "MMM": return Date.CultureInfo.abbreviatedMonthNames[context.getMonth()]; case "MM": return p((context.getMonth() + 1)); case "M": return context.getMonth() + 1; case "t": return context.getHours() < 12 ? Date.CultureInfo.amDesignator.substring(0, 1) : Date.CultureInfo.pmDesignator.substring(0, 1); case "tt": return context.getHours() < 12 ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator; case "S": return ord(context.getDate()); case "W": return context.getWeek(); case "WW": return context.getISOWeek(); case "Q": return "Q" + context.getQuarter(); case "q": return String(context.getQuarter()); case "z": return context.getTimezone(); case "Z": case "X": return Date.getTimezoneOffset(context.getTimezone()); case "ZZ": // Timezone offset in seconds return context.getTimezoneOffset() * -60; case "u": return context.getDay(); case "L": return ($D.isLeapYear(context.getFullYear())) ? 1 : 0; case "B": // Swatch Internet Time (.beats) return "@"+((context.getUTCSeconds() + (context.getUTCMinutes()*60) + ((context.getUTCHours()+1)*3600))/86.4); default: return m; } }; }; $P.toString = function (format, ignoreStandards) { // Standard Date and Time Format Strings. Formats pulled from CultureInfo file and // may vary by culture. if (!ignoreStandards && format && format.length === 1) { output = parseStandardFormats.call(this, format); if (output) { return output; } } var parseFormatStrings = parseFormatStringsClosure(this); return format ? format.replace(/((\\)?(dd?d?d?|MM?M?M?|yy?y?y?|hh?|HH?|mm?|ss?|tt?|S|q|Q|WW?W?W?)(?![^\[]*\]))/g, parseFormatStrings).replace(/\[|\]/g, "") : this._toString(); }; }()); /************************************************************* * SugarPak - Domain Specific Language - Syntactical Sugar * *************************************************************/ (function () { var $D = Date, $P = $D.prototype, $N = Number.prototype; // private $P._orient = +1; // private $P._nth = null; // private $P._is = false; // private $P._same = false; // private $P._isSecond = false; // private $N._dateElement = "days"; /** * Moves the date to the next instance of a date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.today().next().friday();
	Date.today().next().fri();
	Date.today().next().march();
	Date.today().next().mar();
	Date.today().next().week();
	
* * @return {Date} date */ $P.next = function () { this._move = true; this._orient = +1; return this; }; /** * Creates a new Date (Date.today()) and moves the date to the next instance of the date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.next().friday();
	Date.next().fri();
	Date.next().march();
	Date.next().mar();
	Date.next().week();
	
* * @return {Date} date */ $D.next = function () { return $D.today().next(); }; /** * Moves the date to the previous instance of a date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.today().last().friday();
	Date.today().last().fri();
	Date.today().last().march();
	Date.today().last().mar();
	Date.today().last().week();
	
* * @return {Date} date */ $P.last = $P.prev = $P.previous = function () { this._move = true; this._orient = -1; return this; }; /** * Creates a new Date (Date.today()) and moves the date to the previous instance of the date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.last().friday();
	Date.last().fri();
	Date.previous().march();
	Date.prev().mar();
	Date.last().week();
	
* * @return {Date} date */ $D.last = $D.prev = $D.previous = function () { return $D.today().last(); }; /** * Performs a equality check when followed by either a month name, day name or .weekday() function. * Example

	Date.today().is().friday(); // true|false
	Date.today().is().fri();
	Date.today().is().march();
	Date.today().is().mar();
	
* * @return {Boolean} true|false */ $P.is = function () { this._is = true; return this; }; /** * Determines if two date objects occur on/in exactly the same instance of the subsequent date part function. * The function .same() must be followed by a date part function (example: .day(), .month(), .year(), etc). * * An optional Date can be passed in the date part function. If now date is passed as a parameter, 'Now' is used. * * The following example demonstrates how to determine if two dates fall on the exact same day. * * Example

	var d1 = Date.today(); // today at 00:00
	var d2 = new Date();   // exactly now.

	// Do they occur on the same day?
	d1.same().day(d2); // true
	
	// Do they occur on the same hour?
	d1.same().hour(d2); // false, unless d2 hour is '00' (midnight).
	
	// What if it's the same day, but one year apart?
	var nextYear = Date.today().add(1).year();

	d1.same().day(nextYear); // false, because the dates must occur on the exact same day. 
	
* * Scenario: Determine if a given date occurs during some week period 2 months from now. * * Example

	var future = Date.today().add(2).months();
	return someDate.same().week(future); // true|false;
	
* * @return {Boolean} true|false */ $P.same = function () { this._same = true; this._isSecond = false; return this; }; /** * Determines if the current date/time occurs during Today. Must be preceded by the .is() function. * Example

	someDate.is().today();    // true|false
	new Date().is().today();  // true
	Date.today().is().today();// true
	Date.today().add(-1).day().is().today(); // false
	
* * @return {Boolean} true|false */ $P.today = function () { return this.same().day(); }; /** * Determines if the current date is a weekday. This function must be preceded by the .is() function. * Example

	Date.today().is().weekday(); // true|false
	
* * @return {Boolean} true|false */ $P.weekday = function () { if (this._nth) { return df("Weekday").call(this); } if (this._move) { return this.addWeekdays(this._orient); } if (this._is) { this._is = false; return (!this.is().sat() && !this.is().sun()); } return false; }; /** * Determines if the current date is on the weekend. This function must be preceded by the .is() function. * Example

	Date.today().is().weekend(); // true|false
	
* * @return {Boolean} true|false */ $P.weekend = function () { if (this._is) { this._is = false; return (this.is().sat() || this.is().sun()); } return false; }; /** * Sets the Time of the current Date instance. A string "6:15 pm" or config object {hour:18, minute:15} are accepted. * Example

	// Set time to 6:15pm with a String
	Date.today().at("6:15pm");

	// Set time to 6:15pm with a config object
	Date.today().at({hour:18, minute:15});
	
* * @return {Date} date */ $P.at = function (time) { return (typeof time === "string") ? $D.parse(this.toString("d") + " " + time) : this.set(time); }; /** * Creates a new Date() and adds this (Number) to the date based on the preceding date element function (eg. second|minute|hour|day|month|year). * Example

	// Undeclared Numbers must be wrapped with parentheses. Requirment of JavaScript.
	(3).days().fromNow();
	(6).months().fromNow();

	// Declared Number variables do not require parentheses. 
	var n = 6;
	n.months().fromNow();
	
* * @return {Date} A new Date instance */ $N.fromNow = $N.after = function (date) { var c = {}; c[this._dateElement] = this; return ((!date) ? new Date() : date.clone()).add(c); }; /** * Creates a new Date() and subtract this (Number) from the date based on the preceding date element function (eg. second|minute|hour|day|month|year). * Example

	// Undeclared Numbers must be wrapped with parentheses. Requirment of JavaScript.
	(3).days().ago();
	(6).months().ago();

	// Declared Number variables do not require parentheses. 
	var n = 6;
	n.months().ago();
	
* * @return {Date} A new Date instance */ $N.ago = $N.before = function (date) { var c = {}, s = (this._dateElement[this._dateElement.length-1] !== "s") ? this._dateElement + "s" : this._dateElement; c[s] = this * -1; return ((!date) ? new Date() : date.clone()).add(c); }; // Do NOT modify the following string tokens. These tokens are used to build dynamic functions. // All culture-specific strings can be found in the CultureInfo files. var dx = ("sunday monday tuesday wednesday thursday friday saturday").split(/\s/), mx = ("january february march april may june july august september october november december").split(/\s/), px = ("Millisecond Second Minute Hour Day Week Month Year Quarter Weekday").split(/\s/), pxf = ("Milliseconds Seconds Minutes Hours Date Week Month FullYear Quarter").split(/\s/), nth = ("final first second third fourth fifth").split(/\s/), de; /** * Returns an object literal of all the date parts. * Example

	var o = new Date().toObject();
	
	// { year: 2008, month: 4, week: 20, day: 13, hour: 18, minute: 9, second: 32, millisecond: 812 }
	
	// The object properties can be referenced directly from the object.
	
	alert(o.day);  // alerts "13"
	alert(o.year); // alerts "2008"
	
* * @return {Date} An object literal representing the original date object. */ $P.toObject = function () { var o = {}; for (var i = 0; i < px.length; i++) { if (this["get" + pxf[i]]) { o[px[i].toLowerCase()] = this["get" + pxf[i]](); } } return o; }; /** * Returns a date created from an object literal. Ignores the .week property if set in the config. * Example

	var o = new Date().toObject();
	
	return Date.fromObject(o); // will return the same date. 

	var o2 = {month: 1, day: 20, hour: 18}; // birthday party!
	Date.fromObject(o2);
	
* * @return {Date} An object literal representing the original date object. */ $D.fromObject = function(config) { config.week = null; return Date.today().set(config); }; // Create day name functions and abbreviated day name functions (eg. monday(), friday(), fri()). var df = function (n) { return function () { if (this._is) { this._is = false; return this.getDay() === n; } if (this._move) { this._move = null; } if (this._nth !== null) { // If the .second() function was called earlier, remove the _orient // from the date, and then continue. // This is required because 'second' can be used in two different context. // // Example // // Date.today().add(1).second(); // Date.march().second().monday(); // // Things get crazy with the following... // Date.march().add(1).second().second().monday(); // but it works!! // if (this._isSecond) { this.addSeconds(this._orient * -1); } // make sure we reset _isSecond this._isSecond = false; var ntemp = this._nth; this._nth = null; var temp = this.clone().moveToLastDayOfMonth(); this.moveToNthOccurrence(n, ntemp); if (this > temp) { throw new RangeError($D.getDayName(n) + " does not occur " + ntemp + " times in the month of " + $D.getMonthName(temp.getMonth()) + " " + temp.getFullYear() + "."); } return this; } return this.moveToDayOfWeek(n, this._orient); }; }; var sdf = function (n) { return function () { var t = $D.today(), shift = n - t.getDay(); if (n === 0 && Date.CultureInfo.firstDayOfWeek === 1 && t.getDay() !== 0) { shift = shift + 7; } return t.addDays(shift); }; }; // Create month name functions and abbreviated month name functions (eg. january(), march(), mar()). var month_instance_functions = function (n) { return function () { if (this._is) { this._is = false; return this.getMonth() === n; } return this.moveToMonth(n, this._orient); }; }; var month_static_functions = function (n) { return function () { return $D.today().set({ month: n, day: 1 }); }; }; var processTerms = function (names, staticFunc, instanceFunc) { for (var i = 0; i < names.length; i++) { // Create constant static Name variables. $D[names[i].toUpperCase()] = $D[names[i].toUpperCase().substring(0, 3)] = i; // Create Name functions. $D[names[i]] = $D[names[i].substring(0, 3)] = staticFunc(i); // Create Name instance functions. $P[names[i]] = $P[names[i].substring(0, 3)] = instanceFunc(i); } }; processTerms(dx, sdf, df); processTerms(mx, month_static_functions, month_instance_functions); // Create date element functions and plural date element functions used with Date (eg. day(), days(), months()). var ef = function (j) { return function () { // if the .second() function was called earlier, the _orient // has alread been added. Just return this and reset _isSecond. if (this._isSecond) { this._isSecond = false; return this; } if (this._same) { this._same = this._is = false; var o1 = this.toObject(), o2 = (arguments[0] || new Date()).toObject(), v = "", k = j.toLowerCase(); // the substr trick with -1 doesn't work in IE8 or less k = (k[k.length-1] === "s") ? k.substring(0,k.length-1) : k; for (var m = (px.length - 1); m > -1; m--) { v = px[m].toLowerCase(); if (o1[v] !== o2[v]) { return false; } if (k === v) { break; } } return true; } if (j.substring(j.length - 1) !== "s") { j += "s"; } if (this._move) { this._move = null; } return this["add" + j](this._orient); }; }; var nf = function (n) { return function () { this._dateElement = n; return this; }; }; for (var k = 0; k < px.length; k++) { de = px[k].toLowerCase(); if(de !== "weekday") { // Create date element functions and plural date element functions used with Date (eg. day(), days(), months()). $P[de] = $P[de + "s"] = ef(px[k]); // Create date element functions and plural date element functions used with Number (eg. day(), days(), months()). $N[de] = $N[de + "s"] = nf(de + "s"); } } $P._ss = ef("Second"); var nthfn = function (n) { return function (dayOfWeek) { if (this._same) { return this._ss(arguments[0]); } if (dayOfWeek || dayOfWeek === 0) { return this.moveToNthOccurrence(dayOfWeek, n); } this._nth = n; // if the operator is 'second' add the _orient, then deal with it later... if (n === 2 && (dayOfWeek === undefined || dayOfWeek === null)) { this._isSecond = true; return this.addSeconds(this._orient); } return this; }; }; for (var l = 0; l < nth.length; l++) { $P[nth[l]] = (l === 0) ? nthfn(-1) : nthfn(l); } }()); (function () { "use strict"; Date.Parsing = { Exception: function (s) { this.message = "Parse error at '" + s.substring(0, 10) + " ...'"; } }; var $P = Date.Parsing; var dayOffsets = { standard: [0,31,59,90,120,151,181,212,243,273,304,334], leap: [0,31,60,91,121,152,182,213,244,274,305,335] }; $P.isLeapYear = function(year) { return ((year % 4 === 0) && (year % 100 !== 0)) || (year % 400 === 0); }; var utils = { multiReplace : function (str, hash ) { var key; for (key in hash) { if (Object.prototype.hasOwnProperty.call(hash, key)) { var regex; if (typeof hash[key] === "function") { } else { regex = (hash[key] instanceof RegExp) ? hash[key] : new RegExp(hash[key], "g"); } str = str.replace(regex, key); } } return str; }, getDayOfYearFromWeek : function (obj) { var d, jan4, offset; obj.weekDay = (!obj.weekDay && obj.weekDay !== 0) ? 1 : obj.weekDay; d = new Date(obj.year, 0, 4); jan4 = d.getDay() === 0 ? 7 : d.getDay(); // JS is 0 indexed on Sunday. offset = jan4+3; obj.dayOfYear = ((obj.week * 7) + (obj.weekDay === 0 ? 7 : obj.weekDay))-offset; return obj; }, getDayOfYear : function (obj, dayOffset) { if (!obj.dayOfYear) { obj = utils.getDayOfYearFromWeek(obj); } for (var i=0;i <= dayOffset.length;i++) { if (obj.dayOfYear < dayOffset[i] || i === dayOffset.length) { obj.day = obj.day ? obj.day : (obj.dayOfYear - dayOffset[i-1]); break; } else { obj.month = i; } } return obj; }, adjustForTimeZone : function (obj, date) { var offset; if (obj.zone.toUpperCase() === "Z" || (obj.zone_hours === 0 && obj.zone_minutes === 0)) { // it's UTC/GML so work out the current timeszone offset offset = -date.getTimezoneOffset(); } else { offset = (obj.zone_hours*60) + (obj.zone_minutes || 0); if (obj.zone_sign === "+") { offset *= -1; } offset -= date.getTimezoneOffset(); } date.setMinutes(date.getMinutes()+offset); return date; }, setDefaults : function (obj) { obj.year = obj.year || Date.today().getFullYear(); obj.hours = obj.hours || 0; obj.minutes = obj.minutes || 0; obj.seconds = obj.seconds || 0; obj.milliseconds = obj.milliseconds || 0; if (!(!obj.month && (obj.week || obj.dayOfYear))) { // if we have a month, or if we don't but don't have the day calculation data obj.month = obj.month || 0; obj.day = obj.day || 1; } return obj; }, dataNum: function (data, mod, explict, postProcess) { var dataNum = data*1; if (mod) { if (postProcess) { return data ? mod(data)*1 : data; } else { return data ? mod(dataNum) : data; } } else if (!explict){ return data ? dataNum : data; } else { return (data && typeof data !== "undefined") ? dataNum : data; } }, timeDataProcess: function (obj) { var timeObj = {}; for (var x in obj.data) { if (obj.data.hasOwnProperty(x)) { timeObj[x] = obj.ignore[x] ? obj.data[x] : utils.dataNum(obj.data[x], obj.mods[x], obj.explict[x], obj.postProcess[x]); } } if (obj.data.secmins) { obj.data.secmins = obj.data.secmins.replace(",", ".") * 60; if (!timeObj.minutes) { timeObj.minutes = obj.data.secmins; } else if (!timeObj.seconds) { timeObj.seconds = obj.data.secmins; } delete obj.secmins; } return timeObj; }, buildTimeObjectFromData: function (data) { var time = utils.timeDataProcess({ data: { year : data[1], month : data[5], day : data[7], week : data[8], dayOfYear : data[10], hours : data[15], zone_hours : data[23], zone_minutes : data[24], zone : data[21], zone_sign : data[22], weekDay : data[9], minutes: data[16], seconds: data[19], milliseconds: data[20], secmins: data[18] }, mods: { month: function(data) { return data-1; }, weekDay: function (data) { data = Math.abs(data); return (data === 7 ? 0 : data); }, minutes: function (data) { return data.replace(":",""); }, seconds: function (data) { return Math.floor( (data.replace(":","").replace(",","."))*1 ); }, milliseconds: function (data) { return (data.replace(",",".")*1000); } }, postProcess: { minutes: true, seconds: true, milliseconds: true }, explict: { zone_hours: true, zone_minutes: true }, ignore: { zone: true, zone_sign: true, secmins: true } }); return time; }, addToHash: function (hash, keys, data) { keys = keys; data = data; var len = keys.length; for (var i = 0; i < len; i++) { hash[keys[i]] = data[i]; } return hash; }, combineRegex: function (r1, r2) { return new RegExp("(("+r1.source+")\\s("+r2.source+"))"); }, getDateNthString: function(add, last, inc){ if (add) { return Date.today().addDays(inc).toString("d"); } else if (last) { return Date.today().last()[inc]().toString("d"); } }, buildRegexData: function (array) { var arr = []; var len = array.length; for (var i=0; i < len; i++) { if (Object.prototype.toString.call(array[i]) === '[object Array]') { // oldIE compat version of Array.isArray arr.push(this.combineRegex(array[i][0], array[i][1])); } else { arr.push(array[i]); } } return arr; } }; $P.processTimeObject = function (obj) { var date, dayOffset; utils.setDefaults(obj); dayOffset = ($P.isLeapYear(obj.year)) ? dayOffsets.leap : dayOffsets.standard; if (!obj.month && (obj.week || obj.dayOfYear)) { utils.getDayOfYear(obj, dayOffset); } else { obj.dayOfYear = dayOffset[obj.month] + obj.day; } date = new Date(obj.year, obj.month, obj.day, obj.hours, obj.minutes, obj.seconds, obj.milliseconds); if (obj.zone) { utils.adjustForTimeZone(obj, date); // adjust (and calculate) for timezone } return date; }; $P.ISO = { regex : /^([\+-]?\d{4}(?!\d{2}\b))((-?)((0[1-9]|1[0-2])(\3([12]\d|0[1-9]|3[01]))?|W([0-4]\d|5[0-3])(-?[1-7])?|(00[1-9]|0[1-9]\d|[12]\d{2}|3([0-5]\d|6[1-6])))([T\s]((([01]\d|2[0-4])((:?)[0-5]\d)?|24\:?00)([\.,]\d+(?!:))?)?(\17[0-5]\d([\.,]\d+)?)?\s?([zZ]|([\+-])([01]\d|2[0-3]):?([0-5]\d)?)?)?)?$/, parse : function (s) { var time, data = s.match(this.regex); if (!data || !data.length) { return null; } time = utils.buildTimeObjectFromData(data); if (!time.year || (!time.year && (!time.month && !time.day) && (!time.week && !time.dayOfYear)) ) { return null; } return $P.processTimeObject(time); } }; $P.Numeric = { isNumeric: function (e){return!isNaN(parseFloat(e))&&isFinite(e);}, regex: /\b([0-1]?[0-9])([0-3]?[0-9])([0-2]?[0-9]?[0-9][0-9])\b/i, parse: function (s) { var data, i, time = {}, order = Date.CultureInfo.dateElementOrder.split(""); if (!(this.isNumeric(s)) || // if it's non-numeric OR (s[0] === "+" && s[0] === "-")) { // It's an arithmatic string (eg +/-1000) return null; } if (s.length < 5 && s.indexOf(".") < 0 && s.indexOf("/") < 0) { // assume it's just a year. time.year = s; return $P.processTimeObject(time); } data = s.match(this.regex); if (!data || !data.length) { return null; } for (i=0; i < order.length; i++) { switch(order[i]) { case "d": time.day = data[i+1]; break; case "m": time.month = (data[i+1]-1); break; case "y": time.year = data[i+1]; break; } } return $P.processTimeObject(time); } }; $P.Normalizer = { regexData: function () { var $R = Date.CultureInfo.regexPatterns; return utils.buildRegexData([ $R.tomorrow, $R.yesterday, [$R.past, $R.mon], [$R.past, $R.tue], [$R.past, $R.wed], [$R.past, $R.thu], [$R.past, $R.fri], [$R.past, $R.sat], [$R.past, $R.sun] ]); }, basicReplaceHash : function() { var $R = Date.CultureInfo.regexPatterns; return { "January": $R.jan.source, "February": $R.feb, "March": $R.mar, "April": $R.apr, "May": $R.may, "June": $R.jun, "July": $R.jul, "August": $R.aug, "September": $R.sep, "October": $R.oct, "November": $R.nov, "December": $R.dec, "": /\bat\b/gi, " ": /\s{2,}/, "am": $R.inTheMorning, "9am": $R.thisMorning, "pm": $R.inTheEvening, "7pm":$R.thisEvening }; }, keys : function(){ return [ utils.getDateNthString(true, false, 1), // tomorrow utils.getDateNthString(true, false, -1), // yesterday utils.getDateNthString(false, true, "monday"), //last mon utils.getDateNthString(false, true, "tuesday"), //last tues utils.getDateNthString(false, true, "wednesday"), //last wed utils.getDateNthString(false, true, "thursday"), //last thurs utils.getDateNthString(false, true, "friday"), //last fri utils.getDateNthString(false, true, "saturday"), //last sat utils.getDateNthString(false, true, "sunday") //last sun ]; }, buildRegexFunctions: function () { var $R = Date.CultureInfo.regexPatterns; var __ = Date.i18n.__; var tomorrowRE = new RegExp("(\\b\\d\\d?("+__("AM")+"|"+__("PM")+")? )("+$R.tomorrow.source.slice(1)+")", "i"); // adapted tomorrow regex for AM PM relative dates var todayRE = new RegExp($R.today.source + "(?!\\s*([+-]))\\b"); // today, but excludes the math operators (eg "today + 2h") this.replaceFuncs = [ [todayRE, function (full) { return (full.length > 1) ? Date.today().toString("d") : full; }], [tomorrowRE, function(full, m1) { var t = Date.today().addDays(1).toString("d"); return (t + " " + m1); }], [$R.amThisMorning, function(str, am){return am;}], [$R.pmThisEvening, function(str, pm){return pm;}] ]; }, buildReplaceData: function () { this.buildRegexFunctions(); this.replaceHash = utils.addToHash(this.basicReplaceHash(), this.keys(), this.regexData()); }, stringReplaceFuncs: function (s) { for (var i=0; i < this.replaceFuncs.length; i++) { s = s.replace(this.replaceFuncs[i][0], this.replaceFuncs[i][1]); } return s; }, parse: function (s) { s = this.stringReplaceFuncs(s); s = utils.multiReplace(s, this.replaceHash); try { var n = s.split(/([\s\-\.\,\/\x27]+)/); if (n.length === 3 && $P.Numeric.isNumeric(n[0]) && $P.Numeric.isNumeric(n[2]) && (n[2].length >= 4)) { // ok, so we're dealing with x/year. But that's not a full date. // This fixes wonky dateElementOrder parsing when set to dmy order. if (Date.CultureInfo.dateElementOrder[0] === "d") { s = "1/" + n[0] + "/" + n[2]; // set to 1st of month and normalize the seperator } } } catch (e) {} return s; } }; $P.Normalizer.buildReplaceData(); }()); (function () { var $P = Date.Parsing; var _ = $P.Operators = { // // Tokenizers // rtoken: function (r) { // regex token return function (s) { var mx = s.match(r); if (mx) { return ([ mx[0], s.substring(mx[0].length) ]); } else { throw new $P.Exception(s); } }; }, token: function () { // whitespace-eating token return function (s) { return _.rtoken(new RegExp("^\\s*" + s + "\\s*"))(s); }; }, stoken: function (s) { // string token return _.rtoken(new RegExp("^" + s)); }, // Atomic Operators until: function (p) { return function (s) { var qx = [], rx = null; while (s.length) { try { rx = p.call(this, s); } catch (e) { qx.push(rx[0]); s = rx[1]; continue; } break; } return [ qx, s ]; }; }, many: function (p) { return function (s) { var rx = [], r = null; while (s.length) { try { r = p.call(this, s); } catch (e) { return [ rx, s ]; } rx.push(r[0]); s = r[1]; } return [ rx, s ]; }; }, // generator operators -- see below optional: function (p) { return function (s) { var r = null; try { r = p.call(this, s); } catch (e) { return [ null, s ]; } return [ r[0], r[1] ]; }; }, not: function (p) { return function (s) { try { p.call(this, s); } catch (e) { return [null, s]; } throw new $P.Exception(s); }; }, ignore: function (p) { return p ? function (s) { var r = null; r = p.call(this, s); return [null, r[1]]; } : null; }, product: function () { var px = arguments[0], qx = Array.prototype.slice.call(arguments, 1), rx = []; for (var i = 0 ; i < px.length ; i++) { rx.push(_.each(px[i], qx)); } return rx; }, cache: function (rule) { var cache = {}, cache_length = 0, cache_keys = [], CACHE_MAX = Date.Config.CACHE_MAX || 100000, r = null; var cacheCheck = function () { if (cache_length === CACHE_MAX) { // kill several keys, don't want to have to do this all the time... for (var i=0; i < 10; i++) { var key = cache_keys.shift(); if (key) { delete cache[key]; cache_length--; } } } }; return function (s) { cacheCheck(); try { r = cache[s] = (cache[s] || rule.call(this, s)); } catch (e) { r = cache[s] = e; } cache_length++; cache_keys.push(s); if (r instanceof $P.Exception) { throw r; } else { return r; } }; }, // vector operators -- see below any: function () { var px = arguments; return function (s) { var r = null; for (var i = 0; i < px.length; i++) { if (px[i] == null) { continue; } try { r = (px[i].call(this, s)); } catch (e) { r = null; } if (r) { return r; } } throw new $P.Exception(s); }; }, each: function () { var px = arguments; return function (s) { var rx = [], r = null; for (var i = 0; i < px.length ; i++) { if (px[i] == null) { continue; } try { r = (px[i].call(this, s)); } catch (e) { throw new $P.Exception(s); } rx.push(r[0]); s = r[1]; } return [ rx, s]; }; }, all: function () { var px = arguments, _ = _; return _.each(_.optional(px)); }, // delimited operators sequence: function (px, d, c) { d = d || _.rtoken(/^\s*/); c = c || null; if (px.length === 1) { return px[0]; } return function (s) { var r = null, q = null; var rx = []; for (var i = 0; i < px.length ; i++) { try { r = px[i].call(this, s); } catch (e) { break; } rx.push(r[0]); try { q = d.call(this, r[1]); } catch (ex) { q = null; break; } s = q[1]; } if (!r) { throw new $P.Exception(s); } if (q) { throw new $P.Exception(q[1]); } if (c) { try { r = c.call(this, r[1]); } catch (ey) { throw new $P.Exception(r[1]); } } return [ rx, (r?r[1]:s) ]; }; }, // // Composite Operators // between: function (d1, p, d2) { d2 = d2 || d1; var _fn = _.each(_.ignore(d1), p, _.ignore(d2)); return function (s) { var rx = _fn.call(this, s); return [[rx[0][0], r[0][2]], rx[1]]; }; }, list: function (p, d, c) { d = d || _.rtoken(/^\s*/); c = c || null; return (p instanceof Array ? _.each(_.product(p.slice(0, -1), _.ignore(d)), p.slice(-1), _.ignore(c)) : _.each(_.many(_.each(p, _.ignore(d))), px, _.ignore(c))); }, set: function (px, d, c) { d = d || _.rtoken(/^\s*/); c = c || null; return function (s) { // r is the current match, best the current 'best' match // which means it parsed the most amount of input var r = null, p = null, q = null, rx = null, best = [[], s], last = false; // go through the rules in the given set for (var i = 0; i < px.length ; i++) { // last is a flag indicating whether this must be the last element // if there is only 1 element, then it MUST be the last one q = null; p = null; r = null; last = (px.length === 1); // first, we try simply to match the current pattern // if not, try the next pattern try { r = px[i].call(this, s); } catch (e) { continue; } // since we are matching against a set of elements, the first // thing to do is to add r[0] to matched elements rx = [[r[0]], r[1]]; // if we matched and there is still input to parse and // we don't already know this is the last element, // we're going to next check for the delimiter ... // if there's none, or if there's no input left to parse // than this must be the last element after all ... if (r[1].length > 0 && ! last) { try { q = d.call(this, r[1]); } catch (ex) { last = true; } } else { last = true; } // if we parsed the delimiter and now there's no more input, // that means we shouldn't have parsed the delimiter at all // so don't update r and mark this as the last element ... if (!last && q[1].length === 0) { last = true; } // so, if this isn't the last element, we're going to see if // we can get any more matches from the remaining (unmatched) // elements ... if (!last) { // build a list of the remaining rules we can match against, // i.e., all but the one we just matched against var qx = []; for (var j = 0; j < px.length ; j++) { if (i !== j) { qx.push(px[j]); } } // now invoke recursively set with the remaining input // note that we don't include the closing delimiter ... // we'll check for that ourselves at the end p = _.set(qx, d).call(this, q[1]); // if we got a non-empty set as a result ... // (otw rx already contains everything we want to match) if (p[0].length > 0) { // update current result, which is stored in rx ... // basically, pick up the remaining text from p[1] // and concat the result from p[0] so that we don't // get endless nesting ... rx[0] = rx[0].concat(p[0]); rx[1] = p[1]; } } // at this point, rx either contains the last matched element // or the entire matched set that starts with this element. // now we just check to see if this variation is better than // our best so far, in terms of how much of the input is parsed if (rx[1].length < best[1].length) { best = rx; } // if we've parsed all the input, then we're finished if (best[1].length === 0) { break; } } // so now we've either gone through all the patterns trying them // as the initial match; or we found one that parsed the entire // input string ... // if best has no matches, just return empty set ... if (best[0].length === 0) { return best; } // if a closing delimiter is provided, then we have to check it also if (c) { // we try this even if there is no remaining input because the pattern // may well be optional or match empty input ... try { q = c.call(this, best[1]); } catch (ey) { throw new $P.Exception(best[1]); } // it parsed ... be sure to update the best match remaining input best[1] = q[1]; } // if we're here, either there was no closing delimiter or we parsed it // so now we have the best match; just return it! return best; }; }, forward: function (gr, fname) { return function (s) { return gr[fname].call(this, s); }; }, // // Translation Operators // replace: function (rule, repl) { return function (s) { var r = rule.call(this, s); return [repl, r[1]]; }; }, process: function (rule, fn) { return function (s) { var r = rule.call(this, s); return [fn.call(this, r[0]), r[1]]; }; }, min: function (min, rule) { return function (s) { var rx = rule.call(this, s); if (rx[0].length < min) { throw new $P.Exception(s); } return rx; }; } }; // Generator Operators And Vector Operators // Generators are operators that have a signature of F(R) => R, // taking a given rule and returning another rule, such as // ignore, which parses a given rule and throws away the result. // Vector operators are those that have a signature of F(R1,R2,...) => R, // take a list of rules and returning a new rule, such as each. // Generator operators are converted (via the following _generator // function) into functions that can also take a list or array of rules // and return an array of new rules as though the function had been // called on each rule in turn (which is what actually happens). // This allows generators to be used with vector operators more easily. // Example: // each(ignore(foo, bar)) instead of each(ignore(foo), ignore(bar)) // This also turns generators into vector operators, which allows // constructs like: // not(cache(foo, bar)) var _generator = function (op) { function gen() { var args = null, rx = [], px, i; if (arguments.length > 1) { args = Array.prototype.slice.call(arguments); } else if (arguments[0] instanceof Array) { args = arguments[0]; } if (args) { px = args.shift(); if (px.length > 0) { args.unshift(px[i]); rx.push(op.apply(null, args)); args.shift(); return rx; } } else { return op.apply(null, arguments); } } return gen; }; var gx = "optional not ignore cache".split(/\s/); for (var i = 0 ; i < gx.length ; i++) { _[gx[i]] = _generator(_[gx[i]]); } var _vector = function (op) { return function () { if (arguments[0] instanceof Array) { return op.apply(null, arguments[0]); } else { return op.apply(null, arguments); } }; }; var vx = "each any all".split(/\s/); for (var j = 0 ; j < vx.length ; j++) { _[vx[j]] = _vector(_[vx[j]]); } }()); (function () { var $D = Date; var flattenAndCompact = function (ax) { var rx = []; for (var i = 0; i < ax.length; i++) { if (ax[i] instanceof Array) { rx = rx.concat(flattenAndCompact(ax[i])); } else { if (ax[i]) { rx.push(ax[i]); } } } return rx; }; var parseMeridian = function () { if (this.meridian && (this.hour || this.hour === 0)) { if (this.meridian === "a" && this.hour > 11 && Date.Config.strict24hr){ throw "Invalid hour and meridian combination"; } else if (this.meridian === "p" && this.hour < 12 && Date.Config.strict24hr){ throw "Invalid hour and meridian combination"; } else if (this.meridian === "p" && this.hour < 12) { this.hour = this.hour + 12; } else if (this.meridian === "a" && this.hour === 12) { this.hour = 0; } } }; var setDefaults = function () { var now = new Date(); if ((this.hour || this.minute) && (!this.month && !this.year && !this.day)) { this.day = now.getDate(); } if (!this.year) { this.year = now.getFullYear(); } if (!this.month && this.month !== 0) { this.month = now.getMonth(); } if (!this.day) { this.day = 1; } if (!this.hour) { this.hour = 0; } if (!this.minute) { this.minute = 0; } if (!this.second) { this.second = 0; } if (!this.millisecond) { this.millisecond = 0; } }; var finishUtils = { getToday: function () { if (this.now || "hour minute second".indexOf(this.unit) !== -1) { return new Date(); } else { return $D.today(); } }, setDaysFromWeekday: function (today, orient){ var gap; orient = orient || 1; this.unit = "day"; gap = ($D.getDayNumberFromName(this.weekday) - today.getDay()); this.days = gap ? ((gap + (orient * 7)) % 7) : (orient * 7); return this; }, setMonthsFromMonth: function (today, orient) { var gap; orient = orient || 1; this.unit = "month"; gap = (this.month - today.getMonth()); this.months = gap ? ((gap + (orient * 12)) % 12) : (orient * 12); this.month = null; return this; }, setDMYFromWeekday: function () { var d = Date[this.weekday](); this.day = d.getDate(); if (!this.month) { this.month = d.getMonth(); } this.year = d.getFullYear(); return this; }, setUnitValue: function (orient) { if (!this.value && this.operator && this.operator !== null && this[this.unit + "s"] && this[this.unit + "s"] !== null) { this[this.unit + "s"] = this[this.unit + "s"] + ((this.operator === "add") ? 1 : -1) + (this.value||0) * orient; } else if (this[this.unit + "s"] == null || this.operator != null) { if (!this.value) { this.value = 1; } this[this.unit + "s"] = this.value * orient; } }, generateDateFromWeeks: function () { var weekday = (this.weekday !== undefined) ? this.weekday : "today"; var d = Date[weekday]().addWeeks(this.weeks); if (this.now) { d.setTimeToNow(); } return d; } }; $D.Translator = { hour: function (s) { return function () { this.hour = Number(s); }; }, minute: function (s) { return function () { this.minute = Number(s); }; }, second: function (s) { return function () { this.second = Number(s); }; }, /* for ss.s format */ secondAndMillisecond: function (s) { return function () { var mx = s.match(/^([0-5][0-9])\.([0-9]{1,3})/); this.second = Number(mx[1]); this.millisecond = Number(mx[2]); }; }, meridian: function (s) { return function () { this.meridian = s.slice(0, 1).toLowerCase(); }; }, timezone: function (s) { return function () { var n = s.replace(/[^\d\+\-]/g, ""); if (n.length) { this.timezoneOffset = Number(n); } else { this.timezone = s.toLowerCase(); } }; }, day: function (x) { var s = x[0]; return function () { this.day = Number(s.match(/\d+/)[0]); if (this.day < 1) { throw "invalid day"; } }; }, month: function (s) { return function () { this.month = (s.length === 3) ? "jan feb mar apr may jun jul aug sep oct nov dec".indexOf(s)/4 : Number(s) - 1; if (this.month < 0) { throw "invalid month"; } }; }, year: function (s) { return function () { var n = Number(s); this.year = ((s.length > 2) ? n : (n + (((n + 2000) < Date.CultureInfo.twoDigitYearMax) ? 2000 : 1900))); }; }, rday: function (s) { return function () { switch (s) { case "yesterday": this.days = -1; break; case "tomorrow": this.days = 1; break; case "today": this.days = 0; break; case "now": this.days = 0; this.now = true; break; } }; }, finishExact: function (x) { var d; x = (x instanceof Array) ? x : [x]; for (var i = 0 ; i < x.length ; i++) { if (x[i]) { x[i].call(this); } } setDefaults.call(this); parseMeridian.call(this); if (this.day > $D.getDaysInMonth(this.year, this.month)) { throw new RangeError(this.day + " is not a valid value for days."); } d = new Date(this.year, this.month, this.day, this.hour, this.minute, this.second, this.millisecond); if (this.year < 100) { d.setFullYear(this.year); // means years less that 100 are process correctly. JS will parse it otherwise as 1900-1999. } if (this.timezone) { d.set({ timezone: this.timezone }); } else if (this.timezoneOffset) { d.set({ timezoneOffset: this.timezoneOffset }); } return d; }, finish: function (x) { var today, expression, orient, temp; x = (x instanceof Array) ? flattenAndCompact(x) : [ x ]; if (x.length === 0) { return null; } for (var i = 0 ; i < x.length ; i++) { if (typeof x[i] === "function") { x[i].call(this); } } if (this.now && !this.unit && !this.operator) { return new Date(); } else { today = finishUtils.getToday.call(this); } expression = !!(this.days && this.days !== null || this.orient || this.operator); orient = ((this.orient === "past" || this.operator === "subtract") ? -1 : 1); if (this.month && this.unit === "week") { this.value = this.month + 1; delete this.month; delete this.day; } if ((this.month || this.month === 0) && "year day hour minute second".indexOf(this.unit) !== -1) { if (!this.value) { this.value = this.month + 1; } this.month = null; expression = true; } if (!expression && this.weekday && !this.day && !this.days) { finishUtils.setDMYFromWeekday.call(this); } if (expression && this.weekday && this.unit !== "month" && this.unit !== "week") { finishUtils.setDaysFromWeekday.call(this, today, orient); } if (this.weekday && this.unit !== "week" && !this.day && !this.days) { temp = Date[this.weekday](); this.day = temp.getDate(); if (temp.getMonth() !== today.getMonth()) { this.month = temp.getMonth(); } } if (this.month && this.unit === "day" && this.operator) { if (!this.value) { this.value = (this.month + 1); } this.month = null; } if (this.value != null && this.month != null && this.year != null) { this.day = this.value * 1; } if (this.month && !this.day && this.value) { today.set({ day: this.value * 1 }); if (!expression) { this.day = this.value * 1; } } if (!this.month && this.value && this.unit === "month" && !this.now) { this.month = this.value; expression = true; } if (expression && (this.month || this.month === 0) && this.unit !== "year") { finishUtils.setMonthsFromMonth.call(this, today, orient); } if (!this.unit) { this.unit = "day"; } finishUtils.setUnitValue.call(this, orient); parseMeridian.call(this); if ((this.month || this.month === 0) && !this.day) { this.day = 1; } if (!this.orient && !this.operator && this.unit === "week" && this.value && !this.day && !this.month) { return Date.today().setWeek(this.value); } if (this.unit === "week" && this.weeks && !this.day && !this.month) { return finishUtils.generateDateFromWeeks.call(this); } if (expression && this.timezone && this.day && this.days) { this.day = this.days; } if (expression){ today.add(this); } else { today.set(this); } if (this.timezone) { this.timezone = this.timezone.toUpperCase(); var offset = $D.getTimezoneOffset(this.timezone); var timezone; if (today.hasDaylightSavingTime()) { // lets check that we're being sane with timezone setting timezone = $D.getTimezoneAbbreviation(offset, today.isDaylightSavingTime()); if (timezone !== this.timezone) { // bugger, we're in a place where things like EST vs EDT matters. if (today.isDaylightSavingTime()) { today.addHours(-1); } else { today.addHours(1); } } } today.setTimezoneOffset(offset); } return today; } }; }()); (function () { var $D = Date; $D.Grammar = {}; var _ = $D.Parsing.Operators, g = $D.Grammar, t = $D.Translator, _fn; // Allow rolling up into general purpose rules _fn = function () { return _.each(_.any.apply(null, arguments), _.not(g.ctoken2("timeContext"))); }; g.datePartDelimiter = _.rtoken(/^([\s\-\.\,\/\x27]+)/); g.timePartDelimiter = _.stoken(":"); g.whiteSpace = _.rtoken(/^\s*/); g.generalDelimiter = _.rtoken(/^(([\s\,]|at|@|on)+)/); var _C = {}; g.ctoken = function (keys) { var fn = _C[keys]; if (! fn) { var c = Date.CultureInfo.regexPatterns; var kx = keys.split(/\s+/), px = []; for (var i = 0; i < kx.length ; i++) { px.push(_.replace(_.rtoken(c[kx[i]]), kx[i])); } fn = _C[keys] = _.any.apply(null, px); } return fn; }; g.ctoken2 = function (key) { return _.rtoken(Date.CultureInfo.regexPatterns[key]); }; var cacheProcessRtoken = function (key, token, type, eachToken) { if (eachToken) { g[key] = _.cache(_.process(_.each(_.rtoken(token),_.optional(g.ctoken2(eachToken))), type)); } else { g[key] = _.cache(_.process(_.rtoken(token), type)); } }; var cacheProcessCtoken = function (token, type) { return _.cache(_.process(g.ctoken2(token), type)); }; var _F = {}; //function cache var _get = function (f) { _F[f] = (_F[f] || g.format(f)[0]); return _F[f]; }; g.allformats = function (fx) { var rx = []; if (fx instanceof Array) { for (var i = 0; i < fx.length; i++) { rx.push(_get(fx[i])); } } else { rx.push(_get(fx)); } return rx; }; g.formats = function (fx) { if (fx instanceof Array) { var rx = []; for (var i = 0 ; i < fx.length ; i++) { rx.push(_get(fx[i])); } return _.any.apply(null, rx); } else { return _get(fx); } }; var grammarFormats = { timeFormats: function(){ var i, RTokenKeys = [ "h", "hh", "H", "HH", "m", "mm", "s", "ss", "ss.s", "z", "zz" ], RToken = [ /^(0[0-9]|1[0-2]|[1-9])/, /^(0[0-9]|1[0-2])/, /^([0-1][0-9]|2[0-3]|[0-9])/, /^([0-1][0-9]|2[0-3])/, /^([0-5][0-9]|[0-9])/, /^[0-5][0-9]/, /^([0-5][0-9]|[0-9])/, /^[0-5][0-9]/, /^[0-5][0-9]\.[0-9]{1,3}/, /^((\+|\-)\s*\d\d\d\d)|((\+|\-)\d\d\:?\d\d)/, /^((\+|\-)\s*\d\d\d\d)|((\+|\-)\d\d\:?\d\d)/ ], tokens = [ t.hour, t.hour, t.hour, t.hour, t.minute, t.minute, t.second, t.second, t.secondAndMillisecond, t.timezone, t.timezone ]; for (i=0; i < RTokenKeys.length; i++) { cacheProcessRtoken(RTokenKeys[i], RToken[i], tokens[i]); } g.hms = _.cache(_.sequence([g.H, g.m, g.s], g.timePartDelimiter)); g.t = cacheProcessCtoken("shortMeridian", t.meridian); g.tt = cacheProcessCtoken("longMeridian", t.meridian); g.zzz = cacheProcessCtoken("timezone", t.timezone); g.timeSuffix = _.each(_.ignore(g.whiteSpace), _.set([ g.tt, g.zzz ])); g.time = _.each(_.optional(_.ignore(_.stoken("T"))), g.hms, g.timeSuffix); }, dateFormats: function () { // pre-loaded rules for different date part order preferences var _setfn = function () { return _.set(arguments, g.datePartDelimiter); }; var i, RTokenKeys = [ "d", "dd", "M", "MM", "y", "yy", "yyy", "yyyy" ], RToken = [ /^([0-2]\d|3[0-1]|\d)/, /^([0-2]\d|3[0-1])/, /^(1[0-2]|0\d|\d)/, /^(1[0-2]|0\d)/, /^(\d+)/, /^(\d\d)/, /^(\d\d?\d?\d?)/, /^(\d\d\d\d)/ ], tokens = [ t.day, t.day, t.month, t.month, t.year, t.year, t.year, t.year ], eachToken = [ "ordinalSuffix", "ordinalSuffix" ]; for (i=0; i < RTokenKeys.length; i++) { cacheProcessRtoken(RTokenKeys[i], RToken[i], tokens[i], eachToken[i]); } g.MMM = g.MMMM = _.cache(_.process(g.ctoken("jan feb mar apr may jun jul aug sep oct nov dec"), t.month)); g.ddd = g.dddd = _.cache(_.process(g.ctoken("sun mon tue wed thu fri sat"), function (s) { return function () { this.weekday = s; }; } )); g.day = _fn(g.d, g.dd); g.month = _fn(g.M, g.MMM); g.year = _fn(g.yyyy, g.yy); g.mdy = _setfn(g.ddd, g.month, g.day, g.year); g.ymd = _setfn(g.ddd, g.year, g.month, g.day); g.dmy = _setfn(g.ddd, g.day, g.month, g.year); g.date = function (s) { return ((g[Date.CultureInfo.dateElementOrder] || g.mdy).call(this, s)); }; }, relative: function () { // relative date / time expressions g.orientation = _.process(g.ctoken("past future"), function (s) { return function () { this.orient = s; }; } ); g.operator = _.process(g.ctoken("add subtract"), function (s) { return function () { this.operator = s; }; } ); g.rday = _.process(g.ctoken("yesterday tomorrow today now"), t.rday); g.unit = _.process(g.ctoken("second minute hour day week month year"), function (s) { return function () { this.unit = s; }; } ); } }; g.buildGrammarFormats = function () { // these need to be rebuilt every time the language changes. _C = {}; grammarFormats.timeFormats(); grammarFormats.dateFormats(); grammarFormats.relative(); g.value = _.process(_.rtoken(/^([-+]?\d+)?(st|nd|rd|th)?/), function (s) { return function () { this.value = s.replace(/\D/g, ""); }; } ); g.expression = _.set([g.rday, g.operator, g.value, g.unit, g.orientation, g.ddd, g.MMM ]); g.format = _.process(_.many( _.any( // translate format specifiers into grammar rules _.process( _.rtoken(/^(dd?d?d?(?!e)|MM?M?M?|yy?y?y?|hh?|HH?|mm?|ss?|tt?|zz?z?)/), function (fmt) { if (g[fmt]) { return g[fmt]; } else { throw $D.Parsing.Exception(fmt); } } ), // translate separator tokens into token rules _.process(_.rtoken(/^[^dMyhHmstz]+/), // all legal separators function (s) { return _.ignore(_.stoken(s)); } ) ) ), // construct the parser ... function (rules) { return _.process(_.each.apply(null, rules), t.finishExact); } ); // starting rule for general purpose grammar g._start = _.process(_.set([ g.date, g.time, g.expression ], g.generalDelimiter, g.whiteSpace), t.finish); }; g.buildGrammarFormats(); // parsing date format specifiers - ex: "h:m:s tt" // this little guy will generate a custom parser based // on the format string, ex: g.format("h:m:s tt") // check for these formats first g._formats = g.formats([ "\"yyyy-MM-ddTHH:mm:ssZ\"", "yyyy-MM-ddTHH:mm:ss.sz", "yyyy-MM-ddTHH:mm:ssZ", "yyyy-MM-ddTHH:mm:ssz", "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-ddTHH:mmZ", "yyyy-MM-ddTHH:mmz", "yyyy-MM-ddTHH:mm", "ddd, MMM dd, yyyy H:mm:ss tt", "ddd MMM d yyyy HH:mm:ss zzz", "MMddyyyy", "ddMMyyyy", "Mddyyyy", "ddMyyyy", "Mdyyyy", "dMyyyy", "yyyy", "Mdyy", "dMyy", "d" ]); // real starting rule: tries selected formats first, // then general purpose rule g.start = function (s) { try { var r = g._formats.call({}, s); if (r[1].length === 0) { return r; } } catch (e) {} return g._start.call({}, s); }; }()); (function () { var $D = Date; /** * @desc Converts the specified string value into its JavaScript Date equivalent using CultureInfo specific format information. * * Example

	///////////
	// Dates //
	///////////

	// 15-Oct-2004
	var d1 = Date.parse("10/15/2004");

	// 15-Oct-2004
	var d1 = Date.parse("15-Oct-2004");

	// 15-Oct-2004
	var d1 = Date.parse("2004.10.15");

	//Fri Oct 15, 2004
	var d1 = Date.parse("Fri Oct 15, 2004");

	///////////
	// Times //
	///////////

	// Today at 10 PM.
	var d1 = Date.parse("10 PM");

	// Today at 10:30 PM.
	var d1 = Date.parse("10:30 P.M.");

	// Today at 6 AM.
	var d1 = Date.parse("06am");

	/////////////////////
	// Dates and Times //
	/////////////////////

	// 8-July-2004 @ 10:30 PM
	var d1 = Date.parse("July 8th, 2004, 10:30 PM");

	// 1-July-2004 @ 10:30 PM
	var d1 = Date.parse("2004-07-01T22:30:00");

	////////////////////
	// Relative Dates //
	////////////////////

	// Returns today's date. The string "today" is culture specific.
	var d1 = Date.parse("today");

	// Returns yesterday's date. The string "yesterday" is culture specific.
	var d1 = Date.parse("yesterday");

	// Returns the date of the next thursday.
	var d1 = Date.parse("Next thursday");

	// Returns the date of the most previous monday.
	var d1 = Date.parse("last monday");

	// Returns today's day + one year.
	var d1 = Date.parse("next year");

	///////////////
	// Date Math //
	///////////////

	// Today + 2 days
	var d1 = Date.parse("t+2");

	// Today + 2 days
	var d1 = Date.parse("today + 2 days");

	// Today + 3 months
	var d1 = Date.parse("t+3m");

	// Today - 1 year
	var d1 = Date.parse("today - 1 year");

	// Today - 1 year
	var d1 = Date.parse("t-1y"); 


	/////////////////////////////
	// Partial Dates and Times //
	/////////////////////////////

	// July 15th of this year.
	var d1 = Date.parse("July 15");

	// 15th day of current day and year.
	var d1 = Date.parse("15");

	// July 1st of current year at 10pm.
	var d1 = Date.parse("7/1 10pm");
	
* * @param {String} The string value to convert into a Date object [Required] * @return {Date} A Date object or null if the string cannot be converted into a Date. */ var parseUtils = { removeOrds: function (s) { ords = s.match(/\b(\d+)(?:st|nd|rd|th)\b/); // find ordinal matches s = ((ords && ords.length === 2) ? s.replace(ords[0], ords[1]) : s); return s; }, grammarParser: function (s) { var r = null; try { r = $D.Grammar.start.call({}, s.replace(/^\s*(\S*(\s+\S+)*)\s*$/, "$1")); } catch (e) { return null; } return ((r[1].length === 0) ? r[0] : null); }, nativeFallback: function(s) { var t; try { // ok we haven't parsed it, last ditch attempt with the built-in parser. t = Date._parse(s); return (t || t === 0) ? new Date(t) : null; } catch (e) { return null; } } }; function parse (s) { var d; if (!s) { return null; } if (s instanceof Date) { return s.clone(); } if (s.length >= 4 && s.charAt(0) !== "0" && s.charAt(0) !== "+"&& s.charAt(0) !== "-") { // ie: 2004 will pass, 0800 won't. // Start with specific formats d = $D.Parsing.ISO.parse(s) || $D.Parsing.Numeric.parse(s); } if (d instanceof Date && !isNaN(d.getTime())) { return d; } else { // find ordinal dates (1st, 3rd, 8th, etc and remove them as they cause parsing issues) s = $D.Parsing.Normalizer.parse(parseUtils.removeOrds(s)); d = parseUtils.grammarParser(s); if (d !== null) { return d; } else { return parseUtils.nativeFallback(s); } } } if (!$D._parse) { $D._parse = $D.parse; } $D.parse = parse; Date.getParseFunction = function (fx) { var fns = Date.Grammar.allformats(fx); return function (s) { var r = null; for (var i = 0; i < fns.length; i++) { try { r = fns[i].call({}, s); } catch (e) { continue; } if (r[1].length === 0) { return r[0]; } } return null; }; }; /** * Converts the specified string value into its JavaScript Date equivalent using the specified format {String} or formats {Array} and the CultureInfo specific format information. * The format of the string value must match one of the supplied formats exactly. * * Example

	// 15-Oct-2004
	var d1 = Date.parseExact("10/15/2004", "M/d/yyyy");

	// 15-Oct-2004
	var d1 = Date.parse("15-Oct-2004", "M-ddd-yyyy");

	// 15-Oct-2004
	var d1 = Date.parse("2004.10.15", "yyyy.MM.dd");

	// Multiple formats
	var d1 = Date.parseExact("10/15/2004", ["M/d/yyyy", "MMMM d, yyyy"]);
	
* * @param {String} The string value to convert into a Date object [Required]. * @param {Object} The expected format {String} or an array of expected formats {Array} of the date string [Required]. * @return {Date} A Date object or null if the string cannot be converted into a Date. */ $D.parseExact = function (s, fx) { return $D.getParseFunction(fx)(s); }; }()); (function () { var $D = Date, $P = $D.prototype, // $C = $D.CultureInfo, // not used atm p = function (s, l) { if (!l) { l = 2; } return ("000" + s).slice(l * -1); }; /** * Converts a PHP format string to Java/.NET format string. * A PHP format string can be used with ._format or .format. * A Java/.NET format string can be used with .toString(). * The .parseExact function will only accept a Java/.NET format string * * Example * var f1 = "%m/%d/%y" * var f2 = Date.normalizeFormat(f1); // "MM/dd/yy" * * new Date().format(f1); // "04/13/08" * new Date()._format(f1); // "04/13/08" * new Date().toString(f2); // "04/13/08" * * var date = Date.parseExact("04/13/08", f2); // Sun Apr 13 2008 * * @param {String} A PHP format string consisting of one or more format spcifiers. * @return {String} The PHP format converted to a Java/.NET format string. */ var normalizerSubstitutions = { "d" : "dd", "%d": "dd", "D" : "ddd", "%a": "ddd", "j" : "dddd", "l" : "dddd", "%A": "dddd", "S" : "S", "F" : "MMMM", "%B": "MMMM", "m" : "MM", "%m": "MM", "M" : "MMM", "%b": "MMM", "%h": "MMM", "n" : "M", "Y" : "yyyy", "%Y": "yyyy", "y" : "yy", "%y": "yy", "g" : "h", "%I": "h", "G" : "H", "h" : "hh", "H" : "HH", "%H": "HH", "i" : "mm", "%M": "mm", "s" : "ss", "%S": "ss", "%r": "hh:mm tt", "%R": "H:mm", "%T": "H:mm:ss", "%X": "t", "%x": "d", "%e": "d", "%D": "MM/dd/yy", "%n": "\\n", "%t": "\\t", "e" : "z", "T" : "z", "%z": "z", "%Z": "z", "Z" : "ZZ", "N" : "u", "w" : "u", "%w": "u", "W" : "W", "%V": "W" }; var normalizer = { substitutes: function (m) { return normalizerSubstitutions[m]; }, interpreted: function (m, x) { var y; switch (m) { case "%u": return x.getDay() + 1; case "z": return x.getOrdinalNumber(); case "%j": return p(x.getOrdinalNumber(), 3); case "%U": var d1 = x.clone().set({month: 0, day: 1}).addDays(-1).moveToDayOfWeek(0), d2 = x.clone().addDays(1).moveToDayOfWeek(0, -1); return (d2 < d1) ? "00" : p((d2.getOrdinalNumber() - d1.getOrdinalNumber()) / 7 + 1); case "%W": return p(x.getWeek()); case "t": return $D.getDaysInMonth(x.getFullYear(), x.getMonth()); case "o": case "%G": return x.setWeek(x.getISOWeek()).toString("yyyy"); case "%g": return x._format("%G").slice(-2); case "a": case "%p": return t("tt").toLowerCase(); case "A": return t("tt").toUpperCase(); case "u": return p(x.getMilliseconds(), 3); case "I": return (x.isDaylightSavingTime()) ? 1 : 0; case "O": return x.getUTCOffset(); case "P": y = x.getUTCOffset(); return y.substring(0, y.length - 2) + ":" + y.substring(y.length - 2); case "B": var now = new Date(); return Math.floor(((now.getHours() * 3600) + (now.getMinutes() * 60) + now.getSeconds() + (now.getTimezoneOffset() + 60) * 60) / 86.4); case "c": return x.toISOString().replace(/\"/g, ""); case "U": return $D.strtotime("now"); case "%c": return t("d") + " " + t("t"); case "%C": return Math.floor(x.getFullYear() / 100 + 1); } }, shouldOverrideDefaults: function (m) { switch (m) { case "%e": return true; default: return false; } }, parse: function (m, context) { var formatString, c = context || new Date(); formatString = normalizer.substitutes(m); if (formatString) { return formatString; } formatString = normalizer.interpreted(m, c); if (formatString) { return formatString; } else { return m; } } }; $D.normalizeFormat = function (format, context) { return format.replace(/(%|\\)?.|%%/g, function(t){ return normalizer.parse(t, context); }); }; /** * Format a local Unix timestamp according to locale settings * * Example: * Date.strftime("%m/%d/%y", new Date()); // "04/13/08" * Date.strftime("c", "2008-04-13T17:52:03Z"); // "04/13/08" * * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @param {Number|String} The number representing the number of seconds that have elapsed since January 1, 1970 (local time). * @return {String} A string representation of the current Date object. */ $D.strftime = function (format, time) { var d = Date.parse(time); return d._format(format); }; /** * Parse any textual datetime description into a Unix timestamp. * A Unix timestamp is the number of seconds that have elapsed since January 1, 1970 (midnight UTC/GMT). * * Example: * Date.strtotime("04/13/08"); // 1208044800 * Date.strtotime("1970-01-01T00:00:00Z"); // 0 * * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @param {Object} A string or date object. * @return {String} A string representation of the current Date object. */ $D.strtotime = function (time) { var d = $D.parse(time); return Math.round($D.UTC(d.getUTCFullYear(), d.getUTCMonth(), d.getUTCDate(), d.getUTCHours(), d.getUTCMinutes(), d.getUTCSeconds(), d.getUTCMilliseconds()) / 1000); }; /** * Converts the value of the current Date object to its equivalent string representation using a PHP/Unix style of date format specifiers. * Format Specifiers * Format Description Example * ------ --------------------------------------------------------------------------- ----------------------- * %a abbreviated weekday name according to the current localed "Mon" through "Sun" * %A full weekday name according to the current localed "Sunday" through "Saturday" * %b abbreviated month name according to the current localed "Jan" through "Dec" * %B full month name according to the current locale "January" through "December" * %c preferred date and time representation for the current locale "4/13/2008 12:33 PM" * %C century number (the year divided by 100 and truncated to an integer) "00" to "99" * %d day of the month as a decimal number "01" to "31" * %D same as %m/%d/%y "04/13/08" * %e day of the month as a decimal number, a single digit is preceded by a space "1" to "31" * %g like %G, but without the century "08" * %G The 4-digit year corresponding to the ISO week number (see %V). "2008" * This has the same format and value as %Y, except that if the ISO week number * belongs to the previous or next year, that year is used instead. * %h same as %b "Jan" through "Dec" * %H hour as a decimal number using a 24-hour clock. "00" to "23" * %I hour as a decimal number using a 12-hour clock. "01" to "12" * %j day of the year as a decimal number. "001" to "366" * %m month as a decimal number. "01" to "12" * %M minute as a decimal number. "00" to "59" * %n newline character "\n" * %p either "am" or "pm" according to the given time value, or the "am" or "pm" * corresponding strings for the current locale. * %r time in a.m. and p.m. notation "8:44 PM" * %R time in 24 hour notation "20:44" * %S second as a decimal number "00" to "59" * %t tab character "\t" * %T current time, equal to %H:%M:%S "12:49:11" * %u weekday as a decimal number ["1", "7"], with "1" representing Monday "1" to "7" * %U week number of the current year as a decimal number, starting with the "0" to ("52" or "53") * first Sunday as the first day of the first week * %V The ISO 8601:1988 week number of the current year as a decimal number, "00" to ("52" or "53") * range 01 to 53, where week 1 is the first week that has at least 4 days * in the current year, and with Monday as the first day of the week. * (Use %G or %g for the year component that corresponds to the week number * for the specified timestamp.) * %W week number of the current year as a decimal number, starting with the "00" to ("52" or "53") * first Monday as the first day of the first week * %w day of the week as a decimal, Sunday being "0" "0" to "6" * %x preferred date representation for the current locale without the time "4/13/2008" * %X preferred time representation for the current locale without the date "12:53:05" * %y year as a decimal number without a century "00" "99" * %Y year as a decimal number including the century "2008" * %Z time zone or name or abbreviation "UTC", "EST", "PST" * %z same as %Z * %% a literal "%" characters "%" * d Day of the month, 2 digits with leading zeros "01" to "31" * D A textual representation of a day, three letters "Mon" through "Sun" * j Day of the month without leading zeros "1" to "31" * l A full textual representation of the day of the week (lowercase "L") "Sunday" through "Saturday" * N ISO-8601 numeric representation of the day of the week (added in PHP 5.1.0) "1" (for Monday) through "7" (for Sunday) * S English ordinal suffix for the day of the month, 2 characters "st", "nd", "rd" or "th". Works well with j * w Numeric representation of the day of the week "0" (for Sunday) through "6" (for Saturday) * z The day of the year (starting from "0") "0" through "365" * W ISO-8601 week number of year, weeks starting on Monday "00" to ("52" or "53") * F A full textual representation of a month, such as January or March "January" through "December" * m Numeric representation of a month, with leading zeros "01" through "12" * M A short textual representation of a month, three letters "Jan" through "Dec" * n Numeric representation of a month, without leading zeros "1" through "12" * t Number of days in the given month "28" through "31" * L Whether it's a leap year "1" if it is a leap year, "0" otherwise * o ISO-8601 year number. This has the same value as Y, except that if the "2008" * ISO week number (W) belongs to the previous or next year, that year * is used instead. * Y A full numeric representation of a year, 4 digits "2008" * y A two digit representation of a year "08" * a Lowercase Ante meridiem and Post meridiem "am" or "pm" * A Uppercase Ante meridiem and Post meridiem "AM" or "PM" * B Swatch Internet time "000" through "999" * g 12-hour format of an hour without leading zeros "1" through "12" * G 24-hour format of an hour without leading zeros "0" through "23" * h 12-hour format of an hour with leading zeros "01" through "12" * H 24-hour format of an hour with leading zeros "00" through "23" * i Minutes with leading zeros "00" to "59" * s Seconds, with leading zeros "00" through "59" * u Milliseconds "54321" * e Timezone identifier "UTC", "EST", "PST" * I Whether or not the date is in daylight saving time (uppercase i) "1" if Daylight Saving Time, "0" otherwise * O Difference to Greenwich time (GMT) in hours "+0200", "-0600" * P Difference to Greenwich time (GMT) with colon between hours and minutes "+02:00", "-06:00" * T Timezone abbreviation "UTC", "EST", "PST" * Z Timezone offset in seconds. The offset for timezones west of UTC is "-43200" through "50400" * always negative, and for those east of UTC is always positive. * c ISO 8601 date "2004-02-12T15:19:21+00:00" * r RFC 2822 formatted date "Thu, 21 Dec 2000 16:01:07 +0200" * U Seconds since the Unix Epoch (January 1 1970 00:00:00 GMT) "0" * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @return {String} A string representation of the current Date object. */ var formatReplace = function (context) { return function (m) { var formatString, override = false; if (m.charAt(0) === "\\" || m.substring(0, 2) === "%%") { return m.replace("\\", "").replace("%%", "%"); } override = normalizer.shouldOverrideDefaults(m); formatString = $D.normalizeFormat(m, context); if (formatString) { return context.toString(formatString, override); } }; }; $P._format = function (format) { var formatter = formatReplace(this); if (!format) { return this._toString(); } else { return format.replace(/(%|\\)?.|%%/g, formatter); } }; if (!$P.format) { $P.format = $P._format; } }()); (function () { "use strict"; var gFn = function (attr) { return function () { return this[attr]; }; }; var sFn = function (attr) { return function (val) { this[attr] = val; return this; }; }; var attrs = ["years", "months", "days", "hours", "minutes", "seconds", "milliseconds"]; var addSetFuncs = function (context, attrs) { for (var i = 0; i < attrs.length ; i++) { var $a = attrs[i], $b = $a.slice(0, 1).toUpperCase() + $a.slice(1); context.prototype[$a] = 0; context.prototype["get" + $b] = gFn($a); context.prototype["set" + $b] = sFn($a); } }; /** * new TimeSpan(milliseconds); * new TimeSpan(days, hours, minutes, seconds); * new TimeSpan(days, hours, minutes, seconds, milliseconds); */ var TimeSpan = function (days, hours, minutes, seconds, milliseconds) { if (arguments.length === 1 && typeof days === "number") { var orient = (days < 0) ? -1 : +1; var millsLeft = Math.abs(days); this.setDays(Math.floor(millsLeft / 86400000) * orient); millsLeft = millsLeft % 86400000; this.setHours(Math.floor(millsLeft / 3600000) * orient); millsLeft = millsLeft % 3600000; this.setMinutes(Math.floor(millsLeft / 60000) * orient); millsLeft = millsLeft % 60000; this.setSeconds(Math.floor(millsLeft / 1000) * orient); millsLeft = millsLeft % 1000; this.setMilliseconds(millsLeft * orient); } else { this.set(days, hours, minutes, seconds, milliseconds); } this.getTotalMilliseconds = function () { return (this.getDays() * 86400000) + (this.getHours() * 3600000) + (this.getMinutes() * 60000) + (this.getSeconds() * 1000); }; this.compareTo = function (time) { var t1 = new Date(1970, 1, 1, this.getHours(), this.getMinutes(), this.getSeconds()), t2; if (time === null) { t2 = new Date(1970, 1, 1, 0, 0, 0); } else { t2 = new Date(1970, 1, 1, time.getHours(), time.getMinutes(), time.getSeconds()); } return (t1 < t2) ? -1 : (t1 > t2) ? 1 : 0; }; this.equals = function (time) { return (this.compareTo(time) === 0); }; this.add = function (time) { return (time === null) ? this : this.addSeconds(time.getTotalMilliseconds() / 1000); }; this.subtract = function (time) { return (time === null) ? this : this.addSeconds(-time.getTotalMilliseconds() / 1000); }; this.addDays = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 86400000)); }; this.addHours = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 3600000)); }; this.addMinutes = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 60000)); }; this.addSeconds = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 1000)); }; this.addMilliseconds = function (n) { return new TimeSpan(this.getTotalMilliseconds() + n); }; this.get12HourHour = function () { return (this.getHours() > 12) ? this.getHours() - 12 : (this.getHours() === 0) ? 12 : this.getHours(); }; this.getDesignator = function () { return (this.getHours() < 12) ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator; }; this.toString = function (format) { this._toString = function () { if (this.getDays() !== null && this.getDays() > 0) { return this.getDays() + "." + this.getHours() + ":" + this.p(this.getMinutes()) + ":" + this.p(this.getSeconds()); } else { return this.getHours() + ":" + this.p(this.getMinutes()) + ":" + this.p(this.getSeconds()); } }; this.p = function (s) { return (s.toString().length < 2) ? "0" + s : s; }; var me = this; return format ? format.replace(/dd?|HH?|hh?|mm?|ss?|tt?/g, function (format) { switch (format) { case "d": return me.getDays(); case "dd": return me.p(me.getDays()); case "H": return me.getHours(); case "HH": return me.p(me.getHours()); case "h": return me.get12HourHour(); case "hh": return me.p(me.get12HourHour()); case "m": return me.getMinutes(); case "mm": return me.p(me.getMinutes()); case "s": return me.getSeconds(); case "ss": return me.p(me.getSeconds()); case "t": return ((me.getHours() < 12) ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator).substring(0, 1); case "tt": return (me.getHours() < 12) ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator; } } ) : this._toString(); }; return this; }; addSetFuncs(TimeSpan, attrs.slice(2)); TimeSpan.prototype.set = function (days, hours, minutes, seconds, milliseconds){ this.setDays(days || this.getDays()); this.setHours(hours || this.getHours()); this.setMinutes(minutes || this.getMinutes()); this.setSeconds(seconds || this.getSeconds()); this.setMilliseconds(milliseconds || this.getMilliseconds()); }; /** * Gets the time of day for this date instances. * @return {TimeSpan} TimeSpan */ Date.prototype.getTimeOfDay = function () { return new TimeSpan(0, this.getHours(), this.getMinutes(), this.getSeconds(), this.getMilliseconds()); }; Date.TimeSpan = TimeSpan; if (typeof window !== "undefined" ) { // keeping API compatible for v1.x window.TimeSpan = TimeSpan; } }()); (function () { "use strict"; var attrs = ["years", "months", "days", "hours", "minutes", "seconds", "milliseconds"]; var gFn = function (attr) { return function () { return this[attr]; }; }; var sFn = function (attr) { return function (val) { this[attr] = val; return this; }; }; var addSetFuncs = function (context, attrs) { for (var i = 0; i < attrs.length ; i++) { var $a = attrs[i], $b = $a.slice(0, 1).toUpperCase() + $a.slice(1); context.prototype[$a] = 0; context.prototype["get" + $b] = gFn($a); context.prototype["set" + $b] = sFn($a); } }; var setMonthsAndYears = function (orient, d1, d2, context) { function inc() { d1.addMonths(-orient); context.months++; if (context.months === 12) { context.years++; context.months = 0; } } if (orient === +1) { while (d1 > d2) { inc(); } } else { while (d1 < d2) { inc(); } } context.months--; context.months *= orient; context.years *= orient; }; var adjustForDST = function(orient, startDate, endDate) { var hasDSTMismatch = (false === (startDate.isDaylightSavingTime() === endDate.isDaylightSavingTime())); if (hasDSTMismatch && orient === 1) { startDate.addHours(-1); } else if (hasDSTMismatch) { startDate.addHours(1); } }; /** * TimePeriod(startDate, endDate); * TimePeriod(years, months, days, hours, minutes, seconds, milliseconds); */ var TimePeriod = function (years, months, days, hours, minutes, seconds, milliseconds) { if (arguments.length === 7) { this.set(years, months, days, hours, minutes, seconds, milliseconds); } else if (arguments.length === 2 && arguments[0] instanceof Date && arguments[1] instanceof Date) { var startDate = arguments[0].clone(); var endDate = arguments[1].clone(); var orient = (startDate > endDate) ? +1 : -1; this.dates = { start: arguments[0].clone(), end: arguments[1].clone() }; setMonthsAndYears(orient, startDate, endDate, this); adjustForDST(orient, startDate, endDate); // // TODO - adjust for DST var diff = endDate - startDate; if (diff !== 0) { var ts = new TimeSpan(diff); this.set(this.years, this.months, ts.getDays(), ts.getHours(), ts.getMinutes(), ts.getSeconds(), ts.getMilliseconds()); } } return this; }; // create all the set functions. addSetFuncs(TimePeriod, attrs); TimePeriod.prototype.set = function (years, months, days, hours, minutes, seconds, milliseconds){ this.setYears(years || this.getYears()); this.setMonths(months || this.getMonths()); this.setDays(days || this.getDays()); this.setHours(hours || this.getHours()); this.setMinutes(minutes || this.getMinutes()); this.setSeconds(seconds || this.getSeconds()); this.setMilliseconds(milliseconds || this.getMilliseconds()); }; Date.TimePeriod = TimePeriod; if (typeof window !== "undefined") { // keeping API compatible for v1.x window.TimePeriod = TimePeriod; } }()); ================================================ FILE: build/date-uz-Cyrl-UZ.js ================================================ /** * @overview datejs * @version 1.0.0-rc3 * @author Gregory Wild-Smith * @copyright 2015 Gregory Wild-Smith * @license MIT * @homepage https://github.com/abritinthebay/datejs */ /* * DateJS Culture String File * Country Code: uz-Cyrl-UZ * Name: Uzbek (Cyrillic, Uzbekistan) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["uz-Cyrl-UZ"] = { "name": "uz-Cyrl-UZ", "englishName": "Uzbek (Cyrillic, Uzbekistan)", "nativeName": "Ўзбек (Ўзбекистон)", "Sunday": "якшанба", "Monday": "душанба", "Tuesday": "сешанба", "Wednesday": "чоршанба", "Thursday": "пайшанба", "Friday": "жума", "Saturday": "шанба", "Sun": "якш", "Mon": "дш", "Tue": "сш", "Wed": "чш", "Thu": "пш", "Fri": "ж", "Sat": "ш", "Su": "якш", "Mo": "дш", "Tu": "сш", "We": "чш", "Th": "пш", "Fr": "ж", "Sa": "ш", "S_Sun_Initial": "я", "M_Mon_Initial": "д", "T_Tue_Initial": "с", "W_Wed_Initial": "ч", "T_Thu_Initial": "п", "F_Fri_Initial": "ж", "S_Sat_Initial": "ш", "January": "Январ", "February": "Феврал", "March": "Март", "April": "Апрел", "May": "Май", "June": "Июн", "July": "Июл", "August": "Август", "September": "Сентябр", "October": "Октябр", "November": "Ноябр", "December": "Декабр", "Jan_Abbr": "Янв", "Feb_Abbr": "Фев", "Mar_Abbr": "Мар", "Apr_Abbr": "Апр", "May_Abbr": "Май", "Jun_Abbr": "Июн", "Jul_Abbr": "Июл", "Aug_Abbr": "Авг", "Sep_Abbr": "Сен", "Oct_Abbr": "Окт", "Nov_Abbr": "Ноя", "Dec_Abbr": "Дек", "AM": "", "PM": "", "firstDayOfWeek": 1, "twoDigitYearMax": 2029, "mdy": "dmy", "M/d/yyyy": "dd.MM.yyyy", "dddd, MMMM dd, yyyy": "yyyy 'йил' d-MMMM", "h:mm tt": "HH:mm", "h:mm:ss tt": "HH:mm:ss", "dddd, MMMM dd, yyyy h:mm:ss tt": "yyyy 'йил' d-MMMM HH:mm:ss", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "d-MMMM", "MMMM, yyyy": "MMMM yyyy", "/jan(uary)?/": "янв(ар)?", "/feb(ruary)?/": "фев(рал)?", "/mar(ch)?/": "мар(т)?", "/apr(il)?/": "апр(ел)?", "/may/": "май", "/jun(e)?/": "июн", "/jul(y)?/": "июл", "/aug(ust)?/": "авг(уст)?", "/sep(t(ember)?)?/": "сен(тябр)?", "/oct(ober)?/": "окт(ябр)?", "/nov(ember)?/": "ноя(бр)?", "/dec(ember)?/": "дек(абр)?", "/^su(n(day)?)?/": "^якшанба", "/^mo(n(day)?)?/": "^душанба", "/^tu(e(s(day)?)?)?/": "^сешанба", "/^we(d(nesday)?)?/": "^чоршанба", "/^th(u(r(s(day)?)?)?)?/": "^пайшанба", "/^fr(i(day)?)?/": "^жума", "/^sa(t(urday)?)?/": "^шанба", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "uz-Cyrl-UZ"; /** * @overview datejs * @version 1.0.0-rc3 * @author Gregory Wild-Smith * @copyright 2015 Gregory Wild-Smith * @license MIT * @homepage https://github.com/abritinthebay/datejs */(function () { var $D = Date; var lang = Date.CultureStrings ? Date.CultureStrings.lang : null; var loggedKeys = {}; // for debug purposes. var getText = { getFromKey: function (key, countryCode) { var output; if (Date.CultureStrings && Date.CultureStrings[countryCode] && Date.CultureStrings[countryCode][key]) { output = Date.CultureStrings[countryCode][key]; } else { output = getText.buildFromDefault(key); } if (key.charAt(0) === "/") { // Assume it's a regex output = getText.buildFromRegex(key, countryCode); } return output; }, getFromObjectValues: function (obj, countryCode) { var key, output = {}; for(key in obj) { if (obj.hasOwnProperty(key)) { output[key] = getText.getFromKey(obj[key], countryCode); } } return output; }, getFromObjectKeys: function (obj, countryCode) { var key, output = {}; for(key in obj) { if (obj.hasOwnProperty(key)) { output[getText.getFromKey(key, countryCode)] = obj[key]; } } return output; }, getFromArray: function (arr, countryCode) { var output = []; for (var i=0; i < arr.length; i++){ if (i in arr) { output[i] = getText.getFromKey(arr[i], countryCode); } } return output; }, buildFromDefault: function (key) { var output, length, split, last; switch(key) { case "name": output = "en-US"; break; case "englishName": output = "English (United States)"; break; case "nativeName": output = "English (United States)"; break; case "twoDigitYearMax": output = 2049; break; case "firstDayOfWeek": output = 0; break; default: output = key; split = key.split("_"); length = split.length; if (length > 1 && key.charAt(0) !== "/") { // if the key isn't a regex and it has a split. last = split[(length - 1)].toLowerCase(); if (last === "initial" || last === "abbr") { output = split[0]; } } break; } return output; }, buildFromRegex: function (key, countryCode) { var output; if (Date.CultureStrings && Date.CultureStrings[countryCode] && Date.CultureStrings[countryCode][key]) { output = new RegExp(Date.CultureStrings[countryCode][key], "i"); } else { output = new RegExp(key.replace(new RegExp("/", "g"),""), "i"); } return output; } }; var shallowMerge = function (obj1, obj2) { for (var attrname in obj2) { if (obj2.hasOwnProperty(attrname)) { obj1[attrname] = obj2[attrname]; } } }; var __ = function (key, language) { var countryCode = (language) ? language : lang; loggedKeys[key] = key; if (typeof key === "object") { if (key instanceof Array) { return getText.getFromArray(key, countryCode); } else { return getText.getFromObjectKeys(key, countryCode); } } else { return getText.getFromKey(key, countryCode); } }; var loadI18nScript = function (code) { // paatterned after jQuery's getScript. var url = Date.Config.i18n + code + ".js"; var head = document.getElementsByTagName("head")[0] || document.documentElement; var script = document.createElement("script"); script.src = url; var completed = false; var events = { done: function (){} // placeholder function }; // Attach handlers for all browsers script.onload = script.onreadystatechange = function() { if ( !completed && (!this.readyState || this.readyState === "loaded" || this.readyState === "complete") ) { events.done(); head.removeChild(script); } }; setTimeout(function() { head.insertBefore(script, head.firstChild); }, 0); // allows return to execute first return { done: function (cb) { events.done = function() { if (cb) { setTimeout(cb,0); } }; } }; }; var buildInfo = { buildFromMethodHash: function (obj) { var key; for(key in obj) { if (obj.hasOwnProperty(key)) { obj[key] = buildInfo[obj[key]](); } } return obj; }, timeZoneDST: function () { var DST = { "CHADT": "+1345", "NZDT": "+1300", "AEDT": "+1100", "ACDT": "+1030", "AZST": "+0500", "IRDT": "+0430", "EEST": "+0300", "CEST": "+0200", "BST": "+0100", "PMDT": "-0200", "ADT": "-0300", "NDT": "-0230", "EDT": "-0400", "CDT": "-0500", "MDT": "-0600", "PDT": "-0700", "AKDT": "-0800", "HADT": "-0900" }; return __(DST); }, timeZoneStandard: function () { var standard = { "LINT": "+1400", "TOT": "+1300", "CHAST": "+1245", "NZST": "+1200", "NFT": "+1130", "SBT": "+1100", "AEST": "+1000", "ACST": "+0930", "JST": "+0900", "CWST": "+0845", "CT": "+0800", "ICT": "+0700", "MMT": "+0630", "BST": "+0600", "NPT": "+0545", "IST": "+0530", "PKT": "+0500", "AFT": "+0430", "MSK": "+0400", "IRST": "+0330", "FET": "+0300", "EET": "+0200", "CET": "+0100", "GMT": "+0000", "UTC": "+0000", "CVT": "-0100", "GST": "-0200", "BRT": "-0300", "NST": "-0330", "AST": "-0400", "EST": "-0500", "CST": "-0600", "MST": "-0700", "PST": "-0800", "AKST": "-0900", "MIT": "-0930", "HST": "-1000", "SST": "-1100", "BIT": "-1200" }; return __(standard); }, timeZones: function (data) { var zone; data.timezones = []; for (zone in data.abbreviatedTimeZoneStandard) { if (data.abbreviatedTimeZoneStandard.hasOwnProperty(zone)) { data.timezones.push({ name: zone, offset: data.abbreviatedTimeZoneStandard[zone]}); } } for (zone in data.abbreviatedTimeZoneDST) { if (data.abbreviatedTimeZoneDST.hasOwnProperty(zone)) { data.timezones.push({ name: zone, offset: data.abbreviatedTimeZoneDST[zone], dst: true}); } } return data.timezones; }, days: function () { return __(["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"]); }, dayAbbr: function () { return __(["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"]); }, dayShortNames: function () { return __(["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"]); }, dayFirstLetters: function () { return __(["S_Sun_Initial", "M_Mon_Initial", "T_Tues_Initial", "W_Wed_Initial", "T_Thu_Initial", "F_Fri_Initial", "S_Sat_Initial"]); }, months: function () { return __(["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"]); }, monthAbbr: function () { return __(["Jan_Abbr", "Feb_Abbr", "Mar_Abbr", "Apr_Abbr", "May_Abbr", "Jun_Abbr", "Jul_Abbr", "Aug_Abbr", "Sep_Abbr", "Oct_Abbr", "Nov_Abbr", "Dec_Abbr"]); }, formatPatterns: function () { return getText.getFromObjectValues({ shortDate: "M/d/yyyy", longDate: "dddd, MMMM dd, yyyy", shortTime: "h:mm tt", longTime: "h:mm:ss tt", fullDateTime: "dddd, MMMM dd, yyyy h:mm:ss tt", sortableDateTime: "yyyy-MM-ddTHH:mm:ss", universalSortableDateTime: "yyyy-MM-dd HH:mm:ssZ", rfc1123: "ddd, dd MMM yyyy HH:mm:ss", monthDay: "MMMM dd", yearMonth: "MMMM, yyyy" }, Date.i18n.currentLanguage()); }, regex: function () { return getText.getFromObjectValues({ inTheMorning: "/( in the )(morn(ing)?)\\b/", thisMorning: "/(this )(morn(ing)?)\\b/", amThisMorning: "/(\b\\d(am)? )(this )(morn(ing)?)/", inTheEvening: "/( in the )(even(ing)?)\\b/", thisEvening: "/(this )(even(ing)?)\\b/", pmThisEvening: "/(\b\\d(pm)? )(this )(even(ing)?)/", jan: "/jan(uary)?/", feb: "/feb(ruary)?/", mar: "/mar(ch)?/", apr: "/apr(il)?/", may: "/may/", jun: "/jun(e)?/", jul: "/jul(y)?/", aug: "/aug(ust)?/", sep: "/sep(t(ember)?)?/", oct: "/oct(ober)?/", nov: "/nov(ember)?/", dec: "/dec(ember)?/", sun: "/^su(n(day)?)?/", mon: "/^mo(n(day)?)?/", tue: "/^tu(e(s(day)?)?)?/", wed: "/^we(d(nesday)?)?/", thu: "/^th(u(r(s(day)?)?)?)?/", fri: "/fr(i(day)?)?/", sat: "/^sa(t(urday)?)?/", future: "/^next/", past: "/^last|past|prev(ious)?/", add: "/^(\\+|aft(er)?|from|hence)/", subtract: "/^(\\-|bef(ore)?|ago)/", yesterday: "/^yes(terday)?/", today: "/^t(od(ay)?)?/", tomorrow: "/^tom(orrow)?/", now: "/^n(ow)?/", millisecond: "/^ms|milli(second)?s?/", second: "/^sec(ond)?s?/", minute: "/^mn|min(ute)?s?/", hour: "/^h(our)?s?/", week: "/^w(eek)?s?/", month: "/^m(onth)?s?/", day: "/^d(ay)?s?/", year: "/^y(ear)?s?/", shortMeridian: "/^(a|p)/", longMeridian: "/^(a\\.?m?\\.?|p\\.?m?\\.?)/", timezone: "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/", ordinalSuffix: "/^\\s*(st|nd|rd|th)/", timeContext: "/^\\s*(\\:|a(?!u|p)|p)/" }, Date.i18n.currentLanguage()); } }; var CultureInfo = function () { var info = getText.getFromObjectValues({ name: "name", englishName: "englishName", nativeName: "nativeName", amDesignator: "AM", pmDesignator: "PM", firstDayOfWeek: "firstDayOfWeek", twoDigitYearMax: "twoDigitYearMax", dateElementOrder: "mdy" }, Date.i18n.currentLanguage()); var constructedInfo = buildInfo.buildFromMethodHash({ dayNames: "days", abbreviatedDayNames: "dayAbbr", shortestDayNames: "dayShortNames", firstLetterDayNames: "dayFirstLetters", monthNames: "months", abbreviatedMonthNames: "monthAbbr", formatPatterns: "formatPatterns", regexPatterns: "regex", abbreviatedTimeZoneDST: "timeZoneDST", abbreviatedTimeZoneStandard: "timeZoneStandard" }); shallowMerge(info, constructedInfo); buildInfo.timeZones(info); return info; }; $D.i18n = { __: function (key, lang) { return __(key, lang); }, currentLanguage: function () { return lang || "en-US"; }, setLanguage: function (code, force, cb) { var async = false; if (force || code === "en-US" || (!!Date.CultureStrings && !!Date.CultureStrings[code])) { lang = code; Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings.lang = code; Date.CultureInfo = new CultureInfo(); } else { if (!(!!Date.CultureStrings && !!Date.CultureStrings[code])) { if (typeof exports !== "undefined" && this.exports !== exports) { // we're in a Node enviroment, load it using require try { require("../i18n/" + code + ".js"); lang = code; Date.CultureStrings.lang = code; Date.CultureInfo = new CultureInfo(); } catch (e) { // var str = "The language for '" + code + "' could not be loaded by Node. It likely does not exist."; throw new Error("The DateJS IETF language tag '" + code + "' could not be loaded by Node. It likely does not exist."); } } else if (Date.Config && Date.Config.i18n) { // we know the location of the files, so lets load them async = true; loadI18nScript(code).done(function(){ lang = code; Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings.lang = code; Date.CultureInfo = new CultureInfo(); $D.Parsing.Normalizer.buildReplaceData(); // because this is async if ($D.Grammar) { $D.Grammar.buildGrammarFormats(); // so we can parse those strings... } if (cb) { setTimeout(cb,0); } }); } else { Date.console.error("The DateJS IETF language tag '" + code + "' is not available and has not been loaded."); return false; } } } $D.Parsing.Normalizer.buildReplaceData(); // rebuild normalizer strings if ($D.Grammar) { $D.Grammar.buildGrammarFormats(); // so we can parse those strings... } if (!async && cb) { setTimeout(cb,0); } }, getLoggedKeys: function () { return loggedKeys; }, updateCultureInfo: function () { Date.CultureInfo = new CultureInfo(); } }; $D.i18n.updateCultureInfo(); // run automatically }()); (function () { var $D = Date, $P = $D.prototype, p = function (s, l) { if (!l) { l = 2; } return ("000" + s).slice(l * -1); }; if (typeof window !== "undefined" && typeof window.console !== "undefined" && typeof window.console.log !== "undefined") { $D.console = console; // used only to raise non-critical errors if available } else { // set mock so we don't give errors. $D.console = { log: function(){}, error: function(){} }; } $D.Config = $D.Config || {}; $D.initOverloads = function() { /** * Overload of Date.now. Allows an alternate call for Date.now where it returns the * current Date as an object rather than just milliseconds since the Unix Epoch. * * Also provides an implementation of now() for browsers (IE<9) that don't have it. * * Backwards compatible so with work with either: * Date.now() [returns ms] * or * Date.now(true) [returns Date] */ if (!$D.now) { $D._now = function now() { return new Date().getTime(); }; } else if (!$D._now) { $D._now = $D.now; } $D.now = function (returnObj) { if (returnObj) { return $D.present(); } else { return $D._now(); } }; if ( !$P.toISOString ) { $P.toISOString = function() { return this.getUTCFullYear() + "-" + p(this.getUTCMonth() + 1) + "-" + p(this.getUTCDate()) + "T" + p(this.getUTCHours()) + ":" + p(this.getUTCMinutes()) + ":" + p(this.getUTCSeconds()) + "." + String( (this.getUTCMilliseconds()/1000).toFixed(3)).slice(2, 5) + "Z"; }; } // private if ( $P._toString === undefined ){ $P._toString = $P.toString; } }; $D.initOverloads(); /** * Gets a date that is set to the current date. The time is set to the start of the day (00:00 or 12:00 AM). * @return {Date} The current date. */ $D.today = function () { return new Date().clearTime(); }; /** * Gets a date that is set to the current date and time (same as new Date, but chainable) * @return {Date} The current date. */ $D.present = function () { return new Date(); }; /** * Compares the first date to the second date and returns an number indication of their relative values. * @param {Date} First Date object to compare [Required]. * @param {Date} Second Date object to compare to [Required]. * @return {Number} -1 = date1 is lessthan date2. 0 = values are equal. 1 = date1 is greaterthan date2. */ $D.compare = function (date1, date2) { if (isNaN(date1) || isNaN(date2)) { throw new Error(date1 + " - " + date2); } else if (date1 instanceof Date && date2 instanceof Date) { return (date1 < date2) ? -1 : (date1 > date2) ? 1 : 0; } else { throw new TypeError(date1 + " - " + date2); } }; /** * Compares the first Date object to the second Date object and returns true if they are equal. * @param {Date} First Date object to compare [Required] * @param {Date} Second Date object to compare to [Required] * @return {Boolean} true if dates are equal. false if they are not equal. */ $D.equals = function (date1, date2) { return (date1.compareTo(date2) === 0); }; /** * Gets the language appropriate day name when given the day number(0-6) * eg - 0 == Sunday * @return {String} The day name */ $D.getDayName = function (n) { return Date.CultureInfo.dayNames[n]; }; /** * Gets the day number (0-6) if given a CultureInfo specific string which is a valid dayName, abbreviatedDayName or shortestDayName (two char). * @param {String} The name of the day (eg. "Monday, "Mon", "tuesday", "tue", "We", "we"). * @return {Number} The day number */ $D.getDayNumberFromName = function (name) { var n = Date.CultureInfo.dayNames, m = Date.CultureInfo.abbreviatedDayNames, o = Date.CultureInfo.shortestDayNames, s = name.toLowerCase(); for (var i = 0; i < n.length; i++) { if (n[i].toLowerCase() === s || m[i].toLowerCase() === s || o[i].toLowerCase() === s) { return i; } } return -1; }; /** * Gets the month number (0-11) if given a Culture Info specific string which is a valid monthName or abbreviatedMonthName. * @param {String} The name of the month (eg. "February, "Feb", "october", "oct"). * @return {Number} The day number */ $D.getMonthNumberFromName = function (name) { var n = Date.CultureInfo.monthNames, m = Date.CultureInfo.abbreviatedMonthNames, s = name.toLowerCase(); for (var i = 0; i < n.length; i++) { if (n[i].toLowerCase() === s || m[i].toLowerCase() === s) { return i; } } return -1; }; /** * Gets the language appropriate month name when given the month number(0-11) * eg - 0 == January * @return {String} The month name */ $D.getMonthName = function (n) { return Date.CultureInfo.monthNames[n]; }; /** * Determines if the current date instance is within a LeapYear. * @param {Number} The year. * @return {Boolean} true if date is within a LeapYear, otherwise false. */ $D.isLeapYear = function (year) { return ((year % 4 === 0 && year % 100 !== 0) || year % 400 === 0); }; /** * Gets the number of days in the month, given a year and month value. Automatically corrects for LeapYear. * @param {Number} The year. * @param {Number} The month (0-11). * @return {Number} The number of days in the month. */ $D.getDaysInMonth = function (year, month) { if (!month && $D.validateMonth(year)) { month = year; year = Date.today().getFullYear(); } return [31, ($D.isLeapYear(year) ? 29 : 28), 31, 30, 31, 30, 31, 31, 30, 31, 30, 31][month]; }; $P.getDaysInMonth = function () { return $D.getDaysInMonth(this.getFullYear(), this.getMonth()); }; $D.getTimezoneAbbreviation = function (offset, dst) { var p, n = (dst || false) ? Date.CultureInfo.abbreviatedTimeZoneDST : Date.CultureInfo.abbreviatedTimeZoneStandard; for (p in n) { if (n.hasOwnProperty(p)) { if (n[p] === offset) { return p; } } } return null; }; $D.getTimezoneOffset = function (name, dst) { var i, a =[], z = Date.CultureInfo.timezones; if (!name) { name = (new Date()).getTimezone();} for (i = 0; i < z.length; i++) { if (z[i].name === name.toUpperCase()) { a.push(i); } } if (!z[a[0]]) { return null; } if (a.length === 1 || !dst) { return z[a[0]].offset; } else { for (i=0; i < a.length; i++) { if (z[a[i]].dst) { return z[a[i]].offset; } } } }; $D.getQuarter = function (d) { d = d || new Date(); // If no date supplied, use today var q = [1,2,3,4]; return q[Math.floor(d.getMonth() / 3)]; // ~~~ is a bitwise op. Faster than Math.floor }; $D.getDaysLeftInQuarter = function (d) { d = d || new Date(); var qEnd = new Date(d); qEnd.setMonth(qEnd.getMonth() + 3 - qEnd.getMonth() % 3, 0); return Math.floor((qEnd - d) / 8.64e7); }; // private var validate = function (n, min, max, name) { name = name ? name : "Object"; if (typeof n === "undefined") { return false; } else if (typeof n !== "number") { throw new TypeError(n + " is not a Number."); } else if (n < min || n > max) { // As failing validation is *not* an exceptional circumstance // lets not throw a RangeError Exception here. // It's semantically correct but it's not sensible. return false; } return true; }; /** * Validates the number is within an acceptable range for milliseconds [0-999]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateMillisecond = function (value) { return validate(value, 0, 999, "millisecond"); }; /** * Validates the number is within an acceptable range for seconds [0-59]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateSecond = function (value) { return validate(value, 0, 59, "second"); }; /** * Validates the number is within an acceptable range for minutes [0-59]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateMinute = function (value) { return validate(value, 0, 59, "minute"); }; /** * Validates the number is within an acceptable range for hours [0-23]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateHour = function (value) { return validate(value, 0, 23, "hour"); }; /** * Validates the number is within an acceptable range for the days in a month [0-MaxDaysInMonth]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateDay = function (value, year, month) { if (year === undefined || year === null || month === undefined || month === null) { return false;} return validate(value, 1, $D.getDaysInMonth(year, month), "day"); }; /** * Validates the number is within an acceptable range for months [0-11]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateWeek = function (value) { return validate(value, 0, 53, "week"); }; /** * Validates the number is within an acceptable range for months [0-11]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateMonth = function (value) { return validate(value, 0, 11, "month"); }; /** * Validates the number is within an acceptable range for years. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateYear = function (value) { /** * Per ECMAScript spec the range of times supported by Date objects is * exactly -100,000,000 days to +100,000,000 days measured relative to * midnight at the beginning of 01 January, 1970 UTC. * This gives a range of 8,640,000,000,000,000 milliseconds to either * side of 01 January, 1970 UTC. * * Earliest possible date: Tue, 20 Apr 271,822 B.C. 00:00:00 UTC * Latest possible date: Sat, 13 Sep 275,760 00:00:00 UTC */ return validate(value, -271822, 275760, "year"); }; $D.validateTimezone = function(value) { var timezones = {"ACDT":1,"ACST":1,"ACT":1,"ADT":1,"AEDT":1,"AEST":1,"AFT":1,"AKDT":1,"AKST":1,"AMST":1,"AMT":1,"ART":1,"AST":1,"AWDT":1,"AWST":1,"AZOST":1,"AZT":1,"BDT":1,"BIOT":1,"BIT":1,"BOT":1,"BRT":1,"BST":1,"BTT":1,"CAT":1,"CCT":1,"CDT":1,"CEDT":1,"CEST":1,"CET":1,"CHADT":1,"CHAST":1,"CHOT":1,"ChST":1,"CHUT":1,"CIST":1,"CIT":1,"CKT":1,"CLST":1,"CLT":1,"COST":1,"COT":1,"CST":1,"CT":1,"CVT":1,"CWST":1,"CXT":1,"DAVT":1,"DDUT":1,"DFT":1,"EASST":1,"EAST":1,"EAT":1,"ECT":1,"EDT":1,"EEDT":1,"EEST":1,"EET":1,"EGST":1,"EGT":1,"EIT":1,"EST":1,"FET":1,"FJT":1,"FKST":1,"FKT":1,"FNT":1,"GALT":1,"GAMT":1,"GET":1,"GFT":1,"GILT":1,"GIT":1,"GMT":1,"GST":1,"GYT":1,"HADT":1,"HAEC":1,"HAST":1,"HKT":1,"HMT":1,"HOVT":1,"HST":1,"ICT":1,"IDT":1,"IOT":1,"IRDT":1,"IRKT":1,"IRST":1,"IST":1,"JST":1,"KGT":1,"KOST":1,"KRAT":1,"KST":1,"LHST":1,"LINT":1,"MAGT":1,"MART":1,"MAWT":1,"MDT":1,"MET":1,"MEST":1,"MHT":1,"MIST":1,"MIT":1,"MMT":1,"MSK":1,"MST":1,"MUT":1,"MVT":1,"MYT":1,"NCT":1,"NDT":1,"NFT":1,"NPT":1,"NST":1,"NT":1,"NUT":1,"NZDT":1,"NZST":1,"OMST":1,"ORAT":1,"PDT":1,"PET":1,"PETT":1,"PGT":1,"PHOT":1,"PHT":1,"PKT":1,"PMDT":1,"PMST":1,"PONT":1,"PST":1,"PYST":1,"PYT":1,"RET":1,"ROTT":1,"SAKT":1,"SAMT":1,"SAST":1,"SBT":1,"SCT":1,"SGT":1,"SLST":1,"SRT":1,"SST":1,"SYOT":1,"TAHT":1,"THA":1,"TFT":1,"TJT":1,"TKT":1,"TLT":1,"TMT":1,"TOT":1,"TVT":1,"UCT":1,"ULAT":1,"UTC":1,"UYST":1,"UYT":1,"UZT":1,"VET":1,"VLAT":1,"VOLT":1,"VOST":1,"VUT":1,"WAKT":1,"WAST":1,"WAT":1,"WEDT":1,"WEST":1,"WET":1,"WST":1,"YAKT":1,"YEKT":1,"Z":1}; return (timezones[value] === 1); }; $D.validateTimezoneOffset= function(value) { // timezones go from +14hrs to -12hrs, the +X hours are negative offsets. return (value > -841 && value < 721); }; }()); (function () { var $D = Date, $P = $D.prototype, p = function (s, l) { if (!l) { l = 2; } return ("000" + s).slice(l * -1); }; var validateConfigObject = function (obj) { var result = {}, self = this, prop, testFunc; testFunc = function (prop, func, value) { if (prop === "day") { var month = (obj.month !== undefined) ? obj.month : self.getMonth(); var year = (obj.year !== undefined) ? obj.year : self.getFullYear(); return $D[func](value, year, month); } else { return $D[func](value); } }; for (prop in obj) { if (Object.prototype.hasOwnProperty.call(obj, prop)) { var func = "validate" + prop.charAt(0).toUpperCase() + prop.slice(1); if ($D[func] && obj[prop] !== null && testFunc(prop, func, obj[prop])) { result[prop] = obj[prop]; } } } return result; }; /** * Resets the time of this Date object to 12:00 AM (00:00), which is the start of the day. * @param {Boolean} .clone() this date instance before clearing Time * @return {Date} this */ $P.clearTime = function () { this.setHours(0); this.setMinutes(0); this.setSeconds(0); this.setMilliseconds(0); return this; }; /** * Resets the time of this Date object to the current time ('now'). * @return {Date} this */ $P.setTimeToNow = function () { var n = new Date(); this.setHours(n.getHours()); this.setMinutes(n.getMinutes()); this.setSeconds(n.getSeconds()); this.setMilliseconds(n.getMilliseconds()); return this; }; /** * Returns a new Date object that is an exact date and time copy of the original instance. * @return {Date} A new Date instance */ $P.clone = function () { return new Date(this.getTime()); }; /** * Compares this instance to a Date object and returns an number indication of their relative values. * @param {Date} Date object to compare [Required] * @return {Number} -1 = this is lessthan date. 0 = values are equal. 1 = this is greaterthan date. */ $P.compareTo = function (date) { return Date.compare(this, date); }; /** * Compares this instance to another Date object and returns true if they are equal. * @param {Date} Date object to compare. If no date to compare, new Date() [now] is used. * @return {Boolean} true if dates are equal. false if they are not equal. */ $P.equals = function (date) { return Date.equals(this, (date !== undefined ? date : new Date())); }; /** * Determines if this instance is between a range of two dates or equal to either the start or end dates. * @param {Date} Start of range [Required] * @param {Date} End of range [Required] * @return {Boolean} true is this is between or equal to the start and end dates, else false */ $P.between = function (start, end) { return this.getTime() >= start.getTime() && this.getTime() <= end.getTime(); }; /** * Determines if this date occurs after the date to compare to. * @param {Date} Date object to compare. If no date to compare, new Date() ("now") is used. * @return {Boolean} true if this date instance is greater than the date to compare to (or "now"), otherwise false. */ $P.isAfter = function (date) { return this.compareTo(date || new Date()) === 1; }; /** * Determines if this date occurs before the date to compare to. * @param {Date} Date object to compare. If no date to compare, new Date() ("now") is used. * @return {Boolean} true if this date instance is less than the date to compare to (or "now"). */ $P.isBefore = function (date) { return (this.compareTo(date || new Date()) === -1); }; /** * Determines if the current Date instance occurs today. * @return {Boolean} true if this date instance is 'today', otherwise false. */ /** * Determines if the current Date instance occurs on the same Date as the supplied 'date'. * If no 'date' to compare to is provided, the current Date instance is compared to 'today'. * @param {date} Date object to compare. If no date to compare, the current Date ("now") is used. * @return {Boolean} true if this Date instance occurs on the same Day as the supplied 'date'. */ $P.isToday = $P.isSameDay = function (date) { return this.clone().clearTime().equals((date || new Date()).clone().clearTime()); }; /** * Adds the specified number of milliseconds to this instance. * @param {Number} The number of milliseconds to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addMilliseconds = function (value) { if (!value) { return this; } this.setTime(this.getTime() + value * 1); return this; }; /** * Adds the specified number of seconds to this instance. * @param {Number} The number of seconds to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addSeconds = function (value) { if (!value) { return this; } return this.addMilliseconds(value * 1000); }; /** * Adds the specified number of seconds to this instance. * @param {Number} The number of seconds to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addMinutes = function (value) { if (!value) { return this; } return this.addMilliseconds(value * 60000); // 60*1000 }; /** * Adds the specified number of hours to this instance. * @param {Number} The number of hours to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addHours = function (value) { if (!value) { return this; } return this.addMilliseconds(value * 3600000); // 60*60*1000 }; /** * Adds the specified number of days to this instance. * @param {Number} The number of days to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addDays = function (value) { if (!value) { return this; } this.setDate(this.getDate() + value * 1); return this; }; /** * Adds the specified number of weekdays (ie - not sat or sun) to this instance. * @param {Number} The number of days to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addWeekdays = function (value) { if (!value) { return this; } var day = this.getDay(); var weeks = (Math.ceil(Math.abs(value)/7)); if (day === 0 || day === 6) { if (value > 0) { this.next().monday(); this.addDays(-1); day = this.getDay(); } } if (value < 0) { while (value < 0) { this.addDays(-1); day = this.getDay(); if (day !== 0 && day !== 6) { value++; } } return this; } else if (value > 5 || (6-day) <= value) { value = value + (weeks * 2); } return this.addDays(value); }; /** * Adds the specified number of weeks to this instance. * @param {Number} The number of weeks to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addWeeks = function (value) { if (!value) { return this; } return this.addDays(value * 7); }; /** * Adds the specified number of months to this instance. * @param {Number} The number of months to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addMonths = function (value) { if (!value) { return this; } var n = this.getDate(); this.setDate(1); this.setMonth(this.getMonth() + value * 1); this.setDate(Math.min(n, $D.getDaysInMonth(this.getFullYear(), this.getMonth()))); return this; }; $P.addQuarters = function (value) { if (!value) { return this; } // note this will take you to the same point in the quarter as you are now. // i.e. - if you are 15 days into the quarter you'll be 15 days into the resulting one. // bonus: this allows adding fractional quarters return this.addMonths(value * 3); }; /** * Adds the specified number of years to this instance. * @param {Number} The number of years to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addYears = function (value) { if (!value) { return this; } return this.addMonths(value * 12); }; /** * Adds (or subtracts) to the value of the years, months, weeks, days, hours, minutes, seconds, milliseconds of the date instance using given configuration object. Positive and Negative values allowed. * Example

	Date.today().add( { days: 1, months: 1 } )

	new Date().add( { years: -1 } )
	
* @param {Object} Configuration object containing attributes (months, days, etc.) * @return {Date} this */ $P.add = function (config) { if (typeof config === "number") { this._orient = config; return this; } var x = config; if (x.day) { // If we should be a different date than today (eg: for 'tomorrow -1d', etc). // Should only effect parsing, not direct usage (eg, Finish and FinishExact) if ((x.day - this.getDate()) !== 0) { this.setDate(x.day); } } if (x.milliseconds) { this.addMilliseconds(x.milliseconds); } if (x.seconds) { this.addSeconds(x.seconds); } if (x.minutes) { this.addMinutes(x.minutes); } if (x.hours) { this.addHours(x.hours); } if (x.weeks) { this.addWeeks(x.weeks); } if (x.months) { this.addMonths(x.months); } if (x.years) { this.addYears(x.years); } if (x.days) { this.addDays(x.days); } return this; }; /** * Get the week number. Week one (1) is the week which contains the first Thursday of the year. Monday is considered the first day of the week. * The .getWeek() function does NOT convert the date to UTC. The local datetime is used. * Please use .getISOWeek() to get the week of the UTC converted date. * @return {Number} 1 to 53 */ $P.getWeek = function (utc) { // Create a copy of this date object var self, target = new Date(this.valueOf()); if (utc) { target.addMinutes(target.getTimezoneOffset()); self = target.clone(); } else { self = this; } // ISO week date weeks start on monday // so correct the day number var dayNr = (self.getDay() + 6) % 7; // ISO 8601 states that week 1 is the week // with the first thursday of that year. // Set the target date to the thursday in the target week target.setDate(target.getDate() - dayNr + 3); // Store the millisecond value of the target date var firstThursday = target.valueOf(); // Set the target to the first thursday of the year // First set the target to january first target.setMonth(0, 1); // Not a thursday? Correct the date to the next thursday if (target.getDay() !== 4) { target.setMonth(0, 1 + ((4 - target.getDay()) + 7) % 7); } // The weeknumber is the number of weeks between the // first thursday of the year and the thursday in the target week return 1 + Math.ceil((firstThursday - target) / 604800000); // 604800000 = 7 * 24 * 3600 * 1000 }; /** * Get the ISO 8601 week number. Week one ("01") is the week which contains the first Thursday of the year. Monday is considered the first day of the week. * The .getISOWeek() function does convert the date to it's UTC value. Please use .getWeek() to get the week of the local date. * @return {String} "01" to "53" */ $P.getISOWeek = function () { return p(this.getWeek(true)); }; /** * Moves the date to Monday of the week set. Week one (1) is the week which contains the first Thursday of the year. * @param {Number} A Number (1 to 53) that represents the week of the year. * @return {Date} this */ $P.setWeek = function (n) { if ((n - this.getWeek()) === 0) { if (this.getDay() !== 1) { return this.moveToDayOfWeek(1, (this.getDay() > 1 ? -1 : 1)); } else { return this; } } else { return this.moveToDayOfWeek(1, (this.getDay() > 1 ? -1 : 1)).addWeeks(n - this.getWeek()); } }; $P.setQuarter = function (qtr) { var month = Math.abs(((qtr-1) * 3) + 1); return this.setMonth(month, 1); }; $P.getQuarter = function () { return Date.getQuarter(this); }; $P.getDaysLeftInQuarter = function () { return Date.getDaysLeftInQuarter(this); }; /** * Moves the date to the next n'th occurrence of the dayOfWeek starting from the beginning of the month. The number (-1) is a magic number and will return the last occurrence of the dayOfWeek in the month. * @param {Number} The dayOfWeek to move to * @param {Number} The n'th occurrence to move to. Use (-1) to return the last occurrence in the month * @return {Date} this */ $P.moveToNthOccurrence = function (dayOfWeek, occurrence) { if (dayOfWeek === "Weekday") { if (occurrence > 0) { this.moveToFirstDayOfMonth(); if (this.is().weekday()) { occurrence -= 1; } } else if (occurrence < 0) { this.moveToLastDayOfMonth(); if (this.is().weekday()) { occurrence += 1; } } else { return this; } return this.addWeekdays(occurrence); } var shift = 0; if (occurrence > 0) { shift = occurrence - 1; } else if (occurrence === -1) { this.moveToLastDayOfMonth(); if (this.getDay() !== dayOfWeek) { this.moveToDayOfWeek(dayOfWeek, -1); } return this; } return this.moveToFirstDayOfMonth().addDays(-1).moveToDayOfWeek(dayOfWeek, +1).addWeeks(shift); }; var moveToN = function (getFunc, addFunc, nVal) { return function (value, orient) { var diff = (value - this[getFunc]() + nVal * (orient || +1)) % nVal; return this[addFunc]((diff === 0) ? diff += nVal * (orient || +1) : diff); }; }; /** * Move to the next or last dayOfWeek based on the orient value. * @param {Number} The dayOfWeek to move to * @param {Number} Forward (+1) or Back (-1). Defaults to +1. [Optional] * @return {Date} this */ $P.moveToDayOfWeek = moveToN("getDay", "addDays", 7); /** * Move to the next or last month based on the orient value. * @param {Number} The month to move to. 0 = January, 11 = December * @param {Number} Forward (+1) or Back (-1). Defaults to +1. [Optional] * @return {Date} this */ $P.moveToMonth = moveToN("getMonth", "addMonths", 12); /** * Get the Ordinate of the current day ("th", "st", "rd"). * @return {String} */ $P.getOrdinate = function () { var num = this.getDate(); return ord(num); }; /** * Get the Ordinal day (numeric day number) of the year, adjusted for leap year. * @return {Number} 1 through 365 (366 in leap years) */ $P.getOrdinalNumber = function () { return Math.ceil((this.clone().clearTime() - new Date(this.getFullYear(), 0, 1)) / 86400000) + 1; }; /** * Get the time zone abbreviation of the current date. * @return {String} The abbreviated time zone name (e.g. "EST") */ $P.getTimezone = function () { return $D.getTimezoneAbbreviation(this.getUTCOffset(), this.isDaylightSavingTime()); }; $P.setTimezoneOffset = function (offset) { var here = this.getTimezoneOffset(), there = Number(offset) * -6 / 10; return (there || there === 0) ? this.addMinutes(there - here) : this; }; $P.setTimezone = function (offset) { return this.setTimezoneOffset($D.getTimezoneOffset(offset)); }; /** * Indicates whether Daylight Saving Time is observed in the current time zone. * @return {Boolean} true|false */ $P.hasDaylightSavingTime = function () { return (Date.today().set({month: 0, day: 1}).getTimezoneOffset() !== Date.today().set({month: 6, day: 1}).getTimezoneOffset()); }; /** * Indicates whether this Date instance is within the Daylight Saving Time range for the current time zone. * @return {Boolean} true|false */ $P.isDaylightSavingTime = function () { return Date.today().set({month: 0, day: 1}).getTimezoneOffset() !== this.getTimezoneOffset(); }; /** * Get the offset from UTC of the current date. * @return {String} The 4-character offset string prefixed with + or - (e.g. "-0500") */ $P.getUTCOffset = function (offset) { var n = (offset || this.getTimezoneOffset()) * -10 / 6, r; if (n < 0) { r = (n - 10000).toString(); return r.charAt(0) + r.substr(2); } else { r = (n + 10000).toString(); return "+" + r.substr(1); } }; /** * Returns the number of milliseconds between this date and date. * @param {Date} Defaults to now * @return {Number} The diff in milliseconds */ $P.getElapsed = function (date) { return (date || new Date()) - this; }; /** * Set the value of year, month, day, hour, minute, second, millisecond of date instance using given configuration object. * Example

	Date.today().set( { day: 20, month: 1 } )

	new Date().set( { millisecond: 0 } )
	
* * @param {Object} Configuration object containing attributes (month, day, etc.) * @return {Date} this */ $P.set = function (config) { config = validateConfigObject.call(this, config); var key; for (key in config) { if (Object.prototype.hasOwnProperty.call(config, key)) { var name = key.charAt(0).toUpperCase() + key.slice(1); var addFunc, getFunc; if (key !== "week" && key !== "month" && key !== "timezone" && key !== "timezoneOffset") { name += "s"; } addFunc = "add" + name; getFunc = "get" + name; if (key === "month") { addFunc = addFunc + "s"; } else if (key === "year"){ getFunc = "getFullYear"; } if (key !== "day" && key !== "timezone" && key !== "timezoneOffset" && key !== "week" && key !== "hour") { this[addFunc](config[key] - this[getFunc]()); } else if ( key === "timezone"|| key === "timezoneOffset" || key === "week" || key === "hour") { this["set"+name](config[key]); } } } // day has to go last because you can't validate the day without first knowing the month if (config.day) { this.addDays(config.day - this.getDate()); } return this; }; /** * Moves the date to the first day of the month. * @return {Date} this */ $P.moveToFirstDayOfMonth = function () { return this.set({ day: 1 }); }; /** * Moves the date to the last day of the month. * @return {Date} this */ $P.moveToLastDayOfMonth = function () { return this.set({ day: $D.getDaysInMonth(this.getFullYear(), this.getMonth())}); }; /** * Converts the value of the current Date object to its equivalent string representation. * Format Specifiers * CUSTOM DATE AND TIME FORMAT STRINGS * Format Description Example * ------ --------------------------------------------------------------------------- ----------------------- * s The seconds of the minute between 0-59. "0" to "59" * ss The seconds of the minute with leading zero if required. "00" to "59" * * m The minute of the hour between 0-59. "0" or "59" * mm The minute of the hour with leading zero if required. "00" or "59" * * h The hour of the day between 1-12. "1" to "12" * hh The hour of the day with leading zero if required. "01" to "12" * * H The hour of the day between 0-23. "0" to "23" * HH The hour of the day with leading zero if required. "00" to "23" * * d The day of the month between 1 and 31. "1" to "31" * dd The day of the month with leading zero if required. "01" to "31" * ddd Abbreviated day name. Date.CultureInfo.abbreviatedDayNames. "Mon" to "Sun" * dddd The full day name. Date.CultureInfo.dayNames. "Monday" to "Sunday" * * M The month of the year between 1-12. "1" to "12" * MM The month of the year with leading zero if required. "01" to "12" * MMM Abbreviated month name. Date.CultureInfo.abbreviatedMonthNames. "Jan" to "Dec" * MMMM The full month name. Date.CultureInfo.monthNames. "January" to "December" * * yy The year as a two-digit number. "99" or "08" * yyyy The full four digit year. "1999" or "2008" * * t Displays the first character of the A.M./P.M. designator. "A" or "P" * Date.CultureInfo.amDesignator or Date.CultureInfo.pmDesignator * tt Displays the A.M./P.M. designator. "AM" or "PM" * Date.CultureInfo.amDesignator or Date.CultureInfo.pmDesignator * * S The ordinal suffix ("st, "nd", "rd" or "th") of the current day. "st, "nd", "rd" or "th" * * STANDARD DATE AND TIME FORMAT STRINGS * Format Description Example *------ --------------------------------------------------------------------------- ----------------------- * d The CultureInfo shortDate Format Pattern "M/d/yyyy" * D The CultureInfo longDate Format Pattern "dddd, MMMM dd, yyyy" * F The CultureInfo fullDateTime Format Pattern "dddd, MMMM dd, yyyy h:mm:ss tt" * m The CultureInfo monthDay Format Pattern "MMMM dd" * r The CultureInfo rfc1123 Format Pattern "ddd, dd MMM yyyy HH:mm:ss GMT" * s The CultureInfo sortableDateTime Format Pattern "yyyy-MM-ddTHH:mm:ss" * t The CultureInfo shortTime Format Pattern "h:mm tt" * T The CultureInfo longTime Format Pattern "h:mm:ss tt" * u The CultureInfo universalSortableDateTime Format Pattern "yyyy-MM-dd HH:mm:ssZ" * y The CultureInfo yearMonth Format Pattern "MMMM, yyyy" * * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @return {String} A string representation of the current Date object. */ var ord = function (n) { switch (n * 1) { case 1: case 21: case 31: return "st"; case 2: case 22: return "nd"; case 3: case 23: return "rd"; default: return "th"; } }; var parseStandardFormats = function (format) { var y, c = Date.CultureInfo.formatPatterns; switch (format) { case "d": return this.toString(c.shortDate); case "D": return this.toString(c.longDate); case "F": return this.toString(c.fullDateTime); case "m": return this.toString(c.monthDay); case "r": case "R": y = this.clone().addMinutes(this.getTimezoneOffset()); return y.toString(c.rfc1123) + " GMT"; case "s": return this.toString(c.sortableDateTime); case "t": return this.toString(c.shortTime); case "T": return this.toString(c.longTime); case "u": y = this.clone().addMinutes(this.getTimezoneOffset()); return y.toString(c.universalSortableDateTime); case "y": return this.toString(c.yearMonth); default: return false; } }; var parseFormatStringsClosure = function (context) { return function (m) { if (m.charAt(0) === "\\") { return m.replace("\\", ""); } switch (m) { case "hh": return p(context.getHours() < 13 ? (context.getHours() === 0 ? 12 : context.getHours()) : (context.getHours() - 12)); case "h": return context.getHours() < 13 ? (context.getHours() === 0 ? 12 : context.getHours()) : (context.getHours() - 12); case "HH": return p(context.getHours()); case "H": return context.getHours(); case "mm": return p(context.getMinutes()); case "m": return context.getMinutes(); case "ss": return p(context.getSeconds()); case "s": return context.getSeconds(); case "yyyy": return p(context.getFullYear(), 4); case "yy": return p(context.getFullYear()); case "y": return context.getFullYear(); case "E": case "dddd": return Date.CultureInfo.dayNames[context.getDay()]; case "ddd": return Date.CultureInfo.abbreviatedDayNames[context.getDay()]; case "dd": return p(context.getDate()); case "d": return context.getDate(); case "MMMM": return Date.CultureInfo.monthNames[context.getMonth()]; case "MMM": return Date.CultureInfo.abbreviatedMonthNames[context.getMonth()]; case "MM": return p((context.getMonth() + 1)); case "M": return context.getMonth() + 1; case "t": return context.getHours() < 12 ? Date.CultureInfo.amDesignator.substring(0, 1) : Date.CultureInfo.pmDesignator.substring(0, 1); case "tt": return context.getHours() < 12 ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator; case "S": return ord(context.getDate()); case "W": return context.getWeek(); case "WW": return context.getISOWeek(); case "Q": return "Q" + context.getQuarter(); case "q": return String(context.getQuarter()); case "z": return context.getTimezone(); case "Z": case "X": return Date.getTimezoneOffset(context.getTimezone()); case "ZZ": // Timezone offset in seconds return context.getTimezoneOffset() * -60; case "u": return context.getDay(); case "L": return ($D.isLeapYear(context.getFullYear())) ? 1 : 0; case "B": // Swatch Internet Time (.beats) return "@"+((context.getUTCSeconds() + (context.getUTCMinutes()*60) + ((context.getUTCHours()+1)*3600))/86.4); default: return m; } }; }; $P.toString = function (format, ignoreStandards) { // Standard Date and Time Format Strings. Formats pulled from CultureInfo file and // may vary by culture. if (!ignoreStandards && format && format.length === 1) { output = parseStandardFormats.call(this, format); if (output) { return output; } } var parseFormatStrings = parseFormatStringsClosure(this); return format ? format.replace(/((\\)?(dd?d?d?|MM?M?M?|yy?y?y?|hh?|HH?|mm?|ss?|tt?|S|q|Q|WW?W?W?)(?![^\[]*\]))/g, parseFormatStrings).replace(/\[|\]/g, "") : this._toString(); }; }()); /************************************************************* * SugarPak - Domain Specific Language - Syntactical Sugar * *************************************************************/ (function () { var $D = Date, $P = $D.prototype, $N = Number.prototype; // private $P._orient = +1; // private $P._nth = null; // private $P._is = false; // private $P._same = false; // private $P._isSecond = false; // private $N._dateElement = "days"; /** * Moves the date to the next instance of a date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.today().next().friday();
	Date.today().next().fri();
	Date.today().next().march();
	Date.today().next().mar();
	Date.today().next().week();
	
* * @return {Date} date */ $P.next = function () { this._move = true; this._orient = +1; return this; }; /** * Creates a new Date (Date.today()) and moves the date to the next instance of the date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.next().friday();
	Date.next().fri();
	Date.next().march();
	Date.next().mar();
	Date.next().week();
	
* * @return {Date} date */ $D.next = function () { return $D.today().next(); }; /** * Moves the date to the previous instance of a date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.today().last().friday();
	Date.today().last().fri();
	Date.today().last().march();
	Date.today().last().mar();
	Date.today().last().week();
	
* * @return {Date} date */ $P.last = $P.prev = $P.previous = function () { this._move = true; this._orient = -1; return this; }; /** * Creates a new Date (Date.today()) and moves the date to the previous instance of the date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.last().friday();
	Date.last().fri();
	Date.previous().march();
	Date.prev().mar();
	Date.last().week();
	
* * @return {Date} date */ $D.last = $D.prev = $D.previous = function () { return $D.today().last(); }; /** * Performs a equality check when followed by either a month name, day name or .weekday() function. * Example

	Date.today().is().friday(); // true|false
	Date.today().is().fri();
	Date.today().is().march();
	Date.today().is().mar();
	
* * @return {Boolean} true|false */ $P.is = function () { this._is = true; return this; }; /** * Determines if two date objects occur on/in exactly the same instance of the subsequent date part function. * The function .same() must be followed by a date part function (example: .day(), .month(), .year(), etc). * * An optional Date can be passed in the date part function. If now date is passed as a parameter, 'Now' is used. * * The following example demonstrates how to determine if two dates fall on the exact same day. * * Example

	var d1 = Date.today(); // today at 00:00
	var d2 = new Date();   // exactly now.

	// Do they occur on the same day?
	d1.same().day(d2); // true
	
	// Do they occur on the same hour?
	d1.same().hour(d2); // false, unless d2 hour is '00' (midnight).
	
	// What if it's the same day, but one year apart?
	var nextYear = Date.today().add(1).year();

	d1.same().day(nextYear); // false, because the dates must occur on the exact same day. 
	
* * Scenario: Determine if a given date occurs during some week period 2 months from now. * * Example

	var future = Date.today().add(2).months();
	return someDate.same().week(future); // true|false;
	
* * @return {Boolean} true|false */ $P.same = function () { this._same = true; this._isSecond = false; return this; }; /** * Determines if the current date/time occurs during Today. Must be preceded by the .is() function. * Example

	someDate.is().today();    // true|false
	new Date().is().today();  // true
	Date.today().is().today();// true
	Date.today().add(-1).day().is().today(); // false
	
* * @return {Boolean} true|false */ $P.today = function () { return this.same().day(); }; /** * Determines if the current date is a weekday. This function must be preceded by the .is() function. * Example

	Date.today().is().weekday(); // true|false
	
* * @return {Boolean} true|false */ $P.weekday = function () { if (this._nth) { return df("Weekday").call(this); } if (this._move) { return this.addWeekdays(this._orient); } if (this._is) { this._is = false; return (!this.is().sat() && !this.is().sun()); } return false; }; /** * Determines if the current date is on the weekend. This function must be preceded by the .is() function. * Example

	Date.today().is().weekend(); // true|false
	
* * @return {Boolean} true|false */ $P.weekend = function () { if (this._is) { this._is = false; return (this.is().sat() || this.is().sun()); } return false; }; /** * Sets the Time of the current Date instance. A string "6:15 pm" or config object {hour:18, minute:15} are accepted. * Example

	// Set time to 6:15pm with a String
	Date.today().at("6:15pm");

	// Set time to 6:15pm with a config object
	Date.today().at({hour:18, minute:15});
	
* * @return {Date} date */ $P.at = function (time) { return (typeof time === "string") ? $D.parse(this.toString("d") + " " + time) : this.set(time); }; /** * Creates a new Date() and adds this (Number) to the date based on the preceding date element function (eg. second|minute|hour|day|month|year). * Example

	// Undeclared Numbers must be wrapped with parentheses. Requirment of JavaScript.
	(3).days().fromNow();
	(6).months().fromNow();

	// Declared Number variables do not require parentheses. 
	var n = 6;
	n.months().fromNow();
	
* * @return {Date} A new Date instance */ $N.fromNow = $N.after = function (date) { var c = {}; c[this._dateElement] = this; return ((!date) ? new Date() : date.clone()).add(c); }; /** * Creates a new Date() and subtract this (Number) from the date based on the preceding date element function (eg. second|minute|hour|day|month|year). * Example

	// Undeclared Numbers must be wrapped with parentheses. Requirment of JavaScript.
	(3).days().ago();
	(6).months().ago();

	// Declared Number variables do not require parentheses. 
	var n = 6;
	n.months().ago();
	
* * @return {Date} A new Date instance */ $N.ago = $N.before = function (date) { var c = {}, s = (this._dateElement[this._dateElement.length-1] !== "s") ? this._dateElement + "s" : this._dateElement; c[s] = this * -1; return ((!date) ? new Date() : date.clone()).add(c); }; // Do NOT modify the following string tokens. These tokens are used to build dynamic functions. // All culture-specific strings can be found in the CultureInfo files. var dx = ("sunday monday tuesday wednesday thursday friday saturday").split(/\s/), mx = ("january february march april may june july august september october november december").split(/\s/), px = ("Millisecond Second Minute Hour Day Week Month Year Quarter Weekday").split(/\s/), pxf = ("Milliseconds Seconds Minutes Hours Date Week Month FullYear Quarter").split(/\s/), nth = ("final first second third fourth fifth").split(/\s/), de; /** * Returns an object literal of all the date parts. * Example

	var o = new Date().toObject();
	
	// { year: 2008, month: 4, week: 20, day: 13, hour: 18, minute: 9, second: 32, millisecond: 812 }
	
	// The object properties can be referenced directly from the object.
	
	alert(o.day);  // alerts "13"
	alert(o.year); // alerts "2008"
	
* * @return {Date} An object literal representing the original date object. */ $P.toObject = function () { var o = {}; for (var i = 0; i < px.length; i++) { if (this["get" + pxf[i]]) { o[px[i].toLowerCase()] = this["get" + pxf[i]](); } } return o; }; /** * Returns a date created from an object literal. Ignores the .week property if set in the config. * Example

	var o = new Date().toObject();
	
	return Date.fromObject(o); // will return the same date. 

	var o2 = {month: 1, day: 20, hour: 18}; // birthday party!
	Date.fromObject(o2);
	
* * @return {Date} An object literal representing the original date object. */ $D.fromObject = function(config) { config.week = null; return Date.today().set(config); }; // Create day name functions and abbreviated day name functions (eg. monday(), friday(), fri()). var df = function (n) { return function () { if (this._is) { this._is = false; return this.getDay() === n; } if (this._move) { this._move = null; } if (this._nth !== null) { // If the .second() function was called earlier, remove the _orient // from the date, and then continue. // This is required because 'second' can be used in two different context. // // Example // // Date.today().add(1).second(); // Date.march().second().monday(); // // Things get crazy with the following... // Date.march().add(1).second().second().monday(); // but it works!! // if (this._isSecond) { this.addSeconds(this._orient * -1); } // make sure we reset _isSecond this._isSecond = false; var ntemp = this._nth; this._nth = null; var temp = this.clone().moveToLastDayOfMonth(); this.moveToNthOccurrence(n, ntemp); if (this > temp) { throw new RangeError($D.getDayName(n) + " does not occur " + ntemp + " times in the month of " + $D.getMonthName(temp.getMonth()) + " " + temp.getFullYear() + "."); } return this; } return this.moveToDayOfWeek(n, this._orient); }; }; var sdf = function (n) { return function () { var t = $D.today(), shift = n - t.getDay(); if (n === 0 && Date.CultureInfo.firstDayOfWeek === 1 && t.getDay() !== 0) { shift = shift + 7; } return t.addDays(shift); }; }; // Create month name functions and abbreviated month name functions (eg. january(), march(), mar()). var month_instance_functions = function (n) { return function () { if (this._is) { this._is = false; return this.getMonth() === n; } return this.moveToMonth(n, this._orient); }; }; var month_static_functions = function (n) { return function () { return $D.today().set({ month: n, day: 1 }); }; }; var processTerms = function (names, staticFunc, instanceFunc) { for (var i = 0; i < names.length; i++) { // Create constant static Name variables. $D[names[i].toUpperCase()] = $D[names[i].toUpperCase().substring(0, 3)] = i; // Create Name functions. $D[names[i]] = $D[names[i].substring(0, 3)] = staticFunc(i); // Create Name instance functions. $P[names[i]] = $P[names[i].substring(0, 3)] = instanceFunc(i); } }; processTerms(dx, sdf, df); processTerms(mx, month_static_functions, month_instance_functions); // Create date element functions and plural date element functions used with Date (eg. day(), days(), months()). var ef = function (j) { return function () { // if the .second() function was called earlier, the _orient // has alread been added. Just return this and reset _isSecond. if (this._isSecond) { this._isSecond = false; return this; } if (this._same) { this._same = this._is = false; var o1 = this.toObject(), o2 = (arguments[0] || new Date()).toObject(), v = "", k = j.toLowerCase(); // the substr trick with -1 doesn't work in IE8 or less k = (k[k.length-1] === "s") ? k.substring(0,k.length-1) : k; for (var m = (px.length - 1); m > -1; m--) { v = px[m].toLowerCase(); if (o1[v] !== o2[v]) { return false; } if (k === v) { break; } } return true; } if (j.substring(j.length - 1) !== "s") { j += "s"; } if (this._move) { this._move = null; } return this["add" + j](this._orient); }; }; var nf = function (n) { return function () { this._dateElement = n; return this; }; }; for (var k = 0; k < px.length; k++) { de = px[k].toLowerCase(); if(de !== "weekday") { // Create date element functions and plural date element functions used with Date (eg. day(), days(), months()). $P[de] = $P[de + "s"] = ef(px[k]); // Create date element functions and plural date element functions used with Number (eg. day(), days(), months()). $N[de] = $N[de + "s"] = nf(de + "s"); } } $P._ss = ef("Second"); var nthfn = function (n) { return function (dayOfWeek) { if (this._same) { return this._ss(arguments[0]); } if (dayOfWeek || dayOfWeek === 0) { return this.moveToNthOccurrence(dayOfWeek, n); } this._nth = n; // if the operator is 'second' add the _orient, then deal with it later... if (n === 2 && (dayOfWeek === undefined || dayOfWeek === null)) { this._isSecond = true; return this.addSeconds(this._orient); } return this; }; }; for (var l = 0; l < nth.length; l++) { $P[nth[l]] = (l === 0) ? nthfn(-1) : nthfn(l); } }()); (function () { "use strict"; Date.Parsing = { Exception: function (s) { this.message = "Parse error at '" + s.substring(0, 10) + " ...'"; } }; var $P = Date.Parsing; var dayOffsets = { standard: [0,31,59,90,120,151,181,212,243,273,304,334], leap: [0,31,60,91,121,152,182,213,244,274,305,335] }; $P.isLeapYear = function(year) { return ((year % 4 === 0) && (year % 100 !== 0)) || (year % 400 === 0); }; var utils = { multiReplace : function (str, hash ) { var key; for (key in hash) { if (Object.prototype.hasOwnProperty.call(hash, key)) { var regex; if (typeof hash[key] === "function") { } else { regex = (hash[key] instanceof RegExp) ? hash[key] : new RegExp(hash[key], "g"); } str = str.replace(regex, key); } } return str; }, getDayOfYearFromWeek : function (obj) { var d, jan4, offset; obj.weekDay = (!obj.weekDay && obj.weekDay !== 0) ? 1 : obj.weekDay; d = new Date(obj.year, 0, 4); jan4 = d.getDay() === 0 ? 7 : d.getDay(); // JS is 0 indexed on Sunday. offset = jan4+3; obj.dayOfYear = ((obj.week * 7) + (obj.weekDay === 0 ? 7 : obj.weekDay))-offset; return obj; }, getDayOfYear : function (obj, dayOffset) { if (!obj.dayOfYear) { obj = utils.getDayOfYearFromWeek(obj); } for (var i=0;i <= dayOffset.length;i++) { if (obj.dayOfYear < dayOffset[i] || i === dayOffset.length) { obj.day = obj.day ? obj.day : (obj.dayOfYear - dayOffset[i-1]); break; } else { obj.month = i; } } return obj; }, adjustForTimeZone : function (obj, date) { var offset; if (obj.zone.toUpperCase() === "Z" || (obj.zone_hours === 0 && obj.zone_minutes === 0)) { // it's UTC/GML so work out the current timeszone offset offset = -date.getTimezoneOffset(); } else { offset = (obj.zone_hours*60) + (obj.zone_minutes || 0); if (obj.zone_sign === "+") { offset *= -1; } offset -= date.getTimezoneOffset(); } date.setMinutes(date.getMinutes()+offset); return date; }, setDefaults : function (obj) { obj.year = obj.year || Date.today().getFullYear(); obj.hours = obj.hours || 0; obj.minutes = obj.minutes || 0; obj.seconds = obj.seconds || 0; obj.milliseconds = obj.milliseconds || 0; if (!(!obj.month && (obj.week || obj.dayOfYear))) { // if we have a month, or if we don't but don't have the day calculation data obj.month = obj.month || 0; obj.day = obj.day || 1; } return obj; }, dataNum: function (data, mod, explict, postProcess) { var dataNum = data*1; if (mod) { if (postProcess) { return data ? mod(data)*1 : data; } else { return data ? mod(dataNum) : data; } } else if (!explict){ return data ? dataNum : data; } else { return (data && typeof data !== "undefined") ? dataNum : data; } }, timeDataProcess: function (obj) { var timeObj = {}; for (var x in obj.data) { if (obj.data.hasOwnProperty(x)) { timeObj[x] = obj.ignore[x] ? obj.data[x] : utils.dataNum(obj.data[x], obj.mods[x], obj.explict[x], obj.postProcess[x]); } } if (obj.data.secmins) { obj.data.secmins = obj.data.secmins.replace(",", ".") * 60; if (!timeObj.minutes) { timeObj.minutes = obj.data.secmins; } else if (!timeObj.seconds) { timeObj.seconds = obj.data.secmins; } delete obj.secmins; } return timeObj; }, buildTimeObjectFromData: function (data) { var time = utils.timeDataProcess({ data: { year : data[1], month : data[5], day : data[7], week : data[8], dayOfYear : data[10], hours : data[15], zone_hours : data[23], zone_minutes : data[24], zone : data[21], zone_sign : data[22], weekDay : data[9], minutes: data[16], seconds: data[19], milliseconds: data[20], secmins: data[18] }, mods: { month: function(data) { return data-1; }, weekDay: function (data) { data = Math.abs(data); return (data === 7 ? 0 : data); }, minutes: function (data) { return data.replace(":",""); }, seconds: function (data) { return Math.floor( (data.replace(":","").replace(",","."))*1 ); }, milliseconds: function (data) { return (data.replace(",",".")*1000); } }, postProcess: { minutes: true, seconds: true, milliseconds: true }, explict: { zone_hours: true, zone_minutes: true }, ignore: { zone: true, zone_sign: true, secmins: true } }); return time; }, addToHash: function (hash, keys, data) { keys = keys; data = data; var len = keys.length; for (var i = 0; i < len; i++) { hash[keys[i]] = data[i]; } return hash; }, combineRegex: function (r1, r2) { return new RegExp("(("+r1.source+")\\s("+r2.source+"))"); }, getDateNthString: function(add, last, inc){ if (add) { return Date.today().addDays(inc).toString("d"); } else if (last) { return Date.today().last()[inc]().toString("d"); } }, buildRegexData: function (array) { var arr = []; var len = array.length; for (var i=0; i < len; i++) { if (Object.prototype.toString.call(array[i]) === '[object Array]') { // oldIE compat version of Array.isArray arr.push(this.combineRegex(array[i][0], array[i][1])); } else { arr.push(array[i]); } } return arr; } }; $P.processTimeObject = function (obj) { var date, dayOffset; utils.setDefaults(obj); dayOffset = ($P.isLeapYear(obj.year)) ? dayOffsets.leap : dayOffsets.standard; if (!obj.month && (obj.week || obj.dayOfYear)) { utils.getDayOfYear(obj, dayOffset); } else { obj.dayOfYear = dayOffset[obj.month] + obj.day; } date = new Date(obj.year, obj.month, obj.day, obj.hours, obj.minutes, obj.seconds, obj.milliseconds); if (obj.zone) { utils.adjustForTimeZone(obj, date); // adjust (and calculate) for timezone } return date; }; $P.ISO = { regex : /^([\+-]?\d{4}(?!\d{2}\b))((-?)((0[1-9]|1[0-2])(\3([12]\d|0[1-9]|3[01]))?|W([0-4]\d|5[0-3])(-?[1-7])?|(00[1-9]|0[1-9]\d|[12]\d{2}|3([0-5]\d|6[1-6])))([T\s]((([01]\d|2[0-4])((:?)[0-5]\d)?|24\:?00)([\.,]\d+(?!:))?)?(\17[0-5]\d([\.,]\d+)?)?\s?([zZ]|([\+-])([01]\d|2[0-3]):?([0-5]\d)?)?)?)?$/, parse : function (s) { var time, data = s.match(this.regex); if (!data || !data.length) { return null; } time = utils.buildTimeObjectFromData(data); if (!time.year || (!time.year && (!time.month && !time.day) && (!time.week && !time.dayOfYear)) ) { return null; } return $P.processTimeObject(time); } }; $P.Numeric = { isNumeric: function (e){return!isNaN(parseFloat(e))&&isFinite(e);}, regex: /\b([0-1]?[0-9])([0-3]?[0-9])([0-2]?[0-9]?[0-9][0-9])\b/i, parse: function (s) { var data, i, time = {}, order = Date.CultureInfo.dateElementOrder.split(""); if (!(this.isNumeric(s)) || // if it's non-numeric OR (s[0] === "+" && s[0] === "-")) { // It's an arithmatic string (eg +/-1000) return null; } if (s.length < 5 && s.indexOf(".") < 0 && s.indexOf("/") < 0) { // assume it's just a year. time.year = s; return $P.processTimeObject(time); } data = s.match(this.regex); if (!data || !data.length) { return null; } for (i=0; i < order.length; i++) { switch(order[i]) { case "d": time.day = data[i+1]; break; case "m": time.month = (data[i+1]-1); break; case "y": time.year = data[i+1]; break; } } return $P.processTimeObject(time); } }; $P.Normalizer = { regexData: function () { var $R = Date.CultureInfo.regexPatterns; return utils.buildRegexData([ $R.tomorrow, $R.yesterday, [$R.past, $R.mon], [$R.past, $R.tue], [$R.past, $R.wed], [$R.past, $R.thu], [$R.past, $R.fri], [$R.past, $R.sat], [$R.past, $R.sun] ]); }, basicReplaceHash : function() { var $R = Date.CultureInfo.regexPatterns; return { "January": $R.jan.source, "February": $R.feb, "March": $R.mar, "April": $R.apr, "May": $R.may, "June": $R.jun, "July": $R.jul, "August": $R.aug, "September": $R.sep, "October": $R.oct, "November": $R.nov, "December": $R.dec, "": /\bat\b/gi, " ": /\s{2,}/, "am": $R.inTheMorning, "9am": $R.thisMorning, "pm": $R.inTheEvening, "7pm":$R.thisEvening }; }, keys : function(){ return [ utils.getDateNthString(true, false, 1), // tomorrow utils.getDateNthString(true, false, -1), // yesterday utils.getDateNthString(false, true, "monday"), //last mon utils.getDateNthString(false, true, "tuesday"), //last tues utils.getDateNthString(false, true, "wednesday"), //last wed utils.getDateNthString(false, true, "thursday"), //last thurs utils.getDateNthString(false, true, "friday"), //last fri utils.getDateNthString(false, true, "saturday"), //last sat utils.getDateNthString(false, true, "sunday") //last sun ]; }, buildRegexFunctions: function () { var $R = Date.CultureInfo.regexPatterns; var __ = Date.i18n.__; var tomorrowRE = new RegExp("(\\b\\d\\d?("+__("AM")+"|"+__("PM")+")? )("+$R.tomorrow.source.slice(1)+")", "i"); // adapted tomorrow regex for AM PM relative dates var todayRE = new RegExp($R.today.source + "(?!\\s*([+-]))\\b"); // today, but excludes the math operators (eg "today + 2h") this.replaceFuncs = [ [todayRE, function (full) { return (full.length > 1) ? Date.today().toString("d") : full; }], [tomorrowRE, function(full, m1) { var t = Date.today().addDays(1).toString("d"); return (t + " " + m1); }], [$R.amThisMorning, function(str, am){return am;}], [$R.pmThisEvening, function(str, pm){return pm;}] ]; }, buildReplaceData: function () { this.buildRegexFunctions(); this.replaceHash = utils.addToHash(this.basicReplaceHash(), this.keys(), this.regexData()); }, stringReplaceFuncs: function (s) { for (var i=0; i < this.replaceFuncs.length; i++) { s = s.replace(this.replaceFuncs[i][0], this.replaceFuncs[i][1]); } return s; }, parse: function (s) { s = this.stringReplaceFuncs(s); s = utils.multiReplace(s, this.replaceHash); try { var n = s.split(/([\s\-\.\,\/\x27]+)/); if (n.length === 3 && $P.Numeric.isNumeric(n[0]) && $P.Numeric.isNumeric(n[2]) && (n[2].length >= 4)) { // ok, so we're dealing with x/year. But that's not a full date. // This fixes wonky dateElementOrder parsing when set to dmy order. if (Date.CultureInfo.dateElementOrder[0] === "d") { s = "1/" + n[0] + "/" + n[2]; // set to 1st of month and normalize the seperator } } } catch (e) {} return s; } }; $P.Normalizer.buildReplaceData(); }()); (function () { var $P = Date.Parsing; var _ = $P.Operators = { // // Tokenizers // rtoken: function (r) { // regex token return function (s) { var mx = s.match(r); if (mx) { return ([ mx[0], s.substring(mx[0].length) ]); } else { throw new $P.Exception(s); } }; }, token: function () { // whitespace-eating token return function (s) { return _.rtoken(new RegExp("^\\s*" + s + "\\s*"))(s); }; }, stoken: function (s) { // string token return _.rtoken(new RegExp("^" + s)); }, // Atomic Operators until: function (p) { return function (s) { var qx = [], rx = null; while (s.length) { try { rx = p.call(this, s); } catch (e) { qx.push(rx[0]); s = rx[1]; continue; } break; } return [ qx, s ]; }; }, many: function (p) { return function (s) { var rx = [], r = null; while (s.length) { try { r = p.call(this, s); } catch (e) { return [ rx, s ]; } rx.push(r[0]); s = r[1]; } return [ rx, s ]; }; }, // generator operators -- see below optional: function (p) { return function (s) { var r = null; try { r = p.call(this, s); } catch (e) { return [ null, s ]; } return [ r[0], r[1] ]; }; }, not: function (p) { return function (s) { try { p.call(this, s); } catch (e) { return [null, s]; } throw new $P.Exception(s); }; }, ignore: function (p) { return p ? function (s) { var r = null; r = p.call(this, s); return [null, r[1]]; } : null; }, product: function () { var px = arguments[0], qx = Array.prototype.slice.call(arguments, 1), rx = []; for (var i = 0 ; i < px.length ; i++) { rx.push(_.each(px[i], qx)); } return rx; }, cache: function (rule) { var cache = {}, cache_length = 0, cache_keys = [], CACHE_MAX = Date.Config.CACHE_MAX || 100000, r = null; var cacheCheck = function () { if (cache_length === CACHE_MAX) { // kill several keys, don't want to have to do this all the time... for (var i=0; i < 10; i++) { var key = cache_keys.shift(); if (key) { delete cache[key]; cache_length--; } } } }; return function (s) { cacheCheck(); try { r = cache[s] = (cache[s] || rule.call(this, s)); } catch (e) { r = cache[s] = e; } cache_length++; cache_keys.push(s); if (r instanceof $P.Exception) { throw r; } else { return r; } }; }, // vector operators -- see below any: function () { var px = arguments; return function (s) { var r = null; for (var i = 0; i < px.length; i++) { if (px[i] == null) { continue; } try { r = (px[i].call(this, s)); } catch (e) { r = null; } if (r) { return r; } } throw new $P.Exception(s); }; }, each: function () { var px = arguments; return function (s) { var rx = [], r = null; for (var i = 0; i < px.length ; i++) { if (px[i] == null) { continue; } try { r = (px[i].call(this, s)); } catch (e) { throw new $P.Exception(s); } rx.push(r[0]); s = r[1]; } return [ rx, s]; }; }, all: function () { var px = arguments, _ = _; return _.each(_.optional(px)); }, // delimited operators sequence: function (px, d, c) { d = d || _.rtoken(/^\s*/); c = c || null; if (px.length === 1) { return px[0]; } return function (s) { var r = null, q = null; var rx = []; for (var i = 0; i < px.length ; i++) { try { r = px[i].call(this, s); } catch (e) { break; } rx.push(r[0]); try { q = d.call(this, r[1]); } catch (ex) { q = null; break; } s = q[1]; } if (!r) { throw new $P.Exception(s); } if (q) { throw new $P.Exception(q[1]); } if (c) { try { r = c.call(this, r[1]); } catch (ey) { throw new $P.Exception(r[1]); } } return [ rx, (r?r[1]:s) ]; }; }, // // Composite Operators // between: function (d1, p, d2) { d2 = d2 || d1; var _fn = _.each(_.ignore(d1), p, _.ignore(d2)); return function (s) { var rx = _fn.call(this, s); return [[rx[0][0], r[0][2]], rx[1]]; }; }, list: function (p, d, c) { d = d || _.rtoken(/^\s*/); c = c || null; return (p instanceof Array ? _.each(_.product(p.slice(0, -1), _.ignore(d)), p.slice(-1), _.ignore(c)) : _.each(_.many(_.each(p, _.ignore(d))), px, _.ignore(c))); }, set: function (px, d, c) { d = d || _.rtoken(/^\s*/); c = c || null; return function (s) { // r is the current match, best the current 'best' match // which means it parsed the most amount of input var r = null, p = null, q = null, rx = null, best = [[], s], last = false; // go through the rules in the given set for (var i = 0; i < px.length ; i++) { // last is a flag indicating whether this must be the last element // if there is only 1 element, then it MUST be the last one q = null; p = null; r = null; last = (px.length === 1); // first, we try simply to match the current pattern // if not, try the next pattern try { r = px[i].call(this, s); } catch (e) { continue; } // since we are matching against a set of elements, the first // thing to do is to add r[0] to matched elements rx = [[r[0]], r[1]]; // if we matched and there is still input to parse and // we don't already know this is the last element, // we're going to next check for the delimiter ... // if there's none, or if there's no input left to parse // than this must be the last element after all ... if (r[1].length > 0 && ! last) { try { q = d.call(this, r[1]); } catch (ex) { last = true; } } else { last = true; } // if we parsed the delimiter and now there's no more input, // that means we shouldn't have parsed the delimiter at all // so don't update r and mark this as the last element ... if (!last && q[1].length === 0) { last = true; } // so, if this isn't the last element, we're going to see if // we can get any more matches from the remaining (unmatched) // elements ... if (!last) { // build a list of the remaining rules we can match against, // i.e., all but the one we just matched against var qx = []; for (var j = 0; j < px.length ; j++) { if (i !== j) { qx.push(px[j]); } } // now invoke recursively set with the remaining input // note that we don't include the closing delimiter ... // we'll check for that ourselves at the end p = _.set(qx, d).call(this, q[1]); // if we got a non-empty set as a result ... // (otw rx already contains everything we want to match) if (p[0].length > 0) { // update current result, which is stored in rx ... // basically, pick up the remaining text from p[1] // and concat the result from p[0] so that we don't // get endless nesting ... rx[0] = rx[0].concat(p[0]); rx[1] = p[1]; } } // at this point, rx either contains the last matched element // or the entire matched set that starts with this element. // now we just check to see if this variation is better than // our best so far, in terms of how much of the input is parsed if (rx[1].length < best[1].length) { best = rx; } // if we've parsed all the input, then we're finished if (best[1].length === 0) { break; } } // so now we've either gone through all the patterns trying them // as the initial match; or we found one that parsed the entire // input string ... // if best has no matches, just return empty set ... if (best[0].length === 0) { return best; } // if a closing delimiter is provided, then we have to check it also if (c) { // we try this even if there is no remaining input because the pattern // may well be optional or match empty input ... try { q = c.call(this, best[1]); } catch (ey) { throw new $P.Exception(best[1]); } // it parsed ... be sure to update the best match remaining input best[1] = q[1]; } // if we're here, either there was no closing delimiter or we parsed it // so now we have the best match; just return it! return best; }; }, forward: function (gr, fname) { return function (s) { return gr[fname].call(this, s); }; }, // // Translation Operators // replace: function (rule, repl) { return function (s) { var r = rule.call(this, s); return [repl, r[1]]; }; }, process: function (rule, fn) { return function (s) { var r = rule.call(this, s); return [fn.call(this, r[0]), r[1]]; }; }, min: function (min, rule) { return function (s) { var rx = rule.call(this, s); if (rx[0].length < min) { throw new $P.Exception(s); } return rx; }; } }; // Generator Operators And Vector Operators // Generators are operators that have a signature of F(R) => R, // taking a given rule and returning another rule, such as // ignore, which parses a given rule and throws away the result. // Vector operators are those that have a signature of F(R1,R2,...) => R, // take a list of rules and returning a new rule, such as each. // Generator operators are converted (via the following _generator // function) into functions that can also take a list or array of rules // and return an array of new rules as though the function had been // called on each rule in turn (which is what actually happens). // This allows generators to be used with vector operators more easily. // Example: // each(ignore(foo, bar)) instead of each(ignore(foo), ignore(bar)) // This also turns generators into vector operators, which allows // constructs like: // not(cache(foo, bar)) var _generator = function (op) { function gen() { var args = null, rx = [], px, i; if (arguments.length > 1) { args = Array.prototype.slice.call(arguments); } else if (arguments[0] instanceof Array) { args = arguments[0]; } if (args) { px = args.shift(); if (px.length > 0) { args.unshift(px[i]); rx.push(op.apply(null, args)); args.shift(); return rx; } } else { return op.apply(null, arguments); } } return gen; }; var gx = "optional not ignore cache".split(/\s/); for (var i = 0 ; i < gx.length ; i++) { _[gx[i]] = _generator(_[gx[i]]); } var _vector = function (op) { return function () { if (arguments[0] instanceof Array) { return op.apply(null, arguments[0]); } else { return op.apply(null, arguments); } }; }; var vx = "each any all".split(/\s/); for (var j = 0 ; j < vx.length ; j++) { _[vx[j]] = _vector(_[vx[j]]); } }()); (function () { var $D = Date; var flattenAndCompact = function (ax) { var rx = []; for (var i = 0; i < ax.length; i++) { if (ax[i] instanceof Array) { rx = rx.concat(flattenAndCompact(ax[i])); } else { if (ax[i]) { rx.push(ax[i]); } } } return rx; }; var parseMeridian = function () { if (this.meridian && (this.hour || this.hour === 0)) { if (this.meridian === "a" && this.hour > 11 && Date.Config.strict24hr){ throw "Invalid hour and meridian combination"; } else if (this.meridian === "p" && this.hour < 12 && Date.Config.strict24hr){ throw "Invalid hour and meridian combination"; } else if (this.meridian === "p" && this.hour < 12) { this.hour = this.hour + 12; } else if (this.meridian === "a" && this.hour === 12) { this.hour = 0; } } }; var setDefaults = function () { var now = new Date(); if ((this.hour || this.minute) && (!this.month && !this.year && !this.day)) { this.day = now.getDate(); } if (!this.year) { this.year = now.getFullYear(); } if (!this.month && this.month !== 0) { this.month = now.getMonth(); } if (!this.day) { this.day = 1; } if (!this.hour) { this.hour = 0; } if (!this.minute) { this.minute = 0; } if (!this.second) { this.second = 0; } if (!this.millisecond) { this.millisecond = 0; } }; var finishUtils = { getToday: function () { if (this.now || "hour minute second".indexOf(this.unit) !== -1) { return new Date(); } else { return $D.today(); } }, setDaysFromWeekday: function (today, orient){ var gap; orient = orient || 1; this.unit = "day"; gap = ($D.getDayNumberFromName(this.weekday) - today.getDay()); this.days = gap ? ((gap + (orient * 7)) % 7) : (orient * 7); return this; }, setMonthsFromMonth: function (today, orient) { var gap; orient = orient || 1; this.unit = "month"; gap = (this.month - today.getMonth()); this.months = gap ? ((gap + (orient * 12)) % 12) : (orient * 12); this.month = null; return this; }, setDMYFromWeekday: function () { var d = Date[this.weekday](); this.day = d.getDate(); if (!this.month) { this.month = d.getMonth(); } this.year = d.getFullYear(); return this; }, setUnitValue: function (orient) { if (!this.value && this.operator && this.operator !== null && this[this.unit + "s"] && this[this.unit + "s"] !== null) { this[this.unit + "s"] = this[this.unit + "s"] + ((this.operator === "add") ? 1 : -1) + (this.value||0) * orient; } else if (this[this.unit + "s"] == null || this.operator != null) { if (!this.value) { this.value = 1; } this[this.unit + "s"] = this.value * orient; } }, generateDateFromWeeks: function () { var weekday = (this.weekday !== undefined) ? this.weekday : "today"; var d = Date[weekday]().addWeeks(this.weeks); if (this.now) { d.setTimeToNow(); } return d; } }; $D.Translator = { hour: function (s) { return function () { this.hour = Number(s); }; }, minute: function (s) { return function () { this.minute = Number(s); }; }, second: function (s) { return function () { this.second = Number(s); }; }, /* for ss.s format */ secondAndMillisecond: function (s) { return function () { var mx = s.match(/^([0-5][0-9])\.([0-9]{1,3})/); this.second = Number(mx[1]); this.millisecond = Number(mx[2]); }; }, meridian: function (s) { return function () { this.meridian = s.slice(0, 1).toLowerCase(); }; }, timezone: function (s) { return function () { var n = s.replace(/[^\d\+\-]/g, ""); if (n.length) { this.timezoneOffset = Number(n); } else { this.timezone = s.toLowerCase(); } }; }, day: function (x) { var s = x[0]; return function () { this.day = Number(s.match(/\d+/)[0]); if (this.day < 1) { throw "invalid day"; } }; }, month: function (s) { return function () { this.month = (s.length === 3) ? "jan feb mar apr may jun jul aug sep oct nov dec".indexOf(s)/4 : Number(s) - 1; if (this.month < 0) { throw "invalid month"; } }; }, year: function (s) { return function () { var n = Number(s); this.year = ((s.length > 2) ? n : (n + (((n + 2000) < Date.CultureInfo.twoDigitYearMax) ? 2000 : 1900))); }; }, rday: function (s) { return function () { switch (s) { case "yesterday": this.days = -1; break; case "tomorrow": this.days = 1; break; case "today": this.days = 0; break; case "now": this.days = 0; this.now = true; break; } }; }, finishExact: function (x) { var d; x = (x instanceof Array) ? x : [x]; for (var i = 0 ; i < x.length ; i++) { if (x[i]) { x[i].call(this); } } setDefaults.call(this); parseMeridian.call(this); if (this.day > $D.getDaysInMonth(this.year, this.month)) { throw new RangeError(this.day + " is not a valid value for days."); } d = new Date(this.year, this.month, this.day, this.hour, this.minute, this.second, this.millisecond); if (this.year < 100) { d.setFullYear(this.year); // means years less that 100 are process correctly. JS will parse it otherwise as 1900-1999. } if (this.timezone) { d.set({ timezone: this.timezone }); } else if (this.timezoneOffset) { d.set({ timezoneOffset: this.timezoneOffset }); } return d; }, finish: function (x) { var today, expression, orient, temp; x = (x instanceof Array) ? flattenAndCompact(x) : [ x ]; if (x.length === 0) { return null; } for (var i = 0 ; i < x.length ; i++) { if (typeof x[i] === "function") { x[i].call(this); } } if (this.now && !this.unit && !this.operator) { return new Date(); } else { today = finishUtils.getToday.call(this); } expression = !!(this.days && this.days !== null || this.orient || this.operator); orient = ((this.orient === "past" || this.operator === "subtract") ? -1 : 1); if (this.month && this.unit === "week") { this.value = this.month + 1; delete this.month; delete this.day; } if ((this.month || this.month === 0) && "year day hour minute second".indexOf(this.unit) !== -1) { if (!this.value) { this.value = this.month + 1; } this.month = null; expression = true; } if (!expression && this.weekday && !this.day && !this.days) { finishUtils.setDMYFromWeekday.call(this); } if (expression && this.weekday && this.unit !== "month" && this.unit !== "week") { finishUtils.setDaysFromWeekday.call(this, today, orient); } if (this.weekday && this.unit !== "week" && !this.day && !this.days) { temp = Date[this.weekday](); this.day = temp.getDate(); if (temp.getMonth() !== today.getMonth()) { this.month = temp.getMonth(); } } if (this.month && this.unit === "day" && this.operator) { if (!this.value) { this.value = (this.month + 1); } this.month = null; } if (this.value != null && this.month != null && this.year != null) { this.day = this.value * 1; } if (this.month && !this.day && this.value) { today.set({ day: this.value * 1 }); if (!expression) { this.day = this.value * 1; } } if (!this.month && this.value && this.unit === "month" && !this.now) { this.month = this.value; expression = true; } if (expression && (this.month || this.month === 0) && this.unit !== "year") { finishUtils.setMonthsFromMonth.call(this, today, orient); } if (!this.unit) { this.unit = "day"; } finishUtils.setUnitValue.call(this, orient); parseMeridian.call(this); if ((this.month || this.month === 0) && !this.day) { this.day = 1; } if (!this.orient && !this.operator && this.unit === "week" && this.value && !this.day && !this.month) { return Date.today().setWeek(this.value); } if (this.unit === "week" && this.weeks && !this.day && !this.month) { return finishUtils.generateDateFromWeeks.call(this); } if (expression && this.timezone && this.day && this.days) { this.day = this.days; } if (expression){ today.add(this); } else { today.set(this); } if (this.timezone) { this.timezone = this.timezone.toUpperCase(); var offset = $D.getTimezoneOffset(this.timezone); var timezone; if (today.hasDaylightSavingTime()) { // lets check that we're being sane with timezone setting timezone = $D.getTimezoneAbbreviation(offset, today.isDaylightSavingTime()); if (timezone !== this.timezone) { // bugger, we're in a place where things like EST vs EDT matters. if (today.isDaylightSavingTime()) { today.addHours(-1); } else { today.addHours(1); } } } today.setTimezoneOffset(offset); } return today; } }; }()); (function () { var $D = Date; $D.Grammar = {}; var _ = $D.Parsing.Operators, g = $D.Grammar, t = $D.Translator, _fn; // Allow rolling up into general purpose rules _fn = function () { return _.each(_.any.apply(null, arguments), _.not(g.ctoken2("timeContext"))); }; g.datePartDelimiter = _.rtoken(/^([\s\-\.\,\/\x27]+)/); g.timePartDelimiter = _.stoken(":"); g.whiteSpace = _.rtoken(/^\s*/); g.generalDelimiter = _.rtoken(/^(([\s\,]|at|@|on)+)/); var _C = {}; g.ctoken = function (keys) { var fn = _C[keys]; if (! fn) { var c = Date.CultureInfo.regexPatterns; var kx = keys.split(/\s+/), px = []; for (var i = 0; i < kx.length ; i++) { px.push(_.replace(_.rtoken(c[kx[i]]), kx[i])); } fn = _C[keys] = _.any.apply(null, px); } return fn; }; g.ctoken2 = function (key) { return _.rtoken(Date.CultureInfo.regexPatterns[key]); }; var cacheProcessRtoken = function (key, token, type, eachToken) { if (eachToken) { g[key] = _.cache(_.process(_.each(_.rtoken(token),_.optional(g.ctoken2(eachToken))), type)); } else { g[key] = _.cache(_.process(_.rtoken(token), type)); } }; var cacheProcessCtoken = function (token, type) { return _.cache(_.process(g.ctoken2(token), type)); }; var _F = {}; //function cache var _get = function (f) { _F[f] = (_F[f] || g.format(f)[0]); return _F[f]; }; g.allformats = function (fx) { var rx = []; if (fx instanceof Array) { for (var i = 0; i < fx.length; i++) { rx.push(_get(fx[i])); } } else { rx.push(_get(fx)); } return rx; }; g.formats = function (fx) { if (fx instanceof Array) { var rx = []; for (var i = 0 ; i < fx.length ; i++) { rx.push(_get(fx[i])); } return _.any.apply(null, rx); } else { return _get(fx); } }; var grammarFormats = { timeFormats: function(){ var i, RTokenKeys = [ "h", "hh", "H", "HH", "m", "mm", "s", "ss", "ss.s", "z", "zz" ], RToken = [ /^(0[0-9]|1[0-2]|[1-9])/, /^(0[0-9]|1[0-2])/, /^([0-1][0-9]|2[0-3]|[0-9])/, /^([0-1][0-9]|2[0-3])/, /^([0-5][0-9]|[0-9])/, /^[0-5][0-9]/, /^([0-5][0-9]|[0-9])/, /^[0-5][0-9]/, /^[0-5][0-9]\.[0-9]{1,3}/, /^((\+|\-)\s*\d\d\d\d)|((\+|\-)\d\d\:?\d\d)/, /^((\+|\-)\s*\d\d\d\d)|((\+|\-)\d\d\:?\d\d)/ ], tokens = [ t.hour, t.hour, t.hour, t.hour, t.minute, t.minute, t.second, t.second, t.secondAndMillisecond, t.timezone, t.timezone ]; for (i=0; i < RTokenKeys.length; i++) { cacheProcessRtoken(RTokenKeys[i], RToken[i], tokens[i]); } g.hms = _.cache(_.sequence([g.H, g.m, g.s], g.timePartDelimiter)); g.t = cacheProcessCtoken("shortMeridian", t.meridian); g.tt = cacheProcessCtoken("longMeridian", t.meridian); g.zzz = cacheProcessCtoken("timezone", t.timezone); g.timeSuffix = _.each(_.ignore(g.whiteSpace), _.set([ g.tt, g.zzz ])); g.time = _.each(_.optional(_.ignore(_.stoken("T"))), g.hms, g.timeSuffix); }, dateFormats: function () { // pre-loaded rules for different date part order preferences var _setfn = function () { return _.set(arguments, g.datePartDelimiter); }; var i, RTokenKeys = [ "d", "dd", "M", "MM", "y", "yy", "yyy", "yyyy" ], RToken = [ /^([0-2]\d|3[0-1]|\d)/, /^([0-2]\d|3[0-1])/, /^(1[0-2]|0\d|\d)/, /^(1[0-2]|0\d)/, /^(\d+)/, /^(\d\d)/, /^(\d\d?\d?\d?)/, /^(\d\d\d\d)/ ], tokens = [ t.day, t.day, t.month, t.month, t.year, t.year, t.year, t.year ], eachToken = [ "ordinalSuffix", "ordinalSuffix" ]; for (i=0; i < RTokenKeys.length; i++) { cacheProcessRtoken(RTokenKeys[i], RToken[i], tokens[i], eachToken[i]); } g.MMM = g.MMMM = _.cache(_.process(g.ctoken("jan feb mar apr may jun jul aug sep oct nov dec"), t.month)); g.ddd = g.dddd = _.cache(_.process(g.ctoken("sun mon tue wed thu fri sat"), function (s) { return function () { this.weekday = s; }; } )); g.day = _fn(g.d, g.dd); g.month = _fn(g.M, g.MMM); g.year = _fn(g.yyyy, g.yy); g.mdy = _setfn(g.ddd, g.month, g.day, g.year); g.ymd = _setfn(g.ddd, g.year, g.month, g.day); g.dmy = _setfn(g.ddd, g.day, g.month, g.year); g.date = function (s) { return ((g[Date.CultureInfo.dateElementOrder] || g.mdy).call(this, s)); }; }, relative: function () { // relative date / time expressions g.orientation = _.process(g.ctoken("past future"), function (s) { return function () { this.orient = s; }; } ); g.operator = _.process(g.ctoken("add subtract"), function (s) { return function () { this.operator = s; }; } ); g.rday = _.process(g.ctoken("yesterday tomorrow today now"), t.rday); g.unit = _.process(g.ctoken("second minute hour day week month year"), function (s) { return function () { this.unit = s; }; } ); } }; g.buildGrammarFormats = function () { // these need to be rebuilt every time the language changes. _C = {}; grammarFormats.timeFormats(); grammarFormats.dateFormats(); grammarFormats.relative(); g.value = _.process(_.rtoken(/^([-+]?\d+)?(st|nd|rd|th)?/), function (s) { return function () { this.value = s.replace(/\D/g, ""); }; } ); g.expression = _.set([g.rday, g.operator, g.value, g.unit, g.orientation, g.ddd, g.MMM ]); g.format = _.process(_.many( _.any( // translate format specifiers into grammar rules _.process( _.rtoken(/^(dd?d?d?(?!e)|MM?M?M?|yy?y?y?|hh?|HH?|mm?|ss?|tt?|zz?z?)/), function (fmt) { if (g[fmt]) { return g[fmt]; } else { throw $D.Parsing.Exception(fmt); } } ), // translate separator tokens into token rules _.process(_.rtoken(/^[^dMyhHmstz]+/), // all legal separators function (s) { return _.ignore(_.stoken(s)); } ) ) ), // construct the parser ... function (rules) { return _.process(_.each.apply(null, rules), t.finishExact); } ); // starting rule for general purpose grammar g._start = _.process(_.set([ g.date, g.time, g.expression ], g.generalDelimiter, g.whiteSpace), t.finish); }; g.buildGrammarFormats(); // parsing date format specifiers - ex: "h:m:s tt" // this little guy will generate a custom parser based // on the format string, ex: g.format("h:m:s tt") // check for these formats first g._formats = g.formats([ "\"yyyy-MM-ddTHH:mm:ssZ\"", "yyyy-MM-ddTHH:mm:ss.sz", "yyyy-MM-ddTHH:mm:ssZ", "yyyy-MM-ddTHH:mm:ssz", "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-ddTHH:mmZ", "yyyy-MM-ddTHH:mmz", "yyyy-MM-ddTHH:mm", "ddd, MMM dd, yyyy H:mm:ss tt", "ddd MMM d yyyy HH:mm:ss zzz", "MMddyyyy", "ddMMyyyy", "Mddyyyy", "ddMyyyy", "Mdyyyy", "dMyyyy", "yyyy", "Mdyy", "dMyy", "d" ]); // real starting rule: tries selected formats first, // then general purpose rule g.start = function (s) { try { var r = g._formats.call({}, s); if (r[1].length === 0) { return r; } } catch (e) {} return g._start.call({}, s); }; }()); (function () { var $D = Date; /** * @desc Converts the specified string value into its JavaScript Date equivalent using CultureInfo specific format information. * * Example

	///////////
	// Dates //
	///////////

	// 15-Oct-2004
	var d1 = Date.parse("10/15/2004");

	// 15-Oct-2004
	var d1 = Date.parse("15-Oct-2004");

	// 15-Oct-2004
	var d1 = Date.parse("2004.10.15");

	//Fri Oct 15, 2004
	var d1 = Date.parse("Fri Oct 15, 2004");

	///////////
	// Times //
	///////////

	// Today at 10 PM.
	var d1 = Date.parse("10 PM");

	// Today at 10:30 PM.
	var d1 = Date.parse("10:30 P.M.");

	// Today at 6 AM.
	var d1 = Date.parse("06am");

	/////////////////////
	// Dates and Times //
	/////////////////////

	// 8-July-2004 @ 10:30 PM
	var d1 = Date.parse("July 8th, 2004, 10:30 PM");

	// 1-July-2004 @ 10:30 PM
	var d1 = Date.parse("2004-07-01T22:30:00");

	////////////////////
	// Relative Dates //
	////////////////////

	// Returns today's date. The string "today" is culture specific.
	var d1 = Date.parse("today");

	// Returns yesterday's date. The string "yesterday" is culture specific.
	var d1 = Date.parse("yesterday");

	// Returns the date of the next thursday.
	var d1 = Date.parse("Next thursday");

	// Returns the date of the most previous monday.
	var d1 = Date.parse("last monday");

	// Returns today's day + one year.
	var d1 = Date.parse("next year");

	///////////////
	// Date Math //
	///////////////

	// Today + 2 days
	var d1 = Date.parse("t+2");

	// Today + 2 days
	var d1 = Date.parse("today + 2 days");

	// Today + 3 months
	var d1 = Date.parse("t+3m");

	// Today - 1 year
	var d1 = Date.parse("today - 1 year");

	// Today - 1 year
	var d1 = Date.parse("t-1y"); 


	/////////////////////////////
	// Partial Dates and Times //
	/////////////////////////////

	// July 15th of this year.
	var d1 = Date.parse("July 15");

	// 15th day of current day and year.
	var d1 = Date.parse("15");

	// July 1st of current year at 10pm.
	var d1 = Date.parse("7/1 10pm");
	
* * @param {String} The string value to convert into a Date object [Required] * @return {Date} A Date object or null if the string cannot be converted into a Date. */ var parseUtils = { removeOrds: function (s) { ords = s.match(/\b(\d+)(?:st|nd|rd|th)\b/); // find ordinal matches s = ((ords && ords.length === 2) ? s.replace(ords[0], ords[1]) : s); return s; }, grammarParser: function (s) { var r = null; try { r = $D.Grammar.start.call({}, s.replace(/^\s*(\S*(\s+\S+)*)\s*$/, "$1")); } catch (e) { return null; } return ((r[1].length === 0) ? r[0] : null); }, nativeFallback: function(s) { var t; try { // ok we haven't parsed it, last ditch attempt with the built-in parser. t = Date._parse(s); return (t || t === 0) ? new Date(t) : null; } catch (e) { return null; } } }; function parse (s) { var d; if (!s) { return null; } if (s instanceof Date) { return s.clone(); } if (s.length >= 4 && s.charAt(0) !== "0" && s.charAt(0) !== "+"&& s.charAt(0) !== "-") { // ie: 2004 will pass, 0800 won't. // Start with specific formats d = $D.Parsing.ISO.parse(s) || $D.Parsing.Numeric.parse(s); } if (d instanceof Date && !isNaN(d.getTime())) { return d; } else { // find ordinal dates (1st, 3rd, 8th, etc and remove them as they cause parsing issues) s = $D.Parsing.Normalizer.parse(parseUtils.removeOrds(s)); d = parseUtils.grammarParser(s); if (d !== null) { return d; } else { return parseUtils.nativeFallback(s); } } } if (!$D._parse) { $D._parse = $D.parse; } $D.parse = parse; Date.getParseFunction = function (fx) { var fns = Date.Grammar.allformats(fx); return function (s) { var r = null; for (var i = 0; i < fns.length; i++) { try { r = fns[i].call({}, s); } catch (e) { continue; } if (r[1].length === 0) { return r[0]; } } return null; }; }; /** * Converts the specified string value into its JavaScript Date equivalent using the specified format {String} or formats {Array} and the CultureInfo specific format information. * The format of the string value must match one of the supplied formats exactly. * * Example

	// 15-Oct-2004
	var d1 = Date.parseExact("10/15/2004", "M/d/yyyy");

	// 15-Oct-2004
	var d1 = Date.parse("15-Oct-2004", "M-ddd-yyyy");

	// 15-Oct-2004
	var d1 = Date.parse("2004.10.15", "yyyy.MM.dd");

	// Multiple formats
	var d1 = Date.parseExact("10/15/2004", ["M/d/yyyy", "MMMM d, yyyy"]);
	
* * @param {String} The string value to convert into a Date object [Required]. * @param {Object} The expected format {String} or an array of expected formats {Array} of the date string [Required]. * @return {Date} A Date object or null if the string cannot be converted into a Date. */ $D.parseExact = function (s, fx) { return $D.getParseFunction(fx)(s); }; }()); (function () { var $D = Date, $P = $D.prototype, // $C = $D.CultureInfo, // not used atm p = function (s, l) { if (!l) { l = 2; } return ("000" + s).slice(l * -1); }; /** * Converts a PHP format string to Java/.NET format string. * A PHP format string can be used with ._format or .format. * A Java/.NET format string can be used with .toString(). * The .parseExact function will only accept a Java/.NET format string * * Example * var f1 = "%m/%d/%y" * var f2 = Date.normalizeFormat(f1); // "MM/dd/yy" * * new Date().format(f1); // "04/13/08" * new Date()._format(f1); // "04/13/08" * new Date().toString(f2); // "04/13/08" * * var date = Date.parseExact("04/13/08", f2); // Sun Apr 13 2008 * * @param {String} A PHP format string consisting of one or more format spcifiers. * @return {String} The PHP format converted to a Java/.NET format string. */ var normalizerSubstitutions = { "d" : "dd", "%d": "dd", "D" : "ddd", "%a": "ddd", "j" : "dddd", "l" : "dddd", "%A": "dddd", "S" : "S", "F" : "MMMM", "%B": "MMMM", "m" : "MM", "%m": "MM", "M" : "MMM", "%b": "MMM", "%h": "MMM", "n" : "M", "Y" : "yyyy", "%Y": "yyyy", "y" : "yy", "%y": "yy", "g" : "h", "%I": "h", "G" : "H", "h" : "hh", "H" : "HH", "%H": "HH", "i" : "mm", "%M": "mm", "s" : "ss", "%S": "ss", "%r": "hh:mm tt", "%R": "H:mm", "%T": "H:mm:ss", "%X": "t", "%x": "d", "%e": "d", "%D": "MM/dd/yy", "%n": "\\n", "%t": "\\t", "e" : "z", "T" : "z", "%z": "z", "%Z": "z", "Z" : "ZZ", "N" : "u", "w" : "u", "%w": "u", "W" : "W", "%V": "W" }; var normalizer = { substitutes: function (m) { return normalizerSubstitutions[m]; }, interpreted: function (m, x) { var y; switch (m) { case "%u": return x.getDay() + 1; case "z": return x.getOrdinalNumber(); case "%j": return p(x.getOrdinalNumber(), 3); case "%U": var d1 = x.clone().set({month: 0, day: 1}).addDays(-1).moveToDayOfWeek(0), d2 = x.clone().addDays(1).moveToDayOfWeek(0, -1); return (d2 < d1) ? "00" : p((d2.getOrdinalNumber() - d1.getOrdinalNumber()) / 7 + 1); case "%W": return p(x.getWeek()); case "t": return $D.getDaysInMonth(x.getFullYear(), x.getMonth()); case "o": case "%G": return x.setWeek(x.getISOWeek()).toString("yyyy"); case "%g": return x._format("%G").slice(-2); case "a": case "%p": return t("tt").toLowerCase(); case "A": return t("tt").toUpperCase(); case "u": return p(x.getMilliseconds(), 3); case "I": return (x.isDaylightSavingTime()) ? 1 : 0; case "O": return x.getUTCOffset(); case "P": y = x.getUTCOffset(); return y.substring(0, y.length - 2) + ":" + y.substring(y.length - 2); case "B": var now = new Date(); return Math.floor(((now.getHours() * 3600) + (now.getMinutes() * 60) + now.getSeconds() + (now.getTimezoneOffset() + 60) * 60) / 86.4); case "c": return x.toISOString().replace(/\"/g, ""); case "U": return $D.strtotime("now"); case "%c": return t("d") + " " + t("t"); case "%C": return Math.floor(x.getFullYear() / 100 + 1); } }, shouldOverrideDefaults: function (m) { switch (m) { case "%e": return true; default: return false; } }, parse: function (m, context) { var formatString, c = context || new Date(); formatString = normalizer.substitutes(m); if (formatString) { return formatString; } formatString = normalizer.interpreted(m, c); if (formatString) { return formatString; } else { return m; } } }; $D.normalizeFormat = function (format, context) { return format.replace(/(%|\\)?.|%%/g, function(t){ return normalizer.parse(t, context); }); }; /** * Format a local Unix timestamp according to locale settings * * Example: * Date.strftime("%m/%d/%y", new Date()); // "04/13/08" * Date.strftime("c", "2008-04-13T17:52:03Z"); // "04/13/08" * * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @param {Number|String} The number representing the number of seconds that have elapsed since January 1, 1970 (local time). * @return {String} A string representation of the current Date object. */ $D.strftime = function (format, time) { var d = Date.parse(time); return d._format(format); }; /** * Parse any textual datetime description into a Unix timestamp. * A Unix timestamp is the number of seconds that have elapsed since January 1, 1970 (midnight UTC/GMT). * * Example: * Date.strtotime("04/13/08"); // 1208044800 * Date.strtotime("1970-01-01T00:00:00Z"); // 0 * * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @param {Object} A string or date object. * @return {String} A string representation of the current Date object. */ $D.strtotime = function (time) { var d = $D.parse(time); return Math.round($D.UTC(d.getUTCFullYear(), d.getUTCMonth(), d.getUTCDate(), d.getUTCHours(), d.getUTCMinutes(), d.getUTCSeconds(), d.getUTCMilliseconds()) / 1000); }; /** * Converts the value of the current Date object to its equivalent string representation using a PHP/Unix style of date format specifiers. * Format Specifiers * Format Description Example * ------ --------------------------------------------------------------------------- ----------------------- * %a abbreviated weekday name according to the current localed "Mon" through "Sun" * %A full weekday name according to the current localed "Sunday" through "Saturday" * %b abbreviated month name according to the current localed "Jan" through "Dec" * %B full month name according to the current locale "January" through "December" * %c preferred date and time representation for the current locale "4/13/2008 12:33 PM" * %C century number (the year divided by 100 and truncated to an integer) "00" to "99" * %d day of the month as a decimal number "01" to "31" * %D same as %m/%d/%y "04/13/08" * %e day of the month as a decimal number, a single digit is preceded by a space "1" to "31" * %g like %G, but without the century "08" * %G The 4-digit year corresponding to the ISO week number (see %V). "2008" * This has the same format and value as %Y, except that if the ISO week number * belongs to the previous or next year, that year is used instead. * %h same as %b "Jan" through "Dec" * %H hour as a decimal number using a 24-hour clock. "00" to "23" * %I hour as a decimal number using a 12-hour clock. "01" to "12" * %j day of the year as a decimal number. "001" to "366" * %m month as a decimal number. "01" to "12" * %M minute as a decimal number. "00" to "59" * %n newline character "\n" * %p either "am" or "pm" according to the given time value, or the "am" or "pm" * corresponding strings for the current locale. * %r time in a.m. and p.m. notation "8:44 PM" * %R time in 24 hour notation "20:44" * %S second as a decimal number "00" to "59" * %t tab character "\t" * %T current time, equal to %H:%M:%S "12:49:11" * %u weekday as a decimal number ["1", "7"], with "1" representing Monday "1" to "7" * %U week number of the current year as a decimal number, starting with the "0" to ("52" or "53") * first Sunday as the first day of the first week * %V The ISO 8601:1988 week number of the current year as a decimal number, "00" to ("52" or "53") * range 01 to 53, where week 1 is the first week that has at least 4 days * in the current year, and with Monday as the first day of the week. * (Use %G or %g for the year component that corresponds to the week number * for the specified timestamp.) * %W week number of the current year as a decimal number, starting with the "00" to ("52" or "53") * first Monday as the first day of the first week * %w day of the week as a decimal, Sunday being "0" "0" to "6" * %x preferred date representation for the current locale without the time "4/13/2008" * %X preferred time representation for the current locale without the date "12:53:05" * %y year as a decimal number without a century "00" "99" * %Y year as a decimal number including the century "2008" * %Z time zone or name or abbreviation "UTC", "EST", "PST" * %z same as %Z * %% a literal "%" characters "%" * d Day of the month, 2 digits with leading zeros "01" to "31" * D A textual representation of a day, three letters "Mon" through "Sun" * j Day of the month without leading zeros "1" to "31" * l A full textual representation of the day of the week (lowercase "L") "Sunday" through "Saturday" * N ISO-8601 numeric representation of the day of the week (added in PHP 5.1.0) "1" (for Monday) through "7" (for Sunday) * S English ordinal suffix for the day of the month, 2 characters "st", "nd", "rd" or "th". Works well with j * w Numeric representation of the day of the week "0" (for Sunday) through "6" (for Saturday) * z The day of the year (starting from "0") "0" through "365" * W ISO-8601 week number of year, weeks starting on Monday "00" to ("52" or "53") * F A full textual representation of a month, such as January or March "January" through "December" * m Numeric representation of a month, with leading zeros "01" through "12" * M A short textual representation of a month, three letters "Jan" through "Dec" * n Numeric representation of a month, without leading zeros "1" through "12" * t Number of days in the given month "28" through "31" * L Whether it's a leap year "1" if it is a leap year, "0" otherwise * o ISO-8601 year number. This has the same value as Y, except that if the "2008" * ISO week number (W) belongs to the previous or next year, that year * is used instead. * Y A full numeric representation of a year, 4 digits "2008" * y A two digit representation of a year "08" * a Lowercase Ante meridiem and Post meridiem "am" or "pm" * A Uppercase Ante meridiem and Post meridiem "AM" or "PM" * B Swatch Internet time "000" through "999" * g 12-hour format of an hour without leading zeros "1" through "12" * G 24-hour format of an hour without leading zeros "0" through "23" * h 12-hour format of an hour with leading zeros "01" through "12" * H 24-hour format of an hour with leading zeros "00" through "23" * i Minutes with leading zeros "00" to "59" * s Seconds, with leading zeros "00" through "59" * u Milliseconds "54321" * e Timezone identifier "UTC", "EST", "PST" * I Whether or not the date is in daylight saving time (uppercase i) "1" if Daylight Saving Time, "0" otherwise * O Difference to Greenwich time (GMT) in hours "+0200", "-0600" * P Difference to Greenwich time (GMT) with colon between hours and minutes "+02:00", "-06:00" * T Timezone abbreviation "UTC", "EST", "PST" * Z Timezone offset in seconds. The offset for timezones west of UTC is "-43200" through "50400" * always negative, and for those east of UTC is always positive. * c ISO 8601 date "2004-02-12T15:19:21+00:00" * r RFC 2822 formatted date "Thu, 21 Dec 2000 16:01:07 +0200" * U Seconds since the Unix Epoch (January 1 1970 00:00:00 GMT) "0" * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @return {String} A string representation of the current Date object. */ var formatReplace = function (context) { return function (m) { var formatString, override = false; if (m.charAt(0) === "\\" || m.substring(0, 2) === "%%") { return m.replace("\\", "").replace("%%", "%"); } override = normalizer.shouldOverrideDefaults(m); formatString = $D.normalizeFormat(m, context); if (formatString) { return context.toString(formatString, override); } }; }; $P._format = function (format) { var formatter = formatReplace(this); if (!format) { return this._toString(); } else { return format.replace(/(%|\\)?.|%%/g, formatter); } }; if (!$P.format) { $P.format = $P._format; } }()); (function () { "use strict"; var gFn = function (attr) { return function () { return this[attr]; }; }; var sFn = function (attr) { return function (val) { this[attr] = val; return this; }; }; var attrs = ["years", "months", "days", "hours", "minutes", "seconds", "milliseconds"]; var addSetFuncs = function (context, attrs) { for (var i = 0; i < attrs.length ; i++) { var $a = attrs[i], $b = $a.slice(0, 1).toUpperCase() + $a.slice(1); context.prototype[$a] = 0; context.prototype["get" + $b] = gFn($a); context.prototype["set" + $b] = sFn($a); } }; /** * new TimeSpan(milliseconds); * new TimeSpan(days, hours, minutes, seconds); * new TimeSpan(days, hours, minutes, seconds, milliseconds); */ var TimeSpan = function (days, hours, minutes, seconds, milliseconds) { if (arguments.length === 1 && typeof days === "number") { var orient = (days < 0) ? -1 : +1; var millsLeft = Math.abs(days); this.setDays(Math.floor(millsLeft / 86400000) * orient); millsLeft = millsLeft % 86400000; this.setHours(Math.floor(millsLeft / 3600000) * orient); millsLeft = millsLeft % 3600000; this.setMinutes(Math.floor(millsLeft / 60000) * orient); millsLeft = millsLeft % 60000; this.setSeconds(Math.floor(millsLeft / 1000) * orient); millsLeft = millsLeft % 1000; this.setMilliseconds(millsLeft * orient); } else { this.set(days, hours, minutes, seconds, milliseconds); } this.getTotalMilliseconds = function () { return (this.getDays() * 86400000) + (this.getHours() * 3600000) + (this.getMinutes() * 60000) + (this.getSeconds() * 1000); }; this.compareTo = function (time) { var t1 = new Date(1970, 1, 1, this.getHours(), this.getMinutes(), this.getSeconds()), t2; if (time === null) { t2 = new Date(1970, 1, 1, 0, 0, 0); } else { t2 = new Date(1970, 1, 1, time.getHours(), time.getMinutes(), time.getSeconds()); } return (t1 < t2) ? -1 : (t1 > t2) ? 1 : 0; }; this.equals = function (time) { return (this.compareTo(time) === 0); }; this.add = function (time) { return (time === null) ? this : this.addSeconds(time.getTotalMilliseconds() / 1000); }; this.subtract = function (time) { return (time === null) ? this : this.addSeconds(-time.getTotalMilliseconds() / 1000); }; this.addDays = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 86400000)); }; this.addHours = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 3600000)); }; this.addMinutes = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 60000)); }; this.addSeconds = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 1000)); }; this.addMilliseconds = function (n) { return new TimeSpan(this.getTotalMilliseconds() + n); }; this.get12HourHour = function () { return (this.getHours() > 12) ? this.getHours() - 12 : (this.getHours() === 0) ? 12 : this.getHours(); }; this.getDesignator = function () { return (this.getHours() < 12) ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator; }; this.toString = function (format) { this._toString = function () { if (this.getDays() !== null && this.getDays() > 0) { return this.getDays() + "." + this.getHours() + ":" + this.p(this.getMinutes()) + ":" + this.p(this.getSeconds()); } else { return this.getHours() + ":" + this.p(this.getMinutes()) + ":" + this.p(this.getSeconds()); } }; this.p = function (s) { return (s.toString().length < 2) ? "0" + s : s; }; var me = this; return format ? format.replace(/dd?|HH?|hh?|mm?|ss?|tt?/g, function (format) { switch (format) { case "d": return me.getDays(); case "dd": return me.p(me.getDays()); case "H": return me.getHours(); case "HH": return me.p(me.getHours()); case "h": return me.get12HourHour(); case "hh": return me.p(me.get12HourHour()); case "m": return me.getMinutes(); case "mm": return me.p(me.getMinutes()); case "s": return me.getSeconds(); case "ss": return me.p(me.getSeconds()); case "t": return ((me.getHours() < 12) ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator).substring(0, 1); case "tt": return (me.getHours() < 12) ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator; } } ) : this._toString(); }; return this; }; addSetFuncs(TimeSpan, attrs.slice(2)); TimeSpan.prototype.set = function (days, hours, minutes, seconds, milliseconds){ this.setDays(days || this.getDays()); this.setHours(hours || this.getHours()); this.setMinutes(minutes || this.getMinutes()); this.setSeconds(seconds || this.getSeconds()); this.setMilliseconds(milliseconds || this.getMilliseconds()); }; /** * Gets the time of day for this date instances. * @return {TimeSpan} TimeSpan */ Date.prototype.getTimeOfDay = function () { return new TimeSpan(0, this.getHours(), this.getMinutes(), this.getSeconds(), this.getMilliseconds()); }; Date.TimeSpan = TimeSpan; if (typeof window !== "undefined" ) { // keeping API compatible for v1.x window.TimeSpan = TimeSpan; } }()); (function () { "use strict"; var attrs = ["years", "months", "days", "hours", "minutes", "seconds", "milliseconds"]; var gFn = function (attr) { return function () { return this[attr]; }; }; var sFn = function (attr) { return function (val) { this[attr] = val; return this; }; }; var addSetFuncs = function (context, attrs) { for (var i = 0; i < attrs.length ; i++) { var $a = attrs[i], $b = $a.slice(0, 1).toUpperCase() + $a.slice(1); context.prototype[$a] = 0; context.prototype["get" + $b] = gFn($a); context.prototype["set" + $b] = sFn($a); } }; var setMonthsAndYears = function (orient, d1, d2, context) { function inc() { d1.addMonths(-orient); context.months++; if (context.months === 12) { context.years++; context.months = 0; } } if (orient === +1) { while (d1 > d2) { inc(); } } else { while (d1 < d2) { inc(); } } context.months--; context.months *= orient; context.years *= orient; }; var adjustForDST = function(orient, startDate, endDate) { var hasDSTMismatch = (false === (startDate.isDaylightSavingTime() === endDate.isDaylightSavingTime())); if (hasDSTMismatch && orient === 1) { startDate.addHours(-1); } else if (hasDSTMismatch) { startDate.addHours(1); } }; /** * TimePeriod(startDate, endDate); * TimePeriod(years, months, days, hours, minutes, seconds, milliseconds); */ var TimePeriod = function (years, months, days, hours, minutes, seconds, milliseconds) { if (arguments.length === 7) { this.set(years, months, days, hours, minutes, seconds, milliseconds); } else if (arguments.length === 2 && arguments[0] instanceof Date && arguments[1] instanceof Date) { var startDate = arguments[0].clone(); var endDate = arguments[1].clone(); var orient = (startDate > endDate) ? +1 : -1; this.dates = { start: arguments[0].clone(), end: arguments[1].clone() }; setMonthsAndYears(orient, startDate, endDate, this); adjustForDST(orient, startDate, endDate); // // TODO - adjust for DST var diff = endDate - startDate; if (diff !== 0) { var ts = new TimeSpan(diff); this.set(this.years, this.months, ts.getDays(), ts.getHours(), ts.getMinutes(), ts.getSeconds(), ts.getMilliseconds()); } } return this; }; // create all the set functions. addSetFuncs(TimePeriod, attrs); TimePeriod.prototype.set = function (years, months, days, hours, minutes, seconds, milliseconds){ this.setYears(years || this.getYears()); this.setMonths(months || this.getMonths()); this.setDays(days || this.getDays()); this.setHours(hours || this.getHours()); this.setMinutes(minutes || this.getMinutes()); this.setSeconds(seconds || this.getSeconds()); this.setMilliseconds(milliseconds || this.getMilliseconds()); }; Date.TimePeriod = TimePeriod; if (typeof window !== "undefined") { // keeping API compatible for v1.x window.TimePeriod = TimePeriod; } }()); ================================================ FILE: build/date-uz-Latn-UZ.js ================================================ /** * @overview datejs * @version 1.0.0-rc3 * @author Gregory Wild-Smith * @copyright 2015 Gregory Wild-Smith * @license MIT * @homepage https://github.com/abritinthebay/datejs */ /* * DateJS Culture String File * Country Code: uz-Latn-UZ * Name: Uzbek (Latin, Uzbekistan) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["uz-Latn-UZ"] = { "name": "uz-Latn-UZ", "englishName": "Uzbek (Latin, Uzbekistan)", "nativeName": "U'zbek (U'zbekiston Respublikasi)", "Sunday": "yakshanba", "Monday": "dushanba", "Tuesday": "seshanba", "Wednesday": "chorshanba", "Thursday": "payshanba", "Friday": "juma", "Saturday": "shanba", "Sun": "yak.", "Mon": "dsh.", "Tue": "sesh.", "Wed": "chr.", "Thu": "psh.", "Fri": "jm.", "Sat": "sh.", "Su": "yak", "Mo": "dsh", "Tu": "sesh", "We": "chr", "Th": "psh", "Fr": "jm", "Sa": "sh", "S_Sun_Initial": "y", "M_Mon_Initial": "d", "T_Tue_Initial": "s", "W_Wed_Initial": "c", "T_Thu_Initial": "p", "F_Fri_Initial": "j", "S_Sat_Initial": "s", "January": "yanvar", "February": "fevral", "March": "mart", "April": "aprel", "May": "may", "June": "iyun", "July": "iyul", "August": "avgust", "September": "sentyabr", "October": "oktyabr", "November": "noyabr", "December": "dekabr", "Jan_Abbr": "yanvar", "Feb_Abbr": "fevral", "Mar_Abbr": "mart", "Apr_Abbr": "aprel", "May_Abbr": "may", "Jun_Abbr": "iyun", "Jul_Abbr": "iyul", "Aug_Abbr": "avgust", "Sep_Abbr": "sentyabr", "Oct_Abbr": "oktyabr", "Nov_Abbr": "noyabr", "Dec_Abbr": "dekabr", "AM": "", "PM": "", "firstDayOfWeek": 1, "twoDigitYearMax": 2029, "mdy": "dmy", "M/d/yyyy": "dd/MM yyyy", "dddd, MMMM dd, yyyy": "yyyy 'yil' d-MMMM", "h:mm tt": "HH:mm", "h:mm:ss tt": "HH:mm:ss", "dddd, MMMM dd, yyyy h:mm:ss tt": "yyyy 'yil' d-MMMM HH:mm:ss", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "d-MMMM", "MMMM, yyyy": "MMMM yyyy", "/jan(uary)?/": "yanvar", "/feb(ruary)?/": "fevral", "/mar(ch)?/": "mart", "/apr(il)?/": "aprel", "/may/": "may", "/jun(e)?/": "iyun", "/jul(y)?/": "iyul", "/aug(ust)?/": "avgust", "/sep(t(ember)?)?/": "sentyabr", "/oct(ober)?/": "oktyabr", "/nov(ember)?/": "noyabr", "/dec(ember)?/": "dekabr", "/^su(n(day)?)?/": "^yak((.(shanba)?)?)?", "/^mo(n(day)?)?/": "^dsh((.(hanba)?)?)?", "/^tu(e(s(day)?)?)?/": "^sesh((.(anba)?)?)?", "/^we(d(nesday)?)?/": "^chr((.(rshanba)?)?)?", "/^th(u(r(s(day)?)?)?)?/": "^psh((.(shanba)?)?)?", "/^fr(i(day)?)?/": "^jm((.(ma)?)?)?", "/^sa(t(urday)?)?/": "^sh((.(anba)?)?)?", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "uz-Latn-UZ"; /** * @overview datejs * @version 1.0.0-rc3 * @author Gregory Wild-Smith * @copyright 2015 Gregory Wild-Smith * @license MIT * @homepage https://github.com/abritinthebay/datejs */(function () { var $D = Date; var lang = Date.CultureStrings ? Date.CultureStrings.lang : null; var loggedKeys = {}; // for debug purposes. var getText = { getFromKey: function (key, countryCode) { var output; if (Date.CultureStrings && Date.CultureStrings[countryCode] && Date.CultureStrings[countryCode][key]) { output = Date.CultureStrings[countryCode][key]; } else { output = getText.buildFromDefault(key); } if (key.charAt(0) === "/") { // Assume it's a regex output = getText.buildFromRegex(key, countryCode); } return output; }, getFromObjectValues: function (obj, countryCode) { var key, output = {}; for(key in obj) { if (obj.hasOwnProperty(key)) { output[key] = getText.getFromKey(obj[key], countryCode); } } return output; }, getFromObjectKeys: function (obj, countryCode) { var key, output = {}; for(key in obj) { if (obj.hasOwnProperty(key)) { output[getText.getFromKey(key, countryCode)] = obj[key]; } } return output; }, getFromArray: function (arr, countryCode) { var output = []; for (var i=0; i < arr.length; i++){ if (i in arr) { output[i] = getText.getFromKey(arr[i], countryCode); } } return output; }, buildFromDefault: function (key) { var output, length, split, last; switch(key) { case "name": output = "en-US"; break; case "englishName": output = "English (United States)"; break; case "nativeName": output = "English (United States)"; break; case "twoDigitYearMax": output = 2049; break; case "firstDayOfWeek": output = 0; break; default: output = key; split = key.split("_"); length = split.length; if (length > 1 && key.charAt(0) !== "/") { // if the key isn't a regex and it has a split. last = split[(length - 1)].toLowerCase(); if (last === "initial" || last === "abbr") { output = split[0]; } } break; } return output; }, buildFromRegex: function (key, countryCode) { var output; if (Date.CultureStrings && Date.CultureStrings[countryCode] && Date.CultureStrings[countryCode][key]) { output = new RegExp(Date.CultureStrings[countryCode][key], "i"); } else { output = new RegExp(key.replace(new RegExp("/", "g"),""), "i"); } return output; } }; var shallowMerge = function (obj1, obj2) { for (var attrname in obj2) { if (obj2.hasOwnProperty(attrname)) { obj1[attrname] = obj2[attrname]; } } }; var __ = function (key, language) { var countryCode = (language) ? language : lang; loggedKeys[key] = key; if (typeof key === "object") { if (key instanceof Array) { return getText.getFromArray(key, countryCode); } else { return getText.getFromObjectKeys(key, countryCode); } } else { return getText.getFromKey(key, countryCode); } }; var loadI18nScript = function (code) { // paatterned after jQuery's getScript. var url = Date.Config.i18n + code + ".js"; var head = document.getElementsByTagName("head")[0] || document.documentElement; var script = document.createElement("script"); script.src = url; var completed = false; var events = { done: function (){} // placeholder function }; // Attach handlers for all browsers script.onload = script.onreadystatechange = function() { if ( !completed && (!this.readyState || this.readyState === "loaded" || this.readyState === "complete") ) { events.done(); head.removeChild(script); } }; setTimeout(function() { head.insertBefore(script, head.firstChild); }, 0); // allows return to execute first return { done: function (cb) { events.done = function() { if (cb) { setTimeout(cb,0); } }; } }; }; var buildInfo = { buildFromMethodHash: function (obj) { var key; for(key in obj) { if (obj.hasOwnProperty(key)) { obj[key] = buildInfo[obj[key]](); } } return obj; }, timeZoneDST: function () { var DST = { "CHADT": "+1345", "NZDT": "+1300", "AEDT": "+1100", "ACDT": "+1030", "AZST": "+0500", "IRDT": "+0430", "EEST": "+0300", "CEST": "+0200", "BST": "+0100", "PMDT": "-0200", "ADT": "-0300", "NDT": "-0230", "EDT": "-0400", "CDT": "-0500", "MDT": "-0600", "PDT": "-0700", "AKDT": "-0800", "HADT": "-0900" }; return __(DST); }, timeZoneStandard: function () { var standard = { "LINT": "+1400", "TOT": "+1300", "CHAST": "+1245", "NZST": "+1200", "NFT": "+1130", "SBT": "+1100", "AEST": "+1000", "ACST": "+0930", "JST": "+0900", "CWST": "+0845", "CT": "+0800", "ICT": "+0700", "MMT": "+0630", "BST": "+0600", "NPT": "+0545", "IST": "+0530", "PKT": "+0500", "AFT": "+0430", "MSK": "+0400", "IRST": "+0330", "FET": "+0300", "EET": "+0200", "CET": "+0100", "GMT": "+0000", "UTC": "+0000", "CVT": "-0100", "GST": "-0200", "BRT": "-0300", "NST": "-0330", "AST": "-0400", "EST": "-0500", "CST": "-0600", "MST": "-0700", "PST": "-0800", "AKST": "-0900", "MIT": "-0930", "HST": "-1000", "SST": "-1100", "BIT": "-1200" }; return __(standard); }, timeZones: function (data) { var zone; data.timezones = []; for (zone in data.abbreviatedTimeZoneStandard) { if (data.abbreviatedTimeZoneStandard.hasOwnProperty(zone)) { data.timezones.push({ name: zone, offset: data.abbreviatedTimeZoneStandard[zone]}); } } for (zone in data.abbreviatedTimeZoneDST) { if (data.abbreviatedTimeZoneDST.hasOwnProperty(zone)) { data.timezones.push({ name: zone, offset: data.abbreviatedTimeZoneDST[zone], dst: true}); } } return data.timezones; }, days: function () { return __(["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"]); }, dayAbbr: function () { return __(["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"]); }, dayShortNames: function () { return __(["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"]); }, dayFirstLetters: function () { return __(["S_Sun_Initial", "M_Mon_Initial", "T_Tues_Initial", "W_Wed_Initial", "T_Thu_Initial", "F_Fri_Initial", "S_Sat_Initial"]); }, months: function () { return __(["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"]); }, monthAbbr: function () { return __(["Jan_Abbr", "Feb_Abbr", "Mar_Abbr", "Apr_Abbr", "May_Abbr", "Jun_Abbr", "Jul_Abbr", "Aug_Abbr", "Sep_Abbr", "Oct_Abbr", "Nov_Abbr", "Dec_Abbr"]); }, formatPatterns: function () { return getText.getFromObjectValues({ shortDate: "M/d/yyyy", longDate: "dddd, MMMM dd, yyyy", shortTime: "h:mm tt", longTime: "h:mm:ss tt", fullDateTime: "dddd, MMMM dd, yyyy h:mm:ss tt", sortableDateTime: "yyyy-MM-ddTHH:mm:ss", universalSortableDateTime: "yyyy-MM-dd HH:mm:ssZ", rfc1123: "ddd, dd MMM yyyy HH:mm:ss", monthDay: "MMMM dd", yearMonth: "MMMM, yyyy" }, Date.i18n.currentLanguage()); }, regex: function () { return getText.getFromObjectValues({ inTheMorning: "/( in the )(morn(ing)?)\\b/", thisMorning: "/(this )(morn(ing)?)\\b/", amThisMorning: "/(\b\\d(am)? )(this )(morn(ing)?)/", inTheEvening: "/( in the )(even(ing)?)\\b/", thisEvening: "/(this )(even(ing)?)\\b/", pmThisEvening: "/(\b\\d(pm)? )(this )(even(ing)?)/", jan: "/jan(uary)?/", feb: "/feb(ruary)?/", mar: "/mar(ch)?/", apr: "/apr(il)?/", may: "/may/", jun: "/jun(e)?/", jul: "/jul(y)?/", aug: "/aug(ust)?/", sep: "/sep(t(ember)?)?/", oct: "/oct(ober)?/", nov: "/nov(ember)?/", dec: "/dec(ember)?/", sun: "/^su(n(day)?)?/", mon: "/^mo(n(day)?)?/", tue: "/^tu(e(s(day)?)?)?/", wed: "/^we(d(nesday)?)?/", thu: "/^th(u(r(s(day)?)?)?)?/", fri: "/fr(i(day)?)?/", sat: "/^sa(t(urday)?)?/", future: "/^next/", past: "/^last|past|prev(ious)?/", add: "/^(\\+|aft(er)?|from|hence)/", subtract: "/^(\\-|bef(ore)?|ago)/", yesterday: "/^yes(terday)?/", today: "/^t(od(ay)?)?/", tomorrow: "/^tom(orrow)?/", now: "/^n(ow)?/", millisecond: "/^ms|milli(second)?s?/", second: "/^sec(ond)?s?/", minute: "/^mn|min(ute)?s?/", hour: "/^h(our)?s?/", week: "/^w(eek)?s?/", month: "/^m(onth)?s?/", day: "/^d(ay)?s?/", year: "/^y(ear)?s?/", shortMeridian: "/^(a|p)/", longMeridian: "/^(a\\.?m?\\.?|p\\.?m?\\.?)/", timezone: "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/", ordinalSuffix: "/^\\s*(st|nd|rd|th)/", timeContext: "/^\\s*(\\:|a(?!u|p)|p)/" }, Date.i18n.currentLanguage()); } }; var CultureInfo = function () { var info = getText.getFromObjectValues({ name: "name", englishName: "englishName", nativeName: "nativeName", amDesignator: "AM", pmDesignator: "PM", firstDayOfWeek: "firstDayOfWeek", twoDigitYearMax: "twoDigitYearMax", dateElementOrder: "mdy" }, Date.i18n.currentLanguage()); var constructedInfo = buildInfo.buildFromMethodHash({ dayNames: "days", abbreviatedDayNames: "dayAbbr", shortestDayNames: "dayShortNames", firstLetterDayNames: "dayFirstLetters", monthNames: "months", abbreviatedMonthNames: "monthAbbr", formatPatterns: "formatPatterns", regexPatterns: "regex", abbreviatedTimeZoneDST: "timeZoneDST", abbreviatedTimeZoneStandard: "timeZoneStandard" }); shallowMerge(info, constructedInfo); buildInfo.timeZones(info); return info; }; $D.i18n = { __: function (key, lang) { return __(key, lang); }, currentLanguage: function () { return lang || "en-US"; }, setLanguage: function (code, force, cb) { var async = false; if (force || code === "en-US" || (!!Date.CultureStrings && !!Date.CultureStrings[code])) { lang = code; Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings.lang = code; Date.CultureInfo = new CultureInfo(); } else { if (!(!!Date.CultureStrings && !!Date.CultureStrings[code])) { if (typeof exports !== "undefined" && this.exports !== exports) { // we're in a Node enviroment, load it using require try { require("../i18n/" + code + ".js"); lang = code; Date.CultureStrings.lang = code; Date.CultureInfo = new CultureInfo(); } catch (e) { // var str = "The language for '" + code + "' could not be loaded by Node. It likely does not exist."; throw new Error("The DateJS IETF language tag '" + code + "' could not be loaded by Node. It likely does not exist."); } } else if (Date.Config && Date.Config.i18n) { // we know the location of the files, so lets load them async = true; loadI18nScript(code).done(function(){ lang = code; Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings.lang = code; Date.CultureInfo = new CultureInfo(); $D.Parsing.Normalizer.buildReplaceData(); // because this is async if ($D.Grammar) { $D.Grammar.buildGrammarFormats(); // so we can parse those strings... } if (cb) { setTimeout(cb,0); } }); } else { Date.console.error("The DateJS IETF language tag '" + code + "' is not available and has not been loaded."); return false; } } } $D.Parsing.Normalizer.buildReplaceData(); // rebuild normalizer strings if ($D.Grammar) { $D.Grammar.buildGrammarFormats(); // so we can parse those strings... } if (!async && cb) { setTimeout(cb,0); } }, getLoggedKeys: function () { return loggedKeys; }, updateCultureInfo: function () { Date.CultureInfo = new CultureInfo(); } }; $D.i18n.updateCultureInfo(); // run automatically }()); (function () { var $D = Date, $P = $D.prototype, p = function (s, l) { if (!l) { l = 2; } return ("000" + s).slice(l * -1); }; if (typeof window !== "undefined" && typeof window.console !== "undefined" && typeof window.console.log !== "undefined") { $D.console = console; // used only to raise non-critical errors if available } else { // set mock so we don't give errors. $D.console = { log: function(){}, error: function(){} }; } $D.Config = $D.Config || {}; $D.initOverloads = function() { /** * Overload of Date.now. Allows an alternate call for Date.now where it returns the * current Date as an object rather than just milliseconds since the Unix Epoch. * * Also provides an implementation of now() for browsers (IE<9) that don't have it. * * Backwards compatible so with work with either: * Date.now() [returns ms] * or * Date.now(true) [returns Date] */ if (!$D.now) { $D._now = function now() { return new Date().getTime(); }; } else if (!$D._now) { $D._now = $D.now; } $D.now = function (returnObj) { if (returnObj) { return $D.present(); } else { return $D._now(); } }; if ( !$P.toISOString ) { $P.toISOString = function() { return this.getUTCFullYear() + "-" + p(this.getUTCMonth() + 1) + "-" + p(this.getUTCDate()) + "T" + p(this.getUTCHours()) + ":" + p(this.getUTCMinutes()) + ":" + p(this.getUTCSeconds()) + "." + String( (this.getUTCMilliseconds()/1000).toFixed(3)).slice(2, 5) + "Z"; }; } // private if ( $P._toString === undefined ){ $P._toString = $P.toString; } }; $D.initOverloads(); /** * Gets a date that is set to the current date. The time is set to the start of the day (00:00 or 12:00 AM). * @return {Date} The current date. */ $D.today = function () { return new Date().clearTime(); }; /** * Gets a date that is set to the current date and time (same as new Date, but chainable) * @return {Date} The current date. */ $D.present = function () { return new Date(); }; /** * Compares the first date to the second date and returns an number indication of their relative values. * @param {Date} First Date object to compare [Required]. * @param {Date} Second Date object to compare to [Required]. * @return {Number} -1 = date1 is lessthan date2. 0 = values are equal. 1 = date1 is greaterthan date2. */ $D.compare = function (date1, date2) { if (isNaN(date1) || isNaN(date2)) { throw new Error(date1 + " - " + date2); } else if (date1 instanceof Date && date2 instanceof Date) { return (date1 < date2) ? -1 : (date1 > date2) ? 1 : 0; } else { throw new TypeError(date1 + " - " + date2); } }; /** * Compares the first Date object to the second Date object and returns true if they are equal. * @param {Date} First Date object to compare [Required] * @param {Date} Second Date object to compare to [Required] * @return {Boolean} true if dates are equal. false if they are not equal. */ $D.equals = function (date1, date2) { return (date1.compareTo(date2) === 0); }; /** * Gets the language appropriate day name when given the day number(0-6) * eg - 0 == Sunday * @return {String} The day name */ $D.getDayName = function (n) { return Date.CultureInfo.dayNames[n]; }; /** * Gets the day number (0-6) if given a CultureInfo specific string which is a valid dayName, abbreviatedDayName or shortestDayName (two char). * @param {String} The name of the day (eg. "Monday, "Mon", "tuesday", "tue", "We", "we"). * @return {Number} The day number */ $D.getDayNumberFromName = function (name) { var n = Date.CultureInfo.dayNames, m = Date.CultureInfo.abbreviatedDayNames, o = Date.CultureInfo.shortestDayNames, s = name.toLowerCase(); for (var i = 0; i < n.length; i++) { if (n[i].toLowerCase() === s || m[i].toLowerCase() === s || o[i].toLowerCase() === s) { return i; } } return -1; }; /** * Gets the month number (0-11) if given a Culture Info specific string which is a valid monthName or abbreviatedMonthName. * @param {String} The name of the month (eg. "February, "Feb", "october", "oct"). * @return {Number} The day number */ $D.getMonthNumberFromName = function (name) { var n = Date.CultureInfo.monthNames, m = Date.CultureInfo.abbreviatedMonthNames, s = name.toLowerCase(); for (var i = 0; i < n.length; i++) { if (n[i].toLowerCase() === s || m[i].toLowerCase() === s) { return i; } } return -1; }; /** * Gets the language appropriate month name when given the month number(0-11) * eg - 0 == January * @return {String} The month name */ $D.getMonthName = function (n) { return Date.CultureInfo.monthNames[n]; }; /** * Determines if the current date instance is within a LeapYear. * @param {Number} The year. * @return {Boolean} true if date is within a LeapYear, otherwise false. */ $D.isLeapYear = function (year) { return ((year % 4 === 0 && year % 100 !== 0) || year % 400 === 0); }; /** * Gets the number of days in the month, given a year and month value. Automatically corrects for LeapYear. * @param {Number} The year. * @param {Number} The month (0-11). * @return {Number} The number of days in the month. */ $D.getDaysInMonth = function (year, month) { if (!month && $D.validateMonth(year)) { month = year; year = Date.today().getFullYear(); } return [31, ($D.isLeapYear(year) ? 29 : 28), 31, 30, 31, 30, 31, 31, 30, 31, 30, 31][month]; }; $P.getDaysInMonth = function () { return $D.getDaysInMonth(this.getFullYear(), this.getMonth()); }; $D.getTimezoneAbbreviation = function (offset, dst) { var p, n = (dst || false) ? Date.CultureInfo.abbreviatedTimeZoneDST : Date.CultureInfo.abbreviatedTimeZoneStandard; for (p in n) { if (n.hasOwnProperty(p)) { if (n[p] === offset) { return p; } } } return null; }; $D.getTimezoneOffset = function (name, dst) { var i, a =[], z = Date.CultureInfo.timezones; if (!name) { name = (new Date()).getTimezone();} for (i = 0; i < z.length; i++) { if (z[i].name === name.toUpperCase()) { a.push(i); } } if (!z[a[0]]) { return null; } if (a.length === 1 || !dst) { return z[a[0]].offset; } else { for (i=0; i < a.length; i++) { if (z[a[i]].dst) { return z[a[i]].offset; } } } }; $D.getQuarter = function (d) { d = d || new Date(); // If no date supplied, use today var q = [1,2,3,4]; return q[Math.floor(d.getMonth() / 3)]; // ~~~ is a bitwise op. Faster than Math.floor }; $D.getDaysLeftInQuarter = function (d) { d = d || new Date(); var qEnd = new Date(d); qEnd.setMonth(qEnd.getMonth() + 3 - qEnd.getMonth() % 3, 0); return Math.floor((qEnd - d) / 8.64e7); }; // private var validate = function (n, min, max, name) { name = name ? name : "Object"; if (typeof n === "undefined") { return false; } else if (typeof n !== "number") { throw new TypeError(n + " is not a Number."); } else if (n < min || n > max) { // As failing validation is *not* an exceptional circumstance // lets not throw a RangeError Exception here. // It's semantically correct but it's not sensible. return false; } return true; }; /** * Validates the number is within an acceptable range for milliseconds [0-999]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateMillisecond = function (value) { return validate(value, 0, 999, "millisecond"); }; /** * Validates the number is within an acceptable range for seconds [0-59]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateSecond = function (value) { return validate(value, 0, 59, "second"); }; /** * Validates the number is within an acceptable range for minutes [0-59]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateMinute = function (value) { return validate(value, 0, 59, "minute"); }; /** * Validates the number is within an acceptable range for hours [0-23]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateHour = function (value) { return validate(value, 0, 23, "hour"); }; /** * Validates the number is within an acceptable range for the days in a month [0-MaxDaysInMonth]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateDay = function (value, year, month) { if (year === undefined || year === null || month === undefined || month === null) { return false;} return validate(value, 1, $D.getDaysInMonth(year, month), "day"); }; /** * Validates the number is within an acceptable range for months [0-11]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateWeek = function (value) { return validate(value, 0, 53, "week"); }; /** * Validates the number is within an acceptable range for months [0-11]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateMonth = function (value) { return validate(value, 0, 11, "month"); }; /** * Validates the number is within an acceptable range for years. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateYear = function (value) { /** * Per ECMAScript spec the range of times supported by Date objects is * exactly -100,000,000 days to +100,000,000 days measured relative to * midnight at the beginning of 01 January, 1970 UTC. * This gives a range of 8,640,000,000,000,000 milliseconds to either * side of 01 January, 1970 UTC. * * Earliest possible date: Tue, 20 Apr 271,822 B.C. 00:00:00 UTC * Latest possible date: Sat, 13 Sep 275,760 00:00:00 UTC */ return validate(value, -271822, 275760, "year"); }; $D.validateTimezone = function(value) { var timezones = {"ACDT":1,"ACST":1,"ACT":1,"ADT":1,"AEDT":1,"AEST":1,"AFT":1,"AKDT":1,"AKST":1,"AMST":1,"AMT":1,"ART":1,"AST":1,"AWDT":1,"AWST":1,"AZOST":1,"AZT":1,"BDT":1,"BIOT":1,"BIT":1,"BOT":1,"BRT":1,"BST":1,"BTT":1,"CAT":1,"CCT":1,"CDT":1,"CEDT":1,"CEST":1,"CET":1,"CHADT":1,"CHAST":1,"CHOT":1,"ChST":1,"CHUT":1,"CIST":1,"CIT":1,"CKT":1,"CLST":1,"CLT":1,"COST":1,"COT":1,"CST":1,"CT":1,"CVT":1,"CWST":1,"CXT":1,"DAVT":1,"DDUT":1,"DFT":1,"EASST":1,"EAST":1,"EAT":1,"ECT":1,"EDT":1,"EEDT":1,"EEST":1,"EET":1,"EGST":1,"EGT":1,"EIT":1,"EST":1,"FET":1,"FJT":1,"FKST":1,"FKT":1,"FNT":1,"GALT":1,"GAMT":1,"GET":1,"GFT":1,"GILT":1,"GIT":1,"GMT":1,"GST":1,"GYT":1,"HADT":1,"HAEC":1,"HAST":1,"HKT":1,"HMT":1,"HOVT":1,"HST":1,"ICT":1,"IDT":1,"IOT":1,"IRDT":1,"IRKT":1,"IRST":1,"IST":1,"JST":1,"KGT":1,"KOST":1,"KRAT":1,"KST":1,"LHST":1,"LINT":1,"MAGT":1,"MART":1,"MAWT":1,"MDT":1,"MET":1,"MEST":1,"MHT":1,"MIST":1,"MIT":1,"MMT":1,"MSK":1,"MST":1,"MUT":1,"MVT":1,"MYT":1,"NCT":1,"NDT":1,"NFT":1,"NPT":1,"NST":1,"NT":1,"NUT":1,"NZDT":1,"NZST":1,"OMST":1,"ORAT":1,"PDT":1,"PET":1,"PETT":1,"PGT":1,"PHOT":1,"PHT":1,"PKT":1,"PMDT":1,"PMST":1,"PONT":1,"PST":1,"PYST":1,"PYT":1,"RET":1,"ROTT":1,"SAKT":1,"SAMT":1,"SAST":1,"SBT":1,"SCT":1,"SGT":1,"SLST":1,"SRT":1,"SST":1,"SYOT":1,"TAHT":1,"THA":1,"TFT":1,"TJT":1,"TKT":1,"TLT":1,"TMT":1,"TOT":1,"TVT":1,"UCT":1,"ULAT":1,"UTC":1,"UYST":1,"UYT":1,"UZT":1,"VET":1,"VLAT":1,"VOLT":1,"VOST":1,"VUT":1,"WAKT":1,"WAST":1,"WAT":1,"WEDT":1,"WEST":1,"WET":1,"WST":1,"YAKT":1,"YEKT":1,"Z":1}; return (timezones[value] === 1); }; $D.validateTimezoneOffset= function(value) { // timezones go from +14hrs to -12hrs, the +X hours are negative offsets. return (value > -841 && value < 721); }; }()); (function () { var $D = Date, $P = $D.prototype, p = function (s, l) { if (!l) { l = 2; } return ("000" + s).slice(l * -1); }; var validateConfigObject = function (obj) { var result = {}, self = this, prop, testFunc; testFunc = function (prop, func, value) { if (prop === "day") { var month = (obj.month !== undefined) ? obj.month : self.getMonth(); var year = (obj.year !== undefined) ? obj.year : self.getFullYear(); return $D[func](value, year, month); } else { return $D[func](value); } }; for (prop in obj) { if (Object.prototype.hasOwnProperty.call(obj, prop)) { var func = "validate" + prop.charAt(0).toUpperCase() + prop.slice(1); if ($D[func] && obj[prop] !== null && testFunc(prop, func, obj[prop])) { result[prop] = obj[prop]; } } } return result; }; /** * Resets the time of this Date object to 12:00 AM (00:00), which is the start of the day. * @param {Boolean} .clone() this date instance before clearing Time * @return {Date} this */ $P.clearTime = function () { this.setHours(0); this.setMinutes(0); this.setSeconds(0); this.setMilliseconds(0); return this; }; /** * Resets the time of this Date object to the current time ('now'). * @return {Date} this */ $P.setTimeToNow = function () { var n = new Date(); this.setHours(n.getHours()); this.setMinutes(n.getMinutes()); this.setSeconds(n.getSeconds()); this.setMilliseconds(n.getMilliseconds()); return this; }; /** * Returns a new Date object that is an exact date and time copy of the original instance. * @return {Date} A new Date instance */ $P.clone = function () { return new Date(this.getTime()); }; /** * Compares this instance to a Date object and returns an number indication of their relative values. * @param {Date} Date object to compare [Required] * @return {Number} -1 = this is lessthan date. 0 = values are equal. 1 = this is greaterthan date. */ $P.compareTo = function (date) { return Date.compare(this, date); }; /** * Compares this instance to another Date object and returns true if they are equal. * @param {Date} Date object to compare. If no date to compare, new Date() [now] is used. * @return {Boolean} true if dates are equal. false if they are not equal. */ $P.equals = function (date) { return Date.equals(this, (date !== undefined ? date : new Date())); }; /** * Determines if this instance is between a range of two dates or equal to either the start or end dates. * @param {Date} Start of range [Required] * @param {Date} End of range [Required] * @return {Boolean} true is this is between or equal to the start and end dates, else false */ $P.between = function (start, end) { return this.getTime() >= start.getTime() && this.getTime() <= end.getTime(); }; /** * Determines if this date occurs after the date to compare to. * @param {Date} Date object to compare. If no date to compare, new Date() ("now") is used. * @return {Boolean} true if this date instance is greater than the date to compare to (or "now"), otherwise false. */ $P.isAfter = function (date) { return this.compareTo(date || new Date()) === 1; }; /** * Determines if this date occurs before the date to compare to. * @param {Date} Date object to compare. If no date to compare, new Date() ("now") is used. * @return {Boolean} true if this date instance is less than the date to compare to (or "now"). */ $P.isBefore = function (date) { return (this.compareTo(date || new Date()) === -1); }; /** * Determines if the current Date instance occurs today. * @return {Boolean} true if this date instance is 'today', otherwise false. */ /** * Determines if the current Date instance occurs on the same Date as the supplied 'date'. * If no 'date' to compare to is provided, the current Date instance is compared to 'today'. * @param {date} Date object to compare. If no date to compare, the current Date ("now") is used. * @return {Boolean} true if this Date instance occurs on the same Day as the supplied 'date'. */ $P.isToday = $P.isSameDay = function (date) { return this.clone().clearTime().equals((date || new Date()).clone().clearTime()); }; /** * Adds the specified number of milliseconds to this instance. * @param {Number} The number of milliseconds to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addMilliseconds = function (value) { if (!value) { return this; } this.setTime(this.getTime() + value * 1); return this; }; /** * Adds the specified number of seconds to this instance. * @param {Number} The number of seconds to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addSeconds = function (value) { if (!value) { return this; } return this.addMilliseconds(value * 1000); }; /** * Adds the specified number of seconds to this instance. * @param {Number} The number of seconds to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addMinutes = function (value) { if (!value) { return this; } return this.addMilliseconds(value * 60000); // 60*1000 }; /** * Adds the specified number of hours to this instance. * @param {Number} The number of hours to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addHours = function (value) { if (!value) { return this; } return this.addMilliseconds(value * 3600000); // 60*60*1000 }; /** * Adds the specified number of days to this instance. * @param {Number} The number of days to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addDays = function (value) { if (!value) { return this; } this.setDate(this.getDate() + value * 1); return this; }; /** * Adds the specified number of weekdays (ie - not sat or sun) to this instance. * @param {Number} The number of days to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addWeekdays = function (value) { if (!value) { return this; } var day = this.getDay(); var weeks = (Math.ceil(Math.abs(value)/7)); if (day === 0 || day === 6) { if (value > 0) { this.next().monday(); this.addDays(-1); day = this.getDay(); } } if (value < 0) { while (value < 0) { this.addDays(-1); day = this.getDay(); if (day !== 0 && day !== 6) { value++; } } return this; } else if (value > 5 || (6-day) <= value) { value = value + (weeks * 2); } return this.addDays(value); }; /** * Adds the specified number of weeks to this instance. * @param {Number} The number of weeks to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addWeeks = function (value) { if (!value) { return this; } return this.addDays(value * 7); }; /** * Adds the specified number of months to this instance. * @param {Number} The number of months to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addMonths = function (value) { if (!value) { return this; } var n = this.getDate(); this.setDate(1); this.setMonth(this.getMonth() + value * 1); this.setDate(Math.min(n, $D.getDaysInMonth(this.getFullYear(), this.getMonth()))); return this; }; $P.addQuarters = function (value) { if (!value) { return this; } // note this will take you to the same point in the quarter as you are now. // i.e. - if you are 15 days into the quarter you'll be 15 days into the resulting one. // bonus: this allows adding fractional quarters return this.addMonths(value * 3); }; /** * Adds the specified number of years to this instance. * @param {Number} The number of years to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addYears = function (value) { if (!value) { return this; } return this.addMonths(value * 12); }; /** * Adds (or subtracts) to the value of the years, months, weeks, days, hours, minutes, seconds, milliseconds of the date instance using given configuration object. Positive and Negative values allowed. * Example

	Date.today().add( { days: 1, months: 1 } )

	new Date().add( { years: -1 } )
	
* @param {Object} Configuration object containing attributes (months, days, etc.) * @return {Date} this */ $P.add = function (config) { if (typeof config === "number") { this._orient = config; return this; } var x = config; if (x.day) { // If we should be a different date than today (eg: for 'tomorrow -1d', etc). // Should only effect parsing, not direct usage (eg, Finish and FinishExact) if ((x.day - this.getDate()) !== 0) { this.setDate(x.day); } } if (x.milliseconds) { this.addMilliseconds(x.milliseconds); } if (x.seconds) { this.addSeconds(x.seconds); } if (x.minutes) { this.addMinutes(x.minutes); } if (x.hours) { this.addHours(x.hours); } if (x.weeks) { this.addWeeks(x.weeks); } if (x.months) { this.addMonths(x.months); } if (x.years) { this.addYears(x.years); } if (x.days) { this.addDays(x.days); } return this; }; /** * Get the week number. Week one (1) is the week which contains the first Thursday of the year. Monday is considered the first day of the week. * The .getWeek() function does NOT convert the date to UTC. The local datetime is used. * Please use .getISOWeek() to get the week of the UTC converted date. * @return {Number} 1 to 53 */ $P.getWeek = function (utc) { // Create a copy of this date object var self, target = new Date(this.valueOf()); if (utc) { target.addMinutes(target.getTimezoneOffset()); self = target.clone(); } else { self = this; } // ISO week date weeks start on monday // so correct the day number var dayNr = (self.getDay() + 6) % 7; // ISO 8601 states that week 1 is the week // with the first thursday of that year. // Set the target date to the thursday in the target week target.setDate(target.getDate() - dayNr + 3); // Store the millisecond value of the target date var firstThursday = target.valueOf(); // Set the target to the first thursday of the year // First set the target to january first target.setMonth(0, 1); // Not a thursday? Correct the date to the next thursday if (target.getDay() !== 4) { target.setMonth(0, 1 + ((4 - target.getDay()) + 7) % 7); } // The weeknumber is the number of weeks between the // first thursday of the year and the thursday in the target week return 1 + Math.ceil((firstThursday - target) / 604800000); // 604800000 = 7 * 24 * 3600 * 1000 }; /** * Get the ISO 8601 week number. Week one ("01") is the week which contains the first Thursday of the year. Monday is considered the first day of the week. * The .getISOWeek() function does convert the date to it's UTC value. Please use .getWeek() to get the week of the local date. * @return {String} "01" to "53" */ $P.getISOWeek = function () { return p(this.getWeek(true)); }; /** * Moves the date to Monday of the week set. Week one (1) is the week which contains the first Thursday of the year. * @param {Number} A Number (1 to 53) that represents the week of the year. * @return {Date} this */ $P.setWeek = function (n) { if ((n - this.getWeek()) === 0) { if (this.getDay() !== 1) { return this.moveToDayOfWeek(1, (this.getDay() > 1 ? -1 : 1)); } else { return this; } } else { return this.moveToDayOfWeek(1, (this.getDay() > 1 ? -1 : 1)).addWeeks(n - this.getWeek()); } }; $P.setQuarter = function (qtr) { var month = Math.abs(((qtr-1) * 3) + 1); return this.setMonth(month, 1); }; $P.getQuarter = function () { return Date.getQuarter(this); }; $P.getDaysLeftInQuarter = function () { return Date.getDaysLeftInQuarter(this); }; /** * Moves the date to the next n'th occurrence of the dayOfWeek starting from the beginning of the month. The number (-1) is a magic number and will return the last occurrence of the dayOfWeek in the month. * @param {Number} The dayOfWeek to move to * @param {Number} The n'th occurrence to move to. Use (-1) to return the last occurrence in the month * @return {Date} this */ $P.moveToNthOccurrence = function (dayOfWeek, occurrence) { if (dayOfWeek === "Weekday") { if (occurrence > 0) { this.moveToFirstDayOfMonth(); if (this.is().weekday()) { occurrence -= 1; } } else if (occurrence < 0) { this.moveToLastDayOfMonth(); if (this.is().weekday()) { occurrence += 1; } } else { return this; } return this.addWeekdays(occurrence); } var shift = 0; if (occurrence > 0) { shift = occurrence - 1; } else if (occurrence === -1) { this.moveToLastDayOfMonth(); if (this.getDay() !== dayOfWeek) { this.moveToDayOfWeek(dayOfWeek, -1); } return this; } return this.moveToFirstDayOfMonth().addDays(-1).moveToDayOfWeek(dayOfWeek, +1).addWeeks(shift); }; var moveToN = function (getFunc, addFunc, nVal) { return function (value, orient) { var diff = (value - this[getFunc]() + nVal * (orient || +1)) % nVal; return this[addFunc]((diff === 0) ? diff += nVal * (orient || +1) : diff); }; }; /** * Move to the next or last dayOfWeek based on the orient value. * @param {Number} The dayOfWeek to move to * @param {Number} Forward (+1) or Back (-1). Defaults to +1. [Optional] * @return {Date} this */ $P.moveToDayOfWeek = moveToN("getDay", "addDays", 7); /** * Move to the next or last month based on the orient value. * @param {Number} The month to move to. 0 = January, 11 = December * @param {Number} Forward (+1) or Back (-1). Defaults to +1. [Optional] * @return {Date} this */ $P.moveToMonth = moveToN("getMonth", "addMonths", 12); /** * Get the Ordinate of the current day ("th", "st", "rd"). * @return {String} */ $P.getOrdinate = function () { var num = this.getDate(); return ord(num); }; /** * Get the Ordinal day (numeric day number) of the year, adjusted for leap year. * @return {Number} 1 through 365 (366 in leap years) */ $P.getOrdinalNumber = function () { return Math.ceil((this.clone().clearTime() - new Date(this.getFullYear(), 0, 1)) / 86400000) + 1; }; /** * Get the time zone abbreviation of the current date. * @return {String} The abbreviated time zone name (e.g. "EST") */ $P.getTimezone = function () { return $D.getTimezoneAbbreviation(this.getUTCOffset(), this.isDaylightSavingTime()); }; $P.setTimezoneOffset = function (offset) { var here = this.getTimezoneOffset(), there = Number(offset) * -6 / 10; return (there || there === 0) ? this.addMinutes(there - here) : this; }; $P.setTimezone = function (offset) { return this.setTimezoneOffset($D.getTimezoneOffset(offset)); }; /** * Indicates whether Daylight Saving Time is observed in the current time zone. * @return {Boolean} true|false */ $P.hasDaylightSavingTime = function () { return (Date.today().set({month: 0, day: 1}).getTimezoneOffset() !== Date.today().set({month: 6, day: 1}).getTimezoneOffset()); }; /** * Indicates whether this Date instance is within the Daylight Saving Time range for the current time zone. * @return {Boolean} true|false */ $P.isDaylightSavingTime = function () { return Date.today().set({month: 0, day: 1}).getTimezoneOffset() !== this.getTimezoneOffset(); }; /** * Get the offset from UTC of the current date. * @return {String} The 4-character offset string prefixed with + or - (e.g. "-0500") */ $P.getUTCOffset = function (offset) { var n = (offset || this.getTimezoneOffset()) * -10 / 6, r; if (n < 0) { r = (n - 10000).toString(); return r.charAt(0) + r.substr(2); } else { r = (n + 10000).toString(); return "+" + r.substr(1); } }; /** * Returns the number of milliseconds between this date and date. * @param {Date} Defaults to now * @return {Number} The diff in milliseconds */ $P.getElapsed = function (date) { return (date || new Date()) - this; }; /** * Set the value of year, month, day, hour, minute, second, millisecond of date instance using given configuration object. * Example

	Date.today().set( { day: 20, month: 1 } )

	new Date().set( { millisecond: 0 } )
	
* * @param {Object} Configuration object containing attributes (month, day, etc.) * @return {Date} this */ $P.set = function (config) { config = validateConfigObject.call(this, config); var key; for (key in config) { if (Object.prototype.hasOwnProperty.call(config, key)) { var name = key.charAt(0).toUpperCase() + key.slice(1); var addFunc, getFunc; if (key !== "week" && key !== "month" && key !== "timezone" && key !== "timezoneOffset") { name += "s"; } addFunc = "add" + name; getFunc = "get" + name; if (key === "month") { addFunc = addFunc + "s"; } else if (key === "year"){ getFunc = "getFullYear"; } if (key !== "day" && key !== "timezone" && key !== "timezoneOffset" && key !== "week" && key !== "hour") { this[addFunc](config[key] - this[getFunc]()); } else if ( key === "timezone"|| key === "timezoneOffset" || key === "week" || key === "hour") { this["set"+name](config[key]); } } } // day has to go last because you can't validate the day without first knowing the month if (config.day) { this.addDays(config.day - this.getDate()); } return this; }; /** * Moves the date to the first day of the month. * @return {Date} this */ $P.moveToFirstDayOfMonth = function () { return this.set({ day: 1 }); }; /** * Moves the date to the last day of the month. * @return {Date} this */ $P.moveToLastDayOfMonth = function () { return this.set({ day: $D.getDaysInMonth(this.getFullYear(), this.getMonth())}); }; /** * Converts the value of the current Date object to its equivalent string representation. * Format Specifiers * CUSTOM DATE AND TIME FORMAT STRINGS * Format Description Example * ------ --------------------------------------------------------------------------- ----------------------- * s The seconds of the minute between 0-59. "0" to "59" * ss The seconds of the minute with leading zero if required. "00" to "59" * * m The minute of the hour between 0-59. "0" or "59" * mm The minute of the hour with leading zero if required. "00" or "59" * * h The hour of the day between 1-12. "1" to "12" * hh The hour of the day with leading zero if required. "01" to "12" * * H The hour of the day between 0-23. "0" to "23" * HH The hour of the day with leading zero if required. "00" to "23" * * d The day of the month between 1 and 31. "1" to "31" * dd The day of the month with leading zero if required. "01" to "31" * ddd Abbreviated day name. Date.CultureInfo.abbreviatedDayNames. "Mon" to "Sun" * dddd The full day name. Date.CultureInfo.dayNames. "Monday" to "Sunday" * * M The month of the year between 1-12. "1" to "12" * MM The month of the year with leading zero if required. "01" to "12" * MMM Abbreviated month name. Date.CultureInfo.abbreviatedMonthNames. "Jan" to "Dec" * MMMM The full month name. Date.CultureInfo.monthNames. "January" to "December" * * yy The year as a two-digit number. "99" or "08" * yyyy The full four digit year. "1999" or "2008" * * t Displays the first character of the A.M./P.M. designator. "A" or "P" * Date.CultureInfo.amDesignator or Date.CultureInfo.pmDesignator * tt Displays the A.M./P.M. designator. "AM" or "PM" * Date.CultureInfo.amDesignator or Date.CultureInfo.pmDesignator * * S The ordinal suffix ("st, "nd", "rd" or "th") of the current day. "st, "nd", "rd" or "th" * * STANDARD DATE AND TIME FORMAT STRINGS * Format Description Example *------ --------------------------------------------------------------------------- ----------------------- * d The CultureInfo shortDate Format Pattern "M/d/yyyy" * D The CultureInfo longDate Format Pattern "dddd, MMMM dd, yyyy" * F The CultureInfo fullDateTime Format Pattern "dddd, MMMM dd, yyyy h:mm:ss tt" * m The CultureInfo monthDay Format Pattern "MMMM dd" * r The CultureInfo rfc1123 Format Pattern "ddd, dd MMM yyyy HH:mm:ss GMT" * s The CultureInfo sortableDateTime Format Pattern "yyyy-MM-ddTHH:mm:ss" * t The CultureInfo shortTime Format Pattern "h:mm tt" * T The CultureInfo longTime Format Pattern "h:mm:ss tt" * u The CultureInfo universalSortableDateTime Format Pattern "yyyy-MM-dd HH:mm:ssZ" * y The CultureInfo yearMonth Format Pattern "MMMM, yyyy" * * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @return {String} A string representation of the current Date object. */ var ord = function (n) { switch (n * 1) { case 1: case 21: case 31: return "st"; case 2: case 22: return "nd"; case 3: case 23: return "rd"; default: return "th"; } }; var parseStandardFormats = function (format) { var y, c = Date.CultureInfo.formatPatterns; switch (format) { case "d": return this.toString(c.shortDate); case "D": return this.toString(c.longDate); case "F": return this.toString(c.fullDateTime); case "m": return this.toString(c.monthDay); case "r": case "R": y = this.clone().addMinutes(this.getTimezoneOffset()); return y.toString(c.rfc1123) + " GMT"; case "s": return this.toString(c.sortableDateTime); case "t": return this.toString(c.shortTime); case "T": return this.toString(c.longTime); case "u": y = this.clone().addMinutes(this.getTimezoneOffset()); return y.toString(c.universalSortableDateTime); case "y": return this.toString(c.yearMonth); default: return false; } }; var parseFormatStringsClosure = function (context) { return function (m) { if (m.charAt(0) === "\\") { return m.replace("\\", ""); } switch (m) { case "hh": return p(context.getHours() < 13 ? (context.getHours() === 0 ? 12 : context.getHours()) : (context.getHours() - 12)); case "h": return context.getHours() < 13 ? (context.getHours() === 0 ? 12 : context.getHours()) : (context.getHours() - 12); case "HH": return p(context.getHours()); case "H": return context.getHours(); case "mm": return p(context.getMinutes()); case "m": return context.getMinutes(); case "ss": return p(context.getSeconds()); case "s": return context.getSeconds(); case "yyyy": return p(context.getFullYear(), 4); case "yy": return p(context.getFullYear()); case "y": return context.getFullYear(); case "E": case "dddd": return Date.CultureInfo.dayNames[context.getDay()]; case "ddd": return Date.CultureInfo.abbreviatedDayNames[context.getDay()]; case "dd": return p(context.getDate()); case "d": return context.getDate(); case "MMMM": return Date.CultureInfo.monthNames[context.getMonth()]; case "MMM": return Date.CultureInfo.abbreviatedMonthNames[context.getMonth()]; case "MM": return p((context.getMonth() + 1)); case "M": return context.getMonth() + 1; case "t": return context.getHours() < 12 ? Date.CultureInfo.amDesignator.substring(0, 1) : Date.CultureInfo.pmDesignator.substring(0, 1); case "tt": return context.getHours() < 12 ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator; case "S": return ord(context.getDate()); case "W": return context.getWeek(); case "WW": return context.getISOWeek(); case "Q": return "Q" + context.getQuarter(); case "q": return String(context.getQuarter()); case "z": return context.getTimezone(); case "Z": case "X": return Date.getTimezoneOffset(context.getTimezone()); case "ZZ": // Timezone offset in seconds return context.getTimezoneOffset() * -60; case "u": return context.getDay(); case "L": return ($D.isLeapYear(context.getFullYear())) ? 1 : 0; case "B": // Swatch Internet Time (.beats) return "@"+((context.getUTCSeconds() + (context.getUTCMinutes()*60) + ((context.getUTCHours()+1)*3600))/86.4); default: return m; } }; }; $P.toString = function (format, ignoreStandards) { // Standard Date and Time Format Strings. Formats pulled from CultureInfo file and // may vary by culture. if (!ignoreStandards && format && format.length === 1) { output = parseStandardFormats.call(this, format); if (output) { return output; } } var parseFormatStrings = parseFormatStringsClosure(this); return format ? format.replace(/((\\)?(dd?d?d?|MM?M?M?|yy?y?y?|hh?|HH?|mm?|ss?|tt?|S|q|Q|WW?W?W?)(?![^\[]*\]))/g, parseFormatStrings).replace(/\[|\]/g, "") : this._toString(); }; }()); /************************************************************* * SugarPak - Domain Specific Language - Syntactical Sugar * *************************************************************/ (function () { var $D = Date, $P = $D.prototype, $N = Number.prototype; // private $P._orient = +1; // private $P._nth = null; // private $P._is = false; // private $P._same = false; // private $P._isSecond = false; // private $N._dateElement = "days"; /** * Moves the date to the next instance of a date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.today().next().friday();
	Date.today().next().fri();
	Date.today().next().march();
	Date.today().next().mar();
	Date.today().next().week();
	
* * @return {Date} date */ $P.next = function () { this._move = true; this._orient = +1; return this; }; /** * Creates a new Date (Date.today()) and moves the date to the next instance of the date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.next().friday();
	Date.next().fri();
	Date.next().march();
	Date.next().mar();
	Date.next().week();
	
* * @return {Date} date */ $D.next = function () { return $D.today().next(); }; /** * Moves the date to the previous instance of a date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.today().last().friday();
	Date.today().last().fri();
	Date.today().last().march();
	Date.today().last().mar();
	Date.today().last().week();
	
* * @return {Date} date */ $P.last = $P.prev = $P.previous = function () { this._move = true; this._orient = -1; return this; }; /** * Creates a new Date (Date.today()) and moves the date to the previous instance of the date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.last().friday();
	Date.last().fri();
	Date.previous().march();
	Date.prev().mar();
	Date.last().week();
	
* * @return {Date} date */ $D.last = $D.prev = $D.previous = function () { return $D.today().last(); }; /** * Performs a equality check when followed by either a month name, day name or .weekday() function. * Example

	Date.today().is().friday(); // true|false
	Date.today().is().fri();
	Date.today().is().march();
	Date.today().is().mar();
	
* * @return {Boolean} true|false */ $P.is = function () { this._is = true; return this; }; /** * Determines if two date objects occur on/in exactly the same instance of the subsequent date part function. * The function .same() must be followed by a date part function (example: .day(), .month(), .year(), etc). * * An optional Date can be passed in the date part function. If now date is passed as a parameter, 'Now' is used. * * The following example demonstrates how to determine if two dates fall on the exact same day. * * Example

	var d1 = Date.today(); // today at 00:00
	var d2 = new Date();   // exactly now.

	// Do they occur on the same day?
	d1.same().day(d2); // true
	
	// Do they occur on the same hour?
	d1.same().hour(d2); // false, unless d2 hour is '00' (midnight).
	
	// What if it's the same day, but one year apart?
	var nextYear = Date.today().add(1).year();

	d1.same().day(nextYear); // false, because the dates must occur on the exact same day. 
	
* * Scenario: Determine if a given date occurs during some week period 2 months from now. * * Example

	var future = Date.today().add(2).months();
	return someDate.same().week(future); // true|false;
	
* * @return {Boolean} true|false */ $P.same = function () { this._same = true; this._isSecond = false; return this; }; /** * Determines if the current date/time occurs during Today. Must be preceded by the .is() function. * Example

	someDate.is().today();    // true|false
	new Date().is().today();  // true
	Date.today().is().today();// true
	Date.today().add(-1).day().is().today(); // false
	
* * @return {Boolean} true|false */ $P.today = function () { return this.same().day(); }; /** * Determines if the current date is a weekday. This function must be preceded by the .is() function. * Example

	Date.today().is().weekday(); // true|false
	
* * @return {Boolean} true|false */ $P.weekday = function () { if (this._nth) { return df("Weekday").call(this); } if (this._move) { return this.addWeekdays(this._orient); } if (this._is) { this._is = false; return (!this.is().sat() && !this.is().sun()); } return false; }; /** * Determines if the current date is on the weekend. This function must be preceded by the .is() function. * Example

	Date.today().is().weekend(); // true|false
	
* * @return {Boolean} true|false */ $P.weekend = function () { if (this._is) { this._is = false; return (this.is().sat() || this.is().sun()); } return false; }; /** * Sets the Time of the current Date instance. A string "6:15 pm" or config object {hour:18, minute:15} are accepted. * Example

	// Set time to 6:15pm with a String
	Date.today().at("6:15pm");

	// Set time to 6:15pm with a config object
	Date.today().at({hour:18, minute:15});
	
* * @return {Date} date */ $P.at = function (time) { return (typeof time === "string") ? $D.parse(this.toString("d") + " " + time) : this.set(time); }; /** * Creates a new Date() and adds this (Number) to the date based on the preceding date element function (eg. second|minute|hour|day|month|year). * Example

	// Undeclared Numbers must be wrapped with parentheses. Requirment of JavaScript.
	(3).days().fromNow();
	(6).months().fromNow();

	// Declared Number variables do not require parentheses. 
	var n = 6;
	n.months().fromNow();
	
* * @return {Date} A new Date instance */ $N.fromNow = $N.after = function (date) { var c = {}; c[this._dateElement] = this; return ((!date) ? new Date() : date.clone()).add(c); }; /** * Creates a new Date() and subtract this (Number) from the date based on the preceding date element function (eg. second|minute|hour|day|month|year). * Example

	// Undeclared Numbers must be wrapped with parentheses. Requirment of JavaScript.
	(3).days().ago();
	(6).months().ago();

	// Declared Number variables do not require parentheses. 
	var n = 6;
	n.months().ago();
	
* * @return {Date} A new Date instance */ $N.ago = $N.before = function (date) { var c = {}, s = (this._dateElement[this._dateElement.length-1] !== "s") ? this._dateElement + "s" : this._dateElement; c[s] = this * -1; return ((!date) ? new Date() : date.clone()).add(c); }; // Do NOT modify the following string tokens. These tokens are used to build dynamic functions. // All culture-specific strings can be found in the CultureInfo files. var dx = ("sunday monday tuesday wednesday thursday friday saturday").split(/\s/), mx = ("january february march april may june july august september october november december").split(/\s/), px = ("Millisecond Second Minute Hour Day Week Month Year Quarter Weekday").split(/\s/), pxf = ("Milliseconds Seconds Minutes Hours Date Week Month FullYear Quarter").split(/\s/), nth = ("final first second third fourth fifth").split(/\s/), de; /** * Returns an object literal of all the date parts. * Example

	var o = new Date().toObject();
	
	// { year: 2008, month: 4, week: 20, day: 13, hour: 18, minute: 9, second: 32, millisecond: 812 }
	
	// The object properties can be referenced directly from the object.
	
	alert(o.day);  // alerts "13"
	alert(o.year); // alerts "2008"
	
* * @return {Date} An object literal representing the original date object. */ $P.toObject = function () { var o = {}; for (var i = 0; i < px.length; i++) { if (this["get" + pxf[i]]) { o[px[i].toLowerCase()] = this["get" + pxf[i]](); } } return o; }; /** * Returns a date created from an object literal. Ignores the .week property if set in the config. * Example

	var o = new Date().toObject();
	
	return Date.fromObject(o); // will return the same date. 

	var o2 = {month: 1, day: 20, hour: 18}; // birthday party!
	Date.fromObject(o2);
	
* * @return {Date} An object literal representing the original date object. */ $D.fromObject = function(config) { config.week = null; return Date.today().set(config); }; // Create day name functions and abbreviated day name functions (eg. monday(), friday(), fri()). var df = function (n) { return function () { if (this._is) { this._is = false; return this.getDay() === n; } if (this._move) { this._move = null; } if (this._nth !== null) { // If the .second() function was called earlier, remove the _orient // from the date, and then continue. // This is required because 'second' can be used in two different context. // // Example // // Date.today().add(1).second(); // Date.march().second().monday(); // // Things get crazy with the following... // Date.march().add(1).second().second().monday(); // but it works!! // if (this._isSecond) { this.addSeconds(this._orient * -1); } // make sure we reset _isSecond this._isSecond = false; var ntemp = this._nth; this._nth = null; var temp = this.clone().moveToLastDayOfMonth(); this.moveToNthOccurrence(n, ntemp); if (this > temp) { throw new RangeError($D.getDayName(n) + " does not occur " + ntemp + " times in the month of " + $D.getMonthName(temp.getMonth()) + " " + temp.getFullYear() + "."); } return this; } return this.moveToDayOfWeek(n, this._orient); }; }; var sdf = function (n) { return function () { var t = $D.today(), shift = n - t.getDay(); if (n === 0 && Date.CultureInfo.firstDayOfWeek === 1 && t.getDay() !== 0) { shift = shift + 7; } return t.addDays(shift); }; }; // Create month name functions and abbreviated month name functions (eg. january(), march(), mar()). var month_instance_functions = function (n) { return function () { if (this._is) { this._is = false; return this.getMonth() === n; } return this.moveToMonth(n, this._orient); }; }; var month_static_functions = function (n) { return function () { return $D.today().set({ month: n, day: 1 }); }; }; var processTerms = function (names, staticFunc, instanceFunc) { for (var i = 0; i < names.length; i++) { // Create constant static Name variables. $D[names[i].toUpperCase()] = $D[names[i].toUpperCase().substring(0, 3)] = i; // Create Name functions. $D[names[i]] = $D[names[i].substring(0, 3)] = staticFunc(i); // Create Name instance functions. $P[names[i]] = $P[names[i].substring(0, 3)] = instanceFunc(i); } }; processTerms(dx, sdf, df); processTerms(mx, month_static_functions, month_instance_functions); // Create date element functions and plural date element functions used with Date (eg. day(), days(), months()). var ef = function (j) { return function () { // if the .second() function was called earlier, the _orient // has alread been added. Just return this and reset _isSecond. if (this._isSecond) { this._isSecond = false; return this; } if (this._same) { this._same = this._is = false; var o1 = this.toObject(), o2 = (arguments[0] || new Date()).toObject(), v = "", k = j.toLowerCase(); // the substr trick with -1 doesn't work in IE8 or less k = (k[k.length-1] === "s") ? k.substring(0,k.length-1) : k; for (var m = (px.length - 1); m > -1; m--) { v = px[m].toLowerCase(); if (o1[v] !== o2[v]) { return false; } if (k === v) { break; } } return true; } if (j.substring(j.length - 1) !== "s") { j += "s"; } if (this._move) { this._move = null; } return this["add" + j](this._orient); }; }; var nf = function (n) { return function () { this._dateElement = n; return this; }; }; for (var k = 0; k < px.length; k++) { de = px[k].toLowerCase(); if(de !== "weekday") { // Create date element functions and plural date element functions used with Date (eg. day(), days(), months()). $P[de] = $P[de + "s"] = ef(px[k]); // Create date element functions and plural date element functions used with Number (eg. day(), days(), months()). $N[de] = $N[de + "s"] = nf(de + "s"); } } $P._ss = ef("Second"); var nthfn = function (n) { return function (dayOfWeek) { if (this._same) { return this._ss(arguments[0]); } if (dayOfWeek || dayOfWeek === 0) { return this.moveToNthOccurrence(dayOfWeek, n); } this._nth = n; // if the operator is 'second' add the _orient, then deal with it later... if (n === 2 && (dayOfWeek === undefined || dayOfWeek === null)) { this._isSecond = true; return this.addSeconds(this._orient); } return this; }; }; for (var l = 0; l < nth.length; l++) { $P[nth[l]] = (l === 0) ? nthfn(-1) : nthfn(l); } }()); (function () { "use strict"; Date.Parsing = { Exception: function (s) { this.message = "Parse error at '" + s.substring(0, 10) + " ...'"; } }; var $P = Date.Parsing; var dayOffsets = { standard: [0,31,59,90,120,151,181,212,243,273,304,334], leap: [0,31,60,91,121,152,182,213,244,274,305,335] }; $P.isLeapYear = function(year) { return ((year % 4 === 0) && (year % 100 !== 0)) || (year % 400 === 0); }; var utils = { multiReplace : function (str, hash ) { var key; for (key in hash) { if (Object.prototype.hasOwnProperty.call(hash, key)) { var regex; if (typeof hash[key] === "function") { } else { regex = (hash[key] instanceof RegExp) ? hash[key] : new RegExp(hash[key], "g"); } str = str.replace(regex, key); } } return str; }, getDayOfYearFromWeek : function (obj) { var d, jan4, offset; obj.weekDay = (!obj.weekDay && obj.weekDay !== 0) ? 1 : obj.weekDay; d = new Date(obj.year, 0, 4); jan4 = d.getDay() === 0 ? 7 : d.getDay(); // JS is 0 indexed on Sunday. offset = jan4+3; obj.dayOfYear = ((obj.week * 7) + (obj.weekDay === 0 ? 7 : obj.weekDay))-offset; return obj; }, getDayOfYear : function (obj, dayOffset) { if (!obj.dayOfYear) { obj = utils.getDayOfYearFromWeek(obj); } for (var i=0;i <= dayOffset.length;i++) { if (obj.dayOfYear < dayOffset[i] || i === dayOffset.length) { obj.day = obj.day ? obj.day : (obj.dayOfYear - dayOffset[i-1]); break; } else { obj.month = i; } } return obj; }, adjustForTimeZone : function (obj, date) { var offset; if (obj.zone.toUpperCase() === "Z" || (obj.zone_hours === 0 && obj.zone_minutes === 0)) { // it's UTC/GML so work out the current timeszone offset offset = -date.getTimezoneOffset(); } else { offset = (obj.zone_hours*60) + (obj.zone_minutes || 0); if (obj.zone_sign === "+") { offset *= -1; } offset -= date.getTimezoneOffset(); } date.setMinutes(date.getMinutes()+offset); return date; }, setDefaults : function (obj) { obj.year = obj.year || Date.today().getFullYear(); obj.hours = obj.hours || 0; obj.minutes = obj.minutes || 0; obj.seconds = obj.seconds || 0; obj.milliseconds = obj.milliseconds || 0; if (!(!obj.month && (obj.week || obj.dayOfYear))) { // if we have a month, or if we don't but don't have the day calculation data obj.month = obj.month || 0; obj.day = obj.day || 1; } return obj; }, dataNum: function (data, mod, explict, postProcess) { var dataNum = data*1; if (mod) { if (postProcess) { return data ? mod(data)*1 : data; } else { return data ? mod(dataNum) : data; } } else if (!explict){ return data ? dataNum : data; } else { return (data && typeof data !== "undefined") ? dataNum : data; } }, timeDataProcess: function (obj) { var timeObj = {}; for (var x in obj.data) { if (obj.data.hasOwnProperty(x)) { timeObj[x] = obj.ignore[x] ? obj.data[x] : utils.dataNum(obj.data[x], obj.mods[x], obj.explict[x], obj.postProcess[x]); } } if (obj.data.secmins) { obj.data.secmins = obj.data.secmins.replace(",", ".") * 60; if (!timeObj.minutes) { timeObj.minutes = obj.data.secmins; } else if (!timeObj.seconds) { timeObj.seconds = obj.data.secmins; } delete obj.secmins; } return timeObj; }, buildTimeObjectFromData: function (data) { var time = utils.timeDataProcess({ data: { year : data[1], month : data[5], day : data[7], week : data[8], dayOfYear : data[10], hours : data[15], zone_hours : data[23], zone_minutes : data[24], zone : data[21], zone_sign : data[22], weekDay : data[9], minutes: data[16], seconds: data[19], milliseconds: data[20], secmins: data[18] }, mods: { month: function(data) { return data-1; }, weekDay: function (data) { data = Math.abs(data); return (data === 7 ? 0 : data); }, minutes: function (data) { return data.replace(":",""); }, seconds: function (data) { return Math.floor( (data.replace(":","").replace(",","."))*1 ); }, milliseconds: function (data) { return (data.replace(",",".")*1000); } }, postProcess: { minutes: true, seconds: true, milliseconds: true }, explict: { zone_hours: true, zone_minutes: true }, ignore: { zone: true, zone_sign: true, secmins: true } }); return time; }, addToHash: function (hash, keys, data) { keys = keys; data = data; var len = keys.length; for (var i = 0; i < len; i++) { hash[keys[i]] = data[i]; } return hash; }, combineRegex: function (r1, r2) { return new RegExp("(("+r1.source+")\\s("+r2.source+"))"); }, getDateNthString: function(add, last, inc){ if (add) { return Date.today().addDays(inc).toString("d"); } else if (last) { return Date.today().last()[inc]().toString("d"); } }, buildRegexData: function (array) { var arr = []; var len = array.length; for (var i=0; i < len; i++) { if (Object.prototype.toString.call(array[i]) === '[object Array]') { // oldIE compat version of Array.isArray arr.push(this.combineRegex(array[i][0], array[i][1])); } else { arr.push(array[i]); } } return arr; } }; $P.processTimeObject = function (obj) { var date, dayOffset; utils.setDefaults(obj); dayOffset = ($P.isLeapYear(obj.year)) ? dayOffsets.leap : dayOffsets.standard; if (!obj.month && (obj.week || obj.dayOfYear)) { utils.getDayOfYear(obj, dayOffset); } else { obj.dayOfYear = dayOffset[obj.month] + obj.day; } date = new Date(obj.year, obj.month, obj.day, obj.hours, obj.minutes, obj.seconds, obj.milliseconds); if (obj.zone) { utils.adjustForTimeZone(obj, date); // adjust (and calculate) for timezone } return date; }; $P.ISO = { regex : /^([\+-]?\d{4}(?!\d{2}\b))((-?)((0[1-9]|1[0-2])(\3([12]\d|0[1-9]|3[01]))?|W([0-4]\d|5[0-3])(-?[1-7])?|(00[1-9]|0[1-9]\d|[12]\d{2}|3([0-5]\d|6[1-6])))([T\s]((([01]\d|2[0-4])((:?)[0-5]\d)?|24\:?00)([\.,]\d+(?!:))?)?(\17[0-5]\d([\.,]\d+)?)?\s?([zZ]|([\+-])([01]\d|2[0-3]):?([0-5]\d)?)?)?)?$/, parse : function (s) { var time, data = s.match(this.regex); if (!data || !data.length) { return null; } time = utils.buildTimeObjectFromData(data); if (!time.year || (!time.year && (!time.month && !time.day) && (!time.week && !time.dayOfYear)) ) { return null; } return $P.processTimeObject(time); } }; $P.Numeric = { isNumeric: function (e){return!isNaN(parseFloat(e))&&isFinite(e);}, regex: /\b([0-1]?[0-9])([0-3]?[0-9])([0-2]?[0-9]?[0-9][0-9])\b/i, parse: function (s) { var data, i, time = {}, order = Date.CultureInfo.dateElementOrder.split(""); if (!(this.isNumeric(s)) || // if it's non-numeric OR (s[0] === "+" && s[0] === "-")) { // It's an arithmatic string (eg +/-1000) return null; } if (s.length < 5 && s.indexOf(".") < 0 && s.indexOf("/") < 0) { // assume it's just a year. time.year = s; return $P.processTimeObject(time); } data = s.match(this.regex); if (!data || !data.length) { return null; } for (i=0; i < order.length; i++) { switch(order[i]) { case "d": time.day = data[i+1]; break; case "m": time.month = (data[i+1]-1); break; case "y": time.year = data[i+1]; break; } } return $P.processTimeObject(time); } }; $P.Normalizer = { regexData: function () { var $R = Date.CultureInfo.regexPatterns; return utils.buildRegexData([ $R.tomorrow, $R.yesterday, [$R.past, $R.mon], [$R.past, $R.tue], [$R.past, $R.wed], [$R.past, $R.thu], [$R.past, $R.fri], [$R.past, $R.sat], [$R.past, $R.sun] ]); }, basicReplaceHash : function() { var $R = Date.CultureInfo.regexPatterns; return { "January": $R.jan.source, "February": $R.feb, "March": $R.mar, "April": $R.apr, "May": $R.may, "June": $R.jun, "July": $R.jul, "August": $R.aug, "September": $R.sep, "October": $R.oct, "November": $R.nov, "December": $R.dec, "": /\bat\b/gi, " ": /\s{2,}/, "am": $R.inTheMorning, "9am": $R.thisMorning, "pm": $R.inTheEvening, "7pm":$R.thisEvening }; }, keys : function(){ return [ utils.getDateNthString(true, false, 1), // tomorrow utils.getDateNthString(true, false, -1), // yesterday utils.getDateNthString(false, true, "monday"), //last mon utils.getDateNthString(false, true, "tuesday"), //last tues utils.getDateNthString(false, true, "wednesday"), //last wed utils.getDateNthString(false, true, "thursday"), //last thurs utils.getDateNthString(false, true, "friday"), //last fri utils.getDateNthString(false, true, "saturday"), //last sat utils.getDateNthString(false, true, "sunday") //last sun ]; }, buildRegexFunctions: function () { var $R = Date.CultureInfo.regexPatterns; var __ = Date.i18n.__; var tomorrowRE = new RegExp("(\\b\\d\\d?("+__("AM")+"|"+__("PM")+")? )("+$R.tomorrow.source.slice(1)+")", "i"); // adapted tomorrow regex for AM PM relative dates var todayRE = new RegExp($R.today.source + "(?!\\s*([+-]))\\b"); // today, but excludes the math operators (eg "today + 2h") this.replaceFuncs = [ [todayRE, function (full) { return (full.length > 1) ? Date.today().toString("d") : full; }], [tomorrowRE, function(full, m1) { var t = Date.today().addDays(1).toString("d"); return (t + " " + m1); }], [$R.amThisMorning, function(str, am){return am;}], [$R.pmThisEvening, function(str, pm){return pm;}] ]; }, buildReplaceData: function () { this.buildRegexFunctions(); this.replaceHash = utils.addToHash(this.basicReplaceHash(), this.keys(), this.regexData()); }, stringReplaceFuncs: function (s) { for (var i=0; i < this.replaceFuncs.length; i++) { s = s.replace(this.replaceFuncs[i][0], this.replaceFuncs[i][1]); } return s; }, parse: function (s) { s = this.stringReplaceFuncs(s); s = utils.multiReplace(s, this.replaceHash); try { var n = s.split(/([\s\-\.\,\/\x27]+)/); if (n.length === 3 && $P.Numeric.isNumeric(n[0]) && $P.Numeric.isNumeric(n[2]) && (n[2].length >= 4)) { // ok, so we're dealing with x/year. But that's not a full date. // This fixes wonky dateElementOrder parsing when set to dmy order. if (Date.CultureInfo.dateElementOrder[0] === "d") { s = "1/" + n[0] + "/" + n[2]; // set to 1st of month and normalize the seperator } } } catch (e) {} return s; } }; $P.Normalizer.buildReplaceData(); }()); (function () { var $P = Date.Parsing; var _ = $P.Operators = { // // Tokenizers // rtoken: function (r) { // regex token return function (s) { var mx = s.match(r); if (mx) { return ([ mx[0], s.substring(mx[0].length) ]); } else { throw new $P.Exception(s); } }; }, token: function () { // whitespace-eating token return function (s) { return _.rtoken(new RegExp("^\\s*" + s + "\\s*"))(s); }; }, stoken: function (s) { // string token return _.rtoken(new RegExp("^" + s)); }, // Atomic Operators until: function (p) { return function (s) { var qx = [], rx = null; while (s.length) { try { rx = p.call(this, s); } catch (e) { qx.push(rx[0]); s = rx[1]; continue; } break; } return [ qx, s ]; }; }, many: function (p) { return function (s) { var rx = [], r = null; while (s.length) { try { r = p.call(this, s); } catch (e) { return [ rx, s ]; } rx.push(r[0]); s = r[1]; } return [ rx, s ]; }; }, // generator operators -- see below optional: function (p) { return function (s) { var r = null; try { r = p.call(this, s); } catch (e) { return [ null, s ]; } return [ r[0], r[1] ]; }; }, not: function (p) { return function (s) { try { p.call(this, s); } catch (e) { return [null, s]; } throw new $P.Exception(s); }; }, ignore: function (p) { return p ? function (s) { var r = null; r = p.call(this, s); return [null, r[1]]; } : null; }, product: function () { var px = arguments[0], qx = Array.prototype.slice.call(arguments, 1), rx = []; for (var i = 0 ; i < px.length ; i++) { rx.push(_.each(px[i], qx)); } return rx; }, cache: function (rule) { var cache = {}, cache_length = 0, cache_keys = [], CACHE_MAX = Date.Config.CACHE_MAX || 100000, r = null; var cacheCheck = function () { if (cache_length === CACHE_MAX) { // kill several keys, don't want to have to do this all the time... for (var i=0; i < 10; i++) { var key = cache_keys.shift(); if (key) { delete cache[key]; cache_length--; } } } }; return function (s) { cacheCheck(); try { r = cache[s] = (cache[s] || rule.call(this, s)); } catch (e) { r = cache[s] = e; } cache_length++; cache_keys.push(s); if (r instanceof $P.Exception) { throw r; } else { return r; } }; }, // vector operators -- see below any: function () { var px = arguments; return function (s) { var r = null; for (var i = 0; i < px.length; i++) { if (px[i] == null) { continue; } try { r = (px[i].call(this, s)); } catch (e) { r = null; } if (r) { return r; } } throw new $P.Exception(s); }; }, each: function () { var px = arguments; return function (s) { var rx = [], r = null; for (var i = 0; i < px.length ; i++) { if (px[i] == null) { continue; } try { r = (px[i].call(this, s)); } catch (e) { throw new $P.Exception(s); } rx.push(r[0]); s = r[1]; } return [ rx, s]; }; }, all: function () { var px = arguments, _ = _; return _.each(_.optional(px)); }, // delimited operators sequence: function (px, d, c) { d = d || _.rtoken(/^\s*/); c = c || null; if (px.length === 1) { return px[0]; } return function (s) { var r = null, q = null; var rx = []; for (var i = 0; i < px.length ; i++) { try { r = px[i].call(this, s); } catch (e) { break; } rx.push(r[0]); try { q = d.call(this, r[1]); } catch (ex) { q = null; break; } s = q[1]; } if (!r) { throw new $P.Exception(s); } if (q) { throw new $P.Exception(q[1]); } if (c) { try { r = c.call(this, r[1]); } catch (ey) { throw new $P.Exception(r[1]); } } return [ rx, (r?r[1]:s) ]; }; }, // // Composite Operators // between: function (d1, p, d2) { d2 = d2 || d1; var _fn = _.each(_.ignore(d1), p, _.ignore(d2)); return function (s) { var rx = _fn.call(this, s); return [[rx[0][0], r[0][2]], rx[1]]; }; }, list: function (p, d, c) { d = d || _.rtoken(/^\s*/); c = c || null; return (p instanceof Array ? _.each(_.product(p.slice(0, -1), _.ignore(d)), p.slice(-1), _.ignore(c)) : _.each(_.many(_.each(p, _.ignore(d))), px, _.ignore(c))); }, set: function (px, d, c) { d = d || _.rtoken(/^\s*/); c = c || null; return function (s) { // r is the current match, best the current 'best' match // which means it parsed the most amount of input var r = null, p = null, q = null, rx = null, best = [[], s], last = false; // go through the rules in the given set for (var i = 0; i < px.length ; i++) { // last is a flag indicating whether this must be the last element // if there is only 1 element, then it MUST be the last one q = null; p = null; r = null; last = (px.length === 1); // first, we try simply to match the current pattern // if not, try the next pattern try { r = px[i].call(this, s); } catch (e) { continue; } // since we are matching against a set of elements, the first // thing to do is to add r[0] to matched elements rx = [[r[0]], r[1]]; // if we matched and there is still input to parse and // we don't already know this is the last element, // we're going to next check for the delimiter ... // if there's none, or if there's no input left to parse // than this must be the last element after all ... if (r[1].length > 0 && ! last) { try { q = d.call(this, r[1]); } catch (ex) { last = true; } } else { last = true; } // if we parsed the delimiter and now there's no more input, // that means we shouldn't have parsed the delimiter at all // so don't update r and mark this as the last element ... if (!last && q[1].length === 0) { last = true; } // so, if this isn't the last element, we're going to see if // we can get any more matches from the remaining (unmatched) // elements ... if (!last) { // build a list of the remaining rules we can match against, // i.e., all but the one we just matched against var qx = []; for (var j = 0; j < px.length ; j++) { if (i !== j) { qx.push(px[j]); } } // now invoke recursively set with the remaining input // note that we don't include the closing delimiter ... // we'll check for that ourselves at the end p = _.set(qx, d).call(this, q[1]); // if we got a non-empty set as a result ... // (otw rx already contains everything we want to match) if (p[0].length > 0) { // update current result, which is stored in rx ... // basically, pick up the remaining text from p[1] // and concat the result from p[0] so that we don't // get endless nesting ... rx[0] = rx[0].concat(p[0]); rx[1] = p[1]; } } // at this point, rx either contains the last matched element // or the entire matched set that starts with this element. // now we just check to see if this variation is better than // our best so far, in terms of how much of the input is parsed if (rx[1].length < best[1].length) { best = rx; } // if we've parsed all the input, then we're finished if (best[1].length === 0) { break; } } // so now we've either gone through all the patterns trying them // as the initial match; or we found one that parsed the entire // input string ... // if best has no matches, just return empty set ... if (best[0].length === 0) { return best; } // if a closing delimiter is provided, then we have to check it also if (c) { // we try this even if there is no remaining input because the pattern // may well be optional or match empty input ... try { q = c.call(this, best[1]); } catch (ey) { throw new $P.Exception(best[1]); } // it parsed ... be sure to update the best match remaining input best[1] = q[1]; } // if we're here, either there was no closing delimiter or we parsed it // so now we have the best match; just return it! return best; }; }, forward: function (gr, fname) { return function (s) { return gr[fname].call(this, s); }; }, // // Translation Operators // replace: function (rule, repl) { return function (s) { var r = rule.call(this, s); return [repl, r[1]]; }; }, process: function (rule, fn) { return function (s) { var r = rule.call(this, s); return [fn.call(this, r[0]), r[1]]; }; }, min: function (min, rule) { return function (s) { var rx = rule.call(this, s); if (rx[0].length < min) { throw new $P.Exception(s); } return rx; }; } }; // Generator Operators And Vector Operators // Generators are operators that have a signature of F(R) => R, // taking a given rule and returning another rule, such as // ignore, which parses a given rule and throws away the result. // Vector operators are those that have a signature of F(R1,R2,...) => R, // take a list of rules and returning a new rule, such as each. // Generator operators are converted (via the following _generator // function) into functions that can also take a list or array of rules // and return an array of new rules as though the function had been // called on each rule in turn (which is what actually happens). // This allows generators to be used with vector operators more easily. // Example: // each(ignore(foo, bar)) instead of each(ignore(foo), ignore(bar)) // This also turns generators into vector operators, which allows // constructs like: // not(cache(foo, bar)) var _generator = function (op) { function gen() { var args = null, rx = [], px, i; if (arguments.length > 1) { args = Array.prototype.slice.call(arguments); } else if (arguments[0] instanceof Array) { args = arguments[0]; } if (args) { px = args.shift(); if (px.length > 0) { args.unshift(px[i]); rx.push(op.apply(null, args)); args.shift(); return rx; } } else { return op.apply(null, arguments); } } return gen; }; var gx = "optional not ignore cache".split(/\s/); for (var i = 0 ; i < gx.length ; i++) { _[gx[i]] = _generator(_[gx[i]]); } var _vector = function (op) { return function () { if (arguments[0] instanceof Array) { return op.apply(null, arguments[0]); } else { return op.apply(null, arguments); } }; }; var vx = "each any all".split(/\s/); for (var j = 0 ; j < vx.length ; j++) { _[vx[j]] = _vector(_[vx[j]]); } }()); (function () { var $D = Date; var flattenAndCompact = function (ax) { var rx = []; for (var i = 0; i < ax.length; i++) { if (ax[i] instanceof Array) { rx = rx.concat(flattenAndCompact(ax[i])); } else { if (ax[i]) { rx.push(ax[i]); } } } return rx; }; var parseMeridian = function () { if (this.meridian && (this.hour || this.hour === 0)) { if (this.meridian === "a" && this.hour > 11 && Date.Config.strict24hr){ throw "Invalid hour and meridian combination"; } else if (this.meridian === "p" && this.hour < 12 && Date.Config.strict24hr){ throw "Invalid hour and meridian combination"; } else if (this.meridian === "p" && this.hour < 12) { this.hour = this.hour + 12; } else if (this.meridian === "a" && this.hour === 12) { this.hour = 0; } } }; var setDefaults = function () { var now = new Date(); if ((this.hour || this.minute) && (!this.month && !this.year && !this.day)) { this.day = now.getDate(); } if (!this.year) { this.year = now.getFullYear(); } if (!this.month && this.month !== 0) { this.month = now.getMonth(); } if (!this.day) { this.day = 1; } if (!this.hour) { this.hour = 0; } if (!this.minute) { this.minute = 0; } if (!this.second) { this.second = 0; } if (!this.millisecond) { this.millisecond = 0; } }; var finishUtils = { getToday: function () { if (this.now || "hour minute second".indexOf(this.unit) !== -1) { return new Date(); } else { return $D.today(); } }, setDaysFromWeekday: function (today, orient){ var gap; orient = orient || 1; this.unit = "day"; gap = ($D.getDayNumberFromName(this.weekday) - today.getDay()); this.days = gap ? ((gap + (orient * 7)) % 7) : (orient * 7); return this; }, setMonthsFromMonth: function (today, orient) { var gap; orient = orient || 1; this.unit = "month"; gap = (this.month - today.getMonth()); this.months = gap ? ((gap + (orient * 12)) % 12) : (orient * 12); this.month = null; return this; }, setDMYFromWeekday: function () { var d = Date[this.weekday](); this.day = d.getDate(); if (!this.month) { this.month = d.getMonth(); } this.year = d.getFullYear(); return this; }, setUnitValue: function (orient) { if (!this.value && this.operator && this.operator !== null && this[this.unit + "s"] && this[this.unit + "s"] !== null) { this[this.unit + "s"] = this[this.unit + "s"] + ((this.operator === "add") ? 1 : -1) + (this.value||0) * orient; } else if (this[this.unit + "s"] == null || this.operator != null) { if (!this.value) { this.value = 1; } this[this.unit + "s"] = this.value * orient; } }, generateDateFromWeeks: function () { var weekday = (this.weekday !== undefined) ? this.weekday : "today"; var d = Date[weekday]().addWeeks(this.weeks); if (this.now) { d.setTimeToNow(); } return d; } }; $D.Translator = { hour: function (s) { return function () { this.hour = Number(s); }; }, minute: function (s) { return function () { this.minute = Number(s); }; }, second: function (s) { return function () { this.second = Number(s); }; }, /* for ss.s format */ secondAndMillisecond: function (s) { return function () { var mx = s.match(/^([0-5][0-9])\.([0-9]{1,3})/); this.second = Number(mx[1]); this.millisecond = Number(mx[2]); }; }, meridian: function (s) { return function () { this.meridian = s.slice(0, 1).toLowerCase(); }; }, timezone: function (s) { return function () { var n = s.replace(/[^\d\+\-]/g, ""); if (n.length) { this.timezoneOffset = Number(n); } else { this.timezone = s.toLowerCase(); } }; }, day: function (x) { var s = x[0]; return function () { this.day = Number(s.match(/\d+/)[0]); if (this.day < 1) { throw "invalid day"; } }; }, month: function (s) { return function () { this.month = (s.length === 3) ? "jan feb mar apr may jun jul aug sep oct nov dec".indexOf(s)/4 : Number(s) - 1; if (this.month < 0) { throw "invalid month"; } }; }, year: function (s) { return function () { var n = Number(s); this.year = ((s.length > 2) ? n : (n + (((n + 2000) < Date.CultureInfo.twoDigitYearMax) ? 2000 : 1900))); }; }, rday: function (s) { return function () { switch (s) { case "yesterday": this.days = -1; break; case "tomorrow": this.days = 1; break; case "today": this.days = 0; break; case "now": this.days = 0; this.now = true; break; } }; }, finishExact: function (x) { var d; x = (x instanceof Array) ? x : [x]; for (var i = 0 ; i < x.length ; i++) { if (x[i]) { x[i].call(this); } } setDefaults.call(this); parseMeridian.call(this); if (this.day > $D.getDaysInMonth(this.year, this.month)) { throw new RangeError(this.day + " is not a valid value for days."); } d = new Date(this.year, this.month, this.day, this.hour, this.minute, this.second, this.millisecond); if (this.year < 100) { d.setFullYear(this.year); // means years less that 100 are process correctly. JS will parse it otherwise as 1900-1999. } if (this.timezone) { d.set({ timezone: this.timezone }); } else if (this.timezoneOffset) { d.set({ timezoneOffset: this.timezoneOffset }); } return d; }, finish: function (x) { var today, expression, orient, temp; x = (x instanceof Array) ? flattenAndCompact(x) : [ x ]; if (x.length === 0) { return null; } for (var i = 0 ; i < x.length ; i++) { if (typeof x[i] === "function") { x[i].call(this); } } if (this.now && !this.unit && !this.operator) { return new Date(); } else { today = finishUtils.getToday.call(this); } expression = !!(this.days && this.days !== null || this.orient || this.operator); orient = ((this.orient === "past" || this.operator === "subtract") ? -1 : 1); if (this.month && this.unit === "week") { this.value = this.month + 1; delete this.month; delete this.day; } if ((this.month || this.month === 0) && "year day hour minute second".indexOf(this.unit) !== -1) { if (!this.value) { this.value = this.month + 1; } this.month = null; expression = true; } if (!expression && this.weekday && !this.day && !this.days) { finishUtils.setDMYFromWeekday.call(this); } if (expression && this.weekday && this.unit !== "month" && this.unit !== "week") { finishUtils.setDaysFromWeekday.call(this, today, orient); } if (this.weekday && this.unit !== "week" && !this.day && !this.days) { temp = Date[this.weekday](); this.day = temp.getDate(); if (temp.getMonth() !== today.getMonth()) { this.month = temp.getMonth(); } } if (this.month && this.unit === "day" && this.operator) { if (!this.value) { this.value = (this.month + 1); } this.month = null; } if (this.value != null && this.month != null && this.year != null) { this.day = this.value * 1; } if (this.month && !this.day && this.value) { today.set({ day: this.value * 1 }); if (!expression) { this.day = this.value * 1; } } if (!this.month && this.value && this.unit === "month" && !this.now) { this.month = this.value; expression = true; } if (expression && (this.month || this.month === 0) && this.unit !== "year") { finishUtils.setMonthsFromMonth.call(this, today, orient); } if (!this.unit) { this.unit = "day"; } finishUtils.setUnitValue.call(this, orient); parseMeridian.call(this); if ((this.month || this.month === 0) && !this.day) { this.day = 1; } if (!this.orient && !this.operator && this.unit === "week" && this.value && !this.day && !this.month) { return Date.today().setWeek(this.value); } if (this.unit === "week" && this.weeks && !this.day && !this.month) { return finishUtils.generateDateFromWeeks.call(this); } if (expression && this.timezone && this.day && this.days) { this.day = this.days; } if (expression){ today.add(this); } else { today.set(this); } if (this.timezone) { this.timezone = this.timezone.toUpperCase(); var offset = $D.getTimezoneOffset(this.timezone); var timezone; if (today.hasDaylightSavingTime()) { // lets check that we're being sane with timezone setting timezone = $D.getTimezoneAbbreviation(offset, today.isDaylightSavingTime()); if (timezone !== this.timezone) { // bugger, we're in a place where things like EST vs EDT matters. if (today.isDaylightSavingTime()) { today.addHours(-1); } else { today.addHours(1); } } } today.setTimezoneOffset(offset); } return today; } }; }()); (function () { var $D = Date; $D.Grammar = {}; var _ = $D.Parsing.Operators, g = $D.Grammar, t = $D.Translator, _fn; // Allow rolling up into general purpose rules _fn = function () { return _.each(_.any.apply(null, arguments), _.not(g.ctoken2("timeContext"))); }; g.datePartDelimiter = _.rtoken(/^([\s\-\.\,\/\x27]+)/); g.timePartDelimiter = _.stoken(":"); g.whiteSpace = _.rtoken(/^\s*/); g.generalDelimiter = _.rtoken(/^(([\s\,]|at|@|on)+)/); var _C = {}; g.ctoken = function (keys) { var fn = _C[keys]; if (! fn) { var c = Date.CultureInfo.regexPatterns; var kx = keys.split(/\s+/), px = []; for (var i = 0; i < kx.length ; i++) { px.push(_.replace(_.rtoken(c[kx[i]]), kx[i])); } fn = _C[keys] = _.any.apply(null, px); } return fn; }; g.ctoken2 = function (key) { return _.rtoken(Date.CultureInfo.regexPatterns[key]); }; var cacheProcessRtoken = function (key, token, type, eachToken) { if (eachToken) { g[key] = _.cache(_.process(_.each(_.rtoken(token),_.optional(g.ctoken2(eachToken))), type)); } else { g[key] = _.cache(_.process(_.rtoken(token), type)); } }; var cacheProcessCtoken = function (token, type) { return _.cache(_.process(g.ctoken2(token), type)); }; var _F = {}; //function cache var _get = function (f) { _F[f] = (_F[f] || g.format(f)[0]); return _F[f]; }; g.allformats = function (fx) { var rx = []; if (fx instanceof Array) { for (var i = 0; i < fx.length; i++) { rx.push(_get(fx[i])); } } else { rx.push(_get(fx)); } return rx; }; g.formats = function (fx) { if (fx instanceof Array) { var rx = []; for (var i = 0 ; i < fx.length ; i++) { rx.push(_get(fx[i])); } return _.any.apply(null, rx); } else { return _get(fx); } }; var grammarFormats = { timeFormats: function(){ var i, RTokenKeys = [ "h", "hh", "H", "HH", "m", "mm", "s", "ss", "ss.s", "z", "zz" ], RToken = [ /^(0[0-9]|1[0-2]|[1-9])/, /^(0[0-9]|1[0-2])/, /^([0-1][0-9]|2[0-3]|[0-9])/, /^([0-1][0-9]|2[0-3])/, /^([0-5][0-9]|[0-9])/, /^[0-5][0-9]/, /^([0-5][0-9]|[0-9])/, /^[0-5][0-9]/, /^[0-5][0-9]\.[0-9]{1,3}/, /^((\+|\-)\s*\d\d\d\d)|((\+|\-)\d\d\:?\d\d)/, /^((\+|\-)\s*\d\d\d\d)|((\+|\-)\d\d\:?\d\d)/ ], tokens = [ t.hour, t.hour, t.hour, t.hour, t.minute, t.minute, t.second, t.second, t.secondAndMillisecond, t.timezone, t.timezone ]; for (i=0; i < RTokenKeys.length; i++) { cacheProcessRtoken(RTokenKeys[i], RToken[i], tokens[i]); } g.hms = _.cache(_.sequence([g.H, g.m, g.s], g.timePartDelimiter)); g.t = cacheProcessCtoken("shortMeridian", t.meridian); g.tt = cacheProcessCtoken("longMeridian", t.meridian); g.zzz = cacheProcessCtoken("timezone", t.timezone); g.timeSuffix = _.each(_.ignore(g.whiteSpace), _.set([ g.tt, g.zzz ])); g.time = _.each(_.optional(_.ignore(_.stoken("T"))), g.hms, g.timeSuffix); }, dateFormats: function () { // pre-loaded rules for different date part order preferences var _setfn = function () { return _.set(arguments, g.datePartDelimiter); }; var i, RTokenKeys = [ "d", "dd", "M", "MM", "y", "yy", "yyy", "yyyy" ], RToken = [ /^([0-2]\d|3[0-1]|\d)/, /^([0-2]\d|3[0-1])/, /^(1[0-2]|0\d|\d)/, /^(1[0-2]|0\d)/, /^(\d+)/, /^(\d\d)/, /^(\d\d?\d?\d?)/, /^(\d\d\d\d)/ ], tokens = [ t.day, t.day, t.month, t.month, t.year, t.year, t.year, t.year ], eachToken = [ "ordinalSuffix", "ordinalSuffix" ]; for (i=0; i < RTokenKeys.length; i++) { cacheProcessRtoken(RTokenKeys[i], RToken[i], tokens[i], eachToken[i]); } g.MMM = g.MMMM = _.cache(_.process(g.ctoken("jan feb mar apr may jun jul aug sep oct nov dec"), t.month)); g.ddd = g.dddd = _.cache(_.process(g.ctoken("sun mon tue wed thu fri sat"), function (s) { return function () { this.weekday = s; }; } )); g.day = _fn(g.d, g.dd); g.month = _fn(g.M, g.MMM); g.year = _fn(g.yyyy, g.yy); g.mdy = _setfn(g.ddd, g.month, g.day, g.year); g.ymd = _setfn(g.ddd, g.year, g.month, g.day); g.dmy = _setfn(g.ddd, g.day, g.month, g.year); g.date = function (s) { return ((g[Date.CultureInfo.dateElementOrder] || g.mdy).call(this, s)); }; }, relative: function () { // relative date / time expressions g.orientation = _.process(g.ctoken("past future"), function (s) { return function () { this.orient = s; }; } ); g.operator = _.process(g.ctoken("add subtract"), function (s) { return function () { this.operator = s; }; } ); g.rday = _.process(g.ctoken("yesterday tomorrow today now"), t.rday); g.unit = _.process(g.ctoken("second minute hour day week month year"), function (s) { return function () { this.unit = s; }; } ); } }; g.buildGrammarFormats = function () { // these need to be rebuilt every time the language changes. _C = {}; grammarFormats.timeFormats(); grammarFormats.dateFormats(); grammarFormats.relative(); g.value = _.process(_.rtoken(/^([-+]?\d+)?(st|nd|rd|th)?/), function (s) { return function () { this.value = s.replace(/\D/g, ""); }; } ); g.expression = _.set([g.rday, g.operator, g.value, g.unit, g.orientation, g.ddd, g.MMM ]); g.format = _.process(_.many( _.any( // translate format specifiers into grammar rules _.process( _.rtoken(/^(dd?d?d?(?!e)|MM?M?M?|yy?y?y?|hh?|HH?|mm?|ss?|tt?|zz?z?)/), function (fmt) { if (g[fmt]) { return g[fmt]; } else { throw $D.Parsing.Exception(fmt); } } ), // translate separator tokens into token rules _.process(_.rtoken(/^[^dMyhHmstz]+/), // all legal separators function (s) { return _.ignore(_.stoken(s)); } ) ) ), // construct the parser ... function (rules) { return _.process(_.each.apply(null, rules), t.finishExact); } ); // starting rule for general purpose grammar g._start = _.process(_.set([ g.date, g.time, g.expression ], g.generalDelimiter, g.whiteSpace), t.finish); }; g.buildGrammarFormats(); // parsing date format specifiers - ex: "h:m:s tt" // this little guy will generate a custom parser based // on the format string, ex: g.format("h:m:s tt") // check for these formats first g._formats = g.formats([ "\"yyyy-MM-ddTHH:mm:ssZ\"", "yyyy-MM-ddTHH:mm:ss.sz", "yyyy-MM-ddTHH:mm:ssZ", "yyyy-MM-ddTHH:mm:ssz", "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-ddTHH:mmZ", "yyyy-MM-ddTHH:mmz", "yyyy-MM-ddTHH:mm", "ddd, MMM dd, yyyy H:mm:ss tt", "ddd MMM d yyyy HH:mm:ss zzz", "MMddyyyy", "ddMMyyyy", "Mddyyyy", "ddMyyyy", "Mdyyyy", "dMyyyy", "yyyy", "Mdyy", "dMyy", "d" ]); // real starting rule: tries selected formats first, // then general purpose rule g.start = function (s) { try { var r = g._formats.call({}, s); if (r[1].length === 0) { return r; } } catch (e) {} return g._start.call({}, s); }; }()); (function () { var $D = Date; /** * @desc Converts the specified string value into its JavaScript Date equivalent using CultureInfo specific format information. * * Example

	///////////
	// Dates //
	///////////

	// 15-Oct-2004
	var d1 = Date.parse("10/15/2004");

	// 15-Oct-2004
	var d1 = Date.parse("15-Oct-2004");

	// 15-Oct-2004
	var d1 = Date.parse("2004.10.15");

	//Fri Oct 15, 2004
	var d1 = Date.parse("Fri Oct 15, 2004");

	///////////
	// Times //
	///////////

	// Today at 10 PM.
	var d1 = Date.parse("10 PM");

	// Today at 10:30 PM.
	var d1 = Date.parse("10:30 P.M.");

	// Today at 6 AM.
	var d1 = Date.parse("06am");

	/////////////////////
	// Dates and Times //
	/////////////////////

	// 8-July-2004 @ 10:30 PM
	var d1 = Date.parse("July 8th, 2004, 10:30 PM");

	// 1-July-2004 @ 10:30 PM
	var d1 = Date.parse("2004-07-01T22:30:00");

	////////////////////
	// Relative Dates //
	////////////////////

	// Returns today's date. The string "today" is culture specific.
	var d1 = Date.parse("today");

	// Returns yesterday's date. The string "yesterday" is culture specific.
	var d1 = Date.parse("yesterday");

	// Returns the date of the next thursday.
	var d1 = Date.parse("Next thursday");

	// Returns the date of the most previous monday.
	var d1 = Date.parse("last monday");

	// Returns today's day + one year.
	var d1 = Date.parse("next year");

	///////////////
	// Date Math //
	///////////////

	// Today + 2 days
	var d1 = Date.parse("t+2");

	// Today + 2 days
	var d1 = Date.parse("today + 2 days");

	// Today + 3 months
	var d1 = Date.parse("t+3m");

	// Today - 1 year
	var d1 = Date.parse("today - 1 year");

	// Today - 1 year
	var d1 = Date.parse("t-1y"); 


	/////////////////////////////
	// Partial Dates and Times //
	/////////////////////////////

	// July 15th of this year.
	var d1 = Date.parse("July 15");

	// 15th day of current day and year.
	var d1 = Date.parse("15");

	// July 1st of current year at 10pm.
	var d1 = Date.parse("7/1 10pm");
	
* * @param {String} The string value to convert into a Date object [Required] * @return {Date} A Date object or null if the string cannot be converted into a Date. */ var parseUtils = { removeOrds: function (s) { ords = s.match(/\b(\d+)(?:st|nd|rd|th)\b/); // find ordinal matches s = ((ords && ords.length === 2) ? s.replace(ords[0], ords[1]) : s); return s; }, grammarParser: function (s) { var r = null; try { r = $D.Grammar.start.call({}, s.replace(/^\s*(\S*(\s+\S+)*)\s*$/, "$1")); } catch (e) { return null; } return ((r[1].length === 0) ? r[0] : null); }, nativeFallback: function(s) { var t; try { // ok we haven't parsed it, last ditch attempt with the built-in parser. t = Date._parse(s); return (t || t === 0) ? new Date(t) : null; } catch (e) { return null; } } }; function parse (s) { var d; if (!s) { return null; } if (s instanceof Date) { return s.clone(); } if (s.length >= 4 && s.charAt(0) !== "0" && s.charAt(0) !== "+"&& s.charAt(0) !== "-") { // ie: 2004 will pass, 0800 won't. // Start with specific formats d = $D.Parsing.ISO.parse(s) || $D.Parsing.Numeric.parse(s); } if (d instanceof Date && !isNaN(d.getTime())) { return d; } else { // find ordinal dates (1st, 3rd, 8th, etc and remove them as they cause parsing issues) s = $D.Parsing.Normalizer.parse(parseUtils.removeOrds(s)); d = parseUtils.grammarParser(s); if (d !== null) { return d; } else { return parseUtils.nativeFallback(s); } } } if (!$D._parse) { $D._parse = $D.parse; } $D.parse = parse; Date.getParseFunction = function (fx) { var fns = Date.Grammar.allformats(fx); return function (s) { var r = null; for (var i = 0; i < fns.length; i++) { try { r = fns[i].call({}, s); } catch (e) { continue; } if (r[1].length === 0) { return r[0]; } } return null; }; }; /** * Converts the specified string value into its JavaScript Date equivalent using the specified format {String} or formats {Array} and the CultureInfo specific format information. * The format of the string value must match one of the supplied formats exactly. * * Example

	// 15-Oct-2004
	var d1 = Date.parseExact("10/15/2004", "M/d/yyyy");

	// 15-Oct-2004
	var d1 = Date.parse("15-Oct-2004", "M-ddd-yyyy");

	// 15-Oct-2004
	var d1 = Date.parse("2004.10.15", "yyyy.MM.dd");

	// Multiple formats
	var d1 = Date.parseExact("10/15/2004", ["M/d/yyyy", "MMMM d, yyyy"]);
	
* * @param {String} The string value to convert into a Date object [Required]. * @param {Object} The expected format {String} or an array of expected formats {Array} of the date string [Required]. * @return {Date} A Date object or null if the string cannot be converted into a Date. */ $D.parseExact = function (s, fx) { return $D.getParseFunction(fx)(s); }; }()); (function () { var $D = Date, $P = $D.prototype, // $C = $D.CultureInfo, // not used atm p = function (s, l) { if (!l) { l = 2; } return ("000" + s).slice(l * -1); }; /** * Converts a PHP format string to Java/.NET format string. * A PHP format string can be used with ._format or .format. * A Java/.NET format string can be used with .toString(). * The .parseExact function will only accept a Java/.NET format string * * Example * var f1 = "%m/%d/%y" * var f2 = Date.normalizeFormat(f1); // "MM/dd/yy" * * new Date().format(f1); // "04/13/08" * new Date()._format(f1); // "04/13/08" * new Date().toString(f2); // "04/13/08" * * var date = Date.parseExact("04/13/08", f2); // Sun Apr 13 2008 * * @param {String} A PHP format string consisting of one or more format spcifiers. * @return {String} The PHP format converted to a Java/.NET format string. */ var normalizerSubstitutions = { "d" : "dd", "%d": "dd", "D" : "ddd", "%a": "ddd", "j" : "dddd", "l" : "dddd", "%A": "dddd", "S" : "S", "F" : "MMMM", "%B": "MMMM", "m" : "MM", "%m": "MM", "M" : "MMM", "%b": "MMM", "%h": "MMM", "n" : "M", "Y" : "yyyy", "%Y": "yyyy", "y" : "yy", "%y": "yy", "g" : "h", "%I": "h", "G" : "H", "h" : "hh", "H" : "HH", "%H": "HH", "i" : "mm", "%M": "mm", "s" : "ss", "%S": "ss", "%r": "hh:mm tt", "%R": "H:mm", "%T": "H:mm:ss", "%X": "t", "%x": "d", "%e": "d", "%D": "MM/dd/yy", "%n": "\\n", "%t": "\\t", "e" : "z", "T" : "z", "%z": "z", "%Z": "z", "Z" : "ZZ", "N" : "u", "w" : "u", "%w": "u", "W" : "W", "%V": "W" }; var normalizer = { substitutes: function (m) { return normalizerSubstitutions[m]; }, interpreted: function (m, x) { var y; switch (m) { case "%u": return x.getDay() + 1; case "z": return x.getOrdinalNumber(); case "%j": return p(x.getOrdinalNumber(), 3); case "%U": var d1 = x.clone().set({month: 0, day: 1}).addDays(-1).moveToDayOfWeek(0), d2 = x.clone().addDays(1).moveToDayOfWeek(0, -1); return (d2 < d1) ? "00" : p((d2.getOrdinalNumber() - d1.getOrdinalNumber()) / 7 + 1); case "%W": return p(x.getWeek()); case "t": return $D.getDaysInMonth(x.getFullYear(), x.getMonth()); case "o": case "%G": return x.setWeek(x.getISOWeek()).toString("yyyy"); case "%g": return x._format("%G").slice(-2); case "a": case "%p": return t("tt").toLowerCase(); case "A": return t("tt").toUpperCase(); case "u": return p(x.getMilliseconds(), 3); case "I": return (x.isDaylightSavingTime()) ? 1 : 0; case "O": return x.getUTCOffset(); case "P": y = x.getUTCOffset(); return y.substring(0, y.length - 2) + ":" + y.substring(y.length - 2); case "B": var now = new Date(); return Math.floor(((now.getHours() * 3600) + (now.getMinutes() * 60) + now.getSeconds() + (now.getTimezoneOffset() + 60) * 60) / 86.4); case "c": return x.toISOString().replace(/\"/g, ""); case "U": return $D.strtotime("now"); case "%c": return t("d") + " " + t("t"); case "%C": return Math.floor(x.getFullYear() / 100 + 1); } }, shouldOverrideDefaults: function (m) { switch (m) { case "%e": return true; default: return false; } }, parse: function (m, context) { var formatString, c = context || new Date(); formatString = normalizer.substitutes(m); if (formatString) { return formatString; } formatString = normalizer.interpreted(m, c); if (formatString) { return formatString; } else { return m; } } }; $D.normalizeFormat = function (format, context) { return format.replace(/(%|\\)?.|%%/g, function(t){ return normalizer.parse(t, context); }); }; /** * Format a local Unix timestamp according to locale settings * * Example: * Date.strftime("%m/%d/%y", new Date()); // "04/13/08" * Date.strftime("c", "2008-04-13T17:52:03Z"); // "04/13/08" * * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @param {Number|String} The number representing the number of seconds that have elapsed since January 1, 1970 (local time). * @return {String} A string representation of the current Date object. */ $D.strftime = function (format, time) { var d = Date.parse(time); return d._format(format); }; /** * Parse any textual datetime description into a Unix timestamp. * A Unix timestamp is the number of seconds that have elapsed since January 1, 1970 (midnight UTC/GMT). * * Example: * Date.strtotime("04/13/08"); // 1208044800 * Date.strtotime("1970-01-01T00:00:00Z"); // 0 * * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @param {Object} A string or date object. * @return {String} A string representation of the current Date object. */ $D.strtotime = function (time) { var d = $D.parse(time); return Math.round($D.UTC(d.getUTCFullYear(), d.getUTCMonth(), d.getUTCDate(), d.getUTCHours(), d.getUTCMinutes(), d.getUTCSeconds(), d.getUTCMilliseconds()) / 1000); }; /** * Converts the value of the current Date object to its equivalent string representation using a PHP/Unix style of date format specifiers. * Format Specifiers * Format Description Example * ------ --------------------------------------------------------------------------- ----------------------- * %a abbreviated weekday name according to the current localed "Mon" through "Sun" * %A full weekday name according to the current localed "Sunday" through "Saturday" * %b abbreviated month name according to the current localed "Jan" through "Dec" * %B full month name according to the current locale "January" through "December" * %c preferred date and time representation for the current locale "4/13/2008 12:33 PM" * %C century number (the year divided by 100 and truncated to an integer) "00" to "99" * %d day of the month as a decimal number "01" to "31" * %D same as %m/%d/%y "04/13/08" * %e day of the month as a decimal number, a single digit is preceded by a space "1" to "31" * %g like %G, but without the century "08" * %G The 4-digit year corresponding to the ISO week number (see %V). "2008" * This has the same format and value as %Y, except that if the ISO week number * belongs to the previous or next year, that year is used instead. * %h same as %b "Jan" through "Dec" * %H hour as a decimal number using a 24-hour clock. "00" to "23" * %I hour as a decimal number using a 12-hour clock. "01" to "12" * %j day of the year as a decimal number. "001" to "366" * %m month as a decimal number. "01" to "12" * %M minute as a decimal number. "00" to "59" * %n newline character "\n" * %p either "am" or "pm" according to the given time value, or the "am" or "pm" * corresponding strings for the current locale. * %r time in a.m. and p.m. notation "8:44 PM" * %R time in 24 hour notation "20:44" * %S second as a decimal number "00" to "59" * %t tab character "\t" * %T current time, equal to %H:%M:%S "12:49:11" * %u weekday as a decimal number ["1", "7"], with "1" representing Monday "1" to "7" * %U week number of the current year as a decimal number, starting with the "0" to ("52" or "53") * first Sunday as the first day of the first week * %V The ISO 8601:1988 week number of the current year as a decimal number, "00" to ("52" or "53") * range 01 to 53, where week 1 is the first week that has at least 4 days * in the current year, and with Monday as the first day of the week. * (Use %G or %g for the year component that corresponds to the week number * for the specified timestamp.) * %W week number of the current year as a decimal number, starting with the "00" to ("52" or "53") * first Monday as the first day of the first week * %w day of the week as a decimal, Sunday being "0" "0" to "6" * %x preferred date representation for the current locale without the time "4/13/2008" * %X preferred time representation for the current locale without the date "12:53:05" * %y year as a decimal number without a century "00" "99" * %Y year as a decimal number including the century "2008" * %Z time zone or name or abbreviation "UTC", "EST", "PST" * %z same as %Z * %% a literal "%" characters "%" * d Day of the month, 2 digits with leading zeros "01" to "31" * D A textual representation of a day, three letters "Mon" through "Sun" * j Day of the month without leading zeros "1" to "31" * l A full textual representation of the day of the week (lowercase "L") "Sunday" through "Saturday" * N ISO-8601 numeric representation of the day of the week (added in PHP 5.1.0) "1" (for Monday) through "7" (for Sunday) * S English ordinal suffix for the day of the month, 2 characters "st", "nd", "rd" or "th". Works well with j * w Numeric representation of the day of the week "0" (for Sunday) through "6" (for Saturday) * z The day of the year (starting from "0") "0" through "365" * W ISO-8601 week number of year, weeks starting on Monday "00" to ("52" or "53") * F A full textual representation of a month, such as January or March "January" through "December" * m Numeric representation of a month, with leading zeros "01" through "12" * M A short textual representation of a month, three letters "Jan" through "Dec" * n Numeric representation of a month, without leading zeros "1" through "12" * t Number of days in the given month "28" through "31" * L Whether it's a leap year "1" if it is a leap year, "0" otherwise * o ISO-8601 year number. This has the same value as Y, except that if the "2008" * ISO week number (W) belongs to the previous or next year, that year * is used instead. * Y A full numeric representation of a year, 4 digits "2008" * y A two digit representation of a year "08" * a Lowercase Ante meridiem and Post meridiem "am" or "pm" * A Uppercase Ante meridiem and Post meridiem "AM" or "PM" * B Swatch Internet time "000" through "999" * g 12-hour format of an hour without leading zeros "1" through "12" * G 24-hour format of an hour without leading zeros "0" through "23" * h 12-hour format of an hour with leading zeros "01" through "12" * H 24-hour format of an hour with leading zeros "00" through "23" * i Minutes with leading zeros "00" to "59" * s Seconds, with leading zeros "00" through "59" * u Milliseconds "54321" * e Timezone identifier "UTC", "EST", "PST" * I Whether or not the date is in daylight saving time (uppercase i) "1" if Daylight Saving Time, "0" otherwise * O Difference to Greenwich time (GMT) in hours "+0200", "-0600" * P Difference to Greenwich time (GMT) with colon between hours and minutes "+02:00", "-06:00" * T Timezone abbreviation "UTC", "EST", "PST" * Z Timezone offset in seconds. The offset for timezones west of UTC is "-43200" through "50400" * always negative, and for those east of UTC is always positive. * c ISO 8601 date "2004-02-12T15:19:21+00:00" * r RFC 2822 formatted date "Thu, 21 Dec 2000 16:01:07 +0200" * U Seconds since the Unix Epoch (January 1 1970 00:00:00 GMT) "0" * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @return {String} A string representation of the current Date object. */ var formatReplace = function (context) { return function (m) { var formatString, override = false; if (m.charAt(0) === "\\" || m.substring(0, 2) === "%%") { return m.replace("\\", "").replace("%%", "%"); } override = normalizer.shouldOverrideDefaults(m); formatString = $D.normalizeFormat(m, context); if (formatString) { return context.toString(formatString, override); } }; }; $P._format = function (format) { var formatter = formatReplace(this); if (!format) { return this._toString(); } else { return format.replace(/(%|\\)?.|%%/g, formatter); } }; if (!$P.format) { $P.format = $P._format; } }()); (function () { "use strict"; var gFn = function (attr) { return function () { return this[attr]; }; }; var sFn = function (attr) { return function (val) { this[attr] = val; return this; }; }; var attrs = ["years", "months", "days", "hours", "minutes", "seconds", "milliseconds"]; var addSetFuncs = function (context, attrs) { for (var i = 0; i < attrs.length ; i++) { var $a = attrs[i], $b = $a.slice(0, 1).toUpperCase() + $a.slice(1); context.prototype[$a] = 0; context.prototype["get" + $b] = gFn($a); context.prototype["set" + $b] = sFn($a); } }; /** * new TimeSpan(milliseconds); * new TimeSpan(days, hours, minutes, seconds); * new TimeSpan(days, hours, minutes, seconds, milliseconds); */ var TimeSpan = function (days, hours, minutes, seconds, milliseconds) { if (arguments.length === 1 && typeof days === "number") { var orient = (days < 0) ? -1 : +1; var millsLeft = Math.abs(days); this.setDays(Math.floor(millsLeft / 86400000) * orient); millsLeft = millsLeft % 86400000; this.setHours(Math.floor(millsLeft / 3600000) * orient); millsLeft = millsLeft % 3600000; this.setMinutes(Math.floor(millsLeft / 60000) * orient); millsLeft = millsLeft % 60000; this.setSeconds(Math.floor(millsLeft / 1000) * orient); millsLeft = millsLeft % 1000; this.setMilliseconds(millsLeft * orient); } else { this.set(days, hours, minutes, seconds, milliseconds); } this.getTotalMilliseconds = function () { return (this.getDays() * 86400000) + (this.getHours() * 3600000) + (this.getMinutes() * 60000) + (this.getSeconds() * 1000); }; this.compareTo = function (time) { var t1 = new Date(1970, 1, 1, this.getHours(), this.getMinutes(), this.getSeconds()), t2; if (time === null) { t2 = new Date(1970, 1, 1, 0, 0, 0); } else { t2 = new Date(1970, 1, 1, time.getHours(), time.getMinutes(), time.getSeconds()); } return (t1 < t2) ? -1 : (t1 > t2) ? 1 : 0; }; this.equals = function (time) { return (this.compareTo(time) === 0); }; this.add = function (time) { return (time === null) ? this : this.addSeconds(time.getTotalMilliseconds() / 1000); }; this.subtract = function (time) { return (time === null) ? this : this.addSeconds(-time.getTotalMilliseconds() / 1000); }; this.addDays = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 86400000)); }; this.addHours = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 3600000)); }; this.addMinutes = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 60000)); }; this.addSeconds = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 1000)); }; this.addMilliseconds = function (n) { return new TimeSpan(this.getTotalMilliseconds() + n); }; this.get12HourHour = function () { return (this.getHours() > 12) ? this.getHours() - 12 : (this.getHours() === 0) ? 12 : this.getHours(); }; this.getDesignator = function () { return (this.getHours() < 12) ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator; }; this.toString = function (format) { this._toString = function () { if (this.getDays() !== null && this.getDays() > 0) { return this.getDays() + "." + this.getHours() + ":" + this.p(this.getMinutes()) + ":" + this.p(this.getSeconds()); } else { return this.getHours() + ":" + this.p(this.getMinutes()) + ":" + this.p(this.getSeconds()); } }; this.p = function (s) { return (s.toString().length < 2) ? "0" + s : s; }; var me = this; return format ? format.replace(/dd?|HH?|hh?|mm?|ss?|tt?/g, function (format) { switch (format) { case "d": return me.getDays(); case "dd": return me.p(me.getDays()); case "H": return me.getHours(); case "HH": return me.p(me.getHours()); case "h": return me.get12HourHour(); case "hh": return me.p(me.get12HourHour()); case "m": return me.getMinutes(); case "mm": return me.p(me.getMinutes()); case "s": return me.getSeconds(); case "ss": return me.p(me.getSeconds()); case "t": return ((me.getHours() < 12) ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator).substring(0, 1); case "tt": return (me.getHours() < 12) ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator; } } ) : this._toString(); }; return this; }; addSetFuncs(TimeSpan, attrs.slice(2)); TimeSpan.prototype.set = function (days, hours, minutes, seconds, milliseconds){ this.setDays(days || this.getDays()); this.setHours(hours || this.getHours()); this.setMinutes(minutes || this.getMinutes()); this.setSeconds(seconds || this.getSeconds()); this.setMilliseconds(milliseconds || this.getMilliseconds()); }; /** * Gets the time of day for this date instances. * @return {TimeSpan} TimeSpan */ Date.prototype.getTimeOfDay = function () { return new TimeSpan(0, this.getHours(), this.getMinutes(), this.getSeconds(), this.getMilliseconds()); }; Date.TimeSpan = TimeSpan; if (typeof window !== "undefined" ) { // keeping API compatible for v1.x window.TimeSpan = TimeSpan; } }()); (function () { "use strict"; var attrs = ["years", "months", "days", "hours", "minutes", "seconds", "milliseconds"]; var gFn = function (attr) { return function () { return this[attr]; }; }; var sFn = function (attr) { return function (val) { this[attr] = val; return this; }; }; var addSetFuncs = function (context, attrs) { for (var i = 0; i < attrs.length ; i++) { var $a = attrs[i], $b = $a.slice(0, 1).toUpperCase() + $a.slice(1); context.prototype[$a] = 0; context.prototype["get" + $b] = gFn($a); context.prototype["set" + $b] = sFn($a); } }; var setMonthsAndYears = function (orient, d1, d2, context) { function inc() { d1.addMonths(-orient); context.months++; if (context.months === 12) { context.years++; context.months = 0; } } if (orient === +1) { while (d1 > d2) { inc(); } } else { while (d1 < d2) { inc(); } } context.months--; context.months *= orient; context.years *= orient; }; var adjustForDST = function(orient, startDate, endDate) { var hasDSTMismatch = (false === (startDate.isDaylightSavingTime() === endDate.isDaylightSavingTime())); if (hasDSTMismatch && orient === 1) { startDate.addHours(-1); } else if (hasDSTMismatch) { startDate.addHours(1); } }; /** * TimePeriod(startDate, endDate); * TimePeriod(years, months, days, hours, minutes, seconds, milliseconds); */ var TimePeriod = function (years, months, days, hours, minutes, seconds, milliseconds) { if (arguments.length === 7) { this.set(years, months, days, hours, minutes, seconds, milliseconds); } else if (arguments.length === 2 && arguments[0] instanceof Date && arguments[1] instanceof Date) { var startDate = arguments[0].clone(); var endDate = arguments[1].clone(); var orient = (startDate > endDate) ? +1 : -1; this.dates = { start: arguments[0].clone(), end: arguments[1].clone() }; setMonthsAndYears(orient, startDate, endDate, this); adjustForDST(orient, startDate, endDate); // // TODO - adjust for DST var diff = endDate - startDate; if (diff !== 0) { var ts = new TimeSpan(diff); this.set(this.years, this.months, ts.getDays(), ts.getHours(), ts.getMinutes(), ts.getSeconds(), ts.getMilliseconds()); } } return this; }; // create all the set functions. addSetFuncs(TimePeriod, attrs); TimePeriod.prototype.set = function (years, months, days, hours, minutes, seconds, milliseconds){ this.setYears(years || this.getYears()); this.setMonths(months || this.getMonths()); this.setDays(days || this.getDays()); this.setHours(hours || this.getHours()); this.setMinutes(minutes || this.getMinutes()); this.setSeconds(seconds || this.getSeconds()); this.setMilliseconds(milliseconds || this.getMilliseconds()); }; Date.TimePeriod = TimePeriod; if (typeof window !== "undefined") { // keeping API compatible for v1.x window.TimePeriod = TimePeriod; } }()); ================================================ FILE: build/date-vi-VN.js ================================================ /** * @overview datejs * @version 1.0.0-rc3 * @author Gregory Wild-Smith * @copyright 2015 Gregory Wild-Smith * @license MIT * @homepage https://github.com/abritinthebay/datejs */ /* * DateJS Culture String File * Country Code: vi-VN * Name: Vietnamese (Vietnam) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["vi-VN"] = { "name": "vi-VN", "englishName": "Vietnamese (Vietnam)", "nativeName": "Tiếng Việt (Việt Nam)", "Sunday": "Chủ Nhật", "Monday": "Thứ Hai", "Tuesday": "Thứ Ba", "Wednesday": "Thứ Tư", "Thursday": "Thứ Năm", "Friday": "Thứ Sáu", "Saturday": "Thứ Bảy", "Sun": "CN", "Mon": "Hai", "Tue": "Ba", "Wed": "Tư", "Thu": "Năm", "Fri": "Sáu", "Sat": "Bảy", "Su": "C", "Mo": "H", "Tu": "B", "We": "T", "Th": "N", "Fr": "S", "Sa": "B", "S_Sun_Initial": "C", "M_Mon_Initial": "H", "T_Tue_Initial": "B", "W_Wed_Initial": "T", "T_Thu_Initial": "N", "F_Fri_Initial": "S", "S_Sat_Initial": "B", "January": "Tháng Giêng", "February": "Tháng Hai", "March": "Tháng Ba", "April": "Tháng Tư", "May": "Tháng Năm", "June": "Tháng Sáu", "July": "Tháng Bảy", "August": "Tháng Tám", "September": "Tháng Chín", "October": "Tháng Mười", "November": "Tháng Mười Một", "December": "Tháng Mười Hai", "Jan_Abbr": "Thg1", "Feb_Abbr": "Thg2", "Mar_Abbr": "Thg3", "Apr_Abbr": "Thg4", "May_Abbr": "Thg5", "Jun_Abbr": "Thg6", "Jul_Abbr": "Thg7", "Aug_Abbr": "Thg8", "Sep_Abbr": "Thg9", "Oct_Abbr": "Thg10", "Nov_Abbr": "Thg11", "Dec_Abbr": "Thg12", "AM": "SA", "PM": "CH", "firstDayOfWeek": 1, "twoDigitYearMax": 2029, "mdy": "dmy", "M/d/yyyy": "dd/MM/yyyy", "dddd, MMMM dd, yyyy": "dd MMMM yyyy", "h:mm tt": "h:mm tt", "h:mm:ss tt": "h:mm:ss tt", "dddd, MMMM dd, yyyy h:mm:ss tt": "dd MMMM yyyy h:mm:ss tt", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "dd MMMM", "MMMM, yyyy": "MMMM yyyy", "/jan(uary)?/": "tháng giêng", "/feb(ruary)?/": "tháng hai", "/mar(ch)?/": "tháng ba", "/apr(il)?/": "tháng tư", "/may/": "tháng năm", "/jun(e)?/": "tháng sáu", "/jul(y)?/": "tháng bảy", "/aug(ust)?/": "tháng tám", "/sep(t(ember)?)?/": "tháng chín", "/oct(ober)?/": "tháng mười", "/nov(ember)?/": "tháng mười một", "/dec(ember)?/": "tháng mười hai", "/^su(n(day)?)?/": "^c(n(ủ nhật)?)?", "/^mo(n(day)?)?/": "^h(ai(́ hai)?)?", "/^tu(e(s(day)?)?)?/": "^b(a(ứ ba)?)?", "/^we(d(nesday)?)?/": "^t(ư(ứ tư)?)?", "/^th(u(r(s(day)?)?)?)?/": "^n(ăm(́ năm)?)?", "/^fr(i(day)?)?/": "^s(áu( sáu)?)?", "/^sa(t(urday)?)?/": "^b(ảy( bảy)?)?", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "vi-VN"; /** * @overview datejs * @version 1.0.0-rc3 * @author Gregory Wild-Smith * @copyright 2015 Gregory Wild-Smith * @license MIT * @homepage https://github.com/abritinthebay/datejs */(function () { var $D = Date; var lang = Date.CultureStrings ? Date.CultureStrings.lang : null; var loggedKeys = {}; // for debug purposes. var getText = { getFromKey: function (key, countryCode) { var output; if (Date.CultureStrings && Date.CultureStrings[countryCode] && Date.CultureStrings[countryCode][key]) { output = Date.CultureStrings[countryCode][key]; } else { output = getText.buildFromDefault(key); } if (key.charAt(0) === "/") { // Assume it's a regex output = getText.buildFromRegex(key, countryCode); } return output; }, getFromObjectValues: function (obj, countryCode) { var key, output = {}; for(key in obj) { if (obj.hasOwnProperty(key)) { output[key] = getText.getFromKey(obj[key], countryCode); } } return output; }, getFromObjectKeys: function (obj, countryCode) { var key, output = {}; for(key in obj) { if (obj.hasOwnProperty(key)) { output[getText.getFromKey(key, countryCode)] = obj[key]; } } return output; }, getFromArray: function (arr, countryCode) { var output = []; for (var i=0; i < arr.length; i++){ if (i in arr) { output[i] = getText.getFromKey(arr[i], countryCode); } } return output; }, buildFromDefault: function (key) { var output, length, split, last; switch(key) { case "name": output = "en-US"; break; case "englishName": output = "English (United States)"; break; case "nativeName": output = "English (United States)"; break; case "twoDigitYearMax": output = 2049; break; case "firstDayOfWeek": output = 0; break; default: output = key; split = key.split("_"); length = split.length; if (length > 1 && key.charAt(0) !== "/") { // if the key isn't a regex and it has a split. last = split[(length - 1)].toLowerCase(); if (last === "initial" || last === "abbr") { output = split[0]; } } break; } return output; }, buildFromRegex: function (key, countryCode) { var output; if (Date.CultureStrings && Date.CultureStrings[countryCode] && Date.CultureStrings[countryCode][key]) { output = new RegExp(Date.CultureStrings[countryCode][key], "i"); } else { output = new RegExp(key.replace(new RegExp("/", "g"),""), "i"); } return output; } }; var shallowMerge = function (obj1, obj2) { for (var attrname in obj2) { if (obj2.hasOwnProperty(attrname)) { obj1[attrname] = obj2[attrname]; } } }; var __ = function (key, language) { var countryCode = (language) ? language : lang; loggedKeys[key] = key; if (typeof key === "object") { if (key instanceof Array) { return getText.getFromArray(key, countryCode); } else { return getText.getFromObjectKeys(key, countryCode); } } else { return getText.getFromKey(key, countryCode); } }; var loadI18nScript = function (code) { // paatterned after jQuery's getScript. var url = Date.Config.i18n + code + ".js"; var head = document.getElementsByTagName("head")[0] || document.documentElement; var script = document.createElement("script"); script.src = url; var completed = false; var events = { done: function (){} // placeholder function }; // Attach handlers for all browsers script.onload = script.onreadystatechange = function() { if ( !completed && (!this.readyState || this.readyState === "loaded" || this.readyState === "complete") ) { events.done(); head.removeChild(script); } }; setTimeout(function() { head.insertBefore(script, head.firstChild); }, 0); // allows return to execute first return { done: function (cb) { events.done = function() { if (cb) { setTimeout(cb,0); } }; } }; }; var buildInfo = { buildFromMethodHash: function (obj) { var key; for(key in obj) { if (obj.hasOwnProperty(key)) { obj[key] = buildInfo[obj[key]](); } } return obj; }, timeZoneDST: function () { var DST = { "CHADT": "+1345", "NZDT": "+1300", "AEDT": "+1100", "ACDT": "+1030", "AZST": "+0500", "IRDT": "+0430", "EEST": "+0300", "CEST": "+0200", "BST": "+0100", "PMDT": "-0200", "ADT": "-0300", "NDT": "-0230", "EDT": "-0400", "CDT": "-0500", "MDT": "-0600", "PDT": "-0700", "AKDT": "-0800", "HADT": "-0900" }; return __(DST); }, timeZoneStandard: function () { var standard = { "LINT": "+1400", "TOT": "+1300", "CHAST": "+1245", "NZST": "+1200", "NFT": "+1130", "SBT": "+1100", "AEST": "+1000", "ACST": "+0930", "JST": "+0900", "CWST": "+0845", "CT": "+0800", "ICT": "+0700", "MMT": "+0630", "BST": "+0600", "NPT": "+0545", "IST": "+0530", "PKT": "+0500", "AFT": "+0430", "MSK": "+0400", "IRST": "+0330", "FET": "+0300", "EET": "+0200", "CET": "+0100", "GMT": "+0000", "UTC": "+0000", "CVT": "-0100", "GST": "-0200", "BRT": "-0300", "NST": "-0330", "AST": "-0400", "EST": "-0500", "CST": "-0600", "MST": "-0700", "PST": "-0800", "AKST": "-0900", "MIT": "-0930", "HST": "-1000", "SST": "-1100", "BIT": "-1200" }; return __(standard); }, timeZones: function (data) { var zone; data.timezones = []; for (zone in data.abbreviatedTimeZoneStandard) { if (data.abbreviatedTimeZoneStandard.hasOwnProperty(zone)) { data.timezones.push({ name: zone, offset: data.abbreviatedTimeZoneStandard[zone]}); } } for (zone in data.abbreviatedTimeZoneDST) { if (data.abbreviatedTimeZoneDST.hasOwnProperty(zone)) { data.timezones.push({ name: zone, offset: data.abbreviatedTimeZoneDST[zone], dst: true}); } } return data.timezones; }, days: function () { return __(["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"]); }, dayAbbr: function () { return __(["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"]); }, dayShortNames: function () { return __(["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"]); }, dayFirstLetters: function () { return __(["S_Sun_Initial", "M_Mon_Initial", "T_Tues_Initial", "W_Wed_Initial", "T_Thu_Initial", "F_Fri_Initial", "S_Sat_Initial"]); }, months: function () { return __(["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"]); }, monthAbbr: function () { return __(["Jan_Abbr", "Feb_Abbr", "Mar_Abbr", "Apr_Abbr", "May_Abbr", "Jun_Abbr", "Jul_Abbr", "Aug_Abbr", "Sep_Abbr", "Oct_Abbr", "Nov_Abbr", "Dec_Abbr"]); }, formatPatterns: function () { return getText.getFromObjectValues({ shortDate: "M/d/yyyy", longDate: "dddd, MMMM dd, yyyy", shortTime: "h:mm tt", longTime: "h:mm:ss tt", fullDateTime: "dddd, MMMM dd, yyyy h:mm:ss tt", sortableDateTime: "yyyy-MM-ddTHH:mm:ss", universalSortableDateTime: "yyyy-MM-dd HH:mm:ssZ", rfc1123: "ddd, dd MMM yyyy HH:mm:ss", monthDay: "MMMM dd", yearMonth: "MMMM, yyyy" }, Date.i18n.currentLanguage()); }, regex: function () { return getText.getFromObjectValues({ inTheMorning: "/( in the )(morn(ing)?)\\b/", thisMorning: "/(this )(morn(ing)?)\\b/", amThisMorning: "/(\b\\d(am)? )(this )(morn(ing)?)/", inTheEvening: "/( in the )(even(ing)?)\\b/", thisEvening: "/(this )(even(ing)?)\\b/", pmThisEvening: "/(\b\\d(pm)? )(this )(even(ing)?)/", jan: "/jan(uary)?/", feb: "/feb(ruary)?/", mar: "/mar(ch)?/", apr: "/apr(il)?/", may: "/may/", jun: "/jun(e)?/", jul: "/jul(y)?/", aug: "/aug(ust)?/", sep: "/sep(t(ember)?)?/", oct: "/oct(ober)?/", nov: "/nov(ember)?/", dec: "/dec(ember)?/", sun: "/^su(n(day)?)?/", mon: "/^mo(n(day)?)?/", tue: "/^tu(e(s(day)?)?)?/", wed: "/^we(d(nesday)?)?/", thu: "/^th(u(r(s(day)?)?)?)?/", fri: "/fr(i(day)?)?/", sat: "/^sa(t(urday)?)?/", future: "/^next/", past: "/^last|past|prev(ious)?/", add: "/^(\\+|aft(er)?|from|hence)/", subtract: "/^(\\-|bef(ore)?|ago)/", yesterday: "/^yes(terday)?/", today: "/^t(od(ay)?)?/", tomorrow: "/^tom(orrow)?/", now: "/^n(ow)?/", millisecond: "/^ms|milli(second)?s?/", second: "/^sec(ond)?s?/", minute: "/^mn|min(ute)?s?/", hour: "/^h(our)?s?/", week: "/^w(eek)?s?/", month: "/^m(onth)?s?/", day: "/^d(ay)?s?/", year: "/^y(ear)?s?/", shortMeridian: "/^(a|p)/", longMeridian: "/^(a\\.?m?\\.?|p\\.?m?\\.?)/", timezone: "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/", ordinalSuffix: "/^\\s*(st|nd|rd|th)/", timeContext: "/^\\s*(\\:|a(?!u|p)|p)/" }, Date.i18n.currentLanguage()); } }; var CultureInfo = function () { var info = getText.getFromObjectValues({ name: "name", englishName: "englishName", nativeName: "nativeName", amDesignator: "AM", pmDesignator: "PM", firstDayOfWeek: "firstDayOfWeek", twoDigitYearMax: "twoDigitYearMax", dateElementOrder: "mdy" }, Date.i18n.currentLanguage()); var constructedInfo = buildInfo.buildFromMethodHash({ dayNames: "days", abbreviatedDayNames: "dayAbbr", shortestDayNames: "dayShortNames", firstLetterDayNames: "dayFirstLetters", monthNames: "months", abbreviatedMonthNames: "monthAbbr", formatPatterns: "formatPatterns", regexPatterns: "regex", abbreviatedTimeZoneDST: "timeZoneDST", abbreviatedTimeZoneStandard: "timeZoneStandard" }); shallowMerge(info, constructedInfo); buildInfo.timeZones(info); return info; }; $D.i18n = { __: function (key, lang) { return __(key, lang); }, currentLanguage: function () { return lang || "en-US"; }, setLanguage: function (code, force, cb) { var async = false; if (force || code === "en-US" || (!!Date.CultureStrings && !!Date.CultureStrings[code])) { lang = code; Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings.lang = code; Date.CultureInfo = new CultureInfo(); } else { if (!(!!Date.CultureStrings && !!Date.CultureStrings[code])) { if (typeof exports !== "undefined" && this.exports !== exports) { // we're in a Node enviroment, load it using require try { require("../i18n/" + code + ".js"); lang = code; Date.CultureStrings.lang = code; Date.CultureInfo = new CultureInfo(); } catch (e) { // var str = "The language for '" + code + "' could not be loaded by Node. It likely does not exist."; throw new Error("The DateJS IETF language tag '" + code + "' could not be loaded by Node. It likely does not exist."); } } else if (Date.Config && Date.Config.i18n) { // we know the location of the files, so lets load them async = true; loadI18nScript(code).done(function(){ lang = code; Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings.lang = code; Date.CultureInfo = new CultureInfo(); $D.Parsing.Normalizer.buildReplaceData(); // because this is async if ($D.Grammar) { $D.Grammar.buildGrammarFormats(); // so we can parse those strings... } if (cb) { setTimeout(cb,0); } }); } else { Date.console.error("The DateJS IETF language tag '" + code + "' is not available and has not been loaded."); return false; } } } $D.Parsing.Normalizer.buildReplaceData(); // rebuild normalizer strings if ($D.Grammar) { $D.Grammar.buildGrammarFormats(); // so we can parse those strings... } if (!async && cb) { setTimeout(cb,0); } }, getLoggedKeys: function () { return loggedKeys; }, updateCultureInfo: function () { Date.CultureInfo = new CultureInfo(); } }; $D.i18n.updateCultureInfo(); // run automatically }()); (function () { var $D = Date, $P = $D.prototype, p = function (s, l) { if (!l) { l = 2; } return ("000" + s).slice(l * -1); }; if (typeof window !== "undefined" && typeof window.console !== "undefined" && typeof window.console.log !== "undefined") { $D.console = console; // used only to raise non-critical errors if available } else { // set mock so we don't give errors. $D.console = { log: function(){}, error: function(){} }; } $D.Config = $D.Config || {}; $D.initOverloads = function() { /** * Overload of Date.now. Allows an alternate call for Date.now where it returns the * current Date as an object rather than just milliseconds since the Unix Epoch. * * Also provides an implementation of now() for browsers (IE<9) that don't have it. * * Backwards compatible so with work with either: * Date.now() [returns ms] * or * Date.now(true) [returns Date] */ if (!$D.now) { $D._now = function now() { return new Date().getTime(); }; } else if (!$D._now) { $D._now = $D.now; } $D.now = function (returnObj) { if (returnObj) { return $D.present(); } else { return $D._now(); } }; if ( !$P.toISOString ) { $P.toISOString = function() { return this.getUTCFullYear() + "-" + p(this.getUTCMonth() + 1) + "-" + p(this.getUTCDate()) + "T" + p(this.getUTCHours()) + ":" + p(this.getUTCMinutes()) + ":" + p(this.getUTCSeconds()) + "." + String( (this.getUTCMilliseconds()/1000).toFixed(3)).slice(2, 5) + "Z"; }; } // private if ( $P._toString === undefined ){ $P._toString = $P.toString; } }; $D.initOverloads(); /** * Gets a date that is set to the current date. The time is set to the start of the day (00:00 or 12:00 AM). * @return {Date} The current date. */ $D.today = function () { return new Date().clearTime(); }; /** * Gets a date that is set to the current date and time (same as new Date, but chainable) * @return {Date} The current date. */ $D.present = function () { return new Date(); }; /** * Compares the first date to the second date and returns an number indication of their relative values. * @param {Date} First Date object to compare [Required]. * @param {Date} Second Date object to compare to [Required]. * @return {Number} -1 = date1 is lessthan date2. 0 = values are equal. 1 = date1 is greaterthan date2. */ $D.compare = function (date1, date2) { if (isNaN(date1) || isNaN(date2)) { throw new Error(date1 + " - " + date2); } else if (date1 instanceof Date && date2 instanceof Date) { return (date1 < date2) ? -1 : (date1 > date2) ? 1 : 0; } else { throw new TypeError(date1 + " - " + date2); } }; /** * Compares the first Date object to the second Date object and returns true if they are equal. * @param {Date} First Date object to compare [Required] * @param {Date} Second Date object to compare to [Required] * @return {Boolean} true if dates are equal. false if they are not equal. */ $D.equals = function (date1, date2) { return (date1.compareTo(date2) === 0); }; /** * Gets the language appropriate day name when given the day number(0-6) * eg - 0 == Sunday * @return {String} The day name */ $D.getDayName = function (n) { return Date.CultureInfo.dayNames[n]; }; /** * Gets the day number (0-6) if given a CultureInfo specific string which is a valid dayName, abbreviatedDayName or shortestDayName (two char). * @param {String} The name of the day (eg. "Monday, "Mon", "tuesday", "tue", "We", "we"). * @return {Number} The day number */ $D.getDayNumberFromName = function (name) { var n = Date.CultureInfo.dayNames, m = Date.CultureInfo.abbreviatedDayNames, o = Date.CultureInfo.shortestDayNames, s = name.toLowerCase(); for (var i = 0; i < n.length; i++) { if (n[i].toLowerCase() === s || m[i].toLowerCase() === s || o[i].toLowerCase() === s) { return i; } } return -1; }; /** * Gets the month number (0-11) if given a Culture Info specific string which is a valid monthName or abbreviatedMonthName. * @param {String} The name of the month (eg. "February, "Feb", "october", "oct"). * @return {Number} The day number */ $D.getMonthNumberFromName = function (name) { var n = Date.CultureInfo.monthNames, m = Date.CultureInfo.abbreviatedMonthNames, s = name.toLowerCase(); for (var i = 0; i < n.length; i++) { if (n[i].toLowerCase() === s || m[i].toLowerCase() === s) { return i; } } return -1; }; /** * Gets the language appropriate month name when given the month number(0-11) * eg - 0 == January * @return {String} The month name */ $D.getMonthName = function (n) { return Date.CultureInfo.monthNames[n]; }; /** * Determines if the current date instance is within a LeapYear. * @param {Number} The year. * @return {Boolean} true if date is within a LeapYear, otherwise false. */ $D.isLeapYear = function (year) { return ((year % 4 === 0 && year % 100 !== 0) || year % 400 === 0); }; /** * Gets the number of days in the month, given a year and month value. Automatically corrects for LeapYear. * @param {Number} The year. * @param {Number} The month (0-11). * @return {Number} The number of days in the month. */ $D.getDaysInMonth = function (year, month) { if (!month && $D.validateMonth(year)) { month = year; year = Date.today().getFullYear(); } return [31, ($D.isLeapYear(year) ? 29 : 28), 31, 30, 31, 30, 31, 31, 30, 31, 30, 31][month]; }; $P.getDaysInMonth = function () { return $D.getDaysInMonth(this.getFullYear(), this.getMonth()); }; $D.getTimezoneAbbreviation = function (offset, dst) { var p, n = (dst || false) ? Date.CultureInfo.abbreviatedTimeZoneDST : Date.CultureInfo.abbreviatedTimeZoneStandard; for (p in n) { if (n.hasOwnProperty(p)) { if (n[p] === offset) { return p; } } } return null; }; $D.getTimezoneOffset = function (name, dst) { var i, a =[], z = Date.CultureInfo.timezones; if (!name) { name = (new Date()).getTimezone();} for (i = 0; i < z.length; i++) { if (z[i].name === name.toUpperCase()) { a.push(i); } } if (!z[a[0]]) { return null; } if (a.length === 1 || !dst) { return z[a[0]].offset; } else { for (i=0; i < a.length; i++) { if (z[a[i]].dst) { return z[a[i]].offset; } } } }; $D.getQuarter = function (d) { d = d || new Date(); // If no date supplied, use today var q = [1,2,3,4]; return q[Math.floor(d.getMonth() / 3)]; // ~~~ is a bitwise op. Faster than Math.floor }; $D.getDaysLeftInQuarter = function (d) { d = d || new Date(); var qEnd = new Date(d); qEnd.setMonth(qEnd.getMonth() + 3 - qEnd.getMonth() % 3, 0); return Math.floor((qEnd - d) / 8.64e7); }; // private var validate = function (n, min, max, name) { name = name ? name : "Object"; if (typeof n === "undefined") { return false; } else if (typeof n !== "number") { throw new TypeError(n + " is not a Number."); } else if (n < min || n > max) { // As failing validation is *not* an exceptional circumstance // lets not throw a RangeError Exception here. // It's semantically correct but it's not sensible. return false; } return true; }; /** * Validates the number is within an acceptable range for milliseconds [0-999]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateMillisecond = function (value) { return validate(value, 0, 999, "millisecond"); }; /** * Validates the number is within an acceptable range for seconds [0-59]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateSecond = function (value) { return validate(value, 0, 59, "second"); }; /** * Validates the number is within an acceptable range for minutes [0-59]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateMinute = function (value) { return validate(value, 0, 59, "minute"); }; /** * Validates the number is within an acceptable range for hours [0-23]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateHour = function (value) { return validate(value, 0, 23, "hour"); }; /** * Validates the number is within an acceptable range for the days in a month [0-MaxDaysInMonth]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateDay = function (value, year, month) { if (year === undefined || year === null || month === undefined || month === null) { return false;} return validate(value, 1, $D.getDaysInMonth(year, month), "day"); }; /** * Validates the number is within an acceptable range for months [0-11]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateWeek = function (value) { return validate(value, 0, 53, "week"); }; /** * Validates the number is within an acceptable range for months [0-11]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateMonth = function (value) { return validate(value, 0, 11, "month"); }; /** * Validates the number is within an acceptable range for years. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateYear = function (value) { /** * Per ECMAScript spec the range of times supported by Date objects is * exactly -100,000,000 days to +100,000,000 days measured relative to * midnight at the beginning of 01 January, 1970 UTC. * This gives a range of 8,640,000,000,000,000 milliseconds to either * side of 01 January, 1970 UTC. * * Earliest possible date: Tue, 20 Apr 271,822 B.C. 00:00:00 UTC * Latest possible date: Sat, 13 Sep 275,760 00:00:00 UTC */ return validate(value, -271822, 275760, "year"); }; $D.validateTimezone = function(value) { var timezones = {"ACDT":1,"ACST":1,"ACT":1,"ADT":1,"AEDT":1,"AEST":1,"AFT":1,"AKDT":1,"AKST":1,"AMST":1,"AMT":1,"ART":1,"AST":1,"AWDT":1,"AWST":1,"AZOST":1,"AZT":1,"BDT":1,"BIOT":1,"BIT":1,"BOT":1,"BRT":1,"BST":1,"BTT":1,"CAT":1,"CCT":1,"CDT":1,"CEDT":1,"CEST":1,"CET":1,"CHADT":1,"CHAST":1,"CHOT":1,"ChST":1,"CHUT":1,"CIST":1,"CIT":1,"CKT":1,"CLST":1,"CLT":1,"COST":1,"COT":1,"CST":1,"CT":1,"CVT":1,"CWST":1,"CXT":1,"DAVT":1,"DDUT":1,"DFT":1,"EASST":1,"EAST":1,"EAT":1,"ECT":1,"EDT":1,"EEDT":1,"EEST":1,"EET":1,"EGST":1,"EGT":1,"EIT":1,"EST":1,"FET":1,"FJT":1,"FKST":1,"FKT":1,"FNT":1,"GALT":1,"GAMT":1,"GET":1,"GFT":1,"GILT":1,"GIT":1,"GMT":1,"GST":1,"GYT":1,"HADT":1,"HAEC":1,"HAST":1,"HKT":1,"HMT":1,"HOVT":1,"HST":1,"ICT":1,"IDT":1,"IOT":1,"IRDT":1,"IRKT":1,"IRST":1,"IST":1,"JST":1,"KGT":1,"KOST":1,"KRAT":1,"KST":1,"LHST":1,"LINT":1,"MAGT":1,"MART":1,"MAWT":1,"MDT":1,"MET":1,"MEST":1,"MHT":1,"MIST":1,"MIT":1,"MMT":1,"MSK":1,"MST":1,"MUT":1,"MVT":1,"MYT":1,"NCT":1,"NDT":1,"NFT":1,"NPT":1,"NST":1,"NT":1,"NUT":1,"NZDT":1,"NZST":1,"OMST":1,"ORAT":1,"PDT":1,"PET":1,"PETT":1,"PGT":1,"PHOT":1,"PHT":1,"PKT":1,"PMDT":1,"PMST":1,"PONT":1,"PST":1,"PYST":1,"PYT":1,"RET":1,"ROTT":1,"SAKT":1,"SAMT":1,"SAST":1,"SBT":1,"SCT":1,"SGT":1,"SLST":1,"SRT":1,"SST":1,"SYOT":1,"TAHT":1,"THA":1,"TFT":1,"TJT":1,"TKT":1,"TLT":1,"TMT":1,"TOT":1,"TVT":1,"UCT":1,"ULAT":1,"UTC":1,"UYST":1,"UYT":1,"UZT":1,"VET":1,"VLAT":1,"VOLT":1,"VOST":1,"VUT":1,"WAKT":1,"WAST":1,"WAT":1,"WEDT":1,"WEST":1,"WET":1,"WST":1,"YAKT":1,"YEKT":1,"Z":1}; return (timezones[value] === 1); }; $D.validateTimezoneOffset= function(value) { // timezones go from +14hrs to -12hrs, the +X hours are negative offsets. return (value > -841 && value < 721); }; }()); (function () { var $D = Date, $P = $D.prototype, p = function (s, l) { if (!l) { l = 2; } return ("000" + s).slice(l * -1); }; var validateConfigObject = function (obj) { var result = {}, self = this, prop, testFunc; testFunc = function (prop, func, value) { if (prop === "day") { var month = (obj.month !== undefined) ? obj.month : self.getMonth(); var year = (obj.year !== undefined) ? obj.year : self.getFullYear(); return $D[func](value, year, month); } else { return $D[func](value); } }; for (prop in obj) { if (Object.prototype.hasOwnProperty.call(obj, prop)) { var func = "validate" + prop.charAt(0).toUpperCase() + prop.slice(1); if ($D[func] && obj[prop] !== null && testFunc(prop, func, obj[prop])) { result[prop] = obj[prop]; } } } return result; }; /** * Resets the time of this Date object to 12:00 AM (00:00), which is the start of the day. * @param {Boolean} .clone() this date instance before clearing Time * @return {Date} this */ $P.clearTime = function () { this.setHours(0); this.setMinutes(0); this.setSeconds(0); this.setMilliseconds(0); return this; }; /** * Resets the time of this Date object to the current time ('now'). * @return {Date} this */ $P.setTimeToNow = function () { var n = new Date(); this.setHours(n.getHours()); this.setMinutes(n.getMinutes()); this.setSeconds(n.getSeconds()); this.setMilliseconds(n.getMilliseconds()); return this; }; /** * Returns a new Date object that is an exact date and time copy of the original instance. * @return {Date} A new Date instance */ $P.clone = function () { return new Date(this.getTime()); }; /** * Compares this instance to a Date object and returns an number indication of their relative values. * @param {Date} Date object to compare [Required] * @return {Number} -1 = this is lessthan date. 0 = values are equal. 1 = this is greaterthan date. */ $P.compareTo = function (date) { return Date.compare(this, date); }; /** * Compares this instance to another Date object and returns true if they are equal. * @param {Date} Date object to compare. If no date to compare, new Date() [now] is used. * @return {Boolean} true if dates are equal. false if they are not equal. */ $P.equals = function (date) { return Date.equals(this, (date !== undefined ? date : new Date())); }; /** * Determines if this instance is between a range of two dates or equal to either the start or end dates. * @param {Date} Start of range [Required] * @param {Date} End of range [Required] * @return {Boolean} true is this is between or equal to the start and end dates, else false */ $P.between = function (start, end) { return this.getTime() >= start.getTime() && this.getTime() <= end.getTime(); }; /** * Determines if this date occurs after the date to compare to. * @param {Date} Date object to compare. If no date to compare, new Date() ("now") is used. * @return {Boolean} true if this date instance is greater than the date to compare to (or "now"), otherwise false. */ $P.isAfter = function (date) { return this.compareTo(date || new Date()) === 1; }; /** * Determines if this date occurs before the date to compare to. * @param {Date} Date object to compare. If no date to compare, new Date() ("now") is used. * @return {Boolean} true if this date instance is less than the date to compare to (or "now"). */ $P.isBefore = function (date) { return (this.compareTo(date || new Date()) === -1); }; /** * Determines if the current Date instance occurs today. * @return {Boolean} true if this date instance is 'today', otherwise false. */ /** * Determines if the current Date instance occurs on the same Date as the supplied 'date'. * If no 'date' to compare to is provided, the current Date instance is compared to 'today'. * @param {date} Date object to compare. If no date to compare, the current Date ("now") is used. * @return {Boolean} true if this Date instance occurs on the same Day as the supplied 'date'. */ $P.isToday = $P.isSameDay = function (date) { return this.clone().clearTime().equals((date || new Date()).clone().clearTime()); }; /** * Adds the specified number of milliseconds to this instance. * @param {Number} The number of milliseconds to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addMilliseconds = function (value) { if (!value) { return this; } this.setTime(this.getTime() + value * 1); return this; }; /** * Adds the specified number of seconds to this instance. * @param {Number} The number of seconds to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addSeconds = function (value) { if (!value) { return this; } return this.addMilliseconds(value * 1000); }; /** * Adds the specified number of seconds to this instance. * @param {Number} The number of seconds to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addMinutes = function (value) { if (!value) { return this; } return this.addMilliseconds(value * 60000); // 60*1000 }; /** * Adds the specified number of hours to this instance. * @param {Number} The number of hours to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addHours = function (value) { if (!value) { return this; } return this.addMilliseconds(value * 3600000); // 60*60*1000 }; /** * Adds the specified number of days to this instance. * @param {Number} The number of days to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addDays = function (value) { if (!value) { return this; } this.setDate(this.getDate() + value * 1); return this; }; /** * Adds the specified number of weekdays (ie - not sat or sun) to this instance. * @param {Number} The number of days to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addWeekdays = function (value) { if (!value) { return this; } var day = this.getDay(); var weeks = (Math.ceil(Math.abs(value)/7)); if (day === 0 || day === 6) { if (value > 0) { this.next().monday(); this.addDays(-1); day = this.getDay(); } } if (value < 0) { while (value < 0) { this.addDays(-1); day = this.getDay(); if (day !== 0 && day !== 6) { value++; } } return this; } else if (value > 5 || (6-day) <= value) { value = value + (weeks * 2); } return this.addDays(value); }; /** * Adds the specified number of weeks to this instance. * @param {Number} The number of weeks to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addWeeks = function (value) { if (!value) { return this; } return this.addDays(value * 7); }; /** * Adds the specified number of months to this instance. * @param {Number} The number of months to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addMonths = function (value) { if (!value) { return this; } var n = this.getDate(); this.setDate(1); this.setMonth(this.getMonth() + value * 1); this.setDate(Math.min(n, $D.getDaysInMonth(this.getFullYear(), this.getMonth()))); return this; }; $P.addQuarters = function (value) { if (!value) { return this; } // note this will take you to the same point in the quarter as you are now. // i.e. - if you are 15 days into the quarter you'll be 15 days into the resulting one. // bonus: this allows adding fractional quarters return this.addMonths(value * 3); }; /** * Adds the specified number of years to this instance. * @param {Number} The number of years to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addYears = function (value) { if (!value) { return this; } return this.addMonths(value * 12); }; /** * Adds (or subtracts) to the value of the years, months, weeks, days, hours, minutes, seconds, milliseconds of the date instance using given configuration object. Positive and Negative values allowed. * Example

	Date.today().add( { days: 1, months: 1 } )

	new Date().add( { years: -1 } )
	
* @param {Object} Configuration object containing attributes (months, days, etc.) * @return {Date} this */ $P.add = function (config) { if (typeof config === "number") { this._orient = config; return this; } var x = config; if (x.day) { // If we should be a different date than today (eg: for 'tomorrow -1d', etc). // Should only effect parsing, not direct usage (eg, Finish and FinishExact) if ((x.day - this.getDate()) !== 0) { this.setDate(x.day); } } if (x.milliseconds) { this.addMilliseconds(x.milliseconds); } if (x.seconds) { this.addSeconds(x.seconds); } if (x.minutes) { this.addMinutes(x.minutes); } if (x.hours) { this.addHours(x.hours); } if (x.weeks) { this.addWeeks(x.weeks); } if (x.months) { this.addMonths(x.months); } if (x.years) { this.addYears(x.years); } if (x.days) { this.addDays(x.days); } return this; }; /** * Get the week number. Week one (1) is the week which contains the first Thursday of the year. Monday is considered the first day of the week. * The .getWeek() function does NOT convert the date to UTC. The local datetime is used. * Please use .getISOWeek() to get the week of the UTC converted date. * @return {Number} 1 to 53 */ $P.getWeek = function (utc) { // Create a copy of this date object var self, target = new Date(this.valueOf()); if (utc) { target.addMinutes(target.getTimezoneOffset()); self = target.clone(); } else { self = this; } // ISO week date weeks start on monday // so correct the day number var dayNr = (self.getDay() + 6) % 7; // ISO 8601 states that week 1 is the week // with the first thursday of that year. // Set the target date to the thursday in the target week target.setDate(target.getDate() - dayNr + 3); // Store the millisecond value of the target date var firstThursday = target.valueOf(); // Set the target to the first thursday of the year // First set the target to january first target.setMonth(0, 1); // Not a thursday? Correct the date to the next thursday if (target.getDay() !== 4) { target.setMonth(0, 1 + ((4 - target.getDay()) + 7) % 7); } // The weeknumber is the number of weeks between the // first thursday of the year and the thursday in the target week return 1 + Math.ceil((firstThursday - target) / 604800000); // 604800000 = 7 * 24 * 3600 * 1000 }; /** * Get the ISO 8601 week number. Week one ("01") is the week which contains the first Thursday of the year. Monday is considered the first day of the week. * The .getISOWeek() function does convert the date to it's UTC value. Please use .getWeek() to get the week of the local date. * @return {String} "01" to "53" */ $P.getISOWeek = function () { return p(this.getWeek(true)); }; /** * Moves the date to Monday of the week set. Week one (1) is the week which contains the first Thursday of the year. * @param {Number} A Number (1 to 53) that represents the week of the year. * @return {Date} this */ $P.setWeek = function (n) { if ((n - this.getWeek()) === 0) { if (this.getDay() !== 1) { return this.moveToDayOfWeek(1, (this.getDay() > 1 ? -1 : 1)); } else { return this; } } else { return this.moveToDayOfWeek(1, (this.getDay() > 1 ? -1 : 1)).addWeeks(n - this.getWeek()); } }; $P.setQuarter = function (qtr) { var month = Math.abs(((qtr-1) * 3) + 1); return this.setMonth(month, 1); }; $P.getQuarter = function () { return Date.getQuarter(this); }; $P.getDaysLeftInQuarter = function () { return Date.getDaysLeftInQuarter(this); }; /** * Moves the date to the next n'th occurrence of the dayOfWeek starting from the beginning of the month. The number (-1) is a magic number and will return the last occurrence of the dayOfWeek in the month. * @param {Number} The dayOfWeek to move to * @param {Number} The n'th occurrence to move to. Use (-1) to return the last occurrence in the month * @return {Date} this */ $P.moveToNthOccurrence = function (dayOfWeek, occurrence) { if (dayOfWeek === "Weekday") { if (occurrence > 0) { this.moveToFirstDayOfMonth(); if (this.is().weekday()) { occurrence -= 1; } } else if (occurrence < 0) { this.moveToLastDayOfMonth(); if (this.is().weekday()) { occurrence += 1; } } else { return this; } return this.addWeekdays(occurrence); } var shift = 0; if (occurrence > 0) { shift = occurrence - 1; } else if (occurrence === -1) { this.moveToLastDayOfMonth(); if (this.getDay() !== dayOfWeek) { this.moveToDayOfWeek(dayOfWeek, -1); } return this; } return this.moveToFirstDayOfMonth().addDays(-1).moveToDayOfWeek(dayOfWeek, +1).addWeeks(shift); }; var moveToN = function (getFunc, addFunc, nVal) { return function (value, orient) { var diff = (value - this[getFunc]() + nVal * (orient || +1)) % nVal; return this[addFunc]((diff === 0) ? diff += nVal * (orient || +1) : diff); }; }; /** * Move to the next or last dayOfWeek based on the orient value. * @param {Number} The dayOfWeek to move to * @param {Number} Forward (+1) or Back (-1). Defaults to +1. [Optional] * @return {Date} this */ $P.moveToDayOfWeek = moveToN("getDay", "addDays", 7); /** * Move to the next or last month based on the orient value. * @param {Number} The month to move to. 0 = January, 11 = December * @param {Number} Forward (+1) or Back (-1). Defaults to +1. [Optional] * @return {Date} this */ $P.moveToMonth = moveToN("getMonth", "addMonths", 12); /** * Get the Ordinate of the current day ("th", "st", "rd"). * @return {String} */ $P.getOrdinate = function () { var num = this.getDate(); return ord(num); }; /** * Get the Ordinal day (numeric day number) of the year, adjusted for leap year. * @return {Number} 1 through 365 (366 in leap years) */ $P.getOrdinalNumber = function () { return Math.ceil((this.clone().clearTime() - new Date(this.getFullYear(), 0, 1)) / 86400000) + 1; }; /** * Get the time zone abbreviation of the current date. * @return {String} The abbreviated time zone name (e.g. "EST") */ $P.getTimezone = function () { return $D.getTimezoneAbbreviation(this.getUTCOffset(), this.isDaylightSavingTime()); }; $P.setTimezoneOffset = function (offset) { var here = this.getTimezoneOffset(), there = Number(offset) * -6 / 10; return (there || there === 0) ? this.addMinutes(there - here) : this; }; $P.setTimezone = function (offset) { return this.setTimezoneOffset($D.getTimezoneOffset(offset)); }; /** * Indicates whether Daylight Saving Time is observed in the current time zone. * @return {Boolean} true|false */ $P.hasDaylightSavingTime = function () { return (Date.today().set({month: 0, day: 1}).getTimezoneOffset() !== Date.today().set({month: 6, day: 1}).getTimezoneOffset()); }; /** * Indicates whether this Date instance is within the Daylight Saving Time range for the current time zone. * @return {Boolean} true|false */ $P.isDaylightSavingTime = function () { return Date.today().set({month: 0, day: 1}).getTimezoneOffset() !== this.getTimezoneOffset(); }; /** * Get the offset from UTC of the current date. * @return {String} The 4-character offset string prefixed with + or - (e.g. "-0500") */ $P.getUTCOffset = function (offset) { var n = (offset || this.getTimezoneOffset()) * -10 / 6, r; if (n < 0) { r = (n - 10000).toString(); return r.charAt(0) + r.substr(2); } else { r = (n + 10000).toString(); return "+" + r.substr(1); } }; /** * Returns the number of milliseconds between this date and date. * @param {Date} Defaults to now * @return {Number} The diff in milliseconds */ $P.getElapsed = function (date) { return (date || new Date()) - this; }; /** * Set the value of year, month, day, hour, minute, second, millisecond of date instance using given configuration object. * Example

	Date.today().set( { day: 20, month: 1 } )

	new Date().set( { millisecond: 0 } )
	
* * @param {Object} Configuration object containing attributes (month, day, etc.) * @return {Date} this */ $P.set = function (config) { config = validateConfigObject.call(this, config); var key; for (key in config) { if (Object.prototype.hasOwnProperty.call(config, key)) { var name = key.charAt(0).toUpperCase() + key.slice(1); var addFunc, getFunc; if (key !== "week" && key !== "month" && key !== "timezone" && key !== "timezoneOffset") { name += "s"; } addFunc = "add" + name; getFunc = "get" + name; if (key === "month") { addFunc = addFunc + "s"; } else if (key === "year"){ getFunc = "getFullYear"; } if (key !== "day" && key !== "timezone" && key !== "timezoneOffset" && key !== "week" && key !== "hour") { this[addFunc](config[key] - this[getFunc]()); } else if ( key === "timezone"|| key === "timezoneOffset" || key === "week" || key === "hour") { this["set"+name](config[key]); } } } // day has to go last because you can't validate the day without first knowing the month if (config.day) { this.addDays(config.day - this.getDate()); } return this; }; /** * Moves the date to the first day of the month. * @return {Date} this */ $P.moveToFirstDayOfMonth = function () { return this.set({ day: 1 }); }; /** * Moves the date to the last day of the month. * @return {Date} this */ $P.moveToLastDayOfMonth = function () { return this.set({ day: $D.getDaysInMonth(this.getFullYear(), this.getMonth())}); }; /** * Converts the value of the current Date object to its equivalent string representation. * Format Specifiers * CUSTOM DATE AND TIME FORMAT STRINGS * Format Description Example * ------ --------------------------------------------------------------------------- ----------------------- * s The seconds of the minute between 0-59. "0" to "59" * ss The seconds of the minute with leading zero if required. "00" to "59" * * m The minute of the hour between 0-59. "0" or "59" * mm The minute of the hour with leading zero if required. "00" or "59" * * h The hour of the day between 1-12. "1" to "12" * hh The hour of the day with leading zero if required. "01" to "12" * * H The hour of the day between 0-23. "0" to "23" * HH The hour of the day with leading zero if required. "00" to "23" * * d The day of the month between 1 and 31. "1" to "31" * dd The day of the month with leading zero if required. "01" to "31" * ddd Abbreviated day name. Date.CultureInfo.abbreviatedDayNames. "Mon" to "Sun" * dddd The full day name. Date.CultureInfo.dayNames. "Monday" to "Sunday" * * M The month of the year between 1-12. "1" to "12" * MM The month of the year with leading zero if required. "01" to "12" * MMM Abbreviated month name. Date.CultureInfo.abbreviatedMonthNames. "Jan" to "Dec" * MMMM The full month name. Date.CultureInfo.monthNames. "January" to "December" * * yy The year as a two-digit number. "99" or "08" * yyyy The full four digit year. "1999" or "2008" * * t Displays the first character of the A.M./P.M. designator. "A" or "P" * Date.CultureInfo.amDesignator or Date.CultureInfo.pmDesignator * tt Displays the A.M./P.M. designator. "AM" or "PM" * Date.CultureInfo.amDesignator or Date.CultureInfo.pmDesignator * * S The ordinal suffix ("st, "nd", "rd" or "th") of the current day. "st, "nd", "rd" or "th" * * STANDARD DATE AND TIME FORMAT STRINGS * Format Description Example *------ --------------------------------------------------------------------------- ----------------------- * d The CultureInfo shortDate Format Pattern "M/d/yyyy" * D The CultureInfo longDate Format Pattern "dddd, MMMM dd, yyyy" * F The CultureInfo fullDateTime Format Pattern "dddd, MMMM dd, yyyy h:mm:ss tt" * m The CultureInfo monthDay Format Pattern "MMMM dd" * r The CultureInfo rfc1123 Format Pattern "ddd, dd MMM yyyy HH:mm:ss GMT" * s The CultureInfo sortableDateTime Format Pattern "yyyy-MM-ddTHH:mm:ss" * t The CultureInfo shortTime Format Pattern "h:mm tt" * T The CultureInfo longTime Format Pattern "h:mm:ss tt" * u The CultureInfo universalSortableDateTime Format Pattern "yyyy-MM-dd HH:mm:ssZ" * y The CultureInfo yearMonth Format Pattern "MMMM, yyyy" * * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @return {String} A string representation of the current Date object. */ var ord = function (n) { switch (n * 1) { case 1: case 21: case 31: return "st"; case 2: case 22: return "nd"; case 3: case 23: return "rd"; default: return "th"; } }; var parseStandardFormats = function (format) { var y, c = Date.CultureInfo.formatPatterns; switch (format) { case "d": return this.toString(c.shortDate); case "D": return this.toString(c.longDate); case "F": return this.toString(c.fullDateTime); case "m": return this.toString(c.monthDay); case "r": case "R": y = this.clone().addMinutes(this.getTimezoneOffset()); return y.toString(c.rfc1123) + " GMT"; case "s": return this.toString(c.sortableDateTime); case "t": return this.toString(c.shortTime); case "T": return this.toString(c.longTime); case "u": y = this.clone().addMinutes(this.getTimezoneOffset()); return y.toString(c.universalSortableDateTime); case "y": return this.toString(c.yearMonth); default: return false; } }; var parseFormatStringsClosure = function (context) { return function (m) { if (m.charAt(0) === "\\") { return m.replace("\\", ""); } switch (m) { case "hh": return p(context.getHours() < 13 ? (context.getHours() === 0 ? 12 : context.getHours()) : (context.getHours() - 12)); case "h": return context.getHours() < 13 ? (context.getHours() === 0 ? 12 : context.getHours()) : (context.getHours() - 12); case "HH": return p(context.getHours()); case "H": return context.getHours(); case "mm": return p(context.getMinutes()); case "m": return context.getMinutes(); case "ss": return p(context.getSeconds()); case "s": return context.getSeconds(); case "yyyy": return p(context.getFullYear(), 4); case "yy": return p(context.getFullYear()); case "y": return context.getFullYear(); case "E": case "dddd": return Date.CultureInfo.dayNames[context.getDay()]; case "ddd": return Date.CultureInfo.abbreviatedDayNames[context.getDay()]; case "dd": return p(context.getDate()); case "d": return context.getDate(); case "MMMM": return Date.CultureInfo.monthNames[context.getMonth()]; case "MMM": return Date.CultureInfo.abbreviatedMonthNames[context.getMonth()]; case "MM": return p((context.getMonth() + 1)); case "M": return context.getMonth() + 1; case "t": return context.getHours() < 12 ? Date.CultureInfo.amDesignator.substring(0, 1) : Date.CultureInfo.pmDesignator.substring(0, 1); case "tt": return context.getHours() < 12 ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator; case "S": return ord(context.getDate()); case "W": return context.getWeek(); case "WW": return context.getISOWeek(); case "Q": return "Q" + context.getQuarter(); case "q": return String(context.getQuarter()); case "z": return context.getTimezone(); case "Z": case "X": return Date.getTimezoneOffset(context.getTimezone()); case "ZZ": // Timezone offset in seconds return context.getTimezoneOffset() * -60; case "u": return context.getDay(); case "L": return ($D.isLeapYear(context.getFullYear())) ? 1 : 0; case "B": // Swatch Internet Time (.beats) return "@"+((context.getUTCSeconds() + (context.getUTCMinutes()*60) + ((context.getUTCHours()+1)*3600))/86.4); default: return m; } }; }; $P.toString = function (format, ignoreStandards) { // Standard Date and Time Format Strings. Formats pulled from CultureInfo file and // may vary by culture. if (!ignoreStandards && format && format.length === 1) { output = parseStandardFormats.call(this, format); if (output) { return output; } } var parseFormatStrings = parseFormatStringsClosure(this); return format ? format.replace(/((\\)?(dd?d?d?|MM?M?M?|yy?y?y?|hh?|HH?|mm?|ss?|tt?|S|q|Q|WW?W?W?)(?![^\[]*\]))/g, parseFormatStrings).replace(/\[|\]/g, "") : this._toString(); }; }()); /************************************************************* * SugarPak - Domain Specific Language - Syntactical Sugar * *************************************************************/ (function () { var $D = Date, $P = $D.prototype, $N = Number.prototype; // private $P._orient = +1; // private $P._nth = null; // private $P._is = false; // private $P._same = false; // private $P._isSecond = false; // private $N._dateElement = "days"; /** * Moves the date to the next instance of a date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.today().next().friday();
	Date.today().next().fri();
	Date.today().next().march();
	Date.today().next().mar();
	Date.today().next().week();
	
* * @return {Date} date */ $P.next = function () { this._move = true; this._orient = +1; return this; }; /** * Creates a new Date (Date.today()) and moves the date to the next instance of the date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.next().friday();
	Date.next().fri();
	Date.next().march();
	Date.next().mar();
	Date.next().week();
	
* * @return {Date} date */ $D.next = function () { return $D.today().next(); }; /** * Moves the date to the previous instance of a date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.today().last().friday();
	Date.today().last().fri();
	Date.today().last().march();
	Date.today().last().mar();
	Date.today().last().week();
	
* * @return {Date} date */ $P.last = $P.prev = $P.previous = function () { this._move = true; this._orient = -1; return this; }; /** * Creates a new Date (Date.today()) and moves the date to the previous instance of the date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.last().friday();
	Date.last().fri();
	Date.previous().march();
	Date.prev().mar();
	Date.last().week();
	
* * @return {Date} date */ $D.last = $D.prev = $D.previous = function () { return $D.today().last(); }; /** * Performs a equality check when followed by either a month name, day name or .weekday() function. * Example

	Date.today().is().friday(); // true|false
	Date.today().is().fri();
	Date.today().is().march();
	Date.today().is().mar();
	
* * @return {Boolean} true|false */ $P.is = function () { this._is = true; return this; }; /** * Determines if two date objects occur on/in exactly the same instance of the subsequent date part function. * The function .same() must be followed by a date part function (example: .day(), .month(), .year(), etc). * * An optional Date can be passed in the date part function. If now date is passed as a parameter, 'Now' is used. * * The following example demonstrates how to determine if two dates fall on the exact same day. * * Example

	var d1 = Date.today(); // today at 00:00
	var d2 = new Date();   // exactly now.

	// Do they occur on the same day?
	d1.same().day(d2); // true
	
	// Do they occur on the same hour?
	d1.same().hour(d2); // false, unless d2 hour is '00' (midnight).
	
	// What if it's the same day, but one year apart?
	var nextYear = Date.today().add(1).year();

	d1.same().day(nextYear); // false, because the dates must occur on the exact same day. 
	
* * Scenario: Determine if a given date occurs during some week period 2 months from now. * * Example

	var future = Date.today().add(2).months();
	return someDate.same().week(future); // true|false;
	
* * @return {Boolean} true|false */ $P.same = function () { this._same = true; this._isSecond = false; return this; }; /** * Determines if the current date/time occurs during Today. Must be preceded by the .is() function. * Example

	someDate.is().today();    // true|false
	new Date().is().today();  // true
	Date.today().is().today();// true
	Date.today().add(-1).day().is().today(); // false
	
* * @return {Boolean} true|false */ $P.today = function () { return this.same().day(); }; /** * Determines if the current date is a weekday. This function must be preceded by the .is() function. * Example

	Date.today().is().weekday(); // true|false
	
* * @return {Boolean} true|false */ $P.weekday = function () { if (this._nth) { return df("Weekday").call(this); } if (this._move) { return this.addWeekdays(this._orient); } if (this._is) { this._is = false; return (!this.is().sat() && !this.is().sun()); } return false; }; /** * Determines if the current date is on the weekend. This function must be preceded by the .is() function. * Example

	Date.today().is().weekend(); // true|false
	
* * @return {Boolean} true|false */ $P.weekend = function () { if (this._is) { this._is = false; return (this.is().sat() || this.is().sun()); } return false; }; /** * Sets the Time of the current Date instance. A string "6:15 pm" or config object {hour:18, minute:15} are accepted. * Example

	// Set time to 6:15pm with a String
	Date.today().at("6:15pm");

	// Set time to 6:15pm with a config object
	Date.today().at({hour:18, minute:15});
	
* * @return {Date} date */ $P.at = function (time) { return (typeof time === "string") ? $D.parse(this.toString("d") + " " + time) : this.set(time); }; /** * Creates a new Date() and adds this (Number) to the date based on the preceding date element function (eg. second|minute|hour|day|month|year). * Example

	// Undeclared Numbers must be wrapped with parentheses. Requirment of JavaScript.
	(3).days().fromNow();
	(6).months().fromNow();

	// Declared Number variables do not require parentheses. 
	var n = 6;
	n.months().fromNow();
	
* * @return {Date} A new Date instance */ $N.fromNow = $N.after = function (date) { var c = {}; c[this._dateElement] = this; return ((!date) ? new Date() : date.clone()).add(c); }; /** * Creates a new Date() and subtract this (Number) from the date based on the preceding date element function (eg. second|minute|hour|day|month|year). * Example

	// Undeclared Numbers must be wrapped with parentheses. Requirment of JavaScript.
	(3).days().ago();
	(6).months().ago();

	// Declared Number variables do not require parentheses. 
	var n = 6;
	n.months().ago();
	
* * @return {Date} A new Date instance */ $N.ago = $N.before = function (date) { var c = {}, s = (this._dateElement[this._dateElement.length-1] !== "s") ? this._dateElement + "s" : this._dateElement; c[s] = this * -1; return ((!date) ? new Date() : date.clone()).add(c); }; // Do NOT modify the following string tokens. These tokens are used to build dynamic functions. // All culture-specific strings can be found in the CultureInfo files. var dx = ("sunday monday tuesday wednesday thursday friday saturday").split(/\s/), mx = ("january february march april may june july august september october november december").split(/\s/), px = ("Millisecond Second Minute Hour Day Week Month Year Quarter Weekday").split(/\s/), pxf = ("Milliseconds Seconds Minutes Hours Date Week Month FullYear Quarter").split(/\s/), nth = ("final first second third fourth fifth").split(/\s/), de; /** * Returns an object literal of all the date parts. * Example

	var o = new Date().toObject();
	
	// { year: 2008, month: 4, week: 20, day: 13, hour: 18, minute: 9, second: 32, millisecond: 812 }
	
	// The object properties can be referenced directly from the object.
	
	alert(o.day);  // alerts "13"
	alert(o.year); // alerts "2008"
	
* * @return {Date} An object literal representing the original date object. */ $P.toObject = function () { var o = {}; for (var i = 0; i < px.length; i++) { if (this["get" + pxf[i]]) { o[px[i].toLowerCase()] = this["get" + pxf[i]](); } } return o; }; /** * Returns a date created from an object literal. Ignores the .week property if set in the config. * Example

	var o = new Date().toObject();
	
	return Date.fromObject(o); // will return the same date. 

	var o2 = {month: 1, day: 20, hour: 18}; // birthday party!
	Date.fromObject(o2);
	
* * @return {Date} An object literal representing the original date object. */ $D.fromObject = function(config) { config.week = null; return Date.today().set(config); }; // Create day name functions and abbreviated day name functions (eg. monday(), friday(), fri()). var df = function (n) { return function () { if (this._is) { this._is = false; return this.getDay() === n; } if (this._move) { this._move = null; } if (this._nth !== null) { // If the .second() function was called earlier, remove the _orient // from the date, and then continue. // This is required because 'second' can be used in two different context. // // Example // // Date.today().add(1).second(); // Date.march().second().monday(); // // Things get crazy with the following... // Date.march().add(1).second().second().monday(); // but it works!! // if (this._isSecond) { this.addSeconds(this._orient * -1); } // make sure we reset _isSecond this._isSecond = false; var ntemp = this._nth; this._nth = null; var temp = this.clone().moveToLastDayOfMonth(); this.moveToNthOccurrence(n, ntemp); if (this > temp) { throw new RangeError($D.getDayName(n) + " does not occur " + ntemp + " times in the month of " + $D.getMonthName(temp.getMonth()) + " " + temp.getFullYear() + "."); } return this; } return this.moveToDayOfWeek(n, this._orient); }; }; var sdf = function (n) { return function () { var t = $D.today(), shift = n - t.getDay(); if (n === 0 && Date.CultureInfo.firstDayOfWeek === 1 && t.getDay() !== 0) { shift = shift + 7; } return t.addDays(shift); }; }; // Create month name functions and abbreviated month name functions (eg. january(), march(), mar()). var month_instance_functions = function (n) { return function () { if (this._is) { this._is = false; return this.getMonth() === n; } return this.moveToMonth(n, this._orient); }; }; var month_static_functions = function (n) { return function () { return $D.today().set({ month: n, day: 1 }); }; }; var processTerms = function (names, staticFunc, instanceFunc) { for (var i = 0; i < names.length; i++) { // Create constant static Name variables. $D[names[i].toUpperCase()] = $D[names[i].toUpperCase().substring(0, 3)] = i; // Create Name functions. $D[names[i]] = $D[names[i].substring(0, 3)] = staticFunc(i); // Create Name instance functions. $P[names[i]] = $P[names[i].substring(0, 3)] = instanceFunc(i); } }; processTerms(dx, sdf, df); processTerms(mx, month_static_functions, month_instance_functions); // Create date element functions and plural date element functions used with Date (eg. day(), days(), months()). var ef = function (j) { return function () { // if the .second() function was called earlier, the _orient // has alread been added. Just return this and reset _isSecond. if (this._isSecond) { this._isSecond = false; return this; } if (this._same) { this._same = this._is = false; var o1 = this.toObject(), o2 = (arguments[0] || new Date()).toObject(), v = "", k = j.toLowerCase(); // the substr trick with -1 doesn't work in IE8 or less k = (k[k.length-1] === "s") ? k.substring(0,k.length-1) : k; for (var m = (px.length - 1); m > -1; m--) { v = px[m].toLowerCase(); if (o1[v] !== o2[v]) { return false; } if (k === v) { break; } } return true; } if (j.substring(j.length - 1) !== "s") { j += "s"; } if (this._move) { this._move = null; } return this["add" + j](this._orient); }; }; var nf = function (n) { return function () { this._dateElement = n; return this; }; }; for (var k = 0; k < px.length; k++) { de = px[k].toLowerCase(); if(de !== "weekday") { // Create date element functions and plural date element functions used with Date (eg. day(), days(), months()). $P[de] = $P[de + "s"] = ef(px[k]); // Create date element functions and plural date element functions used with Number (eg. day(), days(), months()). $N[de] = $N[de + "s"] = nf(de + "s"); } } $P._ss = ef("Second"); var nthfn = function (n) { return function (dayOfWeek) { if (this._same) { return this._ss(arguments[0]); } if (dayOfWeek || dayOfWeek === 0) { return this.moveToNthOccurrence(dayOfWeek, n); } this._nth = n; // if the operator is 'second' add the _orient, then deal with it later... if (n === 2 && (dayOfWeek === undefined || dayOfWeek === null)) { this._isSecond = true; return this.addSeconds(this._orient); } return this; }; }; for (var l = 0; l < nth.length; l++) { $P[nth[l]] = (l === 0) ? nthfn(-1) : nthfn(l); } }()); (function () { "use strict"; Date.Parsing = { Exception: function (s) { this.message = "Parse error at '" + s.substring(0, 10) + " ...'"; } }; var $P = Date.Parsing; var dayOffsets = { standard: [0,31,59,90,120,151,181,212,243,273,304,334], leap: [0,31,60,91,121,152,182,213,244,274,305,335] }; $P.isLeapYear = function(year) { return ((year % 4 === 0) && (year % 100 !== 0)) || (year % 400 === 0); }; var utils = { multiReplace : function (str, hash ) { var key; for (key in hash) { if (Object.prototype.hasOwnProperty.call(hash, key)) { var regex; if (typeof hash[key] === "function") { } else { regex = (hash[key] instanceof RegExp) ? hash[key] : new RegExp(hash[key], "g"); } str = str.replace(regex, key); } } return str; }, getDayOfYearFromWeek : function (obj) { var d, jan4, offset; obj.weekDay = (!obj.weekDay && obj.weekDay !== 0) ? 1 : obj.weekDay; d = new Date(obj.year, 0, 4); jan4 = d.getDay() === 0 ? 7 : d.getDay(); // JS is 0 indexed on Sunday. offset = jan4+3; obj.dayOfYear = ((obj.week * 7) + (obj.weekDay === 0 ? 7 : obj.weekDay))-offset; return obj; }, getDayOfYear : function (obj, dayOffset) { if (!obj.dayOfYear) { obj = utils.getDayOfYearFromWeek(obj); } for (var i=0;i <= dayOffset.length;i++) { if (obj.dayOfYear < dayOffset[i] || i === dayOffset.length) { obj.day = obj.day ? obj.day : (obj.dayOfYear - dayOffset[i-1]); break; } else { obj.month = i; } } return obj; }, adjustForTimeZone : function (obj, date) { var offset; if (obj.zone.toUpperCase() === "Z" || (obj.zone_hours === 0 && obj.zone_minutes === 0)) { // it's UTC/GML so work out the current timeszone offset offset = -date.getTimezoneOffset(); } else { offset = (obj.zone_hours*60) + (obj.zone_minutes || 0); if (obj.zone_sign === "+") { offset *= -1; } offset -= date.getTimezoneOffset(); } date.setMinutes(date.getMinutes()+offset); return date; }, setDefaults : function (obj) { obj.year = obj.year || Date.today().getFullYear(); obj.hours = obj.hours || 0; obj.minutes = obj.minutes || 0; obj.seconds = obj.seconds || 0; obj.milliseconds = obj.milliseconds || 0; if (!(!obj.month && (obj.week || obj.dayOfYear))) { // if we have a month, or if we don't but don't have the day calculation data obj.month = obj.month || 0; obj.day = obj.day || 1; } return obj; }, dataNum: function (data, mod, explict, postProcess) { var dataNum = data*1; if (mod) { if (postProcess) { return data ? mod(data)*1 : data; } else { return data ? mod(dataNum) : data; } } else if (!explict){ return data ? dataNum : data; } else { return (data && typeof data !== "undefined") ? dataNum : data; } }, timeDataProcess: function (obj) { var timeObj = {}; for (var x in obj.data) { if (obj.data.hasOwnProperty(x)) { timeObj[x] = obj.ignore[x] ? obj.data[x] : utils.dataNum(obj.data[x], obj.mods[x], obj.explict[x], obj.postProcess[x]); } } if (obj.data.secmins) { obj.data.secmins = obj.data.secmins.replace(",", ".") * 60; if (!timeObj.minutes) { timeObj.minutes = obj.data.secmins; } else if (!timeObj.seconds) { timeObj.seconds = obj.data.secmins; } delete obj.secmins; } return timeObj; }, buildTimeObjectFromData: function (data) { var time = utils.timeDataProcess({ data: { year : data[1], month : data[5], day : data[7], week : data[8], dayOfYear : data[10], hours : data[15], zone_hours : data[23], zone_minutes : data[24], zone : data[21], zone_sign : data[22], weekDay : data[9], minutes: data[16], seconds: data[19], milliseconds: data[20], secmins: data[18] }, mods: { month: function(data) { return data-1; }, weekDay: function (data) { data = Math.abs(data); return (data === 7 ? 0 : data); }, minutes: function (data) { return data.replace(":",""); }, seconds: function (data) { return Math.floor( (data.replace(":","").replace(",","."))*1 ); }, milliseconds: function (data) { return (data.replace(",",".")*1000); } }, postProcess: { minutes: true, seconds: true, milliseconds: true }, explict: { zone_hours: true, zone_minutes: true }, ignore: { zone: true, zone_sign: true, secmins: true } }); return time; }, addToHash: function (hash, keys, data) { keys = keys; data = data; var len = keys.length; for (var i = 0; i < len; i++) { hash[keys[i]] = data[i]; } return hash; }, combineRegex: function (r1, r2) { return new RegExp("(("+r1.source+")\\s("+r2.source+"))"); }, getDateNthString: function(add, last, inc){ if (add) { return Date.today().addDays(inc).toString("d"); } else if (last) { return Date.today().last()[inc]().toString("d"); } }, buildRegexData: function (array) { var arr = []; var len = array.length; for (var i=0; i < len; i++) { if (Object.prototype.toString.call(array[i]) === '[object Array]') { // oldIE compat version of Array.isArray arr.push(this.combineRegex(array[i][0], array[i][1])); } else { arr.push(array[i]); } } return arr; } }; $P.processTimeObject = function (obj) { var date, dayOffset; utils.setDefaults(obj); dayOffset = ($P.isLeapYear(obj.year)) ? dayOffsets.leap : dayOffsets.standard; if (!obj.month && (obj.week || obj.dayOfYear)) { utils.getDayOfYear(obj, dayOffset); } else { obj.dayOfYear = dayOffset[obj.month] + obj.day; } date = new Date(obj.year, obj.month, obj.day, obj.hours, obj.minutes, obj.seconds, obj.milliseconds); if (obj.zone) { utils.adjustForTimeZone(obj, date); // adjust (and calculate) for timezone } return date; }; $P.ISO = { regex : /^([\+-]?\d{4}(?!\d{2}\b))((-?)((0[1-9]|1[0-2])(\3([12]\d|0[1-9]|3[01]))?|W([0-4]\d|5[0-3])(-?[1-7])?|(00[1-9]|0[1-9]\d|[12]\d{2}|3([0-5]\d|6[1-6])))([T\s]((([01]\d|2[0-4])((:?)[0-5]\d)?|24\:?00)([\.,]\d+(?!:))?)?(\17[0-5]\d([\.,]\d+)?)?\s?([zZ]|([\+-])([01]\d|2[0-3]):?([0-5]\d)?)?)?)?$/, parse : function (s) { var time, data = s.match(this.regex); if (!data || !data.length) { return null; } time = utils.buildTimeObjectFromData(data); if (!time.year || (!time.year && (!time.month && !time.day) && (!time.week && !time.dayOfYear)) ) { return null; } return $P.processTimeObject(time); } }; $P.Numeric = { isNumeric: function (e){return!isNaN(parseFloat(e))&&isFinite(e);}, regex: /\b([0-1]?[0-9])([0-3]?[0-9])([0-2]?[0-9]?[0-9][0-9])\b/i, parse: function (s) { var data, i, time = {}, order = Date.CultureInfo.dateElementOrder.split(""); if (!(this.isNumeric(s)) || // if it's non-numeric OR (s[0] === "+" && s[0] === "-")) { // It's an arithmatic string (eg +/-1000) return null; } if (s.length < 5 && s.indexOf(".") < 0 && s.indexOf("/") < 0) { // assume it's just a year. time.year = s; return $P.processTimeObject(time); } data = s.match(this.regex); if (!data || !data.length) { return null; } for (i=0; i < order.length; i++) { switch(order[i]) { case "d": time.day = data[i+1]; break; case "m": time.month = (data[i+1]-1); break; case "y": time.year = data[i+1]; break; } } return $P.processTimeObject(time); } }; $P.Normalizer = { regexData: function () { var $R = Date.CultureInfo.regexPatterns; return utils.buildRegexData([ $R.tomorrow, $R.yesterday, [$R.past, $R.mon], [$R.past, $R.tue], [$R.past, $R.wed], [$R.past, $R.thu], [$R.past, $R.fri], [$R.past, $R.sat], [$R.past, $R.sun] ]); }, basicReplaceHash : function() { var $R = Date.CultureInfo.regexPatterns; return { "January": $R.jan.source, "February": $R.feb, "March": $R.mar, "April": $R.apr, "May": $R.may, "June": $R.jun, "July": $R.jul, "August": $R.aug, "September": $R.sep, "October": $R.oct, "November": $R.nov, "December": $R.dec, "": /\bat\b/gi, " ": /\s{2,}/, "am": $R.inTheMorning, "9am": $R.thisMorning, "pm": $R.inTheEvening, "7pm":$R.thisEvening }; }, keys : function(){ return [ utils.getDateNthString(true, false, 1), // tomorrow utils.getDateNthString(true, false, -1), // yesterday utils.getDateNthString(false, true, "monday"), //last mon utils.getDateNthString(false, true, "tuesday"), //last tues utils.getDateNthString(false, true, "wednesday"), //last wed utils.getDateNthString(false, true, "thursday"), //last thurs utils.getDateNthString(false, true, "friday"), //last fri utils.getDateNthString(false, true, "saturday"), //last sat utils.getDateNthString(false, true, "sunday") //last sun ]; }, buildRegexFunctions: function () { var $R = Date.CultureInfo.regexPatterns; var __ = Date.i18n.__; var tomorrowRE = new RegExp("(\\b\\d\\d?("+__("AM")+"|"+__("PM")+")? )("+$R.tomorrow.source.slice(1)+")", "i"); // adapted tomorrow regex for AM PM relative dates var todayRE = new RegExp($R.today.source + "(?!\\s*([+-]))\\b"); // today, but excludes the math operators (eg "today + 2h") this.replaceFuncs = [ [todayRE, function (full) { return (full.length > 1) ? Date.today().toString("d") : full; }], [tomorrowRE, function(full, m1) { var t = Date.today().addDays(1).toString("d"); return (t + " " + m1); }], [$R.amThisMorning, function(str, am){return am;}], [$R.pmThisEvening, function(str, pm){return pm;}] ]; }, buildReplaceData: function () { this.buildRegexFunctions(); this.replaceHash = utils.addToHash(this.basicReplaceHash(), this.keys(), this.regexData()); }, stringReplaceFuncs: function (s) { for (var i=0; i < this.replaceFuncs.length; i++) { s = s.replace(this.replaceFuncs[i][0], this.replaceFuncs[i][1]); } return s; }, parse: function (s) { s = this.stringReplaceFuncs(s); s = utils.multiReplace(s, this.replaceHash); try { var n = s.split(/([\s\-\.\,\/\x27]+)/); if (n.length === 3 && $P.Numeric.isNumeric(n[0]) && $P.Numeric.isNumeric(n[2]) && (n[2].length >= 4)) { // ok, so we're dealing with x/year. But that's not a full date. // This fixes wonky dateElementOrder parsing when set to dmy order. if (Date.CultureInfo.dateElementOrder[0] === "d") { s = "1/" + n[0] + "/" + n[2]; // set to 1st of month and normalize the seperator } } } catch (e) {} return s; } }; $P.Normalizer.buildReplaceData(); }()); (function () { var $P = Date.Parsing; var _ = $P.Operators = { // // Tokenizers // rtoken: function (r) { // regex token return function (s) { var mx = s.match(r); if (mx) { return ([ mx[0], s.substring(mx[0].length) ]); } else { throw new $P.Exception(s); } }; }, token: function () { // whitespace-eating token return function (s) { return _.rtoken(new RegExp("^\\s*" + s + "\\s*"))(s); }; }, stoken: function (s) { // string token return _.rtoken(new RegExp("^" + s)); }, // Atomic Operators until: function (p) { return function (s) { var qx = [], rx = null; while (s.length) { try { rx = p.call(this, s); } catch (e) { qx.push(rx[0]); s = rx[1]; continue; } break; } return [ qx, s ]; }; }, many: function (p) { return function (s) { var rx = [], r = null; while (s.length) { try { r = p.call(this, s); } catch (e) { return [ rx, s ]; } rx.push(r[0]); s = r[1]; } return [ rx, s ]; }; }, // generator operators -- see below optional: function (p) { return function (s) { var r = null; try { r = p.call(this, s); } catch (e) { return [ null, s ]; } return [ r[0], r[1] ]; }; }, not: function (p) { return function (s) { try { p.call(this, s); } catch (e) { return [null, s]; } throw new $P.Exception(s); }; }, ignore: function (p) { return p ? function (s) { var r = null; r = p.call(this, s); return [null, r[1]]; } : null; }, product: function () { var px = arguments[0], qx = Array.prototype.slice.call(arguments, 1), rx = []; for (var i = 0 ; i < px.length ; i++) { rx.push(_.each(px[i], qx)); } return rx; }, cache: function (rule) { var cache = {}, cache_length = 0, cache_keys = [], CACHE_MAX = Date.Config.CACHE_MAX || 100000, r = null; var cacheCheck = function () { if (cache_length === CACHE_MAX) { // kill several keys, don't want to have to do this all the time... for (var i=0; i < 10; i++) { var key = cache_keys.shift(); if (key) { delete cache[key]; cache_length--; } } } }; return function (s) { cacheCheck(); try { r = cache[s] = (cache[s] || rule.call(this, s)); } catch (e) { r = cache[s] = e; } cache_length++; cache_keys.push(s); if (r instanceof $P.Exception) { throw r; } else { return r; } }; }, // vector operators -- see below any: function () { var px = arguments; return function (s) { var r = null; for (var i = 0; i < px.length; i++) { if (px[i] == null) { continue; } try { r = (px[i].call(this, s)); } catch (e) { r = null; } if (r) { return r; } } throw new $P.Exception(s); }; }, each: function () { var px = arguments; return function (s) { var rx = [], r = null; for (var i = 0; i < px.length ; i++) { if (px[i] == null) { continue; } try { r = (px[i].call(this, s)); } catch (e) { throw new $P.Exception(s); } rx.push(r[0]); s = r[1]; } return [ rx, s]; }; }, all: function () { var px = arguments, _ = _; return _.each(_.optional(px)); }, // delimited operators sequence: function (px, d, c) { d = d || _.rtoken(/^\s*/); c = c || null; if (px.length === 1) { return px[0]; } return function (s) { var r = null, q = null; var rx = []; for (var i = 0; i < px.length ; i++) { try { r = px[i].call(this, s); } catch (e) { break; } rx.push(r[0]); try { q = d.call(this, r[1]); } catch (ex) { q = null; break; } s = q[1]; } if (!r) { throw new $P.Exception(s); } if (q) { throw new $P.Exception(q[1]); } if (c) { try { r = c.call(this, r[1]); } catch (ey) { throw new $P.Exception(r[1]); } } return [ rx, (r?r[1]:s) ]; }; }, // // Composite Operators // between: function (d1, p, d2) { d2 = d2 || d1; var _fn = _.each(_.ignore(d1), p, _.ignore(d2)); return function (s) { var rx = _fn.call(this, s); return [[rx[0][0], r[0][2]], rx[1]]; }; }, list: function (p, d, c) { d = d || _.rtoken(/^\s*/); c = c || null; return (p instanceof Array ? _.each(_.product(p.slice(0, -1), _.ignore(d)), p.slice(-1), _.ignore(c)) : _.each(_.many(_.each(p, _.ignore(d))), px, _.ignore(c))); }, set: function (px, d, c) { d = d || _.rtoken(/^\s*/); c = c || null; return function (s) { // r is the current match, best the current 'best' match // which means it parsed the most amount of input var r = null, p = null, q = null, rx = null, best = [[], s], last = false; // go through the rules in the given set for (var i = 0; i < px.length ; i++) { // last is a flag indicating whether this must be the last element // if there is only 1 element, then it MUST be the last one q = null; p = null; r = null; last = (px.length === 1); // first, we try simply to match the current pattern // if not, try the next pattern try { r = px[i].call(this, s); } catch (e) { continue; } // since we are matching against a set of elements, the first // thing to do is to add r[0] to matched elements rx = [[r[0]], r[1]]; // if we matched and there is still input to parse and // we don't already know this is the last element, // we're going to next check for the delimiter ... // if there's none, or if there's no input left to parse // than this must be the last element after all ... if (r[1].length > 0 && ! last) { try { q = d.call(this, r[1]); } catch (ex) { last = true; } } else { last = true; } // if we parsed the delimiter and now there's no more input, // that means we shouldn't have parsed the delimiter at all // so don't update r and mark this as the last element ... if (!last && q[1].length === 0) { last = true; } // so, if this isn't the last element, we're going to see if // we can get any more matches from the remaining (unmatched) // elements ... if (!last) { // build a list of the remaining rules we can match against, // i.e., all but the one we just matched against var qx = []; for (var j = 0; j < px.length ; j++) { if (i !== j) { qx.push(px[j]); } } // now invoke recursively set with the remaining input // note that we don't include the closing delimiter ... // we'll check for that ourselves at the end p = _.set(qx, d).call(this, q[1]); // if we got a non-empty set as a result ... // (otw rx already contains everything we want to match) if (p[0].length > 0) { // update current result, which is stored in rx ... // basically, pick up the remaining text from p[1] // and concat the result from p[0] so that we don't // get endless nesting ... rx[0] = rx[0].concat(p[0]); rx[1] = p[1]; } } // at this point, rx either contains the last matched element // or the entire matched set that starts with this element. // now we just check to see if this variation is better than // our best so far, in terms of how much of the input is parsed if (rx[1].length < best[1].length) { best = rx; } // if we've parsed all the input, then we're finished if (best[1].length === 0) { break; } } // so now we've either gone through all the patterns trying them // as the initial match; or we found one that parsed the entire // input string ... // if best has no matches, just return empty set ... if (best[0].length === 0) { return best; } // if a closing delimiter is provided, then we have to check it also if (c) { // we try this even if there is no remaining input because the pattern // may well be optional or match empty input ... try { q = c.call(this, best[1]); } catch (ey) { throw new $P.Exception(best[1]); } // it parsed ... be sure to update the best match remaining input best[1] = q[1]; } // if we're here, either there was no closing delimiter or we parsed it // so now we have the best match; just return it! return best; }; }, forward: function (gr, fname) { return function (s) { return gr[fname].call(this, s); }; }, // // Translation Operators // replace: function (rule, repl) { return function (s) { var r = rule.call(this, s); return [repl, r[1]]; }; }, process: function (rule, fn) { return function (s) { var r = rule.call(this, s); return [fn.call(this, r[0]), r[1]]; }; }, min: function (min, rule) { return function (s) { var rx = rule.call(this, s); if (rx[0].length < min) { throw new $P.Exception(s); } return rx; }; } }; // Generator Operators And Vector Operators // Generators are operators that have a signature of F(R) => R, // taking a given rule and returning another rule, such as // ignore, which parses a given rule and throws away the result. // Vector operators are those that have a signature of F(R1,R2,...) => R, // take a list of rules and returning a new rule, such as each. // Generator operators are converted (via the following _generator // function) into functions that can also take a list or array of rules // and return an array of new rules as though the function had been // called on each rule in turn (which is what actually happens). // This allows generators to be used with vector operators more easily. // Example: // each(ignore(foo, bar)) instead of each(ignore(foo), ignore(bar)) // This also turns generators into vector operators, which allows // constructs like: // not(cache(foo, bar)) var _generator = function (op) { function gen() { var args = null, rx = [], px, i; if (arguments.length > 1) { args = Array.prototype.slice.call(arguments); } else if (arguments[0] instanceof Array) { args = arguments[0]; } if (args) { px = args.shift(); if (px.length > 0) { args.unshift(px[i]); rx.push(op.apply(null, args)); args.shift(); return rx; } } else { return op.apply(null, arguments); } } return gen; }; var gx = "optional not ignore cache".split(/\s/); for (var i = 0 ; i < gx.length ; i++) { _[gx[i]] = _generator(_[gx[i]]); } var _vector = function (op) { return function () { if (arguments[0] instanceof Array) { return op.apply(null, arguments[0]); } else { return op.apply(null, arguments); } }; }; var vx = "each any all".split(/\s/); for (var j = 0 ; j < vx.length ; j++) { _[vx[j]] = _vector(_[vx[j]]); } }()); (function () { var $D = Date; var flattenAndCompact = function (ax) { var rx = []; for (var i = 0; i < ax.length; i++) { if (ax[i] instanceof Array) { rx = rx.concat(flattenAndCompact(ax[i])); } else { if (ax[i]) { rx.push(ax[i]); } } } return rx; }; var parseMeridian = function () { if (this.meridian && (this.hour || this.hour === 0)) { if (this.meridian === "a" && this.hour > 11 && Date.Config.strict24hr){ throw "Invalid hour and meridian combination"; } else if (this.meridian === "p" && this.hour < 12 && Date.Config.strict24hr){ throw "Invalid hour and meridian combination"; } else if (this.meridian === "p" && this.hour < 12) { this.hour = this.hour + 12; } else if (this.meridian === "a" && this.hour === 12) { this.hour = 0; } } }; var setDefaults = function () { var now = new Date(); if ((this.hour || this.minute) && (!this.month && !this.year && !this.day)) { this.day = now.getDate(); } if (!this.year) { this.year = now.getFullYear(); } if (!this.month && this.month !== 0) { this.month = now.getMonth(); } if (!this.day) { this.day = 1; } if (!this.hour) { this.hour = 0; } if (!this.minute) { this.minute = 0; } if (!this.second) { this.second = 0; } if (!this.millisecond) { this.millisecond = 0; } }; var finishUtils = { getToday: function () { if (this.now || "hour minute second".indexOf(this.unit) !== -1) { return new Date(); } else { return $D.today(); } }, setDaysFromWeekday: function (today, orient){ var gap; orient = orient || 1; this.unit = "day"; gap = ($D.getDayNumberFromName(this.weekday) - today.getDay()); this.days = gap ? ((gap + (orient * 7)) % 7) : (orient * 7); return this; }, setMonthsFromMonth: function (today, orient) { var gap; orient = orient || 1; this.unit = "month"; gap = (this.month - today.getMonth()); this.months = gap ? ((gap + (orient * 12)) % 12) : (orient * 12); this.month = null; return this; }, setDMYFromWeekday: function () { var d = Date[this.weekday](); this.day = d.getDate(); if (!this.month) { this.month = d.getMonth(); } this.year = d.getFullYear(); return this; }, setUnitValue: function (orient) { if (!this.value && this.operator && this.operator !== null && this[this.unit + "s"] && this[this.unit + "s"] !== null) { this[this.unit + "s"] = this[this.unit + "s"] + ((this.operator === "add") ? 1 : -1) + (this.value||0) * orient; } else if (this[this.unit + "s"] == null || this.operator != null) { if (!this.value) { this.value = 1; } this[this.unit + "s"] = this.value * orient; } }, generateDateFromWeeks: function () { var weekday = (this.weekday !== undefined) ? this.weekday : "today"; var d = Date[weekday]().addWeeks(this.weeks); if (this.now) { d.setTimeToNow(); } return d; } }; $D.Translator = { hour: function (s) { return function () { this.hour = Number(s); }; }, minute: function (s) { return function () { this.minute = Number(s); }; }, second: function (s) { return function () { this.second = Number(s); }; }, /* for ss.s format */ secondAndMillisecond: function (s) { return function () { var mx = s.match(/^([0-5][0-9])\.([0-9]{1,3})/); this.second = Number(mx[1]); this.millisecond = Number(mx[2]); }; }, meridian: function (s) { return function () { this.meridian = s.slice(0, 1).toLowerCase(); }; }, timezone: function (s) { return function () { var n = s.replace(/[^\d\+\-]/g, ""); if (n.length) { this.timezoneOffset = Number(n); } else { this.timezone = s.toLowerCase(); } }; }, day: function (x) { var s = x[0]; return function () { this.day = Number(s.match(/\d+/)[0]); if (this.day < 1) { throw "invalid day"; } }; }, month: function (s) { return function () { this.month = (s.length === 3) ? "jan feb mar apr may jun jul aug sep oct nov dec".indexOf(s)/4 : Number(s) - 1; if (this.month < 0) { throw "invalid month"; } }; }, year: function (s) { return function () { var n = Number(s); this.year = ((s.length > 2) ? n : (n + (((n + 2000) < Date.CultureInfo.twoDigitYearMax) ? 2000 : 1900))); }; }, rday: function (s) { return function () { switch (s) { case "yesterday": this.days = -1; break; case "tomorrow": this.days = 1; break; case "today": this.days = 0; break; case "now": this.days = 0; this.now = true; break; } }; }, finishExact: function (x) { var d; x = (x instanceof Array) ? x : [x]; for (var i = 0 ; i < x.length ; i++) { if (x[i]) { x[i].call(this); } } setDefaults.call(this); parseMeridian.call(this); if (this.day > $D.getDaysInMonth(this.year, this.month)) { throw new RangeError(this.day + " is not a valid value for days."); } d = new Date(this.year, this.month, this.day, this.hour, this.minute, this.second, this.millisecond); if (this.year < 100) { d.setFullYear(this.year); // means years less that 100 are process correctly. JS will parse it otherwise as 1900-1999. } if (this.timezone) { d.set({ timezone: this.timezone }); } else if (this.timezoneOffset) { d.set({ timezoneOffset: this.timezoneOffset }); } return d; }, finish: function (x) { var today, expression, orient, temp; x = (x instanceof Array) ? flattenAndCompact(x) : [ x ]; if (x.length === 0) { return null; } for (var i = 0 ; i < x.length ; i++) { if (typeof x[i] === "function") { x[i].call(this); } } if (this.now && !this.unit && !this.operator) { return new Date(); } else { today = finishUtils.getToday.call(this); } expression = !!(this.days && this.days !== null || this.orient || this.operator); orient = ((this.orient === "past" || this.operator === "subtract") ? -1 : 1); if (this.month && this.unit === "week") { this.value = this.month + 1; delete this.month; delete this.day; } if ((this.month || this.month === 0) && "year day hour minute second".indexOf(this.unit) !== -1) { if (!this.value) { this.value = this.month + 1; } this.month = null; expression = true; } if (!expression && this.weekday && !this.day && !this.days) { finishUtils.setDMYFromWeekday.call(this); } if (expression && this.weekday && this.unit !== "month" && this.unit !== "week") { finishUtils.setDaysFromWeekday.call(this, today, orient); } if (this.weekday && this.unit !== "week" && !this.day && !this.days) { temp = Date[this.weekday](); this.day = temp.getDate(); if (temp.getMonth() !== today.getMonth()) { this.month = temp.getMonth(); } } if (this.month && this.unit === "day" && this.operator) { if (!this.value) { this.value = (this.month + 1); } this.month = null; } if (this.value != null && this.month != null && this.year != null) { this.day = this.value * 1; } if (this.month && !this.day && this.value) { today.set({ day: this.value * 1 }); if (!expression) { this.day = this.value * 1; } } if (!this.month && this.value && this.unit === "month" && !this.now) { this.month = this.value; expression = true; } if (expression && (this.month || this.month === 0) && this.unit !== "year") { finishUtils.setMonthsFromMonth.call(this, today, orient); } if (!this.unit) { this.unit = "day"; } finishUtils.setUnitValue.call(this, orient); parseMeridian.call(this); if ((this.month || this.month === 0) && !this.day) { this.day = 1; } if (!this.orient && !this.operator && this.unit === "week" && this.value && !this.day && !this.month) { return Date.today().setWeek(this.value); } if (this.unit === "week" && this.weeks && !this.day && !this.month) { return finishUtils.generateDateFromWeeks.call(this); } if (expression && this.timezone && this.day && this.days) { this.day = this.days; } if (expression){ today.add(this); } else { today.set(this); } if (this.timezone) { this.timezone = this.timezone.toUpperCase(); var offset = $D.getTimezoneOffset(this.timezone); var timezone; if (today.hasDaylightSavingTime()) { // lets check that we're being sane with timezone setting timezone = $D.getTimezoneAbbreviation(offset, today.isDaylightSavingTime()); if (timezone !== this.timezone) { // bugger, we're in a place where things like EST vs EDT matters. if (today.isDaylightSavingTime()) { today.addHours(-1); } else { today.addHours(1); } } } today.setTimezoneOffset(offset); } return today; } }; }()); (function () { var $D = Date; $D.Grammar = {}; var _ = $D.Parsing.Operators, g = $D.Grammar, t = $D.Translator, _fn; // Allow rolling up into general purpose rules _fn = function () { return _.each(_.any.apply(null, arguments), _.not(g.ctoken2("timeContext"))); }; g.datePartDelimiter = _.rtoken(/^([\s\-\.\,\/\x27]+)/); g.timePartDelimiter = _.stoken(":"); g.whiteSpace = _.rtoken(/^\s*/); g.generalDelimiter = _.rtoken(/^(([\s\,]|at|@|on)+)/); var _C = {}; g.ctoken = function (keys) { var fn = _C[keys]; if (! fn) { var c = Date.CultureInfo.regexPatterns; var kx = keys.split(/\s+/), px = []; for (var i = 0; i < kx.length ; i++) { px.push(_.replace(_.rtoken(c[kx[i]]), kx[i])); } fn = _C[keys] = _.any.apply(null, px); } return fn; }; g.ctoken2 = function (key) { return _.rtoken(Date.CultureInfo.regexPatterns[key]); }; var cacheProcessRtoken = function (key, token, type, eachToken) { if (eachToken) { g[key] = _.cache(_.process(_.each(_.rtoken(token),_.optional(g.ctoken2(eachToken))), type)); } else { g[key] = _.cache(_.process(_.rtoken(token), type)); } }; var cacheProcessCtoken = function (token, type) { return _.cache(_.process(g.ctoken2(token), type)); }; var _F = {}; //function cache var _get = function (f) { _F[f] = (_F[f] || g.format(f)[0]); return _F[f]; }; g.allformats = function (fx) { var rx = []; if (fx instanceof Array) { for (var i = 0; i < fx.length; i++) { rx.push(_get(fx[i])); } } else { rx.push(_get(fx)); } return rx; }; g.formats = function (fx) { if (fx instanceof Array) { var rx = []; for (var i = 0 ; i < fx.length ; i++) { rx.push(_get(fx[i])); } return _.any.apply(null, rx); } else { return _get(fx); } }; var grammarFormats = { timeFormats: function(){ var i, RTokenKeys = [ "h", "hh", "H", "HH", "m", "mm", "s", "ss", "ss.s", "z", "zz" ], RToken = [ /^(0[0-9]|1[0-2]|[1-9])/, /^(0[0-9]|1[0-2])/, /^([0-1][0-9]|2[0-3]|[0-9])/, /^([0-1][0-9]|2[0-3])/, /^([0-5][0-9]|[0-9])/, /^[0-5][0-9]/, /^([0-5][0-9]|[0-9])/, /^[0-5][0-9]/, /^[0-5][0-9]\.[0-9]{1,3}/, /^((\+|\-)\s*\d\d\d\d)|((\+|\-)\d\d\:?\d\d)/, /^((\+|\-)\s*\d\d\d\d)|((\+|\-)\d\d\:?\d\d)/ ], tokens = [ t.hour, t.hour, t.hour, t.hour, t.minute, t.minute, t.second, t.second, t.secondAndMillisecond, t.timezone, t.timezone ]; for (i=0; i < RTokenKeys.length; i++) { cacheProcessRtoken(RTokenKeys[i], RToken[i], tokens[i]); } g.hms = _.cache(_.sequence([g.H, g.m, g.s], g.timePartDelimiter)); g.t = cacheProcessCtoken("shortMeridian", t.meridian); g.tt = cacheProcessCtoken("longMeridian", t.meridian); g.zzz = cacheProcessCtoken("timezone", t.timezone); g.timeSuffix = _.each(_.ignore(g.whiteSpace), _.set([ g.tt, g.zzz ])); g.time = _.each(_.optional(_.ignore(_.stoken("T"))), g.hms, g.timeSuffix); }, dateFormats: function () { // pre-loaded rules for different date part order preferences var _setfn = function () { return _.set(arguments, g.datePartDelimiter); }; var i, RTokenKeys = [ "d", "dd", "M", "MM", "y", "yy", "yyy", "yyyy" ], RToken = [ /^([0-2]\d|3[0-1]|\d)/, /^([0-2]\d|3[0-1])/, /^(1[0-2]|0\d|\d)/, /^(1[0-2]|0\d)/, /^(\d+)/, /^(\d\d)/, /^(\d\d?\d?\d?)/, /^(\d\d\d\d)/ ], tokens = [ t.day, t.day, t.month, t.month, t.year, t.year, t.year, t.year ], eachToken = [ "ordinalSuffix", "ordinalSuffix" ]; for (i=0; i < RTokenKeys.length; i++) { cacheProcessRtoken(RTokenKeys[i], RToken[i], tokens[i], eachToken[i]); } g.MMM = g.MMMM = _.cache(_.process(g.ctoken("jan feb mar apr may jun jul aug sep oct nov dec"), t.month)); g.ddd = g.dddd = _.cache(_.process(g.ctoken("sun mon tue wed thu fri sat"), function (s) { return function () { this.weekday = s; }; } )); g.day = _fn(g.d, g.dd); g.month = _fn(g.M, g.MMM); g.year = _fn(g.yyyy, g.yy); g.mdy = _setfn(g.ddd, g.month, g.day, g.year); g.ymd = _setfn(g.ddd, g.year, g.month, g.day); g.dmy = _setfn(g.ddd, g.day, g.month, g.year); g.date = function (s) { return ((g[Date.CultureInfo.dateElementOrder] || g.mdy).call(this, s)); }; }, relative: function () { // relative date / time expressions g.orientation = _.process(g.ctoken("past future"), function (s) { return function () { this.orient = s; }; } ); g.operator = _.process(g.ctoken("add subtract"), function (s) { return function () { this.operator = s; }; } ); g.rday = _.process(g.ctoken("yesterday tomorrow today now"), t.rday); g.unit = _.process(g.ctoken("second minute hour day week month year"), function (s) { return function () { this.unit = s; }; } ); } }; g.buildGrammarFormats = function () { // these need to be rebuilt every time the language changes. _C = {}; grammarFormats.timeFormats(); grammarFormats.dateFormats(); grammarFormats.relative(); g.value = _.process(_.rtoken(/^([-+]?\d+)?(st|nd|rd|th)?/), function (s) { return function () { this.value = s.replace(/\D/g, ""); }; } ); g.expression = _.set([g.rday, g.operator, g.value, g.unit, g.orientation, g.ddd, g.MMM ]); g.format = _.process(_.many( _.any( // translate format specifiers into grammar rules _.process( _.rtoken(/^(dd?d?d?(?!e)|MM?M?M?|yy?y?y?|hh?|HH?|mm?|ss?|tt?|zz?z?)/), function (fmt) { if (g[fmt]) { return g[fmt]; } else { throw $D.Parsing.Exception(fmt); } } ), // translate separator tokens into token rules _.process(_.rtoken(/^[^dMyhHmstz]+/), // all legal separators function (s) { return _.ignore(_.stoken(s)); } ) ) ), // construct the parser ... function (rules) { return _.process(_.each.apply(null, rules), t.finishExact); } ); // starting rule for general purpose grammar g._start = _.process(_.set([ g.date, g.time, g.expression ], g.generalDelimiter, g.whiteSpace), t.finish); }; g.buildGrammarFormats(); // parsing date format specifiers - ex: "h:m:s tt" // this little guy will generate a custom parser based // on the format string, ex: g.format("h:m:s tt") // check for these formats first g._formats = g.formats([ "\"yyyy-MM-ddTHH:mm:ssZ\"", "yyyy-MM-ddTHH:mm:ss.sz", "yyyy-MM-ddTHH:mm:ssZ", "yyyy-MM-ddTHH:mm:ssz", "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-ddTHH:mmZ", "yyyy-MM-ddTHH:mmz", "yyyy-MM-ddTHH:mm", "ddd, MMM dd, yyyy H:mm:ss tt", "ddd MMM d yyyy HH:mm:ss zzz", "MMddyyyy", "ddMMyyyy", "Mddyyyy", "ddMyyyy", "Mdyyyy", "dMyyyy", "yyyy", "Mdyy", "dMyy", "d" ]); // real starting rule: tries selected formats first, // then general purpose rule g.start = function (s) { try { var r = g._formats.call({}, s); if (r[1].length === 0) { return r; } } catch (e) {} return g._start.call({}, s); }; }()); (function () { var $D = Date; /** * @desc Converts the specified string value into its JavaScript Date equivalent using CultureInfo specific format information. * * Example

	///////////
	// Dates //
	///////////

	// 15-Oct-2004
	var d1 = Date.parse("10/15/2004");

	// 15-Oct-2004
	var d1 = Date.parse("15-Oct-2004");

	// 15-Oct-2004
	var d1 = Date.parse("2004.10.15");

	//Fri Oct 15, 2004
	var d1 = Date.parse("Fri Oct 15, 2004");

	///////////
	// Times //
	///////////

	// Today at 10 PM.
	var d1 = Date.parse("10 PM");

	// Today at 10:30 PM.
	var d1 = Date.parse("10:30 P.M.");

	// Today at 6 AM.
	var d1 = Date.parse("06am");

	/////////////////////
	// Dates and Times //
	/////////////////////

	// 8-July-2004 @ 10:30 PM
	var d1 = Date.parse("July 8th, 2004, 10:30 PM");

	// 1-July-2004 @ 10:30 PM
	var d1 = Date.parse("2004-07-01T22:30:00");

	////////////////////
	// Relative Dates //
	////////////////////

	// Returns today's date. The string "today" is culture specific.
	var d1 = Date.parse("today");

	// Returns yesterday's date. The string "yesterday" is culture specific.
	var d1 = Date.parse("yesterday");

	// Returns the date of the next thursday.
	var d1 = Date.parse("Next thursday");

	// Returns the date of the most previous monday.
	var d1 = Date.parse("last monday");

	// Returns today's day + one year.
	var d1 = Date.parse("next year");

	///////////////
	// Date Math //
	///////////////

	// Today + 2 days
	var d1 = Date.parse("t+2");

	// Today + 2 days
	var d1 = Date.parse("today + 2 days");

	// Today + 3 months
	var d1 = Date.parse("t+3m");

	// Today - 1 year
	var d1 = Date.parse("today - 1 year");

	// Today - 1 year
	var d1 = Date.parse("t-1y"); 


	/////////////////////////////
	// Partial Dates and Times //
	/////////////////////////////

	// July 15th of this year.
	var d1 = Date.parse("July 15");

	// 15th day of current day and year.
	var d1 = Date.parse("15");

	// July 1st of current year at 10pm.
	var d1 = Date.parse("7/1 10pm");
	
* * @param {String} The string value to convert into a Date object [Required] * @return {Date} A Date object or null if the string cannot be converted into a Date. */ var parseUtils = { removeOrds: function (s) { ords = s.match(/\b(\d+)(?:st|nd|rd|th)\b/); // find ordinal matches s = ((ords && ords.length === 2) ? s.replace(ords[0], ords[1]) : s); return s; }, grammarParser: function (s) { var r = null; try { r = $D.Grammar.start.call({}, s.replace(/^\s*(\S*(\s+\S+)*)\s*$/, "$1")); } catch (e) { return null; } return ((r[1].length === 0) ? r[0] : null); }, nativeFallback: function(s) { var t; try { // ok we haven't parsed it, last ditch attempt with the built-in parser. t = Date._parse(s); return (t || t === 0) ? new Date(t) : null; } catch (e) { return null; } } }; function parse (s) { var d; if (!s) { return null; } if (s instanceof Date) { return s.clone(); } if (s.length >= 4 && s.charAt(0) !== "0" && s.charAt(0) !== "+"&& s.charAt(0) !== "-") { // ie: 2004 will pass, 0800 won't. // Start with specific formats d = $D.Parsing.ISO.parse(s) || $D.Parsing.Numeric.parse(s); } if (d instanceof Date && !isNaN(d.getTime())) { return d; } else { // find ordinal dates (1st, 3rd, 8th, etc and remove them as they cause parsing issues) s = $D.Parsing.Normalizer.parse(parseUtils.removeOrds(s)); d = parseUtils.grammarParser(s); if (d !== null) { return d; } else { return parseUtils.nativeFallback(s); } } } if (!$D._parse) { $D._parse = $D.parse; } $D.parse = parse; Date.getParseFunction = function (fx) { var fns = Date.Grammar.allformats(fx); return function (s) { var r = null; for (var i = 0; i < fns.length; i++) { try { r = fns[i].call({}, s); } catch (e) { continue; } if (r[1].length === 0) { return r[0]; } } return null; }; }; /** * Converts the specified string value into its JavaScript Date equivalent using the specified format {String} or formats {Array} and the CultureInfo specific format information. * The format of the string value must match one of the supplied formats exactly. * * Example

	// 15-Oct-2004
	var d1 = Date.parseExact("10/15/2004", "M/d/yyyy");

	// 15-Oct-2004
	var d1 = Date.parse("15-Oct-2004", "M-ddd-yyyy");

	// 15-Oct-2004
	var d1 = Date.parse("2004.10.15", "yyyy.MM.dd");

	// Multiple formats
	var d1 = Date.parseExact("10/15/2004", ["M/d/yyyy", "MMMM d, yyyy"]);
	
* * @param {String} The string value to convert into a Date object [Required]. * @param {Object} The expected format {String} or an array of expected formats {Array} of the date string [Required]. * @return {Date} A Date object or null if the string cannot be converted into a Date. */ $D.parseExact = function (s, fx) { return $D.getParseFunction(fx)(s); }; }()); (function () { var $D = Date, $P = $D.prototype, // $C = $D.CultureInfo, // not used atm p = function (s, l) { if (!l) { l = 2; } return ("000" + s).slice(l * -1); }; /** * Converts a PHP format string to Java/.NET format string. * A PHP format string can be used with ._format or .format. * A Java/.NET format string can be used with .toString(). * The .parseExact function will only accept a Java/.NET format string * * Example * var f1 = "%m/%d/%y" * var f2 = Date.normalizeFormat(f1); // "MM/dd/yy" * * new Date().format(f1); // "04/13/08" * new Date()._format(f1); // "04/13/08" * new Date().toString(f2); // "04/13/08" * * var date = Date.parseExact("04/13/08", f2); // Sun Apr 13 2008 * * @param {String} A PHP format string consisting of one or more format spcifiers. * @return {String} The PHP format converted to a Java/.NET format string. */ var normalizerSubstitutions = { "d" : "dd", "%d": "dd", "D" : "ddd", "%a": "ddd", "j" : "dddd", "l" : "dddd", "%A": "dddd", "S" : "S", "F" : "MMMM", "%B": "MMMM", "m" : "MM", "%m": "MM", "M" : "MMM", "%b": "MMM", "%h": "MMM", "n" : "M", "Y" : "yyyy", "%Y": "yyyy", "y" : "yy", "%y": "yy", "g" : "h", "%I": "h", "G" : "H", "h" : "hh", "H" : "HH", "%H": "HH", "i" : "mm", "%M": "mm", "s" : "ss", "%S": "ss", "%r": "hh:mm tt", "%R": "H:mm", "%T": "H:mm:ss", "%X": "t", "%x": "d", "%e": "d", "%D": "MM/dd/yy", "%n": "\\n", "%t": "\\t", "e" : "z", "T" : "z", "%z": "z", "%Z": "z", "Z" : "ZZ", "N" : "u", "w" : "u", "%w": "u", "W" : "W", "%V": "W" }; var normalizer = { substitutes: function (m) { return normalizerSubstitutions[m]; }, interpreted: function (m, x) { var y; switch (m) { case "%u": return x.getDay() + 1; case "z": return x.getOrdinalNumber(); case "%j": return p(x.getOrdinalNumber(), 3); case "%U": var d1 = x.clone().set({month: 0, day: 1}).addDays(-1).moveToDayOfWeek(0), d2 = x.clone().addDays(1).moveToDayOfWeek(0, -1); return (d2 < d1) ? "00" : p((d2.getOrdinalNumber() - d1.getOrdinalNumber()) / 7 + 1); case "%W": return p(x.getWeek()); case "t": return $D.getDaysInMonth(x.getFullYear(), x.getMonth()); case "o": case "%G": return x.setWeek(x.getISOWeek()).toString("yyyy"); case "%g": return x._format("%G").slice(-2); case "a": case "%p": return t("tt").toLowerCase(); case "A": return t("tt").toUpperCase(); case "u": return p(x.getMilliseconds(), 3); case "I": return (x.isDaylightSavingTime()) ? 1 : 0; case "O": return x.getUTCOffset(); case "P": y = x.getUTCOffset(); return y.substring(0, y.length - 2) + ":" + y.substring(y.length - 2); case "B": var now = new Date(); return Math.floor(((now.getHours() * 3600) + (now.getMinutes() * 60) + now.getSeconds() + (now.getTimezoneOffset() + 60) * 60) / 86.4); case "c": return x.toISOString().replace(/\"/g, ""); case "U": return $D.strtotime("now"); case "%c": return t("d") + " " + t("t"); case "%C": return Math.floor(x.getFullYear() / 100 + 1); } }, shouldOverrideDefaults: function (m) { switch (m) { case "%e": return true; default: return false; } }, parse: function (m, context) { var formatString, c = context || new Date(); formatString = normalizer.substitutes(m); if (formatString) { return formatString; } formatString = normalizer.interpreted(m, c); if (formatString) { return formatString; } else { return m; } } }; $D.normalizeFormat = function (format, context) { return format.replace(/(%|\\)?.|%%/g, function(t){ return normalizer.parse(t, context); }); }; /** * Format a local Unix timestamp according to locale settings * * Example: * Date.strftime("%m/%d/%y", new Date()); // "04/13/08" * Date.strftime("c", "2008-04-13T17:52:03Z"); // "04/13/08" * * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @param {Number|String} The number representing the number of seconds that have elapsed since January 1, 1970 (local time). * @return {String} A string representation of the current Date object. */ $D.strftime = function (format, time) { var d = Date.parse(time); return d._format(format); }; /** * Parse any textual datetime description into a Unix timestamp. * A Unix timestamp is the number of seconds that have elapsed since January 1, 1970 (midnight UTC/GMT). * * Example: * Date.strtotime("04/13/08"); // 1208044800 * Date.strtotime("1970-01-01T00:00:00Z"); // 0 * * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @param {Object} A string or date object. * @return {String} A string representation of the current Date object. */ $D.strtotime = function (time) { var d = $D.parse(time); return Math.round($D.UTC(d.getUTCFullYear(), d.getUTCMonth(), d.getUTCDate(), d.getUTCHours(), d.getUTCMinutes(), d.getUTCSeconds(), d.getUTCMilliseconds()) / 1000); }; /** * Converts the value of the current Date object to its equivalent string representation using a PHP/Unix style of date format specifiers. * Format Specifiers * Format Description Example * ------ --------------------------------------------------------------------------- ----------------------- * %a abbreviated weekday name according to the current localed "Mon" through "Sun" * %A full weekday name according to the current localed "Sunday" through "Saturday" * %b abbreviated month name according to the current localed "Jan" through "Dec" * %B full month name according to the current locale "January" through "December" * %c preferred date and time representation for the current locale "4/13/2008 12:33 PM" * %C century number (the year divided by 100 and truncated to an integer) "00" to "99" * %d day of the month as a decimal number "01" to "31" * %D same as %m/%d/%y "04/13/08" * %e day of the month as a decimal number, a single digit is preceded by a space "1" to "31" * %g like %G, but without the century "08" * %G The 4-digit year corresponding to the ISO week number (see %V). "2008" * This has the same format and value as %Y, except that if the ISO week number * belongs to the previous or next year, that year is used instead. * %h same as %b "Jan" through "Dec" * %H hour as a decimal number using a 24-hour clock. "00" to "23" * %I hour as a decimal number using a 12-hour clock. "01" to "12" * %j day of the year as a decimal number. "001" to "366" * %m month as a decimal number. "01" to "12" * %M minute as a decimal number. "00" to "59" * %n newline character "\n" * %p either "am" or "pm" according to the given time value, or the "am" or "pm" * corresponding strings for the current locale. * %r time in a.m. and p.m. notation "8:44 PM" * %R time in 24 hour notation "20:44" * %S second as a decimal number "00" to "59" * %t tab character "\t" * %T current time, equal to %H:%M:%S "12:49:11" * %u weekday as a decimal number ["1", "7"], with "1" representing Monday "1" to "7" * %U week number of the current year as a decimal number, starting with the "0" to ("52" or "53") * first Sunday as the first day of the first week * %V The ISO 8601:1988 week number of the current year as a decimal number, "00" to ("52" or "53") * range 01 to 53, where week 1 is the first week that has at least 4 days * in the current year, and with Monday as the first day of the week. * (Use %G or %g for the year component that corresponds to the week number * for the specified timestamp.) * %W week number of the current year as a decimal number, starting with the "00" to ("52" or "53") * first Monday as the first day of the first week * %w day of the week as a decimal, Sunday being "0" "0" to "6" * %x preferred date representation for the current locale without the time "4/13/2008" * %X preferred time representation for the current locale without the date "12:53:05" * %y year as a decimal number without a century "00" "99" * %Y year as a decimal number including the century "2008" * %Z time zone or name or abbreviation "UTC", "EST", "PST" * %z same as %Z * %% a literal "%" characters "%" * d Day of the month, 2 digits with leading zeros "01" to "31" * D A textual representation of a day, three letters "Mon" through "Sun" * j Day of the month without leading zeros "1" to "31" * l A full textual representation of the day of the week (lowercase "L") "Sunday" through "Saturday" * N ISO-8601 numeric representation of the day of the week (added in PHP 5.1.0) "1" (for Monday) through "7" (for Sunday) * S English ordinal suffix for the day of the month, 2 characters "st", "nd", "rd" or "th". Works well with j * w Numeric representation of the day of the week "0" (for Sunday) through "6" (for Saturday) * z The day of the year (starting from "0") "0" through "365" * W ISO-8601 week number of year, weeks starting on Monday "00" to ("52" or "53") * F A full textual representation of a month, such as January or March "January" through "December" * m Numeric representation of a month, with leading zeros "01" through "12" * M A short textual representation of a month, three letters "Jan" through "Dec" * n Numeric representation of a month, without leading zeros "1" through "12" * t Number of days in the given month "28" through "31" * L Whether it's a leap year "1" if it is a leap year, "0" otherwise * o ISO-8601 year number. This has the same value as Y, except that if the "2008" * ISO week number (W) belongs to the previous or next year, that year * is used instead. * Y A full numeric representation of a year, 4 digits "2008" * y A two digit representation of a year "08" * a Lowercase Ante meridiem and Post meridiem "am" or "pm" * A Uppercase Ante meridiem and Post meridiem "AM" or "PM" * B Swatch Internet time "000" through "999" * g 12-hour format of an hour without leading zeros "1" through "12" * G 24-hour format of an hour without leading zeros "0" through "23" * h 12-hour format of an hour with leading zeros "01" through "12" * H 24-hour format of an hour with leading zeros "00" through "23" * i Minutes with leading zeros "00" to "59" * s Seconds, with leading zeros "00" through "59" * u Milliseconds "54321" * e Timezone identifier "UTC", "EST", "PST" * I Whether or not the date is in daylight saving time (uppercase i) "1" if Daylight Saving Time, "0" otherwise * O Difference to Greenwich time (GMT) in hours "+0200", "-0600" * P Difference to Greenwich time (GMT) with colon between hours and minutes "+02:00", "-06:00" * T Timezone abbreviation "UTC", "EST", "PST" * Z Timezone offset in seconds. The offset for timezones west of UTC is "-43200" through "50400" * always negative, and for those east of UTC is always positive. * c ISO 8601 date "2004-02-12T15:19:21+00:00" * r RFC 2822 formatted date "Thu, 21 Dec 2000 16:01:07 +0200" * U Seconds since the Unix Epoch (January 1 1970 00:00:00 GMT) "0" * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @return {String} A string representation of the current Date object. */ var formatReplace = function (context) { return function (m) { var formatString, override = false; if (m.charAt(0) === "\\" || m.substring(0, 2) === "%%") { return m.replace("\\", "").replace("%%", "%"); } override = normalizer.shouldOverrideDefaults(m); formatString = $D.normalizeFormat(m, context); if (formatString) { return context.toString(formatString, override); } }; }; $P._format = function (format) { var formatter = formatReplace(this); if (!format) { return this._toString(); } else { return format.replace(/(%|\\)?.|%%/g, formatter); } }; if (!$P.format) { $P.format = $P._format; } }()); (function () { "use strict"; var gFn = function (attr) { return function () { return this[attr]; }; }; var sFn = function (attr) { return function (val) { this[attr] = val; return this; }; }; var attrs = ["years", "months", "days", "hours", "minutes", "seconds", "milliseconds"]; var addSetFuncs = function (context, attrs) { for (var i = 0; i < attrs.length ; i++) { var $a = attrs[i], $b = $a.slice(0, 1).toUpperCase() + $a.slice(1); context.prototype[$a] = 0; context.prototype["get" + $b] = gFn($a); context.prototype["set" + $b] = sFn($a); } }; /** * new TimeSpan(milliseconds); * new TimeSpan(days, hours, minutes, seconds); * new TimeSpan(days, hours, minutes, seconds, milliseconds); */ var TimeSpan = function (days, hours, minutes, seconds, milliseconds) { if (arguments.length === 1 && typeof days === "number") { var orient = (days < 0) ? -1 : +1; var millsLeft = Math.abs(days); this.setDays(Math.floor(millsLeft / 86400000) * orient); millsLeft = millsLeft % 86400000; this.setHours(Math.floor(millsLeft / 3600000) * orient); millsLeft = millsLeft % 3600000; this.setMinutes(Math.floor(millsLeft / 60000) * orient); millsLeft = millsLeft % 60000; this.setSeconds(Math.floor(millsLeft / 1000) * orient); millsLeft = millsLeft % 1000; this.setMilliseconds(millsLeft * orient); } else { this.set(days, hours, minutes, seconds, milliseconds); } this.getTotalMilliseconds = function () { return (this.getDays() * 86400000) + (this.getHours() * 3600000) + (this.getMinutes() * 60000) + (this.getSeconds() * 1000); }; this.compareTo = function (time) { var t1 = new Date(1970, 1, 1, this.getHours(), this.getMinutes(), this.getSeconds()), t2; if (time === null) { t2 = new Date(1970, 1, 1, 0, 0, 0); } else { t2 = new Date(1970, 1, 1, time.getHours(), time.getMinutes(), time.getSeconds()); } return (t1 < t2) ? -1 : (t1 > t2) ? 1 : 0; }; this.equals = function (time) { return (this.compareTo(time) === 0); }; this.add = function (time) { return (time === null) ? this : this.addSeconds(time.getTotalMilliseconds() / 1000); }; this.subtract = function (time) { return (time === null) ? this : this.addSeconds(-time.getTotalMilliseconds() / 1000); }; this.addDays = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 86400000)); }; this.addHours = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 3600000)); }; this.addMinutes = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 60000)); }; this.addSeconds = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 1000)); }; this.addMilliseconds = function (n) { return new TimeSpan(this.getTotalMilliseconds() + n); }; this.get12HourHour = function () { return (this.getHours() > 12) ? this.getHours() - 12 : (this.getHours() === 0) ? 12 : this.getHours(); }; this.getDesignator = function () { return (this.getHours() < 12) ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator; }; this.toString = function (format) { this._toString = function () { if (this.getDays() !== null && this.getDays() > 0) { return this.getDays() + "." + this.getHours() + ":" + this.p(this.getMinutes()) + ":" + this.p(this.getSeconds()); } else { return this.getHours() + ":" + this.p(this.getMinutes()) + ":" + this.p(this.getSeconds()); } }; this.p = function (s) { return (s.toString().length < 2) ? "0" + s : s; }; var me = this; return format ? format.replace(/dd?|HH?|hh?|mm?|ss?|tt?/g, function (format) { switch (format) { case "d": return me.getDays(); case "dd": return me.p(me.getDays()); case "H": return me.getHours(); case "HH": return me.p(me.getHours()); case "h": return me.get12HourHour(); case "hh": return me.p(me.get12HourHour()); case "m": return me.getMinutes(); case "mm": return me.p(me.getMinutes()); case "s": return me.getSeconds(); case "ss": return me.p(me.getSeconds()); case "t": return ((me.getHours() < 12) ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator).substring(0, 1); case "tt": return (me.getHours() < 12) ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator; } } ) : this._toString(); }; return this; }; addSetFuncs(TimeSpan, attrs.slice(2)); TimeSpan.prototype.set = function (days, hours, minutes, seconds, milliseconds){ this.setDays(days || this.getDays()); this.setHours(hours || this.getHours()); this.setMinutes(minutes || this.getMinutes()); this.setSeconds(seconds || this.getSeconds()); this.setMilliseconds(milliseconds || this.getMilliseconds()); }; /** * Gets the time of day for this date instances. * @return {TimeSpan} TimeSpan */ Date.prototype.getTimeOfDay = function () { return new TimeSpan(0, this.getHours(), this.getMinutes(), this.getSeconds(), this.getMilliseconds()); }; Date.TimeSpan = TimeSpan; if (typeof window !== "undefined" ) { // keeping API compatible for v1.x window.TimeSpan = TimeSpan; } }()); (function () { "use strict"; var attrs = ["years", "months", "days", "hours", "minutes", "seconds", "milliseconds"]; var gFn = function (attr) { return function () { return this[attr]; }; }; var sFn = function (attr) { return function (val) { this[attr] = val; return this; }; }; var addSetFuncs = function (context, attrs) { for (var i = 0; i < attrs.length ; i++) { var $a = attrs[i], $b = $a.slice(0, 1).toUpperCase() + $a.slice(1); context.prototype[$a] = 0; context.prototype["get" + $b] = gFn($a); context.prototype["set" + $b] = sFn($a); } }; var setMonthsAndYears = function (orient, d1, d2, context) { function inc() { d1.addMonths(-orient); context.months++; if (context.months === 12) { context.years++; context.months = 0; } } if (orient === +1) { while (d1 > d2) { inc(); } } else { while (d1 < d2) { inc(); } } context.months--; context.months *= orient; context.years *= orient; }; var adjustForDST = function(orient, startDate, endDate) { var hasDSTMismatch = (false === (startDate.isDaylightSavingTime() === endDate.isDaylightSavingTime())); if (hasDSTMismatch && orient === 1) { startDate.addHours(-1); } else if (hasDSTMismatch) { startDate.addHours(1); } }; /** * TimePeriod(startDate, endDate); * TimePeriod(years, months, days, hours, minutes, seconds, milliseconds); */ var TimePeriod = function (years, months, days, hours, minutes, seconds, milliseconds) { if (arguments.length === 7) { this.set(years, months, days, hours, minutes, seconds, milliseconds); } else if (arguments.length === 2 && arguments[0] instanceof Date && arguments[1] instanceof Date) { var startDate = arguments[0].clone(); var endDate = arguments[1].clone(); var orient = (startDate > endDate) ? +1 : -1; this.dates = { start: arguments[0].clone(), end: arguments[1].clone() }; setMonthsAndYears(orient, startDate, endDate, this); adjustForDST(orient, startDate, endDate); // // TODO - adjust for DST var diff = endDate - startDate; if (diff !== 0) { var ts = new TimeSpan(diff); this.set(this.years, this.months, ts.getDays(), ts.getHours(), ts.getMinutes(), ts.getSeconds(), ts.getMilliseconds()); } } return this; }; // create all the set functions. addSetFuncs(TimePeriod, attrs); TimePeriod.prototype.set = function (years, months, days, hours, minutes, seconds, milliseconds){ this.setYears(years || this.getYears()); this.setMonths(months || this.getMonths()); this.setDays(days || this.getDays()); this.setHours(hours || this.getHours()); this.setMinutes(minutes || this.getMinutes()); this.setSeconds(seconds || this.getSeconds()); this.setMilliseconds(milliseconds || this.getMilliseconds()); }; Date.TimePeriod = TimePeriod; if (typeof window !== "undefined") { // keeping API compatible for v1.x window.TimePeriod = TimePeriod; } }()); ================================================ FILE: build/date-xh-ZA.js ================================================ /** * @overview datejs * @version 1.0.0-rc3 * @author Gregory Wild-Smith * @copyright 2015 Gregory Wild-Smith * @license MIT * @homepage https://github.com/abritinthebay/datejs */ /* * DateJS Culture String File * Country Code: xh-ZA * Name: Xhosa (South Africa) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["xh-ZA"] = { "name": "xh-ZA", "englishName": "Xhosa (South Africa)", "nativeName": "isiXhosa (uMzantsi Afrika)", "Sunday": "iCawa", "Monday": "uMvulo", "Tuesday": "uLwesibini", "Wednesday": "uLwesithathu", "Thursday": "uLwesine", "Friday": "uLwesihlanu", "Saturday": "uMgqibelo", "Sun": "Sun", "Mon": "Mon", "Tue": "Tue", "Wed": "Wed", "Thu": "Thu", "Fri": "Fri", "Sat": "Sat", "Su": "Sun", "Mo": "Mon", "Tu": "Tue", "We": "Wed", "Th": "Thu", "Fr": "Fri", "Sa": "Sat", "S_Sun_Initial": "S", "M_Mon_Initial": "M", "T_Tue_Initial": "T", "W_Wed_Initial": "W", "T_Thu_Initial": "T", "F_Fri_Initial": "F", "S_Sat_Initial": "S", "January": "eyoMqungu", "February": "eyoMdumba", "March": "eyoKwindla", "April": "Tshazimpuzi", "May": "Canzibe", "June": "eyeSilimela", "July": "eyeKhala", "August": "eyeThupha", "September": "eyoMsintsi", "October": "eyeDwara", "November": "eyeNkanga", "December": "eyoMnga", "Jan_Abbr": "Jan", "Feb_Abbr": "Feb", "Mar_Abbr": "Mar", "Apr_Abbr": "Apr", "May_Abbr": "May", "Jun_Abbr": "Jun", "Jul_Abbr": "Jul", "Aug_Abbr": "Aug", "Sep_Abbr": "Sep", "Oct_Abbr": "Oct", "Nov_Abbr": "Nov", "Dec_Abbr": "Dec", "AM": "AM", "PM": "PM", "firstDayOfWeek": 0, "twoDigitYearMax": 2029, "mdy": "ymd", "M/d/yyyy": "yyyy/MM/dd", "dddd, MMMM dd, yyyy": "dd MMMM yyyy", "h:mm tt": "hh:mm:ss tt", "h:mm:ss tt": "hh:mm:ss tt", "dddd, MMMM dd, yyyy h:mm:ss tt": "dd MMMM yyyy hh:mm:ss tt", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "MMMM dd", "MMMM, yyyy": "MMMM yyyy", "/jan(uary)?/": "eyomqungu", "/feb(ruary)?/": "eyomdumba", "/mar(ch)?/": "eyokwindla", "/apr(il)?/": "tshazimpuzi", "/may/": "canzibe", "/jun(e)?/": "eyesilimela", "/jul(y)?/": "eyekhala", "/aug(ust)?/": "eyethupha", "/sep(t(ember)?)?/": "eyomsintsi", "/oct(ober)?/": "eyedwara", "/nov(ember)?/": "eyenkanga", "/dec(ember)?/": "eyomnga", "/^su(n(day)?)?/": "^icawa", "/^mo(n(day)?)?/": "^umvulo", "/^tu(e(s(day)?)?)?/": "^ulwesibini", "/^we(d(nesday)?)?/": "^ulwesithathu", "/^th(u(r(s(day)?)?)?)?/": "^ulwesine", "/^fr(i(day)?)?/": "^ulwesihlanu", "/^sa(t(urday)?)?/": "^umgqibelo", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "xh-ZA"; /** * @overview datejs * @version 1.0.0-rc3 * @author Gregory Wild-Smith * @copyright 2015 Gregory Wild-Smith * @license MIT * @homepage https://github.com/abritinthebay/datejs */(function () { var $D = Date; var lang = Date.CultureStrings ? Date.CultureStrings.lang : null; var loggedKeys = {}; // for debug purposes. var getText = { getFromKey: function (key, countryCode) { var output; if (Date.CultureStrings && Date.CultureStrings[countryCode] && Date.CultureStrings[countryCode][key]) { output = Date.CultureStrings[countryCode][key]; } else { output = getText.buildFromDefault(key); } if (key.charAt(0) === "/") { // Assume it's a regex output = getText.buildFromRegex(key, countryCode); } return output; }, getFromObjectValues: function (obj, countryCode) { var key, output = {}; for(key in obj) { if (obj.hasOwnProperty(key)) { output[key] = getText.getFromKey(obj[key], countryCode); } } return output; }, getFromObjectKeys: function (obj, countryCode) { var key, output = {}; for(key in obj) { if (obj.hasOwnProperty(key)) { output[getText.getFromKey(key, countryCode)] = obj[key]; } } return output; }, getFromArray: function (arr, countryCode) { var output = []; for (var i=0; i < arr.length; i++){ if (i in arr) { output[i] = getText.getFromKey(arr[i], countryCode); } } return output; }, buildFromDefault: function (key) { var output, length, split, last; switch(key) { case "name": output = "en-US"; break; case "englishName": output = "English (United States)"; break; case "nativeName": output = "English (United States)"; break; case "twoDigitYearMax": output = 2049; break; case "firstDayOfWeek": output = 0; break; default: output = key; split = key.split("_"); length = split.length; if (length > 1 && key.charAt(0) !== "/") { // if the key isn't a regex and it has a split. last = split[(length - 1)].toLowerCase(); if (last === "initial" || last === "abbr") { output = split[0]; } } break; } return output; }, buildFromRegex: function (key, countryCode) { var output; if (Date.CultureStrings && Date.CultureStrings[countryCode] && Date.CultureStrings[countryCode][key]) { output = new RegExp(Date.CultureStrings[countryCode][key], "i"); } else { output = new RegExp(key.replace(new RegExp("/", "g"),""), "i"); } return output; } }; var shallowMerge = function (obj1, obj2) { for (var attrname in obj2) { if (obj2.hasOwnProperty(attrname)) { obj1[attrname] = obj2[attrname]; } } }; var __ = function (key, language) { var countryCode = (language) ? language : lang; loggedKeys[key] = key; if (typeof key === "object") { if (key instanceof Array) { return getText.getFromArray(key, countryCode); } else { return getText.getFromObjectKeys(key, countryCode); } } else { return getText.getFromKey(key, countryCode); } }; var loadI18nScript = function (code) { // paatterned after jQuery's getScript. var url = Date.Config.i18n + code + ".js"; var head = document.getElementsByTagName("head")[0] || document.documentElement; var script = document.createElement("script"); script.src = url; var completed = false; var events = { done: function (){} // placeholder function }; // Attach handlers for all browsers script.onload = script.onreadystatechange = function() { if ( !completed && (!this.readyState || this.readyState === "loaded" || this.readyState === "complete") ) { events.done(); head.removeChild(script); } }; setTimeout(function() { head.insertBefore(script, head.firstChild); }, 0); // allows return to execute first return { done: function (cb) { events.done = function() { if (cb) { setTimeout(cb,0); } }; } }; }; var buildInfo = { buildFromMethodHash: function (obj) { var key; for(key in obj) { if (obj.hasOwnProperty(key)) { obj[key] = buildInfo[obj[key]](); } } return obj; }, timeZoneDST: function () { var DST = { "CHADT": "+1345", "NZDT": "+1300", "AEDT": "+1100", "ACDT": "+1030", "AZST": "+0500", "IRDT": "+0430", "EEST": "+0300", "CEST": "+0200", "BST": "+0100", "PMDT": "-0200", "ADT": "-0300", "NDT": "-0230", "EDT": "-0400", "CDT": "-0500", "MDT": "-0600", "PDT": "-0700", "AKDT": "-0800", "HADT": "-0900" }; return __(DST); }, timeZoneStandard: function () { var standard = { "LINT": "+1400", "TOT": "+1300", "CHAST": "+1245", "NZST": "+1200", "NFT": "+1130", "SBT": "+1100", "AEST": "+1000", "ACST": "+0930", "JST": "+0900", "CWST": "+0845", "CT": "+0800", "ICT": "+0700", "MMT": "+0630", "BST": "+0600", "NPT": "+0545", "IST": "+0530", "PKT": "+0500", "AFT": "+0430", "MSK": "+0400", "IRST": "+0330", "FET": "+0300", "EET": "+0200", "CET": "+0100", "GMT": "+0000", "UTC": "+0000", "CVT": "-0100", "GST": "-0200", "BRT": "-0300", "NST": "-0330", "AST": "-0400", "EST": "-0500", "CST": "-0600", "MST": "-0700", "PST": "-0800", "AKST": "-0900", "MIT": "-0930", "HST": "-1000", "SST": "-1100", "BIT": "-1200" }; return __(standard); }, timeZones: function (data) { var zone; data.timezones = []; for (zone in data.abbreviatedTimeZoneStandard) { if (data.abbreviatedTimeZoneStandard.hasOwnProperty(zone)) { data.timezones.push({ name: zone, offset: data.abbreviatedTimeZoneStandard[zone]}); } } for (zone in data.abbreviatedTimeZoneDST) { if (data.abbreviatedTimeZoneDST.hasOwnProperty(zone)) { data.timezones.push({ name: zone, offset: data.abbreviatedTimeZoneDST[zone], dst: true}); } } return data.timezones; }, days: function () { return __(["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"]); }, dayAbbr: function () { return __(["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"]); }, dayShortNames: function () { return __(["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"]); }, dayFirstLetters: function () { return __(["S_Sun_Initial", "M_Mon_Initial", "T_Tues_Initial", "W_Wed_Initial", "T_Thu_Initial", "F_Fri_Initial", "S_Sat_Initial"]); }, months: function () { return __(["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"]); }, monthAbbr: function () { return __(["Jan_Abbr", "Feb_Abbr", "Mar_Abbr", "Apr_Abbr", "May_Abbr", "Jun_Abbr", "Jul_Abbr", "Aug_Abbr", "Sep_Abbr", "Oct_Abbr", "Nov_Abbr", "Dec_Abbr"]); }, formatPatterns: function () { return getText.getFromObjectValues({ shortDate: "M/d/yyyy", longDate: "dddd, MMMM dd, yyyy", shortTime: "h:mm tt", longTime: "h:mm:ss tt", fullDateTime: "dddd, MMMM dd, yyyy h:mm:ss tt", sortableDateTime: "yyyy-MM-ddTHH:mm:ss", universalSortableDateTime: "yyyy-MM-dd HH:mm:ssZ", rfc1123: "ddd, dd MMM yyyy HH:mm:ss", monthDay: "MMMM dd", yearMonth: "MMMM, yyyy" }, Date.i18n.currentLanguage()); }, regex: function () { return getText.getFromObjectValues({ inTheMorning: "/( in the )(morn(ing)?)\\b/", thisMorning: "/(this )(morn(ing)?)\\b/", amThisMorning: "/(\b\\d(am)? )(this )(morn(ing)?)/", inTheEvening: "/( in the )(even(ing)?)\\b/", thisEvening: "/(this )(even(ing)?)\\b/", pmThisEvening: "/(\b\\d(pm)? )(this )(even(ing)?)/", jan: "/jan(uary)?/", feb: "/feb(ruary)?/", mar: "/mar(ch)?/", apr: "/apr(il)?/", may: "/may/", jun: "/jun(e)?/", jul: "/jul(y)?/", aug: "/aug(ust)?/", sep: "/sep(t(ember)?)?/", oct: "/oct(ober)?/", nov: "/nov(ember)?/", dec: "/dec(ember)?/", sun: "/^su(n(day)?)?/", mon: "/^mo(n(day)?)?/", tue: "/^tu(e(s(day)?)?)?/", wed: "/^we(d(nesday)?)?/", thu: "/^th(u(r(s(day)?)?)?)?/", fri: "/fr(i(day)?)?/", sat: "/^sa(t(urday)?)?/", future: "/^next/", past: "/^last|past|prev(ious)?/", add: "/^(\\+|aft(er)?|from|hence)/", subtract: "/^(\\-|bef(ore)?|ago)/", yesterday: "/^yes(terday)?/", today: "/^t(od(ay)?)?/", tomorrow: "/^tom(orrow)?/", now: "/^n(ow)?/", millisecond: "/^ms|milli(second)?s?/", second: "/^sec(ond)?s?/", minute: "/^mn|min(ute)?s?/", hour: "/^h(our)?s?/", week: "/^w(eek)?s?/", month: "/^m(onth)?s?/", day: "/^d(ay)?s?/", year: "/^y(ear)?s?/", shortMeridian: "/^(a|p)/", longMeridian: "/^(a\\.?m?\\.?|p\\.?m?\\.?)/", timezone: "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/", ordinalSuffix: "/^\\s*(st|nd|rd|th)/", timeContext: "/^\\s*(\\:|a(?!u|p)|p)/" }, Date.i18n.currentLanguage()); } }; var CultureInfo = function () { var info = getText.getFromObjectValues({ name: "name", englishName: "englishName", nativeName: "nativeName", amDesignator: "AM", pmDesignator: "PM", firstDayOfWeek: "firstDayOfWeek", twoDigitYearMax: "twoDigitYearMax", dateElementOrder: "mdy" }, Date.i18n.currentLanguage()); var constructedInfo = buildInfo.buildFromMethodHash({ dayNames: "days", abbreviatedDayNames: "dayAbbr", shortestDayNames: "dayShortNames", firstLetterDayNames: "dayFirstLetters", monthNames: "months", abbreviatedMonthNames: "monthAbbr", formatPatterns: "formatPatterns", regexPatterns: "regex", abbreviatedTimeZoneDST: "timeZoneDST", abbreviatedTimeZoneStandard: "timeZoneStandard" }); shallowMerge(info, constructedInfo); buildInfo.timeZones(info); return info; }; $D.i18n = { __: function (key, lang) { return __(key, lang); }, currentLanguage: function () { return lang || "en-US"; }, setLanguage: function (code, force, cb) { var async = false; if (force || code === "en-US" || (!!Date.CultureStrings && !!Date.CultureStrings[code])) { lang = code; Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings.lang = code; Date.CultureInfo = new CultureInfo(); } else { if (!(!!Date.CultureStrings && !!Date.CultureStrings[code])) { if (typeof exports !== "undefined" && this.exports !== exports) { // we're in a Node enviroment, load it using require try { require("../i18n/" + code + ".js"); lang = code; Date.CultureStrings.lang = code; Date.CultureInfo = new CultureInfo(); } catch (e) { // var str = "The language for '" + code + "' could not be loaded by Node. It likely does not exist."; throw new Error("The DateJS IETF language tag '" + code + "' could not be loaded by Node. It likely does not exist."); } } else if (Date.Config && Date.Config.i18n) { // we know the location of the files, so lets load them async = true; loadI18nScript(code).done(function(){ lang = code; Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings.lang = code; Date.CultureInfo = new CultureInfo(); $D.Parsing.Normalizer.buildReplaceData(); // because this is async if ($D.Grammar) { $D.Grammar.buildGrammarFormats(); // so we can parse those strings... } if (cb) { setTimeout(cb,0); } }); } else { Date.console.error("The DateJS IETF language tag '" + code + "' is not available and has not been loaded."); return false; } } } $D.Parsing.Normalizer.buildReplaceData(); // rebuild normalizer strings if ($D.Grammar) { $D.Grammar.buildGrammarFormats(); // so we can parse those strings... } if (!async && cb) { setTimeout(cb,0); } }, getLoggedKeys: function () { return loggedKeys; }, updateCultureInfo: function () { Date.CultureInfo = new CultureInfo(); } }; $D.i18n.updateCultureInfo(); // run automatically }()); (function () { var $D = Date, $P = $D.prototype, p = function (s, l) { if (!l) { l = 2; } return ("000" + s).slice(l * -1); }; if (typeof window !== "undefined" && typeof window.console !== "undefined" && typeof window.console.log !== "undefined") { $D.console = console; // used only to raise non-critical errors if available } else { // set mock so we don't give errors. $D.console = { log: function(){}, error: function(){} }; } $D.Config = $D.Config || {}; $D.initOverloads = function() { /** * Overload of Date.now. Allows an alternate call for Date.now where it returns the * current Date as an object rather than just milliseconds since the Unix Epoch. * * Also provides an implementation of now() for browsers (IE<9) that don't have it. * * Backwards compatible so with work with either: * Date.now() [returns ms] * or * Date.now(true) [returns Date] */ if (!$D.now) { $D._now = function now() { return new Date().getTime(); }; } else if (!$D._now) { $D._now = $D.now; } $D.now = function (returnObj) { if (returnObj) { return $D.present(); } else { return $D._now(); } }; if ( !$P.toISOString ) { $P.toISOString = function() { return this.getUTCFullYear() + "-" + p(this.getUTCMonth() + 1) + "-" + p(this.getUTCDate()) + "T" + p(this.getUTCHours()) + ":" + p(this.getUTCMinutes()) + ":" + p(this.getUTCSeconds()) + "." + String( (this.getUTCMilliseconds()/1000).toFixed(3)).slice(2, 5) + "Z"; }; } // private if ( $P._toString === undefined ){ $P._toString = $P.toString; } }; $D.initOverloads(); /** * Gets a date that is set to the current date. The time is set to the start of the day (00:00 or 12:00 AM). * @return {Date} The current date. */ $D.today = function () { return new Date().clearTime(); }; /** * Gets a date that is set to the current date and time (same as new Date, but chainable) * @return {Date} The current date. */ $D.present = function () { return new Date(); }; /** * Compares the first date to the second date and returns an number indication of their relative values. * @param {Date} First Date object to compare [Required]. * @param {Date} Second Date object to compare to [Required]. * @return {Number} -1 = date1 is lessthan date2. 0 = values are equal. 1 = date1 is greaterthan date2. */ $D.compare = function (date1, date2) { if (isNaN(date1) || isNaN(date2)) { throw new Error(date1 + " - " + date2); } else if (date1 instanceof Date && date2 instanceof Date) { return (date1 < date2) ? -1 : (date1 > date2) ? 1 : 0; } else { throw new TypeError(date1 + " - " + date2); } }; /** * Compares the first Date object to the second Date object and returns true if they are equal. * @param {Date} First Date object to compare [Required] * @param {Date} Second Date object to compare to [Required] * @return {Boolean} true if dates are equal. false if they are not equal. */ $D.equals = function (date1, date2) { return (date1.compareTo(date2) === 0); }; /** * Gets the language appropriate day name when given the day number(0-6) * eg - 0 == Sunday * @return {String} The day name */ $D.getDayName = function (n) { return Date.CultureInfo.dayNames[n]; }; /** * Gets the day number (0-6) if given a CultureInfo specific string which is a valid dayName, abbreviatedDayName or shortestDayName (two char). * @param {String} The name of the day (eg. "Monday, "Mon", "tuesday", "tue", "We", "we"). * @return {Number} The day number */ $D.getDayNumberFromName = function (name) { var n = Date.CultureInfo.dayNames, m = Date.CultureInfo.abbreviatedDayNames, o = Date.CultureInfo.shortestDayNames, s = name.toLowerCase(); for (var i = 0; i < n.length; i++) { if (n[i].toLowerCase() === s || m[i].toLowerCase() === s || o[i].toLowerCase() === s) { return i; } } return -1; }; /** * Gets the month number (0-11) if given a Culture Info specific string which is a valid monthName or abbreviatedMonthName. * @param {String} The name of the month (eg. "February, "Feb", "october", "oct"). * @return {Number} The day number */ $D.getMonthNumberFromName = function (name) { var n = Date.CultureInfo.monthNames, m = Date.CultureInfo.abbreviatedMonthNames, s = name.toLowerCase(); for (var i = 0; i < n.length; i++) { if (n[i].toLowerCase() === s || m[i].toLowerCase() === s) { return i; } } return -1; }; /** * Gets the language appropriate month name when given the month number(0-11) * eg - 0 == January * @return {String} The month name */ $D.getMonthName = function (n) { return Date.CultureInfo.monthNames[n]; }; /** * Determines if the current date instance is within a LeapYear. * @param {Number} The year. * @return {Boolean} true if date is within a LeapYear, otherwise false. */ $D.isLeapYear = function (year) { return ((year % 4 === 0 && year % 100 !== 0) || year % 400 === 0); }; /** * Gets the number of days in the month, given a year and month value. Automatically corrects for LeapYear. * @param {Number} The year. * @param {Number} The month (0-11). * @return {Number} The number of days in the month. */ $D.getDaysInMonth = function (year, month) { if (!month && $D.validateMonth(year)) { month = year; year = Date.today().getFullYear(); } return [31, ($D.isLeapYear(year) ? 29 : 28), 31, 30, 31, 30, 31, 31, 30, 31, 30, 31][month]; }; $P.getDaysInMonth = function () { return $D.getDaysInMonth(this.getFullYear(), this.getMonth()); }; $D.getTimezoneAbbreviation = function (offset, dst) { var p, n = (dst || false) ? Date.CultureInfo.abbreviatedTimeZoneDST : Date.CultureInfo.abbreviatedTimeZoneStandard; for (p in n) { if (n.hasOwnProperty(p)) { if (n[p] === offset) { return p; } } } return null; }; $D.getTimezoneOffset = function (name, dst) { var i, a =[], z = Date.CultureInfo.timezones; if (!name) { name = (new Date()).getTimezone();} for (i = 0; i < z.length; i++) { if (z[i].name === name.toUpperCase()) { a.push(i); } } if (!z[a[0]]) { return null; } if (a.length === 1 || !dst) { return z[a[0]].offset; } else { for (i=0; i < a.length; i++) { if (z[a[i]].dst) { return z[a[i]].offset; } } } }; $D.getQuarter = function (d) { d = d || new Date(); // If no date supplied, use today var q = [1,2,3,4]; return q[Math.floor(d.getMonth() / 3)]; // ~~~ is a bitwise op. Faster than Math.floor }; $D.getDaysLeftInQuarter = function (d) { d = d || new Date(); var qEnd = new Date(d); qEnd.setMonth(qEnd.getMonth() + 3 - qEnd.getMonth() % 3, 0); return Math.floor((qEnd - d) / 8.64e7); }; // private var validate = function (n, min, max, name) { name = name ? name : "Object"; if (typeof n === "undefined") { return false; } else if (typeof n !== "number") { throw new TypeError(n + " is not a Number."); } else if (n < min || n > max) { // As failing validation is *not* an exceptional circumstance // lets not throw a RangeError Exception here. // It's semantically correct but it's not sensible. return false; } return true; }; /** * Validates the number is within an acceptable range for milliseconds [0-999]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateMillisecond = function (value) { return validate(value, 0, 999, "millisecond"); }; /** * Validates the number is within an acceptable range for seconds [0-59]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateSecond = function (value) { return validate(value, 0, 59, "second"); }; /** * Validates the number is within an acceptable range for minutes [0-59]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateMinute = function (value) { return validate(value, 0, 59, "minute"); }; /** * Validates the number is within an acceptable range for hours [0-23]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateHour = function (value) { return validate(value, 0, 23, "hour"); }; /** * Validates the number is within an acceptable range for the days in a month [0-MaxDaysInMonth]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateDay = function (value, year, month) { if (year === undefined || year === null || month === undefined || month === null) { return false;} return validate(value, 1, $D.getDaysInMonth(year, month), "day"); }; /** * Validates the number is within an acceptable range for months [0-11]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateWeek = function (value) { return validate(value, 0, 53, "week"); }; /** * Validates the number is within an acceptable range for months [0-11]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateMonth = function (value) { return validate(value, 0, 11, "month"); }; /** * Validates the number is within an acceptable range for years. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateYear = function (value) { /** * Per ECMAScript spec the range of times supported by Date objects is * exactly -100,000,000 days to +100,000,000 days measured relative to * midnight at the beginning of 01 January, 1970 UTC. * This gives a range of 8,640,000,000,000,000 milliseconds to either * side of 01 January, 1970 UTC. * * Earliest possible date: Tue, 20 Apr 271,822 B.C. 00:00:00 UTC * Latest possible date: Sat, 13 Sep 275,760 00:00:00 UTC */ return validate(value, -271822, 275760, "year"); }; $D.validateTimezone = function(value) { var timezones = {"ACDT":1,"ACST":1,"ACT":1,"ADT":1,"AEDT":1,"AEST":1,"AFT":1,"AKDT":1,"AKST":1,"AMST":1,"AMT":1,"ART":1,"AST":1,"AWDT":1,"AWST":1,"AZOST":1,"AZT":1,"BDT":1,"BIOT":1,"BIT":1,"BOT":1,"BRT":1,"BST":1,"BTT":1,"CAT":1,"CCT":1,"CDT":1,"CEDT":1,"CEST":1,"CET":1,"CHADT":1,"CHAST":1,"CHOT":1,"ChST":1,"CHUT":1,"CIST":1,"CIT":1,"CKT":1,"CLST":1,"CLT":1,"COST":1,"COT":1,"CST":1,"CT":1,"CVT":1,"CWST":1,"CXT":1,"DAVT":1,"DDUT":1,"DFT":1,"EASST":1,"EAST":1,"EAT":1,"ECT":1,"EDT":1,"EEDT":1,"EEST":1,"EET":1,"EGST":1,"EGT":1,"EIT":1,"EST":1,"FET":1,"FJT":1,"FKST":1,"FKT":1,"FNT":1,"GALT":1,"GAMT":1,"GET":1,"GFT":1,"GILT":1,"GIT":1,"GMT":1,"GST":1,"GYT":1,"HADT":1,"HAEC":1,"HAST":1,"HKT":1,"HMT":1,"HOVT":1,"HST":1,"ICT":1,"IDT":1,"IOT":1,"IRDT":1,"IRKT":1,"IRST":1,"IST":1,"JST":1,"KGT":1,"KOST":1,"KRAT":1,"KST":1,"LHST":1,"LINT":1,"MAGT":1,"MART":1,"MAWT":1,"MDT":1,"MET":1,"MEST":1,"MHT":1,"MIST":1,"MIT":1,"MMT":1,"MSK":1,"MST":1,"MUT":1,"MVT":1,"MYT":1,"NCT":1,"NDT":1,"NFT":1,"NPT":1,"NST":1,"NT":1,"NUT":1,"NZDT":1,"NZST":1,"OMST":1,"ORAT":1,"PDT":1,"PET":1,"PETT":1,"PGT":1,"PHOT":1,"PHT":1,"PKT":1,"PMDT":1,"PMST":1,"PONT":1,"PST":1,"PYST":1,"PYT":1,"RET":1,"ROTT":1,"SAKT":1,"SAMT":1,"SAST":1,"SBT":1,"SCT":1,"SGT":1,"SLST":1,"SRT":1,"SST":1,"SYOT":1,"TAHT":1,"THA":1,"TFT":1,"TJT":1,"TKT":1,"TLT":1,"TMT":1,"TOT":1,"TVT":1,"UCT":1,"ULAT":1,"UTC":1,"UYST":1,"UYT":1,"UZT":1,"VET":1,"VLAT":1,"VOLT":1,"VOST":1,"VUT":1,"WAKT":1,"WAST":1,"WAT":1,"WEDT":1,"WEST":1,"WET":1,"WST":1,"YAKT":1,"YEKT":1,"Z":1}; return (timezones[value] === 1); }; $D.validateTimezoneOffset= function(value) { // timezones go from +14hrs to -12hrs, the +X hours are negative offsets. return (value > -841 && value < 721); }; }()); (function () { var $D = Date, $P = $D.prototype, p = function (s, l) { if (!l) { l = 2; } return ("000" + s).slice(l * -1); }; var validateConfigObject = function (obj) { var result = {}, self = this, prop, testFunc; testFunc = function (prop, func, value) { if (prop === "day") { var month = (obj.month !== undefined) ? obj.month : self.getMonth(); var year = (obj.year !== undefined) ? obj.year : self.getFullYear(); return $D[func](value, year, month); } else { return $D[func](value); } }; for (prop in obj) { if (Object.prototype.hasOwnProperty.call(obj, prop)) { var func = "validate" + prop.charAt(0).toUpperCase() + prop.slice(1); if ($D[func] && obj[prop] !== null && testFunc(prop, func, obj[prop])) { result[prop] = obj[prop]; } } } return result; }; /** * Resets the time of this Date object to 12:00 AM (00:00), which is the start of the day. * @param {Boolean} .clone() this date instance before clearing Time * @return {Date} this */ $P.clearTime = function () { this.setHours(0); this.setMinutes(0); this.setSeconds(0); this.setMilliseconds(0); return this; }; /** * Resets the time of this Date object to the current time ('now'). * @return {Date} this */ $P.setTimeToNow = function () { var n = new Date(); this.setHours(n.getHours()); this.setMinutes(n.getMinutes()); this.setSeconds(n.getSeconds()); this.setMilliseconds(n.getMilliseconds()); return this; }; /** * Returns a new Date object that is an exact date and time copy of the original instance. * @return {Date} A new Date instance */ $P.clone = function () { return new Date(this.getTime()); }; /** * Compares this instance to a Date object and returns an number indication of their relative values. * @param {Date} Date object to compare [Required] * @return {Number} -1 = this is lessthan date. 0 = values are equal. 1 = this is greaterthan date. */ $P.compareTo = function (date) { return Date.compare(this, date); }; /** * Compares this instance to another Date object and returns true if they are equal. * @param {Date} Date object to compare. If no date to compare, new Date() [now] is used. * @return {Boolean} true if dates are equal. false if they are not equal. */ $P.equals = function (date) { return Date.equals(this, (date !== undefined ? date : new Date())); }; /** * Determines if this instance is between a range of two dates or equal to either the start or end dates. * @param {Date} Start of range [Required] * @param {Date} End of range [Required] * @return {Boolean} true is this is between or equal to the start and end dates, else false */ $P.between = function (start, end) { return this.getTime() >= start.getTime() && this.getTime() <= end.getTime(); }; /** * Determines if this date occurs after the date to compare to. * @param {Date} Date object to compare. If no date to compare, new Date() ("now") is used. * @return {Boolean} true if this date instance is greater than the date to compare to (or "now"), otherwise false. */ $P.isAfter = function (date) { return this.compareTo(date || new Date()) === 1; }; /** * Determines if this date occurs before the date to compare to. * @param {Date} Date object to compare. If no date to compare, new Date() ("now") is used. * @return {Boolean} true if this date instance is less than the date to compare to (or "now"). */ $P.isBefore = function (date) { return (this.compareTo(date || new Date()) === -1); }; /** * Determines if the current Date instance occurs today. * @return {Boolean} true if this date instance is 'today', otherwise false. */ /** * Determines if the current Date instance occurs on the same Date as the supplied 'date'. * If no 'date' to compare to is provided, the current Date instance is compared to 'today'. * @param {date} Date object to compare. If no date to compare, the current Date ("now") is used. * @return {Boolean} true if this Date instance occurs on the same Day as the supplied 'date'. */ $P.isToday = $P.isSameDay = function (date) { return this.clone().clearTime().equals((date || new Date()).clone().clearTime()); }; /** * Adds the specified number of milliseconds to this instance. * @param {Number} The number of milliseconds to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addMilliseconds = function (value) { if (!value) { return this; } this.setTime(this.getTime() + value * 1); return this; }; /** * Adds the specified number of seconds to this instance. * @param {Number} The number of seconds to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addSeconds = function (value) { if (!value) { return this; } return this.addMilliseconds(value * 1000); }; /** * Adds the specified number of seconds to this instance. * @param {Number} The number of seconds to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addMinutes = function (value) { if (!value) { return this; } return this.addMilliseconds(value * 60000); // 60*1000 }; /** * Adds the specified number of hours to this instance. * @param {Number} The number of hours to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addHours = function (value) { if (!value) { return this; } return this.addMilliseconds(value * 3600000); // 60*60*1000 }; /** * Adds the specified number of days to this instance. * @param {Number} The number of days to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addDays = function (value) { if (!value) { return this; } this.setDate(this.getDate() + value * 1); return this; }; /** * Adds the specified number of weekdays (ie - not sat or sun) to this instance. * @param {Number} The number of days to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addWeekdays = function (value) { if (!value) { return this; } var day = this.getDay(); var weeks = (Math.ceil(Math.abs(value)/7)); if (day === 0 || day === 6) { if (value > 0) { this.next().monday(); this.addDays(-1); day = this.getDay(); } } if (value < 0) { while (value < 0) { this.addDays(-1); day = this.getDay(); if (day !== 0 && day !== 6) { value++; } } return this; } else if (value > 5 || (6-day) <= value) { value = value + (weeks * 2); } return this.addDays(value); }; /** * Adds the specified number of weeks to this instance. * @param {Number} The number of weeks to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addWeeks = function (value) { if (!value) { return this; } return this.addDays(value * 7); }; /** * Adds the specified number of months to this instance. * @param {Number} The number of months to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addMonths = function (value) { if (!value) { return this; } var n = this.getDate(); this.setDate(1); this.setMonth(this.getMonth() + value * 1); this.setDate(Math.min(n, $D.getDaysInMonth(this.getFullYear(), this.getMonth()))); return this; }; $P.addQuarters = function (value) { if (!value) { return this; } // note this will take you to the same point in the quarter as you are now. // i.e. - if you are 15 days into the quarter you'll be 15 days into the resulting one. // bonus: this allows adding fractional quarters return this.addMonths(value * 3); }; /** * Adds the specified number of years to this instance. * @param {Number} The number of years to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addYears = function (value) { if (!value) { return this; } return this.addMonths(value * 12); }; /** * Adds (or subtracts) to the value of the years, months, weeks, days, hours, minutes, seconds, milliseconds of the date instance using given configuration object. Positive and Negative values allowed. * Example

	Date.today().add( { days: 1, months: 1 } )

	new Date().add( { years: -1 } )
	
* @param {Object} Configuration object containing attributes (months, days, etc.) * @return {Date} this */ $P.add = function (config) { if (typeof config === "number") { this._orient = config; return this; } var x = config; if (x.day) { // If we should be a different date than today (eg: for 'tomorrow -1d', etc). // Should only effect parsing, not direct usage (eg, Finish and FinishExact) if ((x.day - this.getDate()) !== 0) { this.setDate(x.day); } } if (x.milliseconds) { this.addMilliseconds(x.milliseconds); } if (x.seconds) { this.addSeconds(x.seconds); } if (x.minutes) { this.addMinutes(x.minutes); } if (x.hours) { this.addHours(x.hours); } if (x.weeks) { this.addWeeks(x.weeks); } if (x.months) { this.addMonths(x.months); } if (x.years) { this.addYears(x.years); } if (x.days) { this.addDays(x.days); } return this; }; /** * Get the week number. Week one (1) is the week which contains the first Thursday of the year. Monday is considered the first day of the week. * The .getWeek() function does NOT convert the date to UTC. The local datetime is used. * Please use .getISOWeek() to get the week of the UTC converted date. * @return {Number} 1 to 53 */ $P.getWeek = function (utc) { // Create a copy of this date object var self, target = new Date(this.valueOf()); if (utc) { target.addMinutes(target.getTimezoneOffset()); self = target.clone(); } else { self = this; } // ISO week date weeks start on monday // so correct the day number var dayNr = (self.getDay() + 6) % 7; // ISO 8601 states that week 1 is the week // with the first thursday of that year. // Set the target date to the thursday in the target week target.setDate(target.getDate() - dayNr + 3); // Store the millisecond value of the target date var firstThursday = target.valueOf(); // Set the target to the first thursday of the year // First set the target to january first target.setMonth(0, 1); // Not a thursday? Correct the date to the next thursday if (target.getDay() !== 4) { target.setMonth(0, 1 + ((4 - target.getDay()) + 7) % 7); } // The weeknumber is the number of weeks between the // first thursday of the year and the thursday in the target week return 1 + Math.ceil((firstThursday - target) / 604800000); // 604800000 = 7 * 24 * 3600 * 1000 }; /** * Get the ISO 8601 week number. Week one ("01") is the week which contains the first Thursday of the year. Monday is considered the first day of the week. * The .getISOWeek() function does convert the date to it's UTC value. Please use .getWeek() to get the week of the local date. * @return {String} "01" to "53" */ $P.getISOWeek = function () { return p(this.getWeek(true)); }; /** * Moves the date to Monday of the week set. Week one (1) is the week which contains the first Thursday of the year. * @param {Number} A Number (1 to 53) that represents the week of the year. * @return {Date} this */ $P.setWeek = function (n) { if ((n - this.getWeek()) === 0) { if (this.getDay() !== 1) { return this.moveToDayOfWeek(1, (this.getDay() > 1 ? -1 : 1)); } else { return this; } } else { return this.moveToDayOfWeek(1, (this.getDay() > 1 ? -1 : 1)).addWeeks(n - this.getWeek()); } }; $P.setQuarter = function (qtr) { var month = Math.abs(((qtr-1) * 3) + 1); return this.setMonth(month, 1); }; $P.getQuarter = function () { return Date.getQuarter(this); }; $P.getDaysLeftInQuarter = function () { return Date.getDaysLeftInQuarter(this); }; /** * Moves the date to the next n'th occurrence of the dayOfWeek starting from the beginning of the month. The number (-1) is a magic number and will return the last occurrence of the dayOfWeek in the month. * @param {Number} The dayOfWeek to move to * @param {Number} The n'th occurrence to move to. Use (-1) to return the last occurrence in the month * @return {Date} this */ $P.moveToNthOccurrence = function (dayOfWeek, occurrence) { if (dayOfWeek === "Weekday") { if (occurrence > 0) { this.moveToFirstDayOfMonth(); if (this.is().weekday()) { occurrence -= 1; } } else if (occurrence < 0) { this.moveToLastDayOfMonth(); if (this.is().weekday()) { occurrence += 1; } } else { return this; } return this.addWeekdays(occurrence); } var shift = 0; if (occurrence > 0) { shift = occurrence - 1; } else if (occurrence === -1) { this.moveToLastDayOfMonth(); if (this.getDay() !== dayOfWeek) { this.moveToDayOfWeek(dayOfWeek, -1); } return this; } return this.moveToFirstDayOfMonth().addDays(-1).moveToDayOfWeek(dayOfWeek, +1).addWeeks(shift); }; var moveToN = function (getFunc, addFunc, nVal) { return function (value, orient) { var diff = (value - this[getFunc]() + nVal * (orient || +1)) % nVal; return this[addFunc]((diff === 0) ? diff += nVal * (orient || +1) : diff); }; }; /** * Move to the next or last dayOfWeek based on the orient value. * @param {Number} The dayOfWeek to move to * @param {Number} Forward (+1) or Back (-1). Defaults to +1. [Optional] * @return {Date} this */ $P.moveToDayOfWeek = moveToN("getDay", "addDays", 7); /** * Move to the next or last month based on the orient value. * @param {Number} The month to move to. 0 = January, 11 = December * @param {Number} Forward (+1) or Back (-1). Defaults to +1. [Optional] * @return {Date} this */ $P.moveToMonth = moveToN("getMonth", "addMonths", 12); /** * Get the Ordinate of the current day ("th", "st", "rd"). * @return {String} */ $P.getOrdinate = function () { var num = this.getDate(); return ord(num); }; /** * Get the Ordinal day (numeric day number) of the year, adjusted for leap year. * @return {Number} 1 through 365 (366 in leap years) */ $P.getOrdinalNumber = function () { return Math.ceil((this.clone().clearTime() - new Date(this.getFullYear(), 0, 1)) / 86400000) + 1; }; /** * Get the time zone abbreviation of the current date. * @return {String} The abbreviated time zone name (e.g. "EST") */ $P.getTimezone = function () { return $D.getTimezoneAbbreviation(this.getUTCOffset(), this.isDaylightSavingTime()); }; $P.setTimezoneOffset = function (offset) { var here = this.getTimezoneOffset(), there = Number(offset) * -6 / 10; return (there || there === 0) ? this.addMinutes(there - here) : this; }; $P.setTimezone = function (offset) { return this.setTimezoneOffset($D.getTimezoneOffset(offset)); }; /** * Indicates whether Daylight Saving Time is observed in the current time zone. * @return {Boolean} true|false */ $P.hasDaylightSavingTime = function () { return (Date.today().set({month: 0, day: 1}).getTimezoneOffset() !== Date.today().set({month: 6, day: 1}).getTimezoneOffset()); }; /** * Indicates whether this Date instance is within the Daylight Saving Time range for the current time zone. * @return {Boolean} true|false */ $P.isDaylightSavingTime = function () { return Date.today().set({month: 0, day: 1}).getTimezoneOffset() !== this.getTimezoneOffset(); }; /** * Get the offset from UTC of the current date. * @return {String} The 4-character offset string prefixed with + or - (e.g. "-0500") */ $P.getUTCOffset = function (offset) { var n = (offset || this.getTimezoneOffset()) * -10 / 6, r; if (n < 0) { r = (n - 10000).toString(); return r.charAt(0) + r.substr(2); } else { r = (n + 10000).toString(); return "+" + r.substr(1); } }; /** * Returns the number of milliseconds between this date and date. * @param {Date} Defaults to now * @return {Number} The diff in milliseconds */ $P.getElapsed = function (date) { return (date || new Date()) - this; }; /** * Set the value of year, month, day, hour, minute, second, millisecond of date instance using given configuration object. * Example

	Date.today().set( { day: 20, month: 1 } )

	new Date().set( { millisecond: 0 } )
	
* * @param {Object} Configuration object containing attributes (month, day, etc.) * @return {Date} this */ $P.set = function (config) { config = validateConfigObject.call(this, config); var key; for (key in config) { if (Object.prototype.hasOwnProperty.call(config, key)) { var name = key.charAt(0).toUpperCase() + key.slice(1); var addFunc, getFunc; if (key !== "week" && key !== "month" && key !== "timezone" && key !== "timezoneOffset") { name += "s"; } addFunc = "add" + name; getFunc = "get" + name; if (key === "month") { addFunc = addFunc + "s"; } else if (key === "year"){ getFunc = "getFullYear"; } if (key !== "day" && key !== "timezone" && key !== "timezoneOffset" && key !== "week" && key !== "hour") { this[addFunc](config[key] - this[getFunc]()); } else if ( key === "timezone"|| key === "timezoneOffset" || key === "week" || key === "hour") { this["set"+name](config[key]); } } } // day has to go last because you can't validate the day without first knowing the month if (config.day) { this.addDays(config.day - this.getDate()); } return this; }; /** * Moves the date to the first day of the month. * @return {Date} this */ $P.moveToFirstDayOfMonth = function () { return this.set({ day: 1 }); }; /** * Moves the date to the last day of the month. * @return {Date} this */ $P.moveToLastDayOfMonth = function () { return this.set({ day: $D.getDaysInMonth(this.getFullYear(), this.getMonth())}); }; /** * Converts the value of the current Date object to its equivalent string representation. * Format Specifiers * CUSTOM DATE AND TIME FORMAT STRINGS * Format Description Example * ------ --------------------------------------------------------------------------- ----------------------- * s The seconds of the minute between 0-59. "0" to "59" * ss The seconds of the minute with leading zero if required. "00" to "59" * * m The minute of the hour between 0-59. "0" or "59" * mm The minute of the hour with leading zero if required. "00" or "59" * * h The hour of the day between 1-12. "1" to "12" * hh The hour of the day with leading zero if required. "01" to "12" * * H The hour of the day between 0-23. "0" to "23" * HH The hour of the day with leading zero if required. "00" to "23" * * d The day of the month between 1 and 31. "1" to "31" * dd The day of the month with leading zero if required. "01" to "31" * ddd Abbreviated day name. Date.CultureInfo.abbreviatedDayNames. "Mon" to "Sun" * dddd The full day name. Date.CultureInfo.dayNames. "Monday" to "Sunday" * * M The month of the year between 1-12. "1" to "12" * MM The month of the year with leading zero if required. "01" to "12" * MMM Abbreviated month name. Date.CultureInfo.abbreviatedMonthNames. "Jan" to "Dec" * MMMM The full month name. Date.CultureInfo.monthNames. "January" to "December" * * yy The year as a two-digit number. "99" or "08" * yyyy The full four digit year. "1999" or "2008" * * t Displays the first character of the A.M./P.M. designator. "A" or "P" * Date.CultureInfo.amDesignator or Date.CultureInfo.pmDesignator * tt Displays the A.M./P.M. designator. "AM" or "PM" * Date.CultureInfo.amDesignator or Date.CultureInfo.pmDesignator * * S The ordinal suffix ("st, "nd", "rd" or "th") of the current day. "st, "nd", "rd" or "th" * * STANDARD DATE AND TIME FORMAT STRINGS * Format Description Example *------ --------------------------------------------------------------------------- ----------------------- * d The CultureInfo shortDate Format Pattern "M/d/yyyy" * D The CultureInfo longDate Format Pattern "dddd, MMMM dd, yyyy" * F The CultureInfo fullDateTime Format Pattern "dddd, MMMM dd, yyyy h:mm:ss tt" * m The CultureInfo monthDay Format Pattern "MMMM dd" * r The CultureInfo rfc1123 Format Pattern "ddd, dd MMM yyyy HH:mm:ss GMT" * s The CultureInfo sortableDateTime Format Pattern "yyyy-MM-ddTHH:mm:ss" * t The CultureInfo shortTime Format Pattern "h:mm tt" * T The CultureInfo longTime Format Pattern "h:mm:ss tt" * u The CultureInfo universalSortableDateTime Format Pattern "yyyy-MM-dd HH:mm:ssZ" * y The CultureInfo yearMonth Format Pattern "MMMM, yyyy" * * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @return {String} A string representation of the current Date object. */ var ord = function (n) { switch (n * 1) { case 1: case 21: case 31: return "st"; case 2: case 22: return "nd"; case 3: case 23: return "rd"; default: return "th"; } }; var parseStandardFormats = function (format) { var y, c = Date.CultureInfo.formatPatterns; switch (format) { case "d": return this.toString(c.shortDate); case "D": return this.toString(c.longDate); case "F": return this.toString(c.fullDateTime); case "m": return this.toString(c.monthDay); case "r": case "R": y = this.clone().addMinutes(this.getTimezoneOffset()); return y.toString(c.rfc1123) + " GMT"; case "s": return this.toString(c.sortableDateTime); case "t": return this.toString(c.shortTime); case "T": return this.toString(c.longTime); case "u": y = this.clone().addMinutes(this.getTimezoneOffset()); return y.toString(c.universalSortableDateTime); case "y": return this.toString(c.yearMonth); default: return false; } }; var parseFormatStringsClosure = function (context) { return function (m) { if (m.charAt(0) === "\\") { return m.replace("\\", ""); } switch (m) { case "hh": return p(context.getHours() < 13 ? (context.getHours() === 0 ? 12 : context.getHours()) : (context.getHours() - 12)); case "h": return context.getHours() < 13 ? (context.getHours() === 0 ? 12 : context.getHours()) : (context.getHours() - 12); case "HH": return p(context.getHours()); case "H": return context.getHours(); case "mm": return p(context.getMinutes()); case "m": return context.getMinutes(); case "ss": return p(context.getSeconds()); case "s": return context.getSeconds(); case "yyyy": return p(context.getFullYear(), 4); case "yy": return p(context.getFullYear()); case "y": return context.getFullYear(); case "E": case "dddd": return Date.CultureInfo.dayNames[context.getDay()]; case "ddd": return Date.CultureInfo.abbreviatedDayNames[context.getDay()]; case "dd": return p(context.getDate()); case "d": return context.getDate(); case "MMMM": return Date.CultureInfo.monthNames[context.getMonth()]; case "MMM": return Date.CultureInfo.abbreviatedMonthNames[context.getMonth()]; case "MM": return p((context.getMonth() + 1)); case "M": return context.getMonth() + 1; case "t": return context.getHours() < 12 ? Date.CultureInfo.amDesignator.substring(0, 1) : Date.CultureInfo.pmDesignator.substring(0, 1); case "tt": return context.getHours() < 12 ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator; case "S": return ord(context.getDate()); case "W": return context.getWeek(); case "WW": return context.getISOWeek(); case "Q": return "Q" + context.getQuarter(); case "q": return String(context.getQuarter()); case "z": return context.getTimezone(); case "Z": case "X": return Date.getTimezoneOffset(context.getTimezone()); case "ZZ": // Timezone offset in seconds return context.getTimezoneOffset() * -60; case "u": return context.getDay(); case "L": return ($D.isLeapYear(context.getFullYear())) ? 1 : 0; case "B": // Swatch Internet Time (.beats) return "@"+((context.getUTCSeconds() + (context.getUTCMinutes()*60) + ((context.getUTCHours()+1)*3600))/86.4); default: return m; } }; }; $P.toString = function (format, ignoreStandards) { // Standard Date and Time Format Strings. Formats pulled from CultureInfo file and // may vary by culture. if (!ignoreStandards && format && format.length === 1) { output = parseStandardFormats.call(this, format); if (output) { return output; } } var parseFormatStrings = parseFormatStringsClosure(this); return format ? format.replace(/((\\)?(dd?d?d?|MM?M?M?|yy?y?y?|hh?|HH?|mm?|ss?|tt?|S|q|Q|WW?W?W?)(?![^\[]*\]))/g, parseFormatStrings).replace(/\[|\]/g, "") : this._toString(); }; }()); /************************************************************* * SugarPak - Domain Specific Language - Syntactical Sugar * *************************************************************/ (function () { var $D = Date, $P = $D.prototype, $N = Number.prototype; // private $P._orient = +1; // private $P._nth = null; // private $P._is = false; // private $P._same = false; // private $P._isSecond = false; // private $N._dateElement = "days"; /** * Moves the date to the next instance of a date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.today().next().friday();
	Date.today().next().fri();
	Date.today().next().march();
	Date.today().next().mar();
	Date.today().next().week();
	
* * @return {Date} date */ $P.next = function () { this._move = true; this._orient = +1; return this; }; /** * Creates a new Date (Date.today()) and moves the date to the next instance of the date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.next().friday();
	Date.next().fri();
	Date.next().march();
	Date.next().mar();
	Date.next().week();
	
* * @return {Date} date */ $D.next = function () { return $D.today().next(); }; /** * Moves the date to the previous instance of a date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.today().last().friday();
	Date.today().last().fri();
	Date.today().last().march();
	Date.today().last().mar();
	Date.today().last().week();
	
* * @return {Date} date */ $P.last = $P.prev = $P.previous = function () { this._move = true; this._orient = -1; return this; }; /** * Creates a new Date (Date.today()) and moves the date to the previous instance of the date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.last().friday();
	Date.last().fri();
	Date.previous().march();
	Date.prev().mar();
	Date.last().week();
	
* * @return {Date} date */ $D.last = $D.prev = $D.previous = function () { return $D.today().last(); }; /** * Performs a equality check when followed by either a month name, day name or .weekday() function. * Example

	Date.today().is().friday(); // true|false
	Date.today().is().fri();
	Date.today().is().march();
	Date.today().is().mar();
	
* * @return {Boolean} true|false */ $P.is = function () { this._is = true; return this; }; /** * Determines if two date objects occur on/in exactly the same instance of the subsequent date part function. * The function .same() must be followed by a date part function (example: .day(), .month(), .year(), etc). * * An optional Date can be passed in the date part function. If now date is passed as a parameter, 'Now' is used. * * The following example demonstrates how to determine if two dates fall on the exact same day. * * Example

	var d1 = Date.today(); // today at 00:00
	var d2 = new Date();   // exactly now.

	// Do they occur on the same day?
	d1.same().day(d2); // true
	
	// Do they occur on the same hour?
	d1.same().hour(d2); // false, unless d2 hour is '00' (midnight).
	
	// What if it's the same day, but one year apart?
	var nextYear = Date.today().add(1).year();

	d1.same().day(nextYear); // false, because the dates must occur on the exact same day. 
	
* * Scenario: Determine if a given date occurs during some week period 2 months from now. * * Example

	var future = Date.today().add(2).months();
	return someDate.same().week(future); // true|false;
	
* * @return {Boolean} true|false */ $P.same = function () { this._same = true; this._isSecond = false; return this; }; /** * Determines if the current date/time occurs during Today. Must be preceded by the .is() function. * Example

	someDate.is().today();    // true|false
	new Date().is().today();  // true
	Date.today().is().today();// true
	Date.today().add(-1).day().is().today(); // false
	
* * @return {Boolean} true|false */ $P.today = function () { return this.same().day(); }; /** * Determines if the current date is a weekday. This function must be preceded by the .is() function. * Example

	Date.today().is().weekday(); // true|false
	
* * @return {Boolean} true|false */ $P.weekday = function () { if (this._nth) { return df("Weekday").call(this); } if (this._move) { return this.addWeekdays(this._orient); } if (this._is) { this._is = false; return (!this.is().sat() && !this.is().sun()); } return false; }; /** * Determines if the current date is on the weekend. This function must be preceded by the .is() function. * Example

	Date.today().is().weekend(); // true|false
	
* * @return {Boolean} true|false */ $P.weekend = function () { if (this._is) { this._is = false; return (this.is().sat() || this.is().sun()); } return false; }; /** * Sets the Time of the current Date instance. A string "6:15 pm" or config object {hour:18, minute:15} are accepted. * Example

	// Set time to 6:15pm with a String
	Date.today().at("6:15pm");

	// Set time to 6:15pm with a config object
	Date.today().at({hour:18, minute:15});
	
* * @return {Date} date */ $P.at = function (time) { return (typeof time === "string") ? $D.parse(this.toString("d") + " " + time) : this.set(time); }; /** * Creates a new Date() and adds this (Number) to the date based on the preceding date element function (eg. second|minute|hour|day|month|year). * Example

	// Undeclared Numbers must be wrapped with parentheses. Requirment of JavaScript.
	(3).days().fromNow();
	(6).months().fromNow();

	// Declared Number variables do not require parentheses. 
	var n = 6;
	n.months().fromNow();
	
* * @return {Date} A new Date instance */ $N.fromNow = $N.after = function (date) { var c = {}; c[this._dateElement] = this; return ((!date) ? new Date() : date.clone()).add(c); }; /** * Creates a new Date() and subtract this (Number) from the date based on the preceding date element function (eg. second|minute|hour|day|month|year). * Example

	// Undeclared Numbers must be wrapped with parentheses. Requirment of JavaScript.
	(3).days().ago();
	(6).months().ago();

	// Declared Number variables do not require parentheses. 
	var n = 6;
	n.months().ago();
	
* * @return {Date} A new Date instance */ $N.ago = $N.before = function (date) { var c = {}, s = (this._dateElement[this._dateElement.length-1] !== "s") ? this._dateElement + "s" : this._dateElement; c[s] = this * -1; return ((!date) ? new Date() : date.clone()).add(c); }; // Do NOT modify the following string tokens. These tokens are used to build dynamic functions. // All culture-specific strings can be found in the CultureInfo files. var dx = ("sunday monday tuesday wednesday thursday friday saturday").split(/\s/), mx = ("january february march april may june july august september october november december").split(/\s/), px = ("Millisecond Second Minute Hour Day Week Month Year Quarter Weekday").split(/\s/), pxf = ("Milliseconds Seconds Minutes Hours Date Week Month FullYear Quarter").split(/\s/), nth = ("final first second third fourth fifth").split(/\s/), de; /** * Returns an object literal of all the date parts. * Example

	var o = new Date().toObject();
	
	// { year: 2008, month: 4, week: 20, day: 13, hour: 18, minute: 9, second: 32, millisecond: 812 }
	
	// The object properties can be referenced directly from the object.
	
	alert(o.day);  // alerts "13"
	alert(o.year); // alerts "2008"
	
* * @return {Date} An object literal representing the original date object. */ $P.toObject = function () { var o = {}; for (var i = 0; i < px.length; i++) { if (this["get" + pxf[i]]) { o[px[i].toLowerCase()] = this["get" + pxf[i]](); } } return o; }; /** * Returns a date created from an object literal. Ignores the .week property if set in the config. * Example

	var o = new Date().toObject();
	
	return Date.fromObject(o); // will return the same date. 

	var o2 = {month: 1, day: 20, hour: 18}; // birthday party!
	Date.fromObject(o2);
	
* * @return {Date} An object literal representing the original date object. */ $D.fromObject = function(config) { config.week = null; return Date.today().set(config); }; // Create day name functions and abbreviated day name functions (eg. monday(), friday(), fri()). var df = function (n) { return function () { if (this._is) { this._is = false; return this.getDay() === n; } if (this._move) { this._move = null; } if (this._nth !== null) { // If the .second() function was called earlier, remove the _orient // from the date, and then continue. // This is required because 'second' can be used in two different context. // // Example // // Date.today().add(1).second(); // Date.march().second().monday(); // // Things get crazy with the following... // Date.march().add(1).second().second().monday(); // but it works!! // if (this._isSecond) { this.addSeconds(this._orient * -1); } // make sure we reset _isSecond this._isSecond = false; var ntemp = this._nth; this._nth = null; var temp = this.clone().moveToLastDayOfMonth(); this.moveToNthOccurrence(n, ntemp); if (this > temp) { throw new RangeError($D.getDayName(n) + " does not occur " + ntemp + " times in the month of " + $D.getMonthName(temp.getMonth()) + " " + temp.getFullYear() + "."); } return this; } return this.moveToDayOfWeek(n, this._orient); }; }; var sdf = function (n) { return function () { var t = $D.today(), shift = n - t.getDay(); if (n === 0 && Date.CultureInfo.firstDayOfWeek === 1 && t.getDay() !== 0) { shift = shift + 7; } return t.addDays(shift); }; }; // Create month name functions and abbreviated month name functions (eg. january(), march(), mar()). var month_instance_functions = function (n) { return function () { if (this._is) { this._is = false; return this.getMonth() === n; } return this.moveToMonth(n, this._orient); }; }; var month_static_functions = function (n) { return function () { return $D.today().set({ month: n, day: 1 }); }; }; var processTerms = function (names, staticFunc, instanceFunc) { for (var i = 0; i < names.length; i++) { // Create constant static Name variables. $D[names[i].toUpperCase()] = $D[names[i].toUpperCase().substring(0, 3)] = i; // Create Name functions. $D[names[i]] = $D[names[i].substring(0, 3)] = staticFunc(i); // Create Name instance functions. $P[names[i]] = $P[names[i].substring(0, 3)] = instanceFunc(i); } }; processTerms(dx, sdf, df); processTerms(mx, month_static_functions, month_instance_functions); // Create date element functions and plural date element functions used with Date (eg. day(), days(), months()). var ef = function (j) { return function () { // if the .second() function was called earlier, the _orient // has alread been added. Just return this and reset _isSecond. if (this._isSecond) { this._isSecond = false; return this; } if (this._same) { this._same = this._is = false; var o1 = this.toObject(), o2 = (arguments[0] || new Date()).toObject(), v = "", k = j.toLowerCase(); // the substr trick with -1 doesn't work in IE8 or less k = (k[k.length-1] === "s") ? k.substring(0,k.length-1) : k; for (var m = (px.length - 1); m > -1; m--) { v = px[m].toLowerCase(); if (o1[v] !== o2[v]) { return false; } if (k === v) { break; } } return true; } if (j.substring(j.length - 1) !== "s") { j += "s"; } if (this._move) { this._move = null; } return this["add" + j](this._orient); }; }; var nf = function (n) { return function () { this._dateElement = n; return this; }; }; for (var k = 0; k < px.length; k++) { de = px[k].toLowerCase(); if(de !== "weekday") { // Create date element functions and plural date element functions used with Date (eg. day(), days(), months()). $P[de] = $P[de + "s"] = ef(px[k]); // Create date element functions and plural date element functions used with Number (eg. day(), days(), months()). $N[de] = $N[de + "s"] = nf(de + "s"); } } $P._ss = ef("Second"); var nthfn = function (n) { return function (dayOfWeek) { if (this._same) { return this._ss(arguments[0]); } if (dayOfWeek || dayOfWeek === 0) { return this.moveToNthOccurrence(dayOfWeek, n); } this._nth = n; // if the operator is 'second' add the _orient, then deal with it later... if (n === 2 && (dayOfWeek === undefined || dayOfWeek === null)) { this._isSecond = true; return this.addSeconds(this._orient); } return this; }; }; for (var l = 0; l < nth.length; l++) { $P[nth[l]] = (l === 0) ? nthfn(-1) : nthfn(l); } }()); (function () { "use strict"; Date.Parsing = { Exception: function (s) { this.message = "Parse error at '" + s.substring(0, 10) + " ...'"; } }; var $P = Date.Parsing; var dayOffsets = { standard: [0,31,59,90,120,151,181,212,243,273,304,334], leap: [0,31,60,91,121,152,182,213,244,274,305,335] }; $P.isLeapYear = function(year) { return ((year % 4 === 0) && (year % 100 !== 0)) || (year % 400 === 0); }; var utils = { multiReplace : function (str, hash ) { var key; for (key in hash) { if (Object.prototype.hasOwnProperty.call(hash, key)) { var regex; if (typeof hash[key] === "function") { } else { regex = (hash[key] instanceof RegExp) ? hash[key] : new RegExp(hash[key], "g"); } str = str.replace(regex, key); } } return str; }, getDayOfYearFromWeek : function (obj) { var d, jan4, offset; obj.weekDay = (!obj.weekDay && obj.weekDay !== 0) ? 1 : obj.weekDay; d = new Date(obj.year, 0, 4); jan4 = d.getDay() === 0 ? 7 : d.getDay(); // JS is 0 indexed on Sunday. offset = jan4+3; obj.dayOfYear = ((obj.week * 7) + (obj.weekDay === 0 ? 7 : obj.weekDay))-offset; return obj; }, getDayOfYear : function (obj, dayOffset) { if (!obj.dayOfYear) { obj = utils.getDayOfYearFromWeek(obj); } for (var i=0;i <= dayOffset.length;i++) { if (obj.dayOfYear < dayOffset[i] || i === dayOffset.length) { obj.day = obj.day ? obj.day : (obj.dayOfYear - dayOffset[i-1]); break; } else { obj.month = i; } } return obj; }, adjustForTimeZone : function (obj, date) { var offset; if (obj.zone.toUpperCase() === "Z" || (obj.zone_hours === 0 && obj.zone_minutes === 0)) { // it's UTC/GML so work out the current timeszone offset offset = -date.getTimezoneOffset(); } else { offset = (obj.zone_hours*60) + (obj.zone_minutes || 0); if (obj.zone_sign === "+") { offset *= -1; } offset -= date.getTimezoneOffset(); } date.setMinutes(date.getMinutes()+offset); return date; }, setDefaults : function (obj) { obj.year = obj.year || Date.today().getFullYear(); obj.hours = obj.hours || 0; obj.minutes = obj.minutes || 0; obj.seconds = obj.seconds || 0; obj.milliseconds = obj.milliseconds || 0; if (!(!obj.month && (obj.week || obj.dayOfYear))) { // if we have a month, or if we don't but don't have the day calculation data obj.month = obj.month || 0; obj.day = obj.day || 1; } return obj; }, dataNum: function (data, mod, explict, postProcess) { var dataNum = data*1; if (mod) { if (postProcess) { return data ? mod(data)*1 : data; } else { return data ? mod(dataNum) : data; } } else if (!explict){ return data ? dataNum : data; } else { return (data && typeof data !== "undefined") ? dataNum : data; } }, timeDataProcess: function (obj) { var timeObj = {}; for (var x in obj.data) { if (obj.data.hasOwnProperty(x)) { timeObj[x] = obj.ignore[x] ? obj.data[x] : utils.dataNum(obj.data[x], obj.mods[x], obj.explict[x], obj.postProcess[x]); } } if (obj.data.secmins) { obj.data.secmins = obj.data.secmins.replace(",", ".") * 60; if (!timeObj.minutes) { timeObj.minutes = obj.data.secmins; } else if (!timeObj.seconds) { timeObj.seconds = obj.data.secmins; } delete obj.secmins; } return timeObj; }, buildTimeObjectFromData: function (data) { var time = utils.timeDataProcess({ data: { year : data[1], month : data[5], day : data[7], week : data[8], dayOfYear : data[10], hours : data[15], zone_hours : data[23], zone_minutes : data[24], zone : data[21], zone_sign : data[22], weekDay : data[9], minutes: data[16], seconds: data[19], milliseconds: data[20], secmins: data[18] }, mods: { month: function(data) { return data-1; }, weekDay: function (data) { data = Math.abs(data); return (data === 7 ? 0 : data); }, minutes: function (data) { return data.replace(":",""); }, seconds: function (data) { return Math.floor( (data.replace(":","").replace(",","."))*1 ); }, milliseconds: function (data) { return (data.replace(",",".")*1000); } }, postProcess: { minutes: true, seconds: true, milliseconds: true }, explict: { zone_hours: true, zone_minutes: true }, ignore: { zone: true, zone_sign: true, secmins: true } }); return time; }, addToHash: function (hash, keys, data) { keys = keys; data = data; var len = keys.length; for (var i = 0; i < len; i++) { hash[keys[i]] = data[i]; } return hash; }, combineRegex: function (r1, r2) { return new RegExp("(("+r1.source+")\\s("+r2.source+"))"); }, getDateNthString: function(add, last, inc){ if (add) { return Date.today().addDays(inc).toString("d"); } else if (last) { return Date.today().last()[inc]().toString("d"); } }, buildRegexData: function (array) { var arr = []; var len = array.length; for (var i=0; i < len; i++) { if (Object.prototype.toString.call(array[i]) === '[object Array]') { // oldIE compat version of Array.isArray arr.push(this.combineRegex(array[i][0], array[i][1])); } else { arr.push(array[i]); } } return arr; } }; $P.processTimeObject = function (obj) { var date, dayOffset; utils.setDefaults(obj); dayOffset = ($P.isLeapYear(obj.year)) ? dayOffsets.leap : dayOffsets.standard; if (!obj.month && (obj.week || obj.dayOfYear)) { utils.getDayOfYear(obj, dayOffset); } else { obj.dayOfYear = dayOffset[obj.month] + obj.day; } date = new Date(obj.year, obj.month, obj.day, obj.hours, obj.minutes, obj.seconds, obj.milliseconds); if (obj.zone) { utils.adjustForTimeZone(obj, date); // adjust (and calculate) for timezone } return date; }; $P.ISO = { regex : /^([\+-]?\d{4}(?!\d{2}\b))((-?)((0[1-9]|1[0-2])(\3([12]\d|0[1-9]|3[01]))?|W([0-4]\d|5[0-3])(-?[1-7])?|(00[1-9]|0[1-9]\d|[12]\d{2}|3([0-5]\d|6[1-6])))([T\s]((([01]\d|2[0-4])((:?)[0-5]\d)?|24\:?00)([\.,]\d+(?!:))?)?(\17[0-5]\d([\.,]\d+)?)?\s?([zZ]|([\+-])([01]\d|2[0-3]):?([0-5]\d)?)?)?)?$/, parse : function (s) { var time, data = s.match(this.regex); if (!data || !data.length) { return null; } time = utils.buildTimeObjectFromData(data); if (!time.year || (!time.year && (!time.month && !time.day) && (!time.week && !time.dayOfYear)) ) { return null; } return $P.processTimeObject(time); } }; $P.Numeric = { isNumeric: function (e){return!isNaN(parseFloat(e))&&isFinite(e);}, regex: /\b([0-1]?[0-9])([0-3]?[0-9])([0-2]?[0-9]?[0-9][0-9])\b/i, parse: function (s) { var data, i, time = {}, order = Date.CultureInfo.dateElementOrder.split(""); if (!(this.isNumeric(s)) || // if it's non-numeric OR (s[0] === "+" && s[0] === "-")) { // It's an arithmatic string (eg +/-1000) return null; } if (s.length < 5 && s.indexOf(".") < 0 && s.indexOf("/") < 0) { // assume it's just a year. time.year = s; return $P.processTimeObject(time); } data = s.match(this.regex); if (!data || !data.length) { return null; } for (i=0; i < order.length; i++) { switch(order[i]) { case "d": time.day = data[i+1]; break; case "m": time.month = (data[i+1]-1); break; case "y": time.year = data[i+1]; break; } } return $P.processTimeObject(time); } }; $P.Normalizer = { regexData: function () { var $R = Date.CultureInfo.regexPatterns; return utils.buildRegexData([ $R.tomorrow, $R.yesterday, [$R.past, $R.mon], [$R.past, $R.tue], [$R.past, $R.wed], [$R.past, $R.thu], [$R.past, $R.fri], [$R.past, $R.sat], [$R.past, $R.sun] ]); }, basicReplaceHash : function() { var $R = Date.CultureInfo.regexPatterns; return { "January": $R.jan.source, "February": $R.feb, "March": $R.mar, "April": $R.apr, "May": $R.may, "June": $R.jun, "July": $R.jul, "August": $R.aug, "September": $R.sep, "October": $R.oct, "November": $R.nov, "December": $R.dec, "": /\bat\b/gi, " ": /\s{2,}/, "am": $R.inTheMorning, "9am": $R.thisMorning, "pm": $R.inTheEvening, "7pm":$R.thisEvening }; }, keys : function(){ return [ utils.getDateNthString(true, false, 1), // tomorrow utils.getDateNthString(true, false, -1), // yesterday utils.getDateNthString(false, true, "monday"), //last mon utils.getDateNthString(false, true, "tuesday"), //last tues utils.getDateNthString(false, true, "wednesday"), //last wed utils.getDateNthString(false, true, "thursday"), //last thurs utils.getDateNthString(false, true, "friday"), //last fri utils.getDateNthString(false, true, "saturday"), //last sat utils.getDateNthString(false, true, "sunday") //last sun ]; }, buildRegexFunctions: function () { var $R = Date.CultureInfo.regexPatterns; var __ = Date.i18n.__; var tomorrowRE = new RegExp("(\\b\\d\\d?("+__("AM")+"|"+__("PM")+")? )("+$R.tomorrow.source.slice(1)+")", "i"); // adapted tomorrow regex for AM PM relative dates var todayRE = new RegExp($R.today.source + "(?!\\s*([+-]))\\b"); // today, but excludes the math operators (eg "today + 2h") this.replaceFuncs = [ [todayRE, function (full) { return (full.length > 1) ? Date.today().toString("d") : full; }], [tomorrowRE, function(full, m1) { var t = Date.today().addDays(1).toString("d"); return (t + " " + m1); }], [$R.amThisMorning, function(str, am){return am;}], [$R.pmThisEvening, function(str, pm){return pm;}] ]; }, buildReplaceData: function () { this.buildRegexFunctions(); this.replaceHash = utils.addToHash(this.basicReplaceHash(), this.keys(), this.regexData()); }, stringReplaceFuncs: function (s) { for (var i=0; i < this.replaceFuncs.length; i++) { s = s.replace(this.replaceFuncs[i][0], this.replaceFuncs[i][1]); } return s; }, parse: function (s) { s = this.stringReplaceFuncs(s); s = utils.multiReplace(s, this.replaceHash); try { var n = s.split(/([\s\-\.\,\/\x27]+)/); if (n.length === 3 && $P.Numeric.isNumeric(n[0]) && $P.Numeric.isNumeric(n[2]) && (n[2].length >= 4)) { // ok, so we're dealing with x/year. But that's not a full date. // This fixes wonky dateElementOrder parsing when set to dmy order. if (Date.CultureInfo.dateElementOrder[0] === "d") { s = "1/" + n[0] + "/" + n[2]; // set to 1st of month and normalize the seperator } } } catch (e) {} return s; } }; $P.Normalizer.buildReplaceData(); }()); (function () { var $P = Date.Parsing; var _ = $P.Operators = { // // Tokenizers // rtoken: function (r) { // regex token return function (s) { var mx = s.match(r); if (mx) { return ([ mx[0], s.substring(mx[0].length) ]); } else { throw new $P.Exception(s); } }; }, token: function () { // whitespace-eating token return function (s) { return _.rtoken(new RegExp("^\\s*" + s + "\\s*"))(s); }; }, stoken: function (s) { // string token return _.rtoken(new RegExp("^" + s)); }, // Atomic Operators until: function (p) { return function (s) { var qx = [], rx = null; while (s.length) { try { rx = p.call(this, s); } catch (e) { qx.push(rx[0]); s = rx[1]; continue; } break; } return [ qx, s ]; }; }, many: function (p) { return function (s) { var rx = [], r = null; while (s.length) { try { r = p.call(this, s); } catch (e) { return [ rx, s ]; } rx.push(r[0]); s = r[1]; } return [ rx, s ]; }; }, // generator operators -- see below optional: function (p) { return function (s) { var r = null; try { r = p.call(this, s); } catch (e) { return [ null, s ]; } return [ r[0], r[1] ]; }; }, not: function (p) { return function (s) { try { p.call(this, s); } catch (e) { return [null, s]; } throw new $P.Exception(s); }; }, ignore: function (p) { return p ? function (s) { var r = null; r = p.call(this, s); return [null, r[1]]; } : null; }, product: function () { var px = arguments[0], qx = Array.prototype.slice.call(arguments, 1), rx = []; for (var i = 0 ; i < px.length ; i++) { rx.push(_.each(px[i], qx)); } return rx; }, cache: function (rule) { var cache = {}, cache_length = 0, cache_keys = [], CACHE_MAX = Date.Config.CACHE_MAX || 100000, r = null; var cacheCheck = function () { if (cache_length === CACHE_MAX) { // kill several keys, don't want to have to do this all the time... for (var i=0; i < 10; i++) { var key = cache_keys.shift(); if (key) { delete cache[key]; cache_length--; } } } }; return function (s) { cacheCheck(); try { r = cache[s] = (cache[s] || rule.call(this, s)); } catch (e) { r = cache[s] = e; } cache_length++; cache_keys.push(s); if (r instanceof $P.Exception) { throw r; } else { return r; } }; }, // vector operators -- see below any: function () { var px = arguments; return function (s) { var r = null; for (var i = 0; i < px.length; i++) { if (px[i] == null) { continue; } try { r = (px[i].call(this, s)); } catch (e) { r = null; } if (r) { return r; } } throw new $P.Exception(s); }; }, each: function () { var px = arguments; return function (s) { var rx = [], r = null; for (var i = 0; i < px.length ; i++) { if (px[i] == null) { continue; } try { r = (px[i].call(this, s)); } catch (e) { throw new $P.Exception(s); } rx.push(r[0]); s = r[1]; } return [ rx, s]; }; }, all: function () { var px = arguments, _ = _; return _.each(_.optional(px)); }, // delimited operators sequence: function (px, d, c) { d = d || _.rtoken(/^\s*/); c = c || null; if (px.length === 1) { return px[0]; } return function (s) { var r = null, q = null; var rx = []; for (var i = 0; i < px.length ; i++) { try { r = px[i].call(this, s); } catch (e) { break; } rx.push(r[0]); try { q = d.call(this, r[1]); } catch (ex) { q = null; break; } s = q[1]; } if (!r) { throw new $P.Exception(s); } if (q) { throw new $P.Exception(q[1]); } if (c) { try { r = c.call(this, r[1]); } catch (ey) { throw new $P.Exception(r[1]); } } return [ rx, (r?r[1]:s) ]; }; }, // // Composite Operators // between: function (d1, p, d2) { d2 = d2 || d1; var _fn = _.each(_.ignore(d1), p, _.ignore(d2)); return function (s) { var rx = _fn.call(this, s); return [[rx[0][0], r[0][2]], rx[1]]; }; }, list: function (p, d, c) { d = d || _.rtoken(/^\s*/); c = c || null; return (p instanceof Array ? _.each(_.product(p.slice(0, -1), _.ignore(d)), p.slice(-1), _.ignore(c)) : _.each(_.many(_.each(p, _.ignore(d))), px, _.ignore(c))); }, set: function (px, d, c) { d = d || _.rtoken(/^\s*/); c = c || null; return function (s) { // r is the current match, best the current 'best' match // which means it parsed the most amount of input var r = null, p = null, q = null, rx = null, best = [[], s], last = false; // go through the rules in the given set for (var i = 0; i < px.length ; i++) { // last is a flag indicating whether this must be the last element // if there is only 1 element, then it MUST be the last one q = null; p = null; r = null; last = (px.length === 1); // first, we try simply to match the current pattern // if not, try the next pattern try { r = px[i].call(this, s); } catch (e) { continue; } // since we are matching against a set of elements, the first // thing to do is to add r[0] to matched elements rx = [[r[0]], r[1]]; // if we matched and there is still input to parse and // we don't already know this is the last element, // we're going to next check for the delimiter ... // if there's none, or if there's no input left to parse // than this must be the last element after all ... if (r[1].length > 0 && ! last) { try { q = d.call(this, r[1]); } catch (ex) { last = true; } } else { last = true; } // if we parsed the delimiter and now there's no more input, // that means we shouldn't have parsed the delimiter at all // so don't update r and mark this as the last element ... if (!last && q[1].length === 0) { last = true; } // so, if this isn't the last element, we're going to see if // we can get any more matches from the remaining (unmatched) // elements ... if (!last) { // build a list of the remaining rules we can match against, // i.e., all but the one we just matched against var qx = []; for (var j = 0; j < px.length ; j++) { if (i !== j) { qx.push(px[j]); } } // now invoke recursively set with the remaining input // note that we don't include the closing delimiter ... // we'll check for that ourselves at the end p = _.set(qx, d).call(this, q[1]); // if we got a non-empty set as a result ... // (otw rx already contains everything we want to match) if (p[0].length > 0) { // update current result, which is stored in rx ... // basically, pick up the remaining text from p[1] // and concat the result from p[0] so that we don't // get endless nesting ... rx[0] = rx[0].concat(p[0]); rx[1] = p[1]; } } // at this point, rx either contains the last matched element // or the entire matched set that starts with this element. // now we just check to see if this variation is better than // our best so far, in terms of how much of the input is parsed if (rx[1].length < best[1].length) { best = rx; } // if we've parsed all the input, then we're finished if (best[1].length === 0) { break; } } // so now we've either gone through all the patterns trying them // as the initial match; or we found one that parsed the entire // input string ... // if best has no matches, just return empty set ... if (best[0].length === 0) { return best; } // if a closing delimiter is provided, then we have to check it also if (c) { // we try this even if there is no remaining input because the pattern // may well be optional or match empty input ... try { q = c.call(this, best[1]); } catch (ey) { throw new $P.Exception(best[1]); } // it parsed ... be sure to update the best match remaining input best[1] = q[1]; } // if we're here, either there was no closing delimiter or we parsed it // so now we have the best match; just return it! return best; }; }, forward: function (gr, fname) { return function (s) { return gr[fname].call(this, s); }; }, // // Translation Operators // replace: function (rule, repl) { return function (s) { var r = rule.call(this, s); return [repl, r[1]]; }; }, process: function (rule, fn) { return function (s) { var r = rule.call(this, s); return [fn.call(this, r[0]), r[1]]; }; }, min: function (min, rule) { return function (s) { var rx = rule.call(this, s); if (rx[0].length < min) { throw new $P.Exception(s); } return rx; }; } }; // Generator Operators And Vector Operators // Generators are operators that have a signature of F(R) => R, // taking a given rule and returning another rule, such as // ignore, which parses a given rule and throws away the result. // Vector operators are those that have a signature of F(R1,R2,...) => R, // take a list of rules and returning a new rule, such as each. // Generator operators are converted (via the following _generator // function) into functions that can also take a list or array of rules // and return an array of new rules as though the function had been // called on each rule in turn (which is what actually happens). // This allows generators to be used with vector operators more easily. // Example: // each(ignore(foo, bar)) instead of each(ignore(foo), ignore(bar)) // This also turns generators into vector operators, which allows // constructs like: // not(cache(foo, bar)) var _generator = function (op) { function gen() { var args = null, rx = [], px, i; if (arguments.length > 1) { args = Array.prototype.slice.call(arguments); } else if (arguments[0] instanceof Array) { args = arguments[0]; } if (args) { px = args.shift(); if (px.length > 0) { args.unshift(px[i]); rx.push(op.apply(null, args)); args.shift(); return rx; } } else { return op.apply(null, arguments); } } return gen; }; var gx = "optional not ignore cache".split(/\s/); for (var i = 0 ; i < gx.length ; i++) { _[gx[i]] = _generator(_[gx[i]]); } var _vector = function (op) { return function () { if (arguments[0] instanceof Array) { return op.apply(null, arguments[0]); } else { return op.apply(null, arguments); } }; }; var vx = "each any all".split(/\s/); for (var j = 0 ; j < vx.length ; j++) { _[vx[j]] = _vector(_[vx[j]]); } }()); (function () { var $D = Date; var flattenAndCompact = function (ax) { var rx = []; for (var i = 0; i < ax.length; i++) { if (ax[i] instanceof Array) { rx = rx.concat(flattenAndCompact(ax[i])); } else { if (ax[i]) { rx.push(ax[i]); } } } return rx; }; var parseMeridian = function () { if (this.meridian && (this.hour || this.hour === 0)) { if (this.meridian === "a" && this.hour > 11 && Date.Config.strict24hr){ throw "Invalid hour and meridian combination"; } else if (this.meridian === "p" && this.hour < 12 && Date.Config.strict24hr){ throw "Invalid hour and meridian combination"; } else if (this.meridian === "p" && this.hour < 12) { this.hour = this.hour + 12; } else if (this.meridian === "a" && this.hour === 12) { this.hour = 0; } } }; var setDefaults = function () { var now = new Date(); if ((this.hour || this.minute) && (!this.month && !this.year && !this.day)) { this.day = now.getDate(); } if (!this.year) { this.year = now.getFullYear(); } if (!this.month && this.month !== 0) { this.month = now.getMonth(); } if (!this.day) { this.day = 1; } if (!this.hour) { this.hour = 0; } if (!this.minute) { this.minute = 0; } if (!this.second) { this.second = 0; } if (!this.millisecond) { this.millisecond = 0; } }; var finishUtils = { getToday: function () { if (this.now || "hour minute second".indexOf(this.unit) !== -1) { return new Date(); } else { return $D.today(); } }, setDaysFromWeekday: function (today, orient){ var gap; orient = orient || 1; this.unit = "day"; gap = ($D.getDayNumberFromName(this.weekday) - today.getDay()); this.days = gap ? ((gap + (orient * 7)) % 7) : (orient * 7); return this; }, setMonthsFromMonth: function (today, orient) { var gap; orient = orient || 1; this.unit = "month"; gap = (this.month - today.getMonth()); this.months = gap ? ((gap + (orient * 12)) % 12) : (orient * 12); this.month = null; return this; }, setDMYFromWeekday: function () { var d = Date[this.weekday](); this.day = d.getDate(); if (!this.month) { this.month = d.getMonth(); } this.year = d.getFullYear(); return this; }, setUnitValue: function (orient) { if (!this.value && this.operator && this.operator !== null && this[this.unit + "s"] && this[this.unit + "s"] !== null) { this[this.unit + "s"] = this[this.unit + "s"] + ((this.operator === "add") ? 1 : -1) + (this.value||0) * orient; } else if (this[this.unit + "s"] == null || this.operator != null) { if (!this.value) { this.value = 1; } this[this.unit + "s"] = this.value * orient; } }, generateDateFromWeeks: function () { var weekday = (this.weekday !== undefined) ? this.weekday : "today"; var d = Date[weekday]().addWeeks(this.weeks); if (this.now) { d.setTimeToNow(); } return d; } }; $D.Translator = { hour: function (s) { return function () { this.hour = Number(s); }; }, minute: function (s) { return function () { this.minute = Number(s); }; }, second: function (s) { return function () { this.second = Number(s); }; }, /* for ss.s format */ secondAndMillisecond: function (s) { return function () { var mx = s.match(/^([0-5][0-9])\.([0-9]{1,3})/); this.second = Number(mx[1]); this.millisecond = Number(mx[2]); }; }, meridian: function (s) { return function () { this.meridian = s.slice(0, 1).toLowerCase(); }; }, timezone: function (s) { return function () { var n = s.replace(/[^\d\+\-]/g, ""); if (n.length) { this.timezoneOffset = Number(n); } else { this.timezone = s.toLowerCase(); } }; }, day: function (x) { var s = x[0]; return function () { this.day = Number(s.match(/\d+/)[0]); if (this.day < 1) { throw "invalid day"; } }; }, month: function (s) { return function () { this.month = (s.length === 3) ? "jan feb mar apr may jun jul aug sep oct nov dec".indexOf(s)/4 : Number(s) - 1; if (this.month < 0) { throw "invalid month"; } }; }, year: function (s) { return function () { var n = Number(s); this.year = ((s.length > 2) ? n : (n + (((n + 2000) < Date.CultureInfo.twoDigitYearMax) ? 2000 : 1900))); }; }, rday: function (s) { return function () { switch (s) { case "yesterday": this.days = -1; break; case "tomorrow": this.days = 1; break; case "today": this.days = 0; break; case "now": this.days = 0; this.now = true; break; } }; }, finishExact: function (x) { var d; x = (x instanceof Array) ? x : [x]; for (var i = 0 ; i < x.length ; i++) { if (x[i]) { x[i].call(this); } } setDefaults.call(this); parseMeridian.call(this); if (this.day > $D.getDaysInMonth(this.year, this.month)) { throw new RangeError(this.day + " is not a valid value for days."); } d = new Date(this.year, this.month, this.day, this.hour, this.minute, this.second, this.millisecond); if (this.year < 100) { d.setFullYear(this.year); // means years less that 100 are process correctly. JS will parse it otherwise as 1900-1999. } if (this.timezone) { d.set({ timezone: this.timezone }); } else if (this.timezoneOffset) { d.set({ timezoneOffset: this.timezoneOffset }); } return d; }, finish: function (x) { var today, expression, orient, temp; x = (x instanceof Array) ? flattenAndCompact(x) : [ x ]; if (x.length === 0) { return null; } for (var i = 0 ; i < x.length ; i++) { if (typeof x[i] === "function") { x[i].call(this); } } if (this.now && !this.unit && !this.operator) { return new Date(); } else { today = finishUtils.getToday.call(this); } expression = !!(this.days && this.days !== null || this.orient || this.operator); orient = ((this.orient === "past" || this.operator === "subtract") ? -1 : 1); if (this.month && this.unit === "week") { this.value = this.month + 1; delete this.month; delete this.day; } if ((this.month || this.month === 0) && "year day hour minute second".indexOf(this.unit) !== -1) { if (!this.value) { this.value = this.month + 1; } this.month = null; expression = true; } if (!expression && this.weekday && !this.day && !this.days) { finishUtils.setDMYFromWeekday.call(this); } if (expression && this.weekday && this.unit !== "month" && this.unit !== "week") { finishUtils.setDaysFromWeekday.call(this, today, orient); } if (this.weekday && this.unit !== "week" && !this.day && !this.days) { temp = Date[this.weekday](); this.day = temp.getDate(); if (temp.getMonth() !== today.getMonth()) { this.month = temp.getMonth(); } } if (this.month && this.unit === "day" && this.operator) { if (!this.value) { this.value = (this.month + 1); } this.month = null; } if (this.value != null && this.month != null && this.year != null) { this.day = this.value * 1; } if (this.month && !this.day && this.value) { today.set({ day: this.value * 1 }); if (!expression) { this.day = this.value * 1; } } if (!this.month && this.value && this.unit === "month" && !this.now) { this.month = this.value; expression = true; } if (expression && (this.month || this.month === 0) && this.unit !== "year") { finishUtils.setMonthsFromMonth.call(this, today, orient); } if (!this.unit) { this.unit = "day"; } finishUtils.setUnitValue.call(this, orient); parseMeridian.call(this); if ((this.month || this.month === 0) && !this.day) { this.day = 1; } if (!this.orient && !this.operator && this.unit === "week" && this.value && !this.day && !this.month) { return Date.today().setWeek(this.value); } if (this.unit === "week" && this.weeks && !this.day && !this.month) { return finishUtils.generateDateFromWeeks.call(this); } if (expression && this.timezone && this.day && this.days) { this.day = this.days; } if (expression){ today.add(this); } else { today.set(this); } if (this.timezone) { this.timezone = this.timezone.toUpperCase(); var offset = $D.getTimezoneOffset(this.timezone); var timezone; if (today.hasDaylightSavingTime()) { // lets check that we're being sane with timezone setting timezone = $D.getTimezoneAbbreviation(offset, today.isDaylightSavingTime()); if (timezone !== this.timezone) { // bugger, we're in a place where things like EST vs EDT matters. if (today.isDaylightSavingTime()) { today.addHours(-1); } else { today.addHours(1); } } } today.setTimezoneOffset(offset); } return today; } }; }()); (function () { var $D = Date; $D.Grammar = {}; var _ = $D.Parsing.Operators, g = $D.Grammar, t = $D.Translator, _fn; // Allow rolling up into general purpose rules _fn = function () { return _.each(_.any.apply(null, arguments), _.not(g.ctoken2("timeContext"))); }; g.datePartDelimiter = _.rtoken(/^([\s\-\.\,\/\x27]+)/); g.timePartDelimiter = _.stoken(":"); g.whiteSpace = _.rtoken(/^\s*/); g.generalDelimiter = _.rtoken(/^(([\s\,]|at|@|on)+)/); var _C = {}; g.ctoken = function (keys) { var fn = _C[keys]; if (! fn) { var c = Date.CultureInfo.regexPatterns; var kx = keys.split(/\s+/), px = []; for (var i = 0; i < kx.length ; i++) { px.push(_.replace(_.rtoken(c[kx[i]]), kx[i])); } fn = _C[keys] = _.any.apply(null, px); } return fn; }; g.ctoken2 = function (key) { return _.rtoken(Date.CultureInfo.regexPatterns[key]); }; var cacheProcessRtoken = function (key, token, type, eachToken) { if (eachToken) { g[key] = _.cache(_.process(_.each(_.rtoken(token),_.optional(g.ctoken2(eachToken))), type)); } else { g[key] = _.cache(_.process(_.rtoken(token), type)); } }; var cacheProcessCtoken = function (token, type) { return _.cache(_.process(g.ctoken2(token), type)); }; var _F = {}; //function cache var _get = function (f) { _F[f] = (_F[f] || g.format(f)[0]); return _F[f]; }; g.allformats = function (fx) { var rx = []; if (fx instanceof Array) { for (var i = 0; i < fx.length; i++) { rx.push(_get(fx[i])); } } else { rx.push(_get(fx)); } return rx; }; g.formats = function (fx) { if (fx instanceof Array) { var rx = []; for (var i = 0 ; i < fx.length ; i++) { rx.push(_get(fx[i])); } return _.any.apply(null, rx); } else { return _get(fx); } }; var grammarFormats = { timeFormats: function(){ var i, RTokenKeys = [ "h", "hh", "H", "HH", "m", "mm", "s", "ss", "ss.s", "z", "zz" ], RToken = [ /^(0[0-9]|1[0-2]|[1-9])/, /^(0[0-9]|1[0-2])/, /^([0-1][0-9]|2[0-3]|[0-9])/, /^([0-1][0-9]|2[0-3])/, /^([0-5][0-9]|[0-9])/, /^[0-5][0-9]/, /^([0-5][0-9]|[0-9])/, /^[0-5][0-9]/, /^[0-5][0-9]\.[0-9]{1,3}/, /^((\+|\-)\s*\d\d\d\d)|((\+|\-)\d\d\:?\d\d)/, /^((\+|\-)\s*\d\d\d\d)|((\+|\-)\d\d\:?\d\d)/ ], tokens = [ t.hour, t.hour, t.hour, t.hour, t.minute, t.minute, t.second, t.second, t.secondAndMillisecond, t.timezone, t.timezone ]; for (i=0; i < RTokenKeys.length; i++) { cacheProcessRtoken(RTokenKeys[i], RToken[i], tokens[i]); } g.hms = _.cache(_.sequence([g.H, g.m, g.s], g.timePartDelimiter)); g.t = cacheProcessCtoken("shortMeridian", t.meridian); g.tt = cacheProcessCtoken("longMeridian", t.meridian); g.zzz = cacheProcessCtoken("timezone", t.timezone); g.timeSuffix = _.each(_.ignore(g.whiteSpace), _.set([ g.tt, g.zzz ])); g.time = _.each(_.optional(_.ignore(_.stoken("T"))), g.hms, g.timeSuffix); }, dateFormats: function () { // pre-loaded rules for different date part order preferences var _setfn = function () { return _.set(arguments, g.datePartDelimiter); }; var i, RTokenKeys = [ "d", "dd", "M", "MM", "y", "yy", "yyy", "yyyy" ], RToken = [ /^([0-2]\d|3[0-1]|\d)/, /^([0-2]\d|3[0-1])/, /^(1[0-2]|0\d|\d)/, /^(1[0-2]|0\d)/, /^(\d+)/, /^(\d\d)/, /^(\d\d?\d?\d?)/, /^(\d\d\d\d)/ ], tokens = [ t.day, t.day, t.month, t.month, t.year, t.year, t.year, t.year ], eachToken = [ "ordinalSuffix", "ordinalSuffix" ]; for (i=0; i < RTokenKeys.length; i++) { cacheProcessRtoken(RTokenKeys[i], RToken[i], tokens[i], eachToken[i]); } g.MMM = g.MMMM = _.cache(_.process(g.ctoken("jan feb mar apr may jun jul aug sep oct nov dec"), t.month)); g.ddd = g.dddd = _.cache(_.process(g.ctoken("sun mon tue wed thu fri sat"), function (s) { return function () { this.weekday = s; }; } )); g.day = _fn(g.d, g.dd); g.month = _fn(g.M, g.MMM); g.year = _fn(g.yyyy, g.yy); g.mdy = _setfn(g.ddd, g.month, g.day, g.year); g.ymd = _setfn(g.ddd, g.year, g.month, g.day); g.dmy = _setfn(g.ddd, g.day, g.month, g.year); g.date = function (s) { return ((g[Date.CultureInfo.dateElementOrder] || g.mdy).call(this, s)); }; }, relative: function () { // relative date / time expressions g.orientation = _.process(g.ctoken("past future"), function (s) { return function () { this.orient = s; }; } ); g.operator = _.process(g.ctoken("add subtract"), function (s) { return function () { this.operator = s; }; } ); g.rday = _.process(g.ctoken("yesterday tomorrow today now"), t.rday); g.unit = _.process(g.ctoken("second minute hour day week month year"), function (s) { return function () { this.unit = s; }; } ); } }; g.buildGrammarFormats = function () { // these need to be rebuilt every time the language changes. _C = {}; grammarFormats.timeFormats(); grammarFormats.dateFormats(); grammarFormats.relative(); g.value = _.process(_.rtoken(/^([-+]?\d+)?(st|nd|rd|th)?/), function (s) { return function () { this.value = s.replace(/\D/g, ""); }; } ); g.expression = _.set([g.rday, g.operator, g.value, g.unit, g.orientation, g.ddd, g.MMM ]); g.format = _.process(_.many( _.any( // translate format specifiers into grammar rules _.process( _.rtoken(/^(dd?d?d?(?!e)|MM?M?M?|yy?y?y?|hh?|HH?|mm?|ss?|tt?|zz?z?)/), function (fmt) { if (g[fmt]) { return g[fmt]; } else { throw $D.Parsing.Exception(fmt); } } ), // translate separator tokens into token rules _.process(_.rtoken(/^[^dMyhHmstz]+/), // all legal separators function (s) { return _.ignore(_.stoken(s)); } ) ) ), // construct the parser ... function (rules) { return _.process(_.each.apply(null, rules), t.finishExact); } ); // starting rule for general purpose grammar g._start = _.process(_.set([ g.date, g.time, g.expression ], g.generalDelimiter, g.whiteSpace), t.finish); }; g.buildGrammarFormats(); // parsing date format specifiers - ex: "h:m:s tt" // this little guy will generate a custom parser based // on the format string, ex: g.format("h:m:s tt") // check for these formats first g._formats = g.formats([ "\"yyyy-MM-ddTHH:mm:ssZ\"", "yyyy-MM-ddTHH:mm:ss.sz", "yyyy-MM-ddTHH:mm:ssZ", "yyyy-MM-ddTHH:mm:ssz", "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-ddTHH:mmZ", "yyyy-MM-ddTHH:mmz", "yyyy-MM-ddTHH:mm", "ddd, MMM dd, yyyy H:mm:ss tt", "ddd MMM d yyyy HH:mm:ss zzz", "MMddyyyy", "ddMMyyyy", "Mddyyyy", "ddMyyyy", "Mdyyyy", "dMyyyy", "yyyy", "Mdyy", "dMyy", "d" ]); // real starting rule: tries selected formats first, // then general purpose rule g.start = function (s) { try { var r = g._formats.call({}, s); if (r[1].length === 0) { return r; } } catch (e) {} return g._start.call({}, s); }; }()); (function () { var $D = Date; /** * @desc Converts the specified string value into its JavaScript Date equivalent using CultureInfo specific format information. * * Example

	///////////
	// Dates //
	///////////

	// 15-Oct-2004
	var d1 = Date.parse("10/15/2004");

	// 15-Oct-2004
	var d1 = Date.parse("15-Oct-2004");

	// 15-Oct-2004
	var d1 = Date.parse("2004.10.15");

	//Fri Oct 15, 2004
	var d1 = Date.parse("Fri Oct 15, 2004");

	///////////
	// Times //
	///////////

	// Today at 10 PM.
	var d1 = Date.parse("10 PM");

	// Today at 10:30 PM.
	var d1 = Date.parse("10:30 P.M.");

	// Today at 6 AM.
	var d1 = Date.parse("06am");

	/////////////////////
	// Dates and Times //
	/////////////////////

	// 8-July-2004 @ 10:30 PM
	var d1 = Date.parse("July 8th, 2004, 10:30 PM");

	// 1-July-2004 @ 10:30 PM
	var d1 = Date.parse("2004-07-01T22:30:00");

	////////////////////
	// Relative Dates //
	////////////////////

	// Returns today's date. The string "today" is culture specific.
	var d1 = Date.parse("today");

	// Returns yesterday's date. The string "yesterday" is culture specific.
	var d1 = Date.parse("yesterday");

	// Returns the date of the next thursday.
	var d1 = Date.parse("Next thursday");

	// Returns the date of the most previous monday.
	var d1 = Date.parse("last monday");

	// Returns today's day + one year.
	var d1 = Date.parse("next year");

	///////////////
	// Date Math //
	///////////////

	// Today + 2 days
	var d1 = Date.parse("t+2");

	// Today + 2 days
	var d1 = Date.parse("today + 2 days");

	// Today + 3 months
	var d1 = Date.parse("t+3m");

	// Today - 1 year
	var d1 = Date.parse("today - 1 year");

	// Today - 1 year
	var d1 = Date.parse("t-1y"); 


	/////////////////////////////
	// Partial Dates and Times //
	/////////////////////////////

	// July 15th of this year.
	var d1 = Date.parse("July 15");

	// 15th day of current day and year.
	var d1 = Date.parse("15");

	// July 1st of current year at 10pm.
	var d1 = Date.parse("7/1 10pm");
	
* * @param {String} The string value to convert into a Date object [Required] * @return {Date} A Date object or null if the string cannot be converted into a Date. */ var parseUtils = { removeOrds: function (s) { ords = s.match(/\b(\d+)(?:st|nd|rd|th)\b/); // find ordinal matches s = ((ords && ords.length === 2) ? s.replace(ords[0], ords[1]) : s); return s; }, grammarParser: function (s) { var r = null; try { r = $D.Grammar.start.call({}, s.replace(/^\s*(\S*(\s+\S+)*)\s*$/, "$1")); } catch (e) { return null; } return ((r[1].length === 0) ? r[0] : null); }, nativeFallback: function(s) { var t; try { // ok we haven't parsed it, last ditch attempt with the built-in parser. t = Date._parse(s); return (t || t === 0) ? new Date(t) : null; } catch (e) { return null; } } }; function parse (s) { var d; if (!s) { return null; } if (s instanceof Date) { return s.clone(); } if (s.length >= 4 && s.charAt(0) !== "0" && s.charAt(0) !== "+"&& s.charAt(0) !== "-") { // ie: 2004 will pass, 0800 won't. // Start with specific formats d = $D.Parsing.ISO.parse(s) || $D.Parsing.Numeric.parse(s); } if (d instanceof Date && !isNaN(d.getTime())) { return d; } else { // find ordinal dates (1st, 3rd, 8th, etc and remove them as they cause parsing issues) s = $D.Parsing.Normalizer.parse(parseUtils.removeOrds(s)); d = parseUtils.grammarParser(s); if (d !== null) { return d; } else { return parseUtils.nativeFallback(s); } } } if (!$D._parse) { $D._parse = $D.parse; } $D.parse = parse; Date.getParseFunction = function (fx) { var fns = Date.Grammar.allformats(fx); return function (s) { var r = null; for (var i = 0; i < fns.length; i++) { try { r = fns[i].call({}, s); } catch (e) { continue; } if (r[1].length === 0) { return r[0]; } } return null; }; }; /** * Converts the specified string value into its JavaScript Date equivalent using the specified format {String} or formats {Array} and the CultureInfo specific format information. * The format of the string value must match one of the supplied formats exactly. * * Example

	// 15-Oct-2004
	var d1 = Date.parseExact("10/15/2004", "M/d/yyyy");

	// 15-Oct-2004
	var d1 = Date.parse("15-Oct-2004", "M-ddd-yyyy");

	// 15-Oct-2004
	var d1 = Date.parse("2004.10.15", "yyyy.MM.dd");

	// Multiple formats
	var d1 = Date.parseExact("10/15/2004", ["M/d/yyyy", "MMMM d, yyyy"]);
	
* * @param {String} The string value to convert into a Date object [Required]. * @param {Object} The expected format {String} or an array of expected formats {Array} of the date string [Required]. * @return {Date} A Date object or null if the string cannot be converted into a Date. */ $D.parseExact = function (s, fx) { return $D.getParseFunction(fx)(s); }; }()); (function () { var $D = Date, $P = $D.prototype, // $C = $D.CultureInfo, // not used atm p = function (s, l) { if (!l) { l = 2; } return ("000" + s).slice(l * -1); }; /** * Converts a PHP format string to Java/.NET format string. * A PHP format string can be used with ._format or .format. * A Java/.NET format string can be used with .toString(). * The .parseExact function will only accept a Java/.NET format string * * Example * var f1 = "%m/%d/%y" * var f2 = Date.normalizeFormat(f1); // "MM/dd/yy" * * new Date().format(f1); // "04/13/08" * new Date()._format(f1); // "04/13/08" * new Date().toString(f2); // "04/13/08" * * var date = Date.parseExact("04/13/08", f2); // Sun Apr 13 2008 * * @param {String} A PHP format string consisting of one or more format spcifiers. * @return {String} The PHP format converted to a Java/.NET format string. */ var normalizerSubstitutions = { "d" : "dd", "%d": "dd", "D" : "ddd", "%a": "ddd", "j" : "dddd", "l" : "dddd", "%A": "dddd", "S" : "S", "F" : "MMMM", "%B": "MMMM", "m" : "MM", "%m": "MM", "M" : "MMM", "%b": "MMM", "%h": "MMM", "n" : "M", "Y" : "yyyy", "%Y": "yyyy", "y" : "yy", "%y": "yy", "g" : "h", "%I": "h", "G" : "H", "h" : "hh", "H" : "HH", "%H": "HH", "i" : "mm", "%M": "mm", "s" : "ss", "%S": "ss", "%r": "hh:mm tt", "%R": "H:mm", "%T": "H:mm:ss", "%X": "t", "%x": "d", "%e": "d", "%D": "MM/dd/yy", "%n": "\\n", "%t": "\\t", "e" : "z", "T" : "z", "%z": "z", "%Z": "z", "Z" : "ZZ", "N" : "u", "w" : "u", "%w": "u", "W" : "W", "%V": "W" }; var normalizer = { substitutes: function (m) { return normalizerSubstitutions[m]; }, interpreted: function (m, x) { var y; switch (m) { case "%u": return x.getDay() + 1; case "z": return x.getOrdinalNumber(); case "%j": return p(x.getOrdinalNumber(), 3); case "%U": var d1 = x.clone().set({month: 0, day: 1}).addDays(-1).moveToDayOfWeek(0), d2 = x.clone().addDays(1).moveToDayOfWeek(0, -1); return (d2 < d1) ? "00" : p((d2.getOrdinalNumber() - d1.getOrdinalNumber()) / 7 + 1); case "%W": return p(x.getWeek()); case "t": return $D.getDaysInMonth(x.getFullYear(), x.getMonth()); case "o": case "%G": return x.setWeek(x.getISOWeek()).toString("yyyy"); case "%g": return x._format("%G").slice(-2); case "a": case "%p": return t("tt").toLowerCase(); case "A": return t("tt").toUpperCase(); case "u": return p(x.getMilliseconds(), 3); case "I": return (x.isDaylightSavingTime()) ? 1 : 0; case "O": return x.getUTCOffset(); case "P": y = x.getUTCOffset(); return y.substring(0, y.length - 2) + ":" + y.substring(y.length - 2); case "B": var now = new Date(); return Math.floor(((now.getHours() * 3600) + (now.getMinutes() * 60) + now.getSeconds() + (now.getTimezoneOffset() + 60) * 60) / 86.4); case "c": return x.toISOString().replace(/\"/g, ""); case "U": return $D.strtotime("now"); case "%c": return t("d") + " " + t("t"); case "%C": return Math.floor(x.getFullYear() / 100 + 1); } }, shouldOverrideDefaults: function (m) { switch (m) { case "%e": return true; default: return false; } }, parse: function (m, context) { var formatString, c = context || new Date(); formatString = normalizer.substitutes(m); if (formatString) { return formatString; } formatString = normalizer.interpreted(m, c); if (formatString) { return formatString; } else { return m; } } }; $D.normalizeFormat = function (format, context) { return format.replace(/(%|\\)?.|%%/g, function(t){ return normalizer.parse(t, context); }); }; /** * Format a local Unix timestamp according to locale settings * * Example: * Date.strftime("%m/%d/%y", new Date()); // "04/13/08" * Date.strftime("c", "2008-04-13T17:52:03Z"); // "04/13/08" * * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @param {Number|String} The number representing the number of seconds that have elapsed since January 1, 1970 (local time). * @return {String} A string representation of the current Date object. */ $D.strftime = function (format, time) { var d = Date.parse(time); return d._format(format); }; /** * Parse any textual datetime description into a Unix timestamp. * A Unix timestamp is the number of seconds that have elapsed since January 1, 1970 (midnight UTC/GMT). * * Example: * Date.strtotime("04/13/08"); // 1208044800 * Date.strtotime("1970-01-01T00:00:00Z"); // 0 * * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @param {Object} A string or date object. * @return {String} A string representation of the current Date object. */ $D.strtotime = function (time) { var d = $D.parse(time); return Math.round($D.UTC(d.getUTCFullYear(), d.getUTCMonth(), d.getUTCDate(), d.getUTCHours(), d.getUTCMinutes(), d.getUTCSeconds(), d.getUTCMilliseconds()) / 1000); }; /** * Converts the value of the current Date object to its equivalent string representation using a PHP/Unix style of date format specifiers. * Format Specifiers * Format Description Example * ------ --------------------------------------------------------------------------- ----------------------- * %a abbreviated weekday name according to the current localed "Mon" through "Sun" * %A full weekday name according to the current localed "Sunday" through "Saturday" * %b abbreviated month name according to the current localed "Jan" through "Dec" * %B full month name according to the current locale "January" through "December" * %c preferred date and time representation for the current locale "4/13/2008 12:33 PM" * %C century number (the year divided by 100 and truncated to an integer) "00" to "99" * %d day of the month as a decimal number "01" to "31" * %D same as %m/%d/%y "04/13/08" * %e day of the month as a decimal number, a single digit is preceded by a space "1" to "31" * %g like %G, but without the century "08" * %G The 4-digit year corresponding to the ISO week number (see %V). "2008" * This has the same format and value as %Y, except that if the ISO week number * belongs to the previous or next year, that year is used instead. * %h same as %b "Jan" through "Dec" * %H hour as a decimal number using a 24-hour clock. "00" to "23" * %I hour as a decimal number using a 12-hour clock. "01" to "12" * %j day of the year as a decimal number. "001" to "366" * %m month as a decimal number. "01" to "12" * %M minute as a decimal number. "00" to "59" * %n newline character "\n" * %p either "am" or "pm" according to the given time value, or the "am" or "pm" * corresponding strings for the current locale. * %r time in a.m. and p.m. notation "8:44 PM" * %R time in 24 hour notation "20:44" * %S second as a decimal number "00" to "59" * %t tab character "\t" * %T current time, equal to %H:%M:%S "12:49:11" * %u weekday as a decimal number ["1", "7"], with "1" representing Monday "1" to "7" * %U week number of the current year as a decimal number, starting with the "0" to ("52" or "53") * first Sunday as the first day of the first week * %V The ISO 8601:1988 week number of the current year as a decimal number, "00" to ("52" or "53") * range 01 to 53, where week 1 is the first week that has at least 4 days * in the current year, and with Monday as the first day of the week. * (Use %G or %g for the year component that corresponds to the week number * for the specified timestamp.) * %W week number of the current year as a decimal number, starting with the "00" to ("52" or "53") * first Monday as the first day of the first week * %w day of the week as a decimal, Sunday being "0" "0" to "6" * %x preferred date representation for the current locale without the time "4/13/2008" * %X preferred time representation for the current locale without the date "12:53:05" * %y year as a decimal number without a century "00" "99" * %Y year as a decimal number including the century "2008" * %Z time zone or name or abbreviation "UTC", "EST", "PST" * %z same as %Z * %% a literal "%" characters "%" * d Day of the month, 2 digits with leading zeros "01" to "31" * D A textual representation of a day, three letters "Mon" through "Sun" * j Day of the month without leading zeros "1" to "31" * l A full textual representation of the day of the week (lowercase "L") "Sunday" through "Saturday" * N ISO-8601 numeric representation of the day of the week (added in PHP 5.1.0) "1" (for Monday) through "7" (for Sunday) * S English ordinal suffix for the day of the month, 2 characters "st", "nd", "rd" or "th". Works well with j * w Numeric representation of the day of the week "0" (for Sunday) through "6" (for Saturday) * z The day of the year (starting from "0") "0" through "365" * W ISO-8601 week number of year, weeks starting on Monday "00" to ("52" or "53") * F A full textual representation of a month, such as January or March "January" through "December" * m Numeric representation of a month, with leading zeros "01" through "12" * M A short textual representation of a month, three letters "Jan" through "Dec" * n Numeric representation of a month, without leading zeros "1" through "12" * t Number of days in the given month "28" through "31" * L Whether it's a leap year "1" if it is a leap year, "0" otherwise * o ISO-8601 year number. This has the same value as Y, except that if the "2008" * ISO week number (W) belongs to the previous or next year, that year * is used instead. * Y A full numeric representation of a year, 4 digits "2008" * y A two digit representation of a year "08" * a Lowercase Ante meridiem and Post meridiem "am" or "pm" * A Uppercase Ante meridiem and Post meridiem "AM" or "PM" * B Swatch Internet time "000" through "999" * g 12-hour format of an hour without leading zeros "1" through "12" * G 24-hour format of an hour without leading zeros "0" through "23" * h 12-hour format of an hour with leading zeros "01" through "12" * H 24-hour format of an hour with leading zeros "00" through "23" * i Minutes with leading zeros "00" to "59" * s Seconds, with leading zeros "00" through "59" * u Milliseconds "54321" * e Timezone identifier "UTC", "EST", "PST" * I Whether or not the date is in daylight saving time (uppercase i) "1" if Daylight Saving Time, "0" otherwise * O Difference to Greenwich time (GMT) in hours "+0200", "-0600" * P Difference to Greenwich time (GMT) with colon between hours and minutes "+02:00", "-06:00" * T Timezone abbreviation "UTC", "EST", "PST" * Z Timezone offset in seconds. The offset for timezones west of UTC is "-43200" through "50400" * always negative, and for those east of UTC is always positive. * c ISO 8601 date "2004-02-12T15:19:21+00:00" * r RFC 2822 formatted date "Thu, 21 Dec 2000 16:01:07 +0200" * U Seconds since the Unix Epoch (January 1 1970 00:00:00 GMT) "0" * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @return {String} A string representation of the current Date object. */ var formatReplace = function (context) { return function (m) { var formatString, override = false; if (m.charAt(0) === "\\" || m.substring(0, 2) === "%%") { return m.replace("\\", "").replace("%%", "%"); } override = normalizer.shouldOverrideDefaults(m); formatString = $D.normalizeFormat(m, context); if (formatString) { return context.toString(formatString, override); } }; }; $P._format = function (format) { var formatter = formatReplace(this); if (!format) { return this._toString(); } else { return format.replace(/(%|\\)?.|%%/g, formatter); } }; if (!$P.format) { $P.format = $P._format; } }()); (function () { "use strict"; var gFn = function (attr) { return function () { return this[attr]; }; }; var sFn = function (attr) { return function (val) { this[attr] = val; return this; }; }; var attrs = ["years", "months", "days", "hours", "minutes", "seconds", "milliseconds"]; var addSetFuncs = function (context, attrs) { for (var i = 0; i < attrs.length ; i++) { var $a = attrs[i], $b = $a.slice(0, 1).toUpperCase() + $a.slice(1); context.prototype[$a] = 0; context.prototype["get" + $b] = gFn($a); context.prototype["set" + $b] = sFn($a); } }; /** * new TimeSpan(milliseconds); * new TimeSpan(days, hours, minutes, seconds); * new TimeSpan(days, hours, minutes, seconds, milliseconds); */ var TimeSpan = function (days, hours, minutes, seconds, milliseconds) { if (arguments.length === 1 && typeof days === "number") { var orient = (days < 0) ? -1 : +1; var millsLeft = Math.abs(days); this.setDays(Math.floor(millsLeft / 86400000) * orient); millsLeft = millsLeft % 86400000; this.setHours(Math.floor(millsLeft / 3600000) * orient); millsLeft = millsLeft % 3600000; this.setMinutes(Math.floor(millsLeft / 60000) * orient); millsLeft = millsLeft % 60000; this.setSeconds(Math.floor(millsLeft / 1000) * orient); millsLeft = millsLeft % 1000; this.setMilliseconds(millsLeft * orient); } else { this.set(days, hours, minutes, seconds, milliseconds); } this.getTotalMilliseconds = function () { return (this.getDays() * 86400000) + (this.getHours() * 3600000) + (this.getMinutes() * 60000) + (this.getSeconds() * 1000); }; this.compareTo = function (time) { var t1 = new Date(1970, 1, 1, this.getHours(), this.getMinutes(), this.getSeconds()), t2; if (time === null) { t2 = new Date(1970, 1, 1, 0, 0, 0); } else { t2 = new Date(1970, 1, 1, time.getHours(), time.getMinutes(), time.getSeconds()); } return (t1 < t2) ? -1 : (t1 > t2) ? 1 : 0; }; this.equals = function (time) { return (this.compareTo(time) === 0); }; this.add = function (time) { return (time === null) ? this : this.addSeconds(time.getTotalMilliseconds() / 1000); }; this.subtract = function (time) { return (time === null) ? this : this.addSeconds(-time.getTotalMilliseconds() / 1000); }; this.addDays = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 86400000)); }; this.addHours = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 3600000)); }; this.addMinutes = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 60000)); }; this.addSeconds = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 1000)); }; this.addMilliseconds = function (n) { return new TimeSpan(this.getTotalMilliseconds() + n); }; this.get12HourHour = function () { return (this.getHours() > 12) ? this.getHours() - 12 : (this.getHours() === 0) ? 12 : this.getHours(); }; this.getDesignator = function () { return (this.getHours() < 12) ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator; }; this.toString = function (format) { this._toString = function () { if (this.getDays() !== null && this.getDays() > 0) { return this.getDays() + "." + this.getHours() + ":" + this.p(this.getMinutes()) + ":" + this.p(this.getSeconds()); } else { return this.getHours() + ":" + this.p(this.getMinutes()) + ":" + this.p(this.getSeconds()); } }; this.p = function (s) { return (s.toString().length < 2) ? "0" + s : s; }; var me = this; return format ? format.replace(/dd?|HH?|hh?|mm?|ss?|tt?/g, function (format) { switch (format) { case "d": return me.getDays(); case "dd": return me.p(me.getDays()); case "H": return me.getHours(); case "HH": return me.p(me.getHours()); case "h": return me.get12HourHour(); case "hh": return me.p(me.get12HourHour()); case "m": return me.getMinutes(); case "mm": return me.p(me.getMinutes()); case "s": return me.getSeconds(); case "ss": return me.p(me.getSeconds()); case "t": return ((me.getHours() < 12) ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator).substring(0, 1); case "tt": return (me.getHours() < 12) ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator; } } ) : this._toString(); }; return this; }; addSetFuncs(TimeSpan, attrs.slice(2)); TimeSpan.prototype.set = function (days, hours, minutes, seconds, milliseconds){ this.setDays(days || this.getDays()); this.setHours(hours || this.getHours()); this.setMinutes(minutes || this.getMinutes()); this.setSeconds(seconds || this.getSeconds()); this.setMilliseconds(milliseconds || this.getMilliseconds()); }; /** * Gets the time of day for this date instances. * @return {TimeSpan} TimeSpan */ Date.prototype.getTimeOfDay = function () { return new TimeSpan(0, this.getHours(), this.getMinutes(), this.getSeconds(), this.getMilliseconds()); }; Date.TimeSpan = TimeSpan; if (typeof window !== "undefined" ) { // keeping API compatible for v1.x window.TimeSpan = TimeSpan; } }()); (function () { "use strict"; var attrs = ["years", "months", "days", "hours", "minutes", "seconds", "milliseconds"]; var gFn = function (attr) { return function () { return this[attr]; }; }; var sFn = function (attr) { return function (val) { this[attr] = val; return this; }; }; var addSetFuncs = function (context, attrs) { for (var i = 0; i < attrs.length ; i++) { var $a = attrs[i], $b = $a.slice(0, 1).toUpperCase() + $a.slice(1); context.prototype[$a] = 0; context.prototype["get" + $b] = gFn($a); context.prototype["set" + $b] = sFn($a); } }; var setMonthsAndYears = function (orient, d1, d2, context) { function inc() { d1.addMonths(-orient); context.months++; if (context.months === 12) { context.years++; context.months = 0; } } if (orient === +1) { while (d1 > d2) { inc(); } } else { while (d1 < d2) { inc(); } } context.months--; context.months *= orient; context.years *= orient; }; var adjustForDST = function(orient, startDate, endDate) { var hasDSTMismatch = (false === (startDate.isDaylightSavingTime() === endDate.isDaylightSavingTime())); if (hasDSTMismatch && orient === 1) { startDate.addHours(-1); } else if (hasDSTMismatch) { startDate.addHours(1); } }; /** * TimePeriod(startDate, endDate); * TimePeriod(years, months, days, hours, minutes, seconds, milliseconds); */ var TimePeriod = function (years, months, days, hours, minutes, seconds, milliseconds) { if (arguments.length === 7) { this.set(years, months, days, hours, minutes, seconds, milliseconds); } else if (arguments.length === 2 && arguments[0] instanceof Date && arguments[1] instanceof Date) { var startDate = arguments[0].clone(); var endDate = arguments[1].clone(); var orient = (startDate > endDate) ? +1 : -1; this.dates = { start: arguments[0].clone(), end: arguments[1].clone() }; setMonthsAndYears(orient, startDate, endDate, this); adjustForDST(orient, startDate, endDate); // // TODO - adjust for DST var diff = endDate - startDate; if (diff !== 0) { var ts = new TimeSpan(diff); this.set(this.years, this.months, ts.getDays(), ts.getHours(), ts.getMinutes(), ts.getSeconds(), ts.getMilliseconds()); } } return this; }; // create all the set functions. addSetFuncs(TimePeriod, attrs); TimePeriod.prototype.set = function (years, months, days, hours, minutes, seconds, milliseconds){ this.setYears(years || this.getYears()); this.setMonths(months || this.getMonths()); this.setDays(days || this.getDays()); this.setHours(hours || this.getHours()); this.setMinutes(minutes || this.getMinutes()); this.setSeconds(seconds || this.getSeconds()); this.setMilliseconds(milliseconds || this.getMilliseconds()); }; Date.TimePeriod = TimePeriod; if (typeof window !== "undefined") { // keeping API compatible for v1.x window.TimePeriod = TimePeriod; } }()); ================================================ FILE: build/date-zh-CN.js ================================================ /** * @overview datejs * @version 1.0.0-rc3 * @author Gregory Wild-Smith * @copyright 2015 Gregory Wild-Smith * @license MIT * @homepage https://github.com/abritinthebay/datejs */ /* * DateJS Culture String File * Country Code: zh-CN * Name: Chinese (People's Republic of China) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["zh-CN"] = { "name": "zh-CN", "englishName": "Chinese (People's Republic of China)", "nativeName": "中文(中华人民共和国)", "Sunday": "星期日", "Monday": "星期一", "Tuesday": "星期二", "Wednesday": "星期三", "Thursday": "星期四", "Friday": "星期五", "Saturday": "星期六", "Sun": "日", "Mon": "一", "Tue": "二", "Wed": "三", "Thu": "四", "Fri": "五", "Sat": "六", "Su": "日", "Mo": "一", "Tu": "二", "We": "三", "Th": "四", "Fr": "五", "Sa": "六", "S_Sun_Initial": "日", "M_Mon_Initial": "一", "T_Tue_Initial": "二", "W_Wed_Initial": "三", "T_Thu_Initial": "四", "F_Fri_Initial": "五", "S_Sat_Initial": "六", "January": "一月", "February": "二月", "March": "三月", "April": "四月", "May": "五月", "June": "六月", "July": "七月", "August": "八月", "September": "九月", "October": "十月", "November": "十一月", "December": "十二月", "Jan_Abbr": "一月", "Feb_Abbr": "二月", "Mar_Abbr": "三月", "Apr_Abbr": "四月", "May_Abbr": "五月", "Jun_Abbr": "六月", "Jul_Abbr": "七月", "Aug_Abbr": "八月", "Sep_Abbr": "九月", "Oct_Abbr": "十月", "Nov_Abbr": "十一月", "Dec_Abbr": "十二月", "AM": "上午", "PM": "下午", "firstDayOfWeek": 0, "twoDigitYearMax": 2029, "mdy": "ymd", "M/d/yyyy": "yyyy/M/d", "dddd, MMMM dd, yyyy": "yyyy'年'M'月'd'日'", "h:mm tt": "H:mm", "h:mm:ss tt": "H:mm:ss", "dddd, MMMM dd, yyyy h:mm:ss tt": "yyyy'年'M'月'd'日' H:mm:ss", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "M'月'd'日'", "MMMM, yyyy": "yyyy'年'M'月'", "/jan(uary)?/": "一月", "/feb(ruary)?/": "二月", "/mar(ch)?/": "三月", "/apr(il)?/": "四月", "/may/": "五月", "/jun(e)?/": "六月", "/jul(y)?/": "七月", "/aug(ust)?/": "八月", "/sep(t(ember)?)?/": "九月", "/oct(ober)?/": "十月", "/nov(ember)?/": "十一月", "/dec(ember)?/": "十二月", "/^su(n(day)?)?/": "^星期日", "/^mo(n(day)?)?/": "^星期一", "/^tu(e(s(day)?)?)?/": "^星期二", "/^we(d(nesday)?)?/": "^星期三", "/^th(u(r(s(day)?)?)?)?/": "^星期四", "/^fr(i(day)?)?/": "^星期五", "/^sa(t(urday)?)?/": "^星期六", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "zh-CN"; /** * @overview datejs * @version 1.0.0-rc3 * @author Gregory Wild-Smith * @copyright 2015 Gregory Wild-Smith * @license MIT * @homepage https://github.com/abritinthebay/datejs */(function () { var $D = Date; var lang = Date.CultureStrings ? Date.CultureStrings.lang : null; var loggedKeys = {}; // for debug purposes. var getText = { getFromKey: function (key, countryCode) { var output; if (Date.CultureStrings && Date.CultureStrings[countryCode] && Date.CultureStrings[countryCode][key]) { output = Date.CultureStrings[countryCode][key]; } else { output = getText.buildFromDefault(key); } if (key.charAt(0) === "/") { // Assume it's a regex output = getText.buildFromRegex(key, countryCode); } return output; }, getFromObjectValues: function (obj, countryCode) { var key, output = {}; for(key in obj) { if (obj.hasOwnProperty(key)) { output[key] = getText.getFromKey(obj[key], countryCode); } } return output; }, getFromObjectKeys: function (obj, countryCode) { var key, output = {}; for(key in obj) { if (obj.hasOwnProperty(key)) { output[getText.getFromKey(key, countryCode)] = obj[key]; } } return output; }, getFromArray: function (arr, countryCode) { var output = []; for (var i=0; i < arr.length; i++){ if (i in arr) { output[i] = getText.getFromKey(arr[i], countryCode); } } return output; }, buildFromDefault: function (key) { var output, length, split, last; switch(key) { case "name": output = "en-US"; break; case "englishName": output = "English (United States)"; break; case "nativeName": output = "English (United States)"; break; case "twoDigitYearMax": output = 2049; break; case "firstDayOfWeek": output = 0; break; default: output = key; split = key.split("_"); length = split.length; if (length > 1 && key.charAt(0) !== "/") { // if the key isn't a regex and it has a split. last = split[(length - 1)].toLowerCase(); if (last === "initial" || last === "abbr") { output = split[0]; } } break; } return output; }, buildFromRegex: function (key, countryCode) { var output; if (Date.CultureStrings && Date.CultureStrings[countryCode] && Date.CultureStrings[countryCode][key]) { output = new RegExp(Date.CultureStrings[countryCode][key], "i"); } else { output = new RegExp(key.replace(new RegExp("/", "g"),""), "i"); } return output; } }; var shallowMerge = function (obj1, obj2) { for (var attrname in obj2) { if (obj2.hasOwnProperty(attrname)) { obj1[attrname] = obj2[attrname]; } } }; var __ = function (key, language) { var countryCode = (language) ? language : lang; loggedKeys[key] = key; if (typeof key === "object") { if (key instanceof Array) { return getText.getFromArray(key, countryCode); } else { return getText.getFromObjectKeys(key, countryCode); } } else { return getText.getFromKey(key, countryCode); } }; var loadI18nScript = function (code) { // paatterned after jQuery's getScript. var url = Date.Config.i18n + code + ".js"; var head = document.getElementsByTagName("head")[0] || document.documentElement; var script = document.createElement("script"); script.src = url; var completed = false; var events = { done: function (){} // placeholder function }; // Attach handlers for all browsers script.onload = script.onreadystatechange = function() { if ( !completed && (!this.readyState || this.readyState === "loaded" || this.readyState === "complete") ) { events.done(); head.removeChild(script); } }; setTimeout(function() { head.insertBefore(script, head.firstChild); }, 0); // allows return to execute first return { done: function (cb) { events.done = function() { if (cb) { setTimeout(cb,0); } }; } }; }; var buildInfo = { buildFromMethodHash: function (obj) { var key; for(key in obj) { if (obj.hasOwnProperty(key)) { obj[key] = buildInfo[obj[key]](); } } return obj; }, timeZoneDST: function () { var DST = { "CHADT": "+1345", "NZDT": "+1300", "AEDT": "+1100", "ACDT": "+1030", "AZST": "+0500", "IRDT": "+0430", "EEST": "+0300", "CEST": "+0200", "BST": "+0100", "PMDT": "-0200", "ADT": "-0300", "NDT": "-0230", "EDT": "-0400", "CDT": "-0500", "MDT": "-0600", "PDT": "-0700", "AKDT": "-0800", "HADT": "-0900" }; return __(DST); }, timeZoneStandard: function () { var standard = { "LINT": "+1400", "TOT": "+1300", "CHAST": "+1245", "NZST": "+1200", "NFT": "+1130", "SBT": "+1100", "AEST": "+1000", "ACST": "+0930", "JST": "+0900", "CWST": "+0845", "CT": "+0800", "ICT": "+0700", "MMT": "+0630", "BST": "+0600", "NPT": "+0545", "IST": "+0530", "PKT": "+0500", "AFT": "+0430", "MSK": "+0400", "IRST": "+0330", "FET": "+0300", "EET": "+0200", "CET": "+0100", "GMT": "+0000", "UTC": "+0000", "CVT": "-0100", "GST": "-0200", "BRT": "-0300", "NST": "-0330", "AST": "-0400", "EST": "-0500", "CST": "-0600", "MST": "-0700", "PST": "-0800", "AKST": "-0900", "MIT": "-0930", "HST": "-1000", "SST": "-1100", "BIT": "-1200" }; return __(standard); }, timeZones: function (data) { var zone; data.timezones = []; for (zone in data.abbreviatedTimeZoneStandard) { if (data.abbreviatedTimeZoneStandard.hasOwnProperty(zone)) { data.timezones.push({ name: zone, offset: data.abbreviatedTimeZoneStandard[zone]}); } } for (zone in data.abbreviatedTimeZoneDST) { if (data.abbreviatedTimeZoneDST.hasOwnProperty(zone)) { data.timezones.push({ name: zone, offset: data.abbreviatedTimeZoneDST[zone], dst: true}); } } return data.timezones; }, days: function () { return __(["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"]); }, dayAbbr: function () { return __(["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"]); }, dayShortNames: function () { return __(["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"]); }, dayFirstLetters: function () { return __(["S_Sun_Initial", "M_Mon_Initial", "T_Tues_Initial", "W_Wed_Initial", "T_Thu_Initial", "F_Fri_Initial", "S_Sat_Initial"]); }, months: function () { return __(["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"]); }, monthAbbr: function () { return __(["Jan_Abbr", "Feb_Abbr", "Mar_Abbr", "Apr_Abbr", "May_Abbr", "Jun_Abbr", "Jul_Abbr", "Aug_Abbr", "Sep_Abbr", "Oct_Abbr", "Nov_Abbr", "Dec_Abbr"]); }, formatPatterns: function () { return getText.getFromObjectValues({ shortDate: "M/d/yyyy", longDate: "dddd, MMMM dd, yyyy", shortTime: "h:mm tt", longTime: "h:mm:ss tt", fullDateTime: "dddd, MMMM dd, yyyy h:mm:ss tt", sortableDateTime: "yyyy-MM-ddTHH:mm:ss", universalSortableDateTime: "yyyy-MM-dd HH:mm:ssZ", rfc1123: "ddd, dd MMM yyyy HH:mm:ss", monthDay: "MMMM dd", yearMonth: "MMMM, yyyy" }, Date.i18n.currentLanguage()); }, regex: function () { return getText.getFromObjectValues({ inTheMorning: "/( in the )(morn(ing)?)\\b/", thisMorning: "/(this )(morn(ing)?)\\b/", amThisMorning: "/(\b\\d(am)? )(this )(morn(ing)?)/", inTheEvening: "/( in the )(even(ing)?)\\b/", thisEvening: "/(this )(even(ing)?)\\b/", pmThisEvening: "/(\b\\d(pm)? )(this )(even(ing)?)/", jan: "/jan(uary)?/", feb: "/feb(ruary)?/", mar: "/mar(ch)?/", apr: "/apr(il)?/", may: "/may/", jun: "/jun(e)?/", jul: "/jul(y)?/", aug: "/aug(ust)?/", sep: "/sep(t(ember)?)?/", oct: "/oct(ober)?/", nov: "/nov(ember)?/", dec: "/dec(ember)?/", sun: "/^su(n(day)?)?/", mon: "/^mo(n(day)?)?/", tue: "/^tu(e(s(day)?)?)?/", wed: "/^we(d(nesday)?)?/", thu: "/^th(u(r(s(day)?)?)?)?/", fri: "/fr(i(day)?)?/", sat: "/^sa(t(urday)?)?/", future: "/^next/", past: "/^last|past|prev(ious)?/", add: "/^(\\+|aft(er)?|from|hence)/", subtract: "/^(\\-|bef(ore)?|ago)/", yesterday: "/^yes(terday)?/", today: "/^t(od(ay)?)?/", tomorrow: "/^tom(orrow)?/", now: "/^n(ow)?/", millisecond: "/^ms|milli(second)?s?/", second: "/^sec(ond)?s?/", minute: "/^mn|min(ute)?s?/", hour: "/^h(our)?s?/", week: "/^w(eek)?s?/", month: "/^m(onth)?s?/", day: "/^d(ay)?s?/", year: "/^y(ear)?s?/", shortMeridian: "/^(a|p)/", longMeridian: "/^(a\\.?m?\\.?|p\\.?m?\\.?)/", timezone: "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/", ordinalSuffix: "/^\\s*(st|nd|rd|th)/", timeContext: "/^\\s*(\\:|a(?!u|p)|p)/" }, Date.i18n.currentLanguage()); } }; var CultureInfo = function () { var info = getText.getFromObjectValues({ name: "name", englishName: "englishName", nativeName: "nativeName", amDesignator: "AM", pmDesignator: "PM", firstDayOfWeek: "firstDayOfWeek", twoDigitYearMax: "twoDigitYearMax", dateElementOrder: "mdy" }, Date.i18n.currentLanguage()); var constructedInfo = buildInfo.buildFromMethodHash({ dayNames: "days", abbreviatedDayNames: "dayAbbr", shortestDayNames: "dayShortNames", firstLetterDayNames: "dayFirstLetters", monthNames: "months", abbreviatedMonthNames: "monthAbbr", formatPatterns: "formatPatterns", regexPatterns: "regex", abbreviatedTimeZoneDST: "timeZoneDST", abbreviatedTimeZoneStandard: "timeZoneStandard" }); shallowMerge(info, constructedInfo); buildInfo.timeZones(info); return info; }; $D.i18n = { __: function (key, lang) { return __(key, lang); }, currentLanguage: function () { return lang || "en-US"; }, setLanguage: function (code, force, cb) { var async = false; if (force || code === "en-US" || (!!Date.CultureStrings && !!Date.CultureStrings[code])) { lang = code; Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings.lang = code; Date.CultureInfo = new CultureInfo(); } else { if (!(!!Date.CultureStrings && !!Date.CultureStrings[code])) { if (typeof exports !== "undefined" && this.exports !== exports) { // we're in a Node enviroment, load it using require try { require("../i18n/" + code + ".js"); lang = code; Date.CultureStrings.lang = code; Date.CultureInfo = new CultureInfo(); } catch (e) { // var str = "The language for '" + code + "' could not be loaded by Node. It likely does not exist."; throw new Error("The DateJS IETF language tag '" + code + "' could not be loaded by Node. It likely does not exist."); } } else if (Date.Config && Date.Config.i18n) { // we know the location of the files, so lets load them async = true; loadI18nScript(code).done(function(){ lang = code; Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings.lang = code; Date.CultureInfo = new CultureInfo(); $D.Parsing.Normalizer.buildReplaceData(); // because this is async if ($D.Grammar) { $D.Grammar.buildGrammarFormats(); // so we can parse those strings... } if (cb) { setTimeout(cb,0); } }); } else { Date.console.error("The DateJS IETF language tag '" + code + "' is not available and has not been loaded."); return false; } } } $D.Parsing.Normalizer.buildReplaceData(); // rebuild normalizer strings if ($D.Grammar) { $D.Grammar.buildGrammarFormats(); // so we can parse those strings... } if (!async && cb) { setTimeout(cb,0); } }, getLoggedKeys: function () { return loggedKeys; }, updateCultureInfo: function () { Date.CultureInfo = new CultureInfo(); } }; $D.i18n.updateCultureInfo(); // run automatically }()); (function () { var $D = Date, $P = $D.prototype, p = function (s, l) { if (!l) { l = 2; } return ("000" + s).slice(l * -1); }; if (typeof window !== "undefined" && typeof window.console !== "undefined" && typeof window.console.log !== "undefined") { $D.console = console; // used only to raise non-critical errors if available } else { // set mock so we don't give errors. $D.console = { log: function(){}, error: function(){} }; } $D.Config = $D.Config || {}; $D.initOverloads = function() { /** * Overload of Date.now. Allows an alternate call for Date.now where it returns the * current Date as an object rather than just milliseconds since the Unix Epoch. * * Also provides an implementation of now() for browsers (IE<9) that don't have it. * * Backwards compatible so with work with either: * Date.now() [returns ms] * or * Date.now(true) [returns Date] */ if (!$D.now) { $D._now = function now() { return new Date().getTime(); }; } else if (!$D._now) { $D._now = $D.now; } $D.now = function (returnObj) { if (returnObj) { return $D.present(); } else { return $D._now(); } }; if ( !$P.toISOString ) { $P.toISOString = function() { return this.getUTCFullYear() + "-" + p(this.getUTCMonth() + 1) + "-" + p(this.getUTCDate()) + "T" + p(this.getUTCHours()) + ":" + p(this.getUTCMinutes()) + ":" + p(this.getUTCSeconds()) + "." + String( (this.getUTCMilliseconds()/1000).toFixed(3)).slice(2, 5) + "Z"; }; } // private if ( $P._toString === undefined ){ $P._toString = $P.toString; } }; $D.initOverloads(); /** * Gets a date that is set to the current date. The time is set to the start of the day (00:00 or 12:00 AM). * @return {Date} The current date. */ $D.today = function () { return new Date().clearTime(); }; /** * Gets a date that is set to the current date and time (same as new Date, but chainable) * @return {Date} The current date. */ $D.present = function () { return new Date(); }; /** * Compares the first date to the second date and returns an number indication of their relative values. * @param {Date} First Date object to compare [Required]. * @param {Date} Second Date object to compare to [Required]. * @return {Number} -1 = date1 is lessthan date2. 0 = values are equal. 1 = date1 is greaterthan date2. */ $D.compare = function (date1, date2) { if (isNaN(date1) || isNaN(date2)) { throw new Error(date1 + " - " + date2); } else if (date1 instanceof Date && date2 instanceof Date) { return (date1 < date2) ? -1 : (date1 > date2) ? 1 : 0; } else { throw new TypeError(date1 + " - " + date2); } }; /** * Compares the first Date object to the second Date object and returns true if they are equal. * @param {Date} First Date object to compare [Required] * @param {Date} Second Date object to compare to [Required] * @return {Boolean} true if dates are equal. false if they are not equal. */ $D.equals = function (date1, date2) { return (date1.compareTo(date2) === 0); }; /** * Gets the language appropriate day name when given the day number(0-6) * eg - 0 == Sunday * @return {String} The day name */ $D.getDayName = function (n) { return Date.CultureInfo.dayNames[n]; }; /** * Gets the day number (0-6) if given a CultureInfo specific string which is a valid dayName, abbreviatedDayName or shortestDayName (two char). * @param {String} The name of the day (eg. "Monday, "Mon", "tuesday", "tue", "We", "we"). * @return {Number} The day number */ $D.getDayNumberFromName = function (name) { var n = Date.CultureInfo.dayNames, m = Date.CultureInfo.abbreviatedDayNames, o = Date.CultureInfo.shortestDayNames, s = name.toLowerCase(); for (var i = 0; i < n.length; i++) { if (n[i].toLowerCase() === s || m[i].toLowerCase() === s || o[i].toLowerCase() === s) { return i; } } return -1; }; /** * Gets the month number (0-11) if given a Culture Info specific string which is a valid monthName or abbreviatedMonthName. * @param {String} The name of the month (eg. "February, "Feb", "october", "oct"). * @return {Number} The day number */ $D.getMonthNumberFromName = function (name) { var n = Date.CultureInfo.monthNames, m = Date.CultureInfo.abbreviatedMonthNames, s = name.toLowerCase(); for (var i = 0; i < n.length; i++) { if (n[i].toLowerCase() === s || m[i].toLowerCase() === s) { return i; } } return -1; }; /** * Gets the language appropriate month name when given the month number(0-11) * eg - 0 == January * @return {String} The month name */ $D.getMonthName = function (n) { return Date.CultureInfo.monthNames[n]; }; /** * Determines if the current date instance is within a LeapYear. * @param {Number} The year. * @return {Boolean} true if date is within a LeapYear, otherwise false. */ $D.isLeapYear = function (year) { return ((year % 4 === 0 && year % 100 !== 0) || year % 400 === 0); }; /** * Gets the number of days in the month, given a year and month value. Automatically corrects for LeapYear. * @param {Number} The year. * @param {Number} The month (0-11). * @return {Number} The number of days in the month. */ $D.getDaysInMonth = function (year, month) { if (!month && $D.validateMonth(year)) { month = year; year = Date.today().getFullYear(); } return [31, ($D.isLeapYear(year) ? 29 : 28), 31, 30, 31, 30, 31, 31, 30, 31, 30, 31][month]; }; $P.getDaysInMonth = function () { return $D.getDaysInMonth(this.getFullYear(), this.getMonth()); }; $D.getTimezoneAbbreviation = function (offset, dst) { var p, n = (dst || false) ? Date.CultureInfo.abbreviatedTimeZoneDST : Date.CultureInfo.abbreviatedTimeZoneStandard; for (p in n) { if (n.hasOwnProperty(p)) { if (n[p] === offset) { return p; } } } return null; }; $D.getTimezoneOffset = function (name, dst) { var i, a =[], z = Date.CultureInfo.timezones; if (!name) { name = (new Date()).getTimezone();} for (i = 0; i < z.length; i++) { if (z[i].name === name.toUpperCase()) { a.push(i); } } if (!z[a[0]]) { return null; } if (a.length === 1 || !dst) { return z[a[0]].offset; } else { for (i=0; i < a.length; i++) { if (z[a[i]].dst) { return z[a[i]].offset; } } } }; $D.getQuarter = function (d) { d = d || new Date(); // If no date supplied, use today var q = [1,2,3,4]; return q[Math.floor(d.getMonth() / 3)]; // ~~~ is a bitwise op. Faster than Math.floor }; $D.getDaysLeftInQuarter = function (d) { d = d || new Date(); var qEnd = new Date(d); qEnd.setMonth(qEnd.getMonth() + 3 - qEnd.getMonth() % 3, 0); return Math.floor((qEnd - d) / 8.64e7); }; // private var validate = function (n, min, max, name) { name = name ? name : "Object"; if (typeof n === "undefined") { return false; } else if (typeof n !== "number") { throw new TypeError(n + " is not a Number."); } else if (n < min || n > max) { // As failing validation is *not* an exceptional circumstance // lets not throw a RangeError Exception here. // It's semantically correct but it's not sensible. return false; } return true; }; /** * Validates the number is within an acceptable range for milliseconds [0-999]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateMillisecond = function (value) { return validate(value, 0, 999, "millisecond"); }; /** * Validates the number is within an acceptable range for seconds [0-59]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateSecond = function (value) { return validate(value, 0, 59, "second"); }; /** * Validates the number is within an acceptable range for minutes [0-59]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateMinute = function (value) { return validate(value, 0, 59, "minute"); }; /** * Validates the number is within an acceptable range for hours [0-23]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateHour = function (value) { return validate(value, 0, 23, "hour"); }; /** * Validates the number is within an acceptable range for the days in a month [0-MaxDaysInMonth]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateDay = function (value, year, month) { if (year === undefined || year === null || month === undefined || month === null) { return false;} return validate(value, 1, $D.getDaysInMonth(year, month), "day"); }; /** * Validates the number is within an acceptable range for months [0-11]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateWeek = function (value) { return validate(value, 0, 53, "week"); }; /** * Validates the number is within an acceptable range for months [0-11]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateMonth = function (value) { return validate(value, 0, 11, "month"); }; /** * Validates the number is within an acceptable range for years. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateYear = function (value) { /** * Per ECMAScript spec the range of times supported by Date objects is * exactly -100,000,000 days to +100,000,000 days measured relative to * midnight at the beginning of 01 January, 1970 UTC. * This gives a range of 8,640,000,000,000,000 milliseconds to either * side of 01 January, 1970 UTC. * * Earliest possible date: Tue, 20 Apr 271,822 B.C. 00:00:00 UTC * Latest possible date: Sat, 13 Sep 275,760 00:00:00 UTC */ return validate(value, -271822, 275760, "year"); }; $D.validateTimezone = function(value) { var timezones = {"ACDT":1,"ACST":1,"ACT":1,"ADT":1,"AEDT":1,"AEST":1,"AFT":1,"AKDT":1,"AKST":1,"AMST":1,"AMT":1,"ART":1,"AST":1,"AWDT":1,"AWST":1,"AZOST":1,"AZT":1,"BDT":1,"BIOT":1,"BIT":1,"BOT":1,"BRT":1,"BST":1,"BTT":1,"CAT":1,"CCT":1,"CDT":1,"CEDT":1,"CEST":1,"CET":1,"CHADT":1,"CHAST":1,"CHOT":1,"ChST":1,"CHUT":1,"CIST":1,"CIT":1,"CKT":1,"CLST":1,"CLT":1,"COST":1,"COT":1,"CST":1,"CT":1,"CVT":1,"CWST":1,"CXT":1,"DAVT":1,"DDUT":1,"DFT":1,"EASST":1,"EAST":1,"EAT":1,"ECT":1,"EDT":1,"EEDT":1,"EEST":1,"EET":1,"EGST":1,"EGT":1,"EIT":1,"EST":1,"FET":1,"FJT":1,"FKST":1,"FKT":1,"FNT":1,"GALT":1,"GAMT":1,"GET":1,"GFT":1,"GILT":1,"GIT":1,"GMT":1,"GST":1,"GYT":1,"HADT":1,"HAEC":1,"HAST":1,"HKT":1,"HMT":1,"HOVT":1,"HST":1,"ICT":1,"IDT":1,"IOT":1,"IRDT":1,"IRKT":1,"IRST":1,"IST":1,"JST":1,"KGT":1,"KOST":1,"KRAT":1,"KST":1,"LHST":1,"LINT":1,"MAGT":1,"MART":1,"MAWT":1,"MDT":1,"MET":1,"MEST":1,"MHT":1,"MIST":1,"MIT":1,"MMT":1,"MSK":1,"MST":1,"MUT":1,"MVT":1,"MYT":1,"NCT":1,"NDT":1,"NFT":1,"NPT":1,"NST":1,"NT":1,"NUT":1,"NZDT":1,"NZST":1,"OMST":1,"ORAT":1,"PDT":1,"PET":1,"PETT":1,"PGT":1,"PHOT":1,"PHT":1,"PKT":1,"PMDT":1,"PMST":1,"PONT":1,"PST":1,"PYST":1,"PYT":1,"RET":1,"ROTT":1,"SAKT":1,"SAMT":1,"SAST":1,"SBT":1,"SCT":1,"SGT":1,"SLST":1,"SRT":1,"SST":1,"SYOT":1,"TAHT":1,"THA":1,"TFT":1,"TJT":1,"TKT":1,"TLT":1,"TMT":1,"TOT":1,"TVT":1,"UCT":1,"ULAT":1,"UTC":1,"UYST":1,"UYT":1,"UZT":1,"VET":1,"VLAT":1,"VOLT":1,"VOST":1,"VUT":1,"WAKT":1,"WAST":1,"WAT":1,"WEDT":1,"WEST":1,"WET":1,"WST":1,"YAKT":1,"YEKT":1,"Z":1}; return (timezones[value] === 1); }; $D.validateTimezoneOffset= function(value) { // timezones go from +14hrs to -12hrs, the +X hours are negative offsets. return (value > -841 && value < 721); }; }()); (function () { var $D = Date, $P = $D.prototype, p = function (s, l) { if (!l) { l = 2; } return ("000" + s).slice(l * -1); }; var validateConfigObject = function (obj) { var result = {}, self = this, prop, testFunc; testFunc = function (prop, func, value) { if (prop === "day") { var month = (obj.month !== undefined) ? obj.month : self.getMonth(); var year = (obj.year !== undefined) ? obj.year : self.getFullYear(); return $D[func](value, year, month); } else { return $D[func](value); } }; for (prop in obj) { if (Object.prototype.hasOwnProperty.call(obj, prop)) { var func = "validate" + prop.charAt(0).toUpperCase() + prop.slice(1); if ($D[func] && obj[prop] !== null && testFunc(prop, func, obj[prop])) { result[prop] = obj[prop]; } } } return result; }; /** * Resets the time of this Date object to 12:00 AM (00:00), which is the start of the day. * @param {Boolean} .clone() this date instance before clearing Time * @return {Date} this */ $P.clearTime = function () { this.setHours(0); this.setMinutes(0); this.setSeconds(0); this.setMilliseconds(0); return this; }; /** * Resets the time of this Date object to the current time ('now'). * @return {Date} this */ $P.setTimeToNow = function () { var n = new Date(); this.setHours(n.getHours()); this.setMinutes(n.getMinutes()); this.setSeconds(n.getSeconds()); this.setMilliseconds(n.getMilliseconds()); return this; }; /** * Returns a new Date object that is an exact date and time copy of the original instance. * @return {Date} A new Date instance */ $P.clone = function () { return new Date(this.getTime()); }; /** * Compares this instance to a Date object and returns an number indication of their relative values. * @param {Date} Date object to compare [Required] * @return {Number} -1 = this is lessthan date. 0 = values are equal. 1 = this is greaterthan date. */ $P.compareTo = function (date) { return Date.compare(this, date); }; /** * Compares this instance to another Date object and returns true if they are equal. * @param {Date} Date object to compare. If no date to compare, new Date() [now] is used. * @return {Boolean} true if dates are equal. false if they are not equal. */ $P.equals = function (date) { return Date.equals(this, (date !== undefined ? date : new Date())); }; /** * Determines if this instance is between a range of two dates or equal to either the start or end dates. * @param {Date} Start of range [Required] * @param {Date} End of range [Required] * @return {Boolean} true is this is between or equal to the start and end dates, else false */ $P.between = function (start, end) { return this.getTime() >= start.getTime() && this.getTime() <= end.getTime(); }; /** * Determines if this date occurs after the date to compare to. * @param {Date} Date object to compare. If no date to compare, new Date() ("now") is used. * @return {Boolean} true if this date instance is greater than the date to compare to (or "now"), otherwise false. */ $P.isAfter = function (date) { return this.compareTo(date || new Date()) === 1; }; /** * Determines if this date occurs before the date to compare to. * @param {Date} Date object to compare. If no date to compare, new Date() ("now") is used. * @return {Boolean} true if this date instance is less than the date to compare to (or "now"). */ $P.isBefore = function (date) { return (this.compareTo(date || new Date()) === -1); }; /** * Determines if the current Date instance occurs today. * @return {Boolean} true if this date instance is 'today', otherwise false. */ /** * Determines if the current Date instance occurs on the same Date as the supplied 'date'. * If no 'date' to compare to is provided, the current Date instance is compared to 'today'. * @param {date} Date object to compare. If no date to compare, the current Date ("now") is used. * @return {Boolean} true if this Date instance occurs on the same Day as the supplied 'date'. */ $P.isToday = $P.isSameDay = function (date) { return this.clone().clearTime().equals((date || new Date()).clone().clearTime()); }; /** * Adds the specified number of milliseconds to this instance. * @param {Number} The number of milliseconds to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addMilliseconds = function (value) { if (!value) { return this; } this.setTime(this.getTime() + value * 1); return this; }; /** * Adds the specified number of seconds to this instance. * @param {Number} The number of seconds to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addSeconds = function (value) { if (!value) { return this; } return this.addMilliseconds(value * 1000); }; /** * Adds the specified number of seconds to this instance. * @param {Number} The number of seconds to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addMinutes = function (value) { if (!value) { return this; } return this.addMilliseconds(value * 60000); // 60*1000 }; /** * Adds the specified number of hours to this instance. * @param {Number} The number of hours to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addHours = function (value) { if (!value) { return this; } return this.addMilliseconds(value * 3600000); // 60*60*1000 }; /** * Adds the specified number of days to this instance. * @param {Number} The number of days to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addDays = function (value) { if (!value) { return this; } this.setDate(this.getDate() + value * 1); return this; }; /** * Adds the specified number of weekdays (ie - not sat or sun) to this instance. * @param {Number} The number of days to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addWeekdays = function (value) { if (!value) { return this; } var day = this.getDay(); var weeks = (Math.ceil(Math.abs(value)/7)); if (day === 0 || day === 6) { if (value > 0) { this.next().monday(); this.addDays(-1); day = this.getDay(); } } if (value < 0) { while (value < 0) { this.addDays(-1); day = this.getDay(); if (day !== 0 && day !== 6) { value++; } } return this; } else if (value > 5 || (6-day) <= value) { value = value + (weeks * 2); } return this.addDays(value); }; /** * Adds the specified number of weeks to this instance. * @param {Number} The number of weeks to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addWeeks = function (value) { if (!value) { return this; } return this.addDays(value * 7); }; /** * Adds the specified number of months to this instance. * @param {Number} The number of months to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addMonths = function (value) { if (!value) { return this; } var n = this.getDate(); this.setDate(1); this.setMonth(this.getMonth() + value * 1); this.setDate(Math.min(n, $D.getDaysInMonth(this.getFullYear(), this.getMonth()))); return this; }; $P.addQuarters = function (value) { if (!value) { return this; } // note this will take you to the same point in the quarter as you are now. // i.e. - if you are 15 days into the quarter you'll be 15 days into the resulting one. // bonus: this allows adding fractional quarters return this.addMonths(value * 3); }; /** * Adds the specified number of years to this instance. * @param {Number} The number of years to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addYears = function (value) { if (!value) { return this; } return this.addMonths(value * 12); }; /** * Adds (or subtracts) to the value of the years, months, weeks, days, hours, minutes, seconds, milliseconds of the date instance using given configuration object. Positive and Negative values allowed. * Example

	Date.today().add( { days: 1, months: 1 } )

	new Date().add( { years: -1 } )
	
* @param {Object} Configuration object containing attributes (months, days, etc.) * @return {Date} this */ $P.add = function (config) { if (typeof config === "number") { this._orient = config; return this; } var x = config; if (x.day) { // If we should be a different date than today (eg: for 'tomorrow -1d', etc). // Should only effect parsing, not direct usage (eg, Finish and FinishExact) if ((x.day - this.getDate()) !== 0) { this.setDate(x.day); } } if (x.milliseconds) { this.addMilliseconds(x.milliseconds); } if (x.seconds) { this.addSeconds(x.seconds); } if (x.minutes) { this.addMinutes(x.minutes); } if (x.hours) { this.addHours(x.hours); } if (x.weeks) { this.addWeeks(x.weeks); } if (x.months) { this.addMonths(x.months); } if (x.years) { this.addYears(x.years); } if (x.days) { this.addDays(x.days); } return this; }; /** * Get the week number. Week one (1) is the week which contains the first Thursday of the year. Monday is considered the first day of the week. * The .getWeek() function does NOT convert the date to UTC. The local datetime is used. * Please use .getISOWeek() to get the week of the UTC converted date. * @return {Number} 1 to 53 */ $P.getWeek = function (utc) { // Create a copy of this date object var self, target = new Date(this.valueOf()); if (utc) { target.addMinutes(target.getTimezoneOffset()); self = target.clone(); } else { self = this; } // ISO week date weeks start on monday // so correct the day number var dayNr = (self.getDay() + 6) % 7; // ISO 8601 states that week 1 is the week // with the first thursday of that year. // Set the target date to the thursday in the target week target.setDate(target.getDate() - dayNr + 3); // Store the millisecond value of the target date var firstThursday = target.valueOf(); // Set the target to the first thursday of the year // First set the target to january first target.setMonth(0, 1); // Not a thursday? Correct the date to the next thursday if (target.getDay() !== 4) { target.setMonth(0, 1 + ((4 - target.getDay()) + 7) % 7); } // The weeknumber is the number of weeks between the // first thursday of the year and the thursday in the target week return 1 + Math.ceil((firstThursday - target) / 604800000); // 604800000 = 7 * 24 * 3600 * 1000 }; /** * Get the ISO 8601 week number. Week one ("01") is the week which contains the first Thursday of the year. Monday is considered the first day of the week. * The .getISOWeek() function does convert the date to it's UTC value. Please use .getWeek() to get the week of the local date. * @return {String} "01" to "53" */ $P.getISOWeek = function () { return p(this.getWeek(true)); }; /** * Moves the date to Monday of the week set. Week one (1) is the week which contains the first Thursday of the year. * @param {Number} A Number (1 to 53) that represents the week of the year. * @return {Date} this */ $P.setWeek = function (n) { if ((n - this.getWeek()) === 0) { if (this.getDay() !== 1) { return this.moveToDayOfWeek(1, (this.getDay() > 1 ? -1 : 1)); } else { return this; } } else { return this.moveToDayOfWeek(1, (this.getDay() > 1 ? -1 : 1)).addWeeks(n - this.getWeek()); } }; $P.setQuarter = function (qtr) { var month = Math.abs(((qtr-1) * 3) + 1); return this.setMonth(month, 1); }; $P.getQuarter = function () { return Date.getQuarter(this); }; $P.getDaysLeftInQuarter = function () { return Date.getDaysLeftInQuarter(this); }; /** * Moves the date to the next n'th occurrence of the dayOfWeek starting from the beginning of the month. The number (-1) is a magic number and will return the last occurrence of the dayOfWeek in the month. * @param {Number} The dayOfWeek to move to * @param {Number} The n'th occurrence to move to. Use (-1) to return the last occurrence in the month * @return {Date} this */ $P.moveToNthOccurrence = function (dayOfWeek, occurrence) { if (dayOfWeek === "Weekday") { if (occurrence > 0) { this.moveToFirstDayOfMonth(); if (this.is().weekday()) { occurrence -= 1; } } else if (occurrence < 0) { this.moveToLastDayOfMonth(); if (this.is().weekday()) { occurrence += 1; } } else { return this; } return this.addWeekdays(occurrence); } var shift = 0; if (occurrence > 0) { shift = occurrence - 1; } else if (occurrence === -1) { this.moveToLastDayOfMonth(); if (this.getDay() !== dayOfWeek) { this.moveToDayOfWeek(dayOfWeek, -1); } return this; } return this.moveToFirstDayOfMonth().addDays(-1).moveToDayOfWeek(dayOfWeek, +1).addWeeks(shift); }; var moveToN = function (getFunc, addFunc, nVal) { return function (value, orient) { var diff = (value - this[getFunc]() + nVal * (orient || +1)) % nVal; return this[addFunc]((diff === 0) ? diff += nVal * (orient || +1) : diff); }; }; /** * Move to the next or last dayOfWeek based on the orient value. * @param {Number} The dayOfWeek to move to * @param {Number} Forward (+1) or Back (-1). Defaults to +1. [Optional] * @return {Date} this */ $P.moveToDayOfWeek = moveToN("getDay", "addDays", 7); /** * Move to the next or last month based on the orient value. * @param {Number} The month to move to. 0 = January, 11 = December * @param {Number} Forward (+1) or Back (-1). Defaults to +1. [Optional] * @return {Date} this */ $P.moveToMonth = moveToN("getMonth", "addMonths", 12); /** * Get the Ordinate of the current day ("th", "st", "rd"). * @return {String} */ $P.getOrdinate = function () { var num = this.getDate(); return ord(num); }; /** * Get the Ordinal day (numeric day number) of the year, adjusted for leap year. * @return {Number} 1 through 365 (366 in leap years) */ $P.getOrdinalNumber = function () { return Math.ceil((this.clone().clearTime() - new Date(this.getFullYear(), 0, 1)) / 86400000) + 1; }; /** * Get the time zone abbreviation of the current date. * @return {String} The abbreviated time zone name (e.g. "EST") */ $P.getTimezone = function () { return $D.getTimezoneAbbreviation(this.getUTCOffset(), this.isDaylightSavingTime()); }; $P.setTimezoneOffset = function (offset) { var here = this.getTimezoneOffset(), there = Number(offset) * -6 / 10; return (there || there === 0) ? this.addMinutes(there - here) : this; }; $P.setTimezone = function (offset) { return this.setTimezoneOffset($D.getTimezoneOffset(offset)); }; /** * Indicates whether Daylight Saving Time is observed in the current time zone. * @return {Boolean} true|false */ $P.hasDaylightSavingTime = function () { return (Date.today().set({month: 0, day: 1}).getTimezoneOffset() !== Date.today().set({month: 6, day: 1}).getTimezoneOffset()); }; /** * Indicates whether this Date instance is within the Daylight Saving Time range for the current time zone. * @return {Boolean} true|false */ $P.isDaylightSavingTime = function () { return Date.today().set({month: 0, day: 1}).getTimezoneOffset() !== this.getTimezoneOffset(); }; /** * Get the offset from UTC of the current date. * @return {String} The 4-character offset string prefixed with + or - (e.g. "-0500") */ $P.getUTCOffset = function (offset) { var n = (offset || this.getTimezoneOffset()) * -10 / 6, r; if (n < 0) { r = (n - 10000).toString(); return r.charAt(0) + r.substr(2); } else { r = (n + 10000).toString(); return "+" + r.substr(1); } }; /** * Returns the number of milliseconds between this date and date. * @param {Date} Defaults to now * @return {Number} The diff in milliseconds */ $P.getElapsed = function (date) { return (date || new Date()) - this; }; /** * Set the value of year, month, day, hour, minute, second, millisecond of date instance using given configuration object. * Example

	Date.today().set( { day: 20, month: 1 } )

	new Date().set( { millisecond: 0 } )
	
* * @param {Object} Configuration object containing attributes (month, day, etc.) * @return {Date} this */ $P.set = function (config) { config = validateConfigObject.call(this, config); var key; for (key in config) { if (Object.prototype.hasOwnProperty.call(config, key)) { var name = key.charAt(0).toUpperCase() + key.slice(1); var addFunc, getFunc; if (key !== "week" && key !== "month" && key !== "timezone" && key !== "timezoneOffset") { name += "s"; } addFunc = "add" + name; getFunc = "get" + name; if (key === "month") { addFunc = addFunc + "s"; } else if (key === "year"){ getFunc = "getFullYear"; } if (key !== "day" && key !== "timezone" && key !== "timezoneOffset" && key !== "week" && key !== "hour") { this[addFunc](config[key] - this[getFunc]()); } else if ( key === "timezone"|| key === "timezoneOffset" || key === "week" || key === "hour") { this["set"+name](config[key]); } } } // day has to go last because you can't validate the day without first knowing the month if (config.day) { this.addDays(config.day - this.getDate()); } return this; }; /** * Moves the date to the first day of the month. * @return {Date} this */ $P.moveToFirstDayOfMonth = function () { return this.set({ day: 1 }); }; /** * Moves the date to the last day of the month. * @return {Date} this */ $P.moveToLastDayOfMonth = function () { return this.set({ day: $D.getDaysInMonth(this.getFullYear(), this.getMonth())}); }; /** * Converts the value of the current Date object to its equivalent string representation. * Format Specifiers * CUSTOM DATE AND TIME FORMAT STRINGS * Format Description Example * ------ --------------------------------------------------------------------------- ----------------------- * s The seconds of the minute between 0-59. "0" to "59" * ss The seconds of the minute with leading zero if required. "00" to "59" * * m The minute of the hour between 0-59. "0" or "59" * mm The minute of the hour with leading zero if required. "00" or "59" * * h The hour of the day between 1-12. "1" to "12" * hh The hour of the day with leading zero if required. "01" to "12" * * H The hour of the day between 0-23. "0" to "23" * HH The hour of the day with leading zero if required. "00" to "23" * * d The day of the month between 1 and 31. "1" to "31" * dd The day of the month with leading zero if required. "01" to "31" * ddd Abbreviated day name. Date.CultureInfo.abbreviatedDayNames. "Mon" to "Sun" * dddd The full day name. Date.CultureInfo.dayNames. "Monday" to "Sunday" * * M The month of the year between 1-12. "1" to "12" * MM The month of the year with leading zero if required. "01" to "12" * MMM Abbreviated month name. Date.CultureInfo.abbreviatedMonthNames. "Jan" to "Dec" * MMMM The full month name. Date.CultureInfo.monthNames. "January" to "December" * * yy The year as a two-digit number. "99" or "08" * yyyy The full four digit year. "1999" or "2008" * * t Displays the first character of the A.M./P.M. designator. "A" or "P" * Date.CultureInfo.amDesignator or Date.CultureInfo.pmDesignator * tt Displays the A.M./P.M. designator. "AM" or "PM" * Date.CultureInfo.amDesignator or Date.CultureInfo.pmDesignator * * S The ordinal suffix ("st, "nd", "rd" or "th") of the current day. "st, "nd", "rd" or "th" * * STANDARD DATE AND TIME FORMAT STRINGS * Format Description Example *------ --------------------------------------------------------------------------- ----------------------- * d The CultureInfo shortDate Format Pattern "M/d/yyyy" * D The CultureInfo longDate Format Pattern "dddd, MMMM dd, yyyy" * F The CultureInfo fullDateTime Format Pattern "dddd, MMMM dd, yyyy h:mm:ss tt" * m The CultureInfo monthDay Format Pattern "MMMM dd" * r The CultureInfo rfc1123 Format Pattern "ddd, dd MMM yyyy HH:mm:ss GMT" * s The CultureInfo sortableDateTime Format Pattern "yyyy-MM-ddTHH:mm:ss" * t The CultureInfo shortTime Format Pattern "h:mm tt" * T The CultureInfo longTime Format Pattern "h:mm:ss tt" * u The CultureInfo universalSortableDateTime Format Pattern "yyyy-MM-dd HH:mm:ssZ" * y The CultureInfo yearMonth Format Pattern "MMMM, yyyy" * * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @return {String} A string representation of the current Date object. */ var ord = function (n) { switch (n * 1) { case 1: case 21: case 31: return "st"; case 2: case 22: return "nd"; case 3: case 23: return "rd"; default: return "th"; } }; var parseStandardFormats = function (format) { var y, c = Date.CultureInfo.formatPatterns; switch (format) { case "d": return this.toString(c.shortDate); case "D": return this.toString(c.longDate); case "F": return this.toString(c.fullDateTime); case "m": return this.toString(c.monthDay); case "r": case "R": y = this.clone().addMinutes(this.getTimezoneOffset()); return y.toString(c.rfc1123) + " GMT"; case "s": return this.toString(c.sortableDateTime); case "t": return this.toString(c.shortTime); case "T": return this.toString(c.longTime); case "u": y = this.clone().addMinutes(this.getTimezoneOffset()); return y.toString(c.universalSortableDateTime); case "y": return this.toString(c.yearMonth); default: return false; } }; var parseFormatStringsClosure = function (context) { return function (m) { if (m.charAt(0) === "\\") { return m.replace("\\", ""); } switch (m) { case "hh": return p(context.getHours() < 13 ? (context.getHours() === 0 ? 12 : context.getHours()) : (context.getHours() - 12)); case "h": return context.getHours() < 13 ? (context.getHours() === 0 ? 12 : context.getHours()) : (context.getHours() - 12); case "HH": return p(context.getHours()); case "H": return context.getHours(); case "mm": return p(context.getMinutes()); case "m": return context.getMinutes(); case "ss": return p(context.getSeconds()); case "s": return context.getSeconds(); case "yyyy": return p(context.getFullYear(), 4); case "yy": return p(context.getFullYear()); case "y": return context.getFullYear(); case "E": case "dddd": return Date.CultureInfo.dayNames[context.getDay()]; case "ddd": return Date.CultureInfo.abbreviatedDayNames[context.getDay()]; case "dd": return p(context.getDate()); case "d": return context.getDate(); case "MMMM": return Date.CultureInfo.monthNames[context.getMonth()]; case "MMM": return Date.CultureInfo.abbreviatedMonthNames[context.getMonth()]; case "MM": return p((context.getMonth() + 1)); case "M": return context.getMonth() + 1; case "t": return context.getHours() < 12 ? Date.CultureInfo.amDesignator.substring(0, 1) : Date.CultureInfo.pmDesignator.substring(0, 1); case "tt": return context.getHours() < 12 ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator; case "S": return ord(context.getDate()); case "W": return context.getWeek(); case "WW": return context.getISOWeek(); case "Q": return "Q" + context.getQuarter(); case "q": return String(context.getQuarter()); case "z": return context.getTimezone(); case "Z": case "X": return Date.getTimezoneOffset(context.getTimezone()); case "ZZ": // Timezone offset in seconds return context.getTimezoneOffset() * -60; case "u": return context.getDay(); case "L": return ($D.isLeapYear(context.getFullYear())) ? 1 : 0; case "B": // Swatch Internet Time (.beats) return "@"+((context.getUTCSeconds() + (context.getUTCMinutes()*60) + ((context.getUTCHours()+1)*3600))/86.4); default: return m; } }; }; $P.toString = function (format, ignoreStandards) { // Standard Date and Time Format Strings. Formats pulled from CultureInfo file and // may vary by culture. if (!ignoreStandards && format && format.length === 1) { output = parseStandardFormats.call(this, format); if (output) { return output; } } var parseFormatStrings = parseFormatStringsClosure(this); return format ? format.replace(/((\\)?(dd?d?d?|MM?M?M?|yy?y?y?|hh?|HH?|mm?|ss?|tt?|S|q|Q|WW?W?W?)(?![^\[]*\]))/g, parseFormatStrings).replace(/\[|\]/g, "") : this._toString(); }; }()); /************************************************************* * SugarPak - Domain Specific Language - Syntactical Sugar * *************************************************************/ (function () { var $D = Date, $P = $D.prototype, $N = Number.prototype; // private $P._orient = +1; // private $P._nth = null; // private $P._is = false; // private $P._same = false; // private $P._isSecond = false; // private $N._dateElement = "days"; /** * Moves the date to the next instance of a date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.today().next().friday();
	Date.today().next().fri();
	Date.today().next().march();
	Date.today().next().mar();
	Date.today().next().week();
	
* * @return {Date} date */ $P.next = function () { this._move = true; this._orient = +1; return this; }; /** * Creates a new Date (Date.today()) and moves the date to the next instance of the date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.next().friday();
	Date.next().fri();
	Date.next().march();
	Date.next().mar();
	Date.next().week();
	
* * @return {Date} date */ $D.next = function () { return $D.today().next(); }; /** * Moves the date to the previous instance of a date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.today().last().friday();
	Date.today().last().fri();
	Date.today().last().march();
	Date.today().last().mar();
	Date.today().last().week();
	
* * @return {Date} date */ $P.last = $P.prev = $P.previous = function () { this._move = true; this._orient = -1; return this; }; /** * Creates a new Date (Date.today()) and moves the date to the previous instance of the date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.last().friday();
	Date.last().fri();
	Date.previous().march();
	Date.prev().mar();
	Date.last().week();
	
* * @return {Date} date */ $D.last = $D.prev = $D.previous = function () { return $D.today().last(); }; /** * Performs a equality check when followed by either a month name, day name or .weekday() function. * Example

	Date.today().is().friday(); // true|false
	Date.today().is().fri();
	Date.today().is().march();
	Date.today().is().mar();
	
* * @return {Boolean} true|false */ $P.is = function () { this._is = true; return this; }; /** * Determines if two date objects occur on/in exactly the same instance of the subsequent date part function. * The function .same() must be followed by a date part function (example: .day(), .month(), .year(), etc). * * An optional Date can be passed in the date part function. If now date is passed as a parameter, 'Now' is used. * * The following example demonstrates how to determine if two dates fall on the exact same day. * * Example

	var d1 = Date.today(); // today at 00:00
	var d2 = new Date();   // exactly now.

	// Do they occur on the same day?
	d1.same().day(d2); // true
	
	// Do they occur on the same hour?
	d1.same().hour(d2); // false, unless d2 hour is '00' (midnight).
	
	// What if it's the same day, but one year apart?
	var nextYear = Date.today().add(1).year();

	d1.same().day(nextYear); // false, because the dates must occur on the exact same day. 
	
* * Scenario: Determine if a given date occurs during some week period 2 months from now. * * Example

	var future = Date.today().add(2).months();
	return someDate.same().week(future); // true|false;
	
* * @return {Boolean} true|false */ $P.same = function () { this._same = true; this._isSecond = false; return this; }; /** * Determines if the current date/time occurs during Today. Must be preceded by the .is() function. * Example

	someDate.is().today();    // true|false
	new Date().is().today();  // true
	Date.today().is().today();// true
	Date.today().add(-1).day().is().today(); // false
	
* * @return {Boolean} true|false */ $P.today = function () { return this.same().day(); }; /** * Determines if the current date is a weekday. This function must be preceded by the .is() function. * Example

	Date.today().is().weekday(); // true|false
	
* * @return {Boolean} true|false */ $P.weekday = function () { if (this._nth) { return df("Weekday").call(this); } if (this._move) { return this.addWeekdays(this._orient); } if (this._is) { this._is = false; return (!this.is().sat() && !this.is().sun()); } return false; }; /** * Determines if the current date is on the weekend. This function must be preceded by the .is() function. * Example

	Date.today().is().weekend(); // true|false
	
* * @return {Boolean} true|false */ $P.weekend = function () { if (this._is) { this._is = false; return (this.is().sat() || this.is().sun()); } return false; }; /** * Sets the Time of the current Date instance. A string "6:15 pm" or config object {hour:18, minute:15} are accepted. * Example

	// Set time to 6:15pm with a String
	Date.today().at("6:15pm");

	// Set time to 6:15pm with a config object
	Date.today().at({hour:18, minute:15});
	
* * @return {Date} date */ $P.at = function (time) { return (typeof time === "string") ? $D.parse(this.toString("d") + " " + time) : this.set(time); }; /** * Creates a new Date() and adds this (Number) to the date based on the preceding date element function (eg. second|minute|hour|day|month|year). * Example

	// Undeclared Numbers must be wrapped with parentheses. Requirment of JavaScript.
	(3).days().fromNow();
	(6).months().fromNow();

	// Declared Number variables do not require parentheses. 
	var n = 6;
	n.months().fromNow();
	
* * @return {Date} A new Date instance */ $N.fromNow = $N.after = function (date) { var c = {}; c[this._dateElement] = this; return ((!date) ? new Date() : date.clone()).add(c); }; /** * Creates a new Date() and subtract this (Number) from the date based on the preceding date element function (eg. second|minute|hour|day|month|year). * Example

	// Undeclared Numbers must be wrapped with parentheses. Requirment of JavaScript.
	(3).days().ago();
	(6).months().ago();

	// Declared Number variables do not require parentheses. 
	var n = 6;
	n.months().ago();
	
* * @return {Date} A new Date instance */ $N.ago = $N.before = function (date) { var c = {}, s = (this._dateElement[this._dateElement.length-1] !== "s") ? this._dateElement + "s" : this._dateElement; c[s] = this * -1; return ((!date) ? new Date() : date.clone()).add(c); }; // Do NOT modify the following string tokens. These tokens are used to build dynamic functions. // All culture-specific strings can be found in the CultureInfo files. var dx = ("sunday monday tuesday wednesday thursday friday saturday").split(/\s/), mx = ("january february march april may june july august september october november december").split(/\s/), px = ("Millisecond Second Minute Hour Day Week Month Year Quarter Weekday").split(/\s/), pxf = ("Milliseconds Seconds Minutes Hours Date Week Month FullYear Quarter").split(/\s/), nth = ("final first second third fourth fifth").split(/\s/), de; /** * Returns an object literal of all the date parts. * Example

	var o = new Date().toObject();
	
	// { year: 2008, month: 4, week: 20, day: 13, hour: 18, minute: 9, second: 32, millisecond: 812 }
	
	// The object properties can be referenced directly from the object.
	
	alert(o.day);  // alerts "13"
	alert(o.year); // alerts "2008"
	
* * @return {Date} An object literal representing the original date object. */ $P.toObject = function () { var o = {}; for (var i = 0; i < px.length; i++) { if (this["get" + pxf[i]]) { o[px[i].toLowerCase()] = this["get" + pxf[i]](); } } return o; }; /** * Returns a date created from an object literal. Ignores the .week property if set in the config. * Example

	var o = new Date().toObject();
	
	return Date.fromObject(o); // will return the same date. 

	var o2 = {month: 1, day: 20, hour: 18}; // birthday party!
	Date.fromObject(o2);
	
* * @return {Date} An object literal representing the original date object. */ $D.fromObject = function(config) { config.week = null; return Date.today().set(config); }; // Create day name functions and abbreviated day name functions (eg. monday(), friday(), fri()). var df = function (n) { return function () { if (this._is) { this._is = false; return this.getDay() === n; } if (this._move) { this._move = null; } if (this._nth !== null) { // If the .second() function was called earlier, remove the _orient // from the date, and then continue. // This is required because 'second' can be used in two different context. // // Example // // Date.today().add(1).second(); // Date.march().second().monday(); // // Things get crazy with the following... // Date.march().add(1).second().second().monday(); // but it works!! // if (this._isSecond) { this.addSeconds(this._orient * -1); } // make sure we reset _isSecond this._isSecond = false; var ntemp = this._nth; this._nth = null; var temp = this.clone().moveToLastDayOfMonth(); this.moveToNthOccurrence(n, ntemp); if (this > temp) { throw new RangeError($D.getDayName(n) + " does not occur " + ntemp + " times in the month of " + $D.getMonthName(temp.getMonth()) + " " + temp.getFullYear() + "."); } return this; } return this.moveToDayOfWeek(n, this._orient); }; }; var sdf = function (n) { return function () { var t = $D.today(), shift = n - t.getDay(); if (n === 0 && Date.CultureInfo.firstDayOfWeek === 1 && t.getDay() !== 0) { shift = shift + 7; } return t.addDays(shift); }; }; // Create month name functions and abbreviated month name functions (eg. january(), march(), mar()). var month_instance_functions = function (n) { return function () { if (this._is) { this._is = false; return this.getMonth() === n; } return this.moveToMonth(n, this._orient); }; }; var month_static_functions = function (n) { return function () { return $D.today().set({ month: n, day: 1 }); }; }; var processTerms = function (names, staticFunc, instanceFunc) { for (var i = 0; i < names.length; i++) { // Create constant static Name variables. $D[names[i].toUpperCase()] = $D[names[i].toUpperCase().substring(0, 3)] = i; // Create Name functions. $D[names[i]] = $D[names[i].substring(0, 3)] = staticFunc(i); // Create Name instance functions. $P[names[i]] = $P[names[i].substring(0, 3)] = instanceFunc(i); } }; processTerms(dx, sdf, df); processTerms(mx, month_static_functions, month_instance_functions); // Create date element functions and plural date element functions used with Date (eg. day(), days(), months()). var ef = function (j) { return function () { // if the .second() function was called earlier, the _orient // has alread been added. Just return this and reset _isSecond. if (this._isSecond) { this._isSecond = false; return this; } if (this._same) { this._same = this._is = false; var o1 = this.toObject(), o2 = (arguments[0] || new Date()).toObject(), v = "", k = j.toLowerCase(); // the substr trick with -1 doesn't work in IE8 or less k = (k[k.length-1] === "s") ? k.substring(0,k.length-1) : k; for (var m = (px.length - 1); m > -1; m--) { v = px[m].toLowerCase(); if (o1[v] !== o2[v]) { return false; } if (k === v) { break; } } return true; } if (j.substring(j.length - 1) !== "s") { j += "s"; } if (this._move) { this._move = null; } return this["add" + j](this._orient); }; }; var nf = function (n) { return function () { this._dateElement = n; return this; }; }; for (var k = 0; k < px.length; k++) { de = px[k].toLowerCase(); if(de !== "weekday") { // Create date element functions and plural date element functions used with Date (eg. day(), days(), months()). $P[de] = $P[de + "s"] = ef(px[k]); // Create date element functions and plural date element functions used with Number (eg. day(), days(), months()). $N[de] = $N[de + "s"] = nf(de + "s"); } } $P._ss = ef("Second"); var nthfn = function (n) { return function (dayOfWeek) { if (this._same) { return this._ss(arguments[0]); } if (dayOfWeek || dayOfWeek === 0) { return this.moveToNthOccurrence(dayOfWeek, n); } this._nth = n; // if the operator is 'second' add the _orient, then deal with it later... if (n === 2 && (dayOfWeek === undefined || dayOfWeek === null)) { this._isSecond = true; return this.addSeconds(this._orient); } return this; }; }; for (var l = 0; l < nth.length; l++) { $P[nth[l]] = (l === 0) ? nthfn(-1) : nthfn(l); } }()); (function () { "use strict"; Date.Parsing = { Exception: function (s) { this.message = "Parse error at '" + s.substring(0, 10) + " ...'"; } }; var $P = Date.Parsing; var dayOffsets = { standard: [0,31,59,90,120,151,181,212,243,273,304,334], leap: [0,31,60,91,121,152,182,213,244,274,305,335] }; $P.isLeapYear = function(year) { return ((year % 4 === 0) && (year % 100 !== 0)) || (year % 400 === 0); }; var utils = { multiReplace : function (str, hash ) { var key; for (key in hash) { if (Object.prototype.hasOwnProperty.call(hash, key)) { var regex; if (typeof hash[key] === "function") { } else { regex = (hash[key] instanceof RegExp) ? hash[key] : new RegExp(hash[key], "g"); } str = str.replace(regex, key); } } return str; }, getDayOfYearFromWeek : function (obj) { var d, jan4, offset; obj.weekDay = (!obj.weekDay && obj.weekDay !== 0) ? 1 : obj.weekDay; d = new Date(obj.year, 0, 4); jan4 = d.getDay() === 0 ? 7 : d.getDay(); // JS is 0 indexed on Sunday. offset = jan4+3; obj.dayOfYear = ((obj.week * 7) + (obj.weekDay === 0 ? 7 : obj.weekDay))-offset; return obj; }, getDayOfYear : function (obj, dayOffset) { if (!obj.dayOfYear) { obj = utils.getDayOfYearFromWeek(obj); } for (var i=0;i <= dayOffset.length;i++) { if (obj.dayOfYear < dayOffset[i] || i === dayOffset.length) { obj.day = obj.day ? obj.day : (obj.dayOfYear - dayOffset[i-1]); break; } else { obj.month = i; } } return obj; }, adjustForTimeZone : function (obj, date) { var offset; if (obj.zone.toUpperCase() === "Z" || (obj.zone_hours === 0 && obj.zone_minutes === 0)) { // it's UTC/GML so work out the current timeszone offset offset = -date.getTimezoneOffset(); } else { offset = (obj.zone_hours*60) + (obj.zone_minutes || 0); if (obj.zone_sign === "+") { offset *= -1; } offset -= date.getTimezoneOffset(); } date.setMinutes(date.getMinutes()+offset); return date; }, setDefaults : function (obj) { obj.year = obj.year || Date.today().getFullYear(); obj.hours = obj.hours || 0; obj.minutes = obj.minutes || 0; obj.seconds = obj.seconds || 0; obj.milliseconds = obj.milliseconds || 0; if (!(!obj.month && (obj.week || obj.dayOfYear))) { // if we have a month, or if we don't but don't have the day calculation data obj.month = obj.month || 0; obj.day = obj.day || 1; } return obj; }, dataNum: function (data, mod, explict, postProcess) { var dataNum = data*1; if (mod) { if (postProcess) { return data ? mod(data)*1 : data; } else { return data ? mod(dataNum) : data; } } else if (!explict){ return data ? dataNum : data; } else { return (data && typeof data !== "undefined") ? dataNum : data; } }, timeDataProcess: function (obj) { var timeObj = {}; for (var x in obj.data) { if (obj.data.hasOwnProperty(x)) { timeObj[x] = obj.ignore[x] ? obj.data[x] : utils.dataNum(obj.data[x], obj.mods[x], obj.explict[x], obj.postProcess[x]); } } if (obj.data.secmins) { obj.data.secmins = obj.data.secmins.replace(",", ".") * 60; if (!timeObj.minutes) { timeObj.minutes = obj.data.secmins; } else if (!timeObj.seconds) { timeObj.seconds = obj.data.secmins; } delete obj.secmins; } return timeObj; }, buildTimeObjectFromData: function (data) { var time = utils.timeDataProcess({ data: { year : data[1], month : data[5], day : data[7], week : data[8], dayOfYear : data[10], hours : data[15], zone_hours : data[23], zone_minutes : data[24], zone : data[21], zone_sign : data[22], weekDay : data[9], minutes: data[16], seconds: data[19], milliseconds: data[20], secmins: data[18] }, mods: { month: function(data) { return data-1; }, weekDay: function (data) { data = Math.abs(data); return (data === 7 ? 0 : data); }, minutes: function (data) { return data.replace(":",""); }, seconds: function (data) { return Math.floor( (data.replace(":","").replace(",","."))*1 ); }, milliseconds: function (data) { return (data.replace(",",".")*1000); } }, postProcess: { minutes: true, seconds: true, milliseconds: true }, explict: { zone_hours: true, zone_minutes: true }, ignore: { zone: true, zone_sign: true, secmins: true } }); return time; }, addToHash: function (hash, keys, data) { keys = keys; data = data; var len = keys.length; for (var i = 0; i < len; i++) { hash[keys[i]] = data[i]; } return hash; }, combineRegex: function (r1, r2) { return new RegExp("(("+r1.source+")\\s("+r2.source+"))"); }, getDateNthString: function(add, last, inc){ if (add) { return Date.today().addDays(inc).toString("d"); } else if (last) { return Date.today().last()[inc]().toString("d"); } }, buildRegexData: function (array) { var arr = []; var len = array.length; for (var i=0; i < len; i++) { if (Object.prototype.toString.call(array[i]) === '[object Array]') { // oldIE compat version of Array.isArray arr.push(this.combineRegex(array[i][0], array[i][1])); } else { arr.push(array[i]); } } return arr; } }; $P.processTimeObject = function (obj) { var date, dayOffset; utils.setDefaults(obj); dayOffset = ($P.isLeapYear(obj.year)) ? dayOffsets.leap : dayOffsets.standard; if (!obj.month && (obj.week || obj.dayOfYear)) { utils.getDayOfYear(obj, dayOffset); } else { obj.dayOfYear = dayOffset[obj.month] + obj.day; } date = new Date(obj.year, obj.month, obj.day, obj.hours, obj.minutes, obj.seconds, obj.milliseconds); if (obj.zone) { utils.adjustForTimeZone(obj, date); // adjust (and calculate) for timezone } return date; }; $P.ISO = { regex : /^([\+-]?\d{4}(?!\d{2}\b))((-?)((0[1-9]|1[0-2])(\3([12]\d|0[1-9]|3[01]))?|W([0-4]\d|5[0-3])(-?[1-7])?|(00[1-9]|0[1-9]\d|[12]\d{2}|3([0-5]\d|6[1-6])))([T\s]((([01]\d|2[0-4])((:?)[0-5]\d)?|24\:?00)([\.,]\d+(?!:))?)?(\17[0-5]\d([\.,]\d+)?)?\s?([zZ]|([\+-])([01]\d|2[0-3]):?([0-5]\d)?)?)?)?$/, parse : function (s) { var time, data = s.match(this.regex); if (!data || !data.length) { return null; } time = utils.buildTimeObjectFromData(data); if (!time.year || (!time.year && (!time.month && !time.day) && (!time.week && !time.dayOfYear)) ) { return null; } return $P.processTimeObject(time); } }; $P.Numeric = { isNumeric: function (e){return!isNaN(parseFloat(e))&&isFinite(e);}, regex: /\b([0-1]?[0-9])([0-3]?[0-9])([0-2]?[0-9]?[0-9][0-9])\b/i, parse: function (s) { var data, i, time = {}, order = Date.CultureInfo.dateElementOrder.split(""); if (!(this.isNumeric(s)) || // if it's non-numeric OR (s[0] === "+" && s[0] === "-")) { // It's an arithmatic string (eg +/-1000) return null; } if (s.length < 5 && s.indexOf(".") < 0 && s.indexOf("/") < 0) { // assume it's just a year. time.year = s; return $P.processTimeObject(time); } data = s.match(this.regex); if (!data || !data.length) { return null; } for (i=0; i < order.length; i++) { switch(order[i]) { case "d": time.day = data[i+1]; break; case "m": time.month = (data[i+1]-1); break; case "y": time.year = data[i+1]; break; } } return $P.processTimeObject(time); } }; $P.Normalizer = { regexData: function () { var $R = Date.CultureInfo.regexPatterns; return utils.buildRegexData([ $R.tomorrow, $R.yesterday, [$R.past, $R.mon], [$R.past, $R.tue], [$R.past, $R.wed], [$R.past, $R.thu], [$R.past, $R.fri], [$R.past, $R.sat], [$R.past, $R.sun] ]); }, basicReplaceHash : function() { var $R = Date.CultureInfo.regexPatterns; return { "January": $R.jan.source, "February": $R.feb, "March": $R.mar, "April": $R.apr, "May": $R.may, "June": $R.jun, "July": $R.jul, "August": $R.aug, "September": $R.sep, "October": $R.oct, "November": $R.nov, "December": $R.dec, "": /\bat\b/gi, " ": /\s{2,}/, "am": $R.inTheMorning, "9am": $R.thisMorning, "pm": $R.inTheEvening, "7pm":$R.thisEvening }; }, keys : function(){ return [ utils.getDateNthString(true, false, 1), // tomorrow utils.getDateNthString(true, false, -1), // yesterday utils.getDateNthString(false, true, "monday"), //last mon utils.getDateNthString(false, true, "tuesday"), //last tues utils.getDateNthString(false, true, "wednesday"), //last wed utils.getDateNthString(false, true, "thursday"), //last thurs utils.getDateNthString(false, true, "friday"), //last fri utils.getDateNthString(false, true, "saturday"), //last sat utils.getDateNthString(false, true, "sunday") //last sun ]; }, buildRegexFunctions: function () { var $R = Date.CultureInfo.regexPatterns; var __ = Date.i18n.__; var tomorrowRE = new RegExp("(\\b\\d\\d?("+__("AM")+"|"+__("PM")+")? )("+$R.tomorrow.source.slice(1)+")", "i"); // adapted tomorrow regex for AM PM relative dates var todayRE = new RegExp($R.today.source + "(?!\\s*([+-]))\\b"); // today, but excludes the math operators (eg "today + 2h") this.replaceFuncs = [ [todayRE, function (full) { return (full.length > 1) ? Date.today().toString("d") : full; }], [tomorrowRE, function(full, m1) { var t = Date.today().addDays(1).toString("d"); return (t + " " + m1); }], [$R.amThisMorning, function(str, am){return am;}], [$R.pmThisEvening, function(str, pm){return pm;}] ]; }, buildReplaceData: function () { this.buildRegexFunctions(); this.replaceHash = utils.addToHash(this.basicReplaceHash(), this.keys(), this.regexData()); }, stringReplaceFuncs: function (s) { for (var i=0; i < this.replaceFuncs.length; i++) { s = s.replace(this.replaceFuncs[i][0], this.replaceFuncs[i][1]); } return s; }, parse: function (s) { s = this.stringReplaceFuncs(s); s = utils.multiReplace(s, this.replaceHash); try { var n = s.split(/([\s\-\.\,\/\x27]+)/); if (n.length === 3 && $P.Numeric.isNumeric(n[0]) && $P.Numeric.isNumeric(n[2]) && (n[2].length >= 4)) { // ok, so we're dealing with x/year. But that's not a full date. // This fixes wonky dateElementOrder parsing when set to dmy order. if (Date.CultureInfo.dateElementOrder[0] === "d") { s = "1/" + n[0] + "/" + n[2]; // set to 1st of month and normalize the seperator } } } catch (e) {} return s; } }; $P.Normalizer.buildReplaceData(); }()); (function () { var $P = Date.Parsing; var _ = $P.Operators = { // // Tokenizers // rtoken: function (r) { // regex token return function (s) { var mx = s.match(r); if (mx) { return ([ mx[0], s.substring(mx[0].length) ]); } else { throw new $P.Exception(s); } }; }, token: function () { // whitespace-eating token return function (s) { return _.rtoken(new RegExp("^\\s*" + s + "\\s*"))(s); }; }, stoken: function (s) { // string token return _.rtoken(new RegExp("^" + s)); }, // Atomic Operators until: function (p) { return function (s) { var qx = [], rx = null; while (s.length) { try { rx = p.call(this, s); } catch (e) { qx.push(rx[0]); s = rx[1]; continue; } break; } return [ qx, s ]; }; }, many: function (p) { return function (s) { var rx = [], r = null; while (s.length) { try { r = p.call(this, s); } catch (e) { return [ rx, s ]; } rx.push(r[0]); s = r[1]; } return [ rx, s ]; }; }, // generator operators -- see below optional: function (p) { return function (s) { var r = null; try { r = p.call(this, s); } catch (e) { return [ null, s ]; } return [ r[0], r[1] ]; }; }, not: function (p) { return function (s) { try { p.call(this, s); } catch (e) { return [null, s]; } throw new $P.Exception(s); }; }, ignore: function (p) { return p ? function (s) { var r = null; r = p.call(this, s); return [null, r[1]]; } : null; }, product: function () { var px = arguments[0], qx = Array.prototype.slice.call(arguments, 1), rx = []; for (var i = 0 ; i < px.length ; i++) { rx.push(_.each(px[i], qx)); } return rx; }, cache: function (rule) { var cache = {}, cache_length = 0, cache_keys = [], CACHE_MAX = Date.Config.CACHE_MAX || 100000, r = null; var cacheCheck = function () { if (cache_length === CACHE_MAX) { // kill several keys, don't want to have to do this all the time... for (var i=0; i < 10; i++) { var key = cache_keys.shift(); if (key) { delete cache[key]; cache_length--; } } } }; return function (s) { cacheCheck(); try { r = cache[s] = (cache[s] || rule.call(this, s)); } catch (e) { r = cache[s] = e; } cache_length++; cache_keys.push(s); if (r instanceof $P.Exception) { throw r; } else { return r; } }; }, // vector operators -- see below any: function () { var px = arguments; return function (s) { var r = null; for (var i = 0; i < px.length; i++) { if (px[i] == null) { continue; } try { r = (px[i].call(this, s)); } catch (e) { r = null; } if (r) { return r; } } throw new $P.Exception(s); }; }, each: function () { var px = arguments; return function (s) { var rx = [], r = null; for (var i = 0; i < px.length ; i++) { if (px[i] == null) { continue; } try { r = (px[i].call(this, s)); } catch (e) { throw new $P.Exception(s); } rx.push(r[0]); s = r[1]; } return [ rx, s]; }; }, all: function () { var px = arguments, _ = _; return _.each(_.optional(px)); }, // delimited operators sequence: function (px, d, c) { d = d || _.rtoken(/^\s*/); c = c || null; if (px.length === 1) { return px[0]; } return function (s) { var r = null, q = null; var rx = []; for (var i = 0; i < px.length ; i++) { try { r = px[i].call(this, s); } catch (e) { break; } rx.push(r[0]); try { q = d.call(this, r[1]); } catch (ex) { q = null; break; } s = q[1]; } if (!r) { throw new $P.Exception(s); } if (q) { throw new $P.Exception(q[1]); } if (c) { try { r = c.call(this, r[1]); } catch (ey) { throw new $P.Exception(r[1]); } } return [ rx, (r?r[1]:s) ]; }; }, // // Composite Operators // between: function (d1, p, d2) { d2 = d2 || d1; var _fn = _.each(_.ignore(d1), p, _.ignore(d2)); return function (s) { var rx = _fn.call(this, s); return [[rx[0][0], r[0][2]], rx[1]]; }; }, list: function (p, d, c) { d = d || _.rtoken(/^\s*/); c = c || null; return (p instanceof Array ? _.each(_.product(p.slice(0, -1), _.ignore(d)), p.slice(-1), _.ignore(c)) : _.each(_.many(_.each(p, _.ignore(d))), px, _.ignore(c))); }, set: function (px, d, c) { d = d || _.rtoken(/^\s*/); c = c || null; return function (s) { // r is the current match, best the current 'best' match // which means it parsed the most amount of input var r = null, p = null, q = null, rx = null, best = [[], s], last = false; // go through the rules in the given set for (var i = 0; i < px.length ; i++) { // last is a flag indicating whether this must be the last element // if there is only 1 element, then it MUST be the last one q = null; p = null; r = null; last = (px.length === 1); // first, we try simply to match the current pattern // if not, try the next pattern try { r = px[i].call(this, s); } catch (e) { continue; } // since we are matching against a set of elements, the first // thing to do is to add r[0] to matched elements rx = [[r[0]], r[1]]; // if we matched and there is still input to parse and // we don't already know this is the last element, // we're going to next check for the delimiter ... // if there's none, or if there's no input left to parse // than this must be the last element after all ... if (r[1].length > 0 && ! last) { try { q = d.call(this, r[1]); } catch (ex) { last = true; } } else { last = true; } // if we parsed the delimiter and now there's no more input, // that means we shouldn't have parsed the delimiter at all // so don't update r and mark this as the last element ... if (!last && q[1].length === 0) { last = true; } // so, if this isn't the last element, we're going to see if // we can get any more matches from the remaining (unmatched) // elements ... if (!last) { // build a list of the remaining rules we can match against, // i.e., all but the one we just matched against var qx = []; for (var j = 0; j < px.length ; j++) { if (i !== j) { qx.push(px[j]); } } // now invoke recursively set with the remaining input // note that we don't include the closing delimiter ... // we'll check for that ourselves at the end p = _.set(qx, d).call(this, q[1]); // if we got a non-empty set as a result ... // (otw rx already contains everything we want to match) if (p[0].length > 0) { // update current result, which is stored in rx ... // basically, pick up the remaining text from p[1] // and concat the result from p[0] so that we don't // get endless nesting ... rx[0] = rx[0].concat(p[0]); rx[1] = p[1]; } } // at this point, rx either contains the last matched element // or the entire matched set that starts with this element. // now we just check to see if this variation is better than // our best so far, in terms of how much of the input is parsed if (rx[1].length < best[1].length) { best = rx; } // if we've parsed all the input, then we're finished if (best[1].length === 0) { break; } } // so now we've either gone through all the patterns trying them // as the initial match; or we found one that parsed the entire // input string ... // if best has no matches, just return empty set ... if (best[0].length === 0) { return best; } // if a closing delimiter is provided, then we have to check it also if (c) { // we try this even if there is no remaining input because the pattern // may well be optional or match empty input ... try { q = c.call(this, best[1]); } catch (ey) { throw new $P.Exception(best[1]); } // it parsed ... be sure to update the best match remaining input best[1] = q[1]; } // if we're here, either there was no closing delimiter or we parsed it // so now we have the best match; just return it! return best; }; }, forward: function (gr, fname) { return function (s) { return gr[fname].call(this, s); }; }, // // Translation Operators // replace: function (rule, repl) { return function (s) { var r = rule.call(this, s); return [repl, r[1]]; }; }, process: function (rule, fn) { return function (s) { var r = rule.call(this, s); return [fn.call(this, r[0]), r[1]]; }; }, min: function (min, rule) { return function (s) { var rx = rule.call(this, s); if (rx[0].length < min) { throw new $P.Exception(s); } return rx; }; } }; // Generator Operators And Vector Operators // Generators are operators that have a signature of F(R) => R, // taking a given rule and returning another rule, such as // ignore, which parses a given rule and throws away the result. // Vector operators are those that have a signature of F(R1,R2,...) => R, // take a list of rules and returning a new rule, such as each. // Generator operators are converted (via the following _generator // function) into functions that can also take a list or array of rules // and return an array of new rules as though the function had been // called on each rule in turn (which is what actually happens). // This allows generators to be used with vector operators more easily. // Example: // each(ignore(foo, bar)) instead of each(ignore(foo), ignore(bar)) // This also turns generators into vector operators, which allows // constructs like: // not(cache(foo, bar)) var _generator = function (op) { function gen() { var args = null, rx = [], px, i; if (arguments.length > 1) { args = Array.prototype.slice.call(arguments); } else if (arguments[0] instanceof Array) { args = arguments[0]; } if (args) { px = args.shift(); if (px.length > 0) { args.unshift(px[i]); rx.push(op.apply(null, args)); args.shift(); return rx; } } else { return op.apply(null, arguments); } } return gen; }; var gx = "optional not ignore cache".split(/\s/); for (var i = 0 ; i < gx.length ; i++) { _[gx[i]] = _generator(_[gx[i]]); } var _vector = function (op) { return function () { if (arguments[0] instanceof Array) { return op.apply(null, arguments[0]); } else { return op.apply(null, arguments); } }; }; var vx = "each any all".split(/\s/); for (var j = 0 ; j < vx.length ; j++) { _[vx[j]] = _vector(_[vx[j]]); } }()); (function () { var $D = Date; var flattenAndCompact = function (ax) { var rx = []; for (var i = 0; i < ax.length; i++) { if (ax[i] instanceof Array) { rx = rx.concat(flattenAndCompact(ax[i])); } else { if (ax[i]) { rx.push(ax[i]); } } } return rx; }; var parseMeridian = function () { if (this.meridian && (this.hour || this.hour === 0)) { if (this.meridian === "a" && this.hour > 11 && Date.Config.strict24hr){ throw "Invalid hour and meridian combination"; } else if (this.meridian === "p" && this.hour < 12 && Date.Config.strict24hr){ throw "Invalid hour and meridian combination"; } else if (this.meridian === "p" && this.hour < 12) { this.hour = this.hour + 12; } else if (this.meridian === "a" && this.hour === 12) { this.hour = 0; } } }; var setDefaults = function () { var now = new Date(); if ((this.hour || this.minute) && (!this.month && !this.year && !this.day)) { this.day = now.getDate(); } if (!this.year) { this.year = now.getFullYear(); } if (!this.month && this.month !== 0) { this.month = now.getMonth(); } if (!this.day) { this.day = 1; } if (!this.hour) { this.hour = 0; } if (!this.minute) { this.minute = 0; } if (!this.second) { this.second = 0; } if (!this.millisecond) { this.millisecond = 0; } }; var finishUtils = { getToday: function () { if (this.now || "hour minute second".indexOf(this.unit) !== -1) { return new Date(); } else { return $D.today(); } }, setDaysFromWeekday: function (today, orient){ var gap; orient = orient || 1; this.unit = "day"; gap = ($D.getDayNumberFromName(this.weekday) - today.getDay()); this.days = gap ? ((gap + (orient * 7)) % 7) : (orient * 7); return this; }, setMonthsFromMonth: function (today, orient) { var gap; orient = orient || 1; this.unit = "month"; gap = (this.month - today.getMonth()); this.months = gap ? ((gap + (orient * 12)) % 12) : (orient * 12); this.month = null; return this; }, setDMYFromWeekday: function () { var d = Date[this.weekday](); this.day = d.getDate(); if (!this.month) { this.month = d.getMonth(); } this.year = d.getFullYear(); return this; }, setUnitValue: function (orient) { if (!this.value && this.operator && this.operator !== null && this[this.unit + "s"] && this[this.unit + "s"] !== null) { this[this.unit + "s"] = this[this.unit + "s"] + ((this.operator === "add") ? 1 : -1) + (this.value||0) * orient; } else if (this[this.unit + "s"] == null || this.operator != null) { if (!this.value) { this.value = 1; } this[this.unit + "s"] = this.value * orient; } }, generateDateFromWeeks: function () { var weekday = (this.weekday !== undefined) ? this.weekday : "today"; var d = Date[weekday]().addWeeks(this.weeks); if (this.now) { d.setTimeToNow(); } return d; } }; $D.Translator = { hour: function (s) { return function () { this.hour = Number(s); }; }, minute: function (s) { return function () { this.minute = Number(s); }; }, second: function (s) { return function () { this.second = Number(s); }; }, /* for ss.s format */ secondAndMillisecond: function (s) { return function () { var mx = s.match(/^([0-5][0-9])\.([0-9]{1,3})/); this.second = Number(mx[1]); this.millisecond = Number(mx[2]); }; }, meridian: function (s) { return function () { this.meridian = s.slice(0, 1).toLowerCase(); }; }, timezone: function (s) { return function () { var n = s.replace(/[^\d\+\-]/g, ""); if (n.length) { this.timezoneOffset = Number(n); } else { this.timezone = s.toLowerCase(); } }; }, day: function (x) { var s = x[0]; return function () { this.day = Number(s.match(/\d+/)[0]); if (this.day < 1) { throw "invalid day"; } }; }, month: function (s) { return function () { this.month = (s.length === 3) ? "jan feb mar apr may jun jul aug sep oct nov dec".indexOf(s)/4 : Number(s) - 1; if (this.month < 0) { throw "invalid month"; } }; }, year: function (s) { return function () { var n = Number(s); this.year = ((s.length > 2) ? n : (n + (((n + 2000) < Date.CultureInfo.twoDigitYearMax) ? 2000 : 1900))); }; }, rday: function (s) { return function () { switch (s) { case "yesterday": this.days = -1; break; case "tomorrow": this.days = 1; break; case "today": this.days = 0; break; case "now": this.days = 0; this.now = true; break; } }; }, finishExact: function (x) { var d; x = (x instanceof Array) ? x : [x]; for (var i = 0 ; i < x.length ; i++) { if (x[i]) { x[i].call(this); } } setDefaults.call(this); parseMeridian.call(this); if (this.day > $D.getDaysInMonth(this.year, this.month)) { throw new RangeError(this.day + " is not a valid value for days."); } d = new Date(this.year, this.month, this.day, this.hour, this.minute, this.second, this.millisecond); if (this.year < 100) { d.setFullYear(this.year); // means years less that 100 are process correctly. JS will parse it otherwise as 1900-1999. } if (this.timezone) { d.set({ timezone: this.timezone }); } else if (this.timezoneOffset) { d.set({ timezoneOffset: this.timezoneOffset }); } return d; }, finish: function (x) { var today, expression, orient, temp; x = (x instanceof Array) ? flattenAndCompact(x) : [ x ]; if (x.length === 0) { return null; } for (var i = 0 ; i < x.length ; i++) { if (typeof x[i] === "function") { x[i].call(this); } } if (this.now && !this.unit && !this.operator) { return new Date(); } else { today = finishUtils.getToday.call(this); } expression = !!(this.days && this.days !== null || this.orient || this.operator); orient = ((this.orient === "past" || this.operator === "subtract") ? -1 : 1); if (this.month && this.unit === "week") { this.value = this.month + 1; delete this.month; delete this.day; } if ((this.month || this.month === 0) && "year day hour minute second".indexOf(this.unit) !== -1) { if (!this.value) { this.value = this.month + 1; } this.month = null; expression = true; } if (!expression && this.weekday && !this.day && !this.days) { finishUtils.setDMYFromWeekday.call(this); } if (expression && this.weekday && this.unit !== "month" && this.unit !== "week") { finishUtils.setDaysFromWeekday.call(this, today, orient); } if (this.weekday && this.unit !== "week" && !this.day && !this.days) { temp = Date[this.weekday](); this.day = temp.getDate(); if (temp.getMonth() !== today.getMonth()) { this.month = temp.getMonth(); } } if (this.month && this.unit === "day" && this.operator) { if (!this.value) { this.value = (this.month + 1); } this.month = null; } if (this.value != null && this.month != null && this.year != null) { this.day = this.value * 1; } if (this.month && !this.day && this.value) { today.set({ day: this.value * 1 }); if (!expression) { this.day = this.value * 1; } } if (!this.month && this.value && this.unit === "month" && !this.now) { this.month = this.value; expression = true; } if (expression && (this.month || this.month === 0) && this.unit !== "year") { finishUtils.setMonthsFromMonth.call(this, today, orient); } if (!this.unit) { this.unit = "day"; } finishUtils.setUnitValue.call(this, orient); parseMeridian.call(this); if ((this.month || this.month === 0) && !this.day) { this.day = 1; } if (!this.orient && !this.operator && this.unit === "week" && this.value && !this.day && !this.month) { return Date.today().setWeek(this.value); } if (this.unit === "week" && this.weeks && !this.day && !this.month) { return finishUtils.generateDateFromWeeks.call(this); } if (expression && this.timezone && this.day && this.days) { this.day = this.days; } if (expression){ today.add(this); } else { today.set(this); } if (this.timezone) { this.timezone = this.timezone.toUpperCase(); var offset = $D.getTimezoneOffset(this.timezone); var timezone; if (today.hasDaylightSavingTime()) { // lets check that we're being sane with timezone setting timezone = $D.getTimezoneAbbreviation(offset, today.isDaylightSavingTime()); if (timezone !== this.timezone) { // bugger, we're in a place where things like EST vs EDT matters. if (today.isDaylightSavingTime()) { today.addHours(-1); } else { today.addHours(1); } } } today.setTimezoneOffset(offset); } return today; } }; }()); (function () { var $D = Date; $D.Grammar = {}; var _ = $D.Parsing.Operators, g = $D.Grammar, t = $D.Translator, _fn; // Allow rolling up into general purpose rules _fn = function () { return _.each(_.any.apply(null, arguments), _.not(g.ctoken2("timeContext"))); }; g.datePartDelimiter = _.rtoken(/^([\s\-\.\,\/\x27]+)/); g.timePartDelimiter = _.stoken(":"); g.whiteSpace = _.rtoken(/^\s*/); g.generalDelimiter = _.rtoken(/^(([\s\,]|at|@|on)+)/); var _C = {}; g.ctoken = function (keys) { var fn = _C[keys]; if (! fn) { var c = Date.CultureInfo.regexPatterns; var kx = keys.split(/\s+/), px = []; for (var i = 0; i < kx.length ; i++) { px.push(_.replace(_.rtoken(c[kx[i]]), kx[i])); } fn = _C[keys] = _.any.apply(null, px); } return fn; }; g.ctoken2 = function (key) { return _.rtoken(Date.CultureInfo.regexPatterns[key]); }; var cacheProcessRtoken = function (key, token, type, eachToken) { if (eachToken) { g[key] = _.cache(_.process(_.each(_.rtoken(token),_.optional(g.ctoken2(eachToken))), type)); } else { g[key] = _.cache(_.process(_.rtoken(token), type)); } }; var cacheProcessCtoken = function (token, type) { return _.cache(_.process(g.ctoken2(token), type)); }; var _F = {}; //function cache var _get = function (f) { _F[f] = (_F[f] || g.format(f)[0]); return _F[f]; }; g.allformats = function (fx) { var rx = []; if (fx instanceof Array) { for (var i = 0; i < fx.length; i++) { rx.push(_get(fx[i])); } } else { rx.push(_get(fx)); } return rx; }; g.formats = function (fx) { if (fx instanceof Array) { var rx = []; for (var i = 0 ; i < fx.length ; i++) { rx.push(_get(fx[i])); } return _.any.apply(null, rx); } else { return _get(fx); } }; var grammarFormats = { timeFormats: function(){ var i, RTokenKeys = [ "h", "hh", "H", "HH", "m", "mm", "s", "ss", "ss.s", "z", "zz" ], RToken = [ /^(0[0-9]|1[0-2]|[1-9])/, /^(0[0-9]|1[0-2])/, /^([0-1][0-9]|2[0-3]|[0-9])/, /^([0-1][0-9]|2[0-3])/, /^([0-5][0-9]|[0-9])/, /^[0-5][0-9]/, /^([0-5][0-9]|[0-9])/, /^[0-5][0-9]/, /^[0-5][0-9]\.[0-9]{1,3}/, /^((\+|\-)\s*\d\d\d\d)|((\+|\-)\d\d\:?\d\d)/, /^((\+|\-)\s*\d\d\d\d)|((\+|\-)\d\d\:?\d\d)/ ], tokens = [ t.hour, t.hour, t.hour, t.hour, t.minute, t.minute, t.second, t.second, t.secondAndMillisecond, t.timezone, t.timezone ]; for (i=0; i < RTokenKeys.length; i++) { cacheProcessRtoken(RTokenKeys[i], RToken[i], tokens[i]); } g.hms = _.cache(_.sequence([g.H, g.m, g.s], g.timePartDelimiter)); g.t = cacheProcessCtoken("shortMeridian", t.meridian); g.tt = cacheProcessCtoken("longMeridian", t.meridian); g.zzz = cacheProcessCtoken("timezone", t.timezone); g.timeSuffix = _.each(_.ignore(g.whiteSpace), _.set([ g.tt, g.zzz ])); g.time = _.each(_.optional(_.ignore(_.stoken("T"))), g.hms, g.timeSuffix); }, dateFormats: function () { // pre-loaded rules for different date part order preferences var _setfn = function () { return _.set(arguments, g.datePartDelimiter); }; var i, RTokenKeys = [ "d", "dd", "M", "MM", "y", "yy", "yyy", "yyyy" ], RToken = [ /^([0-2]\d|3[0-1]|\d)/, /^([0-2]\d|3[0-1])/, /^(1[0-2]|0\d|\d)/, /^(1[0-2]|0\d)/, /^(\d+)/, /^(\d\d)/, /^(\d\d?\d?\d?)/, /^(\d\d\d\d)/ ], tokens = [ t.day, t.day, t.month, t.month, t.year, t.year, t.year, t.year ], eachToken = [ "ordinalSuffix", "ordinalSuffix" ]; for (i=0; i < RTokenKeys.length; i++) { cacheProcessRtoken(RTokenKeys[i], RToken[i], tokens[i], eachToken[i]); } g.MMM = g.MMMM = _.cache(_.process(g.ctoken("jan feb mar apr may jun jul aug sep oct nov dec"), t.month)); g.ddd = g.dddd = _.cache(_.process(g.ctoken("sun mon tue wed thu fri sat"), function (s) { return function () { this.weekday = s; }; } )); g.day = _fn(g.d, g.dd); g.month = _fn(g.M, g.MMM); g.year = _fn(g.yyyy, g.yy); g.mdy = _setfn(g.ddd, g.month, g.day, g.year); g.ymd = _setfn(g.ddd, g.year, g.month, g.day); g.dmy = _setfn(g.ddd, g.day, g.month, g.year); g.date = function (s) { return ((g[Date.CultureInfo.dateElementOrder] || g.mdy).call(this, s)); }; }, relative: function () { // relative date / time expressions g.orientation = _.process(g.ctoken("past future"), function (s) { return function () { this.orient = s; }; } ); g.operator = _.process(g.ctoken("add subtract"), function (s) { return function () { this.operator = s; }; } ); g.rday = _.process(g.ctoken("yesterday tomorrow today now"), t.rday); g.unit = _.process(g.ctoken("second minute hour day week month year"), function (s) { return function () { this.unit = s; }; } ); } }; g.buildGrammarFormats = function () { // these need to be rebuilt every time the language changes. _C = {}; grammarFormats.timeFormats(); grammarFormats.dateFormats(); grammarFormats.relative(); g.value = _.process(_.rtoken(/^([-+]?\d+)?(st|nd|rd|th)?/), function (s) { return function () { this.value = s.replace(/\D/g, ""); }; } ); g.expression = _.set([g.rday, g.operator, g.value, g.unit, g.orientation, g.ddd, g.MMM ]); g.format = _.process(_.many( _.any( // translate format specifiers into grammar rules _.process( _.rtoken(/^(dd?d?d?(?!e)|MM?M?M?|yy?y?y?|hh?|HH?|mm?|ss?|tt?|zz?z?)/), function (fmt) { if (g[fmt]) { return g[fmt]; } else { throw $D.Parsing.Exception(fmt); } } ), // translate separator tokens into token rules _.process(_.rtoken(/^[^dMyhHmstz]+/), // all legal separators function (s) { return _.ignore(_.stoken(s)); } ) ) ), // construct the parser ... function (rules) { return _.process(_.each.apply(null, rules), t.finishExact); } ); // starting rule for general purpose grammar g._start = _.process(_.set([ g.date, g.time, g.expression ], g.generalDelimiter, g.whiteSpace), t.finish); }; g.buildGrammarFormats(); // parsing date format specifiers - ex: "h:m:s tt" // this little guy will generate a custom parser based // on the format string, ex: g.format("h:m:s tt") // check for these formats first g._formats = g.formats([ "\"yyyy-MM-ddTHH:mm:ssZ\"", "yyyy-MM-ddTHH:mm:ss.sz", "yyyy-MM-ddTHH:mm:ssZ", "yyyy-MM-ddTHH:mm:ssz", "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-ddTHH:mmZ", "yyyy-MM-ddTHH:mmz", "yyyy-MM-ddTHH:mm", "ddd, MMM dd, yyyy H:mm:ss tt", "ddd MMM d yyyy HH:mm:ss zzz", "MMddyyyy", "ddMMyyyy", "Mddyyyy", "ddMyyyy", "Mdyyyy", "dMyyyy", "yyyy", "Mdyy", "dMyy", "d" ]); // real starting rule: tries selected formats first, // then general purpose rule g.start = function (s) { try { var r = g._formats.call({}, s); if (r[1].length === 0) { return r; } } catch (e) {} return g._start.call({}, s); }; }()); (function () { var $D = Date; /** * @desc Converts the specified string value into its JavaScript Date equivalent using CultureInfo specific format information. * * Example

	///////////
	// Dates //
	///////////

	// 15-Oct-2004
	var d1 = Date.parse("10/15/2004");

	// 15-Oct-2004
	var d1 = Date.parse("15-Oct-2004");

	// 15-Oct-2004
	var d1 = Date.parse("2004.10.15");

	//Fri Oct 15, 2004
	var d1 = Date.parse("Fri Oct 15, 2004");

	///////////
	// Times //
	///////////

	// Today at 10 PM.
	var d1 = Date.parse("10 PM");

	// Today at 10:30 PM.
	var d1 = Date.parse("10:30 P.M.");

	// Today at 6 AM.
	var d1 = Date.parse("06am");

	/////////////////////
	// Dates and Times //
	/////////////////////

	// 8-July-2004 @ 10:30 PM
	var d1 = Date.parse("July 8th, 2004, 10:30 PM");

	// 1-July-2004 @ 10:30 PM
	var d1 = Date.parse("2004-07-01T22:30:00");

	////////////////////
	// Relative Dates //
	////////////////////

	// Returns today's date. The string "today" is culture specific.
	var d1 = Date.parse("today");

	// Returns yesterday's date. The string "yesterday" is culture specific.
	var d1 = Date.parse("yesterday");

	// Returns the date of the next thursday.
	var d1 = Date.parse("Next thursday");

	// Returns the date of the most previous monday.
	var d1 = Date.parse("last monday");

	// Returns today's day + one year.
	var d1 = Date.parse("next year");

	///////////////
	// Date Math //
	///////////////

	// Today + 2 days
	var d1 = Date.parse("t+2");

	// Today + 2 days
	var d1 = Date.parse("today + 2 days");

	// Today + 3 months
	var d1 = Date.parse("t+3m");

	// Today - 1 year
	var d1 = Date.parse("today - 1 year");

	// Today - 1 year
	var d1 = Date.parse("t-1y"); 


	/////////////////////////////
	// Partial Dates and Times //
	/////////////////////////////

	// July 15th of this year.
	var d1 = Date.parse("July 15");

	// 15th day of current day and year.
	var d1 = Date.parse("15");

	// July 1st of current year at 10pm.
	var d1 = Date.parse("7/1 10pm");
	
* * @param {String} The string value to convert into a Date object [Required] * @return {Date} A Date object or null if the string cannot be converted into a Date. */ var parseUtils = { removeOrds: function (s) { ords = s.match(/\b(\d+)(?:st|nd|rd|th)\b/); // find ordinal matches s = ((ords && ords.length === 2) ? s.replace(ords[0], ords[1]) : s); return s; }, grammarParser: function (s) { var r = null; try { r = $D.Grammar.start.call({}, s.replace(/^\s*(\S*(\s+\S+)*)\s*$/, "$1")); } catch (e) { return null; } return ((r[1].length === 0) ? r[0] : null); }, nativeFallback: function(s) { var t; try { // ok we haven't parsed it, last ditch attempt with the built-in parser. t = Date._parse(s); return (t || t === 0) ? new Date(t) : null; } catch (e) { return null; } } }; function parse (s) { var d; if (!s) { return null; } if (s instanceof Date) { return s.clone(); } if (s.length >= 4 && s.charAt(0) !== "0" && s.charAt(0) !== "+"&& s.charAt(0) !== "-") { // ie: 2004 will pass, 0800 won't. // Start with specific formats d = $D.Parsing.ISO.parse(s) || $D.Parsing.Numeric.parse(s); } if (d instanceof Date && !isNaN(d.getTime())) { return d; } else { // find ordinal dates (1st, 3rd, 8th, etc and remove them as they cause parsing issues) s = $D.Parsing.Normalizer.parse(parseUtils.removeOrds(s)); d = parseUtils.grammarParser(s); if (d !== null) { return d; } else { return parseUtils.nativeFallback(s); } } } if (!$D._parse) { $D._parse = $D.parse; } $D.parse = parse; Date.getParseFunction = function (fx) { var fns = Date.Grammar.allformats(fx); return function (s) { var r = null; for (var i = 0; i < fns.length; i++) { try { r = fns[i].call({}, s); } catch (e) { continue; } if (r[1].length === 0) { return r[0]; } } return null; }; }; /** * Converts the specified string value into its JavaScript Date equivalent using the specified format {String} or formats {Array} and the CultureInfo specific format information. * The format of the string value must match one of the supplied formats exactly. * * Example

	// 15-Oct-2004
	var d1 = Date.parseExact("10/15/2004", "M/d/yyyy");

	// 15-Oct-2004
	var d1 = Date.parse("15-Oct-2004", "M-ddd-yyyy");

	// 15-Oct-2004
	var d1 = Date.parse("2004.10.15", "yyyy.MM.dd");

	// Multiple formats
	var d1 = Date.parseExact("10/15/2004", ["M/d/yyyy", "MMMM d, yyyy"]);
	
* * @param {String} The string value to convert into a Date object [Required]. * @param {Object} The expected format {String} or an array of expected formats {Array} of the date string [Required]. * @return {Date} A Date object or null if the string cannot be converted into a Date. */ $D.parseExact = function (s, fx) { return $D.getParseFunction(fx)(s); }; }()); (function () { var $D = Date, $P = $D.prototype, // $C = $D.CultureInfo, // not used atm p = function (s, l) { if (!l) { l = 2; } return ("000" + s).slice(l * -1); }; /** * Converts a PHP format string to Java/.NET format string. * A PHP format string can be used with ._format or .format. * A Java/.NET format string can be used with .toString(). * The .parseExact function will only accept a Java/.NET format string * * Example * var f1 = "%m/%d/%y" * var f2 = Date.normalizeFormat(f1); // "MM/dd/yy" * * new Date().format(f1); // "04/13/08" * new Date()._format(f1); // "04/13/08" * new Date().toString(f2); // "04/13/08" * * var date = Date.parseExact("04/13/08", f2); // Sun Apr 13 2008 * * @param {String} A PHP format string consisting of one or more format spcifiers. * @return {String} The PHP format converted to a Java/.NET format string. */ var normalizerSubstitutions = { "d" : "dd", "%d": "dd", "D" : "ddd", "%a": "ddd", "j" : "dddd", "l" : "dddd", "%A": "dddd", "S" : "S", "F" : "MMMM", "%B": "MMMM", "m" : "MM", "%m": "MM", "M" : "MMM", "%b": "MMM", "%h": "MMM", "n" : "M", "Y" : "yyyy", "%Y": "yyyy", "y" : "yy", "%y": "yy", "g" : "h", "%I": "h", "G" : "H", "h" : "hh", "H" : "HH", "%H": "HH", "i" : "mm", "%M": "mm", "s" : "ss", "%S": "ss", "%r": "hh:mm tt", "%R": "H:mm", "%T": "H:mm:ss", "%X": "t", "%x": "d", "%e": "d", "%D": "MM/dd/yy", "%n": "\\n", "%t": "\\t", "e" : "z", "T" : "z", "%z": "z", "%Z": "z", "Z" : "ZZ", "N" : "u", "w" : "u", "%w": "u", "W" : "W", "%V": "W" }; var normalizer = { substitutes: function (m) { return normalizerSubstitutions[m]; }, interpreted: function (m, x) { var y; switch (m) { case "%u": return x.getDay() + 1; case "z": return x.getOrdinalNumber(); case "%j": return p(x.getOrdinalNumber(), 3); case "%U": var d1 = x.clone().set({month: 0, day: 1}).addDays(-1).moveToDayOfWeek(0), d2 = x.clone().addDays(1).moveToDayOfWeek(0, -1); return (d2 < d1) ? "00" : p((d2.getOrdinalNumber() - d1.getOrdinalNumber()) / 7 + 1); case "%W": return p(x.getWeek()); case "t": return $D.getDaysInMonth(x.getFullYear(), x.getMonth()); case "o": case "%G": return x.setWeek(x.getISOWeek()).toString("yyyy"); case "%g": return x._format("%G").slice(-2); case "a": case "%p": return t("tt").toLowerCase(); case "A": return t("tt").toUpperCase(); case "u": return p(x.getMilliseconds(), 3); case "I": return (x.isDaylightSavingTime()) ? 1 : 0; case "O": return x.getUTCOffset(); case "P": y = x.getUTCOffset(); return y.substring(0, y.length - 2) + ":" + y.substring(y.length - 2); case "B": var now = new Date(); return Math.floor(((now.getHours() * 3600) + (now.getMinutes() * 60) + now.getSeconds() + (now.getTimezoneOffset() + 60) * 60) / 86.4); case "c": return x.toISOString().replace(/\"/g, ""); case "U": return $D.strtotime("now"); case "%c": return t("d") + " " + t("t"); case "%C": return Math.floor(x.getFullYear() / 100 + 1); } }, shouldOverrideDefaults: function (m) { switch (m) { case "%e": return true; default: return false; } }, parse: function (m, context) { var formatString, c = context || new Date(); formatString = normalizer.substitutes(m); if (formatString) { return formatString; } formatString = normalizer.interpreted(m, c); if (formatString) { return formatString; } else { return m; } } }; $D.normalizeFormat = function (format, context) { return format.replace(/(%|\\)?.|%%/g, function(t){ return normalizer.parse(t, context); }); }; /** * Format a local Unix timestamp according to locale settings * * Example: * Date.strftime("%m/%d/%y", new Date()); // "04/13/08" * Date.strftime("c", "2008-04-13T17:52:03Z"); // "04/13/08" * * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @param {Number|String} The number representing the number of seconds that have elapsed since January 1, 1970 (local time). * @return {String} A string representation of the current Date object. */ $D.strftime = function (format, time) { var d = Date.parse(time); return d._format(format); }; /** * Parse any textual datetime description into a Unix timestamp. * A Unix timestamp is the number of seconds that have elapsed since January 1, 1970 (midnight UTC/GMT). * * Example: * Date.strtotime("04/13/08"); // 1208044800 * Date.strtotime("1970-01-01T00:00:00Z"); // 0 * * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @param {Object} A string or date object. * @return {String} A string representation of the current Date object. */ $D.strtotime = function (time) { var d = $D.parse(time); return Math.round($D.UTC(d.getUTCFullYear(), d.getUTCMonth(), d.getUTCDate(), d.getUTCHours(), d.getUTCMinutes(), d.getUTCSeconds(), d.getUTCMilliseconds()) / 1000); }; /** * Converts the value of the current Date object to its equivalent string representation using a PHP/Unix style of date format specifiers. * Format Specifiers * Format Description Example * ------ --------------------------------------------------------------------------- ----------------------- * %a abbreviated weekday name according to the current localed "Mon" through "Sun" * %A full weekday name according to the current localed "Sunday" through "Saturday" * %b abbreviated month name according to the current localed "Jan" through "Dec" * %B full month name according to the current locale "January" through "December" * %c preferred date and time representation for the current locale "4/13/2008 12:33 PM" * %C century number (the year divided by 100 and truncated to an integer) "00" to "99" * %d day of the month as a decimal number "01" to "31" * %D same as %m/%d/%y "04/13/08" * %e day of the month as a decimal number, a single digit is preceded by a space "1" to "31" * %g like %G, but without the century "08" * %G The 4-digit year corresponding to the ISO week number (see %V). "2008" * This has the same format and value as %Y, except that if the ISO week number * belongs to the previous or next year, that year is used instead. * %h same as %b "Jan" through "Dec" * %H hour as a decimal number using a 24-hour clock. "00" to "23" * %I hour as a decimal number using a 12-hour clock. "01" to "12" * %j day of the year as a decimal number. "001" to "366" * %m month as a decimal number. "01" to "12" * %M minute as a decimal number. "00" to "59" * %n newline character "\n" * %p either "am" or "pm" according to the given time value, or the "am" or "pm" * corresponding strings for the current locale. * %r time in a.m. and p.m. notation "8:44 PM" * %R time in 24 hour notation "20:44" * %S second as a decimal number "00" to "59" * %t tab character "\t" * %T current time, equal to %H:%M:%S "12:49:11" * %u weekday as a decimal number ["1", "7"], with "1" representing Monday "1" to "7" * %U week number of the current year as a decimal number, starting with the "0" to ("52" or "53") * first Sunday as the first day of the first week * %V The ISO 8601:1988 week number of the current year as a decimal number, "00" to ("52" or "53") * range 01 to 53, where week 1 is the first week that has at least 4 days * in the current year, and with Monday as the first day of the week. * (Use %G or %g for the year component that corresponds to the week number * for the specified timestamp.) * %W week number of the current year as a decimal number, starting with the "00" to ("52" or "53") * first Monday as the first day of the first week * %w day of the week as a decimal, Sunday being "0" "0" to "6" * %x preferred date representation for the current locale without the time "4/13/2008" * %X preferred time representation for the current locale without the date "12:53:05" * %y year as a decimal number without a century "00" "99" * %Y year as a decimal number including the century "2008" * %Z time zone or name or abbreviation "UTC", "EST", "PST" * %z same as %Z * %% a literal "%" characters "%" * d Day of the month, 2 digits with leading zeros "01" to "31" * D A textual representation of a day, three letters "Mon" through "Sun" * j Day of the month without leading zeros "1" to "31" * l A full textual representation of the day of the week (lowercase "L") "Sunday" through "Saturday" * N ISO-8601 numeric representation of the day of the week (added in PHP 5.1.0) "1" (for Monday) through "7" (for Sunday) * S English ordinal suffix for the day of the month, 2 characters "st", "nd", "rd" or "th". Works well with j * w Numeric representation of the day of the week "0" (for Sunday) through "6" (for Saturday) * z The day of the year (starting from "0") "0" through "365" * W ISO-8601 week number of year, weeks starting on Monday "00" to ("52" or "53") * F A full textual representation of a month, such as January or March "January" through "December" * m Numeric representation of a month, with leading zeros "01" through "12" * M A short textual representation of a month, three letters "Jan" through "Dec" * n Numeric representation of a month, without leading zeros "1" through "12" * t Number of days in the given month "28" through "31" * L Whether it's a leap year "1" if it is a leap year, "0" otherwise * o ISO-8601 year number. This has the same value as Y, except that if the "2008" * ISO week number (W) belongs to the previous or next year, that year * is used instead. * Y A full numeric representation of a year, 4 digits "2008" * y A two digit representation of a year "08" * a Lowercase Ante meridiem and Post meridiem "am" or "pm" * A Uppercase Ante meridiem and Post meridiem "AM" or "PM" * B Swatch Internet time "000" through "999" * g 12-hour format of an hour without leading zeros "1" through "12" * G 24-hour format of an hour without leading zeros "0" through "23" * h 12-hour format of an hour with leading zeros "01" through "12" * H 24-hour format of an hour with leading zeros "00" through "23" * i Minutes with leading zeros "00" to "59" * s Seconds, with leading zeros "00" through "59" * u Milliseconds "54321" * e Timezone identifier "UTC", "EST", "PST" * I Whether or not the date is in daylight saving time (uppercase i) "1" if Daylight Saving Time, "0" otherwise * O Difference to Greenwich time (GMT) in hours "+0200", "-0600" * P Difference to Greenwich time (GMT) with colon between hours and minutes "+02:00", "-06:00" * T Timezone abbreviation "UTC", "EST", "PST" * Z Timezone offset in seconds. The offset for timezones west of UTC is "-43200" through "50400" * always negative, and for those east of UTC is always positive. * c ISO 8601 date "2004-02-12T15:19:21+00:00" * r RFC 2822 formatted date "Thu, 21 Dec 2000 16:01:07 +0200" * U Seconds since the Unix Epoch (January 1 1970 00:00:00 GMT) "0" * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @return {String} A string representation of the current Date object. */ var formatReplace = function (context) { return function (m) { var formatString, override = false; if (m.charAt(0) === "\\" || m.substring(0, 2) === "%%") { return m.replace("\\", "").replace("%%", "%"); } override = normalizer.shouldOverrideDefaults(m); formatString = $D.normalizeFormat(m, context); if (formatString) { return context.toString(formatString, override); } }; }; $P._format = function (format) { var formatter = formatReplace(this); if (!format) { return this._toString(); } else { return format.replace(/(%|\\)?.|%%/g, formatter); } }; if (!$P.format) { $P.format = $P._format; } }()); (function () { "use strict"; var gFn = function (attr) { return function () { return this[attr]; }; }; var sFn = function (attr) { return function (val) { this[attr] = val; return this; }; }; var attrs = ["years", "months", "days", "hours", "minutes", "seconds", "milliseconds"]; var addSetFuncs = function (context, attrs) { for (var i = 0; i < attrs.length ; i++) { var $a = attrs[i], $b = $a.slice(0, 1).toUpperCase() + $a.slice(1); context.prototype[$a] = 0; context.prototype["get" + $b] = gFn($a); context.prototype["set" + $b] = sFn($a); } }; /** * new TimeSpan(milliseconds); * new TimeSpan(days, hours, minutes, seconds); * new TimeSpan(days, hours, minutes, seconds, milliseconds); */ var TimeSpan = function (days, hours, minutes, seconds, milliseconds) { if (arguments.length === 1 && typeof days === "number") { var orient = (days < 0) ? -1 : +1; var millsLeft = Math.abs(days); this.setDays(Math.floor(millsLeft / 86400000) * orient); millsLeft = millsLeft % 86400000; this.setHours(Math.floor(millsLeft / 3600000) * orient); millsLeft = millsLeft % 3600000; this.setMinutes(Math.floor(millsLeft / 60000) * orient); millsLeft = millsLeft % 60000; this.setSeconds(Math.floor(millsLeft / 1000) * orient); millsLeft = millsLeft % 1000; this.setMilliseconds(millsLeft * orient); } else { this.set(days, hours, minutes, seconds, milliseconds); } this.getTotalMilliseconds = function () { return (this.getDays() * 86400000) + (this.getHours() * 3600000) + (this.getMinutes() * 60000) + (this.getSeconds() * 1000); }; this.compareTo = function (time) { var t1 = new Date(1970, 1, 1, this.getHours(), this.getMinutes(), this.getSeconds()), t2; if (time === null) { t2 = new Date(1970, 1, 1, 0, 0, 0); } else { t2 = new Date(1970, 1, 1, time.getHours(), time.getMinutes(), time.getSeconds()); } return (t1 < t2) ? -1 : (t1 > t2) ? 1 : 0; }; this.equals = function (time) { return (this.compareTo(time) === 0); }; this.add = function (time) { return (time === null) ? this : this.addSeconds(time.getTotalMilliseconds() / 1000); }; this.subtract = function (time) { return (time === null) ? this : this.addSeconds(-time.getTotalMilliseconds() / 1000); }; this.addDays = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 86400000)); }; this.addHours = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 3600000)); }; this.addMinutes = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 60000)); }; this.addSeconds = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 1000)); }; this.addMilliseconds = function (n) { return new TimeSpan(this.getTotalMilliseconds() + n); }; this.get12HourHour = function () { return (this.getHours() > 12) ? this.getHours() - 12 : (this.getHours() === 0) ? 12 : this.getHours(); }; this.getDesignator = function () { return (this.getHours() < 12) ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator; }; this.toString = function (format) { this._toString = function () { if (this.getDays() !== null && this.getDays() > 0) { return this.getDays() + "." + this.getHours() + ":" + this.p(this.getMinutes()) + ":" + this.p(this.getSeconds()); } else { return this.getHours() + ":" + this.p(this.getMinutes()) + ":" + this.p(this.getSeconds()); } }; this.p = function (s) { return (s.toString().length < 2) ? "0" + s : s; }; var me = this; return format ? format.replace(/dd?|HH?|hh?|mm?|ss?|tt?/g, function (format) { switch (format) { case "d": return me.getDays(); case "dd": return me.p(me.getDays()); case "H": return me.getHours(); case "HH": return me.p(me.getHours()); case "h": return me.get12HourHour(); case "hh": return me.p(me.get12HourHour()); case "m": return me.getMinutes(); case "mm": return me.p(me.getMinutes()); case "s": return me.getSeconds(); case "ss": return me.p(me.getSeconds()); case "t": return ((me.getHours() < 12) ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator).substring(0, 1); case "tt": return (me.getHours() < 12) ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator; } } ) : this._toString(); }; return this; }; addSetFuncs(TimeSpan, attrs.slice(2)); TimeSpan.prototype.set = function (days, hours, minutes, seconds, milliseconds){ this.setDays(days || this.getDays()); this.setHours(hours || this.getHours()); this.setMinutes(minutes || this.getMinutes()); this.setSeconds(seconds || this.getSeconds()); this.setMilliseconds(milliseconds || this.getMilliseconds()); }; /** * Gets the time of day for this date instances. * @return {TimeSpan} TimeSpan */ Date.prototype.getTimeOfDay = function () { return new TimeSpan(0, this.getHours(), this.getMinutes(), this.getSeconds(), this.getMilliseconds()); }; Date.TimeSpan = TimeSpan; if (typeof window !== "undefined" ) { // keeping API compatible for v1.x window.TimeSpan = TimeSpan; } }()); (function () { "use strict"; var attrs = ["years", "months", "days", "hours", "minutes", "seconds", "milliseconds"]; var gFn = function (attr) { return function () { return this[attr]; }; }; var sFn = function (attr) { return function (val) { this[attr] = val; return this; }; }; var addSetFuncs = function (context, attrs) { for (var i = 0; i < attrs.length ; i++) { var $a = attrs[i], $b = $a.slice(0, 1).toUpperCase() + $a.slice(1); context.prototype[$a] = 0; context.prototype["get" + $b] = gFn($a); context.prototype["set" + $b] = sFn($a); } }; var setMonthsAndYears = function (orient, d1, d2, context) { function inc() { d1.addMonths(-orient); context.months++; if (context.months === 12) { context.years++; context.months = 0; } } if (orient === +1) { while (d1 > d2) { inc(); } } else { while (d1 < d2) { inc(); } } context.months--; context.months *= orient; context.years *= orient; }; var adjustForDST = function(orient, startDate, endDate) { var hasDSTMismatch = (false === (startDate.isDaylightSavingTime() === endDate.isDaylightSavingTime())); if (hasDSTMismatch && orient === 1) { startDate.addHours(-1); } else if (hasDSTMismatch) { startDate.addHours(1); } }; /** * TimePeriod(startDate, endDate); * TimePeriod(years, months, days, hours, minutes, seconds, milliseconds); */ var TimePeriod = function (years, months, days, hours, minutes, seconds, milliseconds) { if (arguments.length === 7) { this.set(years, months, days, hours, minutes, seconds, milliseconds); } else if (arguments.length === 2 && arguments[0] instanceof Date && arguments[1] instanceof Date) { var startDate = arguments[0].clone(); var endDate = arguments[1].clone(); var orient = (startDate > endDate) ? +1 : -1; this.dates = { start: arguments[0].clone(), end: arguments[1].clone() }; setMonthsAndYears(orient, startDate, endDate, this); adjustForDST(orient, startDate, endDate); // // TODO - adjust for DST var diff = endDate - startDate; if (diff !== 0) { var ts = new TimeSpan(diff); this.set(this.years, this.months, ts.getDays(), ts.getHours(), ts.getMinutes(), ts.getSeconds(), ts.getMilliseconds()); } } return this; }; // create all the set functions. addSetFuncs(TimePeriod, attrs); TimePeriod.prototype.set = function (years, months, days, hours, minutes, seconds, milliseconds){ this.setYears(years || this.getYears()); this.setMonths(months || this.getMonths()); this.setDays(days || this.getDays()); this.setHours(hours || this.getHours()); this.setMinutes(minutes || this.getMinutes()); this.setSeconds(seconds || this.getSeconds()); this.setMilliseconds(milliseconds || this.getMilliseconds()); }; Date.TimePeriod = TimePeriod; if (typeof window !== "undefined") { // keeping API compatible for v1.x window.TimePeriod = TimePeriod; } }()); ================================================ FILE: build/date-zh-HK.js ================================================ /** * @overview datejs * @version 1.0.0-rc3 * @author Gregory Wild-Smith * @copyright 2015 Gregory Wild-Smith * @license MIT * @homepage https://github.com/abritinthebay/datejs */ /* * DateJS Culture String File * Country Code: zh-HK * Name: Chinese (Hong Kong S.A.R.) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["zh-HK"] = { "name": "zh-HK", "englishName": "Chinese (Hong Kong S.A.R.)", "nativeName": "中文(香港特别行政區)", "Sunday": "Sunday", "Monday": "Monday", "Tuesday": "Tuesday", "Wednesday": "Wednesday", "Thursday": "Thursday", "Friday": "Friday", "Saturday": "Saturday", "Sun": "Sun", "Mon": "Mon", "Tue": "Tue", "Wed": "Wed", "Thu": "Thu", "Fri": "Fri", "Sat": "Sat", "Su": "Su", "Mo": "Mo", "Tu": "Tu", "We": "We", "Th": "Th", "Fr": "Fr", "Sa": "Sa", "S_Sun_Initial": "S", "M_Mon_Initial": "M", "T_Tue_Initial": "T", "W_Wed_Initial": "W", "T_Thu_Initial": "T", "F_Fri_Initial": "F", "S_Sat_Initial": "S", "January": "January", "February": "February", "March": "March", "April": "April", "May": "May", "June": "June", "July": "July", "August": "August", "September": "September", "October": "October", "November": "November", "December": "December", "Jan_Abbr": "Jan", "Feb_Abbr": "Feb", "Mar_Abbr": "Mar", "Apr_Abbr": "Apr", "May_Abbr": "May", "Jun_Abbr": "Jun", "Jul_Abbr": "Jul", "Aug_Abbr": "Aug", "Sep_Abbr": "Sep", "Oct_Abbr": "Oct", "Nov_Abbr": "Nov", "Dec_Abbr": "Dec", "AM": "", "PM": "", "firstDayOfWeek": 0, "twoDigitYearMax": 2029, "mdy": "dmy", "M/d/yyyy": "d/M/yyyy", "dddd, MMMM dd, yyyy": "dddd, d MMMM, yyyy", "h:mm tt": "H:mm", "h:mm:ss tt": "H:mm:ss", "dddd, MMMM dd, yyyy h:mm:ss tt": "dddd, d MMMM, yyyy H:mm:ss", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "d MMMM", "MMMM, yyyy": "MMMM, yyyy", "/jan(uary)?/": "jan(uary)?", "/feb(ruary)?/": "feb(ruary)?", "/mar(ch)?/": "mar(ch)?", "/apr(il)?/": "apr(il)?", "/may/": "may", "/jun(e)?/": "jun(e)?", "/jul(y)?/": "jul(y)?", "/aug(ust)?/": "aug(ust)?", "/sep(t(ember)?)?/": "sep(t(ember)?)?", "/oct(ober)?/": "oct(ober)?", "/nov(ember)?/": "nov(ember)?", "/dec(ember)?/": "dec(ember)?", "/^su(n(day)?)?/": "^su(n(day)?)?", "/^mo(n(day)?)?/": "^mo(n(day)?)?", "/^tu(e(s(day)?)?)?/": "^tu(e(s(day)?)?)?", "/^we(d(nesday)?)?/": "^we(d(nesday)?)?", "/^th(u(r(s(day)?)?)?)?/": "^th(u(r(s(day)?)?)?)?", "/^fr(i(day)?)?/": "^fr(i(day)?)?", "/^sa(t(urday)?)?/": "^sa(t(urday)?)?", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "zh-HK"; /** * @overview datejs * @version 1.0.0-rc3 * @author Gregory Wild-Smith * @copyright 2015 Gregory Wild-Smith * @license MIT * @homepage https://github.com/abritinthebay/datejs */(function () { var $D = Date; var lang = Date.CultureStrings ? Date.CultureStrings.lang : null; var loggedKeys = {}; // for debug purposes. var getText = { getFromKey: function (key, countryCode) { var output; if (Date.CultureStrings && Date.CultureStrings[countryCode] && Date.CultureStrings[countryCode][key]) { output = Date.CultureStrings[countryCode][key]; } else { output = getText.buildFromDefault(key); } if (key.charAt(0) === "/") { // Assume it's a regex output = getText.buildFromRegex(key, countryCode); } return output; }, getFromObjectValues: function (obj, countryCode) { var key, output = {}; for(key in obj) { if (obj.hasOwnProperty(key)) { output[key] = getText.getFromKey(obj[key], countryCode); } } return output; }, getFromObjectKeys: function (obj, countryCode) { var key, output = {}; for(key in obj) { if (obj.hasOwnProperty(key)) { output[getText.getFromKey(key, countryCode)] = obj[key]; } } return output; }, getFromArray: function (arr, countryCode) { var output = []; for (var i=0; i < arr.length; i++){ if (i in arr) { output[i] = getText.getFromKey(arr[i], countryCode); } } return output; }, buildFromDefault: function (key) { var output, length, split, last; switch(key) { case "name": output = "en-US"; break; case "englishName": output = "English (United States)"; break; case "nativeName": output = "English (United States)"; break; case "twoDigitYearMax": output = 2049; break; case "firstDayOfWeek": output = 0; break; default: output = key; split = key.split("_"); length = split.length; if (length > 1 && key.charAt(0) !== "/") { // if the key isn't a regex and it has a split. last = split[(length - 1)].toLowerCase(); if (last === "initial" || last === "abbr") { output = split[0]; } } break; } return output; }, buildFromRegex: function (key, countryCode) { var output; if (Date.CultureStrings && Date.CultureStrings[countryCode] && Date.CultureStrings[countryCode][key]) { output = new RegExp(Date.CultureStrings[countryCode][key], "i"); } else { output = new RegExp(key.replace(new RegExp("/", "g"),""), "i"); } return output; } }; var shallowMerge = function (obj1, obj2) { for (var attrname in obj2) { if (obj2.hasOwnProperty(attrname)) { obj1[attrname] = obj2[attrname]; } } }; var __ = function (key, language) { var countryCode = (language) ? language : lang; loggedKeys[key] = key; if (typeof key === "object") { if (key instanceof Array) { return getText.getFromArray(key, countryCode); } else { return getText.getFromObjectKeys(key, countryCode); } } else { return getText.getFromKey(key, countryCode); } }; var loadI18nScript = function (code) { // paatterned after jQuery's getScript. var url = Date.Config.i18n + code + ".js"; var head = document.getElementsByTagName("head")[0] || document.documentElement; var script = document.createElement("script"); script.src = url; var completed = false; var events = { done: function (){} // placeholder function }; // Attach handlers for all browsers script.onload = script.onreadystatechange = function() { if ( !completed && (!this.readyState || this.readyState === "loaded" || this.readyState === "complete") ) { events.done(); head.removeChild(script); } }; setTimeout(function() { head.insertBefore(script, head.firstChild); }, 0); // allows return to execute first return { done: function (cb) { events.done = function() { if (cb) { setTimeout(cb,0); } }; } }; }; var buildInfo = { buildFromMethodHash: function (obj) { var key; for(key in obj) { if (obj.hasOwnProperty(key)) { obj[key] = buildInfo[obj[key]](); } } return obj; }, timeZoneDST: function () { var DST = { "CHADT": "+1345", "NZDT": "+1300", "AEDT": "+1100", "ACDT": "+1030", "AZST": "+0500", "IRDT": "+0430", "EEST": "+0300", "CEST": "+0200", "BST": "+0100", "PMDT": "-0200", "ADT": "-0300", "NDT": "-0230", "EDT": "-0400", "CDT": "-0500", "MDT": "-0600", "PDT": "-0700", "AKDT": "-0800", "HADT": "-0900" }; return __(DST); }, timeZoneStandard: function () { var standard = { "LINT": "+1400", "TOT": "+1300", "CHAST": "+1245", "NZST": "+1200", "NFT": "+1130", "SBT": "+1100", "AEST": "+1000", "ACST": "+0930", "JST": "+0900", "CWST": "+0845", "CT": "+0800", "ICT": "+0700", "MMT": "+0630", "BST": "+0600", "NPT": "+0545", "IST": "+0530", "PKT": "+0500", "AFT": "+0430", "MSK": "+0400", "IRST": "+0330", "FET": "+0300", "EET": "+0200", "CET": "+0100", "GMT": "+0000", "UTC": "+0000", "CVT": "-0100", "GST": "-0200", "BRT": "-0300", "NST": "-0330", "AST": "-0400", "EST": "-0500", "CST": "-0600", "MST": "-0700", "PST": "-0800", "AKST": "-0900", "MIT": "-0930", "HST": "-1000", "SST": "-1100", "BIT": "-1200" }; return __(standard); }, timeZones: function (data) { var zone; data.timezones = []; for (zone in data.abbreviatedTimeZoneStandard) { if (data.abbreviatedTimeZoneStandard.hasOwnProperty(zone)) { data.timezones.push({ name: zone, offset: data.abbreviatedTimeZoneStandard[zone]}); } } for (zone in data.abbreviatedTimeZoneDST) { if (data.abbreviatedTimeZoneDST.hasOwnProperty(zone)) { data.timezones.push({ name: zone, offset: data.abbreviatedTimeZoneDST[zone], dst: true}); } } return data.timezones; }, days: function () { return __(["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"]); }, dayAbbr: function () { return __(["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"]); }, dayShortNames: function () { return __(["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"]); }, dayFirstLetters: function () { return __(["S_Sun_Initial", "M_Mon_Initial", "T_Tues_Initial", "W_Wed_Initial", "T_Thu_Initial", "F_Fri_Initial", "S_Sat_Initial"]); }, months: function () { return __(["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"]); }, monthAbbr: function () { return __(["Jan_Abbr", "Feb_Abbr", "Mar_Abbr", "Apr_Abbr", "May_Abbr", "Jun_Abbr", "Jul_Abbr", "Aug_Abbr", "Sep_Abbr", "Oct_Abbr", "Nov_Abbr", "Dec_Abbr"]); }, formatPatterns: function () { return getText.getFromObjectValues({ shortDate: "M/d/yyyy", longDate: "dddd, MMMM dd, yyyy", shortTime: "h:mm tt", longTime: "h:mm:ss tt", fullDateTime: "dddd, MMMM dd, yyyy h:mm:ss tt", sortableDateTime: "yyyy-MM-ddTHH:mm:ss", universalSortableDateTime: "yyyy-MM-dd HH:mm:ssZ", rfc1123: "ddd, dd MMM yyyy HH:mm:ss", monthDay: "MMMM dd", yearMonth: "MMMM, yyyy" }, Date.i18n.currentLanguage()); }, regex: function () { return getText.getFromObjectValues({ inTheMorning: "/( in the )(morn(ing)?)\\b/", thisMorning: "/(this )(morn(ing)?)\\b/", amThisMorning: "/(\b\\d(am)? )(this )(morn(ing)?)/", inTheEvening: "/( in the )(even(ing)?)\\b/", thisEvening: "/(this )(even(ing)?)\\b/", pmThisEvening: "/(\b\\d(pm)? )(this )(even(ing)?)/", jan: "/jan(uary)?/", feb: "/feb(ruary)?/", mar: "/mar(ch)?/", apr: "/apr(il)?/", may: "/may/", jun: "/jun(e)?/", jul: "/jul(y)?/", aug: "/aug(ust)?/", sep: "/sep(t(ember)?)?/", oct: "/oct(ober)?/", nov: "/nov(ember)?/", dec: "/dec(ember)?/", sun: "/^su(n(day)?)?/", mon: "/^mo(n(day)?)?/", tue: "/^tu(e(s(day)?)?)?/", wed: "/^we(d(nesday)?)?/", thu: "/^th(u(r(s(day)?)?)?)?/", fri: "/fr(i(day)?)?/", sat: "/^sa(t(urday)?)?/", future: "/^next/", past: "/^last|past|prev(ious)?/", add: "/^(\\+|aft(er)?|from|hence)/", subtract: "/^(\\-|bef(ore)?|ago)/", yesterday: "/^yes(terday)?/", today: "/^t(od(ay)?)?/", tomorrow: "/^tom(orrow)?/", now: "/^n(ow)?/", millisecond: "/^ms|milli(second)?s?/", second: "/^sec(ond)?s?/", minute: "/^mn|min(ute)?s?/", hour: "/^h(our)?s?/", week: "/^w(eek)?s?/", month: "/^m(onth)?s?/", day: "/^d(ay)?s?/", year: "/^y(ear)?s?/", shortMeridian: "/^(a|p)/", longMeridian: "/^(a\\.?m?\\.?|p\\.?m?\\.?)/", timezone: "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/", ordinalSuffix: "/^\\s*(st|nd|rd|th)/", timeContext: "/^\\s*(\\:|a(?!u|p)|p)/" }, Date.i18n.currentLanguage()); } }; var CultureInfo = function () { var info = getText.getFromObjectValues({ name: "name", englishName: "englishName", nativeName: "nativeName", amDesignator: "AM", pmDesignator: "PM", firstDayOfWeek: "firstDayOfWeek", twoDigitYearMax: "twoDigitYearMax", dateElementOrder: "mdy" }, Date.i18n.currentLanguage()); var constructedInfo = buildInfo.buildFromMethodHash({ dayNames: "days", abbreviatedDayNames: "dayAbbr", shortestDayNames: "dayShortNames", firstLetterDayNames: "dayFirstLetters", monthNames: "months", abbreviatedMonthNames: "monthAbbr", formatPatterns: "formatPatterns", regexPatterns: "regex", abbreviatedTimeZoneDST: "timeZoneDST", abbreviatedTimeZoneStandard: "timeZoneStandard" }); shallowMerge(info, constructedInfo); buildInfo.timeZones(info); return info; }; $D.i18n = { __: function (key, lang) { return __(key, lang); }, currentLanguage: function () { return lang || "en-US"; }, setLanguage: function (code, force, cb) { var async = false; if (force || code === "en-US" || (!!Date.CultureStrings && !!Date.CultureStrings[code])) { lang = code; Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings.lang = code; Date.CultureInfo = new CultureInfo(); } else { if (!(!!Date.CultureStrings && !!Date.CultureStrings[code])) { if (typeof exports !== "undefined" && this.exports !== exports) { // we're in a Node enviroment, load it using require try { require("../i18n/" + code + ".js"); lang = code; Date.CultureStrings.lang = code; Date.CultureInfo = new CultureInfo(); } catch (e) { // var str = "The language for '" + code + "' could not be loaded by Node. It likely does not exist."; throw new Error("The DateJS IETF language tag '" + code + "' could not be loaded by Node. It likely does not exist."); } } else if (Date.Config && Date.Config.i18n) { // we know the location of the files, so lets load them async = true; loadI18nScript(code).done(function(){ lang = code; Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings.lang = code; Date.CultureInfo = new CultureInfo(); $D.Parsing.Normalizer.buildReplaceData(); // because this is async if ($D.Grammar) { $D.Grammar.buildGrammarFormats(); // so we can parse those strings... } if (cb) { setTimeout(cb,0); } }); } else { Date.console.error("The DateJS IETF language tag '" + code + "' is not available and has not been loaded."); return false; } } } $D.Parsing.Normalizer.buildReplaceData(); // rebuild normalizer strings if ($D.Grammar) { $D.Grammar.buildGrammarFormats(); // so we can parse those strings... } if (!async && cb) { setTimeout(cb,0); } }, getLoggedKeys: function () { return loggedKeys; }, updateCultureInfo: function () { Date.CultureInfo = new CultureInfo(); } }; $D.i18n.updateCultureInfo(); // run automatically }()); (function () { var $D = Date, $P = $D.prototype, p = function (s, l) { if (!l) { l = 2; } return ("000" + s).slice(l * -1); }; if (typeof window !== "undefined" && typeof window.console !== "undefined" && typeof window.console.log !== "undefined") { $D.console = console; // used only to raise non-critical errors if available } else { // set mock so we don't give errors. $D.console = { log: function(){}, error: function(){} }; } $D.Config = $D.Config || {}; $D.initOverloads = function() { /** * Overload of Date.now. Allows an alternate call for Date.now where it returns the * current Date as an object rather than just milliseconds since the Unix Epoch. * * Also provides an implementation of now() for browsers (IE<9) that don't have it. * * Backwards compatible so with work with either: * Date.now() [returns ms] * or * Date.now(true) [returns Date] */ if (!$D.now) { $D._now = function now() { return new Date().getTime(); }; } else if (!$D._now) { $D._now = $D.now; } $D.now = function (returnObj) { if (returnObj) { return $D.present(); } else { return $D._now(); } }; if ( !$P.toISOString ) { $P.toISOString = function() { return this.getUTCFullYear() + "-" + p(this.getUTCMonth() + 1) + "-" + p(this.getUTCDate()) + "T" + p(this.getUTCHours()) + ":" + p(this.getUTCMinutes()) + ":" + p(this.getUTCSeconds()) + "." + String( (this.getUTCMilliseconds()/1000).toFixed(3)).slice(2, 5) + "Z"; }; } // private if ( $P._toString === undefined ){ $P._toString = $P.toString; } }; $D.initOverloads(); /** * Gets a date that is set to the current date. The time is set to the start of the day (00:00 or 12:00 AM). * @return {Date} The current date. */ $D.today = function () { return new Date().clearTime(); }; /** * Gets a date that is set to the current date and time (same as new Date, but chainable) * @return {Date} The current date. */ $D.present = function () { return new Date(); }; /** * Compares the first date to the second date and returns an number indication of their relative values. * @param {Date} First Date object to compare [Required]. * @param {Date} Second Date object to compare to [Required]. * @return {Number} -1 = date1 is lessthan date2. 0 = values are equal. 1 = date1 is greaterthan date2. */ $D.compare = function (date1, date2) { if (isNaN(date1) || isNaN(date2)) { throw new Error(date1 + " - " + date2); } else if (date1 instanceof Date && date2 instanceof Date) { return (date1 < date2) ? -1 : (date1 > date2) ? 1 : 0; } else { throw new TypeError(date1 + " - " + date2); } }; /** * Compares the first Date object to the second Date object and returns true if they are equal. * @param {Date} First Date object to compare [Required] * @param {Date} Second Date object to compare to [Required] * @return {Boolean} true if dates are equal. false if they are not equal. */ $D.equals = function (date1, date2) { return (date1.compareTo(date2) === 0); }; /** * Gets the language appropriate day name when given the day number(0-6) * eg - 0 == Sunday * @return {String} The day name */ $D.getDayName = function (n) { return Date.CultureInfo.dayNames[n]; }; /** * Gets the day number (0-6) if given a CultureInfo specific string which is a valid dayName, abbreviatedDayName or shortestDayName (two char). * @param {String} The name of the day (eg. "Monday, "Mon", "tuesday", "tue", "We", "we"). * @return {Number} The day number */ $D.getDayNumberFromName = function (name) { var n = Date.CultureInfo.dayNames, m = Date.CultureInfo.abbreviatedDayNames, o = Date.CultureInfo.shortestDayNames, s = name.toLowerCase(); for (var i = 0; i < n.length; i++) { if (n[i].toLowerCase() === s || m[i].toLowerCase() === s || o[i].toLowerCase() === s) { return i; } } return -1; }; /** * Gets the month number (0-11) if given a Culture Info specific string which is a valid monthName or abbreviatedMonthName. * @param {String} The name of the month (eg. "February, "Feb", "october", "oct"). * @return {Number} The day number */ $D.getMonthNumberFromName = function (name) { var n = Date.CultureInfo.monthNames, m = Date.CultureInfo.abbreviatedMonthNames, s = name.toLowerCase(); for (var i = 0; i < n.length; i++) { if (n[i].toLowerCase() === s || m[i].toLowerCase() === s) { return i; } } return -1; }; /** * Gets the language appropriate month name when given the month number(0-11) * eg - 0 == January * @return {String} The month name */ $D.getMonthName = function (n) { return Date.CultureInfo.monthNames[n]; }; /** * Determines if the current date instance is within a LeapYear. * @param {Number} The year. * @return {Boolean} true if date is within a LeapYear, otherwise false. */ $D.isLeapYear = function (year) { return ((year % 4 === 0 && year % 100 !== 0) || year % 400 === 0); }; /** * Gets the number of days in the month, given a year and month value. Automatically corrects for LeapYear. * @param {Number} The year. * @param {Number} The month (0-11). * @return {Number} The number of days in the month. */ $D.getDaysInMonth = function (year, month) { if (!month && $D.validateMonth(year)) { month = year; year = Date.today().getFullYear(); } return [31, ($D.isLeapYear(year) ? 29 : 28), 31, 30, 31, 30, 31, 31, 30, 31, 30, 31][month]; }; $P.getDaysInMonth = function () { return $D.getDaysInMonth(this.getFullYear(), this.getMonth()); }; $D.getTimezoneAbbreviation = function (offset, dst) { var p, n = (dst || false) ? Date.CultureInfo.abbreviatedTimeZoneDST : Date.CultureInfo.abbreviatedTimeZoneStandard; for (p in n) { if (n.hasOwnProperty(p)) { if (n[p] === offset) { return p; } } } return null; }; $D.getTimezoneOffset = function (name, dst) { var i, a =[], z = Date.CultureInfo.timezones; if (!name) { name = (new Date()).getTimezone();} for (i = 0; i < z.length; i++) { if (z[i].name === name.toUpperCase()) { a.push(i); } } if (!z[a[0]]) { return null; } if (a.length === 1 || !dst) { return z[a[0]].offset; } else { for (i=0; i < a.length; i++) { if (z[a[i]].dst) { return z[a[i]].offset; } } } }; $D.getQuarter = function (d) { d = d || new Date(); // If no date supplied, use today var q = [1,2,3,4]; return q[Math.floor(d.getMonth() / 3)]; // ~~~ is a bitwise op. Faster than Math.floor }; $D.getDaysLeftInQuarter = function (d) { d = d || new Date(); var qEnd = new Date(d); qEnd.setMonth(qEnd.getMonth() + 3 - qEnd.getMonth() % 3, 0); return Math.floor((qEnd - d) / 8.64e7); }; // private var validate = function (n, min, max, name) { name = name ? name : "Object"; if (typeof n === "undefined") { return false; } else if (typeof n !== "number") { throw new TypeError(n + " is not a Number."); } else if (n < min || n > max) { // As failing validation is *not* an exceptional circumstance // lets not throw a RangeError Exception here. // It's semantically correct but it's not sensible. return false; } return true; }; /** * Validates the number is within an acceptable range for milliseconds [0-999]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateMillisecond = function (value) { return validate(value, 0, 999, "millisecond"); }; /** * Validates the number is within an acceptable range for seconds [0-59]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateSecond = function (value) { return validate(value, 0, 59, "second"); }; /** * Validates the number is within an acceptable range for minutes [0-59]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateMinute = function (value) { return validate(value, 0, 59, "minute"); }; /** * Validates the number is within an acceptable range for hours [0-23]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateHour = function (value) { return validate(value, 0, 23, "hour"); }; /** * Validates the number is within an acceptable range for the days in a month [0-MaxDaysInMonth]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateDay = function (value, year, month) { if (year === undefined || year === null || month === undefined || month === null) { return false;} return validate(value, 1, $D.getDaysInMonth(year, month), "day"); }; /** * Validates the number is within an acceptable range for months [0-11]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateWeek = function (value) { return validate(value, 0, 53, "week"); }; /** * Validates the number is within an acceptable range for months [0-11]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateMonth = function (value) { return validate(value, 0, 11, "month"); }; /** * Validates the number is within an acceptable range for years. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateYear = function (value) { /** * Per ECMAScript spec the range of times supported by Date objects is * exactly -100,000,000 days to +100,000,000 days measured relative to * midnight at the beginning of 01 January, 1970 UTC. * This gives a range of 8,640,000,000,000,000 milliseconds to either * side of 01 January, 1970 UTC. * * Earliest possible date: Tue, 20 Apr 271,822 B.C. 00:00:00 UTC * Latest possible date: Sat, 13 Sep 275,760 00:00:00 UTC */ return validate(value, -271822, 275760, "year"); }; $D.validateTimezone = function(value) { var timezones = {"ACDT":1,"ACST":1,"ACT":1,"ADT":1,"AEDT":1,"AEST":1,"AFT":1,"AKDT":1,"AKST":1,"AMST":1,"AMT":1,"ART":1,"AST":1,"AWDT":1,"AWST":1,"AZOST":1,"AZT":1,"BDT":1,"BIOT":1,"BIT":1,"BOT":1,"BRT":1,"BST":1,"BTT":1,"CAT":1,"CCT":1,"CDT":1,"CEDT":1,"CEST":1,"CET":1,"CHADT":1,"CHAST":1,"CHOT":1,"ChST":1,"CHUT":1,"CIST":1,"CIT":1,"CKT":1,"CLST":1,"CLT":1,"COST":1,"COT":1,"CST":1,"CT":1,"CVT":1,"CWST":1,"CXT":1,"DAVT":1,"DDUT":1,"DFT":1,"EASST":1,"EAST":1,"EAT":1,"ECT":1,"EDT":1,"EEDT":1,"EEST":1,"EET":1,"EGST":1,"EGT":1,"EIT":1,"EST":1,"FET":1,"FJT":1,"FKST":1,"FKT":1,"FNT":1,"GALT":1,"GAMT":1,"GET":1,"GFT":1,"GILT":1,"GIT":1,"GMT":1,"GST":1,"GYT":1,"HADT":1,"HAEC":1,"HAST":1,"HKT":1,"HMT":1,"HOVT":1,"HST":1,"ICT":1,"IDT":1,"IOT":1,"IRDT":1,"IRKT":1,"IRST":1,"IST":1,"JST":1,"KGT":1,"KOST":1,"KRAT":1,"KST":1,"LHST":1,"LINT":1,"MAGT":1,"MART":1,"MAWT":1,"MDT":1,"MET":1,"MEST":1,"MHT":1,"MIST":1,"MIT":1,"MMT":1,"MSK":1,"MST":1,"MUT":1,"MVT":1,"MYT":1,"NCT":1,"NDT":1,"NFT":1,"NPT":1,"NST":1,"NT":1,"NUT":1,"NZDT":1,"NZST":1,"OMST":1,"ORAT":1,"PDT":1,"PET":1,"PETT":1,"PGT":1,"PHOT":1,"PHT":1,"PKT":1,"PMDT":1,"PMST":1,"PONT":1,"PST":1,"PYST":1,"PYT":1,"RET":1,"ROTT":1,"SAKT":1,"SAMT":1,"SAST":1,"SBT":1,"SCT":1,"SGT":1,"SLST":1,"SRT":1,"SST":1,"SYOT":1,"TAHT":1,"THA":1,"TFT":1,"TJT":1,"TKT":1,"TLT":1,"TMT":1,"TOT":1,"TVT":1,"UCT":1,"ULAT":1,"UTC":1,"UYST":1,"UYT":1,"UZT":1,"VET":1,"VLAT":1,"VOLT":1,"VOST":1,"VUT":1,"WAKT":1,"WAST":1,"WAT":1,"WEDT":1,"WEST":1,"WET":1,"WST":1,"YAKT":1,"YEKT":1,"Z":1}; return (timezones[value] === 1); }; $D.validateTimezoneOffset= function(value) { // timezones go from +14hrs to -12hrs, the +X hours are negative offsets. return (value > -841 && value < 721); }; }()); (function () { var $D = Date, $P = $D.prototype, p = function (s, l) { if (!l) { l = 2; } return ("000" + s).slice(l * -1); }; var validateConfigObject = function (obj) { var result = {}, self = this, prop, testFunc; testFunc = function (prop, func, value) { if (prop === "day") { var month = (obj.month !== undefined) ? obj.month : self.getMonth(); var year = (obj.year !== undefined) ? obj.year : self.getFullYear(); return $D[func](value, year, month); } else { return $D[func](value); } }; for (prop in obj) { if (Object.prototype.hasOwnProperty.call(obj, prop)) { var func = "validate" + prop.charAt(0).toUpperCase() + prop.slice(1); if ($D[func] && obj[prop] !== null && testFunc(prop, func, obj[prop])) { result[prop] = obj[prop]; } } } return result; }; /** * Resets the time of this Date object to 12:00 AM (00:00), which is the start of the day. * @param {Boolean} .clone() this date instance before clearing Time * @return {Date} this */ $P.clearTime = function () { this.setHours(0); this.setMinutes(0); this.setSeconds(0); this.setMilliseconds(0); return this; }; /** * Resets the time of this Date object to the current time ('now'). * @return {Date} this */ $P.setTimeToNow = function () { var n = new Date(); this.setHours(n.getHours()); this.setMinutes(n.getMinutes()); this.setSeconds(n.getSeconds()); this.setMilliseconds(n.getMilliseconds()); return this; }; /** * Returns a new Date object that is an exact date and time copy of the original instance. * @return {Date} A new Date instance */ $P.clone = function () { return new Date(this.getTime()); }; /** * Compares this instance to a Date object and returns an number indication of their relative values. * @param {Date} Date object to compare [Required] * @return {Number} -1 = this is lessthan date. 0 = values are equal. 1 = this is greaterthan date. */ $P.compareTo = function (date) { return Date.compare(this, date); }; /** * Compares this instance to another Date object and returns true if they are equal. * @param {Date} Date object to compare. If no date to compare, new Date() [now] is used. * @return {Boolean} true if dates are equal. false if they are not equal. */ $P.equals = function (date) { return Date.equals(this, (date !== undefined ? date : new Date())); }; /** * Determines if this instance is between a range of two dates or equal to either the start or end dates. * @param {Date} Start of range [Required] * @param {Date} End of range [Required] * @return {Boolean} true is this is between or equal to the start and end dates, else false */ $P.between = function (start, end) { return this.getTime() >= start.getTime() && this.getTime() <= end.getTime(); }; /** * Determines if this date occurs after the date to compare to. * @param {Date} Date object to compare. If no date to compare, new Date() ("now") is used. * @return {Boolean} true if this date instance is greater than the date to compare to (or "now"), otherwise false. */ $P.isAfter = function (date) { return this.compareTo(date || new Date()) === 1; }; /** * Determines if this date occurs before the date to compare to. * @param {Date} Date object to compare. If no date to compare, new Date() ("now") is used. * @return {Boolean} true if this date instance is less than the date to compare to (or "now"). */ $P.isBefore = function (date) { return (this.compareTo(date || new Date()) === -1); }; /** * Determines if the current Date instance occurs today. * @return {Boolean} true if this date instance is 'today', otherwise false. */ /** * Determines if the current Date instance occurs on the same Date as the supplied 'date'. * If no 'date' to compare to is provided, the current Date instance is compared to 'today'. * @param {date} Date object to compare. If no date to compare, the current Date ("now") is used. * @return {Boolean} true if this Date instance occurs on the same Day as the supplied 'date'. */ $P.isToday = $P.isSameDay = function (date) { return this.clone().clearTime().equals((date || new Date()).clone().clearTime()); }; /** * Adds the specified number of milliseconds to this instance. * @param {Number} The number of milliseconds to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addMilliseconds = function (value) { if (!value) { return this; } this.setTime(this.getTime() + value * 1); return this; }; /** * Adds the specified number of seconds to this instance. * @param {Number} The number of seconds to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addSeconds = function (value) { if (!value) { return this; } return this.addMilliseconds(value * 1000); }; /** * Adds the specified number of seconds to this instance. * @param {Number} The number of seconds to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addMinutes = function (value) { if (!value) { return this; } return this.addMilliseconds(value * 60000); // 60*1000 }; /** * Adds the specified number of hours to this instance. * @param {Number} The number of hours to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addHours = function (value) { if (!value) { return this; } return this.addMilliseconds(value * 3600000); // 60*60*1000 }; /** * Adds the specified number of days to this instance. * @param {Number} The number of days to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addDays = function (value) { if (!value) { return this; } this.setDate(this.getDate() + value * 1); return this; }; /** * Adds the specified number of weekdays (ie - not sat or sun) to this instance. * @param {Number} The number of days to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addWeekdays = function (value) { if (!value) { return this; } var day = this.getDay(); var weeks = (Math.ceil(Math.abs(value)/7)); if (day === 0 || day === 6) { if (value > 0) { this.next().monday(); this.addDays(-1); day = this.getDay(); } } if (value < 0) { while (value < 0) { this.addDays(-1); day = this.getDay(); if (day !== 0 && day !== 6) { value++; } } return this; } else if (value > 5 || (6-day) <= value) { value = value + (weeks * 2); } return this.addDays(value); }; /** * Adds the specified number of weeks to this instance. * @param {Number} The number of weeks to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addWeeks = function (value) { if (!value) { return this; } return this.addDays(value * 7); }; /** * Adds the specified number of months to this instance. * @param {Number} The number of months to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addMonths = function (value) { if (!value) { return this; } var n = this.getDate(); this.setDate(1); this.setMonth(this.getMonth() + value * 1); this.setDate(Math.min(n, $D.getDaysInMonth(this.getFullYear(), this.getMonth()))); return this; }; $P.addQuarters = function (value) { if (!value) { return this; } // note this will take you to the same point in the quarter as you are now. // i.e. - if you are 15 days into the quarter you'll be 15 days into the resulting one. // bonus: this allows adding fractional quarters return this.addMonths(value * 3); }; /** * Adds the specified number of years to this instance. * @param {Number} The number of years to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addYears = function (value) { if (!value) { return this; } return this.addMonths(value * 12); }; /** * Adds (or subtracts) to the value of the years, months, weeks, days, hours, minutes, seconds, milliseconds of the date instance using given configuration object. Positive and Negative values allowed. * Example

	Date.today().add( { days: 1, months: 1 } )

	new Date().add( { years: -1 } )
	
* @param {Object} Configuration object containing attributes (months, days, etc.) * @return {Date} this */ $P.add = function (config) { if (typeof config === "number") { this._orient = config; return this; } var x = config; if (x.day) { // If we should be a different date than today (eg: for 'tomorrow -1d', etc). // Should only effect parsing, not direct usage (eg, Finish and FinishExact) if ((x.day - this.getDate()) !== 0) { this.setDate(x.day); } } if (x.milliseconds) { this.addMilliseconds(x.milliseconds); } if (x.seconds) { this.addSeconds(x.seconds); } if (x.minutes) { this.addMinutes(x.minutes); } if (x.hours) { this.addHours(x.hours); } if (x.weeks) { this.addWeeks(x.weeks); } if (x.months) { this.addMonths(x.months); } if (x.years) { this.addYears(x.years); } if (x.days) { this.addDays(x.days); } return this; }; /** * Get the week number. Week one (1) is the week which contains the first Thursday of the year. Monday is considered the first day of the week. * The .getWeek() function does NOT convert the date to UTC. The local datetime is used. * Please use .getISOWeek() to get the week of the UTC converted date. * @return {Number} 1 to 53 */ $P.getWeek = function (utc) { // Create a copy of this date object var self, target = new Date(this.valueOf()); if (utc) { target.addMinutes(target.getTimezoneOffset()); self = target.clone(); } else { self = this; } // ISO week date weeks start on monday // so correct the day number var dayNr = (self.getDay() + 6) % 7; // ISO 8601 states that week 1 is the week // with the first thursday of that year. // Set the target date to the thursday in the target week target.setDate(target.getDate() - dayNr + 3); // Store the millisecond value of the target date var firstThursday = target.valueOf(); // Set the target to the first thursday of the year // First set the target to january first target.setMonth(0, 1); // Not a thursday? Correct the date to the next thursday if (target.getDay() !== 4) { target.setMonth(0, 1 + ((4 - target.getDay()) + 7) % 7); } // The weeknumber is the number of weeks between the // first thursday of the year and the thursday in the target week return 1 + Math.ceil((firstThursday - target) / 604800000); // 604800000 = 7 * 24 * 3600 * 1000 }; /** * Get the ISO 8601 week number. Week one ("01") is the week which contains the first Thursday of the year. Monday is considered the first day of the week. * The .getISOWeek() function does convert the date to it's UTC value. Please use .getWeek() to get the week of the local date. * @return {String} "01" to "53" */ $P.getISOWeek = function () { return p(this.getWeek(true)); }; /** * Moves the date to Monday of the week set. Week one (1) is the week which contains the first Thursday of the year. * @param {Number} A Number (1 to 53) that represents the week of the year. * @return {Date} this */ $P.setWeek = function (n) { if ((n - this.getWeek()) === 0) { if (this.getDay() !== 1) { return this.moveToDayOfWeek(1, (this.getDay() > 1 ? -1 : 1)); } else { return this; } } else { return this.moveToDayOfWeek(1, (this.getDay() > 1 ? -1 : 1)).addWeeks(n - this.getWeek()); } }; $P.setQuarter = function (qtr) { var month = Math.abs(((qtr-1) * 3) + 1); return this.setMonth(month, 1); }; $P.getQuarter = function () { return Date.getQuarter(this); }; $P.getDaysLeftInQuarter = function () { return Date.getDaysLeftInQuarter(this); }; /** * Moves the date to the next n'th occurrence of the dayOfWeek starting from the beginning of the month. The number (-1) is a magic number and will return the last occurrence of the dayOfWeek in the month. * @param {Number} The dayOfWeek to move to * @param {Number} The n'th occurrence to move to. Use (-1) to return the last occurrence in the month * @return {Date} this */ $P.moveToNthOccurrence = function (dayOfWeek, occurrence) { if (dayOfWeek === "Weekday") { if (occurrence > 0) { this.moveToFirstDayOfMonth(); if (this.is().weekday()) { occurrence -= 1; } } else if (occurrence < 0) { this.moveToLastDayOfMonth(); if (this.is().weekday()) { occurrence += 1; } } else { return this; } return this.addWeekdays(occurrence); } var shift = 0; if (occurrence > 0) { shift = occurrence - 1; } else if (occurrence === -1) { this.moveToLastDayOfMonth(); if (this.getDay() !== dayOfWeek) { this.moveToDayOfWeek(dayOfWeek, -1); } return this; } return this.moveToFirstDayOfMonth().addDays(-1).moveToDayOfWeek(dayOfWeek, +1).addWeeks(shift); }; var moveToN = function (getFunc, addFunc, nVal) { return function (value, orient) { var diff = (value - this[getFunc]() + nVal * (orient || +1)) % nVal; return this[addFunc]((diff === 0) ? diff += nVal * (orient || +1) : diff); }; }; /** * Move to the next or last dayOfWeek based on the orient value. * @param {Number} The dayOfWeek to move to * @param {Number} Forward (+1) or Back (-1). Defaults to +1. [Optional] * @return {Date} this */ $P.moveToDayOfWeek = moveToN("getDay", "addDays", 7); /** * Move to the next or last month based on the orient value. * @param {Number} The month to move to. 0 = January, 11 = December * @param {Number} Forward (+1) or Back (-1). Defaults to +1. [Optional] * @return {Date} this */ $P.moveToMonth = moveToN("getMonth", "addMonths", 12); /** * Get the Ordinate of the current day ("th", "st", "rd"). * @return {String} */ $P.getOrdinate = function () { var num = this.getDate(); return ord(num); }; /** * Get the Ordinal day (numeric day number) of the year, adjusted for leap year. * @return {Number} 1 through 365 (366 in leap years) */ $P.getOrdinalNumber = function () { return Math.ceil((this.clone().clearTime() - new Date(this.getFullYear(), 0, 1)) / 86400000) + 1; }; /** * Get the time zone abbreviation of the current date. * @return {String} The abbreviated time zone name (e.g. "EST") */ $P.getTimezone = function () { return $D.getTimezoneAbbreviation(this.getUTCOffset(), this.isDaylightSavingTime()); }; $P.setTimezoneOffset = function (offset) { var here = this.getTimezoneOffset(), there = Number(offset) * -6 / 10; return (there || there === 0) ? this.addMinutes(there - here) : this; }; $P.setTimezone = function (offset) { return this.setTimezoneOffset($D.getTimezoneOffset(offset)); }; /** * Indicates whether Daylight Saving Time is observed in the current time zone. * @return {Boolean} true|false */ $P.hasDaylightSavingTime = function () { return (Date.today().set({month: 0, day: 1}).getTimezoneOffset() !== Date.today().set({month: 6, day: 1}).getTimezoneOffset()); }; /** * Indicates whether this Date instance is within the Daylight Saving Time range for the current time zone. * @return {Boolean} true|false */ $P.isDaylightSavingTime = function () { return Date.today().set({month: 0, day: 1}).getTimezoneOffset() !== this.getTimezoneOffset(); }; /** * Get the offset from UTC of the current date. * @return {String} The 4-character offset string prefixed with + or - (e.g. "-0500") */ $P.getUTCOffset = function (offset) { var n = (offset || this.getTimezoneOffset()) * -10 / 6, r; if (n < 0) { r = (n - 10000).toString(); return r.charAt(0) + r.substr(2); } else { r = (n + 10000).toString(); return "+" + r.substr(1); } }; /** * Returns the number of milliseconds between this date and date. * @param {Date} Defaults to now * @return {Number} The diff in milliseconds */ $P.getElapsed = function (date) { return (date || new Date()) - this; }; /** * Set the value of year, month, day, hour, minute, second, millisecond of date instance using given configuration object. * Example

	Date.today().set( { day: 20, month: 1 } )

	new Date().set( { millisecond: 0 } )
	
* * @param {Object} Configuration object containing attributes (month, day, etc.) * @return {Date} this */ $P.set = function (config) { config = validateConfigObject.call(this, config); var key; for (key in config) { if (Object.prototype.hasOwnProperty.call(config, key)) { var name = key.charAt(0).toUpperCase() + key.slice(1); var addFunc, getFunc; if (key !== "week" && key !== "month" && key !== "timezone" && key !== "timezoneOffset") { name += "s"; } addFunc = "add" + name; getFunc = "get" + name; if (key === "month") { addFunc = addFunc + "s"; } else if (key === "year"){ getFunc = "getFullYear"; } if (key !== "day" && key !== "timezone" && key !== "timezoneOffset" && key !== "week" && key !== "hour") { this[addFunc](config[key] - this[getFunc]()); } else if ( key === "timezone"|| key === "timezoneOffset" || key === "week" || key === "hour") { this["set"+name](config[key]); } } } // day has to go last because you can't validate the day without first knowing the month if (config.day) { this.addDays(config.day - this.getDate()); } return this; }; /** * Moves the date to the first day of the month. * @return {Date} this */ $P.moveToFirstDayOfMonth = function () { return this.set({ day: 1 }); }; /** * Moves the date to the last day of the month. * @return {Date} this */ $P.moveToLastDayOfMonth = function () { return this.set({ day: $D.getDaysInMonth(this.getFullYear(), this.getMonth())}); }; /** * Converts the value of the current Date object to its equivalent string representation. * Format Specifiers * CUSTOM DATE AND TIME FORMAT STRINGS * Format Description Example * ------ --------------------------------------------------------------------------- ----------------------- * s The seconds of the minute between 0-59. "0" to "59" * ss The seconds of the minute with leading zero if required. "00" to "59" * * m The minute of the hour between 0-59. "0" or "59" * mm The minute of the hour with leading zero if required. "00" or "59" * * h The hour of the day between 1-12. "1" to "12" * hh The hour of the day with leading zero if required. "01" to "12" * * H The hour of the day between 0-23. "0" to "23" * HH The hour of the day with leading zero if required. "00" to "23" * * d The day of the month between 1 and 31. "1" to "31" * dd The day of the month with leading zero if required. "01" to "31" * ddd Abbreviated day name. Date.CultureInfo.abbreviatedDayNames. "Mon" to "Sun" * dddd The full day name. Date.CultureInfo.dayNames. "Monday" to "Sunday" * * M The month of the year between 1-12. "1" to "12" * MM The month of the year with leading zero if required. "01" to "12" * MMM Abbreviated month name. Date.CultureInfo.abbreviatedMonthNames. "Jan" to "Dec" * MMMM The full month name. Date.CultureInfo.monthNames. "January" to "December" * * yy The year as a two-digit number. "99" or "08" * yyyy The full four digit year. "1999" or "2008" * * t Displays the first character of the A.M./P.M. designator. "A" or "P" * Date.CultureInfo.amDesignator or Date.CultureInfo.pmDesignator * tt Displays the A.M./P.M. designator. "AM" or "PM" * Date.CultureInfo.amDesignator or Date.CultureInfo.pmDesignator * * S The ordinal suffix ("st, "nd", "rd" or "th") of the current day. "st, "nd", "rd" or "th" * * STANDARD DATE AND TIME FORMAT STRINGS * Format Description Example *------ --------------------------------------------------------------------------- ----------------------- * d The CultureInfo shortDate Format Pattern "M/d/yyyy" * D The CultureInfo longDate Format Pattern "dddd, MMMM dd, yyyy" * F The CultureInfo fullDateTime Format Pattern "dddd, MMMM dd, yyyy h:mm:ss tt" * m The CultureInfo monthDay Format Pattern "MMMM dd" * r The CultureInfo rfc1123 Format Pattern "ddd, dd MMM yyyy HH:mm:ss GMT" * s The CultureInfo sortableDateTime Format Pattern "yyyy-MM-ddTHH:mm:ss" * t The CultureInfo shortTime Format Pattern "h:mm tt" * T The CultureInfo longTime Format Pattern "h:mm:ss tt" * u The CultureInfo universalSortableDateTime Format Pattern "yyyy-MM-dd HH:mm:ssZ" * y The CultureInfo yearMonth Format Pattern "MMMM, yyyy" * * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @return {String} A string representation of the current Date object. */ var ord = function (n) { switch (n * 1) { case 1: case 21: case 31: return "st"; case 2: case 22: return "nd"; case 3: case 23: return "rd"; default: return "th"; } }; var parseStandardFormats = function (format) { var y, c = Date.CultureInfo.formatPatterns; switch (format) { case "d": return this.toString(c.shortDate); case "D": return this.toString(c.longDate); case "F": return this.toString(c.fullDateTime); case "m": return this.toString(c.monthDay); case "r": case "R": y = this.clone().addMinutes(this.getTimezoneOffset()); return y.toString(c.rfc1123) + " GMT"; case "s": return this.toString(c.sortableDateTime); case "t": return this.toString(c.shortTime); case "T": return this.toString(c.longTime); case "u": y = this.clone().addMinutes(this.getTimezoneOffset()); return y.toString(c.universalSortableDateTime); case "y": return this.toString(c.yearMonth); default: return false; } }; var parseFormatStringsClosure = function (context) { return function (m) { if (m.charAt(0) === "\\") { return m.replace("\\", ""); } switch (m) { case "hh": return p(context.getHours() < 13 ? (context.getHours() === 0 ? 12 : context.getHours()) : (context.getHours() - 12)); case "h": return context.getHours() < 13 ? (context.getHours() === 0 ? 12 : context.getHours()) : (context.getHours() - 12); case "HH": return p(context.getHours()); case "H": return context.getHours(); case "mm": return p(context.getMinutes()); case "m": return context.getMinutes(); case "ss": return p(context.getSeconds()); case "s": return context.getSeconds(); case "yyyy": return p(context.getFullYear(), 4); case "yy": return p(context.getFullYear()); case "y": return context.getFullYear(); case "E": case "dddd": return Date.CultureInfo.dayNames[context.getDay()]; case "ddd": return Date.CultureInfo.abbreviatedDayNames[context.getDay()]; case "dd": return p(context.getDate()); case "d": return context.getDate(); case "MMMM": return Date.CultureInfo.monthNames[context.getMonth()]; case "MMM": return Date.CultureInfo.abbreviatedMonthNames[context.getMonth()]; case "MM": return p((context.getMonth() + 1)); case "M": return context.getMonth() + 1; case "t": return context.getHours() < 12 ? Date.CultureInfo.amDesignator.substring(0, 1) : Date.CultureInfo.pmDesignator.substring(0, 1); case "tt": return context.getHours() < 12 ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator; case "S": return ord(context.getDate()); case "W": return context.getWeek(); case "WW": return context.getISOWeek(); case "Q": return "Q" + context.getQuarter(); case "q": return String(context.getQuarter()); case "z": return context.getTimezone(); case "Z": case "X": return Date.getTimezoneOffset(context.getTimezone()); case "ZZ": // Timezone offset in seconds return context.getTimezoneOffset() * -60; case "u": return context.getDay(); case "L": return ($D.isLeapYear(context.getFullYear())) ? 1 : 0; case "B": // Swatch Internet Time (.beats) return "@"+((context.getUTCSeconds() + (context.getUTCMinutes()*60) + ((context.getUTCHours()+1)*3600))/86.4); default: return m; } }; }; $P.toString = function (format, ignoreStandards) { // Standard Date and Time Format Strings. Formats pulled from CultureInfo file and // may vary by culture. if (!ignoreStandards && format && format.length === 1) { output = parseStandardFormats.call(this, format); if (output) { return output; } } var parseFormatStrings = parseFormatStringsClosure(this); return format ? format.replace(/((\\)?(dd?d?d?|MM?M?M?|yy?y?y?|hh?|HH?|mm?|ss?|tt?|S|q|Q|WW?W?W?)(?![^\[]*\]))/g, parseFormatStrings).replace(/\[|\]/g, "") : this._toString(); }; }()); /************************************************************* * SugarPak - Domain Specific Language - Syntactical Sugar * *************************************************************/ (function () { var $D = Date, $P = $D.prototype, $N = Number.prototype; // private $P._orient = +1; // private $P._nth = null; // private $P._is = false; // private $P._same = false; // private $P._isSecond = false; // private $N._dateElement = "days"; /** * Moves the date to the next instance of a date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.today().next().friday();
	Date.today().next().fri();
	Date.today().next().march();
	Date.today().next().mar();
	Date.today().next().week();
	
* * @return {Date} date */ $P.next = function () { this._move = true; this._orient = +1; return this; }; /** * Creates a new Date (Date.today()) and moves the date to the next instance of the date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.next().friday();
	Date.next().fri();
	Date.next().march();
	Date.next().mar();
	Date.next().week();
	
* * @return {Date} date */ $D.next = function () { return $D.today().next(); }; /** * Moves the date to the previous instance of a date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.today().last().friday();
	Date.today().last().fri();
	Date.today().last().march();
	Date.today().last().mar();
	Date.today().last().week();
	
* * @return {Date} date */ $P.last = $P.prev = $P.previous = function () { this._move = true; this._orient = -1; return this; }; /** * Creates a new Date (Date.today()) and moves the date to the previous instance of the date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.last().friday();
	Date.last().fri();
	Date.previous().march();
	Date.prev().mar();
	Date.last().week();
	
* * @return {Date} date */ $D.last = $D.prev = $D.previous = function () { return $D.today().last(); }; /** * Performs a equality check when followed by either a month name, day name or .weekday() function. * Example

	Date.today().is().friday(); // true|false
	Date.today().is().fri();
	Date.today().is().march();
	Date.today().is().mar();
	
* * @return {Boolean} true|false */ $P.is = function () { this._is = true; return this; }; /** * Determines if two date objects occur on/in exactly the same instance of the subsequent date part function. * The function .same() must be followed by a date part function (example: .day(), .month(), .year(), etc). * * An optional Date can be passed in the date part function. If now date is passed as a parameter, 'Now' is used. * * The following example demonstrates how to determine if two dates fall on the exact same day. * * Example

	var d1 = Date.today(); // today at 00:00
	var d2 = new Date();   // exactly now.

	// Do they occur on the same day?
	d1.same().day(d2); // true
	
	// Do they occur on the same hour?
	d1.same().hour(d2); // false, unless d2 hour is '00' (midnight).
	
	// What if it's the same day, but one year apart?
	var nextYear = Date.today().add(1).year();

	d1.same().day(nextYear); // false, because the dates must occur on the exact same day. 
	
* * Scenario: Determine if a given date occurs during some week period 2 months from now. * * Example

	var future = Date.today().add(2).months();
	return someDate.same().week(future); // true|false;
	
* * @return {Boolean} true|false */ $P.same = function () { this._same = true; this._isSecond = false; return this; }; /** * Determines if the current date/time occurs during Today. Must be preceded by the .is() function. * Example

	someDate.is().today();    // true|false
	new Date().is().today();  // true
	Date.today().is().today();// true
	Date.today().add(-1).day().is().today(); // false
	
* * @return {Boolean} true|false */ $P.today = function () { return this.same().day(); }; /** * Determines if the current date is a weekday. This function must be preceded by the .is() function. * Example

	Date.today().is().weekday(); // true|false
	
* * @return {Boolean} true|false */ $P.weekday = function () { if (this._nth) { return df("Weekday").call(this); } if (this._move) { return this.addWeekdays(this._orient); } if (this._is) { this._is = false; return (!this.is().sat() && !this.is().sun()); } return false; }; /** * Determines if the current date is on the weekend. This function must be preceded by the .is() function. * Example

	Date.today().is().weekend(); // true|false
	
* * @return {Boolean} true|false */ $P.weekend = function () { if (this._is) { this._is = false; return (this.is().sat() || this.is().sun()); } return false; }; /** * Sets the Time of the current Date instance. A string "6:15 pm" or config object {hour:18, minute:15} are accepted. * Example

	// Set time to 6:15pm with a String
	Date.today().at("6:15pm");

	// Set time to 6:15pm with a config object
	Date.today().at({hour:18, minute:15});
	
* * @return {Date} date */ $P.at = function (time) { return (typeof time === "string") ? $D.parse(this.toString("d") + " " + time) : this.set(time); }; /** * Creates a new Date() and adds this (Number) to the date based on the preceding date element function (eg. second|minute|hour|day|month|year). * Example

	// Undeclared Numbers must be wrapped with parentheses. Requirment of JavaScript.
	(3).days().fromNow();
	(6).months().fromNow();

	// Declared Number variables do not require parentheses. 
	var n = 6;
	n.months().fromNow();
	
* * @return {Date} A new Date instance */ $N.fromNow = $N.after = function (date) { var c = {}; c[this._dateElement] = this; return ((!date) ? new Date() : date.clone()).add(c); }; /** * Creates a new Date() and subtract this (Number) from the date based on the preceding date element function (eg. second|minute|hour|day|month|year). * Example

	// Undeclared Numbers must be wrapped with parentheses. Requirment of JavaScript.
	(3).days().ago();
	(6).months().ago();

	// Declared Number variables do not require parentheses. 
	var n = 6;
	n.months().ago();
	
* * @return {Date} A new Date instance */ $N.ago = $N.before = function (date) { var c = {}, s = (this._dateElement[this._dateElement.length-1] !== "s") ? this._dateElement + "s" : this._dateElement; c[s] = this * -1; return ((!date) ? new Date() : date.clone()).add(c); }; // Do NOT modify the following string tokens. These tokens are used to build dynamic functions. // All culture-specific strings can be found in the CultureInfo files. var dx = ("sunday monday tuesday wednesday thursday friday saturday").split(/\s/), mx = ("january february march april may june july august september october november december").split(/\s/), px = ("Millisecond Second Minute Hour Day Week Month Year Quarter Weekday").split(/\s/), pxf = ("Milliseconds Seconds Minutes Hours Date Week Month FullYear Quarter").split(/\s/), nth = ("final first second third fourth fifth").split(/\s/), de; /** * Returns an object literal of all the date parts. * Example

	var o = new Date().toObject();
	
	// { year: 2008, month: 4, week: 20, day: 13, hour: 18, minute: 9, second: 32, millisecond: 812 }
	
	// The object properties can be referenced directly from the object.
	
	alert(o.day);  // alerts "13"
	alert(o.year); // alerts "2008"
	
* * @return {Date} An object literal representing the original date object. */ $P.toObject = function () { var o = {}; for (var i = 0; i < px.length; i++) { if (this["get" + pxf[i]]) { o[px[i].toLowerCase()] = this["get" + pxf[i]](); } } return o; }; /** * Returns a date created from an object literal. Ignores the .week property if set in the config. * Example

	var o = new Date().toObject();
	
	return Date.fromObject(o); // will return the same date. 

	var o2 = {month: 1, day: 20, hour: 18}; // birthday party!
	Date.fromObject(o2);
	
* * @return {Date} An object literal representing the original date object. */ $D.fromObject = function(config) { config.week = null; return Date.today().set(config); }; // Create day name functions and abbreviated day name functions (eg. monday(), friday(), fri()). var df = function (n) { return function () { if (this._is) { this._is = false; return this.getDay() === n; } if (this._move) { this._move = null; } if (this._nth !== null) { // If the .second() function was called earlier, remove the _orient // from the date, and then continue. // This is required because 'second' can be used in two different context. // // Example // // Date.today().add(1).second(); // Date.march().second().monday(); // // Things get crazy with the following... // Date.march().add(1).second().second().monday(); // but it works!! // if (this._isSecond) { this.addSeconds(this._orient * -1); } // make sure we reset _isSecond this._isSecond = false; var ntemp = this._nth; this._nth = null; var temp = this.clone().moveToLastDayOfMonth(); this.moveToNthOccurrence(n, ntemp); if (this > temp) { throw new RangeError($D.getDayName(n) + " does not occur " + ntemp + " times in the month of " + $D.getMonthName(temp.getMonth()) + " " + temp.getFullYear() + "."); } return this; } return this.moveToDayOfWeek(n, this._orient); }; }; var sdf = function (n) { return function () { var t = $D.today(), shift = n - t.getDay(); if (n === 0 && Date.CultureInfo.firstDayOfWeek === 1 && t.getDay() !== 0) { shift = shift + 7; } return t.addDays(shift); }; }; // Create month name functions and abbreviated month name functions (eg. january(), march(), mar()). var month_instance_functions = function (n) { return function () { if (this._is) { this._is = false; return this.getMonth() === n; } return this.moveToMonth(n, this._orient); }; }; var month_static_functions = function (n) { return function () { return $D.today().set({ month: n, day: 1 }); }; }; var processTerms = function (names, staticFunc, instanceFunc) { for (var i = 0; i < names.length; i++) { // Create constant static Name variables. $D[names[i].toUpperCase()] = $D[names[i].toUpperCase().substring(0, 3)] = i; // Create Name functions. $D[names[i]] = $D[names[i].substring(0, 3)] = staticFunc(i); // Create Name instance functions. $P[names[i]] = $P[names[i].substring(0, 3)] = instanceFunc(i); } }; processTerms(dx, sdf, df); processTerms(mx, month_static_functions, month_instance_functions); // Create date element functions and plural date element functions used with Date (eg. day(), days(), months()). var ef = function (j) { return function () { // if the .second() function was called earlier, the _orient // has alread been added. Just return this and reset _isSecond. if (this._isSecond) { this._isSecond = false; return this; } if (this._same) { this._same = this._is = false; var o1 = this.toObject(), o2 = (arguments[0] || new Date()).toObject(), v = "", k = j.toLowerCase(); // the substr trick with -1 doesn't work in IE8 or less k = (k[k.length-1] === "s") ? k.substring(0,k.length-1) : k; for (var m = (px.length - 1); m > -1; m--) { v = px[m].toLowerCase(); if (o1[v] !== o2[v]) { return false; } if (k === v) { break; } } return true; } if (j.substring(j.length - 1) !== "s") { j += "s"; } if (this._move) { this._move = null; } return this["add" + j](this._orient); }; }; var nf = function (n) { return function () { this._dateElement = n; return this; }; }; for (var k = 0; k < px.length; k++) { de = px[k].toLowerCase(); if(de !== "weekday") { // Create date element functions and plural date element functions used with Date (eg. day(), days(), months()). $P[de] = $P[de + "s"] = ef(px[k]); // Create date element functions and plural date element functions used with Number (eg. day(), days(), months()). $N[de] = $N[de + "s"] = nf(de + "s"); } } $P._ss = ef("Second"); var nthfn = function (n) { return function (dayOfWeek) { if (this._same) { return this._ss(arguments[0]); } if (dayOfWeek || dayOfWeek === 0) { return this.moveToNthOccurrence(dayOfWeek, n); } this._nth = n; // if the operator is 'second' add the _orient, then deal with it later... if (n === 2 && (dayOfWeek === undefined || dayOfWeek === null)) { this._isSecond = true; return this.addSeconds(this._orient); } return this; }; }; for (var l = 0; l < nth.length; l++) { $P[nth[l]] = (l === 0) ? nthfn(-1) : nthfn(l); } }()); (function () { "use strict"; Date.Parsing = { Exception: function (s) { this.message = "Parse error at '" + s.substring(0, 10) + " ...'"; } }; var $P = Date.Parsing; var dayOffsets = { standard: [0,31,59,90,120,151,181,212,243,273,304,334], leap: [0,31,60,91,121,152,182,213,244,274,305,335] }; $P.isLeapYear = function(year) { return ((year % 4 === 0) && (year % 100 !== 0)) || (year % 400 === 0); }; var utils = { multiReplace : function (str, hash ) { var key; for (key in hash) { if (Object.prototype.hasOwnProperty.call(hash, key)) { var regex; if (typeof hash[key] === "function") { } else { regex = (hash[key] instanceof RegExp) ? hash[key] : new RegExp(hash[key], "g"); } str = str.replace(regex, key); } } return str; }, getDayOfYearFromWeek : function (obj) { var d, jan4, offset; obj.weekDay = (!obj.weekDay && obj.weekDay !== 0) ? 1 : obj.weekDay; d = new Date(obj.year, 0, 4); jan4 = d.getDay() === 0 ? 7 : d.getDay(); // JS is 0 indexed on Sunday. offset = jan4+3; obj.dayOfYear = ((obj.week * 7) + (obj.weekDay === 0 ? 7 : obj.weekDay))-offset; return obj; }, getDayOfYear : function (obj, dayOffset) { if (!obj.dayOfYear) { obj = utils.getDayOfYearFromWeek(obj); } for (var i=0;i <= dayOffset.length;i++) { if (obj.dayOfYear < dayOffset[i] || i === dayOffset.length) { obj.day = obj.day ? obj.day : (obj.dayOfYear - dayOffset[i-1]); break; } else { obj.month = i; } } return obj; }, adjustForTimeZone : function (obj, date) { var offset; if (obj.zone.toUpperCase() === "Z" || (obj.zone_hours === 0 && obj.zone_minutes === 0)) { // it's UTC/GML so work out the current timeszone offset offset = -date.getTimezoneOffset(); } else { offset = (obj.zone_hours*60) + (obj.zone_minutes || 0); if (obj.zone_sign === "+") { offset *= -1; } offset -= date.getTimezoneOffset(); } date.setMinutes(date.getMinutes()+offset); return date; }, setDefaults : function (obj) { obj.year = obj.year || Date.today().getFullYear(); obj.hours = obj.hours || 0; obj.minutes = obj.minutes || 0; obj.seconds = obj.seconds || 0; obj.milliseconds = obj.milliseconds || 0; if (!(!obj.month && (obj.week || obj.dayOfYear))) { // if we have a month, or if we don't but don't have the day calculation data obj.month = obj.month || 0; obj.day = obj.day || 1; } return obj; }, dataNum: function (data, mod, explict, postProcess) { var dataNum = data*1; if (mod) { if (postProcess) { return data ? mod(data)*1 : data; } else { return data ? mod(dataNum) : data; } } else if (!explict){ return data ? dataNum : data; } else { return (data && typeof data !== "undefined") ? dataNum : data; } }, timeDataProcess: function (obj) { var timeObj = {}; for (var x in obj.data) { if (obj.data.hasOwnProperty(x)) { timeObj[x] = obj.ignore[x] ? obj.data[x] : utils.dataNum(obj.data[x], obj.mods[x], obj.explict[x], obj.postProcess[x]); } } if (obj.data.secmins) { obj.data.secmins = obj.data.secmins.replace(",", ".") * 60; if (!timeObj.minutes) { timeObj.minutes = obj.data.secmins; } else if (!timeObj.seconds) { timeObj.seconds = obj.data.secmins; } delete obj.secmins; } return timeObj; }, buildTimeObjectFromData: function (data) { var time = utils.timeDataProcess({ data: { year : data[1], month : data[5], day : data[7], week : data[8], dayOfYear : data[10], hours : data[15], zone_hours : data[23], zone_minutes : data[24], zone : data[21], zone_sign : data[22], weekDay : data[9], minutes: data[16], seconds: data[19], milliseconds: data[20], secmins: data[18] }, mods: { month: function(data) { return data-1; }, weekDay: function (data) { data = Math.abs(data); return (data === 7 ? 0 : data); }, minutes: function (data) { return data.replace(":",""); }, seconds: function (data) { return Math.floor( (data.replace(":","").replace(",","."))*1 ); }, milliseconds: function (data) { return (data.replace(",",".")*1000); } }, postProcess: { minutes: true, seconds: true, milliseconds: true }, explict: { zone_hours: true, zone_minutes: true }, ignore: { zone: true, zone_sign: true, secmins: true } }); return time; }, addToHash: function (hash, keys, data) { keys = keys; data = data; var len = keys.length; for (var i = 0; i < len; i++) { hash[keys[i]] = data[i]; } return hash; }, combineRegex: function (r1, r2) { return new RegExp("(("+r1.source+")\\s("+r2.source+"))"); }, getDateNthString: function(add, last, inc){ if (add) { return Date.today().addDays(inc).toString("d"); } else if (last) { return Date.today().last()[inc]().toString("d"); } }, buildRegexData: function (array) { var arr = []; var len = array.length; for (var i=0; i < len; i++) { if (Object.prototype.toString.call(array[i]) === '[object Array]') { // oldIE compat version of Array.isArray arr.push(this.combineRegex(array[i][0], array[i][1])); } else { arr.push(array[i]); } } return arr; } }; $P.processTimeObject = function (obj) { var date, dayOffset; utils.setDefaults(obj); dayOffset = ($P.isLeapYear(obj.year)) ? dayOffsets.leap : dayOffsets.standard; if (!obj.month && (obj.week || obj.dayOfYear)) { utils.getDayOfYear(obj, dayOffset); } else { obj.dayOfYear = dayOffset[obj.month] + obj.day; } date = new Date(obj.year, obj.month, obj.day, obj.hours, obj.minutes, obj.seconds, obj.milliseconds); if (obj.zone) { utils.adjustForTimeZone(obj, date); // adjust (and calculate) for timezone } return date; }; $P.ISO = { regex : /^([\+-]?\d{4}(?!\d{2}\b))((-?)((0[1-9]|1[0-2])(\3([12]\d|0[1-9]|3[01]))?|W([0-4]\d|5[0-3])(-?[1-7])?|(00[1-9]|0[1-9]\d|[12]\d{2}|3([0-5]\d|6[1-6])))([T\s]((([01]\d|2[0-4])((:?)[0-5]\d)?|24\:?00)([\.,]\d+(?!:))?)?(\17[0-5]\d([\.,]\d+)?)?\s?([zZ]|([\+-])([01]\d|2[0-3]):?([0-5]\d)?)?)?)?$/, parse : function (s) { var time, data = s.match(this.regex); if (!data || !data.length) { return null; } time = utils.buildTimeObjectFromData(data); if (!time.year || (!time.year && (!time.month && !time.day) && (!time.week && !time.dayOfYear)) ) { return null; } return $P.processTimeObject(time); } }; $P.Numeric = { isNumeric: function (e){return!isNaN(parseFloat(e))&&isFinite(e);}, regex: /\b([0-1]?[0-9])([0-3]?[0-9])([0-2]?[0-9]?[0-9][0-9])\b/i, parse: function (s) { var data, i, time = {}, order = Date.CultureInfo.dateElementOrder.split(""); if (!(this.isNumeric(s)) || // if it's non-numeric OR (s[0] === "+" && s[0] === "-")) { // It's an arithmatic string (eg +/-1000) return null; } if (s.length < 5 && s.indexOf(".") < 0 && s.indexOf("/") < 0) { // assume it's just a year. time.year = s; return $P.processTimeObject(time); } data = s.match(this.regex); if (!data || !data.length) { return null; } for (i=0; i < order.length; i++) { switch(order[i]) { case "d": time.day = data[i+1]; break; case "m": time.month = (data[i+1]-1); break; case "y": time.year = data[i+1]; break; } } return $P.processTimeObject(time); } }; $P.Normalizer = { regexData: function () { var $R = Date.CultureInfo.regexPatterns; return utils.buildRegexData([ $R.tomorrow, $R.yesterday, [$R.past, $R.mon], [$R.past, $R.tue], [$R.past, $R.wed], [$R.past, $R.thu], [$R.past, $R.fri], [$R.past, $R.sat], [$R.past, $R.sun] ]); }, basicReplaceHash : function() { var $R = Date.CultureInfo.regexPatterns; return { "January": $R.jan.source, "February": $R.feb, "March": $R.mar, "April": $R.apr, "May": $R.may, "June": $R.jun, "July": $R.jul, "August": $R.aug, "September": $R.sep, "October": $R.oct, "November": $R.nov, "December": $R.dec, "": /\bat\b/gi, " ": /\s{2,}/, "am": $R.inTheMorning, "9am": $R.thisMorning, "pm": $R.inTheEvening, "7pm":$R.thisEvening }; }, keys : function(){ return [ utils.getDateNthString(true, false, 1), // tomorrow utils.getDateNthString(true, false, -1), // yesterday utils.getDateNthString(false, true, "monday"), //last mon utils.getDateNthString(false, true, "tuesday"), //last tues utils.getDateNthString(false, true, "wednesday"), //last wed utils.getDateNthString(false, true, "thursday"), //last thurs utils.getDateNthString(false, true, "friday"), //last fri utils.getDateNthString(false, true, "saturday"), //last sat utils.getDateNthString(false, true, "sunday") //last sun ]; }, buildRegexFunctions: function () { var $R = Date.CultureInfo.regexPatterns; var __ = Date.i18n.__; var tomorrowRE = new RegExp("(\\b\\d\\d?("+__("AM")+"|"+__("PM")+")? )("+$R.tomorrow.source.slice(1)+")", "i"); // adapted tomorrow regex for AM PM relative dates var todayRE = new RegExp($R.today.source + "(?!\\s*([+-]))\\b"); // today, but excludes the math operators (eg "today + 2h") this.replaceFuncs = [ [todayRE, function (full) { return (full.length > 1) ? Date.today().toString("d") : full; }], [tomorrowRE, function(full, m1) { var t = Date.today().addDays(1).toString("d"); return (t + " " + m1); }], [$R.amThisMorning, function(str, am){return am;}], [$R.pmThisEvening, function(str, pm){return pm;}] ]; }, buildReplaceData: function () { this.buildRegexFunctions(); this.replaceHash = utils.addToHash(this.basicReplaceHash(), this.keys(), this.regexData()); }, stringReplaceFuncs: function (s) { for (var i=0; i < this.replaceFuncs.length; i++) { s = s.replace(this.replaceFuncs[i][0], this.replaceFuncs[i][1]); } return s; }, parse: function (s) { s = this.stringReplaceFuncs(s); s = utils.multiReplace(s, this.replaceHash); try { var n = s.split(/([\s\-\.\,\/\x27]+)/); if (n.length === 3 && $P.Numeric.isNumeric(n[0]) && $P.Numeric.isNumeric(n[2]) && (n[2].length >= 4)) { // ok, so we're dealing with x/year. But that's not a full date. // This fixes wonky dateElementOrder parsing when set to dmy order. if (Date.CultureInfo.dateElementOrder[0] === "d") { s = "1/" + n[0] + "/" + n[2]; // set to 1st of month and normalize the seperator } } } catch (e) {} return s; } }; $P.Normalizer.buildReplaceData(); }()); (function () { var $P = Date.Parsing; var _ = $P.Operators = { // // Tokenizers // rtoken: function (r) { // regex token return function (s) { var mx = s.match(r); if (mx) { return ([ mx[0], s.substring(mx[0].length) ]); } else { throw new $P.Exception(s); } }; }, token: function () { // whitespace-eating token return function (s) { return _.rtoken(new RegExp("^\\s*" + s + "\\s*"))(s); }; }, stoken: function (s) { // string token return _.rtoken(new RegExp("^" + s)); }, // Atomic Operators until: function (p) { return function (s) { var qx = [], rx = null; while (s.length) { try { rx = p.call(this, s); } catch (e) { qx.push(rx[0]); s = rx[1]; continue; } break; } return [ qx, s ]; }; }, many: function (p) { return function (s) { var rx = [], r = null; while (s.length) { try { r = p.call(this, s); } catch (e) { return [ rx, s ]; } rx.push(r[0]); s = r[1]; } return [ rx, s ]; }; }, // generator operators -- see below optional: function (p) { return function (s) { var r = null; try { r = p.call(this, s); } catch (e) { return [ null, s ]; } return [ r[0], r[1] ]; }; }, not: function (p) { return function (s) { try { p.call(this, s); } catch (e) { return [null, s]; } throw new $P.Exception(s); }; }, ignore: function (p) { return p ? function (s) { var r = null; r = p.call(this, s); return [null, r[1]]; } : null; }, product: function () { var px = arguments[0], qx = Array.prototype.slice.call(arguments, 1), rx = []; for (var i = 0 ; i < px.length ; i++) { rx.push(_.each(px[i], qx)); } return rx; }, cache: function (rule) { var cache = {}, cache_length = 0, cache_keys = [], CACHE_MAX = Date.Config.CACHE_MAX || 100000, r = null; var cacheCheck = function () { if (cache_length === CACHE_MAX) { // kill several keys, don't want to have to do this all the time... for (var i=0; i < 10; i++) { var key = cache_keys.shift(); if (key) { delete cache[key]; cache_length--; } } } }; return function (s) { cacheCheck(); try { r = cache[s] = (cache[s] || rule.call(this, s)); } catch (e) { r = cache[s] = e; } cache_length++; cache_keys.push(s); if (r instanceof $P.Exception) { throw r; } else { return r; } }; }, // vector operators -- see below any: function () { var px = arguments; return function (s) { var r = null; for (var i = 0; i < px.length; i++) { if (px[i] == null) { continue; } try { r = (px[i].call(this, s)); } catch (e) { r = null; } if (r) { return r; } } throw new $P.Exception(s); }; }, each: function () { var px = arguments; return function (s) { var rx = [], r = null; for (var i = 0; i < px.length ; i++) { if (px[i] == null) { continue; } try { r = (px[i].call(this, s)); } catch (e) { throw new $P.Exception(s); } rx.push(r[0]); s = r[1]; } return [ rx, s]; }; }, all: function () { var px = arguments, _ = _; return _.each(_.optional(px)); }, // delimited operators sequence: function (px, d, c) { d = d || _.rtoken(/^\s*/); c = c || null; if (px.length === 1) { return px[0]; } return function (s) { var r = null, q = null; var rx = []; for (var i = 0; i < px.length ; i++) { try { r = px[i].call(this, s); } catch (e) { break; } rx.push(r[0]); try { q = d.call(this, r[1]); } catch (ex) { q = null; break; } s = q[1]; } if (!r) { throw new $P.Exception(s); } if (q) { throw new $P.Exception(q[1]); } if (c) { try { r = c.call(this, r[1]); } catch (ey) { throw new $P.Exception(r[1]); } } return [ rx, (r?r[1]:s) ]; }; }, // // Composite Operators // between: function (d1, p, d2) { d2 = d2 || d1; var _fn = _.each(_.ignore(d1), p, _.ignore(d2)); return function (s) { var rx = _fn.call(this, s); return [[rx[0][0], r[0][2]], rx[1]]; }; }, list: function (p, d, c) { d = d || _.rtoken(/^\s*/); c = c || null; return (p instanceof Array ? _.each(_.product(p.slice(0, -1), _.ignore(d)), p.slice(-1), _.ignore(c)) : _.each(_.many(_.each(p, _.ignore(d))), px, _.ignore(c))); }, set: function (px, d, c) { d = d || _.rtoken(/^\s*/); c = c || null; return function (s) { // r is the current match, best the current 'best' match // which means it parsed the most amount of input var r = null, p = null, q = null, rx = null, best = [[], s], last = false; // go through the rules in the given set for (var i = 0; i < px.length ; i++) { // last is a flag indicating whether this must be the last element // if there is only 1 element, then it MUST be the last one q = null; p = null; r = null; last = (px.length === 1); // first, we try simply to match the current pattern // if not, try the next pattern try { r = px[i].call(this, s); } catch (e) { continue; } // since we are matching against a set of elements, the first // thing to do is to add r[0] to matched elements rx = [[r[0]], r[1]]; // if we matched and there is still input to parse and // we don't already know this is the last element, // we're going to next check for the delimiter ... // if there's none, or if there's no input left to parse // than this must be the last element after all ... if (r[1].length > 0 && ! last) { try { q = d.call(this, r[1]); } catch (ex) { last = true; } } else { last = true; } // if we parsed the delimiter and now there's no more input, // that means we shouldn't have parsed the delimiter at all // so don't update r and mark this as the last element ... if (!last && q[1].length === 0) { last = true; } // so, if this isn't the last element, we're going to see if // we can get any more matches from the remaining (unmatched) // elements ... if (!last) { // build a list of the remaining rules we can match against, // i.e., all but the one we just matched against var qx = []; for (var j = 0; j < px.length ; j++) { if (i !== j) { qx.push(px[j]); } } // now invoke recursively set with the remaining input // note that we don't include the closing delimiter ... // we'll check for that ourselves at the end p = _.set(qx, d).call(this, q[1]); // if we got a non-empty set as a result ... // (otw rx already contains everything we want to match) if (p[0].length > 0) { // update current result, which is stored in rx ... // basically, pick up the remaining text from p[1] // and concat the result from p[0] so that we don't // get endless nesting ... rx[0] = rx[0].concat(p[0]); rx[1] = p[1]; } } // at this point, rx either contains the last matched element // or the entire matched set that starts with this element. // now we just check to see if this variation is better than // our best so far, in terms of how much of the input is parsed if (rx[1].length < best[1].length) { best = rx; } // if we've parsed all the input, then we're finished if (best[1].length === 0) { break; } } // so now we've either gone through all the patterns trying them // as the initial match; or we found one that parsed the entire // input string ... // if best has no matches, just return empty set ... if (best[0].length === 0) { return best; } // if a closing delimiter is provided, then we have to check it also if (c) { // we try this even if there is no remaining input because the pattern // may well be optional or match empty input ... try { q = c.call(this, best[1]); } catch (ey) { throw new $P.Exception(best[1]); } // it parsed ... be sure to update the best match remaining input best[1] = q[1]; } // if we're here, either there was no closing delimiter or we parsed it // so now we have the best match; just return it! return best; }; }, forward: function (gr, fname) { return function (s) { return gr[fname].call(this, s); }; }, // // Translation Operators // replace: function (rule, repl) { return function (s) { var r = rule.call(this, s); return [repl, r[1]]; }; }, process: function (rule, fn) { return function (s) { var r = rule.call(this, s); return [fn.call(this, r[0]), r[1]]; }; }, min: function (min, rule) { return function (s) { var rx = rule.call(this, s); if (rx[0].length < min) { throw new $P.Exception(s); } return rx; }; } }; // Generator Operators And Vector Operators // Generators are operators that have a signature of F(R) => R, // taking a given rule and returning another rule, such as // ignore, which parses a given rule and throws away the result. // Vector operators are those that have a signature of F(R1,R2,...) => R, // take a list of rules and returning a new rule, such as each. // Generator operators are converted (via the following _generator // function) into functions that can also take a list or array of rules // and return an array of new rules as though the function had been // called on each rule in turn (which is what actually happens). // This allows generators to be used with vector operators more easily. // Example: // each(ignore(foo, bar)) instead of each(ignore(foo), ignore(bar)) // This also turns generators into vector operators, which allows // constructs like: // not(cache(foo, bar)) var _generator = function (op) { function gen() { var args = null, rx = [], px, i; if (arguments.length > 1) { args = Array.prototype.slice.call(arguments); } else if (arguments[0] instanceof Array) { args = arguments[0]; } if (args) { px = args.shift(); if (px.length > 0) { args.unshift(px[i]); rx.push(op.apply(null, args)); args.shift(); return rx; } } else { return op.apply(null, arguments); } } return gen; }; var gx = "optional not ignore cache".split(/\s/); for (var i = 0 ; i < gx.length ; i++) { _[gx[i]] = _generator(_[gx[i]]); } var _vector = function (op) { return function () { if (arguments[0] instanceof Array) { return op.apply(null, arguments[0]); } else { return op.apply(null, arguments); } }; }; var vx = "each any all".split(/\s/); for (var j = 0 ; j < vx.length ; j++) { _[vx[j]] = _vector(_[vx[j]]); } }()); (function () { var $D = Date; var flattenAndCompact = function (ax) { var rx = []; for (var i = 0; i < ax.length; i++) { if (ax[i] instanceof Array) { rx = rx.concat(flattenAndCompact(ax[i])); } else { if (ax[i]) { rx.push(ax[i]); } } } return rx; }; var parseMeridian = function () { if (this.meridian && (this.hour || this.hour === 0)) { if (this.meridian === "a" && this.hour > 11 && Date.Config.strict24hr){ throw "Invalid hour and meridian combination"; } else if (this.meridian === "p" && this.hour < 12 && Date.Config.strict24hr){ throw "Invalid hour and meridian combination"; } else if (this.meridian === "p" && this.hour < 12) { this.hour = this.hour + 12; } else if (this.meridian === "a" && this.hour === 12) { this.hour = 0; } } }; var setDefaults = function () { var now = new Date(); if ((this.hour || this.minute) && (!this.month && !this.year && !this.day)) { this.day = now.getDate(); } if (!this.year) { this.year = now.getFullYear(); } if (!this.month && this.month !== 0) { this.month = now.getMonth(); } if (!this.day) { this.day = 1; } if (!this.hour) { this.hour = 0; } if (!this.minute) { this.minute = 0; } if (!this.second) { this.second = 0; } if (!this.millisecond) { this.millisecond = 0; } }; var finishUtils = { getToday: function () { if (this.now || "hour minute second".indexOf(this.unit) !== -1) { return new Date(); } else { return $D.today(); } }, setDaysFromWeekday: function (today, orient){ var gap; orient = orient || 1; this.unit = "day"; gap = ($D.getDayNumberFromName(this.weekday) - today.getDay()); this.days = gap ? ((gap + (orient * 7)) % 7) : (orient * 7); return this; }, setMonthsFromMonth: function (today, orient) { var gap; orient = orient || 1; this.unit = "month"; gap = (this.month - today.getMonth()); this.months = gap ? ((gap + (orient * 12)) % 12) : (orient * 12); this.month = null; return this; }, setDMYFromWeekday: function () { var d = Date[this.weekday](); this.day = d.getDate(); if (!this.month) { this.month = d.getMonth(); } this.year = d.getFullYear(); return this; }, setUnitValue: function (orient) { if (!this.value && this.operator && this.operator !== null && this[this.unit + "s"] && this[this.unit + "s"] !== null) { this[this.unit + "s"] = this[this.unit + "s"] + ((this.operator === "add") ? 1 : -1) + (this.value||0) * orient; } else if (this[this.unit + "s"] == null || this.operator != null) { if (!this.value) { this.value = 1; } this[this.unit + "s"] = this.value * orient; } }, generateDateFromWeeks: function () { var weekday = (this.weekday !== undefined) ? this.weekday : "today"; var d = Date[weekday]().addWeeks(this.weeks); if (this.now) { d.setTimeToNow(); } return d; } }; $D.Translator = { hour: function (s) { return function () { this.hour = Number(s); }; }, minute: function (s) { return function () { this.minute = Number(s); }; }, second: function (s) { return function () { this.second = Number(s); }; }, /* for ss.s format */ secondAndMillisecond: function (s) { return function () { var mx = s.match(/^([0-5][0-9])\.([0-9]{1,3})/); this.second = Number(mx[1]); this.millisecond = Number(mx[2]); }; }, meridian: function (s) { return function () { this.meridian = s.slice(0, 1).toLowerCase(); }; }, timezone: function (s) { return function () { var n = s.replace(/[^\d\+\-]/g, ""); if (n.length) { this.timezoneOffset = Number(n); } else { this.timezone = s.toLowerCase(); } }; }, day: function (x) { var s = x[0]; return function () { this.day = Number(s.match(/\d+/)[0]); if (this.day < 1) { throw "invalid day"; } }; }, month: function (s) { return function () { this.month = (s.length === 3) ? "jan feb mar apr may jun jul aug sep oct nov dec".indexOf(s)/4 : Number(s) - 1; if (this.month < 0) { throw "invalid month"; } }; }, year: function (s) { return function () { var n = Number(s); this.year = ((s.length > 2) ? n : (n + (((n + 2000) < Date.CultureInfo.twoDigitYearMax) ? 2000 : 1900))); }; }, rday: function (s) { return function () { switch (s) { case "yesterday": this.days = -1; break; case "tomorrow": this.days = 1; break; case "today": this.days = 0; break; case "now": this.days = 0; this.now = true; break; } }; }, finishExact: function (x) { var d; x = (x instanceof Array) ? x : [x]; for (var i = 0 ; i < x.length ; i++) { if (x[i]) { x[i].call(this); } } setDefaults.call(this); parseMeridian.call(this); if (this.day > $D.getDaysInMonth(this.year, this.month)) { throw new RangeError(this.day + " is not a valid value for days."); } d = new Date(this.year, this.month, this.day, this.hour, this.minute, this.second, this.millisecond); if (this.year < 100) { d.setFullYear(this.year); // means years less that 100 are process correctly. JS will parse it otherwise as 1900-1999. } if (this.timezone) { d.set({ timezone: this.timezone }); } else if (this.timezoneOffset) { d.set({ timezoneOffset: this.timezoneOffset }); } return d; }, finish: function (x) { var today, expression, orient, temp; x = (x instanceof Array) ? flattenAndCompact(x) : [ x ]; if (x.length === 0) { return null; } for (var i = 0 ; i < x.length ; i++) { if (typeof x[i] === "function") { x[i].call(this); } } if (this.now && !this.unit && !this.operator) { return new Date(); } else { today = finishUtils.getToday.call(this); } expression = !!(this.days && this.days !== null || this.orient || this.operator); orient = ((this.orient === "past" || this.operator === "subtract") ? -1 : 1); if (this.month && this.unit === "week") { this.value = this.month + 1; delete this.month; delete this.day; } if ((this.month || this.month === 0) && "year day hour minute second".indexOf(this.unit) !== -1) { if (!this.value) { this.value = this.month + 1; } this.month = null; expression = true; } if (!expression && this.weekday && !this.day && !this.days) { finishUtils.setDMYFromWeekday.call(this); } if (expression && this.weekday && this.unit !== "month" && this.unit !== "week") { finishUtils.setDaysFromWeekday.call(this, today, orient); } if (this.weekday && this.unit !== "week" && !this.day && !this.days) { temp = Date[this.weekday](); this.day = temp.getDate(); if (temp.getMonth() !== today.getMonth()) { this.month = temp.getMonth(); } } if (this.month && this.unit === "day" && this.operator) { if (!this.value) { this.value = (this.month + 1); } this.month = null; } if (this.value != null && this.month != null && this.year != null) { this.day = this.value * 1; } if (this.month && !this.day && this.value) { today.set({ day: this.value * 1 }); if (!expression) { this.day = this.value * 1; } } if (!this.month && this.value && this.unit === "month" && !this.now) { this.month = this.value; expression = true; } if (expression && (this.month || this.month === 0) && this.unit !== "year") { finishUtils.setMonthsFromMonth.call(this, today, orient); } if (!this.unit) { this.unit = "day"; } finishUtils.setUnitValue.call(this, orient); parseMeridian.call(this); if ((this.month || this.month === 0) && !this.day) { this.day = 1; } if (!this.orient && !this.operator && this.unit === "week" && this.value && !this.day && !this.month) { return Date.today().setWeek(this.value); } if (this.unit === "week" && this.weeks && !this.day && !this.month) { return finishUtils.generateDateFromWeeks.call(this); } if (expression && this.timezone && this.day && this.days) { this.day = this.days; } if (expression){ today.add(this); } else { today.set(this); } if (this.timezone) { this.timezone = this.timezone.toUpperCase(); var offset = $D.getTimezoneOffset(this.timezone); var timezone; if (today.hasDaylightSavingTime()) { // lets check that we're being sane with timezone setting timezone = $D.getTimezoneAbbreviation(offset, today.isDaylightSavingTime()); if (timezone !== this.timezone) { // bugger, we're in a place where things like EST vs EDT matters. if (today.isDaylightSavingTime()) { today.addHours(-1); } else { today.addHours(1); } } } today.setTimezoneOffset(offset); } return today; } }; }()); (function () { var $D = Date; $D.Grammar = {}; var _ = $D.Parsing.Operators, g = $D.Grammar, t = $D.Translator, _fn; // Allow rolling up into general purpose rules _fn = function () { return _.each(_.any.apply(null, arguments), _.not(g.ctoken2("timeContext"))); }; g.datePartDelimiter = _.rtoken(/^([\s\-\.\,\/\x27]+)/); g.timePartDelimiter = _.stoken(":"); g.whiteSpace = _.rtoken(/^\s*/); g.generalDelimiter = _.rtoken(/^(([\s\,]|at|@|on)+)/); var _C = {}; g.ctoken = function (keys) { var fn = _C[keys]; if (! fn) { var c = Date.CultureInfo.regexPatterns; var kx = keys.split(/\s+/), px = []; for (var i = 0; i < kx.length ; i++) { px.push(_.replace(_.rtoken(c[kx[i]]), kx[i])); } fn = _C[keys] = _.any.apply(null, px); } return fn; }; g.ctoken2 = function (key) { return _.rtoken(Date.CultureInfo.regexPatterns[key]); }; var cacheProcessRtoken = function (key, token, type, eachToken) { if (eachToken) { g[key] = _.cache(_.process(_.each(_.rtoken(token),_.optional(g.ctoken2(eachToken))), type)); } else { g[key] = _.cache(_.process(_.rtoken(token), type)); } }; var cacheProcessCtoken = function (token, type) { return _.cache(_.process(g.ctoken2(token), type)); }; var _F = {}; //function cache var _get = function (f) { _F[f] = (_F[f] || g.format(f)[0]); return _F[f]; }; g.allformats = function (fx) { var rx = []; if (fx instanceof Array) { for (var i = 0; i < fx.length; i++) { rx.push(_get(fx[i])); } } else { rx.push(_get(fx)); } return rx; }; g.formats = function (fx) { if (fx instanceof Array) { var rx = []; for (var i = 0 ; i < fx.length ; i++) { rx.push(_get(fx[i])); } return _.any.apply(null, rx); } else { return _get(fx); } }; var grammarFormats = { timeFormats: function(){ var i, RTokenKeys = [ "h", "hh", "H", "HH", "m", "mm", "s", "ss", "ss.s", "z", "zz" ], RToken = [ /^(0[0-9]|1[0-2]|[1-9])/, /^(0[0-9]|1[0-2])/, /^([0-1][0-9]|2[0-3]|[0-9])/, /^([0-1][0-9]|2[0-3])/, /^([0-5][0-9]|[0-9])/, /^[0-5][0-9]/, /^([0-5][0-9]|[0-9])/, /^[0-5][0-9]/, /^[0-5][0-9]\.[0-9]{1,3}/, /^((\+|\-)\s*\d\d\d\d)|((\+|\-)\d\d\:?\d\d)/, /^((\+|\-)\s*\d\d\d\d)|((\+|\-)\d\d\:?\d\d)/ ], tokens = [ t.hour, t.hour, t.hour, t.hour, t.minute, t.minute, t.second, t.second, t.secondAndMillisecond, t.timezone, t.timezone ]; for (i=0; i < RTokenKeys.length; i++) { cacheProcessRtoken(RTokenKeys[i], RToken[i], tokens[i]); } g.hms = _.cache(_.sequence([g.H, g.m, g.s], g.timePartDelimiter)); g.t = cacheProcessCtoken("shortMeridian", t.meridian); g.tt = cacheProcessCtoken("longMeridian", t.meridian); g.zzz = cacheProcessCtoken("timezone", t.timezone); g.timeSuffix = _.each(_.ignore(g.whiteSpace), _.set([ g.tt, g.zzz ])); g.time = _.each(_.optional(_.ignore(_.stoken("T"))), g.hms, g.timeSuffix); }, dateFormats: function () { // pre-loaded rules for different date part order preferences var _setfn = function () { return _.set(arguments, g.datePartDelimiter); }; var i, RTokenKeys = [ "d", "dd", "M", "MM", "y", "yy", "yyy", "yyyy" ], RToken = [ /^([0-2]\d|3[0-1]|\d)/, /^([0-2]\d|3[0-1])/, /^(1[0-2]|0\d|\d)/, /^(1[0-2]|0\d)/, /^(\d+)/, /^(\d\d)/, /^(\d\d?\d?\d?)/, /^(\d\d\d\d)/ ], tokens = [ t.day, t.day, t.month, t.month, t.year, t.year, t.year, t.year ], eachToken = [ "ordinalSuffix", "ordinalSuffix" ]; for (i=0; i < RTokenKeys.length; i++) { cacheProcessRtoken(RTokenKeys[i], RToken[i], tokens[i], eachToken[i]); } g.MMM = g.MMMM = _.cache(_.process(g.ctoken("jan feb mar apr may jun jul aug sep oct nov dec"), t.month)); g.ddd = g.dddd = _.cache(_.process(g.ctoken("sun mon tue wed thu fri sat"), function (s) { return function () { this.weekday = s; }; } )); g.day = _fn(g.d, g.dd); g.month = _fn(g.M, g.MMM); g.year = _fn(g.yyyy, g.yy); g.mdy = _setfn(g.ddd, g.month, g.day, g.year); g.ymd = _setfn(g.ddd, g.year, g.month, g.day); g.dmy = _setfn(g.ddd, g.day, g.month, g.year); g.date = function (s) { return ((g[Date.CultureInfo.dateElementOrder] || g.mdy).call(this, s)); }; }, relative: function () { // relative date / time expressions g.orientation = _.process(g.ctoken("past future"), function (s) { return function () { this.orient = s; }; } ); g.operator = _.process(g.ctoken("add subtract"), function (s) { return function () { this.operator = s; }; } ); g.rday = _.process(g.ctoken("yesterday tomorrow today now"), t.rday); g.unit = _.process(g.ctoken("second minute hour day week month year"), function (s) { return function () { this.unit = s; }; } ); } }; g.buildGrammarFormats = function () { // these need to be rebuilt every time the language changes. _C = {}; grammarFormats.timeFormats(); grammarFormats.dateFormats(); grammarFormats.relative(); g.value = _.process(_.rtoken(/^([-+]?\d+)?(st|nd|rd|th)?/), function (s) { return function () { this.value = s.replace(/\D/g, ""); }; } ); g.expression = _.set([g.rday, g.operator, g.value, g.unit, g.orientation, g.ddd, g.MMM ]); g.format = _.process(_.many( _.any( // translate format specifiers into grammar rules _.process( _.rtoken(/^(dd?d?d?(?!e)|MM?M?M?|yy?y?y?|hh?|HH?|mm?|ss?|tt?|zz?z?)/), function (fmt) { if (g[fmt]) { return g[fmt]; } else { throw $D.Parsing.Exception(fmt); } } ), // translate separator tokens into token rules _.process(_.rtoken(/^[^dMyhHmstz]+/), // all legal separators function (s) { return _.ignore(_.stoken(s)); } ) ) ), // construct the parser ... function (rules) { return _.process(_.each.apply(null, rules), t.finishExact); } ); // starting rule for general purpose grammar g._start = _.process(_.set([ g.date, g.time, g.expression ], g.generalDelimiter, g.whiteSpace), t.finish); }; g.buildGrammarFormats(); // parsing date format specifiers - ex: "h:m:s tt" // this little guy will generate a custom parser based // on the format string, ex: g.format("h:m:s tt") // check for these formats first g._formats = g.formats([ "\"yyyy-MM-ddTHH:mm:ssZ\"", "yyyy-MM-ddTHH:mm:ss.sz", "yyyy-MM-ddTHH:mm:ssZ", "yyyy-MM-ddTHH:mm:ssz", "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-ddTHH:mmZ", "yyyy-MM-ddTHH:mmz", "yyyy-MM-ddTHH:mm", "ddd, MMM dd, yyyy H:mm:ss tt", "ddd MMM d yyyy HH:mm:ss zzz", "MMddyyyy", "ddMMyyyy", "Mddyyyy", "ddMyyyy", "Mdyyyy", "dMyyyy", "yyyy", "Mdyy", "dMyy", "d" ]); // real starting rule: tries selected formats first, // then general purpose rule g.start = function (s) { try { var r = g._formats.call({}, s); if (r[1].length === 0) { return r; } } catch (e) {} return g._start.call({}, s); }; }()); (function () { var $D = Date; /** * @desc Converts the specified string value into its JavaScript Date equivalent using CultureInfo specific format information. * * Example

	///////////
	// Dates //
	///////////

	// 15-Oct-2004
	var d1 = Date.parse("10/15/2004");

	// 15-Oct-2004
	var d1 = Date.parse("15-Oct-2004");

	// 15-Oct-2004
	var d1 = Date.parse("2004.10.15");

	//Fri Oct 15, 2004
	var d1 = Date.parse("Fri Oct 15, 2004");

	///////////
	// Times //
	///////////

	// Today at 10 PM.
	var d1 = Date.parse("10 PM");

	// Today at 10:30 PM.
	var d1 = Date.parse("10:30 P.M.");

	// Today at 6 AM.
	var d1 = Date.parse("06am");

	/////////////////////
	// Dates and Times //
	/////////////////////

	// 8-July-2004 @ 10:30 PM
	var d1 = Date.parse("July 8th, 2004, 10:30 PM");

	// 1-July-2004 @ 10:30 PM
	var d1 = Date.parse("2004-07-01T22:30:00");

	////////////////////
	// Relative Dates //
	////////////////////

	// Returns today's date. The string "today" is culture specific.
	var d1 = Date.parse("today");

	// Returns yesterday's date. The string "yesterday" is culture specific.
	var d1 = Date.parse("yesterday");

	// Returns the date of the next thursday.
	var d1 = Date.parse("Next thursday");

	// Returns the date of the most previous monday.
	var d1 = Date.parse("last monday");

	// Returns today's day + one year.
	var d1 = Date.parse("next year");

	///////////////
	// Date Math //
	///////////////

	// Today + 2 days
	var d1 = Date.parse("t+2");

	// Today + 2 days
	var d1 = Date.parse("today + 2 days");

	// Today + 3 months
	var d1 = Date.parse("t+3m");

	// Today - 1 year
	var d1 = Date.parse("today - 1 year");

	// Today - 1 year
	var d1 = Date.parse("t-1y"); 


	/////////////////////////////
	// Partial Dates and Times //
	/////////////////////////////

	// July 15th of this year.
	var d1 = Date.parse("July 15");

	// 15th day of current day and year.
	var d1 = Date.parse("15");

	// July 1st of current year at 10pm.
	var d1 = Date.parse("7/1 10pm");
	
* * @param {String} The string value to convert into a Date object [Required] * @return {Date} A Date object or null if the string cannot be converted into a Date. */ var parseUtils = { removeOrds: function (s) { ords = s.match(/\b(\d+)(?:st|nd|rd|th)\b/); // find ordinal matches s = ((ords && ords.length === 2) ? s.replace(ords[0], ords[1]) : s); return s; }, grammarParser: function (s) { var r = null; try { r = $D.Grammar.start.call({}, s.replace(/^\s*(\S*(\s+\S+)*)\s*$/, "$1")); } catch (e) { return null; } return ((r[1].length === 0) ? r[0] : null); }, nativeFallback: function(s) { var t; try { // ok we haven't parsed it, last ditch attempt with the built-in parser. t = Date._parse(s); return (t || t === 0) ? new Date(t) : null; } catch (e) { return null; } } }; function parse (s) { var d; if (!s) { return null; } if (s instanceof Date) { return s.clone(); } if (s.length >= 4 && s.charAt(0) !== "0" && s.charAt(0) !== "+"&& s.charAt(0) !== "-") { // ie: 2004 will pass, 0800 won't. // Start with specific formats d = $D.Parsing.ISO.parse(s) || $D.Parsing.Numeric.parse(s); } if (d instanceof Date && !isNaN(d.getTime())) { return d; } else { // find ordinal dates (1st, 3rd, 8th, etc and remove them as they cause parsing issues) s = $D.Parsing.Normalizer.parse(parseUtils.removeOrds(s)); d = parseUtils.grammarParser(s); if (d !== null) { return d; } else { return parseUtils.nativeFallback(s); } } } if (!$D._parse) { $D._parse = $D.parse; } $D.parse = parse; Date.getParseFunction = function (fx) { var fns = Date.Grammar.allformats(fx); return function (s) { var r = null; for (var i = 0; i < fns.length; i++) { try { r = fns[i].call({}, s); } catch (e) { continue; } if (r[1].length === 0) { return r[0]; } } return null; }; }; /** * Converts the specified string value into its JavaScript Date equivalent using the specified format {String} or formats {Array} and the CultureInfo specific format information. * The format of the string value must match one of the supplied formats exactly. * * Example

	// 15-Oct-2004
	var d1 = Date.parseExact("10/15/2004", "M/d/yyyy");

	// 15-Oct-2004
	var d1 = Date.parse("15-Oct-2004", "M-ddd-yyyy");

	// 15-Oct-2004
	var d1 = Date.parse("2004.10.15", "yyyy.MM.dd");

	// Multiple formats
	var d1 = Date.parseExact("10/15/2004", ["M/d/yyyy", "MMMM d, yyyy"]);
	
* * @param {String} The string value to convert into a Date object [Required]. * @param {Object} The expected format {String} or an array of expected formats {Array} of the date string [Required]. * @return {Date} A Date object or null if the string cannot be converted into a Date. */ $D.parseExact = function (s, fx) { return $D.getParseFunction(fx)(s); }; }()); (function () { var $D = Date, $P = $D.prototype, // $C = $D.CultureInfo, // not used atm p = function (s, l) { if (!l) { l = 2; } return ("000" + s).slice(l * -1); }; /** * Converts a PHP format string to Java/.NET format string. * A PHP format string can be used with ._format or .format. * A Java/.NET format string can be used with .toString(). * The .parseExact function will only accept a Java/.NET format string * * Example * var f1 = "%m/%d/%y" * var f2 = Date.normalizeFormat(f1); // "MM/dd/yy" * * new Date().format(f1); // "04/13/08" * new Date()._format(f1); // "04/13/08" * new Date().toString(f2); // "04/13/08" * * var date = Date.parseExact("04/13/08", f2); // Sun Apr 13 2008 * * @param {String} A PHP format string consisting of one or more format spcifiers. * @return {String} The PHP format converted to a Java/.NET format string. */ var normalizerSubstitutions = { "d" : "dd", "%d": "dd", "D" : "ddd", "%a": "ddd", "j" : "dddd", "l" : "dddd", "%A": "dddd", "S" : "S", "F" : "MMMM", "%B": "MMMM", "m" : "MM", "%m": "MM", "M" : "MMM", "%b": "MMM", "%h": "MMM", "n" : "M", "Y" : "yyyy", "%Y": "yyyy", "y" : "yy", "%y": "yy", "g" : "h", "%I": "h", "G" : "H", "h" : "hh", "H" : "HH", "%H": "HH", "i" : "mm", "%M": "mm", "s" : "ss", "%S": "ss", "%r": "hh:mm tt", "%R": "H:mm", "%T": "H:mm:ss", "%X": "t", "%x": "d", "%e": "d", "%D": "MM/dd/yy", "%n": "\\n", "%t": "\\t", "e" : "z", "T" : "z", "%z": "z", "%Z": "z", "Z" : "ZZ", "N" : "u", "w" : "u", "%w": "u", "W" : "W", "%V": "W" }; var normalizer = { substitutes: function (m) { return normalizerSubstitutions[m]; }, interpreted: function (m, x) { var y; switch (m) { case "%u": return x.getDay() + 1; case "z": return x.getOrdinalNumber(); case "%j": return p(x.getOrdinalNumber(), 3); case "%U": var d1 = x.clone().set({month: 0, day: 1}).addDays(-1).moveToDayOfWeek(0), d2 = x.clone().addDays(1).moveToDayOfWeek(0, -1); return (d2 < d1) ? "00" : p((d2.getOrdinalNumber() - d1.getOrdinalNumber()) / 7 + 1); case "%W": return p(x.getWeek()); case "t": return $D.getDaysInMonth(x.getFullYear(), x.getMonth()); case "o": case "%G": return x.setWeek(x.getISOWeek()).toString("yyyy"); case "%g": return x._format("%G").slice(-2); case "a": case "%p": return t("tt").toLowerCase(); case "A": return t("tt").toUpperCase(); case "u": return p(x.getMilliseconds(), 3); case "I": return (x.isDaylightSavingTime()) ? 1 : 0; case "O": return x.getUTCOffset(); case "P": y = x.getUTCOffset(); return y.substring(0, y.length - 2) + ":" + y.substring(y.length - 2); case "B": var now = new Date(); return Math.floor(((now.getHours() * 3600) + (now.getMinutes() * 60) + now.getSeconds() + (now.getTimezoneOffset() + 60) * 60) / 86.4); case "c": return x.toISOString().replace(/\"/g, ""); case "U": return $D.strtotime("now"); case "%c": return t("d") + " " + t("t"); case "%C": return Math.floor(x.getFullYear() / 100 + 1); } }, shouldOverrideDefaults: function (m) { switch (m) { case "%e": return true; default: return false; } }, parse: function (m, context) { var formatString, c = context || new Date(); formatString = normalizer.substitutes(m); if (formatString) { return formatString; } formatString = normalizer.interpreted(m, c); if (formatString) { return formatString; } else { return m; } } }; $D.normalizeFormat = function (format, context) { return format.replace(/(%|\\)?.|%%/g, function(t){ return normalizer.parse(t, context); }); }; /** * Format a local Unix timestamp according to locale settings * * Example: * Date.strftime("%m/%d/%y", new Date()); // "04/13/08" * Date.strftime("c", "2008-04-13T17:52:03Z"); // "04/13/08" * * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @param {Number|String} The number representing the number of seconds that have elapsed since January 1, 1970 (local time). * @return {String} A string representation of the current Date object. */ $D.strftime = function (format, time) { var d = Date.parse(time); return d._format(format); }; /** * Parse any textual datetime description into a Unix timestamp. * A Unix timestamp is the number of seconds that have elapsed since January 1, 1970 (midnight UTC/GMT). * * Example: * Date.strtotime("04/13/08"); // 1208044800 * Date.strtotime("1970-01-01T00:00:00Z"); // 0 * * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @param {Object} A string or date object. * @return {String} A string representation of the current Date object. */ $D.strtotime = function (time) { var d = $D.parse(time); return Math.round($D.UTC(d.getUTCFullYear(), d.getUTCMonth(), d.getUTCDate(), d.getUTCHours(), d.getUTCMinutes(), d.getUTCSeconds(), d.getUTCMilliseconds()) / 1000); }; /** * Converts the value of the current Date object to its equivalent string representation using a PHP/Unix style of date format specifiers. * Format Specifiers * Format Description Example * ------ --------------------------------------------------------------------------- ----------------------- * %a abbreviated weekday name according to the current localed "Mon" through "Sun" * %A full weekday name according to the current localed "Sunday" through "Saturday" * %b abbreviated month name according to the current localed "Jan" through "Dec" * %B full month name according to the current locale "January" through "December" * %c preferred date and time representation for the current locale "4/13/2008 12:33 PM" * %C century number (the year divided by 100 and truncated to an integer) "00" to "99" * %d day of the month as a decimal number "01" to "31" * %D same as %m/%d/%y "04/13/08" * %e day of the month as a decimal number, a single digit is preceded by a space "1" to "31" * %g like %G, but without the century "08" * %G The 4-digit year corresponding to the ISO week number (see %V). "2008" * This has the same format and value as %Y, except that if the ISO week number * belongs to the previous or next year, that year is used instead. * %h same as %b "Jan" through "Dec" * %H hour as a decimal number using a 24-hour clock. "00" to "23" * %I hour as a decimal number using a 12-hour clock. "01" to "12" * %j day of the year as a decimal number. "001" to "366" * %m month as a decimal number. "01" to "12" * %M minute as a decimal number. "00" to "59" * %n newline character "\n" * %p either "am" or "pm" according to the given time value, or the "am" or "pm" * corresponding strings for the current locale. * %r time in a.m. and p.m. notation "8:44 PM" * %R time in 24 hour notation "20:44" * %S second as a decimal number "00" to "59" * %t tab character "\t" * %T current time, equal to %H:%M:%S "12:49:11" * %u weekday as a decimal number ["1", "7"], with "1" representing Monday "1" to "7" * %U week number of the current year as a decimal number, starting with the "0" to ("52" or "53") * first Sunday as the first day of the first week * %V The ISO 8601:1988 week number of the current year as a decimal number, "00" to ("52" or "53") * range 01 to 53, where week 1 is the first week that has at least 4 days * in the current year, and with Monday as the first day of the week. * (Use %G or %g for the year component that corresponds to the week number * for the specified timestamp.) * %W week number of the current year as a decimal number, starting with the "00" to ("52" or "53") * first Monday as the first day of the first week * %w day of the week as a decimal, Sunday being "0" "0" to "6" * %x preferred date representation for the current locale without the time "4/13/2008" * %X preferred time representation for the current locale without the date "12:53:05" * %y year as a decimal number without a century "00" "99" * %Y year as a decimal number including the century "2008" * %Z time zone or name or abbreviation "UTC", "EST", "PST" * %z same as %Z * %% a literal "%" characters "%" * d Day of the month, 2 digits with leading zeros "01" to "31" * D A textual representation of a day, three letters "Mon" through "Sun" * j Day of the month without leading zeros "1" to "31" * l A full textual representation of the day of the week (lowercase "L") "Sunday" through "Saturday" * N ISO-8601 numeric representation of the day of the week (added in PHP 5.1.0) "1" (for Monday) through "7" (for Sunday) * S English ordinal suffix for the day of the month, 2 characters "st", "nd", "rd" or "th". Works well with j * w Numeric representation of the day of the week "0" (for Sunday) through "6" (for Saturday) * z The day of the year (starting from "0") "0" through "365" * W ISO-8601 week number of year, weeks starting on Monday "00" to ("52" or "53") * F A full textual representation of a month, such as January or March "January" through "December" * m Numeric representation of a month, with leading zeros "01" through "12" * M A short textual representation of a month, three letters "Jan" through "Dec" * n Numeric representation of a month, without leading zeros "1" through "12" * t Number of days in the given month "28" through "31" * L Whether it's a leap year "1" if it is a leap year, "0" otherwise * o ISO-8601 year number. This has the same value as Y, except that if the "2008" * ISO week number (W) belongs to the previous or next year, that year * is used instead. * Y A full numeric representation of a year, 4 digits "2008" * y A two digit representation of a year "08" * a Lowercase Ante meridiem and Post meridiem "am" or "pm" * A Uppercase Ante meridiem and Post meridiem "AM" or "PM" * B Swatch Internet time "000" through "999" * g 12-hour format of an hour without leading zeros "1" through "12" * G 24-hour format of an hour without leading zeros "0" through "23" * h 12-hour format of an hour with leading zeros "01" through "12" * H 24-hour format of an hour with leading zeros "00" through "23" * i Minutes with leading zeros "00" to "59" * s Seconds, with leading zeros "00" through "59" * u Milliseconds "54321" * e Timezone identifier "UTC", "EST", "PST" * I Whether or not the date is in daylight saving time (uppercase i) "1" if Daylight Saving Time, "0" otherwise * O Difference to Greenwich time (GMT) in hours "+0200", "-0600" * P Difference to Greenwich time (GMT) with colon between hours and minutes "+02:00", "-06:00" * T Timezone abbreviation "UTC", "EST", "PST" * Z Timezone offset in seconds. The offset for timezones west of UTC is "-43200" through "50400" * always negative, and for those east of UTC is always positive. * c ISO 8601 date "2004-02-12T15:19:21+00:00" * r RFC 2822 formatted date "Thu, 21 Dec 2000 16:01:07 +0200" * U Seconds since the Unix Epoch (January 1 1970 00:00:00 GMT) "0" * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @return {String} A string representation of the current Date object. */ var formatReplace = function (context) { return function (m) { var formatString, override = false; if (m.charAt(0) === "\\" || m.substring(0, 2) === "%%") { return m.replace("\\", "").replace("%%", "%"); } override = normalizer.shouldOverrideDefaults(m); formatString = $D.normalizeFormat(m, context); if (formatString) { return context.toString(formatString, override); } }; }; $P._format = function (format) { var formatter = formatReplace(this); if (!format) { return this._toString(); } else { return format.replace(/(%|\\)?.|%%/g, formatter); } }; if (!$P.format) { $P.format = $P._format; } }()); (function () { "use strict"; var gFn = function (attr) { return function () { return this[attr]; }; }; var sFn = function (attr) { return function (val) { this[attr] = val; return this; }; }; var attrs = ["years", "months", "days", "hours", "minutes", "seconds", "milliseconds"]; var addSetFuncs = function (context, attrs) { for (var i = 0; i < attrs.length ; i++) { var $a = attrs[i], $b = $a.slice(0, 1).toUpperCase() + $a.slice(1); context.prototype[$a] = 0; context.prototype["get" + $b] = gFn($a); context.prototype["set" + $b] = sFn($a); } }; /** * new TimeSpan(milliseconds); * new TimeSpan(days, hours, minutes, seconds); * new TimeSpan(days, hours, minutes, seconds, milliseconds); */ var TimeSpan = function (days, hours, minutes, seconds, milliseconds) { if (arguments.length === 1 && typeof days === "number") { var orient = (days < 0) ? -1 : +1; var millsLeft = Math.abs(days); this.setDays(Math.floor(millsLeft / 86400000) * orient); millsLeft = millsLeft % 86400000; this.setHours(Math.floor(millsLeft / 3600000) * orient); millsLeft = millsLeft % 3600000; this.setMinutes(Math.floor(millsLeft / 60000) * orient); millsLeft = millsLeft % 60000; this.setSeconds(Math.floor(millsLeft / 1000) * orient); millsLeft = millsLeft % 1000; this.setMilliseconds(millsLeft * orient); } else { this.set(days, hours, minutes, seconds, milliseconds); } this.getTotalMilliseconds = function () { return (this.getDays() * 86400000) + (this.getHours() * 3600000) + (this.getMinutes() * 60000) + (this.getSeconds() * 1000); }; this.compareTo = function (time) { var t1 = new Date(1970, 1, 1, this.getHours(), this.getMinutes(), this.getSeconds()), t2; if (time === null) { t2 = new Date(1970, 1, 1, 0, 0, 0); } else { t2 = new Date(1970, 1, 1, time.getHours(), time.getMinutes(), time.getSeconds()); } return (t1 < t2) ? -1 : (t1 > t2) ? 1 : 0; }; this.equals = function (time) { return (this.compareTo(time) === 0); }; this.add = function (time) { return (time === null) ? this : this.addSeconds(time.getTotalMilliseconds() / 1000); }; this.subtract = function (time) { return (time === null) ? this : this.addSeconds(-time.getTotalMilliseconds() / 1000); }; this.addDays = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 86400000)); }; this.addHours = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 3600000)); }; this.addMinutes = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 60000)); }; this.addSeconds = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 1000)); }; this.addMilliseconds = function (n) { return new TimeSpan(this.getTotalMilliseconds() + n); }; this.get12HourHour = function () { return (this.getHours() > 12) ? this.getHours() - 12 : (this.getHours() === 0) ? 12 : this.getHours(); }; this.getDesignator = function () { return (this.getHours() < 12) ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator; }; this.toString = function (format) { this._toString = function () { if (this.getDays() !== null && this.getDays() > 0) { return this.getDays() + "." + this.getHours() + ":" + this.p(this.getMinutes()) + ":" + this.p(this.getSeconds()); } else { return this.getHours() + ":" + this.p(this.getMinutes()) + ":" + this.p(this.getSeconds()); } }; this.p = function (s) { return (s.toString().length < 2) ? "0" + s : s; }; var me = this; return format ? format.replace(/dd?|HH?|hh?|mm?|ss?|tt?/g, function (format) { switch (format) { case "d": return me.getDays(); case "dd": return me.p(me.getDays()); case "H": return me.getHours(); case "HH": return me.p(me.getHours()); case "h": return me.get12HourHour(); case "hh": return me.p(me.get12HourHour()); case "m": return me.getMinutes(); case "mm": return me.p(me.getMinutes()); case "s": return me.getSeconds(); case "ss": return me.p(me.getSeconds()); case "t": return ((me.getHours() < 12) ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator).substring(0, 1); case "tt": return (me.getHours() < 12) ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator; } } ) : this._toString(); }; return this; }; addSetFuncs(TimeSpan, attrs.slice(2)); TimeSpan.prototype.set = function (days, hours, minutes, seconds, milliseconds){ this.setDays(days || this.getDays()); this.setHours(hours || this.getHours()); this.setMinutes(minutes || this.getMinutes()); this.setSeconds(seconds || this.getSeconds()); this.setMilliseconds(milliseconds || this.getMilliseconds()); }; /** * Gets the time of day for this date instances. * @return {TimeSpan} TimeSpan */ Date.prototype.getTimeOfDay = function () { return new TimeSpan(0, this.getHours(), this.getMinutes(), this.getSeconds(), this.getMilliseconds()); }; Date.TimeSpan = TimeSpan; if (typeof window !== "undefined" ) { // keeping API compatible for v1.x window.TimeSpan = TimeSpan; } }()); (function () { "use strict"; var attrs = ["years", "months", "days", "hours", "minutes", "seconds", "milliseconds"]; var gFn = function (attr) { return function () { return this[attr]; }; }; var sFn = function (attr) { return function (val) { this[attr] = val; return this; }; }; var addSetFuncs = function (context, attrs) { for (var i = 0; i < attrs.length ; i++) { var $a = attrs[i], $b = $a.slice(0, 1).toUpperCase() + $a.slice(1); context.prototype[$a] = 0; context.prototype["get" + $b] = gFn($a); context.prototype["set" + $b] = sFn($a); } }; var setMonthsAndYears = function (orient, d1, d2, context) { function inc() { d1.addMonths(-orient); context.months++; if (context.months === 12) { context.years++; context.months = 0; } } if (orient === +1) { while (d1 > d2) { inc(); } } else { while (d1 < d2) { inc(); } } context.months--; context.months *= orient; context.years *= orient; }; var adjustForDST = function(orient, startDate, endDate) { var hasDSTMismatch = (false === (startDate.isDaylightSavingTime() === endDate.isDaylightSavingTime())); if (hasDSTMismatch && orient === 1) { startDate.addHours(-1); } else if (hasDSTMismatch) { startDate.addHours(1); } }; /** * TimePeriod(startDate, endDate); * TimePeriod(years, months, days, hours, minutes, seconds, milliseconds); */ var TimePeriod = function (years, months, days, hours, minutes, seconds, milliseconds) { if (arguments.length === 7) { this.set(years, months, days, hours, minutes, seconds, milliseconds); } else if (arguments.length === 2 && arguments[0] instanceof Date && arguments[1] instanceof Date) { var startDate = arguments[0].clone(); var endDate = arguments[1].clone(); var orient = (startDate > endDate) ? +1 : -1; this.dates = { start: arguments[0].clone(), end: arguments[1].clone() }; setMonthsAndYears(orient, startDate, endDate, this); adjustForDST(orient, startDate, endDate); // // TODO - adjust for DST var diff = endDate - startDate; if (diff !== 0) { var ts = new TimeSpan(diff); this.set(this.years, this.months, ts.getDays(), ts.getHours(), ts.getMinutes(), ts.getSeconds(), ts.getMilliseconds()); } } return this; }; // create all the set functions. addSetFuncs(TimePeriod, attrs); TimePeriod.prototype.set = function (years, months, days, hours, minutes, seconds, milliseconds){ this.setYears(years || this.getYears()); this.setMonths(months || this.getMonths()); this.setDays(days || this.getDays()); this.setHours(hours || this.getHours()); this.setMinutes(minutes || this.getMinutes()); this.setSeconds(seconds || this.getSeconds()); this.setMilliseconds(milliseconds || this.getMilliseconds()); }; Date.TimePeriod = TimePeriod; if (typeof window !== "undefined") { // keeping API compatible for v1.x window.TimePeriod = TimePeriod; } }()); ================================================ FILE: build/date-zh-MO.js ================================================ /** * @overview datejs * @version 1.0.0-rc3 * @author Gregory Wild-Smith * @copyright 2015 Gregory Wild-Smith * @license MIT * @homepage https://github.com/abritinthebay/datejs */ /* * DateJS Culture String File * Country Code: zh-MO * Name: Chinese (Macao S.A.R.) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["zh-MO"] = { "name": "zh-MO", "englishName": "Chinese (Macao S.A.R.)", "nativeName": "中文(澳門特别行政區)", "Sunday": "星期日", "Monday": "星期一", "Tuesday": "星期二", "Wednesday": "星期三", "Thursday": "星期四", "Friday": "星期五", "Saturday": "星期六", "Sun": "星期日", "Mon": "星期一", "Tue": "星期二", "Wed": "星期三", "Thu": "星期四", "Fri": "星期五", "Sat": "星期六", "Su": "日", "Mo": "一", "Tu": "二", "We": "三", "Th": "四", "Fr": "五", "Sa": "六", "S_Sun_Initial": "日", "M_Mon_Initial": "一", "T_Tue_Initial": "二", "W_Wed_Initial": "三", "T_Thu_Initial": "四", "F_Fri_Initial": "五", "S_Sat_Initial": "六", "January": "一月", "February": "二月", "March": "三月", "April": "四月", "May": "五月", "June": "六月", "July": "七月", "August": "八月", "September": "九月", "October": "十月", "November": "十一月", "December": "十二月", "Jan_Abbr": "一月", "Feb_Abbr": "二月", "Mar_Abbr": "三月", "Apr_Abbr": "四月", "May_Abbr": "五月", "Jun_Abbr": "六月", "Jul_Abbr": "七月", "Aug_Abbr": "八月", "Sep_Abbr": "九月", "Oct_Abbr": "十月", "Nov_Abbr": "十一月", "Dec_Abbr": "十二月", "AM": "", "PM": "", "firstDayOfWeek": 0, "twoDigitYearMax": 2029, "mdy": "dmy", "M/d/yyyy": "d/M/yyyy", "dddd, MMMM dd, yyyy": "dddd, d MMMM, yyyy", "h:mm tt": "H:mm", "h:mm:ss tt": "H:mm:ss", "dddd, MMMM dd, yyyy h:mm:ss tt": "dddd, d MMMM, yyyy H:mm:ss", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "d MMMM", "MMMM, yyyy": "MMMM, yyyy", "/jan(uary)?/": "一月", "/feb(ruary)?/": "二月", "/mar(ch)?/": "三月", "/apr(il)?/": "四月", "/may/": "五月", "/jun(e)?/": "六月", "/jul(y)?/": "七月", "/aug(ust)?/": "八月", "/sep(t(ember)?)?/": "九月", "/oct(ober)?/": "十月", "/nov(ember)?/": "十一月", "/dec(ember)?/": "十二月", "/^su(n(day)?)?/": "^星期日", "/^mo(n(day)?)?/": "^星期一", "/^tu(e(s(day)?)?)?/": "^星期二", "/^we(d(nesday)?)?/": "^星期三", "/^th(u(r(s(day)?)?)?)?/": "^星期四", "/^fr(i(day)?)?/": "^星期五", "/^sa(t(urday)?)?/": "^星期六", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "zh-MO"; /** * @overview datejs * @version 1.0.0-rc3 * @author Gregory Wild-Smith * @copyright 2015 Gregory Wild-Smith * @license MIT * @homepage https://github.com/abritinthebay/datejs */(function () { var $D = Date; var lang = Date.CultureStrings ? Date.CultureStrings.lang : null; var loggedKeys = {}; // for debug purposes. var getText = { getFromKey: function (key, countryCode) { var output; if (Date.CultureStrings && Date.CultureStrings[countryCode] && Date.CultureStrings[countryCode][key]) { output = Date.CultureStrings[countryCode][key]; } else { output = getText.buildFromDefault(key); } if (key.charAt(0) === "/") { // Assume it's a regex output = getText.buildFromRegex(key, countryCode); } return output; }, getFromObjectValues: function (obj, countryCode) { var key, output = {}; for(key in obj) { if (obj.hasOwnProperty(key)) { output[key] = getText.getFromKey(obj[key], countryCode); } } return output; }, getFromObjectKeys: function (obj, countryCode) { var key, output = {}; for(key in obj) { if (obj.hasOwnProperty(key)) { output[getText.getFromKey(key, countryCode)] = obj[key]; } } return output; }, getFromArray: function (arr, countryCode) { var output = []; for (var i=0; i < arr.length; i++){ if (i in arr) { output[i] = getText.getFromKey(arr[i], countryCode); } } return output; }, buildFromDefault: function (key) { var output, length, split, last; switch(key) { case "name": output = "en-US"; break; case "englishName": output = "English (United States)"; break; case "nativeName": output = "English (United States)"; break; case "twoDigitYearMax": output = 2049; break; case "firstDayOfWeek": output = 0; break; default: output = key; split = key.split("_"); length = split.length; if (length > 1 && key.charAt(0) !== "/") { // if the key isn't a regex and it has a split. last = split[(length - 1)].toLowerCase(); if (last === "initial" || last === "abbr") { output = split[0]; } } break; } return output; }, buildFromRegex: function (key, countryCode) { var output; if (Date.CultureStrings && Date.CultureStrings[countryCode] && Date.CultureStrings[countryCode][key]) { output = new RegExp(Date.CultureStrings[countryCode][key], "i"); } else { output = new RegExp(key.replace(new RegExp("/", "g"),""), "i"); } return output; } }; var shallowMerge = function (obj1, obj2) { for (var attrname in obj2) { if (obj2.hasOwnProperty(attrname)) { obj1[attrname] = obj2[attrname]; } } }; var __ = function (key, language) { var countryCode = (language) ? language : lang; loggedKeys[key] = key; if (typeof key === "object") { if (key instanceof Array) { return getText.getFromArray(key, countryCode); } else { return getText.getFromObjectKeys(key, countryCode); } } else { return getText.getFromKey(key, countryCode); } }; var loadI18nScript = function (code) { // paatterned after jQuery's getScript. var url = Date.Config.i18n + code + ".js"; var head = document.getElementsByTagName("head")[0] || document.documentElement; var script = document.createElement("script"); script.src = url; var completed = false; var events = { done: function (){} // placeholder function }; // Attach handlers for all browsers script.onload = script.onreadystatechange = function() { if ( !completed && (!this.readyState || this.readyState === "loaded" || this.readyState === "complete") ) { events.done(); head.removeChild(script); } }; setTimeout(function() { head.insertBefore(script, head.firstChild); }, 0); // allows return to execute first return { done: function (cb) { events.done = function() { if (cb) { setTimeout(cb,0); } }; } }; }; var buildInfo = { buildFromMethodHash: function (obj) { var key; for(key in obj) { if (obj.hasOwnProperty(key)) { obj[key] = buildInfo[obj[key]](); } } return obj; }, timeZoneDST: function () { var DST = { "CHADT": "+1345", "NZDT": "+1300", "AEDT": "+1100", "ACDT": "+1030", "AZST": "+0500", "IRDT": "+0430", "EEST": "+0300", "CEST": "+0200", "BST": "+0100", "PMDT": "-0200", "ADT": "-0300", "NDT": "-0230", "EDT": "-0400", "CDT": "-0500", "MDT": "-0600", "PDT": "-0700", "AKDT": "-0800", "HADT": "-0900" }; return __(DST); }, timeZoneStandard: function () { var standard = { "LINT": "+1400", "TOT": "+1300", "CHAST": "+1245", "NZST": "+1200", "NFT": "+1130", "SBT": "+1100", "AEST": "+1000", "ACST": "+0930", "JST": "+0900", "CWST": "+0845", "CT": "+0800", "ICT": "+0700", "MMT": "+0630", "BST": "+0600", "NPT": "+0545", "IST": "+0530", "PKT": "+0500", "AFT": "+0430", "MSK": "+0400", "IRST": "+0330", "FET": "+0300", "EET": "+0200", "CET": "+0100", "GMT": "+0000", "UTC": "+0000", "CVT": "-0100", "GST": "-0200", "BRT": "-0300", "NST": "-0330", "AST": "-0400", "EST": "-0500", "CST": "-0600", "MST": "-0700", "PST": "-0800", "AKST": "-0900", "MIT": "-0930", "HST": "-1000", "SST": "-1100", "BIT": "-1200" }; return __(standard); }, timeZones: function (data) { var zone; data.timezones = []; for (zone in data.abbreviatedTimeZoneStandard) { if (data.abbreviatedTimeZoneStandard.hasOwnProperty(zone)) { data.timezones.push({ name: zone, offset: data.abbreviatedTimeZoneStandard[zone]}); } } for (zone in data.abbreviatedTimeZoneDST) { if (data.abbreviatedTimeZoneDST.hasOwnProperty(zone)) { data.timezones.push({ name: zone, offset: data.abbreviatedTimeZoneDST[zone], dst: true}); } } return data.timezones; }, days: function () { return __(["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"]); }, dayAbbr: function () { return __(["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"]); }, dayShortNames: function () { return __(["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"]); }, dayFirstLetters: function () { return __(["S_Sun_Initial", "M_Mon_Initial", "T_Tues_Initial", "W_Wed_Initial", "T_Thu_Initial", "F_Fri_Initial", "S_Sat_Initial"]); }, months: function () { return __(["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"]); }, monthAbbr: function () { return __(["Jan_Abbr", "Feb_Abbr", "Mar_Abbr", "Apr_Abbr", "May_Abbr", "Jun_Abbr", "Jul_Abbr", "Aug_Abbr", "Sep_Abbr", "Oct_Abbr", "Nov_Abbr", "Dec_Abbr"]); }, formatPatterns: function () { return getText.getFromObjectValues({ shortDate: "M/d/yyyy", longDate: "dddd, MMMM dd, yyyy", shortTime: "h:mm tt", longTime: "h:mm:ss tt", fullDateTime: "dddd, MMMM dd, yyyy h:mm:ss tt", sortableDateTime: "yyyy-MM-ddTHH:mm:ss", universalSortableDateTime: "yyyy-MM-dd HH:mm:ssZ", rfc1123: "ddd, dd MMM yyyy HH:mm:ss", monthDay: "MMMM dd", yearMonth: "MMMM, yyyy" }, Date.i18n.currentLanguage()); }, regex: function () { return getText.getFromObjectValues({ inTheMorning: "/( in the )(morn(ing)?)\\b/", thisMorning: "/(this )(morn(ing)?)\\b/", amThisMorning: "/(\b\\d(am)? )(this )(morn(ing)?)/", inTheEvening: "/( in the )(even(ing)?)\\b/", thisEvening: "/(this )(even(ing)?)\\b/", pmThisEvening: "/(\b\\d(pm)? )(this )(even(ing)?)/", jan: "/jan(uary)?/", feb: "/feb(ruary)?/", mar: "/mar(ch)?/", apr: "/apr(il)?/", may: "/may/", jun: "/jun(e)?/", jul: "/jul(y)?/", aug: "/aug(ust)?/", sep: "/sep(t(ember)?)?/", oct: "/oct(ober)?/", nov: "/nov(ember)?/", dec: "/dec(ember)?/", sun: "/^su(n(day)?)?/", mon: "/^mo(n(day)?)?/", tue: "/^tu(e(s(day)?)?)?/", wed: "/^we(d(nesday)?)?/", thu: "/^th(u(r(s(day)?)?)?)?/", fri: "/fr(i(day)?)?/", sat: "/^sa(t(urday)?)?/", future: "/^next/", past: "/^last|past|prev(ious)?/", add: "/^(\\+|aft(er)?|from|hence)/", subtract: "/^(\\-|bef(ore)?|ago)/", yesterday: "/^yes(terday)?/", today: "/^t(od(ay)?)?/", tomorrow: "/^tom(orrow)?/", now: "/^n(ow)?/", millisecond: "/^ms|milli(second)?s?/", second: "/^sec(ond)?s?/", minute: "/^mn|min(ute)?s?/", hour: "/^h(our)?s?/", week: "/^w(eek)?s?/", month: "/^m(onth)?s?/", day: "/^d(ay)?s?/", year: "/^y(ear)?s?/", shortMeridian: "/^(a|p)/", longMeridian: "/^(a\\.?m?\\.?|p\\.?m?\\.?)/", timezone: "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/", ordinalSuffix: "/^\\s*(st|nd|rd|th)/", timeContext: "/^\\s*(\\:|a(?!u|p)|p)/" }, Date.i18n.currentLanguage()); } }; var CultureInfo = function () { var info = getText.getFromObjectValues({ name: "name", englishName: "englishName", nativeName: "nativeName", amDesignator: "AM", pmDesignator: "PM", firstDayOfWeek: "firstDayOfWeek", twoDigitYearMax: "twoDigitYearMax", dateElementOrder: "mdy" }, Date.i18n.currentLanguage()); var constructedInfo = buildInfo.buildFromMethodHash({ dayNames: "days", abbreviatedDayNames: "dayAbbr", shortestDayNames: "dayShortNames", firstLetterDayNames: "dayFirstLetters", monthNames: "months", abbreviatedMonthNames: "monthAbbr", formatPatterns: "formatPatterns", regexPatterns: "regex", abbreviatedTimeZoneDST: "timeZoneDST", abbreviatedTimeZoneStandard: "timeZoneStandard" }); shallowMerge(info, constructedInfo); buildInfo.timeZones(info); return info; }; $D.i18n = { __: function (key, lang) { return __(key, lang); }, currentLanguage: function () { return lang || "en-US"; }, setLanguage: function (code, force, cb) { var async = false; if (force || code === "en-US" || (!!Date.CultureStrings && !!Date.CultureStrings[code])) { lang = code; Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings.lang = code; Date.CultureInfo = new CultureInfo(); } else { if (!(!!Date.CultureStrings && !!Date.CultureStrings[code])) { if (typeof exports !== "undefined" && this.exports !== exports) { // we're in a Node enviroment, load it using require try { require("../i18n/" + code + ".js"); lang = code; Date.CultureStrings.lang = code; Date.CultureInfo = new CultureInfo(); } catch (e) { // var str = "The language for '" + code + "' could not be loaded by Node. It likely does not exist."; throw new Error("The DateJS IETF language tag '" + code + "' could not be loaded by Node. It likely does not exist."); } } else if (Date.Config && Date.Config.i18n) { // we know the location of the files, so lets load them async = true; loadI18nScript(code).done(function(){ lang = code; Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings.lang = code; Date.CultureInfo = new CultureInfo(); $D.Parsing.Normalizer.buildReplaceData(); // because this is async if ($D.Grammar) { $D.Grammar.buildGrammarFormats(); // so we can parse those strings... } if (cb) { setTimeout(cb,0); } }); } else { Date.console.error("The DateJS IETF language tag '" + code + "' is not available and has not been loaded."); return false; } } } $D.Parsing.Normalizer.buildReplaceData(); // rebuild normalizer strings if ($D.Grammar) { $D.Grammar.buildGrammarFormats(); // so we can parse those strings... } if (!async && cb) { setTimeout(cb,0); } }, getLoggedKeys: function () { return loggedKeys; }, updateCultureInfo: function () { Date.CultureInfo = new CultureInfo(); } }; $D.i18n.updateCultureInfo(); // run automatically }()); (function () { var $D = Date, $P = $D.prototype, p = function (s, l) { if (!l) { l = 2; } return ("000" + s).slice(l * -1); }; if (typeof window !== "undefined" && typeof window.console !== "undefined" && typeof window.console.log !== "undefined") { $D.console = console; // used only to raise non-critical errors if available } else { // set mock so we don't give errors. $D.console = { log: function(){}, error: function(){} }; } $D.Config = $D.Config || {}; $D.initOverloads = function() { /** * Overload of Date.now. Allows an alternate call for Date.now where it returns the * current Date as an object rather than just milliseconds since the Unix Epoch. * * Also provides an implementation of now() for browsers (IE<9) that don't have it. * * Backwards compatible so with work with either: * Date.now() [returns ms] * or * Date.now(true) [returns Date] */ if (!$D.now) { $D._now = function now() { return new Date().getTime(); }; } else if (!$D._now) { $D._now = $D.now; } $D.now = function (returnObj) { if (returnObj) { return $D.present(); } else { return $D._now(); } }; if ( !$P.toISOString ) { $P.toISOString = function() { return this.getUTCFullYear() + "-" + p(this.getUTCMonth() + 1) + "-" + p(this.getUTCDate()) + "T" + p(this.getUTCHours()) + ":" + p(this.getUTCMinutes()) + ":" + p(this.getUTCSeconds()) + "." + String( (this.getUTCMilliseconds()/1000).toFixed(3)).slice(2, 5) + "Z"; }; } // private if ( $P._toString === undefined ){ $P._toString = $P.toString; } }; $D.initOverloads(); /** * Gets a date that is set to the current date. The time is set to the start of the day (00:00 or 12:00 AM). * @return {Date} The current date. */ $D.today = function () { return new Date().clearTime(); }; /** * Gets a date that is set to the current date and time (same as new Date, but chainable) * @return {Date} The current date. */ $D.present = function () { return new Date(); }; /** * Compares the first date to the second date and returns an number indication of their relative values. * @param {Date} First Date object to compare [Required]. * @param {Date} Second Date object to compare to [Required]. * @return {Number} -1 = date1 is lessthan date2. 0 = values are equal. 1 = date1 is greaterthan date2. */ $D.compare = function (date1, date2) { if (isNaN(date1) || isNaN(date2)) { throw new Error(date1 + " - " + date2); } else if (date1 instanceof Date && date2 instanceof Date) { return (date1 < date2) ? -1 : (date1 > date2) ? 1 : 0; } else { throw new TypeError(date1 + " - " + date2); } }; /** * Compares the first Date object to the second Date object and returns true if they are equal. * @param {Date} First Date object to compare [Required] * @param {Date} Second Date object to compare to [Required] * @return {Boolean} true if dates are equal. false if they are not equal. */ $D.equals = function (date1, date2) { return (date1.compareTo(date2) === 0); }; /** * Gets the language appropriate day name when given the day number(0-6) * eg - 0 == Sunday * @return {String} The day name */ $D.getDayName = function (n) { return Date.CultureInfo.dayNames[n]; }; /** * Gets the day number (0-6) if given a CultureInfo specific string which is a valid dayName, abbreviatedDayName or shortestDayName (two char). * @param {String} The name of the day (eg. "Monday, "Mon", "tuesday", "tue", "We", "we"). * @return {Number} The day number */ $D.getDayNumberFromName = function (name) { var n = Date.CultureInfo.dayNames, m = Date.CultureInfo.abbreviatedDayNames, o = Date.CultureInfo.shortestDayNames, s = name.toLowerCase(); for (var i = 0; i < n.length; i++) { if (n[i].toLowerCase() === s || m[i].toLowerCase() === s || o[i].toLowerCase() === s) { return i; } } return -1; }; /** * Gets the month number (0-11) if given a Culture Info specific string which is a valid monthName or abbreviatedMonthName. * @param {String} The name of the month (eg. "February, "Feb", "october", "oct"). * @return {Number} The day number */ $D.getMonthNumberFromName = function (name) { var n = Date.CultureInfo.monthNames, m = Date.CultureInfo.abbreviatedMonthNames, s = name.toLowerCase(); for (var i = 0; i < n.length; i++) { if (n[i].toLowerCase() === s || m[i].toLowerCase() === s) { return i; } } return -1; }; /** * Gets the language appropriate month name when given the month number(0-11) * eg - 0 == January * @return {String} The month name */ $D.getMonthName = function (n) { return Date.CultureInfo.monthNames[n]; }; /** * Determines if the current date instance is within a LeapYear. * @param {Number} The year. * @return {Boolean} true if date is within a LeapYear, otherwise false. */ $D.isLeapYear = function (year) { return ((year % 4 === 0 && year % 100 !== 0) || year % 400 === 0); }; /** * Gets the number of days in the month, given a year and month value. Automatically corrects for LeapYear. * @param {Number} The year. * @param {Number} The month (0-11). * @return {Number} The number of days in the month. */ $D.getDaysInMonth = function (year, month) { if (!month && $D.validateMonth(year)) { month = year; year = Date.today().getFullYear(); } return [31, ($D.isLeapYear(year) ? 29 : 28), 31, 30, 31, 30, 31, 31, 30, 31, 30, 31][month]; }; $P.getDaysInMonth = function () { return $D.getDaysInMonth(this.getFullYear(), this.getMonth()); }; $D.getTimezoneAbbreviation = function (offset, dst) { var p, n = (dst || false) ? Date.CultureInfo.abbreviatedTimeZoneDST : Date.CultureInfo.abbreviatedTimeZoneStandard; for (p in n) { if (n.hasOwnProperty(p)) { if (n[p] === offset) { return p; } } } return null; }; $D.getTimezoneOffset = function (name, dst) { var i, a =[], z = Date.CultureInfo.timezones; if (!name) { name = (new Date()).getTimezone();} for (i = 0; i < z.length; i++) { if (z[i].name === name.toUpperCase()) { a.push(i); } } if (!z[a[0]]) { return null; } if (a.length === 1 || !dst) { return z[a[0]].offset; } else { for (i=0; i < a.length; i++) { if (z[a[i]].dst) { return z[a[i]].offset; } } } }; $D.getQuarter = function (d) { d = d || new Date(); // If no date supplied, use today var q = [1,2,3,4]; return q[Math.floor(d.getMonth() / 3)]; // ~~~ is a bitwise op. Faster than Math.floor }; $D.getDaysLeftInQuarter = function (d) { d = d || new Date(); var qEnd = new Date(d); qEnd.setMonth(qEnd.getMonth() + 3 - qEnd.getMonth() % 3, 0); return Math.floor((qEnd - d) / 8.64e7); }; // private var validate = function (n, min, max, name) { name = name ? name : "Object"; if (typeof n === "undefined") { return false; } else if (typeof n !== "number") { throw new TypeError(n + " is not a Number."); } else if (n < min || n > max) { // As failing validation is *not* an exceptional circumstance // lets not throw a RangeError Exception here. // It's semantically correct but it's not sensible. return false; } return true; }; /** * Validates the number is within an acceptable range for milliseconds [0-999]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateMillisecond = function (value) { return validate(value, 0, 999, "millisecond"); }; /** * Validates the number is within an acceptable range for seconds [0-59]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateSecond = function (value) { return validate(value, 0, 59, "second"); }; /** * Validates the number is within an acceptable range for minutes [0-59]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateMinute = function (value) { return validate(value, 0, 59, "minute"); }; /** * Validates the number is within an acceptable range for hours [0-23]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateHour = function (value) { return validate(value, 0, 23, "hour"); }; /** * Validates the number is within an acceptable range for the days in a month [0-MaxDaysInMonth]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateDay = function (value, year, month) { if (year === undefined || year === null || month === undefined || month === null) { return false;} return validate(value, 1, $D.getDaysInMonth(year, month), "day"); }; /** * Validates the number is within an acceptable range for months [0-11]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateWeek = function (value) { return validate(value, 0, 53, "week"); }; /** * Validates the number is within an acceptable range for months [0-11]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateMonth = function (value) { return validate(value, 0, 11, "month"); }; /** * Validates the number is within an acceptable range for years. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateYear = function (value) { /** * Per ECMAScript spec the range of times supported by Date objects is * exactly -100,000,000 days to +100,000,000 days measured relative to * midnight at the beginning of 01 January, 1970 UTC. * This gives a range of 8,640,000,000,000,000 milliseconds to either * side of 01 January, 1970 UTC. * * Earliest possible date: Tue, 20 Apr 271,822 B.C. 00:00:00 UTC * Latest possible date: Sat, 13 Sep 275,760 00:00:00 UTC */ return validate(value, -271822, 275760, "year"); }; $D.validateTimezone = function(value) { var timezones = {"ACDT":1,"ACST":1,"ACT":1,"ADT":1,"AEDT":1,"AEST":1,"AFT":1,"AKDT":1,"AKST":1,"AMST":1,"AMT":1,"ART":1,"AST":1,"AWDT":1,"AWST":1,"AZOST":1,"AZT":1,"BDT":1,"BIOT":1,"BIT":1,"BOT":1,"BRT":1,"BST":1,"BTT":1,"CAT":1,"CCT":1,"CDT":1,"CEDT":1,"CEST":1,"CET":1,"CHADT":1,"CHAST":1,"CHOT":1,"ChST":1,"CHUT":1,"CIST":1,"CIT":1,"CKT":1,"CLST":1,"CLT":1,"COST":1,"COT":1,"CST":1,"CT":1,"CVT":1,"CWST":1,"CXT":1,"DAVT":1,"DDUT":1,"DFT":1,"EASST":1,"EAST":1,"EAT":1,"ECT":1,"EDT":1,"EEDT":1,"EEST":1,"EET":1,"EGST":1,"EGT":1,"EIT":1,"EST":1,"FET":1,"FJT":1,"FKST":1,"FKT":1,"FNT":1,"GALT":1,"GAMT":1,"GET":1,"GFT":1,"GILT":1,"GIT":1,"GMT":1,"GST":1,"GYT":1,"HADT":1,"HAEC":1,"HAST":1,"HKT":1,"HMT":1,"HOVT":1,"HST":1,"ICT":1,"IDT":1,"IOT":1,"IRDT":1,"IRKT":1,"IRST":1,"IST":1,"JST":1,"KGT":1,"KOST":1,"KRAT":1,"KST":1,"LHST":1,"LINT":1,"MAGT":1,"MART":1,"MAWT":1,"MDT":1,"MET":1,"MEST":1,"MHT":1,"MIST":1,"MIT":1,"MMT":1,"MSK":1,"MST":1,"MUT":1,"MVT":1,"MYT":1,"NCT":1,"NDT":1,"NFT":1,"NPT":1,"NST":1,"NT":1,"NUT":1,"NZDT":1,"NZST":1,"OMST":1,"ORAT":1,"PDT":1,"PET":1,"PETT":1,"PGT":1,"PHOT":1,"PHT":1,"PKT":1,"PMDT":1,"PMST":1,"PONT":1,"PST":1,"PYST":1,"PYT":1,"RET":1,"ROTT":1,"SAKT":1,"SAMT":1,"SAST":1,"SBT":1,"SCT":1,"SGT":1,"SLST":1,"SRT":1,"SST":1,"SYOT":1,"TAHT":1,"THA":1,"TFT":1,"TJT":1,"TKT":1,"TLT":1,"TMT":1,"TOT":1,"TVT":1,"UCT":1,"ULAT":1,"UTC":1,"UYST":1,"UYT":1,"UZT":1,"VET":1,"VLAT":1,"VOLT":1,"VOST":1,"VUT":1,"WAKT":1,"WAST":1,"WAT":1,"WEDT":1,"WEST":1,"WET":1,"WST":1,"YAKT":1,"YEKT":1,"Z":1}; return (timezones[value] === 1); }; $D.validateTimezoneOffset= function(value) { // timezones go from +14hrs to -12hrs, the +X hours are negative offsets. return (value > -841 && value < 721); }; }()); (function () { var $D = Date, $P = $D.prototype, p = function (s, l) { if (!l) { l = 2; } return ("000" + s).slice(l * -1); }; var validateConfigObject = function (obj) { var result = {}, self = this, prop, testFunc; testFunc = function (prop, func, value) { if (prop === "day") { var month = (obj.month !== undefined) ? obj.month : self.getMonth(); var year = (obj.year !== undefined) ? obj.year : self.getFullYear(); return $D[func](value, year, month); } else { return $D[func](value); } }; for (prop in obj) { if (Object.prototype.hasOwnProperty.call(obj, prop)) { var func = "validate" + prop.charAt(0).toUpperCase() + prop.slice(1); if ($D[func] && obj[prop] !== null && testFunc(prop, func, obj[prop])) { result[prop] = obj[prop]; } } } return result; }; /** * Resets the time of this Date object to 12:00 AM (00:00), which is the start of the day. * @param {Boolean} .clone() this date instance before clearing Time * @return {Date} this */ $P.clearTime = function () { this.setHours(0); this.setMinutes(0); this.setSeconds(0); this.setMilliseconds(0); return this; }; /** * Resets the time of this Date object to the current time ('now'). * @return {Date} this */ $P.setTimeToNow = function () { var n = new Date(); this.setHours(n.getHours()); this.setMinutes(n.getMinutes()); this.setSeconds(n.getSeconds()); this.setMilliseconds(n.getMilliseconds()); return this; }; /** * Returns a new Date object that is an exact date and time copy of the original instance. * @return {Date} A new Date instance */ $P.clone = function () { return new Date(this.getTime()); }; /** * Compares this instance to a Date object and returns an number indication of their relative values. * @param {Date} Date object to compare [Required] * @return {Number} -1 = this is lessthan date. 0 = values are equal. 1 = this is greaterthan date. */ $P.compareTo = function (date) { return Date.compare(this, date); }; /** * Compares this instance to another Date object and returns true if they are equal. * @param {Date} Date object to compare. If no date to compare, new Date() [now] is used. * @return {Boolean} true if dates are equal. false if they are not equal. */ $P.equals = function (date) { return Date.equals(this, (date !== undefined ? date : new Date())); }; /** * Determines if this instance is between a range of two dates or equal to either the start or end dates. * @param {Date} Start of range [Required] * @param {Date} End of range [Required] * @return {Boolean} true is this is between or equal to the start and end dates, else false */ $P.between = function (start, end) { return this.getTime() >= start.getTime() && this.getTime() <= end.getTime(); }; /** * Determines if this date occurs after the date to compare to. * @param {Date} Date object to compare. If no date to compare, new Date() ("now") is used. * @return {Boolean} true if this date instance is greater than the date to compare to (or "now"), otherwise false. */ $P.isAfter = function (date) { return this.compareTo(date || new Date()) === 1; }; /** * Determines if this date occurs before the date to compare to. * @param {Date} Date object to compare. If no date to compare, new Date() ("now") is used. * @return {Boolean} true if this date instance is less than the date to compare to (or "now"). */ $P.isBefore = function (date) { return (this.compareTo(date || new Date()) === -1); }; /** * Determines if the current Date instance occurs today. * @return {Boolean} true if this date instance is 'today', otherwise false. */ /** * Determines if the current Date instance occurs on the same Date as the supplied 'date'. * If no 'date' to compare to is provided, the current Date instance is compared to 'today'. * @param {date} Date object to compare. If no date to compare, the current Date ("now") is used. * @return {Boolean} true if this Date instance occurs on the same Day as the supplied 'date'. */ $P.isToday = $P.isSameDay = function (date) { return this.clone().clearTime().equals((date || new Date()).clone().clearTime()); }; /** * Adds the specified number of milliseconds to this instance. * @param {Number} The number of milliseconds to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addMilliseconds = function (value) { if (!value) { return this; } this.setTime(this.getTime() + value * 1); return this; }; /** * Adds the specified number of seconds to this instance. * @param {Number} The number of seconds to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addSeconds = function (value) { if (!value) { return this; } return this.addMilliseconds(value * 1000); }; /** * Adds the specified number of seconds to this instance. * @param {Number} The number of seconds to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addMinutes = function (value) { if (!value) { return this; } return this.addMilliseconds(value * 60000); // 60*1000 }; /** * Adds the specified number of hours to this instance. * @param {Number} The number of hours to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addHours = function (value) { if (!value) { return this; } return this.addMilliseconds(value * 3600000); // 60*60*1000 }; /** * Adds the specified number of days to this instance. * @param {Number} The number of days to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addDays = function (value) { if (!value) { return this; } this.setDate(this.getDate() + value * 1); return this; }; /** * Adds the specified number of weekdays (ie - not sat or sun) to this instance. * @param {Number} The number of days to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addWeekdays = function (value) { if (!value) { return this; } var day = this.getDay(); var weeks = (Math.ceil(Math.abs(value)/7)); if (day === 0 || day === 6) { if (value > 0) { this.next().monday(); this.addDays(-1); day = this.getDay(); } } if (value < 0) { while (value < 0) { this.addDays(-1); day = this.getDay(); if (day !== 0 && day !== 6) { value++; } } return this; } else if (value > 5 || (6-day) <= value) { value = value + (weeks * 2); } return this.addDays(value); }; /** * Adds the specified number of weeks to this instance. * @param {Number} The number of weeks to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addWeeks = function (value) { if (!value) { return this; } return this.addDays(value * 7); }; /** * Adds the specified number of months to this instance. * @param {Number} The number of months to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addMonths = function (value) { if (!value) { return this; } var n = this.getDate(); this.setDate(1); this.setMonth(this.getMonth() + value * 1); this.setDate(Math.min(n, $D.getDaysInMonth(this.getFullYear(), this.getMonth()))); return this; }; $P.addQuarters = function (value) { if (!value) { return this; } // note this will take you to the same point in the quarter as you are now. // i.e. - if you are 15 days into the quarter you'll be 15 days into the resulting one. // bonus: this allows adding fractional quarters return this.addMonths(value * 3); }; /** * Adds the specified number of years to this instance. * @param {Number} The number of years to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addYears = function (value) { if (!value) { return this; } return this.addMonths(value * 12); }; /** * Adds (or subtracts) to the value of the years, months, weeks, days, hours, minutes, seconds, milliseconds of the date instance using given configuration object. Positive and Negative values allowed. * Example

	Date.today().add( { days: 1, months: 1 } )

	new Date().add( { years: -1 } )
	
* @param {Object} Configuration object containing attributes (months, days, etc.) * @return {Date} this */ $P.add = function (config) { if (typeof config === "number") { this._orient = config; return this; } var x = config; if (x.day) { // If we should be a different date than today (eg: for 'tomorrow -1d', etc). // Should only effect parsing, not direct usage (eg, Finish and FinishExact) if ((x.day - this.getDate()) !== 0) { this.setDate(x.day); } } if (x.milliseconds) { this.addMilliseconds(x.milliseconds); } if (x.seconds) { this.addSeconds(x.seconds); } if (x.minutes) { this.addMinutes(x.minutes); } if (x.hours) { this.addHours(x.hours); } if (x.weeks) { this.addWeeks(x.weeks); } if (x.months) { this.addMonths(x.months); } if (x.years) { this.addYears(x.years); } if (x.days) { this.addDays(x.days); } return this; }; /** * Get the week number. Week one (1) is the week which contains the first Thursday of the year. Monday is considered the first day of the week. * The .getWeek() function does NOT convert the date to UTC. The local datetime is used. * Please use .getISOWeek() to get the week of the UTC converted date. * @return {Number} 1 to 53 */ $P.getWeek = function (utc) { // Create a copy of this date object var self, target = new Date(this.valueOf()); if (utc) { target.addMinutes(target.getTimezoneOffset()); self = target.clone(); } else { self = this; } // ISO week date weeks start on monday // so correct the day number var dayNr = (self.getDay() + 6) % 7; // ISO 8601 states that week 1 is the week // with the first thursday of that year. // Set the target date to the thursday in the target week target.setDate(target.getDate() - dayNr + 3); // Store the millisecond value of the target date var firstThursday = target.valueOf(); // Set the target to the first thursday of the year // First set the target to january first target.setMonth(0, 1); // Not a thursday? Correct the date to the next thursday if (target.getDay() !== 4) { target.setMonth(0, 1 + ((4 - target.getDay()) + 7) % 7); } // The weeknumber is the number of weeks between the // first thursday of the year and the thursday in the target week return 1 + Math.ceil((firstThursday - target) / 604800000); // 604800000 = 7 * 24 * 3600 * 1000 }; /** * Get the ISO 8601 week number. Week one ("01") is the week which contains the first Thursday of the year. Monday is considered the first day of the week. * The .getISOWeek() function does convert the date to it's UTC value. Please use .getWeek() to get the week of the local date. * @return {String} "01" to "53" */ $P.getISOWeek = function () { return p(this.getWeek(true)); }; /** * Moves the date to Monday of the week set. Week one (1) is the week which contains the first Thursday of the year. * @param {Number} A Number (1 to 53) that represents the week of the year. * @return {Date} this */ $P.setWeek = function (n) { if ((n - this.getWeek()) === 0) { if (this.getDay() !== 1) { return this.moveToDayOfWeek(1, (this.getDay() > 1 ? -1 : 1)); } else { return this; } } else { return this.moveToDayOfWeek(1, (this.getDay() > 1 ? -1 : 1)).addWeeks(n - this.getWeek()); } }; $P.setQuarter = function (qtr) { var month = Math.abs(((qtr-1) * 3) + 1); return this.setMonth(month, 1); }; $P.getQuarter = function () { return Date.getQuarter(this); }; $P.getDaysLeftInQuarter = function () { return Date.getDaysLeftInQuarter(this); }; /** * Moves the date to the next n'th occurrence of the dayOfWeek starting from the beginning of the month. The number (-1) is a magic number and will return the last occurrence of the dayOfWeek in the month. * @param {Number} The dayOfWeek to move to * @param {Number} The n'th occurrence to move to. Use (-1) to return the last occurrence in the month * @return {Date} this */ $P.moveToNthOccurrence = function (dayOfWeek, occurrence) { if (dayOfWeek === "Weekday") { if (occurrence > 0) { this.moveToFirstDayOfMonth(); if (this.is().weekday()) { occurrence -= 1; } } else if (occurrence < 0) { this.moveToLastDayOfMonth(); if (this.is().weekday()) { occurrence += 1; } } else { return this; } return this.addWeekdays(occurrence); } var shift = 0; if (occurrence > 0) { shift = occurrence - 1; } else if (occurrence === -1) { this.moveToLastDayOfMonth(); if (this.getDay() !== dayOfWeek) { this.moveToDayOfWeek(dayOfWeek, -1); } return this; } return this.moveToFirstDayOfMonth().addDays(-1).moveToDayOfWeek(dayOfWeek, +1).addWeeks(shift); }; var moveToN = function (getFunc, addFunc, nVal) { return function (value, orient) { var diff = (value - this[getFunc]() + nVal * (orient || +1)) % nVal; return this[addFunc]((diff === 0) ? diff += nVal * (orient || +1) : diff); }; }; /** * Move to the next or last dayOfWeek based on the orient value. * @param {Number} The dayOfWeek to move to * @param {Number} Forward (+1) or Back (-1). Defaults to +1. [Optional] * @return {Date} this */ $P.moveToDayOfWeek = moveToN("getDay", "addDays", 7); /** * Move to the next or last month based on the orient value. * @param {Number} The month to move to. 0 = January, 11 = December * @param {Number} Forward (+1) or Back (-1). Defaults to +1. [Optional] * @return {Date} this */ $P.moveToMonth = moveToN("getMonth", "addMonths", 12); /** * Get the Ordinate of the current day ("th", "st", "rd"). * @return {String} */ $P.getOrdinate = function () { var num = this.getDate(); return ord(num); }; /** * Get the Ordinal day (numeric day number) of the year, adjusted for leap year. * @return {Number} 1 through 365 (366 in leap years) */ $P.getOrdinalNumber = function () { return Math.ceil((this.clone().clearTime() - new Date(this.getFullYear(), 0, 1)) / 86400000) + 1; }; /** * Get the time zone abbreviation of the current date. * @return {String} The abbreviated time zone name (e.g. "EST") */ $P.getTimezone = function () { return $D.getTimezoneAbbreviation(this.getUTCOffset(), this.isDaylightSavingTime()); }; $P.setTimezoneOffset = function (offset) { var here = this.getTimezoneOffset(), there = Number(offset) * -6 / 10; return (there || there === 0) ? this.addMinutes(there - here) : this; }; $P.setTimezone = function (offset) { return this.setTimezoneOffset($D.getTimezoneOffset(offset)); }; /** * Indicates whether Daylight Saving Time is observed in the current time zone. * @return {Boolean} true|false */ $P.hasDaylightSavingTime = function () { return (Date.today().set({month: 0, day: 1}).getTimezoneOffset() !== Date.today().set({month: 6, day: 1}).getTimezoneOffset()); }; /** * Indicates whether this Date instance is within the Daylight Saving Time range for the current time zone. * @return {Boolean} true|false */ $P.isDaylightSavingTime = function () { return Date.today().set({month: 0, day: 1}).getTimezoneOffset() !== this.getTimezoneOffset(); }; /** * Get the offset from UTC of the current date. * @return {String} The 4-character offset string prefixed with + or - (e.g. "-0500") */ $P.getUTCOffset = function (offset) { var n = (offset || this.getTimezoneOffset()) * -10 / 6, r; if (n < 0) { r = (n - 10000).toString(); return r.charAt(0) + r.substr(2); } else { r = (n + 10000).toString(); return "+" + r.substr(1); } }; /** * Returns the number of milliseconds between this date and date. * @param {Date} Defaults to now * @return {Number} The diff in milliseconds */ $P.getElapsed = function (date) { return (date || new Date()) - this; }; /** * Set the value of year, month, day, hour, minute, second, millisecond of date instance using given configuration object. * Example

	Date.today().set( { day: 20, month: 1 } )

	new Date().set( { millisecond: 0 } )
	
* * @param {Object} Configuration object containing attributes (month, day, etc.) * @return {Date} this */ $P.set = function (config) { config = validateConfigObject.call(this, config); var key; for (key in config) { if (Object.prototype.hasOwnProperty.call(config, key)) { var name = key.charAt(0).toUpperCase() + key.slice(1); var addFunc, getFunc; if (key !== "week" && key !== "month" && key !== "timezone" && key !== "timezoneOffset") { name += "s"; } addFunc = "add" + name; getFunc = "get" + name; if (key === "month") { addFunc = addFunc + "s"; } else if (key === "year"){ getFunc = "getFullYear"; } if (key !== "day" && key !== "timezone" && key !== "timezoneOffset" && key !== "week" && key !== "hour") { this[addFunc](config[key] - this[getFunc]()); } else if ( key === "timezone"|| key === "timezoneOffset" || key === "week" || key === "hour") { this["set"+name](config[key]); } } } // day has to go last because you can't validate the day without first knowing the month if (config.day) { this.addDays(config.day - this.getDate()); } return this; }; /** * Moves the date to the first day of the month. * @return {Date} this */ $P.moveToFirstDayOfMonth = function () { return this.set({ day: 1 }); }; /** * Moves the date to the last day of the month. * @return {Date} this */ $P.moveToLastDayOfMonth = function () { return this.set({ day: $D.getDaysInMonth(this.getFullYear(), this.getMonth())}); }; /** * Converts the value of the current Date object to its equivalent string representation. * Format Specifiers * CUSTOM DATE AND TIME FORMAT STRINGS * Format Description Example * ------ --------------------------------------------------------------------------- ----------------------- * s The seconds of the minute between 0-59. "0" to "59" * ss The seconds of the minute with leading zero if required. "00" to "59" * * m The minute of the hour between 0-59. "0" or "59" * mm The minute of the hour with leading zero if required. "00" or "59" * * h The hour of the day between 1-12. "1" to "12" * hh The hour of the day with leading zero if required. "01" to "12" * * H The hour of the day between 0-23. "0" to "23" * HH The hour of the day with leading zero if required. "00" to "23" * * d The day of the month between 1 and 31. "1" to "31" * dd The day of the month with leading zero if required. "01" to "31" * ddd Abbreviated day name. Date.CultureInfo.abbreviatedDayNames. "Mon" to "Sun" * dddd The full day name. Date.CultureInfo.dayNames. "Monday" to "Sunday" * * M The month of the year between 1-12. "1" to "12" * MM The month of the year with leading zero if required. "01" to "12" * MMM Abbreviated month name. Date.CultureInfo.abbreviatedMonthNames. "Jan" to "Dec" * MMMM The full month name. Date.CultureInfo.monthNames. "January" to "December" * * yy The year as a two-digit number. "99" or "08" * yyyy The full four digit year. "1999" or "2008" * * t Displays the first character of the A.M./P.M. designator. "A" or "P" * Date.CultureInfo.amDesignator or Date.CultureInfo.pmDesignator * tt Displays the A.M./P.M. designator. "AM" or "PM" * Date.CultureInfo.amDesignator or Date.CultureInfo.pmDesignator * * S The ordinal suffix ("st, "nd", "rd" or "th") of the current day. "st, "nd", "rd" or "th" * * STANDARD DATE AND TIME FORMAT STRINGS * Format Description Example *------ --------------------------------------------------------------------------- ----------------------- * d The CultureInfo shortDate Format Pattern "M/d/yyyy" * D The CultureInfo longDate Format Pattern "dddd, MMMM dd, yyyy" * F The CultureInfo fullDateTime Format Pattern "dddd, MMMM dd, yyyy h:mm:ss tt" * m The CultureInfo monthDay Format Pattern "MMMM dd" * r The CultureInfo rfc1123 Format Pattern "ddd, dd MMM yyyy HH:mm:ss GMT" * s The CultureInfo sortableDateTime Format Pattern "yyyy-MM-ddTHH:mm:ss" * t The CultureInfo shortTime Format Pattern "h:mm tt" * T The CultureInfo longTime Format Pattern "h:mm:ss tt" * u The CultureInfo universalSortableDateTime Format Pattern "yyyy-MM-dd HH:mm:ssZ" * y The CultureInfo yearMonth Format Pattern "MMMM, yyyy" * * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @return {String} A string representation of the current Date object. */ var ord = function (n) { switch (n * 1) { case 1: case 21: case 31: return "st"; case 2: case 22: return "nd"; case 3: case 23: return "rd"; default: return "th"; } }; var parseStandardFormats = function (format) { var y, c = Date.CultureInfo.formatPatterns; switch (format) { case "d": return this.toString(c.shortDate); case "D": return this.toString(c.longDate); case "F": return this.toString(c.fullDateTime); case "m": return this.toString(c.monthDay); case "r": case "R": y = this.clone().addMinutes(this.getTimezoneOffset()); return y.toString(c.rfc1123) + " GMT"; case "s": return this.toString(c.sortableDateTime); case "t": return this.toString(c.shortTime); case "T": return this.toString(c.longTime); case "u": y = this.clone().addMinutes(this.getTimezoneOffset()); return y.toString(c.universalSortableDateTime); case "y": return this.toString(c.yearMonth); default: return false; } }; var parseFormatStringsClosure = function (context) { return function (m) { if (m.charAt(0) === "\\") { return m.replace("\\", ""); } switch (m) { case "hh": return p(context.getHours() < 13 ? (context.getHours() === 0 ? 12 : context.getHours()) : (context.getHours() - 12)); case "h": return context.getHours() < 13 ? (context.getHours() === 0 ? 12 : context.getHours()) : (context.getHours() - 12); case "HH": return p(context.getHours()); case "H": return context.getHours(); case "mm": return p(context.getMinutes()); case "m": return context.getMinutes(); case "ss": return p(context.getSeconds()); case "s": return context.getSeconds(); case "yyyy": return p(context.getFullYear(), 4); case "yy": return p(context.getFullYear()); case "y": return context.getFullYear(); case "E": case "dddd": return Date.CultureInfo.dayNames[context.getDay()]; case "ddd": return Date.CultureInfo.abbreviatedDayNames[context.getDay()]; case "dd": return p(context.getDate()); case "d": return context.getDate(); case "MMMM": return Date.CultureInfo.monthNames[context.getMonth()]; case "MMM": return Date.CultureInfo.abbreviatedMonthNames[context.getMonth()]; case "MM": return p((context.getMonth() + 1)); case "M": return context.getMonth() + 1; case "t": return context.getHours() < 12 ? Date.CultureInfo.amDesignator.substring(0, 1) : Date.CultureInfo.pmDesignator.substring(0, 1); case "tt": return context.getHours() < 12 ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator; case "S": return ord(context.getDate()); case "W": return context.getWeek(); case "WW": return context.getISOWeek(); case "Q": return "Q" + context.getQuarter(); case "q": return String(context.getQuarter()); case "z": return context.getTimezone(); case "Z": case "X": return Date.getTimezoneOffset(context.getTimezone()); case "ZZ": // Timezone offset in seconds return context.getTimezoneOffset() * -60; case "u": return context.getDay(); case "L": return ($D.isLeapYear(context.getFullYear())) ? 1 : 0; case "B": // Swatch Internet Time (.beats) return "@"+((context.getUTCSeconds() + (context.getUTCMinutes()*60) + ((context.getUTCHours()+1)*3600))/86.4); default: return m; } }; }; $P.toString = function (format, ignoreStandards) { // Standard Date and Time Format Strings. Formats pulled from CultureInfo file and // may vary by culture. if (!ignoreStandards && format && format.length === 1) { output = parseStandardFormats.call(this, format); if (output) { return output; } } var parseFormatStrings = parseFormatStringsClosure(this); return format ? format.replace(/((\\)?(dd?d?d?|MM?M?M?|yy?y?y?|hh?|HH?|mm?|ss?|tt?|S|q|Q|WW?W?W?)(?![^\[]*\]))/g, parseFormatStrings).replace(/\[|\]/g, "") : this._toString(); }; }()); /************************************************************* * SugarPak - Domain Specific Language - Syntactical Sugar * *************************************************************/ (function () { var $D = Date, $P = $D.prototype, $N = Number.prototype; // private $P._orient = +1; // private $P._nth = null; // private $P._is = false; // private $P._same = false; // private $P._isSecond = false; // private $N._dateElement = "days"; /** * Moves the date to the next instance of a date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.today().next().friday();
	Date.today().next().fri();
	Date.today().next().march();
	Date.today().next().mar();
	Date.today().next().week();
	
* * @return {Date} date */ $P.next = function () { this._move = true; this._orient = +1; return this; }; /** * Creates a new Date (Date.today()) and moves the date to the next instance of the date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.next().friday();
	Date.next().fri();
	Date.next().march();
	Date.next().mar();
	Date.next().week();
	
* * @return {Date} date */ $D.next = function () { return $D.today().next(); }; /** * Moves the date to the previous instance of a date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.today().last().friday();
	Date.today().last().fri();
	Date.today().last().march();
	Date.today().last().mar();
	Date.today().last().week();
	
* * @return {Date} date */ $P.last = $P.prev = $P.previous = function () { this._move = true; this._orient = -1; return this; }; /** * Creates a new Date (Date.today()) and moves the date to the previous instance of the date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.last().friday();
	Date.last().fri();
	Date.previous().march();
	Date.prev().mar();
	Date.last().week();
	
* * @return {Date} date */ $D.last = $D.prev = $D.previous = function () { return $D.today().last(); }; /** * Performs a equality check when followed by either a month name, day name or .weekday() function. * Example

	Date.today().is().friday(); // true|false
	Date.today().is().fri();
	Date.today().is().march();
	Date.today().is().mar();
	
* * @return {Boolean} true|false */ $P.is = function () { this._is = true; return this; }; /** * Determines if two date objects occur on/in exactly the same instance of the subsequent date part function. * The function .same() must be followed by a date part function (example: .day(), .month(), .year(), etc). * * An optional Date can be passed in the date part function. If now date is passed as a parameter, 'Now' is used. * * The following example demonstrates how to determine if two dates fall on the exact same day. * * Example

	var d1 = Date.today(); // today at 00:00
	var d2 = new Date();   // exactly now.

	// Do they occur on the same day?
	d1.same().day(d2); // true
	
	// Do they occur on the same hour?
	d1.same().hour(d2); // false, unless d2 hour is '00' (midnight).
	
	// What if it's the same day, but one year apart?
	var nextYear = Date.today().add(1).year();

	d1.same().day(nextYear); // false, because the dates must occur on the exact same day. 
	
* * Scenario: Determine if a given date occurs during some week period 2 months from now. * * Example

	var future = Date.today().add(2).months();
	return someDate.same().week(future); // true|false;
	
* * @return {Boolean} true|false */ $P.same = function () { this._same = true; this._isSecond = false; return this; }; /** * Determines if the current date/time occurs during Today. Must be preceded by the .is() function. * Example

	someDate.is().today();    // true|false
	new Date().is().today();  // true
	Date.today().is().today();// true
	Date.today().add(-1).day().is().today(); // false
	
* * @return {Boolean} true|false */ $P.today = function () { return this.same().day(); }; /** * Determines if the current date is a weekday. This function must be preceded by the .is() function. * Example

	Date.today().is().weekday(); // true|false
	
* * @return {Boolean} true|false */ $P.weekday = function () { if (this._nth) { return df("Weekday").call(this); } if (this._move) { return this.addWeekdays(this._orient); } if (this._is) { this._is = false; return (!this.is().sat() && !this.is().sun()); } return false; }; /** * Determines if the current date is on the weekend. This function must be preceded by the .is() function. * Example

	Date.today().is().weekend(); // true|false
	
* * @return {Boolean} true|false */ $P.weekend = function () { if (this._is) { this._is = false; return (this.is().sat() || this.is().sun()); } return false; }; /** * Sets the Time of the current Date instance. A string "6:15 pm" or config object {hour:18, minute:15} are accepted. * Example

	// Set time to 6:15pm with a String
	Date.today().at("6:15pm");

	// Set time to 6:15pm with a config object
	Date.today().at({hour:18, minute:15});
	
* * @return {Date} date */ $P.at = function (time) { return (typeof time === "string") ? $D.parse(this.toString("d") + " " + time) : this.set(time); }; /** * Creates a new Date() and adds this (Number) to the date based on the preceding date element function (eg. second|minute|hour|day|month|year). * Example

	// Undeclared Numbers must be wrapped with parentheses. Requirment of JavaScript.
	(3).days().fromNow();
	(6).months().fromNow();

	// Declared Number variables do not require parentheses. 
	var n = 6;
	n.months().fromNow();
	
* * @return {Date} A new Date instance */ $N.fromNow = $N.after = function (date) { var c = {}; c[this._dateElement] = this; return ((!date) ? new Date() : date.clone()).add(c); }; /** * Creates a new Date() and subtract this (Number) from the date based on the preceding date element function (eg. second|minute|hour|day|month|year). * Example

	// Undeclared Numbers must be wrapped with parentheses. Requirment of JavaScript.
	(3).days().ago();
	(6).months().ago();

	// Declared Number variables do not require parentheses. 
	var n = 6;
	n.months().ago();
	
* * @return {Date} A new Date instance */ $N.ago = $N.before = function (date) { var c = {}, s = (this._dateElement[this._dateElement.length-1] !== "s") ? this._dateElement + "s" : this._dateElement; c[s] = this * -1; return ((!date) ? new Date() : date.clone()).add(c); }; // Do NOT modify the following string tokens. These tokens are used to build dynamic functions. // All culture-specific strings can be found in the CultureInfo files. var dx = ("sunday monday tuesday wednesday thursday friday saturday").split(/\s/), mx = ("january february march april may june july august september october november december").split(/\s/), px = ("Millisecond Second Minute Hour Day Week Month Year Quarter Weekday").split(/\s/), pxf = ("Milliseconds Seconds Minutes Hours Date Week Month FullYear Quarter").split(/\s/), nth = ("final first second third fourth fifth").split(/\s/), de; /** * Returns an object literal of all the date parts. * Example

	var o = new Date().toObject();
	
	// { year: 2008, month: 4, week: 20, day: 13, hour: 18, minute: 9, second: 32, millisecond: 812 }
	
	// The object properties can be referenced directly from the object.
	
	alert(o.day);  // alerts "13"
	alert(o.year); // alerts "2008"
	
* * @return {Date} An object literal representing the original date object. */ $P.toObject = function () { var o = {}; for (var i = 0; i < px.length; i++) { if (this["get" + pxf[i]]) { o[px[i].toLowerCase()] = this["get" + pxf[i]](); } } return o; }; /** * Returns a date created from an object literal. Ignores the .week property if set in the config. * Example

	var o = new Date().toObject();
	
	return Date.fromObject(o); // will return the same date. 

	var o2 = {month: 1, day: 20, hour: 18}; // birthday party!
	Date.fromObject(o2);
	
* * @return {Date} An object literal representing the original date object. */ $D.fromObject = function(config) { config.week = null; return Date.today().set(config); }; // Create day name functions and abbreviated day name functions (eg. monday(), friday(), fri()). var df = function (n) { return function () { if (this._is) { this._is = false; return this.getDay() === n; } if (this._move) { this._move = null; } if (this._nth !== null) { // If the .second() function was called earlier, remove the _orient // from the date, and then continue. // This is required because 'second' can be used in two different context. // // Example // // Date.today().add(1).second(); // Date.march().second().monday(); // // Things get crazy with the following... // Date.march().add(1).second().second().monday(); // but it works!! // if (this._isSecond) { this.addSeconds(this._orient * -1); } // make sure we reset _isSecond this._isSecond = false; var ntemp = this._nth; this._nth = null; var temp = this.clone().moveToLastDayOfMonth(); this.moveToNthOccurrence(n, ntemp); if (this > temp) { throw new RangeError($D.getDayName(n) + " does not occur " + ntemp + " times in the month of " + $D.getMonthName(temp.getMonth()) + " " + temp.getFullYear() + "."); } return this; } return this.moveToDayOfWeek(n, this._orient); }; }; var sdf = function (n) { return function () { var t = $D.today(), shift = n - t.getDay(); if (n === 0 && Date.CultureInfo.firstDayOfWeek === 1 && t.getDay() !== 0) { shift = shift + 7; } return t.addDays(shift); }; }; // Create month name functions and abbreviated month name functions (eg. january(), march(), mar()). var month_instance_functions = function (n) { return function () { if (this._is) { this._is = false; return this.getMonth() === n; } return this.moveToMonth(n, this._orient); }; }; var month_static_functions = function (n) { return function () { return $D.today().set({ month: n, day: 1 }); }; }; var processTerms = function (names, staticFunc, instanceFunc) { for (var i = 0; i < names.length; i++) { // Create constant static Name variables. $D[names[i].toUpperCase()] = $D[names[i].toUpperCase().substring(0, 3)] = i; // Create Name functions. $D[names[i]] = $D[names[i].substring(0, 3)] = staticFunc(i); // Create Name instance functions. $P[names[i]] = $P[names[i].substring(0, 3)] = instanceFunc(i); } }; processTerms(dx, sdf, df); processTerms(mx, month_static_functions, month_instance_functions); // Create date element functions and plural date element functions used with Date (eg. day(), days(), months()). var ef = function (j) { return function () { // if the .second() function was called earlier, the _orient // has alread been added. Just return this and reset _isSecond. if (this._isSecond) { this._isSecond = false; return this; } if (this._same) { this._same = this._is = false; var o1 = this.toObject(), o2 = (arguments[0] || new Date()).toObject(), v = "", k = j.toLowerCase(); // the substr trick with -1 doesn't work in IE8 or less k = (k[k.length-1] === "s") ? k.substring(0,k.length-1) : k; for (var m = (px.length - 1); m > -1; m--) { v = px[m].toLowerCase(); if (o1[v] !== o2[v]) { return false; } if (k === v) { break; } } return true; } if (j.substring(j.length - 1) !== "s") { j += "s"; } if (this._move) { this._move = null; } return this["add" + j](this._orient); }; }; var nf = function (n) { return function () { this._dateElement = n; return this; }; }; for (var k = 0; k < px.length; k++) { de = px[k].toLowerCase(); if(de !== "weekday") { // Create date element functions and plural date element functions used with Date (eg. day(), days(), months()). $P[de] = $P[de + "s"] = ef(px[k]); // Create date element functions and plural date element functions used with Number (eg. day(), days(), months()). $N[de] = $N[de + "s"] = nf(de + "s"); } } $P._ss = ef("Second"); var nthfn = function (n) { return function (dayOfWeek) { if (this._same) { return this._ss(arguments[0]); } if (dayOfWeek || dayOfWeek === 0) { return this.moveToNthOccurrence(dayOfWeek, n); } this._nth = n; // if the operator is 'second' add the _orient, then deal with it later... if (n === 2 && (dayOfWeek === undefined || dayOfWeek === null)) { this._isSecond = true; return this.addSeconds(this._orient); } return this; }; }; for (var l = 0; l < nth.length; l++) { $P[nth[l]] = (l === 0) ? nthfn(-1) : nthfn(l); } }()); (function () { "use strict"; Date.Parsing = { Exception: function (s) { this.message = "Parse error at '" + s.substring(0, 10) + " ...'"; } }; var $P = Date.Parsing; var dayOffsets = { standard: [0,31,59,90,120,151,181,212,243,273,304,334], leap: [0,31,60,91,121,152,182,213,244,274,305,335] }; $P.isLeapYear = function(year) { return ((year % 4 === 0) && (year % 100 !== 0)) || (year % 400 === 0); }; var utils = { multiReplace : function (str, hash ) { var key; for (key in hash) { if (Object.prototype.hasOwnProperty.call(hash, key)) { var regex; if (typeof hash[key] === "function") { } else { regex = (hash[key] instanceof RegExp) ? hash[key] : new RegExp(hash[key], "g"); } str = str.replace(regex, key); } } return str; }, getDayOfYearFromWeek : function (obj) { var d, jan4, offset; obj.weekDay = (!obj.weekDay && obj.weekDay !== 0) ? 1 : obj.weekDay; d = new Date(obj.year, 0, 4); jan4 = d.getDay() === 0 ? 7 : d.getDay(); // JS is 0 indexed on Sunday. offset = jan4+3; obj.dayOfYear = ((obj.week * 7) + (obj.weekDay === 0 ? 7 : obj.weekDay))-offset; return obj; }, getDayOfYear : function (obj, dayOffset) { if (!obj.dayOfYear) { obj = utils.getDayOfYearFromWeek(obj); } for (var i=0;i <= dayOffset.length;i++) { if (obj.dayOfYear < dayOffset[i] || i === dayOffset.length) { obj.day = obj.day ? obj.day : (obj.dayOfYear - dayOffset[i-1]); break; } else { obj.month = i; } } return obj; }, adjustForTimeZone : function (obj, date) { var offset; if (obj.zone.toUpperCase() === "Z" || (obj.zone_hours === 0 && obj.zone_minutes === 0)) { // it's UTC/GML so work out the current timeszone offset offset = -date.getTimezoneOffset(); } else { offset = (obj.zone_hours*60) + (obj.zone_minutes || 0); if (obj.zone_sign === "+") { offset *= -1; } offset -= date.getTimezoneOffset(); } date.setMinutes(date.getMinutes()+offset); return date; }, setDefaults : function (obj) { obj.year = obj.year || Date.today().getFullYear(); obj.hours = obj.hours || 0; obj.minutes = obj.minutes || 0; obj.seconds = obj.seconds || 0; obj.milliseconds = obj.milliseconds || 0; if (!(!obj.month && (obj.week || obj.dayOfYear))) { // if we have a month, or if we don't but don't have the day calculation data obj.month = obj.month || 0; obj.day = obj.day || 1; } return obj; }, dataNum: function (data, mod, explict, postProcess) { var dataNum = data*1; if (mod) { if (postProcess) { return data ? mod(data)*1 : data; } else { return data ? mod(dataNum) : data; } } else if (!explict){ return data ? dataNum : data; } else { return (data && typeof data !== "undefined") ? dataNum : data; } }, timeDataProcess: function (obj) { var timeObj = {}; for (var x in obj.data) { if (obj.data.hasOwnProperty(x)) { timeObj[x] = obj.ignore[x] ? obj.data[x] : utils.dataNum(obj.data[x], obj.mods[x], obj.explict[x], obj.postProcess[x]); } } if (obj.data.secmins) { obj.data.secmins = obj.data.secmins.replace(",", ".") * 60; if (!timeObj.minutes) { timeObj.minutes = obj.data.secmins; } else if (!timeObj.seconds) { timeObj.seconds = obj.data.secmins; } delete obj.secmins; } return timeObj; }, buildTimeObjectFromData: function (data) { var time = utils.timeDataProcess({ data: { year : data[1], month : data[5], day : data[7], week : data[8], dayOfYear : data[10], hours : data[15], zone_hours : data[23], zone_minutes : data[24], zone : data[21], zone_sign : data[22], weekDay : data[9], minutes: data[16], seconds: data[19], milliseconds: data[20], secmins: data[18] }, mods: { month: function(data) { return data-1; }, weekDay: function (data) { data = Math.abs(data); return (data === 7 ? 0 : data); }, minutes: function (data) { return data.replace(":",""); }, seconds: function (data) { return Math.floor( (data.replace(":","").replace(",","."))*1 ); }, milliseconds: function (data) { return (data.replace(",",".")*1000); } }, postProcess: { minutes: true, seconds: true, milliseconds: true }, explict: { zone_hours: true, zone_minutes: true }, ignore: { zone: true, zone_sign: true, secmins: true } }); return time; }, addToHash: function (hash, keys, data) { keys = keys; data = data; var len = keys.length; for (var i = 0; i < len; i++) { hash[keys[i]] = data[i]; } return hash; }, combineRegex: function (r1, r2) { return new RegExp("(("+r1.source+")\\s("+r2.source+"))"); }, getDateNthString: function(add, last, inc){ if (add) { return Date.today().addDays(inc).toString("d"); } else if (last) { return Date.today().last()[inc]().toString("d"); } }, buildRegexData: function (array) { var arr = []; var len = array.length; for (var i=0; i < len; i++) { if (Object.prototype.toString.call(array[i]) === '[object Array]') { // oldIE compat version of Array.isArray arr.push(this.combineRegex(array[i][0], array[i][1])); } else { arr.push(array[i]); } } return arr; } }; $P.processTimeObject = function (obj) { var date, dayOffset; utils.setDefaults(obj); dayOffset = ($P.isLeapYear(obj.year)) ? dayOffsets.leap : dayOffsets.standard; if (!obj.month && (obj.week || obj.dayOfYear)) { utils.getDayOfYear(obj, dayOffset); } else { obj.dayOfYear = dayOffset[obj.month] + obj.day; } date = new Date(obj.year, obj.month, obj.day, obj.hours, obj.minutes, obj.seconds, obj.milliseconds); if (obj.zone) { utils.adjustForTimeZone(obj, date); // adjust (and calculate) for timezone } return date; }; $P.ISO = { regex : /^([\+-]?\d{4}(?!\d{2}\b))((-?)((0[1-9]|1[0-2])(\3([12]\d|0[1-9]|3[01]))?|W([0-4]\d|5[0-3])(-?[1-7])?|(00[1-9]|0[1-9]\d|[12]\d{2}|3([0-5]\d|6[1-6])))([T\s]((([01]\d|2[0-4])((:?)[0-5]\d)?|24\:?00)([\.,]\d+(?!:))?)?(\17[0-5]\d([\.,]\d+)?)?\s?([zZ]|([\+-])([01]\d|2[0-3]):?([0-5]\d)?)?)?)?$/, parse : function (s) { var time, data = s.match(this.regex); if (!data || !data.length) { return null; } time = utils.buildTimeObjectFromData(data); if (!time.year || (!time.year && (!time.month && !time.day) && (!time.week && !time.dayOfYear)) ) { return null; } return $P.processTimeObject(time); } }; $P.Numeric = { isNumeric: function (e){return!isNaN(parseFloat(e))&&isFinite(e);}, regex: /\b([0-1]?[0-9])([0-3]?[0-9])([0-2]?[0-9]?[0-9][0-9])\b/i, parse: function (s) { var data, i, time = {}, order = Date.CultureInfo.dateElementOrder.split(""); if (!(this.isNumeric(s)) || // if it's non-numeric OR (s[0] === "+" && s[0] === "-")) { // It's an arithmatic string (eg +/-1000) return null; } if (s.length < 5 && s.indexOf(".") < 0 && s.indexOf("/") < 0) { // assume it's just a year. time.year = s; return $P.processTimeObject(time); } data = s.match(this.regex); if (!data || !data.length) { return null; } for (i=0; i < order.length; i++) { switch(order[i]) { case "d": time.day = data[i+1]; break; case "m": time.month = (data[i+1]-1); break; case "y": time.year = data[i+1]; break; } } return $P.processTimeObject(time); } }; $P.Normalizer = { regexData: function () { var $R = Date.CultureInfo.regexPatterns; return utils.buildRegexData([ $R.tomorrow, $R.yesterday, [$R.past, $R.mon], [$R.past, $R.tue], [$R.past, $R.wed], [$R.past, $R.thu], [$R.past, $R.fri], [$R.past, $R.sat], [$R.past, $R.sun] ]); }, basicReplaceHash : function() { var $R = Date.CultureInfo.regexPatterns; return { "January": $R.jan.source, "February": $R.feb, "March": $R.mar, "April": $R.apr, "May": $R.may, "June": $R.jun, "July": $R.jul, "August": $R.aug, "September": $R.sep, "October": $R.oct, "November": $R.nov, "December": $R.dec, "": /\bat\b/gi, " ": /\s{2,}/, "am": $R.inTheMorning, "9am": $R.thisMorning, "pm": $R.inTheEvening, "7pm":$R.thisEvening }; }, keys : function(){ return [ utils.getDateNthString(true, false, 1), // tomorrow utils.getDateNthString(true, false, -1), // yesterday utils.getDateNthString(false, true, "monday"), //last mon utils.getDateNthString(false, true, "tuesday"), //last tues utils.getDateNthString(false, true, "wednesday"), //last wed utils.getDateNthString(false, true, "thursday"), //last thurs utils.getDateNthString(false, true, "friday"), //last fri utils.getDateNthString(false, true, "saturday"), //last sat utils.getDateNthString(false, true, "sunday") //last sun ]; }, buildRegexFunctions: function () { var $R = Date.CultureInfo.regexPatterns; var __ = Date.i18n.__; var tomorrowRE = new RegExp("(\\b\\d\\d?("+__("AM")+"|"+__("PM")+")? )("+$R.tomorrow.source.slice(1)+")", "i"); // adapted tomorrow regex for AM PM relative dates var todayRE = new RegExp($R.today.source + "(?!\\s*([+-]))\\b"); // today, but excludes the math operators (eg "today + 2h") this.replaceFuncs = [ [todayRE, function (full) { return (full.length > 1) ? Date.today().toString("d") : full; }], [tomorrowRE, function(full, m1) { var t = Date.today().addDays(1).toString("d"); return (t + " " + m1); }], [$R.amThisMorning, function(str, am){return am;}], [$R.pmThisEvening, function(str, pm){return pm;}] ]; }, buildReplaceData: function () { this.buildRegexFunctions(); this.replaceHash = utils.addToHash(this.basicReplaceHash(), this.keys(), this.regexData()); }, stringReplaceFuncs: function (s) { for (var i=0; i < this.replaceFuncs.length; i++) { s = s.replace(this.replaceFuncs[i][0], this.replaceFuncs[i][1]); } return s; }, parse: function (s) { s = this.stringReplaceFuncs(s); s = utils.multiReplace(s, this.replaceHash); try { var n = s.split(/([\s\-\.\,\/\x27]+)/); if (n.length === 3 && $P.Numeric.isNumeric(n[0]) && $P.Numeric.isNumeric(n[2]) && (n[2].length >= 4)) { // ok, so we're dealing with x/year. But that's not a full date. // This fixes wonky dateElementOrder parsing when set to dmy order. if (Date.CultureInfo.dateElementOrder[0] === "d") { s = "1/" + n[0] + "/" + n[2]; // set to 1st of month and normalize the seperator } } } catch (e) {} return s; } }; $P.Normalizer.buildReplaceData(); }()); (function () { var $P = Date.Parsing; var _ = $P.Operators = { // // Tokenizers // rtoken: function (r) { // regex token return function (s) { var mx = s.match(r); if (mx) { return ([ mx[0], s.substring(mx[0].length) ]); } else { throw new $P.Exception(s); } }; }, token: function () { // whitespace-eating token return function (s) { return _.rtoken(new RegExp("^\\s*" + s + "\\s*"))(s); }; }, stoken: function (s) { // string token return _.rtoken(new RegExp("^" + s)); }, // Atomic Operators until: function (p) { return function (s) { var qx = [], rx = null; while (s.length) { try { rx = p.call(this, s); } catch (e) { qx.push(rx[0]); s = rx[1]; continue; } break; } return [ qx, s ]; }; }, many: function (p) { return function (s) { var rx = [], r = null; while (s.length) { try { r = p.call(this, s); } catch (e) { return [ rx, s ]; } rx.push(r[0]); s = r[1]; } return [ rx, s ]; }; }, // generator operators -- see below optional: function (p) { return function (s) { var r = null; try { r = p.call(this, s); } catch (e) { return [ null, s ]; } return [ r[0], r[1] ]; }; }, not: function (p) { return function (s) { try { p.call(this, s); } catch (e) { return [null, s]; } throw new $P.Exception(s); }; }, ignore: function (p) { return p ? function (s) { var r = null; r = p.call(this, s); return [null, r[1]]; } : null; }, product: function () { var px = arguments[0], qx = Array.prototype.slice.call(arguments, 1), rx = []; for (var i = 0 ; i < px.length ; i++) { rx.push(_.each(px[i], qx)); } return rx; }, cache: function (rule) { var cache = {}, cache_length = 0, cache_keys = [], CACHE_MAX = Date.Config.CACHE_MAX || 100000, r = null; var cacheCheck = function () { if (cache_length === CACHE_MAX) { // kill several keys, don't want to have to do this all the time... for (var i=0; i < 10; i++) { var key = cache_keys.shift(); if (key) { delete cache[key]; cache_length--; } } } }; return function (s) { cacheCheck(); try { r = cache[s] = (cache[s] || rule.call(this, s)); } catch (e) { r = cache[s] = e; } cache_length++; cache_keys.push(s); if (r instanceof $P.Exception) { throw r; } else { return r; } }; }, // vector operators -- see below any: function () { var px = arguments; return function (s) { var r = null; for (var i = 0; i < px.length; i++) { if (px[i] == null) { continue; } try { r = (px[i].call(this, s)); } catch (e) { r = null; } if (r) { return r; } } throw new $P.Exception(s); }; }, each: function () { var px = arguments; return function (s) { var rx = [], r = null; for (var i = 0; i < px.length ; i++) { if (px[i] == null) { continue; } try { r = (px[i].call(this, s)); } catch (e) { throw new $P.Exception(s); } rx.push(r[0]); s = r[1]; } return [ rx, s]; }; }, all: function () { var px = arguments, _ = _; return _.each(_.optional(px)); }, // delimited operators sequence: function (px, d, c) { d = d || _.rtoken(/^\s*/); c = c || null; if (px.length === 1) { return px[0]; } return function (s) { var r = null, q = null; var rx = []; for (var i = 0; i < px.length ; i++) { try { r = px[i].call(this, s); } catch (e) { break; } rx.push(r[0]); try { q = d.call(this, r[1]); } catch (ex) { q = null; break; } s = q[1]; } if (!r) { throw new $P.Exception(s); } if (q) { throw new $P.Exception(q[1]); } if (c) { try { r = c.call(this, r[1]); } catch (ey) { throw new $P.Exception(r[1]); } } return [ rx, (r?r[1]:s) ]; }; }, // // Composite Operators // between: function (d1, p, d2) { d2 = d2 || d1; var _fn = _.each(_.ignore(d1), p, _.ignore(d2)); return function (s) { var rx = _fn.call(this, s); return [[rx[0][0], r[0][2]], rx[1]]; }; }, list: function (p, d, c) { d = d || _.rtoken(/^\s*/); c = c || null; return (p instanceof Array ? _.each(_.product(p.slice(0, -1), _.ignore(d)), p.slice(-1), _.ignore(c)) : _.each(_.many(_.each(p, _.ignore(d))), px, _.ignore(c))); }, set: function (px, d, c) { d = d || _.rtoken(/^\s*/); c = c || null; return function (s) { // r is the current match, best the current 'best' match // which means it parsed the most amount of input var r = null, p = null, q = null, rx = null, best = [[], s], last = false; // go through the rules in the given set for (var i = 0; i < px.length ; i++) { // last is a flag indicating whether this must be the last element // if there is only 1 element, then it MUST be the last one q = null; p = null; r = null; last = (px.length === 1); // first, we try simply to match the current pattern // if not, try the next pattern try { r = px[i].call(this, s); } catch (e) { continue; } // since we are matching against a set of elements, the first // thing to do is to add r[0] to matched elements rx = [[r[0]], r[1]]; // if we matched and there is still input to parse and // we don't already know this is the last element, // we're going to next check for the delimiter ... // if there's none, or if there's no input left to parse // than this must be the last element after all ... if (r[1].length > 0 && ! last) { try { q = d.call(this, r[1]); } catch (ex) { last = true; } } else { last = true; } // if we parsed the delimiter and now there's no more input, // that means we shouldn't have parsed the delimiter at all // so don't update r and mark this as the last element ... if (!last && q[1].length === 0) { last = true; } // so, if this isn't the last element, we're going to see if // we can get any more matches from the remaining (unmatched) // elements ... if (!last) { // build a list of the remaining rules we can match against, // i.e., all but the one we just matched against var qx = []; for (var j = 0; j < px.length ; j++) { if (i !== j) { qx.push(px[j]); } } // now invoke recursively set with the remaining input // note that we don't include the closing delimiter ... // we'll check for that ourselves at the end p = _.set(qx, d).call(this, q[1]); // if we got a non-empty set as a result ... // (otw rx already contains everything we want to match) if (p[0].length > 0) { // update current result, which is stored in rx ... // basically, pick up the remaining text from p[1] // and concat the result from p[0] so that we don't // get endless nesting ... rx[0] = rx[0].concat(p[0]); rx[1] = p[1]; } } // at this point, rx either contains the last matched element // or the entire matched set that starts with this element. // now we just check to see if this variation is better than // our best so far, in terms of how much of the input is parsed if (rx[1].length < best[1].length) { best = rx; } // if we've parsed all the input, then we're finished if (best[1].length === 0) { break; } } // so now we've either gone through all the patterns trying them // as the initial match; or we found one that parsed the entire // input string ... // if best has no matches, just return empty set ... if (best[0].length === 0) { return best; } // if a closing delimiter is provided, then we have to check it also if (c) { // we try this even if there is no remaining input because the pattern // may well be optional or match empty input ... try { q = c.call(this, best[1]); } catch (ey) { throw new $P.Exception(best[1]); } // it parsed ... be sure to update the best match remaining input best[1] = q[1]; } // if we're here, either there was no closing delimiter or we parsed it // so now we have the best match; just return it! return best; }; }, forward: function (gr, fname) { return function (s) { return gr[fname].call(this, s); }; }, // // Translation Operators // replace: function (rule, repl) { return function (s) { var r = rule.call(this, s); return [repl, r[1]]; }; }, process: function (rule, fn) { return function (s) { var r = rule.call(this, s); return [fn.call(this, r[0]), r[1]]; }; }, min: function (min, rule) { return function (s) { var rx = rule.call(this, s); if (rx[0].length < min) { throw new $P.Exception(s); } return rx; }; } }; // Generator Operators And Vector Operators // Generators are operators that have a signature of F(R) => R, // taking a given rule and returning another rule, such as // ignore, which parses a given rule and throws away the result. // Vector operators are those that have a signature of F(R1,R2,...) => R, // take a list of rules and returning a new rule, such as each. // Generator operators are converted (via the following _generator // function) into functions that can also take a list or array of rules // and return an array of new rules as though the function had been // called on each rule in turn (which is what actually happens). // This allows generators to be used with vector operators more easily. // Example: // each(ignore(foo, bar)) instead of each(ignore(foo), ignore(bar)) // This also turns generators into vector operators, which allows // constructs like: // not(cache(foo, bar)) var _generator = function (op) { function gen() { var args = null, rx = [], px, i; if (arguments.length > 1) { args = Array.prototype.slice.call(arguments); } else if (arguments[0] instanceof Array) { args = arguments[0]; } if (args) { px = args.shift(); if (px.length > 0) { args.unshift(px[i]); rx.push(op.apply(null, args)); args.shift(); return rx; } } else { return op.apply(null, arguments); } } return gen; }; var gx = "optional not ignore cache".split(/\s/); for (var i = 0 ; i < gx.length ; i++) { _[gx[i]] = _generator(_[gx[i]]); } var _vector = function (op) { return function () { if (arguments[0] instanceof Array) { return op.apply(null, arguments[0]); } else { return op.apply(null, arguments); } }; }; var vx = "each any all".split(/\s/); for (var j = 0 ; j < vx.length ; j++) { _[vx[j]] = _vector(_[vx[j]]); } }()); (function () { var $D = Date; var flattenAndCompact = function (ax) { var rx = []; for (var i = 0; i < ax.length; i++) { if (ax[i] instanceof Array) { rx = rx.concat(flattenAndCompact(ax[i])); } else { if (ax[i]) { rx.push(ax[i]); } } } return rx; }; var parseMeridian = function () { if (this.meridian && (this.hour || this.hour === 0)) { if (this.meridian === "a" && this.hour > 11 && Date.Config.strict24hr){ throw "Invalid hour and meridian combination"; } else if (this.meridian === "p" && this.hour < 12 && Date.Config.strict24hr){ throw "Invalid hour and meridian combination"; } else if (this.meridian === "p" && this.hour < 12) { this.hour = this.hour + 12; } else if (this.meridian === "a" && this.hour === 12) { this.hour = 0; } } }; var setDefaults = function () { var now = new Date(); if ((this.hour || this.minute) && (!this.month && !this.year && !this.day)) { this.day = now.getDate(); } if (!this.year) { this.year = now.getFullYear(); } if (!this.month && this.month !== 0) { this.month = now.getMonth(); } if (!this.day) { this.day = 1; } if (!this.hour) { this.hour = 0; } if (!this.minute) { this.minute = 0; } if (!this.second) { this.second = 0; } if (!this.millisecond) { this.millisecond = 0; } }; var finishUtils = { getToday: function () { if (this.now || "hour minute second".indexOf(this.unit) !== -1) { return new Date(); } else { return $D.today(); } }, setDaysFromWeekday: function (today, orient){ var gap; orient = orient || 1; this.unit = "day"; gap = ($D.getDayNumberFromName(this.weekday) - today.getDay()); this.days = gap ? ((gap + (orient * 7)) % 7) : (orient * 7); return this; }, setMonthsFromMonth: function (today, orient) { var gap; orient = orient || 1; this.unit = "month"; gap = (this.month - today.getMonth()); this.months = gap ? ((gap + (orient * 12)) % 12) : (orient * 12); this.month = null; return this; }, setDMYFromWeekday: function () { var d = Date[this.weekday](); this.day = d.getDate(); if (!this.month) { this.month = d.getMonth(); } this.year = d.getFullYear(); return this; }, setUnitValue: function (orient) { if (!this.value && this.operator && this.operator !== null && this[this.unit + "s"] && this[this.unit + "s"] !== null) { this[this.unit + "s"] = this[this.unit + "s"] + ((this.operator === "add") ? 1 : -1) + (this.value||0) * orient; } else if (this[this.unit + "s"] == null || this.operator != null) { if (!this.value) { this.value = 1; } this[this.unit + "s"] = this.value * orient; } }, generateDateFromWeeks: function () { var weekday = (this.weekday !== undefined) ? this.weekday : "today"; var d = Date[weekday]().addWeeks(this.weeks); if (this.now) { d.setTimeToNow(); } return d; } }; $D.Translator = { hour: function (s) { return function () { this.hour = Number(s); }; }, minute: function (s) { return function () { this.minute = Number(s); }; }, second: function (s) { return function () { this.second = Number(s); }; }, /* for ss.s format */ secondAndMillisecond: function (s) { return function () { var mx = s.match(/^([0-5][0-9])\.([0-9]{1,3})/); this.second = Number(mx[1]); this.millisecond = Number(mx[2]); }; }, meridian: function (s) { return function () { this.meridian = s.slice(0, 1).toLowerCase(); }; }, timezone: function (s) { return function () { var n = s.replace(/[^\d\+\-]/g, ""); if (n.length) { this.timezoneOffset = Number(n); } else { this.timezone = s.toLowerCase(); } }; }, day: function (x) { var s = x[0]; return function () { this.day = Number(s.match(/\d+/)[0]); if (this.day < 1) { throw "invalid day"; } }; }, month: function (s) { return function () { this.month = (s.length === 3) ? "jan feb mar apr may jun jul aug sep oct nov dec".indexOf(s)/4 : Number(s) - 1; if (this.month < 0) { throw "invalid month"; } }; }, year: function (s) { return function () { var n = Number(s); this.year = ((s.length > 2) ? n : (n + (((n + 2000) < Date.CultureInfo.twoDigitYearMax) ? 2000 : 1900))); }; }, rday: function (s) { return function () { switch (s) { case "yesterday": this.days = -1; break; case "tomorrow": this.days = 1; break; case "today": this.days = 0; break; case "now": this.days = 0; this.now = true; break; } }; }, finishExact: function (x) { var d; x = (x instanceof Array) ? x : [x]; for (var i = 0 ; i < x.length ; i++) { if (x[i]) { x[i].call(this); } } setDefaults.call(this); parseMeridian.call(this); if (this.day > $D.getDaysInMonth(this.year, this.month)) { throw new RangeError(this.day + " is not a valid value for days."); } d = new Date(this.year, this.month, this.day, this.hour, this.minute, this.second, this.millisecond); if (this.year < 100) { d.setFullYear(this.year); // means years less that 100 are process correctly. JS will parse it otherwise as 1900-1999. } if (this.timezone) { d.set({ timezone: this.timezone }); } else if (this.timezoneOffset) { d.set({ timezoneOffset: this.timezoneOffset }); } return d; }, finish: function (x) { var today, expression, orient, temp; x = (x instanceof Array) ? flattenAndCompact(x) : [ x ]; if (x.length === 0) { return null; } for (var i = 0 ; i < x.length ; i++) { if (typeof x[i] === "function") { x[i].call(this); } } if (this.now && !this.unit && !this.operator) { return new Date(); } else { today = finishUtils.getToday.call(this); } expression = !!(this.days && this.days !== null || this.orient || this.operator); orient = ((this.orient === "past" || this.operator === "subtract") ? -1 : 1); if (this.month && this.unit === "week") { this.value = this.month + 1; delete this.month; delete this.day; } if ((this.month || this.month === 0) && "year day hour minute second".indexOf(this.unit) !== -1) { if (!this.value) { this.value = this.month + 1; } this.month = null; expression = true; } if (!expression && this.weekday && !this.day && !this.days) { finishUtils.setDMYFromWeekday.call(this); } if (expression && this.weekday && this.unit !== "month" && this.unit !== "week") { finishUtils.setDaysFromWeekday.call(this, today, orient); } if (this.weekday && this.unit !== "week" && !this.day && !this.days) { temp = Date[this.weekday](); this.day = temp.getDate(); if (temp.getMonth() !== today.getMonth()) { this.month = temp.getMonth(); } } if (this.month && this.unit === "day" && this.operator) { if (!this.value) { this.value = (this.month + 1); } this.month = null; } if (this.value != null && this.month != null && this.year != null) { this.day = this.value * 1; } if (this.month && !this.day && this.value) { today.set({ day: this.value * 1 }); if (!expression) { this.day = this.value * 1; } } if (!this.month && this.value && this.unit === "month" && !this.now) { this.month = this.value; expression = true; } if (expression && (this.month || this.month === 0) && this.unit !== "year") { finishUtils.setMonthsFromMonth.call(this, today, orient); } if (!this.unit) { this.unit = "day"; } finishUtils.setUnitValue.call(this, orient); parseMeridian.call(this); if ((this.month || this.month === 0) && !this.day) { this.day = 1; } if (!this.orient && !this.operator && this.unit === "week" && this.value && !this.day && !this.month) { return Date.today().setWeek(this.value); } if (this.unit === "week" && this.weeks && !this.day && !this.month) { return finishUtils.generateDateFromWeeks.call(this); } if (expression && this.timezone && this.day && this.days) { this.day = this.days; } if (expression){ today.add(this); } else { today.set(this); } if (this.timezone) { this.timezone = this.timezone.toUpperCase(); var offset = $D.getTimezoneOffset(this.timezone); var timezone; if (today.hasDaylightSavingTime()) { // lets check that we're being sane with timezone setting timezone = $D.getTimezoneAbbreviation(offset, today.isDaylightSavingTime()); if (timezone !== this.timezone) { // bugger, we're in a place where things like EST vs EDT matters. if (today.isDaylightSavingTime()) { today.addHours(-1); } else { today.addHours(1); } } } today.setTimezoneOffset(offset); } return today; } }; }()); (function () { var $D = Date; $D.Grammar = {}; var _ = $D.Parsing.Operators, g = $D.Grammar, t = $D.Translator, _fn; // Allow rolling up into general purpose rules _fn = function () { return _.each(_.any.apply(null, arguments), _.not(g.ctoken2("timeContext"))); }; g.datePartDelimiter = _.rtoken(/^([\s\-\.\,\/\x27]+)/); g.timePartDelimiter = _.stoken(":"); g.whiteSpace = _.rtoken(/^\s*/); g.generalDelimiter = _.rtoken(/^(([\s\,]|at|@|on)+)/); var _C = {}; g.ctoken = function (keys) { var fn = _C[keys]; if (! fn) { var c = Date.CultureInfo.regexPatterns; var kx = keys.split(/\s+/), px = []; for (var i = 0; i < kx.length ; i++) { px.push(_.replace(_.rtoken(c[kx[i]]), kx[i])); } fn = _C[keys] = _.any.apply(null, px); } return fn; }; g.ctoken2 = function (key) { return _.rtoken(Date.CultureInfo.regexPatterns[key]); }; var cacheProcessRtoken = function (key, token, type, eachToken) { if (eachToken) { g[key] = _.cache(_.process(_.each(_.rtoken(token),_.optional(g.ctoken2(eachToken))), type)); } else { g[key] = _.cache(_.process(_.rtoken(token), type)); } }; var cacheProcessCtoken = function (token, type) { return _.cache(_.process(g.ctoken2(token), type)); }; var _F = {}; //function cache var _get = function (f) { _F[f] = (_F[f] || g.format(f)[0]); return _F[f]; }; g.allformats = function (fx) { var rx = []; if (fx instanceof Array) { for (var i = 0; i < fx.length; i++) { rx.push(_get(fx[i])); } } else { rx.push(_get(fx)); } return rx; }; g.formats = function (fx) { if (fx instanceof Array) { var rx = []; for (var i = 0 ; i < fx.length ; i++) { rx.push(_get(fx[i])); } return _.any.apply(null, rx); } else { return _get(fx); } }; var grammarFormats = { timeFormats: function(){ var i, RTokenKeys = [ "h", "hh", "H", "HH", "m", "mm", "s", "ss", "ss.s", "z", "zz" ], RToken = [ /^(0[0-9]|1[0-2]|[1-9])/, /^(0[0-9]|1[0-2])/, /^([0-1][0-9]|2[0-3]|[0-9])/, /^([0-1][0-9]|2[0-3])/, /^([0-5][0-9]|[0-9])/, /^[0-5][0-9]/, /^([0-5][0-9]|[0-9])/, /^[0-5][0-9]/, /^[0-5][0-9]\.[0-9]{1,3}/, /^((\+|\-)\s*\d\d\d\d)|((\+|\-)\d\d\:?\d\d)/, /^((\+|\-)\s*\d\d\d\d)|((\+|\-)\d\d\:?\d\d)/ ], tokens = [ t.hour, t.hour, t.hour, t.hour, t.minute, t.minute, t.second, t.second, t.secondAndMillisecond, t.timezone, t.timezone ]; for (i=0; i < RTokenKeys.length; i++) { cacheProcessRtoken(RTokenKeys[i], RToken[i], tokens[i]); } g.hms = _.cache(_.sequence([g.H, g.m, g.s], g.timePartDelimiter)); g.t = cacheProcessCtoken("shortMeridian", t.meridian); g.tt = cacheProcessCtoken("longMeridian", t.meridian); g.zzz = cacheProcessCtoken("timezone", t.timezone); g.timeSuffix = _.each(_.ignore(g.whiteSpace), _.set([ g.tt, g.zzz ])); g.time = _.each(_.optional(_.ignore(_.stoken("T"))), g.hms, g.timeSuffix); }, dateFormats: function () { // pre-loaded rules for different date part order preferences var _setfn = function () { return _.set(arguments, g.datePartDelimiter); }; var i, RTokenKeys = [ "d", "dd", "M", "MM", "y", "yy", "yyy", "yyyy" ], RToken = [ /^([0-2]\d|3[0-1]|\d)/, /^([0-2]\d|3[0-1])/, /^(1[0-2]|0\d|\d)/, /^(1[0-2]|0\d)/, /^(\d+)/, /^(\d\d)/, /^(\d\d?\d?\d?)/, /^(\d\d\d\d)/ ], tokens = [ t.day, t.day, t.month, t.month, t.year, t.year, t.year, t.year ], eachToken = [ "ordinalSuffix", "ordinalSuffix" ]; for (i=0; i < RTokenKeys.length; i++) { cacheProcessRtoken(RTokenKeys[i], RToken[i], tokens[i], eachToken[i]); } g.MMM = g.MMMM = _.cache(_.process(g.ctoken("jan feb mar apr may jun jul aug sep oct nov dec"), t.month)); g.ddd = g.dddd = _.cache(_.process(g.ctoken("sun mon tue wed thu fri sat"), function (s) { return function () { this.weekday = s; }; } )); g.day = _fn(g.d, g.dd); g.month = _fn(g.M, g.MMM); g.year = _fn(g.yyyy, g.yy); g.mdy = _setfn(g.ddd, g.month, g.day, g.year); g.ymd = _setfn(g.ddd, g.year, g.month, g.day); g.dmy = _setfn(g.ddd, g.day, g.month, g.year); g.date = function (s) { return ((g[Date.CultureInfo.dateElementOrder] || g.mdy).call(this, s)); }; }, relative: function () { // relative date / time expressions g.orientation = _.process(g.ctoken("past future"), function (s) { return function () { this.orient = s; }; } ); g.operator = _.process(g.ctoken("add subtract"), function (s) { return function () { this.operator = s; }; } ); g.rday = _.process(g.ctoken("yesterday tomorrow today now"), t.rday); g.unit = _.process(g.ctoken("second minute hour day week month year"), function (s) { return function () { this.unit = s; }; } ); } }; g.buildGrammarFormats = function () { // these need to be rebuilt every time the language changes. _C = {}; grammarFormats.timeFormats(); grammarFormats.dateFormats(); grammarFormats.relative(); g.value = _.process(_.rtoken(/^([-+]?\d+)?(st|nd|rd|th)?/), function (s) { return function () { this.value = s.replace(/\D/g, ""); }; } ); g.expression = _.set([g.rday, g.operator, g.value, g.unit, g.orientation, g.ddd, g.MMM ]); g.format = _.process(_.many( _.any( // translate format specifiers into grammar rules _.process( _.rtoken(/^(dd?d?d?(?!e)|MM?M?M?|yy?y?y?|hh?|HH?|mm?|ss?|tt?|zz?z?)/), function (fmt) { if (g[fmt]) { return g[fmt]; } else { throw $D.Parsing.Exception(fmt); } } ), // translate separator tokens into token rules _.process(_.rtoken(/^[^dMyhHmstz]+/), // all legal separators function (s) { return _.ignore(_.stoken(s)); } ) ) ), // construct the parser ... function (rules) { return _.process(_.each.apply(null, rules), t.finishExact); } ); // starting rule for general purpose grammar g._start = _.process(_.set([ g.date, g.time, g.expression ], g.generalDelimiter, g.whiteSpace), t.finish); }; g.buildGrammarFormats(); // parsing date format specifiers - ex: "h:m:s tt" // this little guy will generate a custom parser based // on the format string, ex: g.format("h:m:s tt") // check for these formats first g._formats = g.formats([ "\"yyyy-MM-ddTHH:mm:ssZ\"", "yyyy-MM-ddTHH:mm:ss.sz", "yyyy-MM-ddTHH:mm:ssZ", "yyyy-MM-ddTHH:mm:ssz", "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-ddTHH:mmZ", "yyyy-MM-ddTHH:mmz", "yyyy-MM-ddTHH:mm", "ddd, MMM dd, yyyy H:mm:ss tt", "ddd MMM d yyyy HH:mm:ss zzz", "MMddyyyy", "ddMMyyyy", "Mddyyyy", "ddMyyyy", "Mdyyyy", "dMyyyy", "yyyy", "Mdyy", "dMyy", "d" ]); // real starting rule: tries selected formats first, // then general purpose rule g.start = function (s) { try { var r = g._formats.call({}, s); if (r[1].length === 0) { return r; } } catch (e) {} return g._start.call({}, s); }; }()); (function () { var $D = Date; /** * @desc Converts the specified string value into its JavaScript Date equivalent using CultureInfo specific format information. * * Example

	///////////
	// Dates //
	///////////

	// 15-Oct-2004
	var d1 = Date.parse("10/15/2004");

	// 15-Oct-2004
	var d1 = Date.parse("15-Oct-2004");

	// 15-Oct-2004
	var d1 = Date.parse("2004.10.15");

	//Fri Oct 15, 2004
	var d1 = Date.parse("Fri Oct 15, 2004");

	///////////
	// Times //
	///////////

	// Today at 10 PM.
	var d1 = Date.parse("10 PM");

	// Today at 10:30 PM.
	var d1 = Date.parse("10:30 P.M.");

	// Today at 6 AM.
	var d1 = Date.parse("06am");

	/////////////////////
	// Dates and Times //
	/////////////////////

	// 8-July-2004 @ 10:30 PM
	var d1 = Date.parse("July 8th, 2004, 10:30 PM");

	// 1-July-2004 @ 10:30 PM
	var d1 = Date.parse("2004-07-01T22:30:00");

	////////////////////
	// Relative Dates //
	////////////////////

	// Returns today's date. The string "today" is culture specific.
	var d1 = Date.parse("today");

	// Returns yesterday's date. The string "yesterday" is culture specific.
	var d1 = Date.parse("yesterday");

	// Returns the date of the next thursday.
	var d1 = Date.parse("Next thursday");

	// Returns the date of the most previous monday.
	var d1 = Date.parse("last monday");

	// Returns today's day + one year.
	var d1 = Date.parse("next year");

	///////////////
	// Date Math //
	///////////////

	// Today + 2 days
	var d1 = Date.parse("t+2");

	// Today + 2 days
	var d1 = Date.parse("today + 2 days");

	// Today + 3 months
	var d1 = Date.parse("t+3m");

	// Today - 1 year
	var d1 = Date.parse("today - 1 year");

	// Today - 1 year
	var d1 = Date.parse("t-1y"); 


	/////////////////////////////
	// Partial Dates and Times //
	/////////////////////////////

	// July 15th of this year.
	var d1 = Date.parse("July 15");

	// 15th day of current day and year.
	var d1 = Date.parse("15");

	// July 1st of current year at 10pm.
	var d1 = Date.parse("7/1 10pm");
	
* * @param {String} The string value to convert into a Date object [Required] * @return {Date} A Date object or null if the string cannot be converted into a Date. */ var parseUtils = { removeOrds: function (s) { ords = s.match(/\b(\d+)(?:st|nd|rd|th)\b/); // find ordinal matches s = ((ords && ords.length === 2) ? s.replace(ords[0], ords[1]) : s); return s; }, grammarParser: function (s) { var r = null; try { r = $D.Grammar.start.call({}, s.replace(/^\s*(\S*(\s+\S+)*)\s*$/, "$1")); } catch (e) { return null; } return ((r[1].length === 0) ? r[0] : null); }, nativeFallback: function(s) { var t; try { // ok we haven't parsed it, last ditch attempt with the built-in parser. t = Date._parse(s); return (t || t === 0) ? new Date(t) : null; } catch (e) { return null; } } }; function parse (s) { var d; if (!s) { return null; } if (s instanceof Date) { return s.clone(); } if (s.length >= 4 && s.charAt(0) !== "0" && s.charAt(0) !== "+"&& s.charAt(0) !== "-") { // ie: 2004 will pass, 0800 won't. // Start with specific formats d = $D.Parsing.ISO.parse(s) || $D.Parsing.Numeric.parse(s); } if (d instanceof Date && !isNaN(d.getTime())) { return d; } else { // find ordinal dates (1st, 3rd, 8th, etc and remove them as they cause parsing issues) s = $D.Parsing.Normalizer.parse(parseUtils.removeOrds(s)); d = parseUtils.grammarParser(s); if (d !== null) { return d; } else { return parseUtils.nativeFallback(s); } } } if (!$D._parse) { $D._parse = $D.parse; } $D.parse = parse; Date.getParseFunction = function (fx) { var fns = Date.Grammar.allformats(fx); return function (s) { var r = null; for (var i = 0; i < fns.length; i++) { try { r = fns[i].call({}, s); } catch (e) { continue; } if (r[1].length === 0) { return r[0]; } } return null; }; }; /** * Converts the specified string value into its JavaScript Date equivalent using the specified format {String} or formats {Array} and the CultureInfo specific format information. * The format of the string value must match one of the supplied formats exactly. * * Example

	// 15-Oct-2004
	var d1 = Date.parseExact("10/15/2004", "M/d/yyyy");

	// 15-Oct-2004
	var d1 = Date.parse("15-Oct-2004", "M-ddd-yyyy");

	// 15-Oct-2004
	var d1 = Date.parse("2004.10.15", "yyyy.MM.dd");

	// Multiple formats
	var d1 = Date.parseExact("10/15/2004", ["M/d/yyyy", "MMMM d, yyyy"]);
	
* * @param {String} The string value to convert into a Date object [Required]. * @param {Object} The expected format {String} or an array of expected formats {Array} of the date string [Required]. * @return {Date} A Date object or null if the string cannot be converted into a Date. */ $D.parseExact = function (s, fx) { return $D.getParseFunction(fx)(s); }; }()); (function () { var $D = Date, $P = $D.prototype, // $C = $D.CultureInfo, // not used atm p = function (s, l) { if (!l) { l = 2; } return ("000" + s).slice(l * -1); }; /** * Converts a PHP format string to Java/.NET format string. * A PHP format string can be used with ._format or .format. * A Java/.NET format string can be used with .toString(). * The .parseExact function will only accept a Java/.NET format string * * Example * var f1 = "%m/%d/%y" * var f2 = Date.normalizeFormat(f1); // "MM/dd/yy" * * new Date().format(f1); // "04/13/08" * new Date()._format(f1); // "04/13/08" * new Date().toString(f2); // "04/13/08" * * var date = Date.parseExact("04/13/08", f2); // Sun Apr 13 2008 * * @param {String} A PHP format string consisting of one or more format spcifiers. * @return {String} The PHP format converted to a Java/.NET format string. */ var normalizerSubstitutions = { "d" : "dd", "%d": "dd", "D" : "ddd", "%a": "ddd", "j" : "dddd", "l" : "dddd", "%A": "dddd", "S" : "S", "F" : "MMMM", "%B": "MMMM", "m" : "MM", "%m": "MM", "M" : "MMM", "%b": "MMM", "%h": "MMM", "n" : "M", "Y" : "yyyy", "%Y": "yyyy", "y" : "yy", "%y": "yy", "g" : "h", "%I": "h", "G" : "H", "h" : "hh", "H" : "HH", "%H": "HH", "i" : "mm", "%M": "mm", "s" : "ss", "%S": "ss", "%r": "hh:mm tt", "%R": "H:mm", "%T": "H:mm:ss", "%X": "t", "%x": "d", "%e": "d", "%D": "MM/dd/yy", "%n": "\\n", "%t": "\\t", "e" : "z", "T" : "z", "%z": "z", "%Z": "z", "Z" : "ZZ", "N" : "u", "w" : "u", "%w": "u", "W" : "W", "%V": "W" }; var normalizer = { substitutes: function (m) { return normalizerSubstitutions[m]; }, interpreted: function (m, x) { var y; switch (m) { case "%u": return x.getDay() + 1; case "z": return x.getOrdinalNumber(); case "%j": return p(x.getOrdinalNumber(), 3); case "%U": var d1 = x.clone().set({month: 0, day: 1}).addDays(-1).moveToDayOfWeek(0), d2 = x.clone().addDays(1).moveToDayOfWeek(0, -1); return (d2 < d1) ? "00" : p((d2.getOrdinalNumber() - d1.getOrdinalNumber()) / 7 + 1); case "%W": return p(x.getWeek()); case "t": return $D.getDaysInMonth(x.getFullYear(), x.getMonth()); case "o": case "%G": return x.setWeek(x.getISOWeek()).toString("yyyy"); case "%g": return x._format("%G").slice(-2); case "a": case "%p": return t("tt").toLowerCase(); case "A": return t("tt").toUpperCase(); case "u": return p(x.getMilliseconds(), 3); case "I": return (x.isDaylightSavingTime()) ? 1 : 0; case "O": return x.getUTCOffset(); case "P": y = x.getUTCOffset(); return y.substring(0, y.length - 2) + ":" + y.substring(y.length - 2); case "B": var now = new Date(); return Math.floor(((now.getHours() * 3600) + (now.getMinutes() * 60) + now.getSeconds() + (now.getTimezoneOffset() + 60) * 60) / 86.4); case "c": return x.toISOString().replace(/\"/g, ""); case "U": return $D.strtotime("now"); case "%c": return t("d") + " " + t("t"); case "%C": return Math.floor(x.getFullYear() / 100 + 1); } }, shouldOverrideDefaults: function (m) { switch (m) { case "%e": return true; default: return false; } }, parse: function (m, context) { var formatString, c = context || new Date(); formatString = normalizer.substitutes(m); if (formatString) { return formatString; } formatString = normalizer.interpreted(m, c); if (formatString) { return formatString; } else { return m; } } }; $D.normalizeFormat = function (format, context) { return format.replace(/(%|\\)?.|%%/g, function(t){ return normalizer.parse(t, context); }); }; /** * Format a local Unix timestamp according to locale settings * * Example: * Date.strftime("%m/%d/%y", new Date()); // "04/13/08" * Date.strftime("c", "2008-04-13T17:52:03Z"); // "04/13/08" * * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @param {Number|String} The number representing the number of seconds that have elapsed since January 1, 1970 (local time). * @return {String} A string representation of the current Date object. */ $D.strftime = function (format, time) { var d = Date.parse(time); return d._format(format); }; /** * Parse any textual datetime description into a Unix timestamp. * A Unix timestamp is the number of seconds that have elapsed since January 1, 1970 (midnight UTC/GMT). * * Example: * Date.strtotime("04/13/08"); // 1208044800 * Date.strtotime("1970-01-01T00:00:00Z"); // 0 * * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @param {Object} A string or date object. * @return {String} A string representation of the current Date object. */ $D.strtotime = function (time) { var d = $D.parse(time); return Math.round($D.UTC(d.getUTCFullYear(), d.getUTCMonth(), d.getUTCDate(), d.getUTCHours(), d.getUTCMinutes(), d.getUTCSeconds(), d.getUTCMilliseconds()) / 1000); }; /** * Converts the value of the current Date object to its equivalent string representation using a PHP/Unix style of date format specifiers. * Format Specifiers * Format Description Example * ------ --------------------------------------------------------------------------- ----------------------- * %a abbreviated weekday name according to the current localed "Mon" through "Sun" * %A full weekday name according to the current localed "Sunday" through "Saturday" * %b abbreviated month name according to the current localed "Jan" through "Dec" * %B full month name according to the current locale "January" through "December" * %c preferred date and time representation for the current locale "4/13/2008 12:33 PM" * %C century number (the year divided by 100 and truncated to an integer) "00" to "99" * %d day of the month as a decimal number "01" to "31" * %D same as %m/%d/%y "04/13/08" * %e day of the month as a decimal number, a single digit is preceded by a space "1" to "31" * %g like %G, but without the century "08" * %G The 4-digit year corresponding to the ISO week number (see %V). "2008" * This has the same format and value as %Y, except that if the ISO week number * belongs to the previous or next year, that year is used instead. * %h same as %b "Jan" through "Dec" * %H hour as a decimal number using a 24-hour clock. "00" to "23" * %I hour as a decimal number using a 12-hour clock. "01" to "12" * %j day of the year as a decimal number. "001" to "366" * %m month as a decimal number. "01" to "12" * %M minute as a decimal number. "00" to "59" * %n newline character "\n" * %p either "am" or "pm" according to the given time value, or the "am" or "pm" * corresponding strings for the current locale. * %r time in a.m. and p.m. notation "8:44 PM" * %R time in 24 hour notation "20:44" * %S second as a decimal number "00" to "59" * %t tab character "\t" * %T current time, equal to %H:%M:%S "12:49:11" * %u weekday as a decimal number ["1", "7"], with "1" representing Monday "1" to "7" * %U week number of the current year as a decimal number, starting with the "0" to ("52" or "53") * first Sunday as the first day of the first week * %V The ISO 8601:1988 week number of the current year as a decimal number, "00" to ("52" or "53") * range 01 to 53, where week 1 is the first week that has at least 4 days * in the current year, and with Monday as the first day of the week. * (Use %G or %g for the year component that corresponds to the week number * for the specified timestamp.) * %W week number of the current year as a decimal number, starting with the "00" to ("52" or "53") * first Monday as the first day of the first week * %w day of the week as a decimal, Sunday being "0" "0" to "6" * %x preferred date representation for the current locale without the time "4/13/2008" * %X preferred time representation for the current locale without the date "12:53:05" * %y year as a decimal number without a century "00" "99" * %Y year as a decimal number including the century "2008" * %Z time zone or name or abbreviation "UTC", "EST", "PST" * %z same as %Z * %% a literal "%" characters "%" * d Day of the month, 2 digits with leading zeros "01" to "31" * D A textual representation of a day, three letters "Mon" through "Sun" * j Day of the month without leading zeros "1" to "31" * l A full textual representation of the day of the week (lowercase "L") "Sunday" through "Saturday" * N ISO-8601 numeric representation of the day of the week (added in PHP 5.1.0) "1" (for Monday) through "7" (for Sunday) * S English ordinal suffix for the day of the month, 2 characters "st", "nd", "rd" or "th". Works well with j * w Numeric representation of the day of the week "0" (for Sunday) through "6" (for Saturday) * z The day of the year (starting from "0") "0" through "365" * W ISO-8601 week number of year, weeks starting on Monday "00" to ("52" or "53") * F A full textual representation of a month, such as January or March "January" through "December" * m Numeric representation of a month, with leading zeros "01" through "12" * M A short textual representation of a month, three letters "Jan" through "Dec" * n Numeric representation of a month, without leading zeros "1" through "12" * t Number of days in the given month "28" through "31" * L Whether it's a leap year "1" if it is a leap year, "0" otherwise * o ISO-8601 year number. This has the same value as Y, except that if the "2008" * ISO week number (W) belongs to the previous or next year, that year * is used instead. * Y A full numeric representation of a year, 4 digits "2008" * y A two digit representation of a year "08" * a Lowercase Ante meridiem and Post meridiem "am" or "pm" * A Uppercase Ante meridiem and Post meridiem "AM" or "PM" * B Swatch Internet time "000" through "999" * g 12-hour format of an hour without leading zeros "1" through "12" * G 24-hour format of an hour without leading zeros "0" through "23" * h 12-hour format of an hour with leading zeros "01" through "12" * H 24-hour format of an hour with leading zeros "00" through "23" * i Minutes with leading zeros "00" to "59" * s Seconds, with leading zeros "00" through "59" * u Milliseconds "54321" * e Timezone identifier "UTC", "EST", "PST" * I Whether or not the date is in daylight saving time (uppercase i) "1" if Daylight Saving Time, "0" otherwise * O Difference to Greenwich time (GMT) in hours "+0200", "-0600" * P Difference to Greenwich time (GMT) with colon between hours and minutes "+02:00", "-06:00" * T Timezone abbreviation "UTC", "EST", "PST" * Z Timezone offset in seconds. The offset for timezones west of UTC is "-43200" through "50400" * always negative, and for those east of UTC is always positive. * c ISO 8601 date "2004-02-12T15:19:21+00:00" * r RFC 2822 formatted date "Thu, 21 Dec 2000 16:01:07 +0200" * U Seconds since the Unix Epoch (January 1 1970 00:00:00 GMT) "0" * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @return {String} A string representation of the current Date object. */ var formatReplace = function (context) { return function (m) { var formatString, override = false; if (m.charAt(0) === "\\" || m.substring(0, 2) === "%%") { return m.replace("\\", "").replace("%%", "%"); } override = normalizer.shouldOverrideDefaults(m); formatString = $D.normalizeFormat(m, context); if (formatString) { return context.toString(formatString, override); } }; }; $P._format = function (format) { var formatter = formatReplace(this); if (!format) { return this._toString(); } else { return format.replace(/(%|\\)?.|%%/g, formatter); } }; if (!$P.format) { $P.format = $P._format; } }()); (function () { "use strict"; var gFn = function (attr) { return function () { return this[attr]; }; }; var sFn = function (attr) { return function (val) { this[attr] = val; return this; }; }; var attrs = ["years", "months", "days", "hours", "minutes", "seconds", "milliseconds"]; var addSetFuncs = function (context, attrs) { for (var i = 0; i < attrs.length ; i++) { var $a = attrs[i], $b = $a.slice(0, 1).toUpperCase() + $a.slice(1); context.prototype[$a] = 0; context.prototype["get" + $b] = gFn($a); context.prototype["set" + $b] = sFn($a); } }; /** * new TimeSpan(milliseconds); * new TimeSpan(days, hours, minutes, seconds); * new TimeSpan(days, hours, minutes, seconds, milliseconds); */ var TimeSpan = function (days, hours, minutes, seconds, milliseconds) { if (arguments.length === 1 && typeof days === "number") { var orient = (days < 0) ? -1 : +1; var millsLeft = Math.abs(days); this.setDays(Math.floor(millsLeft / 86400000) * orient); millsLeft = millsLeft % 86400000; this.setHours(Math.floor(millsLeft / 3600000) * orient); millsLeft = millsLeft % 3600000; this.setMinutes(Math.floor(millsLeft / 60000) * orient); millsLeft = millsLeft % 60000; this.setSeconds(Math.floor(millsLeft / 1000) * orient); millsLeft = millsLeft % 1000; this.setMilliseconds(millsLeft * orient); } else { this.set(days, hours, minutes, seconds, milliseconds); } this.getTotalMilliseconds = function () { return (this.getDays() * 86400000) + (this.getHours() * 3600000) + (this.getMinutes() * 60000) + (this.getSeconds() * 1000); }; this.compareTo = function (time) { var t1 = new Date(1970, 1, 1, this.getHours(), this.getMinutes(), this.getSeconds()), t2; if (time === null) { t2 = new Date(1970, 1, 1, 0, 0, 0); } else { t2 = new Date(1970, 1, 1, time.getHours(), time.getMinutes(), time.getSeconds()); } return (t1 < t2) ? -1 : (t1 > t2) ? 1 : 0; }; this.equals = function (time) { return (this.compareTo(time) === 0); }; this.add = function (time) { return (time === null) ? this : this.addSeconds(time.getTotalMilliseconds() / 1000); }; this.subtract = function (time) { return (time === null) ? this : this.addSeconds(-time.getTotalMilliseconds() / 1000); }; this.addDays = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 86400000)); }; this.addHours = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 3600000)); }; this.addMinutes = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 60000)); }; this.addSeconds = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 1000)); }; this.addMilliseconds = function (n) { return new TimeSpan(this.getTotalMilliseconds() + n); }; this.get12HourHour = function () { return (this.getHours() > 12) ? this.getHours() - 12 : (this.getHours() === 0) ? 12 : this.getHours(); }; this.getDesignator = function () { return (this.getHours() < 12) ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator; }; this.toString = function (format) { this._toString = function () { if (this.getDays() !== null && this.getDays() > 0) { return this.getDays() + "." + this.getHours() + ":" + this.p(this.getMinutes()) + ":" + this.p(this.getSeconds()); } else { return this.getHours() + ":" + this.p(this.getMinutes()) + ":" + this.p(this.getSeconds()); } }; this.p = function (s) { return (s.toString().length < 2) ? "0" + s : s; }; var me = this; return format ? format.replace(/dd?|HH?|hh?|mm?|ss?|tt?/g, function (format) { switch (format) { case "d": return me.getDays(); case "dd": return me.p(me.getDays()); case "H": return me.getHours(); case "HH": return me.p(me.getHours()); case "h": return me.get12HourHour(); case "hh": return me.p(me.get12HourHour()); case "m": return me.getMinutes(); case "mm": return me.p(me.getMinutes()); case "s": return me.getSeconds(); case "ss": return me.p(me.getSeconds()); case "t": return ((me.getHours() < 12) ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator).substring(0, 1); case "tt": return (me.getHours() < 12) ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator; } } ) : this._toString(); }; return this; }; addSetFuncs(TimeSpan, attrs.slice(2)); TimeSpan.prototype.set = function (days, hours, minutes, seconds, milliseconds){ this.setDays(days || this.getDays()); this.setHours(hours || this.getHours()); this.setMinutes(minutes || this.getMinutes()); this.setSeconds(seconds || this.getSeconds()); this.setMilliseconds(milliseconds || this.getMilliseconds()); }; /** * Gets the time of day for this date instances. * @return {TimeSpan} TimeSpan */ Date.prototype.getTimeOfDay = function () { return new TimeSpan(0, this.getHours(), this.getMinutes(), this.getSeconds(), this.getMilliseconds()); }; Date.TimeSpan = TimeSpan; if (typeof window !== "undefined" ) { // keeping API compatible for v1.x window.TimeSpan = TimeSpan; } }()); (function () { "use strict"; var attrs = ["years", "months", "days", "hours", "minutes", "seconds", "milliseconds"]; var gFn = function (attr) { return function () { return this[attr]; }; }; var sFn = function (attr) { return function (val) { this[attr] = val; return this; }; }; var addSetFuncs = function (context, attrs) { for (var i = 0; i < attrs.length ; i++) { var $a = attrs[i], $b = $a.slice(0, 1).toUpperCase() + $a.slice(1); context.prototype[$a] = 0; context.prototype["get" + $b] = gFn($a); context.prototype["set" + $b] = sFn($a); } }; var setMonthsAndYears = function (orient, d1, d2, context) { function inc() { d1.addMonths(-orient); context.months++; if (context.months === 12) { context.years++; context.months = 0; } } if (orient === +1) { while (d1 > d2) { inc(); } } else { while (d1 < d2) { inc(); } } context.months--; context.months *= orient; context.years *= orient; }; var adjustForDST = function(orient, startDate, endDate) { var hasDSTMismatch = (false === (startDate.isDaylightSavingTime() === endDate.isDaylightSavingTime())); if (hasDSTMismatch && orient === 1) { startDate.addHours(-1); } else if (hasDSTMismatch) { startDate.addHours(1); } }; /** * TimePeriod(startDate, endDate); * TimePeriod(years, months, days, hours, minutes, seconds, milliseconds); */ var TimePeriod = function (years, months, days, hours, minutes, seconds, milliseconds) { if (arguments.length === 7) { this.set(years, months, days, hours, minutes, seconds, milliseconds); } else if (arguments.length === 2 && arguments[0] instanceof Date && arguments[1] instanceof Date) { var startDate = arguments[0].clone(); var endDate = arguments[1].clone(); var orient = (startDate > endDate) ? +1 : -1; this.dates = { start: arguments[0].clone(), end: arguments[1].clone() }; setMonthsAndYears(orient, startDate, endDate, this); adjustForDST(orient, startDate, endDate); // // TODO - adjust for DST var diff = endDate - startDate; if (diff !== 0) { var ts = new TimeSpan(diff); this.set(this.years, this.months, ts.getDays(), ts.getHours(), ts.getMinutes(), ts.getSeconds(), ts.getMilliseconds()); } } return this; }; // create all the set functions. addSetFuncs(TimePeriod, attrs); TimePeriod.prototype.set = function (years, months, days, hours, minutes, seconds, milliseconds){ this.setYears(years || this.getYears()); this.setMonths(months || this.getMonths()); this.setDays(days || this.getDays()); this.setHours(hours || this.getHours()); this.setMinutes(minutes || this.getMinutes()); this.setSeconds(seconds || this.getSeconds()); this.setMilliseconds(milliseconds || this.getMilliseconds()); }; Date.TimePeriod = TimePeriod; if (typeof window !== "undefined") { // keeping API compatible for v1.x window.TimePeriod = TimePeriod; } }()); ================================================ FILE: build/date-zh-SG.js ================================================ /** * @overview datejs * @version 1.0.0-rc3 * @author Gregory Wild-Smith * @copyright 2015 Gregory Wild-Smith * @license MIT * @homepage https://github.com/abritinthebay/datejs */ /* * DateJS Culture String File * Country Code: zh-SG * Name: Chinese (Singapore) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["zh-SG"] = { "name": "zh-SG", "englishName": "Chinese (Singapore)", "nativeName": "中文(新加坡)", "Sunday": "星期日", "Monday": "星期一", "Tuesday": "星期二", "Wednesday": "星期三", "Thursday": "星期四", "Friday": "星期五", "Saturday": "星期六", "Sun": "星期日", "Mon": "星期一", "Tue": "星期二", "Wed": "星期三", "Thu": "星期四", "Fri": "星期五", "Sat": "星期六", "Su": "日", "Mo": "一", "Tu": "二", "We": "三", "Th": "四", "Fr": "五", "Sa": "六", "S_Sun_Initial": "日", "M_Mon_Initial": "一", "T_Tue_Initial": "二", "W_Wed_Initial": "三", "T_Thu_Initial": "四", "F_Fri_Initial": "五", "S_Sat_Initial": "六", "January": "一月", "February": "二月", "March": "三月", "April": "四月", "May": "五月", "June": "六月", "July": "七月", "August": "八月", "September": "九月", "October": "十月", "November": "十一月", "December": "十二月", "Jan_Abbr": "一月", "Feb_Abbr": "二月", "Mar_Abbr": "三月", "Apr_Abbr": "四月", "May_Abbr": "五月", "Jun_Abbr": "六月", "Jul_Abbr": "七月", "Aug_Abbr": "八月", "Sep_Abbr": "九月", "Oct_Abbr": "十月", "Nov_Abbr": "十一月", "Dec_Abbr": "十二月", "AM": "AM", "PM": "PM", "firstDayOfWeek": 0, "twoDigitYearMax": 2029, "mdy": "dmy", "M/d/yyyy": "d/M/yyyy", "dddd, MMMM dd, yyyy": "dddd, d MMMM, yyyy", "h:mm tt": "tt h:mm", "h:mm:ss tt": "tt h:mm:ss", "dddd, MMMM dd, yyyy h:mm:ss tt": "dddd, d MMMM, yyyy tt h:mm:ss", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "d MMMM", "MMMM, yyyy": "MMMM, yyyy", "/jan(uary)?/": "一月", "/feb(ruary)?/": "二月", "/mar(ch)?/": "三月", "/apr(il)?/": "四月", "/may/": "五月", "/jun(e)?/": "六月", "/jul(y)?/": "七月", "/aug(ust)?/": "八月", "/sep(t(ember)?)?/": "九月", "/oct(ober)?/": "十月", "/nov(ember)?/": "十一月", "/dec(ember)?/": "十二月", "/^su(n(day)?)?/": "^星期日", "/^mo(n(day)?)?/": "^星期一", "/^tu(e(s(day)?)?)?/": "^星期二", "/^we(d(nesday)?)?/": "^星期三", "/^th(u(r(s(day)?)?)?)?/": "^星期四", "/^fr(i(day)?)?/": "^星期五", "/^sa(t(urday)?)?/": "^星期六", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "zh-SG"; /** * @overview datejs * @version 1.0.0-rc3 * @author Gregory Wild-Smith * @copyright 2015 Gregory Wild-Smith * @license MIT * @homepage https://github.com/abritinthebay/datejs */(function () { var $D = Date; var lang = Date.CultureStrings ? Date.CultureStrings.lang : null; var loggedKeys = {}; // for debug purposes. var getText = { getFromKey: function (key, countryCode) { var output; if (Date.CultureStrings && Date.CultureStrings[countryCode] && Date.CultureStrings[countryCode][key]) { output = Date.CultureStrings[countryCode][key]; } else { output = getText.buildFromDefault(key); } if (key.charAt(0) === "/") { // Assume it's a regex output = getText.buildFromRegex(key, countryCode); } return output; }, getFromObjectValues: function (obj, countryCode) { var key, output = {}; for(key in obj) { if (obj.hasOwnProperty(key)) { output[key] = getText.getFromKey(obj[key], countryCode); } } return output; }, getFromObjectKeys: function (obj, countryCode) { var key, output = {}; for(key in obj) { if (obj.hasOwnProperty(key)) { output[getText.getFromKey(key, countryCode)] = obj[key]; } } return output; }, getFromArray: function (arr, countryCode) { var output = []; for (var i=0; i < arr.length; i++){ if (i in arr) { output[i] = getText.getFromKey(arr[i], countryCode); } } return output; }, buildFromDefault: function (key) { var output, length, split, last; switch(key) { case "name": output = "en-US"; break; case "englishName": output = "English (United States)"; break; case "nativeName": output = "English (United States)"; break; case "twoDigitYearMax": output = 2049; break; case "firstDayOfWeek": output = 0; break; default: output = key; split = key.split("_"); length = split.length; if (length > 1 && key.charAt(0) !== "/") { // if the key isn't a regex and it has a split. last = split[(length - 1)].toLowerCase(); if (last === "initial" || last === "abbr") { output = split[0]; } } break; } return output; }, buildFromRegex: function (key, countryCode) { var output; if (Date.CultureStrings && Date.CultureStrings[countryCode] && Date.CultureStrings[countryCode][key]) { output = new RegExp(Date.CultureStrings[countryCode][key], "i"); } else { output = new RegExp(key.replace(new RegExp("/", "g"),""), "i"); } return output; } }; var shallowMerge = function (obj1, obj2) { for (var attrname in obj2) { if (obj2.hasOwnProperty(attrname)) { obj1[attrname] = obj2[attrname]; } } }; var __ = function (key, language) { var countryCode = (language) ? language : lang; loggedKeys[key] = key; if (typeof key === "object") { if (key instanceof Array) { return getText.getFromArray(key, countryCode); } else { return getText.getFromObjectKeys(key, countryCode); } } else { return getText.getFromKey(key, countryCode); } }; var loadI18nScript = function (code) { // paatterned after jQuery's getScript. var url = Date.Config.i18n + code + ".js"; var head = document.getElementsByTagName("head")[0] || document.documentElement; var script = document.createElement("script"); script.src = url; var completed = false; var events = { done: function (){} // placeholder function }; // Attach handlers for all browsers script.onload = script.onreadystatechange = function() { if ( !completed && (!this.readyState || this.readyState === "loaded" || this.readyState === "complete") ) { events.done(); head.removeChild(script); } }; setTimeout(function() { head.insertBefore(script, head.firstChild); }, 0); // allows return to execute first return { done: function (cb) { events.done = function() { if (cb) { setTimeout(cb,0); } }; } }; }; var buildInfo = { buildFromMethodHash: function (obj) { var key; for(key in obj) { if (obj.hasOwnProperty(key)) { obj[key] = buildInfo[obj[key]](); } } return obj; }, timeZoneDST: function () { var DST = { "CHADT": "+1345", "NZDT": "+1300", "AEDT": "+1100", "ACDT": "+1030", "AZST": "+0500", "IRDT": "+0430", "EEST": "+0300", "CEST": "+0200", "BST": "+0100", "PMDT": "-0200", "ADT": "-0300", "NDT": "-0230", "EDT": "-0400", "CDT": "-0500", "MDT": "-0600", "PDT": "-0700", "AKDT": "-0800", "HADT": "-0900" }; return __(DST); }, timeZoneStandard: function () { var standard = { "LINT": "+1400", "TOT": "+1300", "CHAST": "+1245", "NZST": "+1200", "NFT": "+1130", "SBT": "+1100", "AEST": "+1000", "ACST": "+0930", "JST": "+0900", "CWST": "+0845", "CT": "+0800", "ICT": "+0700", "MMT": "+0630", "BST": "+0600", "NPT": "+0545", "IST": "+0530", "PKT": "+0500", "AFT": "+0430", "MSK": "+0400", "IRST": "+0330", "FET": "+0300", "EET": "+0200", "CET": "+0100", "GMT": "+0000", "UTC": "+0000", "CVT": "-0100", "GST": "-0200", "BRT": "-0300", "NST": "-0330", "AST": "-0400", "EST": "-0500", "CST": "-0600", "MST": "-0700", "PST": "-0800", "AKST": "-0900", "MIT": "-0930", "HST": "-1000", "SST": "-1100", "BIT": "-1200" }; return __(standard); }, timeZones: function (data) { var zone; data.timezones = []; for (zone in data.abbreviatedTimeZoneStandard) { if (data.abbreviatedTimeZoneStandard.hasOwnProperty(zone)) { data.timezones.push({ name: zone, offset: data.abbreviatedTimeZoneStandard[zone]}); } } for (zone in data.abbreviatedTimeZoneDST) { if (data.abbreviatedTimeZoneDST.hasOwnProperty(zone)) { data.timezones.push({ name: zone, offset: data.abbreviatedTimeZoneDST[zone], dst: true}); } } return data.timezones; }, days: function () { return __(["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"]); }, dayAbbr: function () { return __(["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"]); }, dayShortNames: function () { return __(["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"]); }, dayFirstLetters: function () { return __(["S_Sun_Initial", "M_Mon_Initial", "T_Tues_Initial", "W_Wed_Initial", "T_Thu_Initial", "F_Fri_Initial", "S_Sat_Initial"]); }, months: function () { return __(["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"]); }, monthAbbr: function () { return __(["Jan_Abbr", "Feb_Abbr", "Mar_Abbr", "Apr_Abbr", "May_Abbr", "Jun_Abbr", "Jul_Abbr", "Aug_Abbr", "Sep_Abbr", "Oct_Abbr", "Nov_Abbr", "Dec_Abbr"]); }, formatPatterns: function () { return getText.getFromObjectValues({ shortDate: "M/d/yyyy", longDate: "dddd, MMMM dd, yyyy", shortTime: "h:mm tt", longTime: "h:mm:ss tt", fullDateTime: "dddd, MMMM dd, yyyy h:mm:ss tt", sortableDateTime: "yyyy-MM-ddTHH:mm:ss", universalSortableDateTime: "yyyy-MM-dd HH:mm:ssZ", rfc1123: "ddd, dd MMM yyyy HH:mm:ss", monthDay: "MMMM dd", yearMonth: "MMMM, yyyy" }, Date.i18n.currentLanguage()); }, regex: function () { return getText.getFromObjectValues({ inTheMorning: "/( in the )(morn(ing)?)\\b/", thisMorning: "/(this )(morn(ing)?)\\b/", amThisMorning: "/(\b\\d(am)? )(this )(morn(ing)?)/", inTheEvening: "/( in the )(even(ing)?)\\b/", thisEvening: "/(this )(even(ing)?)\\b/", pmThisEvening: "/(\b\\d(pm)? )(this )(even(ing)?)/", jan: "/jan(uary)?/", feb: "/feb(ruary)?/", mar: "/mar(ch)?/", apr: "/apr(il)?/", may: "/may/", jun: "/jun(e)?/", jul: "/jul(y)?/", aug: "/aug(ust)?/", sep: "/sep(t(ember)?)?/", oct: "/oct(ober)?/", nov: "/nov(ember)?/", dec: "/dec(ember)?/", sun: "/^su(n(day)?)?/", mon: "/^mo(n(day)?)?/", tue: "/^tu(e(s(day)?)?)?/", wed: "/^we(d(nesday)?)?/", thu: "/^th(u(r(s(day)?)?)?)?/", fri: "/fr(i(day)?)?/", sat: "/^sa(t(urday)?)?/", future: "/^next/", past: "/^last|past|prev(ious)?/", add: "/^(\\+|aft(er)?|from|hence)/", subtract: "/^(\\-|bef(ore)?|ago)/", yesterday: "/^yes(terday)?/", today: "/^t(od(ay)?)?/", tomorrow: "/^tom(orrow)?/", now: "/^n(ow)?/", millisecond: "/^ms|milli(second)?s?/", second: "/^sec(ond)?s?/", minute: "/^mn|min(ute)?s?/", hour: "/^h(our)?s?/", week: "/^w(eek)?s?/", month: "/^m(onth)?s?/", day: "/^d(ay)?s?/", year: "/^y(ear)?s?/", shortMeridian: "/^(a|p)/", longMeridian: "/^(a\\.?m?\\.?|p\\.?m?\\.?)/", timezone: "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/", ordinalSuffix: "/^\\s*(st|nd|rd|th)/", timeContext: "/^\\s*(\\:|a(?!u|p)|p)/" }, Date.i18n.currentLanguage()); } }; var CultureInfo = function () { var info = getText.getFromObjectValues({ name: "name", englishName: "englishName", nativeName: "nativeName", amDesignator: "AM", pmDesignator: "PM", firstDayOfWeek: "firstDayOfWeek", twoDigitYearMax: "twoDigitYearMax", dateElementOrder: "mdy" }, Date.i18n.currentLanguage()); var constructedInfo = buildInfo.buildFromMethodHash({ dayNames: "days", abbreviatedDayNames: "dayAbbr", shortestDayNames: "dayShortNames", firstLetterDayNames: "dayFirstLetters", monthNames: "months", abbreviatedMonthNames: "monthAbbr", formatPatterns: "formatPatterns", regexPatterns: "regex", abbreviatedTimeZoneDST: "timeZoneDST", abbreviatedTimeZoneStandard: "timeZoneStandard" }); shallowMerge(info, constructedInfo); buildInfo.timeZones(info); return info; }; $D.i18n = { __: function (key, lang) { return __(key, lang); }, currentLanguage: function () { return lang || "en-US"; }, setLanguage: function (code, force, cb) { var async = false; if (force || code === "en-US" || (!!Date.CultureStrings && !!Date.CultureStrings[code])) { lang = code; Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings.lang = code; Date.CultureInfo = new CultureInfo(); } else { if (!(!!Date.CultureStrings && !!Date.CultureStrings[code])) { if (typeof exports !== "undefined" && this.exports !== exports) { // we're in a Node enviroment, load it using require try { require("../i18n/" + code + ".js"); lang = code; Date.CultureStrings.lang = code; Date.CultureInfo = new CultureInfo(); } catch (e) { // var str = "The language for '" + code + "' could not be loaded by Node. It likely does not exist."; throw new Error("The DateJS IETF language tag '" + code + "' could not be loaded by Node. It likely does not exist."); } } else if (Date.Config && Date.Config.i18n) { // we know the location of the files, so lets load them async = true; loadI18nScript(code).done(function(){ lang = code; Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings.lang = code; Date.CultureInfo = new CultureInfo(); $D.Parsing.Normalizer.buildReplaceData(); // because this is async if ($D.Grammar) { $D.Grammar.buildGrammarFormats(); // so we can parse those strings... } if (cb) { setTimeout(cb,0); } }); } else { Date.console.error("The DateJS IETF language tag '" + code + "' is not available and has not been loaded."); return false; } } } $D.Parsing.Normalizer.buildReplaceData(); // rebuild normalizer strings if ($D.Grammar) { $D.Grammar.buildGrammarFormats(); // so we can parse those strings... } if (!async && cb) { setTimeout(cb,0); } }, getLoggedKeys: function () { return loggedKeys; }, updateCultureInfo: function () { Date.CultureInfo = new CultureInfo(); } }; $D.i18n.updateCultureInfo(); // run automatically }()); (function () { var $D = Date, $P = $D.prototype, p = function (s, l) { if (!l) { l = 2; } return ("000" + s).slice(l * -1); }; if (typeof window !== "undefined" && typeof window.console !== "undefined" && typeof window.console.log !== "undefined") { $D.console = console; // used only to raise non-critical errors if available } else { // set mock so we don't give errors. $D.console = { log: function(){}, error: function(){} }; } $D.Config = $D.Config || {}; $D.initOverloads = function() { /** * Overload of Date.now. Allows an alternate call for Date.now where it returns the * current Date as an object rather than just milliseconds since the Unix Epoch. * * Also provides an implementation of now() for browsers (IE<9) that don't have it. * * Backwards compatible so with work with either: * Date.now() [returns ms] * or * Date.now(true) [returns Date] */ if (!$D.now) { $D._now = function now() { return new Date().getTime(); }; } else if (!$D._now) { $D._now = $D.now; } $D.now = function (returnObj) { if (returnObj) { return $D.present(); } else { return $D._now(); } }; if ( !$P.toISOString ) { $P.toISOString = function() { return this.getUTCFullYear() + "-" + p(this.getUTCMonth() + 1) + "-" + p(this.getUTCDate()) + "T" + p(this.getUTCHours()) + ":" + p(this.getUTCMinutes()) + ":" + p(this.getUTCSeconds()) + "." + String( (this.getUTCMilliseconds()/1000).toFixed(3)).slice(2, 5) + "Z"; }; } // private if ( $P._toString === undefined ){ $P._toString = $P.toString; } }; $D.initOverloads(); /** * Gets a date that is set to the current date. The time is set to the start of the day (00:00 or 12:00 AM). * @return {Date} The current date. */ $D.today = function () { return new Date().clearTime(); }; /** * Gets a date that is set to the current date and time (same as new Date, but chainable) * @return {Date} The current date. */ $D.present = function () { return new Date(); }; /** * Compares the first date to the second date and returns an number indication of their relative values. * @param {Date} First Date object to compare [Required]. * @param {Date} Second Date object to compare to [Required]. * @return {Number} -1 = date1 is lessthan date2. 0 = values are equal. 1 = date1 is greaterthan date2. */ $D.compare = function (date1, date2) { if (isNaN(date1) || isNaN(date2)) { throw new Error(date1 + " - " + date2); } else if (date1 instanceof Date && date2 instanceof Date) { return (date1 < date2) ? -1 : (date1 > date2) ? 1 : 0; } else { throw new TypeError(date1 + " - " + date2); } }; /** * Compares the first Date object to the second Date object and returns true if they are equal. * @param {Date} First Date object to compare [Required] * @param {Date} Second Date object to compare to [Required] * @return {Boolean} true if dates are equal. false if they are not equal. */ $D.equals = function (date1, date2) { return (date1.compareTo(date2) === 0); }; /** * Gets the language appropriate day name when given the day number(0-6) * eg - 0 == Sunday * @return {String} The day name */ $D.getDayName = function (n) { return Date.CultureInfo.dayNames[n]; }; /** * Gets the day number (0-6) if given a CultureInfo specific string which is a valid dayName, abbreviatedDayName or shortestDayName (two char). * @param {String} The name of the day (eg. "Monday, "Mon", "tuesday", "tue", "We", "we"). * @return {Number} The day number */ $D.getDayNumberFromName = function (name) { var n = Date.CultureInfo.dayNames, m = Date.CultureInfo.abbreviatedDayNames, o = Date.CultureInfo.shortestDayNames, s = name.toLowerCase(); for (var i = 0; i < n.length; i++) { if (n[i].toLowerCase() === s || m[i].toLowerCase() === s || o[i].toLowerCase() === s) { return i; } } return -1; }; /** * Gets the month number (0-11) if given a Culture Info specific string which is a valid monthName or abbreviatedMonthName. * @param {String} The name of the month (eg. "February, "Feb", "october", "oct"). * @return {Number} The day number */ $D.getMonthNumberFromName = function (name) { var n = Date.CultureInfo.monthNames, m = Date.CultureInfo.abbreviatedMonthNames, s = name.toLowerCase(); for (var i = 0; i < n.length; i++) { if (n[i].toLowerCase() === s || m[i].toLowerCase() === s) { return i; } } return -1; }; /** * Gets the language appropriate month name when given the month number(0-11) * eg - 0 == January * @return {String} The month name */ $D.getMonthName = function (n) { return Date.CultureInfo.monthNames[n]; }; /** * Determines if the current date instance is within a LeapYear. * @param {Number} The year. * @return {Boolean} true if date is within a LeapYear, otherwise false. */ $D.isLeapYear = function (year) { return ((year % 4 === 0 && year % 100 !== 0) || year % 400 === 0); }; /** * Gets the number of days in the month, given a year and month value. Automatically corrects for LeapYear. * @param {Number} The year. * @param {Number} The month (0-11). * @return {Number} The number of days in the month. */ $D.getDaysInMonth = function (year, month) { if (!month && $D.validateMonth(year)) { month = year; year = Date.today().getFullYear(); } return [31, ($D.isLeapYear(year) ? 29 : 28), 31, 30, 31, 30, 31, 31, 30, 31, 30, 31][month]; }; $P.getDaysInMonth = function () { return $D.getDaysInMonth(this.getFullYear(), this.getMonth()); }; $D.getTimezoneAbbreviation = function (offset, dst) { var p, n = (dst || false) ? Date.CultureInfo.abbreviatedTimeZoneDST : Date.CultureInfo.abbreviatedTimeZoneStandard; for (p in n) { if (n.hasOwnProperty(p)) { if (n[p] === offset) { return p; } } } return null; }; $D.getTimezoneOffset = function (name, dst) { var i, a =[], z = Date.CultureInfo.timezones; if (!name) { name = (new Date()).getTimezone();} for (i = 0; i < z.length; i++) { if (z[i].name === name.toUpperCase()) { a.push(i); } } if (!z[a[0]]) { return null; } if (a.length === 1 || !dst) { return z[a[0]].offset; } else { for (i=0; i < a.length; i++) { if (z[a[i]].dst) { return z[a[i]].offset; } } } }; $D.getQuarter = function (d) { d = d || new Date(); // If no date supplied, use today var q = [1,2,3,4]; return q[Math.floor(d.getMonth() / 3)]; // ~~~ is a bitwise op. Faster than Math.floor }; $D.getDaysLeftInQuarter = function (d) { d = d || new Date(); var qEnd = new Date(d); qEnd.setMonth(qEnd.getMonth() + 3 - qEnd.getMonth() % 3, 0); return Math.floor((qEnd - d) / 8.64e7); }; // private var validate = function (n, min, max, name) { name = name ? name : "Object"; if (typeof n === "undefined") { return false; } else if (typeof n !== "number") { throw new TypeError(n + " is not a Number."); } else if (n < min || n > max) { // As failing validation is *not* an exceptional circumstance // lets not throw a RangeError Exception here. // It's semantically correct but it's not sensible. return false; } return true; }; /** * Validates the number is within an acceptable range for milliseconds [0-999]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateMillisecond = function (value) { return validate(value, 0, 999, "millisecond"); }; /** * Validates the number is within an acceptable range for seconds [0-59]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateSecond = function (value) { return validate(value, 0, 59, "second"); }; /** * Validates the number is within an acceptable range for minutes [0-59]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateMinute = function (value) { return validate(value, 0, 59, "minute"); }; /** * Validates the number is within an acceptable range for hours [0-23]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateHour = function (value) { return validate(value, 0, 23, "hour"); }; /** * Validates the number is within an acceptable range for the days in a month [0-MaxDaysInMonth]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateDay = function (value, year, month) { if (year === undefined || year === null || month === undefined || month === null) { return false;} return validate(value, 1, $D.getDaysInMonth(year, month), "day"); }; /** * Validates the number is within an acceptable range for months [0-11]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateWeek = function (value) { return validate(value, 0, 53, "week"); }; /** * Validates the number is within an acceptable range for months [0-11]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateMonth = function (value) { return validate(value, 0, 11, "month"); }; /** * Validates the number is within an acceptable range for years. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateYear = function (value) { /** * Per ECMAScript spec the range of times supported by Date objects is * exactly -100,000,000 days to +100,000,000 days measured relative to * midnight at the beginning of 01 January, 1970 UTC. * This gives a range of 8,640,000,000,000,000 milliseconds to either * side of 01 January, 1970 UTC. * * Earliest possible date: Tue, 20 Apr 271,822 B.C. 00:00:00 UTC * Latest possible date: Sat, 13 Sep 275,760 00:00:00 UTC */ return validate(value, -271822, 275760, "year"); }; $D.validateTimezone = function(value) { var timezones = {"ACDT":1,"ACST":1,"ACT":1,"ADT":1,"AEDT":1,"AEST":1,"AFT":1,"AKDT":1,"AKST":1,"AMST":1,"AMT":1,"ART":1,"AST":1,"AWDT":1,"AWST":1,"AZOST":1,"AZT":1,"BDT":1,"BIOT":1,"BIT":1,"BOT":1,"BRT":1,"BST":1,"BTT":1,"CAT":1,"CCT":1,"CDT":1,"CEDT":1,"CEST":1,"CET":1,"CHADT":1,"CHAST":1,"CHOT":1,"ChST":1,"CHUT":1,"CIST":1,"CIT":1,"CKT":1,"CLST":1,"CLT":1,"COST":1,"COT":1,"CST":1,"CT":1,"CVT":1,"CWST":1,"CXT":1,"DAVT":1,"DDUT":1,"DFT":1,"EASST":1,"EAST":1,"EAT":1,"ECT":1,"EDT":1,"EEDT":1,"EEST":1,"EET":1,"EGST":1,"EGT":1,"EIT":1,"EST":1,"FET":1,"FJT":1,"FKST":1,"FKT":1,"FNT":1,"GALT":1,"GAMT":1,"GET":1,"GFT":1,"GILT":1,"GIT":1,"GMT":1,"GST":1,"GYT":1,"HADT":1,"HAEC":1,"HAST":1,"HKT":1,"HMT":1,"HOVT":1,"HST":1,"ICT":1,"IDT":1,"IOT":1,"IRDT":1,"IRKT":1,"IRST":1,"IST":1,"JST":1,"KGT":1,"KOST":1,"KRAT":1,"KST":1,"LHST":1,"LINT":1,"MAGT":1,"MART":1,"MAWT":1,"MDT":1,"MET":1,"MEST":1,"MHT":1,"MIST":1,"MIT":1,"MMT":1,"MSK":1,"MST":1,"MUT":1,"MVT":1,"MYT":1,"NCT":1,"NDT":1,"NFT":1,"NPT":1,"NST":1,"NT":1,"NUT":1,"NZDT":1,"NZST":1,"OMST":1,"ORAT":1,"PDT":1,"PET":1,"PETT":1,"PGT":1,"PHOT":1,"PHT":1,"PKT":1,"PMDT":1,"PMST":1,"PONT":1,"PST":1,"PYST":1,"PYT":1,"RET":1,"ROTT":1,"SAKT":1,"SAMT":1,"SAST":1,"SBT":1,"SCT":1,"SGT":1,"SLST":1,"SRT":1,"SST":1,"SYOT":1,"TAHT":1,"THA":1,"TFT":1,"TJT":1,"TKT":1,"TLT":1,"TMT":1,"TOT":1,"TVT":1,"UCT":1,"ULAT":1,"UTC":1,"UYST":1,"UYT":1,"UZT":1,"VET":1,"VLAT":1,"VOLT":1,"VOST":1,"VUT":1,"WAKT":1,"WAST":1,"WAT":1,"WEDT":1,"WEST":1,"WET":1,"WST":1,"YAKT":1,"YEKT":1,"Z":1}; return (timezones[value] === 1); }; $D.validateTimezoneOffset= function(value) { // timezones go from +14hrs to -12hrs, the +X hours are negative offsets. return (value > -841 && value < 721); }; }()); (function () { var $D = Date, $P = $D.prototype, p = function (s, l) { if (!l) { l = 2; } return ("000" + s).slice(l * -1); }; var validateConfigObject = function (obj) { var result = {}, self = this, prop, testFunc; testFunc = function (prop, func, value) { if (prop === "day") { var month = (obj.month !== undefined) ? obj.month : self.getMonth(); var year = (obj.year !== undefined) ? obj.year : self.getFullYear(); return $D[func](value, year, month); } else { return $D[func](value); } }; for (prop in obj) { if (Object.prototype.hasOwnProperty.call(obj, prop)) { var func = "validate" + prop.charAt(0).toUpperCase() + prop.slice(1); if ($D[func] && obj[prop] !== null && testFunc(prop, func, obj[prop])) { result[prop] = obj[prop]; } } } return result; }; /** * Resets the time of this Date object to 12:00 AM (00:00), which is the start of the day. * @param {Boolean} .clone() this date instance before clearing Time * @return {Date} this */ $P.clearTime = function () { this.setHours(0); this.setMinutes(0); this.setSeconds(0); this.setMilliseconds(0); return this; }; /** * Resets the time of this Date object to the current time ('now'). * @return {Date} this */ $P.setTimeToNow = function () { var n = new Date(); this.setHours(n.getHours()); this.setMinutes(n.getMinutes()); this.setSeconds(n.getSeconds()); this.setMilliseconds(n.getMilliseconds()); return this; }; /** * Returns a new Date object that is an exact date and time copy of the original instance. * @return {Date} A new Date instance */ $P.clone = function () { return new Date(this.getTime()); }; /** * Compares this instance to a Date object and returns an number indication of their relative values. * @param {Date} Date object to compare [Required] * @return {Number} -1 = this is lessthan date. 0 = values are equal. 1 = this is greaterthan date. */ $P.compareTo = function (date) { return Date.compare(this, date); }; /** * Compares this instance to another Date object and returns true if they are equal. * @param {Date} Date object to compare. If no date to compare, new Date() [now] is used. * @return {Boolean} true if dates are equal. false if they are not equal. */ $P.equals = function (date) { return Date.equals(this, (date !== undefined ? date : new Date())); }; /** * Determines if this instance is between a range of two dates or equal to either the start or end dates. * @param {Date} Start of range [Required] * @param {Date} End of range [Required] * @return {Boolean} true is this is between or equal to the start and end dates, else false */ $P.between = function (start, end) { return this.getTime() >= start.getTime() && this.getTime() <= end.getTime(); }; /** * Determines if this date occurs after the date to compare to. * @param {Date} Date object to compare. If no date to compare, new Date() ("now") is used. * @return {Boolean} true if this date instance is greater than the date to compare to (or "now"), otherwise false. */ $P.isAfter = function (date) { return this.compareTo(date || new Date()) === 1; }; /** * Determines if this date occurs before the date to compare to. * @param {Date} Date object to compare. If no date to compare, new Date() ("now") is used. * @return {Boolean} true if this date instance is less than the date to compare to (or "now"). */ $P.isBefore = function (date) { return (this.compareTo(date || new Date()) === -1); }; /** * Determines if the current Date instance occurs today. * @return {Boolean} true if this date instance is 'today', otherwise false. */ /** * Determines if the current Date instance occurs on the same Date as the supplied 'date'. * If no 'date' to compare to is provided, the current Date instance is compared to 'today'. * @param {date} Date object to compare. If no date to compare, the current Date ("now") is used. * @return {Boolean} true if this Date instance occurs on the same Day as the supplied 'date'. */ $P.isToday = $P.isSameDay = function (date) { return this.clone().clearTime().equals((date || new Date()).clone().clearTime()); }; /** * Adds the specified number of milliseconds to this instance. * @param {Number} The number of milliseconds to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addMilliseconds = function (value) { if (!value) { return this; } this.setTime(this.getTime() + value * 1); return this; }; /** * Adds the specified number of seconds to this instance. * @param {Number} The number of seconds to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addSeconds = function (value) { if (!value) { return this; } return this.addMilliseconds(value * 1000); }; /** * Adds the specified number of seconds to this instance. * @param {Number} The number of seconds to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addMinutes = function (value) { if (!value) { return this; } return this.addMilliseconds(value * 60000); // 60*1000 }; /** * Adds the specified number of hours to this instance. * @param {Number} The number of hours to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addHours = function (value) { if (!value) { return this; } return this.addMilliseconds(value * 3600000); // 60*60*1000 }; /** * Adds the specified number of days to this instance. * @param {Number} The number of days to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addDays = function (value) { if (!value) { return this; } this.setDate(this.getDate() + value * 1); return this; }; /** * Adds the specified number of weekdays (ie - not sat or sun) to this instance. * @param {Number} The number of days to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addWeekdays = function (value) { if (!value) { return this; } var day = this.getDay(); var weeks = (Math.ceil(Math.abs(value)/7)); if (day === 0 || day === 6) { if (value > 0) { this.next().monday(); this.addDays(-1); day = this.getDay(); } } if (value < 0) { while (value < 0) { this.addDays(-1); day = this.getDay(); if (day !== 0 && day !== 6) { value++; } } return this; } else if (value > 5 || (6-day) <= value) { value = value + (weeks * 2); } return this.addDays(value); }; /** * Adds the specified number of weeks to this instance. * @param {Number} The number of weeks to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addWeeks = function (value) { if (!value) { return this; } return this.addDays(value * 7); }; /** * Adds the specified number of months to this instance. * @param {Number} The number of months to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addMonths = function (value) { if (!value) { return this; } var n = this.getDate(); this.setDate(1); this.setMonth(this.getMonth() + value * 1); this.setDate(Math.min(n, $D.getDaysInMonth(this.getFullYear(), this.getMonth()))); return this; }; $P.addQuarters = function (value) { if (!value) { return this; } // note this will take you to the same point in the quarter as you are now. // i.e. - if you are 15 days into the quarter you'll be 15 days into the resulting one. // bonus: this allows adding fractional quarters return this.addMonths(value * 3); }; /** * Adds the specified number of years to this instance. * @param {Number} The number of years to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addYears = function (value) { if (!value) { return this; } return this.addMonths(value * 12); }; /** * Adds (or subtracts) to the value of the years, months, weeks, days, hours, minutes, seconds, milliseconds of the date instance using given configuration object. Positive and Negative values allowed. * Example

	Date.today().add( { days: 1, months: 1 } )

	new Date().add( { years: -1 } )
	
* @param {Object} Configuration object containing attributes (months, days, etc.) * @return {Date} this */ $P.add = function (config) { if (typeof config === "number") { this._orient = config; return this; } var x = config; if (x.day) { // If we should be a different date than today (eg: for 'tomorrow -1d', etc). // Should only effect parsing, not direct usage (eg, Finish and FinishExact) if ((x.day - this.getDate()) !== 0) { this.setDate(x.day); } } if (x.milliseconds) { this.addMilliseconds(x.milliseconds); } if (x.seconds) { this.addSeconds(x.seconds); } if (x.minutes) { this.addMinutes(x.minutes); } if (x.hours) { this.addHours(x.hours); } if (x.weeks) { this.addWeeks(x.weeks); } if (x.months) { this.addMonths(x.months); } if (x.years) { this.addYears(x.years); } if (x.days) { this.addDays(x.days); } return this; }; /** * Get the week number. Week one (1) is the week which contains the first Thursday of the year. Monday is considered the first day of the week. * The .getWeek() function does NOT convert the date to UTC. The local datetime is used. * Please use .getISOWeek() to get the week of the UTC converted date. * @return {Number} 1 to 53 */ $P.getWeek = function (utc) { // Create a copy of this date object var self, target = new Date(this.valueOf()); if (utc) { target.addMinutes(target.getTimezoneOffset()); self = target.clone(); } else { self = this; } // ISO week date weeks start on monday // so correct the day number var dayNr = (self.getDay() + 6) % 7; // ISO 8601 states that week 1 is the week // with the first thursday of that year. // Set the target date to the thursday in the target week target.setDate(target.getDate() - dayNr + 3); // Store the millisecond value of the target date var firstThursday = target.valueOf(); // Set the target to the first thursday of the year // First set the target to january first target.setMonth(0, 1); // Not a thursday? Correct the date to the next thursday if (target.getDay() !== 4) { target.setMonth(0, 1 + ((4 - target.getDay()) + 7) % 7); } // The weeknumber is the number of weeks between the // first thursday of the year and the thursday in the target week return 1 + Math.ceil((firstThursday - target) / 604800000); // 604800000 = 7 * 24 * 3600 * 1000 }; /** * Get the ISO 8601 week number. Week one ("01") is the week which contains the first Thursday of the year. Monday is considered the first day of the week. * The .getISOWeek() function does convert the date to it's UTC value. Please use .getWeek() to get the week of the local date. * @return {String} "01" to "53" */ $P.getISOWeek = function () { return p(this.getWeek(true)); }; /** * Moves the date to Monday of the week set. Week one (1) is the week which contains the first Thursday of the year. * @param {Number} A Number (1 to 53) that represents the week of the year. * @return {Date} this */ $P.setWeek = function (n) { if ((n - this.getWeek()) === 0) { if (this.getDay() !== 1) { return this.moveToDayOfWeek(1, (this.getDay() > 1 ? -1 : 1)); } else { return this; } } else { return this.moveToDayOfWeek(1, (this.getDay() > 1 ? -1 : 1)).addWeeks(n - this.getWeek()); } }; $P.setQuarter = function (qtr) { var month = Math.abs(((qtr-1) * 3) + 1); return this.setMonth(month, 1); }; $P.getQuarter = function () { return Date.getQuarter(this); }; $P.getDaysLeftInQuarter = function () { return Date.getDaysLeftInQuarter(this); }; /** * Moves the date to the next n'th occurrence of the dayOfWeek starting from the beginning of the month. The number (-1) is a magic number and will return the last occurrence of the dayOfWeek in the month. * @param {Number} The dayOfWeek to move to * @param {Number} The n'th occurrence to move to. Use (-1) to return the last occurrence in the month * @return {Date} this */ $P.moveToNthOccurrence = function (dayOfWeek, occurrence) { if (dayOfWeek === "Weekday") { if (occurrence > 0) { this.moveToFirstDayOfMonth(); if (this.is().weekday()) { occurrence -= 1; } } else if (occurrence < 0) { this.moveToLastDayOfMonth(); if (this.is().weekday()) { occurrence += 1; } } else { return this; } return this.addWeekdays(occurrence); } var shift = 0; if (occurrence > 0) { shift = occurrence - 1; } else if (occurrence === -1) { this.moveToLastDayOfMonth(); if (this.getDay() !== dayOfWeek) { this.moveToDayOfWeek(dayOfWeek, -1); } return this; } return this.moveToFirstDayOfMonth().addDays(-1).moveToDayOfWeek(dayOfWeek, +1).addWeeks(shift); }; var moveToN = function (getFunc, addFunc, nVal) { return function (value, orient) { var diff = (value - this[getFunc]() + nVal * (orient || +1)) % nVal; return this[addFunc]((diff === 0) ? diff += nVal * (orient || +1) : diff); }; }; /** * Move to the next or last dayOfWeek based on the orient value. * @param {Number} The dayOfWeek to move to * @param {Number} Forward (+1) or Back (-1). Defaults to +1. [Optional] * @return {Date} this */ $P.moveToDayOfWeek = moveToN("getDay", "addDays", 7); /** * Move to the next or last month based on the orient value. * @param {Number} The month to move to. 0 = January, 11 = December * @param {Number} Forward (+1) or Back (-1). Defaults to +1. [Optional] * @return {Date} this */ $P.moveToMonth = moveToN("getMonth", "addMonths", 12); /** * Get the Ordinate of the current day ("th", "st", "rd"). * @return {String} */ $P.getOrdinate = function () { var num = this.getDate(); return ord(num); }; /** * Get the Ordinal day (numeric day number) of the year, adjusted for leap year. * @return {Number} 1 through 365 (366 in leap years) */ $P.getOrdinalNumber = function () { return Math.ceil((this.clone().clearTime() - new Date(this.getFullYear(), 0, 1)) / 86400000) + 1; }; /** * Get the time zone abbreviation of the current date. * @return {String} The abbreviated time zone name (e.g. "EST") */ $P.getTimezone = function () { return $D.getTimezoneAbbreviation(this.getUTCOffset(), this.isDaylightSavingTime()); }; $P.setTimezoneOffset = function (offset) { var here = this.getTimezoneOffset(), there = Number(offset) * -6 / 10; return (there || there === 0) ? this.addMinutes(there - here) : this; }; $P.setTimezone = function (offset) { return this.setTimezoneOffset($D.getTimezoneOffset(offset)); }; /** * Indicates whether Daylight Saving Time is observed in the current time zone. * @return {Boolean} true|false */ $P.hasDaylightSavingTime = function () { return (Date.today().set({month: 0, day: 1}).getTimezoneOffset() !== Date.today().set({month: 6, day: 1}).getTimezoneOffset()); }; /** * Indicates whether this Date instance is within the Daylight Saving Time range for the current time zone. * @return {Boolean} true|false */ $P.isDaylightSavingTime = function () { return Date.today().set({month: 0, day: 1}).getTimezoneOffset() !== this.getTimezoneOffset(); }; /** * Get the offset from UTC of the current date. * @return {String} The 4-character offset string prefixed with + or - (e.g. "-0500") */ $P.getUTCOffset = function (offset) { var n = (offset || this.getTimezoneOffset()) * -10 / 6, r; if (n < 0) { r = (n - 10000).toString(); return r.charAt(0) + r.substr(2); } else { r = (n + 10000).toString(); return "+" + r.substr(1); } }; /** * Returns the number of milliseconds between this date and date. * @param {Date} Defaults to now * @return {Number} The diff in milliseconds */ $P.getElapsed = function (date) { return (date || new Date()) - this; }; /** * Set the value of year, month, day, hour, minute, second, millisecond of date instance using given configuration object. * Example

	Date.today().set( { day: 20, month: 1 } )

	new Date().set( { millisecond: 0 } )
	
* * @param {Object} Configuration object containing attributes (month, day, etc.) * @return {Date} this */ $P.set = function (config) { config = validateConfigObject.call(this, config); var key; for (key in config) { if (Object.prototype.hasOwnProperty.call(config, key)) { var name = key.charAt(0).toUpperCase() + key.slice(1); var addFunc, getFunc; if (key !== "week" && key !== "month" && key !== "timezone" && key !== "timezoneOffset") { name += "s"; } addFunc = "add" + name; getFunc = "get" + name; if (key === "month") { addFunc = addFunc + "s"; } else if (key === "year"){ getFunc = "getFullYear"; } if (key !== "day" && key !== "timezone" && key !== "timezoneOffset" && key !== "week" && key !== "hour") { this[addFunc](config[key] - this[getFunc]()); } else if ( key === "timezone"|| key === "timezoneOffset" || key === "week" || key === "hour") { this["set"+name](config[key]); } } } // day has to go last because you can't validate the day without first knowing the month if (config.day) { this.addDays(config.day - this.getDate()); } return this; }; /** * Moves the date to the first day of the month. * @return {Date} this */ $P.moveToFirstDayOfMonth = function () { return this.set({ day: 1 }); }; /** * Moves the date to the last day of the month. * @return {Date} this */ $P.moveToLastDayOfMonth = function () { return this.set({ day: $D.getDaysInMonth(this.getFullYear(), this.getMonth())}); }; /** * Converts the value of the current Date object to its equivalent string representation. * Format Specifiers * CUSTOM DATE AND TIME FORMAT STRINGS * Format Description Example * ------ --------------------------------------------------------------------------- ----------------------- * s The seconds of the minute between 0-59. "0" to "59" * ss The seconds of the minute with leading zero if required. "00" to "59" * * m The minute of the hour between 0-59. "0" or "59" * mm The minute of the hour with leading zero if required. "00" or "59" * * h The hour of the day between 1-12. "1" to "12" * hh The hour of the day with leading zero if required. "01" to "12" * * H The hour of the day between 0-23. "0" to "23" * HH The hour of the day with leading zero if required. "00" to "23" * * d The day of the month between 1 and 31. "1" to "31" * dd The day of the month with leading zero if required. "01" to "31" * ddd Abbreviated day name. Date.CultureInfo.abbreviatedDayNames. "Mon" to "Sun" * dddd The full day name. Date.CultureInfo.dayNames. "Monday" to "Sunday" * * M The month of the year between 1-12. "1" to "12" * MM The month of the year with leading zero if required. "01" to "12" * MMM Abbreviated month name. Date.CultureInfo.abbreviatedMonthNames. "Jan" to "Dec" * MMMM The full month name. Date.CultureInfo.monthNames. "January" to "December" * * yy The year as a two-digit number. "99" or "08" * yyyy The full four digit year. "1999" or "2008" * * t Displays the first character of the A.M./P.M. designator. "A" or "P" * Date.CultureInfo.amDesignator or Date.CultureInfo.pmDesignator * tt Displays the A.M./P.M. designator. "AM" or "PM" * Date.CultureInfo.amDesignator or Date.CultureInfo.pmDesignator * * S The ordinal suffix ("st, "nd", "rd" or "th") of the current day. "st, "nd", "rd" or "th" * * STANDARD DATE AND TIME FORMAT STRINGS * Format Description Example *------ --------------------------------------------------------------------------- ----------------------- * d The CultureInfo shortDate Format Pattern "M/d/yyyy" * D The CultureInfo longDate Format Pattern "dddd, MMMM dd, yyyy" * F The CultureInfo fullDateTime Format Pattern "dddd, MMMM dd, yyyy h:mm:ss tt" * m The CultureInfo monthDay Format Pattern "MMMM dd" * r The CultureInfo rfc1123 Format Pattern "ddd, dd MMM yyyy HH:mm:ss GMT" * s The CultureInfo sortableDateTime Format Pattern "yyyy-MM-ddTHH:mm:ss" * t The CultureInfo shortTime Format Pattern "h:mm tt" * T The CultureInfo longTime Format Pattern "h:mm:ss tt" * u The CultureInfo universalSortableDateTime Format Pattern "yyyy-MM-dd HH:mm:ssZ" * y The CultureInfo yearMonth Format Pattern "MMMM, yyyy" * * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @return {String} A string representation of the current Date object. */ var ord = function (n) { switch (n * 1) { case 1: case 21: case 31: return "st"; case 2: case 22: return "nd"; case 3: case 23: return "rd"; default: return "th"; } }; var parseStandardFormats = function (format) { var y, c = Date.CultureInfo.formatPatterns; switch (format) { case "d": return this.toString(c.shortDate); case "D": return this.toString(c.longDate); case "F": return this.toString(c.fullDateTime); case "m": return this.toString(c.monthDay); case "r": case "R": y = this.clone().addMinutes(this.getTimezoneOffset()); return y.toString(c.rfc1123) + " GMT"; case "s": return this.toString(c.sortableDateTime); case "t": return this.toString(c.shortTime); case "T": return this.toString(c.longTime); case "u": y = this.clone().addMinutes(this.getTimezoneOffset()); return y.toString(c.universalSortableDateTime); case "y": return this.toString(c.yearMonth); default: return false; } }; var parseFormatStringsClosure = function (context) { return function (m) { if (m.charAt(0) === "\\") { return m.replace("\\", ""); } switch (m) { case "hh": return p(context.getHours() < 13 ? (context.getHours() === 0 ? 12 : context.getHours()) : (context.getHours() - 12)); case "h": return context.getHours() < 13 ? (context.getHours() === 0 ? 12 : context.getHours()) : (context.getHours() - 12); case "HH": return p(context.getHours()); case "H": return context.getHours(); case "mm": return p(context.getMinutes()); case "m": return context.getMinutes(); case "ss": return p(context.getSeconds()); case "s": return context.getSeconds(); case "yyyy": return p(context.getFullYear(), 4); case "yy": return p(context.getFullYear()); case "y": return context.getFullYear(); case "E": case "dddd": return Date.CultureInfo.dayNames[context.getDay()]; case "ddd": return Date.CultureInfo.abbreviatedDayNames[context.getDay()]; case "dd": return p(context.getDate()); case "d": return context.getDate(); case "MMMM": return Date.CultureInfo.monthNames[context.getMonth()]; case "MMM": return Date.CultureInfo.abbreviatedMonthNames[context.getMonth()]; case "MM": return p((context.getMonth() + 1)); case "M": return context.getMonth() + 1; case "t": return context.getHours() < 12 ? Date.CultureInfo.amDesignator.substring(0, 1) : Date.CultureInfo.pmDesignator.substring(0, 1); case "tt": return context.getHours() < 12 ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator; case "S": return ord(context.getDate()); case "W": return context.getWeek(); case "WW": return context.getISOWeek(); case "Q": return "Q" + context.getQuarter(); case "q": return String(context.getQuarter()); case "z": return context.getTimezone(); case "Z": case "X": return Date.getTimezoneOffset(context.getTimezone()); case "ZZ": // Timezone offset in seconds return context.getTimezoneOffset() * -60; case "u": return context.getDay(); case "L": return ($D.isLeapYear(context.getFullYear())) ? 1 : 0; case "B": // Swatch Internet Time (.beats) return "@"+((context.getUTCSeconds() + (context.getUTCMinutes()*60) + ((context.getUTCHours()+1)*3600))/86.4); default: return m; } }; }; $P.toString = function (format, ignoreStandards) { // Standard Date and Time Format Strings. Formats pulled from CultureInfo file and // may vary by culture. if (!ignoreStandards && format && format.length === 1) { output = parseStandardFormats.call(this, format); if (output) { return output; } } var parseFormatStrings = parseFormatStringsClosure(this); return format ? format.replace(/((\\)?(dd?d?d?|MM?M?M?|yy?y?y?|hh?|HH?|mm?|ss?|tt?|S|q|Q|WW?W?W?)(?![^\[]*\]))/g, parseFormatStrings).replace(/\[|\]/g, "") : this._toString(); }; }()); /************************************************************* * SugarPak - Domain Specific Language - Syntactical Sugar * *************************************************************/ (function () { var $D = Date, $P = $D.prototype, $N = Number.prototype; // private $P._orient = +1; // private $P._nth = null; // private $P._is = false; // private $P._same = false; // private $P._isSecond = false; // private $N._dateElement = "days"; /** * Moves the date to the next instance of a date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.today().next().friday();
	Date.today().next().fri();
	Date.today().next().march();
	Date.today().next().mar();
	Date.today().next().week();
	
* * @return {Date} date */ $P.next = function () { this._move = true; this._orient = +1; return this; }; /** * Creates a new Date (Date.today()) and moves the date to the next instance of the date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.next().friday();
	Date.next().fri();
	Date.next().march();
	Date.next().mar();
	Date.next().week();
	
* * @return {Date} date */ $D.next = function () { return $D.today().next(); }; /** * Moves the date to the previous instance of a date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.today().last().friday();
	Date.today().last().fri();
	Date.today().last().march();
	Date.today().last().mar();
	Date.today().last().week();
	
* * @return {Date} date */ $P.last = $P.prev = $P.previous = function () { this._move = true; this._orient = -1; return this; }; /** * Creates a new Date (Date.today()) and moves the date to the previous instance of the date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.last().friday();
	Date.last().fri();
	Date.previous().march();
	Date.prev().mar();
	Date.last().week();
	
* * @return {Date} date */ $D.last = $D.prev = $D.previous = function () { return $D.today().last(); }; /** * Performs a equality check when followed by either a month name, day name or .weekday() function. * Example

	Date.today().is().friday(); // true|false
	Date.today().is().fri();
	Date.today().is().march();
	Date.today().is().mar();
	
* * @return {Boolean} true|false */ $P.is = function () { this._is = true; return this; }; /** * Determines if two date objects occur on/in exactly the same instance of the subsequent date part function. * The function .same() must be followed by a date part function (example: .day(), .month(), .year(), etc). * * An optional Date can be passed in the date part function. If now date is passed as a parameter, 'Now' is used. * * The following example demonstrates how to determine if two dates fall on the exact same day. * * Example

	var d1 = Date.today(); // today at 00:00
	var d2 = new Date();   // exactly now.

	// Do they occur on the same day?
	d1.same().day(d2); // true
	
	// Do they occur on the same hour?
	d1.same().hour(d2); // false, unless d2 hour is '00' (midnight).
	
	// What if it's the same day, but one year apart?
	var nextYear = Date.today().add(1).year();

	d1.same().day(nextYear); // false, because the dates must occur on the exact same day. 
	
* * Scenario: Determine if a given date occurs during some week period 2 months from now. * * Example

	var future = Date.today().add(2).months();
	return someDate.same().week(future); // true|false;
	
* * @return {Boolean} true|false */ $P.same = function () { this._same = true; this._isSecond = false; return this; }; /** * Determines if the current date/time occurs during Today. Must be preceded by the .is() function. * Example

	someDate.is().today();    // true|false
	new Date().is().today();  // true
	Date.today().is().today();// true
	Date.today().add(-1).day().is().today(); // false
	
* * @return {Boolean} true|false */ $P.today = function () { return this.same().day(); }; /** * Determines if the current date is a weekday. This function must be preceded by the .is() function. * Example

	Date.today().is().weekday(); // true|false
	
* * @return {Boolean} true|false */ $P.weekday = function () { if (this._nth) { return df("Weekday").call(this); } if (this._move) { return this.addWeekdays(this._orient); } if (this._is) { this._is = false; return (!this.is().sat() && !this.is().sun()); } return false; }; /** * Determines if the current date is on the weekend. This function must be preceded by the .is() function. * Example

	Date.today().is().weekend(); // true|false
	
* * @return {Boolean} true|false */ $P.weekend = function () { if (this._is) { this._is = false; return (this.is().sat() || this.is().sun()); } return false; }; /** * Sets the Time of the current Date instance. A string "6:15 pm" or config object {hour:18, minute:15} are accepted. * Example

	// Set time to 6:15pm with a String
	Date.today().at("6:15pm");

	// Set time to 6:15pm with a config object
	Date.today().at({hour:18, minute:15});
	
* * @return {Date} date */ $P.at = function (time) { return (typeof time === "string") ? $D.parse(this.toString("d") + " " + time) : this.set(time); }; /** * Creates a new Date() and adds this (Number) to the date based on the preceding date element function (eg. second|minute|hour|day|month|year). * Example

	// Undeclared Numbers must be wrapped with parentheses. Requirment of JavaScript.
	(3).days().fromNow();
	(6).months().fromNow();

	// Declared Number variables do not require parentheses. 
	var n = 6;
	n.months().fromNow();
	
* * @return {Date} A new Date instance */ $N.fromNow = $N.after = function (date) { var c = {}; c[this._dateElement] = this; return ((!date) ? new Date() : date.clone()).add(c); }; /** * Creates a new Date() and subtract this (Number) from the date based on the preceding date element function (eg. second|minute|hour|day|month|year). * Example

	// Undeclared Numbers must be wrapped with parentheses. Requirment of JavaScript.
	(3).days().ago();
	(6).months().ago();

	// Declared Number variables do not require parentheses. 
	var n = 6;
	n.months().ago();
	
* * @return {Date} A new Date instance */ $N.ago = $N.before = function (date) { var c = {}, s = (this._dateElement[this._dateElement.length-1] !== "s") ? this._dateElement + "s" : this._dateElement; c[s] = this * -1; return ((!date) ? new Date() : date.clone()).add(c); }; // Do NOT modify the following string tokens. These tokens are used to build dynamic functions. // All culture-specific strings can be found in the CultureInfo files. var dx = ("sunday monday tuesday wednesday thursday friday saturday").split(/\s/), mx = ("january february march april may june july august september october november december").split(/\s/), px = ("Millisecond Second Minute Hour Day Week Month Year Quarter Weekday").split(/\s/), pxf = ("Milliseconds Seconds Minutes Hours Date Week Month FullYear Quarter").split(/\s/), nth = ("final first second third fourth fifth").split(/\s/), de; /** * Returns an object literal of all the date parts. * Example

	var o = new Date().toObject();
	
	// { year: 2008, month: 4, week: 20, day: 13, hour: 18, minute: 9, second: 32, millisecond: 812 }
	
	// The object properties can be referenced directly from the object.
	
	alert(o.day);  // alerts "13"
	alert(o.year); // alerts "2008"
	
* * @return {Date} An object literal representing the original date object. */ $P.toObject = function () { var o = {}; for (var i = 0; i < px.length; i++) { if (this["get" + pxf[i]]) { o[px[i].toLowerCase()] = this["get" + pxf[i]](); } } return o; }; /** * Returns a date created from an object literal. Ignores the .week property if set in the config. * Example

	var o = new Date().toObject();
	
	return Date.fromObject(o); // will return the same date. 

	var o2 = {month: 1, day: 20, hour: 18}; // birthday party!
	Date.fromObject(o2);
	
* * @return {Date} An object literal representing the original date object. */ $D.fromObject = function(config) { config.week = null; return Date.today().set(config); }; // Create day name functions and abbreviated day name functions (eg. monday(), friday(), fri()). var df = function (n) { return function () { if (this._is) { this._is = false; return this.getDay() === n; } if (this._move) { this._move = null; } if (this._nth !== null) { // If the .second() function was called earlier, remove the _orient // from the date, and then continue. // This is required because 'second' can be used in two different context. // // Example // // Date.today().add(1).second(); // Date.march().second().monday(); // // Things get crazy with the following... // Date.march().add(1).second().second().monday(); // but it works!! // if (this._isSecond) { this.addSeconds(this._orient * -1); } // make sure we reset _isSecond this._isSecond = false; var ntemp = this._nth; this._nth = null; var temp = this.clone().moveToLastDayOfMonth(); this.moveToNthOccurrence(n, ntemp); if (this > temp) { throw new RangeError($D.getDayName(n) + " does not occur " + ntemp + " times in the month of " + $D.getMonthName(temp.getMonth()) + " " + temp.getFullYear() + "."); } return this; } return this.moveToDayOfWeek(n, this._orient); }; }; var sdf = function (n) { return function () { var t = $D.today(), shift = n - t.getDay(); if (n === 0 && Date.CultureInfo.firstDayOfWeek === 1 && t.getDay() !== 0) { shift = shift + 7; } return t.addDays(shift); }; }; // Create month name functions and abbreviated month name functions (eg. january(), march(), mar()). var month_instance_functions = function (n) { return function () { if (this._is) { this._is = false; return this.getMonth() === n; } return this.moveToMonth(n, this._orient); }; }; var month_static_functions = function (n) { return function () { return $D.today().set({ month: n, day: 1 }); }; }; var processTerms = function (names, staticFunc, instanceFunc) { for (var i = 0; i < names.length; i++) { // Create constant static Name variables. $D[names[i].toUpperCase()] = $D[names[i].toUpperCase().substring(0, 3)] = i; // Create Name functions. $D[names[i]] = $D[names[i].substring(0, 3)] = staticFunc(i); // Create Name instance functions. $P[names[i]] = $P[names[i].substring(0, 3)] = instanceFunc(i); } }; processTerms(dx, sdf, df); processTerms(mx, month_static_functions, month_instance_functions); // Create date element functions and plural date element functions used with Date (eg. day(), days(), months()). var ef = function (j) { return function () { // if the .second() function was called earlier, the _orient // has alread been added. Just return this and reset _isSecond. if (this._isSecond) { this._isSecond = false; return this; } if (this._same) { this._same = this._is = false; var o1 = this.toObject(), o2 = (arguments[0] || new Date()).toObject(), v = "", k = j.toLowerCase(); // the substr trick with -1 doesn't work in IE8 or less k = (k[k.length-1] === "s") ? k.substring(0,k.length-1) : k; for (var m = (px.length - 1); m > -1; m--) { v = px[m].toLowerCase(); if (o1[v] !== o2[v]) { return false; } if (k === v) { break; } } return true; } if (j.substring(j.length - 1) !== "s") { j += "s"; } if (this._move) { this._move = null; } return this["add" + j](this._orient); }; }; var nf = function (n) { return function () { this._dateElement = n; return this; }; }; for (var k = 0; k < px.length; k++) { de = px[k].toLowerCase(); if(de !== "weekday") { // Create date element functions and plural date element functions used with Date (eg. day(), days(), months()). $P[de] = $P[de + "s"] = ef(px[k]); // Create date element functions and plural date element functions used with Number (eg. day(), days(), months()). $N[de] = $N[de + "s"] = nf(de + "s"); } } $P._ss = ef("Second"); var nthfn = function (n) { return function (dayOfWeek) { if (this._same) { return this._ss(arguments[0]); } if (dayOfWeek || dayOfWeek === 0) { return this.moveToNthOccurrence(dayOfWeek, n); } this._nth = n; // if the operator is 'second' add the _orient, then deal with it later... if (n === 2 && (dayOfWeek === undefined || dayOfWeek === null)) { this._isSecond = true; return this.addSeconds(this._orient); } return this; }; }; for (var l = 0; l < nth.length; l++) { $P[nth[l]] = (l === 0) ? nthfn(-1) : nthfn(l); } }()); (function () { "use strict"; Date.Parsing = { Exception: function (s) { this.message = "Parse error at '" + s.substring(0, 10) + " ...'"; } }; var $P = Date.Parsing; var dayOffsets = { standard: [0,31,59,90,120,151,181,212,243,273,304,334], leap: [0,31,60,91,121,152,182,213,244,274,305,335] }; $P.isLeapYear = function(year) { return ((year % 4 === 0) && (year % 100 !== 0)) || (year % 400 === 0); }; var utils = { multiReplace : function (str, hash ) { var key; for (key in hash) { if (Object.prototype.hasOwnProperty.call(hash, key)) { var regex; if (typeof hash[key] === "function") { } else { regex = (hash[key] instanceof RegExp) ? hash[key] : new RegExp(hash[key], "g"); } str = str.replace(regex, key); } } return str; }, getDayOfYearFromWeek : function (obj) { var d, jan4, offset; obj.weekDay = (!obj.weekDay && obj.weekDay !== 0) ? 1 : obj.weekDay; d = new Date(obj.year, 0, 4); jan4 = d.getDay() === 0 ? 7 : d.getDay(); // JS is 0 indexed on Sunday. offset = jan4+3; obj.dayOfYear = ((obj.week * 7) + (obj.weekDay === 0 ? 7 : obj.weekDay))-offset; return obj; }, getDayOfYear : function (obj, dayOffset) { if (!obj.dayOfYear) { obj = utils.getDayOfYearFromWeek(obj); } for (var i=0;i <= dayOffset.length;i++) { if (obj.dayOfYear < dayOffset[i] || i === dayOffset.length) { obj.day = obj.day ? obj.day : (obj.dayOfYear - dayOffset[i-1]); break; } else { obj.month = i; } } return obj; }, adjustForTimeZone : function (obj, date) { var offset; if (obj.zone.toUpperCase() === "Z" || (obj.zone_hours === 0 && obj.zone_minutes === 0)) { // it's UTC/GML so work out the current timeszone offset offset = -date.getTimezoneOffset(); } else { offset = (obj.zone_hours*60) + (obj.zone_minutes || 0); if (obj.zone_sign === "+") { offset *= -1; } offset -= date.getTimezoneOffset(); } date.setMinutes(date.getMinutes()+offset); return date; }, setDefaults : function (obj) { obj.year = obj.year || Date.today().getFullYear(); obj.hours = obj.hours || 0; obj.minutes = obj.minutes || 0; obj.seconds = obj.seconds || 0; obj.milliseconds = obj.milliseconds || 0; if (!(!obj.month && (obj.week || obj.dayOfYear))) { // if we have a month, or if we don't but don't have the day calculation data obj.month = obj.month || 0; obj.day = obj.day || 1; } return obj; }, dataNum: function (data, mod, explict, postProcess) { var dataNum = data*1; if (mod) { if (postProcess) { return data ? mod(data)*1 : data; } else { return data ? mod(dataNum) : data; } } else if (!explict){ return data ? dataNum : data; } else { return (data && typeof data !== "undefined") ? dataNum : data; } }, timeDataProcess: function (obj) { var timeObj = {}; for (var x in obj.data) { if (obj.data.hasOwnProperty(x)) { timeObj[x] = obj.ignore[x] ? obj.data[x] : utils.dataNum(obj.data[x], obj.mods[x], obj.explict[x], obj.postProcess[x]); } } if (obj.data.secmins) { obj.data.secmins = obj.data.secmins.replace(",", ".") * 60; if (!timeObj.minutes) { timeObj.minutes = obj.data.secmins; } else if (!timeObj.seconds) { timeObj.seconds = obj.data.secmins; } delete obj.secmins; } return timeObj; }, buildTimeObjectFromData: function (data) { var time = utils.timeDataProcess({ data: { year : data[1], month : data[5], day : data[7], week : data[8], dayOfYear : data[10], hours : data[15], zone_hours : data[23], zone_minutes : data[24], zone : data[21], zone_sign : data[22], weekDay : data[9], minutes: data[16], seconds: data[19], milliseconds: data[20], secmins: data[18] }, mods: { month: function(data) { return data-1; }, weekDay: function (data) { data = Math.abs(data); return (data === 7 ? 0 : data); }, minutes: function (data) { return data.replace(":",""); }, seconds: function (data) { return Math.floor( (data.replace(":","").replace(",","."))*1 ); }, milliseconds: function (data) { return (data.replace(",",".")*1000); } }, postProcess: { minutes: true, seconds: true, milliseconds: true }, explict: { zone_hours: true, zone_minutes: true }, ignore: { zone: true, zone_sign: true, secmins: true } }); return time; }, addToHash: function (hash, keys, data) { keys = keys; data = data; var len = keys.length; for (var i = 0; i < len; i++) { hash[keys[i]] = data[i]; } return hash; }, combineRegex: function (r1, r2) { return new RegExp("(("+r1.source+")\\s("+r2.source+"))"); }, getDateNthString: function(add, last, inc){ if (add) { return Date.today().addDays(inc).toString("d"); } else if (last) { return Date.today().last()[inc]().toString("d"); } }, buildRegexData: function (array) { var arr = []; var len = array.length; for (var i=0; i < len; i++) { if (Object.prototype.toString.call(array[i]) === '[object Array]') { // oldIE compat version of Array.isArray arr.push(this.combineRegex(array[i][0], array[i][1])); } else { arr.push(array[i]); } } return arr; } }; $P.processTimeObject = function (obj) { var date, dayOffset; utils.setDefaults(obj); dayOffset = ($P.isLeapYear(obj.year)) ? dayOffsets.leap : dayOffsets.standard; if (!obj.month && (obj.week || obj.dayOfYear)) { utils.getDayOfYear(obj, dayOffset); } else { obj.dayOfYear = dayOffset[obj.month] + obj.day; } date = new Date(obj.year, obj.month, obj.day, obj.hours, obj.minutes, obj.seconds, obj.milliseconds); if (obj.zone) { utils.adjustForTimeZone(obj, date); // adjust (and calculate) for timezone } return date; }; $P.ISO = { regex : /^([\+-]?\d{4}(?!\d{2}\b))((-?)((0[1-9]|1[0-2])(\3([12]\d|0[1-9]|3[01]))?|W([0-4]\d|5[0-3])(-?[1-7])?|(00[1-9]|0[1-9]\d|[12]\d{2}|3([0-5]\d|6[1-6])))([T\s]((([01]\d|2[0-4])((:?)[0-5]\d)?|24\:?00)([\.,]\d+(?!:))?)?(\17[0-5]\d([\.,]\d+)?)?\s?([zZ]|([\+-])([01]\d|2[0-3]):?([0-5]\d)?)?)?)?$/, parse : function (s) { var time, data = s.match(this.regex); if (!data || !data.length) { return null; } time = utils.buildTimeObjectFromData(data); if (!time.year || (!time.year && (!time.month && !time.day) && (!time.week && !time.dayOfYear)) ) { return null; } return $P.processTimeObject(time); } }; $P.Numeric = { isNumeric: function (e){return!isNaN(parseFloat(e))&&isFinite(e);}, regex: /\b([0-1]?[0-9])([0-3]?[0-9])([0-2]?[0-9]?[0-9][0-9])\b/i, parse: function (s) { var data, i, time = {}, order = Date.CultureInfo.dateElementOrder.split(""); if (!(this.isNumeric(s)) || // if it's non-numeric OR (s[0] === "+" && s[0] === "-")) { // It's an arithmatic string (eg +/-1000) return null; } if (s.length < 5 && s.indexOf(".") < 0 && s.indexOf("/") < 0) { // assume it's just a year. time.year = s; return $P.processTimeObject(time); } data = s.match(this.regex); if (!data || !data.length) { return null; } for (i=0; i < order.length; i++) { switch(order[i]) { case "d": time.day = data[i+1]; break; case "m": time.month = (data[i+1]-1); break; case "y": time.year = data[i+1]; break; } } return $P.processTimeObject(time); } }; $P.Normalizer = { regexData: function () { var $R = Date.CultureInfo.regexPatterns; return utils.buildRegexData([ $R.tomorrow, $R.yesterday, [$R.past, $R.mon], [$R.past, $R.tue], [$R.past, $R.wed], [$R.past, $R.thu], [$R.past, $R.fri], [$R.past, $R.sat], [$R.past, $R.sun] ]); }, basicReplaceHash : function() { var $R = Date.CultureInfo.regexPatterns; return { "January": $R.jan.source, "February": $R.feb, "March": $R.mar, "April": $R.apr, "May": $R.may, "June": $R.jun, "July": $R.jul, "August": $R.aug, "September": $R.sep, "October": $R.oct, "November": $R.nov, "December": $R.dec, "": /\bat\b/gi, " ": /\s{2,}/, "am": $R.inTheMorning, "9am": $R.thisMorning, "pm": $R.inTheEvening, "7pm":$R.thisEvening }; }, keys : function(){ return [ utils.getDateNthString(true, false, 1), // tomorrow utils.getDateNthString(true, false, -1), // yesterday utils.getDateNthString(false, true, "monday"), //last mon utils.getDateNthString(false, true, "tuesday"), //last tues utils.getDateNthString(false, true, "wednesday"), //last wed utils.getDateNthString(false, true, "thursday"), //last thurs utils.getDateNthString(false, true, "friday"), //last fri utils.getDateNthString(false, true, "saturday"), //last sat utils.getDateNthString(false, true, "sunday") //last sun ]; }, buildRegexFunctions: function () { var $R = Date.CultureInfo.regexPatterns; var __ = Date.i18n.__; var tomorrowRE = new RegExp("(\\b\\d\\d?("+__("AM")+"|"+__("PM")+")? )("+$R.tomorrow.source.slice(1)+")", "i"); // adapted tomorrow regex for AM PM relative dates var todayRE = new RegExp($R.today.source + "(?!\\s*([+-]))\\b"); // today, but excludes the math operators (eg "today + 2h") this.replaceFuncs = [ [todayRE, function (full) { return (full.length > 1) ? Date.today().toString("d") : full; }], [tomorrowRE, function(full, m1) { var t = Date.today().addDays(1).toString("d"); return (t + " " + m1); }], [$R.amThisMorning, function(str, am){return am;}], [$R.pmThisEvening, function(str, pm){return pm;}] ]; }, buildReplaceData: function () { this.buildRegexFunctions(); this.replaceHash = utils.addToHash(this.basicReplaceHash(), this.keys(), this.regexData()); }, stringReplaceFuncs: function (s) { for (var i=0; i < this.replaceFuncs.length; i++) { s = s.replace(this.replaceFuncs[i][0], this.replaceFuncs[i][1]); } return s; }, parse: function (s) { s = this.stringReplaceFuncs(s); s = utils.multiReplace(s, this.replaceHash); try { var n = s.split(/([\s\-\.\,\/\x27]+)/); if (n.length === 3 && $P.Numeric.isNumeric(n[0]) && $P.Numeric.isNumeric(n[2]) && (n[2].length >= 4)) { // ok, so we're dealing with x/year. But that's not a full date. // This fixes wonky dateElementOrder parsing when set to dmy order. if (Date.CultureInfo.dateElementOrder[0] === "d") { s = "1/" + n[0] + "/" + n[2]; // set to 1st of month and normalize the seperator } } } catch (e) {} return s; } }; $P.Normalizer.buildReplaceData(); }()); (function () { var $P = Date.Parsing; var _ = $P.Operators = { // // Tokenizers // rtoken: function (r) { // regex token return function (s) { var mx = s.match(r); if (mx) { return ([ mx[0], s.substring(mx[0].length) ]); } else { throw new $P.Exception(s); } }; }, token: function () { // whitespace-eating token return function (s) { return _.rtoken(new RegExp("^\\s*" + s + "\\s*"))(s); }; }, stoken: function (s) { // string token return _.rtoken(new RegExp("^" + s)); }, // Atomic Operators until: function (p) { return function (s) { var qx = [], rx = null; while (s.length) { try { rx = p.call(this, s); } catch (e) { qx.push(rx[0]); s = rx[1]; continue; } break; } return [ qx, s ]; }; }, many: function (p) { return function (s) { var rx = [], r = null; while (s.length) { try { r = p.call(this, s); } catch (e) { return [ rx, s ]; } rx.push(r[0]); s = r[1]; } return [ rx, s ]; }; }, // generator operators -- see below optional: function (p) { return function (s) { var r = null; try { r = p.call(this, s); } catch (e) { return [ null, s ]; } return [ r[0], r[1] ]; }; }, not: function (p) { return function (s) { try { p.call(this, s); } catch (e) { return [null, s]; } throw new $P.Exception(s); }; }, ignore: function (p) { return p ? function (s) { var r = null; r = p.call(this, s); return [null, r[1]]; } : null; }, product: function () { var px = arguments[0], qx = Array.prototype.slice.call(arguments, 1), rx = []; for (var i = 0 ; i < px.length ; i++) { rx.push(_.each(px[i], qx)); } return rx; }, cache: function (rule) { var cache = {}, cache_length = 0, cache_keys = [], CACHE_MAX = Date.Config.CACHE_MAX || 100000, r = null; var cacheCheck = function () { if (cache_length === CACHE_MAX) { // kill several keys, don't want to have to do this all the time... for (var i=0; i < 10; i++) { var key = cache_keys.shift(); if (key) { delete cache[key]; cache_length--; } } } }; return function (s) { cacheCheck(); try { r = cache[s] = (cache[s] || rule.call(this, s)); } catch (e) { r = cache[s] = e; } cache_length++; cache_keys.push(s); if (r instanceof $P.Exception) { throw r; } else { return r; } }; }, // vector operators -- see below any: function () { var px = arguments; return function (s) { var r = null; for (var i = 0; i < px.length; i++) { if (px[i] == null) { continue; } try { r = (px[i].call(this, s)); } catch (e) { r = null; } if (r) { return r; } } throw new $P.Exception(s); }; }, each: function () { var px = arguments; return function (s) { var rx = [], r = null; for (var i = 0; i < px.length ; i++) { if (px[i] == null) { continue; } try { r = (px[i].call(this, s)); } catch (e) { throw new $P.Exception(s); } rx.push(r[0]); s = r[1]; } return [ rx, s]; }; }, all: function () { var px = arguments, _ = _; return _.each(_.optional(px)); }, // delimited operators sequence: function (px, d, c) { d = d || _.rtoken(/^\s*/); c = c || null; if (px.length === 1) { return px[0]; } return function (s) { var r = null, q = null; var rx = []; for (var i = 0; i < px.length ; i++) { try { r = px[i].call(this, s); } catch (e) { break; } rx.push(r[0]); try { q = d.call(this, r[1]); } catch (ex) { q = null; break; } s = q[1]; } if (!r) { throw new $P.Exception(s); } if (q) { throw new $P.Exception(q[1]); } if (c) { try { r = c.call(this, r[1]); } catch (ey) { throw new $P.Exception(r[1]); } } return [ rx, (r?r[1]:s) ]; }; }, // // Composite Operators // between: function (d1, p, d2) { d2 = d2 || d1; var _fn = _.each(_.ignore(d1), p, _.ignore(d2)); return function (s) { var rx = _fn.call(this, s); return [[rx[0][0], r[0][2]], rx[1]]; }; }, list: function (p, d, c) { d = d || _.rtoken(/^\s*/); c = c || null; return (p instanceof Array ? _.each(_.product(p.slice(0, -1), _.ignore(d)), p.slice(-1), _.ignore(c)) : _.each(_.many(_.each(p, _.ignore(d))), px, _.ignore(c))); }, set: function (px, d, c) { d = d || _.rtoken(/^\s*/); c = c || null; return function (s) { // r is the current match, best the current 'best' match // which means it parsed the most amount of input var r = null, p = null, q = null, rx = null, best = [[], s], last = false; // go through the rules in the given set for (var i = 0; i < px.length ; i++) { // last is a flag indicating whether this must be the last element // if there is only 1 element, then it MUST be the last one q = null; p = null; r = null; last = (px.length === 1); // first, we try simply to match the current pattern // if not, try the next pattern try { r = px[i].call(this, s); } catch (e) { continue; } // since we are matching against a set of elements, the first // thing to do is to add r[0] to matched elements rx = [[r[0]], r[1]]; // if we matched and there is still input to parse and // we don't already know this is the last element, // we're going to next check for the delimiter ... // if there's none, or if there's no input left to parse // than this must be the last element after all ... if (r[1].length > 0 && ! last) { try { q = d.call(this, r[1]); } catch (ex) { last = true; } } else { last = true; } // if we parsed the delimiter and now there's no more input, // that means we shouldn't have parsed the delimiter at all // so don't update r and mark this as the last element ... if (!last && q[1].length === 0) { last = true; } // so, if this isn't the last element, we're going to see if // we can get any more matches from the remaining (unmatched) // elements ... if (!last) { // build a list of the remaining rules we can match against, // i.e., all but the one we just matched against var qx = []; for (var j = 0; j < px.length ; j++) { if (i !== j) { qx.push(px[j]); } } // now invoke recursively set with the remaining input // note that we don't include the closing delimiter ... // we'll check for that ourselves at the end p = _.set(qx, d).call(this, q[1]); // if we got a non-empty set as a result ... // (otw rx already contains everything we want to match) if (p[0].length > 0) { // update current result, which is stored in rx ... // basically, pick up the remaining text from p[1] // and concat the result from p[0] so that we don't // get endless nesting ... rx[0] = rx[0].concat(p[0]); rx[1] = p[1]; } } // at this point, rx either contains the last matched element // or the entire matched set that starts with this element. // now we just check to see if this variation is better than // our best so far, in terms of how much of the input is parsed if (rx[1].length < best[1].length) { best = rx; } // if we've parsed all the input, then we're finished if (best[1].length === 0) { break; } } // so now we've either gone through all the patterns trying them // as the initial match; or we found one that parsed the entire // input string ... // if best has no matches, just return empty set ... if (best[0].length === 0) { return best; } // if a closing delimiter is provided, then we have to check it also if (c) { // we try this even if there is no remaining input because the pattern // may well be optional or match empty input ... try { q = c.call(this, best[1]); } catch (ey) { throw new $P.Exception(best[1]); } // it parsed ... be sure to update the best match remaining input best[1] = q[1]; } // if we're here, either there was no closing delimiter or we parsed it // so now we have the best match; just return it! return best; }; }, forward: function (gr, fname) { return function (s) { return gr[fname].call(this, s); }; }, // // Translation Operators // replace: function (rule, repl) { return function (s) { var r = rule.call(this, s); return [repl, r[1]]; }; }, process: function (rule, fn) { return function (s) { var r = rule.call(this, s); return [fn.call(this, r[0]), r[1]]; }; }, min: function (min, rule) { return function (s) { var rx = rule.call(this, s); if (rx[0].length < min) { throw new $P.Exception(s); } return rx; }; } }; // Generator Operators And Vector Operators // Generators are operators that have a signature of F(R) => R, // taking a given rule and returning another rule, such as // ignore, which parses a given rule and throws away the result. // Vector operators are those that have a signature of F(R1,R2,...) => R, // take a list of rules and returning a new rule, such as each. // Generator operators are converted (via the following _generator // function) into functions that can also take a list or array of rules // and return an array of new rules as though the function had been // called on each rule in turn (which is what actually happens). // This allows generators to be used with vector operators more easily. // Example: // each(ignore(foo, bar)) instead of each(ignore(foo), ignore(bar)) // This also turns generators into vector operators, which allows // constructs like: // not(cache(foo, bar)) var _generator = function (op) { function gen() { var args = null, rx = [], px, i; if (arguments.length > 1) { args = Array.prototype.slice.call(arguments); } else if (arguments[0] instanceof Array) { args = arguments[0]; } if (args) { px = args.shift(); if (px.length > 0) { args.unshift(px[i]); rx.push(op.apply(null, args)); args.shift(); return rx; } } else { return op.apply(null, arguments); } } return gen; }; var gx = "optional not ignore cache".split(/\s/); for (var i = 0 ; i < gx.length ; i++) { _[gx[i]] = _generator(_[gx[i]]); } var _vector = function (op) { return function () { if (arguments[0] instanceof Array) { return op.apply(null, arguments[0]); } else { return op.apply(null, arguments); } }; }; var vx = "each any all".split(/\s/); for (var j = 0 ; j < vx.length ; j++) { _[vx[j]] = _vector(_[vx[j]]); } }()); (function () { var $D = Date; var flattenAndCompact = function (ax) { var rx = []; for (var i = 0; i < ax.length; i++) { if (ax[i] instanceof Array) { rx = rx.concat(flattenAndCompact(ax[i])); } else { if (ax[i]) { rx.push(ax[i]); } } } return rx; }; var parseMeridian = function () { if (this.meridian && (this.hour || this.hour === 0)) { if (this.meridian === "a" && this.hour > 11 && Date.Config.strict24hr){ throw "Invalid hour and meridian combination"; } else if (this.meridian === "p" && this.hour < 12 && Date.Config.strict24hr){ throw "Invalid hour and meridian combination"; } else if (this.meridian === "p" && this.hour < 12) { this.hour = this.hour + 12; } else if (this.meridian === "a" && this.hour === 12) { this.hour = 0; } } }; var setDefaults = function () { var now = new Date(); if ((this.hour || this.minute) && (!this.month && !this.year && !this.day)) { this.day = now.getDate(); } if (!this.year) { this.year = now.getFullYear(); } if (!this.month && this.month !== 0) { this.month = now.getMonth(); } if (!this.day) { this.day = 1; } if (!this.hour) { this.hour = 0; } if (!this.minute) { this.minute = 0; } if (!this.second) { this.second = 0; } if (!this.millisecond) { this.millisecond = 0; } }; var finishUtils = { getToday: function () { if (this.now || "hour minute second".indexOf(this.unit) !== -1) { return new Date(); } else { return $D.today(); } }, setDaysFromWeekday: function (today, orient){ var gap; orient = orient || 1; this.unit = "day"; gap = ($D.getDayNumberFromName(this.weekday) - today.getDay()); this.days = gap ? ((gap + (orient * 7)) % 7) : (orient * 7); return this; }, setMonthsFromMonth: function (today, orient) { var gap; orient = orient || 1; this.unit = "month"; gap = (this.month - today.getMonth()); this.months = gap ? ((gap + (orient * 12)) % 12) : (orient * 12); this.month = null; return this; }, setDMYFromWeekday: function () { var d = Date[this.weekday](); this.day = d.getDate(); if (!this.month) { this.month = d.getMonth(); } this.year = d.getFullYear(); return this; }, setUnitValue: function (orient) { if (!this.value && this.operator && this.operator !== null && this[this.unit + "s"] && this[this.unit + "s"] !== null) { this[this.unit + "s"] = this[this.unit + "s"] + ((this.operator === "add") ? 1 : -1) + (this.value||0) * orient; } else if (this[this.unit + "s"] == null || this.operator != null) { if (!this.value) { this.value = 1; } this[this.unit + "s"] = this.value * orient; } }, generateDateFromWeeks: function () { var weekday = (this.weekday !== undefined) ? this.weekday : "today"; var d = Date[weekday]().addWeeks(this.weeks); if (this.now) { d.setTimeToNow(); } return d; } }; $D.Translator = { hour: function (s) { return function () { this.hour = Number(s); }; }, minute: function (s) { return function () { this.minute = Number(s); }; }, second: function (s) { return function () { this.second = Number(s); }; }, /* for ss.s format */ secondAndMillisecond: function (s) { return function () { var mx = s.match(/^([0-5][0-9])\.([0-9]{1,3})/); this.second = Number(mx[1]); this.millisecond = Number(mx[2]); }; }, meridian: function (s) { return function () { this.meridian = s.slice(0, 1).toLowerCase(); }; }, timezone: function (s) { return function () { var n = s.replace(/[^\d\+\-]/g, ""); if (n.length) { this.timezoneOffset = Number(n); } else { this.timezone = s.toLowerCase(); } }; }, day: function (x) { var s = x[0]; return function () { this.day = Number(s.match(/\d+/)[0]); if (this.day < 1) { throw "invalid day"; } }; }, month: function (s) { return function () { this.month = (s.length === 3) ? "jan feb mar apr may jun jul aug sep oct nov dec".indexOf(s)/4 : Number(s) - 1; if (this.month < 0) { throw "invalid month"; } }; }, year: function (s) { return function () { var n = Number(s); this.year = ((s.length > 2) ? n : (n + (((n + 2000) < Date.CultureInfo.twoDigitYearMax) ? 2000 : 1900))); }; }, rday: function (s) { return function () { switch (s) { case "yesterday": this.days = -1; break; case "tomorrow": this.days = 1; break; case "today": this.days = 0; break; case "now": this.days = 0; this.now = true; break; } }; }, finishExact: function (x) { var d; x = (x instanceof Array) ? x : [x]; for (var i = 0 ; i < x.length ; i++) { if (x[i]) { x[i].call(this); } } setDefaults.call(this); parseMeridian.call(this); if (this.day > $D.getDaysInMonth(this.year, this.month)) { throw new RangeError(this.day + " is not a valid value for days."); } d = new Date(this.year, this.month, this.day, this.hour, this.minute, this.second, this.millisecond); if (this.year < 100) { d.setFullYear(this.year); // means years less that 100 are process correctly. JS will parse it otherwise as 1900-1999. } if (this.timezone) { d.set({ timezone: this.timezone }); } else if (this.timezoneOffset) { d.set({ timezoneOffset: this.timezoneOffset }); } return d; }, finish: function (x) { var today, expression, orient, temp; x = (x instanceof Array) ? flattenAndCompact(x) : [ x ]; if (x.length === 0) { return null; } for (var i = 0 ; i < x.length ; i++) { if (typeof x[i] === "function") { x[i].call(this); } } if (this.now && !this.unit && !this.operator) { return new Date(); } else { today = finishUtils.getToday.call(this); } expression = !!(this.days && this.days !== null || this.orient || this.operator); orient = ((this.orient === "past" || this.operator === "subtract") ? -1 : 1); if (this.month && this.unit === "week") { this.value = this.month + 1; delete this.month; delete this.day; } if ((this.month || this.month === 0) && "year day hour minute second".indexOf(this.unit) !== -1) { if (!this.value) { this.value = this.month + 1; } this.month = null; expression = true; } if (!expression && this.weekday && !this.day && !this.days) { finishUtils.setDMYFromWeekday.call(this); } if (expression && this.weekday && this.unit !== "month" && this.unit !== "week") { finishUtils.setDaysFromWeekday.call(this, today, orient); } if (this.weekday && this.unit !== "week" && !this.day && !this.days) { temp = Date[this.weekday](); this.day = temp.getDate(); if (temp.getMonth() !== today.getMonth()) { this.month = temp.getMonth(); } } if (this.month && this.unit === "day" && this.operator) { if (!this.value) { this.value = (this.month + 1); } this.month = null; } if (this.value != null && this.month != null && this.year != null) { this.day = this.value * 1; } if (this.month && !this.day && this.value) { today.set({ day: this.value * 1 }); if (!expression) { this.day = this.value * 1; } } if (!this.month && this.value && this.unit === "month" && !this.now) { this.month = this.value; expression = true; } if (expression && (this.month || this.month === 0) && this.unit !== "year") { finishUtils.setMonthsFromMonth.call(this, today, orient); } if (!this.unit) { this.unit = "day"; } finishUtils.setUnitValue.call(this, orient); parseMeridian.call(this); if ((this.month || this.month === 0) && !this.day) { this.day = 1; } if (!this.orient && !this.operator && this.unit === "week" && this.value && !this.day && !this.month) { return Date.today().setWeek(this.value); } if (this.unit === "week" && this.weeks && !this.day && !this.month) { return finishUtils.generateDateFromWeeks.call(this); } if (expression && this.timezone && this.day && this.days) { this.day = this.days; } if (expression){ today.add(this); } else { today.set(this); } if (this.timezone) { this.timezone = this.timezone.toUpperCase(); var offset = $D.getTimezoneOffset(this.timezone); var timezone; if (today.hasDaylightSavingTime()) { // lets check that we're being sane with timezone setting timezone = $D.getTimezoneAbbreviation(offset, today.isDaylightSavingTime()); if (timezone !== this.timezone) { // bugger, we're in a place where things like EST vs EDT matters. if (today.isDaylightSavingTime()) { today.addHours(-1); } else { today.addHours(1); } } } today.setTimezoneOffset(offset); } return today; } }; }()); (function () { var $D = Date; $D.Grammar = {}; var _ = $D.Parsing.Operators, g = $D.Grammar, t = $D.Translator, _fn; // Allow rolling up into general purpose rules _fn = function () { return _.each(_.any.apply(null, arguments), _.not(g.ctoken2("timeContext"))); }; g.datePartDelimiter = _.rtoken(/^([\s\-\.\,\/\x27]+)/); g.timePartDelimiter = _.stoken(":"); g.whiteSpace = _.rtoken(/^\s*/); g.generalDelimiter = _.rtoken(/^(([\s\,]|at|@|on)+)/); var _C = {}; g.ctoken = function (keys) { var fn = _C[keys]; if (! fn) { var c = Date.CultureInfo.regexPatterns; var kx = keys.split(/\s+/), px = []; for (var i = 0; i < kx.length ; i++) { px.push(_.replace(_.rtoken(c[kx[i]]), kx[i])); } fn = _C[keys] = _.any.apply(null, px); } return fn; }; g.ctoken2 = function (key) { return _.rtoken(Date.CultureInfo.regexPatterns[key]); }; var cacheProcessRtoken = function (key, token, type, eachToken) { if (eachToken) { g[key] = _.cache(_.process(_.each(_.rtoken(token),_.optional(g.ctoken2(eachToken))), type)); } else { g[key] = _.cache(_.process(_.rtoken(token), type)); } }; var cacheProcessCtoken = function (token, type) { return _.cache(_.process(g.ctoken2(token), type)); }; var _F = {}; //function cache var _get = function (f) { _F[f] = (_F[f] || g.format(f)[0]); return _F[f]; }; g.allformats = function (fx) { var rx = []; if (fx instanceof Array) { for (var i = 0; i < fx.length; i++) { rx.push(_get(fx[i])); } } else { rx.push(_get(fx)); } return rx; }; g.formats = function (fx) { if (fx instanceof Array) { var rx = []; for (var i = 0 ; i < fx.length ; i++) { rx.push(_get(fx[i])); } return _.any.apply(null, rx); } else { return _get(fx); } }; var grammarFormats = { timeFormats: function(){ var i, RTokenKeys = [ "h", "hh", "H", "HH", "m", "mm", "s", "ss", "ss.s", "z", "zz" ], RToken = [ /^(0[0-9]|1[0-2]|[1-9])/, /^(0[0-9]|1[0-2])/, /^([0-1][0-9]|2[0-3]|[0-9])/, /^([0-1][0-9]|2[0-3])/, /^([0-5][0-9]|[0-9])/, /^[0-5][0-9]/, /^([0-5][0-9]|[0-9])/, /^[0-5][0-9]/, /^[0-5][0-9]\.[0-9]{1,3}/, /^((\+|\-)\s*\d\d\d\d)|((\+|\-)\d\d\:?\d\d)/, /^((\+|\-)\s*\d\d\d\d)|((\+|\-)\d\d\:?\d\d)/ ], tokens = [ t.hour, t.hour, t.hour, t.hour, t.minute, t.minute, t.second, t.second, t.secondAndMillisecond, t.timezone, t.timezone ]; for (i=0; i < RTokenKeys.length; i++) { cacheProcessRtoken(RTokenKeys[i], RToken[i], tokens[i]); } g.hms = _.cache(_.sequence([g.H, g.m, g.s], g.timePartDelimiter)); g.t = cacheProcessCtoken("shortMeridian", t.meridian); g.tt = cacheProcessCtoken("longMeridian", t.meridian); g.zzz = cacheProcessCtoken("timezone", t.timezone); g.timeSuffix = _.each(_.ignore(g.whiteSpace), _.set([ g.tt, g.zzz ])); g.time = _.each(_.optional(_.ignore(_.stoken("T"))), g.hms, g.timeSuffix); }, dateFormats: function () { // pre-loaded rules for different date part order preferences var _setfn = function () { return _.set(arguments, g.datePartDelimiter); }; var i, RTokenKeys = [ "d", "dd", "M", "MM", "y", "yy", "yyy", "yyyy" ], RToken = [ /^([0-2]\d|3[0-1]|\d)/, /^([0-2]\d|3[0-1])/, /^(1[0-2]|0\d|\d)/, /^(1[0-2]|0\d)/, /^(\d+)/, /^(\d\d)/, /^(\d\d?\d?\d?)/, /^(\d\d\d\d)/ ], tokens = [ t.day, t.day, t.month, t.month, t.year, t.year, t.year, t.year ], eachToken = [ "ordinalSuffix", "ordinalSuffix" ]; for (i=0; i < RTokenKeys.length; i++) { cacheProcessRtoken(RTokenKeys[i], RToken[i], tokens[i], eachToken[i]); } g.MMM = g.MMMM = _.cache(_.process(g.ctoken("jan feb mar apr may jun jul aug sep oct nov dec"), t.month)); g.ddd = g.dddd = _.cache(_.process(g.ctoken("sun mon tue wed thu fri sat"), function (s) { return function () { this.weekday = s; }; } )); g.day = _fn(g.d, g.dd); g.month = _fn(g.M, g.MMM); g.year = _fn(g.yyyy, g.yy); g.mdy = _setfn(g.ddd, g.month, g.day, g.year); g.ymd = _setfn(g.ddd, g.year, g.month, g.day); g.dmy = _setfn(g.ddd, g.day, g.month, g.year); g.date = function (s) { return ((g[Date.CultureInfo.dateElementOrder] || g.mdy).call(this, s)); }; }, relative: function () { // relative date / time expressions g.orientation = _.process(g.ctoken("past future"), function (s) { return function () { this.orient = s; }; } ); g.operator = _.process(g.ctoken("add subtract"), function (s) { return function () { this.operator = s; }; } ); g.rday = _.process(g.ctoken("yesterday tomorrow today now"), t.rday); g.unit = _.process(g.ctoken("second minute hour day week month year"), function (s) { return function () { this.unit = s; }; } ); } }; g.buildGrammarFormats = function () { // these need to be rebuilt every time the language changes. _C = {}; grammarFormats.timeFormats(); grammarFormats.dateFormats(); grammarFormats.relative(); g.value = _.process(_.rtoken(/^([-+]?\d+)?(st|nd|rd|th)?/), function (s) { return function () { this.value = s.replace(/\D/g, ""); }; } ); g.expression = _.set([g.rday, g.operator, g.value, g.unit, g.orientation, g.ddd, g.MMM ]); g.format = _.process(_.many( _.any( // translate format specifiers into grammar rules _.process( _.rtoken(/^(dd?d?d?(?!e)|MM?M?M?|yy?y?y?|hh?|HH?|mm?|ss?|tt?|zz?z?)/), function (fmt) { if (g[fmt]) { return g[fmt]; } else { throw $D.Parsing.Exception(fmt); } } ), // translate separator tokens into token rules _.process(_.rtoken(/^[^dMyhHmstz]+/), // all legal separators function (s) { return _.ignore(_.stoken(s)); } ) ) ), // construct the parser ... function (rules) { return _.process(_.each.apply(null, rules), t.finishExact); } ); // starting rule for general purpose grammar g._start = _.process(_.set([ g.date, g.time, g.expression ], g.generalDelimiter, g.whiteSpace), t.finish); }; g.buildGrammarFormats(); // parsing date format specifiers - ex: "h:m:s tt" // this little guy will generate a custom parser based // on the format string, ex: g.format("h:m:s tt") // check for these formats first g._formats = g.formats([ "\"yyyy-MM-ddTHH:mm:ssZ\"", "yyyy-MM-ddTHH:mm:ss.sz", "yyyy-MM-ddTHH:mm:ssZ", "yyyy-MM-ddTHH:mm:ssz", "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-ddTHH:mmZ", "yyyy-MM-ddTHH:mmz", "yyyy-MM-ddTHH:mm", "ddd, MMM dd, yyyy H:mm:ss tt", "ddd MMM d yyyy HH:mm:ss zzz", "MMddyyyy", "ddMMyyyy", "Mddyyyy", "ddMyyyy", "Mdyyyy", "dMyyyy", "yyyy", "Mdyy", "dMyy", "d" ]); // real starting rule: tries selected formats first, // then general purpose rule g.start = function (s) { try { var r = g._formats.call({}, s); if (r[1].length === 0) { return r; } } catch (e) {} return g._start.call({}, s); }; }()); (function () { var $D = Date; /** * @desc Converts the specified string value into its JavaScript Date equivalent using CultureInfo specific format information. * * Example

	///////////
	// Dates //
	///////////

	// 15-Oct-2004
	var d1 = Date.parse("10/15/2004");

	// 15-Oct-2004
	var d1 = Date.parse("15-Oct-2004");

	// 15-Oct-2004
	var d1 = Date.parse("2004.10.15");

	//Fri Oct 15, 2004
	var d1 = Date.parse("Fri Oct 15, 2004");

	///////////
	// Times //
	///////////

	// Today at 10 PM.
	var d1 = Date.parse("10 PM");

	// Today at 10:30 PM.
	var d1 = Date.parse("10:30 P.M.");

	// Today at 6 AM.
	var d1 = Date.parse("06am");

	/////////////////////
	// Dates and Times //
	/////////////////////

	// 8-July-2004 @ 10:30 PM
	var d1 = Date.parse("July 8th, 2004, 10:30 PM");

	// 1-July-2004 @ 10:30 PM
	var d1 = Date.parse("2004-07-01T22:30:00");

	////////////////////
	// Relative Dates //
	////////////////////

	// Returns today's date. The string "today" is culture specific.
	var d1 = Date.parse("today");

	// Returns yesterday's date. The string "yesterday" is culture specific.
	var d1 = Date.parse("yesterday");

	// Returns the date of the next thursday.
	var d1 = Date.parse("Next thursday");

	// Returns the date of the most previous monday.
	var d1 = Date.parse("last monday");

	// Returns today's day + one year.
	var d1 = Date.parse("next year");

	///////////////
	// Date Math //
	///////////////

	// Today + 2 days
	var d1 = Date.parse("t+2");

	// Today + 2 days
	var d1 = Date.parse("today + 2 days");

	// Today + 3 months
	var d1 = Date.parse("t+3m");

	// Today - 1 year
	var d1 = Date.parse("today - 1 year");

	// Today - 1 year
	var d1 = Date.parse("t-1y"); 


	/////////////////////////////
	// Partial Dates and Times //
	/////////////////////////////

	// July 15th of this year.
	var d1 = Date.parse("July 15");

	// 15th day of current day and year.
	var d1 = Date.parse("15");

	// July 1st of current year at 10pm.
	var d1 = Date.parse("7/1 10pm");
	
* * @param {String} The string value to convert into a Date object [Required] * @return {Date} A Date object or null if the string cannot be converted into a Date. */ var parseUtils = { removeOrds: function (s) { ords = s.match(/\b(\d+)(?:st|nd|rd|th)\b/); // find ordinal matches s = ((ords && ords.length === 2) ? s.replace(ords[0], ords[1]) : s); return s; }, grammarParser: function (s) { var r = null; try { r = $D.Grammar.start.call({}, s.replace(/^\s*(\S*(\s+\S+)*)\s*$/, "$1")); } catch (e) { return null; } return ((r[1].length === 0) ? r[0] : null); }, nativeFallback: function(s) { var t; try { // ok we haven't parsed it, last ditch attempt with the built-in parser. t = Date._parse(s); return (t || t === 0) ? new Date(t) : null; } catch (e) { return null; } } }; function parse (s) { var d; if (!s) { return null; } if (s instanceof Date) { return s.clone(); } if (s.length >= 4 && s.charAt(0) !== "0" && s.charAt(0) !== "+"&& s.charAt(0) !== "-") { // ie: 2004 will pass, 0800 won't. // Start with specific formats d = $D.Parsing.ISO.parse(s) || $D.Parsing.Numeric.parse(s); } if (d instanceof Date && !isNaN(d.getTime())) { return d; } else { // find ordinal dates (1st, 3rd, 8th, etc and remove them as they cause parsing issues) s = $D.Parsing.Normalizer.parse(parseUtils.removeOrds(s)); d = parseUtils.grammarParser(s); if (d !== null) { return d; } else { return parseUtils.nativeFallback(s); } } } if (!$D._parse) { $D._parse = $D.parse; } $D.parse = parse; Date.getParseFunction = function (fx) { var fns = Date.Grammar.allformats(fx); return function (s) { var r = null; for (var i = 0; i < fns.length; i++) { try { r = fns[i].call({}, s); } catch (e) { continue; } if (r[1].length === 0) { return r[0]; } } return null; }; }; /** * Converts the specified string value into its JavaScript Date equivalent using the specified format {String} or formats {Array} and the CultureInfo specific format information. * The format of the string value must match one of the supplied formats exactly. * * Example

	// 15-Oct-2004
	var d1 = Date.parseExact("10/15/2004", "M/d/yyyy");

	// 15-Oct-2004
	var d1 = Date.parse("15-Oct-2004", "M-ddd-yyyy");

	// 15-Oct-2004
	var d1 = Date.parse("2004.10.15", "yyyy.MM.dd");

	// Multiple formats
	var d1 = Date.parseExact("10/15/2004", ["M/d/yyyy", "MMMM d, yyyy"]);
	
* * @param {String} The string value to convert into a Date object [Required]. * @param {Object} The expected format {String} or an array of expected formats {Array} of the date string [Required]. * @return {Date} A Date object or null if the string cannot be converted into a Date. */ $D.parseExact = function (s, fx) { return $D.getParseFunction(fx)(s); }; }()); (function () { var $D = Date, $P = $D.prototype, // $C = $D.CultureInfo, // not used atm p = function (s, l) { if (!l) { l = 2; } return ("000" + s).slice(l * -1); }; /** * Converts a PHP format string to Java/.NET format string. * A PHP format string can be used with ._format or .format. * A Java/.NET format string can be used with .toString(). * The .parseExact function will only accept a Java/.NET format string * * Example * var f1 = "%m/%d/%y" * var f2 = Date.normalizeFormat(f1); // "MM/dd/yy" * * new Date().format(f1); // "04/13/08" * new Date()._format(f1); // "04/13/08" * new Date().toString(f2); // "04/13/08" * * var date = Date.parseExact("04/13/08", f2); // Sun Apr 13 2008 * * @param {String} A PHP format string consisting of one or more format spcifiers. * @return {String} The PHP format converted to a Java/.NET format string. */ var normalizerSubstitutions = { "d" : "dd", "%d": "dd", "D" : "ddd", "%a": "ddd", "j" : "dddd", "l" : "dddd", "%A": "dddd", "S" : "S", "F" : "MMMM", "%B": "MMMM", "m" : "MM", "%m": "MM", "M" : "MMM", "%b": "MMM", "%h": "MMM", "n" : "M", "Y" : "yyyy", "%Y": "yyyy", "y" : "yy", "%y": "yy", "g" : "h", "%I": "h", "G" : "H", "h" : "hh", "H" : "HH", "%H": "HH", "i" : "mm", "%M": "mm", "s" : "ss", "%S": "ss", "%r": "hh:mm tt", "%R": "H:mm", "%T": "H:mm:ss", "%X": "t", "%x": "d", "%e": "d", "%D": "MM/dd/yy", "%n": "\\n", "%t": "\\t", "e" : "z", "T" : "z", "%z": "z", "%Z": "z", "Z" : "ZZ", "N" : "u", "w" : "u", "%w": "u", "W" : "W", "%V": "W" }; var normalizer = { substitutes: function (m) { return normalizerSubstitutions[m]; }, interpreted: function (m, x) { var y; switch (m) { case "%u": return x.getDay() + 1; case "z": return x.getOrdinalNumber(); case "%j": return p(x.getOrdinalNumber(), 3); case "%U": var d1 = x.clone().set({month: 0, day: 1}).addDays(-1).moveToDayOfWeek(0), d2 = x.clone().addDays(1).moveToDayOfWeek(0, -1); return (d2 < d1) ? "00" : p((d2.getOrdinalNumber() - d1.getOrdinalNumber()) / 7 + 1); case "%W": return p(x.getWeek()); case "t": return $D.getDaysInMonth(x.getFullYear(), x.getMonth()); case "o": case "%G": return x.setWeek(x.getISOWeek()).toString("yyyy"); case "%g": return x._format("%G").slice(-2); case "a": case "%p": return t("tt").toLowerCase(); case "A": return t("tt").toUpperCase(); case "u": return p(x.getMilliseconds(), 3); case "I": return (x.isDaylightSavingTime()) ? 1 : 0; case "O": return x.getUTCOffset(); case "P": y = x.getUTCOffset(); return y.substring(0, y.length - 2) + ":" + y.substring(y.length - 2); case "B": var now = new Date(); return Math.floor(((now.getHours() * 3600) + (now.getMinutes() * 60) + now.getSeconds() + (now.getTimezoneOffset() + 60) * 60) / 86.4); case "c": return x.toISOString().replace(/\"/g, ""); case "U": return $D.strtotime("now"); case "%c": return t("d") + " " + t("t"); case "%C": return Math.floor(x.getFullYear() / 100 + 1); } }, shouldOverrideDefaults: function (m) { switch (m) { case "%e": return true; default: return false; } }, parse: function (m, context) { var formatString, c = context || new Date(); formatString = normalizer.substitutes(m); if (formatString) { return formatString; } formatString = normalizer.interpreted(m, c); if (formatString) { return formatString; } else { return m; } } }; $D.normalizeFormat = function (format, context) { return format.replace(/(%|\\)?.|%%/g, function(t){ return normalizer.parse(t, context); }); }; /** * Format a local Unix timestamp according to locale settings * * Example: * Date.strftime("%m/%d/%y", new Date()); // "04/13/08" * Date.strftime("c", "2008-04-13T17:52:03Z"); // "04/13/08" * * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @param {Number|String} The number representing the number of seconds that have elapsed since January 1, 1970 (local time). * @return {String} A string representation of the current Date object. */ $D.strftime = function (format, time) { var d = Date.parse(time); return d._format(format); }; /** * Parse any textual datetime description into a Unix timestamp. * A Unix timestamp is the number of seconds that have elapsed since January 1, 1970 (midnight UTC/GMT). * * Example: * Date.strtotime("04/13/08"); // 1208044800 * Date.strtotime("1970-01-01T00:00:00Z"); // 0 * * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @param {Object} A string or date object. * @return {String} A string representation of the current Date object. */ $D.strtotime = function (time) { var d = $D.parse(time); return Math.round($D.UTC(d.getUTCFullYear(), d.getUTCMonth(), d.getUTCDate(), d.getUTCHours(), d.getUTCMinutes(), d.getUTCSeconds(), d.getUTCMilliseconds()) / 1000); }; /** * Converts the value of the current Date object to its equivalent string representation using a PHP/Unix style of date format specifiers. * Format Specifiers * Format Description Example * ------ --------------------------------------------------------------------------- ----------------------- * %a abbreviated weekday name according to the current localed "Mon" through "Sun" * %A full weekday name according to the current localed "Sunday" through "Saturday" * %b abbreviated month name according to the current localed "Jan" through "Dec" * %B full month name according to the current locale "January" through "December" * %c preferred date and time representation for the current locale "4/13/2008 12:33 PM" * %C century number (the year divided by 100 and truncated to an integer) "00" to "99" * %d day of the month as a decimal number "01" to "31" * %D same as %m/%d/%y "04/13/08" * %e day of the month as a decimal number, a single digit is preceded by a space "1" to "31" * %g like %G, but without the century "08" * %G The 4-digit year corresponding to the ISO week number (see %V). "2008" * This has the same format and value as %Y, except that if the ISO week number * belongs to the previous or next year, that year is used instead. * %h same as %b "Jan" through "Dec" * %H hour as a decimal number using a 24-hour clock. "00" to "23" * %I hour as a decimal number using a 12-hour clock. "01" to "12" * %j day of the year as a decimal number. "001" to "366" * %m month as a decimal number. "01" to "12" * %M minute as a decimal number. "00" to "59" * %n newline character "\n" * %p either "am" or "pm" according to the given time value, or the "am" or "pm" * corresponding strings for the current locale. * %r time in a.m. and p.m. notation "8:44 PM" * %R time in 24 hour notation "20:44" * %S second as a decimal number "00" to "59" * %t tab character "\t" * %T current time, equal to %H:%M:%S "12:49:11" * %u weekday as a decimal number ["1", "7"], with "1" representing Monday "1" to "7" * %U week number of the current year as a decimal number, starting with the "0" to ("52" or "53") * first Sunday as the first day of the first week * %V The ISO 8601:1988 week number of the current year as a decimal number, "00" to ("52" or "53") * range 01 to 53, where week 1 is the first week that has at least 4 days * in the current year, and with Monday as the first day of the week. * (Use %G or %g for the year component that corresponds to the week number * for the specified timestamp.) * %W week number of the current year as a decimal number, starting with the "00" to ("52" or "53") * first Monday as the first day of the first week * %w day of the week as a decimal, Sunday being "0" "0" to "6" * %x preferred date representation for the current locale without the time "4/13/2008" * %X preferred time representation for the current locale without the date "12:53:05" * %y year as a decimal number without a century "00" "99" * %Y year as a decimal number including the century "2008" * %Z time zone or name or abbreviation "UTC", "EST", "PST" * %z same as %Z * %% a literal "%" characters "%" * d Day of the month, 2 digits with leading zeros "01" to "31" * D A textual representation of a day, three letters "Mon" through "Sun" * j Day of the month without leading zeros "1" to "31" * l A full textual representation of the day of the week (lowercase "L") "Sunday" through "Saturday" * N ISO-8601 numeric representation of the day of the week (added in PHP 5.1.0) "1" (for Monday) through "7" (for Sunday) * S English ordinal suffix for the day of the month, 2 characters "st", "nd", "rd" or "th". Works well with j * w Numeric representation of the day of the week "0" (for Sunday) through "6" (for Saturday) * z The day of the year (starting from "0") "0" through "365" * W ISO-8601 week number of year, weeks starting on Monday "00" to ("52" or "53") * F A full textual representation of a month, such as January or March "January" through "December" * m Numeric representation of a month, with leading zeros "01" through "12" * M A short textual representation of a month, three letters "Jan" through "Dec" * n Numeric representation of a month, without leading zeros "1" through "12" * t Number of days in the given month "28" through "31" * L Whether it's a leap year "1" if it is a leap year, "0" otherwise * o ISO-8601 year number. This has the same value as Y, except that if the "2008" * ISO week number (W) belongs to the previous or next year, that year * is used instead. * Y A full numeric representation of a year, 4 digits "2008" * y A two digit representation of a year "08" * a Lowercase Ante meridiem and Post meridiem "am" or "pm" * A Uppercase Ante meridiem and Post meridiem "AM" or "PM" * B Swatch Internet time "000" through "999" * g 12-hour format of an hour without leading zeros "1" through "12" * G 24-hour format of an hour without leading zeros "0" through "23" * h 12-hour format of an hour with leading zeros "01" through "12" * H 24-hour format of an hour with leading zeros "00" through "23" * i Minutes with leading zeros "00" to "59" * s Seconds, with leading zeros "00" through "59" * u Milliseconds "54321" * e Timezone identifier "UTC", "EST", "PST" * I Whether or not the date is in daylight saving time (uppercase i) "1" if Daylight Saving Time, "0" otherwise * O Difference to Greenwich time (GMT) in hours "+0200", "-0600" * P Difference to Greenwich time (GMT) with colon between hours and minutes "+02:00", "-06:00" * T Timezone abbreviation "UTC", "EST", "PST" * Z Timezone offset in seconds. The offset for timezones west of UTC is "-43200" through "50400" * always negative, and for those east of UTC is always positive. * c ISO 8601 date "2004-02-12T15:19:21+00:00" * r RFC 2822 formatted date "Thu, 21 Dec 2000 16:01:07 +0200" * U Seconds since the Unix Epoch (January 1 1970 00:00:00 GMT) "0" * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @return {String} A string representation of the current Date object. */ var formatReplace = function (context) { return function (m) { var formatString, override = false; if (m.charAt(0) === "\\" || m.substring(0, 2) === "%%") { return m.replace("\\", "").replace("%%", "%"); } override = normalizer.shouldOverrideDefaults(m); formatString = $D.normalizeFormat(m, context); if (formatString) { return context.toString(formatString, override); } }; }; $P._format = function (format) { var formatter = formatReplace(this); if (!format) { return this._toString(); } else { return format.replace(/(%|\\)?.|%%/g, formatter); } }; if (!$P.format) { $P.format = $P._format; } }()); (function () { "use strict"; var gFn = function (attr) { return function () { return this[attr]; }; }; var sFn = function (attr) { return function (val) { this[attr] = val; return this; }; }; var attrs = ["years", "months", "days", "hours", "minutes", "seconds", "milliseconds"]; var addSetFuncs = function (context, attrs) { for (var i = 0; i < attrs.length ; i++) { var $a = attrs[i], $b = $a.slice(0, 1).toUpperCase() + $a.slice(1); context.prototype[$a] = 0; context.prototype["get" + $b] = gFn($a); context.prototype["set" + $b] = sFn($a); } }; /** * new TimeSpan(milliseconds); * new TimeSpan(days, hours, minutes, seconds); * new TimeSpan(days, hours, minutes, seconds, milliseconds); */ var TimeSpan = function (days, hours, minutes, seconds, milliseconds) { if (arguments.length === 1 && typeof days === "number") { var orient = (days < 0) ? -1 : +1; var millsLeft = Math.abs(days); this.setDays(Math.floor(millsLeft / 86400000) * orient); millsLeft = millsLeft % 86400000; this.setHours(Math.floor(millsLeft / 3600000) * orient); millsLeft = millsLeft % 3600000; this.setMinutes(Math.floor(millsLeft / 60000) * orient); millsLeft = millsLeft % 60000; this.setSeconds(Math.floor(millsLeft / 1000) * orient); millsLeft = millsLeft % 1000; this.setMilliseconds(millsLeft * orient); } else { this.set(days, hours, minutes, seconds, milliseconds); } this.getTotalMilliseconds = function () { return (this.getDays() * 86400000) + (this.getHours() * 3600000) + (this.getMinutes() * 60000) + (this.getSeconds() * 1000); }; this.compareTo = function (time) { var t1 = new Date(1970, 1, 1, this.getHours(), this.getMinutes(), this.getSeconds()), t2; if (time === null) { t2 = new Date(1970, 1, 1, 0, 0, 0); } else { t2 = new Date(1970, 1, 1, time.getHours(), time.getMinutes(), time.getSeconds()); } return (t1 < t2) ? -1 : (t1 > t2) ? 1 : 0; }; this.equals = function (time) { return (this.compareTo(time) === 0); }; this.add = function (time) { return (time === null) ? this : this.addSeconds(time.getTotalMilliseconds() / 1000); }; this.subtract = function (time) { return (time === null) ? this : this.addSeconds(-time.getTotalMilliseconds() / 1000); }; this.addDays = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 86400000)); }; this.addHours = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 3600000)); }; this.addMinutes = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 60000)); }; this.addSeconds = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 1000)); }; this.addMilliseconds = function (n) { return new TimeSpan(this.getTotalMilliseconds() + n); }; this.get12HourHour = function () { return (this.getHours() > 12) ? this.getHours() - 12 : (this.getHours() === 0) ? 12 : this.getHours(); }; this.getDesignator = function () { return (this.getHours() < 12) ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator; }; this.toString = function (format) { this._toString = function () { if (this.getDays() !== null && this.getDays() > 0) { return this.getDays() + "." + this.getHours() + ":" + this.p(this.getMinutes()) + ":" + this.p(this.getSeconds()); } else { return this.getHours() + ":" + this.p(this.getMinutes()) + ":" + this.p(this.getSeconds()); } }; this.p = function (s) { return (s.toString().length < 2) ? "0" + s : s; }; var me = this; return format ? format.replace(/dd?|HH?|hh?|mm?|ss?|tt?/g, function (format) { switch (format) { case "d": return me.getDays(); case "dd": return me.p(me.getDays()); case "H": return me.getHours(); case "HH": return me.p(me.getHours()); case "h": return me.get12HourHour(); case "hh": return me.p(me.get12HourHour()); case "m": return me.getMinutes(); case "mm": return me.p(me.getMinutes()); case "s": return me.getSeconds(); case "ss": return me.p(me.getSeconds()); case "t": return ((me.getHours() < 12) ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator).substring(0, 1); case "tt": return (me.getHours() < 12) ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator; } } ) : this._toString(); }; return this; }; addSetFuncs(TimeSpan, attrs.slice(2)); TimeSpan.prototype.set = function (days, hours, minutes, seconds, milliseconds){ this.setDays(days || this.getDays()); this.setHours(hours || this.getHours()); this.setMinutes(minutes || this.getMinutes()); this.setSeconds(seconds || this.getSeconds()); this.setMilliseconds(milliseconds || this.getMilliseconds()); }; /** * Gets the time of day for this date instances. * @return {TimeSpan} TimeSpan */ Date.prototype.getTimeOfDay = function () { return new TimeSpan(0, this.getHours(), this.getMinutes(), this.getSeconds(), this.getMilliseconds()); }; Date.TimeSpan = TimeSpan; if (typeof window !== "undefined" ) { // keeping API compatible for v1.x window.TimeSpan = TimeSpan; } }()); (function () { "use strict"; var attrs = ["years", "months", "days", "hours", "minutes", "seconds", "milliseconds"]; var gFn = function (attr) { return function () { return this[attr]; }; }; var sFn = function (attr) { return function (val) { this[attr] = val; return this; }; }; var addSetFuncs = function (context, attrs) { for (var i = 0; i < attrs.length ; i++) { var $a = attrs[i], $b = $a.slice(0, 1).toUpperCase() + $a.slice(1); context.prototype[$a] = 0; context.prototype["get" + $b] = gFn($a); context.prototype["set" + $b] = sFn($a); } }; var setMonthsAndYears = function (orient, d1, d2, context) { function inc() { d1.addMonths(-orient); context.months++; if (context.months === 12) { context.years++; context.months = 0; } } if (orient === +1) { while (d1 > d2) { inc(); } } else { while (d1 < d2) { inc(); } } context.months--; context.months *= orient; context.years *= orient; }; var adjustForDST = function(orient, startDate, endDate) { var hasDSTMismatch = (false === (startDate.isDaylightSavingTime() === endDate.isDaylightSavingTime())); if (hasDSTMismatch && orient === 1) { startDate.addHours(-1); } else if (hasDSTMismatch) { startDate.addHours(1); } }; /** * TimePeriod(startDate, endDate); * TimePeriod(years, months, days, hours, minutes, seconds, milliseconds); */ var TimePeriod = function (years, months, days, hours, minutes, seconds, milliseconds) { if (arguments.length === 7) { this.set(years, months, days, hours, minutes, seconds, milliseconds); } else if (arguments.length === 2 && arguments[0] instanceof Date && arguments[1] instanceof Date) { var startDate = arguments[0].clone(); var endDate = arguments[1].clone(); var orient = (startDate > endDate) ? +1 : -1; this.dates = { start: arguments[0].clone(), end: arguments[1].clone() }; setMonthsAndYears(orient, startDate, endDate, this); adjustForDST(orient, startDate, endDate); // // TODO - adjust for DST var diff = endDate - startDate; if (diff !== 0) { var ts = new TimeSpan(diff); this.set(this.years, this.months, ts.getDays(), ts.getHours(), ts.getMinutes(), ts.getSeconds(), ts.getMilliseconds()); } } return this; }; // create all the set functions. addSetFuncs(TimePeriod, attrs); TimePeriod.prototype.set = function (years, months, days, hours, minutes, seconds, milliseconds){ this.setYears(years || this.getYears()); this.setMonths(months || this.getMonths()); this.setDays(days || this.getDays()); this.setHours(hours || this.getHours()); this.setMinutes(minutes || this.getMinutes()); this.setSeconds(seconds || this.getSeconds()); this.setMilliseconds(milliseconds || this.getMilliseconds()); }; Date.TimePeriod = TimePeriod; if (typeof window !== "undefined") { // keeping API compatible for v1.x window.TimePeriod = TimePeriod; } }()); ================================================ FILE: build/date-zh-TW.js ================================================ /** * @overview datejs * @version 1.0.0-rc3 * @author Gregory Wild-Smith * @copyright 2015 Gregory Wild-Smith * @license MIT * @homepage https://github.com/abritinthebay/datejs */ /* * DateJS Culture String File * Country Code: zh-TW * Name: Chinese (Taiwan) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["zh-TW"] = { "name": "zh-TW", "englishName": "Chinese (Taiwan)", "nativeName": "中文(台灣)", "Sunday": "星期日", "Monday": "星期一", "Tuesday": "星期二", "Wednesday": "星期三", "Thursday": "星期四", "Friday": "星期五", "Saturday": "星期六", "Sun": "星期日", "Mon": "星期一", "Tue": "星期二", "Wed": "星期三", "Thu": "星期四", "Fri": "星期五", "Sat": "星期六", "Su": "日", "Mo": "一", "Tu": "二", "We": "三", "Th": "四", "Fr": "五", "Sa": "六", "S_Sun_Initial": "日", "M_Mon_Initial": "一", "T_Tue_Initial": "二", "W_Wed_Initial": "三", "T_Thu_Initial": "四", "F_Fri_Initial": "五", "S_Sat_Initial": "六", "January": "一月", "February": "二月", "March": "三月", "April": "四月", "May": "五月", "June": "六月", "July": "七月", "August": "八月", "September": "九月", "October": "十月", "November": "十一月", "December": "十二月", "Jan_Abbr": "一月", "Feb_Abbr": "二月", "Mar_Abbr": "三月", "Apr_Abbr": "四月", "May_Abbr": "五月", "Jun_Abbr": "六月", "Jul_Abbr": "七月", "Aug_Abbr": "八月", "Sep_Abbr": "九月", "Oct_Abbr": "十月", "Nov_Abbr": "十一月", "Dec_Abbr": "十二月", "AM": "上午", "PM": "下午", "firstDayOfWeek": 0, "twoDigitYearMax": 2029, "mdy": "ymd", "M/d/yyyy": "yyyy/M/d", "dddd, MMMM dd, yyyy": "yyyy'年'M'月'd'日'", "h:mm tt": "tt hh:mm", "h:mm:ss tt": "tt hh:mm:ss", "dddd, MMMM dd, yyyy h:mm:ss tt": "yyyy'年'M'月'd'日' tt hh:mm:ss", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "M'月'd'日'", "MMMM, yyyy": "yyyy'年'M'月'", "/jan(uary)?/": "一月", "/feb(ruary)?/": "二月", "/mar(ch)?/": "三月", "/apr(il)?/": "四月", "/may/": "五月", "/jun(e)?/": "六月", "/jul(y)?/": "七月", "/aug(ust)?/": "八月", "/sep(t(ember)?)?/": "九月", "/oct(ober)?/": "十月", "/nov(ember)?/": "十一月", "/dec(ember)?/": "十二月", "/^su(n(day)?)?/": "^星期日", "/^mo(n(day)?)?/": "^星期一", "/^tu(e(s(day)?)?)?/": "^星期二", "/^we(d(nesday)?)?/": "^星期三", "/^th(u(r(s(day)?)?)?)?/": "^星期四", "/^fr(i(day)?)?/": "^星期五", "/^sa(t(urday)?)?/": "^星期六", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "zh-TW"; /** * @overview datejs * @version 1.0.0-rc3 * @author Gregory Wild-Smith * @copyright 2015 Gregory Wild-Smith * @license MIT * @homepage https://github.com/abritinthebay/datejs */(function () { var $D = Date; var lang = Date.CultureStrings ? Date.CultureStrings.lang : null; var loggedKeys = {}; // for debug purposes. var getText = { getFromKey: function (key, countryCode) { var output; if (Date.CultureStrings && Date.CultureStrings[countryCode] && Date.CultureStrings[countryCode][key]) { output = Date.CultureStrings[countryCode][key]; } else { output = getText.buildFromDefault(key); } if (key.charAt(0) === "/") { // Assume it's a regex output = getText.buildFromRegex(key, countryCode); } return output; }, getFromObjectValues: function (obj, countryCode) { var key, output = {}; for(key in obj) { if (obj.hasOwnProperty(key)) { output[key] = getText.getFromKey(obj[key], countryCode); } } return output; }, getFromObjectKeys: function (obj, countryCode) { var key, output = {}; for(key in obj) { if (obj.hasOwnProperty(key)) { output[getText.getFromKey(key, countryCode)] = obj[key]; } } return output; }, getFromArray: function (arr, countryCode) { var output = []; for (var i=0; i < arr.length; i++){ if (i in arr) { output[i] = getText.getFromKey(arr[i], countryCode); } } return output; }, buildFromDefault: function (key) { var output, length, split, last; switch(key) { case "name": output = "en-US"; break; case "englishName": output = "English (United States)"; break; case "nativeName": output = "English (United States)"; break; case "twoDigitYearMax": output = 2049; break; case "firstDayOfWeek": output = 0; break; default: output = key; split = key.split("_"); length = split.length; if (length > 1 && key.charAt(0) !== "/") { // if the key isn't a regex and it has a split. last = split[(length - 1)].toLowerCase(); if (last === "initial" || last === "abbr") { output = split[0]; } } break; } return output; }, buildFromRegex: function (key, countryCode) { var output; if (Date.CultureStrings && Date.CultureStrings[countryCode] && Date.CultureStrings[countryCode][key]) { output = new RegExp(Date.CultureStrings[countryCode][key], "i"); } else { output = new RegExp(key.replace(new RegExp("/", "g"),""), "i"); } return output; } }; var shallowMerge = function (obj1, obj2) { for (var attrname in obj2) { if (obj2.hasOwnProperty(attrname)) { obj1[attrname] = obj2[attrname]; } } }; var __ = function (key, language) { var countryCode = (language) ? language : lang; loggedKeys[key] = key; if (typeof key === "object") { if (key instanceof Array) { return getText.getFromArray(key, countryCode); } else { return getText.getFromObjectKeys(key, countryCode); } } else { return getText.getFromKey(key, countryCode); } }; var loadI18nScript = function (code) { // paatterned after jQuery's getScript. var url = Date.Config.i18n + code + ".js"; var head = document.getElementsByTagName("head")[0] || document.documentElement; var script = document.createElement("script"); script.src = url; var completed = false; var events = { done: function (){} // placeholder function }; // Attach handlers for all browsers script.onload = script.onreadystatechange = function() { if ( !completed && (!this.readyState || this.readyState === "loaded" || this.readyState === "complete") ) { events.done(); head.removeChild(script); } }; setTimeout(function() { head.insertBefore(script, head.firstChild); }, 0); // allows return to execute first return { done: function (cb) { events.done = function() { if (cb) { setTimeout(cb,0); } }; } }; }; var buildInfo = { buildFromMethodHash: function (obj) { var key; for(key in obj) { if (obj.hasOwnProperty(key)) { obj[key] = buildInfo[obj[key]](); } } return obj; }, timeZoneDST: function () { var DST = { "CHADT": "+1345", "NZDT": "+1300", "AEDT": "+1100", "ACDT": "+1030", "AZST": "+0500", "IRDT": "+0430", "EEST": "+0300", "CEST": "+0200", "BST": "+0100", "PMDT": "-0200", "ADT": "-0300", "NDT": "-0230", "EDT": "-0400", "CDT": "-0500", "MDT": "-0600", "PDT": "-0700", "AKDT": "-0800", "HADT": "-0900" }; return __(DST); }, timeZoneStandard: function () { var standard = { "LINT": "+1400", "TOT": "+1300", "CHAST": "+1245", "NZST": "+1200", "NFT": "+1130", "SBT": "+1100", "AEST": "+1000", "ACST": "+0930", "JST": "+0900", "CWST": "+0845", "CT": "+0800", "ICT": "+0700", "MMT": "+0630", "BST": "+0600", "NPT": "+0545", "IST": "+0530", "PKT": "+0500", "AFT": "+0430", "MSK": "+0400", "IRST": "+0330", "FET": "+0300", "EET": "+0200", "CET": "+0100", "GMT": "+0000", "UTC": "+0000", "CVT": "-0100", "GST": "-0200", "BRT": "-0300", "NST": "-0330", "AST": "-0400", "EST": "-0500", "CST": "-0600", "MST": "-0700", "PST": "-0800", "AKST": "-0900", "MIT": "-0930", "HST": "-1000", "SST": "-1100", "BIT": "-1200" }; return __(standard); }, timeZones: function (data) { var zone; data.timezones = []; for (zone in data.abbreviatedTimeZoneStandard) { if (data.abbreviatedTimeZoneStandard.hasOwnProperty(zone)) { data.timezones.push({ name: zone, offset: data.abbreviatedTimeZoneStandard[zone]}); } } for (zone in data.abbreviatedTimeZoneDST) { if (data.abbreviatedTimeZoneDST.hasOwnProperty(zone)) { data.timezones.push({ name: zone, offset: data.abbreviatedTimeZoneDST[zone], dst: true}); } } return data.timezones; }, days: function () { return __(["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"]); }, dayAbbr: function () { return __(["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"]); }, dayShortNames: function () { return __(["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"]); }, dayFirstLetters: function () { return __(["S_Sun_Initial", "M_Mon_Initial", "T_Tues_Initial", "W_Wed_Initial", "T_Thu_Initial", "F_Fri_Initial", "S_Sat_Initial"]); }, months: function () { return __(["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"]); }, monthAbbr: function () { return __(["Jan_Abbr", "Feb_Abbr", "Mar_Abbr", "Apr_Abbr", "May_Abbr", "Jun_Abbr", "Jul_Abbr", "Aug_Abbr", "Sep_Abbr", "Oct_Abbr", "Nov_Abbr", "Dec_Abbr"]); }, formatPatterns: function () { return getText.getFromObjectValues({ shortDate: "M/d/yyyy", longDate: "dddd, MMMM dd, yyyy", shortTime: "h:mm tt", longTime: "h:mm:ss tt", fullDateTime: "dddd, MMMM dd, yyyy h:mm:ss tt", sortableDateTime: "yyyy-MM-ddTHH:mm:ss", universalSortableDateTime: "yyyy-MM-dd HH:mm:ssZ", rfc1123: "ddd, dd MMM yyyy HH:mm:ss", monthDay: "MMMM dd", yearMonth: "MMMM, yyyy" }, Date.i18n.currentLanguage()); }, regex: function () { return getText.getFromObjectValues({ inTheMorning: "/( in the )(morn(ing)?)\\b/", thisMorning: "/(this )(morn(ing)?)\\b/", amThisMorning: "/(\b\\d(am)? )(this )(morn(ing)?)/", inTheEvening: "/( in the )(even(ing)?)\\b/", thisEvening: "/(this )(even(ing)?)\\b/", pmThisEvening: "/(\b\\d(pm)? )(this )(even(ing)?)/", jan: "/jan(uary)?/", feb: "/feb(ruary)?/", mar: "/mar(ch)?/", apr: "/apr(il)?/", may: "/may/", jun: "/jun(e)?/", jul: "/jul(y)?/", aug: "/aug(ust)?/", sep: "/sep(t(ember)?)?/", oct: "/oct(ober)?/", nov: "/nov(ember)?/", dec: "/dec(ember)?/", sun: "/^su(n(day)?)?/", mon: "/^mo(n(day)?)?/", tue: "/^tu(e(s(day)?)?)?/", wed: "/^we(d(nesday)?)?/", thu: "/^th(u(r(s(day)?)?)?)?/", fri: "/fr(i(day)?)?/", sat: "/^sa(t(urday)?)?/", future: "/^next/", past: "/^last|past|prev(ious)?/", add: "/^(\\+|aft(er)?|from|hence)/", subtract: "/^(\\-|bef(ore)?|ago)/", yesterday: "/^yes(terday)?/", today: "/^t(od(ay)?)?/", tomorrow: "/^tom(orrow)?/", now: "/^n(ow)?/", millisecond: "/^ms|milli(second)?s?/", second: "/^sec(ond)?s?/", minute: "/^mn|min(ute)?s?/", hour: "/^h(our)?s?/", week: "/^w(eek)?s?/", month: "/^m(onth)?s?/", day: "/^d(ay)?s?/", year: "/^y(ear)?s?/", shortMeridian: "/^(a|p)/", longMeridian: "/^(a\\.?m?\\.?|p\\.?m?\\.?)/", timezone: "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/", ordinalSuffix: "/^\\s*(st|nd|rd|th)/", timeContext: "/^\\s*(\\:|a(?!u|p)|p)/" }, Date.i18n.currentLanguage()); } }; var CultureInfo = function () { var info = getText.getFromObjectValues({ name: "name", englishName: "englishName", nativeName: "nativeName", amDesignator: "AM", pmDesignator: "PM", firstDayOfWeek: "firstDayOfWeek", twoDigitYearMax: "twoDigitYearMax", dateElementOrder: "mdy" }, Date.i18n.currentLanguage()); var constructedInfo = buildInfo.buildFromMethodHash({ dayNames: "days", abbreviatedDayNames: "dayAbbr", shortestDayNames: "dayShortNames", firstLetterDayNames: "dayFirstLetters", monthNames: "months", abbreviatedMonthNames: "monthAbbr", formatPatterns: "formatPatterns", regexPatterns: "regex", abbreviatedTimeZoneDST: "timeZoneDST", abbreviatedTimeZoneStandard: "timeZoneStandard" }); shallowMerge(info, constructedInfo); buildInfo.timeZones(info); return info; }; $D.i18n = { __: function (key, lang) { return __(key, lang); }, currentLanguage: function () { return lang || "en-US"; }, setLanguage: function (code, force, cb) { var async = false; if (force || code === "en-US" || (!!Date.CultureStrings && !!Date.CultureStrings[code])) { lang = code; Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings.lang = code; Date.CultureInfo = new CultureInfo(); } else { if (!(!!Date.CultureStrings && !!Date.CultureStrings[code])) { if (typeof exports !== "undefined" && this.exports !== exports) { // we're in a Node enviroment, load it using require try { require("../i18n/" + code + ".js"); lang = code; Date.CultureStrings.lang = code; Date.CultureInfo = new CultureInfo(); } catch (e) { // var str = "The language for '" + code + "' could not be loaded by Node. It likely does not exist."; throw new Error("The DateJS IETF language tag '" + code + "' could not be loaded by Node. It likely does not exist."); } } else if (Date.Config && Date.Config.i18n) { // we know the location of the files, so lets load them async = true; loadI18nScript(code).done(function(){ lang = code; Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings.lang = code; Date.CultureInfo = new CultureInfo(); $D.Parsing.Normalizer.buildReplaceData(); // because this is async if ($D.Grammar) { $D.Grammar.buildGrammarFormats(); // so we can parse those strings... } if (cb) { setTimeout(cb,0); } }); } else { Date.console.error("The DateJS IETF language tag '" + code + "' is not available and has not been loaded."); return false; } } } $D.Parsing.Normalizer.buildReplaceData(); // rebuild normalizer strings if ($D.Grammar) { $D.Grammar.buildGrammarFormats(); // so we can parse those strings... } if (!async && cb) { setTimeout(cb,0); } }, getLoggedKeys: function () { return loggedKeys; }, updateCultureInfo: function () { Date.CultureInfo = new CultureInfo(); } }; $D.i18n.updateCultureInfo(); // run automatically }()); (function () { var $D = Date, $P = $D.prototype, p = function (s, l) { if (!l) { l = 2; } return ("000" + s).slice(l * -1); }; if (typeof window !== "undefined" && typeof window.console !== "undefined" && typeof window.console.log !== "undefined") { $D.console = console; // used only to raise non-critical errors if available } else { // set mock so we don't give errors. $D.console = { log: function(){}, error: function(){} }; } $D.Config = $D.Config || {}; $D.initOverloads = function() { /** * Overload of Date.now. Allows an alternate call for Date.now where it returns the * current Date as an object rather than just milliseconds since the Unix Epoch. * * Also provides an implementation of now() for browsers (IE<9) that don't have it. * * Backwards compatible so with work with either: * Date.now() [returns ms] * or * Date.now(true) [returns Date] */ if (!$D.now) { $D._now = function now() { return new Date().getTime(); }; } else if (!$D._now) { $D._now = $D.now; } $D.now = function (returnObj) { if (returnObj) { return $D.present(); } else { return $D._now(); } }; if ( !$P.toISOString ) { $P.toISOString = function() { return this.getUTCFullYear() + "-" + p(this.getUTCMonth() + 1) + "-" + p(this.getUTCDate()) + "T" + p(this.getUTCHours()) + ":" + p(this.getUTCMinutes()) + ":" + p(this.getUTCSeconds()) + "." + String( (this.getUTCMilliseconds()/1000).toFixed(3)).slice(2, 5) + "Z"; }; } // private if ( $P._toString === undefined ){ $P._toString = $P.toString; } }; $D.initOverloads(); /** * Gets a date that is set to the current date. The time is set to the start of the day (00:00 or 12:00 AM). * @return {Date} The current date. */ $D.today = function () { return new Date().clearTime(); }; /** * Gets a date that is set to the current date and time (same as new Date, but chainable) * @return {Date} The current date. */ $D.present = function () { return new Date(); }; /** * Compares the first date to the second date and returns an number indication of their relative values. * @param {Date} First Date object to compare [Required]. * @param {Date} Second Date object to compare to [Required]. * @return {Number} -1 = date1 is lessthan date2. 0 = values are equal. 1 = date1 is greaterthan date2. */ $D.compare = function (date1, date2) { if (isNaN(date1) || isNaN(date2)) { throw new Error(date1 + " - " + date2); } else if (date1 instanceof Date && date2 instanceof Date) { return (date1 < date2) ? -1 : (date1 > date2) ? 1 : 0; } else { throw new TypeError(date1 + " - " + date2); } }; /** * Compares the first Date object to the second Date object and returns true if they are equal. * @param {Date} First Date object to compare [Required] * @param {Date} Second Date object to compare to [Required] * @return {Boolean} true if dates are equal. false if they are not equal. */ $D.equals = function (date1, date2) { return (date1.compareTo(date2) === 0); }; /** * Gets the language appropriate day name when given the day number(0-6) * eg - 0 == Sunday * @return {String} The day name */ $D.getDayName = function (n) { return Date.CultureInfo.dayNames[n]; }; /** * Gets the day number (0-6) if given a CultureInfo specific string which is a valid dayName, abbreviatedDayName or shortestDayName (two char). * @param {String} The name of the day (eg. "Monday, "Mon", "tuesday", "tue", "We", "we"). * @return {Number} The day number */ $D.getDayNumberFromName = function (name) { var n = Date.CultureInfo.dayNames, m = Date.CultureInfo.abbreviatedDayNames, o = Date.CultureInfo.shortestDayNames, s = name.toLowerCase(); for (var i = 0; i < n.length; i++) { if (n[i].toLowerCase() === s || m[i].toLowerCase() === s || o[i].toLowerCase() === s) { return i; } } return -1; }; /** * Gets the month number (0-11) if given a Culture Info specific string which is a valid monthName or abbreviatedMonthName. * @param {String} The name of the month (eg. "February, "Feb", "october", "oct"). * @return {Number} The day number */ $D.getMonthNumberFromName = function (name) { var n = Date.CultureInfo.monthNames, m = Date.CultureInfo.abbreviatedMonthNames, s = name.toLowerCase(); for (var i = 0; i < n.length; i++) { if (n[i].toLowerCase() === s || m[i].toLowerCase() === s) { return i; } } return -1; }; /** * Gets the language appropriate month name when given the month number(0-11) * eg - 0 == January * @return {String} The month name */ $D.getMonthName = function (n) { return Date.CultureInfo.monthNames[n]; }; /** * Determines if the current date instance is within a LeapYear. * @param {Number} The year. * @return {Boolean} true if date is within a LeapYear, otherwise false. */ $D.isLeapYear = function (year) { return ((year % 4 === 0 && year % 100 !== 0) || year % 400 === 0); }; /** * Gets the number of days in the month, given a year and month value. Automatically corrects for LeapYear. * @param {Number} The year. * @param {Number} The month (0-11). * @return {Number} The number of days in the month. */ $D.getDaysInMonth = function (year, month) { if (!month && $D.validateMonth(year)) { month = year; year = Date.today().getFullYear(); } return [31, ($D.isLeapYear(year) ? 29 : 28), 31, 30, 31, 30, 31, 31, 30, 31, 30, 31][month]; }; $P.getDaysInMonth = function () { return $D.getDaysInMonth(this.getFullYear(), this.getMonth()); }; $D.getTimezoneAbbreviation = function (offset, dst) { var p, n = (dst || false) ? Date.CultureInfo.abbreviatedTimeZoneDST : Date.CultureInfo.abbreviatedTimeZoneStandard; for (p in n) { if (n.hasOwnProperty(p)) { if (n[p] === offset) { return p; } } } return null; }; $D.getTimezoneOffset = function (name, dst) { var i, a =[], z = Date.CultureInfo.timezones; if (!name) { name = (new Date()).getTimezone();} for (i = 0; i < z.length; i++) { if (z[i].name === name.toUpperCase()) { a.push(i); } } if (!z[a[0]]) { return null; } if (a.length === 1 || !dst) { return z[a[0]].offset; } else { for (i=0; i < a.length; i++) { if (z[a[i]].dst) { return z[a[i]].offset; } } } }; $D.getQuarter = function (d) { d = d || new Date(); // If no date supplied, use today var q = [1,2,3,4]; return q[Math.floor(d.getMonth() / 3)]; // ~~~ is a bitwise op. Faster than Math.floor }; $D.getDaysLeftInQuarter = function (d) { d = d || new Date(); var qEnd = new Date(d); qEnd.setMonth(qEnd.getMonth() + 3 - qEnd.getMonth() % 3, 0); return Math.floor((qEnd - d) / 8.64e7); }; // private var validate = function (n, min, max, name) { name = name ? name : "Object"; if (typeof n === "undefined") { return false; } else if (typeof n !== "number") { throw new TypeError(n + " is not a Number."); } else if (n < min || n > max) { // As failing validation is *not* an exceptional circumstance // lets not throw a RangeError Exception here. // It's semantically correct but it's not sensible. return false; } return true; }; /** * Validates the number is within an acceptable range for milliseconds [0-999]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateMillisecond = function (value) { return validate(value, 0, 999, "millisecond"); }; /** * Validates the number is within an acceptable range for seconds [0-59]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateSecond = function (value) { return validate(value, 0, 59, "second"); }; /** * Validates the number is within an acceptable range for minutes [0-59]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateMinute = function (value) { return validate(value, 0, 59, "minute"); }; /** * Validates the number is within an acceptable range for hours [0-23]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateHour = function (value) { return validate(value, 0, 23, "hour"); }; /** * Validates the number is within an acceptable range for the days in a month [0-MaxDaysInMonth]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateDay = function (value, year, month) { if (year === undefined || year === null || month === undefined || month === null) { return false;} return validate(value, 1, $D.getDaysInMonth(year, month), "day"); }; /** * Validates the number is within an acceptable range for months [0-11]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateWeek = function (value) { return validate(value, 0, 53, "week"); }; /** * Validates the number is within an acceptable range for months [0-11]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateMonth = function (value) { return validate(value, 0, 11, "month"); }; /** * Validates the number is within an acceptable range for years. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateYear = function (value) { /** * Per ECMAScript spec the range of times supported by Date objects is * exactly -100,000,000 days to +100,000,000 days measured relative to * midnight at the beginning of 01 January, 1970 UTC. * This gives a range of 8,640,000,000,000,000 milliseconds to either * side of 01 January, 1970 UTC. * * Earliest possible date: Tue, 20 Apr 271,822 B.C. 00:00:00 UTC * Latest possible date: Sat, 13 Sep 275,760 00:00:00 UTC */ return validate(value, -271822, 275760, "year"); }; $D.validateTimezone = function(value) { var timezones = {"ACDT":1,"ACST":1,"ACT":1,"ADT":1,"AEDT":1,"AEST":1,"AFT":1,"AKDT":1,"AKST":1,"AMST":1,"AMT":1,"ART":1,"AST":1,"AWDT":1,"AWST":1,"AZOST":1,"AZT":1,"BDT":1,"BIOT":1,"BIT":1,"BOT":1,"BRT":1,"BST":1,"BTT":1,"CAT":1,"CCT":1,"CDT":1,"CEDT":1,"CEST":1,"CET":1,"CHADT":1,"CHAST":1,"CHOT":1,"ChST":1,"CHUT":1,"CIST":1,"CIT":1,"CKT":1,"CLST":1,"CLT":1,"COST":1,"COT":1,"CST":1,"CT":1,"CVT":1,"CWST":1,"CXT":1,"DAVT":1,"DDUT":1,"DFT":1,"EASST":1,"EAST":1,"EAT":1,"ECT":1,"EDT":1,"EEDT":1,"EEST":1,"EET":1,"EGST":1,"EGT":1,"EIT":1,"EST":1,"FET":1,"FJT":1,"FKST":1,"FKT":1,"FNT":1,"GALT":1,"GAMT":1,"GET":1,"GFT":1,"GILT":1,"GIT":1,"GMT":1,"GST":1,"GYT":1,"HADT":1,"HAEC":1,"HAST":1,"HKT":1,"HMT":1,"HOVT":1,"HST":1,"ICT":1,"IDT":1,"IOT":1,"IRDT":1,"IRKT":1,"IRST":1,"IST":1,"JST":1,"KGT":1,"KOST":1,"KRAT":1,"KST":1,"LHST":1,"LINT":1,"MAGT":1,"MART":1,"MAWT":1,"MDT":1,"MET":1,"MEST":1,"MHT":1,"MIST":1,"MIT":1,"MMT":1,"MSK":1,"MST":1,"MUT":1,"MVT":1,"MYT":1,"NCT":1,"NDT":1,"NFT":1,"NPT":1,"NST":1,"NT":1,"NUT":1,"NZDT":1,"NZST":1,"OMST":1,"ORAT":1,"PDT":1,"PET":1,"PETT":1,"PGT":1,"PHOT":1,"PHT":1,"PKT":1,"PMDT":1,"PMST":1,"PONT":1,"PST":1,"PYST":1,"PYT":1,"RET":1,"ROTT":1,"SAKT":1,"SAMT":1,"SAST":1,"SBT":1,"SCT":1,"SGT":1,"SLST":1,"SRT":1,"SST":1,"SYOT":1,"TAHT":1,"THA":1,"TFT":1,"TJT":1,"TKT":1,"TLT":1,"TMT":1,"TOT":1,"TVT":1,"UCT":1,"ULAT":1,"UTC":1,"UYST":1,"UYT":1,"UZT":1,"VET":1,"VLAT":1,"VOLT":1,"VOST":1,"VUT":1,"WAKT":1,"WAST":1,"WAT":1,"WEDT":1,"WEST":1,"WET":1,"WST":1,"YAKT":1,"YEKT":1,"Z":1}; return (timezones[value] === 1); }; $D.validateTimezoneOffset= function(value) { // timezones go from +14hrs to -12hrs, the +X hours are negative offsets. return (value > -841 && value < 721); }; }()); (function () { var $D = Date, $P = $D.prototype, p = function (s, l) { if (!l) { l = 2; } return ("000" + s).slice(l * -1); }; var validateConfigObject = function (obj) { var result = {}, self = this, prop, testFunc; testFunc = function (prop, func, value) { if (prop === "day") { var month = (obj.month !== undefined) ? obj.month : self.getMonth(); var year = (obj.year !== undefined) ? obj.year : self.getFullYear(); return $D[func](value, year, month); } else { return $D[func](value); } }; for (prop in obj) { if (Object.prototype.hasOwnProperty.call(obj, prop)) { var func = "validate" + prop.charAt(0).toUpperCase() + prop.slice(1); if ($D[func] && obj[prop] !== null && testFunc(prop, func, obj[prop])) { result[prop] = obj[prop]; } } } return result; }; /** * Resets the time of this Date object to 12:00 AM (00:00), which is the start of the day. * @param {Boolean} .clone() this date instance before clearing Time * @return {Date} this */ $P.clearTime = function () { this.setHours(0); this.setMinutes(0); this.setSeconds(0); this.setMilliseconds(0); return this; }; /** * Resets the time of this Date object to the current time ('now'). * @return {Date} this */ $P.setTimeToNow = function () { var n = new Date(); this.setHours(n.getHours()); this.setMinutes(n.getMinutes()); this.setSeconds(n.getSeconds()); this.setMilliseconds(n.getMilliseconds()); return this; }; /** * Returns a new Date object that is an exact date and time copy of the original instance. * @return {Date} A new Date instance */ $P.clone = function () { return new Date(this.getTime()); }; /** * Compares this instance to a Date object and returns an number indication of their relative values. * @param {Date} Date object to compare [Required] * @return {Number} -1 = this is lessthan date. 0 = values are equal. 1 = this is greaterthan date. */ $P.compareTo = function (date) { return Date.compare(this, date); }; /** * Compares this instance to another Date object and returns true if they are equal. * @param {Date} Date object to compare. If no date to compare, new Date() [now] is used. * @return {Boolean} true if dates are equal. false if they are not equal. */ $P.equals = function (date) { return Date.equals(this, (date !== undefined ? date : new Date())); }; /** * Determines if this instance is between a range of two dates or equal to either the start or end dates. * @param {Date} Start of range [Required] * @param {Date} End of range [Required] * @return {Boolean} true is this is between or equal to the start and end dates, else false */ $P.between = function (start, end) { return this.getTime() >= start.getTime() && this.getTime() <= end.getTime(); }; /** * Determines if this date occurs after the date to compare to. * @param {Date} Date object to compare. If no date to compare, new Date() ("now") is used. * @return {Boolean} true if this date instance is greater than the date to compare to (or "now"), otherwise false. */ $P.isAfter = function (date) { return this.compareTo(date || new Date()) === 1; }; /** * Determines if this date occurs before the date to compare to. * @param {Date} Date object to compare. If no date to compare, new Date() ("now") is used. * @return {Boolean} true if this date instance is less than the date to compare to (or "now"). */ $P.isBefore = function (date) { return (this.compareTo(date || new Date()) === -1); }; /** * Determines if the current Date instance occurs today. * @return {Boolean} true if this date instance is 'today', otherwise false. */ /** * Determines if the current Date instance occurs on the same Date as the supplied 'date'. * If no 'date' to compare to is provided, the current Date instance is compared to 'today'. * @param {date} Date object to compare. If no date to compare, the current Date ("now") is used. * @return {Boolean} true if this Date instance occurs on the same Day as the supplied 'date'. */ $P.isToday = $P.isSameDay = function (date) { return this.clone().clearTime().equals((date || new Date()).clone().clearTime()); }; /** * Adds the specified number of milliseconds to this instance. * @param {Number} The number of milliseconds to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addMilliseconds = function (value) { if (!value) { return this; } this.setTime(this.getTime() + value * 1); return this; }; /** * Adds the specified number of seconds to this instance. * @param {Number} The number of seconds to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addSeconds = function (value) { if (!value) { return this; } return this.addMilliseconds(value * 1000); }; /** * Adds the specified number of seconds to this instance. * @param {Number} The number of seconds to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addMinutes = function (value) { if (!value) { return this; } return this.addMilliseconds(value * 60000); // 60*1000 }; /** * Adds the specified number of hours to this instance. * @param {Number} The number of hours to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addHours = function (value) { if (!value) { return this; } return this.addMilliseconds(value * 3600000); // 60*60*1000 }; /** * Adds the specified number of days to this instance. * @param {Number} The number of days to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addDays = function (value) { if (!value) { return this; } this.setDate(this.getDate() + value * 1); return this; }; /** * Adds the specified number of weekdays (ie - not sat or sun) to this instance. * @param {Number} The number of days to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addWeekdays = function (value) { if (!value) { return this; } var day = this.getDay(); var weeks = (Math.ceil(Math.abs(value)/7)); if (day === 0 || day === 6) { if (value > 0) { this.next().monday(); this.addDays(-1); day = this.getDay(); } } if (value < 0) { while (value < 0) { this.addDays(-1); day = this.getDay(); if (day !== 0 && day !== 6) { value++; } } return this; } else if (value > 5 || (6-day) <= value) { value = value + (weeks * 2); } return this.addDays(value); }; /** * Adds the specified number of weeks to this instance. * @param {Number} The number of weeks to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addWeeks = function (value) { if (!value) { return this; } return this.addDays(value * 7); }; /** * Adds the specified number of months to this instance. * @param {Number} The number of months to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addMonths = function (value) { if (!value) { return this; } var n = this.getDate(); this.setDate(1); this.setMonth(this.getMonth() + value * 1); this.setDate(Math.min(n, $D.getDaysInMonth(this.getFullYear(), this.getMonth()))); return this; }; $P.addQuarters = function (value) { if (!value) { return this; } // note this will take you to the same point in the quarter as you are now. // i.e. - if you are 15 days into the quarter you'll be 15 days into the resulting one. // bonus: this allows adding fractional quarters return this.addMonths(value * 3); }; /** * Adds the specified number of years to this instance. * @param {Number} The number of years to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addYears = function (value) { if (!value) { return this; } return this.addMonths(value * 12); }; /** * Adds (or subtracts) to the value of the years, months, weeks, days, hours, minutes, seconds, milliseconds of the date instance using given configuration object. Positive and Negative values allowed. * Example

	Date.today().add( { days: 1, months: 1 } )

	new Date().add( { years: -1 } )
	
* @param {Object} Configuration object containing attributes (months, days, etc.) * @return {Date} this */ $P.add = function (config) { if (typeof config === "number") { this._orient = config; return this; } var x = config; if (x.day) { // If we should be a different date than today (eg: for 'tomorrow -1d', etc). // Should only effect parsing, not direct usage (eg, Finish and FinishExact) if ((x.day - this.getDate()) !== 0) { this.setDate(x.day); } } if (x.milliseconds) { this.addMilliseconds(x.milliseconds); } if (x.seconds) { this.addSeconds(x.seconds); } if (x.minutes) { this.addMinutes(x.minutes); } if (x.hours) { this.addHours(x.hours); } if (x.weeks) { this.addWeeks(x.weeks); } if (x.months) { this.addMonths(x.months); } if (x.years) { this.addYears(x.years); } if (x.days) { this.addDays(x.days); } return this; }; /** * Get the week number. Week one (1) is the week which contains the first Thursday of the year. Monday is considered the first day of the week. * The .getWeek() function does NOT convert the date to UTC. The local datetime is used. * Please use .getISOWeek() to get the week of the UTC converted date. * @return {Number} 1 to 53 */ $P.getWeek = function (utc) { // Create a copy of this date object var self, target = new Date(this.valueOf()); if (utc) { target.addMinutes(target.getTimezoneOffset()); self = target.clone(); } else { self = this; } // ISO week date weeks start on monday // so correct the day number var dayNr = (self.getDay() + 6) % 7; // ISO 8601 states that week 1 is the week // with the first thursday of that year. // Set the target date to the thursday in the target week target.setDate(target.getDate() - dayNr + 3); // Store the millisecond value of the target date var firstThursday = target.valueOf(); // Set the target to the first thursday of the year // First set the target to january first target.setMonth(0, 1); // Not a thursday? Correct the date to the next thursday if (target.getDay() !== 4) { target.setMonth(0, 1 + ((4 - target.getDay()) + 7) % 7); } // The weeknumber is the number of weeks between the // first thursday of the year and the thursday in the target week return 1 + Math.ceil((firstThursday - target) / 604800000); // 604800000 = 7 * 24 * 3600 * 1000 }; /** * Get the ISO 8601 week number. Week one ("01") is the week which contains the first Thursday of the year. Monday is considered the first day of the week. * The .getISOWeek() function does convert the date to it's UTC value. Please use .getWeek() to get the week of the local date. * @return {String} "01" to "53" */ $P.getISOWeek = function () { return p(this.getWeek(true)); }; /** * Moves the date to Monday of the week set. Week one (1) is the week which contains the first Thursday of the year. * @param {Number} A Number (1 to 53) that represents the week of the year. * @return {Date} this */ $P.setWeek = function (n) { if ((n - this.getWeek()) === 0) { if (this.getDay() !== 1) { return this.moveToDayOfWeek(1, (this.getDay() > 1 ? -1 : 1)); } else { return this; } } else { return this.moveToDayOfWeek(1, (this.getDay() > 1 ? -1 : 1)).addWeeks(n - this.getWeek()); } }; $P.setQuarter = function (qtr) { var month = Math.abs(((qtr-1) * 3) + 1); return this.setMonth(month, 1); }; $P.getQuarter = function () { return Date.getQuarter(this); }; $P.getDaysLeftInQuarter = function () { return Date.getDaysLeftInQuarter(this); }; /** * Moves the date to the next n'th occurrence of the dayOfWeek starting from the beginning of the month. The number (-1) is a magic number and will return the last occurrence of the dayOfWeek in the month. * @param {Number} The dayOfWeek to move to * @param {Number} The n'th occurrence to move to. Use (-1) to return the last occurrence in the month * @return {Date} this */ $P.moveToNthOccurrence = function (dayOfWeek, occurrence) { if (dayOfWeek === "Weekday") { if (occurrence > 0) { this.moveToFirstDayOfMonth(); if (this.is().weekday()) { occurrence -= 1; } } else if (occurrence < 0) { this.moveToLastDayOfMonth(); if (this.is().weekday()) { occurrence += 1; } } else { return this; } return this.addWeekdays(occurrence); } var shift = 0; if (occurrence > 0) { shift = occurrence - 1; } else if (occurrence === -1) { this.moveToLastDayOfMonth(); if (this.getDay() !== dayOfWeek) { this.moveToDayOfWeek(dayOfWeek, -1); } return this; } return this.moveToFirstDayOfMonth().addDays(-1).moveToDayOfWeek(dayOfWeek, +1).addWeeks(shift); }; var moveToN = function (getFunc, addFunc, nVal) { return function (value, orient) { var diff = (value - this[getFunc]() + nVal * (orient || +1)) % nVal; return this[addFunc]((diff === 0) ? diff += nVal * (orient || +1) : diff); }; }; /** * Move to the next or last dayOfWeek based on the orient value. * @param {Number} The dayOfWeek to move to * @param {Number} Forward (+1) or Back (-1). Defaults to +1. [Optional] * @return {Date} this */ $P.moveToDayOfWeek = moveToN("getDay", "addDays", 7); /** * Move to the next or last month based on the orient value. * @param {Number} The month to move to. 0 = January, 11 = December * @param {Number} Forward (+1) or Back (-1). Defaults to +1. [Optional] * @return {Date} this */ $P.moveToMonth = moveToN("getMonth", "addMonths", 12); /** * Get the Ordinate of the current day ("th", "st", "rd"). * @return {String} */ $P.getOrdinate = function () { var num = this.getDate(); return ord(num); }; /** * Get the Ordinal day (numeric day number) of the year, adjusted for leap year. * @return {Number} 1 through 365 (366 in leap years) */ $P.getOrdinalNumber = function () { return Math.ceil((this.clone().clearTime() - new Date(this.getFullYear(), 0, 1)) / 86400000) + 1; }; /** * Get the time zone abbreviation of the current date. * @return {String} The abbreviated time zone name (e.g. "EST") */ $P.getTimezone = function () { return $D.getTimezoneAbbreviation(this.getUTCOffset(), this.isDaylightSavingTime()); }; $P.setTimezoneOffset = function (offset) { var here = this.getTimezoneOffset(), there = Number(offset) * -6 / 10; return (there || there === 0) ? this.addMinutes(there - here) : this; }; $P.setTimezone = function (offset) { return this.setTimezoneOffset($D.getTimezoneOffset(offset)); }; /** * Indicates whether Daylight Saving Time is observed in the current time zone. * @return {Boolean} true|false */ $P.hasDaylightSavingTime = function () { return (Date.today().set({month: 0, day: 1}).getTimezoneOffset() !== Date.today().set({month: 6, day: 1}).getTimezoneOffset()); }; /** * Indicates whether this Date instance is within the Daylight Saving Time range for the current time zone. * @return {Boolean} true|false */ $P.isDaylightSavingTime = function () { return Date.today().set({month: 0, day: 1}).getTimezoneOffset() !== this.getTimezoneOffset(); }; /** * Get the offset from UTC of the current date. * @return {String} The 4-character offset string prefixed with + or - (e.g. "-0500") */ $P.getUTCOffset = function (offset) { var n = (offset || this.getTimezoneOffset()) * -10 / 6, r; if (n < 0) { r = (n - 10000).toString(); return r.charAt(0) + r.substr(2); } else { r = (n + 10000).toString(); return "+" + r.substr(1); } }; /** * Returns the number of milliseconds between this date and date. * @param {Date} Defaults to now * @return {Number} The diff in milliseconds */ $P.getElapsed = function (date) { return (date || new Date()) - this; }; /** * Set the value of year, month, day, hour, minute, second, millisecond of date instance using given configuration object. * Example

	Date.today().set( { day: 20, month: 1 } )

	new Date().set( { millisecond: 0 } )
	
* * @param {Object} Configuration object containing attributes (month, day, etc.) * @return {Date} this */ $P.set = function (config) { config = validateConfigObject.call(this, config); var key; for (key in config) { if (Object.prototype.hasOwnProperty.call(config, key)) { var name = key.charAt(0).toUpperCase() + key.slice(1); var addFunc, getFunc; if (key !== "week" && key !== "month" && key !== "timezone" && key !== "timezoneOffset") { name += "s"; } addFunc = "add" + name; getFunc = "get" + name; if (key === "month") { addFunc = addFunc + "s"; } else if (key === "year"){ getFunc = "getFullYear"; } if (key !== "day" && key !== "timezone" && key !== "timezoneOffset" && key !== "week" && key !== "hour") { this[addFunc](config[key] - this[getFunc]()); } else if ( key === "timezone"|| key === "timezoneOffset" || key === "week" || key === "hour") { this["set"+name](config[key]); } } } // day has to go last because you can't validate the day without first knowing the month if (config.day) { this.addDays(config.day - this.getDate()); } return this; }; /** * Moves the date to the first day of the month. * @return {Date} this */ $P.moveToFirstDayOfMonth = function () { return this.set({ day: 1 }); }; /** * Moves the date to the last day of the month. * @return {Date} this */ $P.moveToLastDayOfMonth = function () { return this.set({ day: $D.getDaysInMonth(this.getFullYear(), this.getMonth())}); }; /** * Converts the value of the current Date object to its equivalent string representation. * Format Specifiers * CUSTOM DATE AND TIME FORMAT STRINGS * Format Description Example * ------ --------------------------------------------------------------------------- ----------------------- * s The seconds of the minute between 0-59. "0" to "59" * ss The seconds of the minute with leading zero if required. "00" to "59" * * m The minute of the hour between 0-59. "0" or "59" * mm The minute of the hour with leading zero if required. "00" or "59" * * h The hour of the day between 1-12. "1" to "12" * hh The hour of the day with leading zero if required. "01" to "12" * * H The hour of the day between 0-23. "0" to "23" * HH The hour of the day with leading zero if required. "00" to "23" * * d The day of the month between 1 and 31. "1" to "31" * dd The day of the month with leading zero if required. "01" to "31" * ddd Abbreviated day name. Date.CultureInfo.abbreviatedDayNames. "Mon" to "Sun" * dddd The full day name. Date.CultureInfo.dayNames. "Monday" to "Sunday" * * M The month of the year between 1-12. "1" to "12" * MM The month of the year with leading zero if required. "01" to "12" * MMM Abbreviated month name. Date.CultureInfo.abbreviatedMonthNames. "Jan" to "Dec" * MMMM The full month name. Date.CultureInfo.monthNames. "January" to "December" * * yy The year as a two-digit number. "99" or "08" * yyyy The full four digit year. "1999" or "2008" * * t Displays the first character of the A.M./P.M. designator. "A" or "P" * Date.CultureInfo.amDesignator or Date.CultureInfo.pmDesignator * tt Displays the A.M./P.M. designator. "AM" or "PM" * Date.CultureInfo.amDesignator or Date.CultureInfo.pmDesignator * * S The ordinal suffix ("st, "nd", "rd" or "th") of the current day. "st, "nd", "rd" or "th" * * STANDARD DATE AND TIME FORMAT STRINGS * Format Description Example *------ --------------------------------------------------------------------------- ----------------------- * d The CultureInfo shortDate Format Pattern "M/d/yyyy" * D The CultureInfo longDate Format Pattern "dddd, MMMM dd, yyyy" * F The CultureInfo fullDateTime Format Pattern "dddd, MMMM dd, yyyy h:mm:ss tt" * m The CultureInfo monthDay Format Pattern "MMMM dd" * r The CultureInfo rfc1123 Format Pattern "ddd, dd MMM yyyy HH:mm:ss GMT" * s The CultureInfo sortableDateTime Format Pattern "yyyy-MM-ddTHH:mm:ss" * t The CultureInfo shortTime Format Pattern "h:mm tt" * T The CultureInfo longTime Format Pattern "h:mm:ss tt" * u The CultureInfo universalSortableDateTime Format Pattern "yyyy-MM-dd HH:mm:ssZ" * y The CultureInfo yearMonth Format Pattern "MMMM, yyyy" * * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @return {String} A string representation of the current Date object. */ var ord = function (n) { switch (n * 1) { case 1: case 21: case 31: return "st"; case 2: case 22: return "nd"; case 3: case 23: return "rd"; default: return "th"; } }; var parseStandardFormats = function (format) { var y, c = Date.CultureInfo.formatPatterns; switch (format) { case "d": return this.toString(c.shortDate); case "D": return this.toString(c.longDate); case "F": return this.toString(c.fullDateTime); case "m": return this.toString(c.monthDay); case "r": case "R": y = this.clone().addMinutes(this.getTimezoneOffset()); return y.toString(c.rfc1123) + " GMT"; case "s": return this.toString(c.sortableDateTime); case "t": return this.toString(c.shortTime); case "T": return this.toString(c.longTime); case "u": y = this.clone().addMinutes(this.getTimezoneOffset()); return y.toString(c.universalSortableDateTime); case "y": return this.toString(c.yearMonth); default: return false; } }; var parseFormatStringsClosure = function (context) { return function (m) { if (m.charAt(0) === "\\") { return m.replace("\\", ""); } switch (m) { case "hh": return p(context.getHours() < 13 ? (context.getHours() === 0 ? 12 : context.getHours()) : (context.getHours() - 12)); case "h": return context.getHours() < 13 ? (context.getHours() === 0 ? 12 : context.getHours()) : (context.getHours() - 12); case "HH": return p(context.getHours()); case "H": return context.getHours(); case "mm": return p(context.getMinutes()); case "m": return context.getMinutes(); case "ss": return p(context.getSeconds()); case "s": return context.getSeconds(); case "yyyy": return p(context.getFullYear(), 4); case "yy": return p(context.getFullYear()); case "y": return context.getFullYear(); case "E": case "dddd": return Date.CultureInfo.dayNames[context.getDay()]; case "ddd": return Date.CultureInfo.abbreviatedDayNames[context.getDay()]; case "dd": return p(context.getDate()); case "d": return context.getDate(); case "MMMM": return Date.CultureInfo.monthNames[context.getMonth()]; case "MMM": return Date.CultureInfo.abbreviatedMonthNames[context.getMonth()]; case "MM": return p((context.getMonth() + 1)); case "M": return context.getMonth() + 1; case "t": return context.getHours() < 12 ? Date.CultureInfo.amDesignator.substring(0, 1) : Date.CultureInfo.pmDesignator.substring(0, 1); case "tt": return context.getHours() < 12 ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator; case "S": return ord(context.getDate()); case "W": return context.getWeek(); case "WW": return context.getISOWeek(); case "Q": return "Q" + context.getQuarter(); case "q": return String(context.getQuarter()); case "z": return context.getTimezone(); case "Z": case "X": return Date.getTimezoneOffset(context.getTimezone()); case "ZZ": // Timezone offset in seconds return context.getTimezoneOffset() * -60; case "u": return context.getDay(); case "L": return ($D.isLeapYear(context.getFullYear())) ? 1 : 0; case "B": // Swatch Internet Time (.beats) return "@"+((context.getUTCSeconds() + (context.getUTCMinutes()*60) + ((context.getUTCHours()+1)*3600))/86.4); default: return m; } }; }; $P.toString = function (format, ignoreStandards) { // Standard Date and Time Format Strings. Formats pulled from CultureInfo file and // may vary by culture. if (!ignoreStandards && format && format.length === 1) { output = parseStandardFormats.call(this, format); if (output) { return output; } } var parseFormatStrings = parseFormatStringsClosure(this); return format ? format.replace(/((\\)?(dd?d?d?|MM?M?M?|yy?y?y?|hh?|HH?|mm?|ss?|tt?|S|q|Q|WW?W?W?)(?![^\[]*\]))/g, parseFormatStrings).replace(/\[|\]/g, "") : this._toString(); }; }()); /************************************************************* * SugarPak - Domain Specific Language - Syntactical Sugar * *************************************************************/ (function () { var $D = Date, $P = $D.prototype, $N = Number.prototype; // private $P._orient = +1; // private $P._nth = null; // private $P._is = false; // private $P._same = false; // private $P._isSecond = false; // private $N._dateElement = "days"; /** * Moves the date to the next instance of a date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.today().next().friday();
	Date.today().next().fri();
	Date.today().next().march();
	Date.today().next().mar();
	Date.today().next().week();
	
* * @return {Date} date */ $P.next = function () { this._move = true; this._orient = +1; return this; }; /** * Creates a new Date (Date.today()) and moves the date to the next instance of the date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.next().friday();
	Date.next().fri();
	Date.next().march();
	Date.next().mar();
	Date.next().week();
	
* * @return {Date} date */ $D.next = function () { return $D.today().next(); }; /** * Moves the date to the previous instance of a date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.today().last().friday();
	Date.today().last().fri();
	Date.today().last().march();
	Date.today().last().mar();
	Date.today().last().week();
	
* * @return {Date} date */ $P.last = $P.prev = $P.previous = function () { this._move = true; this._orient = -1; return this; }; /** * Creates a new Date (Date.today()) and moves the date to the previous instance of the date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.last().friday();
	Date.last().fri();
	Date.previous().march();
	Date.prev().mar();
	Date.last().week();
	
* * @return {Date} date */ $D.last = $D.prev = $D.previous = function () { return $D.today().last(); }; /** * Performs a equality check when followed by either a month name, day name or .weekday() function. * Example

	Date.today().is().friday(); // true|false
	Date.today().is().fri();
	Date.today().is().march();
	Date.today().is().mar();
	
* * @return {Boolean} true|false */ $P.is = function () { this._is = true; return this; }; /** * Determines if two date objects occur on/in exactly the same instance of the subsequent date part function. * The function .same() must be followed by a date part function (example: .day(), .month(), .year(), etc). * * An optional Date can be passed in the date part function. If now date is passed as a parameter, 'Now' is used. * * The following example demonstrates how to determine if two dates fall on the exact same day. * * Example

	var d1 = Date.today(); // today at 00:00
	var d2 = new Date();   // exactly now.

	// Do they occur on the same day?
	d1.same().day(d2); // true
	
	// Do they occur on the same hour?
	d1.same().hour(d2); // false, unless d2 hour is '00' (midnight).
	
	// What if it's the same day, but one year apart?
	var nextYear = Date.today().add(1).year();

	d1.same().day(nextYear); // false, because the dates must occur on the exact same day. 
	
* * Scenario: Determine if a given date occurs during some week period 2 months from now. * * Example

	var future = Date.today().add(2).months();
	return someDate.same().week(future); // true|false;
	
* * @return {Boolean} true|false */ $P.same = function () { this._same = true; this._isSecond = false; return this; }; /** * Determines if the current date/time occurs during Today. Must be preceded by the .is() function. * Example

	someDate.is().today();    // true|false
	new Date().is().today();  // true
	Date.today().is().today();// true
	Date.today().add(-1).day().is().today(); // false
	
* * @return {Boolean} true|false */ $P.today = function () { return this.same().day(); }; /** * Determines if the current date is a weekday. This function must be preceded by the .is() function. * Example

	Date.today().is().weekday(); // true|false
	
* * @return {Boolean} true|false */ $P.weekday = function () { if (this._nth) { return df("Weekday").call(this); } if (this._move) { return this.addWeekdays(this._orient); } if (this._is) { this._is = false; return (!this.is().sat() && !this.is().sun()); } return false; }; /** * Determines if the current date is on the weekend. This function must be preceded by the .is() function. * Example

	Date.today().is().weekend(); // true|false
	
* * @return {Boolean} true|false */ $P.weekend = function () { if (this._is) { this._is = false; return (this.is().sat() || this.is().sun()); } return false; }; /** * Sets the Time of the current Date instance. A string "6:15 pm" or config object {hour:18, minute:15} are accepted. * Example

	// Set time to 6:15pm with a String
	Date.today().at("6:15pm");

	// Set time to 6:15pm with a config object
	Date.today().at({hour:18, minute:15});
	
* * @return {Date} date */ $P.at = function (time) { return (typeof time === "string") ? $D.parse(this.toString("d") + " " + time) : this.set(time); }; /** * Creates a new Date() and adds this (Number) to the date based on the preceding date element function (eg. second|minute|hour|day|month|year). * Example

	// Undeclared Numbers must be wrapped with parentheses. Requirment of JavaScript.
	(3).days().fromNow();
	(6).months().fromNow();

	// Declared Number variables do not require parentheses. 
	var n = 6;
	n.months().fromNow();
	
* * @return {Date} A new Date instance */ $N.fromNow = $N.after = function (date) { var c = {}; c[this._dateElement] = this; return ((!date) ? new Date() : date.clone()).add(c); }; /** * Creates a new Date() and subtract this (Number) from the date based on the preceding date element function (eg. second|minute|hour|day|month|year). * Example

	// Undeclared Numbers must be wrapped with parentheses. Requirment of JavaScript.
	(3).days().ago();
	(6).months().ago();

	// Declared Number variables do not require parentheses. 
	var n = 6;
	n.months().ago();
	
* * @return {Date} A new Date instance */ $N.ago = $N.before = function (date) { var c = {}, s = (this._dateElement[this._dateElement.length-1] !== "s") ? this._dateElement + "s" : this._dateElement; c[s] = this * -1; return ((!date) ? new Date() : date.clone()).add(c); }; // Do NOT modify the following string tokens. These tokens are used to build dynamic functions. // All culture-specific strings can be found in the CultureInfo files. var dx = ("sunday monday tuesday wednesday thursday friday saturday").split(/\s/), mx = ("january february march april may june july august september october november december").split(/\s/), px = ("Millisecond Second Minute Hour Day Week Month Year Quarter Weekday").split(/\s/), pxf = ("Milliseconds Seconds Minutes Hours Date Week Month FullYear Quarter").split(/\s/), nth = ("final first second third fourth fifth").split(/\s/), de; /** * Returns an object literal of all the date parts. * Example

	var o = new Date().toObject();
	
	// { year: 2008, month: 4, week: 20, day: 13, hour: 18, minute: 9, second: 32, millisecond: 812 }
	
	// The object properties can be referenced directly from the object.
	
	alert(o.day);  // alerts "13"
	alert(o.year); // alerts "2008"
	
* * @return {Date} An object literal representing the original date object. */ $P.toObject = function () { var o = {}; for (var i = 0; i < px.length; i++) { if (this["get" + pxf[i]]) { o[px[i].toLowerCase()] = this["get" + pxf[i]](); } } return o; }; /** * Returns a date created from an object literal. Ignores the .week property if set in the config. * Example

	var o = new Date().toObject();
	
	return Date.fromObject(o); // will return the same date. 

	var o2 = {month: 1, day: 20, hour: 18}; // birthday party!
	Date.fromObject(o2);
	
* * @return {Date} An object literal representing the original date object. */ $D.fromObject = function(config) { config.week = null; return Date.today().set(config); }; // Create day name functions and abbreviated day name functions (eg. monday(), friday(), fri()). var df = function (n) { return function () { if (this._is) { this._is = false; return this.getDay() === n; } if (this._move) { this._move = null; } if (this._nth !== null) { // If the .second() function was called earlier, remove the _orient // from the date, and then continue. // This is required because 'second' can be used in two different context. // // Example // // Date.today().add(1).second(); // Date.march().second().monday(); // // Things get crazy with the following... // Date.march().add(1).second().second().monday(); // but it works!! // if (this._isSecond) { this.addSeconds(this._orient * -1); } // make sure we reset _isSecond this._isSecond = false; var ntemp = this._nth; this._nth = null; var temp = this.clone().moveToLastDayOfMonth(); this.moveToNthOccurrence(n, ntemp); if (this > temp) { throw new RangeError($D.getDayName(n) + " does not occur " + ntemp + " times in the month of " + $D.getMonthName(temp.getMonth()) + " " + temp.getFullYear() + "."); } return this; } return this.moveToDayOfWeek(n, this._orient); }; }; var sdf = function (n) { return function () { var t = $D.today(), shift = n - t.getDay(); if (n === 0 && Date.CultureInfo.firstDayOfWeek === 1 && t.getDay() !== 0) { shift = shift + 7; } return t.addDays(shift); }; }; // Create month name functions and abbreviated month name functions (eg. january(), march(), mar()). var month_instance_functions = function (n) { return function () { if (this._is) { this._is = false; return this.getMonth() === n; } return this.moveToMonth(n, this._orient); }; }; var month_static_functions = function (n) { return function () { return $D.today().set({ month: n, day: 1 }); }; }; var processTerms = function (names, staticFunc, instanceFunc) { for (var i = 0; i < names.length; i++) { // Create constant static Name variables. $D[names[i].toUpperCase()] = $D[names[i].toUpperCase().substring(0, 3)] = i; // Create Name functions. $D[names[i]] = $D[names[i].substring(0, 3)] = staticFunc(i); // Create Name instance functions. $P[names[i]] = $P[names[i].substring(0, 3)] = instanceFunc(i); } }; processTerms(dx, sdf, df); processTerms(mx, month_static_functions, month_instance_functions); // Create date element functions and plural date element functions used with Date (eg. day(), days(), months()). var ef = function (j) { return function () { // if the .second() function was called earlier, the _orient // has alread been added. Just return this and reset _isSecond. if (this._isSecond) { this._isSecond = false; return this; } if (this._same) { this._same = this._is = false; var o1 = this.toObject(), o2 = (arguments[0] || new Date()).toObject(), v = "", k = j.toLowerCase(); // the substr trick with -1 doesn't work in IE8 or less k = (k[k.length-1] === "s") ? k.substring(0,k.length-1) : k; for (var m = (px.length - 1); m > -1; m--) { v = px[m].toLowerCase(); if (o1[v] !== o2[v]) { return false; } if (k === v) { break; } } return true; } if (j.substring(j.length - 1) !== "s") { j += "s"; } if (this._move) { this._move = null; } return this["add" + j](this._orient); }; }; var nf = function (n) { return function () { this._dateElement = n; return this; }; }; for (var k = 0; k < px.length; k++) { de = px[k].toLowerCase(); if(de !== "weekday") { // Create date element functions and plural date element functions used with Date (eg. day(), days(), months()). $P[de] = $P[de + "s"] = ef(px[k]); // Create date element functions and plural date element functions used with Number (eg. day(), days(), months()). $N[de] = $N[de + "s"] = nf(de + "s"); } } $P._ss = ef("Second"); var nthfn = function (n) { return function (dayOfWeek) { if (this._same) { return this._ss(arguments[0]); } if (dayOfWeek || dayOfWeek === 0) { return this.moveToNthOccurrence(dayOfWeek, n); } this._nth = n; // if the operator is 'second' add the _orient, then deal with it later... if (n === 2 && (dayOfWeek === undefined || dayOfWeek === null)) { this._isSecond = true; return this.addSeconds(this._orient); } return this; }; }; for (var l = 0; l < nth.length; l++) { $P[nth[l]] = (l === 0) ? nthfn(-1) : nthfn(l); } }()); (function () { "use strict"; Date.Parsing = { Exception: function (s) { this.message = "Parse error at '" + s.substring(0, 10) + " ...'"; } }; var $P = Date.Parsing; var dayOffsets = { standard: [0,31,59,90,120,151,181,212,243,273,304,334], leap: [0,31,60,91,121,152,182,213,244,274,305,335] }; $P.isLeapYear = function(year) { return ((year % 4 === 0) && (year % 100 !== 0)) || (year % 400 === 0); }; var utils = { multiReplace : function (str, hash ) { var key; for (key in hash) { if (Object.prototype.hasOwnProperty.call(hash, key)) { var regex; if (typeof hash[key] === "function") { } else { regex = (hash[key] instanceof RegExp) ? hash[key] : new RegExp(hash[key], "g"); } str = str.replace(regex, key); } } return str; }, getDayOfYearFromWeek : function (obj) { var d, jan4, offset; obj.weekDay = (!obj.weekDay && obj.weekDay !== 0) ? 1 : obj.weekDay; d = new Date(obj.year, 0, 4); jan4 = d.getDay() === 0 ? 7 : d.getDay(); // JS is 0 indexed on Sunday. offset = jan4+3; obj.dayOfYear = ((obj.week * 7) + (obj.weekDay === 0 ? 7 : obj.weekDay))-offset; return obj; }, getDayOfYear : function (obj, dayOffset) { if (!obj.dayOfYear) { obj = utils.getDayOfYearFromWeek(obj); } for (var i=0;i <= dayOffset.length;i++) { if (obj.dayOfYear < dayOffset[i] || i === dayOffset.length) { obj.day = obj.day ? obj.day : (obj.dayOfYear - dayOffset[i-1]); break; } else { obj.month = i; } } return obj; }, adjustForTimeZone : function (obj, date) { var offset; if (obj.zone.toUpperCase() === "Z" || (obj.zone_hours === 0 && obj.zone_minutes === 0)) { // it's UTC/GML so work out the current timeszone offset offset = -date.getTimezoneOffset(); } else { offset = (obj.zone_hours*60) + (obj.zone_minutes || 0); if (obj.zone_sign === "+") { offset *= -1; } offset -= date.getTimezoneOffset(); } date.setMinutes(date.getMinutes()+offset); return date; }, setDefaults : function (obj) { obj.year = obj.year || Date.today().getFullYear(); obj.hours = obj.hours || 0; obj.minutes = obj.minutes || 0; obj.seconds = obj.seconds || 0; obj.milliseconds = obj.milliseconds || 0; if (!(!obj.month && (obj.week || obj.dayOfYear))) { // if we have a month, or if we don't but don't have the day calculation data obj.month = obj.month || 0; obj.day = obj.day || 1; } return obj; }, dataNum: function (data, mod, explict, postProcess) { var dataNum = data*1; if (mod) { if (postProcess) { return data ? mod(data)*1 : data; } else { return data ? mod(dataNum) : data; } } else if (!explict){ return data ? dataNum : data; } else { return (data && typeof data !== "undefined") ? dataNum : data; } }, timeDataProcess: function (obj) { var timeObj = {}; for (var x in obj.data) { if (obj.data.hasOwnProperty(x)) { timeObj[x] = obj.ignore[x] ? obj.data[x] : utils.dataNum(obj.data[x], obj.mods[x], obj.explict[x], obj.postProcess[x]); } } if (obj.data.secmins) { obj.data.secmins = obj.data.secmins.replace(",", ".") * 60; if (!timeObj.minutes) { timeObj.minutes = obj.data.secmins; } else if (!timeObj.seconds) { timeObj.seconds = obj.data.secmins; } delete obj.secmins; } return timeObj; }, buildTimeObjectFromData: function (data) { var time = utils.timeDataProcess({ data: { year : data[1], month : data[5], day : data[7], week : data[8], dayOfYear : data[10], hours : data[15], zone_hours : data[23], zone_minutes : data[24], zone : data[21], zone_sign : data[22], weekDay : data[9], minutes: data[16], seconds: data[19], milliseconds: data[20], secmins: data[18] }, mods: { month: function(data) { return data-1; }, weekDay: function (data) { data = Math.abs(data); return (data === 7 ? 0 : data); }, minutes: function (data) { return data.replace(":",""); }, seconds: function (data) { return Math.floor( (data.replace(":","").replace(",","."))*1 ); }, milliseconds: function (data) { return (data.replace(",",".")*1000); } }, postProcess: { minutes: true, seconds: true, milliseconds: true }, explict: { zone_hours: true, zone_minutes: true }, ignore: { zone: true, zone_sign: true, secmins: true } }); return time; }, addToHash: function (hash, keys, data) { keys = keys; data = data; var len = keys.length; for (var i = 0; i < len; i++) { hash[keys[i]] = data[i]; } return hash; }, combineRegex: function (r1, r2) { return new RegExp("(("+r1.source+")\\s("+r2.source+"))"); }, getDateNthString: function(add, last, inc){ if (add) { return Date.today().addDays(inc).toString("d"); } else if (last) { return Date.today().last()[inc]().toString("d"); } }, buildRegexData: function (array) { var arr = []; var len = array.length; for (var i=0; i < len; i++) { if (Object.prototype.toString.call(array[i]) === '[object Array]') { // oldIE compat version of Array.isArray arr.push(this.combineRegex(array[i][0], array[i][1])); } else { arr.push(array[i]); } } return arr; } }; $P.processTimeObject = function (obj) { var date, dayOffset; utils.setDefaults(obj); dayOffset = ($P.isLeapYear(obj.year)) ? dayOffsets.leap : dayOffsets.standard; if (!obj.month && (obj.week || obj.dayOfYear)) { utils.getDayOfYear(obj, dayOffset); } else { obj.dayOfYear = dayOffset[obj.month] + obj.day; } date = new Date(obj.year, obj.month, obj.day, obj.hours, obj.minutes, obj.seconds, obj.milliseconds); if (obj.zone) { utils.adjustForTimeZone(obj, date); // adjust (and calculate) for timezone } return date; }; $P.ISO = { regex : /^([\+-]?\d{4}(?!\d{2}\b))((-?)((0[1-9]|1[0-2])(\3([12]\d|0[1-9]|3[01]))?|W([0-4]\d|5[0-3])(-?[1-7])?|(00[1-9]|0[1-9]\d|[12]\d{2}|3([0-5]\d|6[1-6])))([T\s]((([01]\d|2[0-4])((:?)[0-5]\d)?|24\:?00)([\.,]\d+(?!:))?)?(\17[0-5]\d([\.,]\d+)?)?\s?([zZ]|([\+-])([01]\d|2[0-3]):?([0-5]\d)?)?)?)?$/, parse : function (s) { var time, data = s.match(this.regex); if (!data || !data.length) { return null; } time = utils.buildTimeObjectFromData(data); if (!time.year || (!time.year && (!time.month && !time.day) && (!time.week && !time.dayOfYear)) ) { return null; } return $P.processTimeObject(time); } }; $P.Numeric = { isNumeric: function (e){return!isNaN(parseFloat(e))&&isFinite(e);}, regex: /\b([0-1]?[0-9])([0-3]?[0-9])([0-2]?[0-9]?[0-9][0-9])\b/i, parse: function (s) { var data, i, time = {}, order = Date.CultureInfo.dateElementOrder.split(""); if (!(this.isNumeric(s)) || // if it's non-numeric OR (s[0] === "+" && s[0] === "-")) { // It's an arithmatic string (eg +/-1000) return null; } if (s.length < 5 && s.indexOf(".") < 0 && s.indexOf("/") < 0) { // assume it's just a year. time.year = s; return $P.processTimeObject(time); } data = s.match(this.regex); if (!data || !data.length) { return null; } for (i=0; i < order.length; i++) { switch(order[i]) { case "d": time.day = data[i+1]; break; case "m": time.month = (data[i+1]-1); break; case "y": time.year = data[i+1]; break; } } return $P.processTimeObject(time); } }; $P.Normalizer = { regexData: function () { var $R = Date.CultureInfo.regexPatterns; return utils.buildRegexData([ $R.tomorrow, $R.yesterday, [$R.past, $R.mon], [$R.past, $R.tue], [$R.past, $R.wed], [$R.past, $R.thu], [$R.past, $R.fri], [$R.past, $R.sat], [$R.past, $R.sun] ]); }, basicReplaceHash : function() { var $R = Date.CultureInfo.regexPatterns; return { "January": $R.jan.source, "February": $R.feb, "March": $R.mar, "April": $R.apr, "May": $R.may, "June": $R.jun, "July": $R.jul, "August": $R.aug, "September": $R.sep, "October": $R.oct, "November": $R.nov, "December": $R.dec, "": /\bat\b/gi, " ": /\s{2,}/, "am": $R.inTheMorning, "9am": $R.thisMorning, "pm": $R.inTheEvening, "7pm":$R.thisEvening }; }, keys : function(){ return [ utils.getDateNthString(true, false, 1), // tomorrow utils.getDateNthString(true, false, -1), // yesterday utils.getDateNthString(false, true, "monday"), //last mon utils.getDateNthString(false, true, "tuesday"), //last tues utils.getDateNthString(false, true, "wednesday"), //last wed utils.getDateNthString(false, true, "thursday"), //last thurs utils.getDateNthString(false, true, "friday"), //last fri utils.getDateNthString(false, true, "saturday"), //last sat utils.getDateNthString(false, true, "sunday") //last sun ]; }, buildRegexFunctions: function () { var $R = Date.CultureInfo.regexPatterns; var __ = Date.i18n.__; var tomorrowRE = new RegExp("(\\b\\d\\d?("+__("AM")+"|"+__("PM")+")? )("+$R.tomorrow.source.slice(1)+")", "i"); // adapted tomorrow regex for AM PM relative dates var todayRE = new RegExp($R.today.source + "(?!\\s*([+-]))\\b"); // today, but excludes the math operators (eg "today + 2h") this.replaceFuncs = [ [todayRE, function (full) { return (full.length > 1) ? Date.today().toString("d") : full; }], [tomorrowRE, function(full, m1) { var t = Date.today().addDays(1).toString("d"); return (t + " " + m1); }], [$R.amThisMorning, function(str, am){return am;}], [$R.pmThisEvening, function(str, pm){return pm;}] ]; }, buildReplaceData: function () { this.buildRegexFunctions(); this.replaceHash = utils.addToHash(this.basicReplaceHash(), this.keys(), this.regexData()); }, stringReplaceFuncs: function (s) { for (var i=0; i < this.replaceFuncs.length; i++) { s = s.replace(this.replaceFuncs[i][0], this.replaceFuncs[i][1]); } return s; }, parse: function (s) { s = this.stringReplaceFuncs(s); s = utils.multiReplace(s, this.replaceHash); try { var n = s.split(/([\s\-\.\,\/\x27]+)/); if (n.length === 3 && $P.Numeric.isNumeric(n[0]) && $P.Numeric.isNumeric(n[2]) && (n[2].length >= 4)) { // ok, so we're dealing with x/year. But that's not a full date. // This fixes wonky dateElementOrder parsing when set to dmy order. if (Date.CultureInfo.dateElementOrder[0] === "d") { s = "1/" + n[0] + "/" + n[2]; // set to 1st of month and normalize the seperator } } } catch (e) {} return s; } }; $P.Normalizer.buildReplaceData(); }()); (function () { var $P = Date.Parsing; var _ = $P.Operators = { // // Tokenizers // rtoken: function (r) { // regex token return function (s) { var mx = s.match(r); if (mx) { return ([ mx[0], s.substring(mx[0].length) ]); } else { throw new $P.Exception(s); } }; }, token: function () { // whitespace-eating token return function (s) { return _.rtoken(new RegExp("^\\s*" + s + "\\s*"))(s); }; }, stoken: function (s) { // string token return _.rtoken(new RegExp("^" + s)); }, // Atomic Operators until: function (p) { return function (s) { var qx = [], rx = null; while (s.length) { try { rx = p.call(this, s); } catch (e) { qx.push(rx[0]); s = rx[1]; continue; } break; } return [ qx, s ]; }; }, many: function (p) { return function (s) { var rx = [], r = null; while (s.length) { try { r = p.call(this, s); } catch (e) { return [ rx, s ]; } rx.push(r[0]); s = r[1]; } return [ rx, s ]; }; }, // generator operators -- see below optional: function (p) { return function (s) { var r = null; try { r = p.call(this, s); } catch (e) { return [ null, s ]; } return [ r[0], r[1] ]; }; }, not: function (p) { return function (s) { try { p.call(this, s); } catch (e) { return [null, s]; } throw new $P.Exception(s); }; }, ignore: function (p) { return p ? function (s) { var r = null; r = p.call(this, s); return [null, r[1]]; } : null; }, product: function () { var px = arguments[0], qx = Array.prototype.slice.call(arguments, 1), rx = []; for (var i = 0 ; i < px.length ; i++) { rx.push(_.each(px[i], qx)); } return rx; }, cache: function (rule) { var cache = {}, cache_length = 0, cache_keys = [], CACHE_MAX = Date.Config.CACHE_MAX || 100000, r = null; var cacheCheck = function () { if (cache_length === CACHE_MAX) { // kill several keys, don't want to have to do this all the time... for (var i=0; i < 10; i++) { var key = cache_keys.shift(); if (key) { delete cache[key]; cache_length--; } } } }; return function (s) { cacheCheck(); try { r = cache[s] = (cache[s] || rule.call(this, s)); } catch (e) { r = cache[s] = e; } cache_length++; cache_keys.push(s); if (r instanceof $P.Exception) { throw r; } else { return r; } }; }, // vector operators -- see below any: function () { var px = arguments; return function (s) { var r = null; for (var i = 0; i < px.length; i++) { if (px[i] == null) { continue; } try { r = (px[i].call(this, s)); } catch (e) { r = null; } if (r) { return r; } } throw new $P.Exception(s); }; }, each: function () { var px = arguments; return function (s) { var rx = [], r = null; for (var i = 0; i < px.length ; i++) { if (px[i] == null) { continue; } try { r = (px[i].call(this, s)); } catch (e) { throw new $P.Exception(s); } rx.push(r[0]); s = r[1]; } return [ rx, s]; }; }, all: function () { var px = arguments, _ = _; return _.each(_.optional(px)); }, // delimited operators sequence: function (px, d, c) { d = d || _.rtoken(/^\s*/); c = c || null; if (px.length === 1) { return px[0]; } return function (s) { var r = null, q = null; var rx = []; for (var i = 0; i < px.length ; i++) { try { r = px[i].call(this, s); } catch (e) { break; } rx.push(r[0]); try { q = d.call(this, r[1]); } catch (ex) { q = null; break; } s = q[1]; } if (!r) { throw new $P.Exception(s); } if (q) { throw new $P.Exception(q[1]); } if (c) { try { r = c.call(this, r[1]); } catch (ey) { throw new $P.Exception(r[1]); } } return [ rx, (r?r[1]:s) ]; }; }, // // Composite Operators // between: function (d1, p, d2) { d2 = d2 || d1; var _fn = _.each(_.ignore(d1), p, _.ignore(d2)); return function (s) { var rx = _fn.call(this, s); return [[rx[0][0], r[0][2]], rx[1]]; }; }, list: function (p, d, c) { d = d || _.rtoken(/^\s*/); c = c || null; return (p instanceof Array ? _.each(_.product(p.slice(0, -1), _.ignore(d)), p.slice(-1), _.ignore(c)) : _.each(_.many(_.each(p, _.ignore(d))), px, _.ignore(c))); }, set: function (px, d, c) { d = d || _.rtoken(/^\s*/); c = c || null; return function (s) { // r is the current match, best the current 'best' match // which means it parsed the most amount of input var r = null, p = null, q = null, rx = null, best = [[], s], last = false; // go through the rules in the given set for (var i = 0; i < px.length ; i++) { // last is a flag indicating whether this must be the last element // if there is only 1 element, then it MUST be the last one q = null; p = null; r = null; last = (px.length === 1); // first, we try simply to match the current pattern // if not, try the next pattern try { r = px[i].call(this, s); } catch (e) { continue; } // since we are matching against a set of elements, the first // thing to do is to add r[0] to matched elements rx = [[r[0]], r[1]]; // if we matched and there is still input to parse and // we don't already know this is the last element, // we're going to next check for the delimiter ... // if there's none, or if there's no input left to parse // than this must be the last element after all ... if (r[1].length > 0 && ! last) { try { q = d.call(this, r[1]); } catch (ex) { last = true; } } else { last = true; } // if we parsed the delimiter and now there's no more input, // that means we shouldn't have parsed the delimiter at all // so don't update r and mark this as the last element ... if (!last && q[1].length === 0) { last = true; } // so, if this isn't the last element, we're going to see if // we can get any more matches from the remaining (unmatched) // elements ... if (!last) { // build a list of the remaining rules we can match against, // i.e., all but the one we just matched against var qx = []; for (var j = 0; j < px.length ; j++) { if (i !== j) { qx.push(px[j]); } } // now invoke recursively set with the remaining input // note that we don't include the closing delimiter ... // we'll check for that ourselves at the end p = _.set(qx, d).call(this, q[1]); // if we got a non-empty set as a result ... // (otw rx already contains everything we want to match) if (p[0].length > 0) { // update current result, which is stored in rx ... // basically, pick up the remaining text from p[1] // and concat the result from p[0] so that we don't // get endless nesting ... rx[0] = rx[0].concat(p[0]); rx[1] = p[1]; } } // at this point, rx either contains the last matched element // or the entire matched set that starts with this element. // now we just check to see if this variation is better than // our best so far, in terms of how much of the input is parsed if (rx[1].length < best[1].length) { best = rx; } // if we've parsed all the input, then we're finished if (best[1].length === 0) { break; } } // so now we've either gone through all the patterns trying them // as the initial match; or we found one that parsed the entire // input string ... // if best has no matches, just return empty set ... if (best[0].length === 0) { return best; } // if a closing delimiter is provided, then we have to check it also if (c) { // we try this even if there is no remaining input because the pattern // may well be optional or match empty input ... try { q = c.call(this, best[1]); } catch (ey) { throw new $P.Exception(best[1]); } // it parsed ... be sure to update the best match remaining input best[1] = q[1]; } // if we're here, either there was no closing delimiter or we parsed it // so now we have the best match; just return it! return best; }; }, forward: function (gr, fname) { return function (s) { return gr[fname].call(this, s); }; }, // // Translation Operators // replace: function (rule, repl) { return function (s) { var r = rule.call(this, s); return [repl, r[1]]; }; }, process: function (rule, fn) { return function (s) { var r = rule.call(this, s); return [fn.call(this, r[0]), r[1]]; }; }, min: function (min, rule) { return function (s) { var rx = rule.call(this, s); if (rx[0].length < min) { throw new $P.Exception(s); } return rx; }; } }; // Generator Operators And Vector Operators // Generators are operators that have a signature of F(R) => R, // taking a given rule and returning another rule, such as // ignore, which parses a given rule and throws away the result. // Vector operators are those that have a signature of F(R1,R2,...) => R, // take a list of rules and returning a new rule, such as each. // Generator operators are converted (via the following _generator // function) into functions that can also take a list or array of rules // and return an array of new rules as though the function had been // called on each rule in turn (which is what actually happens). // This allows generators to be used with vector operators more easily. // Example: // each(ignore(foo, bar)) instead of each(ignore(foo), ignore(bar)) // This also turns generators into vector operators, which allows // constructs like: // not(cache(foo, bar)) var _generator = function (op) { function gen() { var args = null, rx = [], px, i; if (arguments.length > 1) { args = Array.prototype.slice.call(arguments); } else if (arguments[0] instanceof Array) { args = arguments[0]; } if (args) { px = args.shift(); if (px.length > 0) { args.unshift(px[i]); rx.push(op.apply(null, args)); args.shift(); return rx; } } else { return op.apply(null, arguments); } } return gen; }; var gx = "optional not ignore cache".split(/\s/); for (var i = 0 ; i < gx.length ; i++) { _[gx[i]] = _generator(_[gx[i]]); } var _vector = function (op) { return function () { if (arguments[0] instanceof Array) { return op.apply(null, arguments[0]); } else { return op.apply(null, arguments); } }; }; var vx = "each any all".split(/\s/); for (var j = 0 ; j < vx.length ; j++) { _[vx[j]] = _vector(_[vx[j]]); } }()); (function () { var $D = Date; var flattenAndCompact = function (ax) { var rx = []; for (var i = 0; i < ax.length; i++) { if (ax[i] instanceof Array) { rx = rx.concat(flattenAndCompact(ax[i])); } else { if (ax[i]) { rx.push(ax[i]); } } } return rx; }; var parseMeridian = function () { if (this.meridian && (this.hour || this.hour === 0)) { if (this.meridian === "a" && this.hour > 11 && Date.Config.strict24hr){ throw "Invalid hour and meridian combination"; } else if (this.meridian === "p" && this.hour < 12 && Date.Config.strict24hr){ throw "Invalid hour and meridian combination"; } else if (this.meridian === "p" && this.hour < 12) { this.hour = this.hour + 12; } else if (this.meridian === "a" && this.hour === 12) { this.hour = 0; } } }; var setDefaults = function () { var now = new Date(); if ((this.hour || this.minute) && (!this.month && !this.year && !this.day)) { this.day = now.getDate(); } if (!this.year) { this.year = now.getFullYear(); } if (!this.month && this.month !== 0) { this.month = now.getMonth(); } if (!this.day) { this.day = 1; } if (!this.hour) { this.hour = 0; } if (!this.minute) { this.minute = 0; } if (!this.second) { this.second = 0; } if (!this.millisecond) { this.millisecond = 0; } }; var finishUtils = { getToday: function () { if (this.now || "hour minute second".indexOf(this.unit) !== -1) { return new Date(); } else { return $D.today(); } }, setDaysFromWeekday: function (today, orient){ var gap; orient = orient || 1; this.unit = "day"; gap = ($D.getDayNumberFromName(this.weekday) - today.getDay()); this.days = gap ? ((gap + (orient * 7)) % 7) : (orient * 7); return this; }, setMonthsFromMonth: function (today, orient) { var gap; orient = orient || 1; this.unit = "month"; gap = (this.month - today.getMonth()); this.months = gap ? ((gap + (orient * 12)) % 12) : (orient * 12); this.month = null; return this; }, setDMYFromWeekday: function () { var d = Date[this.weekday](); this.day = d.getDate(); if (!this.month) { this.month = d.getMonth(); } this.year = d.getFullYear(); return this; }, setUnitValue: function (orient) { if (!this.value && this.operator && this.operator !== null && this[this.unit + "s"] && this[this.unit + "s"] !== null) { this[this.unit + "s"] = this[this.unit + "s"] + ((this.operator === "add") ? 1 : -1) + (this.value||0) * orient; } else if (this[this.unit + "s"] == null || this.operator != null) { if (!this.value) { this.value = 1; } this[this.unit + "s"] = this.value * orient; } }, generateDateFromWeeks: function () { var weekday = (this.weekday !== undefined) ? this.weekday : "today"; var d = Date[weekday]().addWeeks(this.weeks); if (this.now) { d.setTimeToNow(); } return d; } }; $D.Translator = { hour: function (s) { return function () { this.hour = Number(s); }; }, minute: function (s) { return function () { this.minute = Number(s); }; }, second: function (s) { return function () { this.second = Number(s); }; }, /* for ss.s format */ secondAndMillisecond: function (s) { return function () { var mx = s.match(/^([0-5][0-9])\.([0-9]{1,3})/); this.second = Number(mx[1]); this.millisecond = Number(mx[2]); }; }, meridian: function (s) { return function () { this.meridian = s.slice(0, 1).toLowerCase(); }; }, timezone: function (s) { return function () { var n = s.replace(/[^\d\+\-]/g, ""); if (n.length) { this.timezoneOffset = Number(n); } else { this.timezone = s.toLowerCase(); } }; }, day: function (x) { var s = x[0]; return function () { this.day = Number(s.match(/\d+/)[0]); if (this.day < 1) { throw "invalid day"; } }; }, month: function (s) { return function () { this.month = (s.length === 3) ? "jan feb mar apr may jun jul aug sep oct nov dec".indexOf(s)/4 : Number(s) - 1; if (this.month < 0) { throw "invalid month"; } }; }, year: function (s) { return function () { var n = Number(s); this.year = ((s.length > 2) ? n : (n + (((n + 2000) < Date.CultureInfo.twoDigitYearMax) ? 2000 : 1900))); }; }, rday: function (s) { return function () { switch (s) { case "yesterday": this.days = -1; break; case "tomorrow": this.days = 1; break; case "today": this.days = 0; break; case "now": this.days = 0; this.now = true; break; } }; }, finishExact: function (x) { var d; x = (x instanceof Array) ? x : [x]; for (var i = 0 ; i < x.length ; i++) { if (x[i]) { x[i].call(this); } } setDefaults.call(this); parseMeridian.call(this); if (this.day > $D.getDaysInMonth(this.year, this.month)) { throw new RangeError(this.day + " is not a valid value for days."); } d = new Date(this.year, this.month, this.day, this.hour, this.minute, this.second, this.millisecond); if (this.year < 100) { d.setFullYear(this.year); // means years less that 100 are process correctly. JS will parse it otherwise as 1900-1999. } if (this.timezone) { d.set({ timezone: this.timezone }); } else if (this.timezoneOffset) { d.set({ timezoneOffset: this.timezoneOffset }); } return d; }, finish: function (x) { var today, expression, orient, temp; x = (x instanceof Array) ? flattenAndCompact(x) : [ x ]; if (x.length === 0) { return null; } for (var i = 0 ; i < x.length ; i++) { if (typeof x[i] === "function") { x[i].call(this); } } if (this.now && !this.unit && !this.operator) { return new Date(); } else { today = finishUtils.getToday.call(this); } expression = !!(this.days && this.days !== null || this.orient || this.operator); orient = ((this.orient === "past" || this.operator === "subtract") ? -1 : 1); if (this.month && this.unit === "week") { this.value = this.month + 1; delete this.month; delete this.day; } if ((this.month || this.month === 0) && "year day hour minute second".indexOf(this.unit) !== -1) { if (!this.value) { this.value = this.month + 1; } this.month = null; expression = true; } if (!expression && this.weekday && !this.day && !this.days) { finishUtils.setDMYFromWeekday.call(this); } if (expression && this.weekday && this.unit !== "month" && this.unit !== "week") { finishUtils.setDaysFromWeekday.call(this, today, orient); } if (this.weekday && this.unit !== "week" && !this.day && !this.days) { temp = Date[this.weekday](); this.day = temp.getDate(); if (temp.getMonth() !== today.getMonth()) { this.month = temp.getMonth(); } } if (this.month && this.unit === "day" && this.operator) { if (!this.value) { this.value = (this.month + 1); } this.month = null; } if (this.value != null && this.month != null && this.year != null) { this.day = this.value * 1; } if (this.month && !this.day && this.value) { today.set({ day: this.value * 1 }); if (!expression) { this.day = this.value * 1; } } if (!this.month && this.value && this.unit === "month" && !this.now) { this.month = this.value; expression = true; } if (expression && (this.month || this.month === 0) && this.unit !== "year") { finishUtils.setMonthsFromMonth.call(this, today, orient); } if (!this.unit) { this.unit = "day"; } finishUtils.setUnitValue.call(this, orient); parseMeridian.call(this); if ((this.month || this.month === 0) && !this.day) { this.day = 1; } if (!this.orient && !this.operator && this.unit === "week" && this.value && !this.day && !this.month) { return Date.today().setWeek(this.value); } if (this.unit === "week" && this.weeks && !this.day && !this.month) { return finishUtils.generateDateFromWeeks.call(this); } if (expression && this.timezone && this.day && this.days) { this.day = this.days; } if (expression){ today.add(this); } else { today.set(this); } if (this.timezone) { this.timezone = this.timezone.toUpperCase(); var offset = $D.getTimezoneOffset(this.timezone); var timezone; if (today.hasDaylightSavingTime()) { // lets check that we're being sane with timezone setting timezone = $D.getTimezoneAbbreviation(offset, today.isDaylightSavingTime()); if (timezone !== this.timezone) { // bugger, we're in a place where things like EST vs EDT matters. if (today.isDaylightSavingTime()) { today.addHours(-1); } else { today.addHours(1); } } } today.setTimezoneOffset(offset); } return today; } }; }()); (function () { var $D = Date; $D.Grammar = {}; var _ = $D.Parsing.Operators, g = $D.Grammar, t = $D.Translator, _fn; // Allow rolling up into general purpose rules _fn = function () { return _.each(_.any.apply(null, arguments), _.not(g.ctoken2("timeContext"))); }; g.datePartDelimiter = _.rtoken(/^([\s\-\.\,\/\x27]+)/); g.timePartDelimiter = _.stoken(":"); g.whiteSpace = _.rtoken(/^\s*/); g.generalDelimiter = _.rtoken(/^(([\s\,]|at|@|on)+)/); var _C = {}; g.ctoken = function (keys) { var fn = _C[keys]; if (! fn) { var c = Date.CultureInfo.regexPatterns; var kx = keys.split(/\s+/), px = []; for (var i = 0; i < kx.length ; i++) { px.push(_.replace(_.rtoken(c[kx[i]]), kx[i])); } fn = _C[keys] = _.any.apply(null, px); } return fn; }; g.ctoken2 = function (key) { return _.rtoken(Date.CultureInfo.regexPatterns[key]); }; var cacheProcessRtoken = function (key, token, type, eachToken) { if (eachToken) { g[key] = _.cache(_.process(_.each(_.rtoken(token),_.optional(g.ctoken2(eachToken))), type)); } else { g[key] = _.cache(_.process(_.rtoken(token), type)); } }; var cacheProcessCtoken = function (token, type) { return _.cache(_.process(g.ctoken2(token), type)); }; var _F = {}; //function cache var _get = function (f) { _F[f] = (_F[f] || g.format(f)[0]); return _F[f]; }; g.allformats = function (fx) { var rx = []; if (fx instanceof Array) { for (var i = 0; i < fx.length; i++) { rx.push(_get(fx[i])); } } else { rx.push(_get(fx)); } return rx; }; g.formats = function (fx) { if (fx instanceof Array) { var rx = []; for (var i = 0 ; i < fx.length ; i++) { rx.push(_get(fx[i])); } return _.any.apply(null, rx); } else { return _get(fx); } }; var grammarFormats = { timeFormats: function(){ var i, RTokenKeys = [ "h", "hh", "H", "HH", "m", "mm", "s", "ss", "ss.s", "z", "zz" ], RToken = [ /^(0[0-9]|1[0-2]|[1-9])/, /^(0[0-9]|1[0-2])/, /^([0-1][0-9]|2[0-3]|[0-9])/, /^([0-1][0-9]|2[0-3])/, /^([0-5][0-9]|[0-9])/, /^[0-5][0-9]/, /^([0-5][0-9]|[0-9])/, /^[0-5][0-9]/, /^[0-5][0-9]\.[0-9]{1,3}/, /^((\+|\-)\s*\d\d\d\d)|((\+|\-)\d\d\:?\d\d)/, /^((\+|\-)\s*\d\d\d\d)|((\+|\-)\d\d\:?\d\d)/ ], tokens = [ t.hour, t.hour, t.hour, t.hour, t.minute, t.minute, t.second, t.second, t.secondAndMillisecond, t.timezone, t.timezone ]; for (i=0; i < RTokenKeys.length; i++) { cacheProcessRtoken(RTokenKeys[i], RToken[i], tokens[i]); } g.hms = _.cache(_.sequence([g.H, g.m, g.s], g.timePartDelimiter)); g.t = cacheProcessCtoken("shortMeridian", t.meridian); g.tt = cacheProcessCtoken("longMeridian", t.meridian); g.zzz = cacheProcessCtoken("timezone", t.timezone); g.timeSuffix = _.each(_.ignore(g.whiteSpace), _.set([ g.tt, g.zzz ])); g.time = _.each(_.optional(_.ignore(_.stoken("T"))), g.hms, g.timeSuffix); }, dateFormats: function () { // pre-loaded rules for different date part order preferences var _setfn = function () { return _.set(arguments, g.datePartDelimiter); }; var i, RTokenKeys = [ "d", "dd", "M", "MM", "y", "yy", "yyy", "yyyy" ], RToken = [ /^([0-2]\d|3[0-1]|\d)/, /^([0-2]\d|3[0-1])/, /^(1[0-2]|0\d|\d)/, /^(1[0-2]|0\d)/, /^(\d+)/, /^(\d\d)/, /^(\d\d?\d?\d?)/, /^(\d\d\d\d)/ ], tokens = [ t.day, t.day, t.month, t.month, t.year, t.year, t.year, t.year ], eachToken = [ "ordinalSuffix", "ordinalSuffix" ]; for (i=0; i < RTokenKeys.length; i++) { cacheProcessRtoken(RTokenKeys[i], RToken[i], tokens[i], eachToken[i]); } g.MMM = g.MMMM = _.cache(_.process(g.ctoken("jan feb mar apr may jun jul aug sep oct nov dec"), t.month)); g.ddd = g.dddd = _.cache(_.process(g.ctoken("sun mon tue wed thu fri sat"), function (s) { return function () { this.weekday = s; }; } )); g.day = _fn(g.d, g.dd); g.month = _fn(g.M, g.MMM); g.year = _fn(g.yyyy, g.yy); g.mdy = _setfn(g.ddd, g.month, g.day, g.year); g.ymd = _setfn(g.ddd, g.year, g.month, g.day); g.dmy = _setfn(g.ddd, g.day, g.month, g.year); g.date = function (s) { return ((g[Date.CultureInfo.dateElementOrder] || g.mdy).call(this, s)); }; }, relative: function () { // relative date / time expressions g.orientation = _.process(g.ctoken("past future"), function (s) { return function () { this.orient = s; }; } ); g.operator = _.process(g.ctoken("add subtract"), function (s) { return function () { this.operator = s; }; } ); g.rday = _.process(g.ctoken("yesterday tomorrow today now"), t.rday); g.unit = _.process(g.ctoken("second minute hour day week month year"), function (s) { return function () { this.unit = s; }; } ); } }; g.buildGrammarFormats = function () { // these need to be rebuilt every time the language changes. _C = {}; grammarFormats.timeFormats(); grammarFormats.dateFormats(); grammarFormats.relative(); g.value = _.process(_.rtoken(/^([-+]?\d+)?(st|nd|rd|th)?/), function (s) { return function () { this.value = s.replace(/\D/g, ""); }; } ); g.expression = _.set([g.rday, g.operator, g.value, g.unit, g.orientation, g.ddd, g.MMM ]); g.format = _.process(_.many( _.any( // translate format specifiers into grammar rules _.process( _.rtoken(/^(dd?d?d?(?!e)|MM?M?M?|yy?y?y?|hh?|HH?|mm?|ss?|tt?|zz?z?)/), function (fmt) { if (g[fmt]) { return g[fmt]; } else { throw $D.Parsing.Exception(fmt); } } ), // translate separator tokens into token rules _.process(_.rtoken(/^[^dMyhHmstz]+/), // all legal separators function (s) { return _.ignore(_.stoken(s)); } ) ) ), // construct the parser ... function (rules) { return _.process(_.each.apply(null, rules), t.finishExact); } ); // starting rule for general purpose grammar g._start = _.process(_.set([ g.date, g.time, g.expression ], g.generalDelimiter, g.whiteSpace), t.finish); }; g.buildGrammarFormats(); // parsing date format specifiers - ex: "h:m:s tt" // this little guy will generate a custom parser based // on the format string, ex: g.format("h:m:s tt") // check for these formats first g._formats = g.formats([ "\"yyyy-MM-ddTHH:mm:ssZ\"", "yyyy-MM-ddTHH:mm:ss.sz", "yyyy-MM-ddTHH:mm:ssZ", "yyyy-MM-ddTHH:mm:ssz", "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-ddTHH:mmZ", "yyyy-MM-ddTHH:mmz", "yyyy-MM-ddTHH:mm", "ddd, MMM dd, yyyy H:mm:ss tt", "ddd MMM d yyyy HH:mm:ss zzz", "MMddyyyy", "ddMMyyyy", "Mddyyyy", "ddMyyyy", "Mdyyyy", "dMyyyy", "yyyy", "Mdyy", "dMyy", "d" ]); // real starting rule: tries selected formats first, // then general purpose rule g.start = function (s) { try { var r = g._formats.call({}, s); if (r[1].length === 0) { return r; } } catch (e) {} return g._start.call({}, s); }; }()); (function () { var $D = Date; /** * @desc Converts the specified string value into its JavaScript Date equivalent using CultureInfo specific format information. * * Example

	///////////
	// Dates //
	///////////

	// 15-Oct-2004
	var d1 = Date.parse("10/15/2004");

	// 15-Oct-2004
	var d1 = Date.parse("15-Oct-2004");

	// 15-Oct-2004
	var d1 = Date.parse("2004.10.15");

	//Fri Oct 15, 2004
	var d1 = Date.parse("Fri Oct 15, 2004");

	///////////
	// Times //
	///////////

	// Today at 10 PM.
	var d1 = Date.parse("10 PM");

	// Today at 10:30 PM.
	var d1 = Date.parse("10:30 P.M.");

	// Today at 6 AM.
	var d1 = Date.parse("06am");

	/////////////////////
	// Dates and Times //
	/////////////////////

	// 8-July-2004 @ 10:30 PM
	var d1 = Date.parse("July 8th, 2004, 10:30 PM");

	// 1-July-2004 @ 10:30 PM
	var d1 = Date.parse("2004-07-01T22:30:00");

	////////////////////
	// Relative Dates //
	////////////////////

	// Returns today's date. The string "today" is culture specific.
	var d1 = Date.parse("today");

	// Returns yesterday's date. The string "yesterday" is culture specific.
	var d1 = Date.parse("yesterday");

	// Returns the date of the next thursday.
	var d1 = Date.parse("Next thursday");

	// Returns the date of the most previous monday.
	var d1 = Date.parse("last monday");

	// Returns today's day + one year.
	var d1 = Date.parse("next year");

	///////////////
	// Date Math //
	///////////////

	// Today + 2 days
	var d1 = Date.parse("t+2");

	// Today + 2 days
	var d1 = Date.parse("today + 2 days");

	// Today + 3 months
	var d1 = Date.parse("t+3m");

	// Today - 1 year
	var d1 = Date.parse("today - 1 year");

	// Today - 1 year
	var d1 = Date.parse("t-1y"); 


	/////////////////////////////
	// Partial Dates and Times //
	/////////////////////////////

	// July 15th of this year.
	var d1 = Date.parse("July 15");

	// 15th day of current day and year.
	var d1 = Date.parse("15");

	// July 1st of current year at 10pm.
	var d1 = Date.parse("7/1 10pm");
	
* * @param {String} The string value to convert into a Date object [Required] * @return {Date} A Date object or null if the string cannot be converted into a Date. */ var parseUtils = { removeOrds: function (s) { ords = s.match(/\b(\d+)(?:st|nd|rd|th)\b/); // find ordinal matches s = ((ords && ords.length === 2) ? s.replace(ords[0], ords[1]) : s); return s; }, grammarParser: function (s) { var r = null; try { r = $D.Grammar.start.call({}, s.replace(/^\s*(\S*(\s+\S+)*)\s*$/, "$1")); } catch (e) { return null; } return ((r[1].length === 0) ? r[0] : null); }, nativeFallback: function(s) { var t; try { // ok we haven't parsed it, last ditch attempt with the built-in parser. t = Date._parse(s); return (t || t === 0) ? new Date(t) : null; } catch (e) { return null; } } }; function parse (s) { var d; if (!s) { return null; } if (s instanceof Date) { return s.clone(); } if (s.length >= 4 && s.charAt(0) !== "0" && s.charAt(0) !== "+"&& s.charAt(0) !== "-") { // ie: 2004 will pass, 0800 won't. // Start with specific formats d = $D.Parsing.ISO.parse(s) || $D.Parsing.Numeric.parse(s); } if (d instanceof Date && !isNaN(d.getTime())) { return d; } else { // find ordinal dates (1st, 3rd, 8th, etc and remove them as they cause parsing issues) s = $D.Parsing.Normalizer.parse(parseUtils.removeOrds(s)); d = parseUtils.grammarParser(s); if (d !== null) { return d; } else { return parseUtils.nativeFallback(s); } } } if (!$D._parse) { $D._parse = $D.parse; } $D.parse = parse; Date.getParseFunction = function (fx) { var fns = Date.Grammar.allformats(fx); return function (s) { var r = null; for (var i = 0; i < fns.length; i++) { try { r = fns[i].call({}, s); } catch (e) { continue; } if (r[1].length === 0) { return r[0]; } } return null; }; }; /** * Converts the specified string value into its JavaScript Date equivalent using the specified format {String} or formats {Array} and the CultureInfo specific format information. * The format of the string value must match one of the supplied formats exactly. * * Example

	// 15-Oct-2004
	var d1 = Date.parseExact("10/15/2004", "M/d/yyyy");

	// 15-Oct-2004
	var d1 = Date.parse("15-Oct-2004", "M-ddd-yyyy");

	// 15-Oct-2004
	var d1 = Date.parse("2004.10.15", "yyyy.MM.dd");

	// Multiple formats
	var d1 = Date.parseExact("10/15/2004", ["M/d/yyyy", "MMMM d, yyyy"]);
	
* * @param {String} The string value to convert into a Date object [Required]. * @param {Object} The expected format {String} or an array of expected formats {Array} of the date string [Required]. * @return {Date} A Date object or null if the string cannot be converted into a Date. */ $D.parseExact = function (s, fx) { return $D.getParseFunction(fx)(s); }; }()); (function () { var $D = Date, $P = $D.prototype, // $C = $D.CultureInfo, // not used atm p = function (s, l) { if (!l) { l = 2; } return ("000" + s).slice(l * -1); }; /** * Converts a PHP format string to Java/.NET format string. * A PHP format string can be used with ._format or .format. * A Java/.NET format string can be used with .toString(). * The .parseExact function will only accept a Java/.NET format string * * Example * var f1 = "%m/%d/%y" * var f2 = Date.normalizeFormat(f1); // "MM/dd/yy" * * new Date().format(f1); // "04/13/08" * new Date()._format(f1); // "04/13/08" * new Date().toString(f2); // "04/13/08" * * var date = Date.parseExact("04/13/08", f2); // Sun Apr 13 2008 * * @param {String} A PHP format string consisting of one or more format spcifiers. * @return {String} The PHP format converted to a Java/.NET format string. */ var normalizerSubstitutions = { "d" : "dd", "%d": "dd", "D" : "ddd", "%a": "ddd", "j" : "dddd", "l" : "dddd", "%A": "dddd", "S" : "S", "F" : "MMMM", "%B": "MMMM", "m" : "MM", "%m": "MM", "M" : "MMM", "%b": "MMM", "%h": "MMM", "n" : "M", "Y" : "yyyy", "%Y": "yyyy", "y" : "yy", "%y": "yy", "g" : "h", "%I": "h", "G" : "H", "h" : "hh", "H" : "HH", "%H": "HH", "i" : "mm", "%M": "mm", "s" : "ss", "%S": "ss", "%r": "hh:mm tt", "%R": "H:mm", "%T": "H:mm:ss", "%X": "t", "%x": "d", "%e": "d", "%D": "MM/dd/yy", "%n": "\\n", "%t": "\\t", "e" : "z", "T" : "z", "%z": "z", "%Z": "z", "Z" : "ZZ", "N" : "u", "w" : "u", "%w": "u", "W" : "W", "%V": "W" }; var normalizer = { substitutes: function (m) { return normalizerSubstitutions[m]; }, interpreted: function (m, x) { var y; switch (m) { case "%u": return x.getDay() + 1; case "z": return x.getOrdinalNumber(); case "%j": return p(x.getOrdinalNumber(), 3); case "%U": var d1 = x.clone().set({month: 0, day: 1}).addDays(-1).moveToDayOfWeek(0), d2 = x.clone().addDays(1).moveToDayOfWeek(0, -1); return (d2 < d1) ? "00" : p((d2.getOrdinalNumber() - d1.getOrdinalNumber()) / 7 + 1); case "%W": return p(x.getWeek()); case "t": return $D.getDaysInMonth(x.getFullYear(), x.getMonth()); case "o": case "%G": return x.setWeek(x.getISOWeek()).toString("yyyy"); case "%g": return x._format("%G").slice(-2); case "a": case "%p": return t("tt").toLowerCase(); case "A": return t("tt").toUpperCase(); case "u": return p(x.getMilliseconds(), 3); case "I": return (x.isDaylightSavingTime()) ? 1 : 0; case "O": return x.getUTCOffset(); case "P": y = x.getUTCOffset(); return y.substring(0, y.length - 2) + ":" + y.substring(y.length - 2); case "B": var now = new Date(); return Math.floor(((now.getHours() * 3600) + (now.getMinutes() * 60) + now.getSeconds() + (now.getTimezoneOffset() + 60) * 60) / 86.4); case "c": return x.toISOString().replace(/\"/g, ""); case "U": return $D.strtotime("now"); case "%c": return t("d") + " " + t("t"); case "%C": return Math.floor(x.getFullYear() / 100 + 1); } }, shouldOverrideDefaults: function (m) { switch (m) { case "%e": return true; default: return false; } }, parse: function (m, context) { var formatString, c = context || new Date(); formatString = normalizer.substitutes(m); if (formatString) { return formatString; } formatString = normalizer.interpreted(m, c); if (formatString) { return formatString; } else { return m; } } }; $D.normalizeFormat = function (format, context) { return format.replace(/(%|\\)?.|%%/g, function(t){ return normalizer.parse(t, context); }); }; /** * Format a local Unix timestamp according to locale settings * * Example: * Date.strftime("%m/%d/%y", new Date()); // "04/13/08" * Date.strftime("c", "2008-04-13T17:52:03Z"); // "04/13/08" * * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @param {Number|String} The number representing the number of seconds that have elapsed since January 1, 1970 (local time). * @return {String} A string representation of the current Date object. */ $D.strftime = function (format, time) { var d = Date.parse(time); return d._format(format); }; /** * Parse any textual datetime description into a Unix timestamp. * A Unix timestamp is the number of seconds that have elapsed since January 1, 1970 (midnight UTC/GMT). * * Example: * Date.strtotime("04/13/08"); // 1208044800 * Date.strtotime("1970-01-01T00:00:00Z"); // 0 * * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @param {Object} A string or date object. * @return {String} A string representation of the current Date object. */ $D.strtotime = function (time) { var d = $D.parse(time); return Math.round($D.UTC(d.getUTCFullYear(), d.getUTCMonth(), d.getUTCDate(), d.getUTCHours(), d.getUTCMinutes(), d.getUTCSeconds(), d.getUTCMilliseconds()) / 1000); }; /** * Converts the value of the current Date object to its equivalent string representation using a PHP/Unix style of date format specifiers. * Format Specifiers * Format Description Example * ------ --------------------------------------------------------------------------- ----------------------- * %a abbreviated weekday name according to the current localed "Mon" through "Sun" * %A full weekday name according to the current localed "Sunday" through "Saturday" * %b abbreviated month name according to the current localed "Jan" through "Dec" * %B full month name according to the current locale "January" through "December" * %c preferred date and time representation for the current locale "4/13/2008 12:33 PM" * %C century number (the year divided by 100 and truncated to an integer) "00" to "99" * %d day of the month as a decimal number "01" to "31" * %D same as %m/%d/%y "04/13/08" * %e day of the month as a decimal number, a single digit is preceded by a space "1" to "31" * %g like %G, but without the century "08" * %G The 4-digit year corresponding to the ISO week number (see %V). "2008" * This has the same format and value as %Y, except that if the ISO week number * belongs to the previous or next year, that year is used instead. * %h same as %b "Jan" through "Dec" * %H hour as a decimal number using a 24-hour clock. "00" to "23" * %I hour as a decimal number using a 12-hour clock. "01" to "12" * %j day of the year as a decimal number. "001" to "366" * %m month as a decimal number. "01" to "12" * %M minute as a decimal number. "00" to "59" * %n newline character "\n" * %p either "am" or "pm" according to the given time value, or the "am" or "pm" * corresponding strings for the current locale. * %r time in a.m. and p.m. notation "8:44 PM" * %R time in 24 hour notation "20:44" * %S second as a decimal number "00" to "59" * %t tab character "\t" * %T current time, equal to %H:%M:%S "12:49:11" * %u weekday as a decimal number ["1", "7"], with "1" representing Monday "1" to "7" * %U week number of the current year as a decimal number, starting with the "0" to ("52" or "53") * first Sunday as the first day of the first week * %V The ISO 8601:1988 week number of the current year as a decimal number, "00" to ("52" or "53") * range 01 to 53, where week 1 is the first week that has at least 4 days * in the current year, and with Monday as the first day of the week. * (Use %G or %g for the year component that corresponds to the week number * for the specified timestamp.) * %W week number of the current year as a decimal number, starting with the "00" to ("52" or "53") * first Monday as the first day of the first week * %w day of the week as a decimal, Sunday being "0" "0" to "6" * %x preferred date representation for the current locale without the time "4/13/2008" * %X preferred time representation for the current locale without the date "12:53:05" * %y year as a decimal number without a century "00" "99" * %Y year as a decimal number including the century "2008" * %Z time zone or name or abbreviation "UTC", "EST", "PST" * %z same as %Z * %% a literal "%" characters "%" * d Day of the month, 2 digits with leading zeros "01" to "31" * D A textual representation of a day, three letters "Mon" through "Sun" * j Day of the month without leading zeros "1" to "31" * l A full textual representation of the day of the week (lowercase "L") "Sunday" through "Saturday" * N ISO-8601 numeric representation of the day of the week (added in PHP 5.1.0) "1" (for Monday) through "7" (for Sunday) * S English ordinal suffix for the day of the month, 2 characters "st", "nd", "rd" or "th". Works well with j * w Numeric representation of the day of the week "0" (for Sunday) through "6" (for Saturday) * z The day of the year (starting from "0") "0" through "365" * W ISO-8601 week number of year, weeks starting on Monday "00" to ("52" or "53") * F A full textual representation of a month, such as January or March "January" through "December" * m Numeric representation of a month, with leading zeros "01" through "12" * M A short textual representation of a month, three letters "Jan" through "Dec" * n Numeric representation of a month, without leading zeros "1" through "12" * t Number of days in the given month "28" through "31" * L Whether it's a leap year "1" if it is a leap year, "0" otherwise * o ISO-8601 year number. This has the same value as Y, except that if the "2008" * ISO week number (W) belongs to the previous or next year, that year * is used instead. * Y A full numeric representation of a year, 4 digits "2008" * y A two digit representation of a year "08" * a Lowercase Ante meridiem and Post meridiem "am" or "pm" * A Uppercase Ante meridiem and Post meridiem "AM" or "PM" * B Swatch Internet time "000" through "999" * g 12-hour format of an hour without leading zeros "1" through "12" * G 24-hour format of an hour without leading zeros "0" through "23" * h 12-hour format of an hour with leading zeros "01" through "12" * H 24-hour format of an hour with leading zeros "00" through "23" * i Minutes with leading zeros "00" to "59" * s Seconds, with leading zeros "00" through "59" * u Milliseconds "54321" * e Timezone identifier "UTC", "EST", "PST" * I Whether or not the date is in daylight saving time (uppercase i) "1" if Daylight Saving Time, "0" otherwise * O Difference to Greenwich time (GMT) in hours "+0200", "-0600" * P Difference to Greenwich time (GMT) with colon between hours and minutes "+02:00", "-06:00" * T Timezone abbreviation "UTC", "EST", "PST" * Z Timezone offset in seconds. The offset for timezones west of UTC is "-43200" through "50400" * always negative, and for those east of UTC is always positive. * c ISO 8601 date "2004-02-12T15:19:21+00:00" * r RFC 2822 formatted date "Thu, 21 Dec 2000 16:01:07 +0200" * U Seconds since the Unix Epoch (January 1 1970 00:00:00 GMT) "0" * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @return {String} A string representation of the current Date object. */ var formatReplace = function (context) { return function (m) { var formatString, override = false; if (m.charAt(0) === "\\" || m.substring(0, 2) === "%%") { return m.replace("\\", "").replace("%%", "%"); } override = normalizer.shouldOverrideDefaults(m); formatString = $D.normalizeFormat(m, context); if (formatString) { return context.toString(formatString, override); } }; }; $P._format = function (format) { var formatter = formatReplace(this); if (!format) { return this._toString(); } else { return format.replace(/(%|\\)?.|%%/g, formatter); } }; if (!$P.format) { $P.format = $P._format; } }()); (function () { "use strict"; var gFn = function (attr) { return function () { return this[attr]; }; }; var sFn = function (attr) { return function (val) { this[attr] = val; return this; }; }; var attrs = ["years", "months", "days", "hours", "minutes", "seconds", "milliseconds"]; var addSetFuncs = function (context, attrs) { for (var i = 0; i < attrs.length ; i++) { var $a = attrs[i], $b = $a.slice(0, 1).toUpperCase() + $a.slice(1); context.prototype[$a] = 0; context.prototype["get" + $b] = gFn($a); context.prototype["set" + $b] = sFn($a); } }; /** * new TimeSpan(milliseconds); * new TimeSpan(days, hours, minutes, seconds); * new TimeSpan(days, hours, minutes, seconds, milliseconds); */ var TimeSpan = function (days, hours, minutes, seconds, milliseconds) { if (arguments.length === 1 && typeof days === "number") { var orient = (days < 0) ? -1 : +1; var millsLeft = Math.abs(days); this.setDays(Math.floor(millsLeft / 86400000) * orient); millsLeft = millsLeft % 86400000; this.setHours(Math.floor(millsLeft / 3600000) * orient); millsLeft = millsLeft % 3600000; this.setMinutes(Math.floor(millsLeft / 60000) * orient); millsLeft = millsLeft % 60000; this.setSeconds(Math.floor(millsLeft / 1000) * orient); millsLeft = millsLeft % 1000; this.setMilliseconds(millsLeft * orient); } else { this.set(days, hours, minutes, seconds, milliseconds); } this.getTotalMilliseconds = function () { return (this.getDays() * 86400000) + (this.getHours() * 3600000) + (this.getMinutes() * 60000) + (this.getSeconds() * 1000); }; this.compareTo = function (time) { var t1 = new Date(1970, 1, 1, this.getHours(), this.getMinutes(), this.getSeconds()), t2; if (time === null) { t2 = new Date(1970, 1, 1, 0, 0, 0); } else { t2 = new Date(1970, 1, 1, time.getHours(), time.getMinutes(), time.getSeconds()); } return (t1 < t2) ? -1 : (t1 > t2) ? 1 : 0; }; this.equals = function (time) { return (this.compareTo(time) === 0); }; this.add = function (time) { return (time === null) ? this : this.addSeconds(time.getTotalMilliseconds() / 1000); }; this.subtract = function (time) { return (time === null) ? this : this.addSeconds(-time.getTotalMilliseconds() / 1000); }; this.addDays = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 86400000)); }; this.addHours = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 3600000)); }; this.addMinutes = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 60000)); }; this.addSeconds = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 1000)); }; this.addMilliseconds = function (n) { return new TimeSpan(this.getTotalMilliseconds() + n); }; this.get12HourHour = function () { return (this.getHours() > 12) ? this.getHours() - 12 : (this.getHours() === 0) ? 12 : this.getHours(); }; this.getDesignator = function () { return (this.getHours() < 12) ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator; }; this.toString = function (format) { this._toString = function () { if (this.getDays() !== null && this.getDays() > 0) { return this.getDays() + "." + this.getHours() + ":" + this.p(this.getMinutes()) + ":" + this.p(this.getSeconds()); } else { return this.getHours() + ":" + this.p(this.getMinutes()) + ":" + this.p(this.getSeconds()); } }; this.p = function (s) { return (s.toString().length < 2) ? "0" + s : s; }; var me = this; return format ? format.replace(/dd?|HH?|hh?|mm?|ss?|tt?/g, function (format) { switch (format) { case "d": return me.getDays(); case "dd": return me.p(me.getDays()); case "H": return me.getHours(); case "HH": return me.p(me.getHours()); case "h": return me.get12HourHour(); case "hh": return me.p(me.get12HourHour()); case "m": return me.getMinutes(); case "mm": return me.p(me.getMinutes()); case "s": return me.getSeconds(); case "ss": return me.p(me.getSeconds()); case "t": return ((me.getHours() < 12) ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator).substring(0, 1); case "tt": return (me.getHours() < 12) ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator; } } ) : this._toString(); }; return this; }; addSetFuncs(TimeSpan, attrs.slice(2)); TimeSpan.prototype.set = function (days, hours, minutes, seconds, milliseconds){ this.setDays(days || this.getDays()); this.setHours(hours || this.getHours()); this.setMinutes(minutes || this.getMinutes()); this.setSeconds(seconds || this.getSeconds()); this.setMilliseconds(milliseconds || this.getMilliseconds()); }; /** * Gets the time of day for this date instances. * @return {TimeSpan} TimeSpan */ Date.prototype.getTimeOfDay = function () { return new TimeSpan(0, this.getHours(), this.getMinutes(), this.getSeconds(), this.getMilliseconds()); }; Date.TimeSpan = TimeSpan; if (typeof window !== "undefined" ) { // keeping API compatible for v1.x window.TimeSpan = TimeSpan; } }()); (function () { "use strict"; var attrs = ["years", "months", "days", "hours", "minutes", "seconds", "milliseconds"]; var gFn = function (attr) { return function () { return this[attr]; }; }; var sFn = function (attr) { return function (val) { this[attr] = val; return this; }; }; var addSetFuncs = function (context, attrs) { for (var i = 0; i < attrs.length ; i++) { var $a = attrs[i], $b = $a.slice(0, 1).toUpperCase() + $a.slice(1); context.prototype[$a] = 0; context.prototype["get" + $b] = gFn($a); context.prototype["set" + $b] = sFn($a); } }; var setMonthsAndYears = function (orient, d1, d2, context) { function inc() { d1.addMonths(-orient); context.months++; if (context.months === 12) { context.years++; context.months = 0; } } if (orient === +1) { while (d1 > d2) { inc(); } } else { while (d1 < d2) { inc(); } } context.months--; context.months *= orient; context.years *= orient; }; var adjustForDST = function(orient, startDate, endDate) { var hasDSTMismatch = (false === (startDate.isDaylightSavingTime() === endDate.isDaylightSavingTime())); if (hasDSTMismatch && orient === 1) { startDate.addHours(-1); } else if (hasDSTMismatch) { startDate.addHours(1); } }; /** * TimePeriod(startDate, endDate); * TimePeriod(years, months, days, hours, minutes, seconds, milliseconds); */ var TimePeriod = function (years, months, days, hours, minutes, seconds, milliseconds) { if (arguments.length === 7) { this.set(years, months, days, hours, minutes, seconds, milliseconds); } else if (arguments.length === 2 && arguments[0] instanceof Date && arguments[1] instanceof Date) { var startDate = arguments[0].clone(); var endDate = arguments[1].clone(); var orient = (startDate > endDate) ? +1 : -1; this.dates = { start: arguments[0].clone(), end: arguments[1].clone() }; setMonthsAndYears(orient, startDate, endDate, this); adjustForDST(orient, startDate, endDate); // // TODO - adjust for DST var diff = endDate - startDate; if (diff !== 0) { var ts = new TimeSpan(diff); this.set(this.years, this.months, ts.getDays(), ts.getHours(), ts.getMinutes(), ts.getSeconds(), ts.getMilliseconds()); } } return this; }; // create all the set functions. addSetFuncs(TimePeriod, attrs); TimePeriod.prototype.set = function (years, months, days, hours, minutes, seconds, milliseconds){ this.setYears(years || this.getYears()); this.setMonths(months || this.getMonths()); this.setDays(days || this.getDays()); this.setHours(hours || this.getHours()); this.setMinutes(minutes || this.getMinutes()); this.setSeconds(seconds || this.getSeconds()); this.setMilliseconds(milliseconds || this.getMilliseconds()); }; Date.TimePeriod = TimePeriod; if (typeof window !== "undefined") { // keeping API compatible for v1.x window.TimePeriod = TimePeriod; } }()); ================================================ FILE: build/date-zu-ZA.js ================================================ /** * @overview datejs * @version 1.0.0-rc3 * @author Gregory Wild-Smith * @copyright 2015 Gregory Wild-Smith * @license MIT * @homepage https://github.com/abritinthebay/datejs */ /* * DateJS Culture String File * Country Code: zu-ZA * Name: Zulu (South Africa) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["zu-ZA"] = { "name": "zu-ZA", "englishName": "Zulu (South Africa)", "nativeName": "isiZulu (iNingizimu Afrika)", "Sunday": "iSonto", "Monday": "uMsombuluko", "Tuesday": "uLwesibili", "Wednesday": "uLwesithathu", "Thursday": "uLwesine", "Friday": "uLwesihlanu", "Saturday": "uMgqibelo", "Sun": "Sun", "Mon": "Mon", "Tue": "Tue", "Wed": "Wed", "Thu": "Thu", "Fri": "Fri", "Sat": "Sat", "Su": "Sun", "Mo": "Mon", "Tu": "Tue", "We": "Wed", "Th": "Thu", "Fr": "Fri", "Sa": "Sat", "S_Sun_Initial": "S", "M_Mon_Initial": "M", "T_Tue_Initial": "T", "W_Wed_Initial": "W", "T_Thu_Initial": "T", "F_Fri_Initial": "F", "S_Sat_Initial": "S", "January": "uJanuwari", "February": "uFebuwari", "March": "uMashi", "April": "uAprhili", "May": "uMeyi", "June": "uJuni", "July": "uJulayi", "August": "uAgaste", "September": "uSepthemba", "October": "uOkthoba", "November": "uNovemba", "December": "uDisemba", "Jan_Abbr": "Jan", "Feb_Abbr": "Feb", "Mar_Abbr": "Mar", "Apr_Abbr": "Apr", "May_Abbr": "May", "Jun_Abbr": "Jun", "Jul_Abbr": "Jul", "Aug_Abbr": "Aug", "Sep_Abbr": "Sep", "Oct_Abbr": "Oct", "Nov_Abbr": "Nov", "Dec_Abbr": "Dec", "AM": "AM", "PM": "PM", "firstDayOfWeek": 0, "twoDigitYearMax": 2029, "mdy": "ymd", "M/d/yyyy": "yyyy/MM/dd", "dddd, MMMM dd, yyyy": "dd MMMM yyyy", "h:mm tt": "hh:mm:ss tt", "h:mm:ss tt": "hh:mm:ss tt", "dddd, MMMM dd, yyyy h:mm:ss tt": "dd MMMM yyyy hh:mm:ss tt", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "MMMM dd", "MMMM, yyyy": "MMMM yyyy", "/jan(uary)?/": "ujanuwari", "/feb(ruary)?/": "ufebuwari", "/mar(ch)?/": "umashi", "/apr(il)?/": "uaprhili", "/may/": "umeyi", "/jun(e)?/": "ujuni", "/jul(y)?/": "ujulayi", "/aug(ust)?/": "uagaste", "/sep(t(ember)?)?/": "usepthemba", "/oct(ober)?/": "uokthoba", "/nov(ember)?/": "unovemba", "/dec(ember)?/": "udisemba", "/^su(n(day)?)?/": "^isonto", "/^mo(n(day)?)?/": "^umsombuluko", "/^tu(e(s(day)?)?)?/": "^ulwesibili", "/^we(d(nesday)?)?/": "^ulwesithathu", "/^th(u(r(s(day)?)?)?)?/": "^ulwesine", "/^fr(i(day)?)?/": "^ulwesihlanu", "/^sa(t(urday)?)?/": "^umgqibelo", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "zu-ZA"; /** * @overview datejs * @version 1.0.0-rc3 * @author Gregory Wild-Smith * @copyright 2015 Gregory Wild-Smith * @license MIT * @homepage https://github.com/abritinthebay/datejs */(function () { var $D = Date; var lang = Date.CultureStrings ? Date.CultureStrings.lang : null; var loggedKeys = {}; // for debug purposes. var getText = { getFromKey: function (key, countryCode) { var output; if (Date.CultureStrings && Date.CultureStrings[countryCode] && Date.CultureStrings[countryCode][key]) { output = Date.CultureStrings[countryCode][key]; } else { output = getText.buildFromDefault(key); } if (key.charAt(0) === "/") { // Assume it's a regex output = getText.buildFromRegex(key, countryCode); } return output; }, getFromObjectValues: function (obj, countryCode) { var key, output = {}; for(key in obj) { if (obj.hasOwnProperty(key)) { output[key] = getText.getFromKey(obj[key], countryCode); } } return output; }, getFromObjectKeys: function (obj, countryCode) { var key, output = {}; for(key in obj) { if (obj.hasOwnProperty(key)) { output[getText.getFromKey(key, countryCode)] = obj[key]; } } return output; }, getFromArray: function (arr, countryCode) { var output = []; for (var i=0; i < arr.length; i++){ if (i in arr) { output[i] = getText.getFromKey(arr[i], countryCode); } } return output; }, buildFromDefault: function (key) { var output, length, split, last; switch(key) { case "name": output = "en-US"; break; case "englishName": output = "English (United States)"; break; case "nativeName": output = "English (United States)"; break; case "twoDigitYearMax": output = 2049; break; case "firstDayOfWeek": output = 0; break; default: output = key; split = key.split("_"); length = split.length; if (length > 1 && key.charAt(0) !== "/") { // if the key isn't a regex and it has a split. last = split[(length - 1)].toLowerCase(); if (last === "initial" || last === "abbr") { output = split[0]; } } break; } return output; }, buildFromRegex: function (key, countryCode) { var output; if (Date.CultureStrings && Date.CultureStrings[countryCode] && Date.CultureStrings[countryCode][key]) { output = new RegExp(Date.CultureStrings[countryCode][key], "i"); } else { output = new RegExp(key.replace(new RegExp("/", "g"),""), "i"); } return output; } }; var shallowMerge = function (obj1, obj2) { for (var attrname in obj2) { if (obj2.hasOwnProperty(attrname)) { obj1[attrname] = obj2[attrname]; } } }; var __ = function (key, language) { var countryCode = (language) ? language : lang; loggedKeys[key] = key; if (typeof key === "object") { if (key instanceof Array) { return getText.getFromArray(key, countryCode); } else { return getText.getFromObjectKeys(key, countryCode); } } else { return getText.getFromKey(key, countryCode); } }; var loadI18nScript = function (code) { // paatterned after jQuery's getScript. var url = Date.Config.i18n + code + ".js"; var head = document.getElementsByTagName("head")[0] || document.documentElement; var script = document.createElement("script"); script.src = url; var completed = false; var events = { done: function (){} // placeholder function }; // Attach handlers for all browsers script.onload = script.onreadystatechange = function() { if ( !completed && (!this.readyState || this.readyState === "loaded" || this.readyState === "complete") ) { events.done(); head.removeChild(script); } }; setTimeout(function() { head.insertBefore(script, head.firstChild); }, 0); // allows return to execute first return { done: function (cb) { events.done = function() { if (cb) { setTimeout(cb,0); } }; } }; }; var buildInfo = { buildFromMethodHash: function (obj) { var key; for(key in obj) { if (obj.hasOwnProperty(key)) { obj[key] = buildInfo[obj[key]](); } } return obj; }, timeZoneDST: function () { var DST = { "CHADT": "+1345", "NZDT": "+1300", "AEDT": "+1100", "ACDT": "+1030", "AZST": "+0500", "IRDT": "+0430", "EEST": "+0300", "CEST": "+0200", "BST": "+0100", "PMDT": "-0200", "ADT": "-0300", "NDT": "-0230", "EDT": "-0400", "CDT": "-0500", "MDT": "-0600", "PDT": "-0700", "AKDT": "-0800", "HADT": "-0900" }; return __(DST); }, timeZoneStandard: function () { var standard = { "LINT": "+1400", "TOT": "+1300", "CHAST": "+1245", "NZST": "+1200", "NFT": "+1130", "SBT": "+1100", "AEST": "+1000", "ACST": "+0930", "JST": "+0900", "CWST": "+0845", "CT": "+0800", "ICT": "+0700", "MMT": "+0630", "BST": "+0600", "NPT": "+0545", "IST": "+0530", "PKT": "+0500", "AFT": "+0430", "MSK": "+0400", "IRST": "+0330", "FET": "+0300", "EET": "+0200", "CET": "+0100", "GMT": "+0000", "UTC": "+0000", "CVT": "-0100", "GST": "-0200", "BRT": "-0300", "NST": "-0330", "AST": "-0400", "EST": "-0500", "CST": "-0600", "MST": "-0700", "PST": "-0800", "AKST": "-0900", "MIT": "-0930", "HST": "-1000", "SST": "-1100", "BIT": "-1200" }; return __(standard); }, timeZones: function (data) { var zone; data.timezones = []; for (zone in data.abbreviatedTimeZoneStandard) { if (data.abbreviatedTimeZoneStandard.hasOwnProperty(zone)) { data.timezones.push({ name: zone, offset: data.abbreviatedTimeZoneStandard[zone]}); } } for (zone in data.abbreviatedTimeZoneDST) { if (data.abbreviatedTimeZoneDST.hasOwnProperty(zone)) { data.timezones.push({ name: zone, offset: data.abbreviatedTimeZoneDST[zone], dst: true}); } } return data.timezones; }, days: function () { return __(["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"]); }, dayAbbr: function () { return __(["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"]); }, dayShortNames: function () { return __(["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"]); }, dayFirstLetters: function () { return __(["S_Sun_Initial", "M_Mon_Initial", "T_Tues_Initial", "W_Wed_Initial", "T_Thu_Initial", "F_Fri_Initial", "S_Sat_Initial"]); }, months: function () { return __(["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"]); }, monthAbbr: function () { return __(["Jan_Abbr", "Feb_Abbr", "Mar_Abbr", "Apr_Abbr", "May_Abbr", "Jun_Abbr", "Jul_Abbr", "Aug_Abbr", "Sep_Abbr", "Oct_Abbr", "Nov_Abbr", "Dec_Abbr"]); }, formatPatterns: function () { return getText.getFromObjectValues({ shortDate: "M/d/yyyy", longDate: "dddd, MMMM dd, yyyy", shortTime: "h:mm tt", longTime: "h:mm:ss tt", fullDateTime: "dddd, MMMM dd, yyyy h:mm:ss tt", sortableDateTime: "yyyy-MM-ddTHH:mm:ss", universalSortableDateTime: "yyyy-MM-dd HH:mm:ssZ", rfc1123: "ddd, dd MMM yyyy HH:mm:ss", monthDay: "MMMM dd", yearMonth: "MMMM, yyyy" }, Date.i18n.currentLanguage()); }, regex: function () { return getText.getFromObjectValues({ inTheMorning: "/( in the )(morn(ing)?)\\b/", thisMorning: "/(this )(morn(ing)?)\\b/", amThisMorning: "/(\b\\d(am)? )(this )(morn(ing)?)/", inTheEvening: "/( in the )(even(ing)?)\\b/", thisEvening: "/(this )(even(ing)?)\\b/", pmThisEvening: "/(\b\\d(pm)? )(this )(even(ing)?)/", jan: "/jan(uary)?/", feb: "/feb(ruary)?/", mar: "/mar(ch)?/", apr: "/apr(il)?/", may: "/may/", jun: "/jun(e)?/", jul: "/jul(y)?/", aug: "/aug(ust)?/", sep: "/sep(t(ember)?)?/", oct: "/oct(ober)?/", nov: "/nov(ember)?/", dec: "/dec(ember)?/", sun: "/^su(n(day)?)?/", mon: "/^mo(n(day)?)?/", tue: "/^tu(e(s(day)?)?)?/", wed: "/^we(d(nesday)?)?/", thu: "/^th(u(r(s(day)?)?)?)?/", fri: "/fr(i(day)?)?/", sat: "/^sa(t(urday)?)?/", future: "/^next/", past: "/^last|past|prev(ious)?/", add: "/^(\\+|aft(er)?|from|hence)/", subtract: "/^(\\-|bef(ore)?|ago)/", yesterday: "/^yes(terday)?/", today: "/^t(od(ay)?)?/", tomorrow: "/^tom(orrow)?/", now: "/^n(ow)?/", millisecond: "/^ms|milli(second)?s?/", second: "/^sec(ond)?s?/", minute: "/^mn|min(ute)?s?/", hour: "/^h(our)?s?/", week: "/^w(eek)?s?/", month: "/^m(onth)?s?/", day: "/^d(ay)?s?/", year: "/^y(ear)?s?/", shortMeridian: "/^(a|p)/", longMeridian: "/^(a\\.?m?\\.?|p\\.?m?\\.?)/", timezone: "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/", ordinalSuffix: "/^\\s*(st|nd|rd|th)/", timeContext: "/^\\s*(\\:|a(?!u|p)|p)/" }, Date.i18n.currentLanguage()); } }; var CultureInfo = function () { var info = getText.getFromObjectValues({ name: "name", englishName: "englishName", nativeName: "nativeName", amDesignator: "AM", pmDesignator: "PM", firstDayOfWeek: "firstDayOfWeek", twoDigitYearMax: "twoDigitYearMax", dateElementOrder: "mdy" }, Date.i18n.currentLanguage()); var constructedInfo = buildInfo.buildFromMethodHash({ dayNames: "days", abbreviatedDayNames: "dayAbbr", shortestDayNames: "dayShortNames", firstLetterDayNames: "dayFirstLetters", monthNames: "months", abbreviatedMonthNames: "monthAbbr", formatPatterns: "formatPatterns", regexPatterns: "regex", abbreviatedTimeZoneDST: "timeZoneDST", abbreviatedTimeZoneStandard: "timeZoneStandard" }); shallowMerge(info, constructedInfo); buildInfo.timeZones(info); return info; }; $D.i18n = { __: function (key, lang) { return __(key, lang); }, currentLanguage: function () { return lang || "en-US"; }, setLanguage: function (code, force, cb) { var async = false; if (force || code === "en-US" || (!!Date.CultureStrings && !!Date.CultureStrings[code])) { lang = code; Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings.lang = code; Date.CultureInfo = new CultureInfo(); } else { if (!(!!Date.CultureStrings && !!Date.CultureStrings[code])) { if (typeof exports !== "undefined" && this.exports !== exports) { // we're in a Node enviroment, load it using require try { require("../i18n/" + code + ".js"); lang = code; Date.CultureStrings.lang = code; Date.CultureInfo = new CultureInfo(); } catch (e) { // var str = "The language for '" + code + "' could not be loaded by Node. It likely does not exist."; throw new Error("The DateJS IETF language tag '" + code + "' could not be loaded by Node. It likely does not exist."); } } else if (Date.Config && Date.Config.i18n) { // we know the location of the files, so lets load them async = true; loadI18nScript(code).done(function(){ lang = code; Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings.lang = code; Date.CultureInfo = new CultureInfo(); $D.Parsing.Normalizer.buildReplaceData(); // because this is async if ($D.Grammar) { $D.Grammar.buildGrammarFormats(); // so we can parse those strings... } if (cb) { setTimeout(cb,0); } }); } else { Date.console.error("The DateJS IETF language tag '" + code + "' is not available and has not been loaded."); return false; } } } $D.Parsing.Normalizer.buildReplaceData(); // rebuild normalizer strings if ($D.Grammar) { $D.Grammar.buildGrammarFormats(); // so we can parse those strings... } if (!async && cb) { setTimeout(cb,0); } }, getLoggedKeys: function () { return loggedKeys; }, updateCultureInfo: function () { Date.CultureInfo = new CultureInfo(); } }; $D.i18n.updateCultureInfo(); // run automatically }()); (function () { var $D = Date, $P = $D.prototype, p = function (s, l) { if (!l) { l = 2; } return ("000" + s).slice(l * -1); }; if (typeof window !== "undefined" && typeof window.console !== "undefined" && typeof window.console.log !== "undefined") { $D.console = console; // used only to raise non-critical errors if available } else { // set mock so we don't give errors. $D.console = { log: function(){}, error: function(){} }; } $D.Config = $D.Config || {}; $D.initOverloads = function() { /** * Overload of Date.now. Allows an alternate call for Date.now where it returns the * current Date as an object rather than just milliseconds since the Unix Epoch. * * Also provides an implementation of now() for browsers (IE<9) that don't have it. * * Backwards compatible so with work with either: * Date.now() [returns ms] * or * Date.now(true) [returns Date] */ if (!$D.now) { $D._now = function now() { return new Date().getTime(); }; } else if (!$D._now) { $D._now = $D.now; } $D.now = function (returnObj) { if (returnObj) { return $D.present(); } else { return $D._now(); } }; if ( !$P.toISOString ) { $P.toISOString = function() { return this.getUTCFullYear() + "-" + p(this.getUTCMonth() + 1) + "-" + p(this.getUTCDate()) + "T" + p(this.getUTCHours()) + ":" + p(this.getUTCMinutes()) + ":" + p(this.getUTCSeconds()) + "." + String( (this.getUTCMilliseconds()/1000).toFixed(3)).slice(2, 5) + "Z"; }; } // private if ( $P._toString === undefined ){ $P._toString = $P.toString; } }; $D.initOverloads(); /** * Gets a date that is set to the current date. The time is set to the start of the day (00:00 or 12:00 AM). * @return {Date} The current date. */ $D.today = function () { return new Date().clearTime(); }; /** * Gets a date that is set to the current date and time (same as new Date, but chainable) * @return {Date} The current date. */ $D.present = function () { return new Date(); }; /** * Compares the first date to the second date and returns an number indication of their relative values. * @param {Date} First Date object to compare [Required]. * @param {Date} Second Date object to compare to [Required]. * @return {Number} -1 = date1 is lessthan date2. 0 = values are equal. 1 = date1 is greaterthan date2. */ $D.compare = function (date1, date2) { if (isNaN(date1) || isNaN(date2)) { throw new Error(date1 + " - " + date2); } else if (date1 instanceof Date && date2 instanceof Date) { return (date1 < date2) ? -1 : (date1 > date2) ? 1 : 0; } else { throw new TypeError(date1 + " - " + date2); } }; /** * Compares the first Date object to the second Date object and returns true if they are equal. * @param {Date} First Date object to compare [Required] * @param {Date} Second Date object to compare to [Required] * @return {Boolean} true if dates are equal. false if they are not equal. */ $D.equals = function (date1, date2) { return (date1.compareTo(date2) === 0); }; /** * Gets the language appropriate day name when given the day number(0-6) * eg - 0 == Sunday * @return {String} The day name */ $D.getDayName = function (n) { return Date.CultureInfo.dayNames[n]; }; /** * Gets the day number (0-6) if given a CultureInfo specific string which is a valid dayName, abbreviatedDayName or shortestDayName (two char). * @param {String} The name of the day (eg. "Monday, "Mon", "tuesday", "tue", "We", "we"). * @return {Number} The day number */ $D.getDayNumberFromName = function (name) { var n = Date.CultureInfo.dayNames, m = Date.CultureInfo.abbreviatedDayNames, o = Date.CultureInfo.shortestDayNames, s = name.toLowerCase(); for (var i = 0; i < n.length; i++) { if (n[i].toLowerCase() === s || m[i].toLowerCase() === s || o[i].toLowerCase() === s) { return i; } } return -1; }; /** * Gets the month number (0-11) if given a Culture Info specific string which is a valid monthName or abbreviatedMonthName. * @param {String} The name of the month (eg. "February, "Feb", "october", "oct"). * @return {Number} The day number */ $D.getMonthNumberFromName = function (name) { var n = Date.CultureInfo.monthNames, m = Date.CultureInfo.abbreviatedMonthNames, s = name.toLowerCase(); for (var i = 0; i < n.length; i++) { if (n[i].toLowerCase() === s || m[i].toLowerCase() === s) { return i; } } return -1; }; /** * Gets the language appropriate month name when given the month number(0-11) * eg - 0 == January * @return {String} The month name */ $D.getMonthName = function (n) { return Date.CultureInfo.monthNames[n]; }; /** * Determines if the current date instance is within a LeapYear. * @param {Number} The year. * @return {Boolean} true if date is within a LeapYear, otherwise false. */ $D.isLeapYear = function (year) { return ((year % 4 === 0 && year % 100 !== 0) || year % 400 === 0); }; /** * Gets the number of days in the month, given a year and month value. Automatically corrects for LeapYear. * @param {Number} The year. * @param {Number} The month (0-11). * @return {Number} The number of days in the month. */ $D.getDaysInMonth = function (year, month) { if (!month && $D.validateMonth(year)) { month = year; year = Date.today().getFullYear(); } return [31, ($D.isLeapYear(year) ? 29 : 28), 31, 30, 31, 30, 31, 31, 30, 31, 30, 31][month]; }; $P.getDaysInMonth = function () { return $D.getDaysInMonth(this.getFullYear(), this.getMonth()); }; $D.getTimezoneAbbreviation = function (offset, dst) { var p, n = (dst || false) ? Date.CultureInfo.abbreviatedTimeZoneDST : Date.CultureInfo.abbreviatedTimeZoneStandard; for (p in n) { if (n.hasOwnProperty(p)) { if (n[p] === offset) { return p; } } } return null; }; $D.getTimezoneOffset = function (name, dst) { var i, a =[], z = Date.CultureInfo.timezones; if (!name) { name = (new Date()).getTimezone();} for (i = 0; i < z.length; i++) { if (z[i].name === name.toUpperCase()) { a.push(i); } } if (!z[a[0]]) { return null; } if (a.length === 1 || !dst) { return z[a[0]].offset; } else { for (i=0; i < a.length; i++) { if (z[a[i]].dst) { return z[a[i]].offset; } } } }; $D.getQuarter = function (d) { d = d || new Date(); // If no date supplied, use today var q = [1,2,3,4]; return q[Math.floor(d.getMonth() / 3)]; // ~~~ is a bitwise op. Faster than Math.floor }; $D.getDaysLeftInQuarter = function (d) { d = d || new Date(); var qEnd = new Date(d); qEnd.setMonth(qEnd.getMonth() + 3 - qEnd.getMonth() % 3, 0); return Math.floor((qEnd - d) / 8.64e7); }; // private var validate = function (n, min, max, name) { name = name ? name : "Object"; if (typeof n === "undefined") { return false; } else if (typeof n !== "number") { throw new TypeError(n + " is not a Number."); } else if (n < min || n > max) { // As failing validation is *not* an exceptional circumstance // lets not throw a RangeError Exception here. // It's semantically correct but it's not sensible. return false; } return true; }; /** * Validates the number is within an acceptable range for milliseconds [0-999]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateMillisecond = function (value) { return validate(value, 0, 999, "millisecond"); }; /** * Validates the number is within an acceptable range for seconds [0-59]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateSecond = function (value) { return validate(value, 0, 59, "second"); }; /** * Validates the number is within an acceptable range for minutes [0-59]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateMinute = function (value) { return validate(value, 0, 59, "minute"); }; /** * Validates the number is within an acceptable range for hours [0-23]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateHour = function (value) { return validate(value, 0, 23, "hour"); }; /** * Validates the number is within an acceptable range for the days in a month [0-MaxDaysInMonth]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateDay = function (value, year, month) { if (year === undefined || year === null || month === undefined || month === null) { return false;} return validate(value, 1, $D.getDaysInMonth(year, month), "day"); }; /** * Validates the number is within an acceptable range for months [0-11]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateWeek = function (value) { return validate(value, 0, 53, "week"); }; /** * Validates the number is within an acceptable range for months [0-11]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateMonth = function (value) { return validate(value, 0, 11, "month"); }; /** * Validates the number is within an acceptable range for years. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateYear = function (value) { /** * Per ECMAScript spec the range of times supported by Date objects is * exactly -100,000,000 days to +100,000,000 days measured relative to * midnight at the beginning of 01 January, 1970 UTC. * This gives a range of 8,640,000,000,000,000 milliseconds to either * side of 01 January, 1970 UTC. * * Earliest possible date: Tue, 20 Apr 271,822 B.C. 00:00:00 UTC * Latest possible date: Sat, 13 Sep 275,760 00:00:00 UTC */ return validate(value, -271822, 275760, "year"); }; $D.validateTimezone = function(value) { var timezones = {"ACDT":1,"ACST":1,"ACT":1,"ADT":1,"AEDT":1,"AEST":1,"AFT":1,"AKDT":1,"AKST":1,"AMST":1,"AMT":1,"ART":1,"AST":1,"AWDT":1,"AWST":1,"AZOST":1,"AZT":1,"BDT":1,"BIOT":1,"BIT":1,"BOT":1,"BRT":1,"BST":1,"BTT":1,"CAT":1,"CCT":1,"CDT":1,"CEDT":1,"CEST":1,"CET":1,"CHADT":1,"CHAST":1,"CHOT":1,"ChST":1,"CHUT":1,"CIST":1,"CIT":1,"CKT":1,"CLST":1,"CLT":1,"COST":1,"COT":1,"CST":1,"CT":1,"CVT":1,"CWST":1,"CXT":1,"DAVT":1,"DDUT":1,"DFT":1,"EASST":1,"EAST":1,"EAT":1,"ECT":1,"EDT":1,"EEDT":1,"EEST":1,"EET":1,"EGST":1,"EGT":1,"EIT":1,"EST":1,"FET":1,"FJT":1,"FKST":1,"FKT":1,"FNT":1,"GALT":1,"GAMT":1,"GET":1,"GFT":1,"GILT":1,"GIT":1,"GMT":1,"GST":1,"GYT":1,"HADT":1,"HAEC":1,"HAST":1,"HKT":1,"HMT":1,"HOVT":1,"HST":1,"ICT":1,"IDT":1,"IOT":1,"IRDT":1,"IRKT":1,"IRST":1,"IST":1,"JST":1,"KGT":1,"KOST":1,"KRAT":1,"KST":1,"LHST":1,"LINT":1,"MAGT":1,"MART":1,"MAWT":1,"MDT":1,"MET":1,"MEST":1,"MHT":1,"MIST":1,"MIT":1,"MMT":1,"MSK":1,"MST":1,"MUT":1,"MVT":1,"MYT":1,"NCT":1,"NDT":1,"NFT":1,"NPT":1,"NST":1,"NT":1,"NUT":1,"NZDT":1,"NZST":1,"OMST":1,"ORAT":1,"PDT":1,"PET":1,"PETT":1,"PGT":1,"PHOT":1,"PHT":1,"PKT":1,"PMDT":1,"PMST":1,"PONT":1,"PST":1,"PYST":1,"PYT":1,"RET":1,"ROTT":1,"SAKT":1,"SAMT":1,"SAST":1,"SBT":1,"SCT":1,"SGT":1,"SLST":1,"SRT":1,"SST":1,"SYOT":1,"TAHT":1,"THA":1,"TFT":1,"TJT":1,"TKT":1,"TLT":1,"TMT":1,"TOT":1,"TVT":1,"UCT":1,"ULAT":1,"UTC":1,"UYST":1,"UYT":1,"UZT":1,"VET":1,"VLAT":1,"VOLT":1,"VOST":1,"VUT":1,"WAKT":1,"WAST":1,"WAT":1,"WEDT":1,"WEST":1,"WET":1,"WST":1,"YAKT":1,"YEKT":1,"Z":1}; return (timezones[value] === 1); }; $D.validateTimezoneOffset= function(value) { // timezones go from +14hrs to -12hrs, the +X hours are negative offsets. return (value > -841 && value < 721); }; }()); (function () { var $D = Date, $P = $D.prototype, p = function (s, l) { if (!l) { l = 2; } return ("000" + s).slice(l * -1); }; var validateConfigObject = function (obj) { var result = {}, self = this, prop, testFunc; testFunc = function (prop, func, value) { if (prop === "day") { var month = (obj.month !== undefined) ? obj.month : self.getMonth(); var year = (obj.year !== undefined) ? obj.year : self.getFullYear(); return $D[func](value, year, month); } else { return $D[func](value); } }; for (prop in obj) { if (Object.prototype.hasOwnProperty.call(obj, prop)) { var func = "validate" + prop.charAt(0).toUpperCase() + prop.slice(1); if ($D[func] && obj[prop] !== null && testFunc(prop, func, obj[prop])) { result[prop] = obj[prop]; } } } return result; }; /** * Resets the time of this Date object to 12:00 AM (00:00), which is the start of the day. * @param {Boolean} .clone() this date instance before clearing Time * @return {Date} this */ $P.clearTime = function () { this.setHours(0); this.setMinutes(0); this.setSeconds(0); this.setMilliseconds(0); return this; }; /** * Resets the time of this Date object to the current time ('now'). * @return {Date} this */ $P.setTimeToNow = function () { var n = new Date(); this.setHours(n.getHours()); this.setMinutes(n.getMinutes()); this.setSeconds(n.getSeconds()); this.setMilliseconds(n.getMilliseconds()); return this; }; /** * Returns a new Date object that is an exact date and time copy of the original instance. * @return {Date} A new Date instance */ $P.clone = function () { return new Date(this.getTime()); }; /** * Compares this instance to a Date object and returns an number indication of their relative values. * @param {Date} Date object to compare [Required] * @return {Number} -1 = this is lessthan date. 0 = values are equal. 1 = this is greaterthan date. */ $P.compareTo = function (date) { return Date.compare(this, date); }; /** * Compares this instance to another Date object and returns true if they are equal. * @param {Date} Date object to compare. If no date to compare, new Date() [now] is used. * @return {Boolean} true if dates are equal. false if they are not equal. */ $P.equals = function (date) { return Date.equals(this, (date !== undefined ? date : new Date())); }; /** * Determines if this instance is between a range of two dates or equal to either the start or end dates. * @param {Date} Start of range [Required] * @param {Date} End of range [Required] * @return {Boolean} true is this is between or equal to the start and end dates, else false */ $P.between = function (start, end) { return this.getTime() >= start.getTime() && this.getTime() <= end.getTime(); }; /** * Determines if this date occurs after the date to compare to. * @param {Date} Date object to compare. If no date to compare, new Date() ("now") is used. * @return {Boolean} true if this date instance is greater than the date to compare to (or "now"), otherwise false. */ $P.isAfter = function (date) { return this.compareTo(date || new Date()) === 1; }; /** * Determines if this date occurs before the date to compare to. * @param {Date} Date object to compare. If no date to compare, new Date() ("now") is used. * @return {Boolean} true if this date instance is less than the date to compare to (or "now"). */ $P.isBefore = function (date) { return (this.compareTo(date || new Date()) === -1); }; /** * Determines if the current Date instance occurs today. * @return {Boolean} true if this date instance is 'today', otherwise false. */ /** * Determines if the current Date instance occurs on the same Date as the supplied 'date'. * If no 'date' to compare to is provided, the current Date instance is compared to 'today'. * @param {date} Date object to compare. If no date to compare, the current Date ("now") is used. * @return {Boolean} true if this Date instance occurs on the same Day as the supplied 'date'. */ $P.isToday = $P.isSameDay = function (date) { return this.clone().clearTime().equals((date || new Date()).clone().clearTime()); }; /** * Adds the specified number of milliseconds to this instance. * @param {Number} The number of milliseconds to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addMilliseconds = function (value) { if (!value) { return this; } this.setTime(this.getTime() + value * 1); return this; }; /** * Adds the specified number of seconds to this instance. * @param {Number} The number of seconds to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addSeconds = function (value) { if (!value) { return this; } return this.addMilliseconds(value * 1000); }; /** * Adds the specified number of seconds to this instance. * @param {Number} The number of seconds to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addMinutes = function (value) { if (!value) { return this; } return this.addMilliseconds(value * 60000); // 60*1000 }; /** * Adds the specified number of hours to this instance. * @param {Number} The number of hours to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addHours = function (value) { if (!value) { return this; } return this.addMilliseconds(value * 3600000); // 60*60*1000 }; /** * Adds the specified number of days to this instance. * @param {Number} The number of days to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addDays = function (value) { if (!value) { return this; } this.setDate(this.getDate() + value * 1); return this; }; /** * Adds the specified number of weekdays (ie - not sat or sun) to this instance. * @param {Number} The number of days to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addWeekdays = function (value) { if (!value) { return this; } var day = this.getDay(); var weeks = (Math.ceil(Math.abs(value)/7)); if (day === 0 || day === 6) { if (value > 0) { this.next().monday(); this.addDays(-1); day = this.getDay(); } } if (value < 0) { while (value < 0) { this.addDays(-1); day = this.getDay(); if (day !== 0 && day !== 6) { value++; } } return this; } else if (value > 5 || (6-day) <= value) { value = value + (weeks * 2); } return this.addDays(value); }; /** * Adds the specified number of weeks to this instance. * @param {Number} The number of weeks to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addWeeks = function (value) { if (!value) { return this; } return this.addDays(value * 7); }; /** * Adds the specified number of months to this instance. * @param {Number} The number of months to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addMonths = function (value) { if (!value) { return this; } var n = this.getDate(); this.setDate(1); this.setMonth(this.getMonth() + value * 1); this.setDate(Math.min(n, $D.getDaysInMonth(this.getFullYear(), this.getMonth()))); return this; }; $P.addQuarters = function (value) { if (!value) { return this; } // note this will take you to the same point in the quarter as you are now. // i.e. - if you are 15 days into the quarter you'll be 15 days into the resulting one. // bonus: this allows adding fractional quarters return this.addMonths(value * 3); }; /** * Adds the specified number of years to this instance. * @param {Number} The number of years to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addYears = function (value) { if (!value) { return this; } return this.addMonths(value * 12); }; /** * Adds (or subtracts) to the value of the years, months, weeks, days, hours, minutes, seconds, milliseconds of the date instance using given configuration object. Positive and Negative values allowed. * Example

	Date.today().add( { days: 1, months: 1 } )

	new Date().add( { years: -1 } )
	
* @param {Object} Configuration object containing attributes (months, days, etc.) * @return {Date} this */ $P.add = function (config) { if (typeof config === "number") { this._orient = config; return this; } var x = config; if (x.day) { // If we should be a different date than today (eg: for 'tomorrow -1d', etc). // Should only effect parsing, not direct usage (eg, Finish and FinishExact) if ((x.day - this.getDate()) !== 0) { this.setDate(x.day); } } if (x.milliseconds) { this.addMilliseconds(x.milliseconds); } if (x.seconds) { this.addSeconds(x.seconds); } if (x.minutes) { this.addMinutes(x.minutes); } if (x.hours) { this.addHours(x.hours); } if (x.weeks) { this.addWeeks(x.weeks); } if (x.months) { this.addMonths(x.months); } if (x.years) { this.addYears(x.years); } if (x.days) { this.addDays(x.days); } return this; }; /** * Get the week number. Week one (1) is the week which contains the first Thursday of the year. Monday is considered the first day of the week. * The .getWeek() function does NOT convert the date to UTC. The local datetime is used. * Please use .getISOWeek() to get the week of the UTC converted date. * @return {Number} 1 to 53 */ $P.getWeek = function (utc) { // Create a copy of this date object var self, target = new Date(this.valueOf()); if (utc) { target.addMinutes(target.getTimezoneOffset()); self = target.clone(); } else { self = this; } // ISO week date weeks start on monday // so correct the day number var dayNr = (self.getDay() + 6) % 7; // ISO 8601 states that week 1 is the week // with the first thursday of that year. // Set the target date to the thursday in the target week target.setDate(target.getDate() - dayNr + 3); // Store the millisecond value of the target date var firstThursday = target.valueOf(); // Set the target to the first thursday of the year // First set the target to january first target.setMonth(0, 1); // Not a thursday? Correct the date to the next thursday if (target.getDay() !== 4) { target.setMonth(0, 1 + ((4 - target.getDay()) + 7) % 7); } // The weeknumber is the number of weeks between the // first thursday of the year and the thursday in the target week return 1 + Math.ceil((firstThursday - target) / 604800000); // 604800000 = 7 * 24 * 3600 * 1000 }; /** * Get the ISO 8601 week number. Week one ("01") is the week which contains the first Thursday of the year. Monday is considered the first day of the week. * The .getISOWeek() function does convert the date to it's UTC value. Please use .getWeek() to get the week of the local date. * @return {String} "01" to "53" */ $P.getISOWeek = function () { return p(this.getWeek(true)); }; /** * Moves the date to Monday of the week set. Week one (1) is the week which contains the first Thursday of the year. * @param {Number} A Number (1 to 53) that represents the week of the year. * @return {Date} this */ $P.setWeek = function (n) { if ((n - this.getWeek()) === 0) { if (this.getDay() !== 1) { return this.moveToDayOfWeek(1, (this.getDay() > 1 ? -1 : 1)); } else { return this; } } else { return this.moveToDayOfWeek(1, (this.getDay() > 1 ? -1 : 1)).addWeeks(n - this.getWeek()); } }; $P.setQuarter = function (qtr) { var month = Math.abs(((qtr-1) * 3) + 1); return this.setMonth(month, 1); }; $P.getQuarter = function () { return Date.getQuarter(this); }; $P.getDaysLeftInQuarter = function () { return Date.getDaysLeftInQuarter(this); }; /** * Moves the date to the next n'th occurrence of the dayOfWeek starting from the beginning of the month. The number (-1) is a magic number and will return the last occurrence of the dayOfWeek in the month. * @param {Number} The dayOfWeek to move to * @param {Number} The n'th occurrence to move to. Use (-1) to return the last occurrence in the month * @return {Date} this */ $P.moveToNthOccurrence = function (dayOfWeek, occurrence) { if (dayOfWeek === "Weekday") { if (occurrence > 0) { this.moveToFirstDayOfMonth(); if (this.is().weekday()) { occurrence -= 1; } } else if (occurrence < 0) { this.moveToLastDayOfMonth(); if (this.is().weekday()) { occurrence += 1; } } else { return this; } return this.addWeekdays(occurrence); } var shift = 0; if (occurrence > 0) { shift = occurrence - 1; } else if (occurrence === -1) { this.moveToLastDayOfMonth(); if (this.getDay() !== dayOfWeek) { this.moveToDayOfWeek(dayOfWeek, -1); } return this; } return this.moveToFirstDayOfMonth().addDays(-1).moveToDayOfWeek(dayOfWeek, +1).addWeeks(shift); }; var moveToN = function (getFunc, addFunc, nVal) { return function (value, orient) { var diff = (value - this[getFunc]() + nVal * (orient || +1)) % nVal; return this[addFunc]((diff === 0) ? diff += nVal * (orient || +1) : diff); }; }; /** * Move to the next or last dayOfWeek based on the orient value. * @param {Number} The dayOfWeek to move to * @param {Number} Forward (+1) or Back (-1). Defaults to +1. [Optional] * @return {Date} this */ $P.moveToDayOfWeek = moveToN("getDay", "addDays", 7); /** * Move to the next or last month based on the orient value. * @param {Number} The month to move to. 0 = January, 11 = December * @param {Number} Forward (+1) or Back (-1). Defaults to +1. [Optional] * @return {Date} this */ $P.moveToMonth = moveToN("getMonth", "addMonths", 12); /** * Get the Ordinate of the current day ("th", "st", "rd"). * @return {String} */ $P.getOrdinate = function () { var num = this.getDate(); return ord(num); }; /** * Get the Ordinal day (numeric day number) of the year, adjusted for leap year. * @return {Number} 1 through 365 (366 in leap years) */ $P.getOrdinalNumber = function () { return Math.ceil((this.clone().clearTime() - new Date(this.getFullYear(), 0, 1)) / 86400000) + 1; }; /** * Get the time zone abbreviation of the current date. * @return {String} The abbreviated time zone name (e.g. "EST") */ $P.getTimezone = function () { return $D.getTimezoneAbbreviation(this.getUTCOffset(), this.isDaylightSavingTime()); }; $P.setTimezoneOffset = function (offset) { var here = this.getTimezoneOffset(), there = Number(offset) * -6 / 10; return (there || there === 0) ? this.addMinutes(there - here) : this; }; $P.setTimezone = function (offset) { return this.setTimezoneOffset($D.getTimezoneOffset(offset)); }; /** * Indicates whether Daylight Saving Time is observed in the current time zone. * @return {Boolean} true|false */ $P.hasDaylightSavingTime = function () { return (Date.today().set({month: 0, day: 1}).getTimezoneOffset() !== Date.today().set({month: 6, day: 1}).getTimezoneOffset()); }; /** * Indicates whether this Date instance is within the Daylight Saving Time range for the current time zone. * @return {Boolean} true|false */ $P.isDaylightSavingTime = function () { return Date.today().set({month: 0, day: 1}).getTimezoneOffset() !== this.getTimezoneOffset(); }; /** * Get the offset from UTC of the current date. * @return {String} The 4-character offset string prefixed with + or - (e.g. "-0500") */ $P.getUTCOffset = function (offset) { var n = (offset || this.getTimezoneOffset()) * -10 / 6, r; if (n < 0) { r = (n - 10000).toString(); return r.charAt(0) + r.substr(2); } else { r = (n + 10000).toString(); return "+" + r.substr(1); } }; /** * Returns the number of milliseconds between this date and date. * @param {Date} Defaults to now * @return {Number} The diff in milliseconds */ $P.getElapsed = function (date) { return (date || new Date()) - this; }; /** * Set the value of year, month, day, hour, minute, second, millisecond of date instance using given configuration object. * Example

	Date.today().set( { day: 20, month: 1 } )

	new Date().set( { millisecond: 0 } )
	
* * @param {Object} Configuration object containing attributes (month, day, etc.) * @return {Date} this */ $P.set = function (config) { config = validateConfigObject.call(this, config); var key; for (key in config) { if (Object.prototype.hasOwnProperty.call(config, key)) { var name = key.charAt(0).toUpperCase() + key.slice(1); var addFunc, getFunc; if (key !== "week" && key !== "month" && key !== "timezone" && key !== "timezoneOffset") { name += "s"; } addFunc = "add" + name; getFunc = "get" + name; if (key === "month") { addFunc = addFunc + "s"; } else if (key === "year"){ getFunc = "getFullYear"; } if (key !== "day" && key !== "timezone" && key !== "timezoneOffset" && key !== "week" && key !== "hour") { this[addFunc](config[key] - this[getFunc]()); } else if ( key === "timezone"|| key === "timezoneOffset" || key === "week" || key === "hour") { this["set"+name](config[key]); } } } // day has to go last because you can't validate the day without first knowing the month if (config.day) { this.addDays(config.day - this.getDate()); } return this; }; /** * Moves the date to the first day of the month. * @return {Date} this */ $P.moveToFirstDayOfMonth = function () { return this.set({ day: 1 }); }; /** * Moves the date to the last day of the month. * @return {Date} this */ $P.moveToLastDayOfMonth = function () { return this.set({ day: $D.getDaysInMonth(this.getFullYear(), this.getMonth())}); }; /** * Converts the value of the current Date object to its equivalent string representation. * Format Specifiers * CUSTOM DATE AND TIME FORMAT STRINGS * Format Description Example * ------ --------------------------------------------------------------------------- ----------------------- * s The seconds of the minute between 0-59. "0" to "59" * ss The seconds of the minute with leading zero if required. "00" to "59" * * m The minute of the hour between 0-59. "0" or "59" * mm The minute of the hour with leading zero if required. "00" or "59" * * h The hour of the day between 1-12. "1" to "12" * hh The hour of the day with leading zero if required. "01" to "12" * * H The hour of the day between 0-23. "0" to "23" * HH The hour of the day with leading zero if required. "00" to "23" * * d The day of the month between 1 and 31. "1" to "31" * dd The day of the month with leading zero if required. "01" to "31" * ddd Abbreviated day name. Date.CultureInfo.abbreviatedDayNames. "Mon" to "Sun" * dddd The full day name. Date.CultureInfo.dayNames. "Monday" to "Sunday" * * M The month of the year between 1-12. "1" to "12" * MM The month of the year with leading zero if required. "01" to "12" * MMM Abbreviated month name. Date.CultureInfo.abbreviatedMonthNames. "Jan" to "Dec" * MMMM The full month name. Date.CultureInfo.monthNames. "January" to "December" * * yy The year as a two-digit number. "99" or "08" * yyyy The full four digit year. "1999" or "2008" * * t Displays the first character of the A.M./P.M. designator. "A" or "P" * Date.CultureInfo.amDesignator or Date.CultureInfo.pmDesignator * tt Displays the A.M./P.M. designator. "AM" or "PM" * Date.CultureInfo.amDesignator or Date.CultureInfo.pmDesignator * * S The ordinal suffix ("st, "nd", "rd" or "th") of the current day. "st, "nd", "rd" or "th" * * STANDARD DATE AND TIME FORMAT STRINGS * Format Description Example *------ --------------------------------------------------------------------------- ----------------------- * d The CultureInfo shortDate Format Pattern "M/d/yyyy" * D The CultureInfo longDate Format Pattern "dddd, MMMM dd, yyyy" * F The CultureInfo fullDateTime Format Pattern "dddd, MMMM dd, yyyy h:mm:ss tt" * m The CultureInfo monthDay Format Pattern "MMMM dd" * r The CultureInfo rfc1123 Format Pattern "ddd, dd MMM yyyy HH:mm:ss GMT" * s The CultureInfo sortableDateTime Format Pattern "yyyy-MM-ddTHH:mm:ss" * t The CultureInfo shortTime Format Pattern "h:mm tt" * T The CultureInfo longTime Format Pattern "h:mm:ss tt" * u The CultureInfo universalSortableDateTime Format Pattern "yyyy-MM-dd HH:mm:ssZ" * y The CultureInfo yearMonth Format Pattern "MMMM, yyyy" * * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @return {String} A string representation of the current Date object. */ var ord = function (n) { switch (n * 1) { case 1: case 21: case 31: return "st"; case 2: case 22: return "nd"; case 3: case 23: return "rd"; default: return "th"; } }; var parseStandardFormats = function (format) { var y, c = Date.CultureInfo.formatPatterns; switch (format) { case "d": return this.toString(c.shortDate); case "D": return this.toString(c.longDate); case "F": return this.toString(c.fullDateTime); case "m": return this.toString(c.monthDay); case "r": case "R": y = this.clone().addMinutes(this.getTimezoneOffset()); return y.toString(c.rfc1123) + " GMT"; case "s": return this.toString(c.sortableDateTime); case "t": return this.toString(c.shortTime); case "T": return this.toString(c.longTime); case "u": y = this.clone().addMinutes(this.getTimezoneOffset()); return y.toString(c.universalSortableDateTime); case "y": return this.toString(c.yearMonth); default: return false; } }; var parseFormatStringsClosure = function (context) { return function (m) { if (m.charAt(0) === "\\") { return m.replace("\\", ""); } switch (m) { case "hh": return p(context.getHours() < 13 ? (context.getHours() === 0 ? 12 : context.getHours()) : (context.getHours() - 12)); case "h": return context.getHours() < 13 ? (context.getHours() === 0 ? 12 : context.getHours()) : (context.getHours() - 12); case "HH": return p(context.getHours()); case "H": return context.getHours(); case "mm": return p(context.getMinutes()); case "m": return context.getMinutes(); case "ss": return p(context.getSeconds()); case "s": return context.getSeconds(); case "yyyy": return p(context.getFullYear(), 4); case "yy": return p(context.getFullYear()); case "y": return context.getFullYear(); case "E": case "dddd": return Date.CultureInfo.dayNames[context.getDay()]; case "ddd": return Date.CultureInfo.abbreviatedDayNames[context.getDay()]; case "dd": return p(context.getDate()); case "d": return context.getDate(); case "MMMM": return Date.CultureInfo.monthNames[context.getMonth()]; case "MMM": return Date.CultureInfo.abbreviatedMonthNames[context.getMonth()]; case "MM": return p((context.getMonth() + 1)); case "M": return context.getMonth() + 1; case "t": return context.getHours() < 12 ? Date.CultureInfo.amDesignator.substring(0, 1) : Date.CultureInfo.pmDesignator.substring(0, 1); case "tt": return context.getHours() < 12 ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator; case "S": return ord(context.getDate()); case "W": return context.getWeek(); case "WW": return context.getISOWeek(); case "Q": return "Q" + context.getQuarter(); case "q": return String(context.getQuarter()); case "z": return context.getTimezone(); case "Z": case "X": return Date.getTimezoneOffset(context.getTimezone()); case "ZZ": // Timezone offset in seconds return context.getTimezoneOffset() * -60; case "u": return context.getDay(); case "L": return ($D.isLeapYear(context.getFullYear())) ? 1 : 0; case "B": // Swatch Internet Time (.beats) return "@"+((context.getUTCSeconds() + (context.getUTCMinutes()*60) + ((context.getUTCHours()+1)*3600))/86.4); default: return m; } }; }; $P.toString = function (format, ignoreStandards) { // Standard Date and Time Format Strings. Formats pulled from CultureInfo file and // may vary by culture. if (!ignoreStandards && format && format.length === 1) { output = parseStandardFormats.call(this, format); if (output) { return output; } } var parseFormatStrings = parseFormatStringsClosure(this); return format ? format.replace(/((\\)?(dd?d?d?|MM?M?M?|yy?y?y?|hh?|HH?|mm?|ss?|tt?|S|q|Q|WW?W?W?)(?![^\[]*\]))/g, parseFormatStrings).replace(/\[|\]/g, "") : this._toString(); }; }()); /************************************************************* * SugarPak - Domain Specific Language - Syntactical Sugar * *************************************************************/ (function () { var $D = Date, $P = $D.prototype, $N = Number.prototype; // private $P._orient = +1; // private $P._nth = null; // private $P._is = false; // private $P._same = false; // private $P._isSecond = false; // private $N._dateElement = "days"; /** * Moves the date to the next instance of a date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.today().next().friday();
	Date.today().next().fri();
	Date.today().next().march();
	Date.today().next().mar();
	Date.today().next().week();
	
* * @return {Date} date */ $P.next = function () { this._move = true; this._orient = +1; return this; }; /** * Creates a new Date (Date.today()) and moves the date to the next instance of the date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.next().friday();
	Date.next().fri();
	Date.next().march();
	Date.next().mar();
	Date.next().week();
	
* * @return {Date} date */ $D.next = function () { return $D.today().next(); }; /** * Moves the date to the previous instance of a date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.today().last().friday();
	Date.today().last().fri();
	Date.today().last().march();
	Date.today().last().mar();
	Date.today().last().week();
	
* * @return {Date} date */ $P.last = $P.prev = $P.previous = function () { this._move = true; this._orient = -1; return this; }; /** * Creates a new Date (Date.today()) and moves the date to the previous instance of the date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.last().friday();
	Date.last().fri();
	Date.previous().march();
	Date.prev().mar();
	Date.last().week();
	
* * @return {Date} date */ $D.last = $D.prev = $D.previous = function () { return $D.today().last(); }; /** * Performs a equality check when followed by either a month name, day name or .weekday() function. * Example

	Date.today().is().friday(); // true|false
	Date.today().is().fri();
	Date.today().is().march();
	Date.today().is().mar();
	
* * @return {Boolean} true|false */ $P.is = function () { this._is = true; return this; }; /** * Determines if two date objects occur on/in exactly the same instance of the subsequent date part function. * The function .same() must be followed by a date part function (example: .day(), .month(), .year(), etc). * * An optional Date can be passed in the date part function. If now date is passed as a parameter, 'Now' is used. * * The following example demonstrates how to determine if two dates fall on the exact same day. * * Example

	var d1 = Date.today(); // today at 00:00
	var d2 = new Date();   // exactly now.

	// Do they occur on the same day?
	d1.same().day(d2); // true
	
	// Do they occur on the same hour?
	d1.same().hour(d2); // false, unless d2 hour is '00' (midnight).
	
	// What if it's the same day, but one year apart?
	var nextYear = Date.today().add(1).year();

	d1.same().day(nextYear); // false, because the dates must occur on the exact same day. 
	
* * Scenario: Determine if a given date occurs during some week period 2 months from now. * * Example

	var future = Date.today().add(2).months();
	return someDate.same().week(future); // true|false;
	
* * @return {Boolean} true|false */ $P.same = function () { this._same = true; this._isSecond = false; return this; }; /** * Determines if the current date/time occurs during Today. Must be preceded by the .is() function. * Example

	someDate.is().today();    // true|false
	new Date().is().today();  // true
	Date.today().is().today();// true
	Date.today().add(-1).day().is().today(); // false
	
* * @return {Boolean} true|false */ $P.today = function () { return this.same().day(); }; /** * Determines if the current date is a weekday. This function must be preceded by the .is() function. * Example

	Date.today().is().weekday(); // true|false
	
* * @return {Boolean} true|false */ $P.weekday = function () { if (this._nth) { return df("Weekday").call(this); } if (this._move) { return this.addWeekdays(this._orient); } if (this._is) { this._is = false; return (!this.is().sat() && !this.is().sun()); } return false; }; /** * Determines if the current date is on the weekend. This function must be preceded by the .is() function. * Example

	Date.today().is().weekend(); // true|false
	
* * @return {Boolean} true|false */ $P.weekend = function () { if (this._is) { this._is = false; return (this.is().sat() || this.is().sun()); } return false; }; /** * Sets the Time of the current Date instance. A string "6:15 pm" or config object {hour:18, minute:15} are accepted. * Example

	// Set time to 6:15pm with a String
	Date.today().at("6:15pm");

	// Set time to 6:15pm with a config object
	Date.today().at({hour:18, minute:15});
	
* * @return {Date} date */ $P.at = function (time) { return (typeof time === "string") ? $D.parse(this.toString("d") + " " + time) : this.set(time); }; /** * Creates a new Date() and adds this (Number) to the date based on the preceding date element function (eg. second|minute|hour|day|month|year). * Example

	// Undeclared Numbers must be wrapped with parentheses. Requirment of JavaScript.
	(3).days().fromNow();
	(6).months().fromNow();

	// Declared Number variables do not require parentheses. 
	var n = 6;
	n.months().fromNow();
	
* * @return {Date} A new Date instance */ $N.fromNow = $N.after = function (date) { var c = {}; c[this._dateElement] = this; return ((!date) ? new Date() : date.clone()).add(c); }; /** * Creates a new Date() and subtract this (Number) from the date based on the preceding date element function (eg. second|minute|hour|day|month|year). * Example

	// Undeclared Numbers must be wrapped with parentheses. Requirment of JavaScript.
	(3).days().ago();
	(6).months().ago();

	// Declared Number variables do not require parentheses. 
	var n = 6;
	n.months().ago();
	
* * @return {Date} A new Date instance */ $N.ago = $N.before = function (date) { var c = {}, s = (this._dateElement[this._dateElement.length-1] !== "s") ? this._dateElement + "s" : this._dateElement; c[s] = this * -1; return ((!date) ? new Date() : date.clone()).add(c); }; // Do NOT modify the following string tokens. These tokens are used to build dynamic functions. // All culture-specific strings can be found in the CultureInfo files. var dx = ("sunday monday tuesday wednesday thursday friday saturday").split(/\s/), mx = ("january february march april may june july august september october november december").split(/\s/), px = ("Millisecond Second Minute Hour Day Week Month Year Quarter Weekday").split(/\s/), pxf = ("Milliseconds Seconds Minutes Hours Date Week Month FullYear Quarter").split(/\s/), nth = ("final first second third fourth fifth").split(/\s/), de; /** * Returns an object literal of all the date parts. * Example

	var o = new Date().toObject();
	
	// { year: 2008, month: 4, week: 20, day: 13, hour: 18, minute: 9, second: 32, millisecond: 812 }
	
	// The object properties can be referenced directly from the object.
	
	alert(o.day);  // alerts "13"
	alert(o.year); // alerts "2008"
	
* * @return {Date} An object literal representing the original date object. */ $P.toObject = function () { var o = {}; for (var i = 0; i < px.length; i++) { if (this["get" + pxf[i]]) { o[px[i].toLowerCase()] = this["get" + pxf[i]](); } } return o; }; /** * Returns a date created from an object literal. Ignores the .week property if set in the config. * Example

	var o = new Date().toObject();
	
	return Date.fromObject(o); // will return the same date. 

	var o2 = {month: 1, day: 20, hour: 18}; // birthday party!
	Date.fromObject(o2);
	
* * @return {Date} An object literal representing the original date object. */ $D.fromObject = function(config) { config.week = null; return Date.today().set(config); }; // Create day name functions and abbreviated day name functions (eg. monday(), friday(), fri()). var df = function (n) { return function () { if (this._is) { this._is = false; return this.getDay() === n; } if (this._move) { this._move = null; } if (this._nth !== null) { // If the .second() function was called earlier, remove the _orient // from the date, and then continue. // This is required because 'second' can be used in two different context. // // Example // // Date.today().add(1).second(); // Date.march().second().monday(); // // Things get crazy with the following... // Date.march().add(1).second().second().monday(); // but it works!! // if (this._isSecond) { this.addSeconds(this._orient * -1); } // make sure we reset _isSecond this._isSecond = false; var ntemp = this._nth; this._nth = null; var temp = this.clone().moveToLastDayOfMonth(); this.moveToNthOccurrence(n, ntemp); if (this > temp) { throw new RangeError($D.getDayName(n) + " does not occur " + ntemp + " times in the month of " + $D.getMonthName(temp.getMonth()) + " " + temp.getFullYear() + "."); } return this; } return this.moveToDayOfWeek(n, this._orient); }; }; var sdf = function (n) { return function () { var t = $D.today(), shift = n - t.getDay(); if (n === 0 && Date.CultureInfo.firstDayOfWeek === 1 && t.getDay() !== 0) { shift = shift + 7; } return t.addDays(shift); }; }; // Create month name functions and abbreviated month name functions (eg. january(), march(), mar()). var month_instance_functions = function (n) { return function () { if (this._is) { this._is = false; return this.getMonth() === n; } return this.moveToMonth(n, this._orient); }; }; var month_static_functions = function (n) { return function () { return $D.today().set({ month: n, day: 1 }); }; }; var processTerms = function (names, staticFunc, instanceFunc) { for (var i = 0; i < names.length; i++) { // Create constant static Name variables. $D[names[i].toUpperCase()] = $D[names[i].toUpperCase().substring(0, 3)] = i; // Create Name functions. $D[names[i]] = $D[names[i].substring(0, 3)] = staticFunc(i); // Create Name instance functions. $P[names[i]] = $P[names[i].substring(0, 3)] = instanceFunc(i); } }; processTerms(dx, sdf, df); processTerms(mx, month_static_functions, month_instance_functions); // Create date element functions and plural date element functions used with Date (eg. day(), days(), months()). var ef = function (j) { return function () { // if the .second() function was called earlier, the _orient // has alread been added. Just return this and reset _isSecond. if (this._isSecond) { this._isSecond = false; return this; } if (this._same) { this._same = this._is = false; var o1 = this.toObject(), o2 = (arguments[0] || new Date()).toObject(), v = "", k = j.toLowerCase(); // the substr trick with -1 doesn't work in IE8 or less k = (k[k.length-1] === "s") ? k.substring(0,k.length-1) : k; for (var m = (px.length - 1); m > -1; m--) { v = px[m].toLowerCase(); if (o1[v] !== o2[v]) { return false; } if (k === v) { break; } } return true; } if (j.substring(j.length - 1) !== "s") { j += "s"; } if (this._move) { this._move = null; } return this["add" + j](this._orient); }; }; var nf = function (n) { return function () { this._dateElement = n; return this; }; }; for (var k = 0; k < px.length; k++) { de = px[k].toLowerCase(); if(de !== "weekday") { // Create date element functions and plural date element functions used with Date (eg. day(), days(), months()). $P[de] = $P[de + "s"] = ef(px[k]); // Create date element functions and plural date element functions used with Number (eg. day(), days(), months()). $N[de] = $N[de + "s"] = nf(de + "s"); } } $P._ss = ef("Second"); var nthfn = function (n) { return function (dayOfWeek) { if (this._same) { return this._ss(arguments[0]); } if (dayOfWeek || dayOfWeek === 0) { return this.moveToNthOccurrence(dayOfWeek, n); } this._nth = n; // if the operator is 'second' add the _orient, then deal with it later... if (n === 2 && (dayOfWeek === undefined || dayOfWeek === null)) { this._isSecond = true; return this.addSeconds(this._orient); } return this; }; }; for (var l = 0; l < nth.length; l++) { $P[nth[l]] = (l === 0) ? nthfn(-1) : nthfn(l); } }()); (function () { "use strict"; Date.Parsing = { Exception: function (s) { this.message = "Parse error at '" + s.substring(0, 10) + " ...'"; } }; var $P = Date.Parsing; var dayOffsets = { standard: [0,31,59,90,120,151,181,212,243,273,304,334], leap: [0,31,60,91,121,152,182,213,244,274,305,335] }; $P.isLeapYear = function(year) { return ((year % 4 === 0) && (year % 100 !== 0)) || (year % 400 === 0); }; var utils = { multiReplace : function (str, hash ) { var key; for (key in hash) { if (Object.prototype.hasOwnProperty.call(hash, key)) { var regex; if (typeof hash[key] === "function") { } else { regex = (hash[key] instanceof RegExp) ? hash[key] : new RegExp(hash[key], "g"); } str = str.replace(regex, key); } } return str; }, getDayOfYearFromWeek : function (obj) { var d, jan4, offset; obj.weekDay = (!obj.weekDay && obj.weekDay !== 0) ? 1 : obj.weekDay; d = new Date(obj.year, 0, 4); jan4 = d.getDay() === 0 ? 7 : d.getDay(); // JS is 0 indexed on Sunday. offset = jan4+3; obj.dayOfYear = ((obj.week * 7) + (obj.weekDay === 0 ? 7 : obj.weekDay))-offset; return obj; }, getDayOfYear : function (obj, dayOffset) { if (!obj.dayOfYear) { obj = utils.getDayOfYearFromWeek(obj); } for (var i=0;i <= dayOffset.length;i++) { if (obj.dayOfYear < dayOffset[i] || i === dayOffset.length) { obj.day = obj.day ? obj.day : (obj.dayOfYear - dayOffset[i-1]); break; } else { obj.month = i; } } return obj; }, adjustForTimeZone : function (obj, date) { var offset; if (obj.zone.toUpperCase() === "Z" || (obj.zone_hours === 0 && obj.zone_minutes === 0)) { // it's UTC/GML so work out the current timeszone offset offset = -date.getTimezoneOffset(); } else { offset = (obj.zone_hours*60) + (obj.zone_minutes || 0); if (obj.zone_sign === "+") { offset *= -1; } offset -= date.getTimezoneOffset(); } date.setMinutes(date.getMinutes()+offset); return date; }, setDefaults : function (obj) { obj.year = obj.year || Date.today().getFullYear(); obj.hours = obj.hours || 0; obj.minutes = obj.minutes || 0; obj.seconds = obj.seconds || 0; obj.milliseconds = obj.milliseconds || 0; if (!(!obj.month && (obj.week || obj.dayOfYear))) { // if we have a month, or if we don't but don't have the day calculation data obj.month = obj.month || 0; obj.day = obj.day || 1; } return obj; }, dataNum: function (data, mod, explict, postProcess) { var dataNum = data*1; if (mod) { if (postProcess) { return data ? mod(data)*1 : data; } else { return data ? mod(dataNum) : data; } } else if (!explict){ return data ? dataNum : data; } else { return (data && typeof data !== "undefined") ? dataNum : data; } }, timeDataProcess: function (obj) { var timeObj = {}; for (var x in obj.data) { if (obj.data.hasOwnProperty(x)) { timeObj[x] = obj.ignore[x] ? obj.data[x] : utils.dataNum(obj.data[x], obj.mods[x], obj.explict[x], obj.postProcess[x]); } } if (obj.data.secmins) { obj.data.secmins = obj.data.secmins.replace(",", ".") * 60; if (!timeObj.minutes) { timeObj.minutes = obj.data.secmins; } else if (!timeObj.seconds) { timeObj.seconds = obj.data.secmins; } delete obj.secmins; } return timeObj; }, buildTimeObjectFromData: function (data) { var time = utils.timeDataProcess({ data: { year : data[1], month : data[5], day : data[7], week : data[8], dayOfYear : data[10], hours : data[15], zone_hours : data[23], zone_minutes : data[24], zone : data[21], zone_sign : data[22], weekDay : data[9], minutes: data[16], seconds: data[19], milliseconds: data[20], secmins: data[18] }, mods: { month: function(data) { return data-1; }, weekDay: function (data) { data = Math.abs(data); return (data === 7 ? 0 : data); }, minutes: function (data) { return data.replace(":",""); }, seconds: function (data) { return Math.floor( (data.replace(":","").replace(",","."))*1 ); }, milliseconds: function (data) { return (data.replace(",",".")*1000); } }, postProcess: { minutes: true, seconds: true, milliseconds: true }, explict: { zone_hours: true, zone_minutes: true }, ignore: { zone: true, zone_sign: true, secmins: true } }); return time; }, addToHash: function (hash, keys, data) { keys = keys; data = data; var len = keys.length; for (var i = 0; i < len; i++) { hash[keys[i]] = data[i]; } return hash; }, combineRegex: function (r1, r2) { return new RegExp("(("+r1.source+")\\s("+r2.source+"))"); }, getDateNthString: function(add, last, inc){ if (add) { return Date.today().addDays(inc).toString("d"); } else if (last) { return Date.today().last()[inc]().toString("d"); } }, buildRegexData: function (array) { var arr = []; var len = array.length; for (var i=0; i < len; i++) { if (Object.prototype.toString.call(array[i]) === '[object Array]') { // oldIE compat version of Array.isArray arr.push(this.combineRegex(array[i][0], array[i][1])); } else { arr.push(array[i]); } } return arr; } }; $P.processTimeObject = function (obj) { var date, dayOffset; utils.setDefaults(obj); dayOffset = ($P.isLeapYear(obj.year)) ? dayOffsets.leap : dayOffsets.standard; if (!obj.month && (obj.week || obj.dayOfYear)) { utils.getDayOfYear(obj, dayOffset); } else { obj.dayOfYear = dayOffset[obj.month] + obj.day; } date = new Date(obj.year, obj.month, obj.day, obj.hours, obj.minutes, obj.seconds, obj.milliseconds); if (obj.zone) { utils.adjustForTimeZone(obj, date); // adjust (and calculate) for timezone } return date; }; $P.ISO = { regex : /^([\+-]?\d{4}(?!\d{2}\b))((-?)((0[1-9]|1[0-2])(\3([12]\d|0[1-9]|3[01]))?|W([0-4]\d|5[0-3])(-?[1-7])?|(00[1-9]|0[1-9]\d|[12]\d{2}|3([0-5]\d|6[1-6])))([T\s]((([01]\d|2[0-4])((:?)[0-5]\d)?|24\:?00)([\.,]\d+(?!:))?)?(\17[0-5]\d([\.,]\d+)?)?\s?([zZ]|([\+-])([01]\d|2[0-3]):?([0-5]\d)?)?)?)?$/, parse : function (s) { var time, data = s.match(this.regex); if (!data || !data.length) { return null; } time = utils.buildTimeObjectFromData(data); if (!time.year || (!time.year && (!time.month && !time.day) && (!time.week && !time.dayOfYear)) ) { return null; } return $P.processTimeObject(time); } }; $P.Numeric = { isNumeric: function (e){return!isNaN(parseFloat(e))&&isFinite(e);}, regex: /\b([0-1]?[0-9])([0-3]?[0-9])([0-2]?[0-9]?[0-9][0-9])\b/i, parse: function (s) { var data, i, time = {}, order = Date.CultureInfo.dateElementOrder.split(""); if (!(this.isNumeric(s)) || // if it's non-numeric OR (s[0] === "+" && s[0] === "-")) { // It's an arithmatic string (eg +/-1000) return null; } if (s.length < 5 && s.indexOf(".") < 0 && s.indexOf("/") < 0) { // assume it's just a year. time.year = s; return $P.processTimeObject(time); } data = s.match(this.regex); if (!data || !data.length) { return null; } for (i=0; i < order.length; i++) { switch(order[i]) { case "d": time.day = data[i+1]; break; case "m": time.month = (data[i+1]-1); break; case "y": time.year = data[i+1]; break; } } return $P.processTimeObject(time); } }; $P.Normalizer = { regexData: function () { var $R = Date.CultureInfo.regexPatterns; return utils.buildRegexData([ $R.tomorrow, $R.yesterday, [$R.past, $R.mon], [$R.past, $R.tue], [$R.past, $R.wed], [$R.past, $R.thu], [$R.past, $R.fri], [$R.past, $R.sat], [$R.past, $R.sun] ]); }, basicReplaceHash : function() { var $R = Date.CultureInfo.regexPatterns; return { "January": $R.jan.source, "February": $R.feb, "March": $R.mar, "April": $R.apr, "May": $R.may, "June": $R.jun, "July": $R.jul, "August": $R.aug, "September": $R.sep, "October": $R.oct, "November": $R.nov, "December": $R.dec, "": /\bat\b/gi, " ": /\s{2,}/, "am": $R.inTheMorning, "9am": $R.thisMorning, "pm": $R.inTheEvening, "7pm":$R.thisEvening }; }, keys : function(){ return [ utils.getDateNthString(true, false, 1), // tomorrow utils.getDateNthString(true, false, -1), // yesterday utils.getDateNthString(false, true, "monday"), //last mon utils.getDateNthString(false, true, "tuesday"), //last tues utils.getDateNthString(false, true, "wednesday"), //last wed utils.getDateNthString(false, true, "thursday"), //last thurs utils.getDateNthString(false, true, "friday"), //last fri utils.getDateNthString(false, true, "saturday"), //last sat utils.getDateNthString(false, true, "sunday") //last sun ]; }, buildRegexFunctions: function () { var $R = Date.CultureInfo.regexPatterns; var __ = Date.i18n.__; var tomorrowRE = new RegExp("(\\b\\d\\d?("+__("AM")+"|"+__("PM")+")? )("+$R.tomorrow.source.slice(1)+")", "i"); // adapted tomorrow regex for AM PM relative dates var todayRE = new RegExp($R.today.source + "(?!\\s*([+-]))\\b"); // today, but excludes the math operators (eg "today + 2h") this.replaceFuncs = [ [todayRE, function (full) { return (full.length > 1) ? Date.today().toString("d") : full; }], [tomorrowRE, function(full, m1) { var t = Date.today().addDays(1).toString("d"); return (t + " " + m1); }], [$R.amThisMorning, function(str, am){return am;}], [$R.pmThisEvening, function(str, pm){return pm;}] ]; }, buildReplaceData: function () { this.buildRegexFunctions(); this.replaceHash = utils.addToHash(this.basicReplaceHash(), this.keys(), this.regexData()); }, stringReplaceFuncs: function (s) { for (var i=0; i < this.replaceFuncs.length; i++) { s = s.replace(this.replaceFuncs[i][0], this.replaceFuncs[i][1]); } return s; }, parse: function (s) { s = this.stringReplaceFuncs(s); s = utils.multiReplace(s, this.replaceHash); try { var n = s.split(/([\s\-\.\,\/\x27]+)/); if (n.length === 3 && $P.Numeric.isNumeric(n[0]) && $P.Numeric.isNumeric(n[2]) && (n[2].length >= 4)) { // ok, so we're dealing with x/year. But that's not a full date. // This fixes wonky dateElementOrder parsing when set to dmy order. if (Date.CultureInfo.dateElementOrder[0] === "d") { s = "1/" + n[0] + "/" + n[2]; // set to 1st of month and normalize the seperator } } } catch (e) {} return s; } }; $P.Normalizer.buildReplaceData(); }()); (function () { var $P = Date.Parsing; var _ = $P.Operators = { // // Tokenizers // rtoken: function (r) { // regex token return function (s) { var mx = s.match(r); if (mx) { return ([ mx[0], s.substring(mx[0].length) ]); } else { throw new $P.Exception(s); } }; }, token: function () { // whitespace-eating token return function (s) { return _.rtoken(new RegExp("^\\s*" + s + "\\s*"))(s); }; }, stoken: function (s) { // string token return _.rtoken(new RegExp("^" + s)); }, // Atomic Operators until: function (p) { return function (s) { var qx = [], rx = null; while (s.length) { try { rx = p.call(this, s); } catch (e) { qx.push(rx[0]); s = rx[1]; continue; } break; } return [ qx, s ]; }; }, many: function (p) { return function (s) { var rx = [], r = null; while (s.length) { try { r = p.call(this, s); } catch (e) { return [ rx, s ]; } rx.push(r[0]); s = r[1]; } return [ rx, s ]; }; }, // generator operators -- see below optional: function (p) { return function (s) { var r = null; try { r = p.call(this, s); } catch (e) { return [ null, s ]; } return [ r[0], r[1] ]; }; }, not: function (p) { return function (s) { try { p.call(this, s); } catch (e) { return [null, s]; } throw new $P.Exception(s); }; }, ignore: function (p) { return p ? function (s) { var r = null; r = p.call(this, s); return [null, r[1]]; } : null; }, product: function () { var px = arguments[0], qx = Array.prototype.slice.call(arguments, 1), rx = []; for (var i = 0 ; i < px.length ; i++) { rx.push(_.each(px[i], qx)); } return rx; }, cache: function (rule) { var cache = {}, cache_length = 0, cache_keys = [], CACHE_MAX = Date.Config.CACHE_MAX || 100000, r = null; var cacheCheck = function () { if (cache_length === CACHE_MAX) { // kill several keys, don't want to have to do this all the time... for (var i=0; i < 10; i++) { var key = cache_keys.shift(); if (key) { delete cache[key]; cache_length--; } } } }; return function (s) { cacheCheck(); try { r = cache[s] = (cache[s] || rule.call(this, s)); } catch (e) { r = cache[s] = e; } cache_length++; cache_keys.push(s); if (r instanceof $P.Exception) { throw r; } else { return r; } }; }, // vector operators -- see below any: function () { var px = arguments; return function (s) { var r = null; for (var i = 0; i < px.length; i++) { if (px[i] == null) { continue; } try { r = (px[i].call(this, s)); } catch (e) { r = null; } if (r) { return r; } } throw new $P.Exception(s); }; }, each: function () { var px = arguments; return function (s) { var rx = [], r = null; for (var i = 0; i < px.length ; i++) { if (px[i] == null) { continue; } try { r = (px[i].call(this, s)); } catch (e) { throw new $P.Exception(s); } rx.push(r[0]); s = r[1]; } return [ rx, s]; }; }, all: function () { var px = arguments, _ = _; return _.each(_.optional(px)); }, // delimited operators sequence: function (px, d, c) { d = d || _.rtoken(/^\s*/); c = c || null; if (px.length === 1) { return px[0]; } return function (s) { var r = null, q = null; var rx = []; for (var i = 0; i < px.length ; i++) { try { r = px[i].call(this, s); } catch (e) { break; } rx.push(r[0]); try { q = d.call(this, r[1]); } catch (ex) { q = null; break; } s = q[1]; } if (!r) { throw new $P.Exception(s); } if (q) { throw new $P.Exception(q[1]); } if (c) { try { r = c.call(this, r[1]); } catch (ey) { throw new $P.Exception(r[1]); } } return [ rx, (r?r[1]:s) ]; }; }, // // Composite Operators // between: function (d1, p, d2) { d2 = d2 || d1; var _fn = _.each(_.ignore(d1), p, _.ignore(d2)); return function (s) { var rx = _fn.call(this, s); return [[rx[0][0], r[0][2]], rx[1]]; }; }, list: function (p, d, c) { d = d || _.rtoken(/^\s*/); c = c || null; return (p instanceof Array ? _.each(_.product(p.slice(0, -1), _.ignore(d)), p.slice(-1), _.ignore(c)) : _.each(_.many(_.each(p, _.ignore(d))), px, _.ignore(c))); }, set: function (px, d, c) { d = d || _.rtoken(/^\s*/); c = c || null; return function (s) { // r is the current match, best the current 'best' match // which means it parsed the most amount of input var r = null, p = null, q = null, rx = null, best = [[], s], last = false; // go through the rules in the given set for (var i = 0; i < px.length ; i++) { // last is a flag indicating whether this must be the last element // if there is only 1 element, then it MUST be the last one q = null; p = null; r = null; last = (px.length === 1); // first, we try simply to match the current pattern // if not, try the next pattern try { r = px[i].call(this, s); } catch (e) { continue; } // since we are matching against a set of elements, the first // thing to do is to add r[0] to matched elements rx = [[r[0]], r[1]]; // if we matched and there is still input to parse and // we don't already know this is the last element, // we're going to next check for the delimiter ... // if there's none, or if there's no input left to parse // than this must be the last element after all ... if (r[1].length > 0 && ! last) { try { q = d.call(this, r[1]); } catch (ex) { last = true; } } else { last = true; } // if we parsed the delimiter and now there's no more input, // that means we shouldn't have parsed the delimiter at all // so don't update r and mark this as the last element ... if (!last && q[1].length === 0) { last = true; } // so, if this isn't the last element, we're going to see if // we can get any more matches from the remaining (unmatched) // elements ... if (!last) { // build a list of the remaining rules we can match against, // i.e., all but the one we just matched against var qx = []; for (var j = 0; j < px.length ; j++) { if (i !== j) { qx.push(px[j]); } } // now invoke recursively set with the remaining input // note that we don't include the closing delimiter ... // we'll check for that ourselves at the end p = _.set(qx, d).call(this, q[1]); // if we got a non-empty set as a result ... // (otw rx already contains everything we want to match) if (p[0].length > 0) { // update current result, which is stored in rx ... // basically, pick up the remaining text from p[1] // and concat the result from p[0] so that we don't // get endless nesting ... rx[0] = rx[0].concat(p[0]); rx[1] = p[1]; } } // at this point, rx either contains the last matched element // or the entire matched set that starts with this element. // now we just check to see if this variation is better than // our best so far, in terms of how much of the input is parsed if (rx[1].length < best[1].length) { best = rx; } // if we've parsed all the input, then we're finished if (best[1].length === 0) { break; } } // so now we've either gone through all the patterns trying them // as the initial match; or we found one that parsed the entire // input string ... // if best has no matches, just return empty set ... if (best[0].length === 0) { return best; } // if a closing delimiter is provided, then we have to check it also if (c) { // we try this even if there is no remaining input because the pattern // may well be optional or match empty input ... try { q = c.call(this, best[1]); } catch (ey) { throw new $P.Exception(best[1]); } // it parsed ... be sure to update the best match remaining input best[1] = q[1]; } // if we're here, either there was no closing delimiter or we parsed it // so now we have the best match; just return it! return best; }; }, forward: function (gr, fname) { return function (s) { return gr[fname].call(this, s); }; }, // // Translation Operators // replace: function (rule, repl) { return function (s) { var r = rule.call(this, s); return [repl, r[1]]; }; }, process: function (rule, fn) { return function (s) { var r = rule.call(this, s); return [fn.call(this, r[0]), r[1]]; }; }, min: function (min, rule) { return function (s) { var rx = rule.call(this, s); if (rx[0].length < min) { throw new $P.Exception(s); } return rx; }; } }; // Generator Operators And Vector Operators // Generators are operators that have a signature of F(R) => R, // taking a given rule and returning another rule, such as // ignore, which parses a given rule and throws away the result. // Vector operators are those that have a signature of F(R1,R2,...) => R, // take a list of rules and returning a new rule, such as each. // Generator operators are converted (via the following _generator // function) into functions that can also take a list or array of rules // and return an array of new rules as though the function had been // called on each rule in turn (which is what actually happens). // This allows generators to be used with vector operators more easily. // Example: // each(ignore(foo, bar)) instead of each(ignore(foo), ignore(bar)) // This also turns generators into vector operators, which allows // constructs like: // not(cache(foo, bar)) var _generator = function (op) { function gen() { var args = null, rx = [], px, i; if (arguments.length > 1) { args = Array.prototype.slice.call(arguments); } else if (arguments[0] instanceof Array) { args = arguments[0]; } if (args) { px = args.shift(); if (px.length > 0) { args.unshift(px[i]); rx.push(op.apply(null, args)); args.shift(); return rx; } } else { return op.apply(null, arguments); } } return gen; }; var gx = "optional not ignore cache".split(/\s/); for (var i = 0 ; i < gx.length ; i++) { _[gx[i]] = _generator(_[gx[i]]); } var _vector = function (op) { return function () { if (arguments[0] instanceof Array) { return op.apply(null, arguments[0]); } else { return op.apply(null, arguments); } }; }; var vx = "each any all".split(/\s/); for (var j = 0 ; j < vx.length ; j++) { _[vx[j]] = _vector(_[vx[j]]); } }()); (function () { var $D = Date; var flattenAndCompact = function (ax) { var rx = []; for (var i = 0; i < ax.length; i++) { if (ax[i] instanceof Array) { rx = rx.concat(flattenAndCompact(ax[i])); } else { if (ax[i]) { rx.push(ax[i]); } } } return rx; }; var parseMeridian = function () { if (this.meridian && (this.hour || this.hour === 0)) { if (this.meridian === "a" && this.hour > 11 && Date.Config.strict24hr){ throw "Invalid hour and meridian combination"; } else if (this.meridian === "p" && this.hour < 12 && Date.Config.strict24hr){ throw "Invalid hour and meridian combination"; } else if (this.meridian === "p" && this.hour < 12) { this.hour = this.hour + 12; } else if (this.meridian === "a" && this.hour === 12) { this.hour = 0; } } }; var setDefaults = function () { var now = new Date(); if ((this.hour || this.minute) && (!this.month && !this.year && !this.day)) { this.day = now.getDate(); } if (!this.year) { this.year = now.getFullYear(); } if (!this.month && this.month !== 0) { this.month = now.getMonth(); } if (!this.day) { this.day = 1; } if (!this.hour) { this.hour = 0; } if (!this.minute) { this.minute = 0; } if (!this.second) { this.second = 0; } if (!this.millisecond) { this.millisecond = 0; } }; var finishUtils = { getToday: function () { if (this.now || "hour minute second".indexOf(this.unit) !== -1) { return new Date(); } else { return $D.today(); } }, setDaysFromWeekday: function (today, orient){ var gap; orient = orient || 1; this.unit = "day"; gap = ($D.getDayNumberFromName(this.weekday) - today.getDay()); this.days = gap ? ((gap + (orient * 7)) % 7) : (orient * 7); return this; }, setMonthsFromMonth: function (today, orient) { var gap; orient = orient || 1; this.unit = "month"; gap = (this.month - today.getMonth()); this.months = gap ? ((gap + (orient * 12)) % 12) : (orient * 12); this.month = null; return this; }, setDMYFromWeekday: function () { var d = Date[this.weekday](); this.day = d.getDate(); if (!this.month) { this.month = d.getMonth(); } this.year = d.getFullYear(); return this; }, setUnitValue: function (orient) { if (!this.value && this.operator && this.operator !== null && this[this.unit + "s"] && this[this.unit + "s"] !== null) { this[this.unit + "s"] = this[this.unit + "s"] + ((this.operator === "add") ? 1 : -1) + (this.value||0) * orient; } else if (this[this.unit + "s"] == null || this.operator != null) { if (!this.value) { this.value = 1; } this[this.unit + "s"] = this.value * orient; } }, generateDateFromWeeks: function () { var weekday = (this.weekday !== undefined) ? this.weekday : "today"; var d = Date[weekday]().addWeeks(this.weeks); if (this.now) { d.setTimeToNow(); } return d; } }; $D.Translator = { hour: function (s) { return function () { this.hour = Number(s); }; }, minute: function (s) { return function () { this.minute = Number(s); }; }, second: function (s) { return function () { this.second = Number(s); }; }, /* for ss.s format */ secondAndMillisecond: function (s) { return function () { var mx = s.match(/^([0-5][0-9])\.([0-9]{1,3})/); this.second = Number(mx[1]); this.millisecond = Number(mx[2]); }; }, meridian: function (s) { return function () { this.meridian = s.slice(0, 1).toLowerCase(); }; }, timezone: function (s) { return function () { var n = s.replace(/[^\d\+\-]/g, ""); if (n.length) { this.timezoneOffset = Number(n); } else { this.timezone = s.toLowerCase(); } }; }, day: function (x) { var s = x[0]; return function () { this.day = Number(s.match(/\d+/)[0]); if (this.day < 1) { throw "invalid day"; } }; }, month: function (s) { return function () { this.month = (s.length === 3) ? "jan feb mar apr may jun jul aug sep oct nov dec".indexOf(s)/4 : Number(s) - 1; if (this.month < 0) { throw "invalid month"; } }; }, year: function (s) { return function () { var n = Number(s); this.year = ((s.length > 2) ? n : (n + (((n + 2000) < Date.CultureInfo.twoDigitYearMax) ? 2000 : 1900))); }; }, rday: function (s) { return function () { switch (s) { case "yesterday": this.days = -1; break; case "tomorrow": this.days = 1; break; case "today": this.days = 0; break; case "now": this.days = 0; this.now = true; break; } }; }, finishExact: function (x) { var d; x = (x instanceof Array) ? x : [x]; for (var i = 0 ; i < x.length ; i++) { if (x[i]) { x[i].call(this); } } setDefaults.call(this); parseMeridian.call(this); if (this.day > $D.getDaysInMonth(this.year, this.month)) { throw new RangeError(this.day + " is not a valid value for days."); } d = new Date(this.year, this.month, this.day, this.hour, this.minute, this.second, this.millisecond); if (this.year < 100) { d.setFullYear(this.year); // means years less that 100 are process correctly. JS will parse it otherwise as 1900-1999. } if (this.timezone) { d.set({ timezone: this.timezone }); } else if (this.timezoneOffset) { d.set({ timezoneOffset: this.timezoneOffset }); } return d; }, finish: function (x) { var today, expression, orient, temp; x = (x instanceof Array) ? flattenAndCompact(x) : [ x ]; if (x.length === 0) { return null; } for (var i = 0 ; i < x.length ; i++) { if (typeof x[i] === "function") { x[i].call(this); } } if (this.now && !this.unit && !this.operator) { return new Date(); } else { today = finishUtils.getToday.call(this); } expression = !!(this.days && this.days !== null || this.orient || this.operator); orient = ((this.orient === "past" || this.operator === "subtract") ? -1 : 1); if (this.month && this.unit === "week") { this.value = this.month + 1; delete this.month; delete this.day; } if ((this.month || this.month === 0) && "year day hour minute second".indexOf(this.unit) !== -1) { if (!this.value) { this.value = this.month + 1; } this.month = null; expression = true; } if (!expression && this.weekday && !this.day && !this.days) { finishUtils.setDMYFromWeekday.call(this); } if (expression && this.weekday && this.unit !== "month" && this.unit !== "week") { finishUtils.setDaysFromWeekday.call(this, today, orient); } if (this.weekday && this.unit !== "week" && !this.day && !this.days) { temp = Date[this.weekday](); this.day = temp.getDate(); if (temp.getMonth() !== today.getMonth()) { this.month = temp.getMonth(); } } if (this.month && this.unit === "day" && this.operator) { if (!this.value) { this.value = (this.month + 1); } this.month = null; } if (this.value != null && this.month != null && this.year != null) { this.day = this.value * 1; } if (this.month && !this.day && this.value) { today.set({ day: this.value * 1 }); if (!expression) { this.day = this.value * 1; } } if (!this.month && this.value && this.unit === "month" && !this.now) { this.month = this.value; expression = true; } if (expression && (this.month || this.month === 0) && this.unit !== "year") { finishUtils.setMonthsFromMonth.call(this, today, orient); } if (!this.unit) { this.unit = "day"; } finishUtils.setUnitValue.call(this, orient); parseMeridian.call(this); if ((this.month || this.month === 0) && !this.day) { this.day = 1; } if (!this.orient && !this.operator && this.unit === "week" && this.value && !this.day && !this.month) { return Date.today().setWeek(this.value); } if (this.unit === "week" && this.weeks && !this.day && !this.month) { return finishUtils.generateDateFromWeeks.call(this); } if (expression && this.timezone && this.day && this.days) { this.day = this.days; } if (expression){ today.add(this); } else { today.set(this); } if (this.timezone) { this.timezone = this.timezone.toUpperCase(); var offset = $D.getTimezoneOffset(this.timezone); var timezone; if (today.hasDaylightSavingTime()) { // lets check that we're being sane with timezone setting timezone = $D.getTimezoneAbbreviation(offset, today.isDaylightSavingTime()); if (timezone !== this.timezone) { // bugger, we're in a place where things like EST vs EDT matters. if (today.isDaylightSavingTime()) { today.addHours(-1); } else { today.addHours(1); } } } today.setTimezoneOffset(offset); } return today; } }; }()); (function () { var $D = Date; $D.Grammar = {}; var _ = $D.Parsing.Operators, g = $D.Grammar, t = $D.Translator, _fn; // Allow rolling up into general purpose rules _fn = function () { return _.each(_.any.apply(null, arguments), _.not(g.ctoken2("timeContext"))); }; g.datePartDelimiter = _.rtoken(/^([\s\-\.\,\/\x27]+)/); g.timePartDelimiter = _.stoken(":"); g.whiteSpace = _.rtoken(/^\s*/); g.generalDelimiter = _.rtoken(/^(([\s\,]|at|@|on)+)/); var _C = {}; g.ctoken = function (keys) { var fn = _C[keys]; if (! fn) { var c = Date.CultureInfo.regexPatterns; var kx = keys.split(/\s+/), px = []; for (var i = 0; i < kx.length ; i++) { px.push(_.replace(_.rtoken(c[kx[i]]), kx[i])); } fn = _C[keys] = _.any.apply(null, px); } return fn; }; g.ctoken2 = function (key) { return _.rtoken(Date.CultureInfo.regexPatterns[key]); }; var cacheProcessRtoken = function (key, token, type, eachToken) { if (eachToken) { g[key] = _.cache(_.process(_.each(_.rtoken(token),_.optional(g.ctoken2(eachToken))), type)); } else { g[key] = _.cache(_.process(_.rtoken(token), type)); } }; var cacheProcessCtoken = function (token, type) { return _.cache(_.process(g.ctoken2(token), type)); }; var _F = {}; //function cache var _get = function (f) { _F[f] = (_F[f] || g.format(f)[0]); return _F[f]; }; g.allformats = function (fx) { var rx = []; if (fx instanceof Array) { for (var i = 0; i < fx.length; i++) { rx.push(_get(fx[i])); } } else { rx.push(_get(fx)); } return rx; }; g.formats = function (fx) { if (fx instanceof Array) { var rx = []; for (var i = 0 ; i < fx.length ; i++) { rx.push(_get(fx[i])); } return _.any.apply(null, rx); } else { return _get(fx); } }; var grammarFormats = { timeFormats: function(){ var i, RTokenKeys = [ "h", "hh", "H", "HH", "m", "mm", "s", "ss", "ss.s", "z", "zz" ], RToken = [ /^(0[0-9]|1[0-2]|[1-9])/, /^(0[0-9]|1[0-2])/, /^([0-1][0-9]|2[0-3]|[0-9])/, /^([0-1][0-9]|2[0-3])/, /^([0-5][0-9]|[0-9])/, /^[0-5][0-9]/, /^([0-5][0-9]|[0-9])/, /^[0-5][0-9]/, /^[0-5][0-9]\.[0-9]{1,3}/, /^((\+|\-)\s*\d\d\d\d)|((\+|\-)\d\d\:?\d\d)/, /^((\+|\-)\s*\d\d\d\d)|((\+|\-)\d\d\:?\d\d)/ ], tokens = [ t.hour, t.hour, t.hour, t.hour, t.minute, t.minute, t.second, t.second, t.secondAndMillisecond, t.timezone, t.timezone ]; for (i=0; i < RTokenKeys.length; i++) { cacheProcessRtoken(RTokenKeys[i], RToken[i], tokens[i]); } g.hms = _.cache(_.sequence([g.H, g.m, g.s], g.timePartDelimiter)); g.t = cacheProcessCtoken("shortMeridian", t.meridian); g.tt = cacheProcessCtoken("longMeridian", t.meridian); g.zzz = cacheProcessCtoken("timezone", t.timezone); g.timeSuffix = _.each(_.ignore(g.whiteSpace), _.set([ g.tt, g.zzz ])); g.time = _.each(_.optional(_.ignore(_.stoken("T"))), g.hms, g.timeSuffix); }, dateFormats: function () { // pre-loaded rules for different date part order preferences var _setfn = function () { return _.set(arguments, g.datePartDelimiter); }; var i, RTokenKeys = [ "d", "dd", "M", "MM", "y", "yy", "yyy", "yyyy" ], RToken = [ /^([0-2]\d|3[0-1]|\d)/, /^([0-2]\d|3[0-1])/, /^(1[0-2]|0\d|\d)/, /^(1[0-2]|0\d)/, /^(\d+)/, /^(\d\d)/, /^(\d\d?\d?\d?)/, /^(\d\d\d\d)/ ], tokens = [ t.day, t.day, t.month, t.month, t.year, t.year, t.year, t.year ], eachToken = [ "ordinalSuffix", "ordinalSuffix" ]; for (i=0; i < RTokenKeys.length; i++) { cacheProcessRtoken(RTokenKeys[i], RToken[i], tokens[i], eachToken[i]); } g.MMM = g.MMMM = _.cache(_.process(g.ctoken("jan feb mar apr may jun jul aug sep oct nov dec"), t.month)); g.ddd = g.dddd = _.cache(_.process(g.ctoken("sun mon tue wed thu fri sat"), function (s) { return function () { this.weekday = s; }; } )); g.day = _fn(g.d, g.dd); g.month = _fn(g.M, g.MMM); g.year = _fn(g.yyyy, g.yy); g.mdy = _setfn(g.ddd, g.month, g.day, g.year); g.ymd = _setfn(g.ddd, g.year, g.month, g.day); g.dmy = _setfn(g.ddd, g.day, g.month, g.year); g.date = function (s) { return ((g[Date.CultureInfo.dateElementOrder] || g.mdy).call(this, s)); }; }, relative: function () { // relative date / time expressions g.orientation = _.process(g.ctoken("past future"), function (s) { return function () { this.orient = s; }; } ); g.operator = _.process(g.ctoken("add subtract"), function (s) { return function () { this.operator = s; }; } ); g.rday = _.process(g.ctoken("yesterday tomorrow today now"), t.rday); g.unit = _.process(g.ctoken("second minute hour day week month year"), function (s) { return function () { this.unit = s; }; } ); } }; g.buildGrammarFormats = function () { // these need to be rebuilt every time the language changes. _C = {}; grammarFormats.timeFormats(); grammarFormats.dateFormats(); grammarFormats.relative(); g.value = _.process(_.rtoken(/^([-+]?\d+)?(st|nd|rd|th)?/), function (s) { return function () { this.value = s.replace(/\D/g, ""); }; } ); g.expression = _.set([g.rday, g.operator, g.value, g.unit, g.orientation, g.ddd, g.MMM ]); g.format = _.process(_.many( _.any( // translate format specifiers into grammar rules _.process( _.rtoken(/^(dd?d?d?(?!e)|MM?M?M?|yy?y?y?|hh?|HH?|mm?|ss?|tt?|zz?z?)/), function (fmt) { if (g[fmt]) { return g[fmt]; } else { throw $D.Parsing.Exception(fmt); } } ), // translate separator tokens into token rules _.process(_.rtoken(/^[^dMyhHmstz]+/), // all legal separators function (s) { return _.ignore(_.stoken(s)); } ) ) ), // construct the parser ... function (rules) { return _.process(_.each.apply(null, rules), t.finishExact); } ); // starting rule for general purpose grammar g._start = _.process(_.set([ g.date, g.time, g.expression ], g.generalDelimiter, g.whiteSpace), t.finish); }; g.buildGrammarFormats(); // parsing date format specifiers - ex: "h:m:s tt" // this little guy will generate a custom parser based // on the format string, ex: g.format("h:m:s tt") // check for these formats first g._formats = g.formats([ "\"yyyy-MM-ddTHH:mm:ssZ\"", "yyyy-MM-ddTHH:mm:ss.sz", "yyyy-MM-ddTHH:mm:ssZ", "yyyy-MM-ddTHH:mm:ssz", "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-ddTHH:mmZ", "yyyy-MM-ddTHH:mmz", "yyyy-MM-ddTHH:mm", "ddd, MMM dd, yyyy H:mm:ss tt", "ddd MMM d yyyy HH:mm:ss zzz", "MMddyyyy", "ddMMyyyy", "Mddyyyy", "ddMyyyy", "Mdyyyy", "dMyyyy", "yyyy", "Mdyy", "dMyy", "d" ]); // real starting rule: tries selected formats first, // then general purpose rule g.start = function (s) { try { var r = g._formats.call({}, s); if (r[1].length === 0) { return r; } } catch (e) {} return g._start.call({}, s); }; }()); (function () { var $D = Date; /** * @desc Converts the specified string value into its JavaScript Date equivalent using CultureInfo specific format information. * * Example

	///////////
	// Dates //
	///////////

	// 15-Oct-2004
	var d1 = Date.parse("10/15/2004");

	// 15-Oct-2004
	var d1 = Date.parse("15-Oct-2004");

	// 15-Oct-2004
	var d1 = Date.parse("2004.10.15");

	//Fri Oct 15, 2004
	var d1 = Date.parse("Fri Oct 15, 2004");

	///////////
	// Times //
	///////////

	// Today at 10 PM.
	var d1 = Date.parse("10 PM");

	// Today at 10:30 PM.
	var d1 = Date.parse("10:30 P.M.");

	// Today at 6 AM.
	var d1 = Date.parse("06am");

	/////////////////////
	// Dates and Times //
	/////////////////////

	// 8-July-2004 @ 10:30 PM
	var d1 = Date.parse("July 8th, 2004, 10:30 PM");

	// 1-July-2004 @ 10:30 PM
	var d1 = Date.parse("2004-07-01T22:30:00");

	////////////////////
	// Relative Dates //
	////////////////////

	// Returns today's date. The string "today" is culture specific.
	var d1 = Date.parse("today");

	// Returns yesterday's date. The string "yesterday" is culture specific.
	var d1 = Date.parse("yesterday");

	// Returns the date of the next thursday.
	var d1 = Date.parse("Next thursday");

	// Returns the date of the most previous monday.
	var d1 = Date.parse("last monday");

	// Returns today's day + one year.
	var d1 = Date.parse("next year");

	///////////////
	// Date Math //
	///////////////

	// Today + 2 days
	var d1 = Date.parse("t+2");

	// Today + 2 days
	var d1 = Date.parse("today + 2 days");

	// Today + 3 months
	var d1 = Date.parse("t+3m");

	// Today - 1 year
	var d1 = Date.parse("today - 1 year");

	// Today - 1 year
	var d1 = Date.parse("t-1y"); 


	/////////////////////////////
	// Partial Dates and Times //
	/////////////////////////////

	// July 15th of this year.
	var d1 = Date.parse("July 15");

	// 15th day of current day and year.
	var d1 = Date.parse("15");

	// July 1st of current year at 10pm.
	var d1 = Date.parse("7/1 10pm");
	
* * @param {String} The string value to convert into a Date object [Required] * @return {Date} A Date object or null if the string cannot be converted into a Date. */ var parseUtils = { removeOrds: function (s) { ords = s.match(/\b(\d+)(?:st|nd|rd|th)\b/); // find ordinal matches s = ((ords && ords.length === 2) ? s.replace(ords[0], ords[1]) : s); return s; }, grammarParser: function (s) { var r = null; try { r = $D.Grammar.start.call({}, s.replace(/^\s*(\S*(\s+\S+)*)\s*$/, "$1")); } catch (e) { return null; } return ((r[1].length === 0) ? r[0] : null); }, nativeFallback: function(s) { var t; try { // ok we haven't parsed it, last ditch attempt with the built-in parser. t = Date._parse(s); return (t || t === 0) ? new Date(t) : null; } catch (e) { return null; } } }; function parse (s) { var d; if (!s) { return null; } if (s instanceof Date) { return s.clone(); } if (s.length >= 4 && s.charAt(0) !== "0" && s.charAt(0) !== "+"&& s.charAt(0) !== "-") { // ie: 2004 will pass, 0800 won't. // Start with specific formats d = $D.Parsing.ISO.parse(s) || $D.Parsing.Numeric.parse(s); } if (d instanceof Date && !isNaN(d.getTime())) { return d; } else { // find ordinal dates (1st, 3rd, 8th, etc and remove them as they cause parsing issues) s = $D.Parsing.Normalizer.parse(parseUtils.removeOrds(s)); d = parseUtils.grammarParser(s); if (d !== null) { return d; } else { return parseUtils.nativeFallback(s); } } } if (!$D._parse) { $D._parse = $D.parse; } $D.parse = parse; Date.getParseFunction = function (fx) { var fns = Date.Grammar.allformats(fx); return function (s) { var r = null; for (var i = 0; i < fns.length; i++) { try { r = fns[i].call({}, s); } catch (e) { continue; } if (r[1].length === 0) { return r[0]; } } return null; }; }; /** * Converts the specified string value into its JavaScript Date equivalent using the specified format {String} or formats {Array} and the CultureInfo specific format information. * The format of the string value must match one of the supplied formats exactly. * * Example

	// 15-Oct-2004
	var d1 = Date.parseExact("10/15/2004", "M/d/yyyy");

	// 15-Oct-2004
	var d1 = Date.parse("15-Oct-2004", "M-ddd-yyyy");

	// 15-Oct-2004
	var d1 = Date.parse("2004.10.15", "yyyy.MM.dd");

	// Multiple formats
	var d1 = Date.parseExact("10/15/2004", ["M/d/yyyy", "MMMM d, yyyy"]);
	
* * @param {String} The string value to convert into a Date object [Required]. * @param {Object} The expected format {String} or an array of expected formats {Array} of the date string [Required]. * @return {Date} A Date object or null if the string cannot be converted into a Date. */ $D.parseExact = function (s, fx) { return $D.getParseFunction(fx)(s); }; }()); (function () { var $D = Date, $P = $D.prototype, // $C = $D.CultureInfo, // not used atm p = function (s, l) { if (!l) { l = 2; } return ("000" + s).slice(l * -1); }; /** * Converts a PHP format string to Java/.NET format string. * A PHP format string can be used with ._format or .format. * A Java/.NET format string can be used with .toString(). * The .parseExact function will only accept a Java/.NET format string * * Example * var f1 = "%m/%d/%y" * var f2 = Date.normalizeFormat(f1); // "MM/dd/yy" * * new Date().format(f1); // "04/13/08" * new Date()._format(f1); // "04/13/08" * new Date().toString(f2); // "04/13/08" * * var date = Date.parseExact("04/13/08", f2); // Sun Apr 13 2008 * * @param {String} A PHP format string consisting of one or more format spcifiers. * @return {String} The PHP format converted to a Java/.NET format string. */ var normalizerSubstitutions = { "d" : "dd", "%d": "dd", "D" : "ddd", "%a": "ddd", "j" : "dddd", "l" : "dddd", "%A": "dddd", "S" : "S", "F" : "MMMM", "%B": "MMMM", "m" : "MM", "%m": "MM", "M" : "MMM", "%b": "MMM", "%h": "MMM", "n" : "M", "Y" : "yyyy", "%Y": "yyyy", "y" : "yy", "%y": "yy", "g" : "h", "%I": "h", "G" : "H", "h" : "hh", "H" : "HH", "%H": "HH", "i" : "mm", "%M": "mm", "s" : "ss", "%S": "ss", "%r": "hh:mm tt", "%R": "H:mm", "%T": "H:mm:ss", "%X": "t", "%x": "d", "%e": "d", "%D": "MM/dd/yy", "%n": "\\n", "%t": "\\t", "e" : "z", "T" : "z", "%z": "z", "%Z": "z", "Z" : "ZZ", "N" : "u", "w" : "u", "%w": "u", "W" : "W", "%V": "W" }; var normalizer = { substitutes: function (m) { return normalizerSubstitutions[m]; }, interpreted: function (m, x) { var y; switch (m) { case "%u": return x.getDay() + 1; case "z": return x.getOrdinalNumber(); case "%j": return p(x.getOrdinalNumber(), 3); case "%U": var d1 = x.clone().set({month: 0, day: 1}).addDays(-1).moveToDayOfWeek(0), d2 = x.clone().addDays(1).moveToDayOfWeek(0, -1); return (d2 < d1) ? "00" : p((d2.getOrdinalNumber() - d1.getOrdinalNumber()) / 7 + 1); case "%W": return p(x.getWeek()); case "t": return $D.getDaysInMonth(x.getFullYear(), x.getMonth()); case "o": case "%G": return x.setWeek(x.getISOWeek()).toString("yyyy"); case "%g": return x._format("%G").slice(-2); case "a": case "%p": return t("tt").toLowerCase(); case "A": return t("tt").toUpperCase(); case "u": return p(x.getMilliseconds(), 3); case "I": return (x.isDaylightSavingTime()) ? 1 : 0; case "O": return x.getUTCOffset(); case "P": y = x.getUTCOffset(); return y.substring(0, y.length - 2) + ":" + y.substring(y.length - 2); case "B": var now = new Date(); return Math.floor(((now.getHours() * 3600) + (now.getMinutes() * 60) + now.getSeconds() + (now.getTimezoneOffset() + 60) * 60) / 86.4); case "c": return x.toISOString().replace(/\"/g, ""); case "U": return $D.strtotime("now"); case "%c": return t("d") + " " + t("t"); case "%C": return Math.floor(x.getFullYear() / 100 + 1); } }, shouldOverrideDefaults: function (m) { switch (m) { case "%e": return true; default: return false; } }, parse: function (m, context) { var formatString, c = context || new Date(); formatString = normalizer.substitutes(m); if (formatString) { return formatString; } formatString = normalizer.interpreted(m, c); if (formatString) { return formatString; } else { return m; } } }; $D.normalizeFormat = function (format, context) { return format.replace(/(%|\\)?.|%%/g, function(t){ return normalizer.parse(t, context); }); }; /** * Format a local Unix timestamp according to locale settings * * Example: * Date.strftime("%m/%d/%y", new Date()); // "04/13/08" * Date.strftime("c", "2008-04-13T17:52:03Z"); // "04/13/08" * * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @param {Number|String} The number representing the number of seconds that have elapsed since January 1, 1970 (local time). * @return {String} A string representation of the current Date object. */ $D.strftime = function (format, time) { var d = Date.parse(time); return d._format(format); }; /** * Parse any textual datetime description into a Unix timestamp. * A Unix timestamp is the number of seconds that have elapsed since January 1, 1970 (midnight UTC/GMT). * * Example: * Date.strtotime("04/13/08"); // 1208044800 * Date.strtotime("1970-01-01T00:00:00Z"); // 0 * * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @param {Object} A string or date object. * @return {String} A string representation of the current Date object. */ $D.strtotime = function (time) { var d = $D.parse(time); return Math.round($D.UTC(d.getUTCFullYear(), d.getUTCMonth(), d.getUTCDate(), d.getUTCHours(), d.getUTCMinutes(), d.getUTCSeconds(), d.getUTCMilliseconds()) / 1000); }; /** * Converts the value of the current Date object to its equivalent string representation using a PHP/Unix style of date format specifiers. * Format Specifiers * Format Description Example * ------ --------------------------------------------------------------------------- ----------------------- * %a abbreviated weekday name according to the current localed "Mon" through "Sun" * %A full weekday name according to the current localed "Sunday" through "Saturday" * %b abbreviated month name according to the current localed "Jan" through "Dec" * %B full month name according to the current locale "January" through "December" * %c preferred date and time representation for the current locale "4/13/2008 12:33 PM" * %C century number (the year divided by 100 and truncated to an integer) "00" to "99" * %d day of the month as a decimal number "01" to "31" * %D same as %m/%d/%y "04/13/08" * %e day of the month as a decimal number, a single digit is preceded by a space "1" to "31" * %g like %G, but without the century "08" * %G The 4-digit year corresponding to the ISO week number (see %V). "2008" * This has the same format and value as %Y, except that if the ISO week number * belongs to the previous or next year, that year is used instead. * %h same as %b "Jan" through "Dec" * %H hour as a decimal number using a 24-hour clock. "00" to "23" * %I hour as a decimal number using a 12-hour clock. "01" to "12" * %j day of the year as a decimal number. "001" to "366" * %m month as a decimal number. "01" to "12" * %M minute as a decimal number. "00" to "59" * %n newline character "\n" * %p either "am" or "pm" according to the given time value, or the "am" or "pm" * corresponding strings for the current locale. * %r time in a.m. and p.m. notation "8:44 PM" * %R time in 24 hour notation "20:44" * %S second as a decimal number "00" to "59" * %t tab character "\t" * %T current time, equal to %H:%M:%S "12:49:11" * %u weekday as a decimal number ["1", "7"], with "1" representing Monday "1" to "7" * %U week number of the current year as a decimal number, starting with the "0" to ("52" or "53") * first Sunday as the first day of the first week * %V The ISO 8601:1988 week number of the current year as a decimal number, "00" to ("52" or "53") * range 01 to 53, where week 1 is the first week that has at least 4 days * in the current year, and with Monday as the first day of the week. * (Use %G or %g for the year component that corresponds to the week number * for the specified timestamp.) * %W week number of the current year as a decimal number, starting with the "00" to ("52" or "53") * first Monday as the first day of the first week * %w day of the week as a decimal, Sunday being "0" "0" to "6" * %x preferred date representation for the current locale without the time "4/13/2008" * %X preferred time representation for the current locale without the date "12:53:05" * %y year as a decimal number without a century "00" "99" * %Y year as a decimal number including the century "2008" * %Z time zone or name or abbreviation "UTC", "EST", "PST" * %z same as %Z * %% a literal "%" characters "%" * d Day of the month, 2 digits with leading zeros "01" to "31" * D A textual representation of a day, three letters "Mon" through "Sun" * j Day of the month without leading zeros "1" to "31" * l A full textual representation of the day of the week (lowercase "L") "Sunday" through "Saturday" * N ISO-8601 numeric representation of the day of the week (added in PHP 5.1.0) "1" (for Monday) through "7" (for Sunday) * S English ordinal suffix for the day of the month, 2 characters "st", "nd", "rd" or "th". Works well with j * w Numeric representation of the day of the week "0" (for Sunday) through "6" (for Saturday) * z The day of the year (starting from "0") "0" through "365" * W ISO-8601 week number of year, weeks starting on Monday "00" to ("52" or "53") * F A full textual representation of a month, such as January or March "January" through "December" * m Numeric representation of a month, with leading zeros "01" through "12" * M A short textual representation of a month, three letters "Jan" through "Dec" * n Numeric representation of a month, without leading zeros "1" through "12" * t Number of days in the given month "28" through "31" * L Whether it's a leap year "1" if it is a leap year, "0" otherwise * o ISO-8601 year number. This has the same value as Y, except that if the "2008" * ISO week number (W) belongs to the previous or next year, that year * is used instead. * Y A full numeric representation of a year, 4 digits "2008" * y A two digit representation of a year "08" * a Lowercase Ante meridiem and Post meridiem "am" or "pm" * A Uppercase Ante meridiem and Post meridiem "AM" or "PM" * B Swatch Internet time "000" through "999" * g 12-hour format of an hour without leading zeros "1" through "12" * G 24-hour format of an hour without leading zeros "0" through "23" * h 12-hour format of an hour with leading zeros "01" through "12" * H 24-hour format of an hour with leading zeros "00" through "23" * i Minutes with leading zeros "00" to "59" * s Seconds, with leading zeros "00" through "59" * u Milliseconds "54321" * e Timezone identifier "UTC", "EST", "PST" * I Whether or not the date is in daylight saving time (uppercase i) "1" if Daylight Saving Time, "0" otherwise * O Difference to Greenwich time (GMT) in hours "+0200", "-0600" * P Difference to Greenwich time (GMT) with colon between hours and minutes "+02:00", "-06:00" * T Timezone abbreviation "UTC", "EST", "PST" * Z Timezone offset in seconds. The offset for timezones west of UTC is "-43200" through "50400" * always negative, and for those east of UTC is always positive. * c ISO 8601 date "2004-02-12T15:19:21+00:00" * r RFC 2822 formatted date "Thu, 21 Dec 2000 16:01:07 +0200" * U Seconds since the Unix Epoch (January 1 1970 00:00:00 GMT) "0" * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @return {String} A string representation of the current Date object. */ var formatReplace = function (context) { return function (m) { var formatString, override = false; if (m.charAt(0) === "\\" || m.substring(0, 2) === "%%") { return m.replace("\\", "").replace("%%", "%"); } override = normalizer.shouldOverrideDefaults(m); formatString = $D.normalizeFormat(m, context); if (formatString) { return context.toString(formatString, override); } }; }; $P._format = function (format) { var formatter = formatReplace(this); if (!format) { return this._toString(); } else { return format.replace(/(%|\\)?.|%%/g, formatter); } }; if (!$P.format) { $P.format = $P._format; } }()); (function () { "use strict"; var gFn = function (attr) { return function () { return this[attr]; }; }; var sFn = function (attr) { return function (val) { this[attr] = val; return this; }; }; var attrs = ["years", "months", "days", "hours", "minutes", "seconds", "milliseconds"]; var addSetFuncs = function (context, attrs) { for (var i = 0; i < attrs.length ; i++) { var $a = attrs[i], $b = $a.slice(0, 1).toUpperCase() + $a.slice(1); context.prototype[$a] = 0; context.prototype["get" + $b] = gFn($a); context.prototype["set" + $b] = sFn($a); } }; /** * new TimeSpan(milliseconds); * new TimeSpan(days, hours, minutes, seconds); * new TimeSpan(days, hours, minutes, seconds, milliseconds); */ var TimeSpan = function (days, hours, minutes, seconds, milliseconds) { if (arguments.length === 1 && typeof days === "number") { var orient = (days < 0) ? -1 : +1; var millsLeft = Math.abs(days); this.setDays(Math.floor(millsLeft / 86400000) * orient); millsLeft = millsLeft % 86400000; this.setHours(Math.floor(millsLeft / 3600000) * orient); millsLeft = millsLeft % 3600000; this.setMinutes(Math.floor(millsLeft / 60000) * orient); millsLeft = millsLeft % 60000; this.setSeconds(Math.floor(millsLeft / 1000) * orient); millsLeft = millsLeft % 1000; this.setMilliseconds(millsLeft * orient); } else { this.set(days, hours, minutes, seconds, milliseconds); } this.getTotalMilliseconds = function () { return (this.getDays() * 86400000) + (this.getHours() * 3600000) + (this.getMinutes() * 60000) + (this.getSeconds() * 1000); }; this.compareTo = function (time) { var t1 = new Date(1970, 1, 1, this.getHours(), this.getMinutes(), this.getSeconds()), t2; if (time === null) { t2 = new Date(1970, 1, 1, 0, 0, 0); } else { t2 = new Date(1970, 1, 1, time.getHours(), time.getMinutes(), time.getSeconds()); } return (t1 < t2) ? -1 : (t1 > t2) ? 1 : 0; }; this.equals = function (time) { return (this.compareTo(time) === 0); }; this.add = function (time) { return (time === null) ? this : this.addSeconds(time.getTotalMilliseconds() / 1000); }; this.subtract = function (time) { return (time === null) ? this : this.addSeconds(-time.getTotalMilliseconds() / 1000); }; this.addDays = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 86400000)); }; this.addHours = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 3600000)); }; this.addMinutes = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 60000)); }; this.addSeconds = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 1000)); }; this.addMilliseconds = function (n) { return new TimeSpan(this.getTotalMilliseconds() + n); }; this.get12HourHour = function () { return (this.getHours() > 12) ? this.getHours() - 12 : (this.getHours() === 0) ? 12 : this.getHours(); }; this.getDesignator = function () { return (this.getHours() < 12) ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator; }; this.toString = function (format) { this._toString = function () { if (this.getDays() !== null && this.getDays() > 0) { return this.getDays() + "." + this.getHours() + ":" + this.p(this.getMinutes()) + ":" + this.p(this.getSeconds()); } else { return this.getHours() + ":" + this.p(this.getMinutes()) + ":" + this.p(this.getSeconds()); } }; this.p = function (s) { return (s.toString().length < 2) ? "0" + s : s; }; var me = this; return format ? format.replace(/dd?|HH?|hh?|mm?|ss?|tt?/g, function (format) { switch (format) { case "d": return me.getDays(); case "dd": return me.p(me.getDays()); case "H": return me.getHours(); case "HH": return me.p(me.getHours()); case "h": return me.get12HourHour(); case "hh": return me.p(me.get12HourHour()); case "m": return me.getMinutes(); case "mm": return me.p(me.getMinutes()); case "s": return me.getSeconds(); case "ss": return me.p(me.getSeconds()); case "t": return ((me.getHours() < 12) ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator).substring(0, 1); case "tt": return (me.getHours() < 12) ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator; } } ) : this._toString(); }; return this; }; addSetFuncs(TimeSpan, attrs.slice(2)); TimeSpan.prototype.set = function (days, hours, minutes, seconds, milliseconds){ this.setDays(days || this.getDays()); this.setHours(hours || this.getHours()); this.setMinutes(minutes || this.getMinutes()); this.setSeconds(seconds || this.getSeconds()); this.setMilliseconds(milliseconds || this.getMilliseconds()); }; /** * Gets the time of day for this date instances. * @return {TimeSpan} TimeSpan */ Date.prototype.getTimeOfDay = function () { return new TimeSpan(0, this.getHours(), this.getMinutes(), this.getSeconds(), this.getMilliseconds()); }; Date.TimeSpan = TimeSpan; if (typeof window !== "undefined" ) { // keeping API compatible for v1.x window.TimeSpan = TimeSpan; } }()); (function () { "use strict"; var attrs = ["years", "months", "days", "hours", "minutes", "seconds", "milliseconds"]; var gFn = function (attr) { return function () { return this[attr]; }; }; var sFn = function (attr) { return function (val) { this[attr] = val; return this; }; }; var addSetFuncs = function (context, attrs) { for (var i = 0; i < attrs.length ; i++) { var $a = attrs[i], $b = $a.slice(0, 1).toUpperCase() + $a.slice(1); context.prototype[$a] = 0; context.prototype["get" + $b] = gFn($a); context.prototype["set" + $b] = sFn($a); } }; var setMonthsAndYears = function (orient, d1, d2, context) { function inc() { d1.addMonths(-orient); context.months++; if (context.months === 12) { context.years++; context.months = 0; } } if (orient === +1) { while (d1 > d2) { inc(); } } else { while (d1 < d2) { inc(); } } context.months--; context.months *= orient; context.years *= orient; }; var adjustForDST = function(orient, startDate, endDate) { var hasDSTMismatch = (false === (startDate.isDaylightSavingTime() === endDate.isDaylightSavingTime())); if (hasDSTMismatch && orient === 1) { startDate.addHours(-1); } else if (hasDSTMismatch) { startDate.addHours(1); } }; /** * TimePeriod(startDate, endDate); * TimePeriod(years, months, days, hours, minutes, seconds, milliseconds); */ var TimePeriod = function (years, months, days, hours, minutes, seconds, milliseconds) { if (arguments.length === 7) { this.set(years, months, days, hours, minutes, seconds, milliseconds); } else if (arguments.length === 2 && arguments[0] instanceof Date && arguments[1] instanceof Date) { var startDate = arguments[0].clone(); var endDate = arguments[1].clone(); var orient = (startDate > endDate) ? +1 : -1; this.dates = { start: arguments[0].clone(), end: arguments[1].clone() }; setMonthsAndYears(orient, startDate, endDate, this); adjustForDST(orient, startDate, endDate); // // TODO - adjust for DST var diff = endDate - startDate; if (diff !== 0) { var ts = new TimeSpan(diff); this.set(this.years, this.months, ts.getDays(), ts.getHours(), ts.getMinutes(), ts.getSeconds(), ts.getMilliseconds()); } } return this; }; // create all the set functions. addSetFuncs(TimePeriod, attrs); TimePeriod.prototype.set = function (years, months, days, hours, minutes, seconds, milliseconds){ this.setYears(years || this.getYears()); this.setMonths(months || this.getMonths()); this.setDays(days || this.getDays()); this.setHours(hours || this.getHours()); this.setMinutes(minutes || this.getMinutes()); this.setSeconds(seconds || this.getSeconds()); this.setMilliseconds(milliseconds || this.getMilliseconds()); }; Date.TimePeriod = TimePeriod; if (typeof window !== "undefined") { // keeping API compatible for v1.x window.TimePeriod = TimePeriod; } }()); ================================================ FILE: build/date.js ================================================ /** * @overview datejs * @version 1.0.0-rc3 * @author Gregory Wild-Smith * @copyright 2015 Gregory Wild-Smith * @license MIT * @homepage https://github.com/abritinthebay/datejs */(function () { var $D = Date; var lang = Date.CultureStrings ? Date.CultureStrings.lang : null; var loggedKeys = {}; // for debug purposes. var getText = { getFromKey: function (key, countryCode) { var output; if (Date.CultureStrings && Date.CultureStrings[countryCode] && Date.CultureStrings[countryCode][key]) { output = Date.CultureStrings[countryCode][key]; } else { output = getText.buildFromDefault(key); } if (key.charAt(0) === "/") { // Assume it's a regex output = getText.buildFromRegex(key, countryCode); } return output; }, getFromObjectValues: function (obj, countryCode) { var key, output = {}; for(key in obj) { if (obj.hasOwnProperty(key)) { output[key] = getText.getFromKey(obj[key], countryCode); } } return output; }, getFromObjectKeys: function (obj, countryCode) { var key, output = {}; for(key in obj) { if (obj.hasOwnProperty(key)) { output[getText.getFromKey(key, countryCode)] = obj[key]; } } return output; }, getFromArray: function (arr, countryCode) { var output = []; for (var i=0; i < arr.length; i++){ if (i in arr) { output[i] = getText.getFromKey(arr[i], countryCode); } } return output; }, buildFromDefault: function (key) { var output, length, split, last; switch(key) { case "name": output = "en-US"; break; case "englishName": output = "English (United States)"; break; case "nativeName": output = "English (United States)"; break; case "twoDigitYearMax": output = 2049; break; case "firstDayOfWeek": output = 0; break; default: output = key; split = key.split("_"); length = split.length; if (length > 1 && key.charAt(0) !== "/") { // if the key isn't a regex and it has a split. last = split[(length - 1)].toLowerCase(); if (last === "initial" || last === "abbr") { output = split[0]; } } break; } return output; }, buildFromRegex: function (key, countryCode) { var output; if (Date.CultureStrings && Date.CultureStrings[countryCode] && Date.CultureStrings[countryCode][key]) { output = new RegExp(Date.CultureStrings[countryCode][key], "i"); } else { output = new RegExp(key.replace(new RegExp("/", "g"),""), "i"); } return output; } }; var shallowMerge = function (obj1, obj2) { for (var attrname in obj2) { if (obj2.hasOwnProperty(attrname)) { obj1[attrname] = obj2[attrname]; } } }; var __ = function (key, language) { var countryCode = (language) ? language : lang; loggedKeys[key] = key; if (typeof key === "object") { if (key instanceof Array) { return getText.getFromArray(key, countryCode); } else { return getText.getFromObjectKeys(key, countryCode); } } else { return getText.getFromKey(key, countryCode); } }; var loadI18nScript = function (code) { // paatterned after jQuery's getScript. var url = Date.Config.i18n + code + ".js"; var head = document.getElementsByTagName("head")[0] || document.documentElement; var script = document.createElement("script"); script.src = url; var completed = false; var events = { done: function (){} // placeholder function }; // Attach handlers for all browsers script.onload = script.onreadystatechange = function() { if ( !completed && (!this.readyState || this.readyState === "loaded" || this.readyState === "complete") ) { events.done(); head.removeChild(script); } }; setTimeout(function() { head.insertBefore(script, head.firstChild); }, 0); // allows return to execute first return { done: function (cb) { events.done = function() { if (cb) { setTimeout(cb,0); } }; } }; }; var buildInfo = { buildFromMethodHash: function (obj) { var key; for(key in obj) { if (obj.hasOwnProperty(key)) { obj[key] = buildInfo[obj[key]](); } } return obj; }, timeZoneDST: function () { var DST = { "CHADT": "+1345", "NZDT": "+1300", "AEDT": "+1100", "ACDT": "+1030", "AZST": "+0500", "IRDT": "+0430", "EEST": "+0300", "CEST": "+0200", "BST": "+0100", "PMDT": "-0200", "ADT": "-0300", "NDT": "-0230", "EDT": "-0400", "CDT": "-0500", "MDT": "-0600", "PDT": "-0700", "AKDT": "-0800", "HADT": "-0900" }; return __(DST); }, timeZoneStandard: function () { var standard = { "LINT": "+1400", "TOT": "+1300", "CHAST": "+1245", "NZST": "+1200", "NFT": "+1130", "SBT": "+1100", "AEST": "+1000", "ACST": "+0930", "JST": "+0900", "CWST": "+0845", "CT": "+0800", "ICT": "+0700", "MMT": "+0630", "BST": "+0600", "NPT": "+0545", "IST": "+0530", "PKT": "+0500", "AFT": "+0430", "MSK": "+0400", "IRST": "+0330", "FET": "+0300", "EET": "+0200", "CET": "+0100", "GMT": "+0000", "UTC": "+0000", "CVT": "-0100", "GST": "-0200", "BRT": "-0300", "NST": "-0330", "AST": "-0400", "EST": "-0500", "CST": "-0600", "MST": "-0700", "PST": "-0800", "AKST": "-0900", "MIT": "-0930", "HST": "-1000", "SST": "-1100", "BIT": "-1200" }; return __(standard); }, timeZones: function (data) { var zone; data.timezones = []; for (zone in data.abbreviatedTimeZoneStandard) { if (data.abbreviatedTimeZoneStandard.hasOwnProperty(zone)) { data.timezones.push({ name: zone, offset: data.abbreviatedTimeZoneStandard[zone]}); } } for (zone in data.abbreviatedTimeZoneDST) { if (data.abbreviatedTimeZoneDST.hasOwnProperty(zone)) { data.timezones.push({ name: zone, offset: data.abbreviatedTimeZoneDST[zone], dst: true}); } } return data.timezones; }, days: function () { return __(["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"]); }, dayAbbr: function () { return __(["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"]); }, dayShortNames: function () { return __(["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"]); }, dayFirstLetters: function () { return __(["S_Sun_Initial", "M_Mon_Initial", "T_Tues_Initial", "W_Wed_Initial", "T_Thu_Initial", "F_Fri_Initial", "S_Sat_Initial"]); }, months: function () { return __(["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"]); }, monthAbbr: function () { return __(["Jan_Abbr", "Feb_Abbr", "Mar_Abbr", "Apr_Abbr", "May_Abbr", "Jun_Abbr", "Jul_Abbr", "Aug_Abbr", "Sep_Abbr", "Oct_Abbr", "Nov_Abbr", "Dec_Abbr"]); }, formatPatterns: function () { return getText.getFromObjectValues({ shortDate: "M/d/yyyy", longDate: "dddd, MMMM dd, yyyy", shortTime: "h:mm tt", longTime: "h:mm:ss tt", fullDateTime: "dddd, MMMM dd, yyyy h:mm:ss tt", sortableDateTime: "yyyy-MM-ddTHH:mm:ss", universalSortableDateTime: "yyyy-MM-dd HH:mm:ssZ", rfc1123: "ddd, dd MMM yyyy HH:mm:ss", monthDay: "MMMM dd", yearMonth: "MMMM, yyyy" }, Date.i18n.currentLanguage()); }, regex: function () { return getText.getFromObjectValues({ inTheMorning: "/( in the )(morn(ing)?)\\b/", thisMorning: "/(this )(morn(ing)?)\\b/", amThisMorning: "/(\b\\d(am)? )(this )(morn(ing)?)/", inTheEvening: "/( in the )(even(ing)?)\\b/", thisEvening: "/(this )(even(ing)?)\\b/", pmThisEvening: "/(\b\\d(pm)? )(this )(even(ing)?)/", jan: "/jan(uary)?/", feb: "/feb(ruary)?/", mar: "/mar(ch)?/", apr: "/apr(il)?/", may: "/may/", jun: "/jun(e)?/", jul: "/jul(y)?/", aug: "/aug(ust)?/", sep: "/sep(t(ember)?)?/", oct: "/oct(ober)?/", nov: "/nov(ember)?/", dec: "/dec(ember)?/", sun: "/^su(n(day)?)?/", mon: "/^mo(n(day)?)?/", tue: "/^tu(e(s(day)?)?)?/", wed: "/^we(d(nesday)?)?/", thu: "/^th(u(r(s(day)?)?)?)?/", fri: "/fr(i(day)?)?/", sat: "/^sa(t(urday)?)?/", future: "/^next/", past: "/^last|past|prev(ious)?/", add: "/^(\\+|aft(er)?|from|hence)/", subtract: "/^(\\-|bef(ore)?|ago)/", yesterday: "/^yes(terday)?/", today: "/^t(od(ay)?)?/", tomorrow: "/^tom(orrow)?/", now: "/^n(ow)?/", millisecond: "/^ms|milli(second)?s?/", second: "/^sec(ond)?s?/", minute: "/^mn|min(ute)?s?/", hour: "/^h(our)?s?/", week: "/^w(eek)?s?/", month: "/^m(onth)?s?/", day: "/^d(ay)?s?/", year: "/^y(ear)?s?/", shortMeridian: "/^(a|p)/", longMeridian: "/^(a\\.?m?\\.?|p\\.?m?\\.?)/", timezone: "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/", ordinalSuffix: "/^\\s*(st|nd|rd|th)/", timeContext: "/^\\s*(\\:|a(?!u|p)|p)/" }, Date.i18n.currentLanguage()); } }; var CultureInfo = function () { var info = getText.getFromObjectValues({ name: "name", englishName: "englishName", nativeName: "nativeName", amDesignator: "AM", pmDesignator: "PM", firstDayOfWeek: "firstDayOfWeek", twoDigitYearMax: "twoDigitYearMax", dateElementOrder: "mdy" }, Date.i18n.currentLanguage()); var constructedInfo = buildInfo.buildFromMethodHash({ dayNames: "days", abbreviatedDayNames: "dayAbbr", shortestDayNames: "dayShortNames", firstLetterDayNames: "dayFirstLetters", monthNames: "months", abbreviatedMonthNames: "monthAbbr", formatPatterns: "formatPatterns", regexPatterns: "regex", abbreviatedTimeZoneDST: "timeZoneDST", abbreviatedTimeZoneStandard: "timeZoneStandard" }); shallowMerge(info, constructedInfo); buildInfo.timeZones(info); return info; }; $D.i18n = { __: function (key, lang) { return __(key, lang); }, currentLanguage: function () { return lang || "en-US"; }, setLanguage: function (code, force, cb) { var async = false; if (force || code === "en-US" || (!!Date.CultureStrings && !!Date.CultureStrings[code])) { lang = code; Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings.lang = code; Date.CultureInfo = new CultureInfo(); } else { if (!(!!Date.CultureStrings && !!Date.CultureStrings[code])) { if (typeof exports !== "undefined" && this.exports !== exports) { // we're in a Node enviroment, load it using require try { require("../i18n/" + code + ".js"); lang = code; Date.CultureStrings.lang = code; Date.CultureInfo = new CultureInfo(); } catch (e) { // var str = "The language for '" + code + "' could not be loaded by Node. It likely does not exist."; throw new Error("The DateJS IETF language tag '" + code + "' could not be loaded by Node. It likely does not exist."); } } else if (Date.Config && Date.Config.i18n) { // we know the location of the files, so lets load them async = true; loadI18nScript(code).done(function(){ lang = code; Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings.lang = code; Date.CultureInfo = new CultureInfo(); $D.Parsing.Normalizer.buildReplaceData(); // because this is async if ($D.Grammar) { $D.Grammar.buildGrammarFormats(); // so we can parse those strings... } if (cb) { setTimeout(cb,0); } }); } else { Date.console.error("The DateJS IETF language tag '" + code + "' is not available and has not been loaded."); return false; } } } $D.Parsing.Normalizer.buildReplaceData(); // rebuild normalizer strings if ($D.Grammar) { $D.Grammar.buildGrammarFormats(); // so we can parse those strings... } if (!async && cb) { setTimeout(cb,0); } }, getLoggedKeys: function () { return loggedKeys; }, updateCultureInfo: function () { Date.CultureInfo = new CultureInfo(); } }; $D.i18n.updateCultureInfo(); // run automatically }()); (function () { var $D = Date, $P = $D.prototype, p = function (s, l) { if (!l) { l = 2; } return ("000" + s).slice(l * -1); }; if (typeof window !== "undefined" && typeof window.console !== "undefined" && typeof window.console.log !== "undefined") { $D.console = console; // used only to raise non-critical errors if available } else { // set mock so we don't give errors. $D.console = { log: function(){}, error: function(){} }; } $D.Config = $D.Config || {}; $D.initOverloads = function() { /** * Overload of Date.now. Allows an alternate call for Date.now where it returns the * current Date as an object rather than just milliseconds since the Unix Epoch. * * Also provides an implementation of now() for browsers (IE<9) that don't have it. * * Backwards compatible so with work with either: * Date.now() [returns ms] * or * Date.now(true) [returns Date] */ if (!$D.now) { $D._now = function now() { return new Date().getTime(); }; } else if (!$D._now) { $D._now = $D.now; } $D.now = function (returnObj) { if (returnObj) { return $D.present(); } else { return $D._now(); } }; if ( !$P.toISOString ) { $P.toISOString = function() { return this.getUTCFullYear() + "-" + p(this.getUTCMonth() + 1) + "-" + p(this.getUTCDate()) + "T" + p(this.getUTCHours()) + ":" + p(this.getUTCMinutes()) + ":" + p(this.getUTCSeconds()) + "." + String( (this.getUTCMilliseconds()/1000).toFixed(3)).slice(2, 5) + "Z"; }; } // private if ( $P._toString === undefined ){ $P._toString = $P.toString; } }; $D.initOverloads(); /** * Gets a date that is set to the current date. The time is set to the start of the day (00:00 or 12:00 AM). * @return {Date} The current date. */ $D.today = function () { return new Date().clearTime(); }; /** * Gets a date that is set to the current date and time (same as new Date, but chainable) * @return {Date} The current date. */ $D.present = function () { return new Date(); }; /** * Compares the first date to the second date and returns an number indication of their relative values. * @param {Date} First Date object to compare [Required]. * @param {Date} Second Date object to compare to [Required]. * @return {Number} -1 = date1 is lessthan date2. 0 = values are equal. 1 = date1 is greaterthan date2. */ $D.compare = function (date1, date2) { if (isNaN(date1) || isNaN(date2)) { throw new Error(date1 + " - " + date2); } else if (date1 instanceof Date && date2 instanceof Date) { return (date1 < date2) ? -1 : (date1 > date2) ? 1 : 0; } else { throw new TypeError(date1 + " - " + date2); } }; /** * Compares the first Date object to the second Date object and returns true if they are equal. * @param {Date} First Date object to compare [Required] * @param {Date} Second Date object to compare to [Required] * @return {Boolean} true if dates are equal. false if they are not equal. */ $D.equals = function (date1, date2) { return (date1.compareTo(date2) === 0); }; /** * Gets the language appropriate day name when given the day number(0-6) * eg - 0 == Sunday * @return {String} The day name */ $D.getDayName = function (n) { return Date.CultureInfo.dayNames[n]; }; /** * Gets the day number (0-6) if given a CultureInfo specific string which is a valid dayName, abbreviatedDayName or shortestDayName (two char). * @param {String} The name of the day (eg. "Monday, "Mon", "tuesday", "tue", "We", "we"). * @return {Number} The day number */ $D.getDayNumberFromName = function (name) { var n = Date.CultureInfo.dayNames, m = Date.CultureInfo.abbreviatedDayNames, o = Date.CultureInfo.shortestDayNames, s = name.toLowerCase(); for (var i = 0; i < n.length; i++) { if (n[i].toLowerCase() === s || m[i].toLowerCase() === s || o[i].toLowerCase() === s) { return i; } } return -1; }; /** * Gets the month number (0-11) if given a Culture Info specific string which is a valid monthName or abbreviatedMonthName. * @param {String} The name of the month (eg. "February, "Feb", "october", "oct"). * @return {Number} The day number */ $D.getMonthNumberFromName = function (name) { var n = Date.CultureInfo.monthNames, m = Date.CultureInfo.abbreviatedMonthNames, s = name.toLowerCase(); for (var i = 0; i < n.length; i++) { if (n[i].toLowerCase() === s || m[i].toLowerCase() === s) { return i; } } return -1; }; /** * Gets the language appropriate month name when given the month number(0-11) * eg - 0 == January * @return {String} The month name */ $D.getMonthName = function (n) { return Date.CultureInfo.monthNames[n]; }; /** * Determines if the current date instance is within a LeapYear. * @param {Number} The year. * @return {Boolean} true if date is within a LeapYear, otherwise false. */ $D.isLeapYear = function (year) { return ((year % 4 === 0 && year % 100 !== 0) || year % 400 === 0); }; /** * Gets the number of days in the month, given a year and month value. Automatically corrects for LeapYear. * @param {Number} The year. * @param {Number} The month (0-11). * @return {Number} The number of days in the month. */ $D.getDaysInMonth = function (year, month) { if (!month && $D.validateMonth(year)) { month = year; year = Date.today().getFullYear(); } return [31, ($D.isLeapYear(year) ? 29 : 28), 31, 30, 31, 30, 31, 31, 30, 31, 30, 31][month]; }; $P.getDaysInMonth = function () { return $D.getDaysInMonth(this.getFullYear(), this.getMonth()); }; $D.getTimezoneAbbreviation = function (offset, dst) { var p, n = (dst || false) ? Date.CultureInfo.abbreviatedTimeZoneDST : Date.CultureInfo.abbreviatedTimeZoneStandard; for (p in n) { if (n.hasOwnProperty(p)) { if (n[p] === offset) { return p; } } } return null; }; $D.getTimezoneOffset = function (name, dst) { var i, a =[], z = Date.CultureInfo.timezones; if (!name) { name = (new Date()).getTimezone();} for (i = 0; i < z.length; i++) { if (z[i].name === name.toUpperCase()) { a.push(i); } } if (!z[a[0]]) { return null; } if (a.length === 1 || !dst) { return z[a[0]].offset; } else { for (i=0; i < a.length; i++) { if (z[a[i]].dst) { return z[a[i]].offset; } } } }; $D.getQuarter = function (d) { d = d || new Date(); // If no date supplied, use today var q = [1,2,3,4]; return q[Math.floor(d.getMonth() / 3)]; // ~~~ is a bitwise op. Faster than Math.floor }; $D.getDaysLeftInQuarter = function (d) { d = d || new Date(); var qEnd = new Date(d); qEnd.setMonth(qEnd.getMonth() + 3 - qEnd.getMonth() % 3, 0); return Math.floor((qEnd - d) / 8.64e7); }; // private var validate = function (n, min, max, name) { name = name ? name : "Object"; if (typeof n === "undefined") { return false; } else if (typeof n !== "number") { throw new TypeError(n + " is not a Number."); } else if (n < min || n > max) { // As failing validation is *not* an exceptional circumstance // lets not throw a RangeError Exception here. // It's semantically correct but it's not sensible. return false; } return true; }; /** * Validates the number is within an acceptable range for milliseconds [0-999]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateMillisecond = function (value) { return validate(value, 0, 999, "millisecond"); }; /** * Validates the number is within an acceptable range for seconds [0-59]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateSecond = function (value) { return validate(value, 0, 59, "second"); }; /** * Validates the number is within an acceptable range for minutes [0-59]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateMinute = function (value) { return validate(value, 0, 59, "minute"); }; /** * Validates the number is within an acceptable range for hours [0-23]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateHour = function (value) { return validate(value, 0, 23, "hour"); }; /** * Validates the number is within an acceptable range for the days in a month [0-MaxDaysInMonth]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateDay = function (value, year, month) { if (year === undefined || year === null || month === undefined || month === null) { return false;} return validate(value, 1, $D.getDaysInMonth(year, month), "day"); }; /** * Validates the number is within an acceptable range for months [0-11]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateWeek = function (value) { return validate(value, 0, 53, "week"); }; /** * Validates the number is within an acceptable range for months [0-11]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateMonth = function (value) { return validate(value, 0, 11, "month"); }; /** * Validates the number is within an acceptable range for years. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateYear = function (value) { /** * Per ECMAScript spec the range of times supported by Date objects is * exactly -100,000,000 days to +100,000,000 days measured relative to * midnight at the beginning of 01 January, 1970 UTC. * This gives a range of 8,640,000,000,000,000 milliseconds to either * side of 01 January, 1970 UTC. * * Earliest possible date: Tue, 20 Apr 271,822 B.C. 00:00:00 UTC * Latest possible date: Sat, 13 Sep 275,760 00:00:00 UTC */ return validate(value, -271822, 275760, "year"); }; $D.validateTimezone = function(value) { var timezones = {"ACDT":1,"ACST":1,"ACT":1,"ADT":1,"AEDT":1,"AEST":1,"AFT":1,"AKDT":1,"AKST":1,"AMST":1,"AMT":1,"ART":1,"AST":1,"AWDT":1,"AWST":1,"AZOST":1,"AZT":1,"BDT":1,"BIOT":1,"BIT":1,"BOT":1,"BRT":1,"BST":1,"BTT":1,"CAT":1,"CCT":1,"CDT":1,"CEDT":1,"CEST":1,"CET":1,"CHADT":1,"CHAST":1,"CHOT":1,"ChST":1,"CHUT":1,"CIST":1,"CIT":1,"CKT":1,"CLST":1,"CLT":1,"COST":1,"COT":1,"CST":1,"CT":1,"CVT":1,"CWST":1,"CXT":1,"DAVT":1,"DDUT":1,"DFT":1,"EASST":1,"EAST":1,"EAT":1,"ECT":1,"EDT":1,"EEDT":1,"EEST":1,"EET":1,"EGST":1,"EGT":1,"EIT":1,"EST":1,"FET":1,"FJT":1,"FKST":1,"FKT":1,"FNT":1,"GALT":1,"GAMT":1,"GET":1,"GFT":1,"GILT":1,"GIT":1,"GMT":1,"GST":1,"GYT":1,"HADT":1,"HAEC":1,"HAST":1,"HKT":1,"HMT":1,"HOVT":1,"HST":1,"ICT":1,"IDT":1,"IOT":1,"IRDT":1,"IRKT":1,"IRST":1,"IST":1,"JST":1,"KGT":1,"KOST":1,"KRAT":1,"KST":1,"LHST":1,"LINT":1,"MAGT":1,"MART":1,"MAWT":1,"MDT":1,"MET":1,"MEST":1,"MHT":1,"MIST":1,"MIT":1,"MMT":1,"MSK":1,"MST":1,"MUT":1,"MVT":1,"MYT":1,"NCT":1,"NDT":1,"NFT":1,"NPT":1,"NST":1,"NT":1,"NUT":1,"NZDT":1,"NZST":1,"OMST":1,"ORAT":1,"PDT":1,"PET":1,"PETT":1,"PGT":1,"PHOT":1,"PHT":1,"PKT":1,"PMDT":1,"PMST":1,"PONT":1,"PST":1,"PYST":1,"PYT":1,"RET":1,"ROTT":1,"SAKT":1,"SAMT":1,"SAST":1,"SBT":1,"SCT":1,"SGT":1,"SLST":1,"SRT":1,"SST":1,"SYOT":1,"TAHT":1,"THA":1,"TFT":1,"TJT":1,"TKT":1,"TLT":1,"TMT":1,"TOT":1,"TVT":1,"UCT":1,"ULAT":1,"UTC":1,"UYST":1,"UYT":1,"UZT":1,"VET":1,"VLAT":1,"VOLT":1,"VOST":1,"VUT":1,"WAKT":1,"WAST":1,"WAT":1,"WEDT":1,"WEST":1,"WET":1,"WST":1,"YAKT":1,"YEKT":1,"Z":1}; return (timezones[value] === 1); }; $D.validateTimezoneOffset= function(value) { // timezones go from +14hrs to -12hrs, the +X hours are negative offsets. return (value > -841 && value < 721); }; }()); (function () { var $D = Date, $P = $D.prototype, p = function (s, l) { if (!l) { l = 2; } return ("000" + s).slice(l * -1); }; var validateConfigObject = function (obj) { var result = {}, self = this, prop, testFunc; testFunc = function (prop, func, value) { if (prop === "day") { var month = (obj.month !== undefined) ? obj.month : self.getMonth(); var year = (obj.year !== undefined) ? obj.year : self.getFullYear(); return $D[func](value, year, month); } else { return $D[func](value); } }; for (prop in obj) { if (Object.prototype.hasOwnProperty.call(obj, prop)) { var func = "validate" + prop.charAt(0).toUpperCase() + prop.slice(1); if ($D[func] && obj[prop] !== null && testFunc(prop, func, obj[prop])) { result[prop] = obj[prop]; } } } return result; }; /** * Resets the time of this Date object to 12:00 AM (00:00), which is the start of the day. * @param {Boolean} .clone() this date instance before clearing Time * @return {Date} this */ $P.clearTime = function () { this.setHours(0); this.setMinutes(0); this.setSeconds(0); this.setMilliseconds(0); return this; }; /** * Resets the time of this Date object to the current time ('now'). * @return {Date} this */ $P.setTimeToNow = function () { var n = new Date(); this.setHours(n.getHours()); this.setMinutes(n.getMinutes()); this.setSeconds(n.getSeconds()); this.setMilliseconds(n.getMilliseconds()); return this; }; /** * Returns a new Date object that is an exact date and time copy of the original instance. * @return {Date} A new Date instance */ $P.clone = function () { return new Date(this.getTime()); }; /** * Compares this instance to a Date object and returns an number indication of their relative values. * @param {Date} Date object to compare [Required] * @return {Number} -1 = this is lessthan date. 0 = values are equal. 1 = this is greaterthan date. */ $P.compareTo = function (date) { return Date.compare(this, date); }; /** * Compares this instance to another Date object and returns true if they are equal. * @param {Date} Date object to compare. If no date to compare, new Date() [now] is used. * @return {Boolean} true if dates are equal. false if they are not equal. */ $P.equals = function (date) { return Date.equals(this, (date !== undefined ? date : new Date())); }; /** * Determines if this instance is between a range of two dates or equal to either the start or end dates. * @param {Date} Start of range [Required] * @param {Date} End of range [Required] * @return {Boolean} true is this is between or equal to the start and end dates, else false */ $P.between = function (start, end) { return this.getTime() >= start.getTime() && this.getTime() <= end.getTime(); }; /** * Determines if this date occurs after the date to compare to. * @param {Date} Date object to compare. If no date to compare, new Date() ("now") is used. * @return {Boolean} true if this date instance is greater than the date to compare to (or "now"), otherwise false. */ $P.isAfter = function (date) { return this.compareTo(date || new Date()) === 1; }; /** * Determines if this date occurs before the date to compare to. * @param {Date} Date object to compare. If no date to compare, new Date() ("now") is used. * @return {Boolean} true if this date instance is less than the date to compare to (or "now"). */ $P.isBefore = function (date) { return (this.compareTo(date || new Date()) === -1); }; /** * Determines if the current Date instance occurs today. * @return {Boolean} true if this date instance is 'today', otherwise false. */ /** * Determines if the current Date instance occurs on the same Date as the supplied 'date'. * If no 'date' to compare to is provided, the current Date instance is compared to 'today'. * @param {date} Date object to compare. If no date to compare, the current Date ("now") is used. * @return {Boolean} true if this Date instance occurs on the same Day as the supplied 'date'. */ $P.isToday = $P.isSameDay = function (date) { return this.clone().clearTime().equals((date || new Date()).clone().clearTime()); }; /** * Adds the specified number of milliseconds to this instance. * @param {Number} The number of milliseconds to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addMilliseconds = function (value) { if (!value) { return this; } this.setTime(this.getTime() + value * 1); return this; }; /** * Adds the specified number of seconds to this instance. * @param {Number} The number of seconds to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addSeconds = function (value) { if (!value) { return this; } return this.addMilliseconds(value * 1000); }; /** * Adds the specified number of seconds to this instance. * @param {Number} The number of seconds to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addMinutes = function (value) { if (!value) { return this; } return this.addMilliseconds(value * 60000); // 60*1000 }; /** * Adds the specified number of hours to this instance. * @param {Number} The number of hours to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addHours = function (value) { if (!value) { return this; } return this.addMilliseconds(value * 3600000); // 60*60*1000 }; /** * Adds the specified number of days to this instance. * @param {Number} The number of days to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addDays = function (value) { if (!value) { return this; } this.setDate(this.getDate() + value * 1); return this; }; /** * Adds the specified number of weekdays (ie - not sat or sun) to this instance. * @param {Number} The number of days to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addWeekdays = function (value) { if (!value) { return this; } var day = this.getDay(); var weeks = (Math.ceil(Math.abs(value)/7)); if (day === 0 || day === 6) { if (value > 0) { this.next().monday(); this.addDays(-1); day = this.getDay(); } } if (value < 0) { while (value < 0) { this.addDays(-1); day = this.getDay(); if (day !== 0 && day !== 6) { value++; } } return this; } else if (value > 5 || (6-day) <= value) { value = value + (weeks * 2); } return this.addDays(value); }; /** * Adds the specified number of weeks to this instance. * @param {Number} The number of weeks to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addWeeks = function (value) { if (!value) { return this; } return this.addDays(value * 7); }; /** * Adds the specified number of months to this instance. * @param {Number} The number of months to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addMonths = function (value) { if (!value) { return this; } var n = this.getDate(); this.setDate(1); this.setMonth(this.getMonth() + value * 1); this.setDate(Math.min(n, $D.getDaysInMonth(this.getFullYear(), this.getMonth()))); return this; }; $P.addQuarters = function (value) { if (!value) { return this; } // note this will take you to the same point in the quarter as you are now. // i.e. - if you are 15 days into the quarter you'll be 15 days into the resulting one. // bonus: this allows adding fractional quarters return this.addMonths(value * 3); }; /** * Adds the specified number of years to this instance. * @param {Number} The number of years to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addYears = function (value) { if (!value) { return this; } return this.addMonths(value * 12); }; /** * Adds (or subtracts) to the value of the years, months, weeks, days, hours, minutes, seconds, milliseconds of the date instance using given configuration object. Positive and Negative values allowed. * Example

	Date.today().add( { days: 1, months: 1 } )

	new Date().add( { years: -1 } )
	
* @param {Object} Configuration object containing attributes (months, days, etc.) * @return {Date} this */ $P.add = function (config) { if (typeof config === "number") { this._orient = config; return this; } var x = config; if (x.day) { // If we should be a different date than today (eg: for 'tomorrow -1d', etc). // Should only effect parsing, not direct usage (eg, Finish and FinishExact) if ((x.day - this.getDate()) !== 0) { this.setDate(x.day); } } if (x.milliseconds) { this.addMilliseconds(x.milliseconds); } if (x.seconds) { this.addSeconds(x.seconds); } if (x.minutes) { this.addMinutes(x.minutes); } if (x.hours) { this.addHours(x.hours); } if (x.weeks) { this.addWeeks(x.weeks); } if (x.months) { this.addMonths(x.months); } if (x.years) { this.addYears(x.years); } if (x.days) { this.addDays(x.days); } return this; }; /** * Get the week number. Week one (1) is the week which contains the first Thursday of the year. Monday is considered the first day of the week. * The .getWeek() function does NOT convert the date to UTC. The local datetime is used. * Please use .getISOWeek() to get the week of the UTC converted date. * @return {Number} 1 to 53 */ $P.getWeek = function (utc) { // Create a copy of this date object var self, target = new Date(this.valueOf()); if (utc) { target.addMinutes(target.getTimezoneOffset()); self = target.clone(); } else { self = this; } // ISO week date weeks start on monday // so correct the day number var dayNr = (self.getDay() + 6) % 7; // ISO 8601 states that week 1 is the week // with the first thursday of that year. // Set the target date to the thursday in the target week target.setDate(target.getDate() - dayNr + 3); // Store the millisecond value of the target date var firstThursday = target.valueOf(); // Set the target to the first thursday of the year // First set the target to january first target.setMonth(0, 1); // Not a thursday? Correct the date to the next thursday if (target.getDay() !== 4) { target.setMonth(0, 1 + ((4 - target.getDay()) + 7) % 7); } // The weeknumber is the number of weeks between the // first thursday of the year and the thursday in the target week return 1 + Math.ceil((firstThursday - target) / 604800000); // 604800000 = 7 * 24 * 3600 * 1000 }; /** * Get the ISO 8601 week number. Week one ("01") is the week which contains the first Thursday of the year. Monday is considered the first day of the week. * The .getISOWeek() function does convert the date to it's UTC value. Please use .getWeek() to get the week of the local date. * @return {String} "01" to "53" */ $P.getISOWeek = function () { return p(this.getWeek(true)); }; /** * Moves the date to Monday of the week set. Week one (1) is the week which contains the first Thursday of the year. * @param {Number} A Number (1 to 53) that represents the week of the year. * @return {Date} this */ $P.setWeek = function (n) { if ((n - this.getWeek()) === 0) { if (this.getDay() !== 1) { return this.moveToDayOfWeek(1, (this.getDay() > 1 ? -1 : 1)); } else { return this; } } else { return this.moveToDayOfWeek(1, (this.getDay() > 1 ? -1 : 1)).addWeeks(n - this.getWeek()); } }; $P.setQuarter = function (qtr) { var month = Math.abs(((qtr-1) * 3) + 1); return this.setMonth(month, 1); }; $P.getQuarter = function () { return Date.getQuarter(this); }; $P.getDaysLeftInQuarter = function () { return Date.getDaysLeftInQuarter(this); }; /** * Moves the date to the next n'th occurrence of the dayOfWeek starting from the beginning of the month. The number (-1) is a magic number and will return the last occurrence of the dayOfWeek in the month. * @param {Number} The dayOfWeek to move to * @param {Number} The n'th occurrence to move to. Use (-1) to return the last occurrence in the month * @return {Date} this */ $P.moveToNthOccurrence = function (dayOfWeek, occurrence) { if (dayOfWeek === "Weekday") { if (occurrence > 0) { this.moveToFirstDayOfMonth(); if (this.is().weekday()) { occurrence -= 1; } } else if (occurrence < 0) { this.moveToLastDayOfMonth(); if (this.is().weekday()) { occurrence += 1; } } else { return this; } return this.addWeekdays(occurrence); } var shift = 0; if (occurrence > 0) { shift = occurrence - 1; } else if (occurrence === -1) { this.moveToLastDayOfMonth(); if (this.getDay() !== dayOfWeek) { this.moveToDayOfWeek(dayOfWeek, -1); } return this; } return this.moveToFirstDayOfMonth().addDays(-1).moveToDayOfWeek(dayOfWeek, +1).addWeeks(shift); }; var moveToN = function (getFunc, addFunc, nVal) { return function (value, orient) { var diff = (value - this[getFunc]() + nVal * (orient || +1)) % nVal; return this[addFunc]((diff === 0) ? diff += nVal * (orient || +1) : diff); }; }; /** * Move to the next or last dayOfWeek based on the orient value. * @param {Number} The dayOfWeek to move to * @param {Number} Forward (+1) or Back (-1). Defaults to +1. [Optional] * @return {Date} this */ $P.moveToDayOfWeek = moveToN("getDay", "addDays", 7); /** * Move to the next or last month based on the orient value. * @param {Number} The month to move to. 0 = January, 11 = December * @param {Number} Forward (+1) or Back (-1). Defaults to +1. [Optional] * @return {Date} this */ $P.moveToMonth = moveToN("getMonth", "addMonths", 12); /** * Get the Ordinate of the current day ("th", "st", "rd"). * @return {String} */ $P.getOrdinate = function () { var num = this.getDate(); return ord(num); }; /** * Get the Ordinal day (numeric day number) of the year, adjusted for leap year. * @return {Number} 1 through 365 (366 in leap years) */ $P.getOrdinalNumber = function () { return Math.ceil((this.clone().clearTime() - new Date(this.getFullYear(), 0, 1)) / 86400000) + 1; }; /** * Get the time zone abbreviation of the current date. * @return {String} The abbreviated time zone name (e.g. "EST") */ $P.getTimezone = function () { return $D.getTimezoneAbbreviation(this.getUTCOffset(), this.isDaylightSavingTime()); }; $P.setTimezoneOffset = function (offset) { var here = this.getTimezoneOffset(), there = Number(offset) * -6 / 10; return (there || there === 0) ? this.addMinutes(there - here) : this; }; $P.setTimezone = function (offset) { return this.setTimezoneOffset($D.getTimezoneOffset(offset)); }; /** * Indicates whether Daylight Saving Time is observed in the current time zone. * @return {Boolean} true|false */ $P.hasDaylightSavingTime = function () { return (Date.today().set({month: 0, day: 1}).getTimezoneOffset() !== Date.today().set({month: 6, day: 1}).getTimezoneOffset()); }; /** * Indicates whether this Date instance is within the Daylight Saving Time range for the current time zone. * @return {Boolean} true|false */ $P.isDaylightSavingTime = function () { return Date.today().set({month: 0, day: 1}).getTimezoneOffset() !== this.getTimezoneOffset(); }; /** * Get the offset from UTC of the current date. * @return {String} The 4-character offset string prefixed with + or - (e.g. "-0500") */ $P.getUTCOffset = function (offset) { var n = (offset || this.getTimezoneOffset()) * -10 / 6, r; if (n < 0) { r = (n - 10000).toString(); return r.charAt(0) + r.substr(2); } else { r = (n + 10000).toString(); return "+" + r.substr(1); } }; /** * Returns the number of milliseconds between this date and date. * @param {Date} Defaults to now * @return {Number} The diff in milliseconds */ $P.getElapsed = function (date) { return (date || new Date()) - this; }; /** * Set the value of year, month, day, hour, minute, second, millisecond of date instance using given configuration object. * Example

	Date.today().set( { day: 20, month: 1 } )

	new Date().set( { millisecond: 0 } )
	
* * @param {Object} Configuration object containing attributes (month, day, etc.) * @return {Date} this */ $P.set = function (config) { config = validateConfigObject.call(this, config); var key; for (key in config) { if (Object.prototype.hasOwnProperty.call(config, key)) { var name = key.charAt(0).toUpperCase() + key.slice(1); var addFunc, getFunc; if (key !== "week" && key !== "month" && key !== "timezone" && key !== "timezoneOffset") { name += "s"; } addFunc = "add" + name; getFunc = "get" + name; if (key === "month") { addFunc = addFunc + "s"; } else if (key === "year"){ getFunc = "getFullYear"; } if (key !== "day" && key !== "timezone" && key !== "timezoneOffset" && key !== "week" && key !== "hour") { this[addFunc](config[key] - this[getFunc]()); } else if ( key === "timezone"|| key === "timezoneOffset" || key === "week" || key === "hour") { this["set"+name](config[key]); } } } // day has to go last because you can't validate the day without first knowing the month if (config.day) { this.addDays(config.day - this.getDate()); } return this; }; /** * Moves the date to the first day of the month. * @return {Date} this */ $P.moveToFirstDayOfMonth = function () { return this.set({ day: 1 }); }; /** * Moves the date to the last day of the month. * @return {Date} this */ $P.moveToLastDayOfMonth = function () { return this.set({ day: $D.getDaysInMonth(this.getFullYear(), this.getMonth())}); }; /** * Converts the value of the current Date object to its equivalent string representation. * Format Specifiers * CUSTOM DATE AND TIME FORMAT STRINGS * Format Description Example * ------ --------------------------------------------------------------------------- ----------------------- * s The seconds of the minute between 0-59. "0" to "59" * ss The seconds of the minute with leading zero if required. "00" to "59" * * m The minute of the hour between 0-59. "0" or "59" * mm The minute of the hour with leading zero if required. "00" or "59" * * h The hour of the day between 1-12. "1" to "12" * hh The hour of the day with leading zero if required. "01" to "12" * * H The hour of the day between 0-23. "0" to "23" * HH The hour of the day with leading zero if required. "00" to "23" * * d The day of the month between 1 and 31. "1" to "31" * dd The day of the month with leading zero if required. "01" to "31" * ddd Abbreviated day name. Date.CultureInfo.abbreviatedDayNames. "Mon" to "Sun" * dddd The full day name. Date.CultureInfo.dayNames. "Monday" to "Sunday" * * M The month of the year between 1-12. "1" to "12" * MM The month of the year with leading zero if required. "01" to "12" * MMM Abbreviated month name. Date.CultureInfo.abbreviatedMonthNames. "Jan" to "Dec" * MMMM The full month name. Date.CultureInfo.monthNames. "January" to "December" * * yy The year as a two-digit number. "99" or "08" * yyyy The full four digit year. "1999" or "2008" * * t Displays the first character of the A.M./P.M. designator. "A" or "P" * Date.CultureInfo.amDesignator or Date.CultureInfo.pmDesignator * tt Displays the A.M./P.M. designator. "AM" or "PM" * Date.CultureInfo.amDesignator or Date.CultureInfo.pmDesignator * * S The ordinal suffix ("st, "nd", "rd" or "th") of the current day. "st, "nd", "rd" or "th" * * STANDARD DATE AND TIME FORMAT STRINGS * Format Description Example *------ --------------------------------------------------------------------------- ----------------------- * d The CultureInfo shortDate Format Pattern "M/d/yyyy" * D The CultureInfo longDate Format Pattern "dddd, MMMM dd, yyyy" * F The CultureInfo fullDateTime Format Pattern "dddd, MMMM dd, yyyy h:mm:ss tt" * m The CultureInfo monthDay Format Pattern "MMMM dd" * r The CultureInfo rfc1123 Format Pattern "ddd, dd MMM yyyy HH:mm:ss GMT" * s The CultureInfo sortableDateTime Format Pattern "yyyy-MM-ddTHH:mm:ss" * t The CultureInfo shortTime Format Pattern "h:mm tt" * T The CultureInfo longTime Format Pattern "h:mm:ss tt" * u The CultureInfo universalSortableDateTime Format Pattern "yyyy-MM-dd HH:mm:ssZ" * y The CultureInfo yearMonth Format Pattern "MMMM, yyyy" * * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @return {String} A string representation of the current Date object. */ var ord = function (n) { switch (n * 1) { case 1: case 21: case 31: return "st"; case 2: case 22: return "nd"; case 3: case 23: return "rd"; default: return "th"; } }; var parseStandardFormats = function (format) { var y, c = Date.CultureInfo.formatPatterns; switch (format) { case "d": return this.toString(c.shortDate); case "D": return this.toString(c.longDate); case "F": return this.toString(c.fullDateTime); case "m": return this.toString(c.monthDay); case "r": case "R": y = this.clone().addMinutes(this.getTimezoneOffset()); return y.toString(c.rfc1123) + " GMT"; case "s": return this.toString(c.sortableDateTime); case "t": return this.toString(c.shortTime); case "T": return this.toString(c.longTime); case "u": y = this.clone().addMinutes(this.getTimezoneOffset()); return y.toString(c.universalSortableDateTime); case "y": return this.toString(c.yearMonth); default: return false; } }; var parseFormatStringsClosure = function (context) { return function (m) { if (m.charAt(0) === "\\") { return m.replace("\\", ""); } switch (m) { case "hh": return p(context.getHours() < 13 ? (context.getHours() === 0 ? 12 : context.getHours()) : (context.getHours() - 12)); case "h": return context.getHours() < 13 ? (context.getHours() === 0 ? 12 : context.getHours()) : (context.getHours() - 12); case "HH": return p(context.getHours()); case "H": return context.getHours(); case "mm": return p(context.getMinutes()); case "m": return context.getMinutes(); case "ss": return p(context.getSeconds()); case "s": return context.getSeconds(); case "yyyy": return p(context.getFullYear(), 4); case "yy": return p(context.getFullYear()); case "y": return context.getFullYear(); case "E": case "dddd": return Date.CultureInfo.dayNames[context.getDay()]; case "ddd": return Date.CultureInfo.abbreviatedDayNames[context.getDay()]; case "dd": return p(context.getDate()); case "d": return context.getDate(); case "MMMM": return Date.CultureInfo.monthNames[context.getMonth()]; case "MMM": return Date.CultureInfo.abbreviatedMonthNames[context.getMonth()]; case "MM": return p((context.getMonth() + 1)); case "M": return context.getMonth() + 1; case "t": return context.getHours() < 12 ? Date.CultureInfo.amDesignator.substring(0, 1) : Date.CultureInfo.pmDesignator.substring(0, 1); case "tt": return context.getHours() < 12 ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator; case "S": return ord(context.getDate()); case "W": return context.getWeek(); case "WW": return context.getISOWeek(); case "Q": return "Q" + context.getQuarter(); case "q": return String(context.getQuarter()); case "z": return context.getTimezone(); case "Z": case "X": return Date.getTimezoneOffset(context.getTimezone()); case "ZZ": // Timezone offset in seconds return context.getTimezoneOffset() * -60; case "u": return context.getDay(); case "L": return ($D.isLeapYear(context.getFullYear())) ? 1 : 0; case "B": // Swatch Internet Time (.beats) return "@"+((context.getUTCSeconds() + (context.getUTCMinutes()*60) + ((context.getUTCHours()+1)*3600))/86.4); default: return m; } }; }; $P.toString = function (format, ignoreStandards) { // Standard Date and Time Format Strings. Formats pulled from CultureInfo file and // may vary by culture. if (!ignoreStandards && format && format.length === 1) { output = parseStandardFormats.call(this, format); if (output) { return output; } } var parseFormatStrings = parseFormatStringsClosure(this); return format ? format.replace(/((\\)?(dd?d?d?|MM?M?M?|yy?y?y?|hh?|HH?|mm?|ss?|tt?|S|q|Q|WW?W?W?)(?![^\[]*\]))/g, parseFormatStrings).replace(/\[|\]/g, "") : this._toString(); }; }()); /************************************************************* * SugarPak - Domain Specific Language - Syntactical Sugar * *************************************************************/ (function () { var $D = Date, $P = $D.prototype, $N = Number.prototype; // private $P._orient = +1; // private $P._nth = null; // private $P._is = false; // private $P._same = false; // private $P._isSecond = false; // private $N._dateElement = "days"; /** * Moves the date to the next instance of a date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.today().next().friday();
	Date.today().next().fri();
	Date.today().next().march();
	Date.today().next().mar();
	Date.today().next().week();
	
* * @return {Date} date */ $P.next = function () { this._move = true; this._orient = +1; return this; }; /** * Creates a new Date (Date.today()) and moves the date to the next instance of the date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.next().friday();
	Date.next().fri();
	Date.next().march();
	Date.next().mar();
	Date.next().week();
	
* * @return {Date} date */ $D.next = function () { return $D.today().next(); }; /** * Moves the date to the previous instance of a date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.today().last().friday();
	Date.today().last().fri();
	Date.today().last().march();
	Date.today().last().mar();
	Date.today().last().week();
	
* * @return {Date} date */ $P.last = $P.prev = $P.previous = function () { this._move = true; this._orient = -1; return this; }; /** * Creates a new Date (Date.today()) and moves the date to the previous instance of the date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.last().friday();
	Date.last().fri();
	Date.previous().march();
	Date.prev().mar();
	Date.last().week();
	
* * @return {Date} date */ $D.last = $D.prev = $D.previous = function () { return $D.today().last(); }; /** * Performs a equality check when followed by either a month name, day name or .weekday() function. * Example

	Date.today().is().friday(); // true|false
	Date.today().is().fri();
	Date.today().is().march();
	Date.today().is().mar();
	
* * @return {Boolean} true|false */ $P.is = function () { this._is = true; return this; }; /** * Determines if two date objects occur on/in exactly the same instance of the subsequent date part function. * The function .same() must be followed by a date part function (example: .day(), .month(), .year(), etc). * * An optional Date can be passed in the date part function. If now date is passed as a parameter, 'Now' is used. * * The following example demonstrates how to determine if two dates fall on the exact same day. * * Example

	var d1 = Date.today(); // today at 00:00
	var d2 = new Date();   // exactly now.

	// Do they occur on the same day?
	d1.same().day(d2); // true
	
	// Do they occur on the same hour?
	d1.same().hour(d2); // false, unless d2 hour is '00' (midnight).
	
	// What if it's the same day, but one year apart?
	var nextYear = Date.today().add(1).year();

	d1.same().day(nextYear); // false, because the dates must occur on the exact same day. 
	
* * Scenario: Determine if a given date occurs during some week period 2 months from now. * * Example

	var future = Date.today().add(2).months();
	return someDate.same().week(future); // true|false;
	
* * @return {Boolean} true|false */ $P.same = function () { this._same = true; this._isSecond = false; return this; }; /** * Determines if the current date/time occurs during Today. Must be preceded by the .is() function. * Example

	someDate.is().today();    // true|false
	new Date().is().today();  // true
	Date.today().is().today();// true
	Date.today().add(-1).day().is().today(); // false
	
* * @return {Boolean} true|false */ $P.today = function () { return this.same().day(); }; /** * Determines if the current date is a weekday. This function must be preceded by the .is() function. * Example

	Date.today().is().weekday(); // true|false
	
* * @return {Boolean} true|false */ $P.weekday = function () { if (this._nth) { return df("Weekday").call(this); } if (this._move) { return this.addWeekdays(this._orient); } if (this._is) { this._is = false; return (!this.is().sat() && !this.is().sun()); } return false; }; /** * Determines if the current date is on the weekend. This function must be preceded by the .is() function. * Example

	Date.today().is().weekend(); // true|false
	
* * @return {Boolean} true|false */ $P.weekend = function () { if (this._is) { this._is = false; return (this.is().sat() || this.is().sun()); } return false; }; /** * Sets the Time of the current Date instance. A string "6:15 pm" or config object {hour:18, minute:15} are accepted. * Example

	// Set time to 6:15pm with a String
	Date.today().at("6:15pm");

	// Set time to 6:15pm with a config object
	Date.today().at({hour:18, minute:15});
	
* * @return {Date} date */ $P.at = function (time) { return (typeof time === "string") ? $D.parse(this.toString("d") + " " + time) : this.set(time); }; /** * Creates a new Date() and adds this (Number) to the date based on the preceding date element function (eg. second|minute|hour|day|month|year). * Example

	// Undeclared Numbers must be wrapped with parentheses. Requirment of JavaScript.
	(3).days().fromNow();
	(6).months().fromNow();

	// Declared Number variables do not require parentheses. 
	var n = 6;
	n.months().fromNow();
	
* * @return {Date} A new Date instance */ $N.fromNow = $N.after = function (date) { var c = {}; c[this._dateElement] = this; return ((!date) ? new Date() : date.clone()).add(c); }; /** * Creates a new Date() and subtract this (Number) from the date based on the preceding date element function (eg. second|minute|hour|day|month|year). * Example

	// Undeclared Numbers must be wrapped with parentheses. Requirment of JavaScript.
	(3).days().ago();
	(6).months().ago();

	// Declared Number variables do not require parentheses. 
	var n = 6;
	n.months().ago();
	
* * @return {Date} A new Date instance */ $N.ago = $N.before = function (date) { var c = {}, s = (this._dateElement[this._dateElement.length-1] !== "s") ? this._dateElement + "s" : this._dateElement; c[s] = this * -1; return ((!date) ? new Date() : date.clone()).add(c); }; // Do NOT modify the following string tokens. These tokens are used to build dynamic functions. // All culture-specific strings can be found in the CultureInfo files. var dx = ("sunday monday tuesday wednesday thursday friday saturday").split(/\s/), mx = ("january february march april may june july august september october november december").split(/\s/), px = ("Millisecond Second Minute Hour Day Week Month Year Quarter Weekday").split(/\s/), pxf = ("Milliseconds Seconds Minutes Hours Date Week Month FullYear Quarter").split(/\s/), nth = ("final first second third fourth fifth").split(/\s/), de; /** * Returns an object literal of all the date parts. * Example

	var o = new Date().toObject();
	
	// { year: 2008, month: 4, week: 20, day: 13, hour: 18, minute: 9, second: 32, millisecond: 812 }
	
	// The object properties can be referenced directly from the object.
	
	alert(o.day);  // alerts "13"
	alert(o.year); // alerts "2008"
	
* * @return {Date} An object literal representing the original date object. */ $P.toObject = function () { var o = {}; for (var i = 0; i < px.length; i++) { if (this["get" + pxf[i]]) { o[px[i].toLowerCase()] = this["get" + pxf[i]](); } } return o; }; /** * Returns a date created from an object literal. Ignores the .week property if set in the config. * Example

	var o = new Date().toObject();
	
	return Date.fromObject(o); // will return the same date. 

	var o2 = {month: 1, day: 20, hour: 18}; // birthday party!
	Date.fromObject(o2);
	
* * @return {Date} An object literal representing the original date object. */ $D.fromObject = function(config) { config.week = null; return Date.today().set(config); }; // Create day name functions and abbreviated day name functions (eg. monday(), friday(), fri()). var df = function (n) { return function () { if (this._is) { this._is = false; return this.getDay() === n; } if (this._move) { this._move = null; } if (this._nth !== null) { // If the .second() function was called earlier, remove the _orient // from the date, and then continue. // This is required because 'second' can be used in two different context. // // Example // // Date.today().add(1).second(); // Date.march().second().monday(); // // Things get crazy with the following... // Date.march().add(1).second().second().monday(); // but it works!! // if (this._isSecond) { this.addSeconds(this._orient * -1); } // make sure we reset _isSecond this._isSecond = false; var ntemp = this._nth; this._nth = null; var temp = this.clone().moveToLastDayOfMonth(); this.moveToNthOccurrence(n, ntemp); if (this > temp) { throw new RangeError($D.getDayName(n) + " does not occur " + ntemp + " times in the month of " + $D.getMonthName(temp.getMonth()) + " " + temp.getFullYear() + "."); } return this; } return this.moveToDayOfWeek(n, this._orient); }; }; var sdf = function (n) { return function () { var t = $D.today(), shift = n - t.getDay(); if (n === 0 && Date.CultureInfo.firstDayOfWeek === 1 && t.getDay() !== 0) { shift = shift + 7; } return t.addDays(shift); }; }; // Create month name functions and abbreviated month name functions (eg. january(), march(), mar()). var month_instance_functions = function (n) { return function () { if (this._is) { this._is = false; return this.getMonth() === n; } return this.moveToMonth(n, this._orient); }; }; var month_static_functions = function (n) { return function () { return $D.today().set({ month: n, day: 1 }); }; }; var processTerms = function (names, staticFunc, instanceFunc) { for (var i = 0; i < names.length; i++) { // Create constant static Name variables. $D[names[i].toUpperCase()] = $D[names[i].toUpperCase().substring(0, 3)] = i; // Create Name functions. $D[names[i]] = $D[names[i].substring(0, 3)] = staticFunc(i); // Create Name instance functions. $P[names[i]] = $P[names[i].substring(0, 3)] = instanceFunc(i); } }; processTerms(dx, sdf, df); processTerms(mx, month_static_functions, month_instance_functions); // Create date element functions and plural date element functions used with Date (eg. day(), days(), months()). var ef = function (j) { return function () { // if the .second() function was called earlier, the _orient // has alread been added. Just return this and reset _isSecond. if (this._isSecond) { this._isSecond = false; return this; } if (this._same) { this._same = this._is = false; var o1 = this.toObject(), o2 = (arguments[0] || new Date()).toObject(), v = "", k = j.toLowerCase(); // the substr trick with -1 doesn't work in IE8 or less k = (k[k.length-1] === "s") ? k.substring(0,k.length-1) : k; for (var m = (px.length - 1); m > -1; m--) { v = px[m].toLowerCase(); if (o1[v] !== o2[v]) { return false; } if (k === v) { break; } } return true; } if (j.substring(j.length - 1) !== "s") { j += "s"; } if (this._move) { this._move = null; } return this["add" + j](this._orient); }; }; var nf = function (n) { return function () { this._dateElement = n; return this; }; }; for (var k = 0; k < px.length; k++) { de = px[k].toLowerCase(); if(de !== "weekday") { // Create date element functions and plural date element functions used with Date (eg. day(), days(), months()). $P[de] = $P[de + "s"] = ef(px[k]); // Create date element functions and plural date element functions used with Number (eg. day(), days(), months()). $N[de] = $N[de + "s"] = nf(de + "s"); } } $P._ss = ef("Second"); var nthfn = function (n) { return function (dayOfWeek) { if (this._same) { return this._ss(arguments[0]); } if (dayOfWeek || dayOfWeek === 0) { return this.moveToNthOccurrence(dayOfWeek, n); } this._nth = n; // if the operator is 'second' add the _orient, then deal with it later... if (n === 2 && (dayOfWeek === undefined || dayOfWeek === null)) { this._isSecond = true; return this.addSeconds(this._orient); } return this; }; }; for (var l = 0; l < nth.length; l++) { $P[nth[l]] = (l === 0) ? nthfn(-1) : nthfn(l); } }()); (function () { "use strict"; Date.Parsing = { Exception: function (s) { this.message = "Parse error at '" + s.substring(0, 10) + " ...'"; } }; var $P = Date.Parsing; var dayOffsets = { standard: [0,31,59,90,120,151,181,212,243,273,304,334], leap: [0,31,60,91,121,152,182,213,244,274,305,335] }; $P.isLeapYear = function(year) { return ((year % 4 === 0) && (year % 100 !== 0)) || (year % 400 === 0); }; var utils = { multiReplace : function (str, hash ) { var key; for (key in hash) { if (Object.prototype.hasOwnProperty.call(hash, key)) { var regex; if (typeof hash[key] === "function") { } else { regex = (hash[key] instanceof RegExp) ? hash[key] : new RegExp(hash[key], "g"); } str = str.replace(regex, key); } } return str; }, getDayOfYearFromWeek : function (obj) { var d, jan4, offset; obj.weekDay = (!obj.weekDay && obj.weekDay !== 0) ? 1 : obj.weekDay; d = new Date(obj.year, 0, 4); jan4 = d.getDay() === 0 ? 7 : d.getDay(); // JS is 0 indexed on Sunday. offset = jan4+3; obj.dayOfYear = ((obj.week * 7) + (obj.weekDay === 0 ? 7 : obj.weekDay))-offset; return obj; }, getDayOfYear : function (obj, dayOffset) { if (!obj.dayOfYear) { obj = utils.getDayOfYearFromWeek(obj); } for (var i=0;i <= dayOffset.length;i++) { if (obj.dayOfYear < dayOffset[i] || i === dayOffset.length) { obj.day = obj.day ? obj.day : (obj.dayOfYear - dayOffset[i-1]); break; } else { obj.month = i; } } return obj; }, adjustForTimeZone : function (obj, date) { var offset; if (obj.zone.toUpperCase() === "Z" || (obj.zone_hours === 0 && obj.zone_minutes === 0)) { // it's UTC/GML so work out the current timeszone offset offset = -date.getTimezoneOffset(); } else { offset = (obj.zone_hours*60) + (obj.zone_minutes || 0); if (obj.zone_sign === "+") { offset *= -1; } offset -= date.getTimezoneOffset(); } date.setMinutes(date.getMinutes()+offset); return date; }, setDefaults : function (obj) { obj.year = obj.year || Date.today().getFullYear(); obj.hours = obj.hours || 0; obj.minutes = obj.minutes || 0; obj.seconds = obj.seconds || 0; obj.milliseconds = obj.milliseconds || 0; if (!(!obj.month && (obj.week || obj.dayOfYear))) { // if we have a month, or if we don't but don't have the day calculation data obj.month = obj.month || 0; obj.day = obj.day || 1; } return obj; }, dataNum: function (data, mod, explict, postProcess) { var dataNum = data*1; if (mod) { if (postProcess) { return data ? mod(data)*1 : data; } else { return data ? mod(dataNum) : data; } } else if (!explict){ return data ? dataNum : data; } else { return (data && typeof data !== "undefined") ? dataNum : data; } }, timeDataProcess: function (obj) { var timeObj = {}; for (var x in obj.data) { if (obj.data.hasOwnProperty(x)) { timeObj[x] = obj.ignore[x] ? obj.data[x] : utils.dataNum(obj.data[x], obj.mods[x], obj.explict[x], obj.postProcess[x]); } } if (obj.data.secmins) { obj.data.secmins = obj.data.secmins.replace(",", ".") * 60; if (!timeObj.minutes) { timeObj.minutes = obj.data.secmins; } else if (!timeObj.seconds) { timeObj.seconds = obj.data.secmins; } delete obj.secmins; } return timeObj; }, buildTimeObjectFromData: function (data) { var time = utils.timeDataProcess({ data: { year : data[1], month : data[5], day : data[7], week : data[8], dayOfYear : data[10], hours : data[15], zone_hours : data[23], zone_minutes : data[24], zone : data[21], zone_sign : data[22], weekDay : data[9], minutes: data[16], seconds: data[19], milliseconds: data[20], secmins: data[18] }, mods: { month: function(data) { return data-1; }, weekDay: function (data) { data = Math.abs(data); return (data === 7 ? 0 : data); }, minutes: function (data) { return data.replace(":",""); }, seconds: function (data) { return Math.floor( (data.replace(":","").replace(",","."))*1 ); }, milliseconds: function (data) { return (data.replace(",",".")*1000); } }, postProcess: { minutes: true, seconds: true, milliseconds: true }, explict: { zone_hours: true, zone_minutes: true }, ignore: { zone: true, zone_sign: true, secmins: true } }); return time; }, addToHash: function (hash, keys, data) { keys = keys; data = data; var len = keys.length; for (var i = 0; i < len; i++) { hash[keys[i]] = data[i]; } return hash; }, combineRegex: function (r1, r2) { return new RegExp("(("+r1.source+")\\s("+r2.source+"))"); }, getDateNthString: function(add, last, inc){ if (add) { return Date.today().addDays(inc).toString("d"); } else if (last) { return Date.today().last()[inc]().toString("d"); } }, buildRegexData: function (array) { var arr = []; var len = array.length; for (var i=0; i < len; i++) { if (Object.prototype.toString.call(array[i]) === '[object Array]') { // oldIE compat version of Array.isArray arr.push(this.combineRegex(array[i][0], array[i][1])); } else { arr.push(array[i]); } } return arr; } }; $P.processTimeObject = function (obj) { var date, dayOffset; utils.setDefaults(obj); dayOffset = ($P.isLeapYear(obj.year)) ? dayOffsets.leap : dayOffsets.standard; if (!obj.month && (obj.week || obj.dayOfYear)) { utils.getDayOfYear(obj, dayOffset); } else { obj.dayOfYear = dayOffset[obj.month] + obj.day; } date = new Date(obj.year, obj.month, obj.day, obj.hours, obj.minutes, obj.seconds, obj.milliseconds); if (obj.zone) { utils.adjustForTimeZone(obj, date); // adjust (and calculate) for timezone } return date; }; $P.ISO = { regex : /^([\+-]?\d{4}(?!\d{2}\b))((-?)((0[1-9]|1[0-2])(\3([12]\d|0[1-9]|3[01]))?|W([0-4]\d|5[0-3])(-?[1-7])?|(00[1-9]|0[1-9]\d|[12]\d{2}|3([0-5]\d|6[1-6])))([T\s]((([01]\d|2[0-4])((:?)[0-5]\d)?|24\:?00)([\.,]\d+(?!:))?)?(\17[0-5]\d([\.,]\d+)?)?\s?([zZ]|([\+-])([01]\d|2[0-3]):?([0-5]\d)?)?)?)?$/, parse : function (s) { var time, data = s.match(this.regex); if (!data || !data.length) { return null; } time = utils.buildTimeObjectFromData(data); if (!time.year || (!time.year && (!time.month && !time.day) && (!time.week && !time.dayOfYear)) ) { return null; } return $P.processTimeObject(time); } }; $P.Numeric = { isNumeric: function (e){return!isNaN(parseFloat(e))&&isFinite(e);}, regex: /\b([0-1]?[0-9])([0-3]?[0-9])([0-2]?[0-9]?[0-9][0-9])\b/i, parse: function (s) { var data, i, time = {}, order = Date.CultureInfo.dateElementOrder.split(""); if (!(this.isNumeric(s)) || // if it's non-numeric OR (s[0] === "+" && s[0] === "-")) { // It's an arithmatic string (eg +/-1000) return null; } if (s.length < 5 && s.indexOf(".") < 0 && s.indexOf("/") < 0) { // assume it's just a year. time.year = s; return $P.processTimeObject(time); } data = s.match(this.regex); if (!data || !data.length) { return null; } for (i=0; i < order.length; i++) { switch(order[i]) { case "d": time.day = data[i+1]; break; case "m": time.month = (data[i+1]-1); break; case "y": time.year = data[i+1]; break; } } return $P.processTimeObject(time); } }; $P.Normalizer = { regexData: function () { var $R = Date.CultureInfo.regexPatterns; return utils.buildRegexData([ $R.tomorrow, $R.yesterday, [$R.past, $R.mon], [$R.past, $R.tue], [$R.past, $R.wed], [$R.past, $R.thu], [$R.past, $R.fri], [$R.past, $R.sat], [$R.past, $R.sun] ]); }, basicReplaceHash : function() { var $R = Date.CultureInfo.regexPatterns; return { "January": $R.jan.source, "February": $R.feb, "March": $R.mar, "April": $R.apr, "May": $R.may, "June": $R.jun, "July": $R.jul, "August": $R.aug, "September": $R.sep, "October": $R.oct, "November": $R.nov, "December": $R.dec, "": /\bat\b/gi, " ": /\s{2,}/, "am": $R.inTheMorning, "9am": $R.thisMorning, "pm": $R.inTheEvening, "7pm":$R.thisEvening }; }, keys : function(){ return [ utils.getDateNthString(true, false, 1), // tomorrow utils.getDateNthString(true, false, -1), // yesterday utils.getDateNthString(false, true, "monday"), //last mon utils.getDateNthString(false, true, "tuesday"), //last tues utils.getDateNthString(false, true, "wednesday"), //last wed utils.getDateNthString(false, true, "thursday"), //last thurs utils.getDateNthString(false, true, "friday"), //last fri utils.getDateNthString(false, true, "saturday"), //last sat utils.getDateNthString(false, true, "sunday") //last sun ]; }, buildRegexFunctions: function () { var $R = Date.CultureInfo.regexPatterns; var __ = Date.i18n.__; var tomorrowRE = new RegExp("(\\b\\d\\d?("+__("AM")+"|"+__("PM")+")? )("+$R.tomorrow.source.slice(1)+")", "i"); // adapted tomorrow regex for AM PM relative dates var todayRE = new RegExp($R.today.source + "(?!\\s*([+-]))\\b"); // today, but excludes the math operators (eg "today + 2h") this.replaceFuncs = [ [todayRE, function (full) { return (full.length > 1) ? Date.today().toString("d") : full; }], [tomorrowRE, function(full, m1) { var t = Date.today().addDays(1).toString("d"); return (t + " " + m1); }], [$R.amThisMorning, function(str, am){return am;}], [$R.pmThisEvening, function(str, pm){return pm;}] ]; }, buildReplaceData: function () { this.buildRegexFunctions(); this.replaceHash = utils.addToHash(this.basicReplaceHash(), this.keys(), this.regexData()); }, stringReplaceFuncs: function (s) { for (var i=0; i < this.replaceFuncs.length; i++) { s = s.replace(this.replaceFuncs[i][0], this.replaceFuncs[i][1]); } return s; }, parse: function (s) { s = this.stringReplaceFuncs(s); s = utils.multiReplace(s, this.replaceHash); try { var n = s.split(/([\s\-\.\,\/\x27]+)/); if (n.length === 3 && $P.Numeric.isNumeric(n[0]) && $P.Numeric.isNumeric(n[2]) && (n[2].length >= 4)) { // ok, so we're dealing with x/year. But that's not a full date. // This fixes wonky dateElementOrder parsing when set to dmy order. if (Date.CultureInfo.dateElementOrder[0] === "d") { s = "1/" + n[0] + "/" + n[2]; // set to 1st of month and normalize the seperator } } } catch (e) {} return s; } }; $P.Normalizer.buildReplaceData(); }()); (function () { var $P = Date.Parsing; var _ = $P.Operators = { // // Tokenizers // rtoken: function (r) { // regex token return function (s) { var mx = s.match(r); if (mx) { return ([ mx[0], s.substring(mx[0].length) ]); } else { throw new $P.Exception(s); } }; }, token: function () { // whitespace-eating token return function (s) { return _.rtoken(new RegExp("^\\s*" + s + "\\s*"))(s); }; }, stoken: function (s) { // string token return _.rtoken(new RegExp("^" + s)); }, // Atomic Operators until: function (p) { return function (s) { var qx = [], rx = null; while (s.length) { try { rx = p.call(this, s); } catch (e) { qx.push(rx[0]); s = rx[1]; continue; } break; } return [ qx, s ]; }; }, many: function (p) { return function (s) { var rx = [], r = null; while (s.length) { try { r = p.call(this, s); } catch (e) { return [ rx, s ]; } rx.push(r[0]); s = r[1]; } return [ rx, s ]; }; }, // generator operators -- see below optional: function (p) { return function (s) { var r = null; try { r = p.call(this, s); } catch (e) { return [ null, s ]; } return [ r[0], r[1] ]; }; }, not: function (p) { return function (s) { try { p.call(this, s); } catch (e) { return [null, s]; } throw new $P.Exception(s); }; }, ignore: function (p) { return p ? function (s) { var r = null; r = p.call(this, s); return [null, r[1]]; } : null; }, product: function () { var px = arguments[0], qx = Array.prototype.slice.call(arguments, 1), rx = []; for (var i = 0 ; i < px.length ; i++) { rx.push(_.each(px[i], qx)); } return rx; }, cache: function (rule) { var cache = {}, cache_length = 0, cache_keys = [], CACHE_MAX = Date.Config.CACHE_MAX || 100000, r = null; var cacheCheck = function () { if (cache_length === CACHE_MAX) { // kill several keys, don't want to have to do this all the time... for (var i=0; i < 10; i++) { var key = cache_keys.shift(); if (key) { delete cache[key]; cache_length--; } } } }; return function (s) { cacheCheck(); try { r = cache[s] = (cache[s] || rule.call(this, s)); } catch (e) { r = cache[s] = e; } cache_length++; cache_keys.push(s); if (r instanceof $P.Exception) { throw r; } else { return r; } }; }, // vector operators -- see below any: function () { var px = arguments; return function (s) { var r = null; for (var i = 0; i < px.length; i++) { if (px[i] == null) { continue; } try { r = (px[i].call(this, s)); } catch (e) { r = null; } if (r) { return r; } } throw new $P.Exception(s); }; }, each: function () { var px = arguments; return function (s) { var rx = [], r = null; for (var i = 0; i < px.length ; i++) { if (px[i] == null) { continue; } try { r = (px[i].call(this, s)); } catch (e) { throw new $P.Exception(s); } rx.push(r[0]); s = r[1]; } return [ rx, s]; }; }, all: function () { var px = arguments, _ = _; return _.each(_.optional(px)); }, // delimited operators sequence: function (px, d, c) { d = d || _.rtoken(/^\s*/); c = c || null; if (px.length === 1) { return px[0]; } return function (s) { var r = null, q = null; var rx = []; for (var i = 0; i < px.length ; i++) { try { r = px[i].call(this, s); } catch (e) { break; } rx.push(r[0]); try { q = d.call(this, r[1]); } catch (ex) { q = null; break; } s = q[1]; } if (!r) { throw new $P.Exception(s); } if (q) { throw new $P.Exception(q[1]); } if (c) { try { r = c.call(this, r[1]); } catch (ey) { throw new $P.Exception(r[1]); } } return [ rx, (r?r[1]:s) ]; }; }, // // Composite Operators // between: function (d1, p, d2) { d2 = d2 || d1; var _fn = _.each(_.ignore(d1), p, _.ignore(d2)); return function (s) { var rx = _fn.call(this, s); return [[rx[0][0], r[0][2]], rx[1]]; }; }, list: function (p, d, c) { d = d || _.rtoken(/^\s*/); c = c || null; return (p instanceof Array ? _.each(_.product(p.slice(0, -1), _.ignore(d)), p.slice(-1), _.ignore(c)) : _.each(_.many(_.each(p, _.ignore(d))), px, _.ignore(c))); }, set: function (px, d, c) { d = d || _.rtoken(/^\s*/); c = c || null; return function (s) { // r is the current match, best the current 'best' match // which means it parsed the most amount of input var r = null, p = null, q = null, rx = null, best = [[], s], last = false; // go through the rules in the given set for (var i = 0; i < px.length ; i++) { // last is a flag indicating whether this must be the last element // if there is only 1 element, then it MUST be the last one q = null; p = null; r = null; last = (px.length === 1); // first, we try simply to match the current pattern // if not, try the next pattern try { r = px[i].call(this, s); } catch (e) { continue; } // since we are matching against a set of elements, the first // thing to do is to add r[0] to matched elements rx = [[r[0]], r[1]]; // if we matched and there is still input to parse and // we don't already know this is the last element, // we're going to next check for the delimiter ... // if there's none, or if there's no input left to parse // than this must be the last element after all ... if (r[1].length > 0 && ! last) { try { q = d.call(this, r[1]); } catch (ex) { last = true; } } else { last = true; } // if we parsed the delimiter and now there's no more input, // that means we shouldn't have parsed the delimiter at all // so don't update r and mark this as the last element ... if (!last && q[1].length === 0) { last = true; } // so, if this isn't the last element, we're going to see if // we can get any more matches from the remaining (unmatched) // elements ... if (!last) { // build a list of the remaining rules we can match against, // i.e., all but the one we just matched against var qx = []; for (var j = 0; j < px.length ; j++) { if (i !== j) { qx.push(px[j]); } } // now invoke recursively set with the remaining input // note that we don't include the closing delimiter ... // we'll check for that ourselves at the end p = _.set(qx, d).call(this, q[1]); // if we got a non-empty set as a result ... // (otw rx already contains everything we want to match) if (p[0].length > 0) { // update current result, which is stored in rx ... // basically, pick up the remaining text from p[1] // and concat the result from p[0] so that we don't // get endless nesting ... rx[0] = rx[0].concat(p[0]); rx[1] = p[1]; } } // at this point, rx either contains the last matched element // or the entire matched set that starts with this element. // now we just check to see if this variation is better than // our best so far, in terms of how much of the input is parsed if (rx[1].length < best[1].length) { best = rx; } // if we've parsed all the input, then we're finished if (best[1].length === 0) { break; } } // so now we've either gone through all the patterns trying them // as the initial match; or we found one that parsed the entire // input string ... // if best has no matches, just return empty set ... if (best[0].length === 0) { return best; } // if a closing delimiter is provided, then we have to check it also if (c) { // we try this even if there is no remaining input because the pattern // may well be optional or match empty input ... try { q = c.call(this, best[1]); } catch (ey) { throw new $P.Exception(best[1]); } // it parsed ... be sure to update the best match remaining input best[1] = q[1]; } // if we're here, either there was no closing delimiter or we parsed it // so now we have the best match; just return it! return best; }; }, forward: function (gr, fname) { return function (s) { return gr[fname].call(this, s); }; }, // // Translation Operators // replace: function (rule, repl) { return function (s) { var r = rule.call(this, s); return [repl, r[1]]; }; }, process: function (rule, fn) { return function (s) { var r = rule.call(this, s); return [fn.call(this, r[0]), r[1]]; }; }, min: function (min, rule) { return function (s) { var rx = rule.call(this, s); if (rx[0].length < min) { throw new $P.Exception(s); } return rx; }; } }; // Generator Operators And Vector Operators // Generators are operators that have a signature of F(R) => R, // taking a given rule and returning another rule, such as // ignore, which parses a given rule and throws away the result. // Vector operators are those that have a signature of F(R1,R2,...) => R, // take a list of rules and returning a new rule, such as each. // Generator operators are converted (via the following _generator // function) into functions that can also take a list or array of rules // and return an array of new rules as though the function had been // called on each rule in turn (which is what actually happens). // This allows generators to be used with vector operators more easily. // Example: // each(ignore(foo, bar)) instead of each(ignore(foo), ignore(bar)) // This also turns generators into vector operators, which allows // constructs like: // not(cache(foo, bar)) var _generator = function (op) { function gen() { var args = null, rx = [], px, i; if (arguments.length > 1) { args = Array.prototype.slice.call(arguments); } else if (arguments[0] instanceof Array) { args = arguments[0]; } if (args) { px = args.shift(); if (px.length > 0) { args.unshift(px[i]); rx.push(op.apply(null, args)); args.shift(); return rx; } } else { return op.apply(null, arguments); } } return gen; }; var gx = "optional not ignore cache".split(/\s/); for (var i = 0 ; i < gx.length ; i++) { _[gx[i]] = _generator(_[gx[i]]); } var _vector = function (op) { return function () { if (arguments[0] instanceof Array) { return op.apply(null, arguments[0]); } else { return op.apply(null, arguments); } }; }; var vx = "each any all".split(/\s/); for (var j = 0 ; j < vx.length ; j++) { _[vx[j]] = _vector(_[vx[j]]); } }()); (function () { var $D = Date; var flattenAndCompact = function (ax) { var rx = []; for (var i = 0; i < ax.length; i++) { if (ax[i] instanceof Array) { rx = rx.concat(flattenAndCompact(ax[i])); } else { if (ax[i]) { rx.push(ax[i]); } } } return rx; }; var parseMeridian = function () { if (this.meridian && (this.hour || this.hour === 0)) { if (this.meridian === "a" && this.hour > 11 && Date.Config.strict24hr){ throw "Invalid hour and meridian combination"; } else if (this.meridian === "p" && this.hour < 12 && Date.Config.strict24hr){ throw "Invalid hour and meridian combination"; } else if (this.meridian === "p" && this.hour < 12) { this.hour = this.hour + 12; } else if (this.meridian === "a" && this.hour === 12) { this.hour = 0; } } }; var setDefaults = function () { var now = new Date(); if ((this.hour || this.minute) && (!this.month && !this.year && !this.day)) { this.day = now.getDate(); } if (!this.year) { this.year = now.getFullYear(); } if (!this.month && this.month !== 0) { this.month = now.getMonth(); } if (!this.day) { this.day = 1; } if (!this.hour) { this.hour = 0; } if (!this.minute) { this.minute = 0; } if (!this.second) { this.second = 0; } if (!this.millisecond) { this.millisecond = 0; } }; var finishUtils = { getToday: function () { if (this.now || "hour minute second".indexOf(this.unit) !== -1) { return new Date(); } else { return $D.today(); } }, setDaysFromWeekday: function (today, orient){ var gap; orient = orient || 1; this.unit = "day"; gap = ($D.getDayNumberFromName(this.weekday) - today.getDay()); this.days = gap ? ((gap + (orient * 7)) % 7) : (orient * 7); return this; }, setMonthsFromMonth: function (today, orient) { var gap; orient = orient || 1; this.unit = "month"; gap = (this.month - today.getMonth()); this.months = gap ? ((gap + (orient * 12)) % 12) : (orient * 12); this.month = null; return this; }, setDMYFromWeekday: function () { var d = Date[this.weekday](); this.day = d.getDate(); if (!this.month) { this.month = d.getMonth(); } this.year = d.getFullYear(); return this; }, setUnitValue: function (orient) { if (!this.value && this.operator && this.operator !== null && this[this.unit + "s"] && this[this.unit + "s"] !== null) { this[this.unit + "s"] = this[this.unit + "s"] + ((this.operator === "add") ? 1 : -1) + (this.value||0) * orient; } else if (this[this.unit + "s"] == null || this.operator != null) { if (!this.value) { this.value = 1; } this[this.unit + "s"] = this.value * orient; } }, generateDateFromWeeks: function () { var weekday = (this.weekday !== undefined) ? this.weekday : "today"; var d = Date[weekday]().addWeeks(this.weeks); if (this.now) { d.setTimeToNow(); } return d; } }; $D.Translator = { hour: function (s) { return function () { this.hour = Number(s); }; }, minute: function (s) { return function () { this.minute = Number(s); }; }, second: function (s) { return function () { this.second = Number(s); }; }, /* for ss.s format */ secondAndMillisecond: function (s) { return function () { var mx = s.match(/^([0-5][0-9])\.([0-9]{1,3})/); this.second = Number(mx[1]); this.millisecond = Number(mx[2]); }; }, meridian: function (s) { return function () { this.meridian = s.slice(0, 1).toLowerCase(); }; }, timezone: function (s) { return function () { var n = s.replace(/[^\d\+\-]/g, ""); if (n.length) { this.timezoneOffset = Number(n); } else { this.timezone = s.toLowerCase(); } }; }, day: function (x) { var s = x[0]; return function () { this.day = Number(s.match(/\d+/)[0]); if (this.day < 1) { throw "invalid day"; } }; }, month: function (s) { return function () { this.month = (s.length === 3) ? "jan feb mar apr may jun jul aug sep oct nov dec".indexOf(s)/4 : Number(s) - 1; if (this.month < 0) { throw "invalid month"; } }; }, year: function (s) { return function () { var n = Number(s); this.year = ((s.length > 2) ? n : (n + (((n + 2000) < Date.CultureInfo.twoDigitYearMax) ? 2000 : 1900))); }; }, rday: function (s) { return function () { switch (s) { case "yesterday": this.days = -1; break; case "tomorrow": this.days = 1; break; case "today": this.days = 0; break; case "now": this.days = 0; this.now = true; break; } }; }, finishExact: function (x) { var d; x = (x instanceof Array) ? x : [x]; for (var i = 0 ; i < x.length ; i++) { if (x[i]) { x[i].call(this); } } setDefaults.call(this); parseMeridian.call(this); if (this.day > $D.getDaysInMonth(this.year, this.month)) { throw new RangeError(this.day + " is not a valid value for days."); } d = new Date(this.year, this.month, this.day, this.hour, this.minute, this.second, this.millisecond); if (this.year < 100) { d.setFullYear(this.year); // means years less that 100 are process correctly. JS will parse it otherwise as 1900-1999. } if (this.timezone) { d.set({ timezone: this.timezone }); } else if (this.timezoneOffset) { d.set({ timezoneOffset: this.timezoneOffset }); } return d; }, finish: function (x) { var today, expression, orient, temp; x = (x instanceof Array) ? flattenAndCompact(x) : [ x ]; if (x.length === 0) { return null; } for (var i = 0 ; i < x.length ; i++) { if (typeof x[i] === "function") { x[i].call(this); } } if (this.now && !this.unit && !this.operator) { return new Date(); } else { today = finishUtils.getToday.call(this); } expression = !!(this.days && this.days !== null || this.orient || this.operator); orient = ((this.orient === "past" || this.operator === "subtract") ? -1 : 1); if (this.month && this.unit === "week") { this.value = this.month + 1; delete this.month; delete this.day; } if ((this.month || this.month === 0) && "year day hour minute second".indexOf(this.unit) !== -1) { if (!this.value) { this.value = this.month + 1; } this.month = null; expression = true; } if (!expression && this.weekday && !this.day && !this.days) { finishUtils.setDMYFromWeekday.call(this); } if (expression && this.weekday && this.unit !== "month" && this.unit !== "week") { finishUtils.setDaysFromWeekday.call(this, today, orient); } if (this.weekday && this.unit !== "week" && !this.day && !this.days) { temp = Date[this.weekday](); this.day = temp.getDate(); if (temp.getMonth() !== today.getMonth()) { this.month = temp.getMonth(); } } if (this.month && this.unit === "day" && this.operator) { if (!this.value) { this.value = (this.month + 1); } this.month = null; } if (this.value != null && this.month != null && this.year != null) { this.day = this.value * 1; } if (this.month && !this.day && this.value) { today.set({ day: this.value * 1 }); if (!expression) { this.day = this.value * 1; } } if (!this.month && this.value && this.unit === "month" && !this.now) { this.month = this.value; expression = true; } if (expression && (this.month || this.month === 0) && this.unit !== "year") { finishUtils.setMonthsFromMonth.call(this, today, orient); } if (!this.unit) { this.unit = "day"; } finishUtils.setUnitValue.call(this, orient); parseMeridian.call(this); if ((this.month || this.month === 0) && !this.day) { this.day = 1; } if (!this.orient && !this.operator && this.unit === "week" && this.value && !this.day && !this.month) { return Date.today().setWeek(this.value); } if (this.unit === "week" && this.weeks && !this.day && !this.month) { return finishUtils.generateDateFromWeeks.call(this); } if (expression && this.timezone && this.day && this.days) { this.day = this.days; } if (expression){ today.add(this); } else { today.set(this); } if (this.timezone) { this.timezone = this.timezone.toUpperCase(); var offset = $D.getTimezoneOffset(this.timezone); var timezone; if (today.hasDaylightSavingTime()) { // lets check that we're being sane with timezone setting timezone = $D.getTimezoneAbbreviation(offset, today.isDaylightSavingTime()); if (timezone !== this.timezone) { // bugger, we're in a place where things like EST vs EDT matters. if (today.isDaylightSavingTime()) { today.addHours(-1); } else { today.addHours(1); } } } today.setTimezoneOffset(offset); } return today; } }; }()); (function () { var $D = Date; $D.Grammar = {}; var _ = $D.Parsing.Operators, g = $D.Grammar, t = $D.Translator, _fn; // Allow rolling up into general purpose rules _fn = function () { return _.each(_.any.apply(null, arguments), _.not(g.ctoken2("timeContext"))); }; g.datePartDelimiter = _.rtoken(/^([\s\-\.\,\/\x27]+)/); g.timePartDelimiter = _.stoken(":"); g.whiteSpace = _.rtoken(/^\s*/); g.generalDelimiter = _.rtoken(/^(([\s\,]|at|@|on)+)/); var _C = {}; g.ctoken = function (keys) { var fn = _C[keys]; if (! fn) { var c = Date.CultureInfo.regexPatterns; var kx = keys.split(/\s+/), px = []; for (var i = 0; i < kx.length ; i++) { px.push(_.replace(_.rtoken(c[kx[i]]), kx[i])); } fn = _C[keys] = _.any.apply(null, px); } return fn; }; g.ctoken2 = function (key) { return _.rtoken(Date.CultureInfo.regexPatterns[key]); }; var cacheProcessRtoken = function (key, token, type, eachToken) { if (eachToken) { g[key] = _.cache(_.process(_.each(_.rtoken(token),_.optional(g.ctoken2(eachToken))), type)); } else { g[key] = _.cache(_.process(_.rtoken(token), type)); } }; var cacheProcessCtoken = function (token, type) { return _.cache(_.process(g.ctoken2(token), type)); }; var _F = {}; //function cache var _get = function (f) { _F[f] = (_F[f] || g.format(f)[0]); return _F[f]; }; g.allformats = function (fx) { var rx = []; if (fx instanceof Array) { for (var i = 0; i < fx.length; i++) { rx.push(_get(fx[i])); } } else { rx.push(_get(fx)); } return rx; }; g.formats = function (fx) { if (fx instanceof Array) { var rx = []; for (var i = 0 ; i < fx.length ; i++) { rx.push(_get(fx[i])); } return _.any.apply(null, rx); } else { return _get(fx); } }; var grammarFormats = { timeFormats: function(){ var i, RTokenKeys = [ "h", "hh", "H", "HH", "m", "mm", "s", "ss", "ss.s", "z", "zz" ], RToken = [ /^(0[0-9]|1[0-2]|[1-9])/, /^(0[0-9]|1[0-2])/, /^([0-1][0-9]|2[0-3]|[0-9])/, /^([0-1][0-9]|2[0-3])/, /^([0-5][0-9]|[0-9])/, /^[0-5][0-9]/, /^([0-5][0-9]|[0-9])/, /^[0-5][0-9]/, /^[0-5][0-9]\.[0-9]{1,3}/, /^((\+|\-)\s*\d\d\d\d)|((\+|\-)\d\d\:?\d\d)/, /^((\+|\-)\s*\d\d\d\d)|((\+|\-)\d\d\:?\d\d)/ ], tokens = [ t.hour, t.hour, t.hour, t.hour, t.minute, t.minute, t.second, t.second, t.secondAndMillisecond, t.timezone, t.timezone ]; for (i=0; i < RTokenKeys.length; i++) { cacheProcessRtoken(RTokenKeys[i], RToken[i], tokens[i]); } g.hms = _.cache(_.sequence([g.H, g.m, g.s], g.timePartDelimiter)); g.t = cacheProcessCtoken("shortMeridian", t.meridian); g.tt = cacheProcessCtoken("longMeridian", t.meridian); g.zzz = cacheProcessCtoken("timezone", t.timezone); g.timeSuffix = _.each(_.ignore(g.whiteSpace), _.set([ g.tt, g.zzz ])); g.time = _.each(_.optional(_.ignore(_.stoken("T"))), g.hms, g.timeSuffix); }, dateFormats: function () { // pre-loaded rules for different date part order preferences var _setfn = function () { return _.set(arguments, g.datePartDelimiter); }; var i, RTokenKeys = [ "d", "dd", "M", "MM", "y", "yy", "yyy", "yyyy" ], RToken = [ /^([0-2]\d|3[0-1]|\d)/, /^([0-2]\d|3[0-1])/, /^(1[0-2]|0\d|\d)/, /^(1[0-2]|0\d)/, /^(\d+)/, /^(\d\d)/, /^(\d\d?\d?\d?)/, /^(\d\d\d\d)/ ], tokens = [ t.day, t.day, t.month, t.month, t.year, t.year, t.year, t.year ], eachToken = [ "ordinalSuffix", "ordinalSuffix" ]; for (i=0; i < RTokenKeys.length; i++) { cacheProcessRtoken(RTokenKeys[i], RToken[i], tokens[i], eachToken[i]); } g.MMM = g.MMMM = _.cache(_.process(g.ctoken("jan feb mar apr may jun jul aug sep oct nov dec"), t.month)); g.ddd = g.dddd = _.cache(_.process(g.ctoken("sun mon tue wed thu fri sat"), function (s) { return function () { this.weekday = s; }; } )); g.day = _fn(g.d, g.dd); g.month = _fn(g.M, g.MMM); g.year = _fn(g.yyyy, g.yy); g.mdy = _setfn(g.ddd, g.month, g.day, g.year); g.ymd = _setfn(g.ddd, g.year, g.month, g.day); g.dmy = _setfn(g.ddd, g.day, g.month, g.year); g.date = function (s) { return ((g[Date.CultureInfo.dateElementOrder] || g.mdy).call(this, s)); }; }, relative: function () { // relative date / time expressions g.orientation = _.process(g.ctoken("past future"), function (s) { return function () { this.orient = s; }; } ); g.operator = _.process(g.ctoken("add subtract"), function (s) { return function () { this.operator = s; }; } ); g.rday = _.process(g.ctoken("yesterday tomorrow today now"), t.rday); g.unit = _.process(g.ctoken("second minute hour day week month year"), function (s) { return function () { this.unit = s; }; } ); } }; g.buildGrammarFormats = function () { // these need to be rebuilt every time the language changes. _C = {}; grammarFormats.timeFormats(); grammarFormats.dateFormats(); grammarFormats.relative(); g.value = _.process(_.rtoken(/^([-+]?\d+)?(st|nd|rd|th)?/), function (s) { return function () { this.value = s.replace(/\D/g, ""); }; } ); g.expression = _.set([g.rday, g.operator, g.value, g.unit, g.orientation, g.ddd, g.MMM ]); g.format = _.process(_.many( _.any( // translate format specifiers into grammar rules _.process( _.rtoken(/^(dd?d?d?(?!e)|MM?M?M?|yy?y?y?|hh?|HH?|mm?|ss?|tt?|zz?z?)/), function (fmt) { if (g[fmt]) { return g[fmt]; } else { throw $D.Parsing.Exception(fmt); } } ), // translate separator tokens into token rules _.process(_.rtoken(/^[^dMyhHmstz]+/), // all legal separators function (s) { return _.ignore(_.stoken(s)); } ) ) ), // construct the parser ... function (rules) { return _.process(_.each.apply(null, rules), t.finishExact); } ); // starting rule for general purpose grammar g._start = _.process(_.set([ g.date, g.time, g.expression ], g.generalDelimiter, g.whiteSpace), t.finish); }; g.buildGrammarFormats(); // parsing date format specifiers - ex: "h:m:s tt" // this little guy will generate a custom parser based // on the format string, ex: g.format("h:m:s tt") // check for these formats first g._formats = g.formats([ "\"yyyy-MM-ddTHH:mm:ssZ\"", "yyyy-MM-ddTHH:mm:ss.sz", "yyyy-MM-ddTHH:mm:ssZ", "yyyy-MM-ddTHH:mm:ssz", "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-ddTHH:mmZ", "yyyy-MM-ddTHH:mmz", "yyyy-MM-ddTHH:mm", "ddd, MMM dd, yyyy H:mm:ss tt", "ddd MMM d yyyy HH:mm:ss zzz", "MMddyyyy", "ddMMyyyy", "Mddyyyy", "ddMyyyy", "Mdyyyy", "dMyyyy", "yyyy", "Mdyy", "dMyy", "d" ]); // real starting rule: tries selected formats first, // then general purpose rule g.start = function (s) { try { var r = g._formats.call({}, s); if (r[1].length === 0) { return r; } } catch (e) {} return g._start.call({}, s); }; }()); (function () { var $D = Date; /** * @desc Converts the specified string value into its JavaScript Date equivalent using CultureInfo specific format information. * * Example

	///////////
	// Dates //
	///////////

	// 15-Oct-2004
	var d1 = Date.parse("10/15/2004");

	// 15-Oct-2004
	var d1 = Date.parse("15-Oct-2004");

	// 15-Oct-2004
	var d1 = Date.parse("2004.10.15");

	//Fri Oct 15, 2004
	var d1 = Date.parse("Fri Oct 15, 2004");

	///////////
	// Times //
	///////////

	// Today at 10 PM.
	var d1 = Date.parse("10 PM");

	// Today at 10:30 PM.
	var d1 = Date.parse("10:30 P.M.");

	// Today at 6 AM.
	var d1 = Date.parse("06am");

	/////////////////////
	// Dates and Times //
	/////////////////////

	// 8-July-2004 @ 10:30 PM
	var d1 = Date.parse("July 8th, 2004, 10:30 PM");

	// 1-July-2004 @ 10:30 PM
	var d1 = Date.parse("2004-07-01T22:30:00");

	////////////////////
	// Relative Dates //
	////////////////////

	// Returns today's date. The string "today" is culture specific.
	var d1 = Date.parse("today");

	// Returns yesterday's date. The string "yesterday" is culture specific.
	var d1 = Date.parse("yesterday");

	// Returns the date of the next thursday.
	var d1 = Date.parse("Next thursday");

	// Returns the date of the most previous monday.
	var d1 = Date.parse("last monday");

	// Returns today's day + one year.
	var d1 = Date.parse("next year");

	///////////////
	// Date Math //
	///////////////

	// Today + 2 days
	var d1 = Date.parse("t+2");

	// Today + 2 days
	var d1 = Date.parse("today + 2 days");

	// Today + 3 months
	var d1 = Date.parse("t+3m");

	// Today - 1 year
	var d1 = Date.parse("today - 1 year");

	// Today - 1 year
	var d1 = Date.parse("t-1y"); 


	/////////////////////////////
	// Partial Dates and Times //
	/////////////////////////////

	// July 15th of this year.
	var d1 = Date.parse("July 15");

	// 15th day of current day and year.
	var d1 = Date.parse("15");

	// July 1st of current year at 10pm.
	var d1 = Date.parse("7/1 10pm");
	
* * @param {String} The string value to convert into a Date object [Required] * @return {Date} A Date object or null if the string cannot be converted into a Date. */ var parseUtils = { removeOrds: function (s) { ords = s.match(/\b(\d+)(?:st|nd|rd|th)\b/); // find ordinal matches s = ((ords && ords.length === 2) ? s.replace(ords[0], ords[1]) : s); return s; }, grammarParser: function (s) { var r = null; try { r = $D.Grammar.start.call({}, s.replace(/^\s*(\S*(\s+\S+)*)\s*$/, "$1")); } catch (e) { return null; } return ((r[1].length === 0) ? r[0] : null); }, nativeFallback: function(s) { var t; try { // ok we haven't parsed it, last ditch attempt with the built-in parser. t = Date._parse(s); return (t || t === 0) ? new Date(t) : null; } catch (e) { return null; } } }; function parse (s) { var d; if (!s) { return null; } if (s instanceof Date) { return s.clone(); } if (s.length >= 4 && s.charAt(0) !== "0" && s.charAt(0) !== "+"&& s.charAt(0) !== "-") { // ie: 2004 will pass, 0800 won't. // Start with specific formats d = $D.Parsing.ISO.parse(s) || $D.Parsing.Numeric.parse(s); } if (d instanceof Date && !isNaN(d.getTime())) { return d; } else { // find ordinal dates (1st, 3rd, 8th, etc and remove them as they cause parsing issues) s = $D.Parsing.Normalizer.parse(parseUtils.removeOrds(s)); d = parseUtils.grammarParser(s); if (d !== null) { return d; } else { return parseUtils.nativeFallback(s); } } } if (!$D._parse) { $D._parse = $D.parse; } $D.parse = parse; Date.getParseFunction = function (fx) { var fns = Date.Grammar.allformats(fx); return function (s) { var r = null; for (var i = 0; i < fns.length; i++) { try { r = fns[i].call({}, s); } catch (e) { continue; } if (r[1].length === 0) { return r[0]; } } return null; }; }; /** * Converts the specified string value into its JavaScript Date equivalent using the specified format {String} or formats {Array} and the CultureInfo specific format information. * The format of the string value must match one of the supplied formats exactly. * * Example

	// 15-Oct-2004
	var d1 = Date.parseExact("10/15/2004", "M/d/yyyy");

	// 15-Oct-2004
	var d1 = Date.parse("15-Oct-2004", "M-ddd-yyyy");

	// 15-Oct-2004
	var d1 = Date.parse("2004.10.15", "yyyy.MM.dd");

	// Multiple formats
	var d1 = Date.parseExact("10/15/2004", ["M/d/yyyy", "MMMM d, yyyy"]);
	
* * @param {String} The string value to convert into a Date object [Required]. * @param {Object} The expected format {String} or an array of expected formats {Array} of the date string [Required]. * @return {Date} A Date object or null if the string cannot be converted into a Date. */ $D.parseExact = function (s, fx) { return $D.getParseFunction(fx)(s); }; }()); (function () { var $D = Date, $P = $D.prototype, // $C = $D.CultureInfo, // not used atm p = function (s, l) { if (!l) { l = 2; } return ("000" + s).slice(l * -1); }; /** * Converts a PHP format string to Java/.NET format string. * A PHP format string can be used with ._format or .format. * A Java/.NET format string can be used with .toString(). * The .parseExact function will only accept a Java/.NET format string * * Example * var f1 = "%m/%d/%y" * var f2 = Date.normalizeFormat(f1); // "MM/dd/yy" * * new Date().format(f1); // "04/13/08" * new Date()._format(f1); // "04/13/08" * new Date().toString(f2); // "04/13/08" * * var date = Date.parseExact("04/13/08", f2); // Sun Apr 13 2008 * * @param {String} A PHP format string consisting of one or more format spcifiers. * @return {String} The PHP format converted to a Java/.NET format string. */ var normalizerSubstitutions = { "d" : "dd", "%d": "dd", "D" : "ddd", "%a": "ddd", "j" : "dddd", "l" : "dddd", "%A": "dddd", "S" : "S", "F" : "MMMM", "%B": "MMMM", "m" : "MM", "%m": "MM", "M" : "MMM", "%b": "MMM", "%h": "MMM", "n" : "M", "Y" : "yyyy", "%Y": "yyyy", "y" : "yy", "%y": "yy", "g" : "h", "%I": "h", "G" : "H", "h" : "hh", "H" : "HH", "%H": "HH", "i" : "mm", "%M": "mm", "s" : "ss", "%S": "ss", "%r": "hh:mm tt", "%R": "H:mm", "%T": "H:mm:ss", "%X": "t", "%x": "d", "%e": "d", "%D": "MM/dd/yy", "%n": "\\n", "%t": "\\t", "e" : "z", "T" : "z", "%z": "z", "%Z": "z", "Z" : "ZZ", "N" : "u", "w" : "u", "%w": "u", "W" : "W", "%V": "W" }; var normalizer = { substitutes: function (m) { return normalizerSubstitutions[m]; }, interpreted: function (m, x) { var y; switch (m) { case "%u": return x.getDay() + 1; case "z": return x.getOrdinalNumber(); case "%j": return p(x.getOrdinalNumber(), 3); case "%U": var d1 = x.clone().set({month: 0, day: 1}).addDays(-1).moveToDayOfWeek(0), d2 = x.clone().addDays(1).moveToDayOfWeek(0, -1); return (d2 < d1) ? "00" : p((d2.getOrdinalNumber() - d1.getOrdinalNumber()) / 7 + 1); case "%W": return p(x.getWeek()); case "t": return $D.getDaysInMonth(x.getFullYear(), x.getMonth()); case "o": case "%G": return x.setWeek(x.getISOWeek()).toString("yyyy"); case "%g": return x._format("%G").slice(-2); case "a": case "%p": return t("tt").toLowerCase(); case "A": return t("tt").toUpperCase(); case "u": return p(x.getMilliseconds(), 3); case "I": return (x.isDaylightSavingTime()) ? 1 : 0; case "O": return x.getUTCOffset(); case "P": y = x.getUTCOffset(); return y.substring(0, y.length - 2) + ":" + y.substring(y.length - 2); case "B": var now = new Date(); return Math.floor(((now.getHours() * 3600) + (now.getMinutes() * 60) + now.getSeconds() + (now.getTimezoneOffset() + 60) * 60) / 86.4); case "c": return x.toISOString().replace(/\"/g, ""); case "U": return $D.strtotime("now"); case "%c": return t("d") + " " + t("t"); case "%C": return Math.floor(x.getFullYear() / 100 + 1); } }, shouldOverrideDefaults: function (m) { switch (m) { case "%e": return true; default: return false; } }, parse: function (m, context) { var formatString, c = context || new Date(); formatString = normalizer.substitutes(m); if (formatString) { return formatString; } formatString = normalizer.interpreted(m, c); if (formatString) { return formatString; } else { return m; } } }; $D.normalizeFormat = function (format, context) { return format.replace(/(%|\\)?.|%%/g, function(t){ return normalizer.parse(t, context); }); }; /** * Format a local Unix timestamp according to locale settings * * Example: * Date.strftime("%m/%d/%y", new Date()); // "04/13/08" * Date.strftime("c", "2008-04-13T17:52:03Z"); // "04/13/08" * * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @param {Number|String} The number representing the number of seconds that have elapsed since January 1, 1970 (local time). * @return {String} A string representation of the current Date object. */ $D.strftime = function (format, time) { var d = Date.parse(time); return d._format(format); }; /** * Parse any textual datetime description into a Unix timestamp. * A Unix timestamp is the number of seconds that have elapsed since January 1, 1970 (midnight UTC/GMT). * * Example: * Date.strtotime("04/13/08"); // 1208044800 * Date.strtotime("1970-01-01T00:00:00Z"); // 0 * * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @param {Object} A string or date object. * @return {String} A string representation of the current Date object. */ $D.strtotime = function (time) { var d = $D.parse(time); return Math.round($D.UTC(d.getUTCFullYear(), d.getUTCMonth(), d.getUTCDate(), d.getUTCHours(), d.getUTCMinutes(), d.getUTCSeconds(), d.getUTCMilliseconds()) / 1000); }; /** * Converts the value of the current Date object to its equivalent string representation using a PHP/Unix style of date format specifiers. * Format Specifiers * Format Description Example * ------ --------------------------------------------------------------------------- ----------------------- * %a abbreviated weekday name according to the current localed "Mon" through "Sun" * %A full weekday name according to the current localed "Sunday" through "Saturday" * %b abbreviated month name according to the current localed "Jan" through "Dec" * %B full month name according to the current locale "January" through "December" * %c preferred date and time representation for the current locale "4/13/2008 12:33 PM" * %C century number (the year divided by 100 and truncated to an integer) "00" to "99" * %d day of the month as a decimal number "01" to "31" * %D same as %m/%d/%y "04/13/08" * %e day of the month as a decimal number, a single digit is preceded by a space "1" to "31" * %g like %G, but without the century "08" * %G The 4-digit year corresponding to the ISO week number (see %V). "2008" * This has the same format and value as %Y, except that if the ISO week number * belongs to the previous or next year, that year is used instead. * %h same as %b "Jan" through "Dec" * %H hour as a decimal number using a 24-hour clock. "00" to "23" * %I hour as a decimal number using a 12-hour clock. "01" to "12" * %j day of the year as a decimal number. "001" to "366" * %m month as a decimal number. "01" to "12" * %M minute as a decimal number. "00" to "59" * %n newline character "\n" * %p either "am" or "pm" according to the given time value, or the "am" or "pm" * corresponding strings for the current locale. * %r time in a.m. and p.m. notation "8:44 PM" * %R time in 24 hour notation "20:44" * %S second as a decimal number "00" to "59" * %t tab character "\t" * %T current time, equal to %H:%M:%S "12:49:11" * %u weekday as a decimal number ["1", "7"], with "1" representing Monday "1" to "7" * %U week number of the current year as a decimal number, starting with the "0" to ("52" or "53") * first Sunday as the first day of the first week * %V The ISO 8601:1988 week number of the current year as a decimal number, "00" to ("52" or "53") * range 01 to 53, where week 1 is the first week that has at least 4 days * in the current year, and with Monday as the first day of the week. * (Use %G or %g for the year component that corresponds to the week number * for the specified timestamp.) * %W week number of the current year as a decimal number, starting with the "00" to ("52" or "53") * first Monday as the first day of the first week * %w day of the week as a decimal, Sunday being "0" "0" to "6" * %x preferred date representation for the current locale without the time "4/13/2008" * %X preferred time representation for the current locale without the date "12:53:05" * %y year as a decimal number without a century "00" "99" * %Y year as a decimal number including the century "2008" * %Z time zone or name or abbreviation "UTC", "EST", "PST" * %z same as %Z * %% a literal "%" characters "%" * d Day of the month, 2 digits with leading zeros "01" to "31" * D A textual representation of a day, three letters "Mon" through "Sun" * j Day of the month without leading zeros "1" to "31" * l A full textual representation of the day of the week (lowercase "L") "Sunday" through "Saturday" * N ISO-8601 numeric representation of the day of the week (added in PHP 5.1.0) "1" (for Monday) through "7" (for Sunday) * S English ordinal suffix for the day of the month, 2 characters "st", "nd", "rd" or "th". Works well with j * w Numeric representation of the day of the week "0" (for Sunday) through "6" (for Saturday) * z The day of the year (starting from "0") "0" through "365" * W ISO-8601 week number of year, weeks starting on Monday "00" to ("52" or "53") * F A full textual representation of a month, such as January or March "January" through "December" * m Numeric representation of a month, with leading zeros "01" through "12" * M A short textual representation of a month, three letters "Jan" through "Dec" * n Numeric representation of a month, without leading zeros "1" through "12" * t Number of days in the given month "28" through "31" * L Whether it's a leap year "1" if it is a leap year, "0" otherwise * o ISO-8601 year number. This has the same value as Y, except that if the "2008" * ISO week number (W) belongs to the previous or next year, that year * is used instead. * Y A full numeric representation of a year, 4 digits "2008" * y A two digit representation of a year "08" * a Lowercase Ante meridiem and Post meridiem "am" or "pm" * A Uppercase Ante meridiem and Post meridiem "AM" or "PM" * B Swatch Internet time "000" through "999" * g 12-hour format of an hour without leading zeros "1" through "12" * G 24-hour format of an hour without leading zeros "0" through "23" * h 12-hour format of an hour with leading zeros "01" through "12" * H 24-hour format of an hour with leading zeros "00" through "23" * i Minutes with leading zeros "00" to "59" * s Seconds, with leading zeros "00" through "59" * u Milliseconds "54321" * e Timezone identifier "UTC", "EST", "PST" * I Whether or not the date is in daylight saving time (uppercase i) "1" if Daylight Saving Time, "0" otherwise * O Difference to Greenwich time (GMT) in hours "+0200", "-0600" * P Difference to Greenwich time (GMT) with colon between hours and minutes "+02:00", "-06:00" * T Timezone abbreviation "UTC", "EST", "PST" * Z Timezone offset in seconds. The offset for timezones west of UTC is "-43200" through "50400" * always negative, and for those east of UTC is always positive. * c ISO 8601 date "2004-02-12T15:19:21+00:00" * r RFC 2822 formatted date "Thu, 21 Dec 2000 16:01:07 +0200" * U Seconds since the Unix Epoch (January 1 1970 00:00:00 GMT) "0" * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @return {String} A string representation of the current Date object. */ var formatReplace = function (context) { return function (m) { var formatString, override = false; if (m.charAt(0) === "\\" || m.substring(0, 2) === "%%") { return m.replace("\\", "").replace("%%", "%"); } override = normalizer.shouldOverrideDefaults(m); formatString = $D.normalizeFormat(m, context); if (formatString) { return context.toString(formatString, override); } }; }; $P._format = function (format) { var formatter = formatReplace(this); if (!format) { return this._toString(); } else { return format.replace(/(%|\\)?.|%%/g, formatter); } }; if (!$P.format) { $P.format = $P._format; } }()); (function () { "use strict"; var gFn = function (attr) { return function () { return this[attr]; }; }; var sFn = function (attr) { return function (val) { this[attr] = val; return this; }; }; var attrs = ["years", "months", "days", "hours", "minutes", "seconds", "milliseconds"]; var addSetFuncs = function (context, attrs) { for (var i = 0; i < attrs.length ; i++) { var $a = attrs[i], $b = $a.slice(0, 1).toUpperCase() + $a.slice(1); context.prototype[$a] = 0; context.prototype["get" + $b] = gFn($a); context.prototype["set" + $b] = sFn($a); } }; /** * new TimeSpan(milliseconds); * new TimeSpan(days, hours, minutes, seconds); * new TimeSpan(days, hours, minutes, seconds, milliseconds); */ var TimeSpan = function (days, hours, minutes, seconds, milliseconds) { if (arguments.length === 1 && typeof days === "number") { var orient = (days < 0) ? -1 : +1; var millsLeft = Math.abs(days); this.setDays(Math.floor(millsLeft / 86400000) * orient); millsLeft = millsLeft % 86400000; this.setHours(Math.floor(millsLeft / 3600000) * orient); millsLeft = millsLeft % 3600000; this.setMinutes(Math.floor(millsLeft / 60000) * orient); millsLeft = millsLeft % 60000; this.setSeconds(Math.floor(millsLeft / 1000) * orient); millsLeft = millsLeft % 1000; this.setMilliseconds(millsLeft * orient); } else { this.set(days, hours, minutes, seconds, milliseconds); } this.getTotalMilliseconds = function () { return (this.getDays() * 86400000) + (this.getHours() * 3600000) + (this.getMinutes() * 60000) + (this.getSeconds() * 1000); }; this.compareTo = function (time) { var t1 = new Date(1970, 1, 1, this.getHours(), this.getMinutes(), this.getSeconds()), t2; if (time === null) { t2 = new Date(1970, 1, 1, 0, 0, 0); } else { t2 = new Date(1970, 1, 1, time.getHours(), time.getMinutes(), time.getSeconds()); } return (t1 < t2) ? -1 : (t1 > t2) ? 1 : 0; }; this.equals = function (time) { return (this.compareTo(time) === 0); }; this.add = function (time) { return (time === null) ? this : this.addSeconds(time.getTotalMilliseconds() / 1000); }; this.subtract = function (time) { return (time === null) ? this : this.addSeconds(-time.getTotalMilliseconds() / 1000); }; this.addDays = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 86400000)); }; this.addHours = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 3600000)); }; this.addMinutes = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 60000)); }; this.addSeconds = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 1000)); }; this.addMilliseconds = function (n) { return new TimeSpan(this.getTotalMilliseconds() + n); }; this.get12HourHour = function () { return (this.getHours() > 12) ? this.getHours() - 12 : (this.getHours() === 0) ? 12 : this.getHours(); }; this.getDesignator = function () { return (this.getHours() < 12) ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator; }; this.toString = function (format) { this._toString = function () { if (this.getDays() !== null && this.getDays() > 0) { return this.getDays() + "." + this.getHours() + ":" + this.p(this.getMinutes()) + ":" + this.p(this.getSeconds()); } else { return this.getHours() + ":" + this.p(this.getMinutes()) + ":" + this.p(this.getSeconds()); } }; this.p = function (s) { return (s.toString().length < 2) ? "0" + s : s; }; var me = this; return format ? format.replace(/dd?|HH?|hh?|mm?|ss?|tt?/g, function (format) { switch (format) { case "d": return me.getDays(); case "dd": return me.p(me.getDays()); case "H": return me.getHours(); case "HH": return me.p(me.getHours()); case "h": return me.get12HourHour(); case "hh": return me.p(me.get12HourHour()); case "m": return me.getMinutes(); case "mm": return me.p(me.getMinutes()); case "s": return me.getSeconds(); case "ss": return me.p(me.getSeconds()); case "t": return ((me.getHours() < 12) ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator).substring(0, 1); case "tt": return (me.getHours() < 12) ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator; } } ) : this._toString(); }; return this; }; addSetFuncs(TimeSpan, attrs.slice(2)); TimeSpan.prototype.set = function (days, hours, minutes, seconds, milliseconds){ this.setDays(days || this.getDays()); this.setHours(hours || this.getHours()); this.setMinutes(minutes || this.getMinutes()); this.setSeconds(seconds || this.getSeconds()); this.setMilliseconds(milliseconds || this.getMilliseconds()); }; /** * Gets the time of day for this date instances. * @return {TimeSpan} TimeSpan */ Date.prototype.getTimeOfDay = function () { return new TimeSpan(0, this.getHours(), this.getMinutes(), this.getSeconds(), this.getMilliseconds()); }; Date.TimeSpan = TimeSpan; if (typeof window !== "undefined" ) { // keeping API compatible for v1.x window.TimeSpan = TimeSpan; } }()); (function () { "use strict"; var attrs = ["years", "months", "days", "hours", "minutes", "seconds", "milliseconds"]; var gFn = function (attr) { return function () { return this[attr]; }; }; var sFn = function (attr) { return function (val) { this[attr] = val; return this; }; }; var addSetFuncs = function (context, attrs) { for (var i = 0; i < attrs.length ; i++) { var $a = attrs[i], $b = $a.slice(0, 1).toUpperCase() + $a.slice(1); context.prototype[$a] = 0; context.prototype["get" + $b] = gFn($a); context.prototype["set" + $b] = sFn($a); } }; var setMonthsAndYears = function (orient, d1, d2, context) { function inc() { d1.addMonths(-orient); context.months++; if (context.months === 12) { context.years++; context.months = 0; } } if (orient === +1) { while (d1 > d2) { inc(); } } else { while (d1 < d2) { inc(); } } context.months--; context.months *= orient; context.years *= orient; }; var adjustForDST = function(orient, startDate, endDate) { var hasDSTMismatch = (false === (startDate.isDaylightSavingTime() === endDate.isDaylightSavingTime())); if (hasDSTMismatch && orient === 1) { startDate.addHours(-1); } else if (hasDSTMismatch) { startDate.addHours(1); } }; /** * TimePeriod(startDate, endDate); * TimePeriod(years, months, days, hours, minutes, seconds, milliseconds); */ var TimePeriod = function (years, months, days, hours, minutes, seconds, milliseconds) { if (arguments.length === 7) { this.set(years, months, days, hours, minutes, seconds, milliseconds); } else if (arguments.length === 2 && arguments[0] instanceof Date && arguments[1] instanceof Date) { var startDate = arguments[0].clone(); var endDate = arguments[1].clone(); var orient = (startDate > endDate) ? +1 : -1; this.dates = { start: arguments[0].clone(), end: arguments[1].clone() }; setMonthsAndYears(orient, startDate, endDate, this); adjustForDST(orient, startDate, endDate); // // TODO - adjust for DST var diff = endDate - startDate; if (diff !== 0) { var ts = new TimeSpan(diff); this.set(this.years, this.months, ts.getDays(), ts.getHours(), ts.getMinutes(), ts.getSeconds(), ts.getMilliseconds()); } } return this; }; // create all the set functions. addSetFuncs(TimePeriod, attrs); TimePeriod.prototype.set = function (years, months, days, hours, minutes, seconds, milliseconds){ this.setYears(years || this.getYears()); this.setMonths(months || this.getMonths()); this.setDays(days || this.getDays()); this.setHours(hours || this.getHours()); this.setMinutes(minutes || this.getMinutes()); this.setSeconds(seconds || this.getSeconds()); this.setMilliseconds(milliseconds || this.getMilliseconds()); }; Date.TimePeriod = TimePeriod; if (typeof window !== "undefined") { // keeping API compatible for v1.x window.TimePeriod = TimePeriod; } }()); ================================================ FILE: build/i18n/af-ZA.js ================================================ /* * DateJS Culture String File * Country Code: af-ZA * Name: Afrikaans (South Africa) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["af-ZA"] = { "name": "af-ZA", "englishName": "Afrikaans (South Africa)", "nativeName": "Afrikaans (Suid Afrika)", "Sunday": "Sondag", "Monday": "Maandag", "Tuesday": "Dinsdag", "Wednesday": "Woensdag", "Thursday": "Donderdag", "Friday": "Vrydag", "Saturday": "Saterdag", "Sun": "Son", "Mon": "Maan", "Tue": "Dins", "Wed": "Woen", "Thu": "Dond", "Fri": "Vry", "Sat": "Sat", "Su": "So", "Mo": "Ma", "Tu": "Di", "We": "Wo", "Th": "Do", "Fr": "Vr", "Sa": "Sa", "S_Sun_Initial": "S", "M_Mon_Initial": "M", "T_Tue_Initial": "D", "W_Wed_Initial": "W", "T_Thu_Initial": "D", "F_Fri_Initial": "V", "S_Sat_Initial": "S", "January": "Januarie", "February": "Februarie", "March": "Maart", "April": "April", "May": "Mei", "June": "Junie", "July": "Julie", "August": "Augustus", "September": "September", "October": "Oktober", "November": "November", "December": "Desember", "Jan_Abbr": "Jan", "Feb_Abbr": "Feb", "Mar_Abbr": "Mar", "Apr_Abbr": "Apr", "May_Abbr": "Mei", "Jun_Abbr": "Jun", "Jul_Abbr": "Jul", "Aug_Abbr": "Aug", "Sep_Abbr": "Sep", "Oct_Abbr": "Okt", "Nov_Abbr": "Nov", "Dec_Abbr": "Des", "AM": "", "PM": "nm", "firstDayOfWeek": 0, "twoDigitYearMax": 2029, "mdy": "ymd", "M/d/yyyy": "yyyy/MM/dd", "dddd, MMMM dd, yyyy": "dd MMMM yyyy", "h:mm tt": "hh:mm tt", "h:mm:ss tt": "hh:mm:ss tt", "dddd, MMMM dd, yyyy h:mm:ss tt": "dd MMMM yyyy hh:mm:ss tt", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "dd MMMM", "MMMM, yyyy": "MMMM yyyy", "/jan(uary)?/": "jan(uarie)?", "/feb(ruary)?/": "feb(ruarie)?", "/mar(ch)?/": "maart", "/apr(il)?/": "apr(il)?", "/may/": "mei", "/jun(e)?/": "jun(ie)?", "/jul(y)?/": "jul(ie)?", "/aug(ust)?/": "aug(ustus)?", "/sep(t(ember)?)?/": "sep(t(ember)?)?", "/oct(ober)?/": "okt(ober)?", "/nov(ember)?/": "nov(ember)?", "/dec(ember)?/": "des(ember)?", "/^su(n(day)?)?/": "^so(n(dag)?)?", "/^mo(n(day)?)?/": "^ma(an(dag)?)?", "/^tu(e(s(day)?)?)?/": "^di(ns(dag)?)?", "/^we(d(nesday)?)?/": "^wo(en(sdag)?)?", "/^th(u(r(s(day)?)?)?)?/": "^do(nd(erdag)?)?", "/^fr(i(day)?)?/": "^vr(y(dag)?)?", "/^sa(t(urday)?)?/": "^sa(t(erdag)?)?", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "af-ZA"; ================================================ FILE: build/i18n/ar-AE.js ================================================ /* * DateJS Culture String File * Country Code: ar-AE * Name: Arabic (U.A.E.) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["ar-AE"] = { "name": "ar-AE", "englishName": "Arabic (U.A.E.)", "nativeName": "العربية (الإمارات العربية المتحدة)", "Sunday": "الاحد", "Monday": "الاثنين", "Tuesday": "الثلاثاء", "Wednesday": "الاربعاء", "Thursday": "الخميس", "Friday": "الجمعة", "Saturday": "السبت", "Sun": "الاحد", "Mon": "الاثنين", "Tue": "الثلاثاء", "Wed": "الاربعاء", "Thu": "الخميس", "Fri": "الجمعة", "Sat": "السبت", "Su": "أ", "Mo": "ا", "Tu": "ث", "We": "أ", "Th": "خ", "Fr": "ج", "Sa": "س", "S_Sun_Initial": "أ", "M_Mon_Initial": "ا", "T_Tue_Initial": "ث", "W_Wed_Initial": "أ", "T_Thu_Initial": "خ", "F_Fri_Initial": "ج", "S_Sat_Initial": "س", "January": "يناير", "February": "فبراير", "March": "مارس", "April": "ابريل", "May": "مايو", "June": "يونيو", "July": "يوليو", "August": "اغسطس", "September": "سبتمبر", "October": "اكتوبر", "November": "نوفمبر", "December": "ديسمبر", "Jan_Abbr": "يناير", "Feb_Abbr": "فبراير", "Mar_Abbr": "مارس", "Apr_Abbr": "ابريل", "May_Abbr": "مايو", "Jun_Abbr": "يونيو", "Jul_Abbr": "يوليو", "Aug_Abbr": "اغسطس", "Sep_Abbr": "سبتمبر", "Oct_Abbr": "اكتوبر", "Nov_Abbr": "نوفمبر", "Dec_Abbr": "ديسمبر", "AM": "ص", "PM": "م", "firstDayOfWeek": 6, "twoDigitYearMax": 2029, "mdy": "dmy", "M/d/yyyy": "dd/MM/yyyy", "dddd, MMMM dd, yyyy": "dd MMMM, yyyy", "h:mm tt": "hh:mm tt", "h:mm:ss tt": "hh:mm:ss tt", "dddd, MMMM dd, yyyy h:mm:ss tt": "dd MMMM, yyyy hh:mm:ss tt", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "dd MMMM", "MMMM, yyyy": "MMMM, yyyy", "/jan(uary)?/": "يناير", "/feb(ruary)?/": "فبراير", "/mar(ch)?/": "مارس", "/apr(il)?/": "ابريل", "/may/": "مايو", "/jun(e)?/": "يونيو", "/jul(y)?/": "يوليو", "/aug(ust)?/": "اغسطس", "/sep(t(ember)?)?/": "سبتمبر", "/oct(ober)?/": "اكتوبر", "/nov(ember)?/": "نوفمبر", "/dec(ember)?/": "ديسمبر", "/^su(n(day)?)?/": "^الاحد", "/^mo(n(day)?)?/": "^ا(1)?", "/^tu(e(s(day)?)?)?/": "^الثلاثاء", "/^we(d(nesday)?)?/": "^الاربعاء", "/^th(u(r(s(day)?)?)?)?/": "^الخميس", "/^fr(i(day)?)?/": "^الجمعة", "/^sa(t(urday)?)?/": "^السبت", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "ar-AE"; ================================================ FILE: build/i18n/ar-BH.js ================================================ /* * DateJS Culture String File * Country Code: ar-BH * Name: Arabic (Bahrain) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["ar-BH"] = { "name": "ar-BH", "englishName": "Arabic (Bahrain)", "nativeName": "العربية (البحرين)", "Sunday": "الاحد", "Monday": "الاثنين", "Tuesday": "الثلاثاء", "Wednesday": "الاربعاء", "Thursday": "الخميس", "Friday": "الجمعة", "Saturday": "السبت", "Sun": "الاحد", "Mon": "الاثنين", "Tue": "الثلاثاء", "Wed": "الاربعاء", "Thu": "الخميس", "Fri": "الجمعة", "Sat": "السبت", "Su": "أ", "Mo": "ا", "Tu": "ث", "We": "أ", "Th": "خ", "Fr": "ج", "Sa": "س", "S_Sun_Initial": "أ", "M_Mon_Initial": "ا", "T_Tue_Initial": "ث", "W_Wed_Initial": "أ", "T_Thu_Initial": "خ", "F_Fri_Initial": "ج", "S_Sat_Initial": "س", "January": "يناير", "February": "فبراير", "March": "مارس", "April": "ابريل", "May": "مايو", "June": "يونيو", "July": "يوليو", "August": "اغسطس", "September": "سبتمبر", "October": "اكتوبر", "November": "نوفمبر", "December": "ديسمبر", "Jan_Abbr": "يناير", "Feb_Abbr": "فبراير", "Mar_Abbr": "مارس", "Apr_Abbr": "ابريل", "May_Abbr": "مايو", "Jun_Abbr": "يونيو", "Jul_Abbr": "يوليو", "Aug_Abbr": "اغسطس", "Sep_Abbr": "سبتمبر", "Oct_Abbr": "اكتوبر", "Nov_Abbr": "نوفمبر", "Dec_Abbr": "ديسمبر", "AM": "ص", "PM": "م", "firstDayOfWeek": 6, "twoDigitYearMax": 2029, "mdy": "dmy", "M/d/yyyy": "dd/MM/yyyy", "dddd, MMMM dd, yyyy": "dd MMMM, yyyy", "h:mm tt": "hh:mm tt", "h:mm:ss tt": "hh:mm:ss tt", "dddd, MMMM dd, yyyy h:mm:ss tt": "dd MMMM, yyyy hh:mm:ss tt", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "dd MMMM", "MMMM, yyyy": "MMMM, yyyy", "/jan(uary)?/": "يناير", "/feb(ruary)?/": "فبراير", "/mar(ch)?/": "مارس", "/apr(il)?/": "ابريل", "/may/": "مايو", "/jun(e)?/": "يونيو", "/jul(y)?/": "يوليو", "/aug(ust)?/": "اغسطس", "/sep(t(ember)?)?/": "سبتمبر", "/oct(ober)?/": "اكتوبر", "/nov(ember)?/": "نوفمبر", "/dec(ember)?/": "ديسمبر", "/^su(n(day)?)?/": "^الاحد", "/^mo(n(day)?)?/": "^ا(1)?", "/^tu(e(s(day)?)?)?/": "^الثلاثاء", "/^we(d(nesday)?)?/": "^الاربعاء", "/^th(u(r(s(day)?)?)?)?/": "^الخميس", "/^fr(i(day)?)?/": "^الجمعة", "/^sa(t(urday)?)?/": "^السبت", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "ar-BH"; ================================================ FILE: build/i18n/ar-DZ.js ================================================ /* * DateJS Culture String File * Country Code: ar-DZ * Name: Arabic (Algeria) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["ar-DZ"] = { "name": "ar-DZ", "englishName": "Arabic (Algeria)", "nativeName": "العربية (الجزائر)", "Sunday": "الاحد", "Monday": "الاثنين", "Tuesday": "الثلاثاء", "Wednesday": "الاربعاء", "Thursday": "الخميس", "Friday": "الجمعة", "Saturday": "السبت", "Sun": "الاحد", "Mon": "الاثنين", "Tue": "الثلاثاء", "Wed": "الاربعاء", "Thu": "الخميس", "Fri": "الجمعة", "Sat": "السبت", "Su": "أ", "Mo": "ا", "Tu": "ث", "We": "أ", "Th": "خ", "Fr": "ج", "Sa": "س", "S_Sun_Initial": "أ", "M_Mon_Initial": "ا", "T_Tue_Initial": "ث", "W_Wed_Initial": "أ", "T_Thu_Initial": "خ", "F_Fri_Initial": "ج", "S_Sat_Initial": "س", "January": "جانفييه", "February": "فيفرييه", "March": "مارس", "April": "أفريل", "May": "مي", "June": "جوان", "July": "جوييه", "August": "أوت", "September": "سبتمبر", "October": "اكتوبر", "November": "نوفمبر", "December": "ديسمبر", "Jan_Abbr": "جانفييه", "Feb_Abbr": "فيفرييه", "Mar_Abbr": "مارس", "Apr_Abbr": "أفريل", "May_Abbr": "مي", "Jun_Abbr": "جوان", "Jul_Abbr": "جوييه", "Aug_Abbr": "أوت", "Sep_Abbr": "سبتمبر", "Oct_Abbr": "اكتوبر", "Nov_Abbr": "نوفمبر", "Dec_Abbr": "ديسمبر", "AM": "ص", "PM": "م", "firstDayOfWeek": 6, "twoDigitYearMax": 2029, "mdy": "dmy", "M/d/yyyy": "dd-MM-yyyy", "dddd, MMMM dd, yyyy": "dd MMMM, yyyy", "h:mm tt": "H:mm", "h:mm:ss tt": "H:mm:ss", "dddd, MMMM dd, yyyy h:mm:ss tt": "dd MMMM, yyyy H:mm:ss", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "dd MMMM", "MMMM, yyyy": "MMMM, yyyy", "/jan(uary)?/": "جانفييه", "/feb(ruary)?/": "فيفرييه", "/mar(ch)?/": "مارس", "/apr(il)?/": "أفريل", "/may/": "مي", "/jun(e)?/": "جوان", "/jul(y)?/": "جوييه", "/aug(ust)?/": "أوت", "/sep(t(ember)?)?/": "سبتمبر", "/oct(ober)?/": "اكتوبر", "/nov(ember)?/": "نوفمبر", "/dec(ember)?/": "ديسمبر", "/^su(n(day)?)?/": "^الاحد", "/^mo(n(day)?)?/": "^ا(1)?", "/^tu(e(s(day)?)?)?/": "^الثلاثاء", "/^we(d(nesday)?)?/": "^الاربعاء", "/^th(u(r(s(day)?)?)?)?/": "^الخميس", "/^fr(i(day)?)?/": "^الجمعة", "/^sa(t(urday)?)?/": "^السبت", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "ar-DZ"; ================================================ FILE: build/i18n/ar-EG.js ================================================ /* * DateJS Culture String File * Country Code: ar-EG * Name: Arabic (Egypt) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["ar-EG"] = { "name": "ar-EG", "englishName": "Arabic (Egypt)", "nativeName": "العربية (مصر)", "Sunday": "الاحد", "Monday": "الاثنين", "Tuesday": "الثلاثاء", "Wednesday": "الاربعاء", "Thursday": "الخميس", "Friday": "الجمعة", "Saturday": "السبت", "Sun": "الاحد", "Mon": "الاثنين", "Tue": "الثلاثاء", "Wed": "الاربعاء", "Thu": "الخميس", "Fri": "الجمعة", "Sat": "السبت", "Su": "أ", "Mo": "ا", "Tu": "ث", "We": "أ", "Th": "خ", "Fr": "ج", "Sa": "س", "S_Sun_Initial": "أ", "M_Mon_Initial": "ا", "T_Tue_Initial": "ث", "W_Wed_Initial": "أ", "T_Thu_Initial": "خ", "F_Fri_Initial": "ج", "S_Sat_Initial": "س", "January": "يناير", "February": "فبراير", "March": "مارس", "April": "ابريل", "May": "مايو", "June": "يونيو", "July": "يوليو", "August": "اغسطس", "September": "سبتمبر", "October": "اكتوبر", "November": "نوفمبر", "December": "ديسمبر", "Jan_Abbr": "يناير", "Feb_Abbr": "فبراير", "Mar_Abbr": "مارس", "Apr_Abbr": "ابريل", "May_Abbr": "مايو", "Jun_Abbr": "يونيو", "Jul_Abbr": "يوليو", "Aug_Abbr": "اغسطس", "Sep_Abbr": "سبتمبر", "Oct_Abbr": "اكتوبر", "Nov_Abbr": "نوفمبر", "Dec_Abbr": "ديسمبر", "AM": "ص", "PM": "م", "firstDayOfWeek": 6, "twoDigitYearMax": 2029, "mdy": "dmy", "M/d/yyyy": "dd/MM/yyyy", "dddd, MMMM dd, yyyy": "dd MMMM, yyyy", "h:mm tt": "hh:mm tt", "h:mm:ss tt": "hh:mm:ss tt", "dddd, MMMM dd, yyyy h:mm:ss tt": "dd MMMM, yyyy hh:mm:ss tt", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "dd MMMM", "MMMM, yyyy": "MMMM, yyyy", "/jan(uary)?/": "يناير", "/feb(ruary)?/": "فبراير", "/mar(ch)?/": "مارس", "/apr(il)?/": "ابريل", "/may/": "مايو", "/jun(e)?/": "يونيو", "/jul(y)?/": "يوليو", "/aug(ust)?/": "اغسطس", "/sep(t(ember)?)?/": "سبتمبر", "/oct(ober)?/": "اكتوبر", "/nov(ember)?/": "نوفمبر", "/dec(ember)?/": "ديسمبر", "/^su(n(day)?)?/": "^الاحد", "/^mo(n(day)?)?/": "^ا(1)?", "/^tu(e(s(day)?)?)?/": "^الثلاثاء", "/^we(d(nesday)?)?/": "^الاربعاء", "/^th(u(r(s(day)?)?)?)?/": "^الخميس", "/^fr(i(day)?)?/": "^الجمعة", "/^sa(t(urday)?)?/": "^السبت", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "ar-EG"; ================================================ FILE: build/i18n/ar-IQ.js ================================================ /* * DateJS Culture String File * Country Code: ar-IQ * Name: Arabic (Iraq) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["ar-IQ"] = { "name": "ar-IQ", "englishName": "Arabic (Iraq)", "nativeName": "العربية (العراق)", "Sunday": "الاحد", "Monday": "الاثنين", "Tuesday": "الثلاثاء", "Wednesday": "الاربعاء", "Thursday": "الخميس", "Friday": "الجمعة", "Saturday": "السبت", "Sun": "الاحد", "Mon": "الاثنين", "Tue": "الثلاثاء", "Wed": "الاربعاء", "Thu": "الخميس", "Fri": "الجمعة", "Sat": "السبت", "Su": "أ", "Mo": "ا", "Tu": "ث", "We": "أ", "Th": "خ", "Fr": "ج", "Sa": "س", "S_Sun_Initial": "أ", "M_Mon_Initial": "ا", "T_Tue_Initial": "ث", "W_Wed_Initial": "أ", "T_Thu_Initial": "خ", "F_Fri_Initial": "ج", "S_Sat_Initial": "س", "January": "كانون الثاني", "February": "شباط", "March": "آذار", "April": "نيسان", "May": "أيار", "June": "حزيران", "July": "تموز", "August": "آب", "September": "أيلول", "October": "تشرين الأول", "November": "تشرين الثاني", "December": "كانون الأول", "Jan_Abbr": "كانون الثاني", "Feb_Abbr": "شباط", "Mar_Abbr": "آذار", "Apr_Abbr": "نيسان", "May_Abbr": "أيار", "Jun_Abbr": "حزيران", "Jul_Abbr": "تموز", "Aug_Abbr": "آب", "Sep_Abbr": "أيلول", "Oct_Abbr": "تشرين الأول", "Nov_Abbr": "تشرين الثاني", "Dec_Abbr": "كانون الأول", "AM": "ص", "PM": "م", "firstDayOfWeek": 6, "twoDigitYearMax": 2029, "mdy": "dmy", "M/d/yyyy": "dd/MM/yyyy", "dddd, MMMM dd, yyyy": "dd MMMM, yyyy", "h:mm tt": "hh:mm tt", "h:mm:ss tt": "hh:mm:ss tt", "dddd, MMMM dd, yyyy h:mm:ss tt": "dd MMMM, yyyy hh:mm:ss tt", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "dd MMMM", "MMMM, yyyy": "MMMM, yyyy", "/jan(uary)?/": "كانون الثاني", "/feb(ruary)?/": "شباط", "/mar(ch)?/": "آذار", "/apr(il)?/": "نيسان", "/may/": "أيار", "/jun(e)?/": "حزيران", "/jul(y)?/": "تموز", "/aug(ust)?/": "آب", "/sep(t(ember)?)?/": "أيلول", "/oct(ober)?/": "تشرين الأول", "/nov(ember)?/": "تشرين الثاني", "/dec(ember)?/": "كانون الأول", "/^su(n(day)?)?/": "^الاحد", "/^mo(n(day)?)?/": "^ا(1)?", "/^tu(e(s(day)?)?)?/": "^الثلاثاء", "/^we(d(nesday)?)?/": "^الاربعاء", "/^th(u(r(s(day)?)?)?)?/": "^الخميس", "/^fr(i(day)?)?/": "^الجمعة", "/^sa(t(urday)?)?/": "^السبت", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "ar-IQ"; ================================================ FILE: build/i18n/ar-JO.js ================================================ /* * DateJS Culture String File * Country Code: ar-JO * Name: Arabic (Jordan) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["ar-JO"] = { "name": "ar-JO", "englishName": "Arabic (Jordan)", "nativeName": "العربية (الأردن)", "Sunday": "الاحد", "Monday": "الاثنين", "Tuesday": "الثلاثاء", "Wednesday": "الاربعاء", "Thursday": "الخميس", "Friday": "الجمعة", "Saturday": "السبت", "Sun": "الاحد", "Mon": "الاثنين", "Tue": "الثلاثاء", "Wed": "الاربعاء", "Thu": "الخميس", "Fri": "الجمعة", "Sat": "السبت", "Su": "أ", "Mo": "ا", "Tu": "ث", "We": "أ", "Th": "خ", "Fr": "ج", "Sa": "س", "S_Sun_Initial": "أ", "M_Mon_Initial": "ا", "T_Tue_Initial": "ث", "W_Wed_Initial": "أ", "T_Thu_Initial": "خ", "F_Fri_Initial": "ج", "S_Sat_Initial": "س", "January": "كانون الثاني", "February": "شباط", "March": "آذار", "April": "نيسان", "May": "أيار", "June": "حزيران", "July": "تموز", "August": "آب", "September": "أيلول", "October": "تشرين الأول", "November": "تشرين الثاني", "December": "كانون الأول", "Jan_Abbr": "كانون الثاني", "Feb_Abbr": "شباط", "Mar_Abbr": "آذار", "Apr_Abbr": "نيسان", "May_Abbr": "أيار", "Jun_Abbr": "حزيران", "Jul_Abbr": "تموز", "Aug_Abbr": "آب", "Sep_Abbr": "أيلول", "Oct_Abbr": "تشرين الأول", "Nov_Abbr": "تشرين الثاني", "Dec_Abbr": "كانون الأول", "AM": "ص", "PM": "م", "firstDayOfWeek": 6, "twoDigitYearMax": 2029, "mdy": "dmy", "M/d/yyyy": "dd/MM/yyyy", "dddd, MMMM dd, yyyy": "dd MMMM, yyyy", "h:mm tt": "hh:mm tt", "h:mm:ss tt": "hh:mm:ss tt", "dddd, MMMM dd, yyyy h:mm:ss tt": "dd MMMM, yyyy hh:mm:ss tt", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "dd MMMM", "MMMM, yyyy": "MMMM, yyyy", "/jan(uary)?/": "كانون الثاني", "/feb(ruary)?/": "شباط", "/mar(ch)?/": "آذار", "/apr(il)?/": "نيسان", "/may/": "أيار", "/jun(e)?/": "حزيران", "/jul(y)?/": "تموز", "/aug(ust)?/": "آب", "/sep(t(ember)?)?/": "أيلول", "/oct(ober)?/": "تشرين الأول", "/nov(ember)?/": "تشرين الثاني", "/dec(ember)?/": "كانون الأول", "/^su(n(day)?)?/": "^الاحد", "/^mo(n(day)?)?/": "^ا(1)?", "/^tu(e(s(day)?)?)?/": "^الثلاثاء", "/^we(d(nesday)?)?/": "^الاربعاء", "/^th(u(r(s(day)?)?)?)?/": "^الخميس", "/^fr(i(day)?)?/": "^الجمعة", "/^sa(t(urday)?)?/": "^السبت", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "ar-JO"; ================================================ FILE: build/i18n/ar-KW.js ================================================ /* * DateJS Culture String File * Country Code: ar-KW * Name: Arabic (Kuwait) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["ar-KW"] = { "name": "ar-KW", "englishName": "Arabic (Kuwait)", "nativeName": "العربية (الكويت)", "Sunday": "الاحد", "Monday": "الاثنين", "Tuesday": "الثلاثاء", "Wednesday": "الاربعاء", "Thursday": "الخميس", "Friday": "الجمعة", "Saturday": "السبت", "Sun": "الاحد", "Mon": "الاثنين", "Tue": "الثلاثاء", "Wed": "الاربعاء", "Thu": "الخميس", "Fri": "الجمعة", "Sat": "السبت", "Su": "أ", "Mo": "ا", "Tu": "ث", "We": "أ", "Th": "خ", "Fr": "ج", "Sa": "س", "S_Sun_Initial": "أ", "M_Mon_Initial": "ا", "T_Tue_Initial": "ث", "W_Wed_Initial": "أ", "T_Thu_Initial": "خ", "F_Fri_Initial": "ج", "S_Sat_Initial": "س", "January": "يناير", "February": "فبراير", "March": "مارس", "April": "ابريل", "May": "مايو", "June": "يونيو", "July": "يوليو", "August": "اغسطس", "September": "سبتمبر", "October": "اكتوبر", "November": "نوفمبر", "December": "ديسمبر", "Jan_Abbr": "يناير", "Feb_Abbr": "فبراير", "Mar_Abbr": "مارس", "Apr_Abbr": "ابريل", "May_Abbr": "مايو", "Jun_Abbr": "يونيو", "Jul_Abbr": "يوليو", "Aug_Abbr": "اغسطس", "Sep_Abbr": "سبتمبر", "Oct_Abbr": "اكتوبر", "Nov_Abbr": "نوفمبر", "Dec_Abbr": "ديسمبر", "AM": "ص", "PM": "م", "firstDayOfWeek": 6, "twoDigitYearMax": 2029, "mdy": "dmy", "M/d/yyyy": "dd/MM/yyyy", "dddd, MMMM dd, yyyy": "dd MMMM, yyyy", "h:mm tt": "hh:mm tt", "h:mm:ss tt": "hh:mm:ss tt", "dddd, MMMM dd, yyyy h:mm:ss tt": "dd MMMM, yyyy hh:mm:ss tt", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "dd MMMM", "MMMM, yyyy": "MMMM, yyyy", "/jan(uary)?/": "يناير", "/feb(ruary)?/": "فبراير", "/mar(ch)?/": "مارس", "/apr(il)?/": "ابريل", "/may/": "مايو", "/jun(e)?/": "يونيو", "/jul(y)?/": "يوليو", "/aug(ust)?/": "اغسطس", "/sep(t(ember)?)?/": "سبتمبر", "/oct(ober)?/": "اكتوبر", "/nov(ember)?/": "نوفمبر", "/dec(ember)?/": "ديسمبر", "/^su(n(day)?)?/": "^الاحد", "/^mo(n(day)?)?/": "^ا(1)?", "/^tu(e(s(day)?)?)?/": "^الثلاثاء", "/^we(d(nesday)?)?/": "^الاربعاء", "/^th(u(r(s(day)?)?)?)?/": "^الخميس", "/^fr(i(day)?)?/": "^الجمعة", "/^sa(t(urday)?)?/": "^السبت", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "ar-KW"; ================================================ FILE: build/i18n/ar-LB.js ================================================ /* * DateJS Culture String File * Country Code: ar-LB * Name: Arabic (Lebanon) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["ar-LB"] = { "name": "ar-LB", "englishName": "Arabic (Lebanon)", "nativeName": "العربية (لبنان)", "Sunday": "الاحد", "Monday": "الاثنين", "Tuesday": "الثلاثاء", "Wednesday": "الاربعاء", "Thursday": "الخميس", "Friday": "الجمعة", "Saturday": "السبت", "Sun": "الاحد", "Mon": "الاثنين", "Tue": "الثلاثاء", "Wed": "الاربعاء", "Thu": "الخميس", "Fri": "الجمعة", "Sat": "السبت", "Su": "أ", "Mo": "ا", "Tu": "ث", "We": "أ", "Th": "خ", "Fr": "ج", "Sa": "س", "S_Sun_Initial": "أ", "M_Mon_Initial": "ا", "T_Tue_Initial": "ث", "W_Wed_Initial": "أ", "T_Thu_Initial": "خ", "F_Fri_Initial": "ج", "S_Sat_Initial": "س", "January": "كانون الثاني", "February": "شباط", "March": "آذار", "April": "نيسان", "May": "أيار", "June": "حزيران", "July": "تموز", "August": "آب", "September": "أيلول", "October": "تشرين الأول", "November": "تشرين الثاني", "December": "كانون الأول", "Jan_Abbr": "كانون الثاني", "Feb_Abbr": "شباط", "Mar_Abbr": "آذار", "Apr_Abbr": "نيسان", "May_Abbr": "أيار", "Jun_Abbr": "حزيران", "Jul_Abbr": "تموز", "Aug_Abbr": "آب", "Sep_Abbr": "أيلول", "Oct_Abbr": "تشرين الأول", "Nov_Abbr": "تشرين الثاني", "Dec_Abbr": "كانون الأول", "AM": "ص", "PM": "م", "firstDayOfWeek": 1, "twoDigitYearMax": 2029, "mdy": "dmy", "M/d/yyyy": "dd/MM/yyyy", "dddd, MMMM dd, yyyy": "dd MMMM, yyyy", "h:mm tt": "hh:mm tt", "h:mm:ss tt": "hh:mm:ss tt", "dddd, MMMM dd, yyyy h:mm:ss tt": "dd MMMM, yyyy hh:mm:ss tt", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "dd MMMM", "MMMM, yyyy": "MMMM, yyyy", "/jan(uary)?/": "كانون الثاني", "/feb(ruary)?/": "شباط", "/mar(ch)?/": "آذار", "/apr(il)?/": "نيسان", "/may/": "أيار", "/jun(e)?/": "حزيران", "/jul(y)?/": "تموز", "/aug(ust)?/": "آب", "/sep(t(ember)?)?/": "أيلول", "/oct(ober)?/": "تشرين الأول", "/nov(ember)?/": "تشرين الثاني", "/dec(ember)?/": "كانون الأول", "/^su(n(day)?)?/": "^الاحد", "/^mo(n(day)?)?/": "^ا(1)?", "/^tu(e(s(day)?)?)?/": "^الثلاثاء", "/^we(d(nesday)?)?/": "^الاربعاء", "/^th(u(r(s(day)?)?)?)?/": "^الخميس", "/^fr(i(day)?)?/": "^الجمعة", "/^sa(t(urday)?)?/": "^السبت", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "ar-LB"; ================================================ FILE: build/i18n/ar-LY.js ================================================ /* * DateJS Culture String File * Country Code: ar-LY * Name: Arabic (Libya) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["ar-LY"] = { "name": "ar-LY", "englishName": "Arabic (Libya)", "nativeName": "العربية (ليبيا)", "Sunday": "الاحد", "Monday": "الاثنين", "Tuesday": "الثلاثاء", "Wednesday": "الاربعاء", "Thursday": "الخميس", "Friday": "الجمعة", "Saturday": "السبت", "Sun": "الاحد", "Mon": "الاثنين", "Tue": "الثلاثاء", "Wed": "الاربعاء", "Thu": "الخميس", "Fri": "الجمعة", "Sat": "السبت", "Su": "أ", "Mo": "ا", "Tu": "ث", "We": "أ", "Th": "خ", "Fr": "ج", "Sa": "س", "S_Sun_Initial": "أ", "M_Mon_Initial": "ا", "T_Tue_Initial": "ث", "W_Wed_Initial": "أ", "T_Thu_Initial": "خ", "F_Fri_Initial": "ج", "S_Sat_Initial": "س", "January": "يناير", "February": "فبراير", "March": "مارس", "April": "ابريل", "May": "مايو", "June": "يونيو", "July": "يوليو", "August": "اغسطس", "September": "سبتمبر", "October": "اكتوبر", "November": "نوفمبر", "December": "ديسمبر", "Jan_Abbr": "يناير", "Feb_Abbr": "فبراير", "Mar_Abbr": "مارس", "Apr_Abbr": "ابريل", "May_Abbr": "مايو", "Jun_Abbr": "يونيو", "Jul_Abbr": "يوليو", "Aug_Abbr": "اغسطس", "Sep_Abbr": "سبتمبر", "Oct_Abbr": "اكتوبر", "Nov_Abbr": "نوفمبر", "Dec_Abbr": "ديسمبر", "AM": "ص", "PM": "م", "firstDayOfWeek": 6, "twoDigitYearMax": 2029, "mdy": "dmy", "M/d/yyyy": "dd/MM/yyyy", "dddd, MMMM dd, yyyy": "dd MMMM, yyyy", "h:mm tt": "hh:mm tt", "h:mm:ss tt": "hh:mm:ss tt", "dddd, MMMM dd, yyyy h:mm:ss tt": "dd MMMM, yyyy hh:mm:ss tt", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "dd MMMM", "MMMM, yyyy": "MMMM, yyyy", "/jan(uary)?/": "يناير", "/feb(ruary)?/": "فبراير", "/mar(ch)?/": "مارس", "/apr(il)?/": "ابريل", "/may/": "مايو", "/jun(e)?/": "يونيو", "/jul(y)?/": "يوليو", "/aug(ust)?/": "اغسطس", "/sep(t(ember)?)?/": "سبتمبر", "/oct(ober)?/": "اكتوبر", "/nov(ember)?/": "نوفمبر", "/dec(ember)?/": "ديسمبر", "/^su(n(day)?)?/": "^الاحد", "/^mo(n(day)?)?/": "^ا(1)?", "/^tu(e(s(day)?)?)?/": "^الثلاثاء", "/^we(d(nesday)?)?/": "^الاربعاء", "/^th(u(r(s(day)?)?)?)?/": "^الخميس", "/^fr(i(day)?)?/": "^الجمعة", "/^sa(t(urday)?)?/": "^السبت", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "ar-LY"; ================================================ FILE: build/i18n/ar-MA.js ================================================ /* * DateJS Culture String File * Country Code: ar-MA * Name: Arabic (Morocco) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["ar-MA"] = { "name": "ar-MA", "englishName": "Arabic (Morocco)", "nativeName": "العربية (المملكة المغربية)", "Sunday": "الاحد", "Monday": "الاثنين", "Tuesday": "الثلاثاء", "Wednesday": "الاربعاء", "Thursday": "الخميس", "Friday": "الجمعة", "Saturday": "السبت", "Sun": "الاحد", "Mon": "الاثنين", "Tue": "الثلاثاء", "Wed": "الاربعاء", "Thu": "الخميس", "Fri": "الجمعة", "Sat": "السبت", "Su": "أ", "Mo": "ا", "Tu": "ث", "We": "أ", "Th": "خ", "Fr": "ج", "Sa": "س", "S_Sun_Initial": "أ", "M_Mon_Initial": "ا", "T_Tue_Initial": "ث", "W_Wed_Initial": "أ", "T_Thu_Initial": "خ", "F_Fri_Initial": "ج", "S_Sat_Initial": "س", "January": "يناير", "February": "فبراير", "March": "مارس", "April": "ابريل", "May": "ماي", "June": "يونيو", "July": "يوليوز", "August": "غشت", "September": "شتنبر", "October": "اكتوبر", "November": "نونبر", "December": "دجنبر", "Jan_Abbr": "يناير", "Feb_Abbr": "فبراير", "Mar_Abbr": "مارس", "Apr_Abbr": "ابريل", "May_Abbr": "ماي", "Jun_Abbr": "يونيو", "Jul_Abbr": "يوليوز", "Aug_Abbr": "غشت", "Sep_Abbr": "شتنبر", "Oct_Abbr": "اكتوبر", "Nov_Abbr": "نونبر", "Dec_Abbr": "دجنبر", "AM": "ص", "PM": "م", "firstDayOfWeek": 1, "twoDigitYearMax": 2029, "mdy": "dmy", "M/d/yyyy": "dd-MM-yyyy", "dddd, MMMM dd, yyyy": "dd MMMM, yyyy", "h:mm tt": "H:mm", "h:mm:ss tt": "H:mm:ss", "dddd, MMMM dd, yyyy h:mm:ss tt": "dd MMMM, yyyy H:mm:ss", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "dd MMMM", "MMMM, yyyy": "MMMM, yyyy", "/jan(uary)?/": "يناير", "/feb(ruary)?/": "فبراير", "/mar(ch)?/": "مارس", "/apr(il)?/": "ابريل", "/may/": "ماي", "/jun(e)?/": "يونيو", "/jul(y)?/": "يوليوز", "/aug(ust)?/": "غشت", "/sep(t(ember)?)?/": "شتنبر", "/oct(ober)?/": "اكتوبر", "/nov(ember)?/": "نونبر", "/dec(ember)?/": "دجنبر", "/^su(n(day)?)?/": "^الاحد", "/^mo(n(day)?)?/": "^ا(1)?", "/^tu(e(s(day)?)?)?/": "^الثلاثاء", "/^we(d(nesday)?)?/": "^الاربعاء", "/^th(u(r(s(day)?)?)?)?/": "^الخميس", "/^fr(i(day)?)?/": "^الجمعة", "/^sa(t(urday)?)?/": "^السبت", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "ar-MA"; ================================================ FILE: build/i18n/ar-OM.js ================================================ /* * DateJS Culture String File * Country Code: ar-OM * Name: Arabic (Oman) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["ar-OM"] = { "name": "ar-OM", "englishName": "Arabic (Oman)", "nativeName": "العربية (عمان)", "Sunday": "الاحد", "Monday": "الاثنين", "Tuesday": "الثلاثاء", "Wednesday": "الاربعاء", "Thursday": "الخميس", "Friday": "الجمعة", "Saturday": "السبت", "Sun": "الاحد", "Mon": "الاثنين", "Tue": "الثلاثاء", "Wed": "الاربعاء", "Thu": "الخميس", "Fri": "الجمعة", "Sat": "السبت", "Su": "أ", "Mo": "ا", "Tu": "ث", "We": "أ", "Th": "خ", "Fr": "ج", "Sa": "س", "S_Sun_Initial": "أ", "M_Mon_Initial": "ا", "T_Tue_Initial": "ث", "W_Wed_Initial": "أ", "T_Thu_Initial": "خ", "F_Fri_Initial": "ج", "S_Sat_Initial": "س", "January": "يناير", "February": "فبراير", "March": "مارس", "April": "ابريل", "May": "مايو", "June": "يونيو", "July": "يوليو", "August": "اغسطس", "September": "سبتمبر", "October": "اكتوبر", "November": "نوفمبر", "December": "ديسمبر", "Jan_Abbr": "يناير", "Feb_Abbr": "فبراير", "Mar_Abbr": "مارس", "Apr_Abbr": "ابريل", "May_Abbr": "مايو", "Jun_Abbr": "يونيو", "Jul_Abbr": "يوليو", "Aug_Abbr": "اغسطس", "Sep_Abbr": "سبتمبر", "Oct_Abbr": "اكتوبر", "Nov_Abbr": "نوفمبر", "Dec_Abbr": "ديسمبر", "AM": "ص", "PM": "م", "firstDayOfWeek": 6, "twoDigitYearMax": 2029, "mdy": "dmy", "M/d/yyyy": "dd/MM/yyyy", "dddd, MMMM dd, yyyy": "dd MMMM, yyyy", "h:mm tt": "hh:mm tt", "h:mm:ss tt": "hh:mm:ss tt", "dddd, MMMM dd, yyyy h:mm:ss tt": "dd MMMM, yyyy hh:mm:ss tt", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "dd MMMM", "MMMM, yyyy": "MMMM, yyyy", "/jan(uary)?/": "يناير", "/feb(ruary)?/": "فبراير", "/mar(ch)?/": "مارس", "/apr(il)?/": "ابريل", "/may/": "مايو", "/jun(e)?/": "يونيو", "/jul(y)?/": "يوليو", "/aug(ust)?/": "اغسطس", "/sep(t(ember)?)?/": "سبتمبر", "/oct(ober)?/": "اكتوبر", "/nov(ember)?/": "نوفمبر", "/dec(ember)?/": "ديسمبر", "/^su(n(day)?)?/": "^الاحد", "/^mo(n(day)?)?/": "^ا(1)?", "/^tu(e(s(day)?)?)?/": "^الثلاثاء", "/^we(d(nesday)?)?/": "^الاربعاء", "/^th(u(r(s(day)?)?)?)?/": "^الخميس", "/^fr(i(day)?)?/": "^الجمعة", "/^sa(t(urday)?)?/": "^السبت", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "ar-OM"; ================================================ FILE: build/i18n/ar-QA.js ================================================ /* * DateJS Culture String File * Country Code: ar-QA * Name: Arabic (Qatar) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["ar-QA"] = { "name": "ar-QA", "englishName": "Arabic (Qatar)", "nativeName": "العربية (قطر)", "Sunday": "الاحد", "Monday": "الاثنين", "Tuesday": "الثلاثاء", "Wednesday": "الاربعاء", "Thursday": "الخميس", "Friday": "الجمعة", "Saturday": "السبت", "Sun": "الاحد", "Mon": "الاثنين", "Tue": "الثلاثاء", "Wed": "الاربعاء", "Thu": "الخميس", "Fri": "الجمعة", "Sat": "السبت", "Su": "أ", "Mo": "ا", "Tu": "ث", "We": "أ", "Th": "خ", "Fr": "ج", "Sa": "س", "S_Sun_Initial": "أ", "M_Mon_Initial": "ا", "T_Tue_Initial": "ث", "W_Wed_Initial": "أ", "T_Thu_Initial": "خ", "F_Fri_Initial": "ج", "S_Sat_Initial": "س", "January": "يناير", "February": "فبراير", "March": "مارس", "April": "ابريل", "May": "مايو", "June": "يونيو", "July": "يوليو", "August": "اغسطس", "September": "سبتمبر", "October": "اكتوبر", "November": "نوفمبر", "December": "ديسمبر", "Jan_Abbr": "يناير", "Feb_Abbr": "فبراير", "Mar_Abbr": "مارس", "Apr_Abbr": "ابريل", "May_Abbr": "مايو", "Jun_Abbr": "يونيو", "Jul_Abbr": "يوليو", "Aug_Abbr": "اغسطس", "Sep_Abbr": "سبتمبر", "Oct_Abbr": "اكتوبر", "Nov_Abbr": "نوفمبر", "Dec_Abbr": "ديسمبر", "AM": "ص", "PM": "م", "firstDayOfWeek": 6, "twoDigitYearMax": 2029, "mdy": "dmy", "M/d/yyyy": "dd/MM/yyyy", "dddd, MMMM dd, yyyy": "dd MMMM, yyyy", "h:mm tt": "hh:mm tt", "h:mm:ss tt": "hh:mm:ss tt", "dddd, MMMM dd, yyyy h:mm:ss tt": "dd MMMM, yyyy hh:mm:ss tt", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "dd MMMM", "MMMM, yyyy": "MMMM, yyyy", "/jan(uary)?/": "يناير", "/feb(ruary)?/": "فبراير", "/mar(ch)?/": "مارس", "/apr(il)?/": "ابريل", "/may/": "مايو", "/jun(e)?/": "يونيو", "/jul(y)?/": "يوليو", "/aug(ust)?/": "اغسطس", "/sep(t(ember)?)?/": "سبتمبر", "/oct(ober)?/": "اكتوبر", "/nov(ember)?/": "نوفمبر", "/dec(ember)?/": "ديسمبر", "/^su(n(day)?)?/": "^الاحد", "/^mo(n(day)?)?/": "^ا(1)?", "/^tu(e(s(day)?)?)?/": "^الثلاثاء", "/^we(d(nesday)?)?/": "^الاربعاء", "/^th(u(r(s(day)?)?)?)?/": "^الخميس", "/^fr(i(day)?)?/": "^الجمعة", "/^sa(t(urday)?)?/": "^السبت", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "ar-QA"; ================================================ FILE: build/i18n/ar-SA.js ================================================ /* * DateJS Culture String File * Country Code: ar-SA * Name: Arabic (Saudi Arabia) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["ar-SA"] = { "name": "ar-SA", "englishName": "Arabic (Saudi Arabia)", "nativeName": "العربية (المملكة العربية السعودية)", "Sunday": "الاحد", "Monday": "الاثنين", "Tuesday": "الثلاثاء", "Wednesday": "الاربعاء", "Thursday": "الخميس", "Friday": "الجمعة", "Saturday": "السبت", "Sun": "الاحد", "Mon": "الاثنين", "Tue": "الثلاثاء", "Wed": "الاربعاء", "Thu": "الخميس", "Fri": "الجمعة", "Sat": "السبت", "Su": "ح", "Mo": "ن", "Tu": "ث", "We": "ر", "Th": "خ", "Fr": "ج", "Sa": "س", "S_Sun_Initial": "ح", "M_Mon_Initial": "ن", "T_Tue_Initial": "ث", "W_Wed_Initial": "ر", "T_Thu_Initial": "خ", "F_Fri_Initial": "ج", "S_Sat_Initial": "س", "January": "محرم", "February": "صفر", "March": "ربيع الأول", "April": "ربيع الثاني", "May": "جمادى الأولى", "June": "جمادى الثانية", "July": "رجب", "August": "شعبان", "September": "رمضان", "October": "شوال", "November": "ذو القعدة", "December": "ذو الحجة", "Jan_Abbr": "محرم", "Feb_Abbr": "صفر", "Mar_Abbr": "ربيع الاول", "Apr_Abbr": "ربيع الثاني", "May_Abbr": "جمادى الاولى", "Jun_Abbr": "جمادى الثانية", "Jul_Abbr": "رجب", "Aug_Abbr": "شعبان", "Sep_Abbr": "رمضان", "Oct_Abbr": "شوال", "Nov_Abbr": "ذو القعدة", "Dec_Abbr": "ذو الحجة", "AM": "ص", "PM": "م", "firstDayOfWeek": 6, "twoDigitYearMax": 1451, "mdy": "dmy", "M/d/yyyy": "dd/MM/yy", "dddd, MMMM dd, yyyy": "dd/MMMM/yyyy", "h:mm tt": "hh:mm tt", "h:mm:ss tt": "hh:mm:ss tt", "dddd, MMMM dd, yyyy h:mm:ss tt": "dd/MMMM/yyyy hh:mm:ss tt", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "dd MMMM", "MMMM, yyyy": "MMMM, yyyy", "/jan(uary)?/": "محرم", "/feb(ruary)?/": "صفر", "/mar(ch)?/": "ربيع الأول", "/apr(il)?/": "ربيع الثاني", "/may/": "جمادى الأولى", "/jun(e)?/": "جمادى الثانية", "/jul(y)?/": "رجب", "/aug(ust)?/": "شعبان", "/sep(t(ember)?)?/": "رمضان", "/oct(ober)?/": "شوال", "/nov(ember)?/": "ذو القعدة", "/dec(ember)?/": "ذو الحجة", "/^su(n(day)?)?/": "^الاحد", "/^mo(n(day)?)?/": "^الاثنين", "/^tu(e(s(day)?)?)?/": "^الثلاثاء", "/^we(d(nesday)?)?/": "^الاربعاء", "/^th(u(r(s(day)?)?)?)?/": "^الخميس", "/^fr(i(day)?)?/": "^الجمعة", "/^sa(t(urday)?)?/": "^السبت", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "ar-SA"; ================================================ FILE: build/i18n/ar-SY.js ================================================ /* * DateJS Culture String File * Country Code: ar-SY * Name: Arabic (Syria) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["ar-SY"] = { "name": "ar-SY", "englishName": "Arabic (Syria)", "nativeName": "العربية (سوريا)", "Sunday": "الاحد", "Monday": "الاثنين", "Tuesday": "الثلاثاء", "Wednesday": "الاربعاء", "Thursday": "الخميس", "Friday": "الجمعة", "Saturday": "السبت", "Sun": "الاحد", "Mon": "الاثنين", "Tue": "الثلاثاء", "Wed": "الاربعاء", "Thu": "الخميس", "Fri": "الجمعة", "Sat": "السبت", "Su": "أ", "Mo": "ا", "Tu": "ث", "We": "أ", "Th": "خ", "Fr": "ج", "Sa": "س", "S_Sun_Initial": "أ", "M_Mon_Initial": "ا", "T_Tue_Initial": "ث", "W_Wed_Initial": "أ", "T_Thu_Initial": "خ", "F_Fri_Initial": "ج", "S_Sat_Initial": "س", "January": "كانون الثاني", "February": "شباط", "March": "آذار", "April": "نيسان", "May": "أيار", "June": "حزيران", "July": "تموز", "August": "آب", "September": "أيلول", "October": "تشرين الأول", "November": "تشرين الثاني", "December": "كانون الأول", "Jan_Abbr": "كانون الثاني", "Feb_Abbr": "شباط", "Mar_Abbr": "آذار", "Apr_Abbr": "نيسان", "May_Abbr": "أيار", "Jun_Abbr": "حزيران", "Jul_Abbr": "تموز", "Aug_Abbr": "آب", "Sep_Abbr": "أيلول", "Oct_Abbr": "تشرين الأول", "Nov_Abbr": "تشرين الثاني", "Dec_Abbr": "كانون الأول", "AM": "ص", "PM": "م", "firstDayOfWeek": 6, "twoDigitYearMax": 2029, "mdy": "dmy", "M/d/yyyy": "dd/MM/yyyy", "dddd, MMMM dd, yyyy": "dd MMMM, yyyy", "h:mm tt": "hh:mm tt", "h:mm:ss tt": "hh:mm:ss tt", "dddd, MMMM dd, yyyy h:mm:ss tt": "dd MMMM, yyyy hh:mm:ss tt", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "dd MMMM", "MMMM, yyyy": "MMMM, yyyy", "/jan(uary)?/": "كانون الثاني", "/feb(ruary)?/": "شباط", "/mar(ch)?/": "آذار", "/apr(il)?/": "نيسان", "/may/": "أيار", "/jun(e)?/": "حزيران", "/jul(y)?/": "تموز", "/aug(ust)?/": "آب", "/sep(t(ember)?)?/": "أيلول", "/oct(ober)?/": "تشرين الأول", "/nov(ember)?/": "تشرين الثاني", "/dec(ember)?/": "كانون الأول", "/^su(n(day)?)?/": "^الاحد", "/^mo(n(day)?)?/": "^ا(1)?", "/^tu(e(s(day)?)?)?/": "^الثلاثاء", "/^we(d(nesday)?)?/": "^الاربعاء", "/^th(u(r(s(day)?)?)?)?/": "^الخميس", "/^fr(i(day)?)?/": "^الجمعة", "/^sa(t(urday)?)?/": "^السبت", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "ar-SY"; ================================================ FILE: build/i18n/ar-TN.js ================================================ /* * DateJS Culture String File * Country Code: ar-TN * Name: Arabic (Tunisia) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["ar-TN"] = { "name": "ar-TN", "englishName": "Arabic (Tunisia)", "nativeName": "العربية (تونس)", "Sunday": "الاحد", "Monday": "الاثنين", "Tuesday": "الثلاثاء", "Wednesday": "الاربعاء", "Thursday": "الخميس", "Friday": "الجمعة", "Saturday": "السبت", "Sun": "الاحد", "Mon": "الاثنين", "Tue": "الثلاثاء", "Wed": "الاربعاء", "Thu": "الخميس", "Fri": "الجمعة", "Sat": "السبت", "Su": "أ", "Mo": "ا", "Tu": "ث", "We": "أ", "Th": "خ", "Fr": "ج", "Sa": "س", "S_Sun_Initial": "أ", "M_Mon_Initial": "ا", "T_Tue_Initial": "ث", "W_Wed_Initial": "أ", "T_Thu_Initial": "خ", "F_Fri_Initial": "ج", "S_Sat_Initial": "س", "January": "جانفي", "February": "فيفري", "March": "مارس", "April": "افريل", "May": "ماي", "June": "جوان", "July": "جويلية", "August": "اوت", "September": "سبتمبر", "October": "اكتوبر", "November": "نوفمبر", "December": "ديسمبر", "Jan_Abbr": "جانفي", "Feb_Abbr": "فيفري", "Mar_Abbr": "مارس", "Apr_Abbr": "افريل", "May_Abbr": "ماي", "Jun_Abbr": "جوان", "Jul_Abbr": "جويلية", "Aug_Abbr": "اوت", "Sep_Abbr": "سبتمبر", "Oct_Abbr": "اكتوبر", "Nov_Abbr": "نوفمبر", "Dec_Abbr": "ديسمبر", "AM": "ص", "PM": "م", "firstDayOfWeek": 1, "twoDigitYearMax": 2029, "mdy": "dmy", "M/d/yyyy": "dd-MM-yyyy", "dddd, MMMM dd, yyyy": "dd MMMM, yyyy", "h:mm tt": "H:mm", "h:mm:ss tt": "H:mm:ss", "dddd, MMMM dd, yyyy h:mm:ss tt": "dd MMMM, yyyy H:mm:ss", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "dd MMMM", "MMMM, yyyy": "MMMM, yyyy", "/jan(uary)?/": "جانفي", "/feb(ruary)?/": "فيفري", "/mar(ch)?/": "مارس", "/apr(il)?/": "افريل", "/may/": "ماي", "/jun(e)?/": "جوان", "/jul(y)?/": "جويلية", "/aug(ust)?/": "اوت", "/sep(t(ember)?)?/": "سبتمبر", "/oct(ober)?/": "اكتوبر", "/nov(ember)?/": "نوفمبر", "/dec(ember)?/": "ديسمبر", "/^su(n(day)?)?/": "^الاحد", "/^mo(n(day)?)?/": "^ا(1)?", "/^tu(e(s(day)?)?)?/": "^الثلاثاء", "/^we(d(nesday)?)?/": "^الاربعاء", "/^th(u(r(s(day)?)?)?)?/": "^الخميس", "/^fr(i(day)?)?/": "^الجمعة", "/^sa(t(urday)?)?/": "^السبت", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "ar-TN"; ================================================ FILE: build/i18n/ar-YE.js ================================================ /* * DateJS Culture String File * Country Code: ar-YE * Name: Arabic (Yemen) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["ar-YE"] = { "name": "ar-YE", "englishName": "Arabic (Yemen)", "nativeName": "العربية (اليمن)", "Sunday": "الاحد", "Monday": "الاثنين", "Tuesday": "الثلاثاء", "Wednesday": "الاربعاء", "Thursday": "الخميس", "Friday": "الجمعة", "Saturday": "السبت", "Sun": "الاحد", "Mon": "الاثنين", "Tue": "الثلاثاء", "Wed": "الاربعاء", "Thu": "الخميس", "Fri": "الجمعة", "Sat": "السبت", "Su": "أ", "Mo": "ا", "Tu": "ث", "We": "أ", "Th": "خ", "Fr": "ج", "Sa": "س", "S_Sun_Initial": "أ", "M_Mon_Initial": "ا", "T_Tue_Initial": "ث", "W_Wed_Initial": "أ", "T_Thu_Initial": "خ", "F_Fri_Initial": "ج", "S_Sat_Initial": "س", "January": "يناير", "February": "فبراير", "March": "مارس", "April": "ابريل", "May": "مايو", "June": "يونيو", "July": "يوليو", "August": "اغسطس", "September": "سبتمبر", "October": "اكتوبر", "November": "نوفمبر", "December": "ديسمبر", "Jan_Abbr": "يناير", "Feb_Abbr": "فبراير", "Mar_Abbr": "مارس", "Apr_Abbr": "ابريل", "May_Abbr": "مايو", "Jun_Abbr": "يونيو", "Jul_Abbr": "يوليو", "Aug_Abbr": "اغسطس", "Sep_Abbr": "سبتمبر", "Oct_Abbr": "اكتوبر", "Nov_Abbr": "نوفمبر", "Dec_Abbr": "ديسمبر", "AM": "ص", "PM": "م", "firstDayOfWeek": 6, "twoDigitYearMax": 2029, "mdy": "dmy", "M/d/yyyy": "dd/MM/yyyy", "dddd, MMMM dd, yyyy": "dd MMMM, yyyy", "h:mm tt": "hh:mm tt", "h:mm:ss tt": "hh:mm:ss tt", "dddd, MMMM dd, yyyy h:mm:ss tt": "dd MMMM, yyyy hh:mm:ss tt", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "dd MMMM", "MMMM, yyyy": "MMMM, yyyy", "/jan(uary)?/": "يناير", "/feb(ruary)?/": "فبراير", "/mar(ch)?/": "مارس", "/apr(il)?/": "ابريل", "/may/": "مايو", "/jun(e)?/": "يونيو", "/jul(y)?/": "يوليو", "/aug(ust)?/": "اغسطس", "/sep(t(ember)?)?/": "سبتمبر", "/oct(ober)?/": "اكتوبر", "/nov(ember)?/": "نوفمبر", "/dec(ember)?/": "ديسمبر", "/^su(n(day)?)?/": "^الاحد", "/^mo(n(day)?)?/": "^ا(1)?", "/^tu(e(s(day)?)?)?/": "^الثلاثاء", "/^we(d(nesday)?)?/": "^الاربعاء", "/^th(u(r(s(day)?)?)?)?/": "^الخميس", "/^fr(i(day)?)?/": "^الجمعة", "/^sa(t(urday)?)?/": "^السبت", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "ar-YE"; ================================================ FILE: build/i18n/az-Cyrl-AZ.js ================================================ /* * DateJS Culture String File * Country Code: az-Cyrl-AZ * Name: Azeri (Cyrillic, Azerbaijan) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["az-Cyrl-AZ"] = { "name": "az-Cyrl-AZ", "englishName": "Azeri (Cyrillic, Azerbaijan)", "nativeName": "Азәрбајҹан (Азәрбајҹан)", "Sunday": "Базар", "Monday": "Базар ертәси", "Tuesday": "Чәршәнбә ахшамы", "Wednesday": "Чәршәнбә", "Thursday": "Ҹүмә ахшамы", "Friday": "Ҹүмә", "Saturday": "Шәнбә", "Sun": "Б", "Mon": "Бе", "Tue": "Ча", "Wed": "Ч", "Thu": "Ҹа", "Fri": "Ҹ", "Sat": "Ш", "Su": "Б", "Mo": "Бе", "Tu": "Ча", "We": "Ч", "Th": "Ҹа", "Fr": "Ҹ", "Sa": "Ш", "S_Sun_Initial": "Б", "M_Mon_Initial": "Б", "T_Tue_Initial": "Ч", "W_Wed_Initial": "Ч", "T_Thu_Initial": "Ҹ", "F_Fri_Initial": "Ҹ", "S_Sat_Initial": "Ш", "January": "Јанвар", "February": "Феврал", "March": "Март", "April": "Апрел", "May": "Мај", "June": "Ијун", "July": "Ијул", "August": "Август", "September": "Сентјабр", "October": "Октјабр", "November": "Нојабр", "December": "Декабр", "Jan_Abbr": "Јан", "Feb_Abbr": "Фев", "Mar_Abbr": "Мар", "Apr_Abbr": "Апр", "May_Abbr": "Мај", "Jun_Abbr": "Ијун", "Jul_Abbr": "Ијул", "Aug_Abbr": "Авг", "Sep_Abbr": "Сен", "Oct_Abbr": "Окт", "Nov_Abbr": "Ноя", "Dec_Abbr": "Дек", "AM": "", "PM": "", "firstDayOfWeek": 1, "twoDigitYearMax": 2029, "mdy": "dmy", "M/d/yyyy": "dd.MM.yyyy", "dddd, MMMM dd, yyyy": "d MMMM yyyy", "h:mm tt": "H:mm", "h:mm:ss tt": "H:mm:ss", "dddd, MMMM dd, yyyy h:mm:ss tt": "d MMMM yyyy H:mm:ss", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "d MMMM", "MMMM, yyyy": "MMMM yyyy", "/jan(uary)?/": "јан(вар)?", "/feb(ruary)?/": "фев(рал)?", "/mar(ch)?/": "мар(т)?", "/apr(il)?/": "апр(ел)?", "/may/": "мај", "/jun(e)?/": "ијун", "/jul(y)?/": "ијул", "/aug(ust)?/": "авг(уст)?", "/sep(t(ember)?)?/": "сен(тјабр)?", "/oct(ober)?/": "окт(јабр)?", "/nov(ember)?/": "нојабр", "/dec(ember)?/": "дек(абр)?", "/^su(n(day)?)?/": "^базар", "/^mo(n(day)?)?/": "^базар ертәси", "/^tu(e(s(day)?)?)?/": "^чәршәнбә ахшамы", "/^we(d(nesday)?)?/": "^чәршәнбә", "/^th(u(r(s(day)?)?)?)?/": "^ҹүмә ахшамы", "/^fr(i(day)?)?/": "^ҹүмә", "/^sa(t(urday)?)?/": "^шәнбә", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "az-Cyrl-AZ"; ================================================ FILE: build/i18n/az-Latn-AZ.js ================================================ /* * DateJS Culture String File * Country Code: az-Latn-AZ * Name: Azeri (Latin, Azerbaijan) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["az-Latn-AZ"] = { "name": "az-Latn-AZ", "englishName": "Azeri (Latin, Azerbaijan)", "nativeName": "Azərbaycan­ılı (Azərbaycanca)", "Sunday": "Bazar", "Monday": "Bazar ertəsi", "Tuesday": "Çərşənbə axşamı", "Wednesday": "Çərşənbə", "Thursday": "Cümə axşamı", "Friday": "Cümə", "Saturday": "Şənbə", "Sun": "B", "Mon": "Be", "Tue": "Ça", "Wed": "Ç", "Thu": "Ca", "Fri": "C", "Sat": "Ş", "Su": "B", "Mo": "Be", "Tu": "Ça", "We": "Ç", "Th": "Ca", "Fr": "C", "Sa": "Ş", "S_Sun_Initial": "B", "M_Mon_Initial": "B", "T_Tue_Initial": "Ç", "W_Wed_Initial": "Ç", "T_Thu_Initial": "C", "F_Fri_Initial": "C", "S_Sat_Initial": "Ş", "January": "Yanvar", "February": "Fevral", "March": "Mart", "April": "Aprel", "May": "May", "June": "İyun", "July": "İyul", "August": "Avgust", "September": "Sentyabr", "October": "Oktyabr", "November": "Noyabr", "December": "Dekabr", "Jan_Abbr": "Yan", "Feb_Abbr": "Fev", "Mar_Abbr": "Mar", "Apr_Abbr": "Apr", "May_Abbr": "May", "Jun_Abbr": "İyun", "Jul_Abbr": "İyul", "Aug_Abbr": "Avg", "Sep_Abbr": "Sen", "Oct_Abbr": "Okt", "Nov_Abbr": "Noy", "Dec_Abbr": "Dek", "AM": "", "PM": "", "firstDayOfWeek": 1, "twoDigitYearMax": 2029, "mdy": "dmy", "M/d/yyyy": "dd.MM.yyyy", "dddd, MMMM dd, yyyy": "d MMMM yyyy", "h:mm tt": "H:mm", "h:mm:ss tt": "H:mm:ss", "dddd, MMMM dd, yyyy h:mm:ss tt": "d MMMM yyyy H:mm:ss", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "d MMMM", "MMMM, yyyy": "MMMM yyyy", "/jan(uary)?/": "yan(var)?", "/feb(ruary)?/": "fev(ral)?", "/mar(ch)?/": "mar(t)?", "/apr(il)?/": "apr(el)?", "/may/": "may", "/jun(e)?/": "iyun", "/jul(y)?/": "iyul", "/aug(ust)?/": "avg(ust)?", "/sep(t(ember)?)?/": "sen(tyabr)?", "/oct(ober)?/": "okt(yabr)?", "/nov(ember)?/": "noy(abr)?", "/dec(ember)?/": "dek(abr)?", "/^su(n(day)?)?/": "^bazar", "/^mo(n(day)?)?/": "^bazar ertəsi", "/^tu(e(s(day)?)?)?/": "^çərşənbə axşamı", "/^we(d(nesday)?)?/": "^çərşənbə", "/^th(u(r(s(day)?)?)?)?/": "^cümə axşamı", "/^fr(i(day)?)?/": "^cümə", "/^sa(t(urday)?)?/": "^şənbə", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "az-Latn-AZ"; ================================================ FILE: build/i18n/be-BY.js ================================================ /* * DateJS Culture String File * Country Code: be-BY * Name: Belarusian (Belarus) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["be-BY"] = { "name": "be-BY", "englishName": "Belarusian (Belarus)", "nativeName": "Беларускі (Беларусь)", "Sunday": "нядзеля", "Monday": "панядзелак", "Tuesday": "аўторак", "Wednesday": "серада", "Thursday": "чацвер", "Friday": "пятніца", "Saturday": "субота", "Sun": "нд", "Mon": "пн", "Tue": "аў", "Wed": "ср", "Thu": "чц", "Fri": "пт", "Sat": "сб", "Su": "нд", "Mo": "пн", "Tu": "аў", "We": "ср", "Th": "чц", "Fr": "пт", "Sa": "сб", "S_Sun_Initial": "н", "M_Mon_Initial": "п", "T_Tue_Initial": "а", "W_Wed_Initial": "с", "T_Thu_Initial": "ч", "F_Fri_Initial": "п", "S_Sat_Initial": "с", "January": "Студзень", "February": "Люты", "March": "Сакавік", "April": "Красавік", "May": "Май", "June": "Чэрвень", "July": "Ліпень", "August": "Жнівень", "September": "Верасень", "October": "Кастрычнік", "November": "Лістапад", "December": "Снежань", "Jan_Abbr": "Сту", "Feb_Abbr": "Лют", "Mar_Abbr": "Сак", "Apr_Abbr": "Кра", "May_Abbr": "Май", "Jun_Abbr": "Чэр", "Jul_Abbr": "Ліп", "Aug_Abbr": "Жні", "Sep_Abbr": "Вер", "Oct_Abbr": "Кас", "Nov_Abbr": "Ліс", "Dec_Abbr": "Сне", "AM": "", "PM": "", "firstDayOfWeek": 1, "twoDigitYearMax": 2029, "mdy": "dmy", "M/d/yyyy": "dd.MM.yyyy", "dddd, MMMM dd, yyyy": "d MMMM yyyy", "h:mm tt": "H:mm", "h:mm:ss tt": "H:mm:ss", "dddd, MMMM dd, yyyy h:mm:ss tt": "d MMMM yyyy H:mm:ss", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "d MMMM", "MMMM, yyyy": "MMMM yyyy", "/jan(uary)?/": "сту(дзень)?", "/feb(ruary)?/": "лют(ы)?", "/mar(ch)?/": "сак(авік)?", "/apr(il)?/": "кра(савік)?", "/may/": "май", "/jun(e)?/": "чэр(вень)?", "/jul(y)?/": "ліп(ень)?", "/aug(ust)?/": "жні(вень)?", "/sep(t(ember)?)?/": "вер(асень)?", "/oct(ober)?/": "кас(трычнік)?", "/nov(ember)?/": "ліс(тапад)?", "/dec(ember)?/": "сне(жань)?", "/^su(n(day)?)?/": "^нядзеля", "/^mo(n(day)?)?/": "^панядзелак", "/^tu(e(s(day)?)?)?/": "^аўторак", "/^we(d(nesday)?)?/": "^серада", "/^th(u(r(s(day)?)?)?)?/": "^чацвер", "/^fr(i(day)?)?/": "^пятніца", "/^sa(t(urday)?)?/": "^субота", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "be-BY"; ================================================ FILE: build/i18n/bg-BG.js ================================================ /* * DateJS Culture String File * Country Code: bg-BG * Name: Bulgarian (Bulgaria) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["bg-BG"] = { "name": "bg-BG", "englishName": "Bulgarian (Bulgaria)", "nativeName": "български (България)", "Sunday": "неделя", "Monday": "понеделник", "Tuesday": "вторник", "Wednesday": "сряда", "Thursday": "четвъртък", "Friday": "петък", "Saturday": "събота", "Sun": "Нд", "Mon": "Пн", "Tue": "Вт", "Wed": "Ср", "Thu": "Чт", "Fri": "Пт", "Sat": "Сб", "Su": "не", "Mo": "по", "Tu": "вт", "We": "ср", "Th": "че", "Fr": "пе", "Sa": "съ", "S_Sun_Initial": "н", "M_Mon_Initial": "п", "T_Tue_Initial": "в", "W_Wed_Initial": "с", "T_Thu_Initial": "ч", "F_Fri_Initial": "п", "S_Sat_Initial": "с", "January": "Януари", "February": "Февруари", "March": "Март", "April": "Април", "May": "Май", "June": "Юни", "July": "Юли", "August": "Август", "September": "Септември", "October": "Октомври", "November": "Ноември", "December": "Декември", "Jan_Abbr": "Януари", "Feb_Abbr": "Февруари", "Mar_Abbr": "Март", "Apr_Abbr": "Април", "May_Abbr": "Май", "Jun_Abbr": "Юни", "Jul_Abbr": "Юли", "Aug_Abbr": "Август", "Sep_Abbr": "Септември", "Oct_Abbr": "Октомври", "Nov_Abbr": "Ноември", "Dec_Abbr": "Декември", "AM": "", "PM": "", "firstDayOfWeek": 1, "twoDigitYearMax": 2029, "mdy": "dmy", "M/d/yyyy": "dd.M.yyyy 'г.'", "dddd, MMMM dd, yyyy": "dd MMMM yyyy 'г.'", "h:mm tt": "HH:mm", "h:mm:ss tt": "HH:mm:ss", "dddd, MMMM dd, yyyy h:mm:ss tt": "dd MMMM yyyy 'г.' HH:mm:ss", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "dd MMMM", "MMMM, yyyy": "MMMM yyyy 'г.'", "/jan(uary)?/": "януари", "/feb(ruary)?/": "февруари", "/mar(ch)?/": "март", "/apr(il)?/": "април", "/may/": "май", "/jun(e)?/": "юни", "/jul(y)?/": "юли", "/aug(ust)?/": "август", "/sep(t(ember)?)?/": "септември", "/oct(ober)?/": "октомври", "/nov(ember)?/": "ноември", "/dec(ember)?/": "декември", "/^su(n(day)?)?/": "^не((деля)?)?", "/^mo(n(day)?)?/": "^по((неделник)?)?", "/^tu(e(s(day)?)?)?/": "^вторник", "/^we(d(nesday)?)?/": "^сряда", "/^th(u(r(s(day)?)?)?)?/": "^че((твъртък)?)?", "/^fr(i(day)?)?/": "^пе((тък)?)?", "/^sa(t(urday)?)?/": "^съ((бота)?)?", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "bg-BG"; ================================================ FILE: build/i18n/bs-Latn-BA.js ================================================ /* * DateJS Culture String File * Country Code: bs-Latn-BA * Name: Bosnian (Bosnia and Herzegovina) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["bs-Latn-BA"] = { "name": "bs-Latn-BA", "englishName": "Bosnian (Bosnia and Herzegovina)", "nativeName": "bosanski (Bosna i Hercegovina)", "Sunday": "nedjelja", "Monday": "ponedjeljak", "Tuesday": "utorak", "Wednesday": "srijeda", "Thursday": "četvrtak", "Friday": "petak", "Saturday": "subota", "Sun": "ned", "Mon": "pon", "Tue": "uto", "Wed": "sri", "Thu": "čet", "Fri": "pet", "Sat": "sub", "Su": "ned", "Mo": "pon", "Tu": "uto", "We": "sri", "Th": "čet", "Fr": "pet", "Sa": "sub", "S_Sun_Initial": "n", "M_Mon_Initial": "p", "T_Tue_Initial": "u", "W_Wed_Initial": "s", "T_Thu_Initial": "č", "F_Fri_Initial": "p", "S_Sat_Initial": "s", "January": "januar", "February": "februar", "March": "mart", "April": "april", "May": "maj", "June": "jun", "July": "jul", "August": "avgust", "September": "septembar", "October": "oktobar", "November": "novembar", "December": "decembar", "Jan_Abbr": "jan", "Feb_Abbr": "feb", "Mar_Abbr": "mar", "Apr_Abbr": "apr", "May_Abbr": "maj", "Jun_Abbr": "jun", "Jul_Abbr": "jul", "Aug_Abbr": "avg", "Sep_Abbr": "sep", "Oct_Abbr": "okt", "Nov_Abbr": "nov", "Dec_Abbr": "dec", "AM": "", "PM": "", "firstDayOfWeek": 1, "twoDigitYearMax": 2029, "mdy": "dmy", "M/d/yyyy": "d.M.yyyy", "dddd, MMMM dd, yyyy": "d. MMMM yyyy", "h:mm tt": "H:mm:ss", "h:mm:ss tt": "H:mm:ss", "dddd, MMMM dd, yyyy h:mm:ss tt": "d. MMMM yyyy H:mm:ss", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "MMMM dd", "MMMM, yyyy": "MMMM yyyy", "/jan(uary)?/": "jan(uar)?", "/feb(ruary)?/": "feb(ruar)?", "/mar(ch)?/": "mar(t)?", "/apr(il)?/": "apr(il)?", "/may/": "maj", "/jun(e)?/": "jun", "/jul(y)?/": "jul", "/aug(ust)?/": "avg(ust)?", "/sep(t(ember)?)?/": "sep(tembar)?", "/oct(ober)?/": "okt(obar)?", "/nov(ember)?/": "nov(embar)?", "/dec(ember)?/": "dec(embar)?", "/^su(n(day)?)?/": "^nedjelja", "/^mo(n(day)?)?/": "^ponedjeljak", "/^tu(e(s(day)?)?)?/": "^utorak", "/^we(d(nesday)?)?/": "^srijeda", "/^th(u(r(s(day)?)?)?)?/": "^četvrtak", "/^fr(i(day)?)?/": "^petak", "/^sa(t(urday)?)?/": "^subota", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "bs-Latn-BA"; ================================================ FILE: build/i18n/ca-ES.js ================================================ /* * DateJS Culture String File * Country Code: ca-ES * Name: Catalan (Catalan) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["ca-ES"] = { "name": "ca-ES", "englishName": "Catalan (Catalan)", "nativeName": "català (català)", "Sunday": "diumenge", "Monday": "dilluns", "Tuesday": "dimarts", "Wednesday": "dimecres", "Thursday": "dijous", "Friday": "divendres", "Saturday": "dissabte", "Sun": "dg.", "Mon": "dl.", "Tue": "dt.", "Wed": "dc.", "Thu": "dj.", "Fri": "dv.", "Sat": "ds.", "Su": "dg", "Mo": "dl", "Tu": "dt", "We": "dc", "Th": "dj", "Fr": "dv", "Sa": "ds", "S_Sun_Initial": "d", "M_Mon_Initial": "d", "T_Tue_Initial": "d", "W_Wed_Initial": "d", "T_Thu_Initial": "d", "F_Fri_Initial": "d", "S_Sat_Initial": "d", "January": "gener", "February": "febrer", "March": "març", "April": "abril", "May": "maig", "June": "juny", "July": "juliol", "August": "agost", "September": "setembre", "October": "octubre", "November": "novembre", "December": "desembre", "Jan_Abbr": "gen", "Feb_Abbr": "feb", "Mar_Abbr": "març", "Apr_Abbr": "abr", "May_Abbr": "maig", "Jun_Abbr": "juny", "Jul_Abbr": "jul", "Aug_Abbr": "ag", "Sep_Abbr": "set", "Oct_Abbr": "oct", "Nov_Abbr": "nov", "Dec_Abbr": "des", "AM": "", "PM": "", "firstDayOfWeek": 1, "twoDigitYearMax": 2029, "mdy": "dmy", "M/d/yyyy": "dd/MM/yyyy", "dddd, MMMM dd, yyyy": "dddd, d' / 'MMMM' / 'yyyy", "h:mm tt": "HH:mm", "h:mm:ss tt": "HH:mm:ss", "dddd, MMMM dd, yyyy h:mm:ss tt": "dddd, d' / 'MMMM' / 'yyyy HH:mm:ss", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "dd MMMM", "MMMM, yyyy": "MMMM' / 'yyyy", "/jan(uary)?/": "gen(er)?", "/feb(ruary)?/": "feb(rer)?", "/mar(ch)?/": "març", "/apr(il)?/": "abr(il)?", "/may/": "maig", "/jun(e)?/": "juny", "/jul(y)?/": "jul(iol)?", "/aug(ust)?/": "ag(ost)?", "/sep(t(ember)?)?/": "set(embre)?", "/oct(ober)?/": "oct(ubre)?", "/nov(ember)?/": "nov(embre)?", "/dec(ember)?/": "des(embre)?", "/^su(n(day)?)?/": "^dg((.(umenge)?)?)?", "/^mo(n(day)?)?/": "^dl((.(lluns)?)?)?", "/^tu(e(s(day)?)?)?/": "^dt((.(marts)?)?)?", "/^we(d(nesday)?)?/": "^dc((.(mecres)?)?)?", "/^th(u(r(s(day)?)?)?)?/": "^dj((.(jous)?)?)?", "/^fr(i(day)?)?/": "^dv((.(vendres)?)?)?", "/^sa(t(urday)?)?/": "^ds((.(ssabte)?)?)?", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "ca-ES"; ================================================ FILE: build/i18n/cs-CZ.js ================================================ /* * DateJS Culture String File * Country Code: cs-CZ * Name: Czech (Czech Republic) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["cs-CZ"] = { "name": "cs-CZ", "englishName": "Czech (Czech Republic)", "nativeName": "čeština (Česká republika)", "Sunday": "neděle", "Monday": "pondělí", "Tuesday": "úterý", "Wednesday": "středa", "Thursday": "čtvrtek", "Friday": "pátek", "Saturday": "sobota", "Sun": "ne", "Mon": "po", "Tue": "út", "Wed": "st", "Thu": "čt", "Fri": "pá", "Sat": "so", "Su": "ne", "Mo": "po", "Tu": "út", "We": "st", "Th": "čt", "Fr": "pá", "Sa": "so", "S_Sun_Initial": "n", "M_Mon_Initial": "p", "T_Tue_Initial": "ú", "W_Wed_Initial": "s", "T_Thu_Initial": "č", "F_Fri_Initial": "p", "S_Sat_Initial": "s", "January": "leden", "February": "únor", "March": "březen", "April": "duben", "May": "květen", "June": "červen", "July": "červenec", "August": "srpen", "September": "září", "October": "říjen", "November": "listopad", "December": "prosinec", "Jan_Abbr": "I", "Feb_Abbr": "II", "Mar_Abbr": "III", "Apr_Abbr": "IV", "May_Abbr": "V", "Jun_Abbr": "VI", "Jul_Abbr": "VII", "Aug_Abbr": "VIII", "Sep_Abbr": "IX", "Oct_Abbr": "X", "Nov_Abbr": "XI", "Dec_Abbr": "XII", "AM": "dop.", "PM": "odp.", "firstDayOfWeek": 1, "twoDigitYearMax": 2029, "mdy": "dmy", "M/d/yyyy": "d.M.yyyy", "dddd, MMMM dd, yyyy": "d. MMMM yyyy", "h:mm tt": "H:mm", "h:mm:ss tt": "H:mm:ss", "dddd, MMMM dd, yyyy h:mm:ss tt": "d. MMMM yyyy H:mm:ss", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "dd MMMM", "MMMM, yyyy": "MMMM yyyy", "/jan(uary)?/": "leden", "/feb(ruary)?/": "únor", "/mar(ch)?/": "březen", "/apr(il)?/": "duben", "/may/": "květen", "/jun(e)?/": "červen", "/jul(y)?/": "červenec", "/aug(ust)?/": "srpen", "/sep(t(ember)?)?/": "září", "/oct(ober)?/": "říjen", "/nov(ember)?/": "listopad", "/dec(ember)?/": "prosinec", "/^su(n(day)?)?/": "^neděle", "/^mo(n(day)?)?/": "^pondělí", "/^tu(e(s(day)?)?)?/": "^úterý", "/^we(d(nesday)?)?/": "^středa", "/^th(u(r(s(day)?)?)?)?/": "^čtvrtek", "/^fr(i(day)?)?/": "^pátek", "/^sa(t(urday)?)?/": "^sobota", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "cs-CZ"; ================================================ FILE: build/i18n/cy-GB.js ================================================ /* * DateJS Culture String File * Country Code: cy-GB * Name: Welsh (United Kingdom) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["cy-GB"] = { "name": "cy-GB", "englishName": "Welsh (United Kingdom)", "nativeName": "Cymraeg (y Deyrnas Unedig)", "Sunday": "Dydd Sul", "Monday": "Dydd Llun", "Tuesday": "Dydd Mawrth", "Wednesday": "Dydd Mercher", "Thursday": "Dydd Iau", "Friday": "Dydd Gwener", "Saturday": "Dydd Sadwrn", "Sun": "Sul", "Mon": "Llun", "Tue": "Maw", "Wed": "Mer", "Thu": "Iau", "Fri": "Gwe", "Sat": "Sad", "Su": "Sul", "Mo": "Llun", "Tu": "Maw", "We": "Mer", "Th": "Iau", "Fr": "Gwe", "Sa": "Sad", "S_Sun_Initial": "S", "M_Mon_Initial": "L", "T_Tue_Initial": "M", "W_Wed_Initial": "M", "T_Thu_Initial": "I", "F_Fri_Initial": "G", "S_Sat_Initial": "S", "January": "Ionawr", "February": "Chwefror", "March": "Mawrth", "April": "Ebrill", "May": "Mai", "June": "Mehefin", "July": "Gorffennaf", "August": "Awst", "September": "Medi", "October": "Hydref", "November": "Tachwedd", "December": "Rhagfyr", "Jan_Abbr": "Ion", "Feb_Abbr": "Chwe", "Mar_Abbr": "Maw", "Apr_Abbr": "Ebr", "May_Abbr": "Mai", "Jun_Abbr": "Meh", "Jul_Abbr": "Gor", "Aug_Abbr": "Aws", "Sep_Abbr": "Med", "Oct_Abbr": "Hyd", "Nov_Abbr": "Tach", "Dec_Abbr": "Rhag", "AM": "a.m.", "PM": "p.m.", "firstDayOfWeek": 1, "twoDigitYearMax": 2029, "mdy": "dmy", "M/d/yyyy": "dd/MM/yyyy", "dddd, MMMM dd, yyyy": "dd MMMM yyyy", "h:mm tt": "HH:mm:ss", "h:mm:ss tt": "HH:mm:ss", "dddd, MMMM dd, yyyy h:mm:ss tt": "dd MMMM yyyy HH:mm:ss", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "MMMM dd", "MMMM, yyyy": "MMMM yyyy", "/jan(uary)?/": "ion(awr)?", "/feb(ruary)?/": "chwe(fror)?", "/mar(ch)?/": "maw(rth)?", "/apr(il)?/": "ebr(ill)?", "/may/": "mai", "/jun(e)?/": "meh(efin)?", "/jul(y)?/": "gor(ffennaf)?", "/aug(ust)?/": "aws(t)?", "/sep(t(ember)?)?/": "med(i)?", "/oct(ober)?/": "hyd(ref)?", "/nov(ember)?/": "tach(wedd)?", "/dec(ember)?/": "rhag(fyr)?", "/^su(n(day)?)?/": "^dydd sul", "/^mo(n(day)?)?/": "^dydd llun", "/^tu(e(s(day)?)?)?/": "^dydd mawrth", "/^we(d(nesday)?)?/": "^dydd mercher", "/^th(u(r(s(day)?)?)?)?/": "^dydd iau", "/^fr(i(day)?)?/": "^dydd gwener", "/^sa(t(urday)?)?/": "^dydd sadwrn", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "cy-GB"; ================================================ FILE: build/i18n/da-DK.js ================================================ /* * DateJS Culture String File * Country Code: da-DK * Name: Danish (Denmark) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["da-DK"] = { "name": "da-DK", "englishName": "Danish (Denmark)", "nativeName": "dansk (Danmark)", "Sunday": "søndag", "Monday": "mandag", "Tuesday": "tirsdag", "Wednesday": "onsdag", "Thursday": "torsdag", "Friday": "fredag", "Saturday": "lørdag", "Sun": "sø", "Mon": "ma", "Tue": "ti", "Wed": "on", "Thu": "to", "Fri": "fr", "Sat": "lø", "Su": "sø", "Mo": "ma", "Tu": "ti", "We": "on", "Th": "to", "Fr": "fr", "Sa": "lø", "S_Sun_Initial": "s", "M_Mon_Initial": "m", "T_Tue_Initial": "t", "W_Wed_Initial": "o", "T_Thu_Initial": "t", "F_Fri_Initial": "f", "S_Sat_Initial": "l", "January": "januar", "February": "februar", "March": "marts", "April": "april", "May": "maj", "June": "juni", "July": "juli", "August": "august", "September": "september", "October": "oktober", "November": "november", "December": "december", "Jan_Abbr": "jan", "Feb_Abbr": "feb", "Mar_Abbr": "mar", "Apr_Abbr": "apr", "May_Abbr": "maj", "Jun_Abbr": "jun", "Jul_Abbr": "jul", "Aug_Abbr": "aug", "Sep_Abbr": "sep", "Oct_Abbr": "okt", "Nov_Abbr": "nov", "Dec_Abbr": "dec", "AM": "", "PM": "", "firstDayOfWeek": 1, "twoDigitYearMax": 2029, "mdy": "dmy", "M/d/yyyy": "dd-MM-yyyy", "dddd, MMMM dd, yyyy": "d. MMMM yyyy", "h:mm tt": "HH:mm", "h:mm:ss tt": "HH:mm:ss", "dddd, MMMM dd, yyyy h:mm:ss tt": "d. MMMM yyyy HH:mm:ss", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "d. MMMM", "MMMM, yyyy": "MMMM yyyy", "/jan(uary)?/": "jan(uar)?", "/feb(ruary)?/": "feb(ruar)?", "/mar(ch)?/": "mar(ts)?", "/apr(il)?/": "apr(il)?", "/may/": "maj", "/jun(e)?/": "jun(i)?", "/jul(y)?/": "jul(i)?", "/aug(ust)?/": "aug(ust)?", "/sep(t(ember)?)?/": "sep(t(ember)?)?", "/oct(ober)?/": "okt(ober)?", "/nov(ember)?/": "nov(ember)?", "/dec(ember)?/": "dec(ember)?", "/^su(n(day)?)?/": "^søndag", "/^mo(n(day)?)?/": "^mandag", "/^tu(e(s(day)?)?)?/": "^tirsdag", "/^we(d(nesday)?)?/": "^onsdag", "/^th(u(r(s(day)?)?)?)?/": "^torsdag", "/^fr(i(day)?)?/": "^fredag", "/^sa(t(urday)?)?/": "^lørdag", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "da-DK"; ================================================ FILE: build/i18n/de-AT.js ================================================ /* * DateJS Culture String File * Country Code: de-AT * Name: German (Austria) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["de-AT"] = { "name": "de-AT", "englishName": "German (Austria)", "nativeName": "Deutsch (Österreich)", "Sunday": "Sonntag", "Monday": "Montag", "Tuesday": "Dienstag", "Wednesday": "Mittwoch", "Thursday": "Donnerstag", "Friday": "Freitag", "Saturday": "Samstag", "Sun": "Son", "Mon": "Mon", "Tue": "Die", "Wed": "Mit", "Thu": "Don", "Fri": "Fre", "Sat": "Sam", "Su": "So", "Mo": "Mo", "Tu": "Di", "We": "Mi", "Th": "Do", "Fr": "Fr", "Sa": "Sa", "S_Sun_Initial": "S", "M_Mon_Initial": "M", "T_Tue_Initial": "D", "W_Wed_Initial": "M", "T_Thu_Initial": "D", "F_Fri_Initial": "F", "S_Sat_Initial": "S", "January": "Jänner", "February": "Februar", "March": "März", "April": "April", "May": "Mai", "June": "Juni", "July": "Juli", "August": "August", "September": "September", "October": "Oktober", "November": "November", "December": "Dezember", "Jan_Abbr": "J(ä|a)n", "Feb_Abbr": "Feb", "Mar_Abbr": "(M(a|ä)r|Mrz)", "Apr_Abbr": "Apr", "May_Abbr": "Mai", "Jun_Abbr": "Jun", "Jul_Abbr": "Jul", "Aug_Abbr": "Aug", "Sep_Abbr": "Sep", "Oct_Abbr": "Okt", "Nov_Abbr": "Nov", "Dec_Abbr": "Dez", "AM": "", "PM": "", "firstDayOfWeek": 1, "twoDigitYearMax": 2029, "mdy": "dmy", "M/d/yyyy": "dd.MM.yyyy", "dddd, MMMM dd, yyyy": "dddd, dd. MMMM yyyy", "h:mm tt": "HH:mm", "h:mm:ss tt": "HH:mm:ss", "dddd, MMMM dd, yyyy h:mm:ss tt": "dddd, dd. MMMM yyyy HH:mm:ss", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "dd MMMM", "MMMM, yyyy": "MMMM yyyy", "/jan(uary)?/": "jän(ner)?", "/feb(ruary)?/": "feb(ruar)?", "/mar(ch)?/": "mär(z)?", "/apr(il)?/": "apr(il)?", "/may/": "mai", "/jun(e)?/": "jun(i)?", "/jul(y)?/": "jul(i)?", "/aug(ust)?/": "aug(ust)?", "/sep(t(ember)?)?/": "sep(t(ember)?)?", "/oct(ober)?/": "okt(ober)?", "/nov(ember)?/": "nov(ember)?", "/dec(ember)?/": "dez(ember)?", "/^su(n(day)?)?/": "^sonntag", "/^mo(n(day)?)?/": "^montag", "/^tu(e(s(day)?)?)?/": "^dienstag", "/^we(d(nesday)?)?/": "^mittwoch", "/^th(u(r(s(day)?)?)?)?/": "^donnerstag", "/^fr(i(day)?)?/": "^freitag", "/^sa(t(urday)?)?/": "^samstag", "/^next/": "^nächste(r|s|n)?", "/^last|past|prev(ious)?/": "^letzte(r|s|n)?|vergangene(r|s|n)?|vorherige(r|s|n)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|(da)?nach(er)?|von|daher|in)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|(be|zu)?vor|früher)", "/^yes(terday)?/": "^gestern", "/^t(od(ay)?)?/": "^heute", "/^tom(orrow)?/": "^morgen", "/^n(ow)?/": "^jetzt|sofort|gleich", "/^ms|milli(second)?s?/": "^ms|milli(sekunde(n)?)?", "/^sec(ond)?s?/": "^sek(unde(n)?)?", "/^mn|min(ute)?s?/": "^mn|min(ute(n)?)?", "/^h(our)?s?/": "^h|st(d|unde(n)?)?", "/^w(eek)?s?/": "^w(oche(n)?)?", "/^m(onth)?s?/": "^m(onat(e)?)?", "/^d(ay)?s?/": "^d|t(ag(en)?)?", "/^y(ear)?s?/": "^y|j(ahr(en)?)?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "de-AT"; ================================================ FILE: build/i18n/de-CH.js ================================================ /* * DateJS Culture String File * Country Code: de-CH * Name: German (Switzerland) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["de-CH"] = { "name": "de-CH", "englishName": "German (Switzerland)", "nativeName": "Deutsch (Schweiz)", "Sunday": "Sonntag", "Monday": "Montag", "Tuesday": "Dienstag", "Wednesday": "Mittwoch", "Thursday": "Donnerstag", "Friday": "Freitag", "Saturday": "Samstag", "Sun": "Son", "Mon": "Mon", "Tue": "Die", "Wed": "Mit", "Thu": "Don", "Fri": "Fre", "Sat": "Sam", "Su": "So", "Mo": "Mo", "Tu": "Di", "We": "Mi", "Th": "Do", "Fr": "Fr", "Sa": "Sa", "S_Sun_Initial": "S", "M_Mon_Initial": "M", "T_Tue_Initial": "D", "W_Wed_Initial": "M", "T_Thu_Initial": "D", "F_Fri_Initial": "F", "S_Sat_Initial": "S", "January": "Januar", "February": "Februar", "March": "März", "April": "April", "May": "Mai", "June": "Juni", "July": "Juli", "August": "August", "September": "September", "October": "Oktober", "November": "November", "December": "Dezember", "Jan_Abbr": "Jan", "Feb_Abbr": "Feb", "Mar_Abbr": "Mrz", "Apr_Abbr": "Apr", "May_Abbr": "Mai", "Jun_Abbr": "Jun", "Jul_Abbr": "Jul", "Aug_Abbr": "Aug", "Sep_Abbr": "Sep", "Oct_Abbr": "Okt", "Nov_Abbr": "Nov", "Dec_Abbr": "Dez", "AM": "", "PM": "", "firstDayOfWeek": 1, "twoDigitYearMax": 2029, "mdy": "dmy", "M/d/yyyy": "dd.MM.yyyy", "dddd, MMMM dd, yyyy": "dddd, d. MMMM yyyy", "h:mm tt": "HH:mm", "h:mm:ss tt": "HH:mm:ss", "dddd, MMMM dd, yyyy h:mm:ss tt": "dddd, d. MMMM yyyy HH:mm:ss", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "dd MMMM", "MMMM, yyyy": "MMMM yyyy", "/jan(uary)?/": "jan(uar)?", "/feb(ruary)?/": "feb(ruar)?", "/mar(ch)?/": "märz", "/apr(il)?/": "apr(il)?", "/may/": "mai", "/jun(e)?/": "jun(i)?", "/jul(y)?/": "jul(i)?", "/aug(ust)?/": "aug(ust)?", "/sep(t(ember)?)?/": "sep(t(ember)?)?", "/oct(ober)?/": "okt(ober)?", "/nov(ember)?/": "nov(ember)?", "/dec(ember)?/": "dez(ember)?", "/^su(n(day)?)?/": "^sonntag", "/^mo(n(day)?)?/": "^montag", "/^tu(e(s(day)?)?)?/": "^dienstag", "/^we(d(nesday)?)?/": "^mittwoch", "/^th(u(r(s(day)?)?)?)?/": "^donnerstag", "/^fr(i(day)?)?/": "^freitag", "/^sa(t(urday)?)?/": "^samstag", "/^next/": "^nächste(r|s|n)?", "/^last|past|prev(ious)?/": "^letzte(r|s|n)?|vergangene(r|s|n)?|vorherige(r|s|n)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|(da)?nach(er)?|von|daher|in)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|(be|zu)?vor|früher)", "/^yes(terday)?/": "^gestern", "/^t(od(ay)?)?/": "^heute", "/^tom(orrow)?/": "^morgen", "/^n(ow)?/": "^jetzt|sofort|gleich", "/^ms|milli(second)?s?/": "^ms|milli(sekunde(n)?)?", "/^sec(ond)?s?/": "^sek(unde(n)?)?", "/^mn|min(ute)?s?/": "^mn|min(ute(n)?)?", "/^h(our)?s?/": "^h|st(d|unde(n)?)?", "/^w(eek)?s?/": "^w(oche(n)?)?", "/^m(onth)?s?/": "^m(onat(e)?)?", "/^d(ay)?s?/": "^d|t(ag(en)?)?", "/^y(ear)?s?/": "^y|j(ahr(en)?)?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "de-CH"; ================================================ FILE: build/i18n/de-DE.js ================================================ /* * DateJS Culture String File * Country Code: de-DE * Name: German (Germany) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["de-DE"] = { "name": "de-DE", "englishName": "German (Germany)", "nativeName": "Deutsch (Deutschland)", "Sunday": "Sonntag", "Monday": "Montag", "Tuesday": "Dienstag", "Wednesday": "Mittwoch", "Thursday": "Donnerstag", "Friday": "Freitag", "Saturday": "Samstag", "Sun": "Son", "Mon": "Mon", "Tue": "Die", "Wed": "Mit", "Thu": "Don", "Fri": "Fre", "Sat": "Sam", "Su": "So", "Mo": "Mo", "Tu": "Di", "We": "Mi", "Th": "Do", "Fr": "Fr", "Sa": "Sa", "S_Sun_Initial": "S", "M_Mon_Initial": "M", "T_Tue_Initial": "D", "W_Wed_Initial": "M", "T_Thu_Initial": "D", "F_Fri_Initial": "F", "S_Sat_Initial": "S", "January": "Januar", "February": "Februar", "March": "März", "April": "April", "May": "Mai", "June": "Juni", "July": "Juli", "August": "August", "September": "September", "October": "Oktober", "November": "November", "December": "Dezember", "Jan_Abbr": "Jan", "Feb_Abbr": "Feb", "Mar_Abbr": "Mrz", "Apr_Abbr": "Apr", "May_Abbr": "Mai", "Jun_Abbr": "Jun", "Jul_Abbr": "Jul", "Aug_Abbr": "Aug", "Sep_Abbr": "Sep", "Oct_Abbr": "Okt", "Nov_Abbr": "Nov", "Dec_Abbr": "Dez", "AM": "", "PM": "", "firstDayOfWeek": 1, "twoDigitYearMax": 2029, "mdy": "dmy", "M/d/yyyy": "dd.MM.yyyy", "dddd, MMMM dd, yyyy": "dddd, d. MMMM yyyy", "h:mm tt": "HH:mm", "h:mm:ss tt": "HH:mm:ss", "dddd, MMMM dd, yyyy h:mm:ss tt": "dddd, d. MMMM yyyy HH:mm:ss", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "dd MMMM", "MMMM, yyyy": "MMMM yyyy", "/jan(uary)?/": "jan(uar)?", "/feb(ruary)?/": "feb(ruar)?", "/mar(ch)?/": "märz", "/apr(il)?/": "apr(il)?", "/may/": "mai", "/jun(e)?/": "jun(i)?", "/jul(y)?/": "jul(i)?", "/aug(ust)?/": "aug(ust)?", "/sep(t(ember)?)?/": "sep(t(ember)?)?", "/oct(ober)?/": "okt(ober)?", "/nov(ember)?/": "nov(ember)?", "/dec(ember)?/": "dez(ember)?", "/^su(n(day)?)?/": "^sonntag", "/^mo(n(day)?)?/": "^montag", "/^tu(e(s(day)?)?)?/": "^dienstag", "/^we(d(nesday)?)?/": "^mittwoch", "/^th(u(r(s(day)?)?)?)?/": "^donnerstag", "/^fr(i(day)?)?/": "^freitag", "/^sa(t(urday)?)?/": "^samstag", "/^next/": "^nächste(r|s|n)?", "/^last|past|prev(ious)?/": "^letzte(r|s|n)?|vergangene(r|s|n)?|vorherige(r|s|n)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|(da)?nach(er)?|von|daher|in)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|(be|zu)?vor|früher)", "/^yes(terday)?/": "^gestern", "/^t(od(ay)?)?/": "^heute", "/^tom(orrow)?/": "^morgen", "/^n(ow)?/": "^jetzt|sofort|gleich", "/^ms|milli(second)?s?/": "^ms|milli(sekunde(n)?)?", "/^sec(ond)?s?/": "^sek(unde(n)?)?", "/^mn|min(ute)?s?/": "^mn|min(ute(n)?)?", "/^h(our)?s?/": "^h|st(d|unde(n)?)?", "/^w(eek)?s?/": "^w(oche(n)?)?", "/^m(onth)?s?/": "^m(onat(e)?)?", "/^d(ay)?s?/": "^d|t(ag(en)?)?", "/^y(ear)?s?/": "^y|j(ahr(en)?)?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "de-DE"; ================================================ FILE: build/i18n/de-LI.js ================================================ /* * DateJS Culture String File * Country Code: de-LI * Name: German (Liechtenstein) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["de-LI"] = { "name": "de-LI", "englishName": "German (Liechtenstein)", "nativeName": "Deutsch (Liechtenstein)", "Sunday": "Sonntag", "Monday": "Montag", "Tuesday": "Dienstag", "Wednesday": "Mittwoch", "Thursday": "Donnerstag", "Friday": "Freitag", "Saturday": "Samstag", "Sun": "Son", "Mon": "Mon", "Tue": "Die", "Wed": "Mit", "Thu": "Don", "Fri": "Fre", "Sat": "Sam", "Su": "So", "Mo": "Mo", "Tu": "Di", "We": "Mi", "Th": "Do", "Fr": "Fr", "Sa": "Sa", "S_Sun_Initial": "S", "M_Mon_Initial": "M", "T_Tue_Initial": "D", "W_Wed_Initial": "M", "T_Thu_Initial": "D", "F_Fri_Initial": "F", "S_Sat_Initial": "S", "January": "Januar", "February": "Februar", "March": "März", "April": "April", "May": "Mai", "June": "Juni", "July": "Juli", "August": "August", "September": "September", "October": "Oktober", "November": "November", "December": "Dezember", "Jan_Abbr": "Jan", "Feb_Abbr": "Feb", "Mar_Abbr": "Mrz", "Apr_Abbr": "Apr", "May_Abbr": "Mai", "Jun_Abbr": "Jun", "Jul_Abbr": "Jul", "Aug_Abbr": "Aug", "Sep_Abbr": "Sep", "Oct_Abbr": "Okt", "Nov_Abbr": "Nov", "Dec_Abbr": "Dez", "AM": "", "PM": "", "firstDayOfWeek": 1, "twoDigitYearMax": 2029, "mdy": "dmy", "M/d/yyyy": "dd.MM.yyyy", "dddd, MMMM dd, yyyy": "dddd, d. MMMM yyyy", "h:mm tt": "HH:mm", "h:mm:ss tt": "HH:mm:ss", "dddd, MMMM dd, yyyy h:mm:ss tt": "dddd, d. MMMM yyyy HH:mm:ss", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "dd MMMM", "MMMM, yyyy": "MMMM yyyy", "/jan(uary)?/": "jan(uar)?", "/feb(ruary)?/": "feb(ruar)?", "/mar(ch)?/": "märz", "/apr(il)?/": "apr(il)?", "/may/": "mai", "/jun(e)?/": "jun(i)?", "/jul(y)?/": "jul(i)?", "/aug(ust)?/": "aug(ust)?", "/sep(t(ember)?)?/": "sep(t(ember)?)?", "/oct(ober)?/": "okt(ober)?", "/nov(ember)?/": "nov(ember)?", "/dec(ember)?/": "dez(ember)?", "/^su(n(day)?)?/": "^sonntag", "/^mo(n(day)?)?/": "^montag", "/^tu(e(s(day)?)?)?/": "^dienstag", "/^we(d(nesday)?)?/": "^mittwoch", "/^th(u(r(s(day)?)?)?)?/": "^donnerstag", "/^fr(i(day)?)?/": "^freitag", "/^sa(t(urday)?)?/": "^samstag", "/^next/": "^nächste(r|s|n)?", "/^last|past|prev(ious)?/": "^letzte(r|s|n)?|vergangene(r|s|n)?|vorherige(r|s|n)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|(da)?nach(er)?|von|daher|in)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|(be|zu)?vor|früher)", "/^yes(terday)?/": "^gestern", "/^t(od(ay)?)?/": "^heute", "/^tom(orrow)?/": "^morgen", "/^n(ow)?/": "^jetzt|sofort|gleich", "/^ms|milli(second)?s?/": "^ms|milli(sekunde(n)?)?", "/^sec(ond)?s?/": "^sek(unde(n)?)?", "/^mn|min(ute)?s?/": "^mn|min(ute(n)?)?", "/^h(our)?s?/": "^h|st(d|unde(n)?)?", "/^w(eek)?s?/": "^w(oche(n)?)?", "/^m(onth)?s?/": "^m(onat(e)?)?", "/^d(ay)?s?/": "^d|t(ag(en)?)?", "/^y(ear)?s?/": "^y|j(ahr(en)?)?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "de-LI"; ================================================ FILE: build/i18n/de-LU.js ================================================ /* * DateJS Culture String File * Country Code: de-LU * Name: German (Luxembourg) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["de-LU"] = { "name": "de-LU", "englishName": "German (Luxembourg)", "nativeName": "Deutsch (Luxemburg)", "Sunday": "Sonntag", "Monday": "Montag", "Tuesday": "Dienstag", "Wednesday": "Mittwoch", "Thursday": "Donnerstag", "Friday": "Freitag", "Saturday": "Samstag", "Sun": "Son", "Mon": "Mon", "Tue": "Die", "Wed": "Mit", "Thu": "Don", "Fri": "Fre", "Sat": "Sam", "Su": "So", "Mo": "Mo", "Tu": "Di", "We": "Mi", "Th": "Do", "Fr": "Fr", "Sa": "Sa", "S_Sun_Initial": "S", "M_Mon_Initial": "M", "T_Tue_Initial": "D", "W_Wed_Initial": "M", "T_Thu_Initial": "D", "F_Fri_Initial": "F", "S_Sat_Initial": "S", "January": "Januar", "February": "Februar", "March": "März", "April": "April", "May": "Mai", "June": "Juni", "July": "Juli", "August": "August", "September": "September", "October": "Oktober", "November": "November", "December": "Dezember", "Jan_Abbr": "Jan", "Feb_Abbr": "Feb", "Mar_Abbr": "Mrz", "Apr_Abbr": "Apr", "May_Abbr": "Mai", "Jun_Abbr": "Jun", "Jul_Abbr": "Jul", "Aug_Abbr": "Aug", "Sep_Abbr": "Sep", "Oct_Abbr": "Okt", "Nov_Abbr": "Nov", "Dec_Abbr": "Dez", "AM": "", "PM": "", "firstDayOfWeek": 1, "twoDigitYearMax": 2029, "mdy": "dmy", "M/d/yyyy": "dd.MM.yyyy", "dddd, MMMM dd, yyyy": "dddd, d. MMMM yyyy", "h:mm tt": "HH:mm", "h:mm:ss tt": "HH:mm:ss", "dddd, MMMM dd, yyyy h:mm:ss tt": "dddd, d. MMMM yyyy HH:mm:ss", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "dd MMMM", "MMMM, yyyy": "MMMM yyyy", "/jan(uary)?/": "jan(uar)?", "/feb(ruary)?/": "feb(ruar)?", "/mar(ch)?/": "märz", "/apr(il)?/": "apr(il)?", "/may/": "mai", "/jun(e)?/": "jun(i)?", "/jul(y)?/": "jul(i)?", "/aug(ust)?/": "aug(ust)?", "/sep(t(ember)?)?/": "sep(t(ember)?)?", "/oct(ober)?/": "okt(ober)?", "/nov(ember)?/": "nov(ember)?", "/dec(ember)?/": "dez(ember)?", "/^su(n(day)?)?/": "^sonntag", "/^mo(n(day)?)?/": "^montag", "/^tu(e(s(day)?)?)?/": "^dienstag", "/^we(d(nesday)?)?/": "^mittwoch", "/^th(u(r(s(day)?)?)?)?/": "^donnerstag", "/^fr(i(day)?)?/": "^freitag", "/^sa(t(urday)?)?/": "^samstag", "/^next/": "^nächste(r|s|n)?", "/^last|past|prev(ious)?/": "^letzte(r|s|n)?|vergangene(r|s|n)?|vorherige(r|s|n)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|(da)?nach(er)?|von|daher|in)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|(be|zu)?vor|früher)", "/^yes(terday)?/": "^gestern", "/^t(od(ay)?)?/": "^heute", "/^tom(orrow)?/": "^morgen", "/^n(ow)?/": "^jetzt|sofort|gleich", "/^ms|milli(second)?s?/": "^ms|milli(sekunde(n)?)?", "/^sec(ond)?s?/": "^sek(unde(n)?)?", "/^mn|min(ute)?s?/": "^mn|min(ute(n)?)?", "/^h(our)?s?/": "^h|st(d|unde(n)?)?", "/^w(eek)?s?/": "^w(oche(n)?)?", "/^m(onth)?s?/": "^m(onat(e)?)?", "/^d(ay)?s?/": "^d|t(ag(en)?)?", "/^y(ear)?s?/": "^y|j(ahr(en)?)?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "de-LU"; ================================================ FILE: build/i18n/dv-MV.js ================================================ /* * DateJS Culture String File * Country Code: dv-MV * Name: Divehi (Maldives) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["dv-MV"] = { "name": "dv-MV", "englishName": "Divehi (Maldives)", "nativeName": "ދިވެހިބަސް (ދިވެހި ރާއްޖެ)", "Sunday": "الاحد", "Monday": "الاثنين", "Tuesday": "الثلاثاء", "Wednesday": "الاربعاء", "Thursday": "الخميس", "Friday": "الجمعة", "Saturday": "السبت", "Sun": "الاحد", "Mon": "الاثنين", "Tue": "الثلاثاء", "Wed": "الاربعاء", "Thu": "الخميس", "Fri": "الجمعة", "Sat": "السبت", "Su": "ح", "Mo": "ن", "Tu": "ث", "We": "ر", "Th": "خ", "Fr": "ج", "Sa": "س", "S_Sun_Initial": "ح", "M_Mon_Initial": "ن", "T_Tue_Initial": "ث", "W_Wed_Initial": "ر", "T_Thu_Initial": "خ", "F_Fri_Initial": "ج", "S_Sat_Initial": "س", "January": "محرم", "February": "صفر", "March": "ربيع الأول", "April": "ربيع الثاني", "May": "جمادى الأولى", "June": "جمادى الثانية", "July": "رجب", "August": "شعبان", "September": "رمضان", "October": "شوال", "November": "ذو القعدة", "December": "ذو الحجة", "Jan_Abbr": "محرم", "Feb_Abbr": "صفر", "Mar_Abbr": "ربيع الاول", "Apr_Abbr": "ربيع الثاني", "May_Abbr": "جمادى الاولى", "Jun_Abbr": "جمادى الثانية", "Jul_Abbr": "رجب", "Aug_Abbr": "شعبان", "Sep_Abbr": "رمضان", "Oct_Abbr": "شوال", "Nov_Abbr": "ذو القعدة", "Dec_Abbr": "ذو الحجة", "AM": "މކ", "PM": "މފ", "firstDayOfWeek": 0, "twoDigitYearMax": 1451, "mdy": "dmy", "M/d/yyyy": "dd/MM/yy", "dddd, MMMM dd, yyyy": "dd/MMMM/yyyy", "h:mm tt": "HH:mm", "h:mm:ss tt": "HH:mm:ss", "dddd, MMMM dd, yyyy h:mm:ss tt": "dd/MMMM/yyyy HH:mm:ss", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "dd MMMM", "MMMM, yyyy": "MMMM, yyyy", "/jan(uary)?/": "محرم", "/feb(ruary)?/": "صفر", "/mar(ch)?/": "ربيع الأول", "/apr(il)?/": "ربيع الثاني", "/may/": "جمادى الأولى", "/jun(e)?/": "جمادى الثانية", "/jul(y)?/": "رجب", "/aug(ust)?/": "شعبان", "/sep(t(ember)?)?/": "رمضان", "/oct(ober)?/": "شوال", "/nov(ember)?/": "ذو القعدة", "/dec(ember)?/": "ذو الحجة", "/^su(n(day)?)?/": "^الاحد", "/^mo(n(day)?)?/": "^الاثنين", "/^tu(e(s(day)?)?)?/": "^الثلاثاء", "/^we(d(nesday)?)?/": "^الاربعاء", "/^th(u(r(s(day)?)?)?)?/": "^الخميس", "/^fr(i(day)?)?/": "^الجمعة", "/^sa(t(urday)?)?/": "^السبت", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "dv-MV"; ================================================ FILE: build/i18n/el-GR.js ================================================ /* * DateJS Culture String File * Country Code: el-GR * Name: Greek (Greece) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["el-GR"] = { "name": "el-GR", "englishName": "Greek (Greece)", "nativeName": "ελληνικά (Ελλάδα)", "Sunday": "Κυριακή", "Monday": "Δευτέρα", "Tuesday": "Τρίτη", "Wednesday": "Τετάρτη", "Thursday": "Πέμπτη", "Friday": "Παρασκευή", "Saturday": "Σάββατο", "Sun": "Κυρ", "Mon": "Δευ", "Tue": "Τρι", "Wed": "Τετ", "Thu": "Πεμ", "Fri": "Παρ", "Sat": "Σαβ", "Su": "Κυ", "Mo": "Δε", "Tu": "Τρ", "We": "Τε", "Th": "Πε", "Fr": "Πα", "Sa": "Σά", "S_Sun_Initial": "Κ", "M_Mon_Initial": "Δ", "T_Tue_Initial": "Τ", "W_Wed_Initial": "Τ", "T_Thu_Initial": "Π", "F_Fri_Initial": "Π", "S_Sat_Initial": "Σ", "January": "Ιανουάριος", "February": "Φεβρουάριος", "March": "Μάρτιος", "April": "Απρίλιος", "May": "Μάιος", "June": "Ιούνιος", "July": "Ιούλιος", "August": "Αύγουστος", "September": "Σεπτέμβριος", "October": "Οκτώβριος", "November": "Νοέμβριος", "December": "Δεκέμβριος", "Jan_Abbr": "Ιαν", "Feb_Abbr": "Φεβ", "Mar_Abbr": "Μαρ", "Apr_Abbr": "Απρ", "May_Abbr": "Μαϊ", "Jun_Abbr": "Ιουν", "Jul_Abbr": "Ιουλ", "Aug_Abbr": "Αυγ", "Sep_Abbr": "Σεπ", "Oct_Abbr": "Οκτ", "Nov_Abbr": "Νοε", "Dec_Abbr": "Δεκ", "AM": "πμ", "PM": "μμ", "firstDayOfWeek": 1, "twoDigitYearMax": 2029, "mdy": "dmy", "M/d/yyyy": "d/M/yyyy", "dddd, MMMM dd, yyyy": "dddd, d MMMM yyyy", "h:mm tt": "h:mm tt", "h:mm:ss tt": "h:mm:ss tt", "dddd, MMMM dd, yyyy h:mm:ss tt": "dddd, d MMMM yyyy h:mm:ss tt", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "dd MMMM", "MMMM, yyyy": "MMMM yyyy", "/jan(uary)?/": "ιαν(ουάριος)?", "/feb(ruary)?/": "φεβ(ρουάριος)?", "/mar(ch)?/": "μάρτιος", "/apr(il)?/": "απρ(ίλιος)?", "/may/": "μάιος", "/jun(e)?/": "ιούνιος", "/jul(y)?/": "ιούλιος", "/aug(ust)?/": "αύγουστος", "/sep(t(ember)?)?/": "σεπ(τέμβριος)?", "/oct(ober)?/": "οκτ(ώβριος)?", "/nov(ember)?/": "νοέμβριος", "/dec(ember)?/": "δεκ(έμβριος)?", "/^su(n(day)?)?/": "^κυ(ρ(ιακή)?)?", "/^mo(n(day)?)?/": "^δε(υ(τέρα)?)?", "/^tu(e(s(day)?)?)?/": "^τρ(ι(τη)?)?", "/^we(d(nesday)?)?/": "^τε(τ(άρτη)?)?", "/^th(u(r(s(day)?)?)?)?/": "^πε(μ(πτη)?)?", "/^fr(i(day)?)?/": "^πα(ρ(ασκευή)?)?", "/^sa(t(urday)?)?/": "^σά(β(βατο)?)?", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "el-GR"; ================================================ FILE: build/i18n/en-029.js ================================================ /* * DateJS Culture String File * Country Code: en-029 * Name: English (Caribbean) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["en-029"] = { "name": "en-029", "englishName": "English (Caribbean)", "nativeName": "English (Caribbean)", "Sunday": "Sunday", "Monday": "Monday", "Tuesday": "Tuesday", "Wednesday": "Wednesday", "Thursday": "Thursday", "Friday": "Friday", "Saturday": "Saturday", "Sun": "Sun", "Mon": "Mon", "Tue": "Tue", "Wed": "Wed", "Thu": "Thu", "Fri": "Fri", "Sat": "Sat", "Su": "Su", "Mo": "Mo", "Tu": "Tu", "We": "We", "Th": "Th", "Fr": "Fr", "Sa": "Sa", "S_Sun_Initial": "S", "M_Mon_Initial": "M", "T_Tue_Initial": "T", "W_Wed_Initial": "W", "T_Thu_Initial": "T", "F_Fri_Initial": "F", "S_Sat_Initial": "S", "January": "January", "February": "February", "March": "March", "April": "April", "May": "May", "June": "June", "July": "July", "August": "August", "September": "September", "October": "October", "November": "November", "December": "December", "Jan_Abbr": "Jan", "Feb_Abbr": "Feb", "Mar_Abbr": "Mar", "Apr_Abbr": "Apr", "May_Abbr": "May", "Jun_Abbr": "Jun", "Jul_Abbr": "Jul", "Aug_Abbr": "Aug", "Sep_Abbr": "Sep", "Oct_Abbr": "Oct", "Nov_Abbr": "Nov", "Dec_Abbr": "Dec", "AM": "AM", "PM": "PM", "firstDayOfWeek": 1, "twoDigitYearMax": 2029, "mdy": "mdy", "M/d/yyyy": "MM/dd/yyyy", "dddd, MMMM dd, yyyy": "dddd, MMMM dd, yyyy", "h:mm tt": "h:mm tt", "h:mm:ss tt": "h:mm:ss tt", "dddd, MMMM dd, yyyy h:mm:ss tt": "dddd, MMMM dd, yyyy h:mm:ss tt", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "MMMM dd", "MMMM, yyyy": "MMMM, yyyy", "/jan(uary)?/": "jan(uary)?", "/feb(ruary)?/": "feb(ruary)?", "/mar(ch)?/": "mar(ch)?", "/apr(il)?/": "apr(il)?", "/may/": "may", "/jun(e)?/": "jun(e)?", "/jul(y)?/": "jul(y)?", "/aug(ust)?/": "aug(ust)?", "/sep(t(ember)?)?/": "sep(t(ember)?)?", "/oct(ober)?/": "oct(ober)?", "/nov(ember)?/": "nov(ember)?", "/dec(ember)?/": "dec(ember)?", "/^su(n(day)?)?/": "^su(n(day)?)?", "/^mo(n(day)?)?/": "^mo(n(day)?)?", "/^tu(e(s(day)?)?)?/": "^tu(e(s(day)?)?)?", "/^we(d(nesday)?)?/": "^we(d(nesday)?)?", "/^th(u(r(s(day)?)?)?)?/": "^th(u(r(s(day)?)?)?)?", "/^fr(i(day)?)?/": "^fr(i(day)?)?", "/^sa(t(urday)?)?/": "^sa(t(urday)?)?", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "en-029"; ================================================ FILE: build/i18n/en-AU.js ================================================ /* * DateJS Culture String File * Country Code: en-AU * Name: English (Australia) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["en-AU"] = { "name": "en-AU", "englishName": "English (Australia)", "nativeName": "English (Australia)", "Sunday": "Sunday", "Monday": "Monday", "Tuesday": "Tuesday", "Wednesday": "Wednesday", "Thursday": "Thursday", "Friday": "Friday", "Saturday": "Saturday", "Sun": "Sun", "Mon": "Mon", "Tue": "Tue", "Wed": "Wed", "Thu": "Thu", "Fri": "Fri", "Sat": "Sat", "Su": "Su", "Mo": "Mo", "Tu": "Tu", "We": "We", "Th": "Th", "Fr": "Fr", "Sa": "Sa", "S_Sun_Initial": "S", "M_Mon_Initial": "M", "T_Tue_Initial": "T", "W_Wed_Initial": "W", "T_Thu_Initial": "T", "F_Fri_Initial": "F", "S_Sat_Initial": "S", "January": "January", "February": "February", "March": "March", "April": "April", "May": "May", "June": "June", "July": "July", "August": "August", "September": "September", "October": "October", "November": "November", "December": "December", "Jan_Abbr": "Jan", "Feb_Abbr": "Feb", "Mar_Abbr": "Mar", "Apr_Abbr": "Apr", "May_Abbr": "May", "Jun_Abbr": "Jun", "Jul_Abbr": "Jul", "Aug_Abbr": "Aug", "Sep_Abbr": "Sep", "Oct_Abbr": "Oct", "Nov_Abbr": "Nov", "Dec_Abbr": "Dec", "AM": "AM", "PM": "PM", "firstDayOfWeek": 1, "twoDigitYearMax": 2029, "mdy": "dmy", "M/d/yyyy": "d/MM/yyyy", "dddd, MMMM dd, yyyy": "dddd, d MMMM yyyy", "h:mm tt": "h:mm tt", "h:mm:ss tt": "h:mm:ss tt", "dddd, MMMM dd, yyyy h:mm:ss tt": "dddd, d MMMM yyyy h:mm:ss tt", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "dd MMMM", "MMMM, yyyy": "MMMM yyyy", "/jan(uary)?/": "jan(uary)?", "/feb(ruary)?/": "feb(ruary)?", "/mar(ch)?/": "mar(ch)?", "/apr(il)?/": "apr(il)?", "/may/": "may", "/jun(e)?/": "jun(e)?", "/jul(y)?/": "jul(y)?", "/aug(ust)?/": "aug(ust)?", "/sep(t(ember)?)?/": "sep(t(ember)?)?", "/oct(ober)?/": "oct(ober)?", "/nov(ember)?/": "nov(ember)?", "/dec(ember)?/": "dec(ember)?", "/^su(n(day)?)?/": "^su(n(day)?)?", "/^mo(n(day)?)?/": "^mo(n(day)?)?", "/^tu(e(s(day)?)?)?/": "^tu(e(s(day)?)?)?", "/^we(d(nesday)?)?/": "^we(d(nesday)?)?", "/^th(u(r(s(day)?)?)?)?/": "^th(u(r(s(day)?)?)?)?", "/^fr(i(day)?)?/": "^fr(i(day)?)?", "/^sa(t(urday)?)?/": "^sa(t(urday)?)?", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "en-AU"; ================================================ FILE: build/i18n/en-BZ.js ================================================ /* * DateJS Culture String File * Country Code: en-BZ * Name: English (Belize) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["en-BZ"] = { "name": "en-BZ", "englishName": "English (Belize)", "nativeName": "English (Belize)", "Sunday": "Sunday", "Monday": "Monday", "Tuesday": "Tuesday", "Wednesday": "Wednesday", "Thursday": "Thursday", "Friday": "Friday", "Saturday": "Saturday", "Sun": "Sun", "Mon": "Mon", "Tue": "Tue", "Wed": "Wed", "Thu": "Thu", "Fri": "Fri", "Sat": "Sat", "Su": "Su", "Mo": "Mo", "Tu": "Tu", "We": "We", "Th": "Th", "Fr": "Fr", "Sa": "Sa", "S_Sun_Initial": "S", "M_Mon_Initial": "M", "T_Tue_Initial": "T", "W_Wed_Initial": "W", "T_Thu_Initial": "T", "F_Fri_Initial": "F", "S_Sat_Initial": "S", "January": "January", "February": "February", "March": "March", "April": "April", "May": "May", "June": "June", "July": "July", "August": "August", "September": "September", "October": "October", "November": "November", "December": "December", "Jan_Abbr": "Jan", "Feb_Abbr": "Feb", "Mar_Abbr": "Mar", "Apr_Abbr": "Apr", "May_Abbr": "May", "Jun_Abbr": "Jun", "Jul_Abbr": "Jul", "Aug_Abbr": "Aug", "Sep_Abbr": "Sep", "Oct_Abbr": "Oct", "Nov_Abbr": "Nov", "Dec_Abbr": "Dec", "AM": "AM", "PM": "PM", "firstDayOfWeek": 0, "twoDigitYearMax": 2029, "mdy": "dmy", "M/d/yyyy": "dd/MM/yyyy", "dddd, MMMM dd, yyyy": "dddd, dd MMMM yyyy", "h:mm tt": "hh:mm tt", "h:mm:ss tt": "hh:mm:ss tt", "dddd, MMMM dd, yyyy h:mm:ss tt": "dddd, dd MMMM yyyy hh:mm:ss tt", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "dd MMMM", "MMMM, yyyy": "MMMM yyyy", "/jan(uary)?/": "jan(uary)?", "/feb(ruary)?/": "feb(ruary)?", "/mar(ch)?/": "mar(ch)?", "/apr(il)?/": "apr(il)?", "/may/": "may", "/jun(e)?/": "jun(e)?", "/jul(y)?/": "jul(y)?", "/aug(ust)?/": "aug(ust)?", "/sep(t(ember)?)?/": "sep(t(ember)?)?", "/oct(ober)?/": "oct(ober)?", "/nov(ember)?/": "nov(ember)?", "/dec(ember)?/": "dec(ember)?", "/^su(n(day)?)?/": "^su(n(day)?)?", "/^mo(n(day)?)?/": "^mo(n(day)?)?", "/^tu(e(s(day)?)?)?/": "^tu(e(s(day)?)?)?", "/^we(d(nesday)?)?/": "^we(d(nesday)?)?", "/^th(u(r(s(day)?)?)?)?/": "^th(u(r(s(day)?)?)?)?", "/^fr(i(day)?)?/": "^fr(i(day)?)?", "/^sa(t(urday)?)?/": "^sa(t(urday)?)?", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "en-BZ"; ================================================ FILE: build/i18n/en-CA.js ================================================ /* * DateJS Culture String File * Country Code: en-CA * Name: English (Canada) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["en-CA"] = { "name": "en-CA", "englishName": "English (Canada)", "nativeName": "English (Canada)", "Sunday": "Sunday", "Monday": "Monday", "Tuesday": "Tuesday", "Wednesday": "Wednesday", "Thursday": "Thursday", "Friday": "Friday", "Saturday": "Saturday", "Sun": "Sun", "Mon": "Mon", "Tue": "Tue", "Wed": "Wed", "Thu": "Thu", "Fri": "Fri", "Sat": "Sat", "Su": "Su", "Mo": "Mo", "Tu": "Tu", "We": "We", "Th": "Th", "Fr": "Fr", "Sa": "Sa", "S_Sun_Initial": "S", "M_Mon_Initial": "M", "T_Tue_Initial": "T", "W_Wed_Initial": "W", "T_Thu_Initial": "T", "F_Fri_Initial": "F", "S_Sat_Initial": "S", "January": "January", "February": "February", "March": "March", "April": "April", "May": "May", "June": "June", "July": "July", "August": "August", "September": "September", "October": "October", "November": "November", "December": "December", "Jan_Abbr": "Jan", "Feb_Abbr": "Feb", "Mar_Abbr": "Mar", "Apr_Abbr": "Apr", "May_Abbr": "May", "Jun_Abbr": "Jun", "Jul_Abbr": "Jul", "Aug_Abbr": "Aug", "Sep_Abbr": "Sep", "Oct_Abbr": "Oct", "Nov_Abbr": "Nov", "Dec_Abbr": "Dec", "AM": "AM", "PM": "PM", "firstDayOfWeek": 0, "twoDigitYearMax": 2029, "mdy": "dmy", "M/d/yyyy": "dd/MM/yyyy", "dddd, MMMM dd, yyyy": "MMMM d, yyyy", "h:mm tt": "h:mm tt", "h:mm:ss tt": "h:mm:ss tt", "dddd, MMMM dd, yyyy h:mm:ss tt": "MMMM d, yyyy h:mm:ss tt", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "MMMM dd", "MMMM, yyyy": "MMMM, yyyy", "/jan(uary)?/": "jan(uary)?", "/feb(ruary)?/": "feb(ruary)?", "/mar(ch)?/": "mar(ch)?", "/apr(il)?/": "apr(il)?", "/may/": "may", "/jun(e)?/": "jun(e)?", "/jul(y)?/": "jul(y)?", "/aug(ust)?/": "aug(ust)?", "/sep(t(ember)?)?/": "sep(t(ember)?)?", "/oct(ober)?/": "oct(ober)?", "/nov(ember)?/": "nov(ember)?", "/dec(ember)?/": "dec(ember)?", "/^su(n(day)?)?/": "^su(n(day)?)?", "/^mo(n(day)?)?/": "^mo(n(day)?)?", "/^tu(e(s(day)?)?)?/": "^tu(e(s(day)?)?)?", "/^we(d(nesday)?)?/": "^we(d(nesday)?)?", "/^th(u(r(s(day)?)?)?)?/": "^th(u(r(s(day)?)?)?)?", "/^fr(i(day)?)?/": "^fr(i(day)?)?", "/^sa(t(urday)?)?/": "^sa(t(urday)?)?", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "en-CA"; ================================================ FILE: build/i18n/en-GB.js ================================================ /* * DateJS Culture String File * Country Code: en-GB * Name: English (United Kingdom) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["en-GB"] = { "name": "en-GB", "englishName": "English (United Kingdom)", "nativeName": "English (United Kingdom)", "Sunday": "Sunday", "Monday": "Monday", "Tuesday": "Tuesday", "Wednesday": "Wednesday", "Thursday": "Thursday", "Friday": "Friday", "Saturday": "Saturday", "Sun": "Sun", "Mon": "Mon", "Tue": "Tue", "Wed": "Wed", "Thu": "Thu", "Fri": "Fri", "Sat": "Sat", "Su": "Su", "Mo": "Mo", "Tu": "Tu", "We": "We", "Th": "Th", "Fr": "Fr", "Sa": "Sa", "S_Sun_Initial": "S", "M_Mon_Initial": "M", "T_Tue_Initial": "T", "W_Wed_Initial": "W", "T_Thu_Initial": "T", "F_Fri_Initial": "F", "S_Sat_Initial": "S", "January": "January", "February": "February", "March": "March", "April": "April", "May": "May", "June": "June", "July": "July", "August": "August", "September": "September", "October": "October", "November": "November", "December": "December", "Jan_Abbr": "Jan", "Feb_Abbr": "Feb", "Mar_Abbr": "Mar", "Apr_Abbr": "Apr", "May_Abbr": "May", "Jun_Abbr": "Jun", "Jul_Abbr": "Jul", "Aug_Abbr": "Aug", "Sep_Abbr": "Sep", "Oct_Abbr": "Oct", "Nov_Abbr": "Nov", "Dec_Abbr": "Dec", "AM": "AM", "PM": "PM", "firstDayOfWeek": 1, "twoDigitYearMax": 2029, "mdy": "dmy", "M/d/yyyy": "dd/MM/yyyy", "dddd, MMMM dd, yyyy": "dd MMMM yyyy", "h:mm tt": "HH:mm", "h:mm:ss tt": "HH:mm:ss", "dddd, MMMM dd, yyyy h:mm:ss tt": "dd MMMM yyyy HH:mm:ss", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "dd MMMM", "MMMM, yyyy": "MMMM yyyy", "/jan(uary)?/": "jan(uary)?", "/feb(ruary)?/": "feb(ruary)?", "/mar(ch)?/": "mar(ch)?", "/apr(il)?/": "apr(il)?", "/may/": "may", "/jun(e)?/": "jun(e)?", "/jul(y)?/": "jul(y)?", "/aug(ust)?/": "aug(ust)?", "/sep(t(ember)?)?/": "sep(t(ember)?)?", "/oct(ober)?/": "oct(ober)?", "/nov(ember)?/": "nov(ember)?", "/dec(ember)?/": "dec(ember)?", "/^su(n(day)?)?/": "^su(n(day)?)?", "/^mo(n(day)?)?/": "^mo(n(day)?)?", "/^tu(e(s(day)?)?)?/": "^tu(e(s(day)?)?)?", "/^we(d(nesday)?)?/": "^we(d(nesday)?)?", "/^th(u(r(s(day)?)?)?)?/": "^th(u(r(s(day)?)?)?)?", "/^fr(i(day)?)?/": "^fr(i(day)?)?", "/^sa(t(urday)?)?/": "^sa(t(urday)?)?", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "en-GB"; ================================================ FILE: build/i18n/en-IE.js ================================================ /* * DateJS Culture String File * Country Code: en-IE * Name: English (Ireland) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["en-IE"] = { "name": "en-IE", "englishName": "English (Ireland)", "nativeName": "English (Eire)", "Sunday": "Sunday", "Monday": "Monday", "Tuesday": "Tuesday", "Wednesday": "Wednesday", "Thursday": "Thursday", "Friday": "Friday", "Saturday": "Saturday", "Sun": "Sun", "Mon": "Mon", "Tue": "Tue", "Wed": "Wed", "Thu": "Thu", "Fri": "Fri", "Sat": "Sat", "Su": "Su", "Mo": "Mo", "Tu": "Tu", "We": "We", "Th": "Th", "Fr": "Fr", "Sa": "Sa", "S_Sun_Initial": "S", "M_Mon_Initial": "M", "T_Tue_Initial": "T", "W_Wed_Initial": "W", "T_Thu_Initial": "T", "F_Fri_Initial": "F", "S_Sat_Initial": "S", "January": "January", "February": "February", "March": "March", "April": "April", "May": "May", "June": "June", "July": "July", "August": "August", "September": "September", "October": "October", "November": "November", "December": "December", "Jan_Abbr": "Jan", "Feb_Abbr": "Feb", "Mar_Abbr": "Mar", "Apr_Abbr": "Apr", "May_Abbr": "May", "Jun_Abbr": "Jun", "Jul_Abbr": "Jul", "Aug_Abbr": "Aug", "Sep_Abbr": "Sep", "Oct_Abbr": "Oct", "Nov_Abbr": "Nov", "Dec_Abbr": "Dec", "AM": "", "PM": "", "firstDayOfWeek": 1, "twoDigitYearMax": 2029, "mdy": "dmy", "M/d/yyyy": "dd/MM/yyyy", "dddd, MMMM dd, yyyy": "dd MMMM yyyy", "h:mm tt": "HH:mm", "h:mm:ss tt": "HH:mm:ss", "dddd, MMMM dd, yyyy h:mm:ss tt": "dd MMMM yyyy HH:mm:ss", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "dd MMMM", "MMMM, yyyy": "MMMM yyyy", "/jan(uary)?/": "jan(uary)?", "/feb(ruary)?/": "feb(ruary)?", "/mar(ch)?/": "mar(ch)?", "/apr(il)?/": "apr(il)?", "/may/": "may", "/jun(e)?/": "jun(e)?", "/jul(y)?/": "jul(y)?", "/aug(ust)?/": "aug(ust)?", "/sep(t(ember)?)?/": "sep(t(ember)?)?", "/oct(ober)?/": "oct(ober)?", "/nov(ember)?/": "nov(ember)?", "/dec(ember)?/": "dec(ember)?", "/^su(n(day)?)?/": "^su(n(day)?)?", "/^mo(n(day)?)?/": "^mo(n(day)?)?", "/^tu(e(s(day)?)?)?/": "^tu(e(s(day)?)?)?", "/^we(d(nesday)?)?/": "^we(d(nesday)?)?", "/^th(u(r(s(day)?)?)?)?/": "^th(u(r(s(day)?)?)?)?", "/^fr(i(day)?)?/": "^fr(i(day)?)?", "/^sa(t(urday)?)?/": "^sa(t(urday)?)?", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "en-IE"; ================================================ FILE: build/i18n/en-JM.js ================================================ /* * DateJS Culture String File * Country Code: en-JM * Name: English (Jamaica) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["en-JM"] = { "name": "en-JM", "englishName": "English (Jamaica)", "nativeName": "English (Jamaica)", "Sunday": "Sunday", "Monday": "Monday", "Tuesday": "Tuesday", "Wednesday": "Wednesday", "Thursday": "Thursday", "Friday": "Friday", "Saturday": "Saturday", "Sun": "Sun", "Mon": "Mon", "Tue": "Tue", "Wed": "Wed", "Thu": "Thu", "Fri": "Fri", "Sat": "Sat", "Su": "Su", "Mo": "Mo", "Tu": "Tu", "We": "We", "Th": "Th", "Fr": "Fr", "Sa": "Sa", "S_Sun_Initial": "S", "M_Mon_Initial": "M", "T_Tue_Initial": "T", "W_Wed_Initial": "W", "T_Thu_Initial": "T", "F_Fri_Initial": "F", "S_Sat_Initial": "S", "January": "January", "February": "February", "March": "March", "April": "April", "May": "May", "June": "June", "July": "July", "August": "August", "September": "September", "October": "October", "November": "November", "December": "December", "Jan_Abbr": "Jan", "Feb_Abbr": "Feb", "Mar_Abbr": "Mar", "Apr_Abbr": "Apr", "May_Abbr": "May", "Jun_Abbr": "Jun", "Jul_Abbr": "Jul", "Aug_Abbr": "Aug", "Sep_Abbr": "Sep", "Oct_Abbr": "Oct", "Nov_Abbr": "Nov", "Dec_Abbr": "Dec", "AM": "AM", "PM": "PM", "firstDayOfWeek": 0, "twoDigitYearMax": 2029, "mdy": "dmy", "M/d/yyyy": "dd/MM/yyyy", "dddd, MMMM dd, yyyy": "dddd, MMMM dd, yyyy", "h:mm tt": "hh:mm tt", "h:mm:ss tt": "hh:mm:ss tt", "dddd, MMMM dd, yyyy h:mm:ss tt": "dddd, MMMM dd, yyyy hh:mm:ss tt", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "MMMM dd", "MMMM, yyyy": "MMMM, yyyy", "/jan(uary)?/": "jan(uary)?", "/feb(ruary)?/": "feb(ruary)?", "/mar(ch)?/": "mar(ch)?", "/apr(il)?/": "apr(il)?", "/may/": "may", "/jun(e)?/": "jun(e)?", "/jul(y)?/": "jul(y)?", "/aug(ust)?/": "aug(ust)?", "/sep(t(ember)?)?/": "sep(t(ember)?)?", "/oct(ober)?/": "oct(ober)?", "/nov(ember)?/": "nov(ember)?", "/dec(ember)?/": "dec(ember)?", "/^su(n(day)?)?/": "^su(n(day)?)?", "/^mo(n(day)?)?/": "^mo(n(day)?)?", "/^tu(e(s(day)?)?)?/": "^tu(e(s(day)?)?)?", "/^we(d(nesday)?)?/": "^we(d(nesday)?)?", "/^th(u(r(s(day)?)?)?)?/": "^th(u(r(s(day)?)?)?)?", "/^fr(i(day)?)?/": "^fr(i(day)?)?", "/^sa(t(urday)?)?/": "^sa(t(urday)?)?", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "en-JM"; ================================================ FILE: build/i18n/en-NZ.js ================================================ /* * DateJS Culture String File * Country Code: en-NZ * Name: English (New Zealand) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["en-NZ"] = { "name": "en-NZ", "englishName": "English (New Zealand)", "nativeName": "English (New Zealand)", "Sunday": "Sunday", "Monday": "Monday", "Tuesday": "Tuesday", "Wednesday": "Wednesday", "Thursday": "Thursday", "Friday": "Friday", "Saturday": "Saturday", "Sun": "Sun", "Mon": "Mon", "Tue": "Tue", "Wed": "Wed", "Thu": "Thu", "Fri": "Fri", "Sat": "Sat", "Su": "Su", "Mo": "Mo", "Tu": "Tu", "We": "We", "Th": "Th", "Fr": "Fr", "Sa": "Sa", "S_Sun_Initial": "S", "M_Mon_Initial": "M", "T_Tue_Initial": "T", "W_Wed_Initial": "W", "T_Thu_Initial": "T", "F_Fri_Initial": "F", "S_Sat_Initial": "S", "January": "January", "February": "February", "March": "March", "April": "April", "May": "May", "June": "June", "July": "July", "August": "August", "September": "September", "October": "October", "November": "November", "December": "December", "Jan_Abbr": "Jan", "Feb_Abbr": "Feb", "Mar_Abbr": "Mar", "Apr_Abbr": "Apr", "May_Abbr": "May", "Jun_Abbr": "Jun", "Jul_Abbr": "Jul", "Aug_Abbr": "Aug", "Sep_Abbr": "Sep", "Oct_Abbr": "Oct", "Nov_Abbr": "Nov", "Dec_Abbr": "Dec", "AM": "a.m.", "PM": "p.m.", "firstDayOfWeek": 1, "twoDigitYearMax": 2029, "mdy": "dmy", "M/d/yyyy": "d/MM/yyyy", "dddd, MMMM dd, yyyy": "dddd, d MMMM yyyy", "h:mm tt": "h:mm tt", "h:mm:ss tt": "h:mm:ss tt", "dddd, MMMM dd, yyyy h:mm:ss tt": "dddd, d MMMM yyyy h:mm:ss tt", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "dd MMMM", "MMMM, yyyy": "MMMM yyyy", "/jan(uary)?/": "jan(uary)?", "/feb(ruary)?/": "feb(ruary)?", "/mar(ch)?/": "mar(ch)?", "/apr(il)?/": "apr(il)?", "/may/": "may", "/jun(e)?/": "jun(e)?", "/jul(y)?/": "jul(y)?", "/aug(ust)?/": "aug(ust)?", "/sep(t(ember)?)?/": "sep(t(ember)?)?", "/oct(ober)?/": "oct(ober)?", "/nov(ember)?/": "nov(ember)?", "/dec(ember)?/": "dec(ember)?", "/^su(n(day)?)?/": "^su(n(day)?)?", "/^mo(n(day)?)?/": "^mo(n(day)?)?", "/^tu(e(s(day)?)?)?/": "^tu(e(s(day)?)?)?", "/^we(d(nesday)?)?/": "^we(d(nesday)?)?", "/^th(u(r(s(day)?)?)?)?/": "^th(u(r(s(day)?)?)?)?", "/^fr(i(day)?)?/": "^fr(i(day)?)?", "/^sa(t(urday)?)?/": "^sa(t(urday)?)?", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "en-NZ"; ================================================ FILE: build/i18n/en-PH.js ================================================ /* * DateJS Culture String File * Country Code: en-PH * Name: English (Republic of the Philippines) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["en-PH"] = { "name": "en-PH", "englishName": "English (Republic of the Philippines)", "nativeName": "English (Philippines)", "Sunday": "Sunday", "Monday": "Monday", "Tuesday": "Tuesday", "Wednesday": "Wednesday", "Thursday": "Thursday", "Friday": "Friday", "Saturday": "Saturday", "Sun": "Sun", "Mon": "Mon", "Tue": "Tue", "Wed": "Wed", "Thu": "Thu", "Fri": "Fri", "Sat": "Sat", "Su": "Su", "Mo": "Mo", "Tu": "Tu", "We": "We", "Th": "Th", "Fr": "Fr", "Sa": "Sa", "S_Sun_Initial": "S", "M_Mon_Initial": "M", "T_Tue_Initial": "T", "W_Wed_Initial": "W", "T_Thu_Initial": "T", "F_Fri_Initial": "F", "S_Sat_Initial": "S", "January": "January", "February": "February", "March": "March", "April": "April", "May": "May", "June": "June", "July": "July", "August": "August", "September": "September", "October": "October", "November": "November", "December": "December", "Jan_Abbr": "Jan", "Feb_Abbr": "Feb", "Mar_Abbr": "Mar", "Apr_Abbr": "Apr", "May_Abbr": "May", "Jun_Abbr": "Jun", "Jul_Abbr": "Jul", "Aug_Abbr": "Aug", "Sep_Abbr": "Sep", "Oct_Abbr": "Oct", "Nov_Abbr": "Nov", "Dec_Abbr": "Dec", "AM": "AM", "PM": "PM", "firstDayOfWeek": 0, "twoDigitYearMax": 2029, "mdy": "mdy", "M/d/yyyy": "M/d/yyyy", "dddd, MMMM dd, yyyy": "dddd, MMMM dd, yyyy", "h:mm tt": "h:mm tt", "h:mm:ss tt": "h:mm:ss tt", "dddd, MMMM dd, yyyy h:mm:ss tt": "dddd, MMMM dd, yyyy h:mm:ss tt", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "MMMM dd", "MMMM, yyyy": "MMMM, yyyy", "/jan(uary)?/": "jan(uary)?", "/feb(ruary)?/": "feb(ruary)?", "/mar(ch)?/": "mar(ch)?", "/apr(il)?/": "apr(il)?", "/may/": "may", "/jun(e)?/": "jun(e)?", "/jul(y)?/": "jul(y)?", "/aug(ust)?/": "aug(ust)?", "/sep(t(ember)?)?/": "sep(t(ember)?)?", "/oct(ober)?/": "oct(ober)?", "/nov(ember)?/": "nov(ember)?", "/dec(ember)?/": "dec(ember)?", "/^su(n(day)?)?/": "^su(n(day)?)?", "/^mo(n(day)?)?/": "^mo(n(day)?)?", "/^tu(e(s(day)?)?)?/": "^tu(e(s(day)?)?)?", "/^we(d(nesday)?)?/": "^we(d(nesday)?)?", "/^th(u(r(s(day)?)?)?)?/": "^th(u(r(s(day)?)?)?)?", "/^fr(i(day)?)?/": "^fr(i(day)?)?", "/^sa(t(urday)?)?/": "^sa(t(urday)?)?", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "en-PH"; ================================================ FILE: build/i18n/en-TT.js ================================================ /* * DateJS Culture String File * Country Code: en-TT * Name: English (Trinidad and Tobago) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["en-TT"] = { "name": "en-TT", "englishName": "English (Trinidad and Tobago)", "nativeName": "English (Trinidad y Tobago)", "Sunday": "Sunday", "Monday": "Monday", "Tuesday": "Tuesday", "Wednesday": "Wednesday", "Thursday": "Thursday", "Friday": "Friday", "Saturday": "Saturday", "Sun": "Sun", "Mon": "Mon", "Tue": "Tue", "Wed": "Wed", "Thu": "Thu", "Fri": "Fri", "Sat": "Sat", "Su": "Su", "Mo": "Mo", "Tu": "Tu", "We": "We", "Th": "Th", "Fr": "Fr", "Sa": "Sa", "S_Sun_Initial": "S", "M_Mon_Initial": "M", "T_Tue_Initial": "T", "W_Wed_Initial": "W", "T_Thu_Initial": "T", "F_Fri_Initial": "F", "S_Sat_Initial": "S", "January": "January", "February": "February", "March": "March", "April": "April", "May": "May", "June": "June", "July": "July", "August": "August", "September": "September", "October": "October", "November": "November", "December": "December", "Jan_Abbr": "Jan", "Feb_Abbr": "Feb", "Mar_Abbr": "Mar", "Apr_Abbr": "Apr", "May_Abbr": "May", "Jun_Abbr": "Jun", "Jul_Abbr": "Jul", "Aug_Abbr": "Aug", "Sep_Abbr": "Sep", "Oct_Abbr": "Oct", "Nov_Abbr": "Nov", "Dec_Abbr": "Dec", "AM": "AM", "PM": "PM", "firstDayOfWeek": 0, "twoDigitYearMax": 2029, "mdy": "dmy", "M/d/yyyy": "dd/MM/yyyy", "dddd, MMMM dd, yyyy": "dddd, dd MMMM yyyy", "h:mm tt": "hh:mm tt", "h:mm:ss tt": "hh:mm:ss tt", "dddd, MMMM dd, yyyy h:mm:ss tt": "dddd, dd MMMM yyyy hh:mm:ss tt", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "dd MMMM", "MMMM, yyyy": "MMMM yyyy", "/jan(uary)?/": "jan(uary)?", "/feb(ruary)?/": "feb(ruary)?", "/mar(ch)?/": "mar(ch)?", "/apr(il)?/": "apr(il)?", "/may/": "may", "/jun(e)?/": "jun(e)?", "/jul(y)?/": "jul(y)?", "/aug(ust)?/": "aug(ust)?", "/sep(t(ember)?)?/": "sep(t(ember)?)?", "/oct(ober)?/": "oct(ober)?", "/nov(ember)?/": "nov(ember)?", "/dec(ember)?/": "dec(ember)?", "/^su(n(day)?)?/": "^su(n(day)?)?", "/^mo(n(day)?)?/": "^mo(n(day)?)?", "/^tu(e(s(day)?)?)?/": "^tu(e(s(day)?)?)?", "/^we(d(nesday)?)?/": "^we(d(nesday)?)?", "/^th(u(r(s(day)?)?)?)?/": "^th(u(r(s(day)?)?)?)?", "/^fr(i(day)?)?/": "^fr(i(day)?)?", "/^sa(t(urday)?)?/": "^sa(t(urday)?)?", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "en-TT"; ================================================ FILE: build/i18n/en-ZA.js ================================================ /* * DateJS Culture String File * Country Code: en-ZA * Name: English (South Africa) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["en-ZA"] = { "name": "en-ZA", "englishName": "English (South Africa)", "nativeName": "English (South Africa)", "Sunday": "Sunday", "Monday": "Monday", "Tuesday": "Tuesday", "Wednesday": "Wednesday", "Thursday": "Thursday", "Friday": "Friday", "Saturday": "Saturday", "Sun": "Sun", "Mon": "Mon", "Tue": "Tue", "Wed": "Wed", "Thu": "Thu", "Fri": "Fri", "Sat": "Sat", "Su": "Su", "Mo": "Mo", "Tu": "Tu", "We": "We", "Th": "Th", "Fr": "Fr", "Sa": "Sa", "S_Sun_Initial": "S", "M_Mon_Initial": "M", "T_Tue_Initial": "T", "W_Wed_Initial": "W", "T_Thu_Initial": "T", "F_Fri_Initial": "F", "S_Sat_Initial": "S", "January": "January", "February": "February", "March": "March", "April": "April", "May": "May", "June": "June", "July": "July", "August": "August", "September": "September", "October": "October", "November": "November", "December": "December", "Jan_Abbr": "Jan", "Feb_Abbr": "Feb", "Mar_Abbr": "Mar", "Apr_Abbr": "Apr", "May_Abbr": "May", "Jun_Abbr": "Jun", "Jul_Abbr": "Jul", "Aug_Abbr": "Aug", "Sep_Abbr": "Sep", "Oct_Abbr": "Oct", "Nov_Abbr": "Nov", "Dec_Abbr": "Dec", "AM": "AM", "PM": "PM", "firstDayOfWeek": 0, "twoDigitYearMax": 2029, "mdy": "ymd", "M/d/yyyy": "yyyy/MM/dd", "dddd, MMMM dd, yyyy": "dd MMMM yyyy", "h:mm tt": "hh:mm tt", "h:mm:ss tt": "hh:mm:ss tt", "dddd, MMMM dd, yyyy h:mm:ss tt": "dd MMMM yyyy hh:mm:ss tt", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "dd MMMM", "MMMM, yyyy": "MMMM yyyy", "/jan(uary)?/": "jan(uary)?", "/feb(ruary)?/": "feb(ruary)?", "/mar(ch)?/": "mar(ch)?", "/apr(il)?/": "apr(il)?", "/may/": "may", "/jun(e)?/": "jun(e)?", "/jul(y)?/": "jul(y)?", "/aug(ust)?/": "aug(ust)?", "/sep(t(ember)?)?/": "sep(t(ember)?)?", "/oct(ober)?/": "oct(ober)?", "/nov(ember)?/": "nov(ember)?", "/dec(ember)?/": "dec(ember)?", "/^su(n(day)?)?/": "^su(n(day)?)?", "/^mo(n(day)?)?/": "^mo(n(day)?)?", "/^tu(e(s(day)?)?)?/": "^tu(e(s(day)?)?)?", "/^we(d(nesday)?)?/": "^we(d(nesday)?)?", "/^th(u(r(s(day)?)?)?)?/": "^th(u(r(s(day)?)?)?)?", "/^fr(i(day)?)?/": "^fr(i(day)?)?", "/^sa(t(urday)?)?/": "^sa(t(urday)?)?", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "en-ZA"; ================================================ FILE: build/i18n/en-ZW.js ================================================ /* * DateJS Culture String File * Country Code: en-ZW * Name: English (Zimbabwe) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["en-ZW"] = { "name": "en-ZW", "englishName": "English (Zimbabwe)", "nativeName": "English (Zimbabwe)", "Sunday": "Sunday", "Monday": "Monday", "Tuesday": "Tuesday", "Wednesday": "Wednesday", "Thursday": "Thursday", "Friday": "Friday", "Saturday": "Saturday", "Sun": "Sun", "Mon": "Mon", "Tue": "Tue", "Wed": "Wed", "Thu": "Thu", "Fri": "Fri", "Sat": "Sat", "Su": "Su", "Mo": "Mo", "Tu": "Tu", "We": "We", "Th": "Th", "Fr": "Fr", "Sa": "Sa", "S_Sun_Initial": "S", "M_Mon_Initial": "M", "T_Tue_Initial": "T", "W_Wed_Initial": "W", "T_Thu_Initial": "T", "F_Fri_Initial": "F", "S_Sat_Initial": "S", "January": "January", "February": "February", "March": "March", "April": "April", "May": "May", "June": "June", "July": "July", "August": "August", "September": "September", "October": "October", "November": "November", "December": "December", "Jan_Abbr": "Jan", "Feb_Abbr": "Feb", "Mar_Abbr": "Mar", "Apr_Abbr": "Apr", "May_Abbr": "May", "Jun_Abbr": "Jun", "Jul_Abbr": "Jul", "Aug_Abbr": "Aug", "Sep_Abbr": "Sep", "Oct_Abbr": "Oct", "Nov_Abbr": "Nov", "Dec_Abbr": "Dec", "AM": "AM", "PM": "PM", "firstDayOfWeek": 0, "twoDigitYearMax": 2029, "mdy": "mdy", "M/d/yyyy": "M/d/yyyy", "dddd, MMMM dd, yyyy": "dddd, MMMM dd, yyyy", "h:mm tt": "h:mm tt", "h:mm:ss tt": "h:mm:ss tt", "dddd, MMMM dd, yyyy h:mm:ss tt": "dddd, MMMM dd, yyyy h:mm:ss tt", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "MMMM dd", "MMMM, yyyy": "MMMM, yyyy", "/jan(uary)?/": "jan(uary)?", "/feb(ruary)?/": "feb(ruary)?", "/mar(ch)?/": "mar(ch)?", "/apr(il)?/": "apr(il)?", "/may/": "may", "/jun(e)?/": "jun(e)?", "/jul(y)?/": "jul(y)?", "/aug(ust)?/": "aug(ust)?", "/sep(t(ember)?)?/": "sep(t(ember)?)?", "/oct(ober)?/": "oct(ober)?", "/nov(ember)?/": "nov(ember)?", "/dec(ember)?/": "dec(ember)?", "/^su(n(day)?)?/": "^su(n(day)?)?", "/^mo(n(day)?)?/": "^mo(n(day)?)?", "/^tu(e(s(day)?)?)?/": "^tu(e(s(day)?)?)?", "/^we(d(nesday)?)?/": "^we(d(nesday)?)?", "/^th(u(r(s(day)?)?)?)?/": "^th(u(r(s(day)?)?)?)?", "/^fr(i(day)?)?/": "^fr(i(day)?)?", "/^sa(t(urday)?)?/": "^sa(t(urday)?)?", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "en-ZW"; ================================================ FILE: build/i18n/es-AR.js ================================================ /* * DateJS Culture String File * Country Code: es-AR * Name: Spanish (Argentina) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["es-AR"] = { "name": "es-AR", "englishName": "Spanish (Argentina)", "nativeName": "Español (Argentina)", "Sunday": "domingo", "Monday": "lunes", "Tuesday": "martes", "Wednesday": "miércoles", "Thursday": "jueves", "Friday": "viernes", "Saturday": "sábado", "Sun": "dom", "Mon": "lun", "Tue": "mar", "Wed": "mié", "Thu": "jue", "Fri": "vie", "Sat": "sáb", "Su": "do", "Mo": "lu", "Tu": "ma", "We": "mi", "Th": "ju", "Fr": "vi", "Sa": "sá", "S_Sun_Initial": "d", "M_Mon_Initial": "l", "T_Tue_Initial": "m", "W_Wed_Initial": "m", "T_Thu_Initial": "j", "F_Fri_Initial": "v", "S_Sat_Initial": "s", "January": "enero", "February": "febrero", "March": "marzo", "April": "abril", "May": "mayo", "June": "junio", "July": "julio", "August": "agosto", "September": "septiembre", "October": "octubre", "November": "noviembre", "December": "diciembre", "Jan_Abbr": "ene", "Feb_Abbr": "feb", "Mar_Abbr": "mar", "Apr_Abbr": "abr", "May_Abbr": "may", "Jun_Abbr": "jun", "Jul_Abbr": "jul", "Aug_Abbr": "ago", "Sep_Abbr": "sep", "Oct_Abbr": "oct", "Nov_Abbr": "nov", "Dec_Abbr": "dic", "AM": "a.m.", "PM": "p.m.", "firstDayOfWeek": 0, "twoDigitYearMax": 2029, "mdy": "dmy", "M/d/yyyy": "dd/MM/yyyy", "dddd, MMMM dd, yyyy": "dddd, dd' de 'MMMM' de 'yyyy", "h:mm tt": "hh:mm tt", "h:mm:ss tt": "hh:mm:ss tt", "dddd, MMMM dd, yyyy h:mm:ss tt": "dddd, dd' de 'MMMM' de 'yyyy hh:mm:ss tt", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "dd MMMM", "MMMM, yyyy": "MMMM' de 'yyyy", "/jan(uary)?/": "ene(ro)?", "/feb(ruary)?/": "feb(rero)?", "/mar(ch)?/": "mar(zo)?", "/apr(il)?/": "abr(il)?", "/may/": "may(o)?", "/jun(e)?/": "jun(io)?", "/jul(y)?/": "jul(io)?", "/aug(ust)?/": "ago(sto)?", "/sep(t(ember)?)?/": "sep(tiembre)?", "/oct(ober)?/": "oct(ubre)?", "/nov(ember)?/": "nov(iembre)?", "/dec(ember)?/": "dic(iembre)?", "/^su(n(day)?)?/": "^do(m(ingo)?)?", "/^mo(n(day)?)?/": "^lu(n(es)?)?", "/^tu(e(s(day)?)?)?/": "^ma(r(tes)?)?", "/^we(d(nesday)?)?/": "^mi(é(rcoles)?)?", "/^th(u(r(s(day)?)?)?)?/": "^ju(e(ves)?)?", "/^fr(i(day)?)?/": "^vi(e(rnes)?)?", "/^sa(t(urday)?)?/": "^sá(b(ado)?)?", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "es-AR"; ================================================ FILE: build/i18n/es-BO.js ================================================ /* * DateJS Culture String File * Country Code: es-BO * Name: Spanish (Bolivia) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["es-BO"] = { "name": "es-BO", "englishName": "Spanish (Bolivia)", "nativeName": "Español (Bolivia)", "Sunday": "domingo", "Monday": "lunes", "Tuesday": "martes", "Wednesday": "miércoles", "Thursday": "jueves", "Friday": "viernes", "Saturday": "sábado", "Sun": "dom", "Mon": "lun", "Tue": "mar", "Wed": "mié", "Thu": "jue", "Fri": "vie", "Sat": "sáb", "Su": "do", "Mo": "lu", "Tu": "ma", "We": "mi", "Th": "ju", "Fr": "vi", "Sa": "sá", "S_Sun_Initial": "d", "M_Mon_Initial": "l", "T_Tue_Initial": "m", "W_Wed_Initial": "m", "T_Thu_Initial": "j", "F_Fri_Initial": "v", "S_Sat_Initial": "s", "January": "enero", "February": "febrero", "March": "marzo", "April": "abril", "May": "mayo", "June": "junio", "July": "julio", "August": "agosto", "September": "septiembre", "October": "octubre", "November": "noviembre", "December": "diciembre", "Jan_Abbr": "ene", "Feb_Abbr": "feb", "Mar_Abbr": "mar", "Apr_Abbr": "abr", "May_Abbr": "may", "Jun_Abbr": "jun", "Jul_Abbr": "jul", "Aug_Abbr": "ago", "Sep_Abbr": "sep", "Oct_Abbr": "oct", "Nov_Abbr": "nov", "Dec_Abbr": "dic", "AM": "a.m.", "PM": "p.m.", "firstDayOfWeek": 0, "twoDigitYearMax": 2029, "mdy": "dmy", "M/d/yyyy": "dd/MM/yyyy", "dddd, MMMM dd, yyyy": "dddd, dd' de 'MMMM' de 'yyyy", "h:mm tt": "hh:mm tt", "h:mm:ss tt": "hh:mm:ss tt", "dddd, MMMM dd, yyyy h:mm:ss tt": "dddd, dd' de 'MMMM' de 'yyyy hh:mm:ss tt", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "dd MMMM", "MMMM, yyyy": "MMMM' de 'yyyy", "/jan(uary)?/": "ene(ro)?", "/feb(ruary)?/": "feb(rero)?", "/mar(ch)?/": "mar(zo)?", "/apr(il)?/": "abr(il)?", "/may/": "may(o)?", "/jun(e)?/": "jun(io)?", "/jul(y)?/": "jul(io)?", "/aug(ust)?/": "ago(sto)?", "/sep(t(ember)?)?/": "sep(tiembre)?", "/oct(ober)?/": "oct(ubre)?", "/nov(ember)?/": "nov(iembre)?", "/dec(ember)?/": "dic(iembre)?", "/^su(n(day)?)?/": "^do(m(ingo)?)?", "/^mo(n(day)?)?/": "^lu(n(es)?)?", "/^tu(e(s(day)?)?)?/": "^ma(r(tes)?)?", "/^we(d(nesday)?)?/": "^mi(é(rcoles)?)?", "/^th(u(r(s(day)?)?)?)?/": "^ju(e(ves)?)?", "/^fr(i(day)?)?/": "^vi(e(rnes)?)?", "/^sa(t(urday)?)?/": "^sá(b(ado)?)?", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "es-BO"; ================================================ FILE: build/i18n/es-CL.js ================================================ /* * DateJS Culture String File * Country Code: es-CL * Name: Spanish (Chile) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["es-CL"] = { "name": "es-CL", "englishName": "Spanish (Chile)", "nativeName": "Español (Chile)", "Sunday": "domingo", "Monday": "lunes", "Tuesday": "martes", "Wednesday": "miércoles", "Thursday": "jueves", "Friday": "viernes", "Saturday": "sábado", "Sun": "dom", "Mon": "lun", "Tue": "mar", "Wed": "mié", "Thu": "jue", "Fri": "vie", "Sat": "sáb", "Su": "do", "Mo": "lu", "Tu": "ma", "We": "mi", "Th": "ju", "Fr": "vi", "Sa": "sá", "S_Sun_Initial": "d", "M_Mon_Initial": "l", "T_Tue_Initial": "m", "W_Wed_Initial": "m", "T_Thu_Initial": "j", "F_Fri_Initial": "v", "S_Sat_Initial": "s", "January": "enero", "February": "febrero", "March": "marzo", "April": "abril", "May": "mayo", "June": "junio", "July": "julio", "August": "agosto", "September": "septiembre", "October": "octubre", "November": "noviembre", "December": "diciembre", "Jan_Abbr": "ene", "Feb_Abbr": "feb", "Mar_Abbr": "mar", "Apr_Abbr": "abr", "May_Abbr": "may", "Jun_Abbr": "jun", "Jul_Abbr": "jul", "Aug_Abbr": "ago", "Sep_Abbr": "sep", "Oct_Abbr": "oct", "Nov_Abbr": "nov", "Dec_Abbr": "dic", "AM": "", "PM": "", "firstDayOfWeek": 0, "twoDigitYearMax": 2029, "mdy": "dmy", "M/d/yyyy": "dd-MM-yyyy", "dddd, MMMM dd, yyyy": "dddd, dd' de 'MMMM' de 'yyyy", "h:mm tt": "H:mm", "h:mm:ss tt": "H:mm:ss", "dddd, MMMM dd, yyyy h:mm:ss tt": "dddd, dd' de 'MMMM' de 'yyyy H:mm:ss", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "dd MMMM", "MMMM, yyyy": "MMMM' de 'yyyy", "/jan(uary)?/": "ene(ro)?", "/feb(ruary)?/": "feb(rero)?", "/mar(ch)?/": "mar(zo)?", "/apr(il)?/": "abr(il)?", "/may/": "may(o)?", "/jun(e)?/": "jun(io)?", "/jul(y)?/": "jul(io)?", "/aug(ust)?/": "ago(sto)?", "/sep(t(ember)?)?/": "sep(tiembre)?", "/oct(ober)?/": "oct(ubre)?", "/nov(ember)?/": "nov(iembre)?", "/dec(ember)?/": "dic(iembre)?", "/^su(n(day)?)?/": "^do(m(ingo)?)?", "/^mo(n(day)?)?/": "^lu(n(es)?)?", "/^tu(e(s(day)?)?)?/": "^ma(r(tes)?)?", "/^we(d(nesday)?)?/": "^mi(é(rcoles)?)?", "/^th(u(r(s(day)?)?)?)?/": "^ju(e(ves)?)?", "/^fr(i(day)?)?/": "^vi(e(rnes)?)?", "/^sa(t(urday)?)?/": "^sá(b(ado)?)?", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "es-CL"; ================================================ FILE: build/i18n/es-CO.js ================================================ /* * DateJS Culture String File * Country Code: es-CO * Name: Spanish (Colombia) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["es-CO"] = { "name": "es-CO", "englishName": "Spanish (Colombia)", "nativeName": "Español (Colombia)", "Sunday": "domingo", "Monday": "lunes", "Tuesday": "martes", "Wednesday": "miércoles", "Thursday": "jueves", "Friday": "viernes", "Saturday": "sábado", "Sun": "dom", "Mon": "lun", "Tue": "mar", "Wed": "mié", "Thu": "jue", "Fri": "vie", "Sat": "sáb", "Su": "do", "Mo": "lu", "Tu": "ma", "We": "mi", "Th": "ju", "Fr": "vi", "Sa": "sá", "S_Sun_Initial": "d", "M_Mon_Initial": "l", "T_Tue_Initial": "m", "W_Wed_Initial": "m", "T_Thu_Initial": "j", "F_Fri_Initial": "v", "S_Sat_Initial": "s", "January": "enero", "February": "febrero", "March": "marzo", "April": "abril", "May": "mayo", "June": "junio", "July": "julio", "August": "agosto", "September": "septiembre", "October": "octubre", "November": "noviembre", "December": "diciembre", "Jan_Abbr": "ene", "Feb_Abbr": "feb", "Mar_Abbr": "mar", "Apr_Abbr": "abr", "May_Abbr": "may", "Jun_Abbr": "jun", "Jul_Abbr": "jul", "Aug_Abbr": "ago", "Sep_Abbr": "sep", "Oct_Abbr": "oct", "Nov_Abbr": "nov", "Dec_Abbr": "dic", "AM": "a.m.", "PM": "p.m.", "firstDayOfWeek": 0, "twoDigitYearMax": 2029, "mdy": "dmy", "M/d/yyyy": "dd/MM/yyyy", "dddd, MMMM dd, yyyy": "dddd, dd' de 'MMMM' de 'yyyy", "h:mm tt": "hh:mm tt", "h:mm:ss tt": "hh:mm:ss tt", "dddd, MMMM dd, yyyy h:mm:ss tt": "dddd, dd' de 'MMMM' de 'yyyy hh:mm:ss tt", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "dd MMMM", "MMMM, yyyy": "MMMM' de 'yyyy", "/jan(uary)?/": "ene(ro)?", "/feb(ruary)?/": "feb(rero)?", "/mar(ch)?/": "mar(zo)?", "/apr(il)?/": "abr(il)?", "/may/": "may(o)?", "/jun(e)?/": "jun(io)?", "/jul(y)?/": "jul(io)?", "/aug(ust)?/": "ago(sto)?", "/sep(t(ember)?)?/": "sep(tiembre)?", "/oct(ober)?/": "oct(ubre)?", "/nov(ember)?/": "nov(iembre)?", "/dec(ember)?/": "dic(iembre)?", "/^su(n(day)?)?/": "^do(m(ingo)?)?", "/^mo(n(day)?)?/": "^lu(n(es)?)?", "/^tu(e(s(day)?)?)?/": "^ma(r(tes)?)?", "/^we(d(nesday)?)?/": "^mi(é(rcoles)?)?", "/^th(u(r(s(day)?)?)?)?/": "^ju(e(ves)?)?", "/^fr(i(day)?)?/": "^vi(e(rnes)?)?", "/^sa(t(urday)?)?/": "^sá(b(ado)?)?", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "es-CO"; ================================================ FILE: build/i18n/es-CR.js ================================================ /* * DateJS Culture String File * Country Code: es-CR * Name: Spanish (Costa Rica) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["es-CR"] = { "name": "es-CR", "englishName": "Spanish (Costa Rica)", "nativeName": "Español (Costa Rica)", "Sunday": "domingo", "Monday": "lunes", "Tuesday": "martes", "Wednesday": "miércoles", "Thursday": "jueves", "Friday": "viernes", "Saturday": "sábado", "Sun": "dom", "Mon": "lun", "Tue": "mar", "Wed": "mié", "Thu": "jue", "Fri": "vie", "Sat": "sáb", "Su": "do", "Mo": "lu", "Tu": "ma", "We": "mi", "Th": "ju", "Fr": "vi", "Sa": "sá", "S_Sun_Initial": "d", "M_Mon_Initial": "l", "T_Tue_Initial": "m", "W_Wed_Initial": "m", "T_Thu_Initial": "j", "F_Fri_Initial": "v", "S_Sat_Initial": "s", "January": "enero", "February": "febrero", "March": "marzo", "April": "abril", "May": "mayo", "June": "junio", "July": "julio", "August": "agosto", "September": "septiembre", "October": "octubre", "November": "noviembre", "December": "diciembre", "Jan_Abbr": "ene", "Feb_Abbr": "feb", "Mar_Abbr": "mar", "Apr_Abbr": "abr", "May_Abbr": "may", "Jun_Abbr": "jun", "Jul_Abbr": "jul", "Aug_Abbr": "ago", "Sep_Abbr": "sep", "Oct_Abbr": "oct", "Nov_Abbr": "nov", "Dec_Abbr": "dic", "AM": "a.m.", "PM": "p.m.", "firstDayOfWeek": 0, "twoDigitYearMax": 2029, "mdy": "dmy", "M/d/yyyy": "dd/MM/yyyy", "dddd, MMMM dd, yyyy": "dddd, dd' de 'MMMM' de 'yyyy", "h:mm tt": "hh:mm tt", "h:mm:ss tt": "hh:mm:ss tt", "dddd, MMMM dd, yyyy h:mm:ss tt": "dddd, dd' de 'MMMM' de 'yyyy hh:mm:ss tt", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "dd MMMM", "MMMM, yyyy": "MMMM' de 'yyyy", "/jan(uary)?/": "ene(ro)?", "/feb(ruary)?/": "feb(rero)?", "/mar(ch)?/": "mar(zo)?", "/apr(il)?/": "abr(il)?", "/may/": "may(o)?", "/jun(e)?/": "jun(io)?", "/jul(y)?/": "jul(io)?", "/aug(ust)?/": "ago(sto)?", "/sep(t(ember)?)?/": "sep(tiembre)?", "/oct(ober)?/": "oct(ubre)?", "/nov(ember)?/": "nov(iembre)?", "/dec(ember)?/": "dic(iembre)?", "/^su(n(day)?)?/": "^do(m(ingo)?)?", "/^mo(n(day)?)?/": "^lu(n(es)?)?", "/^tu(e(s(day)?)?)?/": "^ma(r(tes)?)?", "/^we(d(nesday)?)?/": "^mi(é(rcoles)?)?", "/^th(u(r(s(day)?)?)?)?/": "^ju(e(ves)?)?", "/^fr(i(day)?)?/": "^vi(e(rnes)?)?", "/^sa(t(urday)?)?/": "^sá(b(ado)?)?", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "es-CR"; ================================================ FILE: build/i18n/es-DO.js ================================================ /* * DateJS Culture String File * Country Code: es-DO * Name: Spanish (Dominican Republic) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["es-DO"] = { "name": "es-DO", "englishName": "Spanish (Dominican Republic)", "nativeName": "Español (República Dominicana)", "Sunday": "domingo", "Monday": "lunes", "Tuesday": "martes", "Wednesday": "miércoles", "Thursday": "jueves", "Friday": "viernes", "Saturday": "sábado", "Sun": "dom", "Mon": "lun", "Tue": "mar", "Wed": "mié", "Thu": "jue", "Fri": "vie", "Sat": "sáb", "Su": "do", "Mo": "lu", "Tu": "ma", "We": "mi", "Th": "ju", "Fr": "vi", "Sa": "sá", "S_Sun_Initial": "d", "M_Mon_Initial": "l", "T_Tue_Initial": "m", "W_Wed_Initial": "m", "T_Thu_Initial": "j", "F_Fri_Initial": "v", "S_Sat_Initial": "s", "January": "enero", "February": "febrero", "March": "marzo", "April": "abril", "May": "mayo", "June": "junio", "July": "julio", "August": "agosto", "September": "septiembre", "October": "octubre", "November": "noviembre", "December": "diciembre", "Jan_Abbr": "ene", "Feb_Abbr": "feb", "Mar_Abbr": "mar", "Apr_Abbr": "abr", "May_Abbr": "may", "Jun_Abbr": "jun", "Jul_Abbr": "jul", "Aug_Abbr": "ago", "Sep_Abbr": "sep", "Oct_Abbr": "oct", "Nov_Abbr": "nov", "Dec_Abbr": "dic", "AM": "a.m.", "PM": "p.m.", "firstDayOfWeek": 0, "twoDigitYearMax": 2029, "mdy": "dmy", "M/d/yyyy": "dd/MM/yyyy", "dddd, MMMM dd, yyyy": "dddd, dd' de 'MMMM' de 'yyyy", "h:mm tt": "hh:mm tt", "h:mm:ss tt": "hh:mm:ss tt", "dddd, MMMM dd, yyyy h:mm:ss tt": "dddd, dd' de 'MMMM' de 'yyyy hh:mm:ss tt", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "dd MMMM", "MMMM, yyyy": "MMMM' de 'yyyy", "/jan(uary)?/": "ene(ro)?", "/feb(ruary)?/": "feb(rero)?", "/mar(ch)?/": "mar(zo)?", "/apr(il)?/": "abr(il)?", "/may/": "may(o)?", "/jun(e)?/": "jun(io)?", "/jul(y)?/": "jul(io)?", "/aug(ust)?/": "ago(sto)?", "/sep(t(ember)?)?/": "sep(tiembre)?", "/oct(ober)?/": "oct(ubre)?", "/nov(ember)?/": "nov(iembre)?", "/dec(ember)?/": "dic(iembre)?", "/^su(n(day)?)?/": "^do(m(ingo)?)?", "/^mo(n(day)?)?/": "^lu(n(es)?)?", "/^tu(e(s(day)?)?)?/": "^ma(r(tes)?)?", "/^we(d(nesday)?)?/": "^mi(é(rcoles)?)?", "/^th(u(r(s(day)?)?)?)?/": "^ju(e(ves)?)?", "/^fr(i(day)?)?/": "^vi(e(rnes)?)?", "/^sa(t(urday)?)?/": "^sá(b(ado)?)?", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "es-DO"; ================================================ FILE: build/i18n/es-EC.js ================================================ /* * DateJS Culture String File * Country Code: es-EC * Name: Spanish (Ecuador) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["es-EC"] = { "name": "es-EC", "englishName": "Spanish (Ecuador)", "nativeName": "Español (Ecuador)", "Sunday": "domingo", "Monday": "lunes", "Tuesday": "martes", "Wednesday": "miércoles", "Thursday": "jueves", "Friday": "viernes", "Saturday": "sábado", "Sun": "dom", "Mon": "lun", "Tue": "mar", "Wed": "mié", "Thu": "jue", "Fri": "vie", "Sat": "sáb", "Su": "do", "Mo": "lu", "Tu": "ma", "We": "mi", "Th": "ju", "Fr": "vi", "Sa": "sá", "S_Sun_Initial": "d", "M_Mon_Initial": "l", "T_Tue_Initial": "m", "W_Wed_Initial": "m", "T_Thu_Initial": "j", "F_Fri_Initial": "v", "S_Sat_Initial": "s", "January": "enero", "February": "febrero", "March": "marzo", "April": "abril", "May": "mayo", "June": "junio", "July": "julio", "August": "agosto", "September": "septiembre", "October": "octubre", "November": "noviembre", "December": "diciembre", "Jan_Abbr": "ene", "Feb_Abbr": "feb", "Mar_Abbr": "mar", "Apr_Abbr": "abr", "May_Abbr": "may", "Jun_Abbr": "jun", "Jul_Abbr": "jul", "Aug_Abbr": "ago", "Sep_Abbr": "sep", "Oct_Abbr": "oct", "Nov_Abbr": "nov", "Dec_Abbr": "dic", "AM": "", "PM": "", "firstDayOfWeek": 0, "twoDigitYearMax": 2029, "mdy": "dmy", "M/d/yyyy": "dd/MM/yyyy", "dddd, MMMM dd, yyyy": "dddd, dd' de 'MMMM' de 'yyyy", "h:mm tt": "H:mm", "h:mm:ss tt": "H:mm:ss", "dddd, MMMM dd, yyyy h:mm:ss tt": "dddd, dd' de 'MMMM' de 'yyyy H:mm:ss", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "dd MMMM", "MMMM, yyyy": "MMMM' de 'yyyy", "/jan(uary)?/": "ene(ro)?", "/feb(ruary)?/": "feb(rero)?", "/mar(ch)?/": "mar(zo)?", "/apr(il)?/": "abr(il)?", "/may/": "may(o)?", "/jun(e)?/": "jun(io)?", "/jul(y)?/": "jul(io)?", "/aug(ust)?/": "ago(sto)?", "/sep(t(ember)?)?/": "sep(tiembre)?", "/oct(ober)?/": "oct(ubre)?", "/nov(ember)?/": "nov(iembre)?", "/dec(ember)?/": "dic(iembre)?", "/^su(n(day)?)?/": "^do(m(ingo)?)?", "/^mo(n(day)?)?/": "^lu(n(es)?)?", "/^tu(e(s(day)?)?)?/": "^ma(r(tes)?)?", "/^we(d(nesday)?)?/": "^mi(é(rcoles)?)?", "/^th(u(r(s(day)?)?)?)?/": "^ju(e(ves)?)?", "/^fr(i(day)?)?/": "^vi(e(rnes)?)?", "/^sa(t(urday)?)?/": "^sá(b(ado)?)?", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "es-EC"; ================================================ FILE: build/i18n/es-ES.js ================================================ /* * DateJS Culture String File * Country Code: es-ES * Name: Spanish (Spain) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["es-ES"] = { "name": "es-ES", "englishName": "Spanish (Spain)", "nativeName": "español (España)", "Sunday": "domingo", "Monday": "lunes", "Tuesday": "martes", "Wednesday": "miércoles", "Thursday": "jueves", "Friday": "viernes", "Saturday": "sábado", "Sun": "dom", "Mon": "lun", "Tue": "mar", "Wed": "mié", "Thu": "jue", "Fri": "vie", "Sat": "sáb", "Su": "do", "Mo": "lu", "Tu": "ma", "We": "mi", "Th": "ju", "Fr": "vi", "Sa": "sá", "S_Sun_Initial": "d", "M_Mon_Initial": "l", "T_Tue_Initial": "m", "W_Wed_Initial": "m", "T_Thu_Initial": "j", "F_Fri_Initial": "v", "S_Sat_Initial": "s", "January": "enero", "February": "febrero", "March": "marzo", "April": "abril", "May": "mayo", "June": "junio", "July": "julio", "August": "agosto", "September": "septiembre", "October": "octubre", "November": "noviembre", "December": "diciembre", "Jan_Abbr": "ene", "Feb_Abbr": "feb", "Mar_Abbr": "mar", "Apr_Abbr": "abr", "May_Abbr": "may", "Jun_Abbr": "jun", "Jul_Abbr": "jul", "Aug_Abbr": "ago", "Sep_Abbr": "sep", "Oct_Abbr": "oct", "Nov_Abbr": "nov", "Dec_Abbr": "dic", "AM": "", "PM": "", "firstDayOfWeek": 1, "twoDigitYearMax": 2029, "mdy": "dmy", "M/d/yyyy": "dd/MM/yyyy", "dddd, MMMM dd, yyyy": "dddd, dd' de 'MMMM' de 'yyyy", "h:mm tt": "H:mm", "h:mm:ss tt": "H:mm:ss", "dddd, MMMM dd, yyyy h:mm:ss tt": "dddd, dd' de 'MMMM' de 'yyyy H:mm:ss", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "dd MMMM", "MMMM, yyyy": "MMMM' de 'yyyy", "/jan(uary)?/": "ene(ro)?", "/feb(ruary)?/": "feb(rero)?", "/mar(ch)?/": "mar(zo)?", "/apr(il)?/": "abr(il)?", "/may/": "may(o)?", "/jun(e)?/": "jun(io)?", "/jul(y)?/": "jul(io)?", "/aug(ust)?/": "ago(sto)?", "/sep(t(ember)?)?/": "sep(tiembre)?", "/oct(ober)?/": "oct(ubre)?", "/nov(ember)?/": "nov(iembre)?", "/dec(ember)?/": "dic(iembre)?", "/^su(n(day)?)?/": "^do(m(ingo)?)?", "/^mo(n(day)?)?/": "^lu(n(es)?)?", "/^tu(e(s(day)?)?)?/": "^ma(r(tes)?)?", "/^we(d(nesday)?)?/": "^mi(é(rcoles)?)?", "/^th(u(r(s(day)?)?)?)?/": "^ju(e(ves)?)?", "/^fr(i(day)?)?/": "^vi(e(rnes)?)?", "/^sa(t(urday)?)?/": "^sá(b(ado)?)?", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "es-ES"; ================================================ FILE: build/i18n/es-GT.js ================================================ /* * DateJS Culture String File * Country Code: es-GT * Name: Spanish (Guatemala) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["es-GT"] = { "name": "es-GT", "englishName": "Spanish (Guatemala)", "nativeName": "Español (Guatemala)", "Sunday": "domingo", "Monday": "lunes", "Tuesday": "martes", "Wednesday": "miércoles", "Thursday": "jueves", "Friday": "viernes", "Saturday": "sábado", "Sun": "dom", "Mon": "lun", "Tue": "mar", "Wed": "mié", "Thu": "jue", "Fri": "vie", "Sat": "sáb", "Su": "do", "Mo": "lu", "Tu": "ma", "We": "mi", "Th": "ju", "Fr": "vi", "Sa": "sá", "S_Sun_Initial": "d", "M_Mon_Initial": "l", "T_Tue_Initial": "m", "W_Wed_Initial": "m", "T_Thu_Initial": "j", "F_Fri_Initial": "v", "S_Sat_Initial": "s", "January": "enero", "February": "febrero", "March": "marzo", "April": "abril", "May": "mayo", "June": "junio", "July": "julio", "August": "agosto", "September": "septiembre", "October": "octubre", "November": "noviembre", "December": "diciembre", "Jan_Abbr": "ene", "Feb_Abbr": "feb", "Mar_Abbr": "mar", "Apr_Abbr": "abr", "May_Abbr": "may", "Jun_Abbr": "jun", "Jul_Abbr": "jul", "Aug_Abbr": "ago", "Sep_Abbr": "sep", "Oct_Abbr": "oct", "Nov_Abbr": "nov", "Dec_Abbr": "dic", "AM": "a.m.", "PM": "p.m.", "firstDayOfWeek": 0, "twoDigitYearMax": 2029, "mdy": "dmy", "M/d/yyyy": "dd/MM/yyyy", "dddd, MMMM dd, yyyy": "dddd, dd' de 'MMMM' de 'yyyy", "h:mm tt": "hh:mm tt", "h:mm:ss tt": "hh:mm:ss tt", "dddd, MMMM dd, yyyy h:mm:ss tt": "dddd, dd' de 'MMMM' de 'yyyy hh:mm:ss tt", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "dd MMMM", "MMMM, yyyy": "MMMM' de 'yyyy", "/jan(uary)?/": "ene(ro)?", "/feb(ruary)?/": "feb(rero)?", "/mar(ch)?/": "mar(zo)?", "/apr(il)?/": "abr(il)?", "/may/": "may(o)?", "/jun(e)?/": "jun(io)?", "/jul(y)?/": "jul(io)?", "/aug(ust)?/": "ago(sto)?", "/sep(t(ember)?)?/": "sep(tiembre)?", "/oct(ober)?/": "oct(ubre)?", "/nov(ember)?/": "nov(iembre)?", "/dec(ember)?/": "dic(iembre)?", "/^su(n(day)?)?/": "^do(m(ingo)?)?", "/^mo(n(day)?)?/": "^lu(n(es)?)?", "/^tu(e(s(day)?)?)?/": "^ma(r(tes)?)?", "/^we(d(nesday)?)?/": "^mi(é(rcoles)?)?", "/^th(u(r(s(day)?)?)?)?/": "^ju(e(ves)?)?", "/^fr(i(day)?)?/": "^vi(e(rnes)?)?", "/^sa(t(urday)?)?/": "^sá(b(ado)?)?", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "es-GT"; ================================================ FILE: build/i18n/es-HN.js ================================================ /* * DateJS Culture String File * Country Code: es-HN * Name: Spanish (Honduras) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["es-HN"] = { "name": "es-HN", "englishName": "Spanish (Honduras)", "nativeName": "Español (Honduras)", "Sunday": "domingo", "Monday": "lunes", "Tuesday": "martes", "Wednesday": "miércoles", "Thursday": "jueves", "Friday": "viernes", "Saturday": "sábado", "Sun": "dom", "Mon": "lun", "Tue": "mar", "Wed": "mié", "Thu": "jue", "Fri": "vie", "Sat": "sáb", "Su": "do", "Mo": "lu", "Tu": "ma", "We": "mi", "Th": "ju", "Fr": "vi", "Sa": "sá", "S_Sun_Initial": "d", "M_Mon_Initial": "l", "T_Tue_Initial": "m", "W_Wed_Initial": "m", "T_Thu_Initial": "j", "F_Fri_Initial": "v", "S_Sat_Initial": "s", "January": "enero", "February": "febrero", "March": "marzo", "April": "abril", "May": "mayo", "June": "junio", "July": "julio", "August": "agosto", "September": "septiembre", "October": "octubre", "November": "noviembre", "December": "diciembre", "Jan_Abbr": "ene", "Feb_Abbr": "feb", "Mar_Abbr": "mar", "Apr_Abbr": "abr", "May_Abbr": "may", "Jun_Abbr": "jun", "Jul_Abbr": "jul", "Aug_Abbr": "ago", "Sep_Abbr": "sep", "Oct_Abbr": "oct", "Nov_Abbr": "nov", "Dec_Abbr": "dic", "AM": "a.m.", "PM": "p.m.", "firstDayOfWeek": 0, "twoDigitYearMax": 2029, "mdy": "dmy", "M/d/yyyy": "dd/MM/yyyy", "dddd, MMMM dd, yyyy": "dddd, dd' de 'MMMM' de 'yyyy", "h:mm tt": "hh:mm tt", "h:mm:ss tt": "hh:mm:ss tt", "dddd, MMMM dd, yyyy h:mm:ss tt": "dddd, dd' de 'MMMM' de 'yyyy hh:mm:ss tt", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "dd MMMM", "MMMM, yyyy": "MMMM' de 'yyyy", "/jan(uary)?/": "ene(ro)?", "/feb(ruary)?/": "feb(rero)?", "/mar(ch)?/": "mar(zo)?", "/apr(il)?/": "abr(il)?", "/may/": "may(o)?", "/jun(e)?/": "jun(io)?", "/jul(y)?/": "jul(io)?", "/aug(ust)?/": "ago(sto)?", "/sep(t(ember)?)?/": "sep(tiembre)?", "/oct(ober)?/": "oct(ubre)?", "/nov(ember)?/": "nov(iembre)?", "/dec(ember)?/": "dic(iembre)?", "/^su(n(day)?)?/": "^do(m(ingo)?)?", "/^mo(n(day)?)?/": "^lu(n(es)?)?", "/^tu(e(s(day)?)?)?/": "^ma(r(tes)?)?", "/^we(d(nesday)?)?/": "^mi(é(rcoles)?)?", "/^th(u(r(s(day)?)?)?)?/": "^ju(e(ves)?)?", "/^fr(i(day)?)?/": "^vi(e(rnes)?)?", "/^sa(t(urday)?)?/": "^sá(b(ado)?)?", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "es-HN"; ================================================ FILE: build/i18n/es-MX.js ================================================ /* * DateJS Culture String File * Country Code: es-MX * Name: Spanish (Mexico) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["es-MX"] = { "name": "es-MX", "englishName": "Spanish (Mexico)", "nativeName": "Español (México)", "Sunday": "domingo", "Monday": "lunes", "Tuesday": "martes", "Wednesday": "miércoles", "Thursday": "jueves", "Friday": "viernes", "Saturday": "sábado", "Sun": "dom", "Mon": "lun", "Tue": "mar", "Wed": "mié", "Thu": "jue", "Fri": "vie", "Sat": "sáb", "Su": "do", "Mo": "lu", "Tu": "ma", "We": "mi", "Th": "ju", "Fr": "vi", "Sa": "sá", "S_Sun_Initial": "d", "M_Mon_Initial": "l", "T_Tue_Initial": "m", "W_Wed_Initial": "m", "T_Thu_Initial": "j", "F_Fri_Initial": "v", "S_Sat_Initial": "s", "January": "enero", "February": "febrero", "March": "marzo", "April": "abril", "May": "mayo", "June": "junio", "July": "julio", "August": "agosto", "September": "septiembre", "October": "octubre", "November": "noviembre", "December": "diciembre", "Jan_Abbr": "ene", "Feb_Abbr": "feb", "Mar_Abbr": "mar", "Apr_Abbr": "abr", "May_Abbr": "may", "Jun_Abbr": "jun", "Jul_Abbr": "jul", "Aug_Abbr": "ago", "Sep_Abbr": "sep", "Oct_Abbr": "oct", "Nov_Abbr": "nov", "Dec_Abbr": "dic", "AM": "a.m.", "PM": "p.m.", "firstDayOfWeek": 0, "twoDigitYearMax": 2029, "mdy": "dmy", "M/d/yyyy": "dd/MM/yyyy", "dddd, MMMM dd, yyyy": "dddd, dd' de 'MMMM' de 'yyyy", "h:mm tt": "hh:mm tt", "h:mm:ss tt": "hh:mm:ss tt", "dddd, MMMM dd, yyyy h:mm:ss tt": "dddd, dd' de 'MMMM' de 'yyyy hh:mm:ss tt", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "dd MMMM", "MMMM, yyyy": "MMMM' de 'yyyy", "/jan(uary)?/": "ene(ro)?", "/feb(ruary)?/": "feb(rero)?", "/mar(ch)?/": "mar(zo)?", "/apr(il)?/": "abr(il)?", "/may/": "may(o)?", "/jun(e)?/": "jun(io)?", "/jul(y)?/": "jul(io)?", "/aug(ust)?/": "ago(sto)?", "/sep(t(ember)?)?/": "sep(tiembre)?", "/oct(ober)?/": "oct(ubre)?", "/nov(ember)?/": "nov(iembre)?", "/dec(ember)?/": "dic(iembre)?", "/^su(n(day)?)?/": "^do(m(ingo)?)?", "/^mo(n(day)?)?/": "^lu(n(es)?)?", "/^tu(e(s(day)?)?)?/": "^ma(r(tes)?)?", "/^we(d(nesday)?)?/": "^mi(é(rcoles)?)?", "/^th(u(r(s(day)?)?)?)?/": "^ju(e(ves)?)?", "/^fr(i(day)?)?/": "^vi(e(rnes)?)?", "/^sa(t(urday)?)?/": "^sá(b(ado)?)?", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "es-MX"; ================================================ FILE: build/i18n/es-NI.js ================================================ /* * DateJS Culture String File * Country Code: es-NI * Name: Spanish (Nicaragua) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["es-NI"] = { "name": "es-NI", "englishName": "Spanish (Nicaragua)", "nativeName": "Español (Nicaragua)", "Sunday": "domingo", "Monday": "lunes", "Tuesday": "martes", "Wednesday": "miércoles", "Thursday": "jueves", "Friday": "viernes", "Saturday": "sábado", "Sun": "dom", "Mon": "lun", "Tue": "mar", "Wed": "mié", "Thu": "jue", "Fri": "vie", "Sat": "sáb", "Su": "do", "Mo": "lu", "Tu": "ma", "We": "mi", "Th": "ju", "Fr": "vi", "Sa": "sá", "S_Sun_Initial": "d", "M_Mon_Initial": "l", "T_Tue_Initial": "m", "W_Wed_Initial": "m", "T_Thu_Initial": "j", "F_Fri_Initial": "v", "S_Sat_Initial": "s", "January": "enero", "February": "febrero", "March": "marzo", "April": "abril", "May": "mayo", "June": "junio", "July": "julio", "August": "agosto", "September": "septiembre", "October": "octubre", "November": "noviembre", "December": "diciembre", "Jan_Abbr": "ene", "Feb_Abbr": "feb", "Mar_Abbr": "mar", "Apr_Abbr": "abr", "May_Abbr": "may", "Jun_Abbr": "jun", "Jul_Abbr": "jul", "Aug_Abbr": "ago", "Sep_Abbr": "sep", "Oct_Abbr": "oct", "Nov_Abbr": "nov", "Dec_Abbr": "dic", "AM": "a.m.", "PM": "p.m.", "firstDayOfWeek": 0, "twoDigitYearMax": 2029, "mdy": "dmy", "M/d/yyyy": "dd/MM/yyyy", "dddd, MMMM dd, yyyy": "dddd, dd' de 'MMMM' de 'yyyy", "h:mm tt": "hh:mm tt", "h:mm:ss tt": "hh:mm:ss tt", "dddd, MMMM dd, yyyy h:mm:ss tt": "dddd, dd' de 'MMMM' de 'yyyy hh:mm:ss tt", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "dd MMMM", "MMMM, yyyy": "MMMM' de 'yyyy", "/jan(uary)?/": "ene(ro)?", "/feb(ruary)?/": "feb(rero)?", "/mar(ch)?/": "mar(zo)?", "/apr(il)?/": "abr(il)?", "/may/": "may(o)?", "/jun(e)?/": "jun(io)?", "/jul(y)?/": "jul(io)?", "/aug(ust)?/": "ago(sto)?", "/sep(t(ember)?)?/": "sep(tiembre)?", "/oct(ober)?/": "oct(ubre)?", "/nov(ember)?/": "nov(iembre)?", "/dec(ember)?/": "dic(iembre)?", "/^su(n(day)?)?/": "^do(m(ingo)?)?", "/^mo(n(day)?)?/": "^lu(n(es)?)?", "/^tu(e(s(day)?)?)?/": "^ma(r(tes)?)?", "/^we(d(nesday)?)?/": "^mi(é(rcoles)?)?", "/^th(u(r(s(day)?)?)?)?/": "^ju(e(ves)?)?", "/^fr(i(day)?)?/": "^vi(e(rnes)?)?", "/^sa(t(urday)?)?/": "^sá(b(ado)?)?", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "es-NI"; ================================================ FILE: build/i18n/es-PA.js ================================================ /* * DateJS Culture String File * Country Code: es-PA * Name: Spanish (Panama) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["es-PA"] = { "name": "es-PA", "englishName": "Spanish (Panama)", "nativeName": "Español (Panamá)", "Sunday": "domingo", "Monday": "lunes", "Tuesday": "martes", "Wednesday": "miércoles", "Thursday": "jueves", "Friday": "viernes", "Saturday": "sábado", "Sun": "dom", "Mon": "lun", "Tue": "mar", "Wed": "mié", "Thu": "jue", "Fri": "vie", "Sat": "sáb", "Su": "do", "Mo": "lu", "Tu": "ma", "We": "mi", "Th": "ju", "Fr": "vi", "Sa": "sá", "S_Sun_Initial": "d", "M_Mon_Initial": "l", "T_Tue_Initial": "m", "W_Wed_Initial": "m", "T_Thu_Initial": "j", "F_Fri_Initial": "v", "S_Sat_Initial": "s", "January": "enero", "February": "febrero", "March": "marzo", "April": "abril", "May": "mayo", "June": "junio", "July": "julio", "August": "agosto", "September": "septiembre", "October": "octubre", "November": "noviembre", "December": "diciembre", "Jan_Abbr": "ene", "Feb_Abbr": "feb", "Mar_Abbr": "mar", "Apr_Abbr": "abr", "May_Abbr": "may", "Jun_Abbr": "jun", "Jul_Abbr": "jul", "Aug_Abbr": "ago", "Sep_Abbr": "sep", "Oct_Abbr": "oct", "Nov_Abbr": "nov", "Dec_Abbr": "dic", "AM": "a.m.", "PM": "p.m.", "firstDayOfWeek": 0, "twoDigitYearMax": 2029, "mdy": "mdy", "M/d/yyyy": "MM/dd/yyyy", "dddd, MMMM dd, yyyy": "dddd, dd' de 'MMMM' de 'yyyy", "h:mm tt": "hh:mm tt", "h:mm:ss tt": "hh:mm:ss tt", "dddd, MMMM dd, yyyy h:mm:ss tt": "dddd, dd' de 'MMMM' de 'yyyy hh:mm:ss tt", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "dd MMMM", "MMMM, yyyy": "MMMM' de 'yyyy", "/jan(uary)?/": "ene(ro)?", "/feb(ruary)?/": "feb(rero)?", "/mar(ch)?/": "mar(zo)?", "/apr(il)?/": "abr(il)?", "/may/": "may(o)?", "/jun(e)?/": "jun(io)?", "/jul(y)?/": "jul(io)?", "/aug(ust)?/": "ago(sto)?", "/sep(t(ember)?)?/": "sep(tiembre)?", "/oct(ober)?/": "oct(ubre)?", "/nov(ember)?/": "nov(iembre)?", "/dec(ember)?/": "dic(iembre)?", "/^su(n(day)?)?/": "^do(m(ingo)?)?", "/^mo(n(day)?)?/": "^lu(n(es)?)?", "/^tu(e(s(day)?)?)?/": "^ma(r(tes)?)?", "/^we(d(nesday)?)?/": "^mi(é(rcoles)?)?", "/^th(u(r(s(day)?)?)?)?/": "^ju(e(ves)?)?", "/^fr(i(day)?)?/": "^vi(e(rnes)?)?", "/^sa(t(urday)?)?/": "^sá(b(ado)?)?", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "es-PA"; ================================================ FILE: build/i18n/es-PE.js ================================================ /* * DateJS Culture String File * Country Code: es-PE * Name: Spanish (Peru) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["es-PE"] = { "name": "es-PE", "englishName": "Spanish (Peru)", "nativeName": "Español (Perú)", "Sunday": "domingo", "Monday": "lunes", "Tuesday": "martes", "Wednesday": "miércoles", "Thursday": "jueves", "Friday": "viernes", "Saturday": "sábado", "Sun": "dom", "Mon": "lun", "Tue": "mar", "Wed": "mié", "Thu": "jue", "Fri": "vie", "Sat": "sáb", "Su": "do", "Mo": "lu", "Tu": "ma", "We": "mi", "Th": "ju", "Fr": "vi", "Sa": "sá", "S_Sun_Initial": "d", "M_Mon_Initial": "l", "T_Tue_Initial": "m", "W_Wed_Initial": "m", "T_Thu_Initial": "j", "F_Fri_Initial": "v", "S_Sat_Initial": "s", "January": "enero", "February": "febrero", "March": "marzo", "April": "abril", "May": "mayo", "June": "junio", "July": "julio", "August": "agosto", "September": "septiembre", "October": "octubre", "November": "noviembre", "December": "diciembre", "Jan_Abbr": "ene", "Feb_Abbr": "feb", "Mar_Abbr": "mar", "Apr_Abbr": "abr", "May_Abbr": "may", "Jun_Abbr": "jun", "Jul_Abbr": "jul", "Aug_Abbr": "ago", "Sep_Abbr": "sep", "Oct_Abbr": "oct", "Nov_Abbr": "nov", "Dec_Abbr": "dic", "AM": "a.m.", "PM": "p.m.", "firstDayOfWeek": 0, "twoDigitYearMax": 2029, "mdy": "dmy", "M/d/yyyy": "dd/MM/yyyy", "dddd, MMMM dd, yyyy": "dddd, dd' de 'MMMM' de 'yyyy", "h:mm tt": "hh:mm tt", "h:mm:ss tt": "hh:mm:ss tt", "dddd, MMMM dd, yyyy h:mm:ss tt": "dddd, dd' de 'MMMM' de 'yyyy hh:mm:ss tt", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "dd MMMM", "MMMM, yyyy": "MMMM' de 'yyyy", "/jan(uary)?/": "ene(ro)?", "/feb(ruary)?/": "feb(rero)?", "/mar(ch)?/": "mar(zo)?", "/apr(il)?/": "abr(il)?", "/may/": "may(o)?", "/jun(e)?/": "jun(io)?", "/jul(y)?/": "jul(io)?", "/aug(ust)?/": "ago(sto)?", "/sep(t(ember)?)?/": "sep(tiembre)?", "/oct(ober)?/": "oct(ubre)?", "/nov(ember)?/": "nov(iembre)?", "/dec(ember)?/": "dic(iembre)?", "/^su(n(day)?)?/": "^do(m(ingo)?)?", "/^mo(n(day)?)?/": "^lu(n(es)?)?", "/^tu(e(s(day)?)?)?/": "^ma(r(tes)?)?", "/^we(d(nesday)?)?/": "^mi(é(rcoles)?)?", "/^th(u(r(s(day)?)?)?)?/": "^ju(e(ves)?)?", "/^fr(i(day)?)?/": "^vi(e(rnes)?)?", "/^sa(t(urday)?)?/": "^sá(b(ado)?)?", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "es-PE"; ================================================ FILE: build/i18n/es-PR.js ================================================ /* * DateJS Culture String File * Country Code: es-PR * Name: Spanish (Puerto Rico) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["es-PR"] = { "name": "es-PR", "englishName": "Spanish (Puerto Rico)", "nativeName": "Español (Puerto Rico)", "Sunday": "domingo", "Monday": "lunes", "Tuesday": "martes", "Wednesday": "miércoles", "Thursday": "jueves", "Friday": "viernes", "Saturday": "sábado", "Sun": "dom", "Mon": "lun", "Tue": "mar", "Wed": "mié", "Thu": "jue", "Fri": "vie", "Sat": "sáb", "Su": "do", "Mo": "lu", "Tu": "ma", "We": "mi", "Th": "ju", "Fr": "vi", "Sa": "sá", "S_Sun_Initial": "d", "M_Mon_Initial": "l", "T_Tue_Initial": "m", "W_Wed_Initial": "m", "T_Thu_Initial": "j", "F_Fri_Initial": "v", "S_Sat_Initial": "s", "January": "enero", "February": "febrero", "March": "marzo", "April": "abril", "May": "mayo", "June": "junio", "July": "julio", "August": "agosto", "September": "septiembre", "October": "octubre", "November": "noviembre", "December": "diciembre", "Jan_Abbr": "ene", "Feb_Abbr": "feb", "Mar_Abbr": "mar", "Apr_Abbr": "abr", "May_Abbr": "may", "Jun_Abbr": "jun", "Jul_Abbr": "jul", "Aug_Abbr": "ago", "Sep_Abbr": "sep", "Oct_Abbr": "oct", "Nov_Abbr": "nov", "Dec_Abbr": "dic", "AM": "a.m.", "PM": "p.m.", "firstDayOfWeek": 0, "twoDigitYearMax": 2029, "mdy": "dmy", "M/d/yyyy": "dd/MM/yyyy", "dddd, MMMM dd, yyyy": "dddd, dd' de 'MMMM' de 'yyyy", "h:mm tt": "hh:mm tt", "h:mm:ss tt": "hh:mm:ss tt", "dddd, MMMM dd, yyyy h:mm:ss tt": "dddd, dd' de 'MMMM' de 'yyyy hh:mm:ss tt", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "dd MMMM", "MMMM, yyyy": "MMMM' de 'yyyy", "/jan(uary)?/": "ene(ro)?", "/feb(ruary)?/": "feb(rero)?", "/mar(ch)?/": "mar(zo)?", "/apr(il)?/": "abr(il)?", "/may/": "may(o)?", "/jun(e)?/": "jun(io)?", "/jul(y)?/": "jul(io)?", "/aug(ust)?/": "ago(sto)?", "/sep(t(ember)?)?/": "sep(tiembre)?", "/oct(ober)?/": "oct(ubre)?", "/nov(ember)?/": "nov(iembre)?", "/dec(ember)?/": "dic(iembre)?", "/^su(n(day)?)?/": "^do(m(ingo)?)?", "/^mo(n(day)?)?/": "^lu(n(es)?)?", "/^tu(e(s(day)?)?)?/": "^ma(r(tes)?)?", "/^we(d(nesday)?)?/": "^mi(é(rcoles)?)?", "/^th(u(r(s(day)?)?)?)?/": "^ju(e(ves)?)?", "/^fr(i(day)?)?/": "^vi(e(rnes)?)?", "/^sa(t(urday)?)?/": "^sá(b(ado)?)?", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "es-PR"; ================================================ FILE: build/i18n/es-PY.js ================================================ /* * DateJS Culture String File * Country Code: es-PY * Name: Spanish (Paraguay) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["es-PY"] = { "name": "es-PY", "englishName": "Spanish (Paraguay)", "nativeName": "Español (Paraguay)", "Sunday": "domingo", "Monday": "lunes", "Tuesday": "martes", "Wednesday": "miércoles", "Thursday": "jueves", "Friday": "viernes", "Saturday": "sábado", "Sun": "dom", "Mon": "lun", "Tue": "mar", "Wed": "mié", "Thu": "jue", "Fri": "vie", "Sat": "sáb", "Su": "do", "Mo": "lu", "Tu": "ma", "We": "mi", "Th": "ju", "Fr": "vi", "Sa": "sá", "S_Sun_Initial": "d", "M_Mon_Initial": "l", "T_Tue_Initial": "m", "W_Wed_Initial": "m", "T_Thu_Initial": "j", "F_Fri_Initial": "v", "S_Sat_Initial": "s", "January": "enero", "February": "febrero", "March": "marzo", "April": "abril", "May": "mayo", "June": "junio", "July": "julio", "August": "agosto", "September": "septiembre", "October": "octubre", "November": "noviembre", "December": "diciembre", "Jan_Abbr": "ene", "Feb_Abbr": "feb", "Mar_Abbr": "mar", "Apr_Abbr": "abr", "May_Abbr": "may", "Jun_Abbr": "jun", "Jul_Abbr": "jul", "Aug_Abbr": "ago", "Sep_Abbr": "sep", "Oct_Abbr": "oct", "Nov_Abbr": "nov", "Dec_Abbr": "dic", "AM": "a.m.", "PM": "p.m.", "firstDayOfWeek": 1, "twoDigitYearMax": 2029, "mdy": "dmy", "M/d/yyyy": "dd/MM/yyyy", "dddd, MMMM dd, yyyy": "dddd, dd' de 'MMMM' de 'yyyy", "h:mm tt": "hh:mm tt", "h:mm:ss tt": "hh:mm:ss tt", "dddd, MMMM dd, yyyy h:mm:ss tt": "dddd, dd' de 'MMMM' de 'yyyy hh:mm:ss tt", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "dd MMMM", "MMMM, yyyy": "MMMM' de 'yyyy", "/jan(uary)?/": "ene(ro)?", "/feb(ruary)?/": "feb(rero)?", "/mar(ch)?/": "mar(zo)?", "/apr(il)?/": "abr(il)?", "/may/": "may(o)?", "/jun(e)?/": "jun(io)?", "/jul(y)?/": "jul(io)?", "/aug(ust)?/": "ago(sto)?", "/sep(t(ember)?)?/": "sep(tiembre)?", "/oct(ober)?/": "oct(ubre)?", "/nov(ember)?/": "nov(iembre)?", "/dec(ember)?/": "dic(iembre)?", "/^su(n(day)?)?/": "^do(m(ingo)?)?", "/^mo(n(day)?)?/": "^lu(n(es)?)?", "/^tu(e(s(day)?)?)?/": "^ma(r(tes)?)?", "/^we(d(nesday)?)?/": "^mi(é(rcoles)?)?", "/^th(u(r(s(day)?)?)?)?/": "^ju(e(ves)?)?", "/^fr(i(day)?)?/": "^vi(e(rnes)?)?", "/^sa(t(urday)?)?/": "^sá(b(ado)?)?", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "es-PY"; ================================================ FILE: build/i18n/es-SV.js ================================================ /* * DateJS Culture String File * Country Code: es-SV * Name: Spanish (El Salvador) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["es-SV"] = { "name": "es-SV", "englishName": "Spanish (El Salvador)", "nativeName": "Español (El Salvador)", "Sunday": "domingo", "Monday": "lunes", "Tuesday": "martes", "Wednesday": "miércoles", "Thursday": "jueves", "Friday": "viernes", "Saturday": "sábado", "Sun": "dom", "Mon": "lun", "Tue": "mar", "Wed": "mié", "Thu": "jue", "Fri": "vie", "Sat": "sáb", "Su": "do", "Mo": "lu", "Tu": "ma", "We": "mi", "Th": "ju", "Fr": "vi", "Sa": "sá", "S_Sun_Initial": "d", "M_Mon_Initial": "l", "T_Tue_Initial": "m", "W_Wed_Initial": "m", "T_Thu_Initial": "j", "F_Fri_Initial": "v", "S_Sat_Initial": "s", "January": "enero", "February": "febrero", "March": "marzo", "April": "abril", "May": "mayo", "June": "junio", "July": "julio", "August": "agosto", "September": "septiembre", "October": "octubre", "November": "noviembre", "December": "diciembre", "Jan_Abbr": "ene", "Feb_Abbr": "feb", "Mar_Abbr": "mar", "Apr_Abbr": "abr", "May_Abbr": "may", "Jun_Abbr": "jun", "Jul_Abbr": "jul", "Aug_Abbr": "ago", "Sep_Abbr": "sep", "Oct_Abbr": "oct", "Nov_Abbr": "nov", "Dec_Abbr": "dic", "AM": "a.m.", "PM": "p.m.", "firstDayOfWeek": 0, "twoDigitYearMax": 2029, "mdy": "dmy", "M/d/yyyy": "dd/MM/yyyy", "dddd, MMMM dd, yyyy": "dddd, dd' de 'MMMM' de 'yyyy", "h:mm tt": "hh:mm tt", "h:mm:ss tt": "hh:mm:ss tt", "dddd, MMMM dd, yyyy h:mm:ss tt": "dddd, dd' de 'MMMM' de 'yyyy hh:mm:ss tt", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "dd MMMM", "MMMM, yyyy": "MMMM' de 'yyyy", "/jan(uary)?/": "ene(ro)?", "/feb(ruary)?/": "feb(rero)?", "/mar(ch)?/": "mar(zo)?", "/apr(il)?/": "abr(il)?", "/may/": "may(o)?", "/jun(e)?/": "jun(io)?", "/jul(y)?/": "jul(io)?", "/aug(ust)?/": "ago(sto)?", "/sep(t(ember)?)?/": "sep(tiembre)?", "/oct(ober)?/": "oct(ubre)?", "/nov(ember)?/": "nov(iembre)?", "/dec(ember)?/": "dic(iembre)?", "/^su(n(day)?)?/": "^do(m(ingo)?)?", "/^mo(n(day)?)?/": "^lu(n(es)?)?", "/^tu(e(s(day)?)?)?/": "^ma(r(tes)?)?", "/^we(d(nesday)?)?/": "^mi(é(rcoles)?)?", "/^th(u(r(s(day)?)?)?)?/": "^ju(e(ves)?)?", "/^fr(i(day)?)?/": "^vi(e(rnes)?)?", "/^sa(t(urday)?)?/": "^sá(b(ado)?)?", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "es-SV"; ================================================ FILE: build/i18n/es-UY.js ================================================ /* * DateJS Culture String File * Country Code: es-UY * Name: Spanish (Uruguay) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["es-UY"] = { "name": "es-UY", "englishName": "Spanish (Uruguay)", "nativeName": "Español (Uruguay)", "Sunday": "domingo", "Monday": "lunes", "Tuesday": "martes", "Wednesday": "miércoles", "Thursday": "jueves", "Friday": "viernes", "Saturday": "sábado", "Sun": "dom", "Mon": "lun", "Tue": "mar", "Wed": "mié", "Thu": "jue", "Fri": "vie", "Sat": "sáb", "Su": "do", "Mo": "lu", "Tu": "ma", "We": "mi", "Th": "ju", "Fr": "vi", "Sa": "sá", "S_Sun_Initial": "d", "M_Mon_Initial": "l", "T_Tue_Initial": "m", "W_Wed_Initial": "m", "T_Thu_Initial": "j", "F_Fri_Initial": "v", "S_Sat_Initial": "s", "January": "enero", "February": "febrero", "March": "marzo", "April": "abril", "May": "mayo", "June": "junio", "July": "julio", "August": "agosto", "September": "septiembre", "October": "octubre", "November": "noviembre", "December": "diciembre", "Jan_Abbr": "ene", "Feb_Abbr": "feb", "Mar_Abbr": "mar", "Apr_Abbr": "abr", "May_Abbr": "may", "Jun_Abbr": "jun", "Jul_Abbr": "jul", "Aug_Abbr": "ago", "Sep_Abbr": "sep", "Oct_Abbr": "oct", "Nov_Abbr": "nov", "Dec_Abbr": "dic", "AM": "a.m.", "PM": "p.m.", "firstDayOfWeek": 1, "twoDigitYearMax": 2029, "mdy": "dmy", "M/d/yyyy": "dd/MM/yyyy", "dddd, MMMM dd, yyyy": "dddd, dd' de 'MMMM' de 'yyyy", "h:mm tt": "hh:mm tt", "h:mm:ss tt": "hh:mm:ss tt", "dddd, MMMM dd, yyyy h:mm:ss tt": "dddd, dd' de 'MMMM' de 'yyyy hh:mm:ss tt", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "dd MMMM", "MMMM, yyyy": "MMMM' de 'yyyy", "/jan(uary)?/": "ene(ro)?", "/feb(ruary)?/": "feb(rero)?", "/mar(ch)?/": "mar(zo)?", "/apr(il)?/": "abr(il)?", "/may/": "may(o)?", "/jun(e)?/": "jun(io)?", "/jul(y)?/": "jul(io)?", "/aug(ust)?/": "ago(sto)?", "/sep(t(ember)?)?/": "sep(tiembre)?", "/oct(ober)?/": "oct(ubre)?", "/nov(ember)?/": "nov(iembre)?", "/dec(ember)?/": "dic(iembre)?", "/^su(n(day)?)?/": "^do(m(ingo)?)?", "/^mo(n(day)?)?/": "^lu(n(es)?)?", "/^tu(e(s(day)?)?)?/": "^ma(r(tes)?)?", "/^we(d(nesday)?)?/": "^mi(é(rcoles)?)?", "/^th(u(r(s(day)?)?)?)?/": "^ju(e(ves)?)?", "/^fr(i(day)?)?/": "^vi(e(rnes)?)?", "/^sa(t(urday)?)?/": "^sá(b(ado)?)?", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "es-UY"; ================================================ FILE: build/i18n/es-VE.js ================================================ /* * DateJS Culture String File * Country Code: es-VE * Name: Spanish (Venezuela) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["es-VE"] = { "name": "es-VE", "englishName": "Spanish (Venezuela)", "nativeName": "Español (Republica Bolivariana de Venezuela)", "Sunday": "domingo", "Monday": "lunes", "Tuesday": "martes", "Wednesday": "miércoles", "Thursday": "jueves", "Friday": "viernes", "Saturday": "sábado", "Sun": "dom", "Mon": "lun", "Tue": "mar", "Wed": "mié", "Thu": "jue", "Fri": "vie", "Sat": "sáb", "Su": "do", "Mo": "lu", "Tu": "ma", "We": "mi", "Th": "ju", "Fr": "vi", "Sa": "sá", "S_Sun_Initial": "d", "M_Mon_Initial": "l", "T_Tue_Initial": "m", "W_Wed_Initial": "m", "T_Thu_Initial": "j", "F_Fri_Initial": "v", "S_Sat_Initial": "s", "January": "enero", "February": "febrero", "March": "marzo", "April": "abril", "May": "mayo", "June": "junio", "July": "julio", "August": "agosto", "September": "septiembre", "October": "octubre", "November": "noviembre", "December": "diciembre", "Jan_Abbr": "ene", "Feb_Abbr": "feb", "Mar_Abbr": "mar", "Apr_Abbr": "abr", "May_Abbr": "may", "Jun_Abbr": "jun", "Jul_Abbr": "jul", "Aug_Abbr": "ago", "Sep_Abbr": "sep", "Oct_Abbr": "oct", "Nov_Abbr": "nov", "Dec_Abbr": "dic", "AM": "a.m.", "PM": "p.m.", "firstDayOfWeek": 0, "twoDigitYearMax": 2029, "mdy": "dmy", "M/d/yyyy": "dd/MM/yyyy", "dddd, MMMM dd, yyyy": "dddd, dd' de 'MMMM' de 'yyyy", "h:mm tt": "hh:mm tt", "h:mm:ss tt": "hh:mm:ss tt", "dddd, MMMM dd, yyyy h:mm:ss tt": "dddd, dd' de 'MMMM' de 'yyyy hh:mm:ss tt", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "dd MMMM", "MMMM, yyyy": "MMMM' de 'yyyy", "/jan(uary)?/": "ene(ro)?", "/feb(ruary)?/": "feb(rero)?", "/mar(ch)?/": "mar(zo)?", "/apr(il)?/": "abr(il)?", "/may/": "may(o)?", "/jun(e)?/": "jun(io)?", "/jul(y)?/": "jul(io)?", "/aug(ust)?/": "ago(sto)?", "/sep(t(ember)?)?/": "sep(tiembre)?", "/oct(ober)?/": "oct(ubre)?", "/nov(ember)?/": "nov(iembre)?", "/dec(ember)?/": "dic(iembre)?", "/^su(n(day)?)?/": "^do(m(ingo)?)?", "/^mo(n(day)?)?/": "^lu(n(es)?)?", "/^tu(e(s(day)?)?)?/": "^ma(r(tes)?)?", "/^we(d(nesday)?)?/": "^mi(é(rcoles)?)?", "/^th(u(r(s(day)?)?)?)?/": "^ju(e(ves)?)?", "/^fr(i(day)?)?/": "^vi(e(rnes)?)?", "/^sa(t(urday)?)?/": "^sá(b(ado)?)?", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "es-VE"; ================================================ FILE: build/i18n/et-EE.js ================================================ /* * DateJS Culture String File * Country Code: et-EE * Name: Estonian (Estonia) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["et-EE"] = { "name": "et-EE", "englishName": "Estonian (Estonia)", "nativeName": "eesti (Eesti)", "Sunday": "pühapäev", "Monday": "esmaspäev", "Tuesday": "teisipäev", "Wednesday": "kolmapäev", "Thursday": "neljapäev", "Friday": "reede", "Saturday": "laupäev", "Sun": "P", "Mon": "E", "Tue": "T", "Wed": "K", "Thu": "N", "Fri": "R", "Sat": "L", "Su": "P", "Mo": "E", "Tu": "T", "We": "K", "Th": "N", "Fr": "R", "Sa": "L", "S_Sun_Initial": "P", "M_Mon_Initial": "E", "T_Tue_Initial": "T", "W_Wed_Initial": "K", "T_Thu_Initial": "N", "F_Fri_Initial": "R", "S_Sat_Initial": "L", "January": "jaanuar", "February": "veebruar", "March": "märts", "April": "aprill", "May": "mai", "June": "juuni", "July": "juuli", "August": "august", "September": "september", "October": "oktoober", "November": "november", "December": "detsember", "Jan_Abbr": "jaan", "Feb_Abbr": "veebr", "Mar_Abbr": "märts", "Apr_Abbr": "apr", "May_Abbr": "mai", "Jun_Abbr": "juuni", "Jul_Abbr": "juuli", "Aug_Abbr": "aug", "Sep_Abbr": "sept", "Oct_Abbr": "okt", "Nov_Abbr": "nov", "Dec_Abbr": "dets", "AM": "EL", "PM": "PL", "firstDayOfWeek": 1, "twoDigitYearMax": 2029, "mdy": "dmy", "M/d/yyyy": "d.MM.yyyy", "dddd, MMMM dd, yyyy": "d. MMMM yyyy'. a.'", "h:mm tt": "H:mm", "h:mm:ss tt": "H:mm:ss", "dddd, MMMM dd, yyyy h:mm:ss tt": "d. MMMM yyyy'. a.' H:mm:ss", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "d. MMMM", "MMMM, yyyy": "MMMM yyyy'. a.'", "/jan(uary)?/": "jaan(uar)?", "/feb(ruary)?/": "veebr(uar)?", "/mar(ch)?/": "märts", "/apr(il)?/": "apr(ill)?", "/may/": "mai", "/jun(e)?/": "juuni", "/jul(y)?/": "juuli", "/aug(ust)?/": "aug(ust)?", "/sep(t(ember)?)?/": "sep(t(ember)?)?", "/oct(ober)?/": "okt(oober)?", "/nov(ember)?/": "nov(ember)?", "/dec(ember)?/": "dets(ember)?", "/^su(n(day)?)?/": "^pühapäev", "/^mo(n(day)?)?/": "^esmaspäev", "/^tu(e(s(day)?)?)?/": "^teisipäev", "/^we(d(nesday)?)?/": "^kolmapäev", "/^th(u(r(s(day)?)?)?)?/": "^neljapäev", "/^fr(i(day)?)?/": "^reede", "/^sa(t(urday)?)?/": "^laupäev", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "et-EE"; ================================================ FILE: build/i18n/eu-ES.js ================================================ /* * DateJS Culture String File * Country Code: eu-ES * Name: Basque (Basque) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["eu-ES"] = { "name": "eu-ES", "englishName": "Basque (Basque)", "nativeName": "euskara (euskara)", "Sunday": "igandea", "Monday": "astelehena", "Tuesday": "asteartea", "Wednesday": "asteazkena", "Thursday": "osteguna", "Friday": "ostirala", "Saturday": "larunbata", "Sun": "ig.", "Mon": "al.", "Tue": "as.", "Wed": "az.", "Thu": "og.", "Fri": "or.", "Sat": "lr.", "Su": "ig", "Mo": "al", "Tu": "as", "We": "az", "Th": "og", "Fr": "or", "Sa": "lr", "S_Sun_Initial": "i", "M_Mon_Initial": "a", "T_Tue_Initial": "a", "W_Wed_Initial": "a", "T_Thu_Initial": "o", "F_Fri_Initial": "o", "S_Sat_Initial": "l", "January": "urtarrila", "February": "otsaila", "March": "martxoa", "April": "apirila", "May": "maiatza", "June": "ekaina", "July": "uztaila", "August": "abuztua", "September": "iraila", "October": "urria", "November": "azaroa", "December": "abendua", "Jan_Abbr": "urt.", "Feb_Abbr": "ots.", "Mar_Abbr": "mar.", "Apr_Abbr": "api.", "May_Abbr": "mai.", "Jun_Abbr": "eka.", "Jul_Abbr": "uzt.", "Aug_Abbr": "abu.", "Sep_Abbr": "ira.", "Oct_Abbr": "urr.", "Nov_Abbr": "aza.", "Dec_Abbr": "abe.", "AM": "", "PM": "", "firstDayOfWeek": 1, "twoDigitYearMax": 2029, "mdy": "ymd", "M/d/yyyy": "yyyy/MM/dd", "dddd, MMMM dd, yyyy": "dddd, yyyy.'eko' MMMM'k 'd", "h:mm tt": "HH:mm", "h:mm:ss tt": "HH:mm:ss", "dddd, MMMM dd, yyyy h:mm:ss tt": "dddd, yyyy.'eko' MMMM'k 'd HH:mm:ss", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "MMMM dd", "MMMM, yyyy": "yyyy.'eko' MMMM", "/jan(uary)?/": "urt(.(arrila)?)?", "/feb(ruary)?/": "ots(.(aila)?)?", "/mar(ch)?/": "mar(.(txoa)?)?", "/apr(il)?/": "api(.(rila)?)?", "/may/": "mai(.(atza)?)?", "/jun(e)?/": "eka(.(ina)?)?", "/jul(y)?/": "uzt(.(aila)?)?", "/aug(ust)?/": "abu(.(ztua)?)?", "/sep(t(ember)?)?/": "ira(.(ila)?)?", "/oct(ober)?/": "urr(.(ia)?)?", "/nov(ember)?/": "aza(.(roa)?)?", "/dec(ember)?/": "abe(.(ndua)?)?", "/^su(n(day)?)?/": "^ig((.(andea)?)?)?", "/^mo(n(day)?)?/": "^al((.(telehena)?)?)?", "/^tu(e(s(day)?)?)?/": "^as((.(teartea)?)?)?", "/^we(d(nesday)?)?/": "^az((.(teazkena)?)?)?", "/^th(u(r(s(day)?)?)?)?/": "^og((.(teguna)?)?)?", "/^fr(i(day)?)?/": "^or((.(tirala)?)?)?", "/^sa(t(urday)?)?/": "^lr((.(runbata)?)?)?", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "eu-ES"; ================================================ FILE: build/i18n/fa-IR.js ================================================ /* * DateJS Culture String File * Country Code: fa-IR * Name: Persian (Iran) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["fa-IR"] = { "name": "fa-IR", "englishName": "Persian (Iran)", "nativeName": "فارسى (ايران)", "Sunday": "Sunday", "Monday": "Monday", "Tuesday": "Tuesday", "Wednesday": "Wednesday", "Thursday": "Thursday", "Friday": "Friday", "Saturday": "Saturday", "Sun": "Sun", "Mon": "Mon", "Tue": "Tue", "Wed": "Wed", "Thu": "Thu", "Fri": "Fri", "Sat": "Sat", "Su": "Su", "Mo": "Mo", "Tu": "Tu", "We": "We", "Th": "Th", "Fr": "Fr", "Sa": "Sa", "S_Sun_Initial": "S", "M_Mon_Initial": "M", "T_Tue_Initial": "T", "W_Wed_Initial": "W", "T_Thu_Initial": "T", "F_Fri_Initial": "F", "S_Sat_Initial": "S", "January": "January", "February": "February", "March": "March", "April": "April", "May": "May", "June": "June", "July": "July", "August": "August", "September": "September", "October": "October", "November": "November", "December": "December", "Jan_Abbr": "Jan", "Feb_Abbr": "Feb", "Mar_Abbr": "Mar", "Apr_Abbr": "Apr", "May_Abbr": "May", "Jun_Abbr": "Jun", "Jul_Abbr": "Jul", "Aug_Abbr": "Aug", "Sep_Abbr": "Sep", "Oct_Abbr": "Oct", "Nov_Abbr": "Nov", "Dec_Abbr": "Dec", "AM": "ق.ظ", "PM": "ب.ظ", "firstDayOfWeek": 0, "twoDigitYearMax": 2029, "mdy": "mdy", "M/d/yyyy": "M/d/yyyy", "dddd, MMMM dd, yyyy": "dddd, MMMM dd, yyyy", "h:mm tt": "hh:mm tt", "h:mm:ss tt": "hh:mm:ss tt", "dddd, MMMM dd, yyyy h:mm:ss tt": "dddd, MMMM dd, yyyy hh:mm:ss tt", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "MMMM dd", "MMMM, yyyy": "MMMM, yyyy", "/jan(uary)?/": "jan(uary)?", "/feb(ruary)?/": "feb(ruary)?", "/mar(ch)?/": "mar(ch)?", "/apr(il)?/": "apr(il)?", "/may/": "may", "/jun(e)?/": "jun(e)?", "/jul(y)?/": "jul(y)?", "/aug(ust)?/": "aug(ust)?", "/sep(t(ember)?)?/": "sep(t(ember)?)?", "/oct(ober)?/": "oct(ober)?", "/nov(ember)?/": "nov(ember)?", "/dec(ember)?/": "dec(ember)?", "/^su(n(day)?)?/": "^su(n(day)?)?", "/^mo(n(day)?)?/": "^mo(n(day)?)?", "/^tu(e(s(day)?)?)?/": "^tu(e(s(day)?)?)?", "/^we(d(nesday)?)?/": "^we(d(nesday)?)?", "/^th(u(r(s(day)?)?)?)?/": "^th(u(r(s(day)?)?)?)?", "/^fr(i(day)?)?/": "^fr(i(day)?)?", "/^sa(t(urday)?)?/": "^sa(t(urday)?)?", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "fa-IR"; ================================================ FILE: build/i18n/fi-FI.js ================================================ /* * DateJS Culture String File * Country Code: fi-FI * Name: Finnish (Finland) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["fi-FI"] = { "name": "fi-FI", "englishName": "Finnish (Finland)", "nativeName": "suomi (Suomi)", "Sunday": "sunnuntai", "Monday": "maanantai", "Tuesday": "tiistai", "Wednesday": "keskiviikko", "Thursday": "torstai", "Friday": "perjantai", "Saturday": "lauantai", "Sun": "su", "Mon": "ma", "Tue": "ti", "Wed": "ke", "Thu": "to", "Fri": "pe", "Sat": "la", "Su": "su", "Mo": "ma", "Tu": "ti", "We": "ke", "Th": "to", "Fr": "pe", "Sa": "la", "S_Sun_Initial": "s", "M_Mon_Initial": "m", "T_Tue_Initial": "t", "W_Wed_Initial": "k", "T_Thu_Initial": "t", "F_Fri_Initial": "p", "S_Sat_Initial": "l", "January": "tammikuu", "February": "helmikuu", "March": "maaliskuu", "April": "huhtikuu", "May": "toukokuu", "June": "kesäkuu", "July": "heinäkuu", "August": "elokuu", "September": "syyskuu", "October": "lokakuu", "November": "marraskuu", "December": "joulukuu", "Jan_Abbr": "tammi", "Feb_Abbr": "helmi", "Mar_Abbr": "maalis", "Apr_Abbr": "huhti", "May_Abbr": "touko", "Jun_Abbr": "kesä", "Jul_Abbr": "heinä", "Aug_Abbr": "elo", "Sep_Abbr": "syys", "Oct_Abbr": "loka", "Nov_Abbr": "marras", "Dec_Abbr": "joulu", "AM": "", "PM": "", "firstDayOfWeek": 1, "twoDigitYearMax": 2029, "mdy": "dmy", "M/d/yyyy": "d.M.yyyy", "dddd, MMMM dd, yyyy": "d. MMMM'ta 'yyyy", "h:mm tt": "H:mm", "h:mm:ss tt": "H:mm:ss", "dddd, MMMM dd, yyyy h:mm:ss tt": "d. MMMM'ta 'yyyy H:mm:ss", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "d. MMMM'ta'", "MMMM, yyyy": "MMMM yyyy", "/jan(uary)?/": "tammi(kuu)?", "/feb(ruary)?/": "helmi(kuu)?", "/mar(ch)?/": "maalis(kuu)?", "/apr(il)?/": "huhti(kuu)?", "/may/": "touko(kuu)?", "/jun(e)?/": "kesä(kuu)?", "/jul(y)?/": "heinä(kuu)?", "/aug(ust)?/": "elo(kuu)?", "/sep(t(ember)?)?/": "syys(kuu)?", "/oct(ober)?/": "loka(kuu)?", "/nov(ember)?/": "marras(kuu)?", "/dec(ember)?/": "joulu(kuu)?", "/^su(n(day)?)?/": "^sunnuntai", "/^mo(n(day)?)?/": "^maanantai", "/^tu(e(s(day)?)?)?/": "^tiistai", "/^we(d(nesday)?)?/": "^keskiviikko", "/^th(u(r(s(day)?)?)?)?/": "^torstai", "/^fr(i(day)?)?/": "^perjantai", "/^sa(t(urday)?)?/": "^lauantai", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "fi-FI"; ================================================ FILE: build/i18n/fo-FO.js ================================================ /* * DateJS Culture String File * Country Code: fo-FO * Name: Faroese (Faroe Islands) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["fo-FO"] = { "name": "fo-FO", "englishName": "Faroese (Faroe Islands)", "nativeName": "føroyskt (Føroyar)", "Sunday": "sunnudagur", "Monday": "mánadagur", "Tuesday": "týsdagur", "Wednesday": "mikudagur", "Thursday": "hósdagur", "Friday": "fríggjadagur", "Saturday": "leygardagur", "Sun": "sun", "Mon": "mán", "Tue": "týs", "Wed": "mik", "Thu": "hós", "Fri": "frí", "Sat": "leyg", "Su": "su", "Mo": "má", "Tu": "tý", "We": "mi", "Th": "hó", "Fr": "fr", "Sa": "ley", "S_Sun_Initial": "s", "M_Mon_Initial": "m", "T_Tue_Initial": "t", "W_Wed_Initial": "m", "T_Thu_Initial": "h", "F_Fri_Initial": "f", "S_Sat_Initial": "l", "January": "januar", "February": "februar", "March": "mars", "April": "apríl", "May": "mai", "June": "juni", "July": "juli", "August": "august", "September": "september", "October": "oktober", "November": "november", "December": "desember", "Jan_Abbr": "jan", "Feb_Abbr": "feb", "Mar_Abbr": "mar", "Apr_Abbr": "apr", "May_Abbr": "mai", "Jun_Abbr": "jun", "Jul_Abbr": "jul", "Aug_Abbr": "aug", "Sep_Abbr": "sep", "Oct_Abbr": "okt", "Nov_Abbr": "nov", "Dec_Abbr": "des", "AM": "", "PM": "", "firstDayOfWeek": 1, "twoDigitYearMax": 2029, "mdy": "dmy", "M/d/yyyy": "dd-MM-yyyy", "dddd, MMMM dd, yyyy": "d. MMMM yyyy", "h:mm tt": "HH.mm", "h:mm:ss tt": "HH.mm.ss", "dddd, MMMM dd, yyyy h:mm:ss tt": "d. MMMM yyyy HH.mm.ss", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "d. MMMM", "MMMM, yyyy": "MMMM yyyy", "/jan(uary)?/": "jan(uar)?", "/feb(ruary)?/": "feb(ruar)?", "/mar(ch)?/": "mar(s)?", "/apr(il)?/": "apr(íl)?", "/may/": "mai", "/jun(e)?/": "jun(i)?", "/jul(y)?/": "jul(i)?", "/aug(ust)?/": "aug(ust)?", "/sep(t(ember)?)?/": "sep(t(ember)?)?", "/oct(ober)?/": "okt(ober)?", "/nov(ember)?/": "nov(ember)?", "/dec(ember)?/": "des(ember)?", "/^su(n(day)?)?/": "^su(n(nudagur)?)?", "/^mo(n(day)?)?/": "^má(n(adagur)?)?", "/^tu(e(s(day)?)?)?/": "^tý(s(dagur)?)?", "/^we(d(nesday)?)?/": "^mi(k(udagur)?)?", "/^th(u(r(s(day)?)?)?)?/": "^hó(s(dagur)?)?", "/^fr(i(day)?)?/": "^fr(í(ggjadagur)?)?", "/^sa(t(urday)?)?/": "^ley(g(ardagur)?)?", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "fo-FO"; ================================================ FILE: build/i18n/fr-BE.js ================================================ /* * DateJS Culture String File * Country Code: fr-BE * Name: French (Belgium) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["fr-BE"] = { "name": "fr-BE", "englishName": "French (Belgium)", "nativeName": "français (Belgique)", "Sunday": "dimanche", "Monday": "lundi", "Tuesday": "mardi", "Wednesday": "mercredi", "Thursday": "jeudi", "Friday": "vendredi", "Saturday": "samedi", "Sun": "dim.", "Mon": "lun.", "Tue": "mar.", "Wed": "mer.", "Thu": "jeu.", "Fri": "ven.", "Sat": "sam.", "Su": "di", "Mo": "lu", "Tu": "ma", "We": "me", "Th": "je", "Fr": "ve", "Sa": "sa", "S_Sun_Initial": "d", "M_Mon_Initial": "l", "T_Tue_Initial": "m", "W_Wed_Initial": "m", "T_Thu_Initial": "j", "F_Fri_Initial": "v", "S_Sat_Initial": "s", "January": "janvier", "February": "février", "March": "mars", "April": "avril", "May": "mai", "June": "juin", "July": "juillet", "August": "août", "September": "septembre", "October": "octobre", "November": "novembre", "December": "décembre", "Jan_Abbr": "janv.", "Feb_Abbr": "févr.", "Mar_Abbr": "mars", "Apr_Abbr": "avr.", "May_Abbr": "mai", "Jun_Abbr": "juin", "Jul_Abbr": "juil.", "Aug_Abbr": "août", "Sep_Abbr": "sept.", "Oct_Abbr": "oct.", "Nov_Abbr": "nov.", "Dec_Abbr": "déc.", "AM": "", "PM": "", "firstDayOfWeek": 1, "twoDigitYearMax": 2029, "mdy": "dmy", "M/d/yyyy": "d/MM/yyyy", "dddd, MMMM dd, yyyy": "dddd d MMMM yyyy", "h:mm tt": "H:mm", "h:mm:ss tt": "H:mm:ss", "dddd, MMMM dd, yyyy h:mm:ss tt": "dddd d MMMM yyyy H:mm:ss", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "d MMMM", "MMMM, yyyy": "MMMM yyyy", "/jan(uary)?/": "janv(.(ier)?)?", "/feb(ruary)?/": "févr(.(ier)?)?", "/mar(ch)?/": "mars", "/apr(il)?/": "avr(.(il)?)?", "/may/": "mai", "/jun(e)?/": "juin", "/jul(y)?/": "juil(.(let)?)?", "/aug(ust)?/": "août", "/sep(t(ember)?)?/": "sept(.(embre)?)?", "/oct(ober)?/": "oct(.(obre)?)?", "/nov(ember)?/": "nov(.(embre)?)?", "/dec(ember)?/": "déc(.(embre)?)?", "/^su(n(day)?)?/": "^di(m(.(anche)?)?)?", "/^mo(n(day)?)?/": "^lu(n(.(di)?)?)?", "/^tu(e(s(day)?)?)?/": "^ma(r(.(di)?)?)?", "/^we(d(nesday)?)?/": "^me(r(.(credi)?)?)?", "/^th(u(r(s(day)?)?)?)?/": "^je(u(.(di)?)?)?", "/^fr(i(day)?)?/": "^ve(n(.(dredi)?)?)?", "/^sa(t(urday)?)?/": "^sa(m(.(edi)?)?)?", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "fr-BE"; ================================================ FILE: build/i18n/fr-CA.js ================================================ /* * DateJS Culture String File * Country Code: fr-CA * Name: French (Canada) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["fr-CA"] = { "name": "fr-CA", "englishName": "French (Canada)", "nativeName": "français (Canada)", "Sunday": "dimanche", "Monday": "lundi", "Tuesday": "mardi", "Wednesday": "mercredi", "Thursday": "jeudi", "Friday": "vendredi", "Saturday": "samedi", "Sun": "dim.", "Mon": "lun.", "Tue": "mar.", "Wed": "mer.", "Thu": "jeu.", "Fri": "ven.", "Sat": "sam.", "Su": "di", "Mo": "lu", "Tu": "ma", "We": "me", "Th": "je", "Fr": "ve", "Sa": "sa", "S_Sun_Initial": "d", "M_Mon_Initial": "l", "T_Tue_Initial": "m", "W_Wed_Initial": "m", "T_Thu_Initial": "j", "F_Fri_Initial": "v", "S_Sat_Initial": "s", "January": "janvier", "February": "février", "March": "mars", "April": "avril", "May": "mai", "June": "juin", "July": "juillet", "August": "août", "September": "septembre", "October": "octobre", "November": "novembre", "December": "décembre", "Jan_Abbr": "janv.", "Feb_Abbr": "févr.", "Mar_Abbr": "mars", "Apr_Abbr": "avr.", "May_Abbr": "mai", "Jun_Abbr": "juin", "Jul_Abbr": "juil.", "Aug_Abbr": "août", "Sep_Abbr": "sept.", "Oct_Abbr": "oct.", "Nov_Abbr": "nov.", "Dec_Abbr": "déc.", "AM": "", "PM": "", "firstDayOfWeek": 0, "twoDigitYearMax": 2029, "mdy": "ymd", "M/d/yyyy": "yyyy-MM-dd", "dddd, MMMM dd, yyyy": "d MMMM yyyy", "h:mm tt": "HH:mm", "h:mm:ss tt": "HH:mm:ss", "dddd, MMMM dd, yyyy h:mm:ss tt": "d MMMM yyyy HH:mm:ss", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "d MMMM", "MMMM, yyyy": "MMMM, yyyy", "/jan(uary)?/": "janv((ier)?)?", "/feb(ruary)?/": "févr((ier)?)?", "/mar(ch)?/": "mars", "/apr(il)?/": "avr((il)?)?", "/may/": "mai", "/jun(e)?/": "juin", "/jul(y)?/": "juil((let)?)?", "/aug(ust)?/": "août", "/sep(t(ember)?)?/": "sept((embre)?)?", "/oct(ober)?/": "oct((obre)?)?", "/nov(ember)?/": "nov((embre)?)?", "/dec(ember)?/": "déc((embre)?)?", "/^su(n(day)?)?/": "^di(m((anche)?)?)?", "/^mo(n(day)?)?/": "^lu(n((di)?)?)?", "/^tu(e(s(day)?)?)?/": "^ma(r((di)?)?)?", "/^we(d(nesday)?)?/": "^me(r((credi)?)?)?", "/^th(u(r(s(day)?)?)?)?/": "^je(u((di)?)?)?", "/^fr(i(day)?)?/": "^ve(n((dredi)?)?)?", "/^sa(t(urday)?)?/": "^sa(m((edi)?)?)?", "/^next/": "^prochain", "/^last|past|prev(ious)?/": "^dernier", "/^(\\+|aft(er)?|from|hence)/": "^précédant", "/^(\\-|bef(ore)?|ago)/": "^succédant", "/^yes(terday)?/": "^hier", "/^t(od(ay)?)?/": "^aujourd\'hui", "/^tom(orrow)?/": "^demain", "/^n(ow)?/": "^maintenant", "/^ms|milli(second)?s?/": "^ms|milli(seconde)?s?", "/^sec(ond)?s?/": "^sec(onde)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(eure)?s?", "/^w(eek)?s?/": "^sem(aine)?s?", "/^m(onth)?s?/": "^m(ois)?", "/^d(ay)?s?/": "^j(our)?s?", "/^y(ear)?s?/": "^a(nnée)?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "fr-CA"; ================================================ FILE: build/i18n/fr-CH.js ================================================ /* * DateJS Culture String File * Country Code: fr-CH * Name: French (Switzerland) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["fr-CH"] = { "name": "fr-CH", "englishName": "French (Switzerland)", "nativeName": "français (Suisse)", "Sunday": "dimanche", "Monday": "lundi", "Tuesday": "mardi", "Wednesday": "mercredi", "Thursday": "jeudi", "Friday": "vendredi", "Saturday": "samedi", "Sun": "dim.", "Mon": "lun.", "Tue": "mar.", "Wed": "mer.", "Thu": "jeu.", "Fri": "ven.", "Sat": "sam.", "Su": "di", "Mo": "lu", "Tu": "ma", "We": "me", "Th": "je", "Fr": "ve", "Sa": "sa", "S_Sun_Initial": "d", "M_Mon_Initial": "l", "T_Tue_Initial": "m", "W_Wed_Initial": "m", "T_Thu_Initial": "j", "F_Fri_Initial": "v", "S_Sat_Initial": "s", "January": "janvier", "February": "février", "March": "mars", "April": "avril", "May": "mai", "June": "juin", "July": "juillet", "August": "août", "September": "septembre", "October": "octobre", "November": "novembre", "December": "décembre", "Jan_Abbr": "janv.", "Feb_Abbr": "févr.", "Mar_Abbr": "mars", "Apr_Abbr": "avr.", "May_Abbr": "mai", "Jun_Abbr": "juin", "Jul_Abbr": "juil.", "Aug_Abbr": "août", "Sep_Abbr": "sept.", "Oct_Abbr": "oct.", "Nov_Abbr": "nov.", "Dec_Abbr": "déc.", "AM": "", "PM": "", "firstDayOfWeek": 1, "twoDigitYearMax": 2029, "mdy": "dmy", "M/d/yyyy": "dd.MM.yyyy", "dddd, MMMM dd, yyyy": "dddd, d. MMMM yyyy", "h:mm tt": "HH:mm", "h:mm:ss tt": "HH:mm:ss", "dddd, MMMM dd, yyyy h:mm:ss tt": "dddd, d. MMMM yyyy HH:mm:ss", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "d MMMM", "MMMM, yyyy": "MMMM yyyy", "/jan(uary)?/": "janv(.(ier)?)?", "/feb(ruary)?/": "févr(.(ier)?)?", "/mar(ch)?/": "mars", "/apr(il)?/": "avr(.(il)?)?", "/may/": "mai", "/jun(e)?/": "juin", "/jul(y)?/": "juil(.(let)?)?", "/aug(ust)?/": "août", "/sep(t(ember)?)?/": "sept(.(embre)?)?", "/oct(ober)?/": "oct(.(obre)?)?", "/nov(ember)?/": "nov(.(embre)?)?", "/dec(ember)?/": "déc(.(embre)?)?", "/^su(n(day)?)?/": "^di(m(.(anche)?)?)?", "/^mo(n(day)?)?/": "^lu(n(.(di)?)?)?", "/^tu(e(s(day)?)?)?/": "^ma(r(.(di)?)?)?", "/^we(d(nesday)?)?/": "^me(r(.(credi)?)?)?", "/^th(u(r(s(day)?)?)?)?/": "^je(u(.(di)?)?)?", "/^fr(i(day)?)?/": "^ve(n(.(dredi)?)?)?", "/^sa(t(urday)?)?/": "^sa(m(.(edi)?)?)?", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "fr-CH"; ================================================ FILE: build/i18n/fr-FR.js ================================================ /* * DateJS Culture String File * Country Code: fr-FR * Name: French (France) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["fr-FR"] = { "name": "fr-FR", "englishName": "French (France)", "nativeName": "français (France)", "Sunday": "dimanche", "Monday": "lundi", "Tuesday": "mardi", "Wednesday": "mercredi", "Thursday": "jeudi", "Friday": "vendredi", "Saturday": "samedi", "Sun": "dim.", "Mon": "lun.", "Tue": "mar.", "Wed": "mer.", "Thu": "jeu.", "Fri": "ven.", "Sat": "sam.", "Su": "di", "Mo": "lu", "Tu": "ma", "We": "me", "Th": "je", "Fr": "ve", "Sa": "sa", "S_Sun_Initial": "d", "M_Mon_Initial": "l", "T_Tue_Initial": "m", "W_Wed_Initial": "m", "T_Thu_Initial": "j", "F_Fri_Initial": "v", "S_Sat_Initial": "s", "January": "janvier", "February": "février", "March": "mars", "April": "avril", "May": "mai", "June": "juin", "July": "juillet", "August": "août", "September": "septembre", "October": "octobre", "November": "novembre", "December": "décembre", "Jan_Abbr": "janv.", "Feb_Abbr": "févr.", "Mar_Abbr": "mars", "Apr_Abbr": "avr.", "May_Abbr": "mai", "Jun_Abbr": "juin", "Jul_Abbr": "juil.", "Aug_Abbr": "août", "Sep_Abbr": "sept.", "Oct_Abbr": "oct.", "Nov_Abbr": "nov.", "Dec_Abbr": "déc.", "AM": "", "PM": "", "firstDayOfWeek": 1, "twoDigitYearMax": 2029, "mdy": "dmy", "M/d/yyyy": "dd/MM/yyyy", "dddd, MMMM dd, yyyy": "dddd d MMMM yyyy", "h:mm tt": "HH:mm", "h:mm:ss tt": "HH:mm:ss", "dddd, MMMM dd, yyyy h:mm:ss tt": "dddd d MMMM yyyy HH:mm:ss", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "d MMMM", "MMMM, yyyy": "MMMM yyyy", "/jan(uary)?/": "janv(.(ier)?)?", "/feb(ruary)?/": "févr(.(ier)?)?", "/mar(ch)?/": "mars", "/apr(il)?/": "avr(.(il)?)?", "/may/": "mai", "/jun(e)?/": "juin", "/jul(y)?/": "juil(.(let)?)?", "/aug(ust)?/": "août", "/sep(t(ember)?)?/": "sept(.(embre)?)?", "/oct(ober)?/": "oct(.(obre)?)?", "/nov(ember)?/": "nov(.(embre)?)?", "/dec(ember)?/": "déc(.(embre)?)?", "/^su(n(day)?)?/": "^di(m(.(anche)?)?)?", "/^mo(n(day)?)?/": "^lu(n(.(di)?)?)?", "/^tu(e(s(day)?)?)?/": "^ma(r(.(di)?)?)?", "/^we(d(nesday)?)?/": "^me(r(.(credi)?)?)?", "/^th(u(r(s(day)?)?)?)?/": "^je(u(.(di)?)?)?", "/^fr(i(day)?)?/": "^ve(n(.(dredi)?)?)?", "/^sa(t(urday)?)?/": "^sa(m(.(edi)?)?)?", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "fr-FR"; ================================================ FILE: build/i18n/fr-LU.js ================================================ /* * DateJS Culture String File * Country Code: fr-LU * Name: French (Luxembourg) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["fr-LU"] = { "name": "fr-LU", "englishName": "French (Luxembourg)", "nativeName": "français (Luxembourg)", "Sunday": "dimanche", "Monday": "lundi", "Tuesday": "mardi", "Wednesday": "mercredi", "Thursday": "jeudi", "Friday": "vendredi", "Saturday": "samedi", "Sun": "dim.", "Mon": "lun.", "Tue": "mar.", "Wed": "mer.", "Thu": "jeu.", "Fri": "ven.", "Sat": "sam.", "Su": "di", "Mo": "lu", "Tu": "ma", "We": "me", "Th": "je", "Fr": "ve", "Sa": "sa", "S_Sun_Initial": "d", "M_Mon_Initial": "l", "T_Tue_Initial": "m", "W_Wed_Initial": "m", "T_Thu_Initial": "j", "F_Fri_Initial": "v", "S_Sat_Initial": "s", "January": "janvier", "February": "février", "March": "mars", "April": "avril", "May": "mai", "June": "juin", "July": "juillet", "August": "août", "September": "septembre", "October": "octobre", "November": "novembre", "December": "décembre", "Jan_Abbr": "janv.", "Feb_Abbr": "févr.", "Mar_Abbr": "mars", "Apr_Abbr": "avr.", "May_Abbr": "mai", "Jun_Abbr": "juin", "Jul_Abbr": "juil.", "Aug_Abbr": "août", "Sep_Abbr": "sept.", "Oct_Abbr": "oct.", "Nov_Abbr": "nov.", "Dec_Abbr": "déc.", "AM": "", "PM": "", "firstDayOfWeek": 1, "twoDigitYearMax": 2029, "mdy": "dmy", "M/d/yyyy": "dd/MM/yyyy", "dddd, MMMM dd, yyyy": "dddd d MMMM yyyy", "h:mm tt": "HH:mm", "h:mm:ss tt": "HH:mm:ss", "dddd, MMMM dd, yyyy h:mm:ss tt": "dddd d MMMM yyyy HH:mm:ss", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "d MMMM", "MMMM, yyyy": "MMMM yyyy", "/jan(uary)?/": "janv(.(ier)?)?", "/feb(ruary)?/": "févr(.(ier)?)?", "/mar(ch)?/": "mars", "/apr(il)?/": "avr(.(il)?)?", "/may/": "mai", "/jun(e)?/": "juin", "/jul(y)?/": "juil(.(let)?)?", "/aug(ust)?/": "août", "/sep(t(ember)?)?/": "sept(.(embre)?)?", "/oct(ober)?/": "oct(.(obre)?)?", "/nov(ember)?/": "nov(.(embre)?)?", "/dec(ember)?/": "déc(.(embre)?)?", "/^su(n(day)?)?/": "^di(m(.(anche)?)?)?", "/^mo(n(day)?)?/": "^lu(n(.(di)?)?)?", "/^tu(e(s(day)?)?)?/": "^ma(r(.(di)?)?)?", "/^we(d(nesday)?)?/": "^me(r(.(credi)?)?)?", "/^th(u(r(s(day)?)?)?)?/": "^je(u(.(di)?)?)?", "/^fr(i(day)?)?/": "^ve(n(.(dredi)?)?)?", "/^sa(t(urday)?)?/": "^sa(m(.(edi)?)?)?", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "fr-LU"; ================================================ FILE: build/i18n/fr-MC.js ================================================ /* * DateJS Culture String File * Country Code: fr-MC * Name: French (Principality of Monaco) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["fr-MC"] = { "name": "fr-MC", "englishName": "French (Principality of Monaco)", "nativeName": "français (Principauté de Monaco)", "Sunday": "dimanche", "Monday": "lundi", "Tuesday": "mardi", "Wednesday": "mercredi", "Thursday": "jeudi", "Friday": "vendredi", "Saturday": "samedi", "Sun": "dim.", "Mon": "lun.", "Tue": "mar.", "Wed": "mer.", "Thu": "jeu.", "Fri": "ven.", "Sat": "sam.", "Su": "di", "Mo": "lu", "Tu": "ma", "We": "me", "Th": "je", "Fr": "ve", "Sa": "sa", "S_Sun_Initial": "d", "M_Mon_Initial": "l", "T_Tue_Initial": "m", "W_Wed_Initial": "m", "T_Thu_Initial": "j", "F_Fri_Initial": "v", "S_Sat_Initial": "s", "January": "janvier", "February": "février", "March": "mars", "April": "avril", "May": "mai", "June": "juin", "July": "juillet", "August": "août", "September": "septembre", "October": "octobre", "November": "novembre", "December": "décembre", "Jan_Abbr": "janv.", "Feb_Abbr": "févr.", "Mar_Abbr": "mars", "Apr_Abbr": "avr.", "May_Abbr": "mai", "Jun_Abbr": "juin", "Jul_Abbr": "juil.", "Aug_Abbr": "août", "Sep_Abbr": "sept.", "Oct_Abbr": "oct.", "Nov_Abbr": "nov.", "Dec_Abbr": "déc.", "AM": "", "PM": "", "firstDayOfWeek": 1, "twoDigitYearMax": 2029, "mdy": "dmy", "M/d/yyyy": "dd/MM/yyyy", "dddd, MMMM dd, yyyy": "dddd d MMMM yyyy", "h:mm tt": "HH:mm", "h:mm:ss tt": "HH:mm:ss", "dddd, MMMM dd, yyyy h:mm:ss tt": "dddd d MMMM yyyy HH:mm:ss", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "d MMMM", "MMMM, yyyy": "MMMM yyyy", "/jan(uary)?/": "janv(.(ier)?)?", "/feb(ruary)?/": "févr(.(ier)?)?", "/mar(ch)?/": "mars", "/apr(il)?/": "avr(.(il)?)?", "/may/": "mai", "/jun(e)?/": "juin", "/jul(y)?/": "juil(.(let)?)?", "/aug(ust)?/": "août", "/sep(t(ember)?)?/": "sept(.(embre)?)?", "/oct(ober)?/": "oct(.(obre)?)?", "/nov(ember)?/": "nov(.(embre)?)?", "/dec(ember)?/": "déc(.(embre)?)?", "/^su(n(day)?)?/": "^di(m(.(anche)?)?)?", "/^mo(n(day)?)?/": "^lu(n(.(di)?)?)?", "/^tu(e(s(day)?)?)?/": "^ma(r(.(di)?)?)?", "/^we(d(nesday)?)?/": "^me(r(.(credi)?)?)?", "/^th(u(r(s(day)?)?)?)?/": "^je(u(.(di)?)?)?", "/^fr(i(day)?)?/": "^ve(n(.(dredi)?)?)?", "/^sa(t(urday)?)?/": "^sa(m(.(edi)?)?)?", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "fr-MC"; ================================================ FILE: build/i18n/gl-ES.js ================================================ /* * DateJS Culture String File * Country Code: gl-ES * Name: Galician (Galician) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["gl-ES"] = { "name": "gl-ES", "englishName": "Galician (Galician)", "nativeName": "galego (galego)", "Sunday": "domingo", "Monday": "luns", "Tuesday": "martes", "Wednesday": "mércores", "Thursday": "xoves", "Friday": "venres", "Saturday": "sábado", "Sun": "dom", "Mon": "luns", "Tue": "mar", "Wed": "mér", "Thu": "xov", "Fri": "ven", "Sat": "sab", "Su": "do", "Mo": "lu", "Tu": "ma", "We": "mé", "Th": "xo", "Fr": "ve", "Sa": "sa", "S_Sun_Initial": "d", "M_Mon_Initial": "l", "T_Tue_Initial": "m", "W_Wed_Initial": "m", "T_Thu_Initial": "x", "F_Fri_Initial": "v", "S_Sat_Initial": "s", "January": "xaneiro", "February": "febreiro", "March": "marzo", "April": "abril", "May": "maio", "June": "xuño", "July": "xullo", "August": "agosto", "September": "setembro", "October": "outubro", "November": "novembro", "December": "decembro", "Jan_Abbr": "xan", "Feb_Abbr": "feb", "Mar_Abbr": "mar", "Apr_Abbr": "abr", "May_Abbr": "maio", "Jun_Abbr": "xuñ", "Jul_Abbr": "xull", "Aug_Abbr": "ago", "Sep_Abbr": "set", "Oct_Abbr": "out", "Nov_Abbr": "nov", "Dec_Abbr": "dec", "AM": "a.m.", "PM": "p.m.", "firstDayOfWeek": 1, "twoDigitYearMax": 2029, "mdy": "dmy", "M/d/yyyy": "dd/MM/yy", "dddd, MMMM dd, yyyy": "dddd, dd' de 'MMMM' de 'yyyy", "h:mm tt": "H:mm", "h:mm:ss tt": "H:mm:ss", "dddd, MMMM dd, yyyy h:mm:ss tt": "dddd, dd' de 'MMMM' de 'yyyy H:mm:ss", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "dd MMMM", "MMMM, yyyy": "MMMM' de 'yyyy", "/jan(uary)?/": "xan(eiro)?", "/feb(ruary)?/": "feb(reiro)?", "/mar(ch)?/": "mar(zo)?", "/apr(il)?/": "abr(il)?", "/may/": "maio", "/jun(e)?/": "xuñ(o)?", "/jul(y)?/": "xull(o)?", "/aug(ust)?/": "ago(sto)?", "/sep(t(ember)?)?/": "set(embro)?", "/oct(ober)?/": "out(ubro)?", "/nov(ember)?/": "nov(embro)?", "/dec(ember)?/": "dec(embro)?", "/^su(n(day)?)?/": "^do(m(ingo)?)?", "/^mo(n(day)?)?/": "^lu(1)?", "/^tu(e(s(day)?)?)?/": "^ma(r(tes)?)?", "/^we(d(nesday)?)?/": "^mé(r(cores)?)?", "/^th(u(r(s(day)?)?)?)?/": "^xo(v(es)?)?", "/^fr(i(day)?)?/": "^ve(n(res)?)?", "/^sa(t(urday)?)?/": "^sa(b(ado)?)?", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "gl-ES"; ================================================ FILE: build/i18n/gu-IN.js ================================================ /* * DateJS Culture String File * Country Code: gu-IN * Name: Gujarati (India) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["gu-IN"] = { "name": "gu-IN", "englishName": "Gujarati (India)", "nativeName": "ગુજરાતી (ભારત)", "Sunday": "રવિવાર", "Monday": "સોમવાર", "Tuesday": "મંગળવાર", "Wednesday": "બુધવાર", "Thursday": "ગુરુવાર", "Friday": "શુક્રવાર", "Saturday": "શનિવાર", "Sun": "રવિ", "Mon": "સોમ", "Tue": "મંગળ", "Wed": "બુધ", "Thu": "ગુરુ", "Fri": "શુક્ર", "Sat": "શનિ", "Su": "ર", "Mo": "સ", "Tu": "મ", "We": "બ", "Th": "ગ", "Fr": "શ", "Sa": "શ", "S_Sun_Initial": "ર", "M_Mon_Initial": "સ", "T_Tue_Initial": "મ", "W_Wed_Initial": "બ", "T_Thu_Initial": "ગ", "F_Fri_Initial": "શ", "S_Sat_Initial": "શ", "January": "જાન્યુઆરી", "February": "ફેબ્રુઆરી", "March": "માર્ચ", "April": "એપ્રિલ", "May": "મે", "June": "જૂન", "July": "જુલાઈ", "August": "ઑગસ્ટ", "September": "સપ્ટેમ્બર", "October": "ઑક્ટ્બર", "November": "નવેમ્બર", "December": "ડિસેમ્બર", "Jan_Abbr": "જાન્યુ", "Feb_Abbr": "ફેબ્રુ", "Mar_Abbr": "માર્ચ", "Apr_Abbr": "એપ્રિલ", "May_Abbr": "મે", "Jun_Abbr": "જૂન", "Jul_Abbr": "જુલાઈ", "Aug_Abbr": "ઑગસ્ટ", "Sep_Abbr": "સપ્ટે", "Oct_Abbr": "ઑક્ટો", "Nov_Abbr": "નવે", "Dec_Abbr": "ડિસે", "AM": "પૂર્વ મધ્યાહ્ન", "PM": "ઉત્તર મધ્યાહ્ન", "firstDayOfWeek": 1, "twoDigitYearMax": 2029, "mdy": "dmy", "M/d/yyyy": "dd-MM-yy", "dddd, MMMM dd, yyyy": "dd MMMM yyyy", "h:mm tt": "HH:mm", "h:mm:ss tt": "HH:mm:ss", "dddd, MMMM dd, yyyy h:mm:ss tt": "dd MMMM yyyy HH:mm:ss", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "dd MMMM", "MMMM, yyyy": "MMMM, yyyy", "/jan(uary)?/": "જાન્યુ(આરી)?", "/feb(ruary)?/": "ફેબ્રુ(આરી)?", "/mar(ch)?/": "માર્ચ", "/apr(il)?/": "એપ્રિલ", "/may/": "મે", "/jun(e)?/": "જૂન", "/jul(y)?/": "જુલાઈ", "/aug(ust)?/": "ઑગસ્ટ", "/sep(t(ember)?)?/": "સપ્ટે(મ્બર)?", "/oct(ober)?/": "ઑક્ટ્બર", "/nov(ember)?/": "નવે(મ્બર)?", "/dec(ember)?/": "ડિસે(મ્બર)?", "/^su(n(day)?)?/": "^ર(વિ(વાર)?)?", "/^mo(n(day)?)?/": "^સ(ોમ(વાર)?)?", "/^tu(e(s(day)?)?)?/": "^મ(ંગળ(વાર)?)?", "/^we(d(nesday)?)?/": "^બ(ુધ(વાર)?)?", "/^th(u(r(s(day)?)?)?)?/": "^ગ(ુરુ(વાર)?)?", "/^fr(i(day)?)?/": "^શ(ુક્ર(વાર)?)?", "/^sa(t(urday)?)?/": "^શ(નિ(વાર)?)?", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "gu-IN"; ================================================ FILE: build/i18n/he-IL.js ================================================ /* * DateJS Culture String File * Country Code: he-IL * Name: Hebrew (Israel) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["he-IL"] = { "name": "he-IL", "englishName": "Hebrew (Israel)", "nativeName": "עברית (ישראל)", "Sunday": "יום ראשון", "Monday": "יום שני", "Tuesday": "יום שלישי", "Wednesday": "יום רביעי", "Thursday": "יום חמישי", "Friday": "יום שישי", "Saturday": "שבת", "Sun": "יום א", "Mon": "יום ב", "Tue": "יום ג", "Wed": "יום ד", "Thu": "יום ה", "Fri": "יום ו", "Sat": "שבת", "Su": "א", "Mo": "ב", "Tu": "ג", "We": "ד", "Th": "ה", "Fr": "ו", "Sa": "ש", "S_Sun_Initial": "א", "M_Mon_Initial": "ב", "T_Tue_Initial": "ג", "W_Wed_Initial": "ד", "T_Thu_Initial": "ה", "F_Fri_Initial": "ו", "S_Sat_Initial": "ש", "January": "ינואר", "February": "פברואר", "March": "מרץ", "April": "אפריל", "May": "מאי", "June": "יוני", "July": "יולי", "August": "אוגוסט", "September": "ספטמבר", "October": "אוקטובר", "November": "נובמבר", "December": "דצמבר", "Jan_Abbr": "ינו", "Feb_Abbr": "פבר", "Mar_Abbr": "מרץ", "Apr_Abbr": "אפר", "May_Abbr": "מאי", "Jun_Abbr": "יונ", "Jul_Abbr": "יול", "Aug_Abbr": "אוג", "Sep_Abbr": "ספט", "Oct_Abbr": "אוק", "Nov_Abbr": "נוב", "Dec_Abbr": "דצמ", "AM": "AM", "PM": "PM", "firstDayOfWeek": 0, "twoDigitYearMax": 2029, "mdy": "dmy", "M/d/yyyy": "dd/MM/yyyy", "dddd, MMMM dd, yyyy": "dddd dd MMMM yyyy", "h:mm tt": "HH:mm", "h:mm:ss tt": "HH:mm:ss", "dddd, MMMM dd, yyyy h:mm:ss tt": "dddd dd MMMM yyyy HH:mm:ss", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "dd MMMM", "MMMM, yyyy": "MMMM yyyy", "/jan(uary)?/": "ינו(אר)?", "/feb(ruary)?/": "פבר(ואר)?", "/mar(ch)?/": "מרץ", "/apr(il)?/": "אפר(יל)?", "/may/": "מאי", "/jun(e)?/": "יונ(י)?", "/jul(y)?/": "יול(י)?", "/aug(ust)?/": "אוג(וסט)?", "/sep(t(ember)?)?/": "ספט(מבר)?", "/oct(ober)?/": "אוק(טובר)?", "/nov(ember)?/": "נוב(מבר)?", "/dec(ember)?/": "דצמ(בר)?", "/^su(n(day)?)?/": "^א(ום א(אשון)?)?", "/^mo(n(day)?)?/": "^ב(ום ב(ני)?)?", "/^tu(e(s(day)?)?)?/": "^ג(ום ג(לישי)?)?", "/^we(d(nesday)?)?/": "^ד(ום ד(ביעי)?)?", "/^th(u(r(s(day)?)?)?)?/": "^ה(ום ה(מישי)?)?", "/^fr(i(day)?)?/": "^ו(ום ו(ישי)?)?", "/^sa(t(urday)?)?/": "^ש(1)?", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "he-IL"; ================================================ FILE: build/i18n/hi-IN.js ================================================ /* * DateJS Culture String File * Country Code: hi-IN * Name: Hindi (India) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["hi-IN"] = { "name": "hi-IN", "englishName": "Hindi (India)", "nativeName": "हिंदी (भारत)", "Sunday": "रविवार", "Monday": "सोमवार", "Tuesday": "मंगलवार", "Wednesday": "बुधवार", "Thursday": "गुरुवार", "Friday": "शुक्रवार", "Saturday": "शनिवार", "Sun": "रवि.", "Mon": "सोम.", "Tue": "मंगल.", "Wed": "बुध.", "Thu": "गुरु.", "Fri": "शुक्र.", "Sat": "शनि.", "Su": "र", "Mo": "स", "Tu": "म", "We": "ब", "Th": "ग", "Fr": "श", "Sa": "श", "S_Sun_Initial": "र", "M_Mon_Initial": "स", "T_Tue_Initial": "म", "W_Wed_Initial": "ब", "T_Thu_Initial": "ग", "F_Fri_Initial": "श", "S_Sat_Initial": "श", "January": "जनवरी", "February": "फरवरी", "March": "मार्च", "April": "अप्रैल", "May": "मई", "June": "जून", "July": "जुलाई", "August": "अगस्त", "September": "सितम्बर", "October": "अक्तूबर", "November": "नवम्बर", "December": "दिसम्बर", "Jan_Abbr": "जनवरी", "Feb_Abbr": "फरवरी", "Mar_Abbr": "मार्च", "Apr_Abbr": "अप्रैल", "May_Abbr": "मई", "Jun_Abbr": "जून", "Jul_Abbr": "जुलाई", "Aug_Abbr": "अगस्त", "Sep_Abbr": "सितम्बर", "Oct_Abbr": "अक्तूबर", "Nov_Abbr": "नवम्बर", "Dec_Abbr": "दिसम्बर", "AM": "पूर्वाह्न", "PM": "अपराह्न", "firstDayOfWeek": 1, "twoDigitYearMax": 2029, "mdy": "dmy", "M/d/yyyy": "dd-MM-yyyy", "dddd, MMMM dd, yyyy": "dd MMMM yyyy", "h:mm tt": "HH:mm", "h:mm:ss tt": "HH:mm:ss", "dddd, MMMM dd, yyyy h:mm:ss tt": "dd MMMM yyyy HH:mm:ss", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "dd MMMM", "MMMM, yyyy": "MMMM, yyyy", "/jan(uary)?/": "जनवरी", "/feb(ruary)?/": "फरवरी", "/mar(ch)?/": "मार्च", "/apr(il)?/": "अप्रैल", "/may/": "मई", "/jun(e)?/": "जून", "/jul(y)?/": "जुलाई", "/aug(ust)?/": "अगस्त", "/sep(t(ember)?)?/": "सितम्बर", "/oct(ober)?/": "अक्तूबर", "/nov(ember)?/": "नवम्बर", "/dec(ember)?/": "दिसम्बर", "/^su(n(day)?)?/": "^र(वि(.(वार)?)?)?", "/^mo(n(day)?)?/": "^स(ोम(.(वार)?)?)?", "/^tu(e(s(day)?)?)?/": "^म(ंगल(.(वार)?)?)?", "/^we(d(nesday)?)?/": "^ब(ुध(.(वार)?)?)?", "/^th(u(r(s(day)?)?)?)?/": "^ग(ुरु(.(वार)?)?)?", "/^fr(i(day)?)?/": "^श(ुक्र(.(वार)?)?)?", "/^sa(t(urday)?)?/": "^श(नि(.(वार)?)?)?", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "hi-IN"; ================================================ FILE: build/i18n/hr-BA.js ================================================ /* * DateJS Culture String File * Country Code: hr-BA * Name: Croatian (Bosnia and Herzegovina) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["hr-BA"] = { "name": "hr-BA", "englishName": "Croatian (Bosnia and Herzegovina)", "nativeName": "hrvatski (Bosna i Hercegovina)", "Sunday": "nedjelja", "Monday": "ponedjeljak", "Tuesday": "utorak", "Wednesday": "srijeda", "Thursday": "četvrtak", "Friday": "petak", "Saturday": "subota", "Sun": "ned", "Mon": "pon", "Tue": "uto", "Wed": "sri", "Thu": "čet", "Fri": "pet", "Sat": "sub", "Su": "ned", "Mo": "pon", "Tu": "uto", "We": "sri", "Th": "čet", "Fr": "pet", "Sa": "sub", "S_Sun_Initial": "n", "M_Mon_Initial": "p", "T_Tue_Initial": "u", "W_Wed_Initial": "s", "T_Thu_Initial": "č", "F_Fri_Initial": "p", "S_Sat_Initial": "s", "January": "siječanj", "February": "veljača", "March": "ožujak", "April": "travanj", "May": "svibanj", "June": "lipanj", "July": "srpanj", "August": "kolovoz", "September": "rujan", "October": "listopad", "November": "studeni", "December": "prosinac", "Jan_Abbr": "sij", "Feb_Abbr": "vlj", "Mar_Abbr": "ožu", "Apr_Abbr": "tra", "May_Abbr": "svi", "Jun_Abbr": "lip", "Jul_Abbr": "srp", "Aug_Abbr": "kol", "Sep_Abbr": "ruj", "Oct_Abbr": "lis", "Nov_Abbr": "stu", "Dec_Abbr": "pro", "AM": "", "PM": "", "firstDayOfWeek": 1, "twoDigitYearMax": 2029, "mdy": "dmy", "M/d/yyyy": "d.M.yyyy", "dddd, MMMM dd, yyyy": "d. MMMM yyyy", "h:mm tt": "H:mm:ss", "h:mm:ss tt": "H:mm:ss", "dddd, MMMM dd, yyyy h:mm:ss tt": "d. MMMM yyyy H:mm:ss", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "MMMM dd", "MMMM, yyyy": "MMMM, yyyy", "/jan(uary)?/": "sij(ečanj)?", "/feb(ruary)?/": "veljača", "/mar(ch)?/": "ožu(jak)?", "/apr(il)?/": "tra(vanj)?", "/may/": "svi(banj)?", "/jun(e)?/": "lip(anj)?", "/jul(y)?/": "srp(anj)?", "/aug(ust)?/": "kol(ovoz)?", "/sep(t(ember)?)?/": "ruj(an)?", "/oct(ober)?/": "lis(topad)?", "/nov(ember)?/": "stu(deni)?", "/dec(ember)?/": "pro(sinac)?", "/^su(n(day)?)?/": "^nedjelja", "/^mo(n(day)?)?/": "^ponedjeljak", "/^tu(e(s(day)?)?)?/": "^utorak", "/^we(d(nesday)?)?/": "^srijeda", "/^th(u(r(s(day)?)?)?)?/": "^četvrtak", "/^fr(i(day)?)?/": "^petak", "/^sa(t(urday)?)?/": "^subota", "/^next/": "^slijedeć(i|e|eg)", "/^last|past|prev(ious)?/": "^zadnji|posljednji|prethodni", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|pos(lije)?|od|odsad(a)?)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|pr(ije)?pred)", "/^yes(terday)?/": "^jučer", "/^t(od(ay)?)?/": "^danas", "/^tom(orrow)?/": "^sutra", "/^n(ow)?/": "^sad(a)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sek(und(a|e|i)?)?", "/^mn|min(ute)?s?/": "^mn|min(ut(a|e|i)?)?", "/^h(our)?s?/": "^s(at(a|i)?)?", "/^w(eek)?s?/": "^tj(edan(a|i)?)?", "/^m(onth)?s?/": "^mj(esec(a|i)?)?", "/^d(ay)?s?/": "^dan(a|i)?", "/^y(ear)?s?/": "^god(in(a|e|i|u))?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "hr-BA"; ================================================ FILE: build/i18n/hr-HR.js ================================================ /* * DateJS Culture String File * Country Code: hr-HR * Name: Croatian (Croatia) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["hr-HR"] = { "name": "hr-HR", "englishName": "Croatian (Croatia)", "nativeName": "hrvatski (Hrvatska)", "Sunday": "nedjelja", "Monday": "ponedjeljak", "Tuesday": "utorak", "Wednesday": "srijeda", "Thursday": "četvrtak", "Friday": "petak", "Saturday": "subota", "Sun": "ned", "Mon": "pon", "Tue": "uto", "Wed": "sri", "Thu": "čet", "Fri": "pet", "Sat": "sub", "Su": "ne", "Mo": "po", "Tu": "ut", "We": "sr", "Th": "če", "Fr": "pe", "Sa": "su", "S_Sun_Initial": "n", "M_Mon_Initial": "p", "T_Tue_Initial": "u", "W_Wed_Initial": "s", "T_Thu_Initial": "č", "F_Fri_Initial": "p", "S_Sat_Initial": "s", "January": "siječanj", "February": "veljača", "March": "ožujak", "April": "travanj", "May": "svibanj", "June": "lipanj", "July": "srpanj", "August": "kolovoz", "September": "rujan", "October": "listopad", "November": "studeni", "December": "prosinac", "Jan_Abbr": "sij", "Feb_Abbr": "vlj", "Mar_Abbr": "ožu", "Apr_Abbr": "tra", "May_Abbr": "svi", "Jun_Abbr": "lip", "Jul_Abbr": "srp", "Aug_Abbr": "kol", "Sep_Abbr": "ruj", "Oct_Abbr": "lis", "Nov_Abbr": "stu", "Dec_Abbr": "pro", "AM": "", "PM": "", "firstDayOfWeek": 1, "twoDigitYearMax": 2029, "mdy": "dmy", "M/d/yyyy": "d.M.yyyy", "dddd, MMMM dd, yyyy": "d. MMMM yyyy", "h:mm tt": "H:mm", "h:mm:ss tt": "H:mm:ss", "dddd, MMMM dd, yyyy h:mm:ss tt": "d. MMMM yyyy H:mm:ss", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "d. MMMM", "MMMM, yyyy": "MMMM, yyyy", "/jan(uary)?/": "sij(ečanj)?", "/feb(ruary)?/": "veljača", "/mar(ch)?/": "ožu(jak)?", "/apr(il)?/": "tra(vanj)?", "/may/": "svi(banj)?", "/jun(e)?/": "lip(anj)?", "/jul(y)?/": "srp(anj)?", "/aug(ust)?/": "kol(ovoz)?", "/sep(t(ember)?)?/": "ruj(an)?", "/oct(ober)?/": "lis(topad)?", "/nov(ember)?/": "stu(deni)?", "/dec(ember)?/": "pro(sinac)?", "/^su(n(day)?)?/": "^ne(d(jelja)?)?", "/^mo(n(day)?)?/": "^po(n(edjeljak)?)?", "/^tu(e(s(day)?)?)?/": "^ut(o(rak)?)?", "/^we(d(nesday)?)?/": "^sr(i(jeda)?)?", "/^th(u(r(s(day)?)?)?)?/": "^če(t(vrtak)?)?", "/^fr(i(day)?)?/": "^pe(t(ak)?)?", "/^sa(t(urday)?)?/": "^su(b(ota)?)?", "/^next/": "^slijedeć(i|e|eg)", "/^last|past|prev(ious)?/": "^zadnji|posljednji|prethodni", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|pos(lije)?|od|odsad(a)?)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|pr(ije)?pred)", "/^yes(terday)?/": "^jučer", "/^t(od(ay)?)?/": "^danas", "/^tom(orrow)?/": "^sutra", "/^n(ow)?/": "^sad(a)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sek(und(a|e|i)?)?", "/^mn|min(ute)?s?/": "^mn|min(ut(a|e|i)?)?", "/^h(our)?s?/": "^s(at(a|i)?)?", "/^w(eek)?s?/": "^tj(edan(a|i)?)?", "/^m(onth)?s?/": "^mj(esec(a|i)?)?", "/^d(ay)?s?/": "^dan(a|i)?", "/^y(ear)?s?/": "^god(in(a|e|i|u))?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "hr-HR"; ================================================ FILE: build/i18n/hu-HU.js ================================================ /* * DateJS Culture String File * Country Code: hu-HU * Name: Hungarian (Hungary) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["hu-HU"] = { "name": "hu-HU", "englishName": "Hungarian (Hungary)", "nativeName": "magyar (Magyarország)", "Sunday": "vasárnap", "Monday": "hétfő", "Tuesday": "kedd", "Wednesday": "szerda", "Thursday": "csütörtök", "Friday": "péntek", "Saturday": "szombat", "Sun": "V", "Mon": "H", "Tue": "K", "Wed": "Sze", "Thu": "Cs", "Fri": "P", "Sat": "Szo", "Su": "V", "Mo": "H", "Tu": "K", "We": "Sze", "Th": "Cs", "Fr": "P", "Sa": "Szo", "S_Sun_Initial": "V", "M_Mon_Initial": "H", "T_Tue_Initial": "K", "W_Wed_Initial": "S", "T_Thu_Initial": "C", "F_Fri_Initial": "P", "S_Sat_Initial": "S", "January": "január", "February": "február", "March": "március", "April": "április", "May": "május", "June": "június", "July": "július", "August": "augusztus", "September": "szeptember", "October": "október", "November": "november", "December": "december", "Jan_Abbr": "jan.", "Feb_Abbr": "febr.", "Mar_Abbr": "márc.", "Apr_Abbr": "ápr.", "May_Abbr": "máj.", "Jun_Abbr": "jún.", "Jul_Abbr": "júl.", "Aug_Abbr": "aug.", "Sep_Abbr": "szept.", "Oct_Abbr": "okt.", "Nov_Abbr": "nov.", "Dec_Abbr": "dec.", "AM": "de.", "PM": "du.", "firstDayOfWeek": 1, "twoDigitYearMax": 2029, "mdy": "ymd", "M/d/yyyy": "yyyy. MM. dd.", "dddd, MMMM dd, yyyy": "yyyy. MMMM d.", "h:mm tt": "H:mm", "h:mm:ss tt": "H:mm:ss", "dddd, MMMM dd, yyyy h:mm:ss tt": "yyyy. MMMM d. H:mm:ss", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "MMMM d.", "MMMM, yyyy": "yyyy. MMMM", "/jan(uary)?/": "jan(.(uár)?)?", "/feb(ruary)?/": "febr(.(uár)?)?", "/mar(ch)?/": "márc(.(ius)?)?", "/apr(il)?/": "ápr(.(ilis)?)?", "/may/": "máj(.(us)?)?", "/jun(e)?/": "jún(.(ius)?)?", "/jul(y)?/": "júl(.(ius)?)?", "/aug(ust)?/": "aug(.(usztus)?)?", "/sep(t(ember)?)?/": "szept(.(ember)?)?", "/oct(ober)?/": "okt(.(óber)?)?", "/nov(ember)?/": "nov(.(ember)?)?", "/dec(ember)?/": "dec(.(ember)?)?", "/^su(n(day)?)?/": "^vasárnap", "/^mo(n(day)?)?/": "^hétfő", "/^tu(e(s(day)?)?)?/": "^kedd", "/^we(d(nesday)?)?/": "^szerda", "/^th(u(r(s(day)?)?)?)?/": "^csütörtök", "/^fr(i(day)?)?/": "^péntek", "/^sa(t(urday)?)?/": "^szombat", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "hu-HU"; ================================================ FILE: build/i18n/hy-AM.js ================================================ /* * DateJS Culture String File * Country Code: hy-AM * Name: Armenian (Armenia) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["hy-AM"] = { "name": "hy-AM", "englishName": "Armenian (Armenia)", "nativeName": "Հայերեն (Հայաստան)", "Sunday": "Կիրակի", "Monday": "Երկուշաբթի", "Tuesday": "Երեքշաբթի", "Wednesday": "Չորեքշաբթի", "Thursday": "Հինգշաբթի", "Friday": "ՈՒրբաթ", "Saturday": "Շաբաթ", "Sun": "Կիր", "Mon": "Երկ", "Tue": "Երք", "Wed": "Չրք", "Thu": "Հնգ", "Fri": "ՈՒր", "Sat": "Շբթ", "Su": "Կ", "Mo": "Ե", "Tu": "Ե", "We": "Չ", "Th": "Հ", "Fr": "Ո", "Sa": "Շ", "S_Sun_Initial": "Կ", "M_Mon_Initial": "Ե", "T_Tue_Initial": "Ե", "W_Wed_Initial": "Չ", "T_Thu_Initial": "Հ", "F_Fri_Initial": "Ո", "S_Sat_Initial": "Շ", "January": "Հունվար", "February": "Փետրվար", "March": "Մարտ", "April": "Ապրիլ", "May": "Մայիս", "June": "Հունիս", "July": "Հուլիս", "August": "Օգոստոս", "September": "Սեպտեմբեր", "October": "Հոկտեմբեր", "November": "Նոյեմբեր", "December": "Դեկտեմբեր", "Jan_Abbr": "ՀՆՎ", "Feb_Abbr": "ՓՏՎ", "Mar_Abbr": "ՄՐՏ", "Apr_Abbr": "ԱՊՐ", "May_Abbr": "ՄՅՍ", "Jun_Abbr": "ՀՆՍ", "Jul_Abbr": "ՀԼՍ", "Aug_Abbr": "ՕԳՍ", "Sep_Abbr": "ՍԵՊ", "Oct_Abbr": "ՀՈԿ", "Nov_Abbr": "ՆՈՅ", "Dec_Abbr": "ԴԵԿ", "AM": "", "PM": "", "firstDayOfWeek": 1, "twoDigitYearMax": 2029, "mdy": "dmy", "M/d/yyyy": "dd.MM.yyyy", "dddd, MMMM dd, yyyy": "d MMMM, yyyy", "h:mm tt": "H:mm", "h:mm:ss tt": "H:mm:ss", "dddd, MMMM dd, yyyy h:mm:ss tt": "d MMMM, yyyy H:mm:ss", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "d MMMM", "MMMM, yyyy": "MMMM, yyyy", "/jan(uary)?/": "հունվար", "/feb(ruary)?/": "փետրվար", "/mar(ch)?/": "մարտ", "/apr(il)?/": "ապր(իլ)?", "/may/": "մայիս", "/jun(e)?/": "հունիս", "/jul(y)?/": "հուլիս", "/aug(ust)?/": "օգոստոս", "/sep(t(ember)?)?/": "սեպ(տեմբեր)?", "/oct(ober)?/": "հոկ(տեմբեր)?", "/nov(ember)?/": "նոյ(եմբեր)?", "/dec(ember)?/": "դեկ(տեմբեր)?", "/^su(n(day)?)?/": "^կ(իր(ակի)?)?", "/^mo(n(day)?)?/": "^ե(րկ(ուշաբթի)?)?", "/^tu(e(s(day)?)?)?/": "^ե(րք(քշաբթի)?)?", "/^we(d(nesday)?)?/": "^չ(րք(եքշաբթի)?)?", "/^th(u(r(s(day)?)?)?)?/": "^հ(նգ(գշաբթի)?)?", "/^fr(i(day)?)?/": "^ո(ւր(բաթ)?)?", "/^sa(t(urday)?)?/": "^շ(բթ(աթ)?)?", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "hy-AM"; ================================================ FILE: build/i18n/id-ID.js ================================================ /* * DateJS Culture String File * Country Code: id-ID * Name: Indonesian (Indonesia) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["id-ID"] = { "name": "id-ID", "englishName": "Indonesian (Indonesia)", "nativeName": "Bahasa Indonesia (Indonesia)", "Sunday": "Minggu", "Monday": "Senin", "Tuesday": "Selasa", "Wednesday": "Rabu", "Thursday": "Kamis", "Friday": "Jumat", "Saturday": "Sabtu", "Sun": "Minggu", "Mon": "Sen", "Tue": "Sel", "Wed": "Rabu", "Thu": "Kamis", "Fri": "Jumat", "Sat": "Sabtu", "Su": "M", "Mo": "S", "Tu": "S", "We": "R", "Th": "K", "Fr": "J", "Sa": "S", "S_Sun_Initial": "M", "M_Mon_Initial": "S", "T_Tue_Initial": "S", "W_Wed_Initial": "R", "T_Thu_Initial": "K", "F_Fri_Initial": "J", "S_Sat_Initial": "S", "January": "Januari", "February": "Februari", "March": "Maret", "April": "April", "May": "Mei", "June": "Juni", "July": "Juli", "August": "Agustus", "September": "September", "October": "Oktober", "November": "Nopember", "December": "Desember", "Jan_Abbr": "Jan", "Feb_Abbr": "Feb", "Mar_Abbr": "Mar", "Apr_Abbr": "Apr", "May_Abbr": "Mei", "Jun_Abbr": "Jun", "Jul_Abbr": "Jul", "Aug_Abbr": "Agust", "Sep_Abbr": "Sep", "Oct_Abbr": "Okt", "Nov_Abbr": "Nop", "Dec_Abbr": "Des", "AM": "", "PM": "", "firstDayOfWeek": 1, "twoDigitYearMax": 2029, "mdy": "dmy", "M/d/yyyy": "dd/MM/yyyy", "dddd, MMMM dd, yyyy": "dd MMMM yyyy", "h:mm tt": "H:mm", "h:mm:ss tt": "H:mm:ss", "dddd, MMMM dd, yyyy h:mm:ss tt": "dd MMMM yyyy H:mm:ss", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "dd MMMM", "MMMM, yyyy": "MMMM yyyy", "/jan(uary)?/": "jan(uari)?", "/feb(ruary)?/": "feb(ruari)?", "/mar(ch)?/": "mar(et)?", "/apr(il)?/": "apr(il)?", "/may/": "mei", "/jun(e)?/": "jun(i)?", "/jul(y)?/": "jul(i)?", "/aug(ust)?/": "agust(us)?", "/sep(t(ember)?)?/": "sep(t(ember)?)?", "/oct(ober)?/": "okt(ober)?", "/nov(ember)?/": "nop(ember)?", "/dec(ember)?/": "des(ember)?", "/^su(n(day)?)?/": "^m(1)?", "/^mo(n(day)?)?/": "^s(en(in)?)?", "/^tu(e(s(day)?)?)?/": "^s(el(asa)?)?", "/^we(d(nesday)?)?/": "^r(1)?", "/^th(u(r(s(day)?)?)?)?/": "^k(1)?", "/^fr(i(day)?)?/": "^j(1)?", "/^sa(t(urday)?)?/": "^s(1)?", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "id-ID"; ================================================ FILE: build/i18n/is-IS.js ================================================ /* * DateJS Culture String File * Country Code: is-IS * Name: Icelandic (Iceland) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["is-IS"] = { "name": "is-IS", "englishName": "Icelandic (Iceland)", "nativeName": "íslenska (Ísland)", "Sunday": "sunnudagur", "Monday": "mánudagur", "Tuesday": "þriðjudagur", "Wednesday": "miðvikudagur", "Thursday": "fimmtudagur", "Friday": "föstudagur", "Saturday": "laugardagur", "Sun": "sun.", "Mon": "mán.", "Tue": "þri.", "Wed": "mið.", "Thu": "fim.", "Fri": "fös.", "Sat": "lau.", "Su": "su", "Mo": "má", "Tu": "þr", "We": "mi", "Th": "fi", "Fr": "fö", "Sa": "la", "S_Sun_Initial": "s", "M_Mon_Initial": "m", "T_Tue_Initial": "þ", "W_Wed_Initial": "m", "T_Thu_Initial": "f", "F_Fri_Initial": "f", "S_Sat_Initial": "l", "January": "janúar", "February": "febrúar", "March": "mars", "April": "apríl", "May": "maí", "June": "júní", "July": "júlí", "August": "ágúst", "September": "september", "October": "október", "November": "nóvember", "December": "desember", "Jan_Abbr": "jan.", "Feb_Abbr": "feb.", "Mar_Abbr": "mar.", "Apr_Abbr": "apr.", "May_Abbr": "maí", "Jun_Abbr": "jún.", "Jul_Abbr": "júl.", "Aug_Abbr": "ágú.", "Sep_Abbr": "sep.", "Oct_Abbr": "okt.", "Nov_Abbr": "nóv.", "Dec_Abbr": "des.", "AM": "", "PM": "", "firstDayOfWeek": 1, "twoDigitYearMax": 2029, "mdy": "dmy", "M/d/yyyy": "d.M.yyyy", "dddd, MMMM dd, yyyy": "d. MMMM yyyy", "h:mm tt": "HH:mm", "h:mm:ss tt": "HH:mm:ss", "dddd, MMMM dd, yyyy h:mm:ss tt": "d. MMMM yyyy HH:mm:ss", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "d. MMMM", "MMMM, yyyy": "MMMM yyyy", "/jan(uary)?/": "jan(.(úar)?)?", "/feb(ruary)?/": "feb(.(rúar)?)?", "/mar(ch)?/": "mar(.(s)?)?", "/apr(il)?/": "apr(.(íl)?)?", "/may/": "maí", "/jun(e)?/": "jún(.(í)?)?", "/jul(y)?/": "júl(.(í)?)?", "/aug(ust)?/": "ágú(.(st)?)?", "/sep(t(ember)?)?/": "sep(t(ember)?)?", "/oct(ober)?/": "okt(.(óber)?)?", "/nov(ember)?/": "nóv(.(ember)?)?", "/dec(ember)?/": "des(.(ember)?)?", "/^su(n(day)?)?/": "^su(n(.(nudagur)?)?)?", "/^mo(n(day)?)?/": "^má(n(.(udagur)?)?)?", "/^tu(e(s(day)?)?)?/": "^þr(i(.(ðjudagur)?)?)?", "/^we(d(nesday)?)?/": "^mi(ð(.(vikudagur)?)?)?", "/^th(u(r(s(day)?)?)?)?/": "^fi(m(.(mtudagur)?)?)?", "/^fr(i(day)?)?/": "^fö(s(.(tudagur)?)?)?", "/^sa(t(urday)?)?/": "^la(u(.(gardagur)?)?)?", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "is-IS"; ================================================ FILE: build/i18n/it-CH.js ================================================ /* * DateJS Culture String File * Country Code: it-CH * Name: Italian (Switzerland) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["it-CH"] = { "name": "it-CH", "englishName": "Italian (Switzerland)", "nativeName": "italiano (Svizzera)", "Sunday": "domenica", "Monday": "lunedì", "Tuesday": "martedì", "Wednesday": "mercoledì", "Thursday": "giovedì", "Friday": "venerdì", "Saturday": "sabato", "Sun": "dom", "Mon": "lun", "Tue": "mar", "Wed": "mer", "Thu": "gio", "Fri": "ven", "Sat": "sab", "Su": "do", "Mo": "lu", "Tu": "ma", "We": "me", "Th": "gi", "Fr": "ve", "Sa": "sa", "S_Sun_Initial": "d", "M_Mon_Initial": "l", "T_Tue_Initial": "m", "W_Wed_Initial": "m", "T_Thu_Initial": "g", "F_Fri_Initial": "v", "S_Sat_Initial": "s", "January": "gennaio", "February": "febbraio", "March": "marzo", "April": "aprile", "May": "maggio", "June": "giugno", "July": "luglio", "August": "agosto", "September": "settembre", "October": "ottobre", "November": "novembre", "December": "dicembre", "Jan_Abbr": "gen", "Feb_Abbr": "feb", "Mar_Abbr": "mar", "Apr_Abbr": "apr", "May_Abbr": "mag", "Jun_Abbr": "gio", "Jul_Abbr": "lug", "Aug_Abbr": "ago", "Sep_Abbr": "set", "Oct_Abbr": "ott", "Nov_Abbr": "nov", "Dec_Abbr": "dic", "AM": "", "PM": "", "firstDayOfWeek": 1, "twoDigitYearMax": 2029, "mdy": "dmy", "M/d/yyyy": "dd.MM.yyyy", "dddd, MMMM dd, yyyy": "dddd, d. MMMM yyyy", "h:mm tt": "HH:mm", "h:mm:ss tt": "HH:mm:ss", "dddd, MMMM dd, yyyy h:mm:ss tt": "dddd, d. MMMM yyyy HH:mm:ss", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "d. MMMM", "MMMM, yyyy": "MMMM yyyy", "/jan(uary)?/": "gen(naio)?", "/feb(ruary)?/": "feb(braio)?", "/mar(ch)?/": "mar(zo)?", "/apr(il)?/": "apr(ile)?", "/may/": "mag(gio)?", "/jun(e)?/": "giugno", "/jul(y)?/": "lug(lio)?", "/aug(ust)?/": "ago(sto)?", "/sep(t(ember)?)?/": "set(tembre)?", "/oct(ober)?/": "ott(obre)?", "/nov(ember)?/": "nov(embre)?", "/dec(ember)?/": "dic(embre)?", "/^su(n(day)?)?/": "^do(m(enica)?)?", "/^mo(n(day)?)?/": "^lu(n(edì)?)?", "/^tu(e(s(day)?)?)?/": "^ma(r(tedì)?)?", "/^we(d(nesday)?)?/": "^me(r(coledì)?)?", "/^th(u(r(s(day)?)?)?)?/": "^gi(o(vedì)?)?", "/^fr(i(day)?)?/": "^ve(n(erdì)?)?", "/^sa(t(urday)?)?/": "^sa(b(ato)?)?", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "it-CH"; ================================================ FILE: build/i18n/it-IT.js ================================================ /* * DateJS Culture String File * Country Code: it-IT * Name: Italian (Italy) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["it-IT"] = { "name": "it-IT", "englishName": "Italian (Italy)", "nativeName": "italiano (Italia)", "Sunday": "domenica", "Monday": "lunedì", "Tuesday": "martedì", "Wednesday": "mercoledì", "Thursday": "giovedì", "Friday": "venerdì", "Saturday": "sabato", "Sun": "dom", "Mon": "lun", "Tue": "mar", "Wed": "mer", "Thu": "gio", "Fri": "ven", "Sat": "sab", "Su": "do", "Mo": "lu", "Tu": "ma", "We": "me", "Th": "gi", "Fr": "ve", "Sa": "sa", "S_Sun_Initial": "d", "M_Mon_Initial": "l", "T_Tue_Initial": "m", "W_Wed_Initial": "m", "T_Thu_Initial": "g", "F_Fri_Initial": "v", "S_Sat_Initial": "s", "January": "gennaio", "February": "febbraio", "March": "marzo", "April": "aprile", "May": "maggio", "June": "giugno", "July": "luglio", "August": "agosto", "September": "settembre", "October": "ottobre", "November": "novembre", "December": "dicembre", "Jan_Abbr": "gen", "Feb_Abbr": "feb", "Mar_Abbr": "mar", "Apr_Abbr": "apr", "May_Abbr": "mag", "Jun_Abbr": "giu", "Jul_Abbr": "lug", "Aug_Abbr": "ago", "Sep_Abbr": "set", "Oct_Abbr": "ott", "Nov_Abbr": "nov", "Dec_Abbr": "dic", "AM": "", "PM": "", "firstDayOfWeek": 1, "twoDigitYearMax": 2029, "mdy": "dmy", "M/d/yyyy": "dd/MM/yyyy", "dddd, MMMM dd, yyyy": "dddd d MMMM yyyy", "h:mm tt": "H.mm", "h:mm:ss tt": "H.mm.ss", "dddd, MMMM dd, yyyy h:mm:ss tt": "dddd d MMMM yyyy H.mm.ss", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "dd MMMM", "MMMM, yyyy": "MMMM yyyy", "/jan(uary)?/": "gen(naio)?", "/feb(ruary)?/": "feb(braio)?", "/mar(ch)?/": "mar(zo)?", "/apr(il)?/": "apr(ile)?", "/may/": "mag(gio)?", "/jun(e)?/": "giu(gno)?", "/jul(y)?/": "lug(lio)?", "/aug(ust)?/": "ago(sto)?", "/sep(t(ember)?)?/": "set(tembre)?", "/oct(ober)?/": "ott(obre)?", "/nov(ember)?/": "nov(embre)?", "/dec(ember)?/": "dic(embre)?", "/^su(n(day)?)?/": "^do(m(enica)?)?", "/^mo(n(day)?)?/": "^lu(n(edì)?)?", "/^tu(e(s(day)?)?)?/": "^ma(r(tedì)?)?", "/^we(d(nesday)?)?/": "^me(r(coledì)?)?", "/^th(u(r(s(day)?)?)?)?/": "^gi(o(vedì)?)?", "/^fr(i(day)?)?/": "^ve(n(erdì)?)?", "/^sa(t(urday)?)?/": "^sa(b(ato)?)?", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "it-IT"; ================================================ FILE: build/i18n/ja-JP.js ================================================ /* * DateJS Culture String File * Country Code: ja-JP * Name: Japanese (Japan) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["ja-JP"] = { "name": "ja-JP", "englishName": "Japanese (Japan)", "nativeName": "日本語 (日本)", "Sunday": "日曜日", "Monday": "月曜日", "Tuesday": "火曜日", "Wednesday": "水曜日", "Thursday": "木曜日", "Friday": "金曜日", "Saturday": "土曜日", "Sun": "日", "Mon": "月", "Tue": "火", "Wed": "水", "Thu": "木", "Fri": "金", "Sat": "土", "Su": "日", "Mo": "月", "Tu": "火", "We": "水", "Th": "木", "Fr": "金", "Sa": "土", "S_Sun_Initial": "日", "M_Mon_Initial": "月", "T_Tue_Initial": "火", "W_Wed_Initial": "水", "T_Thu_Initial": "木", "F_Fri_Initial": "金", "S_Sat_Initial": "土", "January": "1月", "February": "2月", "March": "3月", "April": "4月", "May": "5月", "June": "6月", "July": "7月", "August": "8月", "September": "9月", "October": "10月", "November": "11月", "December": "12月", "Jan_Abbr": "1", "Feb_Abbr": "2", "Mar_Abbr": "3", "Apr_Abbr": "4", "May_Abbr": "5", "Jun_Abbr": "6", "Jul_Abbr": "7", "Aug_Abbr": "8", "Sep_Abbr": "9", "Oct_Abbr": "10", "Nov_Abbr": "11", "Dec_Abbr": "12", "AM": "午前", "PM": "午後", "firstDayOfWeek": 0, "twoDigitYearMax": 2029, "mdy": "ymd", "M/d/yyyy": "yyyy/MM/dd", "dddd, MMMM dd, yyyy": "yyyy'年'M'月'd'日'", "h:mm tt": "H:mm", "h:mm:ss tt": "H:mm:ss", "dddd, MMMM dd, yyyy h:mm:ss tt": "yyyy'年'M'月'd'日' H:mm:ss", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "M'月'd'日'", "MMMM, yyyy": "yyyy'年'M'月'", "/jan(uary)?/": "1(月)?", "/feb(ruary)?/": "2(月)?", "/mar(ch)?/": "3(月)?", "/apr(il)?/": "4(月)?", "/may/": "5(月)?", "/jun(e)?/": "6(月)?", "/jul(y)?/": "7(月)?", "/aug(ust)?/": "8(月)?", "/sep(t(ember)?)?/": "9(月)?", "/oct(ober)?/": "10(月)?", "/nov(ember)?/": "11(月)?", "/dec(ember)?/": "12(月)?", "/^su(n(day)?)?/": "^日曜日", "/^mo(n(day)?)?/": "^月曜日", "/^tu(e(s(day)?)?)?/": "^火曜日", "/^we(d(nesday)?)?/": "^水曜日", "/^th(u(r(s(day)?)?)?)?/": "^木曜日", "/^fr(i(day)?)?/": "^金曜日", "/^sa(t(urday)?)?/": "^土曜日", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "ja-JP"; ================================================ FILE: build/i18n/ka-GE.js ================================================ /* * DateJS Culture String File * Country Code: ka-GE * Name: Georgian (Georgia) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["ka-GE"] = { "name": "ka-GE", "englishName": "Georgian (Georgia)", "nativeName": "ქართული (საქართველო)", "Sunday": "კვირა", "Monday": "ორშაბათი", "Tuesday": "სამშაბათი", "Wednesday": "ოთხშაბათი", "Thursday": "ხუთშაბათი", "Friday": "პარასკევი", "Saturday": "შაბათი", "Sun": "კვირა", "Mon": "ორშაბათი", "Tue": "სამშაბათი", "Wed": "ოთხშაბათი", "Thu": "ხუთშაბათი", "Fri": "პარასკევი", "Sat": "შაბათი", "Su": "კ", "Mo": "ო", "Tu": "ს", "We": "ო", "Th": "ხ", "Fr": "პ", "Sa": "შ", "S_Sun_Initial": "კ", "M_Mon_Initial": "ო", "T_Tue_Initial": "ს", "W_Wed_Initial": "ო", "T_Thu_Initial": "ხ", "F_Fri_Initial": "პ", "S_Sat_Initial": "შ", "January": "იანვარი", "February": "თებერვალი", "March": "მარტი", "April": "აპრილი", "May": "მაისი", "June": "ივნისი", "July": "ივლისი", "August": "აგვისტო", "September": "სექტემბერი", "October": "ოქტომბერი", "November": "ნოემბერი", "December": "დეკემბერი", "Jan_Abbr": "იან", "Feb_Abbr": "თებ", "Mar_Abbr": "მარ", "Apr_Abbr": "აპრ", "May_Abbr": "მაის", "Jun_Abbr": "ივნ", "Jul_Abbr": "ივლ", "Aug_Abbr": "აგვ", "Sep_Abbr": "სექ", "Oct_Abbr": "ოქტ", "Nov_Abbr": "ნოემ", "Dec_Abbr": "დეკ", "AM": "", "PM": "", "firstDayOfWeek": 1, "twoDigitYearMax": 2029, "mdy": "dmy", "M/d/yyyy": "dd.MM.yyyy", "dddd, MMMM dd, yyyy": "yyyy 'წლის' dd MM, dddd", "h:mm tt": "H:mm", "h:mm:ss tt": "H:mm:ss", "dddd, MMMM dd, yyyy h:mm:ss tt": "yyyy 'წლის' dd MM, dddd H:mm:ss", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "dd MM", "MMMM, yyyy": "MMMM yyyy", "/jan(uary)?/": "იან(ვარი)?", "/feb(ruary)?/": "თებ(ერვალი)?", "/mar(ch)?/": "მარ(ტი)?", "/apr(il)?/": "აპრ(ილი)?", "/may/": "მაის(ი)?", "/jun(e)?/": "ივნ(ისი)?", "/jul(y)?/": "ივლ(ისი)?", "/aug(ust)?/": "აგვ(ისტო)?", "/sep(t(ember)?)?/": "სექ(ტემბერი)?", "/oct(ober)?/": "ოქტ(ომბერი)?", "/nov(ember)?/": "ნოემ(ბერი)?", "/dec(ember)?/": "დეკ(ემბერი)?", "/^su(n(day)?)?/": "^კ(1)?", "/^mo(n(day)?)?/": "^ო(1)?", "/^tu(e(s(day)?)?)?/": "^ს(1)?", "/^we(d(nesday)?)?/": "^ო(1)?", "/^th(u(r(s(day)?)?)?)?/": "^ხ(1)?", "/^fr(i(day)?)?/": "^პ(1)?", "/^sa(t(urday)?)?/": "^შ(1)?", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "ka-GE"; ================================================ FILE: build/i18n/kk-KZ.js ================================================ /* * DateJS Culture String File * Country Code: kk-KZ * Name: Kazakh (Kazakhstan) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["kk-KZ"] = { "name": "kk-KZ", "englishName": "Kazakh (Kazakhstan)", "nativeName": "Қазақ (Қазақстан)", "Sunday": "Жексенбі", "Monday": "Дүйсенбі", "Tuesday": "Сейсенбі", "Wednesday": "Сәрсенбі", "Thursday": "Бейсенбі", "Friday": "Жұма", "Saturday": "Сенбі", "Sun": "Жк", "Mon": "Дс", "Tue": "Сс", "Wed": "Ср", "Thu": "Бс", "Fri": "Жм", "Sat": "Сн", "Su": "Жк", "Mo": "Дс", "Tu": "Сс", "We": "Ср", "Th": "Бс", "Fr": "Жм", "Sa": "Сн", "S_Sun_Initial": "Ж", "M_Mon_Initial": "Д", "T_Tue_Initial": "С", "W_Wed_Initial": "С", "T_Thu_Initial": "Б", "F_Fri_Initial": "Ж", "S_Sat_Initial": "С", "January": "қаңтар", "February": "ақпан", "March": "наурыз", "April": "сәуір", "May": "мамыр", "June": "маусым", "July": "шілде", "August": "тамыз", "September": "қыркүйек", "October": "қазан", "November": "қараша", "December": "желтоқсан", "Jan_Abbr": "Қаң", "Feb_Abbr": "Ақп", "Mar_Abbr": "Нау", "Apr_Abbr": "Сәу", "May_Abbr": "Мам", "Jun_Abbr": "Мау", "Jul_Abbr": "Шіл", "Aug_Abbr": "Там", "Sep_Abbr": "Қыр", "Oct_Abbr": "Қаз", "Nov_Abbr": "Қар", "Dec_Abbr": "Жел", "AM": "", "PM": "", "firstDayOfWeek": 1, "twoDigitYearMax": 2029, "mdy": "dmy", "M/d/yyyy": "dd.MM.yyyy", "dddd, MMMM dd, yyyy": "d MMMM yyyy 'ж.'", "h:mm tt": "H:mm", "h:mm:ss tt": "H:mm:ss", "dddd, MMMM dd, yyyy h:mm:ss tt": "d MMMM yyyy 'ж.' H:mm:ss", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "d MMMM", "MMMM, yyyy": "MMMM yyyy", "/jan(uary)?/": "қаң(тар)?", "/feb(ruary)?/": "ақп(ан)?", "/mar(ch)?/": "нау(рыз)?", "/apr(il)?/": "сәу(ір)?", "/may/": "мам(ыр)?", "/jun(e)?/": "мау(сым)?", "/jul(y)?/": "шіл(де)?", "/aug(ust)?/": "там(ыз)?", "/sep(t(ember)?)?/": "қыр(күйек)?", "/oct(ober)?/": "қаз(ан)?", "/nov(ember)?/": "қар(аша)?", "/dec(ember)?/": "жел(тоқсан)?", "/^su(n(day)?)?/": "^жексенбі", "/^mo(n(day)?)?/": "^дүйсенбі", "/^tu(e(s(day)?)?)?/": "^сейсенбі", "/^we(d(nesday)?)?/": "^сәрсенбі", "/^th(u(r(s(day)?)?)?)?/": "^бейсенбі", "/^fr(i(day)?)?/": "^жұма", "/^sa(t(urday)?)?/": "^сенбі", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "kk-KZ"; ================================================ FILE: build/i18n/kn-IN.js ================================================ /* * DateJS Culture String File * Country Code: kn-IN * Name: Kannada (India) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["kn-IN"] = { "name": "kn-IN", "englishName": "Kannada (India)", "nativeName": "ಕನ್ನಡ (ಭಾರತ)", "Sunday": "ಭಾನುವಾರ", "Monday": "ಸೋಮವಾರ", "Tuesday": "ಮಂಗಳವಾರ", "Wednesday": "ಬುಧವಾರ", "Thursday": "ಗುರುವಾರ", "Friday": "ಶುಕ್ರವಾರ", "Saturday": "ಶನಿವಾರ", "Sun": "ಭಾನು.", "Mon": "ಸೋಮ.", "Tue": "ಮಂಗಳ.", "Wed": "ಬುಧ.", "Thu": "ಗುರು.", "Fri": "ಶುಕ್ರ.", "Sat": "ಶನಿ.", "Su": "ರ", "Mo": "ಸ", "Tu": "ಮ", "We": "ಬ", "Th": "ಗ", "Fr": "ಶ", "Sa": "ಶ", "S_Sun_Initial": "ರ", "M_Mon_Initial": "ಸ", "T_Tue_Initial": "ಮ", "W_Wed_Initial": "ಬ", "T_Thu_Initial": "ಗ", "F_Fri_Initial": "ಶ", "S_Sat_Initial": "ಶ", "January": "ಜನವರಿ", "February": "ಫೆಬ್ರವರಿ", "March": "ಮಾರ್ಚ್", "April": "ಎಪ್ರಿಲ್", "May": "ಮೇ", "June": "ಜೂನ್", "July": "ಜುಲೈ", "August": "ಆಗಸ್ಟ್", "September": "ಸೆಪ್ಟಂಬರ್", "October": "ಅಕ್ಟೋಬರ್", "November": "ನವೆಂಬರ್", "December": "ಡಿಸೆಂಬರ್", "Jan_Abbr": "ಜನವರಿ", "Feb_Abbr": "ಫೆಬ್ರವರಿ", "Mar_Abbr": "ಮಾರ್ಚ್", "Apr_Abbr": "ಎಪ್ರಿಲ್", "May_Abbr": "ಮೇ", "Jun_Abbr": "ಜೂನ್", "Jul_Abbr": "ಜುಲೈ", "Aug_Abbr": "ಆಗಸ್ಟ್", "Sep_Abbr": "ಸೆಪ್ಟಂಬರ್", "Oct_Abbr": "ಅಕ್ಟೋಬರ್", "Nov_Abbr": "ನವೆಂಬರ್", "Dec_Abbr": "ಡಿಸೆಂಬರ್", "AM": "ಪೂರ್ವಾಹ್ನ", "PM": "ಅಪರಾಹ್ನ", "firstDayOfWeek": 1, "twoDigitYearMax": 2029, "mdy": "dmy", "M/d/yyyy": "dd-MM-yy", "dddd, MMMM dd, yyyy": "dd MMMM yyyy", "h:mm tt": "HH:mm", "h:mm:ss tt": "HH:mm:ss", "dddd, MMMM dd, yyyy h:mm:ss tt": "dd MMMM yyyy HH:mm:ss", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "dd MMMM", "MMMM, yyyy": "MMMM, yyyy", "/jan(uary)?/": "ಜನವರಿ", "/feb(ruary)?/": "ಫೆಬ್ರವರಿ", "/mar(ch)?/": "ಮಾರ್ಚ್", "/apr(il)?/": "ಎಪ್ರಿಲ್", "/may/": "ಮೇ", "/jun(e)?/": "ಜೂನ್", "/jul(y)?/": "ಜುಲೈ", "/aug(ust)?/": "ಆಗಸ್ಟ್", "/sep(t(ember)?)?/": "ಸೆಪ್ಟಂಬರ್", "/oct(ober)?/": "ಅಕ್ಟೋಬರ್", "/nov(ember)?/": "ನವೆಂಬರ್", "/dec(ember)?/": "ಡಿಸೆಂಬರ್", "/^su(n(day)?)?/": "^ರ(ಾನು(.(ವಾರ)?)?)?", "/^mo(n(day)?)?/": "^ಸ(ೋಮ(.(ವಾರ)?)?)?", "/^tu(e(s(day)?)?)?/": "^ಮ(ಂಗಳ(.(ವಾರ)?)?)?", "/^we(d(nesday)?)?/": "^ಬ(ುಧ(.(ವಾರ)?)?)?", "/^th(u(r(s(day)?)?)?)?/": "^ಗ(ುರು(.(ವಾರ)?)?)?", "/^fr(i(day)?)?/": "^ಶ(ುಕ್ರ(.(ವಾರ)?)?)?", "/^sa(t(urday)?)?/": "^ಶ(ನಿ(.(ವಾರ)?)?)?", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "kn-IN"; ================================================ FILE: build/i18n/ko-KR.js ================================================ /* * DateJS Culture String File * Country Code: ko-KR * Name: Korean (Korea) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["ko-KR"] = { "name": "ko-KR", "englishName": "Korean (Korea)", "nativeName": "한국어 (대한민국)", "Sunday": "일요일", "Monday": "월요일", "Tuesday": "화요일", "Wednesday": "수요일", "Thursday": "목요일", "Friday": "금요일", "Saturday": "토요일", "Sun": "일", "Mon": "월", "Tue": "화", "Wed": "수", "Thu": "목", "Fri": "금", "Sat": "토", "Su": "일", "Mo": "월", "Tu": "화", "We": "수", "Th": "목", "Fr": "금", "Sa": "토", "S_Sun_Initial": "일", "M_Mon_Initial": "월", "T_Tue_Initial": "화", "W_Wed_Initial": "수", "T_Thu_Initial": "목", "F_Fri_Initial": "금", "S_Sat_Initial": "토", "January": "1월", "February": "2월", "March": "3월", "April": "4월", "May": "5월", "June": "6월", "July": "7월", "August": "8월", "September": "9월", "October": "10월", "November": "11월", "December": "12월", "Jan_Abbr": "1", "Feb_Abbr": "2", "Mar_Abbr": "3", "Apr_Abbr": "4", "May_Abbr": "5", "Jun_Abbr": "6", "Jul_Abbr": "7", "Aug_Abbr": "8", "Sep_Abbr": "9", "Oct_Abbr": "10", "Nov_Abbr": "11", "Dec_Abbr": "12", "AM": "오전", "PM": "오후", "firstDayOfWeek": 0, "twoDigitYearMax": 2029, "mdy": "ymd", "M/d/yyyy": "yyyy-MM-dd", "dddd, MMMM dd, yyyy": "yyyy'년' M'월' d'일' dddd", "h:mm tt": "tt h:mm", "h:mm:ss tt": "tt h:mm:ss", "dddd, MMMM dd, yyyy h:mm:ss tt": "yyyy'년' M'월' d'일' dddd tt h:mm:ss", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "M'월' d'일'", "MMMM, yyyy": "yyyy'년' M'월'", "/jan(uary)?/": "1(월)?", "/feb(ruary)?/": "2(월)?", "/mar(ch)?/": "3(월)?", "/apr(il)?/": "4(월)?", "/may/": "5(월)?", "/jun(e)?/": "6(월)?", "/jul(y)?/": "7(월)?", "/aug(ust)?/": "8(월)?", "/sep(t(ember)?)?/": "9(월)?", "/oct(ober)?/": "10(월)?", "/nov(ember)?/": "11(월)?", "/dec(ember)?/": "12(월)?", "/^su(n(day)?)?/": "^일요일", "/^mo(n(day)?)?/": "^월요일", "/^tu(e(s(day)?)?)?/": "^화요일", "/^we(d(nesday)?)?/": "^수요일", "/^th(u(r(s(day)?)?)?)?/": "^목요일", "/^fr(i(day)?)?/": "^금요일", "/^sa(t(urday)?)?/": "^토요일", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "ko-KR"; ================================================ FILE: build/i18n/kok-IN.js ================================================ /* * DateJS Culture String File * Country Code: kok-IN * Name: Konkani (India) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["kok-IN"] = { "name": "kok-IN", "englishName": "Konkani (India)", "nativeName": "कोंकणी (भारत)", "Sunday": "आयतार", "Monday": "सोमार", "Tuesday": "मंगळार", "Wednesday": "बुधवार", "Thursday": "बिरेस्तार", "Friday": "सुक्रार", "Saturday": "शेनवार", "Sun": "आय.", "Mon": "सोम.", "Tue": "मंगळ.", "Wed": "बुध.", "Thu": "बिरे.", "Fri": "सुक्र.", "Sat": "शेन.", "Su": "आ", "Mo": "स", "Tu": "म", "We": "ब", "Th": "ब", "Fr": "स", "Sa": "श", "S_Sun_Initial": "आ", "M_Mon_Initial": "स", "T_Tue_Initial": "म", "W_Wed_Initial": "ब", "T_Thu_Initial": "ब", "F_Fri_Initial": "स", "S_Sat_Initial": "श", "January": "जानेवारी", "February": "फेब्रुवारी", "March": "मार्च", "April": "एप्रिल", "May": "मे", "June": "जून", "July": "जुलै", "August": "ऑगस्ट", "September": "सप्टेंबर", "October": "ऑक्टोबर", "November": "नोवेम्बर", "December": "डिसेंबर", "Jan_Abbr": "जानेवारी", "Feb_Abbr": "फेब्रुवारी", "Mar_Abbr": "मार्च", "Apr_Abbr": "एप्रिल", "May_Abbr": "मे", "Jun_Abbr": "जून", "Jul_Abbr": "जुलै", "Aug_Abbr": "ऑगस्ट", "Sep_Abbr": "सप्टेंबर", "Oct_Abbr": "ऑक्टोबर", "Nov_Abbr": "नोवेम्बर", "Dec_Abbr": "डिसेंबर", "AM": "म.पू.", "PM": "म.नं.", "firstDayOfWeek": 1, "twoDigitYearMax": 2029, "mdy": "dmy", "M/d/yyyy": "dd-MM-yyyy", "dddd, MMMM dd, yyyy": "dd MMMM yyyy", "h:mm tt": "HH:mm", "h:mm:ss tt": "HH:mm:ss", "dddd, MMMM dd, yyyy h:mm:ss tt": "dd MMMM yyyy HH:mm:ss", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "dd MMMM", "MMMM, yyyy": "MMMM, yyyy", "/jan(uary)?/": "जानेवारी", "/feb(ruary)?/": "फेब्रुवारी", "/mar(ch)?/": "मार्च", "/apr(il)?/": "एप्रिल", "/may/": "मे", "/jun(e)?/": "जून", "/jul(y)?/": "जुलै", "/aug(ust)?/": "ऑगस्ट", "/sep(t(ember)?)?/": "सप्टेंबर", "/oct(ober)?/": "ऑक्टोबर", "/nov(ember)?/": "नोवेम्बर", "/dec(ember)?/": "डिसेंबर", "/^su(n(day)?)?/": "^आ(य(.(तार)?)?)?", "/^mo(n(day)?)?/": "^स(ोम(.(ार)?)?)?", "/^tu(e(s(day)?)?)?/": "^म(ंगळ(.(ार)?)?)?", "/^we(d(nesday)?)?/": "^ब(ुध(.(वार)?)?)?", "/^th(u(r(s(day)?)?)?)?/": "^ब(िरे(.(स्तार)?)?)?", "/^fr(i(day)?)?/": "^स(ुक्र(.(ार)?)?)?", "/^sa(t(urday)?)?/": "^श(ेन(.(वार)?)?)?", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "kok-IN"; ================================================ FILE: build/i18n/ky-KG.js ================================================ /* * DateJS Culture String File * Country Code: ky-KG * Name: Kyrgyz (Kyrgyzstan) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["ky-KG"] = { "name": "ky-KG", "englishName": "Kyrgyz (Kyrgyzstan)", "nativeName": "Кыргыз (Кыргызстан)", "Sunday": "Жекшемби", "Monday": "Дүйшөмбү", "Tuesday": "Шейшемби", "Wednesday": "Шаршемби", "Thursday": "Бейшемби", "Friday": "Жума", "Saturday": "Ишемби", "Sun": "Жш", "Mon": "Дш", "Tue": "Шш", "Wed": "Шр", "Thu": "Бш", "Fri": "Жм", "Sat": "Иш", "Su": "Жш", "Mo": "Дш", "Tu": "Шш", "We": "Шр", "Th": "Бш", "Fr": "Жм", "Sa": "Иш", "S_Sun_Initial": "Ж", "M_Mon_Initial": "Д", "T_Tue_Initial": "Ш", "W_Wed_Initial": "Ш", "T_Thu_Initial": "Б", "F_Fri_Initial": "Ж", "S_Sat_Initial": "И", "January": "Январь", "February": "Февраль", "March": "Март", "April": "Апрель", "May": "Май", "June": "Июнь", "July": "Июль", "August": "Август", "September": "Сентябрь", "October": "Октябрь", "November": "Ноябрь", "December": "Декабрь", "Jan_Abbr": "Янв", "Feb_Abbr": "Фев", "Mar_Abbr": "Мар", "Apr_Abbr": "Апр", "May_Abbr": "Май", "Jun_Abbr": "Июн", "Jul_Abbr": "Июл", "Aug_Abbr": "Авг", "Sep_Abbr": "Сен", "Oct_Abbr": "Окт", "Nov_Abbr": "Ноя", "Dec_Abbr": "Дек", "AM": "", "PM": "", "firstDayOfWeek": 1, "twoDigitYearMax": 2029, "mdy": "dmy", "M/d/yyyy": "dd.MM.yy", "dddd, MMMM dd, yyyy": "d'-'MMMM yyyy'-ж.'", "h:mm tt": "H:mm", "h:mm:ss tt": "H:mm:ss", "dddd, MMMM dd, yyyy h:mm:ss tt": "d'-'MMMM yyyy'-ж.' H:mm:ss", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "d MMMM", "MMMM, yyyy": "MMMM yyyy'-ж.'", "/jan(uary)?/": "янв(арь)?", "/feb(ruary)?/": "фев(раль)?", "/mar(ch)?/": "мар(т)?", "/apr(il)?/": "апр(ель)?", "/may/": "май", "/jun(e)?/": "июн(ь)?", "/jul(y)?/": "июл(ь)?", "/aug(ust)?/": "авг(уст)?", "/sep(t(ember)?)?/": "сен(тябрь)?", "/oct(ober)?/": "окт(ябрь)?", "/nov(ember)?/": "ноя(брь)?", "/dec(ember)?/": "дек(абрь)?", "/^su(n(day)?)?/": "^жекшемби", "/^mo(n(day)?)?/": "^дүйшөмбү", "/^tu(e(s(day)?)?)?/": "^шейшемби", "/^we(d(nesday)?)?/": "^шаршемби", "/^th(u(r(s(day)?)?)?)?/": "^бейшемби", "/^fr(i(day)?)?/": "^жума", "/^sa(t(urday)?)?/": "^ишемби", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "ky-KG"; ================================================ FILE: build/i18n/lt-LT.js ================================================ /* * DateJS Culture String File * Country Code: lt-LT * Name: Lithuanian (Lithuania) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["lt-LT"] = { "name": "lt-LT", "englishName": "Lithuanian (Lithuania)", "nativeName": "lietuvių (Lietuva)", "Sunday": "sekmadienis", "Monday": "pirmadienis", "Tuesday": "antradienis", "Wednesday": "trečiadienis", "Thursday": "ketvirtadienis", "Friday": "penktadienis", "Saturday": "šeštadienis", "Sun": "Sk", "Mon": "Pr", "Tue": "An", "Wed": "Tr", "Thu": "Kt", "Fri": "Pn", "Sat": "Št", "Su": "S", "Mo": "P", "Tu": "A", "We": "T", "Th": "K", "Fr": "Pn", "Sa": "Š", "S_Sun_Initial": "S", "M_Mon_Initial": "P", "T_Tue_Initial": "A", "W_Wed_Initial": "T", "T_Thu_Initial": "K", "F_Fri_Initial": "P", "S_Sat_Initial": "Š", "January": "sausis", "February": "vasaris", "March": "kovas", "April": "balandis", "May": "gegužė", "June": "birželis", "July": "liepa", "August": "rugpjūtis", "September": "rugsėjis", "October": "spalis", "November": "lapkritis", "December": "gruodis", "Jan_Abbr": "Sau", "Feb_Abbr": "Vas", "Mar_Abbr": "Kov", "Apr_Abbr": "Bal", "May_Abbr": "Geg", "Jun_Abbr": "Bir", "Jul_Abbr": "Lie", "Aug_Abbr": "Rgp", "Sep_Abbr": "Rgs", "Oct_Abbr": "Spl", "Nov_Abbr": "Lap", "Dec_Abbr": "Grd", "AM": "", "PM": "", "firstDayOfWeek": 1, "twoDigitYearMax": 2029, "mdy": "ymd", "M/d/yyyy": "yyyy.MM.dd", "dddd, MMMM dd, yyyy": "yyyy 'm.' MMMM d 'd.'", "h:mm tt": "HH:mm", "h:mm:ss tt": "HH:mm:ss", "dddd, MMMM dd, yyyy h:mm:ss tt": "yyyy 'm.' MMMM d 'd.' HH:mm:ss", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "MMMM d 'd.'", "MMMM, yyyy": "yyyy 'm.' MMMM", "/jan(uary)?/": "sau(sis)?", "/feb(ruary)?/": "vas(aris)?", "/mar(ch)?/": "kov(as)?", "/apr(il)?/": "bal(andis)?", "/may/": "geg(užė)?", "/jun(e)?/": "bir(želis)?", "/jul(y)?/": "lie(pa)?", "/aug(ust)?/": "rugpjūtis", "/sep(t(ember)?)?/": "rugsėjis", "/oct(ober)?/": "spalis", "/nov(ember)?/": "lap(kritis)?", "/dec(ember)?/": "gruodis", "/^su(n(day)?)?/": "^s(k(kmadienis)?)?", "/^mo(n(day)?)?/": "^p(r(rmadienis)?)?", "/^tu(e(s(day)?)?)?/": "^a(n(tradienis)?)?", "/^we(d(nesday)?)?/": "^t(r(ečiadienis)?)?", "/^th(u(r(s(day)?)?)?)?/": "^k(t(tvirtadienis)?)?", "/^fr(i(day)?)?/": "^penktadienis", "/^sa(t(urday)?)?/": "^š(t(štadienis)?)?", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "lt-LT"; ================================================ FILE: build/i18n/lv-LV.js ================================================ /* * DateJS Culture String File * Country Code: lv-LV * Name: Latvian (Latvia) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["lv-LV"] = { "name": "lv-LV", "englishName": "Latvian (Latvia)", "nativeName": "latviešu (Latvija)", "Sunday": "svētdiena", "Monday": "pirmdiena", "Tuesday": "otrdiena", "Wednesday": "trešdiena", "Thursday": "ceturtdiena", "Friday": "piektdiena", "Saturday": "sestdiena", "Sun": "Sv", "Mon": "Pr", "Tue": "Ot", "Wed": "Tr", "Thu": "Ce", "Fri": "Pk", "Sat": "Se", "Su": "Sv", "Mo": "Pr", "Tu": "Ot", "We": "Tr", "Th": "Ce", "Fr": "Pk", "Sa": "Se", "S_Sun_Initial": "S", "M_Mon_Initial": "P", "T_Tue_Initial": "O", "W_Wed_Initial": "T", "T_Thu_Initial": "C", "F_Fri_Initial": "P", "S_Sat_Initial": "S", "January": "janvāris", "February": "februāris", "March": "marts", "April": "aprīlis", "May": "maijs", "June": "jūnijs", "July": "jūlijs", "August": "augusts", "September": "septembris", "October": "oktobris", "November": "novembris", "December": "decembris", "Jan_Abbr": "Jan", "Feb_Abbr": "Feb", "Mar_Abbr": "Mar", "Apr_Abbr": "Apr", "May_Abbr": "Mai", "Jun_Abbr": "Jūn", "Jul_Abbr": "Jūl", "Aug_Abbr": "Aug", "Sep_Abbr": "Sep", "Oct_Abbr": "Okt", "Nov_Abbr": "Nov", "Dec_Abbr": "Dec", "AM": "", "PM": "", "firstDayOfWeek": 1, "twoDigitYearMax": 2029, "mdy": "ymd", "M/d/yyyy": "yyyy.MM.dd.", "dddd, MMMM dd, yyyy": "dddd, yyyy'. gada 'd. MMMM", "h:mm tt": "H:mm", "h:mm:ss tt": "H:mm:ss", "dddd, MMMM dd, yyyy h:mm:ss tt": "dddd, yyyy'. gada 'd. MMMM H:mm:ss", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "d. MMMM", "MMMM, yyyy": "yyyy. MMMM", "/jan(uary)?/": "jan(vāris)?", "/feb(ruary)?/": "feb(ruāris)?", "/mar(ch)?/": "mar(ts)?", "/apr(il)?/": "apr(īlis)?", "/may/": "mai(js)?", "/jun(e)?/": "jūn(ijs)?", "/jul(y)?/": "jūl(ijs)?", "/aug(ust)?/": "aug(usts)?", "/sep(t(ember)?)?/": "sep(tembris)?", "/oct(ober)?/": "okt(obris)?", "/nov(ember)?/": "nov(embris)?", "/dec(ember)?/": "dec(embris)?", "/^su(n(day)?)?/": "^svētdiena", "/^mo(n(day)?)?/": "^pirmdiena", "/^tu(e(s(day)?)?)?/": "^otrdiena", "/^we(d(nesday)?)?/": "^trešdiena", "/^th(u(r(s(day)?)?)?)?/": "^ceturtdiena", "/^fr(i(day)?)?/": "^piektdiena", "/^sa(t(urday)?)?/": "^sestdiena", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "lv-LV"; ================================================ FILE: build/i18n/mi-NZ.js ================================================ /* * DateJS Culture String File * Country Code: mi-NZ * Name: Maori (New Zealand) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["mi-NZ"] = { "name": "mi-NZ", "englishName": "Maori (New Zealand)", "nativeName": "Reo Māori (Aotearoa)", "Sunday": "Rātapu", "Monday": "Mane", "Tuesday": "Tūrei", "Wednesday": "Wenerei", "Thursday": "Tāite", "Friday": "Paraire", "Saturday": "Hātarei", "Sun": "Ta", "Mon": "Ma", "Tue": "Tū", "Wed": "We", "Thu": "Tāi", "Fri": "Pa", "Sat": "Hā", "Su": "Ta", "Mo": "Ma", "Tu": "Tū", "We": "We", "Th": "Tāi", "Fr": "Pa", "Sa": "Hā", "S_Sun_Initial": "T", "M_Mon_Initial": "M", "T_Tue_Initial": "T", "W_Wed_Initial": "W", "T_Thu_Initial": "T", "F_Fri_Initial": "P", "S_Sat_Initial": "H", "January": "Kohi-tātea", "February": "Hui-tanguru", "March": "Poutū-te-rangi", "April": "Paenga-whāwhā", "May": "Haratua", "June": "Pipiri", "July": "Hōngoingoi", "August": "Here-turi-kōkā", "September": "Mahuru", "October": "Whiringa-ā-nuku", "November": "Whiringa-ā-rangi", "December": "Hakihea", "Jan_Abbr": "Kohi", "Feb_Abbr": "Hui", "Mar_Abbr": "Pou", "Apr_Abbr": "Pae", "May_Abbr": "Hara", "Jun_Abbr": "Pipi", "Jul_Abbr": "Hōngoi", "Aug_Abbr": "Here", "Sep_Abbr": "Mahu", "Oct_Abbr": "Whi-nu", "Nov_Abbr": "Whi-ra", "Dec_Abbr": "Haki", "AM": "a.m.", "PM": "p.m.", "firstDayOfWeek": 1, "twoDigitYearMax": 2029, "mdy": "dmy", "M/d/yyyy": "d/MM/yyyy", "dddd, MMMM dd, yyyy": "dddd, d MMMM yyyy", "h:mm tt": "h:mm:ss tt", "h:mm:ss tt": "h:mm:ss tt", "dddd, MMMM dd, yyyy h:mm:ss tt": "dddd, d MMMM yyyy h:mm:ss tt", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "MMMM dd", "MMMM, yyyy": "MMMM yyyy", "/jan(uary)?/": "kohi(-tātea)?", "/feb(ruary)?/": "hui(-tanguru)?", "/mar(ch)?/": "pou(tū-te-rangi)?", "/apr(il)?/": "pae(nga-whāwhā)?", "/may/": "hara(tua)?", "/jun(e)?/": "pipi(ri)?", "/jul(y)?/": "hōngoi(ngoi)?", "/aug(ust)?/": "here(-turi-kōkā)?", "/sep(t(ember)?)?/": "mahu(ru)?", "/oct(ober)?/": "whiringa-ā-nuku", "/nov(ember)?/": "whiringa-ā-rangi", "/dec(ember)?/": "haki(hea)?", "/^su(n(day)?)?/": "^rātapu", "/^mo(n(day)?)?/": "^mane", "/^tu(e(s(day)?)?)?/": "^tūrei", "/^we(d(nesday)?)?/": "^wenerei", "/^th(u(r(s(day)?)?)?)?/": "^tāite", "/^fr(i(day)?)?/": "^paraire", "/^sa(t(urday)?)?/": "^hātarei", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "mi-NZ"; ================================================ FILE: build/i18n/mk-MK.js ================================================ /* * DateJS Culture String File * Country Code: mk-MK * Name: Macedonian (Former Yugoslav Republic of Macedonia) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["mk-MK"] = { "name": "mk-MK", "englishName": "Macedonian (Former Yugoslav Republic of Macedonia)", "nativeName": "македонски јазик (Македонија)", "Sunday": "недела", "Monday": "понеделник", "Tuesday": "вторник", "Wednesday": "среда", "Thursday": "четврток", "Friday": "петок", "Saturday": "сабота", "Sun": "нед", "Mon": "пон", "Tue": "втр", "Wed": "срд", "Thu": "чет", "Fri": "пет", "Sat": "саб", "Su": "не", "Mo": "по", "Tu": "вт", "We": "ср", "Th": "че", "Fr": "пе", "Sa": "са", "S_Sun_Initial": "н", "M_Mon_Initial": "п", "T_Tue_Initial": "в", "W_Wed_Initial": "с", "T_Thu_Initial": "ч", "F_Fri_Initial": "п", "S_Sat_Initial": "с", "January": "јануари", "February": "февруари", "March": "март", "April": "април", "May": "мај", "June": "јуни", "July": "јули", "August": "август", "September": "септември", "October": "октомври", "November": "ноември", "December": "декември", "Jan_Abbr": "јан", "Feb_Abbr": "фев", "Mar_Abbr": "мар", "Apr_Abbr": "апр", "May_Abbr": "мај", "Jun_Abbr": "јун", "Jul_Abbr": "јул", "Aug_Abbr": "авг", "Sep_Abbr": "сеп", "Oct_Abbr": "окт", "Nov_Abbr": "ное", "Dec_Abbr": "дек", "AM": "", "PM": "", "firstDayOfWeek": 1, "twoDigitYearMax": 2029, "mdy": "dmy", "M/d/yyyy": "dd.MM.yyyy", "dddd, MMMM dd, yyyy": "dddd, dd MMMM yyyy", "h:mm tt": "HH:mm", "h:mm:ss tt": "HH:mm:ss", "dddd, MMMM dd, yyyy h:mm:ss tt": "dddd, dd MMMM yyyy HH:mm:ss", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "dd MMMM", "MMMM, yyyy": "MMMM yyyy", "/jan(uary)?/": "јан(уари)?", "/feb(ruary)?/": "фев(руари)?", "/mar(ch)?/": "мар(т)?", "/apr(il)?/": "апр(ил)?", "/may/": "мај", "/jun(e)?/": "јун(и)?", "/jul(y)?/": "јул(и)?", "/aug(ust)?/": "авг(уст)?", "/sep(t(ember)?)?/": "сеп(тември)?", "/oct(ober)?/": "окт(омври)?", "/nov(ember)?/": "ное(мври)?", "/dec(ember)?/": "дек(ември)?", "/^su(n(day)?)?/": "^не(д(ела)?)?", "/^mo(n(day)?)?/": "^по(н(еделник)?)?", "/^tu(e(s(day)?)?)?/": "^вт(р(рник)?)?", "/^we(d(nesday)?)?/": "^ср(д(да)?)?", "/^th(u(r(s(day)?)?)?)?/": "^че(т(врток)?)?", "/^fr(i(day)?)?/": "^пе(т(ок)?)?", "/^sa(t(urday)?)?/": "^са(б(ота)?)?", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "mk-MK"; ================================================ FILE: build/i18n/mn-MN.js ================================================ /* * DateJS Culture String File * Country Code: mn-MN * Name: Mongolian (Cyrillic, Mongolia) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["mn-MN"] = { "name": "mn-MN", "englishName": "Mongolian (Cyrillic, Mongolia)", "nativeName": "Монгол хэл (Монгол улс)", "Sunday": "Ням", "Monday": "Даваа", "Tuesday": "Мягмар", "Wednesday": "Лхагва", "Thursday": "Пүрэв", "Friday": "Баасан", "Saturday": "Бямба", "Sun": "Ня", "Mon": "Да", "Tue": "Мя", "Wed": "Лх", "Thu": "Пү", "Fri": "Ба", "Sat": "Бя", "Su": "Ня", "Mo": "Да", "Tu": "Мя", "We": "Лх", "Th": "Пү", "Fr": "Ба", "Sa": "Бя", "S_Sun_Initial": "Н", "M_Mon_Initial": "Д", "T_Tue_Initial": "М", "W_Wed_Initial": "Л", "T_Thu_Initial": "П", "F_Fri_Initial": "Б", "S_Sat_Initial": "Б", "January": "1 дүгээр сар", "February": "2 дугаар сар", "March": "3 дугаар сар", "April": "4 дүгээр сар", "May": "5 дугаар сар", "June": "6 дугаар сар", "July": "7 дугаар сар", "August": "8 дугаар сар", "September": "9 дүгээр сар", "October": "10 дугаар сар", "November": "11 дүгээр сар", "December": "12 дугаар сар", "Jan_Abbr": "I", "Feb_Abbr": "II", "Mar_Abbr": "III", "Apr_Abbr": "IV", "May_Abbr": "V", "Jun_Abbr": "VI", "Jul_Abbr": "VII", "Aug_Abbr": "VШ", "Sep_Abbr": "IX", "Oct_Abbr": "X", "Nov_Abbr": "XI", "Dec_Abbr": "XII", "AM": "", "PM": "", "firstDayOfWeek": 1, "twoDigitYearMax": 2029, "mdy": "ymd", "M/d/yyyy": "yy.MM.dd", "dddd, MMMM dd, yyyy": "yyyy 'оны' MMMM d", "h:mm tt": "H:mm", "h:mm:ss tt": "H:mm:ss", "dddd, MMMM dd, yyyy h:mm:ss tt": "yyyy 'оны' MMMM d H:mm:ss", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "d MMMM", "MMMM, yyyy": "yyyy 'он' MMMM", "/jan(uary)?/": "1 дүгээр сар", "/feb(ruary)?/": "2 дугаар сар", "/mar(ch)?/": "3 дугаар сар", "/apr(il)?/": "4 дүгээр сар", "/may/": "5 дугаар сар", "/jun(e)?/": "6 дугаар сар", "/jul(y)?/": "7 дугаар сар", "/aug(ust)?/": "8 дугаар сар", "/sep(t(ember)?)?/": "9 дүгээр сар", "/oct(ober)?/": "10 дугаар сар", "/nov(ember)?/": "11 дүгээр сар", "/dec(ember)?/": "12 дугаар сар", "/^su(n(day)?)?/": "^ням", "/^mo(n(day)?)?/": "^даваа", "/^tu(e(s(day)?)?)?/": "^мягмар", "/^we(d(nesday)?)?/": "^лхагва", "/^th(u(r(s(day)?)?)?)?/": "^пүрэв", "/^fr(i(day)?)?/": "^баасан", "/^sa(t(urday)?)?/": "^бямба", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "mn-MN"; ================================================ FILE: build/i18n/mr-IN.js ================================================ /* * DateJS Culture String File * Country Code: mr-IN * Name: Marathi (India) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["mr-IN"] = { "name": "mr-IN", "englishName": "Marathi (India)", "nativeName": "मराठी (भारत)", "Sunday": "रविवार", "Monday": "सोमवार", "Tuesday": "मंगळवार", "Wednesday": "बुधवार", "Thursday": "गुरुवार", "Friday": "शुक्रवार", "Saturday": "शनिवार", "Sun": "रवि.", "Mon": "सोम.", "Tue": "मंगळ.", "Wed": "बुध.", "Thu": "गुरु.", "Fri": "शुक्र.", "Sat": "शनि.", "Su": "र", "Mo": "स", "Tu": "म", "We": "ब", "Th": "ग", "Fr": "श", "Sa": "श", "S_Sun_Initial": "र", "M_Mon_Initial": "स", "T_Tue_Initial": "म", "W_Wed_Initial": "ब", "T_Thu_Initial": "ग", "F_Fri_Initial": "श", "S_Sat_Initial": "श", "January": "जानेवारी", "February": "फेब्रुवारी", "March": "मार्च", "April": "एप्रिल", "May": "मे", "June": "जून", "July": "जुलै", "August": "ऑगस्ट", "September": "सप्टेंबर", "October": "ऑक्टोबर", "November": "नोव्हेंबर", "December": "डिसेंबर", "Jan_Abbr": "जाने.", "Feb_Abbr": "फेब्रु.", "Mar_Abbr": "मार्च", "Apr_Abbr": "एप्रिल", "May_Abbr": "मे", "Jun_Abbr": "जून", "Jul_Abbr": "जुलै", "Aug_Abbr": "ऑगस्ट", "Sep_Abbr": "सप्टें.", "Oct_Abbr": "ऑक्टो.", "Nov_Abbr": "नोव्हें.", "Dec_Abbr": "डिसें.", "AM": "म.पू.", "PM": "म.नं.", "firstDayOfWeek": 1, "twoDigitYearMax": 2029, "mdy": "dmy", "M/d/yyyy": "dd-MM-yyyy", "dddd, MMMM dd, yyyy": "dd MMMM yyyy", "h:mm tt": "HH:mm", "h:mm:ss tt": "HH:mm:ss", "dddd, MMMM dd, yyyy h:mm:ss tt": "dd MMMM yyyy HH:mm:ss", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "dd MMMM", "MMMM, yyyy": "MMMM, yyyy", "/jan(uary)?/": "जाने(.(वारी)?)?", "/feb(ruary)?/": "फेब्रु(.(वारी)?)?", "/mar(ch)?/": "मार्च", "/apr(il)?/": "एप्रिल", "/may/": "मे", "/jun(e)?/": "जून", "/jul(y)?/": "जुलै", "/aug(ust)?/": "ऑगस्ट", "/sep(t(ember)?)?/": "सप्टें(.(बर)?)?", "/oct(ober)?/": "ऑक्टो(.(बर)?)?", "/nov(ember)?/": "नोव्हें(.(बर)?)?", "/dec(ember)?/": "डिसें(.(बर)?)?", "/^su(n(day)?)?/": "^र(वि(.(वार)?)?)?", "/^mo(n(day)?)?/": "^स(ोम(.(वार)?)?)?", "/^tu(e(s(day)?)?)?/": "^म(ंगळ(.(वार)?)?)?", "/^we(d(nesday)?)?/": "^ब(ुध(.(वार)?)?)?", "/^th(u(r(s(day)?)?)?)?/": "^ग(ुरु(.(वार)?)?)?", "/^fr(i(day)?)?/": "^श(ुक्र(.(वार)?)?)?", "/^sa(t(urday)?)?/": "^श(नि(.(वार)?)?)?", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "mr-IN"; ================================================ FILE: build/i18n/ms-BN.js ================================================ /* * DateJS Culture String File * Country Code: ms-BN * Name: Malay (Brunei Darussalam) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["ms-BN"] = { "name": "ms-BN", "englishName": "Malay (Brunei Darussalam)", "nativeName": "Bahasa Malaysia (Brunei Darussalam)", "Sunday": "Ahad", "Monday": "Isnin", "Tuesday": "Selasa", "Wednesday": "Rabu", "Thursday": "Khamis", "Friday": "Jumaat", "Saturday": "Sabtu", "Sun": "Ahad", "Mon": "Isnin", "Tue": "Sel", "Wed": "Rabu", "Thu": "Khamis", "Fri": "Jumaat", "Sat": "Sabtu", "Su": "A", "Mo": "I", "Tu": "S", "We": "R", "Th": "K", "Fr": "J", "Sa": "S", "S_Sun_Initial": "A", "M_Mon_Initial": "I", "T_Tue_Initial": "S", "W_Wed_Initial": "R", "T_Thu_Initial": "K", "F_Fri_Initial": "J", "S_Sat_Initial": "S", "January": "Januari", "February": "Februari", "March": "Mac", "April": "April", "May": "Mei", "June": "Jun", "July": "Julai", "August": "Ogos", "September": "September", "October": "Oktober", "November": "November", "December": "Disember", "Jan_Abbr": "Jan", "Feb_Abbr": "Feb", "Mar_Abbr": "Mac", "Apr_Abbr": "Apr", "May_Abbr": "Mei", "Jun_Abbr": "Jun", "Jul_Abbr": "Jul", "Aug_Abbr": "Ogos", "Sep_Abbr": "Sept", "Oct_Abbr": "Okt", "Nov_Abbr": "Nov", "Dec_Abbr": "Dis", "AM": "", "PM": "", "firstDayOfWeek": 1, "twoDigitYearMax": 2029, "mdy": "dmy", "M/d/yyyy": "dd/MM/yyyy", "dddd, MMMM dd, yyyy": "dd MMMM yyyy", "h:mm tt": "H:mm", "h:mm:ss tt": "H:mm:ss", "dddd, MMMM dd, yyyy h:mm:ss tt": "dd MMMM yyyy H:mm:ss", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "dd MMMM", "MMMM, yyyy": "MMMM yyyy", "/jan(uary)?/": "jan(uari)?", "/feb(ruary)?/": "feb(ruari)?", "/mar(ch)?/": "mac", "/apr(il)?/": "apr(il)?", "/may/": "mei", "/jun(e)?/": "jun", "/jul(y)?/": "jul(ai)?", "/aug(ust)?/": "ogos", "/sep(t(ember)?)?/": "sep(t(ember)?)?", "/oct(ober)?/": "okt(ober)?", "/nov(ember)?/": "nov(ember)?", "/dec(ember)?/": "dis(ember)?", "/^su(n(day)?)?/": "^a(1)?", "/^mo(n(day)?)?/": "^i(1)?", "/^tu(e(s(day)?)?)?/": "^s(el(asa)?)?", "/^we(d(nesday)?)?/": "^r(1)?", "/^th(u(r(s(day)?)?)?)?/": "^k(1)?", "/^fr(i(day)?)?/": "^j(1)?", "/^sa(t(urday)?)?/": "^s(1)?", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "ms-BN"; ================================================ FILE: build/i18n/ms-MY.js ================================================ /* * DateJS Culture String File * Country Code: ms-MY * Name: Malay (Malaysia) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["ms-MY"] = { "name": "ms-MY", "englishName": "Malay (Malaysia)", "nativeName": "Bahasa Malaysia (Malaysia)", "Sunday": "Ahad", "Monday": "Isnin", "Tuesday": "Selasa", "Wednesday": "Rabu", "Thursday": "Khamis", "Friday": "Jumaat", "Saturday": "Sabtu", "Sun": "Ahad", "Mon": "Isnin", "Tue": "Sel", "Wed": "Rabu", "Thu": "Khamis", "Fri": "Jumaat", "Sat": "Sabtu", "Su": "A", "Mo": "I", "Tu": "S", "We": "R", "Th": "K", "Fr": "J", "Sa": "S", "S_Sun_Initial": "A", "M_Mon_Initial": "I", "T_Tue_Initial": "S", "W_Wed_Initial": "R", "T_Thu_Initial": "K", "F_Fri_Initial": "J", "S_Sat_Initial": "S", "January": "Januari", "February": "Februari", "March": "Mac", "April": "April", "May": "Mei", "June": "Jun", "July": "Julai", "August": "Ogos", "September": "September", "October": "Oktober", "November": "November", "December": "Disember", "Jan_Abbr": "Jan", "Feb_Abbr": "Feb", "Mar_Abbr": "Mac", "Apr_Abbr": "Apr", "May_Abbr": "Mei", "Jun_Abbr": "Jun", "Jul_Abbr": "Jul", "Aug_Abbr": "Ogos", "Sep_Abbr": "Sept", "Oct_Abbr": "Okt", "Nov_Abbr": "Nov", "Dec_Abbr": "Dis", "AM": "", "PM": "", "firstDayOfWeek": 1, "twoDigitYearMax": 2029, "mdy": "dmy", "M/d/yyyy": "dd/MM/yyyy", "dddd, MMMM dd, yyyy": "dd MMMM yyyy", "h:mm tt": "H:mm", "h:mm:ss tt": "H:mm:ss", "dddd, MMMM dd, yyyy h:mm:ss tt": "dd MMMM yyyy H:mm:ss", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "dd MMMM", "MMMM, yyyy": "MMMM yyyy", "/jan(uary)?/": "jan(uari)?", "/feb(ruary)?/": "feb(ruari)?", "/mar(ch)?/": "mac", "/apr(il)?/": "apr(il)?", "/may/": "mei", "/jun(e)?/": "jun", "/jul(y)?/": "jul(ai)?", "/aug(ust)?/": "ogos", "/sep(t(ember)?)?/": "sep(t(ember)?)?", "/oct(ober)?/": "okt(ober)?", "/nov(ember)?/": "nov(ember)?", "/dec(ember)?/": "dis(ember)?", "/^su(n(day)?)?/": "^a(1)?", "/^mo(n(day)?)?/": "^i(1)?", "/^tu(e(s(day)?)?)?/": "^s(el(asa)?)?", "/^we(d(nesday)?)?/": "^r(1)?", "/^th(u(r(s(day)?)?)?)?/": "^k(1)?", "/^fr(i(day)?)?/": "^j(1)?", "/^sa(t(urday)?)?/": "^s(1)?", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "ms-MY"; ================================================ FILE: build/i18n/mt-MT.js ================================================ /* * DateJS Culture String File * Country Code: mt-MT * Name: Maltese (Malta) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["mt-MT"] = { "name": "mt-MT", "englishName": "Maltese (Malta)", "nativeName": "Malti (Malta)", "Sunday": "Il-Ħadd", "Monday": "It-Tnejn", "Tuesday": "It-Tlieta", "Wednesday": "L-Erbgħa", "Thursday": "Il-Ħamis", "Friday": "Il-Ġimgħa", "Saturday": "Is-Sibt", "Sun": "Ħad", "Mon": "Tne", "Tue": "Tli", "Wed": "Erb", "Thu": "Ħam", "Fri": "Ġim", "Sat": "Sib", "Su": "Ħad", "Mo": "Tne", "Tu": "Tli", "We": "Erb", "Th": "Ħam", "Fr": "Ġim", "Sa": "Sib", "S_Sun_Initial": "Ħ", "M_Mon_Initial": "T", "T_Tue_Initial": "T", "W_Wed_Initial": "E", "T_Thu_Initial": "Ħ", "F_Fri_Initial": "Ġ", "S_Sat_Initial": "S", "January": "Jannar", "February": "Frar", "March": "Marzu", "April": "April", "May": "Mejju", "June": "Ġunju", "July": "Lulju", "August": "Awissu", "September": "Settembru", "October": "Ottubru", "November": "Novembru", "December": "Diċembru", "Jan_Abbr": "Jan", "Feb_Abbr": "Fra", "Mar_Abbr": "Mar", "Apr_Abbr": "Apr", "May_Abbr": "Mej", "Jun_Abbr": "Ġun", "Jul_Abbr": "Lul", "Aug_Abbr": "Awi", "Sep_Abbr": "Set", "Oct_Abbr": "Ott", "Nov_Abbr": "Nov", "Dec_Abbr": "Diċ", "AM": "AM", "PM": "PM", "firstDayOfWeek": 1, "twoDigitYearMax": 2029, "mdy": "dmy", "M/d/yyyy": "dd/MM/yyyy", "dddd, MMMM dd, yyyy": "dddd, d' ta' 'MMMM yyyy", "h:mm tt": "HH:mm:ss", "h:mm:ss tt": "HH:mm:ss", "dddd, MMMM dd, yyyy h:mm:ss tt": "dddd, d' ta' 'MMMM yyyy HH:mm:ss", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "MMMM dd", "MMMM, yyyy": "MMMM yyyy", "/jan(uary)?/": "jan(nar)?", "/feb(ruary)?/": "fra(r)?", "/mar(ch)?/": "mar(zu)?", "/apr(il)?/": "apr(il)?", "/may/": "mej(ju)?", "/jun(e)?/": "ġun(ju)?", "/jul(y)?/": "lul(ju)?", "/aug(ust)?/": "awi(ssu)?", "/sep(t(ember)?)?/": "set(tembru)?", "/oct(ober)?/": "ott(ubru)?", "/nov(ember)?/": "nov(embru)?", "/dec(ember)?/": "diċ(embru)?", "/^su(n(day)?)?/": "^il-ħadd", "/^mo(n(day)?)?/": "^it-tnejn", "/^tu(e(s(day)?)?)?/": "^it-tlieta", "/^we(d(nesday)?)?/": "^l-erbgħa", "/^th(u(r(s(day)?)?)?)?/": "^il-ħamis", "/^fr(i(day)?)?/": "^il-ġimgħa", "/^sa(t(urday)?)?/": "^is-sibt", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "mt-MT"; ================================================ FILE: build/i18n/nb-NO.js ================================================ /* * DateJS Culture String File * Country Code: nb-NO * Name: Norwegian, Bokmål (Norway) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["nb-NO"] = { "name": "nb-NO", "englishName": "Norwegian, Bokmål (Norway)", "nativeName": "norsk, bokmål (Norge)", "Sunday": "søndag", "Monday": "mandag", "Tuesday": "tirsdag", "Wednesday": "onsdag", "Thursday": "torsdag", "Friday": "fredag", "Saturday": "lørdag", "Sun": "sø", "Mon": "ma", "Tue": "ti", "Wed": "on", "Thu": "to", "Fri": "fr", "Sat": "lø", "Su": "sø", "Mo": "ma", "Tu": "ti", "We": "on", "Th": "to", "Fr": "fr", "Sa": "lø", "S_Sun_Initial": "s", "M_Mon_Initial": "m", "T_Tue_Initial": "t", "W_Wed_Initial": "o", "T_Thu_Initial": "t", "F_Fri_Initial": "f", "S_Sat_Initial": "l", "January": "januar", "February": "februar", "March": "mars", "April": "april", "May": "mai", "June": "juni", "July": "juli", "August": "august", "September": "september", "October": "oktober", "November": "november", "December": "desember", "Jan_Abbr": "jan", "Feb_Abbr": "feb", "Mar_Abbr": "mar", "Apr_Abbr": "apr", "May_Abbr": "mai", "Jun_Abbr": "jun", "Jul_Abbr": "jul", "Aug_Abbr": "aug", "Sep_Abbr": "sep", "Oct_Abbr": "okt", "Nov_Abbr": "nov", "Dec_Abbr": "des", "AM": "", "PM": "", "firstDayOfWeek": 1, "twoDigitYearMax": 2029, "mdy": "dmy", "M/d/yyyy": "dd.MM.yyyy", "dddd, MMMM dd, yyyy": "d. MMMM yyyy", "h:mm tt": "HH:mm", "h:mm:ss tt": "HH:mm:ss", "dddd, MMMM dd, yyyy h:mm:ss tt": "d. MMMM yyyy HH:mm:ss", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "d. MMMM", "MMMM, yyyy": "MMMM yyyy", "/jan(uary)?/": "jan(uar)?", "/feb(ruary)?/": "feb(ruar)?", "/mar(ch)?/": "mar(s)?", "/apr(il)?/": "apr(il)?", "/may/": "mai", "/jun(e)?/": "jun(i)?", "/jul(y)?/": "jul(i)?", "/aug(ust)?/": "aug(ust)?", "/sep(t(ember)?)?/": "sep(t(ember)?)?", "/oct(ober)?/": "okt(ober)?", "/nov(ember)?/": "nov(ember)?", "/dec(ember)?/": "des(ember)?", "/^su(n(day)?)?/": "^søndag", "/^mo(n(day)?)?/": "^mandag", "/^tu(e(s(day)?)?)?/": "^tirsdag", "/^we(d(nesday)?)?/": "^onsdag", "/^th(u(r(s(day)?)?)?)?/": "^torsdag", "/^fr(i(day)?)?/": "^fredag", "/^sa(t(urday)?)?/": "^lørdag", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "nb-NO"; ================================================ FILE: build/i18n/nl-BE.js ================================================ /* * DateJS Culture String File * Country Code: nl-BE * Name: Dutch (Belgium) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["nl-BE"] = { "name": "nl-BE", "englishName": "Dutch (Belgium)", "nativeName": "Nederlands (België)", "Sunday": "zondag", "Monday": "maandag", "Tuesday": "dinsdag", "Wednesday": "woensdag", "Thursday": "donderdag", "Friday": "vrijdag", "Saturday": "zaterdag", "Sun": "zo", "Mon": "ma", "Tue": "di", "Wed": "wo", "Thu": "do", "Fri": "vr", "Sat": "za", "Su": "zo", "Mo": "ma", "Tu": "di", "We": "wo", "Th": "do", "Fr": "vr", "Sa": "za", "S_Sun_Initial": "z", "M_Mon_Initial": "m", "T_Tue_Initial": "d", "W_Wed_Initial": "w", "T_Thu_Initial": "d", "F_Fri_Initial": "v", "S_Sat_Initial": "z", "January": "januari", "February": "februari", "March": "maart", "April": "april", "May": "mei", "June": "juni", "July": "juli", "August": "augustus", "September": "september", "October": "oktober", "November": "november", "December": "december", "Jan_Abbr": "jan", "Feb_Abbr": "feb", "Mar_Abbr": "mrt", "Apr_Abbr": "apr", "May_Abbr": "mei", "Jun_Abbr": "jun", "Jul_Abbr": "jul", "Aug_Abbr": "aug", "Sep_Abbr": "sep", "Oct_Abbr": "okt", "Nov_Abbr": "nov", "Dec_Abbr": "dec", "AM": "", "PM": "", "firstDayOfWeek": 1, "twoDigitYearMax": 2029, "mdy": "dmy", "M/d/yyyy": "d/MM/yyyy", "dddd, MMMM dd, yyyy": "dddd d MMMM yyyy", "h:mm tt": "H:mm", "h:mm:ss tt": "H:mm:ss", "dddd, MMMM dd, yyyy h:mm:ss tt": "dddd d MMMM yyyy H:mm:ss", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "dd MMMM", "MMMM, yyyy": "MMMM yyyy", "/jan(uary)?/": "jan(uari)?", "/feb(ruary)?/": "feb(ruari)?", "/mar(ch)?/": "maart", "/apr(il)?/": "apr(il)?", "/may/": "mei", "/jun(e)?/": "jun(i)?", "/jul(y)?/": "jul(i)?", "/aug(ust)?/": "aug(ustus)?", "/sep(t(ember)?)?/": "sep(t(ember)?)?", "/oct(ober)?/": "okt(ober)?", "/nov(ember)?/": "nov(ember)?", "/dec(ember)?/": "dec(ember)?", "/^su(n(day)?)?/": "^zondag", "/^mo(n(day)?)?/": "^maandag", "/^tu(e(s(day)?)?)?/": "^dinsdag", "/^we(d(nesday)?)?/": "^woensdag", "/^th(u(r(s(day)?)?)?)?/": "^donderdag", "/^fr(i(day)?)?/": "^vrijdag", "/^sa(t(urday)?)?/": "^zaterdag", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "nl-BE"; ================================================ FILE: build/i18n/nl-NL.js ================================================ /* * DateJS Culture String File * Country Code: nl-NL * Name: Dutch (Netherlands) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["nl-NL"] = { "name": "nl-NL", "englishName": "Dutch (Netherlands)", "nativeName": "Nederlands (Nederland)", "Sunday": "zondag", "Monday": "maandag", "Tuesday": "dinsdag", "Wednesday": "woensdag", "Thursday": "donderdag", "Friday": "vrijdag", "Saturday": "zaterdag", "Sun": "zo", "Mon": "ma", "Tue": "di", "Wed": "wo", "Thu": "do", "Fri": "vr", "Sat": "za", "Su": "zo", "Mo": "ma", "Tu": "di", "We": "wo", "Th": "do", "Fr": "vr", "Sa": "za", "S_Sun_Initial": "z", "M_Mon_Initial": "m", "T_Tue_Initial": "d", "W_Wed_Initial": "w", "T_Thu_Initial": "d", "F_Fri_Initial": "v", "S_Sat_Initial": "z", "January": "januari", "February": "februari", "March": "maart", "April": "april", "May": "mei", "June": "juni", "July": "juli", "August": "augustus", "September": "september", "October": "oktober", "November": "november", "December": "december", "Jan_Abbr": "jan", "Feb_Abbr": "feb", "Mar_Abbr": "mrt", "Apr_Abbr": "apr", "May_Abbr": "mei", "Jun_Abbr": "jun", "Jul_Abbr": "jul", "Aug_Abbr": "aug", "Sep_Abbr": "sep", "Oct_Abbr": "okt", "Nov_Abbr": "nov", "Dec_Abbr": "dec", "AM": "", "PM": "", "firstDayOfWeek": 1, "twoDigitYearMax": 2029, "mdy": "dmy", "M/d/yyyy": "d-M-yyyy", "dddd, MMMM dd, yyyy": "dddd d MMMM yyyy", "h:mm tt": "H:mm", "h:mm:ss tt": "H:mm:ss", "dddd, MMMM dd, yyyy h:mm:ss tt": "dddd d MMMM yyyy H:mm:ss", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "dd MMMM", "MMMM, yyyy": "MMMM yyyy", "/jan(uary)?/": "jan(uari)?", "/feb(ruary)?/": "feb(ruari)?", "/mar(ch)?/": "maart", "/apr(il)?/": "apr(il)?", "/may/": "mei", "/jun(e)?/": "jun(i)?", "/jul(y)?/": "jul(i)?", "/aug(ust)?/": "aug(ustus)?", "/sep(t(ember)?)?/": "sep(t(ember)?)?", "/oct(ober)?/": "okt(ober)?", "/nov(ember)?/": "nov(ember)?", "/dec(ember)?/": "dec(ember)?", "/^su(n(day)?)?/": "^zondag", "/^mo(n(day)?)?/": "^maandag", "/^tu(e(s(day)?)?)?/": "^dinsdag", "/^we(d(nesday)?)?/": "^woensdag", "/^th(u(r(s(day)?)?)?)?/": "^donderdag", "/^fr(i(day)?)?/": "^vrijdag", "/^sa(t(urday)?)?/": "^zaterdag", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "nl-NL"; ================================================ FILE: build/i18n/nn-NO.js ================================================ /* * DateJS Culture String File * Country Code: nn-NO * Name: Norwegian, Nynorsk (Norway) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["nn-NO"] = { "name": "nn-NO", "englishName": "Norwegian, Nynorsk (Norway)", "nativeName": "norsk, nynorsk (Noreg)", "Sunday": "søndag", "Monday": "måndag", "Tuesday": "tysdag", "Wednesday": "onsdag", "Thursday": "torsdag", "Friday": "fredag", "Saturday": "laurdag", "Sun": "sø", "Mon": "må", "Tue": "ty", "Wed": "on", "Thu": "to", "Fri": "fr", "Sat": "la", "Su": "sø", "Mo": "må", "Tu": "ty", "We": "on", "Th": "to", "Fr": "fr", "Sa": "la", "S_Sun_Initial": "s", "M_Mon_Initial": "m", "T_Tue_Initial": "t", "W_Wed_Initial": "o", "T_Thu_Initial": "t", "F_Fri_Initial": "f", "S_Sat_Initial": "l", "January": "januar", "February": "februar", "March": "mars", "April": "april", "May": "mai", "June": "juni", "July": "juli", "August": "august", "September": "september", "October": "oktober", "November": "november", "December": "desember", "Jan_Abbr": "jan", "Feb_Abbr": "feb", "Mar_Abbr": "mar", "Apr_Abbr": "apr", "May_Abbr": "mai", "Jun_Abbr": "jun", "Jul_Abbr": "jul", "Aug_Abbr": "aug", "Sep_Abbr": "sep", "Oct_Abbr": "okt", "Nov_Abbr": "nov", "Dec_Abbr": "des", "AM": "", "PM": "", "firstDayOfWeek": 1, "twoDigitYearMax": 2029, "mdy": "dmy", "M/d/yyyy": "dd.MM.yyyy", "dddd, MMMM dd, yyyy": "d. MMMM yyyy", "h:mm tt": "HH:mm", "h:mm:ss tt": "HH:mm:ss", "dddd, MMMM dd, yyyy h:mm:ss tt": "d. MMMM yyyy HH:mm:ss", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "d. MMMM", "MMMM, yyyy": "MMMM yyyy", "/jan(uary)?/": "jan(uar)?", "/feb(ruary)?/": "feb(ruar)?", "/mar(ch)?/": "mar(s)?", "/apr(il)?/": "apr(il)?", "/may/": "mai", "/jun(e)?/": "jun(i)?", "/jul(y)?/": "jul(i)?", "/aug(ust)?/": "aug(ust)?", "/sep(t(ember)?)?/": "sep(t(ember)?)?", "/oct(ober)?/": "okt(ober)?", "/nov(ember)?/": "nov(ember)?", "/dec(ember)?/": "des(ember)?", "/^su(n(day)?)?/": "^søndag", "/^mo(n(day)?)?/": "^måndag", "/^tu(e(s(day)?)?)?/": "^tysdag", "/^we(d(nesday)?)?/": "^onsdag", "/^th(u(r(s(day)?)?)?)?/": "^torsdag", "/^fr(i(day)?)?/": "^fredag", "/^sa(t(urday)?)?/": "^laurdag", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "nn-NO"; ================================================ FILE: build/i18n/ns-ZA.js ================================================ /* * DateJS Culture String File * Country Code: ns-ZA * Name: Northern Sotho (South Africa) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["ns-ZA"] = { "name": "ns-ZA", "englishName": "Northern Sotho (South Africa)", "nativeName": "Sesotho sa Leboa (Afrika Borwa)", "Sunday": "Lamorena", "Monday": "Mošupologo", "Tuesday": "Labobedi", "Wednesday": "Laboraro", "Thursday": "Labone", "Friday": "Labohlano", "Saturday": "Mokibelo", "Sun": "Sun", "Mon": "Mon", "Tue": "Tue", "Wed": "Wed", "Thu": "Thu", "Fri": "Fri", "Sat": "Sat", "Su": "Sun", "Mo": "Mon", "Tu": "Tue", "We": "Wed", "Th": "Thu", "Fr": "Fri", "Sa": "Sat", "S_Sun_Initial": "S", "M_Mon_Initial": "M", "T_Tue_Initial": "T", "W_Wed_Initial": "W", "T_Thu_Initial": "T", "F_Fri_Initial": "F", "S_Sat_Initial": "S", "January": "Pherekgong", "February": "Hlakola", "March": "Mopitlo", "April": "Moranang", "May": "Mosegamanye", "June": "Ngoatobošego", "July": "Phuphu", "August": "Phato", "September": "Lewedi", "October": "Diphalana", "November": "Dibatsela", "December": "Manthole", "Jan_Abbr": "Jan", "Feb_Abbr": "Feb", "Mar_Abbr": "Mar", "Apr_Abbr": "Apr", "May_Abbr": "May", "Jun_Abbr": "Jun", "Jul_Abbr": "Jul", "Aug_Abbr": "Aug", "Sep_Abbr": "Sep", "Oct_Abbr": "Oct", "Nov_Abbr": "Nov", "Dec_Abbr": "Dec", "AM": "AM", "PM": "PM", "firstDayOfWeek": 0, "twoDigitYearMax": 2029, "mdy": "ymd", "M/d/yyyy": "yyyy/MM/dd", "dddd, MMMM dd, yyyy": "dd MMMM yyyy", "h:mm tt": "hh:mm:ss tt", "h:mm:ss tt": "hh:mm:ss tt", "dddd, MMMM dd, yyyy h:mm:ss tt": "dd MMMM yyyy hh:mm:ss tt", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "MMMM dd", "MMMM, yyyy": "MMMM yyyy", "/jan(uary)?/": "pherekgong", "/feb(ruary)?/": "hlakola", "/mar(ch)?/": "mopitlo", "/apr(il)?/": "moranang", "/may/": "mosegamanye", "/jun(e)?/": "ngoatobošego", "/jul(y)?/": "phuphu", "/aug(ust)?/": "phato", "/sep(t(ember)?)?/": "lewedi", "/oct(ober)?/": "diphalana", "/nov(ember)?/": "dibatsela", "/dec(ember)?/": "manthole", "/^su(n(day)?)?/": "^lamorena", "/^mo(n(day)?)?/": "^mošupologo", "/^tu(e(s(day)?)?)?/": "^labobedi", "/^we(d(nesday)?)?/": "^laboraro", "/^th(u(r(s(day)?)?)?)?/": "^labone", "/^fr(i(day)?)?/": "^labohlano", "/^sa(t(urday)?)?/": "^mokibelo", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "ns-ZA"; ================================================ FILE: build/i18n/pa-IN.js ================================================ /* * DateJS Culture String File * Country Code: pa-IN * Name: Punjabi (India) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["pa-IN"] = { "name": "pa-IN", "englishName": "Punjabi (India)", "nativeName": "ਪੰਜਾਬੀ (ਭਾਰਤ)", "Sunday": "ਐਤਵਾਰ", "Monday": "ਸੋਮਵਾਰ", "Tuesday": "ਮੰਗਲਵਾਰ", "Wednesday": "ਬੁਧਵਾਰ", "Thursday": "ਵੀਰਵਾਰ", "Friday": "ਸ਼ੁੱਕਰਵਾਰ", "Saturday": "ਸ਼ਨੀਚਰਵਾਰ", "Sun": "ਐਤ.", "Mon": "ਸੋਮ.", "Tue": "ਮੰਗਲ.", "Wed": "ਬੁਧ.", "Thu": "ਵੀਰ.", "Fri": "ਸ਼ੁਕਰ.", "Sat": "ਸ਼ਨੀ.", "Su": "ਐ", "Mo": "ਸ", "Tu": "ਮ", "We": "ਬ", "Th": "ਵ", "Fr": "ਸ਼", "Sa": "ਸ਼", "S_Sun_Initial": "ਐ", "M_Mon_Initial": "ਸ", "T_Tue_Initial": "ਮ", "W_Wed_Initial": "ਬ", "T_Thu_Initial": "ਵ", "F_Fri_Initial": "ਸ਼", "S_Sat_Initial": "ਸ਼", "January": "ਜਨਵਰੀ", "February": "ਫ਼ਰਵਰੀ", "March": "ਮਾਰਚ", "April": "ਅਪ੍ਰੈਲ", "May": "ਮਈ", "June": "ਜੂਨ", "July": "ਜੁਲਾਈ", "August": "ਅਗਸਤ", "September": "ਸਤੰਬਰ", "October": "ਅਕਤੂਬਰ", "November": "ਨਵੰਬਰ", "December": "ਦਸੰਬਰ", "Jan_Abbr": "ਜਨਵਰੀ", "Feb_Abbr": "ਫ਼ਰਵਰੀ", "Mar_Abbr": "ਮਾਰਚ", "Apr_Abbr": "ਅਪ੍ਰੈਲ", "May_Abbr": "ਮਈ", "Jun_Abbr": "ਜੂਨ", "Jul_Abbr": "ਜੁਲਾਈ", "Aug_Abbr": "ਅਗਸਤ", "Sep_Abbr": "ਸਤੰਬਰ", "Oct_Abbr": "ਅਕਤੂਬਰ", "Nov_Abbr": "ਨਵੰਬਰ", "Dec_Abbr": "ਦਸੰਬਰ", "AM": "ਸਵੇਰੇ", "PM": "ਸ਼ਾਮ", "firstDayOfWeek": 1, "twoDigitYearMax": 2029, "mdy": "dmy", "M/d/yyyy": "dd-MM-yy", "dddd, MMMM dd, yyyy": "dd MMMM yyyy dddd", "h:mm tt": "tt hh:mm", "h:mm:ss tt": "tt hh:mm:ss", "dddd, MMMM dd, yyyy h:mm:ss tt": "dd MMMM yyyy dddd tt hh:mm:ss", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "dd MMMM", "MMMM, yyyy": "MMMM, yyyy", "/jan(uary)?/": "ਜਨਵਰੀ", "/feb(ruary)?/": "ਫ਼ਰਵਰੀ", "/mar(ch)?/": "ਮਾਰਚ", "/apr(il)?/": "ਅਪ੍ਰੈਲ", "/may/": "ਮਈ", "/jun(e)?/": "ਜੂਨ", "/jul(y)?/": "ਜੁਲਾਈ", "/aug(ust)?/": "ਅਗਸਤ", "/sep(t(ember)?)?/": "ਸਤੰਬਰ", "/oct(ober)?/": "ਅਕਤੂਬਰ", "/nov(ember)?/": "ਨਵੰਬਰ", "/dec(ember)?/": "ਦਸੰਬਰ", "/^su(n(day)?)?/": "^ਐ(ਤ(.(ਵਾਰ)?)?)?", "/^mo(n(day)?)?/": "^ਸ(ੋਮ(.(ਵਾਰ)?)?)?", "/^tu(e(s(day)?)?)?/": "^ਮ(ੰਗਲ(.(ਵਾਰ)?)?)?", "/^we(d(nesday)?)?/": "^ਬ(ੁਧ(.(ਵਾਰ)?)?)?", "/^th(u(r(s(day)?)?)?)?/": "^ਵ(ੀਰ(.(ਵਾਰ)?)?)?", "/^fr(i(day)?)?/": "^ਸ਼(ੁਕਰ(.(ਰਵਾਰ)?)?)?", "/^sa(t(urday)?)?/": "^ਸ਼(ਨੀ(.(ਚਰਵਾਰ)?)?)?", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "pa-IN"; ================================================ FILE: build/i18n/pl-PL.js ================================================ /* * DateJS Culture String File * Country Code: pl-PL * Name: Polish (Poland) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["pl-PL"] = { "name": "pl-PL", "englishName": "Polish (Poland)", "nativeName": "polski (Polska)", "Sunday": "niedziela", "Monday": "poniedziałek", "Tuesday": "wtorek", "Wednesday": "środa", "Thursday": "czwartek", "Friday": "piątek", "Saturday": "sobota", "Sun": "N", "Mon": "Pn", "Tue": "Wt", "Wed": "Śr", "Thu": "Cz", "Fri": "Pt", "Sat": "So", "Su": "N", "Mo": "Pn", "Tu": "Wt", "We": "Śr", "Th": "Cz", "Fr": "Pt", "Sa": "So", "S_Sun_Initial": "N", "M_Mon_Initial": "P", "T_Tue_Initial": "W", "W_Wed_Initial": "Ś", "T_Thu_Initial": "C", "F_Fri_Initial": "P", "S_Sat_Initial": "S", "January": "styczeń", "February": "luty", "March": "marzec", "April": "kwiecień", "May": "maj", "June": "czerwiec", "July": "lipiec", "August": "sierpień", "September": "wrzesień", "October": "październik", "November": "listopad", "December": "grudzień", "Jan_Abbr": "sty", "Feb_Abbr": "lut", "Mar_Abbr": "mar", "Apr_Abbr": "kwi", "May_Abbr": "maj", "Jun_Abbr": "cze", "Jul_Abbr": "lip", "Aug_Abbr": "sie", "Sep_Abbr": "wrz", "Oct_Abbr": "paź", "Nov_Abbr": "lis", "Dec_Abbr": "gru", "AM": "", "PM": "", "firstDayOfWeek": 1, "twoDigitYearMax": 2029, "mdy": "ymd", "M/d/yyyy": "yyyy-MM-dd", "dddd, MMMM dd, yyyy": "d MMMM yyyy", "h:mm tt": "HH:mm", "h:mm:ss tt": "HH:mm:ss", "dddd, MMMM dd, yyyy h:mm:ss tt": "d MMMM yyyy HH:mm:ss", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "d MMMM", "MMMM, yyyy": "MMMM yyyy", "/jan(uary)?/": "sty(czeń)?", "/feb(ruary)?/": "lut(y)?", "/mar(ch)?/": "mar(zec)?", "/apr(il)?/": "kwi(ecień)?", "/may/": "maj", "/jun(e)?/": "cze(rwiec)?", "/jul(y)?/": "lip(iec)?", "/aug(ust)?/": "sie(rpień)?", "/sep(t(ember)?)?/": "wrz(esień)?", "/oct(ober)?/": "paź(dziernik)?", "/nov(ember)?/": "lis(topad)?", "/dec(ember)?/": "gru(dzień)?", "/^su(n(day)?)?/": "^niedziela", "/^mo(n(day)?)?/": "^poniedziałek", "/^tu(e(s(day)?)?)?/": "^wtorek", "/^we(d(nesday)?)?/": "^środa", "/^th(u(r(s(day)?)?)?)?/": "^czwartek", "/^fr(i(day)?)?/": "^piątek", "/^sa(t(urday)?)?/": "^sobota", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "pl-PL"; ================================================ FILE: build/i18n/pt-BR.js ================================================ /* * DateJS Culture String File * Country Code: pt-BR * Name: Portuguese (Brazil) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["pt-BR"] = { "name": "pt-BR", "englishName": "Portuguese (Brazil)", "nativeName": "Português (Brasil)", "Sunday": "domingo", "Monday": "segunda-feira", "Tuesday": "terça-feira", "Wednesday": "quarta-feira", "Thursday": "quinta-feira", "Friday": "sexta-feira", "Saturday": "sábado", "Sun": "dom", "Mon": "seg", "Tue": "ter", "Wed": "qua", "Thu": "qui", "Fri": "sex", "Sat": "sáb", "Su": "dom", "Mo": "seg", "Tu": "ter", "We": "qua", "Th": "qui", "Fr": "sex", "Sa": "sáb", "S_Sun_Initial": "d", "M_Mon_Initial": "s", "T_Tue_Initial": "t", "W_Wed_Initial": "q", "T_Thu_Initial": "q", "F_Fri_Initial": "s", "S_Sat_Initial": "s", "January": "janeiro", "February": "fevereiro", "March": "março", "April": "abril", "May": "maio", "June": "junho", "July": "julho", "August": "agosto", "September": "setembro", "October": "outubro", "November": "novembro", "December": "dezembro", "Jan_Abbr": "jan", "Feb_Abbr": "fev", "Mar_Abbr": "mar", "Apr_Abbr": "abr", "May_Abbr": "mai", "Jun_Abbr": "jun", "Jul_Abbr": "jul", "Aug_Abbr": "ago", "Sep_Abbr": "set", "Oct_Abbr": "out", "Nov_Abbr": "nov", "Dec_Abbr": "dez", "AM": "", "PM": "", "firstDayOfWeek": 0, "twoDigitYearMax": 2029, "mdy": "dmy", "M/d/yyyy": "d/M/yyyy", "dddd, MMMM dd, yyyy": "dddd, d' de 'MMMM' de 'yyyy", "h:mm tt": "H:mm", "h:mm:ss tt": "H:mm:ss", "dddd, MMMM dd, yyyy h:mm:ss tt": "dddd, d' de 'MMMM' de 'yyyy H:mm:ss", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "dd' de 'MMMM", "MMMM, yyyy": "MMMM' de 'yyyy", "/jan(uary)?/": "jan(eiro)?", "/feb(ruary)?/": "fev(ereiro)?", "/mar(ch)?/": "mar(ço)?", "/apr(il)?/": "abr(il)?", "/may/": "mai(o)?", "/jun(e)?/": "jun(ho)?", "/jul(y)?/": "jul(ho)?", "/aug(ust)?/": "ago(sto)?", "/sep(t(ember)?)?/": "set(embro)?", "/oct(ober)?/": "out(ubro)?", "/nov(ember)?/": "nov(embro)?", "/dec(ember)?/": "dez(embro)?", "/^su(n(day)?)?/": "^domingo", "/^mo(n(day)?)?/": "^segunda-feira", "/^tu(e(s(day)?)?)?/": "^terça-feira", "/^we(d(nesday)?)?/": "^quarta-feira", "/^th(u(r(s(day)?)?)?)?/": "^quinta-feira", "/^fr(i(day)?)?/": "^sexta-feira", "/^sa(t(urday)?)?/": "^sábado", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "pt-BR"; ================================================ FILE: build/i18n/pt-PT.js ================================================ /* * DateJS Culture String File * Country Code: pt-PT * Name: Portuguese (Portugal) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["pt-PT"] = { "name": "pt-PT", "englishName": "Portuguese (Portugal)", "nativeName": "Português (Portugal)", "Sunday": "domingo", "Monday": "segunda-feira", "Tuesday": "terça-feira", "Wednesday": "quarta-feira", "Thursday": "quinta-feira", "Friday": "sexta-feira", "Saturday": "sábado", "Sun": "dom", "Mon": "seg", "Tue": "ter", "Wed": "qua", "Thu": "qui", "Fri": "sex", "Sat": "sáb", "Su": "dom", "Mo": "seg", "Tu": "ter", "We": "qua", "Th": "qui", "Fr": "sex", "Sa": "sáb", "S_Sun_Initial": "d", "M_Mon_Initial": "s", "T_Tue_Initial": "t", "W_Wed_Initial": "q", "T_Thu_Initial": "q", "F_Fri_Initial": "s", "S_Sat_Initial": "s", "January": "Janeiro", "February": "Fevereiro", "March": "Março", "April": "Abril", "May": "Maio", "June": "Junho", "July": "Julho", "August": "Agosto", "September": "Setembro", "October": "Outubro", "November": "Novembro", "December": "Dezembro", "Jan_Abbr": "Jan", "Feb_Abbr": "Fev", "Mar_Abbr": "Mar", "Apr_Abbr": "Abr", "May_Abbr": "Mai", "Jun_Abbr": "Jun", "Jul_Abbr": "Jul", "Aug_Abbr": "Ago", "Sep_Abbr": "Set", "Oct_Abbr": "Out", "Nov_Abbr": "Nov", "Dec_Abbr": "Dez", "AM": "", "PM": "", "firstDayOfWeek": 1, "twoDigitYearMax": 2029, "mdy": "dmy", "M/d/yyyy": "dd-MM-yyyy", "dddd, MMMM dd, yyyy": "dddd, d' de 'MMMM' de 'yyyy", "h:mm tt": "H:mm", "h:mm:ss tt": "H:mm:ss", "dddd, MMMM dd, yyyy h:mm:ss tt": "dddd, d' de 'MMMM' de 'yyyy H:mm:ss", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "d/M", "MMMM, yyyy": "MMMM' de 'yyyy", "/jan(uary)?/": "jan(eiro)?", "/feb(ruary)?/": "fev(ereiro)?", "/mar(ch)?/": "mar(ço)?", "/apr(il)?/": "abr(il)?", "/may/": "mai(o)?", "/jun(e)?/": "jun(ho)?", "/jul(y)?/": "jul(ho)?", "/aug(ust)?/": "ago(sto)?", "/sep(t(ember)?)?/": "set(embro)?", "/oct(ober)?/": "out(ubro)?", "/nov(ember)?/": "nov(embro)?", "/dec(ember)?/": "dez(embro)?", "/^su(n(day)?)?/": "^domingo", "/^mo(n(day)?)?/": "^segunda-feira", "/^tu(e(s(day)?)?)?/": "^terça-feira", "/^we(d(nesday)?)?/": "^quarta-feira", "/^th(u(r(s(day)?)?)?)?/": "^quinta-feira", "/^fr(i(day)?)?/": "^sexta-feira", "/^sa(t(urday)?)?/": "^sábado", "/^next/": "^prox(im(o(s)?|a(s)?))?", "/^last|past|prev(ious)?/": "^ant(erior(es)?)?|ult(im(o(s)?|a(s)?))?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|depois)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|antes)", "/^yes(terday)?/": "^ontem", "/^t(od(ay)?)?/": "^h(oje)?", "/^tom(orrow)?/": "^amanha", "/^n(ow)?/": "^a(gora)?", "/^ms|milli(second)?s?/": "^ms|milli(segundo)?s?", "/^sec(ond)?s?/": "^s(egundo)?s?", "/^mn|min(ute)?s?/": "^mn|min(uto)?s?", "/^h(our)?s?/": "^h(ora)?s?", "/^w(eek)?s?/": "^sem(ana)?s?", "/^m(onth)?s?/": "^m(e(se)?s?)?", "/^d(ay)?s?/": "^d(ia(s)?s?)?", "/^y(ear)?s?/": "^an((o)?s?)?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "pt-PT"; ================================================ FILE: build/i18n/quz-BO.js ================================================ /* * DateJS Culture String File * Country Code: quz-BO * Name: Quechua (Bolivia) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["quz-BO"] = { "name": "quz-BO", "englishName": "Quechua (Bolivia)", "nativeName": "runasimi (Bolivia Suyu)", "Sunday": "intichaw", "Monday": "killachaw", "Tuesday": "atipachaw", "Wednesday": "quyllurchaw", "Thursday": "Ch' askachaw", "Friday": "Illapachaw", "Saturday": "k'uychichaw", "Sun": "int", "Mon": "kil", "Tue": "ati", "Wed": "quy", "Thu": "Ch’", "Fri": "Ill", "Sat": "k'u", "Su": "int", "Mo": "kil", "Tu": "ati", "We": "quy", "Th": "Ch’", "Fr": "Ill", "Sa": "k'u", "S_Sun_Initial": "i", "M_Mon_Initial": "k", "T_Tue_Initial": "a", "W_Wed_Initial": "q", "T_Thu_Initial": "C", "F_Fri_Initial": "I", "S_Sat_Initial": "k", "January": "Qulla puquy", "February": "Hatun puquy", "March": "Pauqar waray", "April": "ayriwa", "May": "Aymuray", "June": "Inti raymi", "July": "Anta Sitwa", "August": "Qhapaq Sitwa", "September": "Uma raymi", "October": "Kantaray", "November": "Ayamarq'a", "December": "Kapaq Raymi", "Jan_Abbr": "Qul", "Feb_Abbr": "Hat", "Mar_Abbr": "Pau", "Apr_Abbr": "ayr", "May_Abbr": "Aym", "Jun_Abbr": "Int", "Jul_Abbr": "Ant", "Aug_Abbr": "Qha", "Sep_Abbr": "Uma", "Oct_Abbr": "Kan", "Nov_Abbr": "Aya", "Dec_Abbr": "Kap", "AM": "a.m.", "PM": "p.m.", "firstDayOfWeek": 0, "twoDigitYearMax": 2029, "mdy": "dmy", "M/d/yyyy": "dd/MM/yyyy", "dddd, MMMM dd, yyyy": "dddd, dd' de 'MMMM' de 'yyyy", "h:mm tt": "hh:mm:ss tt", "h:mm:ss tt": "hh:mm:ss tt", "dddd, MMMM dd, yyyy h:mm:ss tt": "dddd, dd' de 'MMMM' de 'yyyy hh:mm:ss tt", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "MMMM dd", "MMMM, yyyy": "MMMM' de 'yyyy", "/jan(uary)?/": "qul(la puquy)?", "/feb(ruary)?/": "hat(un puquy)?", "/mar(ch)?/": "pau(qar waray)?", "/apr(il)?/": "ayr(iwa)?", "/may/": "aym(uray)?", "/jun(e)?/": "int(i raymi)?", "/jul(y)?/": "ant(a sitwa)?", "/aug(ust)?/": "qha(paq sitwa)?", "/sep(t(ember)?)?/": "uma( raymi)?", "/oct(ober)?/": "kan(taray)?", "/nov(ember)?/": "aya(marq'a)?", "/dec(ember)?/": "kap(aq raymi)?", "/^su(n(day)?)?/": "^intichaw", "/^mo(n(day)?)?/": "^killachaw", "/^tu(e(s(day)?)?)?/": "^atipachaw", "/^we(d(nesday)?)?/": "^quyllurchaw", "/^th(u(r(s(day)?)?)?)?/": "^ch' askachaw", "/^fr(i(day)?)?/": "^illapachaw", "/^sa(t(urday)?)?/": "^k'uychichaw", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "quz-BO"; ================================================ FILE: build/i18n/quz-EC.js ================================================ /* * DateJS Culture String File * Country Code: quz-EC * Name: Quechua (Ecuador) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["quz-EC"] = { "name": "quz-EC", "englishName": "Quechua (Ecuador)", "nativeName": "runasimi (Ecuador Suyu)", "Sunday": "intichaw", "Monday": "killachaw", "Tuesday": "atipachaw", "Wednesday": "quyllurchaw", "Thursday": "Ch' askachaw", "Friday": "Illapachaw", "Saturday": "k'uychichaw", "Sun": "int", "Mon": "kil", "Tue": "ati", "Wed": "quy", "Thu": "Ch’", "Fri": "Ill", "Sat": "k'u", "Su": "int", "Mo": "kil", "Tu": "ati", "We": "quy", "Th": "Ch’", "Fr": "Ill", "Sa": "k'u", "S_Sun_Initial": "i", "M_Mon_Initial": "k", "T_Tue_Initial": "a", "W_Wed_Initial": "q", "T_Thu_Initial": "C", "F_Fri_Initial": "I", "S_Sat_Initial": "k", "January": "Qulla puquy", "February": "Hatun puquy", "March": "Pauqar waray", "April": "ayriwa", "May": "Aymuray", "June": "Inti raymi", "July": "Anta Sitwa", "August": "Qhapaq Sitwa", "September": "Uma raymi", "October": "Kantaray", "November": "Ayamarq'a", "December": "Kapaq Raymi", "Jan_Abbr": "Qul", "Feb_Abbr": "Hat", "Mar_Abbr": "Pau", "Apr_Abbr": "ayr", "May_Abbr": "Aym", "Jun_Abbr": "Int", "Jul_Abbr": "Ant", "Aug_Abbr": "Qha", "Sep_Abbr": "Uma", "Oct_Abbr": "Kan", "Nov_Abbr": "Aya", "Dec_Abbr": "Kap", "AM": "", "PM": "", "firstDayOfWeek": 0, "twoDigitYearMax": 2029, "mdy": "dmy", "M/d/yyyy": "dd/MM/yyyy", "dddd, MMMM dd, yyyy": "dddd, dd' de 'MMMM' de 'yyyy", "h:mm tt": "H:mm:ss", "h:mm:ss tt": "H:mm:ss", "dddd, MMMM dd, yyyy h:mm:ss tt": "dddd, dd' de 'MMMM' de 'yyyy H:mm:ss", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "MMMM dd", "MMMM, yyyy": "MMMM' de 'yyyy", "/jan(uary)?/": "qul(la puquy)?", "/feb(ruary)?/": "hat(un puquy)?", "/mar(ch)?/": "pau(qar waray)?", "/apr(il)?/": "ayr(iwa)?", "/may/": "aym(uray)?", "/jun(e)?/": "int(i raymi)?", "/jul(y)?/": "ant(a sitwa)?", "/aug(ust)?/": "qha(paq sitwa)?", "/sep(t(ember)?)?/": "uma( raymi)?", "/oct(ober)?/": "kan(taray)?", "/nov(ember)?/": "aya(marq'a)?", "/dec(ember)?/": "kap(aq raymi)?", "/^su(n(day)?)?/": "^intichaw", "/^mo(n(day)?)?/": "^killachaw", "/^tu(e(s(day)?)?)?/": "^atipachaw", "/^we(d(nesday)?)?/": "^quyllurchaw", "/^th(u(r(s(day)?)?)?)?/": "^ch' askachaw", "/^fr(i(day)?)?/": "^illapachaw", "/^sa(t(urday)?)?/": "^k'uychichaw", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "quz-EC"; ================================================ FILE: build/i18n/quz-PE.js ================================================ /* * DateJS Culture String File * Country Code: quz-PE * Name: Quechua (Peru) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["quz-PE"] = { "name": "quz-PE", "englishName": "Quechua (Peru)", "nativeName": "runasimi (Peru Suyu)", "Sunday": "intichaw", "Monday": "killachaw", "Tuesday": "atipachaw", "Wednesday": "quyllurchaw", "Thursday": "Ch' askachaw", "Friday": "Illapachaw", "Saturday": "k'uychichaw", "Sun": "int", "Mon": "kil", "Tue": "ati", "Wed": "quy", "Thu": "Ch’", "Fri": "Ill", "Sat": "k'u", "Su": "int", "Mo": "kil", "Tu": "ati", "We": "quy", "Th": "Ch’", "Fr": "Ill", "Sa": "k'u", "S_Sun_Initial": "i", "M_Mon_Initial": "k", "T_Tue_Initial": "a", "W_Wed_Initial": "q", "T_Thu_Initial": "C", "F_Fri_Initial": "I", "S_Sat_Initial": "k", "January": "Qulla puquy", "February": "Hatun puquy", "March": "Pauqar waray", "April": "ayriwa", "May": "Aymuray", "June": "Inti raymi", "July": "Anta Sitwa", "August": "Qhapaq Sitwa", "September": "Uma raymi", "October": "Kantaray", "November": "Ayamarq'a", "December": "Kapaq Raymi", "Jan_Abbr": "Qul", "Feb_Abbr": "Hat", "Mar_Abbr": "Pau", "Apr_Abbr": "ayr", "May_Abbr": "Aym", "Jun_Abbr": "Int", "Jul_Abbr": "Ant", "Aug_Abbr": "Qha", "Sep_Abbr": "Uma", "Oct_Abbr": "Kan", "Nov_Abbr": "Aya", "Dec_Abbr": "Kap", "AM": "a.m.", "PM": "p.m.", "firstDayOfWeek": 0, "twoDigitYearMax": 2029, "mdy": "dmy", "M/d/yyyy": "dd/MM/yyyy", "dddd, MMMM dd, yyyy": "dddd, dd' de 'MMMM' de 'yyyy", "h:mm tt": "hh:mm:ss tt", "h:mm:ss tt": "hh:mm:ss tt", "dddd, MMMM dd, yyyy h:mm:ss tt": "dddd, dd' de 'MMMM' de 'yyyy hh:mm:ss tt", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "MMMM dd", "MMMM, yyyy": "MMMM' de 'yyyy", "/jan(uary)?/": "qul(la puquy)?", "/feb(ruary)?/": "hat(un puquy)?", "/mar(ch)?/": "pau(qar waray)?", "/apr(il)?/": "ayr(iwa)?", "/may/": "aym(uray)?", "/jun(e)?/": "int(i raymi)?", "/jul(y)?/": "ant(a sitwa)?", "/aug(ust)?/": "qha(paq sitwa)?", "/sep(t(ember)?)?/": "uma( raymi)?", "/oct(ober)?/": "kan(taray)?", "/nov(ember)?/": "aya(marq'a)?", "/dec(ember)?/": "kap(aq raymi)?", "/^su(n(day)?)?/": "^intichaw", "/^mo(n(day)?)?/": "^killachaw", "/^tu(e(s(day)?)?)?/": "^atipachaw", "/^we(d(nesday)?)?/": "^quyllurchaw", "/^th(u(r(s(day)?)?)?)?/": "^ch' askachaw", "/^fr(i(day)?)?/": "^illapachaw", "/^sa(t(urday)?)?/": "^k'uychichaw", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "quz-PE"; ================================================ FILE: build/i18n/ro-RO.js ================================================ /* * DateJS Culture String File * Country Code: ro-RO * Name: Romanian (Romania) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["ro-RO"] = { "name": "ro-RO", "englishName": "Romanian (Romania)", "nativeName": "română (România)", "Sunday": "duminică", "Monday": "luni", "Tuesday": "marţi", "Wednesday": "miercuri", "Thursday": "joi", "Friday": "vineri", "Saturday": "sâmbătă", "Sun": "D", "Mon": "L", "Tue": "Ma", "Wed": "Mi", "Thu": "J", "Fri": "V", "Sat": "S", "Su": "D", "Mo": "L", "Tu": "Ma", "We": "Mi", "Th": "J", "Fr": "V", "Sa": "S", "S_Sun_Initial": "D", "M_Mon_Initial": "L", "T_Tue_Initial": "M", "W_Wed_Initial": "M", "T_Thu_Initial": "J", "F_Fri_Initial": "V", "S_Sat_Initial": "S", "January": "ianuarie", "February": "februarie", "March": "martie", "April": "aprilie", "May": "mai", "June": "iunie", "July": "iulie", "August": "august", "September": "septembrie", "October": "octombrie", "November": "noiembrie", "December": "decembrie", "Jan_Abbr": "ian.", "Feb_Abbr": "feb.", "Mar_Abbr": "mar.", "Apr_Abbr": "apr.", "May_Abbr": "mai.", "Jun_Abbr": "iun.", "Jul_Abbr": "iul.", "Aug_Abbr": "aug.", "Sep_Abbr": "sep.", "Oct_Abbr": "oct.", "Nov_Abbr": "nov.", "Dec_Abbr": "dec.", "AM": "", "PM": "", "firstDayOfWeek": 1, "twoDigitYearMax": 2029, "mdy": "dmy", "M/d/yyyy": "dd.MM.yyyy", "dddd, MMMM dd, yyyy": "d MMMM yyyy", "h:mm tt": "HH:mm", "h:mm:ss tt": "HH:mm:ss", "dddd, MMMM dd, yyyy h:mm:ss tt": "d MMMM yyyy HH:mm:ss", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "d MMMM", "MMMM, yyyy": "MMMM yyyy", "/jan(uary)?/": "ian(.(uarie)?)?", "/feb(ruary)?/": "feb(.(ruarie)?)?", "/mar(ch)?/": "mar(.(tie)?)?", "/apr(il)?/": "apr(.(ilie)?)?", "/may/": "mai(.()?)?", "/jun(e)?/": "iun(.(ie)?)?", "/jul(y)?/": "iul(.(ie)?)?", "/aug(ust)?/": "aug(.(ust)?)?", "/sep(t(ember)?)?/": "sep(.(tembrie)?)?", "/oct(ober)?/": "oct(.(ombrie)?)?", "/nov(ember)?/": "noiembrie", "/dec(ember)?/": "dec(.(embrie)?)?", "/^su(n(day)?)?/": "^duminică", "/^mo(n(day)?)?/": "^luni", "/^tu(e(s(day)?)?)?/": "^marţi", "/^we(d(nesday)?)?/": "^miercuri", "/^th(u(r(s(day)?)?)?)?/": "^joi", "/^fr(i(day)?)?/": "^vineri", "/^sa(t(urday)?)?/": "^sâmbătă", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "ro-RO"; ================================================ FILE: build/i18n/ru-RU.js ================================================ /* * DateJS Culture String File * Country Code: ru-RU * Name: Russian (Russia) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["ru-RU"] = { "name": "ru-RU", "englishName": "Russian (Russia)", "nativeName": "Pусский (Россия)", "Sunday": "воскресенье", "Monday": "понедельник", "Tuesday": "вторник", "Wednesday": "среда", "Thursday": "четверг", "Friday": "пятница", "Saturday": "суббота", "Sun": "Вс", "Mon": "Пн", "Tue": "Вт", "Wed": "Ср", "Thu": "Чт", "Fri": "Пт", "Sat": "Сб", "Su": "Вс", "Mo": "Пн", "Tu": "Вт", "We": "Ср", "Th": "Чт", "Fr": "Пт", "Sa": "Сб", "S_Sun_Initial": "В", "M_Mon_Initial": "П", "T_Tue_Initial": "В", "W_Wed_Initial": "С", "T_Thu_Initial": "Ч", "F_Fri_Initial": "П", "S_Sat_Initial": "С", "January": "Январь", "February": "Февраль", "March": "Март", "April": "Апрель", "May": "Май", "June": "Июнь", "July": "Июль", "August": "Август", "September": "Сентябрь", "October": "Октябрь", "November": "Ноябрь", "December": "Декабрь", "Jan_Abbr": "янв", "Feb_Abbr": "фев", "Mar_Abbr": "мар", "Apr_Abbr": "апр", "May_Abbr": "май", "Jun_Abbr": "июн", "Jul_Abbr": "июл", "Aug_Abbr": "авг", "Sep_Abbr": "сен", "Oct_Abbr": "окт", "Nov_Abbr": "ноя", "Dec_Abbr": "дек", "AM": "", "PM": "", "firstDayOfWeek": 1, "twoDigitYearMax": 2029, "mdy": "dmy", "M/d/yyyy": "dd.MM.yyyy", "dddd, MMMM dd, yyyy": "d MMMM yyyy 'г.'", "h:mm tt": "H:mm", "h:mm:ss tt": "H:mm:ss", "dddd, MMMM dd, yyyy h:mm:ss tt": "d MMMM yyyy 'г.' H:mm:ss", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "MMMM dd", "MMMM, yyyy": "MMMM yyyy 'г.'", "/jan(uary)?/": "янв(арь)?", "/feb(ruary)?/": "фев(раль)?", "/mar(ch)?/": "мар(т)?", "/apr(il)?/": "апр(ель)?", "/may/": "май", "/jun(e)?/": "июн(ь)?", "/jul(y)?/": "июл(ь)?", "/aug(ust)?/": "авг(уст)?", "/sep(t(ember)?)?/": "сен(тябрь)?", "/oct(ober)?/": "окт(ябрь)?", "/nov(ember)?/": "ноя(брь)?", "/dec(ember)?/": "дек(абрь)?", "/^su(n(day)?)?/": "^воскресенье", "/^mo(n(day)?)?/": "^понедельник", "/^tu(e(s(day)?)?)?/": "^вторник", "/^we(d(nesday)?)?/": "^среда", "/^th(u(r(s(day)?)?)?)?/": "^четверг", "/^fr(i(day)?)?/": "^пятница", "/^sa(t(urday)?)?/": "^суббота", "/^next/": "^след|завтра", "/^last|past|prev(ious)?/": "^пред|вчера", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|через|после|вперед|и|следую?щ(ая|ий|ее)?)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|за|до|поза|пе?ред((ыдущ|шев?ствующ)(ая|ий|ее))|назад)", "/^yes(terday)?/": "^вчера", "/^t(od(ay)?)?/": "^сегодня", "/^tom(orrow)?/": "^завтра", "/^n(ow)?/": "^сейчас|сечас|щас", "/^ms|milli(second)?s?/": "^мс|мили(секунд)?s?", "/^sec(ond)?s?/": "^с(ек(унд)?)?", "/^mn|min(ute)?s?/": "^м(ин(ут)?)?", "/^h(our)?s?/": "^ч((ас)?ов)?", "/^w(eek)?s?/": "^н(ед(ель)?)?", "/^m(onth)?s?/": "^мес(яцев)?", "/^d(ay)?s?/": "^д(ень|ней|ня)?", "/^y(ear)?s?/": "^г(ода?)?|л(ет)?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "ru-RU"; ================================================ FILE: build/i18n/sa-IN.js ================================================ /* * DateJS Culture String File * Country Code: sa-IN * Name: Sanskrit (India) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["sa-IN"] = { "name": "sa-IN", "englishName": "Sanskrit (India)", "nativeName": "संस्कृत (भारतम्)", "Sunday": "रविवासरः", "Monday": "सोमवासरः", "Tuesday": "मङ्गलवासरः", "Wednesday": "बुधवासरः", "Thursday": "गुरुवासरः", "Friday": "शुक्रवासरः", "Saturday": "शनिवासरः", "Sun": "रविवासरः", "Mon": "सोमवासरः", "Tue": "मङ्गलवासरः", "Wed": "बुधवासरः", "Thu": "गुरुवासरः", "Fri": "शुक्रवासरः", "Sat": "शनिवासरः", "Su": "र", "Mo": "स", "Tu": "म", "We": "ब", "Th": "ग", "Fr": "श", "Sa": "श", "S_Sun_Initial": "र", "M_Mon_Initial": "स", "T_Tue_Initial": "म", "W_Wed_Initial": "ब", "T_Thu_Initial": "ग", "F_Fri_Initial": "श", "S_Sat_Initial": "श", "January": "जनवरी", "February": "फरवरी", "March": "मार्च", "April": "अप्रैल", "May": "मई", "June": "जून", "July": "जुलाई", "August": "अगस्त", "September": "सितम्बर", "October": "अक्तूबर", "November": "नवम्बर", "December": "दिसम्बर", "Jan_Abbr": "जनवरी", "Feb_Abbr": "फरवरी", "Mar_Abbr": "मार्च", "Apr_Abbr": "अप्रैल", "May_Abbr": "मई", "Jun_Abbr": "जून", "Jul_Abbr": "जुलाई", "Aug_Abbr": "अगस्त", "Sep_Abbr": "सितम्बर", "Oct_Abbr": "अक्तूबर", "Nov_Abbr": "नवम्बर", "Dec_Abbr": "दिसम्बर", "AM": "पूर्वाह्न", "PM": "अपराह्न", "firstDayOfWeek": 0, "twoDigitYearMax": 2029, "mdy": "dmy", "M/d/yyyy": "dd-MM-yyyy", "dddd, MMMM dd, yyyy": "dd MMMM yyyy dddd", "h:mm tt": "HH:mm", "h:mm:ss tt": "HH:mm:ss", "dddd, MMMM dd, yyyy h:mm:ss tt": "dd MMMM yyyy dddd HH:mm:ss", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "dd MMMM", "MMMM, yyyy": "MMMM, yyyy", "/jan(uary)?/": "जनवरी", "/feb(ruary)?/": "फरवरी", "/mar(ch)?/": "मार्च", "/apr(il)?/": "अप्रैल", "/may/": "मई", "/jun(e)?/": "जून", "/jul(y)?/": "जुलाई", "/aug(ust)?/": "अगस्त", "/sep(t(ember)?)?/": "सितम्बर", "/oct(ober)?/": "अक्तूबर", "/nov(ember)?/": "नवम्बर", "/dec(ember)?/": "दिसम्बर", "/^su(n(day)?)?/": "^र(1)?", "/^mo(n(day)?)?/": "^स(1)?", "/^tu(e(s(day)?)?)?/": "^म(1)?", "/^we(d(nesday)?)?/": "^ब(1)?", "/^th(u(r(s(day)?)?)?)?/": "^ग(1)?", "/^fr(i(day)?)?/": "^श(1)?", "/^sa(t(urday)?)?/": "^श(1)?", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "sa-IN"; ================================================ FILE: build/i18n/se-FI.js ================================================ /* * DateJS Culture String File * Country Code: se-FI * Name: Sami (Northern) (Finland) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["se-FI"] = { "name": "se-FI", "englishName": "Sami (Northern) (Finland)", "nativeName": "davvisámegiella (Suopma)", "Sunday": "sotnabeaivi", "Monday": "vuossárga", "Tuesday": "maŋŋebárga", "Wednesday": "gaskavahkku", "Thursday": "duorastat", "Friday": "bearjadat", "Saturday": "lávvardat", "Sun": "sotn", "Mon": "vuos", "Tue": "maŋ", "Wed": "gask", "Thu": "duor", "Fri": "bear", "Sat": "láv", "Su": "sotn", "Mo": "vuos", "Tu": "maŋ", "We": "gask", "Th": "duor", "Fr": "bear", "Sa": "láv", "S_Sun_Initial": "s", "M_Mon_Initial": "v", "T_Tue_Initial": "m", "W_Wed_Initial": "g", "T_Thu_Initial": "d", "F_Fri_Initial": "b", "S_Sat_Initial": "l", "January": "ođđajagemánnu", "February": "guovvamánnu", "March": "njukčamánnu", "April": "cuoŋománnu", "May": "miessemánnu", "June": "geassemánnu", "July": "suoidnemánnu", "August": "borgemánnu", "September": "čakčamánnu", "October": "golggotmánnu", "November": "skábmamánnu", "December": "juovlamánnu", "Jan_Abbr": "ođđj", "Feb_Abbr": "guov", "Mar_Abbr": "njuk", "Apr_Abbr": "cuo", "May_Abbr": "mies", "Jun_Abbr": "geas", "Jul_Abbr": "suoi", "Aug_Abbr": "borg", "Sep_Abbr": "čakč", "Oct_Abbr": "golg", "Nov_Abbr": "skáb", "Dec_Abbr": "juov", "AM": "", "PM": "", "firstDayOfWeek": 1, "twoDigitYearMax": 2029, "mdy": "dmy", "M/d/yyyy": "d.M.yyyy", "dddd, MMMM dd, yyyy": "MMMM d'. b. 'yyyy", "h:mm tt": "H:mm:ss", "h:mm:ss tt": "H:mm:ss", "dddd, MMMM dd, yyyy h:mm:ss tt": "MMMM d'. b. 'yyyy H:mm:ss", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "MMMM dd", "MMMM, yyyy": "MMMM yyyy", "/jan(uary)?/": "ođđajagemánnu", "/feb(ruary)?/": "guov(vamánnu)?", "/mar(ch)?/": "njuk(čamánnu)?", "/apr(il)?/": "cuo(ŋománnu)?", "/may/": "mies(semánnu)?", "/jun(e)?/": "geas(semánnu)?", "/jul(y)?/": "suoi(dnemánnu)?", "/aug(ust)?/": "borg(emánnu)?", "/sep(t(ember)?)?/": "čakč(amánnu)?", "/oct(ober)?/": "golg(gotmánnu)?", "/nov(ember)?/": "skáb(mamánnu)?", "/dec(ember)?/": "juov(lamánnu)?", "/^su(n(day)?)?/": "^sotnabeaivi", "/^mo(n(day)?)?/": "^vuossárga", "/^tu(e(s(day)?)?)?/": "^maŋŋebárga", "/^we(d(nesday)?)?/": "^gaskavahkku", "/^th(u(r(s(day)?)?)?)?/": "^duorastat", "/^fr(i(day)?)?/": "^bearjadat", "/^sa(t(urday)?)?/": "^lávvardat", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "se-FI"; ================================================ FILE: build/i18n/se-NO.js ================================================ /* * DateJS Culture String File * Country Code: se-NO * Name: Sami (Northern) (Norway) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["se-NO"] = { "name": "se-NO", "englishName": "Sami (Northern) (Norway)", "nativeName": "davvisámegiella (Norga)", "Sunday": "sotnabeaivi", "Monday": "vuossárga", "Tuesday": "maŋŋebárga", "Wednesday": "gaskavahkku", "Thursday": "duorastat", "Friday": "bearjadat", "Saturday": "lávvardat", "Sun": "sotn", "Mon": "vuos", "Tue": "maŋ", "Wed": "gask", "Thu": "duor", "Fri": "bear", "Sat": "láv", "Su": "sotn", "Mo": "vuos", "Tu": "maŋ", "We": "gask", "Th": "duor", "Fr": "bear", "Sa": "láv", "S_Sun_Initial": "s", "M_Mon_Initial": "v", "T_Tue_Initial": "m", "W_Wed_Initial": "g", "T_Thu_Initial": "d", "F_Fri_Initial": "b", "S_Sat_Initial": "l", "January": "ođđajagemánnu", "February": "guovvamánnu", "March": "njukčamánnu", "April": "cuoŋománnu", "May": "miessemánnu", "June": "geassemánnu", "July": "suoidnemánnu", "August": "borgemánnu", "September": "čakčamánnu", "October": "golggotmánnu", "November": "skábmamánnu", "December": "juovlamánnu", "Jan_Abbr": "ođđj", "Feb_Abbr": "guov", "Mar_Abbr": "njuk", "Apr_Abbr": "cuo", "May_Abbr": "mies", "Jun_Abbr": "geas", "Jul_Abbr": "suoi", "Aug_Abbr": "borg", "Sep_Abbr": "čakč", "Oct_Abbr": "golg", "Nov_Abbr": "skáb", "Dec_Abbr": "juov", "AM": "", "PM": "", "firstDayOfWeek": 1, "twoDigitYearMax": 2029, "mdy": "dmy", "M/d/yyyy": "dd.MM.yyyy", "dddd, MMMM dd, yyyy": "MMMM d'. b. 'yyyy", "h:mm tt": "HH:mm:ss", "h:mm:ss tt": "HH:mm:ss", "dddd, MMMM dd, yyyy h:mm:ss tt": "MMMM d'. b. 'yyyy HH:mm:ss", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "MMMM dd", "MMMM, yyyy": "MMMM yyyy", "/jan(uary)?/": "ođđajagemánnu", "/feb(ruary)?/": "guov(vamánnu)?", "/mar(ch)?/": "njuk(čamánnu)?", "/apr(il)?/": "cuo(ŋománnu)?", "/may/": "mies(semánnu)?", "/jun(e)?/": "geas(semánnu)?", "/jul(y)?/": "suoi(dnemánnu)?", "/aug(ust)?/": "borg(emánnu)?", "/sep(t(ember)?)?/": "čakč(amánnu)?", "/oct(ober)?/": "golg(gotmánnu)?", "/nov(ember)?/": "skáb(mamánnu)?", "/dec(ember)?/": "juov(lamánnu)?", "/^su(n(day)?)?/": "^sotnabeaivi", "/^mo(n(day)?)?/": "^vuossárga", "/^tu(e(s(day)?)?)?/": "^maŋŋebárga", "/^we(d(nesday)?)?/": "^gaskavahkku", "/^th(u(r(s(day)?)?)?)?/": "^duorastat", "/^fr(i(day)?)?/": "^bearjadat", "/^sa(t(urday)?)?/": "^lávvardat", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "se-NO"; ================================================ FILE: build/i18n/se-SE.js ================================================ /* * DateJS Culture String File * Country Code: se-SE * Name: Sami (Northern) (Sweden) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["se-SE"] = { "name": "se-SE", "englishName": "Sami (Northern) (Sweden)", "nativeName": "davvisámegiella (Ruoŧŧa)", "Sunday": "sotnabeaivi", "Monday": "mánnodat", "Tuesday": "disdat", "Wednesday": "gaskavahkku", "Thursday": "duorastat", "Friday": "bearjadat", "Saturday": "lávvardat", "Sun": "sotn", "Mon": "mán", "Tue": "dis", "Wed": "gask", "Thu": "duor", "Fri": "bear", "Sat": "láv", "Su": "sotn", "Mo": "mán", "Tu": "dis", "We": "gask", "Th": "duor", "Fr": "bear", "Sa": "láv", "S_Sun_Initial": "s", "M_Mon_Initial": "m", "T_Tue_Initial": "d", "W_Wed_Initial": "g", "T_Thu_Initial": "d", "F_Fri_Initial": "b", "S_Sat_Initial": "l", "January": "ođđajagemánnu", "February": "guovvamánnu", "March": "njukčamánnu", "April": "cuoŋománnu", "May": "miessemánnu", "June": "geassemánnu", "July": "suoidnemánnu", "August": "borgemánnu", "September": "čakčamánnu", "October": "golggotmánnu", "November": "skábmamánnu", "December": "juovlamánnu", "Jan_Abbr": "ođđj", "Feb_Abbr": "guov", "Mar_Abbr": "njuk", "Apr_Abbr": "cuo", "May_Abbr": "mies", "Jun_Abbr": "geas", "Jul_Abbr": "suoi", "Aug_Abbr": "borg", "Sep_Abbr": "čakč", "Oct_Abbr": "golg", "Nov_Abbr": "skáb", "Dec_Abbr": "juov", "AM": "", "PM": "", "firstDayOfWeek": 1, "twoDigitYearMax": 2029, "mdy": "ymd", "M/d/yyyy": "yyyy-MM-dd", "dddd, MMMM dd, yyyy": "MMMM d'. b. 'yyyy", "h:mm tt": "HH:mm:ss", "h:mm:ss tt": "HH:mm:ss", "dddd, MMMM dd, yyyy h:mm:ss tt": "MMMM d'. b. 'yyyy HH:mm:ss", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "MMMM dd", "MMMM, yyyy": "MMMM yyyy", "/jan(uary)?/": "ođđajagemánnu", "/feb(ruary)?/": "guov(vamánnu)?", "/mar(ch)?/": "njuk(čamánnu)?", "/apr(il)?/": "cuo(ŋománnu)?", "/may/": "mies(semánnu)?", "/jun(e)?/": "geas(semánnu)?", "/jul(y)?/": "suoi(dnemánnu)?", "/aug(ust)?/": "borg(emánnu)?", "/sep(t(ember)?)?/": "čakč(amánnu)?", "/oct(ober)?/": "golg(gotmánnu)?", "/nov(ember)?/": "skáb(mamánnu)?", "/dec(ember)?/": "juov(lamánnu)?", "/^su(n(day)?)?/": "^sotnabeaivi", "/^mo(n(day)?)?/": "^mánnodat", "/^tu(e(s(day)?)?)?/": "^disdat", "/^we(d(nesday)?)?/": "^gaskavahkku", "/^th(u(r(s(day)?)?)?)?/": "^duorastat", "/^fr(i(day)?)?/": "^bearjadat", "/^sa(t(urday)?)?/": "^lávvardat", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "se-SE"; ================================================ FILE: build/i18n/sk-SK.js ================================================ /* * DateJS Culture String File * Country Code: sk-SK * Name: Slovak (Slovakia) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["sk-SK"] = { "name": "sk-SK", "englishName": "Slovak (Slovakia)", "nativeName": "slovenčina (Slovenská republika)", "Sunday": "nedeľa", "Monday": "pondelok", "Tuesday": "utorok", "Wednesday": "streda", "Thursday": "štvrtok", "Friday": "piatok", "Saturday": "sobota", "Sun": "ne", "Mon": "po", "Tue": "ut", "Wed": "st", "Thu": "št", "Fri": "pi", "Sat": "so", "Su": "ne", "Mo": "po", "Tu": "ut", "We": "st", "Th": "št", "Fr": "pi", "Sa": "so", "S_Sun_Initial": "n", "M_Mon_Initial": "p", "T_Tue_Initial": "u", "W_Wed_Initial": "s", "T_Thu_Initial": "š", "F_Fri_Initial": "p", "S_Sat_Initial": "s", "January": "január", "February": "február", "March": "marec", "April": "apríl", "May": "máj", "June": "jún", "July": "júl", "August": "august", "September": "september", "October": "október", "November": "november", "December": "december", "Jan_Abbr": "I", "Feb_Abbr": "II", "Mar_Abbr": "III", "Apr_Abbr": "IV", "May_Abbr": "V", "Jun_Abbr": "VI", "Jul_Abbr": "VII", "Aug_Abbr": "VIII", "Sep_Abbr": "IX", "Oct_Abbr": "X", "Nov_Abbr": "XI", "Dec_Abbr": "XII", "AM": "", "PM": "", "firstDayOfWeek": 1, "twoDigitYearMax": 2029, "mdy": "dmy", "M/d/yyyy": "d. M. yyyy", "dddd, MMMM dd, yyyy": "d. MMMM yyyy", "h:mm tt": "H:mm", "h:mm:ss tt": "H:mm:ss", "dddd, MMMM dd, yyyy h:mm:ss tt": "d. MMMM yyyy H:mm:ss", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "dd MMMM", "MMMM, yyyy": "MMMM yyyy", "/jan(uary)?/": "január", "/feb(ruary)?/": "február", "/mar(ch)?/": "marec", "/apr(il)?/": "apríl", "/may/": "máj", "/jun(e)?/": "jún", "/jul(y)?/": "júl", "/aug(ust)?/": "august", "/sep(t(ember)?)?/": "sep(t(ember)?)?", "/oct(ober)?/": "október", "/nov(ember)?/": "november", "/dec(ember)?/": "december", "/^su(n(day)?)?/": "^nedeľa", "/^mo(n(day)?)?/": "^pondelok", "/^tu(e(s(day)?)?)?/": "^utorok", "/^we(d(nesday)?)?/": "^streda", "/^th(u(r(s(day)?)?)?)?/": "^štvrtok", "/^fr(i(day)?)?/": "^piatok", "/^sa(t(urday)?)?/": "^sobota", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "sk-SK"; ================================================ FILE: build/i18n/sl-SI.js ================================================ /* * DateJS Culture String File * Country Code: sl-SI * Name: Slovenian (Slovenia) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["sl-SI"] = { "name": "sl-SI", "englishName": "Slovenian (Slovenia)", "nativeName": "slovenski (Slovenija)", "Sunday": "nedelja", "Monday": "ponedeljek", "Tuesday": "torek", "Wednesday": "sreda", "Thursday": "četrtek", "Friday": "petek", "Saturday": "sobota", "Sun": "ned", "Mon": "pon", "Tue": "tor", "Wed": "sre", "Thu": "čet", "Fri": "pet", "Sat": "sob", "Su": "ne", "Mo": "po", "Tu": "to", "We": "sr", "Th": "če", "Fr": "pe", "Sa": "so", "S_Sun_Initial": "n", "M_Mon_Initial": "p", "T_Tue_Initial": "t", "W_Wed_Initial": "s", "T_Thu_Initial": "č", "F_Fri_Initial": "p", "S_Sat_Initial": "s", "January": "januar", "February": "februar", "March": "marec", "April": "april", "May": "maj", "June": "junij", "July": "julij", "August": "avgust", "September": "september", "October": "oktober", "November": "november", "December": "december", "Jan_Abbr": "jan", "Feb_Abbr": "feb", "Mar_Abbr": "mar", "Apr_Abbr": "apr", "May_Abbr": "maj", "Jun_Abbr": "jun", "Jul_Abbr": "jul", "Aug_Abbr": "avg", "Sep_Abbr": "sep", "Oct_Abbr": "okt", "Nov_Abbr": "nov", "Dec_Abbr": "dec", "AM": "", "PM": "", "firstDayOfWeek": 1, "twoDigitYearMax": 2029, "mdy": "dmy", "M/d/yyyy": "d.M.yyyy", "dddd, MMMM dd, yyyy": "d. MMMM yyyy", "h:mm tt": "H:mm", "h:mm:ss tt": "H:mm:ss", "dddd, MMMM dd, yyyy h:mm:ss tt": "d. MMMM yyyy H:mm:ss", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "d. MMMM", "MMMM, yyyy": "MMMM yyyy", "/jan(uary)?/": "jan(uar)?", "/feb(ruary)?/": "feb(ruar)?", "/mar(ch)?/": "mar(ec)?", "/apr(il)?/": "apr(il)?", "/may/": "maj", "/jun(e)?/": "jun(ij)?", "/jul(y)?/": "jul(ij)?", "/aug(ust)?/": "avg(ust)?", "/sep(t(ember)?)?/": "sep(t(ember)?)?", "/oct(ober)?/": "okt(ober)?", "/nov(ember)?/": "nov(ember)?", "/dec(ember)?/": "dec(ember)?", "/^su(n(day)?)?/": "^ne(d(elja)?)?", "/^mo(n(day)?)?/": "^po(n(edeljek)?)?", "/^tu(e(s(day)?)?)?/": "^to(r(ek)?)?", "/^we(d(nesday)?)?/": "^sr(e(da)?)?", "/^th(u(r(s(day)?)?)?)?/": "^če(t(rtek)?)?", "/^fr(i(day)?)?/": "^pe(t(ek)?)?", "/^sa(t(urday)?)?/": "^so(b(ota)?)?", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "sl-SI"; ================================================ FILE: build/i18n/sma-NO.js ================================================ /* * DateJS Culture String File * Country Code: sma-NO * Name: Sami (Southern) (Norway) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["sma-NO"] = { "name": "sma-NO", "englishName": "Sami (Southern) (Norway)", "nativeName": "åarjelsaemiengiele (Nöörje)", "Sunday": "aejlege", "Monday": "måanta", "Tuesday": "dæjsta", "Wednesday": "gaskevåhkoe", "Thursday": "duarsta", "Friday": "bearjadahke", "Saturday": "laavvardahke", "Sun": "aej", "Mon": "måa", "Tue": "dæj", "Wed": "gask", "Thu": "duar", "Fri": "bearj", "Sat": "laav", "Su": "aej", "Mo": "måa", "Tu": "dæj", "We": "gask", "Th": "duar", "Fr": "bearj", "Sa": "laav", "S_Sun_Initial": "a", "M_Mon_Initial": "m", "T_Tue_Initial": "d", "W_Wed_Initial": "g", "T_Thu_Initial": "d", "F_Fri_Initial": "b", "S_Sat_Initial": "l", "January": "tsïengele", "February": "goevte", "March": "njoktje", "April": "voerhtje", "May": "suehpede", "June": "ruffie", "July": "snjaltje", "August": "mïetske", "September": "skïerede", "October": "golke", "November": "rahka", "December": "goeve", "Jan_Abbr": "tsïen", "Feb_Abbr": "goevt", "Mar_Abbr": "njok", "Apr_Abbr": "voer", "May_Abbr": "sueh", "Jun_Abbr": "ruff", "Jul_Abbr": "snja", "Aug_Abbr": "mïet", "Sep_Abbr": "skïer", "Oct_Abbr": "golk", "Nov_Abbr": "rahk", "Dec_Abbr": "goev", "AM": "", "PM": "", "firstDayOfWeek": 1, "twoDigitYearMax": 2029, "mdy": "dmy", "M/d/yyyy": "dd.MM.yyyy", "dddd, MMMM dd, yyyy": "MMMM d'. b. 'yyyy", "h:mm tt": "HH:mm:ss", "h:mm:ss tt": "HH:mm:ss", "dddd, MMMM dd, yyyy h:mm:ss tt": "MMMM d'. b. 'yyyy HH:mm:ss", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "MMMM dd", "MMMM, yyyy": "MMMM yyyy", "/jan(uary)?/": "tsïen(gele)?", "/feb(ruary)?/": "goevt(e)?", "/mar(ch)?/": "njok(tje)?", "/apr(il)?/": "voer(htje)?", "/may/": "sueh(pede)?", "/jun(e)?/": "ruff(ie)?", "/jul(y)?/": "snja(ltje)?", "/aug(ust)?/": "mïet(ske)?", "/sep(t(ember)?)?/": "skïer(ede)?", "/oct(ober)?/": "golk(e)?", "/nov(ember)?/": "rahk(a)?", "/dec(ember)?/": "goev(e)?", "/^su(n(day)?)?/": "^aejlege", "/^mo(n(day)?)?/": "^måanta", "/^tu(e(s(day)?)?)?/": "^dæjsta", "/^we(d(nesday)?)?/": "^gaskevåhkoe", "/^th(u(r(s(day)?)?)?)?/": "^duarsta", "/^fr(i(day)?)?/": "^bearjadahke", "/^sa(t(urday)?)?/": "^laavvardahke", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "sma-NO"; ================================================ FILE: build/i18n/sma-SE.js ================================================ /* * DateJS Culture String File * Country Code: sma-SE * Name: Sami (Southern) (Sweden) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["sma-SE"] = { "name": "sma-SE", "englishName": "Sami (Southern) (Sweden)", "nativeName": "åarjelsaemiengiele (Sveerje)", "Sunday": "aejlege", "Monday": "måanta", "Tuesday": "dæjsta", "Wednesday": "gaskevåhkoe", "Thursday": "duarsta", "Friday": "bearjadahke", "Saturday": "laavvardahke", "Sun": "aej", "Mon": "måa", "Tue": "dæj", "Wed": "gask", "Thu": "duar", "Fri": "bearj", "Sat": "laav", "Su": "aej", "Mo": "måa", "Tu": "dæj", "We": "gask", "Th": "duar", "Fr": "bearj", "Sa": "laav", "S_Sun_Initial": "a", "M_Mon_Initial": "m", "T_Tue_Initial": "d", "W_Wed_Initial": "g", "T_Thu_Initial": "d", "F_Fri_Initial": "b", "S_Sat_Initial": "l", "January": "tsïengele", "February": "goevte", "March": "njoktje", "April": "voerhtje", "May": "suehpede", "June": "ruffie", "July": "snjaltje", "August": "mïetske", "September": "skïerede", "October": "golke", "November": "rahka", "December": "goeve", "Jan_Abbr": "tsïen", "Feb_Abbr": "goevt", "Mar_Abbr": "njok", "Apr_Abbr": "voer", "May_Abbr": "sueh", "Jun_Abbr": "ruff", "Jul_Abbr": "snja", "Aug_Abbr": "mïet", "Sep_Abbr": "skïer", "Oct_Abbr": "golk", "Nov_Abbr": "rahk", "Dec_Abbr": "goev", "AM": "", "PM": "", "firstDayOfWeek": 1, "twoDigitYearMax": 2029, "mdy": "ymd", "M/d/yyyy": "yyyy-MM-dd", "dddd, MMMM dd, yyyy": "MMMM d'. b. 'yyyy", "h:mm tt": "HH:mm:ss", "h:mm:ss tt": "HH:mm:ss", "dddd, MMMM dd, yyyy h:mm:ss tt": "MMMM d'. b. 'yyyy HH:mm:ss", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "MMMM dd", "MMMM, yyyy": "MMMM yyyy", "/jan(uary)?/": "tsïen(gele)?", "/feb(ruary)?/": "goevt(e)?", "/mar(ch)?/": "njok(tje)?", "/apr(il)?/": "voer(htje)?", "/may/": "sueh(pede)?", "/jun(e)?/": "ruff(ie)?", "/jul(y)?/": "snja(ltje)?", "/aug(ust)?/": "mïet(ske)?", "/sep(t(ember)?)?/": "skïer(ede)?", "/oct(ober)?/": "golk(e)?", "/nov(ember)?/": "rahk(a)?", "/dec(ember)?/": "goev(e)?", "/^su(n(day)?)?/": "^aejlege", "/^mo(n(day)?)?/": "^måanta", "/^tu(e(s(day)?)?)?/": "^dæjsta", "/^we(d(nesday)?)?/": "^gaskevåhkoe", "/^th(u(r(s(day)?)?)?)?/": "^duarsta", "/^fr(i(day)?)?/": "^bearjadahke", "/^sa(t(urday)?)?/": "^laavvardahke", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "sma-SE"; ================================================ FILE: build/i18n/smj-NO.js ================================================ /* * DateJS Culture String File * Country Code: smj-NO * Name: Sami (Lule) (Norway) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["smj-NO"] = { "name": "smj-NO", "englishName": "Sami (Lule) (Norway)", "nativeName": "julevusámegiella (Vuodna)", "Sunday": "sådnåbiejvve", "Monday": "mánnodahka", "Tuesday": "dijstahka", "Wednesday": "gasskavahkko", "Thursday": "duorastahka", "Friday": "bierjjedahka", "Saturday": "lávvodahka", "Sun": "såd", "Mon": "mán", "Tue": "dis", "Wed": "gas", "Thu": "duor", "Fri": "bier", "Sat": "láv", "Su": "såd", "Mo": "mán", "Tu": "dis", "We": "gas", "Th": "duor", "Fr": "bier", "Sa": "láv", "S_Sun_Initial": "s", "M_Mon_Initial": "m", "T_Tue_Initial": "d", "W_Wed_Initial": "g", "T_Thu_Initial": "d", "F_Fri_Initial": "b", "S_Sat_Initial": "l", "January": "ådåjakmánno", "February": "guovvamánno", "March": "sjnjuktjamánno", "April": "vuoratjismánno", "May": "moarmesmánno", "June": "biehtsemánno", "July": "sjnjilltjamánno", "August": "bårggemánno", "September": "ragátmánno", "October": "gålgådismánno", "November": "basádismánno", "December": "javllamánno", "Jan_Abbr": "ådåj", "Feb_Abbr": "guov", "Mar_Abbr": "snju", "Apr_Abbr": "vuor", "May_Abbr": "moar", "Jun_Abbr": "bieh", "Jul_Abbr": "snji", "Aug_Abbr": "bårg", "Sep_Abbr": "ragá", "Oct_Abbr": "gålg", "Nov_Abbr": "basá", "Dec_Abbr": "javl", "AM": "", "PM": "", "firstDayOfWeek": 1, "twoDigitYearMax": 2029, "mdy": "dmy", "M/d/yyyy": "dd.MM.yyyy", "dddd, MMMM dd, yyyy": "MMMM d'. b. 'yyyy", "h:mm tt": "HH:mm:ss", "h:mm:ss tt": "HH:mm:ss", "dddd, MMMM dd, yyyy h:mm:ss tt": "MMMM d'. b. 'yyyy HH:mm:ss", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "MMMM dd", "MMMM, yyyy": "MMMM yyyy", "/jan(uary)?/": "ådåj(akmánno)?", "/feb(ruary)?/": "guov(vamánno)?", "/mar(ch)?/": "sjnjuktjamánno", "/apr(il)?/": "vuor(atjismánno)?", "/may/": "moar(mesmánno)?", "/jun(e)?/": "bieh(tsemánno)?", "/jul(y)?/": "sjnjilltjamánno", "/aug(ust)?/": "bårg(gemánno)?", "/sep(t(ember)?)?/": "ragá(tmánno)?", "/oct(ober)?/": "gålg(ådismánno)?", "/nov(ember)?/": "basá(dismánno)?", "/dec(ember)?/": "javl(lamánno)?", "/^su(n(day)?)?/": "^sådnåbiejvve", "/^mo(n(day)?)?/": "^mánnodahka", "/^tu(e(s(day)?)?)?/": "^dijstahka", "/^we(d(nesday)?)?/": "^gasskavahkko", "/^th(u(r(s(day)?)?)?)?/": "^duorastahka", "/^fr(i(day)?)?/": "^bierjjedahka", "/^sa(t(urday)?)?/": "^lávvodahka", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "smj-NO"; ================================================ FILE: build/i18n/smj-SE.js ================================================ /* * DateJS Culture String File * Country Code: smj-SE * Name: Sami (Lule) (Sweden) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["smj-SE"] = { "name": "smj-SE", "englishName": "Sami (Lule) (Sweden)", "nativeName": "julevusámegiella (Svierik)", "Sunday": "ájllek", "Monday": "mánnodahka", "Tuesday": "dijstahka", "Wednesday": "gasskavahkko", "Thursday": "duorastahka", "Friday": "bierjjedahka", "Saturday": "lávvodahka", "Sun": "ájl", "Mon": "mán", "Tue": "dis", "Wed": "gas", "Thu": "duor", "Fri": "bier", "Sat": "láv", "Su": "ájl", "Mo": "mán", "Tu": "dis", "We": "gas", "Th": "duor", "Fr": "bier", "Sa": "láv", "S_Sun_Initial": "á", "M_Mon_Initial": "m", "T_Tue_Initial": "d", "W_Wed_Initial": "g", "T_Thu_Initial": "d", "F_Fri_Initial": "b", "S_Sat_Initial": "l", "January": "ådåjakmánno", "February": "guovvamánno", "March": "sjnjuktjamánno", "April": "vuoratjismánno", "May": "moarmesmánno", "June": "biehtsemánno", "July": "sjnjilltjamánno", "August": "bårggemánno", "September": "ragátmánno", "October": "gålgådismánno", "November": "basádismánno", "December": "javllamánno", "Jan_Abbr": "ådåj", "Feb_Abbr": "guov", "Mar_Abbr": "snju", "Apr_Abbr": "vuor", "May_Abbr": "moar", "Jun_Abbr": "bieh", "Jul_Abbr": "snji", "Aug_Abbr": "bårg", "Sep_Abbr": "ragá", "Oct_Abbr": "gålg", "Nov_Abbr": "basá", "Dec_Abbr": "javl", "AM": "", "PM": "", "firstDayOfWeek": 1, "twoDigitYearMax": 2029, "mdy": "ymd", "M/d/yyyy": "yyyy-MM-dd", "dddd, MMMM dd, yyyy": "MMMM d'. b. 'yyyy", "h:mm tt": "HH:mm:ss", "h:mm:ss tt": "HH:mm:ss", "dddd, MMMM dd, yyyy h:mm:ss tt": "MMMM d'. b. 'yyyy HH:mm:ss", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "MMMM dd", "MMMM, yyyy": "MMMM yyyy", "/jan(uary)?/": "ådåj(akmánno)?", "/feb(ruary)?/": "guov(vamánno)?", "/mar(ch)?/": "sjnjuktjamánno", "/apr(il)?/": "vuor(atjismánno)?", "/may/": "moar(mesmánno)?", "/jun(e)?/": "bieh(tsemánno)?", "/jul(y)?/": "sjnjilltjamánno", "/aug(ust)?/": "bårg(gemánno)?", "/sep(t(ember)?)?/": "ragá(tmánno)?", "/oct(ober)?/": "gålg(ådismánno)?", "/nov(ember)?/": "basá(dismánno)?", "/dec(ember)?/": "javl(lamánno)?", "/^su(n(day)?)?/": "^ájllek", "/^mo(n(day)?)?/": "^mánnodahka", "/^tu(e(s(day)?)?)?/": "^dijstahka", "/^we(d(nesday)?)?/": "^gasskavahkko", "/^th(u(r(s(day)?)?)?)?/": "^duorastahka", "/^fr(i(day)?)?/": "^bierjjedahka", "/^sa(t(urday)?)?/": "^lávvodahka", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "smj-SE"; ================================================ FILE: build/i18n/smn-FI.js ================================================ /* * DateJS Culture String File * Country Code: smn-FI * Name: Sami (Inari) (Finland) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["smn-FI"] = { "name": "smn-FI", "englishName": "Sami (Inari) (Finland)", "nativeName": "sämikielâ (Suomâ)", "Sunday": "pasepeivi", "Monday": "vuossargâ", "Tuesday": "majebargâ", "Wednesday": "koskokko", "Thursday": "tuorâstâh", "Friday": "vástuppeivi", "Saturday": "lávárdâh", "Sun": "pa", "Mon": "vu", "Tue": "ma", "Wed": "ko", "Thu": "tu", "Fri": "vá", "Sat": "lá", "Su": "pa", "Mo": "vu", "Tu": "ma", "We": "ko", "Th": "tu", "Fr": "vá", "Sa": "lá", "S_Sun_Initial": "p", "M_Mon_Initial": "v", "T_Tue_Initial": "m", "W_Wed_Initial": "k", "T_Thu_Initial": "t", "F_Fri_Initial": "v", "S_Sat_Initial": "l", "January": "uđđâivemáánu", "February": "kuovâmáánu", "March": "njuhčâmáánu", "April": "cuáŋuimáánu", "May": "vyesimáánu", "June": "kesimáánu", "July": "syeinimáánu", "August": "porgemáánu", "September": "čohčâmáánu", "October": "roovvâdmáánu", "November": "skammâmáánu", "December": "juovlâmáánu", "Jan_Abbr": "uđiv", "Feb_Abbr": "kuov", "Mar_Abbr": "njuh", "Apr_Abbr": "cuoŋ", "May_Abbr": "vyes", "Jun_Abbr": "kesi", "Jul_Abbr": "syei", "Aug_Abbr": "porg", "Sep_Abbr": "čoh", "Oct_Abbr": "roov", "Nov_Abbr": "ska", "Dec_Abbr": "juov", "AM": "", "PM": "", "firstDayOfWeek": 1, "twoDigitYearMax": 2029, "mdy": "dmy", "M/d/yyyy": "d.M.yyyy", "dddd, MMMM dd, yyyy": "MMMM d'. p. 'yyyy", "h:mm tt": "H:mm:ss", "h:mm:ss tt": "H:mm:ss", "dddd, MMMM dd, yyyy h:mm:ss tt": "MMMM d'. p. 'yyyy H:mm:ss", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "MMMM dd", "MMMM, yyyy": "MMMM yyyy", "/jan(uary)?/": "uđđâivemáánu", "/feb(ruary)?/": "kuov(âmáánu)?", "/mar(ch)?/": "njuh(čâmáánu)?", "/apr(il)?/": "cuáŋuimáánu", "/may/": "vyes(imáánu)?", "/jun(e)?/": "kesi(máánu)?", "/jul(y)?/": "syei(nimáánu)?", "/aug(ust)?/": "porg(emáánu)?", "/sep(t(ember)?)?/": "čoh(čâmáánu)?", "/oct(ober)?/": "roov(vâdmáánu)?", "/nov(ember)?/": "ska(mmâmáánu)?", "/dec(ember)?/": "juov(lâmáánu)?", "/^su(n(day)?)?/": "^pasepeivi", "/^mo(n(day)?)?/": "^vuossargâ", "/^tu(e(s(day)?)?)?/": "^majebargâ", "/^we(d(nesday)?)?/": "^koskokko", "/^th(u(r(s(day)?)?)?)?/": "^tuorâstâh", "/^fr(i(day)?)?/": "^vástuppeivi", "/^sa(t(urday)?)?/": "^lávárdâh", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "smn-FI"; ================================================ FILE: build/i18n/sms-FI.js ================================================ /* * DateJS Culture String File * Country Code: sms-FI * Name: Sami (Skolt) (Finland) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["sms-FI"] = { "name": "sms-FI", "englishName": "Sami (Skolt) (Finland)", "nativeName": "sääm´ǩiõll (Lää´ddjânnam)", "Sunday": "pâ´sspei´vv", "Monday": "vuõssargg", "Tuesday": "mââibargg", "Wednesday": "seärad", "Thursday": "nelljdpei´vv", "Friday": "piâtnâc", "Saturday": "sue´vet", "Sun": "pâ", "Mon": "vu", "Tue": "mâ", "Wed": "se", "Thu": "ne", "Fri": "pi", "Sat": "su", "Su": "pâ", "Mo": "vu", "Tu": "mâ", "We": "se", "Th": "ne", "Fr": "pi", "Sa": "su", "S_Sun_Initial": "p", "M_Mon_Initial": "v", "T_Tue_Initial": "m", "W_Wed_Initial": "s", "T_Thu_Initial": "n", "F_Fri_Initial": "p", "S_Sat_Initial": "s", "January": "ođđee´jjmään", "February": "tä´lvvmään", "March": "pâ´zzlâšttammään", "April": "njuhččmään", "May": "vue´ssmään", "June": "ǩie´ssmään", "July": "suei´nnmään", "August": "på´rǧǧmään", "September": "čõhččmään", "October": "kålggmään", "November": "skamm´mään", "December": "rosttovmään", "Jan_Abbr": "ođjm", "Feb_Abbr": "tä´lvv", "Mar_Abbr": "pâzl", "Apr_Abbr": "njuh", "May_Abbr": "vue", "Jun_Abbr": "ǩie", "Jul_Abbr": "suei", "Aug_Abbr": "på´r", "Sep_Abbr": "čõh", "Oct_Abbr": "kålg", "Nov_Abbr": "ska", "Dec_Abbr": "rost", "AM": "", "PM": "", "firstDayOfWeek": 1, "twoDigitYearMax": 2029, "mdy": "dmy", "M/d/yyyy": "d.M.yyyy", "dddd, MMMM dd, yyyy": "MMMM d'. p. 'yyyy", "h:mm tt": "H:mm:ss", "h:mm:ss tt": "H:mm:ss", "dddd, MMMM dd, yyyy h:mm:ss tt": "MMMM d'. p. 'yyyy H:mm:ss", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "MMMM dd", "MMMM, yyyy": "MMMM yyyy", "/jan(uary)?/": "ođđee´jjmään", "/feb(ruary)?/": "tä´lvv(mään)?", "/mar(ch)?/": "pâ´zzlâšttammään", "/apr(il)?/": "njuh(ččmään)?", "/may/": "vue(´ssmään)?", "/jun(e)?/": "ǩie(´ssmään)?", "/jul(y)?/": "suei(´nnmään)?", "/aug(ust)?/": "på´r(ǧǧmään)?", "/sep(t(ember)?)?/": "čõh(ččmään)?", "/oct(ober)?/": "kålg(gmään)?", "/nov(ember)?/": "ska(mm´mään)?", "/dec(ember)?/": "rost(tovmään)?", "/^su(n(day)?)?/": "^pâ´sspei´vv", "/^mo(n(day)?)?/": "^vuõssargg", "/^tu(e(s(day)?)?)?/": "^mââibargg", "/^we(d(nesday)?)?/": "^seärad", "/^th(u(r(s(day)?)?)?)?/": "^nelljdpei´vv", "/^fr(i(day)?)?/": "^piâtnâc", "/^sa(t(urday)?)?/": "^sue´vet", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "sms-FI"; ================================================ FILE: build/i18n/sq-AL.js ================================================ /* * DateJS Culture String File * Country Code: sq-AL * Name: Albanian (Albania) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["sq-AL"] = { "name": "sq-AL", "englishName": "Albanian (Albania)", "nativeName": "shqipe (Shqipëria)", "Sunday": "e diel", "Monday": "e hënë", "Tuesday": "e martë", "Wednesday": "e mërkurë", "Thursday": "e enjte", "Friday": "e premte", "Saturday": "e shtunë", "Sun": "Die", "Mon": "Hën", "Tue": "Mar", "Wed": "Mër", "Thu": "Enj", "Fri": "Pre", "Sat": "Sht", "Su": "Di", "Mo": "Hë", "Tu": "Ma", "We": "Më", "Th": "En", "Fr": "Pr", "Sa": "Sh", "S_Sun_Initial": "D", "M_Mon_Initial": "H", "T_Tue_Initial": "M", "W_Wed_Initial": "M", "T_Thu_Initial": "E", "F_Fri_Initial": "P", "S_Sat_Initial": "S", "January": "janar", "February": "shkurt", "March": "mars", "April": "prill", "May": "maj", "June": "qershor", "July": "korrik", "August": "gusht", "September": "shtator", "October": "tetor", "November": "nëntor", "December": "dhjetor", "Jan_Abbr": "Jan", "Feb_Abbr": "Shk", "Mar_Abbr": "Mar", "Apr_Abbr": "Pri", "May_Abbr": "Maj", "Jun_Abbr": "Qer", "Jul_Abbr": "Kor", "Aug_Abbr": "Gsh", "Sep_Abbr": "Sht", "Oct_Abbr": "Tet", "Nov_Abbr": "Nën", "Dec_Abbr": "Dhj", "AM": "PD", "PM": "MD", "firstDayOfWeek": 1, "twoDigitYearMax": 2029, "mdy": "ymd", "M/d/yyyy": "yyyy-MM-dd", "dddd, MMMM dd, yyyy": "yyyy-MM-dd", "h:mm tt": "h:mm.tt", "h:mm:ss tt": "h:mm:ss.tt", "dddd, MMMM dd, yyyy h:mm:ss tt": "yyyy-MM-dd h:mm:ss.tt", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "MMMM dd", "MMMM, yyyy": "yyyy-MM", "/jan(uary)?/": "jan(ar)?", "/feb(ruary)?/": "shk(urt)?", "/mar(ch)?/": "mar(s)?", "/apr(il)?/": "pri(ll)?", "/may/": "maj", "/jun(e)?/": "qer(shor)?", "/jul(y)?/": "kor(rik)?", "/aug(ust)?/": "gusht", "/sep(t(ember)?)?/": "sht(ator)?", "/oct(ober)?/": "tet(or)?", "/nov(ember)?/": "nën(tor)?", "/dec(ember)?/": "dhj(etor)?", "/^su(n(day)?)?/": "^di(e(iel)?)?", "/^mo(n(day)?)?/": "^hë(n(ënë)?)?", "/^tu(e(s(day)?)?)?/": "^ma(r(artë)?)?", "/^we(d(nesday)?)?/": "^më(r(ërkurë)?)?", "/^th(u(r(s(day)?)?)?)?/": "^en(j(njte)?)?", "/^fr(i(day)?)?/": "^pr(e(remte)?)?", "/^sa(t(urday)?)?/": "^sh(t(htunë)?)?", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "sq-AL"; ================================================ FILE: build/i18n/sr-Cyrl-BA.js ================================================ /* * DateJS Culture String File * Country Code: sr-Cyrl-BA * Name: Serbian (Cyrillic) (Bosnia and Herzegovina) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["sr-Cyrl-BA"] = { "name": "sr-Cyrl-BA", "englishName": "Serbian (Cyrillic) (Bosnia and Herzegovina)", "nativeName": "српски (Босна и Херцеговина)", "Sunday": "недеља", "Monday": "понедељак", "Tuesday": "уторак", "Wednesday": "среда", "Thursday": "четвртак", "Friday": "петак", "Saturday": "субота", "Sun": "нед", "Mon": "пон", "Tue": "уто", "Wed": "сре", "Thu": "чет", "Fri": "пет", "Sat": "суб", "Su": "нед", "Mo": "пон", "Tu": "уто", "We": "сре", "Th": "чет", "Fr": "пет", "Sa": "суб", "S_Sun_Initial": "н", "M_Mon_Initial": "п", "T_Tue_Initial": "у", "W_Wed_Initial": "с", "T_Thu_Initial": "ч", "F_Fri_Initial": "п", "S_Sat_Initial": "с", "January": "јануар", "February": "фебруар", "March": "март", "April": "април", "May": "мај", "June": "јун", "July": "јул", "August": "август", "September": "септембар", "October": "октобар", "November": "новембар", "December": "децембар", "Jan_Abbr": "јан", "Feb_Abbr": "феб", "Mar_Abbr": "мар", "Apr_Abbr": "апр", "May_Abbr": "мај", "Jun_Abbr": "јун", "Jul_Abbr": "јул", "Aug_Abbr": "авг", "Sep_Abbr": "сеп", "Oct_Abbr": "окт", "Nov_Abbr": "нов", "Dec_Abbr": "дец", "AM": "", "PM": "", "firstDayOfWeek": 1, "twoDigitYearMax": 2029, "mdy": "dmy", "M/d/yyyy": "d.M.yyyy", "dddd, MMMM dd, yyyy": "d. MMMM yyyy", "h:mm tt": "H:mm:ss", "h:mm:ss tt": "H:mm:ss", "dddd, MMMM dd, yyyy h:mm:ss tt": "d. MMMM yyyy H:mm:ss", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "MMMM dd", "MMMM, yyyy": "MMMM, yyyy", "/jan(uary)?/": "јан(уар)?", "/feb(ruary)?/": "феб(руар)?", "/mar(ch)?/": "мар(т)?", "/apr(il)?/": "апр(ил)?", "/may/": "мај", "/jun(e)?/": "јун", "/jul(y)?/": "јул", "/aug(ust)?/": "авг(уст)?", "/sep(t(ember)?)?/": "сеп(тембар)?", "/oct(ober)?/": "окт(обар)?", "/nov(ember)?/": "нов(ембар)?", "/dec(ember)?/": "дец(ембар)?", "/^su(n(day)?)?/": "^недеља", "/^mo(n(day)?)?/": "^понедељак", "/^tu(e(s(day)?)?)?/": "^уторак", "/^we(d(nesday)?)?/": "^среда", "/^th(u(r(s(day)?)?)?)?/": "^четвртак", "/^fr(i(day)?)?/": "^петак", "/^sa(t(urday)?)?/": "^субота", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "sr-Cyrl-BA"; ================================================ FILE: build/i18n/sr-Cyrl-CS.js ================================================ /* * DateJS Culture String File * Country Code: sr-Cyrl-CS * Name: Serbian (Cyrillic, Serbia) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["sr-Cyrl-CS"] = { "name": "sr-Cyrl-CS", "englishName": "Serbian (Cyrillic, Serbia)", "nativeName": "српски (Србија)", "Sunday": "недеља", "Monday": "понедељак", "Tuesday": "уторак", "Wednesday": "среда", "Thursday": "четвртак", "Friday": "петак", "Saturday": "субота", "Sun": "нед", "Mon": "пон", "Tue": "уто", "Wed": "сре", "Thu": "чет", "Fri": "пет", "Sat": "суб", "Su": "не", "Mo": "по", "Tu": "ут", "We": "ср", "Th": "че", "Fr": "пе", "Sa": "су", "S_Sun_Initial": "н", "M_Mon_Initial": "п", "T_Tue_Initial": "у", "W_Wed_Initial": "с", "T_Thu_Initial": "ч", "F_Fri_Initial": "п", "S_Sat_Initial": "с", "January": "јануар", "February": "фебруар", "March": "март", "April": "април", "May": "мај", "June": "јун", "July": "јул", "August": "август", "September": "септембар", "October": "октобар", "November": "новембар", "December": "децембар", "Jan_Abbr": "јан", "Feb_Abbr": "феб", "Mar_Abbr": "мар", "Apr_Abbr": "апр", "May_Abbr": "мај", "Jun_Abbr": "јун", "Jul_Abbr": "јул", "Aug_Abbr": "авг", "Sep_Abbr": "сеп", "Oct_Abbr": "окт", "Nov_Abbr": "нов", "Dec_Abbr": "дец", "AM": "", "PM": "", "firstDayOfWeek": 1, "twoDigitYearMax": 2029, "mdy": "dmy", "M/d/yyyy": "d.M.yyyy", "dddd, MMMM dd, yyyy": "d. MMMM yyyy", "h:mm tt": "H:mm", "h:mm:ss tt": "H:mm:ss", "dddd, MMMM dd, yyyy h:mm:ss tt": "d. MMMM yyyy H:mm:ss", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "d. MMMM", "MMMM, yyyy": "MMMM yyyy", "/jan(uary)?/": "јан(уар)?", "/feb(ruary)?/": "феб(руар)?", "/mar(ch)?/": "мар(т)?", "/apr(il)?/": "апр(ил)?", "/may/": "мај", "/jun(e)?/": "јун", "/jul(y)?/": "јул", "/aug(ust)?/": "авг(уст)?", "/sep(t(ember)?)?/": "сеп(тембар)?", "/oct(ober)?/": "окт(обар)?", "/nov(ember)?/": "нов(ембар)?", "/dec(ember)?/": "дец(ембар)?", "/^su(n(day)?)?/": "^не(д(еља)?)?", "/^mo(n(day)?)?/": "^по(н(едељак)?)?", "/^tu(e(s(day)?)?)?/": "^ут(о(рак)?)?", "/^we(d(nesday)?)?/": "^ср(е(да)?)?", "/^th(u(r(s(day)?)?)?)?/": "^че(т(вртак)?)?", "/^fr(i(day)?)?/": "^пе(т(ак)?)?", "/^sa(t(urday)?)?/": "^су(б(ота)?)?", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "sr-Cyrl-CS"; ================================================ FILE: build/i18n/sr-Latn-BA.js ================================================ /* * DateJS Culture String File * Country Code: sr-Latn-BA * Name: Serbian (Latin) (Bosnia and Herzegovina) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["sr-Latn-BA"] = { "name": "sr-Latn-BA", "englishName": "Serbian (Latin) (Bosnia and Herzegovina)", "nativeName": "srpski (Bosna i Hercegovina)", "Sunday": "nedelja", "Monday": "ponedeljak", "Tuesday": "utorak", "Wednesday": "sreda", "Thursday": "četvrtak", "Friday": "petak", "Saturday": "subota", "Sun": "ned", "Mon": "pon", "Tue": "uto", "Wed": "sre", "Thu": "čet", "Fri": "pet", "Sat": "sub", "Su": "ned", "Mo": "pon", "Tu": "uto", "We": "sre", "Th": "čet", "Fr": "pet", "Sa": "sub", "S_Sun_Initial": "n", "M_Mon_Initial": "p", "T_Tue_Initial": "u", "W_Wed_Initial": "s", "T_Thu_Initial": "č", "F_Fri_Initial": "p", "S_Sat_Initial": "s", "January": "januar", "February": "februar", "March": "mart", "April": "april", "May": "maj", "June": "jun", "July": "jul", "August": "avgust", "September": "septembar", "October": "oktobar", "November": "novembar", "December": "decembar", "Jan_Abbr": "jan", "Feb_Abbr": "feb", "Mar_Abbr": "mar", "Apr_Abbr": "apr", "May_Abbr": "maj", "Jun_Abbr": "jun", "Jul_Abbr": "jul", "Aug_Abbr": "avg", "Sep_Abbr": "sep", "Oct_Abbr": "okt", "Nov_Abbr": "nov", "Dec_Abbr": "dec", "AM": "", "PM": "", "firstDayOfWeek": 1, "twoDigitYearMax": 2029, "mdy": "dmy", "M/d/yyyy": "d.M.yyyy", "dddd, MMMM dd, yyyy": "d. MMMM yyyy", "h:mm tt": "H:mm:ss", "h:mm:ss tt": "H:mm:ss", "dddd, MMMM dd, yyyy h:mm:ss tt": "d. MMMM yyyy H:mm:ss", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "MMMM dd", "MMMM, yyyy": "MMMM yyyy", "/jan(uary)?/": "jan(uar)?", "/feb(ruary)?/": "feb(ruar)?", "/mar(ch)?/": "mar(t)?", "/apr(il)?/": "apr(il)?", "/may/": "maj", "/jun(e)?/": "jun", "/jul(y)?/": "jul", "/aug(ust)?/": "avg(ust)?", "/sep(t(ember)?)?/": "sep(tembar)?", "/oct(ober)?/": "okt(obar)?", "/nov(ember)?/": "nov(embar)?", "/dec(ember)?/": "dec(embar)?", "/^su(n(day)?)?/": "^nedelja", "/^mo(n(day)?)?/": "^ponedeljak", "/^tu(e(s(day)?)?)?/": "^utorak", "/^we(d(nesday)?)?/": "^sreda", "/^th(u(r(s(day)?)?)?)?/": "^četvrtak", "/^fr(i(day)?)?/": "^petak", "/^sa(t(urday)?)?/": "^subota", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "sr-Latn-BA"; ================================================ FILE: build/i18n/sr-Latn-CS.js ================================================ /* * DateJS Culture String File * Country Code: sr-Latn-CS * Name: Serbian (Latin, Serbia) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["sr-Latn-CS"] = { "name": "sr-Latn-CS", "englishName": "Serbian (Latin, Serbia)", "nativeName": "srpski (Srbija)", "Sunday": "nedelja", "Monday": "ponedeljak", "Tuesday": "utorak", "Wednesday": "sreda", "Thursday": "četvrtak", "Friday": "petak", "Saturday": "subota", "Sun": "ned", "Mon": "pon", "Tue": "uto", "Wed": "sre", "Thu": "čet", "Fri": "pet", "Sat": "sub", "Su": "ne", "Mo": "po", "Tu": "ut", "We": "sr", "Th": "če", "Fr": "pe", "Sa": "su", "S_Sun_Initial": "n", "M_Mon_Initial": "p", "T_Tue_Initial": "u", "W_Wed_Initial": "s", "T_Thu_Initial": "č", "F_Fri_Initial": "p", "S_Sat_Initial": "s", "January": "januar", "February": "februar", "March": "mart", "April": "april", "May": "maj", "June": "jun", "July": "jul", "August": "avgust", "September": "septembar", "October": "oktobar", "November": "novembar", "December": "decembar", "Jan_Abbr": "jan", "Feb_Abbr": "feb", "Mar_Abbr": "mar", "Apr_Abbr": "apr", "May_Abbr": "maj", "Jun_Abbr": "jun", "Jul_Abbr": "jul", "Aug_Abbr": "avg", "Sep_Abbr": "sep", "Oct_Abbr": "okt", "Nov_Abbr": "nov", "Dec_Abbr": "dec", "AM": "", "PM": "", "firstDayOfWeek": 1, "twoDigitYearMax": 2029, "mdy": "dmy", "M/d/yyyy": "d.M.yyyy", "dddd, MMMM dd, yyyy": "d. MMMM yyyy", "h:mm tt": "H:mm", "h:mm:ss tt": "H:mm:ss", "dddd, MMMM dd, yyyy h:mm:ss tt": "d. MMMM yyyy H:mm:ss", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "d. MMMM", "MMMM, yyyy": "MMMM yyyy", "/jan(uary)?/": "jan(uar)?", "/feb(ruary)?/": "feb(ruar)?", "/mar(ch)?/": "mar(t)?", "/apr(il)?/": "apr(il)?", "/may/": "maj", "/jun(e)?/": "jun", "/jul(y)?/": "jul", "/aug(ust)?/": "avg(ust)?", "/sep(t(ember)?)?/": "sep(tembar)?", "/oct(ober)?/": "okt(obar)?", "/nov(ember)?/": "nov(embar)?", "/dec(ember)?/": "dec(embar)?", "/^su(n(day)?)?/": "^ne(d(elja)?)?", "/^mo(n(day)?)?/": "^po(n(edeljak)?)?", "/^tu(e(s(day)?)?)?/": "^ut(o(rak)?)?", "/^we(d(nesday)?)?/": "^sr(e(da)?)?", "/^th(u(r(s(day)?)?)?)?/": "^če(t(vrtak)?)?", "/^fr(i(day)?)?/": "^pe(t(ak)?)?", "/^sa(t(urday)?)?/": "^su(b(ota)?)?", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "sr-Latn-CS"; ================================================ FILE: build/i18n/sv-FI.js ================================================ /* * DateJS Culture String File * Country Code: sv-FI * Name: Swedish (Finland) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["sv-FI"] = { "name": "sv-FI", "englishName": "Swedish (Finland)", "nativeName": "svenska (Finland)", "Sunday": "söndag", "Monday": "måndag", "Tuesday": "tisdag", "Wednesday": "onsdag", "Thursday": "torsdag", "Friday": "fredag", "Saturday": "lördag", "Sun": "sö", "Mon": "må", "Tue": "ti", "Wed": "on", "Thu": "to", "Fri": "fr", "Sat": "lö", "Su": "sö", "Mo": "må", "Tu": "ti", "We": "on", "Th": "to", "Fr": "fr", "Sa": "lö", "S_Sun_Initial": "s", "M_Mon_Initial": "m", "T_Tue_Initial": "t", "W_Wed_Initial": "o", "T_Thu_Initial": "t", "F_Fri_Initial": "f", "S_Sat_Initial": "l", "January": "januari", "February": "februari", "March": "mars", "April": "april", "May": "maj", "June": "juni", "July": "juli", "August": "augusti", "September": "september", "October": "oktober", "November": "november", "December": "december", "Jan_Abbr": "jan", "Feb_Abbr": "feb", "Mar_Abbr": "mar", "Apr_Abbr": "apr", "May_Abbr": "maj", "Jun_Abbr": "jun", "Jul_Abbr": "jul", "Aug_Abbr": "aug", "Sep_Abbr": "sep", "Oct_Abbr": "okt", "Nov_Abbr": "nov", "Dec_Abbr": "dec", "AM": "", "PM": "", "firstDayOfWeek": 1, "twoDigitYearMax": 2029, "mdy": "dmy", "M/d/yyyy": "d.M.yyyy", "dddd, MMMM dd, yyyy": "'den 'd MMMM yyyy", "h:mm tt": "HH:mm", "h:mm:ss tt": "HH:mm:ss", "dddd, MMMM dd, yyyy h:mm:ss tt": "'den 'd MMMM yyyy HH:mm:ss", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "'den 'd MMMM", "MMMM, yyyy": "MMMM yyyy", "/jan(uary)?/": "jan(uari)?", "/feb(ruary)?/": "feb(ruari)?", "/mar(ch)?/": "mar(s)?", "/apr(il)?/": "apr(il)?", "/may/": "maj", "/jun(e)?/": "jun(i)?", "/jul(y)?/": "jul(i)?", "/aug(ust)?/": "aug(usti)?", "/sep(t(ember)?)?/": "sep(t(ember)?)?", "/oct(ober)?/": "okt(ober)?", "/nov(ember)?/": "nov(ember)?", "/dec(ember)?/": "dec(ember)?", "/^su(n(day)?)?/": "^söndag", "/^mo(n(day)?)?/": "^måndag", "/^tu(e(s(day)?)?)?/": "^tisdag", "/^we(d(nesday)?)?/": "^onsdag", "/^th(u(r(s(day)?)?)?)?/": "^torsdag", "/^fr(i(day)?)?/": "^fredag", "/^sa(t(urday)?)?/": "^lördag", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "sv-FI"; ================================================ FILE: build/i18n/sv-SE.js ================================================ /* * DateJS Culture String File * Country Code: sv-SE * Name: Swedish (Sweden) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["sv-SE"] = { "name": "sv-SE", "englishName": "Swedish (Sweden)", "nativeName": "Svenska (Sverige)", "Sunday": "Söndag", "Monday": "Måndag", "Tuesday": "Tisdag", "Wednesday": "Onsdag", "Thursday": "Torsdag", "Friday": "Fredag", "Saturday": "Lördag", "Sun": "Sön", "Mon": "Mån", "Tue": "Tis", "Wed": "Ons", "Thu": "Tor", "Fri": "Fre", "Sat": "Lör", "Su": "Sö", "Mo": "Må", "Tu": "Ti", "We": "On", "Th": "To", "Fr": "Fr", "Sa": "Lö", "S_Sun_Initial": "S", "M_Mon_Initial": "M", "T_Tue_Initial": "T", "W_Wed_Initial": "O", "T_Thu_Initial": "T", "F_Fri_Initial": "F", "S_Sat_Initial": "L", "January": "Januari", "February": "Februari", "March": "Mars", "April": "April", "May": "Maj", "June": "Juni", "July": "Juli", "August": "Augusti", "September": "September", "October": "Oktober", "November": "November", "December": "December", "Jan_Abbr": "Jan", "Feb_Abbr": "Feb", "Mar_Abbr": "Mar", "Apr_Abbr": "Apr", "May_Abbr": "Maj", "Jun_Abbr": "Jun", "Jul_Abbr": "Jul", "Aug_Abbr": "Aug", "Sep_Abbr": "Sep", "Oct_Abbr": "Okt", "Nov_Abbr": "Nov", "Dec_Abbr": "Dec", "AM": "", "PM": "", "firstDayOfWeek": 1, "twoDigitYearMax": 2029, "mdy": "ymd", "M/d/yyyy": "yyyy-MM-dd", "dddd, MMMM dd, yyyy": "'den 'd MMMM yyyy", "h:mm tt": "HH.mm", "h:mm:ss tt": "HH.mm.ss", "dddd, MMMM dd, yyyy h:mm:ss tt": "'den 'd MMMM yyyy HH.mm.ss", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH.mm.ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH.mm.ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH.mm.ss", "MMMM dd": "'den 'd MMMM", "MMMM, yyyy": "MMMM yyyy", "/jan(uary)?/": "jan(uari)?", "/feb(ruary)?/": "feb(ruari)?", "/mar(ch)?/": "mar(s)?", "/apr(il)?/": "apr(il)?", "/may/": "maj", "/jun(e)?/": "jun(i)?", "/jul(y)?/": "jul(i)?", "/aug(ust)?/": "aug(usti)?", "/sep(t(ember)?)?/": "sep(t(ember)?)?", "/oct(ober)?/": "okt(ober)?", "/nov(ember)?/": "nov(ember)?", "/dec(ember)?/": "dec(ember)?", "/^su(n(day)?)?/": "^sö(n(dag)?)?", "/^mo(n(day)?)?/": "^må(n(dag)?)?", "/^tu(e(s(day)?)?)?/": "^ti(s(dag)?)?", "/^we(d(nesday)?)?/": "^on(s(dag)?)?", "/^th(u(r(s(day)?)?)?)?/": "^to(r(s(dag)?)?)?", "/^fr(i(day)?)?/": "^fr(e(dag)?)?", "/^sa(t(urday)?)?/": "^lö(r(dag)?)?", "/^next/": "^nästa", "/^last|past|prev(ious)?/": "^föregående|förra|senaste", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|efter|från)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|före|tidigare)", "/^yes(terday)?/": "^i\\s?går|(för)går(dag)?", "/^t(od(ay)?)?/": "^i\\s?dag?", "/^tom(orrow)?/": "^i\\s?morgon|morgon(dag)?", "/^n(ow)?/": "^nu", "/^ms|milli(second)?s?/": "^ms|milli(sekund)?(er)?", "/^sec(ond)?s?/": "^sek(und)?(er)?", "/^mn|min(ute)?s?/": "^min(ut)?(er)?", "/^h(our)?s?/": "^t(im)?(ar)?", "/^w(eek)?s?/": "^v(eck(a)?)?(or)?", "/^m(onth)?s?/": "^m(ånad)?(er)?", "/^d(ay)?s?/": "^d(ag)?(ar)?", "/^y(ear)?s?/": "^å(r)?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "sv-SE"; ================================================ FILE: build/i18n/sw-KE.js ================================================ /* * DateJS Culture String File * Country Code: sw-KE * Name: Kiswahili (Kenya) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["sw-KE"] = { "name": "sw-KE", "englishName": "Kiswahili (Kenya)", "nativeName": "Kiswahili (Kenya)", "Sunday": "Sunday", "Monday": "Monday", "Tuesday": "Tuesday", "Wednesday": "Wednesday", "Thursday": "Thursday", "Friday": "Friday", "Saturday": "Saturday", "Sun": "Sun", "Mon": "Mon", "Tue": "Tue", "Wed": "Wed", "Thu": "Thu", "Fri": "Fri", "Sat": "Sat", "Su": "S", "Mo": "M", "Tu": "T", "We": "W", "Th": "T", "Fr": "F", "Sa": "S", "S_Sun_Initial": "S", "M_Mon_Initial": "M", "T_Tue_Initial": "T", "W_Wed_Initial": "W", "T_Thu_Initial": "T", "F_Fri_Initial": "F", "S_Sat_Initial": "S", "January": "January", "February": "February", "March": "March", "April": "April", "May": "May", "June": "June", "July": "July", "August": "August", "September": "September", "October": "October", "November": "November", "December": "December", "Jan_Abbr": "Jan", "Feb_Abbr": "Feb", "Mar_Abbr": "Mar", "Apr_Abbr": "Apr", "May_Abbr": "May", "Jun_Abbr": "Jun", "Jul_Abbr": "Jul", "Aug_Abbr": "Aug", "Sep_Abbr": "Sep", "Oct_Abbr": "Oct", "Nov_Abbr": "Nov", "Dec_Abbr": "Dec", "AM": "AM", "PM": "PM", "firstDayOfWeek": 0, "twoDigitYearMax": 2029, "mdy": "mdy", "M/d/yyyy": "M/d/yyyy", "dddd, MMMM dd, yyyy": "dddd, MMMM dd, yyyy", "h:mm tt": "h:mm tt", "h:mm:ss tt": "h:mm:ss tt", "dddd, MMMM dd, yyyy h:mm:ss tt": "dddd, MMMM dd, yyyy h:mm:ss tt", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "MMMM dd", "MMMM, yyyy": "MMMM, yyyy", "/jan(uary)?/": "jan(uary)?", "/feb(ruary)?/": "feb(ruary)?", "/mar(ch)?/": "mar(ch)?", "/apr(il)?/": "apr(il)?", "/may/": "may", "/jun(e)?/": "jun(e)?", "/jul(y)?/": "jul(y)?", "/aug(ust)?/": "aug(ust)?", "/sep(t(ember)?)?/": "sep(t(ember)?)?", "/oct(ober)?/": "oct(ober)?", "/nov(ember)?/": "nov(ember)?", "/dec(ember)?/": "dec(ember)?", "/^su(n(day)?)?/": "^s(un(day)?)?", "/^mo(n(day)?)?/": "^m(on(day)?)?", "/^tu(e(s(day)?)?)?/": "^tu(e(s(day)?)?)?", "/^we(d(nesday)?)?/": "^w(ed(nesday)?)?", "/^th(u(r(s(day)?)?)?)?/": "^th(u(r(s(day)?)?)?)?", "/^fr(i(day)?)?/": "^f(ri(day)?)?", "/^sa(t(urday)?)?/": "^s(at(urday)?)?", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "sw-KE"; ================================================ FILE: build/i18n/syr-SY.js ================================================ /* * DateJS Culture String File * Country Code: syr-SY * Name: Syriac (Syria) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["syr-SY"] = { "name": "syr-SY", "englishName": "Syriac (Syria)", "nativeName": "ܣܘܪܝܝܐ (سوريا)", "Sunday": "ܚܕ ܒܫܒܐ", "Monday": "ܬܪܝܢ ܒܫܒܐ", "Tuesday": "ܬܠܬܐ ܒܫܒܐ", "Wednesday": "ܐܪܒܥܐ ܒܫܒܐ", "Thursday": "ܚܡܫܐ ܒܫܒܐ", "Friday": "ܥܪܘܒܬܐ", "Saturday": "ܫܒܬܐ", "Sun": "܏ܐ ܏ܒܫ", "Mon": "܏ܒ ܏ܒܫ", "Tue": "܏ܓ ܏ܒܫ", "Wed": "܏ܕ ܏ܒܫ", "Thu": "܏ܗ ܏ܒܫ", "Fri": "܏ܥܪܘܒ", "Sat": "܏ܫܒ", "Su": "܏", "Mo": "܏", "Tu": "܏", "We": "܏", "Th": "܏", "Fr": "܏", "Sa": "܏", "S_Sun_Initial": "܏", "M_Mon_Initial": "܏", "T_Tue_Initial": "܏", "W_Wed_Initial": "܏", "T_Thu_Initial": "܏", "F_Fri_Initial": "܏", "S_Sat_Initial": "܏", "January": "ܟܢܘܢ ܐܚܪܝ", "February": "ܫܒܛ", "March": "ܐܕܪ", "April": "ܢܝܣܢ", "May": "ܐܝܪ", "June": "ܚܙܝܪܢ", "July": "ܬܡܘܙ", "August": "ܐܒ", "September": "ܐܝܠܘܠ", "October": "ܬܫܪܝ ܩܕܝܡ", "November": "ܬܫܪܝ ܐܚܪܝ", "December": "ܟܢܘܢ ܩܕܝܡ", "Jan_Abbr": "܏ܟܢ ܏ܒ", "Feb_Abbr": "ܫܒܛ", "Mar_Abbr": "ܐܕܪ", "Apr_Abbr": "ܢܝܣܢ", "May_Abbr": "ܐܝܪ", "Jun_Abbr": "ܚܙܝܪܢ", "Jul_Abbr": "ܬܡܘܙ", "Aug_Abbr": "ܐܒ", "Sep_Abbr": "ܐܝܠܘܠ", "Oct_Abbr": "܏ܬܫ ܏ܐ", "Nov_Abbr": "܏ܬܫ ܏ܒ", "Dec_Abbr": "܏ܟܢ ܏ܐ", "AM": "ܩ.ܛ", "PM": "ܒ.ܛ", "firstDayOfWeek": 6, "twoDigitYearMax": 2029, "mdy": "dmy", "M/d/yyyy": "dd/MM/yyyy", "dddd, MMMM dd, yyyy": "dd MMMM, yyyy", "h:mm tt": "hh:mm tt", "h:mm:ss tt": "hh:mm:ss tt", "dddd, MMMM dd, yyyy h:mm:ss tt": "dd MMMM, yyyy hh:mm:ss tt", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "dd MMMM", "MMMM, yyyy": "MMMM, yyyy", "/jan(uary)?/": "ܟܢܘܢ ܐܚܪܝ", "/feb(ruary)?/": "ܫܒܛ", "/mar(ch)?/": "ܐܕܪ", "/apr(il)?/": "ܢܝܣܢ", "/may/": "ܐܝܪ", "/jun(e)?/": "ܚܙܝܪܢ", "/jul(y)?/": "ܬܡܘܙ", "/aug(ust)?/": "ܐܒ", "/sep(t(ember)?)?/": "ܐܝܠܘܠ", "/oct(ober)?/": "ܬܫܪܝ ܩܕܝܡ", "/nov(ember)?/": "ܬܫܪܝ ܐܚܪܝ", "/dec(ember)?/": "ܟܢܘܢ ܩܕܝܡ", "/^su(n(day)?)?/": "^܏(ܐ ܏ܒܫ(ܐ)?)?", "/^mo(n(day)?)?/": "^܏(ܒ ܏ܒܫ(ܫܒܐ)?)?", "/^tu(e(s(day)?)?)?/": "^܏(ܓ ܏ܒܫ(ܫܒܐ)?)?", "/^we(d(nesday)?)?/": "^܏(ܕ ܏ܒܫ(ܒܫܒܐ)?)?", "/^th(u(r(s(day)?)?)?)?/": "^܏(ܗ ܏ܒܫ(ܫܒܐ)?)?", "/^fr(i(day)?)?/": "^܏(ܥܪܘܒ(ܐ)?)?", "/^sa(t(urday)?)?/": "^܏(ܫܒ(ܐ)?)?", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "syr-SY"; ================================================ FILE: build/i18n/ta-IN.js ================================================ /* * DateJS Culture String File * Country Code: ta-IN * Name: Tamil (India) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["ta-IN"] = { "name": "ta-IN", "englishName": "Tamil (India)", "nativeName": "தமிழ் (இந்தியா)", "Sunday": "ஞாயிறு", "Monday": "திங்கள்", "Tuesday": "செவ்வாய்", "Wednesday": "புதன்", "Thursday": "வியாழன்", "Friday": "வெள்ளி", "Saturday": "சனி", "Sun": "ஞா", "Mon": "தி", "Tue": "செ", "Wed": "பு", "Thu": "வி", "Fri": "வெ", "Sat": "ச", "Su": "ஞ", "Mo": "த", "Tu": "ச", "We": "ப", "Th": "வ", "Fr": "வ", "Sa": "ச", "S_Sun_Initial": "ஞ", "M_Mon_Initial": "த", "T_Tue_Initial": "ச", "W_Wed_Initial": "ப", "T_Thu_Initial": "வ", "F_Fri_Initial": "வ", "S_Sat_Initial": "ச", "January": "ஜனவரி", "February": "பெப்ரவரி", "March": "மார்ச்", "April": "ஏப்ரல்", "May": "மே", "June": "ஜூன்", "July": "ஜூலை", "August": "ஆகஸ்ட்", "September": "செப்டம்பர்", "October": "அக்டோபர்", "November": "நவம்பர்", "December": "டிசம்பர்", "Jan_Abbr": "ஜன.", "Feb_Abbr": "பெப்.", "Mar_Abbr": "மார்.", "Apr_Abbr": "ஏப்.", "May_Abbr": "மே", "Jun_Abbr": "ஜூன்", "Jul_Abbr": "ஜூலை", "Aug_Abbr": "ஆக.", "Sep_Abbr": "செப்.", "Oct_Abbr": "அக்.", "Nov_Abbr": "நவ.", "Dec_Abbr": "டிச.", "AM": "காலை", "PM": "மாலை", "firstDayOfWeek": 1, "twoDigitYearMax": 2029, "mdy": "dmy", "M/d/yyyy": "dd-MM-yyyy", "dddd, MMMM dd, yyyy": "dd MMMM yyyy", "h:mm tt": "HH:mm", "h:mm:ss tt": "HH:mm:ss", "dddd, MMMM dd, yyyy h:mm:ss tt": "dd MMMM yyyy HH:mm:ss", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "dd MMMM", "MMMM, yyyy": "MMMM yyyy", "/jan(uary)?/": "ஜன(.(வரி)?)?", "/feb(ruary)?/": "பெப்(.(ரவரி)?)?", "/mar(ch)?/": "மார்(.(ச்)?)?", "/apr(il)?/": "ஏப்(.(ரல்)?)?", "/may/": "மே", "/jun(e)?/": "ஜூன்", "/jul(y)?/": "ஜூலை", "/aug(ust)?/": "ஆக(.(ஸ்ட்)?)?", "/sep(t(ember)?)?/": "செப்(.(டம்பர்)?)?", "/oct(ober)?/": "அக்(.(டோபர்)?)?", "/nov(ember)?/": "நவ(.(ம்பர்)?)?", "/dec(ember)?/": "டிச(.(ம்பர்)?)?", "/^su(n(day)?)?/": "^ஞ(ா(யிறு)?)?", "/^mo(n(day)?)?/": "^த(ி(ங்கள்)?)?", "/^tu(e(s(day)?)?)?/": "^ச(ெ(வ்வாய்)?)?", "/^we(d(nesday)?)?/": "^ப(ு(தன்)?)?", "/^th(u(r(s(day)?)?)?)?/": "^வ(ி(யாழன்)?)?", "/^fr(i(day)?)?/": "^வ(ெ(ள்ளி)?)?", "/^sa(t(urday)?)?/": "^சனி", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "ta-IN"; ================================================ FILE: build/i18n/te-IN.js ================================================ /* * DateJS Culture String File * Country Code: te-IN * Name: Telugu (India) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["te-IN"] = { "name": "te-IN", "englishName": "Telugu (India)", "nativeName": "తెలుగు (భారత దేశం)", "Sunday": "ఆదివారం", "Monday": "సోమవారం", "Tuesday": "మంగళవారం", "Wednesday": "బుధవారం", "Thursday": "గురువారం", "Friday": "శుక్రవారం", "Saturday": "శనివారం", "Sun": "ఆది.", "Mon": "సోమ.", "Tue": "మంగళ.", "Wed": "బుధ.", "Thu": "గురు.", "Fri": "శుక్ర.", "Sat": "శని.", "Su": "ఆ", "Mo": "స", "Tu": "మ", "We": "బ", "Th": "గ", "Fr": "శ", "Sa": "శ", "S_Sun_Initial": "ఆ", "M_Mon_Initial": "స", "T_Tue_Initial": "మ", "W_Wed_Initial": "బ", "T_Thu_Initial": "గ", "F_Fri_Initial": "శ", "S_Sat_Initial": "శ", "January": "జనవరి", "February": "ఫిబ్రవరి", "March": "మార్చి", "April": "ఏప్రిల్", "May": "మే", "June": "జూన్", "July": "జూలై", "August": "ఆగస్టు", "September": "సెప్టెంబర్", "October": "అక్టోబర్", "November": "నవంబర్", "December": "డిసెంబర్", "Jan_Abbr": "జనవరి", "Feb_Abbr": "ఫిబ్రవరి", "Mar_Abbr": "మార్చి", "Apr_Abbr": "ఏప్రిల్", "May_Abbr": "మే", "Jun_Abbr": "జూన్", "Jul_Abbr": "జూలై", "Aug_Abbr": "ఆగస్టు", "Sep_Abbr": "సెప్టెంబర్", "Oct_Abbr": "అక్టోబర్", "Nov_Abbr": "నవంబర్", "Dec_Abbr": "డిసెంబర్", "AM": "పూర్వాహ్న", "PM": "అపరాహ్న", "firstDayOfWeek": 1, "twoDigitYearMax": 2029, "mdy": "dmy", "M/d/yyyy": "dd-MM-yy", "dddd, MMMM dd, yyyy": "dd MMMM yyyy", "h:mm tt": "HH:mm", "h:mm:ss tt": "HH:mm:ss", "dddd, MMMM dd, yyyy h:mm:ss tt": "dd MMMM yyyy HH:mm:ss", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "dd MMMM", "MMMM, yyyy": "MMMM, yyyy", "/jan(uary)?/": "జనవరి", "/feb(ruary)?/": "ఫిబ్రవరి", "/mar(ch)?/": "మార్చి", "/apr(il)?/": "ఏప్రిల్", "/may/": "మే", "/jun(e)?/": "జూన్", "/jul(y)?/": "జూలై", "/aug(ust)?/": "ఆగస్టు", "/sep(t(ember)?)?/": "సెప్టెంబర్", "/oct(ober)?/": "అక్టోబర్", "/nov(ember)?/": "నవంబర్", "/dec(ember)?/": "డిసెంబర్", "/^su(n(day)?)?/": "^ఆ(ది(.(వారం)?)?)?", "/^mo(n(day)?)?/": "^స(ోమ(.(వారం)?)?)?", "/^tu(e(s(day)?)?)?/": "^మ(ంగళ(.(వారం)?)?)?", "/^we(d(nesday)?)?/": "^బ(ుధ(.(వారం)?)?)?", "/^th(u(r(s(day)?)?)?)?/": "^గ(ురు(.(వారం)?)?)?", "/^fr(i(day)?)?/": "^శ(ుక్ర(.(వారం)?)?)?", "/^sa(t(urday)?)?/": "^శ(ని(.(వారం)?)?)?", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "te-IN"; ================================================ FILE: build/i18n/th-TH.js ================================================ /* * DateJS Culture String File * Country Code: th-TH * Name: Thai (Thailand) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["th-TH"] = { "name": "th-TH", "englishName": "Thai (Thailand)", "nativeName": "ไทย (ไทย)", "Sunday": "อาทิตย์", "Monday": "จันทร์", "Tuesday": "อังคาร", "Wednesday": "พุธ", "Thursday": "พฤหัสบดี", "Friday": "ศุกร์", "Saturday": "เสาร์", "Sun": "อา.", "Mon": "จ.", "Tue": "อ.", "Wed": "พ.", "Thu": "พฤ.", "Fri": "ศ.", "Sat": "ส.", "Su": "อ", "Mo": "จ", "Tu": "อ", "We": "พ", "Th": "พ", "Fr": "ศ", "Sa": "ส", "S_Sun_Initial": "อ", "M_Mon_Initial": "จ", "T_Tue_Initial": "อ", "W_Wed_Initial": "พ", "T_Thu_Initial": "พ", "F_Fri_Initial": "ศ", "S_Sat_Initial": "ส", "January": "มกราคม", "February": "กุมภาพันธ์", "March": "มีนาคม", "April": "เมษายน", "May": "พฤษภาคม", "June": "มิถุนายน", "July": "กรกฎาคม", "August": "สิงหาคม", "September": "กันยายน", "October": "ตุลาคม", "November": "พฤศจิกายน", "December": "ธันวาคม", "Jan_Abbr": "ม.ค.", "Feb_Abbr": "ก.พ.", "Mar_Abbr": "มี.ค.", "Apr_Abbr": "เม.ย.", "May_Abbr": "พ.ค.", "Jun_Abbr": "มิ.ย.", "Jul_Abbr": "ก.ค.", "Aug_Abbr": "ส.ค.", "Sep_Abbr": "ก.ย.", "Oct_Abbr": "ต.ค.", "Nov_Abbr": "พ.ย.", "Dec_Abbr": "ธ.ค.", "AM": "AM", "PM": "PM", "firstDayOfWeek": 1, "twoDigitYearMax": 2572, "mdy": "dmy", "M/d/yyyy": "d/M/yyyy", "dddd, MMMM dd, yyyy": "d MMMM yyyy", "h:mm tt": "H:mm", "h:mm:ss tt": "H:mm:ss", "dddd, MMMM dd, yyyy h:mm:ss tt": "d MMMM yyyy H:mm:ss", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "dd MMMM", "MMMM, yyyy": "MMMM yyyy", "/jan(uary)?/": "ม(.(กราค)?)?", "/feb(ruary)?/": "ก(.(ุมภาพันธ์)?)?", "/mar(ch)?/": "มี(.(นาคม)?)?", "/apr(il)?/": "เม(.(ษายน)?)?", "/may/": "พ(.(ฤษภาคม)?)?", "/jun(e)?/": "มิ(.(ถุนายน)?)?", "/jul(y)?/": "ก(.(รฎาคม)?)?", "/aug(ust)?/": "ส(.(ิงหาคม)?)?", "/sep(t(ember)?)?/": "ก(.(ันยายน)?)?", "/oct(ober)?/": "ต(.(ุลาคม)?)?", "/nov(ember)?/": "พ(.(ฤศจิกายน)?)?", "/dec(ember)?/": "ธ(.(ันวาคม)?)?", "/^su(n(day)?)?/": "^อ(า(.(ทิตย์)?)?)?", "/^mo(n(day)?)?/": "^จ((.(ันทร์)?)?)?", "/^tu(e(s(day)?)?)?/": "^อ((.(ังคาร)?)?)?", "/^we(d(nesday)?)?/": "^พ((.(ุธ)?)?)?", "/^th(u(r(s(day)?)?)?)?/": "^พ(ฤ(.(หัสบดี)?)?)?", "/^fr(i(day)?)?/": "^ศ((.(ุกร์)?)?)?", "/^sa(t(urday)?)?/": "^ส((.(สาร์)?)?)?", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "th-TH"; ================================================ FILE: build/i18n/tn-ZA.js ================================================ /* * DateJS Culture String File * Country Code: tn-ZA * Name: Tswana (South Africa) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["tn-ZA"] = { "name": "tn-ZA", "englishName": "Tswana (South Africa)", "nativeName": "Setswana (Aforika Borwa)", "Sunday": "Latshipi", "Monday": "Mosupologo", "Tuesday": "Labobedi", "Wednesday": "Laboraro", "Thursday": "Labone", "Friday": "Labotlhano", "Saturday": "Lamatlhatso", "Sun": "Sun", "Mon": "Mon", "Tue": "Tue", "Wed": "Wed", "Thu": "Thu", "Fri": "Fri", "Sat": "Sat", "Su": "Sun", "Mo": "Mon", "Tu": "Tue", "We": "Wed", "Th": "Thu", "Fr": "Fri", "Sa": "Sat", "S_Sun_Initial": "S", "M_Mon_Initial": "M", "T_Tue_Initial": "T", "W_Wed_Initial": "W", "T_Thu_Initial": "T", "F_Fri_Initial": "F", "S_Sat_Initial": "S", "January": "Ferikgong", "February": "Tlhakole", "March": "Mopitloe", "April": "Moranang", "May": "Motsheganong", "June": "Seetebosigo", "July": "Phukwi", "August": "Phatwe", "September": "Lwetse", "October": "Diphalane", "November": "Ngwanatsele", "December": "Sedimothole", "Jan_Abbr": "Jan", "Feb_Abbr": "Feb", "Mar_Abbr": "Mar", "Apr_Abbr": "Apr", "May_Abbr": "May", "Jun_Abbr": "Jun", "Jul_Abbr": "Jul", "Aug_Abbr": "Aug", "Sep_Abbr": "Sep", "Oct_Abbr": "Oct", "Nov_Abbr": "Nov", "Dec_Abbr": "Dec", "AM": "AM", "PM": "PM", "firstDayOfWeek": 0, "twoDigitYearMax": 2029, "mdy": "ymd", "M/d/yyyy": "yyyy/MM/dd", "dddd, MMMM dd, yyyy": "dd MMMM yyyy", "h:mm tt": "hh:mm:ss tt", "h:mm:ss tt": "hh:mm:ss tt", "dddd, MMMM dd, yyyy h:mm:ss tt": "dd MMMM yyyy hh:mm:ss tt", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "MMMM dd", "MMMM, yyyy": "MMMM yyyy", "/jan(uary)?/": "ferikgong", "/feb(ruary)?/": "tlhakole", "/mar(ch)?/": "mopitloe", "/apr(il)?/": "moranang", "/may/": "motsheganong", "/jun(e)?/": "seetebosigo", "/jul(y)?/": "phukwi", "/aug(ust)?/": "phatwe", "/sep(t(ember)?)?/": "lwetse", "/oct(ober)?/": "diphalane", "/nov(ember)?/": "ngwanatsele", "/dec(ember)?/": "sedimothole", "/^su(n(day)?)?/": "^latshipi", "/^mo(n(day)?)?/": "^mosupologo", "/^tu(e(s(day)?)?)?/": "^labobedi", "/^we(d(nesday)?)?/": "^laboraro", "/^th(u(r(s(day)?)?)?)?/": "^labone", "/^fr(i(day)?)?/": "^labotlhano", "/^sa(t(urday)?)?/": "^lamatlhatso", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "tn-ZA"; ================================================ FILE: build/i18n/tr-TR.js ================================================ /* * DateJS Culture String File * Country Code: tr-TR * Name: Turkish (Turkey) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["tr-TR"] = { "name": "tr-TR", "englishName": "Turkish (Turkey)", "nativeName": "Türkçe (Türkiye)", "Sunday": "Pazar", "Monday": "Pazartesi", "Tuesday": "Salı", "Wednesday": "Çarşamba", "Thursday": "Perşembe", "Friday": "Cuma", "Saturday": "Cumartesi", "Sun": "Paz", "Mon": "Pzt", "Tue": "Sal", "Wed": "Çar", "Thu": "Per", "Fri": "Cum", "Sat": "Cmt", "Su": "Pz", "Mo": "Pt", "Tu": "Sa", "We": "Ça", "Th": "Pe", "Fr": "Cu", "Sa": "Ct", "S_Sun_Initial": "P", "M_Mon_Initial": "P", "T_Tue_Initial": "S", "W_Wed_Initial": "Ç", "T_Thu_Initial": "P", "F_Fri_Initial": "C", "S_Sat_Initial": "C", "January": "Ocak", "February": "Şubat", "March": "Mart", "April": "Nisan", "May": "Mayıs", "June": "Haziran", "July": "Temmuz", "August": "Ağustos", "September": "Eylül", "October": "Ekim", "November": "Kasım", "December": "Aralık", "Jan_Abbr": "Oca", "Feb_Abbr": "Şub", "Mar_Abbr": "Mar", "Apr_Abbr": "Nis", "May_Abbr": "May", "Jun_Abbr": "Haz", "Jul_Abbr": "Tem", "Aug_Abbr": "Ağu", "Sep_Abbr": "Eyl", "Oct_Abbr": "Eki", "Nov_Abbr": "Kas", "Dec_Abbr": "Ara", "AM": "", "PM": "", "firstDayOfWeek": 1, "twoDigitYearMax": 2029, "mdy": "dmy", "M/d/yyyy": "dd.MM.yyyy", "dddd, MMMM dd, yyyy": "dd MMMM yyyy dddd", "h:mm tt": "HH:mm", "h:mm:ss tt": "HH:mm:ss", "dddd, MMMM dd, yyyy h:mm:ss tt": "dd MMMM yyyy dddd HH:mm:ss", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "dd MMMM", "MMMM, yyyy": "MMMM yyyy", "/jan(uary)?/": "oca(k)?", "/feb(ruary)?/": "şub(at)?", "/mar(ch)?/": "mar(t)?", "/apr(il)?/": "nis(an)?", "/may/": "may(ıs)?", "/jun(e)?/": "haz(iran)?", "/jul(y)?/": "tem(muz)?", "/aug(ust)?/": "ağu(stos)?", "/sep(t(ember)?)?/": "eyl(ül)?", "/oct(ober)?/": "eki(m)?", "/nov(ember)?/": "kas(ım)?", "/dec(ember)?/": "ara(lık)?", "/^su(n(day)?)?/": "^pz(z(ar)?)?", "/^mo(n(day)?)?/": "^pt(t(artesi)?)?", "/^tu(e(s(day)?)?)?/": "^sa(l(ı)?)?", "/^we(d(nesday)?)?/": "^ça(r(şamba)?)?", "/^th(u(r(s(day)?)?)?)?/": "^pe(r(şembe)?)?", "/^fr(i(day)?)?/": "^cu(m(a)?)?", "/^sa(t(urday)?)?/": "^ct(t(artesi)?)?", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "tr-TR"; ================================================ FILE: build/i18n/tt-RU.js ================================================ /* * DateJS Culture String File * Country Code: tt-RU * Name: Tatar (Russia) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["tt-RU"] = { "name": "tt-RU", "englishName": "Tatar (Russia)", "nativeName": "Татар (Россия)", "Sunday": "Якшәмбе", "Monday": "Дүшәмбе", "Tuesday": "Сишәмбе", "Wednesday": "Чәршәмбе", "Thursday": "Пәнҗешәмбе", "Friday": "Җомга", "Saturday": "Шимбә", "Sun": "Якш", "Mon": "Дүш", "Tue": "Сиш", "Wed": "Чәрш", "Thu": "Пәнҗ", "Fri": "Җом", "Sat": "Шим", "Su": "Якш", "Mo": "Дүш", "Tu": "Сиш", "We": "Чәрш", "Th": "Пәнҗ", "Fr": "Җом", "Sa": "Шим", "S_Sun_Initial": "Я", "M_Mon_Initial": "Д", "T_Tue_Initial": "С", "W_Wed_Initial": "Ч", "T_Thu_Initial": "П", "F_Fri_Initial": "Җ", "S_Sat_Initial": "Ш", "January": "Гыйнварь", "February": "Февраль", "March": "Март", "April": "Апрель", "May": "Май", "June": "Июнь", "July": "Июль", "August": "Август", "September": "Сентябрь", "October": "Октябрь", "November": "Ноябрь", "December": "Декабрь", "Jan_Abbr": "Гыйнв", "Feb_Abbr": "Фев", "Mar_Abbr": "Мар", "Apr_Abbr": "Апр", "May_Abbr": "Май", "Jun_Abbr": "Июн", "Jul_Abbr": "Июл", "Aug_Abbr": "Авг", "Sep_Abbr": "Сен", "Oct_Abbr": "Окт", "Nov_Abbr": "Ноя", "Dec_Abbr": "Дек", "AM": "", "PM": "", "firstDayOfWeek": 1, "twoDigitYearMax": 2029, "mdy": "dmy", "M/d/yyyy": "dd.MM.yyyy", "dddd, MMMM dd, yyyy": "d MMMM yyyy", "h:mm tt": "H:mm", "h:mm:ss tt": "H:mm:ss", "dddd, MMMM dd, yyyy h:mm:ss tt": "d MMMM yyyy H:mm:ss", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "d MMMM", "MMMM, yyyy": "MMMM yyyy", "/jan(uary)?/": "гыйнв(арь)?", "/feb(ruary)?/": "фев(раль)?", "/mar(ch)?/": "мар(т)?", "/apr(il)?/": "апр(ель)?", "/may/": "май", "/jun(e)?/": "июн(ь)?", "/jul(y)?/": "июл(ь)?", "/aug(ust)?/": "авг(уст)?", "/sep(t(ember)?)?/": "сен(тябрь)?", "/oct(ober)?/": "окт(ябрь)?", "/nov(ember)?/": "ноя(брь)?", "/dec(ember)?/": "дек(абрь)?", "/^su(n(day)?)?/": "^якшәмбе", "/^mo(n(day)?)?/": "^дүшәмбе", "/^tu(e(s(day)?)?)?/": "^сишәмбе", "/^we(d(nesday)?)?/": "^чәршәмбе", "/^th(u(r(s(day)?)?)?)?/": "^пәнҗешәмбе", "/^fr(i(day)?)?/": "^җомга", "/^sa(t(urday)?)?/": "^шимбә", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "tt-RU"; ================================================ FILE: build/i18n/uk-UA.js ================================================ /* * DateJS Culture String File * Country Code: uk-UA * Name: Ukrainian (Ukraine) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["uk-UA"] = { "name": "uk-UA", "englishName": "Ukrainian (Ukraine)", "nativeName": "україньска (Україна)", "Sunday": "неділя", "Monday": "понеділок", "Tuesday": "вівторок", "Wednesday": "середа", "Thursday": "четвер", "Friday": "п'ятниця", "Saturday": "субота", "Sun": "Нд", "Mon": "Пн", "Tue": "Вт", "Wed": "Ср", "Thu": "Чт", "Fri": "Пт", "Sat": "Сб", "Su": "Нд", "Mo": "Пн", "Tu": "Вт", "We": "Ср", "Th": "Чт", "Fr": "Пт", "Sa": "Сб", "S_Sun_Initial": "Н", "M_Mon_Initial": "П", "T_Tue_Initial": "В", "W_Wed_Initial": "С", "T_Thu_Initial": "Ч", "F_Fri_Initial": "П", "S_Sat_Initial": "С", "January": "Січень", "February": "Лютий", "March": "Березень", "April": "Квітень", "May": "Травень", "June": "Червень", "July": "Липень", "August": "Серпень", "September": "Вересень", "October": "Жовтень", "November": "Листопад", "December": "Грудень", "Jan_Abbr": "Січ", "Feb_Abbr": "Лют", "Mar_Abbr": "Бер", "Apr_Abbr": "Кві", "May_Abbr": "Тра", "Jun_Abbr": "Чер", "Jul_Abbr": "Лип", "Aug_Abbr": "Сер", "Sep_Abbr": "Вер", "Oct_Abbr": "Жов", "Nov_Abbr": "Лис", "Dec_Abbr": "Гру", "AM": "", "PM": "", "firstDayOfWeek": 1, "twoDigitYearMax": 2029, "mdy": "dmy", "M/d/yyyy": "dd.MM.yyyy", "dddd, MMMM dd, yyyy": "d MMMM yyyy' р.'", "h:mm tt": "H:mm", "h:mm:ss tt": "H:mm:ss", "dddd, MMMM dd, yyyy h:mm:ss tt": "d MMMM yyyy' р.' H:mm:ss", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "d MMMM", "MMMM, yyyy": "MMMM yyyy' р.'", "/jan(uary)?/": "січ(ень)?", "/feb(ruary)?/": "лют(ий)?", "/mar(ch)?/": "бер(езень)?", "/apr(il)?/": "кві(тень)?", "/may/": "тра(вень)?", "/jun(e)?/": "чер(вень)?", "/jul(y)?/": "лип(ень)?", "/aug(ust)?/": "сер(пень)?", "/sep(t(ember)?)?/": "вер(есень)?", "/oct(ober)?/": "жов(тень)?", "/nov(ember)?/": "лис(топад)?", "/dec(ember)?/": "гру(день)?", "/^su(n(day)?)?/": "^неділя", "/^mo(n(day)?)?/": "^понеділок", "/^tu(e(s(day)?)?)?/": "^вівторок", "/^we(d(nesday)?)?/": "^середа", "/^th(u(r(s(day)?)?)?)?/": "^четвер", "/^fr(i(day)?)?/": "^п'ятниця", "/^sa(t(urday)?)?/": "^субота", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "uk-UA"; ================================================ FILE: build/i18n/ur-PK.js ================================================ /* * DateJS Culture String File * Country Code: ur-PK * Name: Urdu (Islamic Republic of Pakistan) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["ur-PK"] = { "name": "ur-PK", "englishName": "Urdu (Islamic Republic of Pakistan)", "nativeName": "اُردو (پاکستان)", "Sunday": "اتوار", "Monday": "پير", "Tuesday": "منگل", "Wednesday": "بدھ", "Thursday": "جمعرات", "Friday": "جمعه", "Saturday": "هفته", "Sun": "اتوار", "Mon": "پير", "Tue": "منگل", "Wed": "بدھ", "Thu": "جمعرات", "Fri": "جمعه", "Sat": "هفته", "Su": "ا", "Mo": "پ", "Tu": "م", "We": "ب", "Th": "ج", "Fr": "ج", "Sa": "ه", "S_Sun_Initial": "ا", "M_Mon_Initial": "پ", "T_Tue_Initial": "م", "W_Wed_Initial": "ب", "T_Thu_Initial": "ج", "F_Fri_Initial": "ج", "S_Sat_Initial": "ه", "January": "جنورى", "February": "فرورى", "March": "مارچ", "April": "اپريل", "May": "مئ", "June": "جون", "July": "جولاٸ", "August": "اگست", "September": "ستمبر", "October": "اکتوبر", "November": "نومبر", "December": "دسمبر", "Jan_Abbr": "جنورى", "Feb_Abbr": "فرورى", "Mar_Abbr": "مارچ", "Apr_Abbr": "اپريل", "May_Abbr": "مئ", "Jun_Abbr": "جون", "Jul_Abbr": "جولاٸ", "Aug_Abbr": "اگست", "Sep_Abbr": "ستمبر", "Oct_Abbr": "اکتوبر", "Nov_Abbr": "نومبر", "Dec_Abbr": "دسمبر", "AM": "AM", "PM": "PM", "firstDayOfWeek": 1, "twoDigitYearMax": 2029, "mdy": "dmy", "M/d/yyyy": "dd/MM/yyyy", "dddd, MMMM dd, yyyy": "dd MMMM, yyyy", "h:mm tt": "h:mm tt", "h:mm:ss tt": "h:mm:ss tt", "dddd, MMMM dd, yyyy h:mm:ss tt": "dd MMMM, yyyy h:mm:ss tt", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "dd MMMM", "MMMM, yyyy": "MMMM, yyyy", "/jan(uary)?/": "جنورى", "/feb(ruary)?/": "فرورى", "/mar(ch)?/": "مارچ", "/apr(il)?/": "اپريل", "/may/": "مئ", "/jun(e)?/": "جون", "/jul(y)?/": "جولاٸ", "/aug(ust)?/": "اگست", "/sep(t(ember)?)?/": "ستمبر", "/oct(ober)?/": "اکتوبر", "/nov(ember)?/": "نومبر", "/dec(ember)?/": "دسمبر", "/^su(n(day)?)?/": "^ا(1)?", "/^mo(n(day)?)?/": "^پ(1)?", "/^tu(e(s(day)?)?)?/": "^م(1)?", "/^we(d(nesday)?)?/": "^ب(1)?", "/^th(u(r(s(day)?)?)?)?/": "^ج(1)?", "/^fr(i(day)?)?/": "^ج(1)?", "/^sa(t(urday)?)?/": "^ه(1)?", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "ur-PK"; ================================================ FILE: build/i18n/uz-Cyrl-UZ.js ================================================ /* * DateJS Culture String File * Country Code: uz-Cyrl-UZ * Name: Uzbek (Cyrillic, Uzbekistan) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["uz-Cyrl-UZ"] = { "name": "uz-Cyrl-UZ", "englishName": "Uzbek (Cyrillic, Uzbekistan)", "nativeName": "Ўзбек (Ўзбекистон)", "Sunday": "якшанба", "Monday": "душанба", "Tuesday": "сешанба", "Wednesday": "чоршанба", "Thursday": "пайшанба", "Friday": "жума", "Saturday": "шанба", "Sun": "якш", "Mon": "дш", "Tue": "сш", "Wed": "чш", "Thu": "пш", "Fri": "ж", "Sat": "ш", "Su": "якш", "Mo": "дш", "Tu": "сш", "We": "чш", "Th": "пш", "Fr": "ж", "Sa": "ш", "S_Sun_Initial": "я", "M_Mon_Initial": "д", "T_Tue_Initial": "с", "W_Wed_Initial": "ч", "T_Thu_Initial": "п", "F_Fri_Initial": "ж", "S_Sat_Initial": "ш", "January": "Январ", "February": "Феврал", "March": "Март", "April": "Апрел", "May": "Май", "June": "Июн", "July": "Июл", "August": "Август", "September": "Сентябр", "October": "Октябр", "November": "Ноябр", "December": "Декабр", "Jan_Abbr": "Янв", "Feb_Abbr": "Фев", "Mar_Abbr": "Мар", "Apr_Abbr": "Апр", "May_Abbr": "Май", "Jun_Abbr": "Июн", "Jul_Abbr": "Июл", "Aug_Abbr": "Авг", "Sep_Abbr": "Сен", "Oct_Abbr": "Окт", "Nov_Abbr": "Ноя", "Dec_Abbr": "Дек", "AM": "", "PM": "", "firstDayOfWeek": 1, "twoDigitYearMax": 2029, "mdy": "dmy", "M/d/yyyy": "dd.MM.yyyy", "dddd, MMMM dd, yyyy": "yyyy 'йил' d-MMMM", "h:mm tt": "HH:mm", "h:mm:ss tt": "HH:mm:ss", "dddd, MMMM dd, yyyy h:mm:ss tt": "yyyy 'йил' d-MMMM HH:mm:ss", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "d-MMMM", "MMMM, yyyy": "MMMM yyyy", "/jan(uary)?/": "янв(ар)?", "/feb(ruary)?/": "фев(рал)?", "/mar(ch)?/": "мар(т)?", "/apr(il)?/": "апр(ел)?", "/may/": "май", "/jun(e)?/": "июн", "/jul(y)?/": "июл", "/aug(ust)?/": "авг(уст)?", "/sep(t(ember)?)?/": "сен(тябр)?", "/oct(ober)?/": "окт(ябр)?", "/nov(ember)?/": "ноя(бр)?", "/dec(ember)?/": "дек(абр)?", "/^su(n(day)?)?/": "^якшанба", "/^mo(n(day)?)?/": "^душанба", "/^tu(e(s(day)?)?)?/": "^сешанба", "/^we(d(nesday)?)?/": "^чоршанба", "/^th(u(r(s(day)?)?)?)?/": "^пайшанба", "/^fr(i(day)?)?/": "^жума", "/^sa(t(urday)?)?/": "^шанба", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "uz-Cyrl-UZ"; ================================================ FILE: build/i18n/uz-Latn-UZ.js ================================================ /* * DateJS Culture String File * Country Code: uz-Latn-UZ * Name: Uzbek (Latin, Uzbekistan) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["uz-Latn-UZ"] = { "name": "uz-Latn-UZ", "englishName": "Uzbek (Latin, Uzbekistan)", "nativeName": "U'zbek (U'zbekiston Respublikasi)", "Sunday": "yakshanba", "Monday": "dushanba", "Tuesday": "seshanba", "Wednesday": "chorshanba", "Thursday": "payshanba", "Friday": "juma", "Saturday": "shanba", "Sun": "yak.", "Mon": "dsh.", "Tue": "sesh.", "Wed": "chr.", "Thu": "psh.", "Fri": "jm.", "Sat": "sh.", "Su": "yak", "Mo": "dsh", "Tu": "sesh", "We": "chr", "Th": "psh", "Fr": "jm", "Sa": "sh", "S_Sun_Initial": "y", "M_Mon_Initial": "d", "T_Tue_Initial": "s", "W_Wed_Initial": "c", "T_Thu_Initial": "p", "F_Fri_Initial": "j", "S_Sat_Initial": "s", "January": "yanvar", "February": "fevral", "March": "mart", "April": "aprel", "May": "may", "June": "iyun", "July": "iyul", "August": "avgust", "September": "sentyabr", "October": "oktyabr", "November": "noyabr", "December": "dekabr", "Jan_Abbr": "yanvar", "Feb_Abbr": "fevral", "Mar_Abbr": "mart", "Apr_Abbr": "aprel", "May_Abbr": "may", "Jun_Abbr": "iyun", "Jul_Abbr": "iyul", "Aug_Abbr": "avgust", "Sep_Abbr": "sentyabr", "Oct_Abbr": "oktyabr", "Nov_Abbr": "noyabr", "Dec_Abbr": "dekabr", "AM": "", "PM": "", "firstDayOfWeek": 1, "twoDigitYearMax": 2029, "mdy": "dmy", "M/d/yyyy": "dd/MM yyyy", "dddd, MMMM dd, yyyy": "yyyy 'yil' d-MMMM", "h:mm tt": "HH:mm", "h:mm:ss tt": "HH:mm:ss", "dddd, MMMM dd, yyyy h:mm:ss tt": "yyyy 'yil' d-MMMM HH:mm:ss", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "d-MMMM", "MMMM, yyyy": "MMMM yyyy", "/jan(uary)?/": "yanvar", "/feb(ruary)?/": "fevral", "/mar(ch)?/": "mart", "/apr(il)?/": "aprel", "/may/": "may", "/jun(e)?/": "iyun", "/jul(y)?/": "iyul", "/aug(ust)?/": "avgust", "/sep(t(ember)?)?/": "sentyabr", "/oct(ober)?/": "oktyabr", "/nov(ember)?/": "noyabr", "/dec(ember)?/": "dekabr", "/^su(n(day)?)?/": "^yak((.(shanba)?)?)?", "/^mo(n(day)?)?/": "^dsh((.(hanba)?)?)?", "/^tu(e(s(day)?)?)?/": "^sesh((.(anba)?)?)?", "/^we(d(nesday)?)?/": "^chr((.(rshanba)?)?)?", "/^th(u(r(s(day)?)?)?)?/": "^psh((.(shanba)?)?)?", "/^fr(i(day)?)?/": "^jm((.(ma)?)?)?", "/^sa(t(urday)?)?/": "^sh((.(anba)?)?)?", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "uz-Latn-UZ"; ================================================ FILE: build/i18n/vi-VN.js ================================================ /* * DateJS Culture String File * Country Code: vi-VN * Name: Vietnamese (Vietnam) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["vi-VN"] = { "name": "vi-VN", "englishName": "Vietnamese (Vietnam)", "nativeName": "Tiếng Việt (Việt Nam)", "Sunday": "Chủ Nhật", "Monday": "Thứ Hai", "Tuesday": "Thứ Ba", "Wednesday": "Thứ Tư", "Thursday": "Thứ Năm", "Friday": "Thứ Sáu", "Saturday": "Thứ Bảy", "Sun": "CN", "Mon": "Hai", "Tue": "Ba", "Wed": "Tư", "Thu": "Năm", "Fri": "Sáu", "Sat": "Bảy", "Su": "C", "Mo": "H", "Tu": "B", "We": "T", "Th": "N", "Fr": "S", "Sa": "B", "S_Sun_Initial": "C", "M_Mon_Initial": "H", "T_Tue_Initial": "B", "W_Wed_Initial": "T", "T_Thu_Initial": "N", "F_Fri_Initial": "S", "S_Sat_Initial": "B", "January": "Tháng Giêng", "February": "Tháng Hai", "March": "Tháng Ba", "April": "Tháng Tư", "May": "Tháng Năm", "June": "Tháng Sáu", "July": "Tháng Bảy", "August": "Tháng Tám", "September": "Tháng Chín", "October": "Tháng Mười", "November": "Tháng Mười Một", "December": "Tháng Mười Hai", "Jan_Abbr": "Thg1", "Feb_Abbr": "Thg2", "Mar_Abbr": "Thg3", "Apr_Abbr": "Thg4", "May_Abbr": "Thg5", "Jun_Abbr": "Thg6", "Jul_Abbr": "Thg7", "Aug_Abbr": "Thg8", "Sep_Abbr": "Thg9", "Oct_Abbr": "Thg10", "Nov_Abbr": "Thg11", "Dec_Abbr": "Thg12", "AM": "SA", "PM": "CH", "firstDayOfWeek": 1, "twoDigitYearMax": 2029, "mdy": "dmy", "M/d/yyyy": "dd/MM/yyyy", "dddd, MMMM dd, yyyy": "dd MMMM yyyy", "h:mm tt": "h:mm tt", "h:mm:ss tt": "h:mm:ss tt", "dddd, MMMM dd, yyyy h:mm:ss tt": "dd MMMM yyyy h:mm:ss tt", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "dd MMMM", "MMMM, yyyy": "MMMM yyyy", "/jan(uary)?/": "tháng giêng", "/feb(ruary)?/": "tháng hai", "/mar(ch)?/": "tháng ba", "/apr(il)?/": "tháng tư", "/may/": "tháng năm", "/jun(e)?/": "tháng sáu", "/jul(y)?/": "tháng bảy", "/aug(ust)?/": "tháng tám", "/sep(t(ember)?)?/": "tháng chín", "/oct(ober)?/": "tháng mười", "/nov(ember)?/": "tháng mười một", "/dec(ember)?/": "tháng mười hai", "/^su(n(day)?)?/": "^c(n(ủ nhật)?)?", "/^mo(n(day)?)?/": "^h(ai(́ hai)?)?", "/^tu(e(s(day)?)?)?/": "^b(a(ứ ba)?)?", "/^we(d(nesday)?)?/": "^t(ư(ứ tư)?)?", "/^th(u(r(s(day)?)?)?)?/": "^n(ăm(́ năm)?)?", "/^fr(i(day)?)?/": "^s(áu( sáu)?)?", "/^sa(t(urday)?)?/": "^b(ảy( bảy)?)?", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "vi-VN"; ================================================ FILE: build/i18n/xh-ZA.js ================================================ /* * DateJS Culture String File * Country Code: xh-ZA * Name: Xhosa (South Africa) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["xh-ZA"] = { "name": "xh-ZA", "englishName": "Xhosa (South Africa)", "nativeName": "isiXhosa (uMzantsi Afrika)", "Sunday": "iCawa", "Monday": "uMvulo", "Tuesday": "uLwesibini", "Wednesday": "uLwesithathu", "Thursday": "uLwesine", "Friday": "uLwesihlanu", "Saturday": "uMgqibelo", "Sun": "Sun", "Mon": "Mon", "Tue": "Tue", "Wed": "Wed", "Thu": "Thu", "Fri": "Fri", "Sat": "Sat", "Su": "Sun", "Mo": "Mon", "Tu": "Tue", "We": "Wed", "Th": "Thu", "Fr": "Fri", "Sa": "Sat", "S_Sun_Initial": "S", "M_Mon_Initial": "M", "T_Tue_Initial": "T", "W_Wed_Initial": "W", "T_Thu_Initial": "T", "F_Fri_Initial": "F", "S_Sat_Initial": "S", "January": "eyoMqungu", "February": "eyoMdumba", "March": "eyoKwindla", "April": "Tshazimpuzi", "May": "Canzibe", "June": "eyeSilimela", "July": "eyeKhala", "August": "eyeThupha", "September": "eyoMsintsi", "October": "eyeDwara", "November": "eyeNkanga", "December": "eyoMnga", "Jan_Abbr": "Jan", "Feb_Abbr": "Feb", "Mar_Abbr": "Mar", "Apr_Abbr": "Apr", "May_Abbr": "May", "Jun_Abbr": "Jun", "Jul_Abbr": "Jul", "Aug_Abbr": "Aug", "Sep_Abbr": "Sep", "Oct_Abbr": "Oct", "Nov_Abbr": "Nov", "Dec_Abbr": "Dec", "AM": "AM", "PM": "PM", "firstDayOfWeek": 0, "twoDigitYearMax": 2029, "mdy": "ymd", "M/d/yyyy": "yyyy/MM/dd", "dddd, MMMM dd, yyyy": "dd MMMM yyyy", "h:mm tt": "hh:mm:ss tt", "h:mm:ss tt": "hh:mm:ss tt", "dddd, MMMM dd, yyyy h:mm:ss tt": "dd MMMM yyyy hh:mm:ss tt", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "MMMM dd", "MMMM, yyyy": "MMMM yyyy", "/jan(uary)?/": "eyomqungu", "/feb(ruary)?/": "eyomdumba", "/mar(ch)?/": "eyokwindla", "/apr(il)?/": "tshazimpuzi", "/may/": "canzibe", "/jun(e)?/": "eyesilimela", "/jul(y)?/": "eyekhala", "/aug(ust)?/": "eyethupha", "/sep(t(ember)?)?/": "eyomsintsi", "/oct(ober)?/": "eyedwara", "/nov(ember)?/": "eyenkanga", "/dec(ember)?/": "eyomnga", "/^su(n(day)?)?/": "^icawa", "/^mo(n(day)?)?/": "^umvulo", "/^tu(e(s(day)?)?)?/": "^ulwesibini", "/^we(d(nesday)?)?/": "^ulwesithathu", "/^th(u(r(s(day)?)?)?)?/": "^ulwesine", "/^fr(i(day)?)?/": "^ulwesihlanu", "/^sa(t(urday)?)?/": "^umgqibelo", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "xh-ZA"; ================================================ FILE: build/i18n/zh-CN.js ================================================ /* * DateJS Culture String File * Country Code: zh-CN * Name: Chinese (People's Republic of China) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["zh-CN"] = { "name": "zh-CN", "englishName": "Chinese (People's Republic of China)", "nativeName": "中文(中华人民共和国)", "Sunday": "星期日", "Monday": "星期一", "Tuesday": "星期二", "Wednesday": "星期三", "Thursday": "星期四", "Friday": "星期五", "Saturday": "星期六", "Sun": "日", "Mon": "一", "Tue": "二", "Wed": "三", "Thu": "四", "Fri": "五", "Sat": "六", "Su": "日", "Mo": "一", "Tu": "二", "We": "三", "Th": "四", "Fr": "五", "Sa": "六", "S_Sun_Initial": "日", "M_Mon_Initial": "一", "T_Tue_Initial": "二", "W_Wed_Initial": "三", "T_Thu_Initial": "四", "F_Fri_Initial": "五", "S_Sat_Initial": "六", "January": "一月", "February": "二月", "March": "三月", "April": "四月", "May": "五月", "June": "六月", "July": "七月", "August": "八月", "September": "九月", "October": "十月", "November": "十一月", "December": "十二月", "Jan_Abbr": "一月", "Feb_Abbr": "二月", "Mar_Abbr": "三月", "Apr_Abbr": "四月", "May_Abbr": "五月", "Jun_Abbr": "六月", "Jul_Abbr": "七月", "Aug_Abbr": "八月", "Sep_Abbr": "九月", "Oct_Abbr": "十月", "Nov_Abbr": "十一月", "Dec_Abbr": "十二月", "AM": "上午", "PM": "下午", "firstDayOfWeek": 0, "twoDigitYearMax": 2029, "mdy": "ymd", "M/d/yyyy": "yyyy/M/d", "dddd, MMMM dd, yyyy": "yyyy'年'M'月'd'日'", "h:mm tt": "H:mm", "h:mm:ss tt": "H:mm:ss", "dddd, MMMM dd, yyyy h:mm:ss tt": "yyyy'年'M'月'd'日' H:mm:ss", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "M'月'd'日'", "MMMM, yyyy": "yyyy'年'M'月'", "/jan(uary)?/": "一月", "/feb(ruary)?/": "二月", "/mar(ch)?/": "三月", "/apr(il)?/": "四月", "/may/": "五月", "/jun(e)?/": "六月", "/jul(y)?/": "七月", "/aug(ust)?/": "八月", "/sep(t(ember)?)?/": "九月", "/oct(ober)?/": "十月", "/nov(ember)?/": "十一月", "/dec(ember)?/": "十二月", "/^su(n(day)?)?/": "^星期日", "/^mo(n(day)?)?/": "^星期一", "/^tu(e(s(day)?)?)?/": "^星期二", "/^we(d(nesday)?)?/": "^星期三", "/^th(u(r(s(day)?)?)?)?/": "^星期四", "/^fr(i(day)?)?/": "^星期五", "/^sa(t(urday)?)?/": "^星期六", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "zh-CN"; ================================================ FILE: build/i18n/zh-HK.js ================================================ /* * DateJS Culture String File * Country Code: zh-HK * Name: Chinese (Hong Kong S.A.R.) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["zh-HK"] = { "name": "zh-HK", "englishName": "Chinese (Hong Kong S.A.R.)", "nativeName": "中文(香港特别行政區)", "Sunday": "Sunday", "Monday": "Monday", "Tuesday": "Tuesday", "Wednesday": "Wednesday", "Thursday": "Thursday", "Friday": "Friday", "Saturday": "Saturday", "Sun": "Sun", "Mon": "Mon", "Tue": "Tue", "Wed": "Wed", "Thu": "Thu", "Fri": "Fri", "Sat": "Sat", "Su": "Su", "Mo": "Mo", "Tu": "Tu", "We": "We", "Th": "Th", "Fr": "Fr", "Sa": "Sa", "S_Sun_Initial": "S", "M_Mon_Initial": "M", "T_Tue_Initial": "T", "W_Wed_Initial": "W", "T_Thu_Initial": "T", "F_Fri_Initial": "F", "S_Sat_Initial": "S", "January": "January", "February": "February", "March": "March", "April": "April", "May": "May", "June": "June", "July": "July", "August": "August", "September": "September", "October": "October", "November": "November", "December": "December", "Jan_Abbr": "Jan", "Feb_Abbr": "Feb", "Mar_Abbr": "Mar", "Apr_Abbr": "Apr", "May_Abbr": "May", "Jun_Abbr": "Jun", "Jul_Abbr": "Jul", "Aug_Abbr": "Aug", "Sep_Abbr": "Sep", "Oct_Abbr": "Oct", "Nov_Abbr": "Nov", "Dec_Abbr": "Dec", "AM": "", "PM": "", "firstDayOfWeek": 0, "twoDigitYearMax": 2029, "mdy": "dmy", "M/d/yyyy": "d/M/yyyy", "dddd, MMMM dd, yyyy": "dddd, d MMMM, yyyy", "h:mm tt": "H:mm", "h:mm:ss tt": "H:mm:ss", "dddd, MMMM dd, yyyy h:mm:ss tt": "dddd, d MMMM, yyyy H:mm:ss", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "d MMMM", "MMMM, yyyy": "MMMM, yyyy", "/jan(uary)?/": "jan(uary)?", "/feb(ruary)?/": "feb(ruary)?", "/mar(ch)?/": "mar(ch)?", "/apr(il)?/": "apr(il)?", "/may/": "may", "/jun(e)?/": "jun(e)?", "/jul(y)?/": "jul(y)?", "/aug(ust)?/": "aug(ust)?", "/sep(t(ember)?)?/": "sep(t(ember)?)?", "/oct(ober)?/": "oct(ober)?", "/nov(ember)?/": "nov(ember)?", "/dec(ember)?/": "dec(ember)?", "/^su(n(day)?)?/": "^su(n(day)?)?", "/^mo(n(day)?)?/": "^mo(n(day)?)?", "/^tu(e(s(day)?)?)?/": "^tu(e(s(day)?)?)?", "/^we(d(nesday)?)?/": "^we(d(nesday)?)?", "/^th(u(r(s(day)?)?)?)?/": "^th(u(r(s(day)?)?)?)?", "/^fr(i(day)?)?/": "^fr(i(day)?)?", "/^sa(t(urday)?)?/": "^sa(t(urday)?)?", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "zh-HK"; ================================================ FILE: build/i18n/zh-MO.js ================================================ /* * DateJS Culture String File * Country Code: zh-MO * Name: Chinese (Macao S.A.R.) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["zh-MO"] = { "name": "zh-MO", "englishName": "Chinese (Macao S.A.R.)", "nativeName": "中文(澳門特别行政區)", "Sunday": "星期日", "Monday": "星期一", "Tuesday": "星期二", "Wednesday": "星期三", "Thursday": "星期四", "Friday": "星期五", "Saturday": "星期六", "Sun": "星期日", "Mon": "星期一", "Tue": "星期二", "Wed": "星期三", "Thu": "星期四", "Fri": "星期五", "Sat": "星期六", "Su": "日", "Mo": "一", "Tu": "二", "We": "三", "Th": "四", "Fr": "五", "Sa": "六", "S_Sun_Initial": "日", "M_Mon_Initial": "一", "T_Tue_Initial": "二", "W_Wed_Initial": "三", "T_Thu_Initial": "四", "F_Fri_Initial": "五", "S_Sat_Initial": "六", "January": "一月", "February": "二月", "March": "三月", "April": "四月", "May": "五月", "June": "六月", "July": "七月", "August": "八月", "September": "九月", "October": "十月", "November": "十一月", "December": "十二月", "Jan_Abbr": "一月", "Feb_Abbr": "二月", "Mar_Abbr": "三月", "Apr_Abbr": "四月", "May_Abbr": "五月", "Jun_Abbr": "六月", "Jul_Abbr": "七月", "Aug_Abbr": "八月", "Sep_Abbr": "九月", "Oct_Abbr": "十月", "Nov_Abbr": "十一月", "Dec_Abbr": "十二月", "AM": "", "PM": "", "firstDayOfWeek": 0, "twoDigitYearMax": 2029, "mdy": "dmy", "M/d/yyyy": "d/M/yyyy", "dddd, MMMM dd, yyyy": "dddd, d MMMM, yyyy", "h:mm tt": "H:mm", "h:mm:ss tt": "H:mm:ss", "dddd, MMMM dd, yyyy h:mm:ss tt": "dddd, d MMMM, yyyy H:mm:ss", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "d MMMM", "MMMM, yyyy": "MMMM, yyyy", "/jan(uary)?/": "一月", "/feb(ruary)?/": "二月", "/mar(ch)?/": "三月", "/apr(il)?/": "四月", "/may/": "五月", "/jun(e)?/": "六月", "/jul(y)?/": "七月", "/aug(ust)?/": "八月", "/sep(t(ember)?)?/": "九月", "/oct(ober)?/": "十月", "/nov(ember)?/": "十一月", "/dec(ember)?/": "十二月", "/^su(n(day)?)?/": "^星期日", "/^mo(n(day)?)?/": "^星期一", "/^tu(e(s(day)?)?)?/": "^星期二", "/^we(d(nesday)?)?/": "^星期三", "/^th(u(r(s(day)?)?)?)?/": "^星期四", "/^fr(i(day)?)?/": "^星期五", "/^sa(t(urday)?)?/": "^星期六", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "zh-MO"; ================================================ FILE: build/i18n/zh-SG.js ================================================ /* * DateJS Culture String File * Country Code: zh-SG * Name: Chinese (Singapore) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["zh-SG"] = { "name": "zh-SG", "englishName": "Chinese (Singapore)", "nativeName": "中文(新加坡)", "Sunday": "星期日", "Monday": "星期一", "Tuesday": "星期二", "Wednesday": "星期三", "Thursday": "星期四", "Friday": "星期五", "Saturday": "星期六", "Sun": "星期日", "Mon": "星期一", "Tue": "星期二", "Wed": "星期三", "Thu": "星期四", "Fri": "星期五", "Sat": "星期六", "Su": "日", "Mo": "一", "Tu": "二", "We": "三", "Th": "四", "Fr": "五", "Sa": "六", "S_Sun_Initial": "日", "M_Mon_Initial": "一", "T_Tue_Initial": "二", "W_Wed_Initial": "三", "T_Thu_Initial": "四", "F_Fri_Initial": "五", "S_Sat_Initial": "六", "January": "一月", "February": "二月", "March": "三月", "April": "四月", "May": "五月", "June": "六月", "July": "七月", "August": "八月", "September": "九月", "October": "十月", "November": "十一月", "December": "十二月", "Jan_Abbr": "一月", "Feb_Abbr": "二月", "Mar_Abbr": "三月", "Apr_Abbr": "四月", "May_Abbr": "五月", "Jun_Abbr": "六月", "Jul_Abbr": "七月", "Aug_Abbr": "八月", "Sep_Abbr": "九月", "Oct_Abbr": "十月", "Nov_Abbr": "十一月", "Dec_Abbr": "十二月", "AM": "AM", "PM": "PM", "firstDayOfWeek": 0, "twoDigitYearMax": 2029, "mdy": "dmy", "M/d/yyyy": "d/M/yyyy", "dddd, MMMM dd, yyyy": "dddd, d MMMM, yyyy", "h:mm tt": "tt h:mm", "h:mm:ss tt": "tt h:mm:ss", "dddd, MMMM dd, yyyy h:mm:ss tt": "dddd, d MMMM, yyyy tt h:mm:ss", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "d MMMM", "MMMM, yyyy": "MMMM, yyyy", "/jan(uary)?/": "一月", "/feb(ruary)?/": "二月", "/mar(ch)?/": "三月", "/apr(il)?/": "四月", "/may/": "五月", "/jun(e)?/": "六月", "/jul(y)?/": "七月", "/aug(ust)?/": "八月", "/sep(t(ember)?)?/": "九月", "/oct(ober)?/": "十月", "/nov(ember)?/": "十一月", "/dec(ember)?/": "十二月", "/^su(n(day)?)?/": "^星期日", "/^mo(n(day)?)?/": "^星期一", "/^tu(e(s(day)?)?)?/": "^星期二", "/^we(d(nesday)?)?/": "^星期三", "/^th(u(r(s(day)?)?)?)?/": "^星期四", "/^fr(i(day)?)?/": "^星期五", "/^sa(t(urday)?)?/": "^星期六", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "zh-SG"; ================================================ FILE: build/i18n/zh-TW.js ================================================ /* * DateJS Culture String File * Country Code: zh-TW * Name: Chinese (Taiwan) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["zh-TW"] = { "name": "zh-TW", "englishName": "Chinese (Taiwan)", "nativeName": "中文(台灣)", "Sunday": "星期日", "Monday": "星期一", "Tuesday": "星期二", "Wednesday": "星期三", "Thursday": "星期四", "Friday": "星期五", "Saturday": "星期六", "Sun": "星期日", "Mon": "星期一", "Tue": "星期二", "Wed": "星期三", "Thu": "星期四", "Fri": "星期五", "Sat": "星期六", "Su": "日", "Mo": "一", "Tu": "二", "We": "三", "Th": "四", "Fr": "五", "Sa": "六", "S_Sun_Initial": "日", "M_Mon_Initial": "一", "T_Tue_Initial": "二", "W_Wed_Initial": "三", "T_Thu_Initial": "四", "F_Fri_Initial": "五", "S_Sat_Initial": "六", "January": "一月", "February": "二月", "March": "三月", "April": "四月", "May": "五月", "June": "六月", "July": "七月", "August": "八月", "September": "九月", "October": "十月", "November": "十一月", "December": "十二月", "Jan_Abbr": "一月", "Feb_Abbr": "二月", "Mar_Abbr": "三月", "Apr_Abbr": "四月", "May_Abbr": "五月", "Jun_Abbr": "六月", "Jul_Abbr": "七月", "Aug_Abbr": "八月", "Sep_Abbr": "九月", "Oct_Abbr": "十月", "Nov_Abbr": "十一月", "Dec_Abbr": "十二月", "AM": "上午", "PM": "下午", "firstDayOfWeek": 0, "twoDigitYearMax": 2029, "mdy": "ymd", "M/d/yyyy": "yyyy/M/d", "dddd, MMMM dd, yyyy": "yyyy'年'M'月'd'日'", "h:mm tt": "tt hh:mm", "h:mm:ss tt": "tt hh:mm:ss", "dddd, MMMM dd, yyyy h:mm:ss tt": "yyyy'年'M'月'd'日' tt hh:mm:ss", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "M'月'd'日'", "MMMM, yyyy": "yyyy'年'M'月'", "/jan(uary)?/": "一月", "/feb(ruary)?/": "二月", "/mar(ch)?/": "三月", "/apr(il)?/": "四月", "/may/": "五月", "/jun(e)?/": "六月", "/jul(y)?/": "七月", "/aug(ust)?/": "八月", "/sep(t(ember)?)?/": "九月", "/oct(ober)?/": "十月", "/nov(ember)?/": "十一月", "/dec(ember)?/": "十二月", "/^su(n(day)?)?/": "^星期日", "/^mo(n(day)?)?/": "^星期一", "/^tu(e(s(day)?)?)?/": "^星期二", "/^we(d(nesday)?)?/": "^星期三", "/^th(u(r(s(day)?)?)?)?/": "^星期四", "/^fr(i(day)?)?/": "^星期五", "/^sa(t(urday)?)?/": "^星期六", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "zh-TW"; ================================================ FILE: build/i18n/zu-ZA.js ================================================ /* * DateJS Culture String File * Country Code: zu-ZA * Name: Zulu (South Africa) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["zu-ZA"] = { "name": "zu-ZA", "englishName": "Zulu (South Africa)", "nativeName": "isiZulu (iNingizimu Afrika)", "Sunday": "iSonto", "Monday": "uMsombuluko", "Tuesday": "uLwesibili", "Wednesday": "uLwesithathu", "Thursday": "uLwesine", "Friday": "uLwesihlanu", "Saturday": "uMgqibelo", "Sun": "Sun", "Mon": "Mon", "Tue": "Tue", "Wed": "Wed", "Thu": "Thu", "Fri": "Fri", "Sat": "Sat", "Su": "Sun", "Mo": "Mon", "Tu": "Tue", "We": "Wed", "Th": "Thu", "Fr": "Fri", "Sa": "Sat", "S_Sun_Initial": "S", "M_Mon_Initial": "M", "T_Tue_Initial": "T", "W_Wed_Initial": "W", "T_Thu_Initial": "T", "F_Fri_Initial": "F", "S_Sat_Initial": "S", "January": "uJanuwari", "February": "uFebuwari", "March": "uMashi", "April": "uAprhili", "May": "uMeyi", "June": "uJuni", "July": "uJulayi", "August": "uAgaste", "September": "uSepthemba", "October": "uOkthoba", "November": "uNovemba", "December": "uDisemba", "Jan_Abbr": "Jan", "Feb_Abbr": "Feb", "Mar_Abbr": "Mar", "Apr_Abbr": "Apr", "May_Abbr": "May", "Jun_Abbr": "Jun", "Jul_Abbr": "Jul", "Aug_Abbr": "Aug", "Sep_Abbr": "Sep", "Oct_Abbr": "Oct", "Nov_Abbr": "Nov", "Dec_Abbr": "Dec", "AM": "AM", "PM": "PM", "firstDayOfWeek": 0, "twoDigitYearMax": 2029, "mdy": "ymd", "M/d/yyyy": "yyyy/MM/dd", "dddd, MMMM dd, yyyy": "dd MMMM yyyy", "h:mm tt": "hh:mm:ss tt", "h:mm:ss tt": "hh:mm:ss tt", "dddd, MMMM dd, yyyy h:mm:ss tt": "dd MMMM yyyy hh:mm:ss tt", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "MMMM dd", "MMMM, yyyy": "MMMM yyyy", "/jan(uary)?/": "ujanuwari", "/feb(ruary)?/": "ufebuwari", "/mar(ch)?/": "umashi", "/apr(il)?/": "uaprhili", "/may/": "umeyi", "/jun(e)?/": "ujuni", "/jul(y)?/": "ujulayi", "/aug(ust)?/": "uagaste", "/sep(t(ember)?)?/": "usepthemba", "/oct(ober)?/": "uokthoba", "/nov(ember)?/": "unovemba", "/dec(ember)?/": "udisemba", "/^su(n(day)?)?/": "^isonto", "/^mo(n(day)?)?/": "^umsombuluko", "/^tu(e(s(day)?)?)?/": "^ulwesibili", "/^we(d(nesday)?)?/": "^ulwesithathu", "/^th(u(r(s(day)?)?)?)?/": "^ulwesine", "/^fr(i(day)?)?/": "^ulwesihlanu", "/^sa(t(urday)?)?/": "^umgqibelo", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "zu-ZA"; ================================================ FILE: build/production/i18n/af-ZA.js ================================================ /* * DateJS Culture String File * Country Code: af-ZA * Name: Afrikaans (South Africa) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["af-ZA"] = { "name": "af-ZA", "englishName": "Afrikaans (South Africa)", "nativeName": "Afrikaans (Suid Afrika)", "Sunday": "Sondag", "Monday": "Maandag", "Tuesday": "Dinsdag", "Wednesday": "Woensdag", "Thursday": "Donderdag", "Friday": "Vrydag", "Saturday": "Saterdag", "Sun": "Son", "Mon": "Maan", "Tue": "Dins", "Wed": "Woen", "Thu": "Dond", "Fri": "Vry", "Sat": "Sat", "Su": "So", "Mo": "Ma", "Tu": "Di", "We": "Wo", "Th": "Do", "Fr": "Vr", "Sa": "Sa", "S_Sun_Initial": "S", "M_Mon_Initial": "M", "T_Tue_Initial": "D", "W_Wed_Initial": "W", "T_Thu_Initial": "D", "F_Fri_Initial": "V", "S_Sat_Initial": "S", "January": "Januarie", "February": "Februarie", "March": "Maart", "April": "April", "May": "Mei", "June": "Junie", "July": "Julie", "August": "Augustus", "September": "September", "October": "Oktober", "November": "November", "December": "Desember", "Jan_Abbr": "Jan", "Feb_Abbr": "Feb", "Mar_Abbr": "Mar", "Apr_Abbr": "Apr", "May_Abbr": "Mei", "Jun_Abbr": "Jun", "Jul_Abbr": "Jul", "Aug_Abbr": "Aug", "Sep_Abbr": "Sep", "Oct_Abbr": "Okt", "Nov_Abbr": "Nov", "Dec_Abbr": "Des", "AM": "", "PM": "nm", "firstDayOfWeek": 0, "twoDigitYearMax": 2029, "mdy": "ymd", "M/d/yyyy": "yyyy/MM/dd", "dddd, MMMM dd, yyyy": "dd MMMM yyyy", "h:mm tt": "hh:mm tt", "h:mm:ss tt": "hh:mm:ss tt", "dddd, MMMM dd, yyyy h:mm:ss tt": "dd MMMM yyyy hh:mm:ss tt", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "dd MMMM", "MMMM, yyyy": "MMMM yyyy", "/jan(uary)?/": "jan(uarie)?", "/feb(ruary)?/": "feb(ruarie)?", "/mar(ch)?/": "maart", "/apr(il)?/": "apr(il)?", "/may/": "mei", "/jun(e)?/": "jun(ie)?", "/jul(y)?/": "jul(ie)?", "/aug(ust)?/": "aug(ustus)?", "/sep(t(ember)?)?/": "sep(t(ember)?)?", "/oct(ober)?/": "okt(ober)?", "/nov(ember)?/": "nov(ember)?", "/dec(ember)?/": "des(ember)?", "/^su(n(day)?)?/": "^so(n(dag)?)?", "/^mo(n(day)?)?/": "^ma(an(dag)?)?", "/^tu(e(s(day)?)?)?/": "^di(ns(dag)?)?", "/^we(d(nesday)?)?/": "^wo(en(sdag)?)?", "/^th(u(r(s(day)?)?)?)?/": "^do(nd(erdag)?)?", "/^fr(i(day)?)?/": "^vr(y(dag)?)?", "/^sa(t(urday)?)?/": "^sa(t(erdag)?)?", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "af-ZA"; ================================================ FILE: build/production/i18n/ar-AE.js ================================================ /* * DateJS Culture String File * Country Code: ar-AE * Name: Arabic (U.A.E.) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["ar-AE"] = { "name": "ar-AE", "englishName": "Arabic (U.A.E.)", "nativeName": "العربية (الإمارات العربية المتحدة)", "Sunday": "الاحد", "Monday": "الاثنين", "Tuesday": "الثلاثاء", "Wednesday": "الاربعاء", "Thursday": "الخميس", "Friday": "الجمعة", "Saturday": "السبت", "Sun": "الاحد", "Mon": "الاثنين", "Tue": "الثلاثاء", "Wed": "الاربعاء", "Thu": "الخميس", "Fri": "الجمعة", "Sat": "السبت", "Su": "أ", "Mo": "ا", "Tu": "ث", "We": "أ", "Th": "خ", "Fr": "ج", "Sa": "س", "S_Sun_Initial": "أ", "M_Mon_Initial": "ا", "T_Tue_Initial": "ث", "W_Wed_Initial": "أ", "T_Thu_Initial": "خ", "F_Fri_Initial": "ج", "S_Sat_Initial": "س", "January": "يناير", "February": "فبراير", "March": "مارس", "April": "ابريل", "May": "مايو", "June": "يونيو", "July": "يوليو", "August": "اغسطس", "September": "سبتمبر", "October": "اكتوبر", "November": "نوفمبر", "December": "ديسمبر", "Jan_Abbr": "يناير", "Feb_Abbr": "فبراير", "Mar_Abbr": "مارس", "Apr_Abbr": "ابريل", "May_Abbr": "مايو", "Jun_Abbr": "يونيو", "Jul_Abbr": "يوليو", "Aug_Abbr": "اغسطس", "Sep_Abbr": "سبتمبر", "Oct_Abbr": "اكتوبر", "Nov_Abbr": "نوفمبر", "Dec_Abbr": "ديسمبر", "AM": "ص", "PM": "م", "firstDayOfWeek": 6, "twoDigitYearMax": 2029, "mdy": "dmy", "M/d/yyyy": "dd/MM/yyyy", "dddd, MMMM dd, yyyy": "dd MMMM, yyyy", "h:mm tt": "hh:mm tt", "h:mm:ss tt": "hh:mm:ss tt", "dddd, MMMM dd, yyyy h:mm:ss tt": "dd MMMM, yyyy hh:mm:ss tt", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "dd MMMM", "MMMM, yyyy": "MMMM, yyyy", "/jan(uary)?/": "يناير", "/feb(ruary)?/": "فبراير", "/mar(ch)?/": "مارس", "/apr(il)?/": "ابريل", "/may/": "مايو", "/jun(e)?/": "يونيو", "/jul(y)?/": "يوليو", "/aug(ust)?/": "اغسطس", "/sep(t(ember)?)?/": "سبتمبر", "/oct(ober)?/": "اكتوبر", "/nov(ember)?/": "نوفمبر", "/dec(ember)?/": "ديسمبر", "/^su(n(day)?)?/": "^الاحد", "/^mo(n(day)?)?/": "^ا(1)?", "/^tu(e(s(day)?)?)?/": "^الثلاثاء", "/^we(d(nesday)?)?/": "^الاربعاء", "/^th(u(r(s(day)?)?)?)?/": "^الخميس", "/^fr(i(day)?)?/": "^الجمعة", "/^sa(t(urday)?)?/": "^السبت", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "ar-AE"; ================================================ FILE: build/production/i18n/ar-BH.js ================================================ /* * DateJS Culture String File * Country Code: ar-BH * Name: Arabic (Bahrain) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["ar-BH"] = { "name": "ar-BH", "englishName": "Arabic (Bahrain)", "nativeName": "العربية (البحرين)", "Sunday": "الاحد", "Monday": "الاثنين", "Tuesday": "الثلاثاء", "Wednesday": "الاربعاء", "Thursday": "الخميس", "Friday": "الجمعة", "Saturday": "السبت", "Sun": "الاحد", "Mon": "الاثنين", "Tue": "الثلاثاء", "Wed": "الاربعاء", "Thu": "الخميس", "Fri": "الجمعة", "Sat": "السبت", "Su": "أ", "Mo": "ا", "Tu": "ث", "We": "أ", "Th": "خ", "Fr": "ج", "Sa": "س", "S_Sun_Initial": "أ", "M_Mon_Initial": "ا", "T_Tue_Initial": "ث", "W_Wed_Initial": "أ", "T_Thu_Initial": "خ", "F_Fri_Initial": "ج", "S_Sat_Initial": "س", "January": "يناير", "February": "فبراير", "March": "مارس", "April": "ابريل", "May": "مايو", "June": "يونيو", "July": "يوليو", "August": "اغسطس", "September": "سبتمبر", "October": "اكتوبر", "November": "نوفمبر", "December": "ديسمبر", "Jan_Abbr": "يناير", "Feb_Abbr": "فبراير", "Mar_Abbr": "مارس", "Apr_Abbr": "ابريل", "May_Abbr": "مايو", "Jun_Abbr": "يونيو", "Jul_Abbr": "يوليو", "Aug_Abbr": "اغسطس", "Sep_Abbr": "سبتمبر", "Oct_Abbr": "اكتوبر", "Nov_Abbr": "نوفمبر", "Dec_Abbr": "ديسمبر", "AM": "ص", "PM": "م", "firstDayOfWeek": 6, "twoDigitYearMax": 2029, "mdy": "dmy", "M/d/yyyy": "dd/MM/yyyy", "dddd, MMMM dd, yyyy": "dd MMMM, yyyy", "h:mm tt": "hh:mm tt", "h:mm:ss tt": "hh:mm:ss tt", "dddd, MMMM dd, yyyy h:mm:ss tt": "dd MMMM, yyyy hh:mm:ss tt", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "dd MMMM", "MMMM, yyyy": "MMMM, yyyy", "/jan(uary)?/": "يناير", "/feb(ruary)?/": "فبراير", "/mar(ch)?/": "مارس", "/apr(il)?/": "ابريل", "/may/": "مايو", "/jun(e)?/": "يونيو", "/jul(y)?/": "يوليو", "/aug(ust)?/": "اغسطس", "/sep(t(ember)?)?/": "سبتمبر", "/oct(ober)?/": "اكتوبر", "/nov(ember)?/": "نوفمبر", "/dec(ember)?/": "ديسمبر", "/^su(n(day)?)?/": "^الاحد", "/^mo(n(day)?)?/": "^ا(1)?", "/^tu(e(s(day)?)?)?/": "^الثلاثاء", "/^we(d(nesday)?)?/": "^الاربعاء", "/^th(u(r(s(day)?)?)?)?/": "^الخميس", "/^fr(i(day)?)?/": "^الجمعة", "/^sa(t(urday)?)?/": "^السبت", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "ar-BH"; ================================================ FILE: build/production/i18n/ar-DZ.js ================================================ /* * DateJS Culture String File * Country Code: ar-DZ * Name: Arabic (Algeria) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["ar-DZ"] = { "name": "ar-DZ", "englishName": "Arabic (Algeria)", "nativeName": "العربية (الجزائر)", "Sunday": "الاحد", "Monday": "الاثنين", "Tuesday": "الثلاثاء", "Wednesday": "الاربعاء", "Thursday": "الخميس", "Friday": "الجمعة", "Saturday": "السبت", "Sun": "الاحد", "Mon": "الاثنين", "Tue": "الثلاثاء", "Wed": "الاربعاء", "Thu": "الخميس", "Fri": "الجمعة", "Sat": "السبت", "Su": "أ", "Mo": "ا", "Tu": "ث", "We": "أ", "Th": "خ", "Fr": "ج", "Sa": "س", "S_Sun_Initial": "أ", "M_Mon_Initial": "ا", "T_Tue_Initial": "ث", "W_Wed_Initial": "أ", "T_Thu_Initial": "خ", "F_Fri_Initial": "ج", "S_Sat_Initial": "س", "January": "جانفييه", "February": "فيفرييه", "March": "مارس", "April": "أفريل", "May": "مي", "June": "جوان", "July": "جوييه", "August": "أوت", "September": "سبتمبر", "October": "اكتوبر", "November": "نوفمبر", "December": "ديسمبر", "Jan_Abbr": "جانفييه", "Feb_Abbr": "فيفرييه", "Mar_Abbr": "مارس", "Apr_Abbr": "أفريل", "May_Abbr": "مي", "Jun_Abbr": "جوان", "Jul_Abbr": "جوييه", "Aug_Abbr": "أوت", "Sep_Abbr": "سبتمبر", "Oct_Abbr": "اكتوبر", "Nov_Abbr": "نوفمبر", "Dec_Abbr": "ديسمبر", "AM": "ص", "PM": "م", "firstDayOfWeek": 6, "twoDigitYearMax": 2029, "mdy": "dmy", "M/d/yyyy": "dd-MM-yyyy", "dddd, MMMM dd, yyyy": "dd MMMM, yyyy", "h:mm tt": "H:mm", "h:mm:ss tt": "H:mm:ss", "dddd, MMMM dd, yyyy h:mm:ss tt": "dd MMMM, yyyy H:mm:ss", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "dd MMMM", "MMMM, yyyy": "MMMM, yyyy", "/jan(uary)?/": "جانفييه", "/feb(ruary)?/": "فيفرييه", "/mar(ch)?/": "مارس", "/apr(il)?/": "أفريل", "/may/": "مي", "/jun(e)?/": "جوان", "/jul(y)?/": "جوييه", "/aug(ust)?/": "أوت", "/sep(t(ember)?)?/": "سبتمبر", "/oct(ober)?/": "اكتوبر", "/nov(ember)?/": "نوفمبر", "/dec(ember)?/": "ديسمبر", "/^su(n(day)?)?/": "^الاحد", "/^mo(n(day)?)?/": "^ا(1)?", "/^tu(e(s(day)?)?)?/": "^الثلاثاء", "/^we(d(nesday)?)?/": "^الاربعاء", "/^th(u(r(s(day)?)?)?)?/": "^الخميس", "/^fr(i(day)?)?/": "^الجمعة", "/^sa(t(urday)?)?/": "^السبت", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "ar-DZ"; ================================================ FILE: build/production/i18n/ar-EG.js ================================================ /* * DateJS Culture String File * Country Code: ar-EG * Name: Arabic (Egypt) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["ar-EG"] = { "name": "ar-EG", "englishName": "Arabic (Egypt)", "nativeName": "العربية (مصر)", "Sunday": "الاحد", "Monday": "الاثنين", "Tuesday": "الثلاثاء", "Wednesday": "الاربعاء", "Thursday": "الخميس", "Friday": "الجمعة", "Saturday": "السبت", "Sun": "الاحد", "Mon": "الاثنين", "Tue": "الثلاثاء", "Wed": "الاربعاء", "Thu": "الخميس", "Fri": "الجمعة", "Sat": "السبت", "Su": "أ", "Mo": "ا", "Tu": "ث", "We": "أ", "Th": "خ", "Fr": "ج", "Sa": "س", "S_Sun_Initial": "أ", "M_Mon_Initial": "ا", "T_Tue_Initial": "ث", "W_Wed_Initial": "أ", "T_Thu_Initial": "خ", "F_Fri_Initial": "ج", "S_Sat_Initial": "س", "January": "يناير", "February": "فبراير", "March": "مارس", "April": "ابريل", "May": "مايو", "June": "يونيو", "July": "يوليو", "August": "اغسطس", "September": "سبتمبر", "October": "اكتوبر", "November": "نوفمبر", "December": "ديسمبر", "Jan_Abbr": "يناير", "Feb_Abbr": "فبراير", "Mar_Abbr": "مارس", "Apr_Abbr": "ابريل", "May_Abbr": "مايو", "Jun_Abbr": "يونيو", "Jul_Abbr": "يوليو", "Aug_Abbr": "اغسطس", "Sep_Abbr": "سبتمبر", "Oct_Abbr": "اكتوبر", "Nov_Abbr": "نوفمبر", "Dec_Abbr": "ديسمبر", "AM": "ص", "PM": "م", "firstDayOfWeek": 6, "twoDigitYearMax": 2029, "mdy": "dmy", "M/d/yyyy": "dd/MM/yyyy", "dddd, MMMM dd, yyyy": "dd MMMM, yyyy", "h:mm tt": "hh:mm tt", "h:mm:ss tt": "hh:mm:ss tt", "dddd, MMMM dd, yyyy h:mm:ss tt": "dd MMMM, yyyy hh:mm:ss tt", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "dd MMMM", "MMMM, yyyy": "MMMM, yyyy", "/jan(uary)?/": "يناير", "/feb(ruary)?/": "فبراير", "/mar(ch)?/": "مارس", "/apr(il)?/": "ابريل", "/may/": "مايو", "/jun(e)?/": "يونيو", "/jul(y)?/": "يوليو", "/aug(ust)?/": "اغسطس", "/sep(t(ember)?)?/": "سبتمبر", "/oct(ober)?/": "اكتوبر", "/nov(ember)?/": "نوفمبر", "/dec(ember)?/": "ديسمبر", "/^su(n(day)?)?/": "^الاحد", "/^mo(n(day)?)?/": "^ا(1)?", "/^tu(e(s(day)?)?)?/": "^الثلاثاء", "/^we(d(nesday)?)?/": "^الاربعاء", "/^th(u(r(s(day)?)?)?)?/": "^الخميس", "/^fr(i(day)?)?/": "^الجمعة", "/^sa(t(urday)?)?/": "^السبت", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "ar-EG"; ================================================ FILE: build/production/i18n/ar-IQ.js ================================================ /* * DateJS Culture String File * Country Code: ar-IQ * Name: Arabic (Iraq) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["ar-IQ"] = { "name": "ar-IQ", "englishName": "Arabic (Iraq)", "nativeName": "العربية (العراق)", "Sunday": "الاحد", "Monday": "الاثنين", "Tuesday": "الثلاثاء", "Wednesday": "الاربعاء", "Thursday": "الخميس", "Friday": "الجمعة", "Saturday": "السبت", "Sun": "الاحد", "Mon": "الاثنين", "Tue": "الثلاثاء", "Wed": "الاربعاء", "Thu": "الخميس", "Fri": "الجمعة", "Sat": "السبت", "Su": "أ", "Mo": "ا", "Tu": "ث", "We": "أ", "Th": "خ", "Fr": "ج", "Sa": "س", "S_Sun_Initial": "أ", "M_Mon_Initial": "ا", "T_Tue_Initial": "ث", "W_Wed_Initial": "أ", "T_Thu_Initial": "خ", "F_Fri_Initial": "ج", "S_Sat_Initial": "س", "January": "كانون الثاني", "February": "شباط", "March": "آذار", "April": "نيسان", "May": "أيار", "June": "حزيران", "July": "تموز", "August": "آب", "September": "أيلول", "October": "تشرين الأول", "November": "تشرين الثاني", "December": "كانون الأول", "Jan_Abbr": "كانون الثاني", "Feb_Abbr": "شباط", "Mar_Abbr": "آذار", "Apr_Abbr": "نيسان", "May_Abbr": "أيار", "Jun_Abbr": "حزيران", "Jul_Abbr": "تموز", "Aug_Abbr": "آب", "Sep_Abbr": "أيلول", "Oct_Abbr": "تشرين الأول", "Nov_Abbr": "تشرين الثاني", "Dec_Abbr": "كانون الأول", "AM": "ص", "PM": "م", "firstDayOfWeek": 6, "twoDigitYearMax": 2029, "mdy": "dmy", "M/d/yyyy": "dd/MM/yyyy", "dddd, MMMM dd, yyyy": "dd MMMM, yyyy", "h:mm tt": "hh:mm tt", "h:mm:ss tt": "hh:mm:ss tt", "dddd, MMMM dd, yyyy h:mm:ss tt": "dd MMMM, yyyy hh:mm:ss tt", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "dd MMMM", "MMMM, yyyy": "MMMM, yyyy", "/jan(uary)?/": "كانون الثاني", "/feb(ruary)?/": "شباط", "/mar(ch)?/": "آذار", "/apr(il)?/": "نيسان", "/may/": "أيار", "/jun(e)?/": "حزيران", "/jul(y)?/": "تموز", "/aug(ust)?/": "آب", "/sep(t(ember)?)?/": "أيلول", "/oct(ober)?/": "تشرين الأول", "/nov(ember)?/": "تشرين الثاني", "/dec(ember)?/": "كانون الأول", "/^su(n(day)?)?/": "^الاحد", "/^mo(n(day)?)?/": "^ا(1)?", "/^tu(e(s(day)?)?)?/": "^الثلاثاء", "/^we(d(nesday)?)?/": "^الاربعاء", "/^th(u(r(s(day)?)?)?)?/": "^الخميس", "/^fr(i(day)?)?/": "^الجمعة", "/^sa(t(urday)?)?/": "^السبت", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "ar-IQ"; ================================================ FILE: build/production/i18n/ar-JO.js ================================================ /* * DateJS Culture String File * Country Code: ar-JO * Name: Arabic (Jordan) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["ar-JO"] = { "name": "ar-JO", "englishName": "Arabic (Jordan)", "nativeName": "العربية (الأردن)", "Sunday": "الاحد", "Monday": "الاثنين", "Tuesday": "الثلاثاء", "Wednesday": "الاربعاء", "Thursday": "الخميس", "Friday": "الجمعة", "Saturday": "السبت", "Sun": "الاحد", "Mon": "الاثنين", "Tue": "الثلاثاء", "Wed": "الاربعاء", "Thu": "الخميس", "Fri": "الجمعة", "Sat": "السبت", "Su": "أ", "Mo": "ا", "Tu": "ث", "We": "أ", "Th": "خ", "Fr": "ج", "Sa": "س", "S_Sun_Initial": "أ", "M_Mon_Initial": "ا", "T_Tue_Initial": "ث", "W_Wed_Initial": "أ", "T_Thu_Initial": "خ", "F_Fri_Initial": "ج", "S_Sat_Initial": "س", "January": "كانون الثاني", "February": "شباط", "March": "آذار", "April": "نيسان", "May": "أيار", "June": "حزيران", "July": "تموز", "August": "آب", "September": "أيلول", "October": "تشرين الأول", "November": "تشرين الثاني", "December": "كانون الأول", "Jan_Abbr": "كانون الثاني", "Feb_Abbr": "شباط", "Mar_Abbr": "آذار", "Apr_Abbr": "نيسان", "May_Abbr": "أيار", "Jun_Abbr": "حزيران", "Jul_Abbr": "تموز", "Aug_Abbr": "آب", "Sep_Abbr": "أيلول", "Oct_Abbr": "تشرين الأول", "Nov_Abbr": "تشرين الثاني", "Dec_Abbr": "كانون الأول", "AM": "ص", "PM": "م", "firstDayOfWeek": 6, "twoDigitYearMax": 2029, "mdy": "dmy", "M/d/yyyy": "dd/MM/yyyy", "dddd, MMMM dd, yyyy": "dd MMMM, yyyy", "h:mm tt": "hh:mm tt", "h:mm:ss tt": "hh:mm:ss tt", "dddd, MMMM dd, yyyy h:mm:ss tt": "dd MMMM, yyyy hh:mm:ss tt", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "dd MMMM", "MMMM, yyyy": "MMMM, yyyy", "/jan(uary)?/": "كانون الثاني", "/feb(ruary)?/": "شباط", "/mar(ch)?/": "آذار", "/apr(il)?/": "نيسان", "/may/": "أيار", "/jun(e)?/": "حزيران", "/jul(y)?/": "تموز", "/aug(ust)?/": "آب", "/sep(t(ember)?)?/": "أيلول", "/oct(ober)?/": "تشرين الأول", "/nov(ember)?/": "تشرين الثاني", "/dec(ember)?/": "كانون الأول", "/^su(n(day)?)?/": "^الاحد", "/^mo(n(day)?)?/": "^ا(1)?", "/^tu(e(s(day)?)?)?/": "^الثلاثاء", "/^we(d(nesday)?)?/": "^الاربعاء", "/^th(u(r(s(day)?)?)?)?/": "^الخميس", "/^fr(i(day)?)?/": "^الجمعة", "/^sa(t(urday)?)?/": "^السبت", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "ar-JO"; ================================================ FILE: build/production/i18n/ar-KW.js ================================================ /* * DateJS Culture String File * Country Code: ar-KW * Name: Arabic (Kuwait) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["ar-KW"] = { "name": "ar-KW", "englishName": "Arabic (Kuwait)", "nativeName": "العربية (الكويت)", "Sunday": "الاحد", "Monday": "الاثنين", "Tuesday": "الثلاثاء", "Wednesday": "الاربعاء", "Thursday": "الخميس", "Friday": "الجمعة", "Saturday": "السبت", "Sun": "الاحد", "Mon": "الاثنين", "Tue": "الثلاثاء", "Wed": "الاربعاء", "Thu": "الخميس", "Fri": "الجمعة", "Sat": "السبت", "Su": "أ", "Mo": "ا", "Tu": "ث", "We": "أ", "Th": "خ", "Fr": "ج", "Sa": "س", "S_Sun_Initial": "أ", "M_Mon_Initial": "ا", "T_Tue_Initial": "ث", "W_Wed_Initial": "أ", "T_Thu_Initial": "خ", "F_Fri_Initial": "ج", "S_Sat_Initial": "س", "January": "يناير", "February": "فبراير", "March": "مارس", "April": "ابريل", "May": "مايو", "June": "يونيو", "July": "يوليو", "August": "اغسطس", "September": "سبتمبر", "October": "اكتوبر", "November": "نوفمبر", "December": "ديسمبر", "Jan_Abbr": "يناير", "Feb_Abbr": "فبراير", "Mar_Abbr": "مارس", "Apr_Abbr": "ابريل", "May_Abbr": "مايو", "Jun_Abbr": "يونيو", "Jul_Abbr": "يوليو", "Aug_Abbr": "اغسطس", "Sep_Abbr": "سبتمبر", "Oct_Abbr": "اكتوبر", "Nov_Abbr": "نوفمبر", "Dec_Abbr": "ديسمبر", "AM": "ص", "PM": "م", "firstDayOfWeek": 6, "twoDigitYearMax": 2029, "mdy": "dmy", "M/d/yyyy": "dd/MM/yyyy", "dddd, MMMM dd, yyyy": "dd MMMM, yyyy", "h:mm tt": "hh:mm tt", "h:mm:ss tt": "hh:mm:ss tt", "dddd, MMMM dd, yyyy h:mm:ss tt": "dd MMMM, yyyy hh:mm:ss tt", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "dd MMMM", "MMMM, yyyy": "MMMM, yyyy", "/jan(uary)?/": "يناير", "/feb(ruary)?/": "فبراير", "/mar(ch)?/": "مارس", "/apr(il)?/": "ابريل", "/may/": "مايو", "/jun(e)?/": "يونيو", "/jul(y)?/": "يوليو", "/aug(ust)?/": "اغسطس", "/sep(t(ember)?)?/": "سبتمبر", "/oct(ober)?/": "اكتوبر", "/nov(ember)?/": "نوفمبر", "/dec(ember)?/": "ديسمبر", "/^su(n(day)?)?/": "^الاحد", "/^mo(n(day)?)?/": "^ا(1)?", "/^tu(e(s(day)?)?)?/": "^الثلاثاء", "/^we(d(nesday)?)?/": "^الاربعاء", "/^th(u(r(s(day)?)?)?)?/": "^الخميس", "/^fr(i(day)?)?/": "^الجمعة", "/^sa(t(urday)?)?/": "^السبت", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "ar-KW"; ================================================ FILE: build/production/i18n/ar-LB.js ================================================ /* * DateJS Culture String File * Country Code: ar-LB * Name: Arabic (Lebanon) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["ar-LB"] = { "name": "ar-LB", "englishName": "Arabic (Lebanon)", "nativeName": "العربية (لبنان)", "Sunday": "الاحد", "Monday": "الاثنين", "Tuesday": "الثلاثاء", "Wednesday": "الاربعاء", "Thursday": "الخميس", "Friday": "الجمعة", "Saturday": "السبت", "Sun": "الاحد", "Mon": "الاثنين", "Tue": "الثلاثاء", "Wed": "الاربعاء", "Thu": "الخميس", "Fri": "الجمعة", "Sat": "السبت", "Su": "أ", "Mo": "ا", "Tu": "ث", "We": "أ", "Th": "خ", "Fr": "ج", "Sa": "س", "S_Sun_Initial": "أ", "M_Mon_Initial": "ا", "T_Tue_Initial": "ث", "W_Wed_Initial": "أ", "T_Thu_Initial": "خ", "F_Fri_Initial": "ج", "S_Sat_Initial": "س", "January": "كانون الثاني", "February": "شباط", "March": "آذار", "April": "نيسان", "May": "أيار", "June": "حزيران", "July": "تموز", "August": "آب", "September": "أيلول", "October": "تشرين الأول", "November": "تشرين الثاني", "December": "كانون الأول", "Jan_Abbr": "كانون الثاني", "Feb_Abbr": "شباط", "Mar_Abbr": "آذار", "Apr_Abbr": "نيسان", "May_Abbr": "أيار", "Jun_Abbr": "حزيران", "Jul_Abbr": "تموز", "Aug_Abbr": "آب", "Sep_Abbr": "أيلول", "Oct_Abbr": "تشرين الأول", "Nov_Abbr": "تشرين الثاني", "Dec_Abbr": "كانون الأول", "AM": "ص", "PM": "م", "firstDayOfWeek": 1, "twoDigitYearMax": 2029, "mdy": "dmy", "M/d/yyyy": "dd/MM/yyyy", "dddd, MMMM dd, yyyy": "dd MMMM, yyyy", "h:mm tt": "hh:mm tt", "h:mm:ss tt": "hh:mm:ss tt", "dddd, MMMM dd, yyyy h:mm:ss tt": "dd MMMM, yyyy hh:mm:ss tt", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "dd MMMM", "MMMM, yyyy": "MMMM, yyyy", "/jan(uary)?/": "كانون الثاني", "/feb(ruary)?/": "شباط", "/mar(ch)?/": "آذار", "/apr(il)?/": "نيسان", "/may/": "أيار", "/jun(e)?/": "حزيران", "/jul(y)?/": "تموز", "/aug(ust)?/": "آب", "/sep(t(ember)?)?/": "أيلول", "/oct(ober)?/": "تشرين الأول", "/nov(ember)?/": "تشرين الثاني", "/dec(ember)?/": "كانون الأول", "/^su(n(day)?)?/": "^الاحد", "/^mo(n(day)?)?/": "^ا(1)?", "/^tu(e(s(day)?)?)?/": "^الثلاثاء", "/^we(d(nesday)?)?/": "^الاربعاء", "/^th(u(r(s(day)?)?)?)?/": "^الخميس", "/^fr(i(day)?)?/": "^الجمعة", "/^sa(t(urday)?)?/": "^السبت", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "ar-LB"; ================================================ FILE: build/production/i18n/ar-LY.js ================================================ /* * DateJS Culture String File * Country Code: ar-LY * Name: Arabic (Libya) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["ar-LY"] = { "name": "ar-LY", "englishName": "Arabic (Libya)", "nativeName": "العربية (ليبيا)", "Sunday": "الاحد", "Monday": "الاثنين", "Tuesday": "الثلاثاء", "Wednesday": "الاربعاء", "Thursday": "الخميس", "Friday": "الجمعة", "Saturday": "السبت", "Sun": "الاحد", "Mon": "الاثنين", "Tue": "الثلاثاء", "Wed": "الاربعاء", "Thu": "الخميس", "Fri": "الجمعة", "Sat": "السبت", "Su": "أ", "Mo": "ا", "Tu": "ث", "We": "أ", "Th": "خ", "Fr": "ج", "Sa": "س", "S_Sun_Initial": "أ", "M_Mon_Initial": "ا", "T_Tue_Initial": "ث", "W_Wed_Initial": "أ", "T_Thu_Initial": "خ", "F_Fri_Initial": "ج", "S_Sat_Initial": "س", "January": "يناير", "February": "فبراير", "March": "مارس", "April": "ابريل", "May": "مايو", "June": "يونيو", "July": "يوليو", "August": "اغسطس", "September": "سبتمبر", "October": "اكتوبر", "November": "نوفمبر", "December": "ديسمبر", "Jan_Abbr": "يناير", "Feb_Abbr": "فبراير", "Mar_Abbr": "مارس", "Apr_Abbr": "ابريل", "May_Abbr": "مايو", "Jun_Abbr": "يونيو", "Jul_Abbr": "يوليو", "Aug_Abbr": "اغسطس", "Sep_Abbr": "سبتمبر", "Oct_Abbr": "اكتوبر", "Nov_Abbr": "نوفمبر", "Dec_Abbr": "ديسمبر", "AM": "ص", "PM": "م", "firstDayOfWeek": 6, "twoDigitYearMax": 2029, "mdy": "dmy", "M/d/yyyy": "dd/MM/yyyy", "dddd, MMMM dd, yyyy": "dd MMMM, yyyy", "h:mm tt": "hh:mm tt", "h:mm:ss tt": "hh:mm:ss tt", "dddd, MMMM dd, yyyy h:mm:ss tt": "dd MMMM, yyyy hh:mm:ss tt", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "dd MMMM", "MMMM, yyyy": "MMMM, yyyy", "/jan(uary)?/": "يناير", "/feb(ruary)?/": "فبراير", "/mar(ch)?/": "مارس", "/apr(il)?/": "ابريل", "/may/": "مايو", "/jun(e)?/": "يونيو", "/jul(y)?/": "يوليو", "/aug(ust)?/": "اغسطس", "/sep(t(ember)?)?/": "سبتمبر", "/oct(ober)?/": "اكتوبر", "/nov(ember)?/": "نوفمبر", "/dec(ember)?/": "ديسمبر", "/^su(n(day)?)?/": "^الاحد", "/^mo(n(day)?)?/": "^ا(1)?", "/^tu(e(s(day)?)?)?/": "^الثلاثاء", "/^we(d(nesday)?)?/": "^الاربعاء", "/^th(u(r(s(day)?)?)?)?/": "^الخميس", "/^fr(i(day)?)?/": "^الجمعة", "/^sa(t(urday)?)?/": "^السبت", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "ar-LY"; ================================================ FILE: build/production/i18n/ar-MA.js ================================================ /* * DateJS Culture String File * Country Code: ar-MA * Name: Arabic (Morocco) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["ar-MA"] = { "name": "ar-MA", "englishName": "Arabic (Morocco)", "nativeName": "العربية (المملكة المغربية)", "Sunday": "الاحد", "Monday": "الاثنين", "Tuesday": "الثلاثاء", "Wednesday": "الاربعاء", "Thursday": "الخميس", "Friday": "الجمعة", "Saturday": "السبت", "Sun": "الاحد", "Mon": "الاثنين", "Tue": "الثلاثاء", "Wed": "الاربعاء", "Thu": "الخميس", "Fri": "الجمعة", "Sat": "السبت", "Su": "أ", "Mo": "ا", "Tu": "ث", "We": "أ", "Th": "خ", "Fr": "ج", "Sa": "س", "S_Sun_Initial": "أ", "M_Mon_Initial": "ا", "T_Tue_Initial": "ث", "W_Wed_Initial": "أ", "T_Thu_Initial": "خ", "F_Fri_Initial": "ج", "S_Sat_Initial": "س", "January": "يناير", "February": "فبراير", "March": "مارس", "April": "ابريل", "May": "ماي", "June": "يونيو", "July": "يوليوز", "August": "غشت", "September": "شتنبر", "October": "اكتوبر", "November": "نونبر", "December": "دجنبر", "Jan_Abbr": "يناير", "Feb_Abbr": "فبراير", "Mar_Abbr": "مارس", "Apr_Abbr": "ابريل", "May_Abbr": "ماي", "Jun_Abbr": "يونيو", "Jul_Abbr": "يوليوز", "Aug_Abbr": "غشت", "Sep_Abbr": "شتنبر", "Oct_Abbr": "اكتوبر", "Nov_Abbr": "نونبر", "Dec_Abbr": "دجنبر", "AM": "ص", "PM": "م", "firstDayOfWeek": 1, "twoDigitYearMax": 2029, "mdy": "dmy", "M/d/yyyy": "dd-MM-yyyy", "dddd, MMMM dd, yyyy": "dd MMMM, yyyy", "h:mm tt": "H:mm", "h:mm:ss tt": "H:mm:ss", "dddd, MMMM dd, yyyy h:mm:ss tt": "dd MMMM, yyyy H:mm:ss", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "dd MMMM", "MMMM, yyyy": "MMMM, yyyy", "/jan(uary)?/": "يناير", "/feb(ruary)?/": "فبراير", "/mar(ch)?/": "مارس", "/apr(il)?/": "ابريل", "/may/": "ماي", "/jun(e)?/": "يونيو", "/jul(y)?/": "يوليوز", "/aug(ust)?/": "غشت", "/sep(t(ember)?)?/": "شتنبر", "/oct(ober)?/": "اكتوبر", "/nov(ember)?/": "نونبر", "/dec(ember)?/": "دجنبر", "/^su(n(day)?)?/": "^الاحد", "/^mo(n(day)?)?/": "^ا(1)?", "/^tu(e(s(day)?)?)?/": "^الثلاثاء", "/^we(d(nesday)?)?/": "^الاربعاء", "/^th(u(r(s(day)?)?)?)?/": "^الخميس", "/^fr(i(day)?)?/": "^الجمعة", "/^sa(t(urday)?)?/": "^السبت", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "ar-MA"; ================================================ FILE: build/production/i18n/ar-OM.js ================================================ /* * DateJS Culture String File * Country Code: ar-OM * Name: Arabic (Oman) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["ar-OM"] = { "name": "ar-OM", "englishName": "Arabic (Oman)", "nativeName": "العربية (عمان)", "Sunday": "الاحد", "Monday": "الاثنين", "Tuesday": "الثلاثاء", "Wednesday": "الاربعاء", "Thursday": "الخميس", "Friday": "الجمعة", "Saturday": "السبت", "Sun": "الاحد", "Mon": "الاثنين", "Tue": "الثلاثاء", "Wed": "الاربعاء", "Thu": "الخميس", "Fri": "الجمعة", "Sat": "السبت", "Su": "أ", "Mo": "ا", "Tu": "ث", "We": "أ", "Th": "خ", "Fr": "ج", "Sa": "س", "S_Sun_Initial": "أ", "M_Mon_Initial": "ا", "T_Tue_Initial": "ث", "W_Wed_Initial": "أ", "T_Thu_Initial": "خ", "F_Fri_Initial": "ج", "S_Sat_Initial": "س", "January": "يناير", "February": "فبراير", "March": "مارس", "April": "ابريل", "May": "مايو", "June": "يونيو", "July": "يوليو", "August": "اغسطس", "September": "سبتمبر", "October": "اكتوبر", "November": "نوفمبر", "December": "ديسمبر", "Jan_Abbr": "يناير", "Feb_Abbr": "فبراير", "Mar_Abbr": "مارس", "Apr_Abbr": "ابريل", "May_Abbr": "مايو", "Jun_Abbr": "يونيو", "Jul_Abbr": "يوليو", "Aug_Abbr": "اغسطس", "Sep_Abbr": "سبتمبر", "Oct_Abbr": "اكتوبر", "Nov_Abbr": "نوفمبر", "Dec_Abbr": "ديسمبر", "AM": "ص", "PM": "م", "firstDayOfWeek": 6, "twoDigitYearMax": 2029, "mdy": "dmy", "M/d/yyyy": "dd/MM/yyyy", "dddd, MMMM dd, yyyy": "dd MMMM, yyyy", "h:mm tt": "hh:mm tt", "h:mm:ss tt": "hh:mm:ss tt", "dddd, MMMM dd, yyyy h:mm:ss tt": "dd MMMM, yyyy hh:mm:ss tt", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "dd MMMM", "MMMM, yyyy": "MMMM, yyyy", "/jan(uary)?/": "يناير", "/feb(ruary)?/": "فبراير", "/mar(ch)?/": "مارس", "/apr(il)?/": "ابريل", "/may/": "مايو", "/jun(e)?/": "يونيو", "/jul(y)?/": "يوليو", "/aug(ust)?/": "اغسطس", "/sep(t(ember)?)?/": "سبتمبر", "/oct(ober)?/": "اكتوبر", "/nov(ember)?/": "نوفمبر", "/dec(ember)?/": "ديسمبر", "/^su(n(day)?)?/": "^الاحد", "/^mo(n(day)?)?/": "^ا(1)?", "/^tu(e(s(day)?)?)?/": "^الثلاثاء", "/^we(d(nesday)?)?/": "^الاربعاء", "/^th(u(r(s(day)?)?)?)?/": "^الخميس", "/^fr(i(day)?)?/": "^الجمعة", "/^sa(t(urday)?)?/": "^السبت", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "ar-OM"; ================================================ FILE: build/production/i18n/ar-QA.js ================================================ /* * DateJS Culture String File * Country Code: ar-QA * Name: Arabic (Qatar) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["ar-QA"] = { "name": "ar-QA", "englishName": "Arabic (Qatar)", "nativeName": "العربية (قطر)", "Sunday": "الاحد", "Monday": "الاثنين", "Tuesday": "الثلاثاء", "Wednesday": "الاربعاء", "Thursday": "الخميس", "Friday": "الجمعة", "Saturday": "السبت", "Sun": "الاحد", "Mon": "الاثنين", "Tue": "الثلاثاء", "Wed": "الاربعاء", "Thu": "الخميس", "Fri": "الجمعة", "Sat": "السبت", "Su": "أ", "Mo": "ا", "Tu": "ث", "We": "أ", "Th": "خ", "Fr": "ج", "Sa": "س", "S_Sun_Initial": "أ", "M_Mon_Initial": "ا", "T_Tue_Initial": "ث", "W_Wed_Initial": "أ", "T_Thu_Initial": "خ", "F_Fri_Initial": "ج", "S_Sat_Initial": "س", "January": "يناير", "February": "فبراير", "March": "مارس", "April": "ابريل", "May": "مايو", "June": "يونيو", "July": "يوليو", "August": "اغسطس", "September": "سبتمبر", "October": "اكتوبر", "November": "نوفمبر", "December": "ديسمبر", "Jan_Abbr": "يناير", "Feb_Abbr": "فبراير", "Mar_Abbr": "مارس", "Apr_Abbr": "ابريل", "May_Abbr": "مايو", "Jun_Abbr": "يونيو", "Jul_Abbr": "يوليو", "Aug_Abbr": "اغسطس", "Sep_Abbr": "سبتمبر", "Oct_Abbr": "اكتوبر", "Nov_Abbr": "نوفمبر", "Dec_Abbr": "ديسمبر", "AM": "ص", "PM": "م", "firstDayOfWeek": 6, "twoDigitYearMax": 2029, "mdy": "dmy", "M/d/yyyy": "dd/MM/yyyy", "dddd, MMMM dd, yyyy": "dd MMMM, yyyy", "h:mm tt": "hh:mm tt", "h:mm:ss tt": "hh:mm:ss tt", "dddd, MMMM dd, yyyy h:mm:ss tt": "dd MMMM, yyyy hh:mm:ss tt", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "dd MMMM", "MMMM, yyyy": "MMMM, yyyy", "/jan(uary)?/": "يناير", "/feb(ruary)?/": "فبراير", "/mar(ch)?/": "مارس", "/apr(il)?/": "ابريل", "/may/": "مايو", "/jun(e)?/": "يونيو", "/jul(y)?/": "يوليو", "/aug(ust)?/": "اغسطس", "/sep(t(ember)?)?/": "سبتمبر", "/oct(ober)?/": "اكتوبر", "/nov(ember)?/": "نوفمبر", "/dec(ember)?/": "ديسمبر", "/^su(n(day)?)?/": "^الاحد", "/^mo(n(day)?)?/": "^ا(1)?", "/^tu(e(s(day)?)?)?/": "^الثلاثاء", "/^we(d(nesday)?)?/": "^الاربعاء", "/^th(u(r(s(day)?)?)?)?/": "^الخميس", "/^fr(i(day)?)?/": "^الجمعة", "/^sa(t(urday)?)?/": "^السبت", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "ar-QA"; ================================================ FILE: build/production/i18n/ar-SA.js ================================================ /* * DateJS Culture String File * Country Code: ar-SA * Name: Arabic (Saudi Arabia) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["ar-SA"] = { "name": "ar-SA", "englishName": "Arabic (Saudi Arabia)", "nativeName": "العربية (المملكة العربية السعودية)", "Sunday": "الاحد", "Monday": "الاثنين", "Tuesday": "الثلاثاء", "Wednesday": "الاربعاء", "Thursday": "الخميس", "Friday": "الجمعة", "Saturday": "السبت", "Sun": "الاحد", "Mon": "الاثنين", "Tue": "الثلاثاء", "Wed": "الاربعاء", "Thu": "الخميس", "Fri": "الجمعة", "Sat": "السبت", "Su": "ح", "Mo": "ن", "Tu": "ث", "We": "ر", "Th": "خ", "Fr": "ج", "Sa": "س", "S_Sun_Initial": "ح", "M_Mon_Initial": "ن", "T_Tue_Initial": "ث", "W_Wed_Initial": "ر", "T_Thu_Initial": "خ", "F_Fri_Initial": "ج", "S_Sat_Initial": "س", "January": "محرم", "February": "صفر", "March": "ربيع الأول", "April": "ربيع الثاني", "May": "جمادى الأولى", "June": "جمادى الثانية", "July": "رجب", "August": "شعبان", "September": "رمضان", "October": "شوال", "November": "ذو القعدة", "December": "ذو الحجة", "Jan_Abbr": "محرم", "Feb_Abbr": "صفر", "Mar_Abbr": "ربيع الاول", "Apr_Abbr": "ربيع الثاني", "May_Abbr": "جمادى الاولى", "Jun_Abbr": "جمادى الثانية", "Jul_Abbr": "رجب", "Aug_Abbr": "شعبان", "Sep_Abbr": "رمضان", "Oct_Abbr": "شوال", "Nov_Abbr": "ذو القعدة", "Dec_Abbr": "ذو الحجة", "AM": "ص", "PM": "م", "firstDayOfWeek": 6, "twoDigitYearMax": 1451, "mdy": "dmy", "M/d/yyyy": "dd/MM/yy", "dddd, MMMM dd, yyyy": "dd/MMMM/yyyy", "h:mm tt": "hh:mm tt", "h:mm:ss tt": "hh:mm:ss tt", "dddd, MMMM dd, yyyy h:mm:ss tt": "dd/MMMM/yyyy hh:mm:ss tt", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "dd MMMM", "MMMM, yyyy": "MMMM, yyyy", "/jan(uary)?/": "محرم", "/feb(ruary)?/": "صفر", "/mar(ch)?/": "ربيع الأول", "/apr(il)?/": "ربيع الثاني", "/may/": "جمادى الأولى", "/jun(e)?/": "جمادى الثانية", "/jul(y)?/": "رجب", "/aug(ust)?/": "شعبان", "/sep(t(ember)?)?/": "رمضان", "/oct(ober)?/": "شوال", "/nov(ember)?/": "ذو القعدة", "/dec(ember)?/": "ذو الحجة", "/^su(n(day)?)?/": "^الاحد", "/^mo(n(day)?)?/": "^الاثنين", "/^tu(e(s(day)?)?)?/": "^الثلاثاء", "/^we(d(nesday)?)?/": "^الاربعاء", "/^th(u(r(s(day)?)?)?)?/": "^الخميس", "/^fr(i(day)?)?/": "^الجمعة", "/^sa(t(urday)?)?/": "^السبت", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "ar-SA"; ================================================ FILE: build/production/i18n/ar-SY.js ================================================ /* * DateJS Culture String File * Country Code: ar-SY * Name: Arabic (Syria) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["ar-SY"] = { "name": "ar-SY", "englishName": "Arabic (Syria)", "nativeName": "العربية (سوريا)", "Sunday": "الاحد", "Monday": "الاثنين", "Tuesday": "الثلاثاء", "Wednesday": "الاربعاء", "Thursday": "الخميس", "Friday": "الجمعة", "Saturday": "السبت", "Sun": "الاحد", "Mon": "الاثنين", "Tue": "الثلاثاء", "Wed": "الاربعاء", "Thu": "الخميس", "Fri": "الجمعة", "Sat": "السبت", "Su": "أ", "Mo": "ا", "Tu": "ث", "We": "أ", "Th": "خ", "Fr": "ج", "Sa": "س", "S_Sun_Initial": "أ", "M_Mon_Initial": "ا", "T_Tue_Initial": "ث", "W_Wed_Initial": "أ", "T_Thu_Initial": "خ", "F_Fri_Initial": "ج", "S_Sat_Initial": "س", "January": "كانون الثاني", "February": "شباط", "March": "آذار", "April": "نيسان", "May": "أيار", "June": "حزيران", "July": "تموز", "August": "آب", "September": "أيلول", "October": "تشرين الأول", "November": "تشرين الثاني", "December": "كانون الأول", "Jan_Abbr": "كانون الثاني", "Feb_Abbr": "شباط", "Mar_Abbr": "آذار", "Apr_Abbr": "نيسان", "May_Abbr": "أيار", "Jun_Abbr": "حزيران", "Jul_Abbr": "تموز", "Aug_Abbr": "آب", "Sep_Abbr": "أيلول", "Oct_Abbr": "تشرين الأول", "Nov_Abbr": "تشرين الثاني", "Dec_Abbr": "كانون الأول", "AM": "ص", "PM": "م", "firstDayOfWeek": 6, "twoDigitYearMax": 2029, "mdy": "dmy", "M/d/yyyy": "dd/MM/yyyy", "dddd, MMMM dd, yyyy": "dd MMMM, yyyy", "h:mm tt": "hh:mm tt", "h:mm:ss tt": "hh:mm:ss tt", "dddd, MMMM dd, yyyy h:mm:ss tt": "dd MMMM, yyyy hh:mm:ss tt", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "dd MMMM", "MMMM, yyyy": "MMMM, yyyy", "/jan(uary)?/": "كانون الثاني", "/feb(ruary)?/": "شباط", "/mar(ch)?/": "آذار", "/apr(il)?/": "نيسان", "/may/": "أيار", "/jun(e)?/": "حزيران", "/jul(y)?/": "تموز", "/aug(ust)?/": "آب", "/sep(t(ember)?)?/": "أيلول", "/oct(ober)?/": "تشرين الأول", "/nov(ember)?/": "تشرين الثاني", "/dec(ember)?/": "كانون الأول", "/^su(n(day)?)?/": "^الاحد", "/^mo(n(day)?)?/": "^ا(1)?", "/^tu(e(s(day)?)?)?/": "^الثلاثاء", "/^we(d(nesday)?)?/": "^الاربعاء", "/^th(u(r(s(day)?)?)?)?/": "^الخميس", "/^fr(i(day)?)?/": "^الجمعة", "/^sa(t(urday)?)?/": "^السبت", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "ar-SY"; ================================================ FILE: build/production/i18n/ar-TN.js ================================================ /* * DateJS Culture String File * Country Code: ar-TN * Name: Arabic (Tunisia) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["ar-TN"] = { "name": "ar-TN", "englishName": "Arabic (Tunisia)", "nativeName": "العربية (تونس)", "Sunday": "الاحد", "Monday": "الاثنين", "Tuesday": "الثلاثاء", "Wednesday": "الاربعاء", "Thursday": "الخميس", "Friday": "الجمعة", "Saturday": "السبت", "Sun": "الاحد", "Mon": "الاثنين", "Tue": "الثلاثاء", "Wed": "الاربعاء", "Thu": "الخميس", "Fri": "الجمعة", "Sat": "السبت", "Su": "أ", "Mo": "ا", "Tu": "ث", "We": "أ", "Th": "خ", "Fr": "ج", "Sa": "س", "S_Sun_Initial": "أ", "M_Mon_Initial": "ا", "T_Tue_Initial": "ث", "W_Wed_Initial": "أ", "T_Thu_Initial": "خ", "F_Fri_Initial": "ج", "S_Sat_Initial": "س", "January": "جانفي", "February": "فيفري", "March": "مارس", "April": "افريل", "May": "ماي", "June": "جوان", "July": "جويلية", "August": "اوت", "September": "سبتمبر", "October": "اكتوبر", "November": "نوفمبر", "December": "ديسمبر", "Jan_Abbr": "جانفي", "Feb_Abbr": "فيفري", "Mar_Abbr": "مارس", "Apr_Abbr": "افريل", "May_Abbr": "ماي", "Jun_Abbr": "جوان", "Jul_Abbr": "جويلية", "Aug_Abbr": "اوت", "Sep_Abbr": "سبتمبر", "Oct_Abbr": "اكتوبر", "Nov_Abbr": "نوفمبر", "Dec_Abbr": "ديسمبر", "AM": "ص", "PM": "م", "firstDayOfWeek": 1, "twoDigitYearMax": 2029, "mdy": "dmy", "M/d/yyyy": "dd-MM-yyyy", "dddd, MMMM dd, yyyy": "dd MMMM, yyyy", "h:mm tt": "H:mm", "h:mm:ss tt": "H:mm:ss", "dddd, MMMM dd, yyyy h:mm:ss tt": "dd MMMM, yyyy H:mm:ss", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "dd MMMM", "MMMM, yyyy": "MMMM, yyyy", "/jan(uary)?/": "جانفي", "/feb(ruary)?/": "فيفري", "/mar(ch)?/": "مارس", "/apr(il)?/": "افريل", "/may/": "ماي", "/jun(e)?/": "جوان", "/jul(y)?/": "جويلية", "/aug(ust)?/": "اوت", "/sep(t(ember)?)?/": "سبتمبر", "/oct(ober)?/": "اكتوبر", "/nov(ember)?/": "نوفمبر", "/dec(ember)?/": "ديسمبر", "/^su(n(day)?)?/": "^الاحد", "/^mo(n(day)?)?/": "^ا(1)?", "/^tu(e(s(day)?)?)?/": "^الثلاثاء", "/^we(d(nesday)?)?/": "^الاربعاء", "/^th(u(r(s(day)?)?)?)?/": "^الخميس", "/^fr(i(day)?)?/": "^الجمعة", "/^sa(t(urday)?)?/": "^السبت", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "ar-TN"; ================================================ FILE: build/production/i18n/ar-YE.js ================================================ /* * DateJS Culture String File * Country Code: ar-YE * Name: Arabic (Yemen) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["ar-YE"] = { "name": "ar-YE", "englishName": "Arabic (Yemen)", "nativeName": "العربية (اليمن)", "Sunday": "الاحد", "Monday": "الاثنين", "Tuesday": "الثلاثاء", "Wednesday": "الاربعاء", "Thursday": "الخميس", "Friday": "الجمعة", "Saturday": "السبت", "Sun": "الاحد", "Mon": "الاثنين", "Tue": "الثلاثاء", "Wed": "الاربعاء", "Thu": "الخميس", "Fri": "الجمعة", "Sat": "السبت", "Su": "أ", "Mo": "ا", "Tu": "ث", "We": "أ", "Th": "خ", "Fr": "ج", "Sa": "س", "S_Sun_Initial": "أ", "M_Mon_Initial": "ا", "T_Tue_Initial": "ث", "W_Wed_Initial": "أ", "T_Thu_Initial": "خ", "F_Fri_Initial": "ج", "S_Sat_Initial": "س", "January": "يناير", "February": "فبراير", "March": "مارس", "April": "ابريل", "May": "مايو", "June": "يونيو", "July": "يوليو", "August": "اغسطس", "September": "سبتمبر", "October": "اكتوبر", "November": "نوفمبر", "December": "ديسمبر", "Jan_Abbr": "يناير", "Feb_Abbr": "فبراير", "Mar_Abbr": "مارس", "Apr_Abbr": "ابريل", "May_Abbr": "مايو", "Jun_Abbr": "يونيو", "Jul_Abbr": "يوليو", "Aug_Abbr": "اغسطس", "Sep_Abbr": "سبتمبر", "Oct_Abbr": "اكتوبر", "Nov_Abbr": "نوفمبر", "Dec_Abbr": "ديسمبر", "AM": "ص", "PM": "م", "firstDayOfWeek": 6, "twoDigitYearMax": 2029, "mdy": "dmy", "M/d/yyyy": "dd/MM/yyyy", "dddd, MMMM dd, yyyy": "dd MMMM, yyyy", "h:mm tt": "hh:mm tt", "h:mm:ss tt": "hh:mm:ss tt", "dddd, MMMM dd, yyyy h:mm:ss tt": "dd MMMM, yyyy hh:mm:ss tt", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "dd MMMM", "MMMM, yyyy": "MMMM, yyyy", "/jan(uary)?/": "يناير", "/feb(ruary)?/": "فبراير", "/mar(ch)?/": "مارس", "/apr(il)?/": "ابريل", "/may/": "مايو", "/jun(e)?/": "يونيو", "/jul(y)?/": "يوليو", "/aug(ust)?/": "اغسطس", "/sep(t(ember)?)?/": "سبتمبر", "/oct(ober)?/": "اكتوبر", "/nov(ember)?/": "نوفمبر", "/dec(ember)?/": "ديسمبر", "/^su(n(day)?)?/": "^الاحد", "/^mo(n(day)?)?/": "^ا(1)?", "/^tu(e(s(day)?)?)?/": "^الثلاثاء", "/^we(d(nesday)?)?/": "^الاربعاء", "/^th(u(r(s(day)?)?)?)?/": "^الخميس", "/^fr(i(day)?)?/": "^الجمعة", "/^sa(t(urday)?)?/": "^السبت", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "ar-YE"; ================================================ FILE: build/production/i18n/az-Cyrl-AZ.js ================================================ /* * DateJS Culture String File * Country Code: az-Cyrl-AZ * Name: Azeri (Cyrillic, Azerbaijan) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["az-Cyrl-AZ"] = { "name": "az-Cyrl-AZ", "englishName": "Azeri (Cyrillic, Azerbaijan)", "nativeName": "Азәрбајҹан (Азәрбајҹан)", "Sunday": "Базар", "Monday": "Базар ертәси", "Tuesday": "Чәршәнбә ахшамы", "Wednesday": "Чәршәнбә", "Thursday": "Ҹүмә ахшамы", "Friday": "Ҹүмә", "Saturday": "Шәнбә", "Sun": "Б", "Mon": "Бе", "Tue": "Ча", "Wed": "Ч", "Thu": "Ҹа", "Fri": "Ҹ", "Sat": "Ш", "Su": "Б", "Mo": "Бе", "Tu": "Ча", "We": "Ч", "Th": "Ҹа", "Fr": "Ҹ", "Sa": "Ш", "S_Sun_Initial": "Б", "M_Mon_Initial": "Б", "T_Tue_Initial": "Ч", "W_Wed_Initial": "Ч", "T_Thu_Initial": "Ҹ", "F_Fri_Initial": "Ҹ", "S_Sat_Initial": "Ш", "January": "Јанвар", "February": "Феврал", "March": "Март", "April": "Апрел", "May": "Мај", "June": "Ијун", "July": "Ијул", "August": "Август", "September": "Сентјабр", "October": "Октјабр", "November": "Нојабр", "December": "Декабр", "Jan_Abbr": "Јан", "Feb_Abbr": "Фев", "Mar_Abbr": "Мар", "Apr_Abbr": "Апр", "May_Abbr": "Мај", "Jun_Abbr": "Ијун", "Jul_Abbr": "Ијул", "Aug_Abbr": "Авг", "Sep_Abbr": "Сен", "Oct_Abbr": "Окт", "Nov_Abbr": "Ноя", "Dec_Abbr": "Дек", "AM": "", "PM": "", "firstDayOfWeek": 1, "twoDigitYearMax": 2029, "mdy": "dmy", "M/d/yyyy": "dd.MM.yyyy", "dddd, MMMM dd, yyyy": "d MMMM yyyy", "h:mm tt": "H:mm", "h:mm:ss tt": "H:mm:ss", "dddd, MMMM dd, yyyy h:mm:ss tt": "d MMMM yyyy H:mm:ss", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "d MMMM", "MMMM, yyyy": "MMMM yyyy", "/jan(uary)?/": "јан(вар)?", "/feb(ruary)?/": "фев(рал)?", "/mar(ch)?/": "мар(т)?", "/apr(il)?/": "апр(ел)?", "/may/": "мај", "/jun(e)?/": "ијун", "/jul(y)?/": "ијул", "/aug(ust)?/": "авг(уст)?", "/sep(t(ember)?)?/": "сен(тјабр)?", "/oct(ober)?/": "окт(јабр)?", "/nov(ember)?/": "нојабр", "/dec(ember)?/": "дек(абр)?", "/^su(n(day)?)?/": "^базар", "/^mo(n(day)?)?/": "^базар ертәси", "/^tu(e(s(day)?)?)?/": "^чәршәнбә ахшамы", "/^we(d(nesday)?)?/": "^чәршәнбә", "/^th(u(r(s(day)?)?)?)?/": "^ҹүмә ахшамы", "/^fr(i(day)?)?/": "^ҹүмә", "/^sa(t(urday)?)?/": "^шәнбә", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "az-Cyrl-AZ"; ================================================ FILE: build/production/i18n/az-Latn-AZ.js ================================================ /* * DateJS Culture String File * Country Code: az-Latn-AZ * Name: Azeri (Latin, Azerbaijan) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["az-Latn-AZ"] = { "name": "az-Latn-AZ", "englishName": "Azeri (Latin, Azerbaijan)", "nativeName": "Azərbaycan­ılı (Azərbaycanca)", "Sunday": "Bazar", "Monday": "Bazar ertəsi", "Tuesday": "Çərşənbə axşamı", "Wednesday": "Çərşənbə", "Thursday": "Cümə axşamı", "Friday": "Cümə", "Saturday": "Şənbə", "Sun": "B", "Mon": "Be", "Tue": "Ça", "Wed": "Ç", "Thu": "Ca", "Fri": "C", "Sat": "Ş", "Su": "B", "Mo": "Be", "Tu": "Ça", "We": "Ç", "Th": "Ca", "Fr": "C", "Sa": "Ş", "S_Sun_Initial": "B", "M_Mon_Initial": "B", "T_Tue_Initial": "Ç", "W_Wed_Initial": "Ç", "T_Thu_Initial": "C", "F_Fri_Initial": "C", "S_Sat_Initial": "Ş", "January": "Yanvar", "February": "Fevral", "March": "Mart", "April": "Aprel", "May": "May", "June": "İyun", "July": "İyul", "August": "Avgust", "September": "Sentyabr", "October": "Oktyabr", "November": "Noyabr", "December": "Dekabr", "Jan_Abbr": "Yan", "Feb_Abbr": "Fev", "Mar_Abbr": "Mar", "Apr_Abbr": "Apr", "May_Abbr": "May", "Jun_Abbr": "İyun", "Jul_Abbr": "İyul", "Aug_Abbr": "Avg", "Sep_Abbr": "Sen", "Oct_Abbr": "Okt", "Nov_Abbr": "Noy", "Dec_Abbr": "Dek", "AM": "", "PM": "", "firstDayOfWeek": 1, "twoDigitYearMax": 2029, "mdy": "dmy", "M/d/yyyy": "dd.MM.yyyy", "dddd, MMMM dd, yyyy": "d MMMM yyyy", "h:mm tt": "H:mm", "h:mm:ss tt": "H:mm:ss", "dddd, MMMM dd, yyyy h:mm:ss tt": "d MMMM yyyy H:mm:ss", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "d MMMM", "MMMM, yyyy": "MMMM yyyy", "/jan(uary)?/": "yan(var)?", "/feb(ruary)?/": "fev(ral)?", "/mar(ch)?/": "mar(t)?", "/apr(il)?/": "apr(el)?", "/may/": "may", "/jun(e)?/": "iyun", "/jul(y)?/": "iyul", "/aug(ust)?/": "avg(ust)?", "/sep(t(ember)?)?/": "sen(tyabr)?", "/oct(ober)?/": "okt(yabr)?", "/nov(ember)?/": "noy(abr)?", "/dec(ember)?/": "dek(abr)?", "/^su(n(day)?)?/": "^bazar", "/^mo(n(day)?)?/": "^bazar ertəsi", "/^tu(e(s(day)?)?)?/": "^çərşənbə axşamı", "/^we(d(nesday)?)?/": "^çərşənbə", "/^th(u(r(s(day)?)?)?)?/": "^cümə axşamı", "/^fr(i(day)?)?/": "^cümə", "/^sa(t(urday)?)?/": "^şənbə", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "az-Latn-AZ"; ================================================ FILE: build/production/i18n/be-BY.js ================================================ /* * DateJS Culture String File * Country Code: be-BY * Name: Belarusian (Belarus) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["be-BY"] = { "name": "be-BY", "englishName": "Belarusian (Belarus)", "nativeName": "Беларускі (Беларусь)", "Sunday": "нядзеля", "Monday": "панядзелак", "Tuesday": "аўторак", "Wednesday": "серада", "Thursday": "чацвер", "Friday": "пятніца", "Saturday": "субота", "Sun": "нд", "Mon": "пн", "Tue": "аў", "Wed": "ср", "Thu": "чц", "Fri": "пт", "Sat": "сб", "Su": "нд", "Mo": "пн", "Tu": "аў", "We": "ср", "Th": "чц", "Fr": "пт", "Sa": "сб", "S_Sun_Initial": "н", "M_Mon_Initial": "п", "T_Tue_Initial": "а", "W_Wed_Initial": "с", "T_Thu_Initial": "ч", "F_Fri_Initial": "п", "S_Sat_Initial": "с", "January": "Студзень", "February": "Люты", "March": "Сакавік", "April": "Красавік", "May": "Май", "June": "Чэрвень", "July": "Ліпень", "August": "Жнівень", "September": "Верасень", "October": "Кастрычнік", "November": "Лістапад", "December": "Снежань", "Jan_Abbr": "Сту", "Feb_Abbr": "Лют", "Mar_Abbr": "Сак", "Apr_Abbr": "Кра", "May_Abbr": "Май", "Jun_Abbr": "Чэр", "Jul_Abbr": "Ліп", "Aug_Abbr": "Жні", "Sep_Abbr": "Вер", "Oct_Abbr": "Кас", "Nov_Abbr": "Ліс", "Dec_Abbr": "Сне", "AM": "", "PM": "", "firstDayOfWeek": 1, "twoDigitYearMax": 2029, "mdy": "dmy", "M/d/yyyy": "dd.MM.yyyy", "dddd, MMMM dd, yyyy": "d MMMM yyyy", "h:mm tt": "H:mm", "h:mm:ss tt": "H:mm:ss", "dddd, MMMM dd, yyyy h:mm:ss tt": "d MMMM yyyy H:mm:ss", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "d MMMM", "MMMM, yyyy": "MMMM yyyy", "/jan(uary)?/": "сту(дзень)?", "/feb(ruary)?/": "лют(ы)?", "/mar(ch)?/": "сак(авік)?", "/apr(il)?/": "кра(савік)?", "/may/": "май", "/jun(e)?/": "чэр(вень)?", "/jul(y)?/": "ліп(ень)?", "/aug(ust)?/": "жні(вень)?", "/sep(t(ember)?)?/": "вер(асень)?", "/oct(ober)?/": "кас(трычнік)?", "/nov(ember)?/": "ліс(тапад)?", "/dec(ember)?/": "сне(жань)?", "/^su(n(day)?)?/": "^нядзеля", "/^mo(n(day)?)?/": "^панядзелак", "/^tu(e(s(day)?)?)?/": "^аўторак", "/^we(d(nesday)?)?/": "^серада", "/^th(u(r(s(day)?)?)?)?/": "^чацвер", "/^fr(i(day)?)?/": "^пятніца", "/^sa(t(urday)?)?/": "^субота", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "be-BY"; ================================================ FILE: build/production/i18n/bg-BG.js ================================================ /* * DateJS Culture String File * Country Code: bg-BG * Name: Bulgarian (Bulgaria) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["bg-BG"] = { "name": "bg-BG", "englishName": "Bulgarian (Bulgaria)", "nativeName": "български (България)", "Sunday": "неделя", "Monday": "понеделник", "Tuesday": "вторник", "Wednesday": "сряда", "Thursday": "четвъртък", "Friday": "петък", "Saturday": "събота", "Sun": "Нд", "Mon": "Пн", "Tue": "Вт", "Wed": "Ср", "Thu": "Чт", "Fri": "Пт", "Sat": "Сб", "Su": "не", "Mo": "по", "Tu": "вт", "We": "ср", "Th": "че", "Fr": "пе", "Sa": "съ", "S_Sun_Initial": "н", "M_Mon_Initial": "п", "T_Tue_Initial": "в", "W_Wed_Initial": "с", "T_Thu_Initial": "ч", "F_Fri_Initial": "п", "S_Sat_Initial": "с", "January": "Януари", "February": "Февруари", "March": "Март", "April": "Април", "May": "Май", "June": "Юни", "July": "Юли", "August": "Август", "September": "Септември", "October": "Октомври", "November": "Ноември", "December": "Декември", "Jan_Abbr": "Януари", "Feb_Abbr": "Февруари", "Mar_Abbr": "Март", "Apr_Abbr": "Април", "May_Abbr": "Май", "Jun_Abbr": "Юни", "Jul_Abbr": "Юли", "Aug_Abbr": "Август", "Sep_Abbr": "Септември", "Oct_Abbr": "Октомври", "Nov_Abbr": "Ноември", "Dec_Abbr": "Декември", "AM": "", "PM": "", "firstDayOfWeek": 1, "twoDigitYearMax": 2029, "mdy": "dmy", "M/d/yyyy": "dd.M.yyyy 'г.'", "dddd, MMMM dd, yyyy": "dd MMMM yyyy 'г.'", "h:mm tt": "HH:mm", "h:mm:ss tt": "HH:mm:ss", "dddd, MMMM dd, yyyy h:mm:ss tt": "dd MMMM yyyy 'г.' HH:mm:ss", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "dd MMMM", "MMMM, yyyy": "MMMM yyyy 'г.'", "/jan(uary)?/": "януари", "/feb(ruary)?/": "февруари", "/mar(ch)?/": "март", "/apr(il)?/": "април", "/may/": "май", "/jun(e)?/": "юни", "/jul(y)?/": "юли", "/aug(ust)?/": "август", "/sep(t(ember)?)?/": "септември", "/oct(ober)?/": "октомври", "/nov(ember)?/": "ноември", "/dec(ember)?/": "декември", "/^su(n(day)?)?/": "^не((деля)?)?", "/^mo(n(day)?)?/": "^по((неделник)?)?", "/^tu(e(s(day)?)?)?/": "^вторник", "/^we(d(nesday)?)?/": "^сряда", "/^th(u(r(s(day)?)?)?)?/": "^че((твъртък)?)?", "/^fr(i(day)?)?/": "^пе((тък)?)?", "/^sa(t(urday)?)?/": "^съ((бота)?)?", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "bg-BG"; ================================================ FILE: build/production/i18n/bs-Latn-BA.js ================================================ /* * DateJS Culture String File * Country Code: bs-Latn-BA * Name: Bosnian (Bosnia and Herzegovina) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["bs-Latn-BA"] = { "name": "bs-Latn-BA", "englishName": "Bosnian (Bosnia and Herzegovina)", "nativeName": "bosanski (Bosna i Hercegovina)", "Sunday": "nedjelja", "Monday": "ponedjeljak", "Tuesday": "utorak", "Wednesday": "srijeda", "Thursday": "četvrtak", "Friday": "petak", "Saturday": "subota", "Sun": "ned", "Mon": "pon", "Tue": "uto", "Wed": "sri", "Thu": "čet", "Fri": "pet", "Sat": "sub", "Su": "ned", "Mo": "pon", "Tu": "uto", "We": "sri", "Th": "čet", "Fr": "pet", "Sa": "sub", "S_Sun_Initial": "n", "M_Mon_Initial": "p", "T_Tue_Initial": "u", "W_Wed_Initial": "s", "T_Thu_Initial": "č", "F_Fri_Initial": "p", "S_Sat_Initial": "s", "January": "januar", "February": "februar", "March": "mart", "April": "april", "May": "maj", "June": "jun", "July": "jul", "August": "avgust", "September": "septembar", "October": "oktobar", "November": "novembar", "December": "decembar", "Jan_Abbr": "jan", "Feb_Abbr": "feb", "Mar_Abbr": "mar", "Apr_Abbr": "apr", "May_Abbr": "maj", "Jun_Abbr": "jun", "Jul_Abbr": "jul", "Aug_Abbr": "avg", "Sep_Abbr": "sep", "Oct_Abbr": "okt", "Nov_Abbr": "nov", "Dec_Abbr": "dec", "AM": "", "PM": "", "firstDayOfWeek": 1, "twoDigitYearMax": 2029, "mdy": "dmy", "M/d/yyyy": "d.M.yyyy", "dddd, MMMM dd, yyyy": "d. MMMM yyyy", "h:mm tt": "H:mm:ss", "h:mm:ss tt": "H:mm:ss", "dddd, MMMM dd, yyyy h:mm:ss tt": "d. MMMM yyyy H:mm:ss", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "MMMM dd", "MMMM, yyyy": "MMMM yyyy", "/jan(uary)?/": "jan(uar)?", "/feb(ruary)?/": "feb(ruar)?", "/mar(ch)?/": "mar(t)?", "/apr(il)?/": "apr(il)?", "/may/": "maj", "/jun(e)?/": "jun", "/jul(y)?/": "jul", "/aug(ust)?/": "avg(ust)?", "/sep(t(ember)?)?/": "sep(tembar)?", "/oct(ober)?/": "okt(obar)?", "/nov(ember)?/": "nov(embar)?", "/dec(ember)?/": "dec(embar)?", "/^su(n(day)?)?/": "^nedjelja", "/^mo(n(day)?)?/": "^ponedjeljak", "/^tu(e(s(day)?)?)?/": "^utorak", "/^we(d(nesday)?)?/": "^srijeda", "/^th(u(r(s(day)?)?)?)?/": "^četvrtak", "/^fr(i(day)?)?/": "^petak", "/^sa(t(urday)?)?/": "^subota", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "bs-Latn-BA"; ================================================ FILE: build/production/i18n/ca-ES.js ================================================ /* * DateJS Culture String File * Country Code: ca-ES * Name: Catalan (Catalan) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["ca-ES"] = { "name": "ca-ES", "englishName": "Catalan (Catalan)", "nativeName": "català (català)", "Sunday": "diumenge", "Monday": "dilluns", "Tuesday": "dimarts", "Wednesday": "dimecres", "Thursday": "dijous", "Friday": "divendres", "Saturday": "dissabte", "Sun": "dg.", "Mon": "dl.", "Tue": "dt.", "Wed": "dc.", "Thu": "dj.", "Fri": "dv.", "Sat": "ds.", "Su": "dg", "Mo": "dl", "Tu": "dt", "We": "dc", "Th": "dj", "Fr": "dv", "Sa": "ds", "S_Sun_Initial": "d", "M_Mon_Initial": "d", "T_Tue_Initial": "d", "W_Wed_Initial": "d", "T_Thu_Initial": "d", "F_Fri_Initial": "d", "S_Sat_Initial": "d", "January": "gener", "February": "febrer", "March": "març", "April": "abril", "May": "maig", "June": "juny", "July": "juliol", "August": "agost", "September": "setembre", "October": "octubre", "November": "novembre", "December": "desembre", "Jan_Abbr": "gen", "Feb_Abbr": "feb", "Mar_Abbr": "març", "Apr_Abbr": "abr", "May_Abbr": "maig", "Jun_Abbr": "juny", "Jul_Abbr": "jul", "Aug_Abbr": "ag", "Sep_Abbr": "set", "Oct_Abbr": "oct", "Nov_Abbr": "nov", "Dec_Abbr": "des", "AM": "", "PM": "", "firstDayOfWeek": 1, "twoDigitYearMax": 2029, "mdy": "dmy", "M/d/yyyy": "dd/MM/yyyy", "dddd, MMMM dd, yyyy": "dddd, d' / 'MMMM' / 'yyyy", "h:mm tt": "HH:mm", "h:mm:ss tt": "HH:mm:ss", "dddd, MMMM dd, yyyy h:mm:ss tt": "dddd, d' / 'MMMM' / 'yyyy HH:mm:ss", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "dd MMMM", "MMMM, yyyy": "MMMM' / 'yyyy", "/jan(uary)?/": "gen(er)?", "/feb(ruary)?/": "feb(rer)?", "/mar(ch)?/": "març", "/apr(il)?/": "abr(il)?", "/may/": "maig", "/jun(e)?/": "juny", "/jul(y)?/": "jul(iol)?", "/aug(ust)?/": "ag(ost)?", "/sep(t(ember)?)?/": "set(embre)?", "/oct(ober)?/": "oct(ubre)?", "/nov(ember)?/": "nov(embre)?", "/dec(ember)?/": "des(embre)?", "/^su(n(day)?)?/": "^dg((.(umenge)?)?)?", "/^mo(n(day)?)?/": "^dl((.(lluns)?)?)?", "/^tu(e(s(day)?)?)?/": "^dt((.(marts)?)?)?", "/^we(d(nesday)?)?/": "^dc((.(mecres)?)?)?", "/^th(u(r(s(day)?)?)?)?/": "^dj((.(jous)?)?)?", "/^fr(i(day)?)?/": "^dv((.(vendres)?)?)?", "/^sa(t(urday)?)?/": "^ds((.(ssabte)?)?)?", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "ca-ES"; ================================================ FILE: build/production/i18n/cs-CZ.js ================================================ /* * DateJS Culture String File * Country Code: cs-CZ * Name: Czech (Czech Republic) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["cs-CZ"] = { "name": "cs-CZ", "englishName": "Czech (Czech Republic)", "nativeName": "čeština (Česká republika)", "Sunday": "neděle", "Monday": "pondělí", "Tuesday": "úterý", "Wednesday": "středa", "Thursday": "čtvrtek", "Friday": "pátek", "Saturday": "sobota", "Sun": "ne", "Mon": "po", "Tue": "út", "Wed": "st", "Thu": "čt", "Fri": "pá", "Sat": "so", "Su": "ne", "Mo": "po", "Tu": "út", "We": "st", "Th": "čt", "Fr": "pá", "Sa": "so", "S_Sun_Initial": "n", "M_Mon_Initial": "p", "T_Tue_Initial": "ú", "W_Wed_Initial": "s", "T_Thu_Initial": "č", "F_Fri_Initial": "p", "S_Sat_Initial": "s", "January": "leden", "February": "únor", "March": "březen", "April": "duben", "May": "květen", "June": "červen", "July": "červenec", "August": "srpen", "September": "září", "October": "říjen", "November": "listopad", "December": "prosinec", "Jan_Abbr": "I", "Feb_Abbr": "II", "Mar_Abbr": "III", "Apr_Abbr": "IV", "May_Abbr": "V", "Jun_Abbr": "VI", "Jul_Abbr": "VII", "Aug_Abbr": "VIII", "Sep_Abbr": "IX", "Oct_Abbr": "X", "Nov_Abbr": "XI", "Dec_Abbr": "XII", "AM": "dop.", "PM": "odp.", "firstDayOfWeek": 1, "twoDigitYearMax": 2029, "mdy": "dmy", "M/d/yyyy": "d.M.yyyy", "dddd, MMMM dd, yyyy": "d. MMMM yyyy", "h:mm tt": "H:mm", "h:mm:ss tt": "H:mm:ss", "dddd, MMMM dd, yyyy h:mm:ss tt": "d. MMMM yyyy H:mm:ss", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "dd MMMM", "MMMM, yyyy": "MMMM yyyy", "/jan(uary)?/": "leden", "/feb(ruary)?/": "únor", "/mar(ch)?/": "březen", "/apr(il)?/": "duben", "/may/": "květen", "/jun(e)?/": "červen", "/jul(y)?/": "červenec", "/aug(ust)?/": "srpen", "/sep(t(ember)?)?/": "září", "/oct(ober)?/": "říjen", "/nov(ember)?/": "listopad", "/dec(ember)?/": "prosinec", "/^su(n(day)?)?/": "^neděle", "/^mo(n(day)?)?/": "^pondělí", "/^tu(e(s(day)?)?)?/": "^úterý", "/^we(d(nesday)?)?/": "^středa", "/^th(u(r(s(day)?)?)?)?/": "^čtvrtek", "/^fr(i(day)?)?/": "^pátek", "/^sa(t(urday)?)?/": "^sobota", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "cs-CZ"; ================================================ FILE: build/production/i18n/cy-GB.js ================================================ /* * DateJS Culture String File * Country Code: cy-GB * Name: Welsh (United Kingdom) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["cy-GB"] = { "name": "cy-GB", "englishName": "Welsh (United Kingdom)", "nativeName": "Cymraeg (y Deyrnas Unedig)", "Sunday": "Dydd Sul", "Monday": "Dydd Llun", "Tuesday": "Dydd Mawrth", "Wednesday": "Dydd Mercher", "Thursday": "Dydd Iau", "Friday": "Dydd Gwener", "Saturday": "Dydd Sadwrn", "Sun": "Sul", "Mon": "Llun", "Tue": "Maw", "Wed": "Mer", "Thu": "Iau", "Fri": "Gwe", "Sat": "Sad", "Su": "Sul", "Mo": "Llun", "Tu": "Maw", "We": "Mer", "Th": "Iau", "Fr": "Gwe", "Sa": "Sad", "S_Sun_Initial": "S", "M_Mon_Initial": "L", "T_Tue_Initial": "M", "W_Wed_Initial": "M", "T_Thu_Initial": "I", "F_Fri_Initial": "G", "S_Sat_Initial": "S", "January": "Ionawr", "February": "Chwefror", "March": "Mawrth", "April": "Ebrill", "May": "Mai", "June": "Mehefin", "July": "Gorffennaf", "August": "Awst", "September": "Medi", "October": "Hydref", "November": "Tachwedd", "December": "Rhagfyr", "Jan_Abbr": "Ion", "Feb_Abbr": "Chwe", "Mar_Abbr": "Maw", "Apr_Abbr": "Ebr", "May_Abbr": "Mai", "Jun_Abbr": "Meh", "Jul_Abbr": "Gor", "Aug_Abbr": "Aws", "Sep_Abbr": "Med", "Oct_Abbr": "Hyd", "Nov_Abbr": "Tach", "Dec_Abbr": "Rhag", "AM": "a.m.", "PM": "p.m.", "firstDayOfWeek": 1, "twoDigitYearMax": 2029, "mdy": "dmy", "M/d/yyyy": "dd/MM/yyyy", "dddd, MMMM dd, yyyy": "dd MMMM yyyy", "h:mm tt": "HH:mm:ss", "h:mm:ss tt": "HH:mm:ss", "dddd, MMMM dd, yyyy h:mm:ss tt": "dd MMMM yyyy HH:mm:ss", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "MMMM dd", "MMMM, yyyy": "MMMM yyyy", "/jan(uary)?/": "ion(awr)?", "/feb(ruary)?/": "chwe(fror)?", "/mar(ch)?/": "maw(rth)?", "/apr(il)?/": "ebr(ill)?", "/may/": "mai", "/jun(e)?/": "meh(efin)?", "/jul(y)?/": "gor(ffennaf)?", "/aug(ust)?/": "aws(t)?", "/sep(t(ember)?)?/": "med(i)?", "/oct(ober)?/": "hyd(ref)?", "/nov(ember)?/": "tach(wedd)?", "/dec(ember)?/": "rhag(fyr)?", "/^su(n(day)?)?/": "^dydd sul", "/^mo(n(day)?)?/": "^dydd llun", "/^tu(e(s(day)?)?)?/": "^dydd mawrth", "/^we(d(nesday)?)?/": "^dydd mercher", "/^th(u(r(s(day)?)?)?)?/": "^dydd iau", "/^fr(i(day)?)?/": "^dydd gwener", "/^sa(t(urday)?)?/": "^dydd sadwrn", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "cy-GB"; ================================================ FILE: build/production/i18n/da-DK.js ================================================ /* * DateJS Culture String File * Country Code: da-DK * Name: Danish (Denmark) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["da-DK"] = { "name": "da-DK", "englishName": "Danish (Denmark)", "nativeName": "dansk (Danmark)", "Sunday": "søndag", "Monday": "mandag", "Tuesday": "tirsdag", "Wednesday": "onsdag", "Thursday": "torsdag", "Friday": "fredag", "Saturday": "lørdag", "Sun": "sø", "Mon": "ma", "Tue": "ti", "Wed": "on", "Thu": "to", "Fri": "fr", "Sat": "lø", "Su": "sø", "Mo": "ma", "Tu": "ti", "We": "on", "Th": "to", "Fr": "fr", "Sa": "lø", "S_Sun_Initial": "s", "M_Mon_Initial": "m", "T_Tue_Initial": "t", "W_Wed_Initial": "o", "T_Thu_Initial": "t", "F_Fri_Initial": "f", "S_Sat_Initial": "l", "January": "januar", "February": "februar", "March": "marts", "April": "april", "May": "maj", "June": "juni", "July": "juli", "August": "august", "September": "september", "October": "oktober", "November": "november", "December": "december", "Jan_Abbr": "jan", "Feb_Abbr": "feb", "Mar_Abbr": "mar", "Apr_Abbr": "apr", "May_Abbr": "maj", "Jun_Abbr": "jun", "Jul_Abbr": "jul", "Aug_Abbr": "aug", "Sep_Abbr": "sep", "Oct_Abbr": "okt", "Nov_Abbr": "nov", "Dec_Abbr": "dec", "AM": "", "PM": "", "firstDayOfWeek": 1, "twoDigitYearMax": 2029, "mdy": "dmy", "M/d/yyyy": "dd-MM-yyyy", "dddd, MMMM dd, yyyy": "d. MMMM yyyy", "h:mm tt": "HH:mm", "h:mm:ss tt": "HH:mm:ss", "dddd, MMMM dd, yyyy h:mm:ss tt": "d. MMMM yyyy HH:mm:ss", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "d. MMMM", "MMMM, yyyy": "MMMM yyyy", "/jan(uary)?/": "jan(uar)?", "/feb(ruary)?/": "feb(ruar)?", "/mar(ch)?/": "mar(ts)?", "/apr(il)?/": "apr(il)?", "/may/": "maj", "/jun(e)?/": "jun(i)?", "/jul(y)?/": "jul(i)?", "/aug(ust)?/": "aug(ust)?", "/sep(t(ember)?)?/": "sep(t(ember)?)?", "/oct(ober)?/": "okt(ober)?", "/nov(ember)?/": "nov(ember)?", "/dec(ember)?/": "dec(ember)?", "/^su(n(day)?)?/": "^søndag", "/^mo(n(day)?)?/": "^mandag", "/^tu(e(s(day)?)?)?/": "^tirsdag", "/^we(d(nesday)?)?/": "^onsdag", "/^th(u(r(s(day)?)?)?)?/": "^torsdag", "/^fr(i(day)?)?/": "^fredag", "/^sa(t(urday)?)?/": "^lørdag", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "da-DK"; ================================================ FILE: build/production/i18n/de-AT.js ================================================ /* * DateJS Culture String File * Country Code: de-AT * Name: German (Austria) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["de-AT"] = { "name": "de-AT", "englishName": "German (Austria)", "nativeName": "Deutsch (Österreich)", "Sunday": "Sonntag", "Monday": "Montag", "Tuesday": "Dienstag", "Wednesday": "Mittwoch", "Thursday": "Donnerstag", "Friday": "Freitag", "Saturday": "Samstag", "Sun": "Son", "Mon": "Mon", "Tue": "Die", "Wed": "Mit", "Thu": "Don", "Fri": "Fre", "Sat": "Sam", "Su": "So", "Mo": "Mo", "Tu": "Di", "We": "Mi", "Th": "Do", "Fr": "Fr", "Sa": "Sa", "S_Sun_Initial": "S", "M_Mon_Initial": "M", "T_Tue_Initial": "D", "W_Wed_Initial": "M", "T_Thu_Initial": "D", "F_Fri_Initial": "F", "S_Sat_Initial": "S", "January": "Jänner", "February": "Februar", "March": "März", "April": "April", "May": "Mai", "June": "Juni", "July": "Juli", "August": "August", "September": "September", "October": "Oktober", "November": "November", "December": "Dezember", "Jan_Abbr": "J(ä|a)n", "Feb_Abbr": "Feb", "Mar_Abbr": "(M(a|ä)r|Mrz)", "Apr_Abbr": "Apr", "May_Abbr": "Mai", "Jun_Abbr": "Jun", "Jul_Abbr": "Jul", "Aug_Abbr": "Aug", "Sep_Abbr": "Sep", "Oct_Abbr": "Okt", "Nov_Abbr": "Nov", "Dec_Abbr": "Dez", "AM": "", "PM": "", "firstDayOfWeek": 1, "twoDigitYearMax": 2029, "mdy": "dmy", "M/d/yyyy": "dd.MM.yyyy", "dddd, MMMM dd, yyyy": "dddd, dd. MMMM yyyy", "h:mm tt": "HH:mm", "h:mm:ss tt": "HH:mm:ss", "dddd, MMMM dd, yyyy h:mm:ss tt": "dddd, dd. MMMM yyyy HH:mm:ss", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "dd MMMM", "MMMM, yyyy": "MMMM yyyy", "/jan(uary)?/": "jän(ner)?", "/feb(ruary)?/": "feb(ruar)?", "/mar(ch)?/": "mär(z)?", "/apr(il)?/": "apr(il)?", "/may/": "mai", "/jun(e)?/": "jun(i)?", "/jul(y)?/": "jul(i)?", "/aug(ust)?/": "aug(ust)?", "/sep(t(ember)?)?/": "sep(t(ember)?)?", "/oct(ober)?/": "okt(ober)?", "/nov(ember)?/": "nov(ember)?", "/dec(ember)?/": "dez(ember)?", "/^su(n(day)?)?/": "^sonntag", "/^mo(n(day)?)?/": "^montag", "/^tu(e(s(day)?)?)?/": "^dienstag", "/^we(d(nesday)?)?/": "^mittwoch", "/^th(u(r(s(day)?)?)?)?/": "^donnerstag", "/^fr(i(day)?)?/": "^freitag", "/^sa(t(urday)?)?/": "^samstag", "/^next/": "^nächste(r|s|n)?", "/^last|past|prev(ious)?/": "^letzte(r|s|n)?|vergangene(r|s|n)?|vorherige(r|s|n)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|(da)?nach(er)?|von|daher|in)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|(be|zu)?vor|früher)", "/^yes(terday)?/": "^gestern", "/^t(od(ay)?)?/": "^heute", "/^tom(orrow)?/": "^morgen", "/^n(ow)?/": "^jetzt|sofort|gleich", "/^ms|milli(second)?s?/": "^ms|milli(sekunde(n)?)?", "/^sec(ond)?s?/": "^sek(unde(n)?)?", "/^mn|min(ute)?s?/": "^mn|min(ute(n)?)?", "/^h(our)?s?/": "^h|st(d|unde(n)?)?", "/^w(eek)?s?/": "^w(oche(n)?)?", "/^m(onth)?s?/": "^m(onat(e)?)?", "/^d(ay)?s?/": "^d|t(ag(en)?)?", "/^y(ear)?s?/": "^y|j(ahr(en)?)?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "de-AT"; ================================================ FILE: build/production/i18n/de-CH.js ================================================ /* * DateJS Culture String File * Country Code: de-CH * Name: German (Switzerland) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["de-CH"] = { "name": "de-CH", "englishName": "German (Switzerland)", "nativeName": "Deutsch (Schweiz)", "Sunday": "Sonntag", "Monday": "Montag", "Tuesday": "Dienstag", "Wednesday": "Mittwoch", "Thursday": "Donnerstag", "Friday": "Freitag", "Saturday": "Samstag", "Sun": "Son", "Mon": "Mon", "Tue": "Die", "Wed": "Mit", "Thu": "Don", "Fri": "Fre", "Sat": "Sam", "Su": "So", "Mo": "Mo", "Tu": "Di", "We": "Mi", "Th": "Do", "Fr": "Fr", "Sa": "Sa", "S_Sun_Initial": "S", "M_Mon_Initial": "M", "T_Tue_Initial": "D", "W_Wed_Initial": "M", "T_Thu_Initial": "D", "F_Fri_Initial": "F", "S_Sat_Initial": "S", "January": "Januar", "February": "Februar", "March": "März", "April": "April", "May": "Mai", "June": "Juni", "July": "Juli", "August": "August", "September": "September", "October": "Oktober", "November": "November", "December": "Dezember", "Jan_Abbr": "Jan", "Feb_Abbr": "Feb", "Mar_Abbr": "Mrz", "Apr_Abbr": "Apr", "May_Abbr": "Mai", "Jun_Abbr": "Jun", "Jul_Abbr": "Jul", "Aug_Abbr": "Aug", "Sep_Abbr": "Sep", "Oct_Abbr": "Okt", "Nov_Abbr": "Nov", "Dec_Abbr": "Dez", "AM": "", "PM": "", "firstDayOfWeek": 1, "twoDigitYearMax": 2029, "mdy": "dmy", "M/d/yyyy": "dd.MM.yyyy", "dddd, MMMM dd, yyyy": "dddd, d. MMMM yyyy", "h:mm tt": "HH:mm", "h:mm:ss tt": "HH:mm:ss", "dddd, MMMM dd, yyyy h:mm:ss tt": "dddd, d. MMMM yyyy HH:mm:ss", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "dd MMMM", "MMMM, yyyy": "MMMM yyyy", "/jan(uary)?/": "jan(uar)?", "/feb(ruary)?/": "feb(ruar)?", "/mar(ch)?/": "märz", "/apr(il)?/": "apr(il)?", "/may/": "mai", "/jun(e)?/": "jun(i)?", "/jul(y)?/": "jul(i)?", "/aug(ust)?/": "aug(ust)?", "/sep(t(ember)?)?/": "sep(t(ember)?)?", "/oct(ober)?/": "okt(ober)?", "/nov(ember)?/": "nov(ember)?", "/dec(ember)?/": "dez(ember)?", "/^su(n(day)?)?/": "^sonntag", "/^mo(n(day)?)?/": "^montag", "/^tu(e(s(day)?)?)?/": "^dienstag", "/^we(d(nesday)?)?/": "^mittwoch", "/^th(u(r(s(day)?)?)?)?/": "^donnerstag", "/^fr(i(day)?)?/": "^freitag", "/^sa(t(urday)?)?/": "^samstag", "/^next/": "^nächste(r|s|n)?", "/^last|past|prev(ious)?/": "^letzte(r|s|n)?|vergangene(r|s|n)?|vorherige(r|s|n)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|(da)?nach(er)?|von|daher|in)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|(be|zu)?vor|früher)", "/^yes(terday)?/": "^gestern", "/^t(od(ay)?)?/": "^heute", "/^tom(orrow)?/": "^morgen", "/^n(ow)?/": "^jetzt|sofort|gleich", "/^ms|milli(second)?s?/": "^ms|milli(sekunde(n)?)?", "/^sec(ond)?s?/": "^sek(unde(n)?)?", "/^mn|min(ute)?s?/": "^mn|min(ute(n)?)?", "/^h(our)?s?/": "^h|st(d|unde(n)?)?", "/^w(eek)?s?/": "^w(oche(n)?)?", "/^m(onth)?s?/": "^m(onat(e)?)?", "/^d(ay)?s?/": "^d|t(ag(en)?)?", "/^y(ear)?s?/": "^y|j(ahr(en)?)?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "de-CH"; ================================================ FILE: build/production/i18n/de-DE.js ================================================ /* * DateJS Culture String File * Country Code: de-DE * Name: German (Germany) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["de-DE"] = { "name": "de-DE", "englishName": "German (Germany)", "nativeName": "Deutsch (Deutschland)", "Sunday": "Sonntag", "Monday": "Montag", "Tuesday": "Dienstag", "Wednesday": "Mittwoch", "Thursday": "Donnerstag", "Friday": "Freitag", "Saturday": "Samstag", "Sun": "Son", "Mon": "Mon", "Tue": "Die", "Wed": "Mit", "Thu": "Don", "Fri": "Fre", "Sat": "Sam", "Su": "So", "Mo": "Mo", "Tu": "Di", "We": "Mi", "Th": "Do", "Fr": "Fr", "Sa": "Sa", "S_Sun_Initial": "S", "M_Mon_Initial": "M", "T_Tue_Initial": "D", "W_Wed_Initial": "M", "T_Thu_Initial": "D", "F_Fri_Initial": "F", "S_Sat_Initial": "S", "January": "Januar", "February": "Februar", "March": "März", "April": "April", "May": "Mai", "June": "Juni", "July": "Juli", "August": "August", "September": "September", "October": "Oktober", "November": "November", "December": "Dezember", "Jan_Abbr": "Jan", "Feb_Abbr": "Feb", "Mar_Abbr": "Mrz", "Apr_Abbr": "Apr", "May_Abbr": "Mai", "Jun_Abbr": "Jun", "Jul_Abbr": "Jul", "Aug_Abbr": "Aug", "Sep_Abbr": "Sep", "Oct_Abbr": "Okt", "Nov_Abbr": "Nov", "Dec_Abbr": "Dez", "AM": "", "PM": "", "firstDayOfWeek": 1, "twoDigitYearMax": 2029, "mdy": "dmy", "M/d/yyyy": "dd.MM.yyyy", "dddd, MMMM dd, yyyy": "dddd, d. MMMM yyyy", "h:mm tt": "HH:mm", "h:mm:ss tt": "HH:mm:ss", "dddd, MMMM dd, yyyy h:mm:ss tt": "dddd, d. MMMM yyyy HH:mm:ss", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "dd MMMM", "MMMM, yyyy": "MMMM yyyy", "/jan(uary)?/": "jan(uar)?", "/feb(ruary)?/": "feb(ruar)?", "/mar(ch)?/": "märz", "/apr(il)?/": "apr(il)?", "/may/": "mai", "/jun(e)?/": "jun(i)?", "/jul(y)?/": "jul(i)?", "/aug(ust)?/": "aug(ust)?", "/sep(t(ember)?)?/": "sep(t(ember)?)?", "/oct(ober)?/": "okt(ober)?", "/nov(ember)?/": "nov(ember)?", "/dec(ember)?/": "dez(ember)?", "/^su(n(day)?)?/": "^sonntag", "/^mo(n(day)?)?/": "^montag", "/^tu(e(s(day)?)?)?/": "^dienstag", "/^we(d(nesday)?)?/": "^mittwoch", "/^th(u(r(s(day)?)?)?)?/": "^donnerstag", "/^fr(i(day)?)?/": "^freitag", "/^sa(t(urday)?)?/": "^samstag", "/^next/": "^nächste(r|s|n)?", "/^last|past|prev(ious)?/": "^letzte(r|s|n)?|vergangene(r|s|n)?|vorherige(r|s|n)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|(da)?nach(er)?|von|daher|in)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|(be|zu)?vor|früher)", "/^yes(terday)?/": "^gestern", "/^t(od(ay)?)?/": "^heute", "/^tom(orrow)?/": "^morgen", "/^n(ow)?/": "^jetzt|sofort|gleich", "/^ms|milli(second)?s?/": "^ms|milli(sekunde(n)?)?", "/^sec(ond)?s?/": "^sek(unde(n)?)?", "/^mn|min(ute)?s?/": "^mn|min(ute(n)?)?", "/^h(our)?s?/": "^h|st(d|unde(n)?)?", "/^w(eek)?s?/": "^w(oche(n)?)?", "/^m(onth)?s?/": "^m(onat(e)?)?", "/^d(ay)?s?/": "^d|t(ag(en)?)?", "/^y(ear)?s?/": "^y|j(ahr(en)?)?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "de-DE"; ================================================ FILE: build/production/i18n/de-LI.js ================================================ /* * DateJS Culture String File * Country Code: de-LI * Name: German (Liechtenstein) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["de-LI"] = { "name": "de-LI", "englishName": "German (Liechtenstein)", "nativeName": "Deutsch (Liechtenstein)", "Sunday": "Sonntag", "Monday": "Montag", "Tuesday": "Dienstag", "Wednesday": "Mittwoch", "Thursday": "Donnerstag", "Friday": "Freitag", "Saturday": "Samstag", "Sun": "Son", "Mon": "Mon", "Tue": "Die", "Wed": "Mit", "Thu": "Don", "Fri": "Fre", "Sat": "Sam", "Su": "So", "Mo": "Mo", "Tu": "Di", "We": "Mi", "Th": "Do", "Fr": "Fr", "Sa": "Sa", "S_Sun_Initial": "S", "M_Mon_Initial": "M", "T_Tue_Initial": "D", "W_Wed_Initial": "M", "T_Thu_Initial": "D", "F_Fri_Initial": "F", "S_Sat_Initial": "S", "January": "Januar", "February": "Februar", "March": "März", "April": "April", "May": "Mai", "June": "Juni", "July": "Juli", "August": "August", "September": "September", "October": "Oktober", "November": "November", "December": "Dezember", "Jan_Abbr": "Jan", "Feb_Abbr": "Feb", "Mar_Abbr": "Mrz", "Apr_Abbr": "Apr", "May_Abbr": "Mai", "Jun_Abbr": "Jun", "Jul_Abbr": "Jul", "Aug_Abbr": "Aug", "Sep_Abbr": "Sep", "Oct_Abbr": "Okt", "Nov_Abbr": "Nov", "Dec_Abbr": "Dez", "AM": "", "PM": "", "firstDayOfWeek": 1, "twoDigitYearMax": 2029, "mdy": "dmy", "M/d/yyyy": "dd.MM.yyyy", "dddd, MMMM dd, yyyy": "dddd, d. MMMM yyyy", "h:mm tt": "HH:mm", "h:mm:ss tt": "HH:mm:ss", "dddd, MMMM dd, yyyy h:mm:ss tt": "dddd, d. MMMM yyyy HH:mm:ss", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "dd MMMM", "MMMM, yyyy": "MMMM yyyy", "/jan(uary)?/": "jan(uar)?", "/feb(ruary)?/": "feb(ruar)?", "/mar(ch)?/": "märz", "/apr(il)?/": "apr(il)?", "/may/": "mai", "/jun(e)?/": "jun(i)?", "/jul(y)?/": "jul(i)?", "/aug(ust)?/": "aug(ust)?", "/sep(t(ember)?)?/": "sep(t(ember)?)?", "/oct(ober)?/": "okt(ober)?", "/nov(ember)?/": "nov(ember)?", "/dec(ember)?/": "dez(ember)?", "/^su(n(day)?)?/": "^sonntag", "/^mo(n(day)?)?/": "^montag", "/^tu(e(s(day)?)?)?/": "^dienstag", "/^we(d(nesday)?)?/": "^mittwoch", "/^th(u(r(s(day)?)?)?)?/": "^donnerstag", "/^fr(i(day)?)?/": "^freitag", "/^sa(t(urday)?)?/": "^samstag", "/^next/": "^nächste(r|s|n)?", "/^last|past|prev(ious)?/": "^letzte(r|s|n)?|vergangene(r|s|n)?|vorherige(r|s|n)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|(da)?nach(er)?|von|daher|in)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|(be|zu)?vor|früher)", "/^yes(terday)?/": "^gestern", "/^t(od(ay)?)?/": "^heute", "/^tom(orrow)?/": "^morgen", "/^n(ow)?/": "^jetzt|sofort|gleich", "/^ms|milli(second)?s?/": "^ms|milli(sekunde(n)?)?", "/^sec(ond)?s?/": "^sek(unde(n)?)?", "/^mn|min(ute)?s?/": "^mn|min(ute(n)?)?", "/^h(our)?s?/": "^h|st(d|unde(n)?)?", "/^w(eek)?s?/": "^w(oche(n)?)?", "/^m(onth)?s?/": "^m(onat(e)?)?", "/^d(ay)?s?/": "^d|t(ag(en)?)?", "/^y(ear)?s?/": "^y|j(ahr(en)?)?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "de-LI"; ================================================ FILE: build/production/i18n/de-LU.js ================================================ /* * DateJS Culture String File * Country Code: de-LU * Name: German (Luxembourg) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["de-LU"] = { "name": "de-LU", "englishName": "German (Luxembourg)", "nativeName": "Deutsch (Luxemburg)", "Sunday": "Sonntag", "Monday": "Montag", "Tuesday": "Dienstag", "Wednesday": "Mittwoch", "Thursday": "Donnerstag", "Friday": "Freitag", "Saturday": "Samstag", "Sun": "Son", "Mon": "Mon", "Tue": "Die", "Wed": "Mit", "Thu": "Don", "Fri": "Fre", "Sat": "Sam", "Su": "So", "Mo": "Mo", "Tu": "Di", "We": "Mi", "Th": "Do", "Fr": "Fr", "Sa": "Sa", "S_Sun_Initial": "S", "M_Mon_Initial": "M", "T_Tue_Initial": "D", "W_Wed_Initial": "M", "T_Thu_Initial": "D", "F_Fri_Initial": "F", "S_Sat_Initial": "S", "January": "Januar", "February": "Februar", "March": "März", "April": "April", "May": "Mai", "June": "Juni", "July": "Juli", "August": "August", "September": "September", "October": "Oktober", "November": "November", "December": "Dezember", "Jan_Abbr": "Jan", "Feb_Abbr": "Feb", "Mar_Abbr": "Mrz", "Apr_Abbr": "Apr", "May_Abbr": "Mai", "Jun_Abbr": "Jun", "Jul_Abbr": "Jul", "Aug_Abbr": "Aug", "Sep_Abbr": "Sep", "Oct_Abbr": "Okt", "Nov_Abbr": "Nov", "Dec_Abbr": "Dez", "AM": "", "PM": "", "firstDayOfWeek": 1, "twoDigitYearMax": 2029, "mdy": "dmy", "M/d/yyyy": "dd.MM.yyyy", "dddd, MMMM dd, yyyy": "dddd, d. MMMM yyyy", "h:mm tt": "HH:mm", "h:mm:ss tt": "HH:mm:ss", "dddd, MMMM dd, yyyy h:mm:ss tt": "dddd, d. MMMM yyyy HH:mm:ss", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "dd MMMM", "MMMM, yyyy": "MMMM yyyy", "/jan(uary)?/": "jan(uar)?", "/feb(ruary)?/": "feb(ruar)?", "/mar(ch)?/": "märz", "/apr(il)?/": "apr(il)?", "/may/": "mai", "/jun(e)?/": "jun(i)?", "/jul(y)?/": "jul(i)?", "/aug(ust)?/": "aug(ust)?", "/sep(t(ember)?)?/": "sep(t(ember)?)?", "/oct(ober)?/": "okt(ober)?", "/nov(ember)?/": "nov(ember)?", "/dec(ember)?/": "dez(ember)?", "/^su(n(day)?)?/": "^sonntag", "/^mo(n(day)?)?/": "^montag", "/^tu(e(s(day)?)?)?/": "^dienstag", "/^we(d(nesday)?)?/": "^mittwoch", "/^th(u(r(s(day)?)?)?)?/": "^donnerstag", "/^fr(i(day)?)?/": "^freitag", "/^sa(t(urday)?)?/": "^samstag", "/^next/": "^nächste(r|s|n)?", "/^last|past|prev(ious)?/": "^letzte(r|s|n)?|vergangene(r|s|n)?|vorherige(r|s|n)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|(da)?nach(er)?|von|daher|in)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|(be|zu)?vor|früher)", "/^yes(terday)?/": "^gestern", "/^t(od(ay)?)?/": "^heute", "/^tom(orrow)?/": "^morgen", "/^n(ow)?/": "^jetzt|sofort|gleich", "/^ms|milli(second)?s?/": "^ms|milli(sekunde(n)?)?", "/^sec(ond)?s?/": "^sek(unde(n)?)?", "/^mn|min(ute)?s?/": "^mn|min(ute(n)?)?", "/^h(our)?s?/": "^h|st(d|unde(n)?)?", "/^w(eek)?s?/": "^w(oche(n)?)?", "/^m(onth)?s?/": "^m(onat(e)?)?", "/^d(ay)?s?/": "^d|t(ag(en)?)?", "/^y(ear)?s?/": "^y|j(ahr(en)?)?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "de-LU"; ================================================ FILE: build/production/i18n/dv-MV.js ================================================ /* * DateJS Culture String File * Country Code: dv-MV * Name: Divehi (Maldives) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["dv-MV"] = { "name": "dv-MV", "englishName": "Divehi (Maldives)", "nativeName": "ދިވެހިބަސް (ދިވެހި ރާއްޖެ)", "Sunday": "الاحد", "Monday": "الاثنين", "Tuesday": "الثلاثاء", "Wednesday": "الاربعاء", "Thursday": "الخميس", "Friday": "الجمعة", "Saturday": "السبت", "Sun": "الاحد", "Mon": "الاثنين", "Tue": "الثلاثاء", "Wed": "الاربعاء", "Thu": "الخميس", "Fri": "الجمعة", "Sat": "السبت", "Su": "ح", "Mo": "ن", "Tu": "ث", "We": "ر", "Th": "خ", "Fr": "ج", "Sa": "س", "S_Sun_Initial": "ح", "M_Mon_Initial": "ن", "T_Tue_Initial": "ث", "W_Wed_Initial": "ر", "T_Thu_Initial": "خ", "F_Fri_Initial": "ج", "S_Sat_Initial": "س", "January": "محرم", "February": "صفر", "March": "ربيع الأول", "April": "ربيع الثاني", "May": "جمادى الأولى", "June": "جمادى الثانية", "July": "رجب", "August": "شعبان", "September": "رمضان", "October": "شوال", "November": "ذو القعدة", "December": "ذو الحجة", "Jan_Abbr": "محرم", "Feb_Abbr": "صفر", "Mar_Abbr": "ربيع الاول", "Apr_Abbr": "ربيع الثاني", "May_Abbr": "جمادى الاولى", "Jun_Abbr": "جمادى الثانية", "Jul_Abbr": "رجب", "Aug_Abbr": "شعبان", "Sep_Abbr": "رمضان", "Oct_Abbr": "شوال", "Nov_Abbr": "ذو القعدة", "Dec_Abbr": "ذو الحجة", "AM": "މކ", "PM": "މފ", "firstDayOfWeek": 0, "twoDigitYearMax": 1451, "mdy": "dmy", "M/d/yyyy": "dd/MM/yy", "dddd, MMMM dd, yyyy": "dd/MMMM/yyyy", "h:mm tt": "HH:mm", "h:mm:ss tt": "HH:mm:ss", "dddd, MMMM dd, yyyy h:mm:ss tt": "dd/MMMM/yyyy HH:mm:ss", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "dd MMMM", "MMMM, yyyy": "MMMM, yyyy", "/jan(uary)?/": "محرم", "/feb(ruary)?/": "صفر", "/mar(ch)?/": "ربيع الأول", "/apr(il)?/": "ربيع الثاني", "/may/": "جمادى الأولى", "/jun(e)?/": "جمادى الثانية", "/jul(y)?/": "رجب", "/aug(ust)?/": "شعبان", "/sep(t(ember)?)?/": "رمضان", "/oct(ober)?/": "شوال", "/nov(ember)?/": "ذو القعدة", "/dec(ember)?/": "ذو الحجة", "/^su(n(day)?)?/": "^الاحد", "/^mo(n(day)?)?/": "^الاثنين", "/^tu(e(s(day)?)?)?/": "^الثلاثاء", "/^we(d(nesday)?)?/": "^الاربعاء", "/^th(u(r(s(day)?)?)?)?/": "^الخميس", "/^fr(i(day)?)?/": "^الجمعة", "/^sa(t(urday)?)?/": "^السبت", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "dv-MV"; ================================================ FILE: build/production/i18n/el-GR.js ================================================ /* * DateJS Culture String File * Country Code: el-GR * Name: Greek (Greece) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["el-GR"] = { "name": "el-GR", "englishName": "Greek (Greece)", "nativeName": "ελληνικά (Ελλάδα)", "Sunday": "Κυριακή", "Monday": "Δευτέρα", "Tuesday": "Τρίτη", "Wednesday": "Τετάρτη", "Thursday": "Πέμπτη", "Friday": "Παρασκευή", "Saturday": "Σάββατο", "Sun": "Κυρ", "Mon": "Δευ", "Tue": "Τρι", "Wed": "Τετ", "Thu": "Πεμ", "Fri": "Παρ", "Sat": "Σαβ", "Su": "Κυ", "Mo": "Δε", "Tu": "Τρ", "We": "Τε", "Th": "Πε", "Fr": "Πα", "Sa": "Σά", "S_Sun_Initial": "Κ", "M_Mon_Initial": "Δ", "T_Tue_Initial": "Τ", "W_Wed_Initial": "Τ", "T_Thu_Initial": "Π", "F_Fri_Initial": "Π", "S_Sat_Initial": "Σ", "January": "Ιανουάριος", "February": "Φεβρουάριος", "March": "Μάρτιος", "April": "Απρίλιος", "May": "Μάιος", "June": "Ιούνιος", "July": "Ιούλιος", "August": "Αύγουστος", "September": "Σεπτέμβριος", "October": "Οκτώβριος", "November": "Νοέμβριος", "December": "Δεκέμβριος", "Jan_Abbr": "Ιαν", "Feb_Abbr": "Φεβ", "Mar_Abbr": "Μαρ", "Apr_Abbr": "Απρ", "May_Abbr": "Μαϊ", "Jun_Abbr": "Ιουν", "Jul_Abbr": "Ιουλ", "Aug_Abbr": "Αυγ", "Sep_Abbr": "Σεπ", "Oct_Abbr": "Οκτ", "Nov_Abbr": "Νοε", "Dec_Abbr": "Δεκ", "AM": "πμ", "PM": "μμ", "firstDayOfWeek": 1, "twoDigitYearMax": 2029, "mdy": "dmy", "M/d/yyyy": "d/M/yyyy", "dddd, MMMM dd, yyyy": "dddd, d MMMM yyyy", "h:mm tt": "h:mm tt", "h:mm:ss tt": "h:mm:ss tt", "dddd, MMMM dd, yyyy h:mm:ss tt": "dddd, d MMMM yyyy h:mm:ss tt", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "dd MMMM", "MMMM, yyyy": "MMMM yyyy", "/jan(uary)?/": "ιαν(ουάριος)?", "/feb(ruary)?/": "φεβ(ρουάριος)?", "/mar(ch)?/": "μάρτιος", "/apr(il)?/": "απρ(ίλιος)?", "/may/": "μάιος", "/jun(e)?/": "ιούνιος", "/jul(y)?/": "ιούλιος", "/aug(ust)?/": "αύγουστος", "/sep(t(ember)?)?/": "σεπ(τέμβριος)?", "/oct(ober)?/": "οκτ(ώβριος)?", "/nov(ember)?/": "νοέμβριος", "/dec(ember)?/": "δεκ(έμβριος)?", "/^su(n(day)?)?/": "^κυ(ρ(ιακή)?)?", "/^mo(n(day)?)?/": "^δε(υ(τέρα)?)?", "/^tu(e(s(day)?)?)?/": "^τρ(ι(τη)?)?", "/^we(d(nesday)?)?/": "^τε(τ(άρτη)?)?", "/^th(u(r(s(day)?)?)?)?/": "^πε(μ(πτη)?)?", "/^fr(i(day)?)?/": "^πα(ρ(ασκευή)?)?", "/^sa(t(urday)?)?/": "^σά(β(βατο)?)?", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "el-GR"; ================================================ FILE: build/production/i18n/en-029.js ================================================ /* * DateJS Culture String File * Country Code: en-029 * Name: English (Caribbean) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["en-029"] = { "name": "en-029", "englishName": "English (Caribbean)", "nativeName": "English (Caribbean)", "Sunday": "Sunday", "Monday": "Monday", "Tuesday": "Tuesday", "Wednesday": "Wednesday", "Thursday": "Thursday", "Friday": "Friday", "Saturday": "Saturday", "Sun": "Sun", "Mon": "Mon", "Tue": "Tue", "Wed": "Wed", "Thu": "Thu", "Fri": "Fri", "Sat": "Sat", "Su": "Su", "Mo": "Mo", "Tu": "Tu", "We": "We", "Th": "Th", "Fr": "Fr", "Sa": "Sa", "S_Sun_Initial": "S", "M_Mon_Initial": "M", "T_Tue_Initial": "T", "W_Wed_Initial": "W", "T_Thu_Initial": "T", "F_Fri_Initial": "F", "S_Sat_Initial": "S", "January": "January", "February": "February", "March": "March", "April": "April", "May": "May", "June": "June", "July": "July", "August": "August", "September": "September", "October": "October", "November": "November", "December": "December", "Jan_Abbr": "Jan", "Feb_Abbr": "Feb", "Mar_Abbr": "Mar", "Apr_Abbr": "Apr", "May_Abbr": "May", "Jun_Abbr": "Jun", "Jul_Abbr": "Jul", "Aug_Abbr": "Aug", "Sep_Abbr": "Sep", "Oct_Abbr": "Oct", "Nov_Abbr": "Nov", "Dec_Abbr": "Dec", "AM": "AM", "PM": "PM", "firstDayOfWeek": 1, "twoDigitYearMax": 2029, "mdy": "mdy", "M/d/yyyy": "MM/dd/yyyy", "dddd, MMMM dd, yyyy": "dddd, MMMM dd, yyyy", "h:mm tt": "h:mm tt", "h:mm:ss tt": "h:mm:ss tt", "dddd, MMMM dd, yyyy h:mm:ss tt": "dddd, MMMM dd, yyyy h:mm:ss tt", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "MMMM dd", "MMMM, yyyy": "MMMM, yyyy", "/jan(uary)?/": "jan(uary)?", "/feb(ruary)?/": "feb(ruary)?", "/mar(ch)?/": "mar(ch)?", "/apr(il)?/": "apr(il)?", "/may/": "may", "/jun(e)?/": "jun(e)?", "/jul(y)?/": "jul(y)?", "/aug(ust)?/": "aug(ust)?", "/sep(t(ember)?)?/": "sep(t(ember)?)?", "/oct(ober)?/": "oct(ober)?", "/nov(ember)?/": "nov(ember)?", "/dec(ember)?/": "dec(ember)?", "/^su(n(day)?)?/": "^su(n(day)?)?", "/^mo(n(day)?)?/": "^mo(n(day)?)?", "/^tu(e(s(day)?)?)?/": "^tu(e(s(day)?)?)?", "/^we(d(nesday)?)?/": "^we(d(nesday)?)?", "/^th(u(r(s(day)?)?)?)?/": "^th(u(r(s(day)?)?)?)?", "/^fr(i(day)?)?/": "^fr(i(day)?)?", "/^sa(t(urday)?)?/": "^sa(t(urday)?)?", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "en-029"; ================================================ FILE: build/production/i18n/en-AU.js ================================================ /* * DateJS Culture String File * Country Code: en-AU * Name: English (Australia) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["en-AU"] = { "name": "en-AU", "englishName": "English (Australia)", "nativeName": "English (Australia)", "Sunday": "Sunday", "Monday": "Monday", "Tuesday": "Tuesday", "Wednesday": "Wednesday", "Thursday": "Thursday", "Friday": "Friday", "Saturday": "Saturday", "Sun": "Sun", "Mon": "Mon", "Tue": "Tue", "Wed": "Wed", "Thu": "Thu", "Fri": "Fri", "Sat": "Sat", "Su": "Su", "Mo": "Mo", "Tu": "Tu", "We": "We", "Th": "Th", "Fr": "Fr", "Sa": "Sa", "S_Sun_Initial": "S", "M_Mon_Initial": "M", "T_Tue_Initial": "T", "W_Wed_Initial": "W", "T_Thu_Initial": "T", "F_Fri_Initial": "F", "S_Sat_Initial": "S", "January": "January", "February": "February", "March": "March", "April": "April", "May": "May", "June": "June", "July": "July", "August": "August", "September": "September", "October": "October", "November": "November", "December": "December", "Jan_Abbr": "Jan", "Feb_Abbr": "Feb", "Mar_Abbr": "Mar", "Apr_Abbr": "Apr", "May_Abbr": "May", "Jun_Abbr": "Jun", "Jul_Abbr": "Jul", "Aug_Abbr": "Aug", "Sep_Abbr": "Sep", "Oct_Abbr": "Oct", "Nov_Abbr": "Nov", "Dec_Abbr": "Dec", "AM": "AM", "PM": "PM", "firstDayOfWeek": 1, "twoDigitYearMax": 2029, "mdy": "dmy", "M/d/yyyy": "d/MM/yyyy", "dddd, MMMM dd, yyyy": "dddd, d MMMM yyyy", "h:mm tt": "h:mm tt", "h:mm:ss tt": "h:mm:ss tt", "dddd, MMMM dd, yyyy h:mm:ss tt": "dddd, d MMMM yyyy h:mm:ss tt", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "dd MMMM", "MMMM, yyyy": "MMMM yyyy", "/jan(uary)?/": "jan(uary)?", "/feb(ruary)?/": "feb(ruary)?", "/mar(ch)?/": "mar(ch)?", "/apr(il)?/": "apr(il)?", "/may/": "may", "/jun(e)?/": "jun(e)?", "/jul(y)?/": "jul(y)?", "/aug(ust)?/": "aug(ust)?", "/sep(t(ember)?)?/": "sep(t(ember)?)?", "/oct(ober)?/": "oct(ober)?", "/nov(ember)?/": "nov(ember)?", "/dec(ember)?/": "dec(ember)?", "/^su(n(day)?)?/": "^su(n(day)?)?", "/^mo(n(day)?)?/": "^mo(n(day)?)?", "/^tu(e(s(day)?)?)?/": "^tu(e(s(day)?)?)?", "/^we(d(nesday)?)?/": "^we(d(nesday)?)?", "/^th(u(r(s(day)?)?)?)?/": "^th(u(r(s(day)?)?)?)?", "/^fr(i(day)?)?/": "^fr(i(day)?)?", "/^sa(t(urday)?)?/": "^sa(t(urday)?)?", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "en-AU"; ================================================ FILE: build/production/i18n/en-BZ.js ================================================ /* * DateJS Culture String File * Country Code: en-BZ * Name: English (Belize) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["en-BZ"] = { "name": "en-BZ", "englishName": "English (Belize)", "nativeName": "English (Belize)", "Sunday": "Sunday", "Monday": "Monday", "Tuesday": "Tuesday", "Wednesday": "Wednesday", "Thursday": "Thursday", "Friday": "Friday", "Saturday": "Saturday", "Sun": "Sun", "Mon": "Mon", "Tue": "Tue", "Wed": "Wed", "Thu": "Thu", "Fri": "Fri", "Sat": "Sat", "Su": "Su", "Mo": "Mo", "Tu": "Tu", "We": "We", "Th": "Th", "Fr": "Fr", "Sa": "Sa", "S_Sun_Initial": "S", "M_Mon_Initial": "M", "T_Tue_Initial": "T", "W_Wed_Initial": "W", "T_Thu_Initial": "T", "F_Fri_Initial": "F", "S_Sat_Initial": "S", "January": "January", "February": "February", "March": "March", "April": "April", "May": "May", "June": "June", "July": "July", "August": "August", "September": "September", "October": "October", "November": "November", "December": "December", "Jan_Abbr": "Jan", "Feb_Abbr": "Feb", "Mar_Abbr": "Mar", "Apr_Abbr": "Apr", "May_Abbr": "May", "Jun_Abbr": "Jun", "Jul_Abbr": "Jul", "Aug_Abbr": "Aug", "Sep_Abbr": "Sep", "Oct_Abbr": "Oct", "Nov_Abbr": "Nov", "Dec_Abbr": "Dec", "AM": "AM", "PM": "PM", "firstDayOfWeek": 0, "twoDigitYearMax": 2029, "mdy": "dmy", "M/d/yyyy": "dd/MM/yyyy", "dddd, MMMM dd, yyyy": "dddd, dd MMMM yyyy", "h:mm tt": "hh:mm tt", "h:mm:ss tt": "hh:mm:ss tt", "dddd, MMMM dd, yyyy h:mm:ss tt": "dddd, dd MMMM yyyy hh:mm:ss tt", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "dd MMMM", "MMMM, yyyy": "MMMM yyyy", "/jan(uary)?/": "jan(uary)?", "/feb(ruary)?/": "feb(ruary)?", "/mar(ch)?/": "mar(ch)?", "/apr(il)?/": "apr(il)?", "/may/": "may", "/jun(e)?/": "jun(e)?", "/jul(y)?/": "jul(y)?", "/aug(ust)?/": "aug(ust)?", "/sep(t(ember)?)?/": "sep(t(ember)?)?", "/oct(ober)?/": "oct(ober)?", "/nov(ember)?/": "nov(ember)?", "/dec(ember)?/": "dec(ember)?", "/^su(n(day)?)?/": "^su(n(day)?)?", "/^mo(n(day)?)?/": "^mo(n(day)?)?", "/^tu(e(s(day)?)?)?/": "^tu(e(s(day)?)?)?", "/^we(d(nesday)?)?/": "^we(d(nesday)?)?", "/^th(u(r(s(day)?)?)?)?/": "^th(u(r(s(day)?)?)?)?", "/^fr(i(day)?)?/": "^fr(i(day)?)?", "/^sa(t(urday)?)?/": "^sa(t(urday)?)?", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "en-BZ"; ================================================ FILE: build/production/i18n/en-CA.js ================================================ /* * DateJS Culture String File * Country Code: en-CA * Name: English (Canada) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["en-CA"] = { "name": "en-CA", "englishName": "English (Canada)", "nativeName": "English (Canada)", "Sunday": "Sunday", "Monday": "Monday", "Tuesday": "Tuesday", "Wednesday": "Wednesday", "Thursday": "Thursday", "Friday": "Friday", "Saturday": "Saturday", "Sun": "Sun", "Mon": "Mon", "Tue": "Tue", "Wed": "Wed", "Thu": "Thu", "Fri": "Fri", "Sat": "Sat", "Su": "Su", "Mo": "Mo", "Tu": "Tu", "We": "We", "Th": "Th", "Fr": "Fr", "Sa": "Sa", "S_Sun_Initial": "S", "M_Mon_Initial": "M", "T_Tue_Initial": "T", "W_Wed_Initial": "W", "T_Thu_Initial": "T", "F_Fri_Initial": "F", "S_Sat_Initial": "S", "January": "January", "February": "February", "March": "March", "April": "April", "May": "May", "June": "June", "July": "July", "August": "August", "September": "September", "October": "October", "November": "November", "December": "December", "Jan_Abbr": "Jan", "Feb_Abbr": "Feb", "Mar_Abbr": "Mar", "Apr_Abbr": "Apr", "May_Abbr": "May", "Jun_Abbr": "Jun", "Jul_Abbr": "Jul", "Aug_Abbr": "Aug", "Sep_Abbr": "Sep", "Oct_Abbr": "Oct", "Nov_Abbr": "Nov", "Dec_Abbr": "Dec", "AM": "AM", "PM": "PM", "firstDayOfWeek": 0, "twoDigitYearMax": 2029, "mdy": "dmy", "M/d/yyyy": "dd/MM/yyyy", "dddd, MMMM dd, yyyy": "MMMM d, yyyy", "h:mm tt": "h:mm tt", "h:mm:ss tt": "h:mm:ss tt", "dddd, MMMM dd, yyyy h:mm:ss tt": "MMMM d, yyyy h:mm:ss tt", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "MMMM dd", "MMMM, yyyy": "MMMM, yyyy", "/jan(uary)?/": "jan(uary)?", "/feb(ruary)?/": "feb(ruary)?", "/mar(ch)?/": "mar(ch)?", "/apr(il)?/": "apr(il)?", "/may/": "may", "/jun(e)?/": "jun(e)?", "/jul(y)?/": "jul(y)?", "/aug(ust)?/": "aug(ust)?", "/sep(t(ember)?)?/": "sep(t(ember)?)?", "/oct(ober)?/": "oct(ober)?", "/nov(ember)?/": "nov(ember)?", "/dec(ember)?/": "dec(ember)?", "/^su(n(day)?)?/": "^su(n(day)?)?", "/^mo(n(day)?)?/": "^mo(n(day)?)?", "/^tu(e(s(day)?)?)?/": "^tu(e(s(day)?)?)?", "/^we(d(nesday)?)?/": "^we(d(nesday)?)?", "/^th(u(r(s(day)?)?)?)?/": "^th(u(r(s(day)?)?)?)?", "/^fr(i(day)?)?/": "^fr(i(day)?)?", "/^sa(t(urday)?)?/": "^sa(t(urday)?)?", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "en-CA"; ================================================ FILE: build/production/i18n/en-GB.js ================================================ /* * DateJS Culture String File * Country Code: en-GB * Name: English (United Kingdom) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["en-GB"] = { "name": "en-GB", "englishName": "English (United Kingdom)", "nativeName": "English (United Kingdom)", "Sunday": "Sunday", "Monday": "Monday", "Tuesday": "Tuesday", "Wednesday": "Wednesday", "Thursday": "Thursday", "Friday": "Friday", "Saturday": "Saturday", "Sun": "Sun", "Mon": "Mon", "Tue": "Tue", "Wed": "Wed", "Thu": "Thu", "Fri": "Fri", "Sat": "Sat", "Su": "Su", "Mo": "Mo", "Tu": "Tu", "We": "We", "Th": "Th", "Fr": "Fr", "Sa": "Sa", "S_Sun_Initial": "S", "M_Mon_Initial": "M", "T_Tue_Initial": "T", "W_Wed_Initial": "W", "T_Thu_Initial": "T", "F_Fri_Initial": "F", "S_Sat_Initial": "S", "January": "January", "February": "February", "March": "March", "April": "April", "May": "May", "June": "June", "July": "July", "August": "August", "September": "September", "October": "October", "November": "November", "December": "December", "Jan_Abbr": "Jan", "Feb_Abbr": "Feb", "Mar_Abbr": "Mar", "Apr_Abbr": "Apr", "May_Abbr": "May", "Jun_Abbr": "Jun", "Jul_Abbr": "Jul", "Aug_Abbr": "Aug", "Sep_Abbr": "Sep", "Oct_Abbr": "Oct", "Nov_Abbr": "Nov", "Dec_Abbr": "Dec", "AM": "AM", "PM": "PM", "firstDayOfWeek": 1, "twoDigitYearMax": 2029, "mdy": "dmy", "M/d/yyyy": "dd/MM/yyyy", "dddd, MMMM dd, yyyy": "dd MMMM yyyy", "h:mm tt": "HH:mm", "h:mm:ss tt": "HH:mm:ss", "dddd, MMMM dd, yyyy h:mm:ss tt": "dd MMMM yyyy HH:mm:ss", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "dd MMMM", "MMMM, yyyy": "MMMM yyyy", "/jan(uary)?/": "jan(uary)?", "/feb(ruary)?/": "feb(ruary)?", "/mar(ch)?/": "mar(ch)?", "/apr(il)?/": "apr(il)?", "/may/": "may", "/jun(e)?/": "jun(e)?", "/jul(y)?/": "jul(y)?", "/aug(ust)?/": "aug(ust)?", "/sep(t(ember)?)?/": "sep(t(ember)?)?", "/oct(ober)?/": "oct(ober)?", "/nov(ember)?/": "nov(ember)?", "/dec(ember)?/": "dec(ember)?", "/^su(n(day)?)?/": "^su(n(day)?)?", "/^mo(n(day)?)?/": "^mo(n(day)?)?", "/^tu(e(s(day)?)?)?/": "^tu(e(s(day)?)?)?", "/^we(d(nesday)?)?/": "^we(d(nesday)?)?", "/^th(u(r(s(day)?)?)?)?/": "^th(u(r(s(day)?)?)?)?", "/^fr(i(day)?)?/": "^fr(i(day)?)?", "/^sa(t(urday)?)?/": "^sa(t(urday)?)?", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "en-GB"; ================================================ FILE: build/production/i18n/en-IE.js ================================================ /* * DateJS Culture String File * Country Code: en-IE * Name: English (Ireland) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["en-IE"] = { "name": "en-IE", "englishName": "English (Ireland)", "nativeName": "English (Eire)", "Sunday": "Sunday", "Monday": "Monday", "Tuesday": "Tuesday", "Wednesday": "Wednesday", "Thursday": "Thursday", "Friday": "Friday", "Saturday": "Saturday", "Sun": "Sun", "Mon": "Mon", "Tue": "Tue", "Wed": "Wed", "Thu": "Thu", "Fri": "Fri", "Sat": "Sat", "Su": "Su", "Mo": "Mo", "Tu": "Tu", "We": "We", "Th": "Th", "Fr": "Fr", "Sa": "Sa", "S_Sun_Initial": "S", "M_Mon_Initial": "M", "T_Tue_Initial": "T", "W_Wed_Initial": "W", "T_Thu_Initial": "T", "F_Fri_Initial": "F", "S_Sat_Initial": "S", "January": "January", "February": "February", "March": "March", "April": "April", "May": "May", "June": "June", "July": "July", "August": "August", "September": "September", "October": "October", "November": "November", "December": "December", "Jan_Abbr": "Jan", "Feb_Abbr": "Feb", "Mar_Abbr": "Mar", "Apr_Abbr": "Apr", "May_Abbr": "May", "Jun_Abbr": "Jun", "Jul_Abbr": "Jul", "Aug_Abbr": "Aug", "Sep_Abbr": "Sep", "Oct_Abbr": "Oct", "Nov_Abbr": "Nov", "Dec_Abbr": "Dec", "AM": "", "PM": "", "firstDayOfWeek": 1, "twoDigitYearMax": 2029, "mdy": "dmy", "M/d/yyyy": "dd/MM/yyyy", "dddd, MMMM dd, yyyy": "dd MMMM yyyy", "h:mm tt": "HH:mm", "h:mm:ss tt": "HH:mm:ss", "dddd, MMMM dd, yyyy h:mm:ss tt": "dd MMMM yyyy HH:mm:ss", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "dd MMMM", "MMMM, yyyy": "MMMM yyyy", "/jan(uary)?/": "jan(uary)?", "/feb(ruary)?/": "feb(ruary)?", "/mar(ch)?/": "mar(ch)?", "/apr(il)?/": "apr(il)?", "/may/": "may", "/jun(e)?/": "jun(e)?", "/jul(y)?/": "jul(y)?", "/aug(ust)?/": "aug(ust)?", "/sep(t(ember)?)?/": "sep(t(ember)?)?", "/oct(ober)?/": "oct(ober)?", "/nov(ember)?/": "nov(ember)?", "/dec(ember)?/": "dec(ember)?", "/^su(n(day)?)?/": "^su(n(day)?)?", "/^mo(n(day)?)?/": "^mo(n(day)?)?", "/^tu(e(s(day)?)?)?/": "^tu(e(s(day)?)?)?", "/^we(d(nesday)?)?/": "^we(d(nesday)?)?", "/^th(u(r(s(day)?)?)?)?/": "^th(u(r(s(day)?)?)?)?", "/^fr(i(day)?)?/": "^fr(i(day)?)?", "/^sa(t(urday)?)?/": "^sa(t(urday)?)?", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "en-IE"; ================================================ FILE: build/production/i18n/en-JM.js ================================================ /* * DateJS Culture String File * Country Code: en-JM * Name: English (Jamaica) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["en-JM"] = { "name": "en-JM", "englishName": "English (Jamaica)", "nativeName": "English (Jamaica)", "Sunday": "Sunday", "Monday": "Monday", "Tuesday": "Tuesday", "Wednesday": "Wednesday", "Thursday": "Thursday", "Friday": "Friday", "Saturday": "Saturday", "Sun": "Sun", "Mon": "Mon", "Tue": "Tue", "Wed": "Wed", "Thu": "Thu", "Fri": "Fri", "Sat": "Sat", "Su": "Su", "Mo": "Mo", "Tu": "Tu", "We": "We", "Th": "Th", "Fr": "Fr", "Sa": "Sa", "S_Sun_Initial": "S", "M_Mon_Initial": "M", "T_Tue_Initial": "T", "W_Wed_Initial": "W", "T_Thu_Initial": "T", "F_Fri_Initial": "F", "S_Sat_Initial": "S", "January": "January", "February": "February", "March": "March", "April": "April", "May": "May", "June": "June", "July": "July", "August": "August", "September": "September", "October": "October", "November": "November", "December": "December", "Jan_Abbr": "Jan", "Feb_Abbr": "Feb", "Mar_Abbr": "Mar", "Apr_Abbr": "Apr", "May_Abbr": "May", "Jun_Abbr": "Jun", "Jul_Abbr": "Jul", "Aug_Abbr": "Aug", "Sep_Abbr": "Sep", "Oct_Abbr": "Oct", "Nov_Abbr": "Nov", "Dec_Abbr": "Dec", "AM": "AM", "PM": "PM", "firstDayOfWeek": 0, "twoDigitYearMax": 2029, "mdy": "dmy", "M/d/yyyy": "dd/MM/yyyy", "dddd, MMMM dd, yyyy": "dddd, MMMM dd, yyyy", "h:mm tt": "hh:mm tt", "h:mm:ss tt": "hh:mm:ss tt", "dddd, MMMM dd, yyyy h:mm:ss tt": "dddd, MMMM dd, yyyy hh:mm:ss tt", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "MMMM dd", "MMMM, yyyy": "MMMM, yyyy", "/jan(uary)?/": "jan(uary)?", "/feb(ruary)?/": "feb(ruary)?", "/mar(ch)?/": "mar(ch)?", "/apr(il)?/": "apr(il)?", "/may/": "may", "/jun(e)?/": "jun(e)?", "/jul(y)?/": "jul(y)?", "/aug(ust)?/": "aug(ust)?", "/sep(t(ember)?)?/": "sep(t(ember)?)?", "/oct(ober)?/": "oct(ober)?", "/nov(ember)?/": "nov(ember)?", "/dec(ember)?/": "dec(ember)?", "/^su(n(day)?)?/": "^su(n(day)?)?", "/^mo(n(day)?)?/": "^mo(n(day)?)?", "/^tu(e(s(day)?)?)?/": "^tu(e(s(day)?)?)?", "/^we(d(nesday)?)?/": "^we(d(nesday)?)?", "/^th(u(r(s(day)?)?)?)?/": "^th(u(r(s(day)?)?)?)?", "/^fr(i(day)?)?/": "^fr(i(day)?)?", "/^sa(t(urday)?)?/": "^sa(t(urday)?)?", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "en-JM"; ================================================ FILE: build/production/i18n/en-NZ.js ================================================ /* * DateJS Culture String File * Country Code: en-NZ * Name: English (New Zealand) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["en-NZ"] = { "name": "en-NZ", "englishName": "English (New Zealand)", "nativeName": "English (New Zealand)", "Sunday": "Sunday", "Monday": "Monday", "Tuesday": "Tuesday", "Wednesday": "Wednesday", "Thursday": "Thursday", "Friday": "Friday", "Saturday": "Saturday", "Sun": "Sun", "Mon": "Mon", "Tue": "Tue", "Wed": "Wed", "Thu": "Thu", "Fri": "Fri", "Sat": "Sat", "Su": "Su", "Mo": "Mo", "Tu": "Tu", "We": "We", "Th": "Th", "Fr": "Fr", "Sa": "Sa", "S_Sun_Initial": "S", "M_Mon_Initial": "M", "T_Tue_Initial": "T", "W_Wed_Initial": "W", "T_Thu_Initial": "T", "F_Fri_Initial": "F", "S_Sat_Initial": "S", "January": "January", "February": "February", "March": "March", "April": "April", "May": "May", "June": "June", "July": "July", "August": "August", "September": "September", "October": "October", "November": "November", "December": "December", "Jan_Abbr": "Jan", "Feb_Abbr": "Feb", "Mar_Abbr": "Mar", "Apr_Abbr": "Apr", "May_Abbr": "May", "Jun_Abbr": "Jun", "Jul_Abbr": "Jul", "Aug_Abbr": "Aug", "Sep_Abbr": "Sep", "Oct_Abbr": "Oct", "Nov_Abbr": "Nov", "Dec_Abbr": "Dec", "AM": "a.m.", "PM": "p.m.", "firstDayOfWeek": 1, "twoDigitYearMax": 2029, "mdy": "dmy", "M/d/yyyy": "d/MM/yyyy", "dddd, MMMM dd, yyyy": "dddd, d MMMM yyyy", "h:mm tt": "h:mm tt", "h:mm:ss tt": "h:mm:ss tt", "dddd, MMMM dd, yyyy h:mm:ss tt": "dddd, d MMMM yyyy h:mm:ss tt", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "dd MMMM", "MMMM, yyyy": "MMMM yyyy", "/jan(uary)?/": "jan(uary)?", "/feb(ruary)?/": "feb(ruary)?", "/mar(ch)?/": "mar(ch)?", "/apr(il)?/": "apr(il)?", "/may/": "may", "/jun(e)?/": "jun(e)?", "/jul(y)?/": "jul(y)?", "/aug(ust)?/": "aug(ust)?", "/sep(t(ember)?)?/": "sep(t(ember)?)?", "/oct(ober)?/": "oct(ober)?", "/nov(ember)?/": "nov(ember)?", "/dec(ember)?/": "dec(ember)?", "/^su(n(day)?)?/": "^su(n(day)?)?", "/^mo(n(day)?)?/": "^mo(n(day)?)?", "/^tu(e(s(day)?)?)?/": "^tu(e(s(day)?)?)?", "/^we(d(nesday)?)?/": "^we(d(nesday)?)?", "/^th(u(r(s(day)?)?)?)?/": "^th(u(r(s(day)?)?)?)?", "/^fr(i(day)?)?/": "^fr(i(day)?)?", "/^sa(t(urday)?)?/": "^sa(t(urday)?)?", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "en-NZ"; ================================================ FILE: build/production/i18n/en-PH.js ================================================ /* * DateJS Culture String File * Country Code: en-PH * Name: English (Republic of the Philippines) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["en-PH"] = { "name": "en-PH", "englishName": "English (Republic of the Philippines)", "nativeName": "English (Philippines)", "Sunday": "Sunday", "Monday": "Monday", "Tuesday": "Tuesday", "Wednesday": "Wednesday", "Thursday": "Thursday", "Friday": "Friday", "Saturday": "Saturday", "Sun": "Sun", "Mon": "Mon", "Tue": "Tue", "Wed": "Wed", "Thu": "Thu", "Fri": "Fri", "Sat": "Sat", "Su": "Su", "Mo": "Mo", "Tu": "Tu", "We": "We", "Th": "Th", "Fr": "Fr", "Sa": "Sa", "S_Sun_Initial": "S", "M_Mon_Initial": "M", "T_Tue_Initial": "T", "W_Wed_Initial": "W", "T_Thu_Initial": "T", "F_Fri_Initial": "F", "S_Sat_Initial": "S", "January": "January", "February": "February", "March": "March", "April": "April", "May": "May", "June": "June", "July": "July", "August": "August", "September": "September", "October": "October", "November": "November", "December": "December", "Jan_Abbr": "Jan", "Feb_Abbr": "Feb", "Mar_Abbr": "Mar", "Apr_Abbr": "Apr", "May_Abbr": "May", "Jun_Abbr": "Jun", "Jul_Abbr": "Jul", "Aug_Abbr": "Aug", "Sep_Abbr": "Sep", "Oct_Abbr": "Oct", "Nov_Abbr": "Nov", "Dec_Abbr": "Dec", "AM": "AM", "PM": "PM", "firstDayOfWeek": 0, "twoDigitYearMax": 2029, "mdy": "mdy", "M/d/yyyy": "M/d/yyyy", "dddd, MMMM dd, yyyy": "dddd, MMMM dd, yyyy", "h:mm tt": "h:mm tt", "h:mm:ss tt": "h:mm:ss tt", "dddd, MMMM dd, yyyy h:mm:ss tt": "dddd, MMMM dd, yyyy h:mm:ss tt", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "MMMM dd", "MMMM, yyyy": "MMMM, yyyy", "/jan(uary)?/": "jan(uary)?", "/feb(ruary)?/": "feb(ruary)?", "/mar(ch)?/": "mar(ch)?", "/apr(il)?/": "apr(il)?", "/may/": "may", "/jun(e)?/": "jun(e)?", "/jul(y)?/": "jul(y)?", "/aug(ust)?/": "aug(ust)?", "/sep(t(ember)?)?/": "sep(t(ember)?)?", "/oct(ober)?/": "oct(ober)?", "/nov(ember)?/": "nov(ember)?", "/dec(ember)?/": "dec(ember)?", "/^su(n(day)?)?/": "^su(n(day)?)?", "/^mo(n(day)?)?/": "^mo(n(day)?)?", "/^tu(e(s(day)?)?)?/": "^tu(e(s(day)?)?)?", "/^we(d(nesday)?)?/": "^we(d(nesday)?)?", "/^th(u(r(s(day)?)?)?)?/": "^th(u(r(s(day)?)?)?)?", "/^fr(i(day)?)?/": "^fr(i(day)?)?", "/^sa(t(urday)?)?/": "^sa(t(urday)?)?", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "en-PH"; ================================================ FILE: build/production/i18n/en-TT.js ================================================ /* * DateJS Culture String File * Country Code: en-TT * Name: English (Trinidad and Tobago) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["en-TT"] = { "name": "en-TT", "englishName": "English (Trinidad and Tobago)", "nativeName": "English (Trinidad y Tobago)", "Sunday": "Sunday", "Monday": "Monday", "Tuesday": "Tuesday", "Wednesday": "Wednesday", "Thursday": "Thursday", "Friday": "Friday", "Saturday": "Saturday", "Sun": "Sun", "Mon": "Mon", "Tue": "Tue", "Wed": "Wed", "Thu": "Thu", "Fri": "Fri", "Sat": "Sat", "Su": "Su", "Mo": "Mo", "Tu": "Tu", "We": "We", "Th": "Th", "Fr": "Fr", "Sa": "Sa", "S_Sun_Initial": "S", "M_Mon_Initial": "M", "T_Tue_Initial": "T", "W_Wed_Initial": "W", "T_Thu_Initial": "T", "F_Fri_Initial": "F", "S_Sat_Initial": "S", "January": "January", "February": "February", "March": "March", "April": "April", "May": "May", "June": "June", "July": "July", "August": "August", "September": "September", "October": "October", "November": "November", "December": "December", "Jan_Abbr": "Jan", "Feb_Abbr": "Feb", "Mar_Abbr": "Mar", "Apr_Abbr": "Apr", "May_Abbr": "May", "Jun_Abbr": "Jun", "Jul_Abbr": "Jul", "Aug_Abbr": "Aug", "Sep_Abbr": "Sep", "Oct_Abbr": "Oct", "Nov_Abbr": "Nov", "Dec_Abbr": "Dec", "AM": "AM", "PM": "PM", "firstDayOfWeek": 0, "twoDigitYearMax": 2029, "mdy": "dmy", "M/d/yyyy": "dd/MM/yyyy", "dddd, MMMM dd, yyyy": "dddd, dd MMMM yyyy", "h:mm tt": "hh:mm tt", "h:mm:ss tt": "hh:mm:ss tt", "dddd, MMMM dd, yyyy h:mm:ss tt": "dddd, dd MMMM yyyy hh:mm:ss tt", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "dd MMMM", "MMMM, yyyy": "MMMM yyyy", "/jan(uary)?/": "jan(uary)?", "/feb(ruary)?/": "feb(ruary)?", "/mar(ch)?/": "mar(ch)?", "/apr(il)?/": "apr(il)?", "/may/": "may", "/jun(e)?/": "jun(e)?", "/jul(y)?/": "jul(y)?", "/aug(ust)?/": "aug(ust)?", "/sep(t(ember)?)?/": "sep(t(ember)?)?", "/oct(ober)?/": "oct(ober)?", "/nov(ember)?/": "nov(ember)?", "/dec(ember)?/": "dec(ember)?", "/^su(n(day)?)?/": "^su(n(day)?)?", "/^mo(n(day)?)?/": "^mo(n(day)?)?", "/^tu(e(s(day)?)?)?/": "^tu(e(s(day)?)?)?", "/^we(d(nesday)?)?/": "^we(d(nesday)?)?", "/^th(u(r(s(day)?)?)?)?/": "^th(u(r(s(day)?)?)?)?", "/^fr(i(day)?)?/": "^fr(i(day)?)?", "/^sa(t(urday)?)?/": "^sa(t(urday)?)?", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "en-TT"; ================================================ FILE: build/production/i18n/en-ZA.js ================================================ /* * DateJS Culture String File * Country Code: en-ZA * Name: English (South Africa) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["en-ZA"] = { "name": "en-ZA", "englishName": "English (South Africa)", "nativeName": "English (South Africa)", "Sunday": "Sunday", "Monday": "Monday", "Tuesday": "Tuesday", "Wednesday": "Wednesday", "Thursday": "Thursday", "Friday": "Friday", "Saturday": "Saturday", "Sun": "Sun", "Mon": "Mon", "Tue": "Tue", "Wed": "Wed", "Thu": "Thu", "Fri": "Fri", "Sat": "Sat", "Su": "Su", "Mo": "Mo", "Tu": "Tu", "We": "We", "Th": "Th", "Fr": "Fr", "Sa": "Sa", "S_Sun_Initial": "S", "M_Mon_Initial": "M", "T_Tue_Initial": "T", "W_Wed_Initial": "W", "T_Thu_Initial": "T", "F_Fri_Initial": "F", "S_Sat_Initial": "S", "January": "January", "February": "February", "March": "March", "April": "April", "May": "May", "June": "June", "July": "July", "August": "August", "September": "September", "October": "October", "November": "November", "December": "December", "Jan_Abbr": "Jan", "Feb_Abbr": "Feb", "Mar_Abbr": "Mar", "Apr_Abbr": "Apr", "May_Abbr": "May", "Jun_Abbr": "Jun", "Jul_Abbr": "Jul", "Aug_Abbr": "Aug", "Sep_Abbr": "Sep", "Oct_Abbr": "Oct", "Nov_Abbr": "Nov", "Dec_Abbr": "Dec", "AM": "AM", "PM": "PM", "firstDayOfWeek": 0, "twoDigitYearMax": 2029, "mdy": "ymd", "M/d/yyyy": "yyyy/MM/dd", "dddd, MMMM dd, yyyy": "dd MMMM yyyy", "h:mm tt": "hh:mm tt", "h:mm:ss tt": "hh:mm:ss tt", "dddd, MMMM dd, yyyy h:mm:ss tt": "dd MMMM yyyy hh:mm:ss tt", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "dd MMMM", "MMMM, yyyy": "MMMM yyyy", "/jan(uary)?/": "jan(uary)?", "/feb(ruary)?/": "feb(ruary)?", "/mar(ch)?/": "mar(ch)?", "/apr(il)?/": "apr(il)?", "/may/": "may", "/jun(e)?/": "jun(e)?", "/jul(y)?/": "jul(y)?", "/aug(ust)?/": "aug(ust)?", "/sep(t(ember)?)?/": "sep(t(ember)?)?", "/oct(ober)?/": "oct(ober)?", "/nov(ember)?/": "nov(ember)?", "/dec(ember)?/": "dec(ember)?", "/^su(n(day)?)?/": "^su(n(day)?)?", "/^mo(n(day)?)?/": "^mo(n(day)?)?", "/^tu(e(s(day)?)?)?/": "^tu(e(s(day)?)?)?", "/^we(d(nesday)?)?/": "^we(d(nesday)?)?", "/^th(u(r(s(day)?)?)?)?/": "^th(u(r(s(day)?)?)?)?", "/^fr(i(day)?)?/": "^fr(i(day)?)?", "/^sa(t(urday)?)?/": "^sa(t(urday)?)?", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "en-ZA"; ================================================ FILE: build/production/i18n/en-ZW.js ================================================ /* * DateJS Culture String File * Country Code: en-ZW * Name: English (Zimbabwe) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["en-ZW"] = { "name": "en-ZW", "englishName": "English (Zimbabwe)", "nativeName": "English (Zimbabwe)", "Sunday": "Sunday", "Monday": "Monday", "Tuesday": "Tuesday", "Wednesday": "Wednesday", "Thursday": "Thursday", "Friday": "Friday", "Saturday": "Saturday", "Sun": "Sun", "Mon": "Mon", "Tue": "Tue", "Wed": "Wed", "Thu": "Thu", "Fri": "Fri", "Sat": "Sat", "Su": "Su", "Mo": "Mo", "Tu": "Tu", "We": "We", "Th": "Th", "Fr": "Fr", "Sa": "Sa", "S_Sun_Initial": "S", "M_Mon_Initial": "M", "T_Tue_Initial": "T", "W_Wed_Initial": "W", "T_Thu_Initial": "T", "F_Fri_Initial": "F", "S_Sat_Initial": "S", "January": "January", "February": "February", "March": "March", "April": "April", "May": "May", "June": "June", "July": "July", "August": "August", "September": "September", "October": "October", "November": "November", "December": "December", "Jan_Abbr": "Jan", "Feb_Abbr": "Feb", "Mar_Abbr": "Mar", "Apr_Abbr": "Apr", "May_Abbr": "May", "Jun_Abbr": "Jun", "Jul_Abbr": "Jul", "Aug_Abbr": "Aug", "Sep_Abbr": "Sep", "Oct_Abbr": "Oct", "Nov_Abbr": "Nov", "Dec_Abbr": "Dec", "AM": "AM", "PM": "PM", "firstDayOfWeek": 0, "twoDigitYearMax": 2029, "mdy": "mdy", "M/d/yyyy": "M/d/yyyy", "dddd, MMMM dd, yyyy": "dddd, MMMM dd, yyyy", "h:mm tt": "h:mm tt", "h:mm:ss tt": "h:mm:ss tt", "dddd, MMMM dd, yyyy h:mm:ss tt": "dddd, MMMM dd, yyyy h:mm:ss tt", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "MMMM dd", "MMMM, yyyy": "MMMM, yyyy", "/jan(uary)?/": "jan(uary)?", "/feb(ruary)?/": "feb(ruary)?", "/mar(ch)?/": "mar(ch)?", "/apr(il)?/": "apr(il)?", "/may/": "may", "/jun(e)?/": "jun(e)?", "/jul(y)?/": "jul(y)?", "/aug(ust)?/": "aug(ust)?", "/sep(t(ember)?)?/": "sep(t(ember)?)?", "/oct(ober)?/": "oct(ober)?", "/nov(ember)?/": "nov(ember)?", "/dec(ember)?/": "dec(ember)?", "/^su(n(day)?)?/": "^su(n(day)?)?", "/^mo(n(day)?)?/": "^mo(n(day)?)?", "/^tu(e(s(day)?)?)?/": "^tu(e(s(day)?)?)?", "/^we(d(nesday)?)?/": "^we(d(nesday)?)?", "/^th(u(r(s(day)?)?)?)?/": "^th(u(r(s(day)?)?)?)?", "/^fr(i(day)?)?/": "^fr(i(day)?)?", "/^sa(t(urday)?)?/": "^sa(t(urday)?)?", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "en-ZW"; ================================================ FILE: build/production/i18n/es-AR.js ================================================ /* * DateJS Culture String File * Country Code: es-AR * Name: Spanish (Argentina) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["es-AR"] = { "name": "es-AR", "englishName": "Spanish (Argentina)", "nativeName": "Español (Argentina)", "Sunday": "domingo", "Monday": "lunes", "Tuesday": "martes", "Wednesday": "miércoles", "Thursday": "jueves", "Friday": "viernes", "Saturday": "sábado", "Sun": "dom", "Mon": "lun", "Tue": "mar", "Wed": "mié", "Thu": "jue", "Fri": "vie", "Sat": "sáb", "Su": "do", "Mo": "lu", "Tu": "ma", "We": "mi", "Th": "ju", "Fr": "vi", "Sa": "sá", "S_Sun_Initial": "d", "M_Mon_Initial": "l", "T_Tue_Initial": "m", "W_Wed_Initial": "m", "T_Thu_Initial": "j", "F_Fri_Initial": "v", "S_Sat_Initial": "s", "January": "enero", "February": "febrero", "March": "marzo", "April": "abril", "May": "mayo", "June": "junio", "July": "julio", "August": "agosto", "September": "septiembre", "October": "octubre", "November": "noviembre", "December": "diciembre", "Jan_Abbr": "ene", "Feb_Abbr": "feb", "Mar_Abbr": "mar", "Apr_Abbr": "abr", "May_Abbr": "may", "Jun_Abbr": "jun", "Jul_Abbr": "jul", "Aug_Abbr": "ago", "Sep_Abbr": "sep", "Oct_Abbr": "oct", "Nov_Abbr": "nov", "Dec_Abbr": "dic", "AM": "a.m.", "PM": "p.m.", "firstDayOfWeek": 0, "twoDigitYearMax": 2029, "mdy": "dmy", "M/d/yyyy": "dd/MM/yyyy", "dddd, MMMM dd, yyyy": "dddd, dd' de 'MMMM' de 'yyyy", "h:mm tt": "hh:mm tt", "h:mm:ss tt": "hh:mm:ss tt", "dddd, MMMM dd, yyyy h:mm:ss tt": "dddd, dd' de 'MMMM' de 'yyyy hh:mm:ss tt", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "dd MMMM", "MMMM, yyyy": "MMMM' de 'yyyy", "/jan(uary)?/": "ene(ro)?", "/feb(ruary)?/": "feb(rero)?", "/mar(ch)?/": "mar(zo)?", "/apr(il)?/": "abr(il)?", "/may/": "may(o)?", "/jun(e)?/": "jun(io)?", "/jul(y)?/": "jul(io)?", "/aug(ust)?/": "ago(sto)?", "/sep(t(ember)?)?/": "sep(tiembre)?", "/oct(ober)?/": "oct(ubre)?", "/nov(ember)?/": "nov(iembre)?", "/dec(ember)?/": "dic(iembre)?", "/^su(n(day)?)?/": "^do(m(ingo)?)?", "/^mo(n(day)?)?/": "^lu(n(es)?)?", "/^tu(e(s(day)?)?)?/": "^ma(r(tes)?)?", "/^we(d(nesday)?)?/": "^mi(é(rcoles)?)?", "/^th(u(r(s(day)?)?)?)?/": "^ju(e(ves)?)?", "/^fr(i(day)?)?/": "^vi(e(rnes)?)?", "/^sa(t(urday)?)?/": "^sá(b(ado)?)?", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "es-AR"; ================================================ FILE: build/production/i18n/es-BO.js ================================================ /* * DateJS Culture String File * Country Code: es-BO * Name: Spanish (Bolivia) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["es-BO"] = { "name": "es-BO", "englishName": "Spanish (Bolivia)", "nativeName": "Español (Bolivia)", "Sunday": "domingo", "Monday": "lunes", "Tuesday": "martes", "Wednesday": "miércoles", "Thursday": "jueves", "Friday": "viernes", "Saturday": "sábado", "Sun": "dom", "Mon": "lun", "Tue": "mar", "Wed": "mié", "Thu": "jue", "Fri": "vie", "Sat": "sáb", "Su": "do", "Mo": "lu", "Tu": "ma", "We": "mi", "Th": "ju", "Fr": "vi", "Sa": "sá", "S_Sun_Initial": "d", "M_Mon_Initial": "l", "T_Tue_Initial": "m", "W_Wed_Initial": "m", "T_Thu_Initial": "j", "F_Fri_Initial": "v", "S_Sat_Initial": "s", "January": "enero", "February": "febrero", "March": "marzo", "April": "abril", "May": "mayo", "June": "junio", "July": "julio", "August": "agosto", "September": "septiembre", "October": "octubre", "November": "noviembre", "December": "diciembre", "Jan_Abbr": "ene", "Feb_Abbr": "feb", "Mar_Abbr": "mar", "Apr_Abbr": "abr", "May_Abbr": "may", "Jun_Abbr": "jun", "Jul_Abbr": "jul", "Aug_Abbr": "ago", "Sep_Abbr": "sep", "Oct_Abbr": "oct", "Nov_Abbr": "nov", "Dec_Abbr": "dic", "AM": "a.m.", "PM": "p.m.", "firstDayOfWeek": 0, "twoDigitYearMax": 2029, "mdy": "dmy", "M/d/yyyy": "dd/MM/yyyy", "dddd, MMMM dd, yyyy": "dddd, dd' de 'MMMM' de 'yyyy", "h:mm tt": "hh:mm tt", "h:mm:ss tt": "hh:mm:ss tt", "dddd, MMMM dd, yyyy h:mm:ss tt": "dddd, dd' de 'MMMM' de 'yyyy hh:mm:ss tt", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "dd MMMM", "MMMM, yyyy": "MMMM' de 'yyyy", "/jan(uary)?/": "ene(ro)?", "/feb(ruary)?/": "feb(rero)?", "/mar(ch)?/": "mar(zo)?", "/apr(il)?/": "abr(il)?", "/may/": "may(o)?", "/jun(e)?/": "jun(io)?", "/jul(y)?/": "jul(io)?", "/aug(ust)?/": "ago(sto)?", "/sep(t(ember)?)?/": "sep(tiembre)?", "/oct(ober)?/": "oct(ubre)?", "/nov(ember)?/": "nov(iembre)?", "/dec(ember)?/": "dic(iembre)?", "/^su(n(day)?)?/": "^do(m(ingo)?)?", "/^mo(n(day)?)?/": "^lu(n(es)?)?", "/^tu(e(s(day)?)?)?/": "^ma(r(tes)?)?", "/^we(d(nesday)?)?/": "^mi(é(rcoles)?)?", "/^th(u(r(s(day)?)?)?)?/": "^ju(e(ves)?)?", "/^fr(i(day)?)?/": "^vi(e(rnes)?)?", "/^sa(t(urday)?)?/": "^sá(b(ado)?)?", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "es-BO"; ================================================ FILE: build/production/i18n/es-CL.js ================================================ /* * DateJS Culture String File * Country Code: es-CL * Name: Spanish (Chile) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["es-CL"] = { "name": "es-CL", "englishName": "Spanish (Chile)", "nativeName": "Español (Chile)", "Sunday": "domingo", "Monday": "lunes", "Tuesday": "martes", "Wednesday": "miércoles", "Thursday": "jueves", "Friday": "viernes", "Saturday": "sábado", "Sun": "dom", "Mon": "lun", "Tue": "mar", "Wed": "mié", "Thu": "jue", "Fri": "vie", "Sat": "sáb", "Su": "do", "Mo": "lu", "Tu": "ma", "We": "mi", "Th": "ju", "Fr": "vi", "Sa": "sá", "S_Sun_Initial": "d", "M_Mon_Initial": "l", "T_Tue_Initial": "m", "W_Wed_Initial": "m", "T_Thu_Initial": "j", "F_Fri_Initial": "v", "S_Sat_Initial": "s", "January": "enero", "February": "febrero", "March": "marzo", "April": "abril", "May": "mayo", "June": "junio", "July": "julio", "August": "agosto", "September": "septiembre", "October": "octubre", "November": "noviembre", "December": "diciembre", "Jan_Abbr": "ene", "Feb_Abbr": "feb", "Mar_Abbr": "mar", "Apr_Abbr": "abr", "May_Abbr": "may", "Jun_Abbr": "jun", "Jul_Abbr": "jul", "Aug_Abbr": "ago", "Sep_Abbr": "sep", "Oct_Abbr": "oct", "Nov_Abbr": "nov", "Dec_Abbr": "dic", "AM": "", "PM": "", "firstDayOfWeek": 0, "twoDigitYearMax": 2029, "mdy": "dmy", "M/d/yyyy": "dd-MM-yyyy", "dddd, MMMM dd, yyyy": "dddd, dd' de 'MMMM' de 'yyyy", "h:mm tt": "H:mm", "h:mm:ss tt": "H:mm:ss", "dddd, MMMM dd, yyyy h:mm:ss tt": "dddd, dd' de 'MMMM' de 'yyyy H:mm:ss", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "dd MMMM", "MMMM, yyyy": "MMMM' de 'yyyy", "/jan(uary)?/": "ene(ro)?", "/feb(ruary)?/": "feb(rero)?", "/mar(ch)?/": "mar(zo)?", "/apr(il)?/": "abr(il)?", "/may/": "may(o)?", "/jun(e)?/": "jun(io)?", "/jul(y)?/": "jul(io)?", "/aug(ust)?/": "ago(sto)?", "/sep(t(ember)?)?/": "sep(tiembre)?", "/oct(ober)?/": "oct(ubre)?", "/nov(ember)?/": "nov(iembre)?", "/dec(ember)?/": "dic(iembre)?", "/^su(n(day)?)?/": "^do(m(ingo)?)?", "/^mo(n(day)?)?/": "^lu(n(es)?)?", "/^tu(e(s(day)?)?)?/": "^ma(r(tes)?)?", "/^we(d(nesday)?)?/": "^mi(é(rcoles)?)?", "/^th(u(r(s(day)?)?)?)?/": "^ju(e(ves)?)?", "/^fr(i(day)?)?/": "^vi(e(rnes)?)?", "/^sa(t(urday)?)?/": "^sá(b(ado)?)?", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "es-CL"; ================================================ FILE: build/production/i18n/es-CO.js ================================================ /* * DateJS Culture String File * Country Code: es-CO * Name: Spanish (Colombia) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["es-CO"] = { "name": "es-CO", "englishName": "Spanish (Colombia)", "nativeName": "Español (Colombia)", "Sunday": "domingo", "Monday": "lunes", "Tuesday": "martes", "Wednesday": "miércoles", "Thursday": "jueves", "Friday": "viernes", "Saturday": "sábado", "Sun": "dom", "Mon": "lun", "Tue": "mar", "Wed": "mié", "Thu": "jue", "Fri": "vie", "Sat": "sáb", "Su": "do", "Mo": "lu", "Tu": "ma", "We": "mi", "Th": "ju", "Fr": "vi", "Sa": "sá", "S_Sun_Initial": "d", "M_Mon_Initial": "l", "T_Tue_Initial": "m", "W_Wed_Initial": "m", "T_Thu_Initial": "j", "F_Fri_Initial": "v", "S_Sat_Initial": "s", "January": "enero", "February": "febrero", "March": "marzo", "April": "abril", "May": "mayo", "June": "junio", "July": "julio", "August": "agosto", "September": "septiembre", "October": "octubre", "November": "noviembre", "December": "diciembre", "Jan_Abbr": "ene", "Feb_Abbr": "feb", "Mar_Abbr": "mar", "Apr_Abbr": "abr", "May_Abbr": "may", "Jun_Abbr": "jun", "Jul_Abbr": "jul", "Aug_Abbr": "ago", "Sep_Abbr": "sep", "Oct_Abbr": "oct", "Nov_Abbr": "nov", "Dec_Abbr": "dic", "AM": "a.m.", "PM": "p.m.", "firstDayOfWeek": 0, "twoDigitYearMax": 2029, "mdy": "dmy", "M/d/yyyy": "dd/MM/yyyy", "dddd, MMMM dd, yyyy": "dddd, dd' de 'MMMM' de 'yyyy", "h:mm tt": "hh:mm tt", "h:mm:ss tt": "hh:mm:ss tt", "dddd, MMMM dd, yyyy h:mm:ss tt": "dddd, dd' de 'MMMM' de 'yyyy hh:mm:ss tt", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "dd MMMM", "MMMM, yyyy": "MMMM' de 'yyyy", "/jan(uary)?/": "ene(ro)?", "/feb(ruary)?/": "feb(rero)?", "/mar(ch)?/": "mar(zo)?", "/apr(il)?/": "abr(il)?", "/may/": "may(o)?", "/jun(e)?/": "jun(io)?", "/jul(y)?/": "jul(io)?", "/aug(ust)?/": "ago(sto)?", "/sep(t(ember)?)?/": "sep(tiembre)?", "/oct(ober)?/": "oct(ubre)?", "/nov(ember)?/": "nov(iembre)?", "/dec(ember)?/": "dic(iembre)?", "/^su(n(day)?)?/": "^do(m(ingo)?)?", "/^mo(n(day)?)?/": "^lu(n(es)?)?", "/^tu(e(s(day)?)?)?/": "^ma(r(tes)?)?", "/^we(d(nesday)?)?/": "^mi(é(rcoles)?)?", "/^th(u(r(s(day)?)?)?)?/": "^ju(e(ves)?)?", "/^fr(i(day)?)?/": "^vi(e(rnes)?)?", "/^sa(t(urday)?)?/": "^sá(b(ado)?)?", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "es-CO"; ================================================ FILE: build/production/i18n/es-CR.js ================================================ /* * DateJS Culture String File * Country Code: es-CR * Name: Spanish (Costa Rica) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["es-CR"] = { "name": "es-CR", "englishName": "Spanish (Costa Rica)", "nativeName": "Español (Costa Rica)", "Sunday": "domingo", "Monday": "lunes", "Tuesday": "martes", "Wednesday": "miércoles", "Thursday": "jueves", "Friday": "viernes", "Saturday": "sábado", "Sun": "dom", "Mon": "lun", "Tue": "mar", "Wed": "mié", "Thu": "jue", "Fri": "vie", "Sat": "sáb", "Su": "do", "Mo": "lu", "Tu": "ma", "We": "mi", "Th": "ju", "Fr": "vi", "Sa": "sá", "S_Sun_Initial": "d", "M_Mon_Initial": "l", "T_Tue_Initial": "m", "W_Wed_Initial": "m", "T_Thu_Initial": "j", "F_Fri_Initial": "v", "S_Sat_Initial": "s", "January": "enero", "February": "febrero", "March": "marzo", "April": "abril", "May": "mayo", "June": "junio", "July": "julio", "August": "agosto", "September": "septiembre", "October": "octubre", "November": "noviembre", "December": "diciembre", "Jan_Abbr": "ene", "Feb_Abbr": "feb", "Mar_Abbr": "mar", "Apr_Abbr": "abr", "May_Abbr": "may", "Jun_Abbr": "jun", "Jul_Abbr": "jul", "Aug_Abbr": "ago", "Sep_Abbr": "sep", "Oct_Abbr": "oct", "Nov_Abbr": "nov", "Dec_Abbr": "dic", "AM": "a.m.", "PM": "p.m.", "firstDayOfWeek": 0, "twoDigitYearMax": 2029, "mdy": "dmy", "M/d/yyyy": "dd/MM/yyyy", "dddd, MMMM dd, yyyy": "dddd, dd' de 'MMMM' de 'yyyy", "h:mm tt": "hh:mm tt", "h:mm:ss tt": "hh:mm:ss tt", "dddd, MMMM dd, yyyy h:mm:ss tt": "dddd, dd' de 'MMMM' de 'yyyy hh:mm:ss tt", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "dd MMMM", "MMMM, yyyy": "MMMM' de 'yyyy", "/jan(uary)?/": "ene(ro)?", "/feb(ruary)?/": "feb(rero)?", "/mar(ch)?/": "mar(zo)?", "/apr(il)?/": "abr(il)?", "/may/": "may(o)?", "/jun(e)?/": "jun(io)?", "/jul(y)?/": "jul(io)?", "/aug(ust)?/": "ago(sto)?", "/sep(t(ember)?)?/": "sep(tiembre)?", "/oct(ober)?/": "oct(ubre)?", "/nov(ember)?/": "nov(iembre)?", "/dec(ember)?/": "dic(iembre)?", "/^su(n(day)?)?/": "^do(m(ingo)?)?", "/^mo(n(day)?)?/": "^lu(n(es)?)?", "/^tu(e(s(day)?)?)?/": "^ma(r(tes)?)?", "/^we(d(nesday)?)?/": "^mi(é(rcoles)?)?", "/^th(u(r(s(day)?)?)?)?/": "^ju(e(ves)?)?", "/^fr(i(day)?)?/": "^vi(e(rnes)?)?", "/^sa(t(urday)?)?/": "^sá(b(ado)?)?", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "es-CR"; ================================================ FILE: build/production/i18n/es-DO.js ================================================ /* * DateJS Culture String File * Country Code: es-DO * Name: Spanish (Dominican Republic) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["es-DO"] = { "name": "es-DO", "englishName": "Spanish (Dominican Republic)", "nativeName": "Español (República Dominicana)", "Sunday": "domingo", "Monday": "lunes", "Tuesday": "martes", "Wednesday": "miércoles", "Thursday": "jueves", "Friday": "viernes", "Saturday": "sábado", "Sun": "dom", "Mon": "lun", "Tue": "mar", "Wed": "mié", "Thu": "jue", "Fri": "vie", "Sat": "sáb", "Su": "do", "Mo": "lu", "Tu": "ma", "We": "mi", "Th": "ju", "Fr": "vi", "Sa": "sá", "S_Sun_Initial": "d", "M_Mon_Initial": "l", "T_Tue_Initial": "m", "W_Wed_Initial": "m", "T_Thu_Initial": "j", "F_Fri_Initial": "v", "S_Sat_Initial": "s", "January": "enero", "February": "febrero", "March": "marzo", "April": "abril", "May": "mayo", "June": "junio", "July": "julio", "August": "agosto", "September": "septiembre", "October": "octubre", "November": "noviembre", "December": "diciembre", "Jan_Abbr": "ene", "Feb_Abbr": "feb", "Mar_Abbr": "mar", "Apr_Abbr": "abr", "May_Abbr": "may", "Jun_Abbr": "jun", "Jul_Abbr": "jul", "Aug_Abbr": "ago", "Sep_Abbr": "sep", "Oct_Abbr": "oct", "Nov_Abbr": "nov", "Dec_Abbr": "dic", "AM": "a.m.", "PM": "p.m.", "firstDayOfWeek": 0, "twoDigitYearMax": 2029, "mdy": "dmy", "M/d/yyyy": "dd/MM/yyyy", "dddd, MMMM dd, yyyy": "dddd, dd' de 'MMMM' de 'yyyy", "h:mm tt": "hh:mm tt", "h:mm:ss tt": "hh:mm:ss tt", "dddd, MMMM dd, yyyy h:mm:ss tt": "dddd, dd' de 'MMMM' de 'yyyy hh:mm:ss tt", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "dd MMMM", "MMMM, yyyy": "MMMM' de 'yyyy", "/jan(uary)?/": "ene(ro)?", "/feb(ruary)?/": "feb(rero)?", "/mar(ch)?/": "mar(zo)?", "/apr(il)?/": "abr(il)?", "/may/": "may(o)?", "/jun(e)?/": "jun(io)?", "/jul(y)?/": "jul(io)?", "/aug(ust)?/": "ago(sto)?", "/sep(t(ember)?)?/": "sep(tiembre)?", "/oct(ober)?/": "oct(ubre)?", "/nov(ember)?/": "nov(iembre)?", "/dec(ember)?/": "dic(iembre)?", "/^su(n(day)?)?/": "^do(m(ingo)?)?", "/^mo(n(day)?)?/": "^lu(n(es)?)?", "/^tu(e(s(day)?)?)?/": "^ma(r(tes)?)?", "/^we(d(nesday)?)?/": "^mi(é(rcoles)?)?", "/^th(u(r(s(day)?)?)?)?/": "^ju(e(ves)?)?", "/^fr(i(day)?)?/": "^vi(e(rnes)?)?", "/^sa(t(urday)?)?/": "^sá(b(ado)?)?", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "es-DO"; ================================================ FILE: build/production/i18n/es-EC.js ================================================ /* * DateJS Culture String File * Country Code: es-EC * Name: Spanish (Ecuador) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["es-EC"] = { "name": "es-EC", "englishName": "Spanish (Ecuador)", "nativeName": "Español (Ecuador)", "Sunday": "domingo", "Monday": "lunes", "Tuesday": "martes", "Wednesday": "miércoles", "Thursday": "jueves", "Friday": "viernes", "Saturday": "sábado", "Sun": "dom", "Mon": "lun", "Tue": "mar", "Wed": "mié", "Thu": "jue", "Fri": "vie", "Sat": "sáb", "Su": "do", "Mo": "lu", "Tu": "ma", "We": "mi", "Th": "ju", "Fr": "vi", "Sa": "sá", "S_Sun_Initial": "d", "M_Mon_Initial": "l", "T_Tue_Initial": "m", "W_Wed_Initial": "m", "T_Thu_Initial": "j", "F_Fri_Initial": "v", "S_Sat_Initial": "s", "January": "enero", "February": "febrero", "March": "marzo", "April": "abril", "May": "mayo", "June": "junio", "July": "julio", "August": "agosto", "September": "septiembre", "October": "octubre", "November": "noviembre", "December": "diciembre", "Jan_Abbr": "ene", "Feb_Abbr": "feb", "Mar_Abbr": "mar", "Apr_Abbr": "abr", "May_Abbr": "may", "Jun_Abbr": "jun", "Jul_Abbr": "jul", "Aug_Abbr": "ago", "Sep_Abbr": "sep", "Oct_Abbr": "oct", "Nov_Abbr": "nov", "Dec_Abbr": "dic", "AM": "", "PM": "", "firstDayOfWeek": 0, "twoDigitYearMax": 2029, "mdy": "dmy", "M/d/yyyy": "dd/MM/yyyy", "dddd, MMMM dd, yyyy": "dddd, dd' de 'MMMM' de 'yyyy", "h:mm tt": "H:mm", "h:mm:ss tt": "H:mm:ss", "dddd, MMMM dd, yyyy h:mm:ss tt": "dddd, dd' de 'MMMM' de 'yyyy H:mm:ss", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "dd MMMM", "MMMM, yyyy": "MMMM' de 'yyyy", "/jan(uary)?/": "ene(ro)?", "/feb(ruary)?/": "feb(rero)?", "/mar(ch)?/": "mar(zo)?", "/apr(il)?/": "abr(il)?", "/may/": "may(o)?", "/jun(e)?/": "jun(io)?", "/jul(y)?/": "jul(io)?", "/aug(ust)?/": "ago(sto)?", "/sep(t(ember)?)?/": "sep(tiembre)?", "/oct(ober)?/": "oct(ubre)?", "/nov(ember)?/": "nov(iembre)?", "/dec(ember)?/": "dic(iembre)?", "/^su(n(day)?)?/": "^do(m(ingo)?)?", "/^mo(n(day)?)?/": "^lu(n(es)?)?", "/^tu(e(s(day)?)?)?/": "^ma(r(tes)?)?", "/^we(d(nesday)?)?/": "^mi(é(rcoles)?)?", "/^th(u(r(s(day)?)?)?)?/": "^ju(e(ves)?)?", "/^fr(i(day)?)?/": "^vi(e(rnes)?)?", "/^sa(t(urday)?)?/": "^sá(b(ado)?)?", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "es-EC"; ================================================ FILE: build/production/i18n/es-ES.js ================================================ /* * DateJS Culture String File * Country Code: es-ES * Name: Spanish (Spain) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["es-ES"] = { "name": "es-ES", "englishName": "Spanish (Spain)", "nativeName": "español (España)", "Sunday": "domingo", "Monday": "lunes", "Tuesday": "martes", "Wednesday": "miércoles", "Thursday": "jueves", "Friday": "viernes", "Saturday": "sábado", "Sun": "dom", "Mon": "lun", "Tue": "mar", "Wed": "mié", "Thu": "jue", "Fri": "vie", "Sat": "sáb", "Su": "do", "Mo": "lu", "Tu": "ma", "We": "mi", "Th": "ju", "Fr": "vi", "Sa": "sá", "S_Sun_Initial": "d", "M_Mon_Initial": "l", "T_Tue_Initial": "m", "W_Wed_Initial": "m", "T_Thu_Initial": "j", "F_Fri_Initial": "v", "S_Sat_Initial": "s", "January": "enero", "February": "febrero", "March": "marzo", "April": "abril", "May": "mayo", "June": "junio", "July": "julio", "August": "agosto", "September": "septiembre", "October": "octubre", "November": "noviembre", "December": "diciembre", "Jan_Abbr": "ene", "Feb_Abbr": "feb", "Mar_Abbr": "mar", "Apr_Abbr": "abr", "May_Abbr": "may", "Jun_Abbr": "jun", "Jul_Abbr": "jul", "Aug_Abbr": "ago", "Sep_Abbr": "sep", "Oct_Abbr": "oct", "Nov_Abbr": "nov", "Dec_Abbr": "dic", "AM": "", "PM": "", "firstDayOfWeek": 1, "twoDigitYearMax": 2029, "mdy": "dmy", "M/d/yyyy": "dd/MM/yyyy", "dddd, MMMM dd, yyyy": "dddd, dd' de 'MMMM' de 'yyyy", "h:mm tt": "H:mm", "h:mm:ss tt": "H:mm:ss", "dddd, MMMM dd, yyyy h:mm:ss tt": "dddd, dd' de 'MMMM' de 'yyyy H:mm:ss", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "dd MMMM", "MMMM, yyyy": "MMMM' de 'yyyy", "/jan(uary)?/": "ene(ro)?", "/feb(ruary)?/": "feb(rero)?", "/mar(ch)?/": "mar(zo)?", "/apr(il)?/": "abr(il)?", "/may/": "may(o)?", "/jun(e)?/": "jun(io)?", "/jul(y)?/": "jul(io)?", "/aug(ust)?/": "ago(sto)?", "/sep(t(ember)?)?/": "sep(tiembre)?", "/oct(ober)?/": "oct(ubre)?", "/nov(ember)?/": "nov(iembre)?", "/dec(ember)?/": "dic(iembre)?", "/^su(n(day)?)?/": "^do(m(ingo)?)?", "/^mo(n(day)?)?/": "^lu(n(es)?)?", "/^tu(e(s(day)?)?)?/": "^ma(r(tes)?)?", "/^we(d(nesday)?)?/": "^mi(é(rcoles)?)?", "/^th(u(r(s(day)?)?)?)?/": "^ju(e(ves)?)?", "/^fr(i(day)?)?/": "^vi(e(rnes)?)?", "/^sa(t(urday)?)?/": "^sá(b(ado)?)?", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "es-ES"; ================================================ FILE: build/production/i18n/es-GT.js ================================================ /* * DateJS Culture String File * Country Code: es-GT * Name: Spanish (Guatemala) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["es-GT"] = { "name": "es-GT", "englishName": "Spanish (Guatemala)", "nativeName": "Español (Guatemala)", "Sunday": "domingo", "Monday": "lunes", "Tuesday": "martes", "Wednesday": "miércoles", "Thursday": "jueves", "Friday": "viernes", "Saturday": "sábado", "Sun": "dom", "Mon": "lun", "Tue": "mar", "Wed": "mié", "Thu": "jue", "Fri": "vie", "Sat": "sáb", "Su": "do", "Mo": "lu", "Tu": "ma", "We": "mi", "Th": "ju", "Fr": "vi", "Sa": "sá", "S_Sun_Initial": "d", "M_Mon_Initial": "l", "T_Tue_Initial": "m", "W_Wed_Initial": "m", "T_Thu_Initial": "j", "F_Fri_Initial": "v", "S_Sat_Initial": "s", "January": "enero", "February": "febrero", "March": "marzo", "April": "abril", "May": "mayo", "June": "junio", "July": "julio", "August": "agosto", "September": "septiembre", "October": "octubre", "November": "noviembre", "December": "diciembre", "Jan_Abbr": "ene", "Feb_Abbr": "feb", "Mar_Abbr": "mar", "Apr_Abbr": "abr", "May_Abbr": "may", "Jun_Abbr": "jun", "Jul_Abbr": "jul", "Aug_Abbr": "ago", "Sep_Abbr": "sep", "Oct_Abbr": "oct", "Nov_Abbr": "nov", "Dec_Abbr": "dic", "AM": "a.m.", "PM": "p.m.", "firstDayOfWeek": 0, "twoDigitYearMax": 2029, "mdy": "dmy", "M/d/yyyy": "dd/MM/yyyy", "dddd, MMMM dd, yyyy": "dddd, dd' de 'MMMM' de 'yyyy", "h:mm tt": "hh:mm tt", "h:mm:ss tt": "hh:mm:ss tt", "dddd, MMMM dd, yyyy h:mm:ss tt": "dddd, dd' de 'MMMM' de 'yyyy hh:mm:ss tt", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "dd MMMM", "MMMM, yyyy": "MMMM' de 'yyyy", "/jan(uary)?/": "ene(ro)?", "/feb(ruary)?/": "feb(rero)?", "/mar(ch)?/": "mar(zo)?", "/apr(il)?/": "abr(il)?", "/may/": "may(o)?", "/jun(e)?/": "jun(io)?", "/jul(y)?/": "jul(io)?", "/aug(ust)?/": "ago(sto)?", "/sep(t(ember)?)?/": "sep(tiembre)?", "/oct(ober)?/": "oct(ubre)?", "/nov(ember)?/": "nov(iembre)?", "/dec(ember)?/": "dic(iembre)?", "/^su(n(day)?)?/": "^do(m(ingo)?)?", "/^mo(n(day)?)?/": "^lu(n(es)?)?", "/^tu(e(s(day)?)?)?/": "^ma(r(tes)?)?", "/^we(d(nesday)?)?/": "^mi(é(rcoles)?)?", "/^th(u(r(s(day)?)?)?)?/": "^ju(e(ves)?)?", "/^fr(i(day)?)?/": "^vi(e(rnes)?)?", "/^sa(t(urday)?)?/": "^sá(b(ado)?)?", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "es-GT"; ================================================ FILE: build/production/i18n/es-HN.js ================================================ /* * DateJS Culture String File * Country Code: es-HN * Name: Spanish (Honduras) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["es-HN"] = { "name": "es-HN", "englishName": "Spanish (Honduras)", "nativeName": "Español (Honduras)", "Sunday": "domingo", "Monday": "lunes", "Tuesday": "martes", "Wednesday": "miércoles", "Thursday": "jueves", "Friday": "viernes", "Saturday": "sábado", "Sun": "dom", "Mon": "lun", "Tue": "mar", "Wed": "mié", "Thu": "jue", "Fri": "vie", "Sat": "sáb", "Su": "do", "Mo": "lu", "Tu": "ma", "We": "mi", "Th": "ju", "Fr": "vi", "Sa": "sá", "S_Sun_Initial": "d", "M_Mon_Initial": "l", "T_Tue_Initial": "m", "W_Wed_Initial": "m", "T_Thu_Initial": "j", "F_Fri_Initial": "v", "S_Sat_Initial": "s", "January": "enero", "February": "febrero", "March": "marzo", "April": "abril", "May": "mayo", "June": "junio", "July": "julio", "August": "agosto", "September": "septiembre", "October": "octubre", "November": "noviembre", "December": "diciembre", "Jan_Abbr": "ene", "Feb_Abbr": "feb", "Mar_Abbr": "mar", "Apr_Abbr": "abr", "May_Abbr": "may", "Jun_Abbr": "jun", "Jul_Abbr": "jul", "Aug_Abbr": "ago", "Sep_Abbr": "sep", "Oct_Abbr": "oct", "Nov_Abbr": "nov", "Dec_Abbr": "dic", "AM": "a.m.", "PM": "p.m.", "firstDayOfWeek": 0, "twoDigitYearMax": 2029, "mdy": "dmy", "M/d/yyyy": "dd/MM/yyyy", "dddd, MMMM dd, yyyy": "dddd, dd' de 'MMMM' de 'yyyy", "h:mm tt": "hh:mm tt", "h:mm:ss tt": "hh:mm:ss tt", "dddd, MMMM dd, yyyy h:mm:ss tt": "dddd, dd' de 'MMMM' de 'yyyy hh:mm:ss tt", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "dd MMMM", "MMMM, yyyy": "MMMM' de 'yyyy", "/jan(uary)?/": "ene(ro)?", "/feb(ruary)?/": "feb(rero)?", "/mar(ch)?/": "mar(zo)?", "/apr(il)?/": "abr(il)?", "/may/": "may(o)?", "/jun(e)?/": "jun(io)?", "/jul(y)?/": "jul(io)?", "/aug(ust)?/": "ago(sto)?", "/sep(t(ember)?)?/": "sep(tiembre)?", "/oct(ober)?/": "oct(ubre)?", "/nov(ember)?/": "nov(iembre)?", "/dec(ember)?/": "dic(iembre)?", "/^su(n(day)?)?/": "^do(m(ingo)?)?", "/^mo(n(day)?)?/": "^lu(n(es)?)?", "/^tu(e(s(day)?)?)?/": "^ma(r(tes)?)?", "/^we(d(nesday)?)?/": "^mi(é(rcoles)?)?", "/^th(u(r(s(day)?)?)?)?/": "^ju(e(ves)?)?", "/^fr(i(day)?)?/": "^vi(e(rnes)?)?", "/^sa(t(urday)?)?/": "^sá(b(ado)?)?", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "es-HN"; ================================================ FILE: build/production/i18n/es-MX.js ================================================ /* * DateJS Culture String File * Country Code: es-MX * Name: Spanish (Mexico) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["es-MX"] = { "name": "es-MX", "englishName": "Spanish (Mexico)", "nativeName": "Español (México)", "Sunday": "domingo", "Monday": "lunes", "Tuesday": "martes", "Wednesday": "miércoles", "Thursday": "jueves", "Friday": "viernes", "Saturday": "sábado", "Sun": "dom", "Mon": "lun", "Tue": "mar", "Wed": "mié", "Thu": "jue", "Fri": "vie", "Sat": "sáb", "Su": "do", "Mo": "lu", "Tu": "ma", "We": "mi", "Th": "ju", "Fr": "vi", "Sa": "sá", "S_Sun_Initial": "d", "M_Mon_Initial": "l", "T_Tue_Initial": "m", "W_Wed_Initial": "m", "T_Thu_Initial": "j", "F_Fri_Initial": "v", "S_Sat_Initial": "s", "January": "enero", "February": "febrero", "March": "marzo", "April": "abril", "May": "mayo", "June": "junio", "July": "julio", "August": "agosto", "September": "septiembre", "October": "octubre", "November": "noviembre", "December": "diciembre", "Jan_Abbr": "ene", "Feb_Abbr": "feb", "Mar_Abbr": "mar", "Apr_Abbr": "abr", "May_Abbr": "may", "Jun_Abbr": "jun", "Jul_Abbr": "jul", "Aug_Abbr": "ago", "Sep_Abbr": "sep", "Oct_Abbr": "oct", "Nov_Abbr": "nov", "Dec_Abbr": "dic", "AM": "a.m.", "PM": "p.m.", "firstDayOfWeek": 0, "twoDigitYearMax": 2029, "mdy": "dmy", "M/d/yyyy": "dd/MM/yyyy", "dddd, MMMM dd, yyyy": "dddd, dd' de 'MMMM' de 'yyyy", "h:mm tt": "hh:mm tt", "h:mm:ss tt": "hh:mm:ss tt", "dddd, MMMM dd, yyyy h:mm:ss tt": "dddd, dd' de 'MMMM' de 'yyyy hh:mm:ss tt", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "dd MMMM", "MMMM, yyyy": "MMMM' de 'yyyy", "/jan(uary)?/": "ene(ro)?", "/feb(ruary)?/": "feb(rero)?", "/mar(ch)?/": "mar(zo)?", "/apr(il)?/": "abr(il)?", "/may/": "may(o)?", "/jun(e)?/": "jun(io)?", "/jul(y)?/": "jul(io)?", "/aug(ust)?/": "ago(sto)?", "/sep(t(ember)?)?/": "sep(tiembre)?", "/oct(ober)?/": "oct(ubre)?", "/nov(ember)?/": "nov(iembre)?", "/dec(ember)?/": "dic(iembre)?", "/^su(n(day)?)?/": "^do(m(ingo)?)?", "/^mo(n(day)?)?/": "^lu(n(es)?)?", "/^tu(e(s(day)?)?)?/": "^ma(r(tes)?)?", "/^we(d(nesday)?)?/": "^mi(é(rcoles)?)?", "/^th(u(r(s(day)?)?)?)?/": "^ju(e(ves)?)?", "/^fr(i(day)?)?/": "^vi(e(rnes)?)?", "/^sa(t(urday)?)?/": "^sá(b(ado)?)?", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "es-MX"; ================================================ FILE: build/production/i18n/es-NI.js ================================================ /* * DateJS Culture String File * Country Code: es-NI * Name: Spanish (Nicaragua) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["es-NI"] = { "name": "es-NI", "englishName": "Spanish (Nicaragua)", "nativeName": "Español (Nicaragua)", "Sunday": "domingo", "Monday": "lunes", "Tuesday": "martes", "Wednesday": "miércoles", "Thursday": "jueves", "Friday": "viernes", "Saturday": "sábado", "Sun": "dom", "Mon": "lun", "Tue": "mar", "Wed": "mié", "Thu": "jue", "Fri": "vie", "Sat": "sáb", "Su": "do", "Mo": "lu", "Tu": "ma", "We": "mi", "Th": "ju", "Fr": "vi", "Sa": "sá", "S_Sun_Initial": "d", "M_Mon_Initial": "l", "T_Tue_Initial": "m", "W_Wed_Initial": "m", "T_Thu_Initial": "j", "F_Fri_Initial": "v", "S_Sat_Initial": "s", "January": "enero", "February": "febrero", "March": "marzo", "April": "abril", "May": "mayo", "June": "junio", "July": "julio", "August": "agosto", "September": "septiembre", "October": "octubre", "November": "noviembre", "December": "diciembre", "Jan_Abbr": "ene", "Feb_Abbr": "feb", "Mar_Abbr": "mar", "Apr_Abbr": "abr", "May_Abbr": "may", "Jun_Abbr": "jun", "Jul_Abbr": "jul", "Aug_Abbr": "ago", "Sep_Abbr": "sep", "Oct_Abbr": "oct", "Nov_Abbr": "nov", "Dec_Abbr": "dic", "AM": "a.m.", "PM": "p.m.", "firstDayOfWeek": 0, "twoDigitYearMax": 2029, "mdy": "dmy", "M/d/yyyy": "dd/MM/yyyy", "dddd, MMMM dd, yyyy": "dddd, dd' de 'MMMM' de 'yyyy", "h:mm tt": "hh:mm tt", "h:mm:ss tt": "hh:mm:ss tt", "dddd, MMMM dd, yyyy h:mm:ss tt": "dddd, dd' de 'MMMM' de 'yyyy hh:mm:ss tt", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "dd MMMM", "MMMM, yyyy": "MMMM' de 'yyyy", "/jan(uary)?/": "ene(ro)?", "/feb(ruary)?/": "feb(rero)?", "/mar(ch)?/": "mar(zo)?", "/apr(il)?/": "abr(il)?", "/may/": "may(o)?", "/jun(e)?/": "jun(io)?", "/jul(y)?/": "jul(io)?", "/aug(ust)?/": "ago(sto)?", "/sep(t(ember)?)?/": "sep(tiembre)?", "/oct(ober)?/": "oct(ubre)?", "/nov(ember)?/": "nov(iembre)?", "/dec(ember)?/": "dic(iembre)?", "/^su(n(day)?)?/": "^do(m(ingo)?)?", "/^mo(n(day)?)?/": "^lu(n(es)?)?", "/^tu(e(s(day)?)?)?/": "^ma(r(tes)?)?", "/^we(d(nesday)?)?/": "^mi(é(rcoles)?)?", "/^th(u(r(s(day)?)?)?)?/": "^ju(e(ves)?)?", "/^fr(i(day)?)?/": "^vi(e(rnes)?)?", "/^sa(t(urday)?)?/": "^sá(b(ado)?)?", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "es-NI"; ================================================ FILE: build/production/i18n/es-PA.js ================================================ /* * DateJS Culture String File * Country Code: es-PA * Name: Spanish (Panama) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["es-PA"] = { "name": "es-PA", "englishName": "Spanish (Panama)", "nativeName": "Español (Panamá)", "Sunday": "domingo", "Monday": "lunes", "Tuesday": "martes", "Wednesday": "miércoles", "Thursday": "jueves", "Friday": "viernes", "Saturday": "sábado", "Sun": "dom", "Mon": "lun", "Tue": "mar", "Wed": "mié", "Thu": "jue", "Fri": "vie", "Sat": "sáb", "Su": "do", "Mo": "lu", "Tu": "ma", "We": "mi", "Th": "ju", "Fr": "vi", "Sa": "sá", "S_Sun_Initial": "d", "M_Mon_Initial": "l", "T_Tue_Initial": "m", "W_Wed_Initial": "m", "T_Thu_Initial": "j", "F_Fri_Initial": "v", "S_Sat_Initial": "s", "January": "enero", "February": "febrero", "March": "marzo", "April": "abril", "May": "mayo", "June": "junio", "July": "julio", "August": "agosto", "September": "septiembre", "October": "octubre", "November": "noviembre", "December": "diciembre", "Jan_Abbr": "ene", "Feb_Abbr": "feb", "Mar_Abbr": "mar", "Apr_Abbr": "abr", "May_Abbr": "may", "Jun_Abbr": "jun", "Jul_Abbr": "jul", "Aug_Abbr": "ago", "Sep_Abbr": "sep", "Oct_Abbr": "oct", "Nov_Abbr": "nov", "Dec_Abbr": "dic", "AM": "a.m.", "PM": "p.m.", "firstDayOfWeek": 0, "twoDigitYearMax": 2029, "mdy": "mdy", "M/d/yyyy": "MM/dd/yyyy", "dddd, MMMM dd, yyyy": "dddd, dd' de 'MMMM' de 'yyyy", "h:mm tt": "hh:mm tt", "h:mm:ss tt": "hh:mm:ss tt", "dddd, MMMM dd, yyyy h:mm:ss tt": "dddd, dd' de 'MMMM' de 'yyyy hh:mm:ss tt", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "dd MMMM", "MMMM, yyyy": "MMMM' de 'yyyy", "/jan(uary)?/": "ene(ro)?", "/feb(ruary)?/": "feb(rero)?", "/mar(ch)?/": "mar(zo)?", "/apr(il)?/": "abr(il)?", "/may/": "may(o)?", "/jun(e)?/": "jun(io)?", "/jul(y)?/": "jul(io)?", "/aug(ust)?/": "ago(sto)?", "/sep(t(ember)?)?/": "sep(tiembre)?", "/oct(ober)?/": "oct(ubre)?", "/nov(ember)?/": "nov(iembre)?", "/dec(ember)?/": "dic(iembre)?", "/^su(n(day)?)?/": "^do(m(ingo)?)?", "/^mo(n(day)?)?/": "^lu(n(es)?)?", "/^tu(e(s(day)?)?)?/": "^ma(r(tes)?)?", "/^we(d(nesday)?)?/": "^mi(é(rcoles)?)?", "/^th(u(r(s(day)?)?)?)?/": "^ju(e(ves)?)?", "/^fr(i(day)?)?/": "^vi(e(rnes)?)?", "/^sa(t(urday)?)?/": "^sá(b(ado)?)?", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "es-PA"; ================================================ FILE: build/production/i18n/es-PE.js ================================================ /* * DateJS Culture String File * Country Code: es-PE * Name: Spanish (Peru) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["es-PE"] = { "name": "es-PE", "englishName": "Spanish (Peru)", "nativeName": "Español (Perú)", "Sunday": "domingo", "Monday": "lunes", "Tuesday": "martes", "Wednesday": "miércoles", "Thursday": "jueves", "Friday": "viernes", "Saturday": "sábado", "Sun": "dom", "Mon": "lun", "Tue": "mar", "Wed": "mié", "Thu": "jue", "Fri": "vie", "Sat": "sáb", "Su": "do", "Mo": "lu", "Tu": "ma", "We": "mi", "Th": "ju", "Fr": "vi", "Sa": "sá", "S_Sun_Initial": "d", "M_Mon_Initial": "l", "T_Tue_Initial": "m", "W_Wed_Initial": "m", "T_Thu_Initial": "j", "F_Fri_Initial": "v", "S_Sat_Initial": "s", "January": "enero", "February": "febrero", "March": "marzo", "April": "abril", "May": "mayo", "June": "junio", "July": "julio", "August": "agosto", "September": "septiembre", "October": "octubre", "November": "noviembre", "December": "diciembre", "Jan_Abbr": "ene", "Feb_Abbr": "feb", "Mar_Abbr": "mar", "Apr_Abbr": "abr", "May_Abbr": "may", "Jun_Abbr": "jun", "Jul_Abbr": "jul", "Aug_Abbr": "ago", "Sep_Abbr": "sep", "Oct_Abbr": "oct", "Nov_Abbr": "nov", "Dec_Abbr": "dic", "AM": "a.m.", "PM": "p.m.", "firstDayOfWeek": 0, "twoDigitYearMax": 2029, "mdy": "dmy", "M/d/yyyy": "dd/MM/yyyy", "dddd, MMMM dd, yyyy": "dddd, dd' de 'MMMM' de 'yyyy", "h:mm tt": "hh:mm tt", "h:mm:ss tt": "hh:mm:ss tt", "dddd, MMMM dd, yyyy h:mm:ss tt": "dddd, dd' de 'MMMM' de 'yyyy hh:mm:ss tt", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "dd MMMM", "MMMM, yyyy": "MMMM' de 'yyyy", "/jan(uary)?/": "ene(ro)?", "/feb(ruary)?/": "feb(rero)?", "/mar(ch)?/": "mar(zo)?", "/apr(il)?/": "abr(il)?", "/may/": "may(o)?", "/jun(e)?/": "jun(io)?", "/jul(y)?/": "jul(io)?", "/aug(ust)?/": "ago(sto)?", "/sep(t(ember)?)?/": "sep(tiembre)?", "/oct(ober)?/": "oct(ubre)?", "/nov(ember)?/": "nov(iembre)?", "/dec(ember)?/": "dic(iembre)?", "/^su(n(day)?)?/": "^do(m(ingo)?)?", "/^mo(n(day)?)?/": "^lu(n(es)?)?", "/^tu(e(s(day)?)?)?/": "^ma(r(tes)?)?", "/^we(d(nesday)?)?/": "^mi(é(rcoles)?)?", "/^th(u(r(s(day)?)?)?)?/": "^ju(e(ves)?)?", "/^fr(i(day)?)?/": "^vi(e(rnes)?)?", "/^sa(t(urday)?)?/": "^sá(b(ado)?)?", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "es-PE"; ================================================ FILE: build/production/i18n/es-PR.js ================================================ /* * DateJS Culture String File * Country Code: es-PR * Name: Spanish (Puerto Rico) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["es-PR"] = { "name": "es-PR", "englishName": "Spanish (Puerto Rico)", "nativeName": "Español (Puerto Rico)", "Sunday": "domingo", "Monday": "lunes", "Tuesday": "martes", "Wednesday": "miércoles", "Thursday": "jueves", "Friday": "viernes", "Saturday": "sábado", "Sun": "dom", "Mon": "lun", "Tue": "mar", "Wed": "mié", "Thu": "jue", "Fri": "vie", "Sat": "sáb", "Su": "do", "Mo": "lu", "Tu": "ma", "We": "mi", "Th": "ju", "Fr": "vi", "Sa": "sá", "S_Sun_Initial": "d", "M_Mon_Initial": "l", "T_Tue_Initial": "m", "W_Wed_Initial": "m", "T_Thu_Initial": "j", "F_Fri_Initial": "v", "S_Sat_Initial": "s", "January": "enero", "February": "febrero", "March": "marzo", "April": "abril", "May": "mayo", "June": "junio", "July": "julio", "August": "agosto", "September": "septiembre", "October": "octubre", "November": "noviembre", "December": "diciembre", "Jan_Abbr": "ene", "Feb_Abbr": "feb", "Mar_Abbr": "mar", "Apr_Abbr": "abr", "May_Abbr": "may", "Jun_Abbr": "jun", "Jul_Abbr": "jul", "Aug_Abbr": "ago", "Sep_Abbr": "sep", "Oct_Abbr": "oct", "Nov_Abbr": "nov", "Dec_Abbr": "dic", "AM": "a.m.", "PM": "p.m.", "firstDayOfWeek": 0, "twoDigitYearMax": 2029, "mdy": "dmy", "M/d/yyyy": "dd/MM/yyyy", "dddd, MMMM dd, yyyy": "dddd, dd' de 'MMMM' de 'yyyy", "h:mm tt": "hh:mm tt", "h:mm:ss tt": "hh:mm:ss tt", "dddd, MMMM dd, yyyy h:mm:ss tt": "dddd, dd' de 'MMMM' de 'yyyy hh:mm:ss tt", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "dd MMMM", "MMMM, yyyy": "MMMM' de 'yyyy", "/jan(uary)?/": "ene(ro)?", "/feb(ruary)?/": "feb(rero)?", "/mar(ch)?/": "mar(zo)?", "/apr(il)?/": "abr(il)?", "/may/": "may(o)?", "/jun(e)?/": "jun(io)?", "/jul(y)?/": "jul(io)?", "/aug(ust)?/": "ago(sto)?", "/sep(t(ember)?)?/": "sep(tiembre)?", "/oct(ober)?/": "oct(ubre)?", "/nov(ember)?/": "nov(iembre)?", "/dec(ember)?/": "dic(iembre)?", "/^su(n(day)?)?/": "^do(m(ingo)?)?", "/^mo(n(day)?)?/": "^lu(n(es)?)?", "/^tu(e(s(day)?)?)?/": "^ma(r(tes)?)?", "/^we(d(nesday)?)?/": "^mi(é(rcoles)?)?", "/^th(u(r(s(day)?)?)?)?/": "^ju(e(ves)?)?", "/^fr(i(day)?)?/": "^vi(e(rnes)?)?", "/^sa(t(urday)?)?/": "^sá(b(ado)?)?", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "es-PR"; ================================================ FILE: build/production/i18n/es-PY.js ================================================ /* * DateJS Culture String File * Country Code: es-PY * Name: Spanish (Paraguay) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["es-PY"] = { "name": "es-PY", "englishName": "Spanish (Paraguay)", "nativeName": "Español (Paraguay)", "Sunday": "domingo", "Monday": "lunes", "Tuesday": "martes", "Wednesday": "miércoles", "Thursday": "jueves", "Friday": "viernes", "Saturday": "sábado", "Sun": "dom", "Mon": "lun", "Tue": "mar", "Wed": "mié", "Thu": "jue", "Fri": "vie", "Sat": "sáb", "Su": "do", "Mo": "lu", "Tu": "ma", "We": "mi", "Th": "ju", "Fr": "vi", "Sa": "sá", "S_Sun_Initial": "d", "M_Mon_Initial": "l", "T_Tue_Initial": "m", "W_Wed_Initial": "m", "T_Thu_Initial": "j", "F_Fri_Initial": "v", "S_Sat_Initial": "s", "January": "enero", "February": "febrero", "March": "marzo", "April": "abril", "May": "mayo", "June": "junio", "July": "julio", "August": "agosto", "September": "septiembre", "October": "octubre", "November": "noviembre", "December": "diciembre", "Jan_Abbr": "ene", "Feb_Abbr": "feb", "Mar_Abbr": "mar", "Apr_Abbr": "abr", "May_Abbr": "may", "Jun_Abbr": "jun", "Jul_Abbr": "jul", "Aug_Abbr": "ago", "Sep_Abbr": "sep", "Oct_Abbr": "oct", "Nov_Abbr": "nov", "Dec_Abbr": "dic", "AM": "a.m.", "PM": "p.m.", "firstDayOfWeek": 1, "twoDigitYearMax": 2029, "mdy": "dmy", "M/d/yyyy": "dd/MM/yyyy", "dddd, MMMM dd, yyyy": "dddd, dd' de 'MMMM' de 'yyyy", "h:mm tt": "hh:mm tt", "h:mm:ss tt": "hh:mm:ss tt", "dddd, MMMM dd, yyyy h:mm:ss tt": "dddd, dd' de 'MMMM' de 'yyyy hh:mm:ss tt", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "dd MMMM", "MMMM, yyyy": "MMMM' de 'yyyy", "/jan(uary)?/": "ene(ro)?", "/feb(ruary)?/": "feb(rero)?", "/mar(ch)?/": "mar(zo)?", "/apr(il)?/": "abr(il)?", "/may/": "may(o)?", "/jun(e)?/": "jun(io)?", "/jul(y)?/": "jul(io)?", "/aug(ust)?/": "ago(sto)?", "/sep(t(ember)?)?/": "sep(tiembre)?", "/oct(ober)?/": "oct(ubre)?", "/nov(ember)?/": "nov(iembre)?", "/dec(ember)?/": "dic(iembre)?", "/^su(n(day)?)?/": "^do(m(ingo)?)?", "/^mo(n(day)?)?/": "^lu(n(es)?)?", "/^tu(e(s(day)?)?)?/": "^ma(r(tes)?)?", "/^we(d(nesday)?)?/": "^mi(é(rcoles)?)?", "/^th(u(r(s(day)?)?)?)?/": "^ju(e(ves)?)?", "/^fr(i(day)?)?/": "^vi(e(rnes)?)?", "/^sa(t(urday)?)?/": "^sá(b(ado)?)?", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "es-PY"; ================================================ FILE: build/production/i18n/es-SV.js ================================================ /* * DateJS Culture String File * Country Code: es-SV * Name: Spanish (El Salvador) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["es-SV"] = { "name": "es-SV", "englishName": "Spanish (El Salvador)", "nativeName": "Español (El Salvador)", "Sunday": "domingo", "Monday": "lunes", "Tuesday": "martes", "Wednesday": "miércoles", "Thursday": "jueves", "Friday": "viernes", "Saturday": "sábado", "Sun": "dom", "Mon": "lun", "Tue": "mar", "Wed": "mié", "Thu": "jue", "Fri": "vie", "Sat": "sáb", "Su": "do", "Mo": "lu", "Tu": "ma", "We": "mi", "Th": "ju", "Fr": "vi", "Sa": "sá", "S_Sun_Initial": "d", "M_Mon_Initial": "l", "T_Tue_Initial": "m", "W_Wed_Initial": "m", "T_Thu_Initial": "j", "F_Fri_Initial": "v", "S_Sat_Initial": "s", "January": "enero", "February": "febrero", "March": "marzo", "April": "abril", "May": "mayo", "June": "junio", "July": "julio", "August": "agosto", "September": "septiembre", "October": "octubre", "November": "noviembre", "December": "diciembre", "Jan_Abbr": "ene", "Feb_Abbr": "feb", "Mar_Abbr": "mar", "Apr_Abbr": "abr", "May_Abbr": "may", "Jun_Abbr": "jun", "Jul_Abbr": "jul", "Aug_Abbr": "ago", "Sep_Abbr": "sep", "Oct_Abbr": "oct", "Nov_Abbr": "nov", "Dec_Abbr": "dic", "AM": "a.m.", "PM": "p.m.", "firstDayOfWeek": 0, "twoDigitYearMax": 2029, "mdy": "dmy", "M/d/yyyy": "dd/MM/yyyy", "dddd, MMMM dd, yyyy": "dddd, dd' de 'MMMM' de 'yyyy", "h:mm tt": "hh:mm tt", "h:mm:ss tt": "hh:mm:ss tt", "dddd, MMMM dd, yyyy h:mm:ss tt": "dddd, dd' de 'MMMM' de 'yyyy hh:mm:ss tt", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "dd MMMM", "MMMM, yyyy": "MMMM' de 'yyyy", "/jan(uary)?/": "ene(ro)?", "/feb(ruary)?/": "feb(rero)?", "/mar(ch)?/": "mar(zo)?", "/apr(il)?/": "abr(il)?", "/may/": "may(o)?", "/jun(e)?/": "jun(io)?", "/jul(y)?/": "jul(io)?", "/aug(ust)?/": "ago(sto)?", "/sep(t(ember)?)?/": "sep(tiembre)?", "/oct(ober)?/": "oct(ubre)?", "/nov(ember)?/": "nov(iembre)?", "/dec(ember)?/": "dic(iembre)?", "/^su(n(day)?)?/": "^do(m(ingo)?)?", "/^mo(n(day)?)?/": "^lu(n(es)?)?", "/^tu(e(s(day)?)?)?/": "^ma(r(tes)?)?", "/^we(d(nesday)?)?/": "^mi(é(rcoles)?)?", "/^th(u(r(s(day)?)?)?)?/": "^ju(e(ves)?)?", "/^fr(i(day)?)?/": "^vi(e(rnes)?)?", "/^sa(t(urday)?)?/": "^sá(b(ado)?)?", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "es-SV"; ================================================ FILE: build/production/i18n/es-UY.js ================================================ /* * DateJS Culture String File * Country Code: es-UY * Name: Spanish (Uruguay) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["es-UY"] = { "name": "es-UY", "englishName": "Spanish (Uruguay)", "nativeName": "Español (Uruguay)", "Sunday": "domingo", "Monday": "lunes", "Tuesday": "martes", "Wednesday": "miércoles", "Thursday": "jueves", "Friday": "viernes", "Saturday": "sábado", "Sun": "dom", "Mon": "lun", "Tue": "mar", "Wed": "mié", "Thu": "jue", "Fri": "vie", "Sat": "sáb", "Su": "do", "Mo": "lu", "Tu": "ma", "We": "mi", "Th": "ju", "Fr": "vi", "Sa": "sá", "S_Sun_Initial": "d", "M_Mon_Initial": "l", "T_Tue_Initial": "m", "W_Wed_Initial": "m", "T_Thu_Initial": "j", "F_Fri_Initial": "v", "S_Sat_Initial": "s", "January": "enero", "February": "febrero", "March": "marzo", "April": "abril", "May": "mayo", "June": "junio", "July": "julio", "August": "agosto", "September": "septiembre", "October": "octubre", "November": "noviembre", "December": "diciembre", "Jan_Abbr": "ene", "Feb_Abbr": "feb", "Mar_Abbr": "mar", "Apr_Abbr": "abr", "May_Abbr": "may", "Jun_Abbr": "jun", "Jul_Abbr": "jul", "Aug_Abbr": "ago", "Sep_Abbr": "sep", "Oct_Abbr": "oct", "Nov_Abbr": "nov", "Dec_Abbr": "dic", "AM": "a.m.", "PM": "p.m.", "firstDayOfWeek": 1, "twoDigitYearMax": 2029, "mdy": "dmy", "M/d/yyyy": "dd/MM/yyyy", "dddd, MMMM dd, yyyy": "dddd, dd' de 'MMMM' de 'yyyy", "h:mm tt": "hh:mm tt", "h:mm:ss tt": "hh:mm:ss tt", "dddd, MMMM dd, yyyy h:mm:ss tt": "dddd, dd' de 'MMMM' de 'yyyy hh:mm:ss tt", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "dd MMMM", "MMMM, yyyy": "MMMM' de 'yyyy", "/jan(uary)?/": "ene(ro)?", "/feb(ruary)?/": "feb(rero)?", "/mar(ch)?/": "mar(zo)?", "/apr(il)?/": "abr(il)?", "/may/": "may(o)?", "/jun(e)?/": "jun(io)?", "/jul(y)?/": "jul(io)?", "/aug(ust)?/": "ago(sto)?", "/sep(t(ember)?)?/": "sep(tiembre)?", "/oct(ober)?/": "oct(ubre)?", "/nov(ember)?/": "nov(iembre)?", "/dec(ember)?/": "dic(iembre)?", "/^su(n(day)?)?/": "^do(m(ingo)?)?", "/^mo(n(day)?)?/": "^lu(n(es)?)?", "/^tu(e(s(day)?)?)?/": "^ma(r(tes)?)?", "/^we(d(nesday)?)?/": "^mi(é(rcoles)?)?", "/^th(u(r(s(day)?)?)?)?/": "^ju(e(ves)?)?", "/^fr(i(day)?)?/": "^vi(e(rnes)?)?", "/^sa(t(urday)?)?/": "^sá(b(ado)?)?", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "es-UY"; ================================================ FILE: build/production/i18n/es-VE.js ================================================ /* * DateJS Culture String File * Country Code: es-VE * Name: Spanish (Venezuela) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["es-VE"] = { "name": "es-VE", "englishName": "Spanish (Venezuela)", "nativeName": "Español (Republica Bolivariana de Venezuela)", "Sunday": "domingo", "Monday": "lunes", "Tuesday": "martes", "Wednesday": "miércoles", "Thursday": "jueves", "Friday": "viernes", "Saturday": "sábado", "Sun": "dom", "Mon": "lun", "Tue": "mar", "Wed": "mié", "Thu": "jue", "Fri": "vie", "Sat": "sáb", "Su": "do", "Mo": "lu", "Tu": "ma", "We": "mi", "Th": "ju", "Fr": "vi", "Sa": "sá", "S_Sun_Initial": "d", "M_Mon_Initial": "l", "T_Tue_Initial": "m", "W_Wed_Initial": "m", "T_Thu_Initial": "j", "F_Fri_Initial": "v", "S_Sat_Initial": "s", "January": "enero", "February": "febrero", "March": "marzo", "April": "abril", "May": "mayo", "June": "junio", "July": "julio", "August": "agosto", "September": "septiembre", "October": "octubre", "November": "noviembre", "December": "diciembre", "Jan_Abbr": "ene", "Feb_Abbr": "feb", "Mar_Abbr": "mar", "Apr_Abbr": "abr", "May_Abbr": "may", "Jun_Abbr": "jun", "Jul_Abbr": "jul", "Aug_Abbr": "ago", "Sep_Abbr": "sep", "Oct_Abbr": "oct", "Nov_Abbr": "nov", "Dec_Abbr": "dic", "AM": "a.m.", "PM": "p.m.", "firstDayOfWeek": 0, "twoDigitYearMax": 2029, "mdy": "dmy", "M/d/yyyy": "dd/MM/yyyy", "dddd, MMMM dd, yyyy": "dddd, dd' de 'MMMM' de 'yyyy", "h:mm tt": "hh:mm tt", "h:mm:ss tt": "hh:mm:ss tt", "dddd, MMMM dd, yyyy h:mm:ss tt": "dddd, dd' de 'MMMM' de 'yyyy hh:mm:ss tt", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "dd MMMM", "MMMM, yyyy": "MMMM' de 'yyyy", "/jan(uary)?/": "ene(ro)?", "/feb(ruary)?/": "feb(rero)?", "/mar(ch)?/": "mar(zo)?", "/apr(il)?/": "abr(il)?", "/may/": "may(o)?", "/jun(e)?/": "jun(io)?", "/jul(y)?/": "jul(io)?", "/aug(ust)?/": "ago(sto)?", "/sep(t(ember)?)?/": "sep(tiembre)?", "/oct(ober)?/": "oct(ubre)?", "/nov(ember)?/": "nov(iembre)?", "/dec(ember)?/": "dic(iembre)?", "/^su(n(day)?)?/": "^do(m(ingo)?)?", "/^mo(n(day)?)?/": "^lu(n(es)?)?", "/^tu(e(s(day)?)?)?/": "^ma(r(tes)?)?", "/^we(d(nesday)?)?/": "^mi(é(rcoles)?)?", "/^th(u(r(s(day)?)?)?)?/": "^ju(e(ves)?)?", "/^fr(i(day)?)?/": "^vi(e(rnes)?)?", "/^sa(t(urday)?)?/": "^sá(b(ado)?)?", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "es-VE"; ================================================ FILE: build/production/i18n/et-EE.js ================================================ /* * DateJS Culture String File * Country Code: et-EE * Name: Estonian (Estonia) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["et-EE"] = { "name": "et-EE", "englishName": "Estonian (Estonia)", "nativeName": "eesti (Eesti)", "Sunday": "pühapäev", "Monday": "esmaspäev", "Tuesday": "teisipäev", "Wednesday": "kolmapäev", "Thursday": "neljapäev", "Friday": "reede", "Saturday": "laupäev", "Sun": "P", "Mon": "E", "Tue": "T", "Wed": "K", "Thu": "N", "Fri": "R", "Sat": "L", "Su": "P", "Mo": "E", "Tu": "T", "We": "K", "Th": "N", "Fr": "R", "Sa": "L", "S_Sun_Initial": "P", "M_Mon_Initial": "E", "T_Tue_Initial": "T", "W_Wed_Initial": "K", "T_Thu_Initial": "N", "F_Fri_Initial": "R", "S_Sat_Initial": "L", "January": "jaanuar", "February": "veebruar", "March": "märts", "April": "aprill", "May": "mai", "June": "juuni", "July": "juuli", "August": "august", "September": "september", "October": "oktoober", "November": "november", "December": "detsember", "Jan_Abbr": "jaan", "Feb_Abbr": "veebr", "Mar_Abbr": "märts", "Apr_Abbr": "apr", "May_Abbr": "mai", "Jun_Abbr": "juuni", "Jul_Abbr": "juuli", "Aug_Abbr": "aug", "Sep_Abbr": "sept", "Oct_Abbr": "okt", "Nov_Abbr": "nov", "Dec_Abbr": "dets", "AM": "EL", "PM": "PL", "firstDayOfWeek": 1, "twoDigitYearMax": 2029, "mdy": "dmy", "M/d/yyyy": "d.MM.yyyy", "dddd, MMMM dd, yyyy": "d. MMMM yyyy'. a.'", "h:mm tt": "H:mm", "h:mm:ss tt": "H:mm:ss", "dddd, MMMM dd, yyyy h:mm:ss tt": "d. MMMM yyyy'. a.' H:mm:ss", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "d. MMMM", "MMMM, yyyy": "MMMM yyyy'. a.'", "/jan(uary)?/": "jaan(uar)?", "/feb(ruary)?/": "veebr(uar)?", "/mar(ch)?/": "märts", "/apr(il)?/": "apr(ill)?", "/may/": "mai", "/jun(e)?/": "juuni", "/jul(y)?/": "juuli", "/aug(ust)?/": "aug(ust)?", "/sep(t(ember)?)?/": "sep(t(ember)?)?", "/oct(ober)?/": "okt(oober)?", "/nov(ember)?/": "nov(ember)?", "/dec(ember)?/": "dets(ember)?", "/^su(n(day)?)?/": "^pühapäev", "/^mo(n(day)?)?/": "^esmaspäev", "/^tu(e(s(day)?)?)?/": "^teisipäev", "/^we(d(nesday)?)?/": "^kolmapäev", "/^th(u(r(s(day)?)?)?)?/": "^neljapäev", "/^fr(i(day)?)?/": "^reede", "/^sa(t(urday)?)?/": "^laupäev", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "et-EE"; ================================================ FILE: build/production/i18n/eu-ES.js ================================================ /* * DateJS Culture String File * Country Code: eu-ES * Name: Basque (Basque) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["eu-ES"] = { "name": "eu-ES", "englishName": "Basque (Basque)", "nativeName": "euskara (euskara)", "Sunday": "igandea", "Monday": "astelehena", "Tuesday": "asteartea", "Wednesday": "asteazkena", "Thursday": "osteguna", "Friday": "ostirala", "Saturday": "larunbata", "Sun": "ig.", "Mon": "al.", "Tue": "as.", "Wed": "az.", "Thu": "og.", "Fri": "or.", "Sat": "lr.", "Su": "ig", "Mo": "al", "Tu": "as", "We": "az", "Th": "og", "Fr": "or", "Sa": "lr", "S_Sun_Initial": "i", "M_Mon_Initial": "a", "T_Tue_Initial": "a", "W_Wed_Initial": "a", "T_Thu_Initial": "o", "F_Fri_Initial": "o", "S_Sat_Initial": "l", "January": "urtarrila", "February": "otsaila", "March": "martxoa", "April": "apirila", "May": "maiatza", "June": "ekaina", "July": "uztaila", "August": "abuztua", "September": "iraila", "October": "urria", "November": "azaroa", "December": "abendua", "Jan_Abbr": "urt.", "Feb_Abbr": "ots.", "Mar_Abbr": "mar.", "Apr_Abbr": "api.", "May_Abbr": "mai.", "Jun_Abbr": "eka.", "Jul_Abbr": "uzt.", "Aug_Abbr": "abu.", "Sep_Abbr": "ira.", "Oct_Abbr": "urr.", "Nov_Abbr": "aza.", "Dec_Abbr": "abe.", "AM": "", "PM": "", "firstDayOfWeek": 1, "twoDigitYearMax": 2029, "mdy": "ymd", "M/d/yyyy": "yyyy/MM/dd", "dddd, MMMM dd, yyyy": "dddd, yyyy.'eko' MMMM'k 'd", "h:mm tt": "HH:mm", "h:mm:ss tt": "HH:mm:ss", "dddd, MMMM dd, yyyy h:mm:ss tt": "dddd, yyyy.'eko' MMMM'k 'd HH:mm:ss", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "MMMM dd", "MMMM, yyyy": "yyyy.'eko' MMMM", "/jan(uary)?/": "urt(.(arrila)?)?", "/feb(ruary)?/": "ots(.(aila)?)?", "/mar(ch)?/": "mar(.(txoa)?)?", "/apr(il)?/": "api(.(rila)?)?", "/may/": "mai(.(atza)?)?", "/jun(e)?/": "eka(.(ina)?)?", "/jul(y)?/": "uzt(.(aila)?)?", "/aug(ust)?/": "abu(.(ztua)?)?", "/sep(t(ember)?)?/": "ira(.(ila)?)?", "/oct(ober)?/": "urr(.(ia)?)?", "/nov(ember)?/": "aza(.(roa)?)?", "/dec(ember)?/": "abe(.(ndua)?)?", "/^su(n(day)?)?/": "^ig((.(andea)?)?)?", "/^mo(n(day)?)?/": "^al((.(telehena)?)?)?", "/^tu(e(s(day)?)?)?/": "^as((.(teartea)?)?)?", "/^we(d(nesday)?)?/": "^az((.(teazkena)?)?)?", "/^th(u(r(s(day)?)?)?)?/": "^og((.(teguna)?)?)?", "/^fr(i(day)?)?/": "^or((.(tirala)?)?)?", "/^sa(t(urday)?)?/": "^lr((.(runbata)?)?)?", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "eu-ES"; ================================================ FILE: build/production/i18n/fa-IR.js ================================================ /* * DateJS Culture String File * Country Code: fa-IR * Name: Persian (Iran) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["fa-IR"] = { "name": "fa-IR", "englishName": "Persian (Iran)", "nativeName": "فارسى (ايران)", "Sunday": "Sunday", "Monday": "Monday", "Tuesday": "Tuesday", "Wednesday": "Wednesday", "Thursday": "Thursday", "Friday": "Friday", "Saturday": "Saturday", "Sun": "Sun", "Mon": "Mon", "Tue": "Tue", "Wed": "Wed", "Thu": "Thu", "Fri": "Fri", "Sat": "Sat", "Su": "Su", "Mo": "Mo", "Tu": "Tu", "We": "We", "Th": "Th", "Fr": "Fr", "Sa": "Sa", "S_Sun_Initial": "S", "M_Mon_Initial": "M", "T_Tue_Initial": "T", "W_Wed_Initial": "W", "T_Thu_Initial": "T", "F_Fri_Initial": "F", "S_Sat_Initial": "S", "January": "January", "February": "February", "March": "March", "April": "April", "May": "May", "June": "June", "July": "July", "August": "August", "September": "September", "October": "October", "November": "November", "December": "December", "Jan_Abbr": "Jan", "Feb_Abbr": "Feb", "Mar_Abbr": "Mar", "Apr_Abbr": "Apr", "May_Abbr": "May", "Jun_Abbr": "Jun", "Jul_Abbr": "Jul", "Aug_Abbr": "Aug", "Sep_Abbr": "Sep", "Oct_Abbr": "Oct", "Nov_Abbr": "Nov", "Dec_Abbr": "Dec", "AM": "ق.ظ", "PM": "ب.ظ", "firstDayOfWeek": 0, "twoDigitYearMax": 2029, "mdy": "mdy", "M/d/yyyy": "M/d/yyyy", "dddd, MMMM dd, yyyy": "dddd, MMMM dd, yyyy", "h:mm tt": "hh:mm tt", "h:mm:ss tt": "hh:mm:ss tt", "dddd, MMMM dd, yyyy h:mm:ss tt": "dddd, MMMM dd, yyyy hh:mm:ss tt", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "MMMM dd", "MMMM, yyyy": "MMMM, yyyy", "/jan(uary)?/": "jan(uary)?", "/feb(ruary)?/": "feb(ruary)?", "/mar(ch)?/": "mar(ch)?", "/apr(il)?/": "apr(il)?", "/may/": "may", "/jun(e)?/": "jun(e)?", "/jul(y)?/": "jul(y)?", "/aug(ust)?/": "aug(ust)?", "/sep(t(ember)?)?/": "sep(t(ember)?)?", "/oct(ober)?/": "oct(ober)?", "/nov(ember)?/": "nov(ember)?", "/dec(ember)?/": "dec(ember)?", "/^su(n(day)?)?/": "^su(n(day)?)?", "/^mo(n(day)?)?/": "^mo(n(day)?)?", "/^tu(e(s(day)?)?)?/": "^tu(e(s(day)?)?)?", "/^we(d(nesday)?)?/": "^we(d(nesday)?)?", "/^th(u(r(s(day)?)?)?)?/": "^th(u(r(s(day)?)?)?)?", "/^fr(i(day)?)?/": "^fr(i(day)?)?", "/^sa(t(urday)?)?/": "^sa(t(urday)?)?", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "fa-IR"; ================================================ FILE: build/production/i18n/fi-FI.js ================================================ /* * DateJS Culture String File * Country Code: fi-FI * Name: Finnish (Finland) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["fi-FI"] = { "name": "fi-FI", "englishName": "Finnish (Finland)", "nativeName": "suomi (Suomi)", "Sunday": "sunnuntai", "Monday": "maanantai", "Tuesday": "tiistai", "Wednesday": "keskiviikko", "Thursday": "torstai", "Friday": "perjantai", "Saturday": "lauantai", "Sun": "su", "Mon": "ma", "Tue": "ti", "Wed": "ke", "Thu": "to", "Fri": "pe", "Sat": "la", "Su": "su", "Mo": "ma", "Tu": "ti", "We": "ke", "Th": "to", "Fr": "pe", "Sa": "la", "S_Sun_Initial": "s", "M_Mon_Initial": "m", "T_Tue_Initial": "t", "W_Wed_Initial": "k", "T_Thu_Initial": "t", "F_Fri_Initial": "p", "S_Sat_Initial": "l", "January": "tammikuu", "February": "helmikuu", "March": "maaliskuu", "April": "huhtikuu", "May": "toukokuu", "June": "kesäkuu", "July": "heinäkuu", "August": "elokuu", "September": "syyskuu", "October": "lokakuu", "November": "marraskuu", "December": "joulukuu", "Jan_Abbr": "tammi", "Feb_Abbr": "helmi", "Mar_Abbr": "maalis", "Apr_Abbr": "huhti", "May_Abbr": "touko", "Jun_Abbr": "kesä", "Jul_Abbr": "heinä", "Aug_Abbr": "elo", "Sep_Abbr": "syys", "Oct_Abbr": "loka", "Nov_Abbr": "marras", "Dec_Abbr": "joulu", "AM": "", "PM": "", "firstDayOfWeek": 1, "twoDigitYearMax": 2029, "mdy": "dmy", "M/d/yyyy": "d.M.yyyy", "dddd, MMMM dd, yyyy": "d. MMMM'ta 'yyyy", "h:mm tt": "H:mm", "h:mm:ss tt": "H:mm:ss", "dddd, MMMM dd, yyyy h:mm:ss tt": "d. MMMM'ta 'yyyy H:mm:ss", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "d. MMMM'ta'", "MMMM, yyyy": "MMMM yyyy", "/jan(uary)?/": "tammi(kuu)?", "/feb(ruary)?/": "helmi(kuu)?", "/mar(ch)?/": "maalis(kuu)?", "/apr(il)?/": "huhti(kuu)?", "/may/": "touko(kuu)?", "/jun(e)?/": "kesä(kuu)?", "/jul(y)?/": "heinä(kuu)?", "/aug(ust)?/": "elo(kuu)?", "/sep(t(ember)?)?/": "syys(kuu)?", "/oct(ober)?/": "loka(kuu)?", "/nov(ember)?/": "marras(kuu)?", "/dec(ember)?/": "joulu(kuu)?", "/^su(n(day)?)?/": "^sunnuntai", "/^mo(n(day)?)?/": "^maanantai", "/^tu(e(s(day)?)?)?/": "^tiistai", "/^we(d(nesday)?)?/": "^keskiviikko", "/^th(u(r(s(day)?)?)?)?/": "^torstai", "/^fr(i(day)?)?/": "^perjantai", "/^sa(t(urday)?)?/": "^lauantai", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "fi-FI"; ================================================ FILE: build/production/i18n/fo-FO.js ================================================ /* * DateJS Culture String File * Country Code: fo-FO * Name: Faroese (Faroe Islands) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["fo-FO"] = { "name": "fo-FO", "englishName": "Faroese (Faroe Islands)", "nativeName": "føroyskt (Føroyar)", "Sunday": "sunnudagur", "Monday": "mánadagur", "Tuesday": "týsdagur", "Wednesday": "mikudagur", "Thursday": "hósdagur", "Friday": "fríggjadagur", "Saturday": "leygardagur", "Sun": "sun", "Mon": "mán", "Tue": "týs", "Wed": "mik", "Thu": "hós", "Fri": "frí", "Sat": "leyg", "Su": "su", "Mo": "má", "Tu": "tý", "We": "mi", "Th": "hó", "Fr": "fr", "Sa": "ley", "S_Sun_Initial": "s", "M_Mon_Initial": "m", "T_Tue_Initial": "t", "W_Wed_Initial": "m", "T_Thu_Initial": "h", "F_Fri_Initial": "f", "S_Sat_Initial": "l", "January": "januar", "February": "februar", "March": "mars", "April": "apríl", "May": "mai", "June": "juni", "July": "juli", "August": "august", "September": "september", "October": "oktober", "November": "november", "December": "desember", "Jan_Abbr": "jan", "Feb_Abbr": "feb", "Mar_Abbr": "mar", "Apr_Abbr": "apr", "May_Abbr": "mai", "Jun_Abbr": "jun", "Jul_Abbr": "jul", "Aug_Abbr": "aug", "Sep_Abbr": "sep", "Oct_Abbr": "okt", "Nov_Abbr": "nov", "Dec_Abbr": "des", "AM": "", "PM": "", "firstDayOfWeek": 1, "twoDigitYearMax": 2029, "mdy": "dmy", "M/d/yyyy": "dd-MM-yyyy", "dddd, MMMM dd, yyyy": "d. MMMM yyyy", "h:mm tt": "HH.mm", "h:mm:ss tt": "HH.mm.ss", "dddd, MMMM dd, yyyy h:mm:ss tt": "d. MMMM yyyy HH.mm.ss", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "d. MMMM", "MMMM, yyyy": "MMMM yyyy", "/jan(uary)?/": "jan(uar)?", "/feb(ruary)?/": "feb(ruar)?", "/mar(ch)?/": "mar(s)?", "/apr(il)?/": "apr(íl)?", "/may/": "mai", "/jun(e)?/": "jun(i)?", "/jul(y)?/": "jul(i)?", "/aug(ust)?/": "aug(ust)?", "/sep(t(ember)?)?/": "sep(t(ember)?)?", "/oct(ober)?/": "okt(ober)?", "/nov(ember)?/": "nov(ember)?", "/dec(ember)?/": "des(ember)?", "/^su(n(day)?)?/": "^su(n(nudagur)?)?", "/^mo(n(day)?)?/": "^má(n(adagur)?)?", "/^tu(e(s(day)?)?)?/": "^tý(s(dagur)?)?", "/^we(d(nesday)?)?/": "^mi(k(udagur)?)?", "/^th(u(r(s(day)?)?)?)?/": "^hó(s(dagur)?)?", "/^fr(i(day)?)?/": "^fr(í(ggjadagur)?)?", "/^sa(t(urday)?)?/": "^ley(g(ardagur)?)?", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "fo-FO"; ================================================ FILE: build/production/i18n/fr-BE.js ================================================ /* * DateJS Culture String File * Country Code: fr-BE * Name: French (Belgium) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["fr-BE"] = { "name": "fr-BE", "englishName": "French (Belgium)", "nativeName": "français (Belgique)", "Sunday": "dimanche", "Monday": "lundi", "Tuesday": "mardi", "Wednesday": "mercredi", "Thursday": "jeudi", "Friday": "vendredi", "Saturday": "samedi", "Sun": "dim.", "Mon": "lun.", "Tue": "mar.", "Wed": "mer.", "Thu": "jeu.", "Fri": "ven.", "Sat": "sam.", "Su": "di", "Mo": "lu", "Tu": "ma", "We": "me", "Th": "je", "Fr": "ve", "Sa": "sa", "S_Sun_Initial": "d", "M_Mon_Initial": "l", "T_Tue_Initial": "m", "W_Wed_Initial": "m", "T_Thu_Initial": "j", "F_Fri_Initial": "v", "S_Sat_Initial": "s", "January": "janvier", "February": "février", "March": "mars", "April": "avril", "May": "mai", "June": "juin", "July": "juillet", "August": "août", "September": "septembre", "October": "octobre", "November": "novembre", "December": "décembre", "Jan_Abbr": "janv.", "Feb_Abbr": "févr.", "Mar_Abbr": "mars", "Apr_Abbr": "avr.", "May_Abbr": "mai", "Jun_Abbr": "juin", "Jul_Abbr": "juil.", "Aug_Abbr": "août", "Sep_Abbr": "sept.", "Oct_Abbr": "oct.", "Nov_Abbr": "nov.", "Dec_Abbr": "déc.", "AM": "", "PM": "", "firstDayOfWeek": 1, "twoDigitYearMax": 2029, "mdy": "dmy", "M/d/yyyy": "d/MM/yyyy", "dddd, MMMM dd, yyyy": "dddd d MMMM yyyy", "h:mm tt": "H:mm", "h:mm:ss tt": "H:mm:ss", "dddd, MMMM dd, yyyy h:mm:ss tt": "dddd d MMMM yyyy H:mm:ss", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "d MMMM", "MMMM, yyyy": "MMMM yyyy", "/jan(uary)?/": "janv(.(ier)?)?", "/feb(ruary)?/": "févr(.(ier)?)?", "/mar(ch)?/": "mars", "/apr(il)?/": "avr(.(il)?)?", "/may/": "mai", "/jun(e)?/": "juin", "/jul(y)?/": "juil(.(let)?)?", "/aug(ust)?/": "août", "/sep(t(ember)?)?/": "sept(.(embre)?)?", "/oct(ober)?/": "oct(.(obre)?)?", "/nov(ember)?/": "nov(.(embre)?)?", "/dec(ember)?/": "déc(.(embre)?)?", "/^su(n(day)?)?/": "^di(m(.(anche)?)?)?", "/^mo(n(day)?)?/": "^lu(n(.(di)?)?)?", "/^tu(e(s(day)?)?)?/": "^ma(r(.(di)?)?)?", "/^we(d(nesday)?)?/": "^me(r(.(credi)?)?)?", "/^th(u(r(s(day)?)?)?)?/": "^je(u(.(di)?)?)?", "/^fr(i(day)?)?/": "^ve(n(.(dredi)?)?)?", "/^sa(t(urday)?)?/": "^sa(m(.(edi)?)?)?", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "fr-BE"; ================================================ FILE: build/production/i18n/fr-CA.js ================================================ /* * DateJS Culture String File * Country Code: fr-CA * Name: French (Canada) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["fr-CA"] = { "name": "fr-CA", "englishName": "French (Canada)", "nativeName": "français (Canada)", "Sunday": "dimanche", "Monday": "lundi", "Tuesday": "mardi", "Wednesday": "mercredi", "Thursday": "jeudi", "Friday": "vendredi", "Saturday": "samedi", "Sun": "dim.", "Mon": "lun.", "Tue": "mar.", "Wed": "mer.", "Thu": "jeu.", "Fri": "ven.", "Sat": "sam.", "Su": "di", "Mo": "lu", "Tu": "ma", "We": "me", "Th": "je", "Fr": "ve", "Sa": "sa", "S_Sun_Initial": "d", "M_Mon_Initial": "l", "T_Tue_Initial": "m", "W_Wed_Initial": "m", "T_Thu_Initial": "j", "F_Fri_Initial": "v", "S_Sat_Initial": "s", "January": "janvier", "February": "février", "March": "mars", "April": "avril", "May": "mai", "June": "juin", "July": "juillet", "August": "août", "September": "septembre", "October": "octobre", "November": "novembre", "December": "décembre", "Jan_Abbr": "janv.", "Feb_Abbr": "févr.", "Mar_Abbr": "mars", "Apr_Abbr": "avr.", "May_Abbr": "mai", "Jun_Abbr": "juin", "Jul_Abbr": "juil.", "Aug_Abbr": "août", "Sep_Abbr": "sept.", "Oct_Abbr": "oct.", "Nov_Abbr": "nov.", "Dec_Abbr": "déc.", "AM": "", "PM": "", "firstDayOfWeek": 0, "twoDigitYearMax": 2029, "mdy": "ymd", "M/d/yyyy": "yyyy-MM-dd", "dddd, MMMM dd, yyyy": "d MMMM yyyy", "h:mm tt": "HH:mm", "h:mm:ss tt": "HH:mm:ss", "dddd, MMMM dd, yyyy h:mm:ss tt": "d MMMM yyyy HH:mm:ss", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "d MMMM", "MMMM, yyyy": "MMMM, yyyy", "/jan(uary)?/": "janv((ier)?)?", "/feb(ruary)?/": "févr((ier)?)?", "/mar(ch)?/": "mars", "/apr(il)?/": "avr((il)?)?", "/may/": "mai", "/jun(e)?/": "juin", "/jul(y)?/": "juil((let)?)?", "/aug(ust)?/": "août", "/sep(t(ember)?)?/": "sept((embre)?)?", "/oct(ober)?/": "oct((obre)?)?", "/nov(ember)?/": "nov((embre)?)?", "/dec(ember)?/": "déc((embre)?)?", "/^su(n(day)?)?/": "^di(m((anche)?)?)?", "/^mo(n(day)?)?/": "^lu(n((di)?)?)?", "/^tu(e(s(day)?)?)?/": "^ma(r((di)?)?)?", "/^we(d(nesday)?)?/": "^me(r((credi)?)?)?", "/^th(u(r(s(day)?)?)?)?/": "^je(u((di)?)?)?", "/^fr(i(day)?)?/": "^ve(n((dredi)?)?)?", "/^sa(t(urday)?)?/": "^sa(m((edi)?)?)?", "/^next/": "^prochain", "/^last|past|prev(ious)?/": "^dernier", "/^(\\+|aft(er)?|from|hence)/": "^précédant", "/^(\\-|bef(ore)?|ago)/": "^succédant", "/^yes(terday)?/": "^hier", "/^t(od(ay)?)?/": "^aujourd\'hui", "/^tom(orrow)?/": "^demain", "/^n(ow)?/": "^maintenant", "/^ms|milli(second)?s?/": "^ms|milli(seconde)?s?", "/^sec(ond)?s?/": "^sec(onde)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(eure)?s?", "/^w(eek)?s?/": "^sem(aine)?s?", "/^m(onth)?s?/": "^m(ois)?", "/^d(ay)?s?/": "^j(our)?s?", "/^y(ear)?s?/": "^a(nnée)?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "fr-CA"; ================================================ FILE: build/production/i18n/fr-CH.js ================================================ /* * DateJS Culture String File * Country Code: fr-CH * Name: French (Switzerland) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["fr-CH"] = { "name": "fr-CH", "englishName": "French (Switzerland)", "nativeName": "français (Suisse)", "Sunday": "dimanche", "Monday": "lundi", "Tuesday": "mardi", "Wednesday": "mercredi", "Thursday": "jeudi", "Friday": "vendredi", "Saturday": "samedi", "Sun": "dim.", "Mon": "lun.", "Tue": "mar.", "Wed": "mer.", "Thu": "jeu.", "Fri": "ven.", "Sat": "sam.", "Su": "di", "Mo": "lu", "Tu": "ma", "We": "me", "Th": "je", "Fr": "ve", "Sa": "sa", "S_Sun_Initial": "d", "M_Mon_Initial": "l", "T_Tue_Initial": "m", "W_Wed_Initial": "m", "T_Thu_Initial": "j", "F_Fri_Initial": "v", "S_Sat_Initial": "s", "January": "janvier", "February": "février", "March": "mars", "April": "avril", "May": "mai", "June": "juin", "July": "juillet", "August": "août", "September": "septembre", "October": "octobre", "November": "novembre", "December": "décembre", "Jan_Abbr": "janv.", "Feb_Abbr": "févr.", "Mar_Abbr": "mars", "Apr_Abbr": "avr.", "May_Abbr": "mai", "Jun_Abbr": "juin", "Jul_Abbr": "juil.", "Aug_Abbr": "août", "Sep_Abbr": "sept.", "Oct_Abbr": "oct.", "Nov_Abbr": "nov.", "Dec_Abbr": "déc.", "AM": "", "PM": "", "firstDayOfWeek": 1, "twoDigitYearMax": 2029, "mdy": "dmy", "M/d/yyyy": "dd.MM.yyyy", "dddd, MMMM dd, yyyy": "dddd, d. MMMM yyyy", "h:mm tt": "HH:mm", "h:mm:ss tt": "HH:mm:ss", "dddd, MMMM dd, yyyy h:mm:ss tt": "dddd, d. MMMM yyyy HH:mm:ss", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "d MMMM", "MMMM, yyyy": "MMMM yyyy", "/jan(uary)?/": "janv(.(ier)?)?", "/feb(ruary)?/": "févr(.(ier)?)?", "/mar(ch)?/": "mars", "/apr(il)?/": "avr(.(il)?)?", "/may/": "mai", "/jun(e)?/": "juin", "/jul(y)?/": "juil(.(let)?)?", "/aug(ust)?/": "août", "/sep(t(ember)?)?/": "sept(.(embre)?)?", "/oct(ober)?/": "oct(.(obre)?)?", "/nov(ember)?/": "nov(.(embre)?)?", "/dec(ember)?/": "déc(.(embre)?)?", "/^su(n(day)?)?/": "^di(m(.(anche)?)?)?", "/^mo(n(day)?)?/": "^lu(n(.(di)?)?)?", "/^tu(e(s(day)?)?)?/": "^ma(r(.(di)?)?)?", "/^we(d(nesday)?)?/": "^me(r(.(credi)?)?)?", "/^th(u(r(s(day)?)?)?)?/": "^je(u(.(di)?)?)?", "/^fr(i(day)?)?/": "^ve(n(.(dredi)?)?)?", "/^sa(t(urday)?)?/": "^sa(m(.(edi)?)?)?", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "fr-CH"; ================================================ FILE: build/production/i18n/fr-FR.js ================================================ /* * DateJS Culture String File * Country Code: fr-FR * Name: French (France) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["fr-FR"] = { "name": "fr-FR", "englishName": "French (France)", "nativeName": "français (France)", "Sunday": "dimanche", "Monday": "lundi", "Tuesday": "mardi", "Wednesday": "mercredi", "Thursday": "jeudi", "Friday": "vendredi", "Saturday": "samedi", "Sun": "dim.", "Mon": "lun.", "Tue": "mar.", "Wed": "mer.", "Thu": "jeu.", "Fri": "ven.", "Sat": "sam.", "Su": "di", "Mo": "lu", "Tu": "ma", "We": "me", "Th": "je", "Fr": "ve", "Sa": "sa", "S_Sun_Initial": "d", "M_Mon_Initial": "l", "T_Tue_Initial": "m", "W_Wed_Initial": "m", "T_Thu_Initial": "j", "F_Fri_Initial": "v", "S_Sat_Initial": "s", "January": "janvier", "February": "février", "March": "mars", "April": "avril", "May": "mai", "June": "juin", "July": "juillet", "August": "août", "September": "septembre", "October": "octobre", "November": "novembre", "December": "décembre", "Jan_Abbr": "janv.", "Feb_Abbr": "févr.", "Mar_Abbr": "mars", "Apr_Abbr": "avr.", "May_Abbr": "mai", "Jun_Abbr": "juin", "Jul_Abbr": "juil.", "Aug_Abbr": "août", "Sep_Abbr": "sept.", "Oct_Abbr": "oct.", "Nov_Abbr": "nov.", "Dec_Abbr": "déc.", "AM": "", "PM": "", "firstDayOfWeek": 1, "twoDigitYearMax": 2029, "mdy": "dmy", "M/d/yyyy": "dd/MM/yyyy", "dddd, MMMM dd, yyyy": "dddd d MMMM yyyy", "h:mm tt": "HH:mm", "h:mm:ss tt": "HH:mm:ss", "dddd, MMMM dd, yyyy h:mm:ss tt": "dddd d MMMM yyyy HH:mm:ss", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "d MMMM", "MMMM, yyyy": "MMMM yyyy", "/jan(uary)?/": "janv(.(ier)?)?", "/feb(ruary)?/": "févr(.(ier)?)?", "/mar(ch)?/": "mars", "/apr(il)?/": "avr(.(il)?)?", "/may/": "mai", "/jun(e)?/": "juin", "/jul(y)?/": "juil(.(let)?)?", "/aug(ust)?/": "août", "/sep(t(ember)?)?/": "sept(.(embre)?)?", "/oct(ober)?/": "oct(.(obre)?)?", "/nov(ember)?/": "nov(.(embre)?)?", "/dec(ember)?/": "déc(.(embre)?)?", "/^su(n(day)?)?/": "^di(m(.(anche)?)?)?", "/^mo(n(day)?)?/": "^lu(n(.(di)?)?)?", "/^tu(e(s(day)?)?)?/": "^ma(r(.(di)?)?)?", "/^we(d(nesday)?)?/": "^me(r(.(credi)?)?)?", "/^th(u(r(s(day)?)?)?)?/": "^je(u(.(di)?)?)?", "/^fr(i(day)?)?/": "^ve(n(.(dredi)?)?)?", "/^sa(t(urday)?)?/": "^sa(m(.(edi)?)?)?", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "fr-FR"; ================================================ FILE: build/production/i18n/fr-LU.js ================================================ /* * DateJS Culture String File * Country Code: fr-LU * Name: French (Luxembourg) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["fr-LU"] = { "name": "fr-LU", "englishName": "French (Luxembourg)", "nativeName": "français (Luxembourg)", "Sunday": "dimanche", "Monday": "lundi", "Tuesday": "mardi", "Wednesday": "mercredi", "Thursday": "jeudi", "Friday": "vendredi", "Saturday": "samedi", "Sun": "dim.", "Mon": "lun.", "Tue": "mar.", "Wed": "mer.", "Thu": "jeu.", "Fri": "ven.", "Sat": "sam.", "Su": "di", "Mo": "lu", "Tu": "ma", "We": "me", "Th": "je", "Fr": "ve", "Sa": "sa", "S_Sun_Initial": "d", "M_Mon_Initial": "l", "T_Tue_Initial": "m", "W_Wed_Initial": "m", "T_Thu_Initial": "j", "F_Fri_Initial": "v", "S_Sat_Initial": "s", "January": "janvier", "February": "février", "March": "mars", "April": "avril", "May": "mai", "June": "juin", "July": "juillet", "August": "août", "September": "septembre", "October": "octobre", "November": "novembre", "December": "décembre", "Jan_Abbr": "janv.", "Feb_Abbr": "févr.", "Mar_Abbr": "mars", "Apr_Abbr": "avr.", "May_Abbr": "mai", "Jun_Abbr": "juin", "Jul_Abbr": "juil.", "Aug_Abbr": "août", "Sep_Abbr": "sept.", "Oct_Abbr": "oct.", "Nov_Abbr": "nov.", "Dec_Abbr": "déc.", "AM": "", "PM": "", "firstDayOfWeek": 1, "twoDigitYearMax": 2029, "mdy": "dmy", "M/d/yyyy": "dd/MM/yyyy", "dddd, MMMM dd, yyyy": "dddd d MMMM yyyy", "h:mm tt": "HH:mm", "h:mm:ss tt": "HH:mm:ss", "dddd, MMMM dd, yyyy h:mm:ss tt": "dddd d MMMM yyyy HH:mm:ss", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "d MMMM", "MMMM, yyyy": "MMMM yyyy", "/jan(uary)?/": "janv(.(ier)?)?", "/feb(ruary)?/": "févr(.(ier)?)?", "/mar(ch)?/": "mars", "/apr(il)?/": "avr(.(il)?)?", "/may/": "mai", "/jun(e)?/": "juin", "/jul(y)?/": "juil(.(let)?)?", "/aug(ust)?/": "août", "/sep(t(ember)?)?/": "sept(.(embre)?)?", "/oct(ober)?/": "oct(.(obre)?)?", "/nov(ember)?/": "nov(.(embre)?)?", "/dec(ember)?/": "déc(.(embre)?)?", "/^su(n(day)?)?/": "^di(m(.(anche)?)?)?", "/^mo(n(day)?)?/": "^lu(n(.(di)?)?)?", "/^tu(e(s(day)?)?)?/": "^ma(r(.(di)?)?)?", "/^we(d(nesday)?)?/": "^me(r(.(credi)?)?)?", "/^th(u(r(s(day)?)?)?)?/": "^je(u(.(di)?)?)?", "/^fr(i(day)?)?/": "^ve(n(.(dredi)?)?)?", "/^sa(t(urday)?)?/": "^sa(m(.(edi)?)?)?", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "fr-LU"; ================================================ FILE: build/production/i18n/fr-MC.js ================================================ /* * DateJS Culture String File * Country Code: fr-MC * Name: French (Principality of Monaco) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["fr-MC"] = { "name": "fr-MC", "englishName": "French (Principality of Monaco)", "nativeName": "français (Principauté de Monaco)", "Sunday": "dimanche", "Monday": "lundi", "Tuesday": "mardi", "Wednesday": "mercredi", "Thursday": "jeudi", "Friday": "vendredi", "Saturday": "samedi", "Sun": "dim.", "Mon": "lun.", "Tue": "mar.", "Wed": "mer.", "Thu": "jeu.", "Fri": "ven.", "Sat": "sam.", "Su": "di", "Mo": "lu", "Tu": "ma", "We": "me", "Th": "je", "Fr": "ve", "Sa": "sa", "S_Sun_Initial": "d", "M_Mon_Initial": "l", "T_Tue_Initial": "m", "W_Wed_Initial": "m", "T_Thu_Initial": "j", "F_Fri_Initial": "v", "S_Sat_Initial": "s", "January": "janvier", "February": "février", "March": "mars", "April": "avril", "May": "mai", "June": "juin", "July": "juillet", "August": "août", "September": "septembre", "October": "octobre", "November": "novembre", "December": "décembre", "Jan_Abbr": "janv.", "Feb_Abbr": "févr.", "Mar_Abbr": "mars", "Apr_Abbr": "avr.", "May_Abbr": "mai", "Jun_Abbr": "juin", "Jul_Abbr": "juil.", "Aug_Abbr": "août", "Sep_Abbr": "sept.", "Oct_Abbr": "oct.", "Nov_Abbr": "nov.", "Dec_Abbr": "déc.", "AM": "", "PM": "", "firstDayOfWeek": 1, "twoDigitYearMax": 2029, "mdy": "dmy", "M/d/yyyy": "dd/MM/yyyy", "dddd, MMMM dd, yyyy": "dddd d MMMM yyyy", "h:mm tt": "HH:mm", "h:mm:ss tt": "HH:mm:ss", "dddd, MMMM dd, yyyy h:mm:ss tt": "dddd d MMMM yyyy HH:mm:ss", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "d MMMM", "MMMM, yyyy": "MMMM yyyy", "/jan(uary)?/": "janv(.(ier)?)?", "/feb(ruary)?/": "févr(.(ier)?)?", "/mar(ch)?/": "mars", "/apr(il)?/": "avr(.(il)?)?", "/may/": "mai", "/jun(e)?/": "juin", "/jul(y)?/": "juil(.(let)?)?", "/aug(ust)?/": "août", "/sep(t(ember)?)?/": "sept(.(embre)?)?", "/oct(ober)?/": "oct(.(obre)?)?", "/nov(ember)?/": "nov(.(embre)?)?", "/dec(ember)?/": "déc(.(embre)?)?", "/^su(n(day)?)?/": "^di(m(.(anche)?)?)?", "/^mo(n(day)?)?/": "^lu(n(.(di)?)?)?", "/^tu(e(s(day)?)?)?/": "^ma(r(.(di)?)?)?", "/^we(d(nesday)?)?/": "^me(r(.(credi)?)?)?", "/^th(u(r(s(day)?)?)?)?/": "^je(u(.(di)?)?)?", "/^fr(i(day)?)?/": "^ve(n(.(dredi)?)?)?", "/^sa(t(urday)?)?/": "^sa(m(.(edi)?)?)?", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "fr-MC"; ================================================ FILE: build/production/i18n/gl-ES.js ================================================ /* * DateJS Culture String File * Country Code: gl-ES * Name: Galician (Galician) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["gl-ES"] = { "name": "gl-ES", "englishName": "Galician (Galician)", "nativeName": "galego (galego)", "Sunday": "domingo", "Monday": "luns", "Tuesday": "martes", "Wednesday": "mércores", "Thursday": "xoves", "Friday": "venres", "Saturday": "sábado", "Sun": "dom", "Mon": "luns", "Tue": "mar", "Wed": "mér", "Thu": "xov", "Fri": "ven", "Sat": "sab", "Su": "do", "Mo": "lu", "Tu": "ma", "We": "mé", "Th": "xo", "Fr": "ve", "Sa": "sa", "S_Sun_Initial": "d", "M_Mon_Initial": "l", "T_Tue_Initial": "m", "W_Wed_Initial": "m", "T_Thu_Initial": "x", "F_Fri_Initial": "v", "S_Sat_Initial": "s", "January": "xaneiro", "February": "febreiro", "March": "marzo", "April": "abril", "May": "maio", "June": "xuño", "July": "xullo", "August": "agosto", "September": "setembro", "October": "outubro", "November": "novembro", "December": "decembro", "Jan_Abbr": "xan", "Feb_Abbr": "feb", "Mar_Abbr": "mar", "Apr_Abbr": "abr", "May_Abbr": "maio", "Jun_Abbr": "xuñ", "Jul_Abbr": "xull", "Aug_Abbr": "ago", "Sep_Abbr": "set", "Oct_Abbr": "out", "Nov_Abbr": "nov", "Dec_Abbr": "dec", "AM": "a.m.", "PM": "p.m.", "firstDayOfWeek": 1, "twoDigitYearMax": 2029, "mdy": "dmy", "M/d/yyyy": "dd/MM/yy", "dddd, MMMM dd, yyyy": "dddd, dd' de 'MMMM' de 'yyyy", "h:mm tt": "H:mm", "h:mm:ss tt": "H:mm:ss", "dddd, MMMM dd, yyyy h:mm:ss tt": "dddd, dd' de 'MMMM' de 'yyyy H:mm:ss", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "dd MMMM", "MMMM, yyyy": "MMMM' de 'yyyy", "/jan(uary)?/": "xan(eiro)?", "/feb(ruary)?/": "feb(reiro)?", "/mar(ch)?/": "mar(zo)?", "/apr(il)?/": "abr(il)?", "/may/": "maio", "/jun(e)?/": "xuñ(o)?", "/jul(y)?/": "xull(o)?", "/aug(ust)?/": "ago(sto)?", "/sep(t(ember)?)?/": "set(embro)?", "/oct(ober)?/": "out(ubro)?", "/nov(ember)?/": "nov(embro)?", "/dec(ember)?/": "dec(embro)?", "/^su(n(day)?)?/": "^do(m(ingo)?)?", "/^mo(n(day)?)?/": "^lu(1)?", "/^tu(e(s(day)?)?)?/": "^ma(r(tes)?)?", "/^we(d(nesday)?)?/": "^mé(r(cores)?)?", "/^th(u(r(s(day)?)?)?)?/": "^xo(v(es)?)?", "/^fr(i(day)?)?/": "^ve(n(res)?)?", "/^sa(t(urday)?)?/": "^sa(b(ado)?)?", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "gl-ES"; ================================================ FILE: build/production/i18n/gu-IN.js ================================================ /* * DateJS Culture String File * Country Code: gu-IN * Name: Gujarati (India) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["gu-IN"] = { "name": "gu-IN", "englishName": "Gujarati (India)", "nativeName": "ગુજરાતી (ભારત)", "Sunday": "રવિવાર", "Monday": "સોમવાર", "Tuesday": "મંગળવાર", "Wednesday": "બુધવાર", "Thursday": "ગુરુવાર", "Friday": "શુક્રવાર", "Saturday": "શનિવાર", "Sun": "રવિ", "Mon": "સોમ", "Tue": "મંગળ", "Wed": "બુધ", "Thu": "ગુરુ", "Fri": "શુક્ર", "Sat": "શનિ", "Su": "ર", "Mo": "સ", "Tu": "મ", "We": "બ", "Th": "ગ", "Fr": "શ", "Sa": "શ", "S_Sun_Initial": "ર", "M_Mon_Initial": "સ", "T_Tue_Initial": "મ", "W_Wed_Initial": "બ", "T_Thu_Initial": "ગ", "F_Fri_Initial": "શ", "S_Sat_Initial": "શ", "January": "જાન્યુઆરી", "February": "ફેબ્રુઆરી", "March": "માર્ચ", "April": "એપ્રિલ", "May": "મે", "June": "જૂન", "July": "જુલાઈ", "August": "ઑગસ્ટ", "September": "સપ્ટેમ્બર", "October": "ઑક્ટ્બર", "November": "નવેમ્બર", "December": "ડિસેમ્બર", "Jan_Abbr": "જાન્યુ", "Feb_Abbr": "ફેબ્રુ", "Mar_Abbr": "માર્ચ", "Apr_Abbr": "એપ્રિલ", "May_Abbr": "મે", "Jun_Abbr": "જૂન", "Jul_Abbr": "જુલાઈ", "Aug_Abbr": "ઑગસ્ટ", "Sep_Abbr": "સપ્ટે", "Oct_Abbr": "ઑક્ટો", "Nov_Abbr": "નવે", "Dec_Abbr": "ડિસે", "AM": "પૂર્વ મધ્યાહ્ન", "PM": "ઉત્તર મધ્યાહ્ન", "firstDayOfWeek": 1, "twoDigitYearMax": 2029, "mdy": "dmy", "M/d/yyyy": "dd-MM-yy", "dddd, MMMM dd, yyyy": "dd MMMM yyyy", "h:mm tt": "HH:mm", "h:mm:ss tt": "HH:mm:ss", "dddd, MMMM dd, yyyy h:mm:ss tt": "dd MMMM yyyy HH:mm:ss", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "dd MMMM", "MMMM, yyyy": "MMMM, yyyy", "/jan(uary)?/": "જાન્યુ(આરી)?", "/feb(ruary)?/": "ફેબ્રુ(આરી)?", "/mar(ch)?/": "માર્ચ", "/apr(il)?/": "એપ્રિલ", "/may/": "મે", "/jun(e)?/": "જૂન", "/jul(y)?/": "જુલાઈ", "/aug(ust)?/": "ઑગસ્ટ", "/sep(t(ember)?)?/": "સપ્ટે(મ્બર)?", "/oct(ober)?/": "ઑક્ટ્બર", "/nov(ember)?/": "નવે(મ્બર)?", "/dec(ember)?/": "ડિસે(મ્બર)?", "/^su(n(day)?)?/": "^ર(વિ(વાર)?)?", "/^mo(n(day)?)?/": "^સ(ોમ(વાર)?)?", "/^tu(e(s(day)?)?)?/": "^મ(ંગળ(વાર)?)?", "/^we(d(nesday)?)?/": "^બ(ુધ(વાર)?)?", "/^th(u(r(s(day)?)?)?)?/": "^ગ(ુરુ(વાર)?)?", "/^fr(i(day)?)?/": "^શ(ુક્ર(વાર)?)?", "/^sa(t(urday)?)?/": "^શ(નિ(વાર)?)?", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "gu-IN"; ================================================ FILE: build/production/i18n/he-IL.js ================================================ /* * DateJS Culture String File * Country Code: he-IL * Name: Hebrew (Israel) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["he-IL"] = { "name": "he-IL", "englishName": "Hebrew (Israel)", "nativeName": "עברית (ישראל)", "Sunday": "יום ראשון", "Monday": "יום שני", "Tuesday": "יום שלישי", "Wednesday": "יום רביעי", "Thursday": "יום חמישי", "Friday": "יום שישי", "Saturday": "שבת", "Sun": "יום א", "Mon": "יום ב", "Tue": "יום ג", "Wed": "יום ד", "Thu": "יום ה", "Fri": "יום ו", "Sat": "שבת", "Su": "א", "Mo": "ב", "Tu": "ג", "We": "ד", "Th": "ה", "Fr": "ו", "Sa": "ש", "S_Sun_Initial": "א", "M_Mon_Initial": "ב", "T_Tue_Initial": "ג", "W_Wed_Initial": "ד", "T_Thu_Initial": "ה", "F_Fri_Initial": "ו", "S_Sat_Initial": "ש", "January": "ינואר", "February": "פברואר", "March": "מרץ", "April": "אפריל", "May": "מאי", "June": "יוני", "July": "יולי", "August": "אוגוסט", "September": "ספטמבר", "October": "אוקטובר", "November": "נובמבר", "December": "דצמבר", "Jan_Abbr": "ינו", "Feb_Abbr": "פבר", "Mar_Abbr": "מרץ", "Apr_Abbr": "אפר", "May_Abbr": "מאי", "Jun_Abbr": "יונ", "Jul_Abbr": "יול", "Aug_Abbr": "אוג", "Sep_Abbr": "ספט", "Oct_Abbr": "אוק", "Nov_Abbr": "נוב", "Dec_Abbr": "דצמ", "AM": "AM", "PM": "PM", "firstDayOfWeek": 0, "twoDigitYearMax": 2029, "mdy": "dmy", "M/d/yyyy": "dd/MM/yyyy", "dddd, MMMM dd, yyyy": "dddd dd MMMM yyyy", "h:mm tt": "HH:mm", "h:mm:ss tt": "HH:mm:ss", "dddd, MMMM dd, yyyy h:mm:ss tt": "dddd dd MMMM yyyy HH:mm:ss", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "dd MMMM", "MMMM, yyyy": "MMMM yyyy", "/jan(uary)?/": "ינו(אר)?", "/feb(ruary)?/": "פבר(ואר)?", "/mar(ch)?/": "מרץ", "/apr(il)?/": "אפר(יל)?", "/may/": "מאי", "/jun(e)?/": "יונ(י)?", "/jul(y)?/": "יול(י)?", "/aug(ust)?/": "אוג(וסט)?", "/sep(t(ember)?)?/": "ספט(מבר)?", "/oct(ober)?/": "אוק(טובר)?", "/nov(ember)?/": "נוב(מבר)?", "/dec(ember)?/": "דצמ(בר)?", "/^su(n(day)?)?/": "^א(ום א(אשון)?)?", "/^mo(n(day)?)?/": "^ב(ום ב(ני)?)?", "/^tu(e(s(day)?)?)?/": "^ג(ום ג(לישי)?)?", "/^we(d(nesday)?)?/": "^ד(ום ד(ביעי)?)?", "/^th(u(r(s(day)?)?)?)?/": "^ה(ום ה(מישי)?)?", "/^fr(i(day)?)?/": "^ו(ום ו(ישי)?)?", "/^sa(t(urday)?)?/": "^ש(1)?", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "he-IL"; ================================================ FILE: build/production/i18n/hi-IN.js ================================================ /* * DateJS Culture String File * Country Code: hi-IN * Name: Hindi (India) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["hi-IN"] = { "name": "hi-IN", "englishName": "Hindi (India)", "nativeName": "हिंदी (भारत)", "Sunday": "रविवार", "Monday": "सोमवार", "Tuesday": "मंगलवार", "Wednesday": "बुधवार", "Thursday": "गुरुवार", "Friday": "शुक्रवार", "Saturday": "शनिवार", "Sun": "रवि.", "Mon": "सोम.", "Tue": "मंगल.", "Wed": "बुध.", "Thu": "गुरु.", "Fri": "शुक्र.", "Sat": "शनि.", "Su": "र", "Mo": "स", "Tu": "म", "We": "ब", "Th": "ग", "Fr": "श", "Sa": "श", "S_Sun_Initial": "र", "M_Mon_Initial": "स", "T_Tue_Initial": "म", "W_Wed_Initial": "ब", "T_Thu_Initial": "ग", "F_Fri_Initial": "श", "S_Sat_Initial": "श", "January": "जनवरी", "February": "फरवरी", "March": "मार्च", "April": "अप्रैल", "May": "मई", "June": "जून", "July": "जुलाई", "August": "अगस्त", "September": "सितम्बर", "October": "अक्तूबर", "November": "नवम्बर", "December": "दिसम्बर", "Jan_Abbr": "जनवरी", "Feb_Abbr": "फरवरी", "Mar_Abbr": "मार्च", "Apr_Abbr": "अप्रैल", "May_Abbr": "मई", "Jun_Abbr": "जून", "Jul_Abbr": "जुलाई", "Aug_Abbr": "अगस्त", "Sep_Abbr": "सितम्बर", "Oct_Abbr": "अक्तूबर", "Nov_Abbr": "नवम्बर", "Dec_Abbr": "दिसम्बर", "AM": "पूर्वाह्न", "PM": "अपराह्न", "firstDayOfWeek": 1, "twoDigitYearMax": 2029, "mdy": "dmy", "M/d/yyyy": "dd-MM-yyyy", "dddd, MMMM dd, yyyy": "dd MMMM yyyy", "h:mm tt": "HH:mm", "h:mm:ss tt": "HH:mm:ss", "dddd, MMMM dd, yyyy h:mm:ss tt": "dd MMMM yyyy HH:mm:ss", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "dd MMMM", "MMMM, yyyy": "MMMM, yyyy", "/jan(uary)?/": "जनवरी", "/feb(ruary)?/": "फरवरी", "/mar(ch)?/": "मार्च", "/apr(il)?/": "अप्रैल", "/may/": "मई", "/jun(e)?/": "जून", "/jul(y)?/": "जुलाई", "/aug(ust)?/": "अगस्त", "/sep(t(ember)?)?/": "सितम्बर", "/oct(ober)?/": "अक्तूबर", "/nov(ember)?/": "नवम्बर", "/dec(ember)?/": "दिसम्बर", "/^su(n(day)?)?/": "^र(वि(.(वार)?)?)?", "/^mo(n(day)?)?/": "^स(ोम(.(वार)?)?)?", "/^tu(e(s(day)?)?)?/": "^म(ंगल(.(वार)?)?)?", "/^we(d(nesday)?)?/": "^ब(ुध(.(वार)?)?)?", "/^th(u(r(s(day)?)?)?)?/": "^ग(ुरु(.(वार)?)?)?", "/^fr(i(day)?)?/": "^श(ुक्र(.(वार)?)?)?", "/^sa(t(urday)?)?/": "^श(नि(.(वार)?)?)?", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "hi-IN"; ================================================ FILE: build/production/i18n/hr-BA.js ================================================ /* * DateJS Culture String File * Country Code: hr-BA * Name: Croatian (Bosnia and Herzegovina) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["hr-BA"] = { "name": "hr-BA", "englishName": "Croatian (Bosnia and Herzegovina)", "nativeName": "hrvatski (Bosna i Hercegovina)", "Sunday": "nedjelja", "Monday": "ponedjeljak", "Tuesday": "utorak", "Wednesday": "srijeda", "Thursday": "četvrtak", "Friday": "petak", "Saturday": "subota", "Sun": "ned", "Mon": "pon", "Tue": "uto", "Wed": "sri", "Thu": "čet", "Fri": "pet", "Sat": "sub", "Su": "ned", "Mo": "pon", "Tu": "uto", "We": "sri", "Th": "čet", "Fr": "pet", "Sa": "sub", "S_Sun_Initial": "n", "M_Mon_Initial": "p", "T_Tue_Initial": "u", "W_Wed_Initial": "s", "T_Thu_Initial": "č", "F_Fri_Initial": "p", "S_Sat_Initial": "s", "January": "siječanj", "February": "veljača", "March": "ožujak", "April": "travanj", "May": "svibanj", "June": "lipanj", "July": "srpanj", "August": "kolovoz", "September": "rujan", "October": "listopad", "November": "studeni", "December": "prosinac", "Jan_Abbr": "sij", "Feb_Abbr": "vlj", "Mar_Abbr": "ožu", "Apr_Abbr": "tra", "May_Abbr": "svi", "Jun_Abbr": "lip", "Jul_Abbr": "srp", "Aug_Abbr": "kol", "Sep_Abbr": "ruj", "Oct_Abbr": "lis", "Nov_Abbr": "stu", "Dec_Abbr": "pro", "AM": "", "PM": "", "firstDayOfWeek": 1, "twoDigitYearMax": 2029, "mdy": "dmy", "M/d/yyyy": "d.M.yyyy", "dddd, MMMM dd, yyyy": "d. MMMM yyyy", "h:mm tt": "H:mm:ss", "h:mm:ss tt": "H:mm:ss", "dddd, MMMM dd, yyyy h:mm:ss tt": "d. MMMM yyyy H:mm:ss", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "MMMM dd", "MMMM, yyyy": "MMMM, yyyy", "/jan(uary)?/": "sij(ečanj)?", "/feb(ruary)?/": "veljača", "/mar(ch)?/": "ožu(jak)?", "/apr(il)?/": "tra(vanj)?", "/may/": "svi(banj)?", "/jun(e)?/": "lip(anj)?", "/jul(y)?/": "srp(anj)?", "/aug(ust)?/": "kol(ovoz)?", "/sep(t(ember)?)?/": "ruj(an)?", "/oct(ober)?/": "lis(topad)?", "/nov(ember)?/": "stu(deni)?", "/dec(ember)?/": "pro(sinac)?", "/^su(n(day)?)?/": "^nedjelja", "/^mo(n(day)?)?/": "^ponedjeljak", "/^tu(e(s(day)?)?)?/": "^utorak", "/^we(d(nesday)?)?/": "^srijeda", "/^th(u(r(s(day)?)?)?)?/": "^četvrtak", "/^fr(i(day)?)?/": "^petak", "/^sa(t(urday)?)?/": "^subota", "/^next/": "^slijedeć(i|e|eg)", "/^last|past|prev(ious)?/": "^zadnji|posljednji|prethodni", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|pos(lije)?|od|odsad(a)?)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|pr(ije)?pred)", "/^yes(terday)?/": "^jučer", "/^t(od(ay)?)?/": "^danas", "/^tom(orrow)?/": "^sutra", "/^n(ow)?/": "^sad(a)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sek(und(a|e|i)?)?", "/^mn|min(ute)?s?/": "^mn|min(ut(a|e|i)?)?", "/^h(our)?s?/": "^s(at(a|i)?)?", "/^w(eek)?s?/": "^tj(edan(a|i)?)?", "/^m(onth)?s?/": "^mj(esec(a|i)?)?", "/^d(ay)?s?/": "^dan(a|i)?", "/^y(ear)?s?/": "^god(in(a|e|i|u))?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "hr-BA"; ================================================ FILE: build/production/i18n/hr-HR.js ================================================ /* * DateJS Culture String File * Country Code: hr-HR * Name: Croatian (Croatia) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["hr-HR"] = { "name": "hr-HR", "englishName": "Croatian (Croatia)", "nativeName": "hrvatski (Hrvatska)", "Sunday": "nedjelja", "Monday": "ponedjeljak", "Tuesday": "utorak", "Wednesday": "srijeda", "Thursday": "četvrtak", "Friday": "petak", "Saturday": "subota", "Sun": "ned", "Mon": "pon", "Tue": "uto", "Wed": "sri", "Thu": "čet", "Fri": "pet", "Sat": "sub", "Su": "ne", "Mo": "po", "Tu": "ut", "We": "sr", "Th": "če", "Fr": "pe", "Sa": "su", "S_Sun_Initial": "n", "M_Mon_Initial": "p", "T_Tue_Initial": "u", "W_Wed_Initial": "s", "T_Thu_Initial": "č", "F_Fri_Initial": "p", "S_Sat_Initial": "s", "January": "siječanj", "February": "veljača", "March": "ožujak", "April": "travanj", "May": "svibanj", "June": "lipanj", "July": "srpanj", "August": "kolovoz", "September": "rujan", "October": "listopad", "November": "studeni", "December": "prosinac", "Jan_Abbr": "sij", "Feb_Abbr": "vlj", "Mar_Abbr": "ožu", "Apr_Abbr": "tra", "May_Abbr": "svi", "Jun_Abbr": "lip", "Jul_Abbr": "srp", "Aug_Abbr": "kol", "Sep_Abbr": "ruj", "Oct_Abbr": "lis", "Nov_Abbr": "stu", "Dec_Abbr": "pro", "AM": "", "PM": "", "firstDayOfWeek": 1, "twoDigitYearMax": 2029, "mdy": "dmy", "M/d/yyyy": "d.M.yyyy", "dddd, MMMM dd, yyyy": "d. MMMM yyyy", "h:mm tt": "H:mm", "h:mm:ss tt": "H:mm:ss", "dddd, MMMM dd, yyyy h:mm:ss tt": "d. MMMM yyyy H:mm:ss", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "d. MMMM", "MMMM, yyyy": "MMMM, yyyy", "/jan(uary)?/": "sij(ečanj)?", "/feb(ruary)?/": "veljača", "/mar(ch)?/": "ožu(jak)?", "/apr(il)?/": "tra(vanj)?", "/may/": "svi(banj)?", "/jun(e)?/": "lip(anj)?", "/jul(y)?/": "srp(anj)?", "/aug(ust)?/": "kol(ovoz)?", "/sep(t(ember)?)?/": "ruj(an)?", "/oct(ober)?/": "lis(topad)?", "/nov(ember)?/": "stu(deni)?", "/dec(ember)?/": "pro(sinac)?", "/^su(n(day)?)?/": "^ne(d(jelja)?)?", "/^mo(n(day)?)?/": "^po(n(edjeljak)?)?", "/^tu(e(s(day)?)?)?/": "^ut(o(rak)?)?", "/^we(d(nesday)?)?/": "^sr(i(jeda)?)?", "/^th(u(r(s(day)?)?)?)?/": "^če(t(vrtak)?)?", "/^fr(i(day)?)?/": "^pe(t(ak)?)?", "/^sa(t(urday)?)?/": "^su(b(ota)?)?", "/^next/": "^slijedeć(i|e|eg)", "/^last|past|prev(ious)?/": "^zadnji|posljednji|prethodni", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|pos(lije)?|od|odsad(a)?)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|pr(ije)?pred)", "/^yes(terday)?/": "^jučer", "/^t(od(ay)?)?/": "^danas", "/^tom(orrow)?/": "^sutra", "/^n(ow)?/": "^sad(a)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sek(und(a|e|i)?)?", "/^mn|min(ute)?s?/": "^mn|min(ut(a|e|i)?)?", "/^h(our)?s?/": "^s(at(a|i)?)?", "/^w(eek)?s?/": "^tj(edan(a|i)?)?", "/^m(onth)?s?/": "^mj(esec(a|i)?)?", "/^d(ay)?s?/": "^dan(a|i)?", "/^y(ear)?s?/": "^god(in(a|e|i|u))?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "hr-HR"; ================================================ FILE: build/production/i18n/hu-HU.js ================================================ /* * DateJS Culture String File * Country Code: hu-HU * Name: Hungarian (Hungary) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["hu-HU"] = { "name": "hu-HU", "englishName": "Hungarian (Hungary)", "nativeName": "magyar (Magyarország)", "Sunday": "vasárnap", "Monday": "hétfő", "Tuesday": "kedd", "Wednesday": "szerda", "Thursday": "csütörtök", "Friday": "péntek", "Saturday": "szombat", "Sun": "V", "Mon": "H", "Tue": "K", "Wed": "Sze", "Thu": "Cs", "Fri": "P", "Sat": "Szo", "Su": "V", "Mo": "H", "Tu": "K", "We": "Sze", "Th": "Cs", "Fr": "P", "Sa": "Szo", "S_Sun_Initial": "V", "M_Mon_Initial": "H", "T_Tue_Initial": "K", "W_Wed_Initial": "S", "T_Thu_Initial": "C", "F_Fri_Initial": "P", "S_Sat_Initial": "S", "January": "január", "February": "február", "March": "március", "April": "április", "May": "május", "June": "június", "July": "július", "August": "augusztus", "September": "szeptember", "October": "október", "November": "november", "December": "december", "Jan_Abbr": "jan.", "Feb_Abbr": "febr.", "Mar_Abbr": "márc.", "Apr_Abbr": "ápr.", "May_Abbr": "máj.", "Jun_Abbr": "jún.", "Jul_Abbr": "júl.", "Aug_Abbr": "aug.", "Sep_Abbr": "szept.", "Oct_Abbr": "okt.", "Nov_Abbr": "nov.", "Dec_Abbr": "dec.", "AM": "de.", "PM": "du.", "firstDayOfWeek": 1, "twoDigitYearMax": 2029, "mdy": "ymd", "M/d/yyyy": "yyyy. MM. dd.", "dddd, MMMM dd, yyyy": "yyyy. MMMM d.", "h:mm tt": "H:mm", "h:mm:ss tt": "H:mm:ss", "dddd, MMMM dd, yyyy h:mm:ss tt": "yyyy. MMMM d. H:mm:ss", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "MMMM d.", "MMMM, yyyy": "yyyy. MMMM", "/jan(uary)?/": "jan(.(uár)?)?", "/feb(ruary)?/": "febr(.(uár)?)?", "/mar(ch)?/": "márc(.(ius)?)?", "/apr(il)?/": "ápr(.(ilis)?)?", "/may/": "máj(.(us)?)?", "/jun(e)?/": "jún(.(ius)?)?", "/jul(y)?/": "júl(.(ius)?)?", "/aug(ust)?/": "aug(.(usztus)?)?", "/sep(t(ember)?)?/": "szept(.(ember)?)?", "/oct(ober)?/": "okt(.(óber)?)?", "/nov(ember)?/": "nov(.(ember)?)?", "/dec(ember)?/": "dec(.(ember)?)?", "/^su(n(day)?)?/": "^vasárnap", "/^mo(n(day)?)?/": "^hétfő", "/^tu(e(s(day)?)?)?/": "^kedd", "/^we(d(nesday)?)?/": "^szerda", "/^th(u(r(s(day)?)?)?)?/": "^csütörtök", "/^fr(i(day)?)?/": "^péntek", "/^sa(t(urday)?)?/": "^szombat", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "hu-HU"; ================================================ FILE: build/production/i18n/hy-AM.js ================================================ /* * DateJS Culture String File * Country Code: hy-AM * Name: Armenian (Armenia) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["hy-AM"] = { "name": "hy-AM", "englishName": "Armenian (Armenia)", "nativeName": "Հայերեն (Հայաստան)", "Sunday": "Կիրակի", "Monday": "Երկուշաբթի", "Tuesday": "Երեքշաբթի", "Wednesday": "Չորեքշաբթի", "Thursday": "Հինգշաբթի", "Friday": "ՈՒրբաթ", "Saturday": "Շաբաթ", "Sun": "Կիր", "Mon": "Երկ", "Tue": "Երք", "Wed": "Չրք", "Thu": "Հնգ", "Fri": "ՈՒր", "Sat": "Շբթ", "Su": "Կ", "Mo": "Ե", "Tu": "Ե", "We": "Չ", "Th": "Հ", "Fr": "Ո", "Sa": "Շ", "S_Sun_Initial": "Կ", "M_Mon_Initial": "Ե", "T_Tue_Initial": "Ե", "W_Wed_Initial": "Չ", "T_Thu_Initial": "Հ", "F_Fri_Initial": "Ո", "S_Sat_Initial": "Շ", "January": "Հունվար", "February": "Փետրվար", "March": "Մարտ", "April": "Ապրիլ", "May": "Մայիս", "June": "Հունիս", "July": "Հուլիս", "August": "Օգոստոս", "September": "Սեպտեմբեր", "October": "Հոկտեմբեր", "November": "Նոյեմբեր", "December": "Դեկտեմբեր", "Jan_Abbr": "ՀՆՎ", "Feb_Abbr": "ՓՏՎ", "Mar_Abbr": "ՄՐՏ", "Apr_Abbr": "ԱՊՐ", "May_Abbr": "ՄՅՍ", "Jun_Abbr": "ՀՆՍ", "Jul_Abbr": "ՀԼՍ", "Aug_Abbr": "ՕԳՍ", "Sep_Abbr": "ՍԵՊ", "Oct_Abbr": "ՀՈԿ", "Nov_Abbr": "ՆՈՅ", "Dec_Abbr": "ԴԵԿ", "AM": "", "PM": "", "firstDayOfWeek": 1, "twoDigitYearMax": 2029, "mdy": "dmy", "M/d/yyyy": "dd.MM.yyyy", "dddd, MMMM dd, yyyy": "d MMMM, yyyy", "h:mm tt": "H:mm", "h:mm:ss tt": "H:mm:ss", "dddd, MMMM dd, yyyy h:mm:ss tt": "d MMMM, yyyy H:mm:ss", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "d MMMM", "MMMM, yyyy": "MMMM, yyyy", "/jan(uary)?/": "հունվար", "/feb(ruary)?/": "փետրվար", "/mar(ch)?/": "մարտ", "/apr(il)?/": "ապր(իլ)?", "/may/": "մայիս", "/jun(e)?/": "հունիս", "/jul(y)?/": "հուլիս", "/aug(ust)?/": "օգոստոս", "/sep(t(ember)?)?/": "սեպ(տեմբեր)?", "/oct(ober)?/": "հոկ(տեմբեր)?", "/nov(ember)?/": "նոյ(եմբեր)?", "/dec(ember)?/": "դեկ(տեմբեր)?", "/^su(n(day)?)?/": "^կ(իր(ակի)?)?", "/^mo(n(day)?)?/": "^ե(րկ(ուշաբթի)?)?", "/^tu(e(s(day)?)?)?/": "^ե(րք(քշաբթի)?)?", "/^we(d(nesday)?)?/": "^չ(րք(եքշաբթի)?)?", "/^th(u(r(s(day)?)?)?)?/": "^հ(նգ(գշաբթի)?)?", "/^fr(i(day)?)?/": "^ո(ւր(բաթ)?)?", "/^sa(t(urday)?)?/": "^շ(բթ(աթ)?)?", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "hy-AM"; ================================================ FILE: build/production/i18n/id-ID.js ================================================ /* * DateJS Culture String File * Country Code: id-ID * Name: Indonesian (Indonesia) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["id-ID"] = { "name": "id-ID", "englishName": "Indonesian (Indonesia)", "nativeName": "Bahasa Indonesia (Indonesia)", "Sunday": "Minggu", "Monday": "Senin", "Tuesday": "Selasa", "Wednesday": "Rabu", "Thursday": "Kamis", "Friday": "Jumat", "Saturday": "Sabtu", "Sun": "Minggu", "Mon": "Sen", "Tue": "Sel", "Wed": "Rabu", "Thu": "Kamis", "Fri": "Jumat", "Sat": "Sabtu", "Su": "M", "Mo": "S", "Tu": "S", "We": "R", "Th": "K", "Fr": "J", "Sa": "S", "S_Sun_Initial": "M", "M_Mon_Initial": "S", "T_Tue_Initial": "S", "W_Wed_Initial": "R", "T_Thu_Initial": "K", "F_Fri_Initial": "J", "S_Sat_Initial": "S", "January": "Januari", "February": "Februari", "March": "Maret", "April": "April", "May": "Mei", "June": "Juni", "July": "Juli", "August": "Agustus", "September": "September", "October": "Oktober", "November": "Nopember", "December": "Desember", "Jan_Abbr": "Jan", "Feb_Abbr": "Feb", "Mar_Abbr": "Mar", "Apr_Abbr": "Apr", "May_Abbr": "Mei", "Jun_Abbr": "Jun", "Jul_Abbr": "Jul", "Aug_Abbr": "Agust", "Sep_Abbr": "Sep", "Oct_Abbr": "Okt", "Nov_Abbr": "Nop", "Dec_Abbr": "Des", "AM": "", "PM": "", "firstDayOfWeek": 1, "twoDigitYearMax": 2029, "mdy": "dmy", "M/d/yyyy": "dd/MM/yyyy", "dddd, MMMM dd, yyyy": "dd MMMM yyyy", "h:mm tt": "H:mm", "h:mm:ss tt": "H:mm:ss", "dddd, MMMM dd, yyyy h:mm:ss tt": "dd MMMM yyyy H:mm:ss", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "dd MMMM", "MMMM, yyyy": "MMMM yyyy", "/jan(uary)?/": "jan(uari)?", "/feb(ruary)?/": "feb(ruari)?", "/mar(ch)?/": "mar(et)?", "/apr(il)?/": "apr(il)?", "/may/": "mei", "/jun(e)?/": "jun(i)?", "/jul(y)?/": "jul(i)?", "/aug(ust)?/": "agust(us)?", "/sep(t(ember)?)?/": "sep(t(ember)?)?", "/oct(ober)?/": "okt(ober)?", "/nov(ember)?/": "nop(ember)?", "/dec(ember)?/": "des(ember)?", "/^su(n(day)?)?/": "^m(1)?", "/^mo(n(day)?)?/": "^s(en(in)?)?", "/^tu(e(s(day)?)?)?/": "^s(el(asa)?)?", "/^we(d(nesday)?)?/": "^r(1)?", "/^th(u(r(s(day)?)?)?)?/": "^k(1)?", "/^fr(i(day)?)?/": "^j(1)?", "/^sa(t(urday)?)?/": "^s(1)?", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "id-ID"; ================================================ FILE: build/production/i18n/is-IS.js ================================================ /* * DateJS Culture String File * Country Code: is-IS * Name: Icelandic (Iceland) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["is-IS"] = { "name": "is-IS", "englishName": "Icelandic (Iceland)", "nativeName": "íslenska (Ísland)", "Sunday": "sunnudagur", "Monday": "mánudagur", "Tuesday": "þriðjudagur", "Wednesday": "miðvikudagur", "Thursday": "fimmtudagur", "Friday": "föstudagur", "Saturday": "laugardagur", "Sun": "sun.", "Mon": "mán.", "Tue": "þri.", "Wed": "mið.", "Thu": "fim.", "Fri": "fös.", "Sat": "lau.", "Su": "su", "Mo": "má", "Tu": "þr", "We": "mi", "Th": "fi", "Fr": "fö", "Sa": "la", "S_Sun_Initial": "s", "M_Mon_Initial": "m", "T_Tue_Initial": "þ", "W_Wed_Initial": "m", "T_Thu_Initial": "f", "F_Fri_Initial": "f", "S_Sat_Initial": "l", "January": "janúar", "February": "febrúar", "March": "mars", "April": "apríl", "May": "maí", "June": "júní", "July": "júlí", "August": "ágúst", "September": "september", "October": "október", "November": "nóvember", "December": "desember", "Jan_Abbr": "jan.", "Feb_Abbr": "feb.", "Mar_Abbr": "mar.", "Apr_Abbr": "apr.", "May_Abbr": "maí", "Jun_Abbr": "jún.", "Jul_Abbr": "júl.", "Aug_Abbr": "ágú.", "Sep_Abbr": "sep.", "Oct_Abbr": "okt.", "Nov_Abbr": "nóv.", "Dec_Abbr": "des.", "AM": "", "PM": "", "firstDayOfWeek": 1, "twoDigitYearMax": 2029, "mdy": "dmy", "M/d/yyyy": "d.M.yyyy", "dddd, MMMM dd, yyyy": "d. MMMM yyyy", "h:mm tt": "HH:mm", "h:mm:ss tt": "HH:mm:ss", "dddd, MMMM dd, yyyy h:mm:ss tt": "d. MMMM yyyy HH:mm:ss", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "d. MMMM", "MMMM, yyyy": "MMMM yyyy", "/jan(uary)?/": "jan(.(úar)?)?", "/feb(ruary)?/": "feb(.(rúar)?)?", "/mar(ch)?/": "mar(.(s)?)?", "/apr(il)?/": "apr(.(íl)?)?", "/may/": "maí", "/jun(e)?/": "jún(.(í)?)?", "/jul(y)?/": "júl(.(í)?)?", "/aug(ust)?/": "ágú(.(st)?)?", "/sep(t(ember)?)?/": "sep(t(ember)?)?", "/oct(ober)?/": "okt(.(óber)?)?", "/nov(ember)?/": "nóv(.(ember)?)?", "/dec(ember)?/": "des(.(ember)?)?", "/^su(n(day)?)?/": "^su(n(.(nudagur)?)?)?", "/^mo(n(day)?)?/": "^má(n(.(udagur)?)?)?", "/^tu(e(s(day)?)?)?/": "^þr(i(.(ðjudagur)?)?)?", "/^we(d(nesday)?)?/": "^mi(ð(.(vikudagur)?)?)?", "/^th(u(r(s(day)?)?)?)?/": "^fi(m(.(mtudagur)?)?)?", "/^fr(i(day)?)?/": "^fö(s(.(tudagur)?)?)?", "/^sa(t(urday)?)?/": "^la(u(.(gardagur)?)?)?", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "is-IS"; ================================================ FILE: build/production/i18n/it-CH.js ================================================ /* * DateJS Culture String File * Country Code: it-CH * Name: Italian (Switzerland) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["it-CH"] = { "name": "it-CH", "englishName": "Italian (Switzerland)", "nativeName": "italiano (Svizzera)", "Sunday": "domenica", "Monday": "lunedì", "Tuesday": "martedì", "Wednesday": "mercoledì", "Thursday": "giovedì", "Friday": "venerdì", "Saturday": "sabato", "Sun": "dom", "Mon": "lun", "Tue": "mar", "Wed": "mer", "Thu": "gio", "Fri": "ven", "Sat": "sab", "Su": "do", "Mo": "lu", "Tu": "ma", "We": "me", "Th": "gi", "Fr": "ve", "Sa": "sa", "S_Sun_Initial": "d", "M_Mon_Initial": "l", "T_Tue_Initial": "m", "W_Wed_Initial": "m", "T_Thu_Initial": "g", "F_Fri_Initial": "v", "S_Sat_Initial": "s", "January": "gennaio", "February": "febbraio", "March": "marzo", "April": "aprile", "May": "maggio", "June": "giugno", "July": "luglio", "August": "agosto", "September": "settembre", "October": "ottobre", "November": "novembre", "December": "dicembre", "Jan_Abbr": "gen", "Feb_Abbr": "feb", "Mar_Abbr": "mar", "Apr_Abbr": "apr", "May_Abbr": "mag", "Jun_Abbr": "gio", "Jul_Abbr": "lug", "Aug_Abbr": "ago", "Sep_Abbr": "set", "Oct_Abbr": "ott", "Nov_Abbr": "nov", "Dec_Abbr": "dic", "AM": "", "PM": "", "firstDayOfWeek": 1, "twoDigitYearMax": 2029, "mdy": "dmy", "M/d/yyyy": "dd.MM.yyyy", "dddd, MMMM dd, yyyy": "dddd, d. MMMM yyyy", "h:mm tt": "HH:mm", "h:mm:ss tt": "HH:mm:ss", "dddd, MMMM dd, yyyy h:mm:ss tt": "dddd, d. MMMM yyyy HH:mm:ss", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "d. MMMM", "MMMM, yyyy": "MMMM yyyy", "/jan(uary)?/": "gen(naio)?", "/feb(ruary)?/": "feb(braio)?", "/mar(ch)?/": "mar(zo)?", "/apr(il)?/": "apr(ile)?", "/may/": "mag(gio)?", "/jun(e)?/": "giugno", "/jul(y)?/": "lug(lio)?", "/aug(ust)?/": "ago(sto)?", "/sep(t(ember)?)?/": "set(tembre)?", "/oct(ober)?/": "ott(obre)?", "/nov(ember)?/": "nov(embre)?", "/dec(ember)?/": "dic(embre)?", "/^su(n(day)?)?/": "^do(m(enica)?)?", "/^mo(n(day)?)?/": "^lu(n(edì)?)?", "/^tu(e(s(day)?)?)?/": "^ma(r(tedì)?)?", "/^we(d(nesday)?)?/": "^me(r(coledì)?)?", "/^th(u(r(s(day)?)?)?)?/": "^gi(o(vedì)?)?", "/^fr(i(day)?)?/": "^ve(n(erdì)?)?", "/^sa(t(urday)?)?/": "^sa(b(ato)?)?", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "it-CH"; ================================================ FILE: build/production/i18n/it-IT.js ================================================ /* * DateJS Culture String File * Country Code: it-IT * Name: Italian (Italy) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["it-IT"] = { "name": "it-IT", "englishName": "Italian (Italy)", "nativeName": "italiano (Italia)", "Sunday": "domenica", "Monday": "lunedì", "Tuesday": "martedì", "Wednesday": "mercoledì", "Thursday": "giovedì", "Friday": "venerdì", "Saturday": "sabato", "Sun": "dom", "Mon": "lun", "Tue": "mar", "Wed": "mer", "Thu": "gio", "Fri": "ven", "Sat": "sab", "Su": "do", "Mo": "lu", "Tu": "ma", "We": "me", "Th": "gi", "Fr": "ve", "Sa": "sa", "S_Sun_Initial": "d", "M_Mon_Initial": "l", "T_Tue_Initial": "m", "W_Wed_Initial": "m", "T_Thu_Initial": "g", "F_Fri_Initial": "v", "S_Sat_Initial": "s", "January": "gennaio", "February": "febbraio", "March": "marzo", "April": "aprile", "May": "maggio", "June": "giugno", "July": "luglio", "August": "agosto", "September": "settembre", "October": "ottobre", "November": "novembre", "December": "dicembre", "Jan_Abbr": "gen", "Feb_Abbr": "feb", "Mar_Abbr": "mar", "Apr_Abbr": "apr", "May_Abbr": "mag", "Jun_Abbr": "giu", "Jul_Abbr": "lug", "Aug_Abbr": "ago", "Sep_Abbr": "set", "Oct_Abbr": "ott", "Nov_Abbr": "nov", "Dec_Abbr": "dic", "AM": "", "PM": "", "firstDayOfWeek": 1, "twoDigitYearMax": 2029, "mdy": "dmy", "M/d/yyyy": "dd/MM/yyyy", "dddd, MMMM dd, yyyy": "dddd d MMMM yyyy", "h:mm tt": "H.mm", "h:mm:ss tt": "H.mm.ss", "dddd, MMMM dd, yyyy h:mm:ss tt": "dddd d MMMM yyyy H.mm.ss", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "dd MMMM", "MMMM, yyyy": "MMMM yyyy", "/jan(uary)?/": "gen(naio)?", "/feb(ruary)?/": "feb(braio)?", "/mar(ch)?/": "mar(zo)?", "/apr(il)?/": "apr(ile)?", "/may/": "mag(gio)?", "/jun(e)?/": "giu(gno)?", "/jul(y)?/": "lug(lio)?", "/aug(ust)?/": "ago(sto)?", "/sep(t(ember)?)?/": "set(tembre)?", "/oct(ober)?/": "ott(obre)?", "/nov(ember)?/": "nov(embre)?", "/dec(ember)?/": "dic(embre)?", "/^su(n(day)?)?/": "^do(m(enica)?)?", "/^mo(n(day)?)?/": "^lu(n(edì)?)?", "/^tu(e(s(day)?)?)?/": "^ma(r(tedì)?)?", "/^we(d(nesday)?)?/": "^me(r(coledì)?)?", "/^th(u(r(s(day)?)?)?)?/": "^gi(o(vedì)?)?", "/^fr(i(day)?)?/": "^ve(n(erdì)?)?", "/^sa(t(urday)?)?/": "^sa(b(ato)?)?", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "it-IT"; ================================================ FILE: build/production/i18n/ja-JP.js ================================================ /* * DateJS Culture String File * Country Code: ja-JP * Name: Japanese (Japan) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["ja-JP"] = { "name": "ja-JP", "englishName": "Japanese (Japan)", "nativeName": "日本語 (日本)", "Sunday": "日曜日", "Monday": "月曜日", "Tuesday": "火曜日", "Wednesday": "水曜日", "Thursday": "木曜日", "Friday": "金曜日", "Saturday": "土曜日", "Sun": "日", "Mon": "月", "Tue": "火", "Wed": "水", "Thu": "木", "Fri": "金", "Sat": "土", "Su": "日", "Mo": "月", "Tu": "火", "We": "水", "Th": "木", "Fr": "金", "Sa": "土", "S_Sun_Initial": "日", "M_Mon_Initial": "月", "T_Tue_Initial": "火", "W_Wed_Initial": "水", "T_Thu_Initial": "木", "F_Fri_Initial": "金", "S_Sat_Initial": "土", "January": "1月", "February": "2月", "March": "3月", "April": "4月", "May": "5月", "June": "6月", "July": "7月", "August": "8月", "September": "9月", "October": "10月", "November": "11月", "December": "12月", "Jan_Abbr": "1", "Feb_Abbr": "2", "Mar_Abbr": "3", "Apr_Abbr": "4", "May_Abbr": "5", "Jun_Abbr": "6", "Jul_Abbr": "7", "Aug_Abbr": "8", "Sep_Abbr": "9", "Oct_Abbr": "10", "Nov_Abbr": "11", "Dec_Abbr": "12", "AM": "午前", "PM": "午後", "firstDayOfWeek": 0, "twoDigitYearMax": 2029, "mdy": "ymd", "M/d/yyyy": "yyyy/MM/dd", "dddd, MMMM dd, yyyy": "yyyy'年'M'月'd'日'", "h:mm tt": "H:mm", "h:mm:ss tt": "H:mm:ss", "dddd, MMMM dd, yyyy h:mm:ss tt": "yyyy'年'M'月'd'日' H:mm:ss", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "M'月'd'日'", "MMMM, yyyy": "yyyy'年'M'月'", "/jan(uary)?/": "1(月)?", "/feb(ruary)?/": "2(月)?", "/mar(ch)?/": "3(月)?", "/apr(il)?/": "4(月)?", "/may/": "5(月)?", "/jun(e)?/": "6(月)?", "/jul(y)?/": "7(月)?", "/aug(ust)?/": "8(月)?", "/sep(t(ember)?)?/": "9(月)?", "/oct(ober)?/": "10(月)?", "/nov(ember)?/": "11(月)?", "/dec(ember)?/": "12(月)?", "/^su(n(day)?)?/": "^日曜日", "/^mo(n(day)?)?/": "^月曜日", "/^tu(e(s(day)?)?)?/": "^火曜日", "/^we(d(nesday)?)?/": "^水曜日", "/^th(u(r(s(day)?)?)?)?/": "^木曜日", "/^fr(i(day)?)?/": "^金曜日", "/^sa(t(urday)?)?/": "^土曜日", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "ja-JP"; ================================================ FILE: build/production/i18n/ka-GE.js ================================================ /* * DateJS Culture String File * Country Code: ka-GE * Name: Georgian (Georgia) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["ka-GE"] = { "name": "ka-GE", "englishName": "Georgian (Georgia)", "nativeName": "ქართული (საქართველო)", "Sunday": "კვირა", "Monday": "ორშაბათი", "Tuesday": "სამშაბათი", "Wednesday": "ოთხშაბათი", "Thursday": "ხუთშაბათი", "Friday": "პარასკევი", "Saturday": "შაბათი", "Sun": "კვირა", "Mon": "ორშაბათი", "Tue": "სამშაბათი", "Wed": "ოთხშაბათი", "Thu": "ხუთშაბათი", "Fri": "პარასკევი", "Sat": "შაბათი", "Su": "კ", "Mo": "ო", "Tu": "ს", "We": "ო", "Th": "ხ", "Fr": "პ", "Sa": "შ", "S_Sun_Initial": "კ", "M_Mon_Initial": "ო", "T_Tue_Initial": "ს", "W_Wed_Initial": "ო", "T_Thu_Initial": "ხ", "F_Fri_Initial": "პ", "S_Sat_Initial": "შ", "January": "იანვარი", "February": "თებერვალი", "March": "მარტი", "April": "აპრილი", "May": "მაისი", "June": "ივნისი", "July": "ივლისი", "August": "აგვისტო", "September": "სექტემბერი", "October": "ოქტომბერი", "November": "ნოემბერი", "December": "დეკემბერი", "Jan_Abbr": "იან", "Feb_Abbr": "თებ", "Mar_Abbr": "მარ", "Apr_Abbr": "აპრ", "May_Abbr": "მაის", "Jun_Abbr": "ივნ", "Jul_Abbr": "ივლ", "Aug_Abbr": "აგვ", "Sep_Abbr": "სექ", "Oct_Abbr": "ოქტ", "Nov_Abbr": "ნოემ", "Dec_Abbr": "დეკ", "AM": "", "PM": "", "firstDayOfWeek": 1, "twoDigitYearMax": 2029, "mdy": "dmy", "M/d/yyyy": "dd.MM.yyyy", "dddd, MMMM dd, yyyy": "yyyy 'წლის' dd MM, dddd", "h:mm tt": "H:mm", "h:mm:ss tt": "H:mm:ss", "dddd, MMMM dd, yyyy h:mm:ss tt": "yyyy 'წლის' dd MM, dddd H:mm:ss", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "dd MM", "MMMM, yyyy": "MMMM yyyy", "/jan(uary)?/": "იან(ვარი)?", "/feb(ruary)?/": "თებ(ერვალი)?", "/mar(ch)?/": "მარ(ტი)?", "/apr(il)?/": "აპრ(ილი)?", "/may/": "მაის(ი)?", "/jun(e)?/": "ივნ(ისი)?", "/jul(y)?/": "ივლ(ისი)?", "/aug(ust)?/": "აგვ(ისტო)?", "/sep(t(ember)?)?/": "სექ(ტემბერი)?", "/oct(ober)?/": "ოქტ(ომბერი)?", "/nov(ember)?/": "ნოემ(ბერი)?", "/dec(ember)?/": "დეკ(ემბერი)?", "/^su(n(day)?)?/": "^კ(1)?", "/^mo(n(day)?)?/": "^ო(1)?", "/^tu(e(s(day)?)?)?/": "^ს(1)?", "/^we(d(nesday)?)?/": "^ო(1)?", "/^th(u(r(s(day)?)?)?)?/": "^ხ(1)?", "/^fr(i(day)?)?/": "^პ(1)?", "/^sa(t(urday)?)?/": "^შ(1)?", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "ka-GE"; ================================================ FILE: build/production/i18n/kk-KZ.js ================================================ /* * DateJS Culture String File * Country Code: kk-KZ * Name: Kazakh (Kazakhstan) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["kk-KZ"] = { "name": "kk-KZ", "englishName": "Kazakh (Kazakhstan)", "nativeName": "Қазақ (Қазақстан)", "Sunday": "Жексенбі", "Monday": "Дүйсенбі", "Tuesday": "Сейсенбі", "Wednesday": "Сәрсенбі", "Thursday": "Бейсенбі", "Friday": "Жұма", "Saturday": "Сенбі", "Sun": "Жк", "Mon": "Дс", "Tue": "Сс", "Wed": "Ср", "Thu": "Бс", "Fri": "Жм", "Sat": "Сн", "Su": "Жк", "Mo": "Дс", "Tu": "Сс", "We": "Ср", "Th": "Бс", "Fr": "Жм", "Sa": "Сн", "S_Sun_Initial": "Ж", "M_Mon_Initial": "Д", "T_Tue_Initial": "С", "W_Wed_Initial": "С", "T_Thu_Initial": "Б", "F_Fri_Initial": "Ж", "S_Sat_Initial": "С", "January": "қаңтар", "February": "ақпан", "March": "наурыз", "April": "сәуір", "May": "мамыр", "June": "маусым", "July": "шілде", "August": "тамыз", "September": "қыркүйек", "October": "қазан", "November": "қараша", "December": "желтоқсан", "Jan_Abbr": "Қаң", "Feb_Abbr": "Ақп", "Mar_Abbr": "Нау", "Apr_Abbr": "Сәу", "May_Abbr": "Мам", "Jun_Abbr": "Мау", "Jul_Abbr": "Шіл", "Aug_Abbr": "Там", "Sep_Abbr": "Қыр", "Oct_Abbr": "Қаз", "Nov_Abbr": "Қар", "Dec_Abbr": "Жел", "AM": "", "PM": "", "firstDayOfWeek": 1, "twoDigitYearMax": 2029, "mdy": "dmy", "M/d/yyyy": "dd.MM.yyyy", "dddd, MMMM dd, yyyy": "d MMMM yyyy 'ж.'", "h:mm tt": "H:mm", "h:mm:ss tt": "H:mm:ss", "dddd, MMMM dd, yyyy h:mm:ss tt": "d MMMM yyyy 'ж.' H:mm:ss", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "d MMMM", "MMMM, yyyy": "MMMM yyyy", "/jan(uary)?/": "қаң(тар)?", "/feb(ruary)?/": "ақп(ан)?", "/mar(ch)?/": "нау(рыз)?", "/apr(il)?/": "сәу(ір)?", "/may/": "мам(ыр)?", "/jun(e)?/": "мау(сым)?", "/jul(y)?/": "шіл(де)?", "/aug(ust)?/": "там(ыз)?", "/sep(t(ember)?)?/": "қыр(күйек)?", "/oct(ober)?/": "қаз(ан)?", "/nov(ember)?/": "қар(аша)?", "/dec(ember)?/": "жел(тоқсан)?", "/^su(n(day)?)?/": "^жексенбі", "/^mo(n(day)?)?/": "^дүйсенбі", "/^tu(e(s(day)?)?)?/": "^сейсенбі", "/^we(d(nesday)?)?/": "^сәрсенбі", "/^th(u(r(s(day)?)?)?)?/": "^бейсенбі", "/^fr(i(day)?)?/": "^жұма", "/^sa(t(urday)?)?/": "^сенбі", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "kk-KZ"; ================================================ FILE: build/production/i18n/kn-IN.js ================================================ /* * DateJS Culture String File * Country Code: kn-IN * Name: Kannada (India) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["kn-IN"] = { "name": "kn-IN", "englishName": "Kannada (India)", "nativeName": "ಕನ್ನಡ (ಭಾರತ)", "Sunday": "ಭಾನುವಾರ", "Monday": "ಸೋಮವಾರ", "Tuesday": "ಮಂಗಳವಾರ", "Wednesday": "ಬುಧವಾರ", "Thursday": "ಗುರುವಾರ", "Friday": "ಶುಕ್ರವಾರ", "Saturday": "ಶನಿವಾರ", "Sun": "ಭಾನು.", "Mon": "ಸೋಮ.", "Tue": "ಮಂಗಳ.", "Wed": "ಬುಧ.", "Thu": "ಗುರು.", "Fri": "ಶುಕ್ರ.", "Sat": "ಶನಿ.", "Su": "ರ", "Mo": "ಸ", "Tu": "ಮ", "We": "ಬ", "Th": "ಗ", "Fr": "ಶ", "Sa": "ಶ", "S_Sun_Initial": "ರ", "M_Mon_Initial": "ಸ", "T_Tue_Initial": "ಮ", "W_Wed_Initial": "ಬ", "T_Thu_Initial": "ಗ", "F_Fri_Initial": "ಶ", "S_Sat_Initial": "ಶ", "January": "ಜನವರಿ", "February": "ಫೆಬ್ರವರಿ", "March": "ಮಾರ್ಚ್", "April": "ಎಪ್ರಿಲ್", "May": "ಮೇ", "June": "ಜೂನ್", "July": "ಜುಲೈ", "August": "ಆಗಸ್ಟ್", "September": "ಸೆಪ್ಟಂಬರ್", "October": "ಅಕ್ಟೋಬರ್", "November": "ನವೆಂಬರ್", "December": "ಡಿಸೆಂಬರ್", "Jan_Abbr": "ಜನವರಿ", "Feb_Abbr": "ಫೆಬ್ರವರಿ", "Mar_Abbr": "ಮಾರ್ಚ್", "Apr_Abbr": "ಎಪ್ರಿಲ್", "May_Abbr": "ಮೇ", "Jun_Abbr": "ಜೂನ್", "Jul_Abbr": "ಜುಲೈ", "Aug_Abbr": "ಆಗಸ್ಟ್", "Sep_Abbr": "ಸೆಪ್ಟಂಬರ್", "Oct_Abbr": "ಅಕ್ಟೋಬರ್", "Nov_Abbr": "ನವೆಂಬರ್", "Dec_Abbr": "ಡಿಸೆಂಬರ್", "AM": "ಪೂರ್ವಾಹ್ನ", "PM": "ಅಪರಾಹ್ನ", "firstDayOfWeek": 1, "twoDigitYearMax": 2029, "mdy": "dmy", "M/d/yyyy": "dd-MM-yy", "dddd, MMMM dd, yyyy": "dd MMMM yyyy", "h:mm tt": "HH:mm", "h:mm:ss tt": "HH:mm:ss", "dddd, MMMM dd, yyyy h:mm:ss tt": "dd MMMM yyyy HH:mm:ss", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "dd MMMM", "MMMM, yyyy": "MMMM, yyyy", "/jan(uary)?/": "ಜನವರಿ", "/feb(ruary)?/": "ಫೆಬ್ರವರಿ", "/mar(ch)?/": "ಮಾರ್ಚ್", "/apr(il)?/": "ಎಪ್ರಿಲ್", "/may/": "ಮೇ", "/jun(e)?/": "ಜೂನ್", "/jul(y)?/": "ಜುಲೈ", "/aug(ust)?/": "ಆಗಸ್ಟ್", "/sep(t(ember)?)?/": "ಸೆಪ್ಟಂಬರ್", "/oct(ober)?/": "ಅಕ್ಟೋಬರ್", "/nov(ember)?/": "ನವೆಂಬರ್", "/dec(ember)?/": "ಡಿಸೆಂಬರ್", "/^su(n(day)?)?/": "^ರ(ಾನು(.(ವಾರ)?)?)?", "/^mo(n(day)?)?/": "^ಸ(ೋಮ(.(ವಾರ)?)?)?", "/^tu(e(s(day)?)?)?/": "^ಮ(ಂಗಳ(.(ವಾರ)?)?)?", "/^we(d(nesday)?)?/": "^ಬ(ುಧ(.(ವಾರ)?)?)?", "/^th(u(r(s(day)?)?)?)?/": "^ಗ(ುರು(.(ವಾರ)?)?)?", "/^fr(i(day)?)?/": "^ಶ(ುಕ್ರ(.(ವಾರ)?)?)?", "/^sa(t(urday)?)?/": "^ಶ(ನಿ(.(ವಾರ)?)?)?", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "kn-IN"; ================================================ FILE: build/production/i18n/ko-KR.js ================================================ /* * DateJS Culture String File * Country Code: ko-KR * Name: Korean (Korea) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["ko-KR"] = { "name": "ko-KR", "englishName": "Korean (Korea)", "nativeName": "한국어 (대한민국)", "Sunday": "일요일", "Monday": "월요일", "Tuesday": "화요일", "Wednesday": "수요일", "Thursday": "목요일", "Friday": "금요일", "Saturday": "토요일", "Sun": "일", "Mon": "월", "Tue": "화", "Wed": "수", "Thu": "목", "Fri": "금", "Sat": "토", "Su": "일", "Mo": "월", "Tu": "화", "We": "수", "Th": "목", "Fr": "금", "Sa": "토", "S_Sun_Initial": "일", "M_Mon_Initial": "월", "T_Tue_Initial": "화", "W_Wed_Initial": "수", "T_Thu_Initial": "목", "F_Fri_Initial": "금", "S_Sat_Initial": "토", "January": "1월", "February": "2월", "March": "3월", "April": "4월", "May": "5월", "June": "6월", "July": "7월", "August": "8월", "September": "9월", "October": "10월", "November": "11월", "December": "12월", "Jan_Abbr": "1", "Feb_Abbr": "2", "Mar_Abbr": "3", "Apr_Abbr": "4", "May_Abbr": "5", "Jun_Abbr": "6", "Jul_Abbr": "7", "Aug_Abbr": "8", "Sep_Abbr": "9", "Oct_Abbr": "10", "Nov_Abbr": "11", "Dec_Abbr": "12", "AM": "오전", "PM": "오후", "firstDayOfWeek": 0, "twoDigitYearMax": 2029, "mdy": "ymd", "M/d/yyyy": "yyyy-MM-dd", "dddd, MMMM dd, yyyy": "yyyy'년' M'월' d'일' dddd", "h:mm tt": "tt h:mm", "h:mm:ss tt": "tt h:mm:ss", "dddd, MMMM dd, yyyy h:mm:ss tt": "yyyy'년' M'월' d'일' dddd tt h:mm:ss", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "M'월' d'일'", "MMMM, yyyy": "yyyy'년' M'월'", "/jan(uary)?/": "1(월)?", "/feb(ruary)?/": "2(월)?", "/mar(ch)?/": "3(월)?", "/apr(il)?/": "4(월)?", "/may/": "5(월)?", "/jun(e)?/": "6(월)?", "/jul(y)?/": "7(월)?", "/aug(ust)?/": "8(월)?", "/sep(t(ember)?)?/": "9(월)?", "/oct(ober)?/": "10(월)?", "/nov(ember)?/": "11(월)?", "/dec(ember)?/": "12(월)?", "/^su(n(day)?)?/": "^일요일", "/^mo(n(day)?)?/": "^월요일", "/^tu(e(s(day)?)?)?/": "^화요일", "/^we(d(nesday)?)?/": "^수요일", "/^th(u(r(s(day)?)?)?)?/": "^목요일", "/^fr(i(day)?)?/": "^금요일", "/^sa(t(urday)?)?/": "^토요일", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "ko-KR"; ================================================ FILE: build/production/i18n/kok-IN.js ================================================ /* * DateJS Culture String File * Country Code: kok-IN * Name: Konkani (India) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["kok-IN"] = { "name": "kok-IN", "englishName": "Konkani (India)", "nativeName": "कोंकणी (भारत)", "Sunday": "आयतार", "Monday": "सोमार", "Tuesday": "मंगळार", "Wednesday": "बुधवार", "Thursday": "बिरेस्तार", "Friday": "सुक्रार", "Saturday": "शेनवार", "Sun": "आय.", "Mon": "सोम.", "Tue": "मंगळ.", "Wed": "बुध.", "Thu": "बिरे.", "Fri": "सुक्र.", "Sat": "शेन.", "Su": "आ", "Mo": "स", "Tu": "म", "We": "ब", "Th": "ब", "Fr": "स", "Sa": "श", "S_Sun_Initial": "आ", "M_Mon_Initial": "स", "T_Tue_Initial": "म", "W_Wed_Initial": "ब", "T_Thu_Initial": "ब", "F_Fri_Initial": "स", "S_Sat_Initial": "श", "January": "जानेवारी", "February": "फेब्रुवारी", "March": "मार्च", "April": "एप्रिल", "May": "मे", "June": "जून", "July": "जुलै", "August": "ऑगस्ट", "September": "सप्टेंबर", "October": "ऑक्टोबर", "November": "नोवेम्बर", "December": "डिसेंबर", "Jan_Abbr": "जानेवारी", "Feb_Abbr": "फेब्रुवारी", "Mar_Abbr": "मार्च", "Apr_Abbr": "एप्रिल", "May_Abbr": "मे", "Jun_Abbr": "जून", "Jul_Abbr": "जुलै", "Aug_Abbr": "ऑगस्ट", "Sep_Abbr": "सप्टेंबर", "Oct_Abbr": "ऑक्टोबर", "Nov_Abbr": "नोवेम्बर", "Dec_Abbr": "डिसेंबर", "AM": "म.पू.", "PM": "म.नं.", "firstDayOfWeek": 1, "twoDigitYearMax": 2029, "mdy": "dmy", "M/d/yyyy": "dd-MM-yyyy", "dddd, MMMM dd, yyyy": "dd MMMM yyyy", "h:mm tt": "HH:mm", "h:mm:ss tt": "HH:mm:ss", "dddd, MMMM dd, yyyy h:mm:ss tt": "dd MMMM yyyy HH:mm:ss", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "dd MMMM", "MMMM, yyyy": "MMMM, yyyy", "/jan(uary)?/": "जानेवारी", "/feb(ruary)?/": "फेब्रुवारी", "/mar(ch)?/": "मार्च", "/apr(il)?/": "एप्रिल", "/may/": "मे", "/jun(e)?/": "जून", "/jul(y)?/": "जुलै", "/aug(ust)?/": "ऑगस्ट", "/sep(t(ember)?)?/": "सप्टेंबर", "/oct(ober)?/": "ऑक्टोबर", "/nov(ember)?/": "नोवेम्बर", "/dec(ember)?/": "डिसेंबर", "/^su(n(day)?)?/": "^आ(य(.(तार)?)?)?", "/^mo(n(day)?)?/": "^स(ोम(.(ार)?)?)?", "/^tu(e(s(day)?)?)?/": "^म(ंगळ(.(ार)?)?)?", "/^we(d(nesday)?)?/": "^ब(ुध(.(वार)?)?)?", "/^th(u(r(s(day)?)?)?)?/": "^ब(िरे(.(स्तार)?)?)?", "/^fr(i(day)?)?/": "^स(ुक्र(.(ार)?)?)?", "/^sa(t(urday)?)?/": "^श(ेन(.(वार)?)?)?", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "kok-IN"; ================================================ FILE: build/production/i18n/ky-KG.js ================================================ /* * DateJS Culture String File * Country Code: ky-KG * Name: Kyrgyz (Kyrgyzstan) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["ky-KG"] = { "name": "ky-KG", "englishName": "Kyrgyz (Kyrgyzstan)", "nativeName": "Кыргыз (Кыргызстан)", "Sunday": "Жекшемби", "Monday": "Дүйшөмбү", "Tuesday": "Шейшемби", "Wednesday": "Шаршемби", "Thursday": "Бейшемби", "Friday": "Жума", "Saturday": "Ишемби", "Sun": "Жш", "Mon": "Дш", "Tue": "Шш", "Wed": "Шр", "Thu": "Бш", "Fri": "Жм", "Sat": "Иш", "Su": "Жш", "Mo": "Дш", "Tu": "Шш", "We": "Шр", "Th": "Бш", "Fr": "Жм", "Sa": "Иш", "S_Sun_Initial": "Ж", "M_Mon_Initial": "Д", "T_Tue_Initial": "Ш", "W_Wed_Initial": "Ш", "T_Thu_Initial": "Б", "F_Fri_Initial": "Ж", "S_Sat_Initial": "И", "January": "Январь", "February": "Февраль", "March": "Март", "April": "Апрель", "May": "Май", "June": "Июнь", "July": "Июль", "August": "Август", "September": "Сентябрь", "October": "Октябрь", "November": "Ноябрь", "December": "Декабрь", "Jan_Abbr": "Янв", "Feb_Abbr": "Фев", "Mar_Abbr": "Мар", "Apr_Abbr": "Апр", "May_Abbr": "Май", "Jun_Abbr": "Июн", "Jul_Abbr": "Июл", "Aug_Abbr": "Авг", "Sep_Abbr": "Сен", "Oct_Abbr": "Окт", "Nov_Abbr": "Ноя", "Dec_Abbr": "Дек", "AM": "", "PM": "", "firstDayOfWeek": 1, "twoDigitYearMax": 2029, "mdy": "dmy", "M/d/yyyy": "dd.MM.yy", "dddd, MMMM dd, yyyy": "d'-'MMMM yyyy'-ж.'", "h:mm tt": "H:mm", "h:mm:ss tt": "H:mm:ss", "dddd, MMMM dd, yyyy h:mm:ss tt": "d'-'MMMM yyyy'-ж.' H:mm:ss", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "d MMMM", "MMMM, yyyy": "MMMM yyyy'-ж.'", "/jan(uary)?/": "янв(арь)?", "/feb(ruary)?/": "фев(раль)?", "/mar(ch)?/": "мар(т)?", "/apr(il)?/": "апр(ель)?", "/may/": "май", "/jun(e)?/": "июн(ь)?", "/jul(y)?/": "июл(ь)?", "/aug(ust)?/": "авг(уст)?", "/sep(t(ember)?)?/": "сен(тябрь)?", "/oct(ober)?/": "окт(ябрь)?", "/nov(ember)?/": "ноя(брь)?", "/dec(ember)?/": "дек(абрь)?", "/^su(n(day)?)?/": "^жекшемби", "/^mo(n(day)?)?/": "^дүйшөмбү", "/^tu(e(s(day)?)?)?/": "^шейшемби", "/^we(d(nesday)?)?/": "^шаршемби", "/^th(u(r(s(day)?)?)?)?/": "^бейшемби", "/^fr(i(day)?)?/": "^жума", "/^sa(t(urday)?)?/": "^ишемби", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "ky-KG"; ================================================ FILE: build/production/i18n/lt-LT.js ================================================ /* * DateJS Culture String File * Country Code: lt-LT * Name: Lithuanian (Lithuania) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["lt-LT"] = { "name": "lt-LT", "englishName": "Lithuanian (Lithuania)", "nativeName": "lietuvių (Lietuva)", "Sunday": "sekmadienis", "Monday": "pirmadienis", "Tuesday": "antradienis", "Wednesday": "trečiadienis", "Thursday": "ketvirtadienis", "Friday": "penktadienis", "Saturday": "šeštadienis", "Sun": "Sk", "Mon": "Pr", "Tue": "An", "Wed": "Tr", "Thu": "Kt", "Fri": "Pn", "Sat": "Št", "Su": "S", "Mo": "P", "Tu": "A", "We": "T", "Th": "K", "Fr": "Pn", "Sa": "Š", "S_Sun_Initial": "S", "M_Mon_Initial": "P", "T_Tue_Initial": "A", "W_Wed_Initial": "T", "T_Thu_Initial": "K", "F_Fri_Initial": "P", "S_Sat_Initial": "Š", "January": "sausis", "February": "vasaris", "March": "kovas", "April": "balandis", "May": "gegužė", "June": "birželis", "July": "liepa", "August": "rugpjūtis", "September": "rugsėjis", "October": "spalis", "November": "lapkritis", "December": "gruodis", "Jan_Abbr": "Sau", "Feb_Abbr": "Vas", "Mar_Abbr": "Kov", "Apr_Abbr": "Bal", "May_Abbr": "Geg", "Jun_Abbr": "Bir", "Jul_Abbr": "Lie", "Aug_Abbr": "Rgp", "Sep_Abbr": "Rgs", "Oct_Abbr": "Spl", "Nov_Abbr": "Lap", "Dec_Abbr": "Grd", "AM": "", "PM": "", "firstDayOfWeek": 1, "twoDigitYearMax": 2029, "mdy": "ymd", "M/d/yyyy": "yyyy.MM.dd", "dddd, MMMM dd, yyyy": "yyyy 'm.' MMMM d 'd.'", "h:mm tt": "HH:mm", "h:mm:ss tt": "HH:mm:ss", "dddd, MMMM dd, yyyy h:mm:ss tt": "yyyy 'm.' MMMM d 'd.' HH:mm:ss", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "MMMM d 'd.'", "MMMM, yyyy": "yyyy 'm.' MMMM", "/jan(uary)?/": "sau(sis)?", "/feb(ruary)?/": "vas(aris)?", "/mar(ch)?/": "kov(as)?", "/apr(il)?/": "bal(andis)?", "/may/": "geg(užė)?", "/jun(e)?/": "bir(želis)?", "/jul(y)?/": "lie(pa)?", "/aug(ust)?/": "rugpjūtis", "/sep(t(ember)?)?/": "rugsėjis", "/oct(ober)?/": "spalis", "/nov(ember)?/": "lap(kritis)?", "/dec(ember)?/": "gruodis", "/^su(n(day)?)?/": "^s(k(kmadienis)?)?", "/^mo(n(day)?)?/": "^p(r(rmadienis)?)?", "/^tu(e(s(day)?)?)?/": "^a(n(tradienis)?)?", "/^we(d(nesday)?)?/": "^t(r(ečiadienis)?)?", "/^th(u(r(s(day)?)?)?)?/": "^k(t(tvirtadienis)?)?", "/^fr(i(day)?)?/": "^penktadienis", "/^sa(t(urday)?)?/": "^š(t(štadienis)?)?", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "lt-LT"; ================================================ FILE: build/production/i18n/lv-LV.js ================================================ /* * DateJS Culture String File * Country Code: lv-LV * Name: Latvian (Latvia) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["lv-LV"] = { "name": "lv-LV", "englishName": "Latvian (Latvia)", "nativeName": "latviešu (Latvija)", "Sunday": "svētdiena", "Monday": "pirmdiena", "Tuesday": "otrdiena", "Wednesday": "trešdiena", "Thursday": "ceturtdiena", "Friday": "piektdiena", "Saturday": "sestdiena", "Sun": "Sv", "Mon": "Pr", "Tue": "Ot", "Wed": "Tr", "Thu": "Ce", "Fri": "Pk", "Sat": "Se", "Su": "Sv", "Mo": "Pr", "Tu": "Ot", "We": "Tr", "Th": "Ce", "Fr": "Pk", "Sa": "Se", "S_Sun_Initial": "S", "M_Mon_Initial": "P", "T_Tue_Initial": "O", "W_Wed_Initial": "T", "T_Thu_Initial": "C", "F_Fri_Initial": "P", "S_Sat_Initial": "S", "January": "janvāris", "February": "februāris", "March": "marts", "April": "aprīlis", "May": "maijs", "June": "jūnijs", "July": "jūlijs", "August": "augusts", "September": "septembris", "October": "oktobris", "November": "novembris", "December": "decembris", "Jan_Abbr": "Jan", "Feb_Abbr": "Feb", "Mar_Abbr": "Mar", "Apr_Abbr": "Apr", "May_Abbr": "Mai", "Jun_Abbr": "Jūn", "Jul_Abbr": "Jūl", "Aug_Abbr": "Aug", "Sep_Abbr": "Sep", "Oct_Abbr": "Okt", "Nov_Abbr": "Nov", "Dec_Abbr": "Dec", "AM": "", "PM": "", "firstDayOfWeek": 1, "twoDigitYearMax": 2029, "mdy": "ymd", "M/d/yyyy": "yyyy.MM.dd.", "dddd, MMMM dd, yyyy": "dddd, yyyy'. gada 'd. MMMM", "h:mm tt": "H:mm", "h:mm:ss tt": "H:mm:ss", "dddd, MMMM dd, yyyy h:mm:ss tt": "dddd, yyyy'. gada 'd. MMMM H:mm:ss", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "d. MMMM", "MMMM, yyyy": "yyyy. MMMM", "/jan(uary)?/": "jan(vāris)?", "/feb(ruary)?/": "feb(ruāris)?", "/mar(ch)?/": "mar(ts)?", "/apr(il)?/": "apr(īlis)?", "/may/": "mai(js)?", "/jun(e)?/": "jūn(ijs)?", "/jul(y)?/": "jūl(ijs)?", "/aug(ust)?/": "aug(usts)?", "/sep(t(ember)?)?/": "sep(tembris)?", "/oct(ober)?/": "okt(obris)?", "/nov(ember)?/": "nov(embris)?", "/dec(ember)?/": "dec(embris)?", "/^su(n(day)?)?/": "^svētdiena", "/^mo(n(day)?)?/": "^pirmdiena", "/^tu(e(s(day)?)?)?/": "^otrdiena", "/^we(d(nesday)?)?/": "^trešdiena", "/^th(u(r(s(day)?)?)?)?/": "^ceturtdiena", "/^fr(i(day)?)?/": "^piektdiena", "/^sa(t(urday)?)?/": "^sestdiena", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "lv-LV"; ================================================ FILE: build/production/i18n/mi-NZ.js ================================================ /* * DateJS Culture String File * Country Code: mi-NZ * Name: Maori (New Zealand) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["mi-NZ"] = { "name": "mi-NZ", "englishName": "Maori (New Zealand)", "nativeName": "Reo Māori (Aotearoa)", "Sunday": "Rātapu", "Monday": "Mane", "Tuesday": "Tūrei", "Wednesday": "Wenerei", "Thursday": "Tāite", "Friday": "Paraire", "Saturday": "Hātarei", "Sun": "Ta", "Mon": "Ma", "Tue": "Tū", "Wed": "We", "Thu": "Tāi", "Fri": "Pa", "Sat": "Hā", "Su": "Ta", "Mo": "Ma", "Tu": "Tū", "We": "We", "Th": "Tāi", "Fr": "Pa", "Sa": "Hā", "S_Sun_Initial": "T", "M_Mon_Initial": "M", "T_Tue_Initial": "T", "W_Wed_Initial": "W", "T_Thu_Initial": "T", "F_Fri_Initial": "P", "S_Sat_Initial": "H", "January": "Kohi-tātea", "February": "Hui-tanguru", "March": "Poutū-te-rangi", "April": "Paenga-whāwhā", "May": "Haratua", "June": "Pipiri", "July": "Hōngoingoi", "August": "Here-turi-kōkā", "September": "Mahuru", "October": "Whiringa-ā-nuku", "November": "Whiringa-ā-rangi", "December": "Hakihea", "Jan_Abbr": "Kohi", "Feb_Abbr": "Hui", "Mar_Abbr": "Pou", "Apr_Abbr": "Pae", "May_Abbr": "Hara", "Jun_Abbr": "Pipi", "Jul_Abbr": "Hōngoi", "Aug_Abbr": "Here", "Sep_Abbr": "Mahu", "Oct_Abbr": "Whi-nu", "Nov_Abbr": "Whi-ra", "Dec_Abbr": "Haki", "AM": "a.m.", "PM": "p.m.", "firstDayOfWeek": 1, "twoDigitYearMax": 2029, "mdy": "dmy", "M/d/yyyy": "d/MM/yyyy", "dddd, MMMM dd, yyyy": "dddd, d MMMM yyyy", "h:mm tt": "h:mm:ss tt", "h:mm:ss tt": "h:mm:ss tt", "dddd, MMMM dd, yyyy h:mm:ss tt": "dddd, d MMMM yyyy h:mm:ss tt", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "MMMM dd", "MMMM, yyyy": "MMMM yyyy", "/jan(uary)?/": "kohi(-tātea)?", "/feb(ruary)?/": "hui(-tanguru)?", "/mar(ch)?/": "pou(tū-te-rangi)?", "/apr(il)?/": "pae(nga-whāwhā)?", "/may/": "hara(tua)?", "/jun(e)?/": "pipi(ri)?", "/jul(y)?/": "hōngoi(ngoi)?", "/aug(ust)?/": "here(-turi-kōkā)?", "/sep(t(ember)?)?/": "mahu(ru)?", "/oct(ober)?/": "whiringa-ā-nuku", "/nov(ember)?/": "whiringa-ā-rangi", "/dec(ember)?/": "haki(hea)?", "/^su(n(day)?)?/": "^rātapu", "/^mo(n(day)?)?/": "^mane", "/^tu(e(s(day)?)?)?/": "^tūrei", "/^we(d(nesday)?)?/": "^wenerei", "/^th(u(r(s(day)?)?)?)?/": "^tāite", "/^fr(i(day)?)?/": "^paraire", "/^sa(t(urday)?)?/": "^hātarei", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "mi-NZ"; ================================================ FILE: build/production/i18n/mk-MK.js ================================================ /* * DateJS Culture String File * Country Code: mk-MK * Name: Macedonian (Former Yugoslav Republic of Macedonia) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["mk-MK"] = { "name": "mk-MK", "englishName": "Macedonian (Former Yugoslav Republic of Macedonia)", "nativeName": "македонски јазик (Македонија)", "Sunday": "недела", "Monday": "понеделник", "Tuesday": "вторник", "Wednesday": "среда", "Thursday": "четврток", "Friday": "петок", "Saturday": "сабота", "Sun": "нед", "Mon": "пон", "Tue": "втр", "Wed": "срд", "Thu": "чет", "Fri": "пет", "Sat": "саб", "Su": "не", "Mo": "по", "Tu": "вт", "We": "ср", "Th": "че", "Fr": "пе", "Sa": "са", "S_Sun_Initial": "н", "M_Mon_Initial": "п", "T_Tue_Initial": "в", "W_Wed_Initial": "с", "T_Thu_Initial": "ч", "F_Fri_Initial": "п", "S_Sat_Initial": "с", "January": "јануари", "February": "февруари", "March": "март", "April": "април", "May": "мај", "June": "јуни", "July": "јули", "August": "август", "September": "септември", "October": "октомври", "November": "ноември", "December": "декември", "Jan_Abbr": "јан", "Feb_Abbr": "фев", "Mar_Abbr": "мар", "Apr_Abbr": "апр", "May_Abbr": "мај", "Jun_Abbr": "јун", "Jul_Abbr": "јул", "Aug_Abbr": "авг", "Sep_Abbr": "сеп", "Oct_Abbr": "окт", "Nov_Abbr": "ное", "Dec_Abbr": "дек", "AM": "", "PM": "", "firstDayOfWeek": 1, "twoDigitYearMax": 2029, "mdy": "dmy", "M/d/yyyy": "dd.MM.yyyy", "dddd, MMMM dd, yyyy": "dddd, dd MMMM yyyy", "h:mm tt": "HH:mm", "h:mm:ss tt": "HH:mm:ss", "dddd, MMMM dd, yyyy h:mm:ss tt": "dddd, dd MMMM yyyy HH:mm:ss", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "dd MMMM", "MMMM, yyyy": "MMMM yyyy", "/jan(uary)?/": "јан(уари)?", "/feb(ruary)?/": "фев(руари)?", "/mar(ch)?/": "мар(т)?", "/apr(il)?/": "апр(ил)?", "/may/": "мај", "/jun(e)?/": "јун(и)?", "/jul(y)?/": "јул(и)?", "/aug(ust)?/": "авг(уст)?", "/sep(t(ember)?)?/": "сеп(тември)?", "/oct(ober)?/": "окт(омври)?", "/nov(ember)?/": "ное(мври)?", "/dec(ember)?/": "дек(ември)?", "/^su(n(day)?)?/": "^не(д(ела)?)?", "/^mo(n(day)?)?/": "^по(н(еделник)?)?", "/^tu(e(s(day)?)?)?/": "^вт(р(рник)?)?", "/^we(d(nesday)?)?/": "^ср(д(да)?)?", "/^th(u(r(s(day)?)?)?)?/": "^че(т(врток)?)?", "/^fr(i(day)?)?/": "^пе(т(ок)?)?", "/^sa(t(urday)?)?/": "^са(б(ота)?)?", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "mk-MK"; ================================================ FILE: build/production/i18n/mn-MN.js ================================================ /* * DateJS Culture String File * Country Code: mn-MN * Name: Mongolian (Cyrillic, Mongolia) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["mn-MN"] = { "name": "mn-MN", "englishName": "Mongolian (Cyrillic, Mongolia)", "nativeName": "Монгол хэл (Монгол улс)", "Sunday": "Ням", "Monday": "Даваа", "Tuesday": "Мягмар", "Wednesday": "Лхагва", "Thursday": "Пүрэв", "Friday": "Баасан", "Saturday": "Бямба", "Sun": "Ня", "Mon": "Да", "Tue": "Мя", "Wed": "Лх", "Thu": "Пү", "Fri": "Ба", "Sat": "Бя", "Su": "Ня", "Mo": "Да", "Tu": "Мя", "We": "Лх", "Th": "Пү", "Fr": "Ба", "Sa": "Бя", "S_Sun_Initial": "Н", "M_Mon_Initial": "Д", "T_Tue_Initial": "М", "W_Wed_Initial": "Л", "T_Thu_Initial": "П", "F_Fri_Initial": "Б", "S_Sat_Initial": "Б", "January": "1 дүгээр сар", "February": "2 дугаар сар", "March": "3 дугаар сар", "April": "4 дүгээр сар", "May": "5 дугаар сар", "June": "6 дугаар сар", "July": "7 дугаар сар", "August": "8 дугаар сар", "September": "9 дүгээр сар", "October": "10 дугаар сар", "November": "11 дүгээр сар", "December": "12 дугаар сар", "Jan_Abbr": "I", "Feb_Abbr": "II", "Mar_Abbr": "III", "Apr_Abbr": "IV", "May_Abbr": "V", "Jun_Abbr": "VI", "Jul_Abbr": "VII", "Aug_Abbr": "VШ", "Sep_Abbr": "IX", "Oct_Abbr": "X", "Nov_Abbr": "XI", "Dec_Abbr": "XII", "AM": "", "PM": "", "firstDayOfWeek": 1, "twoDigitYearMax": 2029, "mdy": "ymd", "M/d/yyyy": "yy.MM.dd", "dddd, MMMM dd, yyyy": "yyyy 'оны' MMMM d", "h:mm tt": "H:mm", "h:mm:ss tt": "H:mm:ss", "dddd, MMMM dd, yyyy h:mm:ss tt": "yyyy 'оны' MMMM d H:mm:ss", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "d MMMM", "MMMM, yyyy": "yyyy 'он' MMMM", "/jan(uary)?/": "1 дүгээр сар", "/feb(ruary)?/": "2 дугаар сар", "/mar(ch)?/": "3 дугаар сар", "/apr(il)?/": "4 дүгээр сар", "/may/": "5 дугаар сар", "/jun(e)?/": "6 дугаар сар", "/jul(y)?/": "7 дугаар сар", "/aug(ust)?/": "8 дугаар сар", "/sep(t(ember)?)?/": "9 дүгээр сар", "/oct(ober)?/": "10 дугаар сар", "/nov(ember)?/": "11 дүгээр сар", "/dec(ember)?/": "12 дугаар сар", "/^su(n(day)?)?/": "^ням", "/^mo(n(day)?)?/": "^даваа", "/^tu(e(s(day)?)?)?/": "^мягмар", "/^we(d(nesday)?)?/": "^лхагва", "/^th(u(r(s(day)?)?)?)?/": "^пүрэв", "/^fr(i(day)?)?/": "^баасан", "/^sa(t(urday)?)?/": "^бямба", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "mn-MN"; ================================================ FILE: build/production/i18n/mr-IN.js ================================================ /* * DateJS Culture String File * Country Code: mr-IN * Name: Marathi (India) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["mr-IN"] = { "name": "mr-IN", "englishName": "Marathi (India)", "nativeName": "मराठी (भारत)", "Sunday": "रविवार", "Monday": "सोमवार", "Tuesday": "मंगळवार", "Wednesday": "बुधवार", "Thursday": "गुरुवार", "Friday": "शुक्रवार", "Saturday": "शनिवार", "Sun": "रवि.", "Mon": "सोम.", "Tue": "मंगळ.", "Wed": "बुध.", "Thu": "गुरु.", "Fri": "शुक्र.", "Sat": "शनि.", "Su": "र", "Mo": "स", "Tu": "म", "We": "ब", "Th": "ग", "Fr": "श", "Sa": "श", "S_Sun_Initial": "र", "M_Mon_Initial": "स", "T_Tue_Initial": "म", "W_Wed_Initial": "ब", "T_Thu_Initial": "ग", "F_Fri_Initial": "श", "S_Sat_Initial": "श", "January": "जानेवारी", "February": "फेब्रुवारी", "March": "मार्च", "April": "एप्रिल", "May": "मे", "June": "जून", "July": "जुलै", "August": "ऑगस्ट", "September": "सप्टेंबर", "October": "ऑक्टोबर", "November": "नोव्हेंबर", "December": "डिसेंबर", "Jan_Abbr": "जाने.", "Feb_Abbr": "फेब्रु.", "Mar_Abbr": "मार्च", "Apr_Abbr": "एप्रिल", "May_Abbr": "मे", "Jun_Abbr": "जून", "Jul_Abbr": "जुलै", "Aug_Abbr": "ऑगस्ट", "Sep_Abbr": "सप्टें.", "Oct_Abbr": "ऑक्टो.", "Nov_Abbr": "नोव्हें.", "Dec_Abbr": "डिसें.", "AM": "म.पू.", "PM": "म.नं.", "firstDayOfWeek": 1, "twoDigitYearMax": 2029, "mdy": "dmy", "M/d/yyyy": "dd-MM-yyyy", "dddd, MMMM dd, yyyy": "dd MMMM yyyy", "h:mm tt": "HH:mm", "h:mm:ss tt": "HH:mm:ss", "dddd, MMMM dd, yyyy h:mm:ss tt": "dd MMMM yyyy HH:mm:ss", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "dd MMMM", "MMMM, yyyy": "MMMM, yyyy", "/jan(uary)?/": "जाने(.(वारी)?)?", "/feb(ruary)?/": "फेब्रु(.(वारी)?)?", "/mar(ch)?/": "मार्च", "/apr(il)?/": "एप्रिल", "/may/": "मे", "/jun(e)?/": "जून", "/jul(y)?/": "जुलै", "/aug(ust)?/": "ऑगस्ट", "/sep(t(ember)?)?/": "सप्टें(.(बर)?)?", "/oct(ober)?/": "ऑक्टो(.(बर)?)?", "/nov(ember)?/": "नोव्हें(.(बर)?)?", "/dec(ember)?/": "डिसें(.(बर)?)?", "/^su(n(day)?)?/": "^र(वि(.(वार)?)?)?", "/^mo(n(day)?)?/": "^स(ोम(.(वार)?)?)?", "/^tu(e(s(day)?)?)?/": "^म(ंगळ(.(वार)?)?)?", "/^we(d(nesday)?)?/": "^ब(ुध(.(वार)?)?)?", "/^th(u(r(s(day)?)?)?)?/": "^ग(ुरु(.(वार)?)?)?", "/^fr(i(day)?)?/": "^श(ुक्र(.(वार)?)?)?", "/^sa(t(urday)?)?/": "^श(नि(.(वार)?)?)?", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "mr-IN"; ================================================ FILE: build/production/i18n/ms-BN.js ================================================ /* * DateJS Culture String File * Country Code: ms-BN * Name: Malay (Brunei Darussalam) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["ms-BN"] = { "name": "ms-BN", "englishName": "Malay (Brunei Darussalam)", "nativeName": "Bahasa Malaysia (Brunei Darussalam)", "Sunday": "Ahad", "Monday": "Isnin", "Tuesday": "Selasa", "Wednesday": "Rabu", "Thursday": "Khamis", "Friday": "Jumaat", "Saturday": "Sabtu", "Sun": "Ahad", "Mon": "Isnin", "Tue": "Sel", "Wed": "Rabu", "Thu": "Khamis", "Fri": "Jumaat", "Sat": "Sabtu", "Su": "A", "Mo": "I", "Tu": "S", "We": "R", "Th": "K", "Fr": "J", "Sa": "S", "S_Sun_Initial": "A", "M_Mon_Initial": "I", "T_Tue_Initial": "S", "W_Wed_Initial": "R", "T_Thu_Initial": "K", "F_Fri_Initial": "J", "S_Sat_Initial": "S", "January": "Januari", "February": "Februari", "March": "Mac", "April": "April", "May": "Mei", "June": "Jun", "July": "Julai", "August": "Ogos", "September": "September", "October": "Oktober", "November": "November", "December": "Disember", "Jan_Abbr": "Jan", "Feb_Abbr": "Feb", "Mar_Abbr": "Mac", "Apr_Abbr": "Apr", "May_Abbr": "Mei", "Jun_Abbr": "Jun", "Jul_Abbr": "Jul", "Aug_Abbr": "Ogos", "Sep_Abbr": "Sept", "Oct_Abbr": "Okt", "Nov_Abbr": "Nov", "Dec_Abbr": "Dis", "AM": "", "PM": "", "firstDayOfWeek": 1, "twoDigitYearMax": 2029, "mdy": "dmy", "M/d/yyyy": "dd/MM/yyyy", "dddd, MMMM dd, yyyy": "dd MMMM yyyy", "h:mm tt": "H:mm", "h:mm:ss tt": "H:mm:ss", "dddd, MMMM dd, yyyy h:mm:ss tt": "dd MMMM yyyy H:mm:ss", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "dd MMMM", "MMMM, yyyy": "MMMM yyyy", "/jan(uary)?/": "jan(uari)?", "/feb(ruary)?/": "feb(ruari)?", "/mar(ch)?/": "mac", "/apr(il)?/": "apr(il)?", "/may/": "mei", "/jun(e)?/": "jun", "/jul(y)?/": "jul(ai)?", "/aug(ust)?/": "ogos", "/sep(t(ember)?)?/": "sep(t(ember)?)?", "/oct(ober)?/": "okt(ober)?", "/nov(ember)?/": "nov(ember)?", "/dec(ember)?/": "dis(ember)?", "/^su(n(day)?)?/": "^a(1)?", "/^mo(n(day)?)?/": "^i(1)?", "/^tu(e(s(day)?)?)?/": "^s(el(asa)?)?", "/^we(d(nesday)?)?/": "^r(1)?", "/^th(u(r(s(day)?)?)?)?/": "^k(1)?", "/^fr(i(day)?)?/": "^j(1)?", "/^sa(t(urday)?)?/": "^s(1)?", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "ms-BN"; ================================================ FILE: build/production/i18n/ms-MY.js ================================================ /* * DateJS Culture String File * Country Code: ms-MY * Name: Malay (Malaysia) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["ms-MY"] = { "name": "ms-MY", "englishName": "Malay (Malaysia)", "nativeName": "Bahasa Malaysia (Malaysia)", "Sunday": "Ahad", "Monday": "Isnin", "Tuesday": "Selasa", "Wednesday": "Rabu", "Thursday": "Khamis", "Friday": "Jumaat", "Saturday": "Sabtu", "Sun": "Ahad", "Mon": "Isnin", "Tue": "Sel", "Wed": "Rabu", "Thu": "Khamis", "Fri": "Jumaat", "Sat": "Sabtu", "Su": "A", "Mo": "I", "Tu": "S", "We": "R", "Th": "K", "Fr": "J", "Sa": "S", "S_Sun_Initial": "A", "M_Mon_Initial": "I", "T_Tue_Initial": "S", "W_Wed_Initial": "R", "T_Thu_Initial": "K", "F_Fri_Initial": "J", "S_Sat_Initial": "S", "January": "Januari", "February": "Februari", "March": "Mac", "April": "April", "May": "Mei", "June": "Jun", "July": "Julai", "August": "Ogos", "September": "September", "October": "Oktober", "November": "November", "December": "Disember", "Jan_Abbr": "Jan", "Feb_Abbr": "Feb", "Mar_Abbr": "Mac", "Apr_Abbr": "Apr", "May_Abbr": "Mei", "Jun_Abbr": "Jun", "Jul_Abbr": "Jul", "Aug_Abbr": "Ogos", "Sep_Abbr": "Sept", "Oct_Abbr": "Okt", "Nov_Abbr": "Nov", "Dec_Abbr": "Dis", "AM": "", "PM": "", "firstDayOfWeek": 1, "twoDigitYearMax": 2029, "mdy": "dmy", "M/d/yyyy": "dd/MM/yyyy", "dddd, MMMM dd, yyyy": "dd MMMM yyyy", "h:mm tt": "H:mm", "h:mm:ss tt": "H:mm:ss", "dddd, MMMM dd, yyyy h:mm:ss tt": "dd MMMM yyyy H:mm:ss", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "dd MMMM", "MMMM, yyyy": "MMMM yyyy", "/jan(uary)?/": "jan(uari)?", "/feb(ruary)?/": "feb(ruari)?", "/mar(ch)?/": "mac", "/apr(il)?/": "apr(il)?", "/may/": "mei", "/jun(e)?/": "jun", "/jul(y)?/": "jul(ai)?", "/aug(ust)?/": "ogos", "/sep(t(ember)?)?/": "sep(t(ember)?)?", "/oct(ober)?/": "okt(ober)?", "/nov(ember)?/": "nov(ember)?", "/dec(ember)?/": "dis(ember)?", "/^su(n(day)?)?/": "^a(1)?", "/^mo(n(day)?)?/": "^i(1)?", "/^tu(e(s(day)?)?)?/": "^s(el(asa)?)?", "/^we(d(nesday)?)?/": "^r(1)?", "/^th(u(r(s(day)?)?)?)?/": "^k(1)?", "/^fr(i(day)?)?/": "^j(1)?", "/^sa(t(urday)?)?/": "^s(1)?", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "ms-MY"; ================================================ FILE: build/production/i18n/mt-MT.js ================================================ /* * DateJS Culture String File * Country Code: mt-MT * Name: Maltese (Malta) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["mt-MT"] = { "name": "mt-MT", "englishName": "Maltese (Malta)", "nativeName": "Malti (Malta)", "Sunday": "Il-Ħadd", "Monday": "It-Tnejn", "Tuesday": "It-Tlieta", "Wednesday": "L-Erbgħa", "Thursday": "Il-Ħamis", "Friday": "Il-Ġimgħa", "Saturday": "Is-Sibt", "Sun": "Ħad", "Mon": "Tne", "Tue": "Tli", "Wed": "Erb", "Thu": "Ħam", "Fri": "Ġim", "Sat": "Sib", "Su": "Ħad", "Mo": "Tne", "Tu": "Tli", "We": "Erb", "Th": "Ħam", "Fr": "Ġim", "Sa": "Sib", "S_Sun_Initial": "Ħ", "M_Mon_Initial": "T", "T_Tue_Initial": "T", "W_Wed_Initial": "E", "T_Thu_Initial": "Ħ", "F_Fri_Initial": "Ġ", "S_Sat_Initial": "S", "January": "Jannar", "February": "Frar", "March": "Marzu", "April": "April", "May": "Mejju", "June": "Ġunju", "July": "Lulju", "August": "Awissu", "September": "Settembru", "October": "Ottubru", "November": "Novembru", "December": "Diċembru", "Jan_Abbr": "Jan", "Feb_Abbr": "Fra", "Mar_Abbr": "Mar", "Apr_Abbr": "Apr", "May_Abbr": "Mej", "Jun_Abbr": "Ġun", "Jul_Abbr": "Lul", "Aug_Abbr": "Awi", "Sep_Abbr": "Set", "Oct_Abbr": "Ott", "Nov_Abbr": "Nov", "Dec_Abbr": "Diċ", "AM": "AM", "PM": "PM", "firstDayOfWeek": 1, "twoDigitYearMax": 2029, "mdy": "dmy", "M/d/yyyy": "dd/MM/yyyy", "dddd, MMMM dd, yyyy": "dddd, d' ta' 'MMMM yyyy", "h:mm tt": "HH:mm:ss", "h:mm:ss tt": "HH:mm:ss", "dddd, MMMM dd, yyyy h:mm:ss tt": "dddd, d' ta' 'MMMM yyyy HH:mm:ss", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "MMMM dd", "MMMM, yyyy": "MMMM yyyy", "/jan(uary)?/": "jan(nar)?", "/feb(ruary)?/": "fra(r)?", "/mar(ch)?/": "mar(zu)?", "/apr(il)?/": "apr(il)?", "/may/": "mej(ju)?", "/jun(e)?/": "ġun(ju)?", "/jul(y)?/": "lul(ju)?", "/aug(ust)?/": "awi(ssu)?", "/sep(t(ember)?)?/": "set(tembru)?", "/oct(ober)?/": "ott(ubru)?", "/nov(ember)?/": "nov(embru)?", "/dec(ember)?/": "diċ(embru)?", "/^su(n(day)?)?/": "^il-ħadd", "/^mo(n(day)?)?/": "^it-tnejn", "/^tu(e(s(day)?)?)?/": "^it-tlieta", "/^we(d(nesday)?)?/": "^l-erbgħa", "/^th(u(r(s(day)?)?)?)?/": "^il-ħamis", "/^fr(i(day)?)?/": "^il-ġimgħa", "/^sa(t(urday)?)?/": "^is-sibt", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "mt-MT"; ================================================ FILE: build/production/i18n/nb-NO.js ================================================ /* * DateJS Culture String File * Country Code: nb-NO * Name: Norwegian, Bokmål (Norway) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["nb-NO"] = { "name": "nb-NO", "englishName": "Norwegian, Bokmål (Norway)", "nativeName": "norsk, bokmål (Norge)", "Sunday": "søndag", "Monday": "mandag", "Tuesday": "tirsdag", "Wednesday": "onsdag", "Thursday": "torsdag", "Friday": "fredag", "Saturday": "lørdag", "Sun": "sø", "Mon": "ma", "Tue": "ti", "Wed": "on", "Thu": "to", "Fri": "fr", "Sat": "lø", "Su": "sø", "Mo": "ma", "Tu": "ti", "We": "on", "Th": "to", "Fr": "fr", "Sa": "lø", "S_Sun_Initial": "s", "M_Mon_Initial": "m", "T_Tue_Initial": "t", "W_Wed_Initial": "o", "T_Thu_Initial": "t", "F_Fri_Initial": "f", "S_Sat_Initial": "l", "January": "januar", "February": "februar", "March": "mars", "April": "april", "May": "mai", "June": "juni", "July": "juli", "August": "august", "September": "september", "October": "oktober", "November": "november", "December": "desember", "Jan_Abbr": "jan", "Feb_Abbr": "feb", "Mar_Abbr": "mar", "Apr_Abbr": "apr", "May_Abbr": "mai", "Jun_Abbr": "jun", "Jul_Abbr": "jul", "Aug_Abbr": "aug", "Sep_Abbr": "sep", "Oct_Abbr": "okt", "Nov_Abbr": "nov", "Dec_Abbr": "des", "AM": "", "PM": "", "firstDayOfWeek": 1, "twoDigitYearMax": 2029, "mdy": "dmy", "M/d/yyyy": "dd.MM.yyyy", "dddd, MMMM dd, yyyy": "d. MMMM yyyy", "h:mm tt": "HH:mm", "h:mm:ss tt": "HH:mm:ss", "dddd, MMMM dd, yyyy h:mm:ss tt": "d. MMMM yyyy HH:mm:ss", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "d. MMMM", "MMMM, yyyy": "MMMM yyyy", "/jan(uary)?/": "jan(uar)?", "/feb(ruary)?/": "feb(ruar)?", "/mar(ch)?/": "mar(s)?", "/apr(il)?/": "apr(il)?", "/may/": "mai", "/jun(e)?/": "jun(i)?", "/jul(y)?/": "jul(i)?", "/aug(ust)?/": "aug(ust)?", "/sep(t(ember)?)?/": "sep(t(ember)?)?", "/oct(ober)?/": "okt(ober)?", "/nov(ember)?/": "nov(ember)?", "/dec(ember)?/": "des(ember)?", "/^su(n(day)?)?/": "^søndag", "/^mo(n(day)?)?/": "^mandag", "/^tu(e(s(day)?)?)?/": "^tirsdag", "/^we(d(nesday)?)?/": "^onsdag", "/^th(u(r(s(day)?)?)?)?/": "^torsdag", "/^fr(i(day)?)?/": "^fredag", "/^sa(t(urday)?)?/": "^lørdag", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "nb-NO"; ================================================ FILE: build/production/i18n/nl-BE.js ================================================ /* * DateJS Culture String File * Country Code: nl-BE * Name: Dutch (Belgium) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["nl-BE"] = { "name": "nl-BE", "englishName": "Dutch (Belgium)", "nativeName": "Nederlands (België)", "Sunday": "zondag", "Monday": "maandag", "Tuesday": "dinsdag", "Wednesday": "woensdag", "Thursday": "donderdag", "Friday": "vrijdag", "Saturday": "zaterdag", "Sun": "zo", "Mon": "ma", "Tue": "di", "Wed": "wo", "Thu": "do", "Fri": "vr", "Sat": "za", "Su": "zo", "Mo": "ma", "Tu": "di", "We": "wo", "Th": "do", "Fr": "vr", "Sa": "za", "S_Sun_Initial": "z", "M_Mon_Initial": "m", "T_Tue_Initial": "d", "W_Wed_Initial": "w", "T_Thu_Initial": "d", "F_Fri_Initial": "v", "S_Sat_Initial": "z", "January": "januari", "February": "februari", "March": "maart", "April": "april", "May": "mei", "June": "juni", "July": "juli", "August": "augustus", "September": "september", "October": "oktober", "November": "november", "December": "december", "Jan_Abbr": "jan", "Feb_Abbr": "feb", "Mar_Abbr": "mrt", "Apr_Abbr": "apr", "May_Abbr": "mei", "Jun_Abbr": "jun", "Jul_Abbr": "jul", "Aug_Abbr": "aug", "Sep_Abbr": "sep", "Oct_Abbr": "okt", "Nov_Abbr": "nov", "Dec_Abbr": "dec", "AM": "", "PM": "", "firstDayOfWeek": 1, "twoDigitYearMax": 2029, "mdy": "dmy", "M/d/yyyy": "d/MM/yyyy", "dddd, MMMM dd, yyyy": "dddd d MMMM yyyy", "h:mm tt": "H:mm", "h:mm:ss tt": "H:mm:ss", "dddd, MMMM dd, yyyy h:mm:ss tt": "dddd d MMMM yyyy H:mm:ss", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "dd MMMM", "MMMM, yyyy": "MMMM yyyy", "/jan(uary)?/": "jan(uari)?", "/feb(ruary)?/": "feb(ruari)?", "/mar(ch)?/": "maart", "/apr(il)?/": "apr(il)?", "/may/": "mei", "/jun(e)?/": "jun(i)?", "/jul(y)?/": "jul(i)?", "/aug(ust)?/": "aug(ustus)?", "/sep(t(ember)?)?/": "sep(t(ember)?)?", "/oct(ober)?/": "okt(ober)?", "/nov(ember)?/": "nov(ember)?", "/dec(ember)?/": "dec(ember)?", "/^su(n(day)?)?/": "^zondag", "/^mo(n(day)?)?/": "^maandag", "/^tu(e(s(day)?)?)?/": "^dinsdag", "/^we(d(nesday)?)?/": "^woensdag", "/^th(u(r(s(day)?)?)?)?/": "^donderdag", "/^fr(i(day)?)?/": "^vrijdag", "/^sa(t(urday)?)?/": "^zaterdag", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "nl-BE"; ================================================ FILE: build/production/i18n/nl-NL.js ================================================ /* * DateJS Culture String File * Country Code: nl-NL * Name: Dutch (Netherlands) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["nl-NL"] = { "name": "nl-NL", "englishName": "Dutch (Netherlands)", "nativeName": "Nederlands (Nederland)", "Sunday": "zondag", "Monday": "maandag", "Tuesday": "dinsdag", "Wednesday": "woensdag", "Thursday": "donderdag", "Friday": "vrijdag", "Saturday": "zaterdag", "Sun": "zo", "Mon": "ma", "Tue": "di", "Wed": "wo", "Thu": "do", "Fri": "vr", "Sat": "za", "Su": "zo", "Mo": "ma", "Tu": "di", "We": "wo", "Th": "do", "Fr": "vr", "Sa": "za", "S_Sun_Initial": "z", "M_Mon_Initial": "m", "T_Tue_Initial": "d", "W_Wed_Initial": "w", "T_Thu_Initial": "d", "F_Fri_Initial": "v", "S_Sat_Initial": "z", "January": "januari", "February": "februari", "March": "maart", "April": "april", "May": "mei", "June": "juni", "July": "juli", "August": "augustus", "September": "september", "October": "oktober", "November": "november", "December": "december", "Jan_Abbr": "jan", "Feb_Abbr": "feb", "Mar_Abbr": "mrt", "Apr_Abbr": "apr", "May_Abbr": "mei", "Jun_Abbr": "jun", "Jul_Abbr": "jul", "Aug_Abbr": "aug", "Sep_Abbr": "sep", "Oct_Abbr": "okt", "Nov_Abbr": "nov", "Dec_Abbr": "dec", "AM": "", "PM": "", "firstDayOfWeek": 1, "twoDigitYearMax": 2029, "mdy": "dmy", "M/d/yyyy": "d-M-yyyy", "dddd, MMMM dd, yyyy": "dddd d MMMM yyyy", "h:mm tt": "H:mm", "h:mm:ss tt": "H:mm:ss", "dddd, MMMM dd, yyyy h:mm:ss tt": "dddd d MMMM yyyy H:mm:ss", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "dd MMMM", "MMMM, yyyy": "MMMM yyyy", "/jan(uary)?/": "jan(uari)?", "/feb(ruary)?/": "feb(ruari)?", "/mar(ch)?/": "maart", "/apr(il)?/": "apr(il)?", "/may/": "mei", "/jun(e)?/": "jun(i)?", "/jul(y)?/": "jul(i)?", "/aug(ust)?/": "aug(ustus)?", "/sep(t(ember)?)?/": "sep(t(ember)?)?", "/oct(ober)?/": "okt(ober)?", "/nov(ember)?/": "nov(ember)?", "/dec(ember)?/": "dec(ember)?", "/^su(n(day)?)?/": "^zondag", "/^mo(n(day)?)?/": "^maandag", "/^tu(e(s(day)?)?)?/": "^dinsdag", "/^we(d(nesday)?)?/": "^woensdag", "/^th(u(r(s(day)?)?)?)?/": "^donderdag", "/^fr(i(day)?)?/": "^vrijdag", "/^sa(t(urday)?)?/": "^zaterdag", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "nl-NL"; ================================================ FILE: build/production/i18n/nn-NO.js ================================================ /* * DateJS Culture String File * Country Code: nn-NO * Name: Norwegian, Nynorsk (Norway) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["nn-NO"] = { "name": "nn-NO", "englishName": "Norwegian, Nynorsk (Norway)", "nativeName": "norsk, nynorsk (Noreg)", "Sunday": "søndag", "Monday": "måndag", "Tuesday": "tysdag", "Wednesday": "onsdag", "Thursday": "torsdag", "Friday": "fredag", "Saturday": "laurdag", "Sun": "sø", "Mon": "må", "Tue": "ty", "Wed": "on", "Thu": "to", "Fri": "fr", "Sat": "la", "Su": "sø", "Mo": "må", "Tu": "ty", "We": "on", "Th": "to", "Fr": "fr", "Sa": "la", "S_Sun_Initial": "s", "M_Mon_Initial": "m", "T_Tue_Initial": "t", "W_Wed_Initial": "o", "T_Thu_Initial": "t", "F_Fri_Initial": "f", "S_Sat_Initial": "l", "January": "januar", "February": "februar", "March": "mars", "April": "april", "May": "mai", "June": "juni", "July": "juli", "August": "august", "September": "september", "October": "oktober", "November": "november", "December": "desember", "Jan_Abbr": "jan", "Feb_Abbr": "feb", "Mar_Abbr": "mar", "Apr_Abbr": "apr", "May_Abbr": "mai", "Jun_Abbr": "jun", "Jul_Abbr": "jul", "Aug_Abbr": "aug", "Sep_Abbr": "sep", "Oct_Abbr": "okt", "Nov_Abbr": "nov", "Dec_Abbr": "des", "AM": "", "PM": "", "firstDayOfWeek": 1, "twoDigitYearMax": 2029, "mdy": "dmy", "M/d/yyyy": "dd.MM.yyyy", "dddd, MMMM dd, yyyy": "d. MMMM yyyy", "h:mm tt": "HH:mm", "h:mm:ss tt": "HH:mm:ss", "dddd, MMMM dd, yyyy h:mm:ss tt": "d. MMMM yyyy HH:mm:ss", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "d. MMMM", "MMMM, yyyy": "MMMM yyyy", "/jan(uary)?/": "jan(uar)?", "/feb(ruary)?/": "feb(ruar)?", "/mar(ch)?/": "mar(s)?", "/apr(il)?/": "apr(il)?", "/may/": "mai", "/jun(e)?/": "jun(i)?", "/jul(y)?/": "jul(i)?", "/aug(ust)?/": "aug(ust)?", "/sep(t(ember)?)?/": "sep(t(ember)?)?", "/oct(ober)?/": "okt(ober)?", "/nov(ember)?/": "nov(ember)?", "/dec(ember)?/": "des(ember)?", "/^su(n(day)?)?/": "^søndag", "/^mo(n(day)?)?/": "^måndag", "/^tu(e(s(day)?)?)?/": "^tysdag", "/^we(d(nesday)?)?/": "^onsdag", "/^th(u(r(s(day)?)?)?)?/": "^torsdag", "/^fr(i(day)?)?/": "^fredag", "/^sa(t(urday)?)?/": "^laurdag", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "nn-NO"; ================================================ FILE: build/production/i18n/ns-ZA.js ================================================ /* * DateJS Culture String File * Country Code: ns-ZA * Name: Northern Sotho (South Africa) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["ns-ZA"] = { "name": "ns-ZA", "englishName": "Northern Sotho (South Africa)", "nativeName": "Sesotho sa Leboa (Afrika Borwa)", "Sunday": "Lamorena", "Monday": "Mošupologo", "Tuesday": "Labobedi", "Wednesday": "Laboraro", "Thursday": "Labone", "Friday": "Labohlano", "Saturday": "Mokibelo", "Sun": "Sun", "Mon": "Mon", "Tue": "Tue", "Wed": "Wed", "Thu": "Thu", "Fri": "Fri", "Sat": "Sat", "Su": "Sun", "Mo": "Mon", "Tu": "Tue", "We": "Wed", "Th": "Thu", "Fr": "Fri", "Sa": "Sat", "S_Sun_Initial": "S", "M_Mon_Initial": "M", "T_Tue_Initial": "T", "W_Wed_Initial": "W", "T_Thu_Initial": "T", "F_Fri_Initial": "F", "S_Sat_Initial": "S", "January": "Pherekgong", "February": "Hlakola", "March": "Mopitlo", "April": "Moranang", "May": "Mosegamanye", "June": "Ngoatobošego", "July": "Phuphu", "August": "Phato", "September": "Lewedi", "October": "Diphalana", "November": "Dibatsela", "December": "Manthole", "Jan_Abbr": "Jan", "Feb_Abbr": "Feb", "Mar_Abbr": "Mar", "Apr_Abbr": "Apr", "May_Abbr": "May", "Jun_Abbr": "Jun", "Jul_Abbr": "Jul", "Aug_Abbr": "Aug", "Sep_Abbr": "Sep", "Oct_Abbr": "Oct", "Nov_Abbr": "Nov", "Dec_Abbr": "Dec", "AM": "AM", "PM": "PM", "firstDayOfWeek": 0, "twoDigitYearMax": 2029, "mdy": "ymd", "M/d/yyyy": "yyyy/MM/dd", "dddd, MMMM dd, yyyy": "dd MMMM yyyy", "h:mm tt": "hh:mm:ss tt", "h:mm:ss tt": "hh:mm:ss tt", "dddd, MMMM dd, yyyy h:mm:ss tt": "dd MMMM yyyy hh:mm:ss tt", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "MMMM dd", "MMMM, yyyy": "MMMM yyyy", "/jan(uary)?/": "pherekgong", "/feb(ruary)?/": "hlakola", "/mar(ch)?/": "mopitlo", "/apr(il)?/": "moranang", "/may/": "mosegamanye", "/jun(e)?/": "ngoatobošego", "/jul(y)?/": "phuphu", "/aug(ust)?/": "phato", "/sep(t(ember)?)?/": "lewedi", "/oct(ober)?/": "diphalana", "/nov(ember)?/": "dibatsela", "/dec(ember)?/": "manthole", "/^su(n(day)?)?/": "^lamorena", "/^mo(n(day)?)?/": "^mošupologo", "/^tu(e(s(day)?)?)?/": "^labobedi", "/^we(d(nesday)?)?/": "^laboraro", "/^th(u(r(s(day)?)?)?)?/": "^labone", "/^fr(i(day)?)?/": "^labohlano", "/^sa(t(urday)?)?/": "^mokibelo", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "ns-ZA"; ================================================ FILE: build/production/i18n/pa-IN.js ================================================ /* * DateJS Culture String File * Country Code: pa-IN * Name: Punjabi (India) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["pa-IN"] = { "name": "pa-IN", "englishName": "Punjabi (India)", "nativeName": "ਪੰਜਾਬੀ (ਭਾਰਤ)", "Sunday": "ਐਤਵਾਰ", "Monday": "ਸੋਮਵਾਰ", "Tuesday": "ਮੰਗਲਵਾਰ", "Wednesday": "ਬੁਧਵਾਰ", "Thursday": "ਵੀਰਵਾਰ", "Friday": "ਸ਼ੁੱਕਰਵਾਰ", "Saturday": "ਸ਼ਨੀਚਰਵਾਰ", "Sun": "ਐਤ.", "Mon": "ਸੋਮ.", "Tue": "ਮੰਗਲ.", "Wed": "ਬੁਧ.", "Thu": "ਵੀਰ.", "Fri": "ਸ਼ੁਕਰ.", "Sat": "ਸ਼ਨੀ.", "Su": "ਐ", "Mo": "ਸ", "Tu": "ਮ", "We": "ਬ", "Th": "ਵ", "Fr": "ਸ਼", "Sa": "ਸ਼", "S_Sun_Initial": "ਐ", "M_Mon_Initial": "ਸ", "T_Tue_Initial": "ਮ", "W_Wed_Initial": "ਬ", "T_Thu_Initial": "ਵ", "F_Fri_Initial": "ਸ਼", "S_Sat_Initial": "ਸ਼", "January": "ਜਨਵਰੀ", "February": "ਫ਼ਰਵਰੀ", "March": "ਮਾਰਚ", "April": "ਅਪ੍ਰੈਲ", "May": "ਮਈ", "June": "ਜੂਨ", "July": "ਜੁਲਾਈ", "August": "ਅਗਸਤ", "September": "ਸਤੰਬਰ", "October": "ਅਕਤੂਬਰ", "November": "ਨਵੰਬਰ", "December": "ਦਸੰਬਰ", "Jan_Abbr": "ਜਨਵਰੀ", "Feb_Abbr": "ਫ਼ਰਵਰੀ", "Mar_Abbr": "ਮਾਰਚ", "Apr_Abbr": "ਅਪ੍ਰੈਲ", "May_Abbr": "ਮਈ", "Jun_Abbr": "ਜੂਨ", "Jul_Abbr": "ਜੁਲਾਈ", "Aug_Abbr": "ਅਗਸਤ", "Sep_Abbr": "ਸਤੰਬਰ", "Oct_Abbr": "ਅਕਤੂਬਰ", "Nov_Abbr": "ਨਵੰਬਰ", "Dec_Abbr": "ਦਸੰਬਰ", "AM": "ਸਵੇਰੇ", "PM": "ਸ਼ਾਮ", "firstDayOfWeek": 1, "twoDigitYearMax": 2029, "mdy": "dmy", "M/d/yyyy": "dd-MM-yy", "dddd, MMMM dd, yyyy": "dd MMMM yyyy dddd", "h:mm tt": "tt hh:mm", "h:mm:ss tt": "tt hh:mm:ss", "dddd, MMMM dd, yyyy h:mm:ss tt": "dd MMMM yyyy dddd tt hh:mm:ss", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "dd MMMM", "MMMM, yyyy": "MMMM, yyyy", "/jan(uary)?/": "ਜਨਵਰੀ", "/feb(ruary)?/": "ਫ਼ਰਵਰੀ", "/mar(ch)?/": "ਮਾਰਚ", "/apr(il)?/": "ਅਪ੍ਰੈਲ", "/may/": "ਮਈ", "/jun(e)?/": "ਜੂਨ", "/jul(y)?/": "ਜੁਲਾਈ", "/aug(ust)?/": "ਅਗਸਤ", "/sep(t(ember)?)?/": "ਸਤੰਬਰ", "/oct(ober)?/": "ਅਕਤੂਬਰ", "/nov(ember)?/": "ਨਵੰਬਰ", "/dec(ember)?/": "ਦਸੰਬਰ", "/^su(n(day)?)?/": "^ਐ(ਤ(.(ਵਾਰ)?)?)?", "/^mo(n(day)?)?/": "^ਸ(ੋਮ(.(ਵਾਰ)?)?)?", "/^tu(e(s(day)?)?)?/": "^ਮ(ੰਗਲ(.(ਵਾਰ)?)?)?", "/^we(d(nesday)?)?/": "^ਬ(ੁਧ(.(ਵਾਰ)?)?)?", "/^th(u(r(s(day)?)?)?)?/": "^ਵ(ੀਰ(.(ਵਾਰ)?)?)?", "/^fr(i(day)?)?/": "^ਸ਼(ੁਕਰ(.(ਰਵਾਰ)?)?)?", "/^sa(t(urday)?)?/": "^ਸ਼(ਨੀ(.(ਚਰਵਾਰ)?)?)?", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "pa-IN"; ================================================ FILE: build/production/i18n/pl-PL.js ================================================ /* * DateJS Culture String File * Country Code: pl-PL * Name: Polish (Poland) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["pl-PL"] = { "name": "pl-PL", "englishName": "Polish (Poland)", "nativeName": "polski (Polska)", "Sunday": "niedziela", "Monday": "poniedziałek", "Tuesday": "wtorek", "Wednesday": "środa", "Thursday": "czwartek", "Friday": "piątek", "Saturday": "sobota", "Sun": "N", "Mon": "Pn", "Tue": "Wt", "Wed": "Śr", "Thu": "Cz", "Fri": "Pt", "Sat": "So", "Su": "N", "Mo": "Pn", "Tu": "Wt", "We": "Śr", "Th": "Cz", "Fr": "Pt", "Sa": "So", "S_Sun_Initial": "N", "M_Mon_Initial": "P", "T_Tue_Initial": "W", "W_Wed_Initial": "Ś", "T_Thu_Initial": "C", "F_Fri_Initial": "P", "S_Sat_Initial": "S", "January": "styczeń", "February": "luty", "March": "marzec", "April": "kwiecień", "May": "maj", "June": "czerwiec", "July": "lipiec", "August": "sierpień", "September": "wrzesień", "October": "październik", "November": "listopad", "December": "grudzień", "Jan_Abbr": "sty", "Feb_Abbr": "lut", "Mar_Abbr": "mar", "Apr_Abbr": "kwi", "May_Abbr": "maj", "Jun_Abbr": "cze", "Jul_Abbr": "lip", "Aug_Abbr": "sie", "Sep_Abbr": "wrz", "Oct_Abbr": "paź", "Nov_Abbr": "lis", "Dec_Abbr": "gru", "AM": "", "PM": "", "firstDayOfWeek": 1, "twoDigitYearMax": 2029, "mdy": "ymd", "M/d/yyyy": "yyyy-MM-dd", "dddd, MMMM dd, yyyy": "d MMMM yyyy", "h:mm tt": "HH:mm", "h:mm:ss tt": "HH:mm:ss", "dddd, MMMM dd, yyyy h:mm:ss tt": "d MMMM yyyy HH:mm:ss", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "d MMMM", "MMMM, yyyy": "MMMM yyyy", "/jan(uary)?/": "sty(czeń)?", "/feb(ruary)?/": "lut(y)?", "/mar(ch)?/": "mar(zec)?", "/apr(il)?/": "kwi(ecień)?", "/may/": "maj", "/jun(e)?/": "cze(rwiec)?", "/jul(y)?/": "lip(iec)?", "/aug(ust)?/": "sie(rpień)?", "/sep(t(ember)?)?/": "wrz(esień)?", "/oct(ober)?/": "paź(dziernik)?", "/nov(ember)?/": "lis(topad)?", "/dec(ember)?/": "gru(dzień)?", "/^su(n(day)?)?/": "^niedziela", "/^mo(n(day)?)?/": "^poniedziałek", "/^tu(e(s(day)?)?)?/": "^wtorek", "/^we(d(nesday)?)?/": "^środa", "/^th(u(r(s(day)?)?)?)?/": "^czwartek", "/^fr(i(day)?)?/": "^piątek", "/^sa(t(urday)?)?/": "^sobota", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "pl-PL"; ================================================ FILE: build/production/i18n/pt-BR.js ================================================ /* * DateJS Culture String File * Country Code: pt-BR * Name: Portuguese (Brazil) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["pt-BR"] = { "name": "pt-BR", "englishName": "Portuguese (Brazil)", "nativeName": "Português (Brasil)", "Sunday": "domingo", "Monday": "segunda-feira", "Tuesday": "terça-feira", "Wednesday": "quarta-feira", "Thursday": "quinta-feira", "Friday": "sexta-feira", "Saturday": "sábado", "Sun": "dom", "Mon": "seg", "Tue": "ter", "Wed": "qua", "Thu": "qui", "Fri": "sex", "Sat": "sáb", "Su": "dom", "Mo": "seg", "Tu": "ter", "We": "qua", "Th": "qui", "Fr": "sex", "Sa": "sáb", "S_Sun_Initial": "d", "M_Mon_Initial": "s", "T_Tue_Initial": "t", "W_Wed_Initial": "q", "T_Thu_Initial": "q", "F_Fri_Initial": "s", "S_Sat_Initial": "s", "January": "janeiro", "February": "fevereiro", "March": "março", "April": "abril", "May": "maio", "June": "junho", "July": "julho", "August": "agosto", "September": "setembro", "October": "outubro", "November": "novembro", "December": "dezembro", "Jan_Abbr": "jan", "Feb_Abbr": "fev", "Mar_Abbr": "mar", "Apr_Abbr": "abr", "May_Abbr": "mai", "Jun_Abbr": "jun", "Jul_Abbr": "jul", "Aug_Abbr": "ago", "Sep_Abbr": "set", "Oct_Abbr": "out", "Nov_Abbr": "nov", "Dec_Abbr": "dez", "AM": "", "PM": "", "firstDayOfWeek": 0, "twoDigitYearMax": 2029, "mdy": "dmy", "M/d/yyyy": "d/M/yyyy", "dddd, MMMM dd, yyyy": "dddd, d' de 'MMMM' de 'yyyy", "h:mm tt": "H:mm", "h:mm:ss tt": "H:mm:ss", "dddd, MMMM dd, yyyy h:mm:ss tt": "dddd, d' de 'MMMM' de 'yyyy H:mm:ss", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "dd' de 'MMMM", "MMMM, yyyy": "MMMM' de 'yyyy", "/jan(uary)?/": "jan(eiro)?", "/feb(ruary)?/": "fev(ereiro)?", "/mar(ch)?/": "mar(ço)?", "/apr(il)?/": "abr(il)?", "/may/": "mai(o)?", "/jun(e)?/": "jun(ho)?", "/jul(y)?/": "jul(ho)?", "/aug(ust)?/": "ago(sto)?", "/sep(t(ember)?)?/": "set(embro)?", "/oct(ober)?/": "out(ubro)?", "/nov(ember)?/": "nov(embro)?", "/dec(ember)?/": "dez(embro)?", "/^su(n(day)?)?/": "^domingo", "/^mo(n(day)?)?/": "^segunda-feira", "/^tu(e(s(day)?)?)?/": "^terça-feira", "/^we(d(nesday)?)?/": "^quarta-feira", "/^th(u(r(s(day)?)?)?)?/": "^quinta-feira", "/^fr(i(day)?)?/": "^sexta-feira", "/^sa(t(urday)?)?/": "^sábado", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "pt-BR"; ================================================ FILE: build/production/i18n/pt-PT.js ================================================ /* * DateJS Culture String File * Country Code: pt-PT * Name: Portuguese (Portugal) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["pt-PT"] = { "name": "pt-PT", "englishName": "Portuguese (Portugal)", "nativeName": "Português (Portugal)", "Sunday": "domingo", "Monday": "segunda-feira", "Tuesday": "terça-feira", "Wednesday": "quarta-feira", "Thursday": "quinta-feira", "Friday": "sexta-feira", "Saturday": "sábado", "Sun": "dom", "Mon": "seg", "Tue": "ter", "Wed": "qua", "Thu": "qui", "Fri": "sex", "Sat": "sáb", "Su": "dom", "Mo": "seg", "Tu": "ter", "We": "qua", "Th": "qui", "Fr": "sex", "Sa": "sáb", "S_Sun_Initial": "d", "M_Mon_Initial": "s", "T_Tue_Initial": "t", "W_Wed_Initial": "q", "T_Thu_Initial": "q", "F_Fri_Initial": "s", "S_Sat_Initial": "s", "January": "Janeiro", "February": "Fevereiro", "March": "Março", "April": "Abril", "May": "Maio", "June": "Junho", "July": "Julho", "August": "Agosto", "September": "Setembro", "October": "Outubro", "November": "Novembro", "December": "Dezembro", "Jan_Abbr": "Jan", "Feb_Abbr": "Fev", "Mar_Abbr": "Mar", "Apr_Abbr": "Abr", "May_Abbr": "Mai", "Jun_Abbr": "Jun", "Jul_Abbr": "Jul", "Aug_Abbr": "Ago", "Sep_Abbr": "Set", "Oct_Abbr": "Out", "Nov_Abbr": "Nov", "Dec_Abbr": "Dez", "AM": "", "PM": "", "firstDayOfWeek": 1, "twoDigitYearMax": 2029, "mdy": "dmy", "M/d/yyyy": "dd-MM-yyyy", "dddd, MMMM dd, yyyy": "dddd, d' de 'MMMM' de 'yyyy", "h:mm tt": "H:mm", "h:mm:ss tt": "H:mm:ss", "dddd, MMMM dd, yyyy h:mm:ss tt": "dddd, d' de 'MMMM' de 'yyyy H:mm:ss", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "d/M", "MMMM, yyyy": "MMMM' de 'yyyy", "/jan(uary)?/": "jan(eiro)?", "/feb(ruary)?/": "fev(ereiro)?", "/mar(ch)?/": "mar(ço)?", "/apr(il)?/": "abr(il)?", "/may/": "mai(o)?", "/jun(e)?/": "jun(ho)?", "/jul(y)?/": "jul(ho)?", "/aug(ust)?/": "ago(sto)?", "/sep(t(ember)?)?/": "set(embro)?", "/oct(ober)?/": "out(ubro)?", "/nov(ember)?/": "nov(embro)?", "/dec(ember)?/": "dez(embro)?", "/^su(n(day)?)?/": "^domingo", "/^mo(n(day)?)?/": "^segunda-feira", "/^tu(e(s(day)?)?)?/": "^terça-feira", "/^we(d(nesday)?)?/": "^quarta-feira", "/^th(u(r(s(day)?)?)?)?/": "^quinta-feira", "/^fr(i(day)?)?/": "^sexta-feira", "/^sa(t(urday)?)?/": "^sábado", "/^next/": "^prox(im(o(s)?|a(s)?))?", "/^last|past|prev(ious)?/": "^ant(erior(es)?)?|ult(im(o(s)?|a(s)?))?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|depois)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|antes)", "/^yes(terday)?/": "^ontem", "/^t(od(ay)?)?/": "^h(oje)?", "/^tom(orrow)?/": "^amanha", "/^n(ow)?/": "^a(gora)?", "/^ms|milli(second)?s?/": "^ms|milli(segundo)?s?", "/^sec(ond)?s?/": "^s(egundo)?s?", "/^mn|min(ute)?s?/": "^mn|min(uto)?s?", "/^h(our)?s?/": "^h(ora)?s?", "/^w(eek)?s?/": "^sem(ana)?s?", "/^m(onth)?s?/": "^m(e(se)?s?)?", "/^d(ay)?s?/": "^d(ia(s)?s?)?", "/^y(ear)?s?/": "^an((o)?s?)?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "pt-PT"; ================================================ FILE: build/production/i18n/quz-BO.js ================================================ /* * DateJS Culture String File * Country Code: quz-BO * Name: Quechua (Bolivia) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["quz-BO"] = { "name": "quz-BO", "englishName": "Quechua (Bolivia)", "nativeName": "runasimi (Bolivia Suyu)", "Sunday": "intichaw", "Monday": "killachaw", "Tuesday": "atipachaw", "Wednesday": "quyllurchaw", "Thursday": "Ch' askachaw", "Friday": "Illapachaw", "Saturday": "k'uychichaw", "Sun": "int", "Mon": "kil", "Tue": "ati", "Wed": "quy", "Thu": "Ch’", "Fri": "Ill", "Sat": "k'u", "Su": "int", "Mo": "kil", "Tu": "ati", "We": "quy", "Th": "Ch’", "Fr": "Ill", "Sa": "k'u", "S_Sun_Initial": "i", "M_Mon_Initial": "k", "T_Tue_Initial": "a", "W_Wed_Initial": "q", "T_Thu_Initial": "C", "F_Fri_Initial": "I", "S_Sat_Initial": "k", "January": "Qulla puquy", "February": "Hatun puquy", "March": "Pauqar waray", "April": "ayriwa", "May": "Aymuray", "June": "Inti raymi", "July": "Anta Sitwa", "August": "Qhapaq Sitwa", "September": "Uma raymi", "October": "Kantaray", "November": "Ayamarq'a", "December": "Kapaq Raymi", "Jan_Abbr": "Qul", "Feb_Abbr": "Hat", "Mar_Abbr": "Pau", "Apr_Abbr": "ayr", "May_Abbr": "Aym", "Jun_Abbr": "Int", "Jul_Abbr": "Ant", "Aug_Abbr": "Qha", "Sep_Abbr": "Uma", "Oct_Abbr": "Kan", "Nov_Abbr": "Aya", "Dec_Abbr": "Kap", "AM": "a.m.", "PM": "p.m.", "firstDayOfWeek": 0, "twoDigitYearMax": 2029, "mdy": "dmy", "M/d/yyyy": "dd/MM/yyyy", "dddd, MMMM dd, yyyy": "dddd, dd' de 'MMMM' de 'yyyy", "h:mm tt": "hh:mm:ss tt", "h:mm:ss tt": "hh:mm:ss tt", "dddd, MMMM dd, yyyy h:mm:ss tt": "dddd, dd' de 'MMMM' de 'yyyy hh:mm:ss tt", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "MMMM dd", "MMMM, yyyy": "MMMM' de 'yyyy", "/jan(uary)?/": "qul(la puquy)?", "/feb(ruary)?/": "hat(un puquy)?", "/mar(ch)?/": "pau(qar waray)?", "/apr(il)?/": "ayr(iwa)?", "/may/": "aym(uray)?", "/jun(e)?/": "int(i raymi)?", "/jul(y)?/": "ant(a sitwa)?", "/aug(ust)?/": "qha(paq sitwa)?", "/sep(t(ember)?)?/": "uma( raymi)?", "/oct(ober)?/": "kan(taray)?", "/nov(ember)?/": "aya(marq'a)?", "/dec(ember)?/": "kap(aq raymi)?", "/^su(n(day)?)?/": "^intichaw", "/^mo(n(day)?)?/": "^killachaw", "/^tu(e(s(day)?)?)?/": "^atipachaw", "/^we(d(nesday)?)?/": "^quyllurchaw", "/^th(u(r(s(day)?)?)?)?/": "^ch' askachaw", "/^fr(i(day)?)?/": "^illapachaw", "/^sa(t(urday)?)?/": "^k'uychichaw", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "quz-BO"; ================================================ FILE: build/production/i18n/quz-EC.js ================================================ /* * DateJS Culture String File * Country Code: quz-EC * Name: Quechua (Ecuador) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["quz-EC"] = { "name": "quz-EC", "englishName": "Quechua (Ecuador)", "nativeName": "runasimi (Ecuador Suyu)", "Sunday": "intichaw", "Monday": "killachaw", "Tuesday": "atipachaw", "Wednesday": "quyllurchaw", "Thursday": "Ch' askachaw", "Friday": "Illapachaw", "Saturday": "k'uychichaw", "Sun": "int", "Mon": "kil", "Tue": "ati", "Wed": "quy", "Thu": "Ch’", "Fri": "Ill", "Sat": "k'u", "Su": "int", "Mo": "kil", "Tu": "ati", "We": "quy", "Th": "Ch’", "Fr": "Ill", "Sa": "k'u", "S_Sun_Initial": "i", "M_Mon_Initial": "k", "T_Tue_Initial": "a", "W_Wed_Initial": "q", "T_Thu_Initial": "C", "F_Fri_Initial": "I", "S_Sat_Initial": "k", "January": "Qulla puquy", "February": "Hatun puquy", "March": "Pauqar waray", "April": "ayriwa", "May": "Aymuray", "June": "Inti raymi", "July": "Anta Sitwa", "August": "Qhapaq Sitwa", "September": "Uma raymi", "October": "Kantaray", "November": "Ayamarq'a", "December": "Kapaq Raymi", "Jan_Abbr": "Qul", "Feb_Abbr": "Hat", "Mar_Abbr": "Pau", "Apr_Abbr": "ayr", "May_Abbr": "Aym", "Jun_Abbr": "Int", "Jul_Abbr": "Ant", "Aug_Abbr": "Qha", "Sep_Abbr": "Uma", "Oct_Abbr": "Kan", "Nov_Abbr": "Aya", "Dec_Abbr": "Kap", "AM": "", "PM": "", "firstDayOfWeek": 0, "twoDigitYearMax": 2029, "mdy": "dmy", "M/d/yyyy": "dd/MM/yyyy", "dddd, MMMM dd, yyyy": "dddd, dd' de 'MMMM' de 'yyyy", "h:mm tt": "H:mm:ss", "h:mm:ss tt": "H:mm:ss", "dddd, MMMM dd, yyyy h:mm:ss tt": "dddd, dd' de 'MMMM' de 'yyyy H:mm:ss", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "MMMM dd", "MMMM, yyyy": "MMMM' de 'yyyy", "/jan(uary)?/": "qul(la puquy)?", "/feb(ruary)?/": "hat(un puquy)?", "/mar(ch)?/": "pau(qar waray)?", "/apr(il)?/": "ayr(iwa)?", "/may/": "aym(uray)?", "/jun(e)?/": "int(i raymi)?", "/jul(y)?/": "ant(a sitwa)?", "/aug(ust)?/": "qha(paq sitwa)?", "/sep(t(ember)?)?/": "uma( raymi)?", "/oct(ober)?/": "kan(taray)?", "/nov(ember)?/": "aya(marq'a)?", "/dec(ember)?/": "kap(aq raymi)?", "/^su(n(day)?)?/": "^intichaw", "/^mo(n(day)?)?/": "^killachaw", "/^tu(e(s(day)?)?)?/": "^atipachaw", "/^we(d(nesday)?)?/": "^quyllurchaw", "/^th(u(r(s(day)?)?)?)?/": "^ch' askachaw", "/^fr(i(day)?)?/": "^illapachaw", "/^sa(t(urday)?)?/": "^k'uychichaw", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "quz-EC"; ================================================ FILE: build/production/i18n/quz-PE.js ================================================ /* * DateJS Culture String File * Country Code: quz-PE * Name: Quechua (Peru) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["quz-PE"] = { "name": "quz-PE", "englishName": "Quechua (Peru)", "nativeName": "runasimi (Peru Suyu)", "Sunday": "intichaw", "Monday": "killachaw", "Tuesday": "atipachaw", "Wednesday": "quyllurchaw", "Thursday": "Ch' askachaw", "Friday": "Illapachaw", "Saturday": "k'uychichaw", "Sun": "int", "Mon": "kil", "Tue": "ati", "Wed": "quy", "Thu": "Ch’", "Fri": "Ill", "Sat": "k'u", "Su": "int", "Mo": "kil", "Tu": "ati", "We": "quy", "Th": "Ch’", "Fr": "Ill", "Sa": "k'u", "S_Sun_Initial": "i", "M_Mon_Initial": "k", "T_Tue_Initial": "a", "W_Wed_Initial": "q", "T_Thu_Initial": "C", "F_Fri_Initial": "I", "S_Sat_Initial": "k", "January": "Qulla puquy", "February": "Hatun puquy", "March": "Pauqar waray", "April": "ayriwa", "May": "Aymuray", "June": "Inti raymi", "July": "Anta Sitwa", "August": "Qhapaq Sitwa", "September": "Uma raymi", "October": "Kantaray", "November": "Ayamarq'a", "December": "Kapaq Raymi", "Jan_Abbr": "Qul", "Feb_Abbr": "Hat", "Mar_Abbr": "Pau", "Apr_Abbr": "ayr", "May_Abbr": "Aym", "Jun_Abbr": "Int", "Jul_Abbr": "Ant", "Aug_Abbr": "Qha", "Sep_Abbr": "Uma", "Oct_Abbr": "Kan", "Nov_Abbr": "Aya", "Dec_Abbr": "Kap", "AM": "a.m.", "PM": "p.m.", "firstDayOfWeek": 0, "twoDigitYearMax": 2029, "mdy": "dmy", "M/d/yyyy": "dd/MM/yyyy", "dddd, MMMM dd, yyyy": "dddd, dd' de 'MMMM' de 'yyyy", "h:mm tt": "hh:mm:ss tt", "h:mm:ss tt": "hh:mm:ss tt", "dddd, MMMM dd, yyyy h:mm:ss tt": "dddd, dd' de 'MMMM' de 'yyyy hh:mm:ss tt", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "MMMM dd", "MMMM, yyyy": "MMMM' de 'yyyy", "/jan(uary)?/": "qul(la puquy)?", "/feb(ruary)?/": "hat(un puquy)?", "/mar(ch)?/": "pau(qar waray)?", "/apr(il)?/": "ayr(iwa)?", "/may/": "aym(uray)?", "/jun(e)?/": "int(i raymi)?", "/jul(y)?/": "ant(a sitwa)?", "/aug(ust)?/": "qha(paq sitwa)?", "/sep(t(ember)?)?/": "uma( raymi)?", "/oct(ober)?/": "kan(taray)?", "/nov(ember)?/": "aya(marq'a)?", "/dec(ember)?/": "kap(aq raymi)?", "/^su(n(day)?)?/": "^intichaw", "/^mo(n(day)?)?/": "^killachaw", "/^tu(e(s(day)?)?)?/": "^atipachaw", "/^we(d(nesday)?)?/": "^quyllurchaw", "/^th(u(r(s(day)?)?)?)?/": "^ch' askachaw", "/^fr(i(day)?)?/": "^illapachaw", "/^sa(t(urday)?)?/": "^k'uychichaw", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "quz-PE"; ================================================ FILE: build/production/i18n/ro-RO.js ================================================ /* * DateJS Culture String File * Country Code: ro-RO * Name: Romanian (Romania) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["ro-RO"] = { "name": "ro-RO", "englishName": "Romanian (Romania)", "nativeName": "română (România)", "Sunday": "duminică", "Monday": "luni", "Tuesday": "marţi", "Wednesday": "miercuri", "Thursday": "joi", "Friday": "vineri", "Saturday": "sâmbătă", "Sun": "D", "Mon": "L", "Tue": "Ma", "Wed": "Mi", "Thu": "J", "Fri": "V", "Sat": "S", "Su": "D", "Mo": "L", "Tu": "Ma", "We": "Mi", "Th": "J", "Fr": "V", "Sa": "S", "S_Sun_Initial": "D", "M_Mon_Initial": "L", "T_Tue_Initial": "M", "W_Wed_Initial": "M", "T_Thu_Initial": "J", "F_Fri_Initial": "V", "S_Sat_Initial": "S", "January": "ianuarie", "February": "februarie", "March": "martie", "April": "aprilie", "May": "mai", "June": "iunie", "July": "iulie", "August": "august", "September": "septembrie", "October": "octombrie", "November": "noiembrie", "December": "decembrie", "Jan_Abbr": "ian.", "Feb_Abbr": "feb.", "Mar_Abbr": "mar.", "Apr_Abbr": "apr.", "May_Abbr": "mai.", "Jun_Abbr": "iun.", "Jul_Abbr": "iul.", "Aug_Abbr": "aug.", "Sep_Abbr": "sep.", "Oct_Abbr": "oct.", "Nov_Abbr": "nov.", "Dec_Abbr": "dec.", "AM": "", "PM": "", "firstDayOfWeek": 1, "twoDigitYearMax": 2029, "mdy": "dmy", "M/d/yyyy": "dd.MM.yyyy", "dddd, MMMM dd, yyyy": "d MMMM yyyy", "h:mm tt": "HH:mm", "h:mm:ss tt": "HH:mm:ss", "dddd, MMMM dd, yyyy h:mm:ss tt": "d MMMM yyyy HH:mm:ss", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "d MMMM", "MMMM, yyyy": "MMMM yyyy", "/jan(uary)?/": "ian(.(uarie)?)?", "/feb(ruary)?/": "feb(.(ruarie)?)?", "/mar(ch)?/": "mar(.(tie)?)?", "/apr(il)?/": "apr(.(ilie)?)?", "/may/": "mai(.()?)?", "/jun(e)?/": "iun(.(ie)?)?", "/jul(y)?/": "iul(.(ie)?)?", "/aug(ust)?/": "aug(.(ust)?)?", "/sep(t(ember)?)?/": "sep(.(tembrie)?)?", "/oct(ober)?/": "oct(.(ombrie)?)?", "/nov(ember)?/": "noiembrie", "/dec(ember)?/": "dec(.(embrie)?)?", "/^su(n(day)?)?/": "^duminică", "/^mo(n(day)?)?/": "^luni", "/^tu(e(s(day)?)?)?/": "^marţi", "/^we(d(nesday)?)?/": "^miercuri", "/^th(u(r(s(day)?)?)?)?/": "^joi", "/^fr(i(day)?)?/": "^vineri", "/^sa(t(urday)?)?/": "^sâmbătă", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "ro-RO"; ================================================ FILE: build/production/i18n/ru-RU.js ================================================ /* * DateJS Culture String File * Country Code: ru-RU * Name: Russian (Russia) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["ru-RU"] = { "name": "ru-RU", "englishName": "Russian (Russia)", "nativeName": "Pусский (Россия)", "Sunday": "воскресенье", "Monday": "понедельник", "Tuesday": "вторник", "Wednesday": "среда", "Thursday": "четверг", "Friday": "пятница", "Saturday": "суббота", "Sun": "Вс", "Mon": "Пн", "Tue": "Вт", "Wed": "Ср", "Thu": "Чт", "Fri": "Пт", "Sat": "Сб", "Su": "Вс", "Mo": "Пн", "Tu": "Вт", "We": "Ср", "Th": "Чт", "Fr": "Пт", "Sa": "Сб", "S_Sun_Initial": "В", "M_Mon_Initial": "П", "T_Tue_Initial": "В", "W_Wed_Initial": "С", "T_Thu_Initial": "Ч", "F_Fri_Initial": "П", "S_Sat_Initial": "С", "January": "Январь", "February": "Февраль", "March": "Март", "April": "Апрель", "May": "Май", "June": "Июнь", "July": "Июль", "August": "Август", "September": "Сентябрь", "October": "Октябрь", "November": "Ноябрь", "December": "Декабрь", "Jan_Abbr": "янв", "Feb_Abbr": "фев", "Mar_Abbr": "мар", "Apr_Abbr": "апр", "May_Abbr": "май", "Jun_Abbr": "июн", "Jul_Abbr": "июл", "Aug_Abbr": "авг", "Sep_Abbr": "сен", "Oct_Abbr": "окт", "Nov_Abbr": "ноя", "Dec_Abbr": "дек", "AM": "", "PM": "", "firstDayOfWeek": 1, "twoDigitYearMax": 2029, "mdy": "dmy", "M/d/yyyy": "dd.MM.yyyy", "dddd, MMMM dd, yyyy": "d MMMM yyyy 'г.'", "h:mm tt": "H:mm", "h:mm:ss tt": "H:mm:ss", "dddd, MMMM dd, yyyy h:mm:ss tt": "d MMMM yyyy 'г.' H:mm:ss", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "MMMM dd", "MMMM, yyyy": "MMMM yyyy 'г.'", "/jan(uary)?/": "янв(арь)?", "/feb(ruary)?/": "фев(раль)?", "/mar(ch)?/": "мар(т)?", "/apr(il)?/": "апр(ель)?", "/may/": "май", "/jun(e)?/": "июн(ь)?", "/jul(y)?/": "июл(ь)?", "/aug(ust)?/": "авг(уст)?", "/sep(t(ember)?)?/": "сен(тябрь)?", "/oct(ober)?/": "окт(ябрь)?", "/nov(ember)?/": "ноя(брь)?", "/dec(ember)?/": "дек(абрь)?", "/^su(n(day)?)?/": "^воскресенье", "/^mo(n(day)?)?/": "^понедельник", "/^tu(e(s(day)?)?)?/": "^вторник", "/^we(d(nesday)?)?/": "^среда", "/^th(u(r(s(day)?)?)?)?/": "^четверг", "/^fr(i(day)?)?/": "^пятница", "/^sa(t(urday)?)?/": "^суббота", "/^next/": "^след|завтра", "/^last|past|prev(ious)?/": "^пред|вчера", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|через|после|вперед|и|следую?щ(ая|ий|ее)?)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|за|до|поза|пе?ред((ыдущ|шев?ствующ)(ая|ий|ее))|назад)", "/^yes(terday)?/": "^вчера", "/^t(od(ay)?)?/": "^сегодня", "/^tom(orrow)?/": "^завтра", "/^n(ow)?/": "^сейчас|сечас|щас", "/^ms|milli(second)?s?/": "^мс|мили(секунд)?s?", "/^sec(ond)?s?/": "^с(ек(унд)?)?", "/^mn|min(ute)?s?/": "^м(ин(ут)?)?", "/^h(our)?s?/": "^ч((ас)?ов)?", "/^w(eek)?s?/": "^н(ед(ель)?)?", "/^m(onth)?s?/": "^мес(яцев)?", "/^d(ay)?s?/": "^д(ень|ней|ня)?", "/^y(ear)?s?/": "^г(ода?)?|л(ет)?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "ru-RU"; ================================================ FILE: build/production/i18n/sa-IN.js ================================================ /* * DateJS Culture String File * Country Code: sa-IN * Name: Sanskrit (India) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["sa-IN"] = { "name": "sa-IN", "englishName": "Sanskrit (India)", "nativeName": "संस्कृत (भारतम्)", "Sunday": "रविवासरः", "Monday": "सोमवासरः", "Tuesday": "मङ्गलवासरः", "Wednesday": "बुधवासरः", "Thursday": "गुरुवासरः", "Friday": "शुक्रवासरः", "Saturday": "शनिवासरः", "Sun": "रविवासरः", "Mon": "सोमवासरः", "Tue": "मङ्गलवासरः", "Wed": "बुधवासरः", "Thu": "गुरुवासरः", "Fri": "शुक्रवासरः", "Sat": "शनिवासरः", "Su": "र", "Mo": "स", "Tu": "म", "We": "ब", "Th": "ग", "Fr": "श", "Sa": "श", "S_Sun_Initial": "र", "M_Mon_Initial": "स", "T_Tue_Initial": "म", "W_Wed_Initial": "ब", "T_Thu_Initial": "ग", "F_Fri_Initial": "श", "S_Sat_Initial": "श", "January": "जनवरी", "February": "फरवरी", "March": "मार्च", "April": "अप्रैल", "May": "मई", "June": "जून", "July": "जुलाई", "August": "अगस्त", "September": "सितम्बर", "October": "अक्तूबर", "November": "नवम्बर", "December": "दिसम्बर", "Jan_Abbr": "जनवरी", "Feb_Abbr": "फरवरी", "Mar_Abbr": "मार्च", "Apr_Abbr": "अप्रैल", "May_Abbr": "मई", "Jun_Abbr": "जून", "Jul_Abbr": "जुलाई", "Aug_Abbr": "अगस्त", "Sep_Abbr": "सितम्बर", "Oct_Abbr": "अक्तूबर", "Nov_Abbr": "नवम्बर", "Dec_Abbr": "दिसम्बर", "AM": "पूर्वाह्न", "PM": "अपराह्न", "firstDayOfWeek": 0, "twoDigitYearMax": 2029, "mdy": "dmy", "M/d/yyyy": "dd-MM-yyyy", "dddd, MMMM dd, yyyy": "dd MMMM yyyy dddd", "h:mm tt": "HH:mm", "h:mm:ss tt": "HH:mm:ss", "dddd, MMMM dd, yyyy h:mm:ss tt": "dd MMMM yyyy dddd HH:mm:ss", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "dd MMMM", "MMMM, yyyy": "MMMM, yyyy", "/jan(uary)?/": "जनवरी", "/feb(ruary)?/": "फरवरी", "/mar(ch)?/": "मार्च", "/apr(il)?/": "अप्रैल", "/may/": "मई", "/jun(e)?/": "जून", "/jul(y)?/": "जुलाई", "/aug(ust)?/": "अगस्त", "/sep(t(ember)?)?/": "सितम्बर", "/oct(ober)?/": "अक्तूबर", "/nov(ember)?/": "नवम्बर", "/dec(ember)?/": "दिसम्बर", "/^su(n(day)?)?/": "^र(1)?", "/^mo(n(day)?)?/": "^स(1)?", "/^tu(e(s(day)?)?)?/": "^म(1)?", "/^we(d(nesday)?)?/": "^ब(1)?", "/^th(u(r(s(day)?)?)?)?/": "^ग(1)?", "/^fr(i(day)?)?/": "^श(1)?", "/^sa(t(urday)?)?/": "^श(1)?", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "sa-IN"; ================================================ FILE: build/production/i18n/se-FI.js ================================================ /* * DateJS Culture String File * Country Code: se-FI * Name: Sami (Northern) (Finland) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["se-FI"] = { "name": "se-FI", "englishName": "Sami (Northern) (Finland)", "nativeName": "davvisámegiella (Suopma)", "Sunday": "sotnabeaivi", "Monday": "vuossárga", "Tuesday": "maŋŋebárga", "Wednesday": "gaskavahkku", "Thursday": "duorastat", "Friday": "bearjadat", "Saturday": "lávvardat", "Sun": "sotn", "Mon": "vuos", "Tue": "maŋ", "Wed": "gask", "Thu": "duor", "Fri": "bear", "Sat": "láv", "Su": "sotn", "Mo": "vuos", "Tu": "maŋ", "We": "gask", "Th": "duor", "Fr": "bear", "Sa": "láv", "S_Sun_Initial": "s", "M_Mon_Initial": "v", "T_Tue_Initial": "m", "W_Wed_Initial": "g", "T_Thu_Initial": "d", "F_Fri_Initial": "b", "S_Sat_Initial": "l", "January": "ođđajagemánnu", "February": "guovvamánnu", "March": "njukčamánnu", "April": "cuoŋománnu", "May": "miessemánnu", "June": "geassemánnu", "July": "suoidnemánnu", "August": "borgemánnu", "September": "čakčamánnu", "October": "golggotmánnu", "November": "skábmamánnu", "December": "juovlamánnu", "Jan_Abbr": "ođđj", "Feb_Abbr": "guov", "Mar_Abbr": "njuk", "Apr_Abbr": "cuo", "May_Abbr": "mies", "Jun_Abbr": "geas", "Jul_Abbr": "suoi", "Aug_Abbr": "borg", "Sep_Abbr": "čakč", "Oct_Abbr": "golg", "Nov_Abbr": "skáb", "Dec_Abbr": "juov", "AM": "", "PM": "", "firstDayOfWeek": 1, "twoDigitYearMax": 2029, "mdy": "dmy", "M/d/yyyy": "d.M.yyyy", "dddd, MMMM dd, yyyy": "MMMM d'. b. 'yyyy", "h:mm tt": "H:mm:ss", "h:mm:ss tt": "H:mm:ss", "dddd, MMMM dd, yyyy h:mm:ss tt": "MMMM d'. b. 'yyyy H:mm:ss", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "MMMM dd", "MMMM, yyyy": "MMMM yyyy", "/jan(uary)?/": "ođđajagemánnu", "/feb(ruary)?/": "guov(vamánnu)?", "/mar(ch)?/": "njuk(čamánnu)?", "/apr(il)?/": "cuo(ŋománnu)?", "/may/": "mies(semánnu)?", "/jun(e)?/": "geas(semánnu)?", "/jul(y)?/": "suoi(dnemánnu)?", "/aug(ust)?/": "borg(emánnu)?", "/sep(t(ember)?)?/": "čakč(amánnu)?", "/oct(ober)?/": "golg(gotmánnu)?", "/nov(ember)?/": "skáb(mamánnu)?", "/dec(ember)?/": "juov(lamánnu)?", "/^su(n(day)?)?/": "^sotnabeaivi", "/^mo(n(day)?)?/": "^vuossárga", "/^tu(e(s(day)?)?)?/": "^maŋŋebárga", "/^we(d(nesday)?)?/": "^gaskavahkku", "/^th(u(r(s(day)?)?)?)?/": "^duorastat", "/^fr(i(day)?)?/": "^bearjadat", "/^sa(t(urday)?)?/": "^lávvardat", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "se-FI"; ================================================ FILE: build/production/i18n/se-NO.js ================================================ /* * DateJS Culture String File * Country Code: se-NO * Name: Sami (Northern) (Norway) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["se-NO"] = { "name": "se-NO", "englishName": "Sami (Northern) (Norway)", "nativeName": "davvisámegiella (Norga)", "Sunday": "sotnabeaivi", "Monday": "vuossárga", "Tuesday": "maŋŋebárga", "Wednesday": "gaskavahkku", "Thursday": "duorastat", "Friday": "bearjadat", "Saturday": "lávvardat", "Sun": "sotn", "Mon": "vuos", "Tue": "maŋ", "Wed": "gask", "Thu": "duor", "Fri": "bear", "Sat": "láv", "Su": "sotn", "Mo": "vuos", "Tu": "maŋ", "We": "gask", "Th": "duor", "Fr": "bear", "Sa": "láv", "S_Sun_Initial": "s", "M_Mon_Initial": "v", "T_Tue_Initial": "m", "W_Wed_Initial": "g", "T_Thu_Initial": "d", "F_Fri_Initial": "b", "S_Sat_Initial": "l", "January": "ođđajagemánnu", "February": "guovvamánnu", "March": "njukčamánnu", "April": "cuoŋománnu", "May": "miessemánnu", "June": "geassemánnu", "July": "suoidnemánnu", "August": "borgemánnu", "September": "čakčamánnu", "October": "golggotmánnu", "November": "skábmamánnu", "December": "juovlamánnu", "Jan_Abbr": "ođđj", "Feb_Abbr": "guov", "Mar_Abbr": "njuk", "Apr_Abbr": "cuo", "May_Abbr": "mies", "Jun_Abbr": "geas", "Jul_Abbr": "suoi", "Aug_Abbr": "borg", "Sep_Abbr": "čakč", "Oct_Abbr": "golg", "Nov_Abbr": "skáb", "Dec_Abbr": "juov", "AM": "", "PM": "", "firstDayOfWeek": 1, "twoDigitYearMax": 2029, "mdy": "dmy", "M/d/yyyy": "dd.MM.yyyy", "dddd, MMMM dd, yyyy": "MMMM d'. b. 'yyyy", "h:mm tt": "HH:mm:ss", "h:mm:ss tt": "HH:mm:ss", "dddd, MMMM dd, yyyy h:mm:ss tt": "MMMM d'. b. 'yyyy HH:mm:ss", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "MMMM dd", "MMMM, yyyy": "MMMM yyyy", "/jan(uary)?/": "ođđajagemánnu", "/feb(ruary)?/": "guov(vamánnu)?", "/mar(ch)?/": "njuk(čamánnu)?", "/apr(il)?/": "cuo(ŋománnu)?", "/may/": "mies(semánnu)?", "/jun(e)?/": "geas(semánnu)?", "/jul(y)?/": "suoi(dnemánnu)?", "/aug(ust)?/": "borg(emánnu)?", "/sep(t(ember)?)?/": "čakč(amánnu)?", "/oct(ober)?/": "golg(gotmánnu)?", "/nov(ember)?/": "skáb(mamánnu)?", "/dec(ember)?/": "juov(lamánnu)?", "/^su(n(day)?)?/": "^sotnabeaivi", "/^mo(n(day)?)?/": "^vuossárga", "/^tu(e(s(day)?)?)?/": "^maŋŋebárga", "/^we(d(nesday)?)?/": "^gaskavahkku", "/^th(u(r(s(day)?)?)?)?/": "^duorastat", "/^fr(i(day)?)?/": "^bearjadat", "/^sa(t(urday)?)?/": "^lávvardat", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "se-NO"; ================================================ FILE: build/production/i18n/se-SE.js ================================================ /* * DateJS Culture String File * Country Code: se-SE * Name: Sami (Northern) (Sweden) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["se-SE"] = { "name": "se-SE", "englishName": "Sami (Northern) (Sweden)", "nativeName": "davvisámegiella (Ruoŧŧa)", "Sunday": "sotnabeaivi", "Monday": "mánnodat", "Tuesday": "disdat", "Wednesday": "gaskavahkku", "Thursday": "duorastat", "Friday": "bearjadat", "Saturday": "lávvardat", "Sun": "sotn", "Mon": "mán", "Tue": "dis", "Wed": "gask", "Thu": "duor", "Fri": "bear", "Sat": "láv", "Su": "sotn", "Mo": "mán", "Tu": "dis", "We": "gask", "Th": "duor", "Fr": "bear", "Sa": "láv", "S_Sun_Initial": "s", "M_Mon_Initial": "m", "T_Tue_Initial": "d", "W_Wed_Initial": "g", "T_Thu_Initial": "d", "F_Fri_Initial": "b", "S_Sat_Initial": "l", "January": "ođđajagemánnu", "February": "guovvamánnu", "March": "njukčamánnu", "April": "cuoŋománnu", "May": "miessemánnu", "June": "geassemánnu", "July": "suoidnemánnu", "August": "borgemánnu", "September": "čakčamánnu", "October": "golggotmánnu", "November": "skábmamánnu", "December": "juovlamánnu", "Jan_Abbr": "ođđj", "Feb_Abbr": "guov", "Mar_Abbr": "njuk", "Apr_Abbr": "cuo", "May_Abbr": "mies", "Jun_Abbr": "geas", "Jul_Abbr": "suoi", "Aug_Abbr": "borg", "Sep_Abbr": "čakč", "Oct_Abbr": "golg", "Nov_Abbr": "skáb", "Dec_Abbr": "juov", "AM": "", "PM": "", "firstDayOfWeek": 1, "twoDigitYearMax": 2029, "mdy": "ymd", "M/d/yyyy": "yyyy-MM-dd", "dddd, MMMM dd, yyyy": "MMMM d'. b. 'yyyy", "h:mm tt": "HH:mm:ss", "h:mm:ss tt": "HH:mm:ss", "dddd, MMMM dd, yyyy h:mm:ss tt": "MMMM d'. b. 'yyyy HH:mm:ss", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "MMMM dd", "MMMM, yyyy": "MMMM yyyy", "/jan(uary)?/": "ođđajagemánnu", "/feb(ruary)?/": "guov(vamánnu)?", "/mar(ch)?/": "njuk(čamánnu)?", "/apr(il)?/": "cuo(ŋománnu)?", "/may/": "mies(semánnu)?", "/jun(e)?/": "geas(semánnu)?", "/jul(y)?/": "suoi(dnemánnu)?", "/aug(ust)?/": "borg(emánnu)?", "/sep(t(ember)?)?/": "čakč(amánnu)?", "/oct(ober)?/": "golg(gotmánnu)?", "/nov(ember)?/": "skáb(mamánnu)?", "/dec(ember)?/": "juov(lamánnu)?", "/^su(n(day)?)?/": "^sotnabeaivi", "/^mo(n(day)?)?/": "^mánnodat", "/^tu(e(s(day)?)?)?/": "^disdat", "/^we(d(nesday)?)?/": "^gaskavahkku", "/^th(u(r(s(day)?)?)?)?/": "^duorastat", "/^fr(i(day)?)?/": "^bearjadat", "/^sa(t(urday)?)?/": "^lávvardat", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "se-SE"; ================================================ FILE: build/production/i18n/sk-SK.js ================================================ /* * DateJS Culture String File * Country Code: sk-SK * Name: Slovak (Slovakia) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["sk-SK"] = { "name": "sk-SK", "englishName": "Slovak (Slovakia)", "nativeName": "slovenčina (Slovenská republika)", "Sunday": "nedeľa", "Monday": "pondelok", "Tuesday": "utorok", "Wednesday": "streda", "Thursday": "štvrtok", "Friday": "piatok", "Saturday": "sobota", "Sun": "ne", "Mon": "po", "Tue": "ut", "Wed": "st", "Thu": "št", "Fri": "pi", "Sat": "so", "Su": "ne", "Mo": "po", "Tu": "ut", "We": "st", "Th": "št", "Fr": "pi", "Sa": "so", "S_Sun_Initial": "n", "M_Mon_Initial": "p", "T_Tue_Initial": "u", "W_Wed_Initial": "s", "T_Thu_Initial": "š", "F_Fri_Initial": "p", "S_Sat_Initial": "s", "January": "január", "February": "február", "March": "marec", "April": "apríl", "May": "máj", "June": "jún", "July": "júl", "August": "august", "September": "september", "October": "október", "November": "november", "December": "december", "Jan_Abbr": "I", "Feb_Abbr": "II", "Mar_Abbr": "III", "Apr_Abbr": "IV", "May_Abbr": "V", "Jun_Abbr": "VI", "Jul_Abbr": "VII", "Aug_Abbr": "VIII", "Sep_Abbr": "IX", "Oct_Abbr": "X", "Nov_Abbr": "XI", "Dec_Abbr": "XII", "AM": "", "PM": "", "firstDayOfWeek": 1, "twoDigitYearMax": 2029, "mdy": "dmy", "M/d/yyyy": "d. M. yyyy", "dddd, MMMM dd, yyyy": "d. MMMM yyyy", "h:mm tt": "H:mm", "h:mm:ss tt": "H:mm:ss", "dddd, MMMM dd, yyyy h:mm:ss tt": "d. MMMM yyyy H:mm:ss", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "dd MMMM", "MMMM, yyyy": "MMMM yyyy", "/jan(uary)?/": "január", "/feb(ruary)?/": "február", "/mar(ch)?/": "marec", "/apr(il)?/": "apríl", "/may/": "máj", "/jun(e)?/": "jún", "/jul(y)?/": "júl", "/aug(ust)?/": "august", "/sep(t(ember)?)?/": "sep(t(ember)?)?", "/oct(ober)?/": "október", "/nov(ember)?/": "november", "/dec(ember)?/": "december", "/^su(n(day)?)?/": "^nedeľa", "/^mo(n(day)?)?/": "^pondelok", "/^tu(e(s(day)?)?)?/": "^utorok", "/^we(d(nesday)?)?/": "^streda", "/^th(u(r(s(day)?)?)?)?/": "^štvrtok", "/^fr(i(day)?)?/": "^piatok", "/^sa(t(urday)?)?/": "^sobota", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "sk-SK"; ================================================ FILE: build/production/i18n/sl-SI.js ================================================ /* * DateJS Culture String File * Country Code: sl-SI * Name: Slovenian (Slovenia) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["sl-SI"] = { "name": "sl-SI", "englishName": "Slovenian (Slovenia)", "nativeName": "slovenski (Slovenija)", "Sunday": "nedelja", "Monday": "ponedeljek", "Tuesday": "torek", "Wednesday": "sreda", "Thursday": "četrtek", "Friday": "petek", "Saturday": "sobota", "Sun": "ned", "Mon": "pon", "Tue": "tor", "Wed": "sre", "Thu": "čet", "Fri": "pet", "Sat": "sob", "Su": "ne", "Mo": "po", "Tu": "to", "We": "sr", "Th": "če", "Fr": "pe", "Sa": "so", "S_Sun_Initial": "n", "M_Mon_Initial": "p", "T_Tue_Initial": "t", "W_Wed_Initial": "s", "T_Thu_Initial": "č", "F_Fri_Initial": "p", "S_Sat_Initial": "s", "January": "januar", "February": "februar", "March": "marec", "April": "april", "May": "maj", "June": "junij", "July": "julij", "August": "avgust", "September": "september", "October": "oktober", "November": "november", "December": "december", "Jan_Abbr": "jan", "Feb_Abbr": "feb", "Mar_Abbr": "mar", "Apr_Abbr": "apr", "May_Abbr": "maj", "Jun_Abbr": "jun", "Jul_Abbr": "jul", "Aug_Abbr": "avg", "Sep_Abbr": "sep", "Oct_Abbr": "okt", "Nov_Abbr": "nov", "Dec_Abbr": "dec", "AM": "", "PM": "", "firstDayOfWeek": 1, "twoDigitYearMax": 2029, "mdy": "dmy", "M/d/yyyy": "d.M.yyyy", "dddd, MMMM dd, yyyy": "d. MMMM yyyy", "h:mm tt": "H:mm", "h:mm:ss tt": "H:mm:ss", "dddd, MMMM dd, yyyy h:mm:ss tt": "d. MMMM yyyy H:mm:ss", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "d. MMMM", "MMMM, yyyy": "MMMM yyyy", "/jan(uary)?/": "jan(uar)?", "/feb(ruary)?/": "feb(ruar)?", "/mar(ch)?/": "mar(ec)?", "/apr(il)?/": "apr(il)?", "/may/": "maj", "/jun(e)?/": "jun(ij)?", "/jul(y)?/": "jul(ij)?", "/aug(ust)?/": "avg(ust)?", "/sep(t(ember)?)?/": "sep(t(ember)?)?", "/oct(ober)?/": "okt(ober)?", "/nov(ember)?/": "nov(ember)?", "/dec(ember)?/": "dec(ember)?", "/^su(n(day)?)?/": "^ne(d(elja)?)?", "/^mo(n(day)?)?/": "^po(n(edeljek)?)?", "/^tu(e(s(day)?)?)?/": "^to(r(ek)?)?", "/^we(d(nesday)?)?/": "^sr(e(da)?)?", "/^th(u(r(s(day)?)?)?)?/": "^če(t(rtek)?)?", "/^fr(i(day)?)?/": "^pe(t(ek)?)?", "/^sa(t(urday)?)?/": "^so(b(ota)?)?", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "sl-SI"; ================================================ FILE: build/production/i18n/sma-NO.js ================================================ /* * DateJS Culture String File * Country Code: sma-NO * Name: Sami (Southern) (Norway) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["sma-NO"] = { "name": "sma-NO", "englishName": "Sami (Southern) (Norway)", "nativeName": "åarjelsaemiengiele (Nöörje)", "Sunday": "aejlege", "Monday": "måanta", "Tuesday": "dæjsta", "Wednesday": "gaskevåhkoe", "Thursday": "duarsta", "Friday": "bearjadahke", "Saturday": "laavvardahke", "Sun": "aej", "Mon": "måa", "Tue": "dæj", "Wed": "gask", "Thu": "duar", "Fri": "bearj", "Sat": "laav", "Su": "aej", "Mo": "måa", "Tu": "dæj", "We": "gask", "Th": "duar", "Fr": "bearj", "Sa": "laav", "S_Sun_Initial": "a", "M_Mon_Initial": "m", "T_Tue_Initial": "d", "W_Wed_Initial": "g", "T_Thu_Initial": "d", "F_Fri_Initial": "b", "S_Sat_Initial": "l", "January": "tsïengele", "February": "goevte", "March": "njoktje", "April": "voerhtje", "May": "suehpede", "June": "ruffie", "July": "snjaltje", "August": "mïetske", "September": "skïerede", "October": "golke", "November": "rahka", "December": "goeve", "Jan_Abbr": "tsïen", "Feb_Abbr": "goevt", "Mar_Abbr": "njok", "Apr_Abbr": "voer", "May_Abbr": "sueh", "Jun_Abbr": "ruff", "Jul_Abbr": "snja", "Aug_Abbr": "mïet", "Sep_Abbr": "skïer", "Oct_Abbr": "golk", "Nov_Abbr": "rahk", "Dec_Abbr": "goev", "AM": "", "PM": "", "firstDayOfWeek": 1, "twoDigitYearMax": 2029, "mdy": "dmy", "M/d/yyyy": "dd.MM.yyyy", "dddd, MMMM dd, yyyy": "MMMM d'. b. 'yyyy", "h:mm tt": "HH:mm:ss", "h:mm:ss tt": "HH:mm:ss", "dddd, MMMM dd, yyyy h:mm:ss tt": "MMMM d'. b. 'yyyy HH:mm:ss", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "MMMM dd", "MMMM, yyyy": "MMMM yyyy", "/jan(uary)?/": "tsïen(gele)?", "/feb(ruary)?/": "goevt(e)?", "/mar(ch)?/": "njok(tje)?", "/apr(il)?/": "voer(htje)?", "/may/": "sueh(pede)?", "/jun(e)?/": "ruff(ie)?", "/jul(y)?/": "snja(ltje)?", "/aug(ust)?/": "mïet(ske)?", "/sep(t(ember)?)?/": "skïer(ede)?", "/oct(ober)?/": "golk(e)?", "/nov(ember)?/": "rahk(a)?", "/dec(ember)?/": "goev(e)?", "/^su(n(day)?)?/": "^aejlege", "/^mo(n(day)?)?/": "^måanta", "/^tu(e(s(day)?)?)?/": "^dæjsta", "/^we(d(nesday)?)?/": "^gaskevåhkoe", "/^th(u(r(s(day)?)?)?)?/": "^duarsta", "/^fr(i(day)?)?/": "^bearjadahke", "/^sa(t(urday)?)?/": "^laavvardahke", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "sma-NO"; ================================================ FILE: build/production/i18n/sma-SE.js ================================================ /* * DateJS Culture String File * Country Code: sma-SE * Name: Sami (Southern) (Sweden) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["sma-SE"] = { "name": "sma-SE", "englishName": "Sami (Southern) (Sweden)", "nativeName": "åarjelsaemiengiele (Sveerje)", "Sunday": "aejlege", "Monday": "måanta", "Tuesday": "dæjsta", "Wednesday": "gaskevåhkoe", "Thursday": "duarsta", "Friday": "bearjadahke", "Saturday": "laavvardahke", "Sun": "aej", "Mon": "måa", "Tue": "dæj", "Wed": "gask", "Thu": "duar", "Fri": "bearj", "Sat": "laav", "Su": "aej", "Mo": "måa", "Tu": "dæj", "We": "gask", "Th": "duar", "Fr": "bearj", "Sa": "laav", "S_Sun_Initial": "a", "M_Mon_Initial": "m", "T_Tue_Initial": "d", "W_Wed_Initial": "g", "T_Thu_Initial": "d", "F_Fri_Initial": "b", "S_Sat_Initial": "l", "January": "tsïengele", "February": "goevte", "March": "njoktje", "April": "voerhtje", "May": "suehpede", "June": "ruffie", "July": "snjaltje", "August": "mïetske", "September": "skïerede", "October": "golke", "November": "rahka", "December": "goeve", "Jan_Abbr": "tsïen", "Feb_Abbr": "goevt", "Mar_Abbr": "njok", "Apr_Abbr": "voer", "May_Abbr": "sueh", "Jun_Abbr": "ruff", "Jul_Abbr": "snja", "Aug_Abbr": "mïet", "Sep_Abbr": "skïer", "Oct_Abbr": "golk", "Nov_Abbr": "rahk", "Dec_Abbr": "goev", "AM": "", "PM": "", "firstDayOfWeek": 1, "twoDigitYearMax": 2029, "mdy": "ymd", "M/d/yyyy": "yyyy-MM-dd", "dddd, MMMM dd, yyyy": "MMMM d'. b. 'yyyy", "h:mm tt": "HH:mm:ss", "h:mm:ss tt": "HH:mm:ss", "dddd, MMMM dd, yyyy h:mm:ss tt": "MMMM d'. b. 'yyyy HH:mm:ss", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "MMMM dd", "MMMM, yyyy": "MMMM yyyy", "/jan(uary)?/": "tsïen(gele)?", "/feb(ruary)?/": "goevt(e)?", "/mar(ch)?/": "njok(tje)?", "/apr(il)?/": "voer(htje)?", "/may/": "sueh(pede)?", "/jun(e)?/": "ruff(ie)?", "/jul(y)?/": "snja(ltje)?", "/aug(ust)?/": "mïet(ske)?", "/sep(t(ember)?)?/": "skïer(ede)?", "/oct(ober)?/": "golk(e)?", "/nov(ember)?/": "rahk(a)?", "/dec(ember)?/": "goev(e)?", "/^su(n(day)?)?/": "^aejlege", "/^mo(n(day)?)?/": "^måanta", "/^tu(e(s(day)?)?)?/": "^dæjsta", "/^we(d(nesday)?)?/": "^gaskevåhkoe", "/^th(u(r(s(day)?)?)?)?/": "^duarsta", "/^fr(i(day)?)?/": "^bearjadahke", "/^sa(t(urday)?)?/": "^laavvardahke", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "sma-SE"; ================================================ FILE: build/production/i18n/smj-NO.js ================================================ /* * DateJS Culture String File * Country Code: smj-NO * Name: Sami (Lule) (Norway) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["smj-NO"] = { "name": "smj-NO", "englishName": "Sami (Lule) (Norway)", "nativeName": "julevusámegiella (Vuodna)", "Sunday": "sådnåbiejvve", "Monday": "mánnodahka", "Tuesday": "dijstahka", "Wednesday": "gasskavahkko", "Thursday": "duorastahka", "Friday": "bierjjedahka", "Saturday": "lávvodahka", "Sun": "såd", "Mon": "mán", "Tue": "dis", "Wed": "gas", "Thu": "duor", "Fri": "bier", "Sat": "láv", "Su": "såd", "Mo": "mán", "Tu": "dis", "We": "gas", "Th": "duor", "Fr": "bier", "Sa": "láv", "S_Sun_Initial": "s", "M_Mon_Initial": "m", "T_Tue_Initial": "d", "W_Wed_Initial": "g", "T_Thu_Initial": "d", "F_Fri_Initial": "b", "S_Sat_Initial": "l", "January": "ådåjakmánno", "February": "guovvamánno", "March": "sjnjuktjamánno", "April": "vuoratjismánno", "May": "moarmesmánno", "June": "biehtsemánno", "July": "sjnjilltjamánno", "August": "bårggemánno", "September": "ragátmánno", "October": "gålgådismánno", "November": "basádismánno", "December": "javllamánno", "Jan_Abbr": "ådåj", "Feb_Abbr": "guov", "Mar_Abbr": "snju", "Apr_Abbr": "vuor", "May_Abbr": "moar", "Jun_Abbr": "bieh", "Jul_Abbr": "snji", "Aug_Abbr": "bårg", "Sep_Abbr": "ragá", "Oct_Abbr": "gålg", "Nov_Abbr": "basá", "Dec_Abbr": "javl", "AM": "", "PM": "", "firstDayOfWeek": 1, "twoDigitYearMax": 2029, "mdy": "dmy", "M/d/yyyy": "dd.MM.yyyy", "dddd, MMMM dd, yyyy": "MMMM d'. b. 'yyyy", "h:mm tt": "HH:mm:ss", "h:mm:ss tt": "HH:mm:ss", "dddd, MMMM dd, yyyy h:mm:ss tt": "MMMM d'. b. 'yyyy HH:mm:ss", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "MMMM dd", "MMMM, yyyy": "MMMM yyyy", "/jan(uary)?/": "ådåj(akmánno)?", "/feb(ruary)?/": "guov(vamánno)?", "/mar(ch)?/": "sjnjuktjamánno", "/apr(il)?/": "vuor(atjismánno)?", "/may/": "moar(mesmánno)?", "/jun(e)?/": "bieh(tsemánno)?", "/jul(y)?/": "sjnjilltjamánno", "/aug(ust)?/": "bårg(gemánno)?", "/sep(t(ember)?)?/": "ragá(tmánno)?", "/oct(ober)?/": "gålg(ådismánno)?", "/nov(ember)?/": "basá(dismánno)?", "/dec(ember)?/": "javl(lamánno)?", "/^su(n(day)?)?/": "^sådnåbiejvve", "/^mo(n(day)?)?/": "^mánnodahka", "/^tu(e(s(day)?)?)?/": "^dijstahka", "/^we(d(nesday)?)?/": "^gasskavahkko", "/^th(u(r(s(day)?)?)?)?/": "^duorastahka", "/^fr(i(day)?)?/": "^bierjjedahka", "/^sa(t(urday)?)?/": "^lávvodahka", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "smj-NO"; ================================================ FILE: build/production/i18n/smj-SE.js ================================================ /* * DateJS Culture String File * Country Code: smj-SE * Name: Sami (Lule) (Sweden) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["smj-SE"] = { "name": "smj-SE", "englishName": "Sami (Lule) (Sweden)", "nativeName": "julevusámegiella (Svierik)", "Sunday": "ájllek", "Monday": "mánnodahka", "Tuesday": "dijstahka", "Wednesday": "gasskavahkko", "Thursday": "duorastahka", "Friday": "bierjjedahka", "Saturday": "lávvodahka", "Sun": "ájl", "Mon": "mán", "Tue": "dis", "Wed": "gas", "Thu": "duor", "Fri": "bier", "Sat": "láv", "Su": "ájl", "Mo": "mán", "Tu": "dis", "We": "gas", "Th": "duor", "Fr": "bier", "Sa": "láv", "S_Sun_Initial": "á", "M_Mon_Initial": "m", "T_Tue_Initial": "d", "W_Wed_Initial": "g", "T_Thu_Initial": "d", "F_Fri_Initial": "b", "S_Sat_Initial": "l", "January": "ådåjakmánno", "February": "guovvamánno", "March": "sjnjuktjamánno", "April": "vuoratjismánno", "May": "moarmesmánno", "June": "biehtsemánno", "July": "sjnjilltjamánno", "August": "bårggemánno", "September": "ragátmánno", "October": "gålgådismánno", "November": "basádismánno", "December": "javllamánno", "Jan_Abbr": "ådåj", "Feb_Abbr": "guov", "Mar_Abbr": "snju", "Apr_Abbr": "vuor", "May_Abbr": "moar", "Jun_Abbr": "bieh", "Jul_Abbr": "snji", "Aug_Abbr": "bårg", "Sep_Abbr": "ragá", "Oct_Abbr": "gålg", "Nov_Abbr": "basá", "Dec_Abbr": "javl", "AM": "", "PM": "", "firstDayOfWeek": 1, "twoDigitYearMax": 2029, "mdy": "ymd", "M/d/yyyy": "yyyy-MM-dd", "dddd, MMMM dd, yyyy": "MMMM d'. b. 'yyyy", "h:mm tt": "HH:mm:ss", "h:mm:ss tt": "HH:mm:ss", "dddd, MMMM dd, yyyy h:mm:ss tt": "MMMM d'. b. 'yyyy HH:mm:ss", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "MMMM dd", "MMMM, yyyy": "MMMM yyyy", "/jan(uary)?/": "ådåj(akmánno)?", "/feb(ruary)?/": "guov(vamánno)?", "/mar(ch)?/": "sjnjuktjamánno", "/apr(il)?/": "vuor(atjismánno)?", "/may/": "moar(mesmánno)?", "/jun(e)?/": "bieh(tsemánno)?", "/jul(y)?/": "sjnjilltjamánno", "/aug(ust)?/": "bårg(gemánno)?", "/sep(t(ember)?)?/": "ragá(tmánno)?", "/oct(ober)?/": "gålg(ådismánno)?", "/nov(ember)?/": "basá(dismánno)?", "/dec(ember)?/": "javl(lamánno)?", "/^su(n(day)?)?/": "^ájllek", "/^mo(n(day)?)?/": "^mánnodahka", "/^tu(e(s(day)?)?)?/": "^dijstahka", "/^we(d(nesday)?)?/": "^gasskavahkko", "/^th(u(r(s(day)?)?)?)?/": "^duorastahka", "/^fr(i(day)?)?/": "^bierjjedahka", "/^sa(t(urday)?)?/": "^lávvodahka", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "smj-SE"; ================================================ FILE: build/production/i18n/smn-FI.js ================================================ /* * DateJS Culture String File * Country Code: smn-FI * Name: Sami (Inari) (Finland) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["smn-FI"] = { "name": "smn-FI", "englishName": "Sami (Inari) (Finland)", "nativeName": "sämikielâ (Suomâ)", "Sunday": "pasepeivi", "Monday": "vuossargâ", "Tuesday": "majebargâ", "Wednesday": "koskokko", "Thursday": "tuorâstâh", "Friday": "vástuppeivi", "Saturday": "lávárdâh", "Sun": "pa", "Mon": "vu", "Tue": "ma", "Wed": "ko", "Thu": "tu", "Fri": "vá", "Sat": "lá", "Su": "pa", "Mo": "vu", "Tu": "ma", "We": "ko", "Th": "tu", "Fr": "vá", "Sa": "lá", "S_Sun_Initial": "p", "M_Mon_Initial": "v", "T_Tue_Initial": "m", "W_Wed_Initial": "k", "T_Thu_Initial": "t", "F_Fri_Initial": "v", "S_Sat_Initial": "l", "January": "uđđâivemáánu", "February": "kuovâmáánu", "March": "njuhčâmáánu", "April": "cuáŋuimáánu", "May": "vyesimáánu", "June": "kesimáánu", "July": "syeinimáánu", "August": "porgemáánu", "September": "čohčâmáánu", "October": "roovvâdmáánu", "November": "skammâmáánu", "December": "juovlâmáánu", "Jan_Abbr": "uđiv", "Feb_Abbr": "kuov", "Mar_Abbr": "njuh", "Apr_Abbr": "cuoŋ", "May_Abbr": "vyes", "Jun_Abbr": "kesi", "Jul_Abbr": "syei", "Aug_Abbr": "porg", "Sep_Abbr": "čoh", "Oct_Abbr": "roov", "Nov_Abbr": "ska", "Dec_Abbr": "juov", "AM": "", "PM": "", "firstDayOfWeek": 1, "twoDigitYearMax": 2029, "mdy": "dmy", "M/d/yyyy": "d.M.yyyy", "dddd, MMMM dd, yyyy": "MMMM d'. p. 'yyyy", "h:mm tt": "H:mm:ss", "h:mm:ss tt": "H:mm:ss", "dddd, MMMM dd, yyyy h:mm:ss tt": "MMMM d'. p. 'yyyy H:mm:ss", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "MMMM dd", "MMMM, yyyy": "MMMM yyyy", "/jan(uary)?/": "uđđâivemáánu", "/feb(ruary)?/": "kuov(âmáánu)?", "/mar(ch)?/": "njuh(čâmáánu)?", "/apr(il)?/": "cuáŋuimáánu", "/may/": "vyes(imáánu)?", "/jun(e)?/": "kesi(máánu)?", "/jul(y)?/": "syei(nimáánu)?", "/aug(ust)?/": "porg(emáánu)?", "/sep(t(ember)?)?/": "čoh(čâmáánu)?", "/oct(ober)?/": "roov(vâdmáánu)?", "/nov(ember)?/": "ska(mmâmáánu)?", "/dec(ember)?/": "juov(lâmáánu)?", "/^su(n(day)?)?/": "^pasepeivi", "/^mo(n(day)?)?/": "^vuossargâ", "/^tu(e(s(day)?)?)?/": "^majebargâ", "/^we(d(nesday)?)?/": "^koskokko", "/^th(u(r(s(day)?)?)?)?/": "^tuorâstâh", "/^fr(i(day)?)?/": "^vástuppeivi", "/^sa(t(urday)?)?/": "^lávárdâh", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "smn-FI"; ================================================ FILE: build/production/i18n/sms-FI.js ================================================ /* * DateJS Culture String File * Country Code: sms-FI * Name: Sami (Skolt) (Finland) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["sms-FI"] = { "name": "sms-FI", "englishName": "Sami (Skolt) (Finland)", "nativeName": "sääm´ǩiõll (Lää´ddjânnam)", "Sunday": "pâ´sspei´vv", "Monday": "vuõssargg", "Tuesday": "mââibargg", "Wednesday": "seärad", "Thursday": "nelljdpei´vv", "Friday": "piâtnâc", "Saturday": "sue´vet", "Sun": "pâ", "Mon": "vu", "Tue": "mâ", "Wed": "se", "Thu": "ne", "Fri": "pi", "Sat": "su", "Su": "pâ", "Mo": "vu", "Tu": "mâ", "We": "se", "Th": "ne", "Fr": "pi", "Sa": "su", "S_Sun_Initial": "p", "M_Mon_Initial": "v", "T_Tue_Initial": "m", "W_Wed_Initial": "s", "T_Thu_Initial": "n", "F_Fri_Initial": "p", "S_Sat_Initial": "s", "January": "ođđee´jjmään", "February": "tä´lvvmään", "March": "pâ´zzlâšttammään", "April": "njuhččmään", "May": "vue´ssmään", "June": "ǩie´ssmään", "July": "suei´nnmään", "August": "på´rǧǧmään", "September": "čõhččmään", "October": "kålggmään", "November": "skamm´mään", "December": "rosttovmään", "Jan_Abbr": "ođjm", "Feb_Abbr": "tä´lvv", "Mar_Abbr": "pâzl", "Apr_Abbr": "njuh", "May_Abbr": "vue", "Jun_Abbr": "ǩie", "Jul_Abbr": "suei", "Aug_Abbr": "på´r", "Sep_Abbr": "čõh", "Oct_Abbr": "kålg", "Nov_Abbr": "ska", "Dec_Abbr": "rost", "AM": "", "PM": "", "firstDayOfWeek": 1, "twoDigitYearMax": 2029, "mdy": "dmy", "M/d/yyyy": "d.M.yyyy", "dddd, MMMM dd, yyyy": "MMMM d'. p. 'yyyy", "h:mm tt": "H:mm:ss", "h:mm:ss tt": "H:mm:ss", "dddd, MMMM dd, yyyy h:mm:ss tt": "MMMM d'. p. 'yyyy H:mm:ss", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "MMMM dd", "MMMM, yyyy": "MMMM yyyy", "/jan(uary)?/": "ođđee´jjmään", "/feb(ruary)?/": "tä´lvv(mään)?", "/mar(ch)?/": "pâ´zzlâšttammään", "/apr(il)?/": "njuh(ččmään)?", "/may/": "vue(´ssmään)?", "/jun(e)?/": "ǩie(´ssmään)?", "/jul(y)?/": "suei(´nnmään)?", "/aug(ust)?/": "på´r(ǧǧmään)?", "/sep(t(ember)?)?/": "čõh(ččmään)?", "/oct(ober)?/": "kålg(gmään)?", "/nov(ember)?/": "ska(mm´mään)?", "/dec(ember)?/": "rost(tovmään)?", "/^su(n(day)?)?/": "^pâ´sspei´vv", "/^mo(n(day)?)?/": "^vuõssargg", "/^tu(e(s(day)?)?)?/": "^mââibargg", "/^we(d(nesday)?)?/": "^seärad", "/^th(u(r(s(day)?)?)?)?/": "^nelljdpei´vv", "/^fr(i(day)?)?/": "^piâtnâc", "/^sa(t(urday)?)?/": "^sue´vet", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "sms-FI"; ================================================ FILE: build/production/i18n/sq-AL.js ================================================ /* * DateJS Culture String File * Country Code: sq-AL * Name: Albanian (Albania) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["sq-AL"] = { "name": "sq-AL", "englishName": "Albanian (Albania)", "nativeName": "shqipe (Shqipëria)", "Sunday": "e diel", "Monday": "e hënë", "Tuesday": "e martë", "Wednesday": "e mërkurë", "Thursday": "e enjte", "Friday": "e premte", "Saturday": "e shtunë", "Sun": "Die", "Mon": "Hën", "Tue": "Mar", "Wed": "Mër", "Thu": "Enj", "Fri": "Pre", "Sat": "Sht", "Su": "Di", "Mo": "Hë", "Tu": "Ma", "We": "Më", "Th": "En", "Fr": "Pr", "Sa": "Sh", "S_Sun_Initial": "D", "M_Mon_Initial": "H", "T_Tue_Initial": "M", "W_Wed_Initial": "M", "T_Thu_Initial": "E", "F_Fri_Initial": "P", "S_Sat_Initial": "S", "January": "janar", "February": "shkurt", "March": "mars", "April": "prill", "May": "maj", "June": "qershor", "July": "korrik", "August": "gusht", "September": "shtator", "October": "tetor", "November": "nëntor", "December": "dhjetor", "Jan_Abbr": "Jan", "Feb_Abbr": "Shk", "Mar_Abbr": "Mar", "Apr_Abbr": "Pri", "May_Abbr": "Maj", "Jun_Abbr": "Qer", "Jul_Abbr": "Kor", "Aug_Abbr": "Gsh", "Sep_Abbr": "Sht", "Oct_Abbr": "Tet", "Nov_Abbr": "Nën", "Dec_Abbr": "Dhj", "AM": "PD", "PM": "MD", "firstDayOfWeek": 1, "twoDigitYearMax": 2029, "mdy": "ymd", "M/d/yyyy": "yyyy-MM-dd", "dddd, MMMM dd, yyyy": "yyyy-MM-dd", "h:mm tt": "h:mm.tt", "h:mm:ss tt": "h:mm:ss.tt", "dddd, MMMM dd, yyyy h:mm:ss tt": "yyyy-MM-dd h:mm:ss.tt", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "MMMM dd", "MMMM, yyyy": "yyyy-MM", "/jan(uary)?/": "jan(ar)?", "/feb(ruary)?/": "shk(urt)?", "/mar(ch)?/": "mar(s)?", "/apr(il)?/": "pri(ll)?", "/may/": "maj", "/jun(e)?/": "qer(shor)?", "/jul(y)?/": "kor(rik)?", "/aug(ust)?/": "gusht", "/sep(t(ember)?)?/": "sht(ator)?", "/oct(ober)?/": "tet(or)?", "/nov(ember)?/": "nën(tor)?", "/dec(ember)?/": "dhj(etor)?", "/^su(n(day)?)?/": "^di(e(iel)?)?", "/^mo(n(day)?)?/": "^hë(n(ënë)?)?", "/^tu(e(s(day)?)?)?/": "^ma(r(artë)?)?", "/^we(d(nesday)?)?/": "^më(r(ërkurë)?)?", "/^th(u(r(s(day)?)?)?)?/": "^en(j(njte)?)?", "/^fr(i(day)?)?/": "^pr(e(remte)?)?", "/^sa(t(urday)?)?/": "^sh(t(htunë)?)?", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "sq-AL"; ================================================ FILE: build/production/i18n/sr-Cyrl-BA.js ================================================ /* * DateJS Culture String File * Country Code: sr-Cyrl-BA * Name: Serbian (Cyrillic) (Bosnia and Herzegovina) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["sr-Cyrl-BA"] = { "name": "sr-Cyrl-BA", "englishName": "Serbian (Cyrillic) (Bosnia and Herzegovina)", "nativeName": "српски (Босна и Херцеговина)", "Sunday": "недеља", "Monday": "понедељак", "Tuesday": "уторак", "Wednesday": "среда", "Thursday": "четвртак", "Friday": "петак", "Saturday": "субота", "Sun": "нед", "Mon": "пон", "Tue": "уто", "Wed": "сре", "Thu": "чет", "Fri": "пет", "Sat": "суб", "Su": "нед", "Mo": "пон", "Tu": "уто", "We": "сре", "Th": "чет", "Fr": "пет", "Sa": "суб", "S_Sun_Initial": "н", "M_Mon_Initial": "п", "T_Tue_Initial": "у", "W_Wed_Initial": "с", "T_Thu_Initial": "ч", "F_Fri_Initial": "п", "S_Sat_Initial": "с", "January": "јануар", "February": "фебруар", "March": "март", "April": "април", "May": "мај", "June": "јун", "July": "јул", "August": "август", "September": "септембар", "October": "октобар", "November": "новембар", "December": "децембар", "Jan_Abbr": "јан", "Feb_Abbr": "феб", "Mar_Abbr": "мар", "Apr_Abbr": "апр", "May_Abbr": "мај", "Jun_Abbr": "јун", "Jul_Abbr": "јул", "Aug_Abbr": "авг", "Sep_Abbr": "сеп", "Oct_Abbr": "окт", "Nov_Abbr": "нов", "Dec_Abbr": "дец", "AM": "", "PM": "", "firstDayOfWeek": 1, "twoDigitYearMax": 2029, "mdy": "dmy", "M/d/yyyy": "d.M.yyyy", "dddd, MMMM dd, yyyy": "d. MMMM yyyy", "h:mm tt": "H:mm:ss", "h:mm:ss tt": "H:mm:ss", "dddd, MMMM dd, yyyy h:mm:ss tt": "d. MMMM yyyy H:mm:ss", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "MMMM dd", "MMMM, yyyy": "MMMM, yyyy", "/jan(uary)?/": "јан(уар)?", "/feb(ruary)?/": "феб(руар)?", "/mar(ch)?/": "мар(т)?", "/apr(il)?/": "апр(ил)?", "/may/": "мај", "/jun(e)?/": "јун", "/jul(y)?/": "јул", "/aug(ust)?/": "авг(уст)?", "/sep(t(ember)?)?/": "сеп(тембар)?", "/oct(ober)?/": "окт(обар)?", "/nov(ember)?/": "нов(ембар)?", "/dec(ember)?/": "дец(ембар)?", "/^su(n(day)?)?/": "^недеља", "/^mo(n(day)?)?/": "^понедељак", "/^tu(e(s(day)?)?)?/": "^уторак", "/^we(d(nesday)?)?/": "^среда", "/^th(u(r(s(day)?)?)?)?/": "^четвртак", "/^fr(i(day)?)?/": "^петак", "/^sa(t(urday)?)?/": "^субота", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "sr-Cyrl-BA"; ================================================ FILE: build/production/i18n/sr-Cyrl-CS.js ================================================ /* * DateJS Culture String File * Country Code: sr-Cyrl-CS * Name: Serbian (Cyrillic, Serbia) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["sr-Cyrl-CS"] = { "name": "sr-Cyrl-CS", "englishName": "Serbian (Cyrillic, Serbia)", "nativeName": "српски (Србија)", "Sunday": "недеља", "Monday": "понедељак", "Tuesday": "уторак", "Wednesday": "среда", "Thursday": "четвртак", "Friday": "петак", "Saturday": "субота", "Sun": "нед", "Mon": "пон", "Tue": "уто", "Wed": "сре", "Thu": "чет", "Fri": "пет", "Sat": "суб", "Su": "не", "Mo": "по", "Tu": "ут", "We": "ср", "Th": "че", "Fr": "пе", "Sa": "су", "S_Sun_Initial": "н", "M_Mon_Initial": "п", "T_Tue_Initial": "у", "W_Wed_Initial": "с", "T_Thu_Initial": "ч", "F_Fri_Initial": "п", "S_Sat_Initial": "с", "January": "јануар", "February": "фебруар", "March": "март", "April": "април", "May": "мај", "June": "јун", "July": "јул", "August": "август", "September": "септембар", "October": "октобар", "November": "новембар", "December": "децембар", "Jan_Abbr": "јан", "Feb_Abbr": "феб", "Mar_Abbr": "мар", "Apr_Abbr": "апр", "May_Abbr": "мај", "Jun_Abbr": "јун", "Jul_Abbr": "јул", "Aug_Abbr": "авг", "Sep_Abbr": "сеп", "Oct_Abbr": "окт", "Nov_Abbr": "нов", "Dec_Abbr": "дец", "AM": "", "PM": "", "firstDayOfWeek": 1, "twoDigitYearMax": 2029, "mdy": "dmy", "M/d/yyyy": "d.M.yyyy", "dddd, MMMM dd, yyyy": "d. MMMM yyyy", "h:mm tt": "H:mm", "h:mm:ss tt": "H:mm:ss", "dddd, MMMM dd, yyyy h:mm:ss tt": "d. MMMM yyyy H:mm:ss", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "d. MMMM", "MMMM, yyyy": "MMMM yyyy", "/jan(uary)?/": "јан(уар)?", "/feb(ruary)?/": "феб(руар)?", "/mar(ch)?/": "мар(т)?", "/apr(il)?/": "апр(ил)?", "/may/": "мај", "/jun(e)?/": "јун", "/jul(y)?/": "јул", "/aug(ust)?/": "авг(уст)?", "/sep(t(ember)?)?/": "сеп(тембар)?", "/oct(ober)?/": "окт(обар)?", "/nov(ember)?/": "нов(ембар)?", "/dec(ember)?/": "дец(ембар)?", "/^su(n(day)?)?/": "^не(д(еља)?)?", "/^mo(n(day)?)?/": "^по(н(едељак)?)?", "/^tu(e(s(day)?)?)?/": "^ут(о(рак)?)?", "/^we(d(nesday)?)?/": "^ср(е(да)?)?", "/^th(u(r(s(day)?)?)?)?/": "^че(т(вртак)?)?", "/^fr(i(day)?)?/": "^пе(т(ак)?)?", "/^sa(t(urday)?)?/": "^су(б(ота)?)?", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "sr-Cyrl-CS"; ================================================ FILE: build/production/i18n/sr-Latn-BA.js ================================================ /* * DateJS Culture String File * Country Code: sr-Latn-BA * Name: Serbian (Latin) (Bosnia and Herzegovina) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["sr-Latn-BA"] = { "name": "sr-Latn-BA", "englishName": "Serbian (Latin) (Bosnia and Herzegovina)", "nativeName": "srpski (Bosna i Hercegovina)", "Sunday": "nedelja", "Monday": "ponedeljak", "Tuesday": "utorak", "Wednesday": "sreda", "Thursday": "četvrtak", "Friday": "petak", "Saturday": "subota", "Sun": "ned", "Mon": "pon", "Tue": "uto", "Wed": "sre", "Thu": "čet", "Fri": "pet", "Sat": "sub", "Su": "ned", "Mo": "pon", "Tu": "uto", "We": "sre", "Th": "čet", "Fr": "pet", "Sa": "sub", "S_Sun_Initial": "n", "M_Mon_Initial": "p", "T_Tue_Initial": "u", "W_Wed_Initial": "s", "T_Thu_Initial": "č", "F_Fri_Initial": "p", "S_Sat_Initial": "s", "January": "januar", "February": "februar", "March": "mart", "April": "april", "May": "maj", "June": "jun", "July": "jul", "August": "avgust", "September": "septembar", "October": "oktobar", "November": "novembar", "December": "decembar", "Jan_Abbr": "jan", "Feb_Abbr": "feb", "Mar_Abbr": "mar", "Apr_Abbr": "apr", "May_Abbr": "maj", "Jun_Abbr": "jun", "Jul_Abbr": "jul", "Aug_Abbr": "avg", "Sep_Abbr": "sep", "Oct_Abbr": "okt", "Nov_Abbr": "nov", "Dec_Abbr": "dec", "AM": "", "PM": "", "firstDayOfWeek": 1, "twoDigitYearMax": 2029, "mdy": "dmy", "M/d/yyyy": "d.M.yyyy", "dddd, MMMM dd, yyyy": "d. MMMM yyyy", "h:mm tt": "H:mm:ss", "h:mm:ss tt": "H:mm:ss", "dddd, MMMM dd, yyyy h:mm:ss tt": "d. MMMM yyyy H:mm:ss", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "MMMM dd", "MMMM, yyyy": "MMMM yyyy", "/jan(uary)?/": "jan(uar)?", "/feb(ruary)?/": "feb(ruar)?", "/mar(ch)?/": "mar(t)?", "/apr(il)?/": "apr(il)?", "/may/": "maj", "/jun(e)?/": "jun", "/jul(y)?/": "jul", "/aug(ust)?/": "avg(ust)?", "/sep(t(ember)?)?/": "sep(tembar)?", "/oct(ober)?/": "okt(obar)?", "/nov(ember)?/": "nov(embar)?", "/dec(ember)?/": "dec(embar)?", "/^su(n(day)?)?/": "^nedelja", "/^mo(n(day)?)?/": "^ponedeljak", "/^tu(e(s(day)?)?)?/": "^utorak", "/^we(d(nesday)?)?/": "^sreda", "/^th(u(r(s(day)?)?)?)?/": "^četvrtak", "/^fr(i(day)?)?/": "^petak", "/^sa(t(urday)?)?/": "^subota", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "sr-Latn-BA"; ================================================ FILE: build/production/i18n/sr-Latn-CS.js ================================================ /* * DateJS Culture String File * Country Code: sr-Latn-CS * Name: Serbian (Latin, Serbia) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["sr-Latn-CS"] = { "name": "sr-Latn-CS", "englishName": "Serbian (Latin, Serbia)", "nativeName": "srpski (Srbija)", "Sunday": "nedelja", "Monday": "ponedeljak", "Tuesday": "utorak", "Wednesday": "sreda", "Thursday": "četvrtak", "Friday": "petak", "Saturday": "subota", "Sun": "ned", "Mon": "pon", "Tue": "uto", "Wed": "sre", "Thu": "čet", "Fri": "pet", "Sat": "sub", "Su": "ne", "Mo": "po", "Tu": "ut", "We": "sr", "Th": "če", "Fr": "pe", "Sa": "su", "S_Sun_Initial": "n", "M_Mon_Initial": "p", "T_Tue_Initial": "u", "W_Wed_Initial": "s", "T_Thu_Initial": "č", "F_Fri_Initial": "p", "S_Sat_Initial": "s", "January": "januar", "February": "februar", "March": "mart", "April": "april", "May": "maj", "June": "jun", "July": "jul", "August": "avgust", "September": "septembar", "October": "oktobar", "November": "novembar", "December": "decembar", "Jan_Abbr": "jan", "Feb_Abbr": "feb", "Mar_Abbr": "mar", "Apr_Abbr": "apr", "May_Abbr": "maj", "Jun_Abbr": "jun", "Jul_Abbr": "jul", "Aug_Abbr": "avg", "Sep_Abbr": "sep", "Oct_Abbr": "okt", "Nov_Abbr": "nov", "Dec_Abbr": "dec", "AM": "", "PM": "", "firstDayOfWeek": 1, "twoDigitYearMax": 2029, "mdy": "dmy", "M/d/yyyy": "d.M.yyyy", "dddd, MMMM dd, yyyy": "d. MMMM yyyy", "h:mm tt": "H:mm", "h:mm:ss tt": "H:mm:ss", "dddd, MMMM dd, yyyy h:mm:ss tt": "d. MMMM yyyy H:mm:ss", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "d. MMMM", "MMMM, yyyy": "MMMM yyyy", "/jan(uary)?/": "jan(uar)?", "/feb(ruary)?/": "feb(ruar)?", "/mar(ch)?/": "mar(t)?", "/apr(il)?/": "apr(il)?", "/may/": "maj", "/jun(e)?/": "jun", "/jul(y)?/": "jul", "/aug(ust)?/": "avg(ust)?", "/sep(t(ember)?)?/": "sep(tembar)?", "/oct(ober)?/": "okt(obar)?", "/nov(ember)?/": "nov(embar)?", "/dec(ember)?/": "dec(embar)?", "/^su(n(day)?)?/": "^ne(d(elja)?)?", "/^mo(n(day)?)?/": "^po(n(edeljak)?)?", "/^tu(e(s(day)?)?)?/": "^ut(o(rak)?)?", "/^we(d(nesday)?)?/": "^sr(e(da)?)?", "/^th(u(r(s(day)?)?)?)?/": "^če(t(vrtak)?)?", "/^fr(i(day)?)?/": "^pe(t(ak)?)?", "/^sa(t(urday)?)?/": "^su(b(ota)?)?", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "sr-Latn-CS"; ================================================ FILE: build/production/i18n/sv-FI.js ================================================ /* * DateJS Culture String File * Country Code: sv-FI * Name: Swedish (Finland) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["sv-FI"] = { "name": "sv-FI", "englishName": "Swedish (Finland)", "nativeName": "svenska (Finland)", "Sunday": "söndag", "Monday": "måndag", "Tuesday": "tisdag", "Wednesday": "onsdag", "Thursday": "torsdag", "Friday": "fredag", "Saturday": "lördag", "Sun": "sö", "Mon": "må", "Tue": "ti", "Wed": "on", "Thu": "to", "Fri": "fr", "Sat": "lö", "Su": "sö", "Mo": "må", "Tu": "ti", "We": "on", "Th": "to", "Fr": "fr", "Sa": "lö", "S_Sun_Initial": "s", "M_Mon_Initial": "m", "T_Tue_Initial": "t", "W_Wed_Initial": "o", "T_Thu_Initial": "t", "F_Fri_Initial": "f", "S_Sat_Initial": "l", "January": "januari", "February": "februari", "March": "mars", "April": "april", "May": "maj", "June": "juni", "July": "juli", "August": "augusti", "September": "september", "October": "oktober", "November": "november", "December": "december", "Jan_Abbr": "jan", "Feb_Abbr": "feb", "Mar_Abbr": "mar", "Apr_Abbr": "apr", "May_Abbr": "maj", "Jun_Abbr": "jun", "Jul_Abbr": "jul", "Aug_Abbr": "aug", "Sep_Abbr": "sep", "Oct_Abbr": "okt", "Nov_Abbr": "nov", "Dec_Abbr": "dec", "AM": "", "PM": "", "firstDayOfWeek": 1, "twoDigitYearMax": 2029, "mdy": "dmy", "M/d/yyyy": "d.M.yyyy", "dddd, MMMM dd, yyyy": "'den 'd MMMM yyyy", "h:mm tt": "HH:mm", "h:mm:ss tt": "HH:mm:ss", "dddd, MMMM dd, yyyy h:mm:ss tt": "'den 'd MMMM yyyy HH:mm:ss", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "'den 'd MMMM", "MMMM, yyyy": "MMMM yyyy", "/jan(uary)?/": "jan(uari)?", "/feb(ruary)?/": "feb(ruari)?", "/mar(ch)?/": "mar(s)?", "/apr(il)?/": "apr(il)?", "/may/": "maj", "/jun(e)?/": "jun(i)?", "/jul(y)?/": "jul(i)?", "/aug(ust)?/": "aug(usti)?", "/sep(t(ember)?)?/": "sep(t(ember)?)?", "/oct(ober)?/": "okt(ober)?", "/nov(ember)?/": "nov(ember)?", "/dec(ember)?/": "dec(ember)?", "/^su(n(day)?)?/": "^söndag", "/^mo(n(day)?)?/": "^måndag", "/^tu(e(s(day)?)?)?/": "^tisdag", "/^we(d(nesday)?)?/": "^onsdag", "/^th(u(r(s(day)?)?)?)?/": "^torsdag", "/^fr(i(day)?)?/": "^fredag", "/^sa(t(urday)?)?/": "^lördag", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "sv-FI"; ================================================ FILE: build/production/i18n/sv-SE.js ================================================ /* * DateJS Culture String File * Country Code: sv-SE * Name: Swedish (Sweden) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["sv-SE"] = { "name": "sv-SE", "englishName": "Swedish (Sweden)", "nativeName": "Svenska (Sverige)", "Sunday": "Söndag", "Monday": "Måndag", "Tuesday": "Tisdag", "Wednesday": "Onsdag", "Thursday": "Torsdag", "Friday": "Fredag", "Saturday": "Lördag", "Sun": "Sön", "Mon": "Mån", "Tue": "Tis", "Wed": "Ons", "Thu": "Tor", "Fri": "Fre", "Sat": "Lör", "Su": "Sö", "Mo": "Må", "Tu": "Ti", "We": "On", "Th": "To", "Fr": "Fr", "Sa": "Lö", "S_Sun_Initial": "S", "M_Mon_Initial": "M", "T_Tue_Initial": "T", "W_Wed_Initial": "O", "T_Thu_Initial": "T", "F_Fri_Initial": "F", "S_Sat_Initial": "L", "January": "Januari", "February": "Februari", "March": "Mars", "April": "April", "May": "Maj", "June": "Juni", "July": "Juli", "August": "Augusti", "September": "September", "October": "Oktober", "November": "November", "December": "December", "Jan_Abbr": "Jan", "Feb_Abbr": "Feb", "Mar_Abbr": "Mar", "Apr_Abbr": "Apr", "May_Abbr": "Maj", "Jun_Abbr": "Jun", "Jul_Abbr": "Jul", "Aug_Abbr": "Aug", "Sep_Abbr": "Sep", "Oct_Abbr": "Okt", "Nov_Abbr": "Nov", "Dec_Abbr": "Dec", "AM": "", "PM": "", "firstDayOfWeek": 1, "twoDigitYearMax": 2029, "mdy": "ymd", "M/d/yyyy": "yyyy-MM-dd", "dddd, MMMM dd, yyyy": "'den 'd MMMM yyyy", "h:mm tt": "HH.mm", "h:mm:ss tt": "HH.mm.ss", "dddd, MMMM dd, yyyy h:mm:ss tt": "'den 'd MMMM yyyy HH.mm.ss", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH.mm.ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH.mm.ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH.mm.ss", "MMMM dd": "'den 'd MMMM", "MMMM, yyyy": "MMMM yyyy", "/jan(uary)?/": "jan(uari)?", "/feb(ruary)?/": "feb(ruari)?", "/mar(ch)?/": "mar(s)?", "/apr(il)?/": "apr(il)?", "/may/": "maj", "/jun(e)?/": "jun(i)?", "/jul(y)?/": "jul(i)?", "/aug(ust)?/": "aug(usti)?", "/sep(t(ember)?)?/": "sep(t(ember)?)?", "/oct(ober)?/": "okt(ober)?", "/nov(ember)?/": "nov(ember)?", "/dec(ember)?/": "dec(ember)?", "/^su(n(day)?)?/": "^sö(n(dag)?)?", "/^mo(n(day)?)?/": "^må(n(dag)?)?", "/^tu(e(s(day)?)?)?/": "^ti(s(dag)?)?", "/^we(d(nesday)?)?/": "^on(s(dag)?)?", "/^th(u(r(s(day)?)?)?)?/": "^to(r(s(dag)?)?)?", "/^fr(i(day)?)?/": "^fr(e(dag)?)?", "/^sa(t(urday)?)?/": "^lö(r(dag)?)?", "/^next/": "^nästa", "/^last|past|prev(ious)?/": "^föregående|förra|senaste", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|efter|från)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|före|tidigare)", "/^yes(terday)?/": "^i\\s?går|(för)går(dag)?", "/^t(od(ay)?)?/": "^i\\s?dag?", "/^tom(orrow)?/": "^i\\s?morgon|morgon(dag)?", "/^n(ow)?/": "^nu", "/^ms|milli(second)?s?/": "^ms|milli(sekund)?(er)?", "/^sec(ond)?s?/": "^sek(und)?(er)?", "/^mn|min(ute)?s?/": "^min(ut)?(er)?", "/^h(our)?s?/": "^t(im)?(ar)?", "/^w(eek)?s?/": "^v(eck(a)?)?(or)?", "/^m(onth)?s?/": "^m(ånad)?(er)?", "/^d(ay)?s?/": "^d(ag)?(ar)?", "/^y(ear)?s?/": "^å(r)?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "sv-SE"; ================================================ FILE: build/production/i18n/sw-KE.js ================================================ /* * DateJS Culture String File * Country Code: sw-KE * Name: Kiswahili (Kenya) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["sw-KE"] = { "name": "sw-KE", "englishName": "Kiswahili (Kenya)", "nativeName": "Kiswahili (Kenya)", "Sunday": "Sunday", "Monday": "Monday", "Tuesday": "Tuesday", "Wednesday": "Wednesday", "Thursday": "Thursday", "Friday": "Friday", "Saturday": "Saturday", "Sun": "Sun", "Mon": "Mon", "Tue": "Tue", "Wed": "Wed", "Thu": "Thu", "Fri": "Fri", "Sat": "Sat", "Su": "S", "Mo": "M", "Tu": "T", "We": "W", "Th": "T", "Fr": "F", "Sa": "S", "S_Sun_Initial": "S", "M_Mon_Initial": "M", "T_Tue_Initial": "T", "W_Wed_Initial": "W", "T_Thu_Initial": "T", "F_Fri_Initial": "F", "S_Sat_Initial": "S", "January": "January", "February": "February", "March": "March", "April": "April", "May": "May", "June": "June", "July": "July", "August": "August", "September": "September", "October": "October", "November": "November", "December": "December", "Jan_Abbr": "Jan", "Feb_Abbr": "Feb", "Mar_Abbr": "Mar", "Apr_Abbr": "Apr", "May_Abbr": "May", "Jun_Abbr": "Jun", "Jul_Abbr": "Jul", "Aug_Abbr": "Aug", "Sep_Abbr": "Sep", "Oct_Abbr": "Oct", "Nov_Abbr": "Nov", "Dec_Abbr": "Dec", "AM": "AM", "PM": "PM", "firstDayOfWeek": 0, "twoDigitYearMax": 2029, "mdy": "mdy", "M/d/yyyy": "M/d/yyyy", "dddd, MMMM dd, yyyy": "dddd, MMMM dd, yyyy", "h:mm tt": "h:mm tt", "h:mm:ss tt": "h:mm:ss tt", "dddd, MMMM dd, yyyy h:mm:ss tt": "dddd, MMMM dd, yyyy h:mm:ss tt", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "MMMM dd", "MMMM, yyyy": "MMMM, yyyy", "/jan(uary)?/": "jan(uary)?", "/feb(ruary)?/": "feb(ruary)?", "/mar(ch)?/": "mar(ch)?", "/apr(il)?/": "apr(il)?", "/may/": "may", "/jun(e)?/": "jun(e)?", "/jul(y)?/": "jul(y)?", "/aug(ust)?/": "aug(ust)?", "/sep(t(ember)?)?/": "sep(t(ember)?)?", "/oct(ober)?/": "oct(ober)?", "/nov(ember)?/": "nov(ember)?", "/dec(ember)?/": "dec(ember)?", "/^su(n(day)?)?/": "^s(un(day)?)?", "/^mo(n(day)?)?/": "^m(on(day)?)?", "/^tu(e(s(day)?)?)?/": "^tu(e(s(day)?)?)?", "/^we(d(nesday)?)?/": "^w(ed(nesday)?)?", "/^th(u(r(s(day)?)?)?)?/": "^th(u(r(s(day)?)?)?)?", "/^fr(i(day)?)?/": "^f(ri(day)?)?", "/^sa(t(urday)?)?/": "^s(at(urday)?)?", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "sw-KE"; ================================================ FILE: build/production/i18n/syr-SY.js ================================================ /* * DateJS Culture String File * Country Code: syr-SY * Name: Syriac (Syria) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["syr-SY"] = { "name": "syr-SY", "englishName": "Syriac (Syria)", "nativeName": "ܣܘܪܝܝܐ (سوريا)", "Sunday": "ܚܕ ܒܫܒܐ", "Monday": "ܬܪܝܢ ܒܫܒܐ", "Tuesday": "ܬܠܬܐ ܒܫܒܐ", "Wednesday": "ܐܪܒܥܐ ܒܫܒܐ", "Thursday": "ܚܡܫܐ ܒܫܒܐ", "Friday": "ܥܪܘܒܬܐ", "Saturday": "ܫܒܬܐ", "Sun": "܏ܐ ܏ܒܫ", "Mon": "܏ܒ ܏ܒܫ", "Tue": "܏ܓ ܏ܒܫ", "Wed": "܏ܕ ܏ܒܫ", "Thu": "܏ܗ ܏ܒܫ", "Fri": "܏ܥܪܘܒ", "Sat": "܏ܫܒ", "Su": "܏", "Mo": "܏", "Tu": "܏", "We": "܏", "Th": "܏", "Fr": "܏", "Sa": "܏", "S_Sun_Initial": "܏", "M_Mon_Initial": "܏", "T_Tue_Initial": "܏", "W_Wed_Initial": "܏", "T_Thu_Initial": "܏", "F_Fri_Initial": "܏", "S_Sat_Initial": "܏", "January": "ܟܢܘܢ ܐܚܪܝ", "February": "ܫܒܛ", "March": "ܐܕܪ", "April": "ܢܝܣܢ", "May": "ܐܝܪ", "June": "ܚܙܝܪܢ", "July": "ܬܡܘܙ", "August": "ܐܒ", "September": "ܐܝܠܘܠ", "October": "ܬܫܪܝ ܩܕܝܡ", "November": "ܬܫܪܝ ܐܚܪܝ", "December": "ܟܢܘܢ ܩܕܝܡ", "Jan_Abbr": "܏ܟܢ ܏ܒ", "Feb_Abbr": "ܫܒܛ", "Mar_Abbr": "ܐܕܪ", "Apr_Abbr": "ܢܝܣܢ", "May_Abbr": "ܐܝܪ", "Jun_Abbr": "ܚܙܝܪܢ", "Jul_Abbr": "ܬܡܘܙ", "Aug_Abbr": "ܐܒ", "Sep_Abbr": "ܐܝܠܘܠ", "Oct_Abbr": "܏ܬܫ ܏ܐ", "Nov_Abbr": "܏ܬܫ ܏ܒ", "Dec_Abbr": "܏ܟܢ ܏ܐ", "AM": "ܩ.ܛ", "PM": "ܒ.ܛ", "firstDayOfWeek": 6, "twoDigitYearMax": 2029, "mdy": "dmy", "M/d/yyyy": "dd/MM/yyyy", "dddd, MMMM dd, yyyy": "dd MMMM, yyyy", "h:mm tt": "hh:mm tt", "h:mm:ss tt": "hh:mm:ss tt", "dddd, MMMM dd, yyyy h:mm:ss tt": "dd MMMM, yyyy hh:mm:ss tt", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "dd MMMM", "MMMM, yyyy": "MMMM, yyyy", "/jan(uary)?/": "ܟܢܘܢ ܐܚܪܝ", "/feb(ruary)?/": "ܫܒܛ", "/mar(ch)?/": "ܐܕܪ", "/apr(il)?/": "ܢܝܣܢ", "/may/": "ܐܝܪ", "/jun(e)?/": "ܚܙܝܪܢ", "/jul(y)?/": "ܬܡܘܙ", "/aug(ust)?/": "ܐܒ", "/sep(t(ember)?)?/": "ܐܝܠܘܠ", "/oct(ober)?/": "ܬܫܪܝ ܩܕܝܡ", "/nov(ember)?/": "ܬܫܪܝ ܐܚܪܝ", "/dec(ember)?/": "ܟܢܘܢ ܩܕܝܡ", "/^su(n(day)?)?/": "^܏(ܐ ܏ܒܫ(ܐ)?)?", "/^mo(n(day)?)?/": "^܏(ܒ ܏ܒܫ(ܫܒܐ)?)?", "/^tu(e(s(day)?)?)?/": "^܏(ܓ ܏ܒܫ(ܫܒܐ)?)?", "/^we(d(nesday)?)?/": "^܏(ܕ ܏ܒܫ(ܒܫܒܐ)?)?", "/^th(u(r(s(day)?)?)?)?/": "^܏(ܗ ܏ܒܫ(ܫܒܐ)?)?", "/^fr(i(day)?)?/": "^܏(ܥܪܘܒ(ܐ)?)?", "/^sa(t(urday)?)?/": "^܏(ܫܒ(ܐ)?)?", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "syr-SY"; ================================================ FILE: build/production/i18n/ta-IN.js ================================================ /* * DateJS Culture String File * Country Code: ta-IN * Name: Tamil (India) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["ta-IN"] = { "name": "ta-IN", "englishName": "Tamil (India)", "nativeName": "தமிழ் (இந்தியா)", "Sunday": "ஞாயிறு", "Monday": "திங்கள்", "Tuesday": "செவ்வாய்", "Wednesday": "புதன்", "Thursday": "வியாழன்", "Friday": "வெள்ளி", "Saturday": "சனி", "Sun": "ஞா", "Mon": "தி", "Tue": "செ", "Wed": "பு", "Thu": "வி", "Fri": "வெ", "Sat": "ச", "Su": "ஞ", "Mo": "த", "Tu": "ச", "We": "ப", "Th": "வ", "Fr": "வ", "Sa": "ச", "S_Sun_Initial": "ஞ", "M_Mon_Initial": "த", "T_Tue_Initial": "ச", "W_Wed_Initial": "ப", "T_Thu_Initial": "வ", "F_Fri_Initial": "வ", "S_Sat_Initial": "ச", "January": "ஜனவரி", "February": "பெப்ரவரி", "March": "மார்ச்", "April": "ஏப்ரல்", "May": "மே", "June": "ஜூன்", "July": "ஜூலை", "August": "ஆகஸ்ட்", "September": "செப்டம்பர்", "October": "அக்டோபர்", "November": "நவம்பர்", "December": "டிசம்பர்", "Jan_Abbr": "ஜன.", "Feb_Abbr": "பெப்.", "Mar_Abbr": "மார்.", "Apr_Abbr": "ஏப்.", "May_Abbr": "மே", "Jun_Abbr": "ஜூன்", "Jul_Abbr": "ஜூலை", "Aug_Abbr": "ஆக.", "Sep_Abbr": "செப்.", "Oct_Abbr": "அக்.", "Nov_Abbr": "நவ.", "Dec_Abbr": "டிச.", "AM": "காலை", "PM": "மாலை", "firstDayOfWeek": 1, "twoDigitYearMax": 2029, "mdy": "dmy", "M/d/yyyy": "dd-MM-yyyy", "dddd, MMMM dd, yyyy": "dd MMMM yyyy", "h:mm tt": "HH:mm", "h:mm:ss tt": "HH:mm:ss", "dddd, MMMM dd, yyyy h:mm:ss tt": "dd MMMM yyyy HH:mm:ss", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "dd MMMM", "MMMM, yyyy": "MMMM yyyy", "/jan(uary)?/": "ஜன(.(வரி)?)?", "/feb(ruary)?/": "பெப்(.(ரவரி)?)?", "/mar(ch)?/": "மார்(.(ச்)?)?", "/apr(il)?/": "ஏப்(.(ரல்)?)?", "/may/": "மே", "/jun(e)?/": "ஜூன்", "/jul(y)?/": "ஜூலை", "/aug(ust)?/": "ஆக(.(ஸ்ட்)?)?", "/sep(t(ember)?)?/": "செப்(.(டம்பர்)?)?", "/oct(ober)?/": "அக்(.(டோபர்)?)?", "/nov(ember)?/": "நவ(.(ம்பர்)?)?", "/dec(ember)?/": "டிச(.(ம்பர்)?)?", "/^su(n(day)?)?/": "^ஞ(ா(யிறு)?)?", "/^mo(n(day)?)?/": "^த(ி(ங்கள்)?)?", "/^tu(e(s(day)?)?)?/": "^ச(ெ(வ்வாய்)?)?", "/^we(d(nesday)?)?/": "^ப(ு(தன்)?)?", "/^th(u(r(s(day)?)?)?)?/": "^வ(ி(யாழன்)?)?", "/^fr(i(day)?)?/": "^வ(ெ(ள்ளி)?)?", "/^sa(t(urday)?)?/": "^சனி", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "ta-IN"; ================================================ FILE: build/production/i18n/te-IN.js ================================================ /* * DateJS Culture String File * Country Code: te-IN * Name: Telugu (India) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["te-IN"] = { "name": "te-IN", "englishName": "Telugu (India)", "nativeName": "తెలుగు (భారత దేశం)", "Sunday": "ఆదివారం", "Monday": "సోమవారం", "Tuesday": "మంగళవారం", "Wednesday": "బుధవారం", "Thursday": "గురువారం", "Friday": "శుక్రవారం", "Saturday": "శనివారం", "Sun": "ఆది.", "Mon": "సోమ.", "Tue": "మంగళ.", "Wed": "బుధ.", "Thu": "గురు.", "Fri": "శుక్ర.", "Sat": "శని.", "Su": "ఆ", "Mo": "స", "Tu": "మ", "We": "బ", "Th": "గ", "Fr": "శ", "Sa": "శ", "S_Sun_Initial": "ఆ", "M_Mon_Initial": "స", "T_Tue_Initial": "మ", "W_Wed_Initial": "బ", "T_Thu_Initial": "గ", "F_Fri_Initial": "శ", "S_Sat_Initial": "శ", "January": "జనవరి", "February": "ఫిబ్రవరి", "March": "మార్చి", "April": "ఏప్రిల్", "May": "మే", "June": "జూన్", "July": "జూలై", "August": "ఆగస్టు", "September": "సెప్టెంబర్", "October": "అక్టోబర్", "November": "నవంబర్", "December": "డిసెంబర్", "Jan_Abbr": "జనవరి", "Feb_Abbr": "ఫిబ్రవరి", "Mar_Abbr": "మార్చి", "Apr_Abbr": "ఏప్రిల్", "May_Abbr": "మే", "Jun_Abbr": "జూన్", "Jul_Abbr": "జూలై", "Aug_Abbr": "ఆగస్టు", "Sep_Abbr": "సెప్టెంబర్", "Oct_Abbr": "అక్టోబర్", "Nov_Abbr": "నవంబర్", "Dec_Abbr": "డిసెంబర్", "AM": "పూర్వాహ్న", "PM": "అపరాహ్న", "firstDayOfWeek": 1, "twoDigitYearMax": 2029, "mdy": "dmy", "M/d/yyyy": "dd-MM-yy", "dddd, MMMM dd, yyyy": "dd MMMM yyyy", "h:mm tt": "HH:mm", "h:mm:ss tt": "HH:mm:ss", "dddd, MMMM dd, yyyy h:mm:ss tt": "dd MMMM yyyy HH:mm:ss", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "dd MMMM", "MMMM, yyyy": "MMMM, yyyy", "/jan(uary)?/": "జనవరి", "/feb(ruary)?/": "ఫిబ్రవరి", "/mar(ch)?/": "మార్చి", "/apr(il)?/": "ఏప్రిల్", "/may/": "మే", "/jun(e)?/": "జూన్", "/jul(y)?/": "జూలై", "/aug(ust)?/": "ఆగస్టు", "/sep(t(ember)?)?/": "సెప్టెంబర్", "/oct(ober)?/": "అక్టోబర్", "/nov(ember)?/": "నవంబర్", "/dec(ember)?/": "డిసెంబర్", "/^su(n(day)?)?/": "^ఆ(ది(.(వారం)?)?)?", "/^mo(n(day)?)?/": "^స(ోమ(.(వారం)?)?)?", "/^tu(e(s(day)?)?)?/": "^మ(ంగళ(.(వారం)?)?)?", "/^we(d(nesday)?)?/": "^బ(ుధ(.(వారం)?)?)?", "/^th(u(r(s(day)?)?)?)?/": "^గ(ురు(.(వారం)?)?)?", "/^fr(i(day)?)?/": "^శ(ుక్ర(.(వారం)?)?)?", "/^sa(t(urday)?)?/": "^శ(ని(.(వారం)?)?)?", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "te-IN"; ================================================ FILE: build/production/i18n/th-TH.js ================================================ /* * DateJS Culture String File * Country Code: th-TH * Name: Thai (Thailand) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["th-TH"] = { "name": "th-TH", "englishName": "Thai (Thailand)", "nativeName": "ไทย (ไทย)", "Sunday": "อาทิตย์", "Monday": "จันทร์", "Tuesday": "อังคาร", "Wednesday": "พุธ", "Thursday": "พฤหัสบดี", "Friday": "ศุกร์", "Saturday": "เสาร์", "Sun": "อา.", "Mon": "จ.", "Tue": "อ.", "Wed": "พ.", "Thu": "พฤ.", "Fri": "ศ.", "Sat": "ส.", "Su": "อ", "Mo": "จ", "Tu": "อ", "We": "พ", "Th": "พ", "Fr": "ศ", "Sa": "ส", "S_Sun_Initial": "อ", "M_Mon_Initial": "จ", "T_Tue_Initial": "อ", "W_Wed_Initial": "พ", "T_Thu_Initial": "พ", "F_Fri_Initial": "ศ", "S_Sat_Initial": "ส", "January": "มกราคม", "February": "กุมภาพันธ์", "March": "มีนาคม", "April": "เมษายน", "May": "พฤษภาคม", "June": "มิถุนายน", "July": "กรกฎาคม", "August": "สิงหาคม", "September": "กันยายน", "October": "ตุลาคม", "November": "พฤศจิกายน", "December": "ธันวาคม", "Jan_Abbr": "ม.ค.", "Feb_Abbr": "ก.พ.", "Mar_Abbr": "มี.ค.", "Apr_Abbr": "เม.ย.", "May_Abbr": "พ.ค.", "Jun_Abbr": "มิ.ย.", "Jul_Abbr": "ก.ค.", "Aug_Abbr": "ส.ค.", "Sep_Abbr": "ก.ย.", "Oct_Abbr": "ต.ค.", "Nov_Abbr": "พ.ย.", "Dec_Abbr": "ธ.ค.", "AM": "AM", "PM": "PM", "firstDayOfWeek": 1, "twoDigitYearMax": 2572, "mdy": "dmy", "M/d/yyyy": "d/M/yyyy", "dddd, MMMM dd, yyyy": "d MMMM yyyy", "h:mm tt": "H:mm", "h:mm:ss tt": "H:mm:ss", "dddd, MMMM dd, yyyy h:mm:ss tt": "d MMMM yyyy H:mm:ss", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "dd MMMM", "MMMM, yyyy": "MMMM yyyy", "/jan(uary)?/": "ม(.(กราค)?)?", "/feb(ruary)?/": "ก(.(ุมภาพันธ์)?)?", "/mar(ch)?/": "มี(.(นาคม)?)?", "/apr(il)?/": "เม(.(ษายน)?)?", "/may/": "พ(.(ฤษภาคม)?)?", "/jun(e)?/": "มิ(.(ถุนายน)?)?", "/jul(y)?/": "ก(.(รฎาคม)?)?", "/aug(ust)?/": "ส(.(ิงหาคม)?)?", "/sep(t(ember)?)?/": "ก(.(ันยายน)?)?", "/oct(ober)?/": "ต(.(ุลาคม)?)?", "/nov(ember)?/": "พ(.(ฤศจิกายน)?)?", "/dec(ember)?/": "ธ(.(ันวาคม)?)?", "/^su(n(day)?)?/": "^อ(า(.(ทิตย์)?)?)?", "/^mo(n(day)?)?/": "^จ((.(ันทร์)?)?)?", "/^tu(e(s(day)?)?)?/": "^อ((.(ังคาร)?)?)?", "/^we(d(nesday)?)?/": "^พ((.(ุธ)?)?)?", "/^th(u(r(s(day)?)?)?)?/": "^พ(ฤ(.(หัสบดี)?)?)?", "/^fr(i(day)?)?/": "^ศ((.(ุกร์)?)?)?", "/^sa(t(urday)?)?/": "^ส((.(สาร์)?)?)?", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "th-TH"; ================================================ FILE: build/production/i18n/tn-ZA.js ================================================ /* * DateJS Culture String File * Country Code: tn-ZA * Name: Tswana (South Africa) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["tn-ZA"] = { "name": "tn-ZA", "englishName": "Tswana (South Africa)", "nativeName": "Setswana (Aforika Borwa)", "Sunday": "Latshipi", "Monday": "Mosupologo", "Tuesday": "Labobedi", "Wednesday": "Laboraro", "Thursday": "Labone", "Friday": "Labotlhano", "Saturday": "Lamatlhatso", "Sun": "Sun", "Mon": "Mon", "Tue": "Tue", "Wed": "Wed", "Thu": "Thu", "Fri": "Fri", "Sat": "Sat", "Su": "Sun", "Mo": "Mon", "Tu": "Tue", "We": "Wed", "Th": "Thu", "Fr": "Fri", "Sa": "Sat", "S_Sun_Initial": "S", "M_Mon_Initial": "M", "T_Tue_Initial": "T", "W_Wed_Initial": "W", "T_Thu_Initial": "T", "F_Fri_Initial": "F", "S_Sat_Initial": "S", "January": "Ferikgong", "February": "Tlhakole", "March": "Mopitloe", "April": "Moranang", "May": "Motsheganong", "June": "Seetebosigo", "July": "Phukwi", "August": "Phatwe", "September": "Lwetse", "October": "Diphalane", "November": "Ngwanatsele", "December": "Sedimothole", "Jan_Abbr": "Jan", "Feb_Abbr": "Feb", "Mar_Abbr": "Mar", "Apr_Abbr": "Apr", "May_Abbr": "May", "Jun_Abbr": "Jun", "Jul_Abbr": "Jul", "Aug_Abbr": "Aug", "Sep_Abbr": "Sep", "Oct_Abbr": "Oct", "Nov_Abbr": "Nov", "Dec_Abbr": "Dec", "AM": "AM", "PM": "PM", "firstDayOfWeek": 0, "twoDigitYearMax": 2029, "mdy": "ymd", "M/d/yyyy": "yyyy/MM/dd", "dddd, MMMM dd, yyyy": "dd MMMM yyyy", "h:mm tt": "hh:mm:ss tt", "h:mm:ss tt": "hh:mm:ss tt", "dddd, MMMM dd, yyyy h:mm:ss tt": "dd MMMM yyyy hh:mm:ss tt", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "MMMM dd", "MMMM, yyyy": "MMMM yyyy", "/jan(uary)?/": "ferikgong", "/feb(ruary)?/": "tlhakole", "/mar(ch)?/": "mopitloe", "/apr(il)?/": "moranang", "/may/": "motsheganong", "/jun(e)?/": "seetebosigo", "/jul(y)?/": "phukwi", "/aug(ust)?/": "phatwe", "/sep(t(ember)?)?/": "lwetse", "/oct(ober)?/": "diphalane", "/nov(ember)?/": "ngwanatsele", "/dec(ember)?/": "sedimothole", "/^su(n(day)?)?/": "^latshipi", "/^mo(n(day)?)?/": "^mosupologo", "/^tu(e(s(day)?)?)?/": "^labobedi", "/^we(d(nesday)?)?/": "^laboraro", "/^th(u(r(s(day)?)?)?)?/": "^labone", "/^fr(i(day)?)?/": "^labotlhano", "/^sa(t(urday)?)?/": "^lamatlhatso", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "tn-ZA"; ================================================ FILE: build/production/i18n/tr-TR.js ================================================ /* * DateJS Culture String File * Country Code: tr-TR * Name: Turkish (Turkey) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["tr-TR"] = { "name": "tr-TR", "englishName": "Turkish (Turkey)", "nativeName": "Türkçe (Türkiye)", "Sunday": "Pazar", "Monday": "Pazartesi", "Tuesday": "Salı", "Wednesday": "Çarşamba", "Thursday": "Perşembe", "Friday": "Cuma", "Saturday": "Cumartesi", "Sun": "Paz", "Mon": "Pzt", "Tue": "Sal", "Wed": "Çar", "Thu": "Per", "Fri": "Cum", "Sat": "Cmt", "Su": "Pz", "Mo": "Pt", "Tu": "Sa", "We": "Ça", "Th": "Pe", "Fr": "Cu", "Sa": "Ct", "S_Sun_Initial": "P", "M_Mon_Initial": "P", "T_Tue_Initial": "S", "W_Wed_Initial": "Ç", "T_Thu_Initial": "P", "F_Fri_Initial": "C", "S_Sat_Initial": "C", "January": "Ocak", "February": "Şubat", "March": "Mart", "April": "Nisan", "May": "Mayıs", "June": "Haziran", "July": "Temmuz", "August": "Ağustos", "September": "Eylül", "October": "Ekim", "November": "Kasım", "December": "Aralık", "Jan_Abbr": "Oca", "Feb_Abbr": "Şub", "Mar_Abbr": "Mar", "Apr_Abbr": "Nis", "May_Abbr": "May", "Jun_Abbr": "Haz", "Jul_Abbr": "Tem", "Aug_Abbr": "Ağu", "Sep_Abbr": "Eyl", "Oct_Abbr": "Eki", "Nov_Abbr": "Kas", "Dec_Abbr": "Ara", "AM": "", "PM": "", "firstDayOfWeek": 1, "twoDigitYearMax": 2029, "mdy": "dmy", "M/d/yyyy": "dd.MM.yyyy", "dddd, MMMM dd, yyyy": "dd MMMM yyyy dddd", "h:mm tt": "HH:mm", "h:mm:ss tt": "HH:mm:ss", "dddd, MMMM dd, yyyy h:mm:ss tt": "dd MMMM yyyy dddd HH:mm:ss", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "dd MMMM", "MMMM, yyyy": "MMMM yyyy", "/jan(uary)?/": "oca(k)?", "/feb(ruary)?/": "şub(at)?", "/mar(ch)?/": "mar(t)?", "/apr(il)?/": "nis(an)?", "/may/": "may(ıs)?", "/jun(e)?/": "haz(iran)?", "/jul(y)?/": "tem(muz)?", "/aug(ust)?/": "ağu(stos)?", "/sep(t(ember)?)?/": "eyl(ül)?", "/oct(ober)?/": "eki(m)?", "/nov(ember)?/": "kas(ım)?", "/dec(ember)?/": "ara(lık)?", "/^su(n(day)?)?/": "^pz(z(ar)?)?", "/^mo(n(day)?)?/": "^pt(t(artesi)?)?", "/^tu(e(s(day)?)?)?/": "^sa(l(ı)?)?", "/^we(d(nesday)?)?/": "^ça(r(şamba)?)?", "/^th(u(r(s(day)?)?)?)?/": "^pe(r(şembe)?)?", "/^fr(i(day)?)?/": "^cu(m(a)?)?", "/^sa(t(urday)?)?/": "^ct(t(artesi)?)?", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "tr-TR"; ================================================ FILE: build/production/i18n/tt-RU.js ================================================ /* * DateJS Culture String File * Country Code: tt-RU * Name: Tatar (Russia) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["tt-RU"] = { "name": "tt-RU", "englishName": "Tatar (Russia)", "nativeName": "Татар (Россия)", "Sunday": "Якшәмбе", "Monday": "Дүшәмбе", "Tuesday": "Сишәмбе", "Wednesday": "Чәршәмбе", "Thursday": "Пәнҗешәмбе", "Friday": "Җомга", "Saturday": "Шимбә", "Sun": "Якш", "Mon": "Дүш", "Tue": "Сиш", "Wed": "Чәрш", "Thu": "Пәнҗ", "Fri": "Җом", "Sat": "Шим", "Su": "Якш", "Mo": "Дүш", "Tu": "Сиш", "We": "Чәрш", "Th": "Пәнҗ", "Fr": "Җом", "Sa": "Шим", "S_Sun_Initial": "Я", "M_Mon_Initial": "Д", "T_Tue_Initial": "С", "W_Wed_Initial": "Ч", "T_Thu_Initial": "П", "F_Fri_Initial": "Җ", "S_Sat_Initial": "Ш", "January": "Гыйнварь", "February": "Февраль", "March": "Март", "April": "Апрель", "May": "Май", "June": "Июнь", "July": "Июль", "August": "Август", "September": "Сентябрь", "October": "Октябрь", "November": "Ноябрь", "December": "Декабрь", "Jan_Abbr": "Гыйнв", "Feb_Abbr": "Фев", "Mar_Abbr": "Мар", "Apr_Abbr": "Апр", "May_Abbr": "Май", "Jun_Abbr": "Июн", "Jul_Abbr": "Июл", "Aug_Abbr": "Авг", "Sep_Abbr": "Сен", "Oct_Abbr": "Окт", "Nov_Abbr": "Ноя", "Dec_Abbr": "Дек", "AM": "", "PM": "", "firstDayOfWeek": 1, "twoDigitYearMax": 2029, "mdy": "dmy", "M/d/yyyy": "dd.MM.yyyy", "dddd, MMMM dd, yyyy": "d MMMM yyyy", "h:mm tt": "H:mm", "h:mm:ss tt": "H:mm:ss", "dddd, MMMM dd, yyyy h:mm:ss tt": "d MMMM yyyy H:mm:ss", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "d MMMM", "MMMM, yyyy": "MMMM yyyy", "/jan(uary)?/": "гыйнв(арь)?", "/feb(ruary)?/": "фев(раль)?", "/mar(ch)?/": "мар(т)?", "/apr(il)?/": "апр(ель)?", "/may/": "май", "/jun(e)?/": "июн(ь)?", "/jul(y)?/": "июл(ь)?", "/aug(ust)?/": "авг(уст)?", "/sep(t(ember)?)?/": "сен(тябрь)?", "/oct(ober)?/": "окт(ябрь)?", "/nov(ember)?/": "ноя(брь)?", "/dec(ember)?/": "дек(абрь)?", "/^su(n(day)?)?/": "^якшәмбе", "/^mo(n(day)?)?/": "^дүшәмбе", "/^tu(e(s(day)?)?)?/": "^сишәмбе", "/^we(d(nesday)?)?/": "^чәршәмбе", "/^th(u(r(s(day)?)?)?)?/": "^пәнҗешәмбе", "/^fr(i(day)?)?/": "^җомга", "/^sa(t(urday)?)?/": "^шимбә", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "tt-RU"; ================================================ FILE: build/production/i18n/uk-UA.js ================================================ /* * DateJS Culture String File * Country Code: uk-UA * Name: Ukrainian (Ukraine) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["uk-UA"] = { "name": "uk-UA", "englishName": "Ukrainian (Ukraine)", "nativeName": "україньска (Україна)", "Sunday": "неділя", "Monday": "понеділок", "Tuesday": "вівторок", "Wednesday": "середа", "Thursday": "четвер", "Friday": "п'ятниця", "Saturday": "субота", "Sun": "Нд", "Mon": "Пн", "Tue": "Вт", "Wed": "Ср", "Thu": "Чт", "Fri": "Пт", "Sat": "Сб", "Su": "Нд", "Mo": "Пн", "Tu": "Вт", "We": "Ср", "Th": "Чт", "Fr": "Пт", "Sa": "Сб", "S_Sun_Initial": "Н", "M_Mon_Initial": "П", "T_Tue_Initial": "В", "W_Wed_Initial": "С", "T_Thu_Initial": "Ч", "F_Fri_Initial": "П", "S_Sat_Initial": "С", "January": "Січень", "February": "Лютий", "March": "Березень", "April": "Квітень", "May": "Травень", "June": "Червень", "July": "Липень", "August": "Серпень", "September": "Вересень", "October": "Жовтень", "November": "Листопад", "December": "Грудень", "Jan_Abbr": "Січ", "Feb_Abbr": "Лют", "Mar_Abbr": "Бер", "Apr_Abbr": "Кві", "May_Abbr": "Тра", "Jun_Abbr": "Чер", "Jul_Abbr": "Лип", "Aug_Abbr": "Сер", "Sep_Abbr": "Вер", "Oct_Abbr": "Жов", "Nov_Abbr": "Лис", "Dec_Abbr": "Гру", "AM": "", "PM": "", "firstDayOfWeek": 1, "twoDigitYearMax": 2029, "mdy": "dmy", "M/d/yyyy": "dd.MM.yyyy", "dddd, MMMM dd, yyyy": "d MMMM yyyy' р.'", "h:mm tt": "H:mm", "h:mm:ss tt": "H:mm:ss", "dddd, MMMM dd, yyyy h:mm:ss tt": "d MMMM yyyy' р.' H:mm:ss", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "d MMMM", "MMMM, yyyy": "MMMM yyyy' р.'", "/jan(uary)?/": "січ(ень)?", "/feb(ruary)?/": "лют(ий)?", "/mar(ch)?/": "бер(езень)?", "/apr(il)?/": "кві(тень)?", "/may/": "тра(вень)?", "/jun(e)?/": "чер(вень)?", "/jul(y)?/": "лип(ень)?", "/aug(ust)?/": "сер(пень)?", "/sep(t(ember)?)?/": "вер(есень)?", "/oct(ober)?/": "жов(тень)?", "/nov(ember)?/": "лис(топад)?", "/dec(ember)?/": "гру(день)?", "/^su(n(day)?)?/": "^неділя", "/^mo(n(day)?)?/": "^понеділок", "/^tu(e(s(day)?)?)?/": "^вівторок", "/^we(d(nesday)?)?/": "^середа", "/^th(u(r(s(day)?)?)?)?/": "^четвер", "/^fr(i(day)?)?/": "^п'ятниця", "/^sa(t(urday)?)?/": "^субота", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "uk-UA"; ================================================ FILE: build/production/i18n/ur-PK.js ================================================ /* * DateJS Culture String File * Country Code: ur-PK * Name: Urdu (Islamic Republic of Pakistan) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["ur-PK"] = { "name": "ur-PK", "englishName": "Urdu (Islamic Republic of Pakistan)", "nativeName": "اُردو (پاکستان)", "Sunday": "اتوار", "Monday": "پير", "Tuesday": "منگل", "Wednesday": "بدھ", "Thursday": "جمعرات", "Friday": "جمعه", "Saturday": "هفته", "Sun": "اتوار", "Mon": "پير", "Tue": "منگل", "Wed": "بدھ", "Thu": "جمعرات", "Fri": "جمعه", "Sat": "هفته", "Su": "ا", "Mo": "پ", "Tu": "م", "We": "ب", "Th": "ج", "Fr": "ج", "Sa": "ه", "S_Sun_Initial": "ا", "M_Mon_Initial": "پ", "T_Tue_Initial": "م", "W_Wed_Initial": "ب", "T_Thu_Initial": "ج", "F_Fri_Initial": "ج", "S_Sat_Initial": "ه", "January": "جنورى", "February": "فرورى", "March": "مارچ", "April": "اپريل", "May": "مئ", "June": "جون", "July": "جولاٸ", "August": "اگست", "September": "ستمبر", "October": "اکتوبر", "November": "نومبر", "December": "دسمبر", "Jan_Abbr": "جنورى", "Feb_Abbr": "فرورى", "Mar_Abbr": "مارچ", "Apr_Abbr": "اپريل", "May_Abbr": "مئ", "Jun_Abbr": "جون", "Jul_Abbr": "جولاٸ", "Aug_Abbr": "اگست", "Sep_Abbr": "ستمبر", "Oct_Abbr": "اکتوبر", "Nov_Abbr": "نومبر", "Dec_Abbr": "دسمبر", "AM": "AM", "PM": "PM", "firstDayOfWeek": 1, "twoDigitYearMax": 2029, "mdy": "dmy", "M/d/yyyy": "dd/MM/yyyy", "dddd, MMMM dd, yyyy": "dd MMMM, yyyy", "h:mm tt": "h:mm tt", "h:mm:ss tt": "h:mm:ss tt", "dddd, MMMM dd, yyyy h:mm:ss tt": "dd MMMM, yyyy h:mm:ss tt", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "dd MMMM", "MMMM, yyyy": "MMMM, yyyy", "/jan(uary)?/": "جنورى", "/feb(ruary)?/": "فرورى", "/mar(ch)?/": "مارچ", "/apr(il)?/": "اپريل", "/may/": "مئ", "/jun(e)?/": "جون", "/jul(y)?/": "جولاٸ", "/aug(ust)?/": "اگست", "/sep(t(ember)?)?/": "ستمبر", "/oct(ober)?/": "اکتوبر", "/nov(ember)?/": "نومبر", "/dec(ember)?/": "دسمبر", "/^su(n(day)?)?/": "^ا(1)?", "/^mo(n(day)?)?/": "^پ(1)?", "/^tu(e(s(day)?)?)?/": "^م(1)?", "/^we(d(nesday)?)?/": "^ب(1)?", "/^th(u(r(s(day)?)?)?)?/": "^ج(1)?", "/^fr(i(day)?)?/": "^ج(1)?", "/^sa(t(urday)?)?/": "^ه(1)?", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "ur-PK"; ================================================ FILE: build/production/i18n/uz-Cyrl-UZ.js ================================================ /* * DateJS Culture String File * Country Code: uz-Cyrl-UZ * Name: Uzbek (Cyrillic, Uzbekistan) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["uz-Cyrl-UZ"] = { "name": "uz-Cyrl-UZ", "englishName": "Uzbek (Cyrillic, Uzbekistan)", "nativeName": "Ўзбек (Ўзбекистон)", "Sunday": "якшанба", "Monday": "душанба", "Tuesday": "сешанба", "Wednesday": "чоршанба", "Thursday": "пайшанба", "Friday": "жума", "Saturday": "шанба", "Sun": "якш", "Mon": "дш", "Tue": "сш", "Wed": "чш", "Thu": "пш", "Fri": "ж", "Sat": "ш", "Su": "якш", "Mo": "дш", "Tu": "сш", "We": "чш", "Th": "пш", "Fr": "ж", "Sa": "ш", "S_Sun_Initial": "я", "M_Mon_Initial": "д", "T_Tue_Initial": "с", "W_Wed_Initial": "ч", "T_Thu_Initial": "п", "F_Fri_Initial": "ж", "S_Sat_Initial": "ш", "January": "Январ", "February": "Феврал", "March": "Март", "April": "Апрел", "May": "Май", "June": "Июн", "July": "Июл", "August": "Август", "September": "Сентябр", "October": "Октябр", "November": "Ноябр", "December": "Декабр", "Jan_Abbr": "Янв", "Feb_Abbr": "Фев", "Mar_Abbr": "Мар", "Apr_Abbr": "Апр", "May_Abbr": "Май", "Jun_Abbr": "Июн", "Jul_Abbr": "Июл", "Aug_Abbr": "Авг", "Sep_Abbr": "Сен", "Oct_Abbr": "Окт", "Nov_Abbr": "Ноя", "Dec_Abbr": "Дек", "AM": "", "PM": "", "firstDayOfWeek": 1, "twoDigitYearMax": 2029, "mdy": "dmy", "M/d/yyyy": "dd.MM.yyyy", "dddd, MMMM dd, yyyy": "yyyy 'йил' d-MMMM", "h:mm tt": "HH:mm", "h:mm:ss tt": "HH:mm:ss", "dddd, MMMM dd, yyyy h:mm:ss tt": "yyyy 'йил' d-MMMM HH:mm:ss", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "d-MMMM", "MMMM, yyyy": "MMMM yyyy", "/jan(uary)?/": "янв(ар)?", "/feb(ruary)?/": "фев(рал)?", "/mar(ch)?/": "мар(т)?", "/apr(il)?/": "апр(ел)?", "/may/": "май", "/jun(e)?/": "июн", "/jul(y)?/": "июл", "/aug(ust)?/": "авг(уст)?", "/sep(t(ember)?)?/": "сен(тябр)?", "/oct(ober)?/": "окт(ябр)?", "/nov(ember)?/": "ноя(бр)?", "/dec(ember)?/": "дек(абр)?", "/^su(n(day)?)?/": "^якшанба", "/^mo(n(day)?)?/": "^душанба", "/^tu(e(s(day)?)?)?/": "^сешанба", "/^we(d(nesday)?)?/": "^чоршанба", "/^th(u(r(s(day)?)?)?)?/": "^пайшанба", "/^fr(i(day)?)?/": "^жума", "/^sa(t(urday)?)?/": "^шанба", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "uz-Cyrl-UZ"; ================================================ FILE: build/production/i18n/uz-Latn-UZ.js ================================================ /* * DateJS Culture String File * Country Code: uz-Latn-UZ * Name: Uzbek (Latin, Uzbekistan) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["uz-Latn-UZ"] = { "name": "uz-Latn-UZ", "englishName": "Uzbek (Latin, Uzbekistan)", "nativeName": "U'zbek (U'zbekiston Respublikasi)", "Sunday": "yakshanba", "Monday": "dushanba", "Tuesday": "seshanba", "Wednesday": "chorshanba", "Thursday": "payshanba", "Friday": "juma", "Saturday": "shanba", "Sun": "yak.", "Mon": "dsh.", "Tue": "sesh.", "Wed": "chr.", "Thu": "psh.", "Fri": "jm.", "Sat": "sh.", "Su": "yak", "Mo": "dsh", "Tu": "sesh", "We": "chr", "Th": "psh", "Fr": "jm", "Sa": "sh", "S_Sun_Initial": "y", "M_Mon_Initial": "d", "T_Tue_Initial": "s", "W_Wed_Initial": "c", "T_Thu_Initial": "p", "F_Fri_Initial": "j", "S_Sat_Initial": "s", "January": "yanvar", "February": "fevral", "March": "mart", "April": "aprel", "May": "may", "June": "iyun", "July": "iyul", "August": "avgust", "September": "sentyabr", "October": "oktyabr", "November": "noyabr", "December": "dekabr", "Jan_Abbr": "yanvar", "Feb_Abbr": "fevral", "Mar_Abbr": "mart", "Apr_Abbr": "aprel", "May_Abbr": "may", "Jun_Abbr": "iyun", "Jul_Abbr": "iyul", "Aug_Abbr": "avgust", "Sep_Abbr": "sentyabr", "Oct_Abbr": "oktyabr", "Nov_Abbr": "noyabr", "Dec_Abbr": "dekabr", "AM": "", "PM": "", "firstDayOfWeek": 1, "twoDigitYearMax": 2029, "mdy": "dmy", "M/d/yyyy": "dd/MM yyyy", "dddd, MMMM dd, yyyy": "yyyy 'yil' d-MMMM", "h:mm tt": "HH:mm", "h:mm:ss tt": "HH:mm:ss", "dddd, MMMM dd, yyyy h:mm:ss tt": "yyyy 'yil' d-MMMM HH:mm:ss", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "d-MMMM", "MMMM, yyyy": "MMMM yyyy", "/jan(uary)?/": "yanvar", "/feb(ruary)?/": "fevral", "/mar(ch)?/": "mart", "/apr(il)?/": "aprel", "/may/": "may", "/jun(e)?/": "iyun", "/jul(y)?/": "iyul", "/aug(ust)?/": "avgust", "/sep(t(ember)?)?/": "sentyabr", "/oct(ober)?/": "oktyabr", "/nov(ember)?/": "noyabr", "/dec(ember)?/": "dekabr", "/^su(n(day)?)?/": "^yak((.(shanba)?)?)?", "/^mo(n(day)?)?/": "^dsh((.(hanba)?)?)?", "/^tu(e(s(day)?)?)?/": "^sesh((.(anba)?)?)?", "/^we(d(nesday)?)?/": "^chr((.(rshanba)?)?)?", "/^th(u(r(s(day)?)?)?)?/": "^psh((.(shanba)?)?)?", "/^fr(i(day)?)?/": "^jm((.(ma)?)?)?", "/^sa(t(urday)?)?/": "^sh((.(anba)?)?)?", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "uz-Latn-UZ"; ================================================ FILE: build/production/i18n/vi-VN.js ================================================ /* * DateJS Culture String File * Country Code: vi-VN * Name: Vietnamese (Vietnam) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["vi-VN"] = { "name": "vi-VN", "englishName": "Vietnamese (Vietnam)", "nativeName": "Tiếng Việt (Việt Nam)", "Sunday": "Chủ Nhật", "Monday": "Thứ Hai", "Tuesday": "Thứ Ba", "Wednesday": "Thứ Tư", "Thursday": "Thứ Năm", "Friday": "Thứ Sáu", "Saturday": "Thứ Bảy", "Sun": "CN", "Mon": "Hai", "Tue": "Ba", "Wed": "Tư", "Thu": "Năm", "Fri": "Sáu", "Sat": "Bảy", "Su": "C", "Mo": "H", "Tu": "B", "We": "T", "Th": "N", "Fr": "S", "Sa": "B", "S_Sun_Initial": "C", "M_Mon_Initial": "H", "T_Tue_Initial": "B", "W_Wed_Initial": "T", "T_Thu_Initial": "N", "F_Fri_Initial": "S", "S_Sat_Initial": "B", "January": "Tháng Giêng", "February": "Tháng Hai", "March": "Tháng Ba", "April": "Tháng Tư", "May": "Tháng Năm", "June": "Tháng Sáu", "July": "Tháng Bảy", "August": "Tháng Tám", "September": "Tháng Chín", "October": "Tháng Mười", "November": "Tháng Mười Một", "December": "Tháng Mười Hai", "Jan_Abbr": "Thg1", "Feb_Abbr": "Thg2", "Mar_Abbr": "Thg3", "Apr_Abbr": "Thg4", "May_Abbr": "Thg5", "Jun_Abbr": "Thg6", "Jul_Abbr": "Thg7", "Aug_Abbr": "Thg8", "Sep_Abbr": "Thg9", "Oct_Abbr": "Thg10", "Nov_Abbr": "Thg11", "Dec_Abbr": "Thg12", "AM": "SA", "PM": "CH", "firstDayOfWeek": 1, "twoDigitYearMax": 2029, "mdy": "dmy", "M/d/yyyy": "dd/MM/yyyy", "dddd, MMMM dd, yyyy": "dd MMMM yyyy", "h:mm tt": "h:mm tt", "h:mm:ss tt": "h:mm:ss tt", "dddd, MMMM dd, yyyy h:mm:ss tt": "dd MMMM yyyy h:mm:ss tt", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "dd MMMM", "MMMM, yyyy": "MMMM yyyy", "/jan(uary)?/": "tháng giêng", "/feb(ruary)?/": "tháng hai", "/mar(ch)?/": "tháng ba", "/apr(il)?/": "tháng tư", "/may/": "tháng năm", "/jun(e)?/": "tháng sáu", "/jul(y)?/": "tháng bảy", "/aug(ust)?/": "tháng tám", "/sep(t(ember)?)?/": "tháng chín", "/oct(ober)?/": "tháng mười", "/nov(ember)?/": "tháng mười một", "/dec(ember)?/": "tháng mười hai", "/^su(n(day)?)?/": "^c(n(ủ nhật)?)?", "/^mo(n(day)?)?/": "^h(ai(́ hai)?)?", "/^tu(e(s(day)?)?)?/": "^b(a(ứ ba)?)?", "/^we(d(nesday)?)?/": "^t(ư(ứ tư)?)?", "/^th(u(r(s(day)?)?)?)?/": "^n(ăm(́ năm)?)?", "/^fr(i(day)?)?/": "^s(áu( sáu)?)?", "/^sa(t(urday)?)?/": "^b(ảy( bảy)?)?", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "vi-VN"; ================================================ FILE: build/production/i18n/xh-ZA.js ================================================ /* * DateJS Culture String File * Country Code: xh-ZA * Name: Xhosa (South Africa) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["xh-ZA"] = { "name": "xh-ZA", "englishName": "Xhosa (South Africa)", "nativeName": "isiXhosa (uMzantsi Afrika)", "Sunday": "iCawa", "Monday": "uMvulo", "Tuesday": "uLwesibini", "Wednesday": "uLwesithathu", "Thursday": "uLwesine", "Friday": "uLwesihlanu", "Saturday": "uMgqibelo", "Sun": "Sun", "Mon": "Mon", "Tue": "Tue", "Wed": "Wed", "Thu": "Thu", "Fri": "Fri", "Sat": "Sat", "Su": "Sun", "Mo": "Mon", "Tu": "Tue", "We": "Wed", "Th": "Thu", "Fr": "Fri", "Sa": "Sat", "S_Sun_Initial": "S", "M_Mon_Initial": "M", "T_Tue_Initial": "T", "W_Wed_Initial": "W", "T_Thu_Initial": "T", "F_Fri_Initial": "F", "S_Sat_Initial": "S", "January": "eyoMqungu", "February": "eyoMdumba", "March": "eyoKwindla", "April": "Tshazimpuzi", "May": "Canzibe", "June": "eyeSilimela", "July": "eyeKhala", "August": "eyeThupha", "September": "eyoMsintsi", "October": "eyeDwara", "November": "eyeNkanga", "December": "eyoMnga", "Jan_Abbr": "Jan", "Feb_Abbr": "Feb", "Mar_Abbr": "Mar", "Apr_Abbr": "Apr", "May_Abbr": "May", "Jun_Abbr": "Jun", "Jul_Abbr": "Jul", "Aug_Abbr": "Aug", "Sep_Abbr": "Sep", "Oct_Abbr": "Oct", "Nov_Abbr": "Nov", "Dec_Abbr": "Dec", "AM": "AM", "PM": "PM", "firstDayOfWeek": 0, "twoDigitYearMax": 2029, "mdy": "ymd", "M/d/yyyy": "yyyy/MM/dd", "dddd, MMMM dd, yyyy": "dd MMMM yyyy", "h:mm tt": "hh:mm:ss tt", "h:mm:ss tt": "hh:mm:ss tt", "dddd, MMMM dd, yyyy h:mm:ss tt": "dd MMMM yyyy hh:mm:ss tt", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "MMMM dd", "MMMM, yyyy": "MMMM yyyy", "/jan(uary)?/": "eyomqungu", "/feb(ruary)?/": "eyomdumba", "/mar(ch)?/": "eyokwindla", "/apr(il)?/": "tshazimpuzi", "/may/": "canzibe", "/jun(e)?/": "eyesilimela", "/jul(y)?/": "eyekhala", "/aug(ust)?/": "eyethupha", "/sep(t(ember)?)?/": "eyomsintsi", "/oct(ober)?/": "eyedwara", "/nov(ember)?/": "eyenkanga", "/dec(ember)?/": "eyomnga", "/^su(n(day)?)?/": "^icawa", "/^mo(n(day)?)?/": "^umvulo", "/^tu(e(s(day)?)?)?/": "^ulwesibini", "/^we(d(nesday)?)?/": "^ulwesithathu", "/^th(u(r(s(day)?)?)?)?/": "^ulwesine", "/^fr(i(day)?)?/": "^ulwesihlanu", "/^sa(t(urday)?)?/": "^umgqibelo", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "xh-ZA"; ================================================ FILE: build/production/i18n/zh-CN.js ================================================ /* * DateJS Culture String File * Country Code: zh-CN * Name: Chinese (People's Republic of China) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["zh-CN"] = { "name": "zh-CN", "englishName": "Chinese (People's Republic of China)", "nativeName": "中文(中华人民共和国)", "Sunday": "星期日", "Monday": "星期一", "Tuesday": "星期二", "Wednesday": "星期三", "Thursday": "星期四", "Friday": "星期五", "Saturday": "星期六", "Sun": "日", "Mon": "一", "Tue": "二", "Wed": "三", "Thu": "四", "Fri": "五", "Sat": "六", "Su": "日", "Mo": "一", "Tu": "二", "We": "三", "Th": "四", "Fr": "五", "Sa": "六", "S_Sun_Initial": "日", "M_Mon_Initial": "一", "T_Tue_Initial": "二", "W_Wed_Initial": "三", "T_Thu_Initial": "四", "F_Fri_Initial": "五", "S_Sat_Initial": "六", "January": "一月", "February": "二月", "March": "三月", "April": "四月", "May": "五月", "June": "六月", "July": "七月", "August": "八月", "September": "九月", "October": "十月", "November": "十一月", "December": "十二月", "Jan_Abbr": "一月", "Feb_Abbr": "二月", "Mar_Abbr": "三月", "Apr_Abbr": "四月", "May_Abbr": "五月", "Jun_Abbr": "六月", "Jul_Abbr": "七月", "Aug_Abbr": "八月", "Sep_Abbr": "九月", "Oct_Abbr": "十月", "Nov_Abbr": "十一月", "Dec_Abbr": "十二月", "AM": "上午", "PM": "下午", "firstDayOfWeek": 0, "twoDigitYearMax": 2029, "mdy": "ymd", "M/d/yyyy": "yyyy/M/d", "dddd, MMMM dd, yyyy": "yyyy'年'M'月'd'日'", "h:mm tt": "H:mm", "h:mm:ss tt": "H:mm:ss", "dddd, MMMM dd, yyyy h:mm:ss tt": "yyyy'年'M'月'd'日' H:mm:ss", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "M'月'd'日'", "MMMM, yyyy": "yyyy'年'M'月'", "/jan(uary)?/": "一月", "/feb(ruary)?/": "二月", "/mar(ch)?/": "三月", "/apr(il)?/": "四月", "/may/": "五月", "/jun(e)?/": "六月", "/jul(y)?/": "七月", "/aug(ust)?/": "八月", "/sep(t(ember)?)?/": "九月", "/oct(ober)?/": "十月", "/nov(ember)?/": "十一月", "/dec(ember)?/": "十二月", "/^su(n(day)?)?/": "^星期日", "/^mo(n(day)?)?/": "^星期一", "/^tu(e(s(day)?)?)?/": "^星期二", "/^we(d(nesday)?)?/": "^星期三", "/^th(u(r(s(day)?)?)?)?/": "^星期四", "/^fr(i(day)?)?/": "^星期五", "/^sa(t(urday)?)?/": "^星期六", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "zh-CN"; ================================================ FILE: build/production/i18n/zh-HK.js ================================================ /* * DateJS Culture String File * Country Code: zh-HK * Name: Chinese (Hong Kong S.A.R.) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["zh-HK"] = { "name": "zh-HK", "englishName": "Chinese (Hong Kong S.A.R.)", "nativeName": "中文(香港特别行政區)", "Sunday": "Sunday", "Monday": "Monday", "Tuesday": "Tuesday", "Wednesday": "Wednesday", "Thursday": "Thursday", "Friday": "Friday", "Saturday": "Saturday", "Sun": "Sun", "Mon": "Mon", "Tue": "Tue", "Wed": "Wed", "Thu": "Thu", "Fri": "Fri", "Sat": "Sat", "Su": "Su", "Mo": "Mo", "Tu": "Tu", "We": "We", "Th": "Th", "Fr": "Fr", "Sa": "Sa", "S_Sun_Initial": "S", "M_Mon_Initial": "M", "T_Tue_Initial": "T", "W_Wed_Initial": "W", "T_Thu_Initial": "T", "F_Fri_Initial": "F", "S_Sat_Initial": "S", "January": "January", "February": "February", "March": "March", "April": "April", "May": "May", "June": "June", "July": "July", "August": "August", "September": "September", "October": "October", "November": "November", "December": "December", "Jan_Abbr": "Jan", "Feb_Abbr": "Feb", "Mar_Abbr": "Mar", "Apr_Abbr": "Apr", "May_Abbr": "May", "Jun_Abbr": "Jun", "Jul_Abbr": "Jul", "Aug_Abbr": "Aug", "Sep_Abbr": "Sep", "Oct_Abbr": "Oct", "Nov_Abbr": "Nov", "Dec_Abbr": "Dec", "AM": "", "PM": "", "firstDayOfWeek": 0, "twoDigitYearMax": 2029, "mdy": "dmy", "M/d/yyyy": "d/M/yyyy", "dddd, MMMM dd, yyyy": "dddd, d MMMM, yyyy", "h:mm tt": "H:mm", "h:mm:ss tt": "H:mm:ss", "dddd, MMMM dd, yyyy h:mm:ss tt": "dddd, d MMMM, yyyy H:mm:ss", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "d MMMM", "MMMM, yyyy": "MMMM, yyyy", "/jan(uary)?/": "jan(uary)?", "/feb(ruary)?/": "feb(ruary)?", "/mar(ch)?/": "mar(ch)?", "/apr(il)?/": "apr(il)?", "/may/": "may", "/jun(e)?/": "jun(e)?", "/jul(y)?/": "jul(y)?", "/aug(ust)?/": "aug(ust)?", "/sep(t(ember)?)?/": "sep(t(ember)?)?", "/oct(ober)?/": "oct(ober)?", "/nov(ember)?/": "nov(ember)?", "/dec(ember)?/": "dec(ember)?", "/^su(n(day)?)?/": "^su(n(day)?)?", "/^mo(n(day)?)?/": "^mo(n(day)?)?", "/^tu(e(s(day)?)?)?/": "^tu(e(s(day)?)?)?", "/^we(d(nesday)?)?/": "^we(d(nesday)?)?", "/^th(u(r(s(day)?)?)?)?/": "^th(u(r(s(day)?)?)?)?", "/^fr(i(day)?)?/": "^fr(i(day)?)?", "/^sa(t(urday)?)?/": "^sa(t(urday)?)?", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "zh-HK"; ================================================ FILE: build/production/i18n/zh-MO.js ================================================ /* * DateJS Culture String File * Country Code: zh-MO * Name: Chinese (Macao S.A.R.) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["zh-MO"] = { "name": "zh-MO", "englishName": "Chinese (Macao S.A.R.)", "nativeName": "中文(澳門特别行政區)", "Sunday": "星期日", "Monday": "星期一", "Tuesday": "星期二", "Wednesday": "星期三", "Thursday": "星期四", "Friday": "星期五", "Saturday": "星期六", "Sun": "星期日", "Mon": "星期一", "Tue": "星期二", "Wed": "星期三", "Thu": "星期四", "Fri": "星期五", "Sat": "星期六", "Su": "日", "Mo": "一", "Tu": "二", "We": "三", "Th": "四", "Fr": "五", "Sa": "六", "S_Sun_Initial": "日", "M_Mon_Initial": "一", "T_Tue_Initial": "二", "W_Wed_Initial": "三", "T_Thu_Initial": "四", "F_Fri_Initial": "五", "S_Sat_Initial": "六", "January": "一月", "February": "二月", "March": "三月", "April": "四月", "May": "五月", "June": "六月", "July": "七月", "August": "八月", "September": "九月", "October": "十月", "November": "十一月", "December": "十二月", "Jan_Abbr": "一月", "Feb_Abbr": "二月", "Mar_Abbr": "三月", "Apr_Abbr": "四月", "May_Abbr": "五月", "Jun_Abbr": "六月", "Jul_Abbr": "七月", "Aug_Abbr": "八月", "Sep_Abbr": "九月", "Oct_Abbr": "十月", "Nov_Abbr": "十一月", "Dec_Abbr": "十二月", "AM": "", "PM": "", "firstDayOfWeek": 0, "twoDigitYearMax": 2029, "mdy": "dmy", "M/d/yyyy": "d/M/yyyy", "dddd, MMMM dd, yyyy": "dddd, d MMMM, yyyy", "h:mm tt": "H:mm", "h:mm:ss tt": "H:mm:ss", "dddd, MMMM dd, yyyy h:mm:ss tt": "dddd, d MMMM, yyyy H:mm:ss", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "d MMMM", "MMMM, yyyy": "MMMM, yyyy", "/jan(uary)?/": "一月", "/feb(ruary)?/": "二月", "/mar(ch)?/": "三月", "/apr(il)?/": "四月", "/may/": "五月", "/jun(e)?/": "六月", "/jul(y)?/": "七月", "/aug(ust)?/": "八月", "/sep(t(ember)?)?/": "九月", "/oct(ober)?/": "十月", "/nov(ember)?/": "十一月", "/dec(ember)?/": "十二月", "/^su(n(day)?)?/": "^星期日", "/^mo(n(day)?)?/": "^星期一", "/^tu(e(s(day)?)?)?/": "^星期二", "/^we(d(nesday)?)?/": "^星期三", "/^th(u(r(s(day)?)?)?)?/": "^星期四", "/^fr(i(day)?)?/": "^星期五", "/^sa(t(urday)?)?/": "^星期六", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "zh-MO"; ================================================ FILE: build/production/i18n/zh-SG.js ================================================ /* * DateJS Culture String File * Country Code: zh-SG * Name: Chinese (Singapore) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["zh-SG"] = { "name": "zh-SG", "englishName": "Chinese (Singapore)", "nativeName": "中文(新加坡)", "Sunday": "星期日", "Monday": "星期一", "Tuesday": "星期二", "Wednesday": "星期三", "Thursday": "星期四", "Friday": "星期五", "Saturday": "星期六", "Sun": "星期日", "Mon": "星期一", "Tue": "星期二", "Wed": "星期三", "Thu": "星期四", "Fri": "星期五", "Sat": "星期六", "Su": "日", "Mo": "一", "Tu": "二", "We": "三", "Th": "四", "Fr": "五", "Sa": "六", "S_Sun_Initial": "日", "M_Mon_Initial": "一", "T_Tue_Initial": "二", "W_Wed_Initial": "三", "T_Thu_Initial": "四", "F_Fri_Initial": "五", "S_Sat_Initial": "六", "January": "一月", "February": "二月", "March": "三月", "April": "四月", "May": "五月", "June": "六月", "July": "七月", "August": "八月", "September": "九月", "October": "十月", "November": "十一月", "December": "十二月", "Jan_Abbr": "一月", "Feb_Abbr": "二月", "Mar_Abbr": "三月", "Apr_Abbr": "四月", "May_Abbr": "五月", "Jun_Abbr": "六月", "Jul_Abbr": "七月", "Aug_Abbr": "八月", "Sep_Abbr": "九月", "Oct_Abbr": "十月", "Nov_Abbr": "十一月", "Dec_Abbr": "十二月", "AM": "AM", "PM": "PM", "firstDayOfWeek": 0, "twoDigitYearMax": 2029, "mdy": "dmy", "M/d/yyyy": "d/M/yyyy", "dddd, MMMM dd, yyyy": "dddd, d MMMM, yyyy", "h:mm tt": "tt h:mm", "h:mm:ss tt": "tt h:mm:ss", "dddd, MMMM dd, yyyy h:mm:ss tt": "dddd, d MMMM, yyyy tt h:mm:ss", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "d MMMM", "MMMM, yyyy": "MMMM, yyyy", "/jan(uary)?/": "一月", "/feb(ruary)?/": "二月", "/mar(ch)?/": "三月", "/apr(il)?/": "四月", "/may/": "五月", "/jun(e)?/": "六月", "/jul(y)?/": "七月", "/aug(ust)?/": "八月", "/sep(t(ember)?)?/": "九月", "/oct(ober)?/": "十月", "/nov(ember)?/": "十一月", "/dec(ember)?/": "十二月", "/^su(n(day)?)?/": "^星期日", "/^mo(n(day)?)?/": "^星期一", "/^tu(e(s(day)?)?)?/": "^星期二", "/^we(d(nesday)?)?/": "^星期三", "/^th(u(r(s(day)?)?)?)?/": "^星期四", "/^fr(i(day)?)?/": "^星期五", "/^sa(t(urday)?)?/": "^星期六", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "zh-SG"; ================================================ FILE: build/production/i18n/zh-TW.js ================================================ /* * DateJS Culture String File * Country Code: zh-TW * Name: Chinese (Taiwan) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["zh-TW"] = { "name": "zh-TW", "englishName": "Chinese (Taiwan)", "nativeName": "中文(台灣)", "Sunday": "星期日", "Monday": "星期一", "Tuesday": "星期二", "Wednesday": "星期三", "Thursday": "星期四", "Friday": "星期五", "Saturday": "星期六", "Sun": "星期日", "Mon": "星期一", "Tue": "星期二", "Wed": "星期三", "Thu": "星期四", "Fri": "星期五", "Sat": "星期六", "Su": "日", "Mo": "一", "Tu": "二", "We": "三", "Th": "四", "Fr": "五", "Sa": "六", "S_Sun_Initial": "日", "M_Mon_Initial": "一", "T_Tue_Initial": "二", "W_Wed_Initial": "三", "T_Thu_Initial": "四", "F_Fri_Initial": "五", "S_Sat_Initial": "六", "January": "一月", "February": "二月", "March": "三月", "April": "四月", "May": "五月", "June": "六月", "July": "七月", "August": "八月", "September": "九月", "October": "十月", "November": "十一月", "December": "十二月", "Jan_Abbr": "一月", "Feb_Abbr": "二月", "Mar_Abbr": "三月", "Apr_Abbr": "四月", "May_Abbr": "五月", "Jun_Abbr": "六月", "Jul_Abbr": "七月", "Aug_Abbr": "八月", "Sep_Abbr": "九月", "Oct_Abbr": "十月", "Nov_Abbr": "十一月", "Dec_Abbr": "十二月", "AM": "上午", "PM": "下午", "firstDayOfWeek": 0, "twoDigitYearMax": 2029, "mdy": "ymd", "M/d/yyyy": "yyyy/M/d", "dddd, MMMM dd, yyyy": "yyyy'年'M'月'd'日'", "h:mm tt": "tt hh:mm", "h:mm:ss tt": "tt hh:mm:ss", "dddd, MMMM dd, yyyy h:mm:ss tt": "yyyy'年'M'月'd'日' tt hh:mm:ss", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "M'月'd'日'", "MMMM, yyyy": "yyyy'年'M'月'", "/jan(uary)?/": "一月", "/feb(ruary)?/": "二月", "/mar(ch)?/": "三月", "/apr(il)?/": "四月", "/may/": "五月", "/jun(e)?/": "六月", "/jul(y)?/": "七月", "/aug(ust)?/": "八月", "/sep(t(ember)?)?/": "九月", "/oct(ober)?/": "十月", "/nov(ember)?/": "十一月", "/dec(ember)?/": "十二月", "/^su(n(day)?)?/": "^星期日", "/^mo(n(day)?)?/": "^星期一", "/^tu(e(s(day)?)?)?/": "^星期二", "/^we(d(nesday)?)?/": "^星期三", "/^th(u(r(s(day)?)?)?)?/": "^星期四", "/^fr(i(day)?)?/": "^星期五", "/^sa(t(urday)?)?/": "^星期六", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "zh-TW"; ================================================ FILE: build/production/i18n/zu-ZA.js ================================================ /* * DateJS Culture String File * Country Code: zu-ZA * Name: Zulu (South Africa) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["zu-ZA"] = { "name": "zu-ZA", "englishName": "Zulu (South Africa)", "nativeName": "isiZulu (iNingizimu Afrika)", "Sunday": "iSonto", "Monday": "uMsombuluko", "Tuesday": "uLwesibili", "Wednesday": "uLwesithathu", "Thursday": "uLwesine", "Friday": "uLwesihlanu", "Saturday": "uMgqibelo", "Sun": "Sun", "Mon": "Mon", "Tue": "Tue", "Wed": "Wed", "Thu": "Thu", "Fri": "Fri", "Sat": "Sat", "Su": "Sun", "Mo": "Mon", "Tu": "Tue", "We": "Wed", "Th": "Thu", "Fr": "Fri", "Sa": "Sat", "S_Sun_Initial": "S", "M_Mon_Initial": "M", "T_Tue_Initial": "T", "W_Wed_Initial": "W", "T_Thu_Initial": "T", "F_Fri_Initial": "F", "S_Sat_Initial": "S", "January": "uJanuwari", "February": "uFebuwari", "March": "uMashi", "April": "uAprhili", "May": "uMeyi", "June": "uJuni", "July": "uJulayi", "August": "uAgaste", "September": "uSepthemba", "October": "uOkthoba", "November": "uNovemba", "December": "uDisemba", "Jan_Abbr": "Jan", "Feb_Abbr": "Feb", "Mar_Abbr": "Mar", "Apr_Abbr": "Apr", "May_Abbr": "May", "Jun_Abbr": "Jun", "Jul_Abbr": "Jul", "Aug_Abbr": "Aug", "Sep_Abbr": "Sep", "Oct_Abbr": "Oct", "Nov_Abbr": "Nov", "Dec_Abbr": "Dec", "AM": "AM", "PM": "PM", "firstDayOfWeek": 0, "twoDigitYearMax": 2029, "mdy": "ymd", "M/d/yyyy": "yyyy/MM/dd", "dddd, MMMM dd, yyyy": "dd MMMM yyyy", "h:mm tt": "hh:mm:ss tt", "h:mm:ss tt": "hh:mm:ss tt", "dddd, MMMM dd, yyyy h:mm:ss tt": "dd MMMM yyyy hh:mm:ss tt", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "MMMM dd", "MMMM, yyyy": "MMMM yyyy", "/jan(uary)?/": "ujanuwari", "/feb(ruary)?/": "ufebuwari", "/mar(ch)?/": "umashi", "/apr(il)?/": "uaprhili", "/may/": "umeyi", "/jun(e)?/": "ujuni", "/jul(y)?/": "ujulayi", "/aug(ust)?/": "uagaste", "/sep(t(ember)?)?/": "usepthemba", "/oct(ober)?/": "uokthoba", "/nov(ember)?/": "unovemba", "/dec(ember)?/": "udisemba", "/^su(n(day)?)?/": "^isonto", "/^mo(n(day)?)?/": "^umsombuluko", "/^tu(e(s(day)?)?)?/": "^ulwesibili", "/^we(d(nesday)?)?/": "^ulwesithathu", "/^th(u(r(s(day)?)?)?)?/": "^ulwesine", "/^fr(i(day)?)?/": "^ulwesihlanu", "/^sa(t(urday)?)?/": "^umgqibelo", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "zu-ZA"; ================================================ FILE: index.js ================================================ /** * @overview NPM Module index: include all the core modules, I18n files will be loaded on the fly. * @author Gregory Wild-Smith */ require("./src/core/i18n.js"); require("./src/core/core.js"); require("./src/core/core-prototypes.js"); require("./src/core/sugarpak.js"); require("./src/core/format_parser.js"); require("./src/core/parsing_operators.js"); require("./src/core/parsing_translator.js"); require("./src/core/parsing_grammar.js"); require("./src/core/parser.js"); require("./src/core/extras.js"); require("./src/core/time_period.js"); require("./src/core/time_span.js"); /* * Notice that there is no model.export or exports. This is not required as it modifies the Date object and it's prototypes. */ ================================================ FILE: package.json ================================================ { "name": "datejs", "version": "1.0.0-rc3", "description": "DateJS is the most full-featured, internationalized, open-source JavaScript Date Library.", "devDependencies": { "codeclimate-test-reporter": "*", "grunt": "~0.4.1", "grunt-cli": "~0.1.11", "grunt-closurecompiler": "^0.9.9", "grunt-contrib-concat": "~0.4.0", "grunt-contrib-connect": "~0.7.1", "grunt-contrib-jasmine": "^0.8.1", "grunt-shell": "~0.6.1", "grunt-template-jasmine-istanbul": "^0.3.0", "jasmine-node": "~2.0.0-beta4" }, "dependencies": {}, "repository": { "type": "git", "url": "git://github.com/abritinthebay/datejs.git" }, "homepage": "https://github.com/abritinthebay/datejs", "bugs": { "url": "http://github.com/abritinthebay/datejs/issues" }, "keywords": [ "date", "javascript", "js", "mit" ], "engines": { "node": ">=0.8" }, "scripts": { "test": "grunt test" }, "author": { "name": "Gregory Wild-Smith", "email": "gregory@wild-smith.com" }, "maintainers": [ { "name": "Gregory Wild-Smith", "email": "gregory@wild-smith.com" } ], "main": "./index.js", "originator": "Geoffrey McGill", "license": "MIT", "readmeFilename": "README.md" } ================================================ FILE: reports/coverage.json ================================================ {"src/core/i18n.js":{"path":"src/core/i18n.js","s":{"1":1,"2":1,"3":1,"4":1,"5":1,"6":28001,"7":28001,"8":26062,"9":1939,"10":28001,"11":7360,"12":28001,"13":480,"14":480,"15":10240,"16":10240,"17":480,"18":320,"19":320,"20":9120,"21":9120,"22":320,"23":960,"24":960,"25":8320,"26":8320,"27":960,"28":1939,"29":1939,"30":3,"31":3,"32":3,"33":3,"34":3,"35":3,"36":3,"37":3,"38":160,"39":160,"40":1767,"41":1767,"42":1767,"43":1767,"44":214,"45":214,"46":214,"47":1767,"48":1939,"49":7360,"50":7360,"51":6123,"52":1237,"53":7360,"54":1,"55":160,"56":1600,"57":1600,"58":1,"59":1601,"60":1601,"61":1601,"62":1280,"63":960,"64":320,"65":321,"66":1,"67":1,"68":1,"69":1,"70":1,"71":1,"72":1,"73":1,"74":1,"75":1,"76":1,"77":1,"78":1,"79":1,"80":1,"81":1,"82":1,"83":1,"84":160,"85":160,"86":1600,"87":1600,"88":160,"89":160,"90":160,"91":160,"92":160,"93":160,"94":160,"95":160,"96":6240,"97":6240,"98":160,"99":2880,"100":2880,"101":160,"102":160,"103":160,"104":160,"105":160,"106":160,"107":160,"108":160,"109":160,"110":1,"111":160,"112":160,"113":160,"114":160,"115":160,"116":1,"117":321,"118":637,"119":159,"120":159,"121":157,"122":157,"123":157,"124":157,"125":2,"126":2,"127":0,"128":0,"129":0,"130":0,"131":0,"132":0,"133":2,"134":1,"135":1,"136":1,"137":1,"138":1,"139":1,"140":1,"141":1,"142":1,"143":1,"144":1,"145":1,"146":1,"147":158,"148":158,"149":158,"150":158,"151":156,"152":0,"153":2,"154":1},"b":{"1":[0,1],"2":[26062,1939],"3":[28001,27824,27475],"4":[7360,20641],"5":[10240,0],"6":[9120,0],"7":[8320,0],"8":[3,3,3,3,160,1767],"9":[214,1553],"10":[1767,214],"11":[214,0],"12":[214,36],"13":[6123,1237],"14":[7360,7314,7222],"15":[1600,0],"16":[0,1601],"17":[1280,321],"18":[960,320],"19":[1,0],"20":[1,0],"21":[1,1,0,0],"22":[1,0],"23":[1600,0],"24":[6240,0],"25":[2880,0],"26":[637,9],"27":[157,2],"28":[159,158,158,157],"29":[157,0],"30":[2,0],"31":[2,1],"32":[0,2],"33":[2,0],"34":[1,1],"35":[2,2],"36":[1,0],"37":[1,0],"38":[1,0],"39":[158,0],"40":[156,2],"41":[158,157]},"f":{"1":1,"2":28001,"3":480,"4":320,"5":960,"6":1939,"7":7360,"8":160,"9":1601,"10":1,"11":0,"12":1,"13":1,"14":1,"15":1,"16":160,"17":160,"18":160,"19":160,"20":160,"21":160,"22":160,"23":160,"24":160,"25":160,"26":160,"27":160,"28":160,"29":321,"30":637,"31":159,"32":1,"33":0,"34":2},"fnMap":{"1":{"name":"(anonymous_1)","line":1,"loc":{"start":{"line":1,"column":1},"end":{"line":1,"column":13}}},"2":{"name":"(anonymous_2)","line":6,"loc":{"start":{"line":6,"column":14},"end":{"line":6,"column":42}}},"3":{"name":"(anonymous_3)","line":18,"loc":{"start":{"line":18,"column":23},"end":{"line":18,"column":51}}},"4":{"name":"(anonymous_4)","line":27,"loc":{"start":{"line":27,"column":21},"end":{"line":27,"column":49}}},"5":{"name":"(anonymous_5)","line":36,"loc":{"start":{"line":36,"column":16},"end":{"line":36,"column":44}}},"6":{"name":"(anonymous_6)","line":45,"loc":{"start":{"line":45,"column":20},"end":{"line":45,"column":35}}},"7":{"name":"(anonymous_7)","line":78,"loc":{"start":{"line":78,"column":18},"end":{"line":78,"column":46}}},"8":{"name":"(anonymous_8)","line":89,"loc":{"start":{"line":89,"column":20},"end":{"line":89,"column":42}}},"9":{"name":"(anonymous_9)","line":97,"loc":{"start":{"line":97,"column":10},"end":{"line":97,"column":35}}},"10":{"name":"(anonymous_10)","line":111,"loc":{"start":{"line":111,"column":22},"end":{"line":111,"column":38}}},"11":{"name":"(anonymous_11)","line":120,"loc":{"start":{"line":120,"column":9},"end":{"line":120,"column":20}}},"12":{"name":"(anonymous_12)","line":123,"loc":{"start":{"line":123,"column":46},"end":{"line":123,"column":57}}},"13":{"name":"(anonymous_13)","line":130,"loc":{"start":{"line":130,"column":13},"end":{"line":130,"column":24}}},"14":{"name":"(anonymous_14)","line":135,"loc":{"start":{"line":135,"column":9},"end":{"line":135,"column":23}}},"15":{"name":"(anonymous_15)","line":136,"loc":{"start":{"line":136,"column":18},"end":{"line":136,"column":29}}},"16":{"name":"(anonymous_16)","line":146,"loc":{"start":{"line":146,"column":23},"end":{"line":146,"column":38}}},"17":{"name":"(anonymous_17)","line":155,"loc":{"start":{"line":155,"column":15},"end":{"line":155,"column":27}}},"18":{"name":"(anonymous_18)","line":178,"loc":{"start":{"line":178,"column":20},"end":{"line":178,"column":32}}},"19":{"name":"(anonymous_19)","line":222,"loc":{"start":{"line":222,"column":13},"end":{"line":222,"column":29}}},"20":{"name":"(anonymous_20)","line":237,"loc":{"start":{"line":237,"column":8},"end":{"line":237,"column":20}}},"21":{"name":"(anonymous_21)","line":240,"loc":{"start":{"line":240,"column":11},"end":{"line":240,"column":23}}},"22":{"name":"(anonymous_22)","line":243,"loc":{"start":{"line":243,"column":17},"end":{"line":243,"column":29}}},"23":{"name":"(anonymous_23)","line":246,"loc":{"start":{"line":246,"column":19},"end":{"line":246,"column":31}}},"24":{"name":"(anonymous_24)","line":249,"loc":{"start":{"line":249,"column":10},"end":{"line":249,"column":22}}},"25":{"name":"(anonymous_25)","line":252,"loc":{"start":{"line":252,"column":13},"end":{"line":252,"column":25}}},"26":{"name":"(anonymous_26)","line":255,"loc":{"start":{"line":255,"column":18},"end":{"line":255,"column":30}}},"27":{"name":"(anonymous_27)","line":269,"loc":{"start":{"line":269,"column":9},"end":{"line":269,"column":21}}},"28":{"name":"(anonymous_28)","line":321,"loc":{"start":{"line":321,"column":19},"end":{"line":321,"column":31}}},"29":{"name":"(anonymous_29)","line":352,"loc":{"start":{"line":352,"column":6},"end":{"line":352,"column":27}}},"30":{"name":"(anonymous_30)","line":355,"loc":{"start":{"line":355,"column":19},"end":{"line":355,"column":31}}},"31":{"name":"(anonymous_31)","line":358,"loc":{"start":{"line":358,"column":15},"end":{"line":358,"column":42}}},"32":{"name":"(anonymous_32)","line":381,"loc":{"start":{"line":381,"column":32},"end":{"line":381,"column":42}}},"33":{"name":"(anonymous_33)","line":408,"loc":{"start":{"line":408,"column":17},"end":{"line":408,"column":29}}},"34":{"name":"(anonymous_34)","line":411,"loc":{"start":{"line":411,"column":21},"end":{"line":411,"column":33}}}},"statementMap":{"1":{"start":{"line":1,"column":0},"end":{"line":416,"column":5}},"2":{"start":{"line":2,"column":1},"end":{"line":2,"column":15}},"3":{"start":{"line":3,"column":1},"end":{"line":3,"column":66}},"4":{"start":{"line":4,"column":1},"end":{"line":4,"column":21}},"5":{"start":{"line":5,"column":1},"end":{"line":87,"column":3}},"6":{"start":{"line":7,"column":3},"end":{"line":7,"column":14}},"7":{"start":{"line":8,"column":3},"end":{"line":12,"column":4}},"8":{"start":{"line":9,"column":4},"end":{"line":9,"column":51}},"9":{"start":{"line":11,"column":4},"end":{"line":11,"column":43}},"10":{"start":{"line":13,"column":3},"end":{"line":15,"column":4}},"11":{"start":{"line":14,"column":4},"end":{"line":14,"column":54}},"12":{"start":{"line":16,"column":3},"end":{"line":16,"column":17}},"13":{"start":{"line":19,"column":3},"end":{"line":19,"column":24}},"14":{"start":{"line":20,"column":3},"end":{"line":24,"column":4}},"15":{"start":{"line":21,"column":4},"end":{"line":23,"column":5}},"16":{"start":{"line":22,"column":5},"end":{"line":22,"column":61}},"17":{"start":{"line":25,"column":3},"end":{"line":25,"column":17}},"18":{"start":{"line":28,"column":3},"end":{"line":28,"column":24}},"19":{"start":{"line":29,"column":3},"end":{"line":33,"column":4}},"20":{"start":{"line":30,"column":4},"end":{"line":32,"column":5}},"21":{"start":{"line":31,"column":5},"end":{"line":31,"column":61}},"22":{"start":{"line":34,"column":3},"end":{"line":34,"column":17}},"23":{"start":{"line":37,"column":3},"end":{"line":37,"column":19}},"24":{"start":{"line":38,"column":3},"end":{"line":42,"column":4}},"25":{"start":{"line":39,"column":4},"end":{"line":41,"column":5}},"26":{"start":{"line":40,"column":5},"end":{"line":40,"column":57}},"27":{"start":{"line":43,"column":3},"end":{"line":43,"column":17}},"28":{"start":{"line":46,"column":3},"end":{"line":46,"column":35}},"29":{"start":{"line":47,"column":3},"end":{"line":75,"column":4}},"30":{"start":{"line":49,"column":5},"end":{"line":49,"column":22}},"31":{"start":{"line":50,"column":5},"end":{"line":50,"column":11}},"32":{"start":{"line":52,"column":5},"end":{"line":52,"column":40}},"33":{"start":{"line":53,"column":5},"end":{"line":53,"column":11}},"34":{"start":{"line":55,"column":5},"end":{"line":55,"column":40}},"35":{"start":{"line":56,"column":5},"end":{"line":56,"column":11}},"36":{"start":{"line":58,"column":5},"end":{"line":58,"column":19}},"37":{"start":{"line":59,"column":5},"end":{"line":59,"column":11}},"38":{"start":{"line":61,"column":5},"end":{"line":61,"column":16}},"39":{"start":{"line":62,"column":5},"end":{"line":62,"column":11}},"40":{"start":{"line":64,"column":5},"end":{"line":64,"column":18}},"41":{"start":{"line":65,"column":5},"end":{"line":65,"column":28}},"42":{"start":{"line":66,"column":5},"end":{"line":66,"column":27}},"43":{"start":{"line":67,"column":5},"end":{"line":73,"column":6}},"44":{"start":{"line":69,"column":6},"end":{"line":69,"column":47}},"45":{"start":{"line":70,"column":6},"end":{"line":72,"column":7}},"46":{"start":{"line":71,"column":7},"end":{"line":71,"column":25}},"47":{"start":{"line":74,"column":5},"end":{"line":74,"column":11}},"48":{"start":{"line":76,"column":3},"end":{"line":76,"column":17}},"49":{"start":{"line":79,"column":3},"end":{"line":79,"column":14}},"50":{"start":{"line":80,"column":3},"end":{"line":84,"column":4}},"51":{"start":{"line":81,"column":4},"end":{"line":81,"column":68}},"52":{"start":{"line":83,"column":4},"end":{"line":83,"column":67}},"53":{"start":{"line":85,"column":3},"end":{"line":85,"column":17}},"54":{"start":{"line":89,"column":1},"end":{"line":95,"column":3}},"55":{"start":{"line":90,"column":2},"end":{"line":94,"column":3}},"56":{"start":{"line":91,"column":3},"end":{"line":93,"column":4}},"57":{"start":{"line":92,"column":4},"end":{"line":92,"column":36}},"58":{"start":{"line":97,"column":1},"end":{"line":109,"column":3}},"59":{"start":{"line":98,"column":2},"end":{"line":98,"column":49}},"60":{"start":{"line":99,"column":2},"end":{"line":99,"column":24}},"61":{"start":{"line":100,"column":2},"end":{"line":108,"column":3}},"62":{"start":{"line":101,"column":3},"end":{"line":105,"column":4}},"63":{"start":{"line":102,"column":4},"end":{"line":102,"column":50}},"64":{"start":{"line":104,"column":4},"end":{"line":104,"column":55}},"65":{"start":{"line":107,"column":3},"end":{"line":107,"column":47}},"66":{"start":{"line":111,"column":1},"end":{"line":143,"column":3}},"67":{"start":{"line":113,"column":2},"end":{"line":113,"column":44}},"68":{"start":{"line":114,"column":2},"end":{"line":114,"column":82}},"69":{"start":{"line":115,"column":2},"end":{"line":115,"column":48}},"70":{"start":{"line":116,"column":2},"end":{"line":116,"column":19}},"71":{"start":{"line":118,"column":2},"end":{"line":118,"column":24}},"72":{"start":{"line":119,"column":2},"end":{"line":121,"column":4}},"73":{"start":{"line":123,"column":2},"end":{"line":128,"column":4}},"74":{"start":{"line":124,"column":3},"end":{"line":127,"column":4}},"75":{"start":{"line":125,"column":4},"end":{"line":125,"column":18}},"76":{"start":{"line":126,"column":4},"end":{"line":126,"column":29}},"77":{"start":{"line":130,"column":2},"end":{"line":132,"column":8}},"78":{"start":{"line":131,"column":3},"end":{"line":131,"column":46}},"79":{"start":{"line":134,"column":2},"end":{"line":142,"column":4}},"80":{"start":{"line":136,"column":4},"end":{"line":140,"column":6}},"81":{"start":{"line":137,"column":5},"end":{"line":139,"column":6}},"82":{"start":{"line":138,"column":6},"end":{"line":138,"column":23}},"83":{"start":{"line":145,"column":1},"end":{"line":319,"column":3}},"84":{"start":{"line":147,"column":3},"end":{"line":147,"column":11}},"85":{"start":{"line":148,"column":3},"end":{"line":152,"column":4}},"86":{"start":{"line":149,"column":4},"end":{"line":151,"column":5}},"87":{"start":{"line":150,"column":5},"end":{"line":150,"column":38}},"88":{"start":{"line":153,"column":3},"end":{"line":153,"column":14}},"89":{"start":{"line":156,"column":3},"end":{"line":175,"column":5}},"90":{"start":{"line":176,"column":3},"end":{"line":176,"column":18}},"91":{"start":{"line":179,"column":3},"end":{"line":219,"column":5}},"92":{"start":{"line":220,"column":3},"end":{"line":220,"column":23}},"93":{"start":{"line":223,"column":3},"end":{"line":223,"column":12}},"94":{"start":{"line":224,"column":3},"end":{"line":224,"column":23}},"95":{"start":{"line":225,"column":3},"end":{"line":229,"column":4}},"96":{"start":{"line":226,"column":4},"end":{"line":228,"column":5}},"97":{"start":{"line":227,"column":5},"end":{"line":227,"column":88}},"98":{"start":{"line":230,"column":3},"end":{"line":234,"column":4}},"99":{"start":{"line":231,"column":4},"end":{"line":233,"column":5}},"100":{"start":{"line":232,"column":5},"end":{"line":232,"column":94}},"101":{"start":{"line":235,"column":3},"end":{"line":235,"column":25}},"102":{"start":{"line":238,"column":3},"end":{"line":238,"column":93}},"103":{"start":{"line":241,"column":3},"end":{"line":241,"column":64}},"104":{"start":{"line":244,"column":3},"end":{"line":244,"column":57}},"105":{"start":{"line":247,"column":3},"end":{"line":247,"column":135}},"106":{"start":{"line":250,"column":3},"end":{"line":250,"column":137}},"107":{"start":{"line":253,"column":3},"end":{"line":253,"column":159}},"108":{"start":{"line":256,"column":3},"end":{"line":267,"column":35}},"109":{"start":{"line":270,"column":3},"end":{"line":317,"column":35}},"110":{"start":{"line":321,"column":1},"end":{"line":349,"column":3}},"111":{"start":{"line":322,"column":2},"end":{"line":331,"column":34}},"112":{"start":{"line":333,"column":2},"end":{"line":344,"column":5}},"113":{"start":{"line":346,"column":2},"end":{"line":346,"column":38}},"114":{"start":{"line":347,"column":2},"end":{"line":347,"column":28}},"115":{"start":{"line":348,"column":2},"end":{"line":348,"column":14}},"116":{"start":{"line":351,"column":1},"end":{"line":414,"column":3}},"117":{"start":{"line":353,"column":3},"end":{"line":353,"column":24}},"118":{"start":{"line":356,"column":3},"end":{"line":356,"column":26}},"119":{"start":{"line":359,"column":3},"end":{"line":359,"column":21}},"120":{"start":{"line":360,"column":3},"end":{"line":399,"column":4}},"121":{"start":{"line":361,"column":4},"end":{"line":361,"column":16}},"122":{"start":{"line":362,"column":4},"end":{"line":362,"column":52}},"123":{"start":{"line":363,"column":4},"end":{"line":363,"column":36}},"124":{"start":{"line":364,"column":4},"end":{"line":364,"column":41}},"125":{"start":{"line":366,"column":4},"end":{"line":398,"column":5}},"126":{"start":{"line":367,"column":5},"end":{"line":397,"column":6}},"127":{"start":{"line":369,"column":6},"end":{"line":377,"column":7}},"128":{"start":{"line":370,"column":7},"end":{"line":370,"column":42}},"129":{"start":{"line":371,"column":7},"end":{"line":371,"column":19}},"130":{"start":{"line":372,"column":7},"end":{"line":372,"column":39}},"131":{"start":{"line":373,"column":7},"end":{"line":373,"column":44}},"132":{"start":{"line":376,"column":7},"end":{"line":376,"column":125}},"133":{"start":{"line":378,"column":12},"end":{"line":397,"column":6}},"134":{"start":{"line":380,"column":6},"end":{"line":380,"column":19}},"135":{"start":{"line":381,"column":6},"end":{"line":393,"column":9}},"136":{"start":{"line":382,"column":7},"end":{"line":382,"column":19}},"137":{"start":{"line":383,"column":7},"end":{"line":383,"column":55}},"138":{"start":{"line":384,"column":7},"end":{"line":384,"column":39}},"139":{"start":{"line":385,"column":7},"end":{"line":385,"column":44}},"140":{"start":{"line":386,"column":7},"end":{"line":386,"column":48}},"141":{"start":{"line":387,"column":7},"end":{"line":389,"column":8}},"142":{"start":{"line":388,"column":8},"end":{"line":388,"column":41}},"143":{"start":{"line":390,"column":7},"end":{"line":392,"column":8}},"144":{"start":{"line":391,"column":8},"end":{"line":391,"column":25}},"145":{"start":{"line":395,"column":6},"end":{"line":395,"column":114}},"146":{"start":{"line":396,"column":6},"end":{"line":396,"column":19}},"147":{"start":{"line":400,"column":3},"end":{"line":400,"column":44}},"148":{"start":{"line":401,"column":3},"end":{"line":403,"column":4}},"149":{"start":{"line":402,"column":4},"end":{"line":402,"column":37}},"150":{"start":{"line":404,"column":3},"end":{"line":406,"column":4}},"151":{"start":{"line":405,"column":4},"end":{"line":405,"column":21}},"152":{"start":{"line":409,"column":3},"end":{"line":409,"column":21}},"153":{"start":{"line":412,"column":3},"end":{"line":412,"column":40}},"154":{"start":{"line":415,"column":1},"end":{"line":415,"column":29}}},"branchMap":{"1":{"line":3,"type":"cond-expr","locations":[{"start":{"line":3,"column":34},"end":{"line":3,"column":58}},{"start":{"line":3,"column":61},"end":{"line":3,"column":65}}]},"2":{"line":8,"type":"if","locations":[{"start":{"line":8,"column":3},"end":{"line":8,"column":3}},{"start":{"line":8,"column":3},"end":{"line":8,"column":3}}]},"3":{"line":8,"type":"binary-expr","locations":[{"start":{"line":8,"column":7},"end":{"line":8,"column":26}},{"start":{"line":8,"column":30},"end":{"line":8,"column":62}},{"start":{"line":8,"column":66},"end":{"line":8,"column":103}}]},"4":{"line":13,"type":"if","locations":[{"start":{"line":13,"column":3},"end":{"line":13,"column":3}},{"start":{"line":13,"column":3},"end":{"line":13,"column":3}}]},"5":{"line":21,"type":"if","locations":[{"start":{"line":21,"column":4},"end":{"line":21,"column":4}},{"start":{"line":21,"column":4},"end":{"line":21,"column":4}}]},"6":{"line":30,"type":"if","locations":[{"start":{"line":30,"column":4},"end":{"line":30,"column":4}},{"start":{"line":30,"column":4},"end":{"line":30,"column":4}}]},"7":{"line":39,"type":"if","locations":[{"start":{"line":39,"column":4},"end":{"line":39,"column":4}},{"start":{"line":39,"column":4},"end":{"line":39,"column":4}}]},"8":{"line":47,"type":"switch","locations":[{"start":{"line":48,"column":4},"end":{"line":50,"column":11}},{"start":{"line":51,"column":4},"end":{"line":53,"column":11}},{"start":{"line":54,"column":4},"end":{"line":56,"column":11}},{"start":{"line":57,"column":4},"end":{"line":59,"column":11}},{"start":{"line":60,"column":4},"end":{"line":62,"column":11}},{"start":{"line":63,"column":4},"end":{"line":74,"column":11}}]},"9":{"line":67,"type":"if","locations":[{"start":{"line":67,"column":5},"end":{"line":67,"column":5}},{"start":{"line":67,"column":5},"end":{"line":67,"column":5}}]},"10":{"line":67,"type":"binary-expr","locations":[{"start":{"line":67,"column":9},"end":{"line":67,"column":19}},{"start":{"line":67,"column":23},"end":{"line":67,"column":44}}]},"11":{"line":70,"type":"if","locations":[{"start":{"line":70,"column":6},"end":{"line":70,"column":6}},{"start":{"line":70,"column":6},"end":{"line":70,"column":6}}]},"12":{"line":70,"type":"binary-expr","locations":[{"start":{"line":70,"column":10},"end":{"line":70,"column":28}},{"start":{"line":70,"column":32},"end":{"line":70,"column":47}}]},"13":{"line":80,"type":"if","locations":[{"start":{"line":80,"column":3},"end":{"line":80,"column":3}},{"start":{"line":80,"column":3},"end":{"line":80,"column":3}}]},"14":{"line":80,"type":"binary-expr","locations":[{"start":{"line":80,"column":7},"end":{"line":80,"column":26}},{"start":{"line":80,"column":30},"end":{"line":80,"column":62}},{"start":{"line":80,"column":66},"end":{"line":80,"column":103}}]},"15":{"line":91,"type":"if","locations":[{"start":{"line":91,"column":3},"end":{"line":91,"column":3}},{"start":{"line":91,"column":3},"end":{"line":91,"column":3}}]},"16":{"line":98,"type":"cond-expr","locations":[{"start":{"line":98,"column":33},"end":{"line":98,"column":41}},{"start":{"line":98,"column":44},"end":{"line":98,"column":48}}]},"17":{"line":100,"type":"if","locations":[{"start":{"line":100,"column":2},"end":{"line":100,"column":2}},{"start":{"line":100,"column":2},"end":{"line":100,"column":2}}]},"18":{"line":101,"type":"if","locations":[{"start":{"line":101,"column":3},"end":{"line":101,"column":3}},{"start":{"line":101,"column":3},"end":{"line":101,"column":3}}]},"19":{"line":114,"type":"binary-expr","locations":[{"start":{"line":114,"column":13},"end":{"line":114,"column":53}},{"start":{"line":114,"column":57},"end":{"line":114,"column":81}}]},"20":{"line":124,"type":"if","locations":[{"start":{"line":124,"column":3},"end":{"line":124,"column":3}},{"start":{"line":124,"column":3},"end":{"line":124,"column":3}}]},"21":{"line":124,"type":"binary-expr","locations":[{"start":{"line":124,"column":8},"end":{"line":124,"column":18}},{"start":{"line":124,"column":23},"end":{"line":124,"column":39}},{"start":{"line":124,"column":43},"end":{"line":124,"column":71}},{"start":{"line":124,"column":75},"end":{"line":124,"column":105}}]},"22":{"line":137,"type":"if","locations":[{"start":{"line":137,"column":5},"end":{"line":137,"column":5}},{"start":{"line":137,"column":5},"end":{"line":137,"column":5}}]},"23":{"line":149,"type":"if","locations":[{"start":{"line":149,"column":4},"end":{"line":149,"column":4}},{"start":{"line":149,"column":4},"end":{"line":149,"column":4}}]},"24":{"line":226,"type":"if","locations":[{"start":{"line":226,"column":4},"end":{"line":226,"column":4}},{"start":{"line":226,"column":4},"end":{"line":226,"column":4}}]},"25":{"line":231,"type":"if","locations":[{"start":{"line":231,"column":4},"end":{"line":231,"column":4}},{"start":{"line":231,"column":4},"end":{"line":231,"column":4}}]},"26":{"line":356,"type":"binary-expr","locations":[{"start":{"line":356,"column":10},"end":{"line":356,"column":14}},{"start":{"line":356,"column":18},"end":{"line":356,"column":25}}]},"27":{"line":360,"type":"if","locations":[{"start":{"line":360,"column":3},"end":{"line":360,"column":3}},{"start":{"line":360,"column":3},"end":{"line":360,"column":3}}]},"28":{"line":360,"type":"binary-expr","locations":[{"start":{"line":360,"column":7},"end":{"line":360,"column":12}},{"start":{"line":360,"column":16},"end":{"line":360,"column":32}},{"start":{"line":360,"column":37},"end":{"line":360,"column":58}},{"start":{"line":360,"column":62},"end":{"line":360,"column":89}}]},"29":{"line":362,"type":"binary-expr","locations":[{"start":{"line":362,"column":26},"end":{"line":362,"column":45}},{"start":{"line":362,"column":49},"end":{"line":362,"column":51}}]},"30":{"line":366,"type":"if","locations":[{"start":{"line":366,"column":4},"end":{"line":366,"column":4}},{"start":{"line":366,"column":4},"end":{"line":366,"column":4}}]},"31":{"line":366,"type":"binary-expr","locations":[{"start":{"line":366,"column":10},"end":{"line":366,"column":31}},{"start":{"line":366,"column":35},"end":{"line":366,"column":62}}]},"32":{"line":367,"type":"if","locations":[{"start":{"line":367,"column":5},"end":{"line":367,"column":5}},{"start":{"line":367,"column":5},"end":{"line":367,"column":5}}]},"33":{"line":367,"type":"binary-expr","locations":[{"start":{"line":367,"column":9},"end":{"line":367,"column":39}},{"start":{"line":367,"column":43},"end":{"line":367,"column":67}}]},"34":{"line":378,"type":"if","locations":[{"start":{"line":378,"column":12},"end":{"line":378,"column":12}},{"start":{"line":378,"column":12},"end":{"line":378,"column":12}}]},"35":{"line":378,"type":"binary-expr","locations":[{"start":{"line":378,"column":16},"end":{"line":378,"column":27}},{"start":{"line":378,"column":31},"end":{"line":378,"column":47}}]},"36":{"line":383,"type":"binary-expr","locations":[{"start":{"line":383,"column":29},"end":{"line":383,"column":48}},{"start":{"line":383,"column":52},"end":{"line":383,"column":54}}]},"37":{"line":387,"type":"if","locations":[{"start":{"line":387,"column":7},"end":{"line":387,"column":7}},{"start":{"line":387,"column":7},"end":{"line":387,"column":7}}]},"38":{"line":390,"type":"if","locations":[{"start":{"line":390,"column":7},"end":{"line":390,"column":7}},{"start":{"line":390,"column":7},"end":{"line":390,"column":7}}]},"39":{"line":401,"type":"if","locations":[{"start":{"line":401,"column":3},"end":{"line":401,"column":3}},{"start":{"line":401,"column":3},"end":{"line":401,"column":3}}]},"40":{"line":404,"type":"if","locations":[{"start":{"line":404,"column":3},"end":{"line":404,"column":3}},{"start":{"line":404,"column":3},"end":{"line":404,"column":3}}]},"41":{"line":404,"type":"binary-expr","locations":[{"start":{"line":404,"column":7},"end":{"line":404,"column":13}},{"start":{"line":404,"column":17},"end":{"line":404,"column":19}}]}}},"src/core/core.js":{"path":"src/core/core.js","s":{"1":1,"2":1,"3":15,"4":15,"5":15,"6":1,"7":1,"8":0,"9":1,"10":1,"11":5,"12":1,"13":1,"14":4,"15":2,"16":5,"17":4,"18":3,"19":1,"20":5,"21":1,"22":3,"23":5,"24":2,"25":1,"26":1,"27":2094,"28":1,"29":4,"30":1,"31":408,"32":5,"33":403,"34":401,"35":2,"36":1,"37":398,"38":1,"39":2,"40":1,"41":26,"42":26,"43":105,"44":24,"45":2,"46":1,"47":24,"48":24,"49":163,"50":23,"51":1,"52":1,"53":2,"54":1,"55":591,"56":1,"57":588,"58":12,"59":12,"60":588,"61":1,"62":0,"63":1,"64":6,"65":6,"66":166,"67":166,"68":5,"69":1,"70":1,"71":7,"72":7,"73":0,"74":7,"75":399,"76":8,"77":7,"78":1,"79":6,"80":5,"81":1,"82":2,"83":1,"84":1,"85":15,"86":15,"87":15,"88":1,"89":2,"90":2,"91":2,"92":2,"93":1,"94":369,"95":369,"96":1,"97":368,"98":1,"99":367,"100":28,"101":339,"102":1,"103":1,"104":1,"105":3,"106":1,"107":5,"108":1,"109":30,"110":1,"111":119,"112":0,"113":119,"114":1,"115":1,"116":1,"117":139,"118":1,"119":71,"120":1,"121":3,"122":3,"123":1,"124":2},"b":{"1":[15,0],"2":[1,0],"3":[1,1,1],"4":[1,0],"5":[1,4],"6":[2,2],"7":[3,1],"8":[1,4],"9":[2,3],"10":[5,403],"11":[408,405],"12":[401,2],"13":[403,403],"14":[4,397],"15":[4,393],"16":[24,81],"17":[105,97,88],"18":[23,140],"19":[163,151],"20":[591,29,562],"21":[12,576],"22":[588,38],"23":[28,560],"24":[1,5],"25":[6,5],"26":[166,0],"27":[5,161],"28":[0,7],"29":[8,391],"30":[1,6],"31":[5,1],"32":[6,2],"33":[1,1],"34":[15,0],"35":[2,0],"36":[369,0],"37":[1,368],"38":[1,367],"39":[28,339],"40":[367,366],"41":[0,119],"42":[119,119,119,119],"43":[2,2]},"f":{"1":1,"2":15,"3":0,"4":0,"5":5,"6":1,"7":4,"8":3,"9":2094,"10":4,"11":408,"12":398,"13":2,"14":26,"15":24,"16":2,"17":591,"18":588,"19":0,"20":6,"21":7,"22":15,"23":2,"24":369,"25":1,"26":3,"27":5,"28":30,"29":119,"30":1,"31":139,"32":71,"33":3,"34":2},"fnMap":{"1":{"name":"(anonymous_1)","line":1,"loc":{"start":{"line":1,"column":1},"end":{"line":1,"column":13}}},"2":{"name":"(anonymous_2)","line":4,"loc":{"start":{"line":4,"column":6},"end":{"line":4,"column":22}}},"3":{"name":"(anonymous_3)","line":16,"loc":{"start":{"line":16,"column":8},"end":{"line":16,"column":18}}},"4":{"name":"(anonymous_4)","line":17,"loc":{"start":{"line":17,"column":10},"end":{"line":17,"column":20}}},"5":{"name":"(anonymous_5)","line":22,"loc":{"start":{"line":22,"column":20},"end":{"line":22,"column":31}}},"6":{"name":"now","line":35,"loc":{"start":{"line":35,"column":13},"end":{"line":35,"column":28}}},"7":{"name":"(anonymous_7)","line":42,"loc":{"start":{"line":42,"column":11},"end":{"line":42,"column":32}}},"8":{"name":"(anonymous_8)","line":51,"loc":{"start":{"line":51,"column":20},"end":{"line":51,"column":31}}},"9":{"name":"(anonymous_9)","line":76,"loc":{"start":{"line":76,"column":12},"end":{"line":76,"column":24}}},"10":{"name":"(anonymous_10)","line":84,"loc":{"start":{"line":84,"column":14},"end":{"line":84,"column":26}}},"11":{"name":"(anonymous_11)","line":94,"loc":{"start":{"line":94,"column":14},"end":{"line":94,"column":38}}},"12":{"name":"(anonymous_12)","line":110,"loc":{"start":{"line":110,"column":13},"end":{"line":110,"column":37}}},"13":{"name":"(anonymous_13)","line":119,"loc":{"start":{"line":119,"column":17},"end":{"line":119,"column":30}}},"14":{"name":"(anonymous_14)","line":128,"loc":{"start":{"line":128,"column":27},"end":{"line":128,"column":43}}},"15":{"name":"(anonymous_15)","line":143,"loc":{"start":{"line":143,"column":29},"end":{"line":143,"column":45}}},"16":{"name":"(anonymous_16)","line":158,"loc":{"start":{"line":158,"column":19},"end":{"line":158,"column":32}}},"17":{"name":"(anonymous_17)","line":167,"loc":{"start":{"line":167,"column":17},"end":{"line":167,"column":33}}},"18":{"name":"(anonymous_18)","line":177,"loc":{"start":{"line":177,"column":21},"end":{"line":177,"column":44}}},"19":{"name":"(anonymous_19)","line":185,"loc":{"start":{"line":185,"column":21},"end":{"line":185,"column":33}}},"20":{"name":"(anonymous_20)","line":189,"loc":{"start":{"line":189,"column":30},"end":{"line":189,"column":53}}},"21":{"name":"(anonymous_21)","line":201,"loc":{"start":{"line":201,"column":24},"end":{"line":201,"column":45}}},"22":{"name":"(anonymous_22)","line":223,"loc":{"start":{"line":223,"column":17},"end":{"line":223,"column":30}}},"23":{"name":"(anonymous_23)","line":229,"loc":{"start":{"line":229,"column":27},"end":{"line":229,"column":40}}},"24":{"name":"(anonymous_24)","line":237,"loc":{"start":{"line":237,"column":16},"end":{"line":237,"column":45}}},"25":{"name":"(anonymous_25)","line":257,"loc":{"start":{"line":257,"column":26},"end":{"line":257,"column":43}}},"26":{"name":"(anonymous_26)","line":266,"loc":{"start":{"line":266,"column":21},"end":{"line":266,"column":38}}},"27":{"name":"(anonymous_27)","line":275,"loc":{"start":{"line":275,"column":21},"end":{"line":275,"column":38}}},"28":{"name":"(anonymous_28)","line":284,"loc":{"start":{"line":284,"column":19},"end":{"line":284,"column":36}}},"29":{"name":"(anonymous_29)","line":293,"loc":{"start":{"line":293,"column":18},"end":{"line":293,"column":48}}},"30":{"name":"(anonymous_30)","line":303,"loc":{"start":{"line":303,"column":19},"end":{"line":303,"column":36}}},"31":{"name":"(anonymous_31)","line":312,"loc":{"start":{"line":312,"column":20},"end":{"line":312,"column":37}}},"32":{"name":"(anonymous_32)","line":321,"loc":{"start":{"line":321,"column":19},"end":{"line":321,"column":36}}},"33":{"name":"(anonymous_33)","line":334,"loc":{"start":{"line":334,"column":23},"end":{"line":334,"column":39}}},"34":{"name":"(anonymous_34)","line":338,"loc":{"start":{"line":338,"column":28},"end":{"line":338,"column":44}}}},"statementMap":{"1":{"start":{"line":1,"column":0},"end":{"line":343,"column":5}},"2":{"start":{"line":2,"column":1},"end":{"line":9,"column":4}},"3":{"start":{"line":5,"column":3},"end":{"line":7,"column":4}},"4":{"start":{"line":6,"column":4},"end":{"line":6,"column":10}},"5":{"start":{"line":8,"column":3},"end":{"line":8,"column":36}},"6":{"start":{"line":11,"column":1},"end":{"line":19,"column":2}},"7":{"start":{"line":12,"column":2},"end":{"line":12,"column":23}},"8":{"start":{"line":15,"column":2},"end":{"line":18,"column":4}},"9":{"start":{"line":20,"column":1},"end":{"line":20,"column":29}},"10":{"start":{"line":22,"column":1},"end":{"line":68,"column":3}},"11":{"start":{"line":34,"column":2},"end":{"line":40,"column":3}},"12":{"start":{"line":35,"column":3},"end":{"line":37,"column":5}},"13":{"start":{"line":36,"column":4},"end":{"line":36,"column":32}},"14":{"start":{"line":38,"column":9},"end":{"line":40,"column":3}},"15":{"start":{"line":39,"column":3},"end":{"line":39,"column":20}},"16":{"start":{"line":42,"column":2},"end":{"line":48,"column":4}},"17":{"start":{"line":43,"column":3},"end":{"line":47,"column":4}},"18":{"start":{"line":44,"column":4},"end":{"line":44,"column":24}},"19":{"start":{"line":46,"column":4},"end":{"line":46,"column":21}},"20":{"start":{"line":50,"column":2},"end":{"line":61,"column":3}},"21":{"start":{"line":51,"column":3},"end":{"line":60,"column":5}},"22":{"start":{"line":52,"column":4},"end":{"line":59,"column":8}},"23":{"start":{"line":64,"column":2},"end":{"line":66,"column":3}},"24":{"start":{"line":65,"column":3},"end":{"line":65,"column":30}},"25":{"start":{"line":69,"column":1},"end":{"line":69,"column":20}},"26":{"start":{"line":76,"column":1},"end":{"line":78,"column":3}},"27":{"start":{"line":77,"column":2},"end":{"line":77,"column":32}},"28":{"start":{"line":84,"column":1},"end":{"line":86,"column":3}},"29":{"start":{"line":85,"column":2},"end":{"line":85,"column":20}},"30":{"start":{"line":94,"column":1},"end":{"line":102,"column":3}},"31":{"start":{"line":95,"column":2},"end":{"line":101,"column":3}},"32":{"start":{"line":96,"column":3},"end":{"line":96,"column":42}},"33":{"start":{"line":97,"column":9},"end":{"line":101,"column":3}},"34":{"start":{"line":98,"column":3},"end":{"line":98,"column":57}},"35":{"start":{"line":100,"column":3},"end":{"line":100,"column":46}},"36":{"start":{"line":110,"column":1},"end":{"line":112,"column":3}},"37":{"start":{"line":111,"column":2},"end":{"line":111,"column":40}},"38":{"start":{"line":119,"column":1},"end":{"line":121,"column":3}},"39":{"start":{"line":120,"column":2},"end":{"line":120,"column":38}},"40":{"start":{"line":128,"column":1},"end":{"line":136,"column":3}},"41":{"start":{"line":129,"column":2},"end":{"line":129,"column":141}},"42":{"start":{"line":130,"column":2},"end":{"line":134,"column":3}},"43":{"start":{"line":131,"column":3},"end":{"line":133,"column":4}},"44":{"start":{"line":132,"column":4},"end":{"line":132,"column":13}},"45":{"start":{"line":135,"column":2},"end":{"line":135,"column":12}},"46":{"start":{"line":143,"column":1},"end":{"line":151,"column":3}},"47":{"start":{"line":144,"column":2},"end":{"line":144,"column":106}},"48":{"start":{"line":145,"column":2},"end":{"line":149,"column":3}},"49":{"start":{"line":146,"column":3},"end":{"line":148,"column":4}},"50":{"start":{"line":147,"column":4},"end":{"line":147,"column":13}},"51":{"start":{"line":150,"column":2},"end":{"line":150,"column":12}},"52":{"start":{"line":158,"column":1},"end":{"line":160,"column":3}},"53":{"start":{"line":159,"column":2},"end":{"line":159,"column":40}},"54":{"start":{"line":167,"column":1},"end":{"line":169,"column":3}},"55":{"start":{"line":168,"column":2},"end":{"line":168,"column":68}},"56":{"start":{"line":177,"column":1},"end":{"line":183,"column":3}},"57":{"start":{"line":178,"column":2},"end":{"line":181,"column":3}},"58":{"start":{"line":179,"column":4},"end":{"line":179,"column":17}},"59":{"start":{"line":180,"column":4},"end":{"line":180,"column":38}},"60":{"start":{"line":182,"column":2},"end":{"line":182,"column":94}},"61":{"start":{"line":185,"column":1},"end":{"line":187,"column":3}},"62":{"start":{"line":186,"column":2},"end":{"line":186,"column":64}},"63":{"start":{"line":189,"column":1},"end":{"line":199,"column":3}},"64":{"start":{"line":190,"column":2},"end":{"line":190,"column":117}},"65":{"start":{"line":191,"column":2},"end":{"line":197,"column":3}},"66":{"start":{"line":192,"column":3},"end":{"line":196,"column":4}},"67":{"start":{"line":193,"column":4},"end":{"line":195,"column":5}},"68":{"start":{"line":194,"column":5},"end":{"line":194,"column":14}},"69":{"start":{"line":198,"column":2},"end":{"line":198,"column":14}},"70":{"start":{"line":201,"column":1},"end":{"line":221,"column":3}},"71":{"start":{"line":202,"column":2},"end":{"line":202,"column":47}},"72":{"start":{"line":203,"column":2},"end":{"line":203,"column":50}},"73":{"start":{"line":203,"column":15},"end":{"line":203,"column":49}},"74":{"start":{"line":204,"column":2},"end":{"line":208,"column":3}},"75":{"start":{"line":205,"column":3},"end":{"line":207,"column":4}},"76":{"start":{"line":206,"column":4},"end":{"line":206,"column":14}},"77":{"start":{"line":209,"column":2},"end":{"line":211,"column":3}},"78":{"start":{"line":210,"column":3},"end":{"line":210,"column":15}},"79":{"start":{"line":212,"column":2},"end":{"line":220,"column":3}},"80":{"start":{"line":213,"column":3},"end":{"line":213,"column":25}},"81":{"start":{"line":215,"column":3},"end":{"line":219,"column":4}},"82":{"start":{"line":216,"column":4},"end":{"line":218,"column":5}},"83":{"start":{"line":217,"column":5},"end":{"line":217,"column":27}},"84":{"start":{"line":223,"column":1},"end":{"line":227,"column":3}},"85":{"start":{"line":224,"column":2},"end":{"line":224,"column":22}},"86":{"start":{"line":225,"column":2},"end":{"line":225,"column":20}},"87":{"start":{"line":226,"column":2},"end":{"line":226,"column":41}},"88":{"start":{"line":229,"column":1},"end":{"line":234,"column":3}},"89":{"start":{"line":230,"column":2},"end":{"line":230,"column":22}},"90":{"start":{"line":231,"column":2},"end":{"line":231,"column":25}},"91":{"start":{"line":232,"column":2},"end":{"line":232,"column":62}},"92":{"start":{"line":233,"column":2},"end":{"line":233,"column":41}},"93":{"start":{"line":237,"column":1},"end":{"line":250,"column":3}},"94":{"start":{"line":238,"column":2},"end":{"line":238,"column":32}},"95":{"start":{"line":239,"column":2},"end":{"line":248,"column":3}},"96":{"start":{"line":240,"column":3},"end":{"line":240,"column":16}},"97":{"start":{"line":241,"column":9},"end":{"line":248,"column":3}},"98":{"start":{"line":242,"column":3},"end":{"line":242,"column":48}},"99":{"start":{"line":243,"column":9},"end":{"line":248,"column":3}},"100":{"start":{"line":247,"column":3},"end":{"line":247,"column":16}},"101":{"start":{"line":249,"column":2},"end":{"line":249,"column":14}},"102":{"start":{"line":257,"column":1},"end":{"line":259,"column":3}},"103":{"start":{"line":258,"column":2},"end":{"line":258,"column":48}},"104":{"start":{"line":266,"column":1},"end":{"line":268,"column":3}},"105":{"start":{"line":267,"column":2},"end":{"line":267,"column":42}},"106":{"start":{"line":275,"column":1},"end":{"line":277,"column":3}},"107":{"start":{"line":276,"column":2},"end":{"line":276,"column":42}},"108":{"start":{"line":284,"column":1},"end":{"line":286,"column":3}},"109":{"start":{"line":285,"column":2},"end":{"line":285,"column":40}},"110":{"start":{"line":293,"column":1},"end":{"line":296,"column":3}},"111":{"start":{"line":294,"column":2},"end":{"line":294,"column":100}},"112":{"start":{"line":294,"column":86},"end":{"line":294,"column":99}},"113":{"start":{"line":295,"column":2},"end":{"line":295,"column":67}},"114":{"start":{"line":303,"column":1},"end":{"line":305,"column":3}},"115":{"start":{"line":304,"column":2},"end":{"line":304,"column":40}},"116":{"start":{"line":312,"column":1},"end":{"line":314,"column":3}},"117":{"start":{"line":313,"column":2},"end":{"line":313,"column":41}},"118":{"start":{"line":321,"column":1},"end":{"line":333,"column":3}},"119":{"start":{"line":332,"column":2},"end":{"line":332,"column":50}},"120":{"start":{"line":334,"column":1},"end":{"line":337,"column":3}},"121":{"start":{"line":335,"column":2},"end":{"line":335,"column":1521}},"122":{"start":{"line":336,"column":2},"end":{"line":336,"column":34}},"123":{"start":{"line":338,"column":1},"end":{"line":341,"column":3}},"124":{"start":{"line":340,"column":2},"end":{"line":340,"column":39}}},"branchMap":{"1":{"line":5,"type":"if","locations":[{"start":{"line":5,"column":3},"end":{"line":5,"column":3}},{"start":{"line":5,"column":3},"end":{"line":5,"column":3}}]},"2":{"line":11,"type":"if","locations":[{"start":{"line":11,"column":1},"end":{"line":11,"column":1}},{"start":{"line":11,"column":1},"end":{"line":11,"column":1}}]},"3":{"line":11,"type":"binary-expr","locations":[{"start":{"line":11,"column":5},"end":{"line":11,"column":34}},{"start":{"line":11,"column":38},"end":{"line":11,"column":75}},{"start":{"line":11,"column":79},"end":{"line":11,"column":120}}]},"4":{"line":20,"type":"binary-expr","locations":[{"start":{"line":20,"column":13},"end":{"line":20,"column":22}},{"start":{"line":20,"column":26},"end":{"line":20,"column":28}}]},"5":{"line":34,"type":"if","locations":[{"start":{"line":34,"column":2},"end":{"line":34,"column":2}},{"start":{"line":34,"column":2},"end":{"line":34,"column":2}}]},"6":{"line":38,"type":"if","locations":[{"start":{"line":38,"column":9},"end":{"line":38,"column":9}},{"start":{"line":38,"column":9},"end":{"line":38,"column":9}}]},"7":{"line":43,"type":"if","locations":[{"start":{"line":43,"column":3},"end":{"line":43,"column":3}},{"start":{"line":43,"column":3},"end":{"line":43,"column":3}}]},"8":{"line":50,"type":"if","locations":[{"start":{"line":50,"column":2},"end":{"line":50,"column":2}},{"start":{"line":50,"column":2},"end":{"line":50,"column":2}}]},"9":{"line":64,"type":"if","locations":[{"start":{"line":64,"column":2},"end":{"line":64,"column":2}},{"start":{"line":64,"column":2},"end":{"line":64,"column":2}}]},"10":{"line":95,"type":"if","locations":[{"start":{"line":95,"column":2},"end":{"line":95,"column":2}},{"start":{"line":95,"column":2},"end":{"line":95,"column":2}}]},"11":{"line":95,"type":"binary-expr","locations":[{"start":{"line":95,"column":6},"end":{"line":95,"column":18}},{"start":{"line":95,"column":22},"end":{"line":95,"column":34}}]},"12":{"line":97,"type":"if","locations":[{"start":{"line":97,"column":9},"end":{"line":97,"column":9}},{"start":{"line":97,"column":9},"end":{"line":97,"column":9}}]},"13":{"line":97,"type":"binary-expr","locations":[{"start":{"line":97,"column":13},"end":{"line":97,"column":34}},{"start":{"line":97,"column":38},"end":{"line":97,"column":59}}]},"14":{"line":98,"type":"cond-expr","locations":[{"start":{"line":98,"column":28},"end":{"line":98,"column":30}},{"start":{"line":98,"column":33},"end":{"line":98,"column":56}}]},"15":{"line":98,"type":"cond-expr","locations":[{"start":{"line":98,"column":51},"end":{"line":98,"column":52}},{"start":{"line":98,"column":55},"end":{"line":98,"column":56}}]},"16":{"line":131,"type":"if","locations":[{"start":{"line":131,"column":3},"end":{"line":131,"column":3}},{"start":{"line":131,"column":3},"end":{"line":131,"column":3}}]},"17":{"line":131,"type":"binary-expr","locations":[{"start":{"line":131,"column":7},"end":{"line":131,"column":31}},{"start":{"line":131,"column":35},"end":{"line":131,"column":59}},{"start":{"line":131,"column":63},"end":{"line":131,"column":87}}]},"18":{"line":146,"type":"if","locations":[{"start":{"line":146,"column":3},"end":{"line":146,"column":3}},{"start":{"line":146,"column":3},"end":{"line":146,"column":3}}]},"19":{"line":146,"type":"binary-expr","locations":[{"start":{"line":146,"column":7},"end":{"line":146,"column":31}},{"start":{"line":146,"column":35},"end":{"line":146,"column":59}}]},"20":{"line":168,"type":"binary-expr","locations":[{"start":{"line":168,"column":11},"end":{"line":168,"column":25}},{"start":{"line":168,"column":29},"end":{"line":168,"column":45}},{"start":{"line":168,"column":50},"end":{"line":168,"column":66}}]},"21":{"line":178,"type":"if","locations":[{"start":{"line":178,"column":2},"end":{"line":178,"column":2}},{"start":{"line":178,"column":2},"end":{"line":178,"column":2}}]},"22":{"line":178,"type":"binary-expr","locations":[{"start":{"line":178,"column":6},"end":{"line":178,"column":12}},{"start":{"line":178,"column":16},"end":{"line":178,"column":38}}]},"23":{"line":182,"type":"cond-expr","locations":[{"start":{"line":182,"column":37},"end":{"line":182,"column":39}},{"start":{"line":182,"column":42},"end":{"line":182,"column":44}}]},"24":{"line":190,"type":"cond-expr","locations":[{"start":{"line":190,"column":30},"end":{"line":190,"column":69}},{"start":{"line":190,"column":72},"end":{"line":190,"column":116}}]},"25":{"line":190,"type":"binary-expr","locations":[{"start":{"line":190,"column":14},"end":{"line":190,"column":17}},{"start":{"line":190,"column":21},"end":{"line":190,"column":26}}]},"26":{"line":192,"type":"if","locations":[{"start":{"line":192,"column":3},"end":{"line":192,"column":3}},{"start":{"line":192,"column":3},"end":{"line":192,"column":3}}]},"27":{"line":193,"type":"if","locations":[{"start":{"line":193,"column":4},"end":{"line":193,"column":4}},{"start":{"line":193,"column":4},"end":{"line":193,"column":4}}]},"28":{"line":203,"type":"if","locations":[{"start":{"line":203,"column":2},"end":{"line":203,"column":2}},{"start":{"line":203,"column":2},"end":{"line":203,"column":2}}]},"29":{"line":205,"type":"if","locations":[{"start":{"line":205,"column":3},"end":{"line":205,"column":3}},{"start":{"line":205,"column":3},"end":{"line":205,"column":3}}]},"30":{"line":209,"type":"if","locations":[{"start":{"line":209,"column":2},"end":{"line":209,"column":2}},{"start":{"line":209,"column":2},"end":{"line":209,"column":2}}]},"31":{"line":212,"type":"if","locations":[{"start":{"line":212,"column":2},"end":{"line":212,"column":2}},{"start":{"line":212,"column":2},"end":{"line":212,"column":2}}]},"32":{"line":212,"type":"binary-expr","locations":[{"start":{"line":212,"column":6},"end":{"line":212,"column":20}},{"start":{"line":212,"column":24},"end":{"line":212,"column":28}}]},"33":{"line":216,"type":"if","locations":[{"start":{"line":216,"column":4},"end":{"line":216,"column":4}},{"start":{"line":216,"column":4},"end":{"line":216,"column":4}}]},"34":{"line":224,"type":"binary-expr","locations":[{"start":{"line":224,"column":6},"end":{"line":224,"column":7}},{"start":{"line":224,"column":11},"end":{"line":224,"column":21}}]},"35":{"line":230,"type":"binary-expr","locations":[{"start":{"line":230,"column":6},"end":{"line":230,"column":7}},{"start":{"line":230,"column":11},"end":{"line":230,"column":21}}]},"36":{"line":238,"type":"cond-expr","locations":[{"start":{"line":238,"column":16},"end":{"line":238,"column":20}},{"start":{"line":238,"column":23},"end":{"line":238,"column":31}}]},"37":{"line":239,"type":"if","locations":[{"start":{"line":239,"column":2},"end":{"line":239,"column":2}},{"start":{"line":239,"column":2},"end":{"line":239,"column":2}}]},"38":{"line":241,"type":"if","locations":[{"start":{"line":241,"column":9},"end":{"line":241,"column":9}},{"start":{"line":241,"column":9},"end":{"line":241,"column":9}}]},"39":{"line":243,"type":"if","locations":[{"start":{"line":243,"column":9},"end":{"line":243,"column":9}},{"start":{"line":243,"column":9},"end":{"line":243,"column":9}}]},"40":{"line":243,"type":"binary-expr","locations":[{"start":{"line":243,"column":13},"end":{"line":243,"column":20}},{"start":{"line":243,"column":24},"end":{"line":243,"column":31}}]},"41":{"line":294,"type":"if","locations":[{"start":{"line":294,"column":2},"end":{"line":294,"column":2}},{"start":{"line":294,"column":2},"end":{"line":294,"column":2}}]},"42":{"line":294,"type":"binary-expr","locations":[{"start":{"line":294,"column":6},"end":{"line":294,"column":24}},{"start":{"line":294,"column":28},"end":{"line":294,"column":41}},{"start":{"line":294,"column":45},"end":{"line":294,"column":64}},{"start":{"line":294,"column":68},"end":{"line":294,"column":82}}]},"43":{"line":340,"type":"binary-expr","locations":[{"start":{"line":340,"column":10},"end":{"line":340,"column":22}},{"start":{"line":340,"column":26},"end":{"line":340,"column":37}}]}}},"src/core/core-prototypes.js":{"path":"src/core/core-prototypes.js","s":{"1":1,"2":1,"3":4331,"4":2871,"5":4331,"6":1,"7":151,"8":151,"9":335,"10":119,"11":119,"12":119,"13":216,"14":151,"15":565,"16":565,"17":565,"18":330,"19":150,"20":1,"21":2100,"22":2100,"23":2100,"24":2100,"25":2100,"26":1,"27":3,"28":3,"29":3,"30":3,"31":3,"32":3,"33":1,"34":25,"35":1,"36":408,"37":1,"38":398,"39":1,"40":1,"41":1,"42":2,"43":1,"44":2,"45":1,"46":2,"47":1,"48":155,"49":0,"50":155,"51":155,"52":1,"53":70,"54":0,"55":70,"56":1,"57":48,"58":2,"59":46,"60":1,"61":37,"62":0,"63":37,"64":1,"65":1851,"66":10,"67":1841,"68":1841,"69":1,"70":14,"71":2,"72":12,"73":12,"74":12,"75":4,"76":2,"77":2,"78":2,"79":12,"80":5,"81":11,"82":11,"83":11,"84":5,"85":5,"86":7,"87":2,"88":7,"89":1,"90":55,"91":1,"92":54,"93":1,"94":413,"95":17,"96":396,"97":396,"98":396,"99":396,"100":396,"101":1,"102":1,"103":0,"104":1,"105":1,"106":190,"107":16,"108":174,"109":1,"110":508,"111":83,"112":83,"113":425,"114":425,"115":0,"116":0,"117":425,"118":1,"119":425,"120":31,"121":425,"122":31,"123":425,"124":31,"125":425,"126":1,"127":425,"128":109,"129":425,"130":109,"131":425,"132":119,"133":425,"134":1,"135":86,"136":86,"137":2,"138":2,"139":84,"140":86,"141":86,"142":86,"143":86,"144":86,"145":86,"146":86,"147":1,"148":2,"149":1,"150":3,"151":1,"152":0,"153":1,"154":2,"155":1,"156":1,"157":1,"158":1,"159":14,"160":1,"161":1,"162":1,"163":15,"164":5,"165":2,"166":2,"167":2,"168":3,"169":2,"170":2,"171":1,"172":1,"173":4,"174":10,"175":10,"176":8,"177":2,"178":2,"179":2,"180":1,"181":2,"182":8,"183":1,"184":2,"185":1183,"186":1183,"187":1,"188":1,"189":1,"190":1,"191":1,"192":1,"193":1,"194":1,"195":1,"196":1,"197":5,"198":5,"199":1,"200":1,"201":1,"202":3,"203":1,"204":7,"205":1,"206":3,"207":3,"208":2,"209":2,"210":1,"211":1,"212":1,"213":19,"214":1,"215":151,"216":150,"217":150,"218":330,"219":330,"220":330,"221":330,"222":226,"223":330,"224":330,"225":330,"226":100,"227":230,"228":69,"229":330,"230":177,"231":153,"232":34,"233":150,"234":119,"235":150,"236":1,"237":11,"238":1,"239":10,"240":1,"241":7,"242":1,"243":1,"244":1,"245":4,"246":1,"247":1470,"248":1470,"249":1450,"250":1,"251":1,"252":1,"253":2,"254":2,"255":1,"256":1,"257":1,"258":1,"259":1,"260":1,"261":10,"262":1,"263":1498,"264":4446,"265":3,"266":4443,"267":2,"268":4,"269":5,"270":1,"271":11,"272":1,"273":7,"274":1,"275":1460,"276":2,"277":0,"278":3,"279":3,"280":1424,"281":39,"282":5,"283":3,"284":1418,"285":37,"286":1,"287":5,"288":6,"289":2,"290":1,"291":1,"292":1,"293":0,"294":0,"295":0,"296":0,"297":0,"298":0,"299":0,"300":1,"301":2958,"302":1470,"303":1470,"304":1460,"305":1498,"306":1498},"b":{"1":[2871,1460],"2":[119,216],"3":[96,23],"4":[67,52],"5":[565,0],"6":[330,234],"7":[565,336,335],"8":[398,0],"9":[1,1],"10":[2,0],"11":[2,0],"12":[2,1],"13":[0,155],"14":[0,70],"15":[2,46],"16":[0,37],"17":[10,1841],"18":[2,12],"19":[4,8],"20":[12,9],"21":[2,2],"22":[5,7],"23":[5,6],"24":[11,9],"25":[2,5],"26":[7,7],"27":[1,54],"28":[17,396],"29":[0,1],"30":[16,174],"31":[83,425],"32":[0,425],"33":[0,0],"34":[1,424],"35":[31,394],"36":[31,394],"37":[31,394],"38":[1,424],"39":[109,316],"40":[109,316],"41":[119,306],"42":[2,84],"43":[86,0],"44":[1,2],"45":[0,1],"46":[0,0],"47":[1,1],"48":[5,10],"49":[2,3],"50":[2,0],"51":[2,1],"52":[1,1],"53":[8,2],"54":[2,0],"55":[1,1],"56":[1183,1],"57":[168,1015],"58":[168,0],"59":[5,0],"60":[5,1],"61":[3,1],"62":[2,1],"63":[19,0],"64":[330,0],"65":[226,104],"66":[330,329,229,228],"67":[100,230],"68":[69,161],"69":[177,153],"70":[330,211,210,208,207],"71":[34,119],"72":[153,152,150,149],"73":[119,31],"74":[1,1,1,1,1,1,1,4],"75":[1450,1,1,1,1,2,1,1,1,1,1,10],"76":[3,4443],"77":[2,4,5,1,11,1,7,1,1460,2,0,0,3,3,1424,39,5,3,1418,37,1,5,6,2,1,1,1,0,0,0,0,0,0,0,0],"78":[2,0],"79":[2,0],"80":[4,0],"81":[4,0],"82":[1,0],"83":[5,0],"84":[0,0],"85":[1470,1488],"86":[2958,2958,2944],"87":[1460,10],"88":[1484,14]},"f":{"1":1,"2":4331,"3":151,"4":335,"5":2100,"6":3,"7":25,"8":408,"9":398,"10":1,"11":2,"12":2,"13":2,"14":155,"15":70,"16":48,"17":37,"18":1851,"19":14,"20":55,"21":413,"22":1,"23":190,"24":508,"25":86,"26":2,"27":3,"28":1,"29":14,"30":1,"31":15,"32":2,"33":1183,"34":1,"35":1,"36":1,"37":5,"38":1,"39":3,"40":7,"41":3,"42":19,"43":151,"44":11,"45":10,"46":7,"47":1470,"48":1498,"49":4446,"50":2958},"fnMap":{"1":{"name":"(anonymous_1)","line":1,"loc":{"start":{"line":1,"column":1},"end":{"line":1,"column":13}}},"2":{"name":"(anonymous_2)","line":4,"loc":{"start":{"line":4,"column":6},"end":{"line":4,"column":22}}},"3":{"name":"(anonymous_3)","line":11,"loc":{"start":{"line":11,"column":28},"end":{"line":11,"column":43}}},"4":{"name":"(anonymous_4)","line":13,"loc":{"start":{"line":13,"column":13},"end":{"line":13,"column":42}}},"5":{"name":"(anonymous_5)","line":38,"loc":{"start":{"line":38,"column":16},"end":{"line":38,"column":28}}},"6":{"name":"(anonymous_6)","line":50,"loc":{"start":{"line":50,"column":19},"end":{"line":50,"column":31}}},"7":{"name":"(anonymous_7)","line":62,"loc":{"start":{"line":62,"column":12},"end":{"line":62,"column":24}}},"8":{"name":"(anonymous_8)","line":71,"loc":{"start":{"line":71,"column":16},"end":{"line":71,"column":32}}},"9":{"name":"(anonymous_9)","line":80,"loc":{"start":{"line":80,"column":13},"end":{"line":80,"column":29}}},"10":{"name":"(anonymous_10)","line":90,"loc":{"start":{"line":90,"column":14},"end":{"line":90,"column":36}}},"11":{"name":"(anonymous_11)","line":99,"loc":{"start":{"line":99,"column":14},"end":{"line":99,"column":30}}},"12":{"name":"(anonymous_12)","line":108,"loc":{"start":{"line":108,"column":15},"end":{"line":108,"column":31}}},"13":{"name":"(anonymous_13)","line":123,"loc":{"start":{"line":123,"column":29},"end":{"line":123,"column":45}}},"14":{"name":"(anonymous_14)","line":132,"loc":{"start":{"line":132,"column":22},"end":{"line":132,"column":39}}},"15":{"name":"(anonymous_15)","line":143,"loc":{"start":{"line":143,"column":17},"end":{"line":143,"column":34}}},"16":{"name":"(anonymous_16)","line":153,"loc":{"start":{"line":153,"column":17},"end":{"line":153,"column":34}}},"17":{"name":"(anonymous_17)","line":163,"loc":{"start":{"line":163,"column":15},"end":{"line":163,"column":32}}},"18":{"name":"(anonymous_18)","line":173,"loc":{"start":{"line":173,"column":14},"end":{"line":173,"column":31}}},"19":{"name":"(anonymous_19)","line":184,"loc":{"start":{"line":184,"column":18},"end":{"line":184,"column":35}}},"20":{"name":"(anonymous_20)","line":217,"loc":{"start":{"line":217,"column":15},"end":{"line":217,"column":32}}},"21":{"name":"(anonymous_21)","line":228,"loc":{"start":{"line":228,"column":16},"end":{"line":228,"column":33}}},"22":{"name":"(anonymous_22)","line":237,"loc":{"start":{"line":237,"column":18},"end":{"line":237,"column":35}}},"23":{"name":"(anonymous_23)","line":250,"loc":{"start":{"line":250,"column":15},"end":{"line":250,"column":32}}},"24":{"name":"(anonymous_24)","line":266,"loc":{"start":{"line":266,"column":10},"end":{"line":266,"column":28}}},"25":{"name":"(anonymous_25)","line":314,"loc":{"start":{"line":314,"column":14},"end":{"line":314,"column":29}}},"26":{"name":"(anonymous_26)","line":349,"loc":{"start":{"line":349,"column":17},"end":{"line":349,"column":29}}},"27":{"name":"(anonymous_27)","line":358,"loc":{"start":{"line":358,"column":14},"end":{"line":358,"column":27}}},"28":{"name":"(anonymous_28)","line":370,"loc":{"start":{"line":370,"column":17},"end":{"line":370,"column":32}}},"29":{"name":"(anonymous_29)","line":375,"loc":{"start":{"line":375,"column":17},"end":{"line":375,"column":29}}},"30":{"name":"(anonymous_30)","line":379,"loc":{"start":{"line":379,"column":27},"end":{"line":379,"column":39}}},"31":{"name":"(anonymous_31)","line":389,"loc":{"start":{"line":389,"column":26},"end":{"line":389,"column":59}}},"32":{"name":"(anonymous_32)","line":421,"loc":{"start":{"line":421,"column":15},"end":{"line":421,"column":49}}},"33":{"name":"(anonymous_33)","line":422,"loc":{"start":{"line":422,"column":9},"end":{"line":422,"column":34}}},"34":{"name":"(anonymous_34)","line":445,"loc":{"start":{"line":445,"column":18},"end":{"line":445,"column":30}}},"35":{"name":"(anonymous_35)","line":453,"loc":{"start":{"line":453,"column":23},"end":{"line":453,"column":35}}},"36":{"name":"(anonymous_36)","line":461,"loc":{"start":{"line":461,"column":18},"end":{"line":461,"column":30}}},"37":{"name":"(anonymous_37)","line":465,"loc":{"start":{"line":465,"column":24},"end":{"line":465,"column":42}}},"38":{"name":"(anonymous_38)","line":470,"loc":{"start":{"line":470,"column":18},"end":{"line":470,"column":36}}},"39":{"name":"(anonymous_39)","line":478,"loc":{"start":{"line":478,"column":28},"end":{"line":478,"column":40}}},"40":{"name":"(anonymous_40)","line":486,"loc":{"start":{"line":486,"column":27},"end":{"line":486,"column":39}}},"41":{"name":"(anonymous_41)","line":494,"loc":{"start":{"line":494,"column":19},"end":{"line":494,"column":37}}},"42":{"name":"(anonymous_42)","line":510,"loc":{"start":{"line":510,"column":17},"end":{"line":510,"column":33}}},"43":{"name":"(anonymous_43)","line":526,"loc":{"start":{"line":526,"column":10},"end":{"line":526,"column":28}}},"44":{"name":"(anonymous_44)","line":562,"loc":{"start":{"line":562,"column":28},"end":{"line":562,"column":40}}},"45":{"name":"(anonymous_45)","line":570,"loc":{"start":{"line":570,"column":27},"end":{"line":570,"column":39}}},"46":{"name":"(anonymous_46)","line":631,"loc":{"start":{"line":631,"column":11},"end":{"line":631,"column":24}}},"47":{"name":"(anonymous_47)","line":647,"loc":{"start":{"line":647,"column":28},"end":{"line":647,"column":46}}},"48":{"name":"(anonymous_48)","line":677,"loc":{"start":{"line":677,"column":33},"end":{"line":677,"column":52}}},"49":{"name":"(anonymous_49)","line":678,"loc":{"start":{"line":678,"column":9},"end":{"line":678,"column":22}}},"50":{"name":"(anonymous_50)","line":755,"loc":{"start":{"line":755,"column":15},"end":{"line":755,"column":50}}}},"statementMap":{"1":{"start":{"line":1,"column":0},"end":{"line":769,"column":5}},"2":{"start":{"line":2,"column":1},"end":{"line":9,"column":4}},"3":{"start":{"line":5,"column":3},"end":{"line":7,"column":4}},"4":{"start":{"line":6,"column":4},"end":{"line":6,"column":10}},"5":{"start":{"line":8,"column":3},"end":{"line":8,"column":36}},"6":{"start":{"line":11,"column":1},"end":{"line":32,"column":3}},"7":{"start":{"line":12,"column":2},"end":{"line":12,"column":47}},"8":{"start":{"line":13,"column":2},"end":{"line":21,"column":4}},"9":{"start":{"line":14,"column":3},"end":{"line":20,"column":4}},"10":{"start":{"line":15,"column":4},"end":{"line":15,"column":72}},"11":{"start":{"line":16,"column":4},"end":{"line":16,"column":72}},"12":{"start":{"line":17,"column":4},"end":{"line":17,"column":40}},"13":{"start":{"line":19,"column":4},"end":{"line":19,"column":27}},"14":{"start":{"line":22,"column":2},"end":{"line":30,"column":3}},"15":{"start":{"line":23,"column":3},"end":{"line":29,"column":4}},"16":{"start":{"line":24,"column":4},"end":{"line":24,"column":73}},"17":{"start":{"line":26,"column":4},"end":{"line":28,"column":5}},"18":{"start":{"line":27,"column":5},"end":{"line":27,"column":30}},"19":{"start":{"line":31,"column":2},"end":{"line":31,"column":16}},"20":{"start":{"line":38,"column":1},"end":{"line":44,"column":3}},"21":{"start":{"line":39,"column":2},"end":{"line":39,"column":19}},"22":{"start":{"line":40,"column":2},"end":{"line":40,"column":21}},"23":{"start":{"line":41,"column":2},"end":{"line":41,"column":21}},"24":{"start":{"line":42,"column":2},"end":{"line":42,"column":26}},"25":{"start":{"line":43,"column":2},"end":{"line":43,"column":14}},"26":{"start":{"line":50,"column":1},"end":{"line":57,"column":3}},"27":{"start":{"line":51,"column":2},"end":{"line":51,"column":21}},"28":{"start":{"line":52,"column":2},"end":{"line":52,"column":30}},"29":{"start":{"line":53,"column":2},"end":{"line":53,"column":34}},"30":{"start":{"line":54,"column":2},"end":{"line":54,"column":34}},"31":{"start":{"line":55,"column":2},"end":{"line":55,"column":44}},"32":{"start":{"line":56,"column":2},"end":{"line":56,"column":14}},"33":{"start":{"line":62,"column":1},"end":{"line":64,"column":3}},"34":{"start":{"line":63,"column":2},"end":{"line":63,"column":34}},"35":{"start":{"line":71,"column":1},"end":{"line":73,"column":3}},"36":{"start":{"line":72,"column":2},"end":{"line":72,"column":34}},"37":{"start":{"line":80,"column":1},"end":{"line":82,"column":3}},"38":{"start":{"line":81,"column":2},"end":{"line":81,"column":69}},"39":{"start":{"line":90,"column":1},"end":{"line":92,"column":3}},"40":{"start":{"line":91,"column":2},"end":{"line":91,"column":78}},"41":{"start":{"line":99,"column":1},"end":{"line":101,"column":3}},"42":{"start":{"line":100,"column":2},"end":{"line":100,"column":50}},"43":{"start":{"line":108,"column":1},"end":{"line":110,"column":3}},"44":{"start":{"line":109,"column":2},"end":{"line":109,"column":53}},"45":{"start":{"line":123,"column":1},"end":{"line":125,"column":3}},"46":{"start":{"line":124,"column":2},"end":{"line":124,"column":83}},"47":{"start":{"line":132,"column":1},"end":{"line":136,"column":3}},"48":{"start":{"line":133,"column":2},"end":{"line":133,"column":30}},"49":{"start":{"line":133,"column":16},"end":{"line":133,"column":28}},"50":{"start":{"line":134,"column":2},"end":{"line":134,"column":43}},"51":{"start":{"line":135,"column":2},"end":{"line":135,"column":14}},"52":{"start":{"line":143,"column":1},"end":{"line":146,"column":3}},"53":{"start":{"line":144,"column":2},"end":{"line":144,"column":30}},"54":{"start":{"line":144,"column":16},"end":{"line":144,"column":28}},"55":{"start":{"line":145,"column":2},"end":{"line":145,"column":44}},"56":{"start":{"line":153,"column":1},"end":{"line":156,"column":3}},"57":{"start":{"line":154,"column":2},"end":{"line":154,"column":30}},"58":{"start":{"line":154,"column":16},"end":{"line":154,"column":28}},"59":{"start":{"line":155,"column":2},"end":{"line":155,"column":45}},"60":{"start":{"line":163,"column":1},"end":{"line":166,"column":3}},"61":{"start":{"line":164,"column":2},"end":{"line":164,"column":30}},"62":{"start":{"line":164,"column":16},"end":{"line":164,"column":28}},"63":{"start":{"line":165,"column":2},"end":{"line":165,"column":47}},"64":{"start":{"line":173,"column":1},"end":{"line":177,"column":3}},"65":{"start":{"line":174,"column":2},"end":{"line":174,"column":30}},"66":{"start":{"line":174,"column":16},"end":{"line":174,"column":28}},"67":{"start":{"line":175,"column":2},"end":{"line":175,"column":43}},"68":{"start":{"line":176,"column":2},"end":{"line":176,"column":14}},"69":{"start":{"line":184,"column":1},"end":{"line":210,"column":3}},"70":{"start":{"line":185,"column":2},"end":{"line":185,"column":30}},"71":{"start":{"line":185,"column":16},"end":{"line":185,"column":28}},"72":{"start":{"line":186,"column":2},"end":{"line":186,"column":26}},"73":{"start":{"line":187,"column":2},"end":{"line":187,"column":45}},"74":{"start":{"line":188,"column":2},"end":{"line":194,"column":3}},"75":{"start":{"line":189,"column":3},"end":{"line":193,"column":4}},"76":{"start":{"line":190,"column":4},"end":{"line":190,"column":25}},"77":{"start":{"line":191,"column":4},"end":{"line":191,"column":21}},"78":{"start":{"line":192,"column":4},"end":{"line":192,"column":24}},"79":{"start":{"line":196,"column":2},"end":{"line":207,"column":3}},"80":{"start":{"line":197,"column":3},"end":{"line":203,"column":4}},"81":{"start":{"line":198,"column":4},"end":{"line":198,"column":21}},"82":{"start":{"line":199,"column":4},"end":{"line":199,"column":24}},"83":{"start":{"line":200,"column":4},"end":{"line":202,"column":5}},"84":{"start":{"line":201,"column":5},"end":{"line":201,"column":13}},"85":{"start":{"line":204,"column":3},"end":{"line":204,"column":15}},"86":{"start":{"line":205,"column":9},"end":{"line":207,"column":3}},"87":{"start":{"line":206,"column":3},"end":{"line":206,"column":31}},"88":{"start":{"line":209,"column":2},"end":{"line":209,"column":29}},"89":{"start":{"line":217,"column":1},"end":{"line":220,"column":3}},"90":{"start":{"line":218,"column":2},"end":{"line":218,"column":30}},"91":{"start":{"line":218,"column":16},"end":{"line":218,"column":28}},"92":{"start":{"line":219,"column":2},"end":{"line":219,"column":33}},"93":{"start":{"line":228,"column":1},"end":{"line":235,"column":3}},"94":{"start":{"line":229,"column":2},"end":{"line":229,"column":30}},"95":{"start":{"line":229,"column":16},"end":{"line":229,"column":28}},"96":{"start":{"line":230,"column":2},"end":{"line":230,"column":25}},"97":{"start":{"line":231,"column":2},"end":{"line":231,"column":18}},"98":{"start":{"line":232,"column":2},"end":{"line":232,"column":45}},"99":{"start":{"line":233,"column":2},"end":{"line":233,"column":84}},"100":{"start":{"line":234,"column":2},"end":{"line":234,"column":14}},"101":{"start":{"line":237,"column":1},"end":{"line":243,"column":3}},"102":{"start":{"line":238,"column":2},"end":{"line":238,"column":30}},"103":{"start":{"line":238,"column":16},"end":{"line":238,"column":28}},"104":{"start":{"line":242,"column":2},"end":{"line":242,"column":35}},"105":{"start":{"line":250,"column":1},"end":{"line":253,"column":3}},"106":{"start":{"line":251,"column":2},"end":{"line":251,"column":30}},"107":{"start":{"line":251,"column":16},"end":{"line":251,"column":28}},"108":{"start":{"line":252,"column":2},"end":{"line":252,"column":36}},"109":{"start":{"line":266,"column":1},"end":{"line":306,"column":3}},"110":{"start":{"line":267,"column":2},"end":{"line":270,"column":3}},"111":{"start":{"line":268,"column":3},"end":{"line":268,"column":25}},"112":{"start":{"line":269,"column":3},"end":{"line":269,"column":15}},"113":{"start":{"line":272,"column":2},"end":{"line":272,"column":17}},"114":{"start":{"line":274,"column":2},"end":{"line":280,"column":3}},"115":{"start":{"line":277,"column":3},"end":{"line":279,"column":4}},"116":{"start":{"line":278,"column":4},"end":{"line":278,"column":24}},"117":{"start":{"line":281,"column":2},"end":{"line":283,"column":3}},"118":{"start":{"line":282,"column":3},"end":{"line":282,"column":40}},"119":{"start":{"line":284,"column":2},"end":{"line":286,"column":3}},"120":{"start":{"line":285,"column":3},"end":{"line":285,"column":30}},"121":{"start":{"line":287,"column":2},"end":{"line":289,"column":3}},"122":{"start":{"line":288,"column":3},"end":{"line":288,"column":30}},"123":{"start":{"line":290,"column":2},"end":{"line":292,"column":3}},"124":{"start":{"line":291,"column":3},"end":{"line":291,"column":26}},"125":{"start":{"line":293,"column":2},"end":{"line":295,"column":3}},"126":{"start":{"line":294,"column":3},"end":{"line":294,"column":26}},"127":{"start":{"line":296,"column":2},"end":{"line":298,"column":3}},"128":{"start":{"line":297,"column":3},"end":{"line":297,"column":28}},"129":{"start":{"line":299,"column":2},"end":{"line":301,"column":3}},"130":{"start":{"line":300,"column":3},"end":{"line":300,"column":26}},"131":{"start":{"line":302,"column":2},"end":{"line":304,"column":3}},"132":{"start":{"line":303,"column":3},"end":{"line":303,"column":24}},"133":{"start":{"line":305,"column":2},"end":{"line":305,"column":14}},"134":{"start":{"line":314,"column":1},"end":{"line":342,"column":3}},"135":{"start":{"line":316,"column":2},"end":{"line":316,"column":46}},"136":{"start":{"line":317,"column":2},"end":{"line":322,"column":3}},"137":{"start":{"line":318,"column":3},"end":{"line":318,"column":49}},"138":{"start":{"line":319,"column":3},"end":{"line":319,"column":25}},"139":{"start":{"line":321,"column":3},"end":{"line":321,"column":15}},"140":{"start":{"line":325,"column":2},"end":{"line":325,"column":38}},"141":{"start":{"line":329,"column":2},"end":{"line":329,"column":47}},"142":{"start":{"line":331,"column":2},"end":{"line":331,"column":39}},"143":{"start":{"line":334,"column":2},"end":{"line":334,"column":24}},"144":{"start":{"line":336,"column":2},"end":{"line":338,"column":3}},"145":{"start":{"line":337,"column":3},"end":{"line":337,"column":59}},"146":{"start":{"line":341,"column":2},"end":{"line":341,"column":61}},"147":{"start":{"line":349,"column":1},"end":{"line":351,"column":3}},"148":{"start":{"line":350,"column":2},"end":{"line":350,"column":31}},"149":{"start":{"line":358,"column":1},"end":{"line":368,"column":3}},"150":{"start":{"line":359,"column":2},"end":{"line":367,"column":3}},"151":{"start":{"line":360,"column":3},"end":{"line":364,"column":4}},"152":{"start":{"line":361,"column":4},"end":{"line":361,"column":65}},"153":{"start":{"line":363,"column":4},"end":{"line":363,"column":16}},"154":{"start":{"line":366,"column":3},"end":{"line":366,"column":93}},"155":{"start":{"line":370,"column":1},"end":{"line":373,"column":3}},"156":{"start":{"line":371,"column":2},"end":{"line":371,"column":42}},"157":{"start":{"line":372,"column":2},"end":{"line":372,"column":33}},"158":{"start":{"line":375,"column":1},"end":{"line":377,"column":3}},"159":{"start":{"line":376,"column":2},"end":{"line":376,"column":31}},"160":{"start":{"line":379,"column":1},"end":{"line":381,"column":3}},"161":{"start":{"line":380,"column":2},"end":{"line":380,"column":41}},"162":{"start":{"line":389,"column":1},"end":{"line":418,"column":3}},"163":{"start":{"line":390,"column":2},"end":{"line":405,"column":3}},"164":{"start":{"line":391,"column":3},"end":{"line":403,"column":4}},"165":{"start":{"line":392,"column":4},"end":{"line":392,"column":33}},"166":{"start":{"line":393,"column":4},"end":{"line":395,"column":5}},"167":{"start":{"line":394,"column":5},"end":{"line":394,"column":21}},"168":{"start":{"line":396,"column":10},"end":{"line":403,"column":4}},"169":{"start":{"line":397,"column":4},"end":{"line":397,"column":32}},"170":{"start":{"line":398,"column":4},"end":{"line":400,"column":5}},"171":{"start":{"line":399,"column":5},"end":{"line":399,"column":21}},"172":{"start":{"line":402,"column":4},"end":{"line":402,"column":16}},"173":{"start":{"line":404,"column":3},"end":{"line":404,"column":39}},"174":{"start":{"line":406,"column":2},"end":{"line":406,"column":16}},"175":{"start":{"line":407,"column":2},"end":{"line":416,"column":3}},"176":{"start":{"line":408,"column":3},"end":{"line":408,"column":26}},"177":{"start":{"line":410,"column":7},"end":{"line":416,"column":3}},"178":{"start":{"line":411,"column":3},"end":{"line":411,"column":31}},"179":{"start":{"line":412,"column":3},"end":{"line":414,"column":4}},"180":{"start":{"line":413,"column":4},"end":{"line":413,"column":40}},"181":{"start":{"line":415,"column":3},"end":{"line":415,"column":15}},"182":{"start":{"line":417,"column":2},"end":{"line":417,"column":97}},"183":{"start":{"line":421,"column":1},"end":{"line":426,"column":3}},"184":{"start":{"line":422,"column":2},"end":{"line":425,"column":4}},"185":{"start":{"line":423,"column":3},"end":{"line":423,"column":71}},"186":{"start":{"line":424,"column":3},"end":{"line":424,"column":77}},"187":{"start":{"line":433,"column":1},"end":{"line":433,"column":54}},"188":{"start":{"line":440,"column":1},"end":{"line":440,"column":55}},"189":{"start":{"line":445,"column":1},"end":{"line":448,"column":3}},"190":{"start":{"line":446,"column":2},"end":{"line":446,"column":27}},"191":{"start":{"line":447,"column":2},"end":{"line":447,"column":18}},"192":{"start":{"line":453,"column":1},"end":{"line":455,"column":3}},"193":{"start":{"line":454,"column":2},"end":{"line":454,"column":99}},"194":{"start":{"line":461,"column":1},"end":{"line":463,"column":3}},"195":{"start":{"line":462,"column":2},"end":{"line":462,"column":86}},"196":{"start":{"line":465,"column":1},"end":{"line":468,"column":3}},"197":{"start":{"line":466,"column":2},"end":{"line":466,"column":72}},"198":{"start":{"line":467,"column":2},"end":{"line":467,"column":71}},"199":{"start":{"line":470,"column":1},"end":{"line":472,"column":3}},"200":{"start":{"line":471,"column":2},"end":{"line":471,"column":62}},"201":{"start":{"line":478,"column":1},"end":{"line":480,"column":3}},"202":{"start":{"line":479,"column":2},"end":{"line":479,"column":129}},"203":{"start":{"line":486,"column":1},"end":{"line":488,"column":3}},"204":{"start":{"line":487,"column":2},"end":{"line":487,"column":95}},"205":{"start":{"line":494,"column":1},"end":{"line":503,"column":3}},"206":{"start":{"line":495,"column":2},"end":{"line":495,"column":60}},"207":{"start":{"line":496,"column":2},"end":{"line":502,"column":3}},"208":{"start":{"line":497,"column":3},"end":{"line":497,"column":30}},"209":{"start":{"line":498,"column":3},"end":{"line":498,"column":36}},"210":{"start":{"line":500,"column":3},"end":{"line":500,"column":30}},"211":{"start":{"line":501,"column":3},"end":{"line":501,"column":28}},"212":{"start":{"line":510,"column":1},"end":{"line":512,"column":3}},"213":{"start":{"line":511,"column":2},"end":{"line":511,"column":37}},"214":{"start":{"line":526,"column":1},"end":{"line":556,"column":3}},"215":{"start":{"line":527,"column":2},"end":{"line":527,"column":51}},"216":{"start":{"line":528,"column":2},"end":{"line":528,"column":10}},"217":{"start":{"line":529,"column":2},"end":{"line":549,"column":3}},"218":{"start":{"line":530,"column":3},"end":{"line":548,"column":4}},"219":{"start":{"line":531,"column":4},"end":{"line":531,"column":58}},"220":{"start":{"line":532,"column":4},"end":{"line":532,"column":25}},"221":{"start":{"line":533,"column":4},"end":{"line":535,"column":5}},"222":{"start":{"line":534,"column":5},"end":{"line":534,"column":17}},"223":{"start":{"line":536,"column":4},"end":{"line":536,"column":27}},"224":{"start":{"line":537,"column":4},"end":{"line":537,"column":27}},"225":{"start":{"line":538,"column":4},"end":{"line":542,"column":5}},"226":{"start":{"line":539,"column":5},"end":{"line":539,"column":29}},"227":{"start":{"line":540,"column":11},"end":{"line":542,"column":5}},"228":{"start":{"line":541,"column":5},"end":{"line":541,"column":29}},"229":{"start":{"line":543,"column":4},"end":{"line":547,"column":5}},"230":{"start":{"line":544,"column":6},"end":{"line":544,"column":51}},"231":{"start":{"line":545,"column":11},"end":{"line":547,"column":5}},"232":{"start":{"line":546,"column":5},"end":{"line":546,"column":35}},"233":{"start":{"line":551,"column":2},"end":{"line":553,"column":3}},"234":{"start":{"line":552,"column":3},"end":{"line":552,"column":45}},"235":{"start":{"line":555,"column":2},"end":{"line":555,"column":14}},"236":{"start":{"line":562,"column":1},"end":{"line":564,"column":3}},"237":{"start":{"line":563,"column":2},"end":{"line":563,"column":30}},"238":{"start":{"line":570,"column":1},"end":{"line":572,"column":3}},"239":{"start":{"line":571,"column":2},"end":{"line":571,"column":82}},"240":{"start":{"line":631,"column":1},"end":{"line":646,"column":3}},"241":{"start":{"line":632,"column":2},"end":{"line":645,"column":3}},"242":{"start":{"line":636,"column":3},"end":{"line":636,"column":15}},"243":{"start":{"line":639,"column":3},"end":{"line":639,"column":15}},"244":{"start":{"line":642,"column":3},"end":{"line":642,"column":15}},"245":{"start":{"line":644,"column":3},"end":{"line":644,"column":15}},"246":{"start":{"line":647,"column":1},"end":{"line":676,"column":3}},"247":{"start":{"line":648,"column":2},"end":{"line":648,"column":45}},"248":{"start":{"line":649,"column":2},"end":{"line":675,"column":3}},"249":{"start":{"line":651,"column":4},"end":{"line":651,"column":38}},"250":{"start":{"line":653,"column":4},"end":{"line":653,"column":37}},"251":{"start":{"line":655,"column":4},"end":{"line":655,"column":41}},"252":{"start":{"line":657,"column":4},"end":{"line":657,"column":37}},"253":{"start":{"line":660,"column":4},"end":{"line":660,"column":58}},"254":{"start":{"line":661,"column":4},"end":{"line":661,"column":42}},"255":{"start":{"line":663,"column":4},"end":{"line":663,"column":45}},"256":{"start":{"line":665,"column":4},"end":{"line":665,"column":38}},"257":{"start":{"line":667,"column":4},"end":{"line":667,"column":37}},"258":{"start":{"line":669,"column":4},"end":{"line":669,"column":58}},"259":{"start":{"line":670,"column":4},"end":{"line":670,"column":51}},"260":{"start":{"line":672,"column":4},"end":{"line":672,"column":38}},"261":{"start":{"line":674,"column":4},"end":{"line":674,"column":17}},"262":{"start":{"line":677,"column":1},"end":{"line":754,"column":3}},"263":{"start":{"line":678,"column":2},"end":{"line":753,"column":4}},"264":{"start":{"line":679,"column":3},"end":{"line":681,"column":4}},"265":{"start":{"line":680,"column":4},"end":{"line":680,"column":31}},"266":{"start":{"line":682,"column":3},"end":{"line":752,"column":4}},"267":{"start":{"line":684,"column":5},"end":{"line":684,"column":122}},"268":{"start":{"line":686,"column":5},"end":{"line":686,"column":119}},"269":{"start":{"line":688,"column":5},"end":{"line":688,"column":34}},"270":{"start":{"line":690,"column":5},"end":{"line":690,"column":31}},"271":{"start":{"line":692,"column":5},"end":{"line":692,"column":36}},"272":{"start":{"line":694,"column":5},"end":{"line":694,"column":33}},"273":{"start":{"line":696,"column":5},"end":{"line":696,"column":36}},"274":{"start":{"line":698,"column":5},"end":{"line":698,"column":33}},"275":{"start":{"line":700,"column":5},"end":{"line":700,"column":40}},"276":{"start":{"line":702,"column":5},"end":{"line":702,"column":37}},"277":{"start":{"line":704,"column":5},"end":{"line":704,"column":34}},"278":{"start":{"line":707,"column":5},"end":{"line":707,"column":56}},"279":{"start":{"line":709,"column":5},"end":{"line":709,"column":67}},"280":{"start":{"line":711,"column":5},"end":{"line":711,"column":33}},"281":{"start":{"line":713,"column":5},"end":{"line":713,"column":30}},"282":{"start":{"line":715,"column":5},"end":{"line":715,"column":60}},"283":{"start":{"line":717,"column":5},"end":{"line":717,"column":71}},"284":{"start":{"line":719,"column":5},"end":{"line":719,"column":40}},"285":{"start":{"line":721,"column":5},"end":{"line":721,"column":35}},"286":{"start":{"line":723,"column":5},"end":{"line":723,"column":132}},"287":{"start":{"line":725,"column":5},"end":{"line":725,"column":100}},"288":{"start":{"line":727,"column":5},"end":{"line":727,"column":35}},"289":{"start":{"line":729,"column":5},"end":{"line":729,"column":30}},"290":{"start":{"line":731,"column":5},"end":{"line":731,"column":33}},"291":{"start":{"line":733,"column":5},"end":{"line":733,"column":39}},"292":{"start":{"line":735,"column":5},"end":{"line":735,"column":41}},"293":{"start":{"line":737,"column":5},"end":{"line":737,"column":34}},"294":{"start":{"line":740,"column":5},"end":{"line":740,"column":58}},"295":{"start":{"line":742,"column":5},"end":{"line":742,"column":46}},"296":{"start":{"line":744,"column":5},"end":{"line":744,"column":29}},"297":{"start":{"line":746,"column":5},"end":{"line":746,"column":59}},"298":{"start":{"line":749,"column":5},"end":{"line":749,"column":115}},"299":{"start":{"line":751,"column":5},"end":{"line":751,"column":14}},"300":{"start":{"line":755,"column":1},"end":{"line":767,"column":3}},"301":{"start":{"line":759,"column":2},"end":{"line":764,"column":3}},"302":{"start":{"line":760,"column":3},"end":{"line":760,"column":52}},"303":{"start":{"line":761,"column":3},"end":{"line":763,"column":4}},"304":{"start":{"line":762,"column":4},"end":{"line":762,"column":18}},"305":{"start":{"line":765,"column":2},"end":{"line":765,"column":59}},"306":{"start":{"line":766,"column":2},"end":{"line":766,"column":177}}},"branchMap":{"1":{"line":5,"type":"if","locations":[{"start":{"line":5,"column":3},"end":{"line":5,"column":3}},{"start":{"line":5,"column":3},"end":{"line":5,"column":3}}]},"2":{"line":14,"type":"if","locations":[{"start":{"line":14,"column":3},"end":{"line":14,"column":3}},{"start":{"line":14,"column":3},"end":{"line":14,"column":3}}]},"3":{"line":15,"type":"cond-expr","locations":[{"start":{"line":15,"column":44},"end":{"line":15,"column":53}},{"start":{"line":15,"column":56},"end":{"line":15,"column":71}}]},"4":{"line":16,"type":"cond-expr","locations":[{"start":{"line":16,"column":42},"end":{"line":16,"column":50}},{"start":{"line":16,"column":53},"end":{"line":16,"column":71}}]},"5":{"line":23,"type":"if","locations":[{"start":{"line":23,"column":3},"end":{"line":23,"column":3}},{"start":{"line":23,"column":3},"end":{"line":23,"column":3}}]},"6":{"line":26,"type":"if","locations":[{"start":{"line":26,"column":4},"end":{"line":26,"column":4}},{"start":{"line":26,"column":4},"end":{"line":26,"column":4}}]},"7":{"line":26,"type":"binary-expr","locations":[{"start":{"line":26,"column":8},"end":{"line":26,"column":16}},{"start":{"line":26,"column":20},"end":{"line":26,"column":38}},{"start":{"line":26,"column":42},"end":{"line":26,"column":73}}]},"8":{"line":81,"type":"cond-expr","locations":[{"start":{"line":81,"column":49},"end":{"line":81,"column":53}},{"start":{"line":81,"column":56},"end":{"line":81,"column":66}}]},"9":{"line":91,"type":"binary-expr","locations":[{"start":{"line":91,"column":9},"end":{"line":91,"column":42}},{"start":{"line":91,"column":46},"end":{"line":91,"column":77}}]},"10":{"line":100,"type":"binary-expr","locations":[{"start":{"line":100,"column":24},"end":{"line":100,"column":28}},{"start":{"line":100,"column":32},"end":{"line":100,"column":42}}]},"11":{"line":109,"type":"binary-expr","locations":[{"start":{"line":109,"column":25},"end":{"line":109,"column":29}},{"start":{"line":109,"column":33},"end":{"line":109,"column":43}}]},"12":{"line":124,"type":"binary-expr","locations":[{"start":{"line":124,"column":42},"end":{"line":124,"column":46}},{"start":{"line":124,"column":50},"end":{"line":124,"column":60}}]},"13":{"line":133,"type":"if","locations":[{"start":{"line":133,"column":2},"end":{"line":133,"column":2}},{"start":{"line":133,"column":2},"end":{"line":133,"column":2}}]},"14":{"line":144,"type":"if","locations":[{"start":{"line":144,"column":2},"end":{"line":144,"column":2}},{"start":{"line":144,"column":2},"end":{"line":144,"column":2}}]},"15":{"line":154,"type":"if","locations":[{"start":{"line":154,"column":2},"end":{"line":154,"column":2}},{"start":{"line":154,"column":2},"end":{"line":154,"column":2}}]},"16":{"line":164,"type":"if","locations":[{"start":{"line":164,"column":2},"end":{"line":164,"column":2}},{"start":{"line":164,"column":2},"end":{"line":164,"column":2}}]},"17":{"line":174,"type":"if","locations":[{"start":{"line":174,"column":2},"end":{"line":174,"column":2}},{"start":{"line":174,"column":2},"end":{"line":174,"column":2}}]},"18":{"line":185,"type":"if","locations":[{"start":{"line":185,"column":2},"end":{"line":185,"column":2}},{"start":{"line":185,"column":2},"end":{"line":185,"column":2}}]},"19":{"line":188,"type":"if","locations":[{"start":{"line":188,"column":2},"end":{"line":188,"column":2}},{"start":{"line":188,"column":2},"end":{"line":188,"column":2}}]},"20":{"line":188,"type":"binary-expr","locations":[{"start":{"line":188,"column":6},"end":{"line":188,"column":15}},{"start":{"line":188,"column":19},"end":{"line":188,"column":28}}]},"21":{"line":189,"type":"if","locations":[{"start":{"line":189,"column":3},"end":{"line":189,"column":3}},{"start":{"line":189,"column":3},"end":{"line":189,"column":3}}]},"22":{"line":196,"type":"if","locations":[{"start":{"line":196,"column":2},"end":{"line":196,"column":2}},{"start":{"line":196,"column":2},"end":{"line":196,"column":2}}]},"23":{"line":200,"type":"if","locations":[{"start":{"line":200,"column":4},"end":{"line":200,"column":4}},{"start":{"line":200,"column":4},"end":{"line":200,"column":4}}]},"24":{"line":200,"type":"binary-expr","locations":[{"start":{"line":200,"column":8},"end":{"line":200,"column":17}},{"start":{"line":200,"column":21},"end":{"line":200,"column":30}}]},"25":{"line":205,"type":"if","locations":[{"start":{"line":205,"column":9},"end":{"line":205,"column":9}},{"start":{"line":205,"column":9},"end":{"line":205,"column":9}}]},"26":{"line":205,"type":"binary-expr","locations":[{"start":{"line":205,"column":13},"end":{"line":205,"column":22}},{"start":{"line":205,"column":26},"end":{"line":205,"column":42}}]},"27":{"line":218,"type":"if","locations":[{"start":{"line":218,"column":2},"end":{"line":218,"column":2}},{"start":{"line":218,"column":2},"end":{"line":218,"column":2}}]},"28":{"line":229,"type":"if","locations":[{"start":{"line":229,"column":2},"end":{"line":229,"column":2}},{"start":{"line":229,"column":2},"end":{"line":229,"column":2}}]},"29":{"line":238,"type":"if","locations":[{"start":{"line":238,"column":2},"end":{"line":238,"column":2}},{"start":{"line":238,"column":2},"end":{"line":238,"column":2}}]},"30":{"line":251,"type":"if","locations":[{"start":{"line":251,"column":2},"end":{"line":251,"column":2}},{"start":{"line":251,"column":2},"end":{"line":251,"column":2}}]},"31":{"line":267,"type":"if","locations":[{"start":{"line":267,"column":2},"end":{"line":267,"column":2}},{"start":{"line":267,"column":2},"end":{"line":267,"column":2}}]},"32":{"line":274,"type":"if","locations":[{"start":{"line":274,"column":2},"end":{"line":274,"column":2}},{"start":{"line":274,"column":2},"end":{"line":274,"column":2}}]},"33":{"line":277,"type":"if","locations":[{"start":{"line":277,"column":3},"end":{"line":277,"column":3}},{"start":{"line":277,"column":3},"end":{"line":277,"column":3}}]},"34":{"line":281,"type":"if","locations":[{"start":{"line":281,"column":2},"end":{"line":281,"column":2}},{"start":{"line":281,"column":2},"end":{"line":281,"column":2}}]},"35":{"line":284,"type":"if","locations":[{"start":{"line":284,"column":2},"end":{"line":284,"column":2}},{"start":{"line":284,"column":2},"end":{"line":284,"column":2}}]},"36":{"line":287,"type":"if","locations":[{"start":{"line":287,"column":2},"end":{"line":287,"column":2}},{"start":{"line":287,"column":2},"end":{"line":287,"column":2}}]},"37":{"line":290,"type":"if","locations":[{"start":{"line":290,"column":2},"end":{"line":290,"column":2}},{"start":{"line":290,"column":2},"end":{"line":290,"column":2}}]},"38":{"line":293,"type":"if","locations":[{"start":{"line":293,"column":2},"end":{"line":293,"column":2}},{"start":{"line":293,"column":2},"end":{"line":293,"column":2}}]},"39":{"line":296,"type":"if","locations":[{"start":{"line":296,"column":2},"end":{"line":296,"column":2}},{"start":{"line":296,"column":2},"end":{"line":296,"column":2}}]},"40":{"line":299,"type":"if","locations":[{"start":{"line":299,"column":2},"end":{"line":299,"column":2}},{"start":{"line":299,"column":2},"end":{"line":299,"column":2}}]},"41":{"line":302,"type":"if","locations":[{"start":{"line":302,"column":2},"end":{"line":302,"column":2}},{"start":{"line":302,"column":2},"end":{"line":302,"column":2}}]},"42":{"line":317,"type":"if","locations":[{"start":{"line":317,"column":2},"end":{"line":317,"column":2}},{"start":{"line":317,"column":2},"end":{"line":317,"column":2}}]},"43":{"line":336,"type":"if","locations":[{"start":{"line":336,"column":2},"end":{"line":336,"column":2}},{"start":{"line":336,"column":2},"end":{"line":336,"column":2}}]},"44":{"line":359,"type":"if","locations":[{"start":{"line":359,"column":2},"end":{"line":359,"column":2}},{"start":{"line":359,"column":2},"end":{"line":359,"column":2}}]},"45":{"line":360,"type":"if","locations":[{"start":{"line":360,"column":3},"end":{"line":360,"column":3}},{"start":{"line":360,"column":3},"end":{"line":360,"column":3}}]},"46":{"line":361,"type":"cond-expr","locations":[{"start":{"line":361,"column":56},"end":{"line":361,"column":58}},{"start":{"line":361,"column":61},"end":{"line":361,"column":62}}]},"47":{"line":366,"type":"cond-expr","locations":[{"start":{"line":366,"column":55},"end":{"line":366,"column":57}},{"start":{"line":366,"column":60},"end":{"line":366,"column":61}}]},"48":{"line":390,"type":"if","locations":[{"start":{"line":390,"column":2},"end":{"line":390,"column":2}},{"start":{"line":390,"column":2},"end":{"line":390,"column":2}}]},"49":{"line":391,"type":"if","locations":[{"start":{"line":391,"column":3},"end":{"line":391,"column":3}},{"start":{"line":391,"column":3},"end":{"line":391,"column":3}}]},"50":{"line":393,"type":"if","locations":[{"start":{"line":393,"column":4},"end":{"line":393,"column":4}},{"start":{"line":393,"column":4},"end":{"line":393,"column":4}}]},"51":{"line":396,"type":"if","locations":[{"start":{"line":396,"column":10},"end":{"line":396,"column":10}},{"start":{"line":396,"column":10},"end":{"line":396,"column":10}}]},"52":{"line":398,"type":"if","locations":[{"start":{"line":398,"column":4},"end":{"line":398,"column":4}},{"start":{"line":398,"column":4},"end":{"line":398,"column":4}}]},"53":{"line":407,"type":"if","locations":[{"start":{"line":407,"column":2},"end":{"line":407,"column":2}},{"start":{"line":407,"column":2},"end":{"line":407,"column":2}}]},"54":{"line":410,"type":"if","locations":[{"start":{"line":410,"column":7},"end":{"line":410,"column":7}},{"start":{"line":410,"column":7},"end":{"line":410,"column":7}}]},"55":{"line":412,"type":"if","locations":[{"start":{"line":412,"column":3},"end":{"line":412,"column":3}},{"start":{"line":412,"column":3},"end":{"line":412,"column":3}}]},"56":{"line":423,"type":"binary-expr","locations":[{"start":{"line":423,"column":49},"end":{"line":423,"column":55}},{"start":{"line":423,"column":59},"end":{"line":423,"column":61}}]},"57":{"line":424,"type":"cond-expr","locations":[{"start":{"line":424,"column":39},"end":{"line":424,"column":68}},{"start":{"line":424,"column":71},"end":{"line":424,"column":75}}]},"58":{"line":424,"type":"binary-expr","locations":[{"start":{"line":424,"column":55},"end":{"line":424,"column":61}},{"start":{"line":424,"column":65},"end":{"line":424,"column":67}}]},"59":{"line":467,"type":"cond-expr","locations":[{"start":{"line":467,"column":34},"end":{"line":467,"column":63}},{"start":{"line":467,"column":66},"end":{"line":467,"column":70}}]},"60":{"line":467,"type":"binary-expr","locations":[{"start":{"line":467,"column":10},"end":{"line":467,"column":15}},{"start":{"line":467,"column":19},"end":{"line":467,"column":30}}]},"61":{"line":495,"type":"binary-expr","locations":[{"start":{"line":495,"column":11},"end":{"line":495,"column":17}},{"start":{"line":495,"column":21},"end":{"line":495,"column":45}}]},"62":{"line":496,"type":"if","locations":[{"start":{"line":496,"column":2},"end":{"line":496,"column":2}},{"start":{"line":496,"column":2},"end":{"line":496,"column":2}}]},"63":{"line":511,"type":"binary-expr","locations":[{"start":{"line":511,"column":10},"end":{"line":511,"column":14}},{"start":{"line":511,"column":18},"end":{"line":511,"column":28}}]},"64":{"line":530,"type":"if","locations":[{"start":{"line":530,"column":3},"end":{"line":530,"column":3}},{"start":{"line":530,"column":3},"end":{"line":530,"column":3}}]},"65":{"line":533,"type":"if","locations":[{"start":{"line":533,"column":4},"end":{"line":533,"column":4}},{"start":{"line":533,"column":4},"end":{"line":533,"column":4}}]},"66":{"line":533,"type":"binary-expr","locations":[{"start":{"line":533,"column":8},"end":{"line":533,"column":22}},{"start":{"line":533,"column":26},"end":{"line":533,"column":41}},{"start":{"line":533,"column":45},"end":{"line":533,"column":63}},{"start":{"line":533,"column":67},"end":{"line":533,"column":91}}]},"67":{"line":538,"type":"if","locations":[{"start":{"line":538,"column":4},"end":{"line":538,"column":4}},{"start":{"line":538,"column":4},"end":{"line":538,"column":4}}]},"68":{"line":540,"type":"if","locations":[{"start":{"line":540,"column":11},"end":{"line":540,"column":11}},{"start":{"line":540,"column":11},"end":{"line":540,"column":11}}]},"69":{"line":543,"type":"if","locations":[{"start":{"line":543,"column":4},"end":{"line":543,"column":4}},{"start":{"line":543,"column":4},"end":{"line":543,"column":4}}]},"70":{"line":543,"type":"binary-expr","locations":[{"start":{"line":543,"column":8},"end":{"line":543,"column":21}},{"start":{"line":543,"column":25},"end":{"line":543,"column":43}},{"start":{"line":543,"column":47},"end":{"line":543,"column":71}},{"start":{"line":543,"column":76},"end":{"line":543,"column":90}},{"start":{"line":543,"column":95},"end":{"line":543,"column":109}}]},"71":{"line":545,"type":"if","locations":[{"start":{"line":545,"column":11},"end":{"line":545,"column":11}},{"start":{"line":545,"column":11},"end":{"line":545,"column":11}}]},"72":{"line":545,"type":"binary-expr","locations":[{"start":{"line":545,"column":16},"end":{"line":545,"column":34}},{"start":{"line":545,"column":37},"end":{"line":545,"column":61}},{"start":{"line":545,"column":65},"end":{"line":545,"column":79}},{"start":{"line":545,"column":83},"end":{"line":545,"column":97}}]},"73":{"line":551,"type":"if","locations":[{"start":{"line":551,"column":2},"end":{"line":551,"column":2}},{"start":{"line":551,"column":2},"end":{"line":551,"column":2}}]},"74":{"line":632,"type":"switch","locations":[{"start":{"line":633,"column":2},"end":{"line":633,"column":9}},{"start":{"line":634,"column":2},"end":{"line":634,"column":10}},{"start":{"line":635,"column":2},"end":{"line":636,"column":15}},{"start":{"line":637,"column":2},"end":{"line":637,"column":9}},{"start":{"line":638,"column":2},"end":{"line":639,"column":15}},{"start":{"line":640,"column":2},"end":{"line":640,"column":9}},{"start":{"line":641,"column":2},"end":{"line":642,"column":15}},{"start":{"line":643,"column":2},"end":{"line":644,"column":15}}]},"75":{"line":649,"type":"switch","locations":[{"start":{"line":650,"column":3},"end":{"line":651,"column":38}},{"start":{"line":652,"column":3},"end":{"line":653,"column":37}},{"start":{"line":654,"column":3},"end":{"line":655,"column":41}},{"start":{"line":656,"column":3},"end":{"line":657,"column":37}},{"start":{"line":658,"column":3},"end":{"line":658,"column":12}},{"start":{"line":659,"column":3},"end":{"line":661,"column":42}},{"start":{"line":662,"column":3},"end":{"line":663,"column":45}},{"start":{"line":664,"column":3},"end":{"line":665,"column":38}},{"start":{"line":666,"column":3},"end":{"line":667,"column":37}},{"start":{"line":668,"column":3},"end":{"line":670,"column":51}},{"start":{"line":671,"column":3},"end":{"line":672,"column":38}},{"start":{"line":673,"column":3},"end":{"line":674,"column":17}}]},"76":{"line":679,"type":"if","locations":[{"start":{"line":679,"column":3},"end":{"line":679,"column":3}},{"start":{"line":679,"column":3},"end":{"line":679,"column":3}}]},"77":{"line":682,"type":"switch","locations":[{"start":{"line":683,"column":4},"end":{"line":684,"column":122}},{"start":{"line":685,"column":4},"end":{"line":686,"column":119}},{"start":{"line":687,"column":4},"end":{"line":688,"column":34}},{"start":{"line":689,"column":4},"end":{"line":690,"column":31}},{"start":{"line":691,"column":4},"end":{"line":692,"column":36}},{"start":{"line":693,"column":4},"end":{"line":694,"column":33}},{"start":{"line":695,"column":4},"end":{"line":696,"column":36}},{"start":{"line":697,"column":4},"end":{"line":698,"column":33}},{"start":{"line":699,"column":4},"end":{"line":700,"column":40}},{"start":{"line":701,"column":4},"end":{"line":702,"column":37}},{"start":{"line":703,"column":4},"end":{"line":704,"column":34}},{"start":{"line":705,"column":4},"end":{"line":705,"column":13}},{"start":{"line":706,"column":4},"end":{"line":707,"column":56}},{"start":{"line":708,"column":4},"end":{"line":709,"column":67}},{"start":{"line":710,"column":4},"end":{"line":711,"column":33}},{"start":{"line":712,"column":4},"end":{"line":713,"column":30}},{"start":{"line":714,"column":4},"end":{"line":715,"column":60}},{"start":{"line":716,"column":4},"end":{"line":717,"column":71}},{"start":{"line":718,"column":4},"end":{"line":719,"column":40}},{"start":{"line":720,"column":4},"end":{"line":721,"column":35}},{"start":{"line":722,"column":4},"end":{"line":723,"column":132}},{"start":{"line":724,"column":4},"end":{"line":725,"column":100}},{"start":{"line":726,"column":4},"end":{"line":727,"column":35}},{"start":{"line":728,"column":4},"end":{"line":729,"column":30}},{"start":{"line":730,"column":4},"end":{"line":731,"column":33}},{"start":{"line":732,"column":4},"end":{"line":733,"column":39}},{"start":{"line":734,"column":4},"end":{"line":735,"column":41}},{"start":{"line":736,"column":4},"end":{"line":737,"column":34}},{"start":{"line":738,"column":4},"end":{"line":738,"column":13}},{"start":{"line":739,"column":4},"end":{"line":740,"column":58}},{"start":{"line":741,"column":4},"end":{"line":742,"column":46}},{"start":{"line":743,"column":4},"end":{"line":744,"column":29}},{"start":{"line":745,"column":4},"end":{"line":746,"column":59}},{"start":{"line":747,"column":4},"end":{"line":749,"column":115}},{"start":{"line":750,"column":4},"end":{"line":751,"column":14}}]},"78":{"line":684,"type":"cond-expr","locations":[{"start":{"line":684,"column":41},"end":{"line":684,"column":91}},{"start":{"line":684,"column":96},"end":{"line":684,"column":119}}]},"79":{"line":684,"type":"cond-expr","locations":[{"start":{"line":684,"column":68},"end":{"line":684,"column":70}},{"start":{"line":684,"column":73},"end":{"line":684,"column":91}}]},"80":{"line":686,"type":"cond-expr","locations":[{"start":{"line":686,"column":39},"end":{"line":686,"column":89}},{"start":{"line":686,"column":94},"end":{"line":686,"column":117}}]},"81":{"line":686,"type":"cond-expr","locations":[{"start":{"line":686,"column":66},"end":{"line":686,"column":68}},{"start":{"line":686,"column":71},"end":{"line":686,"column":89}}]},"82":{"line":723,"type":"cond-expr","locations":[{"start":{"line":723,"column":38},"end":{"line":723,"column":83}},{"start":{"line":723,"column":86},"end":{"line":723,"column":131}}]},"83":{"line":725,"type":"cond-expr","locations":[{"start":{"line":725,"column":38},"end":{"line":725,"column":67}},{"start":{"line":725,"column":70},"end":{"line":725,"column":99}}]},"84":{"line":746,"type":"cond-expr","locations":[{"start":{"line":746,"column":53},"end":{"line":746,"column":54}},{"start":{"line":746,"column":57},"end":{"line":746,"column":58}}]},"85":{"line":759,"type":"if","locations":[{"start":{"line":759,"column":2},"end":{"line":759,"column":2}},{"start":{"line":759,"column":2},"end":{"line":759,"column":2}}]},"86":{"line":759,"type":"binary-expr","locations":[{"start":{"line":759,"column":6},"end":{"line":759,"column":22}},{"start":{"line":759,"column":26},"end":{"line":759,"column":32}},{"start":{"line":759,"column":36},"end":{"line":759,"column":55}}]},"87":{"line":761,"type":"if","locations":[{"start":{"line":761,"column":3},"end":{"line":761,"column":3}},{"start":{"line":761,"column":3},"end":{"line":761,"column":3}}]},"88":{"line":766,"type":"cond-expr","locations":[{"start":{"line":766,"column":18},"end":{"line":766,"column":157}},{"start":{"line":766,"column":160},"end":{"line":766,"column":176}}]}}},"src/core/sugarpak.js":{"path":"src/core/sugarpak.js","s":{"1":1,"2":1,"3":1,"4":1,"5":1,"6":1,"7":1,"8":1,"9":1,"10":24,"11":24,"12":24,"13":1,"14":7,"15":1,"16":1137,"17":1137,"18":1137,"19":1,"20":7,"21":1,"22":34,"23":34,"24":1,"25":5,"26":5,"27":5,"28":1,"29":3,"30":1,"31":13,"32":1,"33":12,"34":4,"35":8,"36":7,"37":7,"38":1,"39":1,"40":3,"41":2,"42":2,"43":1,"44":1,"45":1,"46":1,"47":1,"48":1,"49":1,"50":1,"51":1,"52":1,"53":1,"54":1,"55":1,"56":10,"57":10,"58":100,"59":90,"60":10,"61":1,"62":1,"63":1,"64":1,"65":8,"66":1179,"67":20,"68":20,"69":1159,"70":1155,"71":1159,"72":4,"73":3,"74":4,"75":4,"76":4,"77":4,"78":4,"79":4,"80":1,"81":3,"82":1155,"83":1,"84":7,"85":8,"86":8,"87":0,"88":8,"89":1,"90":12,"91":17,"92":2,"93":2,"94":15,"95":1,"96":12,"97":12,"98":1,"99":2,"100":19,"101":19,"102":19,"103":1,"104":1,"105":1,"106":10,"107":89,"108":0,"109":0,"110":89,"111":5,"112":5,"113":5,"114":5,"115":31,"116":31,"117":1,"118":30,"119":4,"120":4,"121":84,"122":7,"123":84,"124":2,"125":84,"126":1,"127":9,"128":2,"129":2,"130":1,"131":10,"132":10,"133":9,"134":9,"135":1,"136":1,"137":6,"138":5,"139":0,"140":5,"141":0,"142":5,"143":5,"144":4,"145":4,"146":1,"147":1,"148":6},"b":{"1":[1,12],"2":[4,8],"3":[7,1],"4":[7,7],"5":[2,1],"6":[2,2],"7":[1,0],"8":[1,0],"9":[0,1],"10":[1,0],"11":[90,10],"12":[20,1159],"13":[1155,4],"14":[4,1155],"15":[3,1],"16":[1,3],"17":[0,8],"18":[8,0,0],"19":[2,15],"20":[0,89],"21":[5,84],"22":[5,3],"23":[5,0],"24":[1,30],"25":[4,26],"26":[7,77],"27":[2,82],"28":[9,1],"29":[0,5],"30":[0,5],"31":[5,5],"32":[4,1],"33":[5,4,0],"34":[1,5]},"f":{"1":1,"2":24,"3":7,"4":1137,"5":7,"6":34,"7":5,"8":3,"9":13,"10":3,"11":1,"12":1,"13":1,"14":10,"15":1,"16":8,"17":1179,"18":7,"19":8,"20":12,"21":17,"22":12,"23":12,"24":2,"25":10,"26":89,"27":9,"28":2,"29":6,"30":5},"fnMap":{"1":{"name":"(anonymous_1)","line":5,"loc":{"start":{"line":5,"column":1},"end":{"line":5,"column":13}}},"2":{"name":"(anonymous_2)","line":39,"loc":{"start":{"line":39,"column":11},"end":{"line":39,"column":23}}},"3":{"name":"(anonymous_3)","line":58,"loc":{"start":{"line":58,"column":11},"end":{"line":58,"column":23}}},"4":{"name":"(anonymous_4)","line":75,"loc":{"start":{"line":75,"column":35},"end":{"line":75,"column":47}}},"5":{"name":"(anonymous_5)","line":94,"loc":{"start":{"line":94,"column":35},"end":{"line":94,"column":47}}},"6":{"name":"(anonymous_6)","line":110,"loc":{"start":{"line":110,"column":9},"end":{"line":110,"column":21}}},"7":{"name":"(anonymous_7)","line":150,"loc":{"start":{"line":150,"column":11},"end":{"line":150,"column":23}}},"8":{"name":"(anonymous_8)","line":168,"loc":{"start":{"line":168,"column":12},"end":{"line":168,"column":24}}},"9":{"name":"(anonymous_9)","line":181,"loc":{"start":{"line":181,"column":14},"end":{"line":181,"column":26}}},"10":{"name":"(anonymous_10)","line":203,"loc":{"start":{"line":203,"column":14},"end":{"line":203,"column":26}}},"11":{"name":"(anonymous_11)","line":224,"loc":{"start":{"line":224,"column":9},"end":{"line":224,"column":25}}},"12":{"name":"(anonymous_12)","line":243,"loc":{"start":{"line":243,"column":25},"end":{"line":243,"column":41}}},"13":{"name":"(anonymous_13)","line":264,"loc":{"start":{"line":264,"column":22},"end":{"line":264,"column":38}}},"14":{"name":"(anonymous_14)","line":296,"loc":{"start":{"line":296,"column":15},"end":{"line":296,"column":27}}},"15":{"name":"(anonymous_15)","line":320,"loc":{"start":{"line":320,"column":17},"end":{"line":320,"column":34}}},"16":{"name":"(anonymous_16)","line":327,"loc":{"start":{"line":327,"column":10},"end":{"line":327,"column":23}}},"17":{"name":"(anonymous_17)","line":328,"loc":{"start":{"line":328,"column":9},"end":{"line":328,"column":21}}},"18":{"name":"(anonymous_18)","line":366,"loc":{"start":{"line":366,"column":11},"end":{"line":366,"column":24}}},"19":{"name":"(anonymous_19)","line":367,"loc":{"start":{"line":367,"column":9},"end":{"line":367,"column":21}}},"20":{"name":"(anonymous_20)","line":379,"loc":{"start":{"line":379,"column":32},"end":{"line":379,"column":45}}},"21":{"name":"(anonymous_21)","line":380,"loc":{"start":{"line":380,"column":9},"end":{"line":380,"column":21}}},"22":{"name":"(anonymous_22)","line":389,"loc":{"start":{"line":389,"column":30},"end":{"line":389,"column":43}}},"23":{"name":"(anonymous_23)","line":390,"loc":{"start":{"line":390,"column":9},"end":{"line":390,"column":21}}},"24":{"name":"(anonymous_24)","line":395,"loc":{"start":{"line":395,"column":20},"end":{"line":395,"column":63}}},"25":{"name":"(anonymous_25)","line":411,"loc":{"start":{"line":411,"column":10},"end":{"line":411,"column":23}}},"26":{"name":"(anonymous_26)","line":412,"loc":{"start":{"line":412,"column":9},"end":{"line":412,"column":21}}},"27":{"name":"(anonymous_27)","line":451,"loc":{"start":{"line":451,"column":10},"end":{"line":451,"column":23}}},"28":{"name":"(anonymous_28)","line":452,"loc":{"start":{"line":452,"column":9},"end":{"line":452,"column":21}}},"29":{"name":"(anonymous_29)","line":471,"loc":{"start":{"line":471,"column":13},"end":{"line":471,"column":26}}},"30":{"name":"(anonymous_30)","line":472,"loc":{"start":{"line":472,"column":9},"end":{"line":472,"column":30}}}},"statementMap":{"1":{"start":{"line":5,"column":0},"end":{"line":493,"column":5}},"2":{"start":{"line":6,"column":1},"end":{"line":6,"column":57}},"3":{"start":{"line":9,"column":1},"end":{"line":9,"column":17}},"4":{"start":{"line":12,"column":1},"end":{"line":12,"column":16}},"5":{"start":{"line":15,"column":1},"end":{"line":15,"column":16}},"6":{"start":{"line":18,"column":1},"end":{"line":18,"column":18}},"7":{"start":{"line":21,"column":1},"end":{"line":21,"column":22}},"8":{"start":{"line":24,"column":1},"end":{"line":24,"column":26}},"9":{"start":{"line":39,"column":1},"end":{"line":43,"column":3}},"10":{"start":{"line":40,"column":2},"end":{"line":40,"column":20}},"11":{"start":{"line":41,"column":2},"end":{"line":41,"column":20}},"12":{"start":{"line":42,"column":2},"end":{"line":42,"column":14}},"13":{"start":{"line":58,"column":1},"end":{"line":60,"column":3}},"14":{"start":{"line":59,"column":2},"end":{"line":59,"column":27}},"15":{"start":{"line":75,"column":1},"end":{"line":79,"column":3}},"16":{"start":{"line":76,"column":2},"end":{"line":76,"column":20}},"17":{"start":{"line":77,"column":2},"end":{"line":77,"column":20}},"18":{"start":{"line":78,"column":2},"end":{"line":78,"column":14}},"19":{"start":{"line":94,"column":1},"end":{"line":96,"column":3}},"20":{"start":{"line":95,"column":2},"end":{"line":95,"column":27}},"21":{"start":{"line":110,"column":1},"end":{"line":113,"column":3}},"22":{"start":{"line":111,"column":2},"end":{"line":111,"column":18}},"23":{"start":{"line":112,"column":2},"end":{"line":112,"column":14}},"24":{"start":{"line":150,"column":1},"end":{"line":154,"column":3}},"25":{"start":{"line":151,"column":2},"end":{"line":151,"column":20}},"26":{"start":{"line":152,"column":2},"end":{"line":152,"column":25}},"27":{"start":{"line":153,"column":2},"end":{"line":153,"column":14}},"28":{"start":{"line":168,"column":1},"end":{"line":170,"column":3}},"29":{"start":{"line":169,"column":2},"end":{"line":169,"column":27}},"30":{"start":{"line":181,"column":1},"end":{"line":193,"column":3}},"31":{"start":{"line":182,"column":2},"end":{"line":184,"column":3}},"32":{"start":{"line":183,"column":3},"end":{"line":183,"column":35}},"33":{"start":{"line":185,"column":2},"end":{"line":187,"column":3}},"34":{"start":{"line":186,"column":3},"end":{"line":186,"column":41}},"35":{"start":{"line":188,"column":2},"end":{"line":191,"column":3}},"36":{"start":{"line":189,"column":3},"end":{"line":189,"column":20}},"37":{"start":{"line":190,"column":3},"end":{"line":190,"column":49}},"38":{"start":{"line":192,"column":2},"end":{"line":192,"column":15}},"39":{"start":{"line":203,"column":1},"end":{"line":209,"column":3}},"40":{"start":{"line":204,"column":2},"end":{"line":207,"column":3}},"41":{"start":{"line":205,"column":3},"end":{"line":205,"column":20}},"42":{"start":{"line":206,"column":3},"end":{"line":206,"column":47}},"43":{"start":{"line":208,"column":2},"end":{"line":208,"column":15}},"44":{"start":{"line":224,"column":1},"end":{"line":226,"column":3}},"45":{"start":{"line":225,"column":2},"end":{"line":225,"column":97}},"46":{"start":{"line":243,"column":1},"end":{"line":247,"column":3}},"47":{"start":{"line":244,"column":2},"end":{"line":244,"column":13}},"48":{"start":{"line":245,"column":2},"end":{"line":245,"column":30}},"49":{"start":{"line":246,"column":2},"end":{"line":246,"column":54}},"50":{"start":{"line":264,"column":1},"end":{"line":269,"column":3}},"51":{"start":{"line":265,"column":2},"end":{"line":266,"column":108}},"52":{"start":{"line":267,"column":2},"end":{"line":267,"column":19}},"53":{"start":{"line":268,"column":2},"end":{"line":268,"column":54}},"54":{"start":{"line":273,"column":1},"end":{"line":278,"column":5}},"55":{"start":{"line":296,"column":1},"end":{"line":304,"column":3}},"56":{"start":{"line":297,"column":2},"end":{"line":297,"column":13}},"57":{"start":{"line":298,"column":2},"end":{"line":302,"column":3}},"58":{"start":{"line":299,"column":3},"end":{"line":301,"column":4}},"59":{"start":{"line":300,"column":4},"end":{"line":300,"column":52}},"60":{"start":{"line":303,"column":2},"end":{"line":303,"column":11}},"61":{"start":{"line":320,"column":1},"end":{"line":323,"column":3}},"62":{"start":{"line":321,"column":2},"end":{"line":321,"column":21}},"63":{"start":{"line":322,"column":2},"end":{"line":322,"column":34}},"64":{"start":{"line":327,"column":1},"end":{"line":364,"column":3}},"65":{"start":{"line":328,"column":2},"end":{"line":363,"column":4}},"66":{"start":{"line":329,"column":3},"end":{"line":332,"column":4}},"67":{"start":{"line":330,"column":4},"end":{"line":330,"column":21}},"68":{"start":{"line":331,"column":4},"end":{"line":331,"column":31}},"69":{"start":{"line":333,"column":3},"end":{"line":333,"column":41}},"70":{"start":{"line":333,"column":21},"end":{"line":333,"column":39}},"71":{"start":{"line":334,"column":3},"end":{"line":361,"column":4}},"72":{"start":{"line":347,"column":4},"end":{"line":349,"column":5}},"73":{"start":{"line":348,"column":5},"end":{"line":348,"column":40}},"74":{"start":{"line":351,"column":4},"end":{"line":351,"column":27}},"75":{"start":{"line":353,"column":4},"end":{"line":353,"column":26}},"76":{"start":{"line":354,"column":4},"end":{"line":354,"column":21}},"77":{"start":{"line":355,"column":4},"end":{"line":355,"column":51}},"78":{"start":{"line":356,"column":4},"end":{"line":356,"column":39}},"79":{"start":{"line":357,"column":4},"end":{"line":359,"column":5}},"80":{"start":{"line":358,"column":5},"end":{"line":358,"column":169}},"81":{"start":{"line":360,"column":4},"end":{"line":360,"column":16}},"82":{"start":{"line":362,"column":3},"end":{"line":362,"column":48}},"83":{"start":{"line":366,"column":1},"end":{"line":374,"column":3}},"84":{"start":{"line":367,"column":2},"end":{"line":373,"column":4}},"85":{"start":{"line":368,"column":3},"end":{"line":368,"column":46}},"86":{"start":{"line":369,"column":3},"end":{"line":371,"column":4}},"87":{"start":{"line":370,"column":4},"end":{"line":370,"column":22}},"88":{"start":{"line":372,"column":3},"end":{"line":372,"column":27}},"89":{"start":{"line":379,"column":1},"end":{"line":387,"column":3}},"90":{"start":{"line":380,"column":2},"end":{"line":386,"column":4}},"91":{"start":{"line":381,"column":3},"end":{"line":384,"column":4}},"92":{"start":{"line":382,"column":4},"end":{"line":382,"column":21}},"93":{"start":{"line":383,"column":4},"end":{"line":383,"column":33}},"94":{"start":{"line":385,"column":3},"end":{"line":385,"column":44}},"95":{"start":{"line":389,"column":1},"end":{"line":393,"column":3}},"96":{"start":{"line":390,"column":2},"end":{"line":392,"column":4}},"97":{"start":{"line":391,"column":3},"end":{"line":391,"column":47}},"98":{"start":{"line":395,"column":1},"end":{"line":405,"column":3}},"99":{"start":{"line":396,"column":2},"end":{"line":403,"column":3}},"100":{"start":{"line":398,"column":3},"end":{"line":398,"column":79}},"101":{"start":{"line":400,"column":3},"end":{"line":400,"column":63}},"102":{"start":{"line":402,"column":3},"end":{"line":402,"column":65}},"103":{"start":{"line":407,"column":1},"end":{"line":407,"column":27}},"104":{"start":{"line":408,"column":1},"end":{"line":408,"column":68}},"105":{"start":{"line":411,"column":1},"end":{"line":448,"column":3}},"106":{"start":{"line":412,"column":2},"end":{"line":447,"column":4}},"107":{"start":{"line":415,"column":3},"end":{"line":418,"column":4}},"108":{"start":{"line":416,"column":4},"end":{"line":416,"column":27}},"109":{"start":{"line":417,"column":4},"end":{"line":417,"column":16}},"110":{"start":{"line":420,"column":3},"end":{"line":440,"column":4}},"111":{"start":{"line":421,"column":4},"end":{"line":421,"column":34}},"112":{"start":{"line":422,"column":4},"end":{"line":425,"column":25}},"113":{"start":{"line":428,"column":4},"end":{"line":428,"column":64}},"114":{"start":{"line":430,"column":4},"end":{"line":438,"column":5}},"115":{"start":{"line":431,"column":5},"end":{"line":431,"column":29}},"116":{"start":{"line":432,"column":5},"end":{"line":434,"column":6}},"117":{"start":{"line":433,"column":6},"end":{"line":433,"column":19}},"118":{"start":{"line":435,"column":5},"end":{"line":437,"column":6}},"119":{"start":{"line":436,"column":6},"end":{"line":436,"column":12}},"120":{"start":{"line":439,"column":4},"end":{"line":439,"column":16}},"121":{"start":{"line":442,"column":3},"end":{"line":444,"column":4}},"122":{"start":{"line":443,"column":4},"end":{"line":443,"column":13}},"123":{"start":{"line":445,"column":3},"end":{"line":445,"column":41}},"124":{"start":{"line":445,"column":21},"end":{"line":445,"column":39}},"125":{"start":{"line":446,"column":3},"end":{"line":446,"column":40}},"126":{"start":{"line":451,"column":1},"end":{"line":456,"column":3}},"127":{"start":{"line":452,"column":2},"end":{"line":455,"column":4}},"128":{"start":{"line":453,"column":3},"end":{"line":453,"column":25}},"129":{"start":{"line":454,"column":3},"end":{"line":454,"column":15}},"130":{"start":{"line":458,"column":1},"end":{"line":467,"column":2}},"131":{"start":{"line":459,"column":2},"end":{"line":459,"column":27}},"132":{"start":{"line":460,"column":2},"end":{"line":466,"column":3}},"133":{"start":{"line":462,"column":3},"end":{"line":462,"column":37}},"134":{"start":{"line":465,"column":3},"end":{"line":465,"column":40}},"135":{"start":{"line":469,"column":1},"end":{"line":469,"column":23}},"136":{"start":{"line":471,"column":1},"end":{"line":488,"column":3}},"137":{"start":{"line":472,"column":2},"end":{"line":487,"column":4}},"138":{"start":{"line":473,"column":3},"end":{"line":475,"column":4}},"139":{"start":{"line":474,"column":4},"end":{"line":474,"column":34}},"140":{"start":{"line":476,"column":3},"end":{"line":478,"column":4}},"141":{"start":{"line":477,"column":4},"end":{"line":477,"column":50}},"142":{"start":{"line":479,"column":3},"end":{"line":479,"column":17}},"143":{"start":{"line":482,"column":3},"end":{"line":485,"column":4}},"144":{"start":{"line":483,"column":4},"end":{"line":483,"column":26}},"145":{"start":{"line":484,"column":4},"end":{"line":484,"column":41}},"146":{"start":{"line":486,"column":3},"end":{"line":486,"column":15}},"147":{"start":{"line":490,"column":1},"end":{"line":492,"column":2}},"148":{"start":{"line":491,"column":2},"end":{"line":491,"column":48}}},"branchMap":{"1":{"line":182,"type":"if","locations":[{"start":{"line":182,"column":2},"end":{"line":182,"column":2}},{"start":{"line":182,"column":2},"end":{"line":182,"column":2}}]},"2":{"line":185,"type":"if","locations":[{"start":{"line":185,"column":2},"end":{"line":185,"column":2}},{"start":{"line":185,"column":2},"end":{"line":185,"column":2}}]},"3":{"line":188,"type":"if","locations":[{"start":{"line":188,"column":2},"end":{"line":188,"column":2}},{"start":{"line":188,"column":2},"end":{"line":188,"column":2}}]},"4":{"line":190,"type":"binary-expr","locations":[{"start":{"line":190,"column":11},"end":{"line":190,"column":27}},{"start":{"line":190,"column":31},"end":{"line":190,"column":47}}]},"5":{"line":204,"type":"if","locations":[{"start":{"line":204,"column":2},"end":{"line":204,"column":2}},{"start":{"line":204,"column":2},"end":{"line":204,"column":2}}]},"6":{"line":206,"type":"binary-expr","locations":[{"start":{"line":206,"column":11},"end":{"line":206,"column":26}},{"start":{"line":206,"column":30},"end":{"line":206,"column":45}}]},"7":{"line":225,"type":"cond-expr","locations":[{"start":{"line":225,"column":38},"end":{"line":225,"column":79}},{"start":{"line":225,"column":82},"end":{"line":225,"column":96}}]},"8":{"line":246,"type":"cond-expr","locations":[{"start":{"line":246,"column":20},"end":{"line":246,"column":30}},{"start":{"line":246,"column":33},"end":{"line":246,"column":45}}]},"9":{"line":266,"type":"cond-expr","locations":[{"start":{"line":266,"column":64},"end":{"line":266,"column":87}},{"start":{"line":266,"column":90},"end":{"line":266,"column":107}}]},"10":{"line":268,"type":"cond-expr","locations":[{"start":{"line":268,"column":20},"end":{"line":268,"column":30}},{"start":{"line":268,"column":33},"end":{"line":268,"column":45}}]},"11":{"line":299,"type":"if","locations":[{"start":{"line":299,"column":3},"end":{"line":299,"column":3}},{"start":{"line":299,"column":3},"end":{"line":299,"column":3}}]},"12":{"line":329,"type":"if","locations":[{"start":{"line":329,"column":3},"end":{"line":329,"column":3}},{"start":{"line":329,"column":3},"end":{"line":329,"column":3}}]},"13":{"line":333,"type":"if","locations":[{"start":{"line":333,"column":3},"end":{"line":333,"column":3}},{"start":{"line":333,"column":3},"end":{"line":333,"column":3}}]},"14":{"line":334,"type":"if","locations":[{"start":{"line":334,"column":3},"end":{"line":334,"column":3}},{"start":{"line":334,"column":3},"end":{"line":334,"column":3}}]},"15":{"line":347,"type":"if","locations":[{"start":{"line":347,"column":4},"end":{"line":347,"column":4}},{"start":{"line":347,"column":4},"end":{"line":347,"column":4}}]},"16":{"line":357,"type":"if","locations":[{"start":{"line":357,"column":4},"end":{"line":357,"column":4}},{"start":{"line":357,"column":4},"end":{"line":357,"column":4}}]},"17":{"line":369,"type":"if","locations":[{"start":{"line":369,"column":3},"end":{"line":369,"column":3}},{"start":{"line":369,"column":3},"end":{"line":369,"column":3}}]},"18":{"line":369,"type":"binary-expr","locations":[{"start":{"line":369,"column":7},"end":{"line":369,"column":14}},{"start":{"line":369,"column":18},"end":{"line":369,"column":55}},{"start":{"line":369,"column":59},"end":{"line":369,"column":75}}]},"19":{"line":381,"type":"if","locations":[{"start":{"line":381,"column":3},"end":{"line":381,"column":3}},{"start":{"line":381,"column":3},"end":{"line":381,"column":3}}]},"20":{"line":415,"type":"if","locations":[{"start":{"line":415,"column":3},"end":{"line":415,"column":3}},{"start":{"line":415,"column":3},"end":{"line":415,"column":3}}]},"21":{"line":420,"type":"if","locations":[{"start":{"line":420,"column":3},"end":{"line":420,"column":3}},{"start":{"line":420,"column":3},"end":{"line":420,"column":3}}]},"22":{"line":423,"type":"binary-expr","locations":[{"start":{"line":423,"column":11},"end":{"line":423,"column":23}},{"start":{"line":423,"column":27},"end":{"line":423,"column":37}}]},"23":{"line":428,"type":"cond-expr","locations":[{"start":{"line":428,"column":34},"end":{"line":428,"column":59}},{"start":{"line":428,"column":62},"end":{"line":428,"column":63}}]},"24":{"line":432,"type":"if","locations":[{"start":{"line":432,"column":5},"end":{"line":432,"column":5}},{"start":{"line":432,"column":5},"end":{"line":432,"column":5}}]},"25":{"line":435,"type":"if","locations":[{"start":{"line":435,"column":5},"end":{"line":435,"column":5}},{"start":{"line":435,"column":5},"end":{"line":435,"column":5}}]},"26":{"line":442,"type":"if","locations":[{"start":{"line":442,"column":3},"end":{"line":442,"column":3}},{"start":{"line":442,"column":3},"end":{"line":442,"column":3}}]},"27":{"line":445,"type":"if","locations":[{"start":{"line":445,"column":3},"end":{"line":445,"column":3}},{"start":{"line":445,"column":3},"end":{"line":445,"column":3}}]},"28":{"line":460,"type":"if","locations":[{"start":{"line":460,"column":2},"end":{"line":460,"column":2}},{"start":{"line":460,"column":2},"end":{"line":460,"column":2}}]},"29":{"line":473,"type":"if","locations":[{"start":{"line":473,"column":3},"end":{"line":473,"column":3}},{"start":{"line":473,"column":3},"end":{"line":473,"column":3}}]},"30":{"line":476,"type":"if","locations":[{"start":{"line":476,"column":3},"end":{"line":476,"column":3}},{"start":{"line":476,"column":3},"end":{"line":476,"column":3}}]},"31":{"line":476,"type":"binary-expr","locations":[{"start":{"line":476,"column":7},"end":{"line":476,"column":16}},{"start":{"line":476,"column":20},"end":{"line":476,"column":35}}]},"32":{"line":482,"type":"if","locations":[{"start":{"line":482,"column":3},"end":{"line":482,"column":3}},{"start":{"line":482,"column":3},"end":{"line":482,"column":3}}]},"33":{"line":482,"type":"binary-expr","locations":[{"start":{"line":482,"column":7},"end":{"line":482,"column":14}},{"start":{"line":482,"column":19},"end":{"line":482,"column":42}},{"start":{"line":482,"column":46},"end":{"line":482,"column":64}}]},"34":{"line":491,"type":"cond-expr","locations":[{"start":{"line":491,"column":27},"end":{"line":491,"column":36}},{"start":{"line":491,"column":39},"end":{"line":491,"column":47}}]}}},"src/core/format_parser.js":{"path":"src/core/format_parser.js","s":{"1":1,"2":1,"3":39302,"4":1,"5":1,"6":1,"7":84,"8":1,"9":530,"10":530,"11":13780,"12":13780,"13":13780,"14":13780,"15":13780,"16":530,"17":17,"18":17,"19":17,"20":17,"21":17,"22":17,"23":17,"24":31,"25":17,"26":31,"27":403,"28":31,"29":31,"30":372,"31":31,"32":21,"33":21,"34":16,"35":5,"36":5,"37":2,"38":5,"39":21,"40":21,"41":84,"42":84,"43":84,"44":84,"45":84,"46":84,"47":53,"48":53,"49":84,"50":960,"51":960,"52":400,"53":240,"54":160,"55":560,"56":400,"57":160,"58":80,"59":80,"60":1200,"61":1200,"62":80,"63":8,"64":8,"65":4,"66":4,"67":4,"68":8,"69":80,"70":80,"71":48,"72":17,"73":17,"74":52,"75":40,"76":29,"77":80,"78":160,"79":160,"80":160,"81":160,"82":1440,"83":160,"84":1120,"85":1440,"86":320,"87":1120,"88":1120,"89":160,"90":160,"91":160,"92":1440,"93":1120,"94":320,"95":160,"96":1,"97":84,"98":84,"99":84,"100":84,"101":31,"102":53,"103":84,"104":84,"105":21,"106":84,"107":1,"108":454,"109":454,"110":374,"111":80,"112":80,"113":0,"114":80,"115":1,"116":573,"117":375,"118":375,"119":368,"120":7,"121":1,"122":1,"123":6,"124":6,"125":2,"126":4,"127":12,"128":4,"129":4,"130":4,"131":4,"132":4,"133":4,"134":4,"135":1,"136":160,"137":160,"138":160,"139":160,"140":160,"141":160,"142":160,"143":160,"144":160,"145":160,"146":5,"147":4,"148":4,"149":0,"150":0,"151":160,"152":160,"153":530,"154":2120,"155":530,"156":530,"157":530,"158":530,"159":530,"160":530,"161":0,"162":0,"163":530,"164":1},"b":{"1":[84,2,82],"2":[13780,0],"3":[0,13780],"4":[13250,530],"5":[0,17],"6":[17,0],"7":[1,16],"8":[0,17],"9":[17,14],"10":[31,372],"11":[403,403],"12":[0,31],"13":[16,5],"14":[21,6,1],"15":[5,5],"16":[2,3],"17":[84,1],"18":[84,21],"19":[84,29],"20":[84,41],"21":[84,55],"22":[53,31],"23":[84,34,17],"24":[53,3],"25":[53,11],"26":[400,560],"27":[240,160],"28":[121,119],"29":[65,95],"30":[400,160],"31":[214,186],"32":[9,151],"33":[160,9],"34":[1200,0],"35":[240,960],"36":[8,72],"37":[4,4],"38":[4,0],"39":[0,17],"40":[320,1120],"41":[1120,0],"42":[1120,320],"43":[2,82],"44":[31,53],"45":[84,34,17],"46":[21,63],"47":[374,80],"48":[454,80],"49":[0,80],"50":[80,80,0,0,0,0],"51":[573,82],"52":[368,7],"53":[375,7,0],"54":[1,6],"55":[7,2,1],"56":[2,4],"57":[6,4],"58":[4,4,4],"59":[4,1],"60":[0,530],"61":[530,158,40,2],"62":[0,0]},"f":{"1":1,"2":39302,"3":84,"4":530,"5":17,"6":31,"7":21,"8":84,"9":960,"10":80,"11":80,"12":48,"13":17,"14":52,"15":40,"16":29,"17":160,"18":1120,"19":1440,"20":160,"21":84,"22":454,"23":573,"24":375,"25":160,"26":160,"27":160,"28":160,"29":5,"30":4,"31":0,"32":0,"33":160,"34":530,"35":530},"fnMap":{"1":{"name":"(anonymous_1)","line":1,"loc":{"start":{"line":1,"column":1},"end":{"line":1,"column":13}}},"2":{"name":"(anonymous_2)","line":4,"loc":{"start":{"line":4,"column":13},"end":{"line":4,"column":26}}},"3":{"name":"(anonymous_3)","line":14,"loc":{"start":{"line":14,"column":17},"end":{"line":14,"column":32}}},"4":{"name":"(anonymous_4)","line":19,"loc":{"start":{"line":19,"column":17},"end":{"line":19,"column":39}}},"5":{"name":"(anonymous_5)","line":34,"loc":{"start":{"line":34,"column":25},"end":{"line":34,"column":40}}},"6":{"name":"(anonymous_6)","line":43,"loc":{"start":{"line":43,"column":17},"end":{"line":43,"column":43}}},"7":{"name":"(anonymous_7)","line":57,"loc":{"start":{"line":57,"column":22},"end":{"line":57,"column":43}}},"8":{"name":"(anonymous_8)","line":72,"loc":{"start":{"line":72,"column":16},"end":{"line":72,"column":31}}},"9":{"name":"(anonymous_9)","line":85,"loc":{"start":{"line":85,"column":11},"end":{"line":85,"column":54}}},"10":{"name":"(anonymous_10)","line":99,"loc":{"start":{"line":99,"column":19},"end":{"line":99,"column":34}}},"11":{"name":"(anonymous_11)","line":117,"loc":{"start":{"line":117,"column":27},"end":{"line":117,"column":43}}},"12":{"name":"(anonymous_12)","line":137,"loc":{"start":{"line":137,"column":12},"end":{"line":137,"column":27}}},"13":{"name":"(anonymous_13)","line":140,"loc":{"start":{"line":140,"column":14},"end":{"line":140,"column":30}}},"14":{"name":"(anonymous_14)","line":144,"loc":{"start":{"line":144,"column":14},"end":{"line":144,"column":30}}},"15":{"name":"(anonymous_15)","line":147,"loc":{"start":{"line":147,"column":14},"end":{"line":147,"column":30}}},"16":{"name":"(anonymous_16)","line":150,"loc":{"start":{"line":150,"column":19},"end":{"line":150,"column":35}}},"17":{"name":"(anonymous_17)","line":171,"loc":{"start":{"line":171,"column":13},"end":{"line":171,"column":41}}},"18":{"name":"(anonymous_18)","line":180,"loc":{"start":{"line":180,"column":16},"end":{"line":180,"column":34}}},"19":{"name":"(anonymous_19)","line":183,"loc":{"start":{"line":183,"column":20},"end":{"line":183,"column":44}}},"20":{"name":"(anonymous_20)","line":191,"loc":{"start":{"line":191,"column":18},"end":{"line":191,"column":35}}},"21":{"name":"(anonymous_21)","line":205,"loc":{"start":{"line":205,"column":24},"end":{"line":205,"column":39}}},"22":{"name":"(anonymous_22)","line":227,"loc":{"start":{"line":227,"column":10},"end":{"line":227,"column":23}}},"23":{"name":"(anonymous_23)","line":243,"loc":{"start":{"line":243,"column":13},"end":{"line":243,"column":25}}},"24":{"name":"(anonymous_24)","line":245,"loc":{"start":{"line":245,"column":9},"end":{"line":245,"column":22}}},"25":{"name":"(anonymous_25)","line":279,"loc":{"start":{"line":279,"column":13},"end":{"line":279,"column":25}}},"26":{"name":"(anonymous_26)","line":293,"loc":{"start":{"line":293,"column":21},"end":{"line":293,"column":32}}},"27":{"name":"(anonymous_27)","line":316,"loc":{"start":{"line":316,"column":9},"end":{"line":316,"column":19}}},"28":{"name":"(anonymous_28)","line":329,"loc":{"start":{"line":329,"column":23},"end":{"line":329,"column":35}}},"29":{"name":"(anonymous_29)","line":336,"loc":{"start":{"line":336,"column":14},"end":{"line":336,"column":30}}},"30":{"name":"(anonymous_30)","line":340,"loc":{"start":{"line":340,"column":4},"end":{"line":340,"column":23}}},"31":{"name":"(anonymous_31)","line":344,"loc":{"start":{"line":344,"column":23},"end":{"line":344,"column":40}}},"32":{"name":"(anonymous_32)","line":345,"loc":{"start":{"line":345,"column":23},"end":{"line":345,"column":40}}},"33":{"name":"(anonymous_33)","line":349,"loc":{"start":{"line":349,"column":20},"end":{"line":349,"column":32}}},"34":{"name":"(anonymous_34)","line":353,"loc":{"start":{"line":353,"column":22},"end":{"line":353,"column":35}}},"35":{"name":"(anonymous_35)","line":359,"loc":{"start":{"line":359,"column":9},"end":{"line":359,"column":22}}}},"statementMap":{"1":{"start":{"line":1,"column":0},"end":{"line":381,"column":5}},"2":{"start":{"line":3,"column":1},"end":{"line":7,"column":3}},"3":{"start":{"line":5,"column":3},"end":{"line":5,"column":68}},"4":{"start":{"line":8,"column":1},"end":{"line":8,"column":23}},"5":{"start":{"line":9,"column":1},"end":{"line":12,"column":3}},"6":{"start":{"line":14,"column":1},"end":{"line":16,"column":3}},"7":{"start":{"line":15,"column":2},"end":{"line":15,"column":72}},"8":{"start":{"line":18,"column":1},"end":{"line":203,"column":3}},"9":{"start":{"line":20,"column":3},"end":{"line":20,"column":11}},"10":{"start":{"line":21,"column":3},"end":{"line":31,"column":4}},"11":{"start":{"line":22,"column":4},"end":{"line":30,"column":5}},"12":{"start":{"line":23,"column":5},"end":{"line":23,"column":15}},"13":{"start":{"line":24,"column":5},"end":{"line":28,"column":6}},"14":{"start":{"line":27,"column":6},"end":{"line":27,"column":85}},"15":{"start":{"line":29,"column":5},"end":{"line":29,"column":35}},"16":{"start":{"line":32,"column":3},"end":{"line":32,"column":14}},"17":{"start":{"line":35,"column":3},"end":{"line":35,"column":23}},"18":{"start":{"line":36,"column":3},"end":{"line":36,"column":71}},"19":{"start":{"line":37,"column":3},"end":{"line":37,"column":32}},"20":{"start":{"line":38,"column":3},"end":{"line":38,"column":44}},"21":{"start":{"line":39,"column":3},"end":{"line":39,"column":19}},"22":{"start":{"line":40,"column":3},"end":{"line":40,"column":83}},"23":{"start":{"line":41,"column":3},"end":{"line":41,"column":14}},"24":{"start":{"line":44,"column":3},"end":{"line":46,"column":4}},"25":{"start":{"line":45,"column":4},"end":{"line":45,"column":42}},"26":{"start":{"line":47,"column":3},"end":{"line":54,"column":4}},"27":{"start":{"line":48,"column":4},"end":{"line":53,"column":5}},"28":{"start":{"line":49,"column":5},"end":{"line":49,"column":68}},"29":{"start":{"line":50,"column":5},"end":{"line":50,"column":11}},"30":{"start":{"line":52,"column":5},"end":{"line":52,"column":19}},"31":{"start":{"line":55,"column":3},"end":{"line":55,"column":14}},"32":{"start":{"line":58,"column":3},"end":{"line":58,"column":14}},"33":{"start":{"line":59,"column":3},"end":{"line":68,"column":4}},"34":{"start":{"line":61,"column":4},"end":{"line":61,"column":39}},"35":{"start":{"line":63,"column":4},"end":{"line":63,"column":59}},"36":{"start":{"line":64,"column":4},"end":{"line":66,"column":5}},"37":{"start":{"line":65,"column":5},"end":{"line":65,"column":18}},"38":{"start":{"line":67,"column":4},"end":{"line":67,"column":39}},"39":{"start":{"line":69,"column":3},"end":{"line":69,"column":45}},"40":{"start":{"line":70,"column":3},"end":{"line":70,"column":15}},"41":{"start":{"line":73,"column":3},"end":{"line":73,"column":53}},"42":{"start":{"line":74,"column":3},"end":{"line":74,"column":30}},"43":{"start":{"line":75,"column":3},"end":{"line":75,"column":34}},"44":{"start":{"line":76,"column":3},"end":{"line":76,"column":34}},"45":{"start":{"line":77,"column":3},"end":{"line":77,"column":44}},"46":{"start":{"line":78,"column":3},"end":{"line":82,"column":4}},"47":{"start":{"line":80,"column":4},"end":{"line":80,"column":31}},"48":{"start":{"line":81,"column":4},"end":{"line":81,"column":27}},"49":{"start":{"line":83,"column":3},"end":{"line":83,"column":14}},"50":{"start":{"line":86,"column":3},"end":{"line":86,"column":24}},"51":{"start":{"line":87,"column":3},"end":{"line":97,"column":4}},"52":{"start":{"line":88,"column":4},"end":{"line":92,"column":5}},"53":{"start":{"line":89,"column":5},"end":{"line":89,"column":38}},"54":{"start":{"line":91,"column":5},"end":{"line":91,"column":39}},"55":{"start":{"line":93,"column":10},"end":{"line":97,"column":4}},"56":{"start":{"line":94,"column":4},"end":{"line":94,"column":33}},"57":{"start":{"line":96,"column":4},"end":{"line":96,"column":66}},"58":{"start":{"line":100,"column":3},"end":{"line":100,"column":20}},"59":{"start":{"line":101,"column":3},"end":{"line":105,"column":4}},"60":{"start":{"line":102,"column":4},"end":{"line":104,"column":5}},"61":{"start":{"line":103,"column":5},"end":{"line":103,"column":124}},"62":{"start":{"line":106,"column":3},"end":{"line":114,"column":4}},"63":{"start":{"line":107,"column":4},"end":{"line":107,"column":63}},"64":{"start":{"line":108,"column":4},"end":{"line":112,"column":5}},"65":{"start":{"line":109,"column":5},"end":{"line":109,"column":40}},"66":{"start":{"line":110,"column":11},"end":{"line":112,"column":5}},"67":{"start":{"line":111,"column":5},"end":{"line":111,"column":40}},"68":{"start":{"line":113,"column":4},"end":{"line":113,"column":23}},"69":{"start":{"line":115,"column":3},"end":{"line":115,"column":18}},"70":{"start":{"line":118,"column":3},"end":{"line":168,"column":6}},"71":{"start":{"line":138,"column":6},"end":{"line":138,"column":20}},"72":{"start":{"line":141,"column":6},"end":{"line":141,"column":28}},"73":{"start":{"line":142,"column":6},"end":{"line":142,"column":37}},"74":{"start":{"line":145,"column":6},"end":{"line":145,"column":34}},"75":{"start":{"line":148,"column":6},"end":{"line":148,"column":69}},"76":{"start":{"line":151,"column":6},"end":{"line":151,"column":42}},"77":{"start":{"line":169,"column":3},"end":{"line":169,"column":15}},"78":{"start":{"line":172,"column":3},"end":{"line":172,"column":15}},"79":{"start":{"line":173,"column":3},"end":{"line":173,"column":15}},"80":{"start":{"line":174,"column":3},"end":{"line":174,"column":25}},"81":{"start":{"line":175,"column":3},"end":{"line":177,"column":4}},"82":{"start":{"line":176,"column":5},"end":{"line":176,"column":29}},"83":{"start":{"line":178,"column":3},"end":{"line":178,"column":15}},"84":{"start":{"line":181,"column":3},"end":{"line":181,"column":60}},"85":{"start":{"line":184,"column":3},"end":{"line":188,"column":4}},"86":{"start":{"line":185,"column":4},"end":{"line":185,"column":51}},"87":{"start":{"line":186,"column":10},"end":{"line":188,"column":4}},"88":{"start":{"line":187,"column":4},"end":{"line":187,"column":52}},"89":{"start":{"line":192,"column":3},"end":{"line":192,"column":16}},"90":{"start":{"line":193,"column":3},"end":{"line":193,"column":26}},"91":{"start":{"line":194,"column":3},"end":{"line":200,"column":4}},"92":{"start":{"line":195,"column":4},"end":{"line":199,"column":5}},"93":{"start":{"line":196,"column":5},"end":{"line":196,"column":59}},"94":{"start":{"line":198,"column":5},"end":{"line":198,"column":24}},"95":{"start":{"line":201,"column":3},"end":{"line":201,"column":14}},"96":{"start":{"line":205,"column":1},"end":{"line":223,"column":3}},"97":{"start":{"line":206,"column":2},"end":{"line":206,"column":22}},"98":{"start":{"line":208,"column":2},"end":{"line":208,"column":25}},"99":{"start":{"line":209,"column":2},"end":{"line":209,"column":80}},"100":{"start":{"line":211,"column":2},"end":{"line":215,"column":3}},"101":{"start":{"line":212,"column":3},"end":{"line":212,"column":38}},"102":{"start":{"line":214,"column":3},"end":{"line":214,"column":50}},"103":{"start":{"line":217,"column":2},"end":{"line":217,"column":103}},"104":{"start":{"line":219,"column":2},"end":{"line":221,"column":3}},"105":{"start":{"line":220,"column":3},"end":{"line":220,"column":38}},"106":{"start":{"line":222,"column":2},"end":{"line":222,"column":14}},"107":{"start":{"line":225,"column":1},"end":{"line":240,"column":3}},"108":{"start":{"line":228,"column":3},"end":{"line":228,"column":40}},"109":{"start":{"line":229,"column":3},"end":{"line":231,"column":4}},"110":{"start":{"line":230,"column":4},"end":{"line":230,"column":16}},"111":{"start":{"line":233,"column":3},"end":{"line":233,"column":46}},"112":{"start":{"line":235,"column":3},"end":{"line":237,"column":4}},"113":{"start":{"line":236,"column":4},"end":{"line":236,"column":16}},"114":{"start":{"line":238,"column":3},"end":{"line":238,"column":37}},"115":{"start":{"line":242,"column":1},"end":{"line":276,"column":3}},"116":{"start":{"line":243,"column":26},"end":{"line":243,"column":67}},"117":{"start":{"line":246,"column":3},"end":{"line":248,"column":56}},"118":{"start":{"line":249,"column":3},"end":{"line":252,"column":4}},"119":{"start":{"line":251,"column":4},"end":{"line":251,"column":16}},"120":{"start":{"line":253,"column":3},"end":{"line":256,"column":4}},"121":{"start":{"line":254,"column":4},"end":{"line":254,"column":18}},"122":{"start":{"line":255,"column":4},"end":{"line":255,"column":38}},"123":{"start":{"line":257,"column":3},"end":{"line":257,"column":30}},"124":{"start":{"line":258,"column":3},"end":{"line":260,"column":4}},"125":{"start":{"line":259,"column":4},"end":{"line":259,"column":16}},"126":{"start":{"line":261,"column":3},"end":{"line":273,"column":4}},"127":{"start":{"line":262,"column":4},"end":{"line":272,"column":5}},"128":{"start":{"line":264,"column":6},"end":{"line":264,"column":27}},"129":{"start":{"line":265,"column":6},"end":{"line":265,"column":12}},"130":{"start":{"line":267,"column":6},"end":{"line":267,"column":33}},"131":{"start":{"line":268,"column":6},"end":{"line":268,"column":12}},"132":{"start":{"line":270,"column":6},"end":{"line":270,"column":28}},"133":{"start":{"line":271,"column":6},"end":{"line":271,"column":12}},"134":{"start":{"line":274,"column":3},"end":{"line":274,"column":37}},"135":{"start":{"line":278,"column":1},"end":{"line":379,"column":3}},"136":{"start":{"line":280,"column":3},"end":{"line":280,"column":43}},"137":{"start":{"line":281,"column":3},"end":{"line":291,"column":6}},"138":{"start":{"line":294,"column":3},"end":{"line":294,"column":43}},"139":{"start":{"line":295,"column":3},"end":{"line":314,"column":5}},"140":{"start":{"line":317,"column":3},"end":{"line":327,"column":5}},"141":{"start":{"line":330,"column":3},"end":{"line":330,"column":43}},"142":{"start":{"line":331,"column":3},"end":{"line":331,"column":25}},"143":{"start":{"line":332,"column":3},"end":{"line":332,"column":114}},"144":{"start":{"line":333,"column":3},"end":{"line":333,"column":67}},"145":{"start":{"line":335,"column":3},"end":{"line":346,"column":5}},"146":{"start":{"line":337,"column":5},"end":{"line":337,"column":66}},"147":{"start":{"line":341,"column":5},"end":{"line":341,"column":51}},"148":{"start":{"line":342,"column":5},"end":{"line":342,"column":27}},"149":{"start":{"line":344,"column":41},"end":{"line":344,"column":51}},"150":{"start":{"line":345,"column":41},"end":{"line":345,"column":51}},"151":{"start":{"line":350,"column":3},"end":{"line":350,"column":30}},"152":{"start":{"line":351,"column":3},"end":{"line":351,"column":94}},"153":{"start":{"line":354,"column":3},"end":{"line":356,"column":4}},"154":{"start":{"line":355,"column":4},"end":{"line":355,"column":68}},"155":{"start":{"line":357,"column":3},"end":{"line":357,"column":12}},"156":{"start":{"line":360,"column":3},"end":{"line":360,"column":34}},"157":{"start":{"line":361,"column":3},"end":{"line":361,"column":47}},"158":{"start":{"line":363,"column":3},"end":{"line":375,"column":17}},"159":{"start":{"line":364,"column":4},"end":{"line":364,"column":43}},"160":{"start":{"line":365,"column":4},"end":{"line":374,"column":5}},"161":{"start":{"line":371,"column":6},"end":{"line":373,"column":7}},"162":{"start":{"line":372,"column":7},"end":{"line":372,"column":36}},"163":{"start":{"line":377,"column":3},"end":{"line":377,"column":12}},"164":{"start":{"line":380,"column":1},"end":{"line":380,"column":34}}},"branchMap":{"1":{"line":15,"type":"binary-expr","locations":[{"start":{"line":15,"column":11},"end":{"line":15,"column":25}},{"start":{"line":15,"column":31},"end":{"line":15,"column":47}},{"start":{"line":15,"column":54},"end":{"line":15,"column":70}}]},"2":{"line":22,"type":"if","locations":[{"start":{"line":22,"column":4},"end":{"line":22,"column":4}},{"start":{"line":22,"column":4},"end":{"line":22,"column":4}}]},"3":{"line":24,"type":"if","locations":[{"start":{"line":24,"column":5},"end":{"line":24,"column":5}},{"start":{"line":24,"column":5},"end":{"line":24,"column":5}}]},"4":{"line":27,"type":"cond-expr","locations":[{"start":{"line":27,"column":46},"end":{"line":27,"column":55}},{"start":{"line":27,"column":58},"end":{"line":27,"column":84}}]},"5":{"line":36,"type":"cond-expr","locations":[{"start":{"line":36,"column":55},"end":{"line":36,"column":56}},{"start":{"line":36,"column":59},"end":{"line":36,"column":70}}]},"6":{"line":36,"type":"binary-expr","locations":[{"start":{"line":36,"column":18},"end":{"line":36,"column":30}},{"start":{"line":36,"column":34},"end":{"line":36,"column":51}}]},"7":{"line":38,"type":"cond-expr","locations":[{"start":{"line":38,"column":29},"end":{"line":38,"column":30}},{"start":{"line":38,"column":33},"end":{"line":38,"column":43}}]},"8":{"line":40,"type":"cond-expr","locations":[{"start":{"line":40,"column":58},"end":{"line":40,"column":59}},{"start":{"line":40,"column":62},"end":{"line":40,"column":73}}]},"9":{"line":44,"type":"if","locations":[{"start":{"line":44,"column":3},"end":{"line":44,"column":3}},{"start":{"line":44,"column":3},"end":{"line":44,"column":3}}]},"10":{"line":48,"type":"if","locations":[{"start":{"line":48,"column":4},"end":{"line":48,"column":4}},{"start":{"line":48,"column":4},"end":{"line":48,"column":4}}]},"11":{"line":48,"type":"binary-expr","locations":[{"start":{"line":48,"column":8},"end":{"line":48,"column":36}},{"start":{"line":48,"column":40},"end":{"line":48,"column":62}}]},"12":{"line":49,"type":"cond-expr","locations":[{"start":{"line":49,"column":25},"end":{"line":49,"column":32}},{"start":{"line":49,"column":36},"end":{"line":49,"column":66}}]},"13":{"line":59,"type":"if","locations":[{"start":{"line":59,"column":3},"end":{"line":59,"column":3}},{"start":{"line":59,"column":3},"end":{"line":59,"column":3}}]},"14":{"line":59,"type":"binary-expr","locations":[{"start":{"line":59,"column":7},"end":{"line":59,"column":37}},{"start":{"line":59,"column":42},"end":{"line":59,"column":62}},{"start":{"line":59,"column":66},"end":{"line":59,"column":88}}]},"15":{"line":63,"type":"binary-expr","locations":[{"start":{"line":63,"column":36},"end":{"line":63,"column":52}},{"start":{"line":63,"column":56},"end":{"line":63,"column":57}}]},"16":{"line":64,"type":"if","locations":[{"start":{"line":64,"column":4},"end":{"line":64,"column":4}},{"start":{"line":64,"column":4},"end":{"line":64,"column":4}}]},"17":{"line":73,"type":"binary-expr","locations":[{"start":{"line":73,"column":14},"end":{"line":73,"column":22}},{"start":{"line":73,"column":26},"end":{"line":73,"column":52}}]},"18":{"line":74,"type":"binary-expr","locations":[{"start":{"line":74,"column":15},"end":{"line":74,"column":24}},{"start":{"line":74,"column":28},"end":{"line":74,"column":29}}]},"19":{"line":75,"type":"binary-expr","locations":[{"start":{"line":75,"column":17},"end":{"line":75,"column":28}},{"start":{"line":75,"column":32},"end":{"line":75,"column":33}}]},"20":{"line":76,"type":"binary-expr","locations":[{"start":{"line":76,"column":17},"end":{"line":76,"column":28}},{"start":{"line":76,"column":32},"end":{"line":76,"column":33}}]},"21":{"line":77,"type":"binary-expr","locations":[{"start":{"line":77,"column":22},"end":{"line":77,"column":38}},{"start":{"line":77,"column":42},"end":{"line":77,"column":43}}]},"22":{"line":78,"type":"if","locations":[{"start":{"line":78,"column":3},"end":{"line":78,"column":3}},{"start":{"line":78,"column":3},"end":{"line":78,"column":3}}]},"23":{"line":78,"type":"binary-expr","locations":[{"start":{"line":78,"column":9},"end":{"line":78,"column":19}},{"start":{"line":78,"column":24},"end":{"line":78,"column":32}},{"start":{"line":78,"column":36},"end":{"line":78,"column":49}}]},"24":{"line":80,"type":"binary-expr","locations":[{"start":{"line":80,"column":16},"end":{"line":80,"column":25}},{"start":{"line":80,"column":29},"end":{"line":80,"column":30}}]},"25":{"line":81,"type":"binary-expr","locations":[{"start":{"line":81,"column":14},"end":{"line":81,"column":21}},{"start":{"line":81,"column":25},"end":{"line":81,"column":26}}]},"26":{"line":87,"type":"if","locations":[{"start":{"line":87,"column":3},"end":{"line":87,"column":3}},{"start":{"line":87,"column":3},"end":{"line":87,"column":3}}]},"27":{"line":88,"type":"if","locations":[{"start":{"line":88,"column":4},"end":{"line":88,"column":4}},{"start":{"line":88,"column":4},"end":{"line":88,"column":4}}]},"28":{"line":89,"type":"cond-expr","locations":[{"start":{"line":89,"column":19},"end":{"line":89,"column":30}},{"start":{"line":89,"column":33},"end":{"line":89,"column":37}}]},"29":{"line":91,"type":"cond-expr","locations":[{"start":{"line":91,"column":19},"end":{"line":91,"column":31}},{"start":{"line":91,"column":34},"end":{"line":91,"column":38}}]},"30":{"line":93,"type":"if","locations":[{"start":{"line":93,"column":10},"end":{"line":93,"column":10}},{"start":{"line":93,"column":10},"end":{"line":93,"column":10}}]},"31":{"line":94,"type":"cond-expr","locations":[{"start":{"line":94,"column":18},"end":{"line":94,"column":25}},{"start":{"line":94,"column":28},"end":{"line":94,"column":32}}]},"32":{"line":96,"type":"cond-expr","locations":[{"start":{"line":96,"column":51},"end":{"line":96,"column":58}},{"start":{"line":96,"column":61},"end":{"line":96,"column":65}}]},"33":{"line":96,"type":"binary-expr","locations":[{"start":{"line":96,"column":12},"end":{"line":96,"column":16}},{"start":{"line":96,"column":20},"end":{"line":96,"column":47}}]},"34":{"line":102,"type":"if","locations":[{"start":{"line":102,"column":4},"end":{"line":102,"column":4}},{"start":{"line":102,"column":4},"end":{"line":102,"column":4}}]},"35":{"line":103,"type":"cond-expr","locations":[{"start":{"line":103,"column":34},"end":{"line":103,"column":45}},{"start":{"line":103,"column":48},"end":{"line":103,"column":123}}]},"36":{"line":106,"type":"if","locations":[{"start":{"line":106,"column":3},"end":{"line":106,"column":3}},{"start":{"line":106,"column":3},"end":{"line":106,"column":3}}]},"37":{"line":108,"type":"if","locations":[{"start":{"line":108,"column":4},"end":{"line":108,"column":4}},{"start":{"line":108,"column":4},"end":{"line":108,"column":4}}]},"38":{"line":110,"type":"if","locations":[{"start":{"line":110,"column":11},"end":{"line":110,"column":11}},{"start":{"line":110,"column":11},"end":{"line":110,"column":11}}]},"39":{"line":142,"type":"cond-expr","locations":[{"start":{"line":142,"column":27},"end":{"line":142,"column":28}},{"start":{"line":142,"column":31},"end":{"line":142,"column":35}}]},"40":{"line":184,"type":"if","locations":[{"start":{"line":184,"column":3},"end":{"line":184,"column":3}},{"start":{"line":184,"column":3},"end":{"line":184,"column":3}}]},"41":{"line":186,"type":"if","locations":[{"start":{"line":186,"column":10},"end":{"line":186,"column":10}},{"start":{"line":186,"column":10},"end":{"line":186,"column":10}}]},"42":{"line":195,"type":"if","locations":[{"start":{"line":195,"column":4},"end":{"line":195,"column":4}},{"start":{"line":195,"column":4},"end":{"line":195,"column":4}}]},"43":{"line":209,"type":"cond-expr","locations":[{"start":{"line":209,"column":42},"end":{"line":209,"column":57}},{"start":{"line":209,"column":60},"end":{"line":209,"column":79}}]},"44":{"line":211,"type":"if","locations":[{"start":{"line":211,"column":2},"end":{"line":211,"column":2}},{"start":{"line":211,"column":2},"end":{"line":211,"column":2}}]},"45":{"line":211,"type":"binary-expr","locations":[{"start":{"line":211,"column":6},"end":{"line":211,"column":16}},{"start":{"line":211,"column":21},"end":{"line":211,"column":29}},{"start":{"line":211,"column":33},"end":{"line":211,"column":46}}]},"46":{"line":219,"type":"if","locations":[{"start":{"line":219,"column":2},"end":{"line":219,"column":2}},{"start":{"line":219,"column":2},"end":{"line":219,"column":2}}]},"47":{"line":229,"type":"if","locations":[{"start":{"line":229,"column":3},"end":{"line":229,"column":3}},{"start":{"line":229,"column":3},"end":{"line":229,"column":3}}]},"48":{"line":229,"type":"binary-expr","locations":[{"start":{"line":229,"column":7},"end":{"line":229,"column":12}},{"start":{"line":229,"column":16},"end":{"line":229,"column":28}}]},"49":{"line":235,"type":"if","locations":[{"start":{"line":235,"column":3},"end":{"line":235,"column":3}},{"start":{"line":235,"column":3},"end":{"line":235,"column":3}}]},"50":{"line":235,"type":"binary-expr","locations":[{"start":{"line":235,"column":7},"end":{"line":235,"column":17}},{"start":{"line":235,"column":22},"end":{"line":235,"column":32}},{"start":{"line":235,"column":37},"end":{"line":235,"column":48}},{"start":{"line":235,"column":52},"end":{"line":235,"column":61}},{"start":{"line":235,"column":67},"end":{"line":235,"column":77}},{"start":{"line":235,"column":81},"end":{"line":235,"column":96}}]},"51":{"line":243,"type":"binary-expr","locations":[{"start":{"line":243,"column":32},"end":{"line":243,"column":53}},{"start":{"line":243,"column":55},"end":{"line":243,"column":66}}]},"52":{"line":249,"type":"if","locations":[{"start":{"line":249,"column":3},"end":{"line":249,"column":3}},{"start":{"line":249,"column":3},"end":{"line":249,"column":3}}]},"53":{"line":249,"type":"binary-expr","locations":[{"start":{"line":249,"column":7},"end":{"line":249,"column":27}},{"start":{"line":250,"column":5},"end":{"line":250,"column":17}},{"start":{"line":250,"column":21},"end":{"line":250,"column":33}}]},"54":{"line":253,"type":"if","locations":[{"start":{"line":253,"column":3},"end":{"line":253,"column":3}},{"start":{"line":253,"column":3},"end":{"line":253,"column":3}}]},"55":{"line":253,"type":"binary-expr","locations":[{"start":{"line":253,"column":7},"end":{"line":253,"column":19}},{"start":{"line":253,"column":23},"end":{"line":253,"column":41}},{"start":{"line":253,"column":45},"end":{"line":253,"column":63}}]},"56":{"line":258,"type":"if","locations":[{"start":{"line":258,"column":3},"end":{"line":258,"column":3}},{"start":{"line":258,"column":3},"end":{"line":258,"column":3}}]},"57":{"line":258,"type":"binary-expr","locations":[{"start":{"line":258,"column":7},"end":{"line":258,"column":12}},{"start":{"line":258,"column":16},"end":{"line":258,"column":28}}]},"58":{"line":262,"type":"switch","locations":[{"start":{"line":263,"column":5},"end":{"line":265,"column":12}},{"start":{"line":266,"column":5},"end":{"line":268,"column":12}},{"start":{"line":269,"column":5},"end":{"line":271,"column":12}}]},"59":{"line":337,"type":"cond-expr","locations":[{"start":{"line":337,"column":32},"end":{"line":337,"column":58}},{"start":{"line":337,"column":61},"end":{"line":337,"column":65}}]},"60":{"line":365,"type":"if","locations":[{"start":{"line":365,"column":4},"end":{"line":365,"column":4}},{"start":{"line":365,"column":4},"end":{"line":365,"column":4}}]},"61":{"line":365,"type":"binary-expr","locations":[{"start":{"line":365,"column":8},"end":{"line":365,"column":22}},{"start":{"line":366,"column":5},"end":{"line":366,"column":31}},{"start":{"line":367,"column":5},"end":{"line":367,"column":31}},{"start":{"line":368,"column":6},"end":{"line":368,"column":22}}]},"62":{"line":371,"type":"if","locations":[{"start":{"line":371,"column":6},"end":{"line":371,"column":6}},{"start":{"line":371,"column":6},"end":{"line":371,"column":6}}]}}},"src/core/parsing_operators.js":{"path":"src/core/parsing_operators.js","s":{"1":1,"2":1,"3":1,"4":10780,"5":25714,"6":25714,"7":4104,"8":21610,"9":0,"10":0,"11":217,"12":0,"13":0,"14":0,"15":0,"16":0,"17":0,"18":0,"19":0,"20":0,"21":0,"22":160,"23":20,"24":20,"25":147,"26":147,"27":0,"28":147,"29":147,"30":20,"31":480,"32":646,"33":646,"34":646,"35":646,"36":0,"37":480,"38":356,"39":356,"40":350,"41":6,"42":376,"43":1104,"44":1104,"45":43,"46":0,"47":0,"48":0,"49":0,"50":4000,"51":4000,"52":15483,"53":0,"54":0,"55":0,"56":0,"57":0,"58":4000,"59":15483,"60":15483,"61":15483,"62":5153,"63":15483,"64":15483,"65":15483,"66":14556,"67":927,"68":1601,"69":1601,"70":5498,"71":5498,"72":31059,"73":0,"74":31059,"75":31059,"76":29340,"77":31059,"78":1719,"79":3779,"80":1140,"81":1140,"82":14052,"83":14052,"84":15582,"85":0,"86":15582,"87":15582,"88":13450,"89":2132,"90":2132,"91":602,"92":0,"93":0,"94":160,"95":160,"96":160,"97":0,"98":160,"99":469,"100":469,"101":469,"102":471,"103":471,"104":457,"105":14,"106":14,"107":14,"108":12,"109":12,"110":2,"111":469,"112":457,"113":12,"114":0,"115":12,"116":0,"117":0,"118":0,"119":12,"120":0,"121":0,"122":0,"123":0,"124":0,"125":0,"126":0,"127":0,"128":2340,"129":2340,"130":2340,"131":2917,"132":2917,"133":6399,"134":6399,"135":6399,"136":6399,"137":6399,"138":6399,"139":3427,"140":2972,"141":2972,"142":1922,"143":1922,"144":542,"145":1050,"146":2972,"147":0,"148":2972,"149":1380,"150":1380,"151":7872,"152":6492,"153":1380,"154":1380,"155":1341,"156":1341,"157":2972,"158":2469,"159":2972,"160":2301,"161":2917,"162":508,"163":2409,"164":528,"165":528,"166":0,"167":528,"168":2409,"169":0,"170":0,"171":5440,"172":16998,"173":1169,"174":5300,"175":18800,"176":2744,"177":0,"178":0,"179":0,"180":0,"181":0,"182":1,"183":1,"184":5336,"185":5336,"186":0,"187":5336,"188":0,"189":5336,"190":0,"191":0,"192":0,"193":0,"194":0,"195":0,"196":5336,"197":4,"198":1,"199":1,"200":4,"201":1,"202":3,"203":2741,"204":0,"205":2741,"206":1,"207":1,"208":3},"b":{"1":[4104,21610],"2":[376,0],"3":[4000,4000],"4":[0,15483],"5":[0,0],"6":[15483,5571],"7":[14556,927],"8":[0,31059],"9":[1719,29340],"10":[0,15582],"11":[160,0],"12":[160,160],"13":[0,160],"14":[457,12],"15":[0,12],"16":[0,12],"17":[12,0],"18":[0,0],"19":[0,0],"20":[0,0],"21":[0,0],"22":[2340,320],"23":[2340,2180],"24":[1922,1050],"25":[2972,1922],"26":[0,2972],"27":[2972,1380],"28":[1380,1592],"29":[6492,1380],"30":[1341,39],"31":[2469,503],"32":[2301,671],"33":[508,2409],"34":[528,1881],"35":[0,0],"36":[0,5336],"37":[0,5336],"38":[0,5336],"39":[0,0],"40":[0,2741]},"f":{"1":1,"2":10780,"3":25714,"4":0,"5":0,"6":217,"7":0,"8":0,"9":160,"10":20,"11":480,"12":646,"13":480,"14":356,"15":376,"16":1104,"17":0,"18":4000,"19":15483,"20":15483,"21":1601,"22":5498,"23":1140,"24":14052,"25":0,"26":160,"27":469,"28":0,"29":0,"30":0,"31":2340,"32":2917,"33":0,"34":0,"35":5440,"36":16998,"37":5300,"38":18800,"39":0,"40":0,"41":4,"42":5336,"43":3,"44":2741},"fnMap":{"1":{"name":"(anonymous_1)","line":1,"loc":{"start":{"line":1,"column":1},"end":{"line":1,"column":13}}},"2":{"name":"(anonymous_2)","line":7,"loc":{"start":{"line":7,"column":10},"end":{"line":7,"column":23}}},"3":{"name":"(anonymous_3)","line":8,"loc":{"start":{"line":8,"column":10},"end":{"line":8,"column":23}}},"4":{"name":"(anonymous_4)","line":17,"loc":{"start":{"line":17,"column":9},"end":{"line":17,"column":21}}},"5":{"name":"(anonymous_5)","line":18,"loc":{"start":{"line":18,"column":10},"end":{"line":18,"column":23}}},"6":{"name":"(anonymous_6)","line":22,"loc":{"start":{"line":22,"column":10},"end":{"line":22,"column":23}}},"7":{"name":"(anonymous_7)","line":28,"loc":{"start":{"line":28,"column":9},"end":{"line":28,"column":22}}},"8":{"name":"(anonymous_8)","line":29,"loc":{"start":{"line":29,"column":10},"end":{"line":29,"column":23}}},"9":{"name":"(anonymous_9)","line":44,"loc":{"start":{"line":44,"column":8},"end":{"line":44,"column":21}}},"10":{"name":"(anonymous_10)","line":45,"loc":{"start":{"line":45,"column":10},"end":{"line":45,"column":23}}},"11":{"name":"(anonymous_11)","line":61,"loc":{"start":{"line":61,"column":12},"end":{"line":61,"column":25}}},"12":{"name":"(anonymous_12)","line":62,"loc":{"start":{"line":62,"column":10},"end":{"line":62,"column":23}}},"13":{"name":"(anonymous_13)","line":72,"loc":{"start":{"line":72,"column":7},"end":{"line":72,"column":20}}},"14":{"name":"(anonymous_14)","line":73,"loc":{"start":{"line":73,"column":10},"end":{"line":73,"column":23}}},"15":{"name":"(anonymous_15)","line":82,"loc":{"start":{"line":82,"column":10},"end":{"line":82,"column":23}}},"16":{"name":"(anonymous_16)","line":84,"loc":{"start":{"line":84,"column":3},"end":{"line":84,"column":16}}},"17":{"name":"(anonymous_17)","line":90,"loc":{"start":{"line":90,"column":11},"end":{"line":90,"column":23}}},"18":{"name":"(anonymous_18)","line":98,"loc":{"start":{"line":98,"column":9},"end":{"line":98,"column":25}}},"19":{"name":"(anonymous_19)","line":100,"loc":{"start":{"line":100,"column":20},"end":{"line":100,"column":32}}},"20":{"name":"(anonymous_20)","line":112,"loc":{"start":{"line":112,"column":10},"end":{"line":112,"column":23}}},"21":{"name":"(anonymous_21)","line":130,"loc":{"start":{"line":130,"column":7},"end":{"line":130,"column":19}}},"22":{"name":"(anonymous_22)","line":132,"loc":{"start":{"line":132,"column":10},"end":{"line":132,"column":23}}},"23":{"name":"(anonymous_23)","line":150,"loc":{"start":{"line":150,"column":8},"end":{"line":150,"column":20}}},"24":{"name":"(anonymous_24)","line":152,"loc":{"start":{"line":152,"column":10},"end":{"line":152,"column":23}}},"25":{"name":"(anonymous_25)","line":169,"loc":{"start":{"line":169,"column":7},"end":{"line":169,"column":19}}},"26":{"name":"(anonymous_26)","line":175,"loc":{"start":{"line":175,"column":12},"end":{"line":175,"column":32}}},"27":{"name":"(anonymous_27)","line":182,"loc":{"start":{"line":182,"column":10},"end":{"line":182,"column":23}}},"28":{"name":"(anonymous_28)","line":221,"loc":{"start":{"line":221,"column":11},"end":{"line":221,"column":32}}},"29":{"name":"(anonymous_29)","line":224,"loc":{"start":{"line":224,"column":10},"end":{"line":224,"column":23}}},"30":{"name":"(anonymous_30)","line":229,"loc":{"start":{"line":229,"column":8},"end":{"line":229,"column":27}}},"31":{"name":"(anonymous_31)","line":236,"loc":{"start":{"line":236,"column":7},"end":{"line":236,"column":27}}},"32":{"name":"(anonymous_32)","line":239,"loc":{"start":{"line":239,"column":10},"end":{"line":239,"column":23}}},"33":{"name":"(anonymous_33)","line":357,"loc":{"start":{"line":357,"column":11},"end":{"line":357,"column":32}}},"34":{"name":"(anonymous_34)","line":358,"loc":{"start":{"line":358,"column":10},"end":{"line":358,"column":23}}},"35":{"name":"(anonymous_35)","line":366,"loc":{"start":{"line":366,"column":11},"end":{"line":366,"column":33}}},"36":{"name":"(anonymous_36)","line":367,"loc":{"start":{"line":367,"column":10},"end":{"line":367,"column":23}}},"37":{"name":"(anonymous_37)","line":372,"loc":{"start":{"line":372,"column":11},"end":{"line":372,"column":31}}},"38":{"name":"(anonymous_38)","line":373,"loc":{"start":{"line":373,"column":10},"end":{"line":373,"column":23}}},"39":{"name":"(anonymous_39)","line":378,"loc":{"start":{"line":378,"column":7},"end":{"line":378,"column":28}}},"40":{"name":"(anonymous_40)","line":379,"loc":{"start":{"line":379,"column":10},"end":{"line":379,"column":23}}},"41":{"name":"(anonymous_41)","line":412,"loc":{"start":{"line":412,"column":18},"end":{"line":412,"column":32}}},"42":{"name":"gen","line":413,"loc":{"start":{"line":413,"column":2},"end":{"line":413,"column":17}}},"43":{"name":"(anonymous_43)","line":442,"loc":{"start":{"line":442,"column":15},"end":{"line":442,"column":29}}},"44":{"name":"(anonymous_44)","line":443,"loc":{"start":{"line":443,"column":9},"end":{"line":443,"column":21}}}},"statementMap":{"1":{"start":{"line":1,"column":0},"end":{"line":458,"column":5}},"2":{"start":{"line":2,"column":1},"end":{"line":2,"column":23}},"3":{"start":{"line":3,"column":1},"end":{"line":387,"column":3}},"4":{"start":{"line":8,"column":3},"end":{"line":15,"column":5}},"5":{"start":{"line":9,"column":4},"end":{"line":9,"column":24}},"6":{"start":{"line":10,"column":4},"end":{"line":14,"column":5}},"7":{"start":{"line":11,"column":5},"end":{"line":11,"column":51}},"8":{"start":{"line":13,"column":5},"end":{"line":13,"column":31}},"9":{"start":{"line":18,"column":3},"end":{"line":20,"column":5}},"10":{"start":{"line":19,"column":4},"end":{"line":19,"column":57}},"11":{"start":{"line":23,"column":3},"end":{"line":23,"column":40}},"12":{"start":{"line":29,"column":3},"end":{"line":42,"column":5}},"13":{"start":{"line":30,"column":4},"end":{"line":30,"column":27}},"14":{"start":{"line":31,"column":4},"end":{"line":40,"column":5}},"15":{"start":{"line":32,"column":5},"end":{"line":38,"column":6}},"16":{"start":{"line":33,"column":6},"end":{"line":33,"column":27}},"17":{"start":{"line":35,"column":6},"end":{"line":35,"column":21}},"18":{"start":{"line":36,"column":6},"end":{"line":36,"column":16}},"19":{"start":{"line":37,"column":6},"end":{"line":37,"column":15}},"20":{"start":{"line":39,"column":5},"end":{"line":39,"column":11}},"21":{"start":{"line":41,"column":4},"end":{"line":41,"column":21}},"22":{"start":{"line":45,"column":3},"end":{"line":57,"column":5}},"23":{"start":{"line":46,"column":4},"end":{"line":46,"column":26}},"24":{"start":{"line":47,"column":4},"end":{"line":55,"column":5}},"25":{"start":{"line":48,"column":5},"end":{"line":52,"column":6}},"26":{"start":{"line":49,"column":6},"end":{"line":49,"column":26}},"27":{"start":{"line":51,"column":6},"end":{"line":51,"column":23}},"28":{"start":{"line":53,"column":5},"end":{"line":53,"column":19}},"29":{"start":{"line":54,"column":5},"end":{"line":54,"column":14}},"30":{"start":{"line":56,"column":4},"end":{"line":56,"column":21}},"31":{"start":{"line":62,"column":3},"end":{"line":70,"column":5}},"32":{"start":{"line":63,"column":4},"end":{"line":63,"column":17}},"33":{"start":{"line":64,"column":4},"end":{"line":68,"column":5}},"34":{"start":{"line":65,"column":5},"end":{"line":65,"column":25}},"35":{"start":{"line":67,"column":5},"end":{"line":67,"column":24}},"36":{"start":{"line":69,"column":4},"end":{"line":69,"column":26}},"37":{"start":{"line":73,"column":3},"end":{"line":80,"column":5}},"38":{"start":{"line":74,"column":4},"end":{"line":78,"column":5}},"39":{"start":{"line":75,"column":5},"end":{"line":75,"column":21}},"40":{"start":{"line":77,"column":5},"end":{"line":77,"column":22}},"41":{"start":{"line":79,"column":4},"end":{"line":79,"column":30}},"42":{"start":{"line":83,"column":3},"end":{"line":88,"column":12}},"43":{"start":{"line":85,"column":4},"end":{"line":85,"column":17}},"44":{"start":{"line":86,"column":4},"end":{"line":86,"column":24}},"45":{"start":{"line":87,"column":4},"end":{"line":87,"column":24}},"46":{"start":{"line":91,"column":3},"end":{"line":92,"column":58}},"47":{"start":{"line":93,"column":3},"end":{"line":95,"column":4}},"48":{"start":{"line":94,"column":4},"end":{"line":94,"column":31}},"49":{"start":{"line":96,"column":3},"end":{"line":96,"column":13}},"50":{"start":{"line":99,"column":3},"end":{"line":99,"column":108}},"51":{"start":{"line":100,"column":3},"end":{"line":111,"column":5}},"52":{"start":{"line":101,"column":4},"end":{"line":110,"column":5}},"53":{"start":{"line":103,"column":5},"end":{"line":109,"column":6}},"54":{"start":{"line":104,"column":6},"end":{"line":104,"column":35}},"55":{"start":{"line":105,"column":6},"end":{"line":108,"column":7}},"56":{"start":{"line":106,"column":7},"end":{"line":106,"column":25}},"57":{"start":{"line":107,"column":7},"end":{"line":107,"column":22}},"58":{"start":{"line":112,"column":3},"end":{"line":126,"column":5}},"59":{"start":{"line":113,"column":4},"end":{"line":113,"column":17}},"60":{"start":{"line":114,"column":4},"end":{"line":118,"column":5}},"61":{"start":{"line":115,"column":5},"end":{"line":115,"column":53}},"62":{"start":{"line":117,"column":5},"end":{"line":117,"column":22}},"63":{"start":{"line":119,"column":4},"end":{"line":119,"column":19}},"64":{"start":{"line":120,"column":4},"end":{"line":120,"column":23}},"65":{"start":{"line":121,"column":4},"end":{"line":125,"column":5}},"66":{"start":{"line":122,"column":5},"end":{"line":122,"column":13}},"67":{"start":{"line":124,"column":5},"end":{"line":124,"column":14}},"68":{"start":{"line":131,"column":3},"end":{"line":131,"column":22}},"69":{"start":{"line":132,"column":3},"end":{"line":148,"column":5}},"70":{"start":{"line":133,"column":4},"end":{"line":133,"column":17}},"71":{"start":{"line":134,"column":4},"end":{"line":146,"column":5}},"72":{"start":{"line":135,"column":5},"end":{"line":137,"column":6}},"73":{"start":{"line":136,"column":6},"end":{"line":136,"column":15}},"74":{"start":{"line":138,"column":5},"end":{"line":142,"column":6}},"75":{"start":{"line":139,"column":6},"end":{"line":139,"column":32}},"76":{"start":{"line":141,"column":6},"end":{"line":141,"column":15}},"77":{"start":{"line":143,"column":5},"end":{"line":145,"column":6}},"78":{"start":{"line":144,"column":6},"end":{"line":144,"column":15}},"79":{"start":{"line":147,"column":4},"end":{"line":147,"column":30}},"80":{"start":{"line":151,"column":3},"end":{"line":151,"column":22}},"81":{"start":{"line":152,"column":3},"end":{"line":167,"column":5}},"82":{"start":{"line":153,"column":4},"end":{"line":153,"column":26}},"83":{"start":{"line":154,"column":4},"end":{"line":165,"column":5}},"84":{"start":{"line":155,"column":5},"end":{"line":157,"column":6}},"85":{"start":{"line":156,"column":6},"end":{"line":156,"column":15}},"86":{"start":{"line":158,"column":5},"end":{"line":162,"column":6}},"87":{"start":{"line":159,"column":6},"end":{"line":159,"column":32}},"88":{"start":{"line":161,"column":6},"end":{"line":161,"column":32}},"89":{"start":{"line":163,"column":5},"end":{"line":163,"column":19}},"90":{"start":{"line":164,"column":5},"end":{"line":164,"column":14}},"91":{"start":{"line":166,"column":4},"end":{"line":166,"column":20}},"92":{"start":{"line":170,"column":3},"end":{"line":170,"column":29}},"93":{"start":{"line":171,"column":3},"end":{"line":171,"column":33}},"94":{"start":{"line":176,"column":3},"end":{"line":176,"column":29}},"95":{"start":{"line":177,"column":3},"end":{"line":177,"column":17}},"96":{"start":{"line":179,"column":3},"end":{"line":181,"column":4}},"97":{"start":{"line":180,"column":4},"end":{"line":180,"column":17}},"98":{"start":{"line":182,"column":3},"end":{"line":214,"column":5}},"99":{"start":{"line":183,"column":4},"end":{"line":183,"column":27}},"100":{"start":{"line":184,"column":4},"end":{"line":184,"column":16}},"101":{"start":{"line":185,"column":4},"end":{"line":199,"column":5}},"102":{"start":{"line":186,"column":5},"end":{"line":190,"column":6}},"103":{"start":{"line":187,"column":6},"end":{"line":187,"column":30}},"104":{"start":{"line":189,"column":6},"end":{"line":189,"column":12}},"105":{"start":{"line":191,"column":5},"end":{"line":191,"column":19}},"106":{"start":{"line":192,"column":5},"end":{"line":197,"column":6}},"107":{"start":{"line":193,"column":6},"end":{"line":193,"column":29}},"108":{"start":{"line":195,"column":6},"end":{"line":195,"column":15}},"109":{"start":{"line":196,"column":6},"end":{"line":196,"column":12}},"110":{"start":{"line":198,"column":5},"end":{"line":198,"column":14}},"111":{"start":{"line":200,"column":4},"end":{"line":202,"column":5}},"112":{"start":{"line":201,"column":5},"end":{"line":201,"column":31}},"113":{"start":{"line":203,"column":4},"end":{"line":205,"column":5}},"114":{"start":{"line":204,"column":5},"end":{"line":204,"column":34}},"115":{"start":{"line":206,"column":4},"end":{"line":212,"column":5}},"116":{"start":{"line":207,"column":5},"end":{"line":211,"column":6}},"117":{"start":{"line":208,"column":6},"end":{"line":208,"column":29}},"118":{"start":{"line":210,"column":6},"end":{"line":210,"column":35}},"119":{"start":{"line":213,"column":4},"end":{"line":213,"column":30}},"120":{"start":{"line":222,"column":3},"end":{"line":222,"column":17}},"121":{"start":{"line":223,"column":3},"end":{"line":223,"column":51}},"122":{"start":{"line":224,"column":3},"end":{"line":227,"column":5}},"123":{"start":{"line":225,"column":4},"end":{"line":225,"column":31}},"124":{"start":{"line":226,"column":4},"end":{"line":226,"column":40}},"125":{"start":{"line":230,"column":3},"end":{"line":230,"column":29}},"126":{"start":{"line":231,"column":3},"end":{"line":231,"column":17}},"127":{"start":{"line":232,"column":3},"end":{"line":234,"column":61}},"128":{"start":{"line":237,"column":3},"end":{"line":237,"column":29}},"129":{"start":{"line":238,"column":3},"end":{"line":238,"column":17}},"130":{"start":{"line":239,"column":3},"end":{"line":355,"column":5}},"131":{"start":{"line":242,"column":4},"end":{"line":242,"column":78}},"132":{"start":{"line":244,"column":4},"end":{"line":328,"column":5}},"133":{"start":{"line":248,"column":5},"end":{"line":248,"column":14}},"134":{"start":{"line":249,"column":5},"end":{"line":249,"column":14}},"135":{"start":{"line":250,"column":5},"end":{"line":250,"column":14}},"136":{"start":{"line":251,"column":5},"end":{"line":251,"column":30}},"137":{"start":{"line":254,"column":5},"end":{"line":258,"column":6}},"138":{"start":{"line":255,"column":6},"end":{"line":255,"column":30}},"139":{"start":{"line":257,"column":6},"end":{"line":257,"column":15}},"140":{"start":{"line":261,"column":5},"end":{"line":261,"column":25}},"141":{"start":{"line":267,"column":5},"end":{"line":275,"column":6}},"142":{"start":{"line":268,"column":6},"end":{"line":272,"column":7}},"143":{"start":{"line":269,"column":7},"end":{"line":269,"column":30}},"144":{"start":{"line":271,"column":7},"end":{"line":271,"column":19}},"145":{"start":{"line":274,"column":6},"end":{"line":274,"column":18}},"146":{"start":{"line":280,"column":5},"end":{"line":282,"column":6}},"147":{"start":{"line":281,"column":6},"end":{"line":281,"column":18}},"148":{"start":{"line":288,"column":5},"end":{"line":313,"column":6}},"149":{"start":{"line":291,"column":6},"end":{"line":291,"column":18}},"150":{"start":{"line":292,"column":6},"end":{"line":296,"column":7}},"151":{"start":{"line":293,"column":7},"end":{"line":295,"column":8}},"152":{"start":{"line":294,"column":8},"end":{"line":294,"column":23}},"153":{"start":{"line":301,"column":6},"end":{"line":301,"column":40}},"154":{"start":{"line":305,"column":6},"end":{"line":312,"column":7}},"155":{"start":{"line":310,"column":7},"end":{"line":310,"column":34}},"156":{"start":{"line":311,"column":7},"end":{"line":311,"column":20}},"157":{"start":{"line":320,"column":5},"end":{"line":322,"column":6}},"158":{"start":{"line":321,"column":6},"end":{"line":321,"column":16}},"159":{"start":{"line":325,"column":5},"end":{"line":327,"column":6}},"160":{"start":{"line":326,"column":6},"end":{"line":326,"column":12}},"161":{"start":{"line":335,"column":4},"end":{"line":337,"column":5}},"162":{"start":{"line":336,"column":5},"end":{"line":336,"column":17}},"163":{"start":{"line":340,"column":4},"end":{"line":351,"column":5}},"164":{"start":{"line":343,"column":5},"end":{"line":347,"column":6}},"165":{"start":{"line":344,"column":6},"end":{"line":344,"column":32}},"166":{"start":{"line":346,"column":6},"end":{"line":346,"column":38}},"167":{"start":{"line":350,"column":5},"end":{"line":350,"column":20}},"168":{"start":{"line":354,"column":4},"end":{"line":354,"column":16}},"169":{"start":{"line":358,"column":3},"end":{"line":360,"column":5}},"170":{"start":{"line":359,"column":4},"end":{"line":359,"column":35}},"171":{"start":{"line":367,"column":3},"end":{"line":370,"column":5}},"172":{"start":{"line":368,"column":4},"end":{"line":368,"column":31}},"173":{"start":{"line":369,"column":4},"end":{"line":369,"column":24}},"174":{"start":{"line":373,"column":3},"end":{"line":376,"column":5}},"175":{"start":{"line":374,"column":4},"end":{"line":374,"column":31}},"176":{"start":{"line":375,"column":4},"end":{"line":375,"column":39}},"177":{"start":{"line":379,"column":3},"end":{"line":385,"column":5}},"178":{"start":{"line":380,"column":4},"end":{"line":380,"column":32}},"179":{"start":{"line":381,"column":4},"end":{"line":383,"column":5}},"180":{"start":{"line":382,"column":5},"end":{"line":382,"column":31}},"181":{"start":{"line":384,"column":4},"end":{"line":384,"column":14}},"182":{"start":{"line":412,"column":1},"end":{"line":434,"column":3}},"183":{"start":{"line":413,"column":2},"end":{"line":431,"column":3}},"184":{"start":{"line":414,"column":3},"end":{"line":414,"column":35}},"185":{"start":{"line":415,"column":3},"end":{"line":419,"column":4}},"186":{"start":{"line":416,"column":4},"end":{"line":416,"column":49}},"187":{"start":{"line":417,"column":10},"end":{"line":419,"column":4}},"188":{"start":{"line":418,"column":4},"end":{"line":418,"column":24}},"189":{"start":{"line":420,"column":3},"end":{"line":430,"column":4}},"190":{"start":{"line":421,"column":4},"end":{"line":421,"column":22}},"191":{"start":{"line":422,"column":4},"end":{"line":427,"column":5}},"192":{"start":{"line":423,"column":5},"end":{"line":423,"column":25}},"193":{"start":{"line":424,"column":5},"end":{"line":424,"column":35}},"194":{"start":{"line":425,"column":5},"end":{"line":425,"column":18}},"195":{"start":{"line":426,"column":5},"end":{"line":426,"column":15}},"196":{"start":{"line":429,"column":4},"end":{"line":429,"column":37}},"197":{"start":{"line":433,"column":2},"end":{"line":433,"column":13}},"198":{"start":{"line":436,"column":1},"end":{"line":436,"column":50}},"199":{"start":{"line":438,"column":1},"end":{"line":440,"column":2}},"200":{"start":{"line":439,"column":2},"end":{"line":439,"column":34}},"201":{"start":{"line":442,"column":1},"end":{"line":450,"column":3}},"202":{"start":{"line":443,"column":2},"end":{"line":449,"column":4}},"203":{"start":{"line":444,"column":3},"end":{"line":448,"column":4}},"204":{"start":{"line":445,"column":4},"end":{"line":445,"column":40}},"205":{"start":{"line":447,"column":4},"end":{"line":447,"column":37}},"206":{"start":{"line":452,"column":1},"end":{"line":452,"column":37}},"207":{"start":{"line":454,"column":1},"end":{"line":456,"column":2}},"208":{"start":{"line":455,"column":2},"end":{"line":455,"column":31}}},"branchMap":{"1":{"line":10,"type":"if","locations":[{"start":{"line":10,"column":4},"end":{"line":10,"column":4}},{"start":{"line":10,"column":4},"end":{"line":10,"column":4}}]},"2":{"line":83,"type":"cond-expr","locations":[{"start":{"line":84,"column":3},"end":{"line":88,"column":4}},{"start":{"line":88,"column":7},"end":{"line":88,"column":11}}]},"3":{"line":99,"type":"binary-expr","locations":[{"start":{"line":99,"column":66},"end":{"line":99,"column":87}},{"start":{"line":99,"column":91},"end":{"line":99,"column":97}}]},"4":{"line":101,"type":"if","locations":[{"start":{"line":101,"column":4},"end":{"line":101,"column":4}},{"start":{"line":101,"column":4},"end":{"line":101,"column":4}}]},"5":{"line":105,"type":"if","locations":[{"start":{"line":105,"column":6},"end":{"line":105,"column":6}},{"start":{"line":105,"column":6},"end":{"line":105,"column":6}}]},"6":{"line":115,"type":"binary-expr","locations":[{"start":{"line":115,"column":21},"end":{"line":115,"column":29}},{"start":{"line":115,"column":33},"end":{"line":115,"column":51}}]},"7":{"line":121,"type":"if","locations":[{"start":{"line":121,"column":4},"end":{"line":121,"column":4}},{"start":{"line":121,"column":4},"end":{"line":121,"column":4}}]},"8":{"line":135,"type":"if","locations":[{"start":{"line":135,"column":5},"end":{"line":135,"column":5}},{"start":{"line":135,"column":5},"end":{"line":135,"column":5}}]},"9":{"line":143,"type":"if","locations":[{"start":{"line":143,"column":5},"end":{"line":143,"column":5}},{"start":{"line":143,"column":5},"end":{"line":143,"column":5}}]},"10":{"line":155,"type":"if","locations":[{"start":{"line":155,"column":5},"end":{"line":155,"column":5}},{"start":{"line":155,"column":5},"end":{"line":155,"column":5}}]},"11":{"line":176,"type":"binary-expr","locations":[{"start":{"line":176,"column":7},"end":{"line":176,"column":8}},{"start":{"line":176,"column":12},"end":{"line":176,"column":28}}]},"12":{"line":177,"type":"binary-expr","locations":[{"start":{"line":177,"column":7},"end":{"line":177,"column":8}},{"start":{"line":177,"column":12},"end":{"line":177,"column":16}}]},"13":{"line":179,"type":"if","locations":[{"start":{"line":179,"column":3},"end":{"line":179,"column":3}},{"start":{"line":179,"column":3},"end":{"line":179,"column":3}}]},"14":{"line":200,"type":"if","locations":[{"start":{"line":200,"column":4},"end":{"line":200,"column":4}},{"start":{"line":200,"column":4},"end":{"line":200,"column":4}}]},"15":{"line":203,"type":"if","locations":[{"start":{"line":203,"column":4},"end":{"line":203,"column":4}},{"start":{"line":203,"column":4},"end":{"line":203,"column":4}}]},"16":{"line":206,"type":"if","locations":[{"start":{"line":206,"column":4},"end":{"line":206,"column":4}},{"start":{"line":206,"column":4},"end":{"line":206,"column":4}}]},"17":{"line":213,"type":"cond-expr","locations":[{"start":{"line":213,"column":20},"end":{"line":213,"column":24}},{"start":{"line":213,"column":25},"end":{"line":213,"column":26}}]},"18":{"line":222,"type":"binary-expr","locations":[{"start":{"line":222,"column":8},"end":{"line":222,"column":10}},{"start":{"line":222,"column":14},"end":{"line":222,"column":16}}]},"19":{"line":230,"type":"binary-expr","locations":[{"start":{"line":230,"column":7},"end":{"line":230,"column":8}},{"start":{"line":230,"column":12},"end":{"line":230,"column":28}}]},"20":{"line":231,"type":"binary-expr","locations":[{"start":{"line":231,"column":7},"end":{"line":231,"column":8}},{"start":{"line":231,"column":12},"end":{"line":231,"column":16}}]},"21":{"line":232,"type":"cond-expr","locations":[{"start":{"line":233,"column":4},"end":{"line":233,"column":76}},{"start":{"line":234,"column":4},"end":{"line":234,"column":59}}]},"22":{"line":237,"type":"binary-expr","locations":[{"start":{"line":237,"column":7},"end":{"line":237,"column":8}},{"start":{"line":237,"column":12},"end":{"line":237,"column":28}}]},"23":{"line":238,"type":"binary-expr","locations":[{"start":{"line":238,"column":7},"end":{"line":238,"column":8}},{"start":{"line":238,"column":12},"end":{"line":238,"column":16}}]},"24":{"line":267,"type":"if","locations":[{"start":{"line":267,"column":5},"end":{"line":267,"column":5}},{"start":{"line":267,"column":5},"end":{"line":267,"column":5}}]},"25":{"line":267,"type":"binary-expr","locations":[{"start":{"line":267,"column":9},"end":{"line":267,"column":24}},{"start":{"line":267,"column":28},"end":{"line":267,"column":34}}]},"26":{"line":280,"type":"if","locations":[{"start":{"line":280,"column":5},"end":{"line":280,"column":5}},{"start":{"line":280,"column":5},"end":{"line":280,"column":5}}]},"27":{"line":280,"type":"binary-expr","locations":[{"start":{"line":280,"column":9},"end":{"line":280,"column":14}},{"start":{"line":280,"column":18},"end":{"line":280,"column":35}}]},"28":{"line":288,"type":"if","locations":[{"start":{"line":288,"column":5},"end":{"line":288,"column":5}},{"start":{"line":288,"column":5},"end":{"line":288,"column":5}}]},"29":{"line":293,"type":"if","locations":[{"start":{"line":293,"column":7},"end":{"line":293,"column":7}},{"start":{"line":293,"column":7},"end":{"line":293,"column":7}}]},"30":{"line":305,"type":"if","locations":[{"start":{"line":305,"column":6},"end":{"line":305,"column":6}},{"start":{"line":305,"column":6},"end":{"line":305,"column":6}}]},"31":{"line":320,"type":"if","locations":[{"start":{"line":320,"column":5},"end":{"line":320,"column":5}},{"start":{"line":320,"column":5},"end":{"line":320,"column":5}}]},"32":{"line":325,"type":"if","locations":[{"start":{"line":325,"column":5},"end":{"line":325,"column":5}},{"start":{"line":325,"column":5},"end":{"line":325,"column":5}}]},"33":{"line":335,"type":"if","locations":[{"start":{"line":335,"column":4},"end":{"line":335,"column":4}},{"start":{"line":335,"column":4},"end":{"line":335,"column":4}}]},"34":{"line":340,"type":"if","locations":[{"start":{"line":340,"column":4},"end":{"line":340,"column":4}},{"start":{"line":340,"column":4},"end":{"line":340,"column":4}}]},"35":{"line":381,"type":"if","locations":[{"start":{"line":381,"column":4},"end":{"line":381,"column":4}},{"start":{"line":381,"column":4},"end":{"line":381,"column":4}}]},"36":{"line":415,"type":"if","locations":[{"start":{"line":415,"column":3},"end":{"line":415,"column":3}},{"start":{"line":415,"column":3},"end":{"line":415,"column":3}}]},"37":{"line":417,"type":"if","locations":[{"start":{"line":417,"column":10},"end":{"line":417,"column":10}},{"start":{"line":417,"column":10},"end":{"line":417,"column":10}}]},"38":{"line":420,"type":"if","locations":[{"start":{"line":420,"column":3},"end":{"line":420,"column":3}},{"start":{"line":420,"column":3},"end":{"line":420,"column":3}}]},"39":{"line":422,"type":"if","locations":[{"start":{"line":422,"column":4},"end":{"line":422,"column":4}},{"start":{"line":422,"column":4},"end":{"line":422,"column":4}}]},"40":{"line":444,"type":"if","locations":[{"start":{"line":444,"column":3},"end":{"line":444,"column":3}},{"start":{"line":444,"column":3},"end":{"line":444,"column":3}}]}}},"src/core/parsing_translator.js":{"path":"src/core/parsing_translator.js","s":{"1":1,"2":1,"3":1,"4":1327,"5":1327,"6":2853,"7":797,"8":2056,"9":1822,"10":1327,"11":1,"12":577,"13":11,"14":0,"15":11,"16":0,"17":11,"18":7,"19":4,"20":0,"21":1,"22":49,"23":49,"24":0,"25":49,"26":42,"27":49,"28":49,"29":49,"30":7,"31":49,"32":49,"33":49,"34":49,"35":49,"36":49,"37":49,"38":49,"39":1,"40":528,"41":91,"42":437,"43":2,"44":2,"45":2,"46":2,"47":2,"48":2,"49":108,"50":108,"51":108,"52":108,"53":108,"54":108,"55":108,"56":1,"57":1,"58":1,"59":1,"60":1,"61":1,"62":528,"63":0,"64":528,"65":525,"66":80,"67":525,"68":35,"69":35,"70":35,"71":1,"72":35,"73":1,"74":12,"75":17,"76":2,"77":3,"78":0,"79":0,"80":0,"81":0,"82":0,"83":0,"84":4,"85":11,"86":2,"87":2,"88":2,"89":0,"90":2,"91":169,"92":169,"93":109,"94":109,"95":0,"96":154,"97":68,"98":68,"99":0,"100":50,"101":72,"102":72,"103":230,"104":222,"105":0,"106":0,"107":0,"108":0,"109":221,"110":221,"111":1,"112":1,"113":1,"114":49,"115":49,"116":49,"117":49,"118":49,"119":49,"120":49,"121":49,"122":2,"123":47,"124":47,"125":0,"126":47,"127":0,"128":47,"129":0,"130":47,"131":530,"132":530,"133":530,"134":2,"135":528,"136":1822,"137":1822,"138":528,"139":0,"140":528,"141":528,"142":528,"143":528,"144":1,"145":1,"146":1,"147":528,"148":0,"149":0,"150":0,"151":0,"152":528,"153":1,"154":528,"155":2,"156":528,"157":0,"158":0,"159":0,"160":0,"161":528,"162":0,"163":0,"164":0,"165":528,"166":0,"167":528,"168":0,"169":0,"170":0,"171":528,"172":108,"173":108,"174":528,"175":108,"176":528,"177":77,"178":528,"179":528,"180":528,"181":0,"182":528,"183":0,"184":528,"185":35,"186":493,"187":0,"188":493,"189":422,"190":71,"191":493,"192":2,"193":2,"194":2,"195":2,"196":2,"197":2,"198":1,"199":0,"200":1,"201":2,"202":493},"b":{"1":[797,2056],"2":[1822,234],"3":[11,566],"4":[577,11,0],"5":[0,11],"6":[11,4,0],"7":[0,11],"8":[11,7,7],"9":[7,4],"10":[11,7],"11":[0,4],"12":[4,4],"13":[0,49],"14":[49,49,0,0,0],"15":[42,7],"16":[49,0],"17":[49,49],"18":[7,42],"19":[49,0],"20":[49,0],"21":[49,0],"22":[49,0],"23":[91,437],"24":[528,527],"25":[2,0],"26":[2,0],"27":[108,0],"28":[108,0],"29":[1,0],"30":[0,528],"31":[528,83,6,6,0],"32":[0,0],"33":[0,0],"34":[525,3],"35":[528,187],"36":[80,445],"37":[3,32],"38":[1,34],"39":[0,2],"40":[0,109],"41":[37,31],"42":[0,68],"43":[59,13],"44":[1,12],"45":[0,0,221,1],"46":[49,0],"47":[49,0],"48":[2,47],"49":[0,47],"50":[0,47],"51":[0,47],"52":[530,0],"53":[2,528],"54":[1822,0],"55":[0,528],"56":[528,1,0],"57":[528,0,528,522],"58":[228,300],"59":[528,525],"60":[1,527],"61":[528,68],"62":[0,528],"63":[528,461,67],"64":[0,0],"65":[1,527],"66":[528,71,5,1],"67":[2,526],"68":[528,457,5,5],"69":[0,528],"70":[528,10,7,2],"71":[0,0],"72":[0,528],"73":[528,68,0],"74":[0,0],"75":[0,528],"76":[528,451,0],"77":[0,528],"78":[528,68,0],"79":[0,0],"80":[108,420],"81":[528,460,445,108],"82":[108,420],"83":[528,457,349,108],"84":[77,451],"85":[0,528],"86":[528,460,68],"87":[0,528],"88":[528,522,71,0,0,0],"89":[35,493],"90":[528,35,35,35],"91":[0,493],"92":[493,422,0,0],"93":[422,71],"94":[2,491],"95":[2,0],"96":[1,1],"97":[0,1]},"f":{"1":1,"2":1327,"3":577,"4":49,"5":528,"6":2,"7":108,"8":1,"9":528,"10":35,"11":12,"12":17,"13":2,"14":3,"15":0,"16":0,"17":0,"18":0,"19":4,"20":11,"21":2,"22":2,"23":169,"24":109,"25":154,"26":68,"27":50,"28":72,"29":230,"30":222,"31":49,"32":530},"fnMap":{"1":{"name":"(anonymous_1)","line":1,"loc":{"start":{"line":1,"column":1},"end":{"line":1,"column":13}}},"2":{"name":"(anonymous_2)","line":4,"loc":{"start":{"line":4,"column":25},"end":{"line":4,"column":39}}},"3":{"name":"(anonymous_3)","line":18,"loc":{"start":{"line":18,"column":21},"end":{"line":18,"column":33}}},"4":{"name":"(anonymous_4)","line":32,"loc":{"start":{"line":32,"column":19},"end":{"line":32,"column":31}}},"5":{"name":"(anonymous_5)","line":67,"loc":{"start":{"line":67,"column":12},"end":{"line":67,"column":24}}},"6":{"name":"(anonymous_6)","line":74,"loc":{"start":{"line":74,"column":22},"end":{"line":74,"column":46}}},"7":{"name":"(anonymous_7)","line":82,"loc":{"start":{"line":82,"column":22},"end":{"line":82,"column":47}}},"8":{"name":"(anonymous_8)","line":91,"loc":{"start":{"line":91,"column":21},"end":{"line":91,"column":33}}},"9":{"name":"(anonymous_9)","line":100,"loc":{"start":{"line":100,"column":16},"end":{"line":100,"column":34}}},"10":{"name":"(anonymous_10)","line":110,"loc":{"start":{"line":110,"column":25},"end":{"line":110,"column":37}}},"11":{"name":"(anonymous_11)","line":121,"loc":{"start":{"line":121,"column":8},"end":{"line":121,"column":21}}},"12":{"name":"(anonymous_12)","line":122,"loc":{"start":{"line":122,"column":10},"end":{"line":122,"column":22}}},"13":{"name":"(anonymous_13)","line":126,"loc":{"start":{"line":126,"column":10},"end":{"line":126,"column":23}}},"14":{"name":"(anonymous_14)","line":127,"loc":{"start":{"line":127,"column":10},"end":{"line":127,"column":22}}},"15":{"name":"(anonymous_15)","line":131,"loc":{"start":{"line":131,"column":10},"end":{"line":131,"column":23}}},"16":{"name":"(anonymous_16)","line":132,"loc":{"start":{"line":132,"column":10},"end":{"line":132,"column":22}}},"17":{"name":"(anonymous_17)","line":137,"loc":{"start":{"line":137,"column":24},"end":{"line":137,"column":37}}},"18":{"name":"(anonymous_18)","line":138,"loc":{"start":{"line":138,"column":10},"end":{"line":138,"column":22}}},"19":{"name":"(anonymous_19)","line":144,"loc":{"start":{"line":144,"column":12},"end":{"line":144,"column":25}}},"20":{"name":"(anonymous_20)","line":145,"loc":{"start":{"line":145,"column":10},"end":{"line":145,"column":22}}},"21":{"name":"(anonymous_21)","line":149,"loc":{"start":{"line":149,"column":12},"end":{"line":149,"column":25}}},"22":{"name":"(anonymous_22)","line":150,"loc":{"start":{"line":150,"column":10},"end":{"line":150,"column":22}}},"23":{"name":"(anonymous_23)","line":159,"loc":{"start":{"line":159,"column":7},"end":{"line":159,"column":20}}},"24":{"name":"(anonymous_24)","line":161,"loc":{"start":{"line":161,"column":10},"end":{"line":161,"column":22}}},"25":{"name":"(anonymous_25)","line":168,"loc":{"start":{"line":168,"column":9},"end":{"line":168,"column":22}}},"26":{"name":"(anonymous_26)","line":169,"loc":{"start":{"line":169,"column":10},"end":{"line":169,"column":22}}},"27":{"name":"(anonymous_27)","line":176,"loc":{"start":{"line":176,"column":8},"end":{"line":176,"column":21}}},"28":{"name":"(anonymous_28)","line":177,"loc":{"start":{"line":177,"column":10},"end":{"line":177,"column":22}}},"29":{"name":"(anonymous_29)","line":183,"loc":{"start":{"line":183,"column":8},"end":{"line":183,"column":21}}},"30":{"name":"(anonymous_30)","line":184,"loc":{"start":{"line":184,"column":10},"end":{"line":184,"column":22}}},"31":{"name":"(anonymous_31)","line":202,"loc":{"start":{"line":202,"column":15},"end":{"line":202,"column":28}}},"32":{"name":"(anonymous_32)","line":231,"loc":{"start":{"line":231,"column":10},"end":{"line":231,"column":23}}}},"statementMap":{"1":{"start":{"line":1,"column":0},"end":{"line":362,"column":5}},"2":{"start":{"line":2,"column":1},"end":{"line":2,"column":15}},"3":{"start":{"line":4,"column":1},"end":{"line":16,"column":3}},"4":{"start":{"line":5,"column":2},"end":{"line":5,"column":14}},"5":{"start":{"line":6,"column":2},"end":{"line":14,"column":3}},"6":{"start":{"line":7,"column":3},"end":{"line":13,"column":4}},"7":{"start":{"line":8,"column":4},"end":{"line":8,"column":45}},"8":{"start":{"line":10,"column":4},"end":{"line":12,"column":5}},"9":{"start":{"line":11,"column":5},"end":{"line":11,"column":20}},"10":{"start":{"line":15,"column":2},"end":{"line":15,"column":12}},"11":{"start":{"line":18,"column":1},"end":{"line":30,"column":3}},"12":{"start":{"line":19,"column":2},"end":{"line":29,"column":3}},"13":{"start":{"line":20,"column":3},"end":{"line":28,"column":4}},"14":{"start":{"line":21,"column":4},"end":{"line":21,"column":50}},"15":{"start":{"line":22,"column":10},"end":{"line":28,"column":4}},"16":{"start":{"line":23,"column":4},"end":{"line":23,"column":50}},"17":{"start":{"line":24,"column":10},"end":{"line":28,"column":4}},"18":{"start":{"line":25,"column":4},"end":{"line":25,"column":31}},"19":{"start":{"line":26,"column":10},"end":{"line":28,"column":4}},"20":{"start":{"line":27,"column":4},"end":{"line":27,"column":18}},"21":{"start":{"line":32,"column":1},"end":{"line":64,"column":3}},"22":{"start":{"line":33,"column":2},"end":{"line":33,"column":23}},"23":{"start":{"line":34,"column":2},"end":{"line":36,"column":3}},"24":{"start":{"line":35,"column":3},"end":{"line":35,"column":28}},"25":{"start":{"line":38,"column":2},"end":{"line":40,"column":3}},"26":{"start":{"line":39,"column":3},"end":{"line":39,"column":33}},"27":{"start":{"line":42,"column":2},"end":{"line":44,"column":3}},"28":{"start":{"line":43,"column":3},"end":{"line":43,"column":31}},"29":{"start":{"line":46,"column":2},"end":{"line":48,"column":3}},"30":{"start":{"line":47,"column":3},"end":{"line":47,"column":16}},"31":{"start":{"line":50,"column":2},"end":{"line":52,"column":3}},"32":{"start":{"line":51,"column":3},"end":{"line":51,"column":17}},"33":{"start":{"line":54,"column":2},"end":{"line":56,"column":3}},"34":{"start":{"line":55,"column":3},"end":{"line":55,"column":19}},"35":{"start":{"line":58,"column":2},"end":{"line":60,"column":3}},"36":{"start":{"line":59,"column":3},"end":{"line":59,"column":19}},"37":{"start":{"line":61,"column":2},"end":{"line":63,"column":3}},"38":{"start":{"line":62,"column":3},"end":{"line":62,"column":24}},"39":{"start":{"line":66,"column":1},"end":{"line":118,"column":3}},"40":{"start":{"line":68,"column":4},"end":{"line":72,"column":4}},"41":{"start":{"line":69,"column":4},"end":{"line":69,"column":22}},"42":{"start":{"line":71,"column":4},"end":{"line":71,"column":22}},"43":{"start":{"line":75,"column":3},"end":{"line":75,"column":11}},"44":{"start":{"line":76,"column":3},"end":{"line":76,"column":24}},"45":{"start":{"line":77,"column":3},"end":{"line":77,"column":21}},"46":{"start":{"line":78,"column":3},"end":{"line":78,"column":66}},"47":{"start":{"line":79,"column":3},"end":{"line":79,"column":63}},"48":{"start":{"line":80,"column":3},"end":{"line":80,"column":15}},"49":{"start":{"line":83,"column":3},"end":{"line":83,"column":11}},"50":{"start":{"line":84,"column":3},"end":{"line":84,"column":24}},"51":{"start":{"line":85,"column":3},"end":{"line":85,"column":23}},"52":{"start":{"line":86,"column":3},"end":{"line":86,"column":41}},"53":{"start":{"line":87,"column":3},"end":{"line":87,"column":68}},"54":{"start":{"line":88,"column":3},"end":{"line":88,"column":21}},"55":{"start":{"line":89,"column":3},"end":{"line":89,"column":15}},"56":{"start":{"line":92,"column":3},"end":{"line":92,"column":32}},"57":{"start":{"line":93,"column":3},"end":{"line":93,"column":26}},"58":{"start":{"line":94,"column":3},"end":{"line":96,"column":4}},"59":{"start":{"line":95,"column":4},"end":{"line":95,"column":30}},"60":{"start":{"line":97,"column":3},"end":{"line":97,"column":31}},"61":{"start":{"line":98,"column":3},"end":{"line":98,"column":15}},"62":{"start":{"line":101,"column":3},"end":{"line":108,"column":4}},"63":{"start":{"line":102,"column":4},"end":{"line":102,"column":116}},"64":{"start":{"line":103,"column":10},"end":{"line":108,"column":4}},"65":{"start":{"line":104,"column":4},"end":{"line":106,"column":5}},"66":{"start":{"line":105,"column":5},"end":{"line":105,"column":20}},"67":{"start":{"line":107,"column":4},"end":{"line":107,"column":48}},"68":{"start":{"line":111,"column":3},"end":{"line":111,"column":71}},"69":{"start":{"line":112,"column":3},"end":{"line":112,"column":48}},"70":{"start":{"line":113,"column":3},"end":{"line":115,"column":4}},"71":{"start":{"line":114,"column":4},"end":{"line":114,"column":21}},"72":{"start":{"line":116,"column":3},"end":{"line":116,"column":12}},"73":{"start":{"line":120,"column":1},"end":{"line":361,"column":3}},"74":{"start":{"line":122,"column":3},"end":{"line":124,"column":5}},"75":{"start":{"line":123,"column":4},"end":{"line":123,"column":26}},"76":{"start":{"line":127,"column":3},"end":{"line":129,"column":5}},"77":{"start":{"line":128,"column":4},"end":{"line":128,"column":28}},"78":{"start":{"line":132,"column":3},"end":{"line":134,"column":5}},"79":{"start":{"line":133,"column":4},"end":{"line":133,"column":28}},"80":{"start":{"line":138,"column":3},"end":{"line":142,"column":5}},"81":{"start":{"line":139,"column":4},"end":{"line":139,"column":52}},"82":{"start":{"line":140,"column":4},"end":{"line":140,"column":32}},"83":{"start":{"line":141,"column":4},"end":{"line":141,"column":37}},"84":{"start":{"line":145,"column":3},"end":{"line":147,"column":5}},"85":{"start":{"line":146,"column":4},"end":{"line":146,"column":48}},"86":{"start":{"line":150,"column":3},"end":{"line":157,"column":5}},"87":{"start":{"line":151,"column":4},"end":{"line":151,"column":40}},"88":{"start":{"line":152,"column":4},"end":{"line":156,"column":5}},"89":{"start":{"line":153,"column":5},"end":{"line":153,"column":37}},"90":{"start":{"line":155,"column":5},"end":{"line":155,"column":37}},"91":{"start":{"line":160,"column":3},"end":{"line":160,"column":16}},"92":{"start":{"line":161,"column":3},"end":{"line":166,"column":5}},"93":{"start":{"line":162,"column":4},"end":{"line":162,"column":41}},"94":{"start":{"line":163,"column":4},"end":{"line":165,"column":5}},"95":{"start":{"line":164,"column":5},"end":{"line":164,"column":25}},"96":{"start":{"line":169,"column":3},"end":{"line":174,"column":5}},"97":{"start":{"line":170,"column":4},"end":{"line":170,"column":115}},"98":{"start":{"line":171,"column":4},"end":{"line":173,"column":5}},"99":{"start":{"line":172,"column":5},"end":{"line":172,"column":27}},"100":{"start":{"line":177,"column":3},"end":{"line":181,"column":5}},"101":{"start":{"line":178,"column":4},"end":{"line":178,"column":22}},"102":{"start":{"line":179,"column":4},"end":{"line":180,"column":76}},"103":{"start":{"line":184,"column":3},"end":{"line":200,"column":5}},"104":{"start":{"line":185,"column":4},"end":{"line":199,"column":5}},"105":{"start":{"line":187,"column":6},"end":{"line":187,"column":21}},"106":{"start":{"line":188,"column":6},"end":{"line":188,"column":12}},"107":{"start":{"line":190,"column":6},"end":{"line":190,"column":20}},"108":{"start":{"line":191,"column":6},"end":{"line":191,"column":12}},"109":{"start":{"line":193,"column":6},"end":{"line":193,"column":20}},"110":{"start":{"line":194,"column":6},"end":{"line":194,"column":12}},"111":{"start":{"line":196,"column":6},"end":{"line":196,"column":20}},"112":{"start":{"line":197,"column":6},"end":{"line":197,"column":22}},"113":{"start":{"line":198,"column":6},"end":{"line":198,"column":12}},"114":{"start":{"line":203,"column":3},"end":{"line":203,"column":9}},"115":{"start":{"line":204,"column":3},"end":{"line":204,"column":38}},"116":{"start":{"line":206,"column":3},"end":{"line":210,"column":4}},"117":{"start":{"line":207,"column":4},"end":{"line":209,"column":5}},"118":{"start":{"line":208,"column":5},"end":{"line":208,"column":21}},"119":{"start":{"line":212,"column":3},"end":{"line":212,"column":26}},"120":{"start":{"line":213,"column":3},"end":{"line":213,"column":28}},"121":{"start":{"line":215,"column":3},"end":{"line":217,"column":4}},"122":{"start":{"line":216,"column":4},"end":{"line":216,"column":71}},"123":{"start":{"line":219,"column":3},"end":{"line":219,"column":104}},"124":{"start":{"line":220,"column":3},"end":{"line":222,"column":4}},"125":{"start":{"line":221,"column":4},"end":{"line":221,"column":29}},"126":{"start":{"line":223,"column":3},"end":{"line":227,"column":4}},"127":{"start":{"line":224,"column":4},"end":{"line":224,"column":39}},"128":{"start":{"line":225,"column":10},"end":{"line":227,"column":4}},"129":{"start":{"line":226,"column":4},"end":{"line":226,"column":51}},"130":{"start":{"line":229,"column":3},"end":{"line":229,"column":12}},"131":{"start":{"line":232,"column":3},"end":{"line":232,"column":39}},"132":{"start":{"line":234,"column":3},"end":{"line":234,"column":59}},"133":{"start":{"line":236,"column":3},"end":{"line":238,"column":4}},"134":{"start":{"line":237,"column":4},"end":{"line":237,"column":16}},"135":{"start":{"line":240,"column":3},"end":{"line":244,"column":4}},"136":{"start":{"line":241,"column":4},"end":{"line":243,"column":5}},"137":{"start":{"line":242,"column":5},"end":{"line":242,"column":21}},"138":{"start":{"line":245,"column":3},"end":{"line":249,"column":4}},"139":{"start":{"line":246,"column":4},"end":{"line":246,"column":22}},"140":{"start":{"line":248,"column":4},"end":{"line":248,"column":44}},"141":{"start":{"line":251,"column":3},"end":{"line":251,"column":84}},"142":{"start":{"line":252,"column":3},"end":{"line":252,"column":80}},"143":{"start":{"line":254,"column":3},"end":{"line":258,"column":4}},"144":{"start":{"line":255,"column":4},"end":{"line":255,"column":32}},"145":{"start":{"line":256,"column":4},"end":{"line":256,"column":22}},"146":{"start":{"line":257,"column":4},"end":{"line":257,"column":20}},"147":{"start":{"line":260,"column":3},"end":{"line":266,"column":4}},"148":{"start":{"line":261,"column":4},"end":{"line":263,"column":5}},"149":{"start":{"line":262,"column":5},"end":{"line":262,"column":33}},"150":{"start":{"line":264,"column":4},"end":{"line":264,"column":22}},"151":{"start":{"line":265,"column":4},"end":{"line":265,"column":22}},"152":{"start":{"line":268,"column":3},"end":{"line":270,"column":4}},"153":{"start":{"line":269,"column":4},"end":{"line":269,"column":45}},"154":{"start":{"line":272,"column":3},"end":{"line":274,"column":4}},"155":{"start":{"line":273,"column":4},"end":{"line":273,"column":61}},"156":{"start":{"line":276,"column":3},"end":{"line":282,"column":4}},"157":{"start":{"line":277,"column":4},"end":{"line":277,"column":32}},"158":{"start":{"line":278,"column":4},"end":{"line":278,"column":30}},"159":{"start":{"line":279,"column":4},"end":{"line":281,"column":5}},"160":{"start":{"line":280,"column":5},"end":{"line":280,"column":34}},"161":{"start":{"line":284,"column":3},"end":{"line":289,"column":4}},"162":{"start":{"line":285,"column":4},"end":{"line":287,"column":5}},"163":{"start":{"line":286,"column":5},"end":{"line":286,"column":35}},"164":{"start":{"line":288,"column":4},"end":{"line":288,"column":22}},"165":{"start":{"line":291,"column":3},"end":{"line":293,"column":4}},"166":{"start":{"line":292,"column":4},"end":{"line":292,"column":30}},"167":{"start":{"line":295,"column":3},"end":{"line":300,"column":4}},"168":{"start":{"line":296,"column":4},"end":{"line":296,"column":39}},"169":{"start":{"line":297,"column":4},"end":{"line":299,"column":5}},"170":{"start":{"line":298,"column":5},"end":{"line":298,"column":31}},"171":{"start":{"line":302,"column":3},"end":{"line":305,"column":4}},"172":{"start":{"line":303,"column":4},"end":{"line":303,"column":28}},"173":{"start":{"line":304,"column":4},"end":{"line":304,"column":22}},"174":{"start":{"line":307,"column":3},"end":{"line":309,"column":4}},"175":{"start":{"line":308,"column":4},"end":{"line":308,"column":61}},"176":{"start":{"line":311,"column":3},"end":{"line":313,"column":4}},"177":{"start":{"line":312,"column":4},"end":{"line":312,"column":22}},"178":{"start":{"line":315,"column":3},"end":{"line":315,"column":47}},"179":{"start":{"line":316,"column":3},"end":{"line":316,"column":28}},"180":{"start":{"line":318,"column":3},"end":{"line":320,"column":4}},"181":{"start":{"line":319,"column":4},"end":{"line":319,"column":17}},"182":{"start":{"line":322,"column":3},"end":{"line":324,"column":4}},"183":{"start":{"line":323,"column":4},"end":{"line":323,"column":44}},"184":{"start":{"line":326,"column":3},"end":{"line":328,"column":4}},"185":{"start":{"line":327,"column":4},"end":{"line":327,"column":56}},"186":{"start":{"line":330,"column":3},"end":{"line":332,"column":4}},"187":{"start":{"line":331,"column":4},"end":{"line":331,"column":25}},"188":{"start":{"line":334,"column":3},"end":{"line":338,"column":4}},"189":{"start":{"line":335,"column":4},"end":{"line":335,"column":20}},"190":{"start":{"line":337,"column":4},"end":{"line":337,"column":20}},"191":{"start":{"line":340,"column":3},"end":{"line":357,"column":4}},"192":{"start":{"line":341,"column":4},"end":{"line":341,"column":48}},"193":{"start":{"line":342,"column":4},"end":{"line":342,"column":53}},"194":{"start":{"line":343,"column":4},"end":{"line":343,"column":17}},"195":{"start":{"line":344,"column":4},"end":{"line":355,"column":5}},"196":{"start":{"line":346,"column":5},"end":{"line":346,"column":81}},"197":{"start":{"line":347,"column":5},"end":{"line":354,"column":6}},"198":{"start":{"line":349,"column":6},"end":{"line":353,"column":7}},"199":{"start":{"line":350,"column":7},"end":{"line":350,"column":26}},"200":{"start":{"line":352,"column":7},"end":{"line":352,"column":25}},"201":{"start":{"line":356,"column":4},"end":{"line":356,"column":36}},"202":{"start":{"line":359,"column":3},"end":{"line":359,"column":16}}},"branchMap":{"1":{"line":7,"type":"if","locations":[{"start":{"line":7,"column":3},"end":{"line":7,"column":3}},{"start":{"line":7,"column":3},"end":{"line":7,"column":3}}]},"2":{"line":10,"type":"if","locations":[{"start":{"line":10,"column":4},"end":{"line":10,"column":4}},{"start":{"line":10,"column":4},"end":{"line":10,"column":4}}]},"3":{"line":19,"type":"if","locations":[{"start":{"line":19,"column":2},"end":{"line":19,"column":2}},{"start":{"line":19,"column":2},"end":{"line":19,"column":2}}]},"4":{"line":19,"type":"binary-expr","locations":[{"start":{"line":19,"column":6},"end":{"line":19,"column":19}},{"start":{"line":19,"column":24},"end":{"line":19,"column":33}},{"start":{"line":19,"column":37},"end":{"line":19,"column":52}}]},"5":{"line":20,"type":"if","locations":[{"start":{"line":20,"column":3},"end":{"line":20,"column":3}},{"start":{"line":20,"column":3},"end":{"line":20,"column":3}}]},"6":{"line":20,"type":"binary-expr","locations":[{"start":{"line":20,"column":7},"end":{"line":20,"column":28}},{"start":{"line":20,"column":32},"end":{"line":20,"column":46}},{"start":{"line":20,"column":50},"end":{"line":20,"column":72}}]},"7":{"line":22,"type":"if","locations":[{"start":{"line":22,"column":10},"end":{"line":22,"column":10}},{"start":{"line":22,"column":10},"end":{"line":22,"column":10}}]},"8":{"line":22,"type":"binary-expr","locations":[{"start":{"line":22,"column":14},"end":{"line":22,"column":35}},{"start":{"line":22,"column":39},"end":{"line":22,"column":53}},{"start":{"line":22,"column":57},"end":{"line":22,"column":79}}]},"9":{"line":24,"type":"if","locations":[{"start":{"line":24,"column":10},"end":{"line":24,"column":10}},{"start":{"line":24,"column":10},"end":{"line":24,"column":10}}]},"10":{"line":24,"type":"binary-expr","locations":[{"start":{"line":24,"column":14},"end":{"line":24,"column":35}},{"start":{"line":24,"column":39},"end":{"line":24,"column":53}}]},"11":{"line":26,"type":"if","locations":[{"start":{"line":26,"column":10},"end":{"line":26,"column":10}},{"start":{"line":26,"column":10},"end":{"line":26,"column":10}}]},"12":{"line":26,"type":"binary-expr","locations":[{"start":{"line":26,"column":14},"end":{"line":26,"column":35}},{"start":{"line":26,"column":39},"end":{"line":26,"column":55}}]},"13":{"line":34,"type":"if","locations":[{"start":{"line":34,"column":2},"end":{"line":34,"column":2}},{"start":{"line":34,"column":2},"end":{"line":34,"column":2}}]},"14":{"line":34,"type":"binary-expr","locations":[{"start":{"line":34,"column":7},"end":{"line":34,"column":16}},{"start":{"line":34,"column":20},"end":{"line":34,"column":31}},{"start":{"line":34,"column":37},"end":{"line":34,"column":48}},{"start":{"line":34,"column":52},"end":{"line":34,"column":62}},{"start":{"line":34,"column":66},"end":{"line":34,"column":75}}]},"15":{"line":38,"type":"if","locations":[{"start":{"line":38,"column":2},"end":{"line":38,"column":2}},{"start":{"line":38,"column":2},"end":{"line":38,"column":2}}]},"16":{"line":42,"type":"if","locations":[{"start":{"line":42,"column":2},"end":{"line":42,"column":2}},{"start":{"line":42,"column":2},"end":{"line":42,"column":2}}]},"17":{"line":42,"type":"binary-expr","locations":[{"start":{"line":42,"column":6},"end":{"line":42,"column":17}},{"start":{"line":42,"column":21},"end":{"line":42,"column":37}}]},"18":{"line":46,"type":"if","locations":[{"start":{"line":46,"column":2},"end":{"line":46,"column":2}},{"start":{"line":46,"column":2},"end":{"line":46,"column":2}}]},"19":{"line":50,"type":"if","locations":[{"start":{"line":50,"column":2},"end":{"line":50,"column":2}},{"start":{"line":50,"column":2},"end":{"line":50,"column":2}}]},"20":{"line":54,"type":"if","locations":[{"start":{"line":54,"column":2},"end":{"line":54,"column":2}},{"start":{"line":54,"column":2},"end":{"line":54,"column":2}}]},"21":{"line":58,"type":"if","locations":[{"start":{"line":58,"column":2},"end":{"line":58,"column":2}},{"start":{"line":58,"column":2},"end":{"line":58,"column":2}}]},"22":{"line":61,"type":"if","locations":[{"start":{"line":61,"column":2},"end":{"line":61,"column":2}},{"start":{"line":61,"column":2},"end":{"line":61,"column":2}}]},"23":{"line":68,"type":"if","locations":[{"start":{"line":68,"column":4},"end":{"line":68,"column":4}},{"start":{"line":68,"column":4},"end":{"line":68,"column":4}}]},"24":{"line":68,"type":"binary-expr","locations":[{"start":{"line":68,"column":8},"end":{"line":68,"column":16}},{"start":{"line":68,"column":20},"end":{"line":68,"column":66}}]},"25":{"line":76,"type":"binary-expr","locations":[{"start":{"line":76,"column":12},"end":{"line":76,"column":18}},{"start":{"line":76,"column":22},"end":{"line":76,"column":23}}]},"26":{"line":79,"type":"cond-expr","locations":[{"start":{"line":79,"column":22},"end":{"line":79,"column":46}},{"start":{"line":79,"column":51},"end":{"line":79,"column":61}}]},"27":{"line":84,"type":"binary-expr","locations":[{"start":{"line":84,"column":12},"end":{"line":84,"column":18}},{"start":{"line":84,"column":22},"end":{"line":84,"column":23}}]},"28":{"line":87,"type":"cond-expr","locations":[{"start":{"line":87,"column":24},"end":{"line":87,"column":50}},{"start":{"line":87,"column":55},"end":{"line":87,"column":66}}]},"29":{"line":94,"type":"if","locations":[{"start":{"line":94,"column":3},"end":{"line":94,"column":3}},{"start":{"line":94,"column":3},"end":{"line":94,"column":3}}]},"30":{"line":101,"type":"if","locations":[{"start":{"line":101,"column":3},"end":{"line":101,"column":3}},{"start":{"line":101,"column":3},"end":{"line":101,"column":3}}]},"31":{"line":101,"type":"binary-expr","locations":[{"start":{"line":101,"column":7},"end":{"line":101,"column":18}},{"start":{"line":101,"column":22},"end":{"line":101,"column":35}},{"start":{"line":101,"column":39},"end":{"line":101,"column":61}},{"start":{"line":101,"column":65},"end":{"line":101,"column":86}},{"start":{"line":101,"column":90},"end":{"line":101,"column":120}}]},"32":{"line":102,"type":"cond-expr","locations":[{"start":{"line":102,"column":81},"end":{"line":102,"column":82}},{"start":{"line":102,"column":85},"end":{"line":102,"column":87}}]},"33":{"line":102,"type":"binary-expr","locations":[{"start":{"line":102,"column":92},"end":{"line":102,"column":102}},{"start":{"line":102,"column":104},"end":{"line":102,"column":105}}]},"34":{"line":103,"type":"if","locations":[{"start":{"line":103,"column":10},"end":{"line":103,"column":10}},{"start":{"line":103,"column":10},"end":{"line":103,"column":10}}]},"35":{"line":103,"type":"binary-expr","locations":[{"start":{"line":103,"column":14},"end":{"line":103,"column":43}},{"start":{"line":103,"column":47},"end":{"line":103,"column":68}}]},"36":{"line":104,"type":"if","locations":[{"start":{"line":104,"column":4},"end":{"line":104,"column":4}},{"start":{"line":104,"column":4},"end":{"line":104,"column":4}}]},"37":{"line":111,"type":"cond-expr","locations":[{"start":{"line":111,"column":48},"end":{"line":111,"column":60}},{"start":{"line":111,"column":63},"end":{"line":111,"column":70}}]},"38":{"line":113,"type":"if","locations":[{"start":{"line":113,"column":3},"end":{"line":113,"column":3}},{"start":{"line":113,"column":3},"end":{"line":113,"column":3}}]},"39":{"line":152,"type":"if","locations":[{"start":{"line":152,"column":4},"end":{"line":152,"column":4}},{"start":{"line":152,"column":4},"end":{"line":152,"column":4}}]},"40":{"line":163,"type":"if","locations":[{"start":{"line":163,"column":4},"end":{"line":163,"column":4}},{"start":{"line":163,"column":4},"end":{"line":163,"column":4}}]},"41":{"line":170,"type":"cond-expr","locations":[{"start":{"line":170,"column":36},"end":{"line":170,"column":98}},{"start":{"line":170,"column":101},"end":{"line":170,"column":114}}]},"42":{"line":171,"type":"if","locations":[{"start":{"line":171,"column":4},"end":{"line":171,"column":4}},{"start":{"line":171,"column":4},"end":{"line":171,"column":4}}]},"43":{"line":179,"type":"cond-expr","locations":[{"start":{"line":179,"column":34},"end":{"line":179,"column":35}},{"start":{"line":180,"column":6},"end":{"line":180,"column":73}}]},"44":{"line":180,"type":"cond-expr","locations":[{"start":{"line":180,"column":61},"end":{"line":180,"column":65}},{"start":{"line":180,"column":68},"end":{"line":180,"column":72}}]},"45":{"line":185,"type":"switch","locations":[{"start":{"line":186,"column":5},"end":{"line":188,"column":12}},{"start":{"line":189,"column":5},"end":{"line":191,"column":12}},{"start":{"line":192,"column":5},"end":{"line":194,"column":12}},{"start":{"line":195,"column":5},"end":{"line":198,"column":12}}]},"46":{"line":204,"type":"cond-expr","locations":[{"start":{"line":204,"column":30},"end":{"line":204,"column":31}},{"start":{"line":204,"column":34},"end":{"line":204,"column":37}}]},"47":{"line":207,"type":"if","locations":[{"start":{"line":207,"column":4},"end":{"line":207,"column":4}},{"start":{"line":207,"column":4},"end":{"line":207,"column":4}}]},"48":{"line":215,"type":"if","locations":[{"start":{"line":215,"column":3},"end":{"line":215,"column":3}},{"start":{"line":215,"column":3},"end":{"line":215,"column":3}}]},"49":{"line":220,"type":"if","locations":[{"start":{"line":220,"column":3},"end":{"line":220,"column":3}},{"start":{"line":220,"column":3},"end":{"line":220,"column":3}}]},"50":{"line":223,"type":"if","locations":[{"start":{"line":223,"column":3},"end":{"line":223,"column":3}},{"start":{"line":223,"column":3},"end":{"line":223,"column":3}}]},"51":{"line":225,"type":"if","locations":[{"start":{"line":225,"column":10},"end":{"line":225,"column":10}},{"start":{"line":225,"column":10},"end":{"line":225,"column":10}}]},"52":{"line":234,"type":"cond-expr","locations":[{"start":{"line":234,"column":30},"end":{"line":234,"column":50}},{"start":{"line":234,"column":53},"end":{"line":234,"column":58}}]},"53":{"line":236,"type":"if","locations":[{"start":{"line":236,"column":3},"end":{"line":236,"column":3}},{"start":{"line":236,"column":3},"end":{"line":236,"column":3}}]},"54":{"line":241,"type":"if","locations":[{"start":{"line":241,"column":4},"end":{"line":241,"column":4}},{"start":{"line":241,"column":4},"end":{"line":241,"column":4}}]},"55":{"line":245,"type":"if","locations":[{"start":{"line":245,"column":3},"end":{"line":245,"column":3}},{"start":{"line":245,"column":3},"end":{"line":245,"column":3}}]},"56":{"line":245,"type":"binary-expr","locations":[{"start":{"line":245,"column":7},"end":{"line":245,"column":15}},{"start":{"line":245,"column":19},"end":{"line":245,"column":29}},{"start":{"line":245,"column":33},"end":{"line":245,"column":47}}]},"57":{"line":251,"type":"binary-expr","locations":[{"start":{"line":251,"column":19},"end":{"line":251,"column":28}},{"start":{"line":251,"column":32},"end":{"line":251,"column":50}},{"start":{"line":251,"column":54},"end":{"line":251,"column":65}},{"start":{"line":251,"column":69},"end":{"line":251,"column":82}}]},"58":{"line":252,"type":"cond-expr","locations":[{"start":{"line":252,"column":72},"end":{"line":252,"column":74}},{"start":{"line":252,"column":77},"end":{"line":252,"column":78}}]},"59":{"line":252,"type":"binary-expr","locations":[{"start":{"line":252,"column":14},"end":{"line":252,"column":36}},{"start":{"line":252,"column":40},"end":{"line":252,"column":68}}]},"60":{"line":254,"type":"if","locations":[{"start":{"line":254,"column":3},"end":{"line":254,"column":3}},{"start":{"line":254,"column":3},"end":{"line":254,"column":3}}]},"61":{"line":254,"type":"binary-expr","locations":[{"start":{"line":254,"column":7},"end":{"line":254,"column":17}},{"start":{"line":254,"column":21},"end":{"line":254,"column":41}}]},"62":{"line":260,"type":"if","locations":[{"start":{"line":260,"column":3},"end":{"line":260,"column":3}},{"start":{"line":260,"column":3},"end":{"line":260,"column":3}}]},"63":{"line":260,"type":"binary-expr","locations":[{"start":{"line":260,"column":8},"end":{"line":260,"column":18}},{"start":{"line":260,"column":22},"end":{"line":260,"column":38}},{"start":{"line":260,"column":43},"end":{"line":260,"column":98}}]},"64":{"line":261,"type":"if","locations":[{"start":{"line":261,"column":4},"end":{"line":261,"column":4}},{"start":{"line":261,"column":4},"end":{"line":261,"column":4}}]},"65":{"line":268,"type":"if","locations":[{"start":{"line":268,"column":3},"end":{"line":268,"column":3}},{"start":{"line":268,"column":3},"end":{"line":268,"column":3}}]},"66":{"line":268,"type":"binary-expr","locations":[{"start":{"line":268,"column":7},"end":{"line":268,"column":18}},{"start":{"line":268,"column":22},"end":{"line":268,"column":34}},{"start":{"line":268,"column":38},"end":{"line":268,"column":47}},{"start":{"line":268,"column":51},"end":{"line":268,"column":61}}]},"67":{"line":272,"type":"if","locations":[{"start":{"line":272,"column":3},"end":{"line":272,"column":3}},{"start":{"line":272,"column":3},"end":{"line":272,"column":3}}]},"68":{"line":272,"type":"binary-expr","locations":[{"start":{"line":272,"column":7},"end":{"line":272,"column":17}},{"start":{"line":272,"column":21},"end":{"line":272,"column":33}},{"start":{"line":272,"column":37},"end":{"line":272,"column":58}},{"start":{"line":272,"column":62},"end":{"line":272,"column":82}}]},"69":{"line":276,"type":"if","locations":[{"start":{"line":276,"column":3},"end":{"line":276,"column":3}},{"start":{"line":276,"column":3},"end":{"line":276,"column":3}}]},"70":{"line":276,"type":"binary-expr","locations":[{"start":{"line":276,"column":7},"end":{"line":276,"column":19}},{"start":{"line":276,"column":23},"end":{"line":276,"column":43}},{"start":{"line":276,"column":47},"end":{"line":276,"column":56}},{"start":{"line":276,"column":60},"end":{"line":276,"column":70}}]},"71":{"line":279,"type":"if","locations":[{"start":{"line":279,"column":4},"end":{"line":279,"column":4}},{"start":{"line":279,"column":4},"end":{"line":279,"column":4}}]},"72":{"line":284,"type":"if","locations":[{"start":{"line":284,"column":3},"end":{"line":284,"column":3}},{"start":{"line":284,"column":3},"end":{"line":284,"column":3}}]},"73":{"line":284,"type":"binary-expr","locations":[{"start":{"line":284,"column":7},"end":{"line":284,"column":17}},{"start":{"line":284,"column":21},"end":{"line":284,"column":40}},{"start":{"line":284,"column":44},"end":{"line":284,"column":57}}]},"74":{"line":285,"type":"if","locations":[{"start":{"line":285,"column":4},"end":{"line":285,"column":4}},{"start":{"line":285,"column":4},"end":{"line":285,"column":4}}]},"75":{"line":291,"type":"if","locations":[{"start":{"line":291,"column":3},"end":{"line":291,"column":3}},{"start":{"line":291,"column":3},"end":{"line":291,"column":3}}]},"76":{"line":291,"type":"binary-expr","locations":[{"start":{"line":291,"column":7},"end":{"line":291,"column":25}},{"start":{"line":291,"column":29},"end":{"line":291,"column":47}},{"start":{"line":291,"column":51},"end":{"line":291,"column":68}}]},"77":{"line":295,"type":"if","locations":[{"start":{"line":295,"column":3},"end":{"line":295,"column":3}},{"start":{"line":295,"column":3},"end":{"line":295,"column":3}}]},"78":{"line":295,"type":"binary-expr","locations":[{"start":{"line":295,"column":7},"end":{"line":295,"column":17}},{"start":{"line":295,"column":21},"end":{"line":295,"column":30}},{"start":{"line":295,"column":34},"end":{"line":295,"column":44}}]},"79":{"line":297,"type":"if","locations":[{"start":{"line":297,"column":4},"end":{"line":297,"column":4}},{"start":{"line":297,"column":4},"end":{"line":297,"column":4}}]},"80":{"line":302,"type":"if","locations":[{"start":{"line":302,"column":3},"end":{"line":302,"column":3}},{"start":{"line":302,"column":3},"end":{"line":302,"column":3}}]},"81":{"line":302,"type":"binary-expr","locations":[{"start":{"line":302,"column":7},"end":{"line":302,"column":18}},{"start":{"line":302,"column":22},"end":{"line":302,"column":32}},{"start":{"line":302,"column":36},"end":{"line":302,"column":57}},{"start":{"line":302,"column":61},"end":{"line":302,"column":70}}]},"82":{"line":307,"type":"if","locations":[{"start":{"line":307,"column":3},"end":{"line":307,"column":3}},{"start":{"line":307,"column":3},"end":{"line":307,"column":3}}]},"83":{"line":307,"type":"binary-expr","locations":[{"start":{"line":307,"column":7},"end":{"line":307,"column":17}},{"start":{"line":307,"column":22},"end":{"line":307,"column":32}},{"start":{"line":307,"column":36},"end":{"line":307,"column":52}},{"start":{"line":307,"column":57},"end":{"line":307,"column":77}}]},"84":{"line":311,"type":"if","locations":[{"start":{"line":311,"column":3},"end":{"line":311,"column":3}},{"start":{"line":311,"column":3},"end":{"line":311,"column":3}}]},"85":{"line":318,"type":"if","locations":[{"start":{"line":318,"column":3},"end":{"line":318,"column":3}},{"start":{"line":318,"column":3},"end":{"line":318,"column":3}}]},"86":{"line":318,"type":"binary-expr","locations":[{"start":{"line":318,"column":8},"end":{"line":318,"column":18}},{"start":{"line":318,"column":22},"end":{"line":318,"column":38}},{"start":{"line":318,"column":43},"end":{"line":318,"column":52}}]},"87":{"line":322,"type":"if","locations":[{"start":{"line":322,"column":3},"end":{"line":322,"column":3}},{"start":{"line":322,"column":3},"end":{"line":322,"column":3}}]},"88":{"line":322,"type":"binary-expr","locations":[{"start":{"line":322,"column":7},"end":{"line":322,"column":19}},{"start":{"line":322,"column":23},"end":{"line":322,"column":37}},{"start":{"line":322,"column":41},"end":{"line":322,"column":61}},{"start":{"line":322,"column":65},"end":{"line":322,"column":75}},{"start":{"line":322,"column":79},"end":{"line":322,"column":88}},{"start":{"line":322,"column":92},"end":{"line":322,"column":103}}]},"89":{"line":326,"type":"if","locations":[{"start":{"line":326,"column":3},"end":{"line":326,"column":3}},{"start":{"line":326,"column":3},"end":{"line":326,"column":3}}]},"90":{"line":326,"type":"binary-expr","locations":[{"start":{"line":326,"column":7},"end":{"line":326,"column":27}},{"start":{"line":326,"column":31},"end":{"line":326,"column":41}},{"start":{"line":326,"column":45},"end":{"line":326,"column":54}},{"start":{"line":326,"column":58},"end":{"line":326,"column":69}}]},"91":{"line":330,"type":"if","locations":[{"start":{"line":330,"column":3},"end":{"line":330,"column":3}},{"start":{"line":330,"column":3},"end":{"line":330,"column":3}}]},"92":{"line":330,"type":"binary-expr","locations":[{"start":{"line":330,"column":7},"end":{"line":330,"column":17}},{"start":{"line":330,"column":21},"end":{"line":330,"column":34}},{"start":{"line":330,"column":38},"end":{"line":330,"column":46}},{"start":{"line":330,"column":50},"end":{"line":330,"column":59}}]},"93":{"line":334,"type":"if","locations":[{"start":{"line":334,"column":3},"end":{"line":334,"column":3}},{"start":{"line":334,"column":3},"end":{"line":334,"column":3}}]},"94":{"line":340,"type":"if","locations":[{"start":{"line":340,"column":3},"end":{"line":340,"column":3}},{"start":{"line":340,"column":3},"end":{"line":340,"column":3}}]},"95":{"line":344,"type":"if","locations":[{"start":{"line":344,"column":4},"end":{"line":344,"column":4}},{"start":{"line":344,"column":4},"end":{"line":344,"column":4}}]},"96":{"line":347,"type":"if","locations":[{"start":{"line":347,"column":5},"end":{"line":347,"column":5}},{"start":{"line":347,"column":5},"end":{"line":347,"column":5}}]},"97":{"line":349,"type":"if","locations":[{"start":{"line":349,"column":6},"end":{"line":349,"column":6}},{"start":{"line":349,"column":6},"end":{"line":349,"column":6}}]}}},"src/core/parsing_grammar.js":{"path":"src/core/parsing_grammar.js","s":{"1":1,"2":1,"3":1,"4":1,"5":1,"6":480,"7":1,"8":1,"9":1,"10":1,"11":1,"12":1,"13":960,"14":960,"15":960,"16":960,"17":960,"18":5440,"19":960,"20":960,"21":1,"22":1280,"23":1,"24":3040,"25":320,"26":2720,"27":1,"28":480,"29":1,"30":1,"31":20,"32":20,"33":1,"34":0,"35":0,"36":0,"37":0,"38":0,"39":0,"40":1,"41":1,"42":1,"43":1,"44":20,"45":1,"46":0,"47":1,"48":160,"49":160,"50":1760,"51":160,"52":160,"53":160,"54":160,"55":160,"56":160,"57":160,"58":480,"59":160,"60":160,"61":1280,"62":160,"63":160,"64":13,"65":10,"66":160,"67":160,"68":160,"69":160,"70":160,"71":160,"72":160,"73":530,"74":160,"75":6,"76":6,"77":160,"78":451,"79":451,"80":160,"81":160,"82":449,"83":449,"84":1,"85":160,"86":160,"87":160,"88":160,"89":160,"90":456,"91":451,"92":160,"93":160,"94":91,"95":91,"96":0,"97":56,"98":20,"99":160,"100":1,"101":1,"102":1,"103":530,"104":530,"105":47,"106":0,"107":530},"b":{"1":[960,0],"2":[320,2720],"3":[20,20],"4":[0,0],"5":[1,0],"6":[530,0],"7":[91,0],"8":[0,47]},"f":{"1":1,"2":480,"3":960,"4":1280,"5":3040,"6":480,"7":20,"8":0,"9":1,"10":160,"11":160,"12":480,"13":13,"14":10,"15":530,"16":160,"17":6,"18":6,"19":451,"20":451,"21":449,"22":449,"23":160,"24":456,"25":451,"26":91,"27":56,"28":20,"29":530},"fnMap":{"1":{"name":"(anonymous_1)","line":1,"loc":{"start":{"line":1,"column":1},"end":{"line":1,"column":13}}},"2":{"name":"(anonymous_2)","line":6,"loc":{"start":{"line":6,"column":7},"end":{"line":6,"column":19}}},"3":{"name":"(anonymous_3)","line":16,"loc":{"start":{"line":16,"column":12},"end":{"line":16,"column":28}}},"4":{"name":"(anonymous_4)","line":28,"loc":{"start":{"line":28,"column":13},"end":{"line":28,"column":28}}},"5":{"name":"(anonymous_5)","line":31,"loc":{"start":{"line":31,"column":26},"end":{"line":31,"column":65}}},"6":{"name":"(anonymous_6)","line":38,"loc":{"start":{"line":38,"column":26},"end":{"line":38,"column":49}}},"7":{"name":"(anonymous_7)","line":43,"loc":{"start":{"line":43,"column":12},"end":{"line":43,"column":25}}},"8":{"name":"(anonymous_8)","line":48,"loc":{"start":{"line":48,"column":16},"end":{"line":48,"column":30}}},"9":{"name":"(anonymous_9)","line":60,"loc":{"start":{"line":60,"column":13},"end":{"line":60,"column":27}}},"10":{"name":"(anonymous_10)","line":73,"loc":{"start":{"line":73,"column":16},"end":{"line":73,"column":26}}},"11":{"name":"(anonymous_11)","line":128,"loc":{"start":{"line":128,"column":16},"end":{"line":128,"column":28}}},"12":{"name":"(anonymous_12)","line":130,"loc":{"start":{"line":130,"column":16},"end":{"line":130,"column":28}}},"13":{"name":"(anonymous_13)","line":174,"loc":{"start":{"line":174,"column":4},"end":{"line":174,"column":17}}},"14":{"name":"(anonymous_14)","line":175,"loc":{"start":{"line":175,"column":12},"end":{"line":175,"column":24}}},"15":{"name":"(anonymous_15)","line":189,"loc":{"start":{"line":189,"column":12},"end":{"line":189,"column":25}}},"16":{"name":"(anonymous_16)","line":193,"loc":{"start":{"line":193,"column":13},"end":{"line":193,"column":25}}},"17":{"name":"(anonymous_17)","line":196,"loc":{"start":{"line":196,"column":4},"end":{"line":196,"column":17}}},"18":{"name":"(anonymous_18)","line":197,"loc":{"start":{"line":197,"column":12},"end":{"line":197,"column":24}}},"19":{"name":"(anonymous_19)","line":204,"loc":{"start":{"line":204,"column":4},"end":{"line":204,"column":17}}},"20":{"name":"(anonymous_20)","line":205,"loc":{"start":{"line":205,"column":12},"end":{"line":205,"column":24}}},"21":{"name":"(anonymous_21)","line":212,"loc":{"start":{"line":212,"column":4},"end":{"line":212,"column":17}}},"22":{"name":"(anonymous_22)","line":213,"loc":{"start":{"line":213,"column":12},"end":{"line":213,"column":24}}},"23":{"name":"(anonymous_23)","line":221,"loc":{"start":{"line":221,"column":25},"end":{"line":221,"column":37}}},"24":{"name":"(anonymous_24)","line":231,"loc":{"start":{"line":231,"column":3},"end":{"line":231,"column":16}}},"25":{"name":"(anonymous_25)","line":232,"loc":{"start":{"line":232,"column":11},"end":{"line":232,"column":23}}},"26":{"name":"(anonymous_26)","line":244,"loc":{"start":{"line":244,"column":6},"end":{"line":244,"column":21}}},"27":{"name":"(anonymous_27)","line":254,"loc":{"start":{"line":254,"column":6},"end":{"line":254,"column":19}}},"28":{"name":"(anonymous_28)","line":261,"loc":{"start":{"line":261,"column":3},"end":{"line":261,"column":20}}},"29":{"name":"(anonymous_29)","line":301,"loc":{"start":{"line":301,"column":11},"end":{"line":301,"column":24}}}},"statementMap":{"1":{"start":{"line":1,"column":0},"end":{"line":310,"column":5}},"2":{"start":{"line":2,"column":1},"end":{"line":2,"column":15}},"3":{"start":{"line":3,"column":1},"end":{"line":3,"column":17}},"4":{"start":{"line":4,"column":1},"end":{"line":4,"column":70}},"5":{"start":{"line":6,"column":1},"end":{"line":8,"column":3}},"6":{"start":{"line":7,"column":2},"end":{"line":7,"column":79}},"7":{"start":{"line":10,"column":1},"end":{"line":10,"column":56}},"8":{"start":{"line":11,"column":1},"end":{"line":11,"column":37}},"9":{"start":{"line":12,"column":1},"end":{"line":12,"column":33}},"10":{"start":{"line":13,"column":1},"end":{"line":13,"column":55}},"11":{"start":{"line":15,"column":1},"end":{"line":15,"column":13}},"12":{"start":{"line":16,"column":1},"end":{"line":27,"column":3}},"13":{"start":{"line":17,"column":2},"end":{"line":17,"column":20}},"14":{"start":{"line":18,"column":2},"end":{"line":25,"column":3}},"15":{"start":{"line":19,"column":3},"end":{"line":19,"column":42}},"16":{"start":{"line":20,"column":3},"end":{"line":20,"column":39}},"17":{"start":{"line":21,"column":3},"end":{"line":23,"column":4}},"18":{"start":{"line":22,"column":4},"end":{"line":22,"column":50}},"19":{"start":{"line":24,"column":3},"end":{"line":24,"column":41}},"20":{"start":{"line":26,"column":2},"end":{"line":26,"column":12}},"21":{"start":{"line":28,"column":1},"end":{"line":30,"column":3}},"22":{"start":{"line":29,"column":2},"end":{"line":29,"column":55}},"23":{"start":{"line":31,"column":1},"end":{"line":37,"column":3}},"24":{"start":{"line":32,"column":2},"end":{"line":36,"column":3}},"25":{"start":{"line":33,"column":3},"end":{"line":33,"column":95}},"26":{"start":{"line":35,"column":3},"end":{"line":35,"column":54}},"27":{"start":{"line":38,"column":1},"end":{"line":40,"column":3}},"28":{"start":{"line":39,"column":2},"end":{"line":39,"column":52}},"29":{"start":{"line":41,"column":1},"end":{"line":41,"column":13}},"30":{"start":{"line":43,"column":1},"end":{"line":46,"column":3}},"31":{"start":{"line":44,"column":2},"end":{"line":44,"column":36}},"32":{"start":{"line":45,"column":2},"end":{"line":45,"column":15}},"33":{"start":{"line":48,"column":1},"end":{"line":58,"column":3}},"34":{"start":{"line":49,"column":2},"end":{"line":49,"column":14}},"35":{"start":{"line":50,"column":2},"end":{"line":56,"column":3}},"36":{"start":{"line":51,"column":3},"end":{"line":53,"column":4}},"37":{"start":{"line":52,"column":4},"end":{"line":52,"column":25}},"38":{"start":{"line":55,"column":3},"end":{"line":55,"column":21}},"39":{"start":{"line":57,"column":2},"end":{"line":57,"column":12}},"40":{"start":{"line":60,"column":1},"end":{"line":70,"column":3}},"41":{"start":{"line":61,"column":2},"end":{"line":69,"column":3}},"42":{"start":{"line":62,"column":3},"end":{"line":62,"column":15}},"43":{"start":{"line":63,"column":3},"end":{"line":65,"column":4}},"44":{"start":{"line":64,"column":4},"end":{"line":64,"column":25}},"45":{"start":{"line":66,"column":3},"end":{"line":66,"column":32}},"46":{"start":{"line":68,"column":3},"end":{"line":68,"column":19}},"47":{"start":{"line":72,"column":1},"end":{"line":219,"column":3}},"48":{"start":{"line":74,"column":3},"end":{"line":113,"column":5}},"49":{"start":{"line":115,"column":3},"end":{"line":117,"column":4}},"50":{"start":{"line":116,"column":4},"end":{"line":116,"column":60}},"51":{"start":{"line":119,"column":3},"end":{"line":119,"column":69}},"52":{"start":{"line":121,"column":3},"end":{"line":121,"column":57}},"53":{"start":{"line":122,"column":3},"end":{"line":122,"column":57}},"54":{"start":{"line":123,"column":3},"end":{"line":123,"column":54}},"55":{"start":{"line":125,"column":3},"end":{"line":125,"column":73}},"56":{"start":{"line":126,"column":3},"end":{"line":126,"column":77}},"57":{"start":{"line":130,"column":3},"end":{"line":132,"column":5}},"58":{"start":{"line":131,"column":4},"end":{"line":131,"column":50}},"59":{"start":{"line":133,"column":3},"end":{"line":167,"column":5}},"60":{"start":{"line":168,"column":3},"end":{"line":170,"column":4}},"61":{"start":{"line":169,"column":4},"end":{"line":169,"column":74}},"62":{"start":{"line":172,"column":3},"end":{"line":172,"column":109}},"63":{"start":{"line":173,"column":3},"end":{"line":179,"column":6}},"64":{"start":{"line":175,"column":5},"end":{"line":177,"column":7}},"65":{"start":{"line":176,"column":6},"end":{"line":176,"column":23}},"66":{"start":{"line":181,"column":3},"end":{"line":181,"column":26}},"67":{"start":{"line":182,"column":3},"end":{"line":182,"column":29}},"68":{"start":{"line":183,"column":3},"end":{"line":183,"column":30}},"69":{"start":{"line":185,"column":3},"end":{"line":185,"column":49}},"70":{"start":{"line":186,"column":3},"end":{"line":186,"column":49}},"71":{"start":{"line":187,"column":3},"end":{"line":187,"column":49}},"72":{"start":{"line":189,"column":3},"end":{"line":191,"column":5}},"73":{"start":{"line":190,"column":4},"end":{"line":190,"column":75}},"74":{"start":{"line":195,"column":3},"end":{"line":201,"column":5}},"75":{"start":{"line":197,"column":5},"end":{"line":199,"column":7}},"76":{"start":{"line":198,"column":6},"end":{"line":198,"column":22}},"77":{"start":{"line":203,"column":3},"end":{"line":209,"column":5}},"78":{"start":{"line":205,"column":5},"end":{"line":207,"column":7}},"79":{"start":{"line":206,"column":6},"end":{"line":206,"column":24}},"80":{"start":{"line":210,"column":3},"end":{"line":210,"column":72}},"81":{"start":{"line":211,"column":3},"end":{"line":217,"column":5}},"82":{"start":{"line":213,"column":5},"end":{"line":215,"column":7}},"83":{"start":{"line":214,"column":6},"end":{"line":214,"column":20}},"84":{"start":{"line":221,"column":1},"end":{"line":269,"column":3}},"85":{"start":{"line":223,"column":2},"end":{"line":223,"column":10}},"86":{"start":{"line":225,"column":2},"end":{"line":225,"column":31}},"87":{"start":{"line":226,"column":2},"end":{"line":226,"column":31}},"88":{"start":{"line":227,"column":2},"end":{"line":227,"column":28}},"89":{"start":{"line":230,"column":2},"end":{"line":236,"column":4}},"90":{"start":{"line":232,"column":4},"end":{"line":234,"column":6}},"91":{"start":{"line":233,"column":5},"end":{"line":233,"column":39}},"92":{"start":{"line":237,"column":2},"end":{"line":237,"column":92}},"93":{"start":{"line":239,"column":2},"end":{"line":264,"column":4}},"94":{"start":{"line":245,"column":7},"end":{"line":249,"column":8}},"95":{"start":{"line":246,"column":8},"end":{"line":246,"column":22}},"96":{"start":{"line":248,"column":8},"end":{"line":248,"column":40}},"97":{"start":{"line":255,"column":7},"end":{"line":255,"column":36}},"98":{"start":{"line":262,"column":4},"end":{"line":262,"column":63}},"99":{"start":{"line":267,"column":2},"end":{"line":268,"column":47}},"100":{"start":{"line":271,"column":1},"end":{"line":271,"column":25}},"101":{"start":{"line":276,"column":1},"end":{"line":297,"column":4}},"102":{"start":{"line":301,"column":1},"end":{"line":309,"column":3}},"103":{"start":{"line":302,"column":2},"end":{"line":307,"column":16}},"104":{"start":{"line":303,"column":3},"end":{"line":303,"column":34}},"105":{"start":{"line":304,"column":3},"end":{"line":306,"column":4}},"106":{"start":{"line":305,"column":4},"end":{"line":305,"column":13}},"107":{"start":{"line":308,"column":2},"end":{"line":308,"column":30}}},"branchMap":{"1":{"line":18,"type":"if","locations":[{"start":{"line":18,"column":2},"end":{"line":18,"column":2}},{"start":{"line":18,"column":2},"end":{"line":18,"column":2}}]},"2":{"line":32,"type":"if","locations":[{"start":{"line":32,"column":2},"end":{"line":32,"column":2}},{"start":{"line":32,"column":2},"end":{"line":32,"column":2}}]},"3":{"line":44,"type":"binary-expr","locations":[{"start":{"line":44,"column":11},"end":{"line":44,"column":16}},{"start":{"line":44,"column":20},"end":{"line":44,"column":34}}]},"4":{"line":50,"type":"if","locations":[{"start":{"line":50,"column":2},"end":{"line":50,"column":2}},{"start":{"line":50,"column":2},"end":{"line":50,"column":2}}]},"5":{"line":61,"type":"if","locations":[{"start":{"line":61,"column":2},"end":{"line":61,"column":2}},{"start":{"line":61,"column":2},"end":{"line":61,"column":2}}]},"6":{"line":190,"type":"binary-expr","locations":[{"start":{"line":190,"column":13},"end":{"line":190,"column":49}},{"start":{"line":190,"column":53},"end":{"line":190,"column":58}}]},"7":{"line":245,"type":"if","locations":[{"start":{"line":245,"column":7},"end":{"line":245,"column":7}},{"start":{"line":245,"column":7},"end":{"line":245,"column":7}}]},"8":{"line":304,"type":"if","locations":[{"start":{"line":304,"column":3},"end":{"line":304,"column":3}},{"start":{"line":304,"column":3},"end":{"line":304,"column":3}}]}}},"src/core/parser.js":{"path":"src/core/parser.js","s":{"1":1,"2":1,"3":1,"4":530,"5":530,"6":530,"7":530,"8":530,"9":530,"10":0,"11":530,"12":2,"13":2,"14":2,"15":2,"16":0,"17":1,"18":620,"19":620,"20":6,"21":614,"22":3,"23":611,"24":449,"25":611,"26":81,"27":530,"28":530,"29":530,"30":528,"31":2,"32":1,"33":1,"34":1,"35":1,"36":0,"37":0,"38":0,"39":0,"40":0,"41":0,"42":0,"43":0,"44":0,"45":0,"46":1,"47":0},"b":{"1":[8,522],"2":[530,8],"3":[528,2],"4":[0,2],"5":[2,2],"6":[6,614],"7":[3,611],"8":[449,162],"9":[611,596,591,520],"10":[449,372],"11":[81,530],"12":[611,81],"13":[528,2],"14":[1,0],"15":[0,0]},"f":{"1":1,"2":530,"3":530,"4":2,"5":620,"6":0,"7":0,"8":0},"fnMap":{"1":{"name":"(anonymous_1)","line":1,"loc":{"start":{"line":1,"column":1},"end":{"line":1,"column":13}}},"2":{"name":"(anonymous_2)","line":105,"loc":{"start":{"line":105,"column":14},"end":{"line":105,"column":27}}},"3":{"name":"(anonymous_3)","line":110,"loc":{"start":{"line":110,"column":17},"end":{"line":110,"column":30}}},"4":{"name":"(anonymous_4)","line":120,"loc":{"start":{"line":120,"column":18},"end":{"line":120,"column":30}}},"5":{"name":"parse","line":131,"loc":{"start":{"line":131,"column":1},"end":{"line":131,"column":20}}},"6":{"name":"(anonymous_6)","line":162,"loc":{"start":{"line":162,"column":25},"end":{"line":162,"column":39}}},"7":{"name":"(anonymous_7)","line":164,"loc":{"start":{"line":164,"column":9},"end":{"line":164,"column":22}}},"8":{"name":"(anonymous_8)","line":203,"loc":{"start":{"line":203,"column":17},"end":{"line":203,"column":34}}}},"statementMap":{"1":{"start":{"line":1,"column":0},"end":{"line":206,"column":5}},"2":{"start":{"line":2,"column":1},"end":{"line":2,"column":15}},"3":{"start":{"line":104,"column":1},"end":{"line":130,"column":3}},"4":{"start":{"line":106,"column":3},"end":{"line":106,"column":46}},"5":{"start":{"line":107,"column":3},"end":{"line":107,"column":71}},"6":{"start":{"line":108,"column":3},"end":{"line":108,"column":12}},"7":{"start":{"line":111,"column":3},"end":{"line":111,"column":16}},"8":{"start":{"line":112,"column":3},"end":{"line":116,"column":4}},"9":{"start":{"line":113,"column":4},"end":{"line":113,"column":77}},"10":{"start":{"line":115,"column":4},"end":{"line":115,"column":16}},"11":{"start":{"line":118,"column":3},"end":{"line":118,"column":46}},"12":{"start":{"line":121,"column":3},"end":{"line":121,"column":9}},"13":{"start":{"line":122,"column":3},"end":{"line":128,"column":4}},"14":{"start":{"line":124,"column":4},"end":{"line":124,"column":23}},"15":{"start":{"line":125,"column":4},"end":{"line":125,"column":47}},"16":{"start":{"line":127,"column":4},"end":{"line":127,"column":16}},"17":{"start":{"line":131,"column":1},"end":{"line":155,"column":2}},"18":{"start":{"line":132,"column":2},"end":{"line":132,"column":8}},"19":{"start":{"line":133,"column":2},"end":{"line":135,"column":3}},"20":{"start":{"line":134,"column":3},"end":{"line":134,"column":15}},"21":{"start":{"line":136,"column":2},"end":{"line":138,"column":3}},"22":{"start":{"line":137,"column":3},"end":{"line":137,"column":20}},"23":{"start":{"line":139,"column":2},"end":{"line":142,"column":3}},"24":{"start":{"line":141,"column":3},"end":{"line":141,"column":62}},"25":{"start":{"line":143,"column":2},"end":{"line":154,"column":3}},"26":{"start":{"line":144,"column":3},"end":{"line":144,"column":12}},"27":{"start":{"line":147,"column":3},"end":{"line":147,"column":61}},"28":{"start":{"line":148,"column":3},"end":{"line":148,"column":35}},"29":{"start":{"line":149,"column":3},"end":{"line":153,"column":4}},"30":{"start":{"line":150,"column":4},"end":{"line":150,"column":13}},"31":{"start":{"line":152,"column":4},"end":{"line":152,"column":40}},"32":{"start":{"line":157,"column":1},"end":{"line":159,"column":2}},"33":{"start":{"line":158,"column":2},"end":{"line":158,"column":23}},"34":{"start":{"line":160,"column":1},"end":{"line":160,"column":18}},"35":{"start":{"line":162,"column":1},"end":{"line":178,"column":3}},"36":{"start":{"line":163,"column":2},"end":{"line":163,"column":40}},"37":{"start":{"line":164,"column":2},"end":{"line":177,"column":4}},"38":{"start":{"line":165,"column":3},"end":{"line":165,"column":16}},"39":{"start":{"line":166,"column":3},"end":{"line":175,"column":4}},"40":{"start":{"line":167,"column":4},"end":{"line":171,"column":5}},"41":{"start":{"line":168,"column":5},"end":{"line":168,"column":28}},"42":{"start":{"line":170,"column":5},"end":{"line":170,"column":14}},"43":{"start":{"line":172,"column":4},"end":{"line":174,"column":5}},"44":{"start":{"line":173,"column":5},"end":{"line":173,"column":17}},"45":{"start":{"line":176,"column":3},"end":{"line":176,"column":15}},"46":{"start":{"line":203,"column":1},"end":{"line":205,"column":3}},"47":{"start":{"line":204,"column":2},"end":{"line":204,"column":36}}},"branchMap":{"1":{"line":107,"type":"cond-expr","locations":[{"start":{"line":107,"column":38},"end":{"line":107,"column":65}},{"start":{"line":107,"column":68},"end":{"line":107,"column":69}}]},"2":{"line":107,"type":"binary-expr","locations":[{"start":{"line":107,"column":9},"end":{"line":107,"column":13}},{"start":{"line":107,"column":17},"end":{"line":107,"column":34}}]},"3":{"line":118,"type":"cond-expr","locations":[{"start":{"line":118,"column":33},"end":{"line":118,"column":37}},{"start":{"line":118,"column":40},"end":{"line":118,"column":44}}]},"4":{"line":125,"type":"cond-expr","locations":[{"start":{"line":125,"column":28},"end":{"line":125,"column":39}},{"start":{"line":125,"column":42},"end":{"line":125,"column":46}}]},"5":{"line":125,"type":"binary-expr","locations":[{"start":{"line":125,"column":12},"end":{"line":125,"column":13}},{"start":{"line":125,"column":17},"end":{"line":125,"column":24}}]},"6":{"line":133,"type":"if","locations":[{"start":{"line":133,"column":2},"end":{"line":133,"column":2}},{"start":{"line":133,"column":2},"end":{"line":133,"column":2}}]},"7":{"line":136,"type":"if","locations":[{"start":{"line":136,"column":2},"end":{"line":136,"column":2}},{"start":{"line":136,"column":2},"end":{"line":136,"column":2}}]},"8":{"line":139,"type":"if","locations":[{"start":{"line":139,"column":2},"end":{"line":139,"column":2}},{"start":{"line":139,"column":2},"end":{"line":139,"column":2}}]},"9":{"line":139,"type":"binary-expr","locations":[{"start":{"line":139,"column":6},"end":{"line":139,"column":19}},{"start":{"line":139,"column":23},"end":{"line":139,"column":42}},{"start":{"line":139,"column":46},"end":{"line":139,"column":65}},{"start":{"line":139,"column":68},"end":{"line":139,"column":87}}]},"10":{"line":141,"type":"binary-expr","locations":[{"start":{"line":141,"column":7},"end":{"line":141,"column":30}},{"start":{"line":141,"column":34},"end":{"line":141,"column":61}}]},"11":{"line":143,"type":"if","locations":[{"start":{"line":143,"column":2},"end":{"line":143,"column":2}},{"start":{"line":143,"column":2},"end":{"line":143,"column":2}}]},"12":{"line":143,"type":"binary-expr","locations":[{"start":{"line":143,"column":6},"end":{"line":143,"column":23}},{"start":{"line":143,"column":27},"end":{"line":143,"column":46}}]},"13":{"line":149,"type":"if","locations":[{"start":{"line":149,"column":3},"end":{"line":149,"column":3}},{"start":{"line":149,"column":3},"end":{"line":149,"column":3}}]},"14":{"line":157,"type":"if","locations":[{"start":{"line":157,"column":1},"end":{"line":157,"column":1}},{"start":{"line":157,"column":1},"end":{"line":157,"column":1}}]},"15":{"line":172,"type":"if","locations":[{"start":{"line":172,"column":4},"end":{"line":172,"column":4}},{"start":{"line":172,"column":4},"end":{"line":172,"column":4}}]}}},"src/core/extras.js":{"path":"src/core/extras.js","s":{"1":1,"2":1,"3":0,"4":0,"5":0,"6":1,"7":1,"8":166,"9":81,"10":81,"11":0,"12":0,"13":0,"14":0,"15":0,"16":0,"17":0,"18":0,"19":0,"20":0,"21":0,"22":0,"23":0,"24":0,"25":0,"26":0,"27":0,"28":0,"29":1,"30":0,"31":0,"32":0,"33":6,"34":0,"35":6,"36":166,"37":166,"38":166,"39":85,"40":81,"41":81,"42":1,"43":80,"44":1,"45":8,"46":166,"47":1,"48":2,"49":2,"50":1,"51":2,"52":2,"53":1,"54":3,"55":6,"56":6,"57":0,"58":6,"59":6,"60":6,"61":6,"62":1,"63":3,"64":3,"65":1,"66":2,"67":1,"68":1},"b":{"1":[0,0],"2":[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0],"3":[0,0],"4":[0,0],"5":[0,6],"6":[166,160],"7":[85,81],"8":[1,80],"9":[0,6],"10":[6,6],"11":[6,0],"12":[1,2],"13":[1,0]},"f":{"1":1,"2":0,"3":166,"4":81,"5":6,"6":166,"7":8,"8":166,"9":2,"10":2,"11":3,"12":6,"13":3},"fnMap":{"1":{"name":"(anonymous_1)","line":1,"loc":{"start":{"line":1,"column":1},"end":{"line":1,"column":13}}},"2":{"name":"(anonymous_2)","line":5,"loc":{"start":{"line":5,"column":6},"end":{"line":5,"column":22}}},"3":{"name":"(anonymous_3)","line":82,"loc":{"start":{"line":82,"column":15},"end":{"line":82,"column":28}}},"4":{"name":"(anonymous_4)","line":85,"loc":{"start":{"line":85,"column":15},"end":{"line":85,"column":31}}},"5":{"name":"(anonymous_5)","line":135,"loc":{"start":{"line":135,"column":26},"end":{"line":135,"column":39}}},"6":{"name":"(anonymous_6)","line":143,"loc":{"start":{"line":143,"column":9},"end":{"line":143,"column":31}}},"7":{"name":"(anonymous_7)","line":159,"loc":{"start":{"line":159,"column":22},"end":{"line":159,"column":49}}},"8":{"name":"(anonymous_8)","line":160,"loc":{"start":{"line":160,"column":40},"end":{"line":160,"column":51}}},"9":{"name":"(anonymous_9)","line":175,"loc":{"start":{"line":175,"column":15},"end":{"line":175,"column":39}}},"10":{"name":"(anonymous_10)","line":191,"loc":{"start":{"line":191,"column":16},"end":{"line":191,"column":32}}},"11":{"name":"(anonymous_11)","line":288,"loc":{"start":{"line":288,"column":21},"end":{"line":288,"column":40}}},"12":{"name":"(anonymous_12)","line":289,"loc":{"start":{"line":289,"column":9},"end":{"line":289,"column":22}}},"13":{"name":"(anonymous_13)","line":302,"loc":{"start":{"line":302,"column":14},"end":{"line":302,"column":32}}}},"statementMap":{"1":{"start":{"line":1,"column":0},"end":{"line":314,"column":5}},"2":{"start":{"line":2,"column":1},"end":{"line":10,"column":4}},"3":{"start":{"line":6,"column":3},"end":{"line":8,"column":4}},"4":{"start":{"line":7,"column":4},"end":{"line":7,"column":10}},"5":{"start":{"line":9,"column":3},"end":{"line":9,"column":36}},"6":{"start":{"line":30,"column":2},"end":{"line":80,"column":3}},"7":{"start":{"line":81,"column":1},"end":{"line":157,"column":3}},"8":{"start":{"line":83,"column":3},"end":{"line":83,"column":37}},"9":{"start":{"line":86,"column":3},"end":{"line":86,"column":9}},"10":{"start":{"line":87,"column":3},"end":{"line":133,"column":4}},"11":{"start":{"line":89,"column":5},"end":{"line":89,"column":27}},"12":{"start":{"line":91,"column":5},"end":{"line":91,"column":33}},"13":{"start":{"line":93,"column":5},"end":{"line":93,"column":39}},"14":{"start":{"line":95,"column":5},"end":{"line":96,"column":55}},"15":{"start":{"line":97,"column":5},"end":{"line":97,"column":90}},"16":{"start":{"line":100,"column":5},"end":{"line":100,"column":27}},"17":{"start":{"line":102,"column":5},"end":{"line":102,"column":61}},"18":{"start":{"line":105,"column":5},"end":{"line":105,"column":55}},"19":{"start":{"line":107,"column":5},"end":{"line":107,"column":38}},"20":{"start":{"line":110,"column":5},"end":{"line":110,"column":34}},"21":{"start":{"line":112,"column":5},"end":{"line":112,"column":34}},"22":{"start":{"line":114,"column":5},"end":{"line":114,"column":38}},"23":{"start":{"line":116,"column":5},"end":{"line":116,"column":47}},"24":{"start":{"line":118,"column":5},"end":{"line":118,"column":29}},"25":{"start":{"line":120,"column":5},"end":{"line":120,"column":26}},"26":{"start":{"line":121,"column":5},"end":{"line":121,"column":75}},"27":{"start":{"line":123,"column":5},"end":{"line":123,"column":26}},"28":{"start":{"line":124,"column":5},"end":{"line":124,"column":140}},"29":{"start":{"line":126,"column":5},"end":{"line":126,"column":47}},"30":{"start":{"line":128,"column":5},"end":{"line":128,"column":32}},"31":{"start":{"line":130,"column":5},"end":{"line":130,"column":34}},"32":{"start":{"line":132,"column":5},"end":{"line":132,"column":50}},"33":{"start":{"line":136,"column":3},"end":{"line":141,"column":4}},"34":{"start":{"line":138,"column":5},"end":{"line":138,"column":17}},"35":{"start":{"line":140,"column":5},"end":{"line":140,"column":18}},"36":{"start":{"line":144,"column":3},"end":{"line":144,"column":47}},"37":{"start":{"line":145,"column":3},"end":{"line":145,"column":44}},"38":{"start":{"line":146,"column":3},"end":{"line":148,"column":4}},"39":{"start":{"line":147,"column":4},"end":{"line":147,"column":24}},"40":{"start":{"line":149,"column":3},"end":{"line":149,"column":47}},"41":{"start":{"line":151,"column":3},"end":{"line":155,"column":4}},"42":{"start":{"line":152,"column":4},"end":{"line":152,"column":24}},"43":{"start":{"line":154,"column":4},"end":{"line":154,"column":13}},"44":{"start":{"line":159,"column":1},"end":{"line":163,"column":3}},"45":{"start":{"line":160,"column":2},"end":{"line":162,"column":5}},"46":{"start":{"line":161,"column":4},"end":{"line":161,"column":40}},"47":{"start":{"line":175,"column":1},"end":{"line":178,"column":3}},"48":{"start":{"line":176,"column":2},"end":{"line":176,"column":27}},"49":{"start":{"line":177,"column":2},"end":{"line":177,"column":27}},"50":{"start":{"line":191,"column":1},"end":{"line":194,"column":3}},"51":{"start":{"line":192,"column":2},"end":{"line":192,"column":25}},"52":{"start":{"line":193,"column":2},"end":{"line":193,"column":167}},"53":{"start":{"line":288,"column":1},"end":{"line":301,"column":3}},"54":{"start":{"line":289,"column":2},"end":{"line":300,"column":4}},"55":{"start":{"line":290,"column":3},"end":{"line":290,"column":38}},"56":{"start":{"line":291,"column":3},"end":{"line":293,"column":4}},"57":{"start":{"line":292,"column":4},"end":{"line":292,"column":50}},"58":{"start":{"line":295,"column":3},"end":{"line":295,"column":51}},"59":{"start":{"line":296,"column":3},"end":{"line":296,"column":49}},"60":{"start":{"line":297,"column":3},"end":{"line":299,"column":4}},"61":{"start":{"line":298,"column":4},"end":{"line":298,"column":52}},"62":{"start":{"line":302,"column":1},"end":{"line":309,"column":3}},"63":{"start":{"line":303,"column":2},"end":{"line":303,"column":38}},"64":{"start":{"line":304,"column":2},"end":{"line":308,"column":3}},"65":{"start":{"line":305,"column":3},"end":{"line":305,"column":27}},"66":{"start":{"line":307,"column":3},"end":{"line":307,"column":52}},"67":{"start":{"line":311,"column":1},"end":{"line":313,"column":2}},"68":{"start":{"line":312,"column":2},"end":{"line":312,"column":25}}},"branchMap":{"1":{"line":6,"type":"if","locations":[{"start":{"line":6,"column":3},"end":{"line":6,"column":3}},{"start":{"line":6,"column":3},"end":{"line":6,"column":3}}]},"2":{"line":87,"type":"switch","locations":[{"start":{"line":88,"column":4},"end":{"line":89,"column":27}},{"start":{"line":90,"column":4},"end":{"line":91,"column":33}},{"start":{"line":92,"column":4},"end":{"line":93,"column":39}},{"start":{"line":94,"column":4},"end":{"line":97,"column":90}},{"start":{"line":99,"column":4},"end":{"line":100,"column":27}},{"start":{"line":101,"column":4},"end":{"line":102,"column":61}},{"start":{"line":103,"column":4},"end":{"line":103,"column":13}},{"start":{"line":104,"column":4},"end":{"line":105,"column":55}},{"start":{"line":106,"column":4},"end":{"line":107,"column":38}},{"start":{"line":108,"column":4},"end":{"line":108,"column":13}},{"start":{"line":109,"column":4},"end":{"line":110,"column":34}},{"start":{"line":111,"column":4},"end":{"line":112,"column":34}},{"start":{"line":113,"column":4},"end":{"line":114,"column":38}},{"start":{"line":115,"column":4},"end":{"line":116,"column":47}},{"start":{"line":117,"column":4},"end":{"line":118,"column":29}},{"start":{"line":119,"column":4},"end":{"line":121,"column":75}},{"start":{"line":122,"column":4},"end":{"line":124,"column":140}},{"start":{"line":125,"column":4},"end":{"line":126,"column":47}},{"start":{"line":127,"column":4},"end":{"line":128,"column":32}},{"start":{"line":129,"column":4},"end":{"line":130,"column":34}},{"start":{"line":131,"column":4},"end":{"line":132,"column":50}}]},"3":{"line":97,"type":"cond-expr","locations":[{"start":{"line":97,"column":24},"end":{"line":97,"column":28}},{"start":{"line":97,"column":31},"end":{"line":97,"column":89}}]},"4":{"line":116,"type":"cond-expr","locations":[{"start":{"line":116,"column":41},"end":{"line":116,"column":42}},{"start":{"line":116,"column":45},"end":{"line":116,"column":46}}]},"5":{"line":136,"type":"switch","locations":[{"start":{"line":137,"column":4},"end":{"line":138,"column":17}},{"start":{"line":139,"column":4},"end":{"line":140,"column":18}}]},"6":{"line":144,"type":"binary-expr","locations":[{"start":{"line":144,"column":25},"end":{"line":144,"column":32}},{"start":{"line":144,"column":36},"end":{"line":144,"column":46}}]},"7":{"line":146,"type":"if","locations":[{"start":{"line":146,"column":3},"end":{"line":146,"column":3}},{"start":{"line":146,"column":3},"end":{"line":146,"column":3}}]},"8":{"line":151,"type":"if","locations":[{"start":{"line":151,"column":3},"end":{"line":151,"column":3}},{"start":{"line":151,"column":3},"end":{"line":151,"column":3}}]},"9":{"line":291,"type":"if","locations":[{"start":{"line":291,"column":3},"end":{"line":291,"column":3}},{"start":{"line":291,"column":3},"end":{"line":291,"column":3}}]},"10":{"line":291,"type":"binary-expr","locations":[{"start":{"line":291,"column":7},"end":{"line":291,"column":27}},{"start":{"line":291,"column":31},"end":{"line":291,"column":57}}]},"11":{"line":297,"type":"if","locations":[{"start":{"line":297,"column":3},"end":{"line":297,"column":3}},{"start":{"line":297,"column":3},"end":{"line":297,"column":3}}]},"12":{"line":304,"type":"if","locations":[{"start":{"line":304,"column":2},"end":{"line":304,"column":2}},{"start":{"line":304,"column":2},"end":{"line":304,"column":2}}]},"13":{"line":311,"type":"if","locations":[{"start":{"line":311,"column":1},"end":{"line":311,"column":1}},{"start":{"line":311,"column":1},"end":{"line":311,"column":1}}]}}},"src/core/time_period.js":{"path":"src/core/time_period.js","s":{"1":1,"2":1,"3":1,"4":7,"5":0,"6":1,"7":7,"8":0,"9":0,"10":1,"11":1,"12":7,"13":7,"14":7,"15":7,"16":1,"17":1,"18":0,"19":0,"20":0,"21":0,"22":0,"23":0,"24":0,"25":0,"26":0,"27":0,"28":0,"29":0,"30":0,"31":1,"32":0,"33":0,"34":0,"35":0,"36":0,"37":1,"38":0,"39":0,"40":0,"41":0,"42":0,"43":0,"44":0,"45":0,"46":0,"47":0,"48":0,"49":0,"50":0,"51":0,"52":1,"53":1,"54":0,"55":0,"56":0,"57":0,"58":0,"59":0,"60":0,"61":1,"62":1,"63":1},"b":{"1":[0,0],"2":[0,0],"3":[0,0],"4":[0,0],"5":[0,0],"6":[0,0],"7":[0,0],"8":[0,0,0],"9":[0,0],"10":[0,0],"11":[0,0],"12":[0,0],"13":[0,0],"14":[0,0],"15":[0,0],"16":[0,0],"17":[0,0],"18":[1,0]},"f":{"1":1,"2":7,"3":0,"4":7,"5":0,"6":1,"7":0,"8":0,"9":0,"10":0,"11":0},"fnMap":{"1":{"name":"(anonymous_1)","line":1,"loc":{"start":{"line":1,"column":1},"end":{"line":1,"column":13}}},"2":{"name":"(anonymous_2)","line":4,"loc":{"start":{"line":4,"column":11},"end":{"line":4,"column":27}}},"3":{"name":"(anonymous_3)","line":5,"loc":{"start":{"line":5,"column":9},"end":{"line":5,"column":21}}},"4":{"name":"(anonymous_4)","line":10,"loc":{"start":{"line":10,"column":11},"end":{"line":10,"column":27}}},"5":{"name":"(anonymous_5)","line":11,"loc":{"start":{"line":11,"column":9},"end":{"line":11,"column":24}}},"6":{"name":"(anonymous_6)","line":16,"loc":{"start":{"line":16,"column":19},"end":{"line":16,"column":45}}},"7":{"name":"(anonymous_7)","line":25,"loc":{"start":{"line":25,"column":25},"end":{"line":25,"column":60}}},"8":{"name":"inc","line":26,"loc":{"start":{"line":26,"column":2},"end":{"line":26,"column":17}}},"9":{"name":"(anonymous_9)","line":48,"loc":{"start":{"line":48,"column":20},"end":{"line":48,"column":57}}},"10":{"name":"(anonymous_10)","line":60,"loc":{"start":{"line":60,"column":18},"end":{"line":60,"column":88}}},"11":{"name":"(anonymous_11)","line":85,"loc":{"start":{"line":85,"column":28},"end":{"line":85,"column":97}}}},"statementMap":{"1":{"start":{"line":1,"column":0},"end":{"line":101,"column":5}},"2":{"start":{"line":3,"column":1},"end":{"line":3,"column":88}},"3":{"start":{"line":4,"column":1},"end":{"line":8,"column":3}},"4":{"start":{"line":5,"column":2},"end":{"line":7,"column":4}},"5":{"start":{"line":6,"column":3},"end":{"line":6,"column":21}},"6":{"start":{"line":10,"column":1},"end":{"line":15,"column":3}},"7":{"start":{"line":11,"column":2},"end":{"line":14,"column":4}},"8":{"start":{"line":12,"column":3},"end":{"line":12,"column":20}},"9":{"start":{"line":13,"column":3},"end":{"line":13,"column":15}},"10":{"start":{"line":16,"column":1},"end":{"line":23,"column":3}},"11":{"start":{"line":17,"column":2},"end":{"line":22,"column":3}},"12":{"start":{"line":18,"column":3},"end":{"line":18,"column":70}},"13":{"start":{"line":19,"column":3},"end":{"line":19,"column":29}},"14":{"start":{"line":20,"column":3},"end":{"line":20,"column":43}},"15":{"start":{"line":21,"column":3},"end":{"line":21,"column":43}},"16":{"start":{"line":25,"column":1},"end":{"line":46,"column":3}},"17":{"start":{"line":26,"column":2},"end":{"line":33,"column":3}},"18":{"start":{"line":27,"column":3},"end":{"line":27,"column":25}},"19":{"start":{"line":28,"column":3},"end":{"line":28,"column":20}},"20":{"start":{"line":29,"column":3},"end":{"line":32,"column":4}},"21":{"start":{"line":30,"column":4},"end":{"line":30,"column":20}},"22":{"start":{"line":31,"column":4},"end":{"line":31,"column":23}},"23":{"start":{"line":34,"column":2},"end":{"line":42,"column":3}},"24":{"start":{"line":35,"column":3},"end":{"line":37,"column":4}},"25":{"start":{"line":36,"column":4},"end":{"line":36,"column":10}},"26":{"start":{"line":39,"column":3},"end":{"line":41,"column":4}},"27":{"start":{"line":40,"column":4},"end":{"line":40,"column":10}},"28":{"start":{"line":43,"column":2},"end":{"line":43,"column":19}},"29":{"start":{"line":44,"column":2},"end":{"line":44,"column":27}},"30":{"start":{"line":45,"column":2},"end":{"line":45,"column":26}},"31":{"start":{"line":48,"column":1},"end":{"line":55,"column":3}},"32":{"start":{"line":49,"column":2},"end":{"line":49,"column":105}},"33":{"start":{"line":50,"column":2},"end":{"line":54,"column":3}},"34":{"start":{"line":51,"column":3},"end":{"line":51,"column":26}},"35":{"start":{"line":52,"column":9},"end":{"line":54,"column":3}},"36":{"start":{"line":53,"column":3},"end":{"line":53,"column":25}},"37":{"start":{"line":60,"column":1},"end":{"line":82,"column":3}},"38":{"start":{"line":61,"column":2},"end":{"line":80,"column":3}},"39":{"start":{"line":62,"column":3},"end":{"line":62,"column":72}},"40":{"start":{"line":63,"column":9},"end":{"line":80,"column":3}},"41":{"start":{"line":64,"column":3},"end":{"line":64,"column":40}},"42":{"start":{"line":65,"column":3},"end":{"line":65,"column":38}},"43":{"start":{"line":66,"column":3},"end":{"line":66,"column":48}},"44":{"start":{"line":67,"column":3},"end":{"line":70,"column":5}},"45":{"start":{"line":72,"column":3},"end":{"line":72,"column":55}},"46":{"start":{"line":73,"column":3},"end":{"line":73,"column":44}},"47":{"start":{"line":75,"column":3},"end":{"line":75,"column":34}},"48":{"start":{"line":76,"column":3},"end":{"line":79,"column":4}},"49":{"start":{"line":77,"column":4},"end":{"line":77,"column":32}},"50":{"start":{"line":78,"column":4},"end":{"line":78,"column":123}},"51":{"start":{"line":81,"column":2},"end":{"line":81,"column":14}},"52":{"start":{"line":84,"column":1},"end":{"line":84,"column":32}},"53":{"start":{"line":85,"column":1},"end":{"line":93,"column":3}},"54":{"start":{"line":86,"column":2},"end":{"line":86,"column":42}},"55":{"start":{"line":87,"column":2},"end":{"line":87,"column":45}},"56":{"start":{"line":88,"column":2},"end":{"line":88,"column":39}},"57":{"start":{"line":89,"column":2},"end":{"line":89,"column":42}},"58":{"start":{"line":90,"column":2},"end":{"line":90,"column":48}},"59":{"start":{"line":91,"column":2},"end":{"line":91,"column":48}},"60":{"start":{"line":92,"column":2},"end":{"line":92,"column":63}},"61":{"start":{"line":95,"column":1},"end":{"line":95,"column":30}},"62":{"start":{"line":97,"column":1},"end":{"line":100,"column":2}},"63":{"start":{"line":99,"column":2},"end":{"line":99,"column":33}}},"branchMap":{"1":{"line":29,"type":"if","locations":[{"start":{"line":29,"column":3},"end":{"line":29,"column":3}},{"start":{"line":29,"column":3},"end":{"line":29,"column":3}}]},"2":{"line":34,"type":"if","locations":[{"start":{"line":34,"column":2},"end":{"line":34,"column":2}},{"start":{"line":34,"column":2},"end":{"line":34,"column":2}}]},"3":{"line":50,"type":"if","locations":[{"start":{"line":50,"column":2},"end":{"line":50,"column":2}},{"start":{"line":50,"column":2},"end":{"line":50,"column":2}}]},"4":{"line":50,"type":"binary-expr","locations":[{"start":{"line":50,"column":6},"end":{"line":50,"column":20}},{"start":{"line":50,"column":24},"end":{"line":50,"column":36}}]},"5":{"line":52,"type":"if","locations":[{"start":{"line":52,"column":9},"end":{"line":52,"column":9}},{"start":{"line":52,"column":9},"end":{"line":52,"column":9}}]},"6":{"line":61,"type":"if","locations":[{"start":{"line":61,"column":2},"end":{"line":61,"column":2}},{"start":{"line":61,"column":2},"end":{"line":61,"column":2}}]},"7":{"line":63,"type":"if","locations":[{"start":{"line":63,"column":9},"end":{"line":63,"column":9}},{"start":{"line":63,"column":9},"end":{"line":63,"column":9}}]},"8":{"line":63,"type":"binary-expr","locations":[{"start":{"line":63,"column":13},"end":{"line":63,"column":35}},{"start":{"line":63,"column":39},"end":{"line":63,"column":67}},{"start":{"line":63,"column":71},"end":{"line":63,"column":99}}]},"9":{"line":66,"type":"cond-expr","locations":[{"start":{"line":66,"column":40},"end":{"line":66,"column":42}},{"start":{"line":66,"column":45},"end":{"line":66,"column":47}}]},"10":{"line":76,"type":"if","locations":[{"start":{"line":76,"column":3},"end":{"line":76,"column":3}},{"start":{"line":76,"column":3},"end":{"line":76,"column":3}}]},"11":{"line":86,"type":"binary-expr","locations":[{"start":{"line":86,"column":16},"end":{"line":86,"column":21}},{"start":{"line":86,"column":25},"end":{"line":86,"column":40}}]},"12":{"line":87,"type":"binary-expr","locations":[{"start":{"line":87,"column":17},"end":{"line":87,"column":23}},{"start":{"line":87,"column":27},"end":{"line":87,"column":43}}]},"13":{"line":88,"type":"binary-expr","locations":[{"start":{"line":88,"column":15},"end":{"line":88,"column":19}},{"start":{"line":88,"column":23},"end":{"line":88,"column":37}}]},"14":{"line":89,"type":"binary-expr","locations":[{"start":{"line":89,"column":16},"end":{"line":89,"column":21}},{"start":{"line":89,"column":25},"end":{"line":89,"column":40}}]},"15":{"line":90,"type":"binary-expr","locations":[{"start":{"line":90,"column":18},"end":{"line":90,"column":25}},{"start":{"line":90,"column":29},"end":{"line":90,"column":46}}]},"16":{"line":91,"type":"binary-expr","locations":[{"start":{"line":91,"column":18},"end":{"line":91,"column":25}},{"start":{"line":91,"column":29},"end":{"line":91,"column":46}}]},"17":{"line":92,"type":"binary-expr","locations":[{"start":{"line":92,"column":23},"end":{"line":92,"column":35}},{"start":{"line":92,"column":39},"end":{"line":92,"column":61}}]},"18":{"line":97,"type":"if","locations":[{"start":{"line":97,"column":1},"end":{"line":97,"column":1}},{"start":{"line":97,"column":1},"end":{"line":97,"column":1}}]}}},"src/core/time_span.js":{"path":"src/core/time_span.js","s":{"1":1,"2":1,"3":5,"4":0,"5":1,"6":5,"7":0,"8":0,"9":1,"10":1,"11":1,"12":5,"13":5,"14":5,"15":5,"16":1,"17":0,"18":0,"19":0,"20":0,"21":0,"22":0,"23":0,"24":0,"25":0,"26":0,"27":0,"28":0,"29":0,"30":0,"31":0,"32":0,"33":0,"34":0,"35":0,"36":0,"37":0,"38":0,"39":0,"40":0,"41":0,"42":0,"43":0,"44":0,"45":0,"46":0,"47":0,"48":0,"49":0,"50":0,"51":0,"52":0,"53":0,"54":0,"55":0,"56":0,"57":0,"58":0,"59":0,"60":0,"61":0,"62":0,"63":0,"64":0,"65":0,"66":0,"67":0,"68":0,"69":0,"70":0,"71":0,"72":0,"73":0,"74":0,"75":0,"76":0,"77":0,"78":0,"79":0,"80":0,"81":1,"82":1,"83":0,"84":0,"85":0,"86":0,"87":0,"88":1,"89":0,"90":1,"91":1,"92":1},"b":{"1":[0,0],"2":[0,0],"3":[0,0],"4":[0,0],"5":[0,0],"6":[0,0],"7":[0,0],"8":[0,0],"9":[0,0],"10":[0,0],"11":[0,0],"12":[0,0],"13":[0,0],"14":[0,0],"15":[0,0],"16":[0,0,0,0,0,0,0,0,0,0,0,0],"17":[0,0],"18":[0,0],"19":[0,0],"20":[0,0],"21":[0,0],"22":[0,0],"23":[0,0],"24":[1,0]},"f":{"1":1,"2":5,"3":0,"4":5,"5":0,"6":1,"7":0,"8":0,"9":0,"10":0,"11":0,"12":0,"13":0,"14":0,"15":0,"16":0,"17":0,"18":0,"19":0,"20":0,"21":0,"22":0,"23":0,"24":0,"25":0},"fnMap":{"1":{"name":"(anonymous_1)","line":1,"loc":{"start":{"line":1,"column":1},"end":{"line":1,"column":13}}},"2":{"name":"(anonymous_2)","line":3,"loc":{"start":{"line":3,"column":11},"end":{"line":3,"column":27}}},"3":{"name":"(anonymous_3)","line":4,"loc":{"start":{"line":4,"column":9},"end":{"line":4,"column":21}}},"4":{"name":"(anonymous_4)","line":9,"loc":{"start":{"line":9,"column":11},"end":{"line":9,"column":27}}},"5":{"name":"(anonymous_5)","line":10,"loc":{"start":{"line":10,"column":9},"end":{"line":10,"column":24}}},"6":{"name":"(anonymous_6)","line":16,"loc":{"start":{"line":16,"column":19},"end":{"line":16,"column":45}}},"7":{"name":"(anonymous_7)","line":29,"loc":{"start":{"line":29,"column":16},"end":{"line":29,"column":71}}},"8":{"name":"(anonymous_8)","line":46,"loc":{"start":{"line":46,"column":30},"end":{"line":46,"column":42}}},"9":{"name":"(anonymous_9)","line":53,"loc":{"start":{"line":53,"column":19},"end":{"line":53,"column":35}}},"10":{"name":"(anonymous_10)","line":64,"loc":{"start":{"line":64,"column":16},"end":{"line":64,"column":32}}},"11":{"name":"(anonymous_11)","line":68,"loc":{"start":{"line":68,"column":13},"end":{"line":68,"column":29}}},"12":{"name":"(anonymous_12)","line":72,"loc":{"start":{"line":72,"column":18},"end":{"line":72,"column":34}}},"13":{"name":"(anonymous_13)","line":76,"loc":{"start":{"line":76,"column":17},"end":{"line":76,"column":30}}},"14":{"name":"(anonymous_14)","line":80,"loc":{"start":{"line":80,"column":18},"end":{"line":80,"column":31}}},"15":{"name":"(anonymous_15)","line":84,"loc":{"start":{"line":84,"column":20},"end":{"line":84,"column":33}}},"16":{"name":"(anonymous_16)","line":88,"loc":{"start":{"line":88,"column":20},"end":{"line":88,"column":33}}},"17":{"name":"(anonymous_17)","line":92,"loc":{"start":{"line":92,"column":25},"end":{"line":92,"column":38}}},"18":{"name":"(anonymous_18)","line":96,"loc":{"start":{"line":96,"column":23},"end":{"line":96,"column":35}}},"19":{"name":"(anonymous_19)","line":100,"loc":{"start":{"line":100,"column":23},"end":{"line":100,"column":35}}},"20":{"name":"(anonymous_20)","line":104,"loc":{"start":{"line":104,"column":18},"end":{"line":104,"column":36}}},"21":{"name":"(anonymous_21)","line":105,"loc":{"start":{"line":105,"column":20},"end":{"line":105,"column":32}}},"22":{"name":"(anonymous_22)","line":113,"loc":{"start":{"line":113,"column":12},"end":{"line":113,"column":25}}},"23":{"name":"(anonymous_23)","line":120,"loc":{"start":{"line":120,"column":3},"end":{"line":120,"column":21}}},"24":{"name":"(anonymous_24)","line":153,"loc":{"start":{"line":153,"column":26},"end":{"line":153,"column":80}}},"25":{"name":"(anonymous_25)","line":166,"loc":{"start":{"line":166,"column":31},"end":{"line":166,"column":43}}}},"statementMap":{"1":{"start":{"line":1,"column":0},"end":{"line":176,"column":5}},"2":{"start":{"line":3,"column":1},"end":{"line":7,"column":3}},"3":{"start":{"line":4,"column":2},"end":{"line":6,"column":4}},"4":{"start":{"line":5,"column":3},"end":{"line":5,"column":21}},"5":{"start":{"line":9,"column":1},"end":{"line":14,"column":3}},"6":{"start":{"line":10,"column":2},"end":{"line":13,"column":4}},"7":{"start":{"line":11,"column":3},"end":{"line":11,"column":20}},"8":{"start":{"line":12,"column":3},"end":{"line":12,"column":15}},"9":{"start":{"line":15,"column":1},"end":{"line":15,"column":88}},"10":{"start":{"line":16,"column":1},"end":{"line":23,"column":3}},"11":{"start":{"line":17,"column":2},"end":{"line":22,"column":3}},"12":{"start":{"line":18,"column":3},"end":{"line":18,"column":70}},"13":{"start":{"line":19,"column":3},"end":{"line":19,"column":29}},"14":{"start":{"line":20,"column":3},"end":{"line":20,"column":43}},"15":{"start":{"line":21,"column":3},"end":{"line":21,"column":43}},"16":{"start":{"line":29,"column":1},"end":{"line":151,"column":3}},"17":{"start":{"line":30,"column":2},"end":{"line":44,"column":3}},"18":{"start":{"line":31,"column":3},"end":{"line":31,"column":37}},"19":{"start":{"line":32,"column":3},"end":{"line":32,"column":34}},"20":{"start":{"line":33,"column":3},"end":{"line":33,"column":59}},"21":{"start":{"line":34,"column":3},"end":{"line":34,"column":36}},"22":{"start":{"line":35,"column":3},"end":{"line":35,"column":59}},"23":{"start":{"line":36,"column":3},"end":{"line":36,"column":35}},"24":{"start":{"line":37,"column":3},"end":{"line":37,"column":59}},"25":{"start":{"line":38,"column":3},"end":{"line":38,"column":33}},"26":{"start":{"line":39,"column":3},"end":{"line":39,"column":58}},"27":{"start":{"line":40,"column":3},"end":{"line":40,"column":32}},"28":{"start":{"line":41,"column":3},"end":{"line":41,"column":44}},"29":{"start":{"line":43,"column":3},"end":{"line":43,"column":57}},"30":{"start":{"line":46,"column":2},"end":{"line":51,"column":4}},"31":{"start":{"line":47,"column":3},"end":{"line":50,"column":32}},"32":{"start":{"line":53,"column":2},"end":{"line":62,"column":4}},"33":{"start":{"line":54,"column":3},"end":{"line":54,"column":92}},"34":{"start":{"line":55,"column":3},"end":{"line":60,"column":4}},"35":{"start":{"line":56,"column":4},"end":{"line":56,"column":39}},"36":{"start":{"line":59,"column":4},"end":{"line":59,"column":85}},"37":{"start":{"line":61,"column":3},"end":{"line":61,"column":45}},"38":{"start":{"line":64,"column":2},"end":{"line":66,"column":4}},"39":{"start":{"line":65,"column":3},"end":{"line":65,"column":39}},"40":{"start":{"line":68,"column":2},"end":{"line":70,"column":4}},"41":{"start":{"line":69,"column":3},"end":{"line":69,"column":87}},"42":{"start":{"line":72,"column":2},"end":{"line":74,"column":4}},"43":{"start":{"line":73,"column":3},"end":{"line":73,"column":88}},"44":{"start":{"line":76,"column":2},"end":{"line":78,"column":4}},"45":{"start":{"line":77,"column":3},"end":{"line":77,"column":69}},"46":{"start":{"line":80,"column":2},"end":{"line":82,"column":4}},"47":{"start":{"line":81,"column":3},"end":{"line":81,"column":68}},"48":{"start":{"line":84,"column":2},"end":{"line":86,"column":4}},"49":{"start":{"line":85,"column":3},"end":{"line":85,"column":66}},"50":{"start":{"line":88,"column":2},"end":{"line":90,"column":4}},"51":{"start":{"line":89,"column":3},"end":{"line":89,"column":65}},"52":{"start":{"line":92,"column":2},"end":{"line":94,"column":4}},"53":{"start":{"line":93,"column":3},"end":{"line":93,"column":56}},"54":{"start":{"line":96,"column":2},"end":{"line":98,"column":4}},"55":{"start":{"line":97,"column":3},"end":{"line":97,"column":105}},"56":{"start":{"line":100,"column":2},"end":{"line":102,"column":4}},"57":{"start":{"line":101,"column":3},"end":{"line":101,"column":97}},"58":{"start":{"line":104,"column":2},"end":{"line":149,"column":4}},"59":{"start":{"line":105,"column":3},"end":{"line":111,"column":5}},"60":{"start":{"line":106,"column":4},"end":{"line":110,"column":5}},"61":{"start":{"line":107,"column":5},"end":{"line":107,"column":119}},"62":{"start":{"line":109,"column":5},"end":{"line":109,"column":96}},"63":{"start":{"line":113,"column":3},"end":{"line":115,"column":5}},"64":{"start":{"line":114,"column":4},"end":{"line":114,"column":51}},"65":{"start":{"line":117,"column":3},"end":{"line":117,"column":17}},"66":{"start":{"line":119,"column":3},"end":{"line":148,"column":24}},"67":{"start":{"line":121,"column":4},"end":{"line":146,"column":5}},"68":{"start":{"line":123,"column":5},"end":{"line":123,"column":25}},"69":{"start":{"line":125,"column":5},"end":{"line":125,"column":31}},"70":{"start":{"line":127,"column":5},"end":{"line":127,"column":26}},"71":{"start":{"line":129,"column":5},"end":{"line":129,"column":32}},"72":{"start":{"line":131,"column":5},"end":{"line":131,"column":31}},"73":{"start":{"line":133,"column":5},"end":{"line":133,"column":37}},"74":{"start":{"line":135,"column":5},"end":{"line":135,"column":28}},"75":{"start":{"line":137,"column":5},"end":{"line":137,"column":34}},"76":{"start":{"line":139,"column":5},"end":{"line":139,"column":28}},"77":{"start":{"line":141,"column":5},"end":{"line":141,"column":34}},"78":{"start":{"line":143,"column":5},"end":{"line":143,"column":115}},"79":{"start":{"line":145,"column":5},"end":{"line":145,"column":97}},"80":{"start":{"line":150,"column":2},"end":{"line":150,"column":14}},"81":{"start":{"line":152,"column":1},"end":{"line":152,"column":39}},"82":{"start":{"line":153,"column":1},"end":{"line":159,"column":3}},"83":{"start":{"line":154,"column":2},"end":{"line":154,"column":39}},"84":{"start":{"line":155,"column":2},"end":{"line":155,"column":42}},"85":{"start":{"line":156,"column":2},"end":{"line":156,"column":48}},"86":{"start":{"line":157,"column":2},"end":{"line":157,"column":48}},"87":{"start":{"line":158,"column":2},"end":{"line":158,"column":63}},"88":{"start":{"line":166,"column":1},"end":{"line":168,"column":3}},"89":{"start":{"line":167,"column":2},"end":{"line":167,"column":104}},"90":{"start":{"line":170,"column":1},"end":{"line":170,"column":26}},"91":{"start":{"line":172,"column":1},"end":{"line":175,"column":2}},"92":{"start":{"line":174,"column":2},"end":{"line":174,"column":29}}},"branchMap":{"1":{"line":30,"type":"if","locations":[{"start":{"line":30,"column":2},"end":{"line":30,"column":2}},{"start":{"line":30,"column":2},"end":{"line":30,"column":2}}]},"2":{"line":30,"type":"binary-expr","locations":[{"start":{"line":30,"column":6},"end":{"line":30,"column":28}},{"start":{"line":30,"column":32},"end":{"line":30,"column":56}}]},"3":{"line":31,"type":"cond-expr","locations":[{"start":{"line":31,"column":29},"end":{"line":31,"column":31}},{"start":{"line":31,"column":34},"end":{"line":31,"column":36}}]},"4":{"line":55,"type":"if","locations":[{"start":{"line":55,"column":3},"end":{"line":55,"column":3}},{"start":{"line":55,"column":3},"end":{"line":55,"column":3}}]},"5":{"line":61,"type":"cond-expr","locations":[{"start":{"line":61,"column":22},"end":{"line":61,"column":24}},{"start":{"line":61,"column":27},"end":{"line":61,"column":44}}]},"6":{"line":61,"type":"cond-expr","locations":[{"start":{"line":61,"column":39},"end":{"line":61,"column":40}},{"start":{"line":61,"column":43},"end":{"line":61,"column":44}}]},"7":{"line":69,"type":"cond-expr","locations":[{"start":{"line":69,"column":28},"end":{"line":69,"column":32}},{"start":{"line":69,"column":35},"end":{"line":69,"column":86}}]},"8":{"line":73,"type":"cond-expr","locations":[{"start":{"line":73,"column":28},"end":{"line":73,"column":32}},{"start":{"line":73,"column":35},"end":{"line":73,"column":87}}]},"9":{"line":97,"type":"cond-expr","locations":[{"start":{"line":97,"column":35},"end":{"line":97,"column":55}},{"start":{"line":97,"column":58},"end":{"line":97,"column":104}}]},"10":{"line":97,"type":"cond-expr","locations":[{"start":{"line":97,"column":84},"end":{"line":97,"column":86}},{"start":{"line":97,"column":89},"end":{"line":97,"column":104}}]},"11":{"line":101,"type":"cond-expr","locations":[{"start":{"line":101,"column":35},"end":{"line":101,"column":64}},{"start":{"line":101,"column":67},"end":{"line":101,"column":96}}]},"12":{"line":106,"type":"if","locations":[{"start":{"line":106,"column":4},"end":{"line":106,"column":4}},{"start":{"line":106,"column":4},"end":{"line":106,"column":4}}]},"13":{"line":106,"type":"binary-expr","locations":[{"start":{"line":106,"column":8},"end":{"line":106,"column":31}},{"start":{"line":106,"column":35},"end":{"line":106,"column":53}}]},"14":{"line":114,"type":"cond-expr","locations":[{"start":{"line":114,"column":39},"end":{"line":114,"column":46}},{"start":{"line":114,"column":49},"end":{"line":114,"column":50}}]},"15":{"line":119,"type":"cond-expr","locations":[{"start":{"line":119,"column":19},"end":{"line":148,"column":4}},{"start":{"line":148,"column":7},"end":{"line":148,"column":23}}]},"16":{"line":121,"type":"switch","locations":[{"start":{"line":122,"column":4},"end":{"line":123,"column":25}},{"start":{"line":124,"column":4},"end":{"line":125,"column":31}},{"start":{"line":126,"column":4},"end":{"line":127,"column":26}},{"start":{"line":128,"column":4},"end":{"line":129,"column":32}},{"start":{"line":130,"column":4},"end":{"line":131,"column":31}},{"start":{"line":132,"column":4},"end":{"line":133,"column":37}},{"start":{"line":134,"column":4},"end":{"line":135,"column":28}},{"start":{"line":136,"column":4},"end":{"line":137,"column":34}},{"start":{"line":138,"column":4},"end":{"line":139,"column":28}},{"start":{"line":140,"column":4},"end":{"line":141,"column":34}},{"start":{"line":142,"column":4},"end":{"line":143,"column":115}},{"start":{"line":144,"column":4},"end":{"line":145,"column":97}}]},"17":{"line":143,"type":"cond-expr","locations":[{"start":{"line":143,"column":36},"end":{"line":143,"column":65}},{"start":{"line":143,"column":68},"end":{"line":143,"column":97}}]},"18":{"line":145,"type":"cond-expr","locations":[{"start":{"line":145,"column":35},"end":{"line":145,"column":64}},{"start":{"line":145,"column":67},"end":{"line":145,"column":96}}]},"19":{"line":154,"type":"binary-expr","locations":[{"start":{"line":154,"column":15},"end":{"line":154,"column":19}},{"start":{"line":154,"column":23},"end":{"line":154,"column":37}}]},"20":{"line":155,"type":"binary-expr","locations":[{"start":{"line":155,"column":16},"end":{"line":155,"column":21}},{"start":{"line":155,"column":25},"end":{"line":155,"column":40}}]},"21":{"line":156,"type":"binary-expr","locations":[{"start":{"line":156,"column":18},"end":{"line":156,"column":25}},{"start":{"line":156,"column":29},"end":{"line":156,"column":46}}]},"22":{"line":157,"type":"binary-expr","locations":[{"start":{"line":157,"column":18},"end":{"line":157,"column":25}},{"start":{"line":157,"column":29},"end":{"line":157,"column":46}}]},"23":{"line":158,"type":"binary-expr","locations":[{"start":{"line":158,"column":23},"end":{"line":158,"column":35}},{"start":{"line":158,"column":39},"end":{"line":158,"column":61}}]},"24":{"line":172,"type":"if","locations":[{"start":{"line":172,"column":1},"end":{"line":172,"column":1}},{"start":{"line":172,"column":1},"end":{"line":172,"column":1}}]}}}} ================================================ FILE: reports/lcov-report/core/core-prototypes.js.html ================================================ Code coverage report for core/core-prototypes.js

Code coverage report for core/core-prototypes.js

Statements: 95.1% (291 / 306)      Branches: 83.33% (195 / 234)      Functions: 100% (50 / 50)      Lines: 96.28% (285 / 296)      Ignored: none     

All files » core/ » core-prototypes.js
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 7691 1     4331 2871   4331     1 151 151 335 119 119 119   216     151 565 565   565 330       150             1 2100 2100 2100 2100 2100             1 3 3 3 3 3 3           1 25               1 408               1 398                 1 1               1 2               1 2                           1 2               1 155 155 155               1 70 70               1 48 46               1 37 37               1 1851 1841 1841               1 14 12 12 12 4 2 2 2       12 5 11 11 11 5     5 7 2     7               1 55 54                 1 413 396 396 396 396 396     1 1       1               1 190 174                           1 508 83 83     425   425             425 1   425 31   425 31   425 31   425 1   425 109   425 109   425 119   425                 1   86 86 2 2   84       86       86   86     86   86 86       86               1 2               1 3 1     1     2       1 1 1     1 14     1 1                 1 15 5 2 2 2   3 2 2 1     1   4   10 10 8   2 2 2 1   2   8       1 2 1183 1183                 1             1         1 1 1           1 1             1 1     1 5 5     1 1             1 3             1 7             1 3 3 2 2   1 1                 1 19                             1 151 150 150 330 330 330 330 226   330 330 330 100 230 69   330 177 153 34         150 119     150             1 11             1 10                                                                                                                       1 7       1     1     1   4     1 1470 1470   1450   1   1   1     2 2   1   1   1   1 1   1   10     1 1498 4446 3   4443   2   4   5   1   11   1   7   1   1460   2         3   3   1424   39   5   3   1418   37   1   5   6   2   1   1   1                                       1       2958 1470 1470 1460     1498 1498      
(function () {
	var $D = Date,
		$P = $D.prototype,
		p = function (s, l) {
			if (!l) {
				l = 2;
			}
			return ("000" + s).slice(l * -1);
		};
 
	var validateConfigObject = function (obj) {
		var result = {}, self = this, prop, testFunc;
		testFunc = function (prop, func, value) {
			if (prop === "day") {
				var month = (obj.month !== undefined) ? obj.month : self.getMonth();
				var year = (obj.year !== undefined) ? obj.year : self.getFullYear();
				return $D[func](value, year, month);
			} else {
				return $D[func](value);
			}
		};
		for (prop in obj) {
			Eif (hasOwnProperty.call(obj, prop)) {
				var func = "validate" + prop.charAt(0).toUpperCase() + prop.slice(1);
 
				if ($D[func] && obj[prop] !== null && testFunc(prop, func, obj[prop])) {
					result[prop] = obj[prop];
				}
			}
		}
		return result;
	};
	/**
	 * Resets the time of this Date object to 12:00 AM (00:00), which is the start of the day.
	 * @param {Boolean}  .clone() this date instance before clearing Time
	 * @return {Date}    this
	 */
	$P.clearTime = function () {
		this.setHours(0);
		this.setMinutes(0);
		this.setSeconds(0);
		this.setMilliseconds(0);
		return this;
	};
 
	/**
	 * Resets the time of this Date object to the current time ('now').
	 * @return {Date}    this
	 */
	$P.setTimeToNow = function () {
		var n = new Date();
		this.setHours(n.getHours());
		this.setMinutes(n.getMinutes());
		this.setSeconds(n.getSeconds());
		this.setMilliseconds(n.getMilliseconds());
		return this;
	};
	/**
	 * Returns a new Date object that is an exact date and time copy of the original instance.
	 * @return {Date}    A new Date instance
	 */
	$P.clone = function () {
		return new Date(this.getTime());
	};
 
	/**
	 * Compares this instance to a Date object and returns an number indication of their relative values.  
	 * @param {Date}     Date object to compare [Required]
	 * @return {Number}  -1 = this is lessthan date. 0 = values are equal. 1 = this is greaterthan date.
	 */
	$P.compareTo = function (date) {
		return Date.compare(this, date);
	};
 
	/**
	 * Compares this instance to another Date object and returns true if they are equal.  
	 * @param {Date}     Date object to compare. If no date to compare, new Date() [now] is used.
	 * @return {Boolean} true if dates are equal. false if they are not equal.
	 */
	$P.equals = function (date) {
		return Date.equals(this, (date !== undefined ? date : new Date()));
	};
 
	/**
	 * Determines if this instance is between a range of two dates or equal to either the start or end dates.
	 * @param {Date}     Start of range [Required]
	 * @param {Date}     End of range [Required]
	 * @return {Boolean} true is this is between or equal to the start and end dates, else false
	 */
	$P.between = function (start, end) {
		return this.getTime() >= start.getTime() && this.getTime() <= end.getTime();
	};
 
	/**
	 * Determines if this date occurs after the date to compare to.
	 * @param {Date}     Date object to compare. If no date to compare, new Date() ("now") is used.
	 * @return {Boolean} true if this date instance is greater than the date to compare to (or "now"), otherwise false.
	 */
	$P.isAfter = function (date) {
		return this.compareTo(date || new Date()) === 1;
	};
 
	/**
	 * Determines if this date occurs before the date to compare to.
	 * @param {Date}     Date object to compare. If no date to compare, new Date() ("now") is used.
	 * @return {Boolean} true if this date instance is less than the date to compare to (or "now").
	 */
	$P.isBefore = function (date) {
		return (this.compareTo(date || new Date()) === -1);
	};
 
	/**
	 * Determines if the current Date instance occurs today.
	 * @return {Boolean} true if this date instance is 'today', otherwise false.
	 */
	
	/**
	 * Determines if the current Date instance occurs on the same Date as the supplied 'date'. 
	 * If no 'date' to compare to is provided, the current Date instance is compared to 'today'. 
	 * @param {date}     Date object to compare. If no date to compare, the current Date ("now") is used.
	 * @return {Boolean} true if this Date instance occurs on the same Day as the supplied 'date'.
	 */
	$P.isToday = $P.isSameDay = function (date) {
		return this.clone().clearTime().equals((date || new Date()).clone().clearTime());
	};
	
	/**
	 * Adds the specified number of milliseconds to this instance. 
	 * @param {Number}   The number of milliseconds to add. The number can be positive or negative [Required]
	 * @return {Date}    this
	 */
	$P.addMilliseconds = function (value) {
		Iif (!value) { return this; }
		this.setTime(this.getTime() + value * 1);
		return this;
	};
 
	/**
	 * Adds the specified number of seconds to this instance. 
	 * @param {Number}   The number of seconds to add. The number can be positive or negative [Required]
	 * @return {Date}    this
	 */
	$P.addSeconds = function (value) {
		Iif (!value) { return this; }
		return this.addMilliseconds(value * 1000);
	};
 
	/**
	 * Adds the specified number of seconds to this instance. 
	 * @param {Number}   The number of seconds to add. The number can be positive or negative [Required]
	 * @return {Date}    this
	 */
	$P.addMinutes = function (value) {
		if (!value) { return this; }
		return this.addMilliseconds(value * 60000); // 60*1000
	};
 
	/**
	 * Adds the specified number of hours to this instance. 
	 * @param {Number}   The number of hours to add. The number can be positive or negative [Required]
	 * @return {Date}    this
	 */
	$P.addHours = function (value) {
		Iif (!value) { return this; }
		return this.addMilliseconds(value * 3600000); // 60*60*1000
	};
 
	/**
	 * Adds the specified number of days to this instance. 
	 * @param {Number}   The number of days to add. The number can be positive or negative [Required]
	 * @return {Date}    this
	 */
	$P.addDays = function (value) {
		if (!value) { return this; }
		this.setDate(this.getDate() + value * 1);
		return this;
	};
 
	/**
	 * Adds the specified number of weekdays (ie - not sat or sun) to this instance. 
	 * @param {Number}   The number of days to add. The number can be positive or negative [Required]
	 * @return {Date}    this
	 */
	$P.addWeekdays = function (value) {
		if (!value) { return this; }
		var day = this.getDay();
		var weeks = (Math.ceil(Math.abs(value)/7));
		if (day === 0 || day === 6) {
			if (value > 0) {
				this.next().monday();
				this.addDays(-1);
				day = this.getDay();
			}
		}
 
		if (value < 0) {
			while (value < 0) {
				this.addDays(-1);
				day = this.getDay();
				if (day !== 0 && day !== 6) {
					value++;
				}
			}
			return this;
		} else if (value > 5 || (6-day) <= value) {
			value = value + (weeks * 2);
		}
 
		return this.addDays(value);
	};
 
	/**
	 * Adds the specified number of weeks to this instance. 
	 * @param {Number}   The number of weeks to add. The number can be positive or negative [Required]
	 * @return {Date}    this
	 */
	$P.addWeeks = function (value) {
		if (!value) { return this; }
		return this.addDays(value * 7);
	};
 
 
	/**
	 * Adds the specified number of months to this instance. 
	 * @param {Number}   The number of months to add. The number can be positive or negative [Required]
	 * @return {Date}    this
	 */
	$P.addMonths = function (value) {
		if (!value) { return this; }
		var n = this.getDate();
		this.setDate(1);
		this.setMonth(this.getMonth() + value * 1);
		this.setDate(Math.min(n, $D.getDaysInMonth(this.getFullYear(), this.getMonth())));
		return this;
	};
 
	$P.addQuarters = function (value) {
		Iif (!value) { return this; }
		// note this will take you to the same point in the quarter as you are now.
		// i.e. - if you are 15 days into the quarter you'll be 15 days into the resulting one.
		// bonus: this allows adding fractional quarters
		return this.addMonths(value * 3);
	};
 
	/**
	 * Adds the specified number of years to this instance. 
	 * @param {Number}   The number of years to add. The number can be positive or negative [Required]
	 * @return {Date}    this
	 */
	$P.addYears = function (value) {
		if (!value) { return this; }
		return this.addMonths(value * 12);
	};
 
	/**
	 * Adds (or subtracts) to the value of the years, months, weeks, days, hours, minutes, seconds, milliseconds of the date instance using given configuration object. Positive and Negative values allowed.
	 * Example
	<pre><code>
	Date.today().add( { days: 1, months: 1 } )
	 
	new Date().add( { years: -1 } )
	</code></pre> 
	 * @param {Object}   Configuration object containing attributes (months, days, etc.)
	 * @return {Date}    this
	 */
	$P.add = function (config) {
		if (typeof config === "number") {
			this._orient = config;
			return this;
		}
		
		var x = config;
 
		Iif (x.day) {
			// If we should be a different date than today (eg: for 'tomorrow -1d', etc).
			// Should only effect parsing, not direct usage (eg, Finish and FinishExact)
			if ((x.day - this.getDate()) !== 0) {
				this.setDate(x.day);
			}
		}
		if (x.milliseconds) {
			this.addMilliseconds(x.milliseconds);
		}
		if (x.seconds) {
			this.addSeconds(x.seconds);
		}
		if (x.minutes) {
			this.addMinutes(x.minutes);
		}
		if (x.hours) {
			this.addHours(x.hours);
		}
		if (x.weeks) {
			this.addWeeks(x.weeks);
		}
		if (x.months) {
			this.addMonths(x.months);
		}
		if (x.years) {
			this.addYears(x.years);
		}
		if (x.days) {
			this.addDays(x.days);
		}
		return this;
	};
	
	/**
	 * Get the week number. Week one (1) is the week which contains the first Thursday of the year. Monday is considered the first day of the week.
	 * The .getWeek() function does NOT convert the date to UTC. The local datetime is used. 
	 * Please use .getISOWeek() to get the week of the UTC converted date.
	 * @return {Number}  1 to 53
	 */
	$P.getWeek = function (utc) {
		// Create a copy of this date object  
		var self, target = new Date(this.valueOf());
		if (utc) {
			target.addMinutes(target.getTimezoneOffset());
			self = target.clone();
		} else {
			self = this;
		}
		// ISO week date weeks start on monday  
		// so correct the day number  
		var dayNr = (self.getDay() + 6) % 7;
		// ISO 8601 states that week 1 is the week  
		// with the first thursday of that year.  
		// Set the target date to the thursday in the target week  
		target.setDate(target.getDate() - dayNr + 3);
		// Store the millisecond value of the target date  
		var firstThursday = target.valueOf();
		// Set the target to the first thursday of the year  
		// First set the target to january first  
		target.setMonth(0, 1);
		// Not a thursday? Correct the date to the next thursday  
		Eif (target.getDay() !== 4) {
			target.setMonth(0, 1 + ((4 - target.getDay()) + 7) % 7);
		}
		// The weeknumber is the number of weeks between the   
		// first thursday of the year and the thursday in the target week  
		return 1 + Math.ceil((firstThursday - target) / 604800000); // 604800000 = 7 * 24 * 3600 * 1000  
	};
	
	/**
	 * Get the ISO 8601 week number. Week one ("01") is the week which contains the first Thursday of the year. Monday is considered the first day of the week.
	 * The .getISOWeek() function does convert the date to it's UTC value. Please use .getWeek() to get the week of the local date.
	 * @return {String}  "01" to "53"
	 */
	$P.getISOWeek = function () {
		return p(this.getWeek(true));
	};
 
	/**
	 * Moves the date to Monday of the week set. Week one (1) is the week which contains the first Thursday of the year.
	 * @param {Number}   A Number (1 to 53) that represents the week of the year.
	 * @return {Date}    this
	 */
	$P.setWeek = function (n) {
		if ((n - this.getWeek()) === 0) {
			Iif (this.getDay() !== 1) {
				return this.moveToDayOfWeek(1, (this.getDay() > 1 ? -1 : 1));
			} else {
				return this;
			}
		} else {
			return this.moveToDayOfWeek(1, (this.getDay() > 1 ? -1 : 1)).addWeeks(n - this.getWeek());
		}
	};
 
	$P.setQuarter = function (qtr) {
		var month = Math.abs(((qtr-1) * 3) + 1);
		return this.setMonth(month, 1);
	};
 
	$P.getQuarter = function () {
		return Date.getQuarter(this);
	};
 
	$P.getDaysLeftInQuarter = function () {
		return Date.getDaysLeftInQuarter(this);
	};
 
	/**
	 * Moves the date to the next n'th occurrence of the dayOfWeek starting from the beginning of the month. The number (-1) is a magic number and will return the last occurrence of the dayOfWeek in the month.
	 * @param {Number}   The dayOfWeek to move to
	 * @param {Number}   The n'th occurrence to move to. Use (-1) to return the last occurrence in the month
	 * @return {Date}    this
	 */
	$P.moveToNthOccurrence = function (dayOfWeek, occurrence) {
		if (dayOfWeek === "Weekday") {
			if (occurrence > 0) {
				this.moveToFirstDayOfMonth();
				Eif (this.is().weekday()) {
					occurrence -= 1;
				}
			} else if (occurrence < 0) {
				this.moveToLastDayOfMonth();
				if (this.is().weekday()) {
					occurrence += 1;
				}
			} else {
				return this;
			}
			return this.addWeekdays(occurrence);
		}
		var shift = 0;
		if (occurrence > 0) {
			shift = occurrence - 1;
		}
		else Eif (occurrence === -1) {
			this.moveToLastDayOfMonth();
			if (this.getDay() !== dayOfWeek) {
				this.moveToDayOfWeek(dayOfWeek, -1);
			}
			return this;
		}
		return this.moveToFirstDayOfMonth().addDays(-1).moveToDayOfWeek(dayOfWeek, +1).addWeeks(shift);
	};
 
 
	var moveToN = function (getFunc, addFunc, nVal) {
		return function (value, orient) {
			var diff = (value - this[getFunc]() + nVal * (orient || +1)) % nVal;
			return this[addFunc]((diff === 0) ? diff += nVal * (orient || +1) : diff);
		};
	};
	/**
	 * Move to the next or last dayOfWeek based on the orient value.
	 * @param {Number}   The dayOfWeek to move to
	 * @param {Number}   Forward (+1) or Back (-1). Defaults to +1. [Optional]
	 * @return {Date}    this
	 */
	$P.moveToDayOfWeek = moveToN("getDay", "addDays", 7);
	/**
	 * Move to the next or last month based on the orient value.
	 * @param {Number}   The month to move to. 0 = January, 11 = December
	 * @param {Number}   Forward (+1) or Back (-1). Defaults to +1. [Optional]
	 * @return {Date}    this
	 */
	$P.moveToMonth = moveToN("getMonth", "addMonths", 12);
	/**
	 * Get the Ordinate of the current day ("th", "st", "rd").
	 * @return {String} 
	 */
	$P.getOrdinate = function () {
		var num = this.getDate();
		return ord(num);
	};
	/**
	 * Get the Ordinal day (numeric day number) of the year, adjusted for leap year.
	 * @return {Number} 1 through 365 (366 in leap years)
	 */
	$P.getOrdinalNumber = function () {
		return Math.ceil((this.clone().clearTime() - new Date(this.getFullYear(), 0, 1)) / 86400000) + 1;
	};
 
	/**
	 * Get the time zone abbreviation of the current date.
	 * @return {String} The abbreviated time zone name (e.g. "EST")
	 */
	$P.getTimezone = function () {
		return $D.getTimezoneAbbreviation(this.getUTCOffset(), this.isDaylightSavingTime());
	};
 
	$P.setTimezoneOffset = function (offset) {
		var here = this.getTimezoneOffset(), there = Number(offset) * -6 / 10;
		return (there || there === 0) ? this.addMinutes(there - here) : this;
	};
 
	$P.setTimezone = function (offset) {
		return this.setTimezoneOffset($D.getTimezoneOffset(offset));
	};
 
	/**
	 * Indicates whether Daylight Saving Time is observed in the current time zone.
	 * @return {Boolean} true|false
	 */
	$P.hasDaylightSavingTime = function () {
		return (Date.today().set({month: 0, day: 1}).getTimezoneOffset() !== Date.today().set({month: 6, day: 1}).getTimezoneOffset());
	};
	
	/**
	 * Indicates whether this Date instance is within the Daylight Saving Time range for the current time zone.
	 * @return {Boolean} true|false
	 */
	$P.isDaylightSavingTime = function () {
		return Date.today().set({month: 0, day: 1}).getTimezoneOffset() !== this.getTimezoneOffset();
	};
 
	/**
	 * Get the offset from UTC of the current date.
	 * @return {String} The 4-character offset string prefixed with + or - (e.g. "-0500")
	 */
	$P.getUTCOffset = function (offset) {
		var n = (offset || this.getTimezoneOffset()) * -10 / 6, r;
		if (n < 0) {
			r = (n - 10000).toString();
			return r.charAt(0) + r.substr(2);
		} else {
			r = (n + 10000).toString();
			return "+" + r.substr(1);
		}
	};
 
	/**
	 * Returns the number of milliseconds between this date and date.
	 * @param {Date} Defaults to now
	 * @return {Number} The diff in milliseconds
	 */
	$P.getElapsed = function (date) {
		return (date || new Date()) - this;
	};
 
	/**
	 * Set the value of year, month, day, hour, minute, second, millisecond of date instance using given configuration object.
	 * Example
	<pre><code>
	Date.today().set( { day: 20, month: 1 } )
 
	new Date().set( { millisecond: 0 } )
	</code></pre>
	 * 
	 * @param {Object}   Configuration object containing attributes (month, day, etc.)
	 * @return {Date}    this
	 */
	$P.set = function (config) {
		config = validateConfigObject.call(this, config);
		var key;
		for (key in config) {
			Eif (hasOwnProperty.call(config, key)) {
				var name = key.charAt(0).toUpperCase() + key.slice(1);
				var addFunc, getFunc;
				if (key !== "week" && key !== "month" && key !== "timezone" && key !== "timezoneOffset") {
					name += "s";
				}
				addFunc = "add" + name;
				getFunc = "get" + name;
				if (key === "month") {
					addFunc = addFunc + "s";
				} else if (key === "year"){
					getFunc = "getFullYear";
				}
				if (key !== "day" && key !== "timezone" && key !== "timezoneOffset"  && key !== "week" &&  key !== "hour") {
						this[addFunc](config[key] - this[getFunc]());
				} else if ( key === "timezone"|| key === "timezoneOffset" || key === "week" || key === "hour") {
					this["set"+name](config[key]);
				}
			}
		}
		// day has to go last because you can't validate the day without first knowing the month
		if (config.day) {
			this.addDays(config.day - this.getDate());
		}
		
		return this;
	};
 
	/**
	 * Moves the date to the first day of the month.
	 * @return {Date}    this
	 */
	$P.moveToFirstDayOfMonth = function () {
		return this.set({ day: 1 });
	};
 
	/**
	 * Moves the date to the last day of the month.
	 * @return {Date}    this
	 */
	$P.moveToLastDayOfMonth = function () {
		return this.set({ day: $D.getDaysInMonth(this.getFullYear(), this.getMonth())});
	};
 
 
	/**
	 * Converts the value of the current Date object to its equivalent string representation.
	 * Format Specifiers
	 * CUSTOM DATE AND TIME FORMAT STRINGS
	 * Format  Description                                                                  Example
	 * ------  ---------------------------------------------------------------------------  -----------------------
	 * s      The seconds of the minute between 0-59.                                      "0" to "59"
	 * ss     The seconds of the minute with leading zero if required.                     "00" to "59"
	 * 
	 * m      The minute of the hour between 0-59.                                         "0"  or "59"
	 * mm     The minute of the hour with leading zero if required.                        "00" or "59"
	 * 
	 * h      The hour of the day between 1-12.                                            "1"  to "12"
	 * hh     The hour of the day with leading zero if required.                           "01" to "12"
	 * 
	 * H      The hour of the day between 0-23.                                            "0"  to "23"
	 * HH     The hour of the day with leading zero if required.                           "00" to "23"
	 * 
	 * d      The day of the month between 1 and 31.                                       "1"  to "31"
	 * dd     The day of the month with leading zero if required.                          "01" to "31"
	 * ddd    Abbreviated day name. Date.CultureInfo.abbreviatedDayNames.                                "Mon" to "Sun" 
	 * dddd   The full day name. Date.CultureInfo.dayNames.                                              "Monday" to "Sunday"
	 * 
	 * M      The month of the year between 1-12.                                          "1" to "12"
	 * MM     The month of the year with leading zero if required.                         "01" to "12"
	 * MMM    Abbreviated month name. Date.CultureInfo.abbreviatedMonthNames.                            "Jan" to "Dec"
	 * MMMM   The full month name. Date.CultureInfo.monthNames.                                          "January" to "December"
	 *
	 * yy     The year as a two-digit number.                                              "99" or "08"
	 * yyyy   The full four digit year.                                                    "1999" or "2008"
	 * 
	 * t      Displays the first character of the A.M./P.M. designator.                    "A" or "P"
	 *		Date.CultureInfo.amDesignator or Date.CultureInfo.pmDesignator
	 * tt     Displays the A.M./P.M. designator.                                           "AM" or "PM"
	 *		Date.CultureInfo.amDesignator or Date.CultureInfo.pmDesignator
	 * 
	 * S      The ordinal suffix ("st, "nd", "rd" or "th") of the current day.            "st, "nd", "rd" or "th"
	 *
	 * STANDARD DATE AND TIME FORMAT STRINGS
	 * Format  Description                                                                  Example
	 *------  ---------------------------------------------------------------------------  -----------------------
	 * d      The CultureInfo shortDate Format Pattern                                     "M/d/yyyy"
	 * D      The CultureInfo longDate Format Pattern                                      "dddd, MMMM dd, yyyy"
	 * F      The CultureInfo fullDateTime Format Pattern                                  "dddd, MMMM dd, yyyy h:mm:ss tt"
	 * m      The CultureInfo monthDay Format Pattern                                      "MMMM dd"
	 * r      The CultureInfo rfc1123 Format Pattern                                       "ddd, dd MMM yyyy HH:mm:ss GMT"
	 * s      The CultureInfo sortableDateTime Format Pattern                              "yyyy-MM-ddTHH:mm:ss"
	 * t      The CultureInfo shortTime Format Pattern                                     "h:mm tt"
	 * T      The CultureInfo longTime Format Pattern                                      "h:mm:ss tt"
	 * u      The CultureInfo universalSortableDateTime Format Pattern                     "yyyy-MM-dd HH:mm:ssZ"
	 * y      The CultureInfo yearMonth Format Pattern                                     "MMMM, yyyy"
	 *
	 * @param {String}   A format string consisting of one or more format spcifiers [Optional].
	 * @return {String}  A string representation of the current Date object.
	 */
	
	var ord = function (n) {
		switch (n * 1) {
		case 1:
		case 21:
		case 31:
			return "st";
		case 2:
		case 22:
			return "nd";
		case 3:
		case 23:
			return "rd";
		default:
			return "th";
		}
	};
	var parseStandardFormats = function (format) {
		var y, c = Date.CultureInfo.formatPatterns;
		switch (format) {
			case "d":
				return this.toString(c.shortDate);
			case "D":
				return this.toString(c.longDate);
			case "F":
				return this.toString(c.fullDateTime);
			case "m":
				return this.toString(c.monthDay);
			case "r":
			case "R":
				y = this.clone().addMinutes(this.getTimezoneOffset());
				return y.toString(c.rfc1123) + " GMT";
			case "s":
				return this.toString(c.sortableDateTime);
			case "t":
				return this.toString(c.shortTime);
			case "T":
				return this.toString(c.longTime);
			case "u":
				y = this.clone().addMinutes(this.getTimezoneOffset());
				return y.toString(c.universalSortableDateTime);
			case "y":
				return this.toString(c.yearMonth);
			default:
				return false;
		}
	};
	var parseFormatStringsClosure = function (context) {
		return function (m) {
			if (m.charAt(0) === "\\") {
				return m.replace("\\", "");
			}
			switch (m) {
				case "hh":
					return p(context.getHours() < 13 ? (context.getHours() === 0 ? 12 : context.getHours()) : (context.getHours() - 12));
				case "h":
					return context.getHours() < 13 ? (context.getHours() === 0 ? 12 : context.getHours()) : (context.getHours() - 12);
				case "HH":
					return p(context.getHours());
				case "H":
					return context.getHours();
				case "mm":
					return p(context.getMinutes());
				case "m":
					return context.getMinutes();
				case "ss":
					return p(context.getSeconds());
				case "s":
					return context.getSeconds();
				case "yyyy":
					return p(context.getFullYear(), 4);
				case "yy":
					return p(context.getFullYear());
				case "y":
					return context.getFullYear();
				case "E":
				case "dddd":
					return Date.CultureInfo.dayNames[context.getDay()];
				case "ddd":
					return Date.CultureInfo.abbreviatedDayNames[context.getDay()];
				case "dd":
					return p(context.getDate());
				case "d":
					return context.getDate();
				case "MMMM":
					return Date.CultureInfo.monthNames[context.getMonth()];
				case "MMM":
					return Date.CultureInfo.abbreviatedMonthNames[context.getMonth()];
				case "MM":
					return p((context.getMonth() + 1));
				case "M":
					return context.getMonth() + 1;
				case "t":
					return context.getHours() < 12 ? Date.CultureInfo.amDesignator.substring(0, 1) : Date.CultureInfo.pmDesignator.substring(0, 1);
				case "tt":
					return context.getHours() < 12 ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator;
				case "S":
					return ord(context.getDate());
				case "W":
					return context.getWeek();
				case "WW":
					return context.getISOWeek();
				case "Q":
					return "Q" + context.getQuarter();
				case "q":
					return String(context.getQuarter());
				case "z":
					return context.getTimezone();
				case "Z":
				case "X":
					return Date.getTimezoneOffset(context.getTimezone());
				case "ZZ": // Timezone offset in seconds
					return context.getTimezoneOffset() * -60;
				case "u":
					return context.getDay();
				case "L":
					return ($D.isLeapYear(context.getFullYear())) ? 1 : 0;
				case "B":
					// Swatch Internet Time (.beats)
					return "@"+((context.getUTCSeconds() + (context.getUTCMinutes()*60) + ((context.getUTCHours()+1)*3600))/86.4);
				default:
					return m;
			}
		};
	};
	$P.toString = function (format, ignoreStandards) {
		
		// Standard Date and Time Format Strings. Formats pulled from CultureInfo file and
		// may vary by culture. 
		if (!ignoreStandards && format && format.length === 1) {
			output = parseStandardFormats.call(this, format);
			if (output) {
				return output;
			}
		}
		var parseFormatStrings = parseFormatStringsClosure(this);
		return format ? format.replace(/((\\)?(dd?d?d?|MM?M?M?|yy?y?y?|hh?|HH?|mm?|ss?|tt?|S|q|Q|WW?W?W?)(?![^\[]*\]))/g, parseFormatStrings).replace(/\[|\]/g, "") : this._toString();
	};
 
}());
================================================ FILE: reports/lcov-report/core/core.js.html ================================================ Code coverage report for core/core.js

Code coverage report for core/core.js

Statements: 96.77% (120 / 124)      Branches: 90.11% (82 / 91)      Functions: 91.18% (31 / 34)      Lines: 98.36% (120 / 122)      Ignored: none     

All files » core/ » core.js
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 3441 1     15 15   15     1 1               1   1                       5 1 1   4 2     5 4 3   1       5 1 3                       5 2       1             1 2094             1 4                 1 408 5 403 401   2                   1 398               1 2               1 26 26 105 24     2               1 24 24 163 23     1               1 2               1 591                 1 588 12 12   588     1       1 6 6 166 166 5       1     1 7 7 7 399 8     7 1   6 5   1 2 1           1 15 15 15     1 2 2 2 2       1 369 369 1 368 1 367       28   339               1 1               1 3               1 5               1 30               1 119 119               1 1               1 139               1                     71   1 3 3   1   2        
(function () {
	var $D = Date,
		$P = $D.prototype,
		p = function (s, l) {
			Eif (!l) {
				l = 2;
			}
			return ("000" + s).slice(l * -1);
		};
	
	Eif (typeof window !== "undefined" && typeof window.console !== "undefined" && typeof window.console.log !== "undefined") {
		$D.console = console; // used only to raise non-critical errors if available
	} else {
		// set mock so we don't give errors.
		$D.console = {
			log: function(){},
			error: function(){}
		};
	}
	$D.Config = $D.Config || {};
 
	$D.initOverloads = function() {
		/** 
		 * Overload of Date.now. Allows an alternate call for Date.now where it returns the 
		 * current Date as an object rather than just milliseconds since the Unix Epoch.
		 *
		 * Also provides an implementation of now() for browsers (IE<9) that don't have it.
		 * 
		 * Backwards compatible so with work with either:
		 *  Date.now() [returns ms]
		 * or
		 *  Date.now(true) [returns Date]
		 */
		if (!$D.now) {
			$D._now = function now() {
				return new Date().getTime();
			};
		} else if (!$D._now) {
			$D._now = $D.now;
		}
 
		$D.now = function (returnObj) {
			if (returnObj) {
				return $D.present();
			} else {
				return $D._now();
			}
		};
 
		if ( !$P.toISOString ) {
			$P.toISOString = function() {
				return this.getUTCFullYear() +
				"-" + p(this.getUTCMonth() + 1) +
				"-" + p(this.getUTCDate()) +
				"T" + p(this.getUTCHours()) +
				":" + p(this.getUTCMinutes()) +
				":" + p(this.getUTCSeconds()) +
				"." + String( (this.getUTCMilliseconds()/1000).toFixed(3)).slice(2, 5) +
				"Z";
			};
		}
		
		// private
		if ( $P._toString === undefined ){
			$P._toString = $P.toString;
		}
 
	};
	$D.initOverloads();
 
 
	/** 
	 * Gets a date that is set to the current date. The time is set to the start of the day (00:00 or 12:00 AM).
	 * @return {Date}    The current date.
	 */
	$D.today = function () {
		return new Date().clearTime();
	};
 
	/** 
	 * Gets a date that is set to the current date and time (same as new Date, but chainable)
	 * @return {Date}    The current date.
	 */
	$D.present = function () {
		return new Date();
	};
 
	/**
	 * Compares the first date to the second date and returns an number indication of their relative values.  
	 * @param {Date}     First Date object to compare [Required].
	 * @param {Date}     Second Date object to compare to [Required].
	 * @return {Number}  -1 = date1 is lessthan date2. 0 = values are equal. 1 = date1 is greaterthan date2.
	 */
	$D.compare = function (date1, date2) {
		if (isNaN(date1) || isNaN(date2)) {
			throw new Error(date1 + " - " + date2);
		} else if (date1 instanceof Date && date2 instanceof Date) {
			return (date1 < date2) ? -1 : (date1 > date2) ? 1 : 0;
		} else {
			throw new TypeError(date1 + " - " + date2);
		}
	};
	
	/**
	 * Compares the first Date object to the second Date object and returns true if they are equal.  
	 * @param {Date}     First Date object to compare [Required]
	 * @param {Date}     Second Date object to compare to [Required]
	 * @return {Boolean} true if dates are equal. false if they are not equal.
	 */
	$D.equals = function (date1, date2) {
		return (date1.compareTo(date2) === 0);
	};
 
	/**
	 * Gets the language appropriate day name when given the day number(0-6)
	 * eg - 0 == Sunday
	 * @return {String}  The day name
	 */
	$D.getDayName = function (n) {
		return Date.CultureInfo.dayNames[n];
	};
 
	/**
	 * Gets the day number (0-6) if given a CultureInfo specific string which is a valid dayName, abbreviatedDayName or shortestDayName (two char).
	 * @param {String}   The name of the day (eg. "Monday, "Mon", "tuesday", "tue", "We", "we").
	 * @return {Number}  The day number
	 */
	$D.getDayNumberFromName = function (name) {
		var n = Date.CultureInfo.dayNames, m = Date.CultureInfo.abbreviatedDayNames, o = Date.CultureInfo.shortestDayNames, s = name.toLowerCase();
		for (var i = 0; i < n.length; i++) {
			if (n[i].toLowerCase() === s || m[i].toLowerCase() === s || o[i].toLowerCase() === s) {
				return i;
			}
		}
		return -1;
	};
	
	/**
	 * Gets the month number (0-11) if given a Culture Info specific string which is a valid monthName or abbreviatedMonthName.
	 * @param {String}   The name of the month (eg. "February, "Feb", "october", "oct").
	 * @return {Number}  The day number
	 */
	$D.getMonthNumberFromName = function (name) {
		var n = Date.CultureInfo.monthNames, m = Date.CultureInfo.abbreviatedMonthNames, s = name.toLowerCase();
		for (var i = 0; i < n.length; i++) {
			if (n[i].toLowerCase() === s || m[i].toLowerCase() === s) {
				return i;
			}
		}
		return -1;
	};
 
	/**
	 * Gets the language appropriate month name when given the month number(0-11)
	 * eg - 0 == January
	 * @return {String}  The month name
	 */
	$D.getMonthName = function (n) {
		return Date.CultureInfo.monthNames[n];
	};
 
	/**
	 * Determines if the current date instance is within a LeapYear.
	 * @param {Number}   The year.
	 * @return {Boolean} true if date is within a LeapYear, otherwise false.
	 */
	$D.isLeapYear = function (year) {
		return ((year % 4 === 0 && year % 100 !== 0) || year % 400 === 0);
	};
 
	/**
	 * Gets the number of days in the month, given a year and month value. Automatically corrects for LeapYear.
	 * @param {Number}   The year.
	 * @param {Number}   The month (0-11).
	 * @return {Number}  The number of days in the month.
	 */
	$D.getDaysInMonth = function (year, month) {
		if (!month && $D.validateMonth(year)) {
				month = year;
				year = Date.today().getFullYear();
		}
		return [31, ($D.isLeapYear(year) ? 29 : 28), 31, 30, 31, 30, 31, 31, 30, 31, 30, 31][month];
	};
 
	$P.getDaysInMonth = function () {
		return $D.getDaysInMonth(this.getFullYear(), this.getMonth());
	};
 
	$D.getTimezoneAbbreviation = function (offset, dst) {
		var p, n = (dst || false) ? Date.CultureInfo.abbreviatedTimeZoneDST : Date.CultureInfo.abbreviatedTimeZoneStandard;
		for (p in n) {
			Eif (n.hasOwnProperty(p)) {
				if (n[p] === offset) {
					return p;
				}
			}
		}
		return null;
	};
	
	$D.getTimezoneOffset = function (name, dst) {
		var i, a =[], z = Date.CultureInfo.timezones;
		Iif (!name) { name = (new Date()).getTimezone();}
		for (i = 0; i < z.length; i++) {
			if (z[i].name === name.toUpperCase()) {
				a.push(i);
			}
		}
		if (!z[a[0]]) {
			return null;
		}
		if (a.length === 1 || !dst) {
			return z[a[0]].offset;
		} else {
			for (i=0; i < a.length; i++) {
				if (z[a[i]].dst) {
					return z[a[i]].offset;
				}
			}
		}
	};
 
	$D.getQuarter = function (d) {
		d = d || new Date(); // If no date supplied, use today
		var q = [1,2,3,4];
		return q[Math.floor(d.getMonth() / 3)]; // ~~~ is a bitwise op. Faster than Math.floor
	};
 
	$D.getDaysLeftInQuarter = function (d) {
		d = d || new Date();
		var qEnd = new Date(d);
		qEnd.setMonth(qEnd.getMonth() + 3 - qEnd.getMonth() % 3, 0);
		return Math.floor((qEnd - d) / 8.64e7);
	};
 
	// private
	var validate = function (n, min, max, name) {
		name = name ? name : "Object";
		if (typeof n === "undefined") {
			return false;
		} else if (typeof n !== "number") {
			throw new TypeError(n + " is not a Number.");
		} else if (n < min || n > max) {
			// As failing validation is *not* an exceptional circumstance 
			// lets not throw a RangeError Exception here. 
			// It's semantically correct but it's not sensible.
			return false;
		}
		return true;
	};
 
	/**
	 * Validates the number is within an acceptable range for milliseconds [0-999].
	 * @param {Number}   The number to check if within range.
	 * @return {Boolean} true if within range, otherwise false.
	 */
	$D.validateMillisecond = function (value) {
		return validate(value, 0, 999, "millisecond");
	};
 
	/**
	 * Validates the number is within an acceptable range for seconds [0-59].
	 * @param {Number}   The number to check if within range.
	 * @return {Boolean} true if within range, otherwise false.
	 */
	$D.validateSecond = function (value) {
		return validate(value, 0, 59, "second");
	};
 
	/**
	 * Validates the number is within an acceptable range for minutes [0-59].
	 * @param {Number}   The number to check if within range.
	 * @return {Boolean} true if within range, otherwise false.
	 */
	$D.validateMinute = function (value) {
		return validate(value, 0, 59, "minute");
	};
 
	/**
	 * Validates the number is within an acceptable range for hours [0-23].
	 * @param {Number}   The number to check if within range.
	 * @return {Boolean} true if within range, otherwise false.
	 */
	$D.validateHour = function (value) {
		return validate(value, 0, 23, "hour");
	};
 
	/**
	 * Validates the number is within an acceptable range for the days in a month [0-MaxDaysInMonth].
	 * @param {Number}   The number to check if within range.
	 * @return {Boolean} true if within range, otherwise false.
	 */
	$D.validateDay = function (value, year, month) {
		Iif (year === undefined || year === null || month === undefined || month === null) { return false;}
		return validate(value, 1, $D.getDaysInMonth(year, month), "day");
	};
 
	/**
	 * Validates the number is within an acceptable range for months [0-11].
	 * @param {Number}   The number to check if within range.
	 * @return {Boolean} true if within range, otherwise false.
	 */
	$D.validateWeek = function (value) {
		return validate(value, 0, 53, "week");
	};
 
	/**
	 * Validates the number is within an acceptable range for months [0-11].
	 * @param {Number}   The number to check if within range.
	 * @return {Boolean} true if within range, otherwise false.
	 */
	$D.validateMonth = function (value) {
		return validate(value, 0, 11, "month");
	};
 
	/**
	 * Validates the number is within an acceptable range for years.
	 * @param {Number}   The number to check if within range.
	 * @return {Boolean} true if within range, otherwise false.
	 */
	$D.validateYear = function (value) {
		/**
		 * Per ECMAScript spec the range of times supported by Date objects is 
		 * exactly -100,000,000 days to +100,000,000 days measured relative to 
		 * midnight at the beginning of 01 January, 1970 UTC. 
		 * This gives a range of 8,640,000,000,000,000 milliseconds to either 
		 * side of 01 January, 1970 UTC.
		 *
		 * Earliest possible date: Tue, 20 Apr 271,822 B.C. 00:00:00 UTC
		 * Latest possible date: Sat, 13 Sep 275,760 00:00:00 UTC
		 */
		return validate(value, -271822, 275760, "year");
	};
	$D.validateTimezone = function(value) {
		var timezones = {"ACDT":1,"ACST":1,"ACT":1,"ADT":1,"AEDT":1,"AEST":1,"AFT":1,"AKDT":1,"AKST":1,"AMST":1,"AMT":1,"ART":1,"AST":1,"AWDT":1,"AWST":1,"AZOST":1,"AZT":1,"BDT":1,"BIOT":1,"BIT":1,"BOT":1,"BRT":1,"BST":1,"BTT":1,"CAT":1,"CCT":1,"CDT":1,"CEDT":1,"CEST":1,"CET":1,"CHADT":1,"CHAST":1,"CHOT":1,"ChST":1,"CHUT":1,"CIST":1,"CIT":1,"CKT":1,"CLST":1,"CLT":1,"COST":1,"COT":1,"CST":1,"CT":1,"CVT":1,"CWST":1,"CXT":1,"DAVT":1,"DDUT":1,"DFT":1,"EASST":1,"EAST":1,"EAT":1,"ECT":1,"EDT":1,"EEDT":1,"EEST":1,"EET":1,"EGST":1,"EGT":1,"EIT":1,"EST":1,"FET":1,"FJT":1,"FKST":1,"FKT":1,"FNT":1,"GALT":1,"GAMT":1,"GET":1,"GFT":1,"GILT":1,"GIT":1,"GMT":1,"GST":1,"GYT":1,"HADT":1,"HAEC":1,"HAST":1,"HKT":1,"HMT":1,"HOVT":1,"HST":1,"ICT":1,"IDT":1,"IOT":1,"IRDT":1,"IRKT":1,"IRST":1,"IST":1,"JST":1,"KGT":1,"KOST":1,"KRAT":1,"KST":1,"LHST":1,"LINT":1,"MAGT":1,"MART":1,"MAWT":1,"MDT":1,"MET":1,"MEST":1,"MHT":1,"MIST":1,"MIT":1,"MMT":1,"MSK":1,"MST":1,"MUT":1,"MVT":1,"MYT":1,"NCT":1,"NDT":1,"NFT":1,"NPT":1,"NST":1,"NT":1,"NUT":1,"NZDT":1,"NZST":1,"OMST":1,"ORAT":1,"PDT":1,"PET":1,"PETT":1,"PGT":1,"PHOT":1,"PHT":1,"PKT":1,"PMDT":1,"PMST":1,"PONT":1,"PST":1,"PYST":1,"PYT":1,"RET":1,"ROTT":1,"SAKT":1,"SAMT":1,"SAST":1,"SBT":1,"SCT":1,"SGT":1,"SLST":1,"SRT":1,"SST":1,"SYOT":1,"TAHT":1,"THA":1,"TFT":1,"TJT":1,"TKT":1,"TLT":1,"TMT":1,"TOT":1,"TVT":1,"UCT":1,"ULAT":1,"UTC":1,"UYST":1,"UYT":1,"UZT":1,"VET":1,"VLAT":1,"VOLT":1,"VOST":1,"VUT":1,"WAKT":1,"WAST":1,"WAT":1,"WEDT":1,"WEST":1,"WET":1,"WST":1,"YAKT":1,"YEKT":1,"Z":1};
		return (timezones[value] === 1);
	};
	$D.validateTimezoneOffset= function(value) {
		// timezones go from +14hrs to -12hrs, the +X hours are negative offsets.
		return (value > -841 && value < 721);
	};
 
}());
 
================================================ FILE: reports/lcov-report/core/extras.js.html ================================================ Code coverage report for core/extras.js

Code coverage report for core/extras.js

Statements: 61.76% (42 / 68)      Branches: 33.33% (15 / 45)      Functions: 92.31% (12 / 13)      Lines: 61.76% (42 / 68)      Ignored: none     

All files » core/ » extras.js
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 3141 1                                                       1                                                                                                     1   166     81 81                                                                             1                   6       6       166 166 166 85   81   81 1   80         1 8 166                           1 2 2                           1 2 2                                                                                                                                                                                             1 3 6 6       6 6 6 6       1 3 3 1   2       1 1    
(function () {
	var $D = Date,
		$P = $D.prototype,
		// $C = $D.CultureInfo, // not used atm
		p = function (s, l) {
			if (!l) {
				l = 2;
			}
			return ("000" + s).slice(l * -1);
		};
	/**
	 * Converts a PHP format string to Java/.NET format string. 
	 * A PHP format string can be used with ._format or .format.
	 * A Java/.NET format string can be used with .toString().
	 * The .parseExact function will only accept a Java/.NET format string
	 *
	 * Example
	 * var f1 = "%m/%d/%y"
	 * var f2 = Date.normalizeFormat(f1);	// "MM/dd/yy"
	 * 
	 * new Date().format(f1);	// "04/13/08"
	 * new Date()._format(f1);	// "04/13/08"
	 * new Date().toString(f2);	// "04/13/08"
	 *  
	 * var date = Date.parseExact("04/13/08", f2); // Sun Apr 13 2008
	 * 
	 * @param {String}   A PHP format string consisting of one or more format spcifiers.
	 * @return {String}  The PHP format converted to a Java/.NET format string.
	 */
	 var normalizerSubstitutions = {
		"d" : "dd",
		"%d": "dd",
		"D" : "ddd",
		"%a": "ddd",
		"j" : "dddd",
		"l" : "dddd",
		"%A": "dddd",
		"S" : "S",
		"F" : "MMMM",
		"%B": "MMMM",
		"m" : "MM",
		"%m": "MM",
		"M" : "MMM",
		"%b": "MMM",
		"%h": "MMM",
		"n" : "M",
		"Y" : "yyyy",
		"%Y": "yyyy",
		"y" : "yy",
		"%y": "yy",
		"g" : "h",
		"%I": "h",
		"G" : "H",
		"h" : "hh",
		"H" : "HH",
		"%H": "HH",
		"i" : "mm",
		"%M": "mm",
		"s" : "ss",
		"%S": "ss",
		"%r": "hh:mm tt",
		"%R": "H:mm",
		"%T": "H:mm:ss",
		"%X": "t",
		"%x": "d",
		"%e": "d",
		"%D": "MM/dd/yy",
		"%n": "\\n",
		"%t": "\\t",
		"e" : "z",
		"T" : "z",
		"%z": "z",
		"%Z": "z",
		"Z" : "ZZ",
		"N" : "u",
		"w" : "u",
		"%w": "u",
		"W" : "W",
		"%V": "W",
	};
	var normalizer = {
		substitutes: function (m) {
			return normalizerSubstitutions[m];
		},
		interpreted: function (m, x) {
			var y;
			switch (m) {
				case "%u":
					return x.getDay() + 1;
				case "z":
					return x.getOrdinalNumber();
				case "%j":
					return p(x.getOrdinalNumber(), 3);
				case "%U":
					var d1 = x.clone().set({month: 0, day: 1}).addDays(-1).moveToDayOfWeek(0),
						d2 = x.clone().addDays(1).moveToDayOfWeek(0, -1);
					return (d2 < d1) ? "00" : p((d2.getOrdinalNumber() - d1.getOrdinalNumber()) / 7 + 1);
 
				case "%W":
					return p(x.getWeek());
				case "t":
					return $D.getDaysInMonth(x.getFullYear(), x.getMonth());
				case "o":
				case "%G":
					return x.setWeek(x.getISOWeek()).toString("yyyy");
				case "%g":
					return x._format("%G").slice(-2);
				case "a":
				case "%p":
					return t("tt").toLowerCase();
				case "A":
					return t("tt").toUpperCase();
				case "u":
					return p(x.getMilliseconds(), 3);
				case "I":
					return (x.isDaylightSavingTime()) ? 1 : 0;
				case "O":
					return x.getUTCOffset();
				case "P":
					y = x.getUTCOffset();
					return y.substring(0, y.length - 2) + ":" + y.substring(y.length - 2);
				case "B":
					var now = new Date();
					return Math.floor(((now.getHours() * 3600) + (now.getMinutes() * 60) + now.getSeconds() + (now.getTimezoneOffset() + 60) * 60) / 86.4);
				case "c":
					return x.toISOString().replace(/\"/g, "");
				case "U":
					return $D.strtotime("now");
				case "%c":
					return t("d") + " " + t("t");
				case "%C":
					return Math.floor(x.getFullYear() / 100 + 1);
			}
		},
		shouldOverrideDefaults: function (m) {
			switch (m) {
				case "%e":
					return true;
				default:
					return false;
			}
		},
		parse: function (m, context) {
			var formatString, c = context || new Date();
			formatString = normalizer.substitutes(m);
			if (formatString) {
				return formatString;
			}
			formatString = normalizer.interpreted(m, c);
 
			if (formatString) {
				return formatString;
			} else {
				return m;
			}
		}
	};
 
	$D.normalizeFormat = function (format, context) {
		return format.replace(/(%|\\)?.|%%/g, function(t){
				return normalizer.parse(t, context);
		});
	};
	/**
	 * Format a local Unix timestamp according to locale settings
	 * 
	 * Example:
	 * Date.strftime("%m/%d/%y", new Date());		// "04/13/08"
	 * Date.strftime("c", "2008-04-13T17:52:03Z");	// "04/13/08"
	 * 
	 * @param {String}   A format string consisting of one or more format spcifiers [Optional].
	 * @param {Number|String}   The number representing the number of seconds that have elapsed since January 1, 1970 (local time). 
	 * @return {String}  A string representation of the current Date object.
	 */
	$D.strftime = function (format, time) {
		var d = Date.parse(time);
		return d._format(format);
	};
	/**
	 * Parse any textual datetime description into a Unix timestamp. 
	 * A Unix timestamp is the number of seconds that have elapsed since January 1, 1970 (midnight UTC/GMT).
	 * 
	 * Example:
	 * Date.strtotime("04/13/08");				// 1208044800
	 * Date.strtotime("1970-01-01T00:00:00Z");	// 0
	 * 
	 * @param {String}   A format string consisting of one or more format spcifiers [Optional].
	 * @param {Object}   A string or date object.
	 * @return {String}  A string representation of the current Date object.
	 */
	$D.strtotime = function (time) {
		var d = $D.parse(time);
		return Math.round($D.UTC(d.getUTCFullYear(), d.getUTCMonth(), d.getUTCDate(), d.getUTCHours(), d.getUTCMinutes(), d.getUTCSeconds(), d.getUTCMilliseconds()) / 1000);
	};
	/**
	 * Converts the value of the current Date object to its equivalent string representation using a PHP/Unix style of date format specifiers.
	 * Format Specifiers
	 * Format  Description																	Example
	 * ------  ---------------------------------------------------------------------------	-----------------------
	 * %a		abbreviated weekday name according to the current localed					"Mon" through "Sun"
	 * %A		full weekday name according to the current localed							"Sunday" through "Saturday"
	 * %b		abbreviated month name according to the current localed						"Jan" through "Dec"
	 * %B		full month name according to the current locale								"January" through "December"
	 * %c		preferred date and time representation for the current locale				"4/13/2008 12:33 PM"
	 * %C		century number (the year divided by 100 and truncated to an integer)		"00" to "99"
	 * %d		day of the month as a decimal number										"01" to "31"
	 * %D		same as %m/%d/%y															"04/13/08"
	 * %e		day of the month as a decimal number, a single digit is preceded by a space	"1" to "31"
	 * %g		like %G, but without the century											"08"
	 * %G		The 4-digit year corresponding to the ISO week number (see %V).				"2008"
	 *		This has the same format and value as %Y, except that if the ISO week number
	 *		belongs to the previous or next year, that year is used instead.
	 * %h		same as %b																	"Jan" through "Dec"
	 * %H		hour as a decimal number using a 24-hour clock.								"00" to "23"
	 * %I		hour as a decimal number using a 12-hour clock.								"01" to "12"
	 * %j		day of the year as a decimal number.										"001" to "366"
	 * %m		month as a decimal number.													"01" to "12"
	 * %M		minute as a decimal number.													"00" to "59"
	 * %n		newline character		"\n"
	 * %p		either "am" or "pm" according to the given time value, or the				"am" or "pm"
	 *		corresponding strings for the current locale.
	 * %r		time in a.m. and p.m. notation												"8:44 PM"
	 * %R		time in 24 hour notation													"20:44"
	 * %S		second as a decimal number													"00" to "59"
	 * %t		tab character																"\t"
	 * %T		current time, equal to %H:%M:%S												"12:49:11"
	 * %u		weekday as a decimal number ["1", "7"], with "1" representing Monday		"1" to "7"
	 * %U		week number of the current year as a decimal number, starting with the		"0" to ("52" or "53")
	 *		first Sunday as the first day of the first week
	 * %V		The ISO 8601:1988 week number of the current year as a decimal number,		"00" to ("52" or "53")
	 *		range 01 to 53, where week 1 is the first week that has at least 4 days
	 *		in the current year, and with Monday as the first day of the week.
	 *		(Use %G or %g for the year component that corresponds to the week number
	 *		for the specified timestamp.)
	 * %W		week number of the current year as a decimal number, starting with the		"00" to ("52" or "53")
	 *		first Monday as the first day of the first week
	 * %w		day of the week as a decimal, Sunday being "0"								"0" to "6"
	 * %x		preferred date representation for the current locale without the time		"4/13/2008"
	 * %X		preferred time representation for the current locale without the date		"12:53:05"
	 * %y		year as a decimal number without a century									"00" "99"
	 * %Y		year as a decimal number including the century								"2008"
	 * %Z		time zone or name or abbreviation											"UTC", "EST", "PST"
	 * %z		same as %Z 
	 * %%		a literal "%" characters													"%"
	 * d		Day of the month, 2 digits with leading zeros								"01" to "31"
	 * D		A textual representation of a day, three letters							"Mon" through "Sun"
	 * j		Day of the month without leading zeros										"1" to "31"
	 * l		A full textual representation of the day of the week (lowercase "L")		"Sunday" through "Saturday"
	 * N		ISO-8601 numeric representation of the day of the week (added in PHP 5.1.0)	"1" (for Monday) through "7" (for Sunday)
	 * S		English ordinal suffix for the day of the month, 2 characters				"st", "nd", "rd" or "th". Works well with j
	 * w		Numeric representation of the day of the week								"0" (for Sunday) through "6" (for Saturday)
	 * z		The day of the year (starting from "0")										"0" through "365"		
	 * W		ISO-8601 week number of year, weeks starting on Monday						"00" to ("52" or "53")
	 * F		A full textual representation of a month, such as January or March			"January" through "December"
	 * m		Numeric representation of a month, with leading zeros						"01" through "12"
	 * M		A short textual representation of a month, three letters					"Jan" through "Dec"
	 * n		Numeric representation of a month, without leading zeros					"1" through "12"
	 * t		Number of days in the given month											"28" through "31"
	 * L		Whether it's a leap year													"1" if it is a leap year, "0" otherwise
	 * o		ISO-8601 year number. This has the same value as Y, except that if the		"2008"
	 *		ISO week number (W) belongs to the previous or next year, that year 
	 *		is used instead.
	 * Y		A full numeric representation of a year, 4 digits							"2008"
	 * y		A two digit representation of a year										"08"
	 * a		Lowercase Ante meridiem and Post meridiem									"am" or "pm"
	 * A		Uppercase Ante meridiem and Post meridiem									"AM" or "PM"
	 * B		Swatch Internet time														"000" through "999"
	 * g		12-hour format of an hour without leading zeros								"1" through "12"
	 * G		24-hour format of an hour without leading zeros								"0" through "23"
	 * h		12-hour format of an hour with leading zeros								"01" through "12"
	 * H		24-hour format of an hour with leading zeros								"00" through "23"
	 * i		Minutes with leading zeros													"00" to "59"
	 * s		Seconds, with leading zeros													"00" through "59"
	 * u		Milliseconds																"54321"
	 * e		Timezone identifier															"UTC", "EST", "PST"
	 * I		Whether or not the date is in daylight saving time (uppercase i)			"1" if Daylight Saving Time, "0" otherwise
	 * O		Difference to Greenwich time (GMT) in hours									"+0200", "-0600"
	 * P		Difference to Greenwich time (GMT) with colon between hours and minutes		"+02:00", "-06:00"
	 * T		Timezone abbreviation														"UTC", "EST", "PST"
	 * Z		Timezone offset in seconds. The offset for timezones west of UTC is			"-43200" through "50400"
	 *			always negative, and for those east of UTC is always positive.
	 * c		ISO 8601 date																"2004-02-12T15:19:21+00:00"
	 * r		RFC 2822 formatted date														"Thu, 21 Dec 2000 16:01:07 +0200"
	 * U		Seconds since the Unix Epoch (January 1 1970 00:00:00 GMT)					"0"
	 * @param {String}   A format string consisting of one or more format spcifiers [Optional].
	 * @return {String}  A string representation of the current Date object.
	 */
	var formatReplace = function (context) {
		return function (m) {
			var formatString, override = false;
			Iif (m.charAt(0) === "\\" || m.substring(0, 2) === "%%") {
				return m.replace("\\", "").replace("%%", "%");
			}
 
			override = normalizer.shouldOverrideDefaults(m);
			formatString = $D.normalizeFormat(m, context);
			Eif (formatString) {
				return context.toString(formatString, override);
			}
		};
	};
	$P._format = function (format) {
		var formatter = formatReplace(this);
		if (!format) {
			return this._toString();
		} else {
			return format.replace(/(%|\\)?.|%%/g, formatter);
		}
	};
 
	Eif (!$P.format) {
		$P.format = $P._format;
	}
}());
================================================ FILE: reports/lcov-report/core/format_parser.js.html ================================================ Code coverage report for core/format_parser.js

Code coverage report for core/format_parser.js

Statements: 96.95% (159 / 164)      Branches: 86.13% (118 / 137)      Functions: 94.29% (33 / 35)      Lines: 96.95% (159 / 164)      Ignored: none     

All files » core/ » format_parser.js
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 3811   1   39302     1 1         1 84     1   530 530 13780 13780 13780     13780   13780     530     17 17 17 17 17 17 17     31 17   31 403 31 31   372     31     21 21   16   5 5 2   5   21 21     84 84 84 84 84 84   53 53   84     960 960 400 240   160   560 400   160       80 80 1200 1200     80 8 8 4 4 4   8   80     80                                       48     17 17     52     40     29                                   80     160 160 160 160 1440   160     1120     1440 320 1120 1120         160 160 160 1440 1120   320     160       1 84   84 84   84 31   53     84   84 21   84     1     454 454 374     80   80     80       1 573     375     375   368   7 1 1   6 6 2   4 12   4 4   4 4   4 4     4       1   160 160                         160 160                                           160                         160 160 160 160   160   5       4 4               160 160     530 2120   530     530 530   530 530 530                       530     1  
(function () {
	"use strict";
	Date.Parsing = {
		Exception: function (s) {
			this.message = "Parse error at '" + s.substring(0, 10) + " ...'";
		}
	};
	var $P = Date.Parsing;
	var dayOffsets = {
		standard: [0,31,59,90,120,151,181,212,243,273,304,334],
		leap: [0,31,60,91,121,152,182,213,244,274,305,335]
	};
 
	$P.isLeapYear = function(year) {
		return ((year % 4 === 0) && (year % 100 !== 0)) || (year % 400 === 0);
	};
 
	var utils = {
		multiReplace : function (str, hash ) {
			var key;
			for (key in hash) {
				Eif (Object.prototype.hasOwnProperty.call(hash, key)) {
					var regex;
					Iif (typeof hash[key] === "function") {
 
					} else {
						regex = (hash[key] instanceof RegExp) ? hash[key] : new RegExp(hash[key], "g");
					}
					str = str.replace(regex, key);
				}
			}
			return str;
		},
		getDayOfYearFromWeek : function (obj) {
			var d, jan4, offset;
			obj.weekDay = (!obj.weekDay && obj.weekDay !== 0) ? 1 : obj.weekDay;
			d = new Date(obj.year, 0, 4);
			jan4 = d.getDay() === 0 ? 7 : d.getDay(); // JS is 0 indexed on Sunday.
			offset = jan4+3;
			obj.dayOfYear = ((obj.week * 7) + (obj.weekDay === 0 ? 7 : obj.weekDay))-offset;
			return obj;
		},
		getDayOfYear : function (obj, dayOffset) {
			if (!obj.dayOfYear) {
				obj = utils.getDayOfYearFromWeek(obj);
			}
			for (var i=0;i <= dayOffset.length;i++) {
				if (obj.dayOfYear < dayOffset[i] || i === dayOffset.length) {
					obj.day = obj.day ? obj.day : (obj.dayOfYear - dayOffset[i-1]);
					break;
				} else {
					obj.month = i;
				}
			}
			return obj;
		},
		adjustForTimeZone : function (obj, date) {
			var offset;
			if (obj.zone.toUpperCase() === "Z" || (obj.zone_hours === 0 && obj.zone_minutes === 0)) {
				// it's UTC/GML so work out the current timeszone offset
				offset = -date.getTimezoneOffset();
			} else {
				offset = (obj.zone_hours*60) + (obj.zone_minutes || 0);
				if (obj.zone_sign === "+") {
					offset *= -1;
				}
				offset -= date.getTimezoneOffset();
			}
			date.setMinutes(date.getMinutes()+offset);
			return date;
		},
		setDefaults : function (obj) {
			obj.year = obj.year || Date.today().getFullYear();
			obj.hours = obj.hours || 0;
			obj.minutes = obj.minutes || 0;
			obj.seconds = obj.seconds || 0;
			obj.milliseconds = obj.milliseconds || 0;
			if (!(!obj.month && (obj.week || obj.dayOfYear))) {
				// if we have a month, or if we don't but don't have the day calculation data
				obj.month = obj.month || 0;
				obj.day = obj.day || 1;
			}
			return obj;
		},
		dataNum: function (data, mod, explict, postProcess) {
			var dataNum = data*1;
			if (mod) {
				if (postProcess) {
					return data ? mod(data)*1 : data;
				} else {
					return data ? mod(dataNum) : data;
				}
			} else if (!explict){
				return data ? dataNum : data;
			} else {
				return (data && typeof data !== "undefined") ? dataNum : data;
			}
		},
		timeDataProcess: function (obj) {
			var timeObj = {};
			for (var x in obj.data) {
				Eif (obj.data.hasOwnProperty(x)) {
					timeObj[x] = obj.ignore[x] ? obj.data[x] : utils.dataNum(obj.data[x], obj.mods[x], obj.explict[x], obj.postProcess[x]);
				}
			}
			if (obj.data.secmins) {
				obj.data.secmins = obj.data.secmins.replace(",", ".") * 60;
				if (!timeObj.minutes) {
					timeObj.minutes = obj.data.secmins;
				} else Eif (!timeObj.seconds) {
					timeObj.seconds = obj.data.secmins;
				}
				delete obj.secmins;
			}
			return timeObj;
		},
		buildTimeObjectFromData: function (data) {
			var time = utils.timeDataProcess({
				data: {
					year : data[1],
					month : data[5],
					day : data[7],
					week : data[8],
					dayOfYear : data[10],
					hours : data[15],
					zone_hours : data[23],
					zone_minutes : data[24],
					zone : data[21],
					zone_sign : data[22],
					weekDay : data[9],
					minutes: data[16],
					seconds: data[19],
					milliseconds: data[20],
					secmins: data[18]
				},
				mods: {
					month: function(data) {
						return data-1;
					},
					weekDay: function (data) {
						data = Math.abs(data);
						return (data === 7 ? 0 : data);
					},
					minutes: function (data) {
						return data.replace(":","");
					},
					seconds: function (data) {
						return Math.floor( (data.replace(":","").replace(",","."))*1 );
					},
					milliseconds: function (data) {
						return (data.replace(",",".")*1000);
					}
				},
				postProcess: {
					minutes: true,
					seconds: true,
					milliseconds: true
				},
				explict: {
					zone_hours: true,
					zone_minutes: true
				},
				ignore: {
					zone: true,
					zone_sign: true,
					secmins: true
				}
			});
			return time;
		},
		addToHash: function (hash, keys, data) {
			keys = keys;
			data = data;
			var len = keys.length;
			for (var i = 0; i < len; i++) {
			  hash[keys[i]] = data[i];
			}
			return hash;
		},
		combineRegex: function (r1, r2) {
			return new RegExp("(("+r1.source+")\\s("+r2.source+"))");
		},
		getDateNthString: function(add, last, inc){
			if (add) {
				return Date.today().addDays(inc).toString("d");
			} else Eif (last) {
				return Date.today().last()[inc]().toString("d");
			}
			
		},
		buildRegexData: function (array) {
			var arr = [];
			var len = array.length;
			for (var i=0; i < len; i++) {
				if (Array.isArray(array[i])) {
					arr.push(this.combineRegex(array[i][0], array[i][1]));
				} else {
					arr.push(array[i]);
				}
			}
			return arr;
		}
	};
 
	$P.processTimeObject = function (obj) {
		var date, dayOffset;
 
		utils.setDefaults(obj);
		dayOffset = ($P.isLeapYear(obj.year)) ? dayOffsets.leap : dayOffsets.standard;
 
		if (!obj.month && (obj.week || obj.dayOfYear)) {
			utils.getDayOfYear(obj, dayOffset);
		} else {
			obj.dayOfYear = dayOffset[obj.month] + obj.day;
		}
 
		date = new Date(obj.year, obj.month, obj.day, obj.hours, obj.minutes, obj.seconds, obj.milliseconds);
 
		if (obj.zone) {
			utils.adjustForTimeZone(obj, date); // adjust (and calculate) for timezone
		}
		return date;
	};
	
	$P.ISO = {
		regex : /^([\+-]?\d{4}(?!\d{2}\b))((-?)((0[1-9]|1[0-2])(\3([12]\d|0[1-9]|3[01]))?|W([0-4]\d|5[0-3])(-?[1-7])?|(00[1-9]|0[1-9]\d|[12]\d{2}|3([0-5]\d|6[1-6])))([T\s]((([01]\d|2[0-4])((:?)[0-5]\d)?|24\:?00)([\.,]\d+(?!:))?)?(\17[0-5]\d([\.,]\d+)?)?\s?([zZ]|([\+-])([01]\d|2[0-3]):?([0-5]\d)?)?)?)?$/,
		parse : function (s) {
			var time, data = s.match(this.regex);
			if (!data || !data.length) {
				return null;
			}
 
			time = utils.buildTimeObjectFromData(data);
 
			Iif (!time.year || (!time.year && (!time.month && !time.day) && (!time.week && !time.dayOfYear)) ) {
				return null;
			}
			return $P.processTimeObject(time);
		}
	};
 
	$P.Numeric = {
		isNumeric: function (e){return!isNaN(parseFloat(e))&&isFinite(e);},
		regex: /\b([0-1]?[0-9])([0-3]?[0-9])([0-2]?[0-9]?[0-9][0-9])\b/i,
		parse: function (s) {
			var data, i,
				time = {},
				order = Date.CultureInfo.dateElementOrder.split("");
			if (!(this.isNumeric(s)) || // if it's non-numeric OR
				(s[0] === "+" && s[0] === "-")) {			// It's an arithmatic string (eg +/-1000)
				return null;
			}
			if (s.length < 5 && s.indexOf(".") < 0 && s.indexOf("/") < 0) { // assume it's just a year.
				time.year = s;
				return $P.processTimeObject(time);
			}
			data = s.match(this.regex);
			if (!data || !data.length) {
				return null;
			}
			for (i=0; i < order.length; i++) {
				switch(order[i]) {
					case "d":
						time.day = data[i+1];
						break;
					case "m":
						time.month = (data[i+1]-1);
						break;
					case "y":
						time.year = data[i+1];
						break;
				}
			}
			return $P.processTimeObject(time);
		}
	};
 
	$P.Normalizer = {
		regexData: function () {
			var $R = Date.CultureInfo.regexPatterns;
			return utils.buildRegexData([
				$R.tomorrow,
				$R.yesterday,
				[$R.past, $R.mon],
				[$R.past, $R.tue],
				[$R.past, $R.wed],
				[$R.past, $R.thu],
				[$R.past, $R.fri],
				[$R.past, $R.sat],
				[$R.past, $R.sun]
			]);
		},
		basicReplaceHash : function() {
			var $R = Date.CultureInfo.regexPatterns;
			return {
				"January": $R.jan.source,
				"February": $R.feb,
				"March": $R.mar,
				"April": $R.apr,
				"May": $R.may,
				"June": $R.jun,
				"July": $R.jul,
				"August": $R.aug,
				"September": $R.sep,
				"October": $R.oct,
				"November": $R.nov,
				"December": $R.dec,
				"": /\bat\b/gi,
				" ": /\s{2,}/,
				"am": $R.inTheMorning,
				"9am": $R.thisMorning,
				"pm": $R.inTheEvening,
				"7pm":$R.thisEvening
			};
		},
		keys : function(){
			return [
				utils.getDateNthString(true, false, 1),				// tomorrow
				utils.getDateNthString(true, false, -1),			// yesterday
				utils.getDateNthString(false, true, "monday"),		//last mon
				utils.getDateNthString(false, true, "tuesday"),		//last tues
				utils.getDateNthString(false, true, "wednesday"),	//last wed
				utils.getDateNthString(false, true, "thursday"),	//last thurs
				utils.getDateNthString(false, true, "friday"),		//last fri
				utils.getDateNthString(false, true, "saturday"),	//last sat
				utils.getDateNthString(false, true, "sunday")		//last sun
			];
		},
		buildRegexFunctions: function () {
			var $R = Date.CultureInfo.regexPatterns;
			var __ = Date.i18n.__;
			var tomorrowRE = new RegExp("(\\b\\d\\d?("+__("AM")+"|"+__("PM")+")? )("+$R.tomorrow.source.slice(1)+")", "i"); // adapted tomorrow regex for AM PM relative dates
			var todayRE = new RegExp($R.today.source + "(?!\\s*([+-]))\\b"); // today, but excludes the math operators (eg "today + 2h")
			
			this.replaceFuncs = [
				[todayRE, function (full) {
					return (full.length > 1) ? Date.today().toString("d") : full;
				}],
				[tomorrowRE,
				function(full, m1) {
					var t = Date.today().addDays(1).toString("d");
					return (t + " " + m1);
				}],
				[$R.amThisMorning, function(str, am){return am;}],
				[$R.pmThisEvening, function(str, pm){return pm;}]
			];
				
		},
		buildReplaceData: function () {
			this.buildRegexFunctions();
			this.replaceHash = utils.addToHash(this.basicReplaceHash(), this.keys(), this.regexData());
		},
		stringReplaceFuncs: function (s) {
			for (var i=0; i < this.replaceFuncs.length; i++) {
				s = s.replace(this.replaceFuncs[i][0], this.replaceFuncs[i][1]);
			}
			return s;
		},
		parse: function (s) {
			s = this.stringReplaceFuncs(s);
			s = utils.multiReplace(s, this.replaceHash);
 
			try {
				var n = s.split(/([\s\-\.\,\/\x27]+)/);
				Iif (n.length === 3 &&
					$P.Numeric.isNumeric(n[0]) &&
					$P.Numeric.isNumeric(n[2]) &&
					(n[2].length >= 4)) {
						// ok, so we're dealing with x/year. But that's not a full date.
						// This fixes wonky dateElementOrder parsing when set to dmy order.
						if (Date.CultureInfo.dateElementOrder[0] === "d") {
							s = "1/" + n[0] + "/" + n[2]; // set to 1st of month and normalize the seperator
						}
				}
			} catch (e) {}
 
			return s;
		}
	};
	$P.Normalizer.buildReplaceData();
}());
================================================ FILE: reports/lcov-report/core/i18n.js.html ================================================ Code coverage report for core/i18n.js

Code coverage report for core/i18n.js

Statements: 95.45% (147 / 154)      Branches: 75% (69 / 92)      Functions: 94.12% (32 / 34)      Lines: 95.45% (147 / 154)      Ignored: none     

All files » core/ » i18n.js
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 4161 1 1 1 1   28001 28001 26062   1939   28001 7360   28001     480 480 10240 10240     480     320 320 9120 9120     320     960 960 8320 8320     960     1939 1939   3 3   3 3   3 3   3 3   160 160   1767 1767 1767 1767   214 214 214     1767   1939     7360 7360 6123   1237   7360       1 160 1600 1600         1 1601 1601 1601 1280 960   320     321       1   1 1 1 1   1 1       1 1 1 1       1 1     1   1 1 1             1   160 160 1600 1600     160     160                                       160     160                                                                                 160     160 160 160 6240 6240     160 2880 2880     160     160     160     160     160     160     160     160                           160                                                                                                     1 160                     160                         160 160 160     1   321     637     159 159 157 157 157 157   2 2                     2   1 1 1 1 1 1 1 1 1   1 1       1 1       158 158 158   158 156             2     1  
(function () {
	var $D = Date;
	var lang = Date.CultureStrings ? Date.CultureStrings.lang : null;
	var loggedKeys = {}; // for debug purposes.
	var getText = {
		getFromKey: function (key, countryCode) {
			var output;
			if (Date.CultureStrings && Date.CultureStrings[countryCode] && Date.CultureStrings[countryCode][key]) {
				output = Date.CultureStrings[countryCode][key];
			} else {
				output = getText.buildFromDefault(key);
			}
			if (key.charAt(0) === "/") { // Assume it's a regex
				output = getText.buildFromRegex(key, countryCode);
			}
			return output;
		},
		getFromObjectValues: function (obj, countryCode) {
			var key, output = {};
			for(key in obj) {
				Eif (obj.hasOwnProperty(key)) {
					output[key] = getText.getFromKey(obj[key], countryCode);
				}
			}
			return output;
		},
		getFromObjectKeys: function (obj, countryCode) {
			var key, output = {};
			for(key in obj) {
				Eif (obj.hasOwnProperty(key)) {
					output[getText.getFromKey(key, countryCode)] = obj[key];
				}
			}
			return output;
		},
		getFromArray: function (arr, countryCode) {
			var output = [];
			for (var i=0; i < arr.length; i++){
				Eif (i in arr) {
					output[i] = getText.getFromKey(arr[i], countryCode);
				}
			}
			return output;
		},
		buildFromDefault: function (key) {
			var output, length, split, last;
			switch(key) {
				case "name":
					output = "en-US";
					break;
				case "englishName":
					output = "English (United States)";
					break;
				case "nativeName":
					output = "English (United States)";
					break;
				case "twoDigitYearMax":
					output = 2049;
					break;
				case "firstDayOfWeek":
					output = 0;
					break;
				default:
					output = key;
					split = key.split("_");
					length = split.length;
					if (length > 1 && key.charAt(0) !== "/") {
						// if the key isn't a regex and it has a split.
						last = split[(length - 1)].toLowerCase();
						Eif (last === "initial" || last === "abbr") {
							output = split[0];
						}
					}
					break;
			}
			return output;
		},
		buildFromRegex: function (key, countryCode) {
			var output;
			if (Date.CultureStrings && Date.CultureStrings[countryCode] && Date.CultureStrings[countryCode][key]) {
				output = new RegExp(Date.CultureStrings[countryCode][key], "i");
			} else {
				output = new RegExp(key.replace(new RegExp("/", "g"),""), "i");
			}
			return output;
		}
	};
 
	var shallowMerge = function (obj1, obj2) {
		for (var attrname in obj2) {
			Eif (obj2.hasOwnProperty(attrname)) {
				obj1[attrname] = obj2[attrname];
			}
		}
	};
 
	var __ = function (key, language) {
		var countryCode = (language) ? language : lang;
		loggedKeys[key] = key;
		if (typeof key === "object") {
			if (key instanceof Array) {
				return getText.getFromArray(key, countryCode);
			} else {
				return getText.getFromObjectKeys(key, countryCode);
			}
		} else {
			return getText.getFromKey(key, countryCode);
		}
	};
	
	var loadI18nScript = function (code) {
		// paatterned after jQuery's getScript.
		var url = Date.Config.i18n + code + ".js";
		var head = document.getElementsByTagName("head")[0] || document.documentElement;
		var script = document.createElement("script");
		script.src = url;
 
		var completed = false;
		var events = {
			done: function (){} // placeholder function
		};
		// Attach handlers for all browsers
		script.onload = script.onreadystatechange = function() {
			Eif ( !completed && (!this.readyState || this.readyState === "loaded" || this.readyState === "complete") ) {
				events.done();
				head.removeChild(script);
			}
		};
 
		setTimeout(function() {
			head.insertBefore(script, head.firstChild);
		}, 0); // allows return to execute first
		
		return {
			done: function (cb) {
				events.done = function() {
					Eif (cb) {
						setTimeout(cb,0);
					}
				};
			}
		};
	};
 
	var buildInfo = {
		buildFromMethodHash: function (obj) {
			var key;
			for(key in obj) {
				Eif (obj.hasOwnProperty(key)) {
					obj[key] = buildInfo[obj[key]]();
				}
			}
			return obj;
		},
		timeZoneDST: function () {
			var DST = {
				"CHADT": "+1345",
				"NZDT": "+1300",
				"AEDT": "+1100",
				"ACDT": "+1030",
				"AZST": "+0500",
				"IRDT": "+0430",
				"EEST": "+0300",
				"CEST": "+0200",
				"BST": "+0100",
				"PMDT": "-0200",
				"ADT": "-0300",
				"NDT": "-0230",
				"EDT": "-0400",
				"CDT": "-0500",
				"MDT": "-0600",
				"PDT": "-0700",
				"AKDT": "-0800",
				"HADT": "-0900"
			};
			return __(DST);
		},
		timeZoneStandard: function () {
			var standard = {
				"LINT": "+1400",
				"TOT": "+1300",
				"CHAST": "+1245",
				"NZST": "+1200",
				"NFT": "+1130",
				"SBT": "+1100",
				"AEST": "+1000",
				"ACST": "+0930",
				"JST": "+0900",
				"CWST": "+0845",
				"CT": "+0800",
				"ICT": "+0700",
				"MMT": "+0630",
				"BST": "+0600",
				"NPT": "+0545",
				"IST": "+0530",
				"PKT": "+0500",
				"AFT": "+0430",
				"MSK": "+0400",
				"IRST": "+0330",
				"FET": "+0300",
				"EET": "+0200",
				"CET": "+0100",
				"GMT": "+0000",
				"UTC": "+0000",
				"CVT": "-0100",
				"GST": "-0200",
				"BRT": "-0300",
				"NST": "-0330",
				"AST": "-0400",
				"EST": "-0500",
				"CST": "-0600",
				"MST": "-0700",
				"PST": "-0800",
				"AKST": "-0900",
				"MIT": "-0930",
				"HST": "-1000",
				"SST": "-1100",
				"BIT": "-1200"
			};
			return __(standard);
		},
		timeZones: function (data) {
			var zone;
			data.timezones = [];
			for (zone in data.abbreviatedTimeZoneStandard) {
				Eif (data.abbreviatedTimeZoneStandard.hasOwnProperty(zone)) {
					data.timezones.push({ name: zone, offset: data.abbreviatedTimeZoneStandard[zone]});
				}
			}
			for (zone in data.abbreviatedTimeZoneDST) {
				Eif (data.abbreviatedTimeZoneDST.hasOwnProperty(zone)) {
					data.timezones.push({ name: zone, offset: data.abbreviatedTimeZoneDST[zone], dst: true});
				}
			}
			return data.timezones;
		},
		days: function () {
			return __(["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"]);
		},
		dayAbbr: function () {
			return __(["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"]);
		},
		dayShortNames: function () {
			return __(["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"]);
		},
		dayFirstLetters: function () {
			return __(["S_Sun_Initial", "M_Mon_Initial", "T_Tues_Initial", "W_Wed_Initial", "T_Thu_Initial", "F_Fri_Initial", "S_Sat_Initial"]);
		},
		months: function () {
			return __(["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"]);
		},
		monthAbbr: function () {
			return __(["Jan_Abbr", "Feb_Abbr", "Mar_Abbr", "Apr_Abbr", "May_Abbr", "Jun_Abbr", "Jul_Abbr", "Aug_Abbr", "Sep_Abbr", "Oct_Abbr", "Nov_Abbr", "Dec_Abbr"]);
		},
		formatPatterns: function () {
			return getText.getFromObjectValues({
				shortDate: "M/d/yyyy",
				longDate: "dddd, MMMM dd, yyyy",
				shortTime: "h:mm tt",
				longTime: "h:mm:ss tt",
				fullDateTime: "dddd, MMMM dd, yyyy h:mm:ss tt",
				sortableDateTime: "yyyy-MM-ddTHH:mm:ss",
				universalSortableDateTime: "yyyy-MM-dd HH:mm:ssZ",
				rfc1123: "ddd, dd MMM yyyy HH:mm:ss",
				monthDay: "MMMM dd",
				yearMonth: "MMMM, yyyy"
			}, Date.i18n.currentLanguage());
		},
		regex: function () {
			return getText.getFromObjectValues({
				inTheMorning: "/( in the )(morn(ing)?)\\b/",
				thisMorning: "/(this )(morn(ing)?)\\b/",
				amThisMorning: "/(\b\\d(am)? )(this )(morn(ing)?)/",
				inTheEvening: "/( in the )(even(ing)?)\\b/",
				thisEvening: "/(this )(even(ing)?)\\b/",
				pmThisEvening: "/(\b\\d(pm)? )(this )(even(ing)?)/",
				jan: "/jan(uary)?/",
				feb: "/feb(ruary)?/",
				mar: "/mar(ch)?/",
				apr: "/apr(il)?/",
				may: "/may/",
				jun: "/jun(e)?/",
				jul: "/jul(y)?/",
				aug: "/aug(ust)?/",
				sep: "/sep(t(ember)?)?/",
				oct: "/oct(ober)?/",
				nov: "/nov(ember)?/",
				dec: "/dec(ember)?/",
				sun: "/^su(n(day)?)?/",
				mon: "/^mo(n(day)?)?/",
				tue: "/^tu(e(s(day)?)?)?/",
				wed: "/^we(d(nesday)?)?/",
				thu: "/^th(u(r(s(day)?)?)?)?/",
				fri: "/fr(i(day)?)?/",
				sat: "/^sa(t(urday)?)?/",
				future: "/^next/",
				past: "/^last|past|prev(ious)?/",
				add: "/^(\\+|aft(er)?|from|hence)/",
				subtract: "/^(\\-|bef(ore)?|ago)/",
				yesterday: "/^yes(terday)?/",
				today: "/^t(od(ay)?)?/",
				tomorrow: "/^tom(orrow)?/",
				now: "/^n(ow)?/",
				millisecond: "/^ms|milli(second)?s?/",
				second: "/^sec(ond)?s?/",
				minute: "/^mn|min(ute)?s?/",
				hour: "/^h(our)?s?/",
				week: "/^w(eek)?s?/",
				month: "/^m(onth)?s?/",
				day: "/^d(ay)?s?/",
				year: "/^y(ear)?s?/",
				shortMeridian: "/^(a|p)/",
				longMeridian: "/^(a\\.?m?\\.?|p\\.?m?\\.?)/",
				timezone: "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/",
				ordinalSuffix: "/^\\s*(st|nd|rd|th)/",
				timeContext: "/^\\s*(\\:|a(?!u|p)|p)/"
			}, Date.i18n.currentLanguage());
		}
	};
 
	var CultureInfo = function () {
		var info = getText.getFromObjectValues({
			name: "name",
			englishName: "englishName",
			nativeName: "nativeName",
			amDesignator: "AM",
			pmDesignator: "PM",
			firstDayOfWeek: "firstDayOfWeek",
			twoDigitYearMax: "twoDigitYearMax",
			dateElementOrder: "mdy"
		}, Date.i18n.currentLanguage());
 
		var constructedInfo = buildInfo.buildFromMethodHash({
			dayNames: "days",
			abbreviatedDayNames: "dayAbbr",
			shortestDayNames: "dayShortNames",
			firstLetterDayNames: "dayFirstLetters",
			monthNames: "months",
			abbreviatedMonthNames: "monthAbbr",
			formatPatterns: "formatPatterns",
			regexPatterns: "regex",
			abbreviatedTimeZoneDST: "timeZoneDST",
			abbreviatedTimeZoneStandard: "timeZoneStandard"
		});
 
		shallowMerge(info, constructedInfo);
		buildInfo.timeZones(info);
		return info;
	};
 
	$D.i18n = {
		__: function (key, lang) {
			return __(key, lang);
		},
		currentLanguage: function () {
			return lang || "en-US";
		},
		setLanguage: function (code, force, cb) {
			var async = false;
			if (force || code === "en-US" || (!!Date.CultureStrings && !!Date.CultureStrings[code])) {
				lang = code;
				Date.CultureStrings = Date.CultureStrings || {};
				Date.CultureStrings.lang = code;
				Date.CultureInfo = new CultureInfo();
			} else {
				Eif (!(!!Date.CultureStrings && !!Date.CultureStrings[code])) {
					Iif (typeof exports !== "undefined" && this.exports !== exports) {
						// we're in a Node enviroment, load it using require
						try {
							require("../i18n/" + code + ".js");
							lang = code;
							Date.CultureStrings.lang = code;
							Date.CultureInfo = new CultureInfo();
						} catch (e) {
							// var str = "The language for '" + code + "' could not be loaded by Node. It likely does not exist.";
							throw new Error("The DateJS IETF language tag '" + code + "' could not be loaded by Node. It likely does not exist.");
						}
					} else if (Date.Config && Date.Config.i18n) {
						// we know the location of the files, so lets load them					
						async = true;
						loadI18nScript(code).done(function(){
							lang = code;
							Date.CultureStrings = Date.CultureStrings || {};
							Date.CultureStrings.lang = code;
							Date.CultureInfo = new CultureInfo();
							$D.Parsing.Normalizer.buildReplaceData(); // because this is async
							Eif ($D.Grammar) {
								$D.Grammar.buildGrammarFormats(); // so we can parse those strings...
							}
							Eif (cb) {
								setTimeout(cb,0);
							}
						});
					} else {
						Date.console.error("The DateJS IETF language tag '" + code + "' is not available and has not been loaded.");
						return false;
					}
				}
			}
			$D.Parsing.Normalizer.buildReplaceData(); // rebuild normalizer strings
			Eif ($D.Grammar) {
				$D.Grammar.buildGrammarFormats(); // so we can parse those strings...
			}
			if (!async && cb) {
				setTimeout(cb,0);
			}
		},
		getLoggedKeys: function () {
			return loggedKeys;
		},
		updateCultureInfo: function () {
			Date.CultureInfo = new CultureInfo();
		}
	};
	$D.i18n.updateCultureInfo(); // run automatically
}());
================================================ FILE: reports/lcov-report/core/index.html ================================================ Code coverage report for core/

Code coverage report for core/

Statements: 82.29% (1385 / 1683)      Branches: 70.61% (793 / 1123)      Functions: 83.48% (288 / 345)      Lines: 82.5% (1377 / 1669)      Ignored: none     

All files » core/
File Statements Branches Functions Lines
core-prototypes.js 95.1% (291 / 306) 83.33% (195 / 234) 100% (50 / 50) 96.28% (285 / 296)
core.js 96.77% (120 / 124) 90.11% (82 / 91) 91.18% (31 / 34) 98.36% (120 / 122)
extras.js 61.76% (42 / 68) 33.33% (15 / 45) 92.31% (12 / 13) 61.76% (42 / 68)
format_parser.js 96.95% (159 / 164) 86.13% (118 / 137) 94.29% (33 / 35) 96.95% (159 / 164)
i18n.js 95.45% (147 / 154) 75% (69 / 92) 94.12% (32 / 34) 95.45% (147 / 154)
parser.js 72.34% (34 / 47) 87.5% (28 / 32) 62.5% (5 / 8) 72.34% (34 / 47)
parsing_grammar.js 91.59% (98 / 107) 56.25% (9 / 16) 96.55% (28 / 29) 91.59% (98 / 107)
parsing_operators.js 72.12% (150 / 208) 65% (52 / 80) 70.45% (31 / 44) 72.12% (150 / 208)
parsing_translator.js 79.7% (161 / 202) 71.43% (165 / 231) 87.5% (28 / 32) 79.7% (161 / 202)
sugarpak.js 96.62% (143 / 148) 82.86% (58 / 70) 100% (30 / 30) 96.58% (141 / 146)
time_period.js 33.33% (21 / 63) 2.7% (1 / 37) 36.36% (4 / 11) 33.33% (21 / 63)
time_span.js 20.65% (19 / 92) 1.72% (1 / 58) 16% (4 / 25) 20.65% (19 / 92)
================================================ FILE: reports/lcov-report/core/parser.js.html ================================================ Code coverage report for core/parser.js

Code coverage report for core/parser.js

Statements: 72.34% (34 / 47)      Branches: 87.5% (28 / 32)      Functions: 62.5% (5 / 8)      Lines: 72.34% (34 / 47)      Ignored: none     

All files » core/ » parser.js
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 2071 1                                                                                                                                                                                                           1   530 530 530     530 530 530         530     2 2   2 2           1 620 620 6   614 3   611   449   611 81     530 530 530 528   2         1 1   1   1                                                                                 1        
(function () {
	var $D = Date;
 
	/**
	 * @desc Converts the specified string value into its JavaScript Date equivalent using CultureInfo specific format information.
	 * 
	 * Example
	<pre><code>
	///////////
	// Dates //
	///////////
 
	// 15-Oct-2004
	var d1 = Date.parse("10/15/2004");
 
	// 15-Oct-2004
	var d1 = Date.parse("15-Oct-2004");
 
	// 15-Oct-2004
	var d1 = Date.parse("2004.10.15");
 
	//Fri Oct 15, 2004
	var d1 = Date.parse("Fri Oct 15, 2004");
 
	///////////
	// Times //
	///////////
 
	// Today at 10 PM.
	var d1 = Date.parse("10 PM");
 
	// Today at 10:30 PM.
	var d1 = Date.parse("10:30 P.M.");
 
	// Today at 6 AM.
	var d1 = Date.parse("06am");
 
	/////////////////////
	// Dates and Times //
	/////////////////////
 
	// 8-July-2004 @ 10:30 PM
	var d1 = Date.parse("July 8th, 2004, 10:30 PM");
 
	// 1-July-2004 @ 10:30 PM
	var d1 = Date.parse("2004-07-01T22:30:00");
 
	////////////////////
	// Relative Dates //
	////////////////////
 
	// Returns today's date. The string "today" is culture specific.
	var d1 = Date.parse("today");
 
	// Returns yesterday's date. The string "yesterday" is culture specific.
	var d1 = Date.parse("yesterday");
 
	// Returns the date of the next thursday.
	var d1 = Date.parse("Next thursday");
 
	// Returns the date of the most previous monday.
	var d1 = Date.parse("last monday");
 
	// Returns today's day + one year.
	var d1 = Date.parse("next year");
 
	///////////////
	// Date Math //
	///////////////
 
	// Today + 2 days
	var d1 = Date.parse("t+2");
 
	// Today + 2 days
	var d1 = Date.parse("today + 2 days");
 
	// Today + 3 months
	var d1 = Date.parse("t+3m");
 
	// Today - 1 year
	var d1 = Date.parse("today - 1 year");
 
	// Today - 1 year
	var d1 = Date.parse("t-1y"); 
 
 
	/////////////////////////////
	// Partial Dates and Times //
	/////////////////////////////
 
	// July 15th of this year.
	var d1 = Date.parse("July 15");
 
	// 15th day of current day and year.
	var d1 = Date.parse("15");
 
	// July 1st of current year at 10pm.
	var d1 = Date.parse("7/1 10pm");
	</code></pre>
	 *
	 * @param {String}   The string value to convert into a Date object [Required]
	 * @return {Date}    A Date object or null if the string cannot be converted into a Date.
	 */
	var parseUtils = {
		removeOrds: function (s) {
			ords = s.match(/\b(\d+)(?:st|nd|rd|th)\b/); // find ordinal matches
			s = ((ords && ords.length === 2) ? s.replace(ords[0], ords[1]) : s);
			return s;
		},
		grammarParser: function (s) {
			var r = null;
			try {
				r = $D.Grammar.start.call({}, s.replace(/^\s*(\S*(\s+\S+)*)\s*$/, "$1"));
			} catch (e) {
				return null;
			}
			
			return ((r[1].length === 0) ? r[0] : null);
		},
		nativeFallback: function(s) {
			var t;
			try {
				// ok we haven't parsed it, last ditch attempt with the built-in parser.
				t = Date._parse(s);
				return (t || t === 0) ? new Date(t) : null;
			} catch (e) {
				return null;
			}
		}
	};
	function parse (s) {
		var d;
		if (!s) {
			return null;
		}
		if (s instanceof Date) {
			return s.clone();
		}
		if (s.length >= 4 && s.charAt(0) !== "0" && s.charAt(0) !== "+"&& s.charAt(0) !== "-") { // ie: 2004 will pass, 0800 won't.
			//  Start with specific formats
			d = $D.Parsing.ISO.parse(s) || $D.Parsing.Numeric.parse(s);
		}
		if (d instanceof Date && !isNaN(d.getTime())) {
			return d;
		} else {
			// find ordinal dates (1st, 3rd, 8th, etc and remove them as they cause parsing issues)
			s = $D.Parsing.Normalizer.parse(parseUtils.removeOrds(s));
			d = parseUtils.grammarParser(s);
			if (d !== null) {
				return d;
			} else {
				return parseUtils.nativeFallback(s);
			}
		}
	}
 
	Eif (!$D._parse) {
		$D._parse = $D.parse;
	}
	$D.parse = parse;
 
	Date.getParseFunction = function (fx) {
		var fns = Date.Grammar.allformats(fx);
		return function (s) {
			var r = null;
			for (var i = 0; i < fns.length; i++) {
				try {
					r = fns[i].call({}, s);
				} catch (e) {
					continue;
				}
				if (r[1].length === 0) {
					return r[0];
				}
			}
			return null;
		};
	};
	
	/**
	 * Converts the specified string value into its JavaScript Date equivalent using the specified format {String} or formats {Array} and the CultureInfo specific format information.
	 * The format of the string value must match one of the supplied formats exactly.
	 * 
	 * Example
	<pre><code>
	// 15-Oct-2004
	var d1 = Date.parseExact("10/15/2004", "M/d/yyyy");
 
	// 15-Oct-2004
	var d1 = Date.parse("15-Oct-2004", "M-ddd-yyyy");
 
	// 15-Oct-2004
	var d1 = Date.parse("2004.10.15", "yyyy.MM.dd");
 
	// Multiple formats
	var d1 = Date.parseExact("10/15/2004", ["M/d/yyyy", "MMMM d, yyyy"]);
	</code></pre>
	 *
	 * @param {String}   The string value to convert into a Date object [Required].
	 * @param {Object}   The expected format {String} or an array of expected formats {Array} of the date string [Required].
	 * @return {Date}    A Date object or null if the string cannot be converted into a Date.
	 */
	$D.parseExact = function (s, fx) {
		return $D.getParseFunction(fx)(s);
	};
}());
 
================================================ FILE: reports/lcov-report/core/parsing_grammar.js.html ================================================ Code coverage report for core/parsing_grammar.js

Code coverage report for core/parsing_grammar.js

Statements: 91.59% (98 / 107)      Branches: 56.25% (9 / 16)      Functions: 96.55% (28 / 29)      Lines: 91.59% (98 / 107)      Ignored: none     

All files » core/ » parsing_grammar.js
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 3101 1 1 1   1 480     1 1 1 1   1 1 960 960 960 960 960 5440   960   960   1 1280   1 3040 320   2720     1 480   1   1 20 20     1                       1 1 1 1 20   1           1   160                                                                                 160 1760     160   160 160 160   160 160       160 480   160                                                                     160 1280     160 160   13 10         160 160 160   160 160 160   160 530         160   6 6         160   451 451       160 160   449 449             1   160   160 160 160     160   456 451       160   160           91 91                 56             20         160       1         1                                                 1 530 530 47       530    
(function () {
	var $D = Date;
	$D.Grammar = {};
	var _ = $D.Parsing.Operators, g = $D.Grammar, t = $D.Translator, _fn;
	// Allow rolling up into general purpose rules
	_fn = function () {
		return _.each(_.any.apply(null, arguments), _.not(g.ctoken2("timeContext")));
	};
	
	g.datePartDelimiter = _.rtoken(/^([\s\-\.\,\/\x27]+)/);
	g.timePartDelimiter = _.stoken(":");
	g.whiteSpace = _.rtoken(/^\s*/);
	g.generalDelimiter = _.rtoken(/^(([\s\,]|at|@|on)+)/);
  
	var _C = {};
	g.ctoken = function (keys) {
		var fn = _C[keys];
		Eif (! fn) {
			var c = Date.CultureInfo.regexPatterns;
			var kx = keys.split(/\s+/), px = [];
			for (var i = 0; i < kx.length ; i++) {
				px.push(_.replace(_.rtoken(c[kx[i]]), kx[i]));
			}
			fn = _C[keys] = _.any.apply(null, px);
		}
		return fn;
	};
	g.ctoken2 = function (key) {
		return _.rtoken(Date.CultureInfo.regexPatterns[key]);
	};
	var cacheProcessRtoken = function (key, token, type, eachToken) {
		if (eachToken) {
			g[key] = _.cache(_.process(_.each(_.rtoken(token),_.optional(g.ctoken2(eachToken))), type));
		} else {
			g[key] = _.cache(_.process(_.rtoken(token), type));
		}
	};
	var cacheProcessCtoken = function (token, type) {
		return _.cache(_.process(g.ctoken2(token), type));
	};
	var _F = {}; //function cache
 
	var _get = function (f) {
		_F[f] = (_F[f] || g.format(f)[0]);
		return _F[f];
	};
 
	g.allformats = function (fx) {
		var rx = [];
		if (fx instanceof Array) {
			for (var i = 0; i < fx.length; i++) {
				rx.push(_get(fx[i]));
			}
		} else {
			rx.push(_get(fx));
		}
		return rx;
	};
  
	g.formats = function (fx) {
		Eif (fx instanceof Array) {
			var rx = [];
			for (var i = 0 ; i < fx.length ; i++) {
				rx.push(_get(fx[i]));
			}
			return _.any.apply(null, rx);
		} else {
			return _get(fx);
		}
	};
 
	var grammarFormats = {
		 timeFormats: function(){
			var i,
			RTokenKeys = [
				"h",
				"hh",
				"H",
				"HH",
				"m",
				"mm",
				"s",
				"ss",
				"ss.s",
				"z",
				"zz"
			],
			RToken = [
				/^(0[0-9]|1[0-2]|[1-9])/,
				/^(0[0-9]|1[0-2])/,
				/^([0-1][0-9]|2[0-3]|[0-9])/,
				/^([0-1][0-9]|2[0-3])/,
				/^([0-5][0-9]|[0-9])/,
				/^[0-5][0-9]/,
				/^([0-5][0-9]|[0-9])/,
				/^[0-5][0-9]/,
				/^[0-5][0-9]\.[0-9]{1,3}/,
				/^((\+|\-)\s*\d\d\d\d)|((\+|\-)\d\d\:?\d\d)/,
				/^((\+|\-)\s*\d\d\d\d)|((\+|\-)\d\d\:?\d\d)/
			],
			tokens = [
				t.hour,
				t.hour,
				t.hour,
				t.minute,
				t.minute,
				t.second,
				t.second,
				t.secondAndMillisecond,
				t.timezone,
				t.timezone,
				t.timezone
			];
 
			for (i=0; i < RTokenKeys.length; i++) {
				cacheProcessRtoken(RTokenKeys[i], RToken[i], tokens[i]);
			}
 
			g.hms = _.cache(_.sequence([g.H, g.m, g.s], g.timePartDelimiter));
 
			g.t = cacheProcessCtoken("shortMeridian", t.meridian);
			g.tt = cacheProcessCtoken("longMeridian", t.meridian);
			g.zzz = cacheProcessCtoken("timezone", t.timezone);
 
			g.timeSuffix = _.each(_.ignore(g.whiteSpace), _.set([ g.tt, g.zzz ]));
			g.time = _.each(_.optional(_.ignore(_.stoken("T"))), g.hms, g.timeSuffix);
		 },
		 dateFormats: function () {
			// pre-loaded rules for different date part order preferences
			var _setfn = function () {
				return  _.set(arguments, g.datePartDelimiter);
			};
			var i,
			RTokenKeys = [
				"d",
				"dd",
				"M",
				"MM",
				"y",
				"yy",
				"yyy",
				"yyyy"
			],
			RToken = [
				/^([0-2]\d|3[0-1]|\d)/,
				/^([0-2]\d|3[0-1])/,
				/^(1[0-2]|0\d|\d)/,
				/^(1[0-2]|0\d)/,
				/^(\d+)/,
				/^(\d\d)/,
				/^(\d\d?\d?\d?)/,
				/^(\d\d\d\d)/
			],
			tokens = [
				t.day,
				t.day,
				t.month,
				t.month,
				t.year,
				t.year,
				t.year,
				t.year
			],
			eachToken = [
				"ordinalSuffix",
				"ordinalSuffix"
			];
			for (i=0; i < RTokenKeys.length; i++) {
				cacheProcessRtoken(RTokenKeys[i], RToken[i], tokens[i], eachToken[i]);
			}
 
			g.MMM = g.MMMM = _.cache(_.process(g.ctoken("jan feb mar apr may jun jul aug sep oct nov dec"), t.month));
			g.ddd = g.dddd = _.cache(_.process(g.ctoken("sun mon tue wed thu fri sat"),
				function (s) {
					return function () {
						this.weekday = s;
					};
				}
			));
 
			g.day = _fn(g.d, g.dd);
			g.month = _fn(g.M, g.MMM);
			g.year = _fn(g.yyyy, g.yy);
 
			g.mdy = _setfn(g.ddd, g.month, g.day, g.year);
			g.ymd = _setfn(g.ddd, g.year, g.month, g.day);
			g.dmy = _setfn(g.ddd, g.day, g.month, g.year);
						
			g.date = function (s) {
				return ((g[Date.CultureInfo.dateElementOrder] || g.mdy).call(this, s));
			};
		 },
		 relative: function () {
			// relative date / time expressions
			g.orientation = _.process(g.ctoken("past future"),
				function (s) {
					return function () {
						this.orient = s;
					};
				}
			);
 
			g.operator = _.process(g.ctoken("add subtract"),
				function (s) {
					return function () {
						this.operator = s;
					};
				}
			);
			g.rday = _.process(g.ctoken("yesterday tomorrow today now"), t.rday);
			g.unit = _.process(g.ctoken("second minute hour day week month year"),
				function (s) {
					return function () {
						this.unit = s;
					};
				}
			);
		 }
	};
 
	g.buildGrammarFormats = function () {
		// these need to be rebuilt every time the language changes.
		_C = {};
 
		grammarFormats.timeFormats();
		grammarFormats.dateFormats();
		grammarFormats.relative();
 
		
		g.value = _.process(_.rtoken(/^([-+]?\d+)?(st|nd|rd|th)?/),
			function (s) {
				return function () {
					this.value = s.replace(/\D/g, "");
				};
			}
		);
		g.expression = _.set([g.rday, g.operator, g.value, g.unit, g.orientation, g.ddd, g.MMM ]);
 
		g.format = _.process(_.many(
			_.any(
				// translate format specifiers into grammar rules
				_.process(
					_.rtoken(/^(dd?d?d?(?!e)|MM?M?M?|yy?y?y?|hh?|HH?|mm?|ss?|tt?|zz?z?)/),
						function (fmt) {
							Eif (g[fmt]) {
								return g[fmt];
							} else {
								throw $D.Parsing.Exception(fmt);
							}
						}
					),
					// translate separator tokens into token rules
					_.process(_.rtoken(/^[^dMyhHmstz]+/), // all legal separators 
						function (s) {
							return _.ignore(_.stoken(s));
						}
					)
				)
			),
			// construct the parser ...
			function (rules) {
				return _.process(_.each.apply(null, rules), t.finishExact);
			}
		);
 
		// starting rule for general purpose grammar
		g._start = _.process(_.set([ g.date, g.time, g.expression ],
		g.generalDelimiter, g.whiteSpace), t.finish);
	};
 
	g.buildGrammarFormats();
	// parsing date format specifiers - ex: "h:m:s tt" 
	// this little guy will generate a custom parser based
	// on the format string, ex: g.format("h:m:s tt")
	// check for these formats first
	g._formats = g.formats([
		"\"yyyy-MM-ddTHH:mm:ssZ\"",
		"yyyy-MM-ddTHH:mm:ss.sz",
		"yyyy-MM-ddTHH:mm:ssZ",
		"yyyy-MM-ddTHH:mm:ssz",
		"yyyy-MM-ddTHH:mm:ss",
		"yyyy-MM-ddTHH:mmZ",
		"yyyy-MM-ddTHH:mmz",
		"yyyy-MM-ddTHH:mm",
		"ddd, MMM dd, yyyy H:mm:ss tt",
		"ddd MMM d yyyy HH:mm:ss zzz",
		"MMddyyyy",
		"ddMMyyyy",
		"Mddyyyy",
		"ddMyyyy",
		"Mdyyyy",
		"dMyyyy",
		"yyyy",
		"Mdyy",
		"dMyy",
		"d"
	]);
	
	// real starting rule: tries selected formats first, 
	// then general purpose rule
	g.start = function (s) {
		try {
			var r = g._formats.call({}, s);
			Iif (r[1].length === 0) {
				return r;
			}
		} catch (e) {}
		return g._start.call({}, s);
	};
}());
================================================ FILE: reports/lcov-report/core/parsing_operators.js.html ================================================ Code coverage report for core/parsing_operators.js

Code coverage report for core/parsing_operators.js

Statements: 72.12% (150 / 208)      Branches: 65% (52 / 80)      Functions: 70.45% (31 / 44)      Lines: 72.12% (150 / 208)      Ignored: none     

All files » core/ » parsing_operators.js
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 4581 1 1         10780 25714 25714 4104   21610                   217                                           160 20 20 147 147       147 147   20           480 646 646 646   646           480 356 356   350   6       376   1104 1104 43                       4000 4000 15483                     4000 15483 15483 15483   5153   15483 15483 15483 14556   927             1601 1601 5498 5498 31059     31059 31059   29340   31059 1719     3779       1140 1140 14052 14052 15582     15582 15582   13450   2132 2132   602                   160 160   160     160 469 469 469 471 471   457   14 14 14   12 12   2   469 457   12     12             12                                               2340 2340 2340     2917   2917       6399 6399 6399 6399     6399 6399   3427       2972           2972 1922 1922   542     1050           2972               2972     1380 1380 7872 6492             1380       1380         1341 1341                 2972 2469       2972 2301                 2917 508       2409     528 528           528       2409                         5440 16998 1169       5300 18800 2744                                                                         1 1 5336 5336   5336     5336                 5336       4     1   1 4     1 3 2741     2741         1   1 3      
(function () {
	var $P = Date.Parsing;
	var _ = $P.Operators = {
		//
		// Tokenizers
		//
		rtoken: function (r) { // regex token
			return function (s) {
				var mx = s.match(r);
				if (mx) {
					return ([ mx[0], s.substring(mx[0].length) ]);
				} else {
					throw new $P.Exception(s);
				}
			};
		},
		token: function () { // whitespace-eating token
			return function (s) {
				return _.rtoken(new RegExp("^\\s*" + s + "\\s*"))(s);
			};
		},
		stoken: function (s) { // string token
			return _.rtoken(new RegExp("^" + s));
		},
 
		// Atomic Operators
 
		until: function (p) {
			return function (s) {
				var qx = [], rx = null;
				while (s.length) {
					try {
						rx = p.call(this, s);
					} catch (e) {
						qx.push(rx[0]);
						s = rx[1];
						continue;
					}
					break;
				}
				return [ qx, s ];
			};
		},
		many: function (p) {
			return function (s) {
				var rx = [], r = null;
				while (s.length) {
					try {
						r = p.call(this, s);
					} catch (e) {
						return [ rx, s ];
					}
					rx.push(r[0]);
					s = r[1];
				}
				return [ rx, s ];
			};
		},
 
		// generator operators -- see below
		optional: function (p) {
			return function (s) {
				var r = null;
				try {
					r = p.call(this, s);
				} catch (e) {
					return [ null, s ];
				}
				return [ r[0], r[1] ];
			};
		},
		not: function (p) {
			return function (s) {
				try {
					p.call(this, s);
				} catch (e) {
					return [null, s];
				}
				throw new $P.Exception(s);
			};
		},
		ignore: function (p) {
			return p ?
			function (s) {
				var r = null;
				r = p.call(this, s);
				return [null, r[1]];
			} : null;
		},
		product: function () {
			var px = arguments[0],
			qx = Array.prototype.slice.call(arguments, 1), rx = [];
			for (var i = 0 ; i < px.length ; i++) {
				rx.push(_.each(px[i], qx));
			}
			return rx;
		},
		cache: function (rule) {
			var cache = {}, cache_length = 0, cache_keys = [], CACHE_MAX = Date.Config.CACHE_MAX || 100000, r = null;
			var cacheCheck = function () {
				Iif (cache_length === CACHE_MAX) {
					// kill several keys, don't want to have to do this all the time...
					for (var i=0; i < 10; i++) {
						var key = cache_keys.shift();
						if (key) {
							delete cache[key];
							cache_length--;
						}
					}
				}
			};
			return function (s) {
				cacheCheck();
				try {
					r = cache[s] = (cache[s] || rule.call(this, s));
				} catch (e) {
					r = cache[s] = e;
				}
				cache_length++;
				cache_keys.push(s);
				if (r instanceof $P.Exception) {
					throw r;
				} else {
					return r;
				}
			};
		},
 
		// vector operators -- see below
		any: function () {
			var px = arguments;
			return function (s) {
				var r = null;
				for (var i = 0; i < px.length; i++) {
					Iif (px[i] == null) {
						continue;
					}
					try {
						r = (px[i].call(this, s));
					} catch (e) {
						r = null;
					}
					if (r) {
						return r;
					}
				}
				throw new $P.Exception(s);
			};
		},
		each: function () {
			var px = arguments;
			return function (s) {
				var rx = [], r = null;
				for (var i = 0; i < px.length ; i++) {
					Iif (px[i] == null) {
						continue;
					}
					try {
						r = (px[i].call(this, s));
					} catch (e) {
						throw new $P.Exception(s);
					}
					rx.push(r[0]);
					s = r[1];
				}
				return [ rx, s];
			};
		},
		all: function () {
			var px = arguments, _ = _;
			return _.each(_.optional(px));
		},
 
		// delimited operators
		sequence: function (px, d, c) {
			d = d || _.rtoken(/^\s*/);
			c = c || null;
			
			Iif (px.length === 1) {
				return px[0];
			}
			return function (s) {
				var r = null, q = null;
				var rx = [];
				for (var i = 0; i < px.length ; i++) {
					try {
						r = px[i].call(this, s);
					} catch (e) {
						break;
					}
					rx.push(r[0]);
					try {
						q = d.call(this, r[1]);
					} catch (ex) {
						q = null;
						break;
					}
					s = q[1];
				}
				if (!r) {
					throw new $P.Exception(s);
				}
				Iif (q) {
					throw new $P.Exception(q[1]);
				}
				Iif (c) {
					try {
						r = c.call(this, r[1]);
					} catch (ey) {
						throw new $P.Exception(r[1]);
					}
				}
				return [ rx, (r?r[1]:s) ];
			};
		},
 
		//
		// Composite Operators
		//
 
		between: function (d1, p, d2) {
			d2 = d2 || d1;
			var _fn = _.each(_.ignore(d1), p, _.ignore(d2));
			return function (s) {
				var rx = _fn.call(this, s);
				return [[rx[0][0], r[0][2]], rx[1]];
			};
		},
		list: function (p, d, c) {
			d = d || _.rtoken(/^\s*/);
			c = c || null;
			return (p instanceof Array ?
				_.each(_.product(p.slice(0, -1), _.ignore(d)), p.slice(-1), _.ignore(c)) :
				_.each(_.many(_.each(p, _.ignore(d))), px, _.ignore(c)));
		},
		set: function (px, d, c) {
			d = d || _.rtoken(/^\s*/);
			c = c || null;
			return function (s) {
				// r is the current match, best the current 'best' match
				// which means it parsed the most amount of input
				var r = null, p = null, q = null, rx = null, best = [[], s], last = false;
				// go through the rules in the given set
				for (var i = 0; i < px.length ; i++) {
 
					// last is a flag indicating whether this must be the last element
					// if there is only 1 element, then it MUST be the last one
					q = null;
					p = null;
					r = null;
					last = (px.length === 1);
					// first, we try simply to match the current pattern
					// if not, try the next pattern
					try {
						r = px[i].call(this, s);
					} catch (e) {
						continue;
					}
					// since we are matching against a set of elements, the first
					// thing to do is to add r[0] to matched elements
					rx = [[r[0]], r[1]];
					// if we matched and there is still input to parse and 
					// we don't already know this is the last element,
					// we're going to next check for the delimiter ...
					// if there's none, or if there's no input left to parse
					// than this must be the last element after all ...
					if (r[1].length > 0 && ! last) {
						try {
							q = d.call(this, r[1]);
						} catch (ex) {
							last = true;
						}
					} else {
						last = true;
					}
 
					// if we parsed the delimiter and now there's no more input,
					// that means we shouldn't have parsed the delimiter at all
					// so don't update r and mark this as the last element ...
					Iif (!last && q[1].length === 0) {
						last = true;
					}
 
 
					// so, if this isn't the last element, we're going to see if
					// we can get any more matches from the remaining (unmatched)
					// elements ...
					if (!last) {
						// build a list of the remaining rules we can match against,
						// i.e., all but the one we just matched against
						var qx = [];
						for (var j = 0; j < px.length ; j++) {
							if (i !== j) {
								qx.push(px[j]);
							}
						}
 
						// now invoke recursively set with the remaining input
						// note that we don't include the closing delimiter ...
						// we'll check for that ourselves at the end
						p = _.set(qx, d).call(this, q[1]);
 
						// if we got a non-empty set as a result ...
						// (otw rx already contains everything we want to match)
						if (p[0].length > 0) {
							// update current result, which is stored in rx ...
							// basically, pick up the remaining text from p[1]
							// and concat the result from p[0] so that we don't
							// get endless nesting ...
							rx[0] = rx[0].concat(p[0]);
							rx[1] = p[1];
						}
					}
 
					// at this point, rx either contains the last matched element
					// or the entire matched set that starts with this element.
 
					// now we just check to see if this variation is better than
					// our best so far, in terms of how much of the input is parsed
					if (rx[1].length < best[1].length) {
						best = rx;
					}
 
					// if we've parsed all the input, then we're finished
					if (best[1].length === 0) {
						break;
					}
				}
 
				// so now we've either gone through all the patterns trying them
				// as the initial match; or we found one that parsed the entire
				// input string ...
 
				// if best has no matches, just return empty set ...
				if (best[0].length === 0) {
					return best;
				}
 
				// if a closing delimiter is provided, then we have to check it also
				if (c) {
					// we try this even if there is no remaining input because the pattern
					// may well be optional or match empty input ...
					try {
						q = c.call(this, best[1]);
					} catch (ey) {
						throw new $P.Exception(best[1]);
					}
 
					// it parsed ... be sure to update the best match remaining input
					best[1] = q[1];
				}
				// if we're here, either there was no closing delimiter or we parsed it
				// so now we have the best match; just return it!
				return best;
			};
		},
		forward: function (gr, fname) {
			return function (s) {
				return gr[fname].call(this, s);
			};
		},
 
		//
		// Translation Operators
		//
		replace: function (rule, repl) {
			return function (s) {
				var r = rule.call(this, s);
				return [repl, r[1]];
			};
		},
		process: function (rule, fn) {
			return function (s) {
				var r = rule.call(this, s);
				return [fn.call(this, r[0]), r[1]];
			};
		},
		min: function (min, rule) {
			return function (s) {
				var rx = rule.call(this, s);
				if (rx[0].length < min) {
					throw new $P.Exception(s);
				}
				return rx;
			};
		}
	};
	
 
	// Generator Operators And Vector Operators
 
	// Generators are operators that have a signature of F(R) => R,
	// taking a given rule and returning another rule, such as 
	// ignore, which parses a given rule and throws away the result.
 
	// Vector operators are those that have a signature of F(R1,R2,...) => R,
	// take a list of rules and returning a new rule, such as each.
 
	// Generator operators are converted (via the following _generator
	// function) into functions that can also take a list or array of rules
	// and return an array of new rules as though the function had been
	// called on each rule in turn (which is what actually happens).
 
	// This allows generators to be used with vector operators more easily.
	// Example:
	// each(ignore(foo, bar)) instead of each(ignore(foo), ignore(bar))
 
	// This also turns generators into vector operators, which allows
	// constructs like:
	// not(cache(foo, bar))
	
	var _generator = function (op) {
		function gen() {
			var args = null, rx = [], px, i;
			Iif (arguments.length > 1) {
				args = Array.prototype.slice.call(arguments);
			} else Iif (arguments[0] instanceof Array) {
				args = arguments[0];
			}
			Iif (args) {
				px = args.shift();
				if (px.length > 0) {
					args.unshift(px[i]);
					rx.push(op.apply(null, args));
					args.shift();
					return rx;
				}
			} else {
				return op.apply(null, arguments);
			}
		}
 
		return gen;
	};
	
	var gx = "optional not ignore cache".split(/\s/);
	
	for (var i = 0 ; i < gx.length ; i++) {
		_[gx[i]] = _generator(_[gx[i]]);
	}
 
	var _vector = function (op) {
		return function () {
			Iif (arguments[0] instanceof Array) {
				return op.apply(null, arguments[0]);
			} else {
				return op.apply(null, arguments);
			}
		};
	};
	
	var vx = "each any all".split(/\s/);
	
	for (var j = 0 ; j < vx.length ; j++) {
		_[vx[j]] = _vector(_[vx[j]]);
	}
	
}());
================================================ FILE: reports/lcov-report/core/parsing_translator.js.html ================================================ Code coverage report for core/parsing_translator.js

Code coverage report for core/parsing_translator.js

Statements: 79.7% (161 / 202)      Branches: 71.43% (165 / 231)      Functions: 87.5% (28 / 32)      Lines: 79.7% (161 / 202)      Ignored: none     

All files » core/ » parsing_translator.js
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 3621 1   1 1327 1327 2853 797   2056 1822       1327     1 577 11   11   11 7 4           1 49 49       49 42     49 49     49 7     49 49     49 49     49 49   49 49       1   528 91   437       2 2 2 2 2 2     108 108 108 108 108 108 108     1 1 1 1   1 1     528   528 525 80   525       35 35 35 1   35       1   12 17       2 3                                 4 11       2 2 2     2         169 169 109 109           154 68 68           50 72 72         230 222               221 221   1 1 1         49 49   49 49 49       49 49   49 2     47 47     47   47       47     530   530   530 2     528 1822 1822     528     528     528 528   528 1 1 1     528               528 1     528 2     528               528             528       528             528 108 108     528 108     528 77     528 528   528       528       528 35     493       493 422   71     493 2 2 2 2   2 2   1     1       2     493      
(function () {
	var $D = Date;
 
	var flattenAndCompact = function (ax) {
		var rx = [];
		for (var i = 0; i < ax.length; i++) {
			if (ax[i] instanceof Array) {
				rx = rx.concat(flattenAndCompact(ax[i]));
			} else {
				if (ax[i]) {
					rx.push(ax[i]);
				}
			}
		}
		return rx;
	};
 
	var parseMeridian = function () {
		if (this.meridian && (this.hour || this.hour === 0)) {
			Iif (this.meridian === "a" && this.hour > 11 && Date.Config.strict24hr){
				throw "Invalid hour and meridian combination";
			} else Iif (this.meridian === "p" && this.hour < 12 && Date.Config.strict24hr){
				throw "Invalid hour and meridian combination";
			} else if (this.meridian === "p" && this.hour < 12) {
				this.hour = this.hour + 12;
			} else Iif (this.meridian === "a" && this.hour === 12) {
				this.hour = 0;
			}
		}
	};
 
	var setDefaults = function () {
		var now = new Date();
		Iif ((this.hour || this.minute) && (!this.month && !this.year && !this.day)) {
			this.day = now.getDate();
		}
 
		if (!this.year) {
			this.year = now.getFullYear();
		}
		
		Eif (!this.month && this.month !== 0) {
			this.month = now.getMonth();
		}
		
		if (!this.day) {
			this.day = 1;
		}
		
		Eif (!this.hour) {
			this.hour = 0;
		}
		
		Eif (!this.minute) {
			this.minute = 0;
		}
 
		Eif (!this.second) {
			this.second = 0;
		}
		Eif (!this.millisecond) {
			this.millisecond = 0;
		}
	};
 
	var finishUtils = {
		getToday: function () {
			 if (this.now || "hour minute second".indexOf(this.unit) !== -1) {
				return new Date();
			} else {
				return $D.today();
			}
		},
		setDaysFromWeekday: function (today, orient){
			var gap;
			orient = orient || 1;
			this.unit = "day";
			gap = ($D.getDayNumberFromName(this.weekday) - today.getDay());
			this.days = gap ? ((gap + (orient * 7)) % 7) : (orient * 7);
			return this;
		},
		setMonthsFromMonth: function (today, orient) {
			var gap;
			orient = orient || 1;
			this.unit = "month";
			gap = (this.month - today.getMonth());
			this.months = gap ? ((gap + (orient * 12)) % 12) : (orient * 12);
			this.month = null;
			return this;
		},
		setDMYFromWeekday: function () {
			var d = Date[this.weekday]();
			this.day = d.getDate();
			Eif (!this.month) {
				this.month = d.getMonth();
			}
			this.year = d.getFullYear();
			return this;
		},
		setUnitValue: function (orient) {
			Iif (!this.value && this.operator && this.operator !== null && this[this.unit + "s"] && this[this.unit + "s"] !== null) {
				this[this.unit + "s"] = this[this.unit + "s"] + ((this.operator === "add") ? 1 : -1) + (this.value||0) * orient;
			} else if (this[this.unit + "s"] == null || this.operator != null) {
				if (!this.value) {
					this.value = 1;
				}
				this[this.unit + "s"] = this.value * orient;
			}
		},
		generateDateFromWeeks: function () {
			var weekday = (this.weekday !== undefined) ? this.weekday : "today";
			var d = Date[weekday]().addWeeks(this.weeks);
			if (this.now) {
				d.setTimeToNow();
			}
			return d;
		}
	};
 
	$D.Translator = {
		hour: function (s) {
			return function () {
				this.hour = Number(s);
			};
		},
		minute: function (s) {
			return function () {
				this.minute = Number(s);
			};
		},
		second: function (s) {
			return function () {
				this.second = Number(s);
			};
		},
		/* for ss.s format */
		secondAndMillisecond: function (s) {
			return function () {
				var mx = s.match(/^([0-5][0-9])\.([0-9]{1,3})/);
				this.second = Number(mx[1]);
				this.millisecond = Number(mx[2]);
			};
		},
		meridian: function (s) {
			return function () {
				this.meridian = s.slice(0, 1).toLowerCase();
			};
		},
		timezone: function (s) {
			return function () {
				var n = s.replace(/[^\d\+\-]/g, "");
				Iif (n.length) {
					this.timezoneOffset = Number(n);
				} else {
					this.timezone = s.toLowerCase();
				}
			};
		},
		day: function (x) {
			var s = x[0];
			return function () {
				this.day = Number(s.match(/\d+/)[0]);
				Iif (this.day < 1) {
					throw "invalid day";
				}
			};
		},
		month: function (s) {
			return function () {
				this.month = (s.length === 3) ? "jan feb mar apr may jun jul aug sep oct nov dec".indexOf(s)/4 : Number(s) - 1;
				Iif (this.month < 0) {
					throw "invalid month";
				}
			};
		},
		year: function (s) {
			return function () {
				var n = Number(s);
				this.year = ((s.length > 2) ? n :
					(n + (((n + 2000) < Date.CultureInfo.twoDigitYearMax) ? 2000 : 1900)));
			};
		},
		rday: function (s) {
			return function () {
				switch (s) {
					case "yesterday":
						this.days = -1;
						break;
					case "tomorrow":
						this.days = 1;
						break;
					case "today":
						this.days = 0;
						break;
					case "now":
						this.days = 0;
						this.now = true;
						break;
				}
			};
		},
		finishExact: function (x) {
			var d;
			x = (x instanceof Array) ? x : [x];
 
			for (var i = 0 ; i < x.length ; i++) {
				Eif (x[i]) {
					x[i].call(this);
				}
			}
			
			setDefaults.call(this);
			parseMeridian.call(this);
 
			if (this.day > $D.getDaysInMonth(this.year, this.month)) {
				throw new RangeError(this.day + " is not a valid value for days.");
			}
 
			d = new Date(this.year, this.month, this.day, this.hour, this.minute, this.second, this.millisecond);
			Iif (this.year < 100) {
				d.setFullYear(this.year); // means years less that 100 are process correctly. JS will parse it otherwise as 1900-1999.
			}
			Iif (this.timezone) {
				d.set({ timezone: this.timezone });
			} else Iif (this.timezoneOffset) {
				d.set({ timezoneOffset: this.timezoneOffset });
			}
			
			return d;
		},
		finish: function (x) {
			var today, expression, orient, temp;
 
			x = (x instanceof Array) ? flattenAndCompact(x) : [ x ];
 
			if (x.length === 0) {
				return null;
			}
 
			for (var i = 0 ; i < x.length ; i++) {
				Eif (typeof x[i] === "function") {
					x[i].call(this);
				}
			}
			Iif (this.now && !this.unit && !this.operator) {
				return new Date();
			} else {
				today = finishUtils.getToday.call(this);
			}
			
			expression = !!(this.days && this.days !== null || this.orient || this.operator);
			orient = ((this.orient === "past" || this.operator === "subtract") ? -1 : 1);
 
			if (this.month && this.unit === "week") {
				this.value = this.month + 1;
				delete this.month;
				delete this.day;
			}
 
			Iif ((this.month || this.month === 0) && "year day hour minute second".indexOf(this.unit) !== -1) {
				if (!this.value) {
					this.value = this.month + 1;
				}
				this.month = null;
				expression = true;
			}
 
			if (!expression && this.weekday && !this.day && !this.days) {
				finishUtils.setDMYFromWeekday.call(this);
			}
 
			if (expression && this.weekday && this.unit !== "month" && this.unit !== "week") {
				finishUtils.setDaysFromWeekday.call(this, today, orient);
			}
 
			Iif (this.weekday && this.unit !== "week" && !this.day && !this.days) {
				temp = Date[this.weekday]();
				this.day = temp.getDate();
				if (temp.getMonth() !== today.getMonth()) {
					this.month = temp.getMonth();
				}
			}
 
			Iif (this.month && this.unit === "day" && this.operator) {
				if (!this.value) {
					this.value = (this.month + 1);
				}
				this.month = null;
			}
 
			Iif (this.value != null && this.month != null && this.year != null) {
				this.day = this.value * 1;
			}
 
			Iif (this.month && !this.day && this.value) {
				today.set({ day: this.value * 1 });
				if (!expression) {
					this.day = this.value * 1;
				}
			}
 
			if (!this.month && this.value && this.unit === "month" && !this.now) {
				this.month = this.value;
				expression = true;
			}
 
			if (expression && (this.month || this.month === 0) && this.unit !== "year") {
				finishUtils.setMonthsFromMonth.call(this, today, orient);
			}
 
			if (!this.unit) {
				this.unit = "day";
			}
 
			finishUtils.setUnitValue.call(this, orient);
			parseMeridian.call(this);
			
			Iif ((this.month || this.month === 0) && !this.day) {
				this.day = 1;
			}
 
			Iif (!this.orient && !this.operator && this.unit === "week" && this.value && !this.day && !this.month) {
				return Date.today().setWeek(this.value);
			}
 
			if (this.unit === "week" && this.weeks && !this.day && !this.month) {
				return finishUtils.generateDateFromWeeks.call(this);
			}
 
			Iif (expression && this.timezone && this.day && this.days) {
				this.day = this.days;
			}
 
			if (expression){
				today.add(this);
			} else {
				today.set(this);
			}
			
			if (this.timezone) {
				this.timezone = this.timezone.toUpperCase();
				var offset = $D.getTimezoneOffset(this.timezone);
				var timezone;
				Eif (today.hasDaylightSavingTime()) {
					// lets check that we're being sane with timezone setting
					timezone = $D.getTimezoneAbbreviation(offset, today.isDaylightSavingTime());
					if (timezone !== this.timezone) {
						// bugger, we're in a place where things like EST vs EDT matters.
						Iif (today.isDaylightSavingTime()) {
							today.addHours(-1);
						} else {
							today.addHours(1);
						}
					}
				}
				today.setTimezoneOffset(offset);
			}
 
			return today;
		}
	};
}());
================================================ FILE: reports/lcov-report/core/sugarpak.js.html ================================================ Code coverage report for core/sugarpak.js

Code coverage report for core/sugarpak.js

Statements: 96.62% (143 / 148)      Branches: 82.86% (58 / 70)      Functions: 100% (30 / 30)      Lines: 96.58% (141 / 146)      Ignored: none     

All files » core/ » sugarpak.js
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494        1 1     1     1     1     1     1     1                             1 24 24 24                               1 7                               1 1137 1137 1137                               1 7                             1 34 34                                                                           1 5 5 5                             1 3                       1 13 1   12 4   8 7 7   1                     1 3 2 2   1                               1 1                                   1 1 1 1                                   1 1   1 1         1                                             1 10 10 100 90     10                                 1 1 1         1 8 1179 20 20   1159 1159                         4 3     4   4 4 4 4 4 1   3   1155       1 7 8 8     8             1 12 17 2 2   15       1 12 12       1 2   19   19   19         1 1     1 10     89         89 5 5           5   5 31 31 1   30 4     4     84 7   84 84         1 9 2 2       1 10 10   9     9       1   1 6 5     5     5     5 4 4   1       1 6      
/*************************************************************
 * SugarPak - Domain Specific Language -  Syntactical Sugar  *
 *************************************************************/
 
(function () {
	var $D = Date, $P = $D.prototype, $N = Number.prototype;
 
	// private
	$P._orient = +1;
 
	// private
	$P._nth = null;
 
	// private
	$P._is = false;
 
	// private
	$P._same = false;
	
	// private
	$P._isSecond = false;
 
	// private
	$N._dateElement = "days";
 
	/** 
	 * Moves the date to the next instance of a date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()).
	 * Example
	<pre><code>
	Date.today().next().friday();
	Date.today().next().fri();
	Date.today().next().march();
	Date.today().next().mar();
	Date.today().next().week();
	</code></pre>
	 * 
	 * @return {Date}    date
	 */
	$P.next = function () {
		this._move = true;
		this._orient = +1;
		return this;
	};
 
	/** 
	 * Creates a new Date (Date.today()) and moves the date to the next instance of the date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()).
	 * Example
	<pre><code>
	Date.next().friday();
	Date.next().fri();
	Date.next().march();
	Date.next().mar();
	Date.next().week();
	</code></pre>
	 * 
	 * @return {Date}    date
	 */
	$D.next = function () {
		return $D.today().next();
	};
 
	/** 
	 * Moves the date to the previous instance of a date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()).
	 * Example
	<pre><code>
	Date.today().last().friday();
	Date.today().last().fri();
	Date.today().last().march();
	Date.today().last().mar();
	Date.today().last().week();
	</code></pre>
	 *  
	 * @return {Date}    date
	 */
	$P.last = $P.prev = $P.previous = function () {
		this._move = true;
		this._orient = -1;
		return this;
	};
 
	/** 
	 * Creates a new Date (Date.today()) and moves the date to the previous instance of the date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()).
	 * Example
	<pre><code>
	Date.last().friday();
	Date.last().fri();
	Date.previous().march();
	Date.prev().mar();
	Date.last().week();
	</code></pre>
	 *  
	 * @return {Date}    date
	 */
	$D.last = $D.prev = $D.previous = function () {
		return $D.today().last();
	};
 
	/** 
	 * Performs a equality check when followed by either a month name, day name or .weekday() function.
	 * Example
	<pre><code>
	Date.today().is().friday(); // true|false
	Date.today().is().fri();
	Date.today().is().march();
	Date.today().is().mar();
	</code></pre>
	 *  
	 * @return {Boolean}    true|false
	 */
	$P.is = function () {
		this._is = true;
		return this;
	};
 
	/** 
	 * Determines if two date objects occur on/in exactly the same instance of the subsequent date part function.
	 * The function .same() must be followed by a date part function (example: .day(), .month(), .year(), etc).
	 *
	 * An optional Date can be passed in the date part function. If now date is passed as a parameter, 'Now' is used. 
	 *
	 * The following example demonstrates how to determine if two dates fall on the exact same day.
	 *
	 * Example
	<pre><code>
	var d1 = Date.today(); // today at 00:00
	var d2 = new Date();   // exactly now.
 
	// Do they occur on the same day?
	d1.same().day(d2); // true
	
	// Do they occur on the same hour?
	d1.same().hour(d2); // false, unless d2 hour is '00' (midnight).
	
	// What if it's the same day, but one year apart?
	var nextYear = Date.today().add(1).year();
 
	d1.same().day(nextYear); // false, because the dates must occur on the exact same day. 
	</code></pre>
	 *
	 * Scenario: Determine if a given date occurs during some week period 2 months from now. 
	 *
	 * Example
	<pre><code>
	var future = Date.today().add(2).months();
	return someDate.same().week(future); // true|false;
	</code></pre>
	 *  
	 * @return {Boolean}    true|false
	 */
	$P.same = function () {
		this._same = true;
		this._isSecond = false;
		return this;
	};
 
	/** 
	 * Determines if the current date/time occurs during Today. Must be preceded by the .is() function.
	 * Example
	<pre><code>
	someDate.is().today();    // true|false
	new Date().is().today();  // true
	Date.today().is().today();// true
	Date.today().add(-1).day().is().today(); // false
	</code></pre>
	 *  
	 * @return {Boolean}    true|false
	 */
	$P.today = function () {
		return this.same().day();
	};
 
	/** 
	 * Determines if the current date is a weekday. This function must be preceded by the .is() function.
	 * Example
	<pre><code>
	Date.today().is().weekday(); // true|false
	</code></pre>
	 *  
	 * @return {Boolean}    true|false
	 */
	$P.weekday = function () {
		if (this._nth) {
			return df("Weekday").call(this);
		}
		if (this._move) {
			return this.addWeekdays(this._orient);
		}
		if (this._is) {
			this._is = false;
			return (!this.is().sat() && !this.is().sun());
		}
		return false;
	};
	/** 
	 * Determines if the current date is on the weekend. This function must be preceded by the .is() function.
	 * Example
	<pre><code>
	Date.today().is().weekend(); // true|false
	</code></pre>
	 *  
	 * @return {Boolean}    true|false
	 */
	$P.weekend = function () {
		if (this._is) {
			this._is = false;
			return (this.is().sat() || this.is().sun());
		}
		return false;
	};
 
	/** 
	 * Sets the Time of the current Date instance. A string "6:15 pm" or config object {hour:18, minute:15} are accepted.
	 * Example
	<pre><code>
	// Set time to 6:15pm with a String
	Date.today().at("6:15pm");
 
	// Set time to 6:15pm with a config object
	Date.today().at({hour:18, minute:15});
	</code></pre>
	 *  
	 * @return {Date}    date
	 */
	$P.at = function (time) {
		return (typeof time === "string") ? $D.parse(this.toString("d") + " " + time) : this.set(time);
	};
		
	/** 
	 * Creates a new Date() and adds this (Number) to the date based on the preceding date element function (eg. second|minute|hour|day|month|year).
	 * Example
	<pre><code>
	// Undeclared Numbers must be wrapped with parentheses. Requirment of JavaScript.
	(3).days().fromNow();
	(6).months().fromNow();
 
	// Declared Number variables do not require parentheses. 
	var n = 6;
	n.months().fromNow();
	</code></pre>
	 *  
	 * @return {Date}    A new Date instance
	 */
	$N.fromNow = $N.after = function (date) {
		var c = {};
		c[this._dateElement] = this;
		return ((!date) ? new Date() : date.clone()).add(c);
	};
 
	/** 
	 * Creates a new Date() and subtract this (Number) from the date based on the preceding date element function (eg. second|minute|hour|day|month|year).
	 * Example
	<pre><code>
	// Undeclared Numbers must be wrapped with parentheses. Requirment of JavaScript.
	(3).days().ago();
	(6).months().ago();
 
	// Declared Number variables do not require parentheses. 
	var n = 6;
	n.months().ago();
	</code></pre>
	 *  
	 * @return {Date}    A new Date instance
	 */
	$N.ago = $N.before = function (date) {
		var c = {},
		s = (this._dateElement[this._dateElement.length-1] !== "s") ? this._dateElement + "s" : this._dateElement;
		c[s] = this * -1;
		return ((!date) ? new Date() : date.clone()).add(c);
	};
 
	// Do NOT modify the following string tokens. These tokens are used to build dynamic functions.
	// All culture-specific strings can be found in the CultureInfo files.
	var dx = ("sunday monday tuesday wednesday thursday friday saturday").split(/\s/),
		mx = ("january february march april may june july august september october november december").split(/\s/),
		px = ("Millisecond Second Minute Hour Day Week Month Year Quarter Weekday").split(/\s/),
		pxf = ("Milliseconds Seconds Minutes Hours Date Week Month FullYear Quarter").split(/\s/),
		nth = ("final first second third fourth fifth").split(/\s/),
		de;
 
   /** 
	 * Returns an object literal of all the date parts.
	 * Example
	<pre><code>
	var o = new Date().toObject();
	
	// { year: 2008, month: 4, week: 20, day: 13, hour: 18, minute: 9, second: 32, millisecond: 812 }
	
	// The object properties can be referenced directly from the object.
	
	alert(o.day);  // alerts "13"
	alert(o.year); // alerts "2008"
	</code></pre>
	 *  
	 * @return {Date}    An object literal representing the original date object.
	 */
	$P.toObject = function () {
		var o = {};
		for (var i = 0; i < px.length; i++) {
			if (this["get" + pxf[i]]) {
				o[px[i].toLowerCase()] = this["get" + pxf[i]]();
			}
		}
		return o;
	};
   
   /** 
	 * Returns a date created from an object literal. Ignores the .week property if set in the config. 
	 * Example
	<pre><code>
	var o = new Date().toObject();
	
	return Date.fromObject(o); // will return the same date. 
 
	var o2 = {month: 1, day: 20, hour: 18}; // birthday party!
	Date.fromObject(o2);
	</code></pre>
	 *  
	 * @return {Date}    An object literal representing the original date object.
	 */
	$D.fromObject = function(config) {
		config.week = null;
		return Date.today().set(config);
	};
		
	// Create day name functions and abbreviated day name functions (eg. monday(), friday(), fri()).
	
	var df = function (n) {
		return function () {
			if (this._is) {
				this._is = false;
				return this.getDay() === n;
			}
			if (this._move) { this._move = null; }
			if (this._nth !== null) {
				// If the .second() function was called earlier, remove the _orient 
				// from the date, and then continue.
				// This is required because 'second' can be used in two different context.
				// 
				// Example
				//
				//   Date.today().add(1).second();
				//   Date.march().second().monday();
				// 
				// Things get crazy with the following...
				//   Date.march().add(1).second().second().monday(); // but it works!!
				//  
				if (this._isSecond) {
					this.addSeconds(this._orient * -1);
				}
				// make sure we reset _isSecond
				this._isSecond = false;
 
				var ntemp = this._nth;
				this._nth = null;
				var temp = this.clone().moveToLastDayOfMonth();
				this.moveToNthOccurrence(n, ntemp);
				if (this > temp) {
					throw new RangeError($D.getDayName(n) + " does not occur " + ntemp + " times in the month of " + $D.getMonthName(temp.getMonth()) + " " + temp.getFullYear() + ".");
				}
				return this;
			}
			return this.moveToDayOfWeek(n, this._orient);
		};
	};
	
	var sdf = function (n) {
		return function () {
			var t = $D.today(), shift = n - t.getDay();
			Iif (n === 0 && Date.CultureInfo.firstDayOfWeek === 1 && t.getDay() !== 0) {
				shift = shift + 7;
			}
			return t.addDays(shift);
		};
	};
	
 
	
	// Create month name functions and abbreviated month name functions (eg. january(), march(), mar()).
	var month_instance_functions = function (n) {
		return function () {
			if (this._is) {
				this._is = false;
				return this.getMonth() === n;
			}
			return this.moveToMonth(n, this._orient);
		};
	};
	
	var month_static_functions = function (n) {
		return function () {
			return $D.today().set({ month: n, day: 1 });
		};
	};
	
	var processTerms = function (names, staticFunc, instanceFunc) {
		for (var i = 0; i < names.length; i++) {
			// Create constant static Name variables.
			$D[names[i].toUpperCase()] = $D[names[i].toUpperCase().substring(0, 3)] = i;
			// Create Name functions.
			$D[names[i]] = $D[names[i].substring(0, 3)] = staticFunc(i);
			// Create Name instance functions.
			$P[names[i]] = $P[names[i].substring(0, 3)] = instanceFunc(i);
		}
 
	};
 
	processTerms(dx, sdf, df);
	processTerms(mx, month_static_functions, month_instance_functions);
	
	// Create date element functions and plural date element functions used with Date (eg. day(), days(), months()).
	var ef = function (j) {
		return function () {
			// if the .second() function was called earlier, the _orient 
			// has alread been added. Just return this and reset _isSecond.
			Iif (this._isSecond) {
				this._isSecond = false;
				return this;
			}
 
			if (this._same) {
				this._same = this._is = false;
				var o1 = this.toObject(),
					o2 = (arguments[0] || new Date()).toObject(),
					v = "",
					k = j.toLowerCase();
 
				// the substr trick with -1 doesn't work in IE8 or less
				k = (k[k.length-1] === "s") ? k.substring(0,k.length-1) : k;
					
				for (var m = (px.length - 1); m > -1; m--) {
					v = px[m].toLowerCase();
					if (o1[v] !== o2[v]) {
						return false;
					}
					if (k === v) {
						break;
					}
				}
				return true;
			}
			
			if (j.substring(j.length - 1) !== "s") {
				j += "s";
			}
			if (this._move) { this._move = null; }
			return this["add" + j](this._orient);
		};
	};
	
	
	var nf = function (n) {
		return function () {
			this._dateElement = n;
			return this;
		};
	};
   
	for (var k = 0; k < px.length; k++) {
		de = px[k].toLowerCase();
		if(de !== "weekday") {
			// Create date element functions and plural date element functions used with Date (eg. day(), days(), months()).
			$P[de] = $P[de + "s"] = ef(px[k]);
			
			// Create date element functions and plural date element functions used with Number (eg. day(), days(), months()).
			$N[de] = $N[de + "s"] = nf(de + "s");
		}
	}
	
	$P._ss = ef("Second");
	
	var nthfn = function (n) {
		return function (dayOfWeek) {
			Iif (this._same) {
				return this._ss(arguments[0]);
			}
			Iif (dayOfWeek || dayOfWeek === 0) {
				return this.moveToNthOccurrence(dayOfWeek, n);
			}
			this._nth = n;
 
			// if the operator is 'second' add the _orient, then deal with it later...
			if (n === 2 && (dayOfWeek === undefined || dayOfWeek === null)) {
				this._isSecond = true;
				return this.addSeconds(this._orient);
			}
			return this;
		};
	};
 
	for (var l = 0; l < nth.length; l++) {
		$P[nth[l]] = (l === 0) ? nthfn(-1) : nthfn(l);
	}
}());
 
================================================ FILE: reports/lcov-report/core/time_period.js.html ================================================ Code coverage report for core/time_period.js

Code coverage report for core/time_period.js

Statements: 33.33% (21 / 63)      Branches: 2.7% (1 / 37)      Functions: 36.36% (4 / 11)      Lines: 33.33% (21 / 63)      Ignored: none     

All files » core/ » time_period.js
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 1011   1 1 7         1 7         1 1 7 7 7 7       1 1                                           1                       1                                               1 1                   1   1   1    
(function () {
	"use strict";
	var attrs = ["years", "months", "days", "hours", "minutes", "seconds", "milliseconds"];
	var gFn = function (attr) {
		return function () {
			return this[attr];
		};
	};
	
	var sFn = function (attr) {
		return function (val) {
			this[attr] = val;
			return this;
		};
	};
	var addSetFuncs = function (context, attrs) {
		for (var i = 0; i < attrs.length ; i++) {
			var $a = attrs[i], $b = $a.slice(0, 1).toUpperCase() + $a.slice(1);
			context.prototype[$a] = 0;
			context.prototype["get" + $b] = gFn($a);
			context.prototype["set" + $b] = sFn($a);
		}
	};
 
	var setMonthsAndYears = function (orient, d1, d2, context) {
		function inc() {
			d1.addMonths(-orient);
			context.months++;
			if (context.months === 12) {
				context.years++;
				context.months = 0;
			}
		}
		if (orient === +1) {
			while (d1 > d2) {
				inc();
			}
		} else {
			while (d1 < d2) {
				inc();
			}
		}
		context.months--;
		context.months *= orient;
		context.years *= orient;
	};
 
	var adjustForDST = function(orient, startDate, endDate) {
		var hasDSTMismatch = (false === (startDate.isDaylightSavingTime() === endDate.isDaylightSavingTime()));
		if (hasDSTMismatch && orient === 1) {
			startDate.addHours(-1);
		} else if (hasDSTMismatch) {
			startDate.addHours(1);
		}
	};
	/**
	 * TimePeriod(startDate, endDate);
	 * TimePeriod(years, months, days, hours, minutes, seconds, milliseconds);
	 */
	var TimePeriod = function (years, months, days, hours, minutes, seconds, milliseconds) {
		if (arguments.length === 7) {
			this.set(years, months, days, hours, minutes, seconds, milliseconds);
		} else if (arguments.length === 2 && arguments[0] instanceof Date && arguments[1] instanceof Date) {
			var startDate = arguments[0].clone();
			var endDate = arguments[1].clone();
			var orient = (startDate > endDate) ? +1 : -1;
			this.dates = {
				start: arguments[0].clone(),
				end: arguments[1].clone()
			};
 
			setMonthsAndYears(orient, startDate, endDate, this);
			adjustForDST(orient, startDate, endDate);
			// // TODO - adjust for DST
			var diff = endDate - startDate;
			if (diff !== 0) {
				var ts = new TimeSpan(diff);
				this.set(this.years, this.months, ts.getDays(), ts.getHours(), ts.getMinutes(), ts.getSeconds(), ts.getMilliseconds());
			}
		}
		return this;
	};
	// create all the set functions.
	addSetFuncs(TimePeriod, attrs);
	TimePeriod.prototype.set = function (years, months, days, hours, minutes, seconds, milliseconds){
		this.setYears(years || this.getYears());
		this.setMonths(months || this.getMonths());
		this.setDays(days || this.getDays());
		this.setHours(hours || this.getHours());
		this.setMinutes(minutes || this.getMinutes());
		this.setSeconds(seconds || this.getSeconds());
		this.setMilliseconds(milliseconds || this.getMilliseconds());
	};
 
	Date.TimePeriod = TimePeriod;
 
	Eif (typeof window !== "undefined") {
		// keeping API compatible for v1.x 
		window.TimePeriod = TimePeriod;
	}
}());
================================================ FILE: reports/lcov-report/core/time_span.js.html ================================================ Code coverage report for core/time_span.js

Code coverage report for core/time_span.js

Statements: 20.65% (19 / 92)      Branches: 1.72% (1 / 58)      Functions: 16% (4 / 25)      Lines: 20.65% (19 / 92)      Ignored: none     

All files » core/ » time_span.js
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 1761   1 5         1 5         1 1 1 5 5 5 5               1                                                                                                                                                                                                                                                     1 1                         1       1   1   1    
(function () {
	"use strict";
	var gFn = function (attr) {
		return function () {
			return this[attr];
		};
	};
	
	var sFn = function (attr) {
		return function (val) {
			this[attr] = val;
			return this;
		};
	};
	var attrs = ["years", "months", "days", "hours", "minutes", "seconds", "milliseconds"];
	var addSetFuncs = function (context, attrs) {
		for (var i = 0; i < attrs.length ; i++) {
			var $a = attrs[i], $b = $a.slice(0, 1).toUpperCase() + $a.slice(1);
			context.prototype[$a] = 0;
			context.prototype["get" + $b] = gFn($a);
			context.prototype["set" + $b] = sFn($a);
		}
	};
	/**
	 * new TimeSpan(milliseconds);
	 * new TimeSpan(days, hours, minutes, seconds);
	 * new TimeSpan(days, hours, minutes, seconds, milliseconds);
	 */
	var TimeSpan = function (days, hours, minutes, seconds, milliseconds) {
		if (arguments.length === 1 && typeof days === "number") {
			var orient = (days < 0) ? -1 : +1;
			var millsLeft = Math.abs(days);
			this.setDays(Math.floor(millsLeft / 86400000) * orient);
			millsLeft = millsLeft % 86400000;
			this.setHours(Math.floor(millsLeft / 3600000) * orient);
			millsLeft = millsLeft % 3600000;
			this.setMinutes(Math.floor(millsLeft / 60000) * orient);
			millsLeft = millsLeft % 60000;
			this.setSeconds(Math.floor(millsLeft / 1000) * orient);
			millsLeft = millsLeft % 1000;
			this.setMilliseconds(millsLeft * orient);
		} else {
			this.set(days, hours, minutes, seconds, milliseconds);
		}
 
		this.getTotalMilliseconds = function () {
			return	(this.getDays() * 86400000) +
					(this.getHours() * 3600000) +
					(this.getMinutes() * 60000) +
					(this.getSeconds() * 1000);
		};
		
		this.compareTo = function (time) {
			var t1 = new Date(1970, 1, 1, this.getHours(), this.getMinutes(), this.getSeconds()), t2;
			if (time === null) {
				t2 = new Date(1970, 1, 1, 0, 0, 0);
			}
			else {
				t2 = new Date(1970, 1, 1, time.getHours(), time.getMinutes(), time.getSeconds());
			}
			return (t1 < t2) ? -1 : (t1 > t2) ? 1 : 0;
		};
 
		this.equals = function (time) {
			return (this.compareTo(time) === 0);
		};
 
		this.add = function (time) {
			return (time === null) ? this : this.addSeconds(time.getTotalMilliseconds() / 1000);
		};
 
		this.subtract = function (time) {
			return (time === null) ? this : this.addSeconds(-time.getTotalMilliseconds() / 1000);
		};
 
		this.addDays = function (n) {
			return new TimeSpan(this.getTotalMilliseconds() + (n * 86400000));
		};
 
		this.addHours = function (n) {
			return new TimeSpan(this.getTotalMilliseconds() + (n * 3600000));
		};
 
		this.addMinutes = function (n) {
			return new TimeSpan(this.getTotalMilliseconds() + (n * 60000));
		};
 
		this.addSeconds = function (n) {
			return new TimeSpan(this.getTotalMilliseconds() + (n * 1000));
		};
 
		this.addMilliseconds = function (n) {
			return new TimeSpan(this.getTotalMilliseconds() + n);
		};
 
		this.get12HourHour = function () {
			return (this.getHours() > 12) ? this.getHours() - 12 : (this.getHours() === 0) ? 12 : this.getHours();
		};
 
		this.getDesignator = function () {
			return (this.getHours() < 12) ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator;
		};
 
		this.toString = function (format) {
			this._toString = function () {
				if (this.getDays() !== null && this.getDays() > 0) {
					return this.getDays() + "." + this.getHours() + ":" + this.p(this.getMinutes()) + ":" + this.p(this.getSeconds());
				} else {
					return this.getHours() + ":" + this.p(this.getMinutes()) + ":" + this.p(this.getSeconds());
				}
			};
			
			this.p = function (s) {
				return (s.toString().length < 2) ? "0" + s : s;
			};
			
			var me = this;
			
			return format ? format.replace(/dd?|HH?|hh?|mm?|ss?|tt?/g,
			function (format) {
				switch (format) {
				case "d":
					return me.getDays();
				case "dd":
					return me.p(me.getDays());
				case "H":
					return me.getHours();
				case "HH":
					return me.p(me.getHours());
				case "h":
					return me.get12HourHour();
				case "hh":
					return me.p(me.get12HourHour());
				case "m":
					return me.getMinutes();
				case "mm":
					return me.p(me.getMinutes());
				case "s":
					return me.getSeconds();
				case "ss":
					return me.p(me.getSeconds());
				case "t":
					return ((me.getHours() < 12) ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator).substring(0, 1);
				case "tt":
					return (me.getHours() < 12) ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator;
				}
			}
			) : this._toString();
		};
		return this;
	};
	addSetFuncs(TimeSpan, attrs.slice(2));
	TimeSpan.prototype.set = function (days, hours, minutes, seconds, milliseconds){
		this.setDays(days || this.getDays());
		this.setHours(hours || this.getHours());
		this.setMinutes(minutes || this.getMinutes());
		this.setSeconds(seconds || this.getSeconds());
		this.setMilliseconds(milliseconds || this.getMilliseconds());
	};
 
 
	/**
	 * Gets the time of day for this date instances. 
	 * @return {TimeSpan} TimeSpan
	 */
	Date.prototype.getTimeOfDay = function () {
		return new TimeSpan(0, this.getHours(), this.getMinutes(), this.getSeconds(), this.getMilliseconds());
	};
 
	Date.TimeSpan = TimeSpan;
 
	Eif (typeof window !== "undefined" ) {
		// keeping API compatible for v1.x 
		window.TimeSpan = TimeSpan;
	}
}());
================================================ FILE: reports/lcov-report/index.html ================================================ Code coverage report for All files

Code coverage report for All files

Statements: 82.29% (1385 / 1683)      Branches: 70.61% (793 / 1123)      Functions: 83.48% (288 / 345)      Lines: 82.5% (1377 / 1669)      Ignored: none     

File Statements Branches Functions Lines
core/ 82.29% (1385 / 1683) 70.61% (793 / 1123) 83.48% (288 / 345) 82.5% (1377 / 1669)
================================================ FILE: reports/lcov-report/prettify.css ================================================ .pln{color:#000}@media screen{.str{color:#080}.kwd{color:#008}.com{color:#800}.typ{color:#606}.lit{color:#066}.pun,.opn,.clo{color:#660}.tag{color:#008}.atn{color:#606}.atv{color:#080}.dec,.var{color:#606}.fun{color:red}}@media print,projection{.str{color:#060}.kwd{color:#006;font-weight:bold}.com{color:#600;font-style:italic}.typ{color:#404;font-weight:bold}.lit{color:#044}.pun,.opn,.clo{color:#440}.tag{color:#006;font-weight:bold}.atn{color:#404}.atv{color:#060}}pre.prettyprint{padding:2px;border:1px solid #888}ol.linenums{margin-top:0;margin-bottom:0}li.L0,li.L1,li.L2,li.L3,li.L5,li.L6,li.L7,li.L8{list-style-type:none}li.L1,li.L3,li.L5,li.L7,li.L9{background:#eee} ================================================ FILE: reports/lcov-report/prettify.js ================================================ window.PR_SHOULD_USE_CONTINUATION=true;(function(){var h=["break,continue,do,else,for,if,return,while"];var u=[h,"auto,case,char,const,default,double,enum,extern,float,goto,int,long,register,short,signed,sizeof,static,struct,switch,typedef,union,unsigned,void,volatile"];var p=[u,"catch,class,delete,false,import,new,operator,private,protected,public,this,throw,true,try,typeof"];var l=[p,"alignof,align_union,asm,axiom,bool,concept,concept_map,const_cast,constexpr,decltype,dynamic_cast,explicit,export,friend,inline,late_check,mutable,namespace,nullptr,reinterpret_cast,static_assert,static_cast,template,typeid,typename,using,virtual,where"];var x=[p,"abstract,boolean,byte,extends,final,finally,implements,import,instanceof,null,native,package,strictfp,super,synchronized,throws,transient"];var R=[x,"as,base,by,checked,decimal,delegate,descending,dynamic,event,fixed,foreach,from,group,implicit,in,interface,internal,into,is,lock,object,out,override,orderby,params,partial,readonly,ref,sbyte,sealed,stackalloc,string,select,uint,ulong,unchecked,unsafe,ushort,var"];var r="all,and,by,catch,class,else,extends,false,finally,for,if,in,is,isnt,loop,new,no,not,null,of,off,on,or,return,super,then,true,try,unless,until,when,while,yes";var w=[p,"debugger,eval,export,function,get,null,set,undefined,var,with,Infinity,NaN"];var s="caller,delete,die,do,dump,elsif,eval,exit,foreach,for,goto,if,import,last,local,my,next,no,our,print,package,redo,require,sub,undef,unless,until,use,wantarray,while,BEGIN,END";var I=[h,"and,as,assert,class,def,del,elif,except,exec,finally,from,global,import,in,is,lambda,nonlocal,not,or,pass,print,raise,try,with,yield,False,True,None"];var f=[h,"alias,and,begin,case,class,def,defined,elsif,end,ensure,false,in,module,next,nil,not,or,redo,rescue,retry,self,super,then,true,undef,unless,until,when,yield,BEGIN,END"];var H=[h,"case,done,elif,esac,eval,fi,function,in,local,set,then,until"];var A=[l,R,w,s+I,f,H];var e=/^(DIR|FILE|vector|(de|priority_)?queue|list|stack|(const_)?iterator|(multi)?(set|map)|bitset|u?(int|float)\d*)/;var C="str";var z="kwd";var j="com";var O="typ";var G="lit";var L="pun";var F="pln";var m="tag";var E="dec";var J="src";var P="atn";var n="atv";var N="nocode";var M="(?:^^\\.?|[+-]|\\!|\\!=|\\!==|\\#|\\%|\\%=|&|&&|&&=|&=|\\(|\\*|\\*=|\\+=|\\,|\\-=|\\->|\\/|\\/=|:|::|\\;|<|<<|<<=|<=|=|==|===|>|>=|>>|>>=|>>>|>>>=|\\?|\\@|\\[|\\^|\\^=|\\^\\^|\\^\\^=|\\{|\\||\\|=|\\|\\||\\|\\|=|\\~|break|case|continue|delete|do|else|finally|instanceof|return|throw|try|typeof)\\s*";function k(Z){var ad=0;var S=false;var ac=false;for(var V=0,U=Z.length;V122)){if(!(al<65||ag>90)){af.push([Math.max(65,ag)|32,Math.min(al,90)|32])}if(!(al<97||ag>122)){af.push([Math.max(97,ag)&~32,Math.min(al,122)&~32])}}}}af.sort(function(av,au){return(av[0]-au[0])||(au[1]-av[1])});var ai=[];var ap=[NaN,NaN];for(var ar=0;arat[0]){if(at[1]+1>at[0]){an.push("-")}an.push(T(at[1]))}}an.push("]");return an.join("")}function W(al){var aj=al.source.match(new RegExp("(?:\\[(?:[^\\x5C\\x5D]|\\\\[\\s\\S])*\\]|\\\\u[A-Fa-f0-9]{4}|\\\\x[A-Fa-f0-9]{2}|\\\\[0-9]+|\\\\[^ux0-9]|\\(\\?[:!=]|[\\(\\)\\^]|[^\\x5B\\x5C\\(\\)\\^]+)","g"));var ah=aj.length;var an=[];for(var ak=0,am=0;ak=2&&ai==="["){aj[ak]=X(ag)}else{if(ai!=="\\"){aj[ak]=ag.replace(/[a-zA-Z]/g,function(ao){var ap=ao.charCodeAt(0);return"["+String.fromCharCode(ap&~32,ap|32)+"]"})}}}}return aj.join("")}var aa=[];for(var V=0,U=Z.length;V=0;){S[ac.charAt(ae)]=Y}}var af=Y[1];var aa=""+af;if(!ag.hasOwnProperty(aa)){ah.push(af);ag[aa]=null}}ah.push(/[\0-\uffff]/);V=k(ah)})();var X=T.length;var W=function(ah){var Z=ah.sourceCode,Y=ah.basePos;var ad=[Y,F];var af=0;var an=Z.match(V)||[];var aj={};for(var ae=0,aq=an.length;ae=5&&"lang-"===ap.substring(0,5);if(am&&!(ai&&typeof ai[1]==="string")){am=false;ap=J}if(!am){aj[ag]=ap}}var ab=af;af+=ag.length;if(!am){ad.push(Y+ab,ap)}else{var al=ai[1];var ak=ag.indexOf(al);var ac=ak+al.length;if(ai[2]){ac=ag.length-ai[2].length;ak=ac-al.length}var ar=ap.substring(5);B(Y+ab,ag.substring(0,ak),W,ad);B(Y+ab+ak,al,q(ar,al),ad);B(Y+ab+ac,ag.substring(ac),W,ad)}}ah.decorations=ad};return W}function i(T){var W=[],S=[];if(T.tripleQuotedStrings){W.push([C,/^(?:\'\'\'(?:[^\'\\]|\\[\s\S]|\'{1,2}(?=[^\']))*(?:\'\'\'|$)|\"\"\"(?:[^\"\\]|\\[\s\S]|\"{1,2}(?=[^\"]))*(?:\"\"\"|$)|\'(?:[^\\\']|\\[\s\S])*(?:\'|$)|\"(?:[^\\\"]|\\[\s\S])*(?:\"|$))/,null,"'\""])}else{if(T.multiLineStrings){W.push([C,/^(?:\'(?:[^\\\']|\\[\s\S])*(?:\'|$)|\"(?:[^\\\"]|\\[\s\S])*(?:\"|$)|\`(?:[^\\\`]|\\[\s\S])*(?:\`|$))/,null,"'\"`"])}else{W.push([C,/^(?:\'(?:[^\\\'\r\n]|\\.)*(?:\'|$)|\"(?:[^\\\"\r\n]|\\.)*(?:\"|$))/,null,"\"'"])}}if(T.verbatimStrings){S.push([C,/^@\"(?:[^\"]|\"\")*(?:\"|$)/,null])}var Y=T.hashComments;if(Y){if(T.cStyleComments){if(Y>1){W.push([j,/^#(?:##(?:[^#]|#(?!##))*(?:###|$)|.*)/,null,"#"])}else{W.push([j,/^#(?:(?:define|elif|else|endif|error|ifdef|include|ifndef|line|pragma|undef|warning)\b|[^\r\n]*)/,null,"#"])}S.push([C,/^<(?:(?:(?:\.\.\/)*|\/?)(?:[\w-]+(?:\/[\w-]+)+)?[\w-]+\.h|[a-z]\w*)>/,null])}else{W.push([j,/^#[^\r\n]*/,null,"#"])}}if(T.cStyleComments){S.push([j,/^\/\/[^\r\n]*/,null]);S.push([j,/^\/\*[\s\S]*?(?:\*\/|$)/,null])}if(T.regexLiterals){var X=("/(?=[^/*])(?:[^/\\x5B\\x5C]|\\x5C[\\s\\S]|\\x5B(?:[^\\x5C\\x5D]|\\x5C[\\s\\S])*(?:\\x5D|$))+/");S.push(["lang-regex",new RegExp("^"+M+"("+X+")")])}var V=T.types;if(V){S.push([O,V])}var U=(""+T.keywords).replace(/^ | $/g,"");if(U.length){S.push([z,new RegExp("^(?:"+U.replace(/[\s,]+/g,"|")+")\\b"),null])}W.push([F,/^\s+/,null," \r\n\t\xA0"]);S.push([G,/^@[a-z_$][a-z_$@0-9]*/i,null],[O,/^(?:[@_]?[A-Z]+[a-z][A-Za-z_$@0-9]*|\w+_t\b)/,null],[F,/^[a-z_$][a-z_$@0-9]*/i,null],[G,new RegExp("^(?:0x[a-f0-9]+|(?:\\d(?:_\\d+)*\\d*(?:\\.\\d*)?|\\.\\d\\+)(?:e[+\\-]?\\d+)?)[a-z]*","i"),null,"0123456789"],[F,/^\\[\s\S]?/,null],[L,/^.[^\s\w\.$@\'\"\`\/\#\\]*/,null]);return g(W,S)}var K=i({keywords:A,hashComments:true,cStyleComments:true,multiLineStrings:true,regexLiterals:true});function Q(V,ag){var U=/(?:^|\s)nocode(?:\s|$)/;var ab=/\r\n?|\n/;var ac=V.ownerDocument;var S;if(V.currentStyle){S=V.currentStyle.whiteSpace}else{if(window.getComputedStyle){S=ac.defaultView.getComputedStyle(V,null).getPropertyValue("white-space")}}var Z=S&&"pre"===S.substring(0,3);var af=ac.createElement("LI");while(V.firstChild){af.appendChild(V.firstChild)}var W=[af];function ae(al){switch(al.nodeType){case 1:if(U.test(al.className)){break}if("BR"===al.nodeName){ad(al);if(al.parentNode){al.parentNode.removeChild(al)}}else{for(var an=al.firstChild;an;an=an.nextSibling){ae(an)}}break;case 3:case 4:if(Z){var am=al.nodeValue;var aj=am.match(ab);if(aj){var ai=am.substring(0,aj.index);al.nodeValue=ai;var ah=am.substring(aj.index+aj[0].length);if(ah){var ak=al.parentNode;ak.insertBefore(ac.createTextNode(ah),al.nextSibling)}ad(al);if(!ai){al.parentNode.removeChild(al)}}}break}}function ad(ak){while(!ak.nextSibling){ak=ak.parentNode;if(!ak){return}}function ai(al,ar){var aq=ar?al.cloneNode(false):al;var ao=al.parentNode;if(ao){var ap=ai(ao,1);var an=al.nextSibling;ap.appendChild(aq);for(var am=an;am;am=an){an=am.nextSibling;ap.appendChild(am)}}return aq}var ah=ai(ak.nextSibling,0);for(var aj;(aj=ah.parentNode)&&aj.nodeType===1;){ah=aj}W.push(ah)}for(var Y=0;Y=S){ah+=2}if(V>=ap){Z+=2}}}var t={};function c(U,V){for(var S=V.length;--S>=0;){var T=V[S];if(!t.hasOwnProperty(T)){t[T]=U}else{if(window.console){console.warn("cannot override language handler %s",T)}}}}function q(T,S){if(!(T&&t.hasOwnProperty(T))){T=/^\s*]*(?:>|$)/],[j,/^<\!--[\s\S]*?(?:-\->|$)/],["lang-",/^<\?([\s\S]+?)(?:\?>|$)/],["lang-",/^<%([\s\S]+?)(?:%>|$)/],[L,/^(?:<[%?]|[%?]>)/],["lang-",/^]*>([\s\S]+?)<\/xmp\b[^>]*>/i],["lang-js",/^]*>([\s\S]*?)(<\/script\b[^>]*>)/i],["lang-css",/^]*>([\s\S]*?)(<\/style\b[^>]*>)/i],["lang-in.tag",/^(<\/?[a-z][^<>]*>)/i]]),["default-markup","htm","html","mxml","xhtml","xml","xsl"]);c(g([[F,/^[\s]+/,null," \t\r\n"],[n,/^(?:\"[^\"]*\"?|\'[^\']*\'?)/,null,"\"'"]],[[m,/^^<\/?[a-z](?:[\w.:-]*\w)?|\/?>$/i],[P,/^(?!style[\s=]|on)[a-z](?:[\w:-]*\w)?/i],["lang-uq.val",/^=\s*([^>\'\"\s]*(?:[^>\'\"\s\/]|\/(?=\s)))/],[L,/^[=<>\/]+/],["lang-js",/^on\w+\s*=\s*\"([^\"]+)\"/i],["lang-js",/^on\w+\s*=\s*\'([^\']+)\'/i],["lang-js",/^on\w+\s*=\s*([^\"\'>\s]+)/i],["lang-css",/^style\s*=\s*\"([^\"]+)\"/i],["lang-css",/^style\s*=\s*\'([^\']+)\'/i],["lang-css",/^style\s*=\s*([^\"\'>\s]+)/i]]),["in.tag"]);c(g([],[[n,/^[\s\S]+/]]),["uq.val"]);c(i({keywords:l,hashComments:true,cStyleComments:true,types:e}),["c","cc","cpp","cxx","cyc","m"]);c(i({keywords:"null,true,false"}),["json"]);c(i({keywords:R,hashComments:true,cStyleComments:true,verbatimStrings:true,types:e}),["cs"]);c(i({keywords:x,cStyleComments:true}),["java"]);c(i({keywords:H,hashComments:true,multiLineStrings:true}),["bsh","csh","sh"]);c(i({keywords:I,hashComments:true,multiLineStrings:true,tripleQuotedStrings:true}),["cv","py"]);c(i({keywords:s,hashComments:true,multiLineStrings:true,regexLiterals:true}),["perl","pl","pm"]);c(i({keywords:f,hashComments:true,multiLineStrings:true,regexLiterals:true}),["rb"]);c(i({keywords:w,cStyleComments:true,regexLiterals:true}),["js"]);c(i({keywords:r,hashComments:3,cStyleComments:true,multilineStrings:true,tripleQuotedStrings:true,regexLiterals:true}),["coffee"]);c(g([],[[C,/^[\s\S]+/]]),["regex"]);function d(V){var U=V.langExtension;try{var S=a(V.sourceNode);var T=S.sourceCode;V.sourceCode=T;V.spans=S.spans;V.basePos=0;q(U,T)(V);D(V)}catch(W){if("console" in window){console.log(W&&W.stack?W.stack:W)}}}function y(W,V,U){var S=document.createElement("PRE");S.innerHTML=W;if(U){Q(S,U)}var T={langExtension:V,numberLines:U,sourceNode:S};d(T);return S.innerHTML}function b(ad){function Y(af){return document.getElementsByTagName(af)}var ac=[Y("pre"),Y("code"),Y("xmp")];var T=[];for(var aa=0;aa=0){var ah=ai.match(ab);var am;if(!ah&&(am=o(aj))&&"CODE"===am.tagName){ah=am.className.match(ab)}if(ah){ah=ah[1]}var al=false;for(var ak=aj.parentNode;ak;ak=ak.parentNode){if((ak.tagName==="pre"||ak.tagName==="code"||ak.tagName==="xmp")&&ak.className&&ak.className.indexOf("prettyprint")>=0){al=true;break}}if(!al){var af=aj.className.match(/\blinenums\b(?::(\d+))?/);af=af?af[1]&&af[1].length?+af[1]:true:false;if(af){Q(aj,af)}S={langExtension:ah,sourceNode:aj,numberLines:af};d(S)}}}if(X]*(?:>|$)/],[PR.PR_COMMENT,/^<\!--[\s\S]*?(?:-\->|$)/],[PR.PR_PUNCTUATION,/^(?:<[%?]|[%?]>)/],["lang-",/^<\?([\s\S]+?)(?:\?>|$)/],["lang-",/^<%([\s\S]+?)(?:%>|$)/],["lang-",/^]*>([\s\S]+?)<\/xmp\b[^>]*>/i],["lang-handlebars",/^]*type\s*=\s*['"]?text\/x-handlebars-template['"]?\b[^>]*>([\s\S]*?)(<\/script\b[^>]*>)/i],["lang-js",/^]*>([\s\S]*?)(<\/script\b[^>]*>)/i],["lang-css",/^]*>([\s\S]*?)(<\/style\b[^>]*>)/i],["lang-in.tag",/^(<\/?[a-z][^<>]*>)/i],[PR.PR_DECLARATION,/^{{[#^>/]?\s*[\w.][^}]*}}/],[PR.PR_DECLARATION,/^{{&?\s*[\w.][^}]*}}/],[PR.PR_DECLARATION,/^{{{>?\s*[\w.][^}]*}}}/],[PR.PR_COMMENT,/^{{![^}]*}}/]]),["handlebars","hbs"]);PR.registerLangHandler(PR.createSimpleLexer([[PR.PR_PLAIN,/^[ \t\r\n\f]+/,null," \t\r\n\f"]],[[PR.PR_STRING,/^\"(?:[^\n\r\f\\\"]|\\(?:\r\n?|\n|\f)|\\[\s\S])*\"/,null],[PR.PR_STRING,/^\'(?:[^\n\r\f\\\']|\\(?:\r\n?|\n|\f)|\\[\s\S])*\'/,null],["lang-css-str",/^url\(([^\)\"\']*)\)/i],[PR.PR_KEYWORD,/^(?:url|rgb|\!important|@import|@page|@media|@charset|inherit)(?=[^\-\w]|$)/i,null],["lang-css-kw",/^(-?(?:[_a-z]|(?:\\[0-9a-f]+ ?))(?:[_a-z0-9\-]|\\(?:\\[0-9a-f]+ ?))*)\s*:/i],[PR.PR_COMMENT,/^\/\*[^*]*\*+(?:[^\/*][^*]*\*+)*\//],[PR.PR_COMMENT,/^(?:)/],[PR.PR_LITERAL,/^(?:\d+|\d*\.\d+)(?:%|[a-z]+)?/i],[PR.PR_LITERAL,/^#(?:[0-9a-f]{3}){1,2}/i],[PR.PR_PLAIN,/^-?(?:[_a-z]|(?:\\[\da-f]+ ?))(?:[_a-z\d\-]|\\(?:\\[\da-f]+ ?))*/i],[PR.PR_PUNCTUATION,/^[^\s\w\'\"]+/]]),["css"]);PR.registerLangHandler(PR.createSimpleLexer([],[[PR.PR_KEYWORD,/^-?(?:[_a-z]|(?:\\[\da-f]+ ?))(?:[_a-z\d\-]|\\(?:\\[\da-f]+ ?))*/i]]),["css-kw"]);PR.registerLangHandler(PR.createSimpleLexer([],[[PR.PR_STRING,/^[^\)\"\']+/]]),["css-str"]); ================================================ FILE: reports/lcov.info ================================================ TN: SF:src/core/i18n.js FN:1,(anonymous_1) FN:6,(anonymous_2) FN:18,(anonymous_3) FN:27,(anonymous_4) FN:36,(anonymous_5) FN:45,(anonymous_6) FN:78,(anonymous_7) FN:89,(anonymous_8) FN:97,(anonymous_9) FN:111,(anonymous_10) FN:120,(anonymous_11) FN:123,(anonymous_12) FN:130,(anonymous_13) FN:135,(anonymous_14) FN:136,(anonymous_15) FN:146,(anonymous_16) FN:155,(anonymous_17) FN:178,(anonymous_18) FN:222,(anonymous_19) FN:237,(anonymous_20) FN:240,(anonymous_21) FN:243,(anonymous_22) FN:246,(anonymous_23) FN:249,(anonymous_24) FN:252,(anonymous_25) FN:255,(anonymous_26) FN:269,(anonymous_27) FN:321,(anonymous_28) FN:352,(anonymous_29) FN:355,(anonymous_30) FN:358,(anonymous_31) FN:381,(anonymous_32) FN:408,(anonymous_33) FN:411,(anonymous_34) FNF:34 FNH:32 FNDA:1,(anonymous_1) FNDA:28001,(anonymous_2) FNDA:480,(anonymous_3) FNDA:320,(anonymous_4) FNDA:960,(anonymous_5) FNDA:1939,(anonymous_6) FNDA:7360,(anonymous_7) FNDA:160,(anonymous_8) FNDA:1601,(anonymous_9) FNDA:1,(anonymous_10) FNDA:0,(anonymous_11) FNDA:1,(anonymous_12) FNDA:1,(anonymous_13) FNDA:1,(anonymous_14) FNDA:1,(anonymous_15) FNDA:160,(anonymous_16) FNDA:160,(anonymous_17) FNDA:160,(anonymous_18) FNDA:160,(anonymous_19) FNDA:160,(anonymous_20) FNDA:160,(anonymous_21) FNDA:160,(anonymous_22) FNDA:160,(anonymous_23) FNDA:160,(anonymous_24) FNDA:160,(anonymous_25) FNDA:160,(anonymous_26) FNDA:160,(anonymous_27) FNDA:160,(anonymous_28) FNDA:321,(anonymous_29) FNDA:637,(anonymous_30) FNDA:159,(anonymous_31) FNDA:1,(anonymous_32) FNDA:0,(anonymous_33) FNDA:2,(anonymous_34) DA:1,1 DA:2,1 DA:3,1 DA:4,1 DA:5,1 DA:7,28001 DA:8,28001 DA:9,26062 DA:11,1939 DA:13,28001 DA:14,7360 DA:16,28001 DA:19,480 DA:20,480 DA:21,10240 DA:22,10240 DA:25,480 DA:28,320 DA:29,320 DA:30,9120 DA:31,9120 DA:34,320 DA:37,960 DA:38,960 DA:39,8320 DA:40,8320 DA:43,960 DA:46,1939 DA:47,1939 DA:49,3 DA:50,3 DA:52,3 DA:53,3 DA:55,3 DA:56,3 DA:58,3 DA:59,3 DA:61,160 DA:62,160 DA:64,1767 DA:65,1767 DA:66,1767 DA:67,1767 DA:69,214 DA:70,214 DA:71,214 DA:74,1767 DA:76,1939 DA:79,7360 DA:80,7360 DA:81,6123 DA:83,1237 DA:85,7360 DA:89,1 DA:90,160 DA:91,1600 DA:92,1600 DA:97,1 DA:98,1601 DA:99,1601 DA:100,1601 DA:101,1280 DA:102,960 DA:104,320 DA:107,321 DA:111,1 DA:113,1 DA:114,1 DA:115,1 DA:116,1 DA:118,1 DA:119,1 DA:123,1 DA:124,1 DA:125,1 DA:126,1 DA:130,1 DA:131,1 DA:134,1 DA:136,1 DA:137,1 DA:138,1 DA:145,1 DA:147,160 DA:148,160 DA:149,1600 DA:150,1600 DA:153,160 DA:156,160 DA:176,160 DA:179,160 DA:220,160 DA:223,160 DA:224,160 DA:225,160 DA:226,6240 DA:227,6240 DA:230,160 DA:231,2880 DA:232,2880 DA:235,160 DA:238,160 DA:241,160 DA:244,160 DA:247,160 DA:250,160 DA:253,160 DA:256,160 DA:270,160 DA:321,1 DA:322,160 DA:333,160 DA:346,160 DA:347,160 DA:348,160 DA:351,1 DA:353,321 DA:356,637 DA:359,159 DA:360,159 DA:361,157 DA:362,157 DA:363,157 DA:364,157 DA:366,2 DA:367,2 DA:369,0 DA:370,0 DA:371,0 DA:372,0 DA:373,0 DA:376,0 DA:378,2 DA:380,1 DA:381,1 DA:382,1 DA:383,1 DA:384,1 DA:385,1 DA:386,1 DA:387,1 DA:388,1 DA:390,1 DA:391,1 DA:395,1 DA:396,1 DA:400,158 DA:401,158 DA:402,158 DA:404,158 DA:405,156 DA:409,0 DA:412,2 DA:415,1 LF:154 LH:147 BRDA:3,1,0,0 BRDA:3,1,1,1 BRDA:8,2,0,26062 BRDA:8,2,1,1939 BRDA:8,3,0,28001 BRDA:8,3,1,27824 BRDA:8,3,2,27475 BRDA:13,4,0,7360 BRDA:13,4,1,20641 BRDA:21,5,0,10240 BRDA:21,5,1,0 BRDA:30,6,0,9120 BRDA:30,6,1,0 BRDA:39,7,0,8320 BRDA:39,7,1,0 BRDA:47,8,0,3 BRDA:47,8,1,3 BRDA:47,8,2,3 BRDA:47,8,3,3 BRDA:47,8,4,160 BRDA:47,8,5,1767 BRDA:67,9,0,214 BRDA:67,9,1,1553 BRDA:67,10,0,1767 BRDA:67,10,1,214 BRDA:70,11,0,214 BRDA:70,11,1,0 BRDA:70,12,0,214 BRDA:70,12,1,36 BRDA:80,13,0,6123 BRDA:80,13,1,1237 BRDA:80,14,0,7360 BRDA:80,14,1,7314 BRDA:80,14,2,7222 BRDA:91,15,0,1600 BRDA:91,15,1,0 BRDA:98,16,0,0 BRDA:98,16,1,1601 BRDA:100,17,0,1280 BRDA:100,17,1,321 BRDA:101,18,0,960 BRDA:101,18,1,320 BRDA:114,19,0,1 BRDA:114,19,1,0 BRDA:124,20,0,1 BRDA:124,20,1,0 BRDA:124,21,0,1 BRDA:124,21,1,1 BRDA:124,21,2,0 BRDA:124,21,3,0 BRDA:137,22,0,1 BRDA:137,22,1,0 BRDA:149,23,0,1600 BRDA:149,23,1,0 BRDA:226,24,0,6240 BRDA:226,24,1,0 BRDA:231,25,0,2880 BRDA:231,25,1,0 BRDA:356,26,0,637 BRDA:356,26,1,9 BRDA:360,27,0,157 BRDA:360,27,1,2 BRDA:360,28,0,159 BRDA:360,28,1,158 BRDA:360,28,2,158 BRDA:360,28,3,157 BRDA:362,29,0,157 BRDA:362,29,1,0 BRDA:366,30,0,2 BRDA:366,30,1,0 BRDA:366,31,0,2 BRDA:366,31,1,1 BRDA:367,32,0,0 BRDA:367,32,1,2 BRDA:367,33,0,2 BRDA:367,33,1,0 BRDA:378,34,0,1 BRDA:378,34,1,1 BRDA:378,35,0,2 BRDA:378,35,1,2 BRDA:383,36,0,1 BRDA:383,36,1,0 BRDA:387,37,0,1 BRDA:387,37,1,0 BRDA:390,38,0,1 BRDA:390,38,1,0 BRDA:401,39,0,158 BRDA:401,39,1,0 BRDA:404,40,0,156 BRDA:404,40,1,2 BRDA:404,41,0,158 BRDA:404,41,1,157 BRF:92 BRH:69 end_of_record TN: SF:src/core/core.js FN:1,(anonymous_1) FN:4,(anonymous_2) FN:16,(anonymous_3) FN:17,(anonymous_4) FN:22,(anonymous_5) FN:35,now FN:42,(anonymous_7) FN:51,(anonymous_8) FN:76,(anonymous_9) FN:84,(anonymous_10) FN:94,(anonymous_11) FN:110,(anonymous_12) FN:119,(anonymous_13) FN:128,(anonymous_14) FN:143,(anonymous_15) FN:158,(anonymous_16) FN:167,(anonymous_17) FN:177,(anonymous_18) FN:185,(anonymous_19) FN:189,(anonymous_20) FN:201,(anonymous_21) FN:223,(anonymous_22) FN:229,(anonymous_23) FN:237,(anonymous_24) FN:257,(anonymous_25) FN:266,(anonymous_26) FN:275,(anonymous_27) FN:284,(anonymous_28) FN:293,(anonymous_29) FN:303,(anonymous_30) FN:312,(anonymous_31) FN:321,(anonymous_32) FN:334,(anonymous_33) FN:338,(anonymous_34) FNF:34 FNH:31 FNDA:1,(anonymous_1) FNDA:15,(anonymous_2) FNDA:0,(anonymous_3) FNDA:0,(anonymous_4) FNDA:5,(anonymous_5) FNDA:1,now FNDA:4,(anonymous_7) FNDA:3,(anonymous_8) FNDA:2094,(anonymous_9) FNDA:4,(anonymous_10) FNDA:408,(anonymous_11) FNDA:398,(anonymous_12) FNDA:2,(anonymous_13) FNDA:26,(anonymous_14) FNDA:24,(anonymous_15) FNDA:2,(anonymous_16) FNDA:591,(anonymous_17) FNDA:588,(anonymous_18) FNDA:0,(anonymous_19) FNDA:6,(anonymous_20) FNDA:7,(anonymous_21) FNDA:15,(anonymous_22) FNDA:2,(anonymous_23) FNDA:369,(anonymous_24) FNDA:1,(anonymous_25) FNDA:3,(anonymous_26) FNDA:5,(anonymous_27) FNDA:30,(anonymous_28) FNDA:119,(anonymous_29) FNDA:1,(anonymous_30) FNDA:139,(anonymous_31) FNDA:71,(anonymous_32) FNDA:3,(anonymous_33) FNDA:2,(anonymous_34) DA:1,1 DA:2,1 DA:5,15 DA:6,15 DA:8,15 DA:11,1 DA:12,1 DA:15,0 DA:20,1 DA:22,1 DA:34,5 DA:35,1 DA:36,1 DA:38,4 DA:39,2 DA:42,5 DA:43,4 DA:44,3 DA:46,1 DA:50,5 DA:51,1 DA:52,3 DA:64,5 DA:65,2 DA:69,1 DA:76,1 DA:77,2094 DA:84,1 DA:85,4 DA:94,1 DA:95,408 DA:96,5 DA:97,403 DA:98,401 DA:100,2 DA:110,1 DA:111,398 DA:119,1 DA:120,2 DA:128,1 DA:129,26 DA:130,26 DA:131,105 DA:132,24 DA:135,2 DA:143,1 DA:144,24 DA:145,24 DA:146,163 DA:147,23 DA:150,1 DA:158,1 DA:159,2 DA:167,1 DA:168,591 DA:177,1 DA:178,588 DA:179,12 DA:180,12 DA:182,588 DA:185,1 DA:186,0 DA:189,1 DA:190,6 DA:191,6 DA:192,166 DA:193,166 DA:194,5 DA:198,1 DA:201,1 DA:202,7 DA:203,7 DA:204,7 DA:205,399 DA:206,8 DA:209,7 DA:210,1 DA:212,6 DA:213,5 DA:215,1 DA:216,2 DA:217,1 DA:223,1 DA:224,15 DA:225,15 DA:226,15 DA:229,1 DA:230,2 DA:231,2 DA:232,2 DA:233,2 DA:237,1 DA:238,369 DA:239,369 DA:240,1 DA:241,368 DA:242,1 DA:243,367 DA:247,28 DA:249,339 DA:257,1 DA:258,1 DA:266,1 DA:267,3 DA:275,1 DA:276,5 DA:284,1 DA:285,30 DA:293,1 DA:294,119 DA:295,119 DA:303,1 DA:304,1 DA:312,1 DA:313,139 DA:321,1 DA:332,71 DA:334,1 DA:335,3 DA:336,3 DA:338,1 DA:340,2 LF:122 LH:120 BRDA:5,1,0,15 BRDA:5,1,1,0 BRDA:11,2,0,1 BRDA:11,2,1,0 BRDA:11,3,0,1 BRDA:11,3,1,1 BRDA:11,3,2,1 BRDA:20,4,0,1 BRDA:20,4,1,0 BRDA:34,5,0,1 BRDA:34,5,1,4 BRDA:38,6,0,2 BRDA:38,6,1,2 BRDA:43,7,0,3 BRDA:43,7,1,1 BRDA:50,8,0,1 BRDA:50,8,1,4 BRDA:64,9,0,2 BRDA:64,9,1,3 BRDA:95,10,0,5 BRDA:95,10,1,403 BRDA:95,11,0,408 BRDA:95,11,1,405 BRDA:97,12,0,401 BRDA:97,12,1,2 BRDA:97,13,0,403 BRDA:97,13,1,403 BRDA:98,14,0,4 BRDA:98,14,1,397 BRDA:98,15,0,4 BRDA:98,15,1,393 BRDA:131,16,0,24 BRDA:131,16,1,81 BRDA:131,17,0,105 BRDA:131,17,1,97 BRDA:131,17,2,88 BRDA:146,18,0,23 BRDA:146,18,1,140 BRDA:146,19,0,163 BRDA:146,19,1,151 BRDA:168,20,0,591 BRDA:168,20,1,29 BRDA:168,20,2,562 BRDA:178,21,0,12 BRDA:178,21,1,576 BRDA:178,22,0,588 BRDA:178,22,1,38 BRDA:182,23,0,28 BRDA:182,23,1,560 BRDA:190,24,0,1 BRDA:190,24,1,5 BRDA:190,25,0,6 BRDA:190,25,1,5 BRDA:192,26,0,166 BRDA:192,26,1,0 BRDA:193,27,0,5 BRDA:193,27,1,161 BRDA:203,28,0,0 BRDA:203,28,1,7 BRDA:205,29,0,8 BRDA:205,29,1,391 BRDA:209,30,0,1 BRDA:209,30,1,6 BRDA:212,31,0,5 BRDA:212,31,1,1 BRDA:212,32,0,6 BRDA:212,32,1,2 BRDA:216,33,0,1 BRDA:216,33,1,1 BRDA:224,34,0,15 BRDA:224,34,1,0 BRDA:230,35,0,2 BRDA:230,35,1,0 BRDA:238,36,0,369 BRDA:238,36,1,0 BRDA:239,37,0,1 BRDA:239,37,1,368 BRDA:241,38,0,1 BRDA:241,38,1,367 BRDA:243,39,0,28 BRDA:243,39,1,339 BRDA:243,40,0,367 BRDA:243,40,1,366 BRDA:294,41,0,0 BRDA:294,41,1,119 BRDA:294,42,0,119 BRDA:294,42,1,119 BRDA:294,42,2,119 BRDA:294,42,3,119 BRDA:340,43,0,2 BRDA:340,43,1,2 BRF:91 BRH:82 end_of_record TN: SF:src/core/core-prototypes.js FN:1,(anonymous_1) FN:4,(anonymous_2) FN:11,(anonymous_3) FN:13,(anonymous_4) FN:38,(anonymous_5) FN:50,(anonymous_6) FN:62,(anonymous_7) FN:71,(anonymous_8) FN:80,(anonymous_9) FN:90,(anonymous_10) FN:99,(anonymous_11) FN:108,(anonymous_12) FN:123,(anonymous_13) FN:132,(anonymous_14) FN:143,(anonymous_15) FN:153,(anonymous_16) FN:163,(anonymous_17) FN:173,(anonymous_18) FN:184,(anonymous_19) FN:217,(anonymous_20) FN:228,(anonymous_21) FN:237,(anonymous_22) FN:250,(anonymous_23) FN:266,(anonymous_24) FN:314,(anonymous_25) FN:349,(anonymous_26) FN:358,(anonymous_27) FN:370,(anonymous_28) FN:375,(anonymous_29) FN:379,(anonymous_30) FN:389,(anonymous_31) FN:421,(anonymous_32) FN:422,(anonymous_33) FN:445,(anonymous_34) FN:453,(anonymous_35) FN:461,(anonymous_36) FN:465,(anonymous_37) FN:470,(anonymous_38) FN:478,(anonymous_39) FN:486,(anonymous_40) FN:494,(anonymous_41) FN:510,(anonymous_42) FN:526,(anonymous_43) FN:562,(anonymous_44) FN:570,(anonymous_45) FN:631,(anonymous_46) FN:647,(anonymous_47) FN:677,(anonymous_48) FN:678,(anonymous_49) FN:755,(anonymous_50) FNF:50 FNH:50 FNDA:1,(anonymous_1) FNDA:4331,(anonymous_2) FNDA:151,(anonymous_3) FNDA:335,(anonymous_4) FNDA:2100,(anonymous_5) FNDA:3,(anonymous_6) FNDA:25,(anonymous_7) FNDA:408,(anonymous_8) FNDA:398,(anonymous_9) FNDA:1,(anonymous_10) FNDA:2,(anonymous_11) FNDA:2,(anonymous_12) FNDA:2,(anonymous_13) FNDA:155,(anonymous_14) FNDA:70,(anonymous_15) FNDA:48,(anonymous_16) FNDA:37,(anonymous_17) FNDA:1851,(anonymous_18) FNDA:14,(anonymous_19) FNDA:55,(anonymous_20) FNDA:413,(anonymous_21) FNDA:1,(anonymous_22) FNDA:190,(anonymous_23) FNDA:508,(anonymous_24) FNDA:86,(anonymous_25) FNDA:2,(anonymous_26) FNDA:3,(anonymous_27) FNDA:1,(anonymous_28) FNDA:14,(anonymous_29) FNDA:1,(anonymous_30) FNDA:15,(anonymous_31) FNDA:2,(anonymous_32) FNDA:1183,(anonymous_33) FNDA:1,(anonymous_34) FNDA:1,(anonymous_35) FNDA:1,(anonymous_36) FNDA:5,(anonymous_37) FNDA:1,(anonymous_38) FNDA:3,(anonymous_39) FNDA:7,(anonymous_40) FNDA:3,(anonymous_41) FNDA:19,(anonymous_42) FNDA:151,(anonymous_43) FNDA:11,(anonymous_44) FNDA:10,(anonymous_45) FNDA:7,(anonymous_46) FNDA:1470,(anonymous_47) FNDA:1498,(anonymous_48) FNDA:4446,(anonymous_49) FNDA:2958,(anonymous_50) DA:1,1 DA:2,1 DA:5,4331 DA:6,2871 DA:8,4331 DA:11,1 DA:12,151 DA:13,151 DA:14,335 DA:15,119 DA:16,119 DA:17,119 DA:19,216 DA:22,151 DA:23,565 DA:24,565 DA:26,565 DA:27,330 DA:31,150 DA:38,1 DA:39,2100 DA:40,2100 DA:41,2100 DA:42,2100 DA:43,2100 DA:50,1 DA:51,3 DA:52,3 DA:53,3 DA:54,3 DA:55,3 DA:56,3 DA:62,1 DA:63,25 DA:71,1 DA:72,408 DA:80,1 DA:81,398 DA:90,1 DA:91,1 DA:99,1 DA:100,2 DA:108,1 DA:109,2 DA:123,1 DA:124,2 DA:132,1 DA:133,155 DA:134,155 DA:135,155 DA:143,1 DA:144,70 DA:145,70 DA:153,1 DA:154,48 DA:155,46 DA:163,1 DA:164,37 DA:165,37 DA:173,1 DA:174,1851 DA:175,1841 DA:176,1841 DA:184,1 DA:185,14 DA:186,12 DA:187,12 DA:188,12 DA:189,4 DA:190,2 DA:191,2 DA:192,2 DA:196,12 DA:197,5 DA:198,11 DA:199,11 DA:200,11 DA:201,5 DA:204,5 DA:205,7 DA:206,2 DA:209,7 DA:217,1 DA:218,55 DA:219,54 DA:228,1 DA:229,413 DA:230,396 DA:231,396 DA:232,396 DA:233,396 DA:234,396 DA:237,1 DA:238,1 DA:242,1 DA:250,1 DA:251,190 DA:252,174 DA:266,1 DA:267,508 DA:268,83 DA:269,83 DA:272,425 DA:274,425 DA:277,0 DA:278,0 DA:281,425 DA:282,1 DA:284,425 DA:285,31 DA:287,425 DA:288,31 DA:290,425 DA:291,31 DA:293,425 DA:294,1 DA:296,425 DA:297,109 DA:299,425 DA:300,109 DA:302,425 DA:303,119 DA:305,425 DA:314,1 DA:316,86 DA:317,86 DA:318,2 DA:319,2 DA:321,84 DA:325,86 DA:329,86 DA:331,86 DA:334,86 DA:336,86 DA:337,86 DA:341,86 DA:349,1 DA:350,2 DA:358,1 DA:359,3 DA:360,1 DA:361,0 DA:363,1 DA:366,2 DA:370,1 DA:371,1 DA:372,1 DA:375,1 DA:376,14 DA:379,1 DA:380,1 DA:389,1 DA:390,15 DA:391,5 DA:392,2 DA:393,2 DA:394,2 DA:396,3 DA:397,2 DA:398,2 DA:399,1 DA:402,1 DA:404,4 DA:406,10 DA:407,10 DA:408,8 DA:410,2 DA:411,2 DA:412,2 DA:413,1 DA:415,2 DA:417,8 DA:421,1 DA:422,2 DA:423,1183 DA:424,1183 DA:433,1 DA:440,1 DA:445,1 DA:446,1 DA:447,1 DA:453,1 DA:454,1 DA:461,1 DA:462,1 DA:465,1 DA:466,5 DA:467,5 DA:470,1 DA:471,1 DA:478,1 DA:479,3 DA:486,1 DA:487,7 DA:494,1 DA:495,3 DA:496,3 DA:497,2 DA:498,2 DA:500,1 DA:501,1 DA:510,1 DA:511,19 DA:526,1 DA:527,151 DA:528,150 DA:529,150 DA:530,330 DA:531,330 DA:532,330 DA:533,330 DA:534,226 DA:536,330 DA:537,330 DA:538,330 DA:539,100 DA:540,230 DA:541,69 DA:543,330 DA:544,177 DA:545,153 DA:546,34 DA:551,150 DA:552,119 DA:555,150 DA:562,1 DA:563,11 DA:570,1 DA:571,10 DA:631,1 DA:632,7 DA:636,1 DA:639,1 DA:642,1 DA:644,4 DA:647,1 DA:648,1470 DA:649,1470 DA:651,1450 DA:653,1 DA:655,1 DA:657,1 DA:660,2 DA:661,2 DA:663,1 DA:665,1 DA:667,1 DA:669,1 DA:670,1 DA:672,1 DA:674,10 DA:677,1 DA:678,1498 DA:679,4446 DA:680,3 DA:682,4443 DA:684,2 DA:686,4 DA:688,5 DA:690,1 DA:692,11 DA:694,1 DA:696,7 DA:698,1 DA:700,1460 DA:702,2 DA:704,0 DA:707,3 DA:709,3 DA:711,1424 DA:713,39 DA:715,5 DA:717,3 DA:719,1418 DA:721,37 DA:723,1 DA:725,5 DA:727,6 DA:729,2 DA:731,1 DA:733,1 DA:735,1 DA:737,0 DA:740,0 DA:742,0 DA:744,0 DA:746,0 DA:749,0 DA:751,0 DA:755,1 DA:759,2958 DA:760,1470 DA:761,1470 DA:762,1460 DA:765,1498 DA:766,1498 LF:296 LH:285 BRDA:5,1,0,2871 BRDA:5,1,1,1460 BRDA:14,2,0,119 BRDA:14,2,1,216 BRDA:15,3,0,96 BRDA:15,3,1,23 BRDA:16,4,0,67 BRDA:16,4,1,52 BRDA:23,5,0,565 BRDA:23,5,1,0 BRDA:26,6,0,330 BRDA:26,6,1,234 BRDA:26,7,0,565 BRDA:26,7,1,336 BRDA:26,7,2,335 BRDA:81,8,0,398 BRDA:81,8,1,0 BRDA:91,9,0,1 BRDA:91,9,1,1 BRDA:100,10,0,2 BRDA:100,10,1,0 BRDA:109,11,0,2 BRDA:109,11,1,0 BRDA:124,12,0,2 BRDA:124,12,1,1 BRDA:133,13,0,0 BRDA:133,13,1,155 BRDA:144,14,0,0 BRDA:144,14,1,70 BRDA:154,15,0,2 BRDA:154,15,1,46 BRDA:164,16,0,0 BRDA:164,16,1,37 BRDA:174,17,0,10 BRDA:174,17,1,1841 BRDA:185,18,0,2 BRDA:185,18,1,12 BRDA:188,19,0,4 BRDA:188,19,1,8 BRDA:188,20,0,12 BRDA:188,20,1,9 BRDA:189,21,0,2 BRDA:189,21,1,2 BRDA:196,22,0,5 BRDA:196,22,1,7 BRDA:200,23,0,5 BRDA:200,23,1,6 BRDA:200,24,0,11 BRDA:200,24,1,9 BRDA:205,25,0,2 BRDA:205,25,1,5 BRDA:205,26,0,7 BRDA:205,26,1,7 BRDA:218,27,0,1 BRDA:218,27,1,54 BRDA:229,28,0,17 BRDA:229,28,1,396 BRDA:238,29,0,0 BRDA:238,29,1,1 BRDA:251,30,0,16 BRDA:251,30,1,174 BRDA:267,31,0,83 BRDA:267,31,1,425 BRDA:274,32,0,0 BRDA:274,32,1,425 BRDA:277,33,0,0 BRDA:277,33,1,0 BRDA:281,34,0,1 BRDA:281,34,1,424 BRDA:284,35,0,31 BRDA:284,35,1,394 BRDA:287,36,0,31 BRDA:287,36,1,394 BRDA:290,37,0,31 BRDA:290,37,1,394 BRDA:293,38,0,1 BRDA:293,38,1,424 BRDA:296,39,0,109 BRDA:296,39,1,316 BRDA:299,40,0,109 BRDA:299,40,1,316 BRDA:302,41,0,119 BRDA:302,41,1,306 BRDA:317,42,0,2 BRDA:317,42,1,84 BRDA:336,43,0,86 BRDA:336,43,1,0 BRDA:359,44,0,1 BRDA:359,44,1,2 BRDA:360,45,0,0 BRDA:360,45,1,1 BRDA:361,46,0,0 BRDA:361,46,1,0 BRDA:366,47,0,1 BRDA:366,47,1,1 BRDA:390,48,0,5 BRDA:390,48,1,10 BRDA:391,49,0,2 BRDA:391,49,1,3 BRDA:393,50,0,2 BRDA:393,50,1,0 BRDA:396,51,0,2 BRDA:396,51,1,1 BRDA:398,52,0,1 BRDA:398,52,1,1 BRDA:407,53,0,8 BRDA:407,53,1,2 BRDA:410,54,0,2 BRDA:410,54,1,0 BRDA:412,55,0,1 BRDA:412,55,1,1 BRDA:423,56,0,1183 BRDA:423,56,1,1 BRDA:424,57,0,168 BRDA:424,57,1,1015 BRDA:424,58,0,168 BRDA:424,58,1,0 BRDA:467,59,0,5 BRDA:467,59,1,0 BRDA:467,60,0,5 BRDA:467,60,1,1 BRDA:495,61,0,3 BRDA:495,61,1,1 BRDA:496,62,0,2 BRDA:496,62,1,1 BRDA:511,63,0,19 BRDA:511,63,1,0 BRDA:530,64,0,330 BRDA:530,64,1,0 BRDA:533,65,0,226 BRDA:533,65,1,104 BRDA:533,66,0,330 BRDA:533,66,1,329 BRDA:533,66,2,229 BRDA:533,66,3,228 BRDA:538,67,0,100 BRDA:538,67,1,230 BRDA:540,68,0,69 BRDA:540,68,1,161 BRDA:543,69,0,177 BRDA:543,69,1,153 BRDA:543,70,0,330 BRDA:543,70,1,211 BRDA:543,70,2,210 BRDA:543,70,3,208 BRDA:543,70,4,207 BRDA:545,71,0,34 BRDA:545,71,1,119 BRDA:545,72,0,153 BRDA:545,72,1,152 BRDA:545,72,2,150 BRDA:545,72,3,149 BRDA:551,73,0,119 BRDA:551,73,1,31 BRDA:632,74,0,1 BRDA:632,74,1,1 BRDA:632,74,2,1 BRDA:632,74,3,1 BRDA:632,74,4,1 BRDA:632,74,5,1 BRDA:632,74,6,1 BRDA:632,74,7,4 BRDA:649,75,0,1450 BRDA:649,75,1,1 BRDA:649,75,2,1 BRDA:649,75,3,1 BRDA:649,75,4,1 BRDA:649,75,5,2 BRDA:649,75,6,1 BRDA:649,75,7,1 BRDA:649,75,8,1 BRDA:649,75,9,1 BRDA:649,75,10,1 BRDA:649,75,11,10 BRDA:679,76,0,3 BRDA:679,76,1,4443 BRDA:682,77,0,2 BRDA:682,77,1,4 BRDA:682,77,2,5 BRDA:682,77,3,1 BRDA:682,77,4,11 BRDA:682,77,5,1 BRDA:682,77,6,7 BRDA:682,77,7,1 BRDA:682,77,8,1460 BRDA:682,77,9,2 BRDA:682,77,10,0 BRDA:682,77,11,0 BRDA:682,77,12,3 BRDA:682,77,13,3 BRDA:682,77,14,1424 BRDA:682,77,15,39 BRDA:682,77,16,5 BRDA:682,77,17,3 BRDA:682,77,18,1418 BRDA:682,77,19,37 BRDA:682,77,20,1 BRDA:682,77,21,5 BRDA:682,77,22,6 BRDA:682,77,23,2 BRDA:682,77,24,1 BRDA:682,77,25,1 BRDA:682,77,26,1 BRDA:682,77,27,0 BRDA:682,77,28,0 BRDA:682,77,29,0 BRDA:682,77,30,0 BRDA:682,77,31,0 BRDA:682,77,32,0 BRDA:682,77,33,0 BRDA:682,77,34,0 BRDA:684,78,0,2 BRDA:684,78,1,0 BRDA:684,79,0,2 BRDA:684,79,1,0 BRDA:686,80,0,4 BRDA:686,80,1,0 BRDA:686,81,0,4 BRDA:686,81,1,0 BRDA:723,82,0,1 BRDA:723,82,1,0 BRDA:725,83,0,5 BRDA:725,83,1,0 BRDA:746,84,0,0 BRDA:746,84,1,0 BRDA:759,85,0,1470 BRDA:759,85,1,1488 BRDA:759,86,0,2958 BRDA:759,86,1,2958 BRDA:759,86,2,2944 BRDA:761,87,0,1460 BRDA:761,87,1,10 BRDA:766,88,0,1484 BRDA:766,88,1,14 BRF:234 BRH:195 end_of_record TN: SF:src/core/sugarpak.js FN:5,(anonymous_1) FN:39,(anonymous_2) FN:58,(anonymous_3) FN:75,(anonymous_4) FN:94,(anonymous_5) FN:110,(anonymous_6) FN:150,(anonymous_7) FN:168,(anonymous_8) FN:181,(anonymous_9) FN:203,(anonymous_10) FN:224,(anonymous_11) FN:243,(anonymous_12) FN:264,(anonymous_13) FN:296,(anonymous_14) FN:320,(anonymous_15) FN:327,(anonymous_16) FN:328,(anonymous_17) FN:366,(anonymous_18) FN:367,(anonymous_19) FN:379,(anonymous_20) FN:380,(anonymous_21) FN:389,(anonymous_22) FN:390,(anonymous_23) FN:395,(anonymous_24) FN:411,(anonymous_25) FN:412,(anonymous_26) FN:451,(anonymous_27) FN:452,(anonymous_28) FN:471,(anonymous_29) FN:472,(anonymous_30) FNF:30 FNH:30 FNDA:1,(anonymous_1) FNDA:24,(anonymous_2) FNDA:7,(anonymous_3) FNDA:1137,(anonymous_4) FNDA:7,(anonymous_5) FNDA:34,(anonymous_6) FNDA:5,(anonymous_7) FNDA:3,(anonymous_8) FNDA:13,(anonymous_9) FNDA:3,(anonymous_10) FNDA:1,(anonymous_11) FNDA:1,(anonymous_12) FNDA:1,(anonymous_13) FNDA:10,(anonymous_14) FNDA:1,(anonymous_15) FNDA:8,(anonymous_16) FNDA:1179,(anonymous_17) FNDA:7,(anonymous_18) FNDA:8,(anonymous_19) FNDA:12,(anonymous_20) FNDA:17,(anonymous_21) FNDA:12,(anonymous_22) FNDA:12,(anonymous_23) FNDA:2,(anonymous_24) FNDA:10,(anonymous_25) FNDA:89,(anonymous_26) FNDA:9,(anonymous_27) FNDA:2,(anonymous_28) FNDA:6,(anonymous_29) FNDA:5,(anonymous_30) DA:5,1 DA:6,1 DA:9,1 DA:12,1 DA:15,1 DA:18,1 DA:21,1 DA:24,1 DA:39,1 DA:40,24 DA:41,24 DA:42,24 DA:58,1 DA:59,7 DA:75,1 DA:76,1137 DA:77,1137 DA:78,1137 DA:94,1 DA:95,7 DA:110,1 DA:111,34 DA:112,34 DA:150,1 DA:151,5 DA:152,5 DA:153,5 DA:168,1 DA:169,3 DA:181,1 DA:182,13 DA:183,1 DA:185,12 DA:186,4 DA:188,8 DA:189,7 DA:190,7 DA:192,1 DA:203,1 DA:204,3 DA:205,2 DA:206,2 DA:208,1 DA:224,1 DA:225,1 DA:243,1 DA:244,1 DA:245,1 DA:246,1 DA:264,1 DA:265,1 DA:267,1 DA:268,1 DA:273,1 DA:296,1 DA:297,10 DA:298,10 DA:299,100 DA:300,90 DA:303,10 DA:320,1 DA:321,1 DA:322,1 DA:327,1 DA:328,8 DA:329,1179 DA:330,20 DA:331,20 DA:333,1159 DA:334,1159 DA:347,4 DA:348,3 DA:351,4 DA:353,4 DA:354,4 DA:355,4 DA:356,4 DA:357,4 DA:358,1 DA:360,3 DA:362,1155 DA:366,1 DA:367,7 DA:368,8 DA:369,8 DA:370,0 DA:372,8 DA:379,1 DA:380,12 DA:381,17 DA:382,2 DA:383,2 DA:385,15 DA:389,1 DA:390,12 DA:391,12 DA:395,1 DA:396,2 DA:398,19 DA:400,19 DA:402,19 DA:407,1 DA:408,1 DA:411,1 DA:412,10 DA:415,89 DA:416,0 DA:417,0 DA:420,89 DA:421,5 DA:422,5 DA:428,5 DA:430,5 DA:431,31 DA:432,31 DA:433,1 DA:435,30 DA:436,4 DA:439,4 DA:442,84 DA:443,7 DA:445,84 DA:446,84 DA:451,1 DA:452,9 DA:453,2 DA:454,2 DA:458,1 DA:459,10 DA:460,10 DA:462,9 DA:465,9 DA:469,1 DA:471,1 DA:472,6 DA:473,5 DA:474,0 DA:476,5 DA:477,0 DA:479,5 DA:482,5 DA:483,4 DA:484,4 DA:486,1 DA:490,1 DA:491,6 LF:146 LH:141 BRDA:182,1,0,1 BRDA:182,1,1,12 BRDA:185,2,0,4 BRDA:185,2,1,8 BRDA:188,3,0,7 BRDA:188,3,1,1 BRDA:190,4,0,7 BRDA:190,4,1,7 BRDA:204,5,0,2 BRDA:204,5,1,1 BRDA:206,6,0,2 BRDA:206,6,1,2 BRDA:225,7,0,1 BRDA:225,7,1,0 BRDA:246,8,0,1 BRDA:246,8,1,0 BRDA:266,9,0,0 BRDA:266,9,1,1 BRDA:268,10,0,1 BRDA:268,10,1,0 BRDA:299,11,0,90 BRDA:299,11,1,10 BRDA:329,12,0,20 BRDA:329,12,1,1159 BRDA:333,13,0,1155 BRDA:333,13,1,4 BRDA:334,14,0,4 BRDA:334,14,1,1155 BRDA:347,15,0,3 BRDA:347,15,1,1 BRDA:357,16,0,1 BRDA:357,16,1,3 BRDA:369,17,0,0 BRDA:369,17,1,8 BRDA:369,18,0,8 BRDA:369,18,1,0 BRDA:369,18,2,0 BRDA:381,19,0,2 BRDA:381,19,1,15 BRDA:415,20,0,0 BRDA:415,20,1,89 BRDA:420,21,0,5 BRDA:420,21,1,84 BRDA:423,22,0,5 BRDA:423,22,1,3 BRDA:428,23,0,5 BRDA:428,23,1,0 BRDA:432,24,0,1 BRDA:432,24,1,30 BRDA:435,25,0,4 BRDA:435,25,1,26 BRDA:442,26,0,7 BRDA:442,26,1,77 BRDA:445,27,0,2 BRDA:445,27,1,82 BRDA:460,28,0,9 BRDA:460,28,1,1 BRDA:473,29,0,0 BRDA:473,29,1,5 BRDA:476,30,0,0 BRDA:476,30,1,5 BRDA:476,31,0,5 BRDA:476,31,1,5 BRDA:482,32,0,4 BRDA:482,32,1,1 BRDA:482,33,0,5 BRDA:482,33,1,4 BRDA:482,33,2,0 BRDA:491,34,0,1 BRDA:491,34,1,5 BRF:70 BRH:58 end_of_record TN: SF:src/core/format_parser.js FN:1,(anonymous_1) FN:4,(anonymous_2) FN:14,(anonymous_3) FN:19,(anonymous_4) FN:34,(anonymous_5) FN:43,(anonymous_6) FN:57,(anonymous_7) FN:72,(anonymous_8) FN:85,(anonymous_9) FN:99,(anonymous_10) FN:117,(anonymous_11) FN:137,(anonymous_12) FN:140,(anonymous_13) FN:144,(anonymous_14) FN:147,(anonymous_15) FN:150,(anonymous_16) FN:171,(anonymous_17) FN:180,(anonymous_18) FN:183,(anonymous_19) FN:191,(anonymous_20) FN:205,(anonymous_21) FN:227,(anonymous_22) FN:243,(anonymous_23) FN:245,(anonymous_24) FN:279,(anonymous_25) FN:293,(anonymous_26) FN:316,(anonymous_27) FN:329,(anonymous_28) FN:336,(anonymous_29) FN:340,(anonymous_30) FN:344,(anonymous_31) FN:345,(anonymous_32) FN:349,(anonymous_33) FN:353,(anonymous_34) FN:359,(anonymous_35) FNF:35 FNH:33 FNDA:1,(anonymous_1) FNDA:39302,(anonymous_2) FNDA:84,(anonymous_3) FNDA:530,(anonymous_4) FNDA:17,(anonymous_5) FNDA:31,(anonymous_6) FNDA:21,(anonymous_7) FNDA:84,(anonymous_8) FNDA:960,(anonymous_9) FNDA:80,(anonymous_10) FNDA:80,(anonymous_11) FNDA:48,(anonymous_12) FNDA:17,(anonymous_13) FNDA:52,(anonymous_14) FNDA:40,(anonymous_15) FNDA:29,(anonymous_16) FNDA:160,(anonymous_17) FNDA:1120,(anonymous_18) FNDA:1440,(anonymous_19) FNDA:160,(anonymous_20) FNDA:84,(anonymous_21) FNDA:454,(anonymous_22) FNDA:573,(anonymous_23) FNDA:375,(anonymous_24) FNDA:160,(anonymous_25) FNDA:160,(anonymous_26) FNDA:160,(anonymous_27) FNDA:160,(anonymous_28) FNDA:5,(anonymous_29) FNDA:4,(anonymous_30) FNDA:0,(anonymous_31) FNDA:0,(anonymous_32) FNDA:160,(anonymous_33) FNDA:530,(anonymous_34) FNDA:530,(anonymous_35) DA:1,1 DA:3,1 DA:5,39302 DA:8,1 DA:9,1 DA:14,1 DA:15,84 DA:18,1 DA:20,530 DA:21,530 DA:22,13780 DA:23,13780 DA:24,13780 DA:27,13780 DA:29,13780 DA:32,530 DA:35,17 DA:36,17 DA:37,17 DA:38,17 DA:39,17 DA:40,17 DA:41,17 DA:44,31 DA:45,17 DA:47,31 DA:48,403 DA:49,31 DA:50,31 DA:52,372 DA:55,31 DA:58,21 DA:59,21 DA:61,16 DA:63,5 DA:64,5 DA:65,2 DA:67,5 DA:69,21 DA:70,21 DA:73,84 DA:74,84 DA:75,84 DA:76,84 DA:77,84 DA:78,84 DA:80,53 DA:81,53 DA:83,84 DA:86,960 DA:87,960 DA:88,400 DA:89,240 DA:91,160 DA:93,560 DA:94,400 DA:96,160 DA:100,80 DA:101,80 DA:102,1200 DA:103,1200 DA:106,80 DA:107,8 DA:108,8 DA:109,4 DA:110,4 DA:111,4 DA:113,8 DA:115,80 DA:118,80 DA:138,48 DA:141,17 DA:142,17 DA:145,52 DA:148,40 DA:151,29 DA:169,80 DA:172,160 DA:173,160 DA:174,160 DA:175,160 DA:176,1440 DA:178,160 DA:181,1120 DA:184,1440 DA:185,320 DA:186,1120 DA:187,1120 DA:192,160 DA:193,160 DA:194,160 DA:195,1440 DA:196,1120 DA:198,320 DA:201,160 DA:205,1 DA:206,84 DA:208,84 DA:209,84 DA:211,84 DA:212,31 DA:214,53 DA:217,84 DA:219,84 DA:220,21 DA:222,84 DA:225,1 DA:228,454 DA:229,454 DA:230,374 DA:233,80 DA:235,80 DA:236,0 DA:238,80 DA:242,1 DA:243,573 DA:246,375 DA:249,375 DA:251,368 DA:253,7 DA:254,1 DA:255,1 DA:257,6 DA:258,6 DA:259,2 DA:261,4 DA:262,12 DA:264,4 DA:265,4 DA:267,4 DA:268,4 DA:270,4 DA:271,4 DA:274,4 DA:278,1 DA:280,160 DA:281,160 DA:294,160 DA:295,160 DA:317,160 DA:330,160 DA:331,160 DA:332,160 DA:333,160 DA:335,160 DA:337,5 DA:341,4 DA:342,4 DA:344,0 DA:345,0 DA:350,160 DA:351,160 DA:354,530 DA:355,2120 DA:357,530 DA:360,530 DA:361,530 DA:363,530 DA:364,530 DA:365,530 DA:371,0 DA:372,0 DA:377,530 DA:380,1 LF:164 LH:159 BRDA:15,1,0,84 BRDA:15,1,1,2 BRDA:15,1,2,82 BRDA:22,2,0,13780 BRDA:22,2,1,0 BRDA:24,3,0,0 BRDA:24,3,1,13780 BRDA:27,4,0,13250 BRDA:27,4,1,530 BRDA:36,5,0,0 BRDA:36,5,1,17 BRDA:36,6,0,17 BRDA:36,6,1,0 BRDA:38,7,0,1 BRDA:38,7,1,16 BRDA:40,8,0,0 BRDA:40,8,1,17 BRDA:44,9,0,17 BRDA:44,9,1,14 BRDA:48,10,0,31 BRDA:48,10,1,372 BRDA:48,11,0,403 BRDA:48,11,1,403 BRDA:49,12,0,0 BRDA:49,12,1,31 BRDA:59,13,0,16 BRDA:59,13,1,5 BRDA:59,14,0,21 BRDA:59,14,1,6 BRDA:59,14,2,1 BRDA:63,15,0,5 BRDA:63,15,1,5 BRDA:64,16,0,2 BRDA:64,16,1,3 BRDA:73,17,0,84 BRDA:73,17,1,1 BRDA:74,18,0,84 BRDA:74,18,1,21 BRDA:75,19,0,84 BRDA:75,19,1,29 BRDA:76,20,0,84 BRDA:76,20,1,41 BRDA:77,21,0,84 BRDA:77,21,1,55 BRDA:78,22,0,53 BRDA:78,22,1,31 BRDA:78,23,0,84 BRDA:78,23,1,34 BRDA:78,23,2,17 BRDA:80,24,0,53 BRDA:80,24,1,3 BRDA:81,25,0,53 BRDA:81,25,1,11 BRDA:87,26,0,400 BRDA:87,26,1,560 BRDA:88,27,0,240 BRDA:88,27,1,160 BRDA:89,28,0,121 BRDA:89,28,1,119 BRDA:91,29,0,65 BRDA:91,29,1,95 BRDA:93,30,0,400 BRDA:93,30,1,160 BRDA:94,31,0,214 BRDA:94,31,1,186 BRDA:96,32,0,9 BRDA:96,32,1,151 BRDA:96,33,0,160 BRDA:96,33,1,9 BRDA:102,34,0,1200 BRDA:102,34,1,0 BRDA:103,35,0,240 BRDA:103,35,1,960 BRDA:106,36,0,8 BRDA:106,36,1,72 BRDA:108,37,0,4 BRDA:108,37,1,4 BRDA:110,38,0,4 BRDA:110,38,1,0 BRDA:142,39,0,0 BRDA:142,39,1,17 BRDA:184,40,0,320 BRDA:184,40,1,1120 BRDA:186,41,0,1120 BRDA:186,41,1,0 BRDA:195,42,0,1120 BRDA:195,42,1,320 BRDA:209,43,0,2 BRDA:209,43,1,82 BRDA:211,44,0,31 BRDA:211,44,1,53 BRDA:211,45,0,84 BRDA:211,45,1,34 BRDA:211,45,2,17 BRDA:219,46,0,21 BRDA:219,46,1,63 BRDA:229,47,0,374 BRDA:229,47,1,80 BRDA:229,48,0,454 BRDA:229,48,1,80 BRDA:235,49,0,0 BRDA:235,49,1,80 BRDA:235,50,0,80 BRDA:235,50,1,80 BRDA:235,50,2,0 BRDA:235,50,3,0 BRDA:235,50,4,0 BRDA:235,50,5,0 BRDA:243,51,0,573 BRDA:243,51,1,82 BRDA:249,52,0,368 BRDA:249,52,1,7 BRDA:249,53,0,375 BRDA:249,53,1,7 BRDA:249,53,2,0 BRDA:253,54,0,1 BRDA:253,54,1,6 BRDA:253,55,0,7 BRDA:253,55,1,2 BRDA:253,55,2,1 BRDA:258,56,0,2 BRDA:258,56,1,4 BRDA:258,57,0,6 BRDA:258,57,1,4 BRDA:262,58,0,4 BRDA:262,58,1,4 BRDA:262,58,2,4 BRDA:337,59,0,4 BRDA:337,59,1,1 BRDA:365,60,0,0 BRDA:365,60,1,530 BRDA:365,61,0,530 BRDA:365,61,1,158 BRDA:365,61,2,40 BRDA:365,61,3,2 BRDA:371,62,0,0 BRDA:371,62,1,0 BRF:137 BRH:118 end_of_record TN: SF:src/core/parsing_operators.js FN:1,(anonymous_1) FN:7,(anonymous_2) FN:8,(anonymous_3) FN:17,(anonymous_4) FN:18,(anonymous_5) FN:22,(anonymous_6) FN:28,(anonymous_7) FN:29,(anonymous_8) FN:44,(anonymous_9) FN:45,(anonymous_10) FN:61,(anonymous_11) FN:62,(anonymous_12) FN:72,(anonymous_13) FN:73,(anonymous_14) FN:82,(anonymous_15) FN:84,(anonymous_16) FN:90,(anonymous_17) FN:98,(anonymous_18) FN:100,(anonymous_19) FN:112,(anonymous_20) FN:130,(anonymous_21) FN:132,(anonymous_22) FN:150,(anonymous_23) FN:152,(anonymous_24) FN:169,(anonymous_25) FN:175,(anonymous_26) FN:182,(anonymous_27) FN:221,(anonymous_28) FN:224,(anonymous_29) FN:229,(anonymous_30) FN:236,(anonymous_31) FN:239,(anonymous_32) FN:357,(anonymous_33) FN:358,(anonymous_34) FN:366,(anonymous_35) FN:367,(anonymous_36) FN:372,(anonymous_37) FN:373,(anonymous_38) FN:378,(anonymous_39) FN:379,(anonymous_40) FN:412,(anonymous_41) FN:413,gen FN:442,(anonymous_43) FN:443,(anonymous_44) FNF:44 FNH:31 FNDA:1,(anonymous_1) FNDA:10780,(anonymous_2) FNDA:25714,(anonymous_3) FNDA:0,(anonymous_4) FNDA:0,(anonymous_5) FNDA:217,(anonymous_6) FNDA:0,(anonymous_7) FNDA:0,(anonymous_8) FNDA:160,(anonymous_9) FNDA:20,(anonymous_10) FNDA:480,(anonymous_11) FNDA:646,(anonymous_12) FNDA:480,(anonymous_13) FNDA:356,(anonymous_14) FNDA:376,(anonymous_15) FNDA:1104,(anonymous_16) FNDA:0,(anonymous_17) FNDA:4000,(anonymous_18) FNDA:15483,(anonymous_19) FNDA:15483,(anonymous_20) FNDA:1601,(anonymous_21) FNDA:5498,(anonymous_22) FNDA:1140,(anonymous_23) FNDA:14052,(anonymous_24) FNDA:0,(anonymous_25) FNDA:160,(anonymous_26) FNDA:469,(anonymous_27) FNDA:0,(anonymous_28) FNDA:0,(anonymous_29) FNDA:0,(anonymous_30) FNDA:2340,(anonymous_31) FNDA:2917,(anonymous_32) FNDA:0,(anonymous_33) FNDA:0,(anonymous_34) FNDA:5440,(anonymous_35) FNDA:16998,(anonymous_36) FNDA:5300,(anonymous_37) FNDA:18800,(anonymous_38) FNDA:0,(anonymous_39) FNDA:0,(anonymous_40) FNDA:4,(anonymous_41) FNDA:5336,gen FNDA:3,(anonymous_43) FNDA:2741,(anonymous_44) DA:1,1 DA:2,1 DA:3,1 DA:8,10780 DA:9,25714 DA:10,25714 DA:11,4104 DA:13,21610 DA:18,0 DA:19,0 DA:23,217 DA:29,0 DA:30,0 DA:31,0 DA:32,0 DA:33,0 DA:35,0 DA:36,0 DA:37,0 DA:39,0 DA:41,0 DA:45,160 DA:46,20 DA:47,20 DA:48,147 DA:49,147 DA:51,0 DA:53,147 DA:54,147 DA:56,20 DA:62,480 DA:63,646 DA:64,646 DA:65,646 DA:67,646 DA:69,0 DA:73,480 DA:74,356 DA:75,356 DA:77,350 DA:79,6 DA:83,376 DA:85,1104 DA:86,1104 DA:87,43 DA:91,0 DA:93,0 DA:94,0 DA:96,0 DA:99,4000 DA:100,4000 DA:101,15483 DA:103,0 DA:104,0 DA:105,0 DA:106,0 DA:107,0 DA:112,4000 DA:113,15483 DA:114,15483 DA:115,15483 DA:117,5153 DA:119,15483 DA:120,15483 DA:121,15483 DA:122,14556 DA:124,927 DA:131,1601 DA:132,1601 DA:133,5498 DA:134,5498 DA:135,31059 DA:136,0 DA:138,31059 DA:139,31059 DA:141,29340 DA:143,31059 DA:144,1719 DA:147,3779 DA:151,1140 DA:152,1140 DA:153,14052 DA:154,14052 DA:155,15582 DA:156,0 DA:158,15582 DA:159,15582 DA:161,13450 DA:163,2132 DA:164,2132 DA:166,602 DA:170,0 DA:171,0 DA:176,160 DA:177,160 DA:179,160 DA:180,0 DA:182,160 DA:183,469 DA:184,469 DA:185,469 DA:186,471 DA:187,471 DA:189,457 DA:191,14 DA:192,14 DA:193,14 DA:195,12 DA:196,12 DA:198,2 DA:200,469 DA:201,457 DA:203,12 DA:204,0 DA:206,12 DA:207,0 DA:208,0 DA:210,0 DA:213,12 DA:222,0 DA:223,0 DA:224,0 DA:225,0 DA:226,0 DA:230,0 DA:231,0 DA:232,0 DA:237,2340 DA:238,2340 DA:239,2340 DA:242,2917 DA:244,2917 DA:248,6399 DA:249,6399 DA:250,6399 DA:251,6399 DA:254,6399 DA:255,6399 DA:257,3427 DA:261,2972 DA:267,2972 DA:268,1922 DA:269,1922 DA:271,542 DA:274,1050 DA:280,2972 DA:281,0 DA:288,2972 DA:291,1380 DA:292,1380 DA:293,7872 DA:294,6492 DA:301,1380 DA:305,1380 DA:310,1341 DA:311,1341 DA:320,2972 DA:321,2469 DA:325,2972 DA:326,2301 DA:335,2917 DA:336,508 DA:340,2409 DA:343,528 DA:344,528 DA:346,0 DA:350,528 DA:354,2409 DA:358,0 DA:359,0 DA:367,5440 DA:368,16998 DA:369,1169 DA:373,5300 DA:374,18800 DA:375,2744 DA:379,0 DA:380,0 DA:381,0 DA:382,0 DA:384,0 DA:412,1 DA:413,1 DA:414,5336 DA:415,5336 DA:416,0 DA:417,5336 DA:418,0 DA:420,5336 DA:421,0 DA:422,0 DA:423,0 DA:424,0 DA:425,0 DA:426,0 DA:429,5336 DA:433,4 DA:436,1 DA:438,1 DA:439,4 DA:442,1 DA:443,3 DA:444,2741 DA:445,0 DA:447,2741 DA:452,1 DA:454,1 DA:455,3 LF:208 LH:150 BRDA:10,1,0,4104 BRDA:10,1,1,21610 BRDA:83,2,0,376 BRDA:83,2,1,0 BRDA:99,3,0,4000 BRDA:99,3,1,4000 BRDA:101,4,0,0 BRDA:101,4,1,15483 BRDA:105,5,0,0 BRDA:105,5,1,0 BRDA:115,6,0,15483 BRDA:115,6,1,5571 BRDA:121,7,0,14556 BRDA:121,7,1,927 BRDA:135,8,0,0 BRDA:135,8,1,31059 BRDA:143,9,0,1719 BRDA:143,9,1,29340 BRDA:155,10,0,0 BRDA:155,10,1,15582 BRDA:176,11,0,160 BRDA:176,11,1,0 BRDA:177,12,0,160 BRDA:177,12,1,160 BRDA:179,13,0,0 BRDA:179,13,1,160 BRDA:200,14,0,457 BRDA:200,14,1,12 BRDA:203,15,0,0 BRDA:203,15,1,12 BRDA:206,16,0,0 BRDA:206,16,1,12 BRDA:213,17,0,12 BRDA:213,17,1,0 BRDA:222,18,0,0 BRDA:222,18,1,0 BRDA:230,19,0,0 BRDA:230,19,1,0 BRDA:231,20,0,0 BRDA:231,20,1,0 BRDA:232,21,0,0 BRDA:232,21,1,0 BRDA:237,22,0,2340 BRDA:237,22,1,320 BRDA:238,23,0,2340 BRDA:238,23,1,2180 BRDA:267,24,0,1922 BRDA:267,24,1,1050 BRDA:267,25,0,2972 BRDA:267,25,1,1922 BRDA:280,26,0,0 BRDA:280,26,1,2972 BRDA:280,27,0,2972 BRDA:280,27,1,1380 BRDA:288,28,0,1380 BRDA:288,28,1,1592 BRDA:293,29,0,6492 BRDA:293,29,1,1380 BRDA:305,30,0,1341 BRDA:305,30,1,39 BRDA:320,31,0,2469 BRDA:320,31,1,503 BRDA:325,32,0,2301 BRDA:325,32,1,671 BRDA:335,33,0,508 BRDA:335,33,1,2409 BRDA:340,34,0,528 BRDA:340,34,1,1881 BRDA:381,35,0,0 BRDA:381,35,1,0 BRDA:415,36,0,0 BRDA:415,36,1,5336 BRDA:417,37,0,0 BRDA:417,37,1,5336 BRDA:420,38,0,0 BRDA:420,38,1,5336 BRDA:422,39,0,0 BRDA:422,39,1,0 BRDA:444,40,0,0 BRDA:444,40,1,2741 BRF:80 BRH:52 end_of_record TN: SF:src/core/parsing_translator.js FN:1,(anonymous_1) FN:4,(anonymous_2) FN:18,(anonymous_3) FN:32,(anonymous_4) FN:67,(anonymous_5) FN:74,(anonymous_6) FN:82,(anonymous_7) FN:91,(anonymous_8) FN:100,(anonymous_9) FN:110,(anonymous_10) FN:121,(anonymous_11) FN:122,(anonymous_12) FN:126,(anonymous_13) FN:127,(anonymous_14) FN:131,(anonymous_15) FN:132,(anonymous_16) FN:137,(anonymous_17) FN:138,(anonymous_18) FN:144,(anonymous_19) FN:145,(anonymous_20) FN:149,(anonymous_21) FN:150,(anonymous_22) FN:159,(anonymous_23) FN:161,(anonymous_24) FN:168,(anonymous_25) FN:169,(anonymous_26) FN:176,(anonymous_27) FN:177,(anonymous_28) FN:183,(anonymous_29) FN:184,(anonymous_30) FN:202,(anonymous_31) FN:231,(anonymous_32) FNF:32 FNH:28 FNDA:1,(anonymous_1) FNDA:1327,(anonymous_2) FNDA:577,(anonymous_3) FNDA:49,(anonymous_4) FNDA:528,(anonymous_5) FNDA:2,(anonymous_6) FNDA:108,(anonymous_7) FNDA:1,(anonymous_8) FNDA:528,(anonymous_9) FNDA:35,(anonymous_10) FNDA:12,(anonymous_11) FNDA:17,(anonymous_12) FNDA:2,(anonymous_13) FNDA:3,(anonymous_14) FNDA:0,(anonymous_15) FNDA:0,(anonymous_16) FNDA:0,(anonymous_17) FNDA:0,(anonymous_18) FNDA:4,(anonymous_19) FNDA:11,(anonymous_20) FNDA:2,(anonymous_21) FNDA:2,(anonymous_22) FNDA:169,(anonymous_23) FNDA:109,(anonymous_24) FNDA:154,(anonymous_25) FNDA:68,(anonymous_26) FNDA:50,(anonymous_27) FNDA:72,(anonymous_28) FNDA:230,(anonymous_29) FNDA:222,(anonymous_30) FNDA:49,(anonymous_31) FNDA:530,(anonymous_32) DA:1,1 DA:2,1 DA:4,1 DA:5,1327 DA:6,1327 DA:7,2853 DA:8,797 DA:10,2056 DA:11,1822 DA:15,1327 DA:18,1 DA:19,577 DA:20,11 DA:21,0 DA:22,11 DA:23,0 DA:24,11 DA:25,7 DA:26,4 DA:27,0 DA:32,1 DA:33,49 DA:34,49 DA:35,0 DA:38,49 DA:39,42 DA:42,49 DA:43,49 DA:46,49 DA:47,7 DA:50,49 DA:51,49 DA:54,49 DA:55,49 DA:58,49 DA:59,49 DA:61,49 DA:62,49 DA:66,1 DA:68,528 DA:69,91 DA:71,437 DA:75,2 DA:76,2 DA:77,2 DA:78,2 DA:79,2 DA:80,2 DA:83,108 DA:84,108 DA:85,108 DA:86,108 DA:87,108 DA:88,108 DA:89,108 DA:92,1 DA:93,1 DA:94,1 DA:95,1 DA:97,1 DA:98,1 DA:101,528 DA:102,0 DA:103,528 DA:104,525 DA:105,80 DA:107,525 DA:111,35 DA:112,35 DA:113,35 DA:114,1 DA:116,35 DA:120,1 DA:122,12 DA:123,17 DA:127,2 DA:128,3 DA:132,0 DA:133,0 DA:138,0 DA:139,0 DA:140,0 DA:141,0 DA:145,4 DA:146,11 DA:150,2 DA:151,2 DA:152,2 DA:153,0 DA:155,2 DA:160,169 DA:161,169 DA:162,109 DA:163,109 DA:164,0 DA:169,154 DA:170,68 DA:171,68 DA:172,0 DA:177,50 DA:178,72 DA:179,72 DA:184,230 DA:185,222 DA:187,0 DA:188,0 DA:190,0 DA:191,0 DA:193,221 DA:194,221 DA:196,1 DA:197,1 DA:198,1 DA:203,49 DA:204,49 DA:206,49 DA:207,49 DA:208,49 DA:212,49 DA:213,49 DA:215,49 DA:216,2 DA:219,47 DA:220,47 DA:221,0 DA:223,47 DA:224,0 DA:225,47 DA:226,0 DA:229,47 DA:232,530 DA:234,530 DA:236,530 DA:237,2 DA:240,528 DA:241,1822 DA:242,1822 DA:245,528 DA:246,0 DA:248,528 DA:251,528 DA:252,528 DA:254,528 DA:255,1 DA:256,1 DA:257,1 DA:260,528 DA:261,0 DA:262,0 DA:264,0 DA:265,0 DA:268,528 DA:269,1 DA:272,528 DA:273,2 DA:276,528 DA:277,0 DA:278,0 DA:279,0 DA:280,0 DA:284,528 DA:285,0 DA:286,0 DA:288,0 DA:291,528 DA:292,0 DA:295,528 DA:296,0 DA:297,0 DA:298,0 DA:302,528 DA:303,108 DA:304,108 DA:307,528 DA:308,108 DA:311,528 DA:312,77 DA:315,528 DA:316,528 DA:318,528 DA:319,0 DA:322,528 DA:323,0 DA:326,528 DA:327,35 DA:330,493 DA:331,0 DA:334,493 DA:335,422 DA:337,71 DA:340,493 DA:341,2 DA:342,2 DA:343,2 DA:344,2 DA:346,2 DA:347,2 DA:349,1 DA:350,0 DA:352,1 DA:356,2 DA:359,493 LF:202 LH:161 BRDA:7,1,0,797 BRDA:7,1,1,2056 BRDA:10,2,0,1822 BRDA:10,2,1,234 BRDA:19,3,0,11 BRDA:19,3,1,566 BRDA:19,4,0,577 BRDA:19,4,1,11 BRDA:19,4,2,0 BRDA:20,5,0,0 BRDA:20,5,1,11 BRDA:20,6,0,11 BRDA:20,6,1,4 BRDA:20,6,2,0 BRDA:22,7,0,0 BRDA:22,7,1,11 BRDA:22,8,0,11 BRDA:22,8,1,7 BRDA:22,8,2,7 BRDA:24,9,0,7 BRDA:24,9,1,4 BRDA:24,10,0,11 BRDA:24,10,1,7 BRDA:26,11,0,0 BRDA:26,11,1,4 BRDA:26,12,0,4 BRDA:26,12,1,4 BRDA:34,13,0,0 BRDA:34,13,1,49 BRDA:34,14,0,49 BRDA:34,14,1,49 BRDA:34,14,2,0 BRDA:34,14,3,0 BRDA:34,14,4,0 BRDA:38,15,0,42 BRDA:38,15,1,7 BRDA:42,16,0,49 BRDA:42,16,1,0 BRDA:42,17,0,49 BRDA:42,17,1,49 BRDA:46,18,0,7 BRDA:46,18,1,42 BRDA:50,19,0,49 BRDA:50,19,1,0 BRDA:54,20,0,49 BRDA:54,20,1,0 BRDA:58,21,0,49 BRDA:58,21,1,0 BRDA:61,22,0,49 BRDA:61,22,1,0 BRDA:68,23,0,91 BRDA:68,23,1,437 BRDA:68,24,0,528 BRDA:68,24,1,527 BRDA:76,25,0,2 BRDA:76,25,1,0 BRDA:79,26,0,2 BRDA:79,26,1,0 BRDA:84,27,0,108 BRDA:84,27,1,0 BRDA:87,28,0,108 BRDA:87,28,1,0 BRDA:94,29,0,1 BRDA:94,29,1,0 BRDA:101,30,0,0 BRDA:101,30,1,528 BRDA:101,31,0,528 BRDA:101,31,1,83 BRDA:101,31,2,6 BRDA:101,31,3,6 BRDA:101,31,4,0 BRDA:102,32,0,0 BRDA:102,32,1,0 BRDA:102,33,0,0 BRDA:102,33,1,0 BRDA:103,34,0,525 BRDA:103,34,1,3 BRDA:103,35,0,528 BRDA:103,35,1,187 BRDA:104,36,0,80 BRDA:104,36,1,445 BRDA:111,37,0,3 BRDA:111,37,1,32 BRDA:113,38,0,1 BRDA:113,38,1,34 BRDA:152,39,0,0 BRDA:152,39,1,2 BRDA:163,40,0,0 BRDA:163,40,1,109 BRDA:170,41,0,37 BRDA:170,41,1,31 BRDA:171,42,0,0 BRDA:171,42,1,68 BRDA:179,43,0,59 BRDA:179,43,1,13 BRDA:180,44,0,1 BRDA:180,44,1,12 BRDA:185,45,0,0 BRDA:185,45,1,0 BRDA:185,45,2,221 BRDA:185,45,3,1 BRDA:204,46,0,49 BRDA:204,46,1,0 BRDA:207,47,0,49 BRDA:207,47,1,0 BRDA:215,48,0,2 BRDA:215,48,1,47 BRDA:220,49,0,0 BRDA:220,49,1,47 BRDA:223,50,0,0 BRDA:223,50,1,47 BRDA:225,51,0,0 BRDA:225,51,1,47 BRDA:234,52,0,530 BRDA:234,52,1,0 BRDA:236,53,0,2 BRDA:236,53,1,528 BRDA:241,54,0,1822 BRDA:241,54,1,0 BRDA:245,55,0,0 BRDA:245,55,1,528 BRDA:245,56,0,528 BRDA:245,56,1,1 BRDA:245,56,2,0 BRDA:251,57,0,528 BRDA:251,57,1,0 BRDA:251,57,2,528 BRDA:251,57,3,522 BRDA:252,58,0,228 BRDA:252,58,1,300 BRDA:252,59,0,528 BRDA:252,59,1,525 BRDA:254,60,0,1 BRDA:254,60,1,527 BRDA:254,61,0,528 BRDA:254,61,1,68 BRDA:260,62,0,0 BRDA:260,62,1,528 BRDA:260,63,0,528 BRDA:260,63,1,461 BRDA:260,63,2,67 BRDA:261,64,0,0 BRDA:261,64,1,0 BRDA:268,65,0,1 BRDA:268,65,1,527 BRDA:268,66,0,528 BRDA:268,66,1,71 BRDA:268,66,2,5 BRDA:268,66,3,1 BRDA:272,67,0,2 BRDA:272,67,1,526 BRDA:272,68,0,528 BRDA:272,68,1,457 BRDA:272,68,2,5 BRDA:272,68,3,5 BRDA:276,69,0,0 BRDA:276,69,1,528 BRDA:276,70,0,528 BRDA:276,70,1,10 BRDA:276,70,2,7 BRDA:276,70,3,2 BRDA:279,71,0,0 BRDA:279,71,1,0 BRDA:284,72,0,0 BRDA:284,72,1,528 BRDA:284,73,0,528 BRDA:284,73,1,68 BRDA:284,73,2,0 BRDA:285,74,0,0 BRDA:285,74,1,0 BRDA:291,75,0,0 BRDA:291,75,1,528 BRDA:291,76,0,528 BRDA:291,76,1,451 BRDA:291,76,2,0 BRDA:295,77,0,0 BRDA:295,77,1,528 BRDA:295,78,0,528 BRDA:295,78,1,68 BRDA:295,78,2,0 BRDA:297,79,0,0 BRDA:297,79,1,0 BRDA:302,80,0,108 BRDA:302,80,1,420 BRDA:302,81,0,528 BRDA:302,81,1,460 BRDA:302,81,2,445 BRDA:302,81,3,108 BRDA:307,82,0,108 BRDA:307,82,1,420 BRDA:307,83,0,528 BRDA:307,83,1,457 BRDA:307,83,2,349 BRDA:307,83,3,108 BRDA:311,84,0,77 BRDA:311,84,1,451 BRDA:318,85,0,0 BRDA:318,85,1,528 BRDA:318,86,0,528 BRDA:318,86,1,460 BRDA:318,86,2,68 BRDA:322,87,0,0 BRDA:322,87,1,528 BRDA:322,88,0,528 BRDA:322,88,1,522 BRDA:322,88,2,71 BRDA:322,88,3,0 BRDA:322,88,4,0 BRDA:322,88,5,0 BRDA:326,89,0,35 BRDA:326,89,1,493 BRDA:326,90,0,528 BRDA:326,90,1,35 BRDA:326,90,2,35 BRDA:326,90,3,35 BRDA:330,91,0,0 BRDA:330,91,1,493 BRDA:330,92,0,493 BRDA:330,92,1,422 BRDA:330,92,2,0 BRDA:330,92,3,0 BRDA:334,93,0,422 BRDA:334,93,1,71 BRDA:340,94,0,2 BRDA:340,94,1,491 BRDA:344,95,0,2 BRDA:344,95,1,0 BRDA:347,96,0,1 BRDA:347,96,1,1 BRDA:349,97,0,0 BRDA:349,97,1,1 BRF:231 BRH:165 end_of_record TN: SF:src/core/parsing_grammar.js FN:1,(anonymous_1) FN:6,(anonymous_2) FN:16,(anonymous_3) FN:28,(anonymous_4) FN:31,(anonymous_5) FN:38,(anonymous_6) FN:43,(anonymous_7) FN:48,(anonymous_8) FN:60,(anonymous_9) FN:73,(anonymous_10) FN:128,(anonymous_11) FN:130,(anonymous_12) FN:174,(anonymous_13) FN:175,(anonymous_14) FN:189,(anonymous_15) FN:193,(anonymous_16) FN:196,(anonymous_17) FN:197,(anonymous_18) FN:204,(anonymous_19) FN:205,(anonymous_20) FN:212,(anonymous_21) FN:213,(anonymous_22) FN:221,(anonymous_23) FN:231,(anonymous_24) FN:232,(anonymous_25) FN:244,(anonymous_26) FN:254,(anonymous_27) FN:261,(anonymous_28) FN:301,(anonymous_29) FNF:29 FNH:28 FNDA:1,(anonymous_1) FNDA:480,(anonymous_2) FNDA:960,(anonymous_3) FNDA:1280,(anonymous_4) FNDA:3040,(anonymous_5) FNDA:480,(anonymous_6) FNDA:20,(anonymous_7) FNDA:0,(anonymous_8) FNDA:1,(anonymous_9) FNDA:160,(anonymous_10) FNDA:160,(anonymous_11) FNDA:480,(anonymous_12) FNDA:13,(anonymous_13) FNDA:10,(anonymous_14) FNDA:530,(anonymous_15) FNDA:160,(anonymous_16) FNDA:6,(anonymous_17) FNDA:6,(anonymous_18) FNDA:451,(anonymous_19) FNDA:451,(anonymous_20) FNDA:449,(anonymous_21) FNDA:449,(anonymous_22) FNDA:160,(anonymous_23) FNDA:456,(anonymous_24) FNDA:451,(anonymous_25) FNDA:91,(anonymous_26) FNDA:56,(anonymous_27) FNDA:20,(anonymous_28) FNDA:530,(anonymous_29) DA:1,1 DA:2,1 DA:3,1 DA:4,1 DA:6,1 DA:7,480 DA:10,1 DA:11,1 DA:12,1 DA:13,1 DA:15,1 DA:16,1 DA:17,960 DA:18,960 DA:19,960 DA:20,960 DA:21,960 DA:22,5440 DA:24,960 DA:26,960 DA:28,1 DA:29,1280 DA:31,1 DA:32,3040 DA:33,320 DA:35,2720 DA:38,1 DA:39,480 DA:41,1 DA:43,1 DA:44,20 DA:45,20 DA:48,1 DA:49,0 DA:50,0 DA:51,0 DA:52,0 DA:55,0 DA:57,0 DA:60,1 DA:61,1 DA:62,1 DA:63,1 DA:64,20 DA:66,1 DA:68,0 DA:72,1 DA:74,160 DA:115,160 DA:116,1760 DA:119,160 DA:121,160 DA:122,160 DA:123,160 DA:125,160 DA:126,160 DA:130,160 DA:131,480 DA:133,160 DA:168,160 DA:169,1280 DA:172,160 DA:173,160 DA:175,13 DA:176,10 DA:181,160 DA:182,160 DA:183,160 DA:185,160 DA:186,160 DA:187,160 DA:189,160 DA:190,530 DA:195,160 DA:197,6 DA:198,6 DA:203,160 DA:205,451 DA:206,451 DA:210,160 DA:211,160 DA:213,449 DA:214,449 DA:221,1 DA:223,160 DA:225,160 DA:226,160 DA:227,160 DA:230,160 DA:232,456 DA:233,451 DA:237,160 DA:239,160 DA:245,91 DA:246,91 DA:248,0 DA:255,56 DA:262,20 DA:267,160 DA:271,1 DA:276,1 DA:301,1 DA:302,530 DA:303,530 DA:304,47 DA:305,0 DA:308,530 LF:107 LH:98 BRDA:18,1,0,960 BRDA:18,1,1,0 BRDA:32,2,0,320 BRDA:32,2,1,2720 BRDA:44,3,0,20 BRDA:44,3,1,20 BRDA:50,4,0,0 BRDA:50,4,1,0 BRDA:61,5,0,1 BRDA:61,5,1,0 BRDA:190,6,0,530 BRDA:190,6,1,0 BRDA:245,7,0,91 BRDA:245,7,1,0 BRDA:304,8,0,0 BRDA:304,8,1,47 BRF:16 BRH:9 end_of_record TN: SF:src/core/parser.js FN:1,(anonymous_1) FN:105,(anonymous_2) FN:110,(anonymous_3) FN:120,(anonymous_4) FN:131,parse FN:162,(anonymous_6) FN:164,(anonymous_7) FN:203,(anonymous_8) FNF:8 FNH:5 FNDA:1,(anonymous_1) FNDA:530,(anonymous_2) FNDA:530,(anonymous_3) FNDA:2,(anonymous_4) FNDA:620,parse FNDA:0,(anonymous_6) FNDA:0,(anonymous_7) FNDA:0,(anonymous_8) DA:1,1 DA:2,1 DA:104,1 DA:106,530 DA:107,530 DA:108,530 DA:111,530 DA:112,530 DA:113,530 DA:115,0 DA:118,530 DA:121,2 DA:122,2 DA:124,2 DA:125,2 DA:127,0 DA:131,1 DA:132,620 DA:133,620 DA:134,6 DA:136,614 DA:137,3 DA:139,611 DA:141,449 DA:143,611 DA:144,81 DA:147,530 DA:148,530 DA:149,530 DA:150,528 DA:152,2 DA:157,1 DA:158,1 DA:160,1 DA:162,1 DA:163,0 DA:164,0 DA:165,0 DA:166,0 DA:167,0 DA:168,0 DA:170,0 DA:172,0 DA:173,0 DA:176,0 DA:203,1 DA:204,0 LF:47 LH:34 BRDA:107,1,0,8 BRDA:107,1,1,522 BRDA:107,2,0,530 BRDA:107,2,1,8 BRDA:118,3,0,528 BRDA:118,3,1,2 BRDA:125,4,0,0 BRDA:125,4,1,2 BRDA:125,5,0,2 BRDA:125,5,1,2 BRDA:133,6,0,6 BRDA:133,6,1,614 BRDA:136,7,0,3 BRDA:136,7,1,611 BRDA:139,8,0,449 BRDA:139,8,1,162 BRDA:139,9,0,611 BRDA:139,9,1,596 BRDA:139,9,2,591 BRDA:139,9,3,520 BRDA:141,10,0,449 BRDA:141,10,1,372 BRDA:143,11,0,81 BRDA:143,11,1,530 BRDA:143,12,0,611 BRDA:143,12,1,81 BRDA:149,13,0,528 BRDA:149,13,1,2 BRDA:157,14,0,1 BRDA:157,14,1,0 BRDA:172,15,0,0 BRDA:172,15,1,0 BRF:32 BRH:28 end_of_record TN: SF:src/core/extras.js FN:1,(anonymous_1) FN:5,(anonymous_2) FN:82,(anonymous_3) FN:85,(anonymous_4) FN:135,(anonymous_5) FN:143,(anonymous_6) FN:159,(anonymous_7) FN:160,(anonymous_8) FN:175,(anonymous_9) FN:191,(anonymous_10) FN:288,(anonymous_11) FN:289,(anonymous_12) FN:302,(anonymous_13) FNF:13 FNH:12 FNDA:1,(anonymous_1) FNDA:0,(anonymous_2) FNDA:166,(anonymous_3) FNDA:81,(anonymous_4) FNDA:6,(anonymous_5) FNDA:166,(anonymous_6) FNDA:8,(anonymous_7) FNDA:166,(anonymous_8) FNDA:2,(anonymous_9) FNDA:2,(anonymous_10) FNDA:3,(anonymous_11) FNDA:6,(anonymous_12) FNDA:3,(anonymous_13) DA:1,1 DA:2,1 DA:6,0 DA:7,0 DA:9,0 DA:30,1 DA:81,1 DA:83,166 DA:86,81 DA:87,81 DA:89,0 DA:91,0 DA:93,0 DA:95,0 DA:97,0 DA:100,0 DA:102,0 DA:105,0 DA:107,0 DA:110,0 DA:112,0 DA:114,0 DA:116,0 DA:118,0 DA:120,0 DA:121,0 DA:123,0 DA:124,0 DA:126,1 DA:128,0 DA:130,0 DA:132,0 DA:136,6 DA:138,0 DA:140,6 DA:144,166 DA:145,166 DA:146,166 DA:147,85 DA:149,81 DA:151,81 DA:152,1 DA:154,80 DA:159,1 DA:160,8 DA:161,166 DA:175,1 DA:176,2 DA:177,2 DA:191,1 DA:192,2 DA:193,2 DA:288,1 DA:289,3 DA:290,6 DA:291,6 DA:292,0 DA:295,6 DA:296,6 DA:297,6 DA:298,6 DA:302,1 DA:303,3 DA:304,3 DA:305,1 DA:307,2 DA:311,1 DA:312,1 LF:68 LH:42 BRDA:6,1,0,0 BRDA:6,1,1,0 BRDA:87,2,0,0 BRDA:87,2,1,0 BRDA:87,2,2,0 BRDA:87,2,3,0 BRDA:87,2,4,0 BRDA:87,2,5,0 BRDA:87,2,6,0 BRDA:87,2,7,0 BRDA:87,2,8,0 BRDA:87,2,9,0 BRDA:87,2,10,0 BRDA:87,2,11,0 BRDA:87,2,12,0 BRDA:87,2,13,0 BRDA:87,2,14,0 BRDA:87,2,15,0 BRDA:87,2,16,0 BRDA:87,2,17,1 BRDA:87,2,18,0 BRDA:87,2,19,0 BRDA:87,2,20,0 BRDA:97,3,0,0 BRDA:97,3,1,0 BRDA:116,4,0,0 BRDA:116,4,1,0 BRDA:136,5,0,0 BRDA:136,5,1,6 BRDA:144,6,0,166 BRDA:144,6,1,160 BRDA:146,7,0,85 BRDA:146,7,1,81 BRDA:151,8,0,1 BRDA:151,8,1,80 BRDA:291,9,0,0 BRDA:291,9,1,6 BRDA:291,10,0,6 BRDA:291,10,1,6 BRDA:297,11,0,6 BRDA:297,11,1,0 BRDA:304,12,0,1 BRDA:304,12,1,2 BRDA:311,13,0,1 BRDA:311,13,1,0 BRF:45 BRH:15 end_of_record TN: SF:src/core/time_period.js FN:1,(anonymous_1) FN:4,(anonymous_2) FN:5,(anonymous_3) FN:10,(anonymous_4) FN:11,(anonymous_5) FN:16,(anonymous_6) FN:25,(anonymous_7) FN:26,inc FN:48,(anonymous_9) FN:60,(anonymous_10) FN:85,(anonymous_11) FNF:11 FNH:4 FNDA:1,(anonymous_1) FNDA:7,(anonymous_2) FNDA:0,(anonymous_3) FNDA:7,(anonymous_4) FNDA:0,(anonymous_5) FNDA:1,(anonymous_6) FNDA:0,(anonymous_7) FNDA:0,inc FNDA:0,(anonymous_9) FNDA:0,(anonymous_10) FNDA:0,(anonymous_11) DA:1,1 DA:3,1 DA:4,1 DA:5,7 DA:6,0 DA:10,1 DA:11,7 DA:12,0 DA:13,0 DA:16,1 DA:17,1 DA:18,7 DA:19,7 DA:20,7 DA:21,7 DA:25,1 DA:26,1 DA:27,0 DA:28,0 DA:29,0 DA:30,0 DA:31,0 DA:34,0 DA:35,0 DA:36,0 DA:39,0 DA:40,0 DA:43,0 DA:44,0 DA:45,0 DA:48,1 DA:49,0 DA:50,0 DA:51,0 DA:52,0 DA:53,0 DA:60,1 DA:61,0 DA:62,0 DA:63,0 DA:64,0 DA:65,0 DA:66,0 DA:67,0 DA:72,0 DA:73,0 DA:75,0 DA:76,0 DA:77,0 DA:78,0 DA:81,0 DA:84,1 DA:85,1 DA:86,0 DA:87,0 DA:88,0 DA:89,0 DA:90,0 DA:91,0 DA:92,0 DA:95,1 DA:97,1 DA:99,1 LF:63 LH:21 BRDA:29,1,0,0 BRDA:29,1,1,0 BRDA:34,2,0,0 BRDA:34,2,1,0 BRDA:50,3,0,0 BRDA:50,3,1,0 BRDA:50,4,0,0 BRDA:50,4,1,0 BRDA:52,5,0,0 BRDA:52,5,1,0 BRDA:61,6,0,0 BRDA:61,6,1,0 BRDA:63,7,0,0 BRDA:63,7,1,0 BRDA:63,8,0,0 BRDA:63,8,1,0 BRDA:63,8,2,0 BRDA:66,9,0,0 BRDA:66,9,1,0 BRDA:76,10,0,0 BRDA:76,10,1,0 BRDA:86,11,0,0 BRDA:86,11,1,0 BRDA:87,12,0,0 BRDA:87,12,1,0 BRDA:88,13,0,0 BRDA:88,13,1,0 BRDA:89,14,0,0 BRDA:89,14,1,0 BRDA:90,15,0,0 BRDA:90,15,1,0 BRDA:91,16,0,0 BRDA:91,16,1,0 BRDA:92,17,0,0 BRDA:92,17,1,0 BRDA:97,18,0,1 BRDA:97,18,1,0 BRF:37 BRH:1 end_of_record TN: SF:src/core/time_span.js FN:1,(anonymous_1) FN:3,(anonymous_2) FN:4,(anonymous_3) FN:9,(anonymous_4) FN:10,(anonymous_5) FN:16,(anonymous_6) FN:29,(anonymous_7) FN:46,(anonymous_8) FN:53,(anonymous_9) FN:64,(anonymous_10) FN:68,(anonymous_11) FN:72,(anonymous_12) FN:76,(anonymous_13) FN:80,(anonymous_14) FN:84,(anonymous_15) FN:88,(anonymous_16) FN:92,(anonymous_17) FN:96,(anonymous_18) FN:100,(anonymous_19) FN:104,(anonymous_20) FN:105,(anonymous_21) FN:113,(anonymous_22) FN:120,(anonymous_23) FN:153,(anonymous_24) FN:166,(anonymous_25) FNF:25 FNH:4 FNDA:1,(anonymous_1) FNDA:5,(anonymous_2) FNDA:0,(anonymous_3) FNDA:5,(anonymous_4) FNDA:0,(anonymous_5) FNDA:1,(anonymous_6) FNDA:0,(anonymous_7) FNDA:0,(anonymous_8) FNDA:0,(anonymous_9) FNDA:0,(anonymous_10) FNDA:0,(anonymous_11) FNDA:0,(anonymous_12) FNDA:0,(anonymous_13) FNDA:0,(anonymous_14) FNDA:0,(anonymous_15) FNDA:0,(anonymous_16) FNDA:0,(anonymous_17) FNDA:0,(anonymous_18) FNDA:0,(anonymous_19) FNDA:0,(anonymous_20) FNDA:0,(anonymous_21) FNDA:0,(anonymous_22) FNDA:0,(anonymous_23) FNDA:0,(anonymous_24) FNDA:0,(anonymous_25) DA:1,1 DA:3,1 DA:4,5 DA:5,0 DA:9,1 DA:10,5 DA:11,0 DA:12,0 DA:15,1 DA:16,1 DA:17,1 DA:18,5 DA:19,5 DA:20,5 DA:21,5 DA:29,1 DA:30,0 DA:31,0 DA:32,0 DA:33,0 DA:34,0 DA:35,0 DA:36,0 DA:37,0 DA:38,0 DA:39,0 DA:40,0 DA:41,0 DA:43,0 DA:46,0 DA:47,0 DA:53,0 DA:54,0 DA:55,0 DA:56,0 DA:59,0 DA:61,0 DA:64,0 DA:65,0 DA:68,0 DA:69,0 DA:72,0 DA:73,0 DA:76,0 DA:77,0 DA:80,0 DA:81,0 DA:84,0 DA:85,0 DA:88,0 DA:89,0 DA:92,0 DA:93,0 DA:96,0 DA:97,0 DA:100,0 DA:101,0 DA:104,0 DA:105,0 DA:106,0 DA:107,0 DA:109,0 DA:113,0 DA:114,0 DA:117,0 DA:119,0 DA:121,0 DA:123,0 DA:125,0 DA:127,0 DA:129,0 DA:131,0 DA:133,0 DA:135,0 DA:137,0 DA:139,0 DA:141,0 DA:143,0 DA:145,0 DA:150,0 DA:152,1 DA:153,1 DA:154,0 DA:155,0 DA:156,0 DA:157,0 DA:158,0 DA:166,1 DA:167,0 DA:170,1 DA:172,1 DA:174,1 LF:92 LH:19 BRDA:30,1,0,0 BRDA:30,1,1,0 BRDA:30,2,0,0 BRDA:30,2,1,0 BRDA:31,3,0,0 BRDA:31,3,1,0 BRDA:55,4,0,0 BRDA:55,4,1,0 BRDA:61,5,0,0 BRDA:61,5,1,0 BRDA:61,6,0,0 BRDA:61,6,1,0 BRDA:69,7,0,0 BRDA:69,7,1,0 BRDA:73,8,0,0 BRDA:73,8,1,0 BRDA:97,9,0,0 BRDA:97,9,1,0 BRDA:97,10,0,0 BRDA:97,10,1,0 BRDA:101,11,0,0 BRDA:101,11,1,0 BRDA:106,12,0,0 BRDA:106,12,1,0 BRDA:106,13,0,0 BRDA:106,13,1,0 BRDA:114,14,0,0 BRDA:114,14,1,0 BRDA:119,15,0,0 BRDA:119,15,1,0 BRDA:121,16,0,0 BRDA:121,16,1,0 BRDA:121,16,2,0 BRDA:121,16,3,0 BRDA:121,16,4,0 BRDA:121,16,5,0 BRDA:121,16,6,0 BRDA:121,16,7,0 BRDA:121,16,8,0 BRDA:121,16,9,0 BRDA:121,16,10,0 BRDA:121,16,11,0 BRDA:143,17,0,0 BRDA:143,17,1,0 BRDA:145,18,0,0 BRDA:145,18,1,0 BRDA:154,19,0,0 BRDA:154,19,1,0 BRDA:155,20,0,0 BRDA:155,20,1,0 BRDA:156,21,0,0 BRDA:156,21,1,0 BRDA:157,22,0,0 BRDA:157,22,1,0 BRDA:158,23,0,0 BRDA:158,23,1,0 BRDA:172,24,0,1 BRDA:172,24,1,0 BRF:58 BRH:1 end_of_record ================================================ FILE: specs/Core-spec.js ================================================ /*globals require, jasmine, describe, it, expect, spyOn */ if (typeof process !== "undefined") { process.env.TZ = 'America/Los_Angeles'; } if (typeof require === "function") { require("../index.js"); } describe("Core Module", function() { describe("has Exception handling for when", function() { it("no params are passed to Date.parse()", function() { var d = Date.parse(""); expect(Date.parse.bind(null)).not.toThrow(); expect(d).toBe(null); }); it("an empty string is passed to Date.parse()", function() { var d = Date.parse(""); expect(Date.parse.bind(null, "")).not.toThrow(); expect(d).toBe(null); }); it("a junk string is passed to Date.parse()", function() { expect(Date.parse.bind(null, "randomstring")).not.toThrow(); var d = Date.parse("randomstring"); expect(d).toBe(null); }); it("null is passed to Date.parse()", function() { expect(Date.parse.bind(null, null)).not.toThrow(); var d = Date.parse(null); expect(d).toBe(null); }); }); describe("throws Exceptions when", function() { it("compares a valid date to an invalid date", function() { var d = new Date(""); expect(d.compareTo.bind(d, new Date())).toThrow(); }); it("checks quality of a valid date to an invalid date", function() { var d = new Date(""); expect(d.equals.bind(d, new Date())).toThrow(); }); it("checks equality of a valid date to an invalid date", function() { var d = new Date(""); expect(d.equals.bind(d, new Date())).toThrow(); }); it("compares a valid date to invalid type", function() { var d = new Date(); expect(d.compareTo.bind(d, 0)).toThrow(new TypeError(d+ " - " + 0)); }); it("checks equality of a valid date with an invalid type", function() { var d = new Date(); expect(d.equals.bind(d, 0)).toThrow(new TypeError(d+ " - " + 0)); }); it("compares a valid date to invalid date", function() { var d = new Date(); expect(d.compareTo.bind(d, new Date(""))).toThrow(); }); it("checks equality of a valid date with an invalid date", function() { var d = new Date(); expect(d.equals.bind(d, new Date(""))).toThrow(); }); }); describe("has basic functionality that",function (){ it("sets up (and creates if required) overloaded Date.now", function(){ var n = Date._now; Date.now = undefined; Date._now = undefined; Date.initOverloads(); expect(typeof Date.now).toBe("function"); expect(typeof Date._now).toBe("function"); expect(typeof Date._now()).toBe("number"); Date.now = n; Date._now = undefined; Date.initOverloads(); // will now only created _now with our date.now expect(typeof Date.now).toBe("function"); expect(typeof Date._now).toBe("function"); }); it("creates toISOString if no browser support", function(){ var s = Date.prototype.toISOString; Date.prototype.toISOString = undefined; Date.initOverloads(); expect(typeof Date.prototype.toISOString).toBe("function"); var d = new Date(); var i = d.toISOString(); expect(typeof i).toBe("string"); Date.toISOString = s; }); it("aliases native toString if present", function(){ var s = Date.prototype._toString; Date.prototype._toString = undefined; Date.initOverloads(); expect(typeof Date.prototype._toString).toBe("function"); Date.prototype._toString = s; }); it("zeros the time", function(){ var d = new Date(); d.clearTime(); expect(d.getHours()).toBe(0); expect(d.getMinutes()).toBe(0); expect(d.getSeconds()).toBe(0); expect(d.getMilliseconds()).toBe(0); }); it("updates time to now", function(){ var d = new Date(1995, 1,1,1,1,1,1); var d2; d.setTimeToNow(); d2 = new Date(); expect(d.getHours()).toBe(d2.getHours()); expect(d.getMinutes()).toBe(d2.getMinutes()); expect(d.getSeconds()).toBe(d2.getSeconds()); expect(d.getMilliseconds()).toBe(d2.getMilliseconds()); }); it("allows chainable todays date with Date.today()", function(){ var d = Date.today(); var d2 = new Date(); expect(d.getHours()).toBe(0); expect(d.getMinutes()).toBe(0); expect(d.getSeconds()).toBe(0); expect(d.getMilliseconds()).toBe(0); expect(d.getDate()).toBe(d2.getDate()); expect(d.getMonth()).toBe(d2.getMonth()); expect(d.getFullYear()).toBe(d2.getFullYear()); }); it("allows chainable todays date and time with Date.present()", function(){ var d = Date.present(); var d2 = new Date(); expect(d.getHours()).toBe(d2.getHours()); expect(d.getMinutes()).toBe(d2.getMinutes()); expect(d.getSeconds()).toBe(d2.getSeconds()); expect(d.getMilliseconds()).toBe(d2.getMilliseconds()); expect(d.getDate()).toBe(d2.getDate()); expect(d.getMonth()).toBe(d2.getMonth()); expect(d.getFullYear()).toBe(d2.getFullYear()); }); it("extends Date.now() to also be able to return a Date Object", function(){ var d = Date.now(); var d2 = Date.now(true); expect(d).toEqual(jasmine.any(Number)); expect(d2).toEqual(jasmine.any(Date)); }); it("gets the Day Name from the Day Number", function(){ expect(Date.getDayName(5)).toBe("Friday"); }); it("gets the Day Number from the Day Name", function(){ expect(Date.getDayNumberFromName("Sunday")).toBe(0); expect(Date.getDayNumberFromName("Sun")).toBe(0); expect(Date.getDayNumberFromName("Su")).toBe(0); expect(Date.getDayNumberFromName("Monday")).toBe(1); expect(Date.getDayNumberFromName("Mon")).toBe(1); expect(Date.getDayNumberFromName("Mo")).toBe(1); expect(Date.getDayNumberFromName("Tuesday")).toBe(2); expect(Date.getDayNumberFromName("Tue")).toBe(2); expect(Date.getDayNumberFromName("Tu")).toBe(2); expect(Date.getDayNumberFromName("Wednesday")).toBe(3); expect(Date.getDayNumberFromName("Wed")).toBe(3); expect(Date.getDayNumberFromName("We")).toBe(3); expect(Date.getDayNumberFromName("Thursday")).toBe(4); expect(Date.getDayNumberFromName("Thu")).toBe(4); expect(Date.getDayNumberFromName("Th")).toBe(4); expect(Date.getDayNumberFromName("Friday")).toBe(5); expect(Date.getDayNumberFromName("Fri")).toBe(5); expect(Date.getDayNumberFromName("Fr")).toBe(5); expect(Date.getDayNumberFromName("Saturday")).toBe(6); expect(Date.getDayNumberFromName("Sat")).toBe(6); expect(Date.getDayNumberFromName("Sa")).toBe(6); expect(Date.getDayNumberFromName("NotARealDay")).toBe(-1); }); it("gets the Month Name from the Month Number", function(){ expect(Date.getMonthName(5)).toBe("June"); }); it("gets the Month Number from the Month Name", function(){ expect(Date.getMonthNumberFromName("January")).toBe(0); expect(Date.getMonthNumberFromName("Jan")).toBe(0); expect(Date.getMonthNumberFromName("February")).toBe(1); expect(Date.getMonthNumberFromName("Feb")).toBe(1); expect(Date.getMonthNumberFromName("March")).toBe(2); expect(Date.getMonthNumberFromName("Mar")).toBe(2); expect(Date.getMonthNumberFromName("April")).toBe(3); expect(Date.getMonthNumberFromName("Apr")).toBe(3); expect(Date.getMonthNumberFromName("May")).toBe(4); expect(Date.getMonthNumberFromName("June")).toBe(5); expect(Date.getMonthNumberFromName("Jun")).toBe(5); expect(Date.getMonthNumberFromName("July")).toBe(6); expect(Date.getMonthNumberFromName("Jul")).toBe(6); expect(Date.getMonthNumberFromName("August")).toBe(7); expect(Date.getMonthNumberFromName("Aug")).toBe(7); expect(Date.getMonthNumberFromName("September")).toBe(8); expect(Date.getMonthNumberFromName("Sep")).toBe(8); expect(Date.getMonthNumberFromName("October")).toBe(9); expect(Date.getMonthNumberFromName("Oct")).toBe(9); expect(Date.getMonthNumberFromName("November")).toBe(10); expect(Date.getMonthNumberFromName("Nov")).toBe(10); expect(Date.getMonthNumberFromName("December")).toBe(11); expect(Date.getMonthNumberFromName("Dec")).toBe(11); expect(Date.getMonthNumberFromName("NotARealMonth")).toBe(-1); }); it("can check if a year is a leap year or not", function() { expect(Date.isLeapYear(2008)).toBe(true); expect(Date.isLeapYear(1995)).toBe(false); }); it("can get the number of days in a given month", function() { var leap = Date.isLeapYear(Date.today().getFullYear()) ? 29 : 28; expect(Date.getDaysInMonth(0)).toBe(31); expect(Date.getDaysInMonth(1)).toBe(leap); expect(Date.getDaysInMonth(2)).toBe(31); expect(Date.getDaysInMonth(3)).toBe(30); expect(Date.getDaysInMonth(4)).toBe(31); expect(Date.getDaysInMonth(5)).toBe(30); expect(Date.getDaysInMonth(6)).toBe(31); expect(Date.getDaysInMonth(7)).toBe(31); expect(Date.getDaysInMonth(8)).toBe(30); expect(Date.getDaysInMonth(9)).toBe(31); expect(Date.getDaysInMonth(10)).toBe(30); expect(Date.getDaysInMonth(11)).toBe(31); }); it("can get the number of days in a given month and year including leap years", function() { expect(Date.getDaysInMonth(2009, 1)).toBe(28); expect(Date.getDaysInMonth(2008, 1)).toBe(29); }); it("can get the Timezone abbrivation with or without Daylight Savings Time", function() { expect(Date.getTimezoneAbbreviation("+0100", false)).toBe("CET"); expect(Date.getTimezoneAbbreviation("+0100", true)).toBe("BST"); expect(Date.getTimezoneAbbreviation("NotARealOffset")).toBeNull(); }); it("can get the Timezone offset from the abbrivation", function() { expect(Date.getTimezoneOffset("CET")).toBe("+0100"); expect(Date.getTimezoneOffset("BST", true)).toBe("+0100"); // forces dst priority expect(Date.getTimezoneOffset("BST")).toBe("+0600"); // Bangladesh Standard Time expect(Date.getTimezoneOffset("NotARealTimeZone")).toBeNull(); }); it("can get the correct Quarter a Date is in", function() { var d = new Date(1995, 11, 4, 0, 0, 0, 0); expect(Date.getQuarter(d)).toBe(4); }); it("can get the correct number of days left in a Quarter", function() { var d = new Date(1995, 11, 4, 0, 0, 0, 0); expect(Date.getDaysLeftInQuarter(d)).toBe(27); }); it("can clone Dates", function() { var d = new Date(1995, 11, 4, 0, 0, 0, 0); var d2 = d.clone(); expect(d2.getTime()).toBe(d.getTime()); }); }); describe("can Compare dates like",function (){ it("today == today", function() { expect(Date.today().compareTo(Date.today())).toBe(0); }); it("today > yesterday", function() { expect(Date.today().compareTo(Date.today().addDays(-1))).toBe(1); }); it("today < tomorrow", function() { expect(Date.today().compareTo(Date.today().addDays(1))).toBe(-1); }); }); describe("can check Equality of",function (){ it("today == today", function() { expect(Date.today().equals(Date.today())).toBe(true); }); it("today != yesterday", function() { expect(Date.today().equals(Date.today().addDays(-1))).not.toBe(true); }); it("today != tomorrow", function() { expect(Date.today().equals(Date.today().addDays(1))).not.toBe(true); }); }); describe("can check relativity like if a Date",function (){ it("is between dates", function() { var d = new Date(1995,11,4); var b = d.between(new Date(1994, 0), new Date(1996, 0)); expect(b).toBe(true); }); it("is after a date", function() { var d = new Date(1995,11,4); var a = d.isAfter(new Date(1996, 0)); var b = d.isAfter(new Date(1994, 0)); expect(a).toBe(false); expect(b).toBe(true); }); it("is before a date", function() { var d = new Date(1995,11,4); var a = d.isBefore(new Date(1996, 0)); var b = d.isBefore(new Date(1994, 0)); expect(a).toBe(true); expect(b).toBe(false); }); it("is today", function() { var d = Date.today(); expect(d.isToday()).toBe(true); }); it("is same day", function() { var d = new Date(1995,11,4); var d2 = new Date(1995,11,4); expect(d.isSameDay(d2)).toBe(true); }); }); describe("can get and set Date attributes like",function (){ it("get the week number", function() { var d = new Date(1995,11,4); expect(d.getWeek()).toBe(49); }); it("get the ISO week number", function() { var d = new Date(1995,11,4); expect(d.getISOWeek()).toBe("49"); }); it("get the days left in the Quarter", function() { var d = new Date(1995,11,4); expect(d.getDaysLeftInQuarter()).toBe(27); }); it("get the ordinate of the current date", function() { var d = new Date(1995,11,4); expect(d.getOrdinate()).toBe("th"); }); it("get the ordinal day number of the current date", function() { var d = new Date(1995,11,4); expect(d.getOrdinalNumber()).toBe(338); }); it("get the UTCOffset of a date", function() { var d = new Date(1995,11,4); expect(d.getUTCOffset(480)).toBe("-0800"); expect(d.getUTCOffset(-480)).toBe("+0800"); }); it("get the time elapsed between current date and supplied date", function() { var d = new Date(1995,11,4); var d2 = new Date(1995,11,4,0,0,0,250); expect(d.getElapsed(d2)).toBe(250); }); it("move to the first day of the month", function() { var d = new Date(1995,1,3); d.moveToFirstDayOfMonth(); expect(d.getDate()).toBe(1); }); it("move to the last day of the month", function() { var d = new Date(1995,1,3); var d2 = new Date(2004,1,3); d.moveToLastDayOfMonth(); d2.moveToLastDayOfMonth(); expect(d.getDate()).toBe(28); expect(d2.getDate()).toBe(29); }); it("move to the nth occurance of a weekday in the month", function() { var d = new Date(1995,11,4); d.moveToNthOccurrence(0, -1); // sunday, last occurrence expect(d.getDate()).toBe(31); d.moveToNthOccurrence(6, -1); // saturday, last occurrence expect(d.getDate()).toBe(30); d.moveToNthOccurrence(0, 1); // sunday, 1st occurrence expect(d.getDate()).toBe(3); d.moveToNthOccurrence(0, 2); // sunday, 2nd occurrence expect(d.getDate()).toBe(10); d.moveToNthOccurrence(0, 3); // sunday, 3rd occurrence expect(d.getDate()).toBe(17); d.moveToNthOccurrence(0, 4); // sunday, 4th occurrence expect(d.getDate()).toBe(24); d.moveToNthOccurrence(0, 5); // sunday, 5th occurrence expect(d.getDate()).toBe(31); d.moveToNthOccurrence("Weekday", 1); // first weekday expect(d.getDate()).toBe(1); d.moveToNthOccurrence("Weekday", -1); // last weekday expect(d.getDate()).toBe(29); d = new Date(1995,11,4); d.moveToNthOccurrence("Weekday", 0); // does nothing expect(d.getDate()).toBe(4); d = new Date(1995,10,4); d.moveToNthOccurrence("Weekday", -1); // last weekday, when last day is weekday expect(d.getDate()).toBe(30); }); it("move to a month - changing year if appropriate", function() { var d = new Date(1995,11,4); d.moveToMonth(3); expect(d.getMonth()).toBe(3); expect(d.getFullYear()).toBe(1996); d.moveToMonth(11, -1); expect(d.getMonth()).toBe(11); expect(d.getFullYear()).toBe(1995); }); }); describe("can set Date attributes like",function (){ it("milliseconds", function() { var d = new Date(2010, 1, 1); var t = d.getTime(); d.set({millisecond: 250}); expect(d.getTime()).toBe(t+250); }); it("seconds", function() { var d = new Date(2010, 1, 1); var t = d.getTime(); d.set({second: 3}); expect(d.getTime()).toBe(t+3000); }); it("minutes", function() { var d = new Date(2010, 1, 1); d.set({minute: 30}); expect(d.getMinutes()).toBe(30); }); it("hours", function() { var d = new Date(2010, 1, 1); d.set({hour: 1}); expect(d.getHours()).toBe(1); }); it("add weekdays", function() { var d = new Date(2010, 1, 1); d.addWeekdays(4); expect(d.getDay()).toBe(5); d.addWeekdays(1); expect(d.getDay()).toBe(1); d.next().sunday(); d.addWeekdays(1); expect(d.getDay()).toBe(1); d.next().monday(); d.addWeekdays(-1); expect(d.getDay()).toBe(5); d.next().sunday(); d.addWeekdays(-1); expect(d.getDay()).toBe(5); d.next().sunday(); d.addDays(-1); d.addWeekdays(2); expect(d.getDay()).toBe(2); }); it("day", function() { var d1 = new Date(2010, 1, 1); var d2 = new Date(2010, 1, 10); d2.set({day: 1}); expect(d1.equals(d2)).toBe(true); }); it("weeks", function() { var d = new Date(2013, 1, 1); var w = d.getWeek(); d.addWeeks(1); expect(d.getWeek()).toBe(w+1); d.setWeek(16); expect(d.getDate()).toBe(15); expect(d.getMonth()).toBe(3); d.set({week: 5}); expect(d.getDate()).toBe(28); expect(d.getMonth()).toBe(0); // bug check d = new Date(2014, 11, 22) // Mon Dec 22 2014 00:00:00 GMT d.setWeek(52); expect(d.getDate()).toBe(22); expect(d.getMonth()).toBe(11); expect(d.getFullYear()).toBe(2014); }); it("month", function() { var d1 = new Date(2010, 1, 1); var d2 = new Date(2010, 2, 1); d2.set({month: 1}); expect(d1.equals(d2)).toBe(true); }); it("quarter", function() { var d1 = new Date(2010, 1, 1); var d2 = new Date(2010, 4, 1); var d3 = new Date(2010, 1, 1); d1.addQuarters(1); expect(d1.equals(d2)).toBe(true); expect(d1.getQuarter()).toBe(2); d1.setQuarter(1); expect(d1.equals(d3)).toBe(true); expect(d1.getQuarter()).toBe(1); }); it("timezone", function() { var d1 = new Date(2010, 1, 1); var d2 = d1.clone().add(-8).hours(); d1.set({timezone: "GMT"}); expect(d1.equals(d2)).toBe(true); }); it("timezone offset", function() { var d1 = new Date(2010, 1, 1); var d2 = d1.clone().add(-3).hours(); var d3 = d1.clone(); var d4 = d1.clone().add(-9).hours(); d1.set({timezoneOffset: "-0500"}); expect(d1.equals(d2)).toBe(true); d3.set({timezoneOffset: "+0100"}); expect(d3.equals(d4)).toBe(true); }); // timezoneOffset it("year", function() { var d1 = new Date(2010, 1, 1); var d2 = new Date(2011, 1, 1); d2.set({year: 2010}); expect(d1.equals(d2)).toBe(true); }); it("year, but throws an exception when type is wrong", function() { var d = new Date(2010, 1, 1); expect(d.set.bind(d, {year: "string"})).toThrow(new TypeError("string is not a Number.")); }); it("year from leap day and preserve the month", function() { var d1 = new Date(2009, 1, 28); var d2 = new Date(2008, 1, 29); d2.set({year: 2009}); expect(d1.equals(d2)).toBe(true); }); it("month and adjust to correct last day of month", function() { var d1 = new Date(2009, 1, 28); var d2 = new Date(2009, 0, 31); d2.set({month: 1}); expect(d1.equals(d2)).toBe(true); }); it("month and adjust correctly to a leap day", function() { var d1 = new Date(2008, 1, 29); var d2 = new Date(2008, 2, 31); d2.set({month: 1}); expect(d1.equals(d2)).toBe(true); }); it("same day", function() { var d1 = new Date(2008, 1, 29); var d2 = new Date(2008, 1, 29); d2.set({day: 29}); expect(d1.equals(d2)).toBe(true); }); it("same month", function() { var d1 = new Date(2008, 1, 29); var d2 = new Date(2008, 1, 29); d2.set({month: 1}); expect(d1.equals(d2)).toBe(true); }); it("same year", function() { var d1 = new Date(2008, 1, 29); var d2 = new Date(2008, 1, 29); d2.set({year: 2008}); expect(d1.equals(d2)).toBe(true); }); it("day, ignoring invalid month, year, and milliseconds", function() { var d1 = new Date(2010, 1, 1); var d2 = new Date(2010, 1, 10); d2.set({day: 1, month: 24, year: -271823, milliseconds: 20000}); expect(d1.equals(d2)).toBe(true); }); it("can add to any property", function() { var d = new Date(2010, 0, 1); var d2 = new Date(2011, 1, 9, 10, 10, 10, 10); d.add({ milliseconds: 10, seconds: 10, minutes: 10, hours: 10, weeks: 1, months: 1, years: 1, days: 1 }); expect(d.equals(d2)).toBe(true); d.add(1).day(); d2 = new Date(2011, 1, 10, 10, 10, 10, 10); expect(d.equals(d2)).toBe(true); }); it("validates undefined values correctly", function () { expect(Date.validateSecond(undefined)).toBe(false); }); }); describe("has Timezone support that", function() { it("can check if the current location has Daylight Savings Time", function() { var d = Date.today(); expect(d.hasDaylightSavingTime()).toBe(true); }); it("can check if a date is in Daylight Savings Time", function() { var d = new Date(2013, 6, 1); expect(d.isDaylightSavingTime()).toBe(true); d.set({month: 11}); expect(d.isDaylightSavingTime()).toBe(false); }); it("can get the current timezone", function() { var d = Date.today(); if (d.isDaylightSavingTime()) { expect(d.getTimezone()).toBe("PDT"); } else { expect(d.getTimezone()).toBe("PST"); } }); }); describe("can convert Date toString in various formats", function(){ var d = new Date(1995, 11, 4, 0, 0, 0, 0); describe("has CultureInfo defined standard formats", function(){ it("d == shortDate", function() { expect(d.toString("d")).toBe("12/4/1995"); }); it("D == longDate", function() { expect(d.toString("D")).toBe("Monday, December 04, 1995"); }); it("F == fullDateTime", function() { expect(d.toString("F")).toBe("Monday, December 04, 1995 12:00:00 AM"); }); it("m == monthDay", function() { expect(d.toString("m")).toBe("December 04"); }); it("r == RFC1123", function() { expect(d.toString("r")).toBe("Mon, 04 Dec 1995 08:00:00 GMT"); expect(d.toString("R")).toBe("Mon, 04 Dec 1995 08:00:00 GMT"); }); it("s == sortableDateTime", function() { expect(d.toString("s")).toBe("1995-12-04T00:00:00"); }); it("t == shortTime", function() { expect(d.toString("t")).toBe("12:00 AM"); }); it("T == longTime", function() { expect(d.toString("T")).toBe("12:00:00 AM"); }); it("u == universalSortableDateTime", function() { expect(d.toString("u")).toBe("1995-12-04 08:00:00Z"); }); it("y == yearMonth", function() { expect(d.toString("y")).toBe("December, 1995"); }); it("W == Week Number", function() { expect(d.toString("W")).toBe("49"); var d2 = d.clone(); d2.addWeeks(4); expect(d2.toString("W")).toBe("1"); }); it("WW == ISO Week Number", function() { var d2 = d.clone(); d2.addWeeks(4); expect(d2.toString("WW")).toBe("01"); }); }); it("doesn't parse strings between [ and ]", function() { expect(d.toString("[the date is] MM/dd/yyyy")).toBe("the date is 12/04/1995"); }); it("hh:mm tt", function() { expect(d.toString("hh:mm tt")).toBe("12:00 AM"); }); it("MMMM dddd, yyyy - hh:mm:ss tt", function() { expect(d.toString("MMMM dd, yyyy - hh:mm:ss tt")).toBe("December 04, 1995 - 12:00:00 AM"); }); it("MMM dS, 'yy - HH:mm", function() { expect(d.toString("MMM dS, 'yy - HH:mm")).toBe("Dec 4th, '95 - 00:00"); }); it("ddd dS @ h:mmt", function() { expect(d.toString("ddd dS @ h:mmt")).toBe("Mon 4th @ 12:00A"); }); it("MM/dd/yyyy", function() { expect(d.toString("MM/dd/yyyy")).toBe("12/04/1995"); }); it("dddd H m s", function() { var d2 = d.clone(); d2.set({minute: 14, second: 12}); expect(d2.toString("dddd H m s")).toBe("Monday 0 14 12"); }); it("fixes incorrectly escaped characters", function() { expect(d.toString("\\MM/\\dd/\\yyyy")).toBe("MM/dd/yyyy"); }); it("returns unknown string unchanged", function() { expect(d.toString("xxxxxzxz")).toBe("xxxxxzxz"); }); it("works with different ordinal suffixes (1st,2nd,3rd,4th..)", function() { expect(d.toString("S")).toBe("th"); d.addDays(-1); expect(d.toString("S")).toBe("rd"); d.addDays(-1); expect(d.toString("S")).toBe("nd"); d.addDays(-1); expect(d.toString("S")).toBe("st"); }); it("can output quarters with 'q' and 'Q'", function() { expect(d.toString("Q")).toBe("Q4"); expect(d.toString("q")).toBe("4"); }); }); }); ================================================ FILE: specs/DateMath-spec.js ================================================ /*globals require, describe, it, expect */ if (typeof process !== "undefined") { process.env.TZ = "America/Los_Angeles"; } if (typeof require === "function") { require("../index.js"); } describe("Date Math operations support", function() { beforeEach(function() { this.d = Date.today(); }); it("t and today ", function () { var d2 = Date.parse("t"); var d3 = Date.parse("today"); expect(this.d.equals(d2)).toBe(true); expect(this.d.equals(d3)).toBe(true); }); it("t+ and today+", function () { this.d.add(1).days(); var d2 = Date.parse("t+"); var d3 = Date.parse("today+"); expect(this.d.equals(d2)).toBe(true); expect(this.d.equals(d3)).toBe(true); }); it("t+1d and today+1d and variants", function () { this.d.add(1).days(); var d2 = Date.parse("t+1d"); var d3 = Date.parse("t+1 d"); var d4 = Date.parse("t + 1 d"); var d5 = Date.parse("t+1day"); var d6 = Date.parse("t+1 day"); var d7 = Date.parse("t + 1 day"); var d8 = Date.parse("today+1d"); var d9 = Date.parse("today+1 d"); var d10 = Date.parse("today + 1 d"); var d11 = Date.parse("today+1day"); var d12 = Date.parse("today+1 day"); var d13 = Date.parse("today + 1 day"); expect(this.d.equals(d2)).toBe(true); expect(this.d.equals(d3)).toBe(true); expect(this.d.equals(d4)).toBe(true); expect(this.d.equals(d5)).toBe(true); expect(this.d.equals(d6)).toBe(true); expect(this.d.equals(d7)).toBe(true); expect(this.d.equals(d8)).toBe(true); expect(this.d.equals(d9)).toBe(true); expect(this.d.equals(d10)).toBe(true); expect(this.d.equals(d11)).toBe(true); expect(this.d.equals(d12)).toBe(true); expect(this.d.equals(d13)).toBe(true); }); it("t+15d and today+15d and variants", function () { this.d.add(15).days(); var d2 = Date.parse("t+15d"); var d3 = Date.parse("t+15 d"); var d4 = Date.parse("t + 15 d"); var d5 = Date.parse("t+15day"); var d6 = Date.parse("t+15 day"); var d7 = Date.parse("t + 15 day"); var d8 = Date.parse("today+15d"); var d9 = Date.parse("today+15 d"); var d10 = Date.parse("today + 15 d"); var d11 = Date.parse("today+15day"); var d12 = Date.parse("today+15 day"); var d13 = Date.parse("today + 15 day"); expect(this.d.equals(d2)).toBe(true); expect(this.d.equals(d3)).toBe(true); expect(this.d.equals(d4)).toBe(true); expect(this.d.equals(d5)).toBe(true); expect(this.d.equals(d6)).toBe(true); expect(this.d.equals(d7)).toBe(true); expect(this.d.equals(d8)).toBe(true); expect(this.d.equals(d9)).toBe(true); expect(this.d.equals(d10)).toBe(true); expect(this.d.equals(d11)).toBe(true); expect(this.d.equals(d12)).toBe(true); expect(this.d.equals(d13)).toBe(true); }); it("t+100d and today+100d and variants", function () { this.d.add(100).days(); var d2 = Date.parse("t+100d"); var d3 = Date.parse("t+100 d"); var d13 = Date.parse("t + 100 d"); var d4 = Date.parse("t+100day"); var d5 = Date.parse("t+100 day"); var d6 = Date.parse("t + 100 day"); var d7 = Date.parse("today+100d"); var d8 = Date.parse("today+100 d"); var d9 = Date.parse("today + 100 d"); var d10 = Date.parse("today+100day"); var d11 = Date.parse("today+100 day"); var d12 = Date.parse("today + 100 day"); expect(this.d.equals(d2)).toBe(true); expect(this.d.equals(d3)).toBe(true); expect(this.d.equals(d4)).toBe(true); expect(this.d.equals(d5)).toBe(true); expect(this.d.equals(d6)).toBe(true); expect(this.d.equals(d7)).toBe(true); expect(this.d.equals(d8)).toBe(true); expect(this.d.equals(d9)).toBe(true); expect(this.d.equals(d10)).toBe(true); expect(this.d.equals(d11)).toBe(true); expect(this.d.equals(d12)).toBe(true); expect(this.d.equals(d13)).toBe(true); }); it("t+1m and today+1m and variants", function () { this.d.add(1).months(); var d2 = Date.parse("t+1m"); var d3 = Date.parse("t+1 m"); var d13 = Date.parse("t + 1 m"); var d4 = Date.parse("t+1month"); var d5 = Date.parse("t+1 month"); var d6 = Date.parse("t + 1 month"); var d7 = Date.parse("today+1m"); var d8 = Date.parse("today+1 m"); var d9 = Date.parse("today + 1 m"); var d10 = Date.parse("today+1month"); var d11 = Date.parse("today+1 month"); var d12 = Date.parse("today + 1 month"); expect(this.d.equals(d2)).toBe(true); expect(this.d.equals(d3)).toBe(true); expect(this.d.equals(d4)).toBe(true); expect(this.d.equals(d5)).toBe(true); expect(this.d.equals(d6)).toBe(true); expect(this.d.equals(d7)).toBe(true); expect(this.d.equals(d8)).toBe(true); expect(this.d.equals(d9)).toBe(true); expect(this.d.equals(d10)).toBe(true); expect(this.d.equals(d11)).toBe(true); expect(this.d.equals(d12)).toBe(true); expect(this.d.equals(d13)).toBe(true); }); it("t+15m and today+15m and variants", function () { this.d.add(15).months(); var d2 = Date.parse("t+15m"); var d3 = Date.parse("t+15 m"); var d13 = Date.parse("t + 15 m"); var d4 = Date.parse("t+15months"); var d5 = Date.parse("t+15 months"); var d6 = Date.parse("t + 15 months"); var d7 = Date.parse("today+15m"); var d8 = Date.parse("today+15 m"); var d9 = Date.parse("today + 15 m"); var d10 = Date.parse("today+15months"); var d11 = Date.parse("today+15 months"); var d12 = Date.parse("today + 15 months"); expect(this.d.equals(d2)).toBe(true); expect(this.d.equals(d3)).toBe(true); expect(this.d.equals(d4)).toBe(true); expect(this.d.equals(d5)).toBe(true); expect(this.d.equals(d6)).toBe(true); expect(this.d.equals(d7)).toBe(true); expect(this.d.equals(d8)).toBe(true); expect(this.d.equals(d9)).toBe(true); expect(this.d.equals(d10)).toBe(true); expect(this.d.equals(d11)).toBe(true); expect(this.d.equals(d12)).toBe(true); expect(this.d.equals(d13)).toBe(true); }); it("t+100d and today+100m and variants", function () { this.d.add(100).months(); var d2 = Date.parse("t+100m"); var d3 = Date.parse("t+100 m"); var d13 = Date.parse("t + 100 m"); var d4 = Date.parse("t+100months"); var d5 = Date.parse("t+100 months"); var d6 = Date.parse("t + 100 months"); var d7 = Date.parse("today+100m"); var d8 = Date.parse("today+100 m"); var d9 = Date.parse("today + 100 m"); var d10 = Date.parse("today+100months"); var d11 = Date.parse("today+100 months"); var d12 = Date.parse("today + 100 months"); expect(this.d.equals(d2)).toBe(true); expect(this.d.equals(d3)).toBe(true); expect(this.d.equals(d4)).toBe(true); expect(this.d.equals(d5)).toBe(true); expect(this.d.equals(d6)).toBe(true); expect(this.d.equals(d7)).toBe(true); expect(this.d.equals(d8)).toBe(true); expect(this.d.equals(d9)).toBe(true); expect(this.d.equals(d10)).toBe(true); expect(this.d.equals(d11)).toBe(true); expect(this.d.equals(d12)).toBe(true); expect(this.d.equals(d13)).toBe(true); }); it("t+1y and today+1y and variants", function () { this.d.add(1).years(); var d2 = Date.parse("t+1y"); var d3 = Date.parse("t+1 y"); var d13 = Date.parse("t + 1 y"); var d4 = Date.parse("t+1year"); var d5 = Date.parse("t+1 year"); var d6 = Date.parse("t + 1 year"); var d7 = Date.parse("today+1y"); var d8 = Date.parse("today+1 y"); var d9 = Date.parse("today + 1 y"); var d10 = Date.parse("today+1year"); var d11 = Date.parse("today+1 year"); var d12 = Date.parse("today + 1 year"); expect(this.d.equals(d2)).toBe(true); expect(this.d.equals(d3)).toBe(true); expect(this.d.equals(d4)).toBe(true); expect(this.d.equals(d5)).toBe(true); expect(this.d.equals(d6)).toBe(true); expect(this.d.equals(d7)).toBe(true); expect(this.d.equals(d8)).toBe(true); expect(this.d.equals(d9)).toBe(true); expect(this.d.equals(d10)).toBe(true); expect(this.d.equals(d11)).toBe(true); expect(this.d.equals(d12)).toBe(true); expect(this.d.equals(d13)).toBe(true); }); it("t+15y and today+15y and variants", function () { this.d.add(15).years(); var d2 = Date.parse("t+15y"); var d3 = Date.parse("t+15 y"); var d13 = Date.parse("t + 15 y"); var d4 = Date.parse("t+15years"); var d5 = Date.parse("t+15 years"); var d6 = Date.parse("t + 15 years"); var d7 = Date.parse("today+15y"); var d8 = Date.parse("today+15 y"); var d9 = Date.parse("today + 15 y"); var d10 = Date.parse("today+15years"); var d11 = Date.parse("today+15 years"); var d12 = Date.parse("today + 15 years"); expect(this.d.equals(d2)).toBe(true); expect(this.d.equals(d3)).toBe(true); expect(this.d.equals(d4)).toBe(true); expect(this.d.equals(d5)).toBe(true); expect(this.d.equals(d6)).toBe(true); expect(this.d.equals(d7)).toBe(true); expect(this.d.equals(d8)).toBe(true); expect(this.d.equals(d9)).toBe(true); expect(this.d.equals(d10)).toBe(true); expect(this.d.equals(d11)).toBe(true); expect(this.d.equals(d12)).toBe(true); expect(this.d.equals(d13)).toBe(true); }); it("t+100d and today+100y and variants", function () { this.d.add(100).years(); var d2 = Date.parse("t+100y"); var d3 = Date.parse("t+100 y"); var d13 = Date.parse("t + 100 y"); var d4 = Date.parse("t+100years"); var d5 = Date.parse("t+100 years"); var d6 = Date.parse("t + 100 years"); var d7 = Date.parse("today+100y"); var d8 = Date.parse("today+100 y"); var d9 = Date.parse("today + 100 y"); var d10 = Date.parse("today+100years"); var d11 = Date.parse("today+100 years"); var d12 = Date.parse("today + 100 years"); expect(this.d.equals(d2)).toBe(true); expect(this.d.equals(d3)).toBe(true); expect(this.d.equals(d4)).toBe(true); expect(this.d.equals(d5)).toBe(true); expect(this.d.equals(d6)).toBe(true); expect(this.d.equals(d7)).toBe(true); expect(this.d.equals(d8)).toBe(true); expect(this.d.equals(d9)).toBe(true); expect(this.d.equals(d10)).toBe(true); expect(this.d.equals(d11)).toBe(true); expect(this.d.equals(d12)).toBe(true); expect(this.d.equals(d13)).toBe(true); }); // now swtich to minus it("t- and today-", function () { this.d.add(-1).days(); var d2 = Date.parse("t-"); var d3 = Date.parse("today-"); expect(this.d.equals(d2)).toBe(true); expect(this.d.equals(d3)).toBe(true); }); it("t-1d and today-1d and variants", function () { this.d.add(-1).days(); var d2 = Date.parse("t-1d"); var d3 = Date.parse("t-1 d"); var d13 = Date.parse("t - 1 d"); var d4 = Date.parse("t-1day"); var d5 = Date.parse("t-1 day"); var d6 = Date.parse("t - 1 day"); var d7 = Date.parse("today-1d"); var d8 = Date.parse("today-1 d"); var d9 = Date.parse("today - 1 d"); var d10 = Date.parse("today-1day"); var d11 = Date.parse("today-1 day"); var d12 = Date.parse("today - 1 day"); expect(this.d.equals(d2)).toBe(true); expect(this.d.equals(d3)).toBe(true); expect(this.d.equals(d4)).toBe(true); expect(this.d.equals(d5)).toBe(true); expect(this.d.equals(d6)).toBe(true); expect(this.d.equals(d7)).toBe(true); expect(this.d.equals(d8)).toBe(true); expect(this.d.equals(d9)).toBe(true); expect(this.d.equals(d10)).toBe(true); expect(this.d.equals(d11)).toBe(true); expect(this.d.equals(d12)).toBe(true); expect(this.d.equals(d13)).toBe(true); }); it("t-15d and today-15d and variants", function () { this.d.add(-15).days(); var d2 = Date.parse("t-15d"); var d3 = Date.parse("t-15 d"); var d13 = Date.parse("t - 15 d"); var d4 = Date.parse("t-15day"); var d5 = Date.parse("t-15 day"); var d6 = Date.parse("t - 15 day"); var d7 = Date.parse("today-15d"); var d8 = Date.parse("today-15 d"); var d9 = Date.parse("today - 15 d"); var d10 = Date.parse("today-15day"); var d11 = Date.parse("today-15 day"); var d12 = Date.parse("today - 15 day"); expect(this.d.equals(d2)).toBe(true); expect(this.d.equals(d3)).toBe(true); expect(this.d.equals(d4)).toBe(true); expect(this.d.equals(d5)).toBe(true); expect(this.d.equals(d6)).toBe(true); expect(this.d.equals(d7)).toBe(true); expect(this.d.equals(d8)).toBe(true); expect(this.d.equals(d9)).toBe(true); expect(this.d.equals(d10)).toBe(true); expect(this.d.equals(d11)).toBe(true); expect(this.d.equals(d12)).toBe(true); expect(this.d.equals(d13)).toBe(true); }); it("t-100d and today-100d and variants", function () { this.d.add(-100).days(); var d2 = Date.parse("t-100d"); var d3 = Date.parse("t-100 d"); var d13 = Date.parse("t - 100 d"); var d4 = Date.parse("t-100day"); var d5 = Date.parse("t-100 day"); var d6 = Date.parse("t - 100 day"); var d7 = Date.parse("today-100d"); var d8 = Date.parse("today-100 d"); var d9 = Date.parse("today - 100 d"); var d10 = Date.parse("today-100day"); var d11 = Date.parse("today-100 day"); var d12 = Date.parse("today - 100 day"); expect(this.d.equals(d2)).toBe(true); expect(this.d.equals(d3)).toBe(true); expect(this.d.equals(d4)).toBe(true); expect(this.d.equals(d5)).toBe(true); expect(this.d.equals(d6)).toBe(true); expect(this.d.equals(d7)).toBe(true); expect(this.d.equals(d8)).toBe(true); expect(this.d.equals(d9)).toBe(true); expect(this.d.equals(d10)).toBe(true); expect(this.d.equals(d11)).toBe(true); expect(this.d.equals(d12)).toBe(true); expect(this.d.equals(d13)).toBe(true); }); it("t-1m and today-1m and variants", function () { this.d.add(-1).months(); var d2 = Date.parse("t-1m"); var d3 = Date.parse("t-1 m"); var d13 = Date.parse("t - 1 m"); var d4 = Date.parse("t-1month"); var d5 = Date.parse("t-1 month"); var d6 = Date.parse("t - 1 month"); var d7 = Date.parse("today-1m"); var d8 = Date.parse("today-1 m"); var d9 = Date.parse("today - 1 m"); var d10 = Date.parse("today-1month"); var d11 = Date.parse("today-1 month"); var d12 = Date.parse("today - 1 month"); expect(this.d.equals(d2)).toBe(true); expect(this.d.equals(d3)).toBe(true); expect(this.d.equals(d4)).toBe(true); expect(this.d.equals(d5)).toBe(true); expect(this.d.equals(d6)).toBe(true); expect(this.d.equals(d7)).toBe(true); expect(this.d.equals(d8)).toBe(true); expect(this.d.equals(d9)).toBe(true); expect(this.d.equals(d10)).toBe(true); expect(this.d.equals(d11)).toBe(true); expect(this.d.equals(d12)).toBe(true); expect(this.d.equals(d13)).toBe(true); }); it("t-15m and today-15m and variants", function () { this.d.add(-15).months(); var d2 = Date.parse("t-15m"); var d3 = Date.parse("t-15 m"); var d13 = Date.parse("t - 15 m"); var d4 = Date.parse("t-15months"); var d5 = Date.parse("t-15 months"); var d6 = Date.parse("t - 15 months"); var d7 = Date.parse("today-15m"); var d8 = Date.parse("today-15 m"); var d9 = Date.parse("today - 15 m"); var d10 = Date.parse("today-15months"); var d11 = Date.parse("today-15 months"); var d12 = Date.parse("today - 15 months"); expect(this.d.equals(d2)).toBe(true); expect(this.d.equals(d3)).toBe(true); expect(this.d.equals(d4)).toBe(true); expect(this.d.equals(d5)).toBe(true); expect(this.d.equals(d6)).toBe(true); expect(this.d.equals(d7)).toBe(true); expect(this.d.equals(d8)).toBe(true); expect(this.d.equals(d9)).toBe(true); expect(this.d.equals(d10)).toBe(true); expect(this.d.equals(d11)).toBe(true); expect(this.d.equals(d12)).toBe(true); expect(this.d.equals(d13)).toBe(true); }); it("t-100d and today-100m and variants", function () { this.d.add(-100).months(); var d2 = Date.parse("t-100m"); var d3 = Date.parse("t-100 m"); var d13 = Date.parse("t - 100 m"); var d4 = Date.parse("t-100months"); var d5 = Date.parse("t-100 months"); var d6 = Date.parse("t - 100 months"); var d7 = Date.parse("today-100m"); var d8 = Date.parse("today-100 m"); var d9 = Date.parse("today - 100 m"); var d10 = Date.parse("today-100months"); var d11 = Date.parse("today-100 months"); var d12 = Date.parse("today - 100 months"); expect(this.d.equals(d2)).toBe(true); expect(this.d.equals(d3)).toBe(true); expect(this.d.equals(d4)).toBe(true); expect(this.d.equals(d5)).toBe(true); expect(this.d.equals(d6)).toBe(true); expect(this.d.equals(d7)).toBe(true); expect(this.d.equals(d8)).toBe(true); expect(this.d.equals(d9)).toBe(true); expect(this.d.equals(d10)).toBe(true); expect(this.d.equals(d11)).toBe(true); expect(this.d.equals(d12)).toBe(true); expect(this.d.equals(d13)).toBe(true); }); it("t-1y and today-1y and variants", function () { this.d.add(-1).years(); var d2 = Date.parse("t-1y"); var d3 = Date.parse("t-1 y"); var d13 = Date.parse("t - 1 y"); var d4 = Date.parse("t-1year"); var d5 = Date.parse("t-1 year"); var d6 = Date.parse("t - 1 year"); var d7 = Date.parse("today-1y"); var d8 = Date.parse("today-1 y"); var d9 = Date.parse("today - 1 y"); var d10 = Date.parse("today-1year"); var d11 = Date.parse("today-1 year"); var d12 = Date.parse("today - 1 year"); expect(this.d.equals(d2)).toBe(true); expect(this.d.equals(d3)).toBe(true); expect(this.d.equals(d4)).toBe(true); expect(this.d.equals(d5)).toBe(true); expect(this.d.equals(d6)).toBe(true); expect(this.d.equals(d7)).toBe(true); expect(this.d.equals(d8)).toBe(true); expect(this.d.equals(d9)).toBe(true); expect(this.d.equals(d10)).toBe(true); expect(this.d.equals(d11)).toBe(true); expect(this.d.equals(d12)).toBe(true); expect(this.d.equals(d13)).toBe(true); }); it("t-15y and today-15y and variants", function () { this.d.add(-15).years(); var d2 = Date.parse("t-15y"); var d3 = Date.parse("t-15 y"); var d13 = Date.parse("t - 15 y"); var d4 = Date.parse("t-15years"); var d5 = Date.parse("t-15 years"); var d6 = Date.parse("t - 15 years"); var d7 = Date.parse("today-15y"); var d8 = Date.parse("today-15 y"); var d9 = Date.parse("today - 15 y"); var d10 = Date.parse("today-15years"); var d11 = Date.parse("today-15 years"); var d12 = Date.parse("today - 15 years"); expect(this.d.equals(d2)).toBe(true); expect(this.d.equals(d3)).toBe(true); expect(this.d.equals(d4)).toBe(true); expect(this.d.equals(d5)).toBe(true); expect(this.d.equals(d6)).toBe(true); expect(this.d.equals(d7)).toBe(true); expect(this.d.equals(d8)).toBe(true); expect(this.d.equals(d9)).toBe(true); expect(this.d.equals(d10)).toBe(true); expect(this.d.equals(d11)).toBe(true); expect(this.d.equals(d12)).toBe(true); expect(this.d.equals(d13)).toBe(true); }); it("t-100y and today-100y and variants", function () { this.d.add(-100).years(); var d2 = Date.parse("t-100y"); var d3 = Date.parse("t-100 y"); var d13 = Date.parse("t - 100 y"); var d4 = Date.parse("t-100years"); var d5 = Date.parse("t-100 years"); var d6 = Date.parse("t - 100 years"); var d7 = Date.parse("today-100y"); var d8 = Date.parse("today-100 y"); var d9 = Date.parse("today - 100 y"); var d10 = Date.parse("today-100years"); var d11 = Date.parse("today-100 years"); var d12 = Date.parse("today - 100 years"); expect(this.d.equals(d2)).toBe(true); expect(this.d.equals(d3)).toBe(true); expect(this.d.equals(d4)).toBe(true); expect(this.d.equals(d5)).toBe(true); expect(this.d.equals(d6)).toBe(true); expect(this.d.equals(d7)).toBe(true); expect(this.d.equals(d8)).toBe(true); expect(this.d.equals(d9)).toBe(true); expect(this.d.equals(d10)).toBe(true); expect(this.d.equals(d11)).toBe(true); expect(this.d.equals(d12)).toBe(true); expect(this.d.equals(d13)).toBe(true); }); // switch to non t or today it("+", function () { this.d.add(1).days(); var d2 = Date.parse("+"); expect(this.d.equals(d2)).toBe(true); }); it("+1d and variants", function () { this.d.add(1).days(); var d2 = Date.parse("+1d"); var d3 = Date.parse("+1 d"); var d4 = Date.parse(" + 1 d"); var d5 = Date.parse("+1day"); var d6 = Date.parse("+1 day"); var d7 = Date.parse(" + 1 day"); expect(this.d.equals(d2)).toBe(true); expect(this.d.equals(d3)).toBe(true); expect(this.d.equals(d4)).toBe(true); expect(this.d.equals(d5)).toBe(true); expect(this.d.equals(d6)).toBe(true); expect(this.d.equals(d7)).toBe(true); }); it("+15d and variants", function () { this.d.add(15).days(); var d2 = Date.parse("+15d"); var d3 = Date.parse("+15 d"); var d4 = Date.parse(" + 15 d"); var d5 = Date.parse("+15day"); var d6 = Date.parse("+15 day"); var d7 = Date.parse(" + 15 day"); expect(this.d.equals(d2)).toBe(true); expect(this.d.equals(d3)).toBe(true); expect(this.d.equals(d4)).toBe(true); expect(this.d.equals(d5)).toBe(true); expect(this.d.equals(d6)).toBe(true); expect(this.d.equals(d7)).toBe(true); }); it("+100d and variants", function () { this.d.add(100).days(); var d2 = Date.parse("+100d"); var d3 = Date.parse("+100 d"); var d4 = Date.parse(" + 100 d"); var d5 = Date.parse("+100day"); var d6 = Date.parse("+100 day"); var d7 = Date.parse(" + 100 day"); expect(this.d.equals(d2)).toBe(true); expect(this.d.equals(d3)).toBe(true); expect(this.d.equals(d4)).toBe(true); expect(this.d.equals(d5)).toBe(true); expect(this.d.equals(d6)).toBe(true); expect(this.d.equals(d7)).toBe(true); }); it("+1m and variants", function () { this.d.add(1).months(); var d2 = Date.parse("+1m"); var d3 = Date.parse("+1 m"); var d4 = Date.parse(" + 1 m"); var d5 = Date.parse("+1month"); var d6 = Date.parse("+1 month"); var d7 = Date.parse(" + 1 month"); expect(this.d.equals(d2)).toBe(true); expect(this.d.equals(d3)).toBe(true); expect(this.d.equals(d4)).toBe(true); expect(this.d.equals(d5)).toBe(true); expect(this.d.equals(d6)).toBe(true); expect(this.d.equals(d7)).toBe(true); }); it("+15m and variants", function () { this.d.add(15).months(); var d2 = Date.parse("+15m"); var d3 = Date.parse("+15 m"); var d4 = Date.parse(" + 15 m"); var d5 = Date.parse("+15months"); var d6 = Date.parse("+15 months"); var d7 = Date.parse(" + 15 months"); expect(this.d.equals(d2)).toBe(true); expect(this.d.equals(d3)).toBe(true); expect(this.d.equals(d4)).toBe(true); expect(this.d.equals(d5)).toBe(true); expect(this.d.equals(d6)).toBe(true); expect(this.d.equals(d7)).toBe(true); }); it("+100d and variants", function () { this.d.add(100).months(); var d2 = Date.parse("+100m"); var d3 = Date.parse("+100 m"); var d4 = Date.parse(" + 100 m"); var d5 = Date.parse("+100months"); var d6 = Date.parse("+100 months"); var d7 = Date.parse(" + 100 months"); expect(this.d.equals(d2)).toBe(true); expect(this.d.equals(d3)).toBe(true); expect(this.d.equals(d4)).toBe(true); expect(this.d.equals(d5)).toBe(true); expect(this.d.equals(d6)).toBe(true); expect(this.d.equals(d7)).toBe(true); }); it("+1y and variants", function () { this.d.add(1).years(); var d2 = Date.parse("+1y"); var d3 = Date.parse("+1 y"); var d4 = Date.parse(" + 1 y"); var d5 = Date.parse("+1year"); var d6 = Date.parse("+1 year"); var d7 = Date.parse(" + 1 year"); expect(this.d.equals(d2)).toBe(true); expect(this.d.equals(d3)).toBe(true); expect(this.d.equals(d4)).toBe(true); expect(this.d.equals(d5)).toBe(true); expect(this.d.equals(d6)).toBe(true); expect(this.d.equals(d7)).toBe(true); }); it("+15y and variants", function () { this.d.add(15).years(); var d2 = Date.parse("+15y"); var d3 = Date.parse("+15 y"); var d4 = Date.parse(" + 15 y"); var d5 = Date.parse("+15years"); var d6 = Date.parse("+15 years"); var d7 = Date.parse(" + 15 years"); expect(this.d.equals(d2)).toBe(true); expect(this.d.equals(d3)).toBe(true); expect(this.d.equals(d4)).toBe(true); expect(this.d.equals(d5)).toBe(true); expect(this.d.equals(d6)).toBe(true); expect(this.d.equals(d7)).toBe(true); }); it("+100d and variants", function () { this.d.add(100).years(); var d2 = Date.parse("+100y"); var d3 = Date.parse("+100 y"); var d4 = Date.parse(" + 100 y"); var d5 = Date.parse("+100years"); var d6 = Date.parse("+100 years"); var d7 = Date.parse(" + 100 years"); expect(this.d.equals(d2)).toBe(true); expect(this.d.equals(d3)).toBe(true); expect(this.d.equals(d4)).toBe(true); expect(this.d.equals(d5)).toBe(true); expect(this.d.equals(d6)).toBe(true); expect(this.d.equals(d7)).toBe(true); }); // now swtich to minus with no t or today it("-", function () { this.d.add(-1).days(); var d2 = Date.parse("-"); expect(this.d.equals(d2)).toBe(true); }); it("-1d and variants", function () { this.d.add(-1).days(); var d2 = Date.parse("-1d"); var d3 = Date.parse("-1 d"); var d4 = Date.parse(" - 1 d"); var d5 = Date.parse("-1day"); var d6 = Date.parse("-1 day"); var d7 = Date.parse(" - 1 day"); expect(this.d.equals(d2)).toBe(true); expect(this.d.equals(d3)).toBe(true); expect(this.d.equals(d4)).toBe(true); expect(this.d.equals(d5)).toBe(true); expect(this.d.equals(d6)).toBe(true); expect(this.d.equals(d7)).toBe(true); }); it("-15d and variants", function () { this.d.add(-15).days(); var d2 = Date.parse("-15d"); var d3 = Date.parse("-15 d"); var d4 = Date.parse(" - 15 d"); var d5 = Date.parse("-15day"); var d6 = Date.parse("-15 day"); var d7 = Date.parse(" - 15 day"); expect(this.d.equals(d2)).toBe(true); expect(this.d.equals(d3)).toBe(true); expect(this.d.equals(d4)).toBe(true); expect(this.d.equals(d5)).toBe(true); expect(this.d.equals(d6)).toBe(true); expect(this.d.equals(d7)).toBe(true); }); it("-100d and variants", function () { this.d.add(-100).days(); var d2 = Date.parse("-100d"); var d3 = Date.parse("-100 d"); var d4 = Date.parse(" - 100 d"); var d5 = Date.parse("-100day"); var d6 = Date.parse("-100 day"); var d7 = Date.parse(" - 100 day"); expect(this.d.equals(d2)).toBe(true); expect(this.d.equals(d3)).toBe(true); expect(this.d.equals(d4)).toBe(true); expect(this.d.equals(d5)).toBe(true); expect(this.d.equals(d6)).toBe(true); expect(this.d.equals(d7)).toBe(true); }); it("-1m and variants", function () { this.d.add(-1).months(); var d2 = Date.parse("-1m"); var d3 = Date.parse("-1 m"); var d4 = Date.parse(" - 1 m"); var d5 = Date.parse("-1month"); var d6 = Date.parse("-1 month"); var d7 = Date.parse(" - 1 month"); expect(this.d.equals(d2)).toBe(true); expect(this.d.equals(d3)).toBe(true); expect(this.d.equals(d4)).toBe(true); expect(this.d.equals(d5)).toBe(true); expect(this.d.equals(d6)).toBe(true); expect(this.d.equals(d7)).toBe(true); }); it("-15m and variants", function () { this.d.add(-15).months(); var d2 = Date.parse("-15m"); var d3 = Date.parse("-15 m"); var d4 = Date.parse(" - 15 m"); var d5 = Date.parse("-15months"); var d6 = Date.parse("-15 months"); var d7 = Date.parse(" - 15 months"); expect(this.d.equals(d2)).toBe(true); expect(this.d.equals(d3)).toBe(true); expect(this.d.equals(d4)).toBe(true); expect(this.d.equals(d5)).toBe(true); expect(this.d.equals(d6)).toBe(true); expect(this.d.equals(d7)).toBe(true); }); it("-100d and variants", function () { this.d.add(-100).months(); var d2 = Date.parse("-100m"); var d3 = Date.parse("-100 m"); var d4 = Date.parse(" - 100 m"); var d5 = Date.parse("-100months"); var d6 = Date.parse("-100 months"); var d7 = Date.parse(" - 100 months"); expect(this.d.equals(d2)).toBe(true); expect(this.d.equals(d3)).toBe(true); expect(this.d.equals(d4)).toBe(true); expect(this.d.equals(d5)).toBe(true); expect(this.d.equals(d6)).toBe(true); expect(this.d.equals(d7)).toBe(true); }); it("-1y and variants", function () { this.d.add(-1).years(); var d2 = Date.parse("-1y"); var d3 = Date.parse("-1 y"); var d4 = Date.parse(" - 1 y"); var d5 = Date.parse("-1year"); var d6 = Date.parse("-1 year"); var d7 = Date.parse(" - 1 year"); expect(this.d.equals(d2)).toBe(true); expect(this.d.equals(d3)).toBe(true); expect(this.d.equals(d4)).toBe(true); expect(this.d.equals(d5)).toBe(true); expect(this.d.equals(d6)).toBe(true); expect(this.d.equals(d7)).toBe(true); }); it("-15y and variants", function () { this.d.add(-15).years(); var d2 = Date.parse("-15y"); var d3 = Date.parse("-15 y"); var d4 = Date.parse(" - 15 y"); var d5 = Date.parse("-15years"); var d6 = Date.parse("-15 years"); var d7 = Date.parse(" - 15 years"); expect(this.d.equals(d2)).toBe(true); expect(this.d.equals(d3)).toBe(true); expect(this.d.equals(d4)).toBe(true); expect(this.d.equals(d5)).toBe(true); expect(this.d.equals(d6)).toBe(true); expect(this.d.equals(d7)).toBe(true); }); it("-100y and variants", function () { this.d.add(-100).years(); var d2 = Date.parse("-100y"); var d3 = Date.parse("-100 y"); var d4 = Date.parse(" - 100 y"); var d5 = Date.parse("-100years"); var d6 = Date.parse("-100 years"); var d7 = Date.parse(" - 100 years"); expect(this.d.equals(d2)).toBe(true); expect(this.d.equals(d3)).toBe(true); expect(this.d.equals(d4)).toBe(true); expect(this.d.equals(d5)).toBe(true); expect(this.d.equals(d6)).toBe(true); expect(this.d.equals(d7)).toBe(true); }); // switch to smaller formats it("+5 second and variants", function () { var d1 = Date.parse("+5sec"); this.d = (new Date()).add(+5).seconds(); expect(this.d.getSeconds()).toBe(d1.getSeconds()); var d2 = Date.parse("+5 sec"); this.d = (new Date()).add(+5).seconds(); expect(this.d.getSeconds()).toBe(d2.getSeconds()); var d3 = Date.parse(" + 5 sec"); this.d = (new Date()).add(+5).seconds(); expect(this.d.getSeconds()).toBe(d3.getSeconds()); var d4 = Date.parse("+5second"); this.d = (new Date()).add(+5).seconds(); expect(this.d.getSeconds()).toBe(d4.getSeconds()); var d5 = Date.parse("+5 second"); this.d = (new Date()).add(+5).seconds(); expect(this.d.getSeconds()).toBe(d5.getSeconds()); var d6 = Date.parse(" + 5 second"); this.d = (new Date()).add(+5).seconds(); expect(this.d.getSeconds()).toBe(d6.getSeconds()); var d7 = Date.parse("+5seconds"); this.d = (new Date()).add(+5).seconds(); expect(this.d.getSeconds()).toBe(d7.getSeconds()); var d8 = Date.parse("+5 seconds"); this.d = (new Date()).add(+5).seconds(); expect(this.d.getSeconds()).toBe(d8.getSeconds()); var d9 = Date.parse(" + 5 seconds"); this.d = (new Date()).add(+5).seconds(); expect(this.d.getSeconds()).toBe(d9.getSeconds()); var d10 = Date.parse("+5Second"); this.d = (new Date()).add(+5).seconds(); expect(this.d.getSeconds()).toBe(d10.getSeconds()); var d11 = Date.parse("+5 Second"); this.d = (new Date()).add(+5).seconds(); expect(this.d.getSeconds()).toBe(d11.getSeconds()); var d12 = Date.parse(" + 5 Second"); this.d = (new Date()).add(+5).seconds(); expect(this.d.getSeconds()).toBe(d12.getSeconds()); var d13 = Date.parse("+5Seconds"); this.d = (new Date()).add(+5).seconds(); expect(this.d.getSeconds()).toBe(d13.getSeconds()); var d14 = Date.parse("+5 Seconds"); this.d = (new Date()).add(+5).seconds(); expect(this.d.getSeconds()).toBe(d14.getSeconds()); var d15 = Date.parse(" + 5 Seconds"); this.d = (new Date()).add(+5).seconds(); expect(this.d.getSeconds()).toBe(d15.getSeconds()); }); it("-5 second and variants", function () { var d1 = Date.parse("-5sec"); this.d = (new Date()).add(-5).seconds(); expect(this.d.getSeconds()).toBe(d1.getSeconds()); var d2 = Date.parse("-5 sec"); this.d = (new Date()).add(-5).seconds(); expect(this.d.getSeconds()).toBe(d2.getSeconds()); var d3 = Date.parse(" - 5 sec"); this.d = (new Date()).add(-5).seconds(); expect(this.d.getSeconds()).toBe(d3.getSeconds()); var d4 = Date.parse("-5second"); this.d = (new Date()).add(-5).seconds(); expect(this.d.getSeconds()).toBe(d4.getSeconds()); var d5 = Date.parse("-5 second"); this.d = (new Date()).add(-5).seconds(); expect(this.d.getSeconds()).toBe(d5.getSeconds()); var d6 = Date.parse(" - 5 second"); this.d = (new Date()).add(-5).seconds(); expect(this.d.getSeconds()).toBe(d6.getSeconds()); var d7 = Date.parse("-5seconds"); this.d = (new Date()).add(-5).seconds(); expect(this.d.getSeconds()).toBe(d7.getSeconds()); var d8 = Date.parse("-5 seconds"); this.d = (new Date()).add(-5).seconds(); expect(this.d.getSeconds()).toBe(d8.getSeconds()); var d9 = Date.parse(" - 5 seconds"); this.d = (new Date()).add(-5).seconds(); expect(this.d.getSeconds()).toBe(d9.getSeconds()); var d10 = Date.parse("-5Second"); this.d = (new Date()).add(-5).seconds(); expect(this.d.getSeconds()).toBe(d10.getSeconds()); var d11 = Date.parse("-5 Second"); this.d = (new Date()).add(-5).seconds(); expect(this.d.getSeconds()).toBe(d11.getSeconds()); var d12 = Date.parse(" - 5 Second"); this.d = (new Date()).add(-5).seconds(); expect(this.d.getSeconds()).toBe(d12.getSeconds()); var d13 = Date.parse("-5Seconds"); this.d = (new Date()).add(-5).seconds(); expect(this.d.getSeconds()).toBe(d13.getSeconds()); var d14 = Date.parse("-5 Seconds"); this.d = (new Date()).add(-5).seconds(); expect(this.d.getSeconds()).toBe(d14.getSeconds()); var d15 = Date.parse(" - 5 Seconds"); this.d = (new Date()).add(-5).seconds(); expect(this.d.getSeconds()).toBe(d15.getSeconds()); }); it("+5 minute and variants", function () { this.d = (new Date()).add(5).minutes(); var d2 = Date.parse("+5min"); var d3 = Date.parse("+5 min"); var d16 = Date.parse(" + 5 min"); var d4 = Date.parse("+5minute"); var d5 = Date.parse("+5 minute"); var d6 = Date.parse(" + 5 minute"); var d7 = Date.parse("+5minutes"); var d8 = Date.parse("+5 minutes"); var d9 = Date.parse(" + 5 minutes"); var d10 = Date.parse("+5Minute"); var d11 = Date.parse("+5 Minute"); var d12 = Date.parse(" + 5 Minute"); var d13 = Date.parse("+5Minutes"); var d14 = Date.parse("+5 Minutes"); var d15 = Date.parse(" + 5 Minutes"); expect(this.d.getMinutes()).toBe(d2.getMinutes()); expect(this.d.getMinutes()).toBe(d3.getMinutes()); expect(this.d.getMinutes()).toBe(d4.getMinutes()); expect(this.d.getMinutes()).toBe(d5.getMinutes()); expect(this.d.getMinutes()).toBe(d6.getMinutes()); expect(this.d.getMinutes()).toBe(d7.getMinutes()); expect(this.d.getMinutes()).toBe(d8.getMinutes()); expect(this.d.getMinutes()).toBe(d9.getMinutes()); expect(this.d.getMinutes()).toBe(d10.getMinutes()); expect(this.d.getMinutes()).toBe(d11.getMinutes()); expect(this.d.getMinutes()).toBe(d12.getMinutes()); expect(this.d.getMinutes()).toBe(d13.getMinutes()); expect(this.d.getMinutes()).toBe(d14.getMinutes()); expect(this.d.getMinutes()).toBe(d15.getMinutes()); expect(this.d.getMinutes()).toBe(d16.getMinutes()); }); it("-5 minute and variants", function () { this.d = (new Date()).add(-5).minutes(); var d2 = Date.parse("-5min"); var d3 = Date.parse("-5 min"); var d16 = Date.parse(" - 5 min"); var d4 = Date.parse("-5minute"); var d5 = Date.parse("-5 minute"); var d6 = Date.parse(" - 5 minute"); var d7 = Date.parse("-5minutes"); var d8 = Date.parse("-5 minutes"); var d9 = Date.parse(" - 5 minutes"); var d10 = Date.parse("-5Minute"); var d11 = Date.parse("-5 Minute"); var d12 = Date.parse(" - 5 Minute"); var d13 = Date.parse("-5Minutes"); var d14 = Date.parse("-5 Minutes"); var d15 = Date.parse(" - 5 Minutes"); expect(this.d.getMinutes()).toBe(d2.getMinutes()); expect(this.d.getMinutes()).toBe(d3.getMinutes()); expect(this.d.getMinutes()).toBe(d4.getMinutes()); expect(this.d.getMinutes()).toBe(d5.getMinutes()); expect(this.d.getMinutes()).toBe(d6.getMinutes()); expect(this.d.getMinutes()).toBe(d7.getMinutes()); expect(this.d.getMinutes()).toBe(d8.getMinutes()); expect(this.d.getMinutes()).toBe(d9.getMinutes()); expect(this.d.getMinutes()).toBe(d10.getMinutes()); expect(this.d.getMinutes()).toBe(d11.getMinutes()); expect(this.d.getMinutes()).toBe(d12.getMinutes()); expect(this.d.getMinutes()).toBe(d13.getMinutes()); expect(this.d.getMinutes()).toBe(d14.getMinutes()); expect(this.d.getMinutes()).toBe(d15.getMinutes()); expect(this.d.getMinutes()).toBe(d16.getMinutes()); }); it("+5 hour and variants", function () { this.d = (new Date()).add(5).hours(); var d2 = Date.parse("+5h"); var d3 = Date.parse("+5 h"); var d16 = Date.parse(" + 5 h"); var d4 = Date.parse("+5hour"); var d5 = Date.parse("+5 hour"); var d6 = Date.parse(" + 5 hour"); var d7 = Date.parse("+5hours"); var d8 = Date.parse("+5 hours"); var d9 = Date.parse(" + 5 hours"); var d10 = Date.parse("+5Hour"); var d11 = Date.parse("+5 Hour"); var d12 = Date.parse(" + 5 Hour"); var d13 = Date.parse("+5Hours"); var d14 = Date.parse("+5 Hours"); var d15 = Date.parse(" + 5 Hours"); expect(this.d.getHours()).toBe(d2.getHours()); expect(this.d.getHours()).toBe(d3.getHours()); expect(this.d.getHours()).toBe(d4.getHours()); expect(this.d.getHours()).toBe(d5.getHours()); expect(this.d.getHours()).toBe(d6.getHours()); expect(this.d.getHours()).toBe(d7.getHours()); expect(this.d.getHours()).toBe(d8.getHours()); expect(this.d.getHours()).toBe(d9.getHours()); expect(this.d.getHours()).toBe(d10.getHours()); expect(this.d.getHours()).toBe(d11.getHours()); expect(this.d.getHours()).toBe(d12.getHours()); expect(this.d.getHours()).toBe(d13.getHours()); expect(this.d.getHours()).toBe(d14.getHours()); expect(this.d.getHours()).toBe(d15.getHours()); expect(this.d.getHours()).toBe(d16.getHours()); }); it("-5 hour and variants", function () { this.d = (new Date()).add(-5).hours(); var d2 = Date.parse("-5h"); var d3 = Date.parse("-5 h"); var d16 = Date.parse(" - 5 h"); var d4 = Date.parse("-5hour"); var d5 = Date.parse("-5 hour"); var d6 = Date.parse(" - 5 hour"); var d7 = Date.parse("-5hours"); var d8 = Date.parse("-5 hours"); var d9 = Date.parse(" - 5 hours"); var d10 = Date.parse("-5Hour"); var d11 = Date.parse("-5 Hour"); var d12 = Date.parse(" - 5 Hour"); var d13 = Date.parse("-5Hours"); var d14 = Date.parse("-5 Hours"); var d15 = Date.parse(" - 5 Hours"); expect(this.d.getHours()).toBe(d2.getHours()); expect(this.d.getHours()).toBe(d3.getHours()); expect(this.d.getHours()).toBe(d4.getHours()); expect(this.d.getHours()).toBe(d5.getHours()); expect(this.d.getHours()).toBe(d6.getHours()); expect(this.d.getHours()).toBe(d7.getHours()); expect(this.d.getHours()).toBe(d8.getHours()); expect(this.d.getHours()).toBe(d9.getHours()); expect(this.d.getHours()).toBe(d10.getHours()); expect(this.d.getHours()).toBe(d11.getHours()); expect(this.d.getHours()).toBe(d12.getHours()); expect(this.d.getHours()).toBe(d13.getHours()); expect(this.d.getHours()).toBe(d14.getHours()); expect(this.d.getHours()).toBe(d15.getHours()); expect(this.d.getHours()).toBe(d16.getHours()); }); it("+5 week and variants", function () { this.d = (new Date()).add(5).weeks(); var d2 = Date.parse("+5w"); var d3 = Date.parse("+5 w"); var d16 = Date.parse(" + 5 w"); var d4 = Date.parse("+5week"); var d5 = Date.parse("+5 week"); var d6 = Date.parse(" + 5 week"); var d7 = Date.parse("+5weeks"); var d8 = Date.parse("+5 weeks"); var d9 = Date.parse(" + 5 weeks"); var d10 = Date.parse("+5Week"); var d11 = Date.parse("+5 Week"); var d12 = Date.parse(" + 5 Week"); var d13 = Date.parse("+5Weeks"); var d14 = Date.parse("+5 Weeks"); var d15 = Date.parse(" + 5 Weeks"); expect(this.d.getWeek()).toBe(d2.getWeek()); expect(this.d.getWeek()).toBe(d3.getWeek()); expect(this.d.getWeek()).toBe(d4.getWeek()); expect(this.d.getWeek()).toBe(d5.getWeek()); expect(this.d.getWeek()).toBe(d6.getWeek()); expect(this.d.getWeek()).toBe(d7.getWeek()); expect(this.d.getWeek()).toBe(d8.getWeek()); expect(this.d.getWeek()).toBe(d9.getWeek()); expect(this.d.getWeek()).toBe(d10.getWeek()); expect(this.d.getWeek()).toBe(d11.getWeek()); expect(this.d.getWeek()).toBe(d12.getWeek()); expect(this.d.getWeek()).toBe(d13.getWeek()); expect(this.d.getWeek()).toBe(d14.getWeek()); expect(this.d.getWeek()).toBe(d15.getWeek()); expect(this.d.getWeek()).toBe(d16.getWeek()); }); it("-5 week and variants", function () { this.d = (new Date()).add(-5).weeks(); var d2 = Date.parse("-5w"); var d3 = Date.parse("-5 w"); var d16 = Date.parse(" - 5 w"); var d4 = Date.parse("-5week"); var d5 = Date.parse("-5 week"); var d6 = Date.parse(" - 5 week"); var d7 = Date.parse("-5weeks"); var d8 = Date.parse("-5 weeks"); var d9 = Date.parse(" - 5 weeks"); var d10 = Date.parse("-5Week"); var d11 = Date.parse("-5 Week"); var d12 = Date.parse(" - 5 Week"); var d13 = Date.parse("-5Weeks"); var d14 = Date.parse("-5 Weeks"); var d15 = Date.parse(" - 5 Weeks"); expect(this.d.getWeek()).toBe(d2.getWeek()); expect(this.d.getWeek()).toBe(d3.getWeek()); expect(this.d.getWeek()).toBe(d4.getWeek()); expect(this.d.getWeek()).toBe(d5.getWeek()); expect(this.d.getWeek()).toBe(d6.getWeek()); expect(this.d.getWeek()).toBe(d7.getWeek()); expect(this.d.getWeek()).toBe(d8.getWeek()); expect(this.d.getWeek()).toBe(d9.getWeek()); expect(this.d.getWeek()).toBe(d10.getWeek()); expect(this.d.getWeek()).toBe(d11.getWeek()); expect(this.d.getWeek()).toBe(d12.getWeek()); expect(this.d.getWeek()).toBe(d13.getWeek()); expect(this.d.getWeek()).toBe(d14.getWeek()); expect(this.d.getWeek()).toBe(d15.getWeek()); expect(this.d.getWeek()).toBe(d16.getWeek()); }); }); ================================================ FILE: specs/Extras-spec.js ================================================ /*globals require, describe, it, expect */ if (typeof process !== "undefined") { process.env.TZ = "America/Los_Angeles"; } if (typeof require === "function") { require("../index.js"); } describe("Extras Module", function(){ var correctDate = new Date(1995, 11, 4, 0, 0, 0, 0); describe("Supports basic utilities", function(){ it("has strtotime for String to Timestamp conversion", function () { var t = Date.strtotime("04/13/08"); // 1208070000 var t2 = Date.strtotime("1970-01-01T00:00:00Z"); // 0 expect(t).toBe(1208070000); expect(t2).toBe(0); }); it("has strftime for UNIX style String formatting", function () { var d = Date.strftime("%m/%d/%y", correctDate); var d2 = Date.strftime("c", correctDate); expect(d).toBe("12/04/95"); expect(d2).toBe("1995-12-04T08:00:00.000Z"); }); it("falls back to 'toString' with no format", function () { var str = correctDate._format(); // using underscore to test core func expect(str).toBe("Mon Dec 04 1995 00:00:00 GMT-0800 (PST)"); }); }); describe("has Normalization functions", function(){ it("can substitute PHP Date formats to SimpleDateFormat", function () { var PHPFormat ="d/%d/dd/D/%a/j/l/%A/S/F/%B/m/%m/M/%b/%h/n/Y/%Y/y/%y/g/%I/G/h/H/%H/i/%M/s/%S/%r/%R/%T/%X/%x/%e/%D/%n/%t"; var SimpleDateFormat = "dd/dd/dddd/ddd/ddd/dddd/dddd/dddd/S/MMMM/MMMM/MM/MM/MMM/MMM/MMM/M/yyyy/yyyy/yy/yy/h/h/H/hh/HH/HH/mm/mm/ss/ss/hh:mm tt/H:mm/H:mm:ss/t/d/d/MM/dd/yy/\\n/\\t"; expect(Date.normalizeFormat(PHPFormat)).toBe(SimpleDateFormat); }); it("can interpret PHP Date formats to calculated formats", function () { var PHPFormat ="d/%d/dd/D/%a/j/l/%A/S/F/%B/m/%m/M/%b/%h/n/Y/%Y/y/%y/g/%I/G/h/H/%H/i/%M/s/%S/%r/%R/%T/%X/%x/%e/%D/%n/%t"; var SimpleDateFormat = "dd/dd/dddd/ddd/ddd/dddd/dddd/dddd/S/MMMM/MMMM/MM/MM/MMM/MMM/MMM/M/yyyy/yyyy/yy/yy/h/h/H/hh/HH/HH/mm/mm/ss/ss/hh:mm tt/H:mm/H:mm:ss/t/d/d/MM/dd/yy/\\n/\\t"; expect(Date.normalizeFormat(PHPFormat)).toBe(SimpleDateFormat); }); }); }); ================================================ FILE: specs/I18n-spec.js ================================================ /*globals require, jasmine, describe, it, expect, spyOn */ if (typeof process !== "undefined") { process.env.TZ = 'America/Los_Angeles'; } if (typeof require === "function") { require("../index.js"); } var langList = ["af-ZA", "ar-AE", "ar-BH", "ar-DZ", "ar-EG", "ar-IQ", "ar-JO", "ar-KW", "ar-LB", "ar-LY", "ar-MA", "ar-OM", "ar-QA", "ar-SA", "ar-SY", "ar-TN", "ar-YE", "az-Cyrl-AZ", "az-Latn-AZ", "be-BY", "bg-BG", "bs-Latn-BA", "ca-ES", "cs-CZ", "cy-GB", "da-DK", "de-AT", "de-CH", "de-DE", "de-LI", "de-LU", "dv-MV", "el-GR", "en-029", "en-AU", "en-BZ", "en-CA", "en-GB", "en-IE", "en-JM", "en-NZ", "en-PH", "en-TT", "en-US", "en-ZA", "en-ZW", "es-AR", "es-BO", "es-CL", "es-CO", "es-CR", "es-DO", "es-EC", "es-ES", "es-GT", "es-HN", "es-MX", "es-NI", "es-PA", "es-PE", "es-PR", "es-PY", "es-SV", "es-UY", "es-VE", "et-EE", "eu-ES", "fa-IR", "fi-FI", "fo-FO", "fr-BE", "fr-CA", "fr-CH", "fr-FR", "fr-LU", "fr-MC", "gl-ES", "gu-IN", "he-IL", "hi-IN", "hr-BA", "hr-HR", "hu-HU", "hy-AM", "id-ID", "is-IS", "it-CH", "it-IT", "ja-JP", "ka-GE", "kk-KZ", "kn-IN", "ko-KR", "kok-IN", "ky-KG", "lt-LT", "lv-LV", "mi-NZ", "mk-MK", "mn-MN", "mr-IN", "ms-BN", "ms-MY", "mt-MT", "nb-NO", "nl-BE", "nl-NL", "nn-NO", "ns-ZA", "pa-IN", "pl-PL", "pt-BR", "pt-PT", "quz-BO", "quz-EC", "quz-PE", "ro-RO", "ru-RU", "sa-IN", "se-FI", "se-NO", "se-SE", "sk-SK", "sl-SI", "sma-NO", "sma-SE", "smj-NO", "smj-SE", "smn-FI", "sms-FI", "sq-AL", "sr-Cyrl-BA", "sr-Cyrl-CS", "sr-Latn-BA", "sr-Latn-CS", "sv-FI", "sv-SE", "sw-KE", "syr-SY", "ta-IN", "te-IN", "th-TH", "tn-ZA", "tr-TR", "tt-RU", "uk-UA", "ur-PK", "uz-Cyrl-UZ", "uz-Latn-UZ", "vi-VN", "xh-ZA", "zh-CN", "zh-HK", "zh-MO", "zh-SG", "zh-TW", "zu-ZA"]; describe("Internationalization Module", function() { describe("has " + langList.length + " supported languages", function() { var list = langList.slice(0); // clone array; var next; for (var i=0; i < langList.length; i++) { next = list.shift(); it("loads " + next, function(done) { Date.i18n.setLanguage(next, false, function(){ expect(Date.i18n.currentLanguage()).toBe(next); done(); }); }); } }); xit("can support parsing other languages", function(done) { // x'ing out atm as there are issues running this in phantom JS for... no obvious reason. // this is an async spec function cb(){ setTimeout(function(){ var d = Date.parse("31/Oktober/2013"); expect(d).not.toBeNull(); expect(d).not.toBeNaN(); expect(d).not.toBeUndefined(); if (d) { expect(d.getDate()).toBe(31); expect(d.getMonth()).toBe(9); expect(d.getFullYear()).toBe(2013); } expect(Date.i18n.__("Sunday")).toBe("Sonntag"); expect(Date.getDayNumberFromName("Sonntag")).toBe(0); done(); },0); } Date.i18n.setLanguage("de-DE",false, cb); }); it("handles junk/invalid tags gracefully", function() { // now force language to be null var cfg = Date.Config; Date.Config = {}; var langSet = Date.i18n.setLanguage("junk"); expect(langSet).toBe(false); Date.Config = cfg; }); it("defaults to US English when no other language is loaded", function() { // now force language to be null Date.i18n.setLanguage(null, true); Date.i18n.updateCultureInfo(); expect(Date.i18n.__("Sunday")).toBe("Sunday"); expect(Date.getDayNumberFromName("Sonntag")).toBe(-1); expect(Date.getDayNumberFromName("Sunday")).toBe(0); }); }); ================================================ FILE: specs/ISOparsing-spec.js ================================================ /*globals require, jasmine, describe, it, expect, spyOn */ if (typeof process !== "undefined") { process.env.TZ = 'America/Los_Angeles'; } if (typeof require === "function") { require("../index.js"); } describe("ISO 8601 Date Parser", function() { var correctDate = new Date(1995, 11, 4, 0, 0, 0, 0); var $P = Date.Parsing; it("should return a Date object for valid ISO Date", function() { var d = $P.ISO.parse("1995-12-04"); expect(d instanceof Date).toEqual(true); }); it("should return null for invalid ISO Date", function() { var d = $P.ISO.parse("notarealISOdate"); expect(d).toBeNull(); }); it("should call processTimeObject method when has valid ISO Date", function() { spyOn($P, "processTimeObject"); $P.ISO.parse("1995-12-04"); expect($P.processTimeObject).toHaveBeenCalled(); }); it("should not call processTimeObject method when invalid ISO Date", function() { spyOn($P, "processTimeObject"); $P.ISO.parse("notarealISOdate"); expect($P.processTimeObject).not.toHaveBeenCalled(); }); it("should pass processTimeObject an object with at least a year property", function() { spyOn($P, "processTimeObject"); $P.ISO.parse("1995-12-04"); var x = $P.processTimeObject.calls.mostRecent().args[0]; expect($P.processTimeObject).toHaveBeenCalled(); expect(x).toEqual(jasmine.any(Object)); expect(x.year).toBeDefined(); }); describe("should parse the following", function() { describe("date formats", function() { it("1995", function() { correctDate.setMonth(0); correctDate.setDate(1); var d = Date.parse("1995"); expect(d.getTime()).toEqual(correctDate.getTime()); }); it("1995-12", function() { correctDate.setMonth(11); var d = Date.parse("1995-12"); expect(d.getTime()).toEqual(correctDate.getTime()); }); it("1995-12-04", function() { correctDate.setMonth(11); correctDate.setDate(4); var d = Date.parse("1995-12-04"); expect(d.getTime()).toEqual(correctDate.getTime()); }); it("19951204", function() { correctDate.setMonth(11); correctDate.setDate(4); var d = Date.parse("19951204"); expect(d.getTime()).toEqual(correctDate.getTime()); }); }); describe("time formats", function() { it("1995-12T13", function() { correctDate = new Date(1995, 11, 1, 13, 0, 0, 0); var d = Date.parse("1995-12T13"); expect(d.getTime()).toEqual(correctDate.getTime()); }); it("1995-12T13:30", function() { correctDate = new Date(1995, 11, 1, 13, 30, 0, 0); var d = Date.parse("1995-12T13:30"); expect(d.getTime()).toEqual(correctDate.getTime()); }); it("1995-12T13:30:30", function() { correctDate = new Date(1995, 11, 1, 13, 30, 30, 0); var d = Date.parse("1995-12T13:30:30"); expect(d.getTime()).toEqual(correctDate.getTime()); }); it("1995-12T13:30:30.255", function() { correctDate = new Date(1995, 11, 1, 13, 30, 30, 255); var d = Date.parse("1995-12T13:30:30.255"); expect(d.getTime()).toEqual(correctDate.getTime()); }); it("1995-12 13", function() { correctDate = new Date(1995, 11, 1, 13, 0, 0, 0); var d = Date.parse("1995-12 13"); expect(d.getTime()).toEqual(correctDate.getTime()); }); it("1995-12 13:30", function() { correctDate = new Date(1995, 11, 1, 13, 30, 0, 0); var d = Date.parse("1995-12 13:30"); expect(d.getTime()).toEqual(correctDate.getTime()); }); it("1995-12 13:30:30", function() { correctDate = new Date(1995, 11, 1, 13, 30, 30, 0); var d = Date.parse("1995-12 13:30:30"); expect(d.getTime()).toEqual(correctDate.getTime()); }); it("1995-12 13:30:30.255", function() { correctDate = new Date(1995, 11, 1, 13, 30, 30, 255); var d = Date.parse("1995-12T13:30:30.255"); expect(d.getTime()).toEqual(correctDate.getTime()); }); it("1995-12-04T13", function() { correctDate = new Date(1995, 11, 4, 13, 0, 0, 0); var d = Date.parse("1995-12-04T13"); expect(d.getTime()).toEqual(correctDate.getTime()); }); it("1995-12-04 13", function() { var d = Date.parse("1995-12-04 13"); expect(d.getTime()).toEqual(correctDate.getTime()); }); it("1995-12-04T13:30", function() { correctDate = new Date(1995, 11, 4, 13, 30, 0, 0); var d = Date.parse("1995-12-04T13:30"); expect(d.getTime()).toEqual(correctDate.getTime()); }); it("1995-12-04 13:30", function() { var d = Date.parse("1995-12-04 13:30"); expect(d.getTime()).toEqual(correctDate.getTime()); }); it("1995-12-04T13.5", function() { var d = Date.parse("1995-12-04T13.5"); expect(d.getTime()).toEqual(correctDate.getTime()); }); it("1995-12-04 13.5", function() { var d = Date.parse("1995-12-04 13.5"); expect(d.getTime()).toEqual(correctDate.getTime()); }); it("1995-12-04T13,5", function() { var d = Date.parse("1995-12-04T13,5"); expect(d.getTime()).toEqual(correctDate.getTime()); }); it("1995-12-04 13,5", function() { var d = Date.parse("1995-12-04 13,5"); expect(d.getTime()).toEqual(correctDate.getTime()); }); it("1995-12-04T13:30:30", function() { correctDate = new Date(1995, 11, 4, 13, 30, 30, 0); var d = Date.parse("1995-12-04T13:30:30"); expect(d.getTime()).toEqual(correctDate.getTime()); }); it("1995-12-04 13:30:30", function() { var d = Date.parse("1995-12-04 13:30:30"); expect(d.getTime()).toEqual(correctDate.getTime()); }); it("19951204T133030", function() { var d = Date.parse("19951204T133030"); expect(d.getTime()).toEqual(correctDate.getTime()); }); it("1995-12-04T13:30.5", function() { var d = Date.parse("1995-12-04T13:30.5"); expect(d.getTime()).toEqual(correctDate.getTime()); }); it("1995-12-04 13:30.5", function() { var d = Date.parse("1995-12-04 13:30.5"); expect(d.getTime()).toEqual(correctDate.getTime()); }); it("1995-12-04T13:30,5", function() { var d = Date.parse("1995-12-04T13:30,5"); expect(d.getTime()).toEqual(correctDate.getTime()); }); it("1995-12-04 13:30,5", function() { var d = Date.parse("1995-12-04 13:30,5"); expect(d.getTime()).toEqual(correctDate.getTime()); }); it("1995-12-04T13:30:30.255", function() { correctDate = new Date(1995, 11, 4, 13, 30, 30, 255); var d = Date.parse("1995-12-04T13:30:30.255"); expect(d.getTime()).toEqual(correctDate.getTime()); }); it("1995-12-04 13:30:30.255", function() { var d = Date.parse("1995-12-04 13:30:30.255"); expect(d.getTime()).toEqual(correctDate.getTime()); }); it("1995-12-04T13:30:30,255", function() { correctDate = new Date(1995, 11, 4, 13, 30, 30, 255); var d = Date.parse("1995-12-04T13:30:30,255"); expect(d.getTime()).toEqual(correctDate.getTime()); }); it("1995-12-04 13:30:30,255", function() { var d = Date.parse("1995-12-04 13:30:30,255"); expect(d.getTime()).toEqual(correctDate.getTime()); }); }); describe("timezone formats", function() { it("1995-12-04T13:30:30.255Z", function() { correctDate.setUTCHours(13); correctDate.setUTCDate(4); var d = Date.parse("1995-12-04T13:30:30.255Z"); expect(d.getTime()).toEqual(correctDate.getTime()); }); it("1995-12-04 13:30:30.255Z", function() { var d = Date.parse("1995-12-04 13:30:30.255Z"); expect(d.getTime()).toEqual(correctDate.getTime()); }); it("1995-12-04T13:30:30.255 Z", function() { var d = Date.parse("1995-12-04T13:30:30.255 Z"); expect(d.getTime()).toEqual(correctDate.getTime()); }); it("1995-12-04 13:30:30.255 Z", function() { var d = Date.parse("1995-12-04 13:30:30.255 Z"); expect(d.getTime()).toEqual(correctDate.getTime()); }); it("19951204T133030Z", function() { correctDate.setMilliseconds(0); var d = Date.parse("19951204T133030Z"); expect(d.getTime()).toEqual(correctDate.getTime()); }); it("19951204T133030.255Z", function() { correctDate.setMilliseconds(255); var d = Date.parse("19951204T133030.255Z"); expect(d.getTime()).toEqual(correctDate.getTime()); }); it("1995-12-04 13:30:30.255+00:00", function() { var d = Date.parse("1995-12-04 13:30:30.255+00:00"); expect(d.getTime()).toEqual(correctDate.getTime()); }); it("1995-12-04 13:30:30.255+01:00", function() { correctDate.setUTCHours(12); var d = Date.parse("1995-12-04 13:30:30.255+01:00"); expect(d.getTime()).toEqual(correctDate.getTime()); }); it("1995-12-04 13:30:30.255+01", function() { correctDate.setUTCHours(12); var d = Date.parse("1995-12-04 13:30:30.255+01"); expect(d.getTime()).toEqual(correctDate.getTime()); }); it("1995-12-04 13:30:30.255-05:00", function() { correctDate.setUTCHours(18); var d = Date.parse("1995-12-04 13:30:30.255-05:00"); expect(d.getTime()).toEqual(correctDate.getTime()); }); it("1995-12-04 13:30:30.255-05", function() { var d = Date.parse("1995-12-04 13:30:30.255-05"); expect(d.getTime()).toEqual(correctDate.getTime()); }); it("1995-12-04T13:30:30,255-05:00", function() { var d = Date.parse("1995-12-04 13:30:30.255-05"); expect(d.getTime()).toEqual(correctDate.getTime()); }); }); describe("week formats", function() { it("1995-W49", function() { correctDate = new Date(1995, 11, 4, 0, 0, 0, 0); var d = Date.parse("1995-W49-1"); expect(d.getTime()).toEqual(correctDate.getTime()); }); it("1995-W49-1", function() { var d = Date.parse("1995-W49-1"); expect(d.getTime()).toEqual(correctDate.getTime()); }); it("1995-W491", function() { var d = Date.parse("1995-W491"); expect(d.getTime()).toEqual(correctDate.getTime()); }); it("1995W491", function() { var d = Date.parse("1995W491"); expect(d.getTime()).toEqual(correctDate.getTime()); }); it("2004-W53-6", function() { // years can have 53 weeks! (per iso spec for weeks) correctDate = new Date(2005, 0, 1, 0, 0, 0, 0); var d = Date.parse("2004-W53-6"); expect(d.getTime()).toEqual(correctDate.getTime()); }); it("1995-W49-1T13", function() { correctDate = new Date(1995, 11, 4, 13, 0, 0, 0); var d = Date.parse("1995-W49-1T13"); expect(d.getTime()).toEqual(correctDate.getTime()); }); it("1995-W49-1 13", function() { var d = Date.parse("1995-W49-1 13"); expect(d.getTime()).toEqual(correctDate.getTime()); }); it("1995-W49-1T13:30", function() { correctDate.setMinutes(30); var d = Date.parse("1995-W49-1T13:30"); expect(d.getTime()).toEqual(correctDate.getTime()); }); it("1995-W49-1 13:30", function() { var d = Date.parse("1995-W49-1 13:30"); expect(d.getTime()).toEqual(correctDate.getTime()); }); it("1995-W49-1T13:30:30", function() { correctDate.setSeconds(30); var d = Date.parse("1995-W49-1T13:30:30"); expect(d.getTime()).toEqual(correctDate.getTime()); }); it("1995-W49-1 13:30:30", function() { var d = Date.parse("1995-W49-1 13:30:30"); expect(d.getTime()).toEqual(correctDate.getTime()); }); it("1995-W49-1T13:30:30.255", function() { correctDate.setMilliseconds(255); var d = Date.parse("1995-W49-1T13:30:30.255"); expect(d.getTime()).toEqual(correctDate.getTime()); }); it("1995-W49-1 13:30:30.255", function() { var d = Date.parse("1995-W49-1 13:30:30.255"); expect(d.getTime()).toEqual(correctDate.getTime()); }); it("1995-W49-1T13:30:30.255Z", function() { correctDate.setUTCHours(13); correctDate.setUTCDate(4); var d = Date.parse("1995-W49-1T13:30:30.255Z"); expect(d.getTime()).toEqual(correctDate.getTime()); }); it("1995-W49-1 13:30:30.255Z", function() { var d = Date.parse("1995-W49-1 13:30:30.255Z"); expect(d.getTime()).toEqual(correctDate.getTime()); }); it("1995-W49-1T13:30:30.255 Z", function() { var d = Date.parse("1995-W49-1T13:30:30.255 Z"); expect(d.getTime()).toEqual(correctDate.getTime()); }); it("1995-W49-1 13:30:30.255 Z", function() { var d = Date.parse("1995-W49-1 13:30:30.255 Z"); expect(d.getTime()).toEqual(correctDate.getTime()); }); }); describe("ordinal formats", function() { it("1995-338", function() { correctDate = new Date(1995, 11, 4, 0, 0, 0, 0); var d = Date.parse("1995-338"); expect(d.getTime()).toEqual(correctDate.getTime()); }); it("1995338", function() { correctDate = new Date(1995, 11, 4, 0, 0, 0, 0); var d = Date.parse("1995338"); expect(d.getTime()).toEqual(correctDate.getTime()); }); it("1995-338T13", function() { correctDate.setHours(13); var d = Date.parse("1995-338T13"); expect(d.getTime()).toEqual(correctDate.getTime()); }); it("1995-338 13", function() { var d = Date.parse("1995-338 13"); expect(d.getTime()).toEqual(correctDate.getTime()); }); it("1995-338T13:30", function() { correctDate.setMinutes(30); var d = Date.parse("1995-338T13:30"); expect(d.getTime()).toEqual(correctDate.getTime()); }); it("1995-338 13:30", function() { var d = Date.parse("1995-338 13:30"); expect(d.getTime()).toEqual(correctDate.getTime()); }); it("1995-338T13:30:30", function() { correctDate.setSeconds(30); var d = Date.parse("1995-338T13:30:30"); expect(d.getTime()).toEqual(correctDate.getTime()); }); it("1995-338 13:30:30", function() { var d = Date.parse("1995-338 13:30:30"); expect(d.getTime()).toEqual(correctDate.getTime()); }); it("1995-338T13:30:30.255", function() { correctDate.setMilliseconds(255); var d = Date.parse("1995-338T13:30:30.255"); expect(d.getTime()).toEqual(correctDate.getTime()); }); it("1995-338 13:30:30.255", function() { var d = Date.parse("1995-338 13:30:30.255"); expect(d.getTime()).toEqual(correctDate.getTime()); }); it("1995-338T13:30:30.255Z", function() { correctDate = new Date(1995, 11, 4, 13, 30, 30, 255); correctDate.setUTCHours(13); var d = Date.parse("1995-338T13:30:30.255Z"); expect(d.getTime()).toEqual(correctDate.getTime()); }); it("1995-338 13:30:30.255Z", function() { var d = Date.parse("1995-338 13:30:30.255Z"); expect(d.getTime()).toEqual(correctDate.getTime()); }); it("1995-338T13:30:30.255 Z", function() { var d = Date.parse("1995-338T13:30:30.255 Z"); expect(d.getTime()).toEqual(correctDate.getTime()); }); it("1995-338 13:30:30.255 Z", function() { var d = Date.parse("1995-338 13:30:30.255 Z"); expect(d.getTime()).toEqual(correctDate.getTime()); }); }); }); }); ================================================ FILE: specs/Parsing-spec.js ================================================ /*globals require, jasmine, describe, it, expect, spyOn */ if (typeof process !== "undefined") { process.env.TZ = 'America/Los_Angeles'; } if (typeof require === "function") { require("../index.js"); } describe("Parsing Module", function() { var correctDate = new Date(1995, 11, 4, 0, 0, 0, 0); describe("can work with Time and Date objects", function(){ it("simple example", function () { var d = Date.parse("December 4th, 1995"); expect(d.getTime()).toBe(correctDate.getTime()); }); it("more complex example", function () { var now = Date.today(); var t = {day: now.getDate(), month: now.getMonth()}; var d = Date.Parsing.processTimeObject(t); expect(d.getTime()).toBe(now.getTime()); }); it("processes Date objects correctly", function () { var now = Date.today(); var d = Date.parse(now); expect(d.getTime()).toBe(now.getTime()); }); }); describe("has basic date string parsing e.g.", function() { it("December 4th, 1995", function () { var d = Date.parse("December 4th, 1995"); expect(d.getTime()).toBe(correctDate.getTime()); }); it("Dec-04-95", function () { var d = Date.parse("Dec-04-95"); expect(d.getTime()).toBe(correctDate.getTime()); }); it("12-04-95", function () { var d = Date.parse("12-04-95"); expect(d.getTime()).toBe(correctDate.getTime()); }); it("12/04/95", function () { var d = Date.parse("12/04/95"); expect(d.getTime()).toBe(correctDate.getTime()); }); it("4-Dec-1995", function () { var d = Date.parse("4-Dec-1995"); expect(d.getTime()).toBe(correctDate.getTime()); }); it("1995-12-04", function () { var d = Date.parse("1995-12-04"); expect(d.getTime()).toBe(correctDate.getTime()); }); it("1995.12.04", function () { var d = Date.parse("1995.12.04"); expect(d.getTime()).toBe(correctDate.getTime()); }); it("12-4, '95", function () { var d = Date.parse("12-4, '95"); expect(d.getTime()).toBe(correctDate.getTime()); }); }); describe("supports variations in phrasing like", function() { it("4-Dec-1995", function () { var d = Date.parse("4-Dec-1995"); expect(d.getTime()).toBe(correctDate.getTime()); }); it("04-Dec-1995", function () { var d = Date.parse("04-Dec-1995"); expect(d.getTime()).toBe(correctDate.getTime()); }); it("04-Dec-95", function () { var d = Date.parse("04-Dec-95"); expect(d.getTime()).toBe(correctDate.getTime()); }); it("4-December-95", function () { var d = Date.parse("4-December-95"); expect(d.getTime()).toBe(correctDate.getTime()); }); it("4-December-1995", function () { var d = Date.parse("4-December-1995"); expect(d.getTime()).toBe(correctDate.getTime()); }); it("04-December-95", function () { var d = Date.parse("04-December-95"); expect(d.getTime()).toBe(correctDate.getTime()); }); it("04-December-1995", function () { var d = Date.parse("04-December-1995"); expect(d.getTime()).toBe(correctDate.getTime()); }); it("December 4 1995", function () { var d = Date.parse("December 4 1995"); expect(d.getTime()).toBe(correctDate.getTime()); }); it("December 4, 1995", function () { var d = Date.parse("December 4, 1995"); expect(d.getTime()).toBe(correctDate.getTime()); }); it("December 04, 1995", function () { var d = Date.parse("December 04, 1995"); expect(d.getTime()).toBe(correctDate.getTime()); }); it("December 4,1995", function () { var d = Date.parse("December 4,1995"); expect(d.getTime()).toBe(correctDate.getTime()); }); it("December 04,1995", function () { var d = Date.parse("December 04,1995"); expect(d.getTime()).toBe(correctDate.getTime()); }); it("December 4, 95", function () { var d = Date.parse("December 4, 95"); expect(d.getTime()).toBe(correctDate.getTime()); }); it("December 04,95", function () { var d = Date.parse("December 04,95"); expect(d.getTime()).toBe(correctDate.getTime()); }); it("December 4th, 1995", function () { var d = Date.parse("December 4th, 1995"); expect(d.getTime()).toBe(correctDate.getTime()); }); it("December 4th 1995", function () { var d = Date.parse("December 4th 1995"); expect(d.getTime()).toBe(correctDate.getTime()); }); it("Dec 4th 1995", function () { var d = Date.parse("Dec 4th 1995"); expect(d.getTime()).toBe(correctDate.getTime()); }); it("Dec 4th 95", function () { var d = Date.parse("Dec 4th 95"); expect(d.getTime()).toBe(correctDate.getTime()); }); it("Mon December 4, 1995", function () { var d = Date.parse("Mon December 4, 1995"); expect(d.getTime()).toBe(correctDate.getTime()); }); it("Mon December 4th, 1995", function () { var d = Date.parse("Mon December 4th, 1995"); expect(d.getTime()).toBe(correctDate.getTime()); }); it("Monday December 4, 1995", function () { var d = Date.parse("Monday December 4, 1995"); expect(d.getTime()).toBe(correctDate.getTime()); }); it("Monday December 4th, 1995", function () { var d = Date.parse("Monday December 4th, 1995"); expect(d.getTime()).toBe(correctDate.getTime()); }); it("Dec-04-1995", function () { var d = Date.parse("Dec-04-1995"); expect(d.getTime()).toBe(correctDate.getTime()); }); it("Dec-04-95", function () { var d = Date.parse("Dec-04-95"); expect(d.getTime()).toBe(correctDate.getTime()); }); }); describe("supports variations in seperators like", function() { it("12/4/1995", function () { var d = Date.parse("12/4/1995"); expect(d.getTime()).toBe(correctDate.getTime()); }); it("12-4-1995", function () { var d = Date.parse("12-4-1995"); expect(d.getTime()).toBe(correctDate.getTime()); }); it("12.4.1995", function () { var d = Date.parse("12.4.1995"); expect(d.getTime()).toBe(correctDate.getTime()); }); }); describe("supports shorter date formats", function() { var thisYear = Date.today().set({month: 9, day: 6}); it("10/6", function () { var d = Date.parse("10/6"); expect(d.getTime()).toBe(thisYear.getTime()); }); it("10.6", function () { var d = Date.parse("10.6"); expect(d.getTime()).toBe(thisYear.getTime()); }); }); describe("supports variations in sortable date formats", function() { it("1995/12/04", function () { var d = Date.parse("1995/12/04"); expect(d.getTime()).toBe(correctDate.getTime()); }); it("1995-12-04", function () { var d = Date.parse("1995-12-04"); expect(d.getTime()).toBe(correctDate.getTime()); }); it("1995.12.04", function () { var d = Date.parse("1995.12.04"); expect(d.getTime()).toBe(correctDate.getTime()); }); it("1995/12/4", function () { var d = Date.parse("1995/12/4"); expect(d.getTime()).toBe(correctDate.getTime()); }); it("1995-12-4", function () { var d = Date.parse("1995-12-4"); expect(d.getTime()).toBe(correctDate.getTime()); }); it("1995.12.4", function () { var d = Date.parse("1995.12.4"); expect(d.getTime()).toBe(correctDate.getTime()); }); }); describe("supports completely numeric date formats", function() { it("12495", function () { var d = Date.parse("12495"); expect(d.getTime()).toBe(correctDate.getTime()); }); it("120495", function () { var d = Date.parse("120495"); expect(d.getTime()).toBe(correctDate.getTime()); }); it("1241995", function () { var d = Date.parse("1241995"); expect(d.getTime()).toBe(correctDate.getTime()); }); it("12041995", function () { var d = Date.parse("12041995"); expect(d.getTime()).toBe(correctDate.getTime()); }); it("treats formats less than 5 digits as years", function () { var d = Date.Parsing.Numeric.parse("2004"); expect(d.getFullYear()).toBe(2004); }); it("returns null for invalid Numeric formats", function () { var d = Date.Parsing.Numeric.parse("331220045"); expect(d).toBeNull(); }); it("returns null for non-Numeric formats", function () { var d = Date.Parsing.Numeric.parse("nonnumeric"); expect(d).toBeNull(); }); }); describe("supports relative dates like", function() { it("last tuesday", function () { var d = Date.parse("last tuesday"); var d2 = Date.today(); var diff = Math.abs(d.getElapsed(Date.today())/1000/60/60/24); // days expect(d.getDay()).toBe(2); expect(diff <= 7).toBeTruthy(); }); it("next tuesday", function () { var d = Date.parse("next tuesday"); var d2 = Date.today(); var diff = Math.abs(d.getElapsed(Date.today())/1000/60/60/24); // days expect(d.getDay()).toBe(2); expect(diff <= 7).toBeTruthy(); }); it("last week", function () { var d = Date.parse("last week"); var w = Date.today().addWeeks(-1).getWeek(); expect(w).toBe(d.getWeek()); }); it("next week", function () { var d = Date.parse("next week"); var w = Date.today().getWeek(); expect(w+1).toBe(d.getWeek()); }); it("thursday last week", function () { var d = Date.parse("thursday last week"); var d2 = Date.thursday().last().week(); expect(d2.equals(d)).toBe(true); }); it("tuesday next week", function () { var d = Date.parse("tuesday next week"); var d2 = Date.tuesday().next().week(); expect(d2.equals(d)).toBe(true); }); it("tuesday 2 weeks from now", function () { var d = Date.parse("tuesday 2 weeks from now"); var d2 = Date.tuesday().addWeeks(2).setTimeToNow(); expect(d2.equals(d)).toBe(true); }); it("this morning", function () { var d = Date.parse("this morning"); var d2 = Date.today().set({hour: 9}); expect(d2.equals(d)).toBe(true); }); it("6 in the morning", function () { var d = Date.parse("6 in the morning"); var d2 = Date.today().set({hour: 6}); expect(d2.equals(d)).toBe(true); }); it("sat 7 in the evening", function () { var d = Date.parse("sat 7 in the evening"); var d2 = Date.saturday().set({hour:19}); expect(d2.equals(d)).toBe(true); }); it("tomorrow 3pm", function () { var d = Date.parse("tomorrow 3pm"); var d2 = Date.today().addDays(1).set({hour: 15}); expect(d2.equals(d)).toBe(true); }); it("tomorrow 3am", function () { var d = Date.parse("tomorrow 3am"); var d2 = Date.today().addDays(1).set({hour: 3}); expect(d2.equals(d)).toBe(true); }); it("3pm tomorrow", function () { var d = Date.parse("3pm tomorrow"); var d2 = Date.today().addDays(1).set({hour: 15}); expect(d2.equals(d)).toBe(true); }); it("3am tomorrow", function () { var d = Date.parse("3am tomorrow"); var d2 = Date.today().addDays(1).set({hour: 3}); expect(d2.equals(d)).toBe(true); }); it("3 tomorrow", function () { var d = Date.parse("3 tomorrow"); var d2 = Date.today().addDays(1).set({hour: 3}); expect(d2.equals(d)).toBe(true); }); it("15 tomorrow", function () { var d = Date.parse("15 tomorrow"); var d2 = Date.today().addDays(1).set({hour: 15}); expect(d2.equals(d)).toBe(true); }); it("today", function () { var d = Date.today(); expect(Date.parse("today").getTime()).toBe(d.getTime()); }); it("tomorrow", function () { var d = Date.today().add(1).days(); expect(Date.parse("tomorrow").getTime()).toBe(d.getTime()); }); it("today 18:00", function () { var d = Date.today().set({hour: 18}); expect(Date.parse("today 18:00").getTime()).toBe(d.getTime()); expect(Date.parse("today 18").getTime()).toBe(d.getTime()); }); it("tomorrow 18:00", function () { var d = Date.today().add(1).days().set({hour: 18}); expect(Date.parse("tomorrow 18:00").getTime()).toBe(d.getTime()); expect(Date.parse("tomorrow 18").getTime()).toBe(d.getTime()); }); }); describe("can parse Timezones correctly", function() { it("defaults to local timezone", function (){ var d = Date.parse("30 Dec 2011 7pm"); var d2 = new Date(2011, 11, 30, 19); expect(d2.equals(d)).toBe(true); }); it("EST changes time", function (){ var d = Date.parse("30 Dec 2011 7pm EST"); var d2 = new Date(2011, 11, 30, 16); expect(d2.equals(d)).toBe(true); }); it("uses correct timezone when incorect DST timezone is specified", function (){ var d = Date.parse("30 Dec 2011 7pm EDT"); var d2 = new Date(2011, 11, 30, 16); expect(d2.equals(d)).toBe(true); }); }); describe("parses 'dd MMM yyyy' format correctly", function() { it("30 Dec 2011", function () { var d = Date.parse("30 Dec 2011"); var d2 = new Date(2011, 11, 30); expect(d2.equals(d)).toBe(true); }); it("31 Dec 2011", function () { var d = Date.parse("31 Dec 2011"); var d2 = new Date(2011, 11, 31); expect(d2.equals(d)).toBe(true); }); it("30 Oct 2011", function () { var d = Date.parse("30 Oct 2011"); var d2 = new Date(2011, 9, 30); expect(d2.equals(d)).toBe(true); }); it("31 Oct 2011", function () { var d = Date.parse("31 Oct 2011"); var d2 = new Date(2011, 9, 31); expect(d2.equals(d)).toBe(true); }); it("29 Oct 2011", function () { var d = Date.parse("29 Oct 2011"); var d2 = new Date(2011, 9, 29); expect(d2.equals(d)).toBe(true); }); it("29 Oct 2010", function () { var d = Date.parse("29 Oct 2010"); var d2 = new Date(2010, 9, 29); expect(d2.equals(d)).toBe(true); }); it("2011 Oct 29", function () { var d = Date.parse("2011 Oct 29"); var d2 = new Date(2011, 9, 29); expect(d2.equals(d)).toBe(true); }); }); }); ================================================ FILE: specs/SpecRunner.html ================================================ DateJS Spec Runner
================================================ FILE: specs/Sugarpak-spec.js ================================================ /*globals require, describe, it, expect */ if (typeof process !== "undefined") { process.env.TZ = 'America/Los_Angeles'; } if (typeof require === "function") { require("../index.js"); } describe("Sugarpak Extensions", function() { describe("has syntax sugar to allow movement to relative dates",function (){ it("can move to the nth instance of a day",function(){ var d = new Date(2013, 0); d.april().second().monday(); expect(d.getMonth()).toBe(3); expect(d.getDate()).toBe(8); expect(d.getDay()).toBe(1); d.march().add(1).second().second().monday(); expect(d.getMonth()).toBe(2); expect(d.getDate()).toBe(10); expect(d.getDay()).toBe(1); expect(d.getSeconds()).toBe(1); d = new Date(2013, 0); d.second().weekday(); expect(d.getDate()).toBe(2); }); it("like month names", function() { expect(Date.today().jan().getMonth()).toBe(0); expect(Date.today().feb().getMonth()).toBe(1); expect(Date.today().mar().getMonth()).toBe(2); expect(Date.today().apr().getMonth()).toBe(3); expect(Date.today().may().getMonth()).toBe(4); expect(Date.today().jun().getMonth()).toBe(5); expect(Date.today().jul().getMonth()).toBe(6); expect(Date.today().aug().getMonth()).toBe(7); expect(Date.today().sep().getMonth()).toBe(8); expect(Date.today().oct().getMonth()).toBe(9); expect(Date.today().nov().getMonth()).toBe(10); expect(Date.today().dec().getMonth()).toBe(11); }); it("will throw an exception when nth instance doesn't exist", function() { var d = new Date(2013, 0); var foo = function () { d.february().fifth().friday(); }; expect(foo).toThrow(); }); }); describe("has constants to describe",function (){ it("months", function() { expect(Date.MARCH).toBe(2); expect(Date.MAR).toBe(2); }); it("days", function() { expect(Date.FRIDAY).toBe(5); expect(Date.FRI).toBe(5); }); }); describe("can move to next",function (){ it("monday", function() { var d1 = new Date(1995, 11, 11); var d2 = new Date(1995, 11, 4); d2.next().monday(); expect(d1.equals(d2)).toBe(true); var d3 = Date.next().monday(); expect(d3.getDay()).toBe(1); var elapsed = (Date.today().getElapsed(d3))/86400000; // milliseconds in a day expect(elapsed).toBeLessThan(8); expect(elapsed).toBeGreaterThan(0); }); it("tuesday", function() { var d1 = new Date(1995, 11, 5); var d2 = new Date(1995, 11, 4); d2.next().tuesday(); expect(d1.equals(d2)).toBe(true); var d3 = Date.next().tuesday(); expect(d3.getDay()).toBe(2); var elapsed = (Date.today().getElapsed(d3))/86400000; // milliseconds in a day expect(elapsed).toBeLessThan(8); expect(elapsed).toBeGreaterThan(0); }); it("wednesday", function() { var d1 = new Date(1995, 11, 6); var d2 = new Date(1995, 11, 4); d2.next().wednesday(); expect(d1.equals(d2)).toBe(true); var d3 = Date.next().wednesday(); expect(d3.getDay()).toBe(3); var elapsed = (Date.today().getElapsed(d3))/86400000; // milliseconds in a day expect(elapsed).toBeLessThan(8); expect(elapsed).toBeGreaterThan(0); }); it("thursday", function() { var d1 = new Date(1995, 11, 7); var d2 = new Date(1995, 11, 4); d2.next().thursday(); expect(d1.equals(d2)).toBe(true); var d3 = Date.next().thursday(); expect(d3.getDay()).toBe(4); var elapsed = (Date.today().getElapsed(d3))/86400000; // milliseconds in a day expect(elapsed).toBeLessThan(8); expect(elapsed).toBeGreaterThan(0); }); it("friday", function() { var d1 = new Date(1995, 11, 8); var d2 = new Date(1995, 11, 4); d2.next().friday(); expect(d1.equals(d2)).toBe(true); var d3 = Date.next().friday(); expect(d3.getDay()).toBe(5); var elapsed = (Date.today().getElapsed(d3))/86400000; // milliseconds in a day expect(elapsed).toBeLessThan(8); expect(elapsed).toBeGreaterThan(0); }); it("saturday", function() { var d1 = new Date(1995, 11, 9); var d2 = new Date(1995, 11, 4); d2.next().saturday(); expect(d1.equals(d2)).toBe(true); var d3 = Date.next().saturday(); expect(d3.getDay()).toBe(6); var elapsed = (Date.today().getElapsed(d3))/86400000; // milliseconds in a day expect(elapsed).toBeLessThan(8); expect(elapsed).toBeGreaterThan(0); }); it("sunday", function() { var d1 = new Date(1995, 11, 10); var d2 = new Date(1995, 11, 4); d2.next().sunday(); expect(d1.equals(d2)).toBe(true); var d3 = Date.next().sunday(); expect(d3.getDay()).toBe(0); var elapsed = (Date.today().getElapsed(d3))/86400000; // milliseconds in a day expect(elapsed).toBeLessThan(8); expect(elapsed).toBeGreaterThan(0); }); it("weekday", function() { var d1 = new Date(1995, 11, 5); var d2 = new Date(1995, 11, 4); d2.next().weekday(); expect(d1.equals(d2)).toBe(true); d1 = new Date(1995, 11, 4); d2 = new Date(1995, 11, 1); d2.next().weekday(); expect(d1.equals(d2)).toBe(true); }); }); describe("can move to last",function (){ it("monday", function() { var d1 = new Date(1995, 10, 27); var d2 = new Date(1995, 11, 4); d2.last().monday(); expect(d1.equals(d2)).toBe(true); var d3 = Date.last().monday(); expect(d3.getDay()).toBe(1); var elapsed = (Date.today().getElapsed(d3))/86400000; // milliseconds in a day expect(elapsed).toBeLessThan(0); expect(elapsed).toBeGreaterThan(-8); }); it("tuesday", function() { var d1 = new Date(1995, 10, 28); var d2 = new Date(1995, 11, 4); d2.last().tuesday(); expect(d1.equals(d2)).toBe(true); var d3 = Date.last().tuesday(); expect(d3.getDay()).toBe(2); var elapsed = (Date.today().getElapsed(d3))/86400000; // milliseconds in a day expect(elapsed).toBeLessThan(0); expect(elapsed).toBeGreaterThan(-8); }); it("wednesday", function() { var d1 = new Date(1995, 10, 29); var d2 = new Date(1995, 11, 4); d2.last().wednesday(); expect(d1.equals(d2)).toBe(true); var d3 = Date.last().wednesday(); expect(d3.getDay()).toBe(3); var elapsed = (Date.today().getElapsed(d3))/86400000; // milliseconds in a day expect(elapsed).toBeLessThan(0); expect(elapsed).toBeGreaterThan(-8); }); it("thursday", function() { var d1 = new Date(1995, 10, 30); var d2 = new Date(1995, 11, 4); d2.last().thursday(); expect(d1.equals(d2)).toBe(true); var d3 = Date.last().thursday(); expect(d3.getDay()).toBe(4); var elapsed = (Date.today().getElapsed(d3))/86400000; // milliseconds in a day expect(elapsed).toBeLessThan(0); expect(elapsed).toBeGreaterThan(-8); }); it("friday", function() { var d1 = new Date(1995, 11, 1); var d2 = new Date(1995, 11, 4); d2.last().friday(); expect(d1.equals(d2)).toBe(true); var d3 = Date.last().friday(); expect(d3.getDay()).toBe(5); var elapsed = (Date.today().getElapsed(d3))/86400000; // milliseconds in a day expect(elapsed).toBeLessThan(0); expect(elapsed).toBeGreaterThan(-8); }); it("saturday", function() { var d1 = new Date(1995, 11, 2); var d2 = new Date(1995, 11, 4); d2.last().saturday(); expect(d1.equals(d2)).toBe(true); var d3 = Date.last().saturday(); expect(d3.getDay()).toBe(6); var elapsed = (Date.today().getElapsed(d3))/86400000; // milliseconds in a day expect(elapsed).toBeLessThan(0); expect(elapsed).toBeGreaterThan(-8); }); it("sunday", function() { var d1 = new Date(1995, 11, 3); var d2 = new Date(1995, 11, 4); d2.last().sunday(); expect(d1.equals(d2)).toBe(true); var d3 = Date.last().sunday(); expect(d3.getDay()).toBe(0); var elapsed = (Date.today().getElapsed(d3))/86400000; // milliseconds in a day expect(elapsed).toBeLessThan(0); expect(elapsed).toBeGreaterThan(-8); }); it("weekday", function() { var d1 = new Date(1995, 11, 5); var d2 = new Date(1995, 11, 4); d1.last().weekday(); expect(d1.equals(d2)).toBe(true); d1 = new Date(1995, 11, 1); d2 = new Date(1995, 11, 4); d2.last().weekday(); expect(d1.equals(d2)).toBe(true); }); }); describe("can can check if a date is",function (){ it("a specific day", function() { var d = new Date(1995, 10, 27); expect(d.is().monday()).toBe(true); expect(d.is().friday()).toBe(false); }); it("a weekday", function() { var d = new Date(1995, 10, 27); expect(d.is().weekday()).toBe(true); expect(d.weekday()).toBe(false); d = new Date(1995, 10, 26); expect(d.is().weekday()).toBe(false); expect(Date.today().next().sunday().is().weekday()).toBe(false); }); it("a weekend", function() { var d = new Date(1995, 10, 27); expect(d.is().weekend()).toBe(false); d = new Date(1995, 10, 26); expect(d.is().weekend()).toBe(true); expect(d.weekend()).toBe(false); }); it("a month", function() { var d = new Date(1995, 10, 27); expect(d.is().november()).toBe(true); expect(d.is().april()).toBe(false); }); it("today", function() { var d = new Date(); expect(d.is().today()).toBe(true); }); it("holding the same properties as another date", function() { var d = new Date(); var d2 = Date.today(); expect(d.same().day(d2)).toBe(true); expect(d.same().minute(d2)).toBe(false); }); }); describe("can create Dates using syntax sugar",function (){ it("at a time that we can parse", function() { var d = Date.today().at("6:15pm"); expect(d.is().today()).toBe(true); expect(d.is().today()).toBe(true); }); it("like (Number) ago", function() { var d = (3).days().ago(); var elapsed = Math.floor((d.getElapsed(Date.now(true)))/86400000); // milliseconds in a day expect(elapsed).toBe(3); }); it("like (Number) fromNow", function() { var d = (3).days().fromNow(); var elapsed = Math.floor((d.getElapsed(Date.now(true)))/86400000); // milliseconds in a day expect(elapsed).toBe(-3); }); it("from an object", function() { var o = {month: 3, day: 17, hour: 13}; var d = Date.fromObject(o); expect(d.getDate()).toBe(17); expect(d.getMonth()).toBe(3); expect(d.getHours()).toBe(13); }); it("like month names", function() { expect(Date.jan().getMonth()).toBe(0); expect(Date.feb().getMonth()).toBe(1); expect(Date.mar().getMonth()).toBe(2); expect(Date.apr().getMonth()).toBe(3); expect(Date.may().getMonth()).toBe(4); expect(Date.jun().getMonth()).toBe(5); expect(Date.jul().getMonth()).toBe(6); expect(Date.aug().getMonth()).toBe(7); expect(Date.sep().getMonth()).toBe(8); expect(Date.oct().getMonth()).toBe(9); expect(Date.nov().getMonth()).toBe(10); expect(Date.dec().getMonth()).toBe(11); }); }); }); ================================================ FILE: specs/jasmine-2.0.3/boot.js ================================================ /** Starting with version 2.0, this file "boots" Jasmine, performing all of the necessary initialization before executing the loaded environment and all of a project's specs. This file should be loaded after `jasmine.js`, but before any project source files or spec files are loaded. Thus this file can also be used to customize Jasmine for a project. If a project is using Jasmine via the standalone distribution, this file can be customized directly. If a project is using Jasmine via the [Ruby gem][jasmine-gem], this file can be copied into the support directory via `jasmine copy_boot_js`. Other environments (e.g., Python) will have different mechanisms. The location of `boot.js` can be specified and/or overridden in `jasmine.yml`. [jasmine-gem]: http://github.com/pivotal/jasmine-gem */ (function() { /** * ## Require & Instantiate * * Require Jasmine's core files. Specifically, this requires and attaches all of Jasmine's code to the `jasmine` reference. */ window.jasmine = jasmineRequire.core(jasmineRequire); /** * Since this is being run in a browser and the results should populate to an HTML page, require the HTML-specific Jasmine code, injecting the same reference. */ jasmineRequire.html(jasmine); /** * Create the Jasmine environment. This is used to run all specs in a project. */ var env = jasmine.getEnv(); /** * ## The Global Interface * * Build up the functions that will be exposed as the Jasmine public interface. A project can customize, rename or alias any of these functions as desired, provided the implementation remains unchanged. */ var jasmineInterface = jasmineRequire.interface(jasmine, env); /** * Add all of the Jasmine global/public interface to the proper global, so a project can use the public interface directly. For example, calling `describe` in specs instead of `jasmine.getEnv().describe`. */ if (typeof window == "undefined" && typeof exports == "object") { extend(exports, jasmineInterface); } else { extend(window, jasmineInterface); } /** * ## Runner Parameters * * More browser specific code - wrap the query string in an object and to allow for getting/setting parameters from the runner user interface. */ var queryString = new jasmine.QueryString({ getWindowLocation: function() { return window.location; } }); var catchingExceptions = queryString.getParam("catch"); env.catchExceptions(typeof catchingExceptions === "undefined" ? true : catchingExceptions); /** * ## Reporters * The `HtmlReporter` builds all of the HTML UI for the runner page. This reporter paints the dots, stars, and x's for specs, as well as all spec names and all failures (if any). */ var htmlReporter = new jasmine.HtmlReporter({ env: env, onRaiseExceptionsClick: function() { queryString.setParam("catch", !env.catchingExceptions()); }, getContainer: function() { return document.body; }, createElement: function() { return document.createElement.apply(document, arguments); }, createTextNode: function() { return document.createTextNode.apply(document, arguments); }, timer: new jasmine.Timer() }); /** * The `jsApiReporter` also receives spec results, and is used by any environment that needs to extract the results from JavaScript. */ env.addReporter(jasmineInterface.jsApiReporter); env.addReporter(htmlReporter); /** * Filter which specs will be run by matching the start of the full name against the `spec` query param. */ var specFilter = new jasmine.HtmlSpecFilter({ filterString: function() { return queryString.getParam("spec"); } }); env.specFilter = function(spec) { return specFilter.matches(spec.getFullName()); }; /** * Setting up timing functions to be able to be overridden. Certain browsers (Safari, IE 8, phantomjs) require this hack. */ window.setTimeout = window.setTimeout; window.setInterval = window.setInterval; window.clearTimeout = window.clearTimeout; window.clearInterval = window.clearInterval; /** * ## Execution * * Replace the browser window's `onload`, ensure it's called, and then run all of the loaded specs. This includes initializing the `HtmlReporter` instance and then executing the loaded Jasmine environment. All of this will happen after all of the specs are loaded. */ var currentWindowOnload = window.onload; window.onload = function() { if (currentWindowOnload) { currentWindowOnload(); } htmlReporter.initialize(); env.execute(); }; /** * Helper function for readability above. */ function extend(destination, source) { for (var property in source) destination[property] = source[property]; return destination; } }()); ================================================ FILE: specs/jasmine-2.0.3/console.js ================================================ /* Copyright (c) 2008-2014 Pivotal Labs Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ function getJasmineRequireObj() { if (typeof module !== 'undefined' && module.exports) { return exports; } else { window.jasmineRequire = window.jasmineRequire || {}; return window.jasmineRequire; } } getJasmineRequireObj().console = function(jRequire, j$) { j$.ConsoleReporter = jRequire.ConsoleReporter(); }; getJasmineRequireObj().ConsoleReporter = function() { var noopTimer = { start: function(){}, elapsed: function(){ return 0; } }; function ConsoleReporter(options) { var print = options.print, showColors = options.showColors || false, onComplete = options.onComplete || function() {}, timer = options.timer || noopTimer, specCount, failureCount, failedSpecs = [], pendingCount, ansi = { green: '\x1B[32m', red: '\x1B[31m', yellow: '\x1B[33m', none: '\x1B[0m' }; this.jasmineStarted = function() { specCount = 0; failureCount = 0; pendingCount = 0; print('Started'); printNewline(); timer.start(); }; this.jasmineDone = function() { printNewline(); for (var i = 0; i < failedSpecs.length; i++) { specFailureDetails(failedSpecs[i]); } if(specCount > 0) { printNewline(); var specCounts = specCount + ' ' + plural('spec', specCount) + ', ' + failureCount + ' ' + plural('failure', failureCount); if (pendingCount) { specCounts += ', ' + pendingCount + ' pending ' + plural('spec', pendingCount); } print(specCounts); } else { print('No specs found'); } printNewline(); var seconds = timer.elapsed() / 1000; print('Finished in ' + seconds + ' ' + plural('second', seconds)); printNewline(); onComplete(failureCount === 0); }; this.specDone = function(result) { specCount++; if (result.status == 'pending') { pendingCount++; print(colored('yellow', '*')); return; } if (result.status == 'passed') { print(colored('green', '.')); return; } if (result.status == 'failed') { failureCount++; failedSpecs.push(result); print(colored('red', 'F')); } }; return this; function printNewline() { print('\n'); } function colored(color, str) { return showColors ? (ansi[color] + str + ansi.none) : str; } function plural(str, count) { return count == 1 ? str : str + 's'; } function repeat(thing, times) { var arr = []; for (var i = 0; i < times; i++) { arr.push(thing); } return arr; } function indent(str, spaces) { var lines = (str || '').split('\n'); var newArr = []; for (var i = 0; i < lines.length; i++) { newArr.push(repeat(' ', spaces).join('') + lines[i]); } return newArr.join('\n'); } function specFailureDetails(result) { printNewline(); print(result.fullName); for (var i = 0; i < result.failedExpectations.length; i++) { var failedExpectation = result.failedExpectations[i]; printNewline(); print(indent(failedExpectation.message, 2)); print(indent(failedExpectation.stack, 2)); } printNewline(); } } return ConsoleReporter; }; ================================================ FILE: specs/jasmine-2.0.3/jasmine-html.js ================================================ /* Copyright (c) 2008-2014 Pivotal Labs Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ jasmineRequire.html = function(j$) { j$.ResultsNode = jasmineRequire.ResultsNode(); j$.HtmlReporter = jasmineRequire.HtmlReporter(j$); j$.QueryString = jasmineRequire.QueryString(); j$.HtmlSpecFilter = jasmineRequire.HtmlSpecFilter(); }; jasmineRequire.HtmlReporter = function(j$) { var noopTimer = { start: function() {}, elapsed: function() { return 0; } }; function HtmlReporter(options) { var env = options.env || {}, getContainer = options.getContainer, createElement = options.createElement, createTextNode = options.createTextNode, onRaiseExceptionsClick = options.onRaiseExceptionsClick || function() {}, timer = options.timer || noopTimer, results = [], specsExecuted = 0, failureCount = 0, pendingSpecCount = 0, htmlReporterMain, symbols; this.initialize = function() { clearPrior(); htmlReporterMain = createDom('div', {className: 'jasmine_html-reporter'}, createDom('div', {className: 'banner'}, createDom('a', {className: 'title', href: 'http://jasmine.github.io/', target: '_blank'}), createDom('span', {className: 'version'}, j$.version) ), createDom('ul', {className: 'symbol-summary'}), createDom('div', {className: 'alert'}), createDom('div', {className: 'results'}, createDom('div', {className: 'failures'}) ) ); getContainer().appendChild(htmlReporterMain); symbols = find('.symbol-summary'); }; var totalSpecsDefined; this.jasmineStarted = function(options) { totalSpecsDefined = options.totalSpecsDefined || 0; timer.start(); }; var summary = createDom('div', {className: 'summary'}); var topResults = new j$.ResultsNode({}, '', null), currentParent = topResults; this.suiteStarted = function(result) { currentParent.addChild(result, 'suite'); currentParent = currentParent.last(); }; this.suiteDone = function(result) { if (currentParent == topResults) { return; } currentParent = currentParent.parent; }; this.specStarted = function(result) { currentParent.addChild(result, 'spec'); }; var failures = []; this.specDone = function(result) { if(noExpectations(result) && console && console.error) { console.error('Spec \'' + result.fullName + '\' has no expectations.'); } if (result.status != 'disabled') { specsExecuted++; } symbols.appendChild(createDom('li', { className: noExpectations(result) ? 'empty' : result.status, id: 'spec_' + result.id, title: result.fullName } )); if (result.status == 'failed') { failureCount++; var failure = createDom('div', {className: 'spec-detail failed'}, createDom('div', {className: 'description'}, createDom('a', {title: result.fullName, href: specHref(result)}, result.fullName) ), createDom('div', {className: 'messages'}) ); var messages = failure.childNodes[1]; for (var i = 0; i < result.failedExpectations.length; i++) { var expectation = result.failedExpectations[i]; messages.appendChild(createDom('div', {className: 'result-message'}, expectation.message)); messages.appendChild(createDom('div', {className: 'stack-trace'}, expectation.stack)); } failures.push(failure); } if (result.status == 'pending') { pendingSpecCount++; } }; this.jasmineDone = function() { var banner = find('.banner'); banner.appendChild(createDom('span', {className: 'duration'}, 'finished in ' + timer.elapsed() / 1000 + 's')); var alert = find('.alert'); alert.appendChild(createDom('span', { className: 'exceptions' }, createDom('label', { className: 'label', 'for': 'raise-exceptions' }, 'raise exceptions'), createDom('input', { className: 'raise', id: 'raise-exceptions', type: 'checkbox' }) )); var checkbox = find('#raise-exceptions'); checkbox.checked = !env.catchingExceptions(); checkbox.onclick = onRaiseExceptionsClick; if (specsExecuted < totalSpecsDefined) { var skippedMessage = 'Ran ' + specsExecuted + ' of ' + totalSpecsDefined + ' specs - run all'; alert.appendChild( createDom('span', {className: 'bar skipped'}, createDom('a', {href: '?', title: 'Run all specs'}, skippedMessage) ) ); } var statusBarMessage = ''; var statusBarClassName = 'bar '; if (totalSpecsDefined > 0) { statusBarMessage += pluralize('spec', specsExecuted) + ', ' + pluralize('failure', failureCount); if (pendingSpecCount) { statusBarMessage += ', ' + pluralize('pending spec', pendingSpecCount); } statusBarClassName += (failureCount > 0) ? 'failed' : 'passed'; } else { statusBarClassName += 'skipped'; statusBarMessage += 'No specs found'; } alert.appendChild(createDom('span', {className: statusBarClassName}, statusBarMessage)); var results = find('.results'); results.appendChild(summary); summaryList(topResults, summary); function summaryList(resultsTree, domParent) { var specListNode; for (var i = 0; i < resultsTree.children.length; i++) { var resultNode = resultsTree.children[i]; if (resultNode.type == 'suite') { var suiteListNode = createDom('ul', {className: 'suite', id: 'suite-' + resultNode.result.id}, createDom('li', {className: 'suite-detail'}, createDom('a', {href: specHref(resultNode.result)}, resultNode.result.description) ) ); summaryList(resultNode, suiteListNode); domParent.appendChild(suiteListNode); } if (resultNode.type == 'spec') { if (domParent.getAttribute('class') != 'specs') { specListNode = createDom('ul', {className: 'specs'}); domParent.appendChild(specListNode); } var specDescription = resultNode.result.description; if(noExpectations(resultNode.result)) { specDescription = 'SPEC HAS NO EXPECTATIONS ' + specDescription; } specListNode.appendChild( createDom('li', { className: resultNode.result.status, id: 'spec-' + resultNode.result.id }, createDom('a', {href: specHref(resultNode.result)}, specDescription) ) ); } } } if (failures.length) { alert.appendChild( createDom('span', {className: 'menu bar spec-list'}, createDom('span', {}, 'Spec List | '), createDom('a', {className: 'failures-menu', href: '#'}, 'Failures'))); alert.appendChild( createDom('span', {className: 'menu bar failure-list'}, createDom('a', {className: 'spec-list-menu', href: '#'}, 'Spec List'), createDom('span', {}, ' | Failures '))); find('.failures-menu').onclick = function() { setMenuModeTo('failure-list'); }; find('.spec-list-menu').onclick = function() { setMenuModeTo('spec-list'); }; setMenuModeTo('failure-list'); var failureNode = find('.failures'); for (var i = 0; i < failures.length; i++) { failureNode.appendChild(failures[i]); } } }; return this; function find(selector) { return getContainer().querySelector('.jasmine_html-reporter ' + selector); } function clearPrior() { // return the reporter var oldReporter = find(''); if(oldReporter) { getContainer().removeChild(oldReporter); } } function createDom(type, attrs, childrenVarArgs) { var el = createElement(type); for (var i = 2; i < arguments.length; i++) { var child = arguments[i]; if (typeof child === 'string') { el.appendChild(createTextNode(child)); } else { if (child) { el.appendChild(child); } } } for (var attr in attrs) { if (attr == 'className') { el[attr] = attrs[attr]; } else { el.setAttribute(attr, attrs[attr]); } } return el; } function pluralize(singular, count) { var word = (count == 1 ? singular : singular + 's'); return '' + count + ' ' + word; } function specHref(result) { return '?spec=' + encodeURIComponent(result.fullName); } function setMenuModeTo(mode) { htmlReporterMain.setAttribute('class', 'jasmine_html-reporter ' + mode); } function noExpectations(result) { return (result.failedExpectations.length + result.passedExpectations.length) === 0 && result.status === 'passed'; } } return HtmlReporter; }; jasmineRequire.HtmlSpecFilter = function() { function HtmlSpecFilter(options) { var filterString = options && options.filterString() && options.filterString().replace(/[-[\]{}()*+?.,\\^$|#\s]/g, '\\$&'); var filterPattern = new RegExp(filterString); this.matches = function(specName) { return filterPattern.test(specName); }; } return HtmlSpecFilter; }; jasmineRequire.ResultsNode = function() { function ResultsNode(result, type, parent) { this.result = result; this.type = type; this.parent = parent; this.children = []; this.addChild = function(result, type) { this.children.push(new ResultsNode(result, type, this)); }; this.last = function() { return this.children[this.children.length - 1]; }; } return ResultsNode; }; jasmineRequire.QueryString = function() { function QueryString(options) { this.setParam = function(key, value) { var paramMap = queryStringToParamMap(); paramMap[key] = value; options.getWindowLocation().search = toQueryString(paramMap); }; this.getParam = function(key) { return queryStringToParamMap()[key]; }; return this; function toQueryString(paramMap) { var qStrPairs = []; for (var prop in paramMap) { qStrPairs.push(encodeURIComponent(prop) + '=' + encodeURIComponent(paramMap[prop])); } return '?' + qStrPairs.join('&'); } function queryStringToParamMap() { var paramStr = options.getWindowLocation().search.substring(1), params = [], paramMap = {}; if (paramStr.length > 0) { params = paramStr.split('&'); for (var i = 0; i < params.length; i++) { var p = params[i].split('='); var value = decodeURIComponent(p[1]); if (value === 'true' || value === 'false') { value = JSON.parse(value); } paramMap[decodeURIComponent(p[0])] = value; } } return paramMap; } } return QueryString; }; ================================================ FILE: specs/jasmine-2.0.3/jasmine.css ================================================ body { overflow-y: scroll; } .jasmine_html-reporter { background-color: #eeeeee; padding: 5px; margin: -8px; font-size: 11px; font-family: Monaco, "Lucida Console", monospace; line-height: 14px; color: #333333; } .jasmine_html-reporter a { text-decoration: none; } .jasmine_html-reporter a:hover { text-decoration: underline; } .jasmine_html-reporter p, .jasmine_html-reporter h1, .jasmine_html-reporter h2, .jasmine_html-reporter h3, .jasmine_html-reporter h4, .jasmine_html-reporter h5, .jasmine_html-reporter h6 { margin: 0; line-height: 14px; } .jasmine_html-reporter .banner, .jasmine_html-reporter .symbol-summary, .jasmine_html-reporter .summary, .jasmine_html-reporter .result-message, .jasmine_html-reporter .spec .description, .jasmine_html-reporter .spec-detail .description, .jasmine_html-reporter .alert .bar, .jasmine_html-reporter .stack-trace { padding-left: 9px; padding-right: 9px; } .jasmine_html-reporter .banner { position: relative; } .jasmine_html-reporter .banner .title { background: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAFoAAAAZCAMAAACGusnyAAACdlBMVEX/////AP+AgICqVaqAQICZM5mAVYCSSZKAQICOOY6ATYCLRouAQICJO4mSSYCIRIiPQICHPIeOR4CGQ4aMQICGPYaLRoCFQ4WKQICPPYWJRYCOQoSJQICNPoSIRICMQoSHQICHRICKQoOHQICKPoOJO4OJQYOMQICMQ4CIQYKLQICIPoKLQ4CKQICNPoKJQISMQ4KJQoSLQYKJQISLQ4KIQoSKQYKIQICIQISMQoSKQYKLQIOLQoOJQYGLQIOKQIOMQoGKQYOLQYGKQIOLQoGJQYOJQIOKQYGJQIOKQoGKQIGLQIKLQ4KKQoGLQYKJQIGKQYKJQIGKQIKJQoGKQYKLQIGKQYKLQIOJQoKKQoOJQYKKQIOJQoKKQoOKQIOLQoKKQYOLQYKJQIOKQoKKQYKKQoKJQYOKQYKLQIOKQoKLQYOKQYKLQIOJQoGKQYKJQYGJQoGKQYKLQoGLQYGKQoGJQYKKQYGJQIKKQoGJQYKLQIKKQYGLQYKKQYGKQYGKQYKJQYOKQoKJQYOKQYKLQYOLQYOKQYKLQYOKQoKKQYKKQYOKQYOJQYKKQYKLQYKKQIKKQoKKQYKKQYKKQoKJQIKKQYKLQYKKQYKKQIKKQYKKQYKKQYKKQIKKQYKJQYGLQYGKQYKKQYKKQYGKQIKKQYGKQYOJQoKKQYOLQYKKQYOKQoKKQYKKQoKKQYKKQYKJQYKLQYKKQYKKQYKKQYKKQYKKQYKKQYKKQYKKQYKJQYKKQYKKQYKKQYKKQYKKQYKKQYKKQYKKQYKKQYKKQYKKQYKLQYKKQYKKQYKKQYKKQYKKQYKKQYKKQYKKQYKKQYKKQYKKQYKKQYKmIDpEAAAA0XRSTlMAAQIDBAUGBwgJCgsMDQ4PEBESExQVFhcYGRobHB0eHyAiIyQlJycoKissLS4wMTQ1Njc4OTo7PDw+P0BCQ0RISUpLTE1OUFNUVVdYWFlaW15fYGFiY2ZnaGlqa2xtb3BxcnN0dnh5ent8fX5/gIGChIWIioyNjo+QkZOUlZaYmZqbnJ2eoKGio6WmqKmsra6vsLGztre4ubq7vL2+wMHDxMjJysvNzs/Q0dLU1tfY2dvc3t/g4eLj5ebn6Onq6+zt7u/w8vP09fb3+Pn6+/z9/vkVQXAAAAMaSURBVHhe5dXxV1N1GMfxz2ABbDgIAm5VDJOyVDIJLUMaVpBWUZUaGbmqoGpZRSiGiRWp6KoZ5AB0ZY50RImZQIlahKkMYXv/R90dBvET/rJfOr3Ouc8v99zPec59zvf56j+vYKlViSf7250X4Mr3O29Tgq08BdGB4DhcekEJ5YkQKFsgWZdtj9JpV+I8xPjLFqkrsEIqO8PHSpis36jWazcqjEsfJjkvRssVU37SdIOu4XCf5vEJPsnwJpnRNU9JmxhMk8l1gehIrq7hTFjzOD+Vf88629qKMJVNltInFeRexRQyJlNeqd1iGDlSzrIUIyXbyFfm3RYprcQRe7lqtWyGYbfc6dT0R2vmdOOkX3u55C1rP37ftiH+tDby4r/RBT0w8TyEkr+epB9XgPDmSYYWbrhCuFYaIyw3fDQAXTnSkh+ANofiHmWf9l+FY1I90FdQTetstO00o23novzVsJ7uB3/C5TkbjRwZ5JerwV4iRWq9HFbFMaK/d0TYqayRiQPuIxxS3Bu8JWU90/60tKi7vkhaznez0a/TbVOKj5CaOZh6fWG6/Lyv9B/ZLR1gw/S/fpbeVD3MCW1li6SvWDOn65tr99/uvWtBS0XDm4s1t+sOHpG0kpBKx/l77wOSnxLpcx6TXmXLTPQOKYOf9Q1dfr8/SJ2mFdCvl1Yl93DiHUZvXeLJbGSzYu5gVJ2slbSakOR8dxCq5adQ2oFLqsE9Ex3L4qQO0eOPeU5x56bypXp4onSEb5OkICX6lDat55TeoztNKQcJaakrz9KCb95oD69IKq+yKW4XPjknaS52V0TZqE2cTtXjcHSCRmUO88e+85hj3EP74i9p8pylw7lxgMDyyl6OV7ZejnjNMfatu87LxRbH0IS35gt2a4ZjmGpVBdKK3Wr6INk8jWWSGqbA55CKgjBRC6E9w78ydTg3ABS3AFV1QN0Y4Aa2pgEjWnQURj9L0ayK6R2ysEqxHUKzYnLvvyU+i9KM2JHJzE4vyZOyDcOwOsySajeLPc8sNvPJkFlyJd20wpqAzZeAfZ3oWybxd+P/3j+SG3uSBdf2VQAAAABJRU5ErkJggg==') no-repeat; background: url('data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiIHN0YW5kYWxvbmU9Im5vIj8+CjwhLS0gQ3JlYXRlZCB3aXRoIElua3NjYXBlIChodHRwOi8vd3d3Lmlua3NjYXBlLm9yZy8pIC0tPgoKPHN2ZwogICB4bWxuczpkYz0iaHR0cDovL3B1cmwub3JnL2RjL2VsZW1lbnRzLzEuMS8iCiAgIHhtbG5zOmNjPSJodHRwOi8vY3JlYXRpdmVjb21tb25zLm9yZy9ucyMiCiAgIHhtbG5zOnJkZj0iaHR0cDovL3d3dy53My5vcmcvMTk5OS8wMi8yMi1yZGYtc3ludGF4LW5zIyIKICAgeG1sbnM6c3ZnPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIKICAgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIgogICB4bWxuczppbmtzY2FwZT0iaHR0cDovL3d3dy5pbmtzY2FwZS5vcmcvbmFtZXNwYWNlcy9pbmtzY2FwZSIKICAgdmVyc2lvbj0iMS4xIgogICB3aWR0aD0iNjgxLjk2MjUyIgogICBoZWlnaHQ9IjE4Ny41IgogICBpZD0ic3ZnMiIKICAgeG1sOnNwYWNlPSJwcmVzZXJ2ZSI+PG1ldGFkYXRhCiAgICAgaWQ9Im1ldGFkYXRhOCI+PHJkZjpSREY+PGNjOldvcmsKICAgICAgICAgcmRmOmFib3V0PSIiPjxkYzpmb3JtYXQ+aW1hZ2Uvc3ZnK3htbDwvZGM6Zm9ybWF0PjxkYzp0eXBlCiAgICAgICAgICAgcmRmOnJlc291cmNlPSJodHRwOi8vcHVybC5vcmcvZGMvZGNtaXR5cGUvU3RpbGxJbWFnZSIgLz48L2NjOldvcms+PC9yZGY6UkRGPjwvbWV0YWRhdGE+PGRlZnMKICAgICBpZD0iZGVmczYiPjxjbGlwUGF0aAogICAgICAgaWQ9ImNsaXBQYXRoMTgiPjxwYXRoCiAgICAgICAgIGQ9Ik0gMCwxNTAwIDAsMCBsIDU0NTUuNzQsMCAwLDE1MDAgTCAwLDE1MDAgeiIKICAgICAgICAgaW5rc2NhcGU6Y29ubmVjdG9yLWN1cnZhdHVyZT0iMCIKICAgICAgICAgaWQ9InBhdGgyMCIgLz48L2NsaXBQYXRoPjwvZGVmcz48ZwogICAgIHRyYW5zZm9ybT0ibWF0cml4KDEuMjUsMCwwLC0xLjI1LDAsMTg3LjUpIgogICAgIGlkPSJnMTAiPjxnCiAgICAgICB0cmFuc2Zvcm09InNjYWxlKDAuMSwwLjEpIgogICAgICAgaWQ9ImcxMiI+PGcKICAgICAgICAgaWQ9ImcxNCI+PGcKICAgICAgICAgICBjbGlwLXBhdGg9InVybCgjY2xpcFBhdGgxOCkiCiAgICAgICAgICAgaWQ9ImcxNiI+PHBhdGgKICAgICAgICAgICAgIGQ9Im0gMTU0NCw1OTkuNDM0IGMgMC45MiwtNDAuMzUyIDI1LjY4LC04MS42MDIgNzEuNTMsLTgxLjYwMiAyNy41MSwwIDQ3LjY4LDEyLjgzMiA2MS40NCwzNS43NTQgMTIuODMsMjIuOTMgMTIuODMsNTYuODUyIDEyLjgzLDgyLjUyNyBsIDAsMzI5LjE4NCAtNzEuNTIsMCAwLDEwNC41NDMgMjY2LjgzLDAgMCwtMTA0LjU0MyAtNzAuNiwwIDAsLTM0NC43NyBjIDAsLTU4LjY5MSAtMy42OCwtMTA0LjUzMSAtNDQuOTMsLTE1Mi4yMTggLTM2LjY4LC00Mi4xOCAtOTYuMjgsLTY2LjAyIC0xNTMuMTQsLTY2LjAyIC0xMTcuMzcsMCAtMjA3LjI0LDc3Ljk0MSAtMjAyLjY0LDE5Ny4xNDUgbCAxMzAuMiwwIgogICAgICAgICAgICAgaW5rc2NhcGU6Y29ubmVjdG9yLWN1cnZhdHVyZT0iMCIKICAgICAgICAgICAgIGlkPSJwYXRoMjIiCiAgICAgICAgICAgICBzdHlsZT0iZmlsbDojOGE0MTgyO2ZpbGwtb3BhY2l0eToxO2ZpbGwtcnVsZTpub256ZXJvO3N0cm9rZTpub25lIiAvPjxwYXRoCiAgICAgICAgICAgICBkPSJtIDIzMDEuNCw2NjIuNjk1IGMgMCw4MC43MDMgLTY2Ljk0LDE0NS44MTMgLTE0Ny42MywxNDUuODEzIC04My40NCwwIC0xNDcuNjMsLTY4Ljc4MSAtMTQ3LjYzLC0xNTEuMzAxIDAsLTc5Ljc4NSA2Ni45NCwtMTQ1LjgwMSAxNDUuOCwtMTQ1LjgwMSA4NC4zNSwwIDE0OS40Niw2Ny44NTIgMTQ5LjQ2LDE1MS4yODkgeiBtIC0xLjgzLC0xODEuNTQ3IGMgLTM1Ljc3LC01NC4wOTcgLTkzLjUzLC03OC44NTkgLTE1Ny43MiwtNzguODU5IC0xNDAuMywwIC0yNTEuMjQsMTE2LjQ0OSAtMjUxLjI0LDI1NC45MTggMCwxNDIuMTI5IDExMy43LDI2MC40MSAyNTYuNzQsMjYwLjQxIDYzLjI3LDAgMTE4LjI5LC0yOS4zMzYgMTUyLjIyLC04Mi41MjMgbCAwLDY5LjY4NyAxNzUuMTQsMCAwLC0xMDQuNTI3IC02MS40NCwwIDAsLTI4MC41OTggNjEuNDQsMCAwLC0xMDQuNTI3IC0xNzUuMTQsMCAwLDY2LjAxOSIKICAgICAgICAgICAgIGlua3NjYXBlOmNvbm5lY3Rvci1jdXJ2YXR1cmU9IjAiCiAgICAgICAgICAgICBpZD0icGF0aDI0IgogICAgICAgICAgICAgc3R5bGU9ImZpbGw6IzhhNDE4MjtmaWxsLW9wYWNpdHk6MTtmaWxsLXJ1bGU6bm9uemVybztzdHJva2U6bm9uZSIgLz48cGF0aAogICAgICAgICAgICAgZD0ibSAyNjIyLjMzLDU1Ny4yNTggYyAzLjY3LC00NC4wMTYgMzMuMDEsLTczLjM0OCA3OC44NiwtNzMuMzQ4IDMzLjkzLDAgNjYuOTMsMjMuODI0IDY2LjkzLDYwLjUwNCAwLDQ4LjYwNiAtNDUuODQsNTYuODU2IC04My40NCw2Ni45NDEgLTg1LjI4LDIyLjAwNCAtMTc4LjgxLDQ4LjYwNiAtMTc4LjgxLDE1NS44NzkgMCw5My41MzYgNzguODYsMTQ3LjYzMyAxNjUuOTgsMTQ3LjYzMyA0NCwwIDgzLjQzLC05LjE3NiAxMTAuOTQsLTQ0LjAwOCBsIDAsMzMuOTIyIDgyLjUzLDAgMCwtMTMyLjk2NSAtMTA4LjIxLDAgYyAtMS44MywzNC44NTYgLTI4LjQyLDU3Ljc3NCAtNjMuMjYsNTcuNzc0IC0zMC4yNiwwIC02Mi4zNSwtMTcuNDIyIC02Mi4zNSwtNTEuMzQ4IDAsLTQ1Ljg0NyA0NC45MywtNTUuOTMgODAuNjksLTY0LjE4IDg4LjAyLC0yMC4xNzUgMTgyLjQ3LC00Ny42OTUgMTgyLjQ3LC0xNTcuNzM0IDAsLTk5LjAyNyAtODMuNDQsLTE1NC4wMzkgLTE3NS4xMywtMTU0LjAzOSAtNDkuNTMsMCAtOTQuNDYsMTUuNTgyIC0xMjYuNTUsNTMuMTggbCAwLC00MC4zNCAtODUuMjcsMCAwLDE0Mi4xMjkgMTE0LjYyLDAiCiAgICAgICAgICAgICBpbmtzY2FwZTpjb25uZWN0b3ItY3VydmF0dXJlPSIwIgogICAgICAgICAgICAgaWQ9InBhdGgyNiIKICAgICAgICAgICAgIHN0eWxlPSJmaWxsOiM4YTQxODI7ZmlsbC1vcGFjaXR5OjE7ZmlsbC1ydWxlOm5vbnplcm87c3Ryb2tlOm5vbmUiIC8+PHBhdGgKICAgICAgICAgICAgIGQ9Im0gMjk4OC4xOCw4MDAuMjU0IC02My4yNiwwIDAsMTA0LjUyNyAxNjUuMDUsMCAwLC03My4zNTUgYyAzMS4xOCw1MS4zNDcgNzguODYsODUuMjc3IDE0MS4yMSw4NS4yNzcgNjcuODUsMCAxMjQuNzEsLTQxLjI1OCAxNTIuMjEsLTEwMi42OTkgMjYuNiw2Mi4zNTEgOTIuNjIsMTAyLjY5OSAxNjAuNDcsMTAyLjY5OSA1My4xOSwwIDEwNS40NiwtMjIgMTQxLjIxLC02Mi4zNTEgMzguNTIsLTQ0LjkzOCAzOC41MiwtOTMuNTMyIDM4LjUyLC0xNDkuNDU3IGwgMCwtMTg1LjIzOSA2My4yNywwIDAsLTEwNC41MjcgLTIzOC40MiwwIDAsMTA0LjUyNyA2My4yOCwwIDAsMTU3LjcxNSBjIDAsMzIuMTAyIDAsNjAuNTI3IC0xNC42Nyw4OC45NTcgLTE4LjM0LDI2LjU4MiAtNDguNjEsNDAuMzQ0IC03OS43Nyw0MC4zNDQgLTMwLjI2LDAgLTYzLjI4LC0xMi44NDQgLTgyLjUzLC0zNi42NzIgLTIyLjkzLC0yOS4zNTUgLTIyLjkzLC01Ni44NjMgLTIyLjkzLC05Mi42MjkgbCAwLC0xNTcuNzE1IDYzLjI3LDAgMCwtMTA0LjUyNyAtMjM4LjQxLDAgMCwxMDQuNTI3IDYzLjI4LDAgMCwxNTAuMzgzIGMgMCwyOS4zNDggMCw2Ni4wMjMgLTE0LjY3LDkxLjY5OSAtMTUuNTksMjkuMzM2IC00Ny42OSw0NC45MzQgLTgwLjcsNDQuOTM0IC0zMS4xOCwwIC01Ny43NywtMTEuMDA4IC03Ny45NCwtMzUuNzc0IC0yNC43NywtMzAuMjUzIC0yNi42LC02Mi4zNDMgLTI2LjYsLTk5Ljk0MSBsIDAsLTE1MS4zMDEgNjMuMjcsMCAwLC0xMDQuNTI3IC0yMzguNCwwIDAsMTA0LjUyNyA2My4yNiwwIDAsMjgwLjU5OCIKICAgICAgICAgICAgIGlua3NjYXBlOmNvbm5lY3Rvci1jdXJ2YXR1cmU9IjAiCiAgICAgICAgICAgICBpZD0icGF0aDI4IgogICAgICAgICAgICAgc3R5bGU9ImZpbGw6IzhhNDE4MjtmaWxsLW9wYWNpdHk6MTtmaWxsLXJ1bGU6bm9uemVybztzdHJva2U6bm9uZSIgLz48cGF0aAogICAgICAgICAgICAgZD0ibSAzOTk4LjY2LDk1MS41NDcgLTExMS44NywwIDAsMTE4LjI5MyAxMTEuODcsMCAwLC0xMTguMjkzIHogbSAwLC00MzEuODkxIDYzLjI3LDAgMCwtMTA0LjUyNyAtMjM5LjMzLDAgMCwxMDQuNTI3IDY0LjE5LDAgMCwyODAuNTk4IC02My4yNywwIDAsMTA0LjUyNyAxNzUuMTQsMCAwLC0zODUuMTI1IgogICAgICAgICAgICAgaW5rc2NhcGU6Y29ubmVjdG9yLWN1cnZhdHVyZT0iMCIKICAgICAgICAgICAgIGlkPSJwYXRoMzAiCiAgICAgICAgICAgICBzdHlsZT0iZmlsbDojOGE0MTgyO2ZpbGwtb3BhY2l0eToxO2ZpbGwtcnVsZTpub256ZXJvO3N0cm9rZTpub25lIiAvPjxwYXRoCiAgICAgICAgICAgICBkPSJtIDQxNTkuMTIsODAwLjI1NCAtNjMuMjcsMCAwLDEwNC41MjcgMTc1LjE0LDAgMCwtNjkuNjg3IGMgMjkuMzUsNTQuMTAxIDg0LjM2LDgwLjY5OSAxNDQuODcsODAuNjk5IDUzLjE5LDAgMTA1LjQ1LC0yMi4wMTYgMTQxLjIyLC02MC41MjcgNDAuMzQsLTQ0LjkzNCA0MS4yNiwtODguMDMyIDQxLjI2LC0xNDMuOTU3IGwgMCwtMTkxLjY1MyA2My4yNywwIDAsLTEwNC41MjcgLTIzOC40LDAgMCwxMDQuNTI3IDYzLjI2LDAgMCwxNTguNjM3IGMgMCwzMC4yNjIgMCw2MS40MzQgLTE5LjI2LDg4LjAzNSAtMjAuMTcsMjYuNTgyIC01My4xOCwzOS40MTQgLTg2LjE5LDM5LjQxNCAtMzMuOTMsMCAtNjguNzcsLTEzLjc1IC04OC45NCwtNDEuMjUgLTIxLjA5LC0yNy41IC0yMS4wOSwtNjkuNjg3IC0yMS4wOSwtMTAyLjcwNyBsIDAsLTE0Mi4xMjkgNjMuMjYsMCAwLC0xMDQuNTI3IC0yMzguNCwwIDAsMTA0LjUyNyA2My4yNywwIDAsMjgwLjU5OCIKICAgICAgICAgICAgIGlua3NjYXBlOmNvbm5lY3Rvci1jdXJ2YXR1cmU9IjAiCiAgICAgICAgICAgICBpZD0icGF0aDMyIgogICAgICAgICAgICAgc3R5bGU9ImZpbGw6IzhhNDE4MjtmaWxsLW9wYWNpdHk6MTtmaWxsLXJ1bGU6bm9uemVybztzdHJva2U6bm9uZSIgLz48cGF0aAogICAgICAgICAgICAgZD0ibSA1MDgyLjQ4LDcwMy45NjUgYyAtMTkuMjQsNzAuNjA1IC04MS42LDExNS41NDcgLTE1NC4wNCwxMTUuNTQ3IC02Ni4wNCwwIC0xMjkuMywtNTEuMzQ4IC0xNDMuMDUsLTExNS41NDcgbCAyOTcuMDksMCB6IG0gODUuMjcsLTE0NC44ODMgYyAtMzguNTEsLTkzLjUyMyAtMTI5LjI3LC0xNTYuNzkzIC0yMzEuMDUsLTE1Ni43OTMgLTE0My4wNywwIC0yNTcuNjgsMTExLjg3MSAtMjU3LjY4LDI1NS44MzYgMCwxNDQuODgzIDEwOS4xMiwyNjEuMzI4IDI1NC45MSwyNjEuMzI4IDY3Ljg3LDAgMTM1LjcyLC0zMC4yNTggMTgzLjM5LC03OC44NjMgNDguNjIsLTUxLjM0NCA2OC43OSwtMTEzLjY5NSA2OC43OSwtMTgzLjM4MyBsIC0zLjY3LC0zOS40MzQgLTM5Ni4xMywwIGMgMTQuNjcsLTY3Ljg2MyA3Ny4wMywtMTE3LjM2MyAxNDYuNzIsLTExNy4zNjMgNDguNTksMCA5MC43NiwxOC4zMjggMTE4LjI4LDU4LjY3MiBsIDExNi40NCwwIgogICAgICAgICAgICAgaW5rc2NhcGU6Y29ubmVjdG9yLWN1cnZhdHVyZT0iMCIKICAgICAgICAgICAgIGlkPSJwYXRoMzQiCiAgICAgICAgICAgICBzdHlsZT0iZmlsbDojOGE0MTgyO2ZpbGwtb3BhY2l0eToxO2ZpbGwtcnVsZTpub256ZXJvO3N0cm9rZTpub25lIiAvPjxwYXRoCiAgICAgICAgICAgICBkPSJtIDY5MC44OTUsODUwLjcwMyA5MC43NSwwIDIyLjU0MywzMS4wMzUgMCwyNDMuMTIyIC0xMzUuODI5LDAgMCwtMjQzLjE0MSAyMi41MzYsLTMxLjAxNiIKICAgICAgICAgICAgIGlua3NjYXBlOmNvbm5lY3Rvci1jdXJ2YXR1cmU9IjAiCiAgICAgICAgICAgICBpZD0icGF0aDM2IgogICAgICAgICAgICAgc3R5bGU9ImZpbGw6IzhhNDE4MjtmaWxsLW9wYWNpdHk6MTtmaWxsLXJ1bGU6bm9uemVybztzdHJva2U6bm9uZSIgLz48cGF0aAogICAgICAgICAgICAgZD0ibSA2MzIuMzk1LDc0Mi4yNTggMjguMDM5LDg2LjMwNCAtMjIuNTUxLDMxLjA0IC0yMzEuMjIzLDc1LjEyOCAtNDEuOTc2LC0xMjkuMTgzIDIzMS4yNTcsLTc1LjEzNyAzNi40NTQsMTEuODQ4IgogICAgICAgICAgICAgaW5rc2NhcGU6Y29ubmVjdG9yLWN1cnZhdHVyZT0iMCIKICAgICAgICAgICAgIGlkPSJwYXRoMzgiCiAgICAgICAgICAgICBzdHlsZT0iZmlsbDojOGE0MTgyO2ZpbGwtb3BhY2l0eToxO2ZpbGwtcnVsZTpub256ZXJvO3N0cm9rZTpub25lIiAvPjxwYXRoCiAgICAgICAgICAgICBkPSJtIDcxNy40NDksNjUzLjEwNSAtNzMuNDEsNTMuMzYgLTM2LjQ4OCwtMTEuODc1IC0xNDIuOTAzLC0xOTYuNjkyIDEwOS44ODMsLTc5LjgyOCAxNDIuOTE4LDE5Ni43MDMgMCwzOC4zMzIiCiAgICAgICAgICAgICBpbmtzY2FwZTpjb25uZWN0b3ItY3VydmF0dXJlPSIwIgogICAgICAgICAgICAgaWQ9InBhdGg0MCIKICAgICAgICAgICAgIHN0eWxlPSJmaWxsOiM4YTQxODI7ZmlsbC1vcGFjaXR5OjE7ZmlsbC1ydWxlOm5vbnplcm87c3Ryb2tlOm5vbmUiIC8+PHBhdGgKICAgICAgICAgICAgIGQ9Im0gODI4LjUyLDcwNi40NjUgLTczLjQyNiwtNTMuMzQgMC4wMTEsLTM4LjM1OSBMIDg5OC4wMDQsNDE4LjA3IDEwMDcuOSw0OTcuODk4IDg2NC45NzMsNjk0LjYwOSA4MjguNTIsNzA2LjQ2NSIKICAgICAgICAgICAgIGlua3NjYXBlOmNvbm5lY3Rvci1jdXJ2YXR1cmU9IjAiCiAgICAgICAgICAgICBpZD0icGF0aDQyIgogICAgICAgICAgICAgc3R5bGU9ImZpbGw6IzhhNDE4MjtmaWxsLW9wYWNpdHk6MTtmaWxsLXJ1bGU6bm9uemVybztzdHJva2U6bm9uZSIgLz48cGF0aAogICAgICAgICAgICAgZD0ibSA4MTIuMDg2LDgyOC41ODYgMjguMDU1LC04Ni4zMiAzNi40ODQsLTExLjgzNiAyMzEuMjI1LDc1LjExNyAtNDEuOTcsMTI5LjE4MyAtMjMxLjIzOSwtNzUuMTQgLTIyLjU1NSwtMzEuMDA0IgogICAgICAgICAgICAgaW5rc2NhcGU6Y29ubmVjdG9yLWN1cnZhdHVyZT0iMCIKICAgICAgICAgICAgIGlkPSJwYXRoNDQiCiAgICAgICAgICAgICBzdHlsZT0iZmlsbDojOGE0MTgyO2ZpbGwtb3BhY2l0eToxO2ZpbGwtcnVsZTpub256ZXJvO3N0cm9rZTpub25lIiAvPjxwYXRoCiAgICAgICAgICAgICBkPSJtIDczNi4zMDEsMTMzNS44OCBjIC0zMjMuMDQ3LDAgLTU4NS44NzUsLTI2Mi43OCAtNTg1Ljg3NSwtNTg1Ljc4MiAwLC0zMjMuMTE4IDI2Mi44MjgsLTU4NS45NzcgNTg1Ljg3NSwtNTg1Ljk3NyAzMjMuMDE5LDAgNTg1LjgwOSwyNjIuODU5IDU4NS44MDksNTg1Ljk3NyAwLDMyMy4wMDIgLTI2Mi43OSw1ODUuNzgyIC01ODUuODA5LDU4NS43ODIgbCAwLDAgeiBtIDAsLTExOC42MSBjIDI1Ny45NzIsMCA0NjcuMTg5LC0yMDkuMTMgNDY3LjE4OSwtNDY3LjE3MiAwLC0yNTguMTI5IC0yMDkuMjE3LC00NjcuMzQ4IC00NjcuMTg5LC00NjcuMzQ4IC0yNTguMDc0LDAgLTQ2Ny4yNTQsMjA5LjIxOSAtNDY3LjI1NCw0NjcuMzQ4IDAsMjU4LjA0MiAyMDkuMTgsNDY3LjE3MiA0NjcuMjU0LDQ2Ny4xNzIiCiAgICAgICAgICAgICBpbmtzY2FwZTpjb25uZWN0b3ItY3VydmF0dXJlPSIwIgogICAgICAgICAgICAgaWQ9InBhdGg0NiIKICAgICAgICAgICAgIHN0eWxlPSJmaWxsOiM4YTQxODI7ZmlsbC1vcGFjaXR5OjE7ZmlsbC1ydWxlOm5vbnplcm87c3Ryb2tlOm5vbmUiIC8+PHBhdGgKICAgICAgICAgICAgIGQ9Im0gMTA5MS4xMyw2MTkuODgzIC0xNzUuNzcxLDU3LjEyMSAxMS42MjksMzUuODA4IDE3NS43NjIsLTU3LjEyMSAtMTEuNjIsLTM1LjgwOCIKICAgICAgICAgICAgIGlua3NjYXBlOmNvbm5lY3Rvci1jdXJ2YXR1cmU9IjAiCiAgICAgICAgICAgICBpZD0icGF0aDQ4IgogICAgICAgICAgICAgc3R5bGU9ImZpbGw6IzhhNDE4MjtmaWxsLW9wYWNpdHk6MTtmaWxsLXJ1bGU6bm9uemVybztzdHJva2U6bm9uZSIgLz48cGF0aAogICAgICAgICAgICAgZD0iTSA4NjYuOTU3LDkwMi4wNzQgODM2LjUsOTI0LjE5OSA5NDUuMTIxLDEwNzMuNzMgOTc1LjU4NiwxMDUxLjYxIDg2Ni45NTcsOTAyLjA3NCIKICAgICAgICAgICAgIGlua3NjYXBlOmNvbm5lY3Rvci1jdXJ2YXR1cmU9IjAiCiAgICAgICAgICAgICBpZD0icGF0aDUwIgogICAgICAgICAgICAgc3R5bGU9ImZpbGw6IzhhNDE4MjtmaWxsLW9wYWNpdHk6MTtmaWxsLXJ1bGU6bm9uemVybztzdHJva2U6bm9uZSIgLz48cGF0aAogICAgICAgICAgICAgZD0iTSA2MDcuNDY1LDkwMy40NDUgNDk4Ljg1NSwxMDUyLjk3IDUyOS4zMiwxMDc1LjEgNjM3LjkzLDkyNS41NjYgNjA3LjQ2NSw5MDMuNDQ1IgogICAgICAgICAgICAgaW5rc2NhcGU6Y29ubmVjdG9yLWN1cnZhdHVyZT0iMCIKICAgICAgICAgICAgIGlkPSJwYXRoNTIiCiAgICAgICAgICAgICBzdHlsZT0iZmlsbDojOGE0MTgyO2ZpbGwtb3BhY2l0eToxO2ZpbGwtcnVsZTpub256ZXJvO3N0cm9rZTpub25lIiAvPjxwYXRoCiAgICAgICAgICAgICBkPSJtIDM4MC42ODgsNjIyLjEyOSAtMTEuNjI2LDM1LjgwMSAxNzUuNzU4LDU3LjA5IDExLjYyMSwtMzUuODAxIC0xNzUuNzUzLC01Ny4wOSIKICAgICAgICAgICAgIGlua3NjYXBlOmNvbm5lY3Rvci1jdXJ2YXR1cmU9IjAiCiAgICAgICAgICAgICBpZD0icGF0aDU0IgogICAgICAgICAgICAgc3R5bGU9ImZpbGw6IzhhNDE4MjtmaWxsLW9wYWNpdHk6MTtmaWxsLXJ1bGU6bm9uemVybztzdHJva2U6bm9uZSIgLz48cGF0aAogICAgICAgICAgICAgZD0ibSA3MTYuMjg5LDM3Ni41OSAzNy42NDA2LDAgMCwxODQuODE2IC0zNy42NDA2LDAgMCwtMTg0LjgxNiB6IgogICAgICAgICAgICAgaW5rc2NhcGU6Y29ubmVjdG9yLWN1cnZhdHVyZT0iMCIKICAgICAgICAgICAgIGlkPSJwYXRoNTYiCiAgICAgICAgICAgICBzdHlsZT0iZmlsbDojOGE0MTgyO2ZpbGwtb3BhY2l0eToxO2ZpbGwtcnVsZTpub256ZXJvO3N0cm9rZTpub25lIiAvPjwvZz48L2c+PC9nPjwvZz48L3N2Zz4=') no-repeat, none; -webkit-background-size: 100%; -moz-background-size: 100%; -o-background-size: 100%; background-size: 100%; display: block; float: left; width: 90px; height: 25px; } .jasmine_html-reporter .banner .version { margin-left: 14px; position: relative; top: 6px; } .jasmine_html-reporter .banner .duration { position: absolute; right: 14px; top: 6px; } .jasmine_html-reporter #jasmine_content { position: fixed; right: 100%; } .jasmine_html-reporter .version { color: #aaaaaa; } .jasmine_html-reporter .banner { margin-top: 14px; } .jasmine_html-reporter .duration { color: #aaaaaa; float: right; } .jasmine_html-reporter .symbol-summary { overflow: hidden; *zoom: 1; margin: 14px 0; } .jasmine_html-reporter .symbol-summary li { display: inline-block; height: 8px; width: 14px; font-size: 16px; } .jasmine_html-reporter .symbol-summary li.passed { font-size: 14px; } .jasmine_html-reporter .symbol-summary li.passed:before { color: #007069; content: "\02022"; } .jasmine_html-reporter .symbol-summary li.failed { line-height: 9px; } .jasmine_html-reporter .symbol-summary li.failed:before { color: #ca3a11; content: "\d7"; font-weight: bold; margin-left: -1px; } .jasmine_html-reporter .symbol-summary li.disabled { font-size: 14px; } .jasmine_html-reporter .symbol-summary li.disabled:before { color: #bababa; content: "\02022"; } .jasmine_html-reporter .symbol-summary li.pending { line-height: 17px; } .jasmine_html-reporter .symbol-summary li.pending:before { color: #ba9d37; content: "*"; } .jasmine_html-reporter .symbol-summary li.empty { font-size: 14px; } .jasmine_html-reporter .symbol-summary li.empty:before { color: #ba9d37; content: "\02022"; } .jasmine_html-reporter .exceptions { color: #fff; float: right; margin-top: 5px; margin-right: 5px; } .jasmine_html-reporter .bar { line-height: 28px; font-size: 14px; display: block; color: #eee; } .jasmine_html-reporter .bar.failed { background-color: #ca3a11; } .jasmine_html-reporter .bar.passed { background-color: #007069; } .jasmine_html-reporter .bar.skipped { background-color: #bababa; } .jasmine_html-reporter .bar.menu { background-color: #fff; color: #aaaaaa; } .jasmine_html-reporter .bar.menu a { color: #333333; } .jasmine_html-reporter .bar a { color: white; } .jasmine_html-reporter.spec-list .bar.menu.failure-list, .jasmine_html-reporter.spec-list .results .failures { display: none; } .jasmine_html-reporter.failure-list .bar.menu.spec-list, .jasmine_html-reporter.failure-list .summary { display: none; } .jasmine_html-reporter .running-alert { background-color: #666666; } .jasmine_html-reporter .results { margin-top: 14px; } .jasmine_html-reporter.showDetails .summaryMenuItem { font-weight: normal; text-decoration: inherit; } .jasmine_html-reporter.showDetails .summaryMenuItem:hover { text-decoration: underline; } .jasmine_html-reporter.showDetails .detailsMenuItem { font-weight: bold; text-decoration: underline; } .jasmine_html-reporter.showDetails .summary { display: none; } .jasmine_html-reporter.showDetails #details { display: block; } .jasmine_html-reporter .summaryMenuItem { font-weight: bold; text-decoration: underline; } .jasmine_html-reporter .summary { margin-top: 14px; } .jasmine_html-reporter .summary ul { list-style-type: none; margin-left: 14px; padding-top: 0; padding-left: 0; } .jasmine_html-reporter .summary ul.suite { margin-top: 7px; margin-bottom: 7px; } .jasmine_html-reporter .summary li.passed a { color: #007069; } .jasmine_html-reporter .summary li.failed a { color: #ca3a11; } .jasmine_html-reporter .summary li.empty a { color: #ba9d37; } .jasmine_html-reporter .summary li.pending a { color: #ba9d37; } .jasmine_html-reporter .description + .suite { margin-top: 0; } .jasmine_html-reporter .suite { margin-top: 14px; } .jasmine_html-reporter .suite a { color: #333333; } .jasmine_html-reporter .failures .spec-detail { margin-bottom: 28px; } .jasmine_html-reporter .failures .spec-detail .description { background-color: #ca3a11; } .jasmine_html-reporter .failures .spec-detail .description a { color: white; } .jasmine_html-reporter .result-message { padding-top: 14px; color: #333333; white-space: pre; } .jasmine_html-reporter .result-message span.result { display: block; } .jasmine_html-reporter .stack-trace { margin: 5px 0 0 0; max-height: 224px; overflow: auto; line-height: 18px; color: #666666; border: 1px solid #ddd; background: white; white-space: pre; } ================================================ FILE: specs/jasmine-2.0.3/jasmine.js ================================================ /* Copyright (c) 2008-2014 Pivotal Labs Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ function getJasmineRequireObj() { if (typeof module !== 'undefined' && module.exports) { return exports; } else { window.jasmineRequire = window.jasmineRequire || {}; return window.jasmineRequire; } } getJasmineRequireObj().core = function(jRequire) { var j$ = {}; jRequire.base(j$); j$.util = jRequire.util(); j$.Any = jRequire.Any(); j$.CallTracker = jRequire.CallTracker(); j$.MockDate = jRequire.MockDate(); j$.Clock = jRequire.Clock(); j$.DelayedFunctionScheduler = jRequire.DelayedFunctionScheduler(); j$.Env = jRequire.Env(j$); j$.ExceptionFormatter = jRequire.ExceptionFormatter(); j$.Expectation = jRequire.Expectation(); j$.buildExpectationResult = jRequire.buildExpectationResult(); j$.JsApiReporter = jRequire.JsApiReporter(); j$.matchersUtil = jRequire.matchersUtil(j$); j$.ObjectContaining = jRequire.ObjectContaining(j$); j$.pp = jRequire.pp(j$); j$.QueueRunner = jRequire.QueueRunner(j$); j$.ReportDispatcher = jRequire.ReportDispatcher(); j$.Spec = jRequire.Spec(j$); j$.SpyStrategy = jRequire.SpyStrategy(); j$.Suite = jRequire.Suite(); j$.Timer = jRequire.Timer(); j$.version = jRequire.version(); j$.matchers = jRequire.requireMatchers(jRequire, j$); return j$; }; getJasmineRequireObj().requireMatchers = function(jRequire, j$) { var availableMatchers = [ 'toBe', 'toBeCloseTo', 'toBeDefined', 'toBeFalsy', 'toBeGreaterThan', 'toBeLessThan', 'toBeNaN', 'toBeNull', 'toBeTruthy', 'toBeUndefined', 'toContain', 'toEqual', 'toHaveBeenCalled', 'toHaveBeenCalledWith', 'toMatch', 'toThrow', 'toThrowError' ], matchers = {}; for (var i = 0; i < availableMatchers.length; i++) { var name = availableMatchers[i]; matchers[name] = jRequire[name](j$); } return matchers; }; getJasmineRequireObj().base = (function (jasmineGlobal) { if (typeof module !== 'undefined' && module.exports) { jasmineGlobal = global; } return function(j$) { j$.unimplementedMethod_ = function() { throw new Error('unimplemented method'); }; j$.MAX_PRETTY_PRINT_DEPTH = 40; j$.MAX_PRETTY_PRINT_ARRAY_LENGTH = 100; j$.DEFAULT_TIMEOUT_INTERVAL = 5000; j$.getGlobal = function() { return jasmineGlobal; }; j$.getEnv = function(options) { var env = j$.currentEnv_ = j$.currentEnv_ || new j$.Env(options); //jasmine. singletons in here (setTimeout blah blah). return env; }; j$.isArray_ = function(value) { return j$.isA_('Array', value); }; j$.isString_ = function(value) { return j$.isA_('String', value); }; j$.isNumber_ = function(value) { return j$.isA_('Number', value); }; j$.isA_ = function(typeName, value) { return Object.prototype.toString.apply(value) === '[object ' + typeName + ']'; }; j$.isDomNode = function(obj) { return obj.nodeType > 0; }; j$.any = function(clazz) { return new j$.Any(clazz); }; j$.objectContaining = function(sample) { return new j$.ObjectContaining(sample); }; j$.createSpy = function(name, originalFn) { var spyStrategy = new j$.SpyStrategy({ name: name, fn: originalFn, getSpy: function() { return spy; } }), callTracker = new j$.CallTracker(), spy = function() { callTracker.track({ object: this, args: Array.prototype.slice.apply(arguments) }); return spyStrategy.exec.apply(this, arguments); }; for (var prop in originalFn) { if (prop === 'and' || prop === 'calls') { throw new Error('Jasmine spies would overwrite the \'and\' and \'calls\' properties on the object being spied upon'); } spy[prop] = originalFn[prop]; } spy.and = spyStrategy; spy.calls = callTracker; return spy; }; j$.isSpy = function(putativeSpy) { if (!putativeSpy) { return false; } return putativeSpy.and instanceof j$.SpyStrategy && putativeSpy.calls instanceof j$.CallTracker; }; j$.createSpyObj = function(baseName, methodNames) { if (!j$.isArray_(methodNames) || methodNames.length === 0) { throw 'createSpyObj requires a non-empty array of method names to create spies for'; } var obj = {}; for (var i = 0; i < methodNames.length; i++) { obj[methodNames[i]] = j$.createSpy(baseName + '.' + methodNames[i]); } return obj; }; }; })(this); getJasmineRequireObj().util = function() { var util = {}; util.inherit = function(childClass, parentClass) { var Subclass = function() { }; Subclass.prototype = parentClass.prototype; childClass.prototype = new Subclass(); }; util.htmlEscape = function(str) { if (!str) { return str; } return str.replace(/&/g, '&') .replace(//g, '>'); }; util.argsToArray = function(args) { var arrayOfArgs = []; for (var i = 0; i < args.length; i++) { arrayOfArgs.push(args[i]); } return arrayOfArgs; }; util.isUndefined = function(obj) { return obj === void 0; }; util.arrayContains = function(array, search) { var i = array.length; while (i--) { if (array[i] == search) { return true; } } return false; }; return util; }; getJasmineRequireObj().Spec = function(j$) { function Spec(attrs) { this.expectationFactory = attrs.expectationFactory; this.resultCallback = attrs.resultCallback || function() {}; this.id = attrs.id; this.description = attrs.description || ''; this.fn = attrs.fn; this.beforeFns = attrs.beforeFns || function() { return []; }; this.afterFns = attrs.afterFns || function() { return []; }; this.onStart = attrs.onStart || function() {}; this.exceptionFormatter = attrs.exceptionFormatter || function() {}; this.getSpecName = attrs.getSpecName || function() { return ''; }; this.expectationResultFactory = attrs.expectationResultFactory || function() { }; this.queueRunnerFactory = attrs.queueRunnerFactory || function() {}; this.catchingExceptions = attrs.catchingExceptions || function() { return true; }; if (!this.fn) { this.pend(); } this.result = { id: this.id, description: this.description, fullName: this.getFullName(), failedExpectations: [], passedExpectations: [] }; } Spec.prototype.addExpectationResult = function(passed, data) { var expectationResult = this.expectationResultFactory(data); if (passed) { this.result.passedExpectations.push(expectationResult); } else { this.result.failedExpectations.push(expectationResult); } }; Spec.prototype.expect = function(actual) { return this.expectationFactory(actual, this); }; Spec.prototype.execute = function(onComplete) { var self = this; this.onStart(this); if (this.markedPending || this.disabled) { complete(); return; } var allFns = this.beforeFns().concat(this.fn).concat(this.afterFns()); this.queueRunnerFactory({ fns: allFns, onException: onException, onComplete: complete, enforceTimeout: function() { return true; } }); function onException(e) { if (Spec.isPendingSpecException(e)) { self.pend(); return; } self.addExpectationResult(false, { matcherName: '', passed: false, expected: '', actual: '', error: e }); } function complete() { self.result.status = self.status(); self.resultCallback(self.result); if (onComplete) { onComplete(); } } }; Spec.prototype.disable = function() { this.disabled = true; }; Spec.prototype.pend = function() { this.markedPending = true; }; Spec.prototype.status = function() { if (this.disabled) { return 'disabled'; } if (this.markedPending) { return 'pending'; } if (this.result.failedExpectations.length > 0) { return 'failed'; } else { return 'passed'; } }; Spec.prototype.getFullName = function() { return this.getSpecName(this); }; Spec.pendingSpecExceptionMessage = '=> marked Pending'; Spec.isPendingSpecException = function(e) { return !!(e && e.toString && e.toString().indexOf(Spec.pendingSpecExceptionMessage) !== -1); }; return Spec; }; if (typeof window == void 0 && typeof exports == 'object') { exports.Spec = jasmineRequire.Spec; } getJasmineRequireObj().Env = function(j$) { function Env(options) { options = options || {}; var self = this; var global = options.global || j$.getGlobal(); var totalSpecsDefined = 0; var catchExceptions = true; var realSetTimeout = j$.getGlobal().setTimeout; var realClearTimeout = j$.getGlobal().clearTimeout; this.clock = new j$.Clock(global, new j$.DelayedFunctionScheduler(), new j$.MockDate(global)); var runnableLookupTable = {}; var spies = []; var currentSpec = null; var currentSuite = null; var reporter = new j$.ReportDispatcher([ 'jasmineStarted', 'jasmineDone', 'suiteStarted', 'suiteDone', 'specStarted', 'specDone' ]); this.specFilter = function() { return true; }; var equalityTesters = []; var customEqualityTesters = []; this.addCustomEqualityTester = function(tester) { customEqualityTesters.push(tester); }; j$.Expectation.addCoreMatchers(j$.matchers); var nextSpecId = 0; var getNextSpecId = function() { return 'spec' + nextSpecId++; }; var nextSuiteId = 0; var getNextSuiteId = function() { return 'suite' + nextSuiteId++; }; var expectationFactory = function(actual, spec) { return j$.Expectation.Factory({ util: j$.matchersUtil, customEqualityTesters: customEqualityTesters, actual: actual, addExpectationResult: addExpectationResult }); function addExpectationResult(passed, result) { return spec.addExpectationResult(passed, result); } }; var specStarted = function(spec) { currentSpec = spec; reporter.specStarted(spec.result); }; var beforeFns = function(suite) { return function() { var befores = []; while(suite) { befores = befores.concat(suite.beforeFns); suite = suite.parentSuite; } return befores.reverse(); }; }; var afterFns = function(suite) { return function() { var afters = []; while(suite) { afters = afters.concat(suite.afterFns); suite = suite.parentSuite; } return afters; }; }; var getSpecName = function(spec, suite) { return suite.getFullName() + ' ' + spec.description; }; // TODO: we may just be able to pass in the fn instead of wrapping here var buildExpectationResult = j$.buildExpectationResult, exceptionFormatter = new j$.ExceptionFormatter(), expectationResultFactory = function(attrs) { attrs.messageFormatter = exceptionFormatter.message; attrs.stackFormatter = exceptionFormatter.stack; return buildExpectationResult(attrs); }; // TODO: fix this naming, and here's where the value comes in this.catchExceptions = function(value) { catchExceptions = !!value; return catchExceptions; }; this.catchingExceptions = function() { return catchExceptions; }; var maximumSpecCallbackDepth = 20; var currentSpecCallbackDepth = 0; function clearStack(fn) { currentSpecCallbackDepth++; if (currentSpecCallbackDepth >= maximumSpecCallbackDepth) { currentSpecCallbackDepth = 0; realSetTimeout(fn, 0); } else { fn(); } } var catchException = function(e) { return j$.Spec.isPendingSpecException(e) || catchExceptions; }; var queueRunnerFactory = function(options) { options.catchException = catchException; options.clearStack = options.clearStack || clearStack; options.timer = {setTimeout: realSetTimeout, clearTimeout: realClearTimeout}; new j$.QueueRunner(options).execute(); }; var topSuite = new j$.Suite({ env: this, id: getNextSuiteId(), description: 'Jasmine__TopLevel__Suite', queueRunner: queueRunnerFactory, resultCallback: function() {} // TODO - hook this up }); runnableLookupTable[topSuite.id] = topSuite; currentSuite = topSuite; this.topSuite = function() { return topSuite; }; this.execute = function(runnablesToRun) { runnablesToRun = runnablesToRun || [topSuite.id]; var allFns = []; for(var i = 0; i < runnablesToRun.length; i++) { var runnable = runnableLookupTable[runnablesToRun[i]]; allFns.push((function(runnable) { return function(done) { runnable.execute(done); }; })(runnable)); } reporter.jasmineStarted({ totalSpecsDefined: totalSpecsDefined }); queueRunnerFactory({fns: allFns, onComplete: reporter.jasmineDone}); }; this.addReporter = function(reporterToAdd) { reporter.addReporter(reporterToAdd); }; this.addMatchers = function(matchersToAdd) { j$.Expectation.addMatchers(matchersToAdd); }; this.spyOn = function(obj, methodName) { if (j$.util.isUndefined(obj)) { throw new Error('spyOn could not find an object to spy upon for ' + methodName + '()'); } if (j$.util.isUndefined(obj[methodName])) { throw new Error(methodName + '() method does not exist'); } if (obj[methodName] && j$.isSpy(obj[methodName])) { //TODO?: should this return the current spy? Downside: may cause user confusion about spy state throw new Error(methodName + ' has already been spied upon'); } var spy = j$.createSpy(methodName, obj[methodName]); spies.push({ spy: spy, baseObj: obj, methodName: methodName, originalValue: obj[methodName] }); obj[methodName] = spy; return spy; }; var suiteFactory = function(description) { var suite = new j$.Suite({ env: self, id: getNextSuiteId(), description: description, parentSuite: currentSuite, queueRunner: queueRunnerFactory, onStart: suiteStarted, resultCallback: function(attrs) { reporter.suiteDone(attrs); } }); runnableLookupTable[suite.id] = suite; return suite; }; this.describe = function(description, specDefinitions) { var suite = suiteFactory(description); var parentSuite = currentSuite; parentSuite.addChild(suite); currentSuite = suite; var declarationError = null; try { specDefinitions.call(suite); } catch (e) { declarationError = e; } if (declarationError) { this.it('encountered a declaration exception', function() { throw declarationError; }); } currentSuite = parentSuite; return suite; }; this.xdescribe = function(description, specDefinitions) { var suite = this.describe(description, specDefinitions); suite.disable(); return suite; }; var specFactory = function(description, fn, suite) { totalSpecsDefined++; var spec = new j$.Spec({ id: getNextSpecId(), beforeFns: beforeFns(suite), afterFns: afterFns(suite), expectationFactory: expectationFactory, exceptionFormatter: exceptionFormatter, resultCallback: specResultCallback, getSpecName: function(spec) { return getSpecName(spec, suite); }, onStart: specStarted, description: description, expectationResultFactory: expectationResultFactory, queueRunnerFactory: queueRunnerFactory, fn: fn }); runnableLookupTable[spec.id] = spec; if (!self.specFilter(spec)) { spec.disable(); } return spec; function removeAllSpies() { for (var i = 0; i < spies.length; i++) { var spyEntry = spies[i]; spyEntry.baseObj[spyEntry.methodName] = spyEntry.originalValue; } spies = []; } function specResultCallback(result) { removeAllSpies(); j$.Expectation.resetMatchers(); customEqualityTesters = []; currentSpec = null; reporter.specDone(result); } }; var suiteStarted = function(suite) { reporter.suiteStarted(suite.result); }; this.it = function(description, fn) { var spec = specFactory(description, fn, currentSuite); currentSuite.addChild(spec); return spec; }; this.xit = function(description, fn) { var spec = this.it(description, fn); spec.pend(); return spec; }; this.expect = function(actual) { if (!currentSpec) { throw new Error('\'expect\' was used when there was no current spec, this could be because an asynchronous test timed out'); } return currentSpec.expect(actual); }; this.beforeEach = function(beforeEachFunction) { currentSuite.beforeEach(beforeEachFunction); }; this.afterEach = function(afterEachFunction) { currentSuite.afterEach(afterEachFunction); }; this.pending = function() { throw j$.Spec.pendingSpecExceptionMessage; }; } return Env; }; getJasmineRequireObj().JsApiReporter = function() { var noopTimer = { start: function(){}, elapsed: function(){ return 0; } }; function JsApiReporter(options) { var timer = options.timer || noopTimer, status = 'loaded'; this.started = false; this.finished = false; this.jasmineStarted = function() { this.started = true; status = 'started'; timer.start(); }; var executionTime; this.jasmineDone = function() { this.finished = true; executionTime = timer.elapsed(); status = 'done'; }; this.status = function() { return status; }; var suites = {}; this.suiteStarted = function(result) { storeSuite(result); }; this.suiteDone = function(result) { storeSuite(result); }; function storeSuite(result) { suites[result.id] = result; } this.suites = function() { return suites; }; var specs = []; this.specStarted = function(result) { }; this.specDone = function(result) { specs.push(result); }; this.specResults = function(index, length) { return specs.slice(index, index + length); }; this.specs = function() { return specs; }; this.executionTime = function() { return executionTime; }; } return JsApiReporter; }; getJasmineRequireObj().Any = function() { function Any(expectedObject) { this.expectedObject = expectedObject; } Any.prototype.jasmineMatches = function(other) { if (this.expectedObject == String) { return typeof other == 'string' || other instanceof String; } if (this.expectedObject == Number) { return typeof other == 'number' || other instanceof Number; } if (this.expectedObject == Function) { return typeof other == 'function' || other instanceof Function; } if (this.expectedObject == Object) { return typeof other == 'object'; } if (this.expectedObject == Boolean) { return typeof other == 'boolean'; } return other instanceof this.expectedObject; }; Any.prototype.jasmineToString = function() { return ''; }; return Any; }; getJasmineRequireObj().CallTracker = function() { function CallTracker() { var calls = []; this.track = function(context) { calls.push(context); }; this.any = function() { return !!calls.length; }; this.count = function() { return calls.length; }; this.argsFor = function(index) { var call = calls[index]; return call ? call.args : []; }; this.all = function() { return calls; }; this.allArgs = function() { var callArgs = []; for(var i = 0; i < calls.length; i++){ callArgs.push(calls[i].args); } return callArgs; }; this.first = function() { return calls[0]; }; this.mostRecent = function() { return calls[calls.length - 1]; }; this.reset = function() { calls = []; }; } return CallTracker; }; getJasmineRequireObj().Clock = function() { function Clock(global, delayedFunctionScheduler, mockDate) { var self = this, realTimingFunctions = { setTimeout: global.setTimeout, clearTimeout: global.clearTimeout, setInterval: global.setInterval, clearInterval: global.clearInterval }, fakeTimingFunctions = { setTimeout: setTimeout, clearTimeout: clearTimeout, setInterval: setInterval, clearInterval: clearInterval }, installed = false, timer; self.install = function() { replace(global, fakeTimingFunctions); timer = fakeTimingFunctions; installed = true; return self; }; self.uninstall = function() { delayedFunctionScheduler.reset(); mockDate.uninstall(); replace(global, realTimingFunctions); timer = realTimingFunctions; installed = false; }; self.mockDate = function(initialDate) { mockDate.install(initialDate); }; self.setTimeout = function(fn, delay, params) { if (legacyIE()) { if (arguments.length > 2) { throw new Error('IE < 9 cannot support extra params to setTimeout without a polyfill'); } return timer.setTimeout(fn, delay); } return Function.prototype.apply.apply(timer.setTimeout, [global, arguments]); }; self.setInterval = function(fn, delay, params) { if (legacyIE()) { if (arguments.length > 2) { throw new Error('IE < 9 cannot support extra params to setInterval without a polyfill'); } return timer.setInterval(fn, delay); } return Function.prototype.apply.apply(timer.setInterval, [global, arguments]); }; self.clearTimeout = function(id) { return Function.prototype.call.apply(timer.clearTimeout, [global, id]); }; self.clearInterval = function(id) { return Function.prototype.call.apply(timer.clearInterval, [global, id]); }; self.tick = function(millis) { if (installed) { mockDate.tick(millis); delayedFunctionScheduler.tick(millis); } else { throw new Error('Mock clock is not installed, use jasmine.clock().install()'); } }; return self; function legacyIE() { //if these methods are polyfilled, apply will be present return !(realTimingFunctions.setTimeout || realTimingFunctions.setInterval).apply; } function replace(dest, source) { for (var prop in source) { dest[prop] = source[prop]; } } function setTimeout(fn, delay) { return delayedFunctionScheduler.scheduleFunction(fn, delay, argSlice(arguments, 2)); } function clearTimeout(id) { return delayedFunctionScheduler.removeFunctionWithId(id); } function setInterval(fn, interval) { return delayedFunctionScheduler.scheduleFunction(fn, interval, argSlice(arguments, 2), true); } function clearInterval(id) { return delayedFunctionScheduler.removeFunctionWithId(id); } function argSlice(argsObj, n) { return Array.prototype.slice.call(argsObj, n); } } return Clock; }; getJasmineRequireObj().DelayedFunctionScheduler = function() { function DelayedFunctionScheduler() { var self = this; var scheduledLookup = []; var scheduledFunctions = {}; var currentTime = 0; var delayedFnCount = 0; self.tick = function(millis) { millis = millis || 0; var endTime = currentTime + millis; runScheduledFunctions(endTime); currentTime = endTime; }; self.scheduleFunction = function(funcToCall, millis, params, recurring, timeoutKey, runAtMillis) { var f; if (typeof(funcToCall) === 'string') { /* jshint evil: true */ f = function() { return eval(funcToCall); }; /* jshint evil: false */ } else { f = funcToCall; } millis = millis || 0; timeoutKey = timeoutKey || ++delayedFnCount; runAtMillis = runAtMillis || (currentTime + millis); var funcToSchedule = { runAtMillis: runAtMillis, funcToCall: f, recurring: recurring, params: params, timeoutKey: timeoutKey, millis: millis }; if (runAtMillis in scheduledFunctions) { scheduledFunctions[runAtMillis].push(funcToSchedule); } else { scheduledFunctions[runAtMillis] = [funcToSchedule]; scheduledLookup.push(runAtMillis); scheduledLookup.sort(function (a, b) { return a - b; }); } return timeoutKey; }; self.removeFunctionWithId = function(timeoutKey) { for (var runAtMillis in scheduledFunctions) { var funcs = scheduledFunctions[runAtMillis]; var i = indexOfFirstToPass(funcs, function (func) { return func.timeoutKey === timeoutKey; }); if (i > -1) { if (funcs.length === 1) { delete scheduledFunctions[runAtMillis]; deleteFromLookup(runAtMillis); } else { funcs.splice(i, 1); } // intervals get rescheduled when executed, so there's never more // than a single scheduled function with a given timeoutKey break; } } }; self.reset = function() { currentTime = 0; scheduledLookup = []; scheduledFunctions = {}; delayedFnCount = 0; }; return self; function indexOfFirstToPass(array, testFn) { var index = -1; for (var i = 0; i < array.length; ++i) { if (testFn(array[i])) { index = i; break; } } return index; } function deleteFromLookup(key) { var value = Number(key); var i = indexOfFirstToPass(scheduledLookup, function (millis) { return millis === value; }); if (i > -1) { scheduledLookup.splice(i, 1); } } function reschedule(scheduledFn) { self.scheduleFunction(scheduledFn.funcToCall, scheduledFn.millis, scheduledFn.params, true, scheduledFn.timeoutKey, scheduledFn.runAtMillis + scheduledFn.millis); } function runScheduledFunctions(endTime) { if (scheduledLookup.length === 0 || scheduledLookup[0] > endTime) { return; } do { currentTime = scheduledLookup.shift(); var funcsToRun = scheduledFunctions[currentTime]; delete scheduledFunctions[currentTime]; for (var i = 0; i < funcsToRun.length; ++i) { var funcToRun = funcsToRun[i]; funcToRun.funcToCall.apply(null, funcToRun.params || []); if (funcToRun.recurring) { reschedule(funcToRun); } } } while (scheduledLookup.length > 0 && // checking first if we're out of time prevents setTimeout(0) // scheduled in a funcToRun from forcing an extra iteration currentTime !== endTime && scheduledLookup[0] <= endTime); } } return DelayedFunctionScheduler; }; getJasmineRequireObj().ExceptionFormatter = function() { function ExceptionFormatter() { this.message = function(error) { var message = ''; if (error.name && error.message) { message += error.name + ': ' + error.message; } else { message += error.toString() + ' thrown'; } if (error.fileName || error.sourceURL) { message += ' in ' + (error.fileName || error.sourceURL); } if (error.line || error.lineNumber) { message += ' (line ' + (error.line || error.lineNumber) + ')'; } return message; }; this.stack = function(error) { return error ? error.stack : null; }; } return ExceptionFormatter; }; getJasmineRequireObj().Expectation = function() { var matchers = {}; function Expectation(options) { this.util = options.util || { buildFailureMessage: function() {} }; this.customEqualityTesters = options.customEqualityTesters || []; this.actual = options.actual; this.addExpectationResult = options.addExpectationResult || function(){}; this.isNot = options.isNot; for (var matcherName in matchers) { this[matcherName] = matchers[matcherName]; } } Expectation.prototype.wrapCompare = function(name, matcherFactory) { return function() { var args = Array.prototype.slice.call(arguments, 0), expected = args.slice(0), message = ''; args.unshift(this.actual); var matcher = matcherFactory(this.util, this.customEqualityTesters), matcherCompare = matcher.compare; function defaultNegativeCompare() { var result = matcher.compare.apply(null, args); result.pass = !result.pass; return result; } if (this.isNot) { matcherCompare = matcher.negativeCompare || defaultNegativeCompare; } var result = matcherCompare.apply(null, args); if (!result.pass) { if (!result.message) { args.unshift(this.isNot); args.unshift(name); message = this.util.buildFailureMessage.apply(null, args); } else { if (Object.prototype.toString.apply(result.message) === '[object Function]') { message = result.message(); } else { message = result.message; } } } if (expected.length == 1) { expected = expected[0]; } // TODO: how many of these params are needed? this.addExpectationResult( result.pass, { matcherName: name, passed: result.pass, message: message, actual: this.actual, expected: expected // TODO: this may need to be arrayified/sliced } ); }; }; Expectation.addCoreMatchers = function(matchers) { var prototype = Expectation.prototype; for (var matcherName in matchers) { var matcher = matchers[matcherName]; prototype[matcherName] = prototype.wrapCompare(matcherName, matcher); } }; Expectation.addMatchers = function(matchersToAdd) { for (var name in matchersToAdd) { var matcher = matchersToAdd[name]; matchers[name] = Expectation.prototype.wrapCompare(name, matcher); } }; Expectation.resetMatchers = function() { for (var name in matchers) { delete matchers[name]; } }; Expectation.Factory = function(options) { options = options || {}; var expect = new Expectation(options); // TODO: this would be nice as its own Object - NegativeExpectation // TODO: copy instead of mutate options options.isNot = true; expect.not = new Expectation(options); return expect; }; return Expectation; }; //TODO: expectation result may make more sense as a presentation of an expectation. getJasmineRequireObj().buildExpectationResult = function() { function buildExpectationResult(options) { var messageFormatter = options.messageFormatter || function() {}, stackFormatter = options.stackFormatter || function() {}; return { matcherName: options.matcherName, expected: options.expected, actual: options.actual, message: message(), stack: stack(), passed: options.passed }; function message() { if (options.passed) { return 'Passed.'; } else if (options.message) { return options.message; } else if (options.error) { return messageFormatter(options.error); } return ''; } function stack() { if (options.passed) { return ''; } var error = options.error; if (!error) { try { throw new Error(message()); } catch (e) { error = e; } } return stackFormatter(error); } } return buildExpectationResult; }; getJasmineRequireObj().MockDate = function() { function MockDate(global) { var self = this; var currentTime = 0; if (!global || !global.Date) { self.install = function() {}; self.tick = function() {}; self.uninstall = function() {}; return self; } var GlobalDate = global.Date; self.install = function(mockDate) { if (mockDate instanceof GlobalDate) { currentTime = mockDate.getTime(); } else { currentTime = new GlobalDate().getTime(); } global.Date = FakeDate; }; self.tick = function(millis) { millis = millis || 0; currentTime = currentTime + millis; }; self.uninstall = function() { currentTime = 0; global.Date = GlobalDate; }; createDateProperties(); return self; function FakeDate() { switch(arguments.length) { case 0: return new GlobalDate(currentTime); case 1: return new GlobalDate(arguments[0]); case 2: return new GlobalDate(arguments[0], arguments[1]); case 3: return new GlobalDate(arguments[0], arguments[1], arguments[2]); case 4: return new GlobalDate(arguments[0], arguments[1], arguments[2], arguments[3]); case 5: return new GlobalDate(arguments[0], arguments[1], arguments[2], arguments[3], arguments[4]); case 6: return new GlobalDate(arguments[0], arguments[1], arguments[2], arguments[3], arguments[4], arguments[5]); case 7: return new GlobalDate(arguments[0], arguments[1], arguments[2], arguments[3], arguments[4], arguments[5], arguments[6]); } } function createDateProperties() { FakeDate.now = function() { if (GlobalDate.now) { return currentTime; } else { throw new Error('Browser does not support Date.now()'); } }; FakeDate.toSource = GlobalDate.toSource; FakeDate.toString = GlobalDate.toString; FakeDate.parse = GlobalDate.parse; FakeDate.UTC = GlobalDate.UTC; } } return MockDate; }; getJasmineRequireObj().ObjectContaining = function(j$) { function ObjectContaining(sample) { this.sample = sample; } ObjectContaining.prototype.jasmineMatches = function(other, mismatchKeys, mismatchValues) { if (typeof(this.sample) !== 'object') { throw new Error('You must provide an object to objectContaining, not \''+this.sample+'\'.'); } mismatchKeys = mismatchKeys || []; mismatchValues = mismatchValues || []; var hasKey = function(obj, keyName) { return obj !== null && !j$.util.isUndefined(obj[keyName]); }; for (var property in this.sample) { if (!hasKey(other, property) && hasKey(this.sample, property)) { mismatchKeys.push('expected has key \'' + property + '\', but missing from actual.'); } else if (!j$.matchersUtil.equals(other[property], this.sample[property])) { mismatchValues.push('\'' + property + '\' was \'' + (other[property] ? j$.util.htmlEscape(other[property].toString()) : other[property]) + '\' in actual, but was \'' + (this.sample[property] ? j$.util.htmlEscape(this.sample[property].toString()) : this.sample[property]) + '\' in expected.'); } } return (mismatchKeys.length === 0 && mismatchValues.length === 0); }; ObjectContaining.prototype.jasmineToString = function() { return ''; }; return ObjectContaining; }; getJasmineRequireObj().pp = function(j$) { function PrettyPrinter() { this.ppNestLevel_ = 0; this.seen = []; } PrettyPrinter.prototype.format = function(value) { this.ppNestLevel_++; try { if (j$.util.isUndefined(value)) { this.emitScalar('undefined'); } else if (value === null) { this.emitScalar('null'); } else if (value === 0 && 1/value === -Infinity) { this.emitScalar('-0'); } else if (value === j$.getGlobal()) { this.emitScalar(''); } else if (value.jasmineToString) { this.emitScalar(value.jasmineToString()); } else if (typeof value === 'string') { this.emitString(value); } else if (j$.isSpy(value)) { this.emitScalar('spy on ' + value.and.identity()); } else if (value instanceof RegExp) { this.emitScalar(value.toString()); } else if (typeof value === 'function') { this.emitScalar('Function'); } else if (typeof value.nodeType === 'number') { this.emitScalar('HTMLNode'); } else if (value instanceof Date) { this.emitScalar('Date(' + value + ')'); } else if (j$.util.arrayContains(this.seen, value)) { this.emitScalar(''); } else if (j$.isArray_(value) || j$.isA_('Object', value)) { this.seen.push(value); if (j$.isArray_(value)) { this.emitArray(value); } else { this.emitObject(value); } this.seen.pop(); } else { this.emitScalar(value.toString()); } } finally { this.ppNestLevel_--; } }; PrettyPrinter.prototype.iterateObject = function(obj, fn) { for (var property in obj) { if (!Object.prototype.hasOwnProperty.call(obj, property)) { continue; } fn(property, obj.__lookupGetter__ ? (!j$.util.isUndefined(obj.__lookupGetter__(property)) && obj.__lookupGetter__(property) !== null) : false); } }; PrettyPrinter.prototype.emitArray = j$.unimplementedMethod_; PrettyPrinter.prototype.emitObject = j$.unimplementedMethod_; PrettyPrinter.prototype.emitScalar = j$.unimplementedMethod_; PrettyPrinter.prototype.emitString = j$.unimplementedMethod_; function StringPrettyPrinter() { PrettyPrinter.call(this); this.string = ''; } j$.util.inherit(StringPrettyPrinter, PrettyPrinter); StringPrettyPrinter.prototype.emitScalar = function(value) { this.append(value); }; StringPrettyPrinter.prototype.emitString = function(value) { this.append('\'' + value + '\''); }; StringPrettyPrinter.prototype.emitArray = function(array) { if (this.ppNestLevel_ > j$.MAX_PRETTY_PRINT_DEPTH) { this.append('Array'); return; } var length = Math.min(array.length, j$.MAX_PRETTY_PRINT_ARRAY_LENGTH); this.append('[ '); for (var i = 0; i < length; i++) { if (i > 0) { this.append(', '); } this.format(array[i]); } if(array.length > length){ this.append(', ...'); } this.append(' ]'); }; StringPrettyPrinter.prototype.emitObject = function(obj) { if (this.ppNestLevel_ > j$.MAX_PRETTY_PRINT_DEPTH) { this.append('Object'); return; } var self = this; this.append('{ '); var first = true; this.iterateObject(obj, function(property, isGetter) { if (first) { first = false; } else { self.append(', '); } self.append(property); self.append(': '); if (isGetter) { self.append(''); } else { self.format(obj[property]); } }); this.append(' }'); }; StringPrettyPrinter.prototype.append = function(value) { this.string += value; }; return function(value) { var stringPrettyPrinter = new StringPrettyPrinter(); stringPrettyPrinter.format(value); return stringPrettyPrinter.string; }; }; getJasmineRequireObj().QueueRunner = function(j$) { function once(fn) { var called = false; return function() { if (!called) { called = true; fn(); } }; } function QueueRunner(attrs) { this.fns = attrs.fns || []; this.onComplete = attrs.onComplete || function() {}; this.clearStack = attrs.clearStack || function(fn) {fn();}; this.onException = attrs.onException || function() {}; this.catchException = attrs.catchException || function() { return true; }; this.enforceTimeout = attrs.enforceTimeout || function() { return false; }; this.userContext = {}; this.timer = attrs.timeout || {setTimeout: setTimeout, clearTimeout: clearTimeout}; } QueueRunner.prototype.execute = function() { this.run(this.fns, 0); }; QueueRunner.prototype.run = function(fns, recursiveIndex) { var length = fns.length, self = this, iterativeIndex; for(iterativeIndex = recursiveIndex; iterativeIndex < length; iterativeIndex++) { var fn = fns[iterativeIndex]; if (fn.length > 0) { return attemptAsync(fn); } else { attemptSync(fn); } } var runnerDone = iterativeIndex >= length; if (runnerDone) { this.clearStack(this.onComplete); } function attemptSync(fn) { try { fn.call(self.userContext); } catch (e) { handleException(e); } } function attemptAsync(fn) { var clearTimeout = function () { Function.prototype.apply.apply(self.timer.clearTimeout, [j$.getGlobal(), [timeoutId]]); }, next = once(function () { clearTimeout(timeoutId); self.run(fns, iterativeIndex + 1); }), timeoutId; if (self.enforceTimeout()) { timeoutId = Function.prototype.apply.apply(self.timer.setTimeout, [j$.getGlobal(), [function() { self.onException(new Error('Timeout - Async callback was not invoked within timeout specified by jasmine.DEFAULT_TIMEOUT_INTERVAL.')); next(); }, j$.DEFAULT_TIMEOUT_INTERVAL]]); } try { fn.call(self.userContext, next); } catch (e) { handleException(e); next(); } } function handleException(e) { self.onException(e); if (!self.catchException(e)) { //TODO: set a var when we catch an exception and //use a finally block to close the loop in a nice way.. throw e; } } }; return QueueRunner; }; getJasmineRequireObj().ReportDispatcher = function() { function ReportDispatcher(methods) { var dispatchedMethods = methods || []; for (var i = 0; i < dispatchedMethods.length; i++) { var method = dispatchedMethods[i]; this[method] = (function(m) { return function() { dispatch(m, arguments); }; }(method)); } var reporters = []; this.addReporter = function(reporter) { reporters.push(reporter); }; return this; function dispatch(method, args) { for (var i = 0; i < reporters.length; i++) { var reporter = reporters[i]; if (reporter[method]) { reporter[method].apply(reporter, args); } } } } return ReportDispatcher; }; getJasmineRequireObj().SpyStrategy = function() { function SpyStrategy(options) { options = options || {}; var identity = options.name || 'unknown', originalFn = options.fn || function() {}, getSpy = options.getSpy || function() {}, plan = function() {}; this.identity = function() { return identity; }; this.exec = function() { return plan.apply(this, arguments); }; this.callThrough = function() { plan = originalFn; return getSpy(); }; this.returnValue = function(value) { plan = function() { return value; }; return getSpy(); }; this.throwError = function(something) { var error = (something instanceof Error) ? something : new Error(something); plan = function() { throw error; }; return getSpy(); }; this.callFake = function(fn) { plan = fn; return getSpy(); }; this.stub = function(fn) { plan = function() {}; return getSpy(); }; } return SpyStrategy; }; getJasmineRequireObj().Suite = function() { function Suite(attrs) { this.env = attrs.env; this.id = attrs.id; this.parentSuite = attrs.parentSuite; this.description = attrs.description; this.onStart = attrs.onStart || function() {}; this.resultCallback = attrs.resultCallback || function() {}; this.clearStack = attrs.clearStack || function(fn) {fn();}; this.beforeFns = []; this.afterFns = []; this.queueRunner = attrs.queueRunner || function() {}; this.disabled = false; this.children = []; this.result = { id: this.id, status: this.disabled ? 'disabled' : '', description: this.description, fullName: this.getFullName() }; } Suite.prototype.getFullName = function() { var fullName = this.description; for (var parentSuite = this.parentSuite; parentSuite; parentSuite = parentSuite.parentSuite) { if (parentSuite.parentSuite) { fullName = parentSuite.description + ' ' + fullName; } } return fullName; }; Suite.prototype.disable = function() { this.disabled = true; this.result.status = 'disabled'; }; Suite.prototype.beforeEach = function(fn) { this.beforeFns.unshift(fn); }; Suite.prototype.afterEach = function(fn) { this.afterFns.unshift(fn); }; Suite.prototype.addChild = function(child) { this.children.push(child); }; Suite.prototype.execute = function(onComplete) { var self = this; this.onStart(this); if (this.disabled) { complete(); return; } var allFns = []; for (var i = 0; i < this.children.length; i++) { allFns.push(wrapChildAsAsync(this.children[i])); } this.queueRunner({ fns: allFns, onComplete: complete }); function complete() { self.resultCallback(self.result); if (onComplete) { onComplete(); } } function wrapChildAsAsync(child) { return function(done) { child.execute(done); }; } }; return Suite; }; if (typeof window == void 0 && typeof exports == 'object') { exports.Suite = jasmineRequire.Suite; } getJasmineRequireObj().Timer = function() { var defaultNow = (function(Date) { return function() { return new Date().getTime(); }; })(Date); function Timer(options) { options = options || {}; var now = options.now || defaultNow, startTime; this.start = function() { startTime = now(); }; this.elapsed = function() { return now() - startTime; }; } return Timer; }; getJasmineRequireObj().matchersUtil = function(j$) { // TODO: what to do about jasmine.pp not being inject? move to JSON.stringify? gut PrettyPrinter? return { equals: function(a, b, customTesters) { customTesters = customTesters || []; return eq(a, b, [], [], customTesters); }, contains: function(haystack, needle, customTesters) { customTesters = customTesters || []; if (Object.prototype.toString.apply(haystack) === '[object Array]') { for (var i = 0; i < haystack.length; i++) { if (eq(haystack[i], needle, [], [], customTesters)) { return true; } } return false; } return !!haystack && haystack.indexOf(needle) >= 0; }, buildFailureMessage: function() { var args = Array.prototype.slice.call(arguments, 0), matcherName = args[0], isNot = args[1], actual = args[2], expected = args.slice(3), englishyPredicate = matcherName.replace(/[A-Z]/g, function(s) { return ' ' + s.toLowerCase(); }); var message = 'Expected ' + j$.pp(actual) + (isNot ? ' not ' : ' ') + englishyPredicate; if (expected.length > 0) { for (var i = 0; i < expected.length; i++) { if (i > 0) { message += ','; } message += ' ' + j$.pp(expected[i]); } } return message + '.'; } }; // Equality function lovingly adapted from isEqual in // [Underscore](http://underscorejs.org) function eq(a, b, aStack, bStack, customTesters) { var result = true; for (var i = 0; i < customTesters.length; i++) { var customTesterResult = customTesters[i](a, b); if (!j$.util.isUndefined(customTesterResult)) { return customTesterResult; } } if (a instanceof j$.Any) { result = a.jasmineMatches(b); if (result) { return true; } } if (b instanceof j$.Any) { result = b.jasmineMatches(a); if (result) { return true; } } if (b instanceof j$.ObjectContaining) { result = b.jasmineMatches(a); if (result) { return true; } } if (a instanceof Error && b instanceof Error) { return a.message == b.message; } // Identical objects are equal. `0 === -0`, but they aren't identical. // See the [Harmony `egal` proposal](http://wiki.ecmascript.org/doku.php?id=harmony:egal). if (a === b) { return a !== 0 || 1 / a == 1 / b; } // A strict comparison is necessary because `null == undefined`. if (a === null || b === null) { return a === b; } var className = Object.prototype.toString.call(a); if (className != Object.prototype.toString.call(b)) { return false; } switch (className) { // Strings, numbers, dates, and booleans are compared by value. case '[object String]': // Primitives and their corresponding object wrappers are equivalent; thus, `"5"` is // equivalent to `new String("5")`. return a == String(b); case '[object Number]': // `NaN`s are equivalent, but non-reflexive. An `egal` comparison is performed for // other numeric values. return a != +a ? b != +b : (a === 0 ? 1 / a == 1 / b : a == +b); case '[object Date]': case '[object Boolean]': // Coerce dates and booleans to numeric primitive values. Dates are compared by their // millisecond representations. Note that invalid dates with millisecond representations // of `NaN` are not equivalent. return +a == +b; // RegExps are compared by their source patterns and flags. case '[object RegExp]': return a.source == b.source && a.global == b.global && a.multiline == b.multiline && a.ignoreCase == b.ignoreCase; } if (typeof a != 'object' || typeof b != 'object') { return false; } // Assume equality for cyclic structures. The algorithm for detecting cyclic // structures is adapted from ES 5.1 section 15.12.3, abstract operation `JO`. var length = aStack.length; while (length--) { // Linear search. Performance is inversely proportional to the number of // unique nested structures. if (aStack[length] == a) { return bStack[length] == b; } } // Add the first object to the stack of traversed objects. aStack.push(a); bStack.push(b); var size = 0; // Recursively compare objects and arrays. if (className == '[object Array]') { // Compare array lengths to determine if a deep comparison is necessary. size = a.length; result = size == b.length; if (result) { // Deep compare the contents, ignoring non-numeric properties. while (size--) { if (!(result = eq(a[size], b[size], aStack, bStack, customTesters))) { break; } } } } else { // Objects with different constructors are not equivalent, but `Object`s // from different frames are. var aCtor = a.constructor, bCtor = b.constructor; if (aCtor !== bCtor && !(isFunction(aCtor) && (aCtor instanceof aCtor) && isFunction(bCtor) && (bCtor instanceof bCtor))) { return false; } // Deep compare objects. for (var key in a) { if (has(a, key)) { // Count the expected number of properties. size++; // Deep compare each member. if (!(result = has(b, key) && eq(a[key], b[key], aStack, bStack, customTesters))) { break; } } } // Ensure that both objects contain the same number of properties. if (result) { for (key in b) { if (has(b, key) && !(size--)) { break; } } result = !size; } } // Remove the first object from the stack of traversed objects. aStack.pop(); bStack.pop(); return result; function has(obj, key) { return obj.hasOwnProperty(key); } function isFunction(obj) { return typeof obj === 'function'; } } }; getJasmineRequireObj().toBe = function() { function toBe() { return { compare: function(actual, expected) { return { pass: actual === expected }; } }; } return toBe; }; getJasmineRequireObj().toBeCloseTo = function() { function toBeCloseTo() { return { compare: function(actual, expected, precision) { if (precision !== 0) { precision = precision || 2; } return { pass: Math.abs(expected - actual) < (Math.pow(10, -precision) / 2) }; } }; } return toBeCloseTo; }; getJasmineRequireObj().toBeDefined = function() { function toBeDefined() { return { compare: function(actual) { return { pass: (void 0 !== actual) }; } }; } return toBeDefined; }; getJasmineRequireObj().toBeFalsy = function() { function toBeFalsy() { return { compare: function(actual) { return { pass: !!!actual }; } }; } return toBeFalsy; }; getJasmineRequireObj().toBeGreaterThan = function() { function toBeGreaterThan() { return { compare: function(actual, expected) { return { pass: actual > expected }; } }; } return toBeGreaterThan; }; getJasmineRequireObj().toBeLessThan = function() { function toBeLessThan() { return { compare: function(actual, expected) { return { pass: actual < expected }; } }; } return toBeLessThan; }; getJasmineRequireObj().toBeNaN = function(j$) { function toBeNaN() { return { compare: function(actual) { var result = { pass: (actual !== actual) }; if (result.pass) { result.message = 'Expected actual not to be NaN.'; } else { result.message = function() { return 'Expected ' + j$.pp(actual) + ' to be NaN.'; }; } return result; } }; } return toBeNaN; }; getJasmineRequireObj().toBeNull = function() { function toBeNull() { return { compare: function(actual) { return { pass: actual === null }; } }; } return toBeNull; }; getJasmineRequireObj().toBeTruthy = function() { function toBeTruthy() { return { compare: function(actual) { return { pass: !!actual }; } }; } return toBeTruthy; }; getJasmineRequireObj().toBeUndefined = function() { function toBeUndefined() { return { compare: function(actual) { return { pass: void 0 === actual }; } }; } return toBeUndefined; }; getJasmineRequireObj().toContain = function() { function toContain(util, customEqualityTesters) { customEqualityTesters = customEqualityTesters || []; return { compare: function(actual, expected) { return { pass: util.contains(actual, expected, customEqualityTesters) }; } }; } return toContain; }; getJasmineRequireObj().toEqual = function() { function toEqual(util, customEqualityTesters) { customEqualityTesters = customEqualityTesters || []; return { compare: function(actual, expected) { var result = { pass: false }; result.pass = util.equals(actual, expected, customEqualityTesters); return result; } }; } return toEqual; }; getJasmineRequireObj().toHaveBeenCalled = function(j$) { function toHaveBeenCalled() { return { compare: function(actual) { var result = {}; if (!j$.isSpy(actual)) { throw new Error('Expected a spy, but got ' + j$.pp(actual) + '.'); } if (arguments.length > 1) { throw new Error('toHaveBeenCalled does not take arguments, use toHaveBeenCalledWith'); } result.pass = actual.calls.any(); result.message = result.pass ? 'Expected spy ' + actual.and.identity() + ' not to have been called.' : 'Expected spy ' + actual.and.identity() + ' to have been called.'; return result; } }; } return toHaveBeenCalled; }; getJasmineRequireObj().toHaveBeenCalledWith = function(j$) { function toHaveBeenCalledWith(util, customEqualityTesters) { return { compare: function() { var args = Array.prototype.slice.call(arguments, 0), actual = args[0], expectedArgs = args.slice(1), result = { pass: false }; if (!j$.isSpy(actual)) { throw new Error('Expected a spy, but got ' + j$.pp(actual) + '.'); } if (!actual.calls.any()) { result.message = function() { return 'Expected spy ' + actual.and.identity() + ' to have been called with ' + j$.pp(expectedArgs) + ' but it was never called.'; }; return result; } if (util.contains(actual.calls.allArgs(), expectedArgs, customEqualityTesters)) { result.pass = true; result.message = function() { return 'Expected spy ' + actual.and.identity() + ' not to have been called with ' + j$.pp(expectedArgs) + ' but it was.'; }; } else { result.message = function() { return 'Expected spy ' + actual.and.identity() + ' to have been called with ' + j$.pp(expectedArgs) + ' but actual calls were ' + j$.pp(actual.calls.allArgs()).replace(/^\[ | \]$/g, '') + '.'; }; } return result; } }; } return toHaveBeenCalledWith; }; getJasmineRequireObj().toMatch = function() { function toMatch() { return { compare: function(actual, expected) { var regexp = new RegExp(expected); return { pass: regexp.test(actual) }; } }; } return toMatch; }; getJasmineRequireObj().toThrow = function(j$) { function toThrow(util) { return { compare: function(actual, expected) { var result = { pass: false }, threw = false, thrown; if (typeof actual != 'function') { throw new Error('Actual is not a Function'); } try { actual(); } catch (e) { threw = true; thrown = e; } if (!threw) { result.message = 'Expected function to throw an exception.'; return result; } if (arguments.length == 1) { result.pass = true; result.message = function() { return 'Expected function not to throw, but it threw ' + j$.pp(thrown) + '.'; }; return result; } if (util.equals(thrown, expected)) { result.pass = true; result.message = function() { return 'Expected function not to throw ' + j$.pp(expected) + '.'; }; } else { result.message = function() { return 'Expected function to throw ' + j$.pp(expected) + ', but it threw ' + j$.pp(thrown) + '.'; }; } return result; } }; } return toThrow; }; getJasmineRequireObj().toThrowError = function(j$) { function toThrowError (util) { return { compare: function(actual) { var threw = false, pass = {pass: true}, fail = {pass: false}, thrown, errorType, message, regexp, name, constructorName; if (typeof actual != 'function') { throw new Error('Actual is not a Function'); } extractExpectedParams.apply(null, arguments); try { actual(); } catch (e) { threw = true; thrown = e; } if (!threw) { fail.message = 'Expected function to throw an Error.'; return fail; } if (!(thrown instanceof Error)) { fail.message = function() { return 'Expected function to throw an Error, but it threw ' + j$.pp(thrown) + '.'; }; return fail; } if (arguments.length == 1) { pass.message = 'Expected function not to throw an Error, but it threw ' + fnNameFor(thrown) + '.'; return pass; } if (errorType) { name = fnNameFor(errorType); constructorName = fnNameFor(thrown.constructor); } if (errorType && message) { if (thrown.constructor == errorType && util.equals(thrown.message, message)) { pass.message = function() { return 'Expected function not to throw ' + name + ' with message ' + j$.pp(message) + '.'; }; return pass; } else { fail.message = function() { return 'Expected function to throw ' + name + ' with message ' + j$.pp(message) + ', but it threw ' + constructorName + ' with message ' + j$.pp(thrown.message) + '.'; }; return fail; } } if (errorType && regexp) { if (thrown.constructor == errorType && regexp.test(thrown.message)) { pass.message = function() { return 'Expected function not to throw ' + name + ' with message matching ' + j$.pp(regexp) + '.'; }; return pass; } else { fail.message = function() { return 'Expected function to throw ' + name + ' with message matching ' + j$.pp(regexp) + ', but it threw ' + constructorName + ' with message ' + j$.pp(thrown.message) + '.'; }; return fail; } } if (errorType) { if (thrown.constructor == errorType) { pass.message = 'Expected function not to throw ' + name + '.'; return pass; } else { fail.message = 'Expected function to throw ' + name + ', but it threw ' + constructorName + '.'; return fail; } } if (message) { if (thrown.message == message) { pass.message = function() { return 'Expected function not to throw an exception with message ' + j$.pp(message) + '.'; }; return pass; } else { fail.message = function() { return 'Expected function to throw an exception with message ' + j$.pp(message) + ', but it threw an exception with message ' + j$.pp(thrown.message) + '.'; }; return fail; } } if (regexp) { if (regexp.test(thrown.message)) { pass.message = function() { return 'Expected function not to throw an exception with a message matching ' + j$.pp(regexp) + '.'; }; return pass; } else { fail.message = function() { return 'Expected function to throw an exception with a message matching ' + j$.pp(regexp) + ', but it threw an exception with message ' + j$.pp(thrown.message) + '.'; }; return fail; } } function fnNameFor(func) { return func.name || func.toString().match(/^\s*function\s*(\w*)\s*\(/)[1]; } function extractExpectedParams() { if (arguments.length == 1) { return; } if (arguments.length == 2) { var expected = arguments[1]; if (expected instanceof RegExp) { regexp = expected; } else if (typeof expected == 'string') { message = expected; } else if (checkForAnErrorType(expected)) { errorType = expected; } if (!(errorType || message || regexp)) { throw new Error('Expected is not an Error, string, or RegExp.'); } } else { if (checkForAnErrorType(arguments[1])) { errorType = arguments[1]; } else { throw new Error('Expected error type is not an Error.'); } if (arguments[2] instanceof RegExp) { regexp = arguments[2]; } else if (typeof arguments[2] == 'string') { message = arguments[2]; } else { throw new Error('Expected error message is not a string or RegExp.'); } } } function checkForAnErrorType(type) { if (typeof type !== 'function') { return false; } var Surrogate = function() {}; Surrogate.prototype = type.prototype; return (new Surrogate()) instanceof Error; } } }; } return toThrowError; }; getJasmineRequireObj().interface = function(jasmine, env) { var jasmineInterface = { describe: function(description, specDefinitions) { return env.describe(description, specDefinitions); }, xdescribe: function(description, specDefinitions) { return env.xdescribe(description, specDefinitions); }, it: function(desc, func) { return env.it(desc, func); }, xit: function(desc, func) { return env.xit(desc, func); }, beforeEach: function(beforeEachFunction) { return env.beforeEach(beforeEachFunction); }, afterEach: function(afterEachFunction) { return env.afterEach(afterEachFunction); }, expect: function(actual) { return env.expect(actual); }, pending: function() { return env.pending(); }, spyOn: function(obj, methodName) { return env.spyOn(obj, methodName); }, jsApiReporter: new jasmine.JsApiReporter({ timer: new jasmine.Timer() }), jasmine: jasmine }; jasmine.addCustomEqualityTester = function(tester) { env.addCustomEqualityTester(tester); }; jasmine.addMatchers = function(matchers) { return env.addMatchers(matchers); }; jasmine.clock = function() { return env.clock; }; return jasmineInterface; }; getJasmineRequireObj().version = function() { return '2.0.3'; }; ================================================ FILE: specs/jasmine-2.0.3/specrunner.tmpl ================================================ Jasmine Spec Runner <% css.forEach(function(style){ %> <% }) %> <% with (scripts) { %> <% [].concat(jasmine, boot, vendor, helpers, src, specs,reporters).forEach(function(script){ %> <% }) %> <% }; %> ================================================ FILE: src/core/core-prototypes.js ================================================ (function () { var $D = Date, $P = $D.prototype, p = function (s, l) { if (!l) { l = 2; } return ("000" + s).slice(l * -1); }; var validateConfigObject = function (obj) { var result = {}, self = this, prop, testFunc; testFunc = function (prop, func, value) { if (prop === "day") { var month = (obj.month !== undefined) ? obj.month : self.getMonth(); var year = (obj.year !== undefined) ? obj.year : self.getFullYear(); return $D[func](value, year, month); } else { return $D[func](value); } }; for (prop in obj) { if (Object.prototype.hasOwnProperty.call(obj, prop)) { var func = "validate" + prop.charAt(0).toUpperCase() + prop.slice(1); if ($D[func] && obj[prop] !== null && testFunc(prop, func, obj[prop])) { result[prop] = obj[prop]; } } } return result; }; /** * Resets the time of this Date object to 12:00 AM (00:00), which is the start of the day. * @param {Boolean} .clone() this date instance before clearing Time * @return {Date} this */ $P.clearTime = function () { this.setHours(0); this.setMinutes(0); this.setSeconds(0); this.setMilliseconds(0); return this; }; /** * Resets the time of this Date object to the current time ('now'). * @return {Date} this */ $P.setTimeToNow = function () { var n = new Date(); this.setHours(n.getHours()); this.setMinutes(n.getMinutes()); this.setSeconds(n.getSeconds()); this.setMilliseconds(n.getMilliseconds()); return this; }; /** * Returns a new Date object that is an exact date and time copy of the original instance. * @return {Date} A new Date instance */ $P.clone = function () { return new Date(this.getTime()); }; /** * Compares this instance to a Date object and returns an number indication of their relative values. * @param {Date} Date object to compare [Required] * @return {Number} -1 = this is lessthan date. 0 = values are equal. 1 = this is greaterthan date. */ $P.compareTo = function (date) { return Date.compare(this, date); }; /** * Compares this instance to another Date object and returns true if they are equal. * @param {Date} Date object to compare. If no date to compare, new Date() [now] is used. * @return {Boolean} true if dates are equal. false if they are not equal. */ $P.equals = function (date) { return Date.equals(this, (date !== undefined ? date : new Date())); }; /** * Determines if this instance is between a range of two dates or equal to either the start or end dates. * @param {Date} Start of range [Required] * @param {Date} End of range [Required] * @return {Boolean} true is this is between or equal to the start and end dates, else false */ $P.between = function (start, end) { return this.getTime() >= start.getTime() && this.getTime() <= end.getTime(); }; /** * Determines if this date occurs after the date to compare to. * @param {Date} Date object to compare. If no date to compare, new Date() ("now") is used. * @return {Boolean} true if this date instance is greater than the date to compare to (or "now"), otherwise false. */ $P.isAfter = function (date) { return this.compareTo(date || new Date()) === 1; }; /** * Determines if this date occurs before the date to compare to. * @param {Date} Date object to compare. If no date to compare, new Date() ("now") is used. * @return {Boolean} true if this date instance is less than the date to compare to (or "now"). */ $P.isBefore = function (date) { return (this.compareTo(date || new Date()) === -1); }; /** * Determines if the current Date instance occurs today. * @return {Boolean} true if this date instance is 'today', otherwise false. */ /** * Determines if the current Date instance occurs on the same Date as the supplied 'date'. * If no 'date' to compare to is provided, the current Date instance is compared to 'today'. * @param {date} Date object to compare. If no date to compare, the current Date ("now") is used. * @return {Boolean} true if this Date instance occurs on the same Day as the supplied 'date'. */ $P.isToday = $P.isSameDay = function (date) { return this.clone().clearTime().equals((date || new Date()).clone().clearTime()); }; /** * Adds the specified number of milliseconds to this instance. * @param {Number} The number of milliseconds to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addMilliseconds = function (value) { if (!value) { return this; } this.setTime(this.getTime() + value * 1); return this; }; /** * Adds the specified number of seconds to this instance. * @param {Number} The number of seconds to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addSeconds = function (value) { if (!value) { return this; } return this.addMilliseconds(value * 1000); }; /** * Adds the specified number of seconds to this instance. * @param {Number} The number of seconds to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addMinutes = function (value) { if (!value) { return this; } return this.addMilliseconds(value * 60000); // 60*1000 }; /** * Adds the specified number of hours to this instance. * @param {Number} The number of hours to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addHours = function (value) { if (!value) { return this; } return this.addMilliseconds(value * 3600000); // 60*60*1000 }; /** * Adds the specified number of days to this instance. * @param {Number} The number of days to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addDays = function (value) { if (!value) { return this; } this.setDate(this.getDate() + value * 1); return this; }; /** * Adds the specified number of weekdays (ie - not sat or sun) to this instance. * @param {Number} The number of days to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addWeekdays = function (value) { if (!value) { return this; } var day = this.getDay(); var weeks = (Math.ceil(Math.abs(value)/7)); if (day === 0 || day === 6) { if (value > 0) { this.next().monday(); this.addDays(-1); day = this.getDay(); } } if (value < 0) { while (value < 0) { this.addDays(-1); day = this.getDay(); if (day !== 0 && day !== 6) { value++; } } return this; } else if (value > 5 || (6-day) <= value) { value = value + (weeks * 2); } return this.addDays(value); }; /** * Adds the specified number of weeks to this instance. * @param {Number} The number of weeks to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addWeeks = function (value) { if (!value) { return this; } return this.addDays(value * 7); }; /** * Adds the specified number of months to this instance. * @param {Number} The number of months to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addMonths = function (value) { if (!value) { return this; } var n = this.getDate(); this.setDate(1); this.setMonth(this.getMonth() + value * 1); this.setDate(Math.min(n, $D.getDaysInMonth(this.getFullYear(), this.getMonth()))); return this; }; $P.addQuarters = function (value) { if (!value) { return this; } // note this will take you to the same point in the quarter as you are now. // i.e. - if you are 15 days into the quarter you'll be 15 days into the resulting one. // bonus: this allows adding fractional quarters return this.addMonths(value * 3); }; /** * Adds the specified number of years to this instance. * @param {Number} The number of years to add. The number can be positive or negative [Required] * @return {Date} this */ $P.addYears = function (value) { if (!value) { return this; } return this.addMonths(value * 12); }; /** * Adds (or subtracts) to the value of the years, months, weeks, days, hours, minutes, seconds, milliseconds of the date instance using given configuration object. Positive and Negative values allowed. * Example

	Date.today().add( { days: 1, months: 1 } )

	new Date().add( { years: -1 } )
	
* @param {Object} Configuration object containing attributes (months, days, etc.) * @return {Date} this */ $P.add = function (config) { if (typeof config === "number") { this._orient = config; return this; } var x = config; if (x.day) { // If we should be a different date than today (eg: for 'tomorrow -1d', etc). // Should only effect parsing, not direct usage (eg, Finish and FinishExact) if ((x.day - this.getDate()) !== 0) { this.setDate(x.day); } } if (x.milliseconds) { this.addMilliseconds(x.milliseconds); } if (x.seconds) { this.addSeconds(x.seconds); } if (x.minutes) { this.addMinutes(x.minutes); } if (x.hours) { this.addHours(x.hours); } if (x.weeks) { this.addWeeks(x.weeks); } if (x.months) { this.addMonths(x.months); } if (x.years) { this.addYears(x.years); } if (x.days) { this.addDays(x.days); } return this; }; /** * Get the week number. Week one (1) is the week which contains the first Thursday of the year. Monday is considered the first day of the week. * The .getWeek() function does NOT convert the date to UTC. The local datetime is used. * Please use .getISOWeek() to get the week of the UTC converted date. * @return {Number} 1 to 53 */ $P.getWeek = function (utc) { // Create a copy of this date object var self, target = new Date(this.valueOf()); if (utc) { target.addMinutes(target.getTimezoneOffset()); self = target.clone(); } else { self = this; } // ISO week date weeks start on monday // so correct the day number var dayNr = (self.getDay() + 6) % 7; // ISO 8601 states that week 1 is the week // with the first thursday of that year. // Set the target date to the thursday in the target week target.setDate(target.getDate() - dayNr + 3); // Store the millisecond value of the target date var firstThursday = target.valueOf(); // Set the target to the first thursday of the year // First set the target to january first target.setMonth(0, 1); // Not a thursday? Correct the date to the next thursday if (target.getDay() !== 4) { target.setMonth(0, 1 + ((4 - target.getDay()) + 7) % 7); } // The weeknumber is the number of weeks between the // first thursday of the year and the thursday in the target week return 1 + Math.ceil((firstThursday - target) / 604800000); // 604800000 = 7 * 24 * 3600 * 1000 }; /** * Get the ISO 8601 week number. Week one ("01") is the week which contains the first Thursday of the year. Monday is considered the first day of the week. * The .getISOWeek() function does convert the date to it's UTC value. Please use .getWeek() to get the week of the local date. * @return {String} "01" to "53" */ $P.getISOWeek = function () { return p(this.getWeek(true)); }; /** * Moves the date to Monday of the week set. Week one (1) is the week which contains the first Thursday of the year. * @param {Number} A Number (1 to 53) that represents the week of the year. * @return {Date} this */ $P.setWeek = function (n) { if ((n - this.getWeek()) === 0) { if (this.getDay() !== 1) { return this.moveToDayOfWeek(1, (this.getDay() > 1 ? -1 : 1)); } else { return this; } } else { return this.moveToDayOfWeek(1, (this.getDay() > 1 ? -1 : 1)).addWeeks(n - this.getWeek()); } }; $P.setQuarter = function (qtr) { var month = Math.abs(((qtr-1) * 3) + 1); return this.setMonth(month, 1); }; $P.getQuarter = function () { return Date.getQuarter(this); }; $P.getDaysLeftInQuarter = function () { return Date.getDaysLeftInQuarter(this); }; /** * Moves the date to the next n'th occurrence of the dayOfWeek starting from the beginning of the month. The number (-1) is a magic number and will return the last occurrence of the dayOfWeek in the month. * @param {Number} The dayOfWeek to move to * @param {Number} The n'th occurrence to move to. Use (-1) to return the last occurrence in the month * @return {Date} this */ $P.moveToNthOccurrence = function (dayOfWeek, occurrence) { if (dayOfWeek === "Weekday") { if (occurrence > 0) { this.moveToFirstDayOfMonth(); if (this.is().weekday()) { occurrence -= 1; } } else if (occurrence < 0) { this.moveToLastDayOfMonth(); if (this.is().weekday()) { occurrence += 1; } } else { return this; } return this.addWeekdays(occurrence); } var shift = 0; if (occurrence > 0) { shift = occurrence - 1; } else if (occurrence === -1) { this.moveToLastDayOfMonth(); if (this.getDay() !== dayOfWeek) { this.moveToDayOfWeek(dayOfWeek, -1); } return this; } return this.moveToFirstDayOfMonth().addDays(-1).moveToDayOfWeek(dayOfWeek, +1).addWeeks(shift); }; var moveToN = function (getFunc, addFunc, nVal) { return function (value, orient) { var diff = (value - this[getFunc]() + nVal * (orient || +1)) % nVal; return this[addFunc]((diff === 0) ? diff += nVal * (orient || +1) : diff); }; }; /** * Move to the next or last dayOfWeek based on the orient value. * @param {Number} The dayOfWeek to move to * @param {Number} Forward (+1) or Back (-1). Defaults to +1. [Optional] * @return {Date} this */ $P.moveToDayOfWeek = moveToN("getDay", "addDays", 7); /** * Move to the next or last month based on the orient value. * @param {Number} The month to move to. 0 = January, 11 = December * @param {Number} Forward (+1) or Back (-1). Defaults to +1. [Optional] * @return {Date} this */ $P.moveToMonth = moveToN("getMonth", "addMonths", 12); /** * Get the Ordinate of the current day ("th", "st", "rd"). * @return {String} */ $P.getOrdinate = function () { var num = this.getDate(); return ord(num); }; /** * Get the Ordinal day (numeric day number) of the year, adjusted for leap year. * @return {Number} 1 through 365 (366 in leap years) */ $P.getOrdinalNumber = function () { return Math.ceil((this.clone().clearTime() - new Date(this.getFullYear(), 0, 1)) / 86400000) + 1; }; /** * Get the time zone abbreviation of the current date. * @return {String} The abbreviated time zone name (e.g. "EST") */ $P.getTimezone = function () { return $D.getTimezoneAbbreviation(this.getUTCOffset(), this.isDaylightSavingTime()); }; $P.setTimezoneOffset = function (offset) { var here = this.getTimezoneOffset(), there = Number(offset) * -6 / 10; return (there || there === 0) ? this.addMinutes(here - there) : this; }; $P.setTimezone = function (offset) { return this.setTimezoneOffset($D.getTimezoneOffset(offset)); }; /** * Indicates whether Daylight Saving Time is observed in the current time zone. * @return {Boolean} true|false */ $P.hasDaylightSavingTime = function () { return (Date.today().set({month: 0, day: 1}).getTimezoneOffset() !== Date.today().set({month: 6, day: 1}).getTimezoneOffset()); }; /** * Indicates whether this Date instance is within the Daylight Saving Time range for the current time zone. * @return {Boolean} true|false */ $P.isDaylightSavingTime = function () { return Date.today().set({month: 0, day: 1}).getTimezoneOffset() !== this.getTimezoneOffset(); }; /** * Get the offset from UTC of the current date. * @return {String} The 4-character offset string prefixed with + or - (e.g. "-0500") */ $P.getUTCOffset = function (offset) { var n = (offset || this.getTimezoneOffset()) * -10 / 6, r; if (n < 0) { r = (n - 10000).toString(); return r.charAt(0) + r.substr(2); } else { r = (n + 10000).toString(); return "+" + r.substr(1); } }; /** * Returns the number of milliseconds between this date and date. * @param {Date} Defaults to now * @return {Number} The diff in milliseconds */ $P.getElapsed = function (date) { return (date || new Date()) - this; }; /** * Set the value of year, month, day, hour, minute, second, millisecond of date instance using given configuration object. * Example

	Date.today().set( { day: 20, month: 1 } )

	new Date().set( { millisecond: 0 } )
	
* * @param {Object} Configuration object containing attributes (month, day, etc.) * @return {Date} this */ $P.set = function (config) { config = validateConfigObject.call(this, config); var key; for (key in config) { if (Object.prototype.hasOwnProperty.call(config, key)) { var name = key.charAt(0).toUpperCase() + key.slice(1); var addFunc, getFunc; if (key !== "week" && key !== "month" && key !== "timezone" && key !== "timezoneOffset") { name += "s"; } addFunc = "add" + name; getFunc = "get" + name; if (key === "month") { addFunc = addFunc + "s"; } else if (key === "year"){ getFunc = "getFullYear"; } if (key !== "day" && key !== "timezone" && key !== "timezoneOffset" && key !== "week" && key !== "hour") { this[addFunc](config[key] - this[getFunc]()); } else if ( key === "timezone"|| key === "timezoneOffset" || key === "week" || key === "hour") { this["set"+name](config[key]); } } } // day has to go last because you can't validate the day without first knowing the month if (config.day) { this.addDays(config.day - this.getDate()); } return this; }; /** * Moves the date to the first day of the month. * @return {Date} this */ $P.moveToFirstDayOfMonth = function () { return this.set({ day: 1 }); }; /** * Moves the date to the last day of the month. * @return {Date} this */ $P.moveToLastDayOfMonth = function () { return this.set({ day: $D.getDaysInMonth(this.getFullYear(), this.getMonth())}); }; /** * Converts the value of the current Date object to its equivalent string representation. * Format Specifiers * CUSTOM DATE AND TIME FORMAT STRINGS * Format Description Example * ------ --------------------------------------------------------------------------- ----------------------- * s The seconds of the minute between 0-59. "0" to "59" * ss The seconds of the minute with leading zero if required. "00" to "59" * * m The minute of the hour between 0-59. "0" or "59" * mm The minute of the hour with leading zero if required. "00" or "59" * * h The hour of the day between 1-12. "1" to "12" * hh The hour of the day with leading zero if required. "01" to "12" * * H The hour of the day between 0-23. "0" to "23" * HH The hour of the day with leading zero if required. "00" to "23" * * d The day of the month between 1 and 31. "1" to "31" * dd The day of the month with leading zero if required. "01" to "31" * ddd Abbreviated day name. Date.CultureInfo.abbreviatedDayNames. "Mon" to "Sun" * dddd The full day name. Date.CultureInfo.dayNames. "Monday" to "Sunday" * * M The month of the year between 1-12. "1" to "12" * MM The month of the year with leading zero if required. "01" to "12" * MMM Abbreviated month name. Date.CultureInfo.abbreviatedMonthNames. "Jan" to "Dec" * MMMM The full month name. Date.CultureInfo.monthNames. "January" to "December" * * yy The year as a two-digit number. "99" or "08" * yyyy The full four digit year. "1999" or "2008" * * t Displays the first character of the A.M./P.M. designator. "A" or "P" * Date.CultureInfo.amDesignator or Date.CultureInfo.pmDesignator * tt Displays the A.M./P.M. designator. "AM" or "PM" * Date.CultureInfo.amDesignator or Date.CultureInfo.pmDesignator * * S The ordinal suffix ("st, "nd", "rd" or "th") of the current day. "st, "nd", "rd" or "th" * * STANDARD DATE AND TIME FORMAT STRINGS * Format Description Example *------ --------------------------------------------------------------------------- ----------------------- * d The CultureInfo shortDate Format Pattern "M/d/yyyy" * D The CultureInfo longDate Format Pattern "dddd, MMMM dd, yyyy" * F The CultureInfo fullDateTime Format Pattern "dddd, MMMM dd, yyyy h:mm:ss tt" * m The CultureInfo monthDay Format Pattern "MMMM dd" * r The CultureInfo rfc1123 Format Pattern "ddd, dd MMM yyyy HH:mm:ss GMT" * s The CultureInfo sortableDateTime Format Pattern "yyyy-MM-ddTHH:mm:ss" * t The CultureInfo shortTime Format Pattern "h:mm tt" * T The CultureInfo longTime Format Pattern "h:mm:ss tt" * u The CultureInfo universalSortableDateTime Format Pattern "yyyy-MM-dd HH:mm:ssZ" * y The CultureInfo yearMonth Format Pattern "MMMM, yyyy" * * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @return {String} A string representation of the current Date object. */ var ord = function (n) { switch (n * 1) { case 1: case 21: case 31: return "st"; case 2: case 22: return "nd"; case 3: case 23: return "rd"; default: return "th"; } }; var parseStandardFormats = function (format) { var y, c = Date.CultureInfo.formatPatterns; switch (format) { case "d": return this.toString(c.shortDate); case "D": return this.toString(c.longDate); case "F": return this.toString(c.fullDateTime); case "m": return this.toString(c.monthDay); case "r": case "R": y = this.clone().addMinutes(this.getTimezoneOffset()); return y.toString(c.rfc1123) + " GMT"; case "s": return this.toString(c.sortableDateTime); case "t": return this.toString(c.shortTime); case "T": return this.toString(c.longTime); case "u": y = this.clone().addMinutes(this.getTimezoneOffset()); return y.toString(c.universalSortableDateTime); case "y": return this.toString(c.yearMonth); default: return false; } }; var parseFormatStringsClosure = function (context) { return function (m) { if (m.charAt(0) === "\\") { return m.replace("\\", ""); } switch (m) { case "hh": return p(context.getHours() < 13 ? (context.getHours() === 0 ? 12 : context.getHours()) : (context.getHours() - 12)); case "h": return context.getHours() < 13 ? (context.getHours() === 0 ? 12 : context.getHours()) : (context.getHours() - 12); case "HH": return p(context.getHours()); case "H": return context.getHours(); case "mm": return p(context.getMinutes()); case "m": return context.getMinutes(); case "ss": return p(context.getSeconds()); case "s": return context.getSeconds(); case "yyyy": return p(context.getFullYear(), 4); case "yy": return p(context.getFullYear()); case "y": return context.getFullYear(); case "E": case "dddd": return Date.CultureInfo.dayNames[context.getDay()]; case "ddd": return Date.CultureInfo.abbreviatedDayNames[context.getDay()]; case "dd": return p(context.getDate()); case "d": return context.getDate(); case "MMMM": return Date.CultureInfo.monthNames[context.getMonth()]; case "MMM": return Date.CultureInfo.abbreviatedMonthNames[context.getMonth()]; case "MM": return p((context.getMonth() + 1)); case "M": return context.getMonth() + 1; case "t": return context.getHours() < 12 ? Date.CultureInfo.amDesignator.substring(0, 1) : Date.CultureInfo.pmDesignator.substring(0, 1); case "tt": return context.getHours() < 12 ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator; case "S": return ord(context.getDate()); case "W": return context.getWeek(); case "WW": return context.getISOWeek(); case "Q": return "Q" + context.getQuarter(); case "q": return String(context.getQuarter()); case "z": return context.getTimezone(); case "Z": case "X": return Date.getTimezoneOffset(context.getTimezone()); case "ZZ": // Timezone offset in seconds return context.getTimezoneOffset() * -60; case "u": return context.getDay(); case "L": return ($D.isLeapYear(context.getFullYear())) ? 1 : 0; case "B": // Swatch Internet Time (.beats) return "@"+((context.getUTCSeconds() + (context.getUTCMinutes()*60) + ((context.getUTCHours()+1)*3600))/86.4); default: return m; } }; }; $P.toString = function (format, ignoreStandards) { // Standard Date and Time Format Strings. Formats pulled from CultureInfo file and // may vary by culture. if (!ignoreStandards && format && format.length === 1) { var output = parseStandardFormats.call(this, format); if (output) { return output; } } var parseFormatStrings = parseFormatStringsClosure(this); return format ? format.replace(/((\\)?(dd?d?d?|MM?M?M?|yy?y?y?|hh?|HH?|mm?|ss?|tt?|S|q|Q|WW?W?W?)(?![^\[]*\]))/g, parseFormatStrings).replace(/\[|\]/g, "") : this._toString(); }; }()); ================================================ FILE: src/core/core.js ================================================ (function () { var $D = Date, $P = $D.prototype, p = function (s, l) { if (!l) { l = 2; } return ("000" + s).slice(l * -1); }; if (typeof window !== "undefined" && typeof window.console !== "undefined" && typeof window.console.log !== "undefined") { $D.console = console; // used only to raise non-critical errors if available } else { // set mock so we don't give errors. $D.console = { log: function(){}, error: function(){} }; } $D.Config = $D.Config || {}; $D.initOverloads = function() { /** * Overload of Date.now. Allows an alternate call for Date.now where it returns the * current Date as an object rather than just milliseconds since the Unix Epoch. * * Also provides an implementation of now() for browsers (IE<9) that don't have it. * * Backwards compatible so with work with either: * Date.now() [returns ms] * or * Date.now(true) [returns Date] */ if (!$D.now) { $D._now = function now() { return new Date().getTime(); }; } else if (!$D._now) { $D._now = $D.now; } $D.now = function (returnObj) { if (returnObj) { return $D.present(); } else { return $D._now(); } }; if ( !$P.toISOString ) { $P.toISOString = function() { return this.getUTCFullYear() + "-" + p(this.getUTCMonth() + 1) + "-" + p(this.getUTCDate()) + "T" + p(this.getUTCHours()) + ":" + p(this.getUTCMinutes()) + ":" + p(this.getUTCSeconds()) + "." + String( (this.getUTCMilliseconds()/1000).toFixed(3)).slice(2, 5) + "Z"; }; } // private if ( $P._toString === undefined ){ $P._toString = $P.toString; } }; $D.initOverloads(); /** * Gets a date that is set to the current date. The time is set to the start of the day (00:00 or 12:00 AM). * @return {Date} The current date. */ $D.today = function () { return new Date().clearTime(); }; /** * Gets a date that is set to the current date and time (same as new Date, but chainable) * @return {Date} The current date. */ $D.present = function () { return new Date(); }; /** * Compares the first date to the second date and returns an number indication of their relative values. * @param {Date} First Date object to compare [Required]. * @param {Date} Second Date object to compare to [Required]. * @return {Number} -1 = date1 is lessthan date2. 0 = values are equal. 1 = date1 is greaterthan date2. */ $D.compare = function (date1, date2) { if (isNaN(date1) || isNaN(date2)) { throw new Error(date1 + " - " + date2); } else if (date1 instanceof Date && date2 instanceof Date) { return (date1 < date2) ? -1 : (date1 > date2) ? 1 : 0; } else { throw new TypeError(date1 + " - " + date2); } }; /** * Compares the first Date object to the second Date object and returns true if they are equal. * @param {Date} First Date object to compare [Required] * @param {Date} Second Date object to compare to [Required] * @return {Boolean} true if dates are equal. false if they are not equal. */ $D.equals = function (date1, date2) { return (date1.compareTo(date2) === 0); }; /** * Gets the language appropriate day name when given the day number(0-6) * eg - 0 == Sunday * @return {String} The day name */ $D.getDayName = function (n) { return Date.CultureInfo.dayNames[n]; }; /** * Gets the day number (0-6) if given a CultureInfo specific string which is a valid dayName, abbreviatedDayName or shortestDayName (two char). * @param {String} The name of the day (eg. "Monday, "Mon", "tuesday", "tue", "We", "we"). * @return {Number} The day number */ $D.getDayNumberFromName = function (name) { var n = Date.CultureInfo.dayNames, m = Date.CultureInfo.abbreviatedDayNames, o = Date.CultureInfo.shortestDayNames, s = name.toLowerCase(); for (var i = 0; i < n.length; i++) { if (n[i].toLowerCase() === s || m[i].toLowerCase() === s || o[i].toLowerCase() === s) { return i; } } return -1; }; /** * Gets the month number (0-11) if given a Culture Info specific string which is a valid monthName or abbreviatedMonthName. * @param {String} The name of the month (eg. "February, "Feb", "october", "oct"). * @return {Number} The day number */ $D.getMonthNumberFromName = function (name) { var n = Date.CultureInfo.monthNames, m = Date.CultureInfo.abbreviatedMonthNames, s = name.toLowerCase(); for (var i = 0; i < n.length; i++) { if (n[i].toLowerCase() === s || m[i].toLowerCase() === s) { return i; } } return -1; }; /** * Gets the language appropriate month name when given the month number(0-11) * eg - 0 == January * @return {String} The month name */ $D.getMonthName = function (n) { return Date.CultureInfo.monthNames[n]; }; /** * Determines if the current date instance is within a LeapYear. * @param {Number} The year. * @return {Boolean} true if date is within a LeapYear, otherwise false. */ $D.isLeapYear = function (year) { return ((year % 4 === 0 && year % 100 !== 0) || year % 400 === 0); }; /** * Gets the number of days in the month, given a year and month value. Automatically corrects for LeapYear. * @param {Number} The year. * @param {Number} The month (0-11). * @return {Number} The number of days in the month. */ $D.getDaysInMonth = function (year, month) { if (!month && $D.validateMonth(year)) { month = year; year = Date.today().getFullYear(); } return [31, ($D.isLeapYear(year) ? 29 : 28), 31, 30, 31, 30, 31, 31, 30, 31, 30, 31][month]; }; $P.getDaysInMonth = function () { return $D.getDaysInMonth(this.getFullYear(), this.getMonth()); }; $D.getTimezoneAbbreviation = function (offset, dst) { var p, n = (dst || false) ? Date.CultureInfo.abbreviatedTimeZoneDST : Date.CultureInfo.abbreviatedTimeZoneStandard; for (p in n) { if (n.hasOwnProperty(p)) { if (n[p] === offset) { return p; } } } return null; }; $D.getTimezoneOffset = function (name, dst) { var i, a =[], z = Date.CultureInfo.timezones; if (!name) { name = (new Date()).getTimezone();} for (i = 0; i < z.length; i++) { if (z[i].name === name.toUpperCase()) { a.push(i); } } if (!z[a[0]]) { return null; } if (a.length === 1 || !dst) { return z[a[0]].offset; } else { for (i=0; i < a.length; i++) { if (z[a[i]].dst) { return z[a[i]].offset; } } } }; $D.getQuarter = function (d) { d = d || new Date(); // If no date supplied, use today var q = [1,2,3,4]; return q[Math.floor(d.getMonth() / 3)]; // ~~~ is a bitwise op. Faster than Math.floor }; $D.getDaysLeftInQuarter = function (d) { d = d || new Date(); var qEnd = new Date(d); qEnd.setMonth(qEnd.getMonth() + 3 - qEnd.getMonth() % 3, 0); return Math.floor((qEnd - d) / 8.64e7); }; // private var validate = function (n, min, max, name) { name = name ? name : "Object"; if (typeof n === "undefined") { return false; } else if (typeof n !== "number") { throw new TypeError(n + " is not a Number."); } else if (n < min || n > max) { // As failing validation is *not* an exceptional circumstance // lets not throw a RangeError Exception here. // It's semantically correct but it's not sensible. return false; } return true; }; /** * Validates the number is within an acceptable range for milliseconds [0-999]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateMillisecond = function (value) { return validate(value, 0, 999, "millisecond"); }; /** * Validates the number is within an acceptable range for seconds [0-59]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateSecond = function (value) { return validate(value, 0, 59, "second"); }; /** * Validates the number is within an acceptable range for minutes [0-59]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateMinute = function (value) { return validate(value, 0, 59, "minute"); }; /** * Validates the number is within an acceptable range for hours [0-23]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateHour = function (value) { return validate(value, 0, 23, "hour"); }; /** * Validates the number is within an acceptable range for the days in a month [0-MaxDaysInMonth]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateDay = function (value, year, month) { if (year === undefined || year === null || month === undefined || month === null) { return false;} return validate(value, 1, $D.getDaysInMonth(year, month), "day"); }; /** * Validates the number is within an acceptable range for months [0-11]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateWeek = function (value) { return validate(value, 0, 53, "week"); }; /** * Validates the number is within an acceptable range for months [0-11]. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateMonth = function (value) { return validate(value, 0, 11, "month"); }; /** * Validates the number is within an acceptable range for years. * @param {Number} The number to check if within range. * @return {Boolean} true if within range, otherwise false. */ $D.validateYear = function (value) { /** * Per ECMAScript spec the range of times supported by Date objects is * exactly -100,000,000 days to +100,000,000 days measured relative to * midnight at the beginning of 01 January, 1970 UTC. * This gives a range of 8,640,000,000,000,000 milliseconds to either * side of 01 January, 1970 UTC. * * Earliest possible date: Tue, 20 Apr 271,822 B.C. 00:00:00 UTC * Latest possible date: Sat, 13 Sep 275,760 00:00:00 UTC */ return validate(value, -271822, 275760, "year"); }; $D.validateTimezone = function(value) { var timezones = {"ACDT":1,"ACST":1,"ACT":1,"ADT":1,"AEDT":1,"AEST":1,"AFT":1,"AKDT":1,"AKST":1,"AMST":1,"AMT":1,"ART":1,"AST":1,"AWDT":1,"AWST":1,"AZOST":1,"AZT":1,"BDT":1,"BIOT":1,"BIT":1,"BOT":1,"BRT":1,"BST":1,"BTT":1,"CAT":1,"CCT":1,"CDT":1,"CEDT":1,"CEST":1,"CET":1,"CHADT":1,"CHAST":1,"CHOT":1,"ChST":1,"CHUT":1,"CIST":1,"CIT":1,"CKT":1,"CLST":1,"CLT":1,"COST":1,"COT":1,"CST":1,"CT":1,"CVT":1,"CWST":1,"CXT":1,"DAVT":1,"DDUT":1,"DFT":1,"EASST":1,"EAST":1,"EAT":1,"ECT":1,"EDT":1,"EEDT":1,"EEST":1,"EET":1,"EGST":1,"EGT":1,"EIT":1,"EST":1,"FET":1,"FJT":1,"FKST":1,"FKT":1,"FNT":1,"GALT":1,"GAMT":1,"GET":1,"GFT":1,"GILT":1,"GIT":1,"GMT":1,"GST":1,"GYT":1,"HADT":1,"HAEC":1,"HAST":1,"HKT":1,"HMT":1,"HOVT":1,"HST":1,"ICT":1,"IDT":1,"IOT":1,"IRDT":1,"IRKT":1,"IRST":1,"IST":1,"JST":1,"KGT":1,"KOST":1,"KRAT":1,"KST":1,"LHST":1,"LINT":1,"MAGT":1,"MART":1,"MAWT":1,"MDT":1,"MET":1,"MEST":1,"MHT":1,"MIST":1,"MIT":1,"MMT":1,"MSK":1,"MST":1,"MUT":1,"MVT":1,"MYT":1,"NCT":1,"NDT":1,"NFT":1,"NPT":1,"NST":1,"NT":1,"NUT":1,"NZDT":1,"NZST":1,"OMST":1,"ORAT":1,"PDT":1,"PET":1,"PETT":1,"PGT":1,"PHOT":1,"PHT":1,"PKT":1,"PMDT":1,"PMST":1,"PONT":1,"PST":1,"PYST":1,"PYT":1,"RET":1,"ROTT":1,"SAKT":1,"SAMT":1,"SAST":1,"SBT":1,"SCT":1,"SGT":1,"SLST":1,"SRT":1,"SST":1,"SYOT":1,"TAHT":1,"THA":1,"TFT":1,"TJT":1,"TKT":1,"TLT":1,"TMT":1,"TOT":1,"TVT":1,"UCT":1,"ULAT":1,"UTC":1,"UYST":1,"UYT":1,"UZT":1,"VET":1,"VLAT":1,"VOLT":1,"VOST":1,"VUT":1,"WAKT":1,"WAST":1,"WAT":1,"WEDT":1,"WEST":1,"WET":1,"WST":1,"YAKT":1,"YEKT":1,"Z":1}; return (timezones[value] === 1); }; $D.validateTimezoneOffset= function(value) { // timezones go from +14hrs to -12hrs, the +X hours are negative offsets. return (value > -841 && value < 721); }; }()); ================================================ FILE: src/core/extras.js ================================================ (function () { var $D = Date, $P = $D.prototype, // $C = $D.CultureInfo, // not used atm p = function (s, l) { if (!l) { l = 2; } return ("000" + s).slice(l * -1); }; /** * Converts a PHP format string to Java/.NET format string. * A PHP format string can be used with ._format or .format. * A Java/.NET format string can be used with .toString(). * The .parseExact function will only accept a Java/.NET format string * * Example * var f1 = "%m/%d/%y" * var f2 = Date.normalizeFormat(f1); // "MM/dd/yy" * * new Date().format(f1); // "04/13/08" * new Date()._format(f1); // "04/13/08" * new Date().toString(f2); // "04/13/08" * * var date = Date.parseExact("04/13/08", f2); // Sun Apr 13 2008 * * @param {String} A PHP format string consisting of one or more format spcifiers. * @return {String} The PHP format converted to a Java/.NET format string. */ var normalizerSubstitutions = { "d" : "dd", "%d": "dd", "D" : "ddd", "%a": "ddd", "j" : "dddd", "l" : "dddd", "%A": "dddd", "S" : "S", "F" : "MMMM", "%B": "MMMM", "m" : "MM", "%m": "MM", "M" : "MMM", "%b": "MMM", "%h": "MMM", "n" : "M", "Y" : "yyyy", "%Y": "yyyy", "y" : "yy", "%y": "yy", "g" : "h", "%I": "h", "G" : "H", "h" : "hh", "H" : "HH", "%H": "HH", "i" : "mm", "%M": "mm", "s" : "ss", "%S": "ss", "%r": "hh:mm tt", "%R": "H:mm", "%T": "H:mm:ss", "%X": "t", "%x": "d", "%e": "d", "%D": "MM/dd/yy", "%n": "\\n", "%t": "\\t", "e" : "z", "T" : "z", "%z": "z", "%Z": "z", "Z" : "ZZ", "N" : "u", "w" : "u", "%w": "u", "W" : "W", "%V": "W" }; var normalizer = { substitutes: function (m) { return normalizerSubstitutions[m]; }, interpreted: function (m, x) { var y; switch (m) { case "%u": return x.getDay() + 1; case "z": return x.getOrdinalNumber(); case "%j": return p(x.getOrdinalNumber(), 3); case "%U": var d1 = x.clone().set({month: 0, day: 1}).addDays(-1).moveToDayOfWeek(0), d2 = x.clone().addDays(1).moveToDayOfWeek(0, -1); return (d2 < d1) ? "00" : p((d2.getOrdinalNumber() - d1.getOrdinalNumber()) / 7 + 1); case "%W": return p(x.getWeek()); case "t": return $D.getDaysInMonth(x.getFullYear(), x.getMonth()); case "o": case "%G": return x.setWeek(x.getISOWeek()).toString("yyyy"); case "%g": return x._format("%G").slice(-2); case "a": case "%p": return t("tt").toLowerCase(); case "A": return t("tt").toUpperCase(); case "u": return p(x.getMilliseconds(), 3); case "I": return (x.isDaylightSavingTime()) ? 1 : 0; case "O": return x.getUTCOffset(); case "P": y = x.getUTCOffset(); return y.substring(0, y.length - 2) + ":" + y.substring(y.length - 2); case "B": var now = new Date(); return Math.floor(((now.getHours() * 3600) + (now.getMinutes() * 60) + now.getSeconds() + (now.getTimezoneOffset() + 60) * 60) / 86.4); case "c": return x.toISOString().replace(/\"/g, ""); case "U": return $D.strtotime("now"); case "%c": return t("d") + " " + t("t"); case "%C": return Math.floor(x.getFullYear() / 100 + 1); } }, shouldOverrideDefaults: function (m) { switch (m) { case "%e": return true; default: return false; } }, parse: function (m, context) { var formatString, c = context || new Date(); formatString = normalizer.substitutes(m); if (formatString) { return formatString; } formatString = normalizer.interpreted(m, c); if (formatString) { return formatString; } else { return m; } } }; $D.normalizeFormat = function (format, context) { return format.replace(/(%|\\)?.|%%/g, function(t){ return normalizer.parse(t, context); }); }; /** * Format a local Unix timestamp according to locale settings * * Example: * Date.strftime("%m/%d/%y", new Date()); // "04/13/08" * Date.strftime("c", "2008-04-13T17:52:03Z"); // "04/13/08" * * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @param {Number|String} The number representing the number of seconds that have elapsed since January 1, 1970 (local time). * @return {String} A string representation of the current Date object. */ $D.strftime = function (format, time) { var d = Date.parse(time); return d._format(format); }; /** * Parse any textual datetime description into a Unix timestamp. * A Unix timestamp is the number of seconds that have elapsed since January 1, 1970 (midnight UTC/GMT). * * Example: * Date.strtotime("04/13/08"); // 1208044800 * Date.strtotime("1970-01-01T00:00:00Z"); // 0 * * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @param {Object} A string or date object. * @return {String} A string representation of the current Date object. */ $D.strtotime = function (time) { var d = $D.parse(time); return Math.round($D.UTC(d.getUTCFullYear(), d.getUTCMonth(), d.getUTCDate(), d.getUTCHours(), d.getUTCMinutes(), d.getUTCSeconds(), d.getUTCMilliseconds()) / 1000); }; /** * Converts the value of the current Date object to its equivalent string representation using a PHP/Unix style of date format specifiers. * Format Specifiers * Format Description Example * ------ --------------------------------------------------------------------------- ----------------------- * %a abbreviated weekday name according to the current localed "Mon" through "Sun" * %A full weekday name according to the current localed "Sunday" through "Saturday" * %b abbreviated month name according to the current localed "Jan" through "Dec" * %B full month name according to the current locale "January" through "December" * %c preferred date and time representation for the current locale "4/13/2008 12:33 PM" * %C century number (the year divided by 100 and truncated to an integer) "00" to "99" * %d day of the month as a decimal number "01" to "31" * %D same as %m/%d/%y "04/13/08" * %e day of the month as a decimal number, a single digit is preceded by a space "1" to "31" * %g like %G, but without the century "08" * %G The 4-digit year corresponding to the ISO week number (see %V). "2008" * This has the same format and value as %Y, except that if the ISO week number * belongs to the previous or next year, that year is used instead. * %h same as %b "Jan" through "Dec" * %H hour as a decimal number using a 24-hour clock. "00" to "23" * %I hour as a decimal number using a 12-hour clock. "01" to "12" * %j day of the year as a decimal number. "001" to "366" * %m month as a decimal number. "01" to "12" * %M minute as a decimal number. "00" to "59" * %n newline character "\n" * %p either "am" or "pm" according to the given time value, or the "am" or "pm" * corresponding strings for the current locale. * %r time in a.m. and p.m. notation "8:44 PM" * %R time in 24 hour notation "20:44" * %S second as a decimal number "00" to "59" * %t tab character "\t" * %T current time, equal to %H:%M:%S "12:49:11" * %u weekday as a decimal number ["1", "7"], with "1" representing Monday "1" to "7" * %U week number of the current year as a decimal number, starting with the "0" to ("52" or "53") * first Sunday as the first day of the first week * %V The ISO 8601:1988 week number of the current year as a decimal number, "00" to ("52" or "53") * range 01 to 53, where week 1 is the first week that has at least 4 days * in the current year, and with Monday as the first day of the week. * (Use %G or %g for the year component that corresponds to the week number * for the specified timestamp.) * %W week number of the current year as a decimal number, starting with the "00" to ("52" or "53") * first Monday as the first day of the first week * %w day of the week as a decimal, Sunday being "0" "0" to "6" * %x preferred date representation for the current locale without the time "4/13/2008" * %X preferred time representation for the current locale without the date "12:53:05" * %y year as a decimal number without a century "00" "99" * %Y year as a decimal number including the century "2008" * %Z time zone or name or abbreviation "UTC", "EST", "PST" * %z same as %Z * %% a literal "%" characters "%" * d Day of the month, 2 digits with leading zeros "01" to "31" * D A textual representation of a day, three letters "Mon" through "Sun" * j Day of the month without leading zeros "1" to "31" * l A full textual representation of the day of the week (lowercase "L") "Sunday" through "Saturday" * N ISO-8601 numeric representation of the day of the week (added in PHP 5.1.0) "1" (for Monday) through "7" (for Sunday) * S English ordinal suffix for the day of the month, 2 characters "st", "nd", "rd" or "th". Works well with j * w Numeric representation of the day of the week "0" (for Sunday) through "6" (for Saturday) * z The day of the year (starting from "0") "0" through "365" * W ISO-8601 week number of year, weeks starting on Monday "00" to ("52" or "53") * F A full textual representation of a month, such as January or March "January" through "December" * m Numeric representation of a month, with leading zeros "01" through "12" * M A short textual representation of a month, three letters "Jan" through "Dec" * n Numeric representation of a month, without leading zeros "1" through "12" * t Number of days in the given month "28" through "31" * L Whether it's a leap year "1" if it is a leap year, "0" otherwise * o ISO-8601 year number. This has the same value as Y, except that if the "2008" * ISO week number (W) belongs to the previous or next year, that year * is used instead. * Y A full numeric representation of a year, 4 digits "2008" * y A two digit representation of a year "08" * a Lowercase Ante meridiem and Post meridiem "am" or "pm" * A Uppercase Ante meridiem and Post meridiem "AM" or "PM" * B Swatch Internet time "000" through "999" * g 12-hour format of an hour without leading zeros "1" through "12" * G 24-hour format of an hour without leading zeros "0" through "23" * h 12-hour format of an hour with leading zeros "01" through "12" * H 24-hour format of an hour with leading zeros "00" through "23" * i Minutes with leading zeros "00" to "59" * s Seconds, with leading zeros "00" through "59" * u Milliseconds "54321" * e Timezone identifier "UTC", "EST", "PST" * I Whether or not the date is in daylight saving time (uppercase i) "1" if Daylight Saving Time, "0" otherwise * O Difference to Greenwich time (GMT) in hours "+0200", "-0600" * P Difference to Greenwich time (GMT) with colon between hours and minutes "+02:00", "-06:00" * T Timezone abbreviation "UTC", "EST", "PST" * Z Timezone offset in seconds. The offset for timezones west of UTC is "-43200" through "50400" * always negative, and for those east of UTC is always positive. * c ISO 8601 date "2004-02-12T15:19:21+00:00" * r RFC 2822 formatted date "Thu, 21 Dec 2000 16:01:07 +0200" * U Seconds since the Unix Epoch (January 1 1970 00:00:00 GMT) "0" * @param {String} A format string consisting of one or more format spcifiers [Optional]. * @return {String} A string representation of the current Date object. */ var formatReplace = function (context) { return function (m) { var formatString, override = false; if (m.charAt(0) === "\\" || m.substring(0, 2) === "%%") { return m.replace("\\", "").replace("%%", "%"); } override = normalizer.shouldOverrideDefaults(m); formatString = $D.normalizeFormat(m, context); if (formatString) { return context.toString(formatString, override); } }; }; $P._format = function (format) { var formatter = formatReplace(this); if (!format) { return this._toString(); } else { return format.replace(/(%|\\)?.|%%/g, formatter); } }; if (!$P.format) { $P.format = $P._format; } }()); ================================================ FILE: src/core/format_parser.js ================================================ (function () { "use strict"; Date.Parsing = { Exception: function (s) { this.message = "Parse error at '" + s.substring(0, 10) + " ...'"; } }; var $P = Date.Parsing; var dayOffsets = { standard: [0,31,59,90,120,151,181,212,243,273,304,334], leap: [0,31,60,91,121,152,182,213,244,274,305,335] }; $P.isLeapYear = function(year) { return ((year % 4 === 0) && (year % 100 !== 0)) || (year % 400 === 0); }; var utils = { multiReplace : function (str, hash ) { var key; for (key in hash) { if (Object.prototype.hasOwnProperty.call(hash, key)) { var regex; if (typeof hash[key] === "function") { } else { regex = (hash[key] instanceof RegExp) ? hash[key] : new RegExp(hash[key], "g"); } str = str.replace(regex, key); } } return str; }, getDayOfYearFromWeek : function (obj) { var d, jan4, offset; obj.weekDay = (!obj.weekDay && obj.weekDay !== 0) ? 1 : obj.weekDay; d = new Date(obj.year, 0, 4); jan4 = d.getDay() === 0 ? 7 : d.getDay(); // JS is 0 indexed on Sunday. offset = jan4+3; obj.dayOfYear = ((obj.week * 7) + (obj.weekDay === 0 ? 7 : obj.weekDay))-offset; return obj; }, getDayOfYear : function (obj, dayOffset) { if (!obj.dayOfYear) { obj = utils.getDayOfYearFromWeek(obj); } for (var i=0;i <= dayOffset.length;i++) { if (obj.dayOfYear < dayOffset[i] || i === dayOffset.length) { obj.day = obj.day ? obj.day : (obj.dayOfYear - dayOffset[i-1]); break; } else { obj.month = i; } } return obj; }, adjustForTimeZone : function (obj, date) { var offset; if (obj.zone.toUpperCase() === "Z" || (obj.zone_hours === 0 && obj.zone_minutes === 0)) { // it's UTC/GML so work out the current timeszone offset offset = -date.getTimezoneOffset(); } else { offset = (obj.zone_hours*60) + (obj.zone_minutes || 0); if (obj.zone_sign === "+") { offset *= -1; } offset -= date.getTimezoneOffset(); } date.setMinutes(date.getMinutes()+offset); return date; }, setDefaults : function (obj) { obj.year = obj.year || Date.today().getFullYear(); obj.hours = obj.hours || 0; obj.minutes = obj.minutes || 0; obj.seconds = obj.seconds || 0; obj.milliseconds = obj.milliseconds || 0; if (!(!obj.month && (obj.week || obj.dayOfYear))) { // if we have a month, or if we don't but don't have the day calculation data obj.month = obj.month || 0; obj.day = obj.day || 1; } return obj; }, dataNum: function (data, mod, explict, postProcess) { var dataNum = data*1; if (mod) { if (postProcess) { return data ? mod(data)*1 : data; } else { return data ? mod(dataNum) : data; } } else if (!explict){ return data ? dataNum : data; } else { return (data && typeof data !== "undefined") ? dataNum : data; } }, timeDataProcess: function (obj) { var timeObj = {}; for (var x in obj.data) { if (obj.data.hasOwnProperty(x)) { timeObj[x] = obj.ignore[x] ? obj.data[x] : utils.dataNum(obj.data[x], obj.mods[x], obj.explict[x], obj.postProcess[x]); } } if (obj.data.secmins) { obj.data.secmins = obj.data.secmins.replace(",", ".") * 60; if (!timeObj.minutes) { timeObj.minutes = obj.data.secmins; } else if (!timeObj.seconds) { timeObj.seconds = obj.data.secmins; } delete obj.secmins; } return timeObj; }, buildTimeObjectFromData: function (data) { var time = utils.timeDataProcess({ data: { year : data[1], month : data[5], day : data[7], week : data[8], dayOfYear : data[10], hours : data[15], zone_hours : data[23], zone_minutes : data[24], zone : data[21], zone_sign : data[22], weekDay : data[9], minutes: data[16], seconds: data[19], milliseconds: data[20], secmins: data[18] }, mods: { month: function(data) { return data-1; }, weekDay: function (data) { data = Math.abs(data); return (data === 7 ? 0 : data); }, minutes: function (data) { return data.replace(":",""); }, seconds: function (data) { return Math.floor( (data.replace(":","").replace(",","."))*1 ); }, milliseconds: function (data) { return (data.replace(",",".")*1000); } }, postProcess: { minutes: true, seconds: true, milliseconds: true }, explict: { zone_hours: true, zone_minutes: true }, ignore: { zone: true, zone_sign: true, secmins: true } }); return time; }, addToHash: function (hash, keys, data) { keys = keys; data = data; var len = keys.length; for (var i = 0; i < len; i++) { hash[keys[i]] = data[i]; } return hash; }, combineRegex: function (r1, r2) { return new RegExp("(("+r1.source+")\\s("+r2.source+"))"); }, getDateNthString: function(add, last, inc){ if (add) { return Date.today().addDays(inc).toString("d"); } else if (last) { return Date.today().last()[inc]().toString("d"); } }, buildRegexData: function (array) { var arr = []; var len = array.length; for (var i=0; i < len; i++) { if (Object.prototype.toString.call(array[i]) === '[object Array]') { // oldIE compat version of Array.isArray arr.push(this.combineRegex(array[i][0], array[i][1])); } else { arr.push(array[i]); } } return arr; } }; $P.processTimeObject = function (obj) { var date, dayOffset; utils.setDefaults(obj); dayOffset = ($P.isLeapYear(obj.year)) ? dayOffsets.leap : dayOffsets.standard; if (!obj.month && (obj.week || obj.dayOfYear)) { utils.getDayOfYear(obj, dayOffset); } else { obj.dayOfYear = dayOffset[obj.month] + obj.day; } date = new Date(obj.year, obj.month, obj.day, obj.hours, obj.minutes, obj.seconds, obj.milliseconds); if (obj.zone) { utils.adjustForTimeZone(obj, date); // adjust (and calculate) for timezone } return date; }; $P.ISO = { regex : /^([\+-]?\d{4}(?!\d{2}\b))((-?)((0[1-9]|1[0-2])(\3([12]\d|0[1-9]|3[01]))?|W([0-4]\d|5[0-3])(-?[1-7])?|(00[1-9]|0[1-9]\d|[12]\d{2}|3([0-5]\d|6[1-6])))([T\s]((([01]\d|2[0-4])((:?)[0-5]\d)?|24\:?00)([\.,]\d+(?!:))?)?(\17[0-5]\d([\.,]\d+)?)?\s?([zZ]|([\+-])([01]\d|2[0-3]):?([0-5]\d)?)?)?)?$/, parse : function (s) { var time, data = s.match(this.regex); if (!data || !data.length) { return null; } time = utils.buildTimeObjectFromData(data); if (!time.year || (!time.year && (!time.month && !time.day) && (!time.week && !time.dayOfYear)) ) { return null; } return $P.processTimeObject(time); } }; $P.Numeric = { isNumeric: function (e){return!isNaN(parseFloat(e))&&isFinite(e);}, regex: /\b([0-1]?[0-9])([0-3]?[0-9])([0-2]?[0-9]?[0-9][0-9])\b/i, parse: function (s) { var data, i, time = {}, order = Date.CultureInfo.dateElementOrder.split(""); if (!(this.isNumeric(s)) || // if it's non-numeric OR (s[0] === "+" && s[0] === "-")) { // It's an arithmatic string (eg +/-1000) return null; } if (s.length < 5 && s.indexOf(".") < 0 && s.indexOf("/") < 0) { // assume it's just a year. time.year = s; return $P.processTimeObject(time); } data = s.match(this.regex); if (!data || !data.length) { return null; } for (i=0; i < order.length; i++) { switch(order[i]) { case "d": time.day = data[i+1]; break; case "m": time.month = (data[i+1]-1); break; case "y": time.year = data[i+1]; break; } } return $P.processTimeObject(time); } }; $P.Normalizer = { regexData: function () { var $R = Date.CultureInfo.regexPatterns; return utils.buildRegexData([ $R.tomorrow, $R.yesterday, [$R.past, $R.mon], [$R.past, $R.tue], [$R.past, $R.wed], [$R.past, $R.thu], [$R.past, $R.fri], [$R.past, $R.sat], [$R.past, $R.sun] ]); }, basicReplaceHash : function() { var $R = Date.CultureInfo.regexPatterns; return { "January": $R.jan.source, "February": $R.feb, "March": $R.mar, "April": $R.apr, "May": $R.may, "June": $R.jun, "July": $R.jul, "August": $R.aug, "September": $R.sep, "October": $R.oct, "November": $R.nov, "December": $R.dec, "": /\bat\b/gi, " ": /\s{2,}/, "am": $R.inTheMorning, "9am": $R.thisMorning, "pm": $R.inTheEvening, "7pm":$R.thisEvening }; }, keys : function(){ return [ utils.getDateNthString(true, false, 1), // tomorrow utils.getDateNthString(true, false, -1), // yesterday utils.getDateNthString(false, true, "monday"), //last mon utils.getDateNthString(false, true, "tuesday"), //last tues utils.getDateNthString(false, true, "wednesday"), //last wed utils.getDateNthString(false, true, "thursday"), //last thurs utils.getDateNthString(false, true, "friday"), //last fri utils.getDateNthString(false, true, "saturday"), //last sat utils.getDateNthString(false, true, "sunday") //last sun ]; }, buildRegexFunctions: function () { var $R = Date.CultureInfo.regexPatterns; var __ = Date.i18n.__; var tomorrowRE = new RegExp("(\\b\\d\\d?("+__("AM")+"|"+__("PM")+")? )("+$R.tomorrow.source.slice(1)+")", "i"); // adapted tomorrow regex for AM PM relative dates var todayRE = new RegExp($R.today.source + "(?!\\s*([+-]))\\b"); // today, but excludes the math operators (eg "today + 2h") this.replaceFuncs = [ [todayRE, function (full) { return (full.length > 1) ? Date.today().toString("d") : full; }], [tomorrowRE, function(full, m1) { var t = Date.today().addDays(1).toString("d"); return (t + " " + m1); }], [$R.amThisMorning, function(str, am){return am;}], [$R.pmThisEvening, function(str, pm){return pm;}], [$R.subtract, function (str, match) { return ""; }, function (str){ return "-"+str; }] ]; }, buildReplaceData: function () { this.buildRegexFunctions(); this.replaceHash = utils.addToHash(this.basicReplaceHash(), this.keys(), this.regexData()); }, stringReplaceFuncs: function (s) { for (var i=0; i < this.replaceFuncs.length; i++) { s = s.replace(this.replaceFuncs[i][0], this.replaceFuncs[i][1]); if(this.replaceFuncs[i][2]) { s = this.replaceFuncs[i][2](s); } } return s; }, parse: function (s) { s = this.stringReplaceFuncs(s); s = utils.multiReplace(s, this.replaceHash); try { var n = s.split(/([\s\-\.\,\/\x27]+)/); if (n.length === 3 && $P.Numeric.isNumeric(n[0]) && $P.Numeric.isNumeric(n[2]) && (n[2].length >= 4)) { // ok, so we're dealing with x/year. But that's not a full date. // This fixes wonky dateElementOrder parsing when set to dmy order. if (Date.CultureInfo.dateElementOrder[0] === "d") { s = "1/" + n[0] + "/" + n[2]; // set to 1st of month and normalize the seperator } } } catch (e) {} return s; } }; $P.Normalizer.buildReplaceData(); }()); ================================================ FILE: src/core/i18n.js ================================================ (function () { var $D = Date; var lang = Date.CultureStrings ? Date.CultureStrings.lang : null; var loggedKeys = {}; // for debug purposes. var getText = { getFromKey: function (key, countryCode) { var output; if (Date.CultureStrings && Date.CultureStrings[countryCode] && Date.CultureStrings[countryCode][key]) { output = Date.CultureStrings[countryCode][key]; } else { output = getText.buildFromDefault(key); } if (key.charAt(0) === "/") { // Assume it's a regex output = getText.buildFromRegex(key, countryCode); } return output; }, getFromObjectValues: function (obj, countryCode) { var key, output = {}; for(key in obj) { if (obj.hasOwnProperty(key)) { output[key] = getText.getFromKey(obj[key], countryCode); } } return output; }, getFromObjectKeys: function (obj, countryCode) { var key, output = {}; for(key in obj) { if (obj.hasOwnProperty(key)) { output[getText.getFromKey(key, countryCode)] = obj[key]; } } return output; }, getFromArray: function (arr, countryCode) { var output = []; for (var i=0; i < arr.length; i++){ if (i in arr) { output[i] = getText.getFromKey(arr[i], countryCode); } } return output; }, buildFromDefault: function (key) { var output, length, split, last; switch(key) { case "name": output = "en-US"; break; case "englishName": output = "English (United States)"; break; case "nativeName": output = "English (United States)"; break; case "twoDigitYearMax": output = 2049; break; case "firstDayOfWeek": output = 0; break; default: output = key; split = key.split("_"); length = split.length; if (length > 1 && key.charAt(0) !== "/") { // if the key isn't a regex and it has a split. last = split[(length - 1)].toLowerCase(); if (last === "initial" || last === "abbr") { output = split[0]; } } break; } return output; }, buildFromRegex: function (key, countryCode) { var output; if (Date.CultureStrings && Date.CultureStrings[countryCode] && Date.CultureStrings[countryCode][key]) { output = new RegExp(Date.CultureStrings[countryCode][key], "i"); } else { output = new RegExp(key.replace(new RegExp("/", "g"),""), "i"); } return output; } }; var shallowMerge = function (obj1, obj2) { for (var attrname in obj2) { if (obj2.hasOwnProperty(attrname)) { obj1[attrname] = obj2[attrname]; } } }; var __ = function (key, language) { var countryCode = (language) ? language : lang; loggedKeys[key] = key; if (typeof key === "object") { if (key instanceof Array) { return getText.getFromArray(key, countryCode); } else { return getText.getFromObjectKeys(key, countryCode); } } else { return getText.getFromKey(key, countryCode); } }; var loadI18nScript = function (code) { // paatterned after jQuery's getScript. var url = Date.Config.i18n + code + ".js"; var head = document.getElementsByTagName("head")[0] || document.documentElement; var script = document.createElement("script"); script.src = url; var completed = false; var events = { done: function (){} // placeholder function }; // Attach handlers for all browsers script.onload = script.onreadystatechange = function() { if ( !completed && (!this.readyState || this.readyState === "loaded" || this.readyState === "complete") ) { events.done(); head.removeChild(script); } }; setTimeout(function() { head.insertBefore(script, head.firstChild); }, 0); // allows return to execute first return { done: function (cb) { events.done = function() { if (cb) { setTimeout(cb,0); } }; } }; }; var buildInfo = { buildFromMethodHash: function (obj) { var key; for(key in obj) { if (obj.hasOwnProperty(key)) { obj[key] = buildInfo[obj[key]](); } } return obj; }, timeZoneDST: function () { var DST = { "CHADT": "+1345", "NZDT": "+1300", "AEDT": "+1100", "ACDT": "+1030", "AZST": "+0500", "IRDT": "+0430", "EEST": "+0300", "CEST": "+0200", "BST": "+0100", "PMDT": "-0200", "ADT": "-0300", "NDT": "-0230", "EDT": "-0400", "CDT": "-0500", "MDT": "-0600", "PDT": "-0700", "AKDT": "-0800", "HADT": "-0900" }; return __(DST); }, timeZoneStandard: function () { var standard = { "LINT": "+1400", "TOT": "+1300", "CHAST": "+1245", "NZST": "+1200", "NFT": "+1130", "SBT": "+1100", "AEST": "+1000", "ACST": "+0930", "JST": "+0900", "CWST": "+0845", "CT": "+0800", "ICT": "+0700", "MMT": "+0630", "BST": "+0600", "NPT": "+0545", "IST": "+0530", "PKT": "+0500", "AFT": "+0430", "MSK": "+0400", "IRST": "+0330", "FET": "+0300", "EET": "+0200", "CET": "+0100", "GMT": "+0000", "UTC": "+0000", "CVT": "-0100", "GST": "-0200", "BRT": "-0300", "NST": "-0330", "AST": "-0400", "EST": "-0500", "CST": "-0600", "MST": "-0700", "PST": "-0800", "AKST": "-0900", "MIT": "-0930", "HST": "-1000", "SST": "-1100", "BIT": "-1200" }; return __(standard); }, timeZones: function (data) { var zone; data.timezones = []; for (zone in data.abbreviatedTimeZoneStandard) { if (data.abbreviatedTimeZoneStandard.hasOwnProperty(zone)) { data.timezones.push({ name: zone, offset: data.abbreviatedTimeZoneStandard[zone]}); } } for (zone in data.abbreviatedTimeZoneDST) { if (data.abbreviatedTimeZoneDST.hasOwnProperty(zone)) { data.timezones.push({ name: zone, offset: data.abbreviatedTimeZoneDST[zone], dst: true}); } } return data.timezones; }, days: function () { return __(["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"]); }, dayAbbr: function () { return __(["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"]); }, dayShortNames: function () { return __(["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"]); }, dayFirstLetters: function () { return __(["S_Sun_Initial", "M_Mon_Initial", "T_Tues_Initial", "W_Wed_Initial", "T_Thu_Initial", "F_Fri_Initial", "S_Sat_Initial"]); }, months: function () { return __(["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"]); }, monthAbbr: function () { return __(["Jan_Abbr", "Feb_Abbr", "Mar_Abbr", "Apr_Abbr", "May_Abbr", "Jun_Abbr", "Jul_Abbr", "Aug_Abbr", "Sep_Abbr", "Oct_Abbr", "Nov_Abbr", "Dec_Abbr"]); }, formatPatterns: function () { return getText.getFromObjectValues({ shortDate: "M/d/yyyy", longDate: "dddd, MMMM dd, yyyy", shortTime: "h:mm tt", longTime: "h:mm:ss tt", fullDateTime: "dddd, MMMM dd, yyyy h:mm:ss tt", sortableDateTime: "yyyy-MM-ddTHH:mm:ss", universalSortableDateTime: "yyyy-MM-dd HH:mm:ssZ", rfc1123: "ddd, dd MMM yyyy HH:mm:ss", monthDay: "MMMM dd", yearMonth: "MMMM, yyyy" }, Date.i18n.currentLanguage()); }, regex: function () { return getText.getFromObjectValues({ inTheMorning: "/( in the )(morn(ing)?)\\b/", thisMorning: "/(this )(morn(ing)?)\\b/", amThisMorning: "/(\b\\d(am)? )(this )(morn(ing)?)/", inTheEvening: "/( in the )(even(ing)?)\\b/", thisEvening: "/(this )(even(ing)?)\\b/", pmThisEvening: "/(\b\\d(pm)? )(this )(even(ing)?)/", jan: "/jan(uary)?/", feb: "/feb(ruary)?/", mar: "/mar(ch)?/", apr: "/apr(il)?/", may: "/may/", jun: "/jun(e)?/", jul: "/jul(y)?/", aug: "/aug(ust)?/", sep: "/sep(t(ember)?)?/", oct: "/oct(ober)?/", nov: "/nov(ember)?/", dec: "/dec(ember)?/", sun: "/^su(n(day)?)?/", mon: "/^mo(n(day)?)?/", tue: "/^tu(e(s(day)?)?)?/", wed: "/^we(d(nesday)?)?/", thu: "/^th(u(r(s(day)?)?)?)?/", fri: "/fr(i(day)?)?/", sat: "/^sa(t(urday)?)?/", future: "/^next/", past: "/^last|past|prev(ious)?/", add: "/^(\\+|aft(er)?|from|hence)/", subtract: "/(^\\-|bef(ore)?|ago)/", yesterday: "/^yes(terday)?/", today: "/^t(od(ay)?)?/", tomorrow: "/^tom(orrow)?/", now: "/^n(ow)?/", millisecond: "/^ms|milli(second)?s?/", second: "/^sec(ond)?s?/", minute: "/^mn|min(ute)?s?/", hour: "/^h(our)?s?/", week: "/^w(eek)?s?/", month: "/^m(onth)?s?/", day: "/^d(ay)?s?/", year: "/^y(ear)?s?/", shortMeridian: "/^(a|p)/", longMeridian: "/^(a\\.?m?\\.?|p\\.?m?\\.?)/", timezone: "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/", ordinalSuffix: "/^\\s*(st|nd|rd|th)/", timeContext: "/^\\s*(\\:|a(?!u|p)|p)/" }, Date.i18n.currentLanguage()); } }; var CultureInfo = function () { var info = getText.getFromObjectValues({ name: "name", englishName: "englishName", nativeName: "nativeName", amDesignator: "AM", pmDesignator: "PM", firstDayOfWeek: "firstDayOfWeek", twoDigitYearMax: "twoDigitYearMax", dateElementOrder: "mdy" }, Date.i18n.currentLanguage()); var constructedInfo = buildInfo.buildFromMethodHash({ dayNames: "days", abbreviatedDayNames: "dayAbbr", shortestDayNames: "dayShortNames", firstLetterDayNames: "dayFirstLetters", monthNames: "months", abbreviatedMonthNames: "monthAbbr", formatPatterns: "formatPatterns", regexPatterns: "regex", abbreviatedTimeZoneDST: "timeZoneDST", abbreviatedTimeZoneStandard: "timeZoneStandard" }); shallowMerge(info, constructedInfo); buildInfo.timeZones(info); return info; }; $D.i18n = { __: function (key, lang) { return __(key, lang); }, currentLanguage: function () { return lang || "en-US"; }, setLanguage: function (code, force, cb) { var async = false; if (force || code === "en-US" || (!!Date.CultureStrings && !!Date.CultureStrings[code])) { lang = code; Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings.lang = code; Date.CultureInfo = new CultureInfo(); } else { if (!(!!Date.CultureStrings && !!Date.CultureStrings[code])) { if (typeof exports !== "undefined" && this.exports !== exports) { // we're in a Node enviroment, load it using require try { require("../i18n/" + code + ".js"); lang = code; Date.CultureStrings.lang = code; Date.CultureInfo = new CultureInfo(); } catch (e) { // var str = "The language for '" + code + "' could not be loaded by Node. It likely does not exist."; throw new Error("The DateJS IETF language tag '" + code + "' could not be loaded by Node. It likely does not exist."); } } else if (Date.Config && Date.Config.i18n) { // we know the location of the files, so lets load them async = true; loadI18nScript(code).done(function(){ lang = code; Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings.lang = code; Date.CultureInfo = new CultureInfo(); $D.Parsing.Normalizer.buildReplaceData(); // because this is async if ($D.Grammar) { $D.Grammar.buildGrammarFormats(); // so we can parse those strings... } if (cb) { setTimeout(cb,0); } }); } else { Date.console.error("The DateJS IETF language tag '" + code + "' is not available and has not been loaded."); return false; } } } $D.Parsing.Normalizer.buildReplaceData(); // rebuild normalizer strings if ($D.Grammar) { $D.Grammar.buildGrammarFormats(); // so we can parse those strings... } if (!async && cb) { setTimeout(cb,0); } }, getLoggedKeys: function () { return loggedKeys; }, updateCultureInfo: function () { Date.CultureInfo = new CultureInfo(); } }; $D.i18n.updateCultureInfo(); // run automatically }()); ================================================ FILE: src/core/parser.js ================================================ (function () { var $D = Date; /** * @desc Converts the specified string value into its JavaScript Date equivalent using CultureInfo specific format information. * * Example

	///////////
	// Dates //
	///////////

	// 15-Oct-2004
	var d1 = Date.parse("10/15/2004");

	// 15-Oct-2004
	var d1 = Date.parse("15-Oct-2004");

	// 15-Oct-2004
	var d1 = Date.parse("2004.10.15");

	//Fri Oct 15, 2004
	var d1 = Date.parse("Fri Oct 15, 2004");

	///////////
	// Times //
	///////////

	// Today at 10 PM.
	var d1 = Date.parse("10 PM");

	// Today at 10:30 PM.
	var d1 = Date.parse("10:30 P.M.");

	// Today at 6 AM.
	var d1 = Date.parse("06am");

	/////////////////////
	// Dates and Times //
	/////////////////////

	// 8-July-2004 @ 10:30 PM
	var d1 = Date.parse("July 8th, 2004, 10:30 PM");

	// 1-July-2004 @ 10:30 PM
	var d1 = Date.parse("2004-07-01T22:30:00");

	////////////////////
	// Relative Dates //
	////////////////////

	// Returns today's date. The string "today" is culture specific.
	var d1 = Date.parse("today");

	// Returns yesterday's date. The string "yesterday" is culture specific.
	var d1 = Date.parse("yesterday");

	// Returns the date of the next thursday.
	var d1 = Date.parse("Next thursday");

	// Returns the date of the most previous monday.
	var d1 = Date.parse("last monday");

	// Returns today's day + one year.
	var d1 = Date.parse("next year");

	///////////////
	// Date Math //
	///////////////

	// Today + 2 days
	var d1 = Date.parse("t+2");

	// Today + 2 days
	var d1 = Date.parse("today + 2 days");

	// Today + 3 months
	var d1 = Date.parse("t+3m");

	// Today - 1 year
	var d1 = Date.parse("today - 1 year");

	// Today - 1 year
	var d1 = Date.parse("t-1y"); 


	/////////////////////////////
	// Partial Dates and Times //
	/////////////////////////////

	// July 15th of this year.
	var d1 = Date.parse("July 15");

	// 15th day of current day and year.
	var d1 = Date.parse("15");

	// July 1st of current year at 10pm.
	var d1 = Date.parse("7/1 10pm");
	
* * @param {String} The string value to convert into a Date object [Required] * @return {Date} A Date object or null if the string cannot be converted into a Date. */ var parseUtils = { removeOrds: function (s) { ords = s.match(/\b(\d+)(?:st|nd|rd|th)\b/); // find ordinal matches s = ((ords && ords.length === 2) ? s.replace(ords[0], ords[1]) : s); return s; }, grammarParser: function (s) { var r = null; try { r = $D.Grammar.start.call({}, s.replace(/^\s*(\S*(\s+\S+)*)\s*$/, "$1")); } catch (e) { return null; } return ((r[1].length === 0) ? r[0] : null); }, nativeFallback: function(s) { var t; try { // ok we haven't parsed it, last ditch attempt with the built-in parser. t = Date._parse(s); return (t || t === 0) ? new Date(t) : null; } catch (e) { return null; } } }; function parse (s) { var d; if (!s) { return null; } if (s instanceof Date) { return s.clone(); } if (s.length >= 4 && s.charAt(0) !== "0" && s.charAt(0) !== "+"&& s.charAt(0) !== "-") { // ie: 2004 will pass, 0800 won't. // Start with specific formats d = $D.Parsing.ISO.parse(s) || $D.Parsing.Numeric.parse(s); } if (d instanceof Date && !isNaN(d.getTime())) { return d; } else { // find ordinal dates (1st, 3rd, 8th, etc and remove them as they cause parsing issues) s = $D.Parsing.Normalizer.parse(parseUtils.removeOrds(s)); d = parseUtils.grammarParser(s); if (d !== null) { return d; } else { return parseUtils.nativeFallback(s); } } } if (!$D._parse) { $D._parse = $D.parse; } $D.parse = parse; Date.getParseFunction = function (fx) { var fns = Date.Grammar.allformats(fx); return function (s) { var r = null; for (var i = 0; i < fns.length; i++) { try { r = fns[i].call({}, s); } catch (e) { continue; } if (r[1].length === 0) { return r[0]; } } return null; }; }; /** * Converts the specified string value into its JavaScript Date equivalent using the specified format {String} or formats {Array} and the CultureInfo specific format information. * The format of the string value must match one of the supplied formats exactly. * * Example

	// 15-Oct-2004
	var d1 = Date.parseExact("10/15/2004", "M/d/yyyy");

	// 15-Oct-2004
	var d1 = Date.parse("15-Oct-2004", "M-ddd-yyyy");

	// 15-Oct-2004
	var d1 = Date.parse("2004.10.15", "yyyy.MM.dd");

	// Multiple formats
	var d1 = Date.parseExact("10/15/2004", ["M/d/yyyy", "MMMM d, yyyy"]);
	
* * @param {String} The string value to convert into a Date object [Required]. * @param {Object} The expected format {String} or an array of expected formats {Array} of the date string [Required]. * @return {Date} A Date object or null if the string cannot be converted into a Date. */ $D.parseExact = function (s, fx) { return $D.getParseFunction(fx)(s); }; }()); ================================================ FILE: src/core/parsing_grammar.js ================================================ (function () { var $D = Date; $D.Grammar = {}; var _ = $D.Parsing.Operators, g = $D.Grammar, t = $D.Translator, _fn; // Allow rolling up into general purpose rules _fn = function () { return _.each(_.any.apply(null, arguments), _.not(g.ctoken2("timeContext"))); }; g.datePartDelimiter = _.rtoken(/^([\s\-\.\,\/\x27]+)/); g.timePartDelimiter = _.stoken(":"); g.whiteSpace = _.rtoken(/^\s*/); g.generalDelimiter = _.rtoken(/^(([\s\,]|at|@|on)+)/); var _C = {}; g.ctoken = function (keys) { var fn = _C[keys]; if (! fn) { var c = Date.CultureInfo.regexPatterns; var kx = keys.split(/\s+/), px = []; for (var i = 0; i < kx.length ; i++) { px.push(_.replace(_.rtoken(c[kx[i]]), kx[i])); } fn = _C[keys] = _.any.apply(null, px); } return fn; }; g.ctoken2 = function (key) { return _.rtoken(Date.CultureInfo.regexPatterns[key]); }; var cacheProcessRtoken = function (key, token, type, eachToken) { if (eachToken) { g[key] = _.cache(_.process(_.each(_.rtoken(token),_.optional(g.ctoken2(eachToken))), type)); } else { g[key] = _.cache(_.process(_.rtoken(token), type)); } }; var cacheProcessCtoken = function (token, type) { return _.cache(_.process(g.ctoken2(token), type)); }; var _F = {}; //function cache var _get = function (f) { _F[f] = (_F[f] || g.format(f)[0]); return _F[f]; }; g.allformats = function (fx) { var rx = []; if (fx instanceof Array) { for (var i = 0; i < fx.length; i++) { rx.push(_get(fx[i])); } } else { rx.push(_get(fx)); } return rx; }; g.formats = function (fx) { if (fx instanceof Array) { var rx = []; for (var i = 0 ; i < fx.length ; i++) { rx.push(_get(fx[i])); } return _.any.apply(null, rx); } else { return _get(fx); } }; var grammarFormats = { timeFormats: function(){ var i, RTokenKeys = [ "h", "hh", "H", "HH", "m", "mm", "s", "ss", "ss.s", "z", "zz" ], RToken = [ /^(0[0-9]|1[0-2]|[1-9])/, /^(0[0-9]|1[0-2])/, /^([0-1][0-9]|2[0-3]|[0-9])/, /^([0-1][0-9]|2[0-3])/, /^([0-5][0-9]|[0-9])/, /^[0-5][0-9]/, /^([0-5][0-9]|[0-9])/, /^[0-5][0-9]/, /^[0-5][0-9]\.[0-9]{1,3}/, /^((\+|\-)\s*\d\d\d\d)|((\+|\-)\d\d\:?\d\d)/, /^((\+|\-)\s*\d\d\d\d)|((\+|\-)\d\d\:?\d\d)/ ], tokens = [ t.hour, t.hour, t.hour, t.hour, t.minute, t.minute, t.second, t.second, t.secondAndMillisecond, t.timezone, t.timezone ]; for (i=0; i < RTokenKeys.length; i++) { cacheProcessRtoken(RTokenKeys[i], RToken[i], tokens[i]); } g.hms = _.cache(_.sequence([g.H, g.m, g.s], g.timePartDelimiter)); g.t = cacheProcessCtoken("shortMeridian", t.meridian); g.tt = cacheProcessCtoken("longMeridian", t.meridian); g.zzz = cacheProcessCtoken("timezone", t.timezone); g.timeSuffix = _.each(_.ignore(g.whiteSpace), _.set([ g.tt, g.zzz ])); g.time = _.each(_.optional(_.ignore(_.stoken("T"))), g.hms, g.timeSuffix); }, dateFormats: function () { // pre-loaded rules for different date part order preferences var _setfn = function () { return _.set(arguments, g.datePartDelimiter); }; var i, RTokenKeys = [ "d", "dd", "M", "MM", "y", "yy", "yyy", "yyyy" ], RToken = [ /^([0-2]\d|3[0-1]|\d)/, /^([0-2]\d|3[0-1])/, /^(1[0-2]|0\d|\d)/, /^(1[0-2]|0\d)/, /^(\d+)/, /^(\d\d)/, /^(\d\d?\d?\d?)/, /^(\d\d\d\d)/ ], tokens = [ t.day, t.day, t.month, t.month, t.year, t.year, t.year, t.year ], eachToken = [ "ordinalSuffix", "ordinalSuffix" ]; for (i=0; i < RTokenKeys.length; i++) { cacheProcessRtoken(RTokenKeys[i], RToken[i], tokens[i], eachToken[i]); } g.MMM = g.MMMM = _.cache(_.process(g.ctoken("jan feb mar apr may jun jul aug sep oct nov dec"), t.month)); g.ddd = g.dddd = _.cache(_.process(g.ctoken("sun mon tue wed thu fri sat"), function (s) { return function () { this.weekday = s; }; } )); g.day = _fn(g.d, g.dd); g.month = _fn(g.M, g.MMM); g.year = _fn(g.yyyy, g.yy); g.mdy = _setfn(g.ddd, g.month, g.day, g.year); g.ymd = _setfn(g.ddd, g.year, g.month, g.day); g.dmy = _setfn(g.ddd, g.day, g.month, g.year); g.date = function (s) { return ((g[Date.CultureInfo.dateElementOrder] || g.mdy).call(this, s)); }; }, relative: function () { // relative date / time expressions g.orientation = _.process(g.ctoken("past future"), function (s) { return function () { this.orient = s; }; } ); g.operator = _.process(g.ctoken("add subtract"), function (s) { return function () { this.operator = s; }; } ); g.rday = _.process(g.ctoken("yesterday tomorrow today now"), t.rday); g.unit = _.process(g.ctoken("second minute hour day week month year"), function (s) { return function () { this.unit = s; }; } ); } }; g.buildGrammarFormats = function () { // these need to be rebuilt every time the language changes. _C = {}; grammarFormats.timeFormats(); grammarFormats.dateFormats(); grammarFormats.relative(); g.value = _.process(_.rtoken(/^([-+]?\d+)?(st|nd|rd|th)?/), function (s) { return function () { this.value = s.replace(/\D/g, ""); }; } ); g.expression = _.set([g.rday, g.operator, g.value, g.unit, g.orientation, g.ddd, g.MMM ]); g.format = _.process(_.many( _.any( // translate format specifiers into grammar rules _.process( _.rtoken(/^(dd?d?d?(?!e)|MM?M?M?|yy?y?y?|hh?|HH?|mm?|ss?|tt?|zz?z?)/), function (fmt) { if (g[fmt]) { return g[fmt]; } else { throw $D.Parsing.Exception(fmt); } } ), // translate separator tokens into token rules _.process(_.rtoken(/^[^dMyhHmstz]+/), // all legal separators function (s) { return _.ignore(_.stoken(s)); } ) ) ), // construct the parser ... function (rules) { return _.process(_.each.apply(null, rules), t.finishExact); } ); // starting rule for general purpose grammar g._start = _.process(_.set([ g.date, g.time, g.expression ], g.generalDelimiter, g.whiteSpace), t.finish); }; g.buildGrammarFormats(); // parsing date format specifiers - ex: "h:m:s tt" // this little guy will generate a custom parser based // on the format string, ex: g.format("h:m:s tt") // check for these formats first g._formats = g.formats([ "\"yyyy-MM-ddTHH:mm:ssZ\"", "yyyy-MM-ddTHH:mm:ss.sz", "yyyy-MM-ddTHH:mm:ssZ", "yyyy-MM-ddTHH:mm:ssz", "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-ddTHH:mmZ", "yyyy-MM-ddTHH:mmz", "yyyy-MM-ddTHH:mm", "ddd, MMM dd, yyyy H:mm:ss tt", "ddd MMM d yyyy HH:mm:ss zzz", "MMddyyyy", "ddMMyyyy", "Mddyyyy", "ddMyyyy", "Mdyyyy", "dMyyyy", "yyyy", "Mdyy", "dMyy", "d" ]); // real starting rule: tries selected formats first, // then general purpose rule g.start = function (s) { try { var r = g._formats.call({}, s); if (r[1].length === 0) { return r; } } catch (e) {} return g._start.call({}, s); }; }()); ================================================ FILE: src/core/parsing_operators.js ================================================ (function () { var $P = Date.Parsing; var _ = $P.Operators = { // // Tokenizers // rtoken: function (r) { // regex token return function (s) { var mx = s.match(r); if (mx) { return ([ mx[0], s.substring(mx[0].length) ]); } else { throw new $P.Exception(s); } }; }, token: function () { // whitespace-eating token return function (s) { return _.rtoken(new RegExp("^\\s*" + s + "\\s*"))(s); }; }, stoken: function (s) { // string token return _.rtoken(new RegExp("^" + s)); }, // Atomic Operators until: function (p) { return function (s) { var qx = [], rx = null; while (s.length) { try { rx = p.call(this, s); } catch (e) { qx.push(rx[0]); s = rx[1]; continue; } break; } return [ qx, s ]; }; }, many: function (p) { return function (s) { var rx = [], r = null; while (s.length) { try { r = p.call(this, s); } catch (e) { return [ rx, s ]; } rx.push(r[0]); s = r[1]; } return [ rx, s ]; }; }, // generator operators -- see below optional: function (p) { return function (s) { var r = null; try { r = p.call(this, s); } catch (e) { return [ null, s ]; } return [ r[0], r[1] ]; }; }, not: function (p) { return function (s) { try { p.call(this, s); } catch (e) { return [null, s]; } throw new $P.Exception(s); }; }, ignore: function (p) { return p ? function (s) { var r = null; r = p.call(this, s); return [null, r[1]]; } : null; }, product: function () { var px = arguments[0], qx = Array.prototype.slice.call(arguments, 1), rx = []; for (var i = 0 ; i < px.length ; i++) { rx.push(_.each(px[i], qx)); } return rx; }, cache: function (rule) { var cache = {}, cache_length = 0, cache_keys = [], CACHE_MAX = Date.Config.CACHE_MAX || 100000, r = null; var cacheCheck = function () { if (cache_length === CACHE_MAX) { // kill several keys, don't want to have to do this all the time... for (var i=0; i < 10; i++) { var key = cache_keys.shift(); if (key) { delete cache[key]; cache_length--; } } } }; return function (s) { cacheCheck(); try { r = cache[s] = (cache[s] || rule.call(this, s)); } catch (e) { r = cache[s] = e; } cache_length++; cache_keys.push(s); if (r instanceof $P.Exception) { throw r; } else { return r; } }; }, // vector operators -- see below any: function () { var px = arguments; return function (s) { var r = null; for (var i = 0; i < px.length; i++) { if (px[i] == null) { continue; } try { r = (px[i].call(this, s)); } catch (e) { r = null; } if (r) { return r; } } throw new $P.Exception(s); }; }, each: function () { var px = arguments; return function (s) { var rx = [], r = null; for (var i = 0; i < px.length ; i++) { if (px[i] == null) { continue; } try { r = (px[i].call(this, s)); } catch (e) { throw new $P.Exception(s); } rx.push(r[0]); s = r[1]; } return [ rx, s]; }; }, all: function () { var px = arguments, _ = _; return _.each(_.optional(px)); }, // delimited operators sequence: function (px, d, c) { d = d || _.rtoken(/^\s*/); c = c || null; if (px.length === 1) { return px[0]; } return function (s) { var r = null, q = null; var rx = []; for (var i = 0; i < px.length ; i++) { try { r = px[i].call(this, s); } catch (e) { break; } rx.push(r[0]); try { q = d.call(this, r[1]); } catch (ex) { q = null; break; } s = q[1]; } if (!r) { throw new $P.Exception(s); } if (q) { throw new $P.Exception(q[1]); } if (c) { try { r = c.call(this, r[1]); } catch (ey) { throw new $P.Exception(r[1]); } } return [ rx, (r?r[1]:s) ]; }; }, // // Composite Operators // between: function (d1, p, d2) { d2 = d2 || d1; var _fn = _.each(_.ignore(d1), p, _.ignore(d2)); return function (s) { var rx = _fn.call(this, s); return [[rx[0][0], r[0][2]], rx[1]]; }; }, list: function (p, d, c) { d = d || _.rtoken(/^\s*/); c = c || null; return (p instanceof Array ? _.each(_.product(p.slice(0, -1), _.ignore(d)), p.slice(-1), _.ignore(c)) : _.each(_.many(_.each(p, _.ignore(d))), px, _.ignore(c))); }, set: function (px, d, c) { d = d || _.rtoken(/^\s*/); c = c || null; return function (s) { // r is the current match, best the current 'best' match // which means it parsed the most amount of input var r = null, p = null, q = null, rx = null, best = [[], s], last = false; // go through the rules in the given set for (var i = 0; i < px.length ; i++) { // last is a flag indicating whether this must be the last element // if there is only 1 element, then it MUST be the last one q = null; p = null; r = null; last = (px.length === 1); // first, we try simply to match the current pattern // if not, try the next pattern try { r = px[i].call(this, s); } catch (e) { continue; } // since we are matching against a set of elements, the first // thing to do is to add r[0] to matched elements rx = [[r[0]], r[1]]; // if we matched and there is still input to parse and // we don't already know this is the last element, // we're going to next check for the delimiter ... // if there's none, or if there's no input left to parse // than this must be the last element after all ... if (r[1].length > 0 && ! last) { try { q = d.call(this, r[1]); } catch (ex) { last = true; } } else { last = true; } // if we parsed the delimiter and now there's no more input, // that means we shouldn't have parsed the delimiter at all // so don't update r and mark this as the last element ... if (!last && q[1].length === 0) { last = true; } // so, if this isn't the last element, we're going to see if // we can get any more matches from the remaining (unmatched) // elements ... if (!last) { // build a list of the remaining rules we can match against, // i.e., all but the one we just matched against var qx = []; for (var j = 0; j < px.length ; j++) { if (i !== j) { qx.push(px[j]); } } // now invoke recursively set with the remaining input // note that we don't include the closing delimiter ... // we'll check for that ourselves at the end p = _.set(qx, d).call(this, q[1]); // if we got a non-empty set as a result ... // (otw rx already contains everything we want to match) if (p[0].length > 0) { // update current result, which is stored in rx ... // basically, pick up the remaining text from p[1] // and concat the result from p[0] so that we don't // get endless nesting ... rx[0] = rx[0].concat(p[0]); rx[1] = p[1]; } } // at this point, rx either contains the last matched element // or the entire matched set that starts with this element. // now we just check to see if this variation is better than // our best so far, in terms of how much of the input is parsed if (rx[1].length < best[1].length) { best = rx; } // if we've parsed all the input, then we're finished if (best[1].length === 0) { break; } } // so now we've either gone through all the patterns trying them // as the initial match; or we found one that parsed the entire // input string ... // if best has no matches, just return empty set ... if (best[0].length === 0) { return best; } // if a closing delimiter is provided, then we have to check it also if (c) { // we try this even if there is no remaining input because the pattern // may well be optional or match empty input ... try { q = c.call(this, best[1]); } catch (ey) { throw new $P.Exception(best[1]); } // it parsed ... be sure to update the best match remaining input best[1] = q[1]; } // if we're here, either there was no closing delimiter or we parsed it // so now we have the best match; just return it! return best; }; }, forward: function (gr, fname) { return function (s) { return gr[fname].call(this, s); }; }, // // Translation Operators // replace: function (rule, repl) { return function (s) { var r = rule.call(this, s); return [repl, r[1]]; }; }, process: function (rule, fn) { return function (s) { var r = rule.call(this, s); return [fn.call(this, r[0]), r[1]]; }; }, min: function (min, rule) { return function (s) { var rx = rule.call(this, s); if (rx[0].length < min) { throw new $P.Exception(s); } return rx; }; } }; // Generator Operators And Vector Operators // Generators are operators that have a signature of F(R) => R, // taking a given rule and returning another rule, such as // ignore, which parses a given rule and throws away the result. // Vector operators are those that have a signature of F(R1,R2,...) => R, // take a list of rules and returning a new rule, such as each. // Generator operators are converted (via the following _generator // function) into functions that can also take a list or array of rules // and return an array of new rules as though the function had been // called on each rule in turn (which is what actually happens). // This allows generators to be used with vector operators more easily. // Example: // each(ignore(foo, bar)) instead of each(ignore(foo), ignore(bar)) // This also turns generators into vector operators, which allows // constructs like: // not(cache(foo, bar)) var _generator = function (op) { function gen() { var args = null, rx = [], px, i; if (arguments.length > 1) { args = Array.prototype.slice.call(arguments); } else if (arguments[0] instanceof Array) { args = arguments[0]; } if (args) { px = args.shift(); if (px.length > 0) { args.unshift(px[i]); rx.push(op.apply(null, args)); args.shift(); return rx; } } else { return op.apply(null, arguments); } } return gen; }; var gx = "optional not ignore cache".split(/\s/); for (var i = 0 ; i < gx.length ; i++) { _[gx[i]] = _generator(_[gx[i]]); } var _vector = function (op) { return function () { if (arguments[0] instanceof Array) { return op.apply(null, arguments[0]); } else { return op.apply(null, arguments); } }; }; var vx = "each any all".split(/\s/); for (var j = 0 ; j < vx.length ; j++) { _[vx[j]] = _vector(_[vx[j]]); } }()); ================================================ FILE: src/core/parsing_translator.js ================================================ (function () { var $D = Date; var flattenAndCompact = function (ax) { var rx = []; for (var i = 0; i < ax.length; i++) { if (ax[i] instanceof Array) { rx = rx.concat(flattenAndCompact(ax[i])); } else { if (ax[i]) { rx.push(ax[i]); } } } return rx; }; var parseMeridian = function () { if (this.meridian && (this.hour || this.hour === 0)) { if (this.meridian === "a" && this.hour > 11 && Date.Config.strict24hr){ throw "Invalid hour and meridian combination"; } else if (this.meridian === "p" && this.hour < 12 && Date.Config.strict24hr){ throw "Invalid hour and meridian combination"; } else if (this.meridian === "p" && this.hour < 12) { this.hour = this.hour + 12; } else if (this.meridian === "a" && this.hour === 12) { this.hour = 0; } } }; var setDefaults = function () { var now = new Date(); if ((this.hour || this.minute) && (!this.month && !this.year && !this.day)) { this.day = now.getDate(); } if (!this.year) { this.year = now.getFullYear(); } if (!this.month && this.month !== 0) { this.month = now.getMonth(); } if (!this.day) { this.day = 1; } if (!this.hour) { this.hour = 0; } if (!this.minute) { this.minute = 0; } if (!this.second) { this.second = 0; } if (!this.millisecond) { this.millisecond = 0; } }; var finishUtils = { getToday: function () { if (this.now || "hour minute second".indexOf(this.unit) !== -1) { return new Date(); } else { return $D.today(); } }, setDaysFromWeekday: function (today, orient){ var gap; orient = orient || 1; this.unit = "day"; gap = ($D.getDayNumberFromName(this.weekday) - today.getDay()); this.days = gap ? ((gap + (orient * 7)) % 7) : (orient * 7); return this; }, setMonthsFromMonth: function (today, orient) { var gap; orient = orient || 1; this.unit = "month"; gap = (this.month - today.getMonth()); this.months = gap ? ((gap + (orient * 12)) % 12) : (orient * 12); this.month = null; return this; }, setDMYFromWeekday: function () { var d = Date[this.weekday](); this.day = d.getDate(); if (!this.month) { this.month = d.getMonth(); } this.year = d.getFullYear(); return this; }, setUnitValue: function (orient) { if (!this.value && this.operator && this.operator !== null && this[this.unit + "s"] && this[this.unit + "s"] !== null) { this[this.unit + "s"] = this[this.unit + "s"] + ((this.operator === "add") ? 1 : -1) + (this.value||0) * orient; } else if (this[this.unit + "s"] == null || this.operator != null) { if (!this.value) { this.value = 1; } this[this.unit + "s"] = this.value * orient; } }, generateDateFromWeeks: function () { var weekday = (this.weekday !== undefined) ? this.weekday : "today"; var d = Date[weekday]().addWeeks(this.weeks); if (this.now) { d.setTimeToNow(); } return d; } }; $D.Translator = { hour: function (s) { return function () { this.hour = Number(s); }; }, minute: function (s) { return function () { this.minute = Number(s); }; }, second: function (s) { return function () { this.second = Number(s); }; }, /* for ss.s format */ secondAndMillisecond: function (s) { return function () { var mx = s.match(/^([0-5][0-9])\.([0-9]{1,3})/); this.second = Number(mx[1]); this.millisecond = Number(mx[2]); }; }, meridian: function (s) { return function () { this.meridian = s.slice(0, 1).toLowerCase(); }; }, timezone: function (s) { return function () { var n = s.replace(/[^\d\+\-]/g, ""); if (n.length) { this.timezoneOffset = Number(n); } else { this.timezone = s.toLowerCase(); } }; }, day: function (x) { var s = x[0]; return function () { this.day = Number(s.match(/\d+/)[0]); if (this.day < 1) { throw "invalid day"; } }; }, month: function (s) { return function () { this.month = (s.length === 3) ? "jan feb mar apr may jun jul aug sep oct nov dec".indexOf(s)/4 : Number(s) - 1; if (this.month < 0) { throw "invalid month"; } }; }, year: function (s) { return function () { var n = Number(s); this.year = ((s.length > 2) ? n : (n + (((n + 2000) < Date.CultureInfo.twoDigitYearMax) ? 2000 : 1900))); }; }, rday: function (s) { return function () { switch (s) { case "yesterday": this.days = -1; break; case "tomorrow": this.days = 1; break; case "today": this.days = 0; break; case "now": this.days = 0; this.now = true; break; } }; }, finishExact: function (x) { var d; x = (x instanceof Array) ? x : [x]; for (var i = 0 ; i < x.length ; i++) { if (x[i]) { x[i].call(this); } } setDefaults.call(this); parseMeridian.call(this); if (this.day > $D.getDaysInMonth(this.year, this.month)) { throw new RangeError(this.day + " is not a valid value for days."); } d = new Date(this.year, this.month, this.day, this.hour, this.minute, this.second, this.millisecond); if (this.year < 100) { d.setFullYear(this.year); // means years less that 100 are process correctly. JS will parse it otherwise as 1900-1999. } if (this.timezone) { d.set({ timezone: this.timezone }); } else if (this.timezoneOffset) { d.set({ timezoneOffset: this.timezoneOffset }); } return d; }, finish: function (x) { var today, expression, orient, temp; x = (x instanceof Array) ? flattenAndCompact(x) : [ x ]; if (x.length === 0) { return null; } for (var i = 0 ; i < x.length ; i++) { if (typeof x[i] === "function") { x[i].call(this); } } if (this.now && !this.unit && !this.operator) { return new Date(); } else { today = finishUtils.getToday.call(this); } expression = !!(this.days && this.days !== null || this.orient || this.operator); orient = ((this.orient === "past" || this.operator === "subtract") ? -1 : 1); if (this.month && this.unit === "week") { this.value = this.month + 1; delete this.month; delete this.day; } if ((this.month || this.month === 0) && "year day hour minute second".indexOf(this.unit) !== -1) { if (!this.value) { this.value = this.month + 1; } this.month = null; expression = true; } if (!expression && this.weekday && !this.day && !this.days) { finishUtils.setDMYFromWeekday.call(this); } if (expression && this.weekday && this.unit !== "month" && this.unit !== "week") { finishUtils.setDaysFromWeekday.call(this, today, orient); } if (this.weekday && this.unit !== "week" && !this.day && !this.days) { temp = Date[this.weekday](); this.day = temp.getDate(); if (temp.getMonth() !== today.getMonth()) { this.month = temp.getMonth(); } } if (this.month && this.unit === "day" && this.operator) { if (!this.value) { this.value = (this.month + 1); } this.month = null; } if (this.value != null && this.month != null && this.year != null) { this.day = this.value * 1; } if (this.month && !this.day && this.value) { today.set({ day: this.value * 1 }); if (!expression) { this.day = this.value * 1; } } if (!this.month && this.value && this.unit === "month" && !this.now) { this.month = this.value; expression = true; } if (expression && (this.month || this.month === 0) && this.unit !== "year") { finishUtils.setMonthsFromMonth.call(this, today, orient); } if (!this.unit) { this.unit = "day"; } finishUtils.setUnitValue.call(this, orient); parseMeridian.call(this); if ((this.month || this.month === 0) && !this.day) { this.day = 1; } if (!this.orient && !this.operator && this.unit === "week" && this.value && !this.day && !this.month) { return Date.today().setWeek(this.value); } if (this.unit === "week" && this.weeks && !this.day && !this.month) { return finishUtils.generateDateFromWeeks.call(this); } if (expression && this.timezone && this.day && this.days) { this.day = this.days; } if (expression){ today.add(this); } else { today.set(this); } if (this.timezone) { this.timezone = this.timezone.toUpperCase(); var offset = $D.getTimezoneOffset(this.timezone); var timezone; if (today.hasDaylightSavingTime()) { // lets check that we're being sane with timezone setting timezone = $D.getTimezoneAbbreviation(offset, today.isDaylightSavingTime()); if (timezone !== this.timezone) { // bugger, we're in a place where things like EST vs EDT matters. if (today.isDaylightSavingTime()) { today.addHours(-1); } else { today.addHours(1); } } } today.setTimezoneOffset(offset); } return today; } }; }()); ================================================ FILE: src/core/sugarpak.js ================================================ /************************************************************* * SugarPak - Domain Specific Language - Syntactical Sugar * *************************************************************/ (function () { var $D = Date, $P = $D.prototype, $N = Number.prototype; // private $P._orient = +1; // private $P._nth = null; // private $P._is = false; // private $P._same = false; // private $P._isSecond = false; // private $N._dateElement = "days"; /** * Moves the date to the next instance of a date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.today().next().friday();
	Date.today().next().fri();
	Date.today().next().march();
	Date.today().next().mar();
	Date.today().next().week();
	
* * @return {Date} date */ $P.next = function () { this._move = true; this._orient = +1; return this; }; /** * Creates a new Date (Date.today()) and moves the date to the next instance of the date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.next().friday();
	Date.next().fri();
	Date.next().march();
	Date.next().mar();
	Date.next().week();
	
* * @return {Date} date */ $D.next = function () { return $D.today().next(); }; /** * Moves the date to the previous instance of a date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.today().last().friday();
	Date.today().last().fri();
	Date.today().last().march();
	Date.today().last().mar();
	Date.today().last().week();
	
* * @return {Date} date */ $P.last = $P.prev = $P.previous = function () { this._move = true; this._orient = -1; return this; }; /** * Creates a new Date (Date.today()) and moves the date to the previous instance of the date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()). * Example

	Date.last().friday();
	Date.last().fri();
	Date.previous().march();
	Date.prev().mar();
	Date.last().week();
	
* * @return {Date} date */ $D.last = $D.prev = $D.previous = function () { return $D.today().last(); }; /** * Performs a equality check when followed by either a month name, day name or .weekday() function. * Example

	Date.today().is().friday(); // true|false
	Date.today().is().fri();
	Date.today().is().march();
	Date.today().is().mar();
	
* * @return {Boolean} true|false */ $P.is = function () { this._is = true; return this; }; /** * Determines if two date objects occur on/in exactly the same instance of the subsequent date part function. * The function .same() must be followed by a date part function (example: .day(), .month(), .year(), etc). * * An optional Date can be passed in the date part function. If now date is passed as a parameter, 'Now' is used. * * The following example demonstrates how to determine if two dates fall on the exact same day. * * Example

	var d1 = Date.today(); // today at 00:00
	var d2 = new Date();   // exactly now.

	// Do they occur on the same day?
	d1.same().day(d2); // true
	
	// Do they occur on the same hour?
	d1.same().hour(d2); // false, unless d2 hour is '00' (midnight).
	
	// What if it's the same day, but one year apart?
	var nextYear = Date.today().add(1).year();

	d1.same().day(nextYear); // false, because the dates must occur on the exact same day. 
	
* * Scenario: Determine if a given date occurs during some week period 2 months from now. * * Example

	var future = Date.today().add(2).months();
	return someDate.same().week(future); // true|false;
	
* * @return {Boolean} true|false */ $P.same = function () { this._same = true; this._isSecond = false; return this; }; /** * Determines if the current date/time occurs during Today. Must be preceded by the .is() function. * Example

	someDate.is().today();    // true|false
	new Date().is().today();  // true
	Date.today().is().today();// true
	Date.today().add(-1).day().is().today(); // false
	
* * @return {Boolean} true|false */ $P.today = function () { return this.same().day(); }; /** * Determines if the current date is a weekday. This function must be preceded by the .is() function. * Example

	Date.today().is().weekday(); // true|false
	
* * @return {Boolean} true|false */ $P.weekday = function () { if (this._nth) { return df("Weekday").call(this); } if (this._move) { return this.addWeekdays(this._orient); } if (this._is) { this._is = false; return (!this.is().sat() && !this.is().sun()); } return false; }; /** * Determines if the current date is on the weekend. This function must be preceded by the .is() function. * Example

	Date.today().is().weekend(); // true|false
	
* * @return {Boolean} true|false */ $P.weekend = function () { if (this._is) { this._is = false; return (this.is().sat() || this.is().sun()); } return false; }; /** * Sets the Time of the current Date instance. A string "6:15 pm" or config object {hour:18, minute:15} are accepted. * Example

	// Set time to 6:15pm with a String
	Date.today().at("6:15pm");

	// Set time to 6:15pm with a config object
	Date.today().at({hour:18, minute:15});
	
* * @return {Date} date */ $P.at = function (time) { return (typeof time === "string") ? $D.parse(this.toString("d") + " " + time) : this.set(time); }; /** * Creates a new Date() and adds this (Number) to the date based on the preceding date element function (eg. second|minute|hour|day|month|year). * Example

	// Undeclared Numbers must be wrapped with parentheses. Requirment of JavaScript.
	(3).days().fromNow();
	(6).months().fromNow();

	// Declared Number variables do not require parentheses. 
	var n = 6;
	n.months().fromNow();
	
* * @return {Date} A new Date instance */ $N.fromNow = $N.after = function (date) { var c = {}; c[this._dateElement] = this; return ((!date) ? new Date() : date.clone()).add(c); }; /** * Creates a new Date() and subtract this (Number) from the date based on the preceding date element function (eg. second|minute|hour|day|month|year). * Example

	// Undeclared Numbers must be wrapped with parentheses. Requirment of JavaScript.
	(3).days().ago();
	(6).months().ago();

	// Declared Number variables do not require parentheses. 
	var n = 6;
	n.months().ago();
	
* * @return {Date} A new Date instance */ $N.ago = $N.before = function (date) { var c = {}, s = (this._dateElement[this._dateElement.length-1] !== "s") ? this._dateElement + "s" : this._dateElement; c[s] = this * -1; return ((!date) ? new Date() : date.clone()).add(c); }; // Do NOT modify the following string tokens. These tokens are used to build dynamic functions. // All culture-specific strings can be found in the CultureInfo files. var dx = ("sunday monday tuesday wednesday thursday friday saturday").split(/\s/), mx = ("january february march april may june july august september october november december").split(/\s/), px = ("Millisecond Second Minute Hour Day Week Month Year Quarter Weekday").split(/\s/), pxf = ("Milliseconds Seconds Minutes Hours Date Week Month FullYear Quarter").split(/\s/), nth = ("final first second third fourth fifth").split(/\s/), de; /** * Returns an object literal of all the date parts. * Example

	var o = new Date().toObject();
	
	// { year: 2008, month: 4, week: 20, day: 13, hour: 18, minute: 9, second: 32, millisecond: 812 }
	
	// The object properties can be referenced directly from the object.
	
	alert(o.day);  // alerts "13"
	alert(o.year); // alerts "2008"
	
* * @return {Date} An object literal representing the original date object. */ $P.toObject = function () { var o = {}; for (var i = 0; i < px.length; i++) { if (this["get" + pxf[i]]) { o[px[i].toLowerCase()] = this["get" + pxf[i]](); } } return o; }; /** * Returns a date created from an object literal. Ignores the .week property if set in the config. * Example

	var o = new Date().toObject();
	
	return Date.fromObject(o); // will return the same date. 

	var o2 = {month: 1, day: 20, hour: 18}; // birthday party!
	Date.fromObject(o2);
	
* * @return {Date} An object literal representing the original date object. */ $D.fromObject = function(config) { config.week = null; return Date.today().set(config); }; // Create day name functions and abbreviated day name functions (eg. monday(), friday(), fri()). var df = function (n) { return function () { if (this._is) { this._is = false; return this.getDay() === n; } if (this._move) { this._move = null; } if (this._nth !== null) { // If the .second() function was called earlier, remove the _orient // from the date, and then continue. // This is required because 'second' can be used in two different context. // // Example // // Date.today().add(1).second(); // Date.march().second().monday(); // // Things get crazy with the following... // Date.march().add(1).second().second().monday(); // but it works!! // if (this._isSecond) { this.addSeconds(this._orient * -1); } // make sure we reset _isSecond this._isSecond = false; var ntemp = this._nth; this._nth = null; var temp = this.clone().moveToLastDayOfMonth(); this.moveToNthOccurrence(n, ntemp); if (this > temp) { throw new RangeError($D.getDayName(n) + " does not occur " + ntemp + " times in the month of " + $D.getMonthName(temp.getMonth()) + " " + temp.getFullYear() + "."); } return this; } return this.moveToDayOfWeek(n, this._orient); }; }; var sdf = function (n) { return function () { var t = $D.today(), shift = n - t.getDay(); if (n === 0 && Date.CultureInfo.firstDayOfWeek === 1 && t.getDay() !== 0) { shift = shift + 7; } return t.addDays(shift); }; }; // Create month name functions and abbreviated month name functions (eg. january(), march(), mar()). var month_instance_functions = function (n) { return function () { if (this._is) { this._is = false; return this.getMonth() === n; } return this.moveToMonth(n, this._orient); }; }; var month_static_functions = function (n) { return function () { return $D.today().set({ month: n, day: 1 }); }; }; var processTerms = function (names, staticFunc, instanceFunc) { for (var i = 0; i < names.length; i++) { // Create constant static Name variables. $D[names[i].toUpperCase()] = $D[names[i].toUpperCase().substring(0, 3)] = i; // Create Name functions. $D[names[i]] = $D[names[i].substring(0, 3)] = staticFunc(i); // Create Name instance functions. $P[names[i]] = $P[names[i].substring(0, 3)] = instanceFunc(i); } }; processTerms(dx, sdf, df); processTerms(mx, month_static_functions, month_instance_functions); // Create date element functions and plural date element functions used with Date (eg. day(), days(), months()). var ef = function (j) { return function () { // if the .second() function was called earlier, the _orient // has alread been added. Just return this and reset _isSecond. if (this._isSecond) { this._isSecond = false; return this; } if (this._same) { this._same = this._is = false; var o1 = this.toObject(), o2 = (arguments[0] || new Date()).toObject(), v = "", k = j.toLowerCase(); // the substr trick with -1 doesn't work in IE8 or less k = (k[k.length-1] === "s") ? k.substring(0,k.length-1) : k; for (var m = (px.length - 1); m > -1; m--) { v = px[m].toLowerCase(); if (o1[v] !== o2[v]) { return false; } if (k === v) { break; } } return true; } if (j.substring(j.length - 1) !== "s") { j += "s"; } if (this._move) { this._move = null; } return this["add" + j](this._orient); }; }; var nf = function (n) { return function () { this._dateElement = n; return this; }; }; for (var k = 0; k < px.length; k++) { de = px[k].toLowerCase(); if(de !== "weekday") { // Create date element functions and plural date element functions used with Date (eg. day(), days(), months()). $P[de] = $P[de + "s"] = ef(px[k]); // Create date element functions and plural date element functions used with Number (eg. day(), days(), months()). $N[de] = $N[de + "s"] = nf(de + "s"); } } $P._ss = ef("Second"); var nthfn = function (n) { return function (dayOfWeek) { if (this._same) { return this._ss(arguments[0]); } if (dayOfWeek || dayOfWeek === 0) { return this.moveToNthOccurrence(dayOfWeek, n); } this._nth = n; // if the operator is 'second' add the _orient, then deal with it later... if (n === 2 && (dayOfWeek === undefined || dayOfWeek === null)) { this._isSecond = true; return this.addSeconds(this._orient); } return this; }; }; for (var l = 0; l < nth.length; l++) { $P[nth[l]] = (l === 0) ? nthfn(-1) : nthfn(l); } }()); ================================================ FILE: src/core/time_period.js ================================================ (function () { "use strict"; var attrs = ["years", "months", "days", "hours", "minutes", "seconds", "milliseconds"]; var gFn = function (attr) { return function () { return this[attr]; }; }; var sFn = function (attr) { return function (val) { this[attr] = val; return this; }; }; var addSetFuncs = function (context, attrs) { for (var i = 0; i < attrs.length ; i++) { var $a = attrs[i], $b = $a.slice(0, 1).toUpperCase() + $a.slice(1); context.prototype[$a] = 0; context.prototype["get" + $b] = gFn($a); context.prototype["set" + $b] = sFn($a); } }; var setMonthsAndYears = function (orient, d1, d2, context) { function inc() { d1.addMonths(-orient); context.months++; if (context.months === 12) { context.years++; context.months = 0; } } if (orient === +1) { while (d1 > d2) { inc(); } } else { while (d1 < d2) { inc(); } } context.months--; context.months *= orient; context.years *= orient; }; var adjustForDST = function(orient, startDate, endDate) { var hasDSTMismatch = (false === (startDate.isDaylightSavingTime() === endDate.isDaylightSavingTime())); if (hasDSTMismatch && orient === 1) { startDate.addHours(-1); } else if (hasDSTMismatch) { startDate.addHours(1); } }; /** * TimePeriod(startDate, endDate); * TimePeriod(years, months, days, hours, minutes, seconds, milliseconds); */ var TimePeriod = function (years, months, days, hours, minutes, seconds, milliseconds) { if (arguments.length === 7) { this.set(years, months, days, hours, minutes, seconds, milliseconds); } else if (arguments.length === 2 && arguments[0] instanceof Date && arguments[1] instanceof Date) { var startDate = arguments[0].clone(); var endDate = arguments[1].clone(); var orient = (startDate > endDate) ? +1 : -1; this.dates = { start: arguments[0].clone(), end: arguments[1].clone() }; setMonthsAndYears(orient, startDate, endDate, this); adjustForDST(orient, startDate, endDate); // // TODO - adjust for DST var diff = endDate - startDate; if (diff !== 0) { var ts = new TimeSpan(diff); this.set(this.years, this.months, ts.getDays(), ts.getHours(), ts.getMinutes(), ts.getSeconds(), ts.getMilliseconds()); } } return this; }; // create all the set functions. addSetFuncs(TimePeriod, attrs); TimePeriod.prototype.set = function (years, months, days, hours, minutes, seconds, milliseconds){ this.setYears(years || this.getYears()); this.setMonths(months || this.getMonths()); this.setDays(days || this.getDays()); this.setHours(hours || this.getHours()); this.setMinutes(minutes || this.getMinutes()); this.setSeconds(seconds || this.getSeconds()); this.setMilliseconds(milliseconds || this.getMilliseconds()); }; Date.TimePeriod = TimePeriod; if (typeof window !== "undefined") { // keeping API compatible for v1.x window.TimePeriod = TimePeriod; } }()); ================================================ FILE: src/core/time_span.js ================================================ (function () { "use strict"; var gFn = function (attr) { return function () { return this[attr]; }; }; var sFn = function (attr) { return function (val) { this[attr] = val; return this; }; }; var attrs = ["years", "months", "days", "hours", "minutes", "seconds", "milliseconds"]; var addSetFuncs = function (context, attrs) { for (var i = 0; i < attrs.length ; i++) { var $a = attrs[i], $b = $a.slice(0, 1).toUpperCase() + $a.slice(1); context.prototype[$a] = 0; context.prototype["get" + $b] = gFn($a); context.prototype["set" + $b] = sFn($a); } }; /** * new TimeSpan(milliseconds); * new TimeSpan(days, hours, minutes, seconds); * new TimeSpan(days, hours, minutes, seconds, milliseconds); */ var TimeSpan = function (days, hours, minutes, seconds, milliseconds) { if (arguments.length === 1 && typeof days === "number") { var orient = (days < 0) ? -1 : +1; var millsLeft = Math.abs(days); this.setDays(Math.floor(millsLeft / 86400000) * orient); millsLeft = millsLeft % 86400000; this.setHours(Math.floor(millsLeft / 3600000) * orient); millsLeft = millsLeft % 3600000; this.setMinutes(Math.floor(millsLeft / 60000) * orient); millsLeft = millsLeft % 60000; this.setSeconds(Math.floor(millsLeft / 1000) * orient); millsLeft = millsLeft % 1000; this.setMilliseconds(millsLeft * orient); } else { this.set(days, hours, minutes, seconds, milliseconds); } this.getTotalMilliseconds = function () { return (this.getDays() * 86400000) + (this.getHours() * 3600000) + (this.getMinutes() * 60000) + (this.getSeconds() * 1000); }; this.compareTo = function (time) { var t1 = new Date(1970, 1, 1, this.getHours(), this.getMinutes(), this.getSeconds()), t2; if (time === null) { t2 = new Date(1970, 1, 1, 0, 0, 0); } else { t2 = new Date(1970, 1, 1, time.getHours(), time.getMinutes(), time.getSeconds()); } return (t1 < t2) ? -1 : (t1 > t2) ? 1 : 0; }; this.equals = function (time) { return (this.compareTo(time) === 0); }; this.add = function (time) { return (time === null) ? this : this.addSeconds(time.getTotalMilliseconds() / 1000); }; this.subtract = function (time) { return (time === null) ? this : this.addSeconds(-time.getTotalMilliseconds() / 1000); }; this.addDays = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 86400000)); }; this.addHours = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 3600000)); }; this.addMinutes = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 60000)); }; this.addSeconds = function (n) { return new TimeSpan(this.getTotalMilliseconds() + (n * 1000)); }; this.addMilliseconds = function (n) { return new TimeSpan(this.getTotalMilliseconds() + n); }; this.get12HourHour = function () { return (this.getHours() > 12) ? this.getHours() - 12 : (this.getHours() === 0) ? 12 : this.getHours(); }; this.getDesignator = function () { return (this.getHours() < 12) ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator; }; this.toString = function (format) { this._toString = function () { if (this.getDays() !== null && this.getDays() > 0) { return this.getDays() + "." + this.getHours() + ":" + this.p(this.getMinutes()) + ":" + this.p(this.getSeconds()); } else { return this.getHours() + ":" + this.p(this.getMinutes()) + ":" + this.p(this.getSeconds()); } }; this.p = function (s) { return (s.toString().length < 2) ? "0" + s : s; }; var me = this; return format ? format.replace(/dd?|HH?|hh?|mm?|ss?|tt?/g, function (format) { switch (format) { case "d": return me.getDays(); case "dd": return me.p(me.getDays()); case "H": return me.getHours(); case "HH": return me.p(me.getHours()); case "h": return me.get12HourHour(); case "hh": return me.p(me.get12HourHour()); case "m": return me.getMinutes(); case "mm": return me.p(me.getMinutes()); case "s": return me.getSeconds(); case "ss": return me.p(me.getSeconds()); case "t": return ((me.getHours() < 12) ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator).substring(0, 1); case "tt": return (me.getHours() < 12) ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator; } } ) : this._toString(); }; return this; }; addSetFuncs(TimeSpan, attrs.slice(2)); TimeSpan.prototype.set = function (days, hours, minutes, seconds, milliseconds){ this.setDays(days || this.getDays()); this.setHours(hours || this.getHours()); this.setMinutes(minutes || this.getMinutes()); this.setSeconds(seconds || this.getSeconds()); this.setMilliseconds(milliseconds || this.getMilliseconds()); }; /** * Gets the time of day for this date instances. * @return {TimeSpan} TimeSpan */ Date.prototype.getTimeOfDay = function () { return new TimeSpan(0, this.getHours(), this.getMinutes(), this.getSeconds(), this.getMilliseconds()); }; Date.TimeSpan = TimeSpan; if (typeof window !== "undefined" ) { // keeping API compatible for v1.x window.TimeSpan = TimeSpan; } }()); ================================================ FILE: src/i18n/af-ZA.js ================================================ /* * DateJS Culture String File * Country Code: af-ZA * Name: Afrikaans (South Africa) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["af-ZA"] = { "name": "af-ZA", "englishName": "Afrikaans (South Africa)", "nativeName": "Afrikaans (Suid Afrika)", "Sunday": "Sondag", "Monday": "Maandag", "Tuesday": "Dinsdag", "Wednesday": "Woensdag", "Thursday": "Donderdag", "Friday": "Vrydag", "Saturday": "Saterdag", "Sun": "Son", "Mon": "Maan", "Tue": "Dins", "Wed": "Woen", "Thu": "Dond", "Fri": "Vry", "Sat": "Sat", "Su": "So", "Mo": "Ma", "Tu": "Di", "We": "Wo", "Th": "Do", "Fr": "Vr", "Sa": "Sa", "S_Sun_Initial": "S", "M_Mon_Initial": "M", "T_Tue_Initial": "D", "W_Wed_Initial": "W", "T_Thu_Initial": "D", "F_Fri_Initial": "V", "S_Sat_Initial": "S", "January": "Januarie", "February": "Februarie", "March": "Maart", "April": "April", "May": "Mei", "June": "Junie", "July": "Julie", "August": "Augustus", "September": "September", "October": "Oktober", "November": "November", "December": "Desember", "Jan_Abbr": "Jan", "Feb_Abbr": "Feb", "Mar_Abbr": "Mar", "Apr_Abbr": "Apr", "May_Abbr": "Mei", "Jun_Abbr": "Jun", "Jul_Abbr": "Jul", "Aug_Abbr": "Aug", "Sep_Abbr": "Sep", "Oct_Abbr": "Okt", "Nov_Abbr": "Nov", "Dec_Abbr": "Des", "AM": "", "PM": "nm", "firstDayOfWeek": 0, "twoDigitYearMax": 2029, "mdy": "ymd", "M/d/yyyy": "yyyy/MM/dd", "dddd, MMMM dd, yyyy": "dd MMMM yyyy", "h:mm tt": "hh:mm tt", "h:mm:ss tt": "hh:mm:ss tt", "dddd, MMMM dd, yyyy h:mm:ss tt": "dd MMMM yyyy hh:mm:ss tt", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "dd MMMM", "MMMM, yyyy": "MMMM yyyy", "/jan(uary)?/": "jan(uarie)?", "/feb(ruary)?/": "feb(ruarie)?", "/mar(ch)?/": "maart", "/apr(il)?/": "apr(il)?", "/may/": "mei", "/jun(e)?/": "jun(ie)?", "/jul(y)?/": "jul(ie)?", "/aug(ust)?/": "aug(ustus)?", "/sep(t(ember)?)?/": "sep(t(ember)?)?", "/oct(ober)?/": "okt(ober)?", "/nov(ember)?/": "nov(ember)?", "/dec(ember)?/": "des(ember)?", "/^su(n(day)?)?/": "^so(n(dag)?)?", "/^mo(n(day)?)?/": "^ma(an(dag)?)?", "/^tu(e(s(day)?)?)?/": "^di(ns(dag)?)?", "/^we(d(nesday)?)?/": "^wo(en(sdag)?)?", "/^th(u(r(s(day)?)?)?)?/": "^do(nd(erdag)?)?", "/^fr(i(day)?)?/": "^vr(y(dag)?)?", "/^sa(t(urday)?)?/": "^sa(t(erdag)?)?", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "af-ZA"; ================================================ FILE: src/i18n/ar-AE.js ================================================ /* * DateJS Culture String File * Country Code: ar-AE * Name: Arabic (U.A.E.) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["ar-AE"] = { "name": "ar-AE", "englishName": "Arabic (U.A.E.)", "nativeName": "العربية (الإمارات العربية المتحدة)", "Sunday": "الاحد", "Monday": "الاثنين", "Tuesday": "الثلاثاء", "Wednesday": "الاربعاء", "Thursday": "الخميس", "Friday": "الجمعة", "Saturday": "السبت", "Sun": "الاحد", "Mon": "الاثنين", "Tue": "الثلاثاء", "Wed": "الاربعاء", "Thu": "الخميس", "Fri": "الجمعة", "Sat": "السبت", "Su": "أ", "Mo": "ا", "Tu": "ث", "We": "أ", "Th": "خ", "Fr": "ج", "Sa": "س", "S_Sun_Initial": "أ", "M_Mon_Initial": "ا", "T_Tue_Initial": "ث", "W_Wed_Initial": "أ", "T_Thu_Initial": "خ", "F_Fri_Initial": "ج", "S_Sat_Initial": "س", "January": "يناير", "February": "فبراير", "March": "مارس", "April": "ابريل", "May": "مايو", "June": "يونيو", "July": "يوليو", "August": "اغسطس", "September": "سبتمبر", "October": "اكتوبر", "November": "نوفمبر", "December": "ديسمبر", "Jan_Abbr": "يناير", "Feb_Abbr": "فبراير", "Mar_Abbr": "مارس", "Apr_Abbr": "ابريل", "May_Abbr": "مايو", "Jun_Abbr": "يونيو", "Jul_Abbr": "يوليو", "Aug_Abbr": "اغسطس", "Sep_Abbr": "سبتمبر", "Oct_Abbr": "اكتوبر", "Nov_Abbr": "نوفمبر", "Dec_Abbr": "ديسمبر", "AM": "ص", "PM": "م", "firstDayOfWeek": 6, "twoDigitYearMax": 2029, "mdy": "dmy", "M/d/yyyy": "dd/MM/yyyy", "dddd, MMMM dd, yyyy": "dd MMMM, yyyy", "h:mm tt": "hh:mm tt", "h:mm:ss tt": "hh:mm:ss tt", "dddd, MMMM dd, yyyy h:mm:ss tt": "dd MMMM, yyyy hh:mm:ss tt", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "dd MMMM", "MMMM, yyyy": "MMMM, yyyy", "/jan(uary)?/": "يناير", "/feb(ruary)?/": "فبراير", "/mar(ch)?/": "مارس", "/apr(il)?/": "ابريل", "/may/": "مايو", "/jun(e)?/": "يونيو", "/jul(y)?/": "يوليو", "/aug(ust)?/": "اغسطس", "/sep(t(ember)?)?/": "سبتمبر", "/oct(ober)?/": "اكتوبر", "/nov(ember)?/": "نوفمبر", "/dec(ember)?/": "ديسمبر", "/^su(n(day)?)?/": "^الاحد", "/^mo(n(day)?)?/": "^ا(1)?", "/^tu(e(s(day)?)?)?/": "^الثلاثاء", "/^we(d(nesday)?)?/": "^الاربعاء", "/^th(u(r(s(day)?)?)?)?/": "^الخميس", "/^fr(i(day)?)?/": "^الجمعة", "/^sa(t(urday)?)?/": "^السبت", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "ar-AE"; ================================================ FILE: src/i18n/ar-BH.js ================================================ /* * DateJS Culture String File * Country Code: ar-BH * Name: Arabic (Bahrain) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["ar-BH"] = { "name": "ar-BH", "englishName": "Arabic (Bahrain)", "nativeName": "العربية (البحرين)", "Sunday": "الاحد", "Monday": "الاثنين", "Tuesday": "الثلاثاء", "Wednesday": "الاربعاء", "Thursday": "الخميس", "Friday": "الجمعة", "Saturday": "السبت", "Sun": "الاحد", "Mon": "الاثنين", "Tue": "الثلاثاء", "Wed": "الاربعاء", "Thu": "الخميس", "Fri": "الجمعة", "Sat": "السبت", "Su": "أ", "Mo": "ا", "Tu": "ث", "We": "أ", "Th": "خ", "Fr": "ج", "Sa": "س", "S_Sun_Initial": "أ", "M_Mon_Initial": "ا", "T_Tue_Initial": "ث", "W_Wed_Initial": "أ", "T_Thu_Initial": "خ", "F_Fri_Initial": "ج", "S_Sat_Initial": "س", "January": "يناير", "February": "فبراير", "March": "مارس", "April": "ابريل", "May": "مايو", "June": "يونيو", "July": "يوليو", "August": "اغسطس", "September": "سبتمبر", "October": "اكتوبر", "November": "نوفمبر", "December": "ديسمبر", "Jan_Abbr": "يناير", "Feb_Abbr": "فبراير", "Mar_Abbr": "مارس", "Apr_Abbr": "ابريل", "May_Abbr": "مايو", "Jun_Abbr": "يونيو", "Jul_Abbr": "يوليو", "Aug_Abbr": "اغسطس", "Sep_Abbr": "سبتمبر", "Oct_Abbr": "اكتوبر", "Nov_Abbr": "نوفمبر", "Dec_Abbr": "ديسمبر", "AM": "ص", "PM": "م", "firstDayOfWeek": 6, "twoDigitYearMax": 2029, "mdy": "dmy", "M/d/yyyy": "dd/MM/yyyy", "dddd, MMMM dd, yyyy": "dd MMMM, yyyy", "h:mm tt": "hh:mm tt", "h:mm:ss tt": "hh:mm:ss tt", "dddd, MMMM dd, yyyy h:mm:ss tt": "dd MMMM, yyyy hh:mm:ss tt", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "dd MMMM", "MMMM, yyyy": "MMMM, yyyy", "/jan(uary)?/": "يناير", "/feb(ruary)?/": "فبراير", "/mar(ch)?/": "مارس", "/apr(il)?/": "ابريل", "/may/": "مايو", "/jun(e)?/": "يونيو", "/jul(y)?/": "يوليو", "/aug(ust)?/": "اغسطس", "/sep(t(ember)?)?/": "سبتمبر", "/oct(ober)?/": "اكتوبر", "/nov(ember)?/": "نوفمبر", "/dec(ember)?/": "ديسمبر", "/^su(n(day)?)?/": "^الاحد", "/^mo(n(day)?)?/": "^ا(1)?", "/^tu(e(s(day)?)?)?/": "^الثلاثاء", "/^we(d(nesday)?)?/": "^الاربعاء", "/^th(u(r(s(day)?)?)?)?/": "^الخميس", "/^fr(i(day)?)?/": "^الجمعة", "/^sa(t(urday)?)?/": "^السبت", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "ar-BH"; ================================================ FILE: src/i18n/ar-DZ.js ================================================ /* * DateJS Culture String File * Country Code: ar-DZ * Name: Arabic (Algeria) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["ar-DZ"] = { "name": "ar-DZ", "englishName": "Arabic (Algeria)", "nativeName": "العربية (الجزائر)", "Sunday": "الاحد", "Monday": "الاثنين", "Tuesday": "الثلاثاء", "Wednesday": "الاربعاء", "Thursday": "الخميس", "Friday": "الجمعة", "Saturday": "السبت", "Sun": "الاحد", "Mon": "الاثنين", "Tue": "الثلاثاء", "Wed": "الاربعاء", "Thu": "الخميس", "Fri": "الجمعة", "Sat": "السبت", "Su": "أ", "Mo": "ا", "Tu": "ث", "We": "أ", "Th": "خ", "Fr": "ج", "Sa": "س", "S_Sun_Initial": "أ", "M_Mon_Initial": "ا", "T_Tue_Initial": "ث", "W_Wed_Initial": "أ", "T_Thu_Initial": "خ", "F_Fri_Initial": "ج", "S_Sat_Initial": "س", "January": "جانفييه", "February": "فيفرييه", "March": "مارس", "April": "أفريل", "May": "مي", "June": "جوان", "July": "جوييه", "August": "أوت", "September": "سبتمبر", "October": "اكتوبر", "November": "نوفمبر", "December": "ديسمبر", "Jan_Abbr": "جانفييه", "Feb_Abbr": "فيفرييه", "Mar_Abbr": "مارس", "Apr_Abbr": "أفريل", "May_Abbr": "مي", "Jun_Abbr": "جوان", "Jul_Abbr": "جوييه", "Aug_Abbr": "أوت", "Sep_Abbr": "سبتمبر", "Oct_Abbr": "اكتوبر", "Nov_Abbr": "نوفمبر", "Dec_Abbr": "ديسمبر", "AM": "ص", "PM": "م", "firstDayOfWeek": 6, "twoDigitYearMax": 2029, "mdy": "dmy", "M/d/yyyy": "dd-MM-yyyy", "dddd, MMMM dd, yyyy": "dd MMMM, yyyy", "h:mm tt": "H:mm", "h:mm:ss tt": "H:mm:ss", "dddd, MMMM dd, yyyy h:mm:ss tt": "dd MMMM, yyyy H:mm:ss", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "dd MMMM", "MMMM, yyyy": "MMMM, yyyy", "/jan(uary)?/": "جانفييه", "/feb(ruary)?/": "فيفرييه", "/mar(ch)?/": "مارس", "/apr(il)?/": "أفريل", "/may/": "مي", "/jun(e)?/": "جوان", "/jul(y)?/": "جوييه", "/aug(ust)?/": "أوت", "/sep(t(ember)?)?/": "سبتمبر", "/oct(ober)?/": "اكتوبر", "/nov(ember)?/": "نوفمبر", "/dec(ember)?/": "ديسمبر", "/^su(n(day)?)?/": "^الاحد", "/^mo(n(day)?)?/": "^ا(1)?", "/^tu(e(s(day)?)?)?/": "^الثلاثاء", "/^we(d(nesday)?)?/": "^الاربعاء", "/^th(u(r(s(day)?)?)?)?/": "^الخميس", "/^fr(i(day)?)?/": "^الجمعة", "/^sa(t(urday)?)?/": "^السبت", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "ar-DZ"; ================================================ FILE: src/i18n/ar-EG.js ================================================ /* * DateJS Culture String File * Country Code: ar-EG * Name: Arabic (Egypt) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["ar-EG"] = { "name": "ar-EG", "englishName": "Arabic (Egypt)", "nativeName": "العربية (مصر)", "Sunday": "الاحد", "Monday": "الاثنين", "Tuesday": "الثلاثاء", "Wednesday": "الاربعاء", "Thursday": "الخميس", "Friday": "الجمعة", "Saturday": "السبت", "Sun": "الاحد", "Mon": "الاثنين", "Tue": "الثلاثاء", "Wed": "الاربعاء", "Thu": "الخميس", "Fri": "الجمعة", "Sat": "السبت", "Su": "أ", "Mo": "ا", "Tu": "ث", "We": "أ", "Th": "خ", "Fr": "ج", "Sa": "س", "S_Sun_Initial": "أ", "M_Mon_Initial": "ا", "T_Tue_Initial": "ث", "W_Wed_Initial": "أ", "T_Thu_Initial": "خ", "F_Fri_Initial": "ج", "S_Sat_Initial": "س", "January": "يناير", "February": "فبراير", "March": "مارس", "April": "ابريل", "May": "مايو", "June": "يونيو", "July": "يوليو", "August": "اغسطس", "September": "سبتمبر", "October": "اكتوبر", "November": "نوفمبر", "December": "ديسمبر", "Jan_Abbr": "يناير", "Feb_Abbr": "فبراير", "Mar_Abbr": "مارس", "Apr_Abbr": "ابريل", "May_Abbr": "مايو", "Jun_Abbr": "يونيو", "Jul_Abbr": "يوليو", "Aug_Abbr": "اغسطس", "Sep_Abbr": "سبتمبر", "Oct_Abbr": "اكتوبر", "Nov_Abbr": "نوفمبر", "Dec_Abbr": "ديسمبر", "AM": "ص", "PM": "م", "firstDayOfWeek": 6, "twoDigitYearMax": 2029, "mdy": "dmy", "M/d/yyyy": "dd/MM/yyyy", "dddd, MMMM dd, yyyy": "dd MMMM, yyyy", "h:mm tt": "hh:mm tt", "h:mm:ss tt": "hh:mm:ss tt", "dddd, MMMM dd, yyyy h:mm:ss tt": "dd MMMM, yyyy hh:mm:ss tt", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "dd MMMM", "MMMM, yyyy": "MMMM, yyyy", "/jan(uary)?/": "يناير", "/feb(ruary)?/": "فبراير", "/mar(ch)?/": "مارس", "/apr(il)?/": "ابريل", "/may/": "مايو", "/jun(e)?/": "يونيو", "/jul(y)?/": "يوليو", "/aug(ust)?/": "اغسطس", "/sep(t(ember)?)?/": "سبتمبر", "/oct(ober)?/": "اكتوبر", "/nov(ember)?/": "نوفمبر", "/dec(ember)?/": "ديسمبر", "/^su(n(day)?)?/": "^الاحد", "/^mo(n(day)?)?/": "^ا(1)?", "/^tu(e(s(day)?)?)?/": "^الثلاثاء", "/^we(d(nesday)?)?/": "^الاربعاء", "/^th(u(r(s(day)?)?)?)?/": "^الخميس", "/^fr(i(day)?)?/": "^الجمعة", "/^sa(t(urday)?)?/": "^السبت", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "ar-EG"; ================================================ FILE: src/i18n/ar-IQ.js ================================================ /* * DateJS Culture String File * Country Code: ar-IQ * Name: Arabic (Iraq) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["ar-IQ"] = { "name": "ar-IQ", "englishName": "Arabic (Iraq)", "nativeName": "العربية (العراق)", "Sunday": "الاحد", "Monday": "الاثنين", "Tuesday": "الثلاثاء", "Wednesday": "الاربعاء", "Thursday": "الخميس", "Friday": "الجمعة", "Saturday": "السبت", "Sun": "الاحد", "Mon": "الاثنين", "Tue": "الثلاثاء", "Wed": "الاربعاء", "Thu": "الخميس", "Fri": "الجمعة", "Sat": "السبت", "Su": "أ", "Mo": "ا", "Tu": "ث", "We": "أ", "Th": "خ", "Fr": "ج", "Sa": "س", "S_Sun_Initial": "أ", "M_Mon_Initial": "ا", "T_Tue_Initial": "ث", "W_Wed_Initial": "أ", "T_Thu_Initial": "خ", "F_Fri_Initial": "ج", "S_Sat_Initial": "س", "January": "كانون الثاني", "February": "شباط", "March": "آذار", "April": "نيسان", "May": "أيار", "June": "حزيران", "July": "تموز", "August": "آب", "September": "أيلول", "October": "تشرين الأول", "November": "تشرين الثاني", "December": "كانون الأول", "Jan_Abbr": "كانون الثاني", "Feb_Abbr": "شباط", "Mar_Abbr": "آذار", "Apr_Abbr": "نيسان", "May_Abbr": "أيار", "Jun_Abbr": "حزيران", "Jul_Abbr": "تموز", "Aug_Abbr": "آب", "Sep_Abbr": "أيلول", "Oct_Abbr": "تشرين الأول", "Nov_Abbr": "تشرين الثاني", "Dec_Abbr": "كانون الأول", "AM": "ص", "PM": "م", "firstDayOfWeek": 6, "twoDigitYearMax": 2029, "mdy": "dmy", "M/d/yyyy": "dd/MM/yyyy", "dddd, MMMM dd, yyyy": "dd MMMM, yyyy", "h:mm tt": "hh:mm tt", "h:mm:ss tt": "hh:mm:ss tt", "dddd, MMMM dd, yyyy h:mm:ss tt": "dd MMMM, yyyy hh:mm:ss tt", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "dd MMMM", "MMMM, yyyy": "MMMM, yyyy", "/jan(uary)?/": "كانون الثاني", "/feb(ruary)?/": "شباط", "/mar(ch)?/": "آذار", "/apr(il)?/": "نيسان", "/may/": "أيار", "/jun(e)?/": "حزيران", "/jul(y)?/": "تموز", "/aug(ust)?/": "آب", "/sep(t(ember)?)?/": "أيلول", "/oct(ober)?/": "تشرين الأول", "/nov(ember)?/": "تشرين الثاني", "/dec(ember)?/": "كانون الأول", "/^su(n(day)?)?/": "^الاحد", "/^mo(n(day)?)?/": "^ا(1)?", "/^tu(e(s(day)?)?)?/": "^الثلاثاء", "/^we(d(nesday)?)?/": "^الاربعاء", "/^th(u(r(s(day)?)?)?)?/": "^الخميس", "/^fr(i(day)?)?/": "^الجمعة", "/^sa(t(urday)?)?/": "^السبت", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "ar-IQ"; ================================================ FILE: src/i18n/ar-JO.js ================================================ /* * DateJS Culture String File * Country Code: ar-JO * Name: Arabic (Jordan) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["ar-JO"] = { "name": "ar-JO", "englishName": "Arabic (Jordan)", "nativeName": "العربية (الأردن)", "Sunday": "الاحد", "Monday": "الاثنين", "Tuesday": "الثلاثاء", "Wednesday": "الاربعاء", "Thursday": "الخميس", "Friday": "الجمعة", "Saturday": "السبت", "Sun": "الاحد", "Mon": "الاثنين", "Tue": "الثلاثاء", "Wed": "الاربعاء", "Thu": "الخميس", "Fri": "الجمعة", "Sat": "السبت", "Su": "أ", "Mo": "ا", "Tu": "ث", "We": "أ", "Th": "خ", "Fr": "ج", "Sa": "س", "S_Sun_Initial": "أ", "M_Mon_Initial": "ا", "T_Tue_Initial": "ث", "W_Wed_Initial": "أ", "T_Thu_Initial": "خ", "F_Fri_Initial": "ج", "S_Sat_Initial": "س", "January": "كانون الثاني", "February": "شباط", "March": "آذار", "April": "نيسان", "May": "أيار", "June": "حزيران", "July": "تموز", "August": "آب", "September": "أيلول", "October": "تشرين الأول", "November": "تشرين الثاني", "December": "كانون الأول", "Jan_Abbr": "كانون الثاني", "Feb_Abbr": "شباط", "Mar_Abbr": "آذار", "Apr_Abbr": "نيسان", "May_Abbr": "أيار", "Jun_Abbr": "حزيران", "Jul_Abbr": "تموز", "Aug_Abbr": "آب", "Sep_Abbr": "أيلول", "Oct_Abbr": "تشرين الأول", "Nov_Abbr": "تشرين الثاني", "Dec_Abbr": "كانون الأول", "AM": "ص", "PM": "م", "firstDayOfWeek": 6, "twoDigitYearMax": 2029, "mdy": "dmy", "M/d/yyyy": "dd/MM/yyyy", "dddd, MMMM dd, yyyy": "dd MMMM, yyyy", "h:mm tt": "hh:mm tt", "h:mm:ss tt": "hh:mm:ss tt", "dddd, MMMM dd, yyyy h:mm:ss tt": "dd MMMM, yyyy hh:mm:ss tt", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "dd MMMM", "MMMM, yyyy": "MMMM, yyyy", "/jan(uary)?/": "كانون الثاني", "/feb(ruary)?/": "شباط", "/mar(ch)?/": "آذار", "/apr(il)?/": "نيسان", "/may/": "أيار", "/jun(e)?/": "حزيران", "/jul(y)?/": "تموز", "/aug(ust)?/": "آب", "/sep(t(ember)?)?/": "أيلول", "/oct(ober)?/": "تشرين الأول", "/nov(ember)?/": "تشرين الثاني", "/dec(ember)?/": "كانون الأول", "/^su(n(day)?)?/": "^الاحد", "/^mo(n(day)?)?/": "^ا(1)?", "/^tu(e(s(day)?)?)?/": "^الثلاثاء", "/^we(d(nesday)?)?/": "^الاربعاء", "/^th(u(r(s(day)?)?)?)?/": "^الخميس", "/^fr(i(day)?)?/": "^الجمعة", "/^sa(t(urday)?)?/": "^السبت", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "ar-JO"; ================================================ FILE: src/i18n/ar-KW.js ================================================ /* * DateJS Culture String File * Country Code: ar-KW * Name: Arabic (Kuwait) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["ar-KW"] = { "name": "ar-KW", "englishName": "Arabic (Kuwait)", "nativeName": "العربية (الكويت)", "Sunday": "الاحد", "Monday": "الاثنين", "Tuesday": "الثلاثاء", "Wednesday": "الاربعاء", "Thursday": "الخميس", "Friday": "الجمعة", "Saturday": "السبت", "Sun": "الاحد", "Mon": "الاثنين", "Tue": "الثلاثاء", "Wed": "الاربعاء", "Thu": "الخميس", "Fri": "الجمعة", "Sat": "السبت", "Su": "أ", "Mo": "ا", "Tu": "ث", "We": "أ", "Th": "خ", "Fr": "ج", "Sa": "س", "S_Sun_Initial": "أ", "M_Mon_Initial": "ا", "T_Tue_Initial": "ث", "W_Wed_Initial": "أ", "T_Thu_Initial": "خ", "F_Fri_Initial": "ج", "S_Sat_Initial": "س", "January": "يناير", "February": "فبراير", "March": "مارس", "April": "ابريل", "May": "مايو", "June": "يونيو", "July": "يوليو", "August": "اغسطس", "September": "سبتمبر", "October": "اكتوبر", "November": "نوفمبر", "December": "ديسمبر", "Jan_Abbr": "يناير", "Feb_Abbr": "فبراير", "Mar_Abbr": "مارس", "Apr_Abbr": "ابريل", "May_Abbr": "مايو", "Jun_Abbr": "يونيو", "Jul_Abbr": "يوليو", "Aug_Abbr": "اغسطس", "Sep_Abbr": "سبتمبر", "Oct_Abbr": "اكتوبر", "Nov_Abbr": "نوفمبر", "Dec_Abbr": "ديسمبر", "AM": "ص", "PM": "م", "firstDayOfWeek": 6, "twoDigitYearMax": 2029, "mdy": "dmy", "M/d/yyyy": "dd/MM/yyyy", "dddd, MMMM dd, yyyy": "dd MMMM, yyyy", "h:mm tt": "hh:mm tt", "h:mm:ss tt": "hh:mm:ss tt", "dddd, MMMM dd, yyyy h:mm:ss tt": "dd MMMM, yyyy hh:mm:ss tt", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "dd MMMM", "MMMM, yyyy": "MMMM, yyyy", "/jan(uary)?/": "يناير", "/feb(ruary)?/": "فبراير", "/mar(ch)?/": "مارس", "/apr(il)?/": "ابريل", "/may/": "مايو", "/jun(e)?/": "يونيو", "/jul(y)?/": "يوليو", "/aug(ust)?/": "اغسطس", "/sep(t(ember)?)?/": "سبتمبر", "/oct(ober)?/": "اكتوبر", "/nov(ember)?/": "نوفمبر", "/dec(ember)?/": "ديسمبر", "/^su(n(day)?)?/": "^الاحد", "/^mo(n(day)?)?/": "^ا(1)?", "/^tu(e(s(day)?)?)?/": "^الثلاثاء", "/^we(d(nesday)?)?/": "^الاربعاء", "/^th(u(r(s(day)?)?)?)?/": "^الخميس", "/^fr(i(day)?)?/": "^الجمعة", "/^sa(t(urday)?)?/": "^السبت", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "ar-KW"; ================================================ FILE: src/i18n/ar-LB.js ================================================ /* * DateJS Culture String File * Country Code: ar-LB * Name: Arabic (Lebanon) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["ar-LB"] = { "name": "ar-LB", "englishName": "Arabic (Lebanon)", "nativeName": "العربية (لبنان)", "Sunday": "الاحد", "Monday": "الاثنين", "Tuesday": "الثلاثاء", "Wednesday": "الاربعاء", "Thursday": "الخميس", "Friday": "الجمعة", "Saturday": "السبت", "Sun": "الاحد", "Mon": "الاثنين", "Tue": "الثلاثاء", "Wed": "الاربعاء", "Thu": "الخميس", "Fri": "الجمعة", "Sat": "السبت", "Su": "أ", "Mo": "ا", "Tu": "ث", "We": "أ", "Th": "خ", "Fr": "ج", "Sa": "س", "S_Sun_Initial": "أ", "M_Mon_Initial": "ا", "T_Tue_Initial": "ث", "W_Wed_Initial": "أ", "T_Thu_Initial": "خ", "F_Fri_Initial": "ج", "S_Sat_Initial": "س", "January": "كانون الثاني", "February": "شباط", "March": "آذار", "April": "نيسان", "May": "أيار", "June": "حزيران", "July": "تموز", "August": "آب", "September": "أيلول", "October": "تشرين الأول", "November": "تشرين الثاني", "December": "كانون الأول", "Jan_Abbr": "كانون الثاني", "Feb_Abbr": "شباط", "Mar_Abbr": "آذار", "Apr_Abbr": "نيسان", "May_Abbr": "أيار", "Jun_Abbr": "حزيران", "Jul_Abbr": "تموز", "Aug_Abbr": "آب", "Sep_Abbr": "أيلول", "Oct_Abbr": "تشرين الأول", "Nov_Abbr": "تشرين الثاني", "Dec_Abbr": "كانون الأول", "AM": "ص", "PM": "م", "firstDayOfWeek": 1, "twoDigitYearMax": 2029, "mdy": "dmy", "M/d/yyyy": "dd/MM/yyyy", "dddd, MMMM dd, yyyy": "dd MMMM, yyyy", "h:mm tt": "hh:mm tt", "h:mm:ss tt": "hh:mm:ss tt", "dddd, MMMM dd, yyyy h:mm:ss tt": "dd MMMM, yyyy hh:mm:ss tt", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "dd MMMM", "MMMM, yyyy": "MMMM, yyyy", "/jan(uary)?/": "كانون الثاني", "/feb(ruary)?/": "شباط", "/mar(ch)?/": "آذار", "/apr(il)?/": "نيسان", "/may/": "أيار", "/jun(e)?/": "حزيران", "/jul(y)?/": "تموز", "/aug(ust)?/": "آب", "/sep(t(ember)?)?/": "أيلول", "/oct(ober)?/": "تشرين الأول", "/nov(ember)?/": "تشرين الثاني", "/dec(ember)?/": "كانون الأول", "/^su(n(day)?)?/": "^الاحد", "/^mo(n(day)?)?/": "^ا(1)?", "/^tu(e(s(day)?)?)?/": "^الثلاثاء", "/^we(d(nesday)?)?/": "^الاربعاء", "/^th(u(r(s(day)?)?)?)?/": "^الخميس", "/^fr(i(day)?)?/": "^الجمعة", "/^sa(t(urday)?)?/": "^السبت", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "ar-LB"; ================================================ FILE: src/i18n/ar-LY.js ================================================ /* * DateJS Culture String File * Country Code: ar-LY * Name: Arabic (Libya) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["ar-LY"] = { "name": "ar-LY", "englishName": "Arabic (Libya)", "nativeName": "العربية (ليبيا)", "Sunday": "الاحد", "Monday": "الاثنين", "Tuesday": "الثلاثاء", "Wednesday": "الاربعاء", "Thursday": "الخميس", "Friday": "الجمعة", "Saturday": "السبت", "Sun": "الاحد", "Mon": "الاثنين", "Tue": "الثلاثاء", "Wed": "الاربعاء", "Thu": "الخميس", "Fri": "الجمعة", "Sat": "السبت", "Su": "أ", "Mo": "ا", "Tu": "ث", "We": "أ", "Th": "خ", "Fr": "ج", "Sa": "س", "S_Sun_Initial": "أ", "M_Mon_Initial": "ا", "T_Tue_Initial": "ث", "W_Wed_Initial": "أ", "T_Thu_Initial": "خ", "F_Fri_Initial": "ج", "S_Sat_Initial": "س", "January": "يناير", "February": "فبراير", "March": "مارس", "April": "ابريل", "May": "مايو", "June": "يونيو", "July": "يوليو", "August": "اغسطس", "September": "سبتمبر", "October": "اكتوبر", "November": "نوفمبر", "December": "ديسمبر", "Jan_Abbr": "يناير", "Feb_Abbr": "فبراير", "Mar_Abbr": "مارس", "Apr_Abbr": "ابريل", "May_Abbr": "مايو", "Jun_Abbr": "يونيو", "Jul_Abbr": "يوليو", "Aug_Abbr": "اغسطس", "Sep_Abbr": "سبتمبر", "Oct_Abbr": "اكتوبر", "Nov_Abbr": "نوفمبر", "Dec_Abbr": "ديسمبر", "AM": "ص", "PM": "م", "firstDayOfWeek": 6, "twoDigitYearMax": 2029, "mdy": "dmy", "M/d/yyyy": "dd/MM/yyyy", "dddd, MMMM dd, yyyy": "dd MMMM, yyyy", "h:mm tt": "hh:mm tt", "h:mm:ss tt": "hh:mm:ss tt", "dddd, MMMM dd, yyyy h:mm:ss tt": "dd MMMM, yyyy hh:mm:ss tt", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "dd MMMM", "MMMM, yyyy": "MMMM, yyyy", "/jan(uary)?/": "يناير", "/feb(ruary)?/": "فبراير", "/mar(ch)?/": "مارس", "/apr(il)?/": "ابريل", "/may/": "مايو", "/jun(e)?/": "يونيو", "/jul(y)?/": "يوليو", "/aug(ust)?/": "اغسطس", "/sep(t(ember)?)?/": "سبتمبر", "/oct(ober)?/": "اكتوبر", "/nov(ember)?/": "نوفمبر", "/dec(ember)?/": "ديسمبر", "/^su(n(day)?)?/": "^الاحد", "/^mo(n(day)?)?/": "^ا(1)?", "/^tu(e(s(day)?)?)?/": "^الثلاثاء", "/^we(d(nesday)?)?/": "^الاربعاء", "/^th(u(r(s(day)?)?)?)?/": "^الخميس", "/^fr(i(day)?)?/": "^الجمعة", "/^sa(t(urday)?)?/": "^السبت", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "ar-LY"; ================================================ FILE: src/i18n/ar-MA.js ================================================ /* * DateJS Culture String File * Country Code: ar-MA * Name: Arabic (Morocco) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["ar-MA"] = { "name": "ar-MA", "englishName": "Arabic (Morocco)", "nativeName": "العربية (المملكة المغربية)", "Sunday": "الاحد", "Monday": "الاثنين", "Tuesday": "الثلاثاء", "Wednesday": "الاربعاء", "Thursday": "الخميس", "Friday": "الجمعة", "Saturday": "السبت", "Sun": "الاحد", "Mon": "الاثنين", "Tue": "الثلاثاء", "Wed": "الاربعاء", "Thu": "الخميس", "Fri": "الجمعة", "Sat": "السبت", "Su": "أ", "Mo": "ا", "Tu": "ث", "We": "أ", "Th": "خ", "Fr": "ج", "Sa": "س", "S_Sun_Initial": "أ", "M_Mon_Initial": "ا", "T_Tue_Initial": "ث", "W_Wed_Initial": "أ", "T_Thu_Initial": "خ", "F_Fri_Initial": "ج", "S_Sat_Initial": "س", "January": "يناير", "February": "فبراير", "March": "مارس", "April": "ابريل", "May": "ماي", "June": "يونيو", "July": "يوليوز", "August": "غشت", "September": "شتنبر", "October": "اكتوبر", "November": "نونبر", "December": "دجنبر", "Jan_Abbr": "يناير", "Feb_Abbr": "فبراير", "Mar_Abbr": "مارس", "Apr_Abbr": "ابريل", "May_Abbr": "ماي", "Jun_Abbr": "يونيو", "Jul_Abbr": "يوليوز", "Aug_Abbr": "غشت", "Sep_Abbr": "شتنبر", "Oct_Abbr": "اكتوبر", "Nov_Abbr": "نونبر", "Dec_Abbr": "دجنبر", "AM": "ص", "PM": "م", "firstDayOfWeek": 1, "twoDigitYearMax": 2029, "mdy": "dmy", "M/d/yyyy": "dd-MM-yyyy", "dddd, MMMM dd, yyyy": "dd MMMM, yyyy", "h:mm tt": "H:mm", "h:mm:ss tt": "H:mm:ss", "dddd, MMMM dd, yyyy h:mm:ss tt": "dd MMMM, yyyy H:mm:ss", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "dd MMMM", "MMMM, yyyy": "MMMM, yyyy", "/jan(uary)?/": "يناير", "/feb(ruary)?/": "فبراير", "/mar(ch)?/": "مارس", "/apr(il)?/": "ابريل", "/may/": "ماي", "/jun(e)?/": "يونيو", "/jul(y)?/": "يوليوز", "/aug(ust)?/": "غشت", "/sep(t(ember)?)?/": "شتنبر", "/oct(ober)?/": "اكتوبر", "/nov(ember)?/": "نونبر", "/dec(ember)?/": "دجنبر", "/^su(n(day)?)?/": "^الاحد", "/^mo(n(day)?)?/": "^ا(1)?", "/^tu(e(s(day)?)?)?/": "^الثلاثاء", "/^we(d(nesday)?)?/": "^الاربعاء", "/^th(u(r(s(day)?)?)?)?/": "^الخميس", "/^fr(i(day)?)?/": "^الجمعة", "/^sa(t(urday)?)?/": "^السبت", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "ar-MA"; ================================================ FILE: src/i18n/ar-OM.js ================================================ /* * DateJS Culture String File * Country Code: ar-OM * Name: Arabic (Oman) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["ar-OM"] = { "name": "ar-OM", "englishName": "Arabic (Oman)", "nativeName": "العربية (عمان)", "Sunday": "الاحد", "Monday": "الاثنين", "Tuesday": "الثلاثاء", "Wednesday": "الاربعاء", "Thursday": "الخميس", "Friday": "الجمعة", "Saturday": "السبت", "Sun": "الاحد", "Mon": "الاثنين", "Tue": "الثلاثاء", "Wed": "الاربعاء", "Thu": "الخميس", "Fri": "الجمعة", "Sat": "السبت", "Su": "أ", "Mo": "ا", "Tu": "ث", "We": "أ", "Th": "خ", "Fr": "ج", "Sa": "س", "S_Sun_Initial": "أ", "M_Mon_Initial": "ا", "T_Tue_Initial": "ث", "W_Wed_Initial": "أ", "T_Thu_Initial": "خ", "F_Fri_Initial": "ج", "S_Sat_Initial": "س", "January": "يناير", "February": "فبراير", "March": "مارس", "April": "ابريل", "May": "مايو", "June": "يونيو", "July": "يوليو", "August": "اغسطس", "September": "سبتمبر", "October": "اكتوبر", "November": "نوفمبر", "December": "ديسمبر", "Jan_Abbr": "يناير", "Feb_Abbr": "فبراير", "Mar_Abbr": "مارس", "Apr_Abbr": "ابريل", "May_Abbr": "مايو", "Jun_Abbr": "يونيو", "Jul_Abbr": "يوليو", "Aug_Abbr": "اغسطس", "Sep_Abbr": "سبتمبر", "Oct_Abbr": "اكتوبر", "Nov_Abbr": "نوفمبر", "Dec_Abbr": "ديسمبر", "AM": "ص", "PM": "م", "firstDayOfWeek": 6, "twoDigitYearMax": 2029, "mdy": "dmy", "M/d/yyyy": "dd/MM/yyyy", "dddd, MMMM dd, yyyy": "dd MMMM, yyyy", "h:mm tt": "hh:mm tt", "h:mm:ss tt": "hh:mm:ss tt", "dddd, MMMM dd, yyyy h:mm:ss tt": "dd MMMM, yyyy hh:mm:ss tt", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "dd MMMM", "MMMM, yyyy": "MMMM, yyyy", "/jan(uary)?/": "يناير", "/feb(ruary)?/": "فبراير", "/mar(ch)?/": "مارس", "/apr(il)?/": "ابريل", "/may/": "مايو", "/jun(e)?/": "يونيو", "/jul(y)?/": "يوليو", "/aug(ust)?/": "اغسطس", "/sep(t(ember)?)?/": "سبتمبر", "/oct(ober)?/": "اكتوبر", "/nov(ember)?/": "نوفمبر", "/dec(ember)?/": "ديسمبر", "/^su(n(day)?)?/": "^الاحد", "/^mo(n(day)?)?/": "^ا(1)?", "/^tu(e(s(day)?)?)?/": "^الثلاثاء", "/^we(d(nesday)?)?/": "^الاربعاء", "/^th(u(r(s(day)?)?)?)?/": "^الخميس", "/^fr(i(day)?)?/": "^الجمعة", "/^sa(t(urday)?)?/": "^السبت", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "ar-OM"; ================================================ FILE: src/i18n/ar-QA.js ================================================ /* * DateJS Culture String File * Country Code: ar-QA * Name: Arabic (Qatar) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["ar-QA"] = { "name": "ar-QA", "englishName": "Arabic (Qatar)", "nativeName": "العربية (قطر)", "Sunday": "الاحد", "Monday": "الاثنين", "Tuesday": "الثلاثاء", "Wednesday": "الاربعاء", "Thursday": "الخميس", "Friday": "الجمعة", "Saturday": "السبت", "Sun": "الاحد", "Mon": "الاثنين", "Tue": "الثلاثاء", "Wed": "الاربعاء", "Thu": "الخميس", "Fri": "الجمعة", "Sat": "السبت", "Su": "أ", "Mo": "ا", "Tu": "ث", "We": "أ", "Th": "خ", "Fr": "ج", "Sa": "س", "S_Sun_Initial": "أ", "M_Mon_Initial": "ا", "T_Tue_Initial": "ث", "W_Wed_Initial": "أ", "T_Thu_Initial": "خ", "F_Fri_Initial": "ج", "S_Sat_Initial": "س", "January": "يناير", "February": "فبراير", "March": "مارس", "April": "ابريل", "May": "مايو", "June": "يونيو", "July": "يوليو", "August": "اغسطس", "September": "سبتمبر", "October": "اكتوبر", "November": "نوفمبر", "December": "ديسمبر", "Jan_Abbr": "يناير", "Feb_Abbr": "فبراير", "Mar_Abbr": "مارس", "Apr_Abbr": "ابريل", "May_Abbr": "مايو", "Jun_Abbr": "يونيو", "Jul_Abbr": "يوليو", "Aug_Abbr": "اغسطس", "Sep_Abbr": "سبتمبر", "Oct_Abbr": "اكتوبر", "Nov_Abbr": "نوفمبر", "Dec_Abbr": "ديسمبر", "AM": "ص", "PM": "م", "firstDayOfWeek": 6, "twoDigitYearMax": 2029, "mdy": "dmy", "M/d/yyyy": "dd/MM/yyyy", "dddd, MMMM dd, yyyy": "dd MMMM, yyyy", "h:mm tt": "hh:mm tt", "h:mm:ss tt": "hh:mm:ss tt", "dddd, MMMM dd, yyyy h:mm:ss tt": "dd MMMM, yyyy hh:mm:ss tt", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "dd MMMM", "MMMM, yyyy": "MMMM, yyyy", "/jan(uary)?/": "يناير", "/feb(ruary)?/": "فبراير", "/mar(ch)?/": "مارس", "/apr(il)?/": "ابريل", "/may/": "مايو", "/jun(e)?/": "يونيو", "/jul(y)?/": "يوليو", "/aug(ust)?/": "اغسطس", "/sep(t(ember)?)?/": "سبتمبر", "/oct(ober)?/": "اكتوبر", "/nov(ember)?/": "نوفمبر", "/dec(ember)?/": "ديسمبر", "/^su(n(day)?)?/": "^الاحد", "/^mo(n(day)?)?/": "^ا(1)?", "/^tu(e(s(day)?)?)?/": "^الثلاثاء", "/^we(d(nesday)?)?/": "^الاربعاء", "/^th(u(r(s(day)?)?)?)?/": "^الخميس", "/^fr(i(day)?)?/": "^الجمعة", "/^sa(t(urday)?)?/": "^السبت", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "ar-QA"; ================================================ FILE: src/i18n/ar-SA.js ================================================ /* * DateJS Culture String File * Country Code: ar-SA * Name: Arabic (Saudi Arabia) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["ar-SA"] = { "name": "ar-SA", "englishName": "Arabic (Saudi Arabia)", "nativeName": "العربية (المملكة العربية السعودية)", "Sunday": "الاحد", "Monday": "الاثنين", "Tuesday": "الثلاثاء", "Wednesday": "الاربعاء", "Thursday": "الخميس", "Friday": "الجمعة", "Saturday": "السبت", "Sun": "الاحد", "Mon": "الاثنين", "Tue": "الثلاثاء", "Wed": "الاربعاء", "Thu": "الخميس", "Fri": "الجمعة", "Sat": "السبت", "Su": "ح", "Mo": "ن", "Tu": "ث", "We": "ر", "Th": "خ", "Fr": "ج", "Sa": "س", "S_Sun_Initial": "ح", "M_Mon_Initial": "ن", "T_Tue_Initial": "ث", "W_Wed_Initial": "ر", "T_Thu_Initial": "خ", "F_Fri_Initial": "ج", "S_Sat_Initial": "س", "January": "محرم", "February": "صفر", "March": "ربيع الأول", "April": "ربيع الثاني", "May": "جمادى الأولى", "June": "جمادى الثانية", "July": "رجب", "August": "شعبان", "September": "رمضان", "October": "شوال", "November": "ذو القعدة", "December": "ذو الحجة", "Jan_Abbr": "محرم", "Feb_Abbr": "صفر", "Mar_Abbr": "ربيع الاول", "Apr_Abbr": "ربيع الثاني", "May_Abbr": "جمادى الاولى", "Jun_Abbr": "جمادى الثانية", "Jul_Abbr": "رجب", "Aug_Abbr": "شعبان", "Sep_Abbr": "رمضان", "Oct_Abbr": "شوال", "Nov_Abbr": "ذو القعدة", "Dec_Abbr": "ذو الحجة", "AM": "ص", "PM": "م", "firstDayOfWeek": 6, "twoDigitYearMax": 1451, "mdy": "dmy", "M/d/yyyy": "dd/MM/yy", "dddd, MMMM dd, yyyy": "dd/MMMM/yyyy", "h:mm tt": "hh:mm tt", "h:mm:ss tt": "hh:mm:ss tt", "dddd, MMMM dd, yyyy h:mm:ss tt": "dd/MMMM/yyyy hh:mm:ss tt", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "dd MMMM", "MMMM, yyyy": "MMMM, yyyy", "/jan(uary)?/": "محرم", "/feb(ruary)?/": "صفر", "/mar(ch)?/": "ربيع الأول", "/apr(il)?/": "ربيع الثاني", "/may/": "جمادى الأولى", "/jun(e)?/": "جمادى الثانية", "/jul(y)?/": "رجب", "/aug(ust)?/": "شعبان", "/sep(t(ember)?)?/": "رمضان", "/oct(ober)?/": "شوال", "/nov(ember)?/": "ذو القعدة", "/dec(ember)?/": "ذو الحجة", "/^su(n(day)?)?/": "^الاحد", "/^mo(n(day)?)?/": "^الاثنين", "/^tu(e(s(day)?)?)?/": "^الثلاثاء", "/^we(d(nesday)?)?/": "^الاربعاء", "/^th(u(r(s(day)?)?)?)?/": "^الخميس", "/^fr(i(day)?)?/": "^الجمعة", "/^sa(t(urday)?)?/": "^السبت", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "ar-SA"; ================================================ FILE: src/i18n/ar-SY.js ================================================ /* * DateJS Culture String File * Country Code: ar-SY * Name: Arabic (Syria) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["ar-SY"] = { "name": "ar-SY", "englishName": "Arabic (Syria)", "nativeName": "العربية (سوريا)", "Sunday": "الاحد", "Monday": "الاثنين", "Tuesday": "الثلاثاء", "Wednesday": "الاربعاء", "Thursday": "الخميس", "Friday": "الجمعة", "Saturday": "السبت", "Sun": "الاحد", "Mon": "الاثنين", "Tue": "الثلاثاء", "Wed": "الاربعاء", "Thu": "الخميس", "Fri": "الجمعة", "Sat": "السبت", "Su": "أ", "Mo": "ا", "Tu": "ث", "We": "أ", "Th": "خ", "Fr": "ج", "Sa": "س", "S_Sun_Initial": "أ", "M_Mon_Initial": "ا", "T_Tue_Initial": "ث", "W_Wed_Initial": "أ", "T_Thu_Initial": "خ", "F_Fri_Initial": "ج", "S_Sat_Initial": "س", "January": "كانون الثاني", "February": "شباط", "March": "آذار", "April": "نيسان", "May": "أيار", "June": "حزيران", "July": "تموز", "August": "آب", "September": "أيلول", "October": "تشرين الأول", "November": "تشرين الثاني", "December": "كانون الأول", "Jan_Abbr": "كانون الثاني", "Feb_Abbr": "شباط", "Mar_Abbr": "آذار", "Apr_Abbr": "نيسان", "May_Abbr": "أيار", "Jun_Abbr": "حزيران", "Jul_Abbr": "تموز", "Aug_Abbr": "آب", "Sep_Abbr": "أيلول", "Oct_Abbr": "تشرين الأول", "Nov_Abbr": "تشرين الثاني", "Dec_Abbr": "كانون الأول", "AM": "ص", "PM": "م", "firstDayOfWeek": 6, "twoDigitYearMax": 2029, "mdy": "dmy", "M/d/yyyy": "dd/MM/yyyy", "dddd, MMMM dd, yyyy": "dd MMMM, yyyy", "h:mm tt": "hh:mm tt", "h:mm:ss tt": "hh:mm:ss tt", "dddd, MMMM dd, yyyy h:mm:ss tt": "dd MMMM, yyyy hh:mm:ss tt", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "dd MMMM", "MMMM, yyyy": "MMMM, yyyy", "/jan(uary)?/": "كانون الثاني", "/feb(ruary)?/": "شباط", "/mar(ch)?/": "آذار", "/apr(il)?/": "نيسان", "/may/": "أيار", "/jun(e)?/": "حزيران", "/jul(y)?/": "تموز", "/aug(ust)?/": "آب", "/sep(t(ember)?)?/": "أيلول", "/oct(ober)?/": "تشرين الأول", "/nov(ember)?/": "تشرين الثاني", "/dec(ember)?/": "كانون الأول", "/^su(n(day)?)?/": "^الاحد", "/^mo(n(day)?)?/": "^ا(1)?", "/^tu(e(s(day)?)?)?/": "^الثلاثاء", "/^we(d(nesday)?)?/": "^الاربعاء", "/^th(u(r(s(day)?)?)?)?/": "^الخميس", "/^fr(i(day)?)?/": "^الجمعة", "/^sa(t(urday)?)?/": "^السبت", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "ar-SY"; ================================================ FILE: src/i18n/ar-TN.js ================================================ /* * DateJS Culture String File * Country Code: ar-TN * Name: Arabic (Tunisia) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["ar-TN"] = { "name": "ar-TN", "englishName": "Arabic (Tunisia)", "nativeName": "العربية (تونس)", "Sunday": "الاحد", "Monday": "الاثنين", "Tuesday": "الثلاثاء", "Wednesday": "الاربعاء", "Thursday": "الخميس", "Friday": "الجمعة", "Saturday": "السبت", "Sun": "الاحد", "Mon": "الاثنين", "Tue": "الثلاثاء", "Wed": "الاربعاء", "Thu": "الخميس", "Fri": "الجمعة", "Sat": "السبت", "Su": "أ", "Mo": "ا", "Tu": "ث", "We": "أ", "Th": "خ", "Fr": "ج", "Sa": "س", "S_Sun_Initial": "أ", "M_Mon_Initial": "ا", "T_Tue_Initial": "ث", "W_Wed_Initial": "أ", "T_Thu_Initial": "خ", "F_Fri_Initial": "ج", "S_Sat_Initial": "س", "January": "جانفي", "February": "فيفري", "March": "مارس", "April": "افريل", "May": "ماي", "June": "جوان", "July": "جويلية", "August": "اوت", "September": "سبتمبر", "October": "اكتوبر", "November": "نوفمبر", "December": "ديسمبر", "Jan_Abbr": "جانفي", "Feb_Abbr": "فيفري", "Mar_Abbr": "مارس", "Apr_Abbr": "افريل", "May_Abbr": "ماي", "Jun_Abbr": "جوان", "Jul_Abbr": "جويلية", "Aug_Abbr": "اوت", "Sep_Abbr": "سبتمبر", "Oct_Abbr": "اكتوبر", "Nov_Abbr": "نوفمبر", "Dec_Abbr": "ديسمبر", "AM": "ص", "PM": "م", "firstDayOfWeek": 1, "twoDigitYearMax": 2029, "mdy": "dmy", "M/d/yyyy": "dd-MM-yyyy", "dddd, MMMM dd, yyyy": "dd MMMM, yyyy", "h:mm tt": "H:mm", "h:mm:ss tt": "H:mm:ss", "dddd, MMMM dd, yyyy h:mm:ss tt": "dd MMMM, yyyy H:mm:ss", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "dd MMMM", "MMMM, yyyy": "MMMM, yyyy", "/jan(uary)?/": "جانفي", "/feb(ruary)?/": "فيفري", "/mar(ch)?/": "مارس", "/apr(il)?/": "افريل", "/may/": "ماي", "/jun(e)?/": "جوان", "/jul(y)?/": "جويلية", "/aug(ust)?/": "اوت", "/sep(t(ember)?)?/": "سبتمبر", "/oct(ober)?/": "اكتوبر", "/nov(ember)?/": "نوفمبر", "/dec(ember)?/": "ديسمبر", "/^su(n(day)?)?/": "^الاحد", "/^mo(n(day)?)?/": "^ا(1)?", "/^tu(e(s(day)?)?)?/": "^الثلاثاء", "/^we(d(nesday)?)?/": "^الاربعاء", "/^th(u(r(s(day)?)?)?)?/": "^الخميس", "/^fr(i(day)?)?/": "^الجمعة", "/^sa(t(urday)?)?/": "^السبت", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "ar-TN"; ================================================ FILE: src/i18n/ar-YE.js ================================================ /* * DateJS Culture String File * Country Code: ar-YE * Name: Arabic (Yemen) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["ar-YE"] = { "name": "ar-YE", "englishName": "Arabic (Yemen)", "nativeName": "العربية (اليمن)", "Sunday": "الاحد", "Monday": "الاثنين", "Tuesday": "الثلاثاء", "Wednesday": "الاربعاء", "Thursday": "الخميس", "Friday": "الجمعة", "Saturday": "السبت", "Sun": "الاحد", "Mon": "الاثنين", "Tue": "الثلاثاء", "Wed": "الاربعاء", "Thu": "الخميس", "Fri": "الجمعة", "Sat": "السبت", "Su": "أ", "Mo": "ا", "Tu": "ث", "We": "أ", "Th": "خ", "Fr": "ج", "Sa": "س", "S_Sun_Initial": "أ", "M_Mon_Initial": "ا", "T_Tue_Initial": "ث", "W_Wed_Initial": "أ", "T_Thu_Initial": "خ", "F_Fri_Initial": "ج", "S_Sat_Initial": "س", "January": "يناير", "February": "فبراير", "March": "مارس", "April": "ابريل", "May": "مايو", "June": "يونيو", "July": "يوليو", "August": "اغسطس", "September": "سبتمبر", "October": "اكتوبر", "November": "نوفمبر", "December": "ديسمبر", "Jan_Abbr": "يناير", "Feb_Abbr": "فبراير", "Mar_Abbr": "مارس", "Apr_Abbr": "ابريل", "May_Abbr": "مايو", "Jun_Abbr": "يونيو", "Jul_Abbr": "يوليو", "Aug_Abbr": "اغسطس", "Sep_Abbr": "سبتمبر", "Oct_Abbr": "اكتوبر", "Nov_Abbr": "نوفمبر", "Dec_Abbr": "ديسمبر", "AM": "ص", "PM": "م", "firstDayOfWeek": 6, "twoDigitYearMax": 2029, "mdy": "dmy", "M/d/yyyy": "dd/MM/yyyy", "dddd, MMMM dd, yyyy": "dd MMMM, yyyy", "h:mm tt": "hh:mm tt", "h:mm:ss tt": "hh:mm:ss tt", "dddd, MMMM dd, yyyy h:mm:ss tt": "dd MMMM, yyyy hh:mm:ss tt", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "dd MMMM", "MMMM, yyyy": "MMMM, yyyy", "/jan(uary)?/": "يناير", "/feb(ruary)?/": "فبراير", "/mar(ch)?/": "مارس", "/apr(il)?/": "ابريل", "/may/": "مايو", "/jun(e)?/": "يونيو", "/jul(y)?/": "يوليو", "/aug(ust)?/": "اغسطس", "/sep(t(ember)?)?/": "سبتمبر", "/oct(ober)?/": "اكتوبر", "/nov(ember)?/": "نوفمبر", "/dec(ember)?/": "ديسمبر", "/^su(n(day)?)?/": "^الاحد", "/^mo(n(day)?)?/": "^ا(1)?", "/^tu(e(s(day)?)?)?/": "^الثلاثاء", "/^we(d(nesday)?)?/": "^الاربعاء", "/^th(u(r(s(day)?)?)?)?/": "^الخميس", "/^fr(i(day)?)?/": "^الجمعة", "/^sa(t(urday)?)?/": "^السبت", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "ar-YE"; ================================================ FILE: src/i18n/az-Cyrl-AZ.js ================================================ /* * DateJS Culture String File * Country Code: az-Cyrl-AZ * Name: Azeri (Cyrillic, Azerbaijan) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["az-Cyrl-AZ"] = { "name": "az-Cyrl-AZ", "englishName": "Azeri (Cyrillic, Azerbaijan)", "nativeName": "Азәрбајҹан (Азәрбајҹан)", "Sunday": "Базар", "Monday": "Базар ертәси", "Tuesday": "Чәршәнбә ахшамы", "Wednesday": "Чәршәнбә", "Thursday": "Ҹүмә ахшамы", "Friday": "Ҹүмә", "Saturday": "Шәнбә", "Sun": "Б", "Mon": "Бе", "Tue": "Ча", "Wed": "Ч", "Thu": "Ҹа", "Fri": "Ҹ", "Sat": "Ш", "Su": "Б", "Mo": "Бе", "Tu": "Ча", "We": "Ч", "Th": "Ҹа", "Fr": "Ҹ", "Sa": "Ш", "S_Sun_Initial": "Б", "M_Mon_Initial": "Б", "T_Tue_Initial": "Ч", "W_Wed_Initial": "Ч", "T_Thu_Initial": "Ҹ", "F_Fri_Initial": "Ҹ", "S_Sat_Initial": "Ш", "January": "Јанвар", "February": "Феврал", "March": "Март", "April": "Апрел", "May": "Мај", "June": "Ијун", "July": "Ијул", "August": "Август", "September": "Сентјабр", "October": "Октјабр", "November": "Нојабр", "December": "Декабр", "Jan_Abbr": "Јан", "Feb_Abbr": "Фев", "Mar_Abbr": "Мар", "Apr_Abbr": "Апр", "May_Abbr": "Мај", "Jun_Abbr": "Ијун", "Jul_Abbr": "Ијул", "Aug_Abbr": "Авг", "Sep_Abbr": "Сен", "Oct_Abbr": "Окт", "Nov_Abbr": "Ноя", "Dec_Abbr": "Дек", "AM": "", "PM": "", "firstDayOfWeek": 1, "twoDigitYearMax": 2029, "mdy": "dmy", "M/d/yyyy": "dd.MM.yyyy", "dddd, MMMM dd, yyyy": "d MMMM yyyy", "h:mm tt": "H:mm", "h:mm:ss tt": "H:mm:ss", "dddd, MMMM dd, yyyy h:mm:ss tt": "d MMMM yyyy H:mm:ss", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "d MMMM", "MMMM, yyyy": "MMMM yyyy", "/jan(uary)?/": "јан(вар)?", "/feb(ruary)?/": "фев(рал)?", "/mar(ch)?/": "мар(т)?", "/apr(il)?/": "апр(ел)?", "/may/": "мај", "/jun(e)?/": "ијун", "/jul(y)?/": "ијул", "/aug(ust)?/": "авг(уст)?", "/sep(t(ember)?)?/": "сен(тјабр)?", "/oct(ober)?/": "окт(јабр)?", "/nov(ember)?/": "нојабр", "/dec(ember)?/": "дек(абр)?", "/^su(n(day)?)?/": "^базар", "/^mo(n(day)?)?/": "^базар ертәси", "/^tu(e(s(day)?)?)?/": "^чәршәнбә ахшамы", "/^we(d(nesday)?)?/": "^чәршәнбә", "/^th(u(r(s(day)?)?)?)?/": "^ҹүмә ахшамы", "/^fr(i(day)?)?/": "^ҹүмә", "/^sa(t(urday)?)?/": "^шәнбә", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "az-Cyrl-AZ"; ================================================ FILE: src/i18n/az-Latn-AZ.js ================================================ /* * DateJS Culture String File * Country Code: az-Latn-AZ * Name: Azeri (Latin, Azerbaijan) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["az-Latn-AZ"] = { "name": "az-Latn-AZ", "englishName": "Azeri (Latin, Azerbaijan)", "nativeName": "Azərbaycan­ılı (Azərbaycanca)", "Sunday": "Bazar", "Monday": "Bazar ertəsi", "Tuesday": "Çərşənbə axşamı", "Wednesday": "Çərşənbə", "Thursday": "Cümə axşamı", "Friday": "Cümə", "Saturday": "Şənbə", "Sun": "B", "Mon": "Be", "Tue": "Ça", "Wed": "Ç", "Thu": "Ca", "Fri": "C", "Sat": "Ş", "Su": "B", "Mo": "Be", "Tu": "Ça", "We": "Ç", "Th": "Ca", "Fr": "C", "Sa": "Ş", "S_Sun_Initial": "B", "M_Mon_Initial": "B", "T_Tue_Initial": "Ç", "W_Wed_Initial": "Ç", "T_Thu_Initial": "C", "F_Fri_Initial": "C", "S_Sat_Initial": "Ş", "January": "Yanvar", "February": "Fevral", "March": "Mart", "April": "Aprel", "May": "May", "June": "İyun", "July": "İyul", "August": "Avgust", "September": "Sentyabr", "October": "Oktyabr", "November": "Noyabr", "December": "Dekabr", "Jan_Abbr": "Yan", "Feb_Abbr": "Fev", "Mar_Abbr": "Mar", "Apr_Abbr": "Apr", "May_Abbr": "May", "Jun_Abbr": "İyun", "Jul_Abbr": "İyul", "Aug_Abbr": "Avg", "Sep_Abbr": "Sen", "Oct_Abbr": "Okt", "Nov_Abbr": "Noy", "Dec_Abbr": "Dek", "AM": "", "PM": "", "firstDayOfWeek": 1, "twoDigitYearMax": 2029, "mdy": "dmy", "M/d/yyyy": "dd.MM.yyyy", "dddd, MMMM dd, yyyy": "d MMMM yyyy", "h:mm tt": "H:mm", "h:mm:ss tt": "H:mm:ss", "dddd, MMMM dd, yyyy h:mm:ss tt": "d MMMM yyyy H:mm:ss", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "d MMMM", "MMMM, yyyy": "MMMM yyyy", "/jan(uary)?/": "yan(var)?", "/feb(ruary)?/": "fev(ral)?", "/mar(ch)?/": "mar(t)?", "/apr(il)?/": "apr(el)?", "/may/": "may", "/jun(e)?/": "iyun", "/jul(y)?/": "iyul", "/aug(ust)?/": "avg(ust)?", "/sep(t(ember)?)?/": "sen(tyabr)?", "/oct(ober)?/": "okt(yabr)?", "/nov(ember)?/": "noy(abr)?", "/dec(ember)?/": "dek(abr)?", "/^su(n(day)?)?/": "^bazar", "/^mo(n(day)?)?/": "^bazar ertəsi", "/^tu(e(s(day)?)?)?/": "^çərşənbə axşamı", "/^we(d(nesday)?)?/": "^çərşənbə", "/^th(u(r(s(day)?)?)?)?/": "^cümə axşamı", "/^fr(i(day)?)?/": "^cümə", "/^sa(t(urday)?)?/": "^şənbə", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "az-Latn-AZ"; ================================================ FILE: src/i18n/be-BY.js ================================================ /* * DateJS Culture String File * Country Code: be-BY * Name: Belarusian (Belarus) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["be-BY"] = { "name": "be-BY", "englishName": "Belarusian (Belarus)", "nativeName": "Беларускі (Беларусь)", "Sunday": "нядзеля", "Monday": "панядзелак", "Tuesday": "аўторак", "Wednesday": "серада", "Thursday": "чацвер", "Friday": "пятніца", "Saturday": "субота", "Sun": "нд", "Mon": "пн", "Tue": "аў", "Wed": "ср", "Thu": "чц", "Fri": "пт", "Sat": "сб", "Su": "нд", "Mo": "пн", "Tu": "аў", "We": "ср", "Th": "чц", "Fr": "пт", "Sa": "сб", "S_Sun_Initial": "н", "M_Mon_Initial": "п", "T_Tue_Initial": "а", "W_Wed_Initial": "с", "T_Thu_Initial": "ч", "F_Fri_Initial": "п", "S_Sat_Initial": "с", "January": "Студзень", "February": "Люты", "March": "Сакавік", "April": "Красавік", "May": "Май", "June": "Чэрвень", "July": "Ліпень", "August": "Жнівень", "September": "Верасень", "October": "Кастрычнік", "November": "Лістапад", "December": "Снежань", "Jan_Abbr": "Сту", "Feb_Abbr": "Лют", "Mar_Abbr": "Сак", "Apr_Abbr": "Кра", "May_Abbr": "Май", "Jun_Abbr": "Чэр", "Jul_Abbr": "Ліп", "Aug_Abbr": "Жні", "Sep_Abbr": "Вер", "Oct_Abbr": "Кас", "Nov_Abbr": "Ліс", "Dec_Abbr": "Сне", "AM": "", "PM": "", "firstDayOfWeek": 1, "twoDigitYearMax": 2029, "mdy": "dmy", "M/d/yyyy": "dd.MM.yyyy", "dddd, MMMM dd, yyyy": "d MMMM yyyy", "h:mm tt": "H:mm", "h:mm:ss tt": "H:mm:ss", "dddd, MMMM dd, yyyy h:mm:ss tt": "d MMMM yyyy H:mm:ss", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "d MMMM", "MMMM, yyyy": "MMMM yyyy", "/jan(uary)?/": "сту(дзень)?", "/feb(ruary)?/": "лют(ы)?", "/mar(ch)?/": "сак(авік)?", "/apr(il)?/": "кра(савік)?", "/may/": "май", "/jun(e)?/": "чэр(вень)?", "/jul(y)?/": "ліп(ень)?", "/aug(ust)?/": "жні(вень)?", "/sep(t(ember)?)?/": "вер(асень)?", "/oct(ober)?/": "кас(трычнік)?", "/nov(ember)?/": "ліс(тапад)?", "/dec(ember)?/": "сне(жань)?", "/^su(n(day)?)?/": "^нядзеля", "/^mo(n(day)?)?/": "^панядзелак", "/^tu(e(s(day)?)?)?/": "^аўторак", "/^we(d(nesday)?)?/": "^серада", "/^th(u(r(s(day)?)?)?)?/": "^чацвер", "/^fr(i(day)?)?/": "^пятніца", "/^sa(t(urday)?)?/": "^субота", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "be-BY"; ================================================ FILE: src/i18n/bg-BG.js ================================================ /* * DateJS Culture String File * Country Code: bg-BG * Name: Bulgarian (Bulgaria) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["bg-BG"] = { "name": "bg-BG", "englishName": "Bulgarian (Bulgaria)", "nativeName": "български (България)", "Sunday": "неделя", "Monday": "понеделник", "Tuesday": "вторник", "Wednesday": "сряда", "Thursday": "четвъртък", "Friday": "петък", "Saturday": "събота", "Sun": "Нд", "Mon": "Пн", "Tue": "Вт", "Wed": "Ср", "Thu": "Чт", "Fri": "Пт", "Sat": "Сб", "Su": "не", "Mo": "по", "Tu": "вт", "We": "ср", "Th": "че", "Fr": "пе", "Sa": "съ", "S_Sun_Initial": "н", "M_Mon_Initial": "п", "T_Tue_Initial": "в", "W_Wed_Initial": "с", "T_Thu_Initial": "ч", "F_Fri_Initial": "п", "S_Sat_Initial": "с", "January": "Януари", "February": "Февруари", "March": "Март", "April": "Април", "May": "Май", "June": "Юни", "July": "Юли", "August": "Август", "September": "Септември", "October": "Октомври", "November": "Ноември", "December": "Декември", "Jan_Abbr": "Януари", "Feb_Abbr": "Февруари", "Mar_Abbr": "Март", "Apr_Abbr": "Април", "May_Abbr": "Май", "Jun_Abbr": "Юни", "Jul_Abbr": "Юли", "Aug_Abbr": "Август", "Sep_Abbr": "Септември", "Oct_Abbr": "Октомври", "Nov_Abbr": "Ноември", "Dec_Abbr": "Декември", "AM": "", "PM": "", "firstDayOfWeek": 1, "twoDigitYearMax": 2029, "mdy": "dmy", "M/d/yyyy": "dd.M.yyyy 'г.'", "dddd, MMMM dd, yyyy": "dd MMMM yyyy 'г.'", "h:mm tt": "HH:mm", "h:mm:ss tt": "HH:mm:ss", "dddd, MMMM dd, yyyy h:mm:ss tt": "dd MMMM yyyy 'г.' HH:mm:ss", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "dd MMMM", "MMMM, yyyy": "MMMM yyyy 'г.'", "/jan(uary)?/": "януари", "/feb(ruary)?/": "февруари", "/mar(ch)?/": "март", "/apr(il)?/": "април", "/may/": "май", "/jun(e)?/": "юни", "/jul(y)?/": "юли", "/aug(ust)?/": "август", "/sep(t(ember)?)?/": "септември", "/oct(ober)?/": "октомври", "/nov(ember)?/": "ноември", "/dec(ember)?/": "декември", "/^su(n(day)?)?/": "^не((деля)?)?", "/^mo(n(day)?)?/": "^по((неделник)?)?", "/^tu(e(s(day)?)?)?/": "^вторник", "/^we(d(nesday)?)?/": "^сряда", "/^th(u(r(s(day)?)?)?)?/": "^че((твъртък)?)?", "/^fr(i(day)?)?/": "^пе((тък)?)?", "/^sa(t(urday)?)?/": "^съ((бота)?)?", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "bg-BG"; ================================================ FILE: src/i18n/bs-Latn-BA.js ================================================ /* * DateJS Culture String File * Country Code: bs-Latn-BA * Name: Bosnian (Bosnia and Herzegovina) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["bs-Latn-BA"] = { "name": "bs-Latn-BA", "englishName": "Bosnian (Bosnia and Herzegovina)", "nativeName": "bosanski (Bosna i Hercegovina)", "Sunday": "nedjelja", "Monday": "ponedjeljak", "Tuesday": "utorak", "Wednesday": "srijeda", "Thursday": "četvrtak", "Friday": "petak", "Saturday": "subota", "Sun": "ned", "Mon": "pon", "Tue": "uto", "Wed": "sri", "Thu": "čet", "Fri": "pet", "Sat": "sub", "Su": "ned", "Mo": "pon", "Tu": "uto", "We": "sri", "Th": "čet", "Fr": "pet", "Sa": "sub", "S_Sun_Initial": "n", "M_Mon_Initial": "p", "T_Tue_Initial": "u", "W_Wed_Initial": "s", "T_Thu_Initial": "č", "F_Fri_Initial": "p", "S_Sat_Initial": "s", "January": "januar", "February": "februar", "March": "mart", "April": "april", "May": "maj", "June": "jun", "July": "jul", "August": "avgust", "September": "septembar", "October": "oktobar", "November": "novembar", "December": "decembar", "Jan_Abbr": "jan", "Feb_Abbr": "feb", "Mar_Abbr": "mar", "Apr_Abbr": "apr", "May_Abbr": "maj", "Jun_Abbr": "jun", "Jul_Abbr": "jul", "Aug_Abbr": "avg", "Sep_Abbr": "sep", "Oct_Abbr": "okt", "Nov_Abbr": "nov", "Dec_Abbr": "dec", "AM": "", "PM": "", "firstDayOfWeek": 1, "twoDigitYearMax": 2029, "mdy": "dmy", "M/d/yyyy": "d.M.yyyy", "dddd, MMMM dd, yyyy": "d. MMMM yyyy", "h:mm tt": "H:mm:ss", "h:mm:ss tt": "H:mm:ss", "dddd, MMMM dd, yyyy h:mm:ss tt": "d. MMMM yyyy H:mm:ss", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "MMMM dd", "MMMM, yyyy": "MMMM yyyy", "/jan(uary)?/": "jan(uar)?", "/feb(ruary)?/": "feb(ruar)?", "/mar(ch)?/": "mar(t)?", "/apr(il)?/": "apr(il)?", "/may/": "maj", "/jun(e)?/": "jun", "/jul(y)?/": "jul", "/aug(ust)?/": "avg(ust)?", "/sep(t(ember)?)?/": "sep(tembar)?", "/oct(ober)?/": "okt(obar)?", "/nov(ember)?/": "nov(embar)?", "/dec(ember)?/": "dec(embar)?", "/^su(n(day)?)?/": "^nedjelja", "/^mo(n(day)?)?/": "^ponedjeljak", "/^tu(e(s(day)?)?)?/": "^utorak", "/^we(d(nesday)?)?/": "^srijeda", "/^th(u(r(s(day)?)?)?)?/": "^četvrtak", "/^fr(i(day)?)?/": "^petak", "/^sa(t(urday)?)?/": "^subota", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "bs-Latn-BA"; ================================================ FILE: src/i18n/ca-ES.js ================================================ /* * DateJS Culture String File * Country Code: ca-ES * Name: Catalan (Catalan) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["ca-ES"] = { "name": "ca-ES", "englishName": "Catalan (Catalan)", "nativeName": "català (català)", "Sunday": "diumenge", "Monday": "dilluns", "Tuesday": "dimarts", "Wednesday": "dimecres", "Thursday": "dijous", "Friday": "divendres", "Saturday": "dissabte", "Sun": "dg.", "Mon": "dl.", "Tue": "dt.", "Wed": "dc.", "Thu": "dj.", "Fri": "dv.", "Sat": "ds.", "Su": "dg", "Mo": "dl", "Tu": "dt", "We": "dc", "Th": "dj", "Fr": "dv", "Sa": "ds", "S_Sun_Initial": "d", "M_Mon_Initial": "d", "T_Tue_Initial": "d", "W_Wed_Initial": "d", "T_Thu_Initial": "d", "F_Fri_Initial": "d", "S_Sat_Initial": "d", "January": "gener", "February": "febrer", "March": "març", "April": "abril", "May": "maig", "June": "juny", "July": "juliol", "August": "agost", "September": "setembre", "October": "octubre", "November": "novembre", "December": "desembre", "Jan_Abbr": "gen", "Feb_Abbr": "feb", "Mar_Abbr": "març", "Apr_Abbr": "abr", "May_Abbr": "maig", "Jun_Abbr": "juny", "Jul_Abbr": "jul", "Aug_Abbr": "ag", "Sep_Abbr": "set", "Oct_Abbr": "oct", "Nov_Abbr": "nov", "Dec_Abbr": "des", "AM": "", "PM": "", "firstDayOfWeek": 1, "twoDigitYearMax": 2029, "mdy": "dmy", "M/d/yyyy": "dd/MM/yyyy", "dddd, MMMM dd, yyyy": "dddd, d' / 'MMMM' / 'yyyy", "h:mm tt": "HH:mm", "h:mm:ss tt": "HH:mm:ss", "dddd, MMMM dd, yyyy h:mm:ss tt": "dddd, d' / 'MMMM' / 'yyyy HH:mm:ss", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "dd MMMM", "MMMM, yyyy": "MMMM' / 'yyyy", "/jan(uary)?/": "gen(er)?", "/feb(ruary)?/": "feb(rer)?", "/mar(ch)?/": "març", "/apr(il)?/": "abr(il)?", "/may/": "maig", "/jun(e)?/": "juny", "/jul(y)?/": "jul(iol)?", "/aug(ust)?/": "ag(ost)?", "/sep(t(ember)?)?/": "set(embre)?", "/oct(ober)?/": "oct(ubre)?", "/nov(ember)?/": "nov(embre)?", "/dec(ember)?/": "des(embre)?", "/^su(n(day)?)?/": "^dg((.(umenge)?)?)?", "/^mo(n(day)?)?/": "^dl((.(lluns)?)?)?", "/^tu(e(s(day)?)?)?/": "^dt((.(marts)?)?)?", "/^we(d(nesday)?)?/": "^dc((.(mecres)?)?)?", "/^th(u(r(s(day)?)?)?)?/": "^dj((.(jous)?)?)?", "/^fr(i(day)?)?/": "^dv((.(vendres)?)?)?", "/^sa(t(urday)?)?/": "^ds((.(ssabte)?)?)?", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "ca-ES"; ================================================ FILE: src/i18n/cs-CZ.js ================================================ /* * DateJS Culture String File * Country Code: cs-CZ * Name: Czech (Czech Republic) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["cs-CZ"] = { "name": "cs-CZ", "englishName": "Czech (Czech Republic)", "nativeName": "čeština (Česká republika)", "Sunday": "neděle", "Monday": "pondělí", "Tuesday": "úterý", "Wednesday": "středa", "Thursday": "čtvrtek", "Friday": "pátek", "Saturday": "sobota", "Sun": "ne", "Mon": "po", "Tue": "út", "Wed": "st", "Thu": "čt", "Fri": "pá", "Sat": "so", "Su": "ne", "Mo": "po", "Tu": "út", "We": "st", "Th": "čt", "Fr": "pá", "Sa": "so", "S_Sun_Initial": "n", "M_Mon_Initial": "p", "T_Tue_Initial": "ú", "W_Wed_Initial": "s", "T_Thu_Initial": "č", "F_Fri_Initial": "p", "S_Sat_Initial": "s", "January": "leden", "February": "únor", "March": "březen", "April": "duben", "May": "květen", "June": "červen", "July": "červenec", "August": "srpen", "September": "září", "October": "říjen", "November": "listopad", "December": "prosinec", "Jan_Abbr": "I", "Feb_Abbr": "II", "Mar_Abbr": "III", "Apr_Abbr": "IV", "May_Abbr": "V", "Jun_Abbr": "VI", "Jul_Abbr": "VII", "Aug_Abbr": "VIII", "Sep_Abbr": "IX", "Oct_Abbr": "X", "Nov_Abbr": "XI", "Dec_Abbr": "XII", "AM": "dop.", "PM": "odp.", "firstDayOfWeek": 1, "twoDigitYearMax": 2029, "mdy": "dmy", "M/d/yyyy": "d.M.yyyy", "dddd, MMMM dd, yyyy": "d. MMMM yyyy", "h:mm tt": "H:mm", "h:mm:ss tt": "H:mm:ss", "dddd, MMMM dd, yyyy h:mm:ss tt": "d. MMMM yyyy H:mm:ss", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "dd MMMM", "MMMM, yyyy": "MMMM yyyy", "/jan(uary)?/": "leden", "/feb(ruary)?/": "únor", "/mar(ch)?/": "březen", "/apr(il)?/": "duben", "/may/": "květen", "/jun(e)?/": "červen", "/jul(y)?/": "červenec", "/aug(ust)?/": "srpen", "/sep(t(ember)?)?/": "září", "/oct(ober)?/": "říjen", "/nov(ember)?/": "listopad", "/dec(ember)?/": "prosinec", "/^su(n(day)?)?/": "^neděle", "/^mo(n(day)?)?/": "^pondělí", "/^tu(e(s(day)?)?)?/": "^úterý", "/^we(d(nesday)?)?/": "^středa", "/^th(u(r(s(day)?)?)?)?/": "^čtvrtek", "/^fr(i(day)?)?/": "^pátek", "/^sa(t(urday)?)?/": "^sobota", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "cs-CZ"; ================================================ FILE: src/i18n/cy-GB.js ================================================ /* * DateJS Culture String File * Country Code: cy-GB * Name: Welsh (United Kingdom) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["cy-GB"] = { "name": "cy-GB", "englishName": "Welsh (United Kingdom)", "nativeName": "Cymraeg (y Deyrnas Unedig)", "Sunday": "Dydd Sul", "Monday": "Dydd Llun", "Tuesday": "Dydd Mawrth", "Wednesday": "Dydd Mercher", "Thursday": "Dydd Iau", "Friday": "Dydd Gwener", "Saturday": "Dydd Sadwrn", "Sun": "Sul", "Mon": "Llun", "Tue": "Maw", "Wed": "Mer", "Thu": "Iau", "Fri": "Gwe", "Sat": "Sad", "Su": "Sul", "Mo": "Llun", "Tu": "Maw", "We": "Mer", "Th": "Iau", "Fr": "Gwe", "Sa": "Sad", "S_Sun_Initial": "S", "M_Mon_Initial": "L", "T_Tue_Initial": "M", "W_Wed_Initial": "M", "T_Thu_Initial": "I", "F_Fri_Initial": "G", "S_Sat_Initial": "S", "January": "Ionawr", "February": "Chwefror", "March": "Mawrth", "April": "Ebrill", "May": "Mai", "June": "Mehefin", "July": "Gorffennaf", "August": "Awst", "September": "Medi", "October": "Hydref", "November": "Tachwedd", "December": "Rhagfyr", "Jan_Abbr": "Ion", "Feb_Abbr": "Chwe", "Mar_Abbr": "Maw", "Apr_Abbr": "Ebr", "May_Abbr": "Mai", "Jun_Abbr": "Meh", "Jul_Abbr": "Gor", "Aug_Abbr": "Aws", "Sep_Abbr": "Med", "Oct_Abbr": "Hyd", "Nov_Abbr": "Tach", "Dec_Abbr": "Rhag", "AM": "a.m.", "PM": "p.m.", "firstDayOfWeek": 1, "twoDigitYearMax": 2029, "mdy": "dmy", "M/d/yyyy": "dd/MM/yyyy", "dddd, MMMM dd, yyyy": "dd MMMM yyyy", "h:mm tt": "HH:mm:ss", "h:mm:ss tt": "HH:mm:ss", "dddd, MMMM dd, yyyy h:mm:ss tt": "dd MMMM yyyy HH:mm:ss", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "MMMM dd", "MMMM, yyyy": "MMMM yyyy", "/jan(uary)?/": "ion(awr)?", "/feb(ruary)?/": "chwe(fror)?", "/mar(ch)?/": "maw(rth)?", "/apr(il)?/": "ebr(ill)?", "/may/": "mai", "/jun(e)?/": "meh(efin)?", "/jul(y)?/": "gor(ffennaf)?", "/aug(ust)?/": "aws(t)?", "/sep(t(ember)?)?/": "med(i)?", "/oct(ober)?/": "hyd(ref)?", "/nov(ember)?/": "tach(wedd)?", "/dec(ember)?/": "rhag(fyr)?", "/^su(n(day)?)?/": "^dydd sul", "/^mo(n(day)?)?/": "^dydd llun", "/^tu(e(s(day)?)?)?/": "^dydd mawrth", "/^we(d(nesday)?)?/": "^dydd mercher", "/^th(u(r(s(day)?)?)?)?/": "^dydd iau", "/^fr(i(day)?)?/": "^dydd gwener", "/^sa(t(urday)?)?/": "^dydd sadwrn", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "cy-GB"; ================================================ FILE: src/i18n/da-DK.js ================================================ /* * DateJS Culture String File * Country Code: da-DK * Name: Danish (Denmark) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["da-DK"] = { "name": "da-DK", "englishName": "Danish (Denmark)", "nativeName": "dansk (Danmark)", "Sunday": "søndag", "Monday": "mandag", "Tuesday": "tirsdag", "Wednesday": "onsdag", "Thursday": "torsdag", "Friday": "fredag", "Saturday": "lørdag", "Sun": "sø", "Mon": "ma", "Tue": "ti", "Wed": "on", "Thu": "to", "Fri": "fr", "Sat": "lø", "Su": "sø", "Mo": "ma", "Tu": "ti", "We": "on", "Th": "to", "Fr": "fr", "Sa": "lø", "S_Sun_Initial": "s", "M_Mon_Initial": "m", "T_Tue_Initial": "t", "W_Wed_Initial": "o", "T_Thu_Initial": "t", "F_Fri_Initial": "f", "S_Sat_Initial": "l", "January": "januar", "February": "februar", "March": "marts", "April": "april", "May": "maj", "June": "juni", "July": "juli", "August": "august", "September": "september", "October": "oktober", "November": "november", "December": "december", "Jan_Abbr": "jan", "Feb_Abbr": "feb", "Mar_Abbr": "mar", "Apr_Abbr": "apr", "May_Abbr": "maj", "Jun_Abbr": "jun", "Jul_Abbr": "jul", "Aug_Abbr": "aug", "Sep_Abbr": "sep", "Oct_Abbr": "okt", "Nov_Abbr": "nov", "Dec_Abbr": "dec", "AM": "", "PM": "", "firstDayOfWeek": 1, "twoDigitYearMax": 2029, "mdy": "dmy", "M/d/yyyy": "dd-MM-yyyy", "dddd, MMMM dd, yyyy": "d. MMMM yyyy", "h:mm tt": "HH:mm", "h:mm:ss tt": "HH:mm:ss", "dddd, MMMM dd, yyyy h:mm:ss tt": "d. MMMM yyyy HH:mm:ss", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "d. MMMM", "MMMM, yyyy": "MMMM yyyy", "/jan(uary)?/": "jan(uar)?", "/feb(ruary)?/": "feb(ruar)?", "/mar(ch)?/": "mar(ts)?", "/apr(il)?/": "apr(il)?", "/may/": "maj", "/jun(e)?/": "jun(i)?", "/jul(y)?/": "jul(i)?", "/aug(ust)?/": "aug(ust)?", "/sep(t(ember)?)?/": "sep(t(ember)?)?", "/oct(ober)?/": "okt(ober)?", "/nov(ember)?/": "nov(ember)?", "/dec(ember)?/": "dec(ember)?", "/^su(n(day)?)?/": "^søndag", "/^mo(n(day)?)?/": "^mandag", "/^tu(e(s(day)?)?)?/": "^tirsdag", "/^we(d(nesday)?)?/": "^onsdag", "/^th(u(r(s(day)?)?)?)?/": "^torsdag", "/^fr(i(day)?)?/": "^fredag", "/^sa(t(urday)?)?/": "^lørdag", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "da-DK"; ================================================ FILE: src/i18n/de-AT.js ================================================ /* * DateJS Culture String File * Country Code: de-AT * Name: German (Austria) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["de-AT"] = { "name": "de-AT", "englishName": "German (Austria)", "nativeName": "Deutsch (Österreich)", "Sunday": "Sonntag", "Monday": "Montag", "Tuesday": "Dienstag", "Wednesday": "Mittwoch", "Thursday": "Donnerstag", "Friday": "Freitag", "Saturday": "Samstag", "Sun": "Son", "Mon": "Mon", "Tue": "Die", "Wed": "Mit", "Thu": "Don", "Fri": "Fre", "Sat": "Sam", "Su": "So", "Mo": "Mo", "Tu": "Di", "We": "Mi", "Th": "Do", "Fr": "Fr", "Sa": "Sa", "S_Sun_Initial": "S", "M_Mon_Initial": "M", "T_Tue_Initial": "D", "W_Wed_Initial": "M", "T_Thu_Initial": "D", "F_Fri_Initial": "F", "S_Sat_Initial": "S", "January": "Jänner", "February": "Februar", "March": "März", "April": "April", "May": "Mai", "June": "Juni", "July": "Juli", "August": "August", "September": "September", "October": "Oktober", "November": "November", "December": "Dezember", "Jan_Abbr": "J(ä|a)n", "Feb_Abbr": "Feb", "Mar_Abbr": "(M(a|ä)r|Mrz)", "Apr_Abbr": "Apr", "May_Abbr": "Mai", "Jun_Abbr": "Jun", "Jul_Abbr": "Jul", "Aug_Abbr": "Aug", "Sep_Abbr": "Sep", "Oct_Abbr": "Okt", "Nov_Abbr": "Nov", "Dec_Abbr": "Dez", "AM": "", "PM": "", "firstDayOfWeek": 1, "twoDigitYearMax": 2029, "mdy": "dmy", "M/d/yyyy": "dd.MM.yyyy", "dddd, MMMM dd, yyyy": "dddd, dd. MMMM yyyy", "h:mm tt": "HH:mm", "h:mm:ss tt": "HH:mm:ss", "dddd, MMMM dd, yyyy h:mm:ss tt": "dddd, dd. MMMM yyyy HH:mm:ss", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "dd MMMM", "MMMM, yyyy": "MMMM yyyy", "/jan(uary)?/": "jän(ner)?", "/feb(ruary)?/": "feb(ruar)?", "/mar(ch)?/": "mär(z)?", "/apr(il)?/": "apr(il)?", "/may/": "mai", "/jun(e)?/": "jun(i)?", "/jul(y)?/": "jul(i)?", "/aug(ust)?/": "aug(ust)?", "/sep(t(ember)?)?/": "sep(t(ember)?)?", "/oct(ober)?/": "okt(ober)?", "/nov(ember)?/": "nov(ember)?", "/dec(ember)?/": "dez(ember)?", "/^su(n(day)?)?/": "^sonntag", "/^mo(n(day)?)?/": "^montag", "/^tu(e(s(day)?)?)?/": "^dienstag", "/^we(d(nesday)?)?/": "^mittwoch", "/^th(u(r(s(day)?)?)?)?/": "^donnerstag", "/^fr(i(day)?)?/": "^freitag", "/^sa(t(urday)?)?/": "^samstag", "/^next/": "^nächste(r|s|n)?", "/^last|past|prev(ious)?/": "^letzte(r|s|n)?|vergangene(r|s|n)?|vorherige(r|s|n)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|(da)?nach(er)?|von|daher|in)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|(be|zu)?vor|früher)", "/^yes(terday)?/": "^gestern", "/^t(od(ay)?)?/": "^heute", "/^tom(orrow)?/": "^morgen", "/^n(ow)?/": "^jetzt|sofort|gleich", "/^ms|milli(second)?s?/": "^ms|milli(sekunde(n)?)?", "/^sec(ond)?s?/": "^sek(unde(n)?)?", "/^mn|min(ute)?s?/": "^mn|min(ute(n)?)?", "/^h(our)?s?/": "^h|st(d|unde(n)?)?", "/^w(eek)?s?/": "^w(oche(n)?)?", "/^m(onth)?s?/": "^m(onat(e)?)?", "/^d(ay)?s?/": "^d|t(ag(en)?)?", "/^y(ear)?s?/": "^y|j(ahr(en)?)?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "de-AT"; ================================================ FILE: src/i18n/de-CH.js ================================================ /* * DateJS Culture String File * Country Code: de-CH * Name: German (Switzerland) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["de-CH"] = { "name": "de-CH", "englishName": "German (Switzerland)", "nativeName": "Deutsch (Schweiz)", "Sunday": "Sonntag", "Monday": "Montag", "Tuesday": "Dienstag", "Wednesday": "Mittwoch", "Thursday": "Donnerstag", "Friday": "Freitag", "Saturday": "Samstag", "Sun": "Son", "Mon": "Mon", "Tue": "Die", "Wed": "Mit", "Thu": "Don", "Fri": "Fre", "Sat": "Sam", "Su": "So", "Mo": "Mo", "Tu": "Di", "We": "Mi", "Th": "Do", "Fr": "Fr", "Sa": "Sa", "S_Sun_Initial": "S", "M_Mon_Initial": "M", "T_Tue_Initial": "D", "W_Wed_Initial": "M", "T_Thu_Initial": "D", "F_Fri_Initial": "F", "S_Sat_Initial": "S", "January": "Januar", "February": "Februar", "March": "März", "April": "April", "May": "Mai", "June": "Juni", "July": "Juli", "August": "August", "September": "September", "October": "Oktober", "November": "November", "December": "Dezember", "Jan_Abbr": "Jan", "Feb_Abbr": "Feb", "Mar_Abbr": "Mrz", "Apr_Abbr": "Apr", "May_Abbr": "Mai", "Jun_Abbr": "Jun", "Jul_Abbr": "Jul", "Aug_Abbr": "Aug", "Sep_Abbr": "Sep", "Oct_Abbr": "Okt", "Nov_Abbr": "Nov", "Dec_Abbr": "Dez", "AM": "", "PM": "", "firstDayOfWeek": 1, "twoDigitYearMax": 2029, "mdy": "dmy", "M/d/yyyy": "dd.MM.yyyy", "dddd, MMMM dd, yyyy": "dddd, d. MMMM yyyy", "h:mm tt": "HH:mm", "h:mm:ss tt": "HH:mm:ss", "dddd, MMMM dd, yyyy h:mm:ss tt": "dddd, d. MMMM yyyy HH:mm:ss", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "dd MMMM", "MMMM, yyyy": "MMMM yyyy", "/jan(uary)?/": "jan(uar)?", "/feb(ruary)?/": "feb(ruar)?", "/mar(ch)?/": "märz", "/apr(il)?/": "apr(il)?", "/may/": "mai", "/jun(e)?/": "jun(i)?", "/jul(y)?/": "jul(i)?", "/aug(ust)?/": "aug(ust)?", "/sep(t(ember)?)?/": "sep(t(ember)?)?", "/oct(ober)?/": "okt(ober)?", "/nov(ember)?/": "nov(ember)?", "/dec(ember)?/": "dez(ember)?", "/^su(n(day)?)?/": "^sonntag", "/^mo(n(day)?)?/": "^montag", "/^tu(e(s(day)?)?)?/": "^dienstag", "/^we(d(nesday)?)?/": "^mittwoch", "/^th(u(r(s(day)?)?)?)?/": "^donnerstag", "/^fr(i(day)?)?/": "^freitag", "/^sa(t(urday)?)?/": "^samstag", "/^next/": "^nächste(r|s|n)?", "/^last|past|prev(ious)?/": "^letzte(r|s|n)?|vergangene(r|s|n)?|vorherige(r|s|n)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|(da)?nach(er)?|von|daher|in)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|(be|zu)?vor|früher)", "/^yes(terday)?/": "^gestern", "/^t(od(ay)?)?/": "^heute", "/^tom(orrow)?/": "^morgen", "/^n(ow)?/": "^jetzt|sofort|gleich", "/^ms|milli(second)?s?/": "^ms|milli(sekunde(n)?)?", "/^sec(ond)?s?/": "^sek(unde(n)?)?", "/^mn|min(ute)?s?/": "^mn|min(ute(n)?)?", "/^h(our)?s?/": "^h|st(d|unde(n)?)?", "/^w(eek)?s?/": "^w(oche(n)?)?", "/^m(onth)?s?/": "^m(onat(e)?)?", "/^d(ay)?s?/": "^d|t(ag(en)?)?", "/^y(ear)?s?/": "^y|j(ahr(en)?)?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "de-CH"; ================================================ FILE: src/i18n/de-DE.js ================================================ /* * DateJS Culture String File * Country Code: de-DE * Name: German (Germany) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["de-DE"] = { "name": "de-DE", "englishName": "German (Germany)", "nativeName": "Deutsch (Deutschland)", "Sunday": "Sonntag", "Monday": "Montag", "Tuesday": "Dienstag", "Wednesday": "Mittwoch", "Thursday": "Donnerstag", "Friday": "Freitag", "Saturday": "Samstag", "Sun": "Son", "Mon": "Mon", "Tue": "Die", "Wed": "Mit", "Thu": "Don", "Fri": "Fre", "Sat": "Sam", "Su": "So", "Mo": "Mo", "Tu": "Di", "We": "Mi", "Th": "Do", "Fr": "Fr", "Sa": "Sa", "S_Sun_Initial": "S", "M_Mon_Initial": "M", "T_Tue_Initial": "D", "W_Wed_Initial": "M", "T_Thu_Initial": "D", "F_Fri_Initial": "F", "S_Sat_Initial": "S", "January": "Januar", "February": "Februar", "March": "März", "April": "April", "May": "Mai", "June": "Juni", "July": "Juli", "August": "August", "September": "September", "October": "Oktober", "November": "November", "December": "Dezember", "Jan_Abbr": "Jan", "Feb_Abbr": "Feb", "Mar_Abbr": "Mrz", "Apr_Abbr": "Apr", "May_Abbr": "Mai", "Jun_Abbr": "Jun", "Jul_Abbr": "Jul", "Aug_Abbr": "Aug", "Sep_Abbr": "Sep", "Oct_Abbr": "Okt", "Nov_Abbr": "Nov", "Dec_Abbr": "Dez", "AM": "", "PM": "", "firstDayOfWeek": 1, "twoDigitYearMax": 2029, "mdy": "dmy", "M/d/yyyy": "dd.MM.yyyy", "dddd, MMMM dd, yyyy": "dddd, d. MMMM yyyy", "h:mm tt": "HH:mm", "h:mm:ss tt": "HH:mm:ss", "dddd, MMMM dd, yyyy h:mm:ss tt": "dddd, d. MMMM yyyy HH:mm:ss", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "dd MMMM", "MMMM, yyyy": "MMMM yyyy", "/jan(uary)?/": "jan(uar)?", "/feb(ruary)?/": "feb(ruar)?", "/mar(ch)?/": "märz", "/apr(il)?/": "apr(il)?", "/may/": "mai", "/jun(e)?/": "jun(i)?", "/jul(y)?/": "jul(i)?", "/aug(ust)?/": "aug(ust)?", "/sep(t(ember)?)?/": "sep(t(ember)?)?", "/oct(ober)?/": "okt(ober)?", "/nov(ember)?/": "nov(ember)?", "/dec(ember)?/": "dez(ember)?", "/^su(n(day)?)?/": "^sonntag", "/^mo(n(day)?)?/": "^montag", "/^tu(e(s(day)?)?)?/": "^dienstag", "/^we(d(nesday)?)?/": "^mittwoch", "/^th(u(r(s(day)?)?)?)?/": "^donnerstag", "/^fr(i(day)?)?/": "^freitag", "/^sa(t(urday)?)?/": "^samstag", "/^next/": "^nächste(r|s|n)?", "/^last|past|prev(ious)?/": "^letzte(r|s|n)?|vergangene(r|s|n)?|vorherige(r|s|n)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|(da)?nach(er)?|von|daher|in)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|(be|zu)?vor|früher)", "/^yes(terday)?/": "^gestern", "/^t(od(ay)?)?/": "^heute", "/^tom(orrow)?/": "^morgen", "/^n(ow)?/": "^jetzt|sofort|gleich", "/^ms|milli(second)?s?/": "^ms|milli(sekunde(n)?)?", "/^sec(ond)?s?/": "^sek(unde(n)?)?", "/^mn|min(ute)?s?/": "^mn|min(ute(n)?)?", "/^h(our)?s?/": "^h|st(d|unde(n)?)?", "/^w(eek)?s?/": "^w(oche(n)?)?", "/^m(onth)?s?/": "^m(onat(e)?)?", "/^d(ay)?s?/": "^d|t(ag(en)?)?", "/^y(ear)?s?/": "^y|j(ahr(en)?)?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "de-DE"; ================================================ FILE: src/i18n/de-LI.js ================================================ /* * DateJS Culture String File * Country Code: de-LI * Name: German (Liechtenstein) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["de-LI"] = { "name": "de-LI", "englishName": "German (Liechtenstein)", "nativeName": "Deutsch (Liechtenstein)", "Sunday": "Sonntag", "Monday": "Montag", "Tuesday": "Dienstag", "Wednesday": "Mittwoch", "Thursday": "Donnerstag", "Friday": "Freitag", "Saturday": "Samstag", "Sun": "Son", "Mon": "Mon", "Tue": "Die", "Wed": "Mit", "Thu": "Don", "Fri": "Fre", "Sat": "Sam", "Su": "So", "Mo": "Mo", "Tu": "Di", "We": "Mi", "Th": "Do", "Fr": "Fr", "Sa": "Sa", "S_Sun_Initial": "S", "M_Mon_Initial": "M", "T_Tue_Initial": "D", "W_Wed_Initial": "M", "T_Thu_Initial": "D", "F_Fri_Initial": "F", "S_Sat_Initial": "S", "January": "Januar", "February": "Februar", "March": "März", "April": "April", "May": "Mai", "June": "Juni", "July": "Juli", "August": "August", "September": "September", "October": "Oktober", "November": "November", "December": "Dezember", "Jan_Abbr": "Jan", "Feb_Abbr": "Feb", "Mar_Abbr": "Mrz", "Apr_Abbr": "Apr", "May_Abbr": "Mai", "Jun_Abbr": "Jun", "Jul_Abbr": "Jul", "Aug_Abbr": "Aug", "Sep_Abbr": "Sep", "Oct_Abbr": "Okt", "Nov_Abbr": "Nov", "Dec_Abbr": "Dez", "AM": "", "PM": "", "firstDayOfWeek": 1, "twoDigitYearMax": 2029, "mdy": "dmy", "M/d/yyyy": "dd.MM.yyyy", "dddd, MMMM dd, yyyy": "dddd, d. MMMM yyyy", "h:mm tt": "HH:mm", "h:mm:ss tt": "HH:mm:ss", "dddd, MMMM dd, yyyy h:mm:ss tt": "dddd, d. MMMM yyyy HH:mm:ss", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "dd MMMM", "MMMM, yyyy": "MMMM yyyy", "/jan(uary)?/": "jan(uar)?", "/feb(ruary)?/": "feb(ruar)?", "/mar(ch)?/": "märz", "/apr(il)?/": "apr(il)?", "/may/": "mai", "/jun(e)?/": "jun(i)?", "/jul(y)?/": "jul(i)?", "/aug(ust)?/": "aug(ust)?", "/sep(t(ember)?)?/": "sep(t(ember)?)?", "/oct(ober)?/": "okt(ober)?", "/nov(ember)?/": "nov(ember)?", "/dec(ember)?/": "dez(ember)?", "/^su(n(day)?)?/": "^sonntag", "/^mo(n(day)?)?/": "^montag", "/^tu(e(s(day)?)?)?/": "^dienstag", "/^we(d(nesday)?)?/": "^mittwoch", "/^th(u(r(s(day)?)?)?)?/": "^donnerstag", "/^fr(i(day)?)?/": "^freitag", "/^sa(t(urday)?)?/": "^samstag", "/^next/": "^nächste(r|s|n)?", "/^last|past|prev(ious)?/": "^letzte(r|s|n)?|vergangene(r|s|n)?|vorherige(r|s|n)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|(da)?nach(er)?|von|daher|in)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|(be|zu)?vor|früher)", "/^yes(terday)?/": "^gestern", "/^t(od(ay)?)?/": "^heute", "/^tom(orrow)?/": "^morgen", "/^n(ow)?/": "^jetzt|sofort|gleich", "/^ms|milli(second)?s?/": "^ms|milli(sekunde(n)?)?", "/^sec(ond)?s?/": "^sek(unde(n)?)?", "/^mn|min(ute)?s?/": "^mn|min(ute(n)?)?", "/^h(our)?s?/": "^h|st(d|unde(n)?)?", "/^w(eek)?s?/": "^w(oche(n)?)?", "/^m(onth)?s?/": "^m(onat(e)?)?", "/^d(ay)?s?/": "^d|t(ag(en)?)?", "/^y(ear)?s?/": "^y|j(ahr(en)?)?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "de-LI"; ================================================ FILE: src/i18n/de-LU.js ================================================ /* * DateJS Culture String File * Country Code: de-LU * Name: German (Luxembourg) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["de-LU"] = { "name": "de-LU", "englishName": "German (Luxembourg)", "nativeName": "Deutsch (Luxemburg)", "Sunday": "Sonntag", "Monday": "Montag", "Tuesday": "Dienstag", "Wednesday": "Mittwoch", "Thursday": "Donnerstag", "Friday": "Freitag", "Saturday": "Samstag", "Sun": "Son", "Mon": "Mon", "Tue": "Die", "Wed": "Mit", "Thu": "Don", "Fri": "Fre", "Sat": "Sam", "Su": "So", "Mo": "Mo", "Tu": "Di", "We": "Mi", "Th": "Do", "Fr": "Fr", "Sa": "Sa", "S_Sun_Initial": "S", "M_Mon_Initial": "M", "T_Tue_Initial": "D", "W_Wed_Initial": "M", "T_Thu_Initial": "D", "F_Fri_Initial": "F", "S_Sat_Initial": "S", "January": "Januar", "February": "Februar", "March": "März", "April": "April", "May": "Mai", "June": "Juni", "July": "Juli", "August": "August", "September": "September", "October": "Oktober", "November": "November", "December": "Dezember", "Jan_Abbr": "Jan", "Feb_Abbr": "Feb", "Mar_Abbr": "Mrz", "Apr_Abbr": "Apr", "May_Abbr": "Mai", "Jun_Abbr": "Jun", "Jul_Abbr": "Jul", "Aug_Abbr": "Aug", "Sep_Abbr": "Sep", "Oct_Abbr": "Okt", "Nov_Abbr": "Nov", "Dec_Abbr": "Dez", "AM": "", "PM": "", "firstDayOfWeek": 1, "twoDigitYearMax": 2029, "mdy": "dmy", "M/d/yyyy": "dd.MM.yyyy", "dddd, MMMM dd, yyyy": "dddd, d. MMMM yyyy", "h:mm tt": "HH:mm", "h:mm:ss tt": "HH:mm:ss", "dddd, MMMM dd, yyyy h:mm:ss tt": "dddd, d. MMMM yyyy HH:mm:ss", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "dd MMMM", "MMMM, yyyy": "MMMM yyyy", "/jan(uary)?/": "jan(uar)?", "/feb(ruary)?/": "feb(ruar)?", "/mar(ch)?/": "märz", "/apr(il)?/": "apr(il)?", "/may/": "mai", "/jun(e)?/": "jun(i)?", "/jul(y)?/": "jul(i)?", "/aug(ust)?/": "aug(ust)?", "/sep(t(ember)?)?/": "sep(t(ember)?)?", "/oct(ober)?/": "okt(ober)?", "/nov(ember)?/": "nov(ember)?", "/dec(ember)?/": "dez(ember)?", "/^su(n(day)?)?/": "^sonntag", "/^mo(n(day)?)?/": "^montag", "/^tu(e(s(day)?)?)?/": "^dienstag", "/^we(d(nesday)?)?/": "^mittwoch", "/^th(u(r(s(day)?)?)?)?/": "^donnerstag", "/^fr(i(day)?)?/": "^freitag", "/^sa(t(urday)?)?/": "^samstag", "/^next/": "^nächste(r|s|n)?", "/^last|past|prev(ious)?/": "^letzte(r|s|n)?|vergangene(r|s|n)?|vorherige(r|s|n)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|(da)?nach(er)?|von|daher|in)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|(be|zu)?vor|früher)", "/^yes(terday)?/": "^gestern", "/^t(od(ay)?)?/": "^heute", "/^tom(orrow)?/": "^morgen", "/^n(ow)?/": "^jetzt|sofort|gleich", "/^ms|milli(second)?s?/": "^ms|milli(sekunde(n)?)?", "/^sec(ond)?s?/": "^sek(unde(n)?)?", "/^mn|min(ute)?s?/": "^mn|min(ute(n)?)?", "/^h(our)?s?/": "^h|st(d|unde(n)?)?", "/^w(eek)?s?/": "^w(oche(n)?)?", "/^m(onth)?s?/": "^m(onat(e)?)?", "/^d(ay)?s?/": "^d|t(ag(en)?)?", "/^y(ear)?s?/": "^y|j(ahr(en)?)?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "de-LU"; ================================================ FILE: src/i18n/dv-MV.js ================================================ /* * DateJS Culture String File * Country Code: dv-MV * Name: Divehi (Maldives) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["dv-MV"] = { "name": "dv-MV", "englishName": "Divehi (Maldives)", "nativeName": "ދިވެހިބަސް (ދިވެހި ރާއްޖެ)", "Sunday": "الاحد", "Monday": "الاثنين", "Tuesday": "الثلاثاء", "Wednesday": "الاربعاء", "Thursday": "الخميس", "Friday": "الجمعة", "Saturday": "السبت", "Sun": "الاحد", "Mon": "الاثنين", "Tue": "الثلاثاء", "Wed": "الاربعاء", "Thu": "الخميس", "Fri": "الجمعة", "Sat": "السبت", "Su": "ح", "Mo": "ن", "Tu": "ث", "We": "ر", "Th": "خ", "Fr": "ج", "Sa": "س", "S_Sun_Initial": "ح", "M_Mon_Initial": "ن", "T_Tue_Initial": "ث", "W_Wed_Initial": "ر", "T_Thu_Initial": "خ", "F_Fri_Initial": "ج", "S_Sat_Initial": "س", "January": "محرم", "February": "صفر", "March": "ربيع الأول", "April": "ربيع الثاني", "May": "جمادى الأولى", "June": "جمادى الثانية", "July": "رجب", "August": "شعبان", "September": "رمضان", "October": "شوال", "November": "ذو القعدة", "December": "ذو الحجة", "Jan_Abbr": "محرم", "Feb_Abbr": "صفر", "Mar_Abbr": "ربيع الاول", "Apr_Abbr": "ربيع الثاني", "May_Abbr": "جمادى الاولى", "Jun_Abbr": "جمادى الثانية", "Jul_Abbr": "رجب", "Aug_Abbr": "شعبان", "Sep_Abbr": "رمضان", "Oct_Abbr": "شوال", "Nov_Abbr": "ذو القعدة", "Dec_Abbr": "ذو الحجة", "AM": "މކ", "PM": "މފ", "firstDayOfWeek": 0, "twoDigitYearMax": 1451, "mdy": "dmy", "M/d/yyyy": "dd/MM/yy", "dddd, MMMM dd, yyyy": "dd/MMMM/yyyy", "h:mm tt": "HH:mm", "h:mm:ss tt": "HH:mm:ss", "dddd, MMMM dd, yyyy h:mm:ss tt": "dd/MMMM/yyyy HH:mm:ss", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "dd MMMM", "MMMM, yyyy": "MMMM, yyyy", "/jan(uary)?/": "محرم", "/feb(ruary)?/": "صفر", "/mar(ch)?/": "ربيع الأول", "/apr(il)?/": "ربيع الثاني", "/may/": "جمادى الأولى", "/jun(e)?/": "جمادى الثانية", "/jul(y)?/": "رجب", "/aug(ust)?/": "شعبان", "/sep(t(ember)?)?/": "رمضان", "/oct(ober)?/": "شوال", "/nov(ember)?/": "ذو القعدة", "/dec(ember)?/": "ذو الحجة", "/^su(n(day)?)?/": "^الاحد", "/^mo(n(day)?)?/": "^الاثنين", "/^tu(e(s(day)?)?)?/": "^الثلاثاء", "/^we(d(nesday)?)?/": "^الاربعاء", "/^th(u(r(s(day)?)?)?)?/": "^الخميس", "/^fr(i(day)?)?/": "^الجمعة", "/^sa(t(urday)?)?/": "^السبت", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "dv-MV"; ================================================ FILE: src/i18n/el-GR.js ================================================ /* * DateJS Culture String File * Country Code: el-GR * Name: Greek (Greece) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["el-GR"] = { "name": "el-GR", "englishName": "Greek (Greece)", "nativeName": "ελληνικά (Ελλάδα)", "Sunday": "Κυριακή", "Monday": "Δευτέρα", "Tuesday": "Τρίτη", "Wednesday": "Τετάρτη", "Thursday": "Πέμπτη", "Friday": "Παρασκευή", "Saturday": "Σάββατο", "Sun": "Κυρ", "Mon": "Δευ", "Tue": "Τρι", "Wed": "Τετ", "Thu": "Πεμ", "Fri": "Παρ", "Sat": "Σαβ", "Su": "Κυ", "Mo": "Δε", "Tu": "Τρ", "We": "Τε", "Th": "Πε", "Fr": "Πα", "Sa": "Σά", "S_Sun_Initial": "Κ", "M_Mon_Initial": "Δ", "T_Tue_Initial": "Τ", "W_Wed_Initial": "Τ", "T_Thu_Initial": "Π", "F_Fri_Initial": "Π", "S_Sat_Initial": "Σ", "January": "Ιανουάριος", "February": "Φεβρουάριος", "March": "Μάρτιος", "April": "Απρίλιος", "May": "Μάιος", "June": "Ιούνιος", "July": "Ιούλιος", "August": "Αύγουστος", "September": "Σεπτέμβριος", "October": "Οκτώβριος", "November": "Νοέμβριος", "December": "Δεκέμβριος", "Jan_Abbr": "Ιαν", "Feb_Abbr": "Φεβ", "Mar_Abbr": "Μαρ", "Apr_Abbr": "Απρ", "May_Abbr": "Μαϊ", "Jun_Abbr": "Ιουν", "Jul_Abbr": "Ιουλ", "Aug_Abbr": "Αυγ", "Sep_Abbr": "Σεπ", "Oct_Abbr": "Οκτ", "Nov_Abbr": "Νοε", "Dec_Abbr": "Δεκ", "AM": "πμ", "PM": "μμ", "firstDayOfWeek": 1, "twoDigitYearMax": 2029, "mdy": "dmy", "M/d/yyyy": "d/M/yyyy", "dddd, MMMM dd, yyyy": "dddd, d MMMM yyyy", "h:mm tt": "h:mm tt", "h:mm:ss tt": "h:mm:ss tt", "dddd, MMMM dd, yyyy h:mm:ss tt": "dddd, d MMMM yyyy h:mm:ss tt", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "dd MMMM", "MMMM, yyyy": "MMMM yyyy", "/jan(uary)?/": "ιαν(ουάριος)?", "/feb(ruary)?/": "φεβ(ρουάριος)?", "/mar(ch)?/": "μάρτιος", "/apr(il)?/": "απρ(ίλιος)?", "/may/": "μάιος", "/jun(e)?/": "ιούνιος", "/jul(y)?/": "ιούλιος", "/aug(ust)?/": "αύγουστος", "/sep(t(ember)?)?/": "σεπ(τέμβριος)?", "/oct(ober)?/": "οκτ(ώβριος)?", "/nov(ember)?/": "νοέμβριος", "/dec(ember)?/": "δεκ(έμβριος)?", "/^su(n(day)?)?/": "^κυ(ρ(ιακή)?)?", "/^mo(n(day)?)?/": "^δε(υ(τέρα)?)?", "/^tu(e(s(day)?)?)?/": "^τρ(ι(τη)?)?", "/^we(d(nesday)?)?/": "^τε(τ(άρτη)?)?", "/^th(u(r(s(day)?)?)?)?/": "^πε(μ(πτη)?)?", "/^fr(i(day)?)?/": "^πα(ρ(ασκευή)?)?", "/^sa(t(urday)?)?/": "^σά(β(βατο)?)?", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "el-GR"; ================================================ FILE: src/i18n/en-029.js ================================================ /* * DateJS Culture String File * Country Code: en-029 * Name: English (Caribbean) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["en-029"] = { "name": "en-029", "englishName": "English (Caribbean)", "nativeName": "English (Caribbean)", "Sunday": "Sunday", "Monday": "Monday", "Tuesday": "Tuesday", "Wednesday": "Wednesday", "Thursday": "Thursday", "Friday": "Friday", "Saturday": "Saturday", "Sun": "Sun", "Mon": "Mon", "Tue": "Tue", "Wed": "Wed", "Thu": "Thu", "Fri": "Fri", "Sat": "Sat", "Su": "Su", "Mo": "Mo", "Tu": "Tu", "We": "We", "Th": "Th", "Fr": "Fr", "Sa": "Sa", "S_Sun_Initial": "S", "M_Mon_Initial": "M", "T_Tue_Initial": "T", "W_Wed_Initial": "W", "T_Thu_Initial": "T", "F_Fri_Initial": "F", "S_Sat_Initial": "S", "January": "January", "February": "February", "March": "March", "April": "April", "May": "May", "June": "June", "July": "July", "August": "August", "September": "September", "October": "October", "November": "November", "December": "December", "Jan_Abbr": "Jan", "Feb_Abbr": "Feb", "Mar_Abbr": "Mar", "Apr_Abbr": "Apr", "May_Abbr": "May", "Jun_Abbr": "Jun", "Jul_Abbr": "Jul", "Aug_Abbr": "Aug", "Sep_Abbr": "Sep", "Oct_Abbr": "Oct", "Nov_Abbr": "Nov", "Dec_Abbr": "Dec", "AM": "AM", "PM": "PM", "firstDayOfWeek": 1, "twoDigitYearMax": 2029, "mdy": "mdy", "M/d/yyyy": "MM/dd/yyyy", "dddd, MMMM dd, yyyy": "dddd, MMMM dd, yyyy", "h:mm tt": "h:mm tt", "h:mm:ss tt": "h:mm:ss tt", "dddd, MMMM dd, yyyy h:mm:ss tt": "dddd, MMMM dd, yyyy h:mm:ss tt", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "MMMM dd", "MMMM, yyyy": "MMMM, yyyy", "/jan(uary)?/": "jan(uary)?", "/feb(ruary)?/": "feb(ruary)?", "/mar(ch)?/": "mar(ch)?", "/apr(il)?/": "apr(il)?", "/may/": "may", "/jun(e)?/": "jun(e)?", "/jul(y)?/": "jul(y)?", "/aug(ust)?/": "aug(ust)?", "/sep(t(ember)?)?/": "sep(t(ember)?)?", "/oct(ober)?/": "oct(ober)?", "/nov(ember)?/": "nov(ember)?", "/dec(ember)?/": "dec(ember)?", "/^su(n(day)?)?/": "^su(n(day)?)?", "/^mo(n(day)?)?/": "^mo(n(day)?)?", "/^tu(e(s(day)?)?)?/": "^tu(e(s(day)?)?)?", "/^we(d(nesday)?)?/": "^we(d(nesday)?)?", "/^th(u(r(s(day)?)?)?)?/": "^th(u(r(s(day)?)?)?)?", "/^fr(i(day)?)?/": "^fr(i(day)?)?", "/^sa(t(urday)?)?/": "^sa(t(urday)?)?", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "en-029"; ================================================ FILE: src/i18n/en-AU.js ================================================ /* * DateJS Culture String File * Country Code: en-AU * Name: English (Australia) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["en-AU"] = { "name": "en-AU", "englishName": "English (Australia)", "nativeName": "English (Australia)", "Sunday": "Sunday", "Monday": "Monday", "Tuesday": "Tuesday", "Wednesday": "Wednesday", "Thursday": "Thursday", "Friday": "Friday", "Saturday": "Saturday", "Sun": "Sun", "Mon": "Mon", "Tue": "Tue", "Wed": "Wed", "Thu": "Thu", "Fri": "Fri", "Sat": "Sat", "Su": "Su", "Mo": "Mo", "Tu": "Tu", "We": "We", "Th": "Th", "Fr": "Fr", "Sa": "Sa", "S_Sun_Initial": "S", "M_Mon_Initial": "M", "T_Tue_Initial": "T", "W_Wed_Initial": "W", "T_Thu_Initial": "T", "F_Fri_Initial": "F", "S_Sat_Initial": "S", "January": "January", "February": "February", "March": "March", "April": "April", "May": "May", "June": "June", "July": "July", "August": "August", "September": "September", "October": "October", "November": "November", "December": "December", "Jan_Abbr": "Jan", "Feb_Abbr": "Feb", "Mar_Abbr": "Mar", "Apr_Abbr": "Apr", "May_Abbr": "May", "Jun_Abbr": "Jun", "Jul_Abbr": "Jul", "Aug_Abbr": "Aug", "Sep_Abbr": "Sep", "Oct_Abbr": "Oct", "Nov_Abbr": "Nov", "Dec_Abbr": "Dec", "AM": "AM", "PM": "PM", "firstDayOfWeek": 1, "twoDigitYearMax": 2029, "mdy": "dmy", "M/d/yyyy": "d/MM/yyyy", "dddd, MMMM dd, yyyy": "dddd, d MMMM yyyy", "h:mm tt": "h:mm tt", "h:mm:ss tt": "h:mm:ss tt", "dddd, MMMM dd, yyyy h:mm:ss tt": "dddd, d MMMM yyyy h:mm:ss tt", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "dd MMMM", "MMMM, yyyy": "MMMM yyyy", "/jan(uary)?/": "jan(uary)?", "/feb(ruary)?/": "feb(ruary)?", "/mar(ch)?/": "mar(ch)?", "/apr(il)?/": "apr(il)?", "/may/": "may", "/jun(e)?/": "jun(e)?", "/jul(y)?/": "jul(y)?", "/aug(ust)?/": "aug(ust)?", "/sep(t(ember)?)?/": "sep(t(ember)?)?", "/oct(ober)?/": "oct(ober)?", "/nov(ember)?/": "nov(ember)?", "/dec(ember)?/": "dec(ember)?", "/^su(n(day)?)?/": "^su(n(day)?)?", "/^mo(n(day)?)?/": "^mo(n(day)?)?", "/^tu(e(s(day)?)?)?/": "^tu(e(s(day)?)?)?", "/^we(d(nesday)?)?/": "^we(d(nesday)?)?", "/^th(u(r(s(day)?)?)?)?/": "^th(u(r(s(day)?)?)?)?", "/^fr(i(day)?)?/": "^fr(i(day)?)?", "/^sa(t(urday)?)?/": "^sa(t(urday)?)?", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "en-AU"; ================================================ FILE: src/i18n/en-BZ.js ================================================ /* * DateJS Culture String File * Country Code: en-BZ * Name: English (Belize) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["en-BZ"] = { "name": "en-BZ", "englishName": "English (Belize)", "nativeName": "English (Belize)", "Sunday": "Sunday", "Monday": "Monday", "Tuesday": "Tuesday", "Wednesday": "Wednesday", "Thursday": "Thursday", "Friday": "Friday", "Saturday": "Saturday", "Sun": "Sun", "Mon": "Mon", "Tue": "Tue", "Wed": "Wed", "Thu": "Thu", "Fri": "Fri", "Sat": "Sat", "Su": "Su", "Mo": "Mo", "Tu": "Tu", "We": "We", "Th": "Th", "Fr": "Fr", "Sa": "Sa", "S_Sun_Initial": "S", "M_Mon_Initial": "M", "T_Tue_Initial": "T", "W_Wed_Initial": "W", "T_Thu_Initial": "T", "F_Fri_Initial": "F", "S_Sat_Initial": "S", "January": "January", "February": "February", "March": "March", "April": "April", "May": "May", "June": "June", "July": "July", "August": "August", "September": "September", "October": "October", "November": "November", "December": "December", "Jan_Abbr": "Jan", "Feb_Abbr": "Feb", "Mar_Abbr": "Mar", "Apr_Abbr": "Apr", "May_Abbr": "May", "Jun_Abbr": "Jun", "Jul_Abbr": "Jul", "Aug_Abbr": "Aug", "Sep_Abbr": "Sep", "Oct_Abbr": "Oct", "Nov_Abbr": "Nov", "Dec_Abbr": "Dec", "AM": "AM", "PM": "PM", "firstDayOfWeek": 0, "twoDigitYearMax": 2029, "mdy": "dmy", "M/d/yyyy": "dd/MM/yyyy", "dddd, MMMM dd, yyyy": "dddd, dd MMMM yyyy", "h:mm tt": "hh:mm tt", "h:mm:ss tt": "hh:mm:ss tt", "dddd, MMMM dd, yyyy h:mm:ss tt": "dddd, dd MMMM yyyy hh:mm:ss tt", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "dd MMMM", "MMMM, yyyy": "MMMM yyyy", "/jan(uary)?/": "jan(uary)?", "/feb(ruary)?/": "feb(ruary)?", "/mar(ch)?/": "mar(ch)?", "/apr(il)?/": "apr(il)?", "/may/": "may", "/jun(e)?/": "jun(e)?", "/jul(y)?/": "jul(y)?", "/aug(ust)?/": "aug(ust)?", "/sep(t(ember)?)?/": "sep(t(ember)?)?", "/oct(ober)?/": "oct(ober)?", "/nov(ember)?/": "nov(ember)?", "/dec(ember)?/": "dec(ember)?", "/^su(n(day)?)?/": "^su(n(day)?)?", "/^mo(n(day)?)?/": "^mo(n(day)?)?", "/^tu(e(s(day)?)?)?/": "^tu(e(s(day)?)?)?", "/^we(d(nesday)?)?/": "^we(d(nesday)?)?", "/^th(u(r(s(day)?)?)?)?/": "^th(u(r(s(day)?)?)?)?", "/^fr(i(day)?)?/": "^fr(i(day)?)?", "/^sa(t(urday)?)?/": "^sa(t(urday)?)?", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "en-BZ"; ================================================ FILE: src/i18n/en-CA.js ================================================ /* * DateJS Culture String File * Country Code: en-CA * Name: English (Canada) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["en-CA"] = { "name": "en-CA", "englishName": "English (Canada)", "nativeName": "English (Canada)", "Sunday": "Sunday", "Monday": "Monday", "Tuesday": "Tuesday", "Wednesday": "Wednesday", "Thursday": "Thursday", "Friday": "Friday", "Saturday": "Saturday", "Sun": "Sun", "Mon": "Mon", "Tue": "Tue", "Wed": "Wed", "Thu": "Thu", "Fri": "Fri", "Sat": "Sat", "Su": "Su", "Mo": "Mo", "Tu": "Tu", "We": "We", "Th": "Th", "Fr": "Fr", "Sa": "Sa", "S_Sun_Initial": "S", "M_Mon_Initial": "M", "T_Tue_Initial": "T", "W_Wed_Initial": "W", "T_Thu_Initial": "T", "F_Fri_Initial": "F", "S_Sat_Initial": "S", "January": "January", "February": "February", "March": "March", "April": "April", "May": "May", "June": "June", "July": "July", "August": "August", "September": "September", "October": "October", "November": "November", "December": "December", "Jan_Abbr": "Jan", "Feb_Abbr": "Feb", "Mar_Abbr": "Mar", "Apr_Abbr": "Apr", "May_Abbr": "May", "Jun_Abbr": "Jun", "Jul_Abbr": "Jul", "Aug_Abbr": "Aug", "Sep_Abbr": "Sep", "Oct_Abbr": "Oct", "Nov_Abbr": "Nov", "Dec_Abbr": "Dec", "AM": "AM", "PM": "PM", "firstDayOfWeek": 0, "twoDigitYearMax": 2029, "mdy": "dmy", "M/d/yyyy": "dd/MM/yyyy", "dddd, MMMM dd, yyyy": "MMMM d, yyyy", "h:mm tt": "h:mm tt", "h:mm:ss tt": "h:mm:ss tt", "dddd, MMMM dd, yyyy h:mm:ss tt": "MMMM d, yyyy h:mm:ss tt", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "MMMM dd", "MMMM, yyyy": "MMMM, yyyy", "/jan(uary)?/": "jan(uary)?", "/feb(ruary)?/": "feb(ruary)?", "/mar(ch)?/": "mar(ch)?", "/apr(il)?/": "apr(il)?", "/may/": "may", "/jun(e)?/": "jun(e)?", "/jul(y)?/": "jul(y)?", "/aug(ust)?/": "aug(ust)?", "/sep(t(ember)?)?/": "sep(t(ember)?)?", "/oct(ober)?/": "oct(ober)?", "/nov(ember)?/": "nov(ember)?", "/dec(ember)?/": "dec(ember)?", "/^su(n(day)?)?/": "^su(n(day)?)?", "/^mo(n(day)?)?/": "^mo(n(day)?)?", "/^tu(e(s(day)?)?)?/": "^tu(e(s(day)?)?)?", "/^we(d(nesday)?)?/": "^we(d(nesday)?)?", "/^th(u(r(s(day)?)?)?)?/": "^th(u(r(s(day)?)?)?)?", "/^fr(i(day)?)?/": "^fr(i(day)?)?", "/^sa(t(urday)?)?/": "^sa(t(urday)?)?", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "en-CA"; ================================================ FILE: src/i18n/en-GB.js ================================================ /* * DateJS Culture String File * Country Code: en-GB * Name: English (United Kingdom) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["en-GB"] = { "name": "en-GB", "englishName": "English (United Kingdom)", "nativeName": "English (United Kingdom)", "Sunday": "Sunday", "Monday": "Monday", "Tuesday": "Tuesday", "Wednesday": "Wednesday", "Thursday": "Thursday", "Friday": "Friday", "Saturday": "Saturday", "Sun": "Sun", "Mon": "Mon", "Tue": "Tue", "Wed": "Wed", "Thu": "Thu", "Fri": "Fri", "Sat": "Sat", "Su": "Su", "Mo": "Mo", "Tu": "Tu", "We": "We", "Th": "Th", "Fr": "Fr", "Sa": "Sa", "S_Sun_Initial": "S", "M_Mon_Initial": "M", "T_Tue_Initial": "T", "W_Wed_Initial": "W", "T_Thu_Initial": "T", "F_Fri_Initial": "F", "S_Sat_Initial": "S", "January": "January", "February": "February", "March": "March", "April": "April", "May": "May", "June": "June", "July": "July", "August": "August", "September": "September", "October": "October", "November": "November", "December": "December", "Jan_Abbr": "Jan", "Feb_Abbr": "Feb", "Mar_Abbr": "Mar", "Apr_Abbr": "Apr", "May_Abbr": "May", "Jun_Abbr": "Jun", "Jul_Abbr": "Jul", "Aug_Abbr": "Aug", "Sep_Abbr": "Sep", "Oct_Abbr": "Oct", "Nov_Abbr": "Nov", "Dec_Abbr": "Dec", "AM": "AM", "PM": "PM", "firstDayOfWeek": 1, "twoDigitYearMax": 2029, "mdy": "dmy", "M/d/yyyy": "dd/MM/yyyy", "dddd, MMMM dd, yyyy": "dd MMMM yyyy", "h:mm tt": "HH:mm", "h:mm:ss tt": "HH:mm:ss", "dddd, MMMM dd, yyyy h:mm:ss tt": "dd MMMM yyyy HH:mm:ss", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "dd MMMM", "MMMM, yyyy": "MMMM yyyy", "/jan(uary)?/": "jan(uary)?", "/feb(ruary)?/": "feb(ruary)?", "/mar(ch)?/": "mar(ch)?", "/apr(il)?/": "apr(il)?", "/may/": "may", "/jun(e)?/": "jun(e)?", "/jul(y)?/": "jul(y)?", "/aug(ust)?/": "aug(ust)?", "/sep(t(ember)?)?/": "sep(t(ember)?)?", "/oct(ober)?/": "oct(ober)?", "/nov(ember)?/": "nov(ember)?", "/dec(ember)?/": "dec(ember)?", "/^su(n(day)?)?/": "^su(n(day)?)?", "/^mo(n(day)?)?/": "^mo(n(day)?)?", "/^tu(e(s(day)?)?)?/": "^tu(e(s(day)?)?)?", "/^we(d(nesday)?)?/": "^we(d(nesday)?)?", "/^th(u(r(s(day)?)?)?)?/": "^th(u(r(s(day)?)?)?)?", "/^fr(i(day)?)?/": "^fr(i(day)?)?", "/^sa(t(urday)?)?/": "^sa(t(urday)?)?", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "en-GB"; ================================================ FILE: src/i18n/en-IE.js ================================================ /* * DateJS Culture String File * Country Code: en-IE * Name: English (Ireland) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["en-IE"] = { "name": "en-IE", "englishName": "English (Ireland)", "nativeName": "English (Eire)", "Sunday": "Sunday", "Monday": "Monday", "Tuesday": "Tuesday", "Wednesday": "Wednesday", "Thursday": "Thursday", "Friday": "Friday", "Saturday": "Saturday", "Sun": "Sun", "Mon": "Mon", "Tue": "Tue", "Wed": "Wed", "Thu": "Thu", "Fri": "Fri", "Sat": "Sat", "Su": "Su", "Mo": "Mo", "Tu": "Tu", "We": "We", "Th": "Th", "Fr": "Fr", "Sa": "Sa", "S_Sun_Initial": "S", "M_Mon_Initial": "M", "T_Tue_Initial": "T", "W_Wed_Initial": "W", "T_Thu_Initial": "T", "F_Fri_Initial": "F", "S_Sat_Initial": "S", "January": "January", "February": "February", "March": "March", "April": "April", "May": "May", "June": "June", "July": "July", "August": "August", "September": "September", "October": "October", "November": "November", "December": "December", "Jan_Abbr": "Jan", "Feb_Abbr": "Feb", "Mar_Abbr": "Mar", "Apr_Abbr": "Apr", "May_Abbr": "May", "Jun_Abbr": "Jun", "Jul_Abbr": "Jul", "Aug_Abbr": "Aug", "Sep_Abbr": "Sep", "Oct_Abbr": "Oct", "Nov_Abbr": "Nov", "Dec_Abbr": "Dec", "AM": "", "PM": "", "firstDayOfWeek": 1, "twoDigitYearMax": 2029, "mdy": "dmy", "M/d/yyyy": "dd/MM/yyyy", "dddd, MMMM dd, yyyy": "dd MMMM yyyy", "h:mm tt": "HH:mm", "h:mm:ss tt": "HH:mm:ss", "dddd, MMMM dd, yyyy h:mm:ss tt": "dd MMMM yyyy HH:mm:ss", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "dd MMMM", "MMMM, yyyy": "MMMM yyyy", "/jan(uary)?/": "jan(uary)?", "/feb(ruary)?/": "feb(ruary)?", "/mar(ch)?/": "mar(ch)?", "/apr(il)?/": "apr(il)?", "/may/": "may", "/jun(e)?/": "jun(e)?", "/jul(y)?/": "jul(y)?", "/aug(ust)?/": "aug(ust)?", "/sep(t(ember)?)?/": "sep(t(ember)?)?", "/oct(ober)?/": "oct(ober)?", "/nov(ember)?/": "nov(ember)?", "/dec(ember)?/": "dec(ember)?", "/^su(n(day)?)?/": "^su(n(day)?)?", "/^mo(n(day)?)?/": "^mo(n(day)?)?", "/^tu(e(s(day)?)?)?/": "^tu(e(s(day)?)?)?", "/^we(d(nesday)?)?/": "^we(d(nesday)?)?", "/^th(u(r(s(day)?)?)?)?/": "^th(u(r(s(day)?)?)?)?", "/^fr(i(day)?)?/": "^fr(i(day)?)?", "/^sa(t(urday)?)?/": "^sa(t(urday)?)?", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "en-IE"; ================================================ FILE: src/i18n/en-JM.js ================================================ /* * DateJS Culture String File * Country Code: en-JM * Name: English (Jamaica) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["en-JM"] = { "name": "en-JM", "englishName": "English (Jamaica)", "nativeName": "English (Jamaica)", "Sunday": "Sunday", "Monday": "Monday", "Tuesday": "Tuesday", "Wednesday": "Wednesday", "Thursday": "Thursday", "Friday": "Friday", "Saturday": "Saturday", "Sun": "Sun", "Mon": "Mon", "Tue": "Tue", "Wed": "Wed", "Thu": "Thu", "Fri": "Fri", "Sat": "Sat", "Su": "Su", "Mo": "Mo", "Tu": "Tu", "We": "We", "Th": "Th", "Fr": "Fr", "Sa": "Sa", "S_Sun_Initial": "S", "M_Mon_Initial": "M", "T_Tue_Initial": "T", "W_Wed_Initial": "W", "T_Thu_Initial": "T", "F_Fri_Initial": "F", "S_Sat_Initial": "S", "January": "January", "February": "February", "March": "March", "April": "April", "May": "May", "June": "June", "July": "July", "August": "August", "September": "September", "October": "October", "November": "November", "December": "December", "Jan_Abbr": "Jan", "Feb_Abbr": "Feb", "Mar_Abbr": "Mar", "Apr_Abbr": "Apr", "May_Abbr": "May", "Jun_Abbr": "Jun", "Jul_Abbr": "Jul", "Aug_Abbr": "Aug", "Sep_Abbr": "Sep", "Oct_Abbr": "Oct", "Nov_Abbr": "Nov", "Dec_Abbr": "Dec", "AM": "AM", "PM": "PM", "firstDayOfWeek": 0, "twoDigitYearMax": 2029, "mdy": "dmy", "M/d/yyyy": "dd/MM/yyyy", "dddd, MMMM dd, yyyy": "dddd, MMMM dd, yyyy", "h:mm tt": "hh:mm tt", "h:mm:ss tt": "hh:mm:ss tt", "dddd, MMMM dd, yyyy h:mm:ss tt": "dddd, MMMM dd, yyyy hh:mm:ss tt", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "MMMM dd", "MMMM, yyyy": "MMMM, yyyy", "/jan(uary)?/": "jan(uary)?", "/feb(ruary)?/": "feb(ruary)?", "/mar(ch)?/": "mar(ch)?", "/apr(il)?/": "apr(il)?", "/may/": "may", "/jun(e)?/": "jun(e)?", "/jul(y)?/": "jul(y)?", "/aug(ust)?/": "aug(ust)?", "/sep(t(ember)?)?/": "sep(t(ember)?)?", "/oct(ober)?/": "oct(ober)?", "/nov(ember)?/": "nov(ember)?", "/dec(ember)?/": "dec(ember)?", "/^su(n(day)?)?/": "^su(n(day)?)?", "/^mo(n(day)?)?/": "^mo(n(day)?)?", "/^tu(e(s(day)?)?)?/": "^tu(e(s(day)?)?)?", "/^we(d(nesday)?)?/": "^we(d(nesday)?)?", "/^th(u(r(s(day)?)?)?)?/": "^th(u(r(s(day)?)?)?)?", "/^fr(i(day)?)?/": "^fr(i(day)?)?", "/^sa(t(urday)?)?/": "^sa(t(urday)?)?", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "en-JM"; ================================================ FILE: src/i18n/en-NZ.js ================================================ /* * DateJS Culture String File * Country Code: en-NZ * Name: English (New Zealand) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["en-NZ"] = { "name": "en-NZ", "englishName": "English (New Zealand)", "nativeName": "English (New Zealand)", "Sunday": "Sunday", "Monday": "Monday", "Tuesday": "Tuesday", "Wednesday": "Wednesday", "Thursday": "Thursday", "Friday": "Friday", "Saturday": "Saturday", "Sun": "Sun", "Mon": "Mon", "Tue": "Tue", "Wed": "Wed", "Thu": "Thu", "Fri": "Fri", "Sat": "Sat", "Su": "Su", "Mo": "Mo", "Tu": "Tu", "We": "We", "Th": "Th", "Fr": "Fr", "Sa": "Sa", "S_Sun_Initial": "S", "M_Mon_Initial": "M", "T_Tue_Initial": "T", "W_Wed_Initial": "W", "T_Thu_Initial": "T", "F_Fri_Initial": "F", "S_Sat_Initial": "S", "January": "January", "February": "February", "March": "March", "April": "April", "May": "May", "June": "June", "July": "July", "August": "August", "September": "September", "October": "October", "November": "November", "December": "December", "Jan_Abbr": "Jan", "Feb_Abbr": "Feb", "Mar_Abbr": "Mar", "Apr_Abbr": "Apr", "May_Abbr": "May", "Jun_Abbr": "Jun", "Jul_Abbr": "Jul", "Aug_Abbr": "Aug", "Sep_Abbr": "Sep", "Oct_Abbr": "Oct", "Nov_Abbr": "Nov", "Dec_Abbr": "Dec", "AM": "a.m.", "PM": "p.m.", "firstDayOfWeek": 1, "twoDigitYearMax": 2029, "mdy": "dmy", "M/d/yyyy": "d/MM/yyyy", "dddd, MMMM dd, yyyy": "dddd, d MMMM yyyy", "h:mm tt": "h:mm tt", "h:mm:ss tt": "h:mm:ss tt", "dddd, MMMM dd, yyyy h:mm:ss tt": "dddd, d MMMM yyyy h:mm:ss tt", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "dd MMMM", "MMMM, yyyy": "MMMM yyyy", "/jan(uary)?/": "jan(uary)?", "/feb(ruary)?/": "feb(ruary)?", "/mar(ch)?/": "mar(ch)?", "/apr(il)?/": "apr(il)?", "/may/": "may", "/jun(e)?/": "jun(e)?", "/jul(y)?/": "jul(y)?", "/aug(ust)?/": "aug(ust)?", "/sep(t(ember)?)?/": "sep(t(ember)?)?", "/oct(ober)?/": "oct(ober)?", "/nov(ember)?/": "nov(ember)?", "/dec(ember)?/": "dec(ember)?", "/^su(n(day)?)?/": "^su(n(day)?)?", "/^mo(n(day)?)?/": "^mo(n(day)?)?", "/^tu(e(s(day)?)?)?/": "^tu(e(s(day)?)?)?", "/^we(d(nesday)?)?/": "^we(d(nesday)?)?", "/^th(u(r(s(day)?)?)?)?/": "^th(u(r(s(day)?)?)?)?", "/^fr(i(day)?)?/": "^fr(i(day)?)?", "/^sa(t(urday)?)?/": "^sa(t(urday)?)?", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "en-NZ"; ================================================ FILE: src/i18n/en-PH.js ================================================ /* * DateJS Culture String File * Country Code: en-PH * Name: English (Republic of the Philippines) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["en-PH"] = { "name": "en-PH", "englishName": "English (Republic of the Philippines)", "nativeName": "English (Philippines)", "Sunday": "Sunday", "Monday": "Monday", "Tuesday": "Tuesday", "Wednesday": "Wednesday", "Thursday": "Thursday", "Friday": "Friday", "Saturday": "Saturday", "Sun": "Sun", "Mon": "Mon", "Tue": "Tue", "Wed": "Wed", "Thu": "Thu", "Fri": "Fri", "Sat": "Sat", "Su": "Su", "Mo": "Mo", "Tu": "Tu", "We": "We", "Th": "Th", "Fr": "Fr", "Sa": "Sa", "S_Sun_Initial": "S", "M_Mon_Initial": "M", "T_Tue_Initial": "T", "W_Wed_Initial": "W", "T_Thu_Initial": "T", "F_Fri_Initial": "F", "S_Sat_Initial": "S", "January": "January", "February": "February", "March": "March", "April": "April", "May": "May", "June": "June", "July": "July", "August": "August", "September": "September", "October": "October", "November": "November", "December": "December", "Jan_Abbr": "Jan", "Feb_Abbr": "Feb", "Mar_Abbr": "Mar", "Apr_Abbr": "Apr", "May_Abbr": "May", "Jun_Abbr": "Jun", "Jul_Abbr": "Jul", "Aug_Abbr": "Aug", "Sep_Abbr": "Sep", "Oct_Abbr": "Oct", "Nov_Abbr": "Nov", "Dec_Abbr": "Dec", "AM": "AM", "PM": "PM", "firstDayOfWeek": 0, "twoDigitYearMax": 2029, "mdy": "mdy", "M/d/yyyy": "M/d/yyyy", "dddd, MMMM dd, yyyy": "dddd, MMMM dd, yyyy", "h:mm tt": "h:mm tt", "h:mm:ss tt": "h:mm:ss tt", "dddd, MMMM dd, yyyy h:mm:ss tt": "dddd, MMMM dd, yyyy h:mm:ss tt", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "MMMM dd", "MMMM, yyyy": "MMMM, yyyy", "/jan(uary)?/": "jan(uary)?", "/feb(ruary)?/": "feb(ruary)?", "/mar(ch)?/": "mar(ch)?", "/apr(il)?/": "apr(il)?", "/may/": "may", "/jun(e)?/": "jun(e)?", "/jul(y)?/": "jul(y)?", "/aug(ust)?/": "aug(ust)?", "/sep(t(ember)?)?/": "sep(t(ember)?)?", "/oct(ober)?/": "oct(ober)?", "/nov(ember)?/": "nov(ember)?", "/dec(ember)?/": "dec(ember)?", "/^su(n(day)?)?/": "^su(n(day)?)?", "/^mo(n(day)?)?/": "^mo(n(day)?)?", "/^tu(e(s(day)?)?)?/": "^tu(e(s(day)?)?)?", "/^we(d(nesday)?)?/": "^we(d(nesday)?)?", "/^th(u(r(s(day)?)?)?)?/": "^th(u(r(s(day)?)?)?)?", "/^fr(i(day)?)?/": "^fr(i(day)?)?", "/^sa(t(urday)?)?/": "^sa(t(urday)?)?", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "en-PH"; ================================================ FILE: src/i18n/en-TT.js ================================================ /* * DateJS Culture String File * Country Code: en-TT * Name: English (Trinidad and Tobago) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["en-TT"] = { "name": "en-TT", "englishName": "English (Trinidad and Tobago)", "nativeName": "English (Trinidad y Tobago)", "Sunday": "Sunday", "Monday": "Monday", "Tuesday": "Tuesday", "Wednesday": "Wednesday", "Thursday": "Thursday", "Friday": "Friday", "Saturday": "Saturday", "Sun": "Sun", "Mon": "Mon", "Tue": "Tue", "Wed": "Wed", "Thu": "Thu", "Fri": "Fri", "Sat": "Sat", "Su": "Su", "Mo": "Mo", "Tu": "Tu", "We": "We", "Th": "Th", "Fr": "Fr", "Sa": "Sa", "S_Sun_Initial": "S", "M_Mon_Initial": "M", "T_Tue_Initial": "T", "W_Wed_Initial": "W", "T_Thu_Initial": "T", "F_Fri_Initial": "F", "S_Sat_Initial": "S", "January": "January", "February": "February", "March": "March", "April": "April", "May": "May", "June": "June", "July": "July", "August": "August", "September": "September", "October": "October", "November": "November", "December": "December", "Jan_Abbr": "Jan", "Feb_Abbr": "Feb", "Mar_Abbr": "Mar", "Apr_Abbr": "Apr", "May_Abbr": "May", "Jun_Abbr": "Jun", "Jul_Abbr": "Jul", "Aug_Abbr": "Aug", "Sep_Abbr": "Sep", "Oct_Abbr": "Oct", "Nov_Abbr": "Nov", "Dec_Abbr": "Dec", "AM": "AM", "PM": "PM", "firstDayOfWeek": 0, "twoDigitYearMax": 2029, "mdy": "dmy", "M/d/yyyy": "dd/MM/yyyy", "dddd, MMMM dd, yyyy": "dddd, dd MMMM yyyy", "h:mm tt": "hh:mm tt", "h:mm:ss tt": "hh:mm:ss tt", "dddd, MMMM dd, yyyy h:mm:ss tt": "dddd, dd MMMM yyyy hh:mm:ss tt", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "dd MMMM", "MMMM, yyyy": "MMMM yyyy", "/jan(uary)?/": "jan(uary)?", "/feb(ruary)?/": "feb(ruary)?", "/mar(ch)?/": "mar(ch)?", "/apr(il)?/": "apr(il)?", "/may/": "may", "/jun(e)?/": "jun(e)?", "/jul(y)?/": "jul(y)?", "/aug(ust)?/": "aug(ust)?", "/sep(t(ember)?)?/": "sep(t(ember)?)?", "/oct(ober)?/": "oct(ober)?", "/nov(ember)?/": "nov(ember)?", "/dec(ember)?/": "dec(ember)?", "/^su(n(day)?)?/": "^su(n(day)?)?", "/^mo(n(day)?)?/": "^mo(n(day)?)?", "/^tu(e(s(day)?)?)?/": "^tu(e(s(day)?)?)?", "/^we(d(nesday)?)?/": "^we(d(nesday)?)?", "/^th(u(r(s(day)?)?)?)?/": "^th(u(r(s(day)?)?)?)?", "/^fr(i(day)?)?/": "^fr(i(day)?)?", "/^sa(t(urday)?)?/": "^sa(t(urday)?)?", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "en-TT"; ================================================ FILE: src/i18n/en-ZA.js ================================================ /* * DateJS Culture String File * Country Code: en-ZA * Name: English (South Africa) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["en-ZA"] = { "name": "en-ZA", "englishName": "English (South Africa)", "nativeName": "English (South Africa)", "Sunday": "Sunday", "Monday": "Monday", "Tuesday": "Tuesday", "Wednesday": "Wednesday", "Thursday": "Thursday", "Friday": "Friday", "Saturday": "Saturday", "Sun": "Sun", "Mon": "Mon", "Tue": "Tue", "Wed": "Wed", "Thu": "Thu", "Fri": "Fri", "Sat": "Sat", "Su": "Su", "Mo": "Mo", "Tu": "Tu", "We": "We", "Th": "Th", "Fr": "Fr", "Sa": "Sa", "S_Sun_Initial": "S", "M_Mon_Initial": "M", "T_Tue_Initial": "T", "W_Wed_Initial": "W", "T_Thu_Initial": "T", "F_Fri_Initial": "F", "S_Sat_Initial": "S", "January": "January", "February": "February", "March": "March", "April": "April", "May": "May", "June": "June", "July": "July", "August": "August", "September": "September", "October": "October", "November": "November", "December": "December", "Jan_Abbr": "Jan", "Feb_Abbr": "Feb", "Mar_Abbr": "Mar", "Apr_Abbr": "Apr", "May_Abbr": "May", "Jun_Abbr": "Jun", "Jul_Abbr": "Jul", "Aug_Abbr": "Aug", "Sep_Abbr": "Sep", "Oct_Abbr": "Oct", "Nov_Abbr": "Nov", "Dec_Abbr": "Dec", "AM": "AM", "PM": "PM", "firstDayOfWeek": 0, "twoDigitYearMax": 2029, "mdy": "ymd", "M/d/yyyy": "yyyy/MM/dd", "dddd, MMMM dd, yyyy": "dd MMMM yyyy", "h:mm tt": "hh:mm tt", "h:mm:ss tt": "hh:mm:ss tt", "dddd, MMMM dd, yyyy h:mm:ss tt": "dd MMMM yyyy hh:mm:ss tt", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "dd MMMM", "MMMM, yyyy": "MMMM yyyy", "/jan(uary)?/": "jan(uary)?", "/feb(ruary)?/": "feb(ruary)?", "/mar(ch)?/": "mar(ch)?", "/apr(il)?/": "apr(il)?", "/may/": "may", "/jun(e)?/": "jun(e)?", "/jul(y)?/": "jul(y)?", "/aug(ust)?/": "aug(ust)?", "/sep(t(ember)?)?/": "sep(t(ember)?)?", "/oct(ober)?/": "oct(ober)?", "/nov(ember)?/": "nov(ember)?", "/dec(ember)?/": "dec(ember)?", "/^su(n(day)?)?/": "^su(n(day)?)?", "/^mo(n(day)?)?/": "^mo(n(day)?)?", "/^tu(e(s(day)?)?)?/": "^tu(e(s(day)?)?)?", "/^we(d(nesday)?)?/": "^we(d(nesday)?)?", "/^th(u(r(s(day)?)?)?)?/": "^th(u(r(s(day)?)?)?)?", "/^fr(i(day)?)?/": "^fr(i(day)?)?", "/^sa(t(urday)?)?/": "^sa(t(urday)?)?", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "en-ZA"; ================================================ FILE: src/i18n/en-ZW.js ================================================ /* * DateJS Culture String File * Country Code: en-ZW * Name: English (Zimbabwe) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["en-ZW"] = { "name": "en-ZW", "englishName": "English (Zimbabwe)", "nativeName": "English (Zimbabwe)", "Sunday": "Sunday", "Monday": "Monday", "Tuesday": "Tuesday", "Wednesday": "Wednesday", "Thursday": "Thursday", "Friday": "Friday", "Saturday": "Saturday", "Sun": "Sun", "Mon": "Mon", "Tue": "Tue", "Wed": "Wed", "Thu": "Thu", "Fri": "Fri", "Sat": "Sat", "Su": "Su", "Mo": "Mo", "Tu": "Tu", "We": "We", "Th": "Th", "Fr": "Fr", "Sa": "Sa", "S_Sun_Initial": "S", "M_Mon_Initial": "M", "T_Tue_Initial": "T", "W_Wed_Initial": "W", "T_Thu_Initial": "T", "F_Fri_Initial": "F", "S_Sat_Initial": "S", "January": "January", "February": "February", "March": "March", "April": "April", "May": "May", "June": "June", "July": "July", "August": "August", "September": "September", "October": "October", "November": "November", "December": "December", "Jan_Abbr": "Jan", "Feb_Abbr": "Feb", "Mar_Abbr": "Mar", "Apr_Abbr": "Apr", "May_Abbr": "May", "Jun_Abbr": "Jun", "Jul_Abbr": "Jul", "Aug_Abbr": "Aug", "Sep_Abbr": "Sep", "Oct_Abbr": "Oct", "Nov_Abbr": "Nov", "Dec_Abbr": "Dec", "AM": "AM", "PM": "PM", "firstDayOfWeek": 0, "twoDigitYearMax": 2029, "mdy": "mdy", "M/d/yyyy": "M/d/yyyy", "dddd, MMMM dd, yyyy": "dddd, MMMM dd, yyyy", "h:mm tt": "h:mm tt", "h:mm:ss tt": "h:mm:ss tt", "dddd, MMMM dd, yyyy h:mm:ss tt": "dddd, MMMM dd, yyyy h:mm:ss tt", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "MMMM dd", "MMMM, yyyy": "MMMM, yyyy", "/jan(uary)?/": "jan(uary)?", "/feb(ruary)?/": "feb(ruary)?", "/mar(ch)?/": "mar(ch)?", "/apr(il)?/": "apr(il)?", "/may/": "may", "/jun(e)?/": "jun(e)?", "/jul(y)?/": "jul(y)?", "/aug(ust)?/": "aug(ust)?", "/sep(t(ember)?)?/": "sep(t(ember)?)?", "/oct(ober)?/": "oct(ober)?", "/nov(ember)?/": "nov(ember)?", "/dec(ember)?/": "dec(ember)?", "/^su(n(day)?)?/": "^su(n(day)?)?", "/^mo(n(day)?)?/": "^mo(n(day)?)?", "/^tu(e(s(day)?)?)?/": "^tu(e(s(day)?)?)?", "/^we(d(nesday)?)?/": "^we(d(nesday)?)?", "/^th(u(r(s(day)?)?)?)?/": "^th(u(r(s(day)?)?)?)?", "/^fr(i(day)?)?/": "^fr(i(day)?)?", "/^sa(t(urday)?)?/": "^sa(t(urday)?)?", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "en-ZW"; ================================================ FILE: src/i18n/es-AR.js ================================================ /* * DateJS Culture String File * Country Code: es-AR * Name: Spanish (Argentina) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["es-AR"] = { "name": "es-AR", "englishName": "Spanish (Argentina)", "nativeName": "Español (Argentina)", "Sunday": "domingo", "Monday": "lunes", "Tuesday": "martes", "Wednesday": "miércoles", "Thursday": "jueves", "Friday": "viernes", "Saturday": "sábado", "Sun": "dom", "Mon": "lun", "Tue": "mar", "Wed": "mié", "Thu": "jue", "Fri": "vie", "Sat": "sáb", "Su": "do", "Mo": "lu", "Tu": "ma", "We": "mi", "Th": "ju", "Fr": "vi", "Sa": "sá", "S_Sun_Initial": "d", "M_Mon_Initial": "l", "T_Tue_Initial": "m", "W_Wed_Initial": "m", "T_Thu_Initial": "j", "F_Fri_Initial": "v", "S_Sat_Initial": "s", "January": "enero", "February": "febrero", "March": "marzo", "April": "abril", "May": "mayo", "June": "junio", "July": "julio", "August": "agosto", "September": "septiembre", "October": "octubre", "November": "noviembre", "December": "diciembre", "Jan_Abbr": "ene", "Feb_Abbr": "feb", "Mar_Abbr": "mar", "Apr_Abbr": "abr", "May_Abbr": "may", "Jun_Abbr": "jun", "Jul_Abbr": "jul", "Aug_Abbr": "ago", "Sep_Abbr": "sep", "Oct_Abbr": "oct", "Nov_Abbr": "nov", "Dec_Abbr": "dic", "AM": "a.m.", "PM": "p.m.", "firstDayOfWeek": 0, "twoDigitYearMax": 2029, "mdy": "dmy", "M/d/yyyy": "dd/MM/yyyy", "dddd, MMMM dd, yyyy": "dddd, dd [de] MMMM [de] yyyy", "h:mm tt": "hh:mm tt", "h:mm:ss tt": "hh:mm:ss tt", "dddd, MMMM dd, yyyy h:mm:ss tt": "dddd, dd [de] MMMM [de] yyyy hh:mm:ss tt", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "dd MMMM", "MMMM, yyyy": "MMMM [de] yyyy", "/jan(uary)?/": "ene(ro)?", "/feb(ruary)?/": "feb(rero)?", "/mar(ch)?/": "mar(zo)?", "/apr(il)?/": "abr(il)?", "/may/": "may(o)?", "/jun(e)?/": "jun(io)?", "/jul(y)?/": "jul(io)?", "/aug(ust)?/": "ago(sto)?", "/sep(t(ember)?)?/": "sep(tiembre)?", "/oct(ober)?/": "oct(ubre)?", "/nov(ember)?/": "nov(iembre)?", "/dec(ember)?/": "dic(iembre)?", "/^su(n(day)?)?/": "^do(m(ingo)?)?", "/^mo(n(day)?)?/": "^lu(n(es)?)?", "/^tu(e(s(day)?)?)?/": "^ma(r(tes)?)?", "/^we(d(nesday)?)?/": "^mi(é(rcoles)?)?", "/^th(u(r(s(day)?)?)?)?/": "^ju(e(ves)?)?", "/^fr(i(day)?)?/": "^vi(e(rnes)?)?", "/^sa(t(urday)?)?/": "^sá(b(ado)?)?", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "es-AR"; ================================================ FILE: src/i18n/es-BO.js ================================================ /* * DateJS Culture String File * Country Code: es-BO * Name: Spanish (Bolivia) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["es-BO"] = { "name": "es-BO", "englishName": "Spanish (Bolivia)", "nativeName": "Español (Bolivia)", "Sunday": "domingo", "Monday": "lunes", "Tuesday": "martes", "Wednesday": "miércoles", "Thursday": "jueves", "Friday": "viernes", "Saturday": "sábado", "Sun": "dom", "Mon": "lun", "Tue": "mar", "Wed": "mié", "Thu": "jue", "Fri": "vie", "Sat": "sáb", "Su": "do", "Mo": "lu", "Tu": "ma", "We": "mi", "Th": "ju", "Fr": "vi", "Sa": "sá", "S_Sun_Initial": "d", "M_Mon_Initial": "l", "T_Tue_Initial": "m", "W_Wed_Initial": "m", "T_Thu_Initial": "j", "F_Fri_Initial": "v", "S_Sat_Initial": "s", "January": "enero", "February": "febrero", "March": "marzo", "April": "abril", "May": "mayo", "June": "junio", "July": "julio", "August": "agosto", "September": "septiembre", "October": "octubre", "November": "noviembre", "December": "diciembre", "Jan_Abbr": "ene", "Feb_Abbr": "feb", "Mar_Abbr": "mar", "Apr_Abbr": "abr", "May_Abbr": "may", "Jun_Abbr": "jun", "Jul_Abbr": "jul", "Aug_Abbr": "ago", "Sep_Abbr": "sep", "Oct_Abbr": "oct", "Nov_Abbr": "nov", "Dec_Abbr": "dic", "AM": "a.m.", "PM": "p.m.", "firstDayOfWeek": 0, "twoDigitYearMax": 2029, "mdy": "dmy", "M/d/yyyy": "dd/MM/yyyy", "dddd, MMMM dd, yyyy": "dddd, dd [de] MMMM [de] yyyy", "h:mm tt": "hh:mm tt", "h:mm:ss tt": "hh:mm:ss tt", "dddd, MMMM dd, yyyy h:mm:ss tt": "dddd, dd [de] MMMM [de] yyyy hh:mm:ss tt", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "dd MMMM", "MMMM, yyyy": "MMMM [de] yyyy", "/jan(uary)?/": "ene(ro)?", "/feb(ruary)?/": "feb(rero)?", "/mar(ch)?/": "mar(zo)?", "/apr(il)?/": "abr(il)?", "/may/": "may(o)?", "/jun(e)?/": "jun(io)?", "/jul(y)?/": "jul(io)?", "/aug(ust)?/": "ago(sto)?", "/sep(t(ember)?)?/": "sep(tiembre)?", "/oct(ober)?/": "oct(ubre)?", "/nov(ember)?/": "nov(iembre)?", "/dec(ember)?/": "dic(iembre)?", "/^su(n(day)?)?/": "^do(m(ingo)?)?", "/^mo(n(day)?)?/": "^lu(n(es)?)?", "/^tu(e(s(day)?)?)?/": "^ma(r(tes)?)?", "/^we(d(nesday)?)?/": "^mi(é(rcoles)?)?", "/^th(u(r(s(day)?)?)?)?/": "^ju(e(ves)?)?", "/^fr(i(day)?)?/": "^vi(e(rnes)?)?", "/^sa(t(urday)?)?/": "^sá(b(ado)?)?", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "es-BO"; ================================================ FILE: src/i18n/es-CL.js ================================================ /* * DateJS Culture String File * Country Code: es-CL * Name: Spanish (Chile) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["es-CL"] = { "name": "es-CL", "englishName": "Spanish (Chile)", "nativeName": "Español (Chile)", "Sunday": "domingo", "Monday": "lunes", "Tuesday": "martes", "Wednesday": "miércoles", "Thursday": "jueves", "Friday": "viernes", "Saturday": "sábado", "Sun": "dom", "Mon": "lun", "Tue": "mar", "Wed": "mié", "Thu": "jue", "Fri": "vie", "Sat": "sáb", "Su": "do", "Mo": "lu", "Tu": "ma", "We": "mi", "Th": "ju", "Fr": "vi", "Sa": "sá", "S_Sun_Initial": "d", "M_Mon_Initial": "l", "T_Tue_Initial": "m", "W_Wed_Initial": "m", "T_Thu_Initial": "j", "F_Fri_Initial": "v", "S_Sat_Initial": "s", "January": "enero", "February": "febrero", "March": "marzo", "April": "abril", "May": "mayo", "June": "junio", "July": "julio", "August": "agosto", "September": "septiembre", "October": "octubre", "November": "noviembre", "December": "diciembre", "Jan_Abbr": "ene", "Feb_Abbr": "feb", "Mar_Abbr": "mar", "Apr_Abbr": "abr", "May_Abbr": "may", "Jun_Abbr": "jun", "Jul_Abbr": "jul", "Aug_Abbr": "ago", "Sep_Abbr": "sep", "Oct_Abbr": "oct", "Nov_Abbr": "nov", "Dec_Abbr": "dic", "AM": "", "PM": "", "firstDayOfWeek": 0, "twoDigitYearMax": 2029, "mdy": "dmy", "M/d/yyyy": "dd-MM-yyyy", "dddd, MMMM dd, yyyy": "dddd, dd [de] MMMM [de] yyyy", "h:mm tt": "H:mm", "h:mm:ss tt": "H:mm:ss", "dddd, MMMM dd, yyyy h:mm:ss tt": "dddd, dd [de] MMMM [de] yyyy H:mm:ss", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "dd MMMM", "MMMM, yyyy": "MMMM [de] yyyy", "/jan(uary)?/": "ene(ro)?", "/feb(ruary)?/": "feb(rero)?", "/mar(ch)?/": "mar(zo)?", "/apr(il)?/": "abr(il)?", "/may/": "may(o)?", "/jun(e)?/": "jun(io)?", "/jul(y)?/": "jul(io)?", "/aug(ust)?/": "ago(sto)?", "/sep(t(ember)?)?/": "sep(tiembre)?", "/oct(ober)?/": "oct(ubre)?", "/nov(ember)?/": "nov(iembre)?", "/dec(ember)?/": "dic(iembre)?", "/^su(n(day)?)?/": "^do(m(ingo)?)?", "/^mo(n(day)?)?/": "^lu(n(es)?)?", "/^tu(e(s(day)?)?)?/": "^ma(r(tes)?)?", "/^we(d(nesday)?)?/": "^mi(é(rcoles)?)?", "/^th(u(r(s(day)?)?)?)?/": "^ju(e(ves)?)?", "/^fr(i(day)?)?/": "^vi(e(rnes)?)?", "/^sa(t(urday)?)?/": "^sá(b(ado)?)?", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "es-CL"; ================================================ FILE: src/i18n/es-CO.js ================================================ /* * DateJS Culture String File * Country Code: es-CO * Name: Spanish (Colombia) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["es-CO"] = { "name": "es-CO", "englishName": "Spanish (Colombia)", "nativeName": "Español (Colombia)", "Sunday": "domingo", "Monday": "lunes", "Tuesday": "martes", "Wednesday": "miércoles", "Thursday": "jueves", "Friday": "viernes", "Saturday": "sábado", "Sun": "dom", "Mon": "lun", "Tue": "mar", "Wed": "mié", "Thu": "jue", "Fri": "vie", "Sat": "sáb", "Su": "do", "Mo": "lu", "Tu": "ma", "We": "mi", "Th": "ju", "Fr": "vi", "Sa": "sá", "S_Sun_Initial": "d", "M_Mon_Initial": "l", "T_Tue_Initial": "m", "W_Wed_Initial": "m", "T_Thu_Initial": "j", "F_Fri_Initial": "v", "S_Sat_Initial": "s", "January": "enero", "February": "febrero", "March": "marzo", "April": "abril", "May": "mayo", "June": "junio", "July": "julio", "August": "agosto", "September": "septiembre", "October": "octubre", "November": "noviembre", "December": "diciembre", "Jan_Abbr": "ene", "Feb_Abbr": "feb", "Mar_Abbr": "mar", "Apr_Abbr": "abr", "May_Abbr": "may", "Jun_Abbr": "jun", "Jul_Abbr": "jul", "Aug_Abbr": "ago", "Sep_Abbr": "sep", "Oct_Abbr": "oct", "Nov_Abbr": "nov", "Dec_Abbr": "dic", "AM": "a.m.", "PM": "p.m.", "firstDayOfWeek": 0, "twoDigitYearMax": 2029, "mdy": "dmy", "M/d/yyyy": "dd/MM/yyyy", "dddd, MMMM dd, yyyy": "dddd, dd [de] MMMM [de] yyyy", "h:mm tt": "hh:mm tt", "h:mm:ss tt": "hh:mm:ss tt", "dddd, MMMM dd, yyyy h:mm:ss tt": "dddd, dd [de] MMMM [de] yyyy hh:mm:ss tt", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "dd MMMM", "MMMM, yyyy": "MMMM [de] yyyy", "/jan(uary)?/": "ene(ro)?", "/feb(ruary)?/": "feb(rero)?", "/mar(ch)?/": "mar(zo)?", "/apr(il)?/": "abr(il)?", "/may/": "may(o)?", "/jun(e)?/": "jun(io)?", "/jul(y)?/": "jul(io)?", "/aug(ust)?/": "ago(sto)?", "/sep(t(ember)?)?/": "sep(tiembre)?", "/oct(ober)?/": "oct(ubre)?", "/nov(ember)?/": "nov(iembre)?", "/dec(ember)?/": "dic(iembre)?", "/^su(n(day)?)?/": "^do(m(ingo)?)?", "/^mo(n(day)?)?/": "^lu(n(es)?)?", "/^tu(e(s(day)?)?)?/": "^ma(r(tes)?)?", "/^we(d(nesday)?)?/": "^mi(é(rcoles)?)?", "/^th(u(r(s(day)?)?)?)?/": "^ju(e(ves)?)?", "/^fr(i(day)?)?/": "^vi(e(rnes)?)?", "/^sa(t(urday)?)?/": "^sá(b(ado)?)?", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "es-CO"; ================================================ FILE: src/i18n/es-CR.js ================================================ /* * DateJS Culture String File * Country Code: es-CR * Name: Spanish (Costa Rica) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["es-CR"] = { "name": "es-CR", "englishName": "Spanish (Costa Rica)", "nativeName": "Español (Costa Rica)", "Sunday": "domingo", "Monday": "lunes", "Tuesday": "martes", "Wednesday": "miércoles", "Thursday": "jueves", "Friday": "viernes", "Saturday": "sábado", "Sun": "dom", "Mon": "lun", "Tue": "mar", "Wed": "mié", "Thu": "jue", "Fri": "vie", "Sat": "sáb", "Su": "do", "Mo": "lu", "Tu": "ma", "We": "mi", "Th": "ju", "Fr": "vi", "Sa": "sá", "S_Sun_Initial": "d", "M_Mon_Initial": "l", "T_Tue_Initial": "m", "W_Wed_Initial": "m", "T_Thu_Initial": "j", "F_Fri_Initial": "v", "S_Sat_Initial": "s", "January": "enero", "February": "febrero", "March": "marzo", "April": "abril", "May": "mayo", "June": "junio", "July": "julio", "August": "agosto", "September": "septiembre", "October": "octubre", "November": "noviembre", "December": "diciembre", "Jan_Abbr": "ene", "Feb_Abbr": "feb", "Mar_Abbr": "mar", "Apr_Abbr": "abr", "May_Abbr": "may", "Jun_Abbr": "jun", "Jul_Abbr": "jul", "Aug_Abbr": "ago", "Sep_Abbr": "sep", "Oct_Abbr": "oct", "Nov_Abbr": "nov", "Dec_Abbr": "dic", "AM": "a.m.", "PM": "p.m.", "firstDayOfWeek": 0, "twoDigitYearMax": 2029, "mdy": "dmy", "M/d/yyyy": "dd/MM/yyyy", "dddd, MMMM dd, yyyy": "dddd, dd [de] MMMM [de] yyyy", "h:mm tt": "hh:mm tt", "h:mm:ss tt": "hh:mm:ss tt", "dddd, MMMM dd, yyyy h:mm:ss tt": "dddd, dd [de] MMMM [de] yyyy hh:mm:ss tt", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "dd MMMM", "MMMM, yyyy": "MMMM [de] yyyy", "/jan(uary)?/": "ene(ro)?", "/feb(ruary)?/": "feb(rero)?", "/mar(ch)?/": "mar(zo)?", "/apr(il)?/": "abr(il)?", "/may/": "may(o)?", "/jun(e)?/": "jun(io)?", "/jul(y)?/": "jul(io)?", "/aug(ust)?/": "ago(sto)?", "/sep(t(ember)?)?/": "sep(tiembre)?", "/oct(ober)?/": "oct(ubre)?", "/nov(ember)?/": "nov(iembre)?", "/dec(ember)?/": "dic(iembre)?", "/^su(n(day)?)?/": "^do(m(ingo)?)?", "/^mo(n(day)?)?/": "^lu(n(es)?)?", "/^tu(e(s(day)?)?)?/": "^ma(r(tes)?)?", "/^we(d(nesday)?)?/": "^mi(é(rcoles)?)?", "/^th(u(r(s(day)?)?)?)?/": "^ju(e(ves)?)?", "/^fr(i(day)?)?/": "^vi(e(rnes)?)?", "/^sa(t(urday)?)?/": "^sá(b(ado)?)?", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "es-CR"; ================================================ FILE: src/i18n/es-DO.js ================================================ /* * DateJS Culture String File * Country Code: es-DO * Name: Spanish (Dominican Republic) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["es-DO"] = { "name": "es-DO", "englishName": "Spanish (Dominican Republic)", "nativeName": "Español (República Dominicana)", "Sunday": "domingo", "Monday": "lunes", "Tuesday": "martes", "Wednesday": "miércoles", "Thursday": "jueves", "Friday": "viernes", "Saturday": "sábado", "Sun": "dom", "Mon": "lun", "Tue": "mar", "Wed": "mié", "Thu": "jue", "Fri": "vie", "Sat": "sáb", "Su": "do", "Mo": "lu", "Tu": "ma", "We": "mi", "Th": "ju", "Fr": "vi", "Sa": "sá", "S_Sun_Initial": "d", "M_Mon_Initial": "l", "T_Tue_Initial": "m", "W_Wed_Initial": "m", "T_Thu_Initial": "j", "F_Fri_Initial": "v", "S_Sat_Initial": "s", "January": "enero", "February": "febrero", "March": "marzo", "April": "abril", "May": "mayo", "June": "junio", "July": "julio", "August": "agosto", "September": "septiembre", "October": "octubre", "November": "noviembre", "December": "diciembre", "Jan_Abbr": "ene", "Feb_Abbr": "feb", "Mar_Abbr": "mar", "Apr_Abbr": "abr", "May_Abbr": "may", "Jun_Abbr": "jun", "Jul_Abbr": "jul", "Aug_Abbr": "ago", "Sep_Abbr": "sep", "Oct_Abbr": "oct", "Nov_Abbr": "nov", "Dec_Abbr": "dic", "AM": "a.m.", "PM": "p.m.", "firstDayOfWeek": 0, "twoDigitYearMax": 2029, "mdy": "dmy", "M/d/yyyy": "dd/MM/yyyy", "dddd, MMMM dd, yyyy": "dddd, dd [de] MMMM [de] yyyy", "h:mm tt": "hh:mm tt", "h:mm:ss tt": "hh:mm:ss tt", "dddd, MMMM dd, yyyy h:mm:ss tt": "dddd, dd [de] MMMM [de] yyyy hh:mm:ss tt", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "dd MMMM", "MMMM, yyyy": "MMMM [de] yyyy", "/jan(uary)?/": "ene(ro)?", "/feb(ruary)?/": "feb(rero)?", "/mar(ch)?/": "mar(zo)?", "/apr(il)?/": "abr(il)?", "/may/": "may(o)?", "/jun(e)?/": "jun(io)?", "/jul(y)?/": "jul(io)?", "/aug(ust)?/": "ago(sto)?", "/sep(t(ember)?)?/": "sep(tiembre)?", "/oct(ober)?/": "oct(ubre)?", "/nov(ember)?/": "nov(iembre)?", "/dec(ember)?/": "dic(iembre)?", "/^su(n(day)?)?/": "^do(m(ingo)?)?", "/^mo(n(day)?)?/": "^lu(n(es)?)?", "/^tu(e(s(day)?)?)?/": "^ma(r(tes)?)?", "/^we(d(nesday)?)?/": "^mi(é(rcoles)?)?", "/^th(u(r(s(day)?)?)?)?/": "^ju(e(ves)?)?", "/^fr(i(day)?)?/": "^vi(e(rnes)?)?", "/^sa(t(urday)?)?/": "^sá(b(ado)?)?", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "es-DO"; ================================================ FILE: src/i18n/es-EC.js ================================================ /* * DateJS Culture String File * Country Code: es-EC * Name: Spanish (Ecuador) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["es-EC"] = { "name": "es-EC", "englishName": "Spanish (Ecuador)", "nativeName": "Español (Ecuador)", "Sunday": "domingo", "Monday": "lunes", "Tuesday": "martes", "Wednesday": "miércoles", "Thursday": "jueves", "Friday": "viernes", "Saturday": "sábado", "Sun": "dom", "Mon": "lun", "Tue": "mar", "Wed": "mié", "Thu": "jue", "Fri": "vie", "Sat": "sáb", "Su": "do", "Mo": "lu", "Tu": "ma", "We": "mi", "Th": "ju", "Fr": "vi", "Sa": "sá", "S_Sun_Initial": "d", "M_Mon_Initial": "l", "T_Tue_Initial": "m", "W_Wed_Initial": "m", "T_Thu_Initial": "j", "F_Fri_Initial": "v", "S_Sat_Initial": "s", "January": "enero", "February": "febrero", "March": "marzo", "April": "abril", "May": "mayo", "June": "junio", "July": "julio", "August": "agosto", "September": "septiembre", "October": "octubre", "November": "noviembre", "December": "diciembre", "Jan_Abbr": "ene", "Feb_Abbr": "feb", "Mar_Abbr": "mar", "Apr_Abbr": "abr", "May_Abbr": "may", "Jun_Abbr": "jun", "Jul_Abbr": "jul", "Aug_Abbr": "ago", "Sep_Abbr": "sep", "Oct_Abbr": "oct", "Nov_Abbr": "nov", "Dec_Abbr": "dic", "AM": "", "PM": "", "firstDayOfWeek": 0, "twoDigitYearMax": 2029, "mdy": "dmy", "M/d/yyyy": "dd/MM/yyyy", "dddd, MMMM dd, yyyy": "dddd, dd [de] MMMM [de] yyyy", "h:mm tt": "H:mm", "h:mm:ss tt": "H:mm:ss", "dddd, MMMM dd, yyyy h:mm:ss tt": "dddd, dd [de] MMMM [de] yyyy H:mm:ss", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "dd MMMM", "MMMM, yyyy": "MMMM [de] yyyy", "/jan(uary)?/": "ene(ro)?", "/feb(ruary)?/": "feb(rero)?", "/mar(ch)?/": "mar(zo)?", "/apr(il)?/": "abr(il)?", "/may/": "may(o)?", "/jun(e)?/": "jun(io)?", "/jul(y)?/": "jul(io)?", "/aug(ust)?/": "ago(sto)?", "/sep(t(ember)?)?/": "sep(tiembre)?", "/oct(ober)?/": "oct(ubre)?", "/nov(ember)?/": "nov(iembre)?", "/dec(ember)?/": "dic(iembre)?", "/^su(n(day)?)?/": "^do(m(ingo)?)?", "/^mo(n(day)?)?/": "^lu(n(es)?)?", "/^tu(e(s(day)?)?)?/": "^ma(r(tes)?)?", "/^we(d(nesday)?)?/": "^mi(é(rcoles)?)?", "/^th(u(r(s(day)?)?)?)?/": "^ju(e(ves)?)?", "/^fr(i(day)?)?/": "^vi(e(rnes)?)?", "/^sa(t(urday)?)?/": "^sá(b(ado)?)?", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "es-EC"; ================================================ FILE: src/i18n/es-ES.js ================================================ /* * DateJS Culture String File * Country Code: es-ES * Name: Spanish (Spain) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["es-ES"] = { "name": "es-ES", "englishName": "Spanish (Spain)", "nativeName": "español (España)", "Sunday": "domingo", "Monday": "lunes", "Tuesday": "martes", "Wednesday": "miércoles", "Thursday": "jueves", "Friday": "viernes", "Saturday": "sábado", "Sun": "dom", "Mon": "lun", "Tue": "mar", "Wed": "mié", "Thu": "jue", "Fri": "vie", "Sat": "sáb", "Su": "do", "Mo": "lu", "Tu": "ma", "We": "mi", "Th": "ju", "Fr": "vi", "Sa": "sá", "S_Sun_Initial": "d", "M_Mon_Initial": "l", "T_Tue_Initial": "m", "W_Wed_Initial": "m", "T_Thu_Initial": "j", "F_Fri_Initial": "v", "S_Sat_Initial": "s", "January": "enero", "February": "febrero", "March": "marzo", "April": "abril", "May": "mayo", "June": "junio", "July": "julio", "August": "agosto", "September": "septiembre", "October": "octubre", "November": "noviembre", "December": "diciembre", "Jan_Abbr": "ene", "Feb_Abbr": "feb", "Mar_Abbr": "mar", "Apr_Abbr": "abr", "May_Abbr": "may", "Jun_Abbr": "jun", "Jul_Abbr": "jul", "Aug_Abbr": "ago", "Sep_Abbr": "sep", "Oct_Abbr": "oct", "Nov_Abbr": "nov", "Dec_Abbr": "dic", "AM": "", "PM": "", "firstDayOfWeek": 1, "twoDigitYearMax": 2029, "mdy": "dmy", "M/d/yyyy": "dd/MM/yyyy", "dddd, MMMM dd, yyyy": "dddd, dd' [de] 'MMMM' [de] 'yyyy", "h:mm tt": "H:mm", "h:mm:ss tt": "H:mm:ss", "dddd, MMMM dd, yyyy h:mm:ss tt": "dddd, dd' [de] 'MMMM' [de] 'yyyy H:mm:ss", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "dd MMMM", "MMMM, yyyy": "MMMM' [de] 'yyyy", "/jan(uary)?/": "ene(ro)?", "/feb(ruary)?/": "feb(rero)?", "/mar(ch)?/": "mar(zo)?", "/apr(il)?/": "abr(il)?", "/may/": "may(o)?", "/jun(e)?/": "jun(io)?", "/jul(y)?/": "jul(io)?", "/aug(ust)?/": "ago(sto)?", "/sep(t(ember)?)?/": "sep(tiembre)?", "/oct(ober)?/": "oct(ubre)?", "/nov(ember)?/": "nov(iembre)?", "/dec(ember)?/": "dic(iembre)?", "/^su(n(day)?)?/": "^do(m(ingo)?)?", "/^mo(n(day)?)?/": "^lu(n(es)?)?", "/^tu(e(s(day)?)?)?/": "^ma(r(tes)?)?", "/^we(d(nesday)?)?/": "^mi(é(rcoles)?)?", "/^th(u(r(s(day)?)?)?)?/": "^ju(e(ves)?)?", "/^fr(i(day)?)?/": "^vi(e(rnes)?)?", "/^sa(t(urday)?)?/": "^sá(b(ado)?)?", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "es-ES"; ================================================ FILE: src/i18n/es-GT.js ================================================ /* * DateJS Culture String File * Country Code: es-GT * Name: Spanish (Guatemala) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["es-GT"] = { "name": "es-GT", "englishName": "Spanish (Guatemala)", "nativeName": "Español (Guatemala)", "Sunday": "domingo", "Monday": "lunes", "Tuesday": "martes", "Wednesday": "miércoles", "Thursday": "jueves", "Friday": "viernes", "Saturday": "sábado", "Sun": "dom", "Mon": "lun", "Tue": "mar", "Wed": "mié", "Thu": "jue", "Fri": "vie", "Sat": "sáb", "Su": "do", "Mo": "lu", "Tu": "ma", "We": "mi", "Th": "ju", "Fr": "vi", "Sa": "sá", "S_Sun_Initial": "d", "M_Mon_Initial": "l", "T_Tue_Initial": "m", "W_Wed_Initial": "m", "T_Thu_Initial": "j", "F_Fri_Initial": "v", "S_Sat_Initial": "s", "January": "enero", "February": "febrero", "March": "marzo", "April": "abril", "May": "mayo", "June": "junio", "July": "julio", "August": "agosto", "September": "septiembre", "October": "octubre", "November": "noviembre", "December": "diciembre", "Jan_Abbr": "ene", "Feb_Abbr": "feb", "Mar_Abbr": "mar", "Apr_Abbr": "abr", "May_Abbr": "may", "Jun_Abbr": "jun", "Jul_Abbr": "jul", "Aug_Abbr": "ago", "Sep_Abbr": "sep", "Oct_Abbr": "oct", "Nov_Abbr": "nov", "Dec_Abbr": "dic", "AM": "a.m.", "PM": "p.m.", "firstDayOfWeek": 0, "twoDigitYearMax": 2029, "mdy": "dmy", "M/d/yyyy": "dd/MM/yyyy", "dddd, MMMM dd, yyyy": "dddd, dd [de] MMMM [de] yyyy", "h:mm tt": "hh:mm tt", "h:mm:ss tt": "hh:mm:ss tt", "dddd, MMMM dd, yyyy h:mm:ss tt": "dddd, dd [de] MMMM [de] yyyy hh:mm:ss tt", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "dd MMMM", "MMMM, yyyy": "MMMM [de] yyyy", "/jan(uary)?/": "ene(ro)?", "/feb(ruary)?/": "feb(rero)?", "/mar(ch)?/": "mar(zo)?", "/apr(il)?/": "abr(il)?", "/may/": "may(o)?", "/jun(e)?/": "jun(io)?", "/jul(y)?/": "jul(io)?", "/aug(ust)?/": "ago(sto)?", "/sep(t(ember)?)?/": "sep(tiembre)?", "/oct(ober)?/": "oct(ubre)?", "/nov(ember)?/": "nov(iembre)?", "/dec(ember)?/": "dic(iembre)?", "/^su(n(day)?)?/": "^do(m(ingo)?)?", "/^mo(n(day)?)?/": "^lu(n(es)?)?", "/^tu(e(s(day)?)?)?/": "^ma(r(tes)?)?", "/^we(d(nesday)?)?/": "^mi(é(rcoles)?)?", "/^th(u(r(s(day)?)?)?)?/": "^ju(e(ves)?)?", "/^fr(i(day)?)?/": "^vi(e(rnes)?)?", "/^sa(t(urday)?)?/": "^sá(b(ado)?)?", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "es-GT"; ================================================ FILE: src/i18n/es-HN.js ================================================ /* * DateJS Culture String File * Country Code: es-HN * Name: Spanish (Honduras) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["es-HN"] = { "name": "es-HN", "englishName": "Spanish (Honduras)", "nativeName": "Español (Honduras)", "Sunday": "domingo", "Monday": "lunes", "Tuesday": "martes", "Wednesday": "miércoles", "Thursday": "jueves", "Friday": "viernes", "Saturday": "sábado", "Sun": "dom", "Mon": "lun", "Tue": "mar", "Wed": "mié", "Thu": "jue", "Fri": "vie", "Sat": "sáb", "Su": "do", "Mo": "lu", "Tu": "ma", "We": "mi", "Th": "ju", "Fr": "vi", "Sa": "sá", "S_Sun_Initial": "d", "M_Mon_Initial": "l", "T_Tue_Initial": "m", "W_Wed_Initial": "m", "T_Thu_Initial": "j", "F_Fri_Initial": "v", "S_Sat_Initial": "s", "January": "enero", "February": "febrero", "March": "marzo", "April": "abril", "May": "mayo", "June": "junio", "July": "julio", "August": "agosto", "September": "septiembre", "October": "octubre", "November": "noviembre", "December": "diciembre", "Jan_Abbr": "ene", "Feb_Abbr": "feb", "Mar_Abbr": "mar", "Apr_Abbr": "abr", "May_Abbr": "may", "Jun_Abbr": "jun", "Jul_Abbr": "jul", "Aug_Abbr": "ago", "Sep_Abbr": "sep", "Oct_Abbr": "oct", "Nov_Abbr": "nov", "Dec_Abbr": "dic", "AM": "a.m.", "PM": "p.m.", "firstDayOfWeek": 0, "twoDigitYearMax": 2029, "mdy": "dmy", "M/d/yyyy": "dd/MM/yyyy", "dddd, MMMM dd, yyyy": "dddd, dd [de] MMMM [de] yyyy", "h:mm tt": "hh:mm tt", "h:mm:ss tt": "hh:mm:ss tt", "dddd, MMMM dd, yyyy h:mm:ss tt": "dddd, dd [de] MMMM [de] yyyy hh:mm:ss tt", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "dd MMMM", "MMMM, yyyy": "MMMM [de] yyyy", "/jan(uary)?/": "ene(ro)?", "/feb(ruary)?/": "feb(rero)?", "/mar(ch)?/": "mar(zo)?", "/apr(il)?/": "abr(il)?", "/may/": "may(o)?", "/jun(e)?/": "jun(io)?", "/jul(y)?/": "jul(io)?", "/aug(ust)?/": "ago(sto)?", "/sep(t(ember)?)?/": "sep(tiembre)?", "/oct(ober)?/": "oct(ubre)?", "/nov(ember)?/": "nov(iembre)?", "/dec(ember)?/": "dic(iembre)?", "/^su(n(day)?)?/": "^do(m(ingo)?)?", "/^mo(n(day)?)?/": "^lu(n(es)?)?", "/^tu(e(s(day)?)?)?/": "^ma(r(tes)?)?", "/^we(d(nesday)?)?/": "^mi(é(rcoles)?)?", "/^th(u(r(s(day)?)?)?)?/": "^ju(e(ves)?)?", "/^fr(i(day)?)?/": "^vi(e(rnes)?)?", "/^sa(t(urday)?)?/": "^sá(b(ado)?)?", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "es-HN"; ================================================ FILE: src/i18n/es-MX.js ================================================ /* * DateJS Culture String File * Country Code: es-MX * Name: Spanish (Mexico) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["es-MX"] = { "name": "es-MX", "englishName": "Spanish (Mexico)", "nativeName": "Español (México)", "Sunday": "domingo", "Monday": "lunes", "Tuesday": "martes", "Wednesday": "miércoles", "Thursday": "jueves", "Friday": "viernes", "Saturday": "sábado", "Sun": "dom", "Mon": "lun", "Tue": "mar", "Wed": "mié", "Thu": "jue", "Fri": "vie", "Sat": "sáb", "Su": "do", "Mo": "lu", "Tu": "ma", "We": "mi", "Th": "ju", "Fr": "vi", "Sa": "sá", "S_Sun_Initial": "d", "M_Mon_Initial": "l", "T_Tue_Initial": "m", "W_Wed_Initial": "m", "T_Thu_Initial": "j", "F_Fri_Initial": "v", "S_Sat_Initial": "s", "January": "enero", "February": "febrero", "March": "marzo", "April": "abril", "May": "mayo", "June": "junio", "July": "julio", "August": "agosto", "September": "septiembre", "October": "octubre", "November": "noviembre", "December": "diciembre", "Jan_Abbr": "ene", "Feb_Abbr": "feb", "Mar_Abbr": "mar", "Apr_Abbr": "abr", "May_Abbr": "may", "Jun_Abbr": "jun", "Jul_Abbr": "jul", "Aug_Abbr": "ago", "Sep_Abbr": "sep", "Oct_Abbr": "oct", "Nov_Abbr": "nov", "Dec_Abbr": "dic", "AM": "a.m.", "PM": "p.m.", "firstDayOfWeek": 0, "twoDigitYearMax": 2029, "mdy": "dmy", "M/d/yyyy": "dd/MM/yyyy", "dddd, MMMM dd, yyyy": "dddd, dd [de] MMMM [de] yyyy", "h:mm tt": "hh:mm tt", "h:mm:ss tt": "hh:mm:ss tt", "dddd, MMMM dd, yyyy h:mm:ss tt": "dddd, dd [de] MMMM [de] yyyy hh:mm:ss tt", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "dd MMMM", "MMMM, yyyy": "MMMM [de] yyyy", "/jan(uary)?/": "ene(ro)?", "/feb(ruary)?/": "feb(rero)?", "/mar(ch)?/": "mar(zo)?", "/apr(il)?/": "abr(il)?", "/may/": "may(o)?", "/jun(e)?/": "jun(io)?", "/jul(y)?/": "jul(io)?", "/aug(ust)?/": "ago(sto)?", "/sep(t(ember)?)?/": "sep(tiembre)?", "/oct(ober)?/": "oct(ubre)?", "/nov(ember)?/": "nov(iembre)?", "/dec(ember)?/": "dic(iembre)?", "/^su(n(day)?)?/": "^do(m(ingo)?)?", "/^mo(n(day)?)?/": "^lu(n(es)?)?", "/^tu(e(s(day)?)?)?/": "^ma(r(tes)?)?", "/^we(d(nesday)?)?/": "^mi(é(rcoles)?)?", "/^th(u(r(s(day)?)?)?)?/": "^ju(e(ves)?)?", "/^fr(i(day)?)?/": "^vi(e(rnes)?)?", "/^sa(t(urday)?)?/": "^sá(b(ado)?)?", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "es-MX"; ================================================ FILE: src/i18n/es-NI.js ================================================ /* * DateJS Culture String File * Country Code: es-NI * Name: Spanish (Nicaragua) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["es-NI"] = { "name": "es-NI", "englishName": "Spanish (Nicaragua)", "nativeName": "Español (Nicaragua)", "Sunday": "domingo", "Monday": "lunes", "Tuesday": "martes", "Wednesday": "miércoles", "Thursday": "jueves", "Friday": "viernes", "Saturday": "sábado", "Sun": "dom", "Mon": "lun", "Tue": "mar", "Wed": "mié", "Thu": "jue", "Fri": "vie", "Sat": "sáb", "Su": "do", "Mo": "lu", "Tu": "ma", "We": "mi", "Th": "ju", "Fr": "vi", "Sa": "sá", "S_Sun_Initial": "d", "M_Mon_Initial": "l", "T_Tue_Initial": "m", "W_Wed_Initial": "m", "T_Thu_Initial": "j", "F_Fri_Initial": "v", "S_Sat_Initial": "s", "January": "enero", "February": "febrero", "March": "marzo", "April": "abril", "May": "mayo", "June": "junio", "July": "julio", "August": "agosto", "September": "septiembre", "October": "octubre", "November": "noviembre", "December": "diciembre", "Jan_Abbr": "ene", "Feb_Abbr": "feb", "Mar_Abbr": "mar", "Apr_Abbr": "abr", "May_Abbr": "may", "Jun_Abbr": "jun", "Jul_Abbr": "jul", "Aug_Abbr": "ago", "Sep_Abbr": "sep", "Oct_Abbr": "oct", "Nov_Abbr": "nov", "Dec_Abbr": "dic", "AM": "a.m.", "PM": "p.m.", "firstDayOfWeek": 0, "twoDigitYearMax": 2029, "mdy": "dmy", "M/d/yyyy": "dd/MM/yyyy", "dddd, MMMM dd, yyyy": "dddd, dd [de] MMMM [de] yyyy", "h:mm tt": "hh:mm tt", "h:mm:ss tt": "hh:mm:ss tt", "dddd, MMMM dd, yyyy h:mm:ss tt": "dddd, dd [de] MMMM [de] yyyy hh:mm:ss tt", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "dd MMMM", "MMMM, yyyy": "MMMM [de] yyyy", "/jan(uary)?/": "ene(ro)?", "/feb(ruary)?/": "feb(rero)?", "/mar(ch)?/": "mar(zo)?", "/apr(il)?/": "abr(il)?", "/may/": "may(o)?", "/jun(e)?/": "jun(io)?", "/jul(y)?/": "jul(io)?", "/aug(ust)?/": "ago(sto)?", "/sep(t(ember)?)?/": "sep(tiembre)?", "/oct(ober)?/": "oct(ubre)?", "/nov(ember)?/": "nov(iembre)?", "/dec(ember)?/": "dic(iembre)?", "/^su(n(day)?)?/": "^do(m(ingo)?)?", "/^mo(n(day)?)?/": "^lu(n(es)?)?", "/^tu(e(s(day)?)?)?/": "^ma(r(tes)?)?", "/^we(d(nesday)?)?/": "^mi(é(rcoles)?)?", "/^th(u(r(s(day)?)?)?)?/": "^ju(e(ves)?)?", "/^fr(i(day)?)?/": "^vi(e(rnes)?)?", "/^sa(t(urday)?)?/": "^sá(b(ado)?)?", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "es-NI"; ================================================ FILE: src/i18n/es-PA.js ================================================ /* * DateJS Culture String File * Country Code: es-PA * Name: Spanish (Panama) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["es-PA"] = { "name": "es-PA", "englishName": "Spanish (Panama)", "nativeName": "Español (Panamá)", "Sunday": "domingo", "Monday": "lunes", "Tuesday": "martes", "Wednesday": "miércoles", "Thursday": "jueves", "Friday": "viernes", "Saturday": "sábado", "Sun": "dom", "Mon": "lun", "Tue": "mar", "Wed": "mié", "Thu": "jue", "Fri": "vie", "Sat": "sáb", "Su": "do", "Mo": "lu", "Tu": "ma", "We": "mi", "Th": "ju", "Fr": "vi", "Sa": "sá", "S_Sun_Initial": "d", "M_Mon_Initial": "l", "T_Tue_Initial": "m", "W_Wed_Initial": "m", "T_Thu_Initial": "j", "F_Fri_Initial": "v", "S_Sat_Initial": "s", "January": "enero", "February": "febrero", "March": "marzo", "April": "abril", "May": "mayo", "June": "junio", "July": "julio", "August": "agosto", "September": "septiembre", "October": "octubre", "November": "noviembre", "December": "diciembre", "Jan_Abbr": "ene", "Feb_Abbr": "feb", "Mar_Abbr": "mar", "Apr_Abbr": "abr", "May_Abbr": "may", "Jun_Abbr": "jun", "Jul_Abbr": "jul", "Aug_Abbr": "ago", "Sep_Abbr": "sep", "Oct_Abbr": "oct", "Nov_Abbr": "nov", "Dec_Abbr": "dic", "AM": "a.m.", "PM": "p.m.", "firstDayOfWeek": 0, "twoDigitYearMax": 2029, "mdy": "mdy", "M/d/yyyy": "MM/dd/yyyy", "dddd, MMMM dd, yyyy": "dddd, dd [de] MMMM [de] yyyy", "h:mm tt": "hh:mm tt", "h:mm:ss tt": "hh:mm:ss tt", "dddd, MMMM dd, yyyy h:mm:ss tt": "dddd, dd [de] MMMM [de] yyyy hh:mm:ss tt", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "dd MMMM", "MMMM, yyyy": "MMMM [de] yyyy", "/jan(uary)?/": "ene(ro)?", "/feb(ruary)?/": "feb(rero)?", "/mar(ch)?/": "mar(zo)?", "/apr(il)?/": "abr(il)?", "/may/": "may(o)?", "/jun(e)?/": "jun(io)?", "/jul(y)?/": "jul(io)?", "/aug(ust)?/": "ago(sto)?", "/sep(t(ember)?)?/": "sep(tiembre)?", "/oct(ober)?/": "oct(ubre)?", "/nov(ember)?/": "nov(iembre)?", "/dec(ember)?/": "dic(iembre)?", "/^su(n(day)?)?/": "^do(m(ingo)?)?", "/^mo(n(day)?)?/": "^lu(n(es)?)?", "/^tu(e(s(day)?)?)?/": "^ma(r(tes)?)?", "/^we(d(nesday)?)?/": "^mi(é(rcoles)?)?", "/^th(u(r(s(day)?)?)?)?/": "^ju(e(ves)?)?", "/^fr(i(day)?)?/": "^vi(e(rnes)?)?", "/^sa(t(urday)?)?/": "^sá(b(ado)?)?", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "es-PA"; ================================================ FILE: src/i18n/es-PE.js ================================================ /* * DateJS Culture String File * Country Code: es-PE * Name: Spanish (Peru) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["es-PE"] = { "name": "es-PE", "englishName": "Spanish (Peru)", "nativeName": "Español (Perú)", "Sunday": "domingo", "Monday": "lunes", "Tuesday": "martes", "Wednesday": "miércoles", "Thursday": "jueves", "Friday": "viernes", "Saturday": "sábado", "Sun": "dom", "Mon": "lun", "Tue": "mar", "Wed": "mié", "Thu": "jue", "Fri": "vie", "Sat": "sáb", "Su": "do", "Mo": "lu", "Tu": "ma", "We": "mi", "Th": "ju", "Fr": "vi", "Sa": "sá", "S_Sun_Initial": "d", "M_Mon_Initial": "l", "T_Tue_Initial": "m", "W_Wed_Initial": "m", "T_Thu_Initial": "j", "F_Fri_Initial": "v", "S_Sat_Initial": "s", "January": "enero", "February": "febrero", "March": "marzo", "April": "abril", "May": "mayo", "June": "junio", "July": "julio", "August": "agosto", "September": "septiembre", "October": "octubre", "November": "noviembre", "December": "diciembre", "Jan_Abbr": "ene", "Feb_Abbr": "feb", "Mar_Abbr": "mar", "Apr_Abbr": "abr", "May_Abbr": "may", "Jun_Abbr": "jun", "Jul_Abbr": "jul", "Aug_Abbr": "ago", "Sep_Abbr": "sep", "Oct_Abbr": "oct", "Nov_Abbr": "nov", "Dec_Abbr": "dic", "AM": "a.m.", "PM": "p.m.", "firstDayOfWeek": 0, "twoDigitYearMax": 2029, "mdy": "dmy", "M/d/yyyy": "dd/MM/yyyy", "dddd, MMMM dd, yyyy": "dddd, dd [de] MMMM [de] yyyy", "h:mm tt": "hh:mm tt", "h:mm:ss tt": "hh:mm:ss tt", "dddd, MMMM dd, yyyy h:mm:ss tt": "dddd, dd [de] MMMM [de] yyyy hh:mm:ss tt", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "dd MMMM", "MMMM, yyyy": "MMMM [de] yyyy", "/jan(uary)?/": "ene(ro)?", "/feb(ruary)?/": "feb(rero)?", "/mar(ch)?/": "mar(zo)?", "/apr(il)?/": "abr(il)?", "/may/": "may(o)?", "/jun(e)?/": "jun(io)?", "/jul(y)?/": "jul(io)?", "/aug(ust)?/": "ago(sto)?", "/sep(t(ember)?)?/": "sep(tiembre)?", "/oct(ober)?/": "oct(ubre)?", "/nov(ember)?/": "nov(iembre)?", "/dec(ember)?/": "dic(iembre)?", "/^su(n(day)?)?/": "^do(m(ingo)?)?", "/^mo(n(day)?)?/": "^lu(n(es)?)?", "/^tu(e(s(day)?)?)?/": "^ma(r(tes)?)?", "/^we(d(nesday)?)?/": "^mi(é(rcoles)?)?", "/^th(u(r(s(day)?)?)?)?/": "^ju(e(ves)?)?", "/^fr(i(day)?)?/": "^vi(e(rnes)?)?", "/^sa(t(urday)?)?/": "^sá(b(ado)?)?", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "es-PE"; ================================================ FILE: src/i18n/es-PR.js ================================================ /* * DateJS Culture String File * Country Code: es-PR * Name: Spanish (Puerto Rico) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["es-PR"] = { "name": "es-PR", "englishName": "Spanish (Puerto Rico)", "nativeName": "Español (Puerto Rico)", "Sunday": "domingo", "Monday": "lunes", "Tuesday": "martes", "Wednesday": "miércoles", "Thursday": "jueves", "Friday": "viernes", "Saturday": "sábado", "Sun": "dom", "Mon": "lun", "Tue": "mar", "Wed": "mié", "Thu": "jue", "Fri": "vie", "Sat": "sáb", "Su": "do", "Mo": "lu", "Tu": "ma", "We": "mi", "Th": "ju", "Fr": "vi", "Sa": "sá", "S_Sun_Initial": "d", "M_Mon_Initial": "l", "T_Tue_Initial": "m", "W_Wed_Initial": "m", "T_Thu_Initial": "j", "F_Fri_Initial": "v", "S_Sat_Initial": "s", "January": "enero", "February": "febrero", "March": "marzo", "April": "abril", "May": "mayo", "June": "junio", "July": "julio", "August": "agosto", "September": "septiembre", "October": "octubre", "November": "noviembre", "December": "diciembre", "Jan_Abbr": "ene", "Feb_Abbr": "feb", "Mar_Abbr": "mar", "Apr_Abbr": "abr", "May_Abbr": "may", "Jun_Abbr": "jun", "Jul_Abbr": "jul", "Aug_Abbr": "ago", "Sep_Abbr": "sep", "Oct_Abbr": "oct", "Nov_Abbr": "nov", "Dec_Abbr": "dic", "AM": "a.m.", "PM": "p.m.", "firstDayOfWeek": 0, "twoDigitYearMax": 2029, "mdy": "dmy", "M/d/yyyy": "dd/MM/yyyy", "dddd, MMMM dd, yyyy": "dddd, dd [de] MMMM [de] yyyy", "h:mm tt": "hh:mm tt", "h:mm:ss tt": "hh:mm:ss tt", "dddd, MMMM dd, yyyy h:mm:ss tt": "dddd, dd [de] MMMM [de] yyyy hh:mm:ss tt", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "dd MMMM", "MMMM, yyyy": "MMMM [de] yyyy", "/jan(uary)?/": "ene(ro)?", "/feb(ruary)?/": "feb(rero)?", "/mar(ch)?/": "mar(zo)?", "/apr(il)?/": "abr(il)?", "/may/": "may(o)?", "/jun(e)?/": "jun(io)?", "/jul(y)?/": "jul(io)?", "/aug(ust)?/": "ago(sto)?", "/sep(t(ember)?)?/": "sep(tiembre)?", "/oct(ober)?/": "oct(ubre)?", "/nov(ember)?/": "nov(iembre)?", "/dec(ember)?/": "dic(iembre)?", "/^su(n(day)?)?/": "^do(m(ingo)?)?", "/^mo(n(day)?)?/": "^lu(n(es)?)?", "/^tu(e(s(day)?)?)?/": "^ma(r(tes)?)?", "/^we(d(nesday)?)?/": "^mi(é(rcoles)?)?", "/^th(u(r(s(day)?)?)?)?/": "^ju(e(ves)?)?", "/^fr(i(day)?)?/": "^vi(e(rnes)?)?", "/^sa(t(urday)?)?/": "^sá(b(ado)?)?", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "es-PR"; ================================================ FILE: src/i18n/es-PY.js ================================================ /* * DateJS Culture String File * Country Code: es-PY * Name: Spanish (Paraguay) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["es-PY"] = { "name": "es-PY", "englishName": "Spanish (Paraguay)", "nativeName": "Español (Paraguay)", "Sunday": "domingo", "Monday": "lunes", "Tuesday": "martes", "Wednesday": "miércoles", "Thursday": "jueves", "Friday": "viernes", "Saturday": "sábado", "Sun": "dom", "Mon": "lun", "Tue": "mar", "Wed": "mié", "Thu": "jue", "Fri": "vie", "Sat": "sáb", "Su": "do", "Mo": "lu", "Tu": "ma", "We": "mi", "Th": "ju", "Fr": "vi", "Sa": "sá", "S_Sun_Initial": "d", "M_Mon_Initial": "l", "T_Tue_Initial": "m", "W_Wed_Initial": "m", "T_Thu_Initial": "j", "F_Fri_Initial": "v", "S_Sat_Initial": "s", "January": "enero", "February": "febrero", "March": "marzo", "April": "abril", "May": "mayo", "June": "junio", "July": "julio", "August": "agosto", "September": "septiembre", "October": "octubre", "November": "noviembre", "December": "diciembre", "Jan_Abbr": "ene", "Feb_Abbr": "feb", "Mar_Abbr": "mar", "Apr_Abbr": "abr", "May_Abbr": "may", "Jun_Abbr": "jun", "Jul_Abbr": "jul", "Aug_Abbr": "ago", "Sep_Abbr": "sep", "Oct_Abbr": "oct", "Nov_Abbr": "nov", "Dec_Abbr": "dic", "AM": "a.m.", "PM": "p.m.", "firstDayOfWeek": 1, "twoDigitYearMax": 2029, "mdy": "dmy", "M/d/yyyy": "dd/MM/yyyy", "dddd, MMMM dd, yyyy": "dddd, dd [de] MMMM [de] yyyy", "h:mm tt": "hh:mm tt", "h:mm:ss tt": "hh:mm:ss tt", "dddd, MMMM dd, yyyy h:mm:ss tt": "dddd, dd [de] MMMM [de] yyyy hh:mm:ss tt", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "dd MMMM", "MMMM, yyyy": "MMMM [de] yyyy", "/jan(uary)?/": "ene(ro)?", "/feb(ruary)?/": "feb(rero)?", "/mar(ch)?/": "mar(zo)?", "/apr(il)?/": "abr(il)?", "/may/": "may(o)?", "/jun(e)?/": "jun(io)?", "/jul(y)?/": "jul(io)?", "/aug(ust)?/": "ago(sto)?", "/sep(t(ember)?)?/": "sep(tiembre)?", "/oct(ober)?/": "oct(ubre)?", "/nov(ember)?/": "nov(iembre)?", "/dec(ember)?/": "dic(iembre)?", "/^su(n(day)?)?/": "^do(m(ingo)?)?", "/^mo(n(day)?)?/": "^lu(n(es)?)?", "/^tu(e(s(day)?)?)?/": "^ma(r(tes)?)?", "/^we(d(nesday)?)?/": "^mi(é(rcoles)?)?", "/^th(u(r(s(day)?)?)?)?/": "^ju(e(ves)?)?", "/^fr(i(day)?)?/": "^vi(e(rnes)?)?", "/^sa(t(urday)?)?/": "^sá(b(ado)?)?", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "es-PY"; ================================================ FILE: src/i18n/es-SV.js ================================================ /* * DateJS Culture String File * Country Code: es-SV * Name: Spanish (El Salvador) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["es-SV"] = { "name": "es-SV", "englishName": "Spanish (El Salvador)", "nativeName": "Español (El Salvador)", "Sunday": "domingo", "Monday": "lunes", "Tuesday": "martes", "Wednesday": "miércoles", "Thursday": "jueves", "Friday": "viernes", "Saturday": "sábado", "Sun": "dom", "Mon": "lun", "Tue": "mar", "Wed": "mié", "Thu": "jue", "Fri": "vie", "Sat": "sáb", "Su": "do", "Mo": "lu", "Tu": "ma", "We": "mi", "Th": "ju", "Fr": "vi", "Sa": "sá", "S_Sun_Initial": "d", "M_Mon_Initial": "l", "T_Tue_Initial": "m", "W_Wed_Initial": "m", "T_Thu_Initial": "j", "F_Fri_Initial": "v", "S_Sat_Initial": "s", "January": "enero", "February": "febrero", "March": "marzo", "April": "abril", "May": "mayo", "June": "junio", "July": "julio", "August": "agosto", "September": "septiembre", "October": "octubre", "November": "noviembre", "December": "diciembre", "Jan_Abbr": "ene", "Feb_Abbr": "feb", "Mar_Abbr": "mar", "Apr_Abbr": "abr", "May_Abbr": "may", "Jun_Abbr": "jun", "Jul_Abbr": "jul", "Aug_Abbr": "ago", "Sep_Abbr": "sep", "Oct_Abbr": "oct", "Nov_Abbr": "nov", "Dec_Abbr": "dic", "AM": "a.m.", "PM": "p.m.", "firstDayOfWeek": 0, "twoDigitYearMax": 2029, "mdy": "dmy", "M/d/yyyy": "dd/MM/yyyy", "dddd, MMMM dd, yyyy": "dddd, dd [de] MMMM [de] yyyy", "h:mm tt": "hh:mm tt", "h:mm:ss tt": "hh:mm:ss tt", "dddd, MMMM dd, yyyy h:mm:ss tt": "dddd, dd [de] MMMM [de] yyyy hh:mm:ss tt", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "dd MMMM", "MMMM, yyyy": "MMMM [de] yyyy", "/jan(uary)?/": "ene(ro)?", "/feb(ruary)?/": "feb(rero)?", "/mar(ch)?/": "mar(zo)?", "/apr(il)?/": "abr(il)?", "/may/": "may(o)?", "/jun(e)?/": "jun(io)?", "/jul(y)?/": "jul(io)?", "/aug(ust)?/": "ago(sto)?", "/sep(t(ember)?)?/": "sep(tiembre)?", "/oct(ober)?/": "oct(ubre)?", "/nov(ember)?/": "nov(iembre)?", "/dec(ember)?/": "dic(iembre)?", "/^su(n(day)?)?/": "^do(m(ingo)?)?", "/^mo(n(day)?)?/": "^lu(n(es)?)?", "/^tu(e(s(day)?)?)?/": "^ma(r(tes)?)?", "/^we(d(nesday)?)?/": "^mi(é(rcoles)?)?", "/^th(u(r(s(day)?)?)?)?/": "^ju(e(ves)?)?", "/^fr(i(day)?)?/": "^vi(e(rnes)?)?", "/^sa(t(urday)?)?/": "^sá(b(ado)?)?", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "es-SV"; ================================================ FILE: src/i18n/es-UY.js ================================================ /* * DateJS Culture String File * Country Code: es-UY * Name: Spanish (Uruguay) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["es-UY"] = { "name": "es-UY", "englishName": "Spanish (Uruguay)", "nativeName": "Español (Uruguay)", "Sunday": "domingo", "Monday": "lunes", "Tuesday": "martes", "Wednesday": "miércoles", "Thursday": "jueves", "Friday": "viernes", "Saturday": "sábado", "Sun": "dom", "Mon": "lun", "Tue": "mar", "Wed": "mié", "Thu": "jue", "Fri": "vie", "Sat": "sáb", "Su": "do", "Mo": "lu", "Tu": "ma", "We": "mi", "Th": "ju", "Fr": "vi", "Sa": "sá", "S_Sun_Initial": "d", "M_Mon_Initial": "l", "T_Tue_Initial": "m", "W_Wed_Initial": "m", "T_Thu_Initial": "j", "F_Fri_Initial": "v", "S_Sat_Initial": "s", "January": "enero", "February": "febrero", "March": "marzo", "April": "abril", "May": "mayo", "June": "junio", "July": "julio", "August": "agosto", "September": "septiembre", "October": "octubre", "November": "noviembre", "December": "diciembre", "Jan_Abbr": "ene", "Feb_Abbr": "feb", "Mar_Abbr": "mar", "Apr_Abbr": "abr", "May_Abbr": "may", "Jun_Abbr": "jun", "Jul_Abbr": "jul", "Aug_Abbr": "ago", "Sep_Abbr": "sep", "Oct_Abbr": "oct", "Nov_Abbr": "nov", "Dec_Abbr": "dic", "AM": "a.m.", "PM": "p.m.", "firstDayOfWeek": 1, "twoDigitYearMax": 2029, "mdy": "dmy", "M/d/yyyy": "dd/MM/yyyy", "dddd, MMMM dd, yyyy": "dddd, dd [de] MMMM [de] yyyy", "h:mm tt": "hh:mm tt", "h:mm:ss tt": "hh:mm:ss tt", "dddd, MMMM dd, yyyy h:mm:ss tt": "dddd, dd [de] MMMM [de] yyyy hh:mm:ss tt", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "dd MMMM", "MMMM, yyyy": "MMMM [de] yyyy", "/jan(uary)?/": "ene(ro)?", "/feb(ruary)?/": "feb(rero)?", "/mar(ch)?/": "mar(zo)?", "/apr(il)?/": "abr(il)?", "/may/": "may(o)?", "/jun(e)?/": "jun(io)?", "/jul(y)?/": "jul(io)?", "/aug(ust)?/": "ago(sto)?", "/sep(t(ember)?)?/": "sep(tiembre)?", "/oct(ober)?/": "oct(ubre)?", "/nov(ember)?/": "nov(iembre)?", "/dec(ember)?/": "dic(iembre)?", "/^su(n(day)?)?/": "^do(m(ingo)?)?", "/^mo(n(day)?)?/": "^lu(n(es)?)?", "/^tu(e(s(day)?)?)?/": "^ma(r(tes)?)?", "/^we(d(nesday)?)?/": "^mi(é(rcoles)?)?", "/^th(u(r(s(day)?)?)?)?/": "^ju(e(ves)?)?", "/^fr(i(day)?)?/": "^vi(e(rnes)?)?", "/^sa(t(urday)?)?/": "^sá(b(ado)?)?", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "es-UY"; ================================================ FILE: src/i18n/es-VE.js ================================================ /* * DateJS Culture String File * Country Code: es-VE * Name: Spanish (Venezuela) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["es-VE"] = { "name": "es-VE", "englishName": "Spanish (Venezuela)", "nativeName": "Español (Republica Bolivariana de Venezuela)", "Sunday": "domingo", "Monday": "lunes", "Tuesday": "martes", "Wednesday": "miércoles", "Thursday": "jueves", "Friday": "viernes", "Saturday": "sábado", "Sun": "dom", "Mon": "lun", "Tue": "mar", "Wed": "mié", "Thu": "jue", "Fri": "vie", "Sat": "sáb", "Su": "do", "Mo": "lu", "Tu": "ma", "We": "mi", "Th": "ju", "Fr": "vi", "Sa": "sá", "S_Sun_Initial": "d", "M_Mon_Initial": "l", "T_Tue_Initial": "m", "W_Wed_Initial": "m", "T_Thu_Initial": "j", "F_Fri_Initial": "v", "S_Sat_Initial": "s", "January": "enero", "February": "febrero", "March": "marzo", "April": "abril", "May": "mayo", "June": "junio", "July": "julio", "August": "agosto", "September": "septiembre", "October": "octubre", "November": "noviembre", "December": "diciembre", "Jan_Abbr": "ene", "Feb_Abbr": "feb", "Mar_Abbr": "mar", "Apr_Abbr": "abr", "May_Abbr": "may", "Jun_Abbr": "jun", "Jul_Abbr": "jul", "Aug_Abbr": "ago", "Sep_Abbr": "sep", "Oct_Abbr": "oct", "Nov_Abbr": "nov", "Dec_Abbr": "dic", "AM": "a.m.", "PM": "p.m.", "firstDayOfWeek": 0, "twoDigitYearMax": 2029, "mdy": "dmy", "M/d/yyyy": "dd/MM/yyyy", "dddd, MMMM dd, yyyy": "dddd, dd [de] MMMM [de] yyyy", "h:mm tt": "hh:mm tt", "h:mm:ss tt": "hh:mm:ss tt", "dddd, MMMM dd, yyyy h:mm:ss tt": "dddd, dd [de] MMMM [de] yyyy hh:mm:ss tt", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "dd MMMM", "MMMM, yyyy": "MMMM [de] yyyy", "/jan(uary)?/": "ene(ro)?", "/feb(ruary)?/": "feb(rero)?", "/mar(ch)?/": "mar(zo)?", "/apr(il)?/": "abr(il)?", "/may/": "may(o)?", "/jun(e)?/": "jun(io)?", "/jul(y)?/": "jul(io)?", "/aug(ust)?/": "ago(sto)?", "/sep(t(ember)?)?/": "sep(tiembre)?", "/oct(ober)?/": "oct(ubre)?", "/nov(ember)?/": "nov(iembre)?", "/dec(ember)?/": "dic(iembre)?", "/^su(n(day)?)?/": "^do(m(ingo)?)?", "/^mo(n(day)?)?/": "^lu(n(es)?)?", "/^tu(e(s(day)?)?)?/": "^ma(r(tes)?)?", "/^we(d(nesday)?)?/": "^mi(é(rcoles)?)?", "/^th(u(r(s(day)?)?)?)?/": "^ju(e(ves)?)?", "/^fr(i(day)?)?/": "^vi(e(rnes)?)?", "/^sa(t(urday)?)?/": "^sá(b(ado)?)?", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "es-VE"; ================================================ FILE: src/i18n/et-EE.js ================================================ /* * DateJS Culture String File * Country Code: et-EE * Name: Estonian (Estonia) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["et-EE"] = { "name": "et-EE", "englishName": "Estonian (Estonia)", "nativeName": "eesti (Eesti)", "Sunday": "pühapäev", "Monday": "esmaspäev", "Tuesday": "teisipäev", "Wednesday": "kolmapäev", "Thursday": "neljapäev", "Friday": "reede", "Saturday": "laupäev", "Sun": "P", "Mon": "E", "Tue": "T", "Wed": "K", "Thu": "N", "Fri": "R", "Sat": "L", "Su": "P", "Mo": "E", "Tu": "T", "We": "K", "Th": "N", "Fr": "R", "Sa": "L", "S_Sun_Initial": "P", "M_Mon_Initial": "E", "T_Tue_Initial": "T", "W_Wed_Initial": "K", "T_Thu_Initial": "N", "F_Fri_Initial": "R", "S_Sat_Initial": "L", "January": "jaanuar", "February": "veebruar", "March": "märts", "April": "aprill", "May": "mai", "June": "juuni", "July": "juuli", "August": "august", "September": "september", "October": "oktoober", "November": "november", "December": "detsember", "Jan_Abbr": "jaan", "Feb_Abbr": "veebr", "Mar_Abbr": "märts", "Apr_Abbr": "apr", "May_Abbr": "mai", "Jun_Abbr": "juuni", "Jul_Abbr": "juuli", "Aug_Abbr": "aug", "Sep_Abbr": "sept", "Oct_Abbr": "okt", "Nov_Abbr": "nov", "Dec_Abbr": "dets", "AM": "EL", "PM": "PL", "firstDayOfWeek": 1, "twoDigitYearMax": 2029, "mdy": "dmy", "M/d/yyyy": "d.MM.yyyy", "dddd, MMMM dd, yyyy": "d. MMMM yyyy'. a.'", "h:mm tt": "H:mm", "h:mm:ss tt": "H:mm:ss", "dddd, MMMM dd, yyyy h:mm:ss tt": "d. MMMM yyyy'. a.' H:mm:ss", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "d. MMMM", "MMMM, yyyy": "MMMM yyyy'. a.'", "/jan(uary)?/": "jaan(uar)?", "/feb(ruary)?/": "veebr(uar)?", "/mar(ch)?/": "märts", "/apr(il)?/": "apr(ill)?", "/may/": "mai", "/jun(e)?/": "juuni", "/jul(y)?/": "juuli", "/aug(ust)?/": "aug(ust)?", "/sep(t(ember)?)?/": "sep(t(ember)?)?", "/oct(ober)?/": "okt(oober)?", "/nov(ember)?/": "nov(ember)?", "/dec(ember)?/": "dets(ember)?", "/^su(n(day)?)?/": "^pühapäev", "/^mo(n(day)?)?/": "^esmaspäev", "/^tu(e(s(day)?)?)?/": "^teisipäev", "/^we(d(nesday)?)?/": "^kolmapäev", "/^th(u(r(s(day)?)?)?)?/": "^neljapäev", "/^fr(i(day)?)?/": "^reede", "/^sa(t(urday)?)?/": "^laupäev", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "et-EE"; ================================================ FILE: src/i18n/eu-ES.js ================================================ /* * DateJS Culture String File * Country Code: eu-ES * Name: Basque (Basque) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["eu-ES"] = { "name": "eu-ES", "englishName": "Basque (Basque)", "nativeName": "euskara (euskara)", "Sunday": "igandea", "Monday": "astelehena", "Tuesday": "asteartea", "Wednesday": "asteazkena", "Thursday": "osteguna", "Friday": "ostirala", "Saturday": "larunbata", "Sun": "ig.", "Mon": "al.", "Tue": "as.", "Wed": "az.", "Thu": "og.", "Fri": "or.", "Sat": "lr.", "Su": "ig", "Mo": "al", "Tu": "as", "We": "az", "Th": "og", "Fr": "or", "Sa": "lr", "S_Sun_Initial": "i", "M_Mon_Initial": "a", "T_Tue_Initial": "a", "W_Wed_Initial": "a", "T_Thu_Initial": "o", "F_Fri_Initial": "o", "S_Sat_Initial": "l", "January": "urtarrila", "February": "otsaila", "March": "martxoa", "April": "apirila", "May": "maiatza", "June": "ekaina", "July": "uztaila", "August": "abuztua", "September": "iraila", "October": "urria", "November": "azaroa", "December": "abendua", "Jan_Abbr": "urt.", "Feb_Abbr": "ots.", "Mar_Abbr": "mar.", "Apr_Abbr": "api.", "May_Abbr": "mai.", "Jun_Abbr": "eka.", "Jul_Abbr": "uzt.", "Aug_Abbr": "abu.", "Sep_Abbr": "ira.", "Oct_Abbr": "urr.", "Nov_Abbr": "aza.", "Dec_Abbr": "abe.", "AM": "", "PM": "", "firstDayOfWeek": 1, "twoDigitYearMax": 2029, "mdy": "ymd", "M/d/yyyy": "yyyy/MM/dd", "dddd, MMMM dd, yyyy": "dddd, yyyy.'eko' MMMM'k 'd", "h:mm tt": "HH:mm", "h:mm:ss tt": "HH:mm:ss", "dddd, MMMM dd, yyyy h:mm:ss tt": "dddd, yyyy.'eko' MMMM'k 'd HH:mm:ss", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "MMMM dd", "MMMM, yyyy": "yyyy.'eko' MMMM", "/jan(uary)?/": "urt(.(arrila)?)?", "/feb(ruary)?/": "ots(.(aila)?)?", "/mar(ch)?/": "mar(.(txoa)?)?", "/apr(il)?/": "api(.(rila)?)?", "/may/": "mai(.(atza)?)?", "/jun(e)?/": "eka(.(ina)?)?", "/jul(y)?/": "uzt(.(aila)?)?", "/aug(ust)?/": "abu(.(ztua)?)?", "/sep(t(ember)?)?/": "ira(.(ila)?)?", "/oct(ober)?/": "urr(.(ia)?)?", "/nov(ember)?/": "aza(.(roa)?)?", "/dec(ember)?/": "abe(.(ndua)?)?", "/^su(n(day)?)?/": "^ig((.(andea)?)?)?", "/^mo(n(day)?)?/": "^al((.(telehena)?)?)?", "/^tu(e(s(day)?)?)?/": "^as((.(teartea)?)?)?", "/^we(d(nesday)?)?/": "^az((.(teazkena)?)?)?", "/^th(u(r(s(day)?)?)?)?/": "^og((.(teguna)?)?)?", "/^fr(i(day)?)?/": "^or((.(tirala)?)?)?", "/^sa(t(urday)?)?/": "^lr((.(runbata)?)?)?", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "eu-ES"; ================================================ FILE: src/i18n/fa-IR.js ================================================ /* * DateJS Culture String File * Country Code: fa-IR * Name: Persian (Iran) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["fa-IR"] = { "name": "fa-IR", "englishName": "Persian (Iran)", "nativeName": "فارسى (ايران)", "Sunday": "Sunday", "Monday": "Monday", "Tuesday": "Tuesday", "Wednesday": "Wednesday", "Thursday": "Thursday", "Friday": "Friday", "Saturday": "Saturday", "Sun": "Sun", "Mon": "Mon", "Tue": "Tue", "Wed": "Wed", "Thu": "Thu", "Fri": "Fri", "Sat": "Sat", "Su": "Su", "Mo": "Mo", "Tu": "Tu", "We": "We", "Th": "Th", "Fr": "Fr", "Sa": "Sa", "S_Sun_Initial": "S", "M_Mon_Initial": "M", "T_Tue_Initial": "T", "W_Wed_Initial": "W", "T_Thu_Initial": "T", "F_Fri_Initial": "F", "S_Sat_Initial": "S", "January": "January", "February": "February", "March": "March", "April": "April", "May": "May", "June": "June", "July": "July", "August": "August", "September": "September", "October": "October", "November": "November", "December": "December", "Jan_Abbr": "Jan", "Feb_Abbr": "Feb", "Mar_Abbr": "Mar", "Apr_Abbr": "Apr", "May_Abbr": "May", "Jun_Abbr": "Jun", "Jul_Abbr": "Jul", "Aug_Abbr": "Aug", "Sep_Abbr": "Sep", "Oct_Abbr": "Oct", "Nov_Abbr": "Nov", "Dec_Abbr": "Dec", "AM": "ق.ظ", "PM": "ب.ظ", "firstDayOfWeek": 0, "twoDigitYearMax": 2029, "mdy": "mdy", "M/d/yyyy": "M/d/yyyy", "dddd, MMMM dd, yyyy": "dddd, MMMM dd, yyyy", "h:mm tt": "hh:mm tt", "h:mm:ss tt": "hh:mm:ss tt", "dddd, MMMM dd, yyyy h:mm:ss tt": "dddd, MMMM dd, yyyy hh:mm:ss tt", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "MMMM dd", "MMMM, yyyy": "MMMM, yyyy", "/jan(uary)?/": "jan(uary)?", "/feb(ruary)?/": "feb(ruary)?", "/mar(ch)?/": "mar(ch)?", "/apr(il)?/": "apr(il)?", "/may/": "may", "/jun(e)?/": "jun(e)?", "/jul(y)?/": "jul(y)?", "/aug(ust)?/": "aug(ust)?", "/sep(t(ember)?)?/": "sep(t(ember)?)?", "/oct(ober)?/": "oct(ober)?", "/nov(ember)?/": "nov(ember)?", "/dec(ember)?/": "dec(ember)?", "/^su(n(day)?)?/": "^su(n(day)?)?", "/^mo(n(day)?)?/": "^mo(n(day)?)?", "/^tu(e(s(day)?)?)?/": "^tu(e(s(day)?)?)?", "/^we(d(nesday)?)?/": "^we(d(nesday)?)?", "/^th(u(r(s(day)?)?)?)?/": "^th(u(r(s(day)?)?)?)?", "/^fr(i(day)?)?/": "^fr(i(day)?)?", "/^sa(t(urday)?)?/": "^sa(t(urday)?)?", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "fa-IR"; ================================================ FILE: src/i18n/fi-FI.js ================================================ /* * DateJS Culture String File * Country Code: fi-FI * Name: Finnish (Finland) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["fi-FI"] = { "name": "fi-FI", "englishName": "Finnish (Finland)", "nativeName": "suomi (Suomi)", "Sunday": "sunnuntai", "Monday": "maanantai", "Tuesday": "tiistai", "Wednesday": "keskiviikko", "Thursday": "torstai", "Friday": "perjantai", "Saturday": "lauantai", "Sun": "su", "Mon": "ma", "Tue": "ti", "Wed": "ke", "Thu": "to", "Fri": "pe", "Sat": "la", "Su": "su", "Mo": "ma", "Tu": "ti", "We": "ke", "Th": "to", "Fr": "pe", "Sa": "la", "S_Sun_Initial": "s", "M_Mon_Initial": "m", "T_Tue_Initial": "t", "W_Wed_Initial": "k", "T_Thu_Initial": "t", "F_Fri_Initial": "p", "S_Sat_Initial": "l", "January": "tammikuu", "February": "helmikuu", "March": "maaliskuu", "April": "huhtikuu", "May": "toukokuu", "June": "kesäkuu", "July": "heinäkuu", "August": "elokuu", "September": "syyskuu", "October": "lokakuu", "November": "marraskuu", "December": "joulukuu", "Jan_Abbr": "tammi", "Feb_Abbr": "helmi", "Mar_Abbr": "maalis", "Apr_Abbr": "huhti", "May_Abbr": "touko", "Jun_Abbr": "kesä", "Jul_Abbr": "heinä", "Aug_Abbr": "elo", "Sep_Abbr": "syys", "Oct_Abbr": "loka", "Nov_Abbr": "marras", "Dec_Abbr": "joulu", "AM": "", "PM": "", "firstDayOfWeek": 1, "twoDigitYearMax": 2029, "mdy": "dmy", "M/d/yyyy": "d.M.yyyy", "dddd, MMMM dd, yyyy": "d. MMMM'ta 'yyyy", "h:mm tt": "H:mm", "h:mm:ss tt": "H:mm:ss", "dddd, MMMM dd, yyyy h:mm:ss tt": "d. MMMM'ta 'yyyy H:mm:ss", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "d. MMMM'ta'", "MMMM, yyyy": "MMMM yyyy", "/jan(uary)?/": "tammi(kuu)?", "/feb(ruary)?/": "helmi(kuu)?", "/mar(ch)?/": "maalis(kuu)?", "/apr(il)?/": "huhti(kuu)?", "/may/": "touko(kuu)?", "/jun(e)?/": "kesä(kuu)?", "/jul(y)?/": "heinä(kuu)?", "/aug(ust)?/": "elo(kuu)?", "/sep(t(ember)?)?/": "syys(kuu)?", "/oct(ober)?/": "loka(kuu)?", "/nov(ember)?/": "marras(kuu)?", "/dec(ember)?/": "joulu(kuu)?", "/^su(n(day)?)?/": "^sunnuntai", "/^mo(n(day)?)?/": "^maanantai", "/^tu(e(s(day)?)?)?/": "^tiistai", "/^we(d(nesday)?)?/": "^keskiviikko", "/^th(u(r(s(day)?)?)?)?/": "^torstai", "/^fr(i(day)?)?/": "^perjantai", "/^sa(t(urday)?)?/": "^lauantai", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "fi-FI"; ================================================ FILE: src/i18n/fo-FO.js ================================================ /* * DateJS Culture String File * Country Code: fo-FO * Name: Faroese (Faroe Islands) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["fo-FO"] = { "name": "fo-FO", "englishName": "Faroese (Faroe Islands)", "nativeName": "føroyskt (Føroyar)", "Sunday": "sunnudagur", "Monday": "mánadagur", "Tuesday": "týsdagur", "Wednesday": "mikudagur", "Thursday": "hósdagur", "Friday": "fríggjadagur", "Saturday": "leygardagur", "Sun": "sun", "Mon": "mán", "Tue": "týs", "Wed": "mik", "Thu": "hós", "Fri": "frí", "Sat": "leyg", "Su": "su", "Mo": "má", "Tu": "tý", "We": "mi", "Th": "hó", "Fr": "fr", "Sa": "ley", "S_Sun_Initial": "s", "M_Mon_Initial": "m", "T_Tue_Initial": "t", "W_Wed_Initial": "m", "T_Thu_Initial": "h", "F_Fri_Initial": "f", "S_Sat_Initial": "l", "January": "januar", "February": "februar", "March": "mars", "April": "apríl", "May": "mai", "June": "juni", "July": "juli", "August": "august", "September": "september", "October": "oktober", "November": "november", "December": "desember", "Jan_Abbr": "jan", "Feb_Abbr": "feb", "Mar_Abbr": "mar", "Apr_Abbr": "apr", "May_Abbr": "mai", "Jun_Abbr": "jun", "Jul_Abbr": "jul", "Aug_Abbr": "aug", "Sep_Abbr": "sep", "Oct_Abbr": "okt", "Nov_Abbr": "nov", "Dec_Abbr": "des", "AM": "", "PM": "", "firstDayOfWeek": 1, "twoDigitYearMax": 2029, "mdy": "dmy", "M/d/yyyy": "dd-MM-yyyy", "dddd, MMMM dd, yyyy": "d. MMMM yyyy", "h:mm tt": "HH.mm", "h:mm:ss tt": "HH.mm.ss", "dddd, MMMM dd, yyyy h:mm:ss tt": "d. MMMM yyyy HH.mm.ss", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "d. MMMM", "MMMM, yyyy": "MMMM yyyy", "/jan(uary)?/": "jan(uar)?", "/feb(ruary)?/": "feb(ruar)?", "/mar(ch)?/": "mar(s)?", "/apr(il)?/": "apr(íl)?", "/may/": "mai", "/jun(e)?/": "jun(i)?", "/jul(y)?/": "jul(i)?", "/aug(ust)?/": "aug(ust)?", "/sep(t(ember)?)?/": "sep(t(ember)?)?", "/oct(ober)?/": "okt(ober)?", "/nov(ember)?/": "nov(ember)?", "/dec(ember)?/": "des(ember)?", "/^su(n(day)?)?/": "^su(n(nudagur)?)?", "/^mo(n(day)?)?/": "^má(n(adagur)?)?", "/^tu(e(s(day)?)?)?/": "^tý(s(dagur)?)?", "/^we(d(nesday)?)?/": "^mi(k(udagur)?)?", "/^th(u(r(s(day)?)?)?)?/": "^hó(s(dagur)?)?", "/^fr(i(day)?)?/": "^fr(í(ggjadagur)?)?", "/^sa(t(urday)?)?/": "^ley(g(ardagur)?)?", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "fo-FO"; ================================================ FILE: src/i18n/fr-BE.js ================================================ /* * DateJS Culture String File * Country Code: fr-BE * Name: French (Belgium) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["fr-BE"] = { "name": "fr-BE", "englishName": "French (Belgium)", "nativeName": "français (Belgique)", "Sunday": "dimanche", "Monday": "lundi", "Tuesday": "mardi", "Wednesday": "mercredi", "Thursday": "jeudi", "Friday": "vendredi", "Saturday": "samedi", "Sun": "dim.", "Mon": "lun.", "Tue": "mar.", "Wed": "mer.", "Thu": "jeu.", "Fri": "ven.", "Sat": "sam.", "Su": "di", "Mo": "lu", "Tu": "ma", "We": "me", "Th": "je", "Fr": "ve", "Sa": "sa", "S_Sun_Initial": "d", "M_Mon_Initial": "l", "T_Tue_Initial": "m", "W_Wed_Initial": "m", "T_Thu_Initial": "j", "F_Fri_Initial": "v", "S_Sat_Initial": "s", "January": "janvier", "February": "février", "March": "mars", "April": "avril", "May": "mai", "June": "juin", "July": "juillet", "August": "août", "September": "septembre", "October": "octobre", "November": "novembre", "December": "décembre", "Jan_Abbr": "janv.", "Feb_Abbr": "févr.", "Mar_Abbr": "mars", "Apr_Abbr": "avr.", "May_Abbr": "mai", "Jun_Abbr": "juin", "Jul_Abbr": "juil.", "Aug_Abbr": "août", "Sep_Abbr": "sept.", "Oct_Abbr": "oct.", "Nov_Abbr": "nov.", "Dec_Abbr": "déc.", "AM": "", "PM": "", "firstDayOfWeek": 1, "twoDigitYearMax": 2029, "mdy": "dmy", "M/d/yyyy": "d/MM/yyyy", "dddd, MMMM dd, yyyy": "dddd d MMMM yyyy", "h:mm tt": "H:mm", "h:mm:ss tt": "H:mm:ss", "dddd, MMMM dd, yyyy h:mm:ss tt": "dddd d MMMM yyyy H:mm:ss", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "d MMMM", "MMMM, yyyy": "MMMM yyyy", "/jan(uary)?/": "janv(.(ier)?)?", "/feb(ruary)?/": "févr(.(ier)?)?", "/mar(ch)?/": "mars", "/apr(il)?/": "avr(.(il)?)?", "/may/": "mai", "/jun(e)?/": "juin", "/jul(y)?/": "juil(.(let)?)?", "/aug(ust)?/": "août", "/sep(t(ember)?)?/": "sept(.(embre)?)?", "/oct(ober)?/": "oct(.(obre)?)?", "/nov(ember)?/": "nov(.(embre)?)?", "/dec(ember)?/": "déc(.(embre)?)?", "/^su(n(day)?)?/": "^di(m(.(anche)?)?)?", "/^mo(n(day)?)?/": "^lu(n(.(di)?)?)?", "/^tu(e(s(day)?)?)?/": "^ma(r(.(di)?)?)?", "/^we(d(nesday)?)?/": "^me(r(.(credi)?)?)?", "/^th(u(r(s(day)?)?)?)?/": "^je(u(.(di)?)?)?", "/^fr(i(day)?)?/": "^ve(n(.(dredi)?)?)?", "/^sa(t(urday)?)?/": "^sa(m(.(edi)?)?)?", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "fr-BE"; ================================================ FILE: src/i18n/fr-CA.js ================================================ /* * DateJS Culture String File * Country Code: fr-CA * Name: French (Canada) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["fr-CA"] = { "name": "fr-CA", "englishName": "French (Canada)", "nativeName": "français (Canada)", "Sunday": "dimanche", "Monday": "lundi", "Tuesday": "mardi", "Wednesday": "mercredi", "Thursday": "jeudi", "Friday": "vendredi", "Saturday": "samedi", "Sun": "dim.", "Mon": "lun.", "Tue": "mar.", "Wed": "mer.", "Thu": "jeu.", "Fri": "ven.", "Sat": "sam.", "Su": "di", "Mo": "lu", "Tu": "ma", "We": "me", "Th": "je", "Fr": "ve", "Sa": "sa", "S_Sun_Initial": "d", "M_Mon_Initial": "l", "T_Tue_Initial": "m", "W_Wed_Initial": "m", "T_Thu_Initial": "j", "F_Fri_Initial": "v", "S_Sat_Initial": "s", "January": "janvier", "February": "février", "March": "mars", "April": "avril", "May": "mai", "June": "juin", "July": "juillet", "August": "août", "September": "septembre", "October": "octobre", "November": "novembre", "December": "décembre", "Jan_Abbr": "janv.", "Feb_Abbr": "févr.", "Mar_Abbr": "mars", "Apr_Abbr": "avr.", "May_Abbr": "mai", "Jun_Abbr": "juin", "Jul_Abbr": "juil.", "Aug_Abbr": "août", "Sep_Abbr": "sept.", "Oct_Abbr": "oct.", "Nov_Abbr": "nov.", "Dec_Abbr": "déc.", "AM": "", "PM": "", "firstDayOfWeek": 0, "twoDigitYearMax": 2029, "mdy": "ymd", "M/d/yyyy": "yyyy-MM-dd", "dddd, MMMM dd, yyyy": "d MMMM yyyy", "h:mm tt": "HH:mm", "h:mm:ss tt": "HH:mm:ss", "dddd, MMMM dd, yyyy h:mm:ss tt": "d MMMM yyyy HH:mm:ss", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "d MMMM", "MMMM, yyyy": "MMMM, yyyy", "/jan(uary)?/": "janv((ier)?)?", "/feb(ruary)?/": "févr((ier)?)?", "/mar(ch)?/": "mars", "/apr(il)?/": "avr((il)?)?", "/may/": "mai", "/jun(e)?/": "juin", "/jul(y)?/": "juil((let)?)?", "/aug(ust)?/": "août", "/sep(t(ember)?)?/": "sept((embre)?)?", "/oct(ober)?/": "oct((obre)?)?", "/nov(ember)?/": "nov((embre)?)?", "/dec(ember)?/": "déc((embre)?)?", "/^su(n(day)?)?/": "^di(m((anche)?)?)?", "/^mo(n(day)?)?/": "^lu(n((di)?)?)?", "/^tu(e(s(day)?)?)?/": "^ma(r((di)?)?)?", "/^we(d(nesday)?)?/": "^me(r((credi)?)?)?", "/^th(u(r(s(day)?)?)?)?/": "^je(u((di)?)?)?", "/^fr(i(day)?)?/": "^ve(n((dredi)?)?)?", "/^sa(t(urday)?)?/": "^sa(m((edi)?)?)?", "/^next/": "^prochain", "/^last|past|prev(ious)?/": "^dernier", "/^(\\+|aft(er)?|from|hence)/": "^précédant", "/^(\\-|bef(ore)?|ago)/": "^succédant", "/^yes(terday)?/": "^hier", "/^t(od(ay)?)?/": "^aujourd\'hui", "/^tom(orrow)?/": "^demain", "/^n(ow)?/": "^maintenant", "/^ms|milli(second)?s?/": "^ms|milli(seconde)?s?", "/^sec(ond)?s?/": "^sec(onde)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(eure)?s?", "/^w(eek)?s?/": "^sem(aine)?s?", "/^m(onth)?s?/": "^m(ois)?", "/^d(ay)?s?/": "^j(our)?s?", "/^y(ear)?s?/": "^a(nnée)?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "fr-CA"; ================================================ FILE: src/i18n/fr-CH.js ================================================ /* * DateJS Culture String File * Country Code: fr-CH * Name: French (Switzerland) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["fr-CH"] = { "name": "fr-CH", "englishName": "French (Switzerland)", "nativeName": "français (Suisse)", "Sunday": "dimanche", "Monday": "lundi", "Tuesday": "mardi", "Wednesday": "mercredi", "Thursday": "jeudi", "Friday": "vendredi", "Saturday": "samedi", "Sun": "dim.", "Mon": "lun.", "Tue": "mar.", "Wed": "mer.", "Thu": "jeu.", "Fri": "ven.", "Sat": "sam.", "Su": "di", "Mo": "lu", "Tu": "ma", "We": "me", "Th": "je", "Fr": "ve", "Sa": "sa", "S_Sun_Initial": "d", "M_Mon_Initial": "l", "T_Tue_Initial": "m", "W_Wed_Initial": "m", "T_Thu_Initial": "j", "F_Fri_Initial": "v", "S_Sat_Initial": "s", "January": "janvier", "February": "février", "March": "mars", "April": "avril", "May": "mai", "June": "juin", "July": "juillet", "August": "août", "September": "septembre", "October": "octobre", "November": "novembre", "December": "décembre", "Jan_Abbr": "janv.", "Feb_Abbr": "févr.", "Mar_Abbr": "mars", "Apr_Abbr": "avr.", "May_Abbr": "mai", "Jun_Abbr": "juin", "Jul_Abbr": "juil.", "Aug_Abbr": "août", "Sep_Abbr": "sept.", "Oct_Abbr": "oct.", "Nov_Abbr": "nov.", "Dec_Abbr": "déc.", "AM": "", "PM": "", "firstDayOfWeek": 1, "twoDigitYearMax": 2029, "mdy": "dmy", "M/d/yyyy": "dd.MM.yyyy", "dddd, MMMM dd, yyyy": "dddd, d. MMMM yyyy", "h:mm tt": "HH:mm", "h:mm:ss tt": "HH:mm:ss", "dddd, MMMM dd, yyyy h:mm:ss tt": "dddd, d. MMMM yyyy HH:mm:ss", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "d MMMM", "MMMM, yyyy": "MMMM yyyy", "/jan(uary)?/": "janv(.(ier)?)?", "/feb(ruary)?/": "févr(.(ier)?)?", "/mar(ch)?/": "mars", "/apr(il)?/": "avr(.(il)?)?", "/may/": "mai", "/jun(e)?/": "juin", "/jul(y)?/": "juil(.(let)?)?", "/aug(ust)?/": "août", "/sep(t(ember)?)?/": "sept(.(embre)?)?", "/oct(ober)?/": "oct(.(obre)?)?", "/nov(ember)?/": "nov(.(embre)?)?", "/dec(ember)?/": "déc(.(embre)?)?", "/^su(n(day)?)?/": "^di(m(.(anche)?)?)?", "/^mo(n(day)?)?/": "^lu(n(.(di)?)?)?", "/^tu(e(s(day)?)?)?/": "^ma(r(.(di)?)?)?", "/^we(d(nesday)?)?/": "^me(r(.(credi)?)?)?", "/^th(u(r(s(day)?)?)?)?/": "^je(u(.(di)?)?)?", "/^fr(i(day)?)?/": "^ve(n(.(dredi)?)?)?", "/^sa(t(urday)?)?/": "^sa(m(.(edi)?)?)?", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "fr-CH"; ================================================ FILE: src/i18n/fr-FR.js ================================================ /* * DateJS Culture String File * Country Code: fr-FR * Name: French (France) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["fr-FR"] = { "name": "fr-FR", "englishName": "French (France)", "nativeName": "français (France)", "Sunday": "dimanche", "Monday": "lundi", "Tuesday": "mardi", "Wednesday": "mercredi", "Thursday": "jeudi", "Friday": "vendredi", "Saturday": "samedi", "Sun": "dim.", "Mon": "lun.", "Tue": "mar.", "Wed": "mer.", "Thu": "jeu.", "Fri": "ven.", "Sat": "sam.", "Su": "di", "Mo": "lu", "Tu": "ma", "We": "me", "Th": "je", "Fr": "ve", "Sa": "sa", "S_Sun_Initial": "d", "M_Mon_Initial": "l", "T_Tue_Initial": "m", "W_Wed_Initial": "m", "T_Thu_Initial": "j", "F_Fri_Initial": "v", "S_Sat_Initial": "s", "January": "janvier", "February": "février", "March": "mars", "April": "avril", "May": "mai", "June": "juin", "July": "juillet", "August": "août", "September": "septembre", "October": "octobre", "November": "novembre", "December": "décembre", "Jan_Abbr": "janv.", "Feb_Abbr": "févr.", "Mar_Abbr": "mars", "Apr_Abbr": "avr.", "May_Abbr": "mai", "Jun_Abbr": "juin", "Jul_Abbr": "juil.", "Aug_Abbr": "août", "Sep_Abbr": "sept.", "Oct_Abbr": "oct.", "Nov_Abbr": "nov.", "Dec_Abbr": "déc.", "AM": "", "PM": "", "firstDayOfWeek": 1, "twoDigitYearMax": 2029, "mdy": "dmy", "M/d/yyyy": "dd/MM/yyyy", "dddd, MMMM dd, yyyy": "dddd d MMMM yyyy", "h:mm tt": "HH:mm", "h:mm:ss tt": "HH:mm:ss", "dddd, MMMM dd, yyyy h:mm:ss tt": "dddd d MMMM yyyy HH:mm:ss", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "d MMMM", "MMMM, yyyy": "MMMM yyyy", "/jan(uary)?/": "janv(.(ier)?)?", "/feb(ruary)?/": "févr(.(ier)?)?", "/mar(ch)?/": "mars", "/apr(il)?/": "avr(.(il)?)?", "/may/": "mai", "/jun(e)?/": "juin", "/jul(y)?/": "juil(.(let)?)?", "/aug(ust)?/": "août", "/sep(t(ember)?)?/": "sept(.(embre)?)?", "/oct(ober)?/": "oct(.(obre)?)?", "/nov(ember)?/": "nov(.(embre)?)?", "/dec(ember)?/": "déc(.(embre)?)?", "/^su(n(day)?)?/": "^di(m(.(anche)?)?)?", "/^mo(n(day)?)?/": "^lu(n(.(di)?)?)?", "/^tu(e(s(day)?)?)?/": "^ma(r(.(di)?)?)?", "/^we(d(nesday)?)?/": "^me(r(.(credi)?)?)?", "/^th(u(r(s(day)?)?)?)?/": "^je(u(.(di)?)?)?", "/^fr(i(day)?)?/": "^ve(n(.(dredi)?)?)?", "/^sa(t(urday)?)?/": "^sa(m(.(edi)?)?)?", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "fr-FR"; ================================================ FILE: src/i18n/fr-LU.js ================================================ /* * DateJS Culture String File * Country Code: fr-LU * Name: French (Luxembourg) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["fr-LU"] = { "name": "fr-LU", "englishName": "French (Luxembourg)", "nativeName": "français (Luxembourg)", "Sunday": "dimanche", "Monday": "lundi", "Tuesday": "mardi", "Wednesday": "mercredi", "Thursday": "jeudi", "Friday": "vendredi", "Saturday": "samedi", "Sun": "dim.", "Mon": "lun.", "Tue": "mar.", "Wed": "mer.", "Thu": "jeu.", "Fri": "ven.", "Sat": "sam.", "Su": "di", "Mo": "lu", "Tu": "ma", "We": "me", "Th": "je", "Fr": "ve", "Sa": "sa", "S_Sun_Initial": "d", "M_Mon_Initial": "l", "T_Tue_Initial": "m", "W_Wed_Initial": "m", "T_Thu_Initial": "j", "F_Fri_Initial": "v", "S_Sat_Initial": "s", "January": "janvier", "February": "février", "March": "mars", "April": "avril", "May": "mai", "June": "juin", "July": "juillet", "August": "août", "September": "septembre", "October": "octobre", "November": "novembre", "December": "décembre", "Jan_Abbr": "janv.", "Feb_Abbr": "févr.", "Mar_Abbr": "mars", "Apr_Abbr": "avr.", "May_Abbr": "mai", "Jun_Abbr": "juin", "Jul_Abbr": "juil.", "Aug_Abbr": "août", "Sep_Abbr": "sept.", "Oct_Abbr": "oct.", "Nov_Abbr": "nov.", "Dec_Abbr": "déc.", "AM": "", "PM": "", "firstDayOfWeek": 1, "twoDigitYearMax": 2029, "mdy": "dmy", "M/d/yyyy": "dd/MM/yyyy", "dddd, MMMM dd, yyyy": "dddd d MMMM yyyy", "h:mm tt": "HH:mm", "h:mm:ss tt": "HH:mm:ss", "dddd, MMMM dd, yyyy h:mm:ss tt": "dddd d MMMM yyyy HH:mm:ss", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "d MMMM", "MMMM, yyyy": "MMMM yyyy", "/jan(uary)?/": "janv(.(ier)?)?", "/feb(ruary)?/": "févr(.(ier)?)?", "/mar(ch)?/": "mars", "/apr(il)?/": "avr(.(il)?)?", "/may/": "mai", "/jun(e)?/": "juin", "/jul(y)?/": "juil(.(let)?)?", "/aug(ust)?/": "août", "/sep(t(ember)?)?/": "sept(.(embre)?)?", "/oct(ober)?/": "oct(.(obre)?)?", "/nov(ember)?/": "nov(.(embre)?)?", "/dec(ember)?/": "déc(.(embre)?)?", "/^su(n(day)?)?/": "^di(m(.(anche)?)?)?", "/^mo(n(day)?)?/": "^lu(n(.(di)?)?)?", "/^tu(e(s(day)?)?)?/": "^ma(r(.(di)?)?)?", "/^we(d(nesday)?)?/": "^me(r(.(credi)?)?)?", "/^th(u(r(s(day)?)?)?)?/": "^je(u(.(di)?)?)?", "/^fr(i(day)?)?/": "^ve(n(.(dredi)?)?)?", "/^sa(t(urday)?)?/": "^sa(m(.(edi)?)?)?", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "fr-LU"; ================================================ FILE: src/i18n/fr-MC.js ================================================ /* * DateJS Culture String File * Country Code: fr-MC * Name: French (Principality of Monaco) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["fr-MC"] = { "name": "fr-MC", "englishName": "French (Principality of Monaco)", "nativeName": "français (Principauté de Monaco)", "Sunday": "dimanche", "Monday": "lundi", "Tuesday": "mardi", "Wednesday": "mercredi", "Thursday": "jeudi", "Friday": "vendredi", "Saturday": "samedi", "Sun": "dim.", "Mon": "lun.", "Tue": "mar.", "Wed": "mer.", "Thu": "jeu.", "Fri": "ven.", "Sat": "sam.", "Su": "di", "Mo": "lu", "Tu": "ma", "We": "me", "Th": "je", "Fr": "ve", "Sa": "sa", "S_Sun_Initial": "d", "M_Mon_Initial": "l", "T_Tue_Initial": "m", "W_Wed_Initial": "m", "T_Thu_Initial": "j", "F_Fri_Initial": "v", "S_Sat_Initial": "s", "January": "janvier", "February": "février", "March": "mars", "April": "avril", "May": "mai", "June": "juin", "July": "juillet", "August": "août", "September": "septembre", "October": "octobre", "November": "novembre", "December": "décembre", "Jan_Abbr": "janv.", "Feb_Abbr": "févr.", "Mar_Abbr": "mars", "Apr_Abbr": "avr.", "May_Abbr": "mai", "Jun_Abbr": "juin", "Jul_Abbr": "juil.", "Aug_Abbr": "août", "Sep_Abbr": "sept.", "Oct_Abbr": "oct.", "Nov_Abbr": "nov.", "Dec_Abbr": "déc.", "AM": "", "PM": "", "firstDayOfWeek": 1, "twoDigitYearMax": 2029, "mdy": "dmy", "M/d/yyyy": "dd/MM/yyyy", "dddd, MMMM dd, yyyy": "dddd d MMMM yyyy", "h:mm tt": "HH:mm", "h:mm:ss tt": "HH:mm:ss", "dddd, MMMM dd, yyyy h:mm:ss tt": "dddd d MMMM yyyy HH:mm:ss", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "d MMMM", "MMMM, yyyy": "MMMM yyyy", "/jan(uary)?/": "janv(.(ier)?)?", "/feb(ruary)?/": "févr(.(ier)?)?", "/mar(ch)?/": "mars", "/apr(il)?/": "avr(.(il)?)?", "/may/": "mai", "/jun(e)?/": "juin", "/jul(y)?/": "juil(.(let)?)?", "/aug(ust)?/": "août", "/sep(t(ember)?)?/": "sept(.(embre)?)?", "/oct(ober)?/": "oct(.(obre)?)?", "/nov(ember)?/": "nov(.(embre)?)?", "/dec(ember)?/": "déc(.(embre)?)?", "/^su(n(day)?)?/": "^di(m(.(anche)?)?)?", "/^mo(n(day)?)?/": "^lu(n(.(di)?)?)?", "/^tu(e(s(day)?)?)?/": "^ma(r(.(di)?)?)?", "/^we(d(nesday)?)?/": "^me(r(.(credi)?)?)?", "/^th(u(r(s(day)?)?)?)?/": "^je(u(.(di)?)?)?", "/^fr(i(day)?)?/": "^ve(n(.(dredi)?)?)?", "/^sa(t(urday)?)?/": "^sa(m(.(edi)?)?)?", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "fr-MC"; ================================================ FILE: src/i18n/gl-ES.js ================================================ /* * DateJS Culture String File * Country Code: gl-ES * Name: Galician (Galician) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["gl-ES"] = { "name": "gl-ES", "englishName": "Galician (Galician)", "nativeName": "galego (galego)", "Sunday": "domingo", "Monday": "luns", "Tuesday": "martes", "Wednesday": "mércores", "Thursday": "xoves", "Friday": "venres", "Saturday": "sábado", "Sun": "dom", "Mon": "luns", "Tue": "mar", "Wed": "mér", "Thu": "xov", "Fri": "ven", "Sat": "sab", "Su": "do", "Mo": "lu", "Tu": "ma", "We": "mé", "Th": "xo", "Fr": "ve", "Sa": "sa", "S_Sun_Initial": "d", "M_Mon_Initial": "l", "T_Tue_Initial": "m", "W_Wed_Initial": "m", "T_Thu_Initial": "x", "F_Fri_Initial": "v", "S_Sat_Initial": "s", "January": "xaneiro", "February": "febreiro", "March": "marzo", "April": "abril", "May": "maio", "June": "xuño", "July": "xullo", "August": "agosto", "September": "setembro", "October": "outubro", "November": "novembro", "December": "decembro", "Jan_Abbr": "xan", "Feb_Abbr": "feb", "Mar_Abbr": "mar", "Apr_Abbr": "abr", "May_Abbr": "maio", "Jun_Abbr": "xuñ", "Jul_Abbr": "xull", "Aug_Abbr": "ago", "Sep_Abbr": "set", "Oct_Abbr": "out", "Nov_Abbr": "nov", "Dec_Abbr": "dec", "AM": "a.m.", "PM": "p.m.", "firstDayOfWeek": 1, "twoDigitYearMax": 2029, "mdy": "dmy", "M/d/yyyy": "dd/MM/yy", "dddd, MMMM dd, yyyy": "dddd, dd' de 'MMMM' de 'yyyy", "h:mm tt": "H:mm", "h:mm:ss tt": "H:mm:ss", "dddd, MMMM dd, yyyy h:mm:ss tt": "dddd, dd' de 'MMMM' de 'yyyy H:mm:ss", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "dd MMMM", "MMMM, yyyy": "MMMM' de 'yyyy", "/jan(uary)?/": "xan(eiro)?", "/feb(ruary)?/": "feb(reiro)?", "/mar(ch)?/": "mar(zo)?", "/apr(il)?/": "abr(il)?", "/may/": "maio", "/jun(e)?/": "xuñ(o)?", "/jul(y)?/": "xull(o)?", "/aug(ust)?/": "ago(sto)?", "/sep(t(ember)?)?/": "set(embro)?", "/oct(ober)?/": "out(ubro)?", "/nov(ember)?/": "nov(embro)?", "/dec(ember)?/": "dec(embro)?", "/^su(n(day)?)?/": "^do(m(ingo)?)?", "/^mo(n(day)?)?/": "^lu(1)?", "/^tu(e(s(day)?)?)?/": "^ma(r(tes)?)?", "/^we(d(nesday)?)?/": "^mé(r(cores)?)?", "/^th(u(r(s(day)?)?)?)?/": "^xo(v(es)?)?", "/^fr(i(day)?)?/": "^ve(n(res)?)?", "/^sa(t(urday)?)?/": "^sa(b(ado)?)?", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "gl-ES"; ================================================ FILE: src/i18n/gu-IN.js ================================================ /* * DateJS Culture String File * Country Code: gu-IN * Name: Gujarati (India) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["gu-IN"] = { "name": "gu-IN", "englishName": "Gujarati (India)", "nativeName": "ગુજરાતી (ભારત)", "Sunday": "રવિવાર", "Monday": "સોમવાર", "Tuesday": "મંગળવાર", "Wednesday": "બુધવાર", "Thursday": "ગુરુવાર", "Friday": "શુક્રવાર", "Saturday": "શનિવાર", "Sun": "રવિ", "Mon": "સોમ", "Tue": "મંગળ", "Wed": "બુધ", "Thu": "ગુરુ", "Fri": "શુક્ર", "Sat": "શનિ", "Su": "ર", "Mo": "સ", "Tu": "મ", "We": "બ", "Th": "ગ", "Fr": "શ", "Sa": "શ", "S_Sun_Initial": "ર", "M_Mon_Initial": "સ", "T_Tue_Initial": "મ", "W_Wed_Initial": "બ", "T_Thu_Initial": "ગ", "F_Fri_Initial": "શ", "S_Sat_Initial": "શ", "January": "જાન્યુઆરી", "February": "ફેબ્રુઆરી", "March": "માર્ચ", "April": "એપ્રિલ", "May": "મે", "June": "જૂન", "July": "જુલાઈ", "August": "ઑગસ્ટ", "September": "સપ્ટેમ્બર", "October": "ઑક્ટ્બર", "November": "નવેમ્બર", "December": "ડિસેમ્બર", "Jan_Abbr": "જાન્યુ", "Feb_Abbr": "ફેબ્રુ", "Mar_Abbr": "માર્ચ", "Apr_Abbr": "એપ્રિલ", "May_Abbr": "મે", "Jun_Abbr": "જૂન", "Jul_Abbr": "જુલાઈ", "Aug_Abbr": "ઑગસ્ટ", "Sep_Abbr": "સપ્ટે", "Oct_Abbr": "ઑક્ટો", "Nov_Abbr": "નવે", "Dec_Abbr": "ડિસે", "AM": "પૂર્વ મધ્યાહ્ન", "PM": "ઉત્તર મધ્યાહ્ન", "firstDayOfWeek": 1, "twoDigitYearMax": 2029, "mdy": "dmy", "M/d/yyyy": "dd-MM-yy", "dddd, MMMM dd, yyyy": "dd MMMM yyyy", "h:mm tt": "HH:mm", "h:mm:ss tt": "HH:mm:ss", "dddd, MMMM dd, yyyy h:mm:ss tt": "dd MMMM yyyy HH:mm:ss", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "dd MMMM", "MMMM, yyyy": "MMMM, yyyy", "/jan(uary)?/": "જાન્યુ(આરી)?", "/feb(ruary)?/": "ફેબ્રુ(આરી)?", "/mar(ch)?/": "માર્ચ", "/apr(il)?/": "એપ્રિલ", "/may/": "મે", "/jun(e)?/": "જૂન", "/jul(y)?/": "જુલાઈ", "/aug(ust)?/": "ઑગસ્ટ", "/sep(t(ember)?)?/": "સપ્ટે(મ્બર)?", "/oct(ober)?/": "ઑક્ટ્બર", "/nov(ember)?/": "નવે(મ્બર)?", "/dec(ember)?/": "ડિસે(મ્બર)?", "/^su(n(day)?)?/": "^ર(વિ(વાર)?)?", "/^mo(n(day)?)?/": "^સ(ોમ(વાર)?)?", "/^tu(e(s(day)?)?)?/": "^મ(ંગળ(વાર)?)?", "/^we(d(nesday)?)?/": "^બ(ુધ(વાર)?)?", "/^th(u(r(s(day)?)?)?)?/": "^ગ(ુરુ(વાર)?)?", "/^fr(i(day)?)?/": "^શ(ુક્ર(વાર)?)?", "/^sa(t(urday)?)?/": "^શ(નિ(વાર)?)?", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "gu-IN"; ================================================ FILE: src/i18n/he-IL.js ================================================ /* * DateJS Culture String File * Country Code: he-IL * Name: Hebrew (Israel) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["he-IL"] = { "name": "he-IL", "englishName": "Hebrew (Israel)", "nativeName": "עברית (ישראל)", "Sunday": "יום ראשון", "Monday": "יום שני", "Tuesday": "יום שלישי", "Wednesday": "יום רביעי", "Thursday": "יום חמישי", "Friday": "יום שישי", "Saturday": "שבת", "Sun": "יום א", "Mon": "יום ב", "Tue": "יום ג", "Wed": "יום ד", "Thu": "יום ה", "Fri": "יום ו", "Sat": "שבת", "Su": "א", "Mo": "ב", "Tu": "ג", "We": "ד", "Th": "ה", "Fr": "ו", "Sa": "ש", "S_Sun_Initial": "א", "M_Mon_Initial": "ב", "T_Tue_Initial": "ג", "W_Wed_Initial": "ד", "T_Thu_Initial": "ה", "F_Fri_Initial": "ו", "S_Sat_Initial": "ש", "January": "ינואר", "February": "פברואר", "March": "מרץ", "April": "אפריל", "May": "מאי", "June": "יוני", "July": "יולי", "August": "אוגוסט", "September": "ספטמבר", "October": "אוקטובר", "November": "נובמבר", "December": "דצמבר", "Jan_Abbr": "ינו", "Feb_Abbr": "פבר", "Mar_Abbr": "מרץ", "Apr_Abbr": "אפר", "May_Abbr": "מאי", "Jun_Abbr": "יונ", "Jul_Abbr": "יול", "Aug_Abbr": "אוג", "Sep_Abbr": "ספט", "Oct_Abbr": "אוק", "Nov_Abbr": "נוב", "Dec_Abbr": "דצמ", "AM": "AM", "PM": "PM", "firstDayOfWeek": 0, "twoDigitYearMax": 2029, "mdy": "dmy", "M/d/yyyy": "dd/MM/yyyy", "dddd, MMMM dd, yyyy": "dddd dd MMMM yyyy", "h:mm tt": "HH:mm", "h:mm:ss tt": "HH:mm:ss", "dddd, MMMM dd, yyyy h:mm:ss tt": "dddd dd MMMM yyyy HH:mm:ss", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "dd MMMM", "MMMM, yyyy": "MMMM yyyy", "/jan(uary)?/": "ינו(אר)?", "/feb(ruary)?/": "פבר(ואר)?", "/mar(ch)?/": "מרץ", "/apr(il)?/": "אפר(יל)?", "/may/": "מאי", "/jun(e)?/": "יונ(י)?", "/jul(y)?/": "יול(י)?", "/aug(ust)?/": "אוג(וסט)?", "/sep(t(ember)?)?/": "ספט(מבר)?", "/oct(ober)?/": "אוק(טובר)?", "/nov(ember)?/": "נוב(מבר)?", "/dec(ember)?/": "דצמ(בר)?", "/^su(n(day)?)?/": "^א(ום א(אשון)?)?", "/^mo(n(day)?)?/": "^ב(ום ב(ני)?)?", "/^tu(e(s(day)?)?)?/": "^ג(ום ג(לישי)?)?", "/^we(d(nesday)?)?/": "^ד(ום ד(ביעי)?)?", "/^th(u(r(s(day)?)?)?)?/": "^ה(ום ה(מישי)?)?", "/^fr(i(day)?)?/": "^ו(ום ו(ישי)?)?", "/^sa(t(urday)?)?/": "^ש(1)?", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "he-IL"; ================================================ FILE: src/i18n/hi-IN.js ================================================ /* * DateJS Culture String File * Country Code: hi-IN * Name: Hindi (India) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["hi-IN"] = { "name": "hi-IN", "englishName": "Hindi (India)", "nativeName": "हिंदी (भारत)", "Sunday": "रविवार", "Monday": "सोमवार", "Tuesday": "मंगलवार", "Wednesday": "बुधवार", "Thursday": "गुरुवार", "Friday": "शुक्रवार", "Saturday": "शनिवार", "Sun": "रवि.", "Mon": "सोम.", "Tue": "मंगल.", "Wed": "बुध.", "Thu": "गुरु.", "Fri": "शुक्र.", "Sat": "शनि.", "Su": "र", "Mo": "स", "Tu": "म", "We": "ब", "Th": "ग", "Fr": "श", "Sa": "श", "S_Sun_Initial": "र", "M_Mon_Initial": "स", "T_Tue_Initial": "म", "W_Wed_Initial": "ब", "T_Thu_Initial": "ग", "F_Fri_Initial": "श", "S_Sat_Initial": "श", "January": "जनवरी", "February": "फरवरी", "March": "मार्च", "April": "अप्रैल", "May": "मई", "June": "जून", "July": "जुलाई", "August": "अगस्त", "September": "सितम्बर", "October": "अक्तूबर", "November": "नवम्बर", "December": "दिसम्बर", "Jan_Abbr": "जनवरी", "Feb_Abbr": "फरवरी", "Mar_Abbr": "मार्च", "Apr_Abbr": "अप्रैल", "May_Abbr": "मई", "Jun_Abbr": "जून", "Jul_Abbr": "जुलाई", "Aug_Abbr": "अगस्त", "Sep_Abbr": "सितम्बर", "Oct_Abbr": "अक्तूबर", "Nov_Abbr": "नवम्बर", "Dec_Abbr": "दिसम्बर", "AM": "पूर्वाह्न", "PM": "अपराह्न", "firstDayOfWeek": 1, "twoDigitYearMax": 2029, "mdy": "dmy", "M/d/yyyy": "dd-MM-yyyy", "dddd, MMMM dd, yyyy": "dd MMMM yyyy", "h:mm tt": "HH:mm", "h:mm:ss tt": "HH:mm:ss", "dddd, MMMM dd, yyyy h:mm:ss tt": "dd MMMM yyyy HH:mm:ss", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "dd MMMM", "MMMM, yyyy": "MMMM, yyyy", "/jan(uary)?/": "जनवरी", "/feb(ruary)?/": "फरवरी", "/mar(ch)?/": "मार्च", "/apr(il)?/": "अप्रैल", "/may/": "मई", "/jun(e)?/": "जून", "/jul(y)?/": "जुलाई", "/aug(ust)?/": "अगस्त", "/sep(t(ember)?)?/": "सितम्बर", "/oct(ober)?/": "अक्तूबर", "/nov(ember)?/": "नवम्बर", "/dec(ember)?/": "दिसम्बर", "/^su(n(day)?)?/": "^र(वि(.(वार)?)?)?", "/^mo(n(day)?)?/": "^स(ोम(.(वार)?)?)?", "/^tu(e(s(day)?)?)?/": "^म(ंगल(.(वार)?)?)?", "/^we(d(nesday)?)?/": "^ब(ुध(.(वार)?)?)?", "/^th(u(r(s(day)?)?)?)?/": "^ग(ुरु(.(वार)?)?)?", "/^fr(i(day)?)?/": "^श(ुक्र(.(वार)?)?)?", "/^sa(t(urday)?)?/": "^श(नि(.(वार)?)?)?", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "hi-IN"; ================================================ FILE: src/i18n/hr-BA.js ================================================ /* * DateJS Culture String File * Country Code: hr-BA * Name: Croatian (Bosnia and Herzegovina) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["hr-BA"] = { "name": "hr-BA", "englishName": "Croatian (Bosnia and Herzegovina)", "nativeName": "hrvatski (Bosna i Hercegovina)", "Sunday": "nedjelja", "Monday": "ponedjeljak", "Tuesday": "utorak", "Wednesday": "srijeda", "Thursday": "četvrtak", "Friday": "petak", "Saturday": "subota", "Sun": "ned", "Mon": "pon", "Tue": "uto", "Wed": "sri", "Thu": "čet", "Fri": "pet", "Sat": "sub", "Su": "ned", "Mo": "pon", "Tu": "uto", "We": "sri", "Th": "čet", "Fr": "pet", "Sa": "sub", "S_Sun_Initial": "n", "M_Mon_Initial": "p", "T_Tue_Initial": "u", "W_Wed_Initial": "s", "T_Thu_Initial": "č", "F_Fri_Initial": "p", "S_Sat_Initial": "s", "January": "siječanj", "February": "veljača", "March": "ožujak", "April": "travanj", "May": "svibanj", "June": "lipanj", "July": "srpanj", "August": "kolovoz", "September": "rujan", "October": "listopad", "November": "studeni", "December": "prosinac", "Jan_Abbr": "sij", "Feb_Abbr": "vlj", "Mar_Abbr": "ožu", "Apr_Abbr": "tra", "May_Abbr": "svi", "Jun_Abbr": "lip", "Jul_Abbr": "srp", "Aug_Abbr": "kol", "Sep_Abbr": "ruj", "Oct_Abbr": "lis", "Nov_Abbr": "stu", "Dec_Abbr": "pro", "AM": "", "PM": "", "firstDayOfWeek": 1, "twoDigitYearMax": 2029, "mdy": "dmy", "M/d/yyyy": "d.M.yyyy", "dddd, MMMM dd, yyyy": "d. MMMM yyyy", "h:mm tt": "H:mm:ss", "h:mm:ss tt": "H:mm:ss", "dddd, MMMM dd, yyyy h:mm:ss tt": "d. MMMM yyyy H:mm:ss", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "MMMM dd", "MMMM, yyyy": "MMMM, yyyy", "/jan(uary)?/": "sij(ečanj)?", "/feb(ruary)?/": "veljača", "/mar(ch)?/": "ožu(jak)?", "/apr(il)?/": "tra(vanj)?", "/may/": "svi(banj)?", "/jun(e)?/": "lip(anj)?", "/jul(y)?/": "srp(anj)?", "/aug(ust)?/": "kol(ovoz)?", "/sep(t(ember)?)?/": "ruj(an)?", "/oct(ober)?/": "lis(topad)?", "/nov(ember)?/": "stu(deni)?", "/dec(ember)?/": "pro(sinac)?", "/^su(n(day)?)?/": "^nedjelja", "/^mo(n(day)?)?/": "^ponedjeljak", "/^tu(e(s(day)?)?)?/": "^utorak", "/^we(d(nesday)?)?/": "^srijeda", "/^th(u(r(s(day)?)?)?)?/": "^četvrtak", "/^fr(i(day)?)?/": "^petak", "/^sa(t(urday)?)?/": "^subota", "/^next/": "^slijedeć(i|e|eg)", "/^last|past|prev(ious)?/": "^zadnji|posljednji|prethodni", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|pos(lije)?|od|odsad(a)?)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|pr(ije)?pred)", "/^yes(terday)?/": "^jučer", "/^t(od(ay)?)?/": "^danas", "/^tom(orrow)?/": "^sutra", "/^n(ow)?/": "^sad(a)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sek(und(a|e|i)?)?", "/^mn|min(ute)?s?/": "^mn|min(ut(a|e|i)?)?", "/^h(our)?s?/": "^s(at(a|i)?)?", "/^w(eek)?s?/": "^tj(edan(a|i)?)?", "/^m(onth)?s?/": "^mj(esec(a|i)?)?", "/^d(ay)?s?/": "^dan(a|i)?", "/^y(ear)?s?/": "^god(in(a|e|i|u))?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "hr-BA"; ================================================ FILE: src/i18n/hr-HR.js ================================================ /* * DateJS Culture String File * Country Code: hr-HR * Name: Croatian (Croatia) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["hr-HR"] = { "name": "hr-HR", "englishName": "Croatian (Croatia)", "nativeName": "hrvatski (Hrvatska)", "Sunday": "nedjelja", "Monday": "ponedjeljak", "Tuesday": "utorak", "Wednesday": "srijeda", "Thursday": "četvrtak", "Friday": "petak", "Saturday": "subota", "Sun": "ned", "Mon": "pon", "Tue": "uto", "Wed": "sri", "Thu": "čet", "Fri": "pet", "Sat": "sub", "Su": "ne", "Mo": "po", "Tu": "ut", "We": "sr", "Th": "če", "Fr": "pe", "Sa": "su", "S_Sun_Initial": "n", "M_Mon_Initial": "p", "T_Tue_Initial": "u", "W_Wed_Initial": "s", "T_Thu_Initial": "č", "F_Fri_Initial": "p", "S_Sat_Initial": "s", "January": "siječanj", "February": "veljača", "March": "ožujak", "April": "travanj", "May": "svibanj", "June": "lipanj", "July": "srpanj", "August": "kolovoz", "September": "rujan", "October": "listopad", "November": "studeni", "December": "prosinac", "Jan_Abbr": "sij", "Feb_Abbr": "vlj", "Mar_Abbr": "ožu", "Apr_Abbr": "tra", "May_Abbr": "svi", "Jun_Abbr": "lip", "Jul_Abbr": "srp", "Aug_Abbr": "kol", "Sep_Abbr": "ruj", "Oct_Abbr": "lis", "Nov_Abbr": "stu", "Dec_Abbr": "pro", "AM": "", "PM": "", "firstDayOfWeek": 1, "twoDigitYearMax": 2029, "mdy": "dmy", "M/d/yyyy": "d.M.yyyy", "dddd, MMMM dd, yyyy": "d. MMMM yyyy", "h:mm tt": "H:mm", "h:mm:ss tt": "H:mm:ss", "dddd, MMMM dd, yyyy h:mm:ss tt": "d. MMMM yyyy H:mm:ss", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "d. MMMM", "MMMM, yyyy": "MMMM, yyyy", "/jan(uary)?/": "sij(ečanj)?", "/feb(ruary)?/": "veljača", "/mar(ch)?/": "ožu(jak)?", "/apr(il)?/": "tra(vanj)?", "/may/": "svi(banj)?", "/jun(e)?/": "lip(anj)?", "/jul(y)?/": "srp(anj)?", "/aug(ust)?/": "kol(ovoz)?", "/sep(t(ember)?)?/": "ruj(an)?", "/oct(ober)?/": "lis(topad)?", "/nov(ember)?/": "stu(deni)?", "/dec(ember)?/": "pro(sinac)?", "/^su(n(day)?)?/": "^ne(d(jelja)?)?", "/^mo(n(day)?)?/": "^po(n(edjeljak)?)?", "/^tu(e(s(day)?)?)?/": "^ut(o(rak)?)?", "/^we(d(nesday)?)?/": "^sr(i(jeda)?)?", "/^th(u(r(s(day)?)?)?)?/": "^če(t(vrtak)?)?", "/^fr(i(day)?)?/": "^pe(t(ak)?)?", "/^sa(t(urday)?)?/": "^su(b(ota)?)?", "/^next/": "^slijedeć(i|e|eg)", "/^last|past|prev(ious)?/": "^zadnji|posljednji|prethodni", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|pos(lije)?|od|odsad(a)?)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|pr(ije)?pred)", "/^yes(terday)?/": "^jučer", "/^t(od(ay)?)?/": "^danas", "/^tom(orrow)?/": "^sutra", "/^n(ow)?/": "^sad(a)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sek(und(a|e|i)?)?", "/^mn|min(ute)?s?/": "^mn|min(ut(a|e|i)?)?", "/^h(our)?s?/": "^s(at(a|i)?)?", "/^w(eek)?s?/": "^tj(edan(a|i)?)?", "/^m(onth)?s?/": "^mj(esec(a|i)?)?", "/^d(ay)?s?/": "^dan(a|i)?", "/^y(ear)?s?/": "^god(in(a|e|i|u))?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "hr-HR"; ================================================ FILE: src/i18n/hu-HU.js ================================================ /* * DateJS Culture String File * Country Code: hu-HU * Name: Hungarian (Hungary) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["hu-HU"] = { "name": "hu-HU", "englishName": "Hungarian (Hungary)", "nativeName": "magyar (Magyarország)", "Sunday": "vasárnap", "Monday": "hétfő", "Tuesday": "kedd", "Wednesday": "szerda", "Thursday": "csütörtök", "Friday": "péntek", "Saturday": "szombat", "Sun": "V", "Mon": "H", "Tue": "K", "Wed": "Sze", "Thu": "Cs", "Fri": "P", "Sat": "Szo", "Su": "V", "Mo": "H", "Tu": "K", "We": "Sze", "Th": "Cs", "Fr": "P", "Sa": "Szo", "S_Sun_Initial": "V", "M_Mon_Initial": "H", "T_Tue_Initial": "K", "W_Wed_Initial": "S", "T_Thu_Initial": "C", "F_Fri_Initial": "P", "S_Sat_Initial": "S", "January": "január", "February": "február", "March": "március", "April": "április", "May": "május", "June": "június", "July": "július", "August": "augusztus", "September": "szeptember", "October": "október", "November": "november", "December": "december", "Jan_Abbr": "jan.", "Feb_Abbr": "febr.", "Mar_Abbr": "márc.", "Apr_Abbr": "ápr.", "May_Abbr": "máj.", "Jun_Abbr": "jún.", "Jul_Abbr": "júl.", "Aug_Abbr": "aug.", "Sep_Abbr": "szept.", "Oct_Abbr": "okt.", "Nov_Abbr": "nov.", "Dec_Abbr": "dec.", "AM": "de.", "PM": "du.", "firstDayOfWeek": 1, "twoDigitYearMax": 2029, "mdy": "ymd", "M/d/yyyy": "yyyy. MM. dd.", "dddd, MMMM dd, yyyy": "yyyy. MMMM d.", "h:mm tt": "H:mm", "h:mm:ss tt": "H:mm:ss", "dddd, MMMM dd, yyyy h:mm:ss tt": "yyyy. MMMM d. H:mm:ss", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "MMMM d.", "MMMM, yyyy": "yyyy. MMMM", "/jan(uary)?/": "jan(.(uár)?)?", "/feb(ruary)?/": "febr(.(uár)?)?", "/mar(ch)?/": "márc(.(ius)?)?", "/apr(il)?/": "ápr(.(ilis)?)?", "/may/": "máj(.(us)?)?", "/jun(e)?/": "jún(.(ius)?)?", "/jul(y)?/": "júl(.(ius)?)?", "/aug(ust)?/": "aug(.(usztus)?)?", "/sep(t(ember)?)?/": "szept(.(ember)?)?", "/oct(ober)?/": "okt(.(óber)?)?", "/nov(ember)?/": "nov(.(ember)?)?", "/dec(ember)?/": "dec(.(ember)?)?", "/^su(n(day)?)?/": "^vasárnap", "/^mo(n(day)?)?/": "^hétfő", "/^tu(e(s(day)?)?)?/": "^kedd", "/^we(d(nesday)?)?/": "^szerda", "/^th(u(r(s(day)?)?)?)?/": "^csütörtök", "/^fr(i(day)?)?/": "^péntek", "/^sa(t(urday)?)?/": "^szombat", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "hu-HU"; ================================================ FILE: src/i18n/hy-AM.js ================================================ /* * DateJS Culture String File * Country Code: hy-AM * Name: Armenian (Armenia) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["hy-AM"] = { "name": "hy-AM", "englishName": "Armenian (Armenia)", "nativeName": "Հայերեն (Հայաստան)", "Sunday": "Կիրակի", "Monday": "Երկուշաբթի", "Tuesday": "Երեքշաբթի", "Wednesday": "Չորեքշաբթի", "Thursday": "Հինգշաբթի", "Friday": "ՈՒրբաթ", "Saturday": "Շաբաթ", "Sun": "Կիր", "Mon": "Երկ", "Tue": "Երք", "Wed": "Չրք", "Thu": "Հնգ", "Fri": "ՈՒր", "Sat": "Շբթ", "Su": "Կ", "Mo": "Ե", "Tu": "Ե", "We": "Չ", "Th": "Հ", "Fr": "Ո", "Sa": "Շ", "S_Sun_Initial": "Կ", "M_Mon_Initial": "Ե", "T_Tue_Initial": "Ե", "W_Wed_Initial": "Չ", "T_Thu_Initial": "Հ", "F_Fri_Initial": "Ո", "S_Sat_Initial": "Շ", "January": "Հունվար", "February": "Փետրվար", "March": "Մարտ", "April": "Ապրիլ", "May": "Մայիս", "June": "Հունիս", "July": "Հուլիս", "August": "Օգոստոս", "September": "Սեպտեմբեր", "October": "Հոկտեմբեր", "November": "Նոյեմբեր", "December": "Դեկտեմբեր", "Jan_Abbr": "ՀՆՎ", "Feb_Abbr": "ՓՏՎ", "Mar_Abbr": "ՄՐՏ", "Apr_Abbr": "ԱՊՐ", "May_Abbr": "ՄՅՍ", "Jun_Abbr": "ՀՆՍ", "Jul_Abbr": "ՀԼՍ", "Aug_Abbr": "ՕԳՍ", "Sep_Abbr": "ՍԵՊ", "Oct_Abbr": "ՀՈԿ", "Nov_Abbr": "ՆՈՅ", "Dec_Abbr": "ԴԵԿ", "AM": "", "PM": "", "firstDayOfWeek": 1, "twoDigitYearMax": 2029, "mdy": "dmy", "M/d/yyyy": "dd.MM.yyyy", "dddd, MMMM dd, yyyy": "d MMMM, yyyy", "h:mm tt": "H:mm", "h:mm:ss tt": "H:mm:ss", "dddd, MMMM dd, yyyy h:mm:ss tt": "d MMMM, yyyy H:mm:ss", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "d MMMM", "MMMM, yyyy": "MMMM, yyyy", "/jan(uary)?/": "հունվար", "/feb(ruary)?/": "փետրվար", "/mar(ch)?/": "մարտ", "/apr(il)?/": "ապր(իլ)?", "/may/": "մայիս", "/jun(e)?/": "հունիս", "/jul(y)?/": "հուլիս", "/aug(ust)?/": "օգոստոս", "/sep(t(ember)?)?/": "սեպ(տեմբեր)?", "/oct(ober)?/": "հոկ(տեմբեր)?", "/nov(ember)?/": "նոյ(եմբեր)?", "/dec(ember)?/": "դեկ(տեմբեր)?", "/^su(n(day)?)?/": "^կ(իր(ակի)?)?", "/^mo(n(day)?)?/": "^ե(րկ(ուշաբթի)?)?", "/^tu(e(s(day)?)?)?/": "^ե(րք(քշաբթի)?)?", "/^we(d(nesday)?)?/": "^չ(րք(եքշաբթի)?)?", "/^th(u(r(s(day)?)?)?)?/": "^հ(նգ(գշաբթի)?)?", "/^fr(i(day)?)?/": "^ո(ւր(բաթ)?)?", "/^sa(t(urday)?)?/": "^շ(բթ(աթ)?)?", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "hy-AM"; ================================================ FILE: src/i18n/id-ID.js ================================================ /* * DateJS Culture String File * Country Code: id-ID * Name: Indonesian (Indonesia) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["id-ID"] = { "name": "id-ID", "englishName": "Indonesian (Indonesia)", "nativeName": "Bahasa Indonesia (Indonesia)", "Sunday": "Minggu", "Monday": "Senin", "Tuesday": "Selasa", "Wednesday": "Rabu", "Thursday": "Kamis", "Friday": "Jumat", "Saturday": "Sabtu", "Sun": "Minggu", "Mon": "Sen", "Tue": "Sel", "Wed": "Rabu", "Thu": "Kamis", "Fri": "Jumat", "Sat": "Sabtu", "Su": "M", "Mo": "S", "Tu": "S", "We": "R", "Th": "K", "Fr": "J", "Sa": "S", "S_Sun_Initial": "M", "M_Mon_Initial": "S", "T_Tue_Initial": "S", "W_Wed_Initial": "R", "T_Thu_Initial": "K", "F_Fri_Initial": "J", "S_Sat_Initial": "S", "January": "Januari", "February": "Februari", "March": "Maret", "April": "April", "May": "Mei", "June": "Juni", "July": "Juli", "August": "Agustus", "September": "September", "October": "Oktober", "November": "Nopember", "December": "Desember", "Jan_Abbr": "Jan", "Feb_Abbr": "Feb", "Mar_Abbr": "Mar", "Apr_Abbr": "Apr", "May_Abbr": "Mei", "Jun_Abbr": "Jun", "Jul_Abbr": "Jul", "Aug_Abbr": "Agust", "Sep_Abbr": "Sep", "Oct_Abbr": "Okt", "Nov_Abbr": "Nop", "Dec_Abbr": "Des", "AM": "", "PM": "", "firstDayOfWeek": 1, "twoDigitYearMax": 2029, "mdy": "dmy", "M/d/yyyy": "dd/MM/yyyy", "dddd, MMMM dd, yyyy": "dd MMMM yyyy", "h:mm tt": "H:mm", "h:mm:ss tt": "H:mm:ss", "dddd, MMMM dd, yyyy h:mm:ss tt": "dd MMMM yyyy H:mm:ss", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "dd MMMM", "MMMM, yyyy": "MMMM yyyy", "/jan(uary)?/": "jan(uari)?", "/feb(ruary)?/": "feb(ruari)?", "/mar(ch)?/": "mar(et)?", "/apr(il)?/": "apr(il)?", "/may/": "mei", "/jun(e)?/": "jun(i)?", "/jul(y)?/": "jul(i)?", "/aug(ust)?/": "agust(us)?", "/sep(t(ember)?)?/": "sep(t(ember)?)?", "/oct(ober)?/": "okt(ober)?", "/nov(ember)?/": "nop(ember)?", "/dec(ember)?/": "des(ember)?", "/^su(n(day)?)?/": "^m(1)?", "/^mo(n(day)?)?/": "^s(en(in)?)?", "/^tu(e(s(day)?)?)?/": "^s(el(asa)?)?", "/^we(d(nesday)?)?/": "^r(1)?", "/^th(u(r(s(day)?)?)?)?/": "^k(1)?", "/^fr(i(day)?)?/": "^j(1)?", "/^sa(t(urday)?)?/": "^s(1)?", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "id-ID"; ================================================ FILE: src/i18n/is-IS.js ================================================ /* * DateJS Culture String File * Country Code: is-IS * Name: Icelandic (Iceland) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["is-IS"] = { "name": "is-IS", "englishName": "Icelandic (Iceland)", "nativeName": "íslenska (Ísland)", "Sunday": "sunnudagur", "Monday": "mánudagur", "Tuesday": "þriðjudagur", "Wednesday": "miðvikudagur", "Thursday": "fimmtudagur", "Friday": "föstudagur", "Saturday": "laugardagur", "Sun": "sun.", "Mon": "mán.", "Tue": "þri.", "Wed": "mið.", "Thu": "fim.", "Fri": "fös.", "Sat": "lau.", "Su": "su", "Mo": "má", "Tu": "þr", "We": "mi", "Th": "fi", "Fr": "fö", "Sa": "la", "S_Sun_Initial": "s", "M_Mon_Initial": "m", "T_Tue_Initial": "þ", "W_Wed_Initial": "m", "T_Thu_Initial": "f", "F_Fri_Initial": "f", "S_Sat_Initial": "l", "January": "janúar", "February": "febrúar", "March": "mars", "April": "apríl", "May": "maí", "June": "júní", "July": "júlí", "August": "ágúst", "September": "september", "October": "október", "November": "nóvember", "December": "desember", "Jan_Abbr": "jan.", "Feb_Abbr": "feb.", "Mar_Abbr": "mar.", "Apr_Abbr": "apr.", "May_Abbr": "maí", "Jun_Abbr": "jún.", "Jul_Abbr": "júl.", "Aug_Abbr": "ágú.", "Sep_Abbr": "sep.", "Oct_Abbr": "okt.", "Nov_Abbr": "nóv.", "Dec_Abbr": "des.", "AM": "", "PM": "", "firstDayOfWeek": 1, "twoDigitYearMax": 2029, "mdy": "dmy", "M/d/yyyy": "d.M.yyyy", "dddd, MMMM dd, yyyy": "d. MMMM yyyy", "h:mm tt": "HH:mm", "h:mm:ss tt": "HH:mm:ss", "dddd, MMMM dd, yyyy h:mm:ss tt": "d. MMMM yyyy HH:mm:ss", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "d. MMMM", "MMMM, yyyy": "MMMM yyyy", "/jan(uary)?/": "jan(.(úar)?)?", "/feb(ruary)?/": "feb(.(rúar)?)?", "/mar(ch)?/": "mar(.(s)?)?", "/apr(il)?/": "apr(.(íl)?)?", "/may/": "maí", "/jun(e)?/": "jún(.(í)?)?", "/jul(y)?/": "júl(.(í)?)?", "/aug(ust)?/": "ágú(.(st)?)?", "/sep(t(ember)?)?/": "sep(t(ember)?)?", "/oct(ober)?/": "okt(.(óber)?)?", "/nov(ember)?/": "nóv(.(ember)?)?", "/dec(ember)?/": "des(.(ember)?)?", "/^su(n(day)?)?/": "^su(n(.(nudagur)?)?)?", "/^mo(n(day)?)?/": "^má(n(.(udagur)?)?)?", "/^tu(e(s(day)?)?)?/": "^þr(i(.(ðjudagur)?)?)?", "/^we(d(nesday)?)?/": "^mi(ð(.(vikudagur)?)?)?", "/^th(u(r(s(day)?)?)?)?/": "^fi(m(.(mtudagur)?)?)?", "/^fr(i(day)?)?/": "^fö(s(.(tudagur)?)?)?", "/^sa(t(urday)?)?/": "^la(u(.(gardagur)?)?)?", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "is-IS"; ================================================ FILE: src/i18n/it-CH.js ================================================ /* * DateJS Culture String File * Country Code: it-CH * Name: Italian (Switzerland) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["it-CH"] = { "name": "it-CH", "englishName": "Italian (Switzerland)", "nativeName": "italiano (Svizzera)", "Sunday": "domenica", "Monday": "lunedì", "Tuesday": "martedì", "Wednesday": "mercoledì", "Thursday": "giovedì", "Friday": "venerdì", "Saturday": "sabato", "Sun": "dom", "Mon": "lun", "Tue": "mar", "Wed": "mer", "Thu": "gio", "Fri": "ven", "Sat": "sab", "Su": "do", "Mo": "lu", "Tu": "ma", "We": "me", "Th": "gi", "Fr": "ve", "Sa": "sa", "S_Sun_Initial": "d", "M_Mon_Initial": "l", "T_Tue_Initial": "m", "W_Wed_Initial": "m", "T_Thu_Initial": "g", "F_Fri_Initial": "v", "S_Sat_Initial": "s", "January": "gennaio", "February": "febbraio", "March": "marzo", "April": "aprile", "May": "maggio", "June": "giugno", "July": "luglio", "August": "agosto", "September": "settembre", "October": "ottobre", "November": "novembre", "December": "dicembre", "Jan_Abbr": "gen", "Feb_Abbr": "feb", "Mar_Abbr": "mar", "Apr_Abbr": "apr", "May_Abbr": "mag", "Jun_Abbr": "gio", "Jul_Abbr": "lug", "Aug_Abbr": "ago", "Sep_Abbr": "set", "Oct_Abbr": "ott", "Nov_Abbr": "nov", "Dec_Abbr": "dic", "AM": "", "PM": "", "firstDayOfWeek": 1, "twoDigitYearMax": 2029, "mdy": "dmy", "M/d/yyyy": "dd.MM.yyyy", "dddd, MMMM dd, yyyy": "dddd, d. MMMM yyyy", "h:mm tt": "HH:mm", "h:mm:ss tt": "HH:mm:ss", "dddd, MMMM dd, yyyy h:mm:ss tt": "dddd, d. MMMM yyyy HH:mm:ss", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "d. MMMM", "MMMM, yyyy": "MMMM yyyy", "/jan(uary)?/": "gen(naio)?", "/feb(ruary)?/": "feb(braio)?", "/mar(ch)?/": "mar(zo)?", "/apr(il)?/": "apr(ile)?", "/may/": "mag(gio)?", "/jun(e)?/": "giugno", "/jul(y)?/": "lug(lio)?", "/aug(ust)?/": "ago(sto)?", "/sep(t(ember)?)?/": "set(tembre)?", "/oct(ober)?/": "ott(obre)?", "/nov(ember)?/": "nov(embre)?", "/dec(ember)?/": "dic(embre)?", "/^su(n(day)?)?/": "^do(m(enica)?)?", "/^mo(n(day)?)?/": "^lu(n(edì)?)?", "/^tu(e(s(day)?)?)?/": "^ma(r(tedì)?)?", "/^we(d(nesday)?)?/": "^me(r(coledì)?)?", "/^th(u(r(s(day)?)?)?)?/": "^gi(o(vedì)?)?", "/^fr(i(day)?)?/": "^ve(n(erdì)?)?", "/^sa(t(urday)?)?/": "^sa(b(ato)?)?", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "it-CH"; ================================================ FILE: src/i18n/it-IT.js ================================================ /* * DateJS Culture String File * Country Code: it-IT * Name: Italian (Italy) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["it-IT"] = { "name": "it-IT", "englishName": "Italian (Italy)", "nativeName": "italiano (Italia)", "Sunday": "domenica", "Monday": "lunedì", "Tuesday": "martedì", "Wednesday": "mercoledì", "Thursday": "giovedì", "Friday": "venerdì", "Saturday": "sabato", "Sun": "dom", "Mon": "lun", "Tue": "mar", "Wed": "mer", "Thu": "gio", "Fri": "ven", "Sat": "sab", "Su": "do", "Mo": "lu", "Tu": "ma", "We": "me", "Th": "gi", "Fr": "ve", "Sa": "sa", "S_Sun_Initial": "d", "M_Mon_Initial": "l", "T_Tue_Initial": "m", "W_Wed_Initial": "m", "T_Thu_Initial": "g", "F_Fri_Initial": "v", "S_Sat_Initial": "s", "January": "gennaio", "February": "febbraio", "March": "marzo", "April": "aprile", "May": "maggio", "June": "giugno", "July": "luglio", "August": "agosto", "September": "settembre", "October": "ottobre", "November": "novembre", "December": "dicembre", "Jan_Abbr": "gen", "Feb_Abbr": "feb", "Mar_Abbr": "mar", "Apr_Abbr": "apr", "May_Abbr": "mag", "Jun_Abbr": "giu", "Jul_Abbr": "lug", "Aug_Abbr": "ago", "Sep_Abbr": "set", "Oct_Abbr": "ott", "Nov_Abbr": "nov", "Dec_Abbr": "dic", "AM": "", "PM": "", "firstDayOfWeek": 1, "twoDigitYearMax": 2029, "mdy": "dmy", "M/d/yyyy": "dd/MM/yyyy", "dddd, MMMM dd, yyyy": "dddd d MMMM yyyy", "h:mm tt": "H.mm", "h:mm:ss tt": "H.mm.ss", "dddd, MMMM dd, yyyy h:mm:ss tt": "dddd d MMMM yyyy H.mm.ss", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "dd MMMM", "MMMM, yyyy": "MMMM yyyy", "/jan(uary)?/": "gen(naio)?", "/feb(ruary)?/": "feb(braio)?", "/mar(ch)?/": "mar(zo)?", "/apr(il)?/": "apr(ile)?", "/may/": "mag(gio)?", "/jun(e)?/": "giu(gno)?", "/jul(y)?/": "lug(lio)?", "/aug(ust)?/": "ago(sto)?", "/sep(t(ember)?)?/": "set(tembre)?", "/oct(ober)?/": "ott(obre)?", "/nov(ember)?/": "nov(embre)?", "/dec(ember)?/": "dic(embre)?", "/^su(n(day)?)?/": "^do(m(enica)?)?", "/^mo(n(day)?)?/": "^lu(n(edì)?)?", "/^tu(e(s(day)?)?)?/": "^ma(r(tedì)?)?", "/^we(d(nesday)?)?/": "^me(r(coledì)?)?", "/^th(u(r(s(day)?)?)?)?/": "^gi(o(vedì)?)?", "/^fr(i(day)?)?/": "^ve(n(erdì)?)?", "/^sa(t(urday)?)?/": "^sa(b(ato)?)?", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "it-IT"; ================================================ FILE: src/i18n/ja-JP.js ================================================ /* * DateJS Culture String File * Country Code: ja-JP * Name: Japanese (Japan) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["ja-JP"] = { "name": "ja-JP", "englishName": "Japanese (Japan)", "nativeName": "日本語 (日本)", "Sunday": "日曜日", "Monday": "月曜日", "Tuesday": "火曜日", "Wednesday": "水曜日", "Thursday": "木曜日", "Friday": "金曜日", "Saturday": "土曜日", "Sun": "日", "Mon": "月", "Tue": "火", "Wed": "水", "Thu": "木", "Fri": "金", "Sat": "土", "Su": "日", "Mo": "月", "Tu": "火", "We": "水", "Th": "木", "Fr": "金", "Sa": "土", "S_Sun_Initial": "日", "M_Mon_Initial": "月", "T_Tue_Initial": "火", "W_Wed_Initial": "水", "T_Thu_Initial": "木", "F_Fri_Initial": "金", "S_Sat_Initial": "土", "January": "1月", "February": "2月", "March": "3月", "April": "4月", "May": "5月", "June": "6月", "July": "7月", "August": "8月", "September": "9月", "October": "10月", "November": "11月", "December": "12月", "Jan_Abbr": "1", "Feb_Abbr": "2", "Mar_Abbr": "3", "Apr_Abbr": "4", "May_Abbr": "5", "Jun_Abbr": "6", "Jul_Abbr": "7", "Aug_Abbr": "8", "Sep_Abbr": "9", "Oct_Abbr": "10", "Nov_Abbr": "11", "Dec_Abbr": "12", "AM": "午前", "PM": "午後", "firstDayOfWeek": 0, "twoDigitYearMax": 2029, "mdy": "ymd", "M/d/yyyy": "yyyy/MM/dd", "dddd, MMMM dd, yyyy": "yyyy'年'M'月'd'日'", "h:mm tt": "H:mm", "h:mm:ss tt": "H:mm:ss", "dddd, MMMM dd, yyyy h:mm:ss tt": "yyyy'年'M'月'd'日' H:mm:ss", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "M'月'd'日'", "MMMM, yyyy": "yyyy'年'M'月'", "/jan(uary)?/": "1(月)?", "/feb(ruary)?/": "2(月)?", "/mar(ch)?/": "3(月)?", "/apr(il)?/": "4(月)?", "/may/": "5(月)?", "/jun(e)?/": "6(月)?", "/jul(y)?/": "7(月)?", "/aug(ust)?/": "8(月)?", "/sep(t(ember)?)?/": "9(月)?", "/oct(ober)?/": "10(月)?", "/nov(ember)?/": "11(月)?", "/dec(ember)?/": "12(月)?", "/^su(n(day)?)?/": "^日曜日", "/^mo(n(day)?)?/": "^月曜日", "/^tu(e(s(day)?)?)?/": "^火曜日", "/^we(d(nesday)?)?/": "^水曜日", "/^th(u(r(s(day)?)?)?)?/": "^木曜日", "/^fr(i(day)?)?/": "^金曜日", "/^sa(t(urday)?)?/": "^土曜日", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "ja-JP"; ================================================ FILE: src/i18n/ka-GE.js ================================================ /* * DateJS Culture String File * Country Code: ka-GE * Name: Georgian (Georgia) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["ka-GE"] = { "name": "ka-GE", "englishName": "Georgian (Georgia)", "nativeName": "ქართული (საქართველო)", "Sunday": "კვირა", "Monday": "ორშაბათი", "Tuesday": "სამშაბათი", "Wednesday": "ოთხშაბათი", "Thursday": "ხუთშაბათი", "Friday": "პარასკევი", "Saturday": "შაბათი", "Sun": "კვირა", "Mon": "ორშაბათი", "Tue": "სამშაბათი", "Wed": "ოთხშაბათი", "Thu": "ხუთშაბათი", "Fri": "პარასკევი", "Sat": "შაბათი", "Su": "კ", "Mo": "ო", "Tu": "ს", "We": "ო", "Th": "ხ", "Fr": "პ", "Sa": "შ", "S_Sun_Initial": "კ", "M_Mon_Initial": "ო", "T_Tue_Initial": "ს", "W_Wed_Initial": "ო", "T_Thu_Initial": "ხ", "F_Fri_Initial": "პ", "S_Sat_Initial": "შ", "January": "იანვარი", "February": "თებერვალი", "March": "მარტი", "April": "აპრილი", "May": "მაისი", "June": "ივნისი", "July": "ივლისი", "August": "აგვისტო", "September": "სექტემბერი", "October": "ოქტომბერი", "November": "ნოემბერი", "December": "დეკემბერი", "Jan_Abbr": "იან", "Feb_Abbr": "თებ", "Mar_Abbr": "მარ", "Apr_Abbr": "აპრ", "May_Abbr": "მაის", "Jun_Abbr": "ივნ", "Jul_Abbr": "ივლ", "Aug_Abbr": "აგვ", "Sep_Abbr": "სექ", "Oct_Abbr": "ოქტ", "Nov_Abbr": "ნოემ", "Dec_Abbr": "დეკ", "AM": "", "PM": "", "firstDayOfWeek": 1, "twoDigitYearMax": 2029, "mdy": "dmy", "M/d/yyyy": "dd.MM.yyyy", "dddd, MMMM dd, yyyy": "yyyy 'წლის' dd MM, dddd", "h:mm tt": "H:mm", "h:mm:ss tt": "H:mm:ss", "dddd, MMMM dd, yyyy h:mm:ss tt": "yyyy 'წლის' dd MM, dddd H:mm:ss", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "dd MM", "MMMM, yyyy": "MMMM yyyy", "/jan(uary)?/": "იან(ვარი)?", "/feb(ruary)?/": "თებ(ერვალი)?", "/mar(ch)?/": "მარ(ტი)?", "/apr(il)?/": "აპრ(ილი)?", "/may/": "მაის(ი)?", "/jun(e)?/": "ივნ(ისი)?", "/jul(y)?/": "ივლ(ისი)?", "/aug(ust)?/": "აგვ(ისტო)?", "/sep(t(ember)?)?/": "სექ(ტემბერი)?", "/oct(ober)?/": "ოქტ(ომბერი)?", "/nov(ember)?/": "ნოემ(ბერი)?", "/dec(ember)?/": "დეკ(ემბერი)?", "/^su(n(day)?)?/": "^კ(1)?", "/^mo(n(day)?)?/": "^ო(1)?", "/^tu(e(s(day)?)?)?/": "^ს(1)?", "/^we(d(nesday)?)?/": "^ო(1)?", "/^th(u(r(s(day)?)?)?)?/": "^ხ(1)?", "/^fr(i(day)?)?/": "^პ(1)?", "/^sa(t(urday)?)?/": "^შ(1)?", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "ka-GE"; ================================================ FILE: src/i18n/kk-KZ.js ================================================ /* * DateJS Culture String File * Country Code: kk-KZ * Name: Kazakh (Kazakhstan) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["kk-KZ"] = { "name": "kk-KZ", "englishName": "Kazakh (Kazakhstan)", "nativeName": "Қазақ (Қазақстан)", "Sunday": "Жексенбі", "Monday": "Дүйсенбі", "Tuesday": "Сейсенбі", "Wednesday": "Сәрсенбі", "Thursday": "Бейсенбі", "Friday": "Жұма", "Saturday": "Сенбі", "Sun": "Жк", "Mon": "Дс", "Tue": "Сс", "Wed": "Ср", "Thu": "Бс", "Fri": "Жм", "Sat": "Сн", "Su": "Жк", "Mo": "Дс", "Tu": "Сс", "We": "Ср", "Th": "Бс", "Fr": "Жм", "Sa": "Сн", "S_Sun_Initial": "Ж", "M_Mon_Initial": "Д", "T_Tue_Initial": "С", "W_Wed_Initial": "С", "T_Thu_Initial": "Б", "F_Fri_Initial": "Ж", "S_Sat_Initial": "С", "January": "қаңтар", "February": "ақпан", "March": "наурыз", "April": "сәуір", "May": "мамыр", "June": "маусым", "July": "шілде", "August": "тамыз", "September": "қыркүйек", "October": "қазан", "November": "қараша", "December": "желтоқсан", "Jan_Abbr": "Қаң", "Feb_Abbr": "Ақп", "Mar_Abbr": "Нау", "Apr_Abbr": "Сәу", "May_Abbr": "Мам", "Jun_Abbr": "Мау", "Jul_Abbr": "Шіл", "Aug_Abbr": "Там", "Sep_Abbr": "Қыр", "Oct_Abbr": "Қаз", "Nov_Abbr": "Қар", "Dec_Abbr": "Жел", "AM": "", "PM": "", "firstDayOfWeek": 1, "twoDigitYearMax": 2029, "mdy": "dmy", "M/d/yyyy": "dd.MM.yyyy", "dddd, MMMM dd, yyyy": "d MMMM yyyy 'ж.'", "h:mm tt": "H:mm", "h:mm:ss tt": "H:mm:ss", "dddd, MMMM dd, yyyy h:mm:ss tt": "d MMMM yyyy 'ж.' H:mm:ss", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "d MMMM", "MMMM, yyyy": "MMMM yyyy", "/jan(uary)?/": "қаң(тар)?", "/feb(ruary)?/": "ақп(ан)?", "/mar(ch)?/": "нау(рыз)?", "/apr(il)?/": "сәу(ір)?", "/may/": "мам(ыр)?", "/jun(e)?/": "мау(сым)?", "/jul(y)?/": "шіл(де)?", "/aug(ust)?/": "там(ыз)?", "/sep(t(ember)?)?/": "қыр(күйек)?", "/oct(ober)?/": "қаз(ан)?", "/nov(ember)?/": "қар(аша)?", "/dec(ember)?/": "жел(тоқсан)?", "/^su(n(day)?)?/": "^жексенбі", "/^mo(n(day)?)?/": "^дүйсенбі", "/^tu(e(s(day)?)?)?/": "^сейсенбі", "/^we(d(nesday)?)?/": "^сәрсенбі", "/^th(u(r(s(day)?)?)?)?/": "^бейсенбі", "/^fr(i(day)?)?/": "^жұма", "/^sa(t(urday)?)?/": "^сенбі", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "kk-KZ"; ================================================ FILE: src/i18n/kn-IN.js ================================================ /* * DateJS Culture String File * Country Code: kn-IN * Name: Kannada (India) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["kn-IN"] = { "name": "kn-IN", "englishName": "Kannada (India)", "nativeName": "ಕನ್ನಡ (ಭಾರತ)", "Sunday": "ಭಾನುವಾರ", "Monday": "ಸೋಮವಾರ", "Tuesday": "ಮಂಗಳವಾರ", "Wednesday": "ಬುಧವಾರ", "Thursday": "ಗುರುವಾರ", "Friday": "ಶುಕ್ರವಾರ", "Saturday": "ಶನಿವಾರ", "Sun": "ಭಾನು.", "Mon": "ಸೋಮ.", "Tue": "ಮಂಗಳ.", "Wed": "ಬುಧ.", "Thu": "ಗುರು.", "Fri": "ಶುಕ್ರ.", "Sat": "ಶನಿ.", "Su": "ರ", "Mo": "ಸ", "Tu": "ಮ", "We": "ಬ", "Th": "ಗ", "Fr": "ಶ", "Sa": "ಶ", "S_Sun_Initial": "ರ", "M_Mon_Initial": "ಸ", "T_Tue_Initial": "ಮ", "W_Wed_Initial": "ಬ", "T_Thu_Initial": "ಗ", "F_Fri_Initial": "ಶ", "S_Sat_Initial": "ಶ", "January": "ಜನವರಿ", "February": "ಫೆಬ್ರವರಿ", "March": "ಮಾರ್ಚ್", "April": "ಎಪ್ರಿಲ್", "May": "ಮೇ", "June": "ಜೂನ್", "July": "ಜುಲೈ", "August": "ಆಗಸ್ಟ್", "September": "ಸೆಪ್ಟಂಬರ್", "October": "ಅಕ್ಟೋಬರ್", "November": "ನವೆಂಬರ್", "December": "ಡಿಸೆಂಬರ್", "Jan_Abbr": "ಜನವರಿ", "Feb_Abbr": "ಫೆಬ್ರವರಿ", "Mar_Abbr": "ಮಾರ್ಚ್", "Apr_Abbr": "ಎಪ್ರಿಲ್", "May_Abbr": "ಮೇ", "Jun_Abbr": "ಜೂನ್", "Jul_Abbr": "ಜುಲೈ", "Aug_Abbr": "ಆಗಸ್ಟ್", "Sep_Abbr": "ಸೆಪ್ಟಂಬರ್", "Oct_Abbr": "ಅಕ್ಟೋಬರ್", "Nov_Abbr": "ನವೆಂಬರ್", "Dec_Abbr": "ಡಿಸೆಂಬರ್", "AM": "ಪೂರ್ವಾಹ್ನ", "PM": "ಅಪರಾಹ್ನ", "firstDayOfWeek": 1, "twoDigitYearMax": 2029, "mdy": "dmy", "M/d/yyyy": "dd-MM-yy", "dddd, MMMM dd, yyyy": "dd MMMM yyyy", "h:mm tt": "HH:mm", "h:mm:ss tt": "HH:mm:ss", "dddd, MMMM dd, yyyy h:mm:ss tt": "dd MMMM yyyy HH:mm:ss", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "dd MMMM", "MMMM, yyyy": "MMMM, yyyy", "/jan(uary)?/": "ಜನವರಿ", "/feb(ruary)?/": "ಫೆಬ್ರವರಿ", "/mar(ch)?/": "ಮಾರ್ಚ್", "/apr(il)?/": "ಎಪ್ರಿಲ್", "/may/": "ಮೇ", "/jun(e)?/": "ಜೂನ್", "/jul(y)?/": "ಜುಲೈ", "/aug(ust)?/": "ಆಗಸ್ಟ್", "/sep(t(ember)?)?/": "ಸೆಪ್ಟಂಬರ್", "/oct(ober)?/": "ಅಕ್ಟೋಬರ್", "/nov(ember)?/": "ನವೆಂಬರ್", "/dec(ember)?/": "ಡಿಸೆಂಬರ್", "/^su(n(day)?)?/": "^ರ(ಾನು(.(ವಾರ)?)?)?", "/^mo(n(day)?)?/": "^ಸ(ೋಮ(.(ವಾರ)?)?)?", "/^tu(e(s(day)?)?)?/": "^ಮ(ಂಗಳ(.(ವಾರ)?)?)?", "/^we(d(nesday)?)?/": "^ಬ(ುಧ(.(ವಾರ)?)?)?", "/^th(u(r(s(day)?)?)?)?/": "^ಗ(ುರು(.(ವಾರ)?)?)?", "/^fr(i(day)?)?/": "^ಶ(ುಕ್ರ(.(ವಾರ)?)?)?", "/^sa(t(urday)?)?/": "^ಶ(ನಿ(.(ವಾರ)?)?)?", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "kn-IN"; ================================================ FILE: src/i18n/ko-KR.js ================================================ /* * DateJS Culture String File * Country Code: ko-KR * Name: Korean (Korea) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["ko-KR"] = { "name": "ko-KR", "englishName": "Korean (Korea)", "nativeName": "한국어 (대한민국)", "Sunday": "일요일", "Monday": "월요일", "Tuesday": "화요일", "Wednesday": "수요일", "Thursday": "목요일", "Friday": "금요일", "Saturday": "토요일", "Sun": "일", "Mon": "월", "Tue": "화", "Wed": "수", "Thu": "목", "Fri": "금", "Sat": "토", "Su": "일", "Mo": "월", "Tu": "화", "We": "수", "Th": "목", "Fr": "금", "Sa": "토", "S_Sun_Initial": "일", "M_Mon_Initial": "월", "T_Tue_Initial": "화", "W_Wed_Initial": "수", "T_Thu_Initial": "목", "F_Fri_Initial": "금", "S_Sat_Initial": "토", "January": "1월", "February": "2월", "March": "3월", "April": "4월", "May": "5월", "June": "6월", "July": "7월", "August": "8월", "September": "9월", "October": "10월", "November": "11월", "December": "12월", "Jan_Abbr": "1", "Feb_Abbr": "2", "Mar_Abbr": "3", "Apr_Abbr": "4", "May_Abbr": "5", "Jun_Abbr": "6", "Jul_Abbr": "7", "Aug_Abbr": "8", "Sep_Abbr": "9", "Oct_Abbr": "10", "Nov_Abbr": "11", "Dec_Abbr": "12", "AM": "오전", "PM": "오후", "firstDayOfWeek": 0, "twoDigitYearMax": 2029, "mdy": "ymd", "M/d/yyyy": "yyyy-MM-dd", "dddd, MMMM dd, yyyy": "yyyy'년' M'월' d'일' dddd", "h:mm tt": "tt h:mm", "h:mm:ss tt": "tt h:mm:ss", "dddd, MMMM dd, yyyy h:mm:ss tt": "yyyy'년' M'월' d'일' dddd tt h:mm:ss", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "M'월' d'일'", "MMMM, yyyy": "yyyy'년' M'월'", "/jan(uary)?/": "1(월)?", "/feb(ruary)?/": "2(월)?", "/mar(ch)?/": "3(월)?", "/apr(il)?/": "4(월)?", "/may/": "5(월)?", "/jun(e)?/": "6(월)?", "/jul(y)?/": "7(월)?", "/aug(ust)?/": "8(월)?", "/sep(t(ember)?)?/": "9(월)?", "/oct(ober)?/": "10(월)?", "/nov(ember)?/": "11(월)?", "/dec(ember)?/": "12(월)?", "/^su(n(day)?)?/": "^일요일", "/^mo(n(day)?)?/": "^월요일", "/^tu(e(s(day)?)?)?/": "^화요일", "/^we(d(nesday)?)?/": "^수요일", "/^th(u(r(s(day)?)?)?)?/": "^목요일", "/^fr(i(day)?)?/": "^금요일", "/^sa(t(urday)?)?/": "^토요일", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "ko-KR"; ================================================ FILE: src/i18n/kok-IN.js ================================================ /* * DateJS Culture String File * Country Code: kok-IN * Name: Konkani (India) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["kok-IN"] = { "name": "kok-IN", "englishName": "Konkani (India)", "nativeName": "कोंकणी (भारत)", "Sunday": "आयतार", "Monday": "सोमार", "Tuesday": "मंगळार", "Wednesday": "बुधवार", "Thursday": "बिरेस्तार", "Friday": "सुक्रार", "Saturday": "शेनवार", "Sun": "आय.", "Mon": "सोम.", "Tue": "मंगळ.", "Wed": "बुध.", "Thu": "बिरे.", "Fri": "सुक्र.", "Sat": "शेन.", "Su": "आ", "Mo": "स", "Tu": "म", "We": "ब", "Th": "ब", "Fr": "स", "Sa": "श", "S_Sun_Initial": "आ", "M_Mon_Initial": "स", "T_Tue_Initial": "म", "W_Wed_Initial": "ब", "T_Thu_Initial": "ब", "F_Fri_Initial": "स", "S_Sat_Initial": "श", "January": "जानेवारी", "February": "फेब्रुवारी", "March": "मार्च", "April": "एप्रिल", "May": "मे", "June": "जून", "July": "जुलै", "August": "ऑगस्ट", "September": "सप्टेंबर", "October": "ऑक्टोबर", "November": "नोवेम्बर", "December": "डिसेंबर", "Jan_Abbr": "जानेवारी", "Feb_Abbr": "फेब्रुवारी", "Mar_Abbr": "मार्च", "Apr_Abbr": "एप्रिल", "May_Abbr": "मे", "Jun_Abbr": "जून", "Jul_Abbr": "जुलै", "Aug_Abbr": "ऑगस्ट", "Sep_Abbr": "सप्टेंबर", "Oct_Abbr": "ऑक्टोबर", "Nov_Abbr": "नोवेम्बर", "Dec_Abbr": "डिसेंबर", "AM": "म.पू.", "PM": "म.नं.", "firstDayOfWeek": 1, "twoDigitYearMax": 2029, "mdy": "dmy", "M/d/yyyy": "dd-MM-yyyy", "dddd, MMMM dd, yyyy": "dd MMMM yyyy", "h:mm tt": "HH:mm", "h:mm:ss tt": "HH:mm:ss", "dddd, MMMM dd, yyyy h:mm:ss tt": "dd MMMM yyyy HH:mm:ss", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "dd MMMM", "MMMM, yyyy": "MMMM, yyyy", "/jan(uary)?/": "जानेवारी", "/feb(ruary)?/": "फेब्रुवारी", "/mar(ch)?/": "मार्च", "/apr(il)?/": "एप्रिल", "/may/": "मे", "/jun(e)?/": "जून", "/jul(y)?/": "जुलै", "/aug(ust)?/": "ऑगस्ट", "/sep(t(ember)?)?/": "सप्टेंबर", "/oct(ober)?/": "ऑक्टोबर", "/nov(ember)?/": "नोवेम्बर", "/dec(ember)?/": "डिसेंबर", "/^su(n(day)?)?/": "^आ(य(.(तार)?)?)?", "/^mo(n(day)?)?/": "^स(ोम(.(ार)?)?)?", "/^tu(e(s(day)?)?)?/": "^म(ंगळ(.(ार)?)?)?", "/^we(d(nesday)?)?/": "^ब(ुध(.(वार)?)?)?", "/^th(u(r(s(day)?)?)?)?/": "^ब(िरे(.(स्तार)?)?)?", "/^fr(i(day)?)?/": "^स(ुक्र(.(ार)?)?)?", "/^sa(t(urday)?)?/": "^श(ेन(.(वार)?)?)?", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "kok-IN"; ================================================ FILE: src/i18n/ky-KG.js ================================================ /* * DateJS Culture String File * Country Code: ky-KG * Name: Kyrgyz (Kyrgyzstan) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["ky-KG"] = { "name": "ky-KG", "englishName": "Kyrgyz (Kyrgyzstan)", "nativeName": "Кыргыз (Кыргызстан)", "Sunday": "Жекшемби", "Monday": "Дүйшөмбү", "Tuesday": "Шейшемби", "Wednesday": "Шаршемби", "Thursday": "Бейшемби", "Friday": "Жума", "Saturday": "Ишемби", "Sun": "Жш", "Mon": "Дш", "Tue": "Шш", "Wed": "Шр", "Thu": "Бш", "Fri": "Жм", "Sat": "Иш", "Su": "Жш", "Mo": "Дш", "Tu": "Шш", "We": "Шр", "Th": "Бш", "Fr": "Жм", "Sa": "Иш", "S_Sun_Initial": "Ж", "M_Mon_Initial": "Д", "T_Tue_Initial": "Ш", "W_Wed_Initial": "Ш", "T_Thu_Initial": "Б", "F_Fri_Initial": "Ж", "S_Sat_Initial": "И", "January": "Январь", "February": "Февраль", "March": "Март", "April": "Апрель", "May": "Май", "June": "Июнь", "July": "Июль", "August": "Август", "September": "Сентябрь", "October": "Октябрь", "November": "Ноябрь", "December": "Декабрь", "Jan_Abbr": "Янв", "Feb_Abbr": "Фев", "Mar_Abbr": "Мар", "Apr_Abbr": "Апр", "May_Abbr": "Май", "Jun_Abbr": "Июн", "Jul_Abbr": "Июл", "Aug_Abbr": "Авг", "Sep_Abbr": "Сен", "Oct_Abbr": "Окт", "Nov_Abbr": "Ноя", "Dec_Abbr": "Дек", "AM": "", "PM": "", "firstDayOfWeek": 1, "twoDigitYearMax": 2029, "mdy": "dmy", "M/d/yyyy": "dd.MM.yy", "dddd, MMMM dd, yyyy": "d'-'MMMM yyyy'-ж.'", "h:mm tt": "H:mm", "h:mm:ss tt": "H:mm:ss", "dddd, MMMM dd, yyyy h:mm:ss tt": "d'-'MMMM yyyy'-ж.' H:mm:ss", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "d MMMM", "MMMM, yyyy": "MMMM yyyy'-ж.'", "/jan(uary)?/": "янв(арь)?", "/feb(ruary)?/": "фев(раль)?", "/mar(ch)?/": "мар(т)?", "/apr(il)?/": "апр(ель)?", "/may/": "май", "/jun(e)?/": "июн(ь)?", "/jul(y)?/": "июл(ь)?", "/aug(ust)?/": "авг(уст)?", "/sep(t(ember)?)?/": "сен(тябрь)?", "/oct(ober)?/": "окт(ябрь)?", "/nov(ember)?/": "ноя(брь)?", "/dec(ember)?/": "дек(абрь)?", "/^su(n(day)?)?/": "^жекшемби", "/^mo(n(day)?)?/": "^дүйшөмбү", "/^tu(e(s(day)?)?)?/": "^шейшемби", "/^we(d(nesday)?)?/": "^шаршемби", "/^th(u(r(s(day)?)?)?)?/": "^бейшемби", "/^fr(i(day)?)?/": "^жума", "/^sa(t(urday)?)?/": "^ишемби", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "ky-KG"; ================================================ FILE: src/i18n/lt-LT.js ================================================ /* * DateJS Culture String File * Country Code: lt-LT * Name: Lithuanian (Lithuania) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["lt-LT"] = { "name": "lt-LT", "englishName": "Lithuanian (Lithuania)", "nativeName": "lietuvių (Lietuva)", "Sunday": "sekmadienis", "Monday": "pirmadienis", "Tuesday": "antradienis", "Wednesday": "trečiadienis", "Thursday": "ketvirtadienis", "Friday": "penktadienis", "Saturday": "šeštadienis", "Sun": "Sk", "Mon": "Pr", "Tue": "An", "Wed": "Tr", "Thu": "Kt", "Fri": "Pn", "Sat": "Št", "Su": "S", "Mo": "P", "Tu": "A", "We": "T", "Th": "K", "Fr": "Pn", "Sa": "Š", "S_Sun_Initial": "S", "M_Mon_Initial": "P", "T_Tue_Initial": "A", "W_Wed_Initial": "T", "T_Thu_Initial": "K", "F_Fri_Initial": "P", "S_Sat_Initial": "Š", "January": "sausis", "February": "vasaris", "March": "kovas", "April": "balandis", "May": "gegužė", "June": "birželis", "July": "liepa", "August": "rugpjūtis", "September": "rugsėjis", "October": "spalis", "November": "lapkritis", "December": "gruodis", "Jan_Abbr": "Sau", "Feb_Abbr": "Vas", "Mar_Abbr": "Kov", "Apr_Abbr": "Bal", "May_Abbr": "Geg", "Jun_Abbr": "Bir", "Jul_Abbr": "Lie", "Aug_Abbr": "Rgp", "Sep_Abbr": "Rgs", "Oct_Abbr": "Spl", "Nov_Abbr": "Lap", "Dec_Abbr": "Grd", "AM": "", "PM": "", "firstDayOfWeek": 1, "twoDigitYearMax": 2029, "mdy": "ymd", "M/d/yyyy": "yyyy.MM.dd", "dddd, MMMM dd, yyyy": "yyyy 'm.' MMMM d 'd.'", "h:mm tt": "HH:mm", "h:mm:ss tt": "HH:mm:ss", "dddd, MMMM dd, yyyy h:mm:ss tt": "yyyy 'm.' MMMM d 'd.' HH:mm:ss", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "MMMM d 'd.'", "MMMM, yyyy": "yyyy 'm.' MMMM", "/jan(uary)?/": "sau(sis)?", "/feb(ruary)?/": "vas(aris)?", "/mar(ch)?/": "kov(as)?", "/apr(il)?/": "bal(andis)?", "/may/": "geg(užė)?", "/jun(e)?/": "bir(želis)?", "/jul(y)?/": "lie(pa)?", "/aug(ust)?/": "rugpjūtis", "/sep(t(ember)?)?/": "rugsėjis", "/oct(ober)?/": "spalis", "/nov(ember)?/": "lap(kritis)?", "/dec(ember)?/": "gruodis", "/^su(n(day)?)?/": "^s(k(kmadienis)?)?", "/^mo(n(day)?)?/": "^p(r(rmadienis)?)?", "/^tu(e(s(day)?)?)?/": "^a(n(tradienis)?)?", "/^we(d(nesday)?)?/": "^t(r(ečiadienis)?)?", "/^th(u(r(s(day)?)?)?)?/": "^k(t(tvirtadienis)?)?", "/^fr(i(day)?)?/": "^penktadienis", "/^sa(t(urday)?)?/": "^š(t(štadienis)?)?", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "lt-LT"; ================================================ FILE: src/i18n/lv-LV.js ================================================ /* * DateJS Culture String File * Country Code: lv-LV * Name: Latvian (Latvia) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["lv-LV"] = { "name": "lv-LV", "englishName": "Latvian (Latvia)", "nativeName": "latviešu (Latvija)", "Sunday": "svētdiena", "Monday": "pirmdiena", "Tuesday": "otrdiena", "Wednesday": "trešdiena", "Thursday": "ceturtdiena", "Friday": "piektdiena", "Saturday": "sestdiena", "Sun": "Sv", "Mon": "Pr", "Tue": "Ot", "Wed": "Tr", "Thu": "Ce", "Fri": "Pk", "Sat": "Se", "Su": "Sv", "Mo": "Pr", "Tu": "Ot", "We": "Tr", "Th": "Ce", "Fr": "Pk", "Sa": "Se", "S_Sun_Initial": "S", "M_Mon_Initial": "P", "T_Tue_Initial": "O", "W_Wed_Initial": "T", "T_Thu_Initial": "C", "F_Fri_Initial": "P", "S_Sat_Initial": "S", "January": "janvāris", "February": "februāris", "March": "marts", "April": "aprīlis", "May": "maijs", "June": "jūnijs", "July": "jūlijs", "August": "augusts", "September": "septembris", "October": "oktobris", "November": "novembris", "December": "decembris", "Jan_Abbr": "Jan", "Feb_Abbr": "Feb", "Mar_Abbr": "Mar", "Apr_Abbr": "Apr", "May_Abbr": "Mai", "Jun_Abbr": "Jūn", "Jul_Abbr": "Jūl", "Aug_Abbr": "Aug", "Sep_Abbr": "Sep", "Oct_Abbr": "Okt", "Nov_Abbr": "Nov", "Dec_Abbr": "Dec", "AM": "", "PM": "", "firstDayOfWeek": 1, "twoDigitYearMax": 2029, "mdy": "ymd", "M/d/yyyy": "yyyy.MM.dd.", "dddd, MMMM dd, yyyy": "dddd, yyyy'. gada 'd. MMMM", "h:mm tt": "H:mm", "h:mm:ss tt": "H:mm:ss", "dddd, MMMM dd, yyyy h:mm:ss tt": "dddd, yyyy'. gada 'd. MMMM H:mm:ss", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "d. MMMM", "MMMM, yyyy": "yyyy. MMMM", "/jan(uary)?/": "jan(vāris)?", "/feb(ruary)?/": "feb(ruāris)?", "/mar(ch)?/": "mar(ts)?", "/apr(il)?/": "apr(īlis)?", "/may/": "mai(js)?", "/jun(e)?/": "jūn(ijs)?", "/jul(y)?/": "jūl(ijs)?", "/aug(ust)?/": "aug(usts)?", "/sep(t(ember)?)?/": "sep(tembris)?", "/oct(ober)?/": "okt(obris)?", "/nov(ember)?/": "nov(embris)?", "/dec(ember)?/": "dec(embris)?", "/^su(n(day)?)?/": "^svētdiena", "/^mo(n(day)?)?/": "^pirmdiena", "/^tu(e(s(day)?)?)?/": "^otrdiena", "/^we(d(nesday)?)?/": "^trešdiena", "/^th(u(r(s(day)?)?)?)?/": "^ceturtdiena", "/^fr(i(day)?)?/": "^piektdiena", "/^sa(t(urday)?)?/": "^sestdiena", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "lv-LV"; ================================================ FILE: src/i18n/mi-NZ.js ================================================ /* * DateJS Culture String File * Country Code: mi-NZ * Name: Maori (New Zealand) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["mi-NZ"] = { "name": "mi-NZ", "englishName": "Maori (New Zealand)", "nativeName": "Reo Māori (Aotearoa)", "Sunday": "Rātapu", "Monday": "Mane", "Tuesday": "Tūrei", "Wednesday": "Wenerei", "Thursday": "Tāite", "Friday": "Paraire", "Saturday": "Hātarei", "Sun": "Ta", "Mon": "Ma", "Tue": "Tū", "Wed": "We", "Thu": "Tāi", "Fri": "Pa", "Sat": "Hā", "Su": "Ta", "Mo": "Ma", "Tu": "Tū", "We": "We", "Th": "Tāi", "Fr": "Pa", "Sa": "Hā", "S_Sun_Initial": "T", "M_Mon_Initial": "M", "T_Tue_Initial": "T", "W_Wed_Initial": "W", "T_Thu_Initial": "T", "F_Fri_Initial": "P", "S_Sat_Initial": "H", "January": "Kohi-tātea", "February": "Hui-tanguru", "March": "Poutū-te-rangi", "April": "Paenga-whāwhā", "May": "Haratua", "June": "Pipiri", "July": "Hōngoingoi", "August": "Here-turi-kōkā", "September": "Mahuru", "October": "Whiringa-ā-nuku", "November": "Whiringa-ā-rangi", "December": "Hakihea", "Jan_Abbr": "Kohi", "Feb_Abbr": "Hui", "Mar_Abbr": "Pou", "Apr_Abbr": "Pae", "May_Abbr": "Hara", "Jun_Abbr": "Pipi", "Jul_Abbr": "Hōngoi", "Aug_Abbr": "Here", "Sep_Abbr": "Mahu", "Oct_Abbr": "Whi-nu", "Nov_Abbr": "Whi-ra", "Dec_Abbr": "Haki", "AM": "a.m.", "PM": "p.m.", "firstDayOfWeek": 1, "twoDigitYearMax": 2029, "mdy": "dmy", "M/d/yyyy": "d/MM/yyyy", "dddd, MMMM dd, yyyy": "dddd, d MMMM yyyy", "h:mm tt": "h:mm:ss tt", "h:mm:ss tt": "h:mm:ss tt", "dddd, MMMM dd, yyyy h:mm:ss tt": "dddd, d MMMM yyyy h:mm:ss tt", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "MMMM dd", "MMMM, yyyy": "MMMM yyyy", "/jan(uary)?/": "kohi(-tātea)?", "/feb(ruary)?/": "hui(-tanguru)?", "/mar(ch)?/": "pou(tū-te-rangi)?", "/apr(il)?/": "pae(nga-whāwhā)?", "/may/": "hara(tua)?", "/jun(e)?/": "pipi(ri)?", "/jul(y)?/": "hōngoi(ngoi)?", "/aug(ust)?/": "here(-turi-kōkā)?", "/sep(t(ember)?)?/": "mahu(ru)?", "/oct(ober)?/": "whiringa-ā-nuku", "/nov(ember)?/": "whiringa-ā-rangi", "/dec(ember)?/": "haki(hea)?", "/^su(n(day)?)?/": "^rātapu", "/^mo(n(day)?)?/": "^mane", "/^tu(e(s(day)?)?)?/": "^tūrei", "/^we(d(nesday)?)?/": "^wenerei", "/^th(u(r(s(day)?)?)?)?/": "^tāite", "/^fr(i(day)?)?/": "^paraire", "/^sa(t(urday)?)?/": "^hātarei", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "mi-NZ"; ================================================ FILE: src/i18n/mk-MK.js ================================================ /* * DateJS Culture String File * Country Code: mk-MK * Name: Macedonian (Former Yugoslav Republic of Macedonia) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["mk-MK"] = { "name": "mk-MK", "englishName": "Macedonian (Former Yugoslav Republic of Macedonia)", "nativeName": "македонски јазик (Македонија)", "Sunday": "недела", "Monday": "понеделник", "Tuesday": "вторник", "Wednesday": "среда", "Thursday": "четврток", "Friday": "петок", "Saturday": "сабота", "Sun": "нед", "Mon": "пон", "Tue": "втр", "Wed": "срд", "Thu": "чет", "Fri": "пет", "Sat": "саб", "Su": "не", "Mo": "по", "Tu": "вт", "We": "ср", "Th": "че", "Fr": "пе", "Sa": "са", "S_Sun_Initial": "н", "M_Mon_Initial": "п", "T_Tue_Initial": "в", "W_Wed_Initial": "с", "T_Thu_Initial": "ч", "F_Fri_Initial": "п", "S_Sat_Initial": "с", "January": "јануари", "February": "февруари", "March": "март", "April": "април", "May": "мај", "June": "јуни", "July": "јули", "August": "август", "September": "септември", "October": "октомври", "November": "ноември", "December": "декември", "Jan_Abbr": "јан", "Feb_Abbr": "фев", "Mar_Abbr": "мар", "Apr_Abbr": "апр", "May_Abbr": "мај", "Jun_Abbr": "јун", "Jul_Abbr": "јул", "Aug_Abbr": "авг", "Sep_Abbr": "сеп", "Oct_Abbr": "окт", "Nov_Abbr": "ное", "Dec_Abbr": "дек", "AM": "", "PM": "", "firstDayOfWeek": 1, "twoDigitYearMax": 2029, "mdy": "dmy", "M/d/yyyy": "dd.MM.yyyy", "dddd, MMMM dd, yyyy": "dddd, dd MMMM yyyy", "h:mm tt": "HH:mm", "h:mm:ss tt": "HH:mm:ss", "dddd, MMMM dd, yyyy h:mm:ss tt": "dddd, dd MMMM yyyy HH:mm:ss", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "dd MMMM", "MMMM, yyyy": "MMMM yyyy", "/jan(uary)?/": "јан(уари)?", "/feb(ruary)?/": "фев(руари)?", "/mar(ch)?/": "мар(т)?", "/apr(il)?/": "апр(ил)?", "/may/": "мај", "/jun(e)?/": "јун(и)?", "/jul(y)?/": "јул(и)?", "/aug(ust)?/": "авг(уст)?", "/sep(t(ember)?)?/": "сеп(тември)?", "/oct(ober)?/": "окт(омври)?", "/nov(ember)?/": "ное(мври)?", "/dec(ember)?/": "дек(ември)?", "/^su(n(day)?)?/": "^не(д(ела)?)?", "/^mo(n(day)?)?/": "^по(н(еделник)?)?", "/^tu(e(s(day)?)?)?/": "^вт(р(рник)?)?", "/^we(d(nesday)?)?/": "^ср(д(да)?)?", "/^th(u(r(s(day)?)?)?)?/": "^че(т(врток)?)?", "/^fr(i(day)?)?/": "^пе(т(ок)?)?", "/^sa(t(urday)?)?/": "^са(б(ота)?)?", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "mk-MK"; ================================================ FILE: src/i18n/mn-MN.js ================================================ /* * DateJS Culture String File * Country Code: mn-MN * Name: Mongolian (Cyrillic, Mongolia) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["mn-MN"] = { "name": "mn-MN", "englishName": "Mongolian (Cyrillic, Mongolia)", "nativeName": "Монгол хэл (Монгол улс)", "Sunday": "Ням", "Monday": "Даваа", "Tuesday": "Мягмар", "Wednesday": "Лхагва", "Thursday": "Пүрэв", "Friday": "Баасан", "Saturday": "Бямба", "Sun": "Ня", "Mon": "Да", "Tue": "Мя", "Wed": "Лх", "Thu": "Пү", "Fri": "Ба", "Sat": "Бя", "Su": "Ня", "Mo": "Да", "Tu": "Мя", "We": "Лх", "Th": "Пү", "Fr": "Ба", "Sa": "Бя", "S_Sun_Initial": "Н", "M_Mon_Initial": "Д", "T_Tue_Initial": "М", "W_Wed_Initial": "Л", "T_Thu_Initial": "П", "F_Fri_Initial": "Б", "S_Sat_Initial": "Б", "January": "1 дүгээр сар", "February": "2 дугаар сар", "March": "3 дугаар сар", "April": "4 дүгээр сар", "May": "5 дугаар сар", "June": "6 дугаар сар", "July": "7 дугаар сар", "August": "8 дугаар сар", "September": "9 дүгээр сар", "October": "10 дугаар сар", "November": "11 дүгээр сар", "December": "12 дугаар сар", "Jan_Abbr": "I", "Feb_Abbr": "II", "Mar_Abbr": "III", "Apr_Abbr": "IV", "May_Abbr": "V", "Jun_Abbr": "VI", "Jul_Abbr": "VII", "Aug_Abbr": "VШ", "Sep_Abbr": "IX", "Oct_Abbr": "X", "Nov_Abbr": "XI", "Dec_Abbr": "XII", "AM": "", "PM": "", "firstDayOfWeek": 1, "twoDigitYearMax": 2029, "mdy": "ymd", "M/d/yyyy": "yy.MM.dd", "dddd, MMMM dd, yyyy": "yyyy 'оны' MMMM d", "h:mm tt": "H:mm", "h:mm:ss tt": "H:mm:ss", "dddd, MMMM dd, yyyy h:mm:ss tt": "yyyy 'оны' MMMM d H:mm:ss", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "d MMMM", "MMMM, yyyy": "yyyy 'он' MMMM", "/jan(uary)?/": "1 дүгээр сар", "/feb(ruary)?/": "2 дугаар сар", "/mar(ch)?/": "3 дугаар сар", "/apr(il)?/": "4 дүгээр сар", "/may/": "5 дугаар сар", "/jun(e)?/": "6 дугаар сар", "/jul(y)?/": "7 дугаар сар", "/aug(ust)?/": "8 дугаар сар", "/sep(t(ember)?)?/": "9 дүгээр сар", "/oct(ober)?/": "10 дугаар сар", "/nov(ember)?/": "11 дүгээр сар", "/dec(ember)?/": "12 дугаар сар", "/^su(n(day)?)?/": "^ням", "/^mo(n(day)?)?/": "^даваа", "/^tu(e(s(day)?)?)?/": "^мягмар", "/^we(d(nesday)?)?/": "^лхагва", "/^th(u(r(s(day)?)?)?)?/": "^пүрэв", "/^fr(i(day)?)?/": "^баасан", "/^sa(t(urday)?)?/": "^бямба", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "mn-MN"; ================================================ FILE: src/i18n/mr-IN.js ================================================ /* * DateJS Culture String File * Country Code: mr-IN * Name: Marathi (India) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["mr-IN"] = { "name": "mr-IN", "englishName": "Marathi (India)", "nativeName": "मराठी (भारत)", "Sunday": "रविवार", "Monday": "सोमवार", "Tuesday": "मंगळवार", "Wednesday": "बुधवार", "Thursday": "गुरुवार", "Friday": "शुक्रवार", "Saturday": "शनिवार", "Sun": "रवि.", "Mon": "सोम.", "Tue": "मंगळ.", "Wed": "बुध.", "Thu": "गुरु.", "Fri": "शुक्र.", "Sat": "शनि.", "Su": "र", "Mo": "स", "Tu": "म", "We": "ब", "Th": "ग", "Fr": "श", "Sa": "श", "S_Sun_Initial": "र", "M_Mon_Initial": "स", "T_Tue_Initial": "म", "W_Wed_Initial": "ब", "T_Thu_Initial": "ग", "F_Fri_Initial": "श", "S_Sat_Initial": "श", "January": "जानेवारी", "February": "फेब्रुवारी", "March": "मार्च", "April": "एप्रिल", "May": "मे", "June": "जून", "July": "जुलै", "August": "ऑगस्ट", "September": "सप्टेंबर", "October": "ऑक्टोबर", "November": "नोव्हेंबर", "December": "डिसेंबर", "Jan_Abbr": "जाने.", "Feb_Abbr": "फेब्रु.", "Mar_Abbr": "मार्च", "Apr_Abbr": "एप्रिल", "May_Abbr": "मे", "Jun_Abbr": "जून", "Jul_Abbr": "जुलै", "Aug_Abbr": "ऑगस्ट", "Sep_Abbr": "सप्टें.", "Oct_Abbr": "ऑक्टो.", "Nov_Abbr": "नोव्हें.", "Dec_Abbr": "डिसें.", "AM": "म.पू.", "PM": "म.नं.", "firstDayOfWeek": 1, "twoDigitYearMax": 2029, "mdy": "dmy", "M/d/yyyy": "dd-MM-yyyy", "dddd, MMMM dd, yyyy": "dd MMMM yyyy", "h:mm tt": "HH:mm", "h:mm:ss tt": "HH:mm:ss", "dddd, MMMM dd, yyyy h:mm:ss tt": "dd MMMM yyyy HH:mm:ss", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "dd MMMM", "MMMM, yyyy": "MMMM, yyyy", "/jan(uary)?/": "जाने(.(वारी)?)?", "/feb(ruary)?/": "फेब्रु(.(वारी)?)?", "/mar(ch)?/": "मार्च", "/apr(il)?/": "एप्रिल", "/may/": "मे", "/jun(e)?/": "जून", "/jul(y)?/": "जुलै", "/aug(ust)?/": "ऑगस्ट", "/sep(t(ember)?)?/": "सप्टें(.(बर)?)?", "/oct(ober)?/": "ऑक्टो(.(बर)?)?", "/nov(ember)?/": "नोव्हें(.(बर)?)?", "/dec(ember)?/": "डिसें(.(बर)?)?", "/^su(n(day)?)?/": "^र(वि(.(वार)?)?)?", "/^mo(n(day)?)?/": "^स(ोम(.(वार)?)?)?", "/^tu(e(s(day)?)?)?/": "^म(ंगळ(.(वार)?)?)?", "/^we(d(nesday)?)?/": "^ब(ुध(.(वार)?)?)?", "/^th(u(r(s(day)?)?)?)?/": "^ग(ुरु(.(वार)?)?)?", "/^fr(i(day)?)?/": "^श(ुक्र(.(वार)?)?)?", "/^sa(t(urday)?)?/": "^श(नि(.(वार)?)?)?", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "mr-IN"; ================================================ FILE: src/i18n/ms-BN.js ================================================ /* * DateJS Culture String File * Country Code: ms-BN * Name: Malay (Brunei Darussalam) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["ms-BN"] = { "name": "ms-BN", "englishName": "Malay (Brunei Darussalam)", "nativeName": "Bahasa Malaysia (Brunei Darussalam)", "Sunday": "Ahad", "Monday": "Isnin", "Tuesday": "Selasa", "Wednesday": "Rabu", "Thursday": "Khamis", "Friday": "Jumaat", "Saturday": "Sabtu", "Sun": "Ahad", "Mon": "Isnin", "Tue": "Sel", "Wed": "Rabu", "Thu": "Khamis", "Fri": "Jumaat", "Sat": "Sabtu", "Su": "A", "Mo": "I", "Tu": "S", "We": "R", "Th": "K", "Fr": "J", "Sa": "S", "S_Sun_Initial": "A", "M_Mon_Initial": "I", "T_Tue_Initial": "S", "W_Wed_Initial": "R", "T_Thu_Initial": "K", "F_Fri_Initial": "J", "S_Sat_Initial": "S", "January": "Januari", "February": "Februari", "March": "Mac", "April": "April", "May": "Mei", "June": "Jun", "July": "Julai", "August": "Ogos", "September": "September", "October": "Oktober", "November": "November", "December": "Disember", "Jan_Abbr": "Jan", "Feb_Abbr": "Feb", "Mar_Abbr": "Mac", "Apr_Abbr": "Apr", "May_Abbr": "Mei", "Jun_Abbr": "Jun", "Jul_Abbr": "Jul", "Aug_Abbr": "Ogos", "Sep_Abbr": "Sept", "Oct_Abbr": "Okt", "Nov_Abbr": "Nov", "Dec_Abbr": "Dis", "AM": "", "PM": "", "firstDayOfWeek": 1, "twoDigitYearMax": 2029, "mdy": "dmy", "M/d/yyyy": "dd/MM/yyyy", "dddd, MMMM dd, yyyy": "dd MMMM yyyy", "h:mm tt": "H:mm", "h:mm:ss tt": "H:mm:ss", "dddd, MMMM dd, yyyy h:mm:ss tt": "dd MMMM yyyy H:mm:ss", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "dd MMMM", "MMMM, yyyy": "MMMM yyyy", "/jan(uary)?/": "jan(uari)?", "/feb(ruary)?/": "feb(ruari)?", "/mar(ch)?/": "mac", "/apr(il)?/": "apr(il)?", "/may/": "mei", "/jun(e)?/": "jun", "/jul(y)?/": "jul(ai)?", "/aug(ust)?/": "ogos", "/sep(t(ember)?)?/": "sep(t(ember)?)?", "/oct(ober)?/": "okt(ober)?", "/nov(ember)?/": "nov(ember)?", "/dec(ember)?/": "dis(ember)?", "/^su(n(day)?)?/": "^a(1)?", "/^mo(n(day)?)?/": "^i(1)?", "/^tu(e(s(day)?)?)?/": "^s(el(asa)?)?", "/^we(d(nesday)?)?/": "^r(1)?", "/^th(u(r(s(day)?)?)?)?/": "^k(1)?", "/^fr(i(day)?)?/": "^j(1)?", "/^sa(t(urday)?)?/": "^s(1)?", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "ms-BN"; ================================================ FILE: src/i18n/ms-MY.js ================================================ /* * DateJS Culture String File * Country Code: ms-MY * Name: Malay (Malaysia) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["ms-MY"] = { "name": "ms-MY", "englishName": "Malay (Malaysia)", "nativeName": "Bahasa Malaysia (Malaysia)", "Sunday": "Ahad", "Monday": "Isnin", "Tuesday": "Selasa", "Wednesday": "Rabu", "Thursday": "Khamis", "Friday": "Jumaat", "Saturday": "Sabtu", "Sun": "Ahad", "Mon": "Isnin", "Tue": "Sel", "Wed": "Rabu", "Thu": "Khamis", "Fri": "Jumaat", "Sat": "Sabtu", "Su": "A", "Mo": "I", "Tu": "S", "We": "R", "Th": "K", "Fr": "J", "Sa": "S", "S_Sun_Initial": "A", "M_Mon_Initial": "I", "T_Tue_Initial": "S", "W_Wed_Initial": "R", "T_Thu_Initial": "K", "F_Fri_Initial": "J", "S_Sat_Initial": "S", "January": "Januari", "February": "Februari", "March": "Mac", "April": "April", "May": "Mei", "June": "Jun", "July": "Julai", "August": "Ogos", "September": "September", "October": "Oktober", "November": "November", "December": "Disember", "Jan_Abbr": "Jan", "Feb_Abbr": "Feb", "Mar_Abbr": "Mac", "Apr_Abbr": "Apr", "May_Abbr": "Mei", "Jun_Abbr": "Jun", "Jul_Abbr": "Jul", "Aug_Abbr": "Ogos", "Sep_Abbr": "Sept", "Oct_Abbr": "Okt", "Nov_Abbr": "Nov", "Dec_Abbr": "Dis", "AM": "", "PM": "", "firstDayOfWeek": 1, "twoDigitYearMax": 2029, "mdy": "dmy", "M/d/yyyy": "dd/MM/yyyy", "dddd, MMMM dd, yyyy": "dd MMMM yyyy", "h:mm tt": "H:mm", "h:mm:ss tt": "H:mm:ss", "dddd, MMMM dd, yyyy h:mm:ss tt": "dd MMMM yyyy H:mm:ss", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "dd MMMM", "MMMM, yyyy": "MMMM yyyy", "/jan(uary)?/": "jan(uari)?", "/feb(ruary)?/": "feb(ruari)?", "/mar(ch)?/": "mac", "/apr(il)?/": "apr(il)?", "/may/": "mei", "/jun(e)?/": "jun", "/jul(y)?/": "jul(ai)?", "/aug(ust)?/": "ogos", "/sep(t(ember)?)?/": "sep(t(ember)?)?", "/oct(ober)?/": "okt(ober)?", "/nov(ember)?/": "nov(ember)?", "/dec(ember)?/": "dis(ember)?", "/^su(n(day)?)?/": "^a(1)?", "/^mo(n(day)?)?/": "^i(1)?", "/^tu(e(s(day)?)?)?/": "^s(el(asa)?)?", "/^we(d(nesday)?)?/": "^r(1)?", "/^th(u(r(s(day)?)?)?)?/": "^k(1)?", "/^fr(i(day)?)?/": "^j(1)?", "/^sa(t(urday)?)?/": "^s(1)?", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "ms-MY"; ================================================ FILE: src/i18n/mt-MT.js ================================================ /* * DateJS Culture String File * Country Code: mt-MT * Name: Maltese (Malta) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["mt-MT"] = { "name": "mt-MT", "englishName": "Maltese (Malta)", "nativeName": "Malti (Malta)", "Sunday": "Il-Ħadd", "Monday": "It-Tnejn", "Tuesday": "It-Tlieta", "Wednesday": "L-Erbgħa", "Thursday": "Il-Ħamis", "Friday": "Il-Ġimgħa", "Saturday": "Is-Sibt", "Sun": "Ħad", "Mon": "Tne", "Tue": "Tli", "Wed": "Erb", "Thu": "Ħam", "Fri": "Ġim", "Sat": "Sib", "Su": "Ħad", "Mo": "Tne", "Tu": "Tli", "We": "Erb", "Th": "Ħam", "Fr": "Ġim", "Sa": "Sib", "S_Sun_Initial": "Ħ", "M_Mon_Initial": "T", "T_Tue_Initial": "T", "W_Wed_Initial": "E", "T_Thu_Initial": "Ħ", "F_Fri_Initial": "Ġ", "S_Sat_Initial": "S", "January": "Jannar", "February": "Frar", "March": "Marzu", "April": "April", "May": "Mejju", "June": "Ġunju", "July": "Lulju", "August": "Awissu", "September": "Settembru", "October": "Ottubru", "November": "Novembru", "December": "Diċembru", "Jan_Abbr": "Jan", "Feb_Abbr": "Fra", "Mar_Abbr": "Mar", "Apr_Abbr": "Apr", "May_Abbr": "Mej", "Jun_Abbr": "Ġun", "Jul_Abbr": "Lul", "Aug_Abbr": "Awi", "Sep_Abbr": "Set", "Oct_Abbr": "Ott", "Nov_Abbr": "Nov", "Dec_Abbr": "Diċ", "AM": "AM", "PM": "PM", "firstDayOfWeek": 1, "twoDigitYearMax": 2029, "mdy": "dmy", "M/d/yyyy": "dd/MM/yyyy", "dddd, MMMM dd, yyyy": "dddd, d' ta' 'MMMM yyyy", "h:mm tt": "HH:mm:ss", "h:mm:ss tt": "HH:mm:ss", "dddd, MMMM dd, yyyy h:mm:ss tt": "dddd, d' ta' 'MMMM yyyy HH:mm:ss", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "MMMM dd", "MMMM, yyyy": "MMMM yyyy", "/jan(uary)?/": "jan(nar)?", "/feb(ruary)?/": "fra(r)?", "/mar(ch)?/": "mar(zu)?", "/apr(il)?/": "apr(il)?", "/may/": "mej(ju)?", "/jun(e)?/": "ġun(ju)?", "/jul(y)?/": "lul(ju)?", "/aug(ust)?/": "awi(ssu)?", "/sep(t(ember)?)?/": "set(tembru)?", "/oct(ober)?/": "ott(ubru)?", "/nov(ember)?/": "nov(embru)?", "/dec(ember)?/": "diċ(embru)?", "/^su(n(day)?)?/": "^il-ħadd", "/^mo(n(day)?)?/": "^it-tnejn", "/^tu(e(s(day)?)?)?/": "^it-tlieta", "/^we(d(nesday)?)?/": "^l-erbgħa", "/^th(u(r(s(day)?)?)?)?/": "^il-ħamis", "/^fr(i(day)?)?/": "^il-ġimgħa", "/^sa(t(urday)?)?/": "^is-sibt", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "mt-MT"; ================================================ FILE: src/i18n/nb-NO.js ================================================ /* * DateJS Culture String File * Country Code: nb-NO * Name: Norwegian, Bokmål (Norway) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["nb-NO"] = { "name": "nb-NO", "englishName": "Norwegian, Bokmål (Norway)", "nativeName": "norsk, bokmål (Norge)", "Sunday": "søndag", "Monday": "mandag", "Tuesday": "tirsdag", "Wednesday": "onsdag", "Thursday": "torsdag", "Friday": "fredag", "Saturday": "lørdag", "Sun": "sø", "Mon": "ma", "Tue": "ti", "Wed": "on", "Thu": "to", "Fri": "fr", "Sat": "lø", "Su": "sø", "Mo": "ma", "Tu": "ti", "We": "on", "Th": "to", "Fr": "fr", "Sa": "lø", "S_Sun_Initial": "s", "M_Mon_Initial": "m", "T_Tue_Initial": "t", "W_Wed_Initial": "o", "T_Thu_Initial": "t", "F_Fri_Initial": "f", "S_Sat_Initial": "l", "January": "januar", "February": "februar", "March": "mars", "April": "april", "May": "mai", "June": "juni", "July": "juli", "August": "august", "September": "september", "October": "oktober", "November": "november", "December": "desember", "Jan_Abbr": "jan", "Feb_Abbr": "feb", "Mar_Abbr": "mar", "Apr_Abbr": "apr", "May_Abbr": "mai", "Jun_Abbr": "jun", "Jul_Abbr": "jul", "Aug_Abbr": "aug", "Sep_Abbr": "sep", "Oct_Abbr": "okt", "Nov_Abbr": "nov", "Dec_Abbr": "des", "AM": "", "PM": "", "firstDayOfWeek": 1, "twoDigitYearMax": 2029, "mdy": "dmy", "M/d/yyyy": "dd.MM.yyyy", "dddd, MMMM dd, yyyy": "d. MMMM yyyy", "h:mm tt": "HH:mm", "h:mm:ss tt": "HH:mm:ss", "dddd, MMMM dd, yyyy h:mm:ss tt": "d. MMMM yyyy HH:mm:ss", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "d. MMMM", "MMMM, yyyy": "MMMM yyyy", "/jan(uary)?/": "jan(uar)?", "/feb(ruary)?/": "feb(ruar)?", "/mar(ch)?/": "mar(s)?", "/apr(il)?/": "apr(il)?", "/may/": "mai", "/jun(e)?/": "jun(i)?", "/jul(y)?/": "jul(i)?", "/aug(ust)?/": "aug(ust)?", "/sep(t(ember)?)?/": "sep(t(ember)?)?", "/oct(ober)?/": "okt(ober)?", "/nov(ember)?/": "nov(ember)?", "/dec(ember)?/": "des(ember)?", "/^su(n(day)?)?/": "^søndag", "/^mo(n(day)?)?/": "^mandag", "/^tu(e(s(day)?)?)?/": "^tirsdag", "/^we(d(nesday)?)?/": "^onsdag", "/^th(u(r(s(day)?)?)?)?/": "^torsdag", "/^fr(i(day)?)?/": "^fredag", "/^sa(t(urday)?)?/": "^lørdag", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "nb-NO"; ================================================ FILE: src/i18n/nl-BE.js ================================================ /* * DateJS Culture String File * Country Code: nl-BE * Name: Dutch (Belgium) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["nl-BE"] = { "name": "nl-BE", "englishName": "Dutch (Belgium)", "nativeName": "Nederlands (België)", "Sunday": "zondag", "Monday": "maandag", "Tuesday": "dinsdag", "Wednesday": "woensdag", "Thursday": "donderdag", "Friday": "vrijdag", "Saturday": "zaterdag", "Sun": "zo", "Mon": "ma", "Tue": "di", "Wed": "wo", "Thu": "do", "Fri": "vr", "Sat": "za", "Su": "zo", "Mo": "ma", "Tu": "di", "We": "wo", "Th": "do", "Fr": "vr", "Sa": "za", "S_Sun_Initial": "z", "M_Mon_Initial": "m", "T_Tue_Initial": "d", "W_Wed_Initial": "w", "T_Thu_Initial": "d", "F_Fri_Initial": "v", "S_Sat_Initial": "z", "January": "januari", "February": "februari", "March": "maart", "April": "april", "May": "mei", "June": "juni", "July": "juli", "August": "augustus", "September": "september", "October": "oktober", "November": "november", "December": "december", "Jan_Abbr": "jan", "Feb_Abbr": "feb", "Mar_Abbr": "mrt", "Apr_Abbr": "apr", "May_Abbr": "mei", "Jun_Abbr": "jun", "Jul_Abbr": "jul", "Aug_Abbr": "aug", "Sep_Abbr": "sep", "Oct_Abbr": "okt", "Nov_Abbr": "nov", "Dec_Abbr": "dec", "AM": "", "PM": "", "firstDayOfWeek": 1, "twoDigitYearMax": 2029, "mdy": "dmy", "M/d/yyyy": "d/MM/yyyy", "dddd, MMMM dd, yyyy": "dddd d MMMM yyyy", "h:mm tt": "H:mm", "h:mm:ss tt": "H:mm:ss", "dddd, MMMM dd, yyyy h:mm:ss tt": "dddd d MMMM yyyy H:mm:ss", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "dd MMMM", "MMMM, yyyy": "MMMM yyyy", "/jan(uary)?/": "jan(uari)?", "/feb(ruary)?/": "feb(ruari)?", "/mar(ch)?/": "maart", "/apr(il)?/": "apr(il)?", "/may/": "mei", "/jun(e)?/": "jun(i)?", "/jul(y)?/": "jul(i)?", "/aug(ust)?/": "aug(ustus)?", "/sep(t(ember)?)?/": "sep(t(ember)?)?", "/oct(ober)?/": "okt(ober)?", "/nov(ember)?/": "nov(ember)?", "/dec(ember)?/": "dec(ember)?", "/^su(n(day)?)?/": "^zondag", "/^mo(n(day)?)?/": "^maandag", "/^tu(e(s(day)?)?)?/": "^dinsdag", "/^we(d(nesday)?)?/": "^woensdag", "/^th(u(r(s(day)?)?)?)?/": "^donderdag", "/^fr(i(day)?)?/": "^vrijdag", "/^sa(t(urday)?)?/": "^zaterdag", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "nl-BE"; ================================================ FILE: src/i18n/nl-NL.js ================================================ /* * DateJS Culture String File * Country Code: nl-NL * Name: Dutch (Netherlands) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["nl-NL"] = { "name": "nl-NL", "englishName": "Dutch (Netherlands)", "nativeName": "Nederlands (Nederland)", "Sunday": "zondag", "Monday": "maandag", "Tuesday": "dinsdag", "Wednesday": "woensdag", "Thursday": "donderdag", "Friday": "vrijdag", "Saturday": "zaterdag", "Sun": "zo", "Mon": "ma", "Tue": "di", "Wed": "wo", "Thu": "do", "Fri": "vr", "Sat": "za", "Su": "zo", "Mo": "ma", "Tu": "di", "We": "wo", "Th": "do", "Fr": "vr", "Sa": "za", "S_Sun_Initial": "z", "M_Mon_Initial": "m", "T_Tue_Initial": "d", "W_Wed_Initial": "w", "T_Thu_Initial": "d", "F_Fri_Initial": "v", "S_Sat_Initial": "z", "January": "januari", "February": "februari", "March": "maart", "April": "april", "May": "mei", "June": "juni", "July": "juli", "August": "augustus", "September": "september", "October": "oktober", "November": "november", "December": "december", "Jan_Abbr": "jan", "Feb_Abbr": "feb", "Mar_Abbr": "mrt", "Apr_Abbr": "apr", "May_Abbr": "mei", "Jun_Abbr": "jun", "Jul_Abbr": "jul", "Aug_Abbr": "aug", "Sep_Abbr": "sep", "Oct_Abbr": "okt", "Nov_Abbr": "nov", "Dec_Abbr": "dec", "AM": "", "PM": "", "firstDayOfWeek": 1, "twoDigitYearMax": 2029, "mdy": "dmy", "M/d/yyyy": "d-M-yyyy", "dddd, MMMM dd, yyyy": "dddd d MMMM yyyy", "h:mm tt": "H:mm", "h:mm:ss tt": "H:mm:ss", "dddd, MMMM dd, yyyy h:mm:ss tt": "dddd d MMMM yyyy H:mm:ss", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "dd MMMM", "MMMM, yyyy": "MMMM yyyy", "/jan(uary)?/": "jan(uari)?", "/feb(ruary)?/": "feb(ruari)?", "/mar(ch)?/": "maart", "/apr(il)?/": "apr(il)?", "/may/": "mei", "/jun(e)?/": "jun(i)?", "/jul(y)?/": "jul(i)?", "/aug(ust)?/": "aug(ustus)?", "/sep(t(ember)?)?/": "sep(t(ember)?)?", "/oct(ober)?/": "okt(ober)?", "/nov(ember)?/": "nov(ember)?", "/dec(ember)?/": "dec(ember)?", "/^su(n(day)?)?/": "^zondag", "/^mo(n(day)?)?/": "^maandag", "/^tu(e(s(day)?)?)?/": "^dinsdag", "/^we(d(nesday)?)?/": "^woensdag", "/^th(u(r(s(day)?)?)?)?/": "^donderdag", "/^fr(i(day)?)?/": "^vrijdag", "/^sa(t(urday)?)?/": "^zaterdag", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "nl-NL"; ================================================ FILE: src/i18n/nn-NO.js ================================================ /* * DateJS Culture String File * Country Code: nn-NO * Name: Norwegian, Nynorsk (Norway) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["nn-NO"] = { "name": "nn-NO", "englishName": "Norwegian, Nynorsk (Norway)", "nativeName": "norsk, nynorsk (Noreg)", "Sunday": "søndag", "Monday": "måndag", "Tuesday": "tysdag", "Wednesday": "onsdag", "Thursday": "torsdag", "Friday": "fredag", "Saturday": "laurdag", "Sun": "sø", "Mon": "må", "Tue": "ty", "Wed": "on", "Thu": "to", "Fri": "fr", "Sat": "la", "Su": "sø", "Mo": "må", "Tu": "ty", "We": "on", "Th": "to", "Fr": "fr", "Sa": "la", "S_Sun_Initial": "s", "M_Mon_Initial": "m", "T_Tue_Initial": "t", "W_Wed_Initial": "o", "T_Thu_Initial": "t", "F_Fri_Initial": "f", "S_Sat_Initial": "l", "January": "januar", "February": "februar", "March": "mars", "April": "april", "May": "mai", "June": "juni", "July": "juli", "August": "august", "September": "september", "October": "oktober", "November": "november", "December": "desember", "Jan_Abbr": "jan", "Feb_Abbr": "feb", "Mar_Abbr": "mar", "Apr_Abbr": "apr", "May_Abbr": "mai", "Jun_Abbr": "jun", "Jul_Abbr": "jul", "Aug_Abbr": "aug", "Sep_Abbr": "sep", "Oct_Abbr": "okt", "Nov_Abbr": "nov", "Dec_Abbr": "des", "AM": "", "PM": "", "firstDayOfWeek": 1, "twoDigitYearMax": 2029, "mdy": "dmy", "M/d/yyyy": "dd.MM.yyyy", "dddd, MMMM dd, yyyy": "d. MMMM yyyy", "h:mm tt": "HH:mm", "h:mm:ss tt": "HH:mm:ss", "dddd, MMMM dd, yyyy h:mm:ss tt": "d. MMMM yyyy HH:mm:ss", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "d. MMMM", "MMMM, yyyy": "MMMM yyyy", "/jan(uary)?/": "jan(uar)?", "/feb(ruary)?/": "feb(ruar)?", "/mar(ch)?/": "mar(s)?", "/apr(il)?/": "apr(il)?", "/may/": "mai", "/jun(e)?/": "jun(i)?", "/jul(y)?/": "jul(i)?", "/aug(ust)?/": "aug(ust)?", "/sep(t(ember)?)?/": "sep(t(ember)?)?", "/oct(ober)?/": "okt(ober)?", "/nov(ember)?/": "nov(ember)?", "/dec(ember)?/": "des(ember)?", "/^su(n(day)?)?/": "^søndag", "/^mo(n(day)?)?/": "^måndag", "/^tu(e(s(day)?)?)?/": "^tysdag", "/^we(d(nesday)?)?/": "^onsdag", "/^th(u(r(s(day)?)?)?)?/": "^torsdag", "/^fr(i(day)?)?/": "^fredag", "/^sa(t(urday)?)?/": "^laurdag", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "nn-NO"; ================================================ FILE: src/i18n/ns-ZA.js ================================================ /* * DateJS Culture String File * Country Code: ns-ZA * Name: Northern Sotho (South Africa) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["ns-ZA"] = { "name": "ns-ZA", "englishName": "Northern Sotho (South Africa)", "nativeName": "Sesotho sa Leboa (Afrika Borwa)", "Sunday": "Lamorena", "Monday": "Mošupologo", "Tuesday": "Labobedi", "Wednesday": "Laboraro", "Thursday": "Labone", "Friday": "Labohlano", "Saturday": "Mokibelo", "Sun": "Sun", "Mon": "Mon", "Tue": "Tue", "Wed": "Wed", "Thu": "Thu", "Fri": "Fri", "Sat": "Sat", "Su": "Sun", "Mo": "Mon", "Tu": "Tue", "We": "Wed", "Th": "Thu", "Fr": "Fri", "Sa": "Sat", "S_Sun_Initial": "S", "M_Mon_Initial": "M", "T_Tue_Initial": "T", "W_Wed_Initial": "W", "T_Thu_Initial": "T", "F_Fri_Initial": "F", "S_Sat_Initial": "S", "January": "Pherekgong", "February": "Hlakola", "March": "Mopitlo", "April": "Moranang", "May": "Mosegamanye", "June": "Ngoatobošego", "July": "Phuphu", "August": "Phato", "September": "Lewedi", "October": "Diphalana", "November": "Dibatsela", "December": "Manthole", "Jan_Abbr": "Jan", "Feb_Abbr": "Feb", "Mar_Abbr": "Mar", "Apr_Abbr": "Apr", "May_Abbr": "May", "Jun_Abbr": "Jun", "Jul_Abbr": "Jul", "Aug_Abbr": "Aug", "Sep_Abbr": "Sep", "Oct_Abbr": "Oct", "Nov_Abbr": "Nov", "Dec_Abbr": "Dec", "AM": "AM", "PM": "PM", "firstDayOfWeek": 0, "twoDigitYearMax": 2029, "mdy": "ymd", "M/d/yyyy": "yyyy/MM/dd", "dddd, MMMM dd, yyyy": "dd MMMM yyyy", "h:mm tt": "hh:mm:ss tt", "h:mm:ss tt": "hh:mm:ss tt", "dddd, MMMM dd, yyyy h:mm:ss tt": "dd MMMM yyyy hh:mm:ss tt", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "MMMM dd", "MMMM, yyyy": "MMMM yyyy", "/jan(uary)?/": "pherekgong", "/feb(ruary)?/": "hlakola", "/mar(ch)?/": "mopitlo", "/apr(il)?/": "moranang", "/may/": "mosegamanye", "/jun(e)?/": "ngoatobošego", "/jul(y)?/": "phuphu", "/aug(ust)?/": "phato", "/sep(t(ember)?)?/": "lewedi", "/oct(ober)?/": "diphalana", "/nov(ember)?/": "dibatsela", "/dec(ember)?/": "manthole", "/^su(n(day)?)?/": "^lamorena", "/^mo(n(day)?)?/": "^mošupologo", "/^tu(e(s(day)?)?)?/": "^labobedi", "/^we(d(nesday)?)?/": "^laboraro", "/^th(u(r(s(day)?)?)?)?/": "^labone", "/^fr(i(day)?)?/": "^labohlano", "/^sa(t(urday)?)?/": "^mokibelo", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "ns-ZA"; ================================================ FILE: src/i18n/pa-IN.js ================================================ /* * DateJS Culture String File * Country Code: pa-IN * Name: Punjabi (India) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["pa-IN"] = { "name": "pa-IN", "englishName": "Punjabi (India)", "nativeName": "ਪੰਜਾਬੀ (ਭਾਰਤ)", "Sunday": "ਐਤਵਾਰ", "Monday": "ਸੋਮਵਾਰ", "Tuesday": "ਮੰਗਲਵਾਰ", "Wednesday": "ਬੁਧਵਾਰ", "Thursday": "ਵੀਰਵਾਰ", "Friday": "ਸ਼ੁੱਕਰਵਾਰ", "Saturday": "ਸ਼ਨੀਚਰਵਾਰ", "Sun": "ਐਤ.", "Mon": "ਸੋਮ.", "Tue": "ਮੰਗਲ.", "Wed": "ਬੁਧ.", "Thu": "ਵੀਰ.", "Fri": "ਸ਼ੁਕਰ.", "Sat": "ਸ਼ਨੀ.", "Su": "ਐ", "Mo": "ਸ", "Tu": "ਮ", "We": "ਬ", "Th": "ਵ", "Fr": "ਸ਼", "Sa": "ਸ਼", "S_Sun_Initial": "ਐ", "M_Mon_Initial": "ਸ", "T_Tue_Initial": "ਮ", "W_Wed_Initial": "ਬ", "T_Thu_Initial": "ਵ", "F_Fri_Initial": "ਸ਼", "S_Sat_Initial": "ਸ਼", "January": "ਜਨਵਰੀ", "February": "ਫ਼ਰਵਰੀ", "March": "ਮਾਰਚ", "April": "ਅਪ੍ਰੈਲ", "May": "ਮਈ", "June": "ਜੂਨ", "July": "ਜੁਲਾਈ", "August": "ਅਗਸਤ", "September": "ਸਤੰਬਰ", "October": "ਅਕਤੂਬਰ", "November": "ਨਵੰਬਰ", "December": "ਦਸੰਬਰ", "Jan_Abbr": "ਜਨਵਰੀ", "Feb_Abbr": "ਫ਼ਰਵਰੀ", "Mar_Abbr": "ਮਾਰਚ", "Apr_Abbr": "ਅਪ੍ਰੈਲ", "May_Abbr": "ਮਈ", "Jun_Abbr": "ਜੂਨ", "Jul_Abbr": "ਜੁਲਾਈ", "Aug_Abbr": "ਅਗਸਤ", "Sep_Abbr": "ਸਤੰਬਰ", "Oct_Abbr": "ਅਕਤੂਬਰ", "Nov_Abbr": "ਨਵੰਬਰ", "Dec_Abbr": "ਦਸੰਬਰ", "AM": "ਸਵੇਰੇ", "PM": "ਸ਼ਾਮ", "firstDayOfWeek": 1, "twoDigitYearMax": 2029, "mdy": "dmy", "M/d/yyyy": "dd-MM-yy", "dddd, MMMM dd, yyyy": "dd MMMM yyyy dddd", "h:mm tt": "tt hh:mm", "h:mm:ss tt": "tt hh:mm:ss", "dddd, MMMM dd, yyyy h:mm:ss tt": "dd MMMM yyyy dddd tt hh:mm:ss", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "dd MMMM", "MMMM, yyyy": "MMMM, yyyy", "/jan(uary)?/": "ਜਨਵਰੀ", "/feb(ruary)?/": "ਫ਼ਰਵਰੀ", "/mar(ch)?/": "ਮਾਰਚ", "/apr(il)?/": "ਅਪ੍ਰੈਲ", "/may/": "ਮਈ", "/jun(e)?/": "ਜੂਨ", "/jul(y)?/": "ਜੁਲਾਈ", "/aug(ust)?/": "ਅਗਸਤ", "/sep(t(ember)?)?/": "ਸਤੰਬਰ", "/oct(ober)?/": "ਅਕਤੂਬਰ", "/nov(ember)?/": "ਨਵੰਬਰ", "/dec(ember)?/": "ਦਸੰਬਰ", "/^su(n(day)?)?/": "^ਐ(ਤ(.(ਵਾਰ)?)?)?", "/^mo(n(day)?)?/": "^ਸ(ੋਮ(.(ਵਾਰ)?)?)?", "/^tu(e(s(day)?)?)?/": "^ਮ(ੰਗਲ(.(ਵਾਰ)?)?)?", "/^we(d(nesday)?)?/": "^ਬ(ੁਧ(.(ਵਾਰ)?)?)?", "/^th(u(r(s(day)?)?)?)?/": "^ਵ(ੀਰ(.(ਵਾਰ)?)?)?", "/^fr(i(day)?)?/": "^ਸ਼(ੁਕਰ(.(ਰਵਾਰ)?)?)?", "/^sa(t(urday)?)?/": "^ਸ਼(ਨੀ(.(ਚਰਵਾਰ)?)?)?", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "pa-IN"; ================================================ FILE: src/i18n/pl-PL.js ================================================ /* * DateJS Culture String File * Country Code: pl-PL * Name: Polish (Poland) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["pl-PL"] = { "name": "pl-PL", "englishName": "Polish (Poland)", "nativeName": "polski (Polska)", "Sunday": "niedziela", "Monday": "poniedziałek", "Tuesday": "wtorek", "Wednesday": "środa", "Thursday": "czwartek", "Friday": "piątek", "Saturday": "sobota", "Sun": "N", "Mon": "Pn", "Tue": "Wt", "Wed": "Śr", "Thu": "Cz", "Fri": "Pt", "Sat": "So", "Su": "N", "Mo": "Pn", "Tu": "Wt", "We": "Śr", "Th": "Cz", "Fr": "Pt", "Sa": "So", "S_Sun_Initial": "N", "M_Mon_Initial": "P", "T_Tue_Initial": "W", "W_Wed_Initial": "Ś", "T_Thu_Initial": "C", "F_Fri_Initial": "P", "S_Sat_Initial": "S", "January": "styczeń", "February": "luty", "March": "marzec", "April": "kwiecień", "May": "maj", "June": "czerwiec", "July": "lipiec", "August": "sierpień", "September": "wrzesień", "October": "październik", "November": "listopad", "December": "grudzień", "Jan_Abbr": "sty", "Feb_Abbr": "lut", "Mar_Abbr": "mar", "Apr_Abbr": "kwi", "May_Abbr": "maj", "Jun_Abbr": "cze", "Jul_Abbr": "lip", "Aug_Abbr": "sie", "Sep_Abbr": "wrz", "Oct_Abbr": "paź", "Nov_Abbr": "lis", "Dec_Abbr": "gru", "AM": "", "PM": "", "firstDayOfWeek": 1, "twoDigitYearMax": 2029, "mdy": "ymd", "M/d/yyyy": "yyyy-MM-dd", "dddd, MMMM dd, yyyy": "d MMMM yyyy", "h:mm tt": "HH:mm", "h:mm:ss tt": "HH:mm:ss", "dddd, MMMM dd, yyyy h:mm:ss tt": "d MMMM yyyy HH:mm:ss", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "d MMMM", "MMMM, yyyy": "MMMM yyyy", "/jan(uary)?/": "sty(czeń)?", "/feb(ruary)?/": "lut(y)?", "/mar(ch)?/": "mar(zec)?", "/apr(il)?/": "kwi(ecień)?", "/may/": "maj", "/jun(e)?/": "cze(rwiec)?", "/jul(y)?/": "lip(iec)?", "/aug(ust)?/": "sie(rpień)?", "/sep(t(ember)?)?/": "wrz(esień)?", "/oct(ober)?/": "paź(dziernik)?", "/nov(ember)?/": "lis(topad)?", "/dec(ember)?/": "gru(dzień)?", "/^su(n(day)?)?/": "^niedziela", "/^mo(n(day)?)?/": "^poniedziałek", "/^tu(e(s(day)?)?)?/": "^wtorek", "/^we(d(nesday)?)?/": "^środa", "/^th(u(r(s(day)?)?)?)?/": "^czwartek", "/^fr(i(day)?)?/": "^piątek", "/^sa(t(urday)?)?/": "^sobota", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "pl-PL"; ================================================ FILE: src/i18n/pt-BR.js ================================================ /* * DateJS Culture String File * Country Code: pt-BR * Name: Portuguese (Brazil) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["pt-BR"] = { "name": "pt-BR", "englishName": "Portuguese (Brazil)", "nativeName": "Português (Brasil)", "Sunday": "domingo", "Monday": "segunda-feira", "Tuesday": "terça-feira", "Wednesday": "quarta-feira", "Thursday": "quinta-feira", "Friday": "sexta-feira", "Saturday": "sábado", "Sun": "dom", "Mon": "seg", "Tue": "ter", "Wed": "qua", "Thu": "qui", "Fri": "sex", "Sat": "sáb", "Su": "dom", "Mo": "seg", "Tu": "ter", "We": "qua", "Th": "qui", "Fr": "sex", "Sa": "sáb", "S_Sun_Initial": "d", "M_Mon_Initial": "s", "T_Tue_Initial": "t", "W_Wed_Initial": "q", "T_Thu_Initial": "q", "F_Fri_Initial": "s", "S_Sat_Initial": "s", "January": "janeiro", "February": "fevereiro", "March": "março", "April": "abril", "May": "maio", "June": "junho", "July": "julho", "August": "agosto", "September": "setembro", "October": "outubro", "November": "novembro", "December": "dezembro", "Jan_Abbr": "jan", "Feb_Abbr": "fev", "Mar_Abbr": "mar", "Apr_Abbr": "abr", "May_Abbr": "mai", "Jun_Abbr": "jun", "Jul_Abbr": "jul", "Aug_Abbr": "ago", "Sep_Abbr": "set", "Oct_Abbr": "out", "Nov_Abbr": "nov", "Dec_Abbr": "dez", "AM": "", "PM": "", "firstDayOfWeek": 0, "twoDigitYearMax": 2029, "mdy": "dmy", "M/d/yyyy": "d/M/yyyy", "dddd, MMMM dd, yyyy": "dddd, d' de 'MMMM' de 'yyyy", "h:mm tt": "H:mm", "h:mm:ss tt": "H:mm:ss", "dddd, MMMM dd, yyyy h:mm:ss tt": "dddd, d' de 'MMMM' de 'yyyy H:mm:ss", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "dd' de 'MMMM", "MMMM, yyyy": "MMMM' de 'yyyy", "/jan(uary)?/": "jan(eiro)?", "/feb(ruary)?/": "fev(ereiro)?", "/mar(ch)?/": "mar(ço)?", "/apr(il)?/": "abr(il)?", "/may/": "mai(o)?", "/jun(e)?/": "jun(ho)?", "/jul(y)?/": "jul(ho)?", "/aug(ust)?/": "ago(sto)?", "/sep(t(ember)?)?/": "set(embro)?", "/oct(ober)?/": "out(ubro)?", "/nov(ember)?/": "nov(embro)?", "/dec(ember)?/": "dez(embro)?", "/^su(n(day)?)?/": "^domingo", "/^mo(n(day)?)?/": "^segunda-feira", "/^tu(e(s(day)?)?)?/": "^terça-feira", "/^we(d(nesday)?)?/": "^quarta-feira", "/^th(u(r(s(day)?)?)?)?/": "^quinta-feira", "/^fr(i(day)?)?/": "^sexta-feira", "/^sa(t(urday)?)?/": "^sábado", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "pt-BR"; ================================================ FILE: src/i18n/pt-PT.js ================================================ /* * DateJS Culture String File * Country Code: pt-PT * Name: Portuguese (Portugal) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["pt-PT"] = { "name": "pt-PT", "englishName": "Portuguese (Portugal)", "nativeName": "Português (Portugal)", "Sunday": "domingo", "Monday": "segunda-feira", "Tuesday": "terça-feira", "Wednesday": "quarta-feira", "Thursday": "quinta-feira", "Friday": "sexta-feira", "Saturday": "sábado", "Sun": "dom", "Mon": "seg", "Tue": "ter", "Wed": "qua", "Thu": "qui", "Fri": "sex", "Sat": "sáb", "Su": "dom", "Mo": "seg", "Tu": "ter", "We": "qua", "Th": "qui", "Fr": "sex", "Sa": "sáb", "S_Sun_Initial": "d", "M_Mon_Initial": "s", "T_Tue_Initial": "t", "W_Wed_Initial": "q", "T_Thu_Initial": "q", "F_Fri_Initial": "s", "S_Sat_Initial": "s", "January": "Janeiro", "February": "Fevereiro", "March": "Março", "April": "Abril", "May": "Maio", "June": "Junho", "July": "Julho", "August": "Agosto", "September": "Setembro", "October": "Outubro", "November": "Novembro", "December": "Dezembro", "Jan_Abbr": "Jan", "Feb_Abbr": "Fev", "Mar_Abbr": "Mar", "Apr_Abbr": "Abr", "May_Abbr": "Mai", "Jun_Abbr": "Jun", "Jul_Abbr": "Jul", "Aug_Abbr": "Ago", "Sep_Abbr": "Set", "Oct_Abbr": "Out", "Nov_Abbr": "Nov", "Dec_Abbr": "Dez", "AM": "", "PM": "", "firstDayOfWeek": 1, "twoDigitYearMax": 2029, "mdy": "dmy", "M/d/yyyy": "dd-MM-yyyy", "dddd, MMMM dd, yyyy": "dddd, d' de 'MMMM' de 'yyyy", "h:mm tt": "H:mm", "h:mm:ss tt": "H:mm:ss", "dddd, MMMM dd, yyyy h:mm:ss tt": "dddd, d' de 'MMMM' de 'yyyy H:mm:ss", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "d/M", "MMMM, yyyy": "MMMM' de 'yyyy", "/jan(uary)?/": "jan(eiro)?", "/feb(ruary)?/": "fev(ereiro)?", "/mar(ch)?/": "mar(ço)?", "/apr(il)?/": "abr(il)?", "/may/": "mai(o)?", "/jun(e)?/": "jun(ho)?", "/jul(y)?/": "jul(ho)?", "/aug(ust)?/": "ago(sto)?", "/sep(t(ember)?)?/": "set(embro)?", "/oct(ober)?/": "out(ubro)?", "/nov(ember)?/": "nov(embro)?", "/dec(ember)?/": "dez(embro)?", "/^su(n(day)?)?/": "^domingo", "/^mo(n(day)?)?/": "^segunda-feira", "/^tu(e(s(day)?)?)?/": "^terça-feira", "/^we(d(nesday)?)?/": "^quarta-feira", "/^th(u(r(s(day)?)?)?)?/": "^quinta-feira", "/^fr(i(day)?)?/": "^sexta-feira", "/^sa(t(urday)?)?/": "^sábado", "/^next/": "^prox(im(o(s)?|a(s)?))?", "/^last|past|prev(ious)?/": "^ant(erior(es)?)?|ult(im(o(s)?|a(s)?))?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|depois)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|antes)", "/^yes(terday)?/": "^ontem", "/^t(od(ay)?)?/": "^h(oje)?", "/^tom(orrow)?/": "^amanha", "/^n(ow)?/": "^a(gora)?", "/^ms|milli(second)?s?/": "^ms|milli(segundo)?s?", "/^sec(ond)?s?/": "^s(egundo)?s?", "/^mn|min(ute)?s?/": "^mn|min(uto)?s?", "/^h(our)?s?/": "^h(ora)?s?", "/^w(eek)?s?/": "^sem(ana)?s?", "/^m(onth)?s?/": "^m(e(se)?s?)?", "/^d(ay)?s?/": "^d(ia(s)?s?)?", "/^y(ear)?s?/": "^an((o)?s?)?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "pt-PT"; ================================================ FILE: src/i18n/quz-BO.js ================================================ /* * DateJS Culture String File * Country Code: quz-BO * Name: Quechua (Bolivia) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["quz-BO"] = { "name": "quz-BO", "englishName": "Quechua (Bolivia)", "nativeName": "runasimi (Bolivia Suyu)", "Sunday": "intichaw", "Monday": "killachaw", "Tuesday": "atipachaw", "Wednesday": "quyllurchaw", "Thursday": "Ch' askachaw", "Friday": "Illapachaw", "Saturday": "k'uychichaw", "Sun": "int", "Mon": "kil", "Tue": "ati", "Wed": "quy", "Thu": "Ch’", "Fri": "Ill", "Sat": "k'u", "Su": "int", "Mo": "kil", "Tu": "ati", "We": "quy", "Th": "Ch’", "Fr": "Ill", "Sa": "k'u", "S_Sun_Initial": "i", "M_Mon_Initial": "k", "T_Tue_Initial": "a", "W_Wed_Initial": "q", "T_Thu_Initial": "C", "F_Fri_Initial": "I", "S_Sat_Initial": "k", "January": "Qulla puquy", "February": "Hatun puquy", "March": "Pauqar waray", "April": "ayriwa", "May": "Aymuray", "June": "Inti raymi", "July": "Anta Sitwa", "August": "Qhapaq Sitwa", "September": "Uma raymi", "October": "Kantaray", "November": "Ayamarq'a", "December": "Kapaq Raymi", "Jan_Abbr": "Qul", "Feb_Abbr": "Hat", "Mar_Abbr": "Pau", "Apr_Abbr": "ayr", "May_Abbr": "Aym", "Jun_Abbr": "Int", "Jul_Abbr": "Ant", "Aug_Abbr": "Qha", "Sep_Abbr": "Uma", "Oct_Abbr": "Kan", "Nov_Abbr": "Aya", "Dec_Abbr": "Kap", "AM": "a.m.", "PM": "p.m.", "firstDayOfWeek": 0, "twoDigitYearMax": 2029, "mdy": "dmy", "M/d/yyyy": "dd/MM/yyyy", "dddd, MMMM dd, yyyy": "dddd, dd' de 'MMMM' de 'yyyy", "h:mm tt": "hh:mm:ss tt", "h:mm:ss tt": "hh:mm:ss tt", "dddd, MMMM dd, yyyy h:mm:ss tt": "dddd, dd' de 'MMMM' de 'yyyy hh:mm:ss tt", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "MMMM dd", "MMMM, yyyy": "MMMM' de 'yyyy", "/jan(uary)?/": "qul(la puquy)?", "/feb(ruary)?/": "hat(un puquy)?", "/mar(ch)?/": "pau(qar waray)?", "/apr(il)?/": "ayr(iwa)?", "/may/": "aym(uray)?", "/jun(e)?/": "int(i raymi)?", "/jul(y)?/": "ant(a sitwa)?", "/aug(ust)?/": "qha(paq sitwa)?", "/sep(t(ember)?)?/": "uma( raymi)?", "/oct(ober)?/": "kan(taray)?", "/nov(ember)?/": "aya(marq'a)?", "/dec(ember)?/": "kap(aq raymi)?", "/^su(n(day)?)?/": "^intichaw", "/^mo(n(day)?)?/": "^killachaw", "/^tu(e(s(day)?)?)?/": "^atipachaw", "/^we(d(nesday)?)?/": "^quyllurchaw", "/^th(u(r(s(day)?)?)?)?/": "^ch' askachaw", "/^fr(i(day)?)?/": "^illapachaw", "/^sa(t(urday)?)?/": "^k'uychichaw", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "quz-BO"; ================================================ FILE: src/i18n/quz-EC.js ================================================ /* * DateJS Culture String File * Country Code: quz-EC * Name: Quechua (Ecuador) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["quz-EC"] = { "name": "quz-EC", "englishName": "Quechua (Ecuador)", "nativeName": "runasimi (Ecuador Suyu)", "Sunday": "intichaw", "Monday": "killachaw", "Tuesday": "atipachaw", "Wednesday": "quyllurchaw", "Thursday": "Ch' askachaw", "Friday": "Illapachaw", "Saturday": "k'uychichaw", "Sun": "int", "Mon": "kil", "Tue": "ati", "Wed": "quy", "Thu": "Ch’", "Fri": "Ill", "Sat": "k'u", "Su": "int", "Mo": "kil", "Tu": "ati", "We": "quy", "Th": "Ch’", "Fr": "Ill", "Sa": "k'u", "S_Sun_Initial": "i", "M_Mon_Initial": "k", "T_Tue_Initial": "a", "W_Wed_Initial": "q", "T_Thu_Initial": "C", "F_Fri_Initial": "I", "S_Sat_Initial": "k", "January": "Qulla puquy", "February": "Hatun puquy", "March": "Pauqar waray", "April": "ayriwa", "May": "Aymuray", "June": "Inti raymi", "July": "Anta Sitwa", "August": "Qhapaq Sitwa", "September": "Uma raymi", "October": "Kantaray", "November": "Ayamarq'a", "December": "Kapaq Raymi", "Jan_Abbr": "Qul", "Feb_Abbr": "Hat", "Mar_Abbr": "Pau", "Apr_Abbr": "ayr", "May_Abbr": "Aym", "Jun_Abbr": "Int", "Jul_Abbr": "Ant", "Aug_Abbr": "Qha", "Sep_Abbr": "Uma", "Oct_Abbr": "Kan", "Nov_Abbr": "Aya", "Dec_Abbr": "Kap", "AM": "", "PM": "", "firstDayOfWeek": 0, "twoDigitYearMax": 2029, "mdy": "dmy", "M/d/yyyy": "dd/MM/yyyy", "dddd, MMMM dd, yyyy": "dddd, dd' de 'MMMM' de 'yyyy", "h:mm tt": "H:mm:ss", "h:mm:ss tt": "H:mm:ss", "dddd, MMMM dd, yyyy h:mm:ss tt": "dddd, dd' de 'MMMM' de 'yyyy H:mm:ss", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "MMMM dd", "MMMM, yyyy": "MMMM' de 'yyyy", "/jan(uary)?/": "qul(la puquy)?", "/feb(ruary)?/": "hat(un puquy)?", "/mar(ch)?/": "pau(qar waray)?", "/apr(il)?/": "ayr(iwa)?", "/may/": "aym(uray)?", "/jun(e)?/": "int(i raymi)?", "/jul(y)?/": "ant(a sitwa)?", "/aug(ust)?/": "qha(paq sitwa)?", "/sep(t(ember)?)?/": "uma( raymi)?", "/oct(ober)?/": "kan(taray)?", "/nov(ember)?/": "aya(marq'a)?", "/dec(ember)?/": "kap(aq raymi)?", "/^su(n(day)?)?/": "^intichaw", "/^mo(n(day)?)?/": "^killachaw", "/^tu(e(s(day)?)?)?/": "^atipachaw", "/^we(d(nesday)?)?/": "^quyllurchaw", "/^th(u(r(s(day)?)?)?)?/": "^ch' askachaw", "/^fr(i(day)?)?/": "^illapachaw", "/^sa(t(urday)?)?/": "^k'uychichaw", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "quz-EC"; ================================================ FILE: src/i18n/quz-PE.js ================================================ /* * DateJS Culture String File * Country Code: quz-PE * Name: Quechua (Peru) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["quz-PE"] = { "name": "quz-PE", "englishName": "Quechua (Peru)", "nativeName": "runasimi (Peru Suyu)", "Sunday": "intichaw", "Monday": "killachaw", "Tuesday": "atipachaw", "Wednesday": "quyllurchaw", "Thursday": "Ch' askachaw", "Friday": "Illapachaw", "Saturday": "k'uychichaw", "Sun": "int", "Mon": "kil", "Tue": "ati", "Wed": "quy", "Thu": "Ch’", "Fri": "Ill", "Sat": "k'u", "Su": "int", "Mo": "kil", "Tu": "ati", "We": "quy", "Th": "Ch’", "Fr": "Ill", "Sa": "k'u", "S_Sun_Initial": "i", "M_Mon_Initial": "k", "T_Tue_Initial": "a", "W_Wed_Initial": "q", "T_Thu_Initial": "C", "F_Fri_Initial": "I", "S_Sat_Initial": "k", "January": "Qulla puquy", "February": "Hatun puquy", "March": "Pauqar waray", "April": "ayriwa", "May": "Aymuray", "June": "Inti raymi", "July": "Anta Sitwa", "August": "Qhapaq Sitwa", "September": "Uma raymi", "October": "Kantaray", "November": "Ayamarq'a", "December": "Kapaq Raymi", "Jan_Abbr": "Qul", "Feb_Abbr": "Hat", "Mar_Abbr": "Pau", "Apr_Abbr": "ayr", "May_Abbr": "Aym", "Jun_Abbr": "Int", "Jul_Abbr": "Ant", "Aug_Abbr": "Qha", "Sep_Abbr": "Uma", "Oct_Abbr": "Kan", "Nov_Abbr": "Aya", "Dec_Abbr": "Kap", "AM": "a.m.", "PM": "p.m.", "firstDayOfWeek": 0, "twoDigitYearMax": 2029, "mdy": "dmy", "M/d/yyyy": "dd/MM/yyyy", "dddd, MMMM dd, yyyy": "dddd, dd' de 'MMMM' de 'yyyy", "h:mm tt": "hh:mm:ss tt", "h:mm:ss tt": "hh:mm:ss tt", "dddd, MMMM dd, yyyy h:mm:ss tt": "dddd, dd' de 'MMMM' de 'yyyy hh:mm:ss tt", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "MMMM dd", "MMMM, yyyy": "MMMM' de 'yyyy", "/jan(uary)?/": "qul(la puquy)?", "/feb(ruary)?/": "hat(un puquy)?", "/mar(ch)?/": "pau(qar waray)?", "/apr(il)?/": "ayr(iwa)?", "/may/": "aym(uray)?", "/jun(e)?/": "int(i raymi)?", "/jul(y)?/": "ant(a sitwa)?", "/aug(ust)?/": "qha(paq sitwa)?", "/sep(t(ember)?)?/": "uma( raymi)?", "/oct(ober)?/": "kan(taray)?", "/nov(ember)?/": "aya(marq'a)?", "/dec(ember)?/": "kap(aq raymi)?", "/^su(n(day)?)?/": "^intichaw", "/^mo(n(day)?)?/": "^killachaw", "/^tu(e(s(day)?)?)?/": "^atipachaw", "/^we(d(nesday)?)?/": "^quyllurchaw", "/^th(u(r(s(day)?)?)?)?/": "^ch' askachaw", "/^fr(i(day)?)?/": "^illapachaw", "/^sa(t(urday)?)?/": "^k'uychichaw", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "quz-PE"; ================================================ FILE: src/i18n/ro-RO.js ================================================ /* * DateJS Culture String File * Country Code: ro-RO * Name: Romanian (Romania) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["ro-RO"] = { "name": "ro-RO", "englishName": "Romanian (Romania)", "nativeName": "română (România)", "Sunday": "duminică", "Monday": "luni", "Tuesday": "marţi", "Wednesday": "miercuri", "Thursday": "joi", "Friday": "vineri", "Saturday": "sâmbătă", "Sun": "D", "Mon": "L", "Tue": "Ma", "Wed": "Mi", "Thu": "J", "Fri": "V", "Sat": "S", "Su": "D", "Mo": "L", "Tu": "Ma", "We": "Mi", "Th": "J", "Fr": "V", "Sa": "S", "S_Sun_Initial": "D", "M_Mon_Initial": "L", "T_Tue_Initial": "M", "W_Wed_Initial": "M", "T_Thu_Initial": "J", "F_Fri_Initial": "V", "S_Sat_Initial": "S", "January": "ianuarie", "February": "februarie", "March": "martie", "April": "aprilie", "May": "mai", "June": "iunie", "July": "iulie", "August": "august", "September": "septembrie", "October": "octombrie", "November": "noiembrie", "December": "decembrie", "Jan_Abbr": "ian.", "Feb_Abbr": "feb.", "Mar_Abbr": "mar.", "Apr_Abbr": "apr.", "May_Abbr": "mai.", "Jun_Abbr": "iun.", "Jul_Abbr": "iul.", "Aug_Abbr": "aug.", "Sep_Abbr": "sep.", "Oct_Abbr": "oct.", "Nov_Abbr": "nov.", "Dec_Abbr": "dec.", "AM": "", "PM": "", "firstDayOfWeek": 1, "twoDigitYearMax": 2029, "mdy": "dmy", "M/d/yyyy": "dd.MM.yyyy", "dddd, MMMM dd, yyyy": "d MMMM yyyy", "h:mm tt": "HH:mm", "h:mm:ss tt": "HH:mm:ss", "dddd, MMMM dd, yyyy h:mm:ss tt": "d MMMM yyyy HH:mm:ss", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "d MMMM", "MMMM, yyyy": "MMMM yyyy", "/jan(uary)?/": "ian(.(uarie)?)?", "/feb(ruary)?/": "feb(.(ruarie)?)?", "/mar(ch)?/": "mar(.(tie)?)?", "/apr(il)?/": "apr(.(ilie)?)?", "/may/": "mai(.()?)?", "/jun(e)?/": "iun(.(ie)?)?", "/jul(y)?/": "iul(.(ie)?)?", "/aug(ust)?/": "aug(.(ust)?)?", "/sep(t(ember)?)?/": "sep(.(tembrie)?)?", "/oct(ober)?/": "oct(.(ombrie)?)?", "/nov(ember)?/": "noiembrie", "/dec(ember)?/": "dec(.(embrie)?)?", "/^su(n(day)?)?/": "^duminică", "/^mo(n(day)?)?/": "^luni", "/^tu(e(s(day)?)?)?/": "^marţi", "/^we(d(nesday)?)?/": "^miercuri", "/^th(u(r(s(day)?)?)?)?/": "^joi", "/^fr(i(day)?)?/": "^vineri", "/^sa(t(urday)?)?/": "^sâmbătă", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "ro-RO"; ================================================ FILE: src/i18n/ru-RU.js ================================================ /* * DateJS Culture String File * Country Code: ru-RU * Name: Russian (Russia) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["ru-RU"] = { "name": "ru-RU", "englishName": "Russian (Russia)", "nativeName": "Pусский (Россия)", "Sunday": "воскресенье", "Monday": "понедельник", "Tuesday": "вторник", "Wednesday": "среда", "Thursday": "четверг", "Friday": "пятница", "Saturday": "суббота", "Sun": "Вс", "Mon": "Пн", "Tue": "Вт", "Wed": "Ср", "Thu": "Чт", "Fri": "Пт", "Sat": "Сб", "Su": "Вс", "Mo": "Пн", "Tu": "Вт", "We": "Ср", "Th": "Чт", "Fr": "Пт", "Sa": "Сб", "S_Sun_Initial": "В", "M_Mon_Initial": "П", "T_Tue_Initial": "В", "W_Wed_Initial": "С", "T_Thu_Initial": "Ч", "F_Fri_Initial": "П", "S_Sat_Initial": "С", "January": "Январь", "February": "Февраль", "March": "Март", "April": "Апрель", "May": "Май", "June": "Июнь", "July": "Июль", "August": "Август", "September": "Сентябрь", "October": "Октябрь", "November": "Ноябрь", "December": "Декабрь", "Jan_Abbr": "янв", "Feb_Abbr": "фев", "Mar_Abbr": "мар", "Apr_Abbr": "апр", "May_Abbr": "май", "Jun_Abbr": "июн", "Jul_Abbr": "июл", "Aug_Abbr": "авг", "Sep_Abbr": "сен", "Oct_Abbr": "окт", "Nov_Abbr": "ноя", "Dec_Abbr": "дек", "AM": "", "PM": "", "firstDayOfWeek": 1, "twoDigitYearMax": 2029, "mdy": "dmy", "M/d/yyyy": "dd.MM.yyyy", "dddd, MMMM dd, yyyy": "d MMMM yyyy 'г.'", "h:mm tt": "H:mm", "h:mm:ss tt": "H:mm:ss", "dddd, MMMM dd, yyyy h:mm:ss tt": "d MMMM yyyy 'г.' H:mm:ss", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "MMMM dd", "MMMM, yyyy": "MMMM yyyy 'г.'", "/jan(uary)?/": "янв(арь)?", "/feb(ruary)?/": "фев(раль)?", "/mar(ch)?/": "мар(т)?", "/apr(il)?/": "апр(ель)?", "/may/": "май", "/jun(e)?/": "июн(ь)?", "/jul(y)?/": "июл(ь)?", "/aug(ust)?/": "авг(уст)?", "/sep(t(ember)?)?/": "сен(тябрь)?", "/oct(ober)?/": "окт(ябрь)?", "/nov(ember)?/": "ноя(брь)?", "/dec(ember)?/": "дек(абрь)?", "/^su(n(day)?)?/": "^воскресенье", "/^mo(n(day)?)?/": "^понедельник", "/^tu(e(s(day)?)?)?/": "^вторник", "/^we(d(nesday)?)?/": "^среда", "/^th(u(r(s(day)?)?)?)?/": "^четверг", "/^fr(i(day)?)?/": "^пятница", "/^sa(t(urday)?)?/": "^суббота", "/^next/": "^след|завтра", "/^last|past|prev(ious)?/": "^пред|вчера", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|через|после|вперед|и|следую?щ(ая|ий|ее)?)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|за|до|поза|пе?ред((ыдущ|шев?ствующ)(ая|ий|ее))|назад)", "/^yes(terday)?/": "^вчера", "/^t(od(ay)?)?/": "^сегодня", "/^tom(orrow)?/": "^завтра", "/^n(ow)?/": "^сейчас|сечас|щас", "/^ms|milli(second)?s?/": "^мс|мили(секунд)?s?", "/^sec(ond)?s?/": "^с(ек(унд)?)?", "/^mn|min(ute)?s?/": "^м(ин(ут)?)?", "/^h(our)?s?/": "^ч((ас)?ов)?", "/^w(eek)?s?/": "^н(ед(ель)?)?", "/^m(onth)?s?/": "^мес(яцев)?", "/^d(ay)?s?/": "^д(ень|ней|ня)?", "/^y(ear)?s?/": "^г(ода?)?|л(ет)?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "ru-RU"; ================================================ FILE: src/i18n/sa-IN.js ================================================ /* * DateJS Culture String File * Country Code: sa-IN * Name: Sanskrit (India) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["sa-IN"] = { "name": "sa-IN", "englishName": "Sanskrit (India)", "nativeName": "संस्कृत (भारतम्)", "Sunday": "रविवासरः", "Monday": "सोमवासरः", "Tuesday": "मङ्गलवासरः", "Wednesday": "बुधवासरः", "Thursday": "गुरुवासरः", "Friday": "शुक्रवासरः", "Saturday": "शनिवासरः", "Sun": "रविवासरः", "Mon": "सोमवासरः", "Tue": "मङ्गलवासरः", "Wed": "बुधवासरः", "Thu": "गुरुवासरः", "Fri": "शुक्रवासरः", "Sat": "शनिवासरः", "Su": "र", "Mo": "स", "Tu": "म", "We": "ब", "Th": "ग", "Fr": "श", "Sa": "श", "S_Sun_Initial": "र", "M_Mon_Initial": "स", "T_Tue_Initial": "म", "W_Wed_Initial": "ब", "T_Thu_Initial": "ग", "F_Fri_Initial": "श", "S_Sat_Initial": "श", "January": "जनवरी", "February": "फरवरी", "March": "मार्च", "April": "अप्रैल", "May": "मई", "June": "जून", "July": "जुलाई", "August": "अगस्त", "September": "सितम्बर", "October": "अक्तूबर", "November": "नवम्बर", "December": "दिसम्बर", "Jan_Abbr": "जनवरी", "Feb_Abbr": "फरवरी", "Mar_Abbr": "मार्च", "Apr_Abbr": "अप्रैल", "May_Abbr": "मई", "Jun_Abbr": "जून", "Jul_Abbr": "जुलाई", "Aug_Abbr": "अगस्त", "Sep_Abbr": "सितम्बर", "Oct_Abbr": "अक्तूबर", "Nov_Abbr": "नवम्बर", "Dec_Abbr": "दिसम्बर", "AM": "पूर्वाह्न", "PM": "अपराह्न", "firstDayOfWeek": 0, "twoDigitYearMax": 2029, "mdy": "dmy", "M/d/yyyy": "dd-MM-yyyy", "dddd, MMMM dd, yyyy": "dd MMMM yyyy dddd", "h:mm tt": "HH:mm", "h:mm:ss tt": "HH:mm:ss", "dddd, MMMM dd, yyyy h:mm:ss tt": "dd MMMM yyyy dddd HH:mm:ss", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "dd MMMM", "MMMM, yyyy": "MMMM, yyyy", "/jan(uary)?/": "जनवरी", "/feb(ruary)?/": "फरवरी", "/mar(ch)?/": "मार्च", "/apr(il)?/": "अप्रैल", "/may/": "मई", "/jun(e)?/": "जून", "/jul(y)?/": "जुलाई", "/aug(ust)?/": "अगस्त", "/sep(t(ember)?)?/": "सितम्बर", "/oct(ober)?/": "अक्तूबर", "/nov(ember)?/": "नवम्बर", "/dec(ember)?/": "दिसम्बर", "/^su(n(day)?)?/": "^र(1)?", "/^mo(n(day)?)?/": "^स(1)?", "/^tu(e(s(day)?)?)?/": "^म(1)?", "/^we(d(nesday)?)?/": "^ब(1)?", "/^th(u(r(s(day)?)?)?)?/": "^ग(1)?", "/^fr(i(day)?)?/": "^श(1)?", "/^sa(t(urday)?)?/": "^श(1)?", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "sa-IN"; ================================================ FILE: src/i18n/se-FI.js ================================================ /* * DateJS Culture String File * Country Code: se-FI * Name: Sami (Northern) (Finland) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["se-FI"] = { "name": "se-FI", "englishName": "Sami (Northern) (Finland)", "nativeName": "davvisámegiella (Suopma)", "Sunday": "sotnabeaivi", "Monday": "vuossárga", "Tuesday": "maŋŋebárga", "Wednesday": "gaskavahkku", "Thursday": "duorastat", "Friday": "bearjadat", "Saturday": "lávvardat", "Sun": "sotn", "Mon": "vuos", "Tue": "maŋ", "Wed": "gask", "Thu": "duor", "Fri": "bear", "Sat": "láv", "Su": "sotn", "Mo": "vuos", "Tu": "maŋ", "We": "gask", "Th": "duor", "Fr": "bear", "Sa": "láv", "S_Sun_Initial": "s", "M_Mon_Initial": "v", "T_Tue_Initial": "m", "W_Wed_Initial": "g", "T_Thu_Initial": "d", "F_Fri_Initial": "b", "S_Sat_Initial": "l", "January": "ođđajagemánnu", "February": "guovvamánnu", "March": "njukčamánnu", "April": "cuoŋománnu", "May": "miessemánnu", "June": "geassemánnu", "July": "suoidnemánnu", "August": "borgemánnu", "September": "čakčamánnu", "October": "golggotmánnu", "November": "skábmamánnu", "December": "juovlamánnu", "Jan_Abbr": "ođđj", "Feb_Abbr": "guov", "Mar_Abbr": "njuk", "Apr_Abbr": "cuo", "May_Abbr": "mies", "Jun_Abbr": "geas", "Jul_Abbr": "suoi", "Aug_Abbr": "borg", "Sep_Abbr": "čakč", "Oct_Abbr": "golg", "Nov_Abbr": "skáb", "Dec_Abbr": "juov", "AM": "", "PM": "", "firstDayOfWeek": 1, "twoDigitYearMax": 2029, "mdy": "dmy", "M/d/yyyy": "d.M.yyyy", "dddd, MMMM dd, yyyy": "MMMM d'. b. 'yyyy", "h:mm tt": "H:mm:ss", "h:mm:ss tt": "H:mm:ss", "dddd, MMMM dd, yyyy h:mm:ss tt": "MMMM d'. b. 'yyyy H:mm:ss", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "MMMM dd", "MMMM, yyyy": "MMMM yyyy", "/jan(uary)?/": "ođđajagemánnu", "/feb(ruary)?/": "guov(vamánnu)?", "/mar(ch)?/": "njuk(čamánnu)?", "/apr(il)?/": "cuo(ŋománnu)?", "/may/": "mies(semánnu)?", "/jun(e)?/": "geas(semánnu)?", "/jul(y)?/": "suoi(dnemánnu)?", "/aug(ust)?/": "borg(emánnu)?", "/sep(t(ember)?)?/": "čakč(amánnu)?", "/oct(ober)?/": "golg(gotmánnu)?", "/nov(ember)?/": "skáb(mamánnu)?", "/dec(ember)?/": "juov(lamánnu)?", "/^su(n(day)?)?/": "^sotnabeaivi", "/^mo(n(day)?)?/": "^vuossárga", "/^tu(e(s(day)?)?)?/": "^maŋŋebárga", "/^we(d(nesday)?)?/": "^gaskavahkku", "/^th(u(r(s(day)?)?)?)?/": "^duorastat", "/^fr(i(day)?)?/": "^bearjadat", "/^sa(t(urday)?)?/": "^lávvardat", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "se-FI"; ================================================ FILE: src/i18n/se-NO.js ================================================ /* * DateJS Culture String File * Country Code: se-NO * Name: Sami (Northern) (Norway) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["se-NO"] = { "name": "se-NO", "englishName": "Sami (Northern) (Norway)", "nativeName": "davvisámegiella (Norga)", "Sunday": "sotnabeaivi", "Monday": "vuossárga", "Tuesday": "maŋŋebárga", "Wednesday": "gaskavahkku", "Thursday": "duorastat", "Friday": "bearjadat", "Saturday": "lávvardat", "Sun": "sotn", "Mon": "vuos", "Tue": "maŋ", "Wed": "gask", "Thu": "duor", "Fri": "bear", "Sat": "láv", "Su": "sotn", "Mo": "vuos", "Tu": "maŋ", "We": "gask", "Th": "duor", "Fr": "bear", "Sa": "láv", "S_Sun_Initial": "s", "M_Mon_Initial": "v", "T_Tue_Initial": "m", "W_Wed_Initial": "g", "T_Thu_Initial": "d", "F_Fri_Initial": "b", "S_Sat_Initial": "l", "January": "ođđajagemánnu", "February": "guovvamánnu", "March": "njukčamánnu", "April": "cuoŋománnu", "May": "miessemánnu", "June": "geassemánnu", "July": "suoidnemánnu", "August": "borgemánnu", "September": "čakčamánnu", "October": "golggotmánnu", "November": "skábmamánnu", "December": "juovlamánnu", "Jan_Abbr": "ođđj", "Feb_Abbr": "guov", "Mar_Abbr": "njuk", "Apr_Abbr": "cuo", "May_Abbr": "mies", "Jun_Abbr": "geas", "Jul_Abbr": "suoi", "Aug_Abbr": "borg", "Sep_Abbr": "čakč", "Oct_Abbr": "golg", "Nov_Abbr": "skáb", "Dec_Abbr": "juov", "AM": "", "PM": "", "firstDayOfWeek": 1, "twoDigitYearMax": 2029, "mdy": "dmy", "M/d/yyyy": "dd.MM.yyyy", "dddd, MMMM dd, yyyy": "MMMM d'. b. 'yyyy", "h:mm tt": "HH:mm:ss", "h:mm:ss tt": "HH:mm:ss", "dddd, MMMM dd, yyyy h:mm:ss tt": "MMMM d'. b. 'yyyy HH:mm:ss", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "MMMM dd", "MMMM, yyyy": "MMMM yyyy", "/jan(uary)?/": "ođđajagemánnu", "/feb(ruary)?/": "guov(vamánnu)?", "/mar(ch)?/": "njuk(čamánnu)?", "/apr(il)?/": "cuo(ŋománnu)?", "/may/": "mies(semánnu)?", "/jun(e)?/": "geas(semánnu)?", "/jul(y)?/": "suoi(dnemánnu)?", "/aug(ust)?/": "borg(emánnu)?", "/sep(t(ember)?)?/": "čakč(amánnu)?", "/oct(ober)?/": "golg(gotmánnu)?", "/nov(ember)?/": "skáb(mamánnu)?", "/dec(ember)?/": "juov(lamánnu)?", "/^su(n(day)?)?/": "^sotnabeaivi", "/^mo(n(day)?)?/": "^vuossárga", "/^tu(e(s(day)?)?)?/": "^maŋŋebárga", "/^we(d(nesday)?)?/": "^gaskavahkku", "/^th(u(r(s(day)?)?)?)?/": "^duorastat", "/^fr(i(day)?)?/": "^bearjadat", "/^sa(t(urday)?)?/": "^lávvardat", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "se-NO"; ================================================ FILE: src/i18n/se-SE.js ================================================ /* * DateJS Culture String File * Country Code: se-SE * Name: Sami (Northern) (Sweden) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["se-SE"] = { "name": "se-SE", "englishName": "Sami (Northern) (Sweden)", "nativeName": "davvisámegiella (Ruoŧŧa)", "Sunday": "sotnabeaivi", "Monday": "mánnodat", "Tuesday": "disdat", "Wednesday": "gaskavahkku", "Thursday": "duorastat", "Friday": "bearjadat", "Saturday": "lávvardat", "Sun": "sotn", "Mon": "mán", "Tue": "dis", "Wed": "gask", "Thu": "duor", "Fri": "bear", "Sat": "láv", "Su": "sotn", "Mo": "mán", "Tu": "dis", "We": "gask", "Th": "duor", "Fr": "bear", "Sa": "láv", "S_Sun_Initial": "s", "M_Mon_Initial": "m", "T_Tue_Initial": "d", "W_Wed_Initial": "g", "T_Thu_Initial": "d", "F_Fri_Initial": "b", "S_Sat_Initial": "l", "January": "ođđajagemánnu", "February": "guovvamánnu", "March": "njukčamánnu", "April": "cuoŋománnu", "May": "miessemánnu", "June": "geassemánnu", "July": "suoidnemánnu", "August": "borgemánnu", "September": "čakčamánnu", "October": "golggotmánnu", "November": "skábmamánnu", "December": "juovlamánnu", "Jan_Abbr": "ođđj", "Feb_Abbr": "guov", "Mar_Abbr": "njuk", "Apr_Abbr": "cuo", "May_Abbr": "mies", "Jun_Abbr": "geas", "Jul_Abbr": "suoi", "Aug_Abbr": "borg", "Sep_Abbr": "čakč", "Oct_Abbr": "golg", "Nov_Abbr": "skáb", "Dec_Abbr": "juov", "AM": "", "PM": "", "firstDayOfWeek": 1, "twoDigitYearMax": 2029, "mdy": "ymd", "M/d/yyyy": "yyyy-MM-dd", "dddd, MMMM dd, yyyy": "MMMM d'. b. 'yyyy", "h:mm tt": "HH:mm:ss", "h:mm:ss tt": "HH:mm:ss", "dddd, MMMM dd, yyyy h:mm:ss tt": "MMMM d'. b. 'yyyy HH:mm:ss", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "MMMM dd", "MMMM, yyyy": "MMMM yyyy", "/jan(uary)?/": "ođđajagemánnu", "/feb(ruary)?/": "guov(vamánnu)?", "/mar(ch)?/": "njuk(čamánnu)?", "/apr(il)?/": "cuo(ŋománnu)?", "/may/": "mies(semánnu)?", "/jun(e)?/": "geas(semánnu)?", "/jul(y)?/": "suoi(dnemánnu)?", "/aug(ust)?/": "borg(emánnu)?", "/sep(t(ember)?)?/": "čakč(amánnu)?", "/oct(ober)?/": "golg(gotmánnu)?", "/nov(ember)?/": "skáb(mamánnu)?", "/dec(ember)?/": "juov(lamánnu)?", "/^su(n(day)?)?/": "^sotnabeaivi", "/^mo(n(day)?)?/": "^mánnodat", "/^tu(e(s(day)?)?)?/": "^disdat", "/^we(d(nesday)?)?/": "^gaskavahkku", "/^th(u(r(s(day)?)?)?)?/": "^duorastat", "/^fr(i(day)?)?/": "^bearjadat", "/^sa(t(urday)?)?/": "^lávvardat", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "se-SE"; ================================================ FILE: src/i18n/sk-SK.js ================================================ /* * DateJS Culture String File * Country Code: sk-SK * Name: Slovak (Slovakia) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["sk-SK"] = { "name": "sk-SK", "englishName": "Slovak (Slovakia)", "nativeName": "slovenčina (Slovenská republika)", "Sunday": "nedeľa", "Monday": "pondelok", "Tuesday": "utorok", "Wednesday": "streda", "Thursday": "štvrtok", "Friday": "piatok", "Saturday": "sobota", "Sun": "ne", "Mon": "po", "Tue": "ut", "Wed": "st", "Thu": "št", "Fri": "pi", "Sat": "so", "Su": "ne", "Mo": "po", "Tu": "ut", "We": "st", "Th": "št", "Fr": "pi", "Sa": "so", "S_Sun_Initial": "n", "M_Mon_Initial": "p", "T_Tue_Initial": "u", "W_Wed_Initial": "s", "T_Thu_Initial": "š", "F_Fri_Initial": "p", "S_Sat_Initial": "s", "January": "január", "February": "február", "March": "marec", "April": "apríl", "May": "máj", "June": "jún", "July": "júl", "August": "august", "September": "september", "October": "október", "November": "november", "December": "december", "Jan_Abbr": "I", "Feb_Abbr": "II", "Mar_Abbr": "III", "Apr_Abbr": "IV", "May_Abbr": "V", "Jun_Abbr": "VI", "Jul_Abbr": "VII", "Aug_Abbr": "VIII", "Sep_Abbr": "IX", "Oct_Abbr": "X", "Nov_Abbr": "XI", "Dec_Abbr": "XII", "AM": "", "PM": "", "firstDayOfWeek": 1, "twoDigitYearMax": 2029, "mdy": "dmy", "M/d/yyyy": "d. M. yyyy", "dddd, MMMM dd, yyyy": "d. MMMM yyyy", "h:mm tt": "H:mm", "h:mm:ss tt": "H:mm:ss", "dddd, MMMM dd, yyyy h:mm:ss tt": "d. MMMM yyyy H:mm:ss", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "dd MMMM", "MMMM, yyyy": "MMMM yyyy", "/jan(uary)?/": "január", "/feb(ruary)?/": "február", "/mar(ch)?/": "marec", "/apr(il)?/": "apríl", "/may/": "máj", "/jun(e)?/": "jún", "/jul(y)?/": "júl", "/aug(ust)?/": "august", "/sep(t(ember)?)?/": "sep(t(ember)?)?", "/oct(ober)?/": "október", "/nov(ember)?/": "november", "/dec(ember)?/": "december", "/^su(n(day)?)?/": "^nedeľa", "/^mo(n(day)?)?/": "^pondelok", "/^tu(e(s(day)?)?)?/": "^utorok", "/^we(d(nesday)?)?/": "^streda", "/^th(u(r(s(day)?)?)?)?/": "^štvrtok", "/^fr(i(day)?)?/": "^piatok", "/^sa(t(urday)?)?/": "^sobota", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "sk-SK"; ================================================ FILE: src/i18n/sl-SI.js ================================================ /* * DateJS Culture String File * Country Code: sl-SI * Name: Slovenian (Slovenia) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["sl-SI"] = { "name": "sl-SI", "englishName": "Slovenian (Slovenia)", "nativeName": "slovenski (Slovenija)", "Sunday": "nedelja", "Monday": "ponedeljek", "Tuesday": "torek", "Wednesday": "sreda", "Thursday": "četrtek", "Friday": "petek", "Saturday": "sobota", "Sun": "ned", "Mon": "pon", "Tue": "tor", "Wed": "sre", "Thu": "čet", "Fri": "pet", "Sat": "sob", "Su": "ne", "Mo": "po", "Tu": "to", "We": "sr", "Th": "če", "Fr": "pe", "Sa": "so", "S_Sun_Initial": "n", "M_Mon_Initial": "p", "T_Tue_Initial": "t", "W_Wed_Initial": "s", "T_Thu_Initial": "č", "F_Fri_Initial": "p", "S_Sat_Initial": "s", "January": "januar", "February": "februar", "March": "marec", "April": "april", "May": "maj", "June": "junij", "July": "julij", "August": "avgust", "September": "september", "October": "oktober", "November": "november", "December": "december", "Jan_Abbr": "jan", "Feb_Abbr": "feb", "Mar_Abbr": "mar", "Apr_Abbr": "apr", "May_Abbr": "maj", "Jun_Abbr": "jun", "Jul_Abbr": "jul", "Aug_Abbr": "avg", "Sep_Abbr": "sep", "Oct_Abbr": "okt", "Nov_Abbr": "nov", "Dec_Abbr": "dec", "AM": "", "PM": "", "firstDayOfWeek": 1, "twoDigitYearMax": 2029, "mdy": "dmy", "M/d/yyyy": "d.M.yyyy", "dddd, MMMM dd, yyyy": "d. MMMM yyyy", "h:mm tt": "H:mm", "h:mm:ss tt": "H:mm:ss", "dddd, MMMM dd, yyyy h:mm:ss tt": "d. MMMM yyyy H:mm:ss", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "d. MMMM", "MMMM, yyyy": "MMMM yyyy", "/jan(uary)?/": "jan(uar)?", "/feb(ruary)?/": "feb(ruar)?", "/mar(ch)?/": "mar(ec)?", "/apr(il)?/": "apr(il)?", "/may/": "maj", "/jun(e)?/": "jun(ij)?", "/jul(y)?/": "jul(ij)?", "/aug(ust)?/": "avg(ust)?", "/sep(t(ember)?)?/": "sep(t(ember)?)?", "/oct(ober)?/": "okt(ober)?", "/nov(ember)?/": "nov(ember)?", "/dec(ember)?/": "dec(ember)?", "/^su(n(day)?)?/": "^ne(d(elja)?)?", "/^mo(n(day)?)?/": "^po(n(edeljek)?)?", "/^tu(e(s(day)?)?)?/": "^to(r(ek)?)?", "/^we(d(nesday)?)?/": "^sr(e(da)?)?", "/^th(u(r(s(day)?)?)?)?/": "^če(t(rtek)?)?", "/^fr(i(day)?)?/": "^pe(t(ek)?)?", "/^sa(t(urday)?)?/": "^so(b(ota)?)?", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "sl-SI"; ================================================ FILE: src/i18n/sma-NO.js ================================================ /* * DateJS Culture String File * Country Code: sma-NO * Name: Sami (Southern) (Norway) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["sma-NO"] = { "name": "sma-NO", "englishName": "Sami (Southern) (Norway)", "nativeName": "åarjelsaemiengiele (Nöörje)", "Sunday": "aejlege", "Monday": "måanta", "Tuesday": "dæjsta", "Wednesday": "gaskevåhkoe", "Thursday": "duarsta", "Friday": "bearjadahke", "Saturday": "laavvardahke", "Sun": "aej", "Mon": "måa", "Tue": "dæj", "Wed": "gask", "Thu": "duar", "Fri": "bearj", "Sat": "laav", "Su": "aej", "Mo": "måa", "Tu": "dæj", "We": "gask", "Th": "duar", "Fr": "bearj", "Sa": "laav", "S_Sun_Initial": "a", "M_Mon_Initial": "m", "T_Tue_Initial": "d", "W_Wed_Initial": "g", "T_Thu_Initial": "d", "F_Fri_Initial": "b", "S_Sat_Initial": "l", "January": "tsïengele", "February": "goevte", "March": "njoktje", "April": "voerhtje", "May": "suehpede", "June": "ruffie", "July": "snjaltje", "August": "mïetske", "September": "skïerede", "October": "golke", "November": "rahka", "December": "goeve", "Jan_Abbr": "tsïen", "Feb_Abbr": "goevt", "Mar_Abbr": "njok", "Apr_Abbr": "voer", "May_Abbr": "sueh", "Jun_Abbr": "ruff", "Jul_Abbr": "snja", "Aug_Abbr": "mïet", "Sep_Abbr": "skïer", "Oct_Abbr": "golk", "Nov_Abbr": "rahk", "Dec_Abbr": "goev", "AM": "", "PM": "", "firstDayOfWeek": 1, "twoDigitYearMax": 2029, "mdy": "dmy", "M/d/yyyy": "dd.MM.yyyy", "dddd, MMMM dd, yyyy": "MMMM d'. b. 'yyyy", "h:mm tt": "HH:mm:ss", "h:mm:ss tt": "HH:mm:ss", "dddd, MMMM dd, yyyy h:mm:ss tt": "MMMM d'. b. 'yyyy HH:mm:ss", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "MMMM dd", "MMMM, yyyy": "MMMM yyyy", "/jan(uary)?/": "tsïen(gele)?", "/feb(ruary)?/": "goevt(e)?", "/mar(ch)?/": "njok(tje)?", "/apr(il)?/": "voer(htje)?", "/may/": "sueh(pede)?", "/jun(e)?/": "ruff(ie)?", "/jul(y)?/": "snja(ltje)?", "/aug(ust)?/": "mïet(ske)?", "/sep(t(ember)?)?/": "skïer(ede)?", "/oct(ober)?/": "golk(e)?", "/nov(ember)?/": "rahk(a)?", "/dec(ember)?/": "goev(e)?", "/^su(n(day)?)?/": "^aejlege", "/^mo(n(day)?)?/": "^måanta", "/^tu(e(s(day)?)?)?/": "^dæjsta", "/^we(d(nesday)?)?/": "^gaskevåhkoe", "/^th(u(r(s(day)?)?)?)?/": "^duarsta", "/^fr(i(day)?)?/": "^bearjadahke", "/^sa(t(urday)?)?/": "^laavvardahke", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "sma-NO"; ================================================ FILE: src/i18n/sma-SE.js ================================================ /* * DateJS Culture String File * Country Code: sma-SE * Name: Sami (Southern) (Sweden) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["sma-SE"] = { "name": "sma-SE", "englishName": "Sami (Southern) (Sweden)", "nativeName": "åarjelsaemiengiele (Sveerje)", "Sunday": "aejlege", "Monday": "måanta", "Tuesday": "dæjsta", "Wednesday": "gaskevåhkoe", "Thursday": "duarsta", "Friday": "bearjadahke", "Saturday": "laavvardahke", "Sun": "aej", "Mon": "måa", "Tue": "dæj", "Wed": "gask", "Thu": "duar", "Fri": "bearj", "Sat": "laav", "Su": "aej", "Mo": "måa", "Tu": "dæj", "We": "gask", "Th": "duar", "Fr": "bearj", "Sa": "laav", "S_Sun_Initial": "a", "M_Mon_Initial": "m", "T_Tue_Initial": "d", "W_Wed_Initial": "g", "T_Thu_Initial": "d", "F_Fri_Initial": "b", "S_Sat_Initial": "l", "January": "tsïengele", "February": "goevte", "March": "njoktje", "April": "voerhtje", "May": "suehpede", "June": "ruffie", "July": "snjaltje", "August": "mïetske", "September": "skïerede", "October": "golke", "November": "rahka", "December": "goeve", "Jan_Abbr": "tsïen", "Feb_Abbr": "goevt", "Mar_Abbr": "njok", "Apr_Abbr": "voer", "May_Abbr": "sueh", "Jun_Abbr": "ruff", "Jul_Abbr": "snja", "Aug_Abbr": "mïet", "Sep_Abbr": "skïer", "Oct_Abbr": "golk", "Nov_Abbr": "rahk", "Dec_Abbr": "goev", "AM": "", "PM": "", "firstDayOfWeek": 1, "twoDigitYearMax": 2029, "mdy": "ymd", "M/d/yyyy": "yyyy-MM-dd", "dddd, MMMM dd, yyyy": "MMMM d'. b. 'yyyy", "h:mm tt": "HH:mm:ss", "h:mm:ss tt": "HH:mm:ss", "dddd, MMMM dd, yyyy h:mm:ss tt": "MMMM d'. b. 'yyyy HH:mm:ss", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "MMMM dd", "MMMM, yyyy": "MMMM yyyy", "/jan(uary)?/": "tsïen(gele)?", "/feb(ruary)?/": "goevt(e)?", "/mar(ch)?/": "njok(tje)?", "/apr(il)?/": "voer(htje)?", "/may/": "sueh(pede)?", "/jun(e)?/": "ruff(ie)?", "/jul(y)?/": "snja(ltje)?", "/aug(ust)?/": "mïet(ske)?", "/sep(t(ember)?)?/": "skïer(ede)?", "/oct(ober)?/": "golk(e)?", "/nov(ember)?/": "rahk(a)?", "/dec(ember)?/": "goev(e)?", "/^su(n(day)?)?/": "^aejlege", "/^mo(n(day)?)?/": "^måanta", "/^tu(e(s(day)?)?)?/": "^dæjsta", "/^we(d(nesday)?)?/": "^gaskevåhkoe", "/^th(u(r(s(day)?)?)?)?/": "^duarsta", "/^fr(i(day)?)?/": "^bearjadahke", "/^sa(t(urday)?)?/": "^laavvardahke", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "sma-SE"; ================================================ FILE: src/i18n/smj-NO.js ================================================ /* * DateJS Culture String File * Country Code: smj-NO * Name: Sami (Lule) (Norway) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["smj-NO"] = { "name": "smj-NO", "englishName": "Sami (Lule) (Norway)", "nativeName": "julevusámegiella (Vuodna)", "Sunday": "sådnåbiejvve", "Monday": "mánnodahka", "Tuesday": "dijstahka", "Wednesday": "gasskavahkko", "Thursday": "duorastahka", "Friday": "bierjjedahka", "Saturday": "lávvodahka", "Sun": "såd", "Mon": "mán", "Tue": "dis", "Wed": "gas", "Thu": "duor", "Fri": "bier", "Sat": "láv", "Su": "såd", "Mo": "mán", "Tu": "dis", "We": "gas", "Th": "duor", "Fr": "bier", "Sa": "láv", "S_Sun_Initial": "s", "M_Mon_Initial": "m", "T_Tue_Initial": "d", "W_Wed_Initial": "g", "T_Thu_Initial": "d", "F_Fri_Initial": "b", "S_Sat_Initial": "l", "January": "ådåjakmánno", "February": "guovvamánno", "March": "sjnjuktjamánno", "April": "vuoratjismánno", "May": "moarmesmánno", "June": "biehtsemánno", "July": "sjnjilltjamánno", "August": "bårggemánno", "September": "ragátmánno", "October": "gålgådismánno", "November": "basádismánno", "December": "javllamánno", "Jan_Abbr": "ådåj", "Feb_Abbr": "guov", "Mar_Abbr": "snju", "Apr_Abbr": "vuor", "May_Abbr": "moar", "Jun_Abbr": "bieh", "Jul_Abbr": "snji", "Aug_Abbr": "bårg", "Sep_Abbr": "ragá", "Oct_Abbr": "gålg", "Nov_Abbr": "basá", "Dec_Abbr": "javl", "AM": "", "PM": "", "firstDayOfWeek": 1, "twoDigitYearMax": 2029, "mdy": "dmy", "M/d/yyyy": "dd.MM.yyyy", "dddd, MMMM dd, yyyy": "MMMM d'. b. 'yyyy", "h:mm tt": "HH:mm:ss", "h:mm:ss tt": "HH:mm:ss", "dddd, MMMM dd, yyyy h:mm:ss tt": "MMMM d'. b. 'yyyy HH:mm:ss", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "MMMM dd", "MMMM, yyyy": "MMMM yyyy", "/jan(uary)?/": "ådåj(akmánno)?", "/feb(ruary)?/": "guov(vamánno)?", "/mar(ch)?/": "sjnjuktjamánno", "/apr(il)?/": "vuor(atjismánno)?", "/may/": "moar(mesmánno)?", "/jun(e)?/": "bieh(tsemánno)?", "/jul(y)?/": "sjnjilltjamánno", "/aug(ust)?/": "bårg(gemánno)?", "/sep(t(ember)?)?/": "ragá(tmánno)?", "/oct(ober)?/": "gålg(ådismánno)?", "/nov(ember)?/": "basá(dismánno)?", "/dec(ember)?/": "javl(lamánno)?", "/^su(n(day)?)?/": "^sådnåbiejvve", "/^mo(n(day)?)?/": "^mánnodahka", "/^tu(e(s(day)?)?)?/": "^dijstahka", "/^we(d(nesday)?)?/": "^gasskavahkko", "/^th(u(r(s(day)?)?)?)?/": "^duorastahka", "/^fr(i(day)?)?/": "^bierjjedahka", "/^sa(t(urday)?)?/": "^lávvodahka", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "smj-NO"; ================================================ FILE: src/i18n/smj-SE.js ================================================ /* * DateJS Culture String File * Country Code: smj-SE * Name: Sami (Lule) (Sweden) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["smj-SE"] = { "name": "smj-SE", "englishName": "Sami (Lule) (Sweden)", "nativeName": "julevusámegiella (Svierik)", "Sunday": "ájllek", "Monday": "mánnodahka", "Tuesday": "dijstahka", "Wednesday": "gasskavahkko", "Thursday": "duorastahka", "Friday": "bierjjedahka", "Saturday": "lávvodahka", "Sun": "ájl", "Mon": "mán", "Tue": "dis", "Wed": "gas", "Thu": "duor", "Fri": "bier", "Sat": "láv", "Su": "ájl", "Mo": "mán", "Tu": "dis", "We": "gas", "Th": "duor", "Fr": "bier", "Sa": "láv", "S_Sun_Initial": "á", "M_Mon_Initial": "m", "T_Tue_Initial": "d", "W_Wed_Initial": "g", "T_Thu_Initial": "d", "F_Fri_Initial": "b", "S_Sat_Initial": "l", "January": "ådåjakmánno", "February": "guovvamánno", "March": "sjnjuktjamánno", "April": "vuoratjismánno", "May": "moarmesmánno", "June": "biehtsemánno", "July": "sjnjilltjamánno", "August": "bårggemánno", "September": "ragátmánno", "October": "gålgådismánno", "November": "basádismánno", "December": "javllamánno", "Jan_Abbr": "ådåj", "Feb_Abbr": "guov", "Mar_Abbr": "snju", "Apr_Abbr": "vuor", "May_Abbr": "moar", "Jun_Abbr": "bieh", "Jul_Abbr": "snji", "Aug_Abbr": "bårg", "Sep_Abbr": "ragá", "Oct_Abbr": "gålg", "Nov_Abbr": "basá", "Dec_Abbr": "javl", "AM": "", "PM": "", "firstDayOfWeek": 1, "twoDigitYearMax": 2029, "mdy": "ymd", "M/d/yyyy": "yyyy-MM-dd", "dddd, MMMM dd, yyyy": "MMMM d'. b. 'yyyy", "h:mm tt": "HH:mm:ss", "h:mm:ss tt": "HH:mm:ss", "dddd, MMMM dd, yyyy h:mm:ss tt": "MMMM d'. b. 'yyyy HH:mm:ss", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "MMMM dd", "MMMM, yyyy": "MMMM yyyy", "/jan(uary)?/": "ådåj(akmánno)?", "/feb(ruary)?/": "guov(vamánno)?", "/mar(ch)?/": "sjnjuktjamánno", "/apr(il)?/": "vuor(atjismánno)?", "/may/": "moar(mesmánno)?", "/jun(e)?/": "bieh(tsemánno)?", "/jul(y)?/": "sjnjilltjamánno", "/aug(ust)?/": "bårg(gemánno)?", "/sep(t(ember)?)?/": "ragá(tmánno)?", "/oct(ober)?/": "gålg(ådismánno)?", "/nov(ember)?/": "basá(dismánno)?", "/dec(ember)?/": "javl(lamánno)?", "/^su(n(day)?)?/": "^ájllek", "/^mo(n(day)?)?/": "^mánnodahka", "/^tu(e(s(day)?)?)?/": "^dijstahka", "/^we(d(nesday)?)?/": "^gasskavahkko", "/^th(u(r(s(day)?)?)?)?/": "^duorastahka", "/^fr(i(day)?)?/": "^bierjjedahka", "/^sa(t(urday)?)?/": "^lávvodahka", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "smj-SE"; ================================================ FILE: src/i18n/smn-FI.js ================================================ /* * DateJS Culture String File * Country Code: smn-FI * Name: Sami (Inari) (Finland) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["smn-FI"] = { "name": "smn-FI", "englishName": "Sami (Inari) (Finland)", "nativeName": "sämikielâ (Suomâ)", "Sunday": "pasepeivi", "Monday": "vuossargâ", "Tuesday": "majebargâ", "Wednesday": "koskokko", "Thursday": "tuorâstâh", "Friday": "vástuppeivi", "Saturday": "lávárdâh", "Sun": "pa", "Mon": "vu", "Tue": "ma", "Wed": "ko", "Thu": "tu", "Fri": "vá", "Sat": "lá", "Su": "pa", "Mo": "vu", "Tu": "ma", "We": "ko", "Th": "tu", "Fr": "vá", "Sa": "lá", "S_Sun_Initial": "p", "M_Mon_Initial": "v", "T_Tue_Initial": "m", "W_Wed_Initial": "k", "T_Thu_Initial": "t", "F_Fri_Initial": "v", "S_Sat_Initial": "l", "January": "uđđâivemáánu", "February": "kuovâmáánu", "March": "njuhčâmáánu", "April": "cuáŋuimáánu", "May": "vyesimáánu", "June": "kesimáánu", "July": "syeinimáánu", "August": "porgemáánu", "September": "čohčâmáánu", "October": "roovvâdmáánu", "November": "skammâmáánu", "December": "juovlâmáánu", "Jan_Abbr": "uđiv", "Feb_Abbr": "kuov", "Mar_Abbr": "njuh", "Apr_Abbr": "cuoŋ", "May_Abbr": "vyes", "Jun_Abbr": "kesi", "Jul_Abbr": "syei", "Aug_Abbr": "porg", "Sep_Abbr": "čoh", "Oct_Abbr": "roov", "Nov_Abbr": "ska", "Dec_Abbr": "juov", "AM": "", "PM": "", "firstDayOfWeek": 1, "twoDigitYearMax": 2029, "mdy": "dmy", "M/d/yyyy": "d.M.yyyy", "dddd, MMMM dd, yyyy": "MMMM d'. p. 'yyyy", "h:mm tt": "H:mm:ss", "h:mm:ss tt": "H:mm:ss", "dddd, MMMM dd, yyyy h:mm:ss tt": "MMMM d'. p. 'yyyy H:mm:ss", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "MMMM dd", "MMMM, yyyy": "MMMM yyyy", "/jan(uary)?/": "uđđâivemáánu", "/feb(ruary)?/": "kuov(âmáánu)?", "/mar(ch)?/": "njuh(čâmáánu)?", "/apr(il)?/": "cuáŋuimáánu", "/may/": "vyes(imáánu)?", "/jun(e)?/": "kesi(máánu)?", "/jul(y)?/": "syei(nimáánu)?", "/aug(ust)?/": "porg(emáánu)?", "/sep(t(ember)?)?/": "čoh(čâmáánu)?", "/oct(ober)?/": "roov(vâdmáánu)?", "/nov(ember)?/": "ska(mmâmáánu)?", "/dec(ember)?/": "juov(lâmáánu)?", "/^su(n(day)?)?/": "^pasepeivi", "/^mo(n(day)?)?/": "^vuossargâ", "/^tu(e(s(day)?)?)?/": "^majebargâ", "/^we(d(nesday)?)?/": "^koskokko", "/^th(u(r(s(day)?)?)?)?/": "^tuorâstâh", "/^fr(i(day)?)?/": "^vástuppeivi", "/^sa(t(urday)?)?/": "^lávárdâh", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "smn-FI"; ================================================ FILE: src/i18n/sms-FI.js ================================================ /* * DateJS Culture String File * Country Code: sms-FI * Name: Sami (Skolt) (Finland) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["sms-FI"] = { "name": "sms-FI", "englishName": "Sami (Skolt) (Finland)", "nativeName": "sääm´ǩiõll (Lää´ddjânnam)", "Sunday": "pâ´sspei´vv", "Monday": "vuõssargg", "Tuesday": "mââibargg", "Wednesday": "seärad", "Thursday": "nelljdpei´vv", "Friday": "piâtnâc", "Saturday": "sue´vet", "Sun": "pâ", "Mon": "vu", "Tue": "mâ", "Wed": "se", "Thu": "ne", "Fri": "pi", "Sat": "su", "Su": "pâ", "Mo": "vu", "Tu": "mâ", "We": "se", "Th": "ne", "Fr": "pi", "Sa": "su", "S_Sun_Initial": "p", "M_Mon_Initial": "v", "T_Tue_Initial": "m", "W_Wed_Initial": "s", "T_Thu_Initial": "n", "F_Fri_Initial": "p", "S_Sat_Initial": "s", "January": "ođđee´jjmään", "February": "tä´lvvmään", "March": "pâ´zzlâšttammään", "April": "njuhččmään", "May": "vue´ssmään", "June": "ǩie´ssmään", "July": "suei´nnmään", "August": "på´rǧǧmään", "September": "čõhččmään", "October": "kålggmään", "November": "skamm´mään", "December": "rosttovmään", "Jan_Abbr": "ođjm", "Feb_Abbr": "tä´lvv", "Mar_Abbr": "pâzl", "Apr_Abbr": "njuh", "May_Abbr": "vue", "Jun_Abbr": "ǩie", "Jul_Abbr": "suei", "Aug_Abbr": "på´r", "Sep_Abbr": "čõh", "Oct_Abbr": "kålg", "Nov_Abbr": "ska", "Dec_Abbr": "rost", "AM": "", "PM": "", "firstDayOfWeek": 1, "twoDigitYearMax": 2029, "mdy": "dmy", "M/d/yyyy": "d.M.yyyy", "dddd, MMMM dd, yyyy": "MMMM d'. p. 'yyyy", "h:mm tt": "H:mm:ss", "h:mm:ss tt": "H:mm:ss", "dddd, MMMM dd, yyyy h:mm:ss tt": "MMMM d'. p. 'yyyy H:mm:ss", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "MMMM dd", "MMMM, yyyy": "MMMM yyyy", "/jan(uary)?/": "ođđee´jjmään", "/feb(ruary)?/": "tä´lvv(mään)?", "/mar(ch)?/": "pâ´zzlâšttammään", "/apr(il)?/": "njuh(ččmään)?", "/may/": "vue(´ssmään)?", "/jun(e)?/": "ǩie(´ssmään)?", "/jul(y)?/": "suei(´nnmään)?", "/aug(ust)?/": "på´r(ǧǧmään)?", "/sep(t(ember)?)?/": "čõh(ččmään)?", "/oct(ober)?/": "kålg(gmään)?", "/nov(ember)?/": "ska(mm´mään)?", "/dec(ember)?/": "rost(tovmään)?", "/^su(n(day)?)?/": "^pâ´sspei´vv", "/^mo(n(day)?)?/": "^vuõssargg", "/^tu(e(s(day)?)?)?/": "^mââibargg", "/^we(d(nesday)?)?/": "^seärad", "/^th(u(r(s(day)?)?)?)?/": "^nelljdpei´vv", "/^fr(i(day)?)?/": "^piâtnâc", "/^sa(t(urday)?)?/": "^sue´vet", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "sms-FI"; ================================================ FILE: src/i18n/sq-AL.js ================================================ /* * DateJS Culture String File * Country Code: sq-AL * Name: Albanian (Albania) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["sq-AL"] = { "name": "sq-AL", "englishName": "Albanian (Albania)", "nativeName": "shqipe (Shqipëria)", "Sunday": "e diel", "Monday": "e hënë", "Tuesday": "e martë", "Wednesday": "e mërkurë", "Thursday": "e enjte", "Friday": "e premte", "Saturday": "e shtunë", "Sun": "Die", "Mon": "Hën", "Tue": "Mar", "Wed": "Mër", "Thu": "Enj", "Fri": "Pre", "Sat": "Sht", "Su": "Di", "Mo": "Hë", "Tu": "Ma", "We": "Më", "Th": "En", "Fr": "Pr", "Sa": "Sh", "S_Sun_Initial": "D", "M_Mon_Initial": "H", "T_Tue_Initial": "M", "W_Wed_Initial": "M", "T_Thu_Initial": "E", "F_Fri_Initial": "P", "S_Sat_Initial": "S", "January": "janar", "February": "shkurt", "March": "mars", "April": "prill", "May": "maj", "June": "qershor", "July": "korrik", "August": "gusht", "September": "shtator", "October": "tetor", "November": "nëntor", "December": "dhjetor", "Jan_Abbr": "Jan", "Feb_Abbr": "Shk", "Mar_Abbr": "Mar", "Apr_Abbr": "Pri", "May_Abbr": "Maj", "Jun_Abbr": "Qer", "Jul_Abbr": "Kor", "Aug_Abbr": "Gsh", "Sep_Abbr": "Sht", "Oct_Abbr": "Tet", "Nov_Abbr": "Nën", "Dec_Abbr": "Dhj", "AM": "PD", "PM": "MD", "firstDayOfWeek": 1, "twoDigitYearMax": 2029, "mdy": "ymd", "M/d/yyyy": "yyyy-MM-dd", "dddd, MMMM dd, yyyy": "yyyy-MM-dd", "h:mm tt": "h:mm.tt", "h:mm:ss tt": "h:mm:ss.tt", "dddd, MMMM dd, yyyy h:mm:ss tt": "yyyy-MM-dd h:mm:ss.tt", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "MMMM dd", "MMMM, yyyy": "yyyy-MM", "/jan(uary)?/": "jan(ar)?", "/feb(ruary)?/": "shk(urt)?", "/mar(ch)?/": "mar(s)?", "/apr(il)?/": "pri(ll)?", "/may/": "maj", "/jun(e)?/": "qer(shor)?", "/jul(y)?/": "kor(rik)?", "/aug(ust)?/": "gusht", "/sep(t(ember)?)?/": "sht(ator)?", "/oct(ober)?/": "tet(or)?", "/nov(ember)?/": "nën(tor)?", "/dec(ember)?/": "dhj(etor)?", "/^su(n(day)?)?/": "^di(e(iel)?)?", "/^mo(n(day)?)?/": "^hë(n(ënë)?)?", "/^tu(e(s(day)?)?)?/": "^ma(r(artë)?)?", "/^we(d(nesday)?)?/": "^më(r(ërkurë)?)?", "/^th(u(r(s(day)?)?)?)?/": "^en(j(njte)?)?", "/^fr(i(day)?)?/": "^pr(e(remte)?)?", "/^sa(t(urday)?)?/": "^sh(t(htunë)?)?", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "sq-AL"; ================================================ FILE: src/i18n/sr-Cyrl-BA.js ================================================ /* * DateJS Culture String File * Country Code: sr-Cyrl-BA * Name: Serbian (Cyrillic) (Bosnia and Herzegovina) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["sr-Cyrl-BA"] = { "name": "sr-Cyrl-BA", "englishName": "Serbian (Cyrillic) (Bosnia and Herzegovina)", "nativeName": "српски (Босна и Херцеговина)", "Sunday": "недеља", "Monday": "понедељак", "Tuesday": "уторак", "Wednesday": "среда", "Thursday": "четвртак", "Friday": "петак", "Saturday": "субота", "Sun": "нед", "Mon": "пон", "Tue": "уто", "Wed": "сре", "Thu": "чет", "Fri": "пет", "Sat": "суб", "Su": "нед", "Mo": "пон", "Tu": "уто", "We": "сре", "Th": "чет", "Fr": "пет", "Sa": "суб", "S_Sun_Initial": "н", "M_Mon_Initial": "п", "T_Tue_Initial": "у", "W_Wed_Initial": "с", "T_Thu_Initial": "ч", "F_Fri_Initial": "п", "S_Sat_Initial": "с", "January": "јануар", "February": "фебруар", "March": "март", "April": "април", "May": "мај", "June": "јун", "July": "јул", "August": "август", "September": "септембар", "October": "октобар", "November": "новембар", "December": "децембар", "Jan_Abbr": "јан", "Feb_Abbr": "феб", "Mar_Abbr": "мар", "Apr_Abbr": "апр", "May_Abbr": "мај", "Jun_Abbr": "јун", "Jul_Abbr": "јул", "Aug_Abbr": "авг", "Sep_Abbr": "сеп", "Oct_Abbr": "окт", "Nov_Abbr": "нов", "Dec_Abbr": "дец", "AM": "", "PM": "", "firstDayOfWeek": 1, "twoDigitYearMax": 2029, "mdy": "dmy", "M/d/yyyy": "d.M.yyyy", "dddd, MMMM dd, yyyy": "d. MMMM yyyy", "h:mm tt": "H:mm:ss", "h:mm:ss tt": "H:mm:ss", "dddd, MMMM dd, yyyy h:mm:ss tt": "d. MMMM yyyy H:mm:ss", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "MMMM dd", "MMMM, yyyy": "MMMM, yyyy", "/jan(uary)?/": "јан(уар)?", "/feb(ruary)?/": "феб(руар)?", "/mar(ch)?/": "мар(т)?", "/apr(il)?/": "апр(ил)?", "/may/": "мај", "/jun(e)?/": "јун", "/jul(y)?/": "јул", "/aug(ust)?/": "авг(уст)?", "/sep(t(ember)?)?/": "сеп(тембар)?", "/oct(ober)?/": "окт(обар)?", "/nov(ember)?/": "нов(ембар)?", "/dec(ember)?/": "дец(ембар)?", "/^su(n(day)?)?/": "^недеља", "/^mo(n(day)?)?/": "^понедељак", "/^tu(e(s(day)?)?)?/": "^уторак", "/^we(d(nesday)?)?/": "^среда", "/^th(u(r(s(day)?)?)?)?/": "^четвртак", "/^fr(i(day)?)?/": "^петак", "/^sa(t(urday)?)?/": "^субота", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "sr-Cyrl-BA"; ================================================ FILE: src/i18n/sr-Cyrl-CS.js ================================================ /* * DateJS Culture String File * Country Code: sr-Cyrl-CS * Name: Serbian (Cyrillic, Serbia) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["sr-Cyrl-CS"] = { "name": "sr-Cyrl-CS", "englishName": "Serbian (Cyrillic, Serbia)", "nativeName": "српски (Србија)", "Sunday": "недеља", "Monday": "понедељак", "Tuesday": "уторак", "Wednesday": "среда", "Thursday": "четвртак", "Friday": "петак", "Saturday": "субота", "Sun": "нед", "Mon": "пон", "Tue": "уто", "Wed": "сре", "Thu": "чет", "Fri": "пет", "Sat": "суб", "Su": "не", "Mo": "по", "Tu": "ут", "We": "ср", "Th": "че", "Fr": "пе", "Sa": "су", "S_Sun_Initial": "н", "M_Mon_Initial": "п", "T_Tue_Initial": "у", "W_Wed_Initial": "с", "T_Thu_Initial": "ч", "F_Fri_Initial": "п", "S_Sat_Initial": "с", "January": "јануар", "February": "фебруар", "March": "март", "April": "април", "May": "мај", "June": "јун", "July": "јул", "August": "август", "September": "септембар", "October": "октобар", "November": "новембар", "December": "децембар", "Jan_Abbr": "јан", "Feb_Abbr": "феб", "Mar_Abbr": "мар", "Apr_Abbr": "апр", "May_Abbr": "мај", "Jun_Abbr": "јун", "Jul_Abbr": "јул", "Aug_Abbr": "авг", "Sep_Abbr": "сеп", "Oct_Abbr": "окт", "Nov_Abbr": "нов", "Dec_Abbr": "дец", "AM": "", "PM": "", "firstDayOfWeek": 1, "twoDigitYearMax": 2029, "mdy": "dmy", "M/d/yyyy": "d.M.yyyy", "dddd, MMMM dd, yyyy": "d. MMMM yyyy", "h:mm tt": "H:mm", "h:mm:ss tt": "H:mm:ss", "dddd, MMMM dd, yyyy h:mm:ss tt": "d. MMMM yyyy H:mm:ss", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "d. MMMM", "MMMM, yyyy": "MMMM yyyy", "/jan(uary)?/": "јан(уар)?", "/feb(ruary)?/": "феб(руар)?", "/mar(ch)?/": "мар(т)?", "/apr(il)?/": "апр(ил)?", "/may/": "мај", "/jun(e)?/": "јун", "/jul(y)?/": "јул", "/aug(ust)?/": "авг(уст)?", "/sep(t(ember)?)?/": "сеп(тембар)?", "/oct(ober)?/": "окт(обар)?", "/nov(ember)?/": "нов(ембар)?", "/dec(ember)?/": "дец(ембар)?", "/^su(n(day)?)?/": "^не(д(еља)?)?", "/^mo(n(day)?)?/": "^по(н(едељак)?)?", "/^tu(e(s(day)?)?)?/": "^ут(о(рак)?)?", "/^we(d(nesday)?)?/": "^ср(е(да)?)?", "/^th(u(r(s(day)?)?)?)?/": "^че(т(вртак)?)?", "/^fr(i(day)?)?/": "^пе(т(ак)?)?", "/^sa(t(urday)?)?/": "^су(б(ота)?)?", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "sr-Cyrl-CS"; ================================================ FILE: src/i18n/sr-Latn-BA.js ================================================ /* * DateJS Culture String File * Country Code: sr-Latn-BA * Name: Serbian (Latin) (Bosnia and Herzegovina) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["sr-Latn-BA"] = { "name": "sr-Latn-BA", "englishName": "Serbian (Latin) (Bosnia and Herzegovina)", "nativeName": "srpski (Bosna i Hercegovina)", "Sunday": "nedelja", "Monday": "ponedeljak", "Tuesday": "utorak", "Wednesday": "sreda", "Thursday": "četvrtak", "Friday": "petak", "Saturday": "subota", "Sun": "ned", "Mon": "pon", "Tue": "uto", "Wed": "sre", "Thu": "čet", "Fri": "pet", "Sat": "sub", "Su": "ned", "Mo": "pon", "Tu": "uto", "We": "sre", "Th": "čet", "Fr": "pet", "Sa": "sub", "S_Sun_Initial": "n", "M_Mon_Initial": "p", "T_Tue_Initial": "u", "W_Wed_Initial": "s", "T_Thu_Initial": "č", "F_Fri_Initial": "p", "S_Sat_Initial": "s", "January": "januar", "February": "februar", "March": "mart", "April": "april", "May": "maj", "June": "jun", "July": "jul", "August": "avgust", "September": "septembar", "October": "oktobar", "November": "novembar", "December": "decembar", "Jan_Abbr": "jan", "Feb_Abbr": "feb", "Mar_Abbr": "mar", "Apr_Abbr": "apr", "May_Abbr": "maj", "Jun_Abbr": "jun", "Jul_Abbr": "jul", "Aug_Abbr": "avg", "Sep_Abbr": "sep", "Oct_Abbr": "okt", "Nov_Abbr": "nov", "Dec_Abbr": "dec", "AM": "", "PM": "", "firstDayOfWeek": 1, "twoDigitYearMax": 2029, "mdy": "dmy", "M/d/yyyy": "d.M.yyyy", "dddd, MMMM dd, yyyy": "d. MMMM yyyy", "h:mm tt": "H:mm:ss", "h:mm:ss tt": "H:mm:ss", "dddd, MMMM dd, yyyy h:mm:ss tt": "d. MMMM yyyy H:mm:ss", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "MMMM dd", "MMMM, yyyy": "MMMM yyyy", "/jan(uary)?/": "jan(uar)?", "/feb(ruary)?/": "feb(ruar)?", "/mar(ch)?/": "mar(t)?", "/apr(il)?/": "apr(il)?", "/may/": "maj", "/jun(e)?/": "jun", "/jul(y)?/": "jul", "/aug(ust)?/": "avg(ust)?", "/sep(t(ember)?)?/": "sep(tembar)?", "/oct(ober)?/": "okt(obar)?", "/nov(ember)?/": "nov(embar)?", "/dec(ember)?/": "dec(embar)?", "/^su(n(day)?)?/": "^nedelja", "/^mo(n(day)?)?/": "^ponedeljak", "/^tu(e(s(day)?)?)?/": "^utorak", "/^we(d(nesday)?)?/": "^sreda", "/^th(u(r(s(day)?)?)?)?/": "^četvrtak", "/^fr(i(day)?)?/": "^petak", "/^sa(t(urday)?)?/": "^subota", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "sr-Latn-BA"; ================================================ FILE: src/i18n/sr-Latn-CS.js ================================================ /* * DateJS Culture String File * Country Code: sr-Latn-CS * Name: Serbian (Latin, Serbia) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["sr-Latn-CS"] = { "name": "sr-Latn-CS", "englishName": "Serbian (Latin, Serbia)", "nativeName": "srpski (Srbija)", "Sunday": "nedelja", "Monday": "ponedeljak", "Tuesday": "utorak", "Wednesday": "sreda", "Thursday": "četvrtak", "Friday": "petak", "Saturday": "subota", "Sun": "ned", "Mon": "pon", "Tue": "uto", "Wed": "sre", "Thu": "čet", "Fri": "pet", "Sat": "sub", "Su": "ne", "Mo": "po", "Tu": "ut", "We": "sr", "Th": "če", "Fr": "pe", "Sa": "su", "S_Sun_Initial": "n", "M_Mon_Initial": "p", "T_Tue_Initial": "u", "W_Wed_Initial": "s", "T_Thu_Initial": "č", "F_Fri_Initial": "p", "S_Sat_Initial": "s", "January": "januar", "February": "februar", "March": "mart", "April": "april", "May": "maj", "June": "jun", "July": "jul", "August": "avgust", "September": "septembar", "October": "oktobar", "November": "novembar", "December": "decembar", "Jan_Abbr": "jan", "Feb_Abbr": "feb", "Mar_Abbr": "mar", "Apr_Abbr": "apr", "May_Abbr": "maj", "Jun_Abbr": "jun", "Jul_Abbr": "jul", "Aug_Abbr": "avg", "Sep_Abbr": "sep", "Oct_Abbr": "okt", "Nov_Abbr": "nov", "Dec_Abbr": "dec", "AM": "", "PM": "", "firstDayOfWeek": 1, "twoDigitYearMax": 2029, "mdy": "dmy", "M/d/yyyy": "d.M.yyyy", "dddd, MMMM dd, yyyy": "d. MMMM yyyy", "h:mm tt": "H:mm", "h:mm:ss tt": "H:mm:ss", "dddd, MMMM dd, yyyy h:mm:ss tt": "d. MMMM yyyy H:mm:ss", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "d. MMMM", "MMMM, yyyy": "MMMM yyyy", "/jan(uary)?/": "jan(uar)?", "/feb(ruary)?/": "feb(ruar)?", "/mar(ch)?/": "mar(t)?", "/apr(il)?/": "apr(il)?", "/may/": "maj", "/jun(e)?/": "jun", "/jul(y)?/": "jul", "/aug(ust)?/": "avg(ust)?", "/sep(t(ember)?)?/": "sep(tembar)?", "/oct(ober)?/": "okt(obar)?", "/nov(ember)?/": "nov(embar)?", "/dec(ember)?/": "dec(embar)?", "/^su(n(day)?)?/": "^ne(d(elja)?)?", "/^mo(n(day)?)?/": "^po(n(edeljak)?)?", "/^tu(e(s(day)?)?)?/": "^ut(o(rak)?)?", "/^we(d(nesday)?)?/": "^sr(e(da)?)?", "/^th(u(r(s(day)?)?)?)?/": "^če(t(vrtak)?)?", "/^fr(i(day)?)?/": "^pe(t(ak)?)?", "/^sa(t(urday)?)?/": "^su(b(ota)?)?", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "sr-Latn-CS"; ================================================ FILE: src/i18n/sv-FI.js ================================================ /* * DateJS Culture String File * Country Code: sv-FI * Name: Swedish (Finland) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["sv-FI"] = { "name": "sv-FI", "englishName": "Swedish (Finland)", "nativeName": "svenska (Finland)", "Sunday": "söndag", "Monday": "måndag", "Tuesday": "tisdag", "Wednesday": "onsdag", "Thursday": "torsdag", "Friday": "fredag", "Saturday": "lördag", "Sun": "sö", "Mon": "må", "Tue": "ti", "Wed": "on", "Thu": "to", "Fri": "fr", "Sat": "lö", "Su": "sö", "Mo": "må", "Tu": "ti", "We": "on", "Th": "to", "Fr": "fr", "Sa": "lö", "S_Sun_Initial": "s", "M_Mon_Initial": "m", "T_Tue_Initial": "t", "W_Wed_Initial": "o", "T_Thu_Initial": "t", "F_Fri_Initial": "f", "S_Sat_Initial": "l", "January": "januari", "February": "februari", "March": "mars", "April": "april", "May": "maj", "June": "juni", "July": "juli", "August": "augusti", "September": "september", "October": "oktober", "November": "november", "December": "december", "Jan_Abbr": "jan", "Feb_Abbr": "feb", "Mar_Abbr": "mar", "Apr_Abbr": "apr", "May_Abbr": "maj", "Jun_Abbr": "jun", "Jul_Abbr": "jul", "Aug_Abbr": "aug", "Sep_Abbr": "sep", "Oct_Abbr": "okt", "Nov_Abbr": "nov", "Dec_Abbr": "dec", "AM": "", "PM": "", "firstDayOfWeek": 1, "twoDigitYearMax": 2029, "mdy": "dmy", "M/d/yyyy": "d.M.yyyy", "dddd, MMMM dd, yyyy": "'den 'd MMMM yyyy", "h:mm tt": "HH:mm", "h:mm:ss tt": "HH:mm:ss", "dddd, MMMM dd, yyyy h:mm:ss tt": "'den 'd MMMM yyyy HH:mm:ss", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "'den 'd MMMM", "MMMM, yyyy": "MMMM yyyy", "/jan(uary)?/": "jan(uari)?", "/feb(ruary)?/": "feb(ruari)?", "/mar(ch)?/": "mar(s)?", "/apr(il)?/": "apr(il)?", "/may/": "maj", "/jun(e)?/": "jun(i)?", "/jul(y)?/": "jul(i)?", "/aug(ust)?/": "aug(usti)?", "/sep(t(ember)?)?/": "sep(t(ember)?)?", "/oct(ober)?/": "okt(ober)?", "/nov(ember)?/": "nov(ember)?", "/dec(ember)?/": "dec(ember)?", "/^su(n(day)?)?/": "^söndag", "/^mo(n(day)?)?/": "^måndag", "/^tu(e(s(day)?)?)?/": "^tisdag", "/^we(d(nesday)?)?/": "^onsdag", "/^th(u(r(s(day)?)?)?)?/": "^torsdag", "/^fr(i(day)?)?/": "^fredag", "/^sa(t(urday)?)?/": "^lördag", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "sv-FI"; ================================================ FILE: src/i18n/sv-SE.js ================================================ /* * DateJS Culture String File * Country Code: sv-SE * Name: Swedish (Sweden) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["sv-SE"] = { "name": "sv-SE", "englishName": "Swedish (Sweden)", "nativeName": "Svenska (Sverige)", "Sunday": "Söndag", "Monday": "Måndag", "Tuesday": "Tisdag", "Wednesday": "Onsdag", "Thursday": "Torsdag", "Friday": "Fredag", "Saturday": "Lördag", "Sun": "Sön", "Mon": "Mån", "Tue": "Tis", "Wed": "Ons", "Thu": "Tor", "Fri": "Fre", "Sat": "Lör", "Su": "Sö", "Mo": "Må", "Tu": "Ti", "We": "On", "Th": "To", "Fr": "Fr", "Sa": "Lö", "S_Sun_Initial": "S", "M_Mon_Initial": "M", "T_Tue_Initial": "T", "W_Wed_Initial": "O", "T_Thu_Initial": "T", "F_Fri_Initial": "F", "S_Sat_Initial": "L", "January": "Januari", "February": "Februari", "March": "Mars", "April": "April", "May": "Maj", "June": "Juni", "July": "Juli", "August": "Augusti", "September": "September", "October": "Oktober", "November": "November", "December": "December", "Jan_Abbr": "Jan", "Feb_Abbr": "Feb", "Mar_Abbr": "Mar", "Apr_Abbr": "Apr", "May_Abbr": "Maj", "Jun_Abbr": "Jun", "Jul_Abbr": "Jul", "Aug_Abbr": "Aug", "Sep_Abbr": "Sep", "Oct_Abbr": "Okt", "Nov_Abbr": "Nov", "Dec_Abbr": "Dec", "AM": "", "PM": "", "firstDayOfWeek": 1, "twoDigitYearMax": 2029, "mdy": "ymd", "M/d/yyyy": "yyyy-MM-dd", "dddd, MMMM dd, yyyy": "'den 'd MMMM yyyy", "h:mm tt": "HH.mm", "h:mm:ss tt": "HH.mm.ss", "dddd, MMMM dd, yyyy h:mm:ss tt": "'den 'd MMMM yyyy HH.mm.ss", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH.mm.ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH.mm.ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH.mm.ss", "MMMM dd": "'den 'd MMMM", "MMMM, yyyy": "MMMM yyyy", "/jan(uary)?/": "jan(uari)?", "/feb(ruary)?/": "feb(ruari)?", "/mar(ch)?/": "mar(s)?", "/apr(il)?/": "apr(il)?", "/may/": "maj", "/jun(e)?/": "jun(i)?", "/jul(y)?/": "jul(i)?", "/aug(ust)?/": "aug(usti)?", "/sep(t(ember)?)?/": "sep(t(ember)?)?", "/oct(ober)?/": "okt(ober)?", "/nov(ember)?/": "nov(ember)?", "/dec(ember)?/": "dec(ember)?", "/^su(n(day)?)?/": "^sö(n(dag)?)?", "/^mo(n(day)?)?/": "^må(n(dag)?)?", "/^tu(e(s(day)?)?)?/": "^ti(s(dag)?)?", "/^we(d(nesday)?)?/": "^on(s(dag)?)?", "/^th(u(r(s(day)?)?)?)?/": "^to(r(s(dag)?)?)?", "/^fr(i(day)?)?/": "^fr(e(dag)?)?", "/^sa(t(urday)?)?/": "^lö(r(dag)?)?", "/^next/": "^nästa", "/^last|past|prev(ious)?/": "^föregående|förra|senaste", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|efter|från)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|före|tidigare)", "/^yes(terday)?/": "^i\\s?går|(för)går(dag)?", "/^t(od(ay)?)?/": "^i\\s?dag?", "/^tom(orrow)?/": "^i\\s?morgon|morgon(dag)?", "/^n(ow)?/": "^nu", "/^ms|milli(second)?s?/": "^ms|milli(sekund)?(er)?", "/^sec(ond)?s?/": "^sek(und)?(er)?", "/^mn|min(ute)?s?/": "^min(ut)?(er)?", "/^h(our)?s?/": "^t(im)?(ar)?", "/^w(eek)?s?/": "^v(eck(a)?)?(or)?", "/^m(onth)?s?/": "^m(ånad)?(er)?", "/^d(ay)?s?/": "^d(ag)?(ar)?", "/^y(ear)?s?/": "^å(r)?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "sv-SE"; ================================================ FILE: src/i18n/sw-KE.js ================================================ /* * DateJS Culture String File * Country Code: sw-KE * Name: Kiswahili (Kenya) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["sw-KE"] = { "name": "sw-KE", "englishName": "Kiswahili (Kenya)", "nativeName": "Kiswahili (Kenya)", "Sunday": "Sunday", "Monday": "Monday", "Tuesday": "Tuesday", "Wednesday": "Wednesday", "Thursday": "Thursday", "Friday": "Friday", "Saturday": "Saturday", "Sun": "Sun", "Mon": "Mon", "Tue": "Tue", "Wed": "Wed", "Thu": "Thu", "Fri": "Fri", "Sat": "Sat", "Su": "S", "Mo": "M", "Tu": "T", "We": "W", "Th": "T", "Fr": "F", "Sa": "S", "S_Sun_Initial": "S", "M_Mon_Initial": "M", "T_Tue_Initial": "T", "W_Wed_Initial": "W", "T_Thu_Initial": "T", "F_Fri_Initial": "F", "S_Sat_Initial": "S", "January": "January", "February": "February", "March": "March", "April": "April", "May": "May", "June": "June", "July": "July", "August": "August", "September": "September", "October": "October", "November": "November", "December": "December", "Jan_Abbr": "Jan", "Feb_Abbr": "Feb", "Mar_Abbr": "Mar", "Apr_Abbr": "Apr", "May_Abbr": "May", "Jun_Abbr": "Jun", "Jul_Abbr": "Jul", "Aug_Abbr": "Aug", "Sep_Abbr": "Sep", "Oct_Abbr": "Oct", "Nov_Abbr": "Nov", "Dec_Abbr": "Dec", "AM": "AM", "PM": "PM", "firstDayOfWeek": 0, "twoDigitYearMax": 2029, "mdy": "mdy", "M/d/yyyy": "M/d/yyyy", "dddd, MMMM dd, yyyy": "dddd, MMMM dd, yyyy", "h:mm tt": "h:mm tt", "h:mm:ss tt": "h:mm:ss tt", "dddd, MMMM dd, yyyy h:mm:ss tt": "dddd, MMMM dd, yyyy h:mm:ss tt", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "MMMM dd", "MMMM, yyyy": "MMMM, yyyy", "/jan(uary)?/": "jan(uary)?", "/feb(ruary)?/": "feb(ruary)?", "/mar(ch)?/": "mar(ch)?", "/apr(il)?/": "apr(il)?", "/may/": "may", "/jun(e)?/": "jun(e)?", "/jul(y)?/": "jul(y)?", "/aug(ust)?/": "aug(ust)?", "/sep(t(ember)?)?/": "sep(t(ember)?)?", "/oct(ober)?/": "oct(ober)?", "/nov(ember)?/": "nov(ember)?", "/dec(ember)?/": "dec(ember)?", "/^su(n(day)?)?/": "^s(un(day)?)?", "/^mo(n(day)?)?/": "^m(on(day)?)?", "/^tu(e(s(day)?)?)?/": "^tu(e(s(day)?)?)?", "/^we(d(nesday)?)?/": "^w(ed(nesday)?)?", "/^th(u(r(s(day)?)?)?)?/": "^th(u(r(s(day)?)?)?)?", "/^fr(i(day)?)?/": "^f(ri(day)?)?", "/^sa(t(urday)?)?/": "^s(at(urday)?)?", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "sw-KE"; ================================================ FILE: src/i18n/syr-SY.js ================================================ /* * DateJS Culture String File * Country Code: syr-SY * Name: Syriac (Syria) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["syr-SY"] = { "name": "syr-SY", "englishName": "Syriac (Syria)", "nativeName": "ܣܘܪܝܝܐ (سوريا)", "Sunday": "ܚܕ ܒܫܒܐ", "Monday": "ܬܪܝܢ ܒܫܒܐ", "Tuesday": "ܬܠܬܐ ܒܫܒܐ", "Wednesday": "ܐܪܒܥܐ ܒܫܒܐ", "Thursday": "ܚܡܫܐ ܒܫܒܐ", "Friday": "ܥܪܘܒܬܐ", "Saturday": "ܫܒܬܐ", "Sun": "܏ܐ ܏ܒܫ", "Mon": "܏ܒ ܏ܒܫ", "Tue": "܏ܓ ܏ܒܫ", "Wed": "܏ܕ ܏ܒܫ", "Thu": "܏ܗ ܏ܒܫ", "Fri": "܏ܥܪܘܒ", "Sat": "܏ܫܒ", "Su": "܏", "Mo": "܏", "Tu": "܏", "We": "܏", "Th": "܏", "Fr": "܏", "Sa": "܏", "S_Sun_Initial": "܏", "M_Mon_Initial": "܏", "T_Tue_Initial": "܏", "W_Wed_Initial": "܏", "T_Thu_Initial": "܏", "F_Fri_Initial": "܏", "S_Sat_Initial": "܏", "January": "ܟܢܘܢ ܐܚܪܝ", "February": "ܫܒܛ", "March": "ܐܕܪ", "April": "ܢܝܣܢ", "May": "ܐܝܪ", "June": "ܚܙܝܪܢ", "July": "ܬܡܘܙ", "August": "ܐܒ", "September": "ܐܝܠܘܠ", "October": "ܬܫܪܝ ܩܕܝܡ", "November": "ܬܫܪܝ ܐܚܪܝ", "December": "ܟܢܘܢ ܩܕܝܡ", "Jan_Abbr": "܏ܟܢ ܏ܒ", "Feb_Abbr": "ܫܒܛ", "Mar_Abbr": "ܐܕܪ", "Apr_Abbr": "ܢܝܣܢ", "May_Abbr": "ܐܝܪ", "Jun_Abbr": "ܚܙܝܪܢ", "Jul_Abbr": "ܬܡܘܙ", "Aug_Abbr": "ܐܒ", "Sep_Abbr": "ܐܝܠܘܠ", "Oct_Abbr": "܏ܬܫ ܏ܐ", "Nov_Abbr": "܏ܬܫ ܏ܒ", "Dec_Abbr": "܏ܟܢ ܏ܐ", "AM": "ܩ.ܛ", "PM": "ܒ.ܛ", "firstDayOfWeek": 6, "twoDigitYearMax": 2029, "mdy": "dmy", "M/d/yyyy": "dd/MM/yyyy", "dddd, MMMM dd, yyyy": "dd MMMM, yyyy", "h:mm tt": "hh:mm tt", "h:mm:ss tt": "hh:mm:ss tt", "dddd, MMMM dd, yyyy h:mm:ss tt": "dd MMMM, yyyy hh:mm:ss tt", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "dd MMMM", "MMMM, yyyy": "MMMM, yyyy", "/jan(uary)?/": "ܟܢܘܢ ܐܚܪܝ", "/feb(ruary)?/": "ܫܒܛ", "/mar(ch)?/": "ܐܕܪ", "/apr(il)?/": "ܢܝܣܢ", "/may/": "ܐܝܪ", "/jun(e)?/": "ܚܙܝܪܢ", "/jul(y)?/": "ܬܡܘܙ", "/aug(ust)?/": "ܐܒ", "/sep(t(ember)?)?/": "ܐܝܠܘܠ", "/oct(ober)?/": "ܬܫܪܝ ܩܕܝܡ", "/nov(ember)?/": "ܬܫܪܝ ܐܚܪܝ", "/dec(ember)?/": "ܟܢܘܢ ܩܕܝܡ", "/^su(n(day)?)?/": "^܏(ܐ ܏ܒܫ(ܐ)?)?", "/^mo(n(day)?)?/": "^܏(ܒ ܏ܒܫ(ܫܒܐ)?)?", "/^tu(e(s(day)?)?)?/": "^܏(ܓ ܏ܒܫ(ܫܒܐ)?)?", "/^we(d(nesday)?)?/": "^܏(ܕ ܏ܒܫ(ܒܫܒܐ)?)?", "/^th(u(r(s(day)?)?)?)?/": "^܏(ܗ ܏ܒܫ(ܫܒܐ)?)?", "/^fr(i(day)?)?/": "^܏(ܥܪܘܒ(ܐ)?)?", "/^sa(t(urday)?)?/": "^܏(ܫܒ(ܐ)?)?", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "syr-SY"; ================================================ FILE: src/i18n/ta-IN.js ================================================ /* * DateJS Culture String File * Country Code: ta-IN * Name: Tamil (India) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["ta-IN"] = { "name": "ta-IN", "englishName": "Tamil (India)", "nativeName": "தமிழ் (இந்தியா)", "Sunday": "ஞாயிறு", "Monday": "திங்கள்", "Tuesday": "செவ்வாய்", "Wednesday": "புதன்", "Thursday": "வியாழன்", "Friday": "வெள்ளி", "Saturday": "சனி", "Sun": "ஞா", "Mon": "தி", "Tue": "செ", "Wed": "பு", "Thu": "வி", "Fri": "வெ", "Sat": "ச", "Su": "ஞ", "Mo": "த", "Tu": "ச", "We": "ப", "Th": "வ", "Fr": "வ", "Sa": "ச", "S_Sun_Initial": "ஞ", "M_Mon_Initial": "த", "T_Tue_Initial": "ச", "W_Wed_Initial": "ப", "T_Thu_Initial": "வ", "F_Fri_Initial": "வ", "S_Sat_Initial": "ச", "January": "ஜனவரி", "February": "பெப்ரவரி", "March": "மார்ச்", "April": "ஏப்ரல்", "May": "மே", "June": "ஜூன்", "July": "ஜூலை", "August": "ஆகஸ்ட்", "September": "செப்டம்பர்", "October": "அக்டோபர்", "November": "நவம்பர்", "December": "டிசம்பர்", "Jan_Abbr": "ஜன.", "Feb_Abbr": "பெப்.", "Mar_Abbr": "மார்.", "Apr_Abbr": "ஏப்.", "May_Abbr": "மே", "Jun_Abbr": "ஜூன்", "Jul_Abbr": "ஜூலை", "Aug_Abbr": "ஆக.", "Sep_Abbr": "செப்.", "Oct_Abbr": "அக்.", "Nov_Abbr": "நவ.", "Dec_Abbr": "டிச.", "AM": "காலை", "PM": "மாலை", "firstDayOfWeek": 1, "twoDigitYearMax": 2029, "mdy": "dmy", "M/d/yyyy": "dd-MM-yyyy", "dddd, MMMM dd, yyyy": "dd MMMM yyyy", "h:mm tt": "HH:mm", "h:mm:ss tt": "HH:mm:ss", "dddd, MMMM dd, yyyy h:mm:ss tt": "dd MMMM yyyy HH:mm:ss", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "dd MMMM", "MMMM, yyyy": "MMMM yyyy", "/jan(uary)?/": "ஜன(.(வரி)?)?", "/feb(ruary)?/": "பெப்(.(ரவரி)?)?", "/mar(ch)?/": "மார்(.(ச்)?)?", "/apr(il)?/": "ஏப்(.(ரல்)?)?", "/may/": "மே", "/jun(e)?/": "ஜூன்", "/jul(y)?/": "ஜூலை", "/aug(ust)?/": "ஆக(.(ஸ்ட்)?)?", "/sep(t(ember)?)?/": "செப்(.(டம்பர்)?)?", "/oct(ober)?/": "அக்(.(டோபர்)?)?", "/nov(ember)?/": "நவ(.(ம்பர்)?)?", "/dec(ember)?/": "டிச(.(ம்பர்)?)?", "/^su(n(day)?)?/": "^ஞ(ா(யிறு)?)?", "/^mo(n(day)?)?/": "^த(ி(ங்கள்)?)?", "/^tu(e(s(day)?)?)?/": "^ச(ெ(வ்வாய்)?)?", "/^we(d(nesday)?)?/": "^ப(ு(தன்)?)?", "/^th(u(r(s(day)?)?)?)?/": "^வ(ி(யாழன்)?)?", "/^fr(i(day)?)?/": "^வ(ெ(ள்ளி)?)?", "/^sa(t(urday)?)?/": "^சனி", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "ta-IN"; ================================================ FILE: src/i18n/te-IN.js ================================================ /* * DateJS Culture String File * Country Code: te-IN * Name: Telugu (India) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["te-IN"] = { "name": "te-IN", "englishName": "Telugu (India)", "nativeName": "తెలుగు (భారత దేశం)", "Sunday": "ఆదివారం", "Monday": "సోమవారం", "Tuesday": "మంగళవారం", "Wednesday": "బుధవారం", "Thursday": "గురువారం", "Friday": "శుక్రవారం", "Saturday": "శనివారం", "Sun": "ఆది.", "Mon": "సోమ.", "Tue": "మంగళ.", "Wed": "బుధ.", "Thu": "గురు.", "Fri": "శుక్ర.", "Sat": "శని.", "Su": "ఆ", "Mo": "స", "Tu": "మ", "We": "బ", "Th": "గ", "Fr": "శ", "Sa": "శ", "S_Sun_Initial": "ఆ", "M_Mon_Initial": "స", "T_Tue_Initial": "మ", "W_Wed_Initial": "బ", "T_Thu_Initial": "గ", "F_Fri_Initial": "శ", "S_Sat_Initial": "శ", "January": "జనవరి", "February": "ఫిబ్రవరి", "March": "మార్చి", "April": "ఏప్రిల్", "May": "మే", "June": "జూన్", "July": "జూలై", "August": "ఆగస్టు", "September": "సెప్టెంబర్", "October": "అక్టోబర్", "November": "నవంబర్", "December": "డిసెంబర్", "Jan_Abbr": "జనవరి", "Feb_Abbr": "ఫిబ్రవరి", "Mar_Abbr": "మార్చి", "Apr_Abbr": "ఏప్రిల్", "May_Abbr": "మే", "Jun_Abbr": "జూన్", "Jul_Abbr": "జూలై", "Aug_Abbr": "ఆగస్టు", "Sep_Abbr": "సెప్టెంబర్", "Oct_Abbr": "అక్టోబర్", "Nov_Abbr": "నవంబర్", "Dec_Abbr": "డిసెంబర్", "AM": "పూర్వాహ్న", "PM": "అపరాహ్న", "firstDayOfWeek": 1, "twoDigitYearMax": 2029, "mdy": "dmy", "M/d/yyyy": "dd-MM-yy", "dddd, MMMM dd, yyyy": "dd MMMM yyyy", "h:mm tt": "HH:mm", "h:mm:ss tt": "HH:mm:ss", "dddd, MMMM dd, yyyy h:mm:ss tt": "dd MMMM yyyy HH:mm:ss", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "dd MMMM", "MMMM, yyyy": "MMMM, yyyy", "/jan(uary)?/": "జనవరి", "/feb(ruary)?/": "ఫిబ్రవరి", "/mar(ch)?/": "మార్చి", "/apr(il)?/": "ఏప్రిల్", "/may/": "మే", "/jun(e)?/": "జూన్", "/jul(y)?/": "జూలై", "/aug(ust)?/": "ఆగస్టు", "/sep(t(ember)?)?/": "సెప్టెంబర్", "/oct(ober)?/": "అక్టోబర్", "/nov(ember)?/": "నవంబర్", "/dec(ember)?/": "డిసెంబర్", "/^su(n(day)?)?/": "^ఆ(ది(.(వారం)?)?)?", "/^mo(n(day)?)?/": "^స(ోమ(.(వారం)?)?)?", "/^tu(e(s(day)?)?)?/": "^మ(ంగళ(.(వారం)?)?)?", "/^we(d(nesday)?)?/": "^బ(ుధ(.(వారం)?)?)?", "/^th(u(r(s(day)?)?)?)?/": "^గ(ురు(.(వారం)?)?)?", "/^fr(i(day)?)?/": "^శ(ుక్ర(.(వారం)?)?)?", "/^sa(t(urday)?)?/": "^శ(ని(.(వారం)?)?)?", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "te-IN"; ================================================ FILE: src/i18n/th-TH.js ================================================ /* * DateJS Culture String File * Country Code: th-TH * Name: Thai (Thailand) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["th-TH"] = { "name": "th-TH", "englishName": "Thai (Thailand)", "nativeName": "ไทย (ไทย)", "Sunday": "อาทิตย์", "Monday": "จันทร์", "Tuesday": "อังคาร", "Wednesday": "พุธ", "Thursday": "พฤหัสบดี", "Friday": "ศุกร์", "Saturday": "เสาร์", "Sun": "อา.", "Mon": "จ.", "Tue": "อ.", "Wed": "พ.", "Thu": "พฤ.", "Fri": "ศ.", "Sat": "ส.", "Su": "อ", "Mo": "จ", "Tu": "อ", "We": "พ", "Th": "พ", "Fr": "ศ", "Sa": "ส", "S_Sun_Initial": "อ", "M_Mon_Initial": "จ", "T_Tue_Initial": "อ", "W_Wed_Initial": "พ", "T_Thu_Initial": "พ", "F_Fri_Initial": "ศ", "S_Sat_Initial": "ส", "January": "มกราคม", "February": "กุมภาพันธ์", "March": "มีนาคม", "April": "เมษายน", "May": "พฤษภาคม", "June": "มิถุนายน", "July": "กรกฎาคม", "August": "สิงหาคม", "September": "กันยายน", "October": "ตุลาคม", "November": "พฤศจิกายน", "December": "ธันวาคม", "Jan_Abbr": "ม.ค.", "Feb_Abbr": "ก.พ.", "Mar_Abbr": "มี.ค.", "Apr_Abbr": "เม.ย.", "May_Abbr": "พ.ค.", "Jun_Abbr": "มิ.ย.", "Jul_Abbr": "ก.ค.", "Aug_Abbr": "ส.ค.", "Sep_Abbr": "ก.ย.", "Oct_Abbr": "ต.ค.", "Nov_Abbr": "พ.ย.", "Dec_Abbr": "ธ.ค.", "AM": "AM", "PM": "PM", "firstDayOfWeek": 1, "twoDigitYearMax": 2572, "mdy": "dmy", "M/d/yyyy": "d/M/yyyy", "dddd, MMMM dd, yyyy": "d MMMM yyyy", "h:mm tt": "H:mm", "h:mm:ss tt": "H:mm:ss", "dddd, MMMM dd, yyyy h:mm:ss tt": "d MMMM yyyy H:mm:ss", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "dd MMMM", "MMMM, yyyy": "MMMM yyyy", "/jan(uary)?/": "ม(.(กราค)?)?", "/feb(ruary)?/": "ก(.(ุมภาพันธ์)?)?", "/mar(ch)?/": "มี(.(นาคม)?)?", "/apr(il)?/": "เม(.(ษายน)?)?", "/may/": "พ(.(ฤษภาคม)?)?", "/jun(e)?/": "มิ(.(ถุนายน)?)?", "/jul(y)?/": "ก(.(รฎาคม)?)?", "/aug(ust)?/": "ส(.(ิงหาคม)?)?", "/sep(t(ember)?)?/": "ก(.(ันยายน)?)?", "/oct(ober)?/": "ต(.(ุลาคม)?)?", "/nov(ember)?/": "พ(.(ฤศจิกายน)?)?", "/dec(ember)?/": "ธ(.(ันวาคม)?)?", "/^su(n(day)?)?/": "^อ(า(.(ทิตย์)?)?)?", "/^mo(n(day)?)?/": "^จ((.(ันทร์)?)?)?", "/^tu(e(s(day)?)?)?/": "^อ((.(ังคาร)?)?)?", "/^we(d(nesday)?)?/": "^พ((.(ุธ)?)?)?", "/^th(u(r(s(day)?)?)?)?/": "^พ(ฤ(.(หัสบดี)?)?)?", "/^fr(i(day)?)?/": "^ศ((.(ุกร์)?)?)?", "/^sa(t(urday)?)?/": "^ส((.(สาร์)?)?)?", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "th-TH"; ================================================ FILE: src/i18n/tn-ZA.js ================================================ /* * DateJS Culture String File * Country Code: tn-ZA * Name: Tswana (South Africa) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["tn-ZA"] = { "name": "tn-ZA", "englishName": "Tswana (South Africa)", "nativeName": "Setswana (Aforika Borwa)", "Sunday": "Latshipi", "Monday": "Mosupologo", "Tuesday": "Labobedi", "Wednesday": "Laboraro", "Thursday": "Labone", "Friday": "Labotlhano", "Saturday": "Lamatlhatso", "Sun": "Sun", "Mon": "Mon", "Tue": "Tue", "Wed": "Wed", "Thu": "Thu", "Fri": "Fri", "Sat": "Sat", "Su": "Sun", "Mo": "Mon", "Tu": "Tue", "We": "Wed", "Th": "Thu", "Fr": "Fri", "Sa": "Sat", "S_Sun_Initial": "S", "M_Mon_Initial": "M", "T_Tue_Initial": "T", "W_Wed_Initial": "W", "T_Thu_Initial": "T", "F_Fri_Initial": "F", "S_Sat_Initial": "S", "January": "Ferikgong", "February": "Tlhakole", "March": "Mopitloe", "April": "Moranang", "May": "Motsheganong", "June": "Seetebosigo", "July": "Phukwi", "August": "Phatwe", "September": "Lwetse", "October": "Diphalane", "November": "Ngwanatsele", "December": "Sedimothole", "Jan_Abbr": "Jan", "Feb_Abbr": "Feb", "Mar_Abbr": "Mar", "Apr_Abbr": "Apr", "May_Abbr": "May", "Jun_Abbr": "Jun", "Jul_Abbr": "Jul", "Aug_Abbr": "Aug", "Sep_Abbr": "Sep", "Oct_Abbr": "Oct", "Nov_Abbr": "Nov", "Dec_Abbr": "Dec", "AM": "AM", "PM": "PM", "firstDayOfWeek": 0, "twoDigitYearMax": 2029, "mdy": "ymd", "M/d/yyyy": "yyyy/MM/dd", "dddd, MMMM dd, yyyy": "dd MMMM yyyy", "h:mm tt": "hh:mm:ss tt", "h:mm:ss tt": "hh:mm:ss tt", "dddd, MMMM dd, yyyy h:mm:ss tt": "dd MMMM yyyy hh:mm:ss tt", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "MMMM dd", "MMMM, yyyy": "MMMM yyyy", "/jan(uary)?/": "ferikgong", "/feb(ruary)?/": "tlhakole", "/mar(ch)?/": "mopitloe", "/apr(il)?/": "moranang", "/may/": "motsheganong", "/jun(e)?/": "seetebosigo", "/jul(y)?/": "phukwi", "/aug(ust)?/": "phatwe", "/sep(t(ember)?)?/": "lwetse", "/oct(ober)?/": "diphalane", "/nov(ember)?/": "ngwanatsele", "/dec(ember)?/": "sedimothole", "/^su(n(day)?)?/": "^latshipi", "/^mo(n(day)?)?/": "^mosupologo", "/^tu(e(s(day)?)?)?/": "^labobedi", "/^we(d(nesday)?)?/": "^laboraro", "/^th(u(r(s(day)?)?)?)?/": "^labone", "/^fr(i(day)?)?/": "^labotlhano", "/^sa(t(urday)?)?/": "^lamatlhatso", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "tn-ZA"; ================================================ FILE: src/i18n/tr-TR.js ================================================ /* * DateJS Culture String File * Country Code: tr-TR * Name: Turkish (Turkey) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["tr-TR"] = { "name": "tr-TR", "englishName": "Turkish (Turkey)", "nativeName": "Türkçe (Türkiye)", "Sunday": "Pazar", "Monday": "Pazartesi", "Tuesday": "Salı", "Wednesday": "Çarşamba", "Thursday": "Perşembe", "Friday": "Cuma", "Saturday": "Cumartesi", "Sun": "Paz", "Mon": "Pzt", "Tue": "Sal", "Wed": "Çar", "Thu": "Per", "Fri": "Cum", "Sat": "Cmt", "Su": "Pz", "Mo": "Pt", "Tu": "Sa", "We": "Ça", "Th": "Pe", "Fr": "Cu", "Sa": "Ct", "S_Sun_Initial": "P", "M_Mon_Initial": "P", "T_Tue_Initial": "S", "W_Wed_Initial": "Ç", "T_Thu_Initial": "P", "F_Fri_Initial": "C", "S_Sat_Initial": "C", "January": "Ocak", "February": "Şubat", "March": "Mart", "April": "Nisan", "May": "Mayıs", "June": "Haziran", "July": "Temmuz", "August": "Ağustos", "September": "Eylül", "October": "Ekim", "November": "Kasım", "December": "Aralık", "Jan_Abbr": "Oca", "Feb_Abbr": "Şub", "Mar_Abbr": "Mar", "Apr_Abbr": "Nis", "May_Abbr": "May", "Jun_Abbr": "Haz", "Jul_Abbr": "Tem", "Aug_Abbr": "Ağu", "Sep_Abbr": "Eyl", "Oct_Abbr": "Eki", "Nov_Abbr": "Kas", "Dec_Abbr": "Ara", "AM": "", "PM": "", "firstDayOfWeek": 1, "twoDigitYearMax": 2029, "mdy": "dmy", "M/d/yyyy": "dd.MM.yyyy", "dddd, MMMM dd, yyyy": "dd MMMM yyyy dddd", "h:mm tt": "HH:mm", "h:mm:ss tt": "HH:mm:ss", "dddd, MMMM dd, yyyy h:mm:ss tt": "dd MMMM yyyy dddd HH:mm:ss", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "dd MMMM", "MMMM, yyyy": "MMMM yyyy", "/jan(uary)?/": "oca(k)?", "/feb(ruary)?/": "şub(at)?", "/mar(ch)?/": "mar(t)?", "/apr(il)?/": "nis(an)?", "/may/": "may(ıs)?", "/jun(e)?/": "haz(iran)?", "/jul(y)?/": "tem(muz)?", "/aug(ust)?/": "ağu(stos)?", "/sep(t(ember)?)?/": "eyl(ül)?", "/oct(ober)?/": "eki(m)?", "/nov(ember)?/": "kas(ım)?", "/dec(ember)?/": "ara(lık)?", "/^su(n(day)?)?/": "^pz(z(ar)?)?", "/^mo(n(day)?)?/": "^pt(t(artesi)?)?", "/^tu(e(s(day)?)?)?/": "^sa(l(ı)?)?", "/^we(d(nesday)?)?/": "^ça(r(şamba)?)?", "/^th(u(r(s(day)?)?)?)?/": "^pe(r(şembe)?)?", "/^fr(i(day)?)?/": "^cu(m(a)?)?", "/^sa(t(urday)?)?/": "^ct(t(artesi)?)?", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "tr-TR"; ================================================ FILE: src/i18n/tt-RU.js ================================================ /* * DateJS Culture String File * Country Code: tt-RU * Name: Tatar (Russia) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["tt-RU"] = { "name": "tt-RU", "englishName": "Tatar (Russia)", "nativeName": "Татар (Россия)", "Sunday": "Якшәмбе", "Monday": "Дүшәмбе", "Tuesday": "Сишәмбе", "Wednesday": "Чәршәмбе", "Thursday": "Пәнҗешәмбе", "Friday": "Җомга", "Saturday": "Шимбә", "Sun": "Якш", "Mon": "Дүш", "Tue": "Сиш", "Wed": "Чәрш", "Thu": "Пәнҗ", "Fri": "Җом", "Sat": "Шим", "Su": "Якш", "Mo": "Дүш", "Tu": "Сиш", "We": "Чәрш", "Th": "Пәнҗ", "Fr": "Җом", "Sa": "Шим", "S_Sun_Initial": "Я", "M_Mon_Initial": "Д", "T_Tue_Initial": "С", "W_Wed_Initial": "Ч", "T_Thu_Initial": "П", "F_Fri_Initial": "Җ", "S_Sat_Initial": "Ш", "January": "Гыйнварь", "February": "Февраль", "March": "Март", "April": "Апрель", "May": "Май", "June": "Июнь", "July": "Июль", "August": "Август", "September": "Сентябрь", "October": "Октябрь", "November": "Ноябрь", "December": "Декабрь", "Jan_Abbr": "Гыйнв", "Feb_Abbr": "Фев", "Mar_Abbr": "Мар", "Apr_Abbr": "Апр", "May_Abbr": "Май", "Jun_Abbr": "Июн", "Jul_Abbr": "Июл", "Aug_Abbr": "Авг", "Sep_Abbr": "Сен", "Oct_Abbr": "Окт", "Nov_Abbr": "Ноя", "Dec_Abbr": "Дек", "AM": "", "PM": "", "firstDayOfWeek": 1, "twoDigitYearMax": 2029, "mdy": "dmy", "M/d/yyyy": "dd.MM.yyyy", "dddd, MMMM dd, yyyy": "d MMMM yyyy", "h:mm tt": "H:mm", "h:mm:ss tt": "H:mm:ss", "dddd, MMMM dd, yyyy h:mm:ss tt": "d MMMM yyyy H:mm:ss", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "d MMMM", "MMMM, yyyy": "MMMM yyyy", "/jan(uary)?/": "гыйнв(арь)?", "/feb(ruary)?/": "фев(раль)?", "/mar(ch)?/": "мар(т)?", "/apr(il)?/": "апр(ель)?", "/may/": "май", "/jun(e)?/": "июн(ь)?", "/jul(y)?/": "июл(ь)?", "/aug(ust)?/": "авг(уст)?", "/sep(t(ember)?)?/": "сен(тябрь)?", "/oct(ober)?/": "окт(ябрь)?", "/nov(ember)?/": "ноя(брь)?", "/dec(ember)?/": "дек(абрь)?", "/^su(n(day)?)?/": "^якшәмбе", "/^mo(n(day)?)?/": "^дүшәмбе", "/^tu(e(s(day)?)?)?/": "^сишәмбе", "/^we(d(nesday)?)?/": "^чәршәмбе", "/^th(u(r(s(day)?)?)?)?/": "^пәнҗешәмбе", "/^fr(i(day)?)?/": "^җомга", "/^sa(t(urday)?)?/": "^шимбә", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "tt-RU"; ================================================ FILE: src/i18n/uk-UA.js ================================================ /* * DateJS Culture String File * Country Code: uk-UA * Name: Ukrainian (Ukraine) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["uk-UA"] = { "name": "uk-UA", "englishName": "Ukrainian (Ukraine)", "nativeName": "україньска (Україна)", "Sunday": "неділя", "Monday": "понеділок", "Tuesday": "вівторок", "Wednesday": "середа", "Thursday": "четвер", "Friday": "п'ятниця", "Saturday": "субота", "Sun": "Нд", "Mon": "Пн", "Tue": "Вт", "Wed": "Ср", "Thu": "Чт", "Fri": "Пт", "Sat": "Сб", "Su": "Нд", "Mo": "Пн", "Tu": "Вт", "We": "Ср", "Th": "Чт", "Fr": "Пт", "Sa": "Сб", "S_Sun_Initial": "Н", "M_Mon_Initial": "П", "T_Tue_Initial": "В", "W_Wed_Initial": "С", "T_Thu_Initial": "Ч", "F_Fri_Initial": "П", "S_Sat_Initial": "С", "January": "Січень", "February": "Лютий", "March": "Березень", "April": "Квітень", "May": "Травень", "June": "Червень", "July": "Липень", "August": "Серпень", "September": "Вересень", "October": "Жовтень", "November": "Листопад", "December": "Грудень", "Jan_Abbr": "Січ", "Feb_Abbr": "Лют", "Mar_Abbr": "Бер", "Apr_Abbr": "Кві", "May_Abbr": "Тра", "Jun_Abbr": "Чер", "Jul_Abbr": "Лип", "Aug_Abbr": "Сер", "Sep_Abbr": "Вер", "Oct_Abbr": "Жов", "Nov_Abbr": "Лис", "Dec_Abbr": "Гру", "AM": "", "PM": "", "firstDayOfWeek": 1, "twoDigitYearMax": 2029, "mdy": "dmy", "M/d/yyyy": "dd.MM.yyyy", "dddd, MMMM dd, yyyy": "d MMMM yyyy' р.'", "h:mm tt": "H:mm", "h:mm:ss tt": "H:mm:ss", "dddd, MMMM dd, yyyy h:mm:ss tt": "d MMMM yyyy' р.' H:mm:ss", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "d MMMM", "MMMM, yyyy": "MMMM yyyy' р.'", "/jan(uary)?/": "січ(ень)?", "/feb(ruary)?/": "лют(ий)?", "/mar(ch)?/": "бер(езень)?", "/apr(il)?/": "кві(тень)?", "/may/": "тра(вень)?", "/jun(e)?/": "чер(вень)?", "/jul(y)?/": "лип(ень)?", "/aug(ust)?/": "сер(пень)?", "/sep(t(ember)?)?/": "вер(есень)?", "/oct(ober)?/": "жов(тень)?", "/nov(ember)?/": "лис(топад)?", "/dec(ember)?/": "гру(день)?", "/^su(n(day)?)?/": "^неділя", "/^mo(n(day)?)?/": "^понеділок", "/^tu(e(s(day)?)?)?/": "^вівторок", "/^we(d(nesday)?)?/": "^середа", "/^th(u(r(s(day)?)?)?)?/": "^четвер", "/^fr(i(day)?)?/": "^п'ятниця", "/^sa(t(urday)?)?/": "^субота", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "uk-UA"; ================================================ FILE: src/i18n/ur-PK.js ================================================ /* * DateJS Culture String File * Country Code: ur-PK * Name: Urdu (Islamic Republic of Pakistan) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["ur-PK"] = { "name": "ur-PK", "englishName": "Urdu (Islamic Republic of Pakistan)", "nativeName": "اُردو (پاکستان)", "Sunday": "اتوار", "Monday": "پير", "Tuesday": "منگل", "Wednesday": "بدھ", "Thursday": "جمعرات", "Friday": "جمعه", "Saturday": "هفته", "Sun": "اتوار", "Mon": "پير", "Tue": "منگل", "Wed": "بدھ", "Thu": "جمعرات", "Fri": "جمعه", "Sat": "هفته", "Su": "ا", "Mo": "پ", "Tu": "م", "We": "ب", "Th": "ج", "Fr": "ج", "Sa": "ه", "S_Sun_Initial": "ا", "M_Mon_Initial": "پ", "T_Tue_Initial": "م", "W_Wed_Initial": "ب", "T_Thu_Initial": "ج", "F_Fri_Initial": "ج", "S_Sat_Initial": "ه", "January": "جنورى", "February": "فرورى", "March": "مارچ", "April": "اپريل", "May": "مئ", "June": "جون", "July": "جولاٸ", "August": "اگست", "September": "ستمبر", "October": "اکتوبر", "November": "نومبر", "December": "دسمبر", "Jan_Abbr": "جنورى", "Feb_Abbr": "فرورى", "Mar_Abbr": "مارچ", "Apr_Abbr": "اپريل", "May_Abbr": "مئ", "Jun_Abbr": "جون", "Jul_Abbr": "جولاٸ", "Aug_Abbr": "اگست", "Sep_Abbr": "ستمبر", "Oct_Abbr": "اکتوبر", "Nov_Abbr": "نومبر", "Dec_Abbr": "دسمبر", "AM": "AM", "PM": "PM", "firstDayOfWeek": 1, "twoDigitYearMax": 2029, "mdy": "dmy", "M/d/yyyy": "dd/MM/yyyy", "dddd, MMMM dd, yyyy": "dd MMMM, yyyy", "h:mm tt": "h:mm tt", "h:mm:ss tt": "h:mm:ss tt", "dddd, MMMM dd, yyyy h:mm:ss tt": "dd MMMM, yyyy h:mm:ss tt", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "dd MMMM", "MMMM, yyyy": "MMMM, yyyy", "/jan(uary)?/": "جنورى", "/feb(ruary)?/": "فرورى", "/mar(ch)?/": "مارچ", "/apr(il)?/": "اپريل", "/may/": "مئ", "/jun(e)?/": "جون", "/jul(y)?/": "جولاٸ", "/aug(ust)?/": "اگست", "/sep(t(ember)?)?/": "ستمبر", "/oct(ober)?/": "اکتوبر", "/nov(ember)?/": "نومبر", "/dec(ember)?/": "دسمبر", "/^su(n(day)?)?/": "^ا(1)?", "/^mo(n(day)?)?/": "^پ(1)?", "/^tu(e(s(day)?)?)?/": "^م(1)?", "/^we(d(nesday)?)?/": "^ب(1)?", "/^th(u(r(s(day)?)?)?)?/": "^ج(1)?", "/^fr(i(day)?)?/": "^ج(1)?", "/^sa(t(urday)?)?/": "^ه(1)?", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "ur-PK"; ================================================ FILE: src/i18n/uz-Cyrl-UZ.js ================================================ /* * DateJS Culture String File * Country Code: uz-Cyrl-UZ * Name: Uzbek (Cyrillic, Uzbekistan) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["uz-Cyrl-UZ"] = { "name": "uz-Cyrl-UZ", "englishName": "Uzbek (Cyrillic, Uzbekistan)", "nativeName": "Ўзбек (Ўзбекистон)", "Sunday": "якшанба", "Monday": "душанба", "Tuesday": "сешанба", "Wednesday": "чоршанба", "Thursday": "пайшанба", "Friday": "жума", "Saturday": "шанба", "Sun": "якш", "Mon": "дш", "Tue": "сш", "Wed": "чш", "Thu": "пш", "Fri": "ж", "Sat": "ш", "Su": "якш", "Mo": "дш", "Tu": "сш", "We": "чш", "Th": "пш", "Fr": "ж", "Sa": "ш", "S_Sun_Initial": "я", "M_Mon_Initial": "д", "T_Tue_Initial": "с", "W_Wed_Initial": "ч", "T_Thu_Initial": "п", "F_Fri_Initial": "ж", "S_Sat_Initial": "ш", "January": "Январ", "February": "Феврал", "March": "Март", "April": "Апрел", "May": "Май", "June": "Июн", "July": "Июл", "August": "Август", "September": "Сентябр", "October": "Октябр", "November": "Ноябр", "December": "Декабр", "Jan_Abbr": "Янв", "Feb_Abbr": "Фев", "Mar_Abbr": "Мар", "Apr_Abbr": "Апр", "May_Abbr": "Май", "Jun_Abbr": "Июн", "Jul_Abbr": "Июл", "Aug_Abbr": "Авг", "Sep_Abbr": "Сен", "Oct_Abbr": "Окт", "Nov_Abbr": "Ноя", "Dec_Abbr": "Дек", "AM": "", "PM": "", "firstDayOfWeek": 1, "twoDigitYearMax": 2029, "mdy": "dmy", "M/d/yyyy": "dd.MM.yyyy", "dddd, MMMM dd, yyyy": "yyyy 'йил' d-MMMM", "h:mm tt": "HH:mm", "h:mm:ss tt": "HH:mm:ss", "dddd, MMMM dd, yyyy h:mm:ss tt": "yyyy 'йил' d-MMMM HH:mm:ss", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "d-MMMM", "MMMM, yyyy": "MMMM yyyy", "/jan(uary)?/": "янв(ар)?", "/feb(ruary)?/": "фев(рал)?", "/mar(ch)?/": "мар(т)?", "/apr(il)?/": "апр(ел)?", "/may/": "май", "/jun(e)?/": "июн", "/jul(y)?/": "июл", "/aug(ust)?/": "авг(уст)?", "/sep(t(ember)?)?/": "сен(тябр)?", "/oct(ober)?/": "окт(ябр)?", "/nov(ember)?/": "ноя(бр)?", "/dec(ember)?/": "дек(абр)?", "/^su(n(day)?)?/": "^якшанба", "/^mo(n(day)?)?/": "^душанба", "/^tu(e(s(day)?)?)?/": "^сешанба", "/^we(d(nesday)?)?/": "^чоршанба", "/^th(u(r(s(day)?)?)?)?/": "^пайшанба", "/^fr(i(day)?)?/": "^жума", "/^sa(t(urday)?)?/": "^шанба", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "uz-Cyrl-UZ"; ================================================ FILE: src/i18n/uz-Latn-UZ.js ================================================ /* * DateJS Culture String File * Country Code: uz-Latn-UZ * Name: Uzbek (Latin, Uzbekistan) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["uz-Latn-UZ"] = { "name": "uz-Latn-UZ", "englishName": "Uzbek (Latin, Uzbekistan)", "nativeName": "U'zbek (U'zbekiston Respublikasi)", "Sunday": "yakshanba", "Monday": "dushanba", "Tuesday": "seshanba", "Wednesday": "chorshanba", "Thursday": "payshanba", "Friday": "juma", "Saturday": "shanba", "Sun": "yak.", "Mon": "dsh.", "Tue": "sesh.", "Wed": "chr.", "Thu": "psh.", "Fri": "jm.", "Sat": "sh.", "Su": "yak", "Mo": "dsh", "Tu": "sesh", "We": "chr", "Th": "psh", "Fr": "jm", "Sa": "sh", "S_Sun_Initial": "y", "M_Mon_Initial": "d", "T_Tue_Initial": "s", "W_Wed_Initial": "c", "T_Thu_Initial": "p", "F_Fri_Initial": "j", "S_Sat_Initial": "s", "January": "yanvar", "February": "fevral", "March": "mart", "April": "aprel", "May": "may", "June": "iyun", "July": "iyul", "August": "avgust", "September": "sentyabr", "October": "oktyabr", "November": "noyabr", "December": "dekabr", "Jan_Abbr": "yanvar", "Feb_Abbr": "fevral", "Mar_Abbr": "mart", "Apr_Abbr": "aprel", "May_Abbr": "may", "Jun_Abbr": "iyun", "Jul_Abbr": "iyul", "Aug_Abbr": "avgust", "Sep_Abbr": "sentyabr", "Oct_Abbr": "oktyabr", "Nov_Abbr": "noyabr", "Dec_Abbr": "dekabr", "AM": "", "PM": "", "firstDayOfWeek": 1, "twoDigitYearMax": 2029, "mdy": "dmy", "M/d/yyyy": "dd/MM yyyy", "dddd, MMMM dd, yyyy": "yyyy 'yil' d-MMMM", "h:mm tt": "HH:mm", "h:mm:ss tt": "HH:mm:ss", "dddd, MMMM dd, yyyy h:mm:ss tt": "yyyy 'yil' d-MMMM HH:mm:ss", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "d-MMMM", "MMMM, yyyy": "MMMM yyyy", "/jan(uary)?/": "yanvar", "/feb(ruary)?/": "fevral", "/mar(ch)?/": "mart", "/apr(il)?/": "aprel", "/may/": "may", "/jun(e)?/": "iyun", "/jul(y)?/": "iyul", "/aug(ust)?/": "avgust", "/sep(t(ember)?)?/": "sentyabr", "/oct(ober)?/": "oktyabr", "/nov(ember)?/": "noyabr", "/dec(ember)?/": "dekabr", "/^su(n(day)?)?/": "^yak((.(shanba)?)?)?", "/^mo(n(day)?)?/": "^dsh((.(hanba)?)?)?", "/^tu(e(s(day)?)?)?/": "^sesh((.(anba)?)?)?", "/^we(d(nesday)?)?/": "^chr((.(rshanba)?)?)?", "/^th(u(r(s(day)?)?)?)?/": "^psh((.(shanba)?)?)?", "/^fr(i(day)?)?/": "^jm((.(ma)?)?)?", "/^sa(t(urday)?)?/": "^sh((.(anba)?)?)?", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "uz-Latn-UZ"; ================================================ FILE: src/i18n/vi-VN.js ================================================ /* * DateJS Culture String File * Country Code: vi-VN * Name: Vietnamese (Vietnam) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["vi-VN"] = { "name": "vi-VN", "englishName": "Vietnamese (Vietnam)", "nativeName": "Tiếng Việt (Việt Nam)", "Sunday": "Chủ Nhật", "Monday": "Thứ Hai", "Tuesday": "Thứ Ba", "Wednesday": "Thứ Tư", "Thursday": "Thứ Năm", "Friday": "Thứ Sáu", "Saturday": "Thứ Bảy", "Sun": "CN", "Mon": "Hai", "Tue": "Ba", "Wed": "Tư", "Thu": "Năm", "Fri": "Sáu", "Sat": "Bảy", "Su": "C", "Mo": "H", "Tu": "B", "We": "T", "Th": "N", "Fr": "S", "Sa": "B", "S_Sun_Initial": "C", "M_Mon_Initial": "H", "T_Tue_Initial": "B", "W_Wed_Initial": "T", "T_Thu_Initial": "N", "F_Fri_Initial": "S", "S_Sat_Initial": "B", "January": "Tháng Giêng", "February": "Tháng Hai", "March": "Tháng Ba", "April": "Tháng Tư", "May": "Tháng Năm", "June": "Tháng Sáu", "July": "Tháng Bảy", "August": "Tháng Tám", "September": "Tháng Chín", "October": "Tháng Mười", "November": "Tháng Mười Một", "December": "Tháng Mười Hai", "Jan_Abbr": "Thg1", "Feb_Abbr": "Thg2", "Mar_Abbr": "Thg3", "Apr_Abbr": "Thg4", "May_Abbr": "Thg5", "Jun_Abbr": "Thg6", "Jul_Abbr": "Thg7", "Aug_Abbr": "Thg8", "Sep_Abbr": "Thg9", "Oct_Abbr": "Thg10", "Nov_Abbr": "Thg11", "Dec_Abbr": "Thg12", "AM": "SA", "PM": "CH", "firstDayOfWeek": 1, "twoDigitYearMax": 2029, "mdy": "dmy", "M/d/yyyy": "dd/MM/yyyy", "dddd, MMMM dd, yyyy": "dd MMMM yyyy", "h:mm tt": "h:mm tt", "h:mm:ss tt": "h:mm:ss tt", "dddd, MMMM dd, yyyy h:mm:ss tt": "dd MMMM yyyy h:mm:ss tt", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "dd MMMM", "MMMM, yyyy": "MMMM yyyy", "/jan(uary)?/": "tháng giêng", "/feb(ruary)?/": "tháng hai", "/mar(ch)?/": "tháng ba", "/apr(il)?/": "tháng tư", "/may/": "tháng năm", "/jun(e)?/": "tháng sáu", "/jul(y)?/": "tháng bảy", "/aug(ust)?/": "tháng tám", "/sep(t(ember)?)?/": "tháng chín", "/oct(ober)?/": "tháng mười", "/nov(ember)?/": "tháng mười một", "/dec(ember)?/": "tháng mười hai", "/^su(n(day)?)?/": "^c(n(ủ nhật)?)?", "/^mo(n(day)?)?/": "^h(ai(́ hai)?)?", "/^tu(e(s(day)?)?)?/": "^b(a(ứ ba)?)?", "/^we(d(nesday)?)?/": "^t(ư(ứ tư)?)?", "/^th(u(r(s(day)?)?)?)?/": "^n(ăm(́ năm)?)?", "/^fr(i(day)?)?/": "^s(áu( sáu)?)?", "/^sa(t(urday)?)?/": "^b(ảy( bảy)?)?", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "vi-VN"; ================================================ FILE: src/i18n/xh-ZA.js ================================================ /* * DateJS Culture String File * Country Code: xh-ZA * Name: Xhosa (South Africa) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["xh-ZA"] = { "name": "xh-ZA", "englishName": "Xhosa (South Africa)", "nativeName": "isiXhosa (uMzantsi Afrika)", "Sunday": "iCawa", "Monday": "uMvulo", "Tuesday": "uLwesibini", "Wednesday": "uLwesithathu", "Thursday": "uLwesine", "Friday": "uLwesihlanu", "Saturday": "uMgqibelo", "Sun": "Sun", "Mon": "Mon", "Tue": "Tue", "Wed": "Wed", "Thu": "Thu", "Fri": "Fri", "Sat": "Sat", "Su": "Sun", "Mo": "Mon", "Tu": "Tue", "We": "Wed", "Th": "Thu", "Fr": "Fri", "Sa": "Sat", "S_Sun_Initial": "S", "M_Mon_Initial": "M", "T_Tue_Initial": "T", "W_Wed_Initial": "W", "T_Thu_Initial": "T", "F_Fri_Initial": "F", "S_Sat_Initial": "S", "January": "eyoMqungu", "February": "eyoMdumba", "March": "eyoKwindla", "April": "Tshazimpuzi", "May": "Canzibe", "June": "eyeSilimela", "July": "eyeKhala", "August": "eyeThupha", "September": "eyoMsintsi", "October": "eyeDwara", "November": "eyeNkanga", "December": "eyoMnga", "Jan_Abbr": "Jan", "Feb_Abbr": "Feb", "Mar_Abbr": "Mar", "Apr_Abbr": "Apr", "May_Abbr": "May", "Jun_Abbr": "Jun", "Jul_Abbr": "Jul", "Aug_Abbr": "Aug", "Sep_Abbr": "Sep", "Oct_Abbr": "Oct", "Nov_Abbr": "Nov", "Dec_Abbr": "Dec", "AM": "AM", "PM": "PM", "firstDayOfWeek": 0, "twoDigitYearMax": 2029, "mdy": "ymd", "M/d/yyyy": "yyyy/MM/dd", "dddd, MMMM dd, yyyy": "dd MMMM yyyy", "h:mm tt": "hh:mm:ss tt", "h:mm:ss tt": "hh:mm:ss tt", "dddd, MMMM dd, yyyy h:mm:ss tt": "dd MMMM yyyy hh:mm:ss tt", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "MMMM dd", "MMMM, yyyy": "MMMM yyyy", "/jan(uary)?/": "eyomqungu", "/feb(ruary)?/": "eyomdumba", "/mar(ch)?/": "eyokwindla", "/apr(il)?/": "tshazimpuzi", "/may/": "canzibe", "/jun(e)?/": "eyesilimela", "/jul(y)?/": "eyekhala", "/aug(ust)?/": "eyethupha", "/sep(t(ember)?)?/": "eyomsintsi", "/oct(ober)?/": "eyedwara", "/nov(ember)?/": "eyenkanga", "/dec(ember)?/": "eyomnga", "/^su(n(day)?)?/": "^icawa", "/^mo(n(day)?)?/": "^umvulo", "/^tu(e(s(day)?)?)?/": "^ulwesibini", "/^we(d(nesday)?)?/": "^ulwesithathu", "/^th(u(r(s(day)?)?)?)?/": "^ulwesine", "/^fr(i(day)?)?/": "^ulwesihlanu", "/^sa(t(urday)?)?/": "^umgqibelo", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "xh-ZA"; ================================================ FILE: src/i18n/zh-CN.js ================================================ /* * DateJS Culture String File * Country Code: zh-CN * Name: Chinese (People's Republic of China) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["zh-CN"] = { "name": "zh-CN", "englishName": "Chinese (People's Republic of China)", "nativeName": "中文(中华人民共和国)", "Sunday": "星期日", "Monday": "星期一", "Tuesday": "星期二", "Wednesday": "星期三", "Thursday": "星期四", "Friday": "星期五", "Saturday": "星期六", "Sun": "日", "Mon": "一", "Tue": "二", "Wed": "三", "Thu": "四", "Fri": "五", "Sat": "六", "Su": "日", "Mo": "一", "Tu": "二", "We": "三", "Th": "四", "Fr": "五", "Sa": "六", "S_Sun_Initial": "日", "M_Mon_Initial": "一", "T_Tue_Initial": "二", "W_Wed_Initial": "三", "T_Thu_Initial": "四", "F_Fri_Initial": "五", "S_Sat_Initial": "六", "January": "一月", "February": "二月", "March": "三月", "April": "四月", "May": "五月", "June": "六月", "July": "七月", "August": "八月", "September": "九月", "October": "十月", "November": "十一月", "December": "十二月", "Jan_Abbr": "一月", "Feb_Abbr": "二月", "Mar_Abbr": "三月", "Apr_Abbr": "四月", "May_Abbr": "五月", "Jun_Abbr": "六月", "Jul_Abbr": "七月", "Aug_Abbr": "八月", "Sep_Abbr": "九月", "Oct_Abbr": "十月", "Nov_Abbr": "十一月", "Dec_Abbr": "十二月", "AM": "上午", "PM": "下午", "firstDayOfWeek": 0, "twoDigitYearMax": 2029, "mdy": "ymd", "M/d/yyyy": "yyyy/M/d", "dddd, MMMM dd, yyyy": "yyyy'年'M'月'd'日'", "h:mm tt": "H:mm", "h:mm:ss tt": "H:mm:ss", "dddd, MMMM dd, yyyy h:mm:ss tt": "yyyy'年'M'月'd'日' H:mm:ss", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "M'月'd'日'", "MMMM, yyyy": "yyyy'年'M'月'", "/jan(uary)?/": "一月", "/feb(ruary)?/": "二月", "/mar(ch)?/": "三月", "/apr(il)?/": "四月", "/may/": "五月", "/jun(e)?/": "六月", "/jul(y)?/": "七月", "/aug(ust)?/": "八月", "/sep(t(ember)?)?/": "九月", "/oct(ober)?/": "十月", "/nov(ember)?/": "十一月", "/dec(ember)?/": "十二月", "/^su(n(day)?)?/": "^星期日", "/^mo(n(day)?)?/": "^星期一", "/^tu(e(s(day)?)?)?/": "^星期二", "/^we(d(nesday)?)?/": "^星期三", "/^th(u(r(s(day)?)?)?)?/": "^星期四", "/^fr(i(day)?)?/": "^星期五", "/^sa(t(urday)?)?/": "^星期六", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "zh-CN"; ================================================ FILE: src/i18n/zh-HK.js ================================================ /* * DateJS Culture String File * Country Code: zh-HK * Name: Chinese (Hong Kong S.A.R.) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["zh-HK"] = { "name": "zh-HK", "englishName": "Chinese (Hong Kong S.A.R.)", "nativeName": "中文(香港特别行政區)", "Sunday": "Sunday", "Monday": "Monday", "Tuesday": "Tuesday", "Wednesday": "Wednesday", "Thursday": "Thursday", "Friday": "Friday", "Saturday": "Saturday", "Sun": "Sun", "Mon": "Mon", "Tue": "Tue", "Wed": "Wed", "Thu": "Thu", "Fri": "Fri", "Sat": "Sat", "Su": "Su", "Mo": "Mo", "Tu": "Tu", "We": "We", "Th": "Th", "Fr": "Fr", "Sa": "Sa", "S_Sun_Initial": "S", "M_Mon_Initial": "M", "T_Tue_Initial": "T", "W_Wed_Initial": "W", "T_Thu_Initial": "T", "F_Fri_Initial": "F", "S_Sat_Initial": "S", "January": "January", "February": "February", "March": "March", "April": "April", "May": "May", "June": "June", "July": "July", "August": "August", "September": "September", "October": "October", "November": "November", "December": "December", "Jan_Abbr": "Jan", "Feb_Abbr": "Feb", "Mar_Abbr": "Mar", "Apr_Abbr": "Apr", "May_Abbr": "May", "Jun_Abbr": "Jun", "Jul_Abbr": "Jul", "Aug_Abbr": "Aug", "Sep_Abbr": "Sep", "Oct_Abbr": "Oct", "Nov_Abbr": "Nov", "Dec_Abbr": "Dec", "AM": "", "PM": "", "firstDayOfWeek": 0, "twoDigitYearMax": 2029, "mdy": "dmy", "M/d/yyyy": "d/M/yyyy", "dddd, MMMM dd, yyyy": "dddd, d MMMM, yyyy", "h:mm tt": "H:mm", "h:mm:ss tt": "H:mm:ss", "dddd, MMMM dd, yyyy h:mm:ss tt": "dddd, d MMMM, yyyy H:mm:ss", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "d MMMM", "MMMM, yyyy": "MMMM, yyyy", "/jan(uary)?/": "jan(uary)?", "/feb(ruary)?/": "feb(ruary)?", "/mar(ch)?/": "mar(ch)?", "/apr(il)?/": "apr(il)?", "/may/": "may", "/jun(e)?/": "jun(e)?", "/jul(y)?/": "jul(y)?", "/aug(ust)?/": "aug(ust)?", "/sep(t(ember)?)?/": "sep(t(ember)?)?", "/oct(ober)?/": "oct(ober)?", "/nov(ember)?/": "nov(ember)?", "/dec(ember)?/": "dec(ember)?", "/^su(n(day)?)?/": "^su(n(day)?)?", "/^mo(n(day)?)?/": "^mo(n(day)?)?", "/^tu(e(s(day)?)?)?/": "^tu(e(s(day)?)?)?", "/^we(d(nesday)?)?/": "^we(d(nesday)?)?", "/^th(u(r(s(day)?)?)?)?/": "^th(u(r(s(day)?)?)?)?", "/^fr(i(day)?)?/": "^fr(i(day)?)?", "/^sa(t(urday)?)?/": "^sa(t(urday)?)?", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "zh-HK"; ================================================ FILE: src/i18n/zh-MO.js ================================================ /* * DateJS Culture String File * Country Code: zh-MO * Name: Chinese (Macao S.A.R.) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["zh-MO"] = { "name": "zh-MO", "englishName": "Chinese (Macao S.A.R.)", "nativeName": "中文(澳門特别行政區)", "Sunday": "星期日", "Monday": "星期一", "Tuesday": "星期二", "Wednesday": "星期三", "Thursday": "星期四", "Friday": "星期五", "Saturday": "星期六", "Sun": "星期日", "Mon": "星期一", "Tue": "星期二", "Wed": "星期三", "Thu": "星期四", "Fri": "星期五", "Sat": "星期六", "Su": "日", "Mo": "一", "Tu": "二", "We": "三", "Th": "四", "Fr": "五", "Sa": "六", "S_Sun_Initial": "日", "M_Mon_Initial": "一", "T_Tue_Initial": "二", "W_Wed_Initial": "三", "T_Thu_Initial": "四", "F_Fri_Initial": "五", "S_Sat_Initial": "六", "January": "一月", "February": "二月", "March": "三月", "April": "四月", "May": "五月", "June": "六月", "July": "七月", "August": "八月", "September": "九月", "October": "十月", "November": "十一月", "December": "十二月", "Jan_Abbr": "一月", "Feb_Abbr": "二月", "Mar_Abbr": "三月", "Apr_Abbr": "四月", "May_Abbr": "五月", "Jun_Abbr": "六月", "Jul_Abbr": "七月", "Aug_Abbr": "八月", "Sep_Abbr": "九月", "Oct_Abbr": "十月", "Nov_Abbr": "十一月", "Dec_Abbr": "十二月", "AM": "", "PM": "", "firstDayOfWeek": 0, "twoDigitYearMax": 2029, "mdy": "dmy", "M/d/yyyy": "d/M/yyyy", "dddd, MMMM dd, yyyy": "dddd, d MMMM, yyyy", "h:mm tt": "H:mm", "h:mm:ss tt": "H:mm:ss", "dddd, MMMM dd, yyyy h:mm:ss tt": "dddd, d MMMM, yyyy H:mm:ss", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "d MMMM", "MMMM, yyyy": "MMMM, yyyy", "/jan(uary)?/": "一月", "/feb(ruary)?/": "二月", "/mar(ch)?/": "三月", "/apr(il)?/": "四月", "/may/": "五月", "/jun(e)?/": "六月", "/jul(y)?/": "七月", "/aug(ust)?/": "八月", "/sep(t(ember)?)?/": "九月", "/oct(ober)?/": "十月", "/nov(ember)?/": "十一月", "/dec(ember)?/": "十二月", "/^su(n(day)?)?/": "^星期日", "/^mo(n(day)?)?/": "^星期一", "/^tu(e(s(day)?)?)?/": "^星期二", "/^we(d(nesday)?)?/": "^星期三", "/^th(u(r(s(day)?)?)?)?/": "^星期四", "/^fr(i(day)?)?/": "^星期五", "/^sa(t(urday)?)?/": "^星期六", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "zh-MO"; ================================================ FILE: src/i18n/zh-SG.js ================================================ /* * DateJS Culture String File * Country Code: zh-SG * Name: Chinese (Singapore) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["zh-SG"] = { "name": "zh-SG", "englishName": "Chinese (Singapore)", "nativeName": "中文(新加坡)", "Sunday": "星期日", "Monday": "星期一", "Tuesday": "星期二", "Wednesday": "星期三", "Thursday": "星期四", "Friday": "星期五", "Saturday": "星期六", "Sun": "星期日", "Mon": "星期一", "Tue": "星期二", "Wed": "星期三", "Thu": "星期四", "Fri": "星期五", "Sat": "星期六", "Su": "日", "Mo": "一", "Tu": "二", "We": "三", "Th": "四", "Fr": "五", "Sa": "六", "S_Sun_Initial": "日", "M_Mon_Initial": "一", "T_Tue_Initial": "二", "W_Wed_Initial": "三", "T_Thu_Initial": "四", "F_Fri_Initial": "五", "S_Sat_Initial": "六", "January": "一月", "February": "二月", "March": "三月", "April": "四月", "May": "五月", "June": "六月", "July": "七月", "August": "八月", "September": "九月", "October": "十月", "November": "十一月", "December": "十二月", "Jan_Abbr": "一月", "Feb_Abbr": "二月", "Mar_Abbr": "三月", "Apr_Abbr": "四月", "May_Abbr": "五月", "Jun_Abbr": "六月", "Jul_Abbr": "七月", "Aug_Abbr": "八月", "Sep_Abbr": "九月", "Oct_Abbr": "十月", "Nov_Abbr": "十一月", "Dec_Abbr": "十二月", "AM": "AM", "PM": "PM", "firstDayOfWeek": 0, "twoDigitYearMax": 2029, "mdy": "dmy", "M/d/yyyy": "d/M/yyyy", "dddd, MMMM dd, yyyy": "dddd, d MMMM, yyyy", "h:mm tt": "tt h:mm", "h:mm:ss tt": "tt h:mm:ss", "dddd, MMMM dd, yyyy h:mm:ss tt": "dddd, d MMMM, yyyy tt h:mm:ss", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "d MMMM", "MMMM, yyyy": "MMMM, yyyy", "/jan(uary)?/": "一月", "/feb(ruary)?/": "二月", "/mar(ch)?/": "三月", "/apr(il)?/": "四月", "/may/": "五月", "/jun(e)?/": "六月", "/jul(y)?/": "七月", "/aug(ust)?/": "八月", "/sep(t(ember)?)?/": "九月", "/oct(ober)?/": "十月", "/nov(ember)?/": "十一月", "/dec(ember)?/": "十二月", "/^su(n(day)?)?/": "^星期日", "/^mo(n(day)?)?/": "^星期一", "/^tu(e(s(day)?)?)?/": "^星期二", "/^we(d(nesday)?)?/": "^星期三", "/^th(u(r(s(day)?)?)?)?/": "^星期四", "/^fr(i(day)?)?/": "^星期五", "/^sa(t(urday)?)?/": "^星期六", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "zh-SG"; ================================================ FILE: src/i18n/zh-TW.js ================================================ /* * DateJS Culture String File * Country Code: zh-TW * Name: Chinese (Taiwan) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["zh-TW"] = { "name": "zh-TW", "englishName": "Chinese (Taiwan)", "nativeName": "中文(台灣)", "Sunday": "星期日", "Monday": "星期一", "Tuesday": "星期二", "Wednesday": "星期三", "Thursday": "星期四", "Friday": "星期五", "Saturday": "星期六", "Sun": "星期日", "Mon": "星期一", "Tue": "星期二", "Wed": "星期三", "Thu": "星期四", "Fri": "星期五", "Sat": "星期六", "Su": "日", "Mo": "一", "Tu": "二", "We": "三", "Th": "四", "Fr": "五", "Sa": "六", "S_Sun_Initial": "日", "M_Mon_Initial": "一", "T_Tue_Initial": "二", "W_Wed_Initial": "三", "T_Thu_Initial": "四", "F_Fri_Initial": "五", "S_Sat_Initial": "六", "January": "一月", "February": "二月", "March": "三月", "April": "四月", "May": "五月", "June": "六月", "July": "七月", "August": "八月", "September": "九月", "October": "十月", "November": "十一月", "December": "十二月", "Jan_Abbr": "一月", "Feb_Abbr": "二月", "Mar_Abbr": "三月", "Apr_Abbr": "四月", "May_Abbr": "五月", "Jun_Abbr": "六月", "Jul_Abbr": "七月", "Aug_Abbr": "八月", "Sep_Abbr": "九月", "Oct_Abbr": "十月", "Nov_Abbr": "十一月", "Dec_Abbr": "十二月", "AM": "上午", "PM": "下午", "firstDayOfWeek": 0, "twoDigitYearMax": 2029, "mdy": "ymd", "M/d/yyyy": "yyyy/M/d", "dddd, MMMM dd, yyyy": "yyyy'年'M'月'd'日'", "h:mm tt": "tt hh:mm", "h:mm:ss tt": "tt hh:mm:ss", "dddd, MMMM dd, yyyy h:mm:ss tt": "yyyy'年'M'月'd'日' tt hh:mm:ss", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "M'月'd'日'", "MMMM, yyyy": "yyyy'年'M'月'", "/jan(uary)?/": "一月", "/feb(ruary)?/": "二月", "/mar(ch)?/": "三月", "/apr(il)?/": "四月", "/may/": "五月", "/jun(e)?/": "六月", "/jul(y)?/": "七月", "/aug(ust)?/": "八月", "/sep(t(ember)?)?/": "九月", "/oct(ober)?/": "十月", "/nov(ember)?/": "十一月", "/dec(ember)?/": "十二月", "/^su(n(day)?)?/": "^星期日", "/^mo(n(day)?)?/": "^星期一", "/^tu(e(s(day)?)?)?/": "^星期二", "/^we(d(nesday)?)?/": "^星期三", "/^th(u(r(s(day)?)?)?)?/": "^星期四", "/^fr(i(day)?)?/": "^星期五", "/^sa(t(urday)?)?/": "^星期六", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "zh-TW"; ================================================ FILE: src/i18n/zu-ZA.js ================================================ /* * DateJS Culture String File * Country Code: zu-ZA * Name: Zulu (South Africa) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["zu-ZA"] = { "name": "zu-ZA", "englishName": "Zulu (South Africa)", "nativeName": "isiZulu (iNingizimu Afrika)", "Sunday": "iSonto", "Monday": "uMsombuluko", "Tuesday": "uLwesibili", "Wednesday": "uLwesithathu", "Thursday": "uLwesine", "Friday": "uLwesihlanu", "Saturday": "uMgqibelo", "Sun": "Sun", "Mon": "Mon", "Tue": "Tue", "Wed": "Wed", "Thu": "Thu", "Fri": "Fri", "Sat": "Sat", "Su": "Sun", "Mo": "Mon", "Tu": "Tue", "We": "Wed", "Th": "Thu", "Fr": "Fri", "Sa": "Sat", "S_Sun_Initial": "S", "M_Mon_Initial": "M", "T_Tue_Initial": "T", "W_Wed_Initial": "W", "T_Thu_Initial": "T", "F_Fri_Initial": "F", "S_Sat_Initial": "S", "January": "uJanuwari", "February": "uFebuwari", "March": "uMashi", "April": "uAprhili", "May": "uMeyi", "June": "uJuni", "July": "uJulayi", "August": "uAgaste", "September": "uSepthemba", "October": "uOkthoba", "November": "uNovemba", "December": "uDisemba", "Jan_Abbr": "Jan", "Feb_Abbr": "Feb", "Mar_Abbr": "Mar", "Apr_Abbr": "Apr", "May_Abbr": "May", "Jun_Abbr": "Jun", "Jul_Abbr": "Jul", "Aug_Abbr": "Aug", "Sep_Abbr": "Sep", "Oct_Abbr": "Oct", "Nov_Abbr": "Nov", "Dec_Abbr": "Dec", "AM": "AM", "PM": "PM", "firstDayOfWeek": 0, "twoDigitYearMax": 2029, "mdy": "ymd", "M/d/yyyy": "yyyy/MM/dd", "dddd, MMMM dd, yyyy": "dd MMMM yyyy", "h:mm tt": "hh:mm:ss tt", "h:mm:ss tt": "hh:mm:ss tt", "dddd, MMMM dd, yyyy h:mm:ss tt": "dd MMMM yyyy hh:mm:ss tt", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "MMMM dd", "MMMM, yyyy": "MMMM yyyy", "/jan(uary)?/": "ujanuwari", "/feb(ruary)?/": "ufebuwari", "/mar(ch)?/": "umashi", "/apr(il)?/": "uaprhili", "/may/": "umeyi", "/jun(e)?/": "ujuni", "/jul(y)?/": "ujulayi", "/aug(ust)?/": "uagaste", "/sep(t(ember)?)?/": "usepthemba", "/oct(ober)?/": "uokthoba", "/nov(ember)?/": "unovemba", "/dec(ember)?/": "udisemba", "/^su(n(day)?)?/": "^isonto", "/^mo(n(day)?)?/": "^umsombuluko", "/^tu(e(s(day)?)?)?/": "^ulwesibili", "/^we(d(nesday)?)?/": "^ulwesithathu", "/^th(u(r(s(day)?)?)?)?/": "^ulwesine", "/^fr(i(day)?)?/": "^ulwesihlanu", "/^sa(t(urday)?)?/": "^umgqibelo", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "zu-ZA"; ================================================ FILE: src/i18n-template.js ================================================ /* * DateJS Culture String File * Country Code: en-US * Name: English (United States) * Format: "key" : "value" * Key is the en-US term, Value is the Key in the current language. */ Date.CultureStrings = Date.CultureStrings || {}; Date.CultureStrings["en-US"] = { "name": "en-US", "englishName": "English (United States)", "nativeName": "English (United States)", "Sunday": "Sunday", "Monday": "Monday", "Tuesday": "Tuesday", "Wednesday": "Wednesday", "Thursday": "Thursday", "Friday": "Friday", "Saturday": "Saturday", "Sun": "Sun", "Mon": "Mon", "Tue": "Tue", "Wed": "Wed", "Thu": "Thu", "Fri": "Fri", "Sat": "Sat", "Su": "Su", "Mo": "Mo", "Tu": "Tu", "We": "We", "Th": "Th", "Fr": "Fr", "Sa": "Sa", "S_Sun_Initial": "S", "M_Mon_Initial": "M", "T_Tue_Initial": "T", "W_Wed_Initial": "W", "T_Thu_Initial": "T", "F_Fri_Initial": "F", "S_Sat_Initial": "S", "January": "January", "February": "February", "March": "March", "April": "April", "May": "May", "June": "June", "July": "July", "August": "August", "September": "September", "October": "October", "November": "November", "December": "December", "Jan_Abbr": "Jan", "Feb_Abbr": "Feb", "Mar_Abbr": "Mar", "Apr_Abbr": "Apr", "May_Abbr": "May", "Jun_Abbr": "Jun", "Jul_Abbr": "Jul", "Aug_Abbr": "Aug", "Sep_Abbr": "Sep", "Oct_Abbr": "Oct", "Nov_Abbr": "Nov", "Dec_Abbr": "Dec", "AM": "AM", "PM": "PM", "firstDayOfWeek": 0, "twoDigitYearMax": 2049, "mdy": "mdy", "M/d/yyyy": "M/d/yyyy", "dddd, MMMM dd, yyyy": "dddd, MMMM dd, yyyy", "h:mm tt": "h:mm tt", "h:mm:ss tt": "h:mm:ss tt", "dddd, MMMM dd, yyyy h:mm:ss tt": "dddd, MMMM dd, yyyy h:mm:ss tt", "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ", "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss", "MMMM dd": "MMMM dd", "MMMM, yyyy": "MMMM, yyyy", "/jan(uary)?/": "jan(uary)?", "/feb(ruary)?/": "feb(ruary)?", "/mar(ch)?/": "mar(ch)?", "/apr(il)?/": "apr(il)?", "/may/": "may", "/jun(e)?/": "jun(e)?", "/jul(y)?/": "jul(y)?", "/aug(ust)?/": "aug(ust)?", "/sep(t(ember)?)?/": "sep(t(ember)?)?", "/oct(ober)?/": "oct(ober)?", "/nov(ember)?/": "nov(ember)?", "/dec(ember)?/": "dec(ember)?", "/^su(n(day)?)?/": "^su(n(day)?)?", "/^mo(n(day)?)?/": "^mo(n(day)?)?", "/^tu(e(s(day)?)?)?/": "^tu(e(s(day)?)?)?", "/^we(d(nesday)?)?/": "^we(d(nesday)?)?", "/^th(u(r(s(day)?)?)?)?/": "^th(u(r(s(day)?)?)?)?", "/^fr(i(day)?)?/": "^fr(i(day)?)?", "/^sa(t(urday)?)?/": "^sa(t(urday)?)?", "/^next/": "^next", "/^last|past|prev(ious)?/": "^last|past|prev(ious)?", "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)", "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)", "/^yes(terday)?/": "^yes(terday)?", "/^t(od(ay)?)?/": "^t(od(ay)?)?", "/^tom(orrow)?/": "^tom(orrow)?", "/^n(ow)?/": "^n(ow)?", "/^ms|milli(second)?s?/": "^ms|milli(second)?s?", "/^sec(ond)?s?/": "^sec(ond)?s?", "/^mn|min(ute)?s?/": "^mn|min(ute)?s?", "/^h(our)?s?/": "^h(our)?s?", "/^w(eek)?s?/": "^w(eek)?s?", "/^m(onth)?s?/": "^m(onth)?s?", "/^d(ay)?s?/": "^d(ay)?s?", "/^y(ear)?s?/": "^y(ear)?s?", "/^(a|p)/": "^(a|p)", "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)", "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)", "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)", "LINT": "LINT", "TOT": "TOT", "CHAST": "CHAST", "NZST": "NZST", "NFT": "NFT", "SBT": "SBT", "AEST": "AEST", "ACST": "ACST", "JST": "JST", "CWST": "CWST", "CT": "CT", "ICT": "ICT", "MMT": "MMT", "BIOT": "BST", "NPT": "NPT", "IST": "IST", "PKT": "PKT", "AFT": "AFT", "MSK": "MSK", "IRST": "IRST", "FET": "FET", "EET": "EET", "CET": "CET", "UTC": "UTC", "GMT": "GMT", "CVT": "CVT", "GST": "GST", "BRT": "BRT", "NST": "NST", "AST": "AST", "EST": "EST", "CST": "CST", "MST": "MST", "PST": "PST", "AKST": "AKST", "MIT": "MIT", "HST": "HST", "SST": "SST", "BIT": "BIT", "CHADT": "CHADT", "NZDT": "NZDT", "AEDT": "AEDT", "ACDT": "ACDT", "AZST": "AZST", "IRDT": "IRDT", "EEST": "EEST", "CEST": "CEST", "BST": "BST", "PMDT": "PMDT", "ADT": "ADT", "NDT": "NDT", "EDT": "EDT", "CDT": "CDT", "MDT": "MDT", "PDT": "PDT", "AKDT": "AKDT", "HADT": "HADT" }; Date.CultureStrings.lang = "en-US"; ================================================ FILE: tests/core/index.html ================================================ Datejs Test Cases : Core Library

Core Library

================================================ FILE: tests/core/index.js ================================================ Date.Specification = new Specification({ 'Exception Handling': { setup: function() {}, 'Date.parse() : No params': { run: function() { this.date = Date.parse() }, assert: function() { return null == this.date } }, 'Date.parse("") : string.empty': { run: function() { this.date = Date.parse('') }, assert: function() { return null == this.date } }, 'Date.parse("asdf") : Random String': { run: function() { this.date = Date.parse('asdf') }, assert: function() { return null == this.date } }, 'Date.parse(null) : null': { run: function() { this.date = Date.parse(null) }, assert: function() { return null == this.date } }, '29-Sep-2008.set({ day: 31 }) : RangeError': { run: function() {}, assert: function() { try { return new Date(2008,8,29).set({ day: 31 }).equals(new Date(2008,9,1)); } catch(ex) { return (ex instanceof RangeError); } return new Date(2008,8,30).equals(this.date) } }, '29-Sep-2008.set({ month: 12 }) : RangeError': { run: function() {}, assert: function() { try { return new Date(2008,8,29).set({ month: 12 }).equals(new Date(2009,0,29)); } catch(ex) { return (ex instanceof RangeError); } } }, 'new Date("").compareTo(new Date()) : Error': { run: function() {}, assert: function() { try { return new Date("").compareTo(new Date()) == 0 } catch(ex) { return (ex instanceof Error); } } }, 'new Date("").equals(new Date()) : Error': { run: function() {}, assert: function() { try { return new Date("").equals(new Date()); } catch(ex) { return (ex instanceof Error); } } }, 'new Date().compareTo(0) : Error': { run: function() {}, assert: function() { try { return new Date().compareTo(0); } catch(ex) { return (ex instanceof TypeError); } } }, 'new Date().equals(0) : TypeError': { run: function() {}, assert: function() { try { return new Date().equals(0); } catch(ex) { return (ex instanceof Error); } } }, 'new Date().compareTo(new Date("")) : TypeError': { run: function() {}, assert: function() { try { return new Date().compareTo(new Date("")); } catch(ex) { return (ex instanceof Error); } } }, 'new Date().equals(new Date("")) : TypeError': { run: function() {}, assert: function() { try { return new Date().equals(new Date("")); } catch(ex) { return (ex instanceof Error); } } } }, '.compareTo() and .equals()': { setup: function() { }, '.compareTo() : today > yesterday': { run: function() {}, assert: function() { return Date.today().compareTo(Date.today().addDays(-1)) == 1; } }, '.compareTo() : today == today': { run: function() {}, assert: function() { return Date.today().compareTo(Date.today()) == 0; } }, '.compareTo() : today < tomorrow': { run: function() {}, assert: function() { return Date.today().compareTo(Date.today().addDays(1)) == -1; } }, '.equals() : today != yesterday': { run: function() {}, assert: function() { return false == Date.today().equals(Date.today().addDays(-1)); } }, '.equals() : today == today': { run: function() {}, assert: function() { return Date.today().equals(Date.today()); } }, '.equals() : today != tomorrow': { run: function() {}, assert: function() { return false == Date.today().equals(Date.today().addDays(1)); } } }, '.set() Tests': { setup: function() { this.d1 = new Date(''); }, '15-Aug-2008 to 15-Sep-2008': { run: function() { this.date = new Date(2008,7,15); this.date.set({ month: 8 }); }, assert: function() { return new Date(2008,8,15).equals(this.date) } }, '15-Aug-2008 to 15-Jul-2008': { run: function() { this.date = new Date(2008,7,15); this.date.set({ month: 6 }); }, assert: function() { return new Date(2008,6,15).equals(this.date) } }, '29-Feb-2008 to 28-Feb-2009': { run: function() { this.date = new Date(2008,1,29); this.date.set({ year: 2009 }); }, assert: function() { return new Date(2009,1,28).equals(this.date) } }, '29-Feb-2008 to 28-Feb-2007': { run: function() { this.date = new Date(2008,1,29); this.date.set({ year: 2007 }); }, assert: function() { return new Date(2007,1,28).equals(this.date) } }, '31-Jan-2008 to 29-Feb-2008': { run: function() { this.date = new Date(2008,0,31); this.date.set({ month: 1 }); }, assert: function() { return new Date(2008,1,29).equals(this.date) } }, '31-Mar-2008 to 29-Feb-2008': { run: function() { this.date = new Date(2008,2,31); this.date.set({ month: 1 }); }, assert: function() { return new Date(2008,1,29).equals(this.date) } }, '30-Sep-2008 to 30-Oct-2008': { run: function() { this.date = new Date(2008,8,30); this.date.set({ month: 9 }); }, assert: function() { return new Date(2008,9,30).equals(this.date) } }, '30-Sep-2008 to 30-Aug-2008': { run: function() { this.date = new Date(2008,8,30); this.date.set({ month: 7 }); }, assert: function() { return new Date(2008,7,30).equals(this.date) } }, '30-Sep-2008 to 30-Sep-2008': { run: function() { this.date = new Date(2008,8,30); this.date.set({ month: 8 }); }, assert: function() { return new Date(2008,8,30).equals(this.date) } }, '31-Aug-2008 to 30-Sep-2008': { run: function() { this.date = new Date(2008,7,31); this.date.set({ month: 8 }); }, assert: function() { return new Date(2008,8,30).equals(this.date) } }, '31-Oct-2008 to 30-Sep-2008': { run: function() { this.date = new Date(2008,9,31); this.date.set({ month: 8 }); }, assert: function() { return new Date(2008,8,30).equals(this.date) } } }, '.next() and .previous()': { setup: function() {}, 'next().monday()': { run: function() { this.date = new Date().clearTime().next().monday(); }, assert: function() { return Date.parse('next monday').equals(this.date) } }, 'next().tuesday()': { run: function() { this.date = new Date().clearTime().next().tuesday(); }, assert: function() { return Date.parse('next tuesday').equals(this.date) } }, 'next().wednesday()': { run: function() { this.date = new Date().clearTime().next().wednesday(); }, assert: function() { return Date.parse('next wednesday').equals(this.date) } }, 'next().thursday()': { run: function() { this.date = new Date().clearTime().next().thursday(); }, assert: function() { return Date.parse('next thursday').equals(this.date) } }, 'next().friday()': { run: function() { this.date = new Date().clearTime().next().friday(); }, assert: function() { return Date.parse('next friday').equals(this.date) } }, 'next().saturday()': { run: function() { this.date = new Date().clearTime().next().saturday(); }, assert: function() { return Date.parse('next saturday').equals(this.date) } }, 'next().sunday()': { run: function() { this.date = new Date().clearTime().next().sunday(); }, assert: function() { return Date.parse('next sunday').equals(this.date) } }, 'last().monday()': { run: function() { this.date = new Date().clearTime().last().monday(); }, assert: function() { return Date.parse('last monday').equals(this.date) } }, 'last().tuesday()': { run: function() { this.date = new Date().clearTime().last().tuesday(); }, assert: function() { return Date.parse('last tuesday').equals(this.date) } }, 'last().wednesday()': { run: function() { this.date = new Date().clearTime().last().wednesday(); }, assert: function() { return Date.parse('last wednesday').equals(this.date) } }, 'last().thursday()': { run: function() { this.date = new Date().clearTime().last().thursday(); }, assert: function() { return Date.parse('last thursday').equals(this.date) } }, 'last().friday()': { run: function() { this.date = new Date().clearTime().last().friday(); }, assert: function() { return Date.parse('last friday').equals(this.date) } }, 'last().saturday()': { run: function() { this.date = new Date().clearTime().last().saturday(); }, assert: function() { return Date.parse('last saturday').equals(this.date) } }, 'last().sunday()': { run: function() { this.date = new Date().clearTime().last().sunday(); }, assert: function() { return Date.parse('last sunday').equals(this.date) } }, 'monday()': { run: function() { this.date = new Date().clearTime().monday(); }, assert: function() { return Date.parse('next monday').equals(this.date) } }, 'tuesday()': { run: function() { this.date = new Date().clearTime().tuesday(); }, assert: function() { return Date.parse('next tuesday').equals(this.date) } }, 'wednesday()': { run: function() { this.date = new Date().clearTime().wednesday(); }, assert: function() { return Date.parse('next wednesday').equals(this.date) } }, 'thursday()': { run: function() { this.date = new Date().clearTime().thursday(); }, assert: function() { return Date.parse('next thursday').equals(this.date) } }, 'friday()': { run: function() { this.date = new Date().clearTime().friday(); }, assert: function() { return Date.parse('next friday').equals(this.date) } }, 'saturday()': { run: function() { this.date = new Date().clearTime().saturday(); }, assert: function() { return Date.parse('next saturday').equals(this.date) } }, 'sunday()': { run: function() { this.date = Date.today().sunday(); }, assert: function() { return Date.parse('next sunday').equals(this.date) } } }, '.is()': { setup: function() {}, '.is().monday()': { run: function() {}, assert: function() { return new Date(2001, 0, 1).is().monday() == true; } }, '.is().mon()': { run: function() {}, assert: function() { return new Date(2001, 0, 1).is().mon() == true; } }, '.is().tuesday()': { run: function() {}, assert: function() { return new Date(2001, 0, 2).is().tuesday() == true; } }, '.is().tue()': { run: function() {}, assert: function() { return new Date(2001, 0, 2).is().tue() == true; } }, '.is().wednesday()': { run: function() {}, assert: function() { return new Date(2001, 0, 3).is().wednesday() == true; } }, '.is().wed()': { run: function() {}, assert: function() { return new Date(2001, 0, 3).is().wed() == true; } }, '.is().thursday()': { run: function() {}, assert: function() { return new Date(2001, 0, 4).is().thursday() == true; } }, '.is().thu()': { run: function() {}, assert: function() { return new Date(2001, 0, 4).is().thu() == true; } }, '.is().friday()': { run: function() {}, assert: function() { return new Date(2001, 0, 5).is().friday() == true; } }, '.is().fri()': { run: function() {}, assert: function() { return new Date(2001, 0, 5).is().fri() == true; } }, '.is().saturday()': { run: function() {}, assert: function() { return new Date(2001, 0, 6).is().saturday() == true; } }, '.is().sat()': { run: function() {}, assert: function() { return new Date(2001, 0, 6).is().sat() == true; } }, '.is().sunday()': { run: function() {}, assert: function() { return new Date(2001, 0, 7).is().sunday() == true; } }, '.is().sun()': { run: function() {}, assert: function() { return new Date(2001, 0, 7).is().sun() == true; } }, '.is().january()': { run: function() {}, assert: function() { return new Date(2001, 0, 1).is().january() == true; } }, '.is().jan()': { run: function() {}, assert: function() { return new Date(2001, 0, 1).is().jan() == true; } }, '.is().february()': { run: function() {}, assert: function() { return new Date(2001, 0, 1).add(1).month().is().february() == true; } }, '.is().feb()': { run: function() {}, assert: function() { return new Date(2001, 0, 1).is().add(1).month().feb() == true; } }, '.is().march()': { run: function() {}, assert: function() { return new Date(2001, 0, 1).add(2).months().is().march() == true; } }, '.is().mar()': { run: function() {}, assert: function() { return new Date(2001, 0, 1).is().add(2).months().mar() == true; } }, '.is().april()': { run: function() {}, assert: function() { return new Date(2001, 0, 1).add(3).months().is().april() == true; } }, '.is().apr()': { run: function() {}, assert: function() { return new Date(2001, 0, 1).is().add(3).months().april() == true; } }, '.is().may()': { run: function() {}, assert: function() { return new Date(2001, 0, 1).add(4).months().is().may() == true; } }, '.is().june()': { run: function() {}, assert: function() { return new Date(2001, 0, 1).add(5).months().is().june() == true; } }, '.is().jun()': { run: function() {}, assert: function() { return new Date(2001, 0, 1).is().add(5).months().jun() == true; } }, '.is().july()': { run: function() {}, assert: function() { return new Date(2001, 0, 1).add(6).months().is().july() == true; } }, '.is().jul()': { run: function() {}, assert: function() { return new Date(2001, 0, 1).is().add(6).months().jul() == true; } }, '.is().august()': { run: function() {}, assert: function() { return new Date(2001, 0, 1).add(7).months().is().august() == true; } }, '.is().aug()': { run: function() {}, assert: function() { return new Date(2001, 0, 1).is().add(7).months().aug() == true; } }, '.is().september()': { run: function() {}, assert: function() { return new Date(2001, 0, 1).add(8).months().is().september() == true; } }, '.is().sep()': { run: function() {}, assert: function() { return new Date(2001, 0, 1).is().add(8).months().sep() == true; } }, '.is().october()': { run: function() {}, assert: function() { return new Date(2001, 0, 1).add(9).months().is().october() == true; } }, '.is().oct()': { run: function() {}, assert: function() { return new Date(2001, 0, 1).is().add(9).months().oct() == true; } }, '.is().november()': { run: function() {}, assert: function() { return new Date(2001, 0, 1).add(10).months().is().november() == true; } }, '.is().nov()': { run: function() {}, assert: function() { return new Date(2001, 0, 1).is().add(10).months().nov() == true; } }, '.is().december()': { run: function() {}, assert: function() { return new Date(2001, 0, 1).add(11).months().is().december() == true; } }, '.is().dec()': { run: function() {}, assert: function() { return new Date(2001, 0, 1).is().add(11).months().dec() == true; } } }, '.add()': { setup: function() {}, '.add(1).second()': { run: function() {}, assert: function() { return new Date(2001, 0, 2).add(1).second().equals(new Date(2001, 0, 2, 0, 0, 1)); } }, '.add(-1).second()': { run: function() {}, assert: function() { return new Date(2001, 0, 2).add(-1).second().equals(new Date(2001, 0, 1, 23, 59, 59)); } }, '.add(10).seconds()': { run: function() {}, assert: function() { return new Date(2001, 0, 2).add(10).seconds().equals(new Date(2001, 0, 2, 0, 0, 10)); } }, '.add(-10).seconds()': { run: function() {}, assert: function() { return new Date(2001, 0, 2).add(-10).seconds().equals(new Date(2001, 0, 1, 23, 59, 50)); } }, '.add(1).minute()': { run: function() {}, assert: function() { return new Date(2001, 0, 2).add(1).minute().equals(new Date(2001, 0, 2, 0, 1, 0)); } }, '.add(-1).minute()': { run: function() {}, assert: function() { return new Date(2001, 0, 2).add(-1).minute().equals(new Date(2001, 0, 1, 23, 59, 0)); } }, '.add(10).minutes()': { run: function() {}, assert: function() { return new Date(2001, 0, 2).add(10).minutes().equals(new Date(2001, 0, 2, 0, 10, 0)); } }, '.add(-10).minutes()': { run: function() {}, assert: function() { return new Date(2001, 0, 2).add(-10).minutes().equals(new Date(2001, 0, 1, 23, 50, 0)); } }, '.add(1).hour()': { run: function() {}, assert: function() { return new Date(2001, 0, 2).add(1).hour().equals(new Date(2001, 0, 2, 1, 0, 0)); } }, '.add(-1).hour()': { run: function() {}, assert: function() { return new Date(2001, 0, 2).add(-1).hour().equals(new Date(2001, 0, 1, 23, 0, 0)); } }, '.add(10).hours()': { run: function() {}, assert: function() { return new Date(2001, 0, 2).add(10).hours().equals(new Date(2001, 0, 2, 10, 0, 0)); } }, '.add(-10).hours()': { run: function() {}, assert: function() { return new Date(2001, 0, 2).add(-10).hours().equals(new Date(2001, 0, 1, 14, 0, 0)); } }, '.add(1).day()': { run: function() {}, assert: function() { return new Date(2001, 0, 1).add(1).day().equals(new Date(2001, 0, 2)); } }, '.add(-1).day()': { run: function() {}, assert: function() { return new Date(2001, 0, 1).add(-1).day().equals(new Date(2000, 11, 31)); } }, '.add(31).days()': { run: function() {}, assert: function() { return new Date(2001, 0, 1).add(31).days().equals(new Date(2001, 1, 1)); } }, '.add(-31).days()': { run: function() {}, assert: function() { return new Date(2001, 0, 1).add(-31).days().equals(new Date(2000, 11, 1)); } }, '.add(1).month()': { run: function() {}, assert: function() { return new Date(2001, 0, 1).add(1).month().equals(new Date(2001, 1, 1)); } }, '.add(-1).month()': { run: function() {}, assert: function() { return new Date(2001, 0, 1).add(-1).month().equals(new Date(2000, 11, 1)); } }, '.add(6).months()': { run: function() {}, assert: function() { return new Date(2001, 0, 1).add(6).months().equals(new Date(2001, 6, 1)); } }, '.add(-6).months()': { run: function() {}, assert: function() { return new Date(2001, 0, 1).add(-6).months().equals(new Date(2000, 6, 1)); } }, '.add(1).month() : 31-Jan to 28-Feb': { run: function() {}, assert: function() { return new Date(2001, 0, 31).add(1).month().equals(new Date(2001, 1, 28)); } }, '.add(-1).month() : 31-Mar to 28-Feb': { run: function() {}, assert: function() { return new Date(2001, 2, 31).add(-1).month().equals(new Date(2001, 1, 28)); } }, '.add(1).month() : 31-Jan to 29-Feb [leap year]': { run: function() {}, assert: function() { return new Date(2008, 0, 31).add(1).month().equals(new Date(2008, 1, 29)); } }, '.add(-1).month() : 31-Mar to 29-Feb [leap year]': { run: function() {}, assert: function() { return new Date(2008, 2, 31).add(-1).month().equals(new Date(2008, 1, 29)); } }, '.add(1).year()': { run: function() {}, assert: function() { return new Date(2001, 0, 1).add(1).year().equals(new Date(2002, 0, 1)); } }, '.add(-1).year()': { run: function() {}, assert: function() { return new Date(2001, 0, 1).add(-1).year().equals(new Date(2000, 0, 1)); } }, '.add(-1).year() : 29-Feb-2000 to 28-Feb-2001 [leap year]': { run: function() {}, assert: function() { return new Date(2000, 1, 29).add(1).year().equals(new Date(2001, 1, 28)); } }, '.add(5).years()': { run: function() {}, assert: function() { return new Date(2001, 0, 1).add(5).years().equals(new Date(2006, 0, 1)); } }, '.add(-5).years()': { run: function() {}, assert: function() { return new Date(2001, 0, 1).add(-5).years().equals(new Date(1996, 0, 1)); } } } , '.moveToNthOccurrence()': { setup: function() {}, 'Final Sunday in Jan': { run: function() {}, assert: function() { return new Date(2008, 0, 27).equals(Date.today().set({year: 2008, month: 0}).final().sunday()); } }, 'Final Sunday in Feb': { run: function() {}, assert: function() { return new Date(2008, 1, 24).equals(Date.today().set({year: 2008, month: 1}).final().sunday()); } }, 'Final Sunday in Mar': { run: function() {}, assert: function() { return new Date(2008, 2, 30).equals(Date.today().set({year: 2008, month: 2}).final().sunday()); } }, 'Final Sunday in Apr': { run: function() {}, assert: function() { return new Date(2008, 3, 27).equals(Date.today().set({year: 2008, month: 3}).final().sunday()); } }, 'Final Sunday in May': { run: function() {}, assert: function() { return new Date(2008, 4, 25).equals(Date.today().set({year: 2008, month: 4}).final().sunday()); } }, 'Final Sunday in Jun': { run: function() {}, assert: function() { return new Date(2008, 5, 29).equals(Date.today().set({year: 2008, month: 5}).final().sunday()); } }, 'Final Sunday in Jul': { run: function() {}, assert: function() { return new Date(2008, 6, 27).equals(Date.today().set({year: 2008, month: 6}).final().sunday()); } }, 'Final Sunday in Aug': { run: function() {}, assert: function() { return new Date(2008, 7, 31).equals(Date.today().set({year: 2008, month: 7}).final().sunday()); } }, 'Final Sunday in Sep': { run: function() {}, assert: function() { return new Date(2008, 8, 28).equals(Date.today().set({year: 2008, month: 8}).final().sunday()); } }, 'Final Sunday in Oct': { run: function() {}, assert: function() { return new Date(2008, 9, 26).equals(Date.today().set({year: 2008, month: 9}).final().sunday()); } }, 'Final Sunday in Nov': { run: function() {}, assert: function() { return new Date(2008, 10, 30).equals(Date.today().set({year: 2008, month: 10}).final().sunday()); } }, 'Final Sunday in Dec': { run: function() {}, assert: function() { return new Date(2008, 11, 28).equals(Date.today().set({year: 2008, month: 11}).final().sunday()); } } }, '.getWeek()': { setup: function() { this.d = new Date(1969, 0, 1); }, '1969': { run: function() {}, assert: function() { return (this.d.addYears(0).getWeek() == 1); } }, '1970': { run: function() {}, assert: function() { return (this.d.addYears(1).getWeek() == 1); } }, '1971': { run: function() {}, assert: function() { return (this.d.addYears(2).getWeek() == 53); } }, '1972': { run: function() {}, assert: function() { return (this.d.addYears(3).getWeek() == 52); } }, '1973': { run: function() {}, assert: function() { return (this.d.addYears(4).getWeek() == 1); } }, '1974': { run: function() {}, assert: function() { return (this.d.addYears(5).getWeek() == 1); } }, '1975': { run: function() {}, assert: function() { return (this.d.addYears(6).getWeek() == 1); } }, '1976': { run: function() {}, assert: function() { return (this.d.addYears(7).getWeek() == 1); } }, '1977': { run: function() {}, assert: function() { return (this.d.addYears(8).getWeek() == 53); } }, '1978': { run: function() {}, assert: function() { return (this.d.addYears(9).getWeek() == 52); } }, '1979': { run: function() {}, assert: function() { return (this.d.addYears(10).getWeek() == 1); } }, '1980': { run: function() {}, assert: function() { return (this.d.addYears(11).getWeek() == 1); } }, '1981': { run: function() {}, assert: function() { return (this.d.addYears(12).getWeek() == 1); } }, '1982': { run: function() {}, assert: function() { return (this.d.addYears(13).getWeek() == 53); } }, '1983': { run: function() {}, assert: function() { return (this.d.addYears(14).getWeek() == 52); } }, '1984': { run: function() {}, assert: function() { return (this.d.addYears(15).getWeek() == 52); } }, '1985': { run: function() {}, assert: function() { return (this.d.addYears(16).getWeek() == 1); } }, '1986': { run: function() {}, assert: function() { return (this.d.addYears(17).getWeek() == 1); } }, '1987': { run: function() {}, assert: function() { return (this.d.addYears(18).getWeek() == 1); } }, '1988': { run: function() {}, assert: function() { return (this.d.addYears(19).getWeek() == 53); } }, '1989': { run: function() {}, assert: function() { return (this.d.addYears(20).getWeek() == 52); } }, '1990': { run: function() {}, assert: function() { return (this.d.addYears(21).getWeek() == 1); } }, '1991': { run: function() {}, assert: function() { return (this.d.addYears(22).getWeek() == 1); } }, '1992': { run: function() {}, assert: function() { return (this.d.addYears(23).getWeek() == 1); } }, '1993': { run: function() {}, assert: function() { return (this.d.addYears(24).getWeek() == 53); } }, '1994': { run: function() {}, assert: function() { return (this.d.addYears(25).getWeek() == 52); } }, '1995': { run: function() {}, assert: function() { return (this.d.addYears(26).getWeek() == 52); } }, '1996': { run: function() {}, assert: function() { return (this.d.addYears(27).getWeek() == 1); } }, '1997': { run: function() {}, assert: function() { return (this.d.addYears(28).getWeek() == 1); } }, '1998': { run: function() {}, assert: function() { return (this.d.addYears(29).getWeek() == 1); } }, '1999': { run: function() {}, assert: function() { return (this.d.addYears(30).getWeek() == 53); } }, '2000': { run: function() {}, assert: function() { return (this.d.addYears(31).getWeek() == 52); } }, '2001': { run: function() {}, assert: function() { return (this.d.addYears(32).getWeek() == 1); } }, '2002': { run: function() {}, assert: function() { return (this.d.addYears(33).getWeek() == 1); } }, '2003': { run: function() {}, assert: function() { return (this.d.addYears(34).getWeek() == 1); } }, '2004': { run: function() {}, assert: function() { return (this.d.addYears(35).getWeek() == 1); } }, '2005': { run: function() {}, assert: function() { return (this.d.addYears(36).getWeek() == 53); } }, '2006': { run: function() {}, assert: function() { return (this.d.addYears(37).getWeek() == 52); } }, '2007': { run: function() {}, assert: function() { return (this.d.addYears(38).getWeek() == 1); } }, '2008': { run: function() {}, assert: function() { return (this.d.addYears(39).getWeek() == 1); } }, '2009': { run: function() {}, assert: function() { return (this.d.addYears(40).getWeek() == 1); } }, '2010': { run: function() {}, assert: function() { return (this.d.addYears(41).getWeek() == 53); } }, '2011': { run: function() {}, assert: function() { return (this.d.addYears(42).getWeek() == 52); } }, '2012': { run: function() {}, assert: function() { return (this.d.addYears(43).getWeek() == 52); } }, '2013': { run: function() {}, assert: function() { return (this.d.addYears(44).getWeek() == 1); } }, '2014': { run: function() {}, assert: function() { return (this.d.addYears(45).getWeek() == 1); } }, '2015': { run: function() {}, assert: function() { return (this.d.addYears(46).getWeek() == 1); } }, '2016': { run: function() {}, assert: function() { return (this.d.addYears(47).getWeek() == 53); } }, '2017': { run: function() {}, assert: function() { return (this.d.addYears(48).getWeek() == 52); } }, '2018': { run: function() {}, assert: function() { return (this.d.addYears(49).getWeek() == 1); } }, '2019': { run: function() {}, assert: function() { return (this.d.addYears(50).getWeek() == 1); } }, '2020': { run: function() {}, assert: function() { return (this.d.addYears(51).getWeek() == 1); } }, '2021': { run: function() {}, assert: function() { return (this.d.addYears(52).getWeek() == 53); } }, '2022': { run: function() {}, assert: function() { return (this.d.addYears(53).getWeek() == 52); } }, '2023': { run: function() {}, assert: function() { return (this.d.addYears(54).getWeek() == 52); } }, '2024': { run: function() {}, assert: function() { return (this.d.addYears(55).getWeek() == 1); } }, '2025': { run: function() {}, assert: function() { return (this.d.addYears(56).getWeek() == 1); } }, '2026': { run: function() {}, assert: function() { return (this.d.addYears(57).getWeek() == 1); } }, '2027': { run: function() {}, assert: function() { return (this.d.addYears(58).getWeek() == 53); } }, '2028': { run: function() {}, assert: function() { return (this.d.addYears(59).getWeek() == 52); } }, '2029': { run: function() {}, assert: function() { return (this.d.addYears(60).getWeek() == 1); } }, '2030': { run: function() {}, assert: function() { return (this.d.addYears(61).getWeek() == 1); } }, '2031': { run: function() {}, assert: function() { return (this.d.addYears(62).getWeek() == 1); } }, '2032': { run: function() {}, assert: function() { return (this.d.addYears(63).getWeek() == 1); } }, '2033': { run: function() {}, assert: function() { return (this.d.addYears(64).getWeek() == 53); } } } , '.setWeek()': { setup: function() { this.d = Date.today().set({year: 1969}); }, '1969': { run: function() {}, assert: function() { return this.d.addYears(0).setWeek(1).equals(new Date(1968, 11, 30)); } }, '1970': { run: function() {}, assert: function() { return this.d.addYears(1).setWeek(1).equals(new Date(1969, 11, 29)); } }, '1971': { run: function() {}, assert: function() { return this.d.addYears(2).setWeek(1).equals(new Date(1971, 0, 4)); } }, '1972': { run: function() {}, assert: function() { return this.d.addYears(3).setWeek(1).equals(new Date(1972, 0, 3)); } }, '1973': { run: function() {}, assert: function() { return this.d.addYears(4).setWeek(1).equals(new Date(1973, 0, 1)); } }, '1974': { run: function() {}, assert: function() { return this.d.addYears(5).setWeek(1).equals(new Date(1973, 11, 31)); } }, '1975': { run: function() {}, assert: function() { return this.d.addYears(6).setWeek(1).equals(new Date(1974, 11, 30)); } }, '1976': { run: function() {}, assert: function() { return this.d.addYears(7).setWeek(1).equals(new Date(1975, 11, 29)); } }, '1977': { run: function() {}, assert: function() { return this.d.addYears(8).setWeek(1).equals(new Date(1977, 0, 3)); } }, '1978': { run: function() {}, assert: function() { return this.d.addYears(9).setWeek(1).equals(new Date(1978, 0, 2)); } }, '1979': { run: function() {}, assert: function() { return this.d.addYears(10).setWeek(1).equals(new Date(1979, 0, 1)); } }, '1980': { run: function() {}, assert: function() { return this.d.addYears(11).setWeek(1).equals(new Date(1979, 11, 31)); } }, '1981': { run: function() {}, assert: function() { return this.d.addYears(12).setWeek(1).equals(new Date(1980, 11, 29)); } }, '1982': { run: function() {}, assert: function() { return this.d.addYears(13).setWeek(1).equals(new Date(1982, 0, 4)); } }, '1983': { run: function() {}, assert: function() { return this.d.addYears(14).setWeek(1).equals(new Date(1983, 0, 3)); } }, '1984': { run: function() {}, assert: function() { return this.d.addYears(15).setWeek(1).equals(new Date(1984, 0, 2)); } }, '1985': { run: function() {}, assert: function() { return this.d.addYears(16).setWeek(1).equals(new Date(1984, 11, 31)); } }, '1986': { run: function() {}, assert: function() { return this.d.addYears(17).setWeek(1).equals(new Date(1985, 11, 30)); } }, '1987': { run: function() {}, assert: function() { return this.d.addYears(18).setWeek(1).equals(new Date(1986, 11, 29)); } }, '1988': { run: function() {}, assert: function() { return this.d.addYears(19).setWeek(1).equals(new Date(1988, 0, 4)); } }, '1989': { run: function() {}, assert: function() { return this.d.addYears(20).setWeek(1).equals(new Date(1989, 0, 2)); } }, '1990': { run: function() {}, assert: function() { return this.d.addYears(21).setWeek(1).equals(new Date(1990, 0, 1)); } }, '1991': { run: function() {}, assert: function() { return this.d.addYears(22).setWeek(1).equals(new Date(1990, 11, 31)); } }, '1992': { run: function() {}, assert: function() { return this.d.addYears(23).setWeek(1).equals(new Date(1991, 11, 30)); } }, '1993': { run: function() {}, assert: function() { return this.d.addYears(24).setWeek(1).equals(new Date(1993, 0, 4)); } }, '1994': { run: function() {}, assert: function() { return this.d.addYears(25).setWeek(1).equals(new Date(1994, 0, 3)); } }, '1995': { run: function() {}, assert: function() { return this.d.addYears(26).setWeek(1).equals(new Date(1995, 0, 2)); } }, '1996': { run: function() {}, assert: function() { return this.d.addYears(27).setWeek(1).equals(new Date(1996, 0, 1)); } }, '1997': { run: function() {}, assert: function() { return this.d.addYears(28).setWeek(1).equals(new Date(1996, 11, 30)); } }, '1998': { run: function() {}, assert: function() { return this.d.addYears(29).setWeek(1).equals(new Date(1997, 11, 29)); } }, '1999': { run: function() {}, assert: function() { return this.d.addYears(30).setWeek(1).equals(new Date(1999, 0, 4)); } }, '2000': { run: function() {}, assert: function() { return this.d.addYears(31).setWeek(1).equals(new Date(2000, 0, 3)); } }, '2001': { run: function() {}, assert: function() { return this.d.addYears(32).setWeek(1).equals(new Date(2001, 0, 1)); } }, '2002': { run: function() {}, assert: function() { return this.d.addYears(33).setWeek(1).equals(new Date(2001, 11, 31)); } }, '2003': { run: function() {}, assert: function() { return this.d.addYears(34).setWeek(1).equals(new Date(2002, 11, 30)); } }, '2004': { run: function() {}, assert: function() { return this.d.addYears(35).setWeek(1).equals(new Date(2003, 11, 29)); } }, '2005': { run: function() {}, assert: function() { return this.d.addYears(36).setWeek(1).equals(new Date(2005, 0, 3)); } }, '2006': { run: function() {}, assert: function() { return this.d.addYears(37).setWeek(1).equals(new Date(2006, 0, 2)); } }, '2007': { run: function() {}, assert: function() { return this.d.addYears(38).setWeek(1).equals(new Date(2007, 0, 1)); } }, '2008': { run: function() {}, assert: function() { return this.d.addYears(39).setWeek(1).equals(new Date(2007, 11, 31)); } }, '2009': { run: function() {}, assert: function() { return this.d.addYears(40).setWeek(1).equals(new Date(2008, 11, 29)); } }, '2010': { run: function() {}, assert: function() { return this.d.addYears(41).setWeek(1).equals(new Date(2010, 0, 4)); } }, '2011': { run: function() {}, assert: function() { return this.d.addYears(42).setWeek(1).equals(new Date(2011, 0, 3)); } }, '2012': { run: function() {}, assert: function() { return this.d.addYears(43).setWeek(1).equals(new Date(2012, 0, 2)); } }, '2013': { run: function() {}, assert: function() { return this.d.addYears(44).setWeek(1).equals(new Date(2012, 11, 31)); } }, '2014': { run: function() {}, assert: function() { return this.d.addYears(45).setWeek(1).equals(new Date(2013, 11, 30)); } }, '2015': { run: function() {}, assert: function() { return this.d.addYears(46).setWeek(1).equals(new Date(2014, 11, 29)); } }, '2016': { run: function() {}, assert: function() { return this.d.addYears(47).setWeek(1).equals(new Date(2016, 0, 4)); } }, '2017': { run: function() {}, assert: function() { return this.d.addYears(48).setWeek(1).equals(new Date(2017, 0, 2)); } }, '2018': { run: function() {}, assert: function() { return this.d.addYears(49).setWeek(1).equals(new Date(2018, 0, 1)); } }, '2019': { run: function() {}, assert: function() { return this.d.addYears(50).setWeek(1).equals(new Date(2018, 11, 31)); } }, '2020': { run: function() {}, assert: function() { return this.d.addYears(51).setWeek(1).equals(new Date(2019, 11, 30)); } }, '2021': { run: function() {}, assert: function() { return this.d.addYears(52).setWeek(1).equals(new Date(2021, 0, 4)); } }, '2022': { run: function() {}, assert: function() { return this.d.addYears(53).setWeek(1).equals(new Date(2022, 0, 3)); } }, '2023': { run: function() {}, assert: function() { return this.d.addYears(54).setWeek(1).equals(new Date(2023, 0, 2)); } }, '2024': { run: function() {}, assert: function() { return this.d.addYears(55).setWeek(1).equals(new Date(2024, 0, 1)); } }, '2025': { run: function() {}, assert: function() { return this.d.addYears(56).setWeek(1).equals(new Date(2024, 11, 30)); } }, '2026': { run: function() {}, assert: function() { return this.d.addYears(57).setWeek(1).equals(new Date(2025, 11, 29)); } }, '2027': { run: function() {}, assert: function() { return this.d.addYears(58).setWeek(1).equals(new Date(2027, 0, 4)); } }, '2028': { run: function() {}, assert: function() { return this.d.addYears(59).setWeek(1).equals(new Date(2028, 0, 3)); } }, '2029': { run: function() {}, assert: function() { return this.d.addYears(60).setWeek(1).equals(new Date(2029, 0, 1)); } }, '2030': { run: function() {}, assert: function() { return this.d.addYears(61).setWeek(1).equals(new Date(2029, 11, 31)); } }, '2031': { run: function() {}, assert: function() { return this.d.addYears(62).setWeek(1).equals(new Date(2030, 11, 30)); } }, '2032': { run: function() {}, assert: function() { return this.d.addYears(63).setWeek(1).equals(new Date(2031, 11, 29)); } }, '2033': { run: function() {}, assert: function() { return this.d.addYears(64).setWeek(1).equals(new Date(2033, 0, 3)); } } } , '.getOrdinalNumber() at 00:00': { setup: function() { }, '1-Jan-2008 (Ordinal Day: 1)': { run: function() {}, assert: function() { return (new Date(2008, 0, 1).getOrdinalNumber() === 1); } }, '15-Jan-2008 (Ordinal Day: 15)': { run: function() {}, assert: function() { return (new Date(2008, 0, 15).getOrdinalNumber() === 15); } }, '1-Feb-2008 (Ordinal Day: 32)': { run: function() {}, assert: function() { return (new Date(2008, 1, 1).getOrdinalNumber() === 32); } }, '28-Feb-2007 (Ordinal Day: 59)': { run: function() {}, assert: function() { return (new Date(2007, 1, 28).getOrdinalNumber() === 59); } }, '29-Feb-2008 (Ordinal Day: 60)': { run: function() {}, assert: function() { return (new Date(2008, 1, 29).getOrdinalNumber() === 60); } }, '1-Mar-2008 (Ordinal Day: 61)': { run: function() {}, assert: function() { return (new Date(2008, 2, 1).getOrdinalNumber() === 61); } }, '1-Apr-2008 (Ordinal Day: 92)': { run: function() {}, assert: function() { return (new Date(2008, 3, 1).getOrdinalNumber() === 92); } }, '1-May-2008 (Ordinal Day: 122)': { run: function() {}, assert: function() { return (new Date(2008, 4, 1).getOrdinalNumber() === 122); } }, '1-Jun-2008 (Ordinal Day: 153)': { run: function() {}, assert: function() { return (new Date(2008, 5, 1).getOrdinalNumber() === 153); } }, '1-Jul-2008 (Ordinal Day: 183)': { run: function() {}, assert: function() { return (new Date(2008, 6, 1).getOrdinalNumber() === 183); } }, '1-Aug-2008 (Ordinal Day: 214)': { run: function() {}, assert: function() { return (new Date(2008, 7, 1).getOrdinalNumber() === 214); } }, '1-Sep-2008 (Ordinal Day: 245)': { run: function() {}, assert: function() { return (new Date(2008, 8, 1).getOrdinalNumber() === 245); } }, '1-Oct-2008 (Ordinal Day: 275)': { run: function() {}, assert: function() { return (new Date(2008, 9, 1).getOrdinalNumber() === 275); } }, '1-Nov-2008 (Ordinal Day: 306)': { run: function() {}, assert: function() { return (new Date(2008, 10, 1).getOrdinalNumber() === 306); } }, '1-Dec-2008 (Ordinal Day: 336)': { run: function() {}, assert: function() { return (new Date(2008, 11, 1).getOrdinalNumber() === 336); } }, '31-Dec-2008 (Ordinal Day: 366)': { run: function() {}, assert: function() { return (new Date(2008, 11, 31).getOrdinalNumber() === 366); } } } , '.getOrdinalNumber() with time set to now': { setup: function() { }, '1-Jan-2008 (Ordinal Day: 1)': { run: function() {}, assert: function() { return (new Date(2008, 0, 1).setTimeToNow().getOrdinalNumber() === 1); } }, '15-Jan-2008 (Ordinal Day: 15)': { run: function() {}, assert: function() { return (new Date(2008, 0, 15).setTimeToNow().getOrdinalNumber() === 15); } }, '1-Feb-2008 (Ordinal Day: 32)': { run: function() {}, assert: function() { return (new Date(2008, 1, 1).setTimeToNow().getOrdinalNumber() === 32); } }, '28-Feb-2007 (Ordinal Day: 59)': { run: function() {}, assert: function() { return (new Date(2007, 1, 28).setTimeToNow().getOrdinalNumber() === 59); } }, '29-Feb-2008 (Ordinal Day: 60)': { run: function() {}, assert: function() { return (new Date(2008, 1, 29).setTimeToNow().getOrdinalNumber() === 60); } }, '1-Mar-2008 (Ordinal Day: 61)': { run: function() {}, assert: function() { return (new Date(2008, 2, 1).setTimeToNow().getOrdinalNumber() === 61); } }, '1-Apr-2008 (Ordinal Day: 92)': { run: function() {}, assert: function() { return (new Date(2008, 3, 1).setTimeToNow().getOrdinalNumber() === 92); } }, '1-May-2008 (Ordinal Day: 122)': { run: function() {}, assert: function() { return (new Date(2008, 4, 1).setTimeToNow().getOrdinalNumber() === 122); } }, '1-Jun-2008 (Ordinal Day: 153)': { run: function() {}, assert: function() { return (new Date(2008, 5, 1).setTimeToNow().getOrdinalNumber() === 153); } }, '1-Jul-2008 (Ordinal Day: 183)': { run: function() {}, assert: function() { return (new Date(2008, 6, 1).setTimeToNow().getOrdinalNumber() === 183); } }, '1-Aug-2008 (Ordinal Day: 214)': { run: function() {}, assert: function() { return (new Date(2008, 7, 1).setTimeToNow().getOrdinalNumber() === 214); } }, '1-Sep-2008 (Ordinal Day: 245)': { run: function() {}, assert: function() { return (new Date(2008, 8, 1).setTimeToNow().getOrdinalNumber() === 245); } }, '1-Oct-2008 (Ordinal Day:275 )': { run: function() {}, assert: function() { return (new Date(2008, 9, 1).setTimeToNow().getOrdinalNumber() === 275); } }, '1-Nov-2008 (Ordinal Day: 306)': { run: function() {}, assert: function() { return (new Date(2008, 10, 1).setTimeToNow().getOrdinalNumber() === 306); } }, '1-Dec-2008 (Ordinal Day: 336)': { run: function() {}, assert: function() { return (new Date(2008, 11, 1).setTimeToNow().getOrdinalNumber() === 336); } }, '31-Dec-2008 (Ordinal Day: 366)': { run: function() {}, assert: function() { return (new Date(2008, 11, 31).setTimeToNow().getOrdinalNumber() === 366); } } } }); $(document).ready(function() { Date.Specification.validate().show() }); ================================================ FILE: tests/culture_info/index.html ================================================ Datejs Test Cases : CultureInfo

es-MX CultureInfo

================================================ FILE: tests/culture_info/index.js ================================================ Date.Specification = new Specification({ 'Overview': { setup: function() { this.baseline = new Date('7/8/2004') }, 'Julio 8, 2004 : Espanol': { run: function() { this.date = Date.parse( 'Julio 8, 2004' ) }, assert: function() { return this.baseline.equals( this.date ) } } } }); $(document).ready( function() { Date.Specification.validate().show() } ); ================================================ FILE: tests/date/index.html ================================================ Datejs Test Cases : Dates

Dates

================================================ FILE: tests/date/index.js ================================================ Date.Specification = new Specification({ 'Overview': { setup: function() { this.baseline = new Date('7/8/2004') }, 'July 8th, 2004 : Typical': { run: function() { this.date = Date.parse('July 8th, 2004') }, assert: function() { return this.baseline.equals( this.date ) } }, 'jul-08-04 : Abbreviated': { run: function() { this.date = Date.parse('jul-8-04') }, assert: function() { return this.baseline.equals( this.date ) } }, '07/08/04 : Numeric': { run: function() { this.date = Date.parse('07/08/04') }, assert: function() { return this.baseline.equals( this.date ) } }, '2004.07.08 : Separator': { run: function() { this.date = Date.parse('2004.07.08') }, assert: function() { return this.baseline.equals( this.date ) } }, '7-8, \'04 : Random Curve ball': { run: function() { this.date = Date.parse('7-8, \'04') }, assert: function() { return this.baseline.equals( this.date ) } }, '07/8/2004 : Leading Zeros': { run: function() { this.date = Date.parse('07/08/2004') }, assert: function() { return this.baseline.equals( this.date ) } }, '15-Jan-2004 : Custom': { run: function() { this.date = Date.parse('15-Jan-2004') }, assert: function() { return new Date(2004,0,15).equals( this.date ) } }, '2004-07-08 : Sortable': { run: function() { this.date = Date.parse('2004-07-08') }, assert: function() { return this.baseline.equals( this.date ) } } }, 'Phrase Variations': { setup: function() { this.baseline = new Date(2004,6,1); this.baseline2 = new Date(2004,6,15); }, '1-Jul-2004': { run: function() { this.date = Date.parse('1-Jul-2004') }, assert: function() { return this.baseline.equals( this.date ) } }, '01-Jul-2004': { run: function() { this.date = Date.parse('01-Jul-2004') }, assert: function() { return this.baseline.equals( this.date ) } }, '01-Jul-04': { run: function() { this.date = Date.parse('01-Jul-04') }, assert: function() { return this.baseline.equals( this.date ) } }, '1-July-2004': { run: function() { this.date = Date.parse('1-July-2004') }, assert: function() { return this.baseline.equals( this.date ) } }, '01-July-2004': { run: function() { this.date = Date.parse('01-July-2004') }, assert: function() { return this.baseline.equals( this.date ) } }, '01-July-04': { run: function() { this.date = Date.parse('01-July-04') }, assert: function() { return this.baseline.equals( this.date ) } }, '15-July-2004': { run: function() { this.date = Date.parse('15-July-2004') }, assert: function() { return this.baseline2.equals( this.date ) } }, '15-July-2004': { run: function() { this.date = Date.parse('15-July-2004') }, assert: function() { return this.baseline2.equals( this.date ) } }, '15-July-04': { run: function() { this.date = Date.parse('15-July-04') }, assert: function() { return this.baseline2.equals( this.date ) } }, 'July 1, 2004': { run: function() { this.date = Date.parse('July 1, 2004') }, assert: function() { return this.baseline.equals( this.date ) } }, 'July 1,2004': { run: function() { this.date = Date.parse('July 1,2004') }, assert: function() { return this.baseline.equals( this.date ) } }, 'Jul 1, 2004': { run: function() { this.date = Date.parse('Jul 1, 2004') }, assert: function() { return this.baseline.equals( this.date ) } }, 'Jul 1,2004': { run: function() { this.date = Date.parse('Jul 1,2004') }, assert: function() { return this.baseline.equals( this.date ) } }, 'July 01, 2004': { run: function() { this.date = Date.parse('July 01, 2004') }, assert: function() { return this.baseline.equals( this.date ) } }, 'July 01,2004': { run: function() { this.date = Date.parse('July 01,2004') }, assert: function() { return this.baseline.equals( this.date ) } }, 'Jul 01, 2004': { run: function() { this.date = Date.parse('Jul 01, 2004') }, assert: function() { return this.baseline.equals( this.date ) } }, 'Jul 01,2004': { run: function() { this.date = Date.parse('Jul 01,2004') }, assert: function() { return this.baseline.equals( this.date ) } }, 'July 01, 04': { run: function() { this.date = Date.parse('July 01, 04') }, assert: function() { return this.baseline.equals( this.date ) } }, 'July 01,04': { run: function() { this.date = Date.parse('July 01,04') }, assert: function() { return this.baseline.equals( this.date ) } }, 'Jul 01, 04': { run: function() { this.date = Date.parse('Jul 01, 04') }, assert: function() { return this.baseline.equals( this.date ) } }, 'Jul 01,04': { run: function() { this.date = Date.parse('Jul 01,04') }, assert: function() { return this.baseline.equals( this.date ) } }, 'July 1st 2004': { run: function() { this.date = Date.parse('July 1st 2004') }, assert: function() { return this.baseline.equals( this.date ) } }, 'July 2nd 2004': { run: function() { this.date = Date.parse('July 2nd 2004') }, assert: function() { return new Date(2004,6,2).equals( this.date ) } }, 'July 3rd 2004': { run: function() { this.date = Date.parse('July 3rd 2004') }, assert: function() { return new Date(2004,6,3).equals( this.date ) } }, 'July 4th 2004': { run: function() { this.date = Date.parse('July 4th 2004') }, assert: function() { return new Date(2004,6,4).equals( this.date ) } }, 'July 15th 2004': { run: function() { this.date = Date.parse('July 15th 2004') }, assert: function() { return new Date(2004,6,15).equals( this.date ) } }, 'July 21st 2004': { run: function() { this.date = Date.parse('July 21st 2004') }, assert: function() { return new Date(2004,6,21).equals( this.date ) } }, 'July 22nd 2004': { run: function() { this.date = Date.parse('July 22nd 2004') }, assert: function() { return new Date(2004,6,22).equals( this.date ) } }, 'July 23rd 2004': { run: function() { this.date = Date.parse('July 23rd 2004') }, assert: function() { return new Date(2004,6,23).equals( this.date ) } }, 'July 31st 2004': { run: function() { this.date = Date.parse('July 31st 2004') }, assert: function() { return new Date(2004,6,31).equals( this.date ) } }, 'Jul 1st 04': { run: function() { this.date = Date.parse('Jul 1st 04') }, assert: function() { return this.baseline.equals( this.date ) } }, 'Jul 2nd 04': { run: function() { this.date = Date.parse('Jul 2nd 04') }, assert: function() { return new Date(2004,6,2).equals( this.date ) } }, 'Jul 3rd 04': { run: function() { this.date = Date.parse('Jul 3rd 04') }, assert: function() { return new Date(2004,6,3).equals( this.date ) } }, 'Jul 4th 04': { run: function() { this.date = Date.parse('Jul 4th 04') }, assert: function() { return new Date(2004,6,4).equals( this.date ) } }, 'Jul 15th 04': { run: function() { this.date = Date.parse('Jul 15th 04') }, assert: function() { return new Date(2004,6,15).equals( this.date ) } }, 'Jul 21st 04': { run: function() { this.date = Date.parse('Jul 21st 04') }, assert: function() { return new Date(2004,6,21).equals( this.date ) } }, 'Jul 22nd 04': { run: function() { this.date = Date.parse('Jul 22nd 04') }, assert: function() { return new Date(2004,6,22).equals( this.date ) } }, 'Jul 23rd 04': { run: function() { this.date = Date.parse('Jul 23rd 04') }, assert: function() { return new Date(2004,6,23).equals( this.date ) } }, 'Jul 31st 04': { run: function() { this.date = Date.parse('Jul 31st 04') }, assert: function() { return new Date(2004,6,31).equals( this.date ) } }, 'Thu July 1, 2004': { run: function() { this.date = Date.parse('Thu July 1, 2004') }, assert: function() { return this.baseline.equals( this.date ) } }, 'Fri July 2, 2004': { run: function() { this.date = Date.parse('Fri July 2, 2004') }, assert: function() { return new Date(2004,6,2).equals( this.date ) } }, 'Sat July 3, 2004': { run: function() { this.date = Date.parse('Sat July 3, 2004') }, assert: function() { return new Date(2004,6,3).equals( this.date ) } }, 'jul-1-2004': { run: function() { this.date = Date.parse('jul-1-2004') }, assert: function() { return this.baseline.equals( this.date ) } }, 'jul-1-04': { run: function() { this.date = Date.parse('jul-1-04') }, assert: function() { return this.baseline.equals( this.date ) } }, 'jul-01-2004': { run: function() { this.date = Date.parse('jul-01-2004') }, assert: function() { return this.baseline.equals( this.date ) } }, 'jul-01-04': { run: function() { this.date = Date.parse('jul-01-04') }, assert: function() { return this.baseline.equals( this.date ) } }, 'jul-15-2004': { run: function() { this.date = Date.parse('jul-15-2004') }, assert: function() { return this.baseline2.equals( this.date ) } }, 'jul-15-04': { run: function() { this.date = Date.parse('jul-15-04') }, assert: function() { return this.baseline2.equals( this.date ) } }, 'jul-15-2004': { run: function() { this.date = Date.parse('jul-15-2004') }, assert: function() { return this.baseline2.equals( this.date ) } }, 'jul-15-04': { run: function() { this.date = Date.parse('jul-15-04') }, assert: function() { return this.baseline2.equals( this.date ) } } }, 'Separator Variations': { setup: function() { this.baseline = new Date(2004,6,1); this.baseline2 = new Date(2004,6,15); }, '7/1/2004': { run: function() { this.date = Date.parse('7/1/2004') }, assert: function() { return this.baseline.equals( this.date ) } }, '07/01/2004': { run: function() { this.date = Date.parse('07/01/2004') }, assert: function() { return this.baseline.equals( this.date ) } }, '07/01/04': { run: function() { this.date = Date.parse('07/01/04') }, assert: function() { return this.baseline.equals( this.date ) } }, '7/1/04': { run: function() { this.date = Date.parse('7/1/04') }, assert: function() { return this.baseline.equals( this.date ) } }, '7/15/2004': { run: function() { this.date = Date.parse('7/15/2004') }, assert: function() { return this.baseline2.equals( this.date ) } }, '07/15/2004': { run: function() { this.date = Date.parse('07/15/2004') }, assert: function() { return this.baseline2.equals( this.date ) } }, '07/15/04': { run: function() { this.date = Date.parse('07/15/04') }, assert: function() { return this.baseline2.equals( this.date ) } }, '7/15/04': { run: function() { this.date = Date.parse('7/15/04') }, assert: function() { return this.baseline2.equals( this.date ) } }, '7-1-2004': { run: function() { this.date = Date.parse('7-1-2004') }, assert: function() { return this.baseline.equals( this.date ) } }, '07-01-2004': { run: function() { this.date = Date.parse('07-01-2004') }, assert: function() { return this.baseline.equals( this.date ) } }, '07-01-04': { run: function() { this.date = Date.parse('07-01-04') }, assert: function() { return this.baseline.equals( this.date ) } }, '7-1-04': { run: function() { this.date = Date.parse('7-1-04') }, assert: function() { return this.baseline.equals( this.date ) } }, '7-15-2004': { run: function() { this.date = Date.parse('7-15-2004') }, assert: function() { return this.baseline2.equals( this.date ) } }, '07-15-2004': { run: function() { this.date = Date.parse('07-15-2004') }, assert: function() { return this.baseline2.equals( this.date ) } }, '07-15-04': { run: function() { this.date = Date.parse('07-15-04') }, assert: function() { return this.baseline2.equals( this.date ) } }, '7-15-04': { run: function() { this.date = Date.parse('7-15-04') }, assert: function() { return this.baseline2.equals( this.date ) } }, '7.1.2004': { run: function() { this.date = Date.parse('7.1.2004') }, assert: function() { return this.baseline.equals( this.date ) } }, '07.01.2004': { run: function() { this.date = Date.parse('07.01.2004') }, assert: function() { return this.baseline.equals( this.date ) } }, '07.01.04': { run: function() { this.date = Date.parse('07.01.04') }, assert: function() { return this.baseline.equals( this.date ) } }, '7.1.04': { run: function() { this.date = Date.parse('7.1.04') }, assert: function() { return this.baseline.equals( this.date ) } }, '7.15.2004': { run: function() { this.date = Date.parse('7.15.2004') }, assert: function() { return this.baseline2.equals( this.date ) } }, '07.15.2004': { run: function() { this.date = Date.parse('07.15.2004') }, assert: function() { return this.baseline2.equals( this.date ) } }, '07.15.04': { run: function() { this.date = Date.parse('07.15.04') }, assert: function() { return this.baseline2.equals( this.date ) } }, '7.15.04': { run: function() { this.date = Date.parse('7.15.04') }, assert: function() { return this.baseline2.equals( this.date ) } } }, 'Sortable Variations': { setup: function() { this.baseline = new Date(2004,6,1); this.baseline2 = new Date(2004,6,15); }, '2004-07-01': { run: function() { this.date = Date.parse('2004-07-01') }, assert: function() { return this.baseline.equals( this.date ) } }, '2004-07-15': { run: function() { this.date = Date.parse('2004-07-15') }, assert: function() { return this.baseline2.equals( this.date ) } }, '2004/7/1': { run: function() { this.date = Date.parse('2004/7/1') }, assert: function() { return this.baseline.equals( this.date ) } }, '2004/07/01': { run: function() { this.date = Date.parse('2004/07/01') }, assert: function() { return this.baseline.equals( this.date ) } }, '2004/7/15': { run: function() { this.date = Date.parse('2004/7/15') }, assert: function() { return this.baseline2.equals( this.date ) } }, '2004/07/15': { run: function() { this.date = Date.parse('2004/07/15') }, assert: function() { return this.baseline2.equals( this.date ) } } }, 'Numeric Dates': { setup: function() { this.baseline = new Date(2004,6,1); this.baseline2 = new Date(2004,6,15); }, '07012004': { run: function() { this.date = Date.parse('07012004') }, assert: function() { return this.baseline.equals( this.date ) } }, '712004': { run: function() { this.date = Date.parse('712004') }, assert: function() { return this.baseline.equals( this.date ) } }, '7104': { run: function() { this.date = Date.parse('7104', { format : "Mdyy" } ) }, assert: function() { return this.baseline.equals( this.date ) } }, '07152004': { run: function() { this.date = Date.parse('07152004') }, assert: function() { return this.baseline2.equals( this.date ) } }, '7152004': { run: function() { this.date = Date.parse('7152004') }, assert: function() { return this.baseline2.equals( this.date ) } }, '71504': { run: function() { this.date = Date.parse('71504', { format : "Mdyy" } ) }, assert: function() { return this.baseline2.equals( this.date ) } } } }); $(document).ready( function() { Date.Specification.validate().show() } ); ================================================ FILE: tests/date2/date2.js ================================================ var Date2 = function(x) { this.year = 0; this.month = 0; this.day = 1; this.hour = 0; this.minute = 0; this.second = 0; this.millisecond = 0; if ( x instanceof String ) { // TODO: convert parse to Date2 return Date2.parse(x); } else if ( x instanceof Object ) { this.set(x); } else if (arguments.length == 0 ) { // TODO: get values from new Date() } }; Date.prototype = { toMilliseconds: function() { // TODO: Adjust for timezone ... return new Date(this.year, this.month, this.day, this.hour, this.minute, this.second, this.millisecond).getMilliseconds(); }, toString: function(fmt) { if ( fmt !== undefined ) { // TODO: format the string } else { // TODO: implement 'abbreviated' functions var datePart = [ this.getAbbreviatedDayOfWeek(), this.getAbbreviatedMonthName(), this.getDay(), this.getYear() ].join(' '); var timePart = [ this.getHour(), this.getMinute(), this.getSecond() ].join(':'); return [ datePart, timePart, this.getTimezone() ].join(' '); } } }; (function() { var capitalize = function(s) { return s.slice(0,1).toUpperCase() + s.slice(1); } var getterFn = function(attr) { return function() { return this[attr]; }; }; var setterFn = function(attr) { return function(val) { this[attr] = val; return this; }; }; var addFn = function(attr) { return function(val) { this[attr] += val; return this; }; }; var attributes = 'year month day hour minute second millisecond timezone'.split(/\s+/); for ( var i = 0; i < attributes.length ; i++ ) { var A = capitalize( attributes[i] ), a = attributes[i]; Date2.prototype['get'+A] = getterFn(a); Date2.prototype['set'+A] = setterFn(a); Date2.prototype['add'+A] = addFn(a); } var bulk = function(name) { Date2.prototype[ name ] = function(obj) { for ( var i = 0; i < attributes.length ; i++ ) { var attribute = capitalize( attributes[i] ); if ( obj[attributes[i]]!= null ) { console.log(name+attribute); this[ name + attribute ]( obj[attributes[i]] ); } } return this; }; }; bulk('add'); bulk('set'); }()); ================================================ FILE: tests/date2/index.html ================================================ Date2 Experiment

Date2 Experiment

================================================ FILE: tests/date_and_time/index.html ================================================ Datejs Test Cases : Date and Times

Date and Times

================================================ FILE: tests/date_and_time/index.js ================================================ Date.Specification = new Specification({ 'Overview': { setup: function() { this.d = []; this.d[0] = new Date(2004,6,8,22,30,0,0); this.d[1] = this.d[0].clone().setTimezoneOffset('-0400'); }, 'July 8th, 2004, 10:30 PM': { run: function() { this.date = Date.parse('July 8th, 2004, 10:30 PM') }, assert: function() { return this.d[0].compareTo( this.date ) == 0 } }, '2004.07.08 22:30': { run: function() { this.date = Date.parse('2004.07.08 22:30') }, assert: function() { return this.d[0].compareTo( this.date ) == 0 } }, '10:30pm 08-July-2004': { run: function() { this.date = Date.parse('10:30pm 08-July-2004') }, assert: function() { return this.d[0].compareTo( this.date ) == 0 } }, 'Thu Jul 8 2004 22:30:00 GMT-0400': { run: function() { this.date = Date.parse('Thu Jul 8 2004 22:30:00 GMT-0400') }, assert: function() { return this.d[1].equals( this.date ) } } }, 'Standard Patterns': { setup: function() { this.today = new Date().clearTime(); this.baseline = new Date(2004,6,1,22,30,0); this.baseline2 = new Date(2004,6,15,6,45,0); }, '2004, July 01, 10:30:00 PM : FullDateTimePattern [dddd, MMMM dd, yyyy h:mm:ss tt]': { run: function() { this.date = Date.parse('2004, July 01, 10:30:00 PM') }, assert: function() { return this.baseline.equals( this.date ) } }, '2004, July 15, 6:45:00 AM : FullDateTimePattern [dddd, MMMM dd, yyyy h:mm:ss tt]': { run: function() { this.date = Date.parse('2004, July 15, 6:45:00 AM') }, assert: function() { return this.baseline2.equals( this.date ) } }, 'Thursday, July 01, 2004 : LongDatePattern [dddd, MMMM dd, yyyy]': { run: function() { this.date = Date.parse('Thursday, July 01, 2004') }, assert: function() { return this.baseline.clearTime().equals( this.date ) } }, 'Thursday, July 15, 2004 : LongDatePattern [dddd, MMMM dd, yyyy]': { run: function() { this.date = Date.parse('Thursday, July 15, 2004') }, assert: function() { return this.baseline2.clearTime().equals( this.date ) } }, '10:30:00 PM : LongTimePattern [h:mm:ss tt]': { run: function() { this.date = Date.parse('10:30:00 PM') }, assert: function() { return this.today.clone().set( { hour: 22, minute: 30 } ).equals( this.date ) } }, '6:45:00 AM : LongTimePattern [h:mm:ss tt]': { run: function() { this.date = Date.parse('6:45:00 AM') }, assert: function() { return this.today.clone().set( { hour: 6, minute: 45 } ).equals( this.date ) } }, 'July 01 : MonthDayPattern [MMMM dd]': { run: function() { this.date = Date.parse('July 01') }, assert: function() { return this.today.clone().set( { month: 6, day: 1 } ).equals( this.date ) } }, 'July 15 : MonthDayPattern [MMMM dd]': { run: function() { this.date = Date.parse('July 15') }, assert: function() { return Date.today().set( { month: 6, day: 15 } ).equals( this.date ) } }, 'July 2004 : YearMonthPattern [MMMM, yyyy]': { run: function() { this.date = Date.parse('July 2004') }, assert: function() { return new Date(2004,6,1).equals( this.date ) } }, '7/1/2004 : ShortDatePattern [M/d/yyyy]': { run: function() { this.date = Date.parse('7/1/2004') }, assert: function() { return this.baseline.clearTime().equals( this.date ) } }, '7/15/2004 : ShortDatePattern [M/d/yyyy]': { run: function() { this.date = Date.parse('7/15/2004') }, assert: function() { return this.baseline2.clearTime().equals( this.date ) } }, '10:30 PM : ShortTimePattern [h:mm tt]': { run: function() { this.date = Date.parse('10:30 PM') }, assert: function() { return this.today.clone().set( { hour: 22, minute: 30 } ).equals( this.date ) } }, '6:45 AM : ShortTimePattern [h:mm tt]': { run: function() { this.date = Date.parse('6:45 AM') }, assert: function() { return this.today.clone().set( { hour: 6, minute: 45 } ).equals( this.date ) } }, '2004-07-01T22:30:00 : SortableDateTimePattern [yyyy-MM-ddTHH:mm:ss]': { run: function() { this.date = Date.parse('2004-07-01T22:30:00') }, assert: function() { return this.baseline.equals( this.date ) } }, '2004-07-15T06:45:00 : SortableDateTimePattern [yyyy-MM-ddTHH:mm:ss]': { run: function() { this.date = Date.parse('2004-07-15T06:45:00') }, assert: function() { return this.baseline2.equals( this.date ) } }, '11 Aug 2007 7:15:00 am EDT': { run: function() { this.date = Date.parse('11 Aug 2007 7:15:00 am EDT') }, assert: function() { return new Date(2007,7,11,7,15,0).add(-3).hours().equals( this.date ) } }, 'Tue Nov 20 2007 08:00:00 UTC': { run: function() { this.date = Date.parse("Tue Nov 20 2007 08:00:00 UTC") }, assert: function() { return new Date(2007,10,20,8,0,0).setTimezone("UTC").equals( this.date ) } }, '24 Apr 2008 17:00': { run: function() { this.date = Date.parse("24 Apr 2008 17:00") }, assert: function() { return new Date(2008,3,24,17,0,0).equals( this.date ) } }, '24 April 2008 17:00': { run: function() { this.date = Date.parse("24 April 2008 17:00") }, assert: function() { return new Date(2008,3,24,17,0,0).equals( this.date ) } } }, 'Numeric Variations': { setup: function() { this.baseline = new Date(2004,6,1,22,30,0); this.baseline2 = new Date(2004,6,15,6,45,0); }, '7/1/2004 10 PM': { run: function() { this.date = Date.parse('7/1/2004 10 PM') }, assert: function() { return this.baseline.addMinutes(-30).equals( this.date ) } }, '07/01/2004 10 PM': { run: function() { this.date = Date.parse('07/01/2004 10 PM') }, assert: function() { return this.baseline.addMinutes(-30).equals( this.date ) } }, '07/01/04 10 PM': { run: function() { this.date = Date.parse('07/01/04 10 PM') }, assert: function() { return this.baseline.addMinutes(-30).equals( this.date ) } }, '7/1/04 10 PM': { run: function() { this.date = Date.parse('7/1/04 10 PM') }, assert: function() { return this.baseline.addMinutes(-30).equals( this.date ) } }, '7/15/2004 6 AM': { run: function() { this.date = Date.parse('7/15/2004 6 AM') }, assert: function() { return this.baseline2.addMinutes(-45).equals( this.date ) } }, '07/15/2004 6 AM': { run: function() { this.date = Date.parse('07/15/2004 6 AM') }, assert: function() { return this.baseline2.addMinutes(-45).equals( this.date ) } }, '07/15/04 6 AM': { run: function() { this.date = Date.parse('07/15/04 6 AM') }, assert: function() { return this.baseline2.addMinutes(-45).equals( this.date ) } }, '7/15/04 6 AM': { run: function() { this.date = Date.parse('7/15/04 6 AM') }, assert: function() { return this.baseline2.addMinutes(-45).equals( this.date ) } }, '7/1/2004 10pm': { run: function() { this.date = Date.parse('7/1/2004 10pm') }, assert: function() { return this.baseline.addMinutes(-30).equals( this.date ) } }, '07/01/2004 10pm': { run: function() { this.date = Date.parse('07/01/2004 10pm') }, assert: function() { return this.baseline.addMinutes(-30).equals( this.date ) } }, '07/01/04 10pm': { run: function() { this.date = Date.parse('07/01/04 10pm') }, assert: function() { return this.baseline.addMinutes(-30).equals( this.date ) } }, '7/1/04 10pm': { run: function() { this.date = Date.parse('7/1/04 10pm') }, assert: function() { return this.baseline.addMinutes(-30).equals( this.date ) } }, '7/15/2004 6am': { run: function() { this.date = Date.parse('7/15/2004 6am') }, assert: function() { return this.baseline2.addMinutes(-45).equals( this.date ) } }, '07/15/2004 6am': { run: function() { this.date = Date.parse('07/15/2004 6am') }, assert: function() { return this.baseline2.addMinutes(-45).equals( this.date ) } }, '07/15/04 6am': { run: function() { this.date = Date.parse('07/15/04 6am') }, assert: function() { return this.baseline2.addMinutes(-45).equals( this.date ) } }, '7/15/04 6am': { run: function() { this.date = Date.parse('7/15/04 6am') }, assert: function() { return this.baseline2.addMinutes(-45).equals( this.date ) } }, '7/1/2004 10:30 PM': { run: function() { this.date = Date.parse('7/1/2004 10:30 PM') }, assert: function() { return this.baseline.equals( this.date ) } }, '07/01/2004 10:30 PM': { run: function() { this.date = Date.parse('07/01/2004 10:30 PM') }, assert: function() { return this.baseline.equals( this.date ) } }, '07/01/04 10:30 PM': { run: function() { this.date = Date.parse('07/01/04 10:30 PM') }, assert: function() { return this.baseline.equals( this.date ) } }, '7/1/04 10:30 PM': { run: function() { this.date = Date.parse('7/1/04 10:30 PM') }, assert: function() { return this.baseline.equals( this.date ) } }, '7/15/2004 6:45 AM': { run: function() { this.date = Date.parse('7/15/2004 6:45 AM') }, assert: function() { return this.baseline2.equals( this.date ) } }, '07/15/2004 6:45 AM': { run: function() { this.date = Date.parse('07/15/2004 6:45 AM') }, assert: function() { return this.baseline2.equals( this.date ) } }, '07/15/04 6:45 AM': { run: function() { this.date = Date.parse('07/15/04 6:45 AM') }, assert: function() { return this.baseline2.equals( this.date ) } }, '7/15/04 6:45 AM': { run: function() { this.date = Date.parse('7/15/04 6:45 AM') }, assert: function() { return this.baseline2.equals( this.date ) } }, '7/1/2004 10:30p': { run: function() { this.date = Date.parse('7/1/2004 10:30p') }, assert: function() { return this.baseline.equals( this.date ) } }, '07/01/2004 10:30p': { run: function() { this.date = Date.parse('07/01/2004 10:30p') }, assert: function() { return this.baseline.equals( this.date ) } }, '07/01/04 10:30p': { run: function() { this.date = Date.parse('07/01/04 10:30p') }, assert: function() { return this.baseline.equals( this.date ) } }, '7/1/04 10:30p': { run: function() { this.date = Date.parse('7/1/04 10:30p') }, assert: function() { return this.baseline.equals( this.date ) } }, '7/15/2004 6:45a': { run: function() { this.date = Date.parse('7/15/2004 6:45a') }, assert: function() { return this.baseline2.equals( this.date ) } }, '07/15/2004 6:45a': { run: function() { this.date = Date.parse('07/15/2004 6:45a') }, assert: function() { return this.baseline2.equals( this.date ) } }, '7/15/04 6:45a': { run: function() { this.date = Date.parse('7/15/04 6:45a') }, assert: function() { return this.baseline2.equals( this.date ) } }, '07/01 10 PM': { run: function() { this.date = Date.parse('07/01 10 PM') }, assert: function() { return new Date().clearTime().set( { month: 6, day: 1, hour: 22 } ).equals( this.date ) } }, '7/1 10 PM': { run: function() { this.date = Date.parse('7/1 10 PM') }, assert: function() { return new Date().clearTime().set( { month: 6, day: 1, hour: 22 } ).equals( this.date ) } }, '07/15 6 AM': { run: function() { this.date = Date.parse('07/15 6 AM') }, assert: function() { return new Date().clearTime().set( { month: 6, day: 15, hour: 6 } ).equals( this.date ) } }, '7/15 6 AM': { run: function() { this.date = Date.parse('7/15 6 AM') }, assert: function() { return new Date().clearTime().set( { month: 6, day: 15, hour: 6 } ).equals( this.date ) } }, '07/01 10pm': { run: function() { this.date = Date.parse('07/01 10pm') }, assert: function() { return new Date().clearTime().set( { month: 6, day: 1, hour: 22 } ).equals( this.date ) } }, '7/1 10pm': { run: function() { this.date = Date.parse('7/1 10pm') }, assert: function() { return new Date().clearTime().set( { month: 6, day: 1, hour: 22 } ).equals( this.date ) } }, '7/15 6am': { run: function() { this.date = Date.parse('7/15 6am') }, assert: function() { return new Date().clearTime().set( { month: 6, day: 15, hour: 6 } ).equals( this.date ) } }, '07/15 6am': { run: function() { this.date = Date.parse('07/15 6am') }, assert: function() { return new Date().clearTime().set( { month: 6, day: 15, hour: 6 } ).equals( this.date ) } }, '07/01 10:30 PM': { run: function() { this.date = Date.parse('07/01 10:30 PM') }, assert: function() { return new Date().clearTime().set( { month: 6, day: 1, hour: 22, minute: 30 } ).equals( this.date ) } }, '7/1 10:30 PM': { run: function() { this.date = Date.parse('7/1 10:30 PM') }, assert: function() { return new Date().clearTime().set( { month: 6, day: 1, hour: 22, minute: 30 } ).equals( this.date ) } }, '7/15 6:45 AM': { run: function() { this.date = Date.parse('7/15 6:45 AM') }, assert: function() { return new Date().clearTime().set( { month: 6, day: 15, hour: 6, minute: 45 } ).equals( this.date ) } }, '07/15 6:45 AM': { run: function() { this.date = Date.parse('07/15 6:45 AM') }, assert: function() { return new Date().clearTime().set( { month: 6, day: 15, hour: 6, minute: 45 } ).equals( this.date ) } }, '7/1 10:30p': { run: function() { this.date = Date.parse('7/1 10:30p') }, assert: function() { return new Date().clearTime().set( { month: 6, day: 1, hour: 22, minute: 30 } ).equals( this.date ) } }, '07/01 10:30p': { run: function() { this.date = Date.parse('07/01 10:30p') }, assert: function() { return new Date().clearTime().set( { month: 6, day: 1, hour: 22, minute: 30 } ).equals( this.date ) } }, '07/15 6:45a': { run: function() { this.date = Date.parse('07/15 6:45a') }, assert: function() { return new Date().clearTime().set( { month: 6, day: 15, hour: 6, minute: 45 } ).equals( this.date ) } }, '7/15 6:45a': { run: function() { this.date = Date.parse('7/15 6:45a') }, assert: function() { return new Date().clearTime().set( { month: 6, day: 15, hour: 6, minute: 45 } ).equals( this.date ) } } }, 'Phrase Variations': { setup: function() { var today = new Date().clearTime(); this.baseline = new Date(2004,06,01,22,30,0,0); this.baseline2 = new Date(2004,06,15,6,45,0,0); this.baseline3 = new Date( today.getFullYear(),06,1,22,30,0,0); this.baseline4 = new Date( today.getFullYear(),06,15,6,45,0,0) }, 'Thu Jul 1 2004 22:30:00': { run: function() { this.date = Date.parse('Thu Jul 1 2004 22:30:00') }, assert: function() { return this.baseline.compareTo( this.date ) == 0 } }, 'Thu July 01 2004 22:30:00': { run: function() { this.date = Date.parse('Thu July 01 2004 22:30:00') }, assert: function() { return this.baseline.compareTo( this.date ) == 0 } }, 'Thu Jul 15 2004 06:45:00': { run: function() { this.date = Date.parse('Thu Jul 15 2004 06:45:00') }, assert: function() { return this.baseline2.compareTo( this.date ) == 0 } }, 'Thu July 15 2004 06:45:00': { run: function() { this.date = Date.parse('Thu July 15 2004 06:45:00') }, assert: function() { return this.baseline2.compareTo( this.date ) == 0 } }, 'July 1 2004 22:30:00': { run: function() { this.date = Date.parse('July 1 2004 22:30:00') }, assert: function() { return this.baseline.compareTo( this.date ) == 0 } }, 'July 01 2004 22:30:00': { run: function() { this.date = Date.parse('July 01 2004 22:30:00') }, assert: function() { return this.baseline.compareTo( this.date ) == 0 } }, 'Jul 15 2004 06:45:00': { run: function() { this.date = Date.parse('Jul 15 2004 06:45:00') }, assert: function() { return this.baseline2.compareTo( this.date ) == 0 } }, 'July 15 2004 06:45:00': { run: function() { this.date = Date.parse('July 15 2004 06:45:00') }, assert: function() { return this.baseline2.compareTo( this.date ) == 0 } }, 'July 1 2004 10 PM': { run: function() { this.date = Date.parse('July 1 2004 10 PM') }, assert: function() { return this.baseline.addMinutes(-30).compareTo( this.date ) == 0 } }, 'July 1 2004 10:30 PM': { run: function() { this.date = Date.parse('July 1 2004 10:30 PM') }, assert: function() { return this.baseline.compareTo( this.date ) == 0 } }, 'Jul 1 2004 10PM': { run: function() { this.date = Date.parse('Jul 1 2004 10PM') }, assert: function() { return this.baseline.addMinutes(-30).compareTo( this.date ) == 0 } }, 'Jul 1 2004 10:30PM': { run: function() { this.date = Date.parse('Jul 1 2004 10:30PM') }, assert: function() { return this.baseline.compareTo( this.date ) == 0 } }, 'July 1 2004 10p': { run: function() { this.date = Date.parse('July 1 2004 10p') }, assert: function() { return this.baseline.addMinutes(-30).compareTo( this.date ) == 0 } }, 'July 1 2004 10:30p': { run: function() { this.date = Date.parse('July 1 2004 10:30p') }, assert: function() { return this.baseline.compareTo( this.date ) == 0 } }, 'July 15 2004 6 AM': { run: function() { this.date = Date.parse('July 15 2004 6 AM') }, assert: function() { return this.baseline2.addMinutes(-45).compareTo( this.date ) == 0 } }, 'July 15 2004 6:45 AM': { run: function() { this.date = Date.parse('July 15 2004 6:45 AM') }, assert: function() { return this.baseline2.compareTo( this.date ) == 0 } }, 'Jul 15 2004 6AM': { run: function() { this.date = Date.parse('Jul 15 2004 6AM') }, assert: function() { return this.baseline2.addMinutes(-45).compareTo( this.date ) == 0 } }, 'Jul 15 2004 6:45AM': { run: function() { this.date = Date.parse('Jul 15 2004 6:45AM') }, assert: function() { return this.baseline2.compareTo( this.date ) == 0 } }, 'July 15 2004 6a': { run: function() { this.date = Date.parse('July 15 2004 6a') }, assert: function() { return this.baseline2.addMinutes(-45).compareTo( this.date ) == 0 } }, 'July 15 2004 6:45a': { run: function() { this.date = Date.parse('July 15 2004 6:45a') }, assert: function() { return this.baseline2.compareTo( this.date ) == 0 } }, 'July 1st 2004 10 PM': { run: function() { this.date = Date.parse('July 1st 2004 10 PM') }, assert: function() { return this.baseline.addMinutes(-30).compareTo( this.date ) == 0 } }, 'July 1st 2004 10:30 PM': { run: function() { this.date = Date.parse('July 1st 2004 10:30 PM') }, assert: function() { return this.baseline.compareTo( this.date ) == 0 } }, 'Jul 1 2004 10PM': { run: function() { this.date = Date.parse('Jul 1 2004 10PM') }, assert: function() { return this.baseline.addMinutes(-30).compareTo( this.date ) == 0 } }, 'Jul 1 2004 10:30PM': { run: function() { this.date = Date.parse('Jul 1 2004 10:30PM') }, assert: function() { return this.baseline.compareTo( this.date ) == 0 } }, 'July 1st 2004 10p': { run: function() { this.date = Date.parse('July 1st 2004 10p') }, assert: function() { return this.baseline.addMinutes(-30).compareTo( this.date ) == 0 } }, 'July 1st 2004 10:30p': { run: function() { this.date = Date.parse('July 1st 2004 10:30p') }, assert: function() { return this.baseline.compareTo( this.date ) == 0 } }, 'July 15th 2004 6 AM': { run: function() { this.date = Date.parse('July 15th 2004 6 AM') }, assert: function() { return this.baseline2.addMinutes(-45).compareTo( this.date ) == 0 } }, 'July 15th 2004 6:45 AM': { run: function() { this.date = Date.parse('July 15th 2004 6:45 AM') }, assert: function() { return this.baseline2.compareTo( this.date ) == 0 } }, 'Jul 15 2004 6AM': { run: function() { this.date = Date.parse('Jul 15 2004 6AM') }, assert: function() { return this.baseline2.addMinutes(-45).compareTo( this.date ) == 0 } }, 'Jul 15 2004 6:45AM': { run: function() { this.date = Date.parse('Jul 15 2004 6:45AM') }, assert: function() { return this.baseline2.compareTo( this.date ) == 0 } }, 'July 15th 2004 6a': { run: function() { this.date = Date.parse('July 15th 2004 6a') }, assert: function() { return this.baseline2.addMinutes(-45).compareTo( this.date ) == 0 } }, 'July 15th 2004 6:45a': { run: function() { this.date = Date.parse('July 15th 2004 6:45a') }, assert: function() { return this.baseline2.compareTo( this.date ) == 0 } }, 'July 1 10 PM': { run: function() { this.date = Date.parse('July 1 10 PM') }, assert: function() { return this.baseline3.addMinutes(-30).compareTo( this.date ) == 0 } }, 'July 1 10:30 PM': { run: function() { this.date = Date.parse('July 1 10:30 PM') }, assert: function() { return this.baseline3.compareTo( this.date ) == 0 } }, 'Jul 1 10PM': { run: function() { this.date = Date.parse('Jul 1 10PM') }, assert: function() { return this.baseline3.addMinutes(-30).compareTo( this.date ) == 0 } }, 'Jul 1 10:30PM': { run: function() { this.date = Date.parse('Jul 1 10:30PM') }, assert: function() { return this.baseline3.compareTo( this.date ) == 0 } }, 'July 1 10p': { run: function() { this.date = Date.parse('July 1 10p') }, assert: function() { return this.baseline3.addMinutes(-30).compareTo( this.date ) == 0 } }, 'July 1 10:30p': { run: function() { this.date = Date.parse('July 1 10:30p') }, assert: function() { return this.baseline3.compareTo( this.date ) == 0 } }, 'July 15 6 AM': { run: function() { this.date = Date.parse('July 15 6 AM') }, assert: function() { return this.baseline4.addMinutes(-45).compareTo( this.date ) == 0 } }, 'July 15 6:45 AM': { run: function() { this.date = Date.parse('July 15 6:45 AM') }, assert: function() { return this.baseline4.compareTo( this.date ) == 0 } }, 'Jul 15 6AM': { run: function() { this.date = Date.parse('Jul 15 6AM') }, assert: function() { return this.baseline4.addMinutes(-45).compareTo( this.date ) == 0 } }, 'Jul 15 6:45AM': { run: function() { this.date = Date.parse('Jul 15 6:45AM') }, assert: function() { return this.baseline4.compareTo( this.date ) == 0 } }, 'July 15 6a': { run: function() { this.date = Date.parse('July 15 6a') }, assert: function() { return this.baseline4.addMinutes(-45).compareTo( this.date ) == 0 } }, 'July 15 6:45a': { run: function() { this.date = Date.parse('July 15 6:45a') }, assert: function() { return this.baseline4.compareTo( this.date ) == 0 } }, 'July 1st 10 PM': { run: function() { this.date = Date.parse('July 1st 10 PM') }, assert: function() { return this.baseline3.addMinutes(-30).compareTo( this.date ) == 0 } }, 'July 1st 10:30 PM': { run: function() { this.date = Date.parse('July 1st 10:30 PM') }, assert: function() { return this.baseline3.compareTo( this.date ) == 0 } }, 'Jul 1 10PM': { run: function() { this.date = Date.parse('Jul 1 10PM') }, assert: function() { return this.baseline3.addMinutes(-30).compareTo( this.date ) == 0 } }, 'Jul 1 10:30PM': { run: function() { this.date = Date.parse('Jul 1 10:30PM') }, assert: function() { return this.baseline3.compareTo( this.date ) == 0 } }, 'July 1st 10p': { run: function() { this.date = Date.parse('July 1st 10p') }, assert: function() { return this.baseline3.addMinutes(-30).compareTo( this.date ) == 0 } }, 'July 1st 10:30p': { run: function() { this.date = Date.parse('July 1st 10:30p') }, assert: function() { return this.baseline3.compareTo( this.date ) == 0 } }, 'July 15th 6 AM': { run: function() { this.date = Date.parse('July 15th 6 AM') }, assert: function() { return this.baseline4.addMinutes(-45).compareTo( this.date ) == 0 } }, 'July 15th 6:45 AM': { run: function() { this.date = Date.parse('July 15th 6:45 AM') }, assert: function() { return this.baseline4.compareTo( this.date ) == 0 } }, 'Jul 15 6AM': { run: function() { this.date = Date.parse('Jul 15 6AM') }, assert: function() { return this.baseline4.addMinutes(-45).compareTo( this.date ) == 0 } }, 'Jul 15 6:45AM': { run: function() { this.date = Date.parse('Jul 15 6:45AM') }, assert: function() { return this.baseline4.compareTo( this.date ) == 0 } }, 'July 15th 6a': { run: function() { this.date = Date.parse('July 15th 6a') }, assert: function() { return this.baseline4.addMinutes(-45).compareTo( this.date ) == 0 } }, 'July 15th 6:45a': { run: function() { this.date = Date.parse('July 15th 6:45a') }, assert: function() { return this.baseline4.compareTo( this.date ) == 0 } }, 'JSON: 2004-07-01T22:30:00': { run: function() { this.date = Date.parse('2004-07-01T22:30:00') }, assert: function() { return this.baseline.compareTo( this.date ) == 0 } }, 'JSON: 2004-07-15T06:45:00': { run: function() { this.date = Date.parse('2004-07-15T06:45:00') }, assert: function() { return this.baseline2.compareTo( this.date ) == 0 } } }, 'Common Formats': { setup: function() { this.d = []; this.d[0] = new Date(2004,6,1,22,30,0,0); this.d[1] = new Date(2004,6,15,6,45,0,0); this.d[2] = Date.today().set( { hour: 22, minute: 30 } ); this.d[3] = Date.today().set( { hour: 6, minute: 45 } ); this.d[4] = Date.today().set( { month: 6, day: 1 } ); this.d[5] = Date.today().set( { month: 6, day: 15 } ); this.d[6] = Date.today().set( { month: 6, day: 1, year: 2004 } ); this.d[7] = this.d[0].clone().setTimezoneOffset( 0 ); this.d[8] = this.d[1].clone().setTimezoneOffset( '-0400' ); }, 'Thursday, July 01, 2004 10:30:00 PM : "dddd, MMMM dd, yyyy h:mm:ss tt"': { run: function() { this.date = Date.parse('Thursday, July 01, 2004 10:30:00 PM') }, assert: function() { return this.d[0].equals( this.date ) } }, 'Thursday, July 01, 2004 : "dddd, MMMM dd, yyyy"': { run: function() { this.date = Date.parse('Thursday, July 01, 2004') }, assert: function() { return this.d[0].clearTime().equals( this.date ) } }, 'Thursday, July 15, 2004 : "dddd, MMMM dd, yyyy"': { run: function() { this.date = Date.parse('Thursday, July 15, 2004') }, assert: function() { return this.d[1].clearTime().equals( this.date ) } }, '10:30:00 PM : "h:mm:ss tt"': { run: function() { this.date = Date.parse('10:30:00 PM') }, assert: function() { return this.d[2].equals( this.date ) } }, '6:45:00 AM : "h:mm:ss tt"': { run: function() { this.date = Date.parse('6:45:00 AM') }, assert: function() { return this.d[3].equals( this.date ) } }, 'July 01 : "MMMM dd"': { run: function() { this.date = Date.parse('July 01') }, assert: function() { return this.d[4].equals( this.date ) } }, 'July 15 : "MMMM dd"': { run: function() { this.date = Date.parse('July 15') }, assert: function() { return this.d[5].equals( this.date ) } }, 'July 2004 : "MMMM, yyyy"': { run: function() { this.date = Date.parse('July 2004') }, assert: function() { return this.d[6].equals( this.date ) } }, '7/1/2004 : "M/d/yyyy"': { run: function() { this.date = Date.parse('7/1/2004') }, assert: function() { return this.d[0].clearTime().equals( this.date ) } }, '7/15/2004 : "M/d/yyyy"': { run: function() { this.date = Date.parse('7/15/2004') }, assert: function() { return this.d[1].clearTime().equals( this.date ) } }, '10:30 PM : "h:mm tt"': { run: function() { this.date = Date.parse('10:30 PM') }, assert: function() { return this.d[2].equals( this.date ) } }, '6:45 AM : "h:mm tt"': { run: function() { this.date = Date.parse('6:45 AM') }, assert: function() { return this.d[3].equals( this.date ) } }, '2004-07-01T22:30:00 : "yyyy-MM-ddTHH:mm:ss"': { run: function() { this.date = Date.parse('2004-07-01T22:30:00') }, assert: function() { return this.d[0].equals( this.date ) } }, '2004-07-15T06:45:00 : "yyyy-MM-ddTHH:mm:ss"': { run: function() { this.date = Date.parse('2004-07-15T06:45:00') }, assert: function() { return this.d[1].equals( this.date ) } }, '2004-07-15 06:45:00 -0400 : "yyyy-MM-dd HH:mm:ss Z"': { run: function() { this.date = Date.parse('2004-07-15 06:45:00 -0400') }, assert: function() { return this.d[8].equals( this.date ) } }, 'Thu, 1 July 2004 22:30:00 GMT : "ddd, dd MMM yyyy HH:mm:ss GMT"': { run: function() { this.date = Date.parse('Thu, 1 July 2004 22:30:00 GMT') }, assert: function() { return this.d[7].equals( this.date ) } } }, 'ISO 8601 Formats': { setup: function() { this.d = []; this.d[0] = new Date(2004,6,1,22,30,0,0); this.d[1] = new Date(2004,6,15,6,45,0,0); this.d[2] = Date.today().set( { hour: 22, minute: 30 } ); this.d[3] = Date.today().set( { hour: 6, minute: 45 } ); this.d[4] = Date.today().set( { month: 6, day: 1 } ); this.d[5] = Date.today().set( { month: 6, day: 15 } ); this.d[6] = Date.today().set( { month: 6, day: 1, year: 2004 } ); this.d[7] = this.d[0].clone().setTimezoneOffset( 0 ); this.d[8] = this.d[1].clone().setTimezoneOffset( '-0400' ); }, '1997 : "YYYY"': { run: function() { }, assert: function() { return Date.today().set({year: 1997, day: 1, month: 0}).equals( Date.parse('1997') ) } }, '1997-07 : "YYYY-MM"': { run: function() { }, assert: function() { return Date.july().set({year: 1997}).equals( Date.parse('1997-07') ) } }, '1997-07-16 : "YYYY-MM-DD"': { run: function() { }, assert: function() { return Date.july().set({year: 1997, day: 16}).equals( Date.parse('1997-07-16') ) } }, '1997-07-16T19:20 : "YYYY-MM-DDThh:mm"': { run: function() { }, assert: function() { return new Date(1997,6,16,19,20,0).equals( Date.parse('1997-07-16T19:20') ) } }, '1997-07-16T19:20 : "YYYY-MM-DDThh:mm" : .parseExact': { run: function() { }, assert: function() { return new Date(1997,6,16,19,20,0).equals( Date.parseExact('1997-07-16T19:20',"yyyy-MM-ddTHH:mm") ) } }, '1997-07-16T19:20:15 : "YYYY-MM-DDThh:mm:ss"': { run: function() { }, assert: function() { return new Date(1997,6,16,19,20,15).equals( Date.parse('1997-07-16T19:20:15') ) } }, '1997-07-16T19:20:15 : "YYYY-MM-DDThh:mm:ss" : .parseExact': { run: function() { }, assert: function() { return new Date(1997,6,16,19,20,15).equals( Date.parseExact('1997-07-16T19:20:15', "yyyy-MM-ddTHH:mm:ss") ) } }, '1997-07-16T19:20+01:00 : "YYYY-MM-DDThh:mmTZD"': { run: function() { }, assert: function() { return new Date(1997,6,16,19,20,0).setTimezoneOffset('+0100').equals( Date.parse('1997-07-16T19:20+01:00') ) } }, '1997-07-16T19:20+01:00 : "YYYY-MM-DDThh:mmTZD" : parseExact': { run: function() { }, assert: function() { return new Date(1997,6,16,19,20,0).setTimezoneOffset('+0100').equals( Date.parseExact('1997-07-16T19:20+01:00', "yyyy-MM-ddTHH:mmz") ) } }, '1997-07-16T19:20:30+01:00 : "YYYY-MM-DDThh:mm:ssTZD"': { run: function() { }, assert: function() { return new Date(1997,6,16,19,20,30).setTimezoneOffset('+0100').equals( Date.parse('1997-07-16T19:20:30+01:00') ) } }, '1997-07-16T19:20:30+01:00 : "YYYY-MM-DDThh:mm:ssTZD" : parseExact': { run: function() { }, assert: function() { return new Date(1997,6,16,19,20,30).setTimezoneOffset('+0100').equals( Date.parseExact('1997-07-16T19:20:30+01:00', "yyyy-MM-ddTHH:mm:ssz") ) } }, '1997-07-16T19:20:30.045+01:00 : "YYYY-MM-DDThh:mm:ss.sTZD"': { run: function() { }, assert: function() { return new Date(1997,6,16,19,20,30,45).setTimezoneOffset('+0100').equals( Date.parse('1997-07-16T19:20:30.045+01:00') ) } } }, 'RFC 3339 Formats': { setup: function() { this.d = []; this.d[0] = new Date(2004,6,1,22,30,0,0); this.d[1] = new Date(2004,6,15,6,45,0,0); this.d[2] = Date.today().set( { hour: 22, minute: 30 } ); this.d[3] = Date.today().set( { hour: 6, minute: 45 } ); this.d[4] = Date.today().set( { month: 6, day: 1 } ); this.d[5] = Date.today().set( { month: 6, day: 15 } ); this.d[6] = Date.today().set( { month: 6, day: 1, year: 2004 } ); this.d[7] = this.d[0].clone().setTimezoneOffset( 0 ); this.d[8] = this.d[1].clone().setTimezoneOffset( '-0400' ); }, '1985-04-12T23:20:50': { run: function() { }, assert: function() { return new Date(1985,3,12,23,20,50).equals( Date.parse('1985-04-12T23:20:50') ) } }, '1985-04-12T23:20:50Z': { run: function() { }, assert: function() { return new Date(1985,3,12,23,20,50).setTimezoneOffset('+0000').equals( Date.parse('1985-04-12T23:20:50Z') ) } }, 'Much faster with Date.parseExact("1985-04-12T23:20:50Z", "yyyy-MM-ddTHH:mm:ssZ")': { run: function() { }, assert: function() { return new Date(1985,3,12,23,20,50).equals( Date.parseExact('1985-04-12T23:20:50Z', "yyyy-MM-ddTHH:mm:ssZ") ) } } } }); $(document).ready( function() { Date.Specification.validate().show() }); ================================================ FILE: tests/dst/index.html ================================================ Datejs Test Cases : Daylight Saving Time

Daylight Saving Time

================================================ FILE: tests/dst/index.js ================================================ Date.Specification = new Specification({ 'Daylight Saving Time': { setup: function() { }, '3/11/2007 1:59:59 + 1 second = 3/11/2007 3:00:00': { run: function() { }, assert: function() { return new Date(2007,2,11,1,59,59).addSeconds(1).equals(new Date(2007,2,11,3,0,0)); } }, '11/4/2007 1:59:59 + 1 second = 11/4/2007 1:00:00': { run: function() { }, assert: function() { return new Date(2007,10,4,1,59,59).addSeconds(1).equals(new Date(2007,10,4,1,0,0)); } } } }); $(document).ready( function() { Date.Specification.validate().show() } ); ================================================ FILE: tests/index.html ================================================ Datejs Test Cases

Datejs Test Cases

  1. Date
  2. Time
  3. Date and Time
  4. Partial
  5. Relative
  6. Relative Date and Time
  7. Date Math
  8. ParseExact
  9. Core Library
  10. Sugarpak
  11. .toString Function
  12. Daylight Saving Time
  13. CulturalInfo (es-MX)

Compare to other libraries

  1. RememberTheMilk.com
  2. Ruby Chronic
================================================ FILE: tests/jQuery/datepicker.css ================================================ /* Main Style Sheet for jQuery UI date picker */ #datepicker_div, .datepicker_inline { font-family: Arial, Helvetica, sans-serif; font-size: 14px; padding: 0; margin: 0; background: #ddd; width: 185px; } #datepicker_div { display: none; border: 1px solid #777; z-index: 10; /*must have*/ } .datepicker_inline { float: left; display: block; border: 0; } .datepicker_dialog { padding: 5px !important; border: 4px ridge #ddd !important; } button.datepicker_trigger { width: 25px; } img.datepicker_trigger { margin: 2px; vertical-align: middle; } .datepicker_prompt { float: left; padding: 2px; background: #ddd; color: #000; } * html .datepicker_prompt { width: 185px; } .datepicker_control, .datepicker_links, .datepicker_header, .datepicker { clear: both; float: left; width: 100%; color: #fff; } .datepicker_control { background: #400; padding: 2px 0px; } .datepicker_links { background: #000; padding: 2px 0px; } .datepicker_control, .datepicker_links { font-weight: bold; font-size: 80%; letter-spacing: 1px; } .datepicker_links label { /* disabled links */ padding: 2px 5px; color: #888; } .datepicker_clear, .datepicker_prev { float: left; width: 34%; } .datepicker_current { float: left; width: 30%; text-align: center; } .datepicker_close, .datepicker_next { float: right; width: 34%; text-align: right; } .datepicker_header { padding: 1px 0 3px; background: #333; text-align: center; font-weight: bold; height: 1.3em; } .datepicker_header select { background: #333; color: #fff; border: 0px; font-weight: bold; } .datepicker { background: #ccc; text-align: center; font-size: 100%; } .datepicker a { display: block; width: 100%; } .datepicker_titleRow { background: #777; } .datepicker_daysRow { background: #eee; color: #666; } .datepicker_weekCol { background: #777; color: #fff; } .datepicker_daysCell { color: #000; border: 1px solid #ddd; } .datepicker_daysCell a{ display: block; } .datepicker_weekEndCell { background: #ddd; } .datepicker_daysCellOver { background: #fff; border: 1px solid #777; } .datepicker_unselectable { color: #888; } .datepicker_today { background: #fcc !important; } .datepicker_currentDay { background: #999 !important; } .datepicker_status { background: #ddd; width: 100%; font-size: 80%; text-align: center; } /* ________ Datepicker Links _______ ** Reset link properties and then override them with !important */ #datepicker_div a, .datepicker_inline a { cursor: pointer; margin: 0; padding: 0; background: none; color: #000; } .datepicker_inline .datepicker_links a { padding: 0 5px !important; } .datepicker_control a, .datepicker_links a { padding: 2px 5px !important; color: #eee !important; } .datepicker_titleRow a { color: #eee !important; } .datepicker_control a:hover { background: #fdd !important; color: #333 !important; } .datepicker_links a:hover, .datepicker_titleRow a:hover { background: #ddd !important; color: #333 !important; } /* ___________ MULTIPLE MONTHS _________*/ .datepicker_multi .datepicker { border: 1px solid #777; } .datepicker_oneMonth { float: left; width: 185px; } .datepicker_newRow { clear: left; } /* ___________ IE6 IFRAME FIX ________ */ .datepicker_cover { display: none; /*sorry for IE5*/ display/**/: block; /*sorry for IE5*/ position: absolute; /*must have*/ z-index: -1; /*must have*/ filter: mask(); /*must have*/ top: -4px; /*must have*/ left: -4px; /*must have*/ width: 200px; /*must have*/ height: 200px; /*must have*/ } ================================================ FILE: tests/jQuery/datepicker.html ================================================  jQuery Datepicker Core Demo

UI Datepicker Core Components

================================================ FILE: tests/jQuery/datepicker.js ================================================ /* jQuery UI Date Picker v3.2 - previously jQuery Calendar Written by Marc Grabanski (m@marcgrabanski.com) and Keith Wood (kbwood@iprimus.com.au). Copyright (c) 2007 Marc Grabanski (http://marcgrabanski.com/code/ui-datepicker) Dual licensed under the MIT (MIT-LICENSE.txt) and GPL (GPL-LICENSE.txt) licenses. Date: 09-03-2007 */ /* Date picker manager. Use the singleton instance of this class, $.datepicker, to interact with the date picker. Settings for (groups of) date pickers are maintained in an instance object (DatepickerInstance), allowing multiple different settings on the same page. */ (function($) { // hide the namespace function Datepicker() { this.debug = false; // Change this to true to start debugging this._nextId = 0; // Next ID for a date picker instance this._inst = []; // List of instances indexed by ID this._curInst = null; // The current instance in use this._disabledInputs = []; // List of date picker inputs that have been disabled this._datepickerShowing = false; // True if the popup picker is showing , false if not this._inDialog = false; // True if showing within a "dialog", false if not this.regional = []; // Available regional settings, indexed by language code this.regional[''] = { // Default regional settings clearText: 'Clear', // Display text for clear link clearStatus: 'Erase the current date', // Status text for clear link closeText: 'Close', // Display text for close link closeStatus: 'Close without change', // Status text for close link prevText: '<Prev', // Display text for previous month link prevStatus: 'Show the previous month', // Status text for previous month link nextText: 'Next>', // Display text for next month link nextStatus: 'Show the next month', // Status text for next month link currentText: 'Today', // Display text for current month link currentStatus: 'Show the current month', // Status text for current month link monthNames: ['January','February','March','April','May','June', 'July','August','September','October','November','December'], // Names of months for drop-down and formatting monthNamesShort: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'], // For formatting monthStatus: 'Show a different month', // Status text for selecting a month yearStatus: 'Show a different year', // Status text for selecting a year weekHeader: 'Wk', // Header for the week of the year column weekStatus: 'Week of the year', // Status text for the week of the year column dayNames: ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'], // For formatting dayNamesShort: ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'], // For formatting dayNamesMin: ['Su','Mo','Tu','We','Th','Fr','Sa'], // Column headings for days starting at Sunday dayStatus: 'Set DD as first week day', // Status text for the day of the week selection dateStatus: 'Select D, M d', // Status text for the date selection dateFormat: 'mm/dd/yy', // See format options on parseDate firstDay: 0, // The first day of the week, Sun = 0, Mon = 1, ... initStatus: 'Select a date', // Initial Status text on opening isRTL: false // True if right-to-left language, false if left-to-right }; this._defaults = { // Global defaults for all the date picker instances showOn: 'focus', // 'focus' for popup on focus, // 'button' for trigger button, or 'both' for either defaultDate: null, // Used when field is blank: actual date, // +/-number for offset from today, null for today appendText: '', // Display text following the input box, e.g. showing the format buttonText: '...', // Text for trigger button buttonImage: '', // URL for trigger button image buttonImageOnly: false, // True if the image appears alone, false if it appears on a button closeAtTop: true, // True to have the clear/close at the top, // false to have them at the bottom hideIfNoPrevNext: false, // True to hide next/previous month links // if not applicable, false to just disable them changeMonth: true, // True if month can be selected directly, false if only prev/next changeYear: true, // True if year can be selected directly, false if only prev/next yearRange: '-10:+10', // Range of years to display in drop-down, // either relative to current year (-nn:+nn) or absolute (nnnn:nnnn) changeFirstDay: true, // True to click on day name to change, false to remain as set showOtherMonths: false, // True to show dates in other months, false to leave blank showWeeks: false, // True to show week of the year, false to omit calculateWeek: this.iso8601Week, // How to calculate the week of the year, // takes a Date and returns the number of the week for it shortYearCutoff: '+10', // Short year values < this are in the current century, // > this are in the previous century, // string value starting with '+' for current year + value showStatus: false, // True to show status bar at bottom, false to not show it statusForDate: this.dateStatus, // Function to provide status text for a date - // takes date and instance as parameters, returns display text minDate: null, // The earliest selectable date, or null for no limit maxDate: null, // The latest selectable date, or null for no limit speed: 'medium', // Speed of display/closure beforeShowDay: null, // Function that takes a date and returns an array with // [0] = true if selectable, false if not, // [1] = custom CSS class name(s) or '', e.g. $.datepicker.noWeekends beforeShow: null, // Function that takes an input field and // returns a set of custom settings for the date picker onSelect: null, // Define a callback function when a date is selected numberOfMonths: 1, // Number of months to show at a time stepMonths: 1, // Number of months to step back/forward rangeSelect: false, // Allows for selecting a date range on one date picker rangeSeparator: ' - ' // Text between two dates in a range }; $.extend(this._defaults, this.regional['']); this._datepickerDiv = $('
'); } $.extend(Datepicker.prototype, { /* Class name added to elements to indicate already configured with a date picker. */ markerClassName: 'hasDatepicker', /* Debug logging (if enabled). */ log: function () { if (this.debug) { console.log.apply('', arguments); } }, /* Register a new date picker instance - with custom settings. */ _register: function(inst) { var id = this._nextId++; this._inst[id] = inst; return id; }, /* Retrieve a particular date picker instance based on its ID. */ _getInst: function(id) { return this._inst[id] || id; }, /* Override the default settings for all instances of the date picker. @param settings object - the new settings to use as defaults (anonymous object) @return the manager object */ setDefaults: function(settings) { extendRemove(this._defaults, settings || {}); return this; }, /* Handle keystrokes. */ _doKeyDown: function(e) { var inst = $.datepicker._getInst(this._calId); if ($.datepicker._datepickerShowing) { switch (e.keyCode) { case 9: $.datepicker.hideDatepicker(''); break; // hide on tab out case 13: $.datepicker._selectDay(inst, inst._selectedMonth, inst._selectedYear, $('td.datepicker_daysCellOver', inst._datepickerDiv)[0]); break; // select the value on enter case 27: $.datepicker.hideDatepicker(inst._get('speed')); break; // hide on escape case 33: $.datepicker._adjustDate(inst, (e.ctrlKey ? -1 : -inst._get('stepMonths')), (e.ctrlKey ? 'Y' : 'M')); break; // previous month/year on page up/+ ctrl case 34: $.datepicker._adjustDate(inst, (e.ctrlKey ? +1 : +inst._get('stepMonths')), (e.ctrlKey ? 'Y' : 'M')); break; // next month/year on page down/+ ctrl case 35: if (e.ctrlKey) $.datepicker._clearDate(inst); break; // clear on ctrl+end case 36: if (e.ctrlKey) $.datepicker._gotoToday(inst); break; // current on ctrl+home case 37: if (e.ctrlKey) $.datepicker._adjustDate(inst, -1, 'D'); break; // -1 day on ctrl+left case 38: if (e.ctrlKey) $.datepicker._adjustDate(inst, -7, 'D'); break; // -1 week on ctrl+up case 39: if (e.ctrlKey) $.datepicker._adjustDate(inst, +1, 'D'); break; // +1 day on ctrl+right case 40: if (e.ctrlKey) $.datepicker._adjustDate(inst, +7, 'D'); break; // +1 week on ctrl+down } } else if (e.keyCode == 36 && e.ctrlKey) { // display the date picker on ctrl+home $.datepicker.showFor(this); } }, /* Filter entered characters - based on date format. */ _doKeyPress: function(e) { var inst = $.datepicker._getInst(this._calId); var chars = $.datepicker._possibleChars(inst._get('dateFormat')); var chr = String.fromCharCode(e.charCode == undefined ? e.keyCode : e.charCode); return (chr < ' ' || !chars || chars.indexOf(chr) > -1); }, /* Attach the date picker to an input field. */ _connectDatepicker: function(target, inst) { var input = $(target); if (this._hasClass(input, this.markerClassName)) { return; } var appendText = inst._get('appendText'); var isRTL = inst._get('isRTL'); if (appendText) { if (isRTL) { input.before('' + appendText + ''); } else { input.after('' + appendText + ''); } } var showOn = inst._get('showOn'); if (showOn == 'focus' || showOn == 'both') { // pop-up date picker when in the marked field input.focus(this.showFor); } if (showOn == 'button' || showOn == 'both') { // pop-up date picker when button clicked var buttonText = inst._get('buttonText'); var buttonImage = inst._get('buttonImage'); var buttonImageOnly = inst._get('buttonImageOnly'); var trigger = $(buttonImageOnly ? '' + buttonText + '' : ''); input.wrap(''); if (isRTL) { input.before(trigger); } else { input.after(trigger); } trigger.click(this.showFor); } input.addClass(this.markerClassName).keydown(this._doKeyDown).keypress(this._doKeyPress); input[0]._calId = inst._id; }, /* Attach an inline date picker to a div. */ _inlineDatepicker: function(target, inst) { var input = $(target); if (this._hasClass(input, this.markerClassName)) { return; } input.addClass(this.markerClassName).append(inst._datepickerDiv); input[0]._calId = inst._id; this._updateDatepicker(inst); inst._datepickerDiv.resize(function() { $.datepicker._inlineShow(inst); }); }, /* Tidy up after displaying the date picker. */ _inlineShow: function(inst) { var numMonths = inst._get('numberOfMonths'); // fix width for dynamic number of date pickers numMonths = (numMonths == null ? 1 : (typeof numMonths == 'number' ? numMonths : numMonths[1])); inst._datepickerDiv.width(numMonths * $('.datepicker', inst._datepickerDiv[0]).width()); }, /* Does this element have a particular class? */ _hasClass: function(element, className) { var classes = element.attr('class'); return (classes && classes.indexOf(className) > -1); }, /* Pop-up the date picker in a "dialog" box. @param dateText string - the initial date to display (in the current format) @param onSelect function - the function(dateText) to call when a date is selected @param settings object - update the dialog date picker instance's settings (anonymous object) @param pos int[2] - coordinates for the dialog's position within the screen or event - with x/y coordinates or leave empty for default (screen centre) @return the manager object */ dialogDatepicker: function(dateText, onSelect, settings, pos) { var inst = this._dialogInst; // internal instance if (!inst) { inst = this._dialogInst = new DatepickerInstance({}, false); this._dialogInput = $(''); this._dialogInput.keydown(this._doKeyDown); $('body').append(this._dialogInput); this._dialogInput[0]._calId = inst._id; } extendRemove(inst._settings, settings || {}); this._dialogInput.val(dateText); this._pos = (pos ? (pos.length ? pos : [pos.pageX, pos.pageY]) : null); if (!this._pos) { var browserWidth = window.innerWidth || document.documentElement.clientWidth || document.body.clientWidth; var browserHeight = window.innerHeight || document.documentElement.clientHeight || document.body.clientHeight; var scrollX = document.documentElement.scrollLeft || document.body.scrollLeft; var scrollY = document.documentElement.scrollTop || document.body.scrollTop; this._pos = // should use actual width/height below [(browserWidth / 2) - 100 + scrollX, (browserHeight / 2) - 150 + scrollY]; } // move input on screen for focus, but hidden behind dialog this._dialogInput.css('left', this._pos[0] + 'px').css('top', this._pos[1] + 'px'); inst._settings.onSelect = onSelect; this._inDialog = true; this._datepickerDiv.addClass('datepicker_dialog'); this.showFor(this._dialogInput[0]); if ($.blockUI) { $.blockUI(this._datepickerDiv); } return this; }, /* Enable the input field(s) for entry. @param inputs element - single input field or string - the ID or other jQuery selector of the input field(s) or object - jQuery collection of input fields @return the manager object */ enableFor: function(inputs) { inputs = (inputs.jquery ? inputs : $(inputs)); inputs.each(function() { this.disabled = false; $(this).siblings('button.datepicker_trigger').each(function() { this.disabled = false; }); $(this).siblings('img.datepicker_trigger').css({opacity: '1.0', cursor: ''}); var $this = this; $.datepicker._disabledInputs = $.map($.datepicker._disabledInputs, function(value) { return (value == $this ? null : value); }); // delete entry }); return this; }, /* Disable the input field(s) from entry. @param inputs element - single input field or string - the ID or other jQuery selector of the input field(s) or object - jQuery collection of input fields @return the manager object */ disableFor: function(inputs) { inputs = (inputs.jquery ? inputs : $(inputs)); inputs.each(function() { this.disabled = true; $(this).siblings('button.datepicker_trigger').each(function() { this.disabled = true; }); $(this).siblings('img.datepicker_trigger').css({opacity: '0.5', cursor: 'default'}); var $this = this; $.datepicker._disabledInputs = $.map($.datepicker._disabledInputs, function(value) { return (value == $this ? null : value); }); // delete entry $.datepicker._disabledInputs[$.datepicker._disabledInputs.length] = this; }); return this; }, /* Is the input field disabled? @param input element - single input field or string - the ID or other jQuery selector of the input field or object - jQuery collection of input field @return boolean - true if disabled, false if enabled */ isDisabled: function(input) { input = (input.jquery ? input[0] : (typeof input == 'string' ? $(input)[0] : input)); for (var i = 0; i < $.datepicker._disabledInputs.length; i++) { if ($.datepicker._disabledInputs[i] == input) { return true; } } return false; }, /* Update the settings for a date picker attached to an input field or division. @param control element - the input field or div/span attached to the date picker or string - the ID or other jQuery selector of the input field or object - jQuery object for input field or div/span @param settings object - the new settings to update @return the manager object */ reconfigureFor: function(control, settings) { control = (control.jquery ? control[0] : (typeof control == 'string' ? $(control)[0] : control)); var inst = this._getInst(control._calId); if (inst) { extendRemove(inst._settings, settings || {}); this._updateDatepicker(inst); } return this; }, /* Set the date for a date picker attached to an input field or division. @param control element - the input field or div/span attached to the date picker or string - the ID or other jQuery selector of the input field or object - jQuery object for input field or div/span @param date Date - the new date @param endDate Date - the new end date for a range (optional) @return the manager object */ setDateFor: function(control, date, endDate) { control = (control.jquery ? control[0] : (typeof control == 'string' ? $(control)[0] : control)); var inst = this._getInst(control._calId); if (inst) { inst._setDate(date, endDate); this._updateDatepicker(inst); } return this; }, /* Retrieve the date for a date picker attached to an input field or division. @param control element - the input field or div/span attached to the date picker or string - the ID or other jQuery selector of the input field or object - jQuery object for input field or div/span @return Date - the current date or Date[2] - the current dates for a range*/ getDateFor: function(control) { control = (control.jquery ? control[0] : (typeof control == 'string' ? $(control)[0] : control)); var inst = this._getInst(control._calId); return (inst ? inst._getDate() : null); }, /* Pop-up the date picker for a given input field. @param control element - the input field attached to the date picker or string - the ID or other jQuery selector of the input field or object - jQuery object for input field @return the manager object */ showFor: function(control) { control = (control.jquery ? control[0] : (typeof control == 'string' ? $(control)[0] : control)); var input = (control.nodeName && control.nodeName.toLowerCase() == 'input' ? control : this); if (input.nodeName.toLowerCase() != 'input') { // find from button/image trigger input = $('input', input.parentNode)[0]; } if ($.datepicker._lastInput == input) { // already here return; } if ($.datepicker.isDisabled(input)) { return; } var inst = $.datepicker._getInst(input._calId); var beforeShow = inst._get('beforeShow'); extendRemove(inst._settings, (beforeShow ? beforeShow(input) : {})); $.datepicker.hideDatepicker(''); $.datepicker._lastInput = input; inst._setDateFromField(input); if ($.datepicker._inDialog) { // hide cursor input.value = ''; } if (!$.datepicker._pos) { // position below input $.datepicker._pos = $.datepicker._findPos(input); $.datepicker._pos[1] += input.offsetHeight; // add the height } var isFixed = false; $(input).parents().each(function() { isFixed |= $(this).css('position') == 'fixed'; }); if (isFixed && $.browser.opera) { // correction for Opera when fixed and scrolled $.datepicker._pos[0] -= document.documentElement.scrollLeft; $.datepicker._pos[1] -= document.documentElement.scrollTop; } inst._datepickerDiv.css('position', ($.datepicker._inDialog && $.blockUI ? 'static' : (isFixed ? 'fixed' : 'absolute'))). css('left', $.datepicker._pos[0] + 'px').css('top', $.datepicker._pos[1] + 'px'); $.datepicker._pos = null; $.datepicker._showDatepicker(inst); return this; }, /* Construct and display the date picker. */ _showDatepicker: function(id) { var inst = this._getInst(id); inst._rangeStart = null; this._updateDatepicker(inst); if (!inst._inline) { var speed = inst._get('speed'); var postProcess = function() { $.datepicker._datepickerShowing = true; $.datepicker._afterShow(inst); }; inst._datepickerDiv.show(speed, postProcess); if (speed == '') { postProcess(); } if (inst._input[0].type != 'hidden') { inst._input[0].focus(); } this._curInst = inst; } }, /* Generate the date picker content. */ _updateDatepicker: function(inst) { inst._datepickerDiv.empty().append(inst._generateDatepicker()); if (inst._get('numberOfMonths') != 1) { inst._datepickerDiv.addClass('datepicker_multi'); } else { inst._datepickerDiv.removeClass('datepicker_multi'); } if (inst._input && inst._input[0].type != 'hidden') { inst._input[0].focus(); } }, /* Tidy up after displaying the date picker. */ _afterShow: function(inst) { var numMonths = inst._get('numberOfMonths'); // fix width for dynamic number of date pickers numMonths = (numMonths == null ? 1 : (typeof numMonths == 'number' ? numMonths : numMonths[1])); inst._datepickerDiv.width(numMonths * $('.datepicker', inst._datepickerDiv[0]).width()); if ($.browser.msie) { // fix IE < 7 select problems $('#datepicker_cover').css({width: inst._datepickerDiv.width() + 4, height: inst._datepickerDiv.height() + 4}); } // re-position on screen if necessary var isFixed = inst._datepickerDiv.css('position') == 'fixed'; var pos = $.datepicker._findPos(inst._input[0]); var browserWidth = window.innerWidth || document.documentElement.clientWidth || document.body.clientWidth; var browserHeight = window.innerHeight || document.documentElement.clientHeight || document.body.clientHeight; var scrollX = (isFixed ? 0 : document.documentElement.scrollLeft || document.body.scrollLeft); var scrollY = (isFixed ? 0 : document.documentElement.scrollTop || document.body.scrollTop); // reposition date picker horizontally if outside the browser window if ((inst._datepickerDiv.offset().left + inst._datepickerDiv.width() - (isFixed && $.browser.msie ? document.documentElement.scrollLeft : 0)) > (browserWidth + scrollX)) { inst._datepickerDiv.css('left', Math.max(scrollX, pos[0] + $(inst._input[0]).width() - inst._datepickerDiv.width() - (isFixed && $.browser.opera ? document.documentElement.scrollLeft : 0)) + 'px'); } // reposition date picker vertically if outside the browser window if ((inst._datepickerDiv.offset().top + inst._datepickerDiv.height() - (isFixed && $.browser.msie ? document.documentElement.scrollTop : 0)) > (browserHeight + scrollY) ) { inst._datepickerDiv.css('top', Math.max(scrollY, pos[1] - (this._inDialog ? 0 : inst._datepickerDiv.height()) - (isFixed && $.browser.opera ? document.documentElement.scrollTop : 0)) + 'px'); } }, /* Find an object's position on the screen. */ _findPos: function(obj) { while (obj && (obj.type == 'hidden' || obj.nodeType != 1)) { obj = obj.nextSibling; } var curleft = curtop = 0; if (obj && obj.offsetParent) { curleft = obj.offsetLeft; curtop = obj.offsetTop; while (obj = obj.offsetParent) { var origcurleft = curleft; curleft += obj.offsetLeft; if (curleft < 0) { curleft = origcurleft; } curtop += obj.offsetTop; } } return [curleft,curtop]; }, /* Hide the date picker from view. @param speed string - the speed at which to close the date picker @return void */ hideDatepicker: function(speed) { var inst = this._curInst; if (!inst) { return; } var rangeSelect = inst._get('rangeSelect'); if (rangeSelect && this._stayOpen) { this._selectDate(inst, inst._formatDate( inst._currentDay, inst._currentMonth, inst._currentYear)); } this._stayOpen = false; if (this._datepickerShowing) { speed = (speed != null ? speed : inst._get('speed')); inst._datepickerDiv.hide(speed, function() { $.datepicker._tidyDialog(inst); }); if (speed == '') { this._tidyDialog(inst); } this._datepickerShowing = false; this._lastInput = null; inst._settings.prompt = null; if (this._inDialog) { this._dialogInput.css('position', 'absolute'). css('left', '0px').css('top', '-100px'); if ($.blockUI) { $.unblockUI(); $('body').append(this._datepickerDiv); } } this._inDialog = false; } this._curInst = null; }, /* Tidy up after a dialog display. */ _tidyDialog: function(inst) { inst._datepickerDiv.removeClass('datepicker_dialog'); $('.datepicker_prompt', inst._datepickerDiv).remove(); }, /* Close date picker if clicked elsewhere. */ _checkExternalClick: function(event) { if (!$.datepicker._curInst) { return; } var target = $(event.target); if ((target.parents("#datepicker_div").length == 0) && (target.attr('class') != 'datepicker_trigger') && $.datepicker._datepickerShowing && !($.datepicker._inDialog && $.blockUI)) { $.datepicker.hideDatepicker(''); } }, /* Adjust one of the date sub-fields. */ _adjustDate: function(id, offset, period) { var inst = this._getInst(id); inst._adjustDate(offset, period); this._updateDatepicker(inst); }, /* Action for current link. */ _gotoToday: function(id) { var date = new Date(); var inst = this._getInst(id); inst._selectedDay = date.getDate(); inst._selectedMonth = date.getMonth(); inst._selectedYear = date.getFullYear(); this._adjustDate(inst); }, /* Action for selecting a new month/year. */ _selectMonthYear: function(id, select, period) { var inst = this._getInst(id); inst._selectingMonthYear = false; inst[period == 'M' ? '_selectedMonth' : '_selectedYear'] = select.options[select.selectedIndex].value - 0; this._adjustDate(inst); }, /* Restore input focus after not changing month/year. */ _clickMonthYear: function(id) { var inst = this._getInst(id); if (inst._input && inst._selectingMonthYear && !$.browser.msie) { inst._input[0].focus(); } inst._selectingMonthYear = !inst._selectingMonthYear; }, /* Action for changing the first week day. */ _changeFirstDay: function(id, a) { var inst = this._getInst(id); var dayNamesMin = inst._get('dayNamesMin'); var value = a.firstChild.nodeValue; for (var i = 0; i < 7; i++) { if (dayNamesMin[i] == value) { inst._settings.firstDay = i; break; } } this._updateDatepicker(inst); }, /* Action for selecting a day. */ _selectDay: function(id, month, year, td) { if (this._hasClass($(td), 'datepicker_unselectable')) { return; } var inst = this._getInst(id); var rangeSelect = inst._get('rangeSelect'); if (rangeSelect) { if (!this._stayOpen) { $('.datepicker td').removeClass('datepicker_currentDay'); $(td).addClass('datepicker_currentDay'); } this._stayOpen = !this._stayOpen; } inst._currentDay = $('a', td).html(); inst._currentMonth = month; inst._currentYear = year; this._selectDate(id, inst._formatDate( inst._currentDay, inst._currentMonth, inst._currentYear)); if (this._stayOpen) { inst._endDay = inst._endMonth = inst._endYear = null; inst._rangeStart = new Date(inst._currentYear, inst._currentMonth, inst._currentDay); this._updateDatepicker(inst); } else if (rangeSelect) { if (inst._inline) { inst._endDay = inst._currentDay; inst._endMonth = inst._currentMonth; inst._endYear = inst._currentYear; inst._selectedDay = inst._currentDay = inst._rangeStart.getDate(); inst._selectedMonth = inst._currentMonth = inst._rangeStart.getMonth(); inst._selectedYear = inst._currentYear = inst._rangeStart.getFullYear(); inst._rangeStart = null; this._updateDatepicker(inst); } else { inst._rangeStart = null; } } }, /* Erase the input field and hide the date picker. */ _clearDate: function(id) { var inst = this._getInst(id); this._stayOpen = false; inst._rangeStart = null; this._selectDate(inst, ''); }, /* Update the input field with the selected date. */ _selectDate: function(id, dateStr) { var inst = this._getInst(id); dateStr = (dateStr != null ? dateStr : inst._formatDate()); if (inst._rangeStart) { dateStr = inst._formatDate(inst._rangeStart) + inst._get('rangeSeparator') + dateStr; } if (inst._input) { inst._input.val(dateStr); } var onSelect = inst._get('onSelect'); if (onSelect) { onSelect(dateStr, inst); // trigger custom callback } else { inst._input.trigger('change'); // fire the change event } if (inst._inline) { this._updateDatepicker(inst); } else { if (!this._stayOpen) { this.hideDatepicker(inst._get('speed')); } } }, /* Set as beforeShowDay function to prevent selection of weekends. @param date Date - the date to customise @return [boolean, string] - is this date selectable?, what is its CSS class? */ noWeekends: function(date) { var day = date.getDay(); return [(day > 0 && day < 6), '']; }, /* Set as calculateWeek to determine the week of the year based on the ISO 8601 definition. @param date Date - the date to get the week for @return number - the number of the week within the year that contains this date */ iso8601Week: function(date) { var checkDate = new Date(date.getFullYear(), date.getMonth(), date.getDate()); var firstMon = new Date(checkDate.getFullYear(), 1 - 1, 4); // First week always contains 4 Jan var firstDay = firstMon.getDay() || 7; // Day of week: Mon = 1, ..., Sun = 7 firstMon.setDate(firstMon.getDate() + 1 - firstDay); // Preceding Monday if (firstDay < 4 && checkDate < firstMon) { // Adjust first three days in year if necessary checkDate.setDate(checkDate.getDate() - 3); // Generate for previous year return $.datepicker.iso8601Week(checkDate); } else if (checkDate > new Date(checkDate.getFullYear(), 12 - 1, 28)) { // Check last three days in year firstDay = new Date(checkDate.getFullYear() + 1, 1 - 1, 4).getDay() || 7; if (firstDay > 4 && (checkDate.getDay() || 7) < firstDay - 3) { // Adjust if necessary checkDate.setDate(checkDate.getDate() + 3); // Generate for next year return $.datepicker.iso8601Week(checkDate); } } return Math.floor(((checkDate - firstMon) / 86400000) / 7) + 1; // Weeks to given date }, /* Provide status text for a particular date. @param date the date to get the status for @param inst the current datepicker instance @return the status display text for this date */ dateStatus: function(date, inst) { return $.datepicker.formatDate(inst._get('dateStatus'), date); }, /* Parse a string value into a date object. The format can be combinations of the following: d - day of month (no leading zero) dd - day of month (two digit) D - day name short DD - day name long m - month of year (no leading zero) mm - month of year (two digit) M - month name short MM - month name long y - year (two digit) yy - year (four digit) '...' - literal text '' - single quote @param format String - the expected format of the date @param value String - the date in the above format @param shortYearCutoff Number - the cutoff year for determining the century (optional) @param dayNamesShort String[7] - abbreviated names of the days from Sunday (optional) @param dayNames String[7] - names of the days from Sunday (optional) @param monthNamesShort String[12] - abbreviated names of the months (optional) @param monthNames String[12] - names of the months (optional) @return Date - the extracted date value or null if value is blank */ parseDate: function (format, value, shortYearCutoff, dayNamesShort, dayNames, monthNamesShort, monthNames) { if (format == null || value == null) { throw 'Invalid arguments'; } // format = dateFormats[format] || format; value = (typeof value == 'object' ? value.toString() : value + ''); if (value == '') { return null; } dayNamesShort = dayNamesShort || this._defaults.dayNamesShort; dayNames = dayNames || this._defaults.dayNames; monthNamesShort = monthNamesShort || this._defaults.monthNamesShort; monthNames = monthNames || this._defaults.monthNames; var year = -1; var month = -1; var day = -1; var literal = false; // Check whether a format character is doubled var lookAhead = function(match) { var matches = (iFormat + 1 < format.length && format.charAt(iFormat + 1) == match); if (matches) { iFormat++; } return matches; }; // Extract a number from the string value var getNumber = function(match) { lookAhead(match); var size = (match == 'y' ? 4 : 2); var num = 0; while (size > 0 && iValue < value.length && value.charAt(iValue) >= '0' && value.charAt(iValue) <= '9') { num = num * 10 + (value.charAt(iValue++) - 0); size--; } if (size == (match == 'y' ? 4 : 2)) { throw 'Missing number at position ' + iValue; } return num; }; // Extract a name from the string value and convert to an index var getName = function(match, shortNames, longNames) { var names = (lookAhead(match) ? longNames : shortNames); var size = 0; for (var j = 0; j < names.length; j++) { size = Math.max(size, names[j].length); } var name = ''; var iInit = iValue; while (size > 0 && iValue < value.length) { name += value.charAt(iValue++); for (var i = 0; i < names.length; i++) { if (name == names[i]) { return i + 1; } } size--; } throw 'Unknown name at position ' + iInit; }; // Confirm that a literal character matches the string value var checkLiteral = function() { if (value.charAt(iValue) != format.charAt(iFormat)) { throw 'Unexpected literal at position ' + iValue; } iValue++; }; var iValue = 0; for (var iFormat = 0; iFormat < format.length; iFormat++) { if (literal) { if (format.charAt(iFormat) == '\'' && !lookAhead('\'')) { literal = false; } else { checkLiteral(); } } else { switch (format.charAt(iFormat)) { case 'd': day = getNumber('d'); break; case 'D': getName('D', dayNamesShort, dayNames); break; case 'm': month = getNumber('m'); break; case 'M': month = getName('M', monthNamesShort, monthNames); break; case 'y': year = getNumber('y'); break; case '\'': if (lookAhead('\'')) { checkLiteral(); } else { literal = true; } break; default: checkLiteral(); } } } if (year < 100) { year += new Date().getFullYear() - new Date().getFullYear() % 100 + (year <= shortYearCutoff ? 0 : -100); } var date = new Date(year, month - 1, day); if (date.getFullYear() != year || date.getMonth() + 1 != month || date.getDate() != day) { throw 'Invalid date'; // E.g. 31/02/* } return date; }, /* Format a date object into a string value. The format can be combinations of the following: d - day of month (no leading zero) dd - day of month (two digit) D - day name short DD - day name long m - month of year (no leading zero) mm - month of year (two digit) M - month name short MM - month name long y - year (two digit) yy - year (four digit) '...' - literal text '' - single quote @param format String - the desired format of the date @param date Date - the date value to format @param dayNamesShort String[7] - abbreviated names of the days from Sunday (optional) @param dayNames String[7] - names of the days from Sunday (optional) @param monthNamesShort String[12] - abbreviated names of the months (optional) @param monthNames String[12] - names of the months (optional) @return String - the date in the above format */ formatDate: function (format, date, dayNamesShort, dayNames, monthNamesShort, monthNames) { if (!date) { return ''; } // format = dateFormats[format] || format; dayNamesShort = dayNamesShort || this._defaults.dayNamesShort; dayNames = dayNames || this._defaults.dayNames; monthNamesShort = monthNamesShort || this._defaults.monthNamesShort; monthNames = monthNames || this._defaults.monthNames; // Check whether a format character is doubled var lookAhead = function(match) { var matches = (iFormat + 1 < format.length && format.charAt(iFormat + 1) == match); if (matches) { iFormat++; } return matches; }; // Format a number, with leading zero if necessary var formatNumber = function(match, value) { return (lookAhead(match) && value < 10 ? '0' : '') + value; }; // Format a name, short or long as requested var formatName = function(match, value, shortNames, longNames) { return (lookAhead(match) ? longNames[value] : shortNames[value]); }; var output = ''; var literal = false; if (date) { for (var iFormat = 0; iFormat < format.length; iFormat++) { if (literal) { if (format.charAt(iFormat) == '\'' && !lookAhead('\'')) { literal = false; } else { output += format.charAt(iFormat); } } else { switch (format.charAt(iFormat)) { case 'd': output += formatNumber('d', date.getDate()); break; case 'D': output += formatName('D', date.getDay(), dayNamesShort, dayNames); break; case 'm': output += formatNumber('m', date.getMonth() + 1); break; case 'M': output += formatName('M', date.getMonth(), monthNamesShort, monthNames); break; case 'y': output += (lookAhead('y') ? date.getFullYear() : (date.getYear() % 100 < 10 ? '0' : '') + date.getYear() % 100); break; case '\'': if (lookAhead('\'')) { output += '\''; } else { literal = true; } break; default: output += format.charAt(iFormat); } } } } return output; }, /* Extract all possible characters from the date format. */ _possibleChars: function (format) { // format = dateFormats[format] || format; var chars = ''; var literal = false; for (var iFormat = 0; iFormat < format.length; iFormat++) { if (literal) { if (format.charAt(iFormat) == '\'' && !lookAhead('\'')) { literal = false; } else { chars += format.charAt(iFormat); } } else { switch (format.charAt(iFormat)) { case 'd': case 'm': case 'y': chars += '0123456789'; break; case 'D': case 'M': return null; // Accept anything case '\'': if (lookAhead('\'')) { chars += '\''; } else { literal = true; } break; default: chars += format.charAt(iFormat); } } } return chars; } }); /* Individualised settings for date picker functionality applied to one or more related inputs. Instances are managed and manipulated through the Datepicker manager. */ function DatepickerInstance(settings, inline) { this._id = $.datepicker._register(this); this._selectedDay = 0; this._selectedMonth = 0; // 0-11 this._selectedYear = 0; // 4-digit year this._input = null; // The attached input field this._inline = inline; // True if showing inline, false if used in a popup this._datepickerDiv = (!inline ? $.datepicker._datepickerDiv : $('
')); // customise the date picker object - uses manager defaults if not overridden this._settings = extendRemove({}, settings || {}); // clone if (inline) { this._setDate(this._getDefaultDate()); } } $.extend(DatepickerInstance.prototype, { /* Get a setting value, defaulting if necessary. */ _get: function(name) { return (this._settings[name] != null ? this._settings[name] : $.datepicker._defaults[name]); }, /* Parse existing date and initialise date picker. */ _setDateFromField: function(input) { this._input = $(input); var dateFormat = this._get('dateFormat'); var dates = this._input.val().split(this._get('rangeSeparator')); this._endDay = this._endMonth = this._endYear = null; var shortYearCutoff = this._get('shortYearCutoff'); shortYearCutoff = (typeof shortYearCutoff != 'string' ? shortYearCutoff : new Date().getFullYear() % 100 + parseInt(shortYearCutoff, 10)); var date = this._getDefaultDate(); if (dates.length > 0) { var dayNamesShort = this._get('dayNamesShort'); var dayNames = this._get('dayNames'); var monthNamesShort = this._get('monthNamesShort'); var monthNames = this._get('monthNames'); if (dates.length > 1) { date = $.datepicker.parseDate(dateFormat, dates[1], shortYearCutoff, dayNamesShort, dayNames, monthNamesShort, monthNames) || this._getDefaultDate(); this._endDay = date.getDate(); this._endMonth = date.getMonth(); this._endYear = date.getFullYear(); } try { date = $.datepicker.parseDate(dateFormat, dates[0], shortYearCutoff, dayNamesShort, dayNames, monthNamesShort, monthNames) || this._getDefaultDate(); } catch (e) { $.datepicker.log(e); date = this._getDefaultDate(); } } this._selectedDay = this._currentDay = date.getDate(); this._selectedMonth = this._currentMonth = date.getMonth(); this._selectedYear = this._currentYear = date.getFullYear(); this._adjustDate(); }, /* Retrieve the default date shown on opening. */ _getDefaultDate: function() { var offsetDate = function(offset) { var date = new Date(); date.setDate(date.getDate() + offset); return date; }; var defaultDate = this._get('defaultDate'); return (defaultDate == null ? new Date() : (typeof defaultDate == 'number' ? offsetDate(defaultDate) : defaultDate)); }, /* Set the date(s) directly. */ _setDate: function(date, endDate) { this._selectedDay = this._currentDay = date.getDate(); this._selectedMonth = this._currentMonth = date.getMonth(); this._selectedYear = this._currentYear = date.getFullYear(); if (this._get('rangeSelect')) { if (endDate) { this._endDay = endDate.getDate(); this._endMonth = endDate.getMonth(); this._endYear = endDate.getFullYear(); } else { this._endDay = this._currentDay; this._endMonth = this._currentMonth; this._endYear = this._currentYear; } } this._adjustDate(); }, /* Retrieve the date(s) directly. */ _getDate: function() { var startDate = (!this._currentYear || (this._input && this._input.val() == '') ? null : new Date(this._currentYear, this._currentMonth, this._currentDay)); if (this._get('rangeSelect')) { return [startDate, new Date(this._endYear, this._endMonth, this._endDay)]; } else { return startDate; } }, /* Generate the HTML for the current state of the date picker. */ _generateDatepicker: function() { var today = new Date(); today = new Date(today.getFullYear(), today.getMonth(), today.getDate()); // clear time var showStatus = this._get('showStatus'); // build the date picker HTML var controls = ''; var prompt = this._get('prompt'); var closeAtTop = this._get('closeAtTop'); var hideIfNoPrevNext = this._get('hideIfNoPrevNext'); var numMonths = this._get('numberOfMonths'); var stepMonths = this._get('stepMonths'); var isMultiMonth = (numMonths != 1); numMonths = (numMonths == null ? [1, 1] : (typeof numMonths == 'number' ? [1, numMonths] : numMonths)); // controls and links var html = (prompt ? '
' + prompt + '
' : '') + (closeAtTop && !this._inline ? controls : '') + ''; var minDate = this._getMinDate(); var maxDate = this._get('maxDate'); var drawMonth = this._selectedMonth; var drawYear = this._selectedYear; var showWeeks = this._get('showWeeks'); for (var row = 0; row < numMonths[0]; row++) { for (var col = 0; col < numMonths[1]; col++) { var selectedDate = new Date(drawYear, drawMonth, this._selectedDay); html += '
' + this._generateMonthYearHeader(drawMonth, drawYear, minDate, maxDate, selectedDate, row > 0 || col > 0) + // draw month headers '' + '' + (showWeeks ? '' : ''); var firstDay = this._get('firstDay'); var changeFirstDay = this._get('changeFirstDay'); var dayNames = this._get('dayNames'); var dayNamesShort = this._get('dayNamesShort'); var dayNamesMin = this._get('dayNamesMin'); for (var dow = 0; dow < 7; dow++) { // days of the week var day = (dow + firstDay) % 7; html += ''; } html += ''; var daysInMonth = this._getDaysInMonth(drawYear, drawMonth); this._selectedDay = Math.min(this._selectedDay, daysInMonth); var leadDays = (this._getFirstDayOfMonth(drawYear, drawMonth) - firstDay + 7) % 7; var currentDate = new Date(this._currentYear, this._currentMonth, this._currentDay); var endDate = this._endDay ? new Date(this._endYear, this._endMonth, this._endDay) : currentDate; var printDate = new Date(drawYear, drawMonth, 1 - leadDays); var numRows = (isMultiMonth ? 6 : Math.ceil((leadDays + daysInMonth) / 7)); // calculate the number of rows to generate var beforeShowDay = this._get('beforeShowDay'); var showOtherMonths = this._get('showOtherMonths'); var calculateWeek = this._get('calculateWeek') || $.datepicker.iso8601Week; var dateStatus = this._get('statusForDate') || $.datepicker.dateStatus; for (var dRow = 0; dRow < numRows; dRow++) { // create date picker rows html += '' + (showWeeks ? '' : ''); for (var dow = 0; dow < 7; dow++) { // create date picker days var daySettings = (beforeShowDay ? beforeShowDay(printDate) : [true, '']); var otherMonth = (printDate.getMonth() != drawMonth); var unselectable = otherMonth || !daySettings[0] || (minDate && printDate < minDate) || (maxDate && printDate > maxDate); html += ''; // display for this month printDate.setDate(printDate.getDate() + 1); } html += ''; } drawMonth++; if (drawMonth > 11) { drawMonth = 0; drawYear++; } html += '
' + this._get('weekHeader') + '' + (!changeFirstDay ? '' + dayNamesMin[day] + (changeFirstDay ? '' : '') + '
' + calculateWeek(printDate) + '' + // actions (otherMonth ? (showOtherMonths ? printDate.getDate() : ' ') : // display for other months (unselectable ? printDate.getDate() : '' + printDate.getDate() + '')) + '
'; } } html += (showStatus ? '
' + this._get('initStatus') + '
' : '') + (!closeAtTop && !this._inline ? controls : '') + '
' + (!$.browser.msie ? '' : ''); return html; }, /* Generate the month and year header. */ _generateMonthYearHeader: function(drawMonth, drawYear, minDate, maxDate, selectedDate, secondary) { minDate = (this._rangeStart && minDate && selectedDate < minDate ? selectedDate : minDate); var showStatus = this._get('showStatus'); var html = '
'; // month selection var monthNames = this._get('monthNames'); if (secondary || !this._get('changeMonth')) { html += monthNames[drawMonth] + ' '; } else { var inMinYear = (minDate && minDate.getFullYear() == drawYear); var inMaxYear = (maxDate && maxDate.getFullYear() == drawYear); html += ''; } // year selection if (secondary || !this._get('changeYear')) { html += drawYear; } else { // determine range of years to display var years = this._get('yearRange').split(':'); var year = 0; var endYear = 0; if (years.length != 2) { year = drawYear - 10; endYear = drawYear + 10; } else if (years[0].charAt(0) == '+' || years[0].charAt(0) == '-') { year = drawYear + parseInt(years[0], 10); endYear = drawYear + parseInt(years[1], 10); } else { year = parseInt(years[0], 10); endYear = parseInt(years[1], 10); } year = (minDate ? Math.max(year, minDate.getFullYear()) : year); endYear = (maxDate ? Math.min(endYear, maxDate.getFullYear()) : endYear); html += ''; } html += '
'; // Close datepicker_header return html; }, /* Provide code to set and clear the status panel. */ _addStatus: function(text) { return ' onmouseover="jQuery(\'#datepicker_status_' + this._id + '\').html(\'' + text + '\');" ' + 'onmouseout="jQuery(\'#datepicker_status_' + this._id + '\').html(\' \');"'; }, /* Adjust one of the date sub-fields. */ _adjustDate: function(offset, period) { var year = this._selectedYear + (period == 'Y' ? offset : 0); var month = this._selectedMonth + (period == 'M' ? offset : 0); var day = Math.min(this._selectedDay, this._getDaysInMonth(year, month)) + (period == 'D' ? offset : 0); var date = new Date(year, month, day); // ensure it is within the bounds set var minDate = this._getMinDate(); var maxDate = this._get('maxDate'); date = (minDate && date < minDate ? minDate : date); date = (maxDate && date > maxDate ? maxDate : date); this._selectedDay = date.getDate(); this._selectedMonth = date.getMonth(); this._selectedYear = date.getFullYear(); }, /* Determine the current minimum date - may be overridden for a range. */ _getMinDate: function() { return this._get('minDate') || this._rangeStart; }, /* Find the number of days in a given month. */ _getDaysInMonth: function(year, month) { return 32 - new Date(year, month, 32).getDate(); }, /* Find the day of the week of the first of a month. */ _getFirstDayOfMonth: function(year, month) { return new Date(year, month, 1).getDay(); }, /* Determines if we should allow a "next/prev" month display change. */ _canAdjustMonth: function(offset) { var date = new Date(this._selectedYear, this._selectedMonth + offset, 1); if (offset < 0) { date.setDate(this._getDaysInMonth(date.getFullYear(), date.getMonth())); } return this._isInRange(date); }, /* Is the given date in the accepted range? */ _isInRange: function(date) { // during range selection, use minimum of selected date and range start var newMinDate = (!this._rangeStart ? null : new Date(this._selectedYear, this._selectedMonth, this._selectedDay)); newMinDate = (newMinDate && this._rangeStart < newMinDate ? this._rangeStart : newMinDate); var minDate = newMinDate || this._get('minDate'); var maxDate = this._get('maxDate'); return ((!minDate || date >= minDate) && (!maxDate || date <= maxDate)); }, /* Format the given date for display. */ _formatDate: function(day, month, year) { if (!day) { this._currentDay = this._selectedDay; this._currentMonth = this._selectedMonth; this._currentYear = this._selectedYear; } var date = (day ? (typeof day == 'object' ? day : new Date(year, month, day)) : new Date(this._currentYear, this._currentMonth, this._currentDay)); return $.datepicker.formatDate(this._get('dateFormat'), date, this._get('dayNamesShort'), this._get('dayNames'), this._get('monthNamesShort'), this._get('monthNames')); } }); /* jQuery extend now ignores nulls! */ function extendRemove(target, props) { $.extend(target, props); for (var name in props) { if (props[name] == null) { target[name] = null; } } return target; }; /* Attach the date picker to a jQuery selection. @param settings object - the new settings to use for this date picker instance (anonymous) @return jQuery object - for chaining further calls */ $.fn.datepicker = function(settings) { return this.each(function() { // check for settings on the control itself - in namespace 'date:' var inlineSettings = null; for (attrName in $.datepicker._defaults) { var attrValue = this.getAttribute('date:' + attrName); if (attrValue) { inlineSettings = inlineSettings || {}; try { inlineSettings[attrName] = eval(attrValue); } catch (err) { inlineSettings[attrName] = attrValue; } } } var nodeName = this.nodeName.toLowerCase(); if (nodeName == 'input') { var instSettings = (inlineSettings ? $.extend($.extend({}, settings || {}), inlineSettings || {}) : settings); // clone and customise var inst = (inst && !inlineSettings ? inst : new DatepickerInstance(instSettings, false)); $.datepicker._connectDatepicker(this, inst); } else if (nodeName == 'div' || nodeName == 'span') { var instSettings = $.extend($.extend({}, settings || {}), inlineSettings || {}); // clone and customise var inst = new DatepickerInstance(instSettings, true); $.datepicker._inlineDatepicker(this, inst); } }); }; /* Initialise the date picker. */ $(document).ready(function() { $.datepicker = new Datepicker(); // singleton instance $(document.body).append($.datepicker._datepickerDiv). mousedown($.datepicker._checkExternalClick); }); })(jQuery); ================================================ FILE: tests/jQuery/datepicker_datejs.js ================================================ /* jQuery UI Date Picker v3.2 - previously jQuery Calendar Written by Marc Grabanski (m@marcgrabanski.com) and Keith Wood (kbwood@iprimus.com.au). Copyright (c) 2007 Marc Grabanski (http://marcgrabanski.com/code/ui-datepicker) Dual licensed under the MIT (MIT-LICENSE.txt) and GPL (GPL-LICENSE.txt) licenses. Date: 09-03-2007 */ /* Date picker manager. Use the singleton instance of this class, $.datepicker, to interact with the date picker. Settings for (groups of) date pickers are maintained in an instance object (DatepickerInstance), allowing multiple different settings on the same page. */ (function($) { // hide the namespace function Datepicker() { this.debug = false; // Change this to true to start debugging this._nextId = 0; // Next ID for a date picker instance this._inst = []; // List of instances indexed by ID this._curInst = null; // The current instance in use this._disabledInputs = []; // List of date picker inputs that have been disabled this._datepickerShowing = false; // True if the popup picker is showing , false if not this._inDialog = false; // True if showing within a "dialog", false if not this.regional = []; // Available regional settings, indexed by language code this.regional[''] = { // Default regional settings clearText: 'Clear', // Display text for clear link clearStatus: 'Erase the current date', // Status text for clear link closeText: 'Close', // Display text for close link closeStatus: 'Close without change', // Status text for close link prevText: '<Prev', // Display text for previous month link prevStatus: 'Show the previous month', // Status text for previous month link nextText: 'Next>', // Display text for next month link nextStatus: 'Show the next month', // Status text for next month link currentText: 'Today', // Display text for current month link currentStatus: 'Show the current month', // Status text for current month link monthNames: ['January','February','March','April','May','June', 'July','August','September','October','November','December'], // Names of months for drop-down and formatting monthNamesShort: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'], // For formatting monthStatus: 'Show a different month', // Status text for selecting a month yearStatus: 'Show a different year', // Status text for selecting a year weekHeader: 'Wk', // Header for the week of the year column weekStatus: 'Week of the year', // Status text for the week of the year column dayNames: ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'], // For formatting dayNamesShort: ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'], // For formatting dayNamesMin: ['Su','Mo','Tu','We','Th','Fr','Sa'], // Column headings for days starting at Sunday dayStatus: 'Set DD as first week day', // Status text for the day of the week selection dateStatus: 'Select D, M d', // Status text for the date selection dateFormat: 'mm/dd/yy', // See format options on parseDate firstDay: 0, // The first day of the week, Sun = 0, Mon = 1, ... initStatus: 'Select a date', // Initial Status text on opening isRTL: false // True if right-to-left language, false if left-to-right }; this._defaults = { // Global defaults for all the date picker instances showOn: 'focus', // 'focus' for popup on focus, // 'button' for trigger button, or 'both' for either defaultDate: null, // Used when field is blank: actual date, // +/-number for offset from today, null for today appendText: '', // Display text following the input box, e.g. showing the format buttonText: '...', // Text for trigger button buttonImage: '', // URL for trigger button image buttonImageOnly: false, // True if the image appears alone, false if it appears on a button closeAtTop: true, // True to have the clear/close at the top, // false to have them at the bottom hideIfNoPrevNext: false, // True to hide next/previous month links // if not applicable, false to just disable them changeMonth: true, // True if month can be selected directly, false if only prev/next changeYear: true, // True if year can be selected directly, false if only prev/next yearRange: '-10:+10', // Range of years to display in drop-down, // either relative to current year (-nn:+nn) or absolute (nnnn:nnnn) changeFirstDay: true, // True to click on day name to change, false to remain as set showOtherMonths: false, // True to show dates in other months, false to leave blank showWeeks: false, // True to show week of the year, false to omit calculateWeek: this.iso8601Week, // How to calculate the week of the year, // takes a Date and returns the number of the week for it shortYearCutoff: '+10', // Short year values < this are in the current century, // > this are in the previous century, // string value starting with '+' for current year + value showStatus: false, // True to show status bar at bottom, false to not show it statusForDate: this.dateStatus, // Function to provide status text for a date - // takes date and instance as parameters, returns display text minDate: null, // The earliest selectable date, or null for no limit maxDate: null, // The latest selectable date, or null for no limit speed: 'medium', // Speed of display/closure beforeShowDay: null, // Function that takes a date and returns an array with // [0] = true if selectable, false if not, // [1] = custom CSS class name(s) or '', e.g. $.datepicker.noWeekends beforeShow: null, // Function that takes an input field and // returns a set of custom settings for the date picker onSelect: null, // Define a callback function when a date is selected numberOfMonths: 1, // Number of months to show at a time stepMonths: 1, // Number of months to step back/forward rangeSelect: false, // Allows for selecting a date range on one date picker rangeSeparator: ' - ' // Text between two dates in a range }; $.extend(this._defaults, this.regional['']); this._datepickerDiv = $('
'); } $.extend(Datepicker.prototype, { /* Class name added to elements to indicate already configured with a date picker. */ markerClassName: 'hasDatepicker', /* Debug logging (if enabled). */ log: function () { if (this.debug) { console.log.apply('', arguments); } }, /* Register a new date picker instance - with custom settings. */ _register: function(inst) { var id = this._nextId++; this._inst[id] = inst; return id; }, /* Retrieve a particular date picker instance based on its ID. */ _getInst: function(id) { return this._inst[id] || id; }, /* Override the default settings for all instances of the date picker. @param settings object - the new settings to use as defaults (anonymous object) @return the manager object */ setDefaults: function(settings) { extendRemove(this._defaults, settings || {}); return this; }, /* Handle keystrokes. */ _doKeyDown: function(e) { var inst = $.datepicker._getInst(this._calId); if ($.datepicker._datepickerShowing) { switch (e.keyCode) { case 9: $.datepicker.hideDatepicker(''); break; // hide on tab out case 13: $.datepicker._selectDay(inst, inst._selectedMonth, inst._selectedYear, $('td.datepicker_daysCellOver', inst._datepickerDiv)[0]); break; // select the value on enter case 27: $.datepicker.hideDatepicker(inst._get('speed')); break; // hide on escape case 33: $.datepicker._adjustDate(inst, (e.ctrlKey ? -1 : -inst._get('stepMonths')), (e.ctrlKey ? 'Y' : 'M')); break; // previous month/year on page up/+ ctrl case 34: $.datepicker._adjustDate(inst, (e.ctrlKey ? +1 : +inst._get('stepMonths')), (e.ctrlKey ? 'Y' : 'M')); break; // next month/year on page down/+ ctrl case 35: if (e.ctrlKey) $.datepicker._clearDate(inst); break; // clear on ctrl+end case 36: if (e.ctrlKey) $.datepicker._gotoToday(inst); break; // current on ctrl+home case 37: if (e.ctrlKey) $.datepicker._adjustDate(inst, -1, 'D'); break; // -1 day on ctrl+left case 38: if (e.ctrlKey) $.datepicker._adjustDate(inst, -7, 'D'); break; // -1 week on ctrl+up case 39: if (e.ctrlKey) $.datepicker._adjustDate(inst, +1, 'D'); break; // +1 day on ctrl+right case 40: if (e.ctrlKey) $.datepicker._adjustDate(inst, +7, 'D'); break; // +1 week on ctrl+down } } else if (e.keyCode == 36 && e.ctrlKey) { // display the date picker on ctrl+home $.datepicker.showFor(this); } }, /* Filter entered characters - based on date format. */ _doKeyPress: function(e) { var inst = $.datepicker._getInst(this._calId); var chars = $.datepicker._possibleChars(inst._get('dateFormat')); var chr = String.fromCharCode(e.charCode == undefined ? e.keyCode : e.charCode); return (chr < ' ' || !chars || chars.indexOf(chr) > -1); }, /* Attach the date picker to an input field. */ _connectDatepicker: function(target, inst) { var input = $(target); if (this._hasClass(input, this.markerClassName)) { return; } var appendText = inst._get('appendText'); var isRTL = inst._get('isRTL'); if (appendText) { if (isRTL) { input.before('' + appendText + ''); } else { input.after('' + appendText + ''); } } var showOn = inst._get('showOn'); if (showOn == 'focus' || showOn == 'both') { // pop-up date picker when in the marked field input.focus(this.showFor); } if (showOn == 'button' || showOn == 'both') { // pop-up date picker when button clicked var buttonText = inst._get('buttonText'); var buttonImage = inst._get('buttonImage'); var buttonImageOnly = inst._get('buttonImageOnly'); var trigger = $(buttonImageOnly ? '' + buttonText + '' : ''); input.wrap(''); if (isRTL) { input.before(trigger); } else { input.after(trigger); } trigger.click(this.showFor); } input.addClass(this.markerClassName).keydown(this._doKeyDown).keypress(this._doKeyPress); input[0]._calId = inst._id; }, /* Attach an inline date picker to a div. */ _inlineDatepicker: function(target, inst) { var input = $(target); if (this._hasClass(input, this.markerClassName)) { return; } input.addClass(this.markerClassName).append(inst._datepickerDiv); input[0]._calId = inst._id; this._updateDatepicker(inst); inst._datepickerDiv.resize(function() { $.datepicker._inlineShow(inst); }); }, /* Tidy up after displaying the date picker. */ _inlineShow: function(inst) { var numMonths = inst._get('numberOfMonths'); // fix width for dynamic number of date pickers numMonths = (numMonths == null ? 1 : (typeof numMonths == 'number' ? numMonths : numMonths[1])); inst._datepickerDiv.width(numMonths * $('.datepicker', inst._datepickerDiv[0]).width()); }, /* Does this element have a particular class? */ _hasClass: function(element, className) { var classes = element.attr('class'); return (classes && classes.indexOf(className) > -1); }, /* Pop-up the date picker in a "dialog" box. @param dateText string - the initial date to display (in the current format) @param onSelect function - the function(dateText) to call when a date is selected @param settings object - update the dialog date picker instance's settings (anonymous object) @param pos int[2] - coordinates for the dialog's position within the screen or event - with x/y coordinates or leave empty for default (screen centre) @return the manager object */ dialogDatepicker: function(dateText, onSelect, settings, pos) { var inst = this._dialogInst; // internal instance if (!inst) { inst = this._dialogInst = new DatepickerInstance({}, false); this._dialogInput = $(''); this._dialogInput.keydown(this._doKeyDown); $('body').append(this._dialogInput); this._dialogInput[0]._calId = inst._id; } extendRemove(inst._settings, settings || {}); this._dialogInput.val(dateText); this._pos = (pos ? (pos.length ? pos : [pos.pageX, pos.pageY]) : null); if (!this._pos) { var browserWidth = window.innerWidth || document.documentElement.clientWidth || document.body.clientWidth; var browserHeight = window.innerHeight || document.documentElement.clientHeight || document.body.clientHeight; var scrollX = document.documentElement.scrollLeft || document.body.scrollLeft; var scrollY = document.documentElement.scrollTop || document.body.scrollTop; this._pos = // should use actual width/height below [(browserWidth / 2) - 100 + scrollX, (browserHeight / 2) - 150 + scrollY]; } // move input on screen for focus, but hidden behind dialog this._dialogInput.css('left', this._pos[0] + 'px').css('top', this._pos[1] + 'px'); inst._settings.onSelect = onSelect; this._inDialog = true; this._datepickerDiv.addClass('datepicker_dialog'); this.showFor(this._dialogInput[0]); if ($.blockUI) { $.blockUI(this._datepickerDiv); } return this; }, /* Enable the input field(s) for entry. @param inputs element - single input field or string - the ID or other jQuery selector of the input field(s) or object - jQuery collection of input fields @return the manager object */ enableFor: function(inputs) { inputs = (inputs.jquery ? inputs : $(inputs)); inputs.each(function() { this.disabled = false; $(this).siblings('button.datepicker_trigger').each(function() { this.disabled = false; }); $(this).siblings('img.datepicker_trigger').css({opacity: '1.0', cursor: ''}); var $this = this; $.datepicker._disabledInputs = $.map($.datepicker._disabledInputs, function(value) { return (value == $this ? null : value); }); // delete entry }); return this; }, /* Disable the input field(s) from entry. @param inputs element - single input field or string - the ID or other jQuery selector of the input field(s) or object - jQuery collection of input fields @return the manager object */ disableFor: function(inputs) { inputs = (inputs.jquery ? inputs : $(inputs)); inputs.each(function() { this.disabled = true; $(this).siblings('button.datepicker_trigger').each(function() { this.disabled = true; }); $(this).siblings('img.datepicker_trigger').css({opacity: '0.5', cursor: 'default'}); var $this = this; $.datepicker._disabledInputs = $.map($.datepicker._disabledInputs, function(value) { return (value == $this ? null : value); }); // delete entry $.datepicker._disabledInputs[$.datepicker._disabledInputs.length] = this; }); return this; }, /* Is the input field disabled? @param input element - single input field or string - the ID or other jQuery selector of the input field or object - jQuery collection of input field @return boolean - true if disabled, false if enabled */ isDisabled: function(input) { input = (input.jquery ? input[0] : (typeof input == 'string' ? $(input)[0] : input)); for (var i = 0; i < $.datepicker._disabledInputs.length; i++) { if ($.datepicker._disabledInputs[i] == input) { return true; } } return false; }, /* Update the settings for a date picker attached to an input field or division. @param control element - the input field or div/span attached to the date picker or string - the ID or other jQuery selector of the input field or object - jQuery object for input field or div/span @param settings object - the new settings to update @return the manager object */ reconfigureFor: function(control, settings) { control = (control.jquery ? control[0] : (typeof control == 'string' ? $(control)[0] : control)); var inst = this._getInst(control._calId); if (inst) { extendRemove(inst._settings, settings || {}); this._updateDatepicker(inst); } return this; }, /* Set the date for a date picker attached to an input field or division. @param control element - the input field or div/span attached to the date picker or string - the ID or other jQuery selector of the input field or object - jQuery object for input field or div/span @param date Date - the new date @param endDate Date - the new end date for a range (optional) @return the manager object */ setDateFor: function(control, date, endDate) { control = (control.jquery ? control[0] : (typeof control == 'string' ? $(control)[0] : control)); var inst = this._getInst(control._calId); if (inst) { inst._setDate(date, endDate); this._updateDatepicker(inst); } return this; }, /* Retrieve the date for a date picker attached to an input field or division. @param control element - the input field or div/span attached to the date picker or string - the ID or other jQuery selector of the input field or object - jQuery object for input field or div/span @return Date - the current date or Date[2] - the current dates for a range*/ getDateFor: function(control) { control = (control.jquery ? control[0] : (typeof control == 'string' ? $(control)[0] : control)); var inst = this._getInst(control._calId); return (inst ? inst._getDate() : null); }, /* Pop-up the date picker for a given input field. @param control element - the input field attached to the date picker or string - the ID or other jQuery selector of the input field or object - jQuery object for input field @return the manager object */ showFor: function(control) { control = (control.jquery ? control[0] : (typeof control == 'string' ? $(control)[0] : control)); var input = (control.nodeName && control.nodeName.toLowerCase() == 'input' ? control : this); if (input.nodeName.toLowerCase() != 'input') { // find from button/image trigger input = $('input', input.parentNode)[0]; } if ($.datepicker._lastInput == input) { // already here return; } if ($.datepicker.isDisabled(input)) { return; } var inst = $.datepicker._getInst(input._calId); var beforeShow = inst._get('beforeShow'); extendRemove(inst._settings, (beforeShow ? beforeShow(input) : {})); $.datepicker.hideDatepicker(''); $.datepicker._lastInput = input; inst._setDateFromField(input); if ($.datepicker._inDialog) { // hide cursor input.value = ''; } if (!$.datepicker._pos) { // position below input $.datepicker._pos = $.datepicker._findPos(input); $.datepicker._pos[1] += input.offsetHeight; // add the height } var isFixed = false; $(input).parents().each(function() { isFixed |= $(this).css('position') == 'fixed'; }); if (isFixed && $.browser.opera) { // correction for Opera when fixed and scrolled $.datepicker._pos[0] -= document.documentElement.scrollLeft; $.datepicker._pos[1] -= document.documentElement.scrollTop; } inst._datepickerDiv.css('position', ($.datepicker._inDialog && $.blockUI ? 'static' : (isFixed ? 'fixed' : 'absolute'))). css('left', $.datepicker._pos[0] + 'px').css('top', $.datepicker._pos[1] + 'px'); $.datepicker._pos = null; $.datepicker._showDatepicker(inst); return this; }, /* Construct and display the date picker. */ _showDatepicker: function(id) { var inst = this._getInst(id); inst._rangeStart = null; this._updateDatepicker(inst); if (!inst._inline) { var speed = inst._get('speed'); var postProcess = function() { $.datepicker._datepickerShowing = true; $.datepicker._afterShow(inst); }; inst._datepickerDiv.show(speed, postProcess); if (speed == '') { postProcess(); } if (inst._input[0].type != 'hidden') { inst._input[0].focus(); } this._curInst = inst; } }, /* Generate the date picker content. */ _updateDatepicker: function(inst) { inst._datepickerDiv.empty().append(inst._generateDatepicker()); if (inst._get('numberOfMonths') != 1) { inst._datepickerDiv.addClass('datepicker_multi'); } else { inst._datepickerDiv.removeClass('datepicker_multi'); } if (inst._input && inst._input[0].type != 'hidden') { inst._input[0].focus(); } }, /* Tidy up after displaying the date picker. */ _afterShow: function(inst) { var numMonths = inst._get('numberOfMonths'); // fix width for dynamic number of date pickers numMonths = (numMonths == null ? 1 : (typeof numMonths == 'number' ? numMonths : numMonths[1])); inst._datepickerDiv.width(numMonths * $('.datepicker', inst._datepickerDiv[0]).width()); if ($.browser.msie) { // fix IE < 7 select problems $('#datepicker_cover').css({width: inst._datepickerDiv.width() + 4, height: inst._datepickerDiv.height() + 4}); } // re-position on screen if necessary var isFixed = inst._datepickerDiv.css('position') == 'fixed'; var pos = $.datepicker._findPos(inst._input[0]); var browserWidth = window.innerWidth || document.documentElement.clientWidth || document.body.clientWidth; var browserHeight = window.innerHeight || document.documentElement.clientHeight || document.body.clientHeight; var scrollX = (isFixed ? 0 : document.documentElement.scrollLeft || document.body.scrollLeft); var scrollY = (isFixed ? 0 : document.documentElement.scrollTop || document.body.scrollTop); // reposition date picker horizontally if outside the browser window if ((inst._datepickerDiv.offset().left + inst._datepickerDiv.width() - (isFixed && $.browser.msie ? document.documentElement.scrollLeft : 0)) > (browserWidth + scrollX)) { inst._datepickerDiv.css('left', Math.max(scrollX, pos[0] + $(inst._input[0]).width() - inst._datepickerDiv.width() - (isFixed && $.browser.opera ? document.documentElement.scrollLeft : 0)) + 'px'); } // reposition date picker vertically if outside the browser window if ((inst._datepickerDiv.offset().top + inst._datepickerDiv.height() - (isFixed && $.browser.msie ? document.documentElement.scrollTop : 0)) > (browserHeight + scrollY) ) { inst._datepickerDiv.css('top', Math.max(scrollY, pos[1] - (this._inDialog ? 0 : inst._datepickerDiv.height()) - (isFixed && $.browser.opera ? document.documentElement.scrollTop : 0)) + 'px'); } }, /* Find an object's position on the screen. */ _findPos: function(obj) { while (obj && (obj.type == 'hidden' || obj.nodeType != 1)) { obj = obj.nextSibling; } var curleft = curtop = 0; if (obj && obj.offsetParent) { curleft = obj.offsetLeft; curtop = obj.offsetTop; while (obj = obj.offsetParent) { var origcurleft = curleft; curleft += obj.offsetLeft; if (curleft < 0) { curleft = origcurleft; } curtop += obj.offsetTop; } } return [curleft,curtop]; }, /* Hide the date picker from view. @param speed string - the speed at which to close the date picker @return void */ hideDatepicker: function(speed) { var inst = this._curInst; if (!inst) { return; } var rangeSelect = inst._get('rangeSelect'); if (rangeSelect && this._stayOpen) { this._selectDate(inst, inst._formatDate( inst._currentDay, inst._currentMonth, inst._currentYear)); } this._stayOpen = false; if (this._datepickerShowing) { speed = (speed != null ? speed : inst._get('speed')); inst._datepickerDiv.hide(speed, function() { $.datepicker._tidyDialog(inst); }); if (speed == '') { this._tidyDialog(inst); } this._datepickerShowing = false; this._lastInput = null; inst._settings.prompt = null; if (this._inDialog) { this._dialogInput.css('position', 'absolute'). css('left', '0px').css('top', '-100px'); if ($.blockUI) { $.unblockUI(); $('body').append(this._datepickerDiv); } } this._inDialog = false; } this._curInst = null; }, /* Tidy up after a dialog display. */ _tidyDialog: function(inst) { inst._datepickerDiv.removeClass('datepicker_dialog'); $('.datepicker_prompt', inst._datepickerDiv).remove(); }, /* Close date picker if clicked elsewhere. */ _checkExternalClick: function(event) { if (!$.datepicker._curInst) { return; } var target = $(event.target); if ((target.parents("#datepicker_div").length == 0) && (target.attr('class') != 'datepicker_trigger') && $.datepicker._datepickerShowing && !($.datepicker._inDialog && $.blockUI)) { $.datepicker.hideDatepicker(''); } }, /* Adjust one of the date sub-fields. */ _adjustDate: function(id, offset, period) { var inst = this._getInst(id); inst._adjustDate(offset, period); this._updateDatepicker(inst); }, /* Action for current link. */ _gotoToday: function(id) { var date = new Date(); var inst = this._getInst(id); inst._selectedDay = date.getDate(); inst._selectedMonth = date.getMonth(); inst._selectedYear = date.getFullYear(); this._adjustDate(inst); }, /* Action for selecting a new month/year. */ _selectMonthYear: function(id, select, period) { var inst = this._getInst(id); inst._selectingMonthYear = false; inst[period == 'M' ? '_selectedMonth' : '_selectedYear'] = select.options[select.selectedIndex].value - 0; this._adjustDate(inst); }, /* Restore input focus after not changing month/year. */ _clickMonthYear: function(id) { var inst = this._getInst(id); if (inst._input && inst._selectingMonthYear && !$.browser.msie) { inst._input[0].focus(); } inst._selectingMonthYear = !inst._selectingMonthYear; }, /* Action for changing the first week day. */ _changeFirstDay: function(id, a) { var inst = this._getInst(id); var dayNamesMin = inst._get('dayNamesMin'); var value = a.firstChild.nodeValue; for (var i = 0; i < 7; i++) { if (dayNamesMin[i] == value) { inst._settings.firstDay = i; break; } } this._updateDatepicker(inst); }, /* Action for selecting a day. */ _selectDay: function(id, month, year, td) { if (this._hasClass($(td), 'datepicker_unselectable')) { return; } var inst = this._getInst(id); var rangeSelect = inst._get('rangeSelect'); if (rangeSelect) { if (!this._stayOpen) { $('.datepicker td').removeClass('datepicker_currentDay'); $(td).addClass('datepicker_currentDay'); } this._stayOpen = !this._stayOpen; } inst._currentDay = $('a', td).html(); inst._currentMonth = month; inst._currentYear = year; this._selectDate(id, inst._formatDate( inst._currentDay, inst._currentMonth, inst._currentYear)); if (this._stayOpen) { inst._endDay = inst._endMonth = inst._endYear = null; inst._rangeStart = new Date(inst._currentYear, inst._currentMonth, inst._currentDay); this._updateDatepicker(inst); } else if (rangeSelect) { if (inst._inline) { inst._endDay = inst._currentDay; inst._endMonth = inst._currentMonth; inst._endYear = inst._currentYear; inst._selectedDay = inst._currentDay = inst._rangeStart.getDate(); inst._selectedMonth = inst._currentMonth = inst._rangeStart.getMonth(); inst._selectedYear = inst._currentYear = inst._rangeStart.getFullYear(); inst._rangeStart = null; this._updateDatepicker(inst); } else { inst._rangeStart = null; } } }, /* Erase the input field and hide the date picker. */ _clearDate: function(id) { var inst = this._getInst(id); this._stayOpen = false; inst._rangeStart = null; this._selectDate(inst, ''); }, /* Update the input field with the selected date. */ _selectDate: function(id, dateStr) { var inst = this._getInst(id); dateStr = (dateStr != null ? dateStr : inst._formatDate()); if (inst._rangeStart) { dateStr = inst._formatDate(inst._rangeStart) + inst._get('rangeSeparator') + dateStr; } if (inst._input) { inst._input.val(dateStr); } var onSelect = inst._get('onSelect'); if (onSelect) { onSelect(dateStr, inst); // trigger custom callback } else { inst._input.trigger('change'); // fire the change event } if (inst._inline) { this._updateDatepicker(inst); } else { if (!this._stayOpen) { this.hideDatepicker(inst._get('speed')); } } }, /* Set as beforeShowDay function to prevent selection of weekends. @param date Date - the date to customise @return [boolean, string] - is this date selectable?, what is its CSS class? */ noWeekends: function(date) { var day = date.getDay(); return [(day > 0 && day < 6), '']; }, /* Set as calculateWeek to determine the week of the year based on the ISO 8601 definition. @param date Date - the date to get the week for @return number - the number of the week within the year that contains this date */ iso8601Week: function(date) { var checkDate = new Date(date.getFullYear(), date.getMonth(), date.getDate()); var firstMon = new Date(checkDate.getFullYear(), 1 - 1, 4); // First week always contains 4 Jan var firstDay = firstMon.getDay() || 7; // Day of week: Mon = 1, ..., Sun = 7 firstMon.setDate(firstMon.getDate() + 1 - firstDay); // Preceding Monday if (firstDay < 4 && checkDate < firstMon) { // Adjust first three days in year if necessary checkDate.setDate(checkDate.getDate() - 3); // Generate for previous year return $.datepicker.iso8601Week(checkDate); } else if (checkDate > new Date(checkDate.getFullYear(), 12 - 1, 28)) { // Check last three days in year firstDay = new Date(checkDate.getFullYear() + 1, 1 - 1, 4).getDay() || 7; if (firstDay > 4 && (checkDate.getDay() || 7) < firstDay - 3) { // Adjust if necessary checkDate.setDate(checkDate.getDate() + 3); // Generate for next year return $.datepicker.iso8601Week(checkDate); } } return Math.floor(((checkDate - firstMon) / 86400000) / 7) + 1; // Weeks to given date }, /* Provide status text for a particular date. @param date the date to get the status for @param inst the current datepicker instance @return the status display text for this date */ dateStatus: function(date, inst) { return $.datepicker.formatDate(inst._get('dateStatus'), date); }, /* Parse a string value into a date object. The format can be combinations of the following: d - day of month (no leading zero) dd - day of month (two digit) D - day name short DD - day name long m - month of year (no leading zero) mm - month of year (two digit) M - month name short MM - month name long y - year (two digit) yy - year (four digit) '...' - literal text '' - single quote @param format String - the expected format of the date @param value String - the date in the above format @param shortYearCutoff Number - the cutoff year for determining the century (optional) @param dayNamesShort String[7] - abbreviated names of the days from Sunday (optional) @param dayNames String[7] - names of the days from Sunday (optional) @param monthNamesShort String[12] - abbreviated names of the months (optional) @param monthNames String[12] - names of the months (optional) @return Date - the extracted date value or null if value is blank */ /* Format a date object into a string value. The format can be combinations of the following: d - day of month (no leading zero) dd - day of month (two digit) D - day name short DD - day name long m - month of year (no leading zero) mm - month of year (two digit) M - month name short MM - month name long y - year (two digit) yy - year (four digit) '...' - literal text '' - single quote @param format String - the desired format of the date @param date Date - the date value to format @param dayNamesShort String[7] - abbreviated names of the days from Sunday (optional) @param dayNames String[7] - names of the days from Sunday (optional) @param monthNamesShort String[12] - abbreviated names of the months (optional) @param monthNames String[12] - names of the months (optional) @return String - the date in the above format */ formatDate: function (format, date, dayNamesShort, dayNames, monthNamesShort, monthNames) { if (!date) { return ''; } // format = dateFormats[format] || format; dayNamesShort = dayNamesShort || this._defaults.dayNamesShort; dayNames = dayNames || this._defaults.dayNames; monthNamesShort = monthNamesShort || this._defaults.monthNamesShort; monthNames = monthNames || this._defaults.monthNames; // Check whether a format character is doubled var lookAhead = function(match) { var matches = (iFormat + 1 < format.length && format.charAt(iFormat + 1) == match); if (matches) { iFormat++; } return matches; }; // Format a number, with leading zero if necessary var formatNumber = function(match, value) { return (lookAhead(match) && value < 10 ? '0' : '') + value; }; // Format a name, short or long as requested var formatName = function(match, value, shortNames, longNames) { return (lookAhead(match) ? longNames[value] : shortNames[value]); }; var output = ''; var literal = false; if (date) { for (var iFormat = 0; iFormat < format.length; iFormat++) { if (literal) { if (format.charAt(iFormat) == '\'' && !lookAhead('\'')) { literal = false; } else { output += format.charAt(iFormat); } } else { switch (format.charAt(iFormat)) { case 'd': output += formatNumber('d', date.getDate()); break; case 'D': output += formatName('D', date.getDay(), dayNamesShort, dayNames); break; case 'm': output += formatNumber('m', date.getMonth() + 1); break; case 'M': output += formatName('M', date.getMonth(), monthNamesShort, monthNames); break; case 'y': output += (lookAhead('y') ? date.getFullYear() : (date.getYear() % 100 < 10 ? '0' : '') + date.getYear() % 100); break; case '\'': if (lookAhead('\'')) { output += '\''; } else { literal = true; } break; default: output += format.charAt(iFormat); } } } } return output; }, /* Extract all possible characters from the date format. */ _possibleChars: function (format) { // format = dateFormats[format] || format; var chars = ''; var literal = false; for (var iFormat = 0; iFormat < format.length; iFormat++) { if (literal) { if (format.charAt(iFormat) == '\'' && !lookAhead('\'')) { literal = false; } else { chars += format.charAt(iFormat); } } else { switch (format.charAt(iFormat)) { case 'd': case 'm': case 'y': chars += '0123456789'; break; case 'D': case 'M': return null; // Accept anything case '\'': if (lookAhead('\'')) { chars += '\''; } else { literal = true; } break; default: chars += format.charAt(iFormat); } } } return chars; } }); /* Individualised settings for date picker functionality applied to one or more related inputs. Instances are managed and manipulated through the Datepicker manager. */ function DatepickerInstance(settings, inline) { this._id = $.datepicker._register(this); this._selectedDay = 0; this._selectedMonth = 0; // 0-11 this._selectedYear = 0; // 4-digit year this._input = null; // The attached input field this._inline = inline; // True if showing inline, false if used in a popup this._datepickerDiv = (!inline ? $.datepicker._datepickerDiv : $('
')); // customise the date picker object - uses manager defaults if not overridden this._settings = extendRemove({}, settings || {}); // clone if (inline) { this._setDate(this._getDefaultDate()); } } $.extend(DatepickerInstance.prototype, { /* Get a setting value, defaulting if necessary. */ _get: function(name) { return (this._settings[name] != null ? this._settings[name] : $.datepicker._defaults[name]); }, /* Parse existing date and initialise date picker. */ _setDateFromField: function(input) { this._input = $(input); var dateFormat = this._get('dateFormat'); var dates = this._input.val().split(this._get('rangeSeparator')); this._endDay = this._endMonth = this._endYear = null; var shortYearCutoff = this._get('shortYearCutoff'); shortYearCutoff = (typeof shortYearCutoff != 'string' ? shortYearCutoff : new Date().getFullYear() % 100 + parseInt(shortYearCutoff, 10)); var date = this._getDefaultDate(); if (dates.length > 0) { if (dates.length > 1) { date = Date.parse(dates[1]) || this._getDefaultDate(); this._endDay = date.getDate(); this._endMonth = date.getMonth(); this._endYear = date.getFullYear(); } try { date =Date.parse(dates[0]) || this._getDefaultDate(); } catch (e) { $.datepicker.log(e); date = this._getDefaultDate(); } } this._selectedDay = this._currentDay = date.getDate(); this._selectedMonth = this._currentMonth = date.getMonth(); this._selectedYear = this._currentYear = date.getFullYear(); this._adjustDate(); }, /* Retrieve the default date shown on opening. */ _getDefaultDate: function() { var offsetDate = function(offset) { var date = new Date(); date.setDate(date.getDate() + offset); return date; }; var defaultDate = this._get('defaultDate'); return (defaultDate == null ? new Date() : (typeof defaultDate == 'number' ? offsetDate(defaultDate) : defaultDate)); }, /* Set the date(s) directly. */ _setDate: function(date, endDate) { this._selectedDay = this._currentDay = date.getDate(); this._selectedMonth = this._currentMonth = date.getMonth(); this._selectedYear = this._currentYear = date.getFullYear(); if (this._get('rangeSelect')) { if (endDate) { this._endDay = endDate.getDate(); this._endMonth = endDate.getMonth(); this._endYear = endDate.getFullYear(); } else { this._endDay = this._currentDay; this._endMonth = this._currentMonth; this._endYear = this._currentYear; } } this._adjustDate(); }, /* Retrieve the date(s) directly. */ _getDate: function() { var startDate = (!this._currentYear || (this._input && this._input.val() == '') ? null : new Date(this._currentYear, this._currentMonth, this._currentDay)); if (this._get('rangeSelect')) { return [startDate, new Date(this._endYear, this._endMonth, this._endDay)]; } else { return startDate; } }, /* Generate the HTML for the current state of the date picker. */ _generateDatepicker: function() { var today = new Date(); today = new Date(today.getFullYear(), today.getMonth(), today.getDate()); // clear time var showStatus = this._get('showStatus'); // build the date picker HTML var controls = ''; var prompt = this._get('prompt'); var closeAtTop = this._get('closeAtTop'); var hideIfNoPrevNext = this._get('hideIfNoPrevNext'); var numMonths = this._get('numberOfMonths'); var stepMonths = this._get('stepMonths'); var isMultiMonth = (numMonths != 1); numMonths = (numMonths == null ? [1, 1] : (typeof numMonths == 'number' ? [1, numMonths] : numMonths)); // controls and links var html = (prompt ? '
' + prompt + '
' : '') + (closeAtTop && !this._inline ? controls : '') + ''; var minDate = this._getMinDate(); var maxDate = this._get('maxDate'); var drawMonth = this._selectedMonth; var drawYear = this._selectedYear; var showWeeks = this._get('showWeeks'); for (var row = 0; row < numMonths[0]; row++) { for (var col = 0; col < numMonths[1]; col++) { var selectedDate = new Date(drawYear, drawMonth, this._selectedDay); html += '
' + this._generateMonthYearHeader(drawMonth, drawYear, minDate, maxDate, selectedDate, row > 0 || col > 0) + // draw month headers '' + '' + (showWeeks ? '' : ''); var firstDay = this._get('firstDay'); var changeFirstDay = this._get('changeFirstDay'); var dayNames = this._get('dayNames'); var dayNamesShort = this._get('dayNamesShort'); var dayNamesMin = this._get('dayNamesMin'); for (var dow = 0; dow < 7; dow++) { // days of the week var day = (dow + firstDay) % 7; html += ''; } html += ''; var daysInMonth = this._getDaysInMonth(drawYear, drawMonth); this._selectedDay = Math.min(this._selectedDay, daysInMonth); var leadDays = (this._getFirstDayOfMonth(drawYear, drawMonth) - firstDay + 7) % 7; var currentDate = new Date(this._currentYear, this._currentMonth, this._currentDay); var endDate = this._endDay ? new Date(this._endYear, this._endMonth, this._endDay) : currentDate; var printDate = new Date(drawYear, drawMonth, 1 - leadDays); var numRows = (isMultiMonth ? 6 : Math.ceil((leadDays + daysInMonth) / 7)); // calculate the number of rows to generate var beforeShowDay = this._get('beforeShowDay'); var showOtherMonths = this._get('showOtherMonths'); var calculateWeek = this._get('calculateWeek') || $.datepicker.iso8601Week; var dateStatus = this._get('statusForDate') || $.datepicker.dateStatus; for (var dRow = 0; dRow < numRows; dRow++) { // create date picker rows html += '' + (showWeeks ? '' : ''); for (var dow = 0; dow < 7; dow++) { // create date picker days var daySettings = (beforeShowDay ? beforeShowDay(printDate) : [true, '']); var otherMonth = (printDate.getMonth() != drawMonth); var unselectable = otherMonth || !daySettings[0] || (minDate && printDate < minDate) || (maxDate && printDate > maxDate); html += ''; // display for this month printDate.setDate(printDate.getDate() + 1); } html += ''; } drawMonth++; if (drawMonth > 11) { drawMonth = 0; drawYear++; } html += '
' + this._get('weekHeader') + '' + (!changeFirstDay ? '' + dayNamesMin[day] + (changeFirstDay ? '' : '') + '
' + calculateWeek(printDate) + '' + // actions (otherMonth ? (showOtherMonths ? printDate.getDate() : ' ') : // display for other months (unselectable ? printDate.getDate() : '' + printDate.getDate() + '')) + '
'; } } html += (showStatus ? '
' + this._get('initStatus') + '
' : '') + (!closeAtTop && !this._inline ? controls : '') + '
' + (!$.browser.msie ? '' : ''); return html; }, /* Generate the month and year header. */ _generateMonthYearHeader: function(drawMonth, drawYear, minDate, maxDate, selectedDate, secondary) { minDate = (this._rangeStart && minDate && selectedDate < minDate ? selectedDate : minDate); var showStatus = this._get('showStatus'); var html = '
'; // month selection var monthNames = this._get('monthNames'); if (secondary || !this._get('changeMonth')) { html += monthNames[drawMonth] + ' '; } else { var inMinYear = (minDate && minDate.getFullYear() == drawYear); var inMaxYear = (maxDate && maxDate.getFullYear() == drawYear); html += ''; } // year selection if (secondary || !this._get('changeYear')) { html += drawYear; } else { // determine range of years to display var years = this._get('yearRange').split(':'); var year = 0; var endYear = 0; if (years.length != 2) { year = drawYear - 10; endYear = drawYear + 10; } else if (years[0].charAt(0) == '+' || years[0].charAt(0) == '-') { year = drawYear + parseInt(years[0], 10); endYear = drawYear + parseInt(years[1], 10); } else { year = parseInt(years[0], 10); endYear = parseInt(years[1], 10); } year = (minDate ? Math.max(year, minDate.getFullYear()) : year); endYear = (maxDate ? Math.min(endYear, maxDate.getFullYear()) : endYear); html += ''; } html += '
'; // Close datepicker_header return html; }, /* Provide code to set and clear the status panel. */ _addStatus: function(text) { return ' onmouseover="jQuery(\'#datepicker_status_' + this._id + '\').html(\'' + text + '\');" ' + 'onmouseout="jQuery(\'#datepicker_status_' + this._id + '\').html(\' \');"'; }, /* Adjust one of the date sub-fields. */ _adjustDate: function(offset, period) { var year = this._selectedYear + (period == 'Y' ? offset : 0); var month = this._selectedMonth + (period == 'M' ? offset : 0); var day = Math.min(this._selectedDay, this._getDaysInMonth(year, month)) + (period == 'D' ? offset : 0); var date = new Date(year, month, day); // ensure it is within the bounds set var minDate = this._getMinDate(); var maxDate = this._get('maxDate'); date = (minDate && date < minDate ? minDate : date); date = (maxDate && date > maxDate ? maxDate : date); this._selectedDay = date.getDate(); this._selectedMonth = date.getMonth(); this._selectedYear = date.getFullYear(); }, /* Determine the current minimum date - may be overridden for a range. */ _getMinDate: function() { return this._get('minDate') || this._rangeStart; }, /* Find the number of days in a given month. */ _getDaysInMonth: function(year, month) { return 32 - new Date(year, month, 32).getDate(); }, /* Find the day of the week of the first of a month. */ _getFirstDayOfMonth: function(year, month) { return new Date(year, month, 1).getDay(); }, /* Determines if we should allow a "next/prev" month display change. */ _canAdjustMonth: function(offset) { var date = new Date(this._selectedYear, this._selectedMonth + offset, 1); if (offset < 0) { date.setDate(this._getDaysInMonth(date.getFullYear(), date.getMonth())); } return this._isInRange(date); }, /* Is the given date in the accepted range? */ _isInRange: function(date) { // during range selection, use minimum of selected date and range start var newMinDate = (!this._rangeStart ? null : new Date(this._selectedYear, this._selectedMonth, this._selectedDay)); newMinDate = (newMinDate && this._rangeStart < newMinDate ? this._rangeStart : newMinDate); var minDate = newMinDate || this._get('minDate'); var maxDate = this._get('maxDate'); return ((!minDate || date >= minDate) && (!maxDate || date <= maxDate)); }, /* Format the given date for display. */ _formatDate: function(day, month, year) { if (!day) { this._currentDay = this._selectedDay; this._currentMonth = this._selectedMonth; this._currentYear = this._selectedYear; } var date = (day ? (typeof day == 'object' ? day : new Date(year, month, day)) : new Date(this._currentYear, this._currentMonth, this._currentDay)); return date.toString(this._get('dateFormat')); } }); /* jQuery extend now ignores nulls! */ function extendRemove(target, props) { $.extend(target, props); for (var name in props) { if (props[name] == null) { target[name] = null; } } return target; }; /* Attach the date picker to a jQuery selection. @param settings object - the new settings to use for this date picker instance (anonymous) @return jQuery object - for chaining further calls */ $.fn.datepicker = function(settings) { return this.each(function() { // check for settings on the control itself - in namespace 'date:' var inlineSettings = null; for (attrName in $.datepicker._defaults) { var attrValue = this.getAttribute('date:' + attrName); if (attrValue) { inlineSettings = inlineSettings || {}; try { inlineSettings[attrName] = eval(attrValue); } catch (err) { inlineSettings[attrName] = attrValue; } } } var nodeName = this.nodeName.toLowerCase(); if (nodeName == 'input') { var instSettings = (inlineSettings ? $.extend($.extend({}, settings || {}), inlineSettings || {}) : settings); // clone and customise var inst = (inst && !inlineSettings ? inst : new DatepickerInstance(instSettings, false)); $.datepicker._connectDatepicker(this, inst); } else if (nodeName == 'div' || nodeName == 'span') { var instSettings = $.extend($.extend({}, settings || {}), inlineSettings || {}); // clone and customise var inst = new DatepickerInstance(instSettings, true); $.datepicker._inlineDatepicker(this, inst); } }); }; /* Initialise the date picker. */ $(document).ready(function() { $.datepicker = new Datepicker(); // singleton instance $(document.body).append($.datepicker._datepickerDiv). mousedown($.datepicker._checkExternalClick); }); })(jQuery); ================================================ FILE: tests/parseExact/index.html ================================================ Datejs Test Cases : parseExact

parseExact

================================================ FILE: tests/parseExact/index.js ================================================ Date.Specification = new Specification({ 'Specific Format': { setup: function() { this.baseline = new Date(2004,6,1); this.baseline2 = new Date(2004,6,15); }, '2008/1/1 : "yyyy/M/d"': { run: function() { this.date = Date.parseExact('2008/1/1', "yyyy/M/d") }, assert: function() { return new Date(2008, 0, 1).equals(this.date) } }, '2008/1/5 : "yyyy/M/d"': { run: function() { this.date = Date.parseExact('2008/1/5', "yyyy/M/d") }, assert: function() { return new Date(2008, 0, 5).equals(this.date) } }, '2008/1/31 : "yyyy/M/d"': { run: function() { this.date = Date.parseExact('2008/1/31', "yyyy/M/d") }, assert: function() { return new Date(2008, 0, 31).equals(this.date) } }, '04/07/15 : "yy/MM/dd"': { run: function() { this.date = Date.parseExact('04/07/15', "yy/MM/dd" ) }, assert: function() { return this.baseline2.equals( this.date ) } }, '04/7/15 : "yy/M/d"': { run: function() { this.date = Date.parseExact('04/7/15', "yy/M/d" ) }, assert: function() { return this.baseline2.equals( this.date ) } }, '2004/1/7 : "yyyy/d/M"': { run: function() { this.date = Date.parseExact('2004/1/7', "yyyy/d/M" ) }, assert: function() { return this.baseline.equals( this.date ) } }, '2004/01/07 : "yyyy/dd/MM"': { run: function() { this.date = Date.parseExact('2004/01/07', "yyyy/dd/MM" ) }, assert: function() { return this.baseline.equals( this.date ) } }, '04/01/07 : "yy/dd/MM"': { run: function() { this.date = Date.parseExact('04/01/07', "yy/dd/MM" ) }, assert: function() { return this.baseline.equals( this.date ) } }, '04/1/7 : "yy/d/M"': { run: function() { this.date = Date.parseExact('04/1/7', "yy/d/M" ) }, assert: function() { return this.baseline.equals( this.date ) } }, '2004/15/7 : "yyyy/d/M"': { run: function() { this.date = Date.parseExact('2004/15/7', "yyyy/d/M" ) }, assert: function() { return this.baseline2.equals( this.date ) } }, '2004/15/07 : "yyyy/dd/MM"': { run: function() { this.date = Date.parseExact('2004/15/07', "yyyy/dd/MM" ) }, assert: function() { return this.baseline2.equals( this.date ) } }, '04/15/07 : "yy/dd/MM"': { run: function() { this.date = Date.parseExact('04/15/07', "yy/dd/MM" ) }, assert: function() { return this.baseline2.equals( this.date ) } }, '04/15/7 : "yy/d/M"': { run: function() { this.date = Date.parseExact('04/15/7', "yy/d/M" ) }, assert: function() { return this.baseline2.equals( this.date ) } }, '1/7/2004 : "d/M/yyyy"': { run: function() { this.date = Date.parseExact('1/7/2004', 'd/M/yyyy' ) }, assert: function() { return this.baseline.equals( this.date ) } }, '01/07/2004 : "dd/MM/yyyy"': { run: function() { this.date = Date.parseExact('01/07/2004', 'dd/MM/yyyy' ) }, assert: function() { return this.baseline.equals( this.date ) } }, '01/07/04 : "dd/MM/yy"': { run: function() { this.date = Date.parseExact('01/07/04', 'dd/MM/yy' ) }, assert: function() { return this.baseline.equals( this.date ) } }, '15/7/2004 : "d/M/yyyy"': { run: function() { this.date = Date.parseExact('15/7/2004', 'd/M/yyyy' ) }, assert: function() { return this.baseline2.equals( this.date ) } }, '15/07/2004 : "d/M/yyyy"': { run: function() { this.date = Date.parseExact('15/07/2004', 'd/M/yyyy' ) }, assert: function() { return this.baseline2.equals( this.date ) } }, '15/07/04 : "d/MM/yy"': { run: function() { this.date = Date.parseExact('15/07/04', 'd/MM/yy' ) }, assert: function() { return this.baseline2.equals( this.date ) } }, '2004 : "yyyy"': { run: function() { this.date = Date.parseExact('2004', 'yyyy' ) }, assert: function() { return Date.today().set({ year: 2004, day: 1 }).equals( this.date ) } }, 'July 2004 : "MMMM, yyyy"': { run: function() { this.date = Date.parseExact('July 2004', 'MMMM yyyy') }, assert: function() { return new Date(2004, 6, 1).equals( this.date ); } }, 'March 15, 2004 : "MMMM d, yyyy"': { run: function() { this.date = Date.parseExact('March 15, 2004', 'MMMM d, yyyy') }, assert: function() { return new Date(2004, 2, 15).equals( this.date ); } }, '00:15 pm : "hh:mm tt"': { run: function() { this.date = Date.parseExact('00:15 pm', 'hh:mm tt').set({millisecond: 0, second: 0}) }, assert: function() { return new Date().set({millisecond: 0, hour: 0, minute: 15, second: 0}).equals(this.date); } }, '12:15 am : "hh:mm tt"': { run: function() { this.date = Date.parseExact('12:15 am', 'hh:mm tt').set({millisecond: 0, second: 0}) }, assert: function() { return new Date().set({millisecond: 0, hour: 0, minute: 15, second: 0}).equals(this.date); } }, '12:15 pm : "hh:mm tt"': { run: function() { this.date = Date.parseExact('12:15 pm', 'hh:mm tt').set({millisecond: 0, second: 0}) }, assert: function() { return new Date().set({millisecond: 0, hour: 12, minute: 15, second: 0}).equals(this.date); } } } }); $(document).ready( function() { Date.Specification.validate().show() } ); ================================================ FILE: tests/partial/index.html ================================================ Datejs Test Cases : Partial

Partial

================================================ FILE: tests/partial/index.js ================================================ Date.Specification = new Specification({ 'Partial Date: No Year': { setup: function() { this.today = new Date().clearTime(); this.baseline = []; this.baseline[0] = this.today.clone().set( { month: 6, day: 1 } ) this.baseline[1] = this.today.clone().set( { month: 6, day: 1, hour: 22 } ); this.baseline[2] = this.today.clone().set( { month: 6, day: 1, hour: 22, minute: 30 } ); this.baseline[3] = this.today.clone().set( { month: 6, day: 15 } ) this.baseline[4] = this.today.clone().set( { month: 6, day: 15, hour: 6 } ); this.baseline[5] = this.today.clone().set( { month: 6, day: 15, hour: 6, minute: 45 } ); }, '7/1 10 PM': { run: function() { this.date = Date.parse('7/1 10 PM') }, assert: function() { return this.baseline[1].compareTo( this.date ) == 0 } }, '07/01 10 PM': { run: function() { this.date = Date.parse('07/01 10 PM') }, assert: function() { return this.baseline[1].compareTo( this.date ) == 0 } }, '07/01 10 PM': { run: function() { this.date = Date.parse('07/01 10 PM') }, assert: function() { return this.baseline[1].compareTo( this.date ) == 0 } }, '7/1 10 PM': { run: function() { this.date = Date.parse('7/1 10 PM') }, assert: function() { return this.baseline[1].compareTo( this.date ) == 0 } }, '7/15 6 AM': { run: function() { this.date = Date.parse('7/15 6 AM') }, assert: function() { return this.baseline[4].compareTo( this.date ) == 0 } }, '07/15 6 AM': { run: function() { this.date = Date.parse('07/15 6 AM') }, assert: function() { return this.baseline[4].compareTo( this.date ) == 0 } }, '07/15 6 AM': { run: function() { this.date = Date.parse('07/15 6 AM') }, assert: function() { return this.baseline[4].compareTo( this.date ) == 0 } }, '7/15 6 AM': { run: function() { this.date = Date.parse('7/15 6 AM') }, assert: function() { return this.baseline[4].compareTo( this.date ) == 0 } }, '7/1 10pm': { run: function() { this.date = Date.parse('7/1 10pm') }, assert: function() { return this.baseline[1].compareTo( this.date ) == 0 } }, '07/01 10pm': { run: function() { this.date = Date.parse('07/01 10pm') }, assert: function() { return this.baseline[1].compareTo( this.date ) == 0 } }, '07/01 10pm': { run: function() { this.date = Date.parse('07/01 10pm') }, assert: function() { return this.baseline[1].compareTo( this.date ) == 0 } }, '7/1 10pm': { run: function() { this.date = Date.parse('7/1 10pm') }, assert: function() { return this.baseline[1].compareTo( this.date ) == 0 } }, '7/15 6am': { run: function() { this.date = Date.parse('7/15 6am') }, assert: function() { return this.baseline[4].compareTo( this.date ) == 0 } }, '07/15 6am': { run: function() { this.date = Date.parse('07/15 6am') }, assert: function() { return this.baseline[4].compareTo( this.date ) == 0 } }, '07/15 6am': { run: function() { this.date = Date.parse('07/15 6am') }, assert: function() { return this.baseline[4].compareTo( this.date ) == 0 } }, '7/15 6am': { run: function() { this.date = Date.parse('7/15 6am') }, assert: function() { return this.baseline[4].equals( this.date ) } }, '7/1 10:30 PM': { run: function() { this.date = Date.parse('7/1 10:30 PM') }, assert: function() { return this.baseline[2].equals( this.date ) } }, '07/01 10:30 PM': { run: function() { this.date = Date.parse('07/01 10:30 PM') }, assert: function() { return this.baseline[2].equals( this.date ) } }, '07/01 10:30 PM': { run: function() { this.date = Date.parse('07/01 10:30 PM') }, assert: function() { return this.baseline[2].equals( this.date ) } }, '7/1 10:30 PM': { run: function() { this.date = Date.parse('7/1 10:30 PM') }, assert: function() { return this.baseline[2].equals( this.date ) } }, '7/15 6:45 AM': { run: function() { this.date = Date.parse('7/15 6:45 AM') }, assert: function() { return this.baseline[5].equals( this.date ) } }, '07/15 6:45 AM': { run: function() { this.date = Date.parse('07/15 6:45 AM') }, assert: function() { return this.baseline[5].equals( this.date ) } }, '07/15 6:45 AM': { run: function() { this.date = Date.parse('07/15 6:45 AM') }, assert: function() { return this.baseline[5].equals( this.date ) } }, '7/15 6:45 AM': { run: function() { this.date = Date.parse('7/15 6:45 AM') }, assert: function() { return this.baseline[5].equals( this.date ) } }, '7/1 10:30p': { run: function() { this.date = Date.parse('7/1 10:30p') }, assert: function() { return this.baseline[2].equals( this.date ) } }, '07/01 10:30p': { run: function() { this.date = Date.parse('07/01 10:30p') }, assert: function() { return this.baseline[2].equals( this.date ) } }, '07/01 10:30p': { run: function() { this.date = Date.parse('07/01 10:30p') }, assert: function() { return this.baseline[2].equals( this.date ) } }, '7/1 10:30p': { run: function() { this.date = Date.parse('7/1 10:30p') }, assert: function() { return this.baseline[2].equals( this.date ) } }, '7/15 6:45a': { run: function() { this.date = Date.parse('7/15 6:45a') }, assert: function() { return this.baseline[5].equals( this.date ) } }, '07/15 6:45a': { run: function() { this.date = Date.parse('07/15 6:45a') }, assert: function() { return this.baseline[5].equals( this.date ) } }, '07/15 6:45a': { run: function() { this.date = Date.parse('07/15 6:45a') }, assert: function() { return this.baseline[5].equals( this.date ) } }, '7/15 6:45a': { run: function() { this.date = Date.parse('7/15 6:45a') }, assert: function() { return this.baseline[5].equals( this.date ) } }, '1-Jul': { run: function() { this.date = Date.parse('1-Jul') }, assert: function() { return this.baseline[0].equals( this.date ) } }, '1-July': { run: function() { this.date = Date.parse('1-July') }, assert: function() { return this.baseline[0].equals( this.date ) } }, '01-Jul': { run: function() { this.date = Date.parse('01-Jul') }, assert: function() { return this.baseline[0].equals( this.date ) } }, '01-July': { run: function() { this.date = Date.parse('01-July') }, assert: function() { return this.baseline[0].equals( this.date ) } }, '15-Jul': { run: function() { this.date = Date.parse('15-Jul') }, assert: function() { return this.baseline[3].equals( this.date ) } }, '15-July': { run: function() { this.date = Date.parse('15-July') }, assert: function() { return this.baseline[3].equals( this.date ) } }, 'July 1': { run: function() { this.date = Date.parse('July 1') }, assert: function() { return this.baseline[0].equals( this.date ) } }, 'Jul 1': { run: function() { this.date = Date.parse('Jul 1') }, assert: function() { return this.baseline[0].equals( this.date ) } }, 'July 01': { run: function() { this.date = Date.parse('July 01') }, assert: function() { return this.baseline[0].equals( this.date ) } }, 'Jul 01': { run: function() { this.date = Date.parse('Jul 01') }, assert: function() { return this.baseline[0].equals( this.date ) } }, 'July 15': { run: function() { this.date = Date.parse('July 15') }, assert: function() { return this.baseline[3].equals( this.date ) } }, 'Jul 15': { run: function() { this.date = Date.parse('Jul 15') }, assert: function() { return this.baseline[3].equals( this.date ) } }, 'July 1st': { run: function() { this.date = Date.parse('July 1st') }, assert: function() { return this.baseline[0].equals( this.date ) } }, 'July 2nd': { run: function() { this.date = Date.parse('July 2nd') }, assert: function() { return this.baseline[0].addDays(1).equals( this.date ) } }, 'July 3rd': { run: function() { this.date = Date.parse('July 3rd') }, assert: function() { return this.baseline[0].addDays(2).equals( this.date ) } }, 'July 4th': { run: function() { this.date = Date.parse('July 4th') }, assert: function() { return this.baseline[0].addDays(3).equals( this.date ) } }, '7/1': { run: function() { this.date = Date.parse('7/1') }, assert: function() { return this.baseline[0].equals( this.date ) } }, '07/01': { run: function() { this.date = Date.parse('07/01') }, assert: function() { return this.baseline[0].equals( this.date ) } }, '7/15': { run: function() { this.date = Date.parse('7/15') }, assert: function() { return this.baseline[3].equals( this.date ) } }, '07/15': { run: function() { this.date = Date.parse('07/15') }, assert: function() { return this.baseline[3].equals( this.date ) } } }, 'No Day: Default To First Of Month': { setup: function() { this.baseline = new Date(2008,6,1); }, 'Jan 2008': { run: function() { this.date = Date.parse('Jan 2008') }, assert: function() { return Date.today().set({year: 2008, month: 0, day: 1}).equals( this.date ) } }, 'January 2008': { run: function() { this.date = Date.parse('January 2008') }, assert: function() { return Date.today().set({year: 2008, month: 0, day: 1}).equals( this.date ) } }, 'Feb 2008': { run: function() { this.date = Date.parse('Feb 2008') }, assert: function() { return Date.today().set({year: 2008, month: 1, day: 1}).equals( this.date ) } }, 'February 2008': { run: function() { this.date = Date.parse('February 2008') }, assert: function() { return Date.today().set({year: 2008, month: 1, day: 1}).equals( this.date ) } }, 'Mar 2008': { run: function() { this.date = Date.parse('Mar 2008') }, assert: function() { return Date.today().set({year: 2008, month: 2, day: 1}).equals( this.date ) } }, 'March 2008': { run: function() { this.date = Date.parse('March 2008') }, assert: function() { return Date.today().set({year: 2008, month: 2, day: 1}).equals( this.date ) } }, 'Apr 2008': { run: function() { this.date = Date.parse('Apr 2008') }, assert: function() { return Date.today().set({year: 2008, month: 3, day: 1}).equals( this.date ) } }, 'April 2008': { run: function() { this.date = Date.parse('April 2008') }, assert: function() { return Date.today().set({year: 2008, month: 3, day: 1}).equals( this.date ) } }, 'May 2008': { run: function() { this.date = Date.parse('May 2008') }, assert: function() { return Date.today().set({year: 2008, month: 4, day: 1}).equals( this.date ) } }, 'Jun 2008': { run: function() { this.date = Date.parse('Jun 2008') }, assert: function() { return Date.today().set({year: 2008, month: 5, day: 1}).equals( this.date ) } }, 'June 2008': { run: function() { this.date = Date.parse('June 2008') }, assert: function() { return Date.today().set({year: 2008, month: 5, day: 1}).equals( this.date ) } }, 'Jul 2008': { run: function() { this.date = Date.parse('Jul 2008') }, assert: function() { return Date.today().set({year: 2008, month: 6, day: 1}).equals( this.date ) } }, 'July 2008': { run: function() { this.date = Date.parse('July 2008') }, assert: function() { return Date.today().set({year: 2008, month: 6, day: 1}).equals( this.date ) } }, 'Aug 2008': { run: function() { this.date = Date.parse('Aug 2008') }, assert: function() { return Date.today().set({year: 2008, month: 7, day: 1}).equals( this.date ) } }, 'August 2008': { run: function() { this.date = Date.parse('August 2008') }, assert: function() { return Date.today().set({year: 2008, month: 7, day: 1}).equals( this.date ) } }, 'Sep 2008': { run: function() { this.date = Date.parse('Sep 2008') }, assert: function() { return Date.today().set({year: 2008, month: 8, day: 1}).equals( this.date ) } }, 'Sept 2008': { run: function() { this.date = Date.parse('Sept 2008') }, assert: function() { return Date.today().set({year: 2008, month: 8, day: 1}).equals( this.date ) } }, 'September 2008': { run: function() { this.date = Date.parse('September 2008') }, assert: function() { return Date.today().set({year: 2008, month: 8, day: 1}).equals( this.date ) } }, 'Oct 2008': { run: function() { this.date = Date.parse('Oct 2008') }, assert: function() { return Date.today().set({year: 2008, month: 9, day: 1}).equals( this.date ) } }, 'October 2008': { run: function() { this.date = Date.parse('October 2008') }, assert: function() { return Date.today().set({year: 2008, month: 9, day: 1}).equals( this.date ) } }, 'Nov 2008': { run: function() { this.date = Date.parse('November 2008') }, assert: function() { return Date.today().set({year: 2008, month: 10, day: 1}).equals( this.date ) } }, 'November 2008': { run: function() { this.date = Date.parse('November 2008') }, assert: function() { return Date.today().set({year: 2008, month: 10, day: 1}).equals( this.date ) } }, 'Dec 2008': { run: function() { this.date = Date.parse('Dec 2008') }, assert: function() { return Date.today().set({year: 2008, month: 11, day: 1}).equals( this.date ) } }, 'December 2008': { run: function() { this.date = Date.parse('December 2008') }, assert: function() { return Date.today().set({year: 2008, month: 11, day: 1}).equals( this.date ) } }, '1/2008': { run: function() { this.date = Date.parse('1/2008') }, assert: function() { return Date.today().set({year: 2008, month: 0, day: 1}).equals( this.date ) } }, '2/2008': { run: function() { this.date = Date.parse('2/2008') }, assert: function() { return Date.today().set({year: 2008, month: 1, day: 1}).equals( this.date ) } }, '3/2008': { run: function() { this.date = Date.parse('3/2008') }, assert: function() { return Date.today().set({year: 2008, month: 2, day: 1}).equals( this.date ) } }, '4/2008': { run: function() { this.date = Date.parse('4/2008') }, assert: function() { return Date.today().set({year: 2008, month: 3, day: 1}).equals( this.date ) } }, '5/2008': { run: function() { this.date = Date.parse('5/2008') }, assert: function() { return Date.today().set({year: 2008, month: 4, day: 1}).equals( this.date ) } }, '6/2008': { run: function() { this.date = Date.parse('6/2008') }, assert: function() { return Date.today().set({year: 2008, month: 5, day: 1}).equals( this.date ) } }, '7/2008': { run: function() { this.date = Date.parse('7/2008') }, assert: function() { return Date.today().set({year: 2008, month: 6, day: 1}).equals( this.date ) } }, '8/2008': { run: function() { this.date = Date.parse('8/2008') }, assert: function() { return Date.today().set({year: 2008, month: 7, day: 1}).equals( this.date ) } }, '9/2008': { run: function() { this.date = Date.parse('9/2008') }, assert: function() { return Date.today().set({year: 2008, month: 8, day: 1}).equals( this.date ) } }, '10/2008': { run: function() { this.date = Date.parse('10/2008') }, assert: function() { return Date.today().set({year: 2008, month: 9, day: 1}).equals( this.date ) } }, '11/2008': { run: function() { this.date = Date.parse('11/2008') }, assert: function() { return Date.today().set({year: 2008, month: 10, day: 1}).equals( this.date ) } }, '12/2008': { run: function() { this.date = Date.parse('12/2008') }, assert: function() { return Date.today().set({year: 2008, month: 11, day: 1}).equals( this.date ) } }, '1 2008': { run: function() { this.date = Date.parse('1 2008') }, assert: function() { return Date.today().set({year: 2008, month: 0, day: 1}).equals( this.date ) } }, '2 2008': { run: function() { this.date = Date.parse('2 2008') }, assert: function() { return Date.today().set({year: 2008, month: 1, day: 1}).equals( this.date ) } }, '3 2008': { run: function() { this.date = Date.parse('3 2008') }, assert: function() { return Date.today().set({year: 2008, month: 2, day: 1}).equals( this.date ) } }, '4 2008': { run: function() { this.date = Date.parse('4 2008') }, assert: function() { return Date.today().set({year: 2008, month: 3, day: 1}).equals( this.date ) } }, '5 2008': { run: function() { this.date = Date.parse('5 2008') }, assert: function() { return Date.today().set({year: 2008, month: 4, day: 1}).equals( this.date ) } }, '6 2008': { run: function() { this.date = Date.parse('6 2008') }, assert: function() { return Date.today().set({year: 2008, month: 5, day: 1}).equals( this.date ) } }, '7 2008': { run: function() { this.date = Date.parse('7 2008') }, assert: function() { return Date.today().set({year: 2008, month: 6, day: 1}).equals( this.date ) } }, '8 2008': { run: function() { this.date = Date.parse('8 2008') }, assert: function() { return Date.today().set({year: 2008, month: 7, day: 1}).equals( this.date ) } }, '9 2008': { run: function() { this.date = Date.parse('9 2008') }, assert: function() { return Date.today().set({year: 2008, month: 8, day: 1}).equals( this.date ) } }, '10 2008': { run: function() { this.date = Date.parse('10 2008') }, assert: function() { return Date.today().set({year: 2008, month: 9, day: 1}).equals( this.date ) } }, '11 2008': { run: function() { this.date = Date.parse('11 2008') }, assert: function() { return Date.today().set({year: 2008, month: 10, day: 1}).equals( this.date ) } }, '12 2008': { run: function() { this.date = Date.parse('12 2008') }, assert: function() { return Date.today().set({year: 2008, month: 11, day: 1}).equals( this.date ) } }, '1-2008': { run: function() { this.date = Date.parse('1-2008') }, assert: function() { return Date.today().set({year: 2008, month: 0, day: 1}).equals( this.date ) } }, '2-2008': { run: function() { this.date = Date.parse('2-2008') }, assert: function() { return Date.today().set({year: 2008, month: 1, day: 1}).equals( this.date ) } }, '3-2008': { run: function() { this.date = Date.parse('3-2008') }, assert: function() { return Date.today().set({year: 2008, month: 2, day: 1}).equals( this.date ) } }, '4-2008': { run: function() { this.date = Date.parse('4-2008') }, assert: function() { return Date.today().set({year: 2008, month: 3, day: 1}).equals( this.date ) } }, '5-2008': { run: function() { this.date = Date.parse('5-2008') }, assert: function() { return Date.today().set({year: 2008, month: 4, day: 1}).equals( this.date ) } }, '6-2008': { run: function() { this.date = Date.parse('6-2008') }, assert: function() { return Date.today().set({year: 2008, month: 5, day: 1}).equals( this.date ) } }, '7-2008': { run: function() { this.date = Date.parse('7-2008') }, assert: function() { return Date.today().set({year: 2008, month: 6, day: 1}).equals( this.date ) } }, '8-2008': { run: function() { this.date = Date.parse('8-2008') }, assert: function() { return Date.today().set({year: 2008, month: 7, day: 1}).equals( this.date ) } }, '9-2008': { run: function() { this.date = Date.parse('9-2008') }, assert: function() { return Date.today().set({year: 2008, month: 8, day: 1}).equals( this.date ) } }, '10-2008': { run: function() { this.date = Date.parse('10-2008') }, assert: function() { return Date.today().set({year: 2008, month: 9, day: 1}).equals( this.date ) } }, '11-2008': { run: function() { this.date = Date.parse('11-2008') }, assert: function() { return Date.today().set({year: 2008, month: 10, day: 1}).equals( this.date ) } }, '12-2008': { run: function() { this.date = Date.parse('12-2008') }, assert: function() { return Date.today().set({year: 2008, month: 11, day: 1}).equals( this.date ) } }, '2008/1': { run: function() { this.date = Date.parse('2008/1') }, assert: function() { return Date.today().set({year: 2008, month: 0, day: 1}).equals( this.date ) } }, '2008/2': { run: function() { this.date = Date.parse('2008/2') }, assert: function() { return Date.today().set({year: 2008, month: 1, day: 1}).equals( this.date ) } }, '2008/3': { run: function() { this.date = Date.parse('2008/3') }, assert: function() { return Date.today().set({year: 2008, month: 2, day: 1}).equals( this.date ) } }, '2008/4': { run: function() { this.date = Date.parse('2008/4') }, assert: function() { return Date.today().set({year: 2008, month: 3, day: 1}).equals( this.date ) } }, '2008/5': { run: function() { this.date = Date.parse('2008/5') }, assert: function() { return Date.today().set({year: 2008, month: 4, day: 1}).equals( this.date ) } }, '2008/6': { run: function() { this.date = Date.parse('2008/6') }, assert: function() { return Date.today().set({year: 2008, month: 5, day: 1}).equals( this.date ) } }, '2008/7': { run: function() { this.date = Date.parse('2008/7') }, assert: function() { return Date.today().set({year: 2008, month: 6, day: 1}).equals( this.date ) } }, '2008/8': { run: function() { this.date = Date.parse('2008/8') }, assert: function() { return Date.today().set({year: 2008, month: 7, day: 1}).equals( this.date ) } }, '2008/9': { run: function() { this.date = Date.parse('2008/9') }, assert: function() { return Date.today().set({year: 2008, month: 8, day: 1}).equals( this.date ) } }, '2008/10': { run: function() { this.date = Date.parse('2008/10') }, assert: function() { return Date.today().set({year: 2008, month: 9, day: 1}).equals( this.date ) } }, '2008/11': { run: function() { this.date = Date.parse('2008/11') }, assert: function() { return Date.today().set({year: 2008, month: 10, day: 1}).equals( this.date ) } }, '2008/12': { run: function() { this.date = Date.parse('2008/12') }, assert: function() { return Date.today().set({year: 2008, month: 11, day: 1}).equals( this.date ) } }, '2008-1': { run: function() { this.date = Date.parse('2008-1') }, assert: function() { return Date.today().set({year: 2008, month: 0, day: 1}).equals( this.date ) } }, '2008-2': { run: function() { this.date = Date.parse('2008-2') }, assert: function() { return Date.today().set({year: 2008, month: 1, day: 1}).equals( this.date ) } }, '2008-3': { run: function() { this.date = Date.parse('2008-3') }, assert: function() { return Date.today().set({year: 2008, month: 2, day: 1}).equals( this.date ) } }, '2008-4': { run: function() { this.date = Date.parse('2008-4') }, assert: function() { return Date.today().set({year: 2008, month: 3, day: 1}).equals( this.date ) } }, '2008-5': { run: function() { this.date = Date.parse('2008-5') }, assert: function() { return Date.today().set({year: 2008, month: 4, day: 1}).equals( this.date ) } }, '2008-6': { run: function() { this.date = Date.parse('2008-6') }, assert: function() { return Date.today().set({year: 2008, month: 5, day: 1}).equals( this.date ) } }, '2008-7': { run: function() { this.date = Date.parse('2008-7') }, assert: function() { return Date.today().set({year: 2008, month: 6, day: 1}).equals( this.date ) } }, '2008-8': { run: function() { this.date = Date.parse('2008-8') }, assert: function() { return Date.today().set({year: 2008, month: 7, day: 1}).equals( this.date ) } }, '2008-9': { run: function() { this.date = Date.parse('2008-9') }, assert: function() { return Date.today().set({year: 2008, month: 8, day: 1}).equals( this.date ) } }, '2008-10': { run: function() { this.date = Date.parse('2008-10') }, assert: function() { return Date.today().set({year: 2008, month: 9, day: 1}).equals( this.date ) } }, '2008-11': { run: function() { this.date = Date.parse('2008-11') }, assert: function() { return Date.today().set({year: 2008, month: 10, day: 1}).equals( this.date ) } }, '2008-12': { run: function() { this.date = Date.parse('2008-12') }, assert: function() { return Date.today().set({year: 2008, month: 11, day: 1}).equals( this.date ) } }, '2008 1': { run: function() { this.date = Date.parse('2008 1') }, assert: function() { return Date.today().set({year: 2008, month: 0, day: 1}).equals( this.date ) } }, '2008 2': { run: function() { this.date = Date.parse('2008 2') }, assert: function() { return Date.today().set({year: 2008, month: 1, day: 1}).equals( this.date ) } }, '2008 3': { run: function() { this.date = Date.parse('2008 3') }, assert: function() { return Date.today().set({year: 2008, month: 2, day: 1}).equals( this.date ) } }, '2008 4': { run: function() { this.date = Date.parse('2008 4') }, assert: function() { return Date.today().set({year: 2008, month: 3, day: 1}).equals( this.date ) } }, '2008 5': { run: function() { this.date = Date.parse('2008 5') }, assert: function() { return Date.today().set({year: 2008, month: 4, day: 1}).equals( this.date ) } }, '2008 6': { run: function() { this.date = Date.parse('2008 6') }, assert: function() { return Date.today().set({year: 2008, month: 5, day: 1}).equals( this.date ) } }, '2008 7': { run: function() { this.date = Date.parse('2008 7') }, assert: function() { return Date.today().set({year: 2008, month: 6, day: 1}).equals( this.date ) } }, '2008 8': { run: function() { this.date = Date.parse('2008 8') }, assert: function() { return Date.today().set({year: 2008, month: 7, day: 1}).equals( this.date ) } }, '2008 9': { run: function() { this.date = Date.parse('2008 9') }, assert: function() { return Date.today().set({year: 2008, month: 8, day: 1}).equals( this.date ) } }, '2008 10': { run: function() { this.date = Date.parse('2008 10') }, assert: function() { return Date.today().set({year: 2008, month: 9, day: 1}).equals( this.date ) } }, '2008 11': { run: function() { this.date = Date.parse('2008 11') }, assert: function() { return Date.today().set({year: 2008, month: 10, day: 1}).equals( this.date ) } }, '2008 12': { run: function() { this.date = Date.parse('2008 12') }, assert: function() { return Date.today().set({year: 2008, month: 11, day: 1}).equals( this.date ) } } }, 'No Year or Month': { setup: function() { //default to current Year and Month this.baseline = new Date(2004,6,1); this.today = Date.today(); this.now = new Date(); }, '1': { run: function() { }, assert: function() { return Date.today().set({day: 1}).equals(Date.parse('1')) } }, '2': { run: function() { }, assert: function() { return Date.today().set({day: 2}).equals(Date.parse('2')) } }, '3': { run: function() { }, assert: function() { return Date.today().set({day: 3}).equals(Date.parse('3')) } }, '4': { run: function() { }, assert: function() { return Date.today().set({day: 4}).equals(Date.parse('4')) } }, '5': { run: function() { }, assert: function() { return Date.today().set({day: 5}).equals(Date.parse('5')) } }, '6': { run: function() { }, assert: function() { return Date.today().set({day: 6}).equals(Date.parse('6')) } }, '7': { run: function() { }, assert: function() { return Date.today().set({day: 7}).equals(Date.parse('7')) } }, '8': { run: function() { }, assert: function() { return Date.today().set({day: 8}).equals(Date.parse('8')) } }, '9': { run: function() { }, assert: function() { return Date.today().set({day: 9}).equals(Date.parse('9')) } }, '10': { run: function() { }, assert: function() { return Date.today().set({day: 10}).equals(Date.parse('10')) } }, '11': { run: function() { }, assert: function() { return Date.today().set({day: 11}).equals(Date.parse('11')) } }, '12': { run: function() { }, assert: function() { return Date.today().set({day: 12}).equals(Date.parse('12')) } }, '13': { run: function() { }, assert: function() { return Date.today().set({day: 13}).equals(Date.parse('13')) } }, '14': { run: function() { }, assert: function() { return Date.today().set({day: 14}).equals(Date.parse('14')) } }, '15': { run: function() { }, assert: function() { return Date.today().set({day: 15}).equals(Date.parse('15')) } }, '16': { run: function() { }, assert: function() { return Date.today().set({day: 16}).equals(Date.parse('16')) } }, '17': { run: function() { }, assert: function() { return Date.today().set({day: 17}).equals(Date.parse('17')) } }, '18': { run: function() { }, assert: function() { return Date.today().set({day: 18}).equals(Date.parse('18')) } }, '19': { run: function() { }, assert: function() { return Date.today().set({day: 19}).equals(Date.parse('19')) } }, '20': { run: function() { }, assert: function() { return Date.today().set({day: 20}).equals(Date.parse('20')) } }, '21': { run: function() { }, assert: function() { return Date.today().set({day: 21}).equals(Date.parse('21')) } }, '22': { run: function() { }, assert: function() { return Date.today().set({day: 22}).equals(Date.parse('22')) } }, '23': { run: function() { }, assert: function() { return Date.today().set({day: 23}).equals(Date.parse('23')) } }, '24': { run: function() { }, assert: function() { return Date.today().set({day: 24}).equals(Date.parse('24')) } }, '25': { run: function() { }, assert: function() { return Date.today().set({day: 25}).equals(Date.parse('25')) } }, '26': { run: function() { }, assert: function() { return Date.today().set({day: 26}).equals(Date.parse('26')) } }, '27': { run: function() { }, assert: function() { return Date.today().set({day: 27}).equals(Date.parse('27')) } }, '28': { run: function() { }, assert: function() { return Date.today().set({day: 28}).equals(Date.parse('28')) } }, '29 : Returns null if current month does not have 29 days': { run: function() { }, assert: function() { this.date = Date.parse('29'); if( this.date != null && Date.getDaysInMonth(this.today.getFullYear(), this.today.getMonth()) >= 29 ) { return true; } if( Date.getDaysInMonth(this.today.getFullYear(), this.today.getMonth()) < 29 && this.date == null ) { return true; } return false; } }, '30 : Returns null if current month does not have 30 days': { run: function() { }, assert: function() { this.date = Date.parse('30'); if( this.date != null && Date.getDaysInMonth(this.today.getFullYear(), this.today.getMonth()) >= 30 ) { return true; } if( Date.getDaysInMonth(this.today.getFullYear(), this.today.getMonth()) < 30 && this.date == null ) { return true; } return false; } }, '31 : Returns null if current month does not have 31 days': { run: function() { }, assert: function() { this.date = Date.parse('31'); if( this.date != null && Date.getDaysInMonth(this.today.getFullYear(), this.today.getMonth()) == 31 ) { return true; } if( Date.getDaysInMonth(this.today.getFullYear(), this.today.getMonth()) < 31 && this.date == null ) { return true; } return false; } }, '32 : Year 1932': { run: function() { }, assert: function() { return Date.today().set( { year: 1932 } ).equals( Date.parse('32') ); } }, '1st': { run: function() { }, assert: function() { return Date.today().set({day: 1}).equals(Date.parse('1st')) } }, '2nd': { run: function() { }, assert: function() { return Date.today().set({day: 2}).equals(Date.parse('2nd')) } }, '3rd': { run: function() { }, assert: function() { return Date.today().set({day: 3}).equals(Date.parse('3rd')) } }, '4th': { run: function() { }, assert: function() { return Date.today().set({day: 4}).equals(Date.parse('4th')) } }, '5th': { run: function() { }, assert: function() { return Date.today().set({day: 5}).equals(Date.parse('5th')) } }, '6th': { run: function() { }, assert: function() { return Date.today().set({day: 6}).equals(Date.parse('6th')) } }, '7th': { run: function() { }, assert: function() { return Date.today().set({day: 7}).equals(Date.parse('7th')) } }, '8th': { run: function() { }, assert: function() { return Date.today().set({day: 8}).equals(Date.parse('8th')) } }, '9th': { run: function() { }, assert: function() { return Date.today().set({day: 9}).equals(Date.parse('9th')) } }, '10th': { run: function() { }, assert: function() { return Date.today().set({day: 10}).equals(Date.parse('10th')) } }, '11th': { run: function() { }, assert: function() { return Date.today().set({day: 11}).equals(Date.parse('11th')) } }, '12th': { run: function() { }, assert: function() { return Date.today().set({day: 12}).equals(Date.parse('12th')) } }, '13th': { run: function() { }, assert: function() { return Date.today().set({day: 13}).equals(Date.parse('13th')) } }, '14th': { run: function() { }, assert: function() { return Date.today().set({day: 14}).equals(Date.parse('14th')) } }, '15th': { run: function() { }, assert: function() { return Date.today().set({day: 15}).equals(Date.parse('15th')) } }, '16th': { run: function() { }, assert: function() { return Date.today().set({day: 16}).equals(Date.parse('16th')) } }, '17th': { run: function() { }, assert: function() { return Date.today().set({day: 17}).equals(Date.parse('17th')) } }, '18th': { run: function() { }, assert: function() { return Date.today().set({day: 18}).equals(Date.parse('18th')) } }, '19th': { run: function() { }, assert: function() { return Date.today().set({day: 19}).equals(Date.parse('19th')) } }, '20th': { run: function() { }, assert: function() { return Date.today().set({day: 20}).equals(Date.parse('20th')) } }, '21st': { run: function() { }, assert: function() { return Date.today().set({day: 21}).equals(Date.parse('21st')) } }, '22nd': { run: function() { }, assert: function() { return Date.today().set({day: 22}).equals(Date.parse('22nd')) } }, '23rd': { run: function() { }, assert: function() { return Date.today().set({day: 23}).equals(Date.parse('23rd')) } }, '24th': { run: function() { }, assert: function() { return Date.today().set({day: 24}).equals(Date.parse('24th')) } }, '25th': { run: function() { }, assert: function() { return Date.today().set({day: 25}).equals(Date.parse('25th')) } }, '26th': { run: function() { }, assert: function() { return Date.today().set({day: 26}).equals(Date.parse('26th')) } }, '27th': { run: function() { }, assert: function() { return Date.today().set({day: 27}).equals(Date.parse('27th')) } }, '28th': { run: function() { }, assert: function() { return Date.today().set({day: 28}).equals(Date.parse('28th')) } }, '29th : Returns null if current month does not have 29 days': { run: function() { }, assert: function() { this.date = Date.parse('29th'); if( this.date != null && Date.getDaysInMonth(this.today.getFullYear(), this.today.getMonth()) >= 29 ) { return true; } if( Date.getDaysInMonth(this.today.getFullYear(), this.today.getMonth()) < 29 && this.date == null ) { return true; } return false; } }, '30th : Returns null if current month does not have 30 days': { run: function() { }, assert: function() { this.date = Date.parse('30th'); if( this.date != null && Date.getDaysInMonth(this.today.getFullYear(), this.today.getMonth()) >= 30 ) { return true; } if( Date.getDaysInMonth(this.today.getFullYear(), this.today.getMonth()) < 30 && this.date == null ) { return true; } return false; } }, '31st : Returns null if current month does not have 31 days': { run: function() { }, assert: function() { this.date = Date.parse('31st'); if( this.date != null && Date.getDaysInMonth(this.today.getFullYear(), this.today.getMonth()) == 31 ) { return true; } if( Date.getDaysInMonth(this.today.getFullYear(), this.today.getMonth()) < 31 && this.date == null ) { return true; } return false; } }, '1 st': { run: function() { }, assert: function() { return Date.today().set({day: 1}).equals(Date.parse('1 st')) } }, '2 nd': { run: function() { }, assert: function() { return Date.today().set({day: 2}).equals(Date.parse('2 nd')) } }, '3 rd': { run: function() { }, assert: function() { return Date.today().set({day: 3}).equals(Date.parse('3 rd')) } }, '4 th': { run: function() { }, assert: function() { return Date.today().set({day: 4}).equals(Date.parse('4 th')) } }, '5 th': { run: function() { }, assert: function() { return Date.today().set({day: 5}).equals(Date.parse('5 th')) } }, '6 th': { run: function() { }, assert: function() { return Date.today().set({day: 6}).equals(Date.parse('6 th')) } }, '7 th': { run: function() { }, assert: function() { return Date.today().set({day: 7}).equals(Date.parse('7 th')) } }, '8 th': { run: function() { }, assert: function() { return Date.today().set({day: 8}).equals(Date.parse('8 th')) } }, '9 th': { run: function() { }, assert: function() { return Date.today().set({day: 9}).equals(Date.parse('9 th')) } }, '10 th': { run: function() { }, assert: function() { return Date.today().set({day: 10}).equals(Date.parse('10 th')) } }, '11 th': { run: function() { }, assert: function() { return Date.today().set({day: 11}).equals(Date.parse('11 th')) } }, '12 th': { run: function() { }, assert: function() { return Date.today().set({day: 12}).equals(Date.parse('12 th')) } }, '13 th': { run: function() { }, assert: function() { return Date.today().set({day: 13}).equals(Date.parse('13 th')) } }, '14 th': { run: function() { }, assert: function() { return Date.today().set({day: 14}).equals(Date.parse('14 th')) } }, '15 th': { run: function() { }, assert: function() { return Date.today().set({day: 15}).equals(Date.parse('15 th')) } }, '16 th': { run: function() { }, assert: function() { return Date.today().set({day: 16}).equals(Date.parse('16 th')) } }, '17 th': { run: function() { }, assert: function() { return Date.today().set({day: 17}).equals(Date.parse('17 th')) } }, '18 th': { run: function() { }, assert: function() { return Date.today().set({day: 18}).equals(Date.parse('18 th')) } }, '19 th': { run: function() { }, assert: function() { return Date.today().set({day: 19}).equals(Date.parse('19 th')) } }, '20 th': { run: function() { }, assert: function() { return Date.today().set({day: 20}).equals(Date.parse('20 th')) } }, '21 st': { run: function() { }, assert: function() { return Date.today().set({day: 21}).equals(Date.parse('21 st')) } }, '22 nd': { run: function() { }, assert: function() { return Date.today().set({day: 22}).equals(Date.parse('22 nd')) } }, '23 rd': { run: function() { }, assert: function() { return Date.today().set({day: 23}).equals(Date.parse('23 rd')) } }, '24 th': { run: function() { }, assert: function() { return Date.today().set({day: 24}).equals(Date.parse('24 th')) } }, '25 th': { run: function() { }, assert: function() { return Date.today().set({day: 25}).equals(Date.parse('25 th')) } }, '26 th': { run: function() { }, assert: function() { return Date.today().set({day: 26}).equals(Date.parse('26 th')) } }, '27 th': { run: function() { }, assert: function() { return Date.today().set({day: 27}).equals(Date.parse('27 th')) } }, '28 th': { run: function() { }, assert: function() { return Date.today().set({day: 28}).equals(Date.parse('28 th')) } }, '29 th : Returns null if current month does not have 29 days': { run: function() { }, assert: function() { this.date = Date.parse('29 th'); if( this.date != null && Date.getDaysInMonth(this.today.getFullYear(), this.today.getMonth()) >= 29 ) { return true; } if( Date.getDaysInMonth(this.today.getFullYear(), this.today.getMonth()) < 29 && this.date == null ) { return true; } return false; } }, '30 th : Returns null if current month does not have 30 days': { run: function() { }, assert: function() { this.date = Date.parse('30 th'); if( this.date != null && Date.getDaysInMonth(this.today.getFullYear(), this.today.getMonth()) >= 30 ) { return true; } if( Date.getDaysInMonth(this.today.getFullYear(), this.today.getMonth()) < 30 && this.date == null ) { return true; } return false; } }, '31 st : Returns null if current month does not have 31 days': { run: function() { }, assert: function() { this.date = Date.parse('31 st'); if( this.date != null && Date.getDaysInMonth(this.today.getFullYear(), this.today.getMonth()) == 31 ) { return true; } if( Date.getDaysInMonth(this.today.getFullYear(), this.today.getMonth()) < 31 && this.date == null ) { return true; } return false; } } } }); $(document).ready( function() { Date.Specification.validate().show() } ); ================================================ FILE: tests/performance/bulk.css ================================================ * { margin:0; padding: 0; font-size: 12pt; font-family: verdana;} body { margin:20px;} h1 { font-size: 18pt; } h1, h2, h3, p { margin-bottom: 20px; } #chart { border: 1px solid gray; padding: 10px;} #chart div.bar { height: 60px; padding: 10px;} #chart div.bar label { display: block; float: left; clear: both; width: 340px; margin: 20px; text-align: right;} #chart div.bar div.value { float: left; height: 30px; background-color: green; margin: 15px; } #chart div.bar div.display { float: left; font-size: 10pt; margin: 20px; } ================================================ FILE: tests/performance/index.html ================================================ Bulk Performance Tests

Performance Timings

Using random dates with format "M/d/yyyy".

================================================ FILE: tests/performance/index.js ================================================ var benchmark = function( fn ) { var start = new Date(); fn(); var end = new Date(); return end - start; }; var micro_benchmark = function( fn ) { var x = 0; for( var i = 0; i < 1000; i++ ) { x+=benchmark(fn); }; return x; }; var dateBenchmark = function( tests, fn ) { var month, day, year; var time = 0; for ( var i = 0 ; i < tests ; i++ ) { month = Math.round( Math.random() * 11 ); day = Math.round( Math.random() * 27 ) + 1; year = Math.round( Math.random() * 10 ) + 1995; var s = month.toString()+'/'+day.toString()+'/'+year.toString(); time += benchmark( function() { fn(s) } ); } return (Math.round(time/tests*1000)); }; $(document).ready(function() { var tests = 250; var results = { 'Native: .parse': dateBenchmark( tests, Date._parse ), 'Ext: parseDate': dateBenchmark( tests, function(s) { Date.parseDate( s, 'm/d/Y' ); } ), 'Datejs: .parseExact': dateBenchmark( tests, function(s) { Date.parseExact( s, 'M/d/yyyy' ); } ), 'Datejs: .getParseFunction': dateBenchmark( tests, Date.getParseFunction('M/d/yyyy') ), 'Datejs: .parse': dateBenchmark( tests, Date.parse ) }; var max = 0; for ( var k in results ) { max = ( max < results[k] ) ? results[k]:max ; } var addResult = function(h, r) { $('#chart').append( '
' + ''+ '
' + '
'+r+' microseconds
'); }; for ( var k in results ) { addResult( k, results[k]); } }); ================================================ FILE: tests/relative/index.html ================================================ Datejs Test Cases : Relative

Relative

================================================ FILE: tests/relative/index.js ================================================ Date.Specification = new Specification({ 'Overview': { setup: function() { }, 'Today': { run: function() { this.date = Date.parse('Today'); }, assert: function() { return Date.today().equals( this.date ) } }, 'Yesterday': { run: function() { this.date = Date.parse('Yesterday') }, assert: function() { return Date.today().addDays(-1).equals( this.date ) } }, 'Tomorrow': { run: function() { this.date = Date.parse('Tomorrow') }, assert: function() { return Date.today().addDays(1).equals( this.date ) } }, 't = "Today"': { run: function() { }, assert: function() { return Date.today().equals(Date.parse('t')) } }, 'tod = "Today"': { run: function() { }, assert: function() { return Date.today().equals(Date.parse('tod')) } }, 'yes = "Yesterday"': { run: function() { }, assert: function() { return Date.today().add(-1).days().equals(Date.parse('yes')) } }, 'tom = "Tomorrow"': { run: function() { }, assert: function() { return Date.today().add(1).day().equals(Date.parse('tom')) } } }, 'Relative Days': { setup: function() { }, 'last monday': { run: function() { }, assert: function() { return Date.today().last().monday().equals(Date.parse('last monday')) } }, 'last mon': { run: function() { }, assert: function() { return Date.today().last().monday().equals(Date.parse('last mon')) } }, 'last mo': { run: function() { }, assert: function() { return Date.today().last().monday().equals(Date.parse('last mo')) } }, 'last tuesday': { run: function() { }, assert: function() { return Date.today().last().tuesday().equals(Date.parse('last tuesday')) } }, 'last tues': { run: function() { }, assert: function() { return Date.today().last().tuesday().equals(Date.parse('last tues')) } }, 'last tue': { run: function() { }, assert: function() { return Date.today().last().tuesday().equals(Date.parse('last tue')) } }, 'last tu': { run: function() { }, assert: function() { return Date.today().last().tuesday().equals(Date.parse('last tu')) } }, 'last wednesday': { run: function() { }, assert: function() { return Date.today().last().wednesday().equals(Date.parse('last wednesday')) } }, 'last wed': { run: function() { }, assert: function() { return Date.today().last().wednesday().equals(Date.parse('last wed')) } }, 'last we': { run: function() { }, assert: function() { return Date.today().last().wednesday().equals(Date.parse('last we')) } }, 'last thursday': { run: function() { }, assert: function() { return Date.today().last().thursday().equals(Date.parse('last thursday')) } }, 'last thurs': { run: function() { }, assert: function() { return Date.today().last().thursday().equals(Date.parse('last thurs')) } }, 'last thur': { run: function() { }, assert: function() { return Date.today().last().thursday().equals(Date.parse('last thur')) } }, 'last thu': { run: function() { }, assert: function() { return Date.today().last().thursday().equals(Date.parse('last thu')) } }, // 'last th': { // run: function() { }, // assert: function() { return Date.today().last().thursday().equals(Date.parse('last th')) } // }, 'last friday': { run: function() { }, assert: function() { return Date.today().last().friday().equals(Date.parse('last friday')) } }, 'last fri': { run: function() { }, assert: function() { return Date.today().last().friday().equals(Date.parse('last fri')) } }, 'last fr': { run: function() { }, assert: function() { return Date.today().last().friday().equals(Date.parse('last fr')) } }, 'last saturday': { run: function() { }, assert: function() { return Date.today().last().saturday().equals(Date.parse('last saturday')) } }, 'last sat': { run: function() { }, assert: function() { return Date.today().last().saturday().equals(Date.parse('last sat')) } }, 'last sa': { run: function() { }, assert: function() { return Date.today().last().saturday().equals(Date.parse('last sa')) } }, 'last sunday': { run: function() { }, assert: function() { return Date.today().last().sunday().equals(Date.parse('last sunday')) } }, 'last sun': { run: function() { }, assert: function() { return Date.today().last().sunday().equals(Date.parse('last sun')) } }, 'last su': { run: function() { }, assert: function() { return Date.today().last().sunday().equals(Date.parse('last su')) } }, 'prev monday': { run: function() { }, assert: function() { return Date.today().prev().monday().equals(Date.parse('prev monday')) } }, 'prev mon': { run: function() { }, assert: function() { return Date.today().prev().monday().equals(Date.parse('prev mon')) } }, 'prev mo': { run: function() { }, assert: function() { return Date.today().prev().monday().equals(Date.parse('prev mo')) } }, 'prev tuesday': { run: function() { }, assert: function() { return Date.today().prev().tuesday().equals(Date.parse('prev tuesday')) } }, 'prev tues': { run: function() { }, assert: function() { return Date.today().prev().tuesday().equals(Date.parse('prev tues')) } }, 'prev tue': { run: function() { }, assert: function() { return Date.today().prev().tuesday().equals(Date.parse('prev tue')) } }, 'prev tu': { run: function() { }, assert: function() { return Date.today().prev().tuesday().equals(Date.parse('prev tu')) } }, 'prev wednesday': { run: function() { }, assert: function() { return Date.today().prev().wednesday().equals(Date.parse('prev wednesday')) } }, 'prev wed': { run: function() { }, assert: function() { return Date.today().prev().wednesday().equals(Date.parse('prev wed')) } }, 'prev we': { run: function() { }, assert: function() { return Date.today().prev().wednesday().equals(Date.parse('prev we')) } }, 'prev thursday': { run: function() { }, assert: function() { return Date.today().prev().thursday().equals(Date.parse('prev thursday')) } }, 'prev thurs': { run: function() { }, assert: function() { return Date.today().prev().thursday().equals(Date.parse('prev thurs')) } }, 'prev thur': { run: function() { }, assert: function() { return Date.today().prev().thursday().equals(Date.parse('prev thur')) } }, 'prev thu': { run: function() { }, assert: function() { return Date.today().prev().thursday().equals(Date.parse('prev thu')) } }, // 'prev th': { // run: function() { }, // assert: function() { return Date.today().prev().thursday().equals(Date.parse('prev th')) } // }, 'prev friday': { run: function() { }, assert: function() { return Date.today().prev().friday().equals(Date.parse('prev friday')) } }, 'prev fri': { run: function() { }, assert: function() { return Date.today().prev().friday().equals(Date.parse('prev fri')) } }, 'prev fr': { run: function() { }, assert: function() { return Date.today().prev().friday().equals(Date.parse('prev fr')) } }, 'prev saturday': { run: function() { }, assert: function() { return Date.today().prev().saturday().equals(Date.parse('prev saturday')) } }, 'prev sat': { run: function() { }, assert: function() { return Date.today().prev().saturday().equals(Date.parse('prev sat')) } }, 'prev sa': { run: function() { }, assert: function() { return Date.today().prev().saturday().equals(Date.parse('prev sa')) } }, 'prev sunday': { run: function() { }, assert: function() { return Date.today().prev().sunday().equals(Date.parse('prev sunday')) } }, 'prev sun': { run: function() { }, assert: function() { return Date.today().prev().sunday().equals(Date.parse('prev sun')) } }, 'prev su': { run: function() { }, assert: function() { return Date.today().prev().sunday().equals(Date.parse('prev su')) } }, 'previous monday': { run: function() { }, assert: function() { return Date.today().previous().monday().equals(Date.parse('previous monday')) } }, 'previous mon': { run: function() { }, assert: function() { return Date.today().previous().monday().equals(Date.parse('previous mon')) } }, 'previous mo': { run: function() { }, assert: function() { return Date.today().previous().monday().equals(Date.parse('previous mo')) } }, 'previous tuesday': { run: function() { }, assert: function() { return Date.today().previous().tuesday().equals(Date.parse('previous tuesday')) } }, 'previous tues': { run: function() { }, assert: function() { return Date.today().previous().tuesday().equals(Date.parse('previous tues')) } }, 'previous tue': { run: function() { }, assert: function() { return Date.today().previous().tuesday().equals(Date.parse('previous tue')) } }, 'previous tu': { run: function() { }, assert: function() { return Date.today().previous().tuesday().equals(Date.parse('previous tu')) } }, 'previous wednesday': { run: function() { }, assert: function() { return Date.today().previous().wednesday().equals(Date.parse('previous wednesday')) } }, 'previous wed': { run: function() { }, assert: function() { return Date.today().previous().wednesday().equals(Date.parse('previous wed')) } }, 'previous we': { run: function() { }, assert: function() { return Date.today().previous().wednesday().equals(Date.parse('previous we')) } }, 'previous thursday': { run: function() { }, assert: function() { return Date.today().previous().thursday().equals(Date.parse('previous thursday')) } }, 'previous thurs': { run: function() { }, assert: function() { return Date.today().previous().thursday().equals(Date.parse('previous thurs')) } }, 'previous thur': { run: function() { }, assert: function() { return Date.today().previous().thursday().equals(Date.parse('previous thur')) } }, 'previous thu': { run: function() { }, assert: function() { return Date.today().previous().thursday().equals(Date.parse('previous thu')) } }, // 'previous th': { // run: function() { }, // assert: function() { return Date.today().previous().thursday().equals(Date.parse('previous th')) } // }, 'previous friday': { run: function() { }, assert: function() { return Date.today().previous().friday().equals(Date.parse('previous friday')) } }, 'previous fri': { run: function() { }, assert: function() { return Date.today().previous().friday().equals(Date.parse('previous fri')) } }, 'previous fr': { run: function() { }, assert: function() { return Date.today().previous().friday().equals(Date.parse('previous fr')) } }, 'previous saturday': { run: function() { }, assert: function() { return Date.today().previous().saturday().equals(Date.parse('previous saturday')) } }, 'previous sat': { run: function() { }, assert: function() { return Date.today().previous().saturday().equals(Date.parse('previous sat')) } }, 'previous sa': { run: function() { }, assert: function() { return Date.today().previous().saturday().equals(Date.parse('previous sa')) } }, 'previous sunday': { run: function() { }, assert: function() { return Date.today().previous().sunday().equals(Date.parse('previous sunday')) } }, 'previous sun': { run: function() { }, assert: function() { return Date.today().previous().sunday().equals(Date.parse('previous sun')) } }, 'previous su': { run: function() { }, assert: function() { return Date.today().previous().sunday().equals(Date.parse('previous su')) } }, 'next monday': { run: function() { }, assert: function() { return Date.today().next().monday().equals(Date.parse('next monday')) } }, 'next mon': { run: function() { }, assert: function() { return Date.today().next().monday().equals(Date.parse('next mon')) } }, 'next mo': { run: function() { }, assert: function() { return Date.today().next().monday().equals(Date.parse('next mo')) } }, 'next tuesday': { run: function() { }, assert: function() { return Date.today().next().tuesday().equals(Date.parse('next tuesday')) } }, 'next tues': { run: function() { }, assert: function() { return Date.today().next().tuesday().equals(Date.parse('next tues')) } }, 'next tue': { run: function() { }, assert: function() { return Date.today().next().tuesday().equals(Date.parse('next tue')) } }, 'next tu': { run: function() { }, assert: function() { return Date.today().next().tuesday().equals(Date.parse('next tu')) } }, 'next wednesday': { run: function() { }, assert: function() { return Date.today().next().wednesday().equals(Date.parse('next wednesday')) } }, 'next wed': { run: function() { }, assert: function() { return Date.today().next().wednesday().equals(Date.parse('next wed')) } }, 'next we': { run: function() { }, assert: function() { return Date.today().next().wednesday().equals(Date.parse('next we')) } }, 'next thursday': { run: function() { }, assert: function() { return Date.today().next().thursday().equals(Date.parse('next thursday')) } }, 'next thurs': { run: function() { }, assert: function() { return Date.today().next().thursday().equals(Date.parse('next thurs')) } }, 'next thur': { run: function() { }, assert: function() { return Date.today().next().thursday().equals(Date.parse('next thur')) } }, 'next thu': { run: function() { }, assert: function() { return Date.today().next().thursday().equals(Date.parse('next thu')) } }, // 'next th': { // run: function() { }, // assert: function() { return Date.today().next().thursday().equals(Date.parse('next th')) } // }, 'next friday': { run: function() { }, assert: function() { return Date.today().next().friday().equals(Date.parse('next friday')) } }, 'next fri': { run: function() { }, assert: function() { return Date.today().next().friday().equals(Date.parse('next fri')) } }, 'next fr': { run: function() { }, assert: function() { return Date.today().next().friday().equals(Date.parse('next fr')) } }, 'next saturday': { run: function() { }, assert: function() { return Date.today().next().saturday().equals(Date.parse('next saturday')) } }, 'next sat': { run: function() { }, assert: function() { return Date.today().next().saturday().equals(Date.parse('next sat')) } }, 'next sa': { run: function() { }, assert: function() { return Date.today().next().saturday().equals(Date.parse('next sa')) } }, 'next sunday': { run: function() { }, assert: function() { return Date.today().next().sunday().equals(Date.parse('next sunday')) } }, 'next sun': { run: function() { }, assert: function() { return Date.today().next().sunday().equals(Date.parse('next sun')) } }, 'next su': { run: function() { }, assert: function() { return Date.today().next().sunday().equals(Date.parse('next su')) } } }, 'Relative Months': { setup: function() { }, 'last january': { run: function() { }, assert: function() { return Date.today().last().january().equals(Date.parse('last january')) } }, 'last jan': { run: function() { }, assert: function() { return Date.today().last().january().equals(Date.parse('last jan')) } }, 'last february': { run: function() { }, assert: function() { return Date.today().last().february().equals(Date.parse('last february')) } }, 'last feb': { run: function() { }, assert: function() { return Date.today().last().february().equals(Date.parse('last feb')) } }, 'last march': { run: function() { }, assert: function() { return Date.today().last().march().equals(Date.parse('last march')) } }, 'last mar': { run: function() { }, assert: function() { return Date.today().last().march().equals(Date.parse('last mar')) } }, 'last april': { run: function() { }, assert: function() { return Date.today().last().april().equals(Date.parse('last april')) } }, 'last apr': { run: function() { }, assert: function() { return Date.today().last().apr().equals(Date.parse('last apr')) } }, 'last may': { run: function() { }, assert: function() { return Date.today().last().may().equals(Date.parse('last may')) } }, 'last june': { run: function() { }, assert: function() { return Date.today().last().june().equals(Date.parse('last june')) } }, 'last jun': { run: function() { }, assert: function() { return Date.today().last().june().equals(Date.parse('last jun')) } }, 'last july': { run: function() { }, assert: function() { return Date.today().last().july().equals(Date.parse('last july')) } }, 'last jul': { run: function() { }, assert: function() { return Date.today().last().july().equals(Date.parse('last july')) } }, 'last august': { run: function() { }, assert: function() { return Date.today().last().august().equals(Date.parse('last august')) } }, 'last aug': { run: function() { }, assert: function() { return Date.today().last().august().equals(Date.parse('last aug')) } }, 'last september': { run: function() { }, assert: function() { return Date.today().last().september().equals(Date.parse('last september')) } }, 'last sept': { run: function() { }, assert: function() { return Date.today().last().september().equals(Date.parse('last sept')) } }, 'last sep': { run: function() { }, assert: function() { return Date.today().last().sep().equals(Date.parse('last sep')) } }, 'last october': { run: function() { }, assert: function() { return Date.today().last().october().equals(Date.parse('last october')) } }, 'last oct': { run: function() { }, assert: function() { return Date.today().last().october().equals(Date.parse('last oct')) } }, 'last november': { run: function() { }, assert: function() { return Date.today().last().november().equals(Date.parse('last november')) } }, 'last nov': { run: function() { }, assert: function() { return Date.today().last().november().equals(Date.parse('last nov')) } }, 'last december': { run: function() { }, assert: function() { return Date.today().last().december().equals(Date.parse('last december')) } }, 'last dec': { run: function() { }, assert: function() { return Date.today().last().december().equals(Date.parse('last dec')) } }, 'prev january': { run: function() { }, assert: function() { return Date.today().prev().january().equals(Date.parse('prev january')) } }, 'prev jan': { run: function() { }, assert: function() { return Date.today().prev().january().equals(Date.parse('prev jan')) } }, 'prev february': { run: function() { }, assert: function() { return Date.today().prev().february().equals(Date.parse('prev february')) } }, 'prev feb': { run: function() { }, assert: function() { return Date.today().prev().february().equals(Date.parse('prev feb')) } }, 'prev march': { run: function() { }, assert: function() { return Date.today().prev().march().equals(Date.parse('prev march')) } }, 'prev mar': { run: function() { }, assert: function() { return Date.today().prev().march().equals(Date.parse('prev mar')) } }, 'prev april': { run: function() { }, assert: function() { return Date.today().prev().april().equals(Date.parse('prev april')) } }, 'prev apr': { run: function() { }, assert: function() { return Date.today().prev().apr().equals(Date.parse('prev apr')) } }, 'prev may': { run: function() { }, assert: function() { return Date.today().prev().may().equals(Date.parse('prev may')) } }, 'prev june': { run: function() { }, assert: function() { return Date.today().prev().june().equals(Date.parse('prev june')) } }, 'prev jun': { run: function() { }, assert: function() { return Date.today().prev().june().equals(Date.parse('prev jun')) } }, 'prev july': { run: function() { }, assert: function() { return Date.today().prev().july().equals(Date.parse('prev july')) } }, 'prev jul': { run: function() { }, assert: function() { return Date.today().prev().july().equals(Date.parse('prev july')) } }, 'prev august': { run: function() { }, assert: function() { return Date.today().prev().august().equals(Date.parse('prev august')) } }, 'prev aug': { run: function() { }, assert: function() { return Date.today().prev().august().equals(Date.parse('prev aug')) } }, 'prev september': { run: function() { }, assert: function() { return Date.today().prev().september().equals(Date.parse('prev september')) } }, 'prev sept': { run: function() { }, assert: function() { return Date.today().prev().september().equals(Date.parse('prev sept')) } }, 'prev sep': { run: function() { }, assert: function() { return Date.today().prev().sep().equals(Date.parse('prev sep')) } }, 'prev october': { run: function() { }, assert: function() { return Date.today().prev().october().equals(Date.parse('prev october')) } }, 'prev oct': { run: function() { }, assert: function() { return Date.today().prev().october().equals(Date.parse('prev oct')) } }, 'prev november': { run: function() { }, assert: function() { return Date.today().prev().november().equals(Date.parse('prev november')) } }, 'prev nov': { run: function() { }, assert: function() { return Date.today().prev().november().equals(Date.parse('prev nov')) } }, 'prev december': { run: function() { }, assert: function() { return Date.today().prev().december().equals(Date.parse('prev december')) } }, 'prev dec': { run: function() { }, assert: function() { return Date.today().prev().december().equals(Date.parse('prev dec')) } }, 'previous january': { run: function() { }, assert: function() { return Date.today().previous().january().equals(Date.parse('previous january')) } }, 'previous jan': { run: function() { }, assert: function() { return Date.today().previous().january().equals(Date.parse('previous jan')) } }, 'previous february': { run: function() { }, assert: function() { return Date.today().previous().february().equals(Date.parse('previous february')) } }, 'previous feb': { run: function() { }, assert: function() { return Date.today().previous().february().equals(Date.parse('previous feb')) } }, 'previous march': { run: function() { }, assert: function() { return Date.today().previous().march().equals(Date.parse('previous march')) } }, 'previous mar': { run: function() { }, assert: function() { return Date.today().previous().march().equals(Date.parse('previous mar')) } }, 'previous april': { run: function() { }, assert: function() { return Date.today().previous().april().equals(Date.parse('previous april')) } }, 'previous apr': { run: function() { }, assert: function() { return Date.today().previous().apr().equals(Date.parse('previous apr')) } }, 'previous may': { run: function() { }, assert: function() { return Date.today().previous().may().equals(Date.parse('previous may')) } }, 'previous june': { run: function() { }, assert: function() { return Date.today().previous().june().equals(Date.parse('previous june')) } }, 'previous jun': { run: function() { }, assert: function() { return Date.today().previous().june().equals(Date.parse('previous jun')) } }, 'previous july': { run: function() { }, assert: function() { return Date.today().previous().july().equals(Date.parse('previous july')) } }, 'previous jul': { run: function() { }, assert: function() { return Date.today().previous().july().equals(Date.parse('previous july')) } }, 'previous august': { run: function() { }, assert: function() { return Date.today().previous().august().equals(Date.parse('previous august')) } }, 'previous aug': { run: function() { }, assert: function() { return Date.today().previous().august().equals(Date.parse('previous aug')) } }, 'previous september': { run: function() { }, assert: function() { return Date.today().previous().september().equals(Date.parse('previous september')) } }, 'previous sept': { run: function() { }, assert: function() { return Date.today().previous().september().equals(Date.parse('previous sept')) } }, 'previous sep': { run: function() { }, assert: function() { return Date.today().previous().sep().equals(Date.parse('previous sep')) } }, 'previous october': { run: function() { }, assert: function() { return Date.today().previous().october().equals(Date.parse('previous october')) } }, 'previous oct': { run: function() { }, assert: function() { return Date.today().previous().october().equals(Date.parse('previous oct')) } }, 'previous november': { run: function() { }, assert: function() { return Date.today().previous().november().equals(Date.parse('previous november')) } }, 'previous nov': { run: function() { }, assert: function() { return Date.today().previous().november().equals(Date.parse('previous nov')) } }, 'previous december': { run: function() { }, assert: function() { return Date.today().previous().december().equals(Date.parse('previous december')) } }, 'previous dec': { run: function() { }, assert: function() { return Date.today().previous().december().equals(Date.parse('previous dec')) } }, 'next january': { run: function() { }, assert: function() { return Date.today().next().january().equals(Date.parse('next january')) } }, 'next jan': { run: function() { }, assert: function() { return Date.today().next().january().equals(Date.parse('next jan')) } }, 'next february': { run: function() { }, assert: function() { return Date.today().next().february().equals(Date.parse('next february')) } }, 'next feb': { run: function() { }, assert: function() { return Date.today().next().february().equals(Date.parse('next feb')) } }, 'next march': { run: function() { }, assert: function() { return Date.today().next().march().equals(Date.parse('next march')) } }, 'next mar': { run: function() { }, assert: function() { return Date.today().next().march().equals(Date.parse('next mar')) } }, 'next april': { run: function() { }, assert: function() { return Date.today().next().april().equals(Date.parse('next april')) } }, 'next apr': { run: function() { }, assert: function() { return Date.today().next().apr().equals(Date.parse('next apr')) } }, 'next may': { run: function() { }, assert: function() { return Date.today().next().may().equals(Date.parse('next may')) } }, 'next june': { run: function() { }, assert: function() { return Date.today().next().june().equals(Date.parse('next june')) } }, 'next jun': { run: function() { }, assert: function() { return Date.today().next().june().equals(Date.parse('next jun')) } }, 'next july': { run: function() { }, assert: function() { return Date.today().next().july().equals(Date.parse('next july')) } }, 'next jul': { run: function() { }, assert: function() { return Date.today().next().july().equals(Date.parse('next july')) } }, 'next august': { run: function() { }, assert: function() { return Date.today().next().august().equals(Date.parse('next august')) } }, 'next aug': { run: function() { }, assert: function() { return Date.today().next().august().equals(Date.parse('next aug')) } }, 'next september': { run: function() { }, assert: function() { return Date.today().next().september().equals(Date.parse('next september')) } }, 'next sept': { run: function() { }, assert: function() { return Date.today().next().september().equals(Date.parse('next sept')) } }, 'next sep': { run: function() { }, assert: function() { return Date.today().next().sep().equals(Date.parse('next sep')) } }, 'next october': { run: function() { }, assert: function() { return Date.today().next().october().equals(Date.parse('next october')) } }, 'next oct': { run: function() { }, assert: function() { return Date.today().next().october().equals(Date.parse('next oct')) } }, 'next november': { run: function() { }, assert: function() { return Date.today().next().november().equals(Date.parse('next november')) } }, 'next nov': { run: function() { }, assert: function() { return Date.today().next().november().equals(Date.parse('next nov')) } }, 'next december': { run: function() { }, assert: function() { return Date.today().next().december().equals(Date.parse('next december')) } }, 'next dec': { run: function() { }, assert: function() { return Date.today().next().december().equals(Date.parse('next dec')) } } }, 'Relative Date Element Parts': { setup: function() { }, 'last seconds': { run: function() { }, assert: function() { return new Date().last().second().set({millisecond: 0}).equals(Date.parse('last seconds').set({millisecond: 0})) } }, 'last second': { run: function() { }, assert: function() { return new Date().last().second().set({millisecond: 0}).equals(Date.parse('last second').set({millisecond: 0})) } }, 'last sec': { run: function() { }, assert: function() { return new Date().last().second().set({millisecond: 0}).equals(Date.parse('last sec').set({millisecond: 0})) } }, 'last minutes': { run: function() { }, assert: function() { return new Date().last().minute().set({millisecond: 0}).equals(Date.parse('last minutes').set({millisecond: 0})) } }, 'last minute': { run: function() { }, assert: function() { return new Date().last().minute().set({millisecond: 0}).equals(Date.parse('last minute').set({millisecond: 0})) } }, 'last min': { run: function() { }, assert: function() { return new Date().last().minute().set({millisecond: 0}).equals(Date.parse('last min').set({millisecond: 0})) } }, 'last mn': { run: function() { }, assert: function() { return new Date().last().minute().set({millisecond: 0}).equals(Date.parse('last mn').set({millisecond: 0})) } }, 'last hours': { run: function() { }, assert: function() { return new Date().last().hour().set({millisecond: 0}).equals(Date.parse('last hours').set({millisecond: 0})) } }, 'last hour': { run: function() { }, assert: function() { return new Date().last().hour().set({millisecond: 0}).equals(Date.parse('last hour').set({millisecond: 0})) } }, 'last days': { run: function() { }, assert: function() { return Date.today().last().day().equals(Date.parse('last days')) } }, 'last day': { run: function() { }, assert: function() { return Date.today().last().day().equals(Date.parse('last day')) } }, 'last weeks': { run: function() { }, assert: function() { return Date.today().last().week().equals(Date.parse('last weeks')) } }, 'last week': { run: function() { }, assert: function() { return Date.today().last().week().equals(Date.parse('last week')) } }, 'last months': { run: function() { }, assert: function() { return Date.today().last().month().equals(Date.parse('last months')) } }, 'last month': { run: function() { }, assert: function() { return Date.today().last().month().equals(Date.parse('last month')) } }, 'last years': { run: function() { }, assert: function() { return Date.today().last().year().equals(Date.parse('last years')) } }, 'last year': { run: function() { }, assert: function() { return Date.today().last().year().equals(Date.parse('last year')) } }, 'prev seconds': { run: function() { }, assert: function() { return new Date().prev().second().set({millisecond: 0}).equals(Date.parse('prev seconds').set({millisecond: 0})) } }, 'prev second': { run: function() { }, assert: function() { return new Date().prev().second().set({millisecond: 0}).equals(Date.parse('prev second').set({millisecond: 0})) } }, 'prev sec': { run: function() { }, assert: function() { return new Date().prev().second().set({millisecond: 0}).equals(Date.parse('prev sec').set({millisecond: 0})) } }, 'prev minutes': { run: function() { }, assert: function() { return new Date().prev().minute().set({millisecond: 0}).equals(Date.parse('prev minutes').set({millisecond: 0})) } }, 'prev minute': { run: function() { }, assert: function() { return new Date().prev().minute().set({millisecond: 0}).equals(Date.parse('prev minute').set({millisecond: 0})) } }, 'prev min': { run: function() { }, assert: function() { return new Date().prev().minute().set({millisecond: 0}).equals(Date.parse('prev min').set({millisecond: 0})) } }, 'prev mn': { run: function() { }, assert: function() { return new Date().prev().minute().set({millisecond: 0}).equals(Date.parse('prev mn').set({millisecond: 0})) } }, 'prev hours': { run: function() { }, assert: function() { return new Date().prev().hour().set({millisecond: 0}).equals(Date.parse('prev hours').set({millisecond: 0})) } }, 'prev hour': { run: function() { }, assert: function() { return new Date().prev().hour().set({millisecond: 0}).equals(Date.parse('prev hour').set({millisecond: 0})) } }, 'prev days': { run: function() { }, assert: function() { return Date.today().prev().day().equals(Date.parse('prev days')) } }, 'prev day': { run: function() { }, assert: function() { return Date.today().prev().day().equals(Date.parse('prev day')) } }, 'prev weeks': { run: function() { }, assert: function() { return Date.today().prev().week().equals(Date.parse('prev weeks')) } }, 'prev week': { run: function() { }, assert: function() { return Date.today().prev().week().equals(Date.parse('prev week')) } }, 'prev months': { run: function() { }, assert: function() { return Date.today().prev().month().equals(Date.parse('prev months')) } }, 'prev month': { run: function() { }, assert: function() { return Date.today().prev().month().equals(Date.parse('prev month')) } }, 'prev years': { run: function() { }, assert: function() { return Date.today().prev().year().equals(Date.parse('prev years')) } }, 'prev year': { run: function() { }, assert: function() { return Date.today().prev().year().equals(Date.parse('prev year')) } }, 'previous seconds': { run: function() { }, assert: function() { return new Date().previous().second().set({millisecond: 0}).equals(Date.parse('previous seconds').set({millisecond: 0})) } }, 'previous second': { run: function() { }, assert: function() { return new Date().previous().second().set({millisecond: 0}).equals(Date.parse('previous second').set({millisecond: 0})) } }, 'previous sec': { run: function() { }, assert: function() { return new Date().previous().second().set({millisecond: 0}).equals(Date.parse('previous sec').set({millisecond: 0})) } }, 'previous minutes': { run: function() { }, assert: function() { return new Date().previous().minute().set({millisecond: 0}).equals(Date.parse('previous minutes').set({millisecond: 0})) } }, 'previous minute': { run: function() { }, assert: function() { return new Date().previous().minute().set({millisecond: 0}).equals(Date.parse('previous minute').set({millisecond: 0})) } }, 'previous min': { run: function() { }, assert: function() { return new Date().previous().minute().set({millisecond: 0}).equals(Date.parse('previous min').set({millisecond: 0})) } }, 'previous mn': { run: function() { }, assert: function() { return new Date().previous().minute().set({millisecond: 0}).equals(Date.parse('previous mn').set({millisecond: 0})) } }, 'previous hours': { run: function() { }, assert: function() { return new Date().previous().hour().set({millisecond: 0}).equals(Date.parse('previous hours').set({millisecond: 0})) } }, 'previous hour': { run: function() { }, assert: function() { return new Date().previous().hour().set({millisecond: 0}).equals(Date.parse('previous hour').set({millisecond: 0})) } }, 'previous days': { run: function() { }, assert: function() { return Date.today().previous().day().equals(Date.parse('previous days')) } }, 'previous day': { run: function() { }, assert: function() { return Date.today().previous().day().equals(Date.parse('previous day')) } }, 'previous weeks': { run: function() { }, assert: function() { return Date.today().previous().week().equals(Date.parse('previous weeks')) } }, 'previous week': { run: function() { }, assert: function() { return Date.today().previous().week().equals(Date.parse('previous week')) } }, 'previous months': { run: function() { }, assert: function() { return Date.today().previous().month().equals(Date.parse('previous months')) } }, 'previous month': { run: function() { }, assert: function() { return Date.today().previous().month().equals(Date.parse('previous month')) } }, 'previous years': { run: function() { }, assert: function() { return Date.today().previous().year().equals(Date.parse('previous years')) } }, 'previous year': { run: function() { }, assert: function() { return Date.today().previous().year().equals(Date.parse('previous year')) } }, 'next seconds': { run: function() { }, assert: function() { return new Date().next().second().set({millisecond: 0}).equals(Date.parse('next seconds').set({millisecond: 0})) } }, 'next second': { run: function() { }, assert: function() { return new Date().next().second().set({millisecond: 0}).equals(Date.parse('next second').set({millisecond: 0})) } }, 'next sec': { run: function() { }, assert: function() { return new Date().next().second().set({millisecond: 0}).equals(Date.parse('next sec').set({millisecond: 0})) } }, 'next minutes': { run: function() { }, assert: function() { return new Date().next().minute().set({millisecond: 0}).equals(Date.parse('next minutes').set({millisecond: 0})) } }, 'next minute': { run: function() { }, assert: function() { return new Date().next().minute().set({millisecond: 0}).equals(Date.parse('next minute').set({millisecond: 0})) } }, 'next min': { run: function() { }, assert: function() { return new Date().next().minute().set({millisecond: 0}).equals(Date.parse('next min').set({millisecond: 0})) } }, 'next mn': { run: function() { }, assert: function() { return new Date().next().minute().set({millisecond: 0}).equals(Date.parse('next mn').set({millisecond: 0})) } }, 'next hours': { run: function() { }, assert: function() { return new Date().next().hour().set({millisecond: 0}).equals(Date.parse('next hours').set({millisecond: 0})) } }, 'next hour': { run: function() { }, assert: function() { return new Date().next().hour().set({millisecond: 0}).equals(Date.parse('next hour').set({millisecond: 0})) } }, 'next days': { run: function() { }, assert: function() { return Date.today().next().day().equals(Date.parse('next days')) } }, 'next day': { run: function() { }, assert: function() { return Date.today().next().day().equals(Date.parse('next day')) } }, 'next weeks': { run: function() { }, assert: function() { return Date.today().next().week().equals(Date.parse('next weeks')) } }, 'next week': { run: function() { }, assert: function() { return Date.today().next().week().equals(Date.parse('next week')) } }, 'next months': { run: function() { }, assert: function() { return Date.today().next().month().equals(Date.parse('next months')) } }, 'next month': { run: function() { }, assert: function() { return Date.today().next().month().equals(Date.parse('next month')) } }, 'next years': { run: function() { }, assert: function() { return Date.today().next().year().equals(Date.parse('next years')) } }, 'next year': { run: function() { }, assert: function() { return Date.today().next().year().equals(Date.parse('next year')) } } } }); $(document).ready( function() { Date.Specification.validate().show() } ); ================================================ FILE: tests/relative_date_and_time/index.html ================================================ Datejs Test Cases : Relative Date and Time

Relative Date and Time

================================================ FILE: tests/relative_date_and_time/index.js ================================================ Date.Specification = new Specification({ '@': { setup: function() { }, 'monday @ 8': { run: function() { }, assert: function() { return Date.monday().set({ hour: 8 }).equals( Date.parse('monday @ 8') ) } }, 'monday @ 8a': { run: function() { }, assert: function() { return Date.monday().set({ hour: 8 }).equals( Date.parse('monday @ 8a') ) } }, 'monday @ 8am': { run: function() { }, assert: function() { return Date.monday().set({ hour: 8 }).equals( Date.parse('monday @ 8am') ) } }, 'monday @ 8 a.m.': { run: function() { }, assert: function() { return Date.monday().set({ hour: 8 }).equals( Date.parse('monday @ 8 a.m.') ) } }, 'monday @ 8:15': { run: function() { }, assert: function() { return Date.monday().set({ hour: 8, minute: 15 }).equals( Date.parse('monday @ 8:15') ) } }, 'monday @ 8p': { run: function() { }, assert: function() { return Date.monday().set({ hour: 20 }).equals( Date.parse('monday @ 8p') ) } }, 'monday @ 8pm': { run: function() { }, assert: function() { return Date.monday().set({ hour: 20 }).equals( Date.parse('monday @ 8pm') ) } }, 'monday @ 8 p.m.': { run: function() { }, assert: function() { return Date.monday().set({ hour: 20 }).equals( Date.parse('monday @ 8 p.m.') ) } }, 'monday @ 20:15': { run: function() { }, assert: function() { return Date.monday().set({ hour: 20, minute: 15 }).equals( Date.parse('monday @ 20:15') ) } }, 'sunday @ 8': { run: function() { }, assert: function() { return Date.sunday().set({ hour: 8 }).equals( Date.parse('sunday @ 8') ) } }, 'sunday @ 8a': { run: function() { }, assert: function() { return Date.sunday().set({ hour: 8 }).equals( Date.parse('sunday @ 8a') ) } }, 'sunday @ 8am': { run: function() { }, assert: function() { return Date.sunday().set({ hour: 8 }).equals( Date.parse('sunday @ 8am') ) } }, 'sunday @ 8 a.m.': { run: function() { }, assert: function() { return Date.sunday().set({ hour: 8 }).equals( Date.parse('sunday @ 8 a.m.') ) } }, 'sunday @ 8:15': { run: function() { }, assert: function() { return Date.sunday().set({ hour: 8, minute: 15 }).equals( Date.parse('sunday @ 8:15') ) } }, 'sunday @ 8p': { run: function() { }, assert: function() { return Date.sunday().set({ hour: 20 }).equals( Date.parse('sunday @ 8p') ) } }, 'sunday @ 8pm': { run: function() { }, assert: function() { return Date.sunday().set({ hour: 20 }).equals( Date.parse('sunday @ 8pm') ) } }, 'sunday @ 8 p.m.': { run: function() { }, assert: function() { return Date.sunday().set({ hour: 20 }).equals( Date.parse('sunday @ 8 p.m.') ) } }, 'sunday @ 20:15': { run: function() { }, assert: function() { return Date.sunday().set({ hour: 20, minute: 15 }).equals( Date.parse('sunday @ 20:15') ) } } }, 'at': { setup: function() { }, 'monday at 8': { run: function() { }, assert: function() { return Date.monday().set({ hour: 8 }).equals( Date.parse('monday at 8') ) } }, 'monday at 8a': { run: function() { }, assert: function() { return Date.monday().set({ hour: 8 }).equals( Date.parse('monday at 8a') ) } }, 'monday at 8am': { run: function() { }, assert: function() { return Date.monday().set({ hour: 8 }).equals( Date.parse('monday at 8am') ) } }, 'monday at 8 a.m.': { run: function() { }, assert: function() { return Date.monday().set({ hour: 8 }).equals( Date.parse('monday at 8 a.m.') ) } }, 'monday at 8:15': { run: function() { }, assert: function() { return Date.monday().set({ hour: 8, minute: 15 }).equals( Date.parse('monday at 8:15') ) } }, 'monday at 8p': { run: function() { }, assert: function() { return Date.monday().set({ hour: 20 }).equals( Date.parse('monday at 8p') ) } }, 'monday at 8pm': { run: function() { }, assert: function() { return Date.monday().set({ hour: 20 }).equals( Date.parse('monday at 8pm') ) } }, 'monday at 8 p.m.': { run: function() { }, assert: function() { return Date.monday().set({ hour: 20 }).equals( Date.parse('monday at 8 p.m.') ) } }, 'monday at 20:15': { run: function() { }, assert: function() { return Date.monday().set({ hour: 20, minute: 15 }).equals( Date.parse('monday at 20:15') ) } }, 'sunday at 8': { run: function() { }, assert: function() { return Date.sunday().set({ hour: 8 }).equals( Date.parse('sunday at 8') ) } }, 'sunday at 8a': { run: function() { }, assert: function() { return Date.sunday().set({ hour: 8 }).equals( Date.parse('sunday at 8a') ) } }, 'sunday at 8am': { run: function() { }, assert: function() { return Date.sunday().set({ hour: 8 }).equals( Date.parse('sunday at 8am') ) } }, 'sunday at 8 a.m.': { run: function() { }, assert: function() { return Date.sunday().set({ hour: 8 }).equals( Date.parse('sunday at 8 a.m.') ) } }, 'sunday at 8:15': { run: function() { }, assert: function() { return Date.sunday().set({ hour: 8, minute: 15 }).equals( Date.parse('sunday at 8:15') ) } }, 'sunday at 8p': { run: function() { }, assert: function() { return Date.sunday().set({ hour: 20 }).equals( Date.parse('sunday at 8p') ) } }, 'sunday at 8pm': { run: function() { }, assert: function() { return Date.sunday().set({ hour: 20 }).equals( Date.parse('sunday at 8pm') ) } }, 'sunday at 8 p.m.': { run: function() { }, assert: function() { return Date.sunday().set({ hour: 20 }).equals( Date.parse('sunday at 8 p.m.') ) } }, 'sunday at 20:15': { run: function() { }, assert: function() { return Date.sunday().set({ hour: 20, minute: 15 }).equals( Date.parse('sunday at 20:15') ) } } }, 'on': { setup: function() { }, '12a on monday': { run: function() { }, assert: function() { return Date.monday().equals( Date.parse('12a on monday') ) } }, '12am on monday': { run: function() { }, assert: function() { return Date.monday().equals( Date.parse('12am on monday') ) } }, '12 am on monday': { run: function() { }, assert: function() { return Date.monday().equals( Date.parse('12 am on monday') ) } }, '12 a.m on monday': { run: function() { }, assert: function() { return Date.monday().equals( Date.parse('12 a.m on monday') ) } }, '12p on monday': { run: function() { }, assert: function() { return Date.monday().set({hour: 12}).equals( Date.parse('12p on monday') ) } }, '12pm on monday': { run: function() { }, assert: function() { return Date.monday().set({hour: 12}).equals( Date.parse('12pm on monday') ) } }, '12 pm on monday': { run: function() { }, assert: function() { return Date.monday().set({hour: 12}).equals( Date.parse('12 pm on monday') ) } }, '12 p.m. on monday': { run: function() { }, assert: function() { return Date.monday().set({hour: 12}).equals( Date.parse('12 p.m. on monday') ) } }, '8a on monday': { run: function() { }, assert: function() { return Date.monday().set({ hour: 8 }).equals( Date.parse('8a on monday') ) } }, '8am on monday': { run: function() { }, assert: function() { return Date.monday().set({ hour: 8 }).equals( Date.parse('8am on monday') ) } }, '8 a.m. on monday': { run: function() { }, assert: function() { return Date.monday().set({ hour: 8 }).equals( Date.parse('8 a.m. on monday') ) } }, '8:15 on monday': { run: function() { }, assert: function() { return Date.monday().set({ hour: 8, minute: 15 }).equals( Date.parse('8:15 on monday') ) } }, '8:15am on monday': { run: function() { }, assert: function() { return Date.monday().set({ hour: 8, minute: 15 }).equals( Date.parse('8:15am on monday') ) } }, '8:15 am on monday': { run: function() { }, assert: function() { return Date.monday().set({ hour: 8, minute: 15 }).equals( Date.parse('8:15 am on monday') ) } }, '8p on monday': { run: function() { }, assert: function() { return Date.monday().set({ hour: 20 }).equals( Date.parse('8p on monday') ) } }, '8pm on monday': { run: function() { }, assert: function() { return Date.monday().set({ hour: 20 }).equals( Date.parse('8pm on monday') ) } }, '8 p.m. on monday': { run: function() { }, assert: function() { return Date.monday().set({ hour: 20 }).equals( Date.parse('8 p.m. on monday') ) } }, '20:15 on monday': { run: function() { }, assert: function() { return Date.monday().set({ hour: 20, minute: 15 }).equals( Date.parse('20:15 on monday') ) } }, '8:15pm on monday': { run: function() { }, assert: function() { return Date.monday().set({ hour: 20, minute: 15 }).equals( Date.parse('8:15pm on monday') ) } }, '8:15 pm on monday': { run: function() { }, assert: function() { return Date.monday().set({ hour: 20, minute: 15 }).equals( Date.parse('8:15 pm on monday') ) } } } }); $(document).ready( function() { Date.Specification.validate().show() } ); ================================================ FILE: tests/rememberthemilk/index.html ================================================ Datejs Test Cases : RememberTheMilk

RememberTheMilk

Comparison support for rememberthemilk.com date and time input formats. See RTM FAQ

================================================ FILE: tests/rememberthemilk/index.js ================================================ Date.Specification = new Specification({ 'RememberTheMilk': { setup: function() { this.now = new Date(); this.now.setMilliseconds(0); }, 'today': { run: function() { }, assert: function() { return Date.today().equals( Date.parse('today') ) } }, 'tod': { run: function() { }, assert: function() { return Date.today().equals( Date.parse('tod') ) } }, 'tomorrow': { run: function() { }, assert: function() { return Date.today().add(1).day().equals( Date.parse('tomorrow') ) } }, 'tom': { run: function() { }, assert: function() { return Date.today().add(1).day().equals( Date.parse('tom') ) } }, '25 Apr': { run: function() { }, assert: function() { return Date.april().set({ day: 25 }).equals( Date.parse('25 Apr') ) } }, 'Apr 25': { run: function() { }, assert: function() { return Date.april().set({ day: 25 }).equals( Date.parse('Apr 25') ) } }, '04/25/2007': { run: function() { }, assert: function() { return new Date(2007,3,25).equals( Date.parse('04/25/2007') ) } }, '25/04/2007': { run: function() { }, assert: function() { return new Date(2007,3,25).equals( Date.parse('25/04/2007') ) } }, '2006/04/25': { run: function() { }, assert: function() { return new Date(2006,3,25).equals( Date.parse('2006/04/25') ) } }, '2006-04-25': { run: function() { }, assert: function() { return new Date(2006,3,25).equals( Date.parse('2006-04-25') ) } }, '25th': { run: function() { }, assert: function() { return Date.today().set({ day: 25 }).equals( Date.parse('25th') ) } }, 'End of month : Not supported currently.': { run: function() { }, assert: function() { return Date.today().moveToLastDayOfMonth().equals( Date.parse('End of month') ) } }, 'Friday': { run: function() { }, assert: function() { return Date.friday().equals( Date.parse('Friday') ) } }, 'Next Friday': { run: function() { }, assert: function() { return Date.today().next().friday().equals( Date.parse('Next Friday') ) } }, 'Fri at 7pm': { run: function() { }, assert: function() { return Date.fri().set({ hour: 19 }).equals( Date.parse('Fri at 7pm') ) } }, 'Fri @ 7pm': { run: function() { }, assert: function() { return Date.fri().set({ hour: 19 }).equals( Date.parse('Fri @ 7pm') ) } }, '6pm': { run: function() { }, assert: function() { return Date.today().set({ hour: 18 }).equals( Date.parse('6pm') ) } }, '18:00': { run: function() { }, assert: function() { return Date.today().set({ hour: 18 }).equals( Date.parse('18:00') ) } }, '5 hours': { run: function() { this.date = Date.parse('5 hours'); this.date.setMilliseconds(0); }, assert: function() { return this.now.add(5).hours().equals( this.date ) } }, '2 days': { run: function() { this.date = Date.parse('2 days'); this.date.setMilliseconds(0); }, assert: function() { return Date.today().add(2).days().equals( this.date ) } }, '3 weeks : Datejs uses "+3 weeks."': { run: function() { this.date = Date.parse('3 weeks'); this.date.setMilliseconds(0); }, assert: function() { return Date.today().add(3).weeks().equals( this.date ) } } } }); $(document).ready( function() { Date.Specification.validate().show() } ); ================================================ FILE: tests/ruby_chronic/index.html ================================================ Datejs Test Cases : Ruby Chronic Comparison

Ruby Chronic Comparison

Comparison support for Ruby Chronic.com date and time input formats.

================================================ FILE: tests/ruby_chronic/index.js ================================================ Date.Specification = new Specification({ 'Pass': { setup: function() { this.now = new Date(); this.now.setMilliseconds(0); }, 'thursday': { run: function() { }, assert: function() { return Date.thursday().equals( Date.parse('thursday') ) } }, 'november': { run: function() { }, assert: function() { return Date.november().equals( Date.parse('november') ) } }, 'friday 1pm': { run: function() { }, assert: function() { return Date.friday().set({hour:13}).equals( Date.parse('friday 1pm') ) } }, 'mon 2:35': { run: function() { }, assert: function() { return Date.monday().set({hour:2, minute:35}).equals( Date.parse('mon 2:35') ) } }, '4pm': { run: function() { }, assert: function() { return Date.today().set({hour:16}).equals( Date.parse('4pm') ) } }, 'yesterday': { run: function() { }, assert: function() { return Date.today().add(-1).day().equals( Date.parse('yesterday') ) } }, 'today': { run: function() { }, assert: function() { return Date.today().equals( Date.parse('today') ) } }, 'tomorrow': { run: function() { }, assert: function() { return Date.today().add(1).day().equals( Date.parse('tomorrow') ) } }, 'next month': { run: function() { }, assert: function() { return Date.today().next().month().equals( Date.parse('next month') ) } }, 'yesterday at 4:00': { run: function() { }, assert: function() { return Date.today().add(-1).day().set({ hour: 4 }).equals( Date.parse('yesterday at 4:00') ) } }, 'last friday at 20:00': { run: function() { }, assert: function() { return Date.today().last().friday().set({ hour: 20 }).equals( Date.parse('last friday at 20:00') ) } }, 'last week tuesday': { run: function() { }, assert: function() { return Date.tuesday().last().week().equals( Date.parse('last week tuesday') ) } }, 'tomorrow at 6:45pm': { run: function() { }, assert: function() { return Date.today().add(1).day().set({ hour: 18, minute: 45}).equals( Date.parse('tomorrow at 6:45pm') ) } }, 'thursday last week': { run: function() { }, assert: function() { return Date.thursday().last().week().equals( Date.parse('thursday last week') ) } }, '5 months before now': { run: function() { }, assert: function() { return new Date().set({ millisecond: 0 }).add(-5).months().equals(Date.parse('5 months before now').set({millisecond: 0})) } }, '7 days from now': { run: function() { }, assert: function() { return new Date().add(7).days().set({millisecond: 0}).equals(Date.parse('7 days from now').set({millisecond:0})) } }, '3 years ago': { run: function() { }, assert: function() { return Date.today().add(-3).years().equals( Date.parse('3 years ago') ) } }, '7 hours ago': { run: function() { }, assert: function() { return (new Date()).add(-7).hours().set({millisecond: 0}).equals(Date.parse('7 hours ago').set({millisecond: 0})) } }, '1 week hence': { run: function() { }, assert: function() { return Date.today().add(7).days().equals(Date.parse('1 week hence')) } }, '1 year ago tomorrow': { run: function() { }, assert: function() { return Date.today().add({years: -1, days: 1}).equals(Date.parse('1 year ago tomorrow')) } }, 'January 5': { run: function() { }, assert: function() { return Date.january().set({day: 5}).equals(Date.parse('January 5')) } }, 'dec 25': { run: function() { }, assert: function() { return Date.december().set({day: 25}).equals(Date.parse('dec 25')) } }, 'may 27th': { run: function() { }, assert: function() { return Date.may().set({day: 27}).equals(Date.parse('may 27th')) } }, 'October 2006': { run: function() { }, assert: function() { return Date.october().set({year: 2006}).equals(Date.parse('October 2006')) } }, 'jan 3 2010': { run: function() { }, assert: function() { return new Date(2010,0,3).equals(Date.parse('jan 3 2010')) } }, 'february 14, 2004': { run: function() { }, assert: function() { return new Date(2004,1,14).equals(Date.parse('february 14, 2004')) } }, '3 jan 2000': { run: function() { }, assert: function() { return new Date(2000,0,3).equals(Date.parse('3 jan 2000')) } }, '5/27/1979': { run: function() { }, assert: function() { return new Date(1979,4,27).equals(Date.parse('5/27/1979')) } }, '27/5/1979': { run: function() { }, assert: function() { return new Date(1979,4,27).equals(Date.parse('27/5/1979')) } }, '05/06': { run: function() { }, assert: function() { return Date.may().set({day: 6}).equals(Date.parse('05/06')) } }, '1979-05-27': { run: function() { }, assert: function() { return new Date(1979,4,27).equals(Date.parse('1979-05-27')) } }, 'Friday': { run: function() { }, assert: function() { return Date.friday().equals(Date.parse('Friday')) } }, '5': { run: function() { }, assert: function() { return Date.today().set({day: 5}).equals(Date.parse('5')) } }, '4:00': { run: function() { }, assert: function() { return Date.today().set({hour: 4}).equals(Date.parse('4:00')) } }, '17:00': { run: function() { }, assert: function() { return Date.today().set({hour: 17}).equals(Date.parse('17:00')) } }, '0800': { run: function() { }, assert: function() { return Date.today().set({year: 800, day: 1}).equals(Date.parse('0800')) } }, '17 april 85': { run: function() { }, assert: function() { return new Date(1985,3,17).equals(Date.parse('17 april 85')) } }, '1979-05-27 05:00': { run: function() { }, assert: function() { return new Date(1979,4,27,5,0,0).equals(Date.parse('1979-05-27 05:00')) } }, 'January 5 @ 7pm': { run: function() { }, assert: function() { return Date.january().set({day: 5, hour: 19}).equals(Date.parse('January 5 @ 7pm')) } } }, 'Fail': { setup: function() { this.now = new Date(); this.now.setMilliseconds(0); }, 'summer : Not really sure what "summer" should return.': { run: function() { }, assert: function() { return Date.july().equals( Date.parse('summer') ) } }, 'friday 13:00 : Both "friday 1pm" and "13:00" pass.': { run: function() { }, assert: function() { return Date.friday().set({hour:13}).equals( Date.parse('friday 13:00') ) } }, '6 in the morning : The term "morning" is not supported': { run: function() { }, assert: function() { return Date.today().set({hour:6}).equals( Date.parse('6 in the morning') ) } }, 'sat 7 in the evening : The term "evening" is not supported': { run: function() { }, assert: function() { return Date.saturday().set({hour:19}).equals( Date.parse('sat 7 in the evening') ) } }, 'this tuesday : The term "this" is not supported': { run: function() { }, assert: function() { return Date.tuesday().equals( Date.parse('this tuesday') ) } }, 'last winter : The term "winter" is not supported': { run: function() { }, assert: function() { return Date.today().set({ month: 11, day: 21 }).add(-1).year().equals( Date.parse('last winter') ) } }, 'this morning : The term "morning" is not supported': { run: function() { }, assert: function() { return Date.today().set({ hour: 9 }).equals( Date.parse('this morning') ) } }, 'last night : The term "night" is not supported': { run: function() { }, assert: function() { return Date.today().set({ hour: 18 }).equals( Date.parse('last night') ) } }, 'this second : The term "this" is not supported': { run: function() { }, assert: function() { return new Date().equals( Date.parse('this second') ) } }, 'afternoon yesterday : The term "afternoon" is not supported': { run: function() { }, assert: function() { return Date.today().add(1).day().set({ hour: 12 }).equals( Date.parse('afternoon yesterday') ) } }, 'in 3 hours : problem with "in"': { run: function() { }, assert: function() { return new Date().set({millisecond:0}).add(3).hours().equals(Date.parse('in 3 hours').set({millisecond:0})) } }, '3 months ago saturday at 5:00 pm': { run: function() { }, assert: function() { return Date.saturday().add({month: -3}).set({hour: 17}).equals(Date.parse('3 months ago saturday at 5:00 pm')) } }, '7 hours before tomorrow at noon': { run: function() { }, assert: function() { return Date.today().add({day: 1}).set({hour: 5}).equals(Date.parse('7 hours before tomorrow at noon')) } }, '3rd wednesday in november': { run: function() { }, assert: function() { return Date.november().third().wednesday().equals(Date.parse('3rd wednesday in november')) } }, '3rd month next year': { run: function() { }, assert: function() { return Date.today().add(1).year().set({month: 2}).equals(Date.parse('3rd month next year')) } }, '3rd thursday this september': { run: function() { }, assert: function() { return Date.september().third().thursday().equals(Date.parse('3rd thursday this september')) } }, '4th day last week': { run: function() { }, assert: function() { return Date.sunday().add(3).days().equals(Date.parse('4th day last week')) } }, 'oct 06 : Currently returns 6th of October, not October 2006': { run: function() { }, assert: function() { return Date.october().set({year: 2006}).equals(Date.parse('oct 06')) } } } }); $(document).ready( function() { Date.Specification.validate().show() } ); ================================================ FILE: tests/scripts/Date_Ext.js ================================================ /** * @class Date * * The date parsing and format syntax is a subset of * PHP's date() function, and the formats that are * supported will provide results equivalent to their PHP versions. * * Following is the list of all currently supported formats: *
Format  Description                                                             Example returned values
------  ----------------------------------------------------------------------  -----------------------
  d     Day of the month, 2 digits with leading zeros                           01 to 31
  D     A textual representation of a day, three letters                        Mon to Sun
  j     Day of the month without leading zeros                                  1 to 31
  l     A full textual representation of the day of the week                    Sunday to Saturday
  S     English ordinal suffix for the day of the month, 2 characters           st, nd, rd or th. Works well with j
  w     Numeric representation of the day of the week                           0 (for Sunday) to 6 (for Saturday)
  z     The day of the year (starting from 0)                                   0 to 364 (365 in leap years)
  W     ISO-8601 week number of year, weeks starting on Monday                  1 to 53
  F     A full textual representation of a month, such as January or March      January to December
  m     Numeric representation of a month, with leading zeros                   01 to 12
  M     A short textual representation of a month, three letters                Jan to Dec
  n     Numeric representation of a month, without leading zeros                1 to 12
  t     Number of days in the given month                                       28 to 31
  L     Whether it's a leap year                                                1 if it is a leap year, 0 otherwise.
  Y     A full numeric representation of a year, 4 digits                       Examples: 1999 or 2003
  y     A two digit representation of a year                                    Examples: 99 or 03
  a     Lowercase Ante meridiem and Post meridiem                               am or pm
  A     Uppercase Ante meridiem and Post meridiem                               AM or PM
  g     12-hour format of an hour without leading zeros                         1 to 12
  G     24-hour format of an hour without leading zeros                         0 to 23
  h     12-hour format of an hour with leading zeros                            01 to 12
  H     24-hour format of an hour with leading zeros                            00 to 23
  i     Minutes, with leading zeros                                             00 to 59
  s     Seconds, with leading zeros                                             00 to 59
  u     Milliseconds, with leading zeros                                        001 to 999
  O     Difference to Greenwich time (GMT) in hours                             Example: +0200
  T     Timezone abbreviation of the machine running the code                   Examples: EST, MDT ...
  Z     Timezone offset in seconds (negative if west of UTC, positive if east)  -43200 to 50400
* * Example usage (note that you must escape format specifiers with '\\' to render them as character literals): *

// Sample date:
// 'Wed Jan 10 2007 15:05:01 GMT-0600 (Central Standard Time)'

var dt = new Date('1/10/2007 03:05:01 PM GMT-0600');
document.write(dt.format('Y-m-d'));                         //2007-01-10
document.write(dt.format('F j, Y, g:i a'));                 //January 10, 2007, 3:05 pm
document.write(dt.format('l, \\t\\he dS of F Y h:i:s A'));  //Wednesday, the 10th of January 2007 03:05:01 PM
 
* * Here are some standard date/time patterns that you might find helpful. They * are not part of the source of Date.js, but to use them you can simply copy this * block of code into any script that is included after Date.js and they will also become * globally available on the Date object. Feel free to add or remove patterns as needed in your code. *

Date.patterns = {
    ISO8601Long:"Y-m-d H:i:s",
    ISO8601Short:"Y-m-d",
    ShortDate: "n/j/Y",
    LongDate: "l, F d, Y",
    FullDateTime: "l, F d, Y g:i:s A",
    MonthDay: "F d",
    ShortTime: "g:i A",
    LongTime: "g:i:s A",
    SortableDateTime: "Y-m-d\\TH:i:s",
    UniversalSortableDateTime: "Y-m-d H:i:sO",
    YearMonth: "F, Y"
};
* * Example usage: *

var dt = new Date();
document.write(dt.format(Date.patterns.ShortDate));
 
*/ /* * Most of the date-formatting functions below are the excellent work of Baron Schwartz. * They generate precompiled functions from date formats instead of parsing and * processing the pattern every time you format a date. These functions are available * on every Date object (any javascript function). * * The original article and download are here: * http://www.xaprb.com/blog/2005/12/12/javascript-closures-for-runtime-efficiency/ * */ // private Date.parseFunctions = {count:0}; // private Date.parseRegexes = []; // private Date.formatFunctions = {count:0}; // private Date.prototype.dateFormat = function(format) { if (Date.formatFunctions[format] == null) { Date.createNewFormat(format); } var func = Date.formatFunctions[format]; return this[func](); }; /** * Formats a date given the supplied format string * @param {String} format The format string * @return {String} The formatted date * @method */ Date.prototype.format = Date.prototype.dateFormat; // private Date.createNewFormat = function(format) { var funcName = "format" + Date.formatFunctions.count++; Date.formatFunctions[format] = funcName; var code = "Date.prototype." + funcName + " = function(){return "; var special = false; var ch = ''; for (var i = 0; i < format.length; ++i) { ch = format.charAt(i); if (!special && ch == "\\") { special = true; } else if (special) { special = false; code += "'" + String.escape(ch) + "' + "; } else { code += Date.getFormatCode(ch); } } eval(code.substring(0, code.length - 3) + ";}"); }; // private Date.getFormatCode = function(character) { switch (character) { case "d": return "String.leftPad(this.getDate(), 2, '0') + "; case "D": return "Date.dayNames[this.getDay()].substring(0, 3) + "; case "j": return "this.getDate() + "; case "l": return "Date.dayNames[this.getDay()] + "; case "S": return "this.getSuffix() + "; case "w": return "this.getDay() + "; case "z": return "this.getDayOfYear() + "; case "W": return "this.getWeekOfYear() + "; case "F": return "Date.monthNames[this.getMonth()] + "; case "m": return "String.leftPad(this.getMonth() + 1, 2, '0') + "; case "M": return "Date.monthNames[this.getMonth()].substring(0, 3) + "; case "n": return "(this.getMonth() + 1) + "; case "t": return "this.getDaysInMonth() + "; case "L": return "(this.isLeapYear() ? 1 : 0) + "; case "Y": return "this.getFullYear() + "; case "y": return "('' + this.getFullYear()).substring(2, 4) + "; case "a": return "(this.getHours() < 12 ? 'am' : 'pm') + "; case "A": return "(this.getHours() < 12 ? 'AM' : 'PM') + "; case "g": return "((this.getHours() % 12) ? this.getHours() % 12 : 12) + "; case "G": return "this.getHours() + "; case "h": return "String.leftPad((this.getHours() % 12) ? this.getHours() % 12 : 12, 2, '0') + "; case "H": return "String.leftPad(this.getHours(), 2, '0') + "; case "i": return "String.leftPad(this.getMinutes(), 2, '0') + "; case "s": return "String.leftPad(this.getSeconds(), 2, '0') + "; case "u": return "String.leftPad(this.getMilliseconds(), 3, '0') + "; case "O": return "this.getGMTOffset() + "; case "T": return "this.getTimezone() + "; case "Z": return "(this.getTimezoneOffset() * -60) + "; default: return "'" + String.escape(character) + "' + "; } }; /** * Parses the passed string using the specified format. Note that this function expects dates in normal calendar * format, meaning that months are 1-based (1 = January) and not zero-based like in JavaScript dates. Any part of * the date format that is not specified will default to the current date value for that part. Time parts can also * be specified, but default to 0. Keep in mind that the input date string must precisely match the specified format * string or the parse operation will fail. * Example Usage:

//dt = Fri May 25 2007 (current date)
var dt = new Date();

//dt = Thu May 25 2006 (today's month/day in 2006)
dt = Date.parseDate("2006", "Y");

//dt = Sun Jan 15 2006 (all date parts specified)
dt = Date.parseDate("2006-01-15", "Y-m-d");

//dt = Sun Jan 15 2006 15:20:01 GMT-0600 (CST)
dt = Date.parseDate("2006-01-15 3:20:01 PM", "Y-m-d h:i:s A" );
* @param {String} input The unparsed date as a string * @param {String} format The format the date is in * @return {Date} The parsed date * @static */ Date.parseDate = function(input, format) { if (Date.parseFunctions[format] == null) { Date.createParser(format); } var func = Date.parseFunctions[format]; return Date[func](input); }; // private Date.createParser = function(format) { var funcName = "parse" + Date.parseFunctions.count++; var regexNum = Date.parseRegexes.length; var currentGroup = 1; Date.parseFunctions[format] = funcName; var code = "Date." + funcName + " = function(input){\n" + "var y = -1, m = -1, d = -1, h = -1, i = -1, s = -1, ms = -1, o, z, v;\n" + "var d = new Date();\n" + "y = d.getFullYear();\n" + "m = d.getMonth();\n" + "d = d.getDate();\n" + "var results = input.match(Date.parseRegexes[" + regexNum + "]);\n" + "if (results && results.length > 0) {"; var regex = ""; var special = false; var ch = ''; for (var i = 0; i < format.length; ++i) { ch = format.charAt(i); if (!special && ch == "\\") { special = true; } else if (special) { special = false; regex += String.escape(ch); } else { var obj = Date.formatCodeToRegex(ch, currentGroup); currentGroup += obj.g; regex += obj.s; if (obj.g && obj.c) { code += obj.c; } } } code += "if (y >= 0 && m >= 0 && d > 0 && h >= 0 && i >= 0 && s >= 0 && ms >= 0)\n" + "{v = new Date(y, m, d, h, i, s, ms);}\n" + "else if (y >= 0 && m >= 0 && d > 0 && h >= 0 && i >= 0 && s >= 0)\n" + "{v = new Date(y, m, d, h, i, s);}\n" + "else if (y >= 0 && m >= 0 && d > 0 && h >= 0 && i >= 0)\n" + "{v = new Date(y, m, d, h, i);}\n" + "else if (y >= 0 && m >= 0 && d > 0 && h >= 0)\n" + "{v = new Date(y, m, d, h);}\n" + "else if (y >= 0 && m >= 0 && d > 0)\n" + "{v = new Date(y, m, d);}\n" + "else if (y >= 0 && m >= 0)\n" + "{v = new Date(y, m);}\n" + "else if (y >= 0)\n" + "{v = new Date(y);}\n" + "}return (v && (z || o))?\n" // favour UTC offset over GMT offset + " ((z)? v.add(Date.SECOND, (v.getTimezoneOffset() * 60) + (z*1)) :\n" // reset to UTC, then add offset + " v.add(Date.HOUR, (v.getGMTOffset() / 100) + (o / -100))) : v\n" // reset to GMT, then add offset + ";}"; Date.parseRegexes[regexNum] = new RegExp("^" + regex + "$", "i"); eval(code); }; // private Date.formatCodeToRegex = function(character, currentGroup) { /* * currentGroup = position in regex result array * g = calculation group (0 or 1. only group 1 contributes to date calculations.) * c = calculation method (required for group 1. null for group 0.) * s = regex string */ switch (character) { case "D": return {g:0, c:null, s:"(?:Sun|Mon|Tue|Wed|Thu|Fri|Sat)"}; case "j": return {g:1, c:"d = parseInt(results[" + currentGroup + "], 10);\n", s:"(\\d{1,2})"}; // day of month without leading zeroes case "d": return {g:1, c:"d = parseInt(results[" + currentGroup + "], 10);\n", s:"(\\d{2})"}; // day of month with leading zeroes case "l": return {g:0, c:null, s:"(?:" + Date.dayNames.join("|") + ")"}; case "S": return {g:0, c:null, s:"(?:st|nd|rd|th)"}; case "w": return {g:0, c:null, s:"\\d"}; case "z": return {g:0, c:null, s:"(?:\\d{1,3})"}; case "W": return {g:0, c:null, s:"(?:\\d{1,2})"}; case "F": return {g:1, c:"m = parseInt(Date.monthNumbers[results[" + currentGroup + "].substring(0, 1).toUpperCase() + results[" + currentGroup + "].substring(1, 3).toLowerCase()], 10);\n", s:"(" + Date.monthNames.join("|") + ")"}; case "M": return {g:1, c:"m = parseInt(Date.monthNumbers[results[" + currentGroup + "].substring(0, 1).toUpperCase() + results[" + currentGroup + "].substring(1, 3).toLowerCase()], 10);\n", s:"(Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)"}; case "n": return {g:1, c:"m = parseInt(results[" + currentGroup + "], 10) - 1;\n", s:"(\\d{1,2})"}; // Numeric representation of a month, without leading zeros case "m": return {g:1, c:"m = parseInt(results[" + currentGroup + "], 10) - 1;\n", s:"(\\d{2})"}; // Numeric representation of a month, with leading zeros case "t": return {g:0, c:null, s:"\\d{1,2}"}; case "L": return {g:0, c:null, s:"(?:1|0)"}; case "Y": return {g:1, c:"y = parseInt(results[" + currentGroup + "], 10);\n", s:"(\\d{4})"}; case "y": return {g:1, c:"var ty = parseInt(results[" + currentGroup + "], 10);\n" + "y = ty > Date.y2kYear ? 1900 + ty : 2000 + ty;\n", s:"(\\d{1,2})"}; case "a": return {g:1, c:"if (results[" + currentGroup + "] == 'am') {\n" + "if (h == 12) { h = 0; }\n" + "} else { if (h < 12) { h += 12; }}", s:"(am|pm)"}; case "A": return {g:1, c:"if (results[" + currentGroup + "] == 'AM') {\n" + "if (h == 12) { h = 0; }\n" + "} else { if (h < 12) { h += 12; }}", s:"(AM|PM)"}; case "g": case "G": return {g:1, c:"h = parseInt(results[" + currentGroup + "], 10);\n", s:"(\\d{1,2})"}; // 12/24-hr format format of an hour without leading zeroes case "h": case "H": return {g:1, c:"h = parseInt(results[" + currentGroup + "], 10);\n", s:"(\\d{2})"}; // 12/24-hr format format of an hour with leading zeroes case "i": return {g:1, c:"i = parseInt(results[" + currentGroup + "], 10);\n", s:"(\\d{2})"}; case "s": return {g:1, c:"s = parseInt(results[" + currentGroup + "], 10);\n", s:"(\\d{2})"}; case "u": return {g:1, c:"ms = parseInt(results[" + currentGroup + "], 10);\n", s:"(\\d{3})"}; case "O": return {g:1, c:[ "o = results[", currentGroup, "];\n", "var sn = o.substring(0,1);\n", // get + / - sign "var hr = o.substring(1,3)*1 + Math.floor(o.substring(3,5) / 60);\n", // get hours (performs minutes-to-hour conversion also) "var mn = o.substring(3,5) % 60;\n", // get minutes "o = ((-12 <= (hr*60 + mn)/60) && ((hr*60 + mn)/60 <= 14))?\n", // -12hrs <= GMT offset <= 14hrs " (sn + String.leftPad(hr, 2, 0) + String.leftPad(mn, 2, 0)) : null;\n" ].join(""), s:"([+\-]\\d{4})"}; case "T": return {g:0, c:null, s:"[A-Z]{1,4}"}; // timezone abbrev. may be between 1 - 4 chars case "Z": return {g:1, c:"z = results[" + currentGroup + "] * 1;\n" // -43200 <= UTC offset <= 50400 + "z = (-43200 <= z && z <= 50400)? z : null;\n", s:"([+\-]?\\d{1,5})"}; // leading '+' sign is optional for UTC offset default: return {g:0, c:null, s:String.escape(character)}; } }; /** * Get the timezone abbreviation of the current date (equivalent to the format specifier 'T'). * @return {String} The abbreviated timezone name (e.g. 'CST') */ Date.prototype.getTimezone = function() { return this.toString().replace(/^.*? ([A-Z]{1,4})[\-+][0-9]{4} .*$/, "$1"); }; /** * Get the offset from GMT of the current date (equivalent to the format specifier 'O'). * @return {String} The 4-character offset string prefixed with + or - (e.g. '-0600') */ Date.prototype.getGMTOffset = function() { return (this.getTimezoneOffset() > 0 ? "-" : "+") + String.leftPad(Math.abs(Math.floor(this.getTimezoneOffset() / 60)), 2, "0") + String.leftPad(this.getTimezoneOffset() % 60, 2, "0"); }; /** * Get the numeric day number of the year, adjusted for leap year. * @return {Number} 0 to 364 (365 in leap years) */ Date.prototype.getDayOfYear = function() { var num = 0; Date.daysInMonth[1] = this.isLeapYear() ? 29 : 28; for (var i = 0; i < this.getMonth(); ++i) { num += Date.daysInMonth[i]; } return num + this.getDate() - 1; }; /** * Get the numeric ISO-8601 week number of the year * (equivalent to the format specifier 'W'). * @return {Number} 1 to 53 */ Date.prototype.getWeekOfYear = function() { /* original getWeek() function developed by Nick Baicoianu at MeanFreePath: http://www.meanfreepath.com */ var jan1 = new Date(this.getFullYear(), 0, 1); var day = jan1.getDay() - 1; // the day of week the year begins on day = (day >= 0 ? day : day + 7); var daynum = Math.floor((this.getTime() - jan1.getTime() - (this.getTimezoneOffset()-jan1.getTimezoneOffset())*60000)/86400000) + 1; var weeknum; // if the year starts before the middle of a week if (day < 4) { weeknum = Math.floor((daynum + day - 1) / 7) + 1; if (weeknum > 52) { jan1 = new Date(this.getFullYear() + 1, 0, 1); day = jan1.getDay() - 1; day = (day >= 0 ? day : day + 7); // if the next year starts before the middle of the week, it is week #1 of that year weeknum = day < 4 ? 1 : 53; } } else { weeknum = Math.floor((daynum + day - 1) / 7) || 52; } return weeknum; }; /** * Whether or not the current date is in a leap year. * @return {Boolean} True if the current date is in a leap year, else false */ Date.prototype.isLeapYear = function() { var year = this.getFullYear(); return ((year & 3) == 0 && (year % 100 || (year % 400 == 0 && year))); }; /** * Get the first day of the current month, adjusted for leap year. The returned value * is the numeric day index within the week (0-6) which can be used in conjunction with * the {@link #monthNames} array to retrieve the textual day name. * Example: *

var dt = new Date('1/10/2007');
document.write(Date.dayNames[dt.getFirstDayOfMonth()]); //output: 'Monday'
* @return {Number} The day number (0-6) */ Date.prototype.getFirstDayOfMonth = function() { var day = (this.getDay() - (this.getDate() - 1)) % 7; return (day < 0) ? (day + 7) : day; }; /** * Get the last day of the current month, adjusted for leap year. The returned value * is the numeric day index within the week (0-6) which can be used in conjunction with * the {@link #monthNames} array to retrieve the textual day name. * Example: *

var dt = new Date('1/10/2007');
document.write(Date.dayNames[dt.getLastDayOfMonth()]); //output: 'Wednesday'
* @return {Number} The day number (0-6) */ Date.prototype.getLastDayOfMonth = function() { var day = (this.getDay() + (Date.daysInMonth[this.getMonth()] - this.getDate())) % 7; return (day < 0) ? (day + 7) : day; }; /** * Get the date of the first day of the month in which this date resides * @return {Date} */ Date.prototype.getFirstDateOfMonth = function() { return new Date(this.getFullYear(), this.getMonth(), 1); }; /** * Get the date of the last day of the month in which this date resides * @return {Date} */ Date.prototype.getLastDateOfMonth = function() { return new Date(this.getFullYear(), this.getMonth(), this.getDaysInMonth()); }; /** * Get the number of days in the current month, adjusted for leap year. * @return {Number} The number of days in the month */ Date.prototype.getDaysInMonth = function() { Date.daysInMonth[1] = this.isLeapYear() ? 29 : 28; return Date.daysInMonth[this.getMonth()]; }; /** * Get the English ordinal suffix of the current day (equivalent to the format specifier 'S'). * @return {String} 'st, 'nd', 'rd' or 'th' */ Date.prototype.getSuffix = function() { switch (this.getDate()) { case 1: case 21: case 31: return "st"; case 2: case 22: return "nd"; case 3: case 23: return "rd"; default: return "th"; } }; // private Date.daysInMonth = [31,28,31,30,31,30,31,31,30,31,30,31]; /** * An array of textual month names. * Override these values for international dates, for example... * Date.monthNames = ['JanInYourLang', 'FebInYourLang', ...]; * @type Array * @static */ Date.monthNames = ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"]; /** * An array of textual day names. * Override these values for international dates, for example... * Date.dayNames = ['SundayInYourLang', 'MondayInYourLang', ...]; * @type Array * @static */ Date.dayNames = ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"]; // private Date.y2kYear = 50; // private Date.monthNumbers = { Jan:0, Feb:1, Mar:2, Apr:3, May:4, Jun:5, Jul:6, Aug:7, Sep:8, Oct:9, Nov:10, Dec:11}; /** * Creates and returns a new Date instance with the exact same date value as the called instance. * Dates are copied and passed by reference, so if a copied date variable is modified later, the original * variable will also be changed. When the intention is to create a new variable that will not * modify the original instance, you should create a clone. * * Example of correctly cloning a date: *

//wrong way:
var orig = new Date('10/1/2006');
var copy = orig;
copy.setDate(5);
document.write(orig);  //returns 'Thu Oct 05 2006'!

//correct way:
var orig = new Date('10/1/2006');
var copy = orig.clone();
copy.setDate(5);
document.write(orig);  //returns 'Thu Oct 01 2006'
* @return {Date} The new Date instance */ Date.prototype.clone = function() { return new Date(this.getTime()); }; /** * Clears any time information from this date @param {Boolean} clone true to create a clone of this date, clear the time and return it @return {Date} this or the clone */ Date.prototype.clearTime = function(clone){ if(clone){ return this.clone().clearTime(); } this.setHours(0); this.setMinutes(0); this.setSeconds(0); this.setMilliseconds(0); return this; }; // private // safari setMonth is broken //if(Ext.isSafari){ // Date.brokenSetMonth = Date.prototype.setMonth; // Date.prototype.setMonth = function(num){ // if(num <= -1){ // var n = Math.ceil(-num); // var back_year = Math.ceil(n/12); // var month = (n % 12) ? 12 - n % 12 : 0 ; // this.setFullYear(this.getFullYear() - back_year); // return Date.brokenSetMonth.call(this, month); // } else { // return Date.brokenSetMonth.apply(this, arguments); // } // }; //} /** Date interval constant @static @type String */ Date.MILLI = "ms"; /** Date interval constant @static @type String */ Date.SECOND = "s"; /** Date interval constant @static @type String */ Date.MINUTE = "mi"; /** Date interval constant @static @type String */ Date.HOUR = "h"; /** Date interval constant @static @type String */ Date.DAY = "d"; /** Date interval constant @static @type String */ Date.MONTH = "mo"; /** Date interval constant @static @type String */ Date.YEAR = "y"; /** * Provides a convenient method of performing basic date arithmetic. This method * does not modify the Date instance being called - it creates and returns * a new Date instance containing the resulting date value. * * Examples: *

//Basic usage:
var dt = new Date('10/29/2006').add(Date.DAY, 5);
document.write(dt); //returns 'Fri Oct 06 2006 00:00:00'

//Negative values will subtract correctly:
var dt2 = new Date('10/1/2006').add(Date.DAY, -5);
document.write(dt2); //returns 'Tue Sep 26 2006 00:00:00'

//You can even chain several calls together in one line!
var dt3 = new Date('10/1/2006').add(Date.DAY, 5).add(Date.HOUR, 8).add(Date.MINUTE, -30);
document.write(dt3); //returns 'Fri Oct 06 2006 07:30:00'
 
* * @param {String} interval A valid date interval enum value * @param {Number} value The amount to add to the current date * @return {Date} The new Date instance */ Date.prototype.add = function(interval, value){ var d = this.clone(); if (!interval || value === 0) return d; switch(interval.toLowerCase()){ case Date.MILLI: d.setMilliseconds(this.getMilliseconds() + value); break; case Date.SECOND: d.setSeconds(this.getSeconds() + value); break; case Date.MINUTE: d.setMinutes(this.getMinutes() + value); break; case Date.HOUR: d.setHours(this.getHours() + value); break; case Date.DAY: d.setDate(this.getDate() + value); break; case Date.MONTH: var day = this.getDate(); if(day > 28){ day = Math.min(day, this.getFirstDateOfMonth().add('mo', value).getLastDateOfMonth().getDate()); } d.setDate(day); d.setMonth(this.getMonth() + value); break; case Date.YEAR: d.setFullYear(this.getFullYear() + value); break; } return d; }; /** * Checks if this date falls on or between the given start and end dates * @param {Date} start Start date * @param {Date} end End date * @return {Boolean} true if this date falls on or between the given start and end dates */ Date.prototype.between = function(start, end){ var t = this.getTime(); return start.getTime() <= t && t <= end.getTime(); } ================================================ FILE: tests/scripts/cruiser.js ================================================ var Cruiser = { About: { Description : 'Javascript framework ', Author : 'Dan Yoder', Version : { major: '0', minor: '4' }, Notices : { Copyright: '(c) 2007 Dan Yoder' }, License : 'Cruiser is freely distributable under the terms of the MIT license.', URL : 'http://dev.zeraweb.com/cruiser/' } } var Module = function(m) { if (m) { for( var k in Module.prototype ) { m[k] = Module.prototype[k] }; return m; } else { return this } }; Module.prototype = { extend: function(m) { for( var k in m ) { this.prototype[k] = m[k] }; return this; } }; Cruiser.String = { lstrip: function() { return this.replace(/^\s*/,'') }, rstrip: function() { return this.replace(/\s*$/,'') }, strip: function() { return this.lstrip().rstrip() }, map: function( args, f ) { var g = function( s, p ) { return f.apply( s, p ); } return args.inject( this, g ); }, toCharArray: String.prototype.toArray, toArray: function( separator ) { if ( separator ) { var f = function( s ) { return s.blank() ? null : s.strip() }; return this.split( separator || ',' ).map( f ); } else { return this.toCharArray() } } }; Module( String ).extend( Cruiser.String ); ================================================ FILE: tests/scripts/date-functions.js ================================================ /* * Copyright (C) 2004 Baron Schwartz * * This program is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by the * Free Software Foundation, version 2.1. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more * details. */ Date.parseFunctions = {count:0}; Date.parseRegexes = []; Date.formatFunctions = {count:0}; Date.prototype.dateFormat = function(format) { if (Date.formatFunctions[format] == null) { Date.createNewFormat(format); } var func = Date.formatFunctions[format]; return this[func](); } Date.createNewFormat = function(format) { var funcName = "format" + Date.formatFunctions.count++; Date.formatFunctions[format] = funcName; var code = "Date.prototype." + funcName + " = function(){return "; var special = false; var ch = ''; for (var i = 0; i < format.length; ++i) { ch = format.charAt(i); if (!special && ch == "\\") { special = true; } else if (special) { special = false; code += "'" + String.escape(ch) + "' + "; } else { code += Date.getFormatCode(ch); } } eval(code.substring(0, code.length - 3) + ";}"); } Date.getFormatCode = function(character) { switch (character) { case "d": return "String.leftPad(this.getDate(), 2, '0') + "; case "D": return "Date.dayNames[this.getDay()].substring(0, 3) + "; case "j": return "this.getDate() + "; case "l": return "Date.dayNames[this.getDay()] + "; case "S": return "this.getSuffix() + "; case "w": return "this.getDay() + "; case "z": return "this.getDayOfYear() + "; case "W": return "this.getWeekOfYear() + "; case "F": return "Date.monthNames[this.getMonth()] + "; case "m": return "String.leftPad(this.getMonth() + 1, 2, '0') + "; case "M": return "Date.monthNames[this.getMonth()].substring(0, 3) + "; case "n": return "(this.getMonth() + 1) + "; case "t": return "this.getDaysInMonth() + "; case "L": return "(this.isLeapYear() ? 1 : 0) + "; case "Y": return "this.getFullYear() + "; case "y": return "('' + this.getFullYear()).substring(2, 4) + "; case "a": return "(this.getHours() < 12 ? 'am' : 'pm') + "; case "A": return "(this.getHours() < 12 ? 'AM' : 'PM') + "; case "g": return "((this.getHours() %12) ? this.getHours() % 12 : 12) + "; case "G": return "this.getHours() + "; case "h": return "String.leftPad((this.getHours() %12) ? this.getHours() % 12 : 12, 2, '0') + "; case "H": return "String.leftPad(this.getHours(), 2, '0') + "; case "i": return "String.leftPad(this.getMinutes(), 2, '0') + "; case "s": return "String.leftPad(this.getSeconds(), 2, '0') + "; case "O": return "this.getGMTOffset() + "; case "T": return "this.getTimezone() + "; case "Z": return "(this.getTimezoneOffset() * -60) + "; default: return "'" + String.escape(character) + "' + "; } } Date.parseDate = function(input, format) { if (Date.parseFunctions[format] == null) { Date.createParser(format); } var func = Date.parseFunctions[format]; return Date[func](input); } Date.createParser = function(format) { var funcName = "parse" + Date.parseFunctions.count++; var regexNum = Date.parseRegexes.length; var currentGroup = 1; Date.parseFunctions[format] = funcName; var code = "Date." + funcName + " = function(input){\n" + "var y = -1, m = -1, d = -1, h = -1, i = -1, s = -1;\n" + "var d = new Date();\n" + "y = d.getFullYear();\n" + "m = d.getMonth();\n" + "d = d.getDate();\n" + "var results = input.match(Date.parseRegexes[" + regexNum + "]);\n" + "if (results && results.length > 0) {" var regex = ""; var special = false; var ch = ''; for (var i = 0; i < format.length; ++i) { ch = format.charAt(i); if (!special && ch == "\\") { special = true; } else if (special) { special = false; regex += String.escape(ch); } else { obj = Date.formatCodeToRegex(ch, currentGroup); currentGroup += obj.g; regex += obj.s; if (obj.g && obj.c) { code += obj.c; } } } code += "if (y > 0 && m >= 0 && d > 0 && h >= 0 && i >= 0 && s >= 0)\n" + "{return new Date(y, m, d, h, i, s);}\n" + "else if (y > 0 && m >= 0 && d > 0 && h >= 0 && i >= 0)\n" + "{return new Date(y, m, d, h, i);}\n" + "else if (y > 0 && m >= 0 && d > 0 && h >= 0)\n" + "{return new Date(y, m, d, h);}\n" + "else if (y > 0 && m >= 0 && d > 0)\n" + "{return new Date(y, m, d);}\n" + "else if (y > 0 && m >= 0)\n" + "{return new Date(y, m);}\n" + "else if (y > 0)\n" + "{return new Date(y);}\n" + "}return null;}"; Date.parseRegexes[regexNum] = new RegExp("^" + regex + "$"); eval(code); } Date.formatCodeToRegex = function(character, currentGroup) { switch (character) { case "D": return {g:0, c:null, s:"(?:Sun|Mon|Tue|Wed|Thu|Fri|Sat)"}; case "j": case "d": return {g:1, c:"d = parseInt(results[" + currentGroup + "], 10);\n", s:"(\\d{1,2})"}; case "l": return {g:0, c:null, s:"(?:" + Date.dayNames.join("|") + ")"}; case "S": return {g:0, c:null, s:"(?:st|nd|rd|th)"}; case "w": return {g:0, c:null, s:"\\d"}; case "z": return {g:0, c:null, s:"(?:\\d{1,3})"}; case "W": return {g:0, c:null, s:"(?:\\d{2})"}; case "F": return {g:1, c:"m = parseInt(Date.monthNumbers[results[" + currentGroup + "].substring(0, 3)], 10);\n", s:"(" + Date.monthNames.join("|") + ")"}; case "M": return {g:1, c:"m = parseInt(Date.monthNumbers[results[" + currentGroup + "]], 10);\n", s:"(Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)"}; case "n": case "m": return {g:1, c:"m = parseInt(results[" + currentGroup + "], 10) - 1;\n", s:"(\\d{1,2})"}; case "t": return {g:0, c:null, s:"\\d{1,2}"}; case "L": return {g:0, c:null, s:"(?:1|0)"}; case "Y": return {g:1, c:"y = parseInt(results[" + currentGroup + "], 10);\n", s:"(\\d{4})"}; case "y": return {g:1, c:"var ty = parseInt(results[" + currentGroup + "], 10);\n" + "y = ty > Date.y2kYear ? 1900 + ty : 2000 + ty;\n", s:"(\\d{1,2})"}; case "a": return {g:1, c:"if (results[" + currentGroup + "] == 'am') {\n" + "if (h == 12) { h = 0; }\n" + "} else { if (h < 12) { h += 12; }}", s:"(am|pm)"}; case "A": return {g:1, c:"if (results[" + currentGroup + "] == 'AM') {\n" + "if (h == 12) { h = 0; }\n" + "} else { if (h < 12) { h += 12; }}", s:"(AM|PM)"}; case "g": case "G": case "h": case "H": return {g:1, c:"h = parseInt(results[" + currentGroup + "], 10);\n", s:"(\\d{1,2})"}; case "i": return {g:1, c:"i = parseInt(results[" + currentGroup + "], 10);\n", s:"(\\d{2})"}; case "s": return {g:1, c:"s = parseInt(results[" + currentGroup + "], 10);\n", s:"(\\d{2})"}; case "O": return {g:0, c:null, s:"[+-]\\d{4}"}; case "T": return {g:0, c:null, s:"[A-Z]{3}"}; case "Z": return {g:0, c:null, s:"[+-]\\d{1,5}"}; default: return {g:0, c:null, s:String.escape(character)}; } } Date.prototype.getTimezone = function() { return this.toString().replace( /^.*? ([A-Z]{3}) [0-9]{4}.*$/, "$1").replace( /^.*?\(([A-Z])[a-z]+ ([A-Z])[a-z]+ ([A-Z])[a-z]+\)$/, "$1$2$3"); } Date.prototype.getGMTOffset = function() { return (this.getTimezoneOffset() > 0 ? "-" : "+") + String.leftPad(Math.floor(this.getTimezoneOffset() / 60), 2, "0") + String.leftPad(this.getTimezoneOffset() % 60, 2, "0"); } //Date.prototype.getDayOfYear2 = function() { // var num = 0; // Date.daysInMonth[1] = this.isLeapYear() ? 29 : 28; // for (var i = 0; i < this.getMonth(); ++i) { // num += Date.daysInMonth[i]; // } // return num + this.getDate() - 1; //} Date.prototype.getDayOfYear2 = function() { var num = 0; Date.daysInMonth[1] = this.isLeapYear() ? 29 : 28; for (var i = 0; i < this.getMonth(); ++i) { num += Date.daysInMonth[i]; } return num + this.getDate() - 1; }; //Date.prototype.getWeekOfYear = function() { // // Skip to Thursday of this week // var now = this.getDayOfYear() + (4 - this.getDay()); // // Find the first Thursday of the year // var jan1 = new Date(this.getFullYear(), 0, 1); // var then = (7 - jan1.getDay() + 4); // return String.leftPad(((now - then) / 7) + 1, 2, "0"); //} Date.prototype.getWeekOfYear = function() { // adapted from http://www.merlyn.demon.co.uk/weekcalc.htm var ms1d = 864e5; // milliseconds in a day var ms7d = 7 * ms1d; // milliseconds in a week var DC3 = Date.UTC(this.getFullYear(), this.getMonth(), this.getDate() + 3) / ms1d; // an Absolute Day Number var AWN = Math.floor(DC3 / 7); // an Absolute Week Number var Wyr = new Date(AWN * ms7d).getUTCFullYear(); return AWN - Math.floor(Date.UTC(Wyr, 0, 7) / ms7d) + 1; }; Date.prototype.isLeapYear = function() { var year = this.getFullYear(); return ((year & 3) == 0 && (year % 100 || (year % 400 == 0 && year))); } Date.prototype.getFirstDayOfMonth = function() { var day = (this.getDay() - (this.getDate() - 1)) % 7; return (day < 0) ? (day + 7) : day; } Date.prototype.getLastDayOfMonth = function() { var day = (this.getDay() + (Date.daysInMonth[this.getMonth()] - this.getDate())) % 7; return (day < 0) ? (day + 7) : day; } Date.prototype.getDaysInMonth = function() { Date.daysInMonth[1] = this.isLeapYear() ? 29 : 28; return Date.daysInMonth[this.getMonth()]; } Date.prototype.getSuffix = function() { switch (this.getDate()) { case 1: case 21: case 31: return "st"; case 2: case 22: return "nd"; case 3: case 23: return "rd"; default: return "th"; } } String.escape = function(string) { return string.replace(/('|\\)/g, "\\$1"); } String.leftPad = function (val, size, ch) { var result = new String(val); if (ch == null) { ch = " "; } while (result.length < size) { result = ch + result; } return result; } Date.daysInMonth = [31,28,31,30,31,30,31,31,30,31,30,31]; Date.monthNames = ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"]; Date.dayNames = ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"]; Date.y2kYear = 50; Date.monthNumbers = { Jan:0, Feb:1, Mar:2, Apr:3, May:4, Jun:5, Jul:6, Aug:7, Sep:8, Oct:9, Nov:10, Dec:11}; Date.patterns = { ISO8601LongPattern:"Y-m-d H:i:s", ISO8601ShortPattern:"Y-m-d", ShortDatePattern: "n/j/Y", LongDatePattern: "l, F d, Y", FullDateTimePattern: "l, F d, Y g:i:s A", MonthDayPattern: "F d", ShortTimePattern: "g:i A", LongTimePattern: "g:i:s A", SortableDateTimePattern: "Y-m-d\\TH:i:s", UniversalSortableDateTimePattern: "Y-m-d H:i:sO", YearMonthPattern: "F, Y"}; ================================================ FILE: tests/scripts/debugging.js ================================================ var _ = Date.Parsing.Operators, G = Date.Grammar, T = Date.Translator; var _test = function(r, s, x, y) { var rx; x = x||{}; y = y||{}; var start = Date.now(); try { rx = r.call( x, s ); } catch(e) { console.log(e); } var finish = new Date(); if ( rx[0] instanceof Array ) { rx[0].flatten().compact().each( function( fn ) { fn.call( y ); } ); } else if ( rx[0] instanceof Function ) { rx[0].call(y); } if ( rx[1].length ) { console.log("Failed to parse: '" + rx[1] + "'."); } console.log("Ran in " + (finish-start) + "ms."); console.log(y); }; ================================================ FILE: tests/scripts/enumerable.js ================================================ var Hash = function(object) { if (object) { for(var k in object) { if (!(typeof this[k]=='function')) { this[k] = object[k] } } } }; Hash.convert = function(object) { for( var k in Hash.prototype ) { object[k] = Hash.prototype[k] }; return object; }; Hash.prototype = { each: function( fn ) { for( var k in this ) { if (! ( typeof this[k] == 'function' )) { fn({0:k, 1: this[k], key: k, value: this[k]}) } } return this; }, merge: function( hash ) { var self = this; new Hash(hash).each( function(item) { self[item.key] = item.value }); return this; } }; Array.convert = function(object) { if (object instanceof Array ) { return object } else if (object.toArray) { return object.toArray() } else { var rval = []; for(var i = 0; i Firebug
================================================ FILE: tests/scripts/firebug/firebug.js ================================================ if (!window.console || !console.firebug) { (function() { window.console = { log: function() { logFormatted(arguments, ""); }, debug: function() { logFormatted(arguments, "debug"); }, info: function() { logFormatted(arguments, "info"); }, warn: function() { logFormatted(arguments, "warning"); }, error: function() { logFormatted(arguments, "error"); }, assert: function(truth, message) { if (!truth) { var args = []; for (var i = 1; i < arguments.length; ++i) args.push(arguments[i]); logFormatted(args.length ? args : ["Assertion Failure"], "error"); throw message ? message : "Assertion Failure"; } }, dir: function(object) { var html = []; var pairs = []; for (var name in object) { try { pairs.push([name, object[name]]); } catch (exc) { } } pairs.sort(function(a, b) { return a[0] < b[0] ? -1 : 1; }); html.push(''); for (var i = 0; i < pairs.length; ++i) { var name = pairs[i][0], value = pairs[i][1]; html.push('', '', ''); } html.push('
', escapeHTML(name), ''); appendObject(value, html); html.push('
'); logRow(html, "dir"); }, dirxml: function(node) { var html = []; appendNode(node, html); logRow(html, "dirxml"); }, group: function() { logRow(arguments, "group", pushGroup); }, groupEnd: function() { logRow(arguments, "", popGroup); }, time: function(name) { timeMap[name] = (new Date()).getTime(); }, timeEnd: function(name) { if (name in timeMap) { var delta = (new Date()).getTime() - timeMap[name]; logFormatted([name+ ":", delta+"ms"]); delete timeMap[name]; } }, count: function() { this.warn(["count() not supported."]); }, trace: function() { this.warn(["trace() not supported."]); }, profile: function() { this.warn(["profile() not supported."]); }, profileEnd: function() { }, clear: function() { consoleBody.innerHTML = ""; }, open: function() { toggleConsole(true); }, close: function() { if (frameVisible) toggleConsole(); } }; // ******************************************************************************************** var consoleFrame = null; var consoleBody = null; var commandLine = null; var frameVisible = false; var messageQueue = []; var groupStack = []; var timeMap = {}; var clPrefix = ">>> "; var isFirefox = navigator.userAgent.indexOf("Firefox") != -1; var isIE = navigator.userAgent.indexOf("MSIE") != -1; var isOpera = navigator.userAgent.indexOf("Opera") != -1; var isSafari = navigator.userAgent.indexOf("AppleWebKit") != -1; // ******************************************************************************************** function toggleConsole(forceOpen) { frameVisible = forceOpen || !frameVisible; if (consoleFrame) consoleFrame.style.visibility = frameVisible ? "visible" : "hidden"; else waitForBody(); } function focusCommandLine() { toggleConsole(true); if (commandLine) commandLine.focus(); } function waitForBody() { if (document.body) createFrame(); else setTimeout(waitForBody, 200); } function createFrame() { if (consoleFrame) return; window.onFirebugReady = function(doc) { window.onFirebugReady = null; var toolbar = doc.getElementById("toolbar"); toolbar.onmousedown = onSplitterMouseDown; commandLine = doc.getElementById("commandLine"); addEvent(commandLine, "keydown", onCommandLineKeyDown); addEvent(doc, isIE || isSafari ? "keydown" : "keypress", onKeyDown); consoleBody = doc.getElementById("log"); layout(); flush(); } var baseURL = getFirebugURL(); consoleFrame = document.createElement("iframe"); consoleFrame.setAttribute("src", baseURL+"/firebug.html"); consoleFrame.setAttribute("frameBorder", "0"); consoleFrame.style.visibility = (frameVisible ? "visible" : "hidden"); consoleFrame.style.zIndex = "2147483583"; consoleFrame.style.position = document.all ? "absolute" : "fixed"; consoleFrame.style.width = "100%"; consoleFrame.style.left = "0"; consoleFrame.style.bottom = "0"; consoleFrame.style.height = "200px"; document.body.appendChild(consoleFrame); } function getFirebugURL() { var scripts = document.getElementsByTagName("script"); for (var i = 0; i < scripts.length; ++i) { if (scripts[i].src.indexOf("firebug.js") != -1) { var lastSlash = scripts[i].src.lastIndexOf("/"); return scripts[i].src.substr(0, lastSlash); } } } function evalCommandLine() { var text = commandLine.value; commandLine.value = ""; logRow([clPrefix, text], "command"); var value; try { value = eval(text); } catch (exc) { } console.log(value); } function layout() { var toolbar = consoleBody.ownerDocument.getElementById("toolbar"); var height = consoleFrame.offsetHeight - (toolbar.offsetHeight + commandLine.offsetHeight); consoleBody.style.top = toolbar.offsetHeight + "px"; consoleBody.style.height = height + "px"; commandLine.style.top = (consoleFrame.offsetHeight - commandLine.offsetHeight) + "px"; } function logRow(message, className, handler) { if (consoleBody) writeMessage(message, className, handler); else { messageQueue.push([message, className, handler]); waitForBody(); } } function flush() { var queue = messageQueue; messageQueue = []; for (var i = 0; i < queue.length; ++i) writeMessage(queue[i][0], queue[i][1], queue[i][2]); } function writeMessage(message, className, handler) { var isScrolledToBottom = consoleBody.scrollTop + consoleBody.offsetHeight >= consoleBody.scrollHeight; if (!handler) handler = writeRow; handler(message, className); if (isScrolledToBottom) consoleBody.scrollTop = consoleBody.scrollHeight - consoleBody.offsetHeight; } function appendRow(row) { var container = groupStack.length ? groupStack[groupStack.length-1] : consoleBody; container.appendChild(row); } function writeRow(message, className) { var row = consoleBody.ownerDocument.createElement("div"); row.className = "logRow" + (className ? " logRow-"+className : ""); row.innerHTML = message.join(""); appendRow(row); } function pushGroup(message, className) { logFormatted(message, className); var groupRow = consoleBody.ownerDocument.createElement("div"); groupRow.className = "logGroup"; var groupRowBox = consoleBody.ownerDocument.createElement("div"); groupRowBox.className = "logGroupBox"; groupRow.appendChild(groupRowBox); appendRow(groupRowBox); groupStack.push(groupRowBox); } function popGroup() { groupStack.pop(); } // ******************************************************************************************** function logFormatted(objects, className) { var html = []; var format = objects[0]; var objIndex = 0; if (typeof(format) != "string") { format = ""; objIndex = -1; } var parts = parseFormat(format); for (var i = 0; i < parts.length; ++i) { var part = parts[i]; if (part && typeof(part) == "object") { var object = objects[++objIndex]; part.appender(object, html); } else appendText(part, html); } for (var i = objIndex+1; i < objects.length; ++i) { appendText(" ", html); var object = objects[i]; if (typeof(object) == "string") appendText(object, html); else appendObject(object, html); } logRow(html, className); } function parseFormat(format) { var parts = []; var reg = /((^%|[^\\]%)(\d+)?(\.)([a-zA-Z]))|((^%|[^\\]%)([a-zA-Z]))/; var appenderMap = {s: appendText, d: appendInteger, i: appendInteger, f: appendFloat}; for (var m = reg.exec(format); m; m = reg.exec(format)) { var type = m[8] ? m[8] : m[5]; var appender = type in appenderMap ? appenderMap[type] : appendObject; var precision = m[3] ? parseInt(m[3]) : (m[4] == "." ? -1 : 0); parts.push(format.substr(0, m[0][0] == "%" ? m.index : m.index+1)); parts.push({appender: appender, precision: precision}); format = format.substr(m.index+m[0].length); } parts.push(format); return parts; } function escapeHTML(value) { function replaceChars(ch) { switch (ch) { case "<": return "<"; case ">": return ">"; case "&": return "&"; case "'": return "'"; case '"': return """; } return "?"; }; return String(value).replace(/[<>&"']/g, replaceChars); } function objectToString(object) { try { return object+""; } catch (exc) { return null; } } // ******************************************************************************************** function appendText(object, html) { html.push(escapeHTML(objectToString(object))); } function appendNull(object, html) { html.push('', escapeHTML(objectToString(object)), ''); } function appendString(object, html) { html.push('"', escapeHTML(objectToString(object)), '"'); } function appendInteger(object, html) { html.push('', escapeHTML(objectToString(object)), ''); } function appendFloat(object, html) { html.push('', escapeHTML(objectToString(object)), ''); } function appendFunction(object, html) { var reName = /function ?(.*?)\(/; var m = reName.exec(objectToString(object)); var name = m ? m[1] : "function"; html.push('', escapeHTML(name), '()'); } function appendObject(object, html) { try { if (object == undefined) appendNull("undefined", html); else if (object == null) appendNull("null", html); else if (typeof object == "string") appendString(object, html); else if (typeof object == "number") appendInteger(object, html); else if (typeof object == "function") appendFunction(object, html); else if (object.nodeType == 1) appendSelector(object, html); else if (typeof object == "object") appendObjectFormatted(object, html); else appendText(object, html); } catch (exc) { } } function appendObjectFormatted(object, html) { var text = objectToString(object); var reObject = /\[object (.*?)\]/; var m = reObject.exec(text); html.push('', m ? m[1] : text, '') } function appendSelector(object, html) { html.push(''); html.push('', escapeHTML(object.nodeName.toLowerCase()), ''); if (object.id) html.push('#', escapeHTML(object.id), ''); if (object.className) html.push('.', escapeHTML(object.className), ''); html.push(''); } function appendNode(node, html) { if (node.nodeType == 1) { html.push( '
', '<', node.nodeName.toLowerCase(), ''); for (var i = 0; i < node.attributes.length; ++i) { var attr = node.attributes[i]; if (!attr.specified) continue; html.push(' ', attr.nodeName.toLowerCase(), '="', escapeHTML(attr.nodeValue), '"') } if (node.firstChild) { html.push('>
'); for (var child = node.firstChild; child; child = child.nextSibling) appendNode(child, html); html.push('
</', node.nodeName.toLowerCase(), '>
'); } else html.push('/>
'); } else if (node.nodeType == 3) { html.push('
', escapeHTML(node.nodeValue), '
'); } } // ******************************************************************************************** function addEvent(object, name, handler) { if (document.all) object.attachEvent("on"+name, handler); else object.addEventListener(name, handler, false); } function removeEvent(object, name, handler) { if (document.all) object.detachEvent("on"+name, handler); else object.removeEventListener(name, handler, false); } function cancelEvent(event) { if (document.all) event.cancelBubble = true; else event.stopPropagation(); } function onError(msg, href, lineNo) { var html = []; var lastSlash = href.lastIndexOf("/"); var fileName = lastSlash == -1 ? href : href.substr(lastSlash+1); html.push( '', msg, '', '' ); logRow(html, "error"); }; function onKeyDown(event) { if (event.keyCode == 123) toggleConsole(); else if ((event.keyCode == 108 || event.keyCode == 76) && event.shiftKey && (event.metaKey || event.ctrlKey)) focusCommandLine(); else return; cancelEvent(event); } function onSplitterMouseDown(event) { if (isSafari || isOpera) return; addEvent(document, "mousemove", onSplitterMouseMove); addEvent(document, "mouseup", onSplitterMouseUp); for (var i = 0; i < frames.length; ++i) { addEvent(frames[i].document, "mousemove", onSplitterMouseMove); addEvent(frames[i].document, "mouseup", onSplitterMouseUp); } } function onSplitterMouseMove(event) { var win = document.all ? event.srcElement.ownerDocument.parentWindow : event.target.ownerDocument.defaultView; var clientY = event.clientY; if (win != win.parent) clientY += win.frameElement ? win.frameElement.offsetTop : 0; var height = consoleFrame.offsetTop + consoleFrame.clientHeight; var y = height - clientY; consoleFrame.style.height = y + "px"; layout(); } function onSplitterMouseUp(event) { removeEvent(document, "mousemove", onSplitterMouseMove); removeEvent(document, "mouseup", onSplitterMouseUp); for (var i = 0; i < frames.length; ++i) { removeEvent(frames[i].document, "mousemove", onSplitterMouseMove); removeEvent(frames[i].document, "mouseup", onSplitterMouseUp); } } function onCommandLineKeyDown(event) { if (event.keyCode == 13) evalCommandLine(); else if (event.keyCode == 27) commandLine.value = ""; } window.onerror = onError; addEvent(document, isIE || isSafari ? "keydown" : "keypress", onKeyDown); if (document.documentElement.getAttribute("debug") == "true") toggleConsole(true); })(); } ================================================ FILE: tests/scripts/firebug/firebugx.js ================================================ if (!("console" in window) || !("firebug" in console)) { var names = ["log", "debug", "info", "warn", "error", "assert", "dir", "dirxml", "group", "groupEnd", "time", "timeEnd", "count", "trace", "profile", "profileEnd"]; window.console = {}; for (var i = 0; i < names.length; ++i) window.console[names[i]] = function() {} } ================================================ FILE: tests/scripts/jquery-1.2.1.pack.js ================================================ /* * jQuery 1.2.1 - New Wave Javascript * * Copyright (c) 2007 John Resig (jquery.com) * Dual licensed under the MIT (MIT-LICENSE.txt) * and GPL (GPL-LICENSE.txt) licenses. * * $Date: 2007-09-16 23:42:06 -0400 (Sun, 16 Sep 2007) $ * $Rev: 3353 $ */ eval(function(p,a,c,k,e,r){e=function(c){return(c35?String.fromCharCode(c+29):c.toString(36))};if(!''.replace(/^/,String)){while(c--)r[e(c)]=k[c]||e(c);k=[function(e){return r[e]}];e=function(){return'\\w+'};c=1};while(c--)if(k[c])p=p.replace(new RegExp('\\b'+e(c)+'\\b','g'),k[c]);return p}('(G(){9(1m E!="W")H w=E;H E=18.15=G(a,b){I 6 7u E?6.5N(a,b):1u E(a,b)};9(1m $!="W")H D=$;18.$=E;H u=/^[^<]*(<(.|\\s)+>)[^>]*$|^#(\\w+)$/;E.1b=E.3A={5N:G(c,a){c=c||U;9(1m c=="1M"){H m=u.2S(c);9(m&&(m[1]||!a)){9(m[1])c=E.4D([m[1]],a);J{H b=U.3S(m[3]);9(b)9(b.22!=m[3])I E().1Y(c);J{6[0]=b;6.K=1;I 6}J c=[]}}J I 1u E(a).1Y(c)}J 9(E.1n(c))I 1u E(U)[E.1b.2d?"2d":"39"](c);I 6.6v(c.1c==1B&&c||(c.4c||c.K&&c!=18&&!c.1y&&c[0]!=W&&c[0].1y)&&E.2h(c)||[c])},4c:"1.2.1",7Y:G(){I 6.K},K:0,21:G(a){I a==W?E.2h(6):6[a]},2o:G(a){H b=E(a);b.4Y=6;I b},6v:G(a){6.K=0;1B.3A.1a.16(6,a);I 6},N:G(a,b){I E.N(6,a,b)},4I:G(a){H b=-1;6.N(G(i){9(6==a)b=i});I b},1x:G(f,d,e){H c=f;9(f.1c==3X)9(d==W)I 6.K&&E[e||"1x"](6[0],f)||W;J{c={};c[f]=d}I 6.N(G(a){L(H b 1i c)E.1x(e?6.R:6,b,E.1e(6,c[b],e,a,b))})},17:G(b,a){I 6.1x(b,a,"3C")},2g:G(e){9(1m e!="5i"&&e!=S)I 6.4n().3g(U.6F(e));H t="";E.N(e||6,G(){E.N(6.3j,G(){9(6.1y!=8)t+=6.1y!=1?6.6x:E.1b.2g([6])})});I t},5m:G(b){9(6[0])E(b,6[0].3H).6u().3d(6[0]).1X(G(){H a=6;1W(a.1w)a=a.1w;I a}).3g(6);I 6},8m:G(a){I 6.N(G(){E(6).6q().5m(a)})},8d:G(a){I 6.N(G(){E(6).5m(a)})},3g:G(){I 6.3z(1q,Q,1,G(a){6.58(a)})},6j:G(){I 6.3z(1q,Q,-1,G(a){6.3d(a,6.1w)})},6g:G(){I 6.3z(1q,P,1,G(a){6.12.3d(a,6)})},50:G(){I 6.3z(1q,P,-1,G(a){6.12.3d(a,6.2q)})},2D:G(){I 6.4Y||E([])},1Y:G(t){H b=E.1X(6,G(a){I E.1Y(t,a)});I 6.2o(/[^+>] [^+>]/.14(t)||t.1g("..")>-1?E.4V(b):b)},6u:G(e){H f=6.1X(G(){I 6.67?E(6.67)[0]:6.4R(Q)});H d=f.1Y("*").4O().N(G(){9(6[F]!=W)6[F]=S});9(e===Q)6.1Y("*").4O().N(G(i){H c=E.M(6,"2P");L(H a 1i c)L(H b 1i c[a])E.1j.1f(d[i],a,c[a][b],c[a][b].M)});I f},1E:G(t){I 6.2o(E.1n(t)&&E.2W(6,G(b,a){I t.16(b,[a])})||E.3m(t,6))},5V:G(t){I 6.2o(t.1c==3X&&E.3m(t,6,Q)||E.2W(6,G(a){I(t.1c==1B||t.4c)?E.2A(a,t)<0:a!=t}))},1f:G(t){I 6.2o(E.1R(6.21(),t.1c==3X?E(t).21():t.K!=W&&(!t.11||E.11(t,"2Y"))?t:[t]))},3t:G(a){I a?E.3m(a,6).K>0:P},7c:G(a){I 6.3t("."+a)},3i:G(b){9(b==W){9(6.K){H c=6[0];9(E.11(c,"24")){H e=c.4Z,a=[],Y=c.Y,2G=c.O=="24-2G";9(e<0)I S;L(H i=2G?e:0,33=2G?e+1:Y.K;i<33;i++){H d=Y[i];9(d.26){H b=E.V.1h&&!d.9V["1Q"].9L?d.2g:d.1Q;9(2G)I b;a.1a(b)}}I a}J I 6[0].1Q.1p(/\\r/g,"")}}J I 6.N(G(){9(b.1c==1B&&/4k|5j/.14(6.O))6.2Q=(E.2A(6.1Q,b)>=0||E.2A(6.2H,b)>=0);J 9(E.11(6,"24")){H a=b.1c==1B?b:[b];E("9h",6).N(G(){6.26=(E.2A(6.1Q,a)>=0||E.2A(6.2g,a)>=0)});9(!a.K)6.4Z=-1}J 6.1Q=b})},4o:G(a){I a==W?(6.K?6[0].3O:S):6.4n().3g(a)},6H:G(a){I 6.50(a).28()},6E:G(i){I 6.2J(i,i+1)},2J:G(){I 6.2o(1B.3A.2J.16(6,1q))},1X:G(b){I 6.2o(E.1X(6,G(a,i){I b.2O(a,i,a)}))},4O:G(){I 6.1f(6.4Y)},3z:G(f,d,g,e){H c=6.K>1,a;I 6.N(G(){9(!a){a=E.4D(f,6.3H);9(g<0)a.8U()}H b=6;9(d&&E.11(6,"1I")&&E.11(a[0],"4m"))b=6.4l("1K")[0]||6.58(U.5B("1K"));E.N(a,G(){H a=c?6.4R(Q):6;9(!5A(0,a))e.2O(b,a)})})}};G 5A(i,b){H a=E.11(b,"1J");9(a){9(b.3k)E.3G({1d:b.3k,3e:P,1V:"1J"});J E.5f(b.2g||b.6s||b.3O||"");9(b.12)b.12.3b(b)}J 9(b.1y==1)E("1J",b).N(5A);I a}E.1k=E.1b.1k=G(){H c=1q[0]||{},a=1,2c=1q.K,5e=P;9(c.1c==8o){5e=c;c=1q[1]||{}}9(2c==1){c=6;a=0}H b;L(;a<2c;a++)9((b=1q[a])!=S)L(H i 1i b){9(c==b[i])6r;9(5e&&1m b[i]==\'5i\'&&c[i])E.1k(c[i],b[i]);J 9(b[i]!=W)c[i]=b[i]}I c};H F="15"+(1u 3D()).3B(),6p=0,5c={};E.1k({8a:G(a){18.$=D;9(a)18.15=w;I E},1n:G(a){I!!a&&1m a!="1M"&&!a.11&&a.1c!=1B&&/G/i.14(a+"")},4a:G(a){I a.2V&&!a.1G||a.37&&a.3H&&!a.3H.1G},5f:G(a){a=E.36(a);9(a){9(18.6l)18.6l(a);J 9(E.V.1N)18.56(a,0);J 3w.2O(18,a)}},11:G(b,a){I b.11&&b.11.27()==a.27()},1L:{},M:G(c,d,b){c=c==18?5c:c;H a=c[F];9(!a)a=c[F]=++6p;9(d&&!E.1L[a])E.1L[a]={};9(b!=W)E.1L[a][d]=b;I d?E.1L[a][d]:a},30:G(c,b){c=c==18?5c:c;H a=c[F];9(b){9(E.1L[a]){2E E.1L[a][b];b="";L(b 1i E.1L[a])1T;9(!b)E.30(c)}}J{2a{2E c[F]}29(e){9(c.53)c.53(F)}2E E.1L[a]}},N:G(a,b,c){9(c){9(a.K==W)L(H i 1i a)b.16(a[i],c);J L(H i=0,48=a.K;i<48;i++)9(b.16(a[i],c)===P)1T}J{9(a.K==W)L(H i 1i a)b.2O(a[i],i,a[i]);J L(H i=0,48=a.K,3i=a[0];i<48&&b.2O(3i,i,3i)!==P;3i=a[++i]){}}I a},1e:G(c,b,d,e,a){9(E.1n(b))b=b.2O(c,[e]);H f=/z-?4I|7T-?7Q|1r|69|7P-?1H/i;I b&&b.1c==4W&&d=="3C"&&!f.14(a)?b+"2T":b},1o:{1f:G(b,c){E.N((c||"").2l(/\\s+/),G(i,a){9(!E.1o.3K(b.1o,a))b.1o+=(b.1o?" ":"")+a})},28:G(b,c){b.1o=c!=W?E.2W(b.1o.2l(/\\s+/),G(a){I!E.1o.3K(c,a)}).66(" "):""},3K:G(t,c){I E.2A(c,(t.1o||t).3s().2l(/\\s+/))>-1}},2k:G(e,o,f){L(H i 1i o){e.R["3r"+i]=e.R[i];e.R[i]=o[i]}f.16(e,[]);L(H i 1i o)e.R[i]=e.R["3r"+i]},17:G(e,p){9(p=="1H"||p=="2N"){H b={},42,41,d=["7J","7I","7G","7F"];E.N(d,G(){b["7C"+6]=0;b["7B"+6+"5Z"]=0});E.2k(e,b,G(){9(E(e).3t(\':3R\')){42=e.7A;41=e.7w}J{e=E(e.4R(Q)).1Y(":4k").5W("2Q").2D().17({4C:"1P",2X:"4F",19:"2Z",7o:"0",1S:"0"}).5R(e.12)[0];H a=E.17(e.12,"2X")||"3V";9(a=="3V")e.12.R.2X="7g";42=e.7e;41=e.7b;9(a=="3V")e.12.R.2X="3V";e.12.3b(e)}});I p=="1H"?42:41}I E.3C(e,p)},3C:G(h,j,i){H g,2w=[],2k=[];G 3n(a){9(!E.V.1N)I P;H b=U.3o.3Z(a,S);I!b||b.4y("3n")==""}9(j=="1r"&&E.V.1h){g=E.1x(h.R,"1r");I g==""?"1":g}9(j.1t(/4u/i))j=y;9(!i&&h.R[j])g=h.R[j];J 9(U.3o&&U.3o.3Z){9(j.1t(/4u/i))j="4u";j=j.1p(/([A-Z])/g,"-$1").2p();H d=U.3o.3Z(h,S);9(d&&!3n(h))g=d.4y(j);J{L(H a=h;a&&3n(a);a=a.12)2w.4w(a);L(a=0;a<2w.K;a++)9(3n(2w[a])){2k[a]=2w[a].R.19;2w[a].R.19="2Z"}g=j=="19"&&2k[2w.K-1]!=S?"2s":U.3o.3Z(h,S).4y(j)||"";L(a=0;a<2k.K;a++)9(2k[a]!=S)2w[a].R.19=2k[a]}9(j=="1r"&&g=="")g="1"}J 9(h.3Q){H f=j.1p(/\\-(\\w)/g,G(m,c){I c.27()});g=h.3Q[j]||h.3Q[f];9(!/^\\d+(2T)?$/i.14(g)&&/^\\d/.14(g)){H k=h.R.1S;H e=h.4v.1S;h.4v.1S=h.3Q.1S;h.R.1S=g||0;g=h.R.71+"2T";h.R.1S=k;h.4v.1S=e}}I g},4D:G(a,e){H r=[];e=e||U;E.N(a,G(i,d){9(!d)I;9(d.1c==4W)d=d.3s();9(1m d=="1M"){d=d.1p(/(<(\\w+)[^>]*?)\\/>/g,G(m,a,b){I b.1t(/^(70|6Z|6Y|9Q|4t|9N|9K|3a|9G|9E)$/i)?m:a+">"});H s=E.36(d).2p(),1s=e.5B("1s"),2x=[];H c=!s.1g("<9y")&&[1,"<24>",""]||!s.1g("<9w")&&[1,"<6T>",""]||s.1t(/^<(9u|1K|9t|9r|9p)/)&&[1,"<1I>",""]||!s.1g("<4m")&&[2,"<1I><1K>",""]||(!s.1g("<9m")||!s.1g("<9k"))&&[3,"<1I><1K><4m>",""]||!s.1g("<6Y")&&[2,"<1I><1K><6L>",""]||E.V.1h&&[1,"1s<1s>",""]||[0,"",""];1s.3O=c[1]+d+c[2];1W(c[0]--)1s=1s.5p;9(E.V.1h){9(!s.1g("<1I")&&s.1g("<1K")<0)2x=1s.1w&&1s.1w.3j;J 9(c[1]=="<1I>"&&s.1g("<1K")<0)2x=1s.3j;L(H n=2x.K-1;n>=0;--n)9(E.11(2x[n],"1K")&&!2x[n].3j.K)2x[n].12.3b(2x[n]);9(/^\\s/.14(d))1s.3d(e.6F(d.1t(/^\\s*/)[0]),1s.1w)}d=E.2h(1s.3j)}9(0===d.K&&(!E.11(d,"2Y")&&!E.11(d,"24")))I;9(d[0]==W||E.11(d,"2Y")||d.Y)r.1a(d);J r=E.1R(r,d)});I r},1x:G(c,d,a){H e=E.4a(c)?{}:E.5o;9(d=="26"&&E.V.1N)c.12.4Z;9(e[d]){9(a!=W)c[e[d]]=a;I c[e[d]]}J 9(E.V.1h&&d=="R")I E.1x(c.R,"9e",a);J 9(a==W&&E.V.1h&&E.11(c,"2Y")&&(d=="9d"||d=="9a"))I c.97(d).6x;J 9(c.37){9(a!=W){9(d=="O"&&E.11(c,"4t")&&c.12)6G"O 94 93\'t 92 91";c.90(d,a)}9(E.V.1h&&/6C|3k/.14(d)&&!E.4a(c))I c.4p(d,2);I c.4p(d)}J{9(d=="1r"&&E.V.1h){9(a!=W){c.69=1;c.1E=(c.1E||"").1p(/6O\\([^)]*\\)/,"")+(3I(a).3s()=="8S"?"":"6O(1r="+a*6A+")")}I c.1E?(3I(c.1E.1t(/1r=([^)]*)/)[1])/6A).3s():""}d=d.1p(/-([a-z])/8Q,G(z,b){I b.27()});9(a!=W)c[d]=a;I c[d]}},36:G(t){I(t||"").1p(/^\\s+|\\s+$/g,"")},2h:G(a){H r=[];9(1m a!="8P")L(H i=0,2c=a.K;i<2c;i++)r.1a(a[i]);J r=a.2J(0);I r},2A:G(b,a){L(H i=0,2c=a.K;i<2c;i++)9(a[i]==b)I i;I-1},1R:G(a,b){9(E.V.1h){L(H i=0;b[i];i++)9(b[i].1y!=8)a.1a(b[i])}J L(H i=0;b[i];i++)a.1a(b[i]);I a},4V:G(b){H r=[],2f={};2a{L(H i=0,6y=b.K;i<6y;i++){H a=E.M(b[i]);9(!2f[a]){2f[a]=Q;r.1a(b[i])}}}29(e){r=b}I r},2W:G(b,a,c){9(1m a=="1M")a=3w("P||G(a,i){I "+a+"}");H d=[];L(H i=0,4g=b.K;i<4g;i++)9(!c&&a(b[i],i)||c&&!a(b[i],i))d.1a(b[i]);I d},1X:G(c,b){9(1m b=="1M")b=3w("P||G(a){I "+b+"}");H d=[];L(H i=0,4g=c.K;i<4g;i++){H a=b(c[i],i);9(a!==S&&a!=W){9(a.1c!=1B)a=[a];d=d.8M(a)}}I d}});H v=8K.8I.2p();E.V={4s:(v.1t(/.+(?:8F|8E|8C|8B)[\\/: ]([\\d.]+)/)||[])[1],1N:/6w/.14(v),34:/34/.14(v),1h:/1h/.14(v)&&!/34/.14(v),35:/35/.14(v)&&!/(8z|6w)/.14(v)};H y=E.V.1h?"4h":"5h";E.1k({5g:!E.V.1h||U.8y=="8x",4h:E.V.1h?"4h":"5h",5o:{"L":"8w","8v":"1o","4u":y,5h:y,4h:y,3O:"3O",1o:"1o",1Q:"1Q",3c:"3c",2Q:"2Q",8u:"8t",26:"26",8s:"8r"}});E.N({1D:"a.12",8q:"15.4e(a,\'12\')",8p:"15.2I(a,2,\'2q\')",8n:"15.2I(a,2,\'4d\')",8l:"15.4e(a,\'2q\')",8k:"15.4e(a,\'4d\')",8j:"15.5d(a.12.1w,a)",8i:"15.5d(a.1w)",6q:"15.11(a,\'8h\')?a.8f||a.8e.U:15.2h(a.3j)"},G(i,n){E.1b[i]=G(a){H b=E.1X(6,n);9(a&&1m a=="1M")b=E.3m(a,b);I 6.2o(E.4V(b))}});E.N({5R:"3g",8c:"6j",3d:"6g",8b:"50",89:"6H"},G(i,n){E.1b[i]=G(){H a=1q;I 6.N(G(){L(H j=0,2c=a.K;j<2c;j++)E(a[j])[n](6)})}});E.N({5W:G(a){E.1x(6,a,"");6.53(a)},88:G(c){E.1o.1f(6,c)},87:G(c){E.1o.28(6,c)},86:G(c){E.1o[E.1o.3K(6,c)?"28":"1f"](6,c)},28:G(a){9(!a||E.1E(a,[6]).r.K){E.30(6);6.12.3b(6)}},4n:G(){E("*",6).N(G(){E.30(6)});1W(6.1w)6.3b(6.1w)}},G(i,n){E.1b[i]=G(){I 6.N(n,1q)}});E.N(["85","5Z"],G(i,a){H n=a.2p();E.1b[n]=G(h){I 6[0]==18?E.V.1N&&3y["84"+a]||E.5g&&38.33(U.2V["5a"+a],U.1G["5a"+a])||U.1G["5a"+a]:6[0]==U?38.33(U.1G["6n"+a],U.1G["6m"+a]):h==W?(6.K?E.17(6[0],n):S):6.17(n,h.1c==3X?h:h+"2T")}});H C=E.V.1N&&3x(E.V.4s)<83?"(?:[\\\\w*57-]|\\\\\\\\.)":"(?:[\\\\w\\82-\\81*57-]|\\\\\\\\.)",6k=1u 47("^>\\\\s*("+C+"+)"),6i=1u 47("^("+C+"+)(#)("+C+"+)"),6h=1u 47("^([#.]?)("+C+"*)");E.1k({55:{"":"m[2]==\'*\'||15.11(a,m[2])","#":"a.4p(\'22\')==m[2]",":":{80:"im[3]-0",2I:"m[3]-0==i",6E:"m[3]-0==i",3v:"i==0",3u:"i==r.K-1",6f:"i%2==0",6e:"i%2","3v-46":"a.12.4l(\'*\')[0]==a","3u-46":"15.2I(a.12.5p,1,\'4d\')==a","7X-46":"!15.2I(a.12.5p,2,\'4d\')",1D:"a.1w",4n:"!a.1w",7W:"(a.6s||a.7V||15(a).2g()||\'\').1g(m[3])>=0",3R:\'"1P"!=a.O&&15.17(a,"19")!="2s"&&15.17(a,"4C")!="1P"\',1P:\'"1P"==a.O||15.17(a,"19")=="2s"||15.17(a,"4C")=="1P"\',7U:"!a.3c",3c:"a.3c",2Q:"a.2Q",26:"a.26||15.1x(a,\'26\')",2g:"\'2g\'==a.O",4k:"\'4k\'==a.O",5j:"\'5j\'==a.O",54:"\'54\'==a.O",52:"\'52\'==a.O",51:"\'51\'==a.O",6d:"\'6d\'==a.O",6c:"\'6c\'==a.O",2r:\'"2r"==a.O||15.11(a,"2r")\',4t:"/4t|24|6b|2r/i.14(a.11)",3K:"15.1Y(m[3],a).K",7S:"/h\\\\d/i.14(a.11)",7R:"15.2W(15.32,G(1b){I a==1b.T;}).K"}},6a:[/^(\\[) *@?([\\w-]+) *([!*$^~=]*) *(\'?"?)(.*?)\\4 *\\]/,/^(:)([\\w-]+)\\("?\'?(.*?(\\(.*?\\))?[^(]*?)"?\'?\\)/,1u 47("^([:.#]*)("+C+"+)")],3m:G(a,c,b){H d,2b=[];1W(a&&a!=d){d=a;H f=E.1E(a,c,b);a=f.t.1p(/^\\s*,\\s*/,"");2b=b?c=f.r:E.1R(2b,f.r)}I 2b},1Y:G(t,o){9(1m t!="1M")I[t];9(o&&!o.1y)o=S;o=o||U;H d=[o],2f=[],3u;1W(t&&3u!=t){H r=[];3u=t;t=E.36(t);H l=P;H g=6k;H m=g.2S(t);9(m){H p=m[1].27();L(H i=0;d[i];i++)L(H c=d[i].1w;c;c=c.2q)9(c.1y==1&&(p=="*"||c.11.27()==p.27()))r.1a(c);d=r;t=t.1p(g,"");9(t.1g(" ")==0)6r;l=Q}J{g=/^([>+~])\\s*(\\w*)/i;9((m=g.2S(t))!=S){r=[];H p=m[2],1R={};m=m[1];L(H j=0,31=d.K;j<31;j++){H n=m=="~"||m=="+"?d[j].2q:d[j].1w;L(;n;n=n.2q)9(n.1y==1){H h=E.M(n);9(m=="~"&&1R[h])1T;9(!p||n.11.27()==p.27()){9(m=="~")1R[h]=Q;r.1a(n)}9(m=="+")1T}}d=r;t=E.36(t.1p(g,""));l=Q}}9(t&&!l){9(!t.1g(",")){9(o==d[0])d.44();2f=E.1R(2f,d);r=d=[o];t=" "+t.68(1,t.K)}J{H k=6i;H m=k.2S(t);9(m){m=[0,m[2],m[3],m[1]]}J{k=6h;m=k.2S(t)}m[2]=m[2].1p(/\\\\/g,"");H f=d[d.K-1];9(m[1]=="#"&&f&&f.3S&&!E.4a(f)){H q=f.3S(m[2]);9((E.V.1h||E.V.34)&&q&&1m q.22=="1M"&&q.22!=m[2])q=E(\'[@22="\'+m[2]+\'"]\',f)[0];d=r=q&&(!m[3]||E.11(q,m[3]))?[q]:[]}J{L(H i=0;d[i];i++){H a=m[1]=="#"&&m[3]?m[3]:m[1]!=""||m[0]==""?"*":m[2];9(a=="*"&&d[i].11.2p()=="5i")a="3a";r=E.1R(r,d[i].4l(a))}9(m[1]==".")r=E.4X(r,m[2]);9(m[1]=="#"){H e=[];L(H i=0;r[i];i++)9(r[i].4p("22")==m[2]){e=[r[i]];1T}r=e}d=r}t=t.1p(k,"")}}9(t){H b=E.1E(t,r);d=r=b.r;t=E.36(b.t)}}9(t)d=[];9(d&&o==d[0])d.44();2f=E.1R(2f,d);I 2f},4X:G(r,m,a){m=" "+m+" ";H c=[];L(H i=0;r[i];i++){H b=(" "+r[i].1o+" ").1g(m)>=0;9(!a&&b||a&&!b)c.1a(r[i])}I c},1E:G(t,r,h){H d;1W(t&&t!=d){d=t;H p=E.6a,m;L(H i=0;p[i];i++){m=p[i].2S(t);9(m){t=t.7O(m[0].K);m[2]=m[2].1p(/\\\\/g,"");1T}}9(!m)1T;9(m[1]==":"&&m[2]=="5V")r=E.1E(m[3],r,Q).r;J 9(m[1]==".")r=E.4X(r,m[2],h);J 9(m[1]=="["){H g=[],O=m[3];L(H i=0,31=r.K;i<31;i++){H a=r[i],z=a[E.5o[m[2]]||m[2]];9(z==S||/6C|3k|26/.14(m[2]))z=E.1x(a,m[2])||\'\';9((O==""&&!!z||O=="="&&z==m[5]||O=="!="&&z!=m[5]||O=="^="&&z&&!z.1g(m[5])||O=="$="&&z.68(z.K-m[5].K)==m[5]||(O=="*="||O=="~=")&&z.1g(m[5])>=0)^h)g.1a(a)}r=g}J 9(m[1]==":"&&m[2]=="2I-46"){H e={},g=[],14=/(\\d*)n\\+?(\\d*)/.2S(m[3]=="6f"&&"2n"||m[3]=="6e"&&"2n+1"||!/\\D/.14(m[3])&&"n+"+m[3]||m[3]),3v=(14[1]||1)-0,d=14[2]-0;L(H i=0,31=r.K;i<31;i++){H j=r[i],12=j.12,22=E.M(12);9(!e[22]){H c=1;L(H n=12.1w;n;n=n.2q)9(n.1y==1)n.4U=c++;e[22]=Q}H b=P;9(3v==1){9(d==0||j.4U==d)b=Q}J 9((j.4U+d)%3v==0)b=Q;9(b^h)g.1a(j)}r=g}J{H f=E.55[m[1]];9(1m f!="1M")f=E.55[m[1]][m[2]];f=3w("P||G(a,i){I "+f+"}");r=E.2W(r,f,h)}}I{r:r,t:t}},4e:G(b,c){H d=[];H a=b[c];1W(a&&a!=U){9(a.1y==1)d.1a(a);a=a[c]}I d},2I:G(a,e,c,b){e=e||1;H d=0;L(;a;a=a[c])9(a.1y==1&&++d==e)1T;I a},5d:G(n,a){H r=[];L(;n;n=n.2q){9(n.1y==1&&(!a||n!=a))r.1a(n)}I r}});E.1j={1f:G(g,e,c,h){9(E.V.1h&&g.4j!=W)g=18;9(!c.2u)c.2u=6.2u++;9(h!=W){H d=c;c=G(){I d.16(6,1q)};c.M=h;c.2u=d.2u}H i=e.2l(".");e=i[0];c.O=i[1];H b=E.M(g,"2P")||E.M(g,"2P",{});H f=E.M(g,"2t",G(){H a;9(1m E=="W"||E.1j.4T)I a;a=E.1j.2t.16(g,1q);I a});H j=b[e];9(!j){j=b[e]={};9(g.4S)g.4S(e,f,P);J g.7N("43"+e,f)}j[c.2u]=c;6.1Z[e]=Q},2u:1,1Z:{},28:G(d,c,b){H e=E.M(d,"2P"),2L,4I;9(1m c=="1M"){H a=c.2l(".");c=a[0]}9(e){9(c&&c.O){b=c.4Q;c=c.O}9(!c){L(c 1i e)6.28(d,c)}J 9(e[c]){9(b)2E e[c][b.2u];J L(b 1i e[c])9(!a[1]||e[c][b].O==a[1])2E e[c][b];L(2L 1i e[c])1T;9(!2L){9(d.4P)d.4P(c,E.M(d,"2t"),P);J d.7M("43"+c,E.M(d,"2t"));2L=S;2E e[c]}}L(2L 1i e)1T;9(!2L){E.30(d,"2P");E.30(d,"2t")}}},1F:G(d,b,e,c,f){b=E.2h(b||[]);9(!e){9(6.1Z[d])E("*").1f([18,U]).1F(d,b)}J{H a,2L,1b=E.1n(e[d]||S),4N=!b[0]||!b[0].2M;9(4N)b.4w(6.4M({O:d,2m:e}));b[0].O=d;9(E.1n(E.M(e,"2t")))a=E.M(e,"2t").16(e,b);9(!1b&&e["43"+d]&&e["43"+d].16(e,b)===P)a=P;9(4N)b.44();9(f&&f.16(e,b)===P)a=P;9(1b&&c!==P&&a!==P&&!(E.11(e,\'a\')&&d=="4L")){6.4T=Q;e[d]()}6.4T=P}I a},2t:G(d){H a;d=E.1j.4M(d||18.1j||{});H b=d.O.2l(".");d.O=b[0];H c=E.M(6,"2P")&&E.M(6,"2P")[d.O],3q=1B.3A.2J.2O(1q,1);3q.4w(d);L(H j 1i c){3q[0].4Q=c[j];3q[0].M=c[j].M;9(!b[1]||c[j].O==b[1]){H e=c[j].16(6,3q);9(a!==P)a=e;9(e===P){d.2M();d.3p()}}}9(E.V.1h)d.2m=d.2M=d.3p=d.4Q=d.M=S;I a},4M:G(c){H a=c;c=E.1k({},a);c.2M=G(){9(a.2M)a.2M();a.7L=P};c.3p=G(){9(a.3p)a.3p();a.7K=Q};9(!c.2m&&c.65)c.2m=c.65;9(E.V.1N&&c.2m.1y==3)c.2m=a.2m.12;9(!c.4K&&c.4J)c.4K=c.4J==c.2m?c.7H:c.4J;9(c.64==S&&c.63!=S){H e=U.2V,b=U.1G;c.64=c.63+(e&&e.2R||b.2R||0);c.7E=c.7D+(e&&e.2B||b.2B||0)}9(!c.3Y&&(c.61||c.60))c.3Y=c.61||c.60;9(!c.5F&&c.5D)c.5F=c.5D;9(!c.3Y&&c.2r)c.3Y=(c.2r&1?1:(c.2r&2?3:(c.2r&4?2:0)));I c}};E.1b.1k({3W:G(c,a,b){I c=="5Y"?6.2G(c,a,b):6.N(G(){E.1j.1f(6,c,b||a,b&&a)})},2G:G(d,b,c){I 6.N(G(){E.1j.1f(6,d,G(a){E(6).5X(a);I(c||b).16(6,1q)},c&&b)})},5X:G(a,b){I 6.N(G(){E.1j.28(6,a,b)})},1F:G(c,a,b){I 6.N(G(){E.1j.1F(c,a,6,Q,b)})},7x:G(c,a,b){9(6[0])I E.1j.1F(c,a,6[0],P,b)},25:G(){H a=1q;I 6.4L(G(e){6.4H=0==6.4H?1:0;e.2M();I a[6.4H].16(6,[e])||P})},7v:G(f,g){G 4G(e){H p=e.4K;1W(p&&p!=6)2a{p=p.12}29(e){p=6};9(p==6)I P;I(e.O=="4x"?f:g).16(6,[e])}I 6.4x(4G).5U(4G)},2d:G(f){5T();9(E.3T)f.16(U,[E]);J E.3l.1a(G(){I f.16(6,[E])});I 6}});E.1k({3T:P,3l:[],2d:G(){9(!E.3T){E.3T=Q;9(E.3l){E.N(E.3l,G(){6.16(U)});E.3l=S}9(E.V.35||E.V.34)U.4P("5S",E.2d,P);9(!18.7t.K)E(18).39(G(){E("#4E").28()})}}});E.N(("7s,7r,39,7q,6n,5Y,4L,7p,"+"7n,7m,7l,4x,5U,7k,24,"+"51,7j,7i,7h,3U").2l(","),G(i,o){E.1b[o]=G(f){I f?6.3W(o,f):6.1F(o)}});H x=P;G 5T(){9(x)I;x=Q;9(E.V.35||E.V.34)U.4S("5S",E.2d,P);J 9(E.V.1h){U.7f("<7d"+"7y 22=4E 7z=Q "+"3k=//:><\\/1J>");H a=U.3S("4E");9(a)a.62=G(){9(6.2C!="1l")I;E.2d()};a=S}J 9(E.V.1N)E.4B=4j(G(){9(U.2C=="5Q"||U.2C=="1l"){4A(E.4B);E.4B=S;E.2d()}},10);E.1j.1f(18,"39",E.2d)}E.1b.1k({39:G(g,d,c){9(E.1n(g))I 6.3W("39",g);H e=g.1g(" ");9(e>=0){H i=g.2J(e,g.K);g=g.2J(0,e)}c=c||G(){};H f="4z";9(d)9(E.1n(d)){c=d;d=S}J{d=E.3a(d);f="5P"}H h=6;E.3G({1d:g,O:f,M:d,1l:G(a,b){9(b=="1C"||b=="5O")h.4o(i?E("<1s/>").3g(a.40.1p(/<1J(.|\\s)*?\\/1J>/g,"")).1Y(i):a.40);56(G(){h.N(c,[a.40,b,a])},13)}});I 6},7a:G(){I E.3a(6.5M())},5M:G(){I 6.1X(G(){I E.11(6,"2Y")?E.2h(6.79):6}).1E(G(){I 6.2H&&!6.3c&&(6.2Q||/24|6b/i.14(6.11)||/2g|1P|52/i.14(6.O))}).1X(G(i,c){H b=E(6).3i();I b==S?S:b.1c==1B?E.1X(b,G(a,i){I{2H:c.2H,1Q:a}}):{2H:c.2H,1Q:b}}).21()}});E.N("5L,5K,6t,5J,5I,5H".2l(","),G(i,o){E.1b[o]=G(f){I 6.3W(o,f)}});H B=(1u 3D).3B();E.1k({21:G(d,b,a,c){9(E.1n(b)){a=b;b=S}I E.3G({O:"4z",1d:d,M:b,1C:a,1V:c})},78:G(b,a){I E.21(b,S,a,"1J")},77:G(c,b,a){I E.21(c,b,a,"45")},76:G(d,b,a,c){9(E.1n(b)){a=b;b={}}I E.3G({O:"5P",1d:d,M:b,1C:a,1V:c})},75:G(a){E.1k(E.59,a)},59:{1Z:Q,O:"4z",2z:0,5G:"74/x-73-2Y-72",6o:Q,3e:Q,M:S},49:{},3G:G(s){H f,2y=/=(\\?|%3F)/g,1v,M;s=E.1k(Q,s,E.1k(Q,{},E.59,s));9(s.M&&s.6o&&1m s.M!="1M")s.M=E.3a(s.M);9(s.1V=="4b"){9(s.O.2p()=="21"){9(!s.1d.1t(2y))s.1d+=(s.1d.1t(/\\?/)?"&":"?")+(s.4b||"5E")+"=?"}J 9(!s.M||!s.M.1t(2y))s.M=(s.M?s.M+"&":"")+(s.4b||"5E")+"=?";s.1V="45"}9(s.1V=="45"&&(s.M&&s.M.1t(2y)||s.1d.1t(2y))){f="4b"+B++;9(s.M)s.M=s.M.1p(2y,"="+f);s.1d=s.1d.1p(2y,"="+f);s.1V="1J";18[f]=G(a){M=a;1C();1l();18[f]=W;2a{2E 18[f]}29(e){}}}9(s.1V=="1J"&&s.1L==S)s.1L=P;9(s.1L===P&&s.O.2p()=="21")s.1d+=(s.1d.1t(/\\?/)?"&":"?")+"57="+(1u 3D()).3B();9(s.M&&s.O.2p()=="21"){s.1d+=(s.1d.1t(/\\?/)?"&":"?")+s.M;s.M=S}9(s.1Z&&!E.5b++)E.1j.1F("5L");9(!s.1d.1g("8g")&&s.1V=="1J"){H h=U.4l("9U")[0];H g=U.5B("1J");g.3k=s.1d;9(!f&&(s.1C||s.1l)){H j=P;g.9R=g.62=G(){9(!j&&(!6.2C||6.2C=="5Q"||6.2C=="1l")){j=Q;1C();1l();h.3b(g)}}}h.58(g);I}H k=P;H i=18.6X?1u 6X("9P.9O"):1u 6W();i.9M(s.O,s.1d,s.3e);9(s.M)i.5C("9J-9I",s.5G);9(s.5y)i.5C("9H-5x-9F",E.49[s.1d]||"9D, 9C 9B 9A 5v:5v:5v 9z");i.5C("X-9x-9v","6W");9(s.6U)s.6U(i);9(s.1Z)E.1j.1F("5H",[i,s]);H c=G(a){9(!k&&i&&(i.2C==4||a=="2z")){k=Q;9(d){4A(d);d=S}1v=a=="2z"&&"2z"||!E.6S(i)&&"3U"||s.5y&&E.6R(i,s.1d)&&"5O"||"1C";9(1v=="1C"){2a{M=E.6Q(i,s.1V)}29(e){1v="5k"}}9(1v=="1C"){H b;2a{b=i.5s("6P-5x")}29(e){}9(s.5y&&b)E.49[s.1d]=b;9(!f)1C()}J E.5r(s,i,1v);1l();9(s.3e)i=S}};9(s.3e){H d=4j(c,13);9(s.2z>0)56(G(){9(i){i.9q();9(!k)c("2z")}},s.2z)}2a{i.9o(s.M)}29(e){E.5r(s,i,S,e)}9(!s.3e)c();I i;G 1C(){9(s.1C)s.1C(M,1v);9(s.1Z)E.1j.1F("5I",[i,s])}G 1l(){9(s.1l)s.1l(i,1v);9(s.1Z)E.1j.1F("6t",[i,s]);9(s.1Z&&!--E.5b)E.1j.1F("5K")}},5r:G(s,a,b,e){9(s.3U)s.3U(a,b,e);9(s.1Z)E.1j.1F("5J",[a,s,e])},5b:0,6S:G(r){2a{I!r.1v&&9n.9l=="54:"||(r.1v>=6N&&r.1v<9j)||r.1v==6M||E.V.1N&&r.1v==W}29(e){}I P},6R:G(a,c){2a{H b=a.5s("6P-5x");I a.1v==6M||b==E.49[c]||E.V.1N&&a.1v==W}29(e){}I P},6Q:G(r,b){H c=r.5s("9i-O");H d=b=="6K"||!b&&c&&c.1g("6K")>=0;H a=d?r.9g:r.40;9(d&&a.2V.37=="5k")6G"5k";9(b=="1J")E.5f(a);9(b=="45")a=3w("("+a+")");I a},3a:G(a){H s=[];9(a.1c==1B||a.4c)E.N(a,G(){s.1a(3f(6.2H)+"="+3f(6.1Q))});J L(H j 1i a)9(a[j]&&a[j].1c==1B)E.N(a[j],G(){s.1a(3f(j)+"="+3f(6))});J s.1a(3f(j)+"="+3f(a[j]));I s.66("&").1p(/%20/g,"+")}});E.1b.1k({1A:G(b,a){I b?6.1U({1H:"1A",2N:"1A",1r:"1A"},b,a):6.1E(":1P").N(G(){6.R.19=6.3h?6.3h:"";9(E.17(6,"19")=="2s")6.R.19="2Z"}).2D()},1z:G(b,a){I b?6.1U({1H:"1z",2N:"1z",1r:"1z"},b,a):6.1E(":3R").N(G(){6.3h=6.3h||E.17(6,"19");9(6.3h=="2s")6.3h="2Z";6.R.19="2s"}).2D()},6J:E.1b.25,25:G(a,b){I E.1n(a)&&E.1n(b)?6.6J(a,b):a?6.1U({1H:"25",2N:"25",1r:"25"},a,b):6.N(G(){E(6)[E(6).3t(":1P")?"1A":"1z"]()})},9c:G(b,a){I 6.1U({1H:"1A"},b,a)},9b:G(b,a){I 6.1U({1H:"1z"},b,a)},99:G(b,a){I 6.1U({1H:"25"},b,a)},98:G(b,a){I 6.1U({1r:"1A"},b,a)},96:G(b,a){I 6.1U({1r:"1z"},b,a)},95:G(c,a,b){I 6.1U({1r:a},c,b)},1U:G(k,i,h,g){H j=E.6D(i,h,g);I 6[j.3L===P?"N":"3L"](G(){j=E.1k({},j);H f=E(6).3t(":1P"),3y=6;L(H p 1i k){9(k[p]=="1z"&&f||k[p]=="1A"&&!f)I E.1n(j.1l)&&j.1l.16(6);9(p=="1H"||p=="2N"){j.19=E.17(6,"19");j.2U=6.R.2U}}9(j.2U!=S)6.R.2U="1P";j.3M=E.1k({},k);E.N(k,G(c,a){H e=1u E.2j(3y,j,c);9(/25|1A|1z/.14(a))e[a=="25"?f?"1A":"1z":a](k);J{H b=a.3s().1t(/^([+-]=)?([\\d+-.]+)(.*)$/),1O=e.2b(Q)||0;9(b){H d=3I(b[2]),2i=b[3]||"2T";9(2i!="2T"){3y.R[c]=(d||1)+2i;1O=((d||1)/e.2b(Q))*1O;3y.R[c]=1O+2i}9(b[1])d=((b[1]=="-="?-1:1)*d)+1O;e.3N(1O,d,2i)}J e.3N(1O,a,"")}});I Q})},3L:G(a,b){9(E.1n(a)){b=a;a="2j"}9(!a||(1m a=="1M"&&!b))I A(6[0],a);I 6.N(G(){9(b.1c==1B)A(6,a,b);J{A(6,a).1a(b);9(A(6,a).K==1)b.16(6)}})},9f:G(){H a=E.32;I 6.N(G(){L(H i=0;i-8O?r:3I(E.17(6.T,6.1e))||0},3N:G(c,b,e){6.5u=(1u 3D()).3B();6.1O=c;6.2D=b;6.2i=e||6.2i||"2T";6.2v=6.1O;6.4q=6.4i=0;6.4r();H f=6;G t(){I f.2F()}t.T=6.T;E.32.1a(t);9(E.32.K==1){H d=4j(G(){H a=E.32;L(H i=0;i6.Y.2e+6.5u){6.2v=6.2D;6.4q=6.4i=1;6.4r();6.Y.3M[6.1e]=Q;H a=Q;L(H i 1i 6.Y.3M)9(6.Y.3M[i]!==Q)a=P;9(a){9(6.Y.19!=S){6.T.R.2U=6.Y.2U;6.T.R.19=6.Y.19;9(E.17(6.T,"19")=="2s")6.T.R.19="2Z"}9(6.Y.1z)6.T.R.19="2s";9(6.Y.1z||6.Y.1A)L(H p 1i 6.Y.3M)E.1x(6.T.R,p,6.Y.3P[p])}9(a&&E.1n(6.Y.1l))6.Y.1l.16(6.T);I P}J{H n=t-6.5u;6.4i=n/6.Y.2e;6.4q=E.3J[6.Y.3J||(E.3J.5q?"5q":"6B")](6.4i,n,0,1,6.Y.2e);6.2v=6.1O+((6.2D-6.1O)*6.4q);6.4r()}I Q}};E.2j.2F={2R:G(a){a.T.2R=a.2v},2B:G(a){a.T.2B=a.2v},1r:G(a){E.1x(a.T.R,"1r",a.2v)},6z:G(a){a.T.R[a.1e]=a.2v+a.2i}};E.1b.6m=G(){H c=0,3E=0,T=6[0],5t;9(T)8L(E.V){H b=E.17(T,"2X")=="4F",1D=T.12,23=T.23,2K=T.3H,4f=1N&&3x(4s)<8J;9(T.6V){5w=T.6V();1f(5w.1S+38.33(2K.2V.2R,2K.1G.2R),5w.3E+38.33(2K.2V.2B,2K.1G.2B));9(1h){H d=E("4o").17("8H");d=(d=="8G"||E.5g&&3x(4s)>=7)&&2||d;1f(-d,-d)}}J{1f(T.5l,T.5z);1W(23){1f(23.5l,23.5z);9(35&&/^t[d|h]$/i.14(1D.37)||!4f)d(23);9(4f&&!b&&E.17(23,"2X")=="4F")b=Q;23=23.23}1W(1D.37&&!/^1G|4o$/i.14(1D.37)){9(!/^8D|1I-9S.*$/i.14(E.17(1D,"19")))1f(-1D.2R,-1D.2B);9(35&&E.17(1D,"2U")!="3R")d(1D);1D=1D.12}9(4f&&b)1f(-2K.1G.5l,-2K.1G.5z)}5t={3E:3E,1S:c}}I 5t;G d(a){1f(E.17(a,"9T"),E.17(a,"8A"))}G 1f(l,t){c+=3x(l)||0;3E+=3x(t)||0}}})();',62,616,'||||||this|||if|||||||||||||||||||||||||||||||||function|var|return|else|length|for|data|each|type|false|true|style|null|elem|document|browser|undefined||options|||nodeName|parentNode||test|jQuery|apply|css|window|display|push|fn|constructor|url|prop|add|indexOf|msie|in|event|extend|complete|typeof|isFunction|className|replace|arguments|opacity|div|match|new|status|firstChild|attr|nodeType|hide|show|Array|success|parent|filter|trigger|body|height|table|script|tbody|cache|string|safari|start|hidden|value|merge|left|break|animate|dataType|while|map|find|global||get|id|offsetParent|select|toggle|selected|toUpperCase|remove|catch|try|cur|al|ready|duration|done|text|makeArray|unit|fx|swap|split|target||pushStack|toLowerCase|nextSibling|button|none|handle|guid|now|stack|tb|jsre|timeout|inArray|scrollTop|readyState|end|delete|step|one|name|nth|slice|doc|ret|preventDefault|width|call|events|checked|scrollLeft|exec|px|overflow|documentElement|grep|position|form|block|removeData|rl|timers|max|opera|mozilla|trim|tagName|Math|load|param|removeChild|disabled|insertBefore|async|encodeURIComponent|append|oldblock|val|childNodes|src|readyList|multiFilter|color|defaultView|stopPropagation|args|old|toString|is|last|first|eval|parseInt|self|domManip|prototype|getTime|curCSS|Date|top||ajax|ownerDocument|parseFloat|easing|has|queue|curAnim|custom|innerHTML|orig|currentStyle|visible|getElementById|isReady|error|static|bind|String|which|getComputedStyle|responseText|oWidth|oHeight|on|shift|json|child|RegExp|ol|lastModified|isXMLDoc|jsonp|jquery|previousSibling|dir|safari2|el|styleFloat|state|setInterval|radio|getElementsByTagName|tr|empty|html|getAttribute|pos|update|version|input|float|runtimeStyle|unshift|mouseover|getPropertyValue|GET|clearInterval|safariTimer|visibility|clean|__ie_init|absolute|handleHover|lastToggle|index|fromElement|relatedTarget|click|fix|evt|andSelf|removeEventListener|handler|cloneNode|addEventListener|triggered|nodeIndex|unique|Number|classFilter|prevObject|selectedIndex|after|submit|password|removeAttribute|file|expr|setTimeout|_|appendChild|ajaxSettings|client|active|win|sibling|deep|globalEval|boxModel|cssFloat|object|checkbox|parsererror|offsetLeft|wrapAll|dequeue|props|lastChild|swing|handleError|getResponseHeader|results|startTime|00|box|Modified|ifModified|offsetTop|evalScript|createElement|setRequestHeader|ctrlKey|callback|metaKey|contentType|ajaxSend|ajaxSuccess|ajaxError|ajaxStop|ajaxStart|serializeArray|init|notmodified|POST|loaded|appendTo|DOMContentLoaded|bindReady|mouseout|not|removeAttr|unbind|unload|Width|keyCode|charCode|onreadystatechange|clientX|pageX|srcElement|join|outerHTML|substr|zoom|parse|textarea|reset|image|odd|even|before|quickClass|quickID|prepend|quickChild|execScript|offset|scroll|processData|uuid|contents|continue|textContent|ajaxComplete|clone|setArray|webkit|nodeValue|fl|_default|100|linear|href|speed|eq|createTextNode|throw|replaceWith|splice|_toggle|xml|colgroup|304|200|alpha|Last|httpData|httpNotModified|httpSuccess|fieldset|beforeSend|getBoundingClientRect|XMLHttpRequest|ActiveXObject|col|br|abbr|pixelLeft|urlencoded|www|application|ajaxSetup|post|getJSON|getScript|elements|serialize|clientWidth|hasClass|scr|clientHeight|write|relative|keyup|keypress|keydown|change|mousemove|mouseup|mousedown|right|dblclick|resize|focus|blur|frames|instanceof|hover|offsetWidth|triggerHandler|ipt|defer|offsetHeight|border|padding|clientY|pageY|Left|Right|toElement|Bottom|Top|cancelBubble|returnValue|detachEvent|attachEvent|substring|line|weight|animated|header|font|enabled|innerText|contains|only|size|gt|lt|uFFFF|u0128|417|inner|Height|toggleClass|removeClass|addClass|replaceAll|noConflict|insertAfter|prependTo|wrap|contentWindow|contentDocument|http|iframe|children|siblings|prevAll|nextAll|wrapInner|prev|Boolean|next|parents|maxLength|maxlength|readOnly|readonly|class|htmlFor|CSS1Compat|compatMode|compatible|borderTopWidth|ie|ra|inline|it|rv|medium|borderWidth|userAgent|522|navigator|with|concat|1px|10000|array|ig|PI|NaN|400|reverse|fast|600|slow|Function|Object|setAttribute|changed|be|can|property|fadeTo|fadeOut|getAttributeNode|fadeIn|slideToggle|method|slideUp|slideDown|action|cssText|stop|responseXML|option|content|300|th|protocol|td|location|send|cap|abort|colg|cos|tfoot|thead|With|leg|Requested|opt|GMT|1970|Jan|01|Thu|area|Since|hr|If|Type|Content|meta|specified|open|link|XMLHTTP|Microsoft|img|onload|row|borderLeftWidth|head|attributes'.split('|'),0,{})) ================================================ FILE: tests/scripts/specifications.js ================================================ Cruiser.Specification = {}; Cruiser.Specification.About = { Description : 'Javascript library for Behavior Driven Design (BDD)', Author : 'Dan Yoder', Version : { major: '0', minor: '5' }, Notices : { Copyright: '(c) 2007 Dan Yoder' }, License : 'Specification is freely distributable under the terms of the MIT license.', URL : 'http://dev.zeraweb.com/specifications/' }; Specification = function(spec) { this.spec = new Hash( spec ); } Specification.prototype = { validate: function() { var result = this.spec.inject( new Specification.Result(), Specification.Context.validate ); return result; }, run: function() { this.validate().show(); } } Specification.Context = { validate: function(r,c) { var name = c[0], spec = new Hash(c[1]); spec.results = new Hash(); r.data[name] = spec.inject( spec, Specification.Test.run ).results; return r; } } Specification.Test = { run: function(r,c) { var name = c[0], test = c[1], time = 0, start = null; switch(name) { case 'results': case 'setup': case 'teardown': return r; } var object = {}; try { if (r.setup) { r.setup.call(object); } if (test.run) { start = new Date(); test.run.call(object); time = (new Date()) - start; } if (test.assert) { r.results[name] = test.assert.call(object, Specification.Assert ); } if (r.teardown) { r.teardown.call(object); } } catch(e) { time = (new Date()) - start ; r.results[name] = false; } return r; } } Specification.Assert = { isTrue: function() { return Array.convert( arguments ).inject( true, function(r,a) { return ( ( r && a ) ? true : false ) }); } } Specification.Result = function() { this.data = new Hash() }; Specification.Result.setOutput = function(e) { Specification.Result.output = e }; Specification.Result.prototype = { show: function() { var r = Specification.Result; if ( !r.output ) { r.output = $('div.results'); } var addContext = function(ctx) { return '

' + ctx[0] + '

' + '' + ctx[1].map( addTest ).join('\n') + '
'; } var addTest = function(test) { var status = test[1] ? "pass" : "fail"; return '' + test[0] + ' '; // with new testItem object // Sample testItem object // test = { id: 34, name: "Random Curve ball", value: "7-8, '04", result: true, time: 5 }; // return '' + test.id + '' + test.value + '' + test.name + '' + test.time + ''; } r.output.append( this.data.map( addContext ).join('\n') ); } } ================================================ FILE: tests/scripts/specifications_original.js ================================================ Cruiser.Specification = {} Cruiser.Specification.About = { Description : 'Javascript library for Behavior Driven Design (BDD)', Author : 'Dan Yoder', Version : { major: '0', minor: '5' }, Notices : { Copyright: '(c) 2007 Dan Yoder' }, License : 'Specification is freely distributable under the terms of the MIT license.', URL : 'http://dev.zeraweb.com/specifications/' } Specification = function(spec) { this.spec = new Hash( spec ); } Specification.log = function(msg,tag) { $('div.log').append("<"+(tag||'p')+" class='message'>"+msg+""); } Specification.prototype = { validate: function() { Specification.log('Processing ...'); var start = new Date(); var result = this.spec.inject( new Specification.Result(), Specification.Context.validate ); var end = new Date(); Specification.log('Processing Time','h1'); Specification.log('Finished processing in ' + (end-start) + ' ms.'); return result; }, run: function() { this.validate().show() } } Specification.Context = { validate: function(r,c) { var name = c[0], spec = new Hash(c[1]); spec.results = new Hash(); Specification.log(name,'h2'); r.data[name] = spec.inject( spec, Specification.Test.run ).results; return r; } } Specification.Test = { run: function(r,c) { var name = c[0], test = c[1], time = 0, start = null; switch(name) { case 'results': case 'setup': case 'teardown': return r; } Specification.log(name,'p'); var object = {}; try { if (r.setup) { r.setup.call(object); } if (test.run) { start = new Date(); test.run.call(object); time = (new Date()) - start } if (test.assert) { r.results[name] = test.assert.call(object, Specification.Assert ) } if (r.teardown) { r.teardown.call(object) } } catch(e) { time = (new Date()) - start ; Specification.log(e); r.results[name] = false } Specification.log('Ran in '+time+' ms.','p'); return r; } } Specification.Assert = { isTrue: function() { return Array.convert( arguments ).inject( true, function(r,a) { return ( ( r && a ) ? true : false ) }); } } Specification.Result = function() { this.data = new Hash() }; Specification.Result.setOutput = function(e) { Specification.Result.output = e }; Specification.Result.prototype = { show: function() { Specification.log("Displaying results ...",'p'); var r = Specification.Result, start = new Date(); if ( ! r.output ) { r.output = $('div.results') } var addContext = function(ctx) { return "

"+ctx[0]+"

"+ "
"+ctx[1].map( addTest ).join('\n')+"
"; } var addTest = function(test) { var status = test[1]?'pass':'fail'; return "
" + "
"+test[0]+"
"+ "
"+status+"
"; } r.output.append( this.data.map( addContext ).join('\n') ); var end = new Date(); Specification.log("Results displayed in " + (end-start) + " ms.",'p'); } } ================================================ FILE: tests/styles/chart.css ================================================ #chart { padding: 10px; } #chart div.item { height: 18px; padding: 4px; } #chart div.item label { display: block; float: left; clear: both; width: 200px; text-align: right; } #chart div.item div.bar { float: left; height: 18px; background-color: #72C868; margin: 0 15px; } #chart div.item div.display { float: left; } ================================================ FILE: tests/styles/specifications.css ================================================ body { padding: 5px 20px; font-family: Verdana, Helvetica, Arial, Sans-serif; color: #333; font-size: 10pt; } body, li, a, label, div, table, th, td { font-size: 10pt; font-family: Verdana, Helvetica, Arial, Sans-serif; } li { margin-bottom: 4px; } .information { border: 1px solid #729ECD; padding: 4px; padding-left: 30px; background: #E6EEF7 url(../images/information.png) no-repeat 6px 12px; margin: 12px 0; } h1 { font-size: 18pt; } h2 { padding-top: 8px; font-size: 14pt; clear: both; } table.test { width: 800px; } table.test th { width: 700px; font-weight: normal; text-align: left; padding: 4px; padding-left: 30px; } table.test td { padding: 4px; } tr.pass th { border: 1px solid #72C868; background: #E9FFDD url(../images/accept.png) no-repeat 6px 4px ; } tr.pass td { border: 1px solid #72C868; background-color: #E9FFDD; } tr.fail th { border: 1px solid #F58263; background: #FEEBE7 url(../images/exclamation.png) no-repeat 6px 4px ; } tr.fail td { border: 1px solid #F58263; background-color: #FEEBE7; } ================================================ FILE: tests/sugarpak/index.html ================================================ Datejs Test Cases : Sugarpak Library

Sugarpak

================================================ FILE: tests/sugarpak/index.js ================================================ Date.Specification = new Specification({ 'Need more sugarpak.js tests?': { setup: function() {}, 'true': { run: function() { }, assert: function() { return true; } } }, '.same()': { setup: function() {}, 'same year(Date.today())': { run: function() { }, assert: function() { return Date.today().same().year(); } }, 'same month(Date.today())': { run: function() { }, assert: function() { return Date.today().same().month(); } }, 'same week(Date.today())': { run: function() { }, assert: function() { return Date.today().same().week(); } }, 'same day(Date.today())': { run: function() { }, assert: function() { return Date.today().same().day(); } }, 'same hour(Date.today())': { run: function() { }, assert: function() { return !Date.today().same().hour(); } }, 'same minute(Date.today())': { run: function() { }, assert: function() { return !Date.today().same().minute(); } }, 'same second(Date.today())': { run: function() { }, assert: function() { return !Date.today().same().second(); } }, 'same millisecond(Date.today())': { run: function() { }, assert: function() { return !Date.today().same().millisecond(); } }, 'same year(new Date())': { run: function() { }, assert: function() { return new Date().same().year(); } }, 'same month(new Date())': { run: function() { }, assert: function() { return new Date().same().month(); } }, 'same week(new Date())': { run: function() { }, assert: function() { return new Date().same().week(); } }, 'same day(new Date())': { run: function() { }, assert: function() { return new Date().same().day(); } }, 'same hour(new Date())': { run: function() { }, assert: function() { return new Date().same().hour(); } }, 'same minute(new Date())': { run: function() { }, assert: function() { return new Date().same().minute(); } }, 'same second(new Date())': { run: function() { }, assert: function() { return new Date().same().second(); } }, 'same millisecond(new Date())': { run: function() { }, assert: function() { return new Date().same().millisecond(); } }, 'same year2(Date.today())': { run: function() { }, assert: function() { return Date.today().same().year(Date.today()); } }, 'same month2(Date.today())': { run: function() { }, assert: function() { return Date.today().same().month(Date.today()); } }, 'same week2(Date.today())': { run: function() { }, assert: function() { return Date.today().same().week(Date.today()); } }, 'same day2(Date.today())': { run: function() { }, assert: function() { return Date.today().same().day(Date.today()); } }, 'same hour2(Date.today())': { run: function() { }, assert: function() { return Date.today().same().hour(Date.today()); } }, 'same minute2(Date.today())': { run: function() { }, assert: function() { return Date.today().same().minute(Date.today()); } }, 'same second2(Date.today())': { run: function() { }, assert: function() { return Date.today().same().second(Date.today()); } }, 'same millisecond2(Date.today())': { run: function() { }, assert: function() { return Date.today().same().millisecond(Date.today()); } }, 'same year2(new Date())': { run: function() { }, assert: function() { return Date.today().same().year(new Date()); } }, 'same month2(new Date())': { run: function() { }, assert: function() { return Date.today().same().month(new Date()); } }, 'same week2(new Date())': { run: function() { }, assert: function() { return Date.today().same().week(new Date()); } }, 'same day2(new Date())': { run: function() { }, assert: function() { return Date.today().same().day(new Date()); } }, 'same hour2(new Date())': { run: function() { }, assert: function() { return !Date.today().same().hour(new Date()); } }, 'same minute2(new Date())': { run: function() { }, assert: function() { return !Date.today().same().minute(new Date()); } }, 'same second2(new Date())': { run: function() { }, assert: function() { return !Date.today().same().second(new Date()); } }, 'same millisecond2(new Date())': { run: function() { }, assert: function() { return !Date.today().same().millisecond(new Date()); } } } }); $(document).ready( function() { Date.Specification.validate().show() } ); ================================================ FILE: tests/time/index.html ================================================ Datejs Test Cases : Times

Times

================================================ FILE: tests/time/index.js ================================================ Date.Specification = new Specification({ 'Times': { setup: function() { this.baseline = []; this.baseline[0] = Date.today().set( { hour: 6 } ); this.baseline[1] = Date.today().set( { hour: 6, minute: 45 } ); this.baseline[2] = Date.today().set( { hour: 22 } ); this.baseline[3] = Date.today().set( { hour: 22, minute: 30 } ); }, '12 am': { run: function() { }, assert: function() { return Date.today().equals(Date.parse("12 am")) } }, '12 AM': { run: function() { }, assert: function() { return Date.today().equals(Date.parse("12 am")) } }, '12 A': { run: function() { }, assert: function() { return Date.today().equals(Date.parse("12 A")) } }, '12A': { run: function() { }, assert: function() { return Date.today().equals(Date.parse("12A")) } }, '12 pm': { run: function() { }, assert: function() { return Date.today().add(12).hours().equals(Date.parse("12 pm")) } }, '12 PM': { run: function() { }, assert: function() { return Date.today().add(12).hours().equals(Date.parse("12 PM")) } }, '12 P': { run: function() { }, assert: function() { return Date.today().add(12).hours().equals(Date.parse("12 P")) } }, '12P': { run: function() { }, assert: function() { return Date.today().add(12).hours().equals(Date.parse("12P")) } }, '22:30': { run: function() { this.date = Date.parse('22:30') }, assert: function() { return this.baseline[3].equals( this.date ) } }, '6:45': { run: function() { this.date = Date.parse('6:45') }, assert: function() { return this.baseline[1].equals( this.date ) } }, '06:45': { run: function() { this.date = Date.parse('06:45') }, assert: function() { return this.baseline[1].equals( this.date ) } }, '10 pm': { run: function() { this.date = Date.parse('10 pm') }, assert: function() { return this.baseline[2].equals( this.date ) } }, '10pm': { run: function() { this.date = Date.parse('10pm') }, assert: function() { return this.baseline[2].equals( this.date ) } }, '10 p.m.': { run: function() { this.date = Date.parse('10 p.m.') }, assert: function() { return this.baseline[2].equals( this.date ) } }, '10 PM': { run: function() { this.date = Date.parse('10 PM') }, assert: function() { return this.baseline[2].equals( this.date ) } }, '10PM': { run: function() { this.date = Date.parse('10PM') }, assert: function() { return this.baseline[2].equals( this.date ) } }, '10 P.M.': { run: function() { this.date = Date.parse('10 P.M.') }, assert: function() { return this.baseline[2].equals( this.date ) } }, '6 am': { run: function() { this.date = Date.parse('6 am') }, assert: function() { return this.baseline[0].equals( this.date ) } }, '6am': { run: function() { this.date = Date.parse('6am') }, assert: function() { return this.baseline[0].equals( this.date ) } }, '06 am': { run: function() { this.date = Date.parse('06 am') }, assert: function() { return this.baseline[0].equals( this.date ) } }, '06am': { run: function() { this.date = Date.parse('06am') }, assert: function() { return this.baseline[0].equals( this.date ) } }, '6 AM': { run: function() { this.date = Date.parse('6 AM') }, assert: function() { return this.baseline[0].equals( this.date ) } }, '6AM': { run: function() { this.date = Date.parse('6AM') }, assert: function() { return this.baseline[0].equals( this.date ) } }, '6 A.M.': { run: function() { this.date = Date.parse('6 A.M.') }, assert: function() { return this.baseline[0].equals( this.date ) } }, '06 AM': { run: function() { this.date = Date.parse('06 AM') }, assert: function() { return this.baseline[0].equals( this.date ) } }, '06AM': { run: function() { this.date = Date.parse('06AM') }, assert: function() { return this.baseline[0].equals( this.date ) } }, '06 A.M.': { run: function() { this.date = Date.parse('06 A.M.') }, assert: function() { return this.baseline[0].equals( this.date ) } }, '10:30P': { run: function() { this.date = Date.parse('10:30P') }, assert: function() { return this.baseline[3].equals( this.date ) } }, '10:30 P': { run: function() { this.date = Date.parse('10:30 P') }, assert: function() { return this.baseline[3].equals( this.date ) } }, '10:30 PM': { run: function() { this.date = Date.parse('10:30 PM') }, assert: function() { return this.baseline[3].equals( this.date ) } }, '10:30PM': { run: function() { this.date = Date.parse('10:30PM') }, assert: function() { return this.baseline[3].equals( this.date ) } }, '10:30 P.M.': { run: function() { this.date = Date.parse('10:30 P.M.') }, assert: function() { return this.baseline[3].equals( this.date ) } }, '6:45A': { run: function() { this.date = Date.parse('6:45A') }, assert: function() { return this.baseline[1].equals( this.date ) } }, '6:45 A': { run: function() { this.date = Date.parse('6:45 A') }, assert: function() { return this.baseline[1].equals( this.date ) } }, '6:45 AM': { run: function() { this.date = Date.parse('6:45 AM') }, assert: function() { return this.baseline[1].equals( this.date ) } }, '6:45AM': { run: function() { this.date = Date.parse('6:45AM') }, assert: function() { return this.baseline[1].equals( this.date ) } }, '6:45 A.M.': { run: function() { this.date = Date.parse('6:45 A.M.') }, assert: function() { return this.baseline[1].equals( this.date ) } }, '22:30': { run: function() { this.date = Date.parse('22:30') }, assert: function() { return this.baseline[3].equals( this.date ) } }, '6:45': { run: function() { this.date = Date.parse('6:45') }, assert: function() { return this.baseline[1].equals( this.date ) } }, '06:45': { run: function() { this.date = Date.parse('06:45') }, assert: function() { return this.baseline[1].equals( this.date ) } }, '22:30:45': { run: function() { this.date = Date.parse('22:30:45') }, assert: function() { return this.baseline[3].addSeconds(45).equals( this.date ) } }, '06:45:25': { run: function() { this.date = Date.parse('06:45:25') }, assert: function() { return this.baseline[1].addSeconds(25).equals( this.date ) } }, '10:30:45 PM': { run: function() { this.date = Date.parse('10:30:45 PM') }, assert: function() { return this.baseline[3].addSeconds(45).equals( this.date ) } }, '10:30:45PM': { run: function() { this.date = Date.parse('10:30:45PM') }, assert: function() { return this.baseline[3].addSeconds(45).equals( this.date ) } }, '10:30:45 P': { run: function() { this.date = Date.parse('10:30:45 P') }, assert: function() { return this.baseline[3].addSeconds(45).equals( this.date ) } }, '10:30:45P': { run: function() { this.date = Date.parse('10:30:45P') }, assert: function() { return this.baseline[3].addSeconds(45).equals( this.date ) } }, '10:30:45 P.M.': { run: function() { this.date = Date.parse('10:30:45 P.M.') }, assert: function() { return this.baseline[3].addSeconds(45).equals( this.date ) } }, '6:45:25 AM': { run: function() { this.date = Date.parse('6:45:25 AM') }, assert: function() { return this.baseline[1].addSeconds(25).equals( this.date ) } }, '6:45:25AM': { run: function() { this.date = Date.parse('6:45:25AM') }, assert: function() { return this.baseline[1].addSeconds(25).equals( this.date ) } }, '6:45:25 A': { run: function() { this.date = Date.parse('6:45:25 A') }, assert: function() { return this.baseline[1].addSeconds(25).equals( this.date ) } }, '6:45:25A': { run: function() { this.date = Date.parse('6:45:25A') }, assert: function() { return this.baseline[1].addSeconds(25).equals( this.date ) } }, '6:45:25 A.M.': { run: function() { this.date = Date.parse('6:45:25 A.M') }, assert: function() { return this.baseline[1].addSeconds(25).equals( this.date ) } } }, 'With Timezones': { setup: function() { this.d = []; this.d[0] = Date.today().set({hour: 22, minute: 30 }).setTimezoneOffset(-500); this.d[1] = Date.today().set({hour: 22 }).setTimezoneOffset(-500); }, '10:30 PM EST': { run: function() { this.date = Date.parse('10:30 PM EST') }, assert: function() { return this.d[0].equals( this.date ) } }, '10:30 PM -0500 : Offset': { run: function() { this.date = Date.parse('10:30 PM -0500') }, assert: function() { return this.d[0].equals( this.date ) } } } , 'Misc': { setup: function() { }, '10:2 == 10:02': { run: function() { this.date = Date.parse('10:2') }, assert: function() { return Date.today().set({hour: 10, minute: 2}).equals( this.date ) } }, '10:2:5 == 10:02:05': { run: function() { this.date = Date.parse('10:2:5') }, assert: function() { return Date.today().set({hour: 10, minute: 2, second: 5}).equals( this.date ) } } } }); $(document).ready( function() { Date.Specification.validate().show() } ); ================================================ FILE: tests/tostring/index.html ================================================ Datejs Test Cases : .toString

.toString

================================================ FILE: tests/tostring/index.js ================================================ Date.Specification = new Specification({ 'en-US': { setup: function() { this.today = new Date().clearTime(); }, '"12:00 AM" : "hh:mm tt"': { run: function() {}, assert: function() { return Date.today().toString("hh:mm tt") == "12:00 AM"; } }, '"12:05 AM" : "hh:mm tt"': { run: function() {}, assert: function() { return Date.today().set({minute: 5}).toString("hh:mm tt") == "12:05 AM"; } }, '"12:00 PM" : "hh:mm tt"': { run: function() {}, assert: function() { return Date.today().set({hour: 12}).toString("hh:mm tt") == "12:00 PM"; } }, '"12:05 PM" : "hh:mm tt"': { run: function() {}, assert: function() { return Date.today().set({hour: 12, minute: 5}).toString("hh:mm tt") == "12:05 PM"; } }, '"December 16, 2007 - 12:00 PM" : "MMMM dd, yyyy - hh:mm tt"': { run: function() {}, assert: function() { return new Date(2007,11,16,12,0,0).toString("MMMM dd, yyyy - hh:mm tt") == "December 16, 2007 - 12:00 PM"; } }, '"December 16, 2007 - 12:00 AM" : "MMMM dd, yyyy - hh:mm tt"': { run: function() {}, assert: function() { return new Date(2007,11,16,0,0,0).toString("MMMM dd, yyyy - hh:mm tt") == "December 16, 2007 - 12:00 AM"; } }, '"December 16, 2007 - 12:51 AM" : "MMMM dd, yyyy - hh:mm tt"': { run: function() {}, assert: function() { return new Date(2007,11,16,0,51,53).toString("MMMM dd, yyyy - hh:mm tt") == "December 16, 2007 - 12:51 AM"; } } }, 'Ordinal suffix, .toString("S")': { setup: function() {}, '1st': { run: function() { }, assert: function() { return (new Date(2008, 0, 1).toString("S") == "st"); } }, '2nd': { run: function() { }, assert: function() { return (new Date(2008, 0, 2).toString("S") == "nd"); } }, '3rd': { run: function() { }, assert: function() { return (new Date(2008, 0, 3).toString("S") == "rd"); } }, '4th': { run: function() { }, assert: function() { return (new Date(2008, 0, 4).toString("S") == "th"); } }, '5th': { run: function() { }, assert: function() { return (new Date(2008, 0, 5).toString("S") == "th"); } }, '6th': { run: function() { }, assert: function() { return (new Date(2008, 0, 6).toString("S") == "th"); } }, '7th': { run: function() { }, assert: function() { return (new Date(2008, 0, 7).toString("S") == "th"); } }, '8th': { run: function() { }, assert: function() { return (new Date(2008, 0, 8).toString("S") == "th"); } }, '9th': { run: function() { }, assert: function() { return (new Date(2008, 0, 9).toString("S") == "th"); } }, '10th': { run: function() { }, assert: function() { return (new Date(2008, 0, 10).toString("S") == "th"); } }, '11th': { run: function() { }, assert: function() { return (new Date(2008, 0, 11).toString("S") == "th"); } }, '12th': { run: function() { }, assert: function() { return (new Date(2008, 0, 12).toString("S") == "th"); } }, '13th': { run: function() { }, assert: function() { return (new Date(2008, 0, 13).toString("S") == "th"); } }, '14th': { run: function() { }, assert: function() { return (new Date(2008, 0, 14).toString("S") == "th"); } }, '15th': { run: function() { }, assert: function() { return (new Date(2008, 0, 15).toString("S") == "th"); } }, '16th': { run: function() { }, assert: function() { return (new Date(2008, 0, 16).toString("S") == "th"); } }, '17th': { run: function() { }, assert: function() { return (new Date(2008, 0, 17).toString("S") == "th"); } }, '18th': { run: function() { }, assert: function() { return (new Date(2008, 0, 18).toString("S") == "th"); } }, '19th': { run: function() { }, assert: function() { return (new Date(2008, 0, 19).toString("S") == "th"); } }, '20th': { run: function() { }, assert: function() { return (new Date(2008, 0, 20).toString("S") == "th"); } }, '21th': { run: function() { }, assert: function() { return (new Date(2008, 0, 21).toString("S") == "st"); } }, '22th': { run: function() { }, assert: function() { return (new Date(2008, 0, 22).toString("S") == "nd"); } }, '23rd': { run: function() { }, assert: function() { return (new Date(2008, 0, 23).toString("S") == "rd"); } }, '24th': { run: function() { }, assert: function() { return (new Date(2008, 0, 24).toString("S") == "th"); } }, '25th': { run: function() { }, assert: function() { return (new Date(2008, 0, 25).toString("S") == "th"); } }, '26th': { run: function() { }, assert: function() { return (new Date(2008, 0, 26).toString("S") == "th"); } }, '27th': { run: function() { }, assert: function() { return (new Date(2008, 0, 27).toString("S") == "th"); } }, '28th': { run: function() { }, assert: function() { return (new Date(2008, 0, 28).toString("S") == "th"); } }, '29th': { run: function() { }, assert: function() { return (new Date(2008, 0, 29).toString("S") == "th"); } }, '30th': { run: function() { }, assert: function() { return (new Date(2008, 0, 30).toString("S") == "th"); } }, '31th': { run: function() { }, assert: function() { return (new Date(2008, 0, 31).toString("S") == "st"); } } } }); $(document).ready( function() { Date.Specification.validate().show() } );